commit 1e75612e829b7645adaa092ea493afcd122eb8a9 Author: Nienna Date: Wed Sep 2 21:48:27 2026 +0800 working diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..59e7c8c --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,269 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "cc" +version = "1.2.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e228eec9be7c17ccb640b59b36a5cd805ea2a564a4c5e162c2f659fea30d3b96" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "datastream-client" +version = "0.0.0" + +[[package]] +name = "datastream-server" +version = "0.0.0" +dependencies = [ + "dns", + "http", + "postgresql-client", + "rustls", + "rustls-pki-types", + "uri", + "webpki-roots", +] + +[[package]] +name = "dns" +version = "0.0.0" +dependencies = [ + "uri", +] + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "html" +version = "0.0.0" + +[[package]] +name = "http" +version = "0.0.0" +dependencies = [ + "rustls", + "rustls-pki-types", + "time", + "uri", + "webpki-roots", +] + +[[package]] +name = "libc" +version = "0.2.186" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "postgresql-client" +version = "0.0.0" + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom", + "libc", + "untrusted", + "windows-sys", +] + +[[package]] +name = "rustls" +version = "0.23.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b92b125634d9b795e7beca796cc790df15a7fb38323bf3196fda83292d06b1f" +dependencies = [ + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pki-types" +version = "1.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30a7197ae7eb376e574fe940d068c30fe0462554a3ddbe4eca7838e049c937a9" +dependencies = [ + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61c429a8649f110dddef65e2a5ad240f747e85f7758a6bccc7e5777bd33f756e" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "time" +version = "0.0.0" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "uri" +version = "0.0.0" + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "web-server" +version = "0.0.0" +dependencies = [ + "rustls", + "rustls-pki-types", + "uri", + "webpki-roots", +] + +[[package]] +name = "webpki-roots" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf85cb06032201fa7c6f829d7db5a7e5aa45bcc0655327713065f6f0576731bf" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "zeroize" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13c156562582aa81c60cb29407084cdb54c4164760106ab78e6c5b0858cf64e" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..daec549 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,13 @@ +[workspace] +resolver = "3" +members = [ + "datastream-server", + "datastream-client", + "postgresql-client", + "html", + "http", + "uri", + "dns", + "time", + "web-server", +] diff --git a/datastream-client/Cargo.toml b/datastream-client/Cargo.toml new file mode 100644 index 0000000..d15dd30 --- /dev/null +++ b/datastream-client/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "datastream-client" +version = "0.0.0" +edition = "2024" + +[dependencies] \ No newline at end of file diff --git a/datastream-client/src/main.rs b/datastream-client/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/datastream-client/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/datastream-server/Cargo.toml b/datastream-server/Cargo.toml new file mode 100644 index 0000000..735230e --- /dev/null +++ b/datastream-server/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "datastream-server" +version = "0.0.0" +edition = "2024" + +[dependencies] +postgresql-client = {path = "../postgresql-client"} +uri = { path = "../uri" } +http = { path = "../http" } +dns = { path = "../dns" } +rustls = { version = "0.23.41", default-features = false, features = ["std", "tls12", "ring"] } +rustls-pki-types = "1.14.1" +webpki-roots = "1.0.8" diff --git a/datastream-server/src/main.rs b/datastream-server/src/main.rs new file mode 100644 index 0000000..006198b --- /dev/null +++ b/datastream-server/src/main.rs @@ -0,0 +1,75 @@ +#![warn(clippy::todo, clippy::unimplemented)] +use std::{io::{Read, Result as IoResult, Write}, net::{IpAddr, TcpStream}, sync::Arc}; + +use postgresql_client::{PsqlSession, Location}; + +use uri::Host; +use http::{Response, parse::parse_response, Header, Request, RequestTarget}; + +fn main() { + println!("Hello, world!"); + let psql_session = PsqlSession::connect(None).unwrap(); +} + +fn todostuff() { + todo!() +} + +//WIP: Tear apart and reconfigure structure. +fn fetch_resource_http(host: Host, path: String) -> Result { + let request = Request { + method: http::Method::Get, + version: http::HttpVersion::Http11, + target: RequestTarget::Origin(path), + headers: vec![Header::Host(host.clone())], + body: vec![], + }; + + //Connect to a host. + + let mut connection = TcpStream::connect((match host { + Host::Ip(ip_addr) => ip_addr, + Host::Name(domain) => dns::lookup_via_system(domain).unwrap()[0], + }, 443)).unwrap(); + + // Negotiate a TLS connection. + + let root_store = rustls::RootCertStore::from_iter( + webpki_roots::TLS_SERVER_ROOTS + .iter() + .cloned(), + ); + + let config = rustls::ClientConfig::builder() + .with_root_certificates(root_store) + .with_no_client_auth(); + + let rc_config = Arc::new(config); + let example_com = "example.com".try_into().unwrap(); + let mut client = rustls::ClientConnection::new(rc_config, example_com).unwrap(); + + //Get the writer + + let mut writer = client.writer(); + + // Start sending data + + request.write_to(&mut writer).unwrap(); + + loop { + let mut buf = vec!(); + if client.wants_read() && connection.peek(&mut buf).is_ok() { + client.read_tls(&mut connection).unwrap(); + client.process_new_packets().unwrap(); + + let mut plaintext = vec!(); + client.reader().read_to_end(&mut plaintext).unwrap(); + + match parse_response(&plaintext) { + Ok(Some(r)) => return Ok(r), //We have a complete response. + Ok(None) => continue, // We need more bytes, keep reading. + Err(e) => panic!(), // Some error, return. + }; + } + } +} \ No newline at end of file diff --git a/dns/Cargo.toml b/dns/Cargo.toml new file mode 100644 index 0000000..0717ead --- /dev/null +++ b/dns/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "dns" +version = "0.0.0" +edition = "2024" + +[dependencies] +uri = {path = "../uri"} diff --git a/dns/README.md b/dns/README.md new file mode 100644 index 0000000..f212947 --- /dev/null +++ b/dns/README.md @@ -0,0 +1,2 @@ +A basic dns lookup library. +Trying to be just a bit more complicated that using the system lookup, with options for custom dns server lookup \ No newline at end of file diff --git a/dns/src/lib.rs b/dns/src/lib.rs new file mode 100644 index 0000000..cfcb95e --- /dev/null +++ b/dns/src/lib.rs @@ -0,0 +1,208 @@ +mod parse; +mod message; + +use message::{Header}; +use uri::HostName; + +use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; + +#[derive(Debug,Copy,Clone)] +pub enum Error { + ServerNotFound, + RecordNotFound, + ConnectionTerminated, +} + + +pub type Result = std::result::Result; + +#[repr(u16)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub enum RecordType { + Reserved = 0, + A = 1, + NS = 2, + MD = 3, + MF = 4, + CNAME = 5, + SOA = 6, + MB = 7, + MG = 8, + MR = 9, + NULL = 10, + WKS = 11, + PTR = 12, + HINFO = 13, + MINFO = 14, + MX = 15, + TXT = 16, + RP = 17, + AFSDB = 18, + X25 = 19, + ISDN = 20, + RT = 21, + NSAP = 22, + NSAP_PTR = 23, + SIG = 24, + KEY = 25, + PX = 26, + GPOS = 27, + AAAA = 28, + LOC = 29, + NXT = 30, + EID = 31, + NIMLOC = 32, + SRV = 33, + ATMA = 34, + NAPTR = 35, + KX = 36, + CERT = 37, + A6 = 38, + DNAME = 39, + SINK = 40, + OPT = 41, + APL = 42, + DS = 43, + SSHFP = 44, + IPSECKEY = 45, + RRSIG = 46, + NSEC = 47, + DNSKEY = 48, + DHCID = 49, + NSEC3 = 50, + NSEC3PARAM = 51, + TLSA = 52, + SMIMEA = 53, + HIP = 55, + NINFO = 56, + RKEY = 57, + TALINK = 58, + CDS = 59, + CDNSKEY = 60, + OPENPGPKEY = 61, + CSYNC = 62, + ZONEMD = 63, + SVCB = 64, + HTTPS = 65, + DSYNC = 66, + HHIT = 67, + BRID = 68, + SPF = 99, + UINFO = 100, + UID = 101, + GID = 102, + UNSPEC = 103, + NID = 104, + L32 = 105, + L64 = 106, + LP = 107, + EUI48 = 108, + EUI64 = 109, + NXNAME = 128, + TKEY = 249, + TSIG = 250, + IXFR = 251, + AXFR = 252, + MAILB = 253, + MAILA = 254, + ANY = 255, + URI = 256, + CAA = 257, + AVC = 258, + DOA = 259, + AMTRELAY = 260, + RESINFO = 261, + WALLET = 262, + CLA = 263, + IPN = 264, + TA = 32768, + DLV = 32769, +} + + +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub enum Record { + A { + addr: Ipv4Addr, + }, + AAAA { + addr: Ipv6Addr, + }, + NS { + host: String, + }, + CNAME { + host: String, + }, + SOA { + mname: String, + rname: String, + serial: u32, + refresh: u32, + retry: u32, + expire: u32, + minimum: u32, + }, + MX { + preference: u16, + exchange: String, + }, + TXT { + text: Vec, + }, + SRV { + priority: u16, + weight: u16, + port: u16, + target: String, + }, + PTR { + host: String, + }, + CAA { + flags: u8, + tag: String, + value: Vec, + }, + DS { + key_tag: u16, + algorithm: u8, + digest_type: u8, + digest: Vec, + }, + DNSKEY { + flags: u16, + protocol: u8, + algorithm: u8, + public_key: Vec, + }, + RRSIG { + type_covered: u16, + algorithm: u8, + labels: u8, + original_ttl: u32, + signature_expiration: u32, + signature_inception: u32, + key_tag: u16, + signer_name: String, + signature: Vec, + }, + Unknown { + typ: u16, + data: Vec, + }, +} + +pub fn lookup_via_system(name: HostName) -> Result> { + todo!() +} + +pub fn lookup_via_server(server: IpAddr) -> Result { + todo!() +} + +#[cfg(test)] +mod tests { + use super::*; + +} diff --git a/dns/src/message.rs b/dns/src/message.rs new file mode 100644 index 0000000..cdf8142 --- /dev/null +++ b/dns/src/message.rs @@ -0,0 +1,48 @@ + +pub struct Header { + id: u16, + message_type: MessageType, + query_type: QueryType, + is_authority: bool, + is_truncated: bool, + recursion_desired: bool, + recursion_available: bool, + response_code: ResponseCode, + num_question_entries: u16, + num_answer_entries: u16, + num_nameserver_records: u16, + num_additonal_records: u16, +} + +pub struct Question { + +} + +pub struct Resource { + +} + +#[repr(u8)] +pub enum MessageType { + Query = 0, + Response = 1, +} + +#[repr(u8)] +pub enum QueryType { + Query = 0, + InverseQuery = 1, + Status = 2, + Other = 15, +} + +#[repr(u8)] +pub enum ResponseCode { + Ok = 0, + FormatError = 1, + ServerFailure = 2, + NameError = 3, + NotImplemented = 4, + Refused = 5, + Other = 15, +} \ No newline at end of file diff --git a/dns/src/parse.rs b/dns/src/parse.rs new file mode 100644 index 0000000..4759f4d --- /dev/null +++ b/dns/src/parse.rs @@ -0,0 +1,24 @@ +use crate::message::Header; + + +enum ParseError { + +} + +type Result = std::result::Result; + +fn parse_header(input: &[u8]) -> Result> { + todo!() +} + +fn parse_question_section(input: &[u8]) -> Result> { + todo!() +} + +fn parse_record_section(input: &[u8]) -> Result> { + todo!() +} + +fn parse_message(input: &[u8]) -> Result> { + todo!() +} diff --git a/html/Cargo.toml b/html/Cargo.toml new file mode 100644 index 0000000..08c360c --- /dev/null +++ b/html/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "html" +version = "0.0.0" +edition = "2024" + +[dependencies] \ No newline at end of file diff --git a/html/src/lib.rs b/html/src/lib.rs new file mode 100644 index 0000000..b93cf3f --- /dev/null +++ b/html/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: u64, right: u64) -> u64 { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} diff --git a/http/.cargo/config.toml b/http/.cargo/config.toml new file mode 100644 index 0000000..11bdee2 --- /dev/null +++ b/http/.cargo/config.toml @@ -0,0 +1,6 @@ +[source.crates-io] +replace-with = "vendored-sources" + +[source.vendored-sources] +directory = "vendor" + diff --git a/http/Cargo.toml b/http/Cargo.toml new file mode 100644 index 0000000..3f0f0f2 --- /dev/null +++ b/http/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "http" +version = "0.0.0" +edition = "2024" + +[dependencies] +rustls = { version = "0.23.41", default-features = false, features = ["std", "tls12", "ring"] } +rustls-pki-types = "1.14.1" +webpki-roots = "1.0.8" +uri = { path = "../uri" } +time = { path = "../time" } diff --git a/http/src/header.rs b/http/src/header.rs new file mode 100644 index 0000000..3a238b8 --- /dev/null +++ b/http/src/header.rs @@ -0,0 +1,36 @@ +use time::GregorianDateTime; + +use crate::Host; + +//WIP: Research and write more variants +pub enum Header { + Host(Host), + UserAgent(String), + Accept(Vec<(ContentType, Option)>), + ContentType(ContentType), + AcceptLanguage(Vec<(String, Option)>), + AcceptEncoding(Vec<(Encoding, Option)>), + ContentEncoding(Vec), + Cookie(Vec), + Priority(bool), + IfModifiedSince(GregorianDateTime), + Other(String,String), +} + +//WIP: More Variants +pub enum Encoding { + Gzip, + Compress, + Deflate, + Br, + Zstd, + Dcb, + Dcz, + Identity, + Wildcard, +} + +//TODO: Research variants and actually write +pub enum ContentType { + +} diff --git a/http/src/lib.rs b/http/src/lib.rs new file mode 100644 index 0000000..8e5575b --- /dev/null +++ b/http/src/lib.rs @@ -0,0 +1,75 @@ +#![warn(clippy::todo, clippy::unimplemented)] + +mod statuscode; +pub mod parse; +mod request; +mod response; +mod header; + +pub use {request::{Request, RequestTarget}, + response::{Response}, statuscode::{StatusCode, StatusClass}, header::Header}; + +use std::fmt::Display; + +use parse::ParseError; + +pub use uri::Host; + +#[derive(Debug, PartialEq)] +pub enum HttpError { + Parse(ParseError), +} + +#[derive(Debug, PartialEq)] +pub enum HttpVersion { + Http10, + Http11, + Http20, + Http30, +} + +impl Display for HttpVersion { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str(match self { + HttpVersion::Http10 => "HTTP/1.0", + HttpVersion::Http11 => "HTTP/1.1", + HttpVersion::Http20 => "HTTP/2", + HttpVersion::Http30 => "HTTP/3", + }) + } +} + +#[derive(Debug, PartialEq)] +pub enum Method { + Get, + Head, + Post, + Put, + Delete, + Connect, + Options, + Trace, + Patch, +} + +impl Method { + pub fn from_bytes(bytes: &[u8]) -> Result { + todo!() + } +} + +impl Display for Method { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str(match self { + Method::Get => "GET", + Method::Head => "HEAD", + Method::Post => "POST", + Method::Put => "PUT", + Method::Delete => "DELETE", + Method::Connect => "CONNECT", + Method::Options => "OPTIONS", + Method::Trace => "TRACE", + Method::Patch => "PATCH", + }) + } +} \ No newline at end of file diff --git a/http/src/parse.rs b/http/src/parse.rs new file mode 100644 index 0000000..6aba7ca --- /dev/null +++ b/http/src/parse.rs @@ -0,0 +1,377 @@ +use crate::{HttpVersion, Method, request::{Request, RequestTarget}, response::Response, statuscode::{StatusClass, StatusCode}}; + +#[derive(Debug, PartialEq)] +pub enum ParseError { + TooLong, + Malformed, + BadStatusCode, + BadVersion, + InvalidEncoding, + MissingChunkSize, +} + +#[derive(Debug, PartialEq)] +pub struct StatusLine { + version: HttpVersion, + status: Status, + reason: Vec, +} + +pub struct RequestLine { + pub method: Method, + pub target: RequestTarget, + pub version: HttpVersion, +} + +#[derive(Debug, PartialEq)] +pub struct Status { + pub code: u16, +} + +impl Status { + pub fn known(self) -> Option { + StatusCode::from_u16(self.code) + } + + pub fn class(self) -> Option { + match self.code / 100 { + 1 => Some(StatusClass::Informational), + 2 => Some(StatusClass::Success), + 3 => Some(StatusClass::Redirection), + 4 => Some(StatusClass::ClientError), + 5 => Some(StatusClass::ServerError), + _ => None, + } + } +} + +const MAX_STATUS_LINE_LEN: usize = 8192; + +//TODO: Further testing + fuzzing + general onceover +pub fn parse_status_line(input: &[u8], request_type: Method) -> Result, ParseError> { + let search_end = input.len().min(MAX_STATUS_LINE_LEN); + let line_end = match find_crlf(&input[..search_end]) { + Some(pos) => pos, + None => { + if input.len() >= MAX_STATUS_LINE_LEN { + return Err(ParseError::TooLong); + } + return Ok(None); + } + }; + + let line = &input[..line_end]; + + let first_space = line.iter().position(|&b| b.is_ascii_whitespace()) + .ok_or(ParseError::Malformed)?; + let version_bytes = &line[..first_space]; + let after_version = line[first_space + 1..].trim_ascii_start(); + + let (status_bytes, reason_bytes) = match after_version.iter().position(|&b| b.is_ascii_whitespace()) { + Some(p) => (after_version[..p].trim_ascii_end(), after_version[p + 1..].trim_ascii()), + None => (after_version.trim_ascii_end(), &[][..]), + }; + + let version = match version_bytes { + b"HTTP/1.1" => HttpVersion::Http11, + b"HTTP/1.0" => HttpVersion::Http10, + _ => return Err(ParseError::BadVersion), + }; + + if status_bytes.len() != 3 { + return Err(ParseError::BadStatusCode); + } + let mut status: u16 = 0; + for &b in status_bytes { + if !b.is_ascii_digit() { + return Err(ParseError::BadStatusCode); + } + status = status * 10 + (b - b'0') as u16; + } + + Ok(Some(( + StatusLine { + version, + status: Status { code: status }, + reason: reason_bytes.to_vec(), + }, line_end + 2, + ))) +} + +const MAX_REQUEST_LINE_LEN: usize = 8192; + +//TODO: Further testing + fuzzing + general onceover +pub fn parse_request_line(input: &[u8]) -> Result, ParseError> { + let search_end = input.len().min(MAX_REQUEST_LINE_LEN); + let line_end = match find_crlf(&input[..search_end]) { + Some(pos) => pos, + None => { + if input.len() >= MAX_REQUEST_LINE_LEN { + return Err(ParseError::TooLong); + } + return Ok(None); + } + }; + + let line = &input[..line_end]; + + let first_space = line.iter().position(|&b| b.is_ascii_whitespace()) + .ok_or(ParseError::Malformed)?; + let method_bytes = &line[..first_space]; + let after_method = line[first_space + 1..].trim_ascii_start(); + + let (target_bytes, version_bytes) = match after_method.iter().position(|&b| b.is_ascii_whitespace()) { + Some(p) => (after_method[..p].trim_ascii_end(), after_method[p + 1..].trim_ascii()), + None => (after_method.trim_ascii_end(), &[][..]), + }; + + + let method = Method::from_bytes(method_bytes)?; + let target = RequestTarget::from_bytes(target_bytes)?; + let version = match version_bytes { + b"HTTP/1.1" => HttpVersion::Http11, + b"HTTP/1.0" => HttpVersion::Http10, + _ => return Err(ParseError::BadVersion), + }; + + Ok(Some(( + RequestLine { + method, + target, + version, + }, line_end + 2, + ))) +} + +const MAX_HEADERS_SECTION_LEN: usize = 8192; //8KiB + +//TODO: Further testing + fuzzing + general onceover +fn parse_headers(input: &[u8]) -> Result,usize)>, ParseError> { + //Frame the header section. + //let headers_end = match input.windows(4).position(|w| w == b"\r\n\r\n") { + // Some(pos) => pos, + // None => { + // if input.len() >= MAX_HEADERS_SECTION_LEN { + // return Err(ParseError::TooLong); + // } + // return Ok(None); + // } + //}; + + let mut headers = &input[..]; + let mut fields = vec!(); + let mut consumed = 0; + loop { + //if headers.is_empty() { break }; + let line_end = match find_crlf(headers) { + Some(e) => e, + None => return Ok(None), + }; + let line = &headers[..line_end]; + consumed += line_end + 2; + if consumed > MAX_HEADERS_SECTION_LEN { return Err(ParseError::TooLong)} + if line.is_empty() { break }; + let colon = line.iter().position(|&b| b == b':').ok_or(ParseError::Malformed)?; //Fails if no colon on line. + + let field_name = str::from_utf8(&line[..colon]).map_err(|_| ParseError::InvalidEncoding)?.to_owned(); + if field_name.trim_ascii_end().len() != field_name.len() { return Err(ParseError::Malformed) } + let field_value = str::from_utf8(&line[colon+1..]).map_err(|_| ParseError::InvalidEncoding)?.trim_ascii().to_owned(); + + fields.push((field_name,field_value)); + headers = &headers[line_end+2..]; + } + + Ok(Some((fields,consumed))) +} + +//TODO: Further testing + fuzzing + general onceover +fn parse_body(input: &[u8], encoding: Encoding) -> Result, usize)>, ParseError> { + match encoding { + Encoding::Length(l) => Ok(Some((input[..l].to_owned(), l))), + Encoding::Chunked => { parse_chunked_body(input) } + } +} + +//TODO: Further testing + fuzzing + general onceover +fn parse_chunked_body(input: &[u8]) -> Result, usize)>, ParseError> { + let mut chunks = vec!(); + let mut consumed = 0usize; + let mut remaining = &input[..]; + loop { + //Chunk size + extensions (ignored) line. + let line_end = match find_crlf(remaining) { + Some(pos) => pos, + None => return Ok(None), + }; + if line_end == 0 { return Err(ParseError::MissingChunkSize)}; + let chunk_meta = &remaining[..line_end]; + let semicolon = chunk_meta.iter().position(|&p| p == b';').unwrap_or(chunk_meta.len()); + let chunk_size = usize::from_str_radix(str::from_utf8((&chunk_meta[..semicolon]).trim_ascii()).unwrap(), 16).unwrap(); + if chunk_size == 0 { break } + + //Chunk body. + remaining = &remaining[line_end+2..]; consumed += line_end+2; + chunks.push(&remaining[..chunk_size]); + if remaining[chunk_size..chunk_size+2] != [b'\r',b'\n'] { return Err(ParseError::Malformed) } + remaining = &remaining[chunk_size+2..]; consumed += chunk_size+2; + } + Ok(Some((chunks.into_iter().flatten().copied().collect(), consumed))) +} + +//TODO: Write +pub fn parse_request(input: &[u8]) -> Result, ParseError> { + todo!() +} + +//TODO: Write +pub fn parse_response(input: &[u8]) -> Result, ParseError> { + todo!() +} + +enum Encoding { + Length(usize), + Chunked, +} + +fn find_crlf(input: &[u8]) -> Option { + input.windows(2).position(|w| w == b"\r\n") +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_find_crlf() { + assert_eq!(find_crlf(b"\r\n"), Some(0)); + assert_eq!(find_crlf(b"\0\r\n"), Some(1)); + assert_eq!(find_crlf(b"not here"), None); + assert_eq!(find_crlf(b"\n"), None); + assert_eq!(find_crlf(b"\r"), None); + assert_eq!(find_crlf(b"\n\r"), None); + } + + #[test] + fn test_parse_status_line() { + assert_eq!(parse_status_line(b"HTTP/1.1 100 reason\r\nSOMEOTHERSHIT", Method::Get), + Ok(Some(( StatusLine { version: HttpVersion::Http11, status: Status { code: 100 }, reason: b"reason".as_slice().to_owned() }, + 21, + )))); + assert_eq!(parse_status_line(b"HTTP/1.1 300 reason \r\nSOMEOTHERSHIT", Method::Get), + Ok(Some(( StatusLine { version: HttpVersion::Http11, status: Status { code: 300 }, reason: b"reason".as_slice().to_owned() }, + 35, + )))); + assert_eq!(parse_status_line(b"HTTP/1.0 400 Some other reason\r\nSOMEOTHERSHIT", Method::Get), + Ok(Some(( StatusLine { version:HttpVersion::Http10, status: Status { code: 400 }, reason: b"Some other reason".as_slice().to_owned() }, + 32, + )))); + } + + #[test] + fn test_parse_status_line_invalid_version() { + assert_eq!(parse_status_line(b"HP/1.0 400 Some other reason\r\nSOMEOTHERSHIT", Method::Get), + Err(ParseError::BadVersion) + ); + assert_eq!(parse_status_line(b"HTTP/1.2 400 Some other reason\r\nSOMEOTHERSHIT", Method::Get), + Err(ParseError::BadVersion) + ); + assert_eq!(parse_status_line(b"HTTP/2.1 400 Some other reason\r\nSOMEOTHERSHIT", Method::Get), + Err(ParseError::BadVersion) + ); + assert_eq!(parse_status_line(b"HTTP/1 400 Some other reason\r\nSOMEOTHERSHIT", Method::Get), + Err(ParseError::BadVersion) + ); + assert_eq!(parse_status_line(b"HTTP/3 400 Some other reason\r\nSOMEOTHERSHIT", Method::Get), + Err(ParseError::BadVersion) + ); + } + + #[test] + fn test_parse_status_line_invalid_code() { + assert_eq!(parse_status_line(b"HTTP/1.1 0400 Some other reason\r\nSOMEOTHERSHIT", Method::Get), + Err(ParseError::BadStatusCode) + ); + + assert_eq!(parse_status_line(b"HTTP/1.1 4000 Some other reason\r\nSOMEOTHERSHIT", Method::Get), + Err(ParseError::BadStatusCode) + ); + + assert_eq!(parse_status_line(b"HTTP/1.1 040.0 Some other reason\r\nSOMEOTHERSHIT", Method::Get), + Err(ParseError::BadStatusCode) + ); + + assert_eq!(parse_status_line(b"HTTP/1.1 04 Some other reason\r\nSOMEOTHERSHIT", Method::Get), + Err(ParseError::BadStatusCode) + ); + + assert_eq!(parse_status_line(b"HTTP/1.1 0x64 Some other reason\r\nSOMEOTHERSHIT", Method::Get), + Err(ParseError::BadStatusCode) + ); + } + + #[test] + fn test_parse_status_line_no_reason() { + assert_eq!(parse_status_line(b"HTTP/1.1 100\r\nSOMEOTHERSHIT", Method::Get), + Ok(Some(( StatusLine { version: HttpVersion::Http11, status: Status { code: 100 }, reason: b"".as_slice().to_owned() }, + 14, + )))); + + assert_eq!(parse_status_line(b"HTTP/1.1 100 \t \r\nSOMEOTHERSHIT", Method::Get), + Ok(Some(( StatusLine { version: HttpVersion::Http11, status: Status { code: 100 }, reason: b"".as_slice().to_owned() }, + 17, + )))); + } + + #[test] + fn test_parse_status_line_empty() { + assert_eq!(parse_status_line(b"\r\n", Method::Get), Err(ParseError::Malformed)); + assert_eq!(parse_status_line(b"", Method::Get), Ok(None)); + } + + #[test] + fn test_parse_status_line_oversize() { + let bytes = [b'1';65521]; + assert_eq!(parse_status_line(&bytes, Method::Get), Err(ParseError::TooLong)); + } + + #[test] + fn test_parse_status_line_incomplete() { + assert_eq!(parse_status_line(b"", Method::Get), Ok(None)); + } + + #[test] + fn test_parse_headers() { + assert_eq!(parse_headers(b"Field1: Field value is this mate\r\n\r\n"), Ok(Some((vec![("Field1".to_owned(),"Field value is this mate".to_owned())], 36)))); + } + + #[test] + fn test_parse_headers_whitespace_in_name() { + assert_eq!(parse_headers(b"Field1 : Field value is this mate\r\n\r\n"), Err(ParseError::Malformed)); + } + + #[test] + fn test_parse_headers_incomplete() { + assert_eq!(parse_headers(b"Field1: field value is this mate \r\n"), Ok(None)); + } + + #[test] + fn test_parse_headers_too_long() { + let mut bytes = [b'\0';8196]; + for i in 0..2049 { + bytes[i*4] = b'f'; + bytes[i*4+1] = b':'; + bytes[i*4+2] = b'\r'; + bytes[i*4+3] = b'\n'; + } + assert_eq!(parse_headers(&bytes), Err(ParseError::TooLong)); + + let mut bytes = [b'\0';8192]; + for i in 0..2048 { + bytes[i*4] = b'f'; + bytes[i*4+1] = b':'; + bytes[i*4+2] = b'\r'; + bytes[i*4+3] = b'\n'; + } + assert_ne!(parse_headers(&bytes), Err(ParseError::TooLong)); + } +} diff --git a/http/src/parse2.rs b/http/src/parse2.rs new file mode 100644 index 0000000..e69de29 diff --git a/http/src/request.rs b/http/src/request.rs new file mode 100644 index 0000000..ad8418c --- /dev/null +++ b/http/src/request.rs @@ -0,0 +1,129 @@ +use std::io::{Write, Result as IoResult}; + +use uri::{Host, Uri}; +use time::{Utc}; + +use crate::{HttpVersion, Method, parse::ParseError, header::Header}; + +///For Serialization. Does no extra processing of the contents otherwise. +/// Pre-fill with things like required headers, etc. +pub struct Request { + pub method: Method, + pub version: HttpVersion, + pub target: RequestTarget, + pub headers: Vec
, + pub body: Vec, +} + + +pub enum RequestTarget { + Origin(String), + Absolute(Uri), + Authority(Host,u16), + Asterisk, +} + +impl RequestTarget { + //TODO: Write + pub fn from_bytes(bytes: &[u8]) -> Result { + todo!() + } + + /// Write to a Writer. Outputs in the format expected by HTTP 1.1 for the request target in the request line. + fn write_to(&self, w: &mut W) -> IoResult<()> { + match self { + RequestTarget::Origin(o) => w.write_all(b"/").and(w.write_all(o.as_bytes())), + RequestTarget::Absolute(uri) => uri.write_to(w), + RequestTarget::Authority(host,port) => host.write_to(w).and(w.write_all(b":")).and(w.write_all(port.to_string().as_bytes())), + RequestTarget::Asterisk => w.write_all(b"*"), + }.and(w.write_all(b"/")) + } +} + + +impl Request { + fn write_request_line(&self, w: &mut W) -> IoResult<()> { + w.write_all(self.method.to_string().as_bytes())?; + w.write_all(b" ")?; + self.target.write_to(w); + w.write_all(b" ")?; + w.write_all(self.version.to_string().as_bytes())?; + w.write_all(b"\r\n") + } + + pub fn write_to(&self, w: &mut W) -> IoResult<()> { + self.write_request_line(w)?; + for header in &self.headers { + header.write_to(w)?; + w.write_all(b"\r\n")?; + } + w.write_all(b"\r\n")?; + w.write_all(self.body.as_slice()) + } +} + +impl Header { + //WIP: More variants + /// Returns true if the header is permitted to be sent in a request. + fn is_request_header(&self) -> bool { + use Header::*; + match self { + Host(_) | UserAgent(_) | Accept(_) => true, + _ => false, + } + } + + //WIP: More variants + /// Returns true if the header is permitted to be sent in a response. + fn is_response_header(&self) -> bool { + use Header::*; + match self { + ContentEncoding(_) | ContentType(_) => true, + _ => false, + } + } + + fn name_as_bytes(&self) -> &[u8] { + match self { + Header::Host(_) => b"Host", + Header::UserAgent(_) => b"User-Agent", + Header::Accept(_) => b"Accept", + Header::ContentType(_) => b"Content-Type", + Header::AcceptLanguage(_) => b"Accept-Language", + Header::AcceptEncoding(_) => b"Accept-Encoding", + Header::ContentEncoding(_) => b"Content-Encoding", + Header::Cookie(_) => b"Cookie", + Header::Priority(_) => b"Priority", + Header::IfModifiedSince(_) => b"If-Modified-Since", + Header::Other(name, _) => name.as_str().as_bytes(), + } + } + + fn value_as_bytes(&self) -> &[u8] { + match self { + Header::Host(host) => todo!(), + Header::UserAgent(agent) => todo!(), + Header::Accept(items) => todo!(), + Header::ContentType(content_type) => todo!(), + Header::AcceptLanguage(items) => todo!(), + Header::AcceptEncoding(items) => todo!(), + Header::ContentEncoding(encodings) => todo!(), + Header::Cookie(items) => todo!(), + Header::Priority(priority) => todo!(), + Header::IfModifiedSince(utc) => todo!(), + Header::Other(_, value) => value.as_str().as_bytes(), + } + } + + //TODO: Write + fn write_value_to(&self, w: &mut W) -> IoResult<()> { + todo!(); + } + + fn write_to(&self, w: &mut W) -> IoResult<()> { + w.write_all(self.name_as_bytes())?; + w.write_all(b": ")?; + w.write_all(self.value_as_bytes())?; + Ok(()) + } +} diff --git a/http/src/response.rs b/http/src/response.rs new file mode 100644 index 0000000..46eb2d9 --- /dev/null +++ b/http/src/response.rs @@ -0,0 +1,15 @@ + +use std::io::{Write, Result as IoResult}; + +use uri::{Host, Uri}; +use time::{Utc}; + +use crate::{HttpVersion, Method, header::Header, statuscode::StatusCode}; + +pub struct Response { + pub status_code: StatusCode, + pub reason: String, + pub version: HttpVersion, + pub headers: Vec
, + pub body: Vec, +} \ No newline at end of file diff --git a/http/src/statuscode.rs b/http/src/statuscode.rs new file mode 100644 index 0000000..9841422 --- /dev/null +++ b/http/src/statuscode.rs @@ -0,0 +1,316 @@ +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[repr(u16)] +pub enum StatusCode { + // 1xx Informational + Continue = 100, + SwitchingProtocols = 101, + Processing = 102, + EarlyHints = 103, + + // 2xx Success + Ok = 200, + Created = 201, + Accepted = 202, + NonAuthoritativeInformation = 203, + NoContent = 204, + ResetContent = 205, + PartialContent = 206, + MultiStatus = 207, + AlreadyReported = 208, + ImUsed = 226, + + // 3xx Redirection + MultipleChoices = 300, + MovedPermanently = 301, + Found = 302, + SeeOther = 303, + NotModified = 304, + UseProxy = 305, + // 306 is reserved and unused + TemporaryRedirect = 307, + PermanentRedirect = 308, + + // 4xx Client Error + BadRequest = 400, + Unauthorized = 401, + PaymentRequired = 402, + Forbidden = 403, + NotFound = 404, + MethodNotAllowed = 405, + NotAcceptable = 406, + ProxyAuthenticationRequired = 407, + RequestTimeout = 408, + Conflict = 409, + Gone = 410, + LengthRequired = 411, + PreconditionFailed = 412, + ContentTooLarge = 413, + UriTooLong = 414, + UnsupportedMediaType = 415, + RangeNotSatisfiable = 416, + ExpectationFailed = 417, + ImATeapot = 418, + MisdirectedRequest = 421, + UnprocessableContent = 422, + Locked = 423, + FailedDependency = 424, + TooEarly = 425, + UpgradeRequired = 426, + PreconditionRequired = 428, + TooManyRequests = 429, + RequestHeaderFieldsTooLarge = 431, + UnavailableForLegalReasons = 451, + + // 5xx Server Error + InternalServerError = 500, + NotImplemented = 501, + BadGateway = 502, + ServiceUnavailable = 503, + GatewayTimeout = 504, + HttpVersionNotSupported = 505, + VariantAlsoNegotiates = 506, + InsufficientStorage = 507, + LoopDetected = 508, + NotExtended = 510, + NetworkAuthenticationRequired = 511, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum StatusClass { + Informational, // 1xx + Success, // 2xx + Redirection, // 3xx + ClientError, // 4xx + ServerError, // 5xx +} + +impl StatusCode { + /// Convert a raw u16 into a StatusCode. Returns None for unrecognized codes. + pub fn from_u16(code: u16) -> Option { + Some(match code { + 100 => Self::Continue, + 101 => Self::SwitchingProtocols, + 102 => Self::Processing, + 103 => Self::EarlyHints, + + 200 => Self::Ok, + 201 => Self::Created, + 202 => Self::Accepted, + 203 => Self::NonAuthoritativeInformation, + 204 => Self::NoContent, + 205 => Self::ResetContent, + 206 => Self::PartialContent, + 207 => Self::MultiStatus, + 208 => Self::AlreadyReported, + 226 => Self::ImUsed, + + 300 => Self::MultipleChoices, + 301 => Self::MovedPermanently, + 302 => Self::Found, + 303 => Self::SeeOther, + 304 => Self::NotModified, + 305 => Self::UseProxy, + 307 => Self::TemporaryRedirect, + 308 => Self::PermanentRedirect, + + 400 => Self::BadRequest, + 401 => Self::Unauthorized, + 402 => Self::PaymentRequired, + 403 => Self::Forbidden, + 404 => Self::NotFound, + 405 => Self::MethodNotAllowed, + 406 => Self::NotAcceptable, + 407 => Self::ProxyAuthenticationRequired, + 408 => Self::RequestTimeout, + 409 => Self::Conflict, + 410 => Self::Gone, + 411 => Self::LengthRequired, + 412 => Self::PreconditionFailed, + 413 => Self::ContentTooLarge, + 414 => Self::UriTooLong, + 415 => Self::UnsupportedMediaType, + 416 => Self::RangeNotSatisfiable, + 417 => Self::ExpectationFailed, + 418 => Self::ImATeapot, + 421 => Self::MisdirectedRequest, + 422 => Self::UnprocessableContent, + 423 => Self::Locked, + 424 => Self::FailedDependency, + 425 => Self::TooEarly, + 426 => Self::UpgradeRequired, + 428 => Self::PreconditionRequired, + 429 => Self::TooManyRequests, + 431 => Self::RequestHeaderFieldsTooLarge, + 451 => Self::UnavailableForLegalReasons, + + 500 => Self::InternalServerError, + 501 => Self::NotImplemented, + 502 => Self::BadGateway, + 503 => Self::ServiceUnavailable, + 504 => Self::GatewayTimeout, + 505 => Self::HttpVersionNotSupported, + 506 => Self::VariantAlsoNegotiates, + 507 => Self::InsufficientStorage, + 508 => Self::LoopDetected, + 510 => Self::NotExtended, + 511 => Self::NetworkAuthenticationRequired, + + _ => return None, + }) + } + + /// Get the numeric value. Since the enum is #[repr(u16)], this is a no-op cast. + pub fn as_u16(self) -> u16 { + self as u16 + } + + /// Classify by the hundreds digit. + pub fn class(self) -> StatusClass { + match self.as_u16() / 100 { + 1 => StatusClass::Informational, + 2 => StatusClass::Success, + 3 => StatusClass::Redirection, + 4 => StatusClass::ClientError, + 5 => StatusClass::ServerError, + _ => unreachable!("all StatusCode variants are 1xx-5xx"), + } + } + + pub fn is_informational(self) -> bool { matches!(self.class(), StatusClass::Informational) } + pub fn is_success(self) -> bool { matches!(self.class(), StatusClass::Success) } + pub fn is_redirection(self) -> bool { matches!(self.class(), StatusClass::Redirection) } + pub fn is_client_error(self) -> bool { matches!(self.class(), StatusClass::ClientError) } + pub fn is_server_error(self) -> bool { matches!(self.class(), StatusClass::ServerError) } + + /// The default reason phrase. Servers can send anything they like; + /// this is what the registry recommends. + pub fn canonical_reason(self) -> &'static str { + match self { + Self::Continue => "Continue", + Self::SwitchingProtocols => "Switching Protocols", + Self::Processing => "Processing", + Self::EarlyHints => "Early Hints", + + Self::Ok => "OK", + Self::Created => "Created", + Self::Accepted => "Accepted", + Self::NonAuthoritativeInformation => "Non-Authoritative Information", + Self::NoContent => "No Content", + Self::ResetContent => "Reset Content", + Self::PartialContent => "Partial Content", + Self::MultiStatus => "Multi-Status", + Self::AlreadyReported => "Already Reported", + Self::ImUsed => "IM Used", + + Self::MultipleChoices => "Multiple Choices", + Self::MovedPermanently => "Moved Permanently", + Self::Found => "Found", + Self::SeeOther => "See Other", + Self::NotModified => "Not Modified", + Self::UseProxy => "Use Proxy", + Self::TemporaryRedirect => "Temporary Redirect", + Self::PermanentRedirect => "Permanent Redirect", + + Self::BadRequest => "Bad Request", + Self::Unauthorized => "Unauthorized", + Self::PaymentRequired => "Payment Required", + Self::Forbidden => "Forbidden", + Self::NotFound => "Not Found", + Self::MethodNotAllowed => "Method Not Allowed", + Self::NotAcceptable => "Not Acceptable", + Self::ProxyAuthenticationRequired => "Proxy Authentication Required", + Self::RequestTimeout => "Request Timeout", + Self::Conflict => "Conflict", + Self::Gone => "Gone", + Self::LengthRequired => "Length Required", + Self::PreconditionFailed => "Precondition Failed", + Self::ContentTooLarge => "Content Too Large", + Self::UriTooLong => "URI Too Long", + Self::UnsupportedMediaType => "Unsupported Media Type", + Self::RangeNotSatisfiable => "Range Not Satisfiable", + Self::ExpectationFailed => "Expectation Failed", + Self::ImATeapot => "I'm a teapot", + Self::MisdirectedRequest => "Misdirected Request", + Self::UnprocessableContent => "Unprocessable Content", + Self::Locked => "Locked", + Self::FailedDependency => "Failed Dependency", + Self::TooEarly => "Too Early", + Self::UpgradeRequired => "Upgrade Required", + Self::PreconditionRequired => "Precondition Required", + Self::TooManyRequests => "Too Many Requests", + Self::RequestHeaderFieldsTooLarge => "Request Header Fields Too Large", + Self::UnavailableForLegalReasons => "Unavailable For Legal Reasons", + + Self::InternalServerError => "Internal Server Error", + Self::NotImplemented => "Not Implemented", + Self::BadGateway => "Bad Gateway", + Self::ServiceUnavailable => "Service Unavailable", + Self::GatewayTimeout => "Gateway Timeout", + Self::HttpVersionNotSupported => "HTTP Version Not Supported", + Self::VariantAlsoNegotiates => "Variant Also Negotiates", + Self::InsufficientStorage => "Insufficient Storage", + Self::LoopDetected => "Loop Detected", + Self::NotExtended => "Not Extended", + Self::NetworkAuthenticationRequired => "Network Authentication Required", + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + fn test_enum() { + + } + + #[test] + fn test_class() { + + } + + #[test] + fn is_informational() { + + } + + #[test] + fn is_success() { + + } + + #[test] + fn is_redirection() { + + } + + #[test] + fn is_client_error() { + + } + + #[test] + fn is_server_error() { + + } + + #[test] + fn test_canonical_reason() { + assert_eq!(StatusCode::Continue.canonical_reason(), "Continue"); + assert_ne!(StatusCode::Continue.canonical_reason(), "Ok"); + } + + #[test] + fn test_as_u16() { + assert_eq!(StatusCode::Continue.as_u16(), 100); + } + + #[test] + fn test_from_u16() { + assert_eq!(StatusCode::from_u16(100), Some(StatusCode::Continue)); + assert_eq!(StatusCode::from_u16(600), None); + assert_eq!(StatusCode::from_u16(1000), None); + assert_eq!(StatusCode::from_u16(0100), Some(StatusCode::Continue)); + assert_eq!(StatusCode::from_u16(001), None); + } +} \ No newline at end of file diff --git a/http/vendor/cc/.cargo-checksum.json b/http/vendor/cc/.cargo-checksum.json new file mode 100644 index 0000000..8380c54 --- /dev/null +++ b/http/vendor/cc/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{".cargo_vcs_info.json":"cf5afb0cbc1d9c66b3a9f8bc0c7d07834c0e41ab52fe7b6e1cdf6e96a197b1be","CHANGELOG.md":"9eb80365dff5691558d4e261eb82ef768e733ff3d5b5403e3cdd18d68dd33370","Cargo.lock":"5a0c090548b2ea7602c3a4e8ca7f8d1f4538dc875dd28d7aa22b7e9a376556f7","Cargo.toml":"7b6349fd108dec1ed9a187322dea88fa2e8cce55dbceab956451412e6530fdaf","Cargo.toml.orig":"2f3281a08d13b585f7808e0775a17e9cd32d7b8be41cfe95d9c1a1c5a970450c","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"cc952a506dc726eed3e128d47d62defbac4470bbb0e465f6a043ae8bf0c96d19","clippy.toml":"cf46251b0953d1a3c7a4f8f8941a08d8a416d5fc348dfe3f3c520eb93fcc18ea","src/command_helpers.rs":"650c9682edc3d7732249e327c1026c7cc733f3702f4867b9580223e97522d3c6","src/detect_compiler_family.c":"97ca4b021495611e828becea6187add37414186a16dfedd26c2947cbce6e8b2f","src/flags.rs":"11f22aa9741b0d445b19ab29ea1076cc32a4143316a74855b6bd682004217543","src/lib.rs":"81899387bcfec723c52e40f50a8af9fef00fb9fd75e0392c5f2658b72e084b4c","src/parallel/async_executor.rs":"4ce24435fff6b6555b43fee042c16bd65d4150d0346567f246b9190d85b45983","src/parallel/command_runner.rs":"1d17d9a037de93b31cc7ee6a914a1e1f6c1ac156cf8619f0014dcbaca6a0b215","src/parallel/job_token.rs":"858b684423bce773d04a042f3f9bafbd21deda21bbb1efefb078a20ef5d8a134","src/parallel/mod.rs":"bf156170790d40a76015a8c78cc2a391cbe1b60bb96c1fac1d047d26e342386a","src/parallel/stderr.rs":"840fe8d0ba613c98fa92cbebc374a028a3212ba7dcea58285483223a31acc7eb","src/target.rs":"a9d2d347a3a08015531f00b32bc8a7478f5636822cc8e0237ea9efa3f07d4cd4","src/target/apple.rs":"da9411b2c4db419e0fa39f765ee53b8665b3837fb39827679a53238734a4a1c1","src/target/generated.rs":"c53159c0903d759741ef901e84ce9f7ff31e800921aeb903769b4d80c9097968","src/target/llvm.rs":"190fe8d2b204cd4a6e68f2a1aada17ecd6390799564ed25792fcc08ab34710ba","src/target/parser.rs":"e2a5246a8fe46d39616410685cf7418f6b86344c5309bf09817978b182b3b38c","src/tempfile.rs":"3d9a4bd894862a345aa230a61ec266f0c68f4ef9713d1d9c727482e61f1ea7c3","src/tool.rs":"1d279a6f0738f9164ca794c85bd55951aa95e2adc788e75a6bb8133393d6cce8","src/utilities.rs":"ebb59ac01fb9588bcea0d0ee786e5d5a5696b4284a1245657625db03e830b72e"},"package":"e228eec9be7c17ccb640b59b36a5cd805ea2a564a4c5e162c2f659fea30d3b96"} \ No newline at end of file diff --git a/http/vendor/cc/.cargo_vcs_info.json b/http/vendor/cc/.cargo_vcs_info.json new file mode 100644 index 0000000..8c59ae3 --- /dev/null +++ b/http/vendor/cc/.cargo_vcs_info.json @@ -0,0 +1,6 @@ +{ + "git": { + "sha1": "640c66a8b8a225146a16068bad637d5e3417ffbf" + }, + "path_in_vcs": "" +} \ No newline at end of file diff --git a/http/vendor/cc/CHANGELOG.md b/http/vendor/cc/CHANGELOG.md new file mode 100644 index 0000000..81df07f --- /dev/null +++ b/http/vendor/cc/CHANGELOG.md @@ -0,0 +1,817 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [1.2.65](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.64...cc-v1.2.65) - 2026-06-19 + +### Other + +- Regenerate target info ([#1763](https://github.com/rust-lang/cc-rs/pull/1763)) + +## [1.2.64](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.63...cc-v1.2.64) - 2026-06-12 + +### Other + +- Add more bare-metal 32-bit Arm support ([#1753](https://github.com/rust-lang/cc-rs/pull/1753)) +- Remove unnecessary clone ([#1748](https://github.com/rust-lang/cc-rs/pull/1748)) +- Add default compiler prefixes for thumbv7a/thumbv7r/thumbv8r bare-metal targets ([#1742](https://github.com/rust-lang/cc-rs/pull/1742)) + +## [1.2.63](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.62...cc-v1.2.63) - 2026-05-29 + +### Other + +- Update shlex requirement from 1.3.0 to 2.0.1 ([#1736](https://github.com/rust-lang/cc-rs/pull/1736)) + +## [1.2.62](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.61...cc-v1.2.62) - 2026-05-08 + +### Other + +- Regenerate target info ([#1721](https://github.com/rust-lang/cc-rs/pull/1721)) +- Allow exceptions on wasm platforms ([#1714](https://github.com/rust-lang/cc-rs/pull/1714)) +- Add relibc env ([#1710](https://github.com/rust-lang/cc-rs/pull/1710)) +- recognize sh4 architecture in parse_arch() ([#1712](https://github.com/rust-lang/cc-rs/pull/1712)) + +## [1.2.61](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.60...cc-v1.2.61) - 2026-04-24 + +### Other + +- fix `OutputKind::Capture` documentation ([#1705](https://github.com/rust-lang/cc-rs/pull/1705)) + +## [1.2.60](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.59...cc-v1.2.60) - 2026-04-10 + +### Fixed + +- *(ar)* suppress warnings from `D` modifier probe ([#1700](https://github.com/rust-lang/cc-rs/pull/1700)) + +## [1.2.59](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.58...cc-v1.2.59) - 2026-04-03 + +### Fixed + +- *(ar)* deterministic archives with `D` modifier ([#1697](https://github.com/rust-lang/cc-rs/pull/1697)) + +### Other + +- Regenerate target info ([#1698](https://github.com/rust-lang/cc-rs/pull/1698)) +- Fix target abi parsing for sanitiser targets ([#1695](https://github.com/rust-lang/cc-rs/pull/1695)) + +## [1.2.58](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.57...cc-v1.2.58) - 2026-03-27 + +### Other + +- Update Compile-time Requirements to add info about clang-cl.exe ([#1693](https://github.com/rust-lang/cc-rs/pull/1693)) + +## [1.2.57](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.56...cc-v1.2.57) - 2026-03-13 + +### Other + +- Size archiver batches according to argument length not argument count ([#1689](https://github.com/rust-lang/cc-rs/pull/1689)) +- Added `Build::env` for setting environment variables of compiler invocations and other child processes ([#1656](https://github.com/rust-lang/cc-rs/pull/1656) [#1682](https://github.com/rust-lang/cc-rs/pull/1682)) + +## [1.2.56](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.55...cc-v1.2.56) - 2026-02-13 + +### Other + +- Regenerate target info ([#1676](https://github.com/rust-lang/cc-rs/pull/1676)) +- Fix `clang-cl` target when cross-compiling ([#1670](https://github.com/rust-lang/cc-rs/pull/1670)) + +## [1.2.55](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.54...cc-v1.2.55) - 2026-01-30 + +### Other + +- Regenerate target info ([#1667](https://github.com/rust-lang/cc-rs/pull/1667)) +- Fix RUSTFLAGS typo in test-linker-plugin-lto ([#1665](https://github.com/rust-lang/cc-rs/pull/1665)) +- Disable PIC for armv7-sony-vita-newlibeabihf ([#1664](https://github.com/rust-lang/cc-rs/pull/1664)) + +## [1.2.54](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.53...cc-v1.2.54) - 2026-01-23 + +### Other + +- Fix x86_64-unknown-linux-gnuasan parsing ([#1661](https://github.com/rust-lang/cc-rs/pull/1661)) +- Regenerate target info ([#1660](https://github.com/rust-lang/cc-rs/pull/1660)) + +## [1.2.53](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.52...cc-v1.2.53) - 2026-01-16 + +### Other + +- Add missing RISC-V targets ([#1657](https://github.com/rust-lang/cc-rs/pull/1657)) + +## [1.2.52](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.51...cc-v1.2.52) - 2026-01-09 + +### Other + +- Fix contradictory doc for CC compiler in crate doc ([#1650](https://github.com/rust-lang/cc-rs/pull/1650)) +- Have CUDA compilaion check for sbsa-linux when targeting aarch64. ([#1647](https://github.com/rust-lang/cc-rs/pull/1647)) +- Update link for -Cdwarf-version; Remove -Z (stabilized in 1.88) ([#1648](https://github.com/rust-lang/cc-rs/pull/1648)) +- Fix Build::env_tool to check for .exe on windows ([#1646](https://github.com/rust-lang/cc-rs/pull/1646)) + +## [1.2.51](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.50...cc-v1.2.51) - 2025-12-26 + +### Other + +- Regenerate target info ([#1642](https://github.com/rust-lang/cc-rs/pull/1642)) +- Update Readmes ([#1641](https://github.com/rust-lang/cc-rs/pull/1641)) + +## [1.2.50](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.49...cc-v1.2.50) - 2025-12-19 + +### Other + +- Add tests for `OUT_DIR` escape for '..' file paths (#1631) +- Fix #283: Make warnings(false) actually suppress compiler warnings ([#1633](https://github.com/rust-lang/cc-rs/pull/1633)) + +## [1.2.49](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.48...cc-v1.2.49) - 2025-12-06 + +### Other + +- Fix run_output to prevent infinite blocking ([#1627](https://github.com/rust-lang/cc-rs/pull/1627)) +- Fix detect_family deadlock ([#1626](https://github.com/rust-lang/cc-rs/pull/1626)) +- Fix link in new debug_str doc comment ([#1625](https://github.com/rust-lang/cc-rs/pull/1625)) +- Support more of Cargo's debug levels with Build::debug_str ([#1624](https://github.com/rust-lang/cc-rs/pull/1624)) + +## [1.2.48](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.47...cc-v1.2.48) - 2025-11-28 + +### Other + +- Regenerate target info ([#1620](https://github.com/rust-lang/cc-rs/pull/1620)) + +## [1.2.47](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.46...cc-v1.2.47) - 2025-11-21 + +### Other + +- add helenos linker identifications ([#1615](https://github.com/rust-lang/cc-rs/pull/1615)) + +## [1.2.46](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.45...cc-v1.2.46) - 2025-11-14 + +### Other + +- Add Visual Studio 2026 support ([#1609](https://github.com/rust-lang/cc-rs/pull/1609)) + +## [1.2.45](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.44...cc-v1.2.45) - 2025-11-07 + +### Other + +- Regenerate target info ([#1606](https://github.com/rust-lang/cc-rs/pull/1606)) +- Use a default check for the "env" variable in apple_sdk_name ([#1605](https://github.com/rust-lang/cc-rs/pull/1605)) + +## [1.2.44](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.43...cc-v1.2.44) - 2025-10-31 + +### Other + +- Fix debug assertion for env/abi mismatch ([#1604](https://github.com/rust-lang/cc-rs/pull/1604)) +- Update CHANGELOG for version 1.2.43 ([#1602](https://github.com/rust-lang/cc-rs/pull/1602)) +- Stop passing an invalid target to `llvm-mingw`'s cross-compilation wrappers ([#1495](https://github.com/rust-lang/cc-rs/pull/1495)) + +## [1.2.43](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.42...cc-v1.2.43) - 2025-10-24 + +### Other + +- Mark `static_flag` and `shared_flag` as deprecated ([#1582](https://github.com/rust-lang/cc-rs/pull/1582)) + +## [1.2.42](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.41...cc-v1.2.42) - 2025-10-24 + +### Other + +- Fix check-semver-checks ([#1600](https://github.com/rust-lang/cc-rs/pull/1600)) +- minor improvement for docs ([#1598](https://github.com/rust-lang/cc-rs/pull/1598)) +- Fix linker-plugin-lto: use `-flto=thin` ([#1594](https://github.com/rust-lang/cc-rs/pull/1594)) +- Disable check-buildstd for armv7k-apple-watchos ([#1599](https://github.com/rust-lang/cc-rs/pull/1599)) +- Add elf abi to ppc64 targets ([#1596](https://github.com/rust-lang/cc-rs/pull/1596)) + +## [1.2.41](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.40...cc-v1.2.41) - 2025-10-10 + +### Other + +- Allow using VCToolsVersion to request a specific msvc version ([#1589](https://github.com/rust-lang/cc-rs/pull/1589)) +- Regenerate target info ([#1592](https://github.com/rust-lang/cc-rs/pull/1592)) +- Regenerate windows sys bindings ([#1591](https://github.com/rust-lang/cc-rs/pull/1591)) +- Update windows-bindgen requirement from 0.64 to 0.65 ([#1590](https://github.com/rust-lang/cc-rs/pull/1590)) +- Fix `get_base_archiver_variant` for clang-cl: use `--print-search-dirs` ([#1587](https://github.com/rust-lang/cc-rs/pull/1587)) + +## [1.2.40](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.39...cc-v1.2.40) - 2025-10-03 + +### Other + +- Reorder changelog and remove duplicate Unreleased section ([#1579](https://github.com/rust-lang/cc-rs/pull/1579)) +- Prefer clang if linker-plugin-lto specified ([#1573](https://github.com/rust-lang/cc-rs/pull/1573)) +- Fix building for Mac Catalyst ([#1577](https://github.com/rust-lang/cc-rs/pull/1577)) +- Improve ESP microcontroller targets ([#1574](https://github.com/rust-lang/cc-rs/pull/1574)) + +## [1.2.39](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.38...cc-v1.2.39) - 2025-09-26 + +### Other + +- Fix cross compilation to xtensa-esp32s3-espidf ([#1569](https://github.com/rust-lang/cc-rs/pull/1569)) +- Fix autodetect_wasi_compiler: support non utf-8 path ([#1568](https://github.com/rust-lang/cc-rs/pull/1568)) +- Regenerate target info ([#1567](https://github.com/rust-lang/cc-rs/pull/1567)) +- Fix rustcflags mapping: require -Clinker-plugin-lto for -flto ([#1564](https://github.com/rust-lang/cc-rs/pull/1564)) +- Use `$WASI_SDK_PATH` on WASI targets by default ([#1562](https://github.com/rust-lang/cc-rs/pull/1562)) +- Fix atomicity violations in concurrent cache operations ([#1559](https://github.com/rust-lang/cc-rs/pull/1559)) + +## [1.2.38](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.37...cc-v1.2.38) - 2025-09-19 + +### Other + +- updated the following local packages: find-msvc-tools + +## [1.2.37](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.36...cc-v1.2.37) - 2025-09-12 + +### Other + +- Fix errmsg in RustcCodegenFlags::set_rustc_flag ([#1551](https://github.com/rust-lang/cc-rs/pull/1551)) +- propagate stack protector to Linux C compilers ([#1550](https://github.com/rust-lang/cc-rs/pull/1550)) +- Extract new fn `run_commands_in_parallel` ([#1549](https://github.com/rust-lang/cc-rs/pull/1549)) + +## [1.2.36](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.35...cc-v1.2.36) - 2025-09-05 + +### Other + +- Regenerate windows sys bindings ([#1548](https://github.com/rust-lang/cc-rs/pull/1548)) +- Update windows-bindgen requirement from 0.62 to 0.63 ([#1547](https://github.com/rust-lang/cc-rs/pull/1547)) +- Add fn get_ucrt_dir for find-msvc-tools ([#1546](https://github.com/rust-lang/cc-rs/pull/1546)) +- Regenerate target info ([#1544](https://github.com/rust-lang/cc-rs/pull/1544)) +- fix publish.yml ([#1543](https://github.com/rust-lang/cc-rs/pull/1543)) +- Replace periods with underscores as well when parsing env variables ([#1541](https://github.com/rust-lang/cc-rs/pull/1541)) + +## [1.2.35](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.34...cc-v1.2.35) - 2025-09-01 + +### Fixed + +- fix building for aarch64-apple-visionos-sim on nightly ([#1534](https://github.com/rust-lang/cc-rs/pull/1534)) +- fix tests apple_sdkroot_wrong ([#1530](https://github.com/rust-lang/cc-rs/pull/1530)) + +### Other + +- Regenerate target info ([#1536](https://github.com/rust-lang/cc-rs/pull/1536)) +- Optimize Tool::to_command ([#1535](https://github.com/rust-lang/cc-rs/pull/1535)) +- Extract find-msvc-tools ([#1531](https://github.com/rust-lang/cc-rs/pull/1531)) +- Add prefer_clang_cl_over_msvc ([#1516](https://github.com/rust-lang/cc-rs/pull/1516)) + +## [1.2.34](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.33...cc-v1.2.34) - 2025-08-22 + +### Fixed + +- add `-mcpu=mvp` and `-mmutable-globals` for `wasm32v1-none` ([#1524](https://github.com/rust-lang/cc-rs/pull/1524)) + +### Other + +- Optimize parse_version in find_tools.rs ([#1527](https://github.com/rust-lang/cc-rs/pull/1527)) +- Fallback to manually searching for tool dir ([#1526](https://github.com/rust-lang/cc-rs/pull/1526)) + +## [1.2.33](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.32...cc-v1.2.33) - 2025-08-15 + +### Other + +- Regenerate target info ([#1521](https://github.com/rust-lang/cc-rs/pull/1521)) +- [win][arm64ec] Add testing for Arm64EC Windows ([#1512](https://github.com/rust-lang/cc-rs/pull/1512)) +- Fix parsing of nigthly targets ([#1517](https://github.com/rust-lang/cc-rs/pull/1517)) +- [win][arm64ec] Fix finding assembler and setting is_arm for Arm64EC ([#1511](https://github.com/rust-lang/cc-rs/pull/1511)) + +## [1.2.32](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.31...cc-v1.2.32) - 2025-08-08 + +### Fixed + +- fix new clippy lint introduced in rust 1.89.0 ([#1509](https://github.com/rust-lang/cc-rs/pull/1509)) + +### Other + +- clarify cargo default if no rerun emitted ([#1508](https://github.com/rust-lang/cc-rs/pull/1508)) +- extract compile_objects_sequential ([#1507](https://github.com/rust-lang/cc-rs/pull/1507)) +- Windows `find_tools`: add support for finding Clang ([#1506](https://github.com/rust-lang/cc-rs/pull/1506)) +- Add m68k-unknown-linux-gnu cross-compile target ([#1505](https://github.com/rust-lang/cc-rs/pull/1505)) + +## [1.2.31](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.30...cc-v1.2.31) - 2025-08-01 + +### Other + +- Add doc for using sccache/ccache etc ([#1502](https://github.com/rust-lang/cc-rs/pull/1502)) +- ability to statically link against C++ stdlib ([#1497](https://github.com/rust-lang/cc-rs/pull/1497)) +- Add instructions on using sccache ([#1503](https://github.com/rust-lang/cc-rs/pull/1503)) +- Add support for recognizing some architectures supported by GCC, but not LLVM. ([#1500](https://github.com/rust-lang/cc-rs/pull/1500)) + +## [1.2.30](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.29...cc-v1.2.30) - 2025-07-18 + +### Other + +- define _REENTRANT by default ([#1496](https://github.com/rust-lang/cc-rs/pull/1496)) + +## [1.2.29](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.28...cc-v1.2.29) - 2025-07-05 + +### Other + +- Fix target parsing for powerpc ([#1490](https://github.com/rust-lang/cc-rs/pull/1490)) + +## [1.2.28](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.27...cc-v1.2.28) - 2025-07-04 + +### Other + +- Recognize `mlibc` environment ([#1488](https://github.com/rust-lang/cc-rs/pull/1488)) +- Fix clippy warnings about not using variables in `format!` strings ([#1489](https://github.com/rust-lang/cc-rs/pull/1489)) + +## [1.2.27](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.26...cc-v1.2.27) - 2025-06-13 + +### Other + +- Regenerate windows sys bindings ([#1485](https://github.com/rust-lang/cc-rs/pull/1485)) +- Update windows-bindgen requirement from 0.61 to 0.62 ([#1484](https://github.com/rust-lang/cc-rs/pull/1484)) +- Regenerate target info ([#1483](https://github.com/rust-lang/cc-rs/pull/1483)) + +## [1.2.26](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.25...cc-v1.2.26) - 2025-06-06 + +### Other + +- Also set `SDKROOT` when building apple platforms ([#1475](https://github.com/rust-lang/cc-rs/pull/1475)) +- use windows 2022 in CI ([#1479](https://github.com/rust-lang/cc-rs/pull/1479)) +- Detect -Wslash-u-filename warning on clang-cl ([#1477](https://github.com/rust-lang/cc-rs/pull/1477)) + +## [1.2.25](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.24...cc-v1.2.25) - 2025-05-30 + +### Other + +- make `powerp64` use `powerpc64-linux-gnu` prefix ([#1474](https://github.com/rust-lang/cc-rs/pull/1474)) + +## [1.2.24](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.23...cc-v1.2.24) - 2025-05-23 + +### Other + +- Regenerate windows sys bindings ([#1471](https://github.com/rust-lang/cc-rs/pull/1471)) + +## [1.2.23](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.22...cc-v1.2.23) - 2025-05-16 + +### Other + +- support "vxworks" and "nto" OSes on `get_base_archiver_variant` ([#1456](https://github.com/rust-lang/cc-rs/pull/1456)) + +## [1.2.22](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.21...cc-v1.2.22) - 2025-05-09 + +### Other + +- Add `flags` method to `cc::Build` for adding multiple flags ([#1466](https://github.com/rust-lang/cc-rs/pull/1466)) + +## [1.2.21](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.20...cc-v1.2.21) - 2025-05-02 + +### Other + +- Fix wasm32-unknown-unknown by passing -c ([#1424](https://github.com/rust-lang/cc-rs/pull/1424)) + +## [1.2.20](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.19...cc-v1.2.20) - 2025-04-25 + +### Other + +- Regenerate target info ([#1461](https://github.com/rust-lang/cc-rs/pull/1461)) +- Fix parser.rs on latest rustc nightly ([#1459](https://github.com/rust-lang/cc-rs/pull/1459)) + +## [1.2.19](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.18...cc-v1.2.19) - 2025-04-11 + +### Other + +- Fix musl compilation: Add musl as a prefix fallback ([#1455](https://github.com/rust-lang/cc-rs/pull/1455)) + +## [1.2.18](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.17...cc-v1.2.18) - 2025-04-04 + +### Other + +- Regenerate target info ([#1450](https://github.com/rust-lang/cc-rs/pull/1450)) +- Use `std::thread::available_parallelism` for determining the default number of jobs ([#1447](https://github.com/rust-lang/cc-rs/pull/1447)) +- Fix mips64-openwrt-linux-musl parsing ([#1449](https://github.com/rust-lang/cc-rs/pull/1449)) +- Use compiler prefix `x86_64-linux-musl` ([#1443](https://github.com/rust-lang/cc-rs/pull/1443)) + +## [1.2.17](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.16...cc-v1.2.17) - 2025-03-21 + +### Other + +- Regenerate target info ([#1439](https://github.com/rust-lang/cc-rs/pull/1439)) +- Regenerate windows sys bindings ([#1437](https://github.com/rust-lang/cc-rs/pull/1437)) +- Fix wasm32-wali-linux-musl target parsing ([#1434](https://github.com/rust-lang/cc-rs/pull/1434)) +- Parse `rustc` target names ([#1413](https://github.com/rust-lang/cc-rs/pull/1413)) +- Regenerate target info ([#1429](https://github.com/rust-lang/cc-rs/pull/1429)) +- Added base support for `wasm32-wali-linux-musl` target ([#1373](https://github.com/rust-lang/cc-rs/pull/1373)) + +## [1.2.16](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.15...cc-v1.2.16) - 2025-02-28 + +### Fixed + +- force windows compiler to run in `out_dir` to prevent artifacts in cwd (#1415) + +### Other + +- use `/arch:SSE2` for `x86` target arch (#1425) +- Regenerate windows-sys binding ([#1422](https://github.com/rust-lang/cc-rs/pull/1422)) +- Regenerate target info ([#1418](https://github.com/rust-lang/cc-rs/pull/1418)) +- Add LIB var when compiling flag_check (#1417) +- Change flag ordering ([#1403](https://github.com/rust-lang/cc-rs/pull/1403)) +- Fix archiver detection for musl cross compilation ([#1404](https://github.com/rust-lang/cc-rs/pull/1404)) + +## [1.2.15](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.14...cc-v1.2.15) - 2025-02-21 + +### Other + +- Regenerate target info ([#1406](https://github.com/rust-lang/cc-rs/pull/1406)) +- Always read from all `CFLAGS`-style flags ([#1401](https://github.com/rust-lang/cc-rs/pull/1401)) +- Simplify the error output on failed `Command` invocation ([#1397](https://github.com/rust-lang/cc-rs/pull/1397)) + +## [1.2.14](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.13...cc-v1.2.14) - 2025-02-14 + +### Other + +- Regenerate target info ([#1398](https://github.com/rust-lang/cc-rs/pull/1398)) +- Add support for setting `-gdwarf-{version}` based on RUSTFLAGS ([#1395](https://github.com/rust-lang/cc-rs/pull/1395)) +- Add support for alternative network stack io-sock on QNX 7.1 aarch64 and x86_64 ([#1312](https://github.com/rust-lang/cc-rs/pull/1312)) + +## [1.2.13](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.12...cc-v1.2.13) - 2025-02-08 + +### Other + +- Fix cross-compiling for Apple platforms ([#1389](https://github.com/rust-lang/cc-rs/pull/1389)) + +## [1.2.12](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.11...cc-v1.2.12) - 2025-02-04 + +### Other + +- Split impl Build ([#1382](https://github.com/rust-lang/cc-rs/pull/1382)) +- Don't specify both `-target` and `-mtargetos=` on Apple targets ([#1384](https://github.com/rust-lang/cc-rs/pull/1384)) + +## [1.2.11](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.10...cc-v1.2.11) - 2025-01-31 + +### Other + +- Fix more flag inheritance ([#1380](https://github.com/rust-lang/cc-rs/pull/1380)) +- Include wrapper args. in `stdout` family heuristics to restore classifying `clang --driver-mode=cl` as `Msvc { clang_cl: true }` ([#1378](https://github.com/rust-lang/cc-rs/pull/1378)) +- Constrain `-Clto` and `-Cembed-bitcode` flag inheritance to be `clang`-only ([#1379](https://github.com/rust-lang/cc-rs/pull/1379)) +- Pass deployment target with `-m*-version-min=` ([#1339](https://github.com/rust-lang/cc-rs/pull/1339)) +- Regenerate target info ([#1376](https://github.com/rust-lang/cc-rs/pull/1376)) + +## [1.2.10](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.9...cc-v1.2.10) - 2025-01-17 + +### Other + +- Fix CC_FORCE_DISABLE=0 evaluating to true ([#1371](https://github.com/rust-lang/cc-rs/pull/1371)) +- Regenerate target info ([#1369](https://github.com/rust-lang/cc-rs/pull/1369)) +- Make hidden lifetimes explicit. ([#1366](https://github.com/rust-lang/cc-rs/pull/1366)) + +## [1.2.9](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.8...cc-v1.2.9) - 2025-01-12 + +### Other + +- Don't pass inherited PGO flags to GNU compilers (#1363) +- Adjusted zig cc judgment and avoided zigbuild errors([#1360](https://github.com/rust-lang/cc-rs/pull/1360)) ([#1361](https://github.com/rust-lang/cc-rs/pull/1361)) +- Fix compilation on macOS using clang and fix compilation using zig-cc ([#1364](https://github.com/rust-lang/cc-rs/pull/1364)) + +## [1.2.8](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.7...cc-v1.2.8) - 2025-01-11 + +### Other + +- Add `is_like_clang_cl()` getter (#1357) +- Fix clippy error in lib.rs ([#1356](https://github.com/rust-lang/cc-rs/pull/1356)) +- Regenerate target info ([#1352](https://github.com/rust-lang/cc-rs/pull/1352)) +- Fix compiler family detection issue with clang-cl on macOS ([#1328](https://github.com/rust-lang/cc-rs/pull/1328)) +- Update `windows-bindgen` dependency ([#1347](https://github.com/rust-lang/cc-rs/pull/1347)) +- Fix clippy warnings ([#1346](https://github.com/rust-lang/cc-rs/pull/1346)) + +## [1.2.7](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.6...cc-v1.2.7) - 2025-01-03 + +### Other + +- Regenerate target info ([#1342](https://github.com/rust-lang/cc-rs/pull/1342)) +- Document new supported architecture names in windows::find +- Make is_flag_supported_inner take an &Tool ([#1337](https://github.com/rust-lang/cc-rs/pull/1337)) +- Fix is_flag_supported on msvc ([#1336](https://github.com/rust-lang/cc-rs/pull/1336)) +- Allow using Visual Studio target names in `find_tool` ([#1335](https://github.com/rust-lang/cc-rs/pull/1335)) + +## [1.2.6](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.5...cc-v1.2.6) - 2024-12-27 + +### Other + +- Don't inherit the `/Oy` flag for 64-bit targets ([#1330](https://github.com/rust-lang/cc-rs/pull/1330)) + +## [1.2.5](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.4...cc-v1.2.5) - 2024-12-19 + +### Other + +- Check linking when testing if compiler flags are supported ([#1322](https://github.com/rust-lang/cc-rs/pull/1322)) + +## [1.2.4](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.3...cc-v1.2.4) - 2024-12-13 + +### Other + +- Add support for C/C++ compiler for Neutrino QNX: `qcc` ([#1319](https://github.com/rust-lang/cc-rs/pull/1319)) +- use -maix64 instead of -m64 ([#1307](https://github.com/rust-lang/cc-rs/pull/1307)) + +## [1.2.3](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.2...cc-v1.2.3) - 2024-12-06 + +### Other + +- Improve detection of environment when compiling from msbuild or msvc ([#1310](https://github.com/rust-lang/cc-rs/pull/1310)) +- Better error message when failing on unknown targets ([#1313](https://github.com/rust-lang/cc-rs/pull/1313)) +- Optimize RustcCodegenFlags ([#1305](https://github.com/rust-lang/cc-rs/pull/1305)) + +## [1.2.2](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.1...cc-v1.2.2) - 2024-11-29 + +### Other + +- Inherit flags from rustc ([#1279](https://github.com/rust-lang/cc-rs/pull/1279)) +- Add support for using sccache wrapper with cuda/nvcc ([#1304](https://github.com/rust-lang/cc-rs/pull/1304)) +- Fix msvc stdout not shown on error ([#1303](https://github.com/rust-lang/cc-rs/pull/1303)) +- Regenerate target info ([#1301](https://github.com/rust-lang/cc-rs/pull/1301)) +- Fix compilation of C++ code for armv7-unknown-linux-gnueabihf ([#1298](https://github.com/rust-lang/cc-rs/pull/1298)) +- Fetch target info from Cargo even if `Build::target` is manually set ([#1299](https://github.com/rust-lang/cc-rs/pull/1299)) +- Fix two files with different extensions having the same object name ([#1295](https://github.com/rust-lang/cc-rs/pull/1295)) +- Allow disabling cc's ability to compile via env var CC_FORCE_DISABLE ([#1292](https://github.com/rust-lang/cc-rs/pull/1292)) +- Regenerate target info ([#1293](https://github.com/rust-lang/cc-rs/pull/1293)) + +## [1.2.1](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.0...cc-v1.2.1) - 2024-11-14 + +### Other + +- When invoking `cl -?`, set stdin to null ([#1288](https://github.com/rust-lang/cc-rs/pull/1288)) + +## [1.2.0](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.37...cc-v1.2.0) - 2024-11-11 + +### Added + +- add i686-pc-windows-gnullvm prefix detection ([#1283](https://github.com/rust-lang/cc-rs/pull/1283)) + +### Other + +- Allow only specifying the architecture ([#1285](https://github.com/rust-lang/cc-rs/pull/1285)) +- Fix WASM vs. WASI options ([#1284](https://github.com/rust-lang/cc-rs/pull/1284)) + +## [1.1.37](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.36...cc-v1.1.37) - 2024-11-08 + +### Other + +- Use relative directory for obj files hash ([#1270](https://github.com/rust-lang/cc-rs/pull/1270)) +- Regenerate target info ([#1280](https://github.com/rust-lang/cc-rs/pull/1280)) + +## [1.1.36](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.35...cc-v1.1.36) - 2024-11-05 + +### Other + +- Fix CUDA build with clang++. ([#1273](https://github.com/rust-lang/cc-rs/pull/1273)) + +## [1.1.35](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.34...cc-v1.1.35) - 2024-11-04 + +### Other + +- Remove support for FRC ([#1268](https://github.com/rust-lang/cc-rs/pull/1268)) +- Do not add -fPIC by default on UEFI targets ([#1263](https://github.com/rust-lang/cc-rs/pull/1263)) +- Use -windows-gnu for all UEFI targets ([#1264](https://github.com/rust-lang/cc-rs/pull/1264)) + +## [1.1.34](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.33...cc-v1.1.34) - 2024-11-02 + +### Other + +- Remove redundant flags ([#1256](https://github.com/rust-lang/cc-rs/pull/1256)) + +## [1.1.33](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.32...cc-v1.1.33) - 2024-11-02 + +### Other + +- Reduce size of `cc::Build` and size of generated targets ([#1257](https://github.com/rust-lang/cc-rs/pull/1257)) + +## [1.1.32](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.31...cc-v1.1.32) - 2024-11-02 + +### Other + +- Use `rustc`'s knowledge of LLVM/Clang target triples ([#1252](https://github.com/rust-lang/cc-rs/pull/1252)) +- Use Cargo's target information when possible ([#1225](https://github.com/rust-lang/cc-rs/pull/1225)) + +## [1.1.31](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.30...cc-v1.1.31) - 2024-10-19 + +### Other + +- Add comment explaining why cc does not rebuild on env PATH change ([#1247](https://github.com/rust-lang/cc-rs/pull/1247)) + +## [1.1.30](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.29...cc-v1.1.30) - 2024-10-11 + +### Other + +- Don't pass -fPIC by default on wasm ([#1245](https://github.com/rust-lang/cc-rs/pull/1245)) + +## [1.1.29](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.28...cc-v1.1.29) - 2024-10-11 + +### Other + +- Regenerate target info ([#1243](https://github.com/rust-lang/cc-rs/pull/1243)) + +## [1.1.28](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.27...cc-v1.1.28) - 2024-10-06 + +### Other + +- Environment variables: For one accepting boolean, treat "0", "false" and empty env as false ([#1238](https://github.com/rust-lang/cc-rs/pull/1238)) + +## [1.1.27](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.26...cc-v1.1.27) - 2024-10-06 + +### Other + +- Revert "Use debug version of MSVC runtime library on debug ([#1231](https://github.com/rust-lang/cc-rs/pull/1231))" ([#1237](https://github.com/rust-lang/cc-rs/pull/1237)) +- Disable `CC_ENABLE_DEBUG_OUTPUT` if it is set to "0" ([#1234](https://github.com/rust-lang/cc-rs/pull/1234)) + +## [1.1.26](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.25...cc-v1.1.26) - 2024-10-06 + +### Other + +- Use debug version of MSVC runtime library on debug ([#1231](https://github.com/rust-lang/cc-rs/pull/1231)) + +## [1.1.25](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.24...cc-v1.1.25) - 2024-10-05 + +### Other + +- Remove incorrect "lib" prefixes in CXXSTDLIB doc comments ([#1228](https://github.com/rust-lang/cc-rs/pull/1228)) + +## [1.1.24](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.23...cc-v1.1.24) - 2024-10-01 + +### Other + +- Fix wasm32-wasip1-threads: shared-memory disallowed due to not compiled with 'atomics' or 'bulk-memory' features ([#1221](https://github.com/rust-lang/cc-rs/pull/1221)) +- Reduce the need for the host target triple ([#1224](https://github.com/rust-lang/cc-rs/pull/1224)) +- Add auto cancellation for CI jobs ([#1222](https://github.com/rust-lang/cc-rs/pull/1222)) + +## [1.1.23](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.22...cc-v1.1.23) - 2024-09-30 + +### Other + +- Update doc for detecting changes/upgrades of compilers ([#1218](https://github.com/rust-lang/cc-rs/pull/1218)) + +## [1.1.22](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.21...cc-v1.1.22) - 2024-09-27 + +### Other + +- Don't rerun if PATH changes ([#1215](https://github.com/rust-lang/cc-rs/pull/1215)) + +## [1.1.21](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.20...cc-v1.1.21) - 2024-09-18 + +### Other + +- disable pic for targets that end in `-none` ([#1212](https://github.com/rust-lang/cc-rs/pull/1212)) + +## [1.1.20](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.19...cc-v1.1.20) - 2024-09-17 + +### Other + +- Add buildcache as known Rust and C/C++ compiler wrapper ([#1209](https://github.com/rust-lang/cc-rs/pull/1209)) + +## [1.1.19](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.18...cc-v1.1.19) - 2024-09-15 + +### Other + +- Add support arm64e-apple-darwin ([#1207](https://github.com/rust-lang/cc-rs/pull/1207)) + +## [1.1.18](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.17...cc-v1.1.18) - 2024-09-07 + +### Other +- Fixed unsoundness in `StderrForwarder::forward_available` ([#1203](https://github.com/rust-lang/cc-rs/pull/1203)) + +## [1.1.17](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.16...cc-v1.1.17) - 2024-09-06 + +### Fixed +- fix finding toolchains when invoked by msbuild ([#1201](https://github.com/rust-lang/cc-rs/pull/1201)) + +## [1.1.16](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.15...cc-v1.1.16) - 2024-09-04 + +### Other +- Treat VxWorks wr-cc as a Gnu compiler ([#1198](https://github.com/rust-lang/cc-rs/pull/1198)) + +## [1.1.15](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.14...cc-v1.1.15) - 2024-08-26 + +### Other +- Add -mfloat-abi=hard as a default argument when using any arm/thumb-none-eabihf target ([#1194](https://github.com/rust-lang/cc-rs/pull/1194)) + +## [1.1.14](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.13...cc-v1.1.14) - 2024-08-23 + +### Other +- allow finding tools from path if VisualStudioDir is set + +## [1.1.13](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.12...cc-v1.1.13) - 2024-08-16 + +### Other +- Fix detect family: should detect emscripten as clang, closes [#1185](https://github.com/rust-lang/cc-rs/pull/1185) ([#1186](https://github.com/rust-lang/cc-rs/pull/1186)) + +## [1.1.12](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.11...cc-v1.1.12) - 2024-08-15 + +### Other +- improve docs ([#1183](https://github.com/rust-lang/cc-rs/pull/1183)) + +## [1.1.11](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.10...cc-v1.1.11) - 2024-08-14 + +### Other +- Add support for parsing shell encoded `*FLAGS` ([#1181](https://github.com/rust-lang/cc-rs/pull/1181)) +- Replace vector of tuples with BTreeMap which already is sorted and free of duplicates ([#1177](https://github.com/rust-lang/cc-rs/pull/1177)) + +## [1.1.10](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.9...cc-v1.1.10) - 2024-08-11 + +### Other +- Remap Windows targets triples to their LLVM counterparts ([#1176](https://github.com/rust-lang/cc-rs/pull/1176)) + +## [1.1.9](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.8...cc-v1.1.9) - 2024-08-11 + +### Other +- Add custom CC wrapper to the wrapper whitelist ([#1175](https://github.com/rust-lang/cc-rs/pull/1175)) + +## [1.1.8](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.7...cc-v1.1.8) - 2024-08-06 + +### Other +- Fix broken link in docs.rs ([#1173](https://github.com/rust-lang/cc-rs/pull/1173)) + +## [1.1.7](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.6...cc-v1.1.7) - 2024-07-29 + +### Other +- add `.objects` ([#1166](https://github.com/rust-lang/cc-rs/pull/1166)) + +## [1.1.6](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.5...cc-v1.1.6) - 2024-07-19 + +### Other +- Clippy fixes ([#1163](https://github.com/rust-lang/cc-rs/pull/1163)) + +## [1.1.5](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.4...cc-v1.1.5) - 2024-07-15 + +### Other +- Fix cyclic compilation: Use vendored once_cell ([#1154](https://github.com/rust-lang/cc-rs/pull/1154)) + +## [1.1.4](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.3...cc-v1.1.4) - 2024-07-14 + +### Other +- Support compiling on wasm targets (Supersede [#1068](https://github.com/rust-lang/cc-rs/pull/1068)) ([#1160](https://github.com/rust-lang/cc-rs/pull/1160)) + +## [1.1.3](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.2...cc-v1.1.3) - 2024-07-14 + +### Other +- Reduce msrv to 1.63 ([#1158](https://github.com/rust-lang/cc-rs/pull/1158)) +- Revert "Use raw-dylib for windows-sys ([#1137](https://github.com/rust-lang/cc-rs/pull/1137))" ([#1157](https://github.com/rust-lang/cc-rs/pull/1157)) +- Fix typos ([#1152](https://github.com/rust-lang/cc-rs/pull/1152)) +- Fix `doc_lazy_continuation` lints ([#1153](https://github.com/rust-lang/cc-rs/pull/1153)) + +## [1.1.2](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.1...cc-v1.1.2) - 2024-07-12 + +### Other +- Add empty `jobserver` feature. ([#1150](https://github.com/rust-lang/cc-rs/pull/1150)) + +## [1.1.1](https://github.com/rust-lang/cc-rs/compare/cc-v1.1.0...cc-v1.1.1) - 2024-07-12 + +### Other +- Fix is_flag_supported not respecting emit_rerun_if_env_changed ([#1147](https://github.com/rust-lang/cc-rs/pull/1147)) ([#1148](https://github.com/rust-lang/cc-rs/pull/1148)) + +## [1.1.0](https://github.com/rust-lang/cc-rs/compare/cc-v1.0.106...cc-v1.1.0) - 2024-07-08 + +### Added +- add cargo_output to eliminate last vestiges of stdout pollution ([#1141](https://github.com/rust-lang/cc-rs/pull/1141)) + +## [1.0.106](https://github.com/rust-lang/cc-rs/compare/cc-v1.0.105...cc-v1.0.106) - 2024-07-08 + +### Other +- Drop support for Visual Studio 12 (2013) ([#1046](https://github.com/rust-lang/cc-rs/pull/1046)) +- Use raw-dylib for windows-sys ([#1137](https://github.com/rust-lang/cc-rs/pull/1137)) +- Bump msrv to 1.67 ([#1143](https://github.com/rust-lang/cc-rs/pull/1143)) +- Bump msrv to 1.65 ([#1140](https://github.com/rust-lang/cc-rs/pull/1140)) +- Fix clippy warnings ([#1138](https://github.com/rust-lang/cc-rs/pull/1138)) + +## [1.0.105](https://github.com/rust-lang/cc-rs/compare/cc-v1.0.104...cc-v1.0.105) - 2024-07-07 + +### Other +- Regenerate windows sys bindings ([#1132](https://github.com/rust-lang/cc-rs/pull/1132)) +- Fix generate-windows-sys-bindings ([#1133](https://github.com/rust-lang/cc-rs/pull/1133)) +- Fix gen-windows-sys-binding ([#1130](https://github.com/rust-lang/cc-rs/pull/1130)) +- Fix gen-windows-sys-binding ([#1127](https://github.com/rust-lang/cc-rs/pull/1127)) +- Update windows-bindgen requirement from 0.57 to 0.58 ([#1123](https://github.com/rust-lang/cc-rs/pull/1123)) + +## [1.0.104](https://github.com/rust-lang/cc-rs/compare/cc-v1.0.103...cc-v1.0.104) - 2024-07-01 + +### Other +- Fixed link break about compile-time-requirements ([#1118](https://github.com/rust-lang/cc-rs/pull/1118)) + +## [1.0.103](https://github.com/rust-lang/cc-rs/compare/cc-v1.0.102...cc-v1.0.103) - 2024-06-30 + +### Other +- Fix compilation for wasm: env WASI_SYSROOT should be optional ([#1114](https://github.com/rust-lang/cc-rs/pull/1114)) + +## [1.0.102](https://github.com/rust-lang/cc-rs/compare/cc-v1.0.101...cc-v1.0.102) - 2024-06-29 + +### Other +- Fix invalid wasi targets compatibility ([#1105](https://github.com/rust-lang/cc-rs/pull/1105)) +- Speedup regenerate-target-info and regenerate-windows-sys ([#1110](https://github.com/rust-lang/cc-rs/pull/1110)) + +## [1.0.101](https://github.com/rust-lang/cc-rs/compare/cc-v1.0.100...cc-v1.0.101) - 2024-06-25 + +### Other +- Use `Build::getenv` instead of `env::var*` in anywhere that makes sense ([#1103](https://github.com/rust-lang/cc-rs/pull/1103)) + +## [1.0.100](https://github.com/rust-lang/cc-rs/compare/cc-v1.0.99...cc-v1.0.100) - 2024-06-23 + +### Other +- Update publish.yml to use release-plz ([#1101](https://github.com/rust-lang/cc-rs/pull/1101)) +- Accept `OsStr` instead of `str` for flags ([#1100](https://github.com/rust-lang/cc-rs/pull/1100)) +- Use `dep:` syntax to avoid implicit features. ([#1099](https://github.com/rust-lang/cc-rs/pull/1099)) +- Minor clippy fixes. ([#1098](https://github.com/rust-lang/cc-rs/pull/1098)) +- Fix WASI compilation for C++ ([#1083](https://github.com/rust-lang/cc-rs/pull/1083)) +- Regenerate windows sys bindings ([#1096](https://github.com/rust-lang/cc-rs/pull/1096)) +- Rename regenerate-windows-sys to regenerate-windows-sys.yml ([#1095](https://github.com/rust-lang/cc-rs/pull/1095)) +- Create regenerate-windows-sys.yml ([#1094](https://github.com/rust-lang/cc-rs/pull/1094)) +- Update windows-bindgen requirement from 0.56 to 0.57 ([#1091](https://github.com/rust-lang/cc-rs/pull/1091)) +- Eagerly close tempfile to fix [#1082](https://github.com/rust-lang/cc-rs/pull/1082) ([#1087](https://github.com/rust-lang/cc-rs/pull/1087)) +- Output msvc.exe in the output directory ([#1090](https://github.com/rust-lang/cc-rs/pull/1090)) +- Fix clippy warnings on Windows ([#1088](https://github.com/rust-lang/cc-rs/pull/1088)) +- Don't try to free DLL on drop ([#1089](https://github.com/rust-lang/cc-rs/pull/1089)) +- Fix panic safety issue in StderrForwarder ([#1079](https://github.com/rust-lang/cc-rs/pull/1079)) diff --git a/http/vendor/cc/Cargo.lock b/http/vendor/cc/Cargo.lock new file mode 100644 index 0000000..ecd275b --- /dev/null +++ b/http/vendor/cc/Cargo.lock @@ -0,0 +1,173 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "bitflags" +version = "2.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8" + +[[package]] +name = "cc" +version = "1.2.65" +dependencies = [ + "find-msvc-tools", + "jobserver", + "libc", + "shlex", + "tempfile", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "fastrand" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f1f227452a390804cdb637b74a86990f2a7d7ba4b7d5693aac9b4dd6defd8d6" + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi 5.3.0", + "wasip2", +] + +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "libc", + "r-efi 6.0.0", +] + +[[package]] +name = "jobserver" +version = "0.1.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" +dependencies = [ + "getrandom 0.3.4", + "libc", +] + +[[package]] +name = "libc" +version = "0.2.186" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "rustix" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "tempfile" +version = "3.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" +dependencies = [ + "fastrand", + "getrandom 0.4.3", + "once_cell", + "rustix", + "windows-sys", +] + +[[package]] +name = "wasip2" +version = "1.0.4+wasi-0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "wit-bindgen" +version = "0.57.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" diff --git a/http/vendor/cc/Cargo.toml b/http/vendor/cc/Cargo.toml new file mode 100644 index 0000000..52e9b12 --- /dev/null +++ b/http/vendor/cc/Cargo.toml @@ -0,0 +1,79 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies. +# +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. + +[package] +edition = "2018" +rust-version = "1.63" +name = "cc" +version = "1.2.65" +authors = ["Alex Crichton "] +build = false +exclude = [ + "/.github", + "tests", + "src/bin", +] +autolib = false +autobins = false +autoexamples = false +autotests = false +autobenches = false +description = """ +A build-time dependency for Cargo build scripts to assist in invoking the native +C compiler to compile native C code into a static archive to be linked into Rust +code. +""" +homepage = "https://github.com/rust-lang/cc-rs" +documentation = "https://docs.rs/cc" +readme = "README.md" +keywords = ["build-dependencies"] +categories = ["development-tools::build-utils"] +license = "MIT OR Apache-2.0" +repository = "https://github.com/rust-lang/cc-rs" + +[features] +jobserver = [] +parallel = [ + "dep:libc", + "dep:jobserver", +] + +[lib] +name = "cc" +path = "src/lib.rs" + +[dependencies.find-msvc-tools] +version = "0.1.9" + +[dependencies.jobserver] +version = "0.1.30" +optional = true +default-features = false + +[dependencies.shlex] +version = "2.0.1" + +[dev-dependencies.tempfile] +version = "3" + +[target."cfg(unix)".dependencies.libc] +version = "0.2.62" +optional = true +default-features = false + +[lints.rust.unexpected_cfgs] +level = "allow" +priority = 0 +check-cfg = ["cfg(disable_clang_cl_tests)"] + +[profile.release] +opt-level = 3 +lto = true diff --git a/http/vendor/cc/Cargo.toml.orig b/http/vendor/cc/Cargo.toml.orig new file mode 100644 index 0000000..3ea8aee --- /dev/null +++ b/http/vendor/cc/Cargo.toml.orig @@ -0,0 +1,59 @@ +[package] +name = "cc" +version = "1.2.65" +authors = ["Alex Crichton "] +license = "MIT OR Apache-2.0" +repository = "https://github.com/rust-lang/cc-rs" +homepage = "https://github.com/rust-lang/cc-rs" +documentation = "https://docs.rs/cc" +description = """ +A build-time dependency for Cargo build scripts to assist in invoking the native +C compiler to compile native C code into a static archive to be linked into Rust +code. +""" +keywords = ["build-dependencies"] +readme = "README.md" +categories = ["development-tools::build-utils"] +# The binary target is only used by tests. +exclude = ["/.github", "tests", "src/bin"] +edition = "2018" +rust-version = "1.63" + +[dependencies] +jobserver = { version = "0.1.30", default-features = false, optional = true } +shlex = "2.0.1" +find-msvc-tools = { version = "0.1.9", path = "find-msvc-tools" } + +[target.'cfg(unix)'.dependencies] +# Don't turn on the feature "std" for this, see https://github.com/rust-lang/cargo/issues/4866 +# which is still an issue with `resolver = "1"`. +libc = { version = "0.2.62", default-features = false, optional = true } + +[features] +parallel = ["dep:libc", "dep:jobserver"] +# This is a placeholder feature for people who incorrectly used `cc` with `features = ["jobserver"]` +# so that they aren't broken. This has never enabled `parallel`, so we won't do that. +jobserver = [] + +[dev-dependencies] +tempfile = "3" + +[workspace] +members = [ + "find-msvc-tools", + "dev-tools/cc-test", + "dev-tools/gen-target-info", + "dev-tools/gen-windows-sys-binding", + "dev-tools/wasi-test", +] + +[patch.crates-io] +cc = { path = "." } + +[lints.rust] +unexpected_cfgs = { level = "allow", check-cfg = ['cfg(disable_clang_cl_tests)'] } + +[profile.release] +opt-level = 3 # Or "s" or "z" for different optimization goals +lto = true + diff --git a/http/vendor/cc/LICENSE-APACHE b/http/vendor/cc/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/http/vendor/cc/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/http/vendor/cc/LICENSE-MIT b/http/vendor/cc/LICENSE-MIT new file mode 100644 index 0000000..39e0ed6 --- /dev/null +++ b/http/vendor/cc/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 Alex Crichton + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/http/vendor/cc/README.md b/http/vendor/cc/README.md new file mode 100644 index 0000000..f1d1119 --- /dev/null +++ b/http/vendor/cc/README.md @@ -0,0 +1,29 @@ +# cc-rs + +A library for +[Cargo build scripts](https://doc.rust-lang.org/cargo/reference/build-scripts.html) +to compile a set of C/C++/assembly/CUDA files into a static archive for Cargo to +link into the crate being built. This crate does not compile code itself; it +calls out to the default compiler for the platform. This crate will +automatically detect situations such as cross compilation and various +environment variables and will build code appropriately. + +Refer to the [documentation](https://docs.rs/cc) for detailed usage +instructions. + +## License + +This project is licensed under either of + + * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or + https://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or + https://opensource.org/license/mit) + +at your option. + +### Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in cc-rs by you, as defined in the Apache-2.0 license, shall be +dual licensed as above, without any additional terms or conditions. diff --git a/http/vendor/cc/clippy.toml b/http/vendor/cc/clippy.toml new file mode 100644 index 0000000..79dd5a4 --- /dev/null +++ b/http/vendor/cc/clippy.toml @@ -0,0 +1,7 @@ +disallowed-methods = [ + { path = "std::env::var_os", reason = "Please use Build::getenv" }, + { path = "std::env::var", reason = "Please use Build::getenv" }, + { path = "std::env::set_var", reason = "use `GlobalEnv::lock().set`" }, + { path = "std::env::remove_var", reason = "use `GlobalEnv::lock().remove`" }, +] +doc-valid-idents = ["AppleClang", "OpenBSD", ".."] diff --git a/http/vendor/cc/src/command_helpers.rs b/http/vendor/cc/src/command_helpers.rs new file mode 100644 index 0000000..57c49f4 --- /dev/null +++ b/http/vendor/cc/src/command_helpers.rs @@ -0,0 +1,482 @@ +//! Miscellaneous helpers for running commands + +use std::{ + borrow::Cow, + collections::hash_map, + ffi::OsString, + fmt::Display, + fs, + hash::Hasher, + io::{self, Read, Write}, + path::Path, + process::{Child, ChildStderr, Command, Output, Stdio}, + sync::{ + atomic::{AtomicBool, Ordering}, + Arc, + }, +}; + +use crate::{utilities::cargo_env_var_os, Error, ErrorKind, Object}; + +#[derive(Clone, Debug)] +pub(crate) struct CargoOutput { + pub(crate) metadata: bool, + pub(crate) warnings: bool, + pub(crate) debug: bool, + pub(crate) output: OutputKind, + checked_dbg_var: Arc, +} + +/// Different strategies for handling compiler output (to stdout) +#[derive(Clone, Debug)] +pub(crate) enum OutputKind { + /// Forward the output to this process' stdout ([`Stdio::inherit()`]) + Forward, + /// Discard the output ([`Stdio::null()`]) + Discard, + /// Capture the result ([`Stdio::piped()`]) + Capture, +} + +impl CargoOutput { + pub(crate) fn new() -> Self { + #[allow(clippy::disallowed_methods)] + Self { + metadata: true, + warnings: true, + output: OutputKind::Forward, + debug: match std::env::var_os("CC_ENABLE_DEBUG_OUTPUT") { + Some(v) => v != "0" && v != "false" && !v.is_empty(), + None => false, + }, + checked_dbg_var: Arc::new(AtomicBool::new(false)), + } + } + + pub(crate) fn print_metadata(&self, s: &dyn Display) { + if self.metadata { + println!("{s}"); + } + } + + pub(crate) fn print_warning(&self, arg: &dyn Display) { + if self.warnings { + println!("cargo:warning={arg}"); + } + } + + pub(crate) fn print_debug(&self, arg: &dyn Display) { + if self.metadata + && self + .checked_dbg_var + .compare_exchange(false, true, Ordering::Relaxed, Ordering::Relaxed) + .is_ok() + { + println!("cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT"); + } + if self.debug { + println!("{arg}"); + } + } + + fn stdio_for_warnings(&self) -> Stdio { + if self.warnings { + Stdio::piped() + } else { + Stdio::null() + } + } + + fn stdio_for_output(&self) -> Stdio { + match self.output { + OutputKind::Capture => Stdio::piped(), + OutputKind::Forward => Stdio::inherit(), + OutputKind::Discard => Stdio::null(), + } + } +} + +pub(crate) struct StderrForwarder { + inner: Option<(ChildStderr, Vec)>, + #[cfg(feature = "parallel")] + is_non_blocking: bool, + #[cfg(feature = "parallel")] + bytes_available_failed: bool, + /// number of bytes buffered in inner + bytes_buffered: usize, +} + +const MIN_BUFFER_CAPACITY: usize = 100; + +impl StderrForwarder { + pub(crate) fn new(child: &mut Child) -> Self { + Self { + inner: child + .stderr + .take() + .map(|stderr| (stderr, Vec::with_capacity(MIN_BUFFER_CAPACITY))), + bytes_buffered: 0, + #[cfg(feature = "parallel")] + is_non_blocking: false, + #[cfg(feature = "parallel")] + bytes_available_failed: false, + } + } + + pub(crate) fn forward_available(&mut self) -> bool { + if let Some((stderr, buffer)) = self.inner.as_mut() { + loop { + // For non-blocking we check to see if there is data available, so we should try to + // read at least that much. For blocking, always read at least the minimum amount. + #[cfg(not(feature = "parallel"))] + let to_reserve = MIN_BUFFER_CAPACITY; + #[cfg(feature = "parallel")] + let to_reserve = if self.is_non_blocking && !self.bytes_available_failed { + match crate::parallel::stderr::bytes_available(stderr) { + #[cfg(windows)] + Ok(0) => break false, + #[cfg(unix)] + Ok(0) => { + // On Unix, depending on the implementation, we may sometimes get 0 in a + // loop (either there is data available or the pipe is broken), so + // continue with the non-blocking read anyway. + MIN_BUFFER_CAPACITY + } + #[cfg(windows)] + Err(_) => { + // On Windows, if we get an error then the pipe is broken, so flush + // the buffer and bail. + if !buffer.is_empty() { + write_warning(&buffer[..]); + } + self.inner = None; + break true; + } + #[cfg(unix)] + Err(_) => { + // On Unix, depending on the implementation, we may get spurious + // errors so make a note not to use bytes_available again and try + // the non-blocking read anyway. + self.bytes_available_failed = true; + MIN_BUFFER_CAPACITY + } + #[cfg(target_family = "wasm")] + Err(_) => panic!("bytes_available should always succeed on wasm"), + Ok(bytes_available) => MIN_BUFFER_CAPACITY.max(bytes_available), + } + } else { + MIN_BUFFER_CAPACITY + }; + if self.bytes_buffered + to_reserve > buffer.len() { + buffer.resize(self.bytes_buffered + to_reserve, 0); + } + + match stderr.read(&mut buffer[self.bytes_buffered..]) { + Err(err) if err.kind() == std::io::ErrorKind::WouldBlock => { + // No data currently, yield back. + break false; + } + Err(err) if err.kind() == std::io::ErrorKind::Interrupted => { + // Interrupted, try again. + continue; + } + Ok(bytes_read) if bytes_read != 0 => { + self.bytes_buffered += bytes_read; + let mut consumed = 0; + for line in buffer[..self.bytes_buffered].split_inclusive(|&b| b == b'\n') { + // Only forward complete lines, leave the rest in the buffer. + if let Some((b'\n', line)) = line.split_last() { + consumed += line.len() + 1; + write_warning(line); + } + } + if consumed > 0 && consumed < self.bytes_buffered { + // Remove the consumed bytes from buffer + buffer.copy_within(consumed.., 0); + } + self.bytes_buffered -= consumed; + } + res => { + // End of stream: flush remaining data and bail. + if self.bytes_buffered > 0 { + write_warning(&buffer[..self.bytes_buffered]); + } + if let Err(err) = res { + write_warning( + format!("Failed to read from child stderr: {err}").as_bytes(), + ); + } + self.inner.take(); + break true; + } + } + } + } else { + true + } + } + + #[cfg(feature = "parallel")] + pub(crate) fn set_non_blocking(&mut self) -> Result<(), Error> { + assert!(!self.is_non_blocking); + + #[cfg(unix)] + if let Some((stderr, _)) = self.inner.as_ref() { + crate::parallel::stderr::set_non_blocking(stderr)?; + } + + self.is_non_blocking = true; + Ok(()) + } + + #[cfg(feature = "parallel")] + pub(crate) fn forward_all(&mut self) { + while !self.forward_available() {} + } + + #[cfg(not(feature = "parallel"))] + fn forward_all(&mut self) { + let forward_result = self.forward_available(); + assert!(forward_result, "Should have consumed all data"); + } +} + +fn write_warning(line: &[u8]) { + let stdout = io::stdout(); + let mut stdout = stdout.lock(); + stdout.write_all(b"cargo:warning=").unwrap(); + stdout.write_all(line).unwrap(); + stdout.write_all(b"\n").unwrap(); +} + +fn wait_on_child( + cmd: &Command, + child: &mut Child, + cargo_output: &CargoOutput, +) -> Result<(), Error> { + StderrForwarder::new(child).forward_all(); + + let status = match child.wait() { + Ok(s) => s, + Err(e) => { + return Err(Error::new( + ErrorKind::ToolExecError, + format!("failed to wait on spawned child process `{cmd:?}`: {e}"), + )); + } + }; + + cargo_output.print_debug(&status); + + if status.success() { + Ok(()) + } else { + Err(Error::new( + ErrorKind::ToolExecError, + format!("command did not execute successfully (status code {status}): {cmd:?}"), + )) + } +} + +/// Find the destination object path for each file in the input source files, +/// and store them in the output Object. +pub(crate) fn objects_from_files(files: &[Arc], dst: &Path) -> Result, Error> { + let mut objects = Vec::with_capacity(files.len()); + for file in files { + let basename = file + .file_name() + .ok_or_else(|| { + Error::new( + ErrorKind::InvalidArgument, + "No file_name for object file path!", + ) + })? + .to_string_lossy(); + let dirname = file + .parent() + .ok_or_else(|| { + Error::new( + ErrorKind::InvalidArgument, + "No parent for object file path!", + ) + })? + .to_string_lossy(); + + // Hash the dirname. This should prevent conflicts if we have multiple + // object files with the same filename in different subfolders. + let mut hasher = hash_map::DefaultHasher::new(); + + // Make the dirname relative (if possible) to avoid full system paths influencing the sha + // and making the output system-dependent + let dirname = if let Some(root) = cargo_env_var_os("CARGO_MANIFEST_DIR") { + let root = root.to_string_lossy(); + Cow::Borrowed(dirname.strip_prefix(&*root).unwrap_or(&dirname)) + } else { + dirname + }; + + hasher.write(dirname.as_bytes()); + if let Some(extension) = file.extension() { + hasher.write(extension.to_string_lossy().as_bytes()); + } + + let obj = dst + .join(format!("{:016x}-{}", hasher.finish(), basename)) + .with_extension("o"); + + match obj.parent() { + Some(s) => fs::create_dir_all(s)?, + None => { + return Err(Error::new( + ErrorKind::InvalidArgument, + "dst is an invalid path with no parent", + )); + } + }; + + objects.push(Object::new(file.to_path_buf(), obj)); + } + + Ok(objects) +} + +pub(crate) fn run(cmd: &mut Command, cargo_output: &CargoOutput) -> Result<(), Error> { + let mut child = spawn(cmd, cargo_output)?; + wait_on_child(cmd, &mut child, cargo_output) +} + +/// Like [`run`], but stderr is only forwarded as `cargo:warning=` when the +/// command succeeds. On failure, stderr is silently discarded. +/// +/// Useful for probe commands where failure is expected and the error +/// message is not actionable. +pub(crate) fn run_silent_on_error( + cmd: &mut Command, + cargo_output: &CargoOutput, +) -> Result<(), Error> { + let Output { + status, + stdout: _, + stderr, + } = spawn_and_wait_for_output(cmd, cargo_output)?; + + cargo_output.print_debug(&status); + + if status.success() { + if cargo_output.warnings { + stderr + .split(|&b| b == b'\n') + .map(|line| line.strip_suffix(b"\r").unwrap_or(line)) + .filter(|line| !line.is_empty()) + .for_each(write_warning); + } + Ok(()) + } else { + Err(Error::new( + ErrorKind::ToolExecError, + format!("command did not execute successfully (status code {status}): {cmd:?}"), + )) + } +} + +pub(crate) fn spawn_and_wait_for_output( + cmd: &mut Command, + cargo_output: &CargoOutput, +) -> Result { + // We specifically need the output to be captured, so override default + let mut captured_cargo_output = cargo_output.clone(); + captured_cargo_output.output = OutputKind::Capture; + spawn(cmd, &captured_cargo_output)? + .wait_with_output() + .map_err(|e| { + Error::new( + ErrorKind::ToolExecError, + format!("failed to wait on spawned child process `{cmd:?}`: {e}"), + ) + }) +} + +pub(crate) fn run_output(cmd: &mut Command, cargo_output: &CargoOutput) -> Result, Error> { + let Output { + status, + stdout, + stderr, + } = spawn_and_wait_for_output(cmd, cargo_output)?; + + stderr + .split(|&b| b == b'\n') + .filter(|part| !part.is_empty()) + .for_each(write_warning); + + cargo_output.print_debug(&status); + + if status.success() { + Ok(stdout) + } else { + Err(Error::new( + ErrorKind::ToolExecError, + format!("command did not execute successfully (status code {status}): {cmd:?}"), + )) + } +} + +pub(crate) fn spawn(cmd: &mut Command, cargo_output: &CargoOutput) -> Result { + struct ResetStderr<'cmd>(&'cmd mut Command); + + impl Drop for ResetStderr<'_> { + fn drop(&mut self) { + // Reset stderr to default to release pipe_writer so that print thread will + // not block forever. + self.0.stderr(Stdio::inherit()); + } + } + + cargo_output.print_debug(&format_args!("running: {cmd:?}")); + + let cmd = ResetStderr(cmd); + let child = cmd + .0 + .stderr(cargo_output.stdio_for_warnings()) + .stdout(cargo_output.stdio_for_output()) + .spawn(); + match child { + Ok(child) => Ok(child), + Err(ref e) if e.kind() == io::ErrorKind::NotFound => { + let extra = if cfg!(windows) { + " (see https://docs.rs/cc/latest/cc/#compile-time-requirements for help)" + } else { + "" + }; + Err(Error::new( + ErrorKind::ToolNotFound, + format!("failed to find tool {:?}: {e}{extra}", cmd.0.get_program()), + )) + } + Err(e) => Err(Error::new( + ErrorKind::ToolExecError, + format!("command `{:?}` failed to start: {e}", cmd.0), + )), + } +} + +pub(crate) struct CmdAddOutputFileArgs { + pub(crate) cuda: bool, + pub(crate) is_assembler_msvc: bool, + pub(crate) msvc: bool, + pub(crate) clang: bool, + pub(crate) gnu: bool, + pub(crate) is_asm: bool, + pub(crate) is_arm: bool, +} + +pub(crate) fn command_add_output_file(cmd: &mut Command, dst: &Path, args: CmdAddOutputFileArgs) { + if args.is_assembler_msvc + || !(!args.msvc || args.clang || args.gnu || args.cuda || (args.is_asm && args.is_arm)) + { + let mut s = OsString::from("-Fo"); + s.push(dst); + cmd.arg(s); + } else { + cmd.arg("-o").arg(dst); + } +} diff --git a/http/vendor/cc/src/detect_compiler_family.c b/http/vendor/cc/src/detect_compiler_family.c new file mode 100644 index 0000000..601cee6 --- /dev/null +++ b/http/vendor/cc/src/detect_compiler_family.c @@ -0,0 +1,15 @@ +#ifdef __clang__ +#pragma message "clang" +#endif + +#ifdef __GNUC__ +#pragma message "gcc" +#endif + +#ifdef __EMSCRIPTEN__ +#pragma message "emscripten" +#endif + +#ifdef __VXWORKS__ +#pragma message "VxWorks" +#endif diff --git a/http/vendor/cc/src/flags.rs b/http/vendor/cc/src/flags.rs new file mode 100644 index 0000000..f383021 --- /dev/null +++ b/http/vendor/cc/src/flags.rs @@ -0,0 +1,563 @@ +use crate::target::TargetInfo; +use crate::{Build, Error, ErrorKind, Tool, ToolFamily}; +use std::borrow::Cow; +use std::ffi::OsString; + +#[derive(Debug, PartialEq, Default)] +pub(crate) struct RustcCodegenFlags<'a> { + branch_protection: Option<&'a str>, + code_model: Option<&'a str>, + no_vectorize_loops: bool, + no_vectorize_slp: bool, + profile_generate: Option<&'a str>, + profile_use: Option<&'a str>, + control_flow_guard: Option<&'a str>, + lto: Option<&'a str>, + relocation_model: Option<&'a str>, + embed_bitcode: Option, + force_frame_pointers: Option, + no_redzone: Option, + soft_float: Option, + dwarf_version: Option, + stack_protector: Option<&'a str>, + linker_plugin_lto: Option, +} + +impl<'this> RustcCodegenFlags<'this> { + // Parse flags obtained from CARGO_ENCODED_RUSTFLAGS + pub(crate) fn parse(rustflags_env: &'this str) -> Result { + fn is_flag_prefix(flag: &str) -> bool { + [ + "-Z", + "-C", + "--codegen", + "-L", + "-l", + "-o", + "-W", + "--warn", + "-A", + "--allow", + "-D", + "--deny", + "-F", + "--forbid", + ] + .contains(&flag) + } + + fn handle_flag_prefix<'a>(prev: &'a str, curr: &'a str) -> (&'a str, &'a str) { + match prev { + "--codegen" | "-C" => ("-C", curr), + // Handle flags passed like --codegen=code-model=small + _ if curr.starts_with("--codegen=") => ("-C", &curr[10..]), + "-Z" => ("-Z", curr), + "-L" | "-l" | "-o" => (prev, curr), + // Handle lint flags + "-W" | "--warn" => ("-W", curr), + "-A" | "--allow" => ("-A", curr), + "-D" | "--deny" => ("-D", curr), + "-F" | "--forbid" => ("-F", curr), + _ => ("", curr), + } + } + + let mut codegen_flags = Self::default(); + + let mut prev_prefix = None; + for curr in rustflags_env.split("\u{1f}") { + let prev = prev_prefix.take().unwrap_or(""); + if prev.is_empty() && is_flag_prefix(curr) { + prev_prefix = Some(curr); + continue; + } + + let (prefix, rustc_flag) = handle_flag_prefix(prev, curr); + codegen_flags.set_rustc_flag(prefix, rustc_flag)?; + } + + Ok(codegen_flags) + } + + fn set_rustc_flag(&mut self, prefix: &str, flag: &'this str) -> Result<(), Error> { + // Convert a textual representation of a bool-like rustc flag argument into an actual bool + fn arg_to_bool(arg: impl AsRef) -> Option { + match arg.as_ref() { + "y" | "yes" | "on" | "true" => Some(true), + "n" | "no" | "off" | "false" => Some(false), + _ => None, + } + } + + fn arg_to_u32(arg: impl AsRef) -> Option { + arg.as_ref().parse().ok() + } + + let (flag, value) = if let Some((flag, value)) = flag.split_once('=') { + (flag, Some(value)) + } else { + (flag, None) + }; + let flag = if prefix.is_empty() { + Cow::Borrowed(flag) + } else { + Cow::Owned(format!("{prefix}{flag}")) + }; + let flag = flag.as_ref(); + + fn flag_not_empty_generic( + flag: &str, + flag_value: Option, + ) -> Result, Error> { + if let Some(flag_value) = flag_value { + Ok(Some(flag_value)) + } else { + Err(Error::new( + ErrorKind::InvalidFlag, + format!("{flag} must have a value"), + )) + } + } + let flag_not_empty = |flag_value| flag_not_empty_generic(flag, flag_value); + + match flag { + // https://doc.rust-lang.org/rustc/codegen-options/index.html#code-model + "-Ccode-model" => { + self.code_model = flag_not_empty(value)?; + } + // https://doc.rust-lang.org/rustc/codegen-options/index.html#no-vectorize-loops + "-Cno-vectorize-loops" => self.no_vectorize_loops = true, + // https://doc.rust-lang.org/rustc/codegen-options/index.html#no-vectorize-slp + "-Cno-vectorize-slp" => self.no_vectorize_slp = true, + // https://doc.rust-lang.org/rustc/codegen-options/index.html#profile-generate + "-Cprofile-generate" => { + self.profile_generate = flag_not_empty(value)?; + } + // https://doc.rust-lang.org/rustc/codegen-options/index.html#profile-use + "-Cprofile-use" => { + self.profile_use = flag_not_empty(value)?; + } + // https://doc.rust-lang.org/rustc/codegen-options/index.html#control-flow-guard + "-Ccontrol-flow-guard" => self.control_flow_guard = value.or(Some("true")), + // https://doc.rust-lang.org/rustc/codegen-options/index.html#lto + // + // This variable is currently unused, we just keep it in case we need it in future + "-Clto" => self.lto = value.or(Some("true")), + // https://doc.rust-lang.org/rustc/linker-plugin-lto.html + "-Clinker-plugin-lto" => self.linker_plugin_lto = Some(true), + // https://doc.rust-lang.org/rustc/codegen-options/index.html#relocation-model + "-Crelocation-model" => { + self.relocation_model = flag_not_empty(value)?; + } + // https://doc.rust-lang.org/rustc/codegen-options/index.html#embed-bitcode + "-Cembed-bitcode" => self.embed_bitcode = value.map_or(Some(true), arg_to_bool), + // https://doc.rust-lang.org/rustc/codegen-options/index.html#force-frame-pointers + "-Cforce-frame-pointers" => { + self.force_frame_pointers = value.map_or(Some(true), arg_to_bool) + } + // https://doc.rust-lang.org/rustc/codegen-options/index.html#no-redzone + "-Cno-redzone" => self.no_redzone = value.map_or(Some(true), arg_to_bool), + // https://doc.rust-lang.org/rustc/codegen-options/index.html#soft-float + // Note: This flag is now deprecated in rustc. + "-Csoft-float" => self.soft_float = value.map_or(Some(true), arg_to_bool), + // https://doc.rust-lang.org/beta/unstable-book/compiler-flags/branch-protection.html + // FIXME: Drop the -Z variant and update the doc link once the option is stabilised + "-Zbranch-protection" | "-Cbranch-protection" => { + self.branch_protection = flag_not_empty(value)?; + } + // https://doc.rust-lang.org/beta/rustc/codegen-options/index.html#dwarf-version + "-Cdwarf-version" => { + self.dwarf_version = flag_not_empty_generic(flag, value.and_then(arg_to_u32))?; + } + // https://github.com/rust-lang/rust/issues/114903 + // FIXME: Drop the -Z variant and update the doc link once the option is stabilized + "-Zstack-protector" | "-Cstack-protector" => { + self.stack_protector = flag_not_empty(value)?; + } + _ => {} + } + Ok(()) + } + + // Rust and clang/cc don't agree on what equivalent flags should look like. + pub(crate) fn cc_flags(&self, build: &Build, tool: &mut Tool, target: &TargetInfo<'_>) { + let family = tool.family; + // Push `flag` to `flags` if it is supported by the currently used CC + let mut push_if_supported = |flag: OsString| { + if build + .is_flag_supported_inner(&flag, tool, target) + .unwrap_or(false) + { + tool.args.push(flag); + } else { + build.cargo_output.print_warning(&format!( + "Inherited flag {flag:?} is not supported by the currently used CC" + )); + } + }; + + let clang_or_gnu = + matches!(family, ToolFamily::Clang { .. }) || matches!(family, ToolFamily::Gnu); + + // Flags shared between clang and gnu + if clang_or_gnu { + // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mbranch-protection + // https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html#index-mbranch-protection (Aarch64) + // https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html#index-mbranch-protection-1 (ARM) + // https://developer.arm.com/documentation/101754/0619/armclang-Reference/armclang-Command-line-Options/-mbranch-protection + if let Some(value) = self.branch_protection { + push_if_supported( + format!("-mbranch-protection={}", value.replace(",", "+")).into(), + ); + } + // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mcmodel + // https://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html (several archs, search for `-mcmodel=`). + // FIXME(madsmtm): Parse the model, to make sure we pass the correct value (depending on arch). + if let Some(value) = self.code_model { + push_if_supported(format!("-mcmodel={value}").into()); + } + // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fno-vectorize + // https://gcc.gnu.org/onlinedocs/gnat_ugn/Vectorization-of-loops.html + if self.no_vectorize_loops { + push_if_supported("-fno-vectorize".into()); + } + // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fno-slp-vectorize + // https://gcc.gnu.org/onlinedocs/gnat_ugn/Vectorization-of-loops.html + if self.no_vectorize_slp { + push_if_supported("-fno-slp-vectorize".into()); + } + if let Some(value) = self.relocation_model { + let cc_flag = match value { + // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fPIC + // https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#index-fPIC + "pic" => Some("-fPIC"), + // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fPIE + // https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#index-fPIE + "pie" => Some("-fPIE"), + // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mdynamic-no-pic + // https://gcc.gnu.org/onlinedocs/gcc/RS_002f6000-and-PowerPC-Options.html#index-mdynamic-no-pic + "dynamic-no-pic" => Some("-mdynamic-no-pic"), + _ => None, + }; + if let Some(cc_flag) = cc_flag { + push_if_supported(cc_flag.into()); + } + } + // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fno-omit-frame-pointer + // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fomit-frame-pointer + // https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-fomit-frame-pointer + if let Some(value) = self.force_frame_pointers { + let cc_flag = if value { + "-fno-omit-frame-pointer" + } else { + "-fomit-frame-pointer" + }; + push_if_supported(cc_flag.into()); + } + // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mno-red-zone + // https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html#index-mno-red-zone + // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mred-zone + // https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html#index-mred-zone + if let Some(value) = self.no_redzone { + let cc_flag = if value { "-mno-red-zone" } else { "-mred-zone" }; + push_if_supported(cc_flag.into()); + } + // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-msoft-float + // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mhard-float + // https://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html (several archs, search for `-msoft-float`). + // https://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html (several archs, search for `-mhard-float`). + if let Some(value) = self.soft_float { + let cc_flag = if value { + "-msoft-float" + } else { + // Do not use -mno-soft-float, that's basically just an alias for -mno-implicit-float. + "-mhard-float" + }; + push_if_supported(cc_flag.into()); + } + // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-gdwarf-2 + // https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html#index-gdwarf + if let Some(value) = self.dwarf_version { + push_if_supported(format!("-gdwarf-{value}").into()); + } + // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fstack-protector + // https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html#index-fstack-protector + if let Some(value) = self.stack_protector { + // don't need to propagate stack-protector on MSVC since /GS is already the default + // https://learn.microsoft.com/en-us/cpp/build/reference/gs-buffer-security-check?view=msvc-170 + // + // Do NOT `stack-protector=none` since it weakens security for C code, + // and `-Zstack-protector=basic` is deprecated and will be removed soon. + let cc_flag = match value { + "strong" => Some("-fstack-protector-strong"), + "all" => Some("-fstack-protector-all"), + _ => None, + }; + if let Some(cc_flag) = cc_flag { + push_if_supported(cc_flag.into()); + } + } + } + + // Compiler-exclusive flags + match family { + ToolFamily::Clang { .. } => { + // GNU and Clang compilers both support the same PGO flags, but they use different libraries and + // different formats for the profile files which are not compatible. + // clang and rustc both internally use llvm, so we want to inherit the PGO flags only for clang. + // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fprofile-generate + if let Some(value) = self.profile_generate { + push_if_supported(format!("-fprofile-generate={value}").into()); + } + // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fprofile-use + if let Some(value) = self.profile_use { + push_if_supported(format!("-fprofile-use={value}").into()); + } + + // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fembed-bitcode + if let Some(value) = self.embed_bitcode { + let cc_val = if value { "all" } else { "off" }; + push_if_supported(format!("-fembed-bitcode={cc_val}").into()); + } + + // https://doc.rust-lang.org/rustc/linker-plugin-lto.html + if self.linker_plugin_lto.unwrap_or(false) { + // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-flto + // In order to use linker-plugin-lto to achieve cross-lang lto, cc has to use thin LTO + // to compile the c/c++ libraries because llvm linker plugin/lld uses thin LTO by default. + // And for thin LTO in linker plugin to work, the archive also has to be compiled using thin LTO, + // since thin LTO generates extra information that fat LTO does not generate that + // is required for thin LTO process. + push_if_supported("-flto=thin".into()); + } + // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mguard + if let Some(value) = self.control_flow_guard { + let cc_val = match value { + "y" | "yes" | "on" | "true" | "checks" => Some("cf"), + "nochecks" => Some("cf-nochecks"), + "n" | "no" | "off" | "false" => Some("none"), + _ => None, + }; + if let Some(cc_val) = cc_val { + push_if_supported(format!("-mguard={cc_val}").into()); + } + } + } + ToolFamily::Gnu => {} + ToolFamily::Msvc { .. } => { + // https://learn.microsoft.com/en-us/cpp/build/reference/guard-enable-control-flow-guard + if let Some(value) = self.control_flow_guard { + let cc_val = match value { + "y" | "yes" | "on" | "true" | "checks" => Some("cf"), + "n" | "no" | "off" | "false" => Some("cf-"), + _ => None, + }; + if let Some(cc_val) = cc_val { + push_if_supported(format!("/guard:{cc_val}").into()); + } + } + // https://learn.microsoft.com/en-us/cpp/build/reference/oy-frame-pointer-omission + if let Some(value) = self.force_frame_pointers { + // Flag is unsupported on 64-bit arches + if !target.arch.contains("64") { + let cc_flag = if value { "/Oy-" } else { "/Oy" }; + push_if_supported(cc_flag.into()); + } + } + } + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[track_caller] + fn check(env: &str, expected: &RustcCodegenFlags) { + let actual = RustcCodegenFlags::parse(env).unwrap(); + assert_eq!(actual, *expected); + } + + #[test] + fn codegen_type() { + let expected = RustcCodegenFlags { + code_model: Some("tiny"), + ..RustcCodegenFlags::default() + }; + check("-Ccode-model=tiny", &expected); + check("-C\u{1f}code-model=tiny", &expected); + check("--codegen\u{1f}code-model=tiny", &expected); + check("--codegen=code-model=tiny", &expected); + } + + #[test] + fn precedence() { + check( + "-ccode-model=tiny\u{1f}-Ccode-model=small", + &RustcCodegenFlags { + code_model: Some("small"), + ..RustcCodegenFlags::default() + }, + ); + } + + #[test] + fn two_valid_prefixes() { + let expected = RustcCodegenFlags::default(); + check("-L\u{1f}-Clto", &expected); + } + + #[test] + fn stack_protector() { + let expected = RustcCodegenFlags { + stack_protector: Some("strong"), + ..RustcCodegenFlags::default() + }; + check("-Zstack-protector=strong", &expected); + check("-Cstack-protector=strong", &expected); + } + + #[test] + fn three_valid_prefixes() { + let expected = RustcCodegenFlags { + lto: Some("true"), + ..RustcCodegenFlags::default() + }; + check("-L\u{1f}-L\u{1f}-Clto", &expected); + } + + #[test] + fn all_rustc_flags() { + // Throw all possible flags at the parser to catch false positives + let flags = [ + // Set all the flags we recognise first + "-Ccode-model=tiny", + "-Ccontrol-flow-guard=yes", + "-Cembed-bitcode=no", + "-Cforce-frame-pointers=yes", + "-Clto=false", + "-Clink-dead-code=yes", + "-Cno-redzone=yes", + "-Cno-vectorize-loops", + "-Cno-vectorize-slp", + "-Cprofile-generate=fooprofile", + "-Cprofile-use=fooprofile", + "-Crelocation-model=pic", + "-Csoft-float=yes", + "-Zbranch-protection=bti,pac-ret,leaf", + "-Cdwarf-version=5", + "-Zstack-protector=strong", + // Set flags we don't recognise but rustc supports next + // rustc flags + "--cfg", + "a", + "--check-cfg 'cfg(verbose)", + "-L", + "/usr/lib/foo", + "-l", + "static:+whole-archive=mylib", + "--crate-type=dylib", + "--crate-name=foo", + "--edition=2021", + "--emit=asm", + "--print=crate-name", + "-g", + "-O", + "-o", + "foooutput", + "--out-dir", + "foooutdir", + "--target", + "aarch64-unknown-linux-gnu", + "-W", + "missing-docs", + "-D", + "unused-variables", + "--force-warn", + "dead-code", + "-A", + "unused", + "-F", + "unused", + "--cap-lints", + "warn", + "--version", + "--verbose", + "-v", + "--extern", + "foocrate", + "--sysroot", + "fooroot", + "--error-format", + "human", + "--color", + "auto", + "--diagnostic-width", + "80", + "--remap-path-prefix", + "foo=bar", + "--json=artifact", + // Codegen flags + "-Car", + "-Ccodegen-units=1", + "-Ccollapse-macro-debuginfo=yes", + "-Cdebug-assertions=yes", + "-Cdebuginfo=1", + "-Cdefault-linker-libraries=yes", + "-Cdlltool=foo", + "-Cextra-filename=foo", + "-Cforce-unwind-tables=yes", + "-Cincremental=foodir", + "-Cinline-threshold=6", + "-Cinstrument-coverage", + "-Clink-arg=-foo", + "-Clink-args=-foo", + "-Clink-self-contained=yes", + "-Clinker=lld", + "-Clinker-flavor=ld.lld", + "-Clinker-plugin-lto=/path", + "-Cllvm-args=foo", + "-Cmetadata=foo", + "-Cno-prepopulate-passes", + "-Cno-stack-check", + "-Copt-level=3", + "-Coverflow-checks=yes", + "-Cpanic=abort", + "-Cpasses=foopass", + "-Cprefer-dynamic=yes", + "-Crelro-level=partial", + "-Cremark=all", + "-Crpath=yes", + "-Csave-temps=yes", + "-Csplit-debuginfo=packed", + "-Cstrip=symbols", + "-Csymbol-mangling-version=v0", + "-Ctarget-cpu=native", + "-Ctarget-feature=+sve", + // Unstable options + "-Ztune-cpu=machine", + ]; + check( + &flags.join("\u{1f}"), + &RustcCodegenFlags { + code_model: Some("tiny"), + control_flow_guard: Some("yes"), + embed_bitcode: Some(false), + force_frame_pointers: Some(true), + lto: Some("false"), + no_redzone: Some(true), + no_vectorize_loops: true, + no_vectorize_slp: true, + profile_generate: Some("fooprofile"), + profile_use: Some("fooprofile"), + relocation_model: Some("pic"), + soft_float: Some(true), + branch_protection: Some("bti,pac-ret,leaf"), + dwarf_version: Some(5), + stack_protector: Some("strong"), + linker_plugin_lto: Some(true), + }, + ); + } +} diff --git a/http/vendor/cc/src/lib.rs b/http/vendor/cc/src/lib.rs new file mode 100644 index 0000000..e230a38 --- /dev/null +++ b/http/vendor/cc/src/lib.rs @@ -0,0 +1,4547 @@ +//! A library for [Cargo build scripts](https://doc.rust-lang.org/cargo/reference/build-scripts.html) +//! to compile a set of C/C++/assembly/CUDA files into a static archive for Cargo +//! to link into the crate being built. This crate does not compile code itself; +//! it calls out to the default compiler for the platform. This crate will +//! automatically detect situations such as cross compilation and +//! [various environment variables](#external-configuration-via-environment-variables) and will build code appropriately. +//! +//! # Example +//! +//! First, you'll want to both add a build script for your crate (`build.rs`) and +//! also add this crate to your `Cargo.toml` via: +//! +//! ```toml +//! [build-dependencies] +//! cc = "1.0" +//! ``` +//! +//! Next up, you'll want to write a build script like so: +//! +//! ```rust,no_run +//! // build.rs +//! cc::Build::new() +//! .file("foo.c") +//! .file("bar.c") +//! .compile("foo"); +//! ``` +//! +//! And that's it! Running `cargo build` should take care of the rest and your Rust +//! application will now have the C files `foo.c` and `bar.c` compiled into a file +//! named `libfoo.a`. If the C files contain +//! +//! ```c +//! void foo_function(void) { ... } +//! ``` +//! +//! and +//! +//! ```c +//! int32_t bar_function(int32_t x) { ... } +//! ``` +//! +//! you can call them from Rust by declaring them in +//! your Rust code like so: +//! +//! ```rust,no_run +//! extern "C" { +//! fn foo_function(); +//! fn bar_function(x: i32) -> i32; +//! } +//! +//! pub fn call() { +//! unsafe { +//! foo_function(); +//! bar_function(42); +//! } +//! } +//! +//! fn main() { +//! call(); +//! } +//! ``` +//! +//! See [the Rustonomicon](https://doc.rust-lang.org/nomicon/ffi.html) for more details. +//! +//! # External configuration via environment variables +//! +//! To control the programs and flags used for building, the builder can set a +//! number of different environment variables. +//! +//! * `CFLAGS` - a series of space separated flags passed to compilers. Note that +//! individual flags cannot currently contain spaces, so doing +//! something like: `-L=foo\ bar` is not possible. +//! * `CC` - the actual C compiler used. Note that this supports passing a known +//! wrapper via `sccache cc`. This compiler must understand the `-c` flag. For +//! certain `TARGET`s, it also is assumed to know about other flags (most +//! common is `-fPIC`). +//! ccache, distcc, sccache, icecc, cachepot and buildcache are supported, +//! for sccache, simply set `CC` to `sccache cc`. +//! For other custom `CC` wrapper, just set `CC_KNOWN_WRAPPER_CUSTOM` +//! to the custom wrapper used in `CC`. +//! * `AR` - the `ar` (archiver) executable to use to build the static library. +//! * `CRATE_CC_NO_DEFAULTS` - the default compiler flags may cause conflicts in +//! some cross compiling scenarios. Setting this variable +//! will disable the generation of default compiler +//! flags. +//! * `CC_ENABLE_DEBUG_OUTPUT` - if set, compiler command invocations and exit codes will +//! be logged to stdout. This is useful for debugging build script issues, but can be +//! overly verbose for normal use. +//! * `CC_SHELL_ESCAPED_FLAGS` - if set, `*FLAGS` will be parsed as if they were shell +//! arguments (similar to `make` and `cmake`) rather than splitting them on each space. +//! For example, with `CFLAGS='a "b c"'`, the compiler will be invoked with 2 arguments - +//! `a` and `b c` - rather than 3: `a`, `"b` and `c"`. +//! * `CXX...` - see [C++ Support](#c-support). +//! * `CC_FORCE_DISABLE` - If set, `cc` will never run any [`Command`]s, and methods that +//! would return an [`Error`]. This is intended for use by third-party build systems +//! which want to be absolutely sure that they are in control of building all +//! dependencies. Note that operations that return [`Tool`]s such as +//! [`Build::get_compiler`] may produce less accurate results as in some cases `cc` runs +//! commands in order to locate compilers. Additionally, this does nothing to prevent +//! users from running [`Tool::to_command`] and executing the [`Command`] themselves. +//! * `RUSTC_WRAPPER` - If set, the specified command will be prefixed to the compiler +//! command. This is useful for projects that want to use +//! [sccache](https://github.com/mozilla/sccache), +//! [buildcache](https://gitlab.com/bits-n-bites/buildcache), or +//! [cachepot](https://github.com/paritytech/cachepot). +//! +//! Furthermore, projects using this crate may specify custom environment variables +//! to be inspected, for example via the `Build::try_flags_from_environment` +//! function. Consult the project’s own documentation or its use of the `cc` crate +//! for any additional variables it may use. +//! +//! Each of these variables can also be supplied with certain prefixes and suffixes, +//! in the following prioritized order: +//! +//! 1. `_` - for example, `CC_x86_64-unknown-linux-gnu` or `CC_thumbv8m.main-none-eabi` +//! 2. `_` - for example, `CC_x86_64_unknown_linux_gnu` or `CC_thumbv8m_main_none_eabi` (both periods and underscores are replaced) +//! 3. `_` - for example, `HOST_CC` or `TARGET_CFLAGS` +//! 4. `` - a plain `CC`, `AR` as above. +//! +//! If none of these variables exist, cc-rs uses built-in defaults. +//! +//! In addition to the above optional environment variables, `cc-rs` has some +//! functions with hard requirements on some variables supplied by [cargo's +//! build-script driver][cargo] that it has the `TARGET`, `OUT_DIR`, `OPT_LEVEL`, +//! and `HOST` variables. +//! +//! [cargo]: https://doc.rust-lang.org/cargo/reference/build-scripts.html#inputs-to-the-build-script +//! +//! # Optional features +//! +//! ## Parallel +//! +//! Currently cc-rs supports parallel compilation (think `make -jN`) but this +//! feature is turned off by default. To enable cc-rs to compile C/C++ in parallel, +//! you can change your dependency to: +//! +//! ```toml +//! [build-dependencies] +//! cc = { version = "1.0", features = ["parallel"] } +//! ``` +//! +//! By default cc-rs will limit parallelism to `$NUM_JOBS`, or if not present it +//! will limit it to the number of cpus on the machine. If you are using cargo, +//! use `-jN` option of `build`, `test` and `run` commands as `$NUM_JOBS` +//! is supplied by cargo. +//! +//! # Compile-time Requirements +//! +//! To work properly this crate needs access to a C compiler when the build script +//! is being run. This crate does not ship a C compiler with it. The compiler +//! required varies per platform, but there are three broad categories: +//! +//! * Unix platforms require `cc` to be the C compiler. This can be found by +//! installing cc/clang on Linux distributions and Xcode on macOS, for example. +//! * Windows platforms targeting MSVC (e.g. your target name ends in `-msvc`) +//! require Visual Studio to be installed. `cc-rs` attempts to locate it, and +//! if it fails, `cl.exe` is expected to be available in `PATH`. This can be +//! set up by running the appropriate developer tools shell. +//! * When using `prefer_clang_cl_over_msvc`, make sure that the `C++ Clang compiler for Windows` component +//! is installed through the Visual Studio Installer, so that `cc-rs` can find `clang-cl.exe`. +//! * Windows platforms targeting MinGW (e.g. your target name ends in `-gnu`) +//! require `cc` to be available in `PATH`. We recommend the +//! [MinGW-w64](https://www.mingw-w64.org/) distribution. +//! You may also acquire it via +//! [MSYS2](https://www.msys2.org/), as explained [here][msys2-help]. Make sure +//! to install the appropriate architecture corresponding to your installation of +//! rustc. GCC from older [MinGW](http://www.mingw.org/) project is compatible +//! only with 32-bit rust compiler. +//! +//! [msys2-help]: https://github.com/rust-lang/rust/blob/master/INSTALL.md#building-on-windows +//! +//! # C++ support +//! +//! `cc-rs` supports C++ libraries compilation by using the `cpp` method on +//! `Build`: +//! +//! ```rust,no_run +//! cc::Build::new() +//! .cpp(true) // Switch to C++ library compilation. +//! .file("foo.cpp") +//! .compile("foo"); +//! ``` +//! +//! For C++ libraries, the `CXX` and `CXXFLAGS` environment variables are used instead of `CC` and `CFLAGS`. +//! +//! The C++ standard library may be linked to the crate target. By default it's `libc++` for macOS, FreeBSD, and OpenBSD, `libc++_shared` for Android, nothing for MSVC, and `libstdc++` for anything else. It can be changed in one of two ways: +//! +//! 1. by using the `cpp_link_stdlib` method on `Build`: +//! ```rust,no_run +//! cc::Build::new() +//! .cpp(true) +//! .file("foo.cpp") +//! .cpp_link_stdlib("stdc++") // use libstdc++ +//! .compile("foo"); +//! ``` +//! 2. by setting the `CXXSTDLIB` environment variable. +//! +//! In particular, for Android you may want to [use `c++_static` if you have at most one shared library](https://developer.android.com/ndk/guides/cpp-support). +//! +//! Remember that C++ does name mangling so `extern "C"` might be required to enable Rust linker to find your functions. +//! +//! # CUDA C++ support +//! +//! `cc-rs` also supports compiling CUDA C++ libraries by using the `cuda` method +//! on `Build`: +//! +//! ```rust,no_run +//! cc::Build::new() +//! // Switch to CUDA C++ library compilation using NVCC. +//! .cuda(true) +//! .cudart("static") +//! // Generate code for Maxwell (GTX 970, 980, 980 Ti, Titan X). +//! .flag("-gencode").flag("arch=compute_52,code=sm_52") +//! // Generate code for Maxwell (Jetson TX1). +//! .flag("-gencode").flag("arch=compute_53,code=sm_53") +//! // Generate code for Pascal (GTX 1070, 1080, 1080 Ti, Titan Xp). +//! .flag("-gencode").flag("arch=compute_61,code=sm_61") +//! // Generate code for Pascal (Tesla P100). +//! .flag("-gencode").flag("arch=compute_60,code=sm_60") +//! // Generate code for Pascal (Jetson TX2). +//! .flag("-gencode").flag("arch=compute_62,code=sm_62") +//! // Generate code in parallel +//! .flag("-t0") +//! .file("bar.cu") +//! .compile("bar"); +//! ``` +//! +//! # Speed up compilation with sccache +//! +//! `cc-rs` does not handle incremental compilation like `make` or `ninja`. It +//! always compiles the all sources, no matter if they have changed or not. +//! This would be time-consuming in large projects. To save compilation time, +//! you can use [sccache](https://github.com/mozilla/sccache) by setting +//! environment variable `RUSTC_WRAPPER=sccache`, which will use cached `.o` +//! files if the sources are unchanged. + +#![doc(html_root_url = "https://docs.rs/cc/1.0")] +#![deny(warnings)] +#![deny(missing_docs)] +#![deny(clippy::disallowed_methods)] +#![warn(clippy::doc_markdown)] + +use std::borrow::Cow; +use std::collections::HashMap; +use std::env; +use std::ffi::{OsStr, OsString}; +use std::fmt::{self, Display}; +use std::fs; +use std::io::{self, Write}; +use std::path::{Component, Path, PathBuf}; +use std::process::{Command, Stdio}; +use std::sync::{Arc, RwLock}; + +use shlex::Shlex; + +#[cfg(feature = "parallel")] +mod parallel; + +mod target; +use self::target::*; + +/// A helper module to looking for windows-specific tools: +/// 1. On Windows host, probe the Windows Registry if needed; +/// 2. On non-Windows host, check specified environment variables. +pub mod windows_registry { + // Regardless of whether this should be in this crate's public API, + // it has been since 2015, so don't break it. + + /// Attempts to find a tool within an MSVC installation using the Windows + /// registry as a point to search from. + /// + /// The `arch_or_target` argument is the architecture or the Rust target name + /// that the tool should work for (e.g. compile or link for). The supported + /// architecture names are: + /// - `"x64"` or `"x86_64"` + /// - `"arm64"` or `"aarch64"` + /// - `"arm64ec"` + /// - `"x86"`, `"i586"` or `"i686"` + /// - `"arm"` or `"thumbv7a"` + /// + /// The `tool` argument is the tool to find. Supported tools include: + /// - MSVC tools: `cl.exe`, `link.exe`, `lib.exe`, etc. + /// - `MSBuild`: `msbuild.exe` + /// - Visual Studio IDE: `devenv.exe` + /// - Clang/LLVM tools: `clang.exe`, `clang++.exe`, `clang-*.exe`, `llvm-*.exe`, `lld.exe`, etc. + /// + /// This function will return `None` if the tool could not be found, or it will + /// return `Some(cmd)` which represents a command that's ready to execute the + /// tool with the appropriate environment variables set. + /// + /// Note that this function always returns `None` for non-MSVC targets (if a + /// full target name was specified). + pub fn find(arch_or_target: &str, tool: &str) -> Option { + ::find_msvc_tools::find(arch_or_target, tool) + } + + /// A version of Visual Studio + #[derive(Debug, PartialEq, Eq, Copy, Clone)] + #[non_exhaustive] + pub enum VsVers { + /// Visual Studio 12 (2013) + #[deprecated = "Visual Studio 12 is no longer supported. cc will never return this value."] + Vs12, + /// Visual Studio 14 (2015) + Vs14, + /// Visual Studio 15 (2017) + Vs15, + /// Visual Studio 16 (2019) + Vs16, + /// Visual Studio 17 (2022) + Vs17, + /// Visual Studio 18 (2026) + Vs18, + } + + /// Find the most recent installed version of Visual Studio + /// + /// This is used by the cmake crate to figure out the correct + /// generator. + pub fn find_vs_version() -> Result { + ::find_msvc_tools::find_vs_version().map(|vers| match vers { + #[allow(deprecated)] + ::find_msvc_tools::VsVers::Vs12 => VsVers::Vs12, + ::find_msvc_tools::VsVers::Vs14 => VsVers::Vs14, + ::find_msvc_tools::VsVers::Vs15 => VsVers::Vs15, + ::find_msvc_tools::VsVers::Vs16 => VsVers::Vs16, + ::find_msvc_tools::VsVers::Vs17 => VsVers::Vs17, + ::find_msvc_tools::VsVers::Vs18 => VsVers::Vs18, + _ => unreachable!("unknown VS version"), + }) + } + + /// Similar to the `find` function above, this function will attempt the same + /// operation (finding a MSVC tool in a local install) but instead returns a + /// [`Tool`](crate::Tool) which may be introspected. + pub fn find_tool(arch_or_target: &str, tool: &str) -> Option { + ::find_msvc_tools::find_tool(arch_or_target, tool).map(crate::Tool::from_find_msvc_tools) + } +} + +mod command_helpers; +use command_helpers::*; + +mod tool; +pub use tool::Tool; +use tool::{CompilerFamilyLookupCache, ToolFamily}; + +mod tempfile; + +mod utilities; +use utilities::*; + +mod flags; +use flags::*; + +#[derive(Debug, Eq, PartialEq, Hash)] +struct CompilerFlag { + compiler: Box, + flag: Box, +} + +#[derive(Debug, Default)] +struct BuildCache { + apple_sdk_root_cache: RwLock, Arc>>, + apple_versions_cache: RwLock, Arc>>, + cached_compiler_family: RwLock, + known_flag_support_status_cache: RwLock>, + target_info_parser: target::TargetInfoParser, +} + +/// A builder for compilation of a native library. +/// +/// A `Build` is the main type of the `cc` crate and is used to control all the +/// various configuration options and such of a compile. You'll find more +/// documentation on each method itself. +#[derive(Clone, Debug)] +pub struct Build { + include_directories: Vec>, + definitions: Vec<(Arc, Option>)>, + objects: Vec>, + flags: Vec>, + flags_supported: Vec>, + ar_flags: Vec>, + asm_flags: Vec>, + no_default_flags: bool, + files: Vec>, + cpp: bool, + cpp_link_stdlib: Option>>, + cpp_link_stdlib_static: bool, + cpp_set_stdlib: Option>, + cuda: bool, + cudart: Option>, + ccbin: bool, + std: Option>, + target: Option>, + /// The host compiler. + /// + /// Try to not access this directly, and instead prefer `cfg!(...)`. + host: Option>, + out_dir: Option>, + opt_level: Option>, + debug: Option>, + force_frame_pointer: Option, + env: Vec<(Arc, Arc)>, + compiler: Option>, + archiver: Option>, + ranlib: Option>, + cargo_output: CargoOutput, + link_lib_modifiers: Vec>, + pic: Option, + use_plt: Option, + static_crt: Option, + shared_flag: Option, + static_flag: Option, + warnings_into_errors: bool, + warnings: Option, + extra_warnings: Option, + emit_rerun_if_env_changed: bool, + shell_escaped_flags: Option, + build_cache: Arc, + inherit_rustflags: bool, + prefer_clang_cl_over_msvc: bool, +} + +/// Represents the types of errors that may occur while using cc-rs. +#[derive(Clone, Debug)] +enum ErrorKind { + /// Error occurred while performing I/O. + IOError, + /// Environment variable not found, with the var in question as extra info. + EnvVarNotFound, + /// Error occurred while using external tools (ie: invocation of compiler). + ToolExecError, + /// Error occurred due to missing external tools. + ToolNotFound, + /// One of the function arguments failed validation. + InvalidArgument, + /// No known macro is defined for the compiler when discovering tool family. + ToolFamilyMacroNotFound, + /// Invalid target. + InvalidTarget, + /// Unknown target. + UnknownTarget, + /// Invalid rustc flag. + InvalidFlag, + #[cfg(feature = "parallel")] + /// jobserver helpthread failure + JobserverHelpThreadError, + /// `cc` has been disabled by an environment variable. + Disabled, +} + +/// Represents an internal error that occurred, with an explanation. +#[derive(Clone, Debug)] +pub struct Error { + /// Describes the kind of error that occurred. + kind: ErrorKind, + /// More explanation of error that occurred. + message: Cow<'static, str>, +} + +impl Error { + fn new(kind: ErrorKind, message: impl Into>) -> Error { + Error { + kind, + message: message.into(), + } + } +} + +impl From for Error { + fn from(e: io::Error) -> Error { + Error::new(ErrorKind::IOError, format!("{e}")) + } +} + +impl Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{:?}: {}", self.kind, self.message) + } +} + +impl std::error::Error for Error {} + +/// Represents an object. +/// +/// This is a source file -> object file pair. +#[derive(Clone, Debug)] +struct Object { + src: PathBuf, + dst: PathBuf, +} + +impl Object { + /// Create a new source file -> object file pair. + fn new(src: PathBuf, dst: PathBuf) -> Object { + Object { src, dst } + } +} + +/// Configure the builder. +impl Build { + /// Construct a new instance of a blank set of configuration. + /// + /// This builder is finished with the [`compile`] function. + /// + /// [`compile`]: struct.Build.html#method.compile + pub fn new() -> Build { + Build { + include_directories: Vec::new(), + definitions: Vec::new(), + objects: Vec::new(), + flags: Vec::new(), + flags_supported: Vec::new(), + ar_flags: Vec::new(), + asm_flags: Vec::new(), + no_default_flags: false, + files: Vec::new(), + shared_flag: None, + static_flag: None, + cpp: false, + cpp_link_stdlib: None, + cpp_link_stdlib_static: false, + cpp_set_stdlib: None, + cuda: false, + cudart: None, + ccbin: true, + std: None, + target: None, + host: None, + out_dir: None, + opt_level: None, + debug: None, + force_frame_pointer: None, + env: Vec::new(), + compiler: None, + archiver: None, + ranlib: None, + cargo_output: CargoOutput::new(), + link_lib_modifiers: Vec::new(), + pic: None, + use_plt: None, + static_crt: None, + warnings: None, + extra_warnings: None, + warnings_into_errors: false, + emit_rerun_if_env_changed: true, + shell_escaped_flags: None, + build_cache: Arc::default(), + inherit_rustflags: true, + prefer_clang_cl_over_msvc: false, + } + } + + /// Add a directory to the `-I` or include path for headers + /// + /// # Example + /// + /// ```no_run + /// use std::path::Path; + /// + /// let library_path = Path::new("/path/to/library"); + /// + /// cc::Build::new() + /// .file("src/foo.c") + /// .include(library_path) + /// .include("src") + /// .compile("foo"); + /// ``` + pub fn include>(&mut self, dir: P) -> &mut Build { + self.include_directories.push(dir.as_ref().into()); + self + } + + /// Add multiple directories to the `-I` include path. + /// + /// # Example + /// + /// ```no_run + /// # use std::path::Path; + /// # let condition = true; + /// # + /// let mut extra_dir = None; + /// if condition { + /// extra_dir = Some(Path::new("/path/to")); + /// } + /// + /// cc::Build::new() + /// .file("src/foo.c") + /// .includes(extra_dir) + /// .compile("foo"); + /// ``` + pub fn includes

(&mut self, dirs: P) -> &mut Build + where + P: IntoIterator, + P::Item: AsRef, + { + for dir in dirs { + self.include(dir); + } + self + } + + /// Specify a `-D` variable with an optional value. + /// + /// # Example + /// + /// ```no_run + /// cc::Build::new() + /// .file("src/foo.c") + /// .define("FOO", "BAR") + /// .define("BAZ", None) + /// .compile("foo"); + /// ``` + pub fn define<'a, V: Into>>(&mut self, var: &str, val: V) -> &mut Build { + self.definitions + .push((var.into(), val.into().map(Into::into))); + self + } + + /// Add an arbitrary object file to link in + pub fn object>(&mut self, obj: P) -> &mut Build { + self.objects.push(obj.as_ref().into()); + self + } + + /// Add arbitrary object files to link in + pub fn objects

(&mut self, objs: P) -> &mut Build + where + P: IntoIterator, + P::Item: AsRef, + { + for obj in objs { + self.object(obj); + } + self + } + + /// Add an arbitrary flag to the invocation of the compiler + /// + /// # Example + /// + /// ```no_run + /// cc::Build::new() + /// .file("src/foo.c") + /// .flag("-ffunction-sections") + /// .compile("foo"); + /// ``` + pub fn flag(&mut self, flag: impl AsRef) -> &mut Build { + self.flags.push(flag.as_ref().into()); + self + } + + /// Add multiple flags to the invocation of the compiler. + /// This is equivalent to calling [`flag`](Self::flag) for each item in the iterator. + /// + /// # Example + /// ```no_run + /// cc::Build::new() + /// .file("src/foo.c") + /// .flags(["-Wall", "-Wextra"]) + /// .compile("foo"); + /// ``` + pub fn flags(&mut self, flags: Iter) -> &mut Build + where + Iter: IntoIterator, + Iter::Item: AsRef, + { + for flag in flags { + self.flag(flag); + } + self + } + + /// Removes a compiler flag that was added by [`Build::flag`]. + /// + /// Will not remove flags added by other means (default flags, + /// flags from env, and so on). + /// + /// # Example + /// ``` + /// cc::Build::new() + /// .file("src/foo.c") + /// .flag("unwanted_flag") + /// .remove_flag("unwanted_flag"); + /// ``` + pub fn remove_flag(&mut self, flag: &str) -> &mut Build { + self.flags.retain(|other_flag| &**other_flag != flag); + self + } + + /// Add a flag to the invocation of the ar + /// + /// # Example + /// + /// ```no_run + /// cc::Build::new() + /// .file("src/foo.c") + /// .file("src/bar.c") + /// .ar_flag("/NODEFAULTLIB:libc.dll") + /// .compile("foo"); + /// ``` + pub fn ar_flag(&mut self, flag: impl AsRef) -> &mut Build { + self.ar_flags.push(flag.as_ref().into()); + self + } + + /// Add a flag that will only be used with assembly files. + /// + /// The flag will be applied to input files with either a `.s` or + /// `.asm` extension (case insensitive). + /// + /// # Example + /// + /// ```no_run + /// cc::Build::new() + /// .asm_flag("-Wa,-defsym,abc=1") + /// .file("src/foo.S") // The asm flag will be applied here + /// .file("src/bar.c") // The asm flag will not be applied here + /// .compile("foo"); + /// ``` + pub fn asm_flag(&mut self, flag: impl AsRef) -> &mut Build { + self.asm_flags.push(flag.as_ref().into()); + self + } + + /// Add an arbitrary flag to the invocation of the compiler if it supports it + /// + /// # Example + /// + /// ```no_run + /// cc::Build::new() + /// .file("src/foo.c") + /// .flag_if_supported("-Wlogical-op") // only supported by GCC + /// .flag_if_supported("-Wunreachable-code") // only supported by clang + /// .compile("foo"); + /// ``` + pub fn flag_if_supported(&mut self, flag: impl AsRef) -> &mut Build { + self.flags_supported.push(flag.as_ref().into()); + self + } + + /// Add flags from the specified environment variable. + /// + /// Normally the `cc` crate will consult with the standard set of environment + /// variables (such as `CFLAGS` and `CXXFLAGS`) to construct the compiler invocation. Use of + /// this method provides additional levers for the end user to use when configuring the build + /// process. + /// + /// Just like the standard variables, this method will search for an environment variable with + /// appropriate target prefixes, when appropriate. + /// + /// # Examples + /// + /// This method is particularly beneficial in introducing the ability to specify crate-specific + /// flags. + /// + /// ```no_run + /// cc::Build::new() + /// .file("src/foo.c") + /// .try_flags_from_environment(concat!(env!("CARGO_PKG_NAME"), "_CFLAGS")) + /// .expect("the environment variable must be specified and UTF-8") + /// .compile("foo"); + /// ``` + /// + pub fn try_flags_from_environment(&mut self, environ_key: &str) -> Result<&mut Build, Error> { + let flags = self.envflags(environ_key)?.ok_or_else(|| { + Error::new( + ErrorKind::EnvVarNotFound, + format!("could not find environment variable {environ_key}"), + ) + })?; + self.flags.extend( + flags + .into_iter() + .map(|flag| Arc::from(OsString::from(flag).as_os_str())), + ); + Ok(self) + } + + /// Set the `-shared` flag. + /// + /// This will typically be ignored by the compiler when calling [`Self::compile()`] since it only + /// produces static libraries. + /// + /// # Example + /// + /// ```no_run + /// // This will create a library named "liblibfoo.so.a" + /// cc::Build::new() + /// .file("src/foo.c") + /// .shared_flag(true) + /// .compile("libfoo.so"); + /// ``` + #[deprecated = "cc only creates static libraries, setting this does nothing"] + pub fn shared_flag(&mut self, shared_flag: bool) -> &mut Build { + self.shared_flag = Some(shared_flag); + self + } + + /// Set the `-static` flag. + /// + /// This will typically be ignored by the compiler when calling [`Self::compile()`] since it only + /// produces static libraries. + /// + /// # Example + /// + /// ```no_run + /// cc::Build::new() + /// .file("src/foo.c") + /// .shared_flag(true) + /// .static_flag(true) + /// .compile("foo"); + /// ``` + #[deprecated = "cc only creates static libraries, setting this does nothing"] + pub fn static_flag(&mut self, static_flag: bool) -> &mut Build { + self.static_flag = Some(static_flag); + self + } + + /// Disables the generation of default compiler flags. The default compiler + /// flags may cause conflicts in some cross compiling scenarios. + /// + /// Setting the `CRATE_CC_NO_DEFAULTS` environment variable has the same + /// effect as setting this to `true`. The presence of the environment + /// variable and the value of `no_default_flags` will be OR'd together. + pub fn no_default_flags(&mut self, no_default_flags: bool) -> &mut Build { + self.no_default_flags = no_default_flags; + self + } + + /// Add a file which will be compiled + pub fn file>(&mut self, p: P) -> &mut Build { + self.files.push(p.as_ref().into()); + self + } + + /// Add files which will be compiled + pub fn files

(&mut self, p: P) -> &mut Build + where + P: IntoIterator, + P::Item: AsRef, + { + for file in p.into_iter() { + self.file(file); + } + self + } + + /// Get the files which will be compiled + pub fn get_files(&self) -> impl Iterator { + self.files.iter().map(AsRef::as_ref) + } + + /// Set C++ support. + /// + /// The other `cpp_*` options will only become active if this is set to + /// `true`. + /// + /// The name of the C++ standard library to link is decided by: + /// 1. If [`cpp_link_stdlib`](Build::cpp_link_stdlib) is set, use its value. + /// 2. Else if the `CXXSTDLIB` environment variable is set, use its value. + /// 3. Else the default is `c++` for OS X and BSDs, `c++_shared` for Android, + /// `None` for MSVC and `stdc++` for anything else. + pub fn cpp(&mut self, cpp: bool) -> &mut Build { + self.cpp = cpp; + self + } + + /// Set CUDA C++ support. + /// + /// Enabling CUDA will invoke the CUDA compiler, NVCC. While NVCC accepts + /// the most common compiler flags, e.g. `-std=c++17`, some project-specific + /// flags might have to be prefixed with "-Xcompiler" flag, for example as + /// `.flag("-Xcompiler").flag("-fpermissive")`. See the documentation for + /// `nvcc`, the CUDA compiler driver, at + /// for more information. + /// + /// If enabled, this also implicitly enables C++ support. + pub fn cuda(&mut self, cuda: bool) -> &mut Build { + self.cuda = cuda; + if cuda { + self.cpp = true; + self.cudart = Some("static".into()); + } + self + } + + /// Link CUDA run-time. + /// + /// This option mimics the `--cudart` NVCC command-line option. Just like + /// the original it accepts `{none|shared|static}`, with default being + /// `static`. The method has to be invoked after `.cuda(true)`, or not + /// at all, if the default is right for the project. + pub fn cudart(&mut self, cudart: &str) -> &mut Build { + if self.cuda { + self.cudart = Some(cudart.into()); + } + self + } + + /// Set CUDA host compiler. + /// + /// By default, a `-ccbin` flag will be passed to NVCC to specify the + /// underlying host compiler. The value of `-ccbin` is the same as the + /// chosen C++ compiler. This is not always desired, because NVCC might + /// not support that compiler. In this case, you can remove the `-ccbin` + /// flag so that NVCC will choose the host compiler by itself. + pub fn ccbin(&mut self, ccbin: bool) -> &mut Build { + self.ccbin = ccbin; + self + } + + /// Specify the C or C++ language standard version. + /// + /// These values are common to modern versions of GCC, Clang and MSVC: + /// - `c11` for ISO/IEC 9899:2011 + /// - `c17` for ISO/IEC 9899:2018 + /// - `c++14` for ISO/IEC 14882:2014 + /// - `c++17` for ISO/IEC 14882:2017 + /// - `c++20` for ISO/IEC 14882:2020 + /// + /// Other values have less broad support, e.g. MSVC does not support `c++11` + /// (`c++14` is the minimum), `c89` (omit the flag instead) or `c99`. + /// + /// For compiling C++ code, you should also set `.cpp(true)`. + /// + /// The default is that no standard flag is passed to the compiler, so the + /// language version will be the compiler's default. + /// + /// # Example + /// + /// ```no_run + /// cc::Build::new() + /// .file("src/modern.cpp") + /// .cpp(true) + /// .std("c++17") + /// .compile("modern"); + /// ``` + pub fn std(&mut self, std: &str) -> &mut Build { + self.std = Some(std.into()); + self + } + + /// Set warnings into errors flag. + /// + /// Disabled by default. + /// + /// Warning: turning warnings into errors only make sense + /// if you are a developer of the crate using cc-rs. + /// Some warnings only appear on some architecture or + /// specific version of the compiler. Any user of this crate, + /// or any other crate depending on it, could fail during + /// compile time. + /// + /// # Example + /// + /// ```no_run + /// cc::Build::new() + /// .file("src/foo.c") + /// .warnings_into_errors(true) + /// .compile("libfoo.a"); + /// ``` + pub fn warnings_into_errors(&mut self, warnings_into_errors: bool) -> &mut Build { + self.warnings_into_errors = warnings_into_errors; + self + } + + /// Set warnings flags. + /// + /// Adds some flags: + /// - "-Wall" for MSVC. + /// - "-Wall", "-Wextra" for GNU and Clang. + /// + /// Enabled by default. + /// + /// # Example + /// + /// ```no_run + /// cc::Build::new() + /// .file("src/foo.c") + /// .warnings(false) + /// .compile("libfoo.a"); + /// ``` + pub fn warnings(&mut self, warnings: bool) -> &mut Build { + self.warnings = Some(warnings); + self.extra_warnings = Some(warnings); + self + } + + /// Set extra warnings flags. + /// + /// Adds some flags: + /// - nothing for MSVC. + /// - "-Wextra" for GNU and Clang. + /// + /// Enabled by default. + /// + /// # Example + /// + /// ```no_run + /// // Disables -Wextra, -Wall remains enabled: + /// cc::Build::new() + /// .file("src/foo.c") + /// .extra_warnings(false) + /// .compile("libfoo.a"); + /// ``` + pub fn extra_warnings(&mut self, warnings: bool) -> &mut Build { + self.extra_warnings = Some(warnings); + self + } + + /// Set the standard library to link against when compiling with C++ + /// support. + /// + /// If the `CXXSTDLIB` environment variable is set, its value will + /// override the default value, but not the value explicitly set by calling + /// this function. + /// + /// A value of `None` indicates that no automatic linking should happen, + /// otherwise cargo will link against the specified library. + /// + /// The given library name must not contain the `lib` prefix. + /// + /// Common values: + /// - `stdc++` for GNU + /// - `c++` for Clang + /// - `c++_shared` or `c++_static` for Android + /// + /// # Example + /// + /// ```no_run + /// cc::Build::new() + /// .file("src/foo.c") + /// .shared_flag(true) + /// .cpp_link_stdlib("stdc++") + /// .compile("libfoo.so"); + /// ``` + pub fn cpp_link_stdlib<'a, V: Into>>( + &mut self, + cpp_link_stdlib: V, + ) -> &mut Build { + self.cpp_link_stdlib = Some(cpp_link_stdlib.into().map(Arc::from)); + self + } + + /// Force linker to statically link C++ stdlib. By default cc-rs will emit + /// rustc-link flag to link against system C++ stdlib (e.g. libstdc++.so, libc++.so) + /// Provide value of `true` if linking against system library is not desired + /// + /// Note that for `wasm32` target C++ stdlib will always be linked statically + /// + /// # Example + /// + /// ```no_run + /// cc::Build::new() + /// .file("src/foo.cpp") + /// .cpp(true) + /// .cpp_link_stdlib("stdc++") + /// .cpp_link_stdlib_static(true) + /// .compile("foo"); + /// ``` + pub fn cpp_link_stdlib_static(&mut self, is_static: bool) -> &mut Build { + self.cpp_link_stdlib_static = is_static; + self + } + + /// Force the C++ compiler to use the specified standard library. + /// + /// Setting this option will automatically set `cpp_link_stdlib` to the same + /// value. + /// + /// The default value of this option is always `None`. + /// + /// This option has no effect when compiling for a Visual Studio based + /// target. + /// + /// This option sets the `-stdlib` flag, which is only supported by some + /// compilers (clang, icc) but not by others (gcc). The library will not + /// detect which compiler is used, as such it is the responsibility of the + /// caller to ensure that this option is only used in conjunction with a + /// compiler which supports the `-stdlib` flag. + /// + /// A value of `None` indicates that no specific C++ standard library should + /// be used, otherwise `-stdlib` is added to the compile invocation. + /// + /// The given library name must not contain the `lib` prefix. + /// + /// Common values: + /// - `stdc++` for GNU + /// - `c++` for Clang + /// + /// # Example + /// + /// ```no_run + /// cc::Build::new() + /// .file("src/foo.c") + /// .cpp_set_stdlib("c++") + /// .compile("libfoo.a"); + /// ``` + pub fn cpp_set_stdlib<'a, V: Into>>( + &mut self, + cpp_set_stdlib: V, + ) -> &mut Build { + let cpp_set_stdlib = cpp_set_stdlib.into().map(Arc::from); + self.cpp_set_stdlib.clone_from(&cpp_set_stdlib); + self.cpp_link_stdlib = Some(cpp_set_stdlib); + self + } + + /// Configures the `rustc` target this configuration will be compiling + /// for. + /// + /// This will fail if using a target not in a pre-compiled list taken from + /// `rustc +nightly --print target-list`. The list will be updated + /// periodically. + /// + /// You should avoid setting this in build scripts, target information + /// will instead be retrieved from the environment variables `TARGET` and + /// `CARGO_CFG_TARGET_*` that Cargo sets. + /// + /// # Example + /// + /// ```no_run + /// cc::Build::new() + /// .file("src/foo.c") + /// .target("aarch64-linux-android") + /// .compile("foo"); + /// ``` + pub fn target(&mut self, target: &str) -> &mut Build { + self.target = Some(target.into()); + self + } + + /// Configures the host assumed by this configuration. + /// + /// This option is automatically scraped from the `HOST` environment + /// variable by build scripts, so it's not required to call this function. + /// + /// # Example + /// + /// ```no_run + /// cc::Build::new() + /// .file("src/foo.c") + /// .host("arm-linux-gnueabihf") + /// .compile("foo"); + /// ``` + pub fn host(&mut self, host: &str) -> &mut Build { + self.host = Some(host.into()); + self + } + + /// Configures the optimization level of the generated object files. + /// + /// This option is automatically scraped from the `OPT_LEVEL` environment + /// variable by build scripts, so it's not required to call this function. + pub fn opt_level(&mut self, opt_level: u32) -> &mut Build { + self.opt_level = Some(opt_level.to_string().into()); + self + } + + /// Configures the optimization level of the generated object files. + /// + /// This option is automatically scraped from the `OPT_LEVEL` environment + /// variable by build scripts, so it's not required to call this function. + pub fn opt_level_str(&mut self, opt_level: &str) -> &mut Build { + self.opt_level = Some(opt_level.into()); + self + } + + /// Configures whether the compiler will emit debug information when + /// generating object files. + /// + /// This option is automatically scraped from the `DEBUG` environment + /// variable by build scripts, so it's not required to call this function. + pub fn debug(&mut self, debug: bool) -> &mut Build { + self.debug = Some(debug.to_string().into()); + self + } + + /// Configures whether the compiler will emit debug information when + /// generating object files. + /// + /// This should be one of the values accepted by Cargo's [`debug`][1] + /// profile setting, which cc-rs will try to map to the appropriate C + /// compiler flag. + /// + /// This option is automatically scraped from the `DEBUG` environment + /// variable by build scripts, so it's not required to call this function. + /// + /// [1]: https://doc.rust-lang.org/cargo/reference/profiles.html#debug + pub fn debug_str(&mut self, debug: &str) -> &mut Build { + self.debug = Some(debug.into()); + self + } + + /// Configures whether the compiler will emit instructions to store + /// frame pointers during codegen. + /// + /// This option is automatically enabled when debug information is emitted. + /// Otherwise the target platform compiler's default will be used. + /// You can use this option to force a specific setting. + pub fn force_frame_pointer(&mut self, force: bool) -> &mut Build { + self.force_frame_pointer = Some(force); + self + } + + /// Configures the output directory where all object files and static + /// libraries will be located. + /// + /// This option is automatically scraped from the `OUT_DIR` environment + /// variable by build scripts, so it's not required to call this function. + pub fn out_dir>(&mut self, out_dir: P) -> &mut Build { + self.out_dir = Some(out_dir.as_ref().into()); + self + } + + /// Configures the compiler to be used to produce output. + /// + /// This option is automatically determined from the target platform or a + /// number of environment variables, so it's not required to call this + /// function. + pub fn compiler>(&mut self, compiler: P) -> &mut Build { + self.compiler = Some(compiler.as_ref().into()); + self + } + + /// Configures the tool used to assemble archives. + /// + /// This option is automatically determined from the target platform or a + /// number of environment variables, so it's not required to call this + /// function. + pub fn archiver>(&mut self, archiver: P) -> &mut Build { + self.archiver = Some(archiver.as_ref().into()); + self + } + + /// Configures the tool used to index archives. + /// + /// This option is automatically determined from the target platform or a + /// number of environment variables, so it's not required to call this + /// function. + pub fn ranlib>(&mut self, ranlib: P) -> &mut Build { + self.ranlib = Some(ranlib.as_ref().into()); + self + } + + /// Define whether metadata should be emitted for cargo allowing it to + /// automatically link the binary. Defaults to `true`. + /// + /// The emitted metadata is: + /// + /// - `rustc-link-lib=static=`*compiled lib* + /// - `rustc-link-search=native=`*target folder* + /// - When target is MSVC, the ATL-MFC libs are added via `rustc-link-search=native=` + /// - When C++ is enabled, the C++ stdlib is added via `rustc-link-lib` + /// - If `emit_rerun_if_env_changed` is not `false`, `rerun-if-env-changed=`*env* + /// + pub fn cargo_metadata(&mut self, cargo_metadata: bool) -> &mut Build { + self.cargo_output.metadata = cargo_metadata; + self + } + + /// Define whether compile warnings should be emitted for cargo. Defaults to + /// `true`. + /// + /// If disabled, compiler messages will not be printed. + /// Issues unrelated to the compilation will always produce cargo warnings regardless of this setting. + pub fn cargo_warnings(&mut self, cargo_warnings: bool) -> &mut Build { + self.cargo_output.warnings = cargo_warnings; + self + } + + /// Define whether debug information should be emitted for cargo. Defaults to whether + /// or not the environment variable `CC_ENABLE_DEBUG_OUTPUT` is set. + /// + /// If enabled, the compiler will emit debug information when generating object files, + /// such as the command invoked and the exit status. + pub fn cargo_debug(&mut self, cargo_debug: bool) -> &mut Build { + self.cargo_output.debug = cargo_debug; + self + } + + /// Define whether compiler output (to stdout) should be emitted. Defaults to `true` + /// (forward compiler stdout to this process' stdout) + /// + /// Some compilers emit errors to stdout, so if you *really* need stdout to be clean + /// you should also set this to `false`. + pub fn cargo_output(&mut self, cargo_output: bool) -> &mut Build { + self.cargo_output.output = if cargo_output { + OutputKind::Forward + } else { + OutputKind::Discard + }; + self + } + + /// Adds a native library modifier that will be added to the + /// `rustc-link-lib=static:MODIFIERS=LIBRARY_NAME` metadata line + /// emitted for cargo if `cargo_metadata` is enabled. + /// See + /// for the list of modifiers accepted by rustc. + pub fn link_lib_modifier(&mut self, link_lib_modifier: impl AsRef) -> &mut Build { + self.link_lib_modifiers + .push(link_lib_modifier.as_ref().into()); + self + } + + /// Configures whether the compiler will emit position independent code. + /// + /// This option defaults to `false` for `windows-gnu` and bare metal targets and + /// to `true` for all other targets. + pub fn pic(&mut self, pic: bool) -> &mut Build { + self.pic = Some(pic); + self + } + + /// Configures whether the Procedure Linkage Table is used for indirect + /// calls into shared libraries. + /// + /// The PLT is used to provide features like lazy binding, but introduces + /// a small performance loss due to extra pointer indirection. Setting + /// `use_plt` to `false` can provide a small performance increase. + /// + /// Note that skipping the PLT requires a recent version of GCC/Clang. + /// + /// This only applies to ELF targets. It has no effect on other platforms. + pub fn use_plt(&mut self, use_plt: bool) -> &mut Build { + self.use_plt = Some(use_plt); + self + } + + /// Define whether metadata should be emitted for cargo to only trigger + /// rebuild when detected environment changes, by default build script is + /// always run on every compilation if no rerun cargo metadata is emitted. + /// + /// NOTE that cc does not emit metadata to detect changes for `PATH`, since it could + /// be changed every compilation yet does not affect the result of compilation + /// (i.e. rust-analyzer adds temporary directory to `PATH`). + /// + /// cc in general, has no way detecting changes to compiler, as there are so many ways to + /// change it and sidestep the detection, for example the compiler might be wrapped in a script + /// so detecting change of the file, or using checksum won't work. + /// + /// We recommend users to decide for themselves, if they want rebuild if the compiler has been upgraded + /// or changed, and how to detect that. + /// + /// This has no effect if the `cargo_metadata` option is `false`. + /// + /// This option defaults to `true`. + pub fn emit_rerun_if_env_changed(&mut self, emit_rerun_if_env_changed: bool) -> &mut Build { + self.emit_rerun_if_env_changed = emit_rerun_if_env_changed; + self + } + + /// Configures whether the /MT flag or the /MD flag will be passed to msvc build tools. + /// + /// This option defaults to `false`, and affect only msvc targets. + pub fn static_crt(&mut self, static_crt: bool) -> &mut Build { + self.static_crt = Some(static_crt); + self + } + + /// Configure whether *FLAGS variables are parsed using `shlex`, similarly to `make` and + /// `cmake`. + /// + /// This option defaults to `false`. + pub fn shell_escaped_flags(&mut self, shell_escaped_flags: bool) -> &mut Build { + self.shell_escaped_flags = Some(shell_escaped_flags); + self + } + + /// Configure whether cc should automatically inherit compatible flags passed to rustc + /// from `CARGO_ENCODED_RUSTFLAGS`. + /// + /// This option defaults to `true`. + pub fn inherit_rustflags(&mut self, inherit_rustflags: bool) -> &mut Build { + self.inherit_rustflags = inherit_rustflags; + self + } + + /// Prefer to use clang-cl over msvc. + /// + /// This option defaults to `false`. + pub fn prefer_clang_cl_over_msvc(&mut self, prefer_clang_cl_over_msvc: bool) -> &mut Build { + self.prefer_clang_cl_over_msvc = prefer_clang_cl_over_msvc; + self + } + + /// Set an environment variable for compiler invocations and other child processes. + /// + /// `cc` reads a lot of different variables from the current process' environment. It currently + /// allows the following standard environment variables to be overwritten by this function: + /// - `SDKROOT` + /// - `*_DEPLOYMENT_TARGET` + /// - `WASI_SDK_ROOT` + /// + /// The logic here is "environment variables that the C compiler could itself reasonably have + /// read". + pub fn env(&mut self, key: K, val: V) -> &mut Build + where + K: AsRef, + V: AsRef, + { + self.env.push((key.as_ref().into(), val.as_ref().into())); + self + } + + // retained for backwards compatibility only + #[doc(hidden)] + #[deprecated = "use `env` instead"] + pub fn __set_env(&mut self, key: K, val: V) -> &mut Build + where + K: AsRef, + V: AsRef, + { + self.env(key, val) + } +} + +/// Invoke or fetch the compiler or archiver. +impl Build { + /// Run the compiler to test if it accepts the given flag. + /// + /// For a convenience method for setting flags conditionally, + /// see `flag_if_supported()`. + /// + /// It may return error if it's unable to run the compiler with a test file + /// (e.g. the compiler is missing or a write to the `out_dir` failed). + /// + /// Note: Once computed, the result of this call is stored in the + /// `known_flag_support` field. If `is_flag_supported(flag)` + /// is called again, the result will be read from the hash table. + pub fn is_flag_supported(&self, flag: impl AsRef) -> Result { + self.is_flag_supported_inner( + flag.as_ref(), + &self.get_base_compiler()?, + &self.get_target()?, + ) + } + + fn ensure_check_file(&self) -> Result { + let out_dir = self.get_out_dir()?; + let src = if self.cuda { + assert!(self.cpp); + out_dir.join("flag_check.cu") + } else if self.cpp { + out_dir.join("flag_check.cpp") + } else { + out_dir.join("flag_check.c") + }; + + if !src.exists() { + let mut f = fs::File::create(&src)?; + write!(f, "int main(void) {{ return 0; }}")?; + } + + Ok(src) + } + + fn is_flag_supported_inner( + &self, + flag: &OsStr, + tool: &Tool, + target: &TargetInfo<'_>, + ) -> Result { + let compiler_flag = CompilerFlag { + compiler: tool.path().into(), + flag: flag.into(), + }; + + if let Some(is_supported) = self + .build_cache + .known_flag_support_status_cache + .read() + .unwrap() + .get(&compiler_flag) + .cloned() + { + return Ok(is_supported); + } + + let out_dir = self.get_out_dir()?; + let src = self.ensure_check_file()?; + let obj = out_dir.join("flag_check"); + + let mut compiler = { + let mut cfg = Build::new(); + cfg.flag(flag) + .compiler(tool.path()) + .cargo_metadata(self.cargo_output.metadata) + .opt_level(0) + .debug(false) + .cpp(self.cpp) + .cuda(self.cuda) + .inherit_rustflags(false) + .emit_rerun_if_env_changed(self.emit_rerun_if_env_changed); + if let Some(target) = &self.target { + cfg.target(target); + } + if let Some(host) = &self.host { + cfg.host(host); + } + cfg.try_get_compiler()? + }; + + // Clang uses stderr for verbose output, which yields a false positive + // result if the CFLAGS/CXXFLAGS include -v to aid in debugging. + if compiler.family.verbose_stderr() { + compiler.remove_arg("-v".into()); + } + if compiler.is_like_clang() { + // Avoid reporting that the arg is unsupported just because the + // compiler complains that it wasn't used. + compiler.push_cc_arg("-Wno-unused-command-line-argument".into()); + } + + let mut cmd = compiler.to_command(); + command_add_output_file( + &mut cmd, + &obj, + CmdAddOutputFileArgs { + cuda: self.cuda, + is_assembler_msvc: false, + msvc: compiler.is_like_msvc(), + clang: compiler.is_like_clang(), + gnu: compiler.is_like_gnu(), + is_asm: false, + is_arm: is_arm(target), + }, + ); + + // Checking for compiler flags does not require linking (and we _must_ + // avoid making it do so, since it breaks cross-compilation when the C + // compiler isn't configured to be able to link). + // https://github.com/rust-lang/cc-rs/issues/1423 + cmd.arg("-c"); + + if compiler.supports_path_delimiter() { + cmd.arg("--"); + } + + cmd.arg(&src); + + if compiler.is_like_msvc() { + // On MSVC we need to make sure the LIB directory is included + // so the CRT can be found. + for (key, value) in &tool.env { + if key == "LIB" { + cmd.env("LIB", value); + break; + } + } + } + + let output = cmd.current_dir(out_dir).output()?; + let is_supported = output.status.success() && output.stderr.is_empty(); + + self.build_cache + .known_flag_support_status_cache + .write() + .unwrap() + .insert(compiler_flag, is_supported); + + Ok(is_supported) + } + + /// Run the compiler, generating the file `output` + /// + /// This will return a result instead of panicking; see [`Self::compile()`] for + /// the complete description. + pub fn try_compile(&self, output: &str) -> Result<(), Error> { + let mut output_components = Path::new(output).components(); + match (output_components.next(), output_components.next()) { + (Some(Component::Normal(_)), None) => {} + _ => { + return Err(Error::new( + ErrorKind::InvalidArgument, + "argument of `compile` must be a single normal path component", + )); + } + } + + let (lib_name, gnu_lib_name) = if output.starts_with("lib") && output.ends_with(".a") { + (&output[3..output.len() - 2], output.to_owned()) + } else { + let mut gnu = String::with_capacity(5 + output.len()); + gnu.push_str("lib"); + gnu.push_str(output); + gnu.push_str(".a"); + (output, gnu) + }; + let dst = self.get_out_dir()?; + + let objects = objects_from_files(&self.files, &dst)?; + + self.compile_objects(&objects)?; + self.assemble(lib_name, &dst.join(gnu_lib_name), &objects)?; + + let target = self.get_target()?; + if target.env == "msvc" { + let compiler = self.get_base_compiler()?; + let atlmfc_lib = compiler + .env() + .iter() + .find(|&(var, _)| var.as_os_str() == OsStr::new("LIB")) + .and_then(|(_, lib_paths)| { + env::split_paths(lib_paths).find(|path| { + let sub = Path::new("atlmfc/lib"); + path.ends_with(sub) || path.parent().map_or(false, |p| p.ends_with(sub)) + }) + }); + + if let Some(atlmfc_lib) = atlmfc_lib { + self.cargo_output.print_metadata(&format_args!( + "cargo:rustc-link-search=native={}", + atlmfc_lib.display() + )); + } + } + + if self.link_lib_modifiers.is_empty() { + self.cargo_output + .print_metadata(&format_args!("cargo:rustc-link-lib=static={lib_name}")); + } else { + self.cargo_output.print_metadata(&format_args!( + "cargo:rustc-link-lib=static:{}={}", + JoinOsStrs { + slice: &self.link_lib_modifiers, + delimiter: ',' + }, + lib_name + )); + } + self.cargo_output.print_metadata(&format_args!( + "cargo:rustc-link-search=native={}", + dst.display() + )); + + // Add specific C++ libraries, if enabled. + if self.cpp { + if let Some(stdlib) = self.get_cpp_link_stdlib()? { + if self.cpp_link_stdlib_static { + self.cargo_output.print_metadata(&format_args!( + "cargo:rustc-link-lib=static={}", + stdlib.display() + )); + } else { + self.cargo_output + .print_metadata(&format_args!("cargo:rustc-link-lib={}", stdlib.display())); + } + } + // Link c++ lib from WASI sysroot + if target.arch == "wasm32" { + if target.os == "wasi" { + if let Ok(wasi_sysroot) = self.wasi_sysroot() { + self.cargo_output.print_metadata(&format_args!( + "cargo:rustc-flags=-L {}/lib/{} -lstatic=c++ -lstatic=c++abi", + Path::new(&wasi_sysroot).display(), + self.get_raw_target()? + )); + } + } else if target.os == "linux" { + let musl_sysroot = self.wasm_musl_sysroot().unwrap(); + self.cargo_output.print_metadata(&format_args!( + "cargo:rustc-flags=-L {}/lib -lstatic=c++ -lstatic=c++abi", + Path::new(&musl_sysroot).display(), + )); + } + } + } + + let cudart = match &self.cudart { + Some(opt) => opt, // {none|shared|static} + None => "none", + }; + if cudart != "none" { + if let Some(nvcc) = self.which(&self.get_compiler().path, None) { + // Try to figure out the -L search path. If it fails, + // it's on user to specify one by passing it through + // RUSTFLAGS environment variable. + let mut libtst = false; + let mut libdir = nvcc; + libdir.pop(); // remove 'nvcc' + libdir.push(".."); + if cfg!(target_os = "linux") { + libdir.push("targets"); + libdir.push(format!("{}-linux", target.arch)); + if !libdir.exists() && target.arch == "aarch64" { + libdir.pop(); + libdir.push("sbsa-linux"); + } + libdir.push("lib"); + libtst = true; + } else if cfg!(target_env = "msvc") { + libdir.push("lib"); + match target.arch { + "x86_64" => { + libdir.push("x64"); + libtst = true; + } + "x86" => { + libdir.push("Win32"); + libtst = true; + } + _ => libtst = false, + } + } + if libtst && libdir.is_dir() { + self.cargo_output.print_metadata(&format_args!( + "cargo:rustc-link-search=native={}", + libdir.to_str().unwrap() + )); + } + + // And now the -l flag. + let lib = match cudart { + "shared" => "cudart", + "static" => "cudart_static", + bad => panic!("unsupported cudart option: {}", bad), + }; + self.cargo_output + .print_metadata(&format_args!("cargo:rustc-link-lib={lib}")); + } + } + + Ok(()) + } + + /// Run the compiler, generating the file `output` + /// + /// # Library name + /// + /// The `output` string argument determines the file name for the compiled + /// library. The Rust compiler will create an assembly named "lib"+output+".a". + /// MSVC will create a file named output+".lib". + /// + /// The choice of `output` is close to arbitrary, but: + /// + /// - must be nonempty, + /// - must not contain a path separator (`/`), + /// - must be unique across all `compile` invocations made by the same build + /// script. + /// + /// If your build script compiles a single source file, the base name of + /// that source file would usually be reasonable: + /// + /// ```no_run + /// cc::Build::new().file("blobstore.c").compile("blobstore"); + /// ``` + /// + /// Compiling multiple source files, some people use their crate's name, or + /// their crate's name + "-cc". + /// + /// Otherwise, please use your imagination. + /// + /// For backwards compatibility, if `output` starts with "lib" *and* ends + /// with ".a", a second "lib" prefix and ".a" suffix do not get added on, + /// but this usage is deprecated; please omit `lib` and `.a` in the argument + /// that you pass. + /// + /// # Panics + /// + /// Panics if `output` is not formatted correctly or if one of the underlying + /// compiler commands fails. It can also panic if it fails reading file names + /// or creating directories. + pub fn compile(&self, output: &str) { + if let Err(e) = self.try_compile(output) { + fail(&e.message); + } + } + + /// Run the compiler, generating intermediate files, but without linking + /// them into an archive file. + /// + /// This will return a list of compiled object files, in the same order + /// as they were passed in as `file`/`files` methods. + pub fn compile_intermediates(&self) -> Vec { + match self.try_compile_intermediates() { + Ok(v) => v, + Err(e) => fail(&e.message), + } + } + + /// Run the compiler, generating intermediate files, but without linking + /// them into an archive file. + /// + /// This will return a result instead of panicking; see `compile_intermediates()` for the complete description. + pub fn try_compile_intermediates(&self) -> Result, Error> { + let dst = self.get_out_dir()?; + let objects = objects_from_files(&self.files, &dst)?; + + self.compile_objects(&objects)?; + + Ok(objects.into_iter().map(|v| v.dst).collect()) + } + + fn compile_objects(&self, objs: &[Object]) -> Result<(), Error> { + if self.is_disabled() { + return Err(Error::new( + ErrorKind::Disabled, + "the `cc` crate's functionality has been disabled by the `CC_FORCE_DISABLE` environment variable.", + )); + } + + #[cfg(feature = "parallel")] + if objs.len() > 1 { + return parallel::run_commands_in_parallel( + &self.cargo_output, + &mut objs.iter().map(|obj| self.create_compile_object_cmd(obj)), + ); + } + + for obj in objs { + let mut cmd = self.create_compile_object_cmd(obj)?; + run(&mut cmd, &self.cargo_output)?; + } + + Ok(()) + } + + fn create_compile_object_cmd(&self, obj: &Object) -> Result { + let asm_ext = AsmFileExt::from_path(&obj.src); + let is_asm = asm_ext.is_some(); + let target = self.get_target()?; + let msvc = target.env == "msvc"; + let compiler = self.try_get_compiler()?; + + let is_assembler_msvc = msvc && asm_ext == Some(AsmFileExt::DotAsm); + let mut cmd = if is_assembler_msvc { + self.msvc_macro_assembler()? + } else { + compiler.to_command() + }; + let is_arm = is_arm(&target); + command_add_output_file( + &mut cmd, + &obj.dst, + CmdAddOutputFileArgs { + cuda: self.cuda, + is_assembler_msvc, + msvc: compiler.is_like_msvc(), + clang: compiler.is_like_clang(), + gnu: compiler.is_like_gnu(), + is_asm, + is_arm, + }, + ); + // armasm and armasm64 don't require -c option + if !is_assembler_msvc || !is_arm { + cmd.arg("-c"); + } + if self.cuda && self.cuda_file_count() > 1 { + cmd.arg("--device-c"); + } + if is_asm { + cmd.args(self.asm_flags.iter().map(std::ops::Deref::deref)); + } + + if compiler.supports_path_delimiter() && !is_assembler_msvc { + // #513: For `clang-cl`, separate flags/options from the input file. + // When cross-compiling macOS -> Windows, this avoids interpreting + // common `/Users/...` paths as the `/U` flag and triggering + // `-Wslash-u-filename` warning. + cmd.arg("--"); + } + cmd.arg(&obj.src); + + if cfg!(target_os = "macos") { + self.fix_env_for_apple_os(&mut cmd)?; + } + + Ok(cmd) + } + + /// This will return a result instead of panicking; see [`Self::expand()`] for + /// the complete description. + pub fn try_expand(&self) -> Result, Error> { + let compiler = self.try_get_compiler()?; + let mut cmd = compiler.to_command(); + cmd.arg("-E"); + + assert!( + self.files.len() <= 1, + "Expand may only be called for a single file" + ); + + let is_asm = self + .files + .iter() + .map(std::ops::Deref::deref) + .find_map(AsmFileExt::from_path) + .is_some(); + + if compiler.family == (ToolFamily::Msvc { clang_cl: true }) && !is_asm { + // #513: For `clang-cl`, separate flags/options from the input file. + // When cross-compiling macOS -> Windows, this avoids interpreting + // common `/Users/...` paths as the `/U` flag and triggering + // `-Wslash-u-filename` warning. + cmd.arg("--"); + } + + cmd.args(self.files.iter().map(std::ops::Deref::deref)); + + run_output(&mut cmd, &self.cargo_output) + } + + /// Run the compiler, returning the macro-expanded version of the input files. + /// + /// This is only relevant for C and C++ files. + /// + /// # Panics + /// Panics if more than one file is present in the config, or if compiler + /// path has an invalid file name. + /// + /// # Example + /// ```no_run + /// let out = cc::Build::new().file("src/foo.c").expand(); + /// ``` + pub fn expand(&self) -> Vec { + match self.try_expand() { + Err(e) => fail(&e.message), + Ok(v) => v, + } + } + + /// Get the compiler that's in use for this configuration. + /// + /// This function will return a `Tool` which represents the culmination + /// of this configuration at a snapshot in time. The returned compiler can + /// be inspected (e.g. the path, arguments, environment) to forward along to + /// other tools, or the `to_command` method can be used to invoke the + /// compiler itself. + /// + /// This method will take into account all configuration such as debug + /// information, optimization level, include directories, defines, etc. + /// Additionally, the compiler binary in use follows the standard + /// conventions for this path, e.g. looking at the explicitly set compiler, + /// environment variables (a number of which are inspected here), and then + /// falling back to the default configuration. + /// + /// # Panics + /// + /// Panics if an error occurred while determining the architecture. + pub fn get_compiler(&self) -> Tool { + match self.try_get_compiler() { + Ok(tool) => tool, + Err(e) => fail(&e.message), + } + } + + /// Get the compiler that's in use for this configuration. + /// + /// This will return a result instead of panicking; see + /// [`get_compiler()`](Self::get_compiler) for the complete description. + pub fn try_get_compiler(&self) -> Result { + let opt_level = self.get_opt_level()?; + let target = self.get_target()?; + + let mut cmd = self.get_base_compiler()?; + + // The flags below are added in roughly the following order: + // 1. Default flags + // - Controlled by `cc-rs`. + // 2. `rustc`-inherited flags + // - Controlled by `rustc`. + // 3. Builder flags + // - Controlled by the developer using `cc-rs` in e.g. their `build.rs`. + // 4. Environment flags + // - Controlled by the end user. + // + // This is important to allow later flags to override previous ones. + + // Copied from + // + // Disables non-English messages from localized linkers. + // Such messages may cause issues with text encoding on Windows + // and prevent inspection of msvc output in case of errors, which we occasionally do. + // This should be acceptable because other messages from rustc are in English anyway, + // and may also be desirable to improve searchability of the compiler diagnostics. + if matches!(cmd.family, ToolFamily::Msvc { clang_cl: false }) { + cmd.env.push(("VSLANG".into(), "1033".into())); + } else { + cmd.env.push(("LC_ALL".into(), "C".into())); + } + + // Disable default flag generation via `no_default_flags` or environment variable + let no_defaults = self.no_default_flags || self.get_env_boolean("CRATE_CC_NO_DEFAULTS"); + if !no_defaults { + self.add_default_flags(&mut cmd, &target, &opt_level)?; + } + + // Specify various flags that are not considered part of the default flags above. + // FIXME(madsmtm): Should these be considered part of the defaults? If no, why not? + if let Some(ref std) = self.std { + let separator = match cmd.family { + ToolFamily::Msvc { .. } => ':', + ToolFamily::Gnu | ToolFamily::Clang { .. } => '=', + }; + cmd.push_cc_arg(format!("-std{separator}{std}").into()); + } + for directory in self.include_directories.iter() { + cmd.args.push("-I".into()); + cmd.args.push(directory.as_os_str().into()); + } + if self.warnings_into_errors { + let warnings_to_errors_flag = cmd.family.warnings_to_errors_flag().into(); + cmd.push_cc_arg(warnings_to_errors_flag); + } + + // If warnings and/or extra_warnings haven't been explicitly set, + // then we set them only if the environment doesn't already have + // CFLAGS/CXXFLAGS, since those variables presumably already contain + // the desired set of warnings flags. + let envflags = self.envflags(if self.cpp { "CXXFLAGS" } else { "CFLAGS" })?; + match self.warnings { + Some(true) => { + let wflags = cmd.family.warnings_flags().into(); + cmd.push_cc_arg(wflags); + } + Some(false) => { + let wflags = cmd.family.warnings_suppression_flags().into(); + cmd.push_cc_arg(wflags); + } + None => { + if envflags.is_none() { + let wflags = cmd.family.warnings_flags().into(); + cmd.push_cc_arg(wflags); + } + } + } + if self.extra_warnings.unwrap_or(envflags.is_none()) { + if let Some(wflags) = cmd.family.extra_warnings_flags() { + cmd.push_cc_arg(wflags.into()); + } + } + + // Add cc flags inherited from matching rustc flags. + if self.inherit_rustflags { + self.add_inherited_rustflags(&mut cmd, &target)?; + } + + // Set flags configured in the builder (do this second-to-last, to allow these to override + // everything above). + for flag in self.flags.iter() { + cmd.args.push((**flag).into()); + } + for flag in self.flags_supported.iter() { + if self + .is_flag_supported_inner(flag, &cmd, &target) + .unwrap_or(false) + { + cmd.push_cc_arg((**flag).into()); + } + } + for (key, value) in self.definitions.iter() { + if let Some(ref value) = *value { + cmd.args.push(format!("-D{key}={value}").into()); + } else { + cmd.args.push(format!("-D{key}").into()); + } + } + + // Set flags from the environment (do this last, to allow these to override everything else). + if let Some(flags) = &envflags { + for arg in flags { + cmd.push_cc_arg(arg.into()); + } + } + + // Set custom env vars that the user specified with `Build::env`. + // + // Do this last, to allow overwriting the other values above. + for (key, val) in &self.env { + cmd.env.push((key.into(), val.into())); + } + + Ok(cmd) + } + + fn add_default_flags( + &self, + cmd: &mut Tool, + target: &TargetInfo<'_>, + opt_level: &str, + ) -> Result<(), Error> { + let raw_target = self.get_raw_target()?; + // Non-target flags + // If the flag is not conditioned on target variable, it belongs here :) + match cmd.family { + ToolFamily::Msvc { .. } => { + cmd.push_cc_arg("-nologo".into()); + + let crt_flag = match self.static_crt { + Some(true) => "-MT", + Some(false) => "-MD", + None => { + let features = cargo_env_var_os("CARGO_CFG_TARGET_FEATURE"); + let features = features.as_deref().unwrap_or_default(); + if features.to_string_lossy().contains("crt-static") { + "-MT" + } else { + "-MD" + } + } + }; + cmd.push_cc_arg(crt_flag.into()); + + match opt_level { + // Msvc uses /O1 to enable all optimizations that minimize code size. + "z" | "s" | "1" => cmd.push_opt_unless_duplicate("-O1".into()), + // -O3 is a valid value for gcc and clang compilers, but not msvc. Cap to /O2. + "2" | "3" => cmd.push_opt_unless_duplicate("-O2".into()), + _ => {} + } + } + ToolFamily::Gnu | ToolFamily::Clang { .. } => { + // arm-linux-androideabi-gcc 4.8 shipped with Android NDK does + // not support '-Oz' + if opt_level == "z" && !cmd.is_like_clang() { + cmd.push_opt_unless_duplicate("-Os".into()); + } else { + cmd.push_opt_unless_duplicate(format!("-O{opt_level}").into()); + } + + if cmd.is_like_clang() && target.os == "android" { + // For compatibility with code that doesn't use pre-defined `__ANDROID__` macro. + // If compiler used via ndk-build or cmake (officially supported build methods) + // this macros is defined. + // See https://android.googlesource.com/platform/ndk/+/refs/heads/ndk-release-r21/build/cmake/android.toolchain.cmake#456 + // https://android.googlesource.com/platform/ndk/+/refs/heads/ndk-release-r21/build/core/build-binary.mk#141 + cmd.push_opt_unless_duplicate("-DANDROID".into()); + } + + if target.os != "ios" + && target.os != "watchos" + && target.os != "tvos" + && target.os != "visionos" + { + cmd.push_cc_arg("-ffunction-sections".into()); + cmd.push_cc_arg("-fdata-sections".into()); + } + // Disable generation of PIC on bare-metal for now: rust-lld doesn't support this yet + // + // `rustc` also defaults to disable PIC on WASM: + // + if self.pic.unwrap_or( + target.os != "windows" + && target.os != "none" + && target.os != "uefi" + && target.os != "vita" + && target.arch != "wasm32" + && target.arch != "wasm64", + ) { + cmd.push_cc_arg("-fPIC".into()); + // PLT only applies if code is compiled with PIC support, + // and only for ELF targets. + if (target.os == "linux" || target.os == "android") + && !self.use_plt.unwrap_or(true) + { + cmd.push_cc_arg("-fno-plt".into()); + } + } + + if target.os == "wasi" { + // Link clang sysroot + if let Ok(wasi_sysroot) = self.wasi_sysroot() { + cmd.push_cc_arg( + format!("--sysroot={}", Path::new(&wasi_sysroot).display()).into(), + ); + } + + // FIXME(madsmtm): Read from `target_features` instead? + if raw_target.contains("threads") { + cmd.push_cc_arg("-pthread".into()); + } + } + + if target.os == "nto" { + // Select the target with `-V`, see qcc documentation: + // QNX 7.1: https://www.qnx.com/developers/docs/7.1/index.html#com.qnx.doc.neutrino.utilities/topic/q/qcc.html + // QNX 8.0: https://www.qnx.com/developers/docs/8.0/com.qnx.doc.neutrino.utilities/topic/q/qcc.html + // This assumes qcc/q++ as compiler, which is currently the only supported compiler for QNX. + // See for details: https://github.com/rust-lang/cc-rs/pull/1319 + let arg = match target.full_arch { + "x86" | "i586" => "-Vgcc_ntox86_cxx", + "aarch64" => "-Vgcc_ntoaarch64le_cxx", + "x86_64" => "-Vgcc_ntox86_64_cxx", + _ => { + return Err(Error::new( + ErrorKind::InvalidTarget, + format!("Unknown architecture for Neutrino QNX: {}", target.arch), + )) + } + }; + cmd.push_cc_arg(arg.into()); + } + } + } + + if self.get_debug() { + if self.cuda { + // NVCC debug flag + cmd.args.push("-G".into()); + } + let family = cmd.family; + family.add_debug_flags( + cmd, + self.get_debug_str().as_deref().unwrap_or_default(), + self.get_dwarf_version(), + ); + } + + if self.get_force_frame_pointer() { + let family = cmd.family; + family.add_force_frame_pointer(cmd); + } + + if !cmd.is_like_msvc() { + if target.arch == "x86" { + cmd.args.push("-m32".into()); + } else if target.abi == "x32" { + cmd.args.push("-mx32".into()); + } else if target.os == "aix" { + if cmd.family == ToolFamily::Gnu { + cmd.args.push("-maix64".into()); + } else { + cmd.args.push("-m64".into()); + } + } else if target.arch == "x86_64" || target.arch == "powerpc64" { + cmd.args.push("-m64".into()); + } + } + + // Target flags + match cmd.family { + ToolFamily::Clang { .. } => { + if !(cmd.has_internal_target_arg + || (target.os == "android" + && android_clang_compiler_uses_target_arg_internally(&cmd.path))) + { + if target.os == "freebsd" { + // FreeBSD only supports C++11 and above when compiling against libc++ + // (available from FreeBSD 10 onwards). Under FreeBSD, clang uses libc++ by + // default on FreeBSD 10 and newer unless `--target` is manually passed to + // the compiler, in which case its default behavior differs: + // * If --target=xxx-unknown-freebsdX(.Y) is specified and X is greater than + // or equal to 10, clang++ uses libc++ + // * If --target=xxx-unknown-freebsd is specified (without a version), + // clang++ cannot assume libc++ is available and reverts to a default of + // libstdc++ (this behavior was changed in llvm 14). + // + // This breaks C++11 (or greater) builds if targeting FreeBSD with the + // generic xxx-unknown-freebsd target on clang 13 or below *without* + // explicitly specifying that libc++ should be used. + // When cross-compiling, we can't infer from the rust/cargo target name + // which major version of FreeBSD we are targeting, so we need to make sure + // that libc++ is used (unless the user has explicitly specified otherwise). + // There's no compelling reason to use a different approach when compiling + // natively. + if self.cpp && self.cpp_set_stdlib.is_none() { + cmd.push_cc_arg("-stdlib=libc++".into()); + } + } else if target.arch == "wasm32" && target.os == "linux" { + for x in &[ + "atomics", + "bulk-memory", + "mutable-globals", + "sign-ext", + "exception-handling", + ] { + cmd.push_cc_arg(format!("-m{x}").into()); + } + for x in &["wasm-exceptions", "declspec"] { + cmd.push_cc_arg(format!("-f{x}").into()); + } + let musl_sysroot = self.wasm_musl_sysroot().unwrap(); + cmd.push_cc_arg( + format!("--sysroot={}", Path::new(&musl_sysroot).display()).into(), + ); + cmd.push_cc_arg("-pthread".into()); + } + // Pass `--target` with the LLVM target to configure Clang for cross-compiling. + // + // This is **required** for cross-compilation, as it's the only flag that + // consistently forces Clang to change the "toolchain" that is responsible for + // parsing target-specific flags: + // https://github.com/rust-lang/cc-rs/issues/1388 + // https://github.com/llvm/llvm-project/blob/llvmorg-19.1.7/clang/lib/Driver/Driver.cpp#L1359-L1360 + // https://github.com/llvm/llvm-project/blob/llvmorg-19.1.7/clang/lib/Driver/Driver.cpp#L6347-L6532 + // + // This can be confusing, because on e.g. host macOS, you can usually get by + // with `-arch` and `-mtargetos=`. But that only works because the _default_ + // toolchain is `Darwin`, which enables parsing of darwin-specific options. + // + // NOTE: In the past, we passed the deployment version in here on all Apple + // targets, but versioned targets were found to have poor compatibility with + // older versions of Clang, especially when it comes to configuration files: + // https://github.com/rust-lang/cc-rs/issues/1278 + // + // So instead, we pass the deployment target with `-m*-version-min=`, and only + // pass it here on visionOS and Mac Catalyst where that option does not exist: + // https://github.com/rust-lang/cc-rs/issues/1383 + let version = if target.os == "visionos" || target.env == "macabi" { + Some(self.apple_deployment_target(target)) + } else { + None + }; + + let clang_target = + target.llvm_target(&self.get_raw_target()?, version.as_deref()); + cmd.push_cc_arg(format!("--target={clang_target}").into()); + } + } + ToolFamily::Msvc { clang_cl } => { + // This is an undocumented flag from MSVC but helps with making + // builds more reproducible by avoiding putting timestamps into + // files. + cmd.push_cc_arg("-Brepro".into()); + + if clang_cl { + cmd.push_cc_arg( + format!( + "--target={}", + target.llvm_target(&self.get_raw_target()?, None) + ) + .into(), + ); + + if target.arch == "x86" { + // See + // . + // + // NOTE: Rust officially supported Windows targets all require SSE2 as part + // of baseline target features. + // + // NOTE: The same applies for STL. See: - + // , and - + // . + cmd.push_cc_arg("-arch:SSE2".into()); + } + } else if target.full_arch == "i586" { + cmd.push_cc_arg("-arch:IA32".into()); + } else if target.full_arch == "arm64ec" { + cmd.push_cc_arg("-arm64EC".into()); + } + // There is a check in corecrt.h that will generate a + // compilation error if + // _ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE is + // not defined to 1. The check was added in Windows + // 8 days because only store apps were allowed on ARM. + // This changed with the release of Windows 10 IoT Core. + // The check will be going away in future versions of + // the SDK, but for all released versions of the + // Windows SDK it is required. + if target.arch == "arm" { + cmd.args + .push("-D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1".into()); + } + } + ToolFamily::Gnu => { + if target.vendor == "kmc" { + cmd.args.push("-finput-charset=utf-8".into()); + } + + if self.static_flag.is_none() { + let features = cargo_env_var_os("CARGO_CFG_TARGET_FEATURE"); + let features = features.as_deref().unwrap_or_default(); + if features.to_string_lossy().contains("crt-static") { + cmd.args.push("-static".into()); + } + } + + // armv7 targets get to use armv7 instructions + if (target.full_arch.starts_with("armv7") + || target.full_arch.starts_with("thumbv7")) + && (target.os == "linux" || target.vendor == "kmc") + { + cmd.args.push("-march=armv7-a".into()); + + if target.abi == "eabihf" { + // lowest common denominator FPU + cmd.args.push("-mfpu=vfpv3-d16".into()); + cmd.args.push("-mfloat-abi=hard".into()); + } + } + + // (x86 Android doesn't say "eabi") + if target.os == "android" && target.full_arch.contains("v7") { + cmd.args.push("-march=armv7-a".into()); + cmd.args.push("-mthumb".into()); + if !target.full_arch.contains("neon") { + // On android we can guarantee some extra float instructions + // (specified in the android spec online) + // NEON guarantees even more; see below. + cmd.args.push("-mfpu=vfpv3-d16".into()); + } + cmd.args.push("-mfloat-abi=softfp".into()); + } + + if target.full_arch.contains("neon") { + cmd.args.push("-mfpu=neon-vfpv4".into()); + } + + if target.full_arch == "armv4t" && target.os == "linux" { + cmd.args.push("-march=armv4t".into()); + cmd.args.push("-marm".into()); + cmd.args.push("-mfloat-abi=soft".into()); + } + + if target.full_arch == "armv5te" && target.os == "linux" { + cmd.args.push("-march=armv5te".into()); + cmd.args.push("-marm".into()); + cmd.args.push("-mfloat-abi=soft".into()); + } + + // For us arm == armv6 by default + if target.full_arch == "arm" && target.os == "linux" { + cmd.args.push("-march=armv6".into()); + cmd.args.push("-marm".into()); + if target.abi == "eabihf" { + cmd.args.push("-mfpu=vfp".into()); + } else { + cmd.args.push("-mfloat-abi=soft".into()); + } + } + + // Turn codegen down on i586 to avoid some instructions. + if target.full_arch == "i586" && target.os == "linux" { + cmd.args.push("-march=pentium".into()); + } + + // Set codegen level for i686 correctly + if target.full_arch == "i686" && target.os == "linux" { + cmd.args.push("-march=i686".into()); + } + + // Looks like `musl-gcc` makes it hard for `-m32` to make its way + // all the way to the linker, so we need to actually instruct the + // linker that we're generating 32-bit executables as well. This'll + // typically only be used for build scripts which transitively use + // these flags that try to compile executables. + if target.arch == "x86" && target.env == "musl" { + cmd.args.push("-Wl,-melf_i386".into()); + } + + // + // Arm Target Details + // + + // Set Float ABI for all Arm bare-metal targets using EABIHF + if target.arch == "arm" && target.os == "none" && target.abi == "eabihf" { + cmd.args.push("-mfloat-abi=hard".into()) + } + // Set -mthumb for all Thumb targets + if target.full_arch.starts_with("thumb") { + cmd.args.push("-mthumb".into()); + } + // Armv6-M targets (no FPU available) + if target.full_arch.starts_with("thumbv6m") { + // ARMv6S-M is an old name for "ARMv6-M with SVC support" + // before SVC support became mandatory. Some versions of GAS care + // about the difference. + cmd.args.push("-march=armv6s-m".into()); + } + // Armv7-M targets (no FPU available) + if target.full_arch.starts_with("thumbv7m") { + cmd.args.push("-march=armv7-m".into()); + } + // Armv7E-M targets + if target.full_arch.starts_with("thumbv7em") { + cmd.args.push("-march=armv7e-m".into()); + if target.abi == "eabihf" { + cmd.args.push("-mfpu=fpv4-sp-d16".into()) + } + } + // Armv8-M Baseline (no FPU available) + if target.full_arch.starts_with("thumbv8m.base") { + cmd.args.push("-march=armv8-m.base".into()); + } + // Armv8-M Mainline targets + if target.full_arch.starts_with("thumbv8m.main") { + cmd.args.push("-march=armv8-m.main".into()); + if target.abi == "eabihf" { + cmd.args.push("-mfpu=fpv5-sp-d16".into()) + } + } + // ARMv6 targets + if target.full_arch.starts_with("armv6") + || (target.full_arch.starts_with("thumbv6") + && !target.full_arch.starts_with("thumbv6m")) + { + cmd.args.push("-march=armv6".into()); + if target.abi == "eabihf" { + // lowest common denominator FPU + cmd.args.push("-mfpu=vfpv2".into()); + } + } + // ARMv7-R targets + if target.full_arch.starts_with("armebv7r") + || target.full_arch.starts_with("armv7r") + || target.full_arch.starts_with("thumbv7r") + { + if target.full_arch.starts_with("armeb") { + cmd.args.push("-mbig-endian".into()); + } + cmd.args.push("-march=armv7-r".into()); + if target.abi == "eabihf" { + // lowest common denominator FPU + // (see Cortex-R4 technical reference manual) + cmd.args.push("-mfpu=vfpv3-d16".into()) + } + } + // Armv7-A targets + if target.full_arch.starts_with("armv7a") + || target.full_arch.starts_with("thumbv7a") + { + cmd.args.push("-march=armv7-a".into()); + if target.abi == "eabihf" { + // lowest common denominator FPU + cmd.args.push("-mfpu=vfpv3-d16".into()); + } + } + // Armv8-R targets + if target.full_arch.starts_with("armv8r") + || target.full_arch.starts_with("thumbv8r") + { + cmd.args.push("-march=armv8-r".into()); + if target.abi == "eabihf" { + cmd.args.push("-mfpu=fp-armv8".into()) + } + } + + if target.arch == "riscv32" || target.arch == "riscv64" { + // get the 32i/32imac/32imc/64gc/64imac/... part + let arch = &target.full_arch[5..]; + if arch.starts_with("64") { + if matches!(target.os, "linux" | "freebsd" | "netbsd") { + cmd.args.push(("-march=rv64gc").into()); + cmd.args.push("-mabi=lp64d".into()); + } else { + cmd.args.push(("-march=rv".to_owned() + arch).into()); + cmd.args.push("-mabi=lp64".into()); + } + } else if arch.starts_with("32") { + if target.os == "linux" { + cmd.args.push(("-march=rv32gc").into()); + cmd.args.push("-mabi=ilp32d".into()); + } else { + cmd.args.push(("-march=rv".to_owned() + arch).into()); + cmd.args.push("-mabi=ilp32".into()); + } + } else { + cmd.args.push("-mcmodel=medany".into()); + } + } + } + } + + if raw_target == "wasm32v1-none" { + // `wasm32v1-none` target only exists in `rustc`, so we need to change the compilation flags: + // https://doc.rust-lang.org/rustc/platform-support/wasm32v1-none.html + cmd.push_cc_arg("-mcpu=mvp".into()); + cmd.push_cc_arg("-mmutable-globals".into()); + } + + if target.os == "solaris" || target.os == "illumos" { + // On Solaris and illumos, multi-threaded C programs must be built with `_REENTRANT` + // defined. This configures headers to define APIs appropriately for multi-threaded + // use. This is documented in threads(7), see also https://illumos.org/man/7/threads. + // + // If C code is compiled without multi-threading support but does use multiple threads, + // incorrect behavior may result. One extreme example is that on some systems the + // global errno may be at the same address as the process' first thread's errno; errno + // clobbering may occur to disastrous effect. Conversely, if _REENTRANT is defined + // while it is not actually needed, system headers may define some APIs suboptimally + // but will not result in incorrect behavior. Other code *should* be reasonable under + // such conditions. + // + // We're typically building C code to eventually link into a Rust program. Many Rust + // programs are multi-threaded in some form. So, set the flag by default. + cmd.args.push("-D_REENTRANT".into()); + } + + if target.vendor == "apple" { + self.apple_flags(cmd)?; + } + + if self.static_flag.unwrap_or(false) { + cmd.args.push("-static".into()); + } + if self.shared_flag.unwrap_or(false) { + cmd.args.push("-shared".into()); + } + + if self.cpp { + match (self.cpp_set_stdlib.as_ref(), cmd.family) { + (None, _) => {} + (Some(stdlib), ToolFamily::Gnu) | (Some(stdlib), ToolFamily::Clang { .. }) => { + cmd.push_cc_arg(format!("-stdlib=lib{stdlib}").into()); + } + _ => { + self.cargo_output.print_warning(&format_args!("cpp_set_stdlib is specified, but the {:?} compiler does not support this option, ignored", cmd.family)); + } + } + } + + Ok(()) + } + + fn add_inherited_rustflags( + &self, + cmd: &mut Tool, + target: &TargetInfo<'_>, + ) -> Result<(), Error> { + let env_os = match cargo_env_var_os("CARGO_ENCODED_RUSTFLAGS") { + Some(env) => env, + // No encoded RUSTFLAGS -> nothing to do + None => return Ok(()), + }; + + let env = env_os.to_string_lossy(); + let codegen_flags = RustcCodegenFlags::parse(&env)?; + codegen_flags.cc_flags(self, cmd, target); + Ok(()) + } + + fn msvc_macro_assembler(&self) -> Result { + let target = self.get_target()?; + let tool = match target.arch { + "x86_64" => "ml64.exe", + "arm" => "armasm.exe", + "aarch64" | "arm64ec" => "armasm64.exe", + _ => "ml.exe", + }; + let mut cmd = self + .find_msvc_tools_find(&target, tool) + .unwrap_or_else(|| self.cmd(tool)); + cmd.arg("-nologo"); // undocumented, yet working with armasm[64] + for directory in self.include_directories.iter() { + cmd.arg("-I").arg(&**directory); + } + if is_arm(&target) { + if self.get_debug() { + cmd.arg("-g"); + } + + if target.arch == "arm64ec" { + cmd.args(["-machine", "ARM64EC"]); + } + + for (key, value) in self.definitions.iter() { + cmd.arg("-PreDefine"); + if let Some(ref value) = *value { + if let Ok(i) = value.parse::() { + cmd.arg(format!("{key} SETA {i}")); + } else if value.starts_with('"') && value.ends_with('"') { + cmd.arg(format!("{key} SETS {value}")); + } else { + cmd.arg(format!("{key} SETS \"{value}\"")); + } + } else { + cmd.arg(format!("{} SETL {}", key, "{TRUE}")); + } + } + } else { + if self.get_debug() { + cmd.arg("-Zi"); + } + + for (key, value) in self.definitions.iter() { + if let Some(ref value) = *value { + cmd.arg(format!("-D{key}={value}")); + } else { + cmd.arg(format!("-D{key}")); + } + } + } + + if target.arch == "x86" { + cmd.arg("-safeseh"); + } + + Ok(cmd) + } + + fn assemble(&self, lib_name: &str, dst: &Path, objs: &[Object]) -> Result<(), Error> { + // Delete the destination if it exists as we want to + // create on the first iteration instead of appending. + let _ = fs::remove_file(dst); + + // Add objects to the archive in limited-length batches. This helps keep + // the length of the command line within a reasonable length to avoid + // blowing system limits on limiting platforms like Windows. + // + // Optimistically try the `D` (deterministic) ar modifier, which zeros + // out timestamps, UIDs, and GIDs. If the archiver doesn't support it, + // we remember and stop trying for subsequent batches. + // (`None` -> haven't probed yet) + let mut deterministic_ar: Option = None; + + let mut objs = objs + .iter() + .map(|o| o.dst.as_path()) + .chain(self.objects.iter().map(std::ops::Deref::deref)) + .peekable(); + let mut batch = Vec::new(); + while objs.peek().is_some() { + let mut remaining_len = 4000; + while let Some(path) = + objs.next_if(|peek| batch.is_empty() || peek.as_os_str().len() <= remaining_len) + { + batch.push(path); + remaining_len = remaining_len.saturating_sub(path.as_os_str().len()); + } + self.assemble_progressive(dst, &batch, &mut deterministic_ar)?; + batch.clear(); + } + + if self.cuda && self.cuda_file_count() > 0 { + // Link the device-side code and add it to the target library, + // so that non-CUDA linker can link the final binary. + + let out_dir = self.get_out_dir()?; + let dlink = out_dir.join(lib_name.to_owned() + "_dlink.o"); + let mut nvcc = self.get_compiler().to_command(); + nvcc.arg("--device-link").arg("-o").arg(&dlink).arg(dst); + run(&mut nvcc, &self.cargo_output)?; + self.assemble_progressive(dst, &[dlink.as_path()], &mut deterministic_ar)?; + } + + let target = self.get_target()?; + if target.env == "msvc" { + // The Rust compiler will look for libfoo.a and foo.lib, but the + // MSVC linker will also be passed foo.lib, so be sure that both + // exist for now. + + let lib_dst = dst.with_file_name(format!("{lib_name}.lib")); + let _ = fs::remove_file(&lib_dst); + match fs::hard_link(dst, &lib_dst).or_else(|_| { + // if hard-link fails, just copy (ignoring the number of bytes written) + fs::copy(dst, &lib_dst).map(|_| ()) + }) { + Ok(_) => (), + Err(_) => { + return Err(Error::new( + ErrorKind::IOError, + "Could not copy or create a hard-link to the generated lib file.", + )); + } + }; + } else { + // Non-msvc targets (those using `ar`) need a separate step to add + // the symbol table to archives since our construction command of + // `cq` doesn't add it for us. + let mut ar = self.try_get_archiver()?; + // NOTE: We add `s` even if flags were passed using $ARFLAGS/ar_flag, because `s` + // here represents a _mode_, not an arbitrary flag. Further discussion of this choice + // can be seen in https://github.com/rust-lang/cc-rs/pull/763. + match deterministic_ar { + Some(false) => { + // See comment in `assemble_progressive` for more on ZERO_AR_DATE. + ar.env("ZERO_AR_DATE", "1"); + run(ar.arg("s").arg(dst), &self.cargo_output)?; + } + Some(true) => { + run(ar.arg("sD").arg(dst), &self.cargo_output)?; + } + None => { + if run_silent_on_error(ar.arg("sD").arg(dst), &self.cargo_output).is_err() { + let mut ar = self.try_get_archiver()?; + ar.env("ZERO_AR_DATE", "1"); + run(ar.arg("s").arg(dst), &self.cargo_output)?; + } + } + } + } + + Ok(()) + } + + fn assemble_progressive( + &self, + dst: &Path, + objs: &[&Path], + deterministic_ar: &mut Option, + ) -> Result<(), Error> { + let target = self.get_target()?; + + let (mut cmd, program, any_flags) = self.try_get_archiver_and_flags()?; + if target.env == "msvc" && !program.to_string_lossy().contains("llvm-ar") { + // NOTE: -out: here is an I/O flag, and so must be included even if $ARFLAGS/ar_flag is + // in use. -nologo on the other hand is just a regular flag, and one that we'll skip if + // the caller has explicitly dictated the flags they want. See + // https://github.com/rust-lang/cc-rs/pull/763 for further discussion. + let mut out = OsString::from("-out:"); + out.push(dst); + cmd.arg(out); + if !any_flags { + cmd.arg("-nologo"); + } + // If the library file already exists, add the library name + // as an argument to let lib.exe know we are appending the objs. + if dst.exists() { + cmd.arg(dst); + } + cmd.args(objs); + run(&mut cmd, &self.cargo_output)?; + } else { + // Set an environment variable to tell the OSX archiver to ensure + // that all dates listed in the archive are zero, improving + // determinism of builds. AFAIK there's not really official + // documentation of this but there's a lot of references to it if + // you search google. + // + // You can reproduce this locally on a mac with: + // + // $ touch foo.c + // $ cc -c foo.c -o foo.o + // + // # Notice that these two checksums are different + // $ ar crus libfoo1.a foo.o && sleep 2 && ar crus libfoo2.a foo.o + // $ md5sum libfoo*.a + // + // # Notice that these two checksums are the same + // $ export ZERO_AR_DATE=1 + // $ ar crus libfoo1.a foo.o && sleep 2 && touch foo.o && ar crus libfoo2.a foo.o + // $ md5sum libfoo*.a + // + // In any case if this doesn't end up getting read, it shouldn't + // cause that many issues! + cmd.env("ZERO_AR_DATE", "1"); + + // NOTE: We add cq here regardless of whether $ARFLAGS/ar_flag have been used because + // it dictates the _mode_ ar runs in, which the setter of $ARFLAGS/ar_flag can't + // dictate. See https://github.com/rust-lang/cc-rs/pull/763 for further discussion. + match *deterministic_ar { + Some(false) => { + run(cmd.arg("cq").arg(dst).args(objs), &self.cargo_output)?; + } + Some(true) => { + run(cmd.arg("cqD").arg(dst).args(objs), &self.cargo_output)?; + } + None => { + // Probe: try `D` and remember the result for later batches. + if run_silent_on_error(cmd.arg("cqD").arg(dst).args(objs), &self.cargo_output) + .is_ok() + { + *deterministic_ar = Some(true); + } else { + *deterministic_ar = Some(false); + let (mut cmd, _, _) = self.try_get_archiver_and_flags()?; + cmd.env("ZERO_AR_DATE", "1"); + run(cmd.arg("cq").arg(dst).args(objs), &self.cargo_output)?; + } + } + } + } + + Ok(()) + } + + fn apple_flags(&self, cmd: &mut Tool) -> Result<(), Error> { + let target = self.get_target()?; + + // This is a Darwin/Apple-specific flag that works both on GCC and Clang, but it is only + // necessary on GCC since we specify `-target` on Clang. + // https://gcc.gnu.org/onlinedocs/gcc/Darwin-Options.html#:~:text=arch + // https://clang.llvm.org/docs/CommandGuide/clang.html#cmdoption-arch + if cmd.is_like_gnu() { + let arch = map_darwin_target_from_rust_to_compiler_architecture(&target); + cmd.args.push("-arch".into()); + cmd.args.push(arch.into()); + } + + // Pass the deployment target via `-mmacosx-version-min=`, `-miphoneos-version-min=` and + // similar. Also necessary on GCC, as it forces a compilation error if the compiler is not + // configured for Darwin: https://gcc.gnu.org/onlinedocs/gcc/Darwin-Options.html + // + // On visionOS and Mac Catalyst, there is no -m*-version-min= flag: + // https://github.com/llvm/llvm-project/issues/88271 + // And the workaround to use `-mtargetos=` cannot be used with the `--target` flag that we + // otherwise specify. So we avoid emitting that, and put the version in `--target` instead. + if cmd.is_like_gnu() || !(target.os == "visionos" || target.env == "macabi") { + let min_version = self.apple_deployment_target(&target); + cmd.args + .push(target.apple_version_flag(&min_version).into()); + } + + // AppleClang sometimes requires sysroot even on macOS + if cmd.is_xctoolchain_clang() || target.os != "macos" { + self.cargo_output.print_metadata(&format_args!( + "Detecting {:?} SDK path for {}", + target.os, + target.apple_sdk_name(), + )); + let sdk_path = self.apple_sdk_root(&target)?; + + cmd.args.push("-isysroot".into()); + cmd.args.push(OsStr::new(&sdk_path).to_owned()); + cmd.env + .push(("SDKROOT".into(), OsStr::new(&sdk_path).to_owned())); + + if target.env == "macabi" { + // Mac Catalyst uses the macOS SDK, but to compile against and + // link to iOS-specific frameworks, we should have the support + // library stubs in the include and library search path. + let ios_support = Path::new(&sdk_path).join("System/iOSSupport"); + + cmd.args.extend([ + // Header search path + OsString::from("-isystem"), + ios_support.join("usr/include").into(), + // Framework header search path + OsString::from("-iframework"), + ios_support.join("System/Library/Frameworks").into(), + // Library search path + { + let mut s = OsString::from("-L"); + s.push(ios_support.join("usr/lib")); + s + }, + // Framework linker search path + { + // Technically, we _could_ avoid emitting `-F`, as + // `-iframework` implies it, but let's keep it in for + // clarity. + let mut s = OsString::from("-F"); + s.push(ios_support.join("System/Library/Frameworks")); + s + }, + ]); + } + } + + Ok(()) + } + + fn cmd>(&self, prog: P) -> Command { + let mut cmd = Command::new(prog); + for (a, b) in self.env.iter() { + cmd.env(a, b); + } + cmd + } + + fn prefer_clang(&self) -> bool { + if let Some(env) = cargo_env_var_os("CARGO_ENCODED_RUSTFLAGS") { + env.to_string_lossy().contains("linker-plugin-lto") + } else { + false + } + } + + fn get_base_compiler(&self) -> Result { + let out_dir = self.get_out_dir().ok(); + let out_dir = out_dir.as_deref(); + + if let Some(c) = &self.compiler { + return Ok(Tool::new( + (**c).to_owned(), + &self.build_cache.cached_compiler_family, + &self.cargo_output, + out_dir, + )); + } + let target = self.get_target()?; + let raw_target = self.get_raw_target()?; + + let msvc = if self.prefer_clang_cl_over_msvc { + "clang-cl.exe" + } else { + "cl.exe" + }; + + let (env, gnu, traditional, clang) = if self.cpp { + ("CXX", "g++", "c++", "clang++") + } else { + ("CC", "gcc", "cc", "clang") + }; + + let fallback = Cow::Borrowed(Path::new(traditional)); + let default = if cfg!(target_os = "solaris") || cfg!(target_os = "illumos") { + // On historical Solaris systems, "cc" may have been Sun Studio, which + // is not flag-compatible with "gcc". This history casts a long shadow, + // and many modern illumos distributions today ship GCC as "gcc" without + // also making it available as "cc". + Cow::Borrowed(Path::new(gnu)) + } else if self.prefer_clang() { + self.which(Path::new(clang), None) + .map(Cow::Owned) + .unwrap_or(fallback) + } else { + fallback + }; + + let cl_exe = self.find_msvc_tools_find_tool(&target, msvc); + + let tool_opt: Option = self + .env_tool(env) + .map(|(tool, wrapper, args)| { + // Chop off leading/trailing whitespace to work around + // semi-buggy build scripts which are shared in + // makefiles/configure scripts (where spaces are far more + // lenient) + let mut t = Tool::with_args( + tool, + args.clone(), + &self.build_cache.cached_compiler_family, + &self.cargo_output, + out_dir, + ); + if let Some(cc_wrapper) = wrapper { + t.cc_wrapper_path = Some(Path::new(&cc_wrapper).to_owned()); + } + for arg in args { + t.cc_wrapper_args.push(arg.into()); + } + t + }) + .or_else(|| { + if target.os == "emscripten" { + let tool = if self.cpp { "em++" } else { "emcc" }; + // Windows uses bat file so we have to be a bit more specific + if cfg!(windows) { + let mut t = Tool::with_family( + PathBuf::from("cmd"), + ToolFamily::Clang { zig_cc: false }, + ); + t.args.push("/c".into()); + t.args.push(format!("{tool}.bat").into()); + Some(t) + } else { + Some(Tool::new( + PathBuf::from(tool), + &self.build_cache.cached_compiler_family, + &self.cargo_output, + out_dir, + )) + } + } else { + None + } + }) + .or_else(|| cl_exe.clone()); + + let tool = match tool_opt { + Some(t) => t, + None => { + let compiler: PathBuf = if cfg!(windows) && target.os == "windows" { + if target.env == "msvc" { + msvc.into() + } else { + let cc = if target.abi == "llvm" { clang } else { gnu }; + format!("{cc}.exe").into() + } + } else if target.os == "ios" + || target.os == "watchos" + || target.os == "tvos" + || target.os == "visionos" + { + clang.into() + } else if target.os == "android" { + autodetect_android_compiler(&raw_target, gnu, clang) + } else if target.os == "cloudabi" { + format!( + "{}-{}-{}-{}", + target.full_arch, target.vendor, target.os, traditional + ) + .into() + } else if target.os == "wasi" { + self.autodetect_wasi_compiler(&raw_target, clang) + } else if target.arch == "wasm32" || target.arch == "wasm64" { + // Compiling WASM is not currently supported by GCC, so + // let's default to Clang. + clang.into() + } else if target.os == "vxworks" { + if self.cpp { "wr-c++" } else { "wr-cc" }.into() + } else if target.arch == "arm" && target.vendor == "kmc" { + format!("arm-kmc-eabi-{gnu}").into() + } else if target.arch == "aarch64" && target.vendor == "kmc" { + format!("aarch64-kmc-elf-{gnu}").into() + } else if target.os == "nto" { + // See for details: https://github.com/rust-lang/cc-rs/pull/1319 + if self.cpp { "q++" } else { "qcc" }.into() + } else if self.get_is_cross_compile()? { + let prefix = self.prefix_for_target(&raw_target); + match prefix { + Some(prefix) => { + let cc = if target.abi == "llvm" { clang } else { gnu }; + format!("{prefix}-{cc}").into() + } + None => default.into(), + } + } else { + default.into() + }; + + let mut t = Tool::new( + compiler, + &self.build_cache.cached_compiler_family, + &self.cargo_output, + out_dir, + ); + if let Some(cc_wrapper) = self.rustc_wrapper_fallback() { + t.cc_wrapper_path = Some(Path::new(&cc_wrapper).to_owned()); + } + t + } + }; + + let mut tool = if self.cuda { + assert!( + tool.args.is_empty(), + "CUDA compilation currently assumes empty pre-existing args" + ); + let nvcc = match self.getenv_with_target_prefixes("NVCC") { + Err(_) => PathBuf::from("nvcc"), + Ok(nvcc) => PathBuf::from(&*nvcc), + }; + let mut nvcc_tool = Tool::with_features( + nvcc, + vec![], + self.cuda, + &self.build_cache.cached_compiler_family, + &self.cargo_output, + out_dir, + ); + if self.ccbin { + nvcc_tool + .args + .push(format!("-ccbin={}", tool.path.display()).into()); + } + if let Some(cc_wrapper) = self.rustc_wrapper_fallback() { + nvcc_tool.cc_wrapper_path = Some(Path::new(&cc_wrapper).to_owned()); + } + nvcc_tool.family = tool.family; + nvcc_tool + } else { + tool + }; + + // New "standalone" C/C++ cross-compiler executables from recent Android NDK + // are just shell scripts that call main clang binary (from Android NDK) with + // proper `--target` argument. + // + // For example, armv7a-linux-androideabi16-clang passes + // `--target=armv7a-linux-androideabi16` to clang. + // + // As the shell script calls the main clang binary, the command line limit length + // on Windows is restricted to around 8k characters instead of around 32k characters. + // To remove this limit, we call the main clang binary directly and construct the + // `--target=` ourselves. + if cfg!(windows) && android_clang_compiler_uses_target_arg_internally(&tool.path) { + if let Some(path) = tool.path.file_name() { + let file_name = path.to_str().unwrap().to_owned(); + let (target, clang) = file_name.split_at(file_name.rfind('-').unwrap()); + + tool.has_internal_target_arg = true; + tool.path.set_file_name(clang.trim_start_matches('-')); + tool.path.set_extension("exe"); + tool.args.push(format!("--target={target}").into()); + + // Additionally, shell scripts for target i686-linux-android versions 16 to 24 + // pass the `mstackrealign` option so we do that here as well. + if target.contains("i686-linux-android") { + let (_, version) = target.split_at(target.rfind('d').unwrap() + 1); + if let Ok(version) = version.parse::() { + if version > 15 && version < 25 { + tool.args.push("-mstackrealign".into()); + } + } + } + }; + } + + // Under cross-compilation scenarios, llvm-mingw's clang executable is just a + // wrapper script that calls the actual clang binary with a suitable `--target` + // argument, much like the Android NDK case outlined above. Passing a target + // argument ourselves in this case will result in an error, as they expect + // targets like `x86_64-w64-mingw32`, and we can't always set such a target + // string because it is specific to this MinGW cross-compilation toolchain. + // + // For example, the following command will always fail due to using an unsuitable + // `--target` argument we'd otherwise pass: + // $ /opt/llvm-mingw-20250613-ucrt-ubuntu-22.04-x86_64/bin/x86_64-w64-mingw32-clang --target=x86_64-pc-windows-gnu dummy.c + // + // Code reference: + // https://github.com/mstorsjo/llvm-mingw/blob/a1f6413e5c21fd74b64137b56167f4fba500d1d8/wrappers/clang-target-wrapper.sh#L31 + if !cfg!(windows) && target.os == "windows" && is_llvm_mingw_wrapper(&tool.path) { + tool.has_internal_target_arg = true; + } + + // If we found `cl.exe` in our environment, the tool we're returning is + // an MSVC-like tool, *and* no env vars were set then set env vars for + // the tool that we're returning. + // + // Env vars are needed for things like `link.exe` being put into PATH as + // well as header include paths sometimes. These paths are automatically + // included by default but if the `CC` or `CXX` env vars are set these + // won't be used. This'll ensure that when the env vars are used to + // configure for invocations like `clang-cl` we still get a "works out + // of the box" experience. + if let Some(cl_exe) = cl_exe { + if tool.family == (ToolFamily::Msvc { clang_cl: true }) + && tool.env.is_empty() + && target.env == "msvc" + { + for (k, v) in cl_exe.env.iter() { + tool.env.push((k.to_owned(), v.to_owned())); + } + } + } + + if target.env == "msvc" && tool.family == ToolFamily::Gnu { + self.cargo_output + .print_warning(&"GNU compiler is not supported for this target"); + } + + Ok(tool) + } + + /// Returns a fallback `cc_compiler_wrapper` by introspecting `RUSTC_WRAPPER` + fn rustc_wrapper_fallback(&self) -> Option> { + // No explicit CC wrapper was detected, but check if RUSTC_WRAPPER + // is defined and is a build accelerator that is compatible with + // C/C++ compilers (e.g. sccache) + const VALID_WRAPPERS: &[&str] = &["sccache", "cachepot", "buildcache"]; + + let rustc_wrapper = cargo_env_var_os("RUSTC_WRAPPER")?; + let wrapper_path = Path::new(&rustc_wrapper); + let wrapper_stem = wrapper_path.file_stem()?; + + if VALID_WRAPPERS.contains(&wrapper_stem.to_str()?) { + Some(Cow::Owned(rustc_wrapper)) + } else { + None + } + } + + /// Returns compiler path, optional modifier name from whitelist, and arguments vec + fn env_tool(&self, name: &str) -> Option<(PathBuf, Option>, Vec)> { + let tool = self.getenv_with_target_prefixes(name).ok()?; + let tool = tool.to_string_lossy(); + let tool = tool.trim(); + + if tool.is_empty() { + return None; + } + + // If this is an exact path on the filesystem we don't want to do any + // interpretation at all, just pass it on through. This'll hopefully get + // us to support spaces-in-paths. + if let Some(exe) = check_exe(Path::new(tool).into()) { + return Some((exe, self.rustc_wrapper_fallback(), Vec::new())); + } + + // Ok now we want to handle a couple of scenarios. We'll assume from + // here on out that spaces are splitting separate arguments. Two major + // features we want to support are: + // + // CC='sccache cc' + // + // aka using `sccache` or any other wrapper/caching-like-thing for + // compilations. We want to know what the actual compiler is still, + // though, because our `Tool` API support introspection of it to see + // what compiler is in use. + // + // additionally we want to support + // + // CC='cc -flag' + // + // where the CC env var is used to also pass default flags to the C + // compiler. + // + // It's true that everything here is a bit of a pain, but apparently if + // you're not literally make or bash then you get a lot of bug reports. + let mut known_wrappers = vec![ + "ccache", + "distcc", + "sccache", + "icecc", + "cachepot", + "buildcache", + ]; + let custom_wrapper = self.get_env("CC_KNOWN_WRAPPER_CUSTOM"); + if custom_wrapper.is_some() { + known_wrappers.push(custom_wrapper.as_deref().unwrap().to_str().unwrap()); + } + + let mut parts = tool.split_whitespace(); + let maybe_wrapper = parts.next()?; + + let file_stem = Path::new(maybe_wrapper).file_stem()?.to_str()?; + if known_wrappers.contains(&file_stem) { + if let Some(compiler) = parts.next() { + return Some(( + compiler.into(), + Some(Cow::Owned(maybe_wrapper.into())), + parts.map(|s| s.to_string()).collect(), + )); + } + } + + Some(( + maybe_wrapper.into(), + self.rustc_wrapper_fallback(), + parts.map(|s| s.to_string()).collect(), + )) + } + + /// Returns the C++ standard library: + /// 1. If [`cpp_link_stdlib`](cc::Build::cpp_link_stdlib) is set, uses its value. + /// 2. Else if the `CXXSTDLIB` environment variable is set, uses its value. + /// 3. Else the default is `c++` for OS X and BSDs, `c++_shared` for Android, + /// `None` for MSVC and `stdc++` for anything else. + fn get_cpp_link_stdlib(&self) -> Result>, Error> { + match &self.cpp_link_stdlib { + Some(s) => Ok(s.as_deref().map(Path::new).map(Cow::Borrowed)), + None => { + if let Ok(stdlib) = self.getenv_with_target_prefixes("CXXSTDLIB") { + if stdlib.is_empty() { + Ok(None) + } else { + Ok(Some(Cow::Owned(Path::new(&stdlib).to_owned()))) + } + } else { + let target = self.get_target()?; + if target.env == "msvc" { + Ok(None) + } else if target.vendor == "apple" + || target.os == "freebsd" + || target.os == "openbsd" + || target.os == "aix" + || (target.os == "linux" && target.env == "ohos") + || target.os == "wasi" + { + Ok(Some(Cow::Borrowed(Path::new("c++")))) + } else if target.os == "android" { + Ok(Some(Cow::Borrowed(Path::new("c++_shared")))) + } else { + Ok(Some(Cow::Borrowed(Path::new("stdc++")))) + } + } + } + } + } + + /// Get the archiver (ar) that's in use for this configuration. + /// + /// You can use [`Command::get_program`] to get just the path to the command. + /// + /// This method will take into account all configuration such as debug + /// information, optimization level, include directories, defines, etc. + /// Additionally, the compiler binary in use follows the standard + /// conventions for this path, e.g. looking at the explicitly set compiler, + /// environment variables (a number of which are inspected here), and then + /// falling back to the default configuration. + /// + /// # Panics + /// + /// Panics if an error occurred while determining the architecture. + pub fn get_archiver(&self) -> Command { + match self.try_get_archiver() { + Ok(tool) => tool, + Err(e) => fail(&e.message), + } + } + + /// Get the archiver that's in use for this configuration. + /// + /// This will return a result instead of panicking; + /// see [`Self::get_archiver`] for the complete description. + pub fn try_get_archiver(&self) -> Result { + Ok(self.try_get_archiver_and_flags()?.0) + } + + fn try_get_archiver_and_flags(&self) -> Result<(Command, PathBuf, bool), Error> { + let (mut cmd, name) = self.get_base_archiver()?; + let mut any_flags = false; + if let Some(flags) = self.envflags("ARFLAGS")? { + any_flags = true; + cmd.args(flags); + } + for flag in &self.ar_flags { + any_flags = true; + cmd.arg(&**flag); + } + Ok((cmd, name, any_flags)) + } + + fn get_base_archiver(&self) -> Result<(Command, PathBuf), Error> { + if let Some(ref a) = self.archiver { + let archiver = &**a; + return Ok((self.cmd(archiver), archiver.into())); + } + + self.get_base_archiver_variant("AR", "ar") + } + + /// Get the ranlib that's in use for this configuration. + /// + /// You can use [`Command::get_program`] to get just the path to the command. + /// + /// This method will take into account all configuration such as debug + /// information, optimization level, include directories, defines, etc. + /// Additionally, the compiler binary in use follows the standard + /// conventions for this path, e.g. looking at the explicitly set compiler, + /// environment variables (a number of which are inspected here), and then + /// falling back to the default configuration. + /// + /// # Panics + /// + /// Panics if an error occurred while determining the architecture. + pub fn get_ranlib(&self) -> Command { + match self.try_get_ranlib() { + Ok(tool) => tool, + Err(e) => fail(&e.message), + } + } + + /// Get the ranlib that's in use for this configuration. + /// + /// This will return a result instead of panicking; + /// see [`Self::get_ranlib`] for the complete description. + pub fn try_get_ranlib(&self) -> Result { + let mut cmd = self.get_base_ranlib()?; + if let Some(flags) = self.envflags("RANLIBFLAGS")? { + cmd.args(flags); + } + Ok(cmd) + } + + fn get_base_ranlib(&self) -> Result { + if let Some(ref r) = self.ranlib { + return Ok(self.cmd(&**r)); + } + + Ok(self.get_base_archiver_variant("RANLIB", "ranlib")?.0) + } + + fn get_base_archiver_variant( + &self, + env: &str, + tool: &str, + ) -> Result<(Command, PathBuf), Error> { + let target = self.get_target()?; + let mut name = PathBuf::new(); + let tool_opt: Option = self + .env_tool(env) + .map(|(tool, _wrapper, args)| { + name.clone_from(&tool); + let mut cmd = self.cmd(tool); + cmd.args(args); + cmd + }) + .or_else(|| { + if target.os == "emscripten" { + // Windows use bat files so we have to be a bit more specific + if cfg!(windows) { + let mut cmd = self.cmd("cmd"); + name = format!("em{tool}.bat").into(); + cmd.arg("/c").arg(&name); + Some(cmd) + } else { + name = format!("em{tool}").into(); + Some(self.cmd(&name)) + } + } else if target.arch == "wasm32" || target.arch == "wasm64" { + // Formally speaking one should be able to use this approach, + // parsing -print-search-dirs output, to cover all clang targets, + // including Android SDKs and other cross-compilation scenarios... + // And even extend it to gcc targets by searching for "ar" instead + // of "llvm-ar"... + let compiler = self.get_base_compiler().ok()?; + if compiler.is_like_clang() { + name = format!("llvm-{tool}").into(); + self.search_programs(&compiler.path, &name, &self.cargo_output) + .map(|name| self.cmd(name)) + } else { + None + } + } else { + None + } + }); + + let tool = match tool_opt { + Some(t) => t, + None => { + if target.os == "android" { + name = format!("llvm-{tool}").into(); + match Command::new(&name).arg("--version").status() { + Ok(status) if status.success() => (), + _ => { + // FIXME: Use parsed target. + let raw_target = self.get_raw_target()?; + name = format!("{}-{}", raw_target.replace("armv7", "arm"), tool).into() + } + } + self.cmd(&name) + } else if target.env == "msvc" { + // NOTE: There isn't really a ranlib on msvc, so arguably we should return + // `None` somehow here. But in general, callers will already have to be aware + // of not running ranlib on Windows anyway, so it feels okay to return lib.exe + // here. + + let compiler = self.get_base_compiler()?; + let lib = if compiler.family == (ToolFamily::Msvc { clang_cl: true }) { + self.search_programs( + &compiler.path, + Path::new("llvm-lib"), + &self.cargo_output, + ) + .or_else(|| { + // See if there is 'llvm-lib' next to 'clang-cl' + if let Some(mut cmd) = self.which(&compiler.path, None) { + cmd.pop(); + cmd.push("llvm-lib"); + self.which(&cmd, None) + } else { + None + } + }) + } else { + None + }; + + if let Some(lib) = lib { + name = lib; + self.cmd(&name) + } else { + name = PathBuf::from("lib.exe"); + let mut cmd = match self.find_msvc_tools_find(&target, "lib.exe") { + Some(t) => t, + None => self.cmd("lib.exe"), + }; + if target.full_arch == "arm64ec" { + cmd.arg("/machine:arm64ec"); + } + cmd + } + } else if target.os == "illumos" { + // The default 'ar' on illumos uses a non-standard flags, + // but the OS comes bundled with a GNU-compatible variant. + // + // Use the GNU-variant to match other Unix systems. + name = format!("g{tool}").into(); + self.cmd(&name) + } else if target.os == "vxworks" { + name = format!("wr-{tool}").into(); + self.cmd(&name) + } else if target.os == "nto" { + // Ref: https://www.qnx.com/developers/docs/8.0/com.qnx.doc.neutrino.utilities/topic/a/ar.html + name = match target.full_arch { + "i586" => format!("ntox86-{tool}").into(), + "x86" | "aarch64" | "x86_64" => { + format!("nto{}-{}", target.arch, tool).into() + } + _ => { + return Err(Error::new( + ErrorKind::InvalidTarget, + format!("Unknown architecture for Neutrino QNX: {}", target.arch), + )) + } + }; + self.cmd(&name) + } else if self.get_is_cross_compile()? { + match self.prefix_for_target(&self.get_raw_target()?) { + Some(prefix) => { + // GCC uses $target-gcc-ar, whereas binutils uses $target-ar -- try both. + // Prefer -ar if it exists, as builds of `-gcc-ar` have been observed to be + // outright broken (such as when targeting freebsd with `--disable-lto` + // toolchain where the archiver attempts to load the LTO plugin anyway but + // fails to find one). + // + // The same applies to ranlib. + let chosen = ["", "-gcc"] + .iter() + .filter_map(|infix| { + let target_p = format!("{prefix}{infix}-{tool}"); + let status = Command::new(&target_p) + .arg("--version") + .stdin(Stdio::null()) + .stdout(Stdio::null()) + .stderr(Stdio::null()) + .status() + .ok()?; + status.success().then_some(target_p) + }) + .next() + .unwrap_or_else(|| tool.to_string()); + name = chosen.into(); + self.cmd(&name) + } + None => { + name = tool.into(); + self.cmd(&name) + } + } + } else { + name = tool.into(); + self.cmd(&name) + } + } + }; + + Ok((tool, name)) + } + + // FIXME: Use parsed target instead of raw target. + fn prefix_for_target(&self, target: &str) -> Option> { + // CROSS_COMPILE is of the form: "arm-linux-gnueabi-" + self.get_env("CROSS_COMPILE") + .as_deref() + .map(|s| s.to_string_lossy().trim_end_matches('-').to_owned()) + .map(Cow::Owned) + .or_else(|| { + // Put aside RUSTC_LINKER's prefix to be used as second choice, after CROSS_COMPILE + cargo_env_var_os("RUSTC_LINKER").and_then(|var| { + var.to_string_lossy() + .strip_suffix("-gcc") + .map(str::to_string) + .map(Cow::Owned) + }) + }) + .or_else(|| { + match target { + // Note: there is no `aarch64-pc-windows-gnu` target, only `-gnullvm` + "aarch64-pc-windows-gnullvm" => Some("aarch64-w64-mingw32"), + "aarch64-uwp-windows-gnu" => Some("aarch64-w64-mingw32"), + "aarch64-unknown-helenos" => Some("aarch64-helenos"), + "aarch64-unknown-linux-gnu" => Some("aarch64-linux-gnu"), + "aarch64-unknown-linux-musl" => Some("aarch64-linux-musl"), + "aarch64-unknown-linux-relibc" => Some("aarch64-linux-relibc"), + "aarch64-unknown-netbsd" => Some("aarch64--netbsd"), + "arm-unknown-linux-gnueabi" => Some("arm-linux-gnueabi"), + "armv4t-unknown-linux-gnueabi" => Some("arm-linux-gnueabi"), + "armv5te-unknown-helenos-eabi" => Some("arm-helenos"), + "armv5te-unknown-linux-gnueabi" => Some("arm-linux-gnueabi"), + "armv5te-unknown-linux-musleabi" => Some("arm-linux-gnueabi"), + "arm-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"), + "arm-unknown-linux-musleabi" => Some("arm-linux-musleabi"), + "arm-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"), + "arm-unknown-netbsd-eabi" => Some("arm--netbsdelf-eabi"), + "armv6-unknown-netbsd-eabihf" => Some("armv6--netbsdelf-eabihf"), + "armv7-unknown-linux-gnueabi" => Some("arm-linux-gnueabi"), + "armv7-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"), + "armv7-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"), + "armv7neon-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"), + "armv7neon-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"), + "thumbv7-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"), + "thumbv7-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"), + "thumbv7neon-unknown-linux-gnueabihf" => Some("arm-linux-gnueabihf"), + "thumbv7neon-unknown-linux-musleabihf" => Some("arm-linux-musleabihf"), + "armv7-unknown-netbsd-eabihf" => Some("armv7--netbsdelf-eabihf"), + "hexagon-unknown-linux-musl" => Some("hexagon-linux-musl"), + "i586-unknown-linux-musl" => Some("musl"), + "i686-pc-windows-gnu" => Some("i686-w64-mingw32"), + "i686-pc-windows-gnullvm" => Some("i686-w64-mingw32"), + "i686-uwp-windows-gnu" => Some("i686-w64-mingw32"), + "i686-unknown-helenos" => Some("i686-helenos"), + "i686-unknown-linux-gnu" => self.find_working_gnu_prefix(&[ + "i686-linux-gnu", + "x86_64-linux-gnu", // transparently support gcc-multilib + ]), // explicit None if not found, so caller knows to fall back + "i686-unknown-linux-musl" => Some("musl"), + "i686-unknown-netbsd" => Some("i486--netbsdelf"), + "loongarch64-unknown-linux-gnu" => Some("loongarch64-linux-gnu"), + "m68k-unknown-linux-gnu" => Some("m68k-linux-gnu"), + "mips-unknown-linux-gnu" => Some("mips-linux-gnu"), + "mips-unknown-linux-musl" => Some("mips-linux-musl"), + "mipsel-unknown-linux-gnu" => Some("mipsel-linux-gnu"), + "mipsel-unknown-linux-musl" => Some("mipsel-linux-musl"), + "mips64-unknown-linux-gnuabi64" => Some("mips64-linux-gnuabi64"), + "mips64el-unknown-linux-gnuabi64" => Some("mips64el-linux-gnuabi64"), + "mipsisa32r6-unknown-linux-gnu" => Some("mipsisa32r6-linux-gnu"), + "mipsisa32r6el-unknown-linux-gnu" => Some("mipsisa32r6el-linux-gnu"), + "mipsisa64r6-unknown-linux-gnuabi64" => Some("mipsisa64r6-linux-gnuabi64"), + "mipsisa64r6el-unknown-linux-gnuabi64" => Some("mipsisa64r6el-linux-gnuabi64"), + "powerpc-unknown-helenos" => Some("ppc-helenos"), + "powerpc-unknown-linux-gnu" => Some("powerpc-linux-gnu"), + "powerpc-unknown-linux-gnuspe" => Some("powerpc-linux-gnuspe"), + "powerpc-unknown-netbsd" => Some("powerpc--netbsd"), + "powerpc64-unknown-linux-gnu" => Some("powerpc64-linux-gnu"), + "powerpc64le-unknown-linux-gnu" => Some("powerpc64le-linux-gnu"), + "riscv32i-unknown-none-elf" => self.find_working_gnu_prefix(&[ + "riscv32-unknown-elf", + "riscv64-unknown-elf", + "riscv-none-embed", + ]), + "riscv32im-unknown-none-elf" => self.find_working_gnu_prefix(&[ + "riscv32-unknown-elf", + "riscv64-unknown-elf", + "riscv-none-embed", + ]), + "riscv32imac-esp-espidf" => Some("riscv32-esp-elf"), + "riscv32imac-unknown-none-elf" => self.find_working_gnu_prefix(&[ + "riscv32-unknown-elf", + "riscv64-unknown-elf", + "riscv-none-embed", + ]), + "riscv32imafc-unknown-none-elf" => self.find_working_gnu_prefix(&[ + "riscv32-unknown-elf", + "riscv64-unknown-elf", + "riscv-none-embed", + ]), + "riscv32imac-unknown-xous-elf" => self.find_working_gnu_prefix(&[ + "riscv32-unknown-elf", + "riscv64-unknown-elf", + "riscv-none-embed", + ]), + "riscv32imc-esp-espidf" => Some("riscv32-esp-elf"), + "riscv32imc-unknown-none-elf" => self.find_working_gnu_prefix(&[ + "riscv32-unknown-elf", + "riscv64-unknown-elf", + "riscv-none-embed", + ]), + "riscv64gc-unknown-none-elf" => self.find_working_gnu_prefix(&[ + "riscv64-unknown-elf", + "riscv32-unknown-elf", + "riscv-none-embed", + ]), + "riscv64imac-unknown-none-elf" => self.find_working_gnu_prefix(&[ + "riscv64-unknown-elf", + "riscv32-unknown-elf", + "riscv-none-embed", + ]), + "riscv64gc-unknown-linux-gnu" => Some("riscv64-linux-gnu"), + "riscv64a23-unknown-linux-gnu" => Some("riscv64-linux-gnu"), + "riscv32gc-unknown-linux-gnu" => Some("riscv32-linux-gnu"), + "riscv64gc-unknown-linux-musl" => Some("riscv64-linux-musl"), + "riscv32gc-unknown-linux-musl" => Some("riscv32-linux-musl"), + "riscv64gc-unknown-netbsd" => Some("riscv64--netbsd"), + "s390x-unknown-linux-gnu" => Some("s390x-linux-gnu"), + "sparc-unknown-linux-gnu" => Some("sparc-linux-gnu"), + "sparc64-unknown-helenos" => Some("sparc64-helenos"), + "sparc64-unknown-linux-gnu" => Some("sparc64-linux-gnu"), + "sparc64-unknown-netbsd" => Some("sparc64--netbsd"), + "sparcv9-sun-solaris" => Some("sparcv9-sun-solaris"), + "armv4t-none-eabi" => Some("arm-none-eabi"), + "armv5te-none-eabi" => Some("arm-none-eabi"), + "armv6-none-eabi" => Some("arm-none-eabi"), + "armv6-none-eabihf" => Some("arm-none-eabi"), + "armv7a-none-eabi" => Some("arm-none-eabi"), + "armv7a-none-eabihf" => Some("arm-none-eabi"), + "armebv7r-none-eabi" => Some("arm-none-eabi"), + "armebv7r-none-eabihf" => Some("arm-none-eabi"), + "armv7r-none-eabi" => Some("arm-none-eabi"), + "armv7r-none-eabihf" => Some("arm-none-eabi"), + "armv8r-none-eabihf" => Some("arm-none-eabi"), + "thumbv4t-none-eabi" => Some("arm-none-eabi"), + "thumbv5te-none-eabi" => Some("arm-none-eabi"), + "thumbv6-none-eabi" => Some("arm-none-eabi"), + "thumbv7a-none-eabi" => Some("arm-none-eabi"), + "thumbv7a-none-eabihf" => Some("arm-none-eabi"), + "thumbv7r-none-eabi" => Some("arm-none-eabi"), + "thumbv7r-none-eabihf" => Some("arm-none-eabi"), + "thumbv8r-none-eabihf" => Some("arm-none-eabi"), + "thumbv6m-none-eabi" => Some("arm-none-eabi"), + "thumbv7em-none-eabi" => Some("arm-none-eabi"), + "thumbv7em-none-eabihf" => Some("arm-none-eabi"), + "thumbv7m-none-eabi" => Some("arm-none-eabi"), + "thumbv8m.base-none-eabi" => Some("arm-none-eabi"), + "thumbv8m.main-none-eabi" => Some("arm-none-eabi"), + "thumbv8m.main-none-eabihf" => Some("arm-none-eabi"), + "x86_64-pc-windows-gnu" => Some("x86_64-w64-mingw32"), + "x86_64-pc-windows-gnullvm" => Some("x86_64-w64-mingw32"), + "x86_64-uwp-windows-gnu" => Some("x86_64-w64-mingw32"), + "x86_64-rumprun-netbsd" => Some("x86_64-rumprun-netbsd"), + "x86_64-unknown-helenos" => Some("amd64-helenos"), + "x86_64-unknown-linux-gnu" => self.find_working_gnu_prefix(&[ + "x86_64-linux-gnu", // rustfmt wrap + ]), // explicit None if not found, so caller knows to fall back + "x86_64-unknown-linux-musl" => { + self.find_working_gnu_prefix(&["x86_64-linux-musl", "musl"]) + } + "x86_64-unknown-linux-relibc" => { + self.find_working_gnu_prefix(&["x86_64-linux-relibc", "relibc"]) + } + "x86_64-unknown-netbsd" => Some("x86_64--netbsd"), + "xtensa-esp32-espidf" + | "xtensa-esp32-none-elf" + | "xtensa-esp32s2-espidf" + | "xtensa-esp32s2-none-elf" + | "xtensa-esp32s3-espidf" + | "xtensa-esp32s3-none-elf" => Some("xtensa-esp-elf"), + _ => None, + } + .map(Cow::Borrowed) + }) + } + + /// Some platforms have multiple, compatible, canonical prefixes. Look through + /// each possible prefix for a compiler that exists and return it. The prefixes + /// should be ordered from most-likely to least-likely. + fn find_working_gnu_prefix(&self, prefixes: &[&'static str]) -> Option<&'static str> { + let suffix = if self.cpp { "-g++" } else { "-gcc" }; + let extension = std::env::consts::EXE_SUFFIX; + + // Loop through PATH entries searching for each toolchain. This ensures that we + // are more likely to discover the toolchain early on, because chances are good + // that the desired toolchain is in one of the higher-priority paths. + self.get_env("PATH") + .as_ref() + .and_then(|path_entries| { + env::split_paths(path_entries).find_map(|path_entry| { + for prefix in prefixes { + let target_compiler = format!("{prefix}{suffix}{extension}"); + if path_entry.join(&target_compiler).exists() { + return Some(prefix); + } + } + None + }) + }) + .copied() + // If no toolchain was found, provide the first toolchain that was passed in. + // This toolchain has been shown not to exist, however it will appear in the + // error that is shown to the user which should make it easier to search for + // where it should be obtained. + .or_else(|| prefixes.first().copied()) + } + + fn get_target(&self) -> Result, Error> { + match &self.target { + Some(t) if Some(OsStr::new(&**t)) != cargo_env_var_os("TARGET").as_deref() => { + TargetInfo::from_rustc_target(t) + } + // Fetch target information from environment if not set, or if the + // target was the same as the TARGET environment variable, in + // case the user did `build.target(&env::var("TARGET").unwrap())`. + _ => self + .build_cache + .target_info_parser + .parse_from_cargo_environment_variables(), + } + } + + fn get_raw_target(&self) -> Result, Error> { + match &self.target { + Some(t) => Ok(Cow::Borrowed(t)), + None => cargo_env_var("TARGET").map(Cow::Owned), + } + } + + fn get_is_cross_compile(&self) -> Result { + let target = self.get_raw_target()?; + let host: Cow<'_, str> = match &self.host { + Some(h) => Cow::Borrowed(h), + None => Cow::Owned(cargo_env_var("HOST")?), + }; + Ok(host != target) + } + + fn get_opt_level(&self) -> Result, Error> { + match &self.opt_level { + Some(ol) => Ok(Cow::Borrowed(ol)), + None => cargo_env_var("OPT_LEVEL").map(Cow::Owned), + } + } + + /// Returns true if *any* debug info is enabled. + /// + /// [`get_debug_str`] provides more detail. + fn get_debug(&self) -> bool { + match self.get_debug_str() { + Err(_) => false, + Ok(d) => match &*d { + // From https://doc.rust-lang.org/cargo/reference/profiles.html#debug + "" | "0" | "false" | "none" => false, + _ => true, + }, + } + } + + fn get_debug_str(&self) -> Result, Error> { + match &self.debug { + Some(d) => Ok(Cow::Borrowed(d)), + None => cargo_env_var("DEBUG").map(Cow::Owned), + } + } + + fn get_shell_escaped_flags(&self) -> bool { + self.shell_escaped_flags + .unwrap_or_else(|| self.get_env_boolean("CC_SHELL_ESCAPED_FLAGS")) + } + + fn get_dwarf_version(&self) -> Option { + // Tentatively matches the DWARF version defaults as of rustc 1.62. + let target = self.get_target().ok()?; + if matches!( + target.os, + "android" | "dragonfly" | "freebsd" | "netbsd" | "openbsd" + ) || target.vendor == "apple" + || (target.os == "windows" && target.env == "gnu") + { + Some(2) + } else if target.os == "linux" { + Some(4) + } else { + None + } + } + + fn get_force_frame_pointer(&self) -> bool { + self.force_frame_pointer.unwrap_or_else(|| self.get_debug()) + } + + fn get_out_dir(&self) -> Result, Error> { + match &self.out_dir { + Some(p) => Ok(Cow::Borrowed(&**p)), + None => cargo_env_var_os("OUT_DIR") + .map(PathBuf::from) + .map(Cow::Owned) + .ok_or_else(|| { + Error::new( + ErrorKind::EnvVarNotFound, + "Environment variable OUT_DIR not defined.", + ) + }), + } + } + + /// Look up an environment variable, and tell Cargo that we used it. + fn get_env(&self, v: &str) -> Option { + // Excluding `PATH` prevents spurious rebuilds on Windows, see + // for details. + if self.emit_rerun_if_env_changed && v != "PATH" { + self.cargo_output + .print_metadata(&format_args!("cargo:rerun-if-env-changed={v}")); + } + #[allow(clippy::disallowed_methods)] // We emit rerun-if-env-changed above + let r = env::var_os(v); + self.cargo_output.print_metadata(&format_args!( + "{} = {}", + v, + OptionOsStrDisplay(r.as_deref()) + )); + r + } + + /// Look up an environment variable that's allowed to be overwritten by + /// [`Build::env`]. + /// + /// This is useful for environment variables that the compiler could + /// reasonably read, such as `SDKROOT` and `WASI_SDK_PATH` - for these, we + /// generally want to allow build scripts to overwrite them. + /// + /// On the other hand, we don't want to allow overwriting environment + /// variables that are `CC`-specific such as `CC_FORCE_DISABLE` + /// (`Build::env` applies to child processes, not to `cc` itself). + fn get_env_overridable(&self, key: &str) -> Option> { + // Try to look up in overrides first. + if let Some((_key, val)) = self.env.iter().find(|(k, _)| k.as_ref() == key) { + return Some(Cow::Borrowed(&**val)); + } + + // If not found in overrides, look up from environment. + self.get_env(key).map(Cow::Owned) + } + + /// Get boolean flag that is either true or false. + /// + /// Used for `CC_*`-style flags. + fn get_env_boolean(&self, key: &str) -> bool { + match self.get_env(key) { + // Set -> `true`, unless set to `""`, `"0"`, `"no"` `"false"` + Some(s) => &*s != "0" && &*s != "false" && &*s != "no" && !s.is_empty(), + // Not set -> default to `false`. + None => false, + } + } + + /// The list of environment variables to check for a given env, in order of priority. + fn target_envs(&self, env: &str) -> Result<[String; 4], Error> { + let target = self.get_raw_target()?; + let kind = if self.get_is_cross_compile()? { + "TARGET" + } else { + "HOST" + }; + let target_u = target.replace(['-', '.'], "_"); + + Ok([ + format!("{env}_{target}"), + format!("{env}_{target_u}"), + format!("{kind}_{env}"), + env.to_string(), + ]) + } + + /// Get a single-valued environment variable with target variants. + fn getenv_with_target_prefixes(&self, env: &str) -> Result { + // Take from first environment variable in the environment. + let res = self + .target_envs(env)? + .iter() + .filter_map(|env| self.get_env(env)) + .next(); + + match res { + Some(res) => Ok(res), + None => Err(Error::new( + ErrorKind::EnvVarNotFound, + format!("could not find environment variable {env}"), + )), + } + } + + /// Get values from CFLAGS-style environment variable. + fn envflags(&self, env: &str) -> Result>, Error> { + // Collect from all environment variables, in reverse order as in + // `getenv_with_target_prefixes` precedence (so that `CFLAGS_$TARGET` + // can override flags in `TARGET_CFLAGS`, which overrides those in + // `CFLAGS`). + let mut any_set = false; + let mut res = vec![]; + for env in self.target_envs(env)?.iter().rev() { + if let Some(var) = self.get_env(env) { + any_set = true; + + let var = var.to_string_lossy(); + if self.get_shell_escaped_flags() { + res.extend(Shlex::new(&var)); + } else { + res.extend(var.split_ascii_whitespace().map(ToString::to_string)); + } + } + } + + Ok(if any_set { Some(res) } else { None }) + } + + /// Returns true if `cc` has been disabled by `CC_FORCE_DISABLE`. + fn is_disabled(&self) -> bool { + self.get_env_boolean("CC_FORCE_DISABLE") + } + + fn fix_env_for_apple_os(&self, cmd: &mut Command) -> Result<(), Error> { + let target = self.get_target()?; + if cfg!(target_os = "macos") && target.os == "macos" { + // Additionally, `IPHONEOS_DEPLOYMENT_TARGET` must not be set when using the Xcode linker at + // "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld", + // although this is apparently ignored when using the linker at "/usr/bin/ld". + cmd.env_remove("IPHONEOS_DEPLOYMENT_TARGET"); + } + Ok(()) + } + + fn apple_sdk_root_inner(&self, sdk: &str) -> Result, Error> { + // Code copied from rustc's compiler/rustc_codegen_ssa/src/back/link.rs. + if let Some(sdkroot) = self.get_env_overridable("SDKROOT") { + let p = Path::new(&sdkroot); + let does_sdkroot_contain = |strings: &[&str]| { + let sdkroot_str = p.to_string_lossy(); + strings.iter().any(|s| sdkroot_str.contains(s)) + }; + match sdk { + // Ignore `SDKROOT` if it's clearly set for the wrong platform. + "appletvos" + if does_sdkroot_contain(&["TVSimulator.platform", "MacOSX.platform"]) => {} + "appletvsimulator" + if does_sdkroot_contain(&["TVOS.platform", "MacOSX.platform"]) => {} + "iphoneos" + if does_sdkroot_contain(&["iPhoneSimulator.platform", "MacOSX.platform"]) => {} + "iphonesimulator" + if does_sdkroot_contain(&["iPhoneOS.platform", "MacOSX.platform"]) => {} + "macosx10.15" + if does_sdkroot_contain(&["iPhoneOS.platform", "iPhoneSimulator.platform"]) => { + } + "watchos" + if does_sdkroot_contain(&["WatchSimulator.platform", "MacOSX.platform"]) => {} + "watchsimulator" + if does_sdkroot_contain(&["WatchOS.platform", "MacOSX.platform"]) => {} + "xros" if does_sdkroot_contain(&["XRSimulator.platform", "MacOSX.platform"]) => {} + "xrsimulator" if does_sdkroot_contain(&["XROS.platform", "MacOSX.platform"]) => {} + // Ignore `SDKROOT` if it's not a valid path. + _ if !p.is_absolute() || p == Path::new("/") || !p.exists() => {} + _ => return Ok(sdkroot), + } + } + + let sdk_path = run_output( + self.cmd("xcrun") + .arg("--show-sdk-path") + .arg("--sdk") + .arg(sdk), + &self.cargo_output, + )?; + + let sdk_path = match String::from_utf8(sdk_path) { + Ok(p) => p, + Err(_) => { + return Err(Error::new( + ErrorKind::IOError, + "Unable to determine Apple SDK path.", + )); + } + }; + Ok(Cow::Owned(sdk_path.trim().into())) + } + + fn apple_sdk_root(&self, target: &TargetInfo<'_>) -> Result, Error> { + let sdk = target.apple_sdk_name(); + + if let Some(ret) = self + .build_cache + .apple_sdk_root_cache + .read() + .expect("apple_sdk_root_cache lock failed") + .get(sdk) + .cloned() + { + return Ok(ret); + } + let sdk_path: Arc = self.apple_sdk_root_inner(sdk)?.into(); + self.build_cache + .apple_sdk_root_cache + .write() + .expect("apple_sdk_root_cache lock failed") + .insert(sdk.into(), sdk_path.clone()); + Ok(sdk_path) + } + + fn apple_deployment_target(&self, target: &TargetInfo<'_>) -> Arc { + let sdk = target.apple_sdk_name(); + if let Some(ret) = self + .build_cache + .apple_versions_cache + .read() + .expect("apple_versions_cache lock failed") + .get(sdk) + .cloned() + { + return ret; + } + + let default_deployment_from_sdk = || -> Option> { + let version = run_output( + self.cmd("xcrun") + .arg("--show-sdk-version") + .arg("--sdk") + .arg(sdk), + &self.cargo_output, + ) + .ok()?; + + Some(Arc::from(std::str::from_utf8(&version).ok()?.trim())) + }; + + let deployment_from_env = |name: &str| -> Option> { + self.get_env_overridable(name)?.to_str().map(Arc::from) + }; + + // Determines if the acquired deployment target is too low to support modern C++ on some Apple platform. + // + // A long time ago they used libstdc++, but since macOS 10.9 and iOS 7 libc++ has been the library the SDKs provide to link against. + // If a `cc`` config wants to use C++, we round up to these versions as the baseline. + let maybe_cpp_version_baseline = |deployment_target_ver: Arc| -> Option> { + if !self.cpp { + return Some(deployment_target_ver); + } + + let mut deployment_target = deployment_target_ver + .split('.') + .map(|v| v.parse::().expect("integer version")); + + match target.os { + "macos" => { + let major = deployment_target.next().unwrap_or(0); + let minor = deployment_target.next().unwrap_or(0); + + // If below 10.9, we ignore it and let the SDK's target definitions handle it. + if major == 10 && minor < 9 { + self.cargo_output.print_warning(&format_args!( + "macOS deployment target ({deployment_target_ver}) too low, it will be increased" + )); + return None; + } + } + "ios" => { + let major = deployment_target.next().unwrap_or(0); + + // If below 10.7, we ignore it and let the SDK's target definitions handle it. + if major < 7 { + self.cargo_output.print_warning(&format_args!( + "iOS deployment target ({deployment_target_ver}) too low, it will be increased" + )); + return None; + } + } + // watchOS, tvOS, visionOS, and others are all new enough that libc++ is their baseline. + _ => {} + } + + // If the deployment target met or exceeded the C++ baseline + Some(deployment_target_ver) + }; + + // The hardcoded minimums here are subject to change in a future compiler release, + // and only exist as last resort fallbacks. Don't consider them stable. + // `cc` doesn't use rustc's `--print deployment-target`` because the compiler's defaults + // don't align well with Apple's SDKs and other third-party libraries that require ~generally~ higher + // deployment targets. rustc isn't interested in those by default though so its fine to be different here. + // + // If no explicit target is passed, `cc` defaults to the current Xcode SDK's `DefaultDeploymentTarget` for better + // compatibility. This is also the crate's historical behavior and what has become a relied-on value. + // + // The ordering of env -> XCode SDK -> old rustc defaults is intentional for performance when using + // an explicit target. + let version: Arc = match target.os { + "macos" => deployment_from_env("MACOSX_DEPLOYMENT_TARGET") + .and_then(maybe_cpp_version_baseline) + .or_else(default_deployment_from_sdk) + .unwrap_or_else(|| { + if target.arch == "aarch64" { + "11.0".into() + } else { + let default: Arc = Arc::from("10.7"); + maybe_cpp_version_baseline(default.clone()).unwrap_or(default) + } + }), + + "ios" => deployment_from_env("IPHONEOS_DEPLOYMENT_TARGET") + .and_then(maybe_cpp_version_baseline) + .or_else(default_deployment_from_sdk) + .unwrap_or_else(|| "7.0".into()), + + "watchos" => deployment_from_env("WATCHOS_DEPLOYMENT_TARGET") + .or_else(default_deployment_from_sdk) + .unwrap_or_else(|| "5.0".into()), + + "tvos" => deployment_from_env("TVOS_DEPLOYMENT_TARGET") + .or_else(default_deployment_from_sdk) + .unwrap_or_else(|| "9.0".into()), + + "visionos" => deployment_from_env("XROS_DEPLOYMENT_TARGET") + .or_else(default_deployment_from_sdk) + .unwrap_or_else(|| "1.0".into()), + + os => unreachable!("unknown Apple OS: {}", os), + }; + + self.build_cache + .apple_versions_cache + .write() + .expect("apple_versions_cache lock failed") + .insert(sdk.into(), version.clone()); + + version + } + + fn wasm_musl_sysroot(&self) -> Result { + if let Some(musl_sysroot_path) = self.get_env("WASM_MUSL_SYSROOT") { + Ok(musl_sysroot_path) + } else { + Err(Error::new( + ErrorKind::EnvVarNotFound, + "Environment variable WASM_MUSL_SYSROOT not defined for wasm32. Download sysroot from GitHub & setup environment variable MUSL_SYSROOT targeting the folder.", + )) + } + } + + fn wasi_sysroot(&self) -> Result { + if let Some(wasi_sysroot_path) = self.get_env("WASI_SYSROOT") { + Ok(wasi_sysroot_path) + } else { + Err(Error::new( + ErrorKind::EnvVarNotFound, + "Environment variable WASI_SYSROOT not defined. Download sysroot from GitHub & setup environment variable WASI_SYSROOT targeting the folder.", + )) + } + } + + fn cuda_file_count(&self) -> usize { + self.files + .iter() + .filter(|file| file.extension() == Some(OsStr::new("cu"))) + .count() + } + + fn which(&self, tool: &Path, path_entries: Option<&OsStr>) -> Option { + // Loop through PATH entries searching for the |tool|. + let find_exe_in_path = |path_entries: &OsStr| -> Option { + env::split_paths(path_entries).find_map(|path_entry| check_exe(path_entry.join(tool))) + }; + + // If |tool| is not just one "word," assume it's an actual path... + if tool.components().count() > 1 { + check_exe(PathBuf::from(tool)) + } else { + path_entries + .and_then(find_exe_in_path) + .or_else(|| find_exe_in_path(&self.get_env("PATH")?)) + } + } + + /// search for |prog| on 'programs' path in '|cc| --print-search-dirs' output + fn search_programs( + &self, + cc: &Path, + prog: &Path, + cargo_output: &CargoOutput, + ) -> Option { + let search_dirs = run_output( + self.cmd(cc).arg("--print-search-dirs"), + // this doesn't concern the compilation so we always want to show warnings. + cargo_output, + ) + .ok()?; + // clang driver appears to be forcing UTF-8 output even on Windows, + // hence from_utf8 is assumed to be usable in all cases. + let search_dirs = std::str::from_utf8(&search_dirs).ok()?; + for dirs in search_dirs.split(['\r', '\n']) { + if let Some(path) = dirs.strip_prefix("programs: =") { + return self.which(prog, Some(OsStr::new(path))); + } + } + None + } + + fn find_msvc_tools_find(&self, target: &TargetInfo<'_>, tool: &str) -> Option { + self.find_msvc_tools_find_tool(target, tool) + .map(|c| c.to_command()) + } + + fn find_msvc_tools_find_tool(&self, target: &TargetInfo<'_>, tool: &str) -> Option { + struct BuildEnvGetter<'s>(&'s Build); + + impl ::find_msvc_tools::EnvGetter for BuildEnvGetter<'_> { + fn get_env(&self, name: &str) -> Option<::find_msvc_tools::Env> { + // TODO: Should we allow overriding these with `Build::env`? + // + self.0.get_env(name).map(::find_msvc_tools::Env::Owned) + } + } + + if target.env != "msvc" { + return None; + } + + ::find_msvc_tools::find_tool_with_env(target.full_arch, tool, &BuildEnvGetter(self)) + .map(Tool::from_find_msvc_tools) + } + + /// Compiling for WASI targets typically uses the [wasi-sdk] project and + /// installations of wasi-sdk are typically indicated with the + /// `WASI_SDK_PATH` environment variable. Check to see if that environment + /// variable exists, and check to see if an appropriate compiler is located + /// there. If that all passes then use that compiler by default, but + /// otherwise fall back to whatever the clang default is since gcc doesn't + /// have support for compiling to wasm. + /// + /// [wasi-sdk]: https://github.com/WebAssembly/wasi-sdk + fn autodetect_wasi_compiler(&self, raw_target: &str, clang: &str) -> PathBuf { + if let Some(path) = self.get_env_overridable("WASI_SDK_PATH") { + let target_clang = Path::new(&path) + .join("bin") + .join(format!("{raw_target}-clang")); + if let Some(path) = self.which(&target_clang, None) { + return path; + } + } + + clang.into() + } +} + +impl Default for Build { + fn default() -> Build { + Build::new() + } +} + +fn fail(s: &str) -> ! { + eprintln!("\n\nerror occurred in cc-rs: {s}\n\n"); + std::process::exit(1); +} + +// Use by default minimum available API level +// See note about naming here +// https://android.googlesource.com/platform/ndk/+/refs/heads/ndk-release-r21/docs/BuildSystemMaintainers.md#Clang +static NEW_STANDALONE_ANDROID_COMPILERS: [&str; 4] = [ + "aarch64-linux-android21-clang", + "armv7a-linux-androideabi16-clang", + "i686-linux-android16-clang", + "x86_64-linux-android21-clang", +]; + +// New "standalone" C/C++ cross-compiler executables from recent Android NDK +// are just shell scripts that call main clang binary (from Android NDK) with +// proper `--target` argument. +// +// For example, armv7a-linux-androideabi16-clang passes +// `--target=armv7a-linux-androideabi16` to clang. +// So to construct proper command line check if +// `--target` argument would be passed or not to clang +fn android_clang_compiler_uses_target_arg_internally(clang_path: &Path) -> bool { + if let Some(filename) = clang_path.file_name() { + if let Some(filename_str) = filename.to_str() { + if let Some(idx) = filename_str.rfind('-') { + return filename_str.split_at(idx).0.contains("android"); + } + } + } + false +} + +fn is_llvm_mingw_wrapper(clang_path: &Path) -> bool { + if let Some(filename) = clang_path + .file_name() + .and_then(|file_name| file_name.to_str()) + { + filename.ends_with("-w64-mingw32-clang") || filename.ends_with("-w64-mingw32-clang++") + } else { + false + } +} + +// FIXME: Use parsed target. +fn autodetect_android_compiler(raw_target: &str, gnu: &str, clang: &str) -> PathBuf { + let new_clang_key = match raw_target { + "aarch64-linux-android" => Some("aarch64"), + "armv7-linux-androideabi" => Some("armv7a"), + "i686-linux-android" => Some("i686"), + "x86_64-linux-android" => Some("x86_64"), + _ => None, + }; + + let new_clang = new_clang_key + .map(|key| { + NEW_STANDALONE_ANDROID_COMPILERS + .iter() + .find(|x| x.starts_with(key)) + }) + .unwrap_or(None); + + if let Some(new_clang) = new_clang { + if Command::new(new_clang).output().is_ok() { + return (*new_clang).into(); + } + } + + let target = raw_target + .replace("armv7neon", "arm") + .replace("armv7", "arm") + .replace("thumbv7neon", "arm") + .replace("thumbv7", "arm"); + let gnu_compiler = format!("{target}-{gnu}"); + let clang_compiler = format!("{target}-{clang}"); + + // On Windows, the Android clang compiler is provided as a `.cmd` file instead + // of a `.exe` file. `std::process::Command` won't run `.cmd` files unless the + // `.cmd` is explicitly appended to the command name, so we do that here. + let clang_compiler_cmd = format!("{target}-{clang}.cmd"); + + // Check if gnu compiler is present + // if not, use clang + if Command::new(&gnu_compiler).output().is_ok() { + gnu_compiler + } else if cfg!(windows) && Command::new(&clang_compiler_cmd).output().is_ok() { + clang_compiler_cmd + } else { + clang_compiler + } + .into() +} + +// Rust and clang/cc don't agree on how to name the target. +fn map_darwin_target_from_rust_to_compiler_architecture<'a>(target: &TargetInfo<'a>) -> &'a str { + match target.full_arch { + "aarch64" => "arm64", + "arm64_32" => "arm64_32", + "arm64e" => "arm64e", + "armv7k" => "armv7k", + "armv7s" => "armv7s", + "i386" => "i386", + "i686" => "i386", + "powerpc" => "ppc", + "powerpc64" => "ppc64", + "x86_64" => "x86_64", + "x86_64h" => "x86_64h", + arch => arch, + } +} + +fn is_arm(target: &TargetInfo<'_>) -> bool { + matches!(target.arch, "aarch64" | "arm64ec" | "arm") +} + +#[derive(Clone, Copy, PartialEq)] +enum AsmFileExt { + /// `.asm` files. On MSVC targets, we assume these should be passed to MASM + /// (`ml{,64}.exe`). + DotAsm, + /// `.s` or `.S` files, which do not have the special handling on MSVC targets. + DotS, +} + +impl AsmFileExt { + fn from_path(file: &Path) -> Option { + if let Some(ext) = file.extension() { + if let Some(ext) = ext.to_str() { + let ext = ext.to_lowercase(); + match &*ext { + "asm" => return Some(AsmFileExt::DotAsm), + "s" => return Some(AsmFileExt::DotS), + _ => return None, + } + } + } + None + } +} + +fn check_exe(mut exe: PathBuf) -> Option { + let exe_ext = std::env::consts::EXE_EXTENSION; + let check = exe.exists() || (!exe_ext.is_empty() && exe.set_extension(exe_ext) && exe.exists()); + check.then_some(exe) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_android_clang_compiler_uses_target_arg_internally() { + for version in 16..21 { + assert!(android_clang_compiler_uses_target_arg_internally( + &PathBuf::from(format!("armv7a-linux-androideabi{}-clang", version)) + )); + assert!(android_clang_compiler_uses_target_arg_internally( + &PathBuf::from(format!("armv7a-linux-androideabi{}-clang++", version)) + )); + } + assert!(!android_clang_compiler_uses_target_arg_internally( + &PathBuf::from("clang-i686-linux-android") + )); + assert!(!android_clang_compiler_uses_target_arg_internally( + &PathBuf::from("clang") + )); + assert!(!android_clang_compiler_uses_target_arg_internally( + &PathBuf::from("clang++") + )); + } +} diff --git a/http/vendor/cc/src/parallel/async_executor.rs b/http/vendor/cc/src/parallel/async_executor.rs new file mode 100644 index 0000000..9ebd1ad --- /dev/null +++ b/http/vendor/cc/src/parallel/async_executor.rs @@ -0,0 +1,118 @@ +use std::{ + cell::Cell, + future::Future, + pin::Pin, + ptr, + task::{Context, Poll, RawWaker, RawWakerVTable, Waker}, + thread, + time::Duration, +}; + +use crate::Error; + +const NOOP_WAKER_VTABLE: RawWakerVTable = RawWakerVTable::new( + // Cloning just returns a new no-op raw waker + |_| NOOP_RAW_WAKER, + // `wake` does nothing + |_| {}, + // `wake_by_ref` does nothing + |_| {}, + // Dropping does nothing as we don't allocate anything + |_| {}, +); +const NOOP_RAW_WAKER: RawWaker = RawWaker::new(ptr::null(), &NOOP_WAKER_VTABLE); + +#[derive(Default)] +pub(crate) struct YieldOnce(bool); + +impl Future for YieldOnce { + type Output = (); + + fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<()> { + let flag = &mut std::pin::Pin::into_inner(self).0; + if !*flag { + *flag = true; + Poll::Pending + } else { + Poll::Ready(()) + } + } +} + +/// Execute the futures and return when they are all done. +/// +/// Here we use our own homebrew async executor since cc is used in the build +/// script of many popular projects, pulling in additional dependencies would +/// significantly slow down its compilation. +pub(crate) fn block_on( + mut fut1: Fut1, + mut fut2: Fut2, + has_made_progress: &Cell, +) -> Result<(), Error> +where + Fut1: Future>, + Fut2: Future>, +{ + // Shadows the future so that it can never be moved and is guaranteed + // to be pinned. + // + // The same trick used in `pin!` macro. + // + // TODO: Once MSRV is bumped to 1.68, replace this with `std::pin::pin!` + let mut fut1 = Some(unsafe { Pin::new_unchecked(&mut fut1) }); + let mut fut2 = Some(unsafe { Pin::new_unchecked(&mut fut2) }); + + // TODO: Once `Waker::noop` stablised and our MSRV is bumped to the version + // which it is stablised, replace this with `Waker::noop`. + let waker = unsafe { Waker::from_raw(NOOP_RAW_WAKER) }; + let mut context = Context::from_waker(&waker); + + let mut backoff_cnt = 0; + + loop { + has_made_progress.set(false); + + if let Some(fut) = fut2.as_mut() { + if let Poll::Ready(res) = fut.as_mut().poll(&mut context) { + fut2 = None; + res?; + } + } + + if let Some(fut) = fut1.as_mut() { + if let Poll::Ready(res) = fut.as_mut().poll(&mut context) { + fut1 = None; + res?; + } + } + + if fut1.is_none() && fut2.is_none() { + return Ok(()); + } + + if !has_made_progress.get() { + if backoff_cnt > 3 { + // We have yielded at least three times without making' + // any progress, so we will sleep for a while. + let duration = Duration::from_millis(100 * (backoff_cnt - 3).min(10)); + thread::sleep(duration); + } else { + // Given that we spawned a lot of compilation tasks, it is unlikely + // that OS cannot find other ready task to execute. + // + // If all of them are done, then we will yield them and spawn more, + // or simply return. + // + // Thus this will not be turned into a busy-wait loop and it will not + // waste CPU resource. + thread::yield_now(); + } + } + + backoff_cnt = if has_made_progress.get() { + 0 + } else { + backoff_cnt + 1 + }; + } +} diff --git a/http/vendor/cc/src/parallel/command_runner.rs b/http/vendor/cc/src/parallel/command_runner.rs new file mode 100644 index 0000000..9393a98 --- /dev/null +++ b/http/vendor/cc/src/parallel/command_runner.rs @@ -0,0 +1,175 @@ +use std::{ + cell::Cell, + io::{self, Write as _}, + process::{Child, Command}, +}; + +use crate::{ + parallel::{ + async_executor::{block_on, YieldOnce}, + job_token, + }, + spawn, CargoOutput, Error, ErrorKind, StderrForwarder, +}; + +struct KillOnDrop(Child, StderrForwarder); + +impl Drop for KillOnDrop { + fn drop(&mut self) { + let child = &mut self.0; + + child.kill().ok(); + } +} + +fn cell_update(cell: &Cell, f: F) +where + T: Default, + F: FnOnce(T) -> T, +{ + let old = cell.take(); + let new = f(old); + cell.set(new); +} + +fn try_wait_on_child( + cmd: &Command, + child: &mut Child, + mut stdout: impl io::Write, + stderr_forwarder: &mut StderrForwarder, +) -> Result, Error> { + stderr_forwarder.forward_available(); + + match child.try_wait() { + Ok(Some(status)) => { + stderr_forwarder.forward_all(); + + let _ = writeln!(stdout, "{}", status); + + if status.success() { + Ok(Some(())) + } else { + Err(Error::new( + ErrorKind::ToolExecError, + format!("command did not execute successfully (status code {status}): {cmd:?}"), + )) + } + } + Ok(None) => Ok(None), + Err(e) => { + stderr_forwarder.forward_all(); + Err(Error::new( + ErrorKind::ToolExecError, + format!("failed to wait on spawned child process `{cmd:?}`: {e}"), + )) + } + } +} + +pub(crate) fn run_commands_in_parallel( + cargo_output: &CargoOutput, + cmds: &mut dyn Iterator>, +) -> Result<(), Error> { + // Limit our parallelism globally with a jobserver. + let mut tokens = job_token::ActiveJobTokenServer::new(); + + // When compiling objects in parallel we do a few dirty tricks to speed + // things up: + // + // * First is that we use the `jobserver` crate to limit the parallelism + // of this build script. The `jobserver` crate will use a jobserver + // configured by Cargo for build scripts to ensure that parallelism is + // coordinated across C compilations and Rust compilations. Before we + // compile anything we make sure to wait until we acquire a token. + // + // Note that this jobserver is cached globally so we only used one per + // process and only worry about creating it once. + // + // * Next we use spawn the process to actually compile objects in + // parallel after we've acquired a token to perform some work + // + // With all that in mind we compile all objects in a loop here, after we + // acquire the appropriate tokens, Once all objects have been compiled + // we wait on all the processes and propagate the results of compilation. + + let pendings = Cell::new(Vec::<(Command, KillOnDrop, job_token::JobToken)>::new()); + let is_disconnected = Cell::new(false); + let has_made_progress = Cell::new(false); + + let wait_future = async { + let mut error = None; + // Buffer the stdout + let mut stdout = io::BufWriter::with_capacity(128, io::stdout()); + + loop { + // If the other end of the pipe is already disconnected, then we're not gonna get any new jobs, + // so it doesn't make sense to reuse the tokens; in fact, + // releasing them as soon as possible (once we know that the other end is disconnected) is beneficial. + // Imagine that the last file built takes an hour to finish; in this scenario, + // by not releasing the tokens before that last file is done we would effectively block other processes from + // starting sooner - even though we only need one token for that last file, not N others that were acquired. + + let mut pendings_is_empty = false; + + cell_update(&pendings, |mut pendings| { + // Try waiting on them. + pendings.retain_mut(|(cmd, child, _token)| { + match try_wait_on_child(cmd, &mut child.0, &mut stdout, &mut child.1) { + Ok(Some(())) => { + // Task done, remove the entry + has_made_progress.set(true); + false + } + Ok(None) => true, // Task still not finished, keep the entry + Err(err) => { + // Task fail, remove the entry. + // Since we can only return one error, log the error to make + // sure users always see all the compilation failures. + has_made_progress.set(true); + + if cargo_output.warnings { + let _ = writeln!(stdout, "cargo:warning={}", err); + } + error = Some(err); + + false + } + } + }); + pendings_is_empty = pendings.is_empty(); + pendings + }); + + if pendings_is_empty && is_disconnected.get() { + break if let Some(err) = error { + Err(err) + } else { + Ok(()) + }; + } + + YieldOnce::default().await; + } + }; + let spawn_future = async { + for res in cmds { + let mut cmd = res?; + let token = tokens.acquire().await?; + let mut child = spawn(&mut cmd, cargo_output)?; + let mut stderr_forwarder = StderrForwarder::new(&mut child); + stderr_forwarder.set_non_blocking()?; + + cell_update(&pendings, |mut pendings| { + pendings.push((cmd, KillOnDrop(child, stderr_forwarder), token)); + pendings + }); + + has_made_progress.set(true); + } + is_disconnected.set(true); + + Ok::<_, Error>(()) + }; + + block_on(wait_future, spawn_future, &has_made_progress) +} diff --git a/http/vendor/cc/src/parallel/job_token.rs b/http/vendor/cc/src/parallel/job_token.rs new file mode 100644 index 0000000..fc35f9e --- /dev/null +++ b/http/vendor/cc/src/parallel/job_token.rs @@ -0,0 +1,262 @@ +use std::marker::PhantomData; + +use crate::{utilities::OnceLock, Error}; + +pub(crate) struct JobToken(PhantomData<()>); + +impl JobToken { + fn new() -> Self { + Self(PhantomData) + } +} + +impl Drop for JobToken { + fn drop(&mut self) { + match JobTokenServer::new() { + JobTokenServer::Inherited(jobserver) => jobserver.release_token_raw(), + JobTokenServer::InProcess(jobserver) => jobserver.release_token_raw(), + } + } +} + +enum JobTokenServer { + Inherited(inherited_jobserver::JobServer), + InProcess(inprocess_jobserver::JobServer), +} + +impl JobTokenServer { + /// This function returns a static reference to the jobserver because + /// - creating a jobserver from env is a bit fd-unsafe (e.g. the fd might + /// be closed by other jobserver users in the process) and better do it + /// at the start of the program. + /// - in case a jobserver cannot be created from env (e.g. it's not + /// present), we will create a global in-process only jobserver + /// that has to be static so that it will be shared by all cc + /// compilation. + fn new() -> &'static Self { + // TODO: Replace with a OnceLock once MSRV is 1.70 + static JOBSERVER: OnceLock = OnceLock::new(); + + JOBSERVER.get_or_init(|| { + unsafe { inherited_jobserver::JobServer::from_env() } + .map(Self::Inherited) + .unwrap_or_else(|| Self::InProcess(inprocess_jobserver::JobServer::new())) + }) + } +} + +pub(crate) enum ActiveJobTokenServer { + Inherited(inherited_jobserver::ActiveJobServer<'static>), + InProcess(&'static inprocess_jobserver::JobServer), +} + +impl ActiveJobTokenServer { + pub(crate) fn new() -> Self { + match JobTokenServer::new() { + JobTokenServer::Inherited(inherited_jobserver) => { + Self::Inherited(inherited_jobserver.enter_active()) + } + JobTokenServer::InProcess(inprocess_jobserver) => Self::InProcess(inprocess_jobserver), + } + } + + pub(crate) async fn acquire(&mut self) -> Result { + match self { + Self::Inherited(jobserver) => jobserver.acquire().await, + Self::InProcess(jobserver) => Ok(jobserver.acquire().await), + } + } +} + +mod inherited_jobserver { + use super::JobToken; + + use crate::{parallel::async_executor::YieldOnce, Error, ErrorKind}; + + use std::{ + io, mem, + sync::{mpsc, Mutex, MutexGuard, PoisonError}, + }; + + pub(super) struct JobServer { + /// Implicit token for this process which is obtained and will be + /// released in parent. Since `JobTokens` only give back what they got, + /// there should be at most one global implicit token in the wild. + /// + /// Since Rust does not execute any `Drop` for global variables, + /// we can't just put it back to jobserver and then re-acquire it at + /// the end of the process. + /// + /// Use `Mutex` to avoid race between acquire and release. + /// If an `AtomicBool` is used, then it's possible for: + /// - `release_token_raw`: Tries to set `global_implicit_token` to true, but it is already + /// set to `true`, continue to release it to jobserver + /// - `acquire` takes the global implicit token, set `global_implicit_token` to false + /// - `release_token_raw` now writes the token back into the jobserver, while + /// `global_implicit_token` is `false` + /// + /// If the program exits here, then cc effectively increases parallelism by one, which is + /// incorrect, hence we use a `Mutex` here. + global_implicit_token: Mutex, + inner: jobserver::Client, + } + + impl JobServer { + pub(super) unsafe fn from_env() -> Option { + jobserver::Client::from_env().map(|inner| Self { + inner, + global_implicit_token: Mutex::new(true), + }) + } + + fn get_global_implicit_token(&self) -> MutexGuard<'_, bool> { + self.global_implicit_token + .lock() + .unwrap_or_else(PoisonError::into_inner) + } + + /// All tokens except for the global implicit token will be put back into the jobserver + /// immediately and they cannot be cached, since Rust does not call `Drop::drop` on + /// global variables. + pub(super) fn release_token_raw(&self) { + let mut global_implicit_token = self.get_global_implicit_token(); + + if *global_implicit_token { + // There's already a global implicit token, so this token must + // be released back into jobserver. + // + // `release_raw` should not block + let _ = self.inner.release_raw(); + } else { + *global_implicit_token = true; + } + } + + pub(super) fn enter_active(&self) -> ActiveJobServer<'_> { + ActiveJobServer { + jobserver: self, + helper_thread: None, + } + } + } + + struct HelperThread { + inner: jobserver::HelperThread, + /// When rx is dropped, all the token stored within it will be dropped. + rx: mpsc::Receiver>, + } + + impl HelperThread { + fn new(jobserver: &JobServer) -> Result { + let (tx, rx) = mpsc::channel(); + + Ok(Self { + rx, + inner: jobserver.inner.clone().into_helper_thread(move |res| { + let _ = tx.send(res); + })?, + }) + } + } + + pub(crate) struct ActiveJobServer<'a> { + jobserver: &'a JobServer, + helper_thread: Option, + } + + impl ActiveJobServer<'_> { + pub(super) async fn acquire(&mut self) -> Result { + let mut has_requested_token = false; + + loop { + // Fast path + if mem::replace(&mut *self.jobserver.get_global_implicit_token(), false) { + break Ok(JobToken::new()); + } + + match self.jobserver.inner.try_acquire() { + Ok(Some(acquired)) => { + acquired.drop_without_releasing(); + break Ok(JobToken::new()); + } + Ok(None) => YieldOnce::default().await, + Err(err) if err.kind() == io::ErrorKind::Unsupported => { + // Fallback to creating a help thread with blocking acquire + let helper_thread = if let Some(thread) = self.helper_thread.as_ref() { + thread + } else { + self.helper_thread + .insert(HelperThread::new(self.jobserver)?) + }; + + match helper_thread.rx.try_recv() { + Ok(res) => { + let acquired = res?; + acquired.drop_without_releasing(); + break Ok(JobToken::new()); + } + Err(mpsc::TryRecvError::Disconnected) => break Err(Error::new( + ErrorKind::JobserverHelpThreadError, + "jobserver help thread has returned before ActiveJobServer is dropped", + )), + Err(mpsc::TryRecvError::Empty) => { + if !has_requested_token { + helper_thread.inner.request_token(); + has_requested_token = true; + } + YieldOnce::default().await + } + } + } + Err(err) => break Err(err.into()), + } + } + } + } +} + +mod inprocess_jobserver { + use super::JobToken; + + use crate::{parallel::async_executor::YieldOnce, utilities::cargo_env_var_os}; + + use std::sync::atomic::{ + AtomicU32, + Ordering::{AcqRel, Acquire}, + }; + + pub(crate) struct JobServer(AtomicU32); + + impl JobServer { + pub(super) fn new() -> Self { + // Use `NUM_JOBS` if set (it's configured by Cargo) and otherwise + // just fall back to the number of cores on the local machine, or a reasonable + // default if that cannot be determined. + + let parallelism = cargo_env_var_os("NUM_JOBS") + .and_then(|j| j.to_str()?.parse::().ok()) + .or_else(|| Some(std::thread::available_parallelism().ok()?.get() as u32)) + .unwrap_or(4); + + Self(AtomicU32::new(parallelism)) + } + + pub(super) async fn acquire(&self) -> JobToken { + loop { + let res = self + .0 + .fetch_update(AcqRel, Acquire, |tokens| tokens.checked_sub(1)); + + if res.is_ok() { + break JobToken::new(); + } + + YieldOnce::default().await + } + } + + pub(super) fn release_token_raw(&self) { + self.0.fetch_add(1, AcqRel); + } + } +} diff --git a/http/vendor/cc/src/parallel/mod.rs b/http/vendor/cc/src/parallel/mod.rs new file mode 100644 index 0000000..09dfe12 --- /dev/null +++ b/http/vendor/cc/src/parallel/mod.rs @@ -0,0 +1,6 @@ +mod async_executor; +mod command_runner; +mod job_token; +pub(crate) mod stderr; + +pub(crate) use command_runner::run_commands_in_parallel; diff --git a/http/vendor/cc/src/parallel/stderr.rs b/http/vendor/cc/src/parallel/stderr.rs new file mode 100644 index 0000000..8533fec --- /dev/null +++ b/http/vendor/cc/src/parallel/stderr.rs @@ -0,0 +1,91 @@ +#![cfg_attr(target_family = "wasm", allow(unused))] +/// Helpers functions for [`ChildStderr`]. +use std::{convert::TryInto, process::ChildStderr}; + +use crate::{Error, ErrorKind}; + +#[cfg(all(not(unix), not(windows), not(target_family = "wasm")))] +compile_error!("Only unix and windows support non-blocking pipes! For other OSes, disable the parallel feature."); + +#[cfg(unix)] +fn get_flags(fd: std::os::unix::io::RawFd) -> Result { + let flags = unsafe { libc::fcntl(fd, libc::F_GETFL, 0) }; + if flags == -1 { + Err(Error::new( + ErrorKind::IOError, + format!( + "Failed to get flags for pipe {}: {}", + fd, + std::io::Error::last_os_error() + ), + )) + } else { + Ok(flags) + } +} + +#[cfg(unix)] +fn set_flags(fd: std::os::unix::io::RawFd, flags: std::os::raw::c_int) -> Result<(), Error> { + if unsafe { libc::fcntl(fd, libc::F_SETFL, flags) } == -1 { + Err(Error::new( + ErrorKind::IOError, + format!( + "Failed to set flags for pipe {}: {}", + fd, + std::io::Error::last_os_error() + ), + )) + } else { + Ok(()) + } +} + +#[cfg(unix)] +pub fn set_non_blocking(pipe: &impl std::os::unix::io::AsRawFd) -> Result<(), Error> { + // On Unix, switch the pipe to non-blocking mode. + // On Windows, we have a different way to be non-blocking. + let fd = pipe.as_raw_fd(); + + let flags = get_flags(fd)?; + set_flags(fd, flags | libc::O_NONBLOCK) +} + +pub fn bytes_available(stderr: &mut ChildStderr) -> Result { + let mut bytes_available = 0; + #[cfg(windows)] + { + use ::find_msvc_tools::windows_sys::PeekNamedPipe; + use std::os::windows::io::AsRawHandle; + use std::ptr::null_mut; + if unsafe { + PeekNamedPipe( + stderr.as_raw_handle(), + null_mut(), + 0, + null_mut(), + &mut bytes_available, + null_mut(), + ) + } == 0 + { + return Err(Error::new( + ErrorKind::IOError, + format!( + "PeekNamedPipe failed with {}", + std::io::Error::last_os_error() + ), + )); + } + } + #[cfg(unix)] + { + use std::os::unix::io::AsRawFd; + if unsafe { libc::ioctl(stderr.as_raw_fd(), libc::FIONREAD, &mut bytes_available) } != 0 { + return Err(Error::new( + ErrorKind::IOError, + format!("ioctl failed with {}", std::io::Error::last_os_error()), + )); + } + } + Ok(bytes_available.try_into().unwrap()) +} diff --git a/http/vendor/cc/src/target.rs b/http/vendor/cc/src/target.rs new file mode 100644 index 0000000..ed432df --- /dev/null +++ b/http/vendor/cc/src/target.rs @@ -0,0 +1,41 @@ +//! Parsing of `rustc` target names to match the values exposed to Cargo +//! build scripts (`CARGO_CFG_*`). + +mod apple; +mod generated; +mod llvm; +mod parser; + +pub(crate) use parser::TargetInfoParser; + +/// Information specific to a `rustc` target. +/// +/// See . +#[derive(Debug, PartialEq, Clone)] +pub(crate) struct TargetInfo<'a> { + /// The full architecture, including the subarchitecture. + /// + /// This differs from `cfg!(target_arch)`, which only specifies the + /// overall architecture, which is too coarse for certain cases. + pub full_arch: &'a str, + /// The overall target architecture. + /// + /// This is the same as the value of `cfg!(target_arch)`. + pub arch: &'a str, + /// The target vendor. + /// + /// This is the same as the value of `cfg!(target_vendor)`. + pub vendor: &'a str, + /// The operating system, or `none` on bare-metal targets. + /// + /// This is the same as the value of `cfg!(target_os)`. + pub os: &'a str, + /// The environment on top of the operating system. + /// + /// This is the same as the value of `cfg!(target_env)`. + pub env: &'a str, + /// The ABI on top of the operating system. + /// + /// This is the same as the value of `cfg!(target_abi)`. + pub abi: &'a str, +} diff --git a/http/vendor/cc/src/tempfile.rs b/http/vendor/cc/src/tempfile.rs new file mode 100644 index 0000000..310c91b --- /dev/null +++ b/http/vendor/cc/src/tempfile.rs @@ -0,0 +1,86 @@ +#![cfg_attr(target_family = "wasm", allow(unused))] + +use std::{ + collections::hash_map::RandomState, + fs::{remove_file, File, OpenOptions}, + hash::{BuildHasher, Hasher}, + io, os, + path::{Path, PathBuf}, +}; + +#[cfg(not(any(unix, target_family = "wasm", windows)))] +compile_error!("Your system is not supported since cc cannot create named tempfile"); + +fn rand() -> u64 { + RandomState::new().build_hasher().finish() +} + +fn tmpname(suffix: &str) -> String { + format!("{}{}", rand(), suffix) +} + +fn create_named(path: &Path) -> io::Result { + let mut open_options = OpenOptions::new(); + + open_options.read(true).write(true).create_new(true); + + #[cfg(all(unix, not(target_os = "wasi")))] + ::mode(&mut open_options, 0o600); + + #[cfg(windows)] + ::custom_flags( + &mut open_options, + ::find_msvc_tools::windows_sys::FILE_ATTRIBUTE_TEMPORARY, + ); + + open_options.open(path) +} + +pub(super) struct NamedTempfile { + path: PathBuf, + file: Option, +} + +impl NamedTempfile { + pub(super) fn new(base: &Path, suffix: &str) -> io::Result { + for _ in 0..10 { + let path = base.join(tmpname(suffix)); + match create_named(&path) { + Ok(file) => { + return Ok(Self { + file: Some(file), + path, + }) + } + Err(e) if e.kind() == io::ErrorKind::AlreadyExists => continue, + Err(e) => return Err(e), + }; + } + + Err(io::Error::new( + io::ErrorKind::AlreadyExists, + format!( + "too many temporary files exist in base `{}` with suffix `{}`", + base.display(), + suffix + ), + )) + } + + pub(super) fn path(&self) -> &Path { + &self.path + } + + pub(super) fn take_file(&mut self) -> Option { + self.file.take() + } +} + +impl Drop for NamedTempfile { + fn drop(&mut self) { + // On Windows you have to close all handle to it before + // removing the file. + self.file.take(); + let _ = remove_file(&self.path); + } +} diff --git a/http/vendor/cc/src/tool.rs b/http/vendor/cc/src/tool.rs new file mode 100644 index 0000000..14692a1 --- /dev/null +++ b/http/vendor/cc/src/tool.rs @@ -0,0 +1,595 @@ +use crate::{ + command_helpers::{run_output, spawn_and_wait_for_output, CargoOutput}, + run, + tempfile::NamedTempfile, + Error, ErrorKind, OutputKind, +}; +use std::{ + borrow::Cow, + collections::HashMap, + env, + ffi::{OsStr, OsString}, + io::Write, + path::{Path, PathBuf}, + process::{Command, Output, Stdio}, + sync::RwLock, +}; + +pub(crate) type CompilerFamilyLookupCache = HashMap]>, ToolFamily>; + +/// Configuration used to represent an invocation of a C compiler. +/// +/// This can be used to figure out what compiler is in use, what the arguments +/// to it are, and what the environment variables look like for the compiler. +/// This can be used to further configure other build systems (e.g. forward +/// along CC and/or CFLAGS) or the `to_command` method can be used to run the +/// compiler itself. +#[derive(Clone, Debug)] +#[allow(missing_docs)] +pub struct Tool { + pub(crate) path: PathBuf, + pub(crate) cc_wrapper_path: Option, + pub(crate) cc_wrapper_args: Vec, + pub(crate) args: Vec, + pub(crate) env: Vec<(OsString, OsString)>, + pub(crate) family: ToolFamily, + pub(crate) cuda: bool, + pub(crate) removed_args: Vec, + pub(crate) has_internal_target_arg: bool, +} + +impl Tool { + pub(crate) fn from_find_msvc_tools(tool: ::find_msvc_tools::Tool) -> Self { + let mut cc_tool = Self::with_family( + tool.path().into(), + ToolFamily::Msvc { + clang_cl: tool.is_clang_cl(), + }, + ); + + cc_tool.env = tool + .env() + .into_iter() + .map(|(k, v)| (k.clone(), v.clone())) + .collect(); + + cc_tool + } + + pub(crate) fn new( + path: PathBuf, + cached_compiler_family: &RwLock, + cargo_output: &CargoOutput, + out_dir: Option<&Path>, + ) -> Self { + Self::with_features( + path, + vec![], + false, + cached_compiler_family, + cargo_output, + out_dir, + ) + } + + pub(crate) fn with_args( + path: PathBuf, + args: Vec, + cached_compiler_family: &RwLock, + cargo_output: &CargoOutput, + out_dir: Option<&Path>, + ) -> Self { + Self::with_features( + path, + args, + false, + cached_compiler_family, + cargo_output, + out_dir, + ) + } + + /// Explicitly set the `ToolFamily`, skipping name-based detection. + pub(crate) fn with_family(path: PathBuf, family: ToolFamily) -> Self { + Self { + path, + cc_wrapper_path: None, + cc_wrapper_args: Vec::new(), + args: Vec::new(), + env: Vec::new(), + family, + cuda: false, + removed_args: Vec::new(), + has_internal_target_arg: false, + } + } + + pub(crate) fn with_features( + path: PathBuf, + args: Vec, + cuda: bool, + cached_compiler_family: &RwLock, + cargo_output: &CargoOutput, + out_dir: Option<&Path>, + ) -> Self { + fn is_zig_cc(path: &Path, cargo_output: &CargoOutput) -> bool { + run_output( + Command::new(path).arg("--version"), + // tool detection issues should always be shown as warnings + cargo_output, + ) + .map(|o| String::from_utf8_lossy(&o).contains("ziglang")) + .unwrap_or_default() + || { + match path.file_name().map(OsStr::to_string_lossy) { + Some(fname) => fname.contains("zig"), + _ => false, + } + } + } + + fn guess_family_from_stdout( + stdout: &str, + path: &Path, + args: &[String], + cargo_output: &CargoOutput, + ) -> Result { + cargo_output.print_debug(&stdout); + + // https://gitlab.kitware.com/cmake/cmake/-/blob/69a2eeb9dff5b60f2f1e5b425002a0fd45b7cadb/Modules/CMakeDetermineCompilerId.cmake#L267-271 + // stdin is set to null to ensure that the help output is never paginated. + let accepts_cl_style_flags = run( + Command::new(path).args(args).arg("-?").stdin(Stdio::null()), + &{ + // the errors are not errors! + let mut cargo_output = cargo_output.clone(); + cargo_output.warnings = cargo_output.debug; + cargo_output.output = OutputKind::Discard; + cargo_output + }, + ) + .is_ok(); + + let clang = stdout.contains(r#""clang""#); + let gcc = stdout.contains(r#""gcc""#); + let emscripten = stdout.contains(r#""emscripten""#); + let vxworks = stdout.contains(r#""VxWorks""#); + + match (clang, accepts_cl_style_flags, gcc, emscripten, vxworks) { + (clang_cl, true, _, false, false) => Ok(ToolFamily::Msvc { clang_cl }), + (true, _, _, _, false) | (_, _, _, true, false) => Ok(ToolFamily::Clang { + zig_cc: is_zig_cc(path, cargo_output), + }), + (false, false, true, _, false) | (_, _, _, _, true) => Ok(ToolFamily::Gnu), + (false, false, false, false, false) => { + cargo_output.print_warning(&"Compiler family detection failed since it does not define `__clang__`, `__GNUC__`, `__EMSCRIPTEN__` or `__VXWORKS__`, also does not accept cl style flag `-?`, fallback to treating it as GNU"); + Err(Error::new( + ErrorKind::ToolFamilyMacroNotFound, + "Expects macro `__clang__`, `__GNUC__` or `__EMSCRIPTEN__`, `__VXWORKS__` or accepts cl style flag `-?`, but found none", + )) + } + } + } + + fn detect_family_inner( + path: &Path, + args: &[String], + cargo_output: &CargoOutput, + out_dir: Option<&Path>, + ) -> Result { + let out_dir = out_dir + .map(Cow::Borrowed) + .unwrap_or_else(|| Cow::Owned(env::temp_dir())); + + // Ensure all the parent directories exist otherwise temp file creation + // will fail + std::fs::create_dir_all(&out_dir).map_err(|err| Error { + kind: ErrorKind::IOError, + message: format!("failed to create OUT_DIR '{}': {}", out_dir.display(), err) + .into(), + })?; + + let mut tmp = + NamedTempfile::new(&out_dir, "detect_compiler_family.c").map_err(|err| Error { + kind: ErrorKind::IOError, + message: format!( + "failed to create detect_compiler_family.c temp file in '{}': {}", + out_dir.display(), + err + ) + .into(), + })?; + let mut tmp_file = tmp.take_file().unwrap(); + tmp_file.write_all(include_bytes!("detect_compiler_family.c"))?; + // Close the file handle *now*, otherwise the compiler may fail to open it on Windows + // (#1082). The file stays on disk and its path remains valid until `tmp` is dropped. + tmp_file.flush()?; + tmp_file.sync_data()?; + drop(tmp_file); + + // When expanding the file, the compiler prints a lot of information to stderr + // that it is not an error, but related to expanding itself. + // + // cc would have to disable warning here to prevent generation of too many warnings. + let mut compiler_detect_output = cargo_output.clone(); + compiler_detect_output.warnings = compiler_detect_output.debug; + + let mut cmd = Command::new(path); + cmd.arg("-E").arg(tmp.path()); + + // The -Wslash-u-filename warning is normally part of stdout. + // But with clang-cl it can be part of stderr instead and exit with a + // non-zero exit code. + let mut captured_cargo_output = compiler_detect_output.clone(); + captured_cargo_output.warnings = true; + let Output { + status, + stdout, + stderr, + } = spawn_and_wait_for_output(&mut cmd, &captured_cargo_output)?; + + let stdout = if [&stdout, &stderr] + .iter() + .any(|o| String::from_utf8_lossy(o).contains("-Wslash-u-filename")) + { + run_output( + Command::new(path).arg("-E").arg("--").arg(tmp.path()), + &compiler_detect_output, + )? + } else { + if !status.success() { + return Err(Error::new( + ErrorKind::ToolExecError, + format!( + "command did not execute successfully (status code {status}): {cmd:?}" + ), + )); + } + + stdout + }; + + let stdout = String::from_utf8_lossy(&stdout); + guess_family_from_stdout(&stdout, path, args, cargo_output) + } + let detect_family = |path: &Path, args: &[String]| -> Result { + let cache_key = [path.as_os_str()] + .iter() + .cloned() + .chain(args.iter().map(OsStr::new)) + .map(Into::into) + .collect(); + if let Some(family) = cached_compiler_family.read().unwrap().get(&cache_key) { + return Ok(*family); + } + + let family = detect_family_inner(path, args, cargo_output, out_dir)?; + cached_compiler_family + .write() + .unwrap() + .insert(cache_key, family); + Ok(family) + }; + + let family = detect_family(&path, &args).unwrap_or_else(|e| { + cargo_output.print_warning(&format_args!( + "Compiler family detection failed due to error: {e}" + )); + match path.file_name().map(OsStr::to_string_lossy) { + Some(fname) if fname.contains("clang-cl") => ToolFamily::Msvc { clang_cl: true }, + Some(fname) if fname.ends_with("cl") || fname == "cl.exe" => { + ToolFamily::Msvc { clang_cl: false } + } + Some(fname) if fname.contains("clang") => { + let is_clang_cl = args + .iter() + .any(|a| a.strip_prefix("--driver-mode=") == Some("cl")); + if is_clang_cl { + ToolFamily::Msvc { clang_cl: true } + } else { + ToolFamily::Clang { + zig_cc: is_zig_cc(&path, cargo_output), + } + } + } + Some(fname) if fname.contains("zig") => ToolFamily::Clang { zig_cc: true }, + _ => ToolFamily::Gnu, + } + }); + + Tool { + path, + cc_wrapper_path: None, + cc_wrapper_args: Vec::new(), + args: Vec::new(), + env: Vec::new(), + family, + cuda, + removed_args: Vec::new(), + has_internal_target_arg: false, + } + } + + /// Add an argument to be stripped from the final command arguments. + pub(crate) fn remove_arg(&mut self, flag: OsString) { + self.removed_args.push(flag); + } + + /// Push an "exotic" flag to the end of the compiler's arguments list. + /// + /// Nvidia compiler accepts only the most common compiler flags like `-D`, + /// `-I`, `-c`, etc. Options meant specifically for the underlying + /// host C++ compiler have to be prefixed with `-Xcompiler`. + /// [Another possible future application for this function is passing + /// clang-specific flags to clang-cl, which otherwise accepts only + /// MSVC-specific options.] + pub(crate) fn push_cc_arg(&mut self, flag: OsString) { + if self.cuda { + self.args.push("-Xcompiler".into()); + } + self.args.push(flag); + } + + /// Checks if an argument or flag has already been specified or conflicts. + /// + /// Currently only checks optimization flags. + pub(crate) fn is_duplicate_opt_arg(&self, flag: &OsString) -> bool { + let flag = flag.to_str().unwrap(); + let mut chars = flag.chars(); + + // Only duplicate check compiler flags + if self.is_like_msvc() { + if chars.next() != Some('/') { + return false; + } + } else if (self.is_like_gnu() || self.is_like_clang()) && chars.next() != Some('-') { + return false; + } + + // Check for existing optimization flags (-O, /O) + if chars.next() == Some('O') { + return self + .args() + .iter() + .any(|a| a.to_str().unwrap_or("").chars().nth(1) == Some('O')); + } + + // TODO Check for existing -m..., -m...=..., /arch:... flags + false + } + + /// Don't push optimization arg if it conflicts with existing args. + pub(crate) fn push_opt_unless_duplicate(&mut self, flag: OsString) { + if self.is_duplicate_opt_arg(&flag) { + eprintln!("Info: Ignoring duplicate arg {:?}", &flag); + } else { + self.push_cc_arg(flag); + } + } + + /// Converts this compiler into a `Command` that's ready to be run. + /// + /// This is useful for when the compiler needs to be executed and the + /// command returned will already have the initial arguments and environment + /// variables configured. + pub fn to_command(&self) -> Command { + let mut cmd = match self.cc_wrapper_path { + Some(ref cc_wrapper_path) => { + let mut cmd = Command::new(cc_wrapper_path); + cmd.arg(&self.path); + cmd + } + None => Command::new(&self.path), + }; + cmd.args(&self.cc_wrapper_args); + + cmd.args(self.args.iter().filter(|a| !self.removed_args.contains(a))); + + for (k, v) in self.env.iter() { + cmd.env(k, v); + } + + cmd + } + + /// Returns the path for this compiler. + /// + /// Note that this may not be a path to a file on the filesystem, e.g. "cc", + /// but rather something which will be resolved when a process is spawned. + pub fn path(&self) -> &Path { + &self.path + } + + /// Returns the default set of arguments to the compiler needed to produce + /// executables for the target this compiler generates. + pub fn args(&self) -> &[OsString] { + &self.args + } + + /// Returns the set of environment variables needed for this compiler to + /// operate. + /// + /// This is typically only used for MSVC compilers currently. + pub fn env(&self) -> &[(OsString, OsString)] { + &self.env + } + + /// Returns the compiler command in format of CC environment variable. + /// Or empty string if CC env was not present + /// + /// This is typically used by configure script + pub fn cc_env(&self) -> OsString { + match self.cc_wrapper_path { + Some(ref cc_wrapper_path) => { + let mut cc_env = cc_wrapper_path.as_os_str().to_owned(); + cc_env.push(" "); + cc_env.push(self.path.to_path_buf().into_os_string()); + for arg in self.cc_wrapper_args.iter() { + cc_env.push(" "); + cc_env.push(arg); + } + cc_env + } + None => OsString::from(""), + } + } + + /// Returns the compiler flags in format of CFLAGS environment variable. + /// Important here - this will not be CFLAGS from env, its internal gcc's flags to use as CFLAGS + /// This is typically used by configure script + pub fn cflags_env(&self) -> OsString { + let mut flags = OsString::new(); + for (i, arg) in self.args.iter().enumerate() { + if i > 0 { + flags.push(" "); + } + flags.push(arg); + } + flags + } + + /// Whether the tool is GNU Compiler Collection-like. + pub fn is_like_gnu(&self) -> bool { + self.family == ToolFamily::Gnu + } + + /// Whether the tool is Clang-like. + pub fn is_like_clang(&self) -> bool { + matches!(self.family, ToolFamily::Clang { .. }) + } + + /// Whether the tool is AppleClang under .xctoolchain + #[cfg(target_vendor = "apple")] + pub(crate) fn is_xctoolchain_clang(&self) -> bool { + let path = self.path.to_string_lossy(); + path.contains(".xctoolchain/") + } + #[cfg(not(target_vendor = "apple"))] + pub(crate) fn is_xctoolchain_clang(&self) -> bool { + false + } + + /// Whether the tool is MSVC-like. + pub fn is_like_msvc(&self) -> bool { + matches!(self.family, ToolFamily::Msvc { .. }) + } + + /// Whether the tool is `clang-cl`-based MSVC-like. + pub fn is_like_clang_cl(&self) -> bool { + matches!(self.family, ToolFamily::Msvc { clang_cl: true }) + } + + /// Supports using `--` delimiter to separate arguments and path to source files. + pub(crate) fn supports_path_delimiter(&self) -> bool { + // homebrew clang and zig-cc does not support this while stock version does + matches!(self.family, ToolFamily::Msvc { clang_cl: true }) && !self.cuda + } +} + +/// Represents the family of tools this tool belongs to. +/// +/// Each family of tools differs in how and what arguments they accept. +/// +/// Detection of a family is done on best-effort basis and may not accurately reflect the tool. +#[derive(Copy, Clone, Debug, PartialEq)] +pub enum ToolFamily { + /// Tool is GNU Compiler Collection-like. + Gnu, + /// Tool is Clang-like. It differs from the GCC in a sense that it accepts superset of flags + /// and its cross-compilation approach is different. + Clang { zig_cc: bool }, + /// Tool is the MSVC cl.exe. + Msvc { clang_cl: bool }, +} + +impl ToolFamily { + /// What the flag to request debug info for this family of tools look like + pub(crate) fn add_debug_flags( + &self, + cmd: &mut Tool, + debug_opt: &str, + dwarf_version: Option, + ) { + match *self { + ToolFamily::Msvc { .. } => { + cmd.push_cc_arg("-Z7".into()); + } + ToolFamily::Gnu | ToolFamily::Clang { .. } => { + match debug_opt { + // From https://doc.rust-lang.org/cargo/reference/profiles.html#debug + "" | "0" | "false" | "none" => { + debug_assert!( + false, + "earlier check should have avoided calling add_debug_flags" + ); + } + + // line-directives-only is LLVM-specific; for GCC we have to treat it like "1" + "line-directives-only" if cmd.is_like_clang() => { + cmd.push_cc_arg("-gline-directives-only".into()); + } + // Clang has -gline-tables-only, but it's an alias for -g1 anyway. + // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-gline-tables-only + "1" | "limited" | "line-tables-only" | "line-directives-only" => { + cmd.push_cc_arg("-g1".into()); + } + "2" | "true" | "full" => { + cmd.push_cc_arg("-g".into()); + } + _ => { + // Err on the side of including too much info rather than too little. + cmd.push_cc_arg("-g".into()); + } + } + if let Some(v) = dwarf_version { + cmd.push_cc_arg(format!("-gdwarf-{v}").into()); + } + } + } + } + + /// What the flag to force frame pointers. + pub(crate) fn add_force_frame_pointer(&self, cmd: &mut Tool) { + match *self { + ToolFamily::Gnu | ToolFamily::Clang { .. } => { + cmd.push_cc_arg("-fno-omit-frame-pointer".into()); + } + _ => (), + } + } + + /// What the flags to enable all warnings + pub(crate) fn warnings_flags(&self) -> &'static str { + match *self { + ToolFamily::Msvc { .. } => "-W4", + ToolFamily::Gnu | ToolFamily::Clang { .. } => "-Wall", + } + } + + pub(crate) fn warnings_suppression_flags(&self) -> &'static str { + match *self { + ToolFamily::Msvc { .. } => "-W0", + ToolFamily::Gnu | ToolFamily::Clang { .. } => "-w", + } + } + + /// What the flags to enable extra warnings + pub(crate) fn extra_warnings_flags(&self) -> Option<&'static str> { + match *self { + ToolFamily::Msvc { .. } => None, + ToolFamily::Gnu | ToolFamily::Clang { .. } => Some("-Wextra"), + } + } + + /// What the flag to turn warning into errors + pub(crate) fn warnings_to_errors_flag(&self) -> &'static str { + match *self { + ToolFamily::Msvc { .. } => "-WX", + ToolFamily::Gnu | ToolFamily::Clang { .. } => "-Werror", + } + } + + pub(crate) fn verbose_stderr(&self) -> bool { + matches!(*self, ToolFamily::Clang { .. }) + } +} diff --git a/http/vendor/cc/src/utilities.rs b/http/vendor/cc/src/utilities.rs new file mode 100644 index 0000000..b66da63 --- /dev/null +++ b/http/vendor/cc/src/utilities.rs @@ -0,0 +1,160 @@ +use std::{ + cell::UnsafeCell, + ffi::{OsStr, OsString}, + fmt::{self, Write}, + marker::PhantomData, + mem::MaybeUninit, + panic::{RefUnwindSafe, UnwindSafe}, + path::Path, + sync::Once, +}; + +use crate::{Error, ErrorKind}; + +pub(super) struct JoinOsStrs<'a, T> { + pub(super) slice: &'a [T], + pub(super) delimiter: char, +} + +impl fmt::Display for JoinOsStrs<'_, T> +where + T: AsRef, +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let len = self.slice.len(); + for (index, os_str) in self.slice.iter().enumerate() { + // TODO: Use OsStr::display once it is stablised, + // Path and OsStr has the same `Display` impl + write!(f, "{}", Path::new(os_str).display())?; + if index + 1 < len { + f.write_char(self.delimiter)?; + } + } + Ok(()) + } +} + +pub(super) struct OptionOsStrDisplay(pub(super) Option); + +impl fmt::Display for OptionOsStrDisplay +where + T: AsRef, +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + // TODO: Use OsStr::display once it is stablised + // Path and OsStr has the same `Display` impl + if let Some(os_str) = self.0.as_ref() { + write!(f, "Some({})", Path::new(os_str).display()) + } else { + f.write_str("None") + } + } +} + +pub(crate) struct OnceLock { + once: Once, + value: UnsafeCell>, + _marker: PhantomData, +} + +impl Default for OnceLock { + fn default() -> Self { + Self::new() + } +} + +impl OnceLock { + pub(crate) const fn new() -> Self { + Self { + once: Once::new(), + value: UnsafeCell::new(MaybeUninit::uninit()), + _marker: PhantomData, + } + } + + #[inline] + fn is_initialized(&self) -> bool { + self.once.is_completed() + } + + unsafe fn get_unchecked(&self) -> &T { + debug_assert!(self.is_initialized()); + #[allow(clippy::needless_borrow)] + #[allow(unused_unsafe)] + unsafe { + (&*self.value.get()).assume_init_ref() + } + } + + pub(crate) fn get_or_init(&self, f: impl FnOnce() -> T) -> &T { + self.once.call_once(|| { + unsafe { &mut *self.value.get() }.write(f()); + }); + unsafe { self.get_unchecked() } + } + + pub(crate) fn get(&self) -> Option<&T> { + if self.is_initialized() { + // Safe b/c checked is_initialized + Some(unsafe { self.get_unchecked() }) + } else { + None + } + } +} + +impl fmt::Debug for OnceLock { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let mut d = f.debug_tuple("OnceLock"); + match self.get() { + Some(v) => d.field(v), + None => d.field(&format_args!("")), + }; + d.finish() + } +} + +unsafe impl Sync for OnceLock {} +unsafe impl Send for OnceLock {} + +impl RefUnwindSafe for OnceLock {} +impl UnwindSafe for OnceLock {} + +impl Drop for OnceLock { + #[inline] + fn drop(&mut self) { + if self.once.is_completed() { + // SAFETY: The cell is initialized and being dropped, so it can't + // be accessed again. + unsafe { self.value.get_mut().assume_init_drop() }; + } + } +} + +/// Access an environment variable that's set by Cargo. +/// +/// +/// +/// Cargo doesn't need to be told about these with `rerun-if-env-changed`, and +/// that we don't want to allow overwriting them with `Build::env`. +#[allow(clippy::disallowed_methods)] // Cargo env, no need for cache busting. +pub(crate) fn cargo_env_var_os(key: &str) -> Option { + std::env::var_os(key) +} + +pub(crate) fn cargo_env_var(key: &str) -> Result { + if let Some(value) = cargo_env_var_os(key) { + match value.into_string() { + Ok(value) => Ok(value), + Err(value) => Err(Error::new( + ErrorKind::EnvVarNotFound, + format!("environment variable {key} is not valid utf-8: {value:?}"), + )), + } + } else { + Err(Error::new( + ErrorKind::EnvVarNotFound, + format!("environment variable {key} not defined"), + )) + } +} diff --git a/http/vendor/cfg-if/.cargo-checksum.json b/http/vendor/cfg-if/.cargo-checksum.json new file mode 100644 index 0000000..78d3f3f --- /dev/null +++ b/http/vendor/cfg-if/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{".cargo_vcs_info.json":"65840ba044457862e25b2d7d53f4a2de232adf933bd31aba8f2bd6a1f51a6881",".github/dependabot.yml":"828e3ecefdc555a5210a5bdffd5621ef3625ceb35c7fc91a0b4faef6f9921b75",".github/workflows/main.yaml":"6612a51b1f1479eabac7d3bd14aa609811d4afd2df2d454b9a1f6d6f3748f5b2",".github/workflows/publish.yaml":"1417805078704eecbaeea8611c5a44df575bfe1908d6969d909224a6e5e26ca8","CHANGELOG.md":"08ba7340057565b338afaa29b36bd2a1c46f5495b043bc49d12230a6a82d5f76","Cargo.lock":"26922b9384045e5a3d496f21ec7c355da585d0caa1d13b887b634527d36fc450","Cargo.toml":"281d508beb1fe3927cf03d3f2f8c9a5117b1e4fe97ae21b9026cf318e8c35273","Cargo.toml.orig":"5a17ee17da78f5179373b8324a1180e71efe2bcf3e3c9ca18c1bdb1e3faa9792","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"cd565d563a2c70d197bb6fee1678e122214e22af7bdb046b80f52c1d953cd72f","src/lib.rs":"c09723e0890d15810374009e96b20bf0eb2f65f383006516f34db36240835c85","tests/xcrate.rs":"bcec148e69db81b1a618bdd6f96a25d9a0442e6ecc692fe28f1206d9bffc006a"},"package":"9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"} \ No newline at end of file diff --git a/http/vendor/cfg-if/.cargo_vcs_info.json b/http/vendor/cfg-if/.cargo_vcs_info.json new file mode 100644 index 0000000..d4bec31 --- /dev/null +++ b/http/vendor/cfg-if/.cargo_vcs_info.json @@ -0,0 +1,6 @@ +{ + "git": { + "sha1": "3510ca6abea34cbbc702509a4e50ea9709925eda" + }, + "path_in_vcs": "" +} \ No newline at end of file diff --git a/http/vendor/cfg-if/.github/dependabot.yml b/http/vendor/cfg-if/.github/dependabot.yml new file mode 100644 index 0000000..36e4ff0 --- /dev/null +++ b/http/vendor/cfg-if/.github/dependabot.yml @@ -0,0 +1,14 @@ +version: 2 +updates: + - package-ecosystem: cargo + directory: "/" + schedule: + interval: daily + time: "08:00" + open-pull-requests-limit: 10 + + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: weekly + open-pull-requests-limit: 3 diff --git a/http/vendor/cfg-if/.github/workflows/main.yaml b/http/vendor/cfg-if/.github/workflows/main.yaml new file mode 100644 index 0000000..7288a62 --- /dev/null +++ b/http/vendor/cfg-if/.github/workflows/main.yaml @@ -0,0 +1,48 @@ +name: CI +on: [push, pull_request] + +permissions: + contents: read + +env: + RUSTDOCFLAGS: -Dwarnings + RUSTFLAGS: -Dwarnings + +jobs: + test: + name: Test + runs-on: ubuntu-latest + strategy: + matrix: + rust: + - "1.32" # msrv + - stable + - beta + - nightly + steps: + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + - name: Install Rust ${{ matrix.rust }} + run: | + rustup self update + rustup update ${{ matrix.rust }} + rustup default ${{ matrix.rust }} + rustc -vV + - name: Run tests + run: | + set -eux + # Remove `-Dwarnings` at the MSRV since lints may be different + [ "${{ matrix.rust }}" = "1.32" ] && export RUSTFLAGS="--cfg msrv_test" + cargo test + + rustfmt: + name: Rustfmt + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + - name: Install Rust Stable + run: | + rustup update stable + rustup default stable + rustup component add rustfmt + - name: Run rustfmt + run: cargo fmt -- --check diff --git a/http/vendor/cfg-if/.github/workflows/publish.yaml b/http/vendor/cfg-if/.github/workflows/publish.yaml new file mode 100644 index 0000000..248e3cc --- /dev/null +++ b/http/vendor/cfg-if/.github/workflows/publish.yaml @@ -0,0 +1,25 @@ +name: Release-plz + +permissions: + pull-requests: write + contents: write + +on: + push: { branches: [main] } + +jobs: + release-plz: + name: Release-plz + runs-on: ubuntu-24.04 + steps: + - name: Checkout repository + uses: actions/checkout@v5 + with: + fetch-depth: 0 + - name: Install Rust (rustup) + run: rustup update nightly --no-self-update && rustup default nightly + - name: Run release-plz + uses: MarcoIeni/release-plz-action@v0.5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/http/vendor/cfg-if/CHANGELOG.md b/http/vendor/cfg-if/CHANGELOG.md new file mode 100644 index 0000000..55b54ec --- /dev/null +++ b/http/vendor/cfg-if/CHANGELOG.md @@ -0,0 +1,29 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [1.0.4](https://github.com/rust-lang/cfg-if/compare/v1.0.3...v1.0.4) - 2025-10-15 + +- Support `cfg(true)` and `cfg(false)` ([#99](https://github.com/rust-lang/cfg-if/pull/99)) +- Set and test a MSRV of 1.32 +- Have a single top-level rule + +## [1.0.3](https://github.com/rust-lang/cfg-if/compare/v1.0.2...v1.0.3) - 2025-08-19 + +- Revert "Remove `@__identity` rule." + +## [1.0.2](https://github.com/rust-lang/cfg-if/compare/v1.0.1...v1.0.2) - 2025-08-19 + +- Remove `@__identity` rule. + +## [1.0.1](https://github.com/rust-lang/cfg-if/compare/v1.0.0...v1.0.1) - 2025-06-09 + +- Remove `compiler-builtins` from `rustc-dep-of-std` dependencies +- Remove redundant configuration from Cargo.toml +- More readable formatting and identifier names. ([#39](https://github.com/rust-lang/cfg-if/pull/39)) +- Add expanded example to readme ([#38](https://github.com/rust-lang/cfg-if/pull/38)) diff --git a/http/vendor/cfg-if/Cargo.lock b/http/vendor/cfg-if/Cargo.lock new file mode 100644 index 0000000..5716679 --- /dev/null +++ b/http/vendor/cfg-if/Cargo.lock @@ -0,0 +1,16 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "cfg-if" +version = "1.0.4" +dependencies = [ + "rustc-std-workspace-core 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustc-std-workspace-core" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[metadata] +"checksum rustc-std-workspace-core 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa9c45b374136f52f2d6311062c7146bff20fec063c3f5d46a410bd937746955" diff --git a/http/vendor/cfg-if/Cargo.toml b/http/vendor/cfg-if/Cargo.toml new file mode 100644 index 0000000..450f7a2 --- /dev/null +++ b/http/vendor/cfg-if/Cargo.toml @@ -0,0 +1,47 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies. +# +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. + +[package] +edition = "2018" +rust-version = "1.32" +name = "cfg-if" +version = "1.0.4" +authors = ["Alex Crichton "] +build = false +autolib = false +autobins = false +autoexamples = false +autotests = false +autobenches = false +description = """ +A macro to ergonomically define an item depending on a large number of #[cfg] +parameters. Structured like an if-else chain, the first matching branch is the +item that gets emitted. +""" +readme = "README.md" +license = "MIT OR Apache-2.0" +repository = "https://github.com/rust-lang/cfg-if" + +[features] +rustc-dep-of-std = ["core"] + +[lib] +name = "cfg_if" +path = "src/lib.rs" + +[[test]] +name = "xcrate" +path = "tests/xcrate.rs" + +[dependencies.core] +version = "1.0.0" +optional = true +package = "rustc-std-workspace-core" diff --git a/http/vendor/cfg-if/Cargo.toml.orig b/http/vendor/cfg-if/Cargo.toml.orig new file mode 100644 index 0000000..6a98924 --- /dev/null +++ b/http/vendor/cfg-if/Cargo.toml.orig @@ -0,0 +1,20 @@ +[package] +name = "cfg-if" +version = "1.0.4" +authors = ["Alex Crichton "] +license = "MIT OR Apache-2.0" +readme = "README.md" +repository = "https://github.com/rust-lang/cfg-if" +description = """ +A macro to ergonomically define an item depending on a large number of #[cfg] +parameters. Structured like an if-else chain, the first matching branch is the +item that gets emitted. +""" +edition = "2018" +rust-version = "1.32" + +[dependencies] +core = { version = "1.0.0", optional = true, package = "rustc-std-workspace-core" } + +[features] +rustc-dep-of-std = ["core"] diff --git a/http/vendor/cfg-if/LICENSE-APACHE b/http/vendor/cfg-if/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/http/vendor/cfg-if/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/http/vendor/cfg-if/LICENSE-MIT b/http/vendor/cfg-if/LICENSE-MIT new file mode 100644 index 0000000..39e0ed6 --- /dev/null +++ b/http/vendor/cfg-if/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 Alex Crichton + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/http/vendor/cfg-if/README.md b/http/vendor/cfg-if/README.md new file mode 100644 index 0000000..d174b6e --- /dev/null +++ b/http/vendor/cfg-if/README.md @@ -0,0 +1,56 @@ +# cfg-if + +[Documentation](https://docs.rs/cfg-if) + +A macro to ergonomically define an item depending on a large number of #[cfg] +parameters. Structured like an if-else chain, the first matching branch is the +item that gets emitted. + +```toml +[dependencies] +cfg-if = "1.0" +``` + +## Example + +```rust +cfg_if::cfg_if! { + if #[cfg(unix)] { + fn foo() { /* unix specific functionality */ } + } else if #[cfg(target_pointer_width = "32")] { + fn foo() { /* non-unix, 32-bit functionality */ } + } else { + fn foo() { /* fallback implementation */ } + } +} + +fn main() { + foo(); +} +``` +The `cfg_if!` block above is expanded to: +```rust +#[cfg(unix)] +fn foo() { /* unix specific functionality */ } +#[cfg(all(target_pointer_width = "32", not(unix)))] +fn foo() { /* non-unix, 32-bit functionality */ } +#[cfg(not(any(unix, target_pointer_width = "32")))] +fn foo() { /* fallback implementation */ } +``` + +# License + +This project is licensed under either of + + * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or + https://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or + https://opensource.org/licenses/MIT) + +at your option. + +### Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in `cfg-if` by you, as defined in the Apache-2.0 license, shall be +dual licensed as above, without any additional terms or conditions. diff --git a/http/vendor/cfg-if/src/lib.rs b/http/vendor/cfg-if/src/lib.rs new file mode 100644 index 0000000..2c7414e --- /dev/null +++ b/http/vendor/cfg-if/src/lib.rs @@ -0,0 +1,212 @@ +//! A macro for defining `#[cfg]` if-else statements. +//! +//! The macro provided by this crate, `cfg_if`, is similar to the `if/elif` C +//! preprocessor macro by allowing definition of a cascade of `#[cfg]` cases, +//! emitting the implementation which matches first. +//! +//! This allows you to conveniently provide a long list `#[cfg]`'d blocks of code +//! without having to rewrite each clause multiple times. +//! +//! # Example +//! +//! ``` +//! cfg_if::cfg_if! { +//! if #[cfg(unix)] { +//! fn foo() { /* unix specific functionality */ } +//! } else if #[cfg(target_pointer_width = "32")] { +//! fn foo() { /* non-unix, 32-bit functionality */ } +//! } else { +//! fn foo() { /* fallback implementation */ } +//! } +//! } +//! +//! # fn main() {} +//! ``` + +#![no_std] +#![doc(html_root_url = "https://docs.rs/cfg-if")] +#![deny(missing_docs)] +#![cfg_attr(test, allow(unexpected_cfgs))] // we test with features that do not exist + +/// The main macro provided by this crate. See crate documentation for more +/// information. +#[macro_export] +macro_rules! cfg_if { + ( + if #[cfg( $($i_meta:tt)+ )] { $( $i_tokens:tt )* } + $( + else if #[cfg( $($ei_meta:tt)+ )] { $( $ei_tokens:tt )* } + )* + $( + else { $( $e_tokens:tt )* } + )? + ) => { + $crate::cfg_if! { + @__items () ; + (( $($i_meta)+ ) ( $( $i_tokens )* )), + $( + (( $($ei_meta)+ ) ( $( $ei_tokens )* )), + )* + $( + (() ( $( $e_tokens )* )), + )? + } + }; + + // Internal and recursive macro to emit all the items + // + // Collects all the previous cfgs in a list at the beginning, so they can be + // negated. After the semicolon are all the remaining items. + (@__items ( $( ($($_:tt)*) , )* ) ; ) => {}; + ( + @__items ( $( ($($no:tt)+) , )* ) ; + (( $( $($yes:tt)+ )? ) ( $( $tokens:tt )* )), + $( $rest:tt , )* + ) => { + // Emit all items within one block, applying an appropriate #[cfg]. The + // #[cfg] will require all `$yes` matchers specified and must also negate + // all previous matchers. + #[cfg(all( + $( $($yes)+ , )? + not(any( $( $($no)+ ),* )) + ))] + // Subtle: You might think we could put `$( $tokens )*` here. But if + // that contains multiple items then the `#[cfg(all(..))]` above would + // only apply to the first one. By wrapping `$( $tokens )*` in this + // macro call, we temporarily group the items into a single thing (the + // macro call) that will be included/excluded by the `#[cfg(all(..))]` + // as appropriate. If the `#[cfg(all(..))]` succeeds, the macro call + // will be included, and then evaluated, producing `$( $tokens )*`. See + // also the "issue #90" test below. + $crate::cfg_if! { @__temp_group $( $tokens )* } + + // Recurse to emit all other items in `$rest`, and when we do so add all + // our `$yes` matchers to the list of `$no` matchers as future emissions + // will have to negate everything we just matched as well. + $crate::cfg_if! { + @__items ( $( ($($no)+) , )* $( ($($yes)+) , )? ) ; + $( $rest , )* + } + }; + + // See the "Subtle" comment above. + (@__temp_group $( $tokens:tt )* ) => { + $( $tokens )* + }; +} + +#[cfg(test)] +mod tests { + cfg_if! { + if #[cfg(test)] { + use core::option::Option as Option2; + fn works1() -> Option2 { Some(1) } + } else { + fn works1() -> Option { None } + } + } + + cfg_if! { + if #[cfg(foo)] { + fn works2() -> bool { false } + } else if #[cfg(test)] { + fn works2() -> bool { true } + } else { + fn works2() -> bool { false } + } + } + + cfg_if! { + if #[cfg(foo)] { + fn works3() -> bool { false } + } else { + fn works3() -> bool { true } + } + } + + cfg_if! { + if #[cfg(test)] { + use core::option::Option as Option3; + fn works4() -> Option3 { Some(1) } + } + } + + cfg_if! { + if #[cfg(foo)] { + fn works5() -> bool { false } + } else if #[cfg(test)] { + fn works5() -> bool { true } + } + } + + // In issue #90 there was a bug that caused only the first item within a + // block to be annotated with the produced `#[cfg(...)]`. In this example, + // it meant that the first `type _B` wasn't being omitted as it should have + // been, which meant we had two `type _B`s, which caused an error. See also + // the "Subtle" comment above. + cfg_if!( + if #[cfg(target_os = "no-such-operating-system-good-sir!")] { + type _A = usize; + type _B = usize; + } else { + type _A = i32; + type _B = i32; + } + ); + + #[cfg(not(msrv_test))] + cfg_if! { + if #[cfg(false)] { + fn works6() -> bool { false } + } else if #[cfg(true)] { + fn works6() -> bool { true } + } else if #[cfg(false)] { + fn works6() -> bool { false } + } + } + + #[test] + fn it_works() { + assert!(works1().is_some()); + assert!(works2()); + assert!(works3()); + assert!(works4().is_some()); + assert!(works5()); + #[cfg(not(msrv_test))] + assert!(works6()); + } + + #[test] + #[allow(clippy::assertions_on_constants)] + fn test_usage_within_a_function() { + cfg_if! { + if #[cfg(debug_assertions)] { + // we want to put more than one thing here to make sure that they + // all get configured properly. + assert!(cfg!(debug_assertions)); + assert_eq!(4, 2 + 2); + } else { + assert!(works1().is_some()); + assert_eq!(10, 5 + 5); + } + } + } + + #[allow(dead_code)] + trait Trait { + fn blah(&self); + } + + #[allow(dead_code)] + struct Struct; + + impl Trait for Struct { + cfg_if! { + if #[cfg(feature = "blah")] { + fn blah(&self) { unimplemented!(); } + } else { + fn blah(&self) { unimplemented!(); } + } + } + } +} diff --git a/http/vendor/cfg-if/tests/xcrate.rs b/http/vendor/cfg-if/tests/xcrate.rs new file mode 100644 index 0000000..454e90f --- /dev/null +++ b/http/vendor/cfg-if/tests/xcrate.rs @@ -0,0 +1,16 @@ +#![allow(unexpected_cfgs)] // `foo` doesn't exist + +cfg_if::cfg_if! { + if #[cfg(foo)] { + fn works() -> bool { false } + } else if #[cfg(test)] { + fn works() -> bool { true } + } else { + fn works() -> bool { false } + } +} + +#[test] +fn smoke() { + assert!(works()); +} diff --git a/http/vendor/find-msvc-tools/.cargo-checksum.json b/http/vendor/find-msvc-tools/.cargo-checksum.json new file mode 100644 index 0000000..35d13a1 --- /dev/null +++ b/http/vendor/find-msvc-tools/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{".cargo_vcs_info.json":"a6a00e4fc7a085688fcd4550501bc164e55a5f6b84225a5a744d4124dd493e3d","CHANGELOG.md":"d8241689c2a2901c42c6c2284659915ed85e4c36216c1d5d771fa0be9c64a4a9","Cargo.lock":"ee3c45e2461f086b0122abd500f2c55bf9d05876ea6323b951578080cd158838","Cargo.toml":"1162710613011a622ba62b035b570cc13584516082f9cf579cfaf2f144a77a76","Cargo.toml.orig":"3941ba1194442678125b6ca4221a07ac27ac64f7dadd7467490e55e39cc205f9","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","README.md":"5e7b2b1f5ffc1da7695d3e151a2d4d0b8f681e65a24ddf85a353d4bcfa81967a","src/com.rs":"d71a248866e04a19c62221999f7f120890cb98bc74ea7fd0b714f766d3e0dd81","src/find_tools.rs":"4b97e6f518943d4754ac73c77bc5932025bd1b48d10ed310694ed7d7449ae256","src/lib.rs":"56b0350126ad84accee5fd3d160c6a04a32d17012013fc6f687caf4b59a76ce8","src/registry.rs":"ccbb665b60517a62d249dbe708675ea915c423c14bea786e17efee27453afd41","src/setup_config.rs":"5fee84b80d089ae4a92f10080b072ea2bb32c2edbcdc759cb9072e380404fc46","src/tool.rs":"83e805a8354278837c474c0907b8dd80c496ae4812b2f777f2b2e4266ba68032","src/vs_instances.rs":"10a4433ff6799b11dc01da568ba20af9153aa645d9dc4154cf1c0da15308577c","src/winapi.rs":"d486d80ebe222f3bf61bba50038cf63b258585325b29b89d149de8b5a489c2b5","src/windows_link.rs":"5b4648ebc22b028caca9f4b4bf8881fe2d094b7bec217264ba2e6e2c49d1ccee","src/windows_sys.rs":"c3c803c6408795eb3a2bb3feaf3dc83a8d3049d76f026a4d25d21162fdb890dd"},"package":"5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582"} \ No newline at end of file diff --git a/http/vendor/find-msvc-tools/.cargo_vcs_info.json b/http/vendor/find-msvc-tools/.cargo_vcs_info.json new file mode 100644 index 0000000..626ad41 --- /dev/null +++ b/http/vendor/find-msvc-tools/.cargo_vcs_info.json @@ -0,0 +1,6 @@ +{ + "git": { + "sha1": "0767349e1d1253e6849b4c2af2059db661f54343" + }, + "path_in_vcs": "find-msvc-tools" +} \ No newline at end of file diff --git a/http/vendor/find-msvc-tools/CHANGELOG.md b/http/vendor/find-msvc-tools/CHANGELOG.md new file mode 100644 index 0000000..27dcec9 --- /dev/null +++ b/http/vendor/find-msvc-tools/CHANGELOG.md @@ -0,0 +1,65 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [0.1.9](https://github.com/rust-lang/cc-rs/compare/find-msvc-tools-v0.1.8...find-msvc-tools-v0.1.9) - 2026-01-30 + +### Other + +- Add `find_windows_sdk` API ([#1663](https://github.com/rust-lang/cc-rs/pull/1663)) + +## [0.1.8](https://github.com/rust-lang/cc-rs/compare/find-msvc-tools-v0.1.7...find-msvc-tools-v0.1.8) - 2026-01-16 + +### Other + +- Regenerate windows sys bindings ([#1653](https://github.com/rust-lang/cc-rs/pull/1653)) + +## [0.1.7](https://github.com/rust-lang/cc-rs/compare/find-msvc-tools-v0.1.6...find-msvc-tools-v0.1.7) - 2026-01-09 + +### Other + +- Fix tool existence check in find_tool method ([#1645](https://github.com/rust-lang/cc-rs/pull/1645)) +- Fix SdkInfo::find_tool to check for executable extension ([#1644](https://github.com/rust-lang/cc-rs/pull/1644)) + +## [0.1.6](https://github.com/rust-lang/cc-rs/compare/find-msvc-tools-v0.1.5...find-msvc-tools-v0.1.6) - 2025-12-26 + +### Other + +- Update Readmes ([#1641](https://github.com/rust-lang/cc-rs/pull/1641)) + +## [0.1.5](https://github.com/rust-lang/cc-rs/compare/find-msvc-tools-v0.1.4...find-msvc-tools-v0.1.5) - 2025-11-14 + +### Other + +- Add Visual Studio 2026 support ([#1609](https://github.com/rust-lang/cc-rs/pull/1609)) + +## [0.1.4](https://github.com/rust-lang/cc-rs/compare/find-msvc-tools-v0.1.3...find-msvc-tools-v0.1.4) - 2025-10-10 + +### Other + +- Allow using VCToolsVersion to request a specific msvc version ([#1589](https://github.com/rust-lang/cc-rs/pull/1589)) +- Regenerate windows sys bindings ([#1591](https://github.com/rust-lang/cc-rs/pull/1591)) + +## [0.1.3](https://github.com/rust-lang/cc-rs/compare/find-msvc-tools-v0.1.2...find-msvc-tools-v0.1.3) - 2025-10-03 + +### Other + +- Regenerate windows sys bindings ([#1572](https://github.com/rust-lang/cc-rs/pull/1572)) + +## [0.1.2](https://github.com/rust-lang/cc-rs/compare/find-msvc-tools-v0.1.1...find-msvc-tools-v0.1.2) - 2025-09-19 + +### Other + +- [win] Search the Windows SDK for tools as well ([#1553](https://github.com/rust-lang/cc-rs/pull/1553)) + +## [0.1.1](https://github.com/rust-lang/cc-rs/compare/find-msvc-tools-v0.1.0...find-msvc-tools-v0.1.1) - 2025-09-05 + +### Other + +- Regenerate windows sys bindings ([#1548](https://github.com/rust-lang/cc-rs/pull/1548)) +- Add fn get_ucrt_dir for find-msvc-tools ([#1546](https://github.com/rust-lang/cc-rs/pull/1546)) diff --git a/http/vendor/find-msvc-tools/Cargo.lock b/http/vendor/find-msvc-tools/Cargo.lock new file mode 100644 index 0000000..b292c60 --- /dev/null +++ b/http/vendor/find-msvc-tools/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" diff --git a/http/vendor/find-msvc-tools/Cargo.toml b/http/vendor/find-msvc-tools/Cargo.toml new file mode 100644 index 0000000..34ddf30 --- /dev/null +++ b/http/vendor/find-msvc-tools/Cargo.toml @@ -0,0 +1,40 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies. +# +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. + +[package] +edition = "2018" +rust-version = "1.63" +name = "find-msvc-tools" +version = "0.1.9" +build = false +autolib = false +autobins = false +autoexamples = false +autotests = false +autobenches = false +description = "Find windows-specific tools, read MSVC versions from the registry and from COM interfaces" +documentation = "https://docs.rs/find-msvc-tools" +readme = "README.md" +keywords = ["build-dependencies"] +categories = ["development-tools::build-utils"] +license = "MIT OR Apache-2.0" +repository = "https://github.com/rust-lang/cc-rs" + +[lib] +name = "find_msvc_tools" +path = "src/lib.rs" + +[dependencies] + +[lints.rust.unexpected_cfgs] +level = "allow" +priority = 0 +check-cfg = ["cfg(disable_clang_cl_tests)"] diff --git a/http/vendor/find-msvc-tools/Cargo.toml.orig b/http/vendor/find-msvc-tools/Cargo.toml.orig new file mode 100644 index 0000000..0834c69 --- /dev/null +++ b/http/vendor/find-msvc-tools/Cargo.toml.orig @@ -0,0 +1,18 @@ +[package] +name = "find-msvc-tools" +version = "0.1.9" +edition = "2018" +license = "MIT OR Apache-2.0" +repository = "https://github.com/rust-lang/cc-rs" +documentation = "https://docs.rs/find-msvc-tools" +description = "Find windows-specific tools, read MSVC versions from the registry and from COM interfaces" +keywords = ["build-dependencies"] +categories = ["development-tools::build-utils"] +rust-version = "1.63" + + +[dependencies] + +[lints.rust] +unexpected_cfgs = { level = "allow", check-cfg = ['cfg(disable_clang_cl_tests)'] } + diff --git a/http/vendor/find-msvc-tools/LICENSE-APACHE b/http/vendor/find-msvc-tools/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/http/vendor/find-msvc-tools/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/http/vendor/find-msvc-tools/LICENSE-MIT b/http/vendor/find-msvc-tools/LICENSE-MIT new file mode 100644 index 0000000..39e0ed6 --- /dev/null +++ b/http/vendor/find-msvc-tools/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2014 Alex Crichton + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/http/vendor/find-msvc-tools/README.md b/http/vendor/find-msvc-tools/README.md new file mode 100644 index 0000000..84bcd75 --- /dev/null +++ b/http/vendor/find-msvc-tools/README.md @@ -0,0 +1,30 @@ +# find-msvc-tools + +> This crate is maintained by the library team, primarily for use by the `cc` +> crate and not intended for external use (except as a transitive dependency). +> This crate may make major changes to its APIs or be deprecated without +> warning. + +An internal use library for finding windows-specific tools, reading MSVC +versions from the registry and from COM interfaces. + +Refer to the [documentation](https://docs.rs/find-msvc-tools) for detailed usage +instructions. + +## License + +This project is licensed under either of + + * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or + https://www.apache.org/licenses/LICENSE-2.0) + * MIT license ([LICENSE-MIT](LICENSE-MIT) or + https://opensource.org/license/mit) + +at your option. + +### Contribution + +Unless you explicitly state otherwise, any contribution transitively +intentionally submitted for inclusion in find-msvc-tools by you, as defined in +the Apache-2.0 license, shall be dual licensed as above, without any additional +terms or conditions. \ No newline at end of file diff --git a/http/vendor/find-msvc-tools/src/com.rs b/http/vendor/find-msvc-tools/src/com.rs new file mode 100644 index 0000000..704d786 --- /dev/null +++ b/http/vendor/find-msvc-tools/src/com.rs @@ -0,0 +1,110 @@ +// Copyright © 2017 winapi-rs developers +// Licensed under the Apache License, Version 2.0 +// or the MIT license +// , at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. + +use crate::{ + winapi::{IUnknown, Interface}, + windows_sys::{ + CoInitializeEx, SysFreeString, SysStringLen, BSTR, COINIT_MULTITHREADED, HRESULT, S_FALSE, + S_OK, + }, +}; +use std::{ + convert::TryInto, + ffi::OsString, + ops::Deref, + os::windows::ffi::OsStringExt, + ptr::{null, null_mut}, + slice::from_raw_parts, +}; + +pub fn initialize() -> Result<(), HRESULT> { + let err = unsafe { CoInitializeEx(null(), COINIT_MULTITHREADED.try_into().unwrap()) }; + if err != S_OK && err != S_FALSE { + // S_FALSE just means COM is already initialized + Err(err) + } else { + Ok(()) + } +} + +pub struct ComPtr(*mut T) +where + T: Interface; +impl ComPtr +where + T: Interface, +{ + /// Creates a `ComPtr` to wrap a raw pointer. + /// It takes ownership over the pointer which means it does __not__ call `AddRef`. + /// `T` __must__ be a COM interface that inherits from `IUnknown`. + pub unsafe fn from_raw(ptr: *mut T) -> ComPtr { + assert!(!ptr.is_null()); + ComPtr(ptr) + } + /// For internal use only. + fn as_unknown(&self) -> &IUnknown { + unsafe { &*(self.0 as *mut IUnknown) } + } + /// Performs `QueryInterface` fun. + pub fn cast(&self) -> Result, i32> + where + U: Interface, + { + let mut obj = null_mut(); + let err = unsafe { self.as_unknown().QueryInterface(&U::uuidof(), &mut obj) }; + if err < 0 { + return Err(err); + } + Ok(unsafe { ComPtr::from_raw(obj as *mut U) }) + } +} +impl Deref for ComPtr +where + T: Interface, +{ + type Target = T; + fn deref(&self) -> &T { + unsafe { &*self.0 } + } +} +impl Clone for ComPtr +where + T: Interface, +{ + fn clone(&self) -> Self { + unsafe { + self.as_unknown().AddRef(); + ComPtr::from_raw(self.0) + } + } +} +impl Drop for ComPtr +where + T: Interface, +{ + fn drop(&mut self) { + unsafe { + self.as_unknown().Release(); + } + } +} +pub struct BStr(BSTR); +impl BStr { + pub unsafe fn from_raw(s: BSTR) -> BStr { + BStr(s) + } + pub fn to_osstring(&self) -> OsString { + let len = unsafe { SysStringLen(self.0) }; + let slice = unsafe { from_raw_parts(self.0, len as usize) }; + OsStringExt::from_wide(slice) + } +} +impl Drop for BStr { + fn drop(&mut self) { + unsafe { SysFreeString(self.0) }; + } +} diff --git a/http/vendor/find-msvc-tools/src/find_tools.rs b/http/vendor/find-msvc-tools/src/find_tools.rs new file mode 100644 index 0000000..0546bc9 --- /dev/null +++ b/http/vendor/find-msvc-tools/src/find_tools.rs @@ -0,0 +1,1606 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! An internal use crate to looking for windows-specific tools: +//! 1. On Windows host, probe the Windows Registry if needed; +//! 2. On non-Windows host, check specified environment variables. + +#![allow(clippy::upper_case_acronyms)] + +use std::{ + env, + ffi::{OsStr, OsString}, + ops::Deref, + path::{Path, PathBuf}, + process::Command, + sync::Arc, +}; + +use crate::Tool; + +/// The target provided by the user. +#[derive(Copy, Clone, PartialEq, Eq)] +enum TargetArch { + X86, + X64, + Arm, + Arm64, + Arm64ec, +} +impl TargetArch { + /// Parse the `TargetArch` from a str. Returns `None` if the arch is unrecognized. + fn new(arch: &str) -> Option { + // NOTE: Keep up to date with docs in [`find`]. + match arch { + "x64" | "x86_64" => Some(Self::X64), + "arm64" | "aarch64" => Some(Self::Arm64), + "arm64ec" => Some(Self::Arm64ec), + "x86" | "i686" | "i586" => Some(Self::X86), + "arm" | "thumbv7a" => Some(Self::Arm), + _ => None, + } + } + + #[cfg(windows)] + /// Gets the Visual Studio name for the architecture. + fn as_vs_arch(&self) -> &'static str { + match self { + Self::X64 => "x64", + Self::Arm64 | Self::Arm64ec => "arm64", + Self::X86 => "x86", + Self::Arm => "arm", + } + } +} + +#[derive(Debug, Clone)] +#[non_exhaustive] +pub enum Env { + Owned(OsString), + Arced(Arc), +} + +impl AsRef for Env { + fn as_ref(&self) -> &OsStr { + self.deref() + } +} + +impl Deref for Env { + type Target = OsStr; + + fn deref(&self) -> &Self::Target { + match self { + Env::Owned(os_str) => os_str, + Env::Arced(os_str) => os_str, + } + } +} + +impl From for PathBuf { + fn from(env: Env) -> Self { + match env { + Env::Owned(os_str) => PathBuf::from(os_str), + Env::Arced(os_str) => PathBuf::from(os_str.deref()), + } + } +} + +pub trait EnvGetter { + fn get_env(&self, name: &'static str) -> Option; +} + +struct StdEnvGetter; + +impl EnvGetter for StdEnvGetter { + #[allow(clippy::disallowed_methods)] + fn get_env(&self, name: &'static str) -> Option { + env::var_os(name).map(Env::Owned) + } +} + +/// Attempts to find a tool within an MSVC installation using the Windows +/// registry as a point to search from. +/// +/// The `arch_or_target` argument is the architecture or the Rust target name +/// that the tool should work for (e.g. compile or link for). The supported +/// architecture names are: +/// - `"x64"` or `"x86_64"` +/// - `"arm64"` or `"aarch64"` +/// - `"arm64ec"` +/// - `"x86"`, `"i586"` or `"i686"` +/// - `"arm"` or `"thumbv7a"` +/// +/// The `tool` argument is the tool to find. Supported tools include: +/// - MSVC tools: `cl.exe`, `link.exe`, `lib.exe`, etc. +/// - `MSBuild`: `msbuild.exe` +/// - Visual Studio IDE: `devenv.exe` +/// - Clang/LLVM tools: `clang.exe`, `clang++.exe`, `clang-*.exe`, `llvm-*.exe`, `lld.exe`, etc. +/// +/// This function will return `None` if the tool could not be found, or it will +/// return `Some(cmd)` which represents a command that's ready to execute the +/// tool with the appropriate environment variables set. +/// +/// To find MSVC tools, this function will first attempt to detect if we are +/// running in the context of a developer command prompt, and then use the tools +/// as found in the current `PATH`. If that fails, it will attempt to locate +/// the newest MSVC toolset in the newest installed version of Visual Studio. +/// To limit the search to a specific version of the MSVC toolset, set the +/// VCToolsVersion environment variable to the desired version (e.g. "14.44.35207"). +/// +/// Note that this function always returns `None` for non-MSVC targets (if a +/// full target name was specified). +pub fn find(arch_or_target: &str, tool: &str) -> Option { + find_tool(arch_or_target, tool).map(|c| c.to_command()) +} + +/// Similar to the `find` function above, this function will attempt the same +/// operation (finding a MSVC tool in a local install) but instead returns a +/// `Tool` which may be introspected. +pub fn find_tool(arch_or_target: &str, tool: &str) -> Option { + let full_arch = if let Some((full_arch, rest)) = arch_or_target.split_once("-") { + // The logic is all tailored for MSVC, if the target is not that then + // bail out early. + if !rest.contains("msvc") { + return None; + } + full_arch + } else { + arch_or_target + }; + find_tool_with_env(full_arch, tool, &StdEnvGetter) +} + +pub fn find_tool_with_env(full_arch: &str, tool: &str, env_getter: &dyn EnvGetter) -> Option { + // We only need the arch. + let target = TargetArch::new(full_arch)?; + + // Looks like msbuild isn't located in the same location as other tools like + // cl.exe and lib.exe. + if tool.contains("msbuild") { + return impl_::find_msbuild(target, env_getter); + } + + // Looks like devenv isn't located in the same location as other tools like + // cl.exe and lib.exe. + if tool.contains("devenv") { + return impl_::find_devenv(target, env_getter); + } + + // Clang/LLVM isn't located in the same location as other tools like + // cl.exe and lib.exe. + if ["clang", "lldb", "llvm", "ld", "lld"] + .iter() + .any(|&t| tool.contains(t)) + { + return impl_::find_llvm_tool(tool, target, env_getter); + } + + // Ok, if we're here, now comes the fun part of the probing. Default shells + // or shells like MSYS aren't really configured to execute `cl.exe` and the + // various compiler tools shipped as part of Visual Studio. Here we try to + // first find the relevant tool, then we also have to be sure to fill in + // environment variables like `LIB`, `INCLUDE`, and `PATH` to ensure that + // the tool is actually usable. + + impl_::find_msvc_environment(tool, target, env_getter) + .or_else(|| impl_::find_msvc_15plus(tool, target, env_getter)) + .or_else(|| impl_::find_msvc_14(tool, target, env_getter)) +} + +/// An SDK found by [`find_windows_sdk`] +#[derive(Default)] +pub struct Sdk { + libs: Vec, + path: Vec, + include: Vec, + version: String, +} + +impl Sdk { + /// Directories containing static libraries (e.g. `.lib` files). + pub fn libs(&self) -> impl Iterator { + self.libs.iter().map(PathBuf::as_path) + } + + /// Directories containing binaries (`.exe` and `.dll` files). + pub fn path(&self) -> impl Iterator { + self.path.iter().map(PathBuf::as_path) + } + + /// Directories containing source headers (e.g. `.h` files) + pub fn include(&self) -> impl Iterator { + self.include.iter().map(PathBuf::as_path) + } + + /// The Windows SDK version that was found. + pub fn sdk_version(&self) -> &str { + &self.version + } +} + +/// Find the directories of the latest installed Windows SDK. +/// +/// It's not necessary to call this if using [`find`] or [`find_tool`] as they will populate the relvant +/// environment variables with the SDK directories. +pub fn find_windows_sdk(full_arch: &str) -> Option { + let target = TargetArch::new(full_arch)?; + impl_::get_sdks(target, &StdEnvGetter) +} + +/// A version of Visual Studio +#[derive(Debug, PartialEq, Eq, Copy, Clone)] +#[non_exhaustive] +pub enum VsVers { + /// Visual Studio 12 (2013) + #[deprecated( + note = "Visual Studio 12 is no longer supported. cc will never return this value." + )] + Vs12, + /// Visual Studio 14 (2015) + Vs14, + /// Visual Studio 15 (2017) + Vs15, + /// Visual Studio 16 (2019) + Vs16, + /// Visual Studio 17 (2022) + Vs17, + /// Visual Studio 18 (2026) + Vs18, +} + +/// Find the most recent installed version of Visual Studio +/// +/// This is used by the cmake crate to figure out the correct +/// generator. +#[allow(clippy::disallowed_methods)] +pub fn find_vs_version() -> Result { + fn has_msbuild_version(version: &str) -> bool { + impl_::has_msbuild_version(version, &StdEnvGetter) + } + + match std::env::var("VisualStudioVersion") { + Ok(version) => match &version[..] { + "18.0" => Ok(VsVers::Vs18), + "17.0" => Ok(VsVers::Vs17), + "16.0" => Ok(VsVers::Vs16), + "15.0" => Ok(VsVers::Vs15), + "14.0" => Ok(VsVers::Vs14), + vers => Err(format!( + "\n\n\ + unsupported or unknown VisualStudio version: {vers}\n\ + if another version is installed consider running \ + the appropriate vcvars script before building this \ + crate\n\ + " + )), + }, + _ => { + // Check for the presence of a specific registry key + // that indicates visual studio is installed. + if has_msbuild_version("18.0") { + Ok(VsVers::Vs18) + } else if has_msbuild_version("17.0") { + Ok(VsVers::Vs17) + } else if has_msbuild_version("16.0") { + Ok(VsVers::Vs16) + } else if has_msbuild_version("15.0") { + Ok(VsVers::Vs15) + } else if has_msbuild_version("14.0") { + Ok(VsVers::Vs14) + } else { + Err("\n\n\ + couldn't determine visual studio generator\n\ + if VisualStudio is installed, however, consider \ + running the appropriate vcvars script before building \ + this crate\n\ + " + .to_string()) + } + } + } +} + +/// To find the Universal CRT we look in a specific registry key for where +/// all the Universal CRTs are located and then sort them asciibetically to +/// find the newest version. While this sort of sorting isn't ideal, it is +/// what vcvars does so that's good enough for us. +/// +/// Returns a pair of (root, version) for the ucrt dir if found +pub fn get_ucrt_dir() -> Option<(PathBuf, String)> { + impl_::get_ucrt_dir() +} + +/// Windows Implementation. +#[cfg(windows)] +mod impl_ { + use crate::com; + use crate::registry::{RegistryKey, LOCAL_MACHINE}; + use crate::setup_config::SetupConfiguration; + use crate::vs_instances::{VsInstances, VswhereInstance}; + use crate::windows_sys::{ + GetMachineTypeAttributes, GetProcAddress, LoadLibraryA, UserEnabled, HMODULE, + IMAGE_FILE_MACHINE_AMD64, MACHINE_ATTRIBUTES, S_OK, + }; + use std::convert::TryFrom; + use std::env; + use std::ffi::OsString; + use std::fs::File; + use std::io::Read; + use std::iter; + use std::mem; + use std::path::{Path, PathBuf}; + use std::process::Command; + use std::str::FromStr; + use std::sync::atomic::{AtomicBool, Ordering}; + use std::sync::Once; + + use super::{EnvGetter, Sdk, TargetArch}; + use crate::Tool; + + struct MsvcTool { + tool: PathBuf, + libs: Vec, + path: Vec, + include: Vec, + } + + struct LibraryHandle(HMODULE); + + impl LibraryHandle { + fn new(name: &[u8]) -> Option { + let handle = unsafe { LoadLibraryA(name.as_ptr() as _) }; + (!handle.is_null()).then_some(Self(handle)) + } + + /// Get a function pointer to a function in the library. + /// # SAFETY + /// + /// The caller must ensure that the function signature matches the actual function. + /// The easiest way to do this is to add an entry to `windows_sys_no_link.list` and use the + /// generated function for `func_signature`. + /// + /// The function returned cannot be used after the handle is dropped. + unsafe fn get_proc_address(&self, name: &[u8]) -> Option { + let symbol = GetProcAddress(self.0, name.as_ptr() as _); + symbol.map(|symbol| mem::transmute_copy(&symbol)) + } + } + + type GetMachineTypeAttributesFuncType = + unsafe extern "system" fn(u16, *mut MACHINE_ATTRIBUTES) -> i32; + const _: () = { + // Ensure that our hand-written signature matches the actual function signature. + // We can't use `GetMachineTypeAttributes` outside of a const scope otherwise we'll end up statically linking to + // it, which will fail to load on older versions of Windows. + let _: GetMachineTypeAttributesFuncType = GetMachineTypeAttributes; + }; + + fn is_amd64_emulation_supported_inner() -> Option { + // GetMachineTypeAttributes is only available on Win11 22000+, so dynamically load it. + let kernel32 = LibraryHandle::new(b"kernel32.dll\0")?; + // SAFETY: GetMachineTypeAttributesFuncType is checked to match the real function signature. + let get_machine_type_attributes = unsafe { + kernel32 + .get_proc_address::(b"GetMachineTypeAttributes\0") + }?; + let mut attributes = Default::default(); + if unsafe { get_machine_type_attributes(IMAGE_FILE_MACHINE_AMD64, &mut attributes) } == S_OK + { + Some((attributes & UserEnabled) != 0) + } else { + Some(false) + } + } + + fn is_amd64_emulation_supported() -> bool { + // TODO: Replace with a OnceLock once MSRV is 1.70. + static LOAD_VALUE: Once = Once::new(); + static IS_SUPPORTED: AtomicBool = AtomicBool::new(false); + + // Using Relaxed ordering since the Once is providing synchronization. + LOAD_VALUE.call_once(|| { + IS_SUPPORTED.store( + is_amd64_emulation_supported_inner().unwrap_or(false), + Ordering::Relaxed, + ); + }); + IS_SUPPORTED.load(Ordering::Relaxed) + } + + impl MsvcTool { + fn new(tool: PathBuf) -> MsvcTool { + MsvcTool { + tool, + libs: Vec::new(), + path: Vec::new(), + include: Vec::new(), + } + } + + fn add_sdk(&mut self, sdk_info: Sdk) { + self.libs.extend(sdk_info.libs); + self.path.extend(sdk_info.path); + self.include.extend(sdk_info.include); + } + + fn into_tool(self, env_getter: &dyn EnvGetter) -> Tool { + let MsvcTool { + tool, + libs, + path, + include, + } = self; + let mut tool = Tool { + tool, + is_clang_cl: false, + env: Vec::new(), + }; + add_env(&mut tool, "LIB", libs, env_getter); + add_env(&mut tool, "PATH", path, env_getter); + add_env(&mut tool, "INCLUDE", include, env_getter); + tool + } + } + + impl Sdk { + fn find_tool(&self, tool: &str) -> Option { + self.path.iter().map(|p| p.join(tool)).find_map(|mut p| { + (p.exists() || (p.set_extension(env::consts::EXE_SUFFIX) && p.exists())) + .then_some(p) + }) + } + } + + /// Checks to see if the target's arch matches the VS environment. Returns `None` if the + /// environment is unknown. + fn is_vscmd_target(target: TargetArch, env_getter: &dyn EnvGetter) -> Option { + is_vscmd_target_env(target, env_getter).or_else(|| is_vscmd_target_cl(target, env_getter)) + } + + /// Checks to see if the `VSCMD_ARG_TGT_ARCH` environment variable matches the + /// given target's arch. Returns `None` if the variable does not exist. + fn is_vscmd_target_env(target: TargetArch, env_getter: &dyn EnvGetter) -> Option { + let vscmd_arch = env_getter.get_env("VSCMD_ARG_TGT_ARCH")?; + Some(target.as_vs_arch() == vscmd_arch.as_ref()) + } + + /// Checks if the cl.exe target matches the given target's arch. Returns `None` if anything + /// fails. + fn is_vscmd_target_cl(target: TargetArch, env_getter: &dyn EnvGetter) -> Option { + let cmd_target = vscmd_target_cl(env_getter)?; + Some(target.as_vs_arch() == cmd_target) + } + + /// Detect the target architecture of `cl.exe` in the current path, and return `None` if this + /// fails for any reason. + fn vscmd_target_cl(env_getter: &dyn EnvGetter) -> Option<&'static str> { + let cl_exe = env_getter.get_env("PATH").and_then(|path| { + env::split_paths(&path) + .map(|p| p.join("cl.exe")) + .find(|p| p.exists()) + })?; + let mut cl = Command::new(cl_exe); + cl.stderr(std::process::Stdio::piped()) + .stdout(std::process::Stdio::null()); + + let out = cl.output().ok()?; + let cl_arch = out + .stderr + .split(|&b| b == b'\n' || b == b'\r') + .next()? + .rsplit(|&b| b == b' ') + .next()?; + + match cl_arch { + b"x64" => Some("x64"), + b"x86" => Some("x86"), + b"ARM64" => Some("arm64"), + b"ARM" => Some("arm"), + _ => None, + } + } + + /// Attempt to find the tool using environment variables set by vcvars. + pub(super) fn find_msvc_environment( + tool: &str, + target: TargetArch, + env_getter: &dyn EnvGetter, + ) -> Option { + // Early return if the environment isn't one that is known to have compiler toolsets in PATH + // `VCINSTALLDIR` is set from vcvarsall.bat (developer command prompt) + // `VSTEL_MSBuildProjectFullPath` is set by msbuild when invoking custom build steps + // NOTE: `VisualStudioDir` used to be used but this isn't set when invoking msbuild from the commandline + if env_getter.get_env("VCINSTALLDIR").is_none() + && env_getter.get_env("VSTEL_MSBuildProjectFullPath").is_none() + { + return None; + } + + // If the vscmd target differs from the requested target then + // attempt to get the tool using the VS install directory. + if is_vscmd_target(target, env_getter) == Some(false) { + // We will only get here with versions 15+. + let vs_install_dir: PathBuf = env_getter.get_env("VSINSTALLDIR")?.into(); + tool_from_vs15plus_instance(tool, target, &vs_install_dir, env_getter) + } else { + // Fallback to simply using the current environment. + env_getter + .get_env("PATH") + .and_then(|path| { + env::split_paths(&path) + .map(|p| p.join(tool)) + .find(|p| p.exists()) + }) + .map(|path| Tool { + tool: path, + is_clang_cl: false, + env: Vec::new(), + }) + } + } + + fn find_msbuild_vs18(target: TargetArch, env_getter: &dyn EnvGetter) -> Option { + find_tool_in_vs16plus_path(r"MSBuild\Current\Bin\MSBuild.exe", target, "18", env_getter) + } + + fn find_msbuild_vs17(target: TargetArch, env_getter: &dyn EnvGetter) -> Option { + find_tool_in_vs16plus_path(r"MSBuild\Current\Bin\MSBuild.exe", target, "17", env_getter) + } + + #[allow(bare_trait_objects)] + fn vs16plus_instances( + target: TargetArch, + version: &'static str, + env_getter: &dyn EnvGetter, + ) -> Box> { + let instances = if let Some(instances) = vs15plus_instances(target, env_getter) { + instances + } else { + return Box::new(iter::empty()); + }; + Box::new(instances.into_iter().filter_map(move |instance| { + let installation_name = instance.installation_name()?; + if installation_name.starts_with(&format!("VisualStudio/{}.", version)) + || installation_name.starts_with(&format!("VisualStudioPreview/{}.", version)) + { + Some(instance.installation_path()?) + } else { + None + } + })) + } + + fn find_tool_in_vs16plus_path( + tool: &str, + target: TargetArch, + version: &'static str, + env_getter: &dyn EnvGetter, + ) -> Option { + vs16plus_instances(target, version, env_getter) + .filter_map(|path| { + let path = path.join(tool); + if !path.is_file() { + return None; + } + let mut tool = Tool { + tool: path, + is_clang_cl: false, + env: Vec::new(), + }; + if target == TargetArch::X64 { + tool.env.push(("Platform".into(), "X64".into())); + } + if matches!(target, TargetArch::Arm64 | TargetArch::Arm64ec) { + tool.env.push(("Platform".into(), "ARM64".into())); + } + Some(tool) + }) + .next() + } + + fn find_msbuild_vs16(target: TargetArch, env_getter: &dyn EnvGetter) -> Option { + find_tool_in_vs16plus_path(r"MSBuild\Current\Bin\MSBuild.exe", target, "16", env_getter) + } + + pub(super) fn find_llvm_tool( + tool: &str, + target: TargetArch, + env_getter: &dyn EnvGetter, + ) -> Option { + find_llvm_tool_vs17plus(tool, target, env_getter, "18") + .or_else(|| find_llvm_tool_vs17plus(tool, target, env_getter, "17")) + } + + fn find_llvm_tool_vs17plus( + tool: &str, + target: TargetArch, + env_getter: &dyn EnvGetter, + version: &'static str, + ) -> Option { + vs16plus_instances(target, version, env_getter) + .filter_map(|mut base_path| { + base_path.push(r"VC\Tools\LLVM"); + let host_folder = match host_arch() { + // The default LLVM bin folder is x86, and there's separate subfolders + // for the x64 and ARM64 host tools. + X86 => "", + X86_64 => "x64", + AARCH64 => "ARM64", + _ => return None, + }; + if host_folder != "" { + // E.g. C:\...\VC\Tools\LLVM\x64 + base_path.push(host_folder); + } + // E.g. C:\...\VC\Tools\LLVM\x64\bin\clang.exe + base_path.push("bin"); + base_path.push(tool); + let is_clang_cl = tool.contains("clang-cl"); + base_path.is_file().then(|| Tool { + tool: base_path, + is_clang_cl, + env: Vec::new(), + }) + }) + .next() + } + + // In MSVC 15 (2017) MS once again changed the scheme for locating + // the tooling. Now we must go through some COM interfaces, which + // is super fun for Rust. + // + // Note that much of this logic can be found [online] wrt paths, COM, etc. + // + // [online]: https://blogs.msdn.microsoft.com/vcblog/2017/03/06/finding-the-visual-c-compiler-tools-in-visual-studio-2017/ + // + // Returns MSVC 15+ instances (15, 16 right now), the order should be consider undefined. + // + // However, on ARM64 this method doesn't work because VS Installer fails to register COM component on ARM64. + // Hence, as the last resort we try to use vswhere.exe to list available instances. + fn vs15plus_instances(target: TargetArch, env_getter: &dyn EnvGetter) -> Option { + vs15plus_instances_using_com() + .or_else(|| vs15plus_instances_using_vswhere(target, env_getter)) + } + + fn vs15plus_instances_using_com() -> Option { + com::initialize().ok()?; + + let config = SetupConfiguration::new().ok()?; + let enum_setup_instances = config.enum_all_instances().ok()?; + + Some(VsInstances::ComBased(enum_setup_instances)) + } + + fn vs15plus_instances_using_vswhere( + target: TargetArch, + env_getter: &dyn EnvGetter, + ) -> Option { + let program_files_path = env_getter + .get_env("ProgramFiles(x86)") + .or_else(|| env_getter.get_env("ProgramFiles"))?; + + let program_files_path = Path::new(program_files_path.as_ref()); + + let vswhere_path = + program_files_path.join(r"Microsoft Visual Studio\Installer\vswhere.exe"); + + if !vswhere_path.exists() { + return None; + } + + let tools_arch = match target { + TargetArch::X86 | TargetArch::X64 => Some("x86.x64"), + TargetArch::Arm => Some("ARM"), + TargetArch::Arm64 | TargetArch::Arm64ec => Some("ARM64"), + }; + + let vswhere_output = Command::new(vswhere_path) + .args([ + "-latest", + "-products", + "*", + "-requires", + &format!("Microsoft.VisualStudio.Component.VC.Tools.{}", tools_arch?), + "-format", + "text", + "-nologo", + ]) + .stderr(std::process::Stdio::inherit()) + .output() + .ok()?; + + let vs_instances = + VsInstances::VswhereBased(VswhereInstance::try_from(&vswhere_output.stdout).ok()?); + + Some(vs_instances) + } + + // Inspired from official microsoft/vswhere ParseVersionString + // i.e. at most four u16 numbers separated by '.' + fn parse_version(version: &str) -> Option<[u16; 4]> { + let mut iter = version.split('.').map(u16::from_str).fuse(); + let mut get_next_number = move || match iter.next() { + Some(Ok(version_part)) => Some(version_part), + Some(Err(_)) => None, + None => Some(0), + }; + Some([ + get_next_number()?, + get_next_number()?, + get_next_number()?, + get_next_number()?, + ]) + } + + pub(super) fn find_msvc_15plus( + tool: &str, + target: TargetArch, + env_getter: &dyn EnvGetter, + ) -> Option { + let iter = vs15plus_instances(target, env_getter)?; + iter.into_iter() + .filter_map(|instance| { + let version = parse_version(&instance.installation_version()?)?; + let instance_path = instance.installation_path()?; + let tool = tool_from_vs15plus_instance(tool, target, &instance_path, env_getter)?; + Some((version, tool)) + }) + .max_by(|(a_version, _), (b_version, _)| a_version.cmp(b_version)) + .map(|(_version, tool)| tool) + } + + // While the paths to Visual Studio 2017's devenv and MSBuild could + // potentially be retrieved from the registry, finding them via + // SetupConfiguration has shown to be [more reliable], and is preferred + // according to Microsoft. To help head off potential regressions though, + // we keep the registry method as a fallback option. + // + // [more reliable]: https://github.com/rust-lang/cc-rs/pull/331 + fn find_tool_in_vs15_path( + tool: &str, + target: TargetArch, + env_getter: &dyn EnvGetter, + ) -> Option { + let mut path = match vs15plus_instances(target, env_getter) { + Some(instances) => instances + .into_iter() + .filter_map(|instance| instance.installation_path()) + .map(|path| path.join(tool)) + .find(|path| path.is_file()), + None => None, + }; + + if path.is_none() { + let key = r"SOFTWARE\WOW6432Node\Microsoft\VisualStudio\SxS\VS7"; + path = LOCAL_MACHINE + .open(key.as_ref()) + .ok() + .and_then(|key| key.query_str("15.0").ok()) + .map(|path| PathBuf::from(path).join(tool)) + .and_then(|path| if path.is_file() { Some(path) } else { None }); + } + + path.map(|path| { + let mut tool = Tool { + tool: path, + is_clang_cl: false, + env: Vec::new(), + }; + if target == TargetArch::X64 { + tool.env.push(("Platform".into(), "X64".into())); + } else if matches!(target, TargetArch::Arm64 | TargetArch::Arm64ec) { + tool.env.push(("Platform".into(), "ARM64".into())); + } + tool + }) + } + + fn tool_from_vs15plus_instance( + tool: &str, + target: TargetArch, + instance_path: &Path, + env_getter: &dyn EnvGetter, + ) -> Option { + let (root_path, bin_path, host_dylib_path, lib_path, alt_lib_path, include_path) = + vs15plus_vc_paths(target, instance_path, env_getter)?; + let sdk_info = get_sdks(target, env_getter)?; + let mut tool_path = bin_path.join(tool); + if !tool_path.exists() { + tool_path = sdk_info.find_tool(tool)?; + }; + + let mut tool = MsvcTool::new(tool_path); + tool.path.push(bin_path.clone()); + tool.path.push(host_dylib_path); + if let Some(alt_lib_path) = alt_lib_path { + tool.libs.push(alt_lib_path); + } + tool.libs.push(lib_path); + tool.include.push(include_path); + + if let Some((atl_lib_path, atl_include_path)) = atl_paths(target, &root_path) { + tool.libs.push(atl_lib_path); + tool.include.push(atl_include_path); + } + + tool.add_sdk(sdk_info); + + Some(tool.into_tool(env_getter)) + } + + fn vs15plus_vc_paths( + target_arch: TargetArch, + instance_path: &Path, + env_getter: &dyn EnvGetter, + ) -> Option<(PathBuf, PathBuf, PathBuf, PathBuf, Option, PathBuf)> { + let version = vs15plus_vc_read_version(instance_path, env_getter)?; + + let hosts = match host_arch() { + X86 => &["X86"], + X86_64 => &["X64"], + // Starting with VS 17.4, there is a natively hosted compiler on ARM64: + // https://devblogs.microsoft.com/visualstudio/arm64-visual-studio-is-officially-here/ + // On older versions of VS, we use x64 if running under emulation is supported, + // otherwise use x86. + AARCH64 => { + if is_amd64_emulation_supported() { + &["ARM64", "X64", "X86"][..] + } else { + &["ARM64", "X86"] + } + } + _ => return None, + }; + let target_dir = target_arch.as_vs_arch(); + // The directory layout here is MSVC/bin/Host$host/$target/ + let path = instance_path.join(r"VC\Tools\MSVC").join(version); + // We use the first available host architecture that can build for the target + let (host_path, host) = hosts.iter().find_map(|&x| { + let candidate = path.join("bin").join(format!("Host{}", x)); + if candidate.join(target_dir).exists() { + Some((candidate, x)) + } else { + None + } + })?; + // This is the path to the toolchain for a particular target, running + // on a given host + let bin_path = host_path.join(target_dir); + // But! we also need PATH to contain the target directory for the host + // architecture, because it contains dlls like mspdb140.dll compiled for + // the host architecture. + let host_dylib_path = host_path.join(host.to_lowercase()); + let lib_fragment = if use_spectre_mitigated_libs(env_getter) { + r"lib\spectre" + } else { + "lib" + }; + let lib_path = path.join(lib_fragment).join(target_dir); + let alt_lib_path = + (target_arch == TargetArch::Arm64ec).then(|| path.join(lib_fragment).join("arm64ec")); + let include_path = path.join("include"); + Some(( + path, + bin_path, + host_dylib_path, + lib_path, + alt_lib_path, + include_path, + )) + } + + fn vs15plus_vc_read_version(dir: &Path, env_getter: &dyn EnvGetter) -> Option { + if let Some(version) = env_getter.get_env("VCToolsVersion") { + // Restrict the search to a specific msvc version; if it doesn't exist then + // our caller will fail to find the tool for this instance and move on. + return version.to_str().map(ToString::to_string); + } + + // Try to open the default version file. + let mut version_path: PathBuf = + dir.join(r"VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt"); + let mut version_file = if let Ok(f) = File::open(&version_path) { + f + } else { + // If the default doesn't exist, search for other version files. + // These are in the form Microsoft.VCToolsVersion.v143.default.txt + // where `143` is any three decimal digit version number. + // This sorts versions by lexical order and selects the highest version. + let mut version_file = String::new(); + version_path.pop(); + for file in version_path.read_dir().ok()? { + let name = file.ok()?.file_name(); + let name = name.to_str()?; + if name.starts_with("Microsoft.VCToolsVersion.v") + && name.ends_with(".default.txt") + && name > &version_file + { + version_file.replace_range(.., name); + } + } + if version_file.is_empty() { + // If all else fails, manually search for bin directories. + let tools_dir: PathBuf = dir.join(r"VC\Tools\MSVC"); + return tools_dir + .read_dir() + .ok()? + .filter_map(|file| { + let file = file.ok()?; + let name = file.file_name().into_string().ok()?; + + file.path().join("bin").exists().then(|| { + let version = parse_version(&name); + (name, version) + }) + }) + .max_by(|(_, a), (_, b)| a.cmp(b)) + .map(|(version, _)| version); + } + version_path.push(version_file); + File::open(version_path).ok()? + }; + + // Get the version string from the file we found. + let mut version = String::new(); + version_file.read_to_string(&mut version).ok()?; + version.truncate(version.trim_end().len()); + Some(version) + } + + fn use_spectre_mitigated_libs(env_getter: &dyn EnvGetter) -> bool { + env_getter + .get_env("VSCMD_ARG_VCVARS_SPECTRE") + .map(|env| env.as_ref() == "spectre") + .unwrap_or_default() + } + + fn atl_paths(target: TargetArch, path: &Path) -> Option<(PathBuf, PathBuf)> { + let atl_path = path.join("atlmfc"); + let sub = target.as_vs_arch(); + if atl_path.exists() { + Some((atl_path.join("lib").join(sub), atl_path.join("include"))) + } else { + None + } + } + + // For MSVC 14 we need to find the Universal CRT as well as either + // the Windows 10 SDK or Windows 8.1 SDK. + pub(super) fn find_msvc_14( + tool: &str, + target: TargetArch, + env_getter: &dyn EnvGetter, + ) -> Option { + if env_getter.get_env("VCToolsVersion").is_some() { + // VCToolsVersion is not set/supported for MSVC 14 + return None; + } + + let vcdir = get_vc_dir("14.0")?; + let sdk_info = get_sdks(target, env_getter)?; + let mut tool = get_tool(tool, &vcdir, target, &sdk_info)?; + tool.add_sdk(sdk_info); + Some(tool.into_tool(env_getter)) + } + + pub(super) fn get_sdks(target: TargetArch, env_getter: &dyn EnvGetter) -> Option { + let sub = target.as_vs_arch(); + let (ucrt, ucrt_version) = get_ucrt_dir()?; + + let host = match host_arch() { + X86 => "x86", + X86_64 => "x64", + AARCH64 => "arm64", + _ => return None, + }; + + let mut info = Sdk::default(); + + info.path + .push(ucrt.join("bin").join(&ucrt_version).join(host)); + + let ucrt_include = ucrt.join("include").join(&ucrt_version); + info.include.push(ucrt_include.join("ucrt")); + + let ucrt_lib = ucrt.join("lib").join(&ucrt_version); + info.libs.push(ucrt_lib.join("ucrt").join(sub)); + + if let Some((sdk, version)) = get_sdk10_dir(env_getter) { + info.path.push(sdk.join("bin").join(host)); + let sdk_lib = sdk.join("lib").join(&version); + info.libs.push(sdk_lib.join("um").join(sub)); + let sdk_include = sdk.join("include").join(&version); + info.include.push(sdk_include.join("um")); + info.include.push(sdk_include.join("cppwinrt")); + info.include.push(sdk_include.join("winrt")); + info.include.push(sdk_include.join("shared")); + info.version = version; + } else if let Some(sdk) = get_sdk81_dir() { + info.path.push(sdk.join("bin").join(host)); + let sdk_lib = sdk.join("lib").join("winv6.3"); + info.libs.push(sdk_lib.join("um").join(sub)); + let sdk_include = sdk.join("include"); + info.include.push(sdk_include.join("um")); + info.include.push(sdk_include.join("winrt")); + info.include.push(sdk_include.join("shared")); + info.version = "8.1".into(); + } + + Some(info) + } + + fn add_env( + tool: &mut Tool, + env: &'static str, + paths: Vec, + env_getter: &dyn EnvGetter, + ) { + let prev = env_getter.get_env(env); + let prev = prev.as_ref().map(AsRef::as_ref).unwrap_or_default(); + let prev = env::split_paths(&prev); + let new = paths.into_iter().chain(prev); + tool.env + .push((env.to_string().into(), env::join_paths(new).unwrap())); + } + + // Given a possible MSVC installation directory, we look for the linker and + // then add the MSVC library path. + fn get_tool(tool: &str, path: &Path, target: TargetArch, sdk_info: &Sdk) -> Option { + bin_subdir(target) + .into_iter() + .map(|(sub, host)| { + ( + path.join("bin").join(sub).join(tool), + Some(path.join("bin").join(host)), + ) + }) + .filter(|(path, _)| path.is_file()) + .chain(iter::once_with(|| Some((sdk_info.find_tool(tool)?, None))).flatten()) + .map(|(tool_path, host)| { + let mut tool = MsvcTool::new(tool_path); + tool.path.extend(host); + let sub = vc_lib_subdir(target); + tool.libs.push(path.join("lib").join(sub)); + tool.include.push(path.join("include")); + let atlmfc_path = path.join("atlmfc"); + if atlmfc_path.exists() { + tool.libs.push(atlmfc_path.join("lib").join(sub)); + tool.include.push(atlmfc_path.join("include")); + } + tool + }) + .next() + } + + // To find MSVC we look in a specific registry key for the version we are + // trying to find. + fn get_vc_dir(ver: &str) -> Option { + let key = r"SOFTWARE\Microsoft\VisualStudio\SxS\VC7"; + let key = LOCAL_MACHINE.open(key.as_ref()).ok()?; + let path = key.query_str(ver).ok()?; + Some(path.into()) + } + + // To find the Universal CRT we look in a specific registry key for where + // all the Universal CRTs are located and then sort them asciibetically to + // find the newest version. While this sort of sorting isn't ideal, it is + // what vcvars does so that's good enough for us. + // + // Returns a pair of (root, version) for the ucrt dir if found + pub(super) fn get_ucrt_dir() -> Option<(PathBuf, String)> { + let key = r"SOFTWARE\Microsoft\Windows Kits\Installed Roots"; + let key = LOCAL_MACHINE.open(key.as_ref()).ok()?; + let root = key.query_str("KitsRoot10").ok()?; + let readdir = Path::new(&root).join("lib").read_dir().ok()?; + let max_libdir = readdir + .filter_map(|dir| dir.ok()) + .map(|dir| dir.path()) + .filter(|dir| { + dir.components() + .last() + .and_then(|c| c.as_os_str().to_str()) + .map(|c| c.starts_with("10.") && dir.join("ucrt").is_dir()) + .unwrap_or(false) + }) + .max()?; + let version = max_libdir.components().last().unwrap(); + let version = version.as_os_str().to_str().unwrap().to_string(); + Some((root.into(), version)) + } + + // Vcvars finds the correct version of the Windows 10 SDK by looking + // for the include `um\Windows.h` because sometimes a given version will + // only have UCRT bits without the rest of the SDK. Since we only care about + // libraries and not includes, we instead look for `um\x64\kernel32.lib`. + // Since the 32-bit and 64-bit libraries are always installed together we + // only need to bother checking x64, making this code a tiny bit simpler. + // Like we do for the Universal CRT, we sort the possibilities + // asciibetically to find the newest one as that is what vcvars does. + // Before doing that, we check the "WindowsSdkDir" and "WindowsSDKVersion" + // environment variables set by vcvars to use the environment sdk version + // if one is already configured. + fn get_sdk10_dir(env_getter: &dyn EnvGetter) -> Option<(PathBuf, String)> { + if let (Some(root), Some(version)) = ( + env_getter.get_env("WindowsSdkDir"), + env_getter + .get_env("WindowsSDKVersion") + .as_ref() + .and_then(|version| version.as_ref().to_str()), + ) { + return Some(( + PathBuf::from(root), + version.trim_end_matches('\\').to_string(), + )); + } + + let key = r"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0"; + let key = LOCAL_MACHINE.open(key.as_ref()).ok()?; + let root = key.query_str("InstallationFolder").ok()?; + let readdir = Path::new(&root).join("lib").read_dir().ok()?; + let mut dirs = readdir + .filter_map(|dir| dir.ok()) + .map(|dir| dir.path()) + .collect::>(); + dirs.sort(); + let dir = dirs + .into_iter() + .rev() + .find(|dir| dir.join("um").join("x64").join("kernel32.lib").is_file())?; + let version = dir.components().last().unwrap(); + let version = version.as_os_str().to_str().unwrap().to_string(); + Some((root.into(), version)) + } + + // Interestingly there are several subdirectories, `win7` `win8` and + // `winv6.3`. Vcvars seems to only care about `winv6.3` though, so the same + // applies to us. Note that if we were targeting kernel mode drivers + // instead of user mode applications, we would care. + fn get_sdk81_dir() -> Option { + let key = r"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.1"; + let key = LOCAL_MACHINE.open(key.as_ref()).ok()?; + let root = key.query_str("InstallationFolder").ok()?; + Some(root.into()) + } + + const PROCESSOR_ARCHITECTURE_INTEL: u16 = 0; + const PROCESSOR_ARCHITECTURE_AMD64: u16 = 9; + const PROCESSOR_ARCHITECTURE_ARM64: u16 = 12; + const X86: u16 = PROCESSOR_ARCHITECTURE_INTEL; + const X86_64: u16 = PROCESSOR_ARCHITECTURE_AMD64; + const AARCH64: u16 = PROCESSOR_ARCHITECTURE_ARM64; + + // When choosing the tool to use, we have to choose the one which matches + // the target architecture. Otherwise we end up in situations where someone + // on 32-bit Windows is trying to cross compile to 64-bit and it tries to + // invoke the native 64-bit compiler which won't work. + // + // For the return value of this function, the first member of the tuple is + // the folder of the tool we will be invoking, while the second member is + // the folder of the host toolchain for that tool which is essential when + // using a cross linker. We return a Vec since on x64 there are often two + // linkers that can target the architecture we desire. The 64-bit host + // linker is preferred, and hence first, due to 64-bit allowing it more + // address space to work with and potentially being faster. + fn bin_subdir(target: TargetArch) -> Vec<(&'static str, &'static str)> { + match (target, host_arch()) { + (TargetArch::X86, X86) => vec![("", "")], + (TargetArch::X86, X86_64) => vec![("amd64_x86", "amd64"), ("", "")], + (TargetArch::X64, X86) => vec![("x86_amd64", "")], + (TargetArch::X64, X86_64) => vec![("amd64", "amd64"), ("x86_amd64", "")], + (TargetArch::Arm, X86) => vec![("x86_arm", "")], + (TargetArch::Arm, X86_64) => vec![("amd64_arm", "amd64"), ("x86_arm", "")], + _ => vec![], + } + } + + // MSVC's x86 libraries are not in a subfolder + fn vc_lib_subdir(target: TargetArch) -> &'static str { + match target { + TargetArch::X86 => "", + TargetArch::X64 => "amd64", + TargetArch::Arm => "arm", + TargetArch::Arm64 | TargetArch::Arm64ec => "arm64", + } + } + + #[allow(bad_style)] + fn host_arch() -> u16 { + type DWORD = u32; + type WORD = u16; + type LPVOID = *mut u8; + type DWORD_PTR = usize; + + #[repr(C)] + struct SYSTEM_INFO { + wProcessorArchitecture: WORD, + _wReserved: WORD, + _dwPageSize: DWORD, + _lpMinimumApplicationAddress: LPVOID, + _lpMaximumApplicationAddress: LPVOID, + _dwActiveProcessorMask: DWORD_PTR, + _dwNumberOfProcessors: DWORD, + _dwProcessorType: DWORD, + _dwAllocationGranularity: DWORD, + _wProcessorLevel: WORD, + _wProcessorRevision: WORD, + } + + extern "system" { + fn GetNativeSystemInfo(lpSystemInfo: *mut SYSTEM_INFO); + } + + unsafe { + let mut info = mem::zeroed(); + GetNativeSystemInfo(&mut info); + info.wProcessorArchitecture + } + } + + #[cfg(test)] + mod tests { + use super::*; + use std::path::Path; + // Import the find function from the module level + use crate::find_tools::find; + + fn host_arch_to_string(host_arch_value: u16) -> &'static str { + match host_arch_value { + X86 => "x86", + X86_64 => "x64", + AARCH64 => "arm64", + _ => panic!("Unsupported host architecture: {}", host_arch_value), + } + } + + #[test] + fn test_find_cl_exe() { + // Test that we can find cl.exe for common target architectures + // and validate the correct host-target combination paths + // This should pass on Windows CI with Visual Studio installed + + let target_architectures = ["x64", "x86", "arm64"]; + let mut found_any = false; + + // Determine the host architecture + let host_arch_value = host_arch(); + let host_name = host_arch_to_string(host_arch_value); + + for &target_arch in &target_architectures { + if let Some(cmd) = find(target_arch, "cl.exe") { + // Verify the command looks valid + assert!( + !cmd.get_program().is_empty(), + "cl.exe program path should not be empty" + ); + assert!( + Path::new(cmd.get_program()).exists(), + "cl.exe should exist at: {:?}", + cmd.get_program() + ); + + // Verify the path contains the correct host-target combination + // Use case-insensitive comparison since VS IDE uses "Hostx64" while Build Tools use "HostX64" + let path_str = cmd.get_program().to_string_lossy(); + let path_str_lower = path_str.to_lowercase(); + let expected_host_target_path = + format!("\\bin\\host{host_name}\\{target_arch}"); + let expected_host_target_path_unix = + expected_host_target_path.replace("\\", "/"); + + assert!( + path_str_lower.contains(&expected_host_target_path) || path_str_lower.contains(&expected_host_target_path_unix), + "cl.exe path should contain host-target combination (case-insensitive) '{}' for {} host targeting {}, but found: {}", + expected_host_target_path, + host_name, + target_arch, + path_str + ); + + found_any = true; + } + } + + assert!(found_any, "Expected to find cl.exe for at least one target architecture (x64, x86, or arm64) on Windows CI with Visual Studio installed"); + } + + #[test] + #[cfg(not(disable_clang_cl_tests))] + fn test_find_llvm_tools() { + // Import StdEnvGetter from the parent module + use crate::find_tools::StdEnvGetter; + + // Test the actual find_llvm_tool function with various LLVM tools + // This test assumes CI environment has Visual Studio + Clang installed + // We test against x64 target since clang can cross-compile to any target + let target_arch = TargetArch::new("x64").expect("Should support x64 architecture"); + let llvm_tools = ["clang.exe", "clang++.exe", "lld.exe", "llvm-ar.exe"]; + + // Determine expected host-specific path based on host architecture + let host_arch_value = host_arch(); + let expected_host_path = match host_arch_value { + X86 => "LLVM\\bin", // x86 host + X86_64 => "LLVM\\x64\\bin", // x64 host + AARCH64 => "LLVM\\ARM64\\bin", // arm64 host + _ => panic!("Unsupported host architecture: {}", host_arch_value), + }; + + let host_name = host_arch_to_string(host_arch_value); + + let mut found_tools_count = 0; + + for &tool in &llvm_tools { + // Test finding LLVM tools using the standard environment getter + let env_getter = StdEnvGetter; + let result = find_llvm_tool(tool, target_arch, &env_getter); + + match result { + Some(found_tool) => { + found_tools_count += 1; + + // Verify the found tool has a valid, non-empty path + assert!( + !found_tool.path().as_os_str().is_empty(), + "Found LLVM tool '{}' should have a non-empty path", + tool + ); + + // Verify the tool path actually exists on filesystem + assert!( + found_tool.path().exists(), + "LLVM tool '{}' path should exist: {:?}", + tool, + found_tool.path() + ); + + // Verify the tool path contains the expected tool name + let path_str = found_tool.path().to_string_lossy(); + assert!( + path_str.contains(tool.trim_end_matches(".exe")), + "Tool path '{}' should contain tool name '{}'", + path_str, + tool + ); + + // Verify it's in the correct host-specific VS LLVM directory + assert!( + path_str.contains(expected_host_path) || path_str.contains(&expected_host_path.replace("\\", "/")), + "LLVM tool should be in host-specific VS LLVM directory '{}' for {} host, but found: {}", + expected_host_path, + host_name, + path_str + ); + } + None => {} + } + } + + // On CI with VS + Clang installed, we should find at least some LLVM tools + assert!( + found_tools_count > 0, + "Expected to find at least one LLVM tool on CI with Visual Studio + Clang installed for {} host. Found: {}", + host_name, + found_tools_count + ); + } + } + + // Given a registry key, look at all the sub keys and find the one which has + // the maximal numeric value. + // + // Returns the name of the maximal key as well as the opened maximal key. + fn max_version(key: &RegistryKey) -> Option<(OsString, RegistryKey)> { + let mut max_vers = 0; + let mut max_key = None; + for subkey in key.iter().filter_map(|k| k.ok()) { + let val = subkey + .to_str() + .and_then(|s| s.trim_start_matches('v').replace('.', "").parse().ok()); + let val = match val { + Some(s) => s, + None => continue, + }; + if val > max_vers { + if let Ok(k) = key.open(&subkey) { + max_vers = val; + max_key = Some((subkey, k)); + } + } + } + max_key + } + + #[inline(always)] + pub(super) fn has_msbuild_version(version: &str, env_getter: &dyn EnvGetter) -> bool { + match version { + "18.0" => { + find_msbuild_vs18(TargetArch::X64, env_getter).is_some() + || find_msbuild_vs18(TargetArch::X86, env_getter).is_some() + || find_msbuild_vs18(TargetArch::Arm64, env_getter).is_some() + } + "17.0" => { + find_msbuild_vs17(TargetArch::X64, env_getter).is_some() + || find_msbuild_vs17(TargetArch::X86, env_getter).is_some() + || find_msbuild_vs17(TargetArch::Arm64, env_getter).is_some() + } + "16.0" => { + find_msbuild_vs16(TargetArch::X64, env_getter).is_some() + || find_msbuild_vs16(TargetArch::X86, env_getter).is_some() + || find_msbuild_vs16(TargetArch::Arm64, env_getter).is_some() + } + "15.0" => { + find_msbuild_vs15(TargetArch::X64, env_getter).is_some() + || find_msbuild_vs15(TargetArch::X86, env_getter).is_some() + || find_msbuild_vs15(TargetArch::Arm64, env_getter).is_some() + } + "14.0" => LOCAL_MACHINE + .open(&OsString::from(format!( + "SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\{}", + version + ))) + .is_ok(), + _ => false, + } + } + + pub(super) fn find_devenv(target: TargetArch, env_getter: &dyn EnvGetter) -> Option { + find_devenv_vs15(target, env_getter) + } + + fn find_devenv_vs15(target: TargetArch, env_getter: &dyn EnvGetter) -> Option { + find_tool_in_vs15_path(r"Common7\IDE\devenv.exe", target, env_getter) + } + + // see http://stackoverflow.com/questions/328017/path-to-msbuild + pub(super) fn find_msbuild(target: TargetArch, env_getter: &dyn EnvGetter) -> Option { + // VS 15 (2017) changed how to locate msbuild + if let Some(r) = find_msbuild_vs18(target, env_getter) { + Some(r) + } else if let Some(r) = find_msbuild_vs17(target, env_getter) { + Some(r) + } else if let Some(r) = find_msbuild_vs16(target, env_getter) { + return Some(r); + } else if let Some(r) = find_msbuild_vs15(target, env_getter) { + return Some(r); + } else { + find_old_msbuild(target) + } + } + + fn find_msbuild_vs15(target: TargetArch, env_getter: &dyn EnvGetter) -> Option { + find_tool_in_vs15_path(r"MSBuild\15.0\Bin\MSBuild.exe", target, env_getter) + } + + fn find_old_msbuild(target: TargetArch) -> Option { + let key = r"SOFTWARE\Microsoft\MSBuild\ToolsVersions"; + LOCAL_MACHINE + .open(key.as_ref()) + .ok() + .and_then(|key| { + max_version(&key).and_then(|(_vers, key)| key.query_str("MSBuildToolsPath").ok()) + }) + .map(|path| { + let mut path = PathBuf::from(path); + path.push("MSBuild.exe"); + let mut tool = Tool { + tool: path, + is_clang_cl: false, + env: Vec::new(), + }; + if target == TargetArch::X64 { + tool.env.push(("Platform".into(), "X64".into())); + } + tool + }) + } +} + +/// Non-Windows Implementation. +#[cfg(not(windows))] +mod impl_ { + use std::{env, ffi::OsStr, path::PathBuf}; + + use super::{EnvGetter, Sdk, TargetArch}; + use crate::Tool; + + /// Finding msbuild.exe tool under unix system is not currently supported. + /// Maybe can check it using an environment variable looks like `MSBUILD_BIN`. + #[inline(always)] + pub(super) fn find_msbuild(_target: TargetArch, _: &dyn EnvGetter) -> Option { + None + } + + // Finding devenv.exe tool under unix system is not currently supported. + // Maybe can check it using an environment variable looks like `DEVENV_BIN`. + #[inline(always)] + pub(super) fn find_devenv(_target: TargetArch, _: &dyn EnvGetter) -> Option { + None + } + + // Finding Clang/LLVM-related tools on unix systems is not currently supported. + #[inline(always)] + pub(super) fn find_llvm_tool( + _tool: &str, + _target: TargetArch, + _: &dyn EnvGetter, + ) -> Option { + None + } + + /// Attempt to find the tool using environment variables set by vcvars. + pub(super) fn find_msvc_environment( + tool: &str, + _target: TargetArch, + env_getter: &dyn EnvGetter, + ) -> Option { + // Early return if the environment doesn't contain a VC install. + let vc_install_dir = env_getter.get_env("VCINSTALLDIR")?; + let vs_install_dir = env_getter.get_env("VSINSTALLDIR")?; + + let get_tool = |install_dir: &OsStr| { + env::split_paths(install_dir) + .map(|p| p.join(tool)) + .find(|p| p.exists()) + .map(|path| Tool { + tool: path, + is_clang_cl: false, + env: Vec::new(), + }) + }; + + // Take the path of tool for the vc install directory. + get_tool(vc_install_dir.as_ref()) + // Take the path of tool for the vs install directory. + .or_else(|| get_tool(vs_install_dir.as_ref())) + // Take the path of tool for the current path environment. + .or_else(|| { + env_getter + .get_env("PATH") + .as_ref() + .map(|path| path.as_ref()) + .and_then(get_tool) + }) + } + + #[inline(always)] + pub(super) fn find_msvc_15plus( + _tool: &str, + _target: TargetArch, + _: &dyn EnvGetter, + ) -> Option { + None + } + + // For MSVC 14 we need to find the Universal CRT as well as either + // the Windows 10 SDK or Windows 8.1 SDK. + #[inline(always)] + pub(super) fn find_msvc_14( + _tool: &str, + _target: TargetArch, + _: &dyn EnvGetter, + ) -> Option { + None + } + + #[inline(always)] + pub(super) fn has_msbuild_version(_version: &str, _: &dyn EnvGetter) -> bool { + false + } + + #[inline(always)] + pub(super) fn get_ucrt_dir() -> Option<(PathBuf, String)> { + None + } + + #[inline(always)] + pub(super) fn get_sdks(_target: TargetArch, _env_getter: &dyn EnvGetter) -> Option { + None + } +} diff --git a/http/vendor/find-msvc-tools/src/lib.rs b/http/vendor/find-msvc-tools/src/lib.rs new file mode 100644 index 0000000..f49a24b --- /dev/null +++ b/http/vendor/find-msvc-tools/src/lib.rs @@ -0,0 +1,28 @@ +//! These modules are all glue to support reading the MSVC version from +//! the registry and from COM interfaces. + +// This is used in the crate's public API, so don't use #[cfg(windows)] +mod find_tools; +pub use find_tools::*; + +mod tool; +pub use tool::*; + +#[cfg(windows)] +#[doc(hidden)] +pub mod windows_link; +#[cfg(windows)] +#[doc(hidden)] +pub mod windows_sys; + +#[cfg(windows)] +mod registry; +#[cfg(windows)] +#[macro_use] +mod winapi; +#[cfg(windows)] +mod com; +#[cfg(windows)] +mod setup_config; +#[cfg(windows)] +mod vs_instances; diff --git a/http/vendor/find-msvc-tools/src/registry.rs b/http/vendor/find-msvc-tools/src/registry.rs new file mode 100644 index 0000000..89a08ef --- /dev/null +++ b/http/vendor/find-msvc-tools/src/registry.rs @@ -0,0 +1,191 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use crate::windows_sys::{ + RegCloseKey, RegEnumKeyExW, RegOpenKeyExW, RegQueryValueExW, ERROR_NO_MORE_ITEMS, + ERROR_SUCCESS, HKEY, HKEY_LOCAL_MACHINE, KEY_READ, KEY_WOW64_32KEY, REG_SZ, +}; +use std::{ + ffi::{OsStr, OsString}, + io, + ops::RangeFrom, + os::windows::prelude::*, + ptr::null_mut, +}; + +/// Must never be `HKEY_PERFORMANCE_DATA`. +pub(crate) struct RegistryKey(Repr); + +#[allow(clippy::upper_case_acronyms)] +type DWORD = u32; + +struct OwnedKey(HKEY); + +/// Note: must not encode `HKEY_PERFORMANCE_DATA` or one of its subkeys. +enum Repr { + /// `HKEY_LOCAL_MACHINE`. + LocalMachine, + /// A subkey of `HKEY_LOCAL_MACHINE`. + Owned(OwnedKey), +} + +pub struct Iter<'a> { + idx: RangeFrom, + key: &'a RegistryKey, +} + +unsafe impl Sync for Repr {} +unsafe impl Send for Repr {} + +pub(crate) const LOCAL_MACHINE: RegistryKey = RegistryKey(Repr::LocalMachine); + +impl RegistryKey { + fn raw(&self) -> HKEY { + match self.0 { + Repr::LocalMachine => HKEY_LOCAL_MACHINE, + Repr::Owned(ref val) => val.0, + } + } + + /// Open a sub-key of `self`. + pub fn open(&self, key: &OsStr) -> io::Result { + let key = key.encode_wide().chain(Some(0)).collect::>(); + let mut ret = null_mut(); + let err = unsafe { + RegOpenKeyExW( + self.raw(), + key.as_ptr(), + 0, + KEY_READ | KEY_WOW64_32KEY, + &mut ret, + ) + }; + if err == ERROR_SUCCESS { + Ok(RegistryKey(Repr::Owned(OwnedKey(ret)))) + } else { + Err(io::Error::from_raw_os_error(err as i32)) + } + } + + pub fn iter(&self) -> Iter<'_> { + Iter { + idx: 0.., + key: self, + } + } + + pub fn query_str(&self, name: &str) -> io::Result { + let name: &OsStr = name.as_ref(); + let name = name.encode_wide().chain(Some(0)).collect::>(); + let mut len = 0; + let mut kind = 0; + unsafe { + let err = RegQueryValueExW( + self.raw(), + name.as_ptr(), + null_mut(), + &mut kind, + null_mut(), + &mut len, + ); + if err != ERROR_SUCCESS { + return Err(io::Error::from_raw_os_error(err as i32)); + } + if kind != REG_SZ { + return Err(io::Error::new( + io::ErrorKind::Other, + "registry key wasn't a string", + )); + } + + // The length here is the length in bytes, but we're using wide + // characters so we need to be sure to halve it for the length + // passed in. + assert!(len % 2 == 0, "impossible wide string size: {} bytes", len); + let vlen = len as usize / 2; + // Defensively initialized, see comment about + // `HKEY_PERFORMANCE_DATA` below. + let mut v = vec![0u16; vlen]; + let err = RegQueryValueExW( + self.raw(), + name.as_ptr(), + null_mut(), + null_mut(), + v.as_mut_ptr() as *mut _, + &mut len, + ); + // We don't check for `ERROR_MORE_DATA` (which would if the value + // grew between the first and second call to `RegQueryValueExW`), + // both because it's extremely unlikely, and this is a bit more + // defensive more defensive against weird types of registry keys. + if err != ERROR_SUCCESS { + return Err(io::Error::from_raw_os_error(err as i32)); + } + // The length is allowed to change, but should still be even, as + // well as smaller. + assert!(len % 2 == 0, "impossible wide string size: {} bytes", len); + // If the length grew but returned a success code, it *probably* + // indicates we're `HKEY_PERFORMANCE_DATA` or a subkey(?). We + // consider this UB, since those keys write "undefined" or + // "unpredictable" values to len, and need to use a completely + // different loop structure. This should be impossible (and enforce + // it in the API to the best of our ability), but to mitigate the + // damage we do some smoke-checks on the len, and ensure `v` has + // been fully initialized (rather than trusting the result of + // `RegQueryValueExW`). + let actual_len = len as usize / 2; + assert!(actual_len <= v.len()); + v.truncate(actual_len); + // Some registry keys may have a terminating nul character, but + // we're not interested in that, so chop it off if it's there. + if !v.is_empty() && v[v.len() - 1] == 0 { + v.pop(); + } + Ok(OsString::from_wide(&v)) + } + } +} + +impl Drop for OwnedKey { + fn drop(&mut self) { + unsafe { + RegCloseKey(self.0); + } + } +} + +impl<'a> Iterator for Iter<'a> { + type Item = io::Result; + + fn next(&mut self) -> Option> { + self.idx.next().and_then(|i| unsafe { + let mut v = Vec::with_capacity(256); + let mut len = v.capacity() as DWORD; + let ret = RegEnumKeyExW( + self.key.raw(), + i, + v.as_mut_ptr(), + &mut len, + null_mut(), + null_mut(), + null_mut(), + null_mut(), + ); + if ret == ERROR_NO_MORE_ITEMS { + None + } else if ret != ERROR_SUCCESS { + Some(Err(io::Error::from_raw_os_error(ret as i32))) + } else { + v.set_len(len as usize); + Some(Ok(OsString::from_wide(&v))) + } + }) + } +} diff --git a/http/vendor/find-msvc-tools/src/setup_config.rs b/http/vendor/find-msvc-tools/src/setup_config.rs new file mode 100644 index 0000000..fe2c030 --- /dev/null +++ b/http/vendor/find-msvc-tools/src/setup_config.rs @@ -0,0 +1,283 @@ +// Copyright © 2017 winapi-rs developers +// Licensed under the Apache License, Version 2.0 +// or the MIT license +// , at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. + +#![allow(bad_style)] +#![allow(unused)] + +use crate::{ + com::{BStr, ComPtr}, + winapi::{ + IUnknown, IUnknownVtbl, Interface, LCID, LPCOLESTR, LPCWSTR, LPFILETIME, LPSAFEARRAY, + PULONGLONG, ULONG, + }, + windows_sys::{CoCreateInstance, BSTR, CLSCTX_ALL, HRESULT, S_FALSE}, +}; + +use std::{ + ffi::OsString, + ptr::{null, null_mut}, +}; + +// Bindings to the Setup.Configuration stuff +pub type InstanceState = u32; + +pub const eNone: InstanceState = 0; +pub const eLocal: InstanceState = 1; +pub const eRegistered: InstanceState = 2; +pub const eNoRebootRequired: InstanceState = 4; +pub const eComplete: InstanceState = -1i32 as u32; + +RIDL! {#[uuid(0xb41463c3, 0x8866, 0x43b5, 0xbc, 0x33, 0x2b, 0x06, 0x76, 0xf7, 0xf4, 0x2e)] +interface ISetupInstance(ISetupInstanceVtbl): IUnknown(IUnknownVtbl) { + fn GetInstanceId( + pbstrInstanceId: *mut BSTR, + ) -> HRESULT, + fn GetInstallDate( + pInstallDate: LPFILETIME, + ) -> HRESULT, + fn GetInstallationName( + pbstrInstallationName: *mut BSTR, + ) -> HRESULT, + fn GetInstallationPath( + pbstrInstallationPath: *mut BSTR, + ) -> HRESULT, + fn GetInstallationVersion( + pbstrInstallationVersion: *mut BSTR, + ) -> HRESULT, + fn GetDisplayName( + lcid: LCID, + pbstrDisplayName: *mut BSTR, + ) -> HRESULT, + fn GetDescription( + lcid: LCID, + pbstrDescription: *mut BSTR, + ) -> HRESULT, + fn ResolvePath( + pwszRelativePath: LPCOLESTR, + pbstrAbsolutePath: *mut BSTR, + ) -> HRESULT, +}} + +RIDL! {#[uuid(0x89143c9a, 0x05af, 0x49b0, 0xb7, 0x17, 0x72, 0xe2, 0x18, 0xa2, 0x18, 0x5c)] +interface ISetupInstance2(ISetupInstance2Vtbl): ISetupInstance(ISetupInstanceVtbl) { + fn GetState( + pState: *mut InstanceState, + ) -> HRESULT, + fn GetPackages( + ppsaPackages: *mut LPSAFEARRAY, + ) -> HRESULT, + fn GetProduct( + ppPackage: *mut *mut ISetupPackageReference, + ) -> HRESULT, + fn GetProductPath( + pbstrProductPath: *mut BSTR, + ) -> HRESULT, +}} + +RIDL! {#[uuid(0x6380bcff, 0x41d3, 0x4b2e, 0x8b, 0x2e, 0xbf, 0x8a, 0x68, 0x10, 0xc8, 0x48)] +interface IEnumSetupInstances(IEnumSetupInstancesVtbl): IUnknown(IUnknownVtbl) { + fn Next( + celt: ULONG, + rgelt: *mut *mut ISetupInstance, + pceltFetched: *mut ULONG, + ) -> HRESULT, + fn Skip( + celt: ULONG, + ) -> HRESULT, + fn Reset() -> HRESULT, + fn Clone( + ppenum: *mut *mut IEnumSetupInstances, + ) -> HRESULT, +}} + +RIDL! {#[uuid(0x42843719, 0xdb4c, 0x46c2, 0x8e, 0x7c, 0x64, 0xf1, 0x81, 0x6e, 0xfd, 0x5b)] +interface ISetupConfiguration(ISetupConfigurationVtbl): IUnknown(IUnknownVtbl) { + fn EnumInstances( + ppEnumInstances: *mut *mut IEnumSetupInstances, + ) -> HRESULT, + fn GetInstanceForCurrentProcess( + ppInstance: *mut *mut ISetupInstance, + ) -> HRESULT, + fn GetInstanceForPath( + wzPath: LPCWSTR, + ppInstance: *mut *mut ISetupInstance, + ) -> HRESULT, +}} + +RIDL! {#[uuid(0x26aab78c, 0x4a60, 0x49d6, 0xaf, 0x3b, 0x3c, 0x35, 0xbc, 0x93, 0x36, 0x5d)] +interface ISetupConfiguration2(ISetupConfiguration2Vtbl): + ISetupConfiguration(ISetupConfigurationVtbl) { + fn EnumAllInstances( + ppEnumInstances: *mut *mut IEnumSetupInstances, + ) -> HRESULT, +}} + +RIDL! {#[uuid(0xda8d8a16, 0xb2b6, 0x4487, 0xa2, 0xf1, 0x59, 0x4c, 0xcc, 0xcd, 0x6b, 0xf5)] +interface ISetupPackageReference(ISetupPackageReferenceVtbl): IUnknown(IUnknownVtbl) { + fn GetId( + pbstrId: *mut BSTR, + ) -> HRESULT, + fn GetVersion( + pbstrVersion: *mut BSTR, + ) -> HRESULT, + fn GetChip( + pbstrChip: *mut BSTR, + ) -> HRESULT, + fn GetLanguage( + pbstrLanguage: *mut BSTR, + ) -> HRESULT, + fn GetBranch( + pbstrBranch: *mut BSTR, + ) -> HRESULT, + fn GetType( + pbstrType: *mut BSTR, + ) -> HRESULT, + fn GetUniqueId( + pbstrUniqueId: *mut BSTR, + ) -> HRESULT, +}} + +RIDL! {#[uuid(0x42b21b78, 0x6192, 0x463e, 0x87, 0xbf, 0xd5, 0x77, 0x83, 0x8f, 0x1d, 0x5c)] +interface ISetupHelper(ISetupHelperVtbl): IUnknown(IUnknownVtbl) { + fn ParseVersion( + pwszVersion: LPCOLESTR, + pullVersion: PULONGLONG, + ) -> HRESULT, + fn ParseVersionRange( + pwszVersionRange: LPCOLESTR, + pullMinVersion: PULONGLONG, + pullMaxVersion: PULONGLONG, + ) -> HRESULT, +}} + +DEFINE_GUID! {CLSID_SetupConfiguration, +0x177f0c4a, 0x1cd3, 0x4de7, 0xa3, 0x2c, 0x71, 0xdb, 0xbb, 0x9f, 0xa3, 0x6d} + +// Safe wrapper around the COM interfaces +pub struct SetupConfiguration(ComPtr); + +impl SetupConfiguration { + pub fn new() -> Result { + let mut obj = null_mut(); + let err = unsafe { + CoCreateInstance( + &CLSID_SetupConfiguration, + null_mut(), + CLSCTX_ALL, + &ISetupConfiguration::uuidof(), + &mut obj, + ) + }; + if err < 0 { + return Err(err); + } + let obj = unsafe { ComPtr::from_raw(obj as *mut ISetupConfiguration) }; + Ok(SetupConfiguration(obj)) + } + pub fn get_instance_for_current_process(&self) -> Result { + let mut obj = null_mut(); + let err = unsafe { self.0.GetInstanceForCurrentProcess(&mut obj) }; + if err < 0 { + return Err(err); + } + Ok(unsafe { SetupInstance::from_raw(obj) }) + } + pub fn enum_instances(&self) -> Result { + let mut obj = null_mut(); + let err = unsafe { self.0.EnumInstances(&mut obj) }; + if err < 0 { + return Err(err); + } + Ok(unsafe { EnumSetupInstances::from_raw(obj) }) + } + pub fn enum_all_instances(&self) -> Result { + let mut obj = null_mut(); + let this = self.0.cast::()?; + let err = unsafe { this.EnumAllInstances(&mut obj) }; + if err < 0 { + return Err(err); + } + Ok(unsafe { EnumSetupInstances::from_raw(obj) }) + } +} + +pub struct SetupInstance(ComPtr); + +impl SetupInstance { + pub unsafe fn from_raw(obj: *mut ISetupInstance) -> SetupInstance { + SetupInstance(ComPtr::from_raw(obj)) + } + pub fn instance_id(&self) -> Result { + let mut s = null(); + let err = unsafe { self.0.GetInstanceId(&mut s) }; + let bstr = unsafe { BStr::from_raw(s) }; + if err < 0 { + return Err(err); + } + Ok(bstr.to_osstring()) + } + pub fn installation_name(&self) -> Result { + let mut s = null(); + let err = unsafe { self.0.GetInstallationName(&mut s) }; + let bstr = unsafe { BStr::from_raw(s) }; + if err < 0 { + return Err(err); + } + Ok(bstr.to_osstring()) + } + pub fn installation_path(&self) -> Result { + let mut s = null(); + let err = unsafe { self.0.GetInstallationPath(&mut s) }; + let bstr = unsafe { BStr::from_raw(s) }; + if err < 0 { + return Err(err); + } + Ok(bstr.to_osstring()) + } + pub fn installation_version(&self) -> Result { + let mut s = null(); + let err = unsafe { self.0.GetInstallationVersion(&mut s) }; + let bstr = unsafe { BStr::from_raw(s) }; + if err < 0 { + return Err(err); + } + Ok(bstr.to_osstring()) + } + pub fn product_path(&self) -> Result { + let mut s = null(); + let this = self.0.cast::()?; + let err = unsafe { this.GetProductPath(&mut s) }; + let bstr = unsafe { BStr::from_raw(s) }; + if err < 0 { + return Err(err); + } + Ok(bstr.to_osstring()) + } +} + +pub struct EnumSetupInstances(ComPtr); + +impl EnumSetupInstances { + pub unsafe fn from_raw(obj: *mut IEnumSetupInstances) -> EnumSetupInstances { + EnumSetupInstances(ComPtr::from_raw(obj)) + } +} + +impl Iterator for EnumSetupInstances { + type Item = Result; + fn next(&mut self) -> Option> { + let mut obj = null_mut(); + let err = unsafe { self.0.Next(1, &mut obj, null_mut()) }; + if err < 0 { + return Some(Err(err)); + } + if err == S_FALSE { + return None; + } + Some(Ok(unsafe { SetupInstance::from_raw(obj) })) + } +} diff --git a/http/vendor/find-msvc-tools/src/tool.rs b/http/vendor/find-msvc-tools/src/tool.rs new file mode 100644 index 0000000..55b4cac --- /dev/null +++ b/http/vendor/find-msvc-tools/src/tool.rs @@ -0,0 +1,45 @@ +use std::{ + ffi::OsString, + path::{Path, PathBuf}, + process::Command, +}; + +/// `Tool` found by `find-msvc-tools` +#[derive(Clone, Debug)] +pub struct Tool { + pub(crate) tool: PathBuf, + pub(crate) is_clang_cl: bool, + pub(crate) env: Vec<(OsString, OsString)>, +} + +impl Tool { + /// Converts this compiler into a `Command` that's ready to be run. + /// + /// This is useful for when the compiler needs to be executed and the + /// command returned will already have the initial arguments and environment + /// variables configured. + pub fn to_command(&self) -> Command { + let mut cmd = Command::new(&self.tool); + + for (k, v) in self.env.iter() { + cmd.env(k, v); + } + + cmd + } + + /// Check is the tool clang-cl related + pub fn is_clang_cl(&self) -> bool { + self.is_clang_cl + } + + /// Get path to the tool + pub fn path(&self) -> &Path { + &self.tool + } + + /// Get environment variables for the tools + pub fn env(&self) -> impl IntoIterator { + &self.env + } +} diff --git a/http/vendor/find-msvc-tools/src/vs_instances.rs b/http/vendor/find-msvc-tools/src/vs_instances.rs new file mode 100644 index 0000000..23089c7 --- /dev/null +++ b/http/vendor/find-msvc-tools/src/vs_instances.rs @@ -0,0 +1,199 @@ +use std::borrow::Cow; +use std::collections::HashMap; +use std::convert::TryFrom; +use std::io::BufRead; +use std::path::PathBuf; + +use crate::setup_config::{EnumSetupInstances, SetupInstance}; + +pub enum VsInstance { + Com(SetupInstance), + Vswhere(VswhereInstance), +} + +impl VsInstance { + pub fn installation_name(&self) -> Option> { + match self { + VsInstance::Com(s) => s + .installation_name() + .ok() + .and_then(|s| s.into_string().ok()) + .map(Cow::from), + VsInstance::Vswhere(v) => v.map.get("installationName").map(Cow::from), + } + } + + pub fn installation_path(&self) -> Option { + match self { + VsInstance::Com(s) => s.installation_path().ok().map(PathBuf::from), + VsInstance::Vswhere(v) => v.map.get("installationPath").map(PathBuf::from), + } + } + + pub fn installation_version(&self) -> Option> { + match self { + VsInstance::Com(s) => s + .installation_version() + .ok() + .and_then(|s| s.into_string().ok()) + .map(Cow::from), + VsInstance::Vswhere(v) => v.map.get("installationVersion").map(Cow::from), + } + } +} + +pub enum VsInstances { + ComBased(EnumSetupInstances), + VswhereBased(VswhereInstance), +} + +impl IntoIterator for VsInstances { + type Item = VsInstance; + #[allow(bare_trait_objects)] + type IntoIter = Box>; + + fn into_iter(self) -> Self::IntoIter { + match self { + VsInstances::ComBased(e) => { + Box::new(e.into_iter().filter_map(Result::ok).map(VsInstance::Com)) + } + VsInstances::VswhereBased(v) => Box::new(std::iter::once(VsInstance::Vswhere(v))), + } + } +} + +#[derive(Debug)] +pub struct VswhereInstance { + map: HashMap, +} + +impl TryFrom<&Vec> for VswhereInstance { + type Error = &'static str; + + fn try_from(output: &Vec) -> Result { + let map: HashMap<_, _> = output + .lines() + .map_while(Result::ok) + .filter_map(|s| { + let mut splitn = s.splitn(2, ": "); + Some((splitn.next()?.to_owned(), splitn.next()?.to_owned())) + }) + .collect(); + + if !map.contains_key("installationName") + || !map.contains_key("installationPath") + || !map.contains_key("installationVersion") + { + return Err("required properties not found"); + } + + Ok(Self { map }) + } +} + +#[cfg(test)] +mod tests_ { + use std::borrow::Cow; + use std::convert::TryFrom; + use std::path::PathBuf; + + #[test] + fn it_parses_vswhere_output_correctly() { + let output = br"instanceId: 58104422 +installDate: 21/02/2021 21:50:33 +installationName: VisualStudio/16.9.2+31112.23 +installationPath: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools +installationVersion: 16.9.31112.23 +productId: Microsoft.VisualStudio.Product.BuildTools +productPath: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\LaunchDevCmd.bat +state: 4294967295 +isComplete: 1 +isLaunchable: 1 +isPrerelease: 0 +isRebootRequired: 0 +displayName: Visual Studio Build Tools 2019 +description: The Visual Studio Build Tools allows you to build native and managed MSBuild-based applications without requiring the Visual Studio IDE. There are options to install the Visual C++ compilers and libraries, MFC, ATL, and C++/CLI support. +channelId: VisualStudio.16.Release +channelUri: https://aka.ms/vs/16/release/channel +enginePath: C:\Program Files (x86)\Microsoft Visual Studio\Installer\resources\app\ServiceHub\Services\Microsoft.VisualStudio.Setup.Service +releaseNotes: https://docs.microsoft.com/en-us/visualstudio/releases/2019/release-notes-v16.9#16.9.2 +thirdPartyNotices: https://go.microsoft.com/fwlink/?LinkId=660909 +updateDate: 2021-03-17T21:16:46.5963702Z +catalog_buildBranch: d16.9 +catalog_buildVersion: 16.9.31112.23 +catalog_id: VisualStudio/16.9.2+31112.23 +catalog_localBuild: build-lab +catalog_manifestName: VisualStudio +catalog_manifestType: installer +catalog_productDisplayVersion: 16.9.2 +catalog_productLine: Dev16 +catalog_productLineVersion: 2019 +catalog_productMilestone: RTW +catalog_productMilestoneIsPreRelease: False +catalog_productName: Visual Studio +catalog_productPatchVersion: 2 +catalog_productPreReleaseMilestoneSuffix: 1.0 +catalog_productSemanticVersion: 16.9.2+31112.23 +catalog_requiredEngineVersion: 2.9.3365.38425 +properties_campaignId: 156063665.1613940062 +properties_channelManifestId: VisualStudio.16.Release/16.9.2+31112.23 +properties_nickname: +properties_setupEngineFilePath: C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installershell.exe +" + .to_vec(); + + let vswhere_instance = super::VswhereInstance::try_from(&output); + assert!(vswhere_instance.is_ok()); + + let vs_instance = super::VsInstance::Vswhere(vswhere_instance.unwrap()); + assert_eq!( + vs_instance.installation_name(), + Some(Cow::from("VisualStudio/16.9.2+31112.23")) + ); + assert_eq!( + vs_instance.installation_path(), + Some(PathBuf::from( + r"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools" + )) + ); + assert_eq!( + vs_instance.installation_version(), + Some(Cow::from("16.9.31112.23")) + ); + } + + #[test] + fn it_returns_an_error_for_empty_output() { + let output = b"".to_vec(); + + let vswhere_instance = super::VswhereInstance::try_from(&output); + + assert!(vswhere_instance.is_err()); + } + + #[test] + fn it_returns_an_error_for_output_consisting_of_empty_lines() { + let output = br" + +" + .to_vec(); + + let vswhere_instance = super::VswhereInstance::try_from(&output); + + assert!(vswhere_instance.is_err()); + } + + #[test] + fn it_returns_an_error_for_output_without_required_properties() { + let output = br"instanceId: 58104422 +installDate: 21/02/2021 21:50:33 +productId: Microsoft.VisualStudio.Product.BuildTools +productPath: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\LaunchDevCmd.bat +" + .to_vec(); + + let vswhere_instance = super::VswhereInstance::try_from(&output); + + assert!(vswhere_instance.is_err()); + } +} diff --git a/http/vendor/find-msvc-tools/src/winapi.rs b/http/vendor/find-msvc-tools/src/winapi.rs new file mode 100644 index 0000000..52790a5 --- /dev/null +++ b/http/vendor/find-msvc-tools/src/winapi.rs @@ -0,0 +1,146 @@ +// Copyright © 2015-2017 winapi-rs developers +// Licensed under the Apache License, Version 2.0 +// or the MIT license +// , at your option. +// All files in the project carrying such notice may not be copied, modified, or distributed +// except according to those terms. + +#![allow(bad_style, clippy::upper_case_acronyms)] + +use std::os::raw; + +pub type wchar_t = u16; + +pub use crate::windows_sys::{FILETIME, GUID, HRESULT, SAFEARRAY}; + +pub type REFIID = *const IID; +pub type IID = GUID; +pub type ULONG = raw::c_ulong; +pub type DWORD = u32; +pub type LPFILETIME = *mut FILETIME; +pub type OLECHAR = WCHAR; +pub type WCHAR = wchar_t; +pub type LPCOLESTR = *const OLECHAR; +pub type LCID = DWORD; +pub type LPCWSTR = *const WCHAR; +pub type PULONGLONG = *mut ULONGLONG; +pub type ULONGLONG = u64; + +pub trait Interface { + fn uuidof() -> GUID; +} + +pub type LPSAFEARRAY = *mut SAFEARRAY; + +macro_rules! DEFINE_GUID { + ( + $name:ident, $l:expr, $w1:expr, $w2:expr, + $b1:expr, $b2:expr, $b3:expr, $b4:expr, $b5:expr, $b6:expr, $b7:expr, $b8:expr + ) => { + pub const $name: $crate::winapi::GUID = $crate::winapi::GUID { + data1: $l, + data2: $w1, + data3: $w2, + data4: [$b1, $b2, $b3, $b4, $b5, $b6, $b7, $b8], + }; + }; +} + +macro_rules! RIDL { + (#[uuid($($uuid:expr),+)] + interface $interface:ident ($vtbl:ident) {$( + fn $method:ident($($p:ident : $t:ty,)*) -> $rtr:ty, + )+}) => ( + #[repr(C)] + pub struct $vtbl { + $(pub $method: unsafe extern "system" fn( + This: *mut $interface, + $($p: $t),* + ) -> $rtr,)+ + } + #[repr(C)] + pub struct $interface { + pub lpVtbl: *const $vtbl, + } + RIDL!{@impl $interface {$(fn $method($($p: $t,)*) -> $rtr,)+}} + RIDL!{@uuid $interface $($uuid),+} + ); + (#[uuid($($uuid:expr),+)] + interface $interface:ident ($vtbl:ident) : $pinterface:ident ($pvtbl:ident) { + }) => ( + #[repr(C)] + pub struct $vtbl { + pub parent: $pvtbl, + } + #[repr(C)] + pub struct $interface { + pub lpVtbl: *const $vtbl, + } + RIDL!{@deref $interface $pinterface} + RIDL!{@uuid $interface $($uuid),+} + ); + (#[uuid($($uuid:expr),+)] + interface $interface:ident ($vtbl:ident) : $pinterface:ident ($pvtbl:ident) {$( + fn $method:ident($($p:ident : $t:ty,)*) -> $rtr:ty, + )+}) => ( + #[repr(C)] + pub struct $vtbl { + pub parent: $pvtbl, + $(pub $method: unsafe extern "system" fn( + This: *mut $interface, + $($p: $t,)* + ) -> $rtr,)+ + } + #[repr(C)] + pub struct $interface { + pub lpVtbl: *const $vtbl, + } + RIDL!{@impl $interface {$(fn $method($($p: $t,)*) -> $rtr,)+}} + RIDL!{@deref $interface $pinterface} + RIDL!{@uuid $interface $($uuid),+} + ); + (@deref $interface:ident $pinterface:ident) => ( + impl ::std::ops::Deref for $interface { + type Target = $pinterface; + #[inline] + fn deref(&self) -> &$pinterface { + unsafe { &*(self as *const $interface as *const $pinterface) } + } + } + ); + (@impl $interface:ident {$( + fn $method:ident($($p:ident : $t:ty,)*) -> $rtr:ty, + )+}) => ( + impl $interface { + $(#[inline] pub unsafe fn $method(&self, $($p: $t,)*) -> $rtr { + ((*self.lpVtbl).$method)(self as *const _ as *mut _, $($p,)*) + })+ + } + ); + (@uuid $interface:ident + $l:expr, $w1:expr, $w2:expr, + $b1:expr, $b2:expr, $b3:expr, $b4:expr, $b5:expr, $b6:expr, $b7:expr, $b8:expr + ) => ( + impl $crate::winapi::Interface for $interface { + #[inline] + fn uuidof() -> $crate::winapi::GUID { + $crate::winapi::GUID { + data1: $l, + data2: $w1, + data3: $w2, + data4: [$b1, $b2, $b3, $b4, $b5, $b6, $b7, $b8], + } + } + } + ); +} + +RIDL! {#[uuid(0x00000000, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46)] +interface IUnknown(IUnknownVtbl) { + fn QueryInterface( + riid: REFIID, + ppvObject: *mut *mut raw::c_void, + ) -> HRESULT, + fn AddRef() -> ULONG, + fn Release() -> ULONG, +}} diff --git a/http/vendor/find-msvc-tools/src/windows_link.rs b/http/vendor/find-msvc-tools/src/windows_link.rs new file mode 100644 index 0000000..d08affe --- /dev/null +++ b/http/vendor/find-msvc-tools/src/windows_link.rs @@ -0,0 +1,19 @@ +//! Provides the `link!` macro used by the generated windows bindings. +//! +//! This is a simple wrapper around an `extern` block with a `#[link]` attribute. +//! It's very roughly equivalent to the windows-targets crate. + +macro_rules! link_macro { + ($library:literal $abi:literal $($link_name:literal)? $(#[$doc:meta])? fn $($function:tt)*) => ( + // Note: the windows-targets crate uses a pre-built Windows.lib import library which we don't + // have in this repo. So instead we always link kernel32.lib and add the rest of the import + // libraries below by using an empty extern block. This works because extern blocks are not + // connected to the library given in the #[link] attribute. + #[link(name = "kernel32")] + extern $abi { + $(#[link_name=$link_name])? + pub fn $($function)*; + } + ) +} +pub(crate) use link_macro as link; diff --git a/http/vendor/find-msvc-tools/src/windows_sys.rs b/http/vendor/find-msvc-tools/src/windows_sys.rs new file mode 100644 index 0000000..786d407 --- /dev/null +++ b/http/vendor/find-msvc-tools/src/windows_sys.rs @@ -0,0 +1,139 @@ +// This file is autogenerated. +// +// To add bindings, edit windows_sys.lst then run: +// +// ``` +// cd dev-tools/generate-windows-sys/ +// cargo run +// ``` +// Bindings generated by `windows-bindgen` 0.66.0 + +#![allow( + non_snake_case, + non_upper_case_globals, + non_camel_case_types, + dead_code, + clippy::all +)] + +windows_link::link!("ole32.dll" "system" fn CoCreateInstance(rclsid : *const GUID, punkouter : * mut core::ffi::c_void, dwclscontext : CLSCTX, riid : *const GUID, ppv : *mut *mut core::ffi::c_void) -> HRESULT); +windows_link::link!("ole32.dll" "system" fn CoInitializeEx(pvreserved : *const core::ffi::c_void, dwcoinit : u32) -> HRESULT); +windows_link::link!("kernel32.dll" "system" fn FreeLibrary(hlibmodule : HMODULE) -> BOOL); +windows_link::link!("kernel32.dll" "system" fn GetMachineTypeAttributes(machine : u16, machinetypeattributes : *mut MACHINE_ATTRIBUTES) -> HRESULT); +windows_link::link!("kernel32.dll" "system" fn GetProcAddress(hmodule : HMODULE, lpprocname : PCSTR) -> FARPROC); +windows_link::link!("kernel32.dll" "system" fn LoadLibraryA(lplibfilename : PCSTR) -> HMODULE); +windows_link::link!("kernel32.dll" "system" fn OpenSemaphoreA(dwdesiredaccess : u32, binherithandle : BOOL, lpname : PCSTR) -> HANDLE); +windows_link::link!("kernel32.dll" "system" fn PeekNamedPipe(hnamedpipe : HANDLE, lpbuffer : *mut core::ffi::c_void, nbuffersize : u32, lpbytesread : *mut u32, lptotalbytesavail : *mut u32, lpbytesleftthismessage : *mut u32) -> BOOL); +windows_link::link!("advapi32.dll" "system" fn RegCloseKey(hkey : HKEY) -> WIN32_ERROR); +windows_link::link!("advapi32.dll" "system" fn RegEnumKeyExW(hkey : HKEY, dwindex : u32, lpname : PWSTR, lpcchname : *mut u32, lpreserved : *const u32, lpclass : PWSTR, lpcchclass : *mut u32, lpftlastwritetime : *mut FILETIME) -> WIN32_ERROR); +windows_link::link!("advapi32.dll" "system" fn RegOpenKeyExW(hkey : HKEY, lpsubkey : PCWSTR, uloptions : u32, samdesired : REG_SAM_FLAGS, phkresult : *mut HKEY) -> WIN32_ERROR); +windows_link::link!("advapi32.dll" "system" fn RegQueryValueExW(hkey : HKEY, lpvaluename : PCWSTR, lpreserved : *const u32, lptype : *mut REG_VALUE_TYPE, lpdata : *mut u8, lpcbdata : *mut u32) -> WIN32_ERROR); +windows_link::link!("kernel32.dll" "system" fn ReleaseSemaphore(hsemaphore : HANDLE, lreleasecount : i32, lppreviouscount : *mut i32) -> BOOL); +windows_link::link!("oleaut32.dll" "system" fn SysFreeString(bstrstring : BSTR)); +windows_link::link!("oleaut32.dll" "system" fn SysStringLen(pbstr : BSTR) -> u32); +windows_link::link!("kernel32.dll" "system" fn WaitForSingleObject(hhandle : HANDLE, dwmilliseconds : u32) -> WAIT_EVENT); +pub type ADVANCED_FEATURE_FLAGS = u16; +pub type BOOL = i32; +pub type BSTR = *const u16; +pub type CLSCTX = u32; +pub const CLSCTX_ALL: CLSCTX = 23u32; +pub type COINIT = i32; +pub const COINIT_MULTITHREADED: COINIT = 0i32; +pub const ERROR_NO_MORE_ITEMS: WIN32_ERROR = 259u32; +pub const ERROR_SUCCESS: WIN32_ERROR = 0u32; +pub const FALSE: BOOL = 0i32; +pub type FARPROC = Option isize>; +#[repr(C)] +#[derive(Clone, Copy, Default)] +pub struct FILETIME { + pub dwLowDateTime: u32, + pub dwHighDateTime: u32, +} +pub const FILE_ATTRIBUTE_TEMPORARY: FILE_FLAGS_AND_ATTRIBUTES = 256u32; +pub type FILE_FLAGS_AND_ATTRIBUTES = u32; +#[repr(C)] +#[derive(Clone, Copy)] +pub struct GUID { + pub data1: u32, + pub data2: u16, + pub data3: u16, + pub data4: [u8; 8], +} +impl GUID { + pub const fn from_u128(uuid: u128) -> Self { + Self { + data1: (uuid >> 96) as u32, + data2: (uuid >> 80 & 0xffff) as u16, + data3: (uuid >> 64 & 0xffff) as u16, + data4: (uuid as u64).to_be_bytes(), + } + } +} +pub type HANDLE = *mut core::ffi::c_void; +pub type HINSTANCE = *mut core::ffi::c_void; +pub type HKEY = *mut core::ffi::c_void; +pub const HKEY_LOCAL_MACHINE: HKEY = -2147483646i32 as _; +pub type HMODULE = *mut core::ffi::c_void; +pub type HRESULT = i32; +pub type IMAGE_FILE_MACHINE = u16; +pub const IMAGE_FILE_MACHINE_AMD64: IMAGE_FILE_MACHINE = 34404u16; +pub const IID_IUnknown: GUID = GUID::from_u128(0x00000000_0000_0000_c000_000000000046); +#[repr(C)] +pub struct IUnknown_Vtbl { + pub QueryInterface: unsafe extern "system" fn( + this: *mut core::ffi::c_void, + iid: *const GUID, + interface: *mut *mut core::ffi::c_void, + ) -> HRESULT, + pub AddRef: unsafe extern "system" fn(this: *mut core::ffi::c_void) -> u32, + pub Release: unsafe extern "system" fn(this: *mut core::ffi::c_void) -> u32, +} +pub const KEY_READ: REG_SAM_FLAGS = 131097u32; +pub const KEY_WOW64_32KEY: REG_SAM_FLAGS = 512u32; +pub type MACHINE_ATTRIBUTES = i32; +pub type PCSTR = *const u8; +pub type PCWSTR = *const u16; +pub type PWSTR = *mut u16; +pub type REG_SAM_FLAGS = u32; +pub const REG_SZ: REG_VALUE_TYPE = 1u32; +pub type REG_VALUE_TYPE = u32; +#[repr(C)] +#[derive(Clone, Copy)] +pub struct SAFEARRAY { + pub cDims: u16, + pub fFeatures: ADVANCED_FEATURE_FLAGS, + pub cbElements: u32, + pub cLocks: u32, + pub pvData: *mut core::ffi::c_void, + pub rgsabound: [SAFEARRAYBOUND; 1], +} +impl Default for SAFEARRAY { + fn default() -> Self { + unsafe { core::mem::zeroed() } + } +} +#[repr(C)] +#[derive(Clone, Copy, Default)] +pub struct SAFEARRAYBOUND { + pub cElements: u32, + pub lLbound: i32, +} +pub const SEMAPHORE_MODIFY_STATE: SYNCHRONIZATION_ACCESS_RIGHTS = 2u32; +pub type SYNCHRONIZATION_ACCESS_RIGHTS = u32; +pub const S_FALSE: HRESULT = 0x1_u32 as _; +pub const S_OK: HRESULT = 0x0_u32 as _; +pub type THREAD_ACCESS_RIGHTS = u32; +pub const THREAD_SYNCHRONIZE: THREAD_ACCESS_RIGHTS = 1048576u32; +pub const UserEnabled: MACHINE_ATTRIBUTES = 1i32; +pub const WAIT_ABANDONED: WAIT_EVENT = 128u32; +pub type WAIT_EVENT = u32; +pub const WAIT_FAILED: WAIT_EVENT = 4294967295u32; +pub const WAIT_OBJECT_0: WAIT_EVENT = 0u32; +pub const WAIT_TIMEOUT: WAIT_EVENT = 258u32; +pub type WIN32_ERROR = u32; + +#[link(name = "advapi32")] +#[link(name = "ole32")] +#[link(name = "oleaut32")] +extern "C" {} +use super::windows_link; diff --git a/http/vendor/getrandom/.cargo-checksum.json b/http/vendor/getrandom/.cargo-checksum.json new file mode 100644 index 0000000..d0a5a6f --- /dev/null +++ b/http/vendor/getrandom/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{".cargo_vcs_info.json":"fd2b1c20ac76771233208d762a77f301fe47646ff0dcfcdfc414fcffbf2b88fc","CHANGELOG.md":"265048f136f2faa5418cb775377c1b43d03afa22d0d5f5a70aee5819381e5703","Cargo.lock":"cd8ab626b9db5d90d3c83048ee9f41892ff4d888a35038efdc4725e2d2c33c1d","Cargo.toml":"032d84ffe843860402ec2339ae4179be20fd6f432109e595a3fa83be54893ec7","Cargo.toml.orig":"850cb9e629142ded23e40a80943fc19b559b09931bb71df35cef2ae7f6152c14","LICENSE-APACHE":"aaff376532ea30a0cd5330b9502ad4a4c8bf769c539c87ffe78819d188a18ebf","LICENSE-MIT":"42fa16951ce7f24b5a467a40e5b449a1d41e662f97ca779864f053f39e097737","README.md":"543f0efa922ff55d3cdc1c96a188dff669f57a2ff3b7dfa0c95368b8e646b5dd","SECURITY.md":"816ea79f8c7937888ab5a972a1efb270c4bada028b448953a195359fe11d526e","benches/buffer.rs":"242f56eaeecd1d0a0f6f9419d1bf312b8d211215355022bd4aef5e5e0f53e2a5","src/apple-other.rs":"75f2c3319068e06ec27135d516953ab645cc7c45033f045cba44136236ef5601","src/custom.rs":"ae5dc94bc12a4a284762e99891b013c509942b1a802ea559e04e572ed44479dc","src/error.rs":"ab5b82ddb8304e8ad75d905d7dc5ba8deec92096930e81e87d7a28f3da382dee","src/error_impls.rs":"4c068e81d876237a7e0a0e91519896bd670c2f999ca729f7fb970caf888cab46","src/espidf.rs":"50f70136fe46f9fe9a728aa7881cdc8144f430620168cf42519c2666a8edc11f","src/fuchsia.rs":"535ed84250cfe8f176494eba226d1c1df9687b5c30cf52d5949f56a591947656","src/getentropy.rs":"5beb52344a9b71c75426bbc56eb989f5fcb81642772737d52e92578b315615a1","src/getrandom.rs":"aad70b8e54710deef974d04d6f5473bf1b47b6fef16c751046b87f2a30a1dbe2","src/hermit.rs":"c9d9d5c78e0e435c2678ef43d1296aef885fd62957d6b454d758ca475cd4e544","src/js.rs":"4306b7a49441e0da2a0737f92f56d3258ddcd1566ec3aea4a4f4a865bbf0ff87","src/lazy.rs":"21764d7cffe5177a331ec37758cc550c6e3be8c5f6fdfb7606053dafbe6a994b","src/lib.rs":"50dbe3913bc42b354bfedd773b54540d569215cc4615140f549fd6be7266f24d","src/linux_android.rs":"92c71e68adcb9bc4ee39e6b2db730e06af1e0c8db0389712b5ea8a1d86991277","src/linux_android_with_fallback.rs":"620577d889d92916aeed62ac0e4f711725fddb7e7bb331f02474160104354e8e","src/netbsd.rs":"765e6820c840d1a6931b7f0d60f373d46a7bca472e5bb1bb9a0b8fcf64b93688","src/rdrand.rs":"ffbe1bfb8f5b30a95f462fa85db07e251f63248c6c0daf3b5f586034cedfa976","src/solaris.rs":"ea2482d6e99a7f18c21c76327c2c61cd462ffa9811e04107ada36dfee42baf7d","src/solid.rs":"a5a6e4b2b43400548b36035b9a513e70ec17809d521757e7228d2214352d24ed","src/use_file.rs":"9a743fbf324120cfb4fd23c925f6b756edb3898f269654bc50dc5a73d6329266","src/util.rs":"e2c1b86ea97ca5c61d562182890cbe24c7eaa37ff8945c17fcfa665b767da1b0","src/util_libc.rs":"39fddfc06948dbd65c4dc696f71d32cf158c5ca91632afa78cbc4c22e0192502","src/vxworks.rs":"3c132cd52df3a8cf903f430ce90d3432c4b4bb99bf069f5546dee43f4f10a555","src/wasi.rs":"45b95d98766cfdc0495cfe5da6c3b63e99dda34c334deee779cf146a29350344","src/windows.rs":"695666d2bf31257e4a02cf970dee50a9a1f83c118b88b67d1a261cc5f7c1a66f","tests/common/mod.rs":"b9a36043d71963ba43a9e2899ba8eea80ff9f3284d243d9b9b9f941afa4f4aa4","tests/custom.rs":"1e944ae523b62dba53fe3daf1b964a2498c8fdd21dfa7afe53781bff2fcf276e","tests/normal.rs":"9e1c4b1e468a09ed0225370dfb6608f8b8135e0fabb09bbc1a718105164aade6","tests/rdrand.rs":"fcf3f78e3078e1b262d0efae8f3c4a730f3fbf68df656fceb78e22ee4cc98990"},"package":"ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0"} \ No newline at end of file diff --git a/http/vendor/getrandom/.cargo_vcs_info.json b/http/vendor/getrandom/.cargo_vcs_info.json new file mode 100644 index 0000000..d0d51b9 --- /dev/null +++ b/http/vendor/getrandom/.cargo_vcs_info.json @@ -0,0 +1,6 @@ +{ + "git": { + "sha1": "b625985d852600a3eeb68556811e59e7c9a6a098" + }, + "path_in_vcs": "" +} \ No newline at end of file diff --git a/http/vendor/getrandom/CHANGELOG.md b/http/vendor/getrandom/CHANGELOG.md new file mode 100644 index 0000000..403f824 --- /dev/null +++ b/http/vendor/getrandom/CHANGELOG.md @@ -0,0 +1,508 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [0.2.17] - 2026-01-12 +### Fixed +- Use `doc_cfg` instead of `doc_auto_cfg` (partial backport of [#732]) [#768] +- `BCryptGenRandom` signature [#778] + +[#732]: https://github.com/rust-random/getrandom/pull/732 +[#768]: https://github.com/rust-random/getrandom/pull/768 +[#778]: https://github.com/rust-random/getrandom/pull/778 + +## [0.2.16] - 2025-04-22 +### Added +- Cygwin support (backport of [#626]) [#654] + +[#626]: https://github.com/rust-random/getrandom/pull/626 +[#654]: https://github.com/rust-random/getrandom/pull/654 + +## [0.2.15] - 2024-05-06 +### Added +- Apple visionOS support [#410] + +### Changed +- Use `libc::getrandom` on DragonflyBSD, FreeBSD, illumos, and Solaris [#411] [#416] [#417] [#420] +- Unify `libc::getentropy`-based implementations [#418] + +[#410]: https://github.com/rust-random/getrandom/pull/410 +[#411]: https://github.com/rust-random/getrandom/pull/411 +[#416]: https://github.com/rust-random/getrandom/pull/416 +[#417]: https://github.com/rust-random/getrandom/pull/417 +[#418]: https://github.com/rust-random/getrandom/pull/418 +[#420]: https://github.com/rust-random/getrandom/pull/420 + +## [0.2.14] - 2024-04-08 +### Fixed +- Enable `/dev/urandom` fallback for MUSL-based Linux targets [#408] + +[#408]: https://github.com/rust-random/getrandom/pull/408 + +## [0.2.13] - 2024-04-06 +### Added +- `linux_disable_fallback` crate feature to disable `/dev/urandom`-based fallback on Linux and + Android targets. Enabling this feature bumps minimum supported Linux kernel version to 3.17 and + Android API level to 23 (Marshmallow). [#396] + +### Changed +- Disable `/dev/urandom` fallback for Linux targets outside of the following `target_arch`es: + `aarch64`, `arm`, `powerpc`, `powerpc64`, `s390x`, `x86`, `x86_64` [#396] +- Do not catch `EPERM` error code on Android while checking availability of + the `getrandom` syscall [#396] + +[#396]: https://github.com/rust-random/getrandom/pull/396 + +## [0.2.12] - 2024-01-09 +### Fixed +- Custom backend for targets without atomics [#385] + +### Changed +- Improve robustness of the Hermit backend and `sys_fill_exact` [#386] +- Raise minimum supported Apple OS versions to macOS 10.12 and iOS 10 [#388] + +### Added +- Document platform support policy [#387] + +[#385]: https://github.com/rust-random/getrandom/pull/385 +[#386]: https://github.com/rust-random/getrandom/pull/386 +[#387]: https://github.com/rust-random/getrandom/pull/387 +[#388]: https://github.com/rust-random/getrandom/pull/388 + +## [0.2.11] - 2023-11-08 +### Added +- GNU/Hurd support [#370] + +### Changed +- Renamed `__getrandom_internal` to `__GETRANDOM_INTERNAL` [#369] +- Updated link to Hermit docs [#374] + +[#369]: https://github.com/rust-random/getrandom/pull/369 +[#370]: https://github.com/rust-random/getrandom/pull/370 +[#374]: https://github.com/rust-random/getrandom/pull/374 + +## [0.2.10] - 2023-06-06 +### Added +- Support for PS Vita (`armv7-sony-vita-newlibeabihf`) [#359] + +### Changed +- Use getentropy from libc on Emscripten targets [#362] + +[#359]: https://github.com/rust-random/getrandom/pull/359 +[#362]: https://github.com/rust-random/getrandom/pull/362 + +## [0.2.9] - 2023-04-06 +### Added +- AIX support [#282] +- `getrandom_uninit` function [#291] +- `wasm64-unknown-unknown` support [#303] +- tvOS and watchOS support [#317] +- QNX/nto support [#325] +- Support for `getrandom` syscall on NetBSD ≥ 10.0 [#331] +- `RtlGenRandom` fallback for non-UWP Windows [#337] + +### Breaking Changes +- Update MSRV to 1.36 [#291] + +### Fixed +- Solaris/OpenBSD/Dragonfly build [#301] + +### Changed +- Update MSRV to 1.36 [#291] +- Use getentropy on Emscripten [#307] +- Solaris: consistantly use `/dev/random` source [#310] +- Move 3ds selection above rdrand/js/custom fallback [#312] +- Remove buffer zeroing from Node.js implementation [#315] +- Use `open` instead of `open64` [#326] +- Remove #cfg from bsd_arandom.rs [#332] +- Hermit: use `sys_read_entropy` syscall [#333] +- Eliminate potential panic in sys_fill_exact [#334] +- rdrand: Remove checking for 0 and !0 and instead check CPU family and do a self-test [#335] +- Move `__getrandom_custom` definition into a const block [#344] +- Switch the custom backend to Rust ABI [#347] + +[#282]: https://github.com/rust-random/getrandom/pull/282 +[#291]: https://github.com/rust-random/getrandom/pull/291 +[#301]: https://github.com/rust-random/getrandom/pull/301 +[#303]: https://github.com/rust-random/getrandom/pull/303 +[#307]: https://github.com/rust-random/getrandom/pull/307 +[#310]: https://github.com/rust-random/getrandom/pull/310 +[#312]: https://github.com/rust-random/getrandom/pull/312 +[#315]: https://github.com/rust-random/getrandom/pull/315 +[#317]: https://github.com/rust-random/getrandom/pull/317 +[#325]: https://github.com/rust-random/getrandom/pull/325 +[#326]: https://github.com/rust-random/getrandom/pull/326 +[#331]: https://github.com/rust-random/getrandom/pull/331 +[#332]: https://github.com/rust-random/getrandom/pull/332 +[#333]: https://github.com/rust-random/getrandom/pull/333 +[#334]: https://github.com/rust-random/getrandom/pull/334 +[#335]: https://github.com/rust-random/getrandom/pull/335 +[#337]: https://github.com/rust-random/getrandom/pull/337 +[#344]: https://github.com/rust-random/getrandom/pull/344 +[#347]: https://github.com/rust-random/getrandom/pull/347 + +## [0.2.8] - 2022-10-20 +### Changed +- The [Web Cryptography API] will now be preferred on `wasm32-unknown-unknown` + when using the `"js"` feature, even on Node.js [#284] [#295] + +### Added +- Added benchmarks to track buffer initialization cost [#272] + +### Fixed +- Use `$crate` in `register_custom_getrandom!` [#270] + +### Documentation +- Add information about enabling `"js"` feature [#280] +- Fix link to `wasm-bindgen` [#278] +- Document the varied implementations for underlying randomness sources [#276] + +[Web Cryptography API]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API +[#284]: https://github.com/rust-random/getrandom/pull/284 +[#295]: https://github.com/rust-random/getrandom/pull/295 +[#272]: https://github.com/rust-random/getrandom/pull/272 +[#270]: https://github.com/rust-random/getrandom/pull/270 +[#280]: https://github.com/rust-random/getrandom/pull/280 +[#278]: https://github.com/rust-random/getrandom/pull/278 +[#276]: https://github.com/rust-random/getrandom/pull/276 + +## [0.2.7] - 2022-06-14 +### Changed +- Update `wasi` dependency to `0.11` [#253] + +### Fixed +- Use `AtomicPtr` instead of `AtomicUsize` for Strict Provenance compatibility. [#263] + +### Documentation +- Add comments explaining use of fallback mechanisms [#257] [#260] + +[#263]: https://github.com/rust-random/getrandom/pull/263 +[#260]: https://github.com/rust-random/getrandom/pull/260 +[#253]: https://github.com/rust-random/getrandom/pull/253 +[#257]: https://github.com/rust-random/getrandom/pull/257 + +## [0.2.6] - 2022-03-28 +### Added +- Nintendo 3DS (`armv6k-nintendo-3ds`) support [#248] + +### Changed +- Retry `open` when interrupted [#252] + +[#248]: https://github.com/rust-random/getrandom/pull/248 +[#252]: https://github.com/rust-random/getrandom/pull/252 + +## [0.2.5] - 2022-02-22 +### Added +- ESP-IDF targets (`*‑espidf`) support [#245] + +### Fixed +- Webpack warning caused by dynamic require [#234] +- Error checking on iOS for `SecRandomCopyBytes` [#244] + +[#234]: https://github.com/rust-random/getrandom/pull/234 +[#244]: https://github.com/rust-random/getrandom/pull/244 +[#245]: https://github.com/rust-random/getrandom/pull/245 + +## [0.2.4] - 2021-12-13 +### Changed +- Use explicit imports in the `js` backend [#220] +- Use `/dev/urandom` on Redox instead of `rand:` [#222] +- Use `NonZeroU32::new_unchecked` to convert wasi error [#233] + +### Added +- SOLID targets (`*-kmc-solid_*`) support [#235] +- Limited Hermit (`x86_64-unknown-hermit`) support [#236] + +[#220]: https://github.com/rust-random/getrandom/pull/220 +[#222]: https://github.com/rust-random/getrandom/pull/222 +[#233]: https://github.com/rust-random/getrandom/pull/233 +[#235]: https://github.com/rust-random/getrandom/pull/235 +[#236]: https://github.com/rust-random/getrandom/pull/236 + +## [0.2.3] - 2021-04-10 +### Changed +- Replace build.rs with link attributes. [#205] +- Add support for getrandom syscall on DragonFly BSD. [#210] +- Improve Node.js detection. [#215] + +[#205]: https://github.com/rust-random/getrandom/pull/205 +[#210]: https://github.com/rust-random/getrandom/pull/210 +[#215]: https://github.com/rust-random/getrandom/pull/215 + +## [0.2.2] - 2021-01-19 +### Changed +- Forward `rustc-dep-of-std` to dependencies. [#198] +- Highlight feature-dependent functionality in documentation using the `doc_cfg` feature. [#200] + +[#198]: https://github.com/rust-random/getrandom/pull/198 +[#200]: https://github.com/rust-random/getrandom/pull/200 + +## [0.2.1] - 2021-01-03 +### Changed +- Update `cfg-if` to v1.0. [#166] +- Update `wasi` to v0.10. [#167] + +### Fixed +- Multithreaded WASM support. [#165] + +### Removed +- Windows XP support. [#177] +- Direct `stdweb` support. [#178] +- CloudABI support. [#184] + +[#165]: https://github.com/rust-random/getrandom/pull/165 +[#166]: https://github.com/rust-random/getrandom/pull/166 +[#167]: https://github.com/rust-random/getrandom/pull/167 +[#177]: https://github.com/rust-random/getrandom/pull/177 +[#178]: https://github.com/rust-random/getrandom/pull/178 +[#184]: https://github.com/rust-random/getrandom/pull/184 + +## [0.2.0] - 2020-09-10 +### Features for using getrandom on unsupported targets + +The following (off by default) Cargo features have been added: +- `"rdrand"` - use the RDRAND instruction on `no_std` `x86`/`x86_64` targets [#133] +- `"js"` - use JavaScript calls on `wasm32-unknown-unknown` [#149] + - Replaces the `stdweb` and `wasm-bindgen` features (which are removed) +- `"custom"` - allows a user to specify a custom implementation [#109] + +### Breaking Changes +- Unsupported targets no longer compile [#107] +- Change/Add `Error` constants [#120] +- Only impl `std` traits when the `"std"` Cargo feature is specified [#106] +- Remove official support for Hermit, L4Re, and UEFI [#133] +- Remove optional `"log"` dependency [#131] +- Update minimum supported Linux kernel to 2.6.32 [#153] +- Update MSRV to 1.34 [#159] + +[#106]: https://github.com/rust-random/getrandom/pull/106 +[#107]: https://github.com/rust-random/getrandom/pull/107 +[#109]: https://github.com/rust-random/getrandom/pull/109 +[#120]: https://github.com/rust-random/getrandom/pull/120 +[#131]: https://github.com/rust-random/getrandom/pull/131 +[#133]: https://github.com/rust-random/getrandom/pull/133 +[#149]: https://github.com/rust-random/getrandom/pull/149 +[#153]: https://github.com/rust-random/getrandom/pull/153 +[#159]: https://github.com/rust-random/getrandom/pull/159 + +## [0.1.16] - 2020-12-31 +### Changed +- Update `cfg-if` to v1.0. [#173] +- Implement `std::error::Error` for the `Error` type on additional targets. [#169] + +### Fixed +- Multithreaded WASM support. [#171] + +[#173]: https://github.com/rust-random/getrandom/pull/173 +[#171]: https://github.com/rust-random/getrandom/pull/171 +[#169]: https://github.com/rust-random/getrandom/pull/169 + +## [0.1.15] - 2020-09-10 +### Changed +- Added support for Internet Explorer 11 [#139] +- Fix Webpack require warning with `wasm-bindgen` [#137] + +[#137]: https://github.com/rust-random/getrandom/pull/137 +[#139]: https://github.com/rust-random/getrandom/pull/139 + +## [0.1.14] - 2020-01-07 +### Changed +- Remove use of spin-locks in the `use_file` module. [#125] +- Update `wasi` to v0.9. [#126] +- Do not read errno value on DragonFlyBSD to fix compilation failure. [#129] + +[#125]: https://github.com/rust-random/getrandom/pull/125 +[#126]: https://github.com/rust-random/getrandom/pull/126 +[#129]: https://github.com/rust-random/getrandom/pull/129 + +## [0.1.13] - 2019-08-25 +### Added +- VxWorks targets support. [#86] + +### Changed +- If zero-length slice is passed to the `getrandom` function, always return +`Ok(())` immediately without doing any calls to the underlying operating +system. [#104] +- Use the `kern.arandom` sysctl on NetBSD. [#115] + +### Fixed +- Bump `cfg-if` minimum version from 0.1.0 to 0.1.2. [#112] +- Typos and bad doc links. [#117] + +[#86]: https://github.com/rust-random/getrandom/pull/86 +[#104]: https://github.com/rust-random/getrandom/pull/104 +[#112]: https://github.com/rust-random/getrandom/pull/112 +[#115]: https://github.com/rust-random/getrandom/pull/115 +[#117]: https://github.com/rust-random/getrandom/pull/117 + +## [0.1.12] - 2019-08-18 +### Changed +- Update wasi dependency from v0.5 to v0.7. [#100] + +[#100]: https://github.com/rust-random/getrandom/pull/100 + +## [0.1.11] - 2019-08-25 +### Fixed +- Implement `std`-dependent traits for selected targets even if `std` +feature is disabled. (backward compatibility with v0.1.8) [#96] + +[#96]: https://github.com/rust-random/getrandom/pull/96 + +## [0.1.10] - 2019-08-18 [YANKED] +### Changed +- Use the dummy implementation on `wasm32-unknown-unknown` even with the +disabled `dummy` feature. [#90] + +### Fixed +- Fix CSP error for `wasm-bindgen`. [#92] + +[#90]: https://github.com/rust-random/getrandom/pull/90 +[#92]: https://github.com/rust-random/getrandom/pull/92 + +## [0.1.9] - 2019-08-14 [YANKED] +### Changed +- Remove `std` dependency for opening and reading files. [#58] +- Use `wasi` instead of `libc` on WASI target. [#64] +- By default emit a compile-time error when built for an unsupported target. +This behaviour can be disabled by using the `dummy` feature. [#71] + +### Added +- Add support for UWP targets. [#69] +- Add unstable `rustc-dep-of-std` feature. [#78] + +[#58]: https://github.com/rust-random/getrandom/pull/58 +[#64]: https://github.com/rust-random/getrandom/pull/64 +[#69]: https://github.com/rust-random/getrandom/pull/69 +[#71]: https://github.com/rust-random/getrandom/pull/71 +[#78]: https://github.com/rust-random/getrandom/pull/78 + +## [0.1.8] - 2019-07-29 +### Changed +- Explicitly specify types to arguments of 'libc::syscall'. [#74] + +[#74]: https://github.com/rust-random/getrandom/pull/74 + +## [0.1.7] - 2019-07-29 +### Added +- Support for hermit and l4re. [#61] +- `Error::raw_os_error` method, `Error::INTERNAL_START` and +`Error::CUSTOM_START` constants. Use `libc` for retrieving OS error descriptions. [#54] + +### Changed +- Remove `lazy_static` dependency and use custom structures for lock-free +initialization. [#51] [#52] +- Try `getrandom()` first on FreeBSD. [#57] + +### Removed +- Bitrig support. [#56] + +### Deprecated +- `Error::UNKNOWN`, `Error::UNAVAILABLE`. [#54] + +[#51]: https://github.com/rust-random/getrandom/pull/51 +[#52]: https://github.com/rust-random/getrandom/pull/52 +[#54]: https://github.com/rust-random/getrandom/pull/54 +[#56]: https://github.com/rust-random/getrandom/pull/56 +[#57]: https://github.com/rust-random/getrandom/pull/57 +[#61]: https://github.com/rust-random/getrandom/pull/61 + +## [0.1.6] - 2019-06-30 +### Changed +- Minor change of RDRAND AMD bug handling. [#48] + +[#48]: https://github.com/rust-random/getrandom/pull/48 + +## [0.1.5] - 2019-06-29 +### Fixed +- Use shared `File` instead of shared file descriptor. [#44] +- Workaround for RDRAND hardware bug present on some AMD CPUs. [#43] + +### Changed +- Try `getentropy` and then fallback to `/dev/random` on macOS. [#38] + +[#38]: https://github.com/rust-random/getrandom/issues/38 +[#43]: https://github.com/rust-random/getrandom/pull/43 +[#44]: https://github.com/rust-random/getrandom/issues/44 + +## [0.1.4] - 2019-06-28 +### Added +- Add support for `x86_64-unknown-uefi` target by using RDRAND with CPUID +feature detection. [#30] + +### Fixed +- Fix long buffer issues on Windows and Linux. [#31] [#32] +- Check `EPERM` in addition to `ENOSYS` on Linux. [#37] + +### Changed +- Improve efficiency by sharing file descriptor across threads. [#13] +- Remove `cloudabi`, `winapi`, and `fuchsia-cprng` dependencies. [#40] +- Improve RDRAND implementation. [#24] +- Don't block during syscall detection on Linux. [#26] +- Increase consistency with libc implementation on FreeBSD. [#36] +- Apply `rustfmt`. [#39] + +[#30]: https://github.com/rust-random/getrandom/pull/30 +[#13]: https://github.com/rust-random/getrandom/issues/13 +[#40]: https://github.com/rust-random/getrandom/pull/40 +[#26]: https://github.com/rust-random/getrandom/pull/26 +[#24]: https://github.com/rust-random/getrandom/pull/24 +[#39]: https://github.com/rust-random/getrandom/pull/39 +[#36]: https://github.com/rust-random/getrandom/pull/36 +[#31]: https://github.com/rust-random/getrandom/issues/31 +[#32]: https://github.com/rust-random/getrandom/issues/32 +[#37]: https://github.com/rust-random/getrandom/issues/37 + +## [0.1.3] - 2019-05-15 +- Update for `wasm32-unknown-wasi` being renamed to `wasm32-wasi`, and for + WASI being categorized as an OS. + +## [0.1.2] - 2019-04-06 +- Add support for `wasm32-unknown-wasi` target. + +## [0.1.1] - 2019-04-05 +- Enable std functionality for CloudABI by default. + +## [0.1.0] - 2019-03-23 +Publish initial implementation. + +## [0.0.0] - 2019-01-19 +Publish an empty template library. + +[0.2.17]: https://github.com/rust-random/getrandom/compare/v0.2.16...v0.2.17 +[0.2.16]: https://github.com/rust-random/getrandom/compare/v0.2.15...v0.2.16 +[0.2.15]: https://github.com/rust-random/getrandom/compare/v0.2.14...v0.2.15 +[0.2.14]: https://github.com/rust-random/getrandom/compare/v0.2.13...v0.2.14 +[0.2.13]: https://github.com/rust-random/getrandom/compare/v0.2.12...v0.2.13 +[0.2.12]: https://github.com/rust-random/getrandom/compare/v0.2.11...v0.2.12 +[0.2.11]: https://github.com/rust-random/getrandom/compare/v0.2.10...v0.2.11 +[0.2.10]: https://github.com/rust-random/getrandom/compare/v0.2.9...v0.2.10 +[0.2.9]: https://github.com/rust-random/getrandom/compare/v0.2.8...v0.2.9 +[0.2.8]: https://github.com/rust-random/getrandom/compare/v0.2.7...v0.2.8 +[0.2.7]: https://github.com/rust-random/getrandom/compare/v0.2.6...v0.2.7 +[0.2.6]: https://github.com/rust-random/getrandom/compare/v0.2.5...v0.2.6 +[0.2.5]: https://github.com/rust-random/getrandom/compare/v0.2.4...v0.2.5 +[0.2.4]: https://github.com/rust-random/getrandom/compare/v0.2.3...v0.2.4 +[0.2.3]: https://github.com/rust-random/getrandom/compare/v0.2.2...v0.2.3 +[0.2.2]: https://github.com/rust-random/getrandom/compare/v0.2.1...v0.2.2 +[0.2.1]: https://github.com/rust-random/getrandom/compare/v0.2.0...v0.2.1 +[0.2.0]: https://github.com/rust-random/getrandom/compare/v0.1.15...v0.2.0 +[0.1.16]: https://github.com/rust-random/getrandom/compare/v0.1.15...v0.1.16 +[0.1.15]: https://github.com/rust-random/getrandom/compare/v0.1.14...v0.1.15 +[0.1.14]: https://github.com/rust-random/getrandom/compare/v0.1.13...v0.1.14 +[0.1.13]: https://github.com/rust-random/getrandom/compare/v0.1.12...v0.1.13 +[0.1.12]: https://github.com/rust-random/getrandom/compare/v0.1.11...v0.1.12 +[0.1.11]: https://github.com/rust-random/getrandom/compare/v0.1.10...v0.1.11 +[0.1.10]: https://github.com/rust-random/getrandom/compare/v0.1.9...v0.1.10 +[0.1.9]: https://github.com/rust-random/getrandom/compare/v0.1.8...v0.1.9 +[0.1.8]: https://github.com/rust-random/getrandom/compare/v0.1.7...v0.1.8 +[0.1.7]: https://github.com/rust-random/getrandom/compare/v0.1.6...v0.1.7 +[0.1.6]: https://github.com/rust-random/getrandom/compare/v0.1.5...v0.1.6 +[0.1.5]: https://github.com/rust-random/getrandom/compare/v0.1.4...v0.1.5 +[0.1.4]: https://github.com/rust-random/getrandom/compare/v0.1.3...v0.1.4 +[0.1.3]: https://github.com/rust-random/getrandom/compare/v0.1.2...v0.1.3 +[0.1.2]: https://github.com/rust-random/getrandom/compare/v0.1.1...v0.1.2 +[0.1.1]: https://github.com/rust-random/getrandom/compare/v0.1.0...v0.1.1 +[0.1.0]: https://github.com/rust-random/getrandom/compare/v0.0.0...v0.1.0 +[0.0.0]: https://github.com/rust-random/getrandom/releases/tag/v0.0.0 diff --git a/http/vendor/getrandom/Cargo.lock b/http/vendor/getrandom/Cargo.lock new file mode 100644 index 0000000..3c978ac --- /dev/null +++ b/http/vendor/getrandom/Cargo.lock @@ -0,0 +1,413 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "async-trait" +version = "0.1.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "bumpalo" +version = "3.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dd9dc738b7a8311c7ade152424974d8115f2cdad61e8dab8dac9f2362298510" + +[[package]] +name = "cast" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" + +[[package]] +name = "cc" +version = "1.2.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd4932aefd12402b36c60956a4fe0035421f544799057659ff86f923657aada3" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "compiler_builtins" +version = "0.1.160" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6376049cfa92c0aa8b9ac95fae22184b981c658208d4ed8a1dc553cd83612895" + +[[package]] +name = "find-msvc-tools" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f449e6c6c08c865631d4890cfacf252b3d396c9bcc83adb6623cdb02a8336c41" + +[[package]] +name = "getrandom" +version = "0.2.17" +dependencies = [ + "cfg-if", + "compiler_builtins", + "js-sys", + "libc", + "rustc-std-workspace-core", + "wasi", + "wasm-bindgen", + "wasm-bindgen-test", +] + +[[package]] +name = "itoa" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" + +[[package]] +name = "js-sys" +version = "0.3.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "464a3709c7f55f1f721e5389aa6ea4e3bc6aba669353300af094b29ffbdde1d8" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "libc" +version = "0.2.180" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc" +dependencies = [ + "rustc-std-workspace-core", +] + +[[package]] +name = "libm" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" + +[[package]] +name = "memchr" +version = "2.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" + +[[package]] +name = "minicov" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4869b6a491569605d66d3952bcdf03df789e5b536e5f0cf7758a7f08a55ae24d" +dependencies = [ + "cc", + "walkdir", +] + +[[package]] +name = "nu-ansi-term" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", + "libm", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "oorandom" +version = "11.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" + +[[package]] +name = "proc-macro2" +version = "1.0.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "535d180e0ecab6268a3e718bb9fd44db66bbbc256257165fc699dadf70d16fe7" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc74d9a594b72ae6656596548f56f667211f8a97b3d4c3d467150794690dc40a" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rustc-std-workspace-alloc" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d441c3b2ebf55cebf796bfdc265d67fa09db17b7bb6bd4be75c509e1e8fec3" + +[[package]] +name = "rustc-std-workspace-core" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa9c45b374136f52f2d6311062c7146bff20fec063c3f5d46a410bd937746955" + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "syn" +version = "2.0.114" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4d107df263a3013ef9b1879b0df87d706ff80f65a86ea879bd9c31f9b307c2a" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" +dependencies = [ + "rustc-std-workspace-alloc", + "rustc-std-workspace-core", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d759f433fa64a2d763d1340820e46e111a7a5ab75f993d1852d70b03dbb80fd" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836d9622d604feee9e5de25ac10e3ea5f2d65b41eac0d9ce72eb5deae707ce7c" +dependencies = [ + "cfg-if", + "js-sys", + "once_cell", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48cb0d2638f8baedbc542ed444afc0644a29166f1595371af4fecf8ce1e7eeb3" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cefb59d5cd5f92d9dcf80e4683949f15ca4b511f4ac0a6e14d4e1ac60c6ecd40" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbc538057e648b67f72a982e708d485b2efa771e1ac05fec311f9f63e5800db4" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wasm-bindgen-test" +version = "0.3.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25e90e66d265d3a1efc0e72a54809ab90b9c0c515915c67cdf658689d2c22c6c" +dependencies = [ + "async-trait", + "cast", + "js-sys", + "libm", + "minicov", + "nu-ansi-term", + "num-traits", + "oorandom", + "serde", + "serde_json", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-bindgen-test-macro", +] + +[[package]] +name = "wasm-bindgen-test-macro" +version = "0.3.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7150335716dce6028bead2b848e72f47b45e7b9422f64cccdc23bedca89affc1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "web-sys" +version = "0.3.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b32828d774c412041098d182a8b38b16ea816958e07cf40eec2bc080ae137ac" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "zmij" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fc5a66a20078bf1251bde995aa2fdcc4b800c70b5d92dd2c62abc5c60f679f8" diff --git a/http/vendor/getrandom/Cargo.toml b/http/vendor/getrandom/Cargo.toml new file mode 100644 index 0000000..626f9cf --- /dev/null +++ b/http/vendor/getrandom/Cargo.toml @@ -0,0 +1,121 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies. +# +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. + +[package] +edition = "2018" +name = "getrandom" +version = "0.2.17" +authors = ["The Rand Project Developers"] +build = false +exclude = [".*"] +autolib = false +autobins = false +autoexamples = false +autotests = false +autobenches = false +description = "A small cross-platform library for retrieving random data from system source" +documentation = "https://docs.rs/getrandom" +readme = "README.md" +categories = [ + "os", + "no-std", +] +license = "MIT OR Apache-2.0" +repository = "https://github.com/rust-random/getrandom" + +[package.metadata.docs.rs] +features = [ + "std", + "custom", +] +rustdoc-args = [ + "--cfg", + "docsrs", +] + +[package.metadata.cross.target.x86_64-unknown-netbsd] +pre-build = [ + "mkdir -p /tmp/netbsd", + "curl https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.2/amd64/binary/sets/base.tar.xz -O", + "tar -C /tmp/netbsd -xJf base.tar.xz", + "cp /tmp/netbsd/usr/lib/libexecinfo.so /usr/local/x86_64-unknown-netbsd/lib", + "rm base.tar.xz", + "rm -rf /tmp/netbsd", +] + +[features] +custom = [] +js = [ + "wasm-bindgen", + "js-sys", +] +linux_disable_fallback = [] +rdrand = [] +rustc-dep-of-std = [ + "compiler_builtins", + "core", + "libc/rustc-dep-of-std", + "wasi/rustc-dep-of-std", +] +std = [] +test-in-browser = [] + +[lib] +name = "getrandom" +path = "src/lib.rs" + +[[test]] +name = "custom" +path = "tests/custom.rs" + +[[test]] +name = "normal" +path = "tests/normal.rs" + +[[test]] +name = "rdrand" +path = "tests/rdrand.rs" + +[[bench]] +name = "buffer" +path = "benches/buffer.rs" + +[dependencies.cfg-if] +version = "1" + +[dependencies.compiler_builtins] +version = "0.1" +optional = true + +[dependencies.core] +version = "1.0" +optional = true +package = "rustc-std-workspace-core" + +[target.'cfg(all(any(target_arch = "wasm32", target_arch = "wasm64"), target_os = "unknown"))'.dependencies.js-sys] +version = "0.3" +optional = true + +[target.'cfg(all(any(target_arch = "wasm32", target_arch = "wasm64"), target_os = "unknown"))'.dependencies.wasm-bindgen] +version = "0.2.62" +optional = true +default-features = false + +[target.'cfg(all(any(target_arch = "wasm32", target_arch = "wasm64"), target_os = "unknown"))'.dev-dependencies.wasm-bindgen-test] +version = "0.3.18" + +[target.'cfg(target_os = "wasi")'.dependencies.wasi] +version = "0.11" +default-features = false + +[target."cfg(unix)".dependencies.libc] +version = "0.2.154" +default-features = false diff --git a/http/vendor/getrandom/Cargo.toml.orig b/http/vendor/getrandom/Cargo.toml.orig new file mode 100644 index 0000000..fa2a05d --- /dev/null +++ b/http/vendor/getrandom/Cargo.toml.orig @@ -0,0 +1,67 @@ +[package] +name = "getrandom" +version = "0.2.17" # Also update html_root_url in lib.rs when bumping this +edition = "2018" +authors = ["The Rand Project Developers"] +license = "MIT OR Apache-2.0" +description = "A small cross-platform library for retrieving random data from system source" +documentation = "https://docs.rs/getrandom" +repository = "https://github.com/rust-random/getrandom" +categories = ["os", "no-std"] +exclude = [".*"] + +[dependencies] +cfg-if = "1" + +# When built as part of libstd +compiler_builtins = { version = "0.1", optional = true } +core = { version = "1.0", optional = true, package = "rustc-std-workspace-core" } + +[target.'cfg(unix)'.dependencies] +libc = { version = "0.2.154", default-features = false } + +[target.'cfg(target_os = "wasi")'.dependencies] +wasi = { version = "0.11", default-features = false } + +[target.'cfg(all(any(target_arch = "wasm32", target_arch = "wasm64"), target_os = "unknown"))'.dependencies] +wasm-bindgen = { version = "0.2.62", default-features = false, optional = true } +js-sys = { version = "0.3", optional = true } +[target.'cfg(all(any(target_arch = "wasm32", target_arch = "wasm64"), target_os = "unknown"))'.dev-dependencies] +wasm-bindgen-test = "0.3.18" + +[features] +# Implement std-only traits for getrandom::Error +std = [] +# Disable `/dev/urandom` fallback for Linux and Android targets. +# Bumps minimum supported Linux kernel version to 3.17 and Android API level to 23 (Marshmallow). +linux_disable_fallback = [] +# Feature to enable fallback RDRAND-based implementation on x86/x86_64 +rdrand = [] +# Feature to enable JavaScript bindings on wasm*-unknown-unknown +js = ["wasm-bindgen", "js-sys"] +# Feature to enable custom RNG implementations +custom = [] +# Unstable feature to support being a libstd dependency +rustc-dep-of-std = [ + "compiler_builtins", + "core", + "libc/rustc-dep-of-std", + "wasi/rustc-dep-of-std", +] +# Unstable/test-only feature to run wasm-bindgen tests in a browser +test-in-browser = [] + +[package.metadata.docs.rs] +features = ["std", "custom"] +rustdoc-args = ["--cfg", "docsrs"] + +# workaround for https://github.com/cross-rs/cross/issues/1345 +[package.metadata.cross.target.x86_64-unknown-netbsd] +pre-build = [ + "mkdir -p /tmp/netbsd", + "curl https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.2/amd64/binary/sets/base.tar.xz -O", + "tar -C /tmp/netbsd -xJf base.tar.xz", + "cp /tmp/netbsd/usr/lib/libexecinfo.so /usr/local/x86_64-unknown-netbsd/lib", + "rm base.tar.xz", + "rm -rf /tmp/netbsd", +] diff --git a/http/vendor/getrandom/LICENSE-APACHE b/http/vendor/getrandom/LICENSE-APACHE new file mode 100644 index 0000000..17d7468 --- /dev/null +++ b/http/vendor/getrandom/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/http/vendor/getrandom/LICENSE-MIT b/http/vendor/getrandom/LICENSE-MIT new file mode 100644 index 0000000..8ca28a1 --- /dev/null +++ b/http/vendor/getrandom/LICENSE-MIT @@ -0,0 +1,26 @@ +Copyright (c) 2018-2024 The rust-random Project Developers +Copyright (c) 2014 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/http/vendor/getrandom/README.md b/http/vendor/getrandom/README.md new file mode 100644 index 0000000..b4b5a2b --- /dev/null +++ b/http/vendor/getrandom/README.md @@ -0,0 +1,81 @@ +# getrandom + +[![Build Status]][GitHub Actions] [![Crate]][crates.io] [![Documentation]][docs.rs] [![Dependency Status]][deps.rs] [![Downloads]][crates.io] [![License]][LICENSE-MIT] + +[GitHub Actions]: https://github.com/rust-random/getrandom/actions?query=workflow:Tests+branch:master +[Build Status]: https://github.com/rust-random/getrandom/actions/workflows/tests.yml/badge.svg?branch=master +[crates.io]: https://crates.io/crates/getrandom +[Crate]: https://img.shields.io/crates/v/getrandom +[docs.rs]: https://docs.rs/getrandom +[Documentation]: https://docs.rs/getrandom/badge.svg +[deps.rs]: https://deps.rs/repo/github/rust-random/getrandom +[Dependency Status]: https://deps.rs/repo/github/rust-random/getrandom/status.svg +[Downloads]: https://img.shields.io/crates/d/getrandom +[LICENSE-MIT]: https://raw.githubusercontent.com/rust-random/getrandom/master/LICENSE-MIT +[License]: https://img.shields.io/crates/l/getrandom + + +A Rust library for retrieving random data from (operating) system sources. It is +assumed that the system always provides high-quality cryptographically secure random +data, ideally backed by hardware entropy sources. This crate derives its name +from Linux's `getrandom` function, but is cross-platform, roughly supporting +the same set of platforms as Rust's `std` lib. + +This is a low-level API. Most users should prefer using high-level random-number +library like [`rand`]. + +[`rand`]: https://crates.io/crates/rand + +## Usage + +Add this to your `Cargo.toml`: + +```toml +[dependencies] +getrandom = "0.2" +``` + +Then invoke the `getrandom` function: + +```rust +fn get_random_buf() -> Result<[u8; 32], getrandom::Error> { + let mut buf = [0u8; 32]; + getrandom::getrandom(&mut buf)?; + Ok(buf) +} +``` + +For more information about supported targets, entropy sources, `no_std` targets, +crate features, WASM support and Custom RNGs see the +[`getrandom` documentation](https://docs.rs/getrandom/latest) and +[`getrandom::Error` documentation](https://docs.rs/getrandom/latest/getrandom/struct.Error.html). + +## Minimum Supported Rust Version + +This crate requires Rust 1.36.0 or later. + +## Platform Support + +This crate generally supports the same operating system and platform versions that the Rust standard library does. +Additional targets may be supported using pluggable custom implementations. + +This means that as Rust drops support for old versions of operating systems (such as old Linux kernel versions, Android API levels, etc) +in stable releases, `getrandom` may create new patch releases (`0.N.x`) that remove support for outdated platform versions. + +## License + +The `getrandom` library is distributed under either of + + * [Apache License, Version 2.0][LICENSE-APACHE] + * [MIT license][LICENSE-MIT] + +at your option. + +### Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in the work by you, as defined in the Apache-2.0 license, shall be +dual licensed as above, without any additional terms or conditions. + +[LICENSE-APACHE]: https://github.com/rust-random/getrandom/blob/master/LICENSE-APACHE +[LICENSE-MIT]: https://github.com/rust-random/getrandom/blob/master/LICENSE-MIT diff --git a/http/vendor/getrandom/SECURITY.md b/http/vendor/getrandom/SECURITY.md new file mode 100644 index 0000000..19bfb9a --- /dev/null +++ b/http/vendor/getrandom/SECURITY.md @@ -0,0 +1,13 @@ +# Security Policy + +## Supported Versions + +Security updates are applied only to the latest release. + +## Reporting a Vulnerability + +If you have discovered a security vulnerability in this project, please report it privately. **Do not disclose it as a public issue.** This gives us time to work with you to fix the issue before public exposure, reducing the chance that the exploit will be used before a patch is released. + +Please disclose it at [security advisory](https://github.com/rust-random/getrandom/security/advisories/new). + +This project is maintained by a team of volunteers on a reasonable-effort basis. As such, please give us at least 90 days to work on a fix before public exposure. diff --git a/http/vendor/getrandom/benches/buffer.rs b/http/vendor/getrandom/benches/buffer.rs new file mode 100644 index 0000000..b32be43 --- /dev/null +++ b/http/vendor/getrandom/benches/buffer.rs @@ -0,0 +1,71 @@ +#![feature(test, maybe_uninit_uninit_array_transpose)] +extern crate test; + +use std::mem::MaybeUninit; + +// Call getrandom on a zero-initialized stack buffer +#[inline(always)] +fn bench_getrandom() { + let mut buf = [0u8; N]; + getrandom::getrandom(&mut buf).unwrap(); + test::black_box(&buf as &[u8]); +} + +// Call getrandom_uninit on an uninitialized stack buffer +#[inline(always)] +fn bench_getrandom_uninit() { + let mut uninit = [MaybeUninit::uninit(); N]; + let buf: &[u8] = getrandom::getrandom_uninit(&mut uninit).unwrap(); + test::black_box(buf); +} + +// We benchmark using #[inline(never)] "inner" functions for two reasons: +// - Avoiding inlining reduces a source of variance when running benchmarks. +// - It is _much_ easier to get the assembly or IR for the inner loop. +// +// For example, using cargo-show-asm (https://github.com/pacak/cargo-show-asm), +// we can get the assembly for a particular benchmark's inner loop by running: +// cargo asm --bench buffer --release buffer::p384::bench_getrandom::inner +macro_rules! bench { + ( $name:ident, $size:expr ) => { + pub mod $name { + #[bench] + pub fn bench_getrandom(b: &mut test::Bencher) { + #[inline(never)] + fn inner() { + super::bench_getrandom::<{ $size }>() + } + + b.bytes = $size as u64; + b.iter(inner); + } + #[bench] + pub fn bench_getrandom_uninit(b: &mut test::Bencher) { + #[inline(never)] + fn inner() { + super::bench_getrandom_uninit::<{ $size }>() + } + + b.bytes = $size as u64; + b.iter(inner); + } + } + }; +} + +// 16 bytes (128 bits) is the size of an 128-bit AES key/nonce. +bench!(aes128, 128 / 8); + +// 32 bytes (256 bits) is the seed sized used for rand::thread_rng +// and the `random` value in a ClientHello/ServerHello for TLS. +// This is also the size of a 256-bit AES/HMAC/P-256/Curve25519 key +// and/or nonce. +bench!(p256, 256 / 8); + +// A P-384/HMAC-384 key and/or nonce. +bench!(p384, 384 / 8); + +// Initializing larger buffers is not the primary use case of this library, as +// this should normally be done by a userspace CSPRNG. However, we have a test +// here to see the effects of a lower (amortized) syscall overhead. +bench!(page, 4096); diff --git a/http/vendor/getrandom/src/apple-other.rs b/http/vendor/getrandom/src/apple-other.rs new file mode 100644 index 0000000..167d8cf --- /dev/null +++ b/http/vendor/getrandom/src/apple-other.rs @@ -0,0 +1,24 @@ +//! Implementation for iOS, tvOS, and watchOS where `getentropy` is unavailable. +use crate::Error; +use core::{ffi::c_void, mem::MaybeUninit}; + +// libsystem contains the libc of Darwin, and every binary ends up linked against it either way. This +// makes it a more lightweight choice compared to `Security.framework`. +extern "C" { + // This RNG uses a thread-local CSPRNG to provide data, which is seeded by the operating system's root CSPRNG. + // Its the best option after `getentropy` on modern Darwin-based platforms that also avoids the + // high startup costs and linking of Security.framework. + // + // While its just an implementation detail, `Security.framework` just calls into this anyway. + fn CCRandomGenerateBytes(bytes: *mut c_void, size: usize) -> i32; +} + +pub fn getrandom_inner(dest: &mut [MaybeUninit]) -> Result<(), Error> { + let ret = unsafe { CCRandomGenerateBytes(dest.as_mut_ptr() as *mut c_void, dest.len()) }; + // kCCSuccess (from CommonCryptoError.h) is always zero. + if ret != 0 { + Err(Error::IOS_SEC_RANDOM) + } else { + Ok(()) + } +} diff --git a/http/vendor/getrandom/src/custom.rs b/http/vendor/getrandom/src/custom.rs new file mode 100644 index 0000000..79be7fc --- /dev/null +++ b/http/vendor/getrandom/src/custom.rs @@ -0,0 +1,105 @@ +//! An implementation which calls out to an externally defined function. +use crate::{util::uninit_slice_fill_zero, Error}; +use core::{mem::MaybeUninit, num::NonZeroU32}; + +/// Register a function to be invoked by `getrandom` on unsupported targets. +/// +/// ## Writing a custom `getrandom` implementation +/// +/// The function to register must have the same signature as +/// [`getrandom::getrandom`](crate::getrandom). The function can be defined +/// wherever you want, either in root crate or a dependent crate. +/// +/// For example, if we wanted a `failure-getrandom` crate containing an +/// implementation that always fails, we would first depend on `getrandom` +/// (for the [`Error`] type) in `failure-getrandom/Cargo.toml`: +/// ```toml +/// [dependencies] +/// getrandom = "0.2" +/// ``` +/// Note that the crate containing this function does **not** need to enable the +/// `"custom"` Cargo feature. +/// +/// Next, in `failure-getrandom/src/lib.rs`, we define our function: +/// ```rust +/// use core::num::NonZeroU32; +/// use getrandom::Error; +/// +/// // Some application-specific error code +/// const MY_CUSTOM_ERROR_CODE: u32 = Error::CUSTOM_START + 42; +/// pub fn always_fail(buf: &mut [u8]) -> Result<(), Error> { +/// let code = NonZeroU32::new(MY_CUSTOM_ERROR_CODE).unwrap(); +/// Err(Error::from(code)) +/// } +/// ``` +/// +/// ## Registering a custom `getrandom` implementation +/// +/// Functions can only be registered in the root binary crate. Attempting to +/// register a function in a non-root crate will result in a linker error. +/// This is similar to +/// [`#[panic_handler]`](https://doc.rust-lang.org/nomicon/panic-handler.html) or +/// [`#[global_allocator]`](https://doc.rust-lang.org/edition-guide/rust-2018/platform-and-target-support/global-allocators.html), +/// where helper crates define handlers/allocators but only the binary crate +/// actually _uses_ the functionality. +/// +/// To register the function, we first depend on `failure-getrandom` _and_ +/// `getrandom` in `Cargo.toml`: +/// ```toml +/// [dependencies] +/// failure-getrandom = "0.1" +/// getrandom = { version = "0.2", features = ["custom"] } +/// ``` +/// +/// Then, we register the function in `src/main.rs`: +/// ```rust +/// # mod failure_getrandom { pub fn always_fail(_: &mut [u8]) -> Result<(), getrandom::Error> { unimplemented!() } } +/// use failure_getrandom::always_fail; +/// use getrandom::register_custom_getrandom; +/// +/// register_custom_getrandom!(always_fail); +/// ``` +/// +/// Now any user of `getrandom` (direct or indirect) on this target will use the +/// registered function. As noted in the +/// [top-level documentation](index.html#custom-implementations) this +/// registration only has an effect on unsupported targets. +#[macro_export] +macro_rules! register_custom_getrandom { + ($path:path) => { + // TODO(MSRV 1.37): change to unnamed block + const __GETRANDOM_INTERNAL: () = { + // We use Rust ABI to be safe against potential panics in the passed function. + #[no_mangle] + unsafe fn __getrandom_custom(dest: *mut u8, len: usize) -> u32 { + // Make sure the passed function has the type of getrandom::getrandom + type F = fn(&mut [u8]) -> ::core::result::Result<(), $crate::Error>; + let _: F = $crate::getrandom; + let f: F = $path; + let slice = ::core::slice::from_raw_parts_mut(dest, len); + match f(slice) { + Ok(()) => 0, + Err(e) => e.code().get(), + } + } + }; + }; +} + +#[allow(dead_code)] +pub fn getrandom_inner(dest: &mut [MaybeUninit]) -> Result<(), Error> { + extern "Rust" { + fn __getrandom_custom(dest: *mut u8, len: usize) -> u32; + } + // Previously we always passed a valid, initialized slice to + // `__getrandom_custom`. Ensure `dest` has been initialized for backward + // compatibility with implementations that rely on that (e.g. Rust + // implementations that construct a `&mut [u8]` slice from `dest` and + // `len`). + let dest = uninit_slice_fill_zero(dest); + let ret = unsafe { __getrandom_custom(dest.as_mut_ptr(), dest.len()) }; + match NonZeroU32::new(ret) { + None => Ok(()), + Some(code) => Err(Error::from(code)), + } +} diff --git a/http/vendor/getrandom/src/error.rs b/http/vendor/getrandom/src/error.rs new file mode 100644 index 0000000..13c81c7 --- /dev/null +++ b/http/vendor/getrandom/src/error.rs @@ -0,0 +1,189 @@ +use core::{fmt, num::NonZeroU32}; + +/// A small and `no_std` compatible error type +/// +/// The [`Error::raw_os_error()`] will indicate if the error is from the OS, and +/// if so, which error code the OS gave the application. If such an error is +/// encountered, please consult with your system documentation. +/// +/// Internally this type is a NonZeroU32, with certain values reserved for +/// certain purposes, see [`Error::INTERNAL_START`] and [`Error::CUSTOM_START`]. +/// +/// *If this crate's `"std"` Cargo feature is enabled*, then: +/// - [`getrandom::Error`][Error] implements +/// [`std::error::Error`](https://doc.rust-lang.org/std/error/trait.Error.html) +/// - [`std::io::Error`](https://doc.rust-lang.org/std/io/struct.Error.html) implements +/// [`From`](https://doc.rust-lang.org/std/convert/trait.From.html). +#[derive(Copy, Clone, Eq, PartialEq)] +pub struct Error(NonZeroU32); + +const fn internal_error(n: u16) -> Error { + // SAFETY: code > 0 as INTERNAL_START > 0 and adding n won't overflow a u32. + let code = Error::INTERNAL_START + (n as u32); + Error(unsafe { NonZeroU32::new_unchecked(code) }) +} + +impl Error { + /// This target/platform is not supported by `getrandom`. + pub const UNSUPPORTED: Error = internal_error(0); + /// The platform-specific `errno` returned a non-positive value. + pub const ERRNO_NOT_POSITIVE: Error = internal_error(1); + /// Encountered an unexpected situation which should not happen in practice. + pub const UNEXPECTED: Error = internal_error(2); + /// Call to [`CCRandomGenerateBytes`](https://opensource.apple.com/source/CommonCrypto/CommonCrypto-60074/include/CommonRandom.h.auto.html) failed + /// on iOS, tvOS, or waatchOS. + // TODO: Update this constant name in the next breaking release. + pub const IOS_SEC_RANDOM: Error = internal_error(3); + /// Call to Windows [`RtlGenRandom`](https://docs.microsoft.com/en-us/windows/win32/api/ntsecapi/nf-ntsecapi-rtlgenrandom) failed. + pub const WINDOWS_RTL_GEN_RANDOM: Error = internal_error(4); + /// RDRAND instruction failed due to a hardware issue. + pub const FAILED_RDRAND: Error = internal_error(5); + /// RDRAND instruction unsupported on this target. + pub const NO_RDRAND: Error = internal_error(6); + /// The environment does not support the Web Crypto API. + pub const WEB_CRYPTO: Error = internal_error(7); + /// Calling Web Crypto API `crypto.getRandomValues` failed. + pub const WEB_GET_RANDOM_VALUES: Error = internal_error(8); + /// On VxWorks, call to `randSecure` failed (random number generator is not yet initialized). + pub const VXWORKS_RAND_SECURE: Error = internal_error(11); + /// Node.js does not have the `crypto` CommonJS module. + pub const NODE_CRYPTO: Error = internal_error(12); + /// Calling Node.js function `crypto.randomFillSync` failed. + pub const NODE_RANDOM_FILL_SYNC: Error = internal_error(13); + /// Called from an ES module on Node.js. This is unsupported, see: + /// . + pub const NODE_ES_MODULE: Error = internal_error(14); + + /// Codes below this point represent OS Errors (i.e. positive i32 values). + /// Codes at or above this point, but below [`Error::CUSTOM_START`] are + /// reserved for use by the `rand` and `getrandom` crates. + pub const INTERNAL_START: u32 = 1 << 31; + + /// Codes at or above this point can be used by users to define their own + /// custom errors. + pub const CUSTOM_START: u32 = (1 << 31) + (1 << 30); + + /// Extract the raw OS error code (if this error came from the OS) + /// + /// This method is identical to [`std::io::Error::raw_os_error()`][1], except + /// that it works in `no_std` contexts. If this method returns `None`, the + /// error value can still be formatted via the `Display` implementation. + /// + /// [1]: https://doc.rust-lang.org/std/io/struct.Error.html#method.raw_os_error + #[inline] + pub fn raw_os_error(self) -> Option { + if self.0.get() < Self::INTERNAL_START { + match () { + #[cfg(target_os = "solid_asp3")] + // On SOLID, negate the error code again to obtain the original + // error code. + () => Some(-(self.0.get() as i32)), + #[cfg(not(target_os = "solid_asp3"))] + () => Some(self.0.get() as i32), + } + } else { + None + } + } + + /// Extract the bare error code. + /// + /// This code can either come from the underlying OS, or be a custom error. + /// Use [`Error::raw_os_error()`] to disambiguate. + #[inline] + pub const fn code(self) -> NonZeroU32 { + self.0 + } +} + +cfg_if! { + if #[cfg(unix)] { + fn os_err(errno: i32, buf: &mut [u8]) -> Option<&str> { + let buf_ptr = buf.as_mut_ptr() as *mut libc::c_char; + if unsafe { libc::strerror_r(errno, buf_ptr, buf.len()) } != 0 { + return None; + } + + // Take up to trailing null byte + let n = buf.len(); + let idx = buf.iter().position(|&b| b == 0).unwrap_or(n); + core::str::from_utf8(&buf[..idx]).ok() + } + } else { + fn os_err(_errno: i32, _buf: &mut [u8]) -> Option<&str> { + None + } + } +} + +impl fmt::Debug for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let mut dbg = f.debug_struct("Error"); + if let Some(errno) = self.raw_os_error() { + dbg.field("os_error", &errno); + let mut buf = [0u8; 128]; + if let Some(err) = os_err(errno, &mut buf) { + dbg.field("description", &err); + } + } else if let Some(desc) = internal_desc(*self) { + dbg.field("internal_code", &self.0.get()); + dbg.field("description", &desc); + } else { + dbg.field("unknown_code", &self.0.get()); + } + dbg.finish() + } +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + if let Some(errno) = self.raw_os_error() { + let mut buf = [0u8; 128]; + match os_err(errno, &mut buf) { + Some(err) => err.fmt(f), + None => write!(f, "OS Error: {}", errno), + } + } else if let Some(desc) = internal_desc(*self) { + f.write_str(desc) + } else { + write!(f, "Unknown Error: {}", self.0.get()) + } + } +} + +impl From for Error { + fn from(code: NonZeroU32) -> Self { + Self(code) + } +} + +fn internal_desc(error: Error) -> Option<&'static str> { + match error { + Error::UNSUPPORTED => Some("getrandom: this target is not supported"), + Error::ERRNO_NOT_POSITIVE => Some("errno: did not return a positive value"), + Error::UNEXPECTED => Some("unexpected situation"), + Error::IOS_SEC_RANDOM => Some("SecRandomCopyBytes: iOS Security framework failure"), + Error::WINDOWS_RTL_GEN_RANDOM => Some("RtlGenRandom: Windows system function failure"), + Error::FAILED_RDRAND => Some("RDRAND: failed multiple times: CPU issue likely"), + Error::NO_RDRAND => Some("RDRAND: instruction not supported"), + Error::WEB_CRYPTO => Some("Web Crypto API is unavailable"), + Error::WEB_GET_RANDOM_VALUES => Some("Calling Web API crypto.getRandomValues failed"), + Error::VXWORKS_RAND_SECURE => Some("randSecure: VxWorks RNG module is not initialized"), + Error::NODE_CRYPTO => Some("Node.js crypto CommonJS module is unavailable"), + Error::NODE_RANDOM_FILL_SYNC => Some("Calling Node.js API crypto.randomFillSync failed"), + Error::NODE_ES_MODULE => Some("Node.js ES modules are not directly supported, see https://docs.rs/getrandom#nodejs-es-module-support"), + _ => None, + } +} + +#[cfg(test)] +mod tests { + use super::Error; + use core::mem::size_of; + + #[test] + fn test_size() { + assert_eq!(size_of::(), 4); + assert_eq!(size_of::>(), 4); + } +} diff --git a/http/vendor/getrandom/src/error_impls.rs b/http/vendor/getrandom/src/error_impls.rs new file mode 100644 index 0000000..2c32601 --- /dev/null +++ b/http/vendor/getrandom/src/error_impls.rs @@ -0,0 +1,15 @@ +extern crate std; + +use crate::Error; +use std::io; + +impl From for io::Error { + fn from(err: Error) -> Self { + match err.raw_os_error() { + Some(errno) => io::Error::from_raw_os_error(errno), + None => io::Error::new(io::ErrorKind::Other, err), + } + } +} + +impl std::error::Error for Error {} diff --git a/http/vendor/getrandom/src/espidf.rs b/http/vendor/getrandom/src/espidf.rs new file mode 100644 index 0000000..7da5ca8 --- /dev/null +++ b/http/vendor/getrandom/src/espidf.rs @@ -0,0 +1,18 @@ +//! Implementation for ESP-IDF +use crate::Error; +use core::{ffi::c_void, mem::MaybeUninit}; + +extern "C" { + fn esp_fill_random(buf: *mut c_void, len: usize) -> u32; +} + +pub fn getrandom_inner(dest: &mut [MaybeUninit]) -> Result<(), Error> { + // Not that NOT enabling WiFi, BT, or the voltage noise entropy source (via `bootloader_random_enable`) + // will cause ESP-IDF to return pseudo-random numbers based on the voltage noise entropy, after the initial boot process: + // https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/random.html + // + // However tracking if some of these entropy sources is enabled is way too difficult to implement here + unsafe { esp_fill_random(dest.as_mut_ptr().cast(), dest.len()) }; + + Ok(()) +} diff --git a/http/vendor/getrandom/src/fuchsia.rs b/http/vendor/getrandom/src/fuchsia.rs new file mode 100644 index 0000000..1197068 --- /dev/null +++ b/http/vendor/getrandom/src/fuchsia.rs @@ -0,0 +1,13 @@ +//! Implementation for Fuchsia Zircon +use crate::Error; +use core::mem::MaybeUninit; + +#[link(name = "zircon")] +extern "C" { + fn zx_cprng_draw(buffer: *mut u8, length: usize); +} + +pub fn getrandom_inner(dest: &mut [MaybeUninit]) -> Result<(), Error> { + unsafe { zx_cprng_draw(dest.as_mut_ptr() as *mut u8, dest.len()) } + Ok(()) +} diff --git a/http/vendor/getrandom/src/getentropy.rs b/http/vendor/getrandom/src/getentropy.rs new file mode 100644 index 0000000..41bab8f --- /dev/null +++ b/http/vendor/getrandom/src/getentropy.rs @@ -0,0 +1,21 @@ +//! Implementation using getentropy(2) +//! +//! Available since: +//! - macOS 10.12 +//! - OpenBSD 5.6 +//! - Emscripten 2.0.5 +//! - vita newlib since Dec 2021 +//! +//! For these targets, we use getentropy(2) because getrandom(2) doesn't exist. +use crate::{util_libc::last_os_error, Error}; +use core::mem::MaybeUninit; + +pub fn getrandom_inner(dest: &mut [MaybeUninit]) -> Result<(), Error> { + for chunk in dest.chunks_mut(256) { + let ret = unsafe { libc::getentropy(chunk.as_mut_ptr() as *mut libc::c_void, chunk.len()) }; + if ret != 0 { + return Err(last_os_error()); + } + } + Ok(()) +} diff --git a/http/vendor/getrandom/src/getrandom.rs b/http/vendor/getrandom/src/getrandom.rs new file mode 100644 index 0000000..bc58365 --- /dev/null +++ b/http/vendor/getrandom/src/getrandom.rs @@ -0,0 +1,25 @@ +//! Implementation using getrandom(2). +//! +//! Available since: +//! - Linux Kernel 3.17, Glibc 2.25, Musl 1.1.20 +//! - Android API level 23 (Marshmallow) +//! - NetBSD 10.0 +//! - FreeBSD 12.0 +//! - illumos since Dec 2018 +//! - DragonFly 5.7 +//! - Hurd Glibc 2.31 +//! - shim-3ds since Feb 2022 +//! +//! For these platforms, we always use the default pool and never set the +//! GRND_RANDOM flag to use the /dev/random pool. On Linux/Android/Hurd, using +//! GRND_RANDOM is not recommended. On NetBSD/FreeBSD/Dragonfly/3ds, it does +//! nothing. On illumos, the default pool is used to implement getentropy(2), +//! so we assume it is acceptable here. +use crate::{util_libc::sys_fill_exact, Error}; +use core::mem::MaybeUninit; + +pub fn getrandom_inner(dest: &mut [MaybeUninit]) -> Result<(), Error> { + sys_fill_exact(dest, |buf| unsafe { + libc::getrandom(buf.as_mut_ptr() as *mut libc::c_void, buf.len(), 0) + }) +} diff --git a/http/vendor/getrandom/src/hermit.rs b/http/vendor/getrandom/src/hermit.rs new file mode 100644 index 0000000..c4f6194 --- /dev/null +++ b/http/vendor/getrandom/src/hermit.rs @@ -0,0 +1,29 @@ +//! Implementation for Hermit +use crate::Error; +use core::{mem::MaybeUninit, num::NonZeroU32}; + +/// Minimum return value which we should get from syscalls in practice, +/// because Hermit uses positive `i32`s for error codes: +/// https://github.com/hermitcore/libhermit-rs/blob/main/src/errno.rs +const MIN_RET_CODE: isize = -(i32::MAX as isize); + +extern "C" { + fn sys_read_entropy(buffer: *mut u8, length: usize, flags: u32) -> isize; +} + +pub fn getrandom_inner(mut dest: &mut [MaybeUninit]) -> Result<(), Error> { + while !dest.is_empty() { + let res = unsafe { sys_read_entropy(dest.as_mut_ptr() as *mut u8, dest.len(), 0) }; + // Positive `isize`s can be safely casted to `usize` + if res > 0 && (res as usize) <= dest.len() { + dest = &mut dest[res as usize..]; + } else { + let err = match res { + MIN_RET_CODE..=-1 => NonZeroU32::new(-res as u32).unwrap().into(), + _ => Error::UNEXPECTED, + }; + return Err(err); + } + } + Ok(()) +} diff --git a/http/vendor/getrandom/src/js.rs b/http/vendor/getrandom/src/js.rs new file mode 100644 index 0000000..e5428f5 --- /dev/null +++ b/http/vendor/getrandom/src/js.rs @@ -0,0 +1,155 @@ +//! Implementation for WASM based on Web and Node.js +use crate::Error; + +extern crate std; +use std::{mem::MaybeUninit, thread_local}; + +use js_sys::{global, Function, Uint8Array}; +use wasm_bindgen::{prelude::wasm_bindgen, JsCast, JsValue}; + +// Size of our temporary Uint8Array buffer used with WebCrypto methods +// Maximum is 65536 bytes see https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues +const WEB_CRYPTO_BUFFER_SIZE: usize = 256; +// Node.js's crypto.randomFillSync requires the size to be less than 2**31. +const NODE_MAX_BUFFER_SIZE: usize = (1 << 31) - 1; + +enum RngSource { + Node(NodeCrypto), + Web(WebCrypto, Uint8Array), +} + +// JsValues are always per-thread, so we initialize RngSource for each thread. +// See: https://github.com/rustwasm/wasm-bindgen/pull/955 +thread_local!( + static RNG_SOURCE: Result = getrandom_init(); +); + +pub(crate) fn getrandom_inner(dest: &mut [MaybeUninit]) -> Result<(), Error> { + RNG_SOURCE.with(|result| { + let source = result.as_ref().map_err(|&e| e)?; + + match source { + RngSource::Node(n) => { + for chunk in dest.chunks_mut(NODE_MAX_BUFFER_SIZE) { + // SAFETY: chunk is never used directly, the memory is only + // modified via the Uint8Array view, which is passed + // directly to JavaScript. Also, crypto.randomFillSync does + // not resize the buffer. We know the length is less than + // u32::MAX because of the chunking above. + // Note that this uses the fact that JavaScript doesn't + // have a notion of "uninitialized memory", this is purely + // a Rust/C/C++ concept. + let res = n.random_fill_sync(unsafe { + Uint8Array::view_mut_raw(chunk.as_mut_ptr() as *mut u8, chunk.len()) + }); + if res.is_err() { + return Err(Error::NODE_RANDOM_FILL_SYNC); + } + } + } + RngSource::Web(crypto, buf) => { + // getRandomValues does not work with all types of WASM memory, + // so we initially write to browser memory to avoid exceptions. + for chunk in dest.chunks_mut(WEB_CRYPTO_BUFFER_SIZE) { + // The chunk can be smaller than buf's length, so we call to + // JS to create a smaller view of buf without allocation. + let sub_buf = buf.subarray(0, chunk.len() as u32); + + if crypto.get_random_values(&sub_buf).is_err() { + return Err(Error::WEB_GET_RANDOM_VALUES); + } + + // SAFETY: `sub_buf`'s length is the same length as `chunk` + unsafe { sub_buf.raw_copy_to_ptr(chunk.as_mut_ptr() as *mut u8) }; + } + } + }; + Ok(()) + }) +} + +fn getrandom_init() -> Result { + let global: Global = global().unchecked_into(); + + // Get the Web Crypto interface if we are in a browser, Web Worker, Deno, + // or another environment that supports the Web Cryptography API. This + // also allows for user-provided polyfills in unsupported environments. + let crypto = match global.crypto() { + // Standard Web Crypto interface + c if c.is_object() => c, + // Node.js CommonJS Crypto module + _ if is_node(&global) => { + // If module.require isn't a valid function, we are in an ES module. + match Module::require_fn().and_then(JsCast::dyn_into::) { + Ok(require_fn) => match require_fn.call1(&global, &JsValue::from_str("crypto")) { + Ok(n) => return Ok(RngSource::Node(n.unchecked_into())), + Err(_) => return Err(Error::NODE_CRYPTO), + }, + Err(_) => return Err(Error::NODE_ES_MODULE), + } + } + // IE 11 Workaround + _ => match global.ms_crypto() { + c if c.is_object() => c, + _ => return Err(Error::WEB_CRYPTO), + }, + }; + + let buf = Uint8Array::new_with_length(WEB_CRYPTO_BUFFER_SIZE as u32); + Ok(RngSource::Web(crypto, buf)) +} + +// Taken from https://www.npmjs.com/package/browser-or-node +fn is_node(global: &Global) -> bool { + let process = global.process(); + if process.is_object() { + let versions = process.versions(); + if versions.is_object() { + return versions.node().is_string(); + } + } + false +} + +#[wasm_bindgen] +extern "C" { + // Return type of js_sys::global() + type Global; + + // Web Crypto API: Crypto interface (https://www.w3.org/TR/WebCryptoAPI/) + type WebCrypto; + // Getters for the WebCrypto API + #[wasm_bindgen(method, getter)] + fn crypto(this: &Global) -> WebCrypto; + #[wasm_bindgen(method, getter, js_name = msCrypto)] + fn ms_crypto(this: &Global) -> WebCrypto; + // Crypto.getRandomValues() + #[wasm_bindgen(method, js_name = getRandomValues, catch)] + fn get_random_values(this: &WebCrypto, buf: &Uint8Array) -> Result<(), JsValue>; + + // Node JS crypto module (https://nodejs.org/api/crypto.html) + type NodeCrypto; + // crypto.randomFillSync() + #[wasm_bindgen(method, js_name = randomFillSync, catch)] + fn random_fill_sync(this: &NodeCrypto, buf: Uint8Array) -> Result<(), JsValue>; + + // Ideally, we would just use `fn require(s: &str)` here. However, doing + // this causes a Webpack warning. So we instead return the function itself + // and manually invoke it using call1. This also lets us to check that the + // function actually exists, allowing for better error messages. See: + // https://github.com/rust-random/getrandom/issues/224 + // https://github.com/rust-random/getrandom/issues/256 + type Module; + #[wasm_bindgen(getter, static_method_of = Module, js_class = module, js_name = require, catch)] + fn require_fn() -> Result; + + // Node JS process Object (https://nodejs.org/api/process.html) + #[wasm_bindgen(method, getter)] + fn process(this: &Global) -> Process; + type Process; + #[wasm_bindgen(method, getter)] + fn versions(this: &Process) -> Versions; + type Versions; + #[wasm_bindgen(method, getter)] + fn node(this: &Versions) -> JsValue; +} diff --git a/http/vendor/getrandom/src/lazy.rs b/http/vendor/getrandom/src/lazy.rs new file mode 100644 index 0000000..100ce1e --- /dev/null +++ b/http/vendor/getrandom/src/lazy.rs @@ -0,0 +1,56 @@ +use core::sync::atomic::{AtomicUsize, Ordering::Relaxed}; + +// This structure represents a lazily initialized static usize value. Useful +// when it is preferable to just rerun initialization instead of locking. +// unsync_init will invoke an init() function until it succeeds, then return the +// cached value for future calls. +// +// unsync_init supports init() "failing". If the init() method returns UNINIT, +// that value will be returned as normal, but will not be cached. +// +// Users should only depend on the _value_ returned by init() functions. +// Specifically, for the following init() function: +// fn init() -> usize { +// a(); +// let v = b(); +// c(); +// v +// } +// the effects of c() or writes to shared memory will not necessarily be +// observed and additional synchronization methods may be needed. +pub(crate) struct LazyUsize(AtomicUsize); + +impl LazyUsize { + pub const fn new() -> Self { + Self(AtomicUsize::new(Self::UNINIT)) + } + + // The initialization is not completed. + pub const UNINIT: usize = usize::max_value(); + + // Runs the init() function at most once, returning the value of some run of + // init(). Multiple callers can run their init() functions in parallel. + // init() should always return the same value, if it succeeds. + pub fn unsync_init(&self, init: impl FnOnce() -> usize) -> usize { + // Relaxed ordering is fine, as we only have a single atomic variable. + let mut val = self.0.load(Relaxed); + if val == Self::UNINIT { + val = init(); + self.0.store(val, Relaxed); + } + val + } +} + +// Identical to LazyUsize except with bool instead of usize. +pub(crate) struct LazyBool(LazyUsize); + +impl LazyBool { + pub const fn new() -> Self { + Self(LazyUsize::new()) + } + + pub fn unsync_init(&self, init: impl FnOnce() -> bool) -> bool { + self.0.unsync_init(|| init() as usize) != 0 + } +} diff --git a/http/vendor/getrandom/src/lib.rs b/http/vendor/getrandom/src/lib.rs new file mode 100644 index 0000000..4d2e4ea --- /dev/null +++ b/http/vendor/getrandom/src/lib.rs @@ -0,0 +1,407 @@ +//! Interface to the operating system's random number generator. +//! +//! # Supported targets +//! +//! | Target | Target Triple | Implementation +//! | ----------------- | ------------------ | -------------- +//! | Linux, Android | `*‑linux‑*` | [`getrandom`][1] system call if available, otherwise [`/dev/urandom`][2] after successfully polling `/dev/random` +//! | Windows | `*‑windows‑*` | [`BCryptGenRandom`] +//! | macOS | `*‑apple‑darwin` | [`getentropy`][3] +//! | iOS, tvOS, watchOS | `*‑apple‑ios`, `*-apple-tvos`, `*-apple-watchos` | [`CCRandomGenerateBytes`] +//! | FreeBSD | `*‑freebsd` | [`getrandom`][5] +//! | OpenBSD | `*‑openbsd` | [`getentropy`][7] +//! | NetBSD | `*‑netbsd` | [`getrandom`][16] if available, otherwise [`kern.arandom`][8] +//! | Dragonfly BSD | `*‑dragonfly` | [`getrandom`][9] +//! | Solaris | `*‑solaris` | [`getrandom`][11] (with `GRND_RANDOM`) +//! | illumos | `*‑illumos` | [`getrandom`][12] +//! | Fuchsia OS | `*‑fuchsia` | [`cprng_draw`] +//! | Redox | `*‑redox` | `/dev/urandom` +//! | Haiku | `*‑haiku` | `/dev/urandom` (identical to `/dev/random`) +//! | Hermit | `*-hermit` | [`sys_read_entropy`] +//! | Hurd | `*-hurd-*` | [`getrandom`][17] +//! | SGX | `x86_64‑*‑sgx` | [`RDRAND`] +//! | VxWorks | `*‑wrs‑vxworks‑*` | `randABytes` after checking entropy pool initialization with `randSecure` +//! | ESP-IDF | `*‑espidf` | [`esp_fill_random`] +//! | Emscripten | `*‑emscripten` | [`getentropy`][13] +//! | WASI | `wasm32‑wasi` | [`random_get`] +//! | Web Browser and Node.js | `wasm*‑*‑unknown` | [`Crypto.getRandomValues`] if available, then [`crypto.randomFillSync`] if on Node.js, see [WebAssembly support] +//! | SOLID | `*-kmc-solid_*` | `SOLID_RNG_SampleRandomBytes` +//! | Nintendo 3DS | `*-nintendo-3ds` | [`getrandom`][18] +//! | PS Vita | `*-vita-*` | [`getentropy`][13] +//! | QNX Neutrino | `*‑nto-qnx*` | [`/dev/urandom`][14] (identical to `/dev/random`) +//! | AIX | `*-ibm-aix` | [`/dev/urandom`][15] +//! | Cygwin | `*-cygwin` | [`getrandom`][19] (based on [`RtlGenRandom`]) +//! +//! Pull Requests that add support for new targets to `getrandom` are always welcome. +//! +//! ## Unsupported targets +//! +//! By default, `getrandom` will not compile on unsupported targets, but certain +//! features allow a user to select a "fallback" implementation if no supported +//! implementation exists. +//! +//! All of the below mechanisms only affect unsupported +//! targets. Supported targets will _always_ use their supported implementations. +//! This prevents a crate from overriding a secure source of randomness +//! (either accidentally or intentionally). +//! +//! ## `/dev/urandom` fallback on Linux and Android +//! +//! On Linux targets the fallback is present only if either `target_env` is `musl`, +//! or `target_arch` is one of the following: `aarch64`, `arm`, `powerpc`, `powerpc64`, +//! `s390x`, `x86`, `x86_64`. Other supported targets [require][platform-support] +//! kernel versions which support `getrandom` system call, so fallback is not needed. +//! +//! On Android targets the fallback is present only for the following `target_arch`es: +//! `aarch64`, `arm`, `x86`, `x86_64`. Other `target_arch`es (e.g. RISC-V) require +//! sufficiently high API levels. +//! +//! The fallback can be disabled by enabling the `linux_disable_fallback` crate feature. +//! Note that doing so will bump minimum supported Linux kernel version to 3.17 and +//! Android API level to 23 (Marshmallow). +//! +//! ### RDRAND on x86 +//! +//! *If the `rdrand` Cargo feature is enabled*, `getrandom` will fallback to using +//! the [`RDRAND`] instruction to get randomness on `no_std` `x86`/`x86_64` +//! targets. This feature has no effect on other CPU architectures. +//! +//! ### WebAssembly support +//! +//! This crate fully supports the +//! [`wasm32-wasi`](https://github.com/CraneStation/wasi) and +//! [`wasm32-unknown-emscripten`](https://www.hellorust.com/setup/emscripten/) +//! targets. However, the `wasm32-unknown-unknown` target (i.e. the target used +//! by `wasm-pack`) is not automatically +//! supported since, from the target name alone, we cannot deduce which +//! JavaScript interface is in use (or if JavaScript is available at all). +//! +//! Instead, *if the `js` Cargo feature is enabled*, this crate will assume +//! that you are building for an environment containing JavaScript, and will +//! call the appropriate methods. Both web browser (main window and Web Workers) +//! and Node.js environments are supported, invoking the methods +//! [described above](#supported-targets) using the [`wasm-bindgen`] toolchain. +//! +//! To enable the `js` Cargo feature, add the following to the `dependencies` +//! section in your `Cargo.toml` file: +//! ```toml +//! [dependencies] +//! getrandom = { version = "0.2", features = ["js"] } +//! ``` +//! +//! This can be done even if `getrandom` is not a direct dependency. Cargo +//! allows crates to enable features for indirect dependencies. +//! +//! This feature should only be enabled for binary, test, or benchmark crates. +//! Library crates should generally not enable this feature, leaving such a +//! decision to *users* of their library. Also, libraries should not introduce +//! their own `js` features *just* to enable `getrandom`'s `js` feature. +//! +//! This feature has no effect on targets other than `wasm32-unknown-unknown`. +//! +//! #### Node.js ES module support +//! +//! Node.js supports both [CommonJS modules] and [ES modules]. Due to +//! limitations in wasm-bindgen's [`module`] support, we cannot directly +//! support ES Modules running on Node.js. However, on Node v15 and later, the +//! module author can add a simple shim to support the Web Cryptography API: +//! ```js +//! import { webcrypto } from 'node:crypto' +//! globalThis.crypto = webcrypto +//! ``` +//! This crate will then use the provided `webcrypto` implementation. +//! +//! ### Platform Support +//! This crate generally supports the same operating system and platform versions +//! that the Rust standard library does. Additional targets may be supported using +//! pluggable custom implementations. +//! +//! This means that as Rust drops support for old versions of operating systems +//! (such as old Linux kernel versions, Android API levels, etc) in stable releases, +//! `getrandom` may create new patch releases (`0.N.x`) that remove support for +//! outdated platform versions. +//! +//! ### Custom implementations +//! +//! The [`register_custom_getrandom!`] macro allows a user to mark their own +//! function as the backing implementation for [`getrandom`]. See the macro's +//! documentation for more information about writing and registering your own +//! custom implementations. +//! +//! Note that registering a custom implementation only has an effect on targets +//! that would otherwise not compile. Any supported targets (including those +//! using `rdrand` and `js` Cargo features) continue using their normal +//! implementations even if a function is registered. +//! +//! ## Early boot +//! +//! Sometimes, early in the boot process, the OS has not collected enough +//! entropy to securely seed its RNG. This is especially common on virtual +//! machines, where standard "random" events are hard to come by. +//! +//! Some operating system interfaces always block until the RNG is securely +//! seeded. This can take anywhere from a few seconds to more than a minute. +//! A few (Linux, NetBSD and Solaris) offer a choice between blocking and +//! getting an error; in these cases, we always choose to block. +//! +//! On Linux (when the `getrandom` system call is not available), reading from +//! `/dev/urandom` never blocks, even when the OS hasn't collected enough +//! entropy yet. To avoid returning low-entropy bytes, we first poll +//! `/dev/random` and only switch to `/dev/urandom` once this has succeeded. +//! +//! On OpenBSD, this kind of entropy accounting isn't available, and on +//! NetBSD, blocking on it is discouraged. On these platforms, nonblocking +//! interfaces are used, even when reliable entropy may not be available. +//! On the platforms where it is used, the reliability of entropy accounting +//! itself isn't free from controversy. This library provides randomness +//! sourced according to the platform's best practices, but each platform has +//! its own limits on the grade of randomness it can promise in environments +//! with few sources of entropy. +//! +//! ## Error handling +//! +//! We always choose failure over returning known insecure "random" bytes. In +//! general, on supported platforms, failure is highly unlikely, though not +//! impossible. If an error does occur, then it is likely that it will occur +//! on every call to `getrandom`, hence after the first successful call one +//! can be reasonably confident that no errors will occur. +//! +//! [1]: https://manned.org/getrandom.2 +//! [2]: https://manned.org/urandom.4 +//! [3]: https://www.unix.com/man-page/mojave/2/getentropy/ +//! [4]: https://www.unix.com/man-page/mojave/4/urandom/ +//! [5]: https://www.freebsd.org/cgi/man.cgi?query=getrandom&manpath=FreeBSD+12.0-stable +//! [7]: https://man.openbsd.org/getentropy.2 +//! [8]: https://man.netbsd.org/sysctl.7 +//! [9]: https://leaf.dragonflybsd.org/cgi/web-man?command=getrandom +//! [11]: https://docs.oracle.com/cd/E88353_01/html/E37841/getrandom-2.html +//! [12]: https://illumos.org/man/2/getrandom +//! [13]: https://github.com/emscripten-core/emscripten/pull/12240 +//! [14]: https://www.qnx.com/developers/docs/7.1/index.html#com.qnx.doc.neutrino.utilities/topic/r/random.html +//! [15]: https://www.ibm.com/docs/en/aix/7.3?topic=files-random-urandom-devices +//! [16]: https://man.netbsd.org/getrandom.2 +//! [17]: https://www.gnu.org/software/libc/manual/html_mono/libc.html#index-getrandom +//! [18]: https://github.com/rust3ds/shim-3ds/commit/b01d2568836dea2a65d05d662f8e5f805c64389d +//! [19]: https://github.com/cygwin/cygwin/blob/main/winsup/cygwin/libc/getentropy.cc +//! +//! [`BCryptGenRandom`]: https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom +//! [`RtlGenRandom`]: https://learn.microsoft.com/en-us/windows/win32/api/ntsecapi/nf-ntsecapi-rtlgenrandom +//! [`Crypto.getRandomValues`]: https://www.w3.org/TR/WebCryptoAPI/#Crypto-method-getRandomValues +//! [`RDRAND`]: https://software.intel.com/en-us/articles/intel-digital-random-number-generator-drng-software-implementation-guide +//! [`CCRandomGenerateBytes`]: https://opensource.apple.com/source/CommonCrypto/CommonCrypto-60074/include/CommonRandom.h.auto.html +//! [`cprng_draw`]: https://fuchsia.dev/fuchsia-src/zircon/syscalls/cprng_draw +//! [`crypto.randomFillSync`]: https://nodejs.org/api/crypto.html#cryptorandomfillsyncbuffer-offset-size +//! [`esp_fill_random`]: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/random.html#_CPPv415esp_fill_randomPv6size_t +//! [`random_get`]: https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md#-random_getbuf-pointeru8-buf_len-size---errno +//! [WebAssembly support]: #webassembly-support +//! [`wasm-bindgen`]: https://github.com/rustwasm/wasm-bindgen +//! [`module`]: https://rustwasm.github.io/wasm-bindgen/reference/attributes/on-js-imports/module.html +//! [CommonJS modules]: https://nodejs.org/api/modules.html +//! [ES modules]: https://nodejs.org/api/esm.html +//! [`sys_read_entropy`]: https://github.com/hermit-os/kernel/blob/315f58ff5efc81d9bf0618af85a59963ff55f8b1/src/syscalls/entropy.rs#L47-L55 +//! [platform-support]: https://doc.rust-lang.org/stable/rustc/platform-support.html + +#![doc( + html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png", + html_favicon_url = "https://www.rust-lang.org/favicon.ico", + html_root_url = "https://docs.rs/getrandom/0.2.17" +)] +#![no_std] +#![warn(rust_2018_idioms, unused_lifetimes, missing_docs)] +#![cfg_attr(docsrs, feature(doc_cfg))] + +#[macro_use] +extern crate cfg_if; + +use crate::util::{slice_as_uninit_mut, slice_assume_init_mut}; +use core::mem::MaybeUninit; + +mod error; +mod util; +// To prevent a breaking change when targets are added, we always export the +// register_custom_getrandom macro, so old Custom RNG crates continue to build. +#[cfg(feature = "custom")] +mod custom; +#[cfg(feature = "std")] +mod error_impls; + +pub use crate::error::Error; + +// System-specific implementations. +// +// These should all provide getrandom_inner with the signature +// `fn getrandom_inner(dest: &mut [MaybeUninit]) -> Result<(), Error>`. +// The function MUST fully initialize `dest` when `Ok(())` is returned. +// The function MUST NOT ever write uninitialized bytes into `dest`, +// regardless of what value it returns. +cfg_if! { + if #[cfg(any(target_os = "haiku", target_os = "redox", target_os = "nto", target_os = "aix"))] { + mod util_libc; + #[path = "use_file.rs"] mod imp; + } else if #[cfg(any( + target_os = "macos", + target_os = "openbsd", + target_os = "vita", + target_os = "emscripten", + ))] { + mod util_libc; + #[path = "getentropy.rs"] mod imp; + } else if #[cfg(any( + target_os = "dragonfly", + target_os = "freebsd", + target_os = "hurd", + target_os = "illumos", + // Check for target_arch = "arm" to only include the 3DS. Does not + // include the Nintendo Switch (which is target_arch = "aarch64"). + all(target_os = "horizon", target_arch = "arm"), + target_os = "cygwin", + ))] { + mod util_libc; + #[path = "getrandom.rs"] mod imp; + } else if #[cfg(all( + not(feature = "linux_disable_fallback"), + any( + // Rust supports Android API level 19 (KitKat) [0] and the next upgrade targets + // level 21 (Lollipop) [1], while `getrandom(2)` was added only in + // level 23 (Marshmallow). Note that it applies only to the "old" `target_arch`es, + // RISC-V Android targets sufficiently new API level, same will apply for potential + // new Android `target_arch`es. + // [0]: https://blog.rust-lang.org/2023/01/09/android-ndk-update-r25.html + // [1]: https://github.com/rust-lang/rust/pull/120593 + all( + target_os = "android", + any( + target_arch = "aarch64", + target_arch = "arm", + target_arch = "x86", + target_arch = "x86_64", + ), + ), + // Only on these `target_arch`es Rust supports Linux kernel versions (3.2+) + // that precede the version (3.17) in which `getrandom(2)` was added: + // https://doc.rust-lang.org/stable/rustc/platform-support.html + all( + target_os = "linux", + any( + target_arch = "aarch64", + target_arch = "arm", + target_arch = "powerpc", + target_arch = "powerpc64", + target_arch = "s390x", + target_arch = "x86", + target_arch = "x86_64", + // Minimum supported Linux kernel version for MUSL targets + // is not specified explicitly (as of Rust 1.77) and they + // are used in practice to target pre-3.17 kernels. + target_env = "musl", + ), + ) + ), + ))] { + mod util_libc; + mod use_file; + mod lazy; + #[path = "linux_android_with_fallback.rs"] mod imp; + } else if #[cfg(any(target_os = "android", target_os = "linux"))] { + mod util_libc; + #[path = "linux_android.rs"] mod imp; + } else if #[cfg(target_os = "solaris")] { + mod util_libc; + #[path = "solaris.rs"] mod imp; + } else if #[cfg(target_os = "netbsd")] { + mod util_libc; + #[path = "netbsd.rs"] mod imp; + } else if #[cfg(target_os = "fuchsia")] { + #[path = "fuchsia.rs"] mod imp; + } else if #[cfg(any(target_os = "ios", target_os = "visionos", target_os = "watchos", target_os = "tvos"))] { + #[path = "apple-other.rs"] mod imp; + } else if #[cfg(all(target_arch = "wasm32", target_os = "wasi"))] { + #[path = "wasi.rs"] mod imp; + } else if #[cfg(target_os = "hermit")] { + #[path = "hermit.rs"] mod imp; + } else if #[cfg(target_os = "vxworks")] { + mod util_libc; + #[path = "vxworks.rs"] mod imp; + } else if #[cfg(target_os = "solid_asp3")] { + #[path = "solid.rs"] mod imp; + } else if #[cfg(target_os = "espidf")] { + #[path = "espidf.rs"] mod imp; + } else if #[cfg(windows)] { + #[path = "windows.rs"] mod imp; + } else if #[cfg(all(target_arch = "x86_64", target_env = "sgx"))] { + mod lazy; + #[path = "rdrand.rs"] mod imp; + } else if #[cfg(all(feature = "rdrand", + any(target_arch = "x86_64", target_arch = "x86")))] { + mod lazy; + #[path = "rdrand.rs"] mod imp; + } else if #[cfg(all(feature = "js", + any(target_arch = "wasm32", target_arch = "wasm64"), + target_os = "unknown"))] { + #[path = "js.rs"] mod imp; + } else if #[cfg(feature = "custom")] { + use custom as imp; + } else if #[cfg(all(any(target_arch = "wasm32", target_arch = "wasm64"), + target_os = "unknown"))] { + compile_error!("the wasm*-unknown-unknown targets are not supported by \ + default, you may need to enable the \"js\" feature. \ + For more information see: \ + https://docs.rs/getrandom/#webassembly-support"); + } else { + compile_error!("target is not supported, for more information see: \ + https://docs.rs/getrandom/#unsupported-targets"); + } +} + +/// Fill `dest` with random bytes from the system's preferred random number +/// source. +/// +/// This function returns an error on any failure, including partial reads. We +/// make no guarantees regarding the contents of `dest` on error. If `dest` is +/// empty, `getrandom` immediately returns success, making no calls to the +/// underlying operating system. +/// +/// Blocking is possible, at least during early boot; see module documentation. +/// +/// In general, `getrandom` will be fast enough for interactive usage, though +/// significantly slower than a user-space CSPRNG; for the latter consider +/// [`rand::thread_rng`](https://docs.rs/rand/*/rand/fn.thread_rng.html). +#[inline] +pub fn getrandom(dest: &mut [u8]) -> Result<(), Error> { + // SAFETY: The `&mut MaybeUninit<_>` reference doesn't escape, and + // `getrandom_uninit` guarantees it will never de-initialize any part of + // `dest`. + getrandom_uninit(unsafe { slice_as_uninit_mut(dest) })?; + Ok(()) +} + +/// Version of the `getrandom` function which fills `dest` with random bytes +/// returns a mutable reference to those bytes. +/// +/// On successful completion this function is guaranteed to return a slice +/// which points to the same memory as `dest` and has the same length. +/// In other words, it's safe to assume that `dest` is initialized after +/// this function has returned `Ok`. +/// +/// No part of `dest` will ever be de-initialized at any point, regardless +/// of what is returned. +/// +/// # Examples +/// +/// ```ignore +/// # // We ignore this test since `uninit_array` is unstable. +/// #![feature(maybe_uninit_uninit_array)] +/// # fn main() -> Result<(), getrandom::Error> { +/// let mut buf = core::mem::MaybeUninit::uninit_array::<1024>(); +/// let buf: &mut [u8] = getrandom::getrandom_uninit(&mut buf)?; +/// # Ok(()) } +/// ``` +#[inline] +pub fn getrandom_uninit(dest: &mut [MaybeUninit]) -> Result<&mut [u8], Error> { + if !dest.is_empty() { + imp::getrandom_inner(dest)?; + } + // SAFETY: `dest` has been fully initialized by `imp::getrandom_inner` + // since it returned `Ok`. + Ok(unsafe { slice_assume_init_mut(dest) }) +} diff --git a/http/vendor/getrandom/src/linux_android.rs b/http/vendor/getrandom/src/linux_android.rs new file mode 100644 index 0000000..93a6494 --- /dev/null +++ b/http/vendor/getrandom/src/linux_android.rs @@ -0,0 +1,7 @@ +//! Implementation for Linux / Android without `/dev/urandom` fallback +use crate::{util_libc, Error}; +use core::mem::MaybeUninit; + +pub fn getrandom_inner(dest: &mut [MaybeUninit]) -> Result<(), Error> { + util_libc::sys_fill_exact(dest, util_libc::getrandom_syscall) +} diff --git a/http/vendor/getrandom/src/linux_android_with_fallback.rs b/http/vendor/getrandom/src/linux_android_with_fallback.rs new file mode 100644 index 0000000..0f5ea8a --- /dev/null +++ b/http/vendor/getrandom/src/linux_android_with_fallback.rs @@ -0,0 +1,33 @@ +//! Implementation for Linux / Android with `/dev/urandom` fallback +use crate::{ + lazy::LazyBool, + util_libc::{getrandom_syscall, last_os_error, sys_fill_exact}, + {use_file, Error}, +}; +use core::mem::MaybeUninit; + +pub fn getrandom_inner(dest: &mut [MaybeUninit]) -> Result<(), Error> { + // getrandom(2) was introduced in Linux 3.17 + static HAS_GETRANDOM: LazyBool = LazyBool::new(); + if HAS_GETRANDOM.unsync_init(is_getrandom_available) { + sys_fill_exact(dest, getrandom_syscall) + } else { + use_file::getrandom_inner(dest) + } +} + +fn is_getrandom_available() -> bool { + if getrandom_syscall(&mut []) < 0 { + match last_os_error().raw_os_error() { + Some(libc::ENOSYS) => false, // No kernel support + // The fallback on EPERM is intentionally not done on Android since this workaround + // seems to be needed only for specific Linux-based products that aren't based + // on Android. See https://github.com/rust-random/getrandom/issues/229. + #[cfg(target_os = "linux")] + Some(libc::EPERM) => false, // Blocked by seccomp + _ => true, + } + } else { + true + } +} diff --git a/http/vendor/getrandom/src/netbsd.rs b/http/vendor/getrandom/src/netbsd.rs new file mode 100644 index 0000000..b8a770f --- /dev/null +++ b/http/vendor/getrandom/src/netbsd.rs @@ -0,0 +1,46 @@ +//! Implementation for NetBSD +use crate::{ + util_libc::{sys_fill_exact, Weak}, + Error, +}; +use core::{mem::MaybeUninit, ptr}; + +fn kern_arnd(buf: &mut [MaybeUninit]) -> libc::ssize_t { + static MIB: [libc::c_int; 2] = [libc::CTL_KERN, libc::KERN_ARND]; + let mut len = buf.len(); + let ret = unsafe { + libc::sysctl( + MIB.as_ptr(), + MIB.len() as libc::c_uint, + buf.as_mut_ptr() as *mut _, + &mut len, + ptr::null(), + 0, + ) + }; + if ret == -1 { + -1 + } else { + len as libc::ssize_t + } +} + +type GetRandomFn = unsafe extern "C" fn(*mut u8, libc::size_t, libc::c_uint) -> libc::ssize_t; + +pub fn getrandom_inner(dest: &mut [MaybeUninit]) -> Result<(), Error> { + // getrandom(2) was introduced in NetBSD 10.0 + static GETRANDOM: Weak = unsafe { Weak::new("getrandom\0") }; + if let Some(fptr) = GETRANDOM.ptr() { + let func: GetRandomFn = unsafe { core::mem::transmute(fptr) }; + return sys_fill_exact(dest, |buf| unsafe { + func(buf.as_mut_ptr() as *mut u8, buf.len(), 0) + }); + } + + // NetBSD will only return up to 256 bytes at a time, and + // older NetBSD kernels will fail on longer buffers. + for chunk in dest.chunks_mut(256) { + sys_fill_exact(chunk, kern_arnd)? + } + Ok(()) +} diff --git a/http/vendor/getrandom/src/rdrand.rs b/http/vendor/getrandom/src/rdrand.rs new file mode 100644 index 0000000..f527c8c --- /dev/null +++ b/http/vendor/getrandom/src/rdrand.rs @@ -0,0 +1,121 @@ +//! RDRAND backend for x86(-64) targets +use crate::{lazy::LazyBool, util::slice_as_uninit, Error}; +use core::mem::{size_of, MaybeUninit}; + +cfg_if! { + if #[cfg(target_arch = "x86_64")] { + use core::arch::x86_64 as arch; + use arch::_rdrand64_step as rdrand_step; + } else if #[cfg(target_arch = "x86")] { + use core::arch::x86 as arch; + use arch::_rdrand32_step as rdrand_step; + } +} + +// Recommendation from "Intel® Digital Random Number Generator (DRNG) Software +// Implementation Guide" - Section 5.2.1 and "Intel® 64 and IA-32 Architectures +// Software Developer’s Manual" - Volume 1 - Section 7.3.17.1. +const RETRY_LIMIT: usize = 10; + +#[target_feature(enable = "rdrand")] +unsafe fn rdrand() -> Option { + for _ in 0..RETRY_LIMIT { + let mut val = 0; + if rdrand_step(&mut val) == 1 { + return Some(val as usize); + } + } + None +} + +// "rdrand" target feature requires "+rdrand" flag, see https://github.com/rust-lang/rust/issues/49653. +#[cfg(all(target_env = "sgx", not(target_feature = "rdrand")))] +compile_error!( + "SGX targets require 'rdrand' target feature. Enable by using -C target-feature=+rdrand." +); + +// Run a small self-test to make sure we aren't repeating values +// Adapted from Linux's test in arch/x86/kernel/cpu/rdrand.c +// Fails with probability < 2^(-90) on 32-bit systems +#[target_feature(enable = "rdrand")] +unsafe fn self_test() -> bool { + // On AMD, RDRAND returns 0xFF...FF on failure, count it as a collision. + let mut prev = !0; // TODO(MSRV 1.43): Move to usize::MAX + let mut fails = 0; + for _ in 0..8 { + match rdrand() { + Some(val) if val == prev => fails += 1, + Some(val) => prev = val, + None => return false, + }; + } + fails <= 2 +} + +fn is_rdrand_good() -> bool { + #[cfg(not(target_feature = "rdrand"))] + { + // SAFETY: All Rust x86 targets are new enough to have CPUID, and we + // check that leaf 1 is supported before using it. + let cpuid0 = unsafe { arch::__cpuid(0) }; + if cpuid0.eax < 1 { + return false; + } + let cpuid1 = unsafe { arch::__cpuid(1) }; + + let vendor_id = [ + cpuid0.ebx.to_le_bytes(), + cpuid0.edx.to_le_bytes(), + cpuid0.ecx.to_le_bytes(), + ]; + if vendor_id == [*b"Auth", *b"enti", *b"cAMD"] { + let mut family = (cpuid1.eax >> 8) & 0xF; + if family == 0xF { + family += (cpuid1.eax >> 20) & 0xFF; + } + // AMD CPUs families before 17h (Zen) sometimes fail to set CF when + // RDRAND fails after suspend. Don't use RDRAND on those families. + // See https://bugzilla.redhat.com/show_bug.cgi?id=1150286 + if family < 0x17 { + return false; + } + } + + const RDRAND_FLAG: u32 = 1 << 30; + if cpuid1.ecx & RDRAND_FLAG == 0 { + return false; + } + } + + // SAFETY: We have already checked that rdrand is available. + unsafe { self_test() } +} + +pub fn getrandom_inner(dest: &mut [MaybeUninit]) -> Result<(), Error> { + static RDRAND_GOOD: LazyBool = LazyBool::new(); + if !RDRAND_GOOD.unsync_init(is_rdrand_good) { + return Err(Error::NO_RDRAND); + } + // SAFETY: After this point, we know rdrand is supported. + unsafe { rdrand_exact(dest) }.ok_or(Error::FAILED_RDRAND) +} + +// TODO: make this function safe when we have feature(target_feature_11) +#[target_feature(enable = "rdrand")] +unsafe fn rdrand_exact(dest: &mut [MaybeUninit]) -> Option<()> { + // We use chunks_exact_mut instead of chunks_mut as it allows almost all + // calls to memcpy to be elided by the compiler. + let mut chunks = dest.chunks_exact_mut(size_of::()); + for chunk in chunks.by_ref() { + let src = rdrand()?.to_ne_bytes(); + chunk.copy_from_slice(slice_as_uninit(&src)); + } + + let tail = chunks.into_remainder(); + let n = tail.len(); + if n > 0 { + let src = rdrand()?.to_ne_bytes(); + tail.copy_from_slice(slice_as_uninit(&src[..n])); + } + Some(()) +} diff --git a/http/vendor/getrandom/src/solaris.rs b/http/vendor/getrandom/src/solaris.rs new file mode 100644 index 0000000..8a3401e --- /dev/null +++ b/http/vendor/getrandom/src/solaris.rs @@ -0,0 +1,34 @@ +//! Solaris implementation using getrandom(2). +//! +//! While getrandom(2) has been available since Solaris 11.3, it has a few +//! quirks not present on other OSes. First, on Solaris 11.3, calls will always +//! fail if bufsz > 1024. Second, it will always either fail or completely fill +//! the buffer (returning bufsz). Third, error is indicated by returning 0, +//! rather than by returning -1. Finally, "if GRND_RANDOM is not specified +//! then getrandom(2) is always a non blocking call". This _might_ imply that +//! in early-boot scenarios with low entropy, getrandom(2) will not properly +//! block. To be safe, we set GRND_RANDOM, mirroring the man page examples. +//! +//! For more information, see the man page linked in lib.rs and this blog post: +//! https://blogs.oracle.com/solaris/post/solaris-new-system-calls-getentropy2-and-getrandom2 +//! which also explains why this crate should not use getentropy(2). +use crate::{util_libc::last_os_error, Error}; +use core::mem::MaybeUninit; + +const MAX_BYTES: usize = 1024; + +pub fn getrandom_inner(dest: &mut [MaybeUninit]) -> Result<(), Error> { + for chunk in dest.chunks_mut(MAX_BYTES) { + let ptr = chunk.as_mut_ptr() as *mut libc::c_void; + let ret = unsafe { libc::getrandom(ptr, chunk.len(), libc::GRND_RANDOM) }; + // In case the man page has a typo, we also check for negative ret. + if ret <= 0 { + return Err(last_os_error()); + } + // If getrandom(2) succeeds, it should have completely filled chunk. + if (ret as usize) != chunk.len() { + return Err(Error::UNEXPECTED); + } + } + Ok(()) +} diff --git a/http/vendor/getrandom/src/solid.rs b/http/vendor/getrandom/src/solid.rs new file mode 100644 index 0000000..cae8caf --- /dev/null +++ b/http/vendor/getrandom/src/solid.rs @@ -0,0 +1,18 @@ +//! Implementation for SOLID +use crate::Error; +use core::{mem::MaybeUninit, num::NonZeroU32}; + +extern "C" { + pub fn SOLID_RNG_SampleRandomBytes(buffer: *mut u8, length: usize) -> i32; +} + +pub fn getrandom_inner(dest: &mut [MaybeUninit]) -> Result<(), Error> { + let ret = unsafe { SOLID_RNG_SampleRandomBytes(dest.as_mut_ptr() as *mut u8, dest.len()) }; + if ret >= 0 { + Ok(()) + } else { + // ITRON error numbers are always negative, so we negate it so that it + // falls in the dedicated OS error range (1..INTERNAL_START). + Err(NonZeroU32::new((-ret) as u32).unwrap().into()) + } +} diff --git a/http/vendor/getrandom/src/use_file.rs b/http/vendor/getrandom/src/use_file.rs new file mode 100644 index 0000000..bd643ae --- /dev/null +++ b/http/vendor/getrandom/src/use_file.rs @@ -0,0 +1,120 @@ +//! Implementations that just need to read from a file +use crate::{ + util_libc::{open_readonly, sys_fill_exact}, + Error, +}; +use core::{ + cell::UnsafeCell, + mem::MaybeUninit, + sync::atomic::{AtomicUsize, Ordering::Relaxed}, +}; + +/// For all platforms, we use `/dev/urandom` rather than `/dev/random`. +/// For more information see the linked man pages in lib.rs. +/// - On Linux, "/dev/urandom is preferred and sufficient in all use cases". +/// - On Redox, only /dev/urandom is provided. +/// - On AIX, /dev/urandom will "provide cryptographically secure output". +/// - On Haiku and QNX Neutrino they are identical. +const FILE_PATH: &str = "/dev/urandom\0"; +const FD_UNINIT: usize = usize::max_value(); + +pub fn getrandom_inner(dest: &mut [MaybeUninit]) -> Result<(), Error> { + let fd = get_rng_fd()?; + sys_fill_exact(dest, |buf| unsafe { + libc::read(fd, buf.as_mut_ptr() as *mut libc::c_void, buf.len()) + }) +} + +// Returns the file descriptor for the device file used to retrieve random +// bytes. The file will be opened exactly once. All subsequent calls will +// return the same file descriptor. This file descriptor is never closed. +fn get_rng_fd() -> Result { + static FD: AtomicUsize = AtomicUsize::new(FD_UNINIT); + fn get_fd() -> Option { + match FD.load(Relaxed) { + FD_UNINIT => None, + val => Some(val as libc::c_int), + } + } + + // Use double-checked locking to avoid acquiring the lock if possible. + if let Some(fd) = get_fd() { + return Ok(fd); + } + + // SAFETY: We use the mutex only in this method, and we always unlock it + // before returning, making sure we don't violate the pthread_mutex_t API. + static MUTEX: Mutex = Mutex::new(); + unsafe { MUTEX.lock() }; + let _guard = DropGuard(|| unsafe { MUTEX.unlock() }); + + if let Some(fd) = get_fd() { + return Ok(fd); + } + + // On Linux, /dev/urandom might return insecure values. + #[cfg(any(target_os = "android", target_os = "linux"))] + wait_until_rng_ready()?; + + let fd = unsafe { open_readonly(FILE_PATH)? }; + // The fd always fits in a usize without conflicting with FD_UNINIT. + debug_assert!(fd >= 0 && (fd as usize) < FD_UNINIT); + FD.store(fd as usize, Relaxed); + + Ok(fd) +} + +// Succeeds once /dev/urandom is safe to read from +#[cfg(any(target_os = "android", target_os = "linux"))] +fn wait_until_rng_ready() -> Result<(), Error> { + // Poll /dev/random to make sure it is ok to read from /dev/urandom. + let fd = unsafe { open_readonly("/dev/random\0")? }; + let mut pfd = libc::pollfd { + fd, + events: libc::POLLIN, + revents: 0, + }; + let _guard = DropGuard(|| unsafe { + libc::close(fd); + }); + + loop { + // A negative timeout means an infinite timeout. + let res = unsafe { libc::poll(&mut pfd, 1, -1) }; + if res >= 0 { + debug_assert_eq!(res, 1); // We only used one fd, and cannot timeout. + return Ok(()); + } + let err = crate::util_libc::last_os_error(); + match err.raw_os_error() { + Some(libc::EINTR) | Some(libc::EAGAIN) => continue, + _ => return Err(err), + } + } +} + +struct Mutex(UnsafeCell); + +impl Mutex { + const fn new() -> Self { + Self(UnsafeCell::new(libc::PTHREAD_MUTEX_INITIALIZER)) + } + unsafe fn lock(&self) { + let r = libc::pthread_mutex_lock(self.0.get()); + debug_assert_eq!(r, 0); + } + unsafe fn unlock(&self) { + let r = libc::pthread_mutex_unlock(self.0.get()); + debug_assert_eq!(r, 0); + } +} + +unsafe impl Sync for Mutex {} + +struct DropGuard(F); + +impl Drop for DropGuard { + fn drop(&mut self) { + self.0() + } +} diff --git a/http/vendor/getrandom/src/util.rs b/http/vendor/getrandom/src/util.rs new file mode 100644 index 0000000..1c4e70b --- /dev/null +++ b/http/vendor/getrandom/src/util.rs @@ -0,0 +1,35 @@ +#![allow(dead_code)] +use core::{mem::MaybeUninit, ptr}; + +/// Polyfill for `maybe_uninit_slice` feature's +/// `MaybeUninit::slice_assume_init_mut`. Every element of `slice` must have +/// been initialized. +#[inline(always)] +pub unsafe fn slice_assume_init_mut(slice: &mut [MaybeUninit]) -> &mut [T] { + // SAFETY: `MaybeUninit` is guaranteed to be layout-compatible with `T`. + &mut *(slice as *mut [MaybeUninit] as *mut [T]) +} + +#[inline] +pub fn uninit_slice_fill_zero(slice: &mut [MaybeUninit]) -> &mut [u8] { + unsafe { ptr::write_bytes(slice.as_mut_ptr(), 0, slice.len()) }; + unsafe { slice_assume_init_mut(slice) } +} + +#[inline(always)] +pub fn slice_as_uninit(slice: &[T]) -> &[MaybeUninit] { + // SAFETY: `MaybeUninit` is guaranteed to be layout-compatible with `T`. + // There is no risk of writing a `MaybeUninit` into the result since + // the result isn't mutable. + unsafe { &*(slice as *const [T] as *const [MaybeUninit]) } +} + +/// View an mutable initialized array as potentially-uninitialized. +/// +/// This is unsafe because it allows assigning uninitialized values into +/// `slice`, which would be undefined behavior. +#[inline(always)] +pub unsafe fn slice_as_uninit_mut(slice: &mut [T]) -> &mut [MaybeUninit] { + // SAFETY: `MaybeUninit` is guaranteed to be layout-compatible with `T`. + &mut *(slice as *mut [T] as *mut [MaybeUninit]) +} diff --git a/http/vendor/getrandom/src/util_libc.rs b/http/vendor/getrandom/src/util_libc.rs new file mode 100644 index 0000000..f488b41 --- /dev/null +++ b/http/vendor/getrandom/src/util_libc.rs @@ -0,0 +1,162 @@ +#![allow(dead_code)] +use crate::Error; +use core::{ + mem::MaybeUninit, + num::NonZeroU32, + ptr::NonNull, + sync::atomic::{fence, AtomicPtr, Ordering}, +}; +use libc::c_void; + +cfg_if! { + if #[cfg(any(target_os = "netbsd", target_os = "openbsd", target_os = "android", target_os = "cygwin"))] { + use libc::__errno as errno_location; + } else if #[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "hurd", target_os = "redox", target_os = "dragonfly"))] { + use libc::__errno_location as errno_location; + } else if #[cfg(any(target_os = "solaris", target_os = "illumos"))] { + use libc::___errno as errno_location; + } else if #[cfg(any(target_os = "macos", target_os = "freebsd"))] { + use libc::__error as errno_location; + } else if #[cfg(target_os = "haiku")] { + use libc::_errnop as errno_location; + } else if #[cfg(target_os = "nto")] { + use libc::__get_errno_ptr as errno_location; + } else if #[cfg(any(all(target_os = "horizon", target_arch = "arm"), target_os = "vita"))] { + extern "C" { + // Not provided by libc: https://github.com/rust-lang/libc/issues/1995 + fn __errno() -> *mut libc::c_int; + } + use __errno as errno_location; + } else if #[cfg(target_os = "aix")] { + use libc::_Errno as errno_location; + } +} + +cfg_if! { + if #[cfg(target_os = "vxworks")] { + use libc::errnoGet as get_errno; + } else { + unsafe fn get_errno() -> libc::c_int { *errno_location() } + } +} + +pub fn last_os_error() -> Error { + let errno = unsafe { get_errno() }; + if errno > 0 { + Error::from(NonZeroU32::new(errno as u32).unwrap()) + } else { + Error::ERRNO_NOT_POSITIVE + } +} + +// Fill a buffer by repeatedly invoking a system call. The `sys_fill` function: +// - should return -1 and set errno on failure +// - should return the number of bytes written on success +pub fn sys_fill_exact( + mut buf: &mut [MaybeUninit], + sys_fill: impl Fn(&mut [MaybeUninit]) -> libc::ssize_t, +) -> Result<(), Error> { + while !buf.is_empty() { + let res = sys_fill(buf); + match res { + res if res > 0 => buf = buf.get_mut(res as usize..).ok_or(Error::UNEXPECTED)?, + -1 => { + let err = last_os_error(); + // We should try again if the call was interrupted. + if err.raw_os_error() != Some(libc::EINTR) { + return Err(err); + } + } + // Negative return codes not equal to -1 should be impossible. + // EOF (ret = 0) should be impossible, as the data we are reading + // should be an infinite stream of random bytes. + _ => return Err(Error::UNEXPECTED), + } + } + Ok(()) +} + +// A "weak" binding to a C function that may or may not be present at runtime. +// Used for supporting newer OS features while still building on older systems. +// Based off of the DlsymWeak struct in libstd: +// https://github.com/rust-lang/rust/blob/1.61.0/library/std/src/sys/unix/weak.rs#L84 +// except that the caller must manually cast self.ptr() to a function pointer. +pub struct Weak { + name: &'static str, + addr: AtomicPtr, +} + +impl Weak { + // A non-null pointer value which indicates we are uninitialized. This + // constant should ideally not be a valid address of a function pointer. + // However, if by chance libc::dlsym does return UNINIT, there will not + // be undefined behavior. libc::dlsym will just be called each time ptr() + // is called. This would be inefficient, but correct. + // TODO: Replace with core::ptr::invalid_mut(1) when that is stable. + const UNINIT: *mut c_void = 1 as *mut c_void; + + // Construct a binding to a C function with a given name. This function is + // unsafe because `name` _must_ be null terminated. + pub const unsafe fn new(name: &'static str) -> Self { + Self { + name, + addr: AtomicPtr::new(Self::UNINIT), + } + } + + // Return the address of a function if present at runtime. Otherwise, + // return None. Multiple callers can call ptr() concurrently. It will + // always return _some_ value returned by libc::dlsym. However, the + // dlsym function may be called multiple times. + pub fn ptr(&self) -> Option> { + // Despite having only a single atomic variable (self.addr), we still + // cannot always use Ordering::Relaxed, as we need to make sure a + // successful call to dlsym() is "ordered before" any data read through + // the returned pointer (which occurs when the function is called). + // Our implementation mirrors that of the one in libstd, meaning that + // the use of non-Relaxed operations is probably unnecessary. + match self.addr.load(Ordering::Relaxed) { + Self::UNINIT => { + let symbol = self.name.as_ptr() as *const _; + let addr = unsafe { libc::dlsym(libc::RTLD_DEFAULT, symbol) }; + // Synchronizes with the Acquire fence below + self.addr.store(addr, Ordering::Release); + NonNull::new(addr) + } + addr => { + let func = NonNull::new(addr)?; + fence(Ordering::Acquire); + Some(func) + } + } + } +} + +// SAFETY: path must be null terminated, FD must be manually closed. +pub unsafe fn open_readonly(path: &str) -> Result { + debug_assert_eq!(path.as_bytes().last(), Some(&0)); + loop { + let fd = libc::open(path.as_ptr() as *const _, libc::O_RDONLY | libc::O_CLOEXEC); + if fd >= 0 { + return Ok(fd); + } + let err = last_os_error(); + // We should try again if open() was interrupted. + if err.raw_os_error() != Some(libc::EINTR) { + return Err(err); + } + } +} + +/// Thin wrapper around the `getrandom()` Linux system call +#[cfg(any(target_os = "android", target_os = "linux"))] +pub fn getrandom_syscall(buf: &mut [MaybeUninit]) -> libc::ssize_t { + unsafe { + libc::syscall( + libc::SYS_getrandom, + buf.as_mut_ptr() as *mut libc::c_void, + buf.len(), + 0, + ) as libc::ssize_t + } +} diff --git a/http/vendor/getrandom/src/vxworks.rs b/http/vendor/getrandom/src/vxworks.rs new file mode 100644 index 0000000..7ca9d6b --- /dev/null +++ b/http/vendor/getrandom/src/vxworks.rs @@ -0,0 +1,29 @@ +//! Implementation for VxWorks +use crate::{util_libc::last_os_error, Error}; +use core::{ + mem::MaybeUninit, + sync::atomic::{AtomicBool, Ordering::Relaxed}, +}; + +pub fn getrandom_inner(dest: &mut [MaybeUninit]) -> Result<(), Error> { + static RNG_INIT: AtomicBool = AtomicBool::new(false); + while !RNG_INIT.load(Relaxed) { + let ret = unsafe { libc::randSecure() }; + if ret < 0 { + return Err(Error::VXWORKS_RAND_SECURE); + } else if ret > 0 { + RNG_INIT.store(true, Relaxed); + break; + } + unsafe { libc::usleep(10) }; + } + + // Prevent overflow of i32 + for chunk in dest.chunks_mut(i32::max_value() as usize) { + let ret = unsafe { libc::randABytes(chunk.as_mut_ptr() as *mut u8, chunk.len() as i32) }; + if ret != 0 { + return Err(last_os_error()); + } + } + Ok(()) +} diff --git a/http/vendor/getrandom/src/wasi.rs b/http/vendor/getrandom/src/wasi.rs new file mode 100644 index 0000000..d6c8a91 --- /dev/null +++ b/http/vendor/getrandom/src/wasi.rs @@ -0,0 +1,17 @@ +//! Implementation for WASI +use crate::Error; +use core::{ + mem::MaybeUninit, + num::{NonZeroU16, NonZeroU32}, +}; +use wasi::random_get; + +pub fn getrandom_inner(dest: &mut [MaybeUninit]) -> Result<(), Error> { + unsafe { random_get(dest.as_mut_ptr() as *mut u8, dest.len()) }.map_err(|e| { + // The WASI errno will always be non-zero, but we check just in case. + match NonZeroU16::new(e.raw()) { + Some(r) => Error::from(NonZeroU32::from(r)), + None => Error::ERRNO_NOT_POSITIVE, + } + }) +} diff --git a/http/vendor/getrandom/src/windows.rs b/http/vendor/getrandom/src/windows.rs new file mode 100644 index 0000000..fa4ba03 --- /dev/null +++ b/http/vendor/getrandom/src/windows.rs @@ -0,0 +1,60 @@ +//! Implementation for Windows +use crate::Error; +use core::{ffi::c_void, mem::MaybeUninit, num::NonZeroU32, ptr}; + +const BCRYPT_USE_SYSTEM_PREFERRED_RNG: u32 = 0x00000002; + +#[link(name = "bcrypt")] +extern "system" { + fn BCryptGenRandom( + hAlgorithm: *mut c_void, + pBuffer: *mut u8, + cbBuffer: u32, + dwFlags: u32, + ) -> i32; +} + +// Forbidden when targetting UWP +#[cfg(not(target_vendor = "uwp"))] +#[link(name = "advapi32")] +extern "system" { + #[link_name = "SystemFunction036"] + fn RtlGenRandom(RandomBuffer: *mut c_void, RandomBufferLength: u32) -> u8; +} + +pub fn getrandom_inner(dest: &mut [MaybeUninit]) -> Result<(), Error> { + // Prevent overflow of u32 + for chunk in dest.chunks_mut(u32::max_value() as usize) { + // BCryptGenRandom was introduced in Windows Vista + let ret = unsafe { + BCryptGenRandom( + ptr::null_mut(), + chunk.as_mut_ptr() as *mut u8, + chunk.len() as u32, + BCRYPT_USE_SYSTEM_PREFERRED_RNG, + ) + }; + let ret = ret as u32; + // NTSTATUS codes use the two highest bits for severity status. + if ret >> 30 == 0b11 { + // Failed. Try RtlGenRandom as a fallback. + #[cfg(not(target_vendor = "uwp"))] + { + let ret = + unsafe { RtlGenRandom(chunk.as_mut_ptr() as *mut c_void, chunk.len() as u32) }; + if ret != 0 { + continue; + } + } + // We zeroize the highest bit, so the error code will reside + // inside the range designated for OS codes. + let code = ret ^ (1 << 31); + // SAFETY: the second highest bit is always equal to one, + // so it's impossible to get zero. Unfortunately the type + // system does not have a way to express this yet. + let code = unsafe { NonZeroU32::new_unchecked(code) }; + return Err(Error::from(code)); + } + } + Ok(()) +} diff --git a/http/vendor/getrandom/tests/common/mod.rs b/http/vendor/getrandom/tests/common/mod.rs new file mode 100644 index 0000000..666f7f5 --- /dev/null +++ b/http/vendor/getrandom/tests/common/mod.rs @@ -0,0 +1,100 @@ +use super::getrandom_impl; + +#[cfg(all(target_arch = "wasm32", target_os = "unknown"))] +use wasm_bindgen_test::wasm_bindgen_test as test; + +#[cfg(feature = "test-in-browser")] +wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser); + +#[test] +fn test_zero() { + // Test that APIs are happy with zero-length requests + getrandom_impl(&mut [0u8; 0]).unwrap(); +} + +// Return the number of bits in which s1 and s2 differ +#[cfg(not(feature = "custom"))] +fn num_diff_bits(s1: &[u8], s2: &[u8]) -> usize { + assert_eq!(s1.len(), s2.len()); + s1.iter() + .zip(s2.iter()) + .map(|(a, b)| (a ^ b).count_ones() as usize) + .sum() +} + +// Tests the quality of calling getrandom on two large buffers +#[test] +#[cfg(not(feature = "custom"))] +fn test_diff() { + let mut v1 = [0u8; 1000]; + getrandom_impl(&mut v1).unwrap(); + + let mut v2 = [0u8; 1000]; + getrandom_impl(&mut v2).unwrap(); + + // Between 3.5 and 4.5 bits per byte should differ. Probability of failure: + // ~ 2^(-94) = 2 * CDF[BinomialDistribution[8000, 0.5], 3500] + let d = num_diff_bits(&v1, &v2); + assert!(d > 3500); + assert!(d < 4500); +} + +// Tests the quality of calling getrandom repeatedly on small buffers +#[test] +#[cfg(not(feature = "custom"))] +fn test_small() { + // For each buffer size, get at least 256 bytes and check that between + // 3 and 5 bits per byte differ. Probability of failure: + // ~ 2^(-91) = 64 * 2 * CDF[BinomialDistribution[8*256, 0.5], 3*256] + for size in 1..=64 { + let mut num_bytes = 0; + let mut diff_bits = 0; + while num_bytes < 256 { + let mut s1 = vec![0u8; size]; + getrandom_impl(&mut s1).unwrap(); + let mut s2 = vec![0u8; size]; + getrandom_impl(&mut s2).unwrap(); + + num_bytes += size; + diff_bits += num_diff_bits(&s1, &s2); + } + assert!(diff_bits > 3 * num_bytes); + assert!(diff_bits < 5 * num_bytes); + } +} + +#[test] +fn test_huge() { + let mut huge = [0u8; 100_000]; + getrandom_impl(&mut huge).unwrap(); +} + +// On WASM, the thread API always fails/panics +#[cfg(not(target_arch = "wasm32"))] +#[test] +fn test_multithreading() { + extern crate std; + use std::{sync::mpsc::channel, thread, vec}; + + let mut txs = vec![]; + for _ in 0..20 { + let (tx, rx) = channel(); + txs.push(tx); + + thread::spawn(move || { + // wait until all the tasks are ready to go. + rx.recv().unwrap(); + let mut v = [0u8; 1000]; + + for _ in 0..100 { + getrandom_impl(&mut v).unwrap(); + thread::yield_now(); + } + }); + } + + // start all the tasks + for tx in txs.iter() { + tx.send(()).unwrap(); + } +} diff --git a/http/vendor/getrandom/tests/custom.rs b/http/vendor/getrandom/tests/custom.rs new file mode 100644 index 0000000..b085094 --- /dev/null +++ b/http/vendor/getrandom/tests/custom.rs @@ -0,0 +1,54 @@ +// Test that a custom handler works on wasm32-unknown-unknown +#![cfg(all( + target_arch = "wasm32", + target_os = "unknown", + feature = "custom", + not(feature = "js") +))] + +use wasm_bindgen_test::wasm_bindgen_test as test; + +use core::num::NonZeroU32; +use getrandom::{getrandom, register_custom_getrandom, Error}; + +fn len7_err() -> Error { + NonZeroU32::new(Error::INTERNAL_START + 7).unwrap().into() +} + +fn super_insecure_rng(buf: &mut [u8]) -> Result<(), Error> { + // `getrandom` guarantees it will not call any implementation if the output + // buffer is empty. + assert!(!buf.is_empty()); + // Length 7 buffers return a custom error + if buf.len() == 7 { + return Err(len7_err()); + } + // Otherwise, fill bytes based on input length + let mut start = buf.len() as u8; + for b in buf { + *b = start; + start = start.wrapping_mul(3); + } + Ok(()) +} + +register_custom_getrandom!(super_insecure_rng); + +use getrandom::getrandom as getrandom_impl; +mod common; + +#[test] +fn custom_rng_output() { + let mut buf = [0u8; 4]; + assert_eq!(getrandom(&mut buf), Ok(())); + assert_eq!(buf, [4, 12, 36, 108]); + + let mut buf = [0u8; 3]; + assert_eq!(getrandom(&mut buf), Ok(())); + assert_eq!(buf, [3, 9, 27]); +} + +#[test] +fn rng_err_output() { + assert_eq!(getrandom(&mut [0; 7]), Err(len7_err())); +} diff --git a/http/vendor/getrandom/tests/normal.rs b/http/vendor/getrandom/tests/normal.rs new file mode 100644 index 0000000..5fff13b --- /dev/null +++ b/http/vendor/getrandom/tests/normal.rs @@ -0,0 +1,11 @@ +// Don't test on custom wasm32-unknown-unknown +#![cfg(not(all( + target_arch = "wasm32", + target_os = "unknown", + feature = "custom", + not(feature = "js") +)))] + +// Use the normal getrandom implementation on this architecture. +use getrandom::getrandom as getrandom_impl; +mod common; diff --git a/http/vendor/getrandom/tests/rdrand.rs b/http/vendor/getrandom/tests/rdrand.rs new file mode 100644 index 0000000..a355c31 --- /dev/null +++ b/http/vendor/getrandom/tests/rdrand.rs @@ -0,0 +1,22 @@ +// We only test the RDRAND-based RNG source on supported architectures. +#![cfg(any(target_arch = "x86_64", target_arch = "x86"))] + +// rdrand.rs expects to be part of the getrandom main crate, so we need these +// additional imports to get rdrand.rs to compile. +use getrandom::Error; +#[macro_use] +extern crate cfg_if; +#[path = "../src/lazy.rs"] +mod lazy; +#[path = "../src/rdrand.rs"] +mod rdrand; +#[path = "../src/util.rs"] +mod util; + +// The rdrand implementation has the signature of getrandom_uninit(), but our +// tests expect getrandom_impl() to have the signature of getrandom(). +fn getrandom_impl(dest: &mut [u8]) -> Result<(), Error> { + rdrand::getrandom_inner(unsafe { util::slice_as_uninit_mut(dest) })?; + Ok(()) +} +mod common; diff --git a/http/vendor/libc/.cargo-checksum.json b/http/vendor/libc/.cargo-checksum.json new file mode 100644 index 0000000..ccc8537 --- /dev/null +++ b/http/vendor/libc/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{".cargo_vcs_info.json":"79f4e131fdc5bb4c9e7e0bd24728a9988a8c5d41a0aac106f906a181d3b6e52f",".editorconfig":"e57fecd6b82cd69640ca1bc4e44f0c7acfe5fc12f641f14af9536e323b4159db",".git-blame-ignore-revs":"761aa385c661241fa77c15b502c361398cf500bbb9f8c3a4579b412c4c6249d7",".release-plz.toml":"fcf2d382c4a2abd96caf9cc391b63e0c94d5832f5c48e9ab9eb4b2c847c0887c",".rustfmt.toml":"c88d9ba0e884291a2904d43cc7b940fafcb1ab443cdb7bcfca7117809c4f2816","CHANGELOG.md":"4a8d73789fafa25546de9333d49eed4a1a2e99075fd323b556bc1f65feb19f53","CONTRIBUTING.md":"a79d97a32ebab59a5d7b360f9f9bd5b8e98b58cd83a7c0853059347f1f81cb53","Cargo.lock":"f73065fee2180d2c25908eb5dadd8a152a7906095b1f2bca0f1da26087d67775","Cargo.toml":"9a45433b9dc5f1dcd397062608a320c2ab472319e79566ea4646dfff3ca67821","Cargo.toml.orig":"1aa1b972f961d26c76f62db1292be9d7fc4d24ccccbe8a3c22ffd3a6fc1c2c8d","LICENSE-APACHE":"62c7a1e35f56406896d7aa7ca52d0cc0d272ac022b5d2796e7d6905db8a3636a","LICENSE-MIT":"123a331b5dbf04c30097fa43b8f858bc85df671fe776de498d01f3d6b7c1f69e","README.md":"cc560a2a9ab2a264fe78ec49fe5e5aed8cffdb8ad011a7dfeaaccbf161696bd8","build.rs":"4b348c53d0a0cd0067ef9887b50f60a1fffdc5d00dda5c0e27fae6aa0ce3dee8","src/fuchsia/aarch64.rs":"34105478e20e9ce40b9e484eea6494e2408fead17c13500da90a2d44d996ce63","src/fuchsia/mod.rs":"b4fc067b8408844fb80be9d017896e41763e2595fcd3526c4fcfed809dd90459","src/fuchsia/riscv64.rs":"a91ae8276df139f6181591be7209f9a68e9f3de5eec881c2e1c9768c53c4e292","src/fuchsia/x86_64.rs":"543ea567b29d646afc026956ee5e652c10e87256789058e7e39f91bf2fe8bf14","src/hermit.rs":"b8e56d680321459a27740aa95fe6576ee6d4e223abce74c0a4795fe998c6c30f","src/lib.rs":"cc2d16d6a06b312913276cb785d637d0755e3afbafc92f18376692dc31e1dc77","src/macros.rs":"e1a7439f50a1d7a47a3268b625e36e7c9a916909f5b3a7fae35217e454e5680c","src/new/aix/mod.rs":"df0de5d8e452a8abb27727b8451b2ceff3bb856f7e5d9e9306df5177e4c6326f","src/new/aix/unistd.rs":"bcbb65f70759cd84c81fc24ea36aac423edb8f9d7148f65b545ee63954411fd1","src/new/apple/libc/signal.rs":"a960b6153775d791055b278534f79e21f8ff76c2c0c2891271e7abdf26e193d3","src/new/apple/libc/unistd.rs":"bcbb65f70759cd84c81fc24ea36aac423edb8f9d7148f65b545ee63954411fd1","src/new/apple/libpthread/mod.rs":"1e99efe513b0ee1fa6e53daf5950fc027380b1d71d793eca9e5b22af7b331b5b","src/new/apple/libpthread/pthread_/introspection.rs":"3c797ded6d1a55670f9537a997407cf2267e6c7e7dbfa360d32474e2432979af","src/new/apple/libpthread/pthread_/pthread.rs":"c2b680120ec8db839e702c4340bc39748ac34c806b5fc08acea0a4593131a015","src/new/apple/libpthread/pthread_/pthread_impl.rs":"57a9925a75b79d092c65288b8a8eb21bfb6c7de4c70d37a49018b4eb8b32a646","src/new/apple/libpthread/pthread_/pthread_spis.rs":"1ba51c251249822fae222db6a19e17278ffffc424fc6eea30282a6171491edbe","src/new/apple/libpthread/pthread_/qos.rs":"40f816fb6cebd19ead21197671e5425b454144515ee4b966d00db32ba6b0dfe5","src/new/apple/libpthread/pthread_/sched.rs":"7b22a3204e72d5013ebac7b830235d50883aefca86d720f1f38b93d54e309477","src/new/apple/libpthread/pthread_/spawn.rs":"daef8af8ed0b3d16922c2f5a511a67f57f69b5f80dfe37362bd0b410213f95ca","src/new/apple/libpthread/pthread_/stack_np.rs":"d1b6e2eab1850c303f8eec4059b3e8ec57d69eb47c216243f6b4b7523761fc29","src/new/apple/libpthread/sys/_pthread/_pthread_types.rs":"a7a4307d7c3f91a6b03f76599fac5f40de556e5652123c6bc3b95df2bfa685de","src/new/apple/libpthread/sys/mod.rs":"337265fe49d77a7dcc879cd23e4f5baedcffab4808433dfb6ab9deb4ab490380","src/new/apple/libpthread/sys/qos.rs":"a6297cbab4089b330416bfcbe13b6d7aa8e75352299295046429b2e9d3bada42","src/new/apple/mod.rs":"45464bc6661b88e55856acb6ce4c47467a9aba44083e42b0e0d87d80ca3c11fd","src/new/apple/xnu/arm/_mcontext.rs":"63f1c62b47e7d7181c2b85f3cd3833c69a29eb0cad37a5754bfa6b5954ae7f6f","src/new/apple/xnu/i386/_mcontext.rs":"50543eaa5cf1d87f900b0c3e531dbfefd7586e1be2be3406223b2319edfcb7f2","src/new/apple/xnu/mach/arm/_structs.rs":"8e4af554170cef61c9143f92a283fd7eef66ad78824f194bbc89b098c6049a43","src/new/apple/xnu/mach/i386/_structs.rs":"d7316b7d3fa5e55a5818cfd8a1977921bb14e07133648cffa8f4d9da2e31a604","src/new/apple/xnu/mach/machine/_structs.rs":"82f5a7f751897c882ed4c378d6282976ff21cf0c9cdf7f3be3cecd369a63b6f8","src/new/apple/xnu/mach/mod.rs":"46aad5c7197df2cc57c4392d9019034236233f0240bc7975f9e22ac33c9d40ed","src/new/apple/xnu/machine/_mcontext.rs":"166b0a450b730e2a943ca08a0c70061effb77ff9eff6f41c7b0c51b2d4215db9","src/new/apple/xnu/mod.rs":"b35c4301d54dd2a207c32750f09f989dcc2de6e470a5cfa936de69c550555c7e","src/new/apple/xnu/sys/_types/_ucontext.rs":"1651132d39042f0fc8cca7a23c890da0031b74359472189f851fb3458f2fde3e","src/new/apple/xnu/sys/mod.rs":"734e1803a311320fd6f0b7b10929fe90a0b27322e792c95d42c620cc59b25563","src/new/apple/xnu/sys/signal.rs":"a03cb64ec19326657c87ff8a5a31c2e6bc1deb55f9a7343ab1b2420819ed72bf","src/new/bionic_libc/mod.rs":"5b2b375123095ae59617ffc1b5e13970ae685c823e3cecf014a173d56162d77c","src/new/bionic_libc/pthread.rs":"d40b7f8421cf78d61f23224c3bda17407e40a1c85dd8122ca4f290624b21d8a1","src/new/bionic_libc/sys/mod.rs":"570e7c97f7c1efb14e167a3f0688547fbc907ed9dca93ad6d90dc719289cb6f1","src/new/bionic_libc/sys/socket.rs":"19877b1de0e235a01734f9aebf20fc1ff1a01fd17302ed1a7d7b520a9fa68edb","src/new/bionic_libc/unistd.rs":"bcbb65f70759cd84c81fc24ea36aac423edb8f9d7148f65b545ee63954411fd1","src/new/common/bsd.rs":"8282cc2b87ca3afc6b01216fe3c3fe1818a3d57e95aa8d1e1a36cc5af1660609","src/new/common/freebsd_like.rs":"156dce9baa6b0ac57d483ffb582a913b9e4944cf10bbb5711a64da5f496a55c2","src/new/common/linux_like/mod.rs":"d42e65b3d6fccd5ba85a8397abb28267a96bfb76b6b47754000fbe9332c03fe4","src/new/common/linux_like/pthread.rs":"a1a33b1e27cd159ab1035c73e72fa8b0c266dd5a28f1079ad74d3c370857f097","src/new/common/mod.rs":"5bcbce2960ff0840ab67a1ba5011009fa1f0f7697cff745d1461bf2b1460ddc6","src/new/common/netbsd_like.rs":"4327dd28d929f2c7b316f9241c44da6f6069d3db4381fb82700ec6d70d749041","src/new/common/posix/mod.rs":"f64b9d7f78e924529c62f2cd78199075eb334e0db9479cb59787f2740bd82d51","src/new/common/posix/pthread.rs":"7bd380ac6cda7940f5e160b6f9d1cf45885f2ba1d7e96014828b13e830eaf230","src/new/common/posix/unistd.rs":"3f633a8c6776d1442f014717785fea3f068d1d3edbfad545d445f8076cb58447","src/new/common/solarish.rs":"ac208e1ad95d07b7528419fd9c573612d58af3d50766816b81667570ccb8b3b3","src/new/cygwin/mod.rs":"9de4cba157252e7731256d60192468f5a759ebd33ab2b509819ffc7557adced5","src/new/cygwin/unistd.rs":"bcbb65f70759cd84c81fc24ea36aac423edb8f9d7148f65b545ee63954411fd1","src/new/dragonfly/mod.rs":"7b96df7e566874a736d0c33ffc9e75a5f80e674da990cb664556728769ff25f9","src/new/dragonfly/unistd.rs":"bcbb65f70759cd84c81fc24ea36aac423edb8f9d7148f65b545ee63954411fd1","src/new/emscripten/mod.rs":"d0ec81b919d9d078bb7d66d9429c08b609e2b0fab512be30aa22cc00fa620660","src/new/emscripten/pthread.rs":"65b51deca94ba18d81608191a5523c37f9508a87a76934006d1173869996531c","src/new/emscripten/sched.rs":"6f0a5b3cefb42bb01feabf34ad92d4bdbe5743263d4cd7b754baf921da81a127","src/new/emscripten/unistd.rs":"bcbb65f70759cd84c81fc24ea36aac423edb8f9d7148f65b545ee63954411fd1","src/new/espidf/mod.rs":"c89c7d3b96583d84888aae0c463dc49b5af61b34a97e9cde52fb9b62d301a023","src/new/freebsd/mod.rs":"cca5cd6815abcaf276799618b748117eee7a6484bc48c629773eaed622188ccc","src/new/freebsd/sys/file.rs":"4dffceca36eaa53c3ace434e4fed1309009448c67ea6684a067a2cf362235e02","src/new/freebsd/sys/mod.rs":"1b064e41914b6e434be2b0c9d3f21f0365eaeeb358a231010c9b817bbd8f730e","src/new/freebsd/unistd.rs":"bcbb65f70759cd84c81fc24ea36aac423edb8f9d7148f65b545ee63954411fd1","src/new/fuchsia/mod.rs":"c15b2da96c52281e86d4f114522999e6e713723f4950d62c2d544be641b28722","src/new/fuchsia/unistd.rs":"bcbb65f70759cd84c81fc24ea36aac423edb8f9d7148f65b545ee63954411fd1","src/new/glibc/mod.rs":"1867ccaee8fe486b3723d683db23b40b2ff0c029c9d6281fd63d6de9de77d4fd","src/new/glibc/posix/unistd.rs":"b8528999ecab0a4883c0d89b1cb3c585a666255ab4a4bf5bfc705f7613edd8f4","src/new/glibc/sysdeps/nptl/mod.rs":"36c75e15c94efdc9db1ff8747cc557b5a314e0e3fdb006581f4a96b322ccde9d","src/new/glibc/sysdeps/nptl/pthread.rs":"b3bb630c736ffbe99081f5bec4c99f50cc36fe159b8059594b1d6965d178936c","src/new/glibc/sysdeps/unix/linux/mod.rs":"9a7c4d5c62c37166b35d2daa69a3dc8f5b4548ef49955463ae41393e260a4cb5","src/new/glibc/sysdeps/unix/linux/net/route.rs":"d8ec70bbaa919692430fdd608b70db11dbfe86b202760727dfd474a4b25b35c2","src/new/glibc/sysdeps/unix/mod.rs":"aa6d2fb4c32f5e1139cae14bcf7cee5935657aeff97df9c064ae9acd67620d04","src/new/haiku/mod.rs":"b3863768692c6da24fc28fdcf0c29a9dd9e3a84f301d4bee6ccc4f802befc4f8","src/new/haiku/unistd.rs":"bcbb65f70759cd84c81fc24ea36aac423edb8f9d7148f65b545ee63954411fd1","src/new/hermit_abi/mod.rs":"25e5d698f292b95057f18dfe203fa96316326e0ca103da532190bb17c29cfdcf","src/new/horizon/mod.rs":"44b47e15d429026d369adfc16a4e9783cdda1be3d0a04f17c283da06573df886","src/new/hurd/mod.rs":"190a149192c237634df3e49c4834d05299aee91a3d399f356d97c36d35571a59","src/new/illumos/mod.rs":"eb5dd158844f63375a6fbb881d63279b12865342d1bb0da221216b7aa9c474b5","src/new/illumos/unistd.rs":"bcbb65f70759cd84c81fc24ea36aac423edb8f9d7148f65b545ee63954411fd1","src/new/l4re/mod.rs":"d0cd277d7c0b32cd5d3619f7a188f3e646da8f71ae07012dccd921b3fb2b2300","src/new/linux_uapi/linux/can.rs":"b30565ca3a98f76f98a6410fdd0649336270aa1ae4c677d1ce0d67a9be8803ee","src/new/linux_uapi/linux/can/bcm.rs":"1718a1c3aae686d18ec83dff1560439d61de244bfaf332256cc2b42b85fe5249","src/new/linux_uapi/linux/can/error.rs":"5c5ef6d7c2b9432ebbf6147f96cd260e10686f449f879e64db4757670a6ec638","src/new/linux_uapi/linux/can/j1939.rs":"ab2a330c3d3cca3ac6a693b381661772036e10a6dc0004db3809a4f42cf724ba","src/new/linux_uapi/linux/can/netlink.rs":"2d90a0cb5dc9a15365c99c5101db1698f2da2df66704cfefdafd06252bcabe3e","src/new/linux_uapi/linux/can/raw.rs":"933ed151ce976b869b239abc031bb626dd3fa48ec3dd63d2c2b1b891c7bedf1c","src/new/linux_uapi/linux/keyctl.rs":"c25ee20a54a14d56de2c886c32f718b7a403b18152cc81bd7726f974cdf5b3a3","src/new/linux_uapi/linux/membarrier.rs":"5d6b55b1f7410aeb24ce6bcdbac0d33144b14dc048641ebccb5adc697ea7de2f","src/new/linux_uapi/linux/mod.rs":"c17b121acb9e3bd807ab58e532a19bf76f7a19a38ae94e7812beb14ddc3362b0","src/new/linux_uapi/linux/netlink.rs":"1ee00c018a23cac0ade157d6c725b3e6f0b69b23b46b9690c5ab398c889527b7","src/new/linux_uapi/linux/pidfd.rs":"6500c63d1ccaf4b7e14a36f225fd309bce9de80a50b81bca14bc6bded6ebd04e","src/new/linux_uapi/mod.rs":"76cc081d46d008fe05fbb3d7f007fb62374d4efd9464916bbeb9b20c288c6416","src/new/mod.rs":"360bd97f6f1cc19143289c05c0f9e3b86029918f6d9ed78d09c752c81a53ae6c","src/new/musl/arch/generic/mod.rs":"106383ed35cb7526bbbb0e16ce3521ddb2a9e61fb533687922fc9b43cd654af7","src/new/musl/arch/mips/bits/socket.rs":"eb4dff2ab581eb893e0e6547ae7a7d86453caa069b61272a818256280a23ca71","src/new/musl/arch/mips/mod.rs":"cc6c0a24ef77b7c404887fb5b7a7fd15c2a79e2a3396531ea0058636cacb3018","src/new/musl/arch/mips64/bits/socket.rs":"eb4dff2ab581eb893e0e6547ae7a7d86453caa069b61272a818256280a23ca71","src/new/musl/arch/mips64/mod.rs":"40242447a56ed21249f0417f87a7ccd074a366f19eb1353d94e904f370e0f20f","src/new/musl/arch/mod.rs":"31a73fedfd8606e04352425fb4917181f2d7376f445cb61a5460bd682ce29ed4","src/new/musl/mod.rs":"6b2e092bdc907d2d236a5f6ad977d931e13e99425a3738a62769220697cc13de","src/new/musl/pthread.rs":"e76e8f71cba55b45e4aa954970f939142595b828fd7e83586fc9145299a3b1cb","src/new/musl/sched.rs":"6f0a5b3cefb42bb01feabf34ad92d4bdbe5743263d4cd7b754baf921da81a127","src/new/musl/sys/socket.rs":"ed9de77a5937115aada325ce3d68b31e24e7ac21691dc2cb52c4e4695aa1e1dd","src/new/musl/unistd.rs":"bcbb65f70759cd84c81fc24ea36aac423edb8f9d7148f65b545ee63954411fd1","src/new/netbsd/mod.rs":"d7bddddf98b09188a6fe541feaaaecdee85eb55fee2aa3cf670f7e6afa4ac342","src/new/netbsd/net/if_.rs":"5083d0f9d84de47c8b6fae60c9bb74d7c0586a80ccb8d625e5e2b4876e7f9444","src/new/netbsd/sys/file.rs":"a30095d85a4f8af49494f9b38114415f5c30e1d96a8c882eb7efd83a1cb6816a","src/new/netbsd/sys/ipc.rs":"91af85c26b3dca2a0661c820871d176baf29c00d53540f4807b9b28f9f3dfae4","src/new/netbsd/sys/mod.rs":"2dfbbf18e7585b64acfeb2f39d0495b50c142caec680db64bb4655e182347262","src/new/netbsd/sys/socket.rs":"a926087991d4cd7ebe31a3f626b5a196047c20955e9e3c99f5abe50b899b1ef3","src/new/netbsd/sys/statvfs.rs":"875c73a2c18ef78c7363b2196282579b88beca2d42ed24bda4fe8e7800db9bd4","src/new/netbsd/sys/time.rs":"7d420d5384e13ca361aaf9a7fc9faafe29a55b216988c8252a891d2232407a0c","src/new/netbsd/sys/timex.rs":"1b476328c16ce06e316485bd9dc751f31e51f63d0c07e438bf3227e66da07768","src/new/netbsd/sys/types.rs":"a0ec3ac038f0026c285ebfd869a8ae062117b1ff29855cbcf570f7f55860c854","src/new/netbsd/unistd.rs":"bcbb65f70759cd84c81fc24ea36aac423edb8f9d7148f65b545ee63954411fd1","src/new/netbsd/utmp_.rs":"cbd35108f4ad7fd3c4fc65b888ba7813a29e3ed4af7920604df8085345f81973","src/new/netbsd/utmpx_.rs":"27171f826d6d2bf962a1d973a3427477ae960ad5dccc947c481d45f17ae645f0","src/new/newlib/mod.rs":"046372b698393e20436c85b28dac6f02b5cc7d599d134637bbdaa89f2530d1a6","src/new/newlib/unistd.rs":"15e74fb2c22e2343faa06a7a61baca198d7867cd70f8a4ead6cdc1f4fae24905","src/new/nto/mod.rs":"2e80a71385d3344a5f0b95b8d509148b52ea1a253d87e8f27345956d119f7e58","src/new/nto/net/bpf.rs":"1ee0b92315fb2926085777a024cb92d7c1f71328eca1af09a3db0417f180d263","src/new/nto/net/if_.rs":"cdea96569bb155c7372da481dbf00630aadfadb68ef07bfe94d258a6c600b82b","src/new/nto/unistd.rs":"bcbb65f70759cd84c81fc24ea36aac423edb8f9d7148f65b545ee63954411fd1","src/new/nuttx/mod.rs":"7dbbf039987cb5ca17d2a1a562dc967de1c31b970568f728339cd5b9c8e05e25","src/new/nuttx/unistd.rs":"bcbb65f70759cd84c81fc24ea36aac423edb8f9d7148f65b545ee63954411fd1","src/new/openbsd/mod.rs":"7d86ff099ddfdc8c383f49a1f6fa9c1169810cbe0c1c57d0e86dc14cb1d87320","src/new/openbsd/sys/ipc.rs":"dd37c821138dbf723d637319ad0849e9ed0b2fce1d498e7e38627a8b0a8bf142","src/new/openbsd/sys/mod.rs":"a8fd8f1cb50bffb34db04d1040048e7c23043fea834c1915453b5d539034a845","src/new/openbsd/unistd.rs":"bcbb65f70759cd84c81fc24ea36aac423edb8f9d7148f65b545ee63954411fd1","src/new/qurt/dlfcn.rs":"8bfec94f78786e2eee9d4306efbf9ad977cf2b3f0d930f8cc65186e922371a9a","src/new/qurt/errno.rs":"2456f7f7557e4716f8b65b1ef67281f795c70ad1d5515d6b001d26c07b943af3","src/new/qurt/fcntl.rs":"ce176e0c9fb6799004cfc9f1fe5eb20ab7226cf8d304bf8ae9cfe4e3f37ad680","src/new/qurt/limits.rs":"5c76ea0d9560d5da65fe7ecaba8e45766dd56b203523979359e5436062306359","src/new/qurt/mod.rs":"6325ef45b6ad49aaba335a52b85a90eceaf5b2d782c06210edefc1999c1fcf99","src/new/qurt/pthread.rs":"8e64d22f2c73ea8559bd7c4de5d21b077969638e1e12c979c1d77c1a2ea2aaf2","src/new/qurt/semaphore.rs":"eb995a92cdead52ee61c3f498c7e408430b8430cd6cb6be74b47e6728c6773ae","src/new/qurt/signal.rs":"3d9b0cdba135af86fed0846b710fef48edba54a034e14147c7e7785db282a335","src/new/qurt/stdio.rs":"280e1faa29c7e2749469a9f9c4b0fa4ba8e0cee42a6e53d9376be6b8e3b8c2ff","src/new/qurt/stdlib.rs":"7d2aad4837a4be08083be8153ecf3e95d8c70469598fbad25793c4cfed1939d8","src/new/qurt/sys/mman.rs":"c0b862bf262564507796b1cdda967c601d265e6a1f1abfe1a5b6d45aa0742df6","src/new/qurt/sys/mod.rs":"e8585c4d447d02d1f4b72183e3d8b8c0d57301ca7099534ce2086a7a3d384b7d","src/new/qurt/sys/sched.rs":"12dfe86d5bb8c96a8624b3a408df7bc1595dfc71ca870e9ea586f68a32bc67f6","src/new/qurt/sys/stat.rs":"bbd98cd523dfc7e34c163bc2d397be8ed08401fe24d85d617b581d31e5bdb708","src/new/qurt/sys/types.rs":"c23c7f02eaa198f04991f0dede9e55279effd49ec4a341fb13064f68c19f24ca","src/new/qurt/time.rs":"598e21d7205714c2f8c92e7dd1f6f7162d5552c453ac68aeb3d38346cff52e4a","src/new/qurt/unistd.rs":"49b2b023a1276f9de2e093f03609e8cb5b0cefa9f0ea96b5bf3009d159b0dcd8","src/new/redox/mod.rs":"aaeaa40c0bffde42973cd1809c1c845075f92fac95a074fe3d01d4fb02dc0992","src/new/relibc/mod.rs":"5c6955e052d8b7ead97179e356c369ffcc435e09fcca4def3e100568845e7296","src/new/relibc/unistd.rs":"bcbb65f70759cd84c81fc24ea36aac423edb8f9d7148f65b545ee63954411fd1","src/new/rtems/mod.rs":"8ad621434ced0a9d1c0ed5d68514f59b0c8bd4c77fdad81eb09e671e7a42cf1d","src/new/sgx/mod.rs":"c500dc72eff5cbf99c9d7e0e3f1faa3c680bfd7f6ac0166fa1a35fd0d7e69f41","src/new/sgx/unistd.rs":"bcbb65f70759cd84c81fc24ea36aac423edb8f9d7148f65b545ee63954411fd1","src/new/solaris/mod.rs":"ce8a152ebacb9e8e0d87829d166e3ead64222ead397371bd557e18eefdcafe3d","src/new/solaris/unistd.rs":"bcbb65f70759cd84c81fc24ea36aac423edb8f9d7148f65b545ee63954411fd1","src/new/solid/mod.rs":"dc5c3c8a627972865ef0a968125e74b2f87636dc89dd2df0f7cea9a40d7c6beb","src/new/teeos/mod.rs":"1d69f212e2a848a32292eef9ad16a44a8d5cf80c7d43db5f445dbd1a49400e3b","src/new/trusty/mod.rs":"3f009fef70cbe062126c82f1f9274cba60b12d3766b825d66326666a1f240fc2","src/new/uclibc/mod.rs":"c3f988f3eb289ba6bc3b2535b82163a7ff160288b7494c156f0fba62143cf2d5","src/new/uclibc/pthread.rs":"ab235319003806c5f20aef5f851af472480e88ff13d2a5f730870efb95e7982e","src/new/uclibc/unistd.rs":"bcbb65f70759cd84c81fc24ea36aac423edb8f9d7148f65b545ee63954411fd1","src/new/ucrt/mod.rs":"4fd3a973de4c4c6349e76320e09b13701ac284e7ae03c671054b1eeebb86215d","src/new/vita/mod.rs":"196d6ca5c9b1ccc602a6270c3cf0b0bdbd39246066d1a8385df03ba45b31d368","src/new/vxworks/mod.rs":"fa569763957eb87e7e1ce5fa07293116c66661ff0c21d277fda5b30c61451176","src/new/vxworks/unistd.rs":"bcbb65f70759cd84c81fc24ea36aac423edb8f9d7148f65b545ee63954411fd1","src/new/wasi/mod.rs":"2a74140697bc528193214aad11edc632923bd0cf8350d24f6d600f849dd19e19","src/new/xous/mod.rs":"69016c5c153d9a14003b15558cab96b4691a927586c20ca493fc8d3bb65594eb","src/primitives.rs":"af323402fee13278461bcaec6a06a15dfca24a02d48b0570c88e2746288d7078","src/psp.rs":"081cf4e5127ba10ebb62a9a5f8f849dd92742693db443db429d446ee472b5d41","src/qurt/mod.rs":"5af8edfb34f5431586b7ae00b341daa4312737c1e39c16348b1fff1d1cb8c642","src/sgx.rs":"964d6af358f5c85f948275090e5a7854e0169c43b5c338070b6a4cd156ebc9e6","src/solid/aarch64.rs":"4d4236500f98858fc249f3b6858af5009851c8c582031926b8195b2646f7da5e","src/solid/arm.rs":"4d4236500f98858fc249f3b6858af5009851c8c582031926b8195b2646f7da5e","src/solid/mod.rs":"0b5a07cf7df8227fecc13ea5b7ddf0bb9520c8be44bfb8c15f9449715911dfa0","src/switch.rs":"5db5be2d9c235c00f74b25cceabdf2ce5ec9e1936f991815513e4edf5dec0d56","src/teeos/mod.rs":"ad18343da08ebb6c1fba77fb8efe9ce4551519bea617c1a000aa92f3e50b8565","src/trusty.rs":"cc90bf6b35a515021a3155aa3cc5fcab33457b8fbb2ac7259f0b694d33625fd8","src/types.rs":"5d7831b60664bbe955e00b9b8c75cf834e27295ad36f249f9aee534f533571bc","src/unix/aix/mod.rs":"89a4848c84c15b827021da8b92770d73505bb2edf3ca2429dbcfd007dec02721","src/unix/aix/powerpc64.rs":"724b02ca3afb2722930de172b3144a6bffb70792612a7fbe53553cac58bd2ccc","src/unix/bsd/apple/b32/mod.rs":"30a6d351260806e98666ee4ba64b783d1fe1d8b1d32c3ba7766bd5d638dab2dd","src/unix/bsd/apple/b64/aarch64/mod.rs":"bf2e39a80c8d768c2969197b80fafa50608ac0186b4f4aea53e7fa8bf40d2214","src/unix/bsd/apple/b64/mod.rs":"2619b6afd99e938157753c436e969aa1703b0404b913e456e469df5c6d69538f","src/unix/bsd/apple/b64/x86_64/mod.rs":"ff16a360cb478a4c2e912b9779a806d0e3439e4c5110e0325c82af5ee8429591","src/unix/bsd/apple/mod.rs":"8f3299d0de1c3f39aad406c7955760168734300d62850bdcc862611fc25a199b","src/unix/bsd/freebsdlike/dragonfly/mod.rs":"3ec640c35a0b5c0dfdf3fb981e6c3ac74e33781941ecca67390d076b167b5564","src/unix/bsd/freebsdlike/freebsd/aarch64.rs":"f13a68b825a58596b5d3339378b0812b778481a291aeacb41de74cb65ad66d3f","src/unix/bsd/freebsdlike/freebsd/arm.rs":"d627ed0bf17932ec0e3226944a4f9714805b27a953778b309d914545cf21b82a","src/unix/bsd/freebsdlike/freebsd/freebsd11/b32.rs":"316e70938d2b050fd67e5aaf0bcdd0a70d55f195b26ce4ad6055cdf05cea2e61","src/unix/bsd/freebsdlike/freebsd/freebsd11/b64.rs":"811c3f1aeb70dfd051abc9d3357e8eca9564c08b85d3ea6f81caacfa559e3060","src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs":"87fdf9253ff788b9b66d0bd26b1e7e401e80d165bb4278833dfb80046ee06064","src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs":"7153ee461d9c41e5b849603561dd118091af53a7c990d94a171a4e1412381ec8","src/unix/bsd/freebsdlike/freebsd/freebsd12/x86_64.rs":"64c4bd82eaf30a2681417f982fce28de7d1b0743bfaa14004692a56cee44be21","src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs":"bee7fcbb5ff8d1a011b56afa025bcab87bff3e3f90d5d4e0bbbb5349f5bc6b5f","src/unix/bsd/freebsdlike/freebsd/freebsd13/x86_64.rs":"64c4bd82eaf30a2681417f982fce28de7d1b0743bfaa14004692a56cee44be21","src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs":"4dbfaa01fce15bcaaab3d70f9f8da3b2e34a93cb2ca0d380b582926bbe43c2ce","src/unix/bsd/freebsdlike/freebsd/freebsd14/x86_64.rs":"d6e66809e109dc779efe5584b79d34fcd6fdba91973a415d64ae66f481f45940","src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs":"55c0ce55e6c140d9c0c8b3fce76b23e975eff6c4d5eeb14c9581f8e51638e34a","src/unix/bsd/freebsdlike/freebsd/freebsd15/x86_64.rs":"d6e66809e109dc779efe5584b79d34fcd6fdba91973a415d64ae66f481f45940","src/unix/bsd/freebsdlike/freebsd/mod.rs":"ab3734f8aa742fe5c3b5e31c29f0a99e7522abe28b3f7560ccf01f7c64305ca8","src/unix/bsd/freebsdlike/freebsd/powerpc.rs":"af7a43826e3ca9e5e7c3d7c1b50defa482074fd9909de3ee2e52cd0109c1a950","src/unix/bsd/freebsdlike/freebsd/powerpc64.rs":"f7be922bddd7a4b7da863d6aba057aab2d27f500c7101596bbaaccf075133451","src/unix/bsd/freebsdlike/freebsd/riscv64.rs":"69242a001ab21b6e06b7442c37a89dbc5a67660c7c3cade1d46b65adf32a5669","src/unix/bsd/freebsdlike/freebsd/x86.rs":"5165242f0c82040898dbf711294ba45c5ab2635d39d0bbf9cc899b816415e2a4","src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs":"84044f397dbf13a1c517885c7b234efa2900d116324a4cca626d2f8df398d655","src/unix/bsd/freebsdlike/mod.rs":"c183016e0d192bd490958e4aeb5022dd203ca288abe8f1f502b2d1215b47e30c","src/unix/bsd/mod.rs":"a51588c418deaa58acecddc08c3578cd45659af7a6aec055447ec05143534b0d","src/unix/bsd/netbsdlike/mod.rs":"78f8873b9b91362253031ad6d3d6ee61640496b1c24b75b3ab9186e1eb35a545","src/unix/bsd/netbsdlike/netbsd/aarch64.rs":"ba2425edbf025f13ab3c3534d1671d310392df3a7d237539817d9cfa675971c8","src/unix/bsd/netbsdlike/netbsd/arm.rs":"8dd57613695dec1b2104ec35839f0b9b6d234c6cc80365e9fef9ca977c1865a0","src/unix/bsd/netbsdlike/netbsd/mips.rs":"20cdd8d1427c986ecc3fcf7960d337917a13cfd8386dd2d54f8693a23d60892f","src/unix/bsd/netbsdlike/netbsd/mod.rs":"12d1e288aa3c351000721502e3cbd7115d7d5584ffc5c37f5c00e9c56f657385","src/unix/bsd/netbsdlike/netbsd/powerpc.rs":"c19c4edbc73b5a97b51e3e2ad39b9fee02ad15e80c70ceb3a1abfe977e5c0ead","src/unix/bsd/netbsdlike/netbsd/riscv64.rs":"f446c996f00e4d15fd25461a30c767c05d083df9e047b0da497ce7c545acfa96","src/unix/bsd/netbsdlike/netbsd/sparc64.rs":"d50816e830225779ac9e9a55a7e3e097882153d72987061d76a96ee736c8af9c","src/unix/bsd/netbsdlike/netbsd/x86.rs":"3006b6a086c0241f5383ca101e7b9357368d713f9c38400633491656d110798e","src/unix/bsd/netbsdlike/netbsd/x86_64.rs":"13dd36a0db740930155b5f28fedfac606c7291c0276bbf2c2b3fe03a4dbd2a51","src/unix/bsd/netbsdlike/openbsd/aarch64.rs":"13c91b304dfb5c3c26777863827c7b3707fe245fcf50da32caab641aff998c63","src/unix/bsd/netbsdlike/openbsd/arm.rs":"f064d935f416ca9f7e5e767b9b46da2250c997d667c0c7f4b4c7dfe02d0258c3","src/unix/bsd/netbsdlike/openbsd/mips64.rs":"bee7664d88f8451ae22552fc0721b6b6a6dee2493cc42bcb9829c1e47e4b05f5","src/unix/bsd/netbsdlike/openbsd/mod.rs":"9943458aaf3a35ce0d3b259b0b666d29347b04cb1a1722e6450073e71f894398","src/unix/bsd/netbsdlike/openbsd/powerpc.rs":"f064d935f416ca9f7e5e767b9b46da2250c997d667c0c7f4b4c7dfe02d0258c3","src/unix/bsd/netbsdlike/openbsd/powerpc64.rs":"1f62a42e2970c42de9e3492fbf3cd5b45410889f033743579266342d1a9e2a00","src/unix/bsd/netbsdlike/openbsd/riscv64.rs":"b2cf3778bfb51d1c0277f0e92963a04f734be3e29879c6c09a25bad2d9b5ab6a","src/unix/bsd/netbsdlike/openbsd/sparc64.rs":"8d4c5a4cae63e09e1c156164ddc82e0fc77926841d4d4e419dd2e7a7b7145f58","src/unix/bsd/netbsdlike/openbsd/x86.rs":"e6da2fdff7706fd3eac147d3aaf16afdd8542f231f502660d1d89c79b5eca21b","src/unix/bsd/netbsdlike/openbsd/x86_64.rs":"bc7ed75ce66059aafa7a86986aefff267b2c951e47558453fe13ce1bdb48dc0b","src/unix/cygwin/mod.rs":"0da02791aefa8c45531abbea9a9f55b3c3d0d7e8d9af0c250d969ce22b48ee95","src/unix/haiku/b32.rs":"c3f8678ceee65a3094d8133b0d1a94470860e0b1867977f0569c52c5a20e039f","src/unix/haiku/b64.rs":"f97ce9225f4710893dab03ab3e13bc62152cc84f90c597ec88f6dc1f4c27d242","src/unix/haiku/bsd.rs":"4d9af31fdac2561ee5f942dca97dd2f48139ca74660d40b854b307fa5679d1c8","src/unix/haiku/mod.rs":"5a619d44c8e1205ada8f4bf67cf94b8f133949d15d505cba5dceb65557eaa736","src/unix/haiku/native.rs":"85836b1063ddc01c176c61cff8c006cf6f5dc4b1f465f41b5c330aa372a44ab6","src/unix/haiku/x86_64.rs":"def40c16609b5d62c3cdbba6a38340720a96b326ad98d53838554e4b6878d2ee","src/unix/hurd/b32.rs":"501f426f7aeb60acf4119064100dd94bbdfebff2cec785428708059d853dc123","src/unix/hurd/b64.rs":"b9b2082e721a5ec89ba55fd5a16bbffcc8a05ca7cef6dbfbd78aff0806cb931f","src/unix/hurd/mod.rs":"287a2fdd2065fc8a13c4932b3f241d1453607e74829b6d2012a44b6f5f36f654","src/unix/linux_like/android/b32/arm.rs":"5c6ad12746052b86846f9d7c3bd484d15bd3e2113785a19220186ab2a9bb31ba","src/unix/linux_like/android/b32/mod.rs":"04edc73374218c6b854929cae4bc5171ad5066f3636f87235640ec20a49f1559","src/unix/linux_like/android/b32/x86/mod.rs":"72cd0fb5a067170e7409359b6c0114f5472e313060b9642e2e48dc9fabfd4614","src/unix/linux_like/android/b64/aarch64/mod.rs":"66def5f0af9594af50535eba7501bce89620010a7d7aa769ef401235b03efa88","src/unix/linux_like/android/b64/mod.rs":"5afe4dc379ae30ddab9295e5ab8ac89f39f5129f519612d7528bfbfeb0a1d934","src/unix/linux_like/android/b64/riscv64/mod.rs":"47c97eeb221c48bd08c2fc2ddf5f9f4d20c185df76681fe14e3a0950fb37ecbf","src/unix/linux_like/android/b64/x86_64/mod.rs":"4d6eb98fd17e821d0e05755ccb3f4f2b6e37bfbab533894ed444138b750e6b08","src/unix/linux_like/android/mod.rs":"9f0cce22a507e263c4a9bf3501fbd85e14b2e7e9a71c6fe1e046ee051470a1eb","src/unix/linux_like/emscripten/lfs64.rs":"486f987bc39653a48e6538ab0e8263cd2c1bd3d4732a2c573f89f7a037936c38","src/unix/linux_like/emscripten/mod.rs":"538dbcd492324f0254c1ed1f66ad8e7bc9e367cdd70a004cb0183b6fb368e64a","src/unix/linux_like/l4re/mod.rs":"47c07dc3c5e368ec9a64b33af9a314f51e5ed6c7fc6456bfba919d661a812275","src/unix/linux_like/l4re/uclibc/aarch64/mod.rs":"3111d03e5f43dfe1639fe7189903044cb980591c0580a62e8b511de4943201e2","src/unix/linux_like/l4re/uclibc/mod.rs":"3678301a89b80f638ea90b4ec2e3d225bb186eaba3d07f324969e46b81a1955a","src/unix/linux_like/l4re/uclibc/x86_64/mod.rs":"89bb7c67398c836c7f17727338c6032e7667307f02ef0f5d0121031fea1aa358","src/unix/linux_like/linux/arch/generic/mod.rs":"f531e877d712eb30cddf97c76273b7ba7fef19cf8eaafd60ca9ac26019b49adf","src/unix/linux_like/linux/arch/mips/mod.rs":"dcc1d2e85dd2087f61635c753d1781ec70dcba5c95aee285255f09216ea1e0f8","src/unix/linux_like/linux/arch/mod.rs":"8bc5898b03760a95dd4f124ac76ad92e5ae36b2d0644203d752ef2b37e487c3a","src/unix/linux_like/linux/arch/powerpc/mod.rs":"77b286fce4ac755ec840b9c70824a648314b3a5ed2a385d291138589647fdbaf","src/unix/linux_like/linux/arch/sparc/mod.rs":"46f3bd08ec01147af43c93a22c21956af038fa5f6e56643f8e39ca30721bf8cd","src/unix/linux_like/linux/gnu/b32/arm/mod.rs":"60d5c7667d81db0ad9faf65edc79420b2100cab27699e03de4d415de931e9f58","src/unix/linux_like/linux/gnu/b32/csky/mod.rs":"627e61997c33fc12fca9e337d248d8531ef0751f21f70110b65631a0e481b66d","src/unix/linux_like/linux/gnu/b32/m68k/mod.rs":"2ea8f649fc9f01829de439ffe0fdbf9566602ed6ec0088128167af1080c3a1b2","src/unix/linux_like/linux/gnu/b32/mips/mod.rs":"8b3254b47401cde6118f9eea7e98319af8174d99feac451949e673a28ed4ff6e","src/unix/linux_like/linux/gnu/b32/mod.rs":"5ff89d834a09550c9393965bfd2b74e0f9ab6059bc76f2a827faed631afe10a7","src/unix/linux_like/linux/gnu/b32/powerpc.rs":"585983c6617a590ee0ac5217280d03642efcf721bd80fdabd6b9477031574fee","src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs":"a5e6c931ca8da568626233f2aa5ee0dd0b8e4e1e8905d52ab9dd0ea618376c2f","src/unix/linux_like/linux/gnu/b32/sparc/mod.rs":"0ddd77054079d7f7ee7aede95552e6494f67fc3db332ec1f5f83a9d09e1a9710","src/unix/linux_like/linux/gnu/b32/x86/mod.rs":"e370a80bfdec000347c384f080b30c6f537dc51e17e715c2dd8a360e6a1407f3","src/unix/linux_like/linux/gnu/b64/aarch64/ilp32.rs":"638b2d717dcf5b59a0058c3dabab43edd84de9d1d7da6e16ad0c58e863000417","src/unix/linux_like/linux/gnu/b64/aarch64/lp64.rs":"28c11e70467b2f00735d3a04c369e96e04fd44d0587ee33359f38328b0677ee6","src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs":"7948baae6e8dfbbba78caaea27a2ef059dbe5f0a2b533bd89cc5d6c5dd7f7f1d","src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs":"242cd513eca13d14fbcc326369bb54006782260a558f0c2367102471d4081631","src/unix/linux_like/linux/gnu/b64/mips64/mod.rs":"007809bca7493eab4ac99a30b4495f73b544d7c882b81b5ca719c1b70761e0bf","src/unix/linux_like/linux/gnu/b64/mod.rs":"64d4182c10180692d381d8eea3d9ce8a6d47289b9c1218070241c5a445d9f1a0","src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs":"4dafacc390ff02ae3c34591a1605e1ac380c13338928a7e2e1ce748fc1e46323","src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs":"f1a54e0bc0d791ad642e07df5f8d4eda1b4d497059c0e5d20b52e094ed635b19","src/unix/linux_like/linux/gnu/b64/s390x.rs":"741d95cf29b65a9fa5c7316b888f8c79f944376b308c7929eb21054b5a16a83d","src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs":"adc09bb20980ee2d5892a2f68949505bed2fa00954b837aa0a15eeb04edd53cb","src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs":"d72ae5556347be715e3fdfc084e7e95a184504f1575230f163ab7a72a405cb24","src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs":"07240332eaf44996d86e37b12d71b519b499c9c9b57898441c58ac2e8c0cb6f7","src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs":"914898b781dfe6b2f755730d6000223d1beea177731e180ccbfdd84a0b8b3bd9","src/unix/linux_like/linux/gnu/mod.rs":"0ff72f74b015bc9ef4d1732fc5594945fdb5ca388e4aa0be71260fecb90e6f1f","src/unix/linux_like/linux/mod.rs":"3d293f05bfb6f9605e238399e404bf77ca91f4f7def6596f77f404c71b80b572","src/unix/linux_like/linux/musl/b32/arm/mod.rs":"7dc4b9a4d723d6868a84e81dbd5953b234c4540db3edd5a4a7ea0e154b101d91","src/unix/linux_like/linux/musl/b32/hexagon.rs":"17063ab52334500ec67d9f1f706bfcd493092d7a7f28f3b5558915cce756885e","src/unix/linux_like/linux/musl/b32/mips/mod.rs":"64f6b834d3d98db1c2d95d40371c644f71170d7710fcdd933f1ff51c3fbe2c70","src/unix/linux_like/linux/musl/b32/mod.rs":"6630c3ae8e27eb2bae6309bef4c96be9a21ebb877ce281b881a73589b7264a7a","src/unix/linux_like/linux/musl/b32/powerpc.rs":"a946612120ed9700ff1e4e729b0f8107a40f9ed7f5b320357552d5475441042d","src/unix/linux_like/linux/musl/b32/riscv32/mod.rs":"df3e3bbd2f69420b6de3a1d9aa242402f0bf26c77c573b2debea53af964f07d7","src/unix/linux_like/linux/musl/b32/x86/mod.rs":"83e340712e8acd89cefcb5eef0e826da79f47a7a42784699df90604c4e9a8712","src/unix/linux_like/linux/musl/b64/aarch64/mod.rs":"b165f81469b144a9c6d60486c3a8b4770fce5f4ad67958aad3c0b0ee85fde117","src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs":"9885dd43e46d3f34156b2871c3c08a88775efecb9eab0b4ed9bf396c1cb509d3","src/unix/linux_like/linux/musl/b64/mips64.rs":"24dd0c412ae02b84552a1803b4369dcc0fa3b989f9b6a406f404690c757fbc8b","src/unix/linux_like/linux/musl/b64/mod.rs":"1ce1eee49b1c7c5c02fe04b1539a0316becf0295763e3e18b1088895ed937373","src/unix/linux_like/linux/musl/b64/powerpc64.rs":"5f2a8d0a5b6a4d044c75ba433b4f69e27d475cbd5ba81e659e756757b5c36111","src/unix/linux_like/linux/musl/b64/riscv64/mod.rs":"d5298d224be38474d05c53ffda6384fdb24771774e5c19f84898c23e4603459c","src/unix/linux_like/linux/musl/b64/s390x.rs":"77079b262e2fda7b569c19236f264f460c157051bac349928306a07c4cb61195","src/unix/linux_like/linux/musl/b64/wasm32/mod.rs":"bd65c06c4e422cb859be803e0dc7404513c13e9d9c3c672f5462f0bbd3dc8ef2","src/unix/linux_like/linux/musl/b64/wasm32/wali.rs":"006149b7af0145dc40123fc7991d853c7f2c5c77bbc9c8a44c276be0d99a1343","src/unix/linux_like/linux/musl/b64/x86_64/mod.rs":"4535e44cfc85c66253c4cda347366d54c3ffa8e0b47b4b89cd87d96fb4005b1e","src/unix/linux_like/linux/musl/lfs64.rs":"61b1eae698d93dbd7c665e920ef685fd6eea0c4a2d96acc1d5f111d87b88ef38","src/unix/linux_like/linux/musl/mod.rs":"56c79797cafb7949f639f84a5a34676b34d776c843f0ad49ddca0684092580f4","src/unix/linux_like/linux/uclibc/arm/mod.rs":"9eb48a19e49cd2a989f6daae9552dd477d645bc2540a8bae5ac71894565375b0","src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs":"0b3c063ff6510c68577f8789ff87c1b630dc1c219611070fa91aa2b5b5ec595f","src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs":"3a3b90f896a07f5d17e3440bbff7b3153aed564732ef2e468167c7a425922ea8","src/unix/linux_like/linux/uclibc/mips/mod.rs":"e552f579a8dc9e690891113aa6360607ad962bd84cbb60c370b5c5f7c7d1d8c0","src/unix/linux_like/linux/uclibc/mod.rs":"413b7cc1cd88580162836dc8b1cf1fa569b3431248c13e030a1f50519ddaa875","src/unix/linux_like/linux/uclibc/x86_64/mod.rs":"53937263439095a4af0e5d583eb6cc621dd07a41aaa154b2f4cd1ec799dd7187","src/unix/linux_like/linux_l4re_shared.rs":"c21e27065fb45df318fe76366f8250cf1e6bb0a15394f4d6bc69686d774a780c","src/unix/linux_like/mod.rs":"399dc67be0898f73946145b26e12bf23beeb9048fb86b69affdc56be5622bf19","src/unix/mod.rs":"32699be951ec02142e7de59f34ae0f6162620576a4bd88ae372d39d2027421ea","src/unix/newlib/aarch64/mod.rs":"d72d067a433bf24ee6b6255c4d04ea7c966518b8d064560c593f1ab23c025962","src/unix/newlib/arm/mod.rs":"95b6e4b3cd1eeb0386d4867e9e4c3438305aa3e8ae75697e06720aa06540a666","src/unix/newlib/espidf/mod.rs":"cbaf10ccdb429719003cac3f3cd4aa0aa63a12a383afc5bd88a4ab3abaef9e2e","src/unix/newlib/generic.rs":"c435a955d72878a71ea0719a75a4579818da6a2e01635f9fe1073d9a0d67352f","src/unix/newlib/horizon/mod.rs":"7c4680766b9986a379fc354a183f4072c1c70d643307edd1a0ca8e0f2c34d5a8","src/unix/newlib/mod.rs":"1aac15b55a852732174bcfee52f3b1452c3e491461a87b70a7ee4c97a458785f","src/unix/newlib/powerpc/mod.rs":"4d6dca09ea5dc000cbd39fb939a9b1a743d819931dfca3c896659e919a07a7da","src/unix/newlib/rtems/mod.rs":"7d06863f1942a90c9a6dd412637b93c18df00e7397cb1289176b9a2a19004b7c","src/unix/newlib/vita/mod.rs":"2f9bf66b40c2aa611033faf3ade5510dc9789af7302571fade40a1715398f06c","src/unix/nto/aarch64.rs":"73ad54ebca13454a75c7b0815e853175070a8ac2eefa338012a03e8b59f01e0c","src/unix/nto/mod.rs":"ddcb98afedf905c0af8819af1591a0c7df629a187ceb35108aeaa467c4879746","src/unix/nto/neutrino.rs":"bb9d24ccee3b9e53af6d028f04ecb646e216ac1a9e2b2ade54bc06135ce3ac59","src/unix/nto/x86_64.rs":"c2e46c6ab4c02c8f773298ec1e90eeccac43c09fa111ac9ae63408abc6eff584","src/unix/nuttx/mod.rs":"4083559d825d2af9ade2c3f14e29802315c9a79091ce8d480c438c3242c7ba80","src/unix/redox/mod.rs":"40dbff61515612a7275ca1454a912ddc08f1b6f73bc084f4b563213bd46fde94","src/unix/solarish/compat.rs":"3d120a056208c03215cfbe3eef1584105160d133c0aa4557bb38018c177640b0","src/unix/solarish/illumos.rs":"74fa022e2799fed83ddeefecfdf559fff63e315ba36304845d65c9721b3ce3b7","src/unix/solarish/mod.rs":"03d1a75ecb758dde3c9ae3c3300c6d241e5e2481329724e32cfca6ffd5882cb3","src/unix/solarish/solaris.rs":"2be39ce5f464823359e7e2e4bae94c9acac9245042570df11a0ed75d49f8acad","src/unix/solarish/x86.rs":"44261c1f1b300dac9fa0dab93ec85d0c3b3c48b15bc4515b9820c9421cff7427","src/unix/solarish/x86_64.rs":"eec1602998dbd3b3aeb2d9a5bd66fc53a6fbbcd7967ed0bb2dd61a8c176023e4","src/unix/solarish/x86_common.rs":"4ae02d88622f7f080f5e8cd328f13187edbc5e124fb3e05e4cf212597f6cce48","src/vxworks/aarch64.rs":"4d4236500f98858fc249f3b6858af5009851c8c582031926b8195b2646f7da5e","src/vxworks/arm.rs":"4d4236500f98858fc249f3b6858af5009851c8c582031926b8195b2646f7da5e","src/vxworks/mod.rs":"e687423e39c07ca03d735f464537f40cc6d45407eaf6bbcfcead4a26a2e68881","src/vxworks/powerpc.rs":"4d4236500f98858fc249f3b6858af5009851c8c582031926b8195b2646f7da5e","src/vxworks/powerpc64.rs":"4d4236500f98858fc249f3b6858af5009851c8c582031926b8195b2646f7da5e","src/vxworks/riscv32.rs":"b1f933205800f0da00f975d53b18fe0035e075cc4613acf110a09a277dc3302a","src/vxworks/riscv64.rs":"b1f933205800f0da00f975d53b18fe0035e075cc4613acf110a09a277dc3302a","src/vxworks/x86.rs":"b1f933205800f0da00f975d53b18fe0035e075cc4613acf110a09a277dc3302a","src/vxworks/x86_64.rs":"b1f933205800f0da00f975d53b18fe0035e075cc4613acf110a09a277dc3302a","src/wasi/mod.rs":"bf128fa1c53277185b638eb953c5b8d503ae7a182780470b40b06f7c29331f38","src/wasi/p2.rs":"feecc0485eabd2c32bc5d800df6ad1b9b4d282741342fb08792f2635204e1e08","src/windows/gnu/mod.rs":"6422acc5c5a82122c11efb84882778e30888c0693c0993fbf7f3baa59e4cbbb5","src/windows/mod.rs":"01da11840df8118ad12f40dc38e921b4ecfd1045badc700d456f549789df24d4","src/windows/msvc/mod.rs":"40410b26b606d1b59b0742b2632f3cd0a28a5429f784f9693fae0a78c15b3889","src/xous.rs":"1a83621c40248ad4d0c08e1fd4c1107d5efcbc2f4f0169538b7b4a885abedbfa","tests/const_fn.rs":"8ac3171d7bced3576a4e93f48570b3e00c553d7510ab85a7473ae3b716a812dc"},"package":"68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"} \ No newline at end of file diff --git a/http/vendor/libc/.cargo_vcs_info.json b/http/vendor/libc/.cargo_vcs_info.json new file mode 100644 index 0000000..2e53efb --- /dev/null +++ b/http/vendor/libc/.cargo_vcs_info.json @@ -0,0 +1,6 @@ +{ + "git": { + "sha1": "42620ffc4109dc32e02f1cae9e63a3f4311b4b71" + }, + "path_in_vcs": "" +} \ No newline at end of file diff --git a/http/vendor/libc/.editorconfig b/http/vendor/libc/.editorconfig new file mode 100644 index 0000000..155c990 --- /dev/null +++ b/http/vendor/libc/.editorconfig @@ -0,0 +1,7 @@ +[*.sh] +# See https://github.com/mvdan/sh/blob/master/cmd/shfmt/shfmt.1.scd#examples +indent_style = space +indent_size = 4 + +switch_case_indent = true +space_redirects = true diff --git a/http/vendor/libc/.git-blame-ignore-revs b/http/vendor/libc/.git-blame-ignore-revs new file mode 100644 index 0000000..d358a2c --- /dev/null +++ b/http/vendor/libc/.git-blame-ignore-revs @@ -0,0 +1,6 @@ +# Format macro bodies +50f26e08e146b7e9c7d1af9614486eba327d1e31 + +# Automated changes related to the 2021 edition upgrade +643182f7da26cedb09349b8bb3735c2e58ba24e6 +108310db03e7db35ef48a902d9ce9a88ab8f9b77 diff --git a/http/vendor/libc/.release-plz.toml b/http/vendor/libc/.release-plz.toml new file mode 100644 index 0000000..6442af5 --- /dev/null +++ b/http/vendor/libc/.release-plz.toml @@ -0,0 +1,49 @@ +[workspace] +git_release_name = "{{ version }}" +git_tag_name = "{{ version }}" + +[changelog] +body = """ +## [{{ version | trim_start_matches(pat="v") }}]\ + {%- if release_link -%}\ + ({{ release_link }})\ + {% endif %} \ + - {{ timestamp | date(format="%Y-%m-%d") }} +{% for group, commits in commits | group_by(attribute="group") %} +### {{ group | upper_first }} + {% for commit in commits %} + - {% if commit.scope -%}{{ commit.scope | upper_first }}: {% endif %} + {%- if commit.breaking %}[**breaking**] {% endif %} + {{- commit.message }} + {%- if commit.links %} ([{{ commit.links.1.text }}]({{ commit.links.1.href }})){% endif -%} + {% endfor %} +{% endfor %} +{%- if github -%} +{% if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %} + ## New Contributors ❤️ +{% endif %}\ +{% for contributor in github.contributors | filter(attribute="is_first_time", value=true) %} + * @{{ contributor.username }} made their first contribution + {%- if contributor.pr_number %} in \ + [#{{ contributor.pr_number }}]({{ self::remote_url() }}/pull/{{ contributor.pr_number }}) \ + {%- endif %} +{%- endfor -%} +{%- endif %} +""" + +commit_parsers = [ + { message = '(?i)^(\w+: )?feat', group = "added" }, + { message = '(?i)^(\w+: )?add', group = "added" }, + { message = '(?i)^(\w+: )?change', group = "changed" }, + { message = '(?i)^(\w+: )?cleanup', group = "cleanup" }, + { message = '(?i)^(\w+: )?deprecate', group = "deprecated" }, + { message = '(?i)^(\w+: )?remove', group = "removed" }, + { message = '(?i)^(\w+: )?fix', group = "fixed" }, + { message = '(?i)^(\w+: )?fix', group = "fixed" }, + { message = '^.*', group = "other" }, +] + +link_parsers = [ + # Extract backport patterns + { pattern = '\(backport <.*/(\d+)>\)', text = "#$1", href = "https://github.com/rust-lang/libc/pull/$1"} +] diff --git a/http/vendor/libc/.rustfmt.toml b/http/vendor/libc/.rustfmt.toml new file mode 100644 index 0000000..42e6cff --- /dev/null +++ b/http/vendor/libc/.rustfmt.toml @@ -0,0 +1,6 @@ +edition = "2021" +error_on_line_overflow = true +group_imports = "StdExternalCrate" +imports_granularity = "Module" +# This crate gets large lists of reexports. Use vertical to reduce conflicts. +imports_layout = "Vertical" diff --git a/http/vendor/libc/CHANGELOG.md b/http/vendor/libc/CHANGELOG.md new file mode 100644 index 0000000..0e37267 --- /dev/null +++ b/http/vendor/libc/CHANGELOG.md @@ -0,0 +1,1034 @@ +# Changelog + +## [0.2.186](https://github.com/rust-lang/libc/compare/0.2.185...0.2.186) - 2026-04-24 + +### Added + +- Apple: Add `KEVENT_FLAG_*` constants ([#5070](https://github.com/rust-lang/libc/pull/5070)) +- Linux: Add `PR_SET_MEMORY_MERGE` and `PR_GET_MEMORY_MERGE` ([#5060](https://github.com/rust-lang/libc/pull/5060)) + +### Changed + +- CI: Migrate FreeBSD CI from Cirrus CI to GitHub Actions ([#5058](https://github.com/rust-lang/libc/pull/5058)) + +## [0.2.185](https://github.com/rust-lang/libc/compare/0.2.184...0.2.185) - 2026-04-13 + +### Added + +- EspIDF: Add `espidf_picolibc` cfg for picolibc `O_*` flag values ([#5035](https://github.com/rust-lang/libc/pull/5035)) +- Hexagon: add missing constants and fix types for linux-musl ([#5042](https://github.com/rust-lang/libc/pull/5042)) +- Redox: Add semaphore functions ([#5051](https://github.com/rust-lang/libc/pull/5051)) +- Windows: Add `sprintf`, `snprintf`, and the `scanf` family ([#5024](https://github.com/rust-lang/libc/pull/5024)) + +### Fixed + +- Hexagon: Decouple `time64` types from musl symbol redirects ([#5040](https://github.com/rust-lang/libc/pull/5040)) +- Horizon: Change `POLL` constants from `c_short` to `c_int` ([#5045](https://github.com/rust-lang/libc/pull/5045)) + + +## [0.2.184](https://github.com/rust-lang/libc/compare/0.2.183...0.2.184) - 2026-04-01 + +### MSRV + +This release increases the MSRV of `libc` to 1.65. With this update, you can now always use the +`core::ffi::c_*` types with `libc` definitions, since `libc` has been changed to reexport from +`core` rather than redefining them. (This _usually_ worked before but had edge cases.) +([#4972](https://github.com/rust-lang/libc/pull/4972)) + +### Added + +- BSD: Add `IP_MINTTL` to bsd ([#5026](https://github.com/rust-lang/libc/pull/5026)) +- Cygwin: Add `TIOCM_DSR` ([#5031](https://github.com/rust-lang/libc/pull/5031)) +- FreeBSD: Added `xfile` structe and file descriptor types ([#5002](https://github.com/rust-lang/libc/pull/5002)) +- Linux: Add CAN netlink bindings ([#5011](https://github.com/rust-lang/libc/pull/5011)) +- Linux: Add `struct ethhdr` ([#4239](https://github.com/rust-lang/libc/pull/4239)) +- Linux: Add `struct ifinfomsg` ([#5012](https://github.com/rust-lang/libc/pull/5012)) +- Linux: Define `max_align_t` for riscv64 ([#5029](https://github.com/rust-lang/libc/pull/5029)) +- NetBSD: Add missing `CLOCK_` constants ([#5020](https://github.com/rust-lang/libc/pull/5020)) +- NuttX: Add `_SC_HOST_NAME_MAX` ([#5004](https://github.com/rust-lang/libc/pull/5004)) +- VxWorks: Add `flock` and `F_*LCK` constants ([#4043](https://github.com/rust-lang/libc/pull/4043)) +- WASI: Add all `_SC_*` sysconf constants ([#5023](https://github.com/rust-lang/libc/pull/5023)) + +### Deprecated + +The remaining fixed-width integer aliases, `__uint128_t`, `__uint128`, `__int128_t`, and `__int128`, +have been deprecated. Use `i128` and `u128` instead. ([#4343](https://github.com/rust-lang/libc/pull/4343)) + +### Fixed + +- **breaking** Redox: Fix signal action constant types ([#5009](https://github.com/rust-lang/libc/pull/5009)) +- EspIDF: Correct the value of `DT_*` constants ([#5034](https://github.com/rust-lang/libc/pull/5034)) +- Redox: Fix locale values and add `RTLD_NOLOAD`, some TCP constants ([#5025](https://github.com/rust-lang/libc/pull/5025)) +- Various: Use `Padding::new()` rather than `Padding::uninit()` ([#5036](https://github.com/rust-lang/libc/pull/5036)) + +### Changed + +- **potentially breaking** Linux: Add new fields to `struct ptrace_syscall_info` ([#4966](https://github.com/rust-lang/libc/pull/4966)) +- Re-export `core::ffi` integer types rather than redefining ([#5015](https://github.com/rust-lang/libc/pull/5015)) +- Redox: Update `F_DUPFD`, `IP`, and `TCP` constants to match relibc ([#4990](https://github.com/rust-lang/libc/pull/4990)) + + + +## [0.2.183](https://github.com/rust-lang/libc/compare/0.2.182...0.2.183) - 2026-03-08 + +### Added + +- ESP-IDF: Add `SOMAXCONN` ([#4993](https://github.com/rust-lang/libc/pull/4993)) +- Linux: Add `name_to_handle_at` and `open_by_handle_at` ([#4988](https://github.com/rust-lang/libc/pull/4988)) +- NetBSD: Add `kinfo_file`, `kinfo_pcb`, and related constants ([#4985](https://github.com/rust-lang/libc/pull/4985)) +- OpenBSD: Add `kinfo_file` and related constants ([#4991](https://github.com/rust-lang/libc/pull/4991)) +- VxWorks: Add additional structs and defines ([#5003](https://github.com/rust-lang/libc/pull/5003)) +- Various: Implement `Default` for `timeval` and `timespec` ([#4976](https://github.com/rust-lang/libc/pull/4976)) + +### Fixed + +- Hexagon musl: Enable unstable 64-bit `time_t` support and `musl_v1_2_3` ([#4992](https://github.com/rust-lang/libc/pull/4992)) +- Nintendo Switch: Fix target support ([#4982](https://github.com/rust-lang/libc/pull/4982)) +- OpenBSD: Wrap an unused field in `Padding` ([#4997](https://github.com/rust-lang/libc/pull/4997)) +- Redox: Change `sigaction.sa_flags` to `c_int` ([#4986](https://github.com/rust-lang/libc/pull/4986)) +- Redox: Fix `blkcnt_t` type ([#4994](https://github.com/rust-lang/libc/pull/4994)) + +## [0.2.182](https://github.com/rust-lang/libc/compare/0.2.181...0.2.182) - 2026-02-13 + +### Added + +- Android, Linux: Add `tgkill` ([#4970](https://github.com/rust-lang/libc/pull/4970)) +- Redox: Add `RENAME_NOREPLACE` ([#4968](https://github.com/rust-lang/libc/pull/4968)) +- Redox: Add `renameat2` ([#4968](https://github.com/rust-lang/libc/pull/4968)) + + +## [0.2.181](https://github.com/rust-lang/libc/compare/0.2.180...0.2.181) - 2026-02-09 + +### Added + +- Apple: Add `MADV_ZERO` ([#4924](https://github.com/rust-lang/libc/pull/4924)) +- Redox: Add `makedev`, `major`, and `minor` ([#4928](https://github.com/rust-lang/libc/pull/4928)) +- GLibc: Add `PTRACE_SET_SYSCALL_INFO` ([#4933](https://github.com/rust-lang/libc/pull/4933)) +- OpenBSD: Add more kqueue related constants for ([#4945](https://github.com/rust-lang/libc/pull/4945)) +- Linux: add CAN error types ([#4944](https://github.com/rust-lang/libc/pull/4944)) +- OpenBSD: Add siginfo_t::si_status ([#4946](https://github.com/rust-lang/libc/pull/4946)) +- QNX NTO: Add `max_align_t` ([#4927](https://github.com/rust-lang/libc/pull/4927)) +- Illumos: Add `_CS_PATH` ([#4956](https://github.com/rust-lang/libc/pull/4956)) +- OpenBSD: add `ppoll` ([#4957](https://github.com/rust-lang/libc/pull/4957)) + +### Fixed + +- **breaking**: Redox: Fix the type of dev_t ([#4928](https://github.com/rust-lang/libc/pull/4928)) +- AIX: Change 'tv_nsec' of 'struct timespec' to type 'c_long' ([#4931](https://github.com/rust-lang/libc/pull/4931)) +- AIX: Use 'struct st_timespec' in 'struct stat{,64}' ([#4931](https://github.com/rust-lang/libc/pull/4931)) +- Glibc: Link old version of `tc{g,s}etattr` ([#4938](https://github.com/rust-lang/libc/pull/4938)) +- Glibc: Link the correct version of `cf{g,s}et{i,o}speed` on mips{32,64}r6 ([#4938](https://github.com/rust-lang/libc/pull/4938)) +- OpenBSD: Fix constness of tm.tm_zone ([#4948](https://github.com/rust-lang/libc/pull/4948)) +- OpenBSD: Fix the definition of `ptrace_thread_state` ([#4947](https://github.com/rust-lang/libc/pull/4947)) +- QuRT: Fix type visibility and defs ([#4932](https://github.com/rust-lang/libc/pull/4932)) +- Redox: Fix values for `PTHREAD_MUTEX_{NORMAL, RECURSIVE}` ([#4943](https://github.com/rust-lang/libc/pull/4943)) +- Various: Mark additional fields as private padding ([#4922](https://github.com/rust-lang/libc/pull/4922)) + +### Changed + +- Fuchsia: Update `SO_*` constants ([#4937](https://github.com/rust-lang/libc/pull/4937)) +- Revert "musl: convert inline timespecs to timespec" (resolves build issues on targets only supported by Musl 1.2.3+ ) ([#4958](https://github.com/rust-lang/libc/pull/4958)) + + +## [0.2.180](https://github.com/rust-lang/libc/compare/0.2.179...0.2.180) - 2026-01-08 + +### Added + +- QNX: Add missing BPF and ifreq structures ([#4769](https://github.com/rust-lang/libc/pull/4769)) + +### Fixed + +- Linux, L4Re: address soundness issues of `CMSG_NXTHDR` ([#4903](https://github.com/rust-lang/libc/pull/4903)) +- Linux-like: Handle zero-sized payload differences in `CMSG_NXTHDR` ([#4903](https://github.com/rust-lang/libc/pull/4903)) +- Musl: Fix incorrect definitions of struct stat on some 32-bit architectures ([#4914](https://github.com/rust-lang/libc/pull/4914)) +- NetBSD: RISC-V 64: Correct `mcontext` type definitions ([#4886](https://github.com/rust-lang/libc/pull/4886)) +- uClibc: Re-enable `__SIZEOF_PTHREAD_COND_T` on non-L4Re uclibc ([#4915](https://github.com/rust-lang/libc/pull/4915)) +- uClibc: Restructure Linux `netlink` module to resolve build errors ([#4915](https://github.com/rust-lang/libc/pull/4915)) + + +## [0.2.179](https://github.com/rust-lang/libc/compare/0.2.178...0.2.179) - 2025-01-03 + +With this release, we now have _unstable_ support for 64-bit `time_t` on 32-bit +platforms with both Musl and Glibc. Testing is appreciated! + +For now, these can be enabled by setting environment variables during build: + +```text +RUST_LIBC_UNSTABLE_MUSL_V1_2_3=1 +RUST_LIBC_UNSTABLE_GNU_TIME_BITS=64 +``` + +Note that the exact configuration will change in the future. Setting the +`MUSL_V1_2_3` variable also enables some newer API unrelated to `time_t`. + +### Added + +- L4Re: Add uclibc aarch64 support ([#4479](https://github.com/rust-lang/libc/pull/4479)) +- Linux, Android: Add a generic definition for `XCASE` ([#4847](https://github.com/rust-lang/libc/pull/4847)) +- Linux-like: Add `NAME_MAX` ([#4888](https://github.com/rust-lang/libc/pull/4888)) +- Linux: Add `AT_EXECVE_CHECK` ([#4422](https://github.com/rust-lang/libc/pull/4422)) +- Linux: Add the `SUN_LEN` macro ([#4269](https://github.com/rust-lang/libc/pull/4269)) +- Linux: add `getitimer` and `setitimer` ([#4890](https://github.com/rust-lang/libc/pull/4890)) +- Linux: add `pthread_tryjoin_n` and `pthread_timedjoin_np` ([#4887](https://github.com/rust-lang/libc/pull/4887)) +- Musl: Add unstable support for 64-bit `time_t` on 32-bit platforms ([#4463](https://github.com/rust-lang/libc/pull/4463)) +- NetBSD, OpenBSD: Add interface `LINK_STATE_*` definitions from `sys/net/if.h` ([#4751](https://github.com/rust-lang/libc/pull/4751)) +- QuRT: Add support for Qualcomm QuRT ([#4845](https://github.com/rust-lang/libc/pull/4845)) +- Types: Add Padding::uninit() ([#4862](https://github.com/rust-lang/libc/pull/4862)) + +### Fixed + +- Glibc: Link old version of `cf{g,s}et{i,o}speed` ([#4882](https://github.com/rust-lang/libc/pull/4882)) +- L4Re: Fixes for `pthread` ([#4479](https://github.com/rust-lang/libc/pull/4479)) +- L4re: Fix a wide variety of incorrect definitions ([#4479](https://github.com/rust-lang/libc/pull/4479)) +- Musl: Fix the value of `CPU_SETSIZE` on musl 1.2+ ([#4865](https://github.com/rust-lang/libc/pull/4865)) +- Musl: RISC-V: fix public padding fields in `stat/stat64` ([#4463](https://github.com/rust-lang/libc/pull/4463)) +- Musl: s390x: Fix definition of `SIGSTKSZ`/`MINSIGSTKSZ` ([#4884](https://github.com/rust-lang/libc/pull/4884)) +- NetBSD: Arm: Fix `PT_{GET,SET}FPREGS`, `_REG_TIPDR`, and `_REG_{LR,SP}` ([#4899](https://github.com/rust-lang/libc/pull/4899)) +- NetBSD: Fix `if_msghdr` alignment ([#4902](https://github.com/rust-lang/libc/pull/4902)) +- NetBSD: Fix `siginfo_t` layout on 32-bit platforms ([#4904](https://github.com/rust-lang/libc/pull/4904)) +- NetBSD: change definition of `pthread_spin_t` to allow arch redefinition. ([#4899](https://github.com/rust-lang/libc/pull/4899)) +- Newlib: Fix ambiguous glob exports and other warnings for Vita and 3DS ([#4875](https://github.com/rust-lang/libc/pull/4875)) +- QNX: Fix build error ([#4879](https://github.com/rust-lang/libc/pull/4879)) + +### Changed + +- CI: Update CI images to FreeBSD 15.0-release ([#4857](https://github.com/rust-lang/libc/pull/4857)) +- L4Re: Make `pthread` struct fields private ([#4876](https://github.com/rust-lang/libc/pull/4876)) +- Linux, Fuchsia: Mark mq_attr padding area as such ([#4858](https://github.com/rust-lang/libc/pull/4858)) +- Types: Wrap a number of private fields in the `Padding` type ([#4862](https://github.com/rust-lang/libc/pull/4862)) + +### Removed + +- Build: Remove `RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64` ([#4865](https://github.com/rust-lang/libc/pull/4865)) +- WASI: Remove nonexistent clocks ([#4880](https://github.com/rust-lang/libc/pull/4880)) + + +## [0.2.178](https://github.com/rust-lang/libc/compare/0.2.177...0.2.178) - 2025-12-01 + +### Added + +- BSD: Add `issetugid` ([#4744](https://github.com/rust-lang/libc/pull/4744)) +- Cygwin: Add missing utmp/x.h, grp.h, and stdio.h interfaces ([#4827](https://github.com/rust-lang/libc/pull/4827)) +- Linux s390x musl: Add `__psw_t`/`fprefset_t`/`*context_t` ([#4726](https://github.com/rust-lang/libc/pull/4726)) +- Linux, Android: Add definition for IUCLC ([#4846](https://github.com/rust-lang/libc/pull/4846)) +- Linux, FreeBSD: Add `AT_HWCAP{3,4}` ([#4734](https://github.com/rust-lang/libc/pull/4734)) +- Linux: Add definitions from linux/can/bcm.h ([#4683](https://github.com/rust-lang/libc/pull/4683)) +- Linux: Add syscalls 451-469 for m68k ([#4850](https://github.com/rust-lang/libc/pull/4850)) +- Linux: PowerPC: Add 'ucontext.h' definitions ([#4696](https://github.com/rust-lang/libc/pull/4696)) +- NetBSD: Define `eventfd` ([#4830](https://github.com/rust-lang/libc/pull/4830)) +- Newlib: Add missing constants from `unistd.h` ([#4811](https://github.com/rust-lang/libc/pull/4811)) +- QNX NTO: Add `cfmakeraw` ([#4704](https://github.com/rust-lang/libc/pull/4704)) +- QNX NTO: Add `cfsetspeed` ([#4704](https://github.com/rust-lang/libc/pull/4704)) +- Redox: Add `getresgid` and `getresuid` ([#4752](https://github.com/rust-lang/libc/pull/4752)) +- Redox: Add `setresgid` and `setresuid` ([#4752](https://github.com/rust-lang/libc/pull/4752)) +- VxWorks: Add definitions from `select.h`, `stat.h`, `poll.h`, `ttycom.h`, `utsname.h`, `resource.h`, `mman.h`, `udp.h`, `in.h`, `in6.h`, `if.h`, `fnmatch.h`, and `sioLibCommon.h` ([#4781](https://github.com/rust-lang/libc/pull/4781)) +- VxWorks: Add missing defines/functions needed by rust stdlib ([#4779](https://github.com/rust-lang/libc/pull/4779)) +- WASI: Add more definitions for libstd ([#4747](https://github.com/rust-lang/libc/pull/4747)) + +### Deprecated + +- Apple: Deprecate `TIOCREMOTE` ([#4764](https://github.com/rust-lang/libc/pull/4764)) + +### Fixed + +Note that there were a large number of fixes on NetBSD for this `libc` release, some of which include minor breakage. + +- AIX: Change errno `EWOULDBLOCK` to make it an alias of `EAGAIN` ([#4790](https://github.com/rust-lang/libc/pull/4790)) +- AIX: Resolve function comparison and `unnecessary_transmutes` warnings ([#4780](https://github.com/rust-lang/libc/pull/4780)) +- Apple: Correct the value of `SF_SETTABLE` ([#4764](https://github.com/rust-lang/libc/pull/4764)) +- DragonflyBSD: Fix the type of `mcontext_t.mc_fpregs` ([#]()) +- EspIDF: Fix the duplicate definition of `gethostname` ([#4773](https://github.com/rust-lang/libc/pull/4773)) +- L4Re: Update available pthread API ([#4836](https://github.com/rust-lang/libc/pull/4836)) +- Linux: Correct the value of `NFT_MSG_MAX` ([#4761](https://github.com/rust-lang/libc/pull/4761)) +- Linux: Remove incorrect `repr(align(8))` for `canxl_frame` ([#4760](https://github.com/rust-lang/libc/pull/4760)) +- Make `eventfd` argument names match OS docs/headers ([#4830](https://github.com/rust-lang/libc/pull/4830)) +- NetBSD: Account for upstream changes to ptrace with LWP ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Correct `ipc_perm`, split from OpenBSD as `ipc.rs` ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Correct a number of symbol link names ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Correct the type of `kinfo_vmentry.kve_path` ([#]()) +- NetBSD: Fix `uucred.cr_ngroups` from `int` to `short` ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Fix the type of `kevent.udata` ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Fix the type of `mcontext_t.__fpregs` ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Fix the value of `PT_SUSPEND` ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Fix the values of FNM_* constants ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Increase the size of `sockaddr_dl.sdl_data` from 12 to 24 ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Introduce `if_.rs`, fix the definition of `ifreq` ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Introduce `time.rs`, fix the values of `CLOCK_*_CPUTIME_ID` ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Introduce `timex.rs` ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Introduce `types.rs`, correct the definition of `lwpid_t` ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Introduce `utmp_.rs`, correct the definition of `lastlog` ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Introduce `utmpx_.rs`, correct utmpx definitions ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Make `_cpuset` an extern type ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: RISC-V 64: Fix the `mcontext` types ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- Nuttx: Resolve warnings ([#4773](https://github.com/rust-lang/libc/pull/4773)) +- OHOS: Don't emit duplicate lfs64 definitions ([#4804](https://github.com/rust-lang/libc/pull/4804)) +- Redox: Fix the type of `pid_t` ([#4825](https://github.com/rust-lang/libc/pull/4825)) +- WASI: Gate `__wasilibc_register_preopened_fd` ([#4837](https://github.com/rust-lang/libc/pull/4837)) +- Wali: Fix unknown config ([#4773](https://github.com/rust-lang/libc/pull/4773)) + +### Changed + +- AIX: Declare field 'tv_nsec' of structure 'timespec' as 'i32' in both 32-bit and 64-bit modes ([#4750](https://github.com/rust-lang/libc/pull/4750)) +- DragonFly: Avoid usage of `thread_local` ([#3653](https://github.com/rust-lang/libc/pull/3653)) +- Linux: Update the definition for `ucontext_t` and unskip its tests ([#4760](https://github.com/rust-lang/libc/pull/4760)) +- MinGW: Set `L_tmpnam` and `TMP_MAX` to the UCRT value ([#4566](https://github.com/rust-lang/libc/pull/4566)) +- WASI: More closely align pthread type reprs ([#4747](https://github.com/rust-lang/libc/pull/4747)) +- Simplify rustc-check-cfg emission in build.rs ([#4724](https://github.com/rust-lang/libc/pull/4724)) +- Transition a number of definitions to the new source structure (internal change) + +### Removed + +- MIPS Musl: Remove rogue definition of `SIGSTKFLT` ([#4749](https://github.com/rust-lang/libc/pull/4749)) +- NetBSD: Make `statvfs.f_spare` non-public ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Remove BPF constants ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Remove `*_MAXID` constants and `AT_SUN_LDPGSIZE` ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Remove `IFF_NOTRAILERS` ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Remove `vm_size_t` ([#4782](https://github.com/rust-lang/libc/pull/4782)) +- NetBSD: Replace REG_ENOSYS with REG_ILLSEQ ([#4782](https://github.com/rust-lang/libc/pull/4782)) + + +## [0.2.177](https://github.com/rust-lang/libc/compare/0.2.176...0.2.177) - 2025-10-09 + +### Added + +- Apple: Add `TIOCGETA`, `TIOCSETA`, `TIOCSETAW`, `TIOCSETAF` constants ([#4736](https://github.com/rust-lang/libc/pull/4736)) +- Apple: Add `pthread_cond_timedwait_relative_np` ([#4719](https://github.com/rust-lang/libc/pull/4719)) +- BSDs: Add `_CS_PATH` constant ([#4738](https://github.com/rust-lang/libc/pull/4738)) +- Linux-like: Add `SIGEMT` for mips* and sparc* architectures ([#4730](https://github.com/rust-lang/libc/pull/4730)) +- OpenBSD: Add `elf_aux_info` ([#4729](https://github.com/rust-lang/libc/pull/4729)) +- Redox: Add more sysconf constants ([#4728](https://github.com/rust-lang/libc/pull/4728)) +- Windows: Add `wcsnlen` ([#4721](https://github.com/rust-lang/libc/pull/4721)) + +### Changed + +- WASIP2: Invert conditional to include p2 APIs ([#4733](https://github.com/rust-lang/libc/pull/4733)) + +## [0.2.176](https://github.com/rust-lang/libc/compare/0.2.175...0.2.176) - 2025-09-23 + +### Support + +- The default FreeBSD version has been raised from 11 to 12. This matches `rustc` since 1.78. ([#2406](https://github.com/rust-lang/libc/pull/2406)) +- `Debug` is now always implemented, rather than being gated behind the `extra_traits` feature. ([#4624](https://github.com/rust-lang/libc/pull/4624)) + +### Added + +- AIX: Restore some non-POSIX functions guarded by the `_KERNEL` macro. ([#4607](https://github.com/rust-lang/libc/pull/4607)) +- FreeBSD 14: Add `st_fileref` to `struct stat` ([#4642](https://github.com/rust-lang/libc/pull/4642)) +- Haiku: Add the `accept4` POSIX call ([#4586](https://github.com/rust-lang/libc/pull/4586)) +- Introduce a wrapper for representing padding ([#4632](https://github.com/rust-lang/libc/pull/4632)) +- Linux: Add `EM_RISCV` ([#4659](https://github.com/rust-lang/libc/pull/4659)) +- Linux: Add `MS_NOSYMFOLLOW` ([#4389](https://github.com/rust-lang/libc/pull/4389)) +- Linux: Add `backtrace_symbols(_fd)` ([#4668](https://github.com/rust-lang/libc/pull/4668)) +- Linux: Add missing `SOL_PACKET` optnames ([#4669](https://github.com/rust-lang/libc/pull/4669)) +- Musl s390x: Add `SYS_mseal` ([#4549](https://github.com/rust-lang/libc/pull/4549)) +- NuttX: Add `__errno` ([#4687](https://github.com/rust-lang/libc/pull/4687)) +- Redox: Add `dirfd`, `VDISABLE`, and resource consts ([#4660](https://github.com/rust-lang/libc/pull/4660)) +- Redox: Add more `resource.h`, `fcntl.h` constants ([#4666](https://github.com/rust-lang/libc/pull/4666)) +- Redox: Enable `strftime` and `mkostemp[s]` ([#4629](https://github.com/rust-lang/libc/pull/4629)) +- Unix, Windows: Add `qsort_r` (Unix), and `qsort(_s)` (Windows) ([#4677](https://github.com/rust-lang/libc/pull/4677)) +- Unix: Add `dlvsym` for Linux-gnu, FreeBSD, and NetBSD ([#4671](https://github.com/rust-lang/libc/pull/4671)) +- Unix: Add `sigqueue` ([#4620](https://github.com/rust-lang/libc/pull/4620)) + +### Changed + +- FreeBSD 15: Mark `kinfo_proc` as non-exhaustive ([#4553](https://github.com/rust-lang/libc/pull/4553)) +- FreeBSD: Set the ELF symbol version for `readdir_r` ([#4694](https://github.com/rust-lang/libc/pull/4694)) +- Linux: Correct the config for whether or not `epoll_event` is packed ([#4639](https://github.com/rust-lang/libc/pull/4639)) +- Tests: Replace the old `ctest` with the much more reliable new implementation ([#4655](https://github.com/rust-lang/libc/pull/4655) and many related PRs) + +### Fixed + +- AIX: Fix the type of the 4th arguement of `getgrnam_r` ([#4656](https://github.com/rust-lang/libc/pull/4656 +- FreeBSD: Limit `P_IDLEPROC` to FreeBSD 15 ([#4640](https://github.com/rust-lang/libc/pull/4640)) +- FreeBSD: Limit `mcontext_t::mc_tlsbase` to FreeBSD 15 ([#4640](https://github.com/rust-lang/libc/pull/464)) +- FreeBSD: Update gating of `mcontext_t.mc_tlsbase` ([#4703](https://github.com/rust-lang/libc/pull/4703)) +- Musl s390x: Correct the definition of `statfs[64]` ([#4549](https://github.com/rust-lang/libc/pull/4549)) +- Musl s390x: Make `fpreg_t` a union ([#4549](https://github.com/rust-lang/libc/pull/4549)) +- Redox: Fix the types of `gid_t` and `uid_t` ([#4689](https://github.com/rust-lang/libc/pull/4689)) +- Redox: Fix the value of `MAP_FIXED` ([#4684](https://github.com/rust-lang/libc/pull/4684)) + +### Deprecated + +- Apple: Correct the `deprecated` attribute for `iconv` ([`a97a0b53`](https://github.com/rust-lang/libc/commit/a97a0b53fb7faf5f99cd720ab12b1b8a5bf9f950)) +- FreeBSD: Deprecate `TIOCMGDTRWAIT` and `TIOCMSDTRWAIT` ([#4685](https://github.com/rust-lang/libc/pull/4685)) + +### Removed + +- FreeBSD: Remove `JAIL_{GET,SET}_MASK`, `_MC_FLAG_MASK` ([#4691](https://github.com/rust-lang/libc/pull/4691)) + +## [0.2.175](https://github.com/rust-lang/libc/compare/0.2.174...0.2.175) - 2025-08-10 + +### Added + +- AIX: Add `getpeereid` ([#4524](https://github.com/rust-lang/libc/pull/4524)) +- AIX: Add `struct ld_info` and friends ([#4578](https://github.com/rust-lang/libc/pull/4578)) +- AIX: Retore `struct winsize` ([#4577](https://github.com/rust-lang/libc/pull/4577)) +- Android: Add UDP socket option constants ([#4619](https://github.com/rust-lang/libc/pull/4619)) +- Android: Add `CLONE_CLEAR_SIGHAND` and `CLONE_INTO_CGROUP` ([#4502](https://github.com/rust-lang/libc/pull/4502)) +- Android: Add more `prctl` constants ([#4531](https://github.com/rust-lang/libc/pull/4531)) +- FreeBSD Add further TCP stack-related constants ([#4196](https://github.com/rust-lang/libc/pull/4196)) +- FreeBSD x86-64: Add `mcontext_t.mc_tlsbase ` ([#4503](https://github.com/rust-lang/libc/pull/4503)) +- FreeBSD15: Add `kinfo_proc.ki_uerrmsg` ([#4552](https://github.com/rust-lang/libc/pull/4552)) +- FreeBSD: Add `in_conninfo` ([#4482](https://github.com/rust-lang/libc/pull/4482)) +- FreeBSD: Add `xinpgen` and related types ([#4482](https://github.com/rust-lang/libc/pull/4482)) +- FreeBSD: Add `xktls_session` ([#4482](https://github.com/rust-lang/libc/pull/4482)) +- Haiku: Add functionality from `libbsd` ([#4221](https://github.com/rust-lang/libc/pull/4221)) +- Linux: Add `SECBIT_*` ([#4480](https://github.com/rust-lang/libc/pull/4480)) +- NetBSD, OpenBSD: Export `ioctl` request generator macros ([#4460](https://github.com/rust-lang/libc/pull/4460)) +- NetBSD: Add `ptsname_r` ([#4608](https://github.com/rust-lang/libc/pull/4608)) +- RISCV32: Add time-related syscalls ([#4612](https://github.com/rust-lang/libc/pull/4612)) +- Solarish: Add `strftime*` ([#4453](https://github.com/rust-lang/libc/pull/4453)) +- linux: Add `EXEC_RESTRICT_*` and `EXEC_DENY_*` ([#4545](https://github.com/rust-lang/libc/pull/4545)) + +### Changed + +- AIX: Add `const` to signatures to be consistent with other platforms ([#4563](https://github.com/rust-lang/libc/pull/4563)) + +### Fixed + +- AIX: Fix the type of `struct statvfs.f_fsid` ([#4576](https://github.com/rust-lang/libc/pull/4576)) +- AIX: Fix the type of constants for the `ioctl` `request` argument ([#4582](https://github.com/rust-lang/libc/pull/4582)) +- AIX: Fix the types of `stat{,64}.st_*tim` ([#4597](https://github.com/rust-lang/libc/pull/4597)) +- AIX: Use unique `errno` values ([#4507](https://github.com/rust-lang/libc/pull/4507)) +- Build: Fix an incorrect `target_os` -> `target_arch` check ([#4550](https://github.com/rust-lang/libc/pull/4550)) +- FreeBSD: Fix the type of `xktls_session_onedir.ifnet` ([#4552](https://github.com/rust-lang/libc/pull/4552)) +- Mips64 musl: Fix the type of `nlink_t` ([#4509](https://github.com/rust-lang/libc/pull/4509)) +- Mips64 musl: Use a special MIPS definition of `stack_t` ([#4528](https://github.com/rust-lang/libc/pull/4528)) +- Mips64: Fix `SI_TIMER`, `SI_MESGQ` and `SI_ASYNCIO` definitions ([#4529](https://github.com/rust-lang/libc/pull/4529)) +- Musl Mips64: Swap the order of `si_errno` and `si_code` in `siginfo_t` ([#4530](https://github.com/rust-lang/libc/pull/4530)) +- Musl Mips64: Use a special MIPS definition of `statfs` ([#4527](https://github.com/rust-lang/libc/pull/4527)) +- Musl: Fix the definition of `fanotify_event_metadata` ([#4510](https://github.com/rust-lang/libc/pull/4510)) +- NetBSD: Correct `enum fae_action` to be `#[repr(C)]` ([#60a8cfd5](https://github.com/rust-lang/libc/commit/60a8cfd564f83164d45b9533ff7a0d7371878f2a)) +- PSP: Correct `char` -> `c_char` ([eaab4fc3](https://github.com/rust-lang/libc/commit/eaab4fc3f05dc646a953d4fd5ba46dfa1f8bd6f6)) +- PowerPC musl: Fix `termios` definitions ([#4518](https://github.com/rust-lang/libc/pull/4518)) +- PowerPC musl: Fix the definition of `EDEADLK` ([#4517](https://github.com/rust-lang/libc/pull/4517)) +- PowerPC musl: Fix the definition of `NCCS` ([#4513](https://github.com/rust-lang/libc/pull/4513)) +- PowerPC musl: Fix the definitions of `MAP_LOCKED` and `MAP_NORESERVE` ([#4516](https://github.com/rust-lang/libc/pull/4516)) +- PowerPC64 musl: Fix the definition of `shmid_ds` ([#4519](https://github.com/rust-lang/libc/pull/4519)) + +### Deprecated + +- Linux: `MAP_32BIT` is only defined on x86 on non-x86 architectures ([#4511](https://github.com/rust-lang/libc/pull/4511)) + +### Removed + +- AIX: Remove duplicate constant definitions `FIND` and `ENTER` ([#4588](https://github.com/rust-lang/libc/pull/4588)) +- s390x musl: Remove `O_FSYNC` ([#4515](https://github.com/rust-lang/libc/pull/4515)) +- s390x musl: Remove `RTLD_DEEPBIND` ([#4515](https://github.com/rust-lang/libc/pull/4515)) + + +## [0.2.174](https://github.com/rust-lang/libc/compare/0.2.173...0.2.174) - 2025-06-17 + +### Added + +- Linux: Make `pidfd_info` fields pub ([#4487](https://github.com/rust-lang/libc/pull/4487)) + +### Fixed + +- Gnu x32: Add missing `timespec.tv_nsec` ([#4497](https://github.com/rust-lang/libc/pull/4497)) +- NuttX: Use `nlink_t` type for `st_nlink` in `struct stat` definition ([#4483](https://github.com/rust-lang/libc/pull/4483)) + +### Other + +- Allow new `unpredictable_function_pointer_comparisons` lints ([#4489](https://github.com/rust-lang/libc/pull/4489)) +- OpenBSD: Fix some clippy warnings to use `pointer::cast`. ([#4490](https://github.com/rust-lang/libc/pull/4490)) +- Remove unessecary semicolons from definitions of `CMSG_NXTHDR`. ([#4492](https://github.com/rust-lang/libc/pull/4492)) + + +## [0.2.173](https://github.com/rust-lang/libc/compare/0.2.172...0.2.173) - 2025-06-09 + +### Added + +- AIX: Add an AIX triple to Cargo.toml for doc ([#4475](https://github.com/rust-lang/libc/pull/4475)) +- FreeBSD: Add the `SO_SPLICE` socket option support for FreeBSD >= 14.2 ([#4451](https://github.com/rust-lang/libc/pull/4451)) +- Linux GNU: Prepare for supporting `_TIME_BITS=64` ([#4433](https://github.com/rust-lang/libc/pull/4433)) +- Linux: Add constant PACKET_IGNORE_OUTGOING ([#4319](https://github.com/rust-lang/libc/pull/4319)) +- Linux: Add constants and types for `nsfs` ioctls ([#4436](https://github.com/rust-lang/libc/pull/4436)) +- Linux: Add constants for Memory-Deny-Write-Execute `prctls` ([#4400](https://github.com/rust-lang/libc/pull/4400)) +- Linux: Add constants from `linux/cn_proc.h` and `linux/connector.h` ([#4434](https://github.com/rust-lang/libc/pull/4434)) +- Linux: Add new flags for `pwritev2` and `preadv2` ([#4452](https://github.com/rust-lang/libc/pull/4452)) +- Linux: Add pid_type enum values ([#4403](https://github.com/rust-lang/libc/pull/4403)) +- Linux: Update pidfd constants and types (Linux 6.9-6.15) ([#4402](https://github.com/rust-lang/libc/pull/4402)) +- Loongarch64 musl: Define the `MADV_SOFT_OFFLINE` constant ([#4448](https://github.com/rust-lang/libc/pull/4448)) +- Musl: Add new fields since 1.2.0/1.2.2 to `struct tcp_info` ([#4443](https://github.com/rust-lang/libc/pull/4443)) +- Musl: Prepare for supporting v1.2.3 ([#4443](https://github.com/rust-lang/libc/pull/4443)) +- NuttX: Add `arc4random` and `arc4random_buf` ([#4464](https://github.com/rust-lang/libc/pull/4464)) +- RISC-V Musl: Add `MADV_SOFT_OFFLINE` definition ([#4447](https://github.com/rust-lang/libc/pull/4447)) +- Redox: Define SCM_RIGHTS ([#4440](https://github.com/rust-lang/libc/pull/4440)) +- VxWorks: Add missing UTIME defines and TASK_RENAME_LENGTH ([#4407](https://github.com/rust-lang/libc/pull/4407)) +- Windows: Add more `time.h` functions ([#4427](https://github.com/rust-lang/libc/pull/4427)) + +### Changed + +- Redox: Update `SA_` constants. ([#4426](https://github.com/rust-lang/libc/pull/4426)) +- Redox: make `CMSG_ALIGN`, `CMSG_LEN`, and `CMSG_SPACE` const functions ([#4441](https://github.com/rust-lang/libc/pull/4441)) + +### Fixed + +- AIX: Enable libc-test and fix definitions/declarations. ([#4450](https://github.com/rust-lang/libc/pull/4450)) +- Emscripten: Fix querying emcc on windows (use emcc.bat) ([#4248](https://github.com/rust-lang/libc/pull/4248)) +- Hurd: Fix build from missing `fpos_t` ([#4472](https://github.com/rust-lang/libc/pull/4472)) +- Loongarch64 Musl: Fix the `struct ipc_perm` bindings ([#4384](https://github.com/rust-lang/libc/pull/4384)) +- Musl: Fix the `O_LARGEFILE` constant value. ([#4443](https://github.com/rust-lang/libc/pull/4443)) + +## [0.2.172](https://github.com/rust-lang/libc/compare/0.2.171...0.2.172) - 2025-04-14 + +### Added + +- Android: Add `getauxval` for 32-bit targets ([#4338](https://github.com/rust-lang/libc/pull/4338)) +- Android: Add `if_tun.h` ioctls ([#4379](https://github.com/rust-lang/libc/pull/4379)) +- Android: Define `SO_BINDTOIFINDEX` ([#4391](https://github.com/rust-lang/libc/pull/4391)) +- Cygwin: Add `posix_spawn_file_actions_add[f]chdir[_np]` ([#4387](https://github.com/rust-lang/libc/pull/4387)) +- Cygwin: Add new socket options ([#4350](https://github.com/rust-lang/libc/pull/4350)) +- Cygwin: Add statfs & fcntl ([#4321](https://github.com/rust-lang/libc/pull/4321)) +- FreeBSD: Add `filedesc` and `fdescenttbl` ([#4327](https://github.com/rust-lang/libc/pull/4327)) +- Glibc: Add unstable support for _FILE_OFFSET_BITS=64 ([#4345](https://github.com/rust-lang/libc/pull/4345)) +- Hermit: Add `AF_UNSPEC` ([#4344](https://github.com/rust-lang/libc/pull/4344)) +- Hermit: Add `AF_VSOCK` ([#4344](https://github.com/rust-lang/libc/pull/4344)) +- Illumos, NetBSD: Add `timerfd` APIs ([#4333](https://github.com/rust-lang/libc/pull/4333)) +- Linux: Add `_IO`, `_IOW`, `_IOR`, `_IOWR` to the exported API ([#4325](https://github.com/rust-lang/libc/pull/4325)) +- Linux: Add `tcp_info` to uClibc bindings ([#4347](https://github.com/rust-lang/libc/pull/4347)) +- Linux: Add further BPF program flags ([#4356](https://github.com/rust-lang/libc/pull/4356)) +- Linux: Add missing INPUT_PROP_XXX flags from `input-event-codes.h` ([#4326](https://github.com/rust-lang/libc/pull/4326)) +- Linux: Add missing TLS bindings ([#4296](https://github.com/rust-lang/libc/pull/4296)) +- Linux: Add more constants from `seccomp.h` ([#4330](https://github.com/rust-lang/libc/pull/4330)) +- Linux: Add more glibc `ptrace_sud_config` and related `PTRACE_*ET_SYSCALL_USER_DISPATCH_CONFIG`. ([#4386](https://github.com/rust-lang/libc/pull/4386)) +- Linux: Add new netlink flags ([#4288](https://github.com/rust-lang/libc/pull/4288)) +- Linux: Define ioctl codes on more architectures ([#4382](https://github.com/rust-lang/libc/pull/4382)) +- Linux: Add missing `pthread_attr_setstack` ([#4349](https://github.com/rust-lang/libc/pull/4349)) +- Musl: Add missing `utmpx` API ([#4332](https://github.com/rust-lang/libc/pull/4332)) +- Musl: Enable `getrandom` on all platforms ([#4346](https://github.com/rust-lang/libc/pull/4346)) +- NuttX: Add more signal constants ([#4353](https://github.com/rust-lang/libc/pull/4353)) +- QNX: Add QNX 7.1-iosock and 8.0 to list of additional cfgs ([#4169](https://github.com/rust-lang/libc/pull/4169)) +- QNX: Add support for alternative Neutrino network stack `io-sock` ([#4169](https://github.com/rust-lang/libc/pull/4169)) +- Redox: Add more `sys/socket.h` and `sys/uio.h` definitions ([#4388](https://github.com/rust-lang/libc/pull/4388)) +- Solaris: Temporarily define `O_DIRECT` and `SIGINFO` ([#4348](https://github.com/rust-lang/libc/pull/4348)) +- Solarish: Add `secure_getenv` ([#4342](https://github.com/rust-lang/libc/pull/4342)) +- VxWorks: Add missing `d_type` member to `dirent` ([#4352](https://github.com/rust-lang/libc/pull/4352)) +- VxWorks: Add missing signal-related constsants ([#4352](https://github.com/rust-lang/libc/pull/4352)) +- VxWorks: Add more error codes ([#4337](https://github.com/rust-lang/libc/pull/4337)) + +### Deprecated + +- FreeBSD: Deprecate `TCP_PCAP_OUT` and `TCP_PCAP_IN` ([#4381](https://github.com/rust-lang/libc/pull/4381)) + +### Fixed + +- Cygwin: Fix member types of `statfs` ([#4324](https://github.com/rust-lang/libc/pull/4324)) +- Cygwin: Fix tests ([#4357](https://github.com/rust-lang/libc/pull/4357)) +- Hermit: Make `AF_INET = 3` ([#4344](https://github.com/rust-lang/libc/pull/4344)) +- Musl: Fix the syscall table on RISC-V-32 ([#4335](https://github.com/rust-lang/libc/pull/4335)) +- Musl: Fix the value of `SA_ONSTACK` on RISC-V-32 ([#4335](https://github.com/rust-lang/libc/pull/4335)) +- VxWorks: Fix a typo in the `waitpid` parameter name ([#4334](https://github.com/rust-lang/libc/pull/4334)) + +### Removed + +- Musl: Remove `O_FSYNC` on RISC-V-32 (use `O_SYNC` instead) ([#4335](https://github.com/rust-lang/libc/pull/4335)) +- Musl: Remove `RTLD_DEEPBIND` on RISC-V-32 ([#4335](https://github.com/rust-lang/libc/pull/4335)) + +### Other + +- CI: Add matrix env variables to the environment ([#4345](https://github.com/rust-lang/libc/pull/4345)) +- CI: Always deny warnings ([#4363](https://github.com/rust-lang/libc/pull/4363)) +- CI: Always upload successfully created artifacts ([#4345](https://github.com/rust-lang/libc/pull/4345)) +- CI: Install musl from source for loongarch64 ([#4320](https://github.com/rust-lang/libc/pull/4320)) +- CI: Revert "Also skip `MFD_EXEC` and `MFD_NOEXEC_SEAL` on sparc64" ([#]()) +- CI: Use `$PWD` instead of `$(pwd)` in run-docker ([#4345](https://github.com/rust-lang/libc/pull/4345)) +- Solarish: Restrict `openpty` and `forkpty` polyfills to Illumos, replace Solaris implementation with bindings ([#4329](https://github.com/rust-lang/libc/pull/4329)) +- Testing: Ensure the makedev test does not emit unused errors ([#4363](https://github.com/rust-lang/libc/pull/4363)) + +## [0.2.171](https://github.com/rust-lang/libc/compare/0.2.170...0.2.171) - 2025-03-11 + +### Added + +- Android: Add `if_nameindex`/`if_freenameindex` support ([#4247](https://github.com/rust-lang/libc/pull/4247)) +- Apple: Add missing proc types and constants ([#4310](https://github.com/rust-lang/libc/pull/4310)) +- BSD: Add `devname` ([#4285](https://github.com/rust-lang/libc/pull/4285)) +- Cygwin: Add PTY and group API ([#4309](https://github.com/rust-lang/libc/pull/4309)) +- Cygwin: Add support ([#4279](https://github.com/rust-lang/libc/pull/4279)) +- FreeBSD: Make `spawn.h` interfaces available on all FreeBSD-like systems ([#4294](https://github.com/rust-lang/libc/pull/4294)) +- Linux: Add `AF_XDP` structs for all Linux environments ([#4163](https://github.com/rust-lang/libc/pull/4163)) +- Linux: Add SysV semaphore constants ([#4286](https://github.com/rust-lang/libc/pull/4286)) +- Linux: Add `F_SEAL_EXEC` ([#4316](https://github.com/rust-lang/libc/pull/4316)) +- Linux: Add `SO_PREFER_BUSY_POLL` and `SO_BUSY_POLL_BUDGET` ([#3917](https://github.com/rust-lang/libc/pull/3917)) +- Linux: Add `devmem` structs ([#4299](https://github.com/rust-lang/libc/pull/4299)) +- Linux: Add socket constants up to `SO_DEVMEM_DONTNEED` ([#4299](https://github.com/rust-lang/libc/pull/4299)) +- NetBSD, OpenBSD, DragonflyBSD: Add `closefrom` ([#4290](https://github.com/rust-lang/libc/pull/4290)) +- NuttX: Add `pw_passwd` field to `passwd` ([#4222](https://github.com/rust-lang/libc/pull/4222)) +- Solarish: define `IP_BOUND_IF` and `IPV6_BOUND_IF` ([#4287](https://github.com/rust-lang/libc/pull/4287)) +- Wali: Add bindings for `wasm32-wali-linux-musl` target ([#4244](https://github.com/rust-lang/libc/pull/4244)) + +### Changed + +- AIX: Use `sa_sigaction` instead of a union ([#4250](https://github.com/rust-lang/libc/pull/4250)) +- Make `msqid_ds.__msg_cbytes` public ([#4301](https://github.com/rust-lang/libc/pull/4301)) +- Unix: Make all `major`, `minor`, `makedev` into `const fn` ([#4208](https://github.com/rust-lang/libc/pull/4208)) + +### Deprecated + +- Linux: Deprecate obsolete packet filter interfaces ([#4267](https://github.com/rust-lang/libc/pull/4267)) + +### Fixed + +- Cygwin: Fix strerror_r ([#4308](https://github.com/rust-lang/libc/pull/4308)) +- Cygwin: Fix usage of f! ([#4308](https://github.com/rust-lang/libc/pull/4308)) +- Hermit: Make `stat::st_size` signed ([#4298](https://github.com/rust-lang/libc/pull/4298)) +- Linux: Correct values for `SI_TIMER`, `SI_MESGQ`, `SI_ASYNCIO` ([#4292](https://github.com/rust-lang/libc/pull/4292)) +- NuttX: Update `tm_zone` and `d_name` fields to use `c_char` type ([#4222](https://github.com/rust-lang/libc/pull/4222)) +- Xous: Include the prelude to define `c_int` ([#4304](https://github.com/rust-lang/libc/pull/4304)) + +### Other + +- Add labels to FIXMEs ([#4231](https://github.com/rust-lang/libc/pull/4231), [#4232](https://github.com/rust-lang/libc/pull/4232), [#4234](https://github.com/rust-lang/libc/pull/4234), [#4235](https://github.com/rust-lang/libc/pull/4235), [#4236](https://github.com/rust-lang/libc/pull/4236)) +- CI: Fix "cannot find libc" error on Sparc64 ([#4317](https://github.com/rust-lang/libc/pull/4317)) +- CI: Fix "cannot find libc" error on s390x ([#4317](https://github.com/rust-lang/libc/pull/4317)) +- CI: Pass `--no-self-update` to `rustup update` ([#4306](https://github.com/rust-lang/libc/pull/4306)) +- CI: Remove tests for the `i586-pc-windows-msvc` target ([#4311](https://github.com/rust-lang/libc/pull/4311)) +- CI: Remove the `check_cfg` job ([#4322](https://github.com/rust-lang/libc/pull/4312)) +- Change the range syntax that is giving `ctest` problems ([#4311](https://github.com/rust-lang/libc/pull/4311)) +- Linux: Split out the stat struct for gnu/b32/mips ([#4276](https://github.com/rust-lang/libc/pull/4276)) + +### Removed + +- NuttX: Remove `pthread_set_name_np` ([#4251](https://github.com/rust-lang/libc/pull/4251)) + +## [0.2.170](https://github.com/rust-lang/libc/compare/0.2.169...0.2.170) - 2025-02-23 + +### Added + +- Android: Declare `setdomainname` and `getdomainname` +- FreeBSD: Add `evdev` structures +- FreeBSD: Add the new `st_filerev` field to `stat32` ([#4254](https://github.com/rust-lang/libc/pull/4254)) +- Linux: Add `SI_*`` and `TRAP_*`` signal codes +- Linux: Add experimental configuration to enable 64-bit time in kernel APIs, set by `RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64`. +- Linux: Add recent socket timestamping flags +- Linux: Added new CANFD_FDF flag for the flags field of canfd_frame +- Musl: add CLONE_NEWTIME +- Solarish: add the posix_spawn family of functions + +### Deprecated + +- Linux: deprecate kernel modules syscalls + +### Changed + +- Emscripten: Assume version is at least 3.1.42 + +### Fixed + +- BSD: Correct the definition of `WEXITSTATUS` +- Hurd: Fix CMSG_DATA on 64bit systems ([#4240](https://github.com/rust-lang/libc/pull/424)) +- NetBSD: fix `getmntinfo` ([#4265](https://github.com/rust-lang/libc/pull/4265) +- VxWorks: Fix the size of `time_t` + +### Other + +- Add labels to FIXMEs , , +- CI: Bump FreeBSD CI to 13.4 and 14.2 +- Copy definitions from core::ffi and centralize them +- Define c_char at top-level and remove per-target c_char definitions +- Port style.rs to syn and add tests for the style checker + +## [0.2.169](https://github.com/rust-lang/libc/compare/0.2.168...0.2.169) - 2024-12-18 + +### Added + +- FreeBSD: add more socket TCP stack constants +- Fuchsia: add a `sockaddr_vm` definition + +### Fixed + +**Breaking**: [rust-lang/rust#132975](https://github.com/rust-lang/rust/pull/132975) corrected the signedness of `core::ffi::c_char` on various Tier 2 and Tier 3 platforms (mostly Arm and RISC-V) to match Clang. This release contains the corresponding changes to `libc`, including the following specific pull requests: + +- ESP-IDF: Replace arch-conditional `c_char` with a reexport +- Fix `c_char` on various targets +- Mirror `c_char` configuration from `rust-lang/rust` + +### Cleanup + +- Do not re-export `c_void` in target-specific code + +## [0.2.168](https://github.com/rust-lang/libc/compare/0.2.167...0.2.168) - 2024-12-09 + +### Added + +- Linux: Add new process flags ([#4174](https://github.com/rust-lang/libc/pull/4174)) +- Linux: Make `IFA_*` constants available on all Linux targets +- Linux: add `MAP_DROPPABLE` +- Solaris, Illumos: add `SIGRTMIN` and `SIGRTMAX` +- Unix, Linux: adding POSIX `memccpy` and `mempcpy` GNU extension +- CI: Upload artifacts created by libc-test +- CI: Use workflow commands to group output by target +- CI: add caching + +## [0.2.167](https://github.com/rust-lang/libc/compare/0.2.166...0.2.167) - 2024-11-28 + +### Added + +- Solarish: add `st_fstype` to `stat` +- Trusty: Add `intptr_t` and `uintptr_t` ([#4161](https://github.com/rust-lang/libc/pull/4161)) + +### Fixed + +- Fix the build with `rustc-dep-of-std` +- Wasi: Add back unsafe block for `clockid_t` static variables ([#4157](https://github.com/rust-lang/libc/pull/4157)) + +### Cleanup + +- Create an internal prelude +- Fix `unused_qualifications` + +### Other + +- CI: Check various FreeBSD versions ([#4159](https://github.com/rust-lang/libc/pull/4159)) +- CI: add a timeout for all jobs +- CI: verify MSRV for `wasm32-wasi` +- Migrate to the 2021 edition + +### Removed + +- Remove one unused import after the edition 2021 bump + +## [0.2.166](https://github.com/rust-lang/libc/compare/0.2.165...0.2.166) - 2024-11-26 + +### Fixed + +This release resolves two cases of unintentional breakage from the previous release: + +- Revert removal of array size hacks [#4150](https://github.com/rust-lang/libc/pull/4150) +- Ensure `const extern` functions are always enabled [#4151](https://github.com/rust-lang/libc/pull/4151) + +## [0.2.165](https://github.com/rust-lang/libc/compare/0.2.164...0.2.165) - 2024-11-25 + +### Added + +- Android: add `mkostemp`, `mkostemps` +- Android: add a few API 30 calls +- Android: add missing syscall constants +- Apple: add `in6_ifreq` +- Apple: add missing `sysctl` net types (before release: remove `if_family_id` ([#4137](https://github.com/rust-lang/libc/pulls/4137))) +- Freebsd: add `kcmp` call support +- Hurd: add `MAP_32BIT` and `MAP_EXCL` +- Hurd: add `domainname` field to `utsname` ([#4089](https://github.com/rust-lang/libc/pulls/4089)) +- Linux GNU: add `f_flags` to struct `statfs` for arm, mips, powerpc and x86 +- Linux GNU: add `malloc_stats` +- Linux: add ELF relocation-related structs +- Linux: add `ptp_*` structs +- Linux: add `ptp_clock_caps` +- Linux: add `ptp_pin_function` and most `PTP_` constants +- Linux: add missing AF_XDP structs & constants +- Linux: add missing netfilter consts ([#3734](https://github.com/rust-lang/libc/pulls/3734)) +- Linux: add struct and constants for the `mount_setattr` syscall +- Linux: add wireless API +- Linux: expose the `len8_dlc` field of `can_frame` +- Musl: add `utmpx` API +- Musl: add missing syscall constants +- NetBSD: add `mcontext`-related data for RISCV64 +- Redox: add new `netinet` constants ) +- Solarish: add `_POSIX_VDISABLE` ([#4103](https://github.com/rust-lang/libc/pulls/4103)) +- Tests: Add a test that the `const extern fn` macro works +- Tests: Add test of primitive types against `std` +- Unix: Add `htonl`, `htons`, `ntohl`, `ntohs` +- Unix: add `aligned_alloc` +- Windows: add `aligned_realloc` + +### Fixed + +- **breaking** Hurd: fix `MAP_HASSEMAPHORE` name ([#4127](https://github.com/rust-lang/libc/pulls/4127)) +- **breaking** ulibc Mips: fix `SA_*` mismatched types ([#3211](https://github.com/rust-lang/libc/pulls/3211)) +- Aix: fix an enum FFI safety warning +- Haiku: fix some typos ([#3664](https://github.com/rust-lang/libc/pulls/3664)) +- Tests: fix `Elf{32,64}_Relr`-related tests +- Tests: fix libc-tests for `loongarch64-linux-musl` +- Tests: fix some clippy warnings +- Tests: fix tests on `riscv64gc-unknown-freebsd` + +### Deprecated + +- Apple: deprecate `iconv_open` +- Apple: deprecate `mach_task_self` +- Apple: update `mach` deprecation notices for things that were removed in `main` + +### Cleanup + +- Adjust the `f!` macro to be more flexible +- Aix: remove duplicate constants +- CI: make scripts more uniform +- Drop the `libc_align` conditional +- Drop the `libc_cfg_target_vendor` conditional +- Drop the `libc_const_size_of` conditional +- Drop the `libc_core_cvoid` conditional +- Drop the `libc_int128` conditional +- Drop the `libc_non_exhaustive` conditional +- Drop the `libc_packedN` conditional +- Drop the `libc_priv_mod_use` conditional +- Drop the `libc_union` conditional +- Drop the `long_array` conditional +- Drop the `ptr_addr_of` conditional +- Drop warnings about deprecated cargo features +- Eliminate uses of `struct_formatter` +- Fix a few other array size hacks +- Glibc: remove redundant definitions ([#3261](https://github.com/rust-lang/libc/pulls/3261)) +- Musl: remove redundant definitions ([#3261](https://github.com/rust-lang/libc/pulls/3261)) +- Musl: unify definitions of `siginfo_t` ([#3261](https://github.com/rust-lang/libc/pulls/3261)) +- Musl: unify definitions of statfs and statfs64 ([#3261](https://github.com/rust-lang/libc/pulls/3261)) +- Musl: unify definitions of statvfs and statvfs64 ([#3261](https://github.com/rust-lang/libc/pulls/3261)) +- Musl: unify statx definitions ([#3978](https://github.com/rust-lang/libc/pulls/3978)) +- Remove array size hacks for Rust < 1.47 +- Remove repetitive words +- Use #[derive] for Copy/Clone in s! and friends +- Use some tricks to format macro bodies + +### Other + +- Apply formatting to macro bodies +- Bump libc-test to Rust 2021 Edition +- CI: Add a check that semver files don't contain duplicate entries +- CI: Add `fanotify_event_info_fid` to FAM-exempt types +- CI: Allow rustfmt to organize imports ([#4136](https://github.com/rust-lang/libc/pulls/4136)) +- CI: Always run rustfmt +- CI: Change 32-bit Docker images to use EOL repos +- CI: Change 64-bit Docker images to ubuntu:24.10 +- CI: Disable the check for >1 s! invocation +- CI: Ensure build channels get run even if FILTER is unset +- CI: Ensure there is a fallback for no_std +- CI: Fix cases where unset variables cause errors +- CI: Naming adjustments and cleanup +- CI: Only invoke rustup if running in CI +- CI: Remove the logic to handle old rust versions +- CI: Set -u (error on unset) in all script files +- CI: add support for `loongarch64-unknown-linux-musl` +- CI: make `aarch64-apple-darwin` not a nightly-only target +- CI: run shellcheck on all scripts +- CI: update musl headers to Linux 6.6 +- CI: use qemu-sparc64 to run sparc64 tests +- Drop the `libc_const_extern_fn` conditional +- Drop the `libc_underscore_const_names` conditional +- Explicitly set the edition to 2015 +- Introduce a `git-blame-ignore-revs` file +- Tests: Ignore fields as required on Ubuntu 24.10 +- Tests: skip `ATF_*` constants for OpenBSD +- Triagebot: Add an autolabel for CI + +## [0.2.164](https://github.com/rust-lang/libc/compare/0.2.163...0.2.164) - 2024-11-16 + +### MSRV + +This release increases the MSRV of `libc` to 1.63. + +### Other + +- CI: remove tests with rust < 1.63 +- MSRV: document the MSRV of the stable channel to be 1.63 +- MacOS: move ifconf to s_no_extra_traits + +## [0.2.163](https://github.com/rust-lang/libc/compare/0.2.162...0.2.163) - 2024-11-16 + +### Added + +- Aix: add more `dlopen` flags +- Android: add group calls +- FreeBSD: add `TCP_FUNCTION_BLK` and `TCP_FUNCTION_ALIAS` +- Linux: add `confstr` +- Solarish: add `aio` +- Solarish: add `arc4random*` + +### Changed + +- Emscripten: upgrade emsdk to 3.1.68 +- Hurd: use more standard types +- Hurd: use the standard `ssize_t = isize` +- Solaris: fix `confstr` and `ucontext_t` + +### Other + +- CI: add Solaris +- CI: add `i686-unknown-freebsd` +- CI: ensure that calls to `sort` do not depend on locale +- Specify `rust-version` in `Cargo.toml` + +## [0.2.162](https://github.com/rust-lang/libc/compare/0.2.161...0.2.162) - 2024-11-07 + +### Added + +- Android: fix the alignment of `uc_mcontext` on arm64 +- Apple: add `host_cpu_load_info` +- ESP-IDF: add a time flag +- FreeBSD: add the `CLOSE_RANGE_CLOEXEC` flag +- FreeBSD: fix test errors regarding `__gregset_t` +- FreeBSD: fix tests on x86 FreeBSD 15 +- FreeBSD: make `ucontext_t` and `mcontext_t` available on all architectures +- Haiku: add `getentropy` +- Illumos: add `syncfs` +- Illumos: add some recently-added constants +- Linux: add `ioctl` flags +- Linux: add epoll busy polling parameters +- NuttX: add `pthread_[get/set]name_np` +- RTEMS: add `arc4random_buf` +- Trusty OS: add initial support +- WASIp2: expand socket support + +### Fixed + +- Emscripten: don't pass `-lc` +- Hurd: change `st_fsid` field to `st_dev` +- Hurd: fix the definition of `utsname` +- Illumos/Solaris: fix `FNM_CASEFOLD` definition +- Solaris: fix all tests + +### Other + +- CI: Add loongarch64 +- CI: Check that semver files are sorted +- CI: Re-enable the FreeBSD 15 job +- Clean up imports and `extern crate` usage +- Convert `mode_t` constants to octal +- Remove the `wasm32-wasi` target that has been deleted upstream + +## [0.2.161](https://github.com/rust-lang/libc/compare/0.2.160...0.2.161) - 2024-10-17 + +### Fixed + +- OpenBSD: fix `FNM_PATHNAME` and `FNM_NOESCAPE` values + +## [0.2.160](https://github.com/rust-lang/libc/compare/0.2.159...0.2.160) - 2024-10-17 + +### Added + +- Android: add `PR_GET_NAME` and `PR_SET_NAME` +- Apple: add `F_TRANSFEREXTENTS` +- Apple: add `mach_error_string` +- Apple: add additional `pthread` APIs +- Apple: add the `LOCAL_PEERTOKEN` socket option +- BSD: add `RTF_*`, `RTA_*`, `RTAX_*`, and `RTM_*` definitions +- Emscripten: add `AT_EACCESS` +- Emscripten: add `getgrgid`, `getgrnam`, `getgrnam_r` and `getgrgid_r` +- Emscripten: add `getpwnam_r` and `getpwuid_r` +- FreeBSD: add `POLLRDHUP` +- Haiku: add `arc4random` +- Illumos: add `ptsname_r` +- Linux: add `fanotify` interfaces +- Linux: add `tcp_info` +- Linux: add additional AF_PACKET options +- Linux: make Elf constants always available +- Musl x86: add `iopl` and `ioperm` +- Musl: add `posix_spawn` chdir functions +- Musl: add `utmpx.h` constants +- NetBSD: add `sysctlnametomib`, `CLOCK_THREAD_CPUTIME_ID` and `CLOCK_PROCESS_CPUTIME_ID` +- Nuttx: initial support +- RTEMS: add `getentropy` +- RTEMS: initial support +- Solarish: add `POLLRDHUP`, `POSIX_FADV_*`, `O_RSYNC`, and `posix_fallocate` +- Unix: add `fnmatch.h` +- VxWorks: add riscv64 support +- VxWorks: update constants related to the scheduler + +### Changed + +- Redox: change `ino_t` to be `c_ulonglong` + +### Fixed + +- ESP-IDF: fix mismatched constants and structs +- FreeBSD: fix `struct stat` on FreeBSD 12+ + +### Other + +- CI: Fix CI for FreeBSD 15 +- Docs: link to `windows-sys` + +## [0.2.159](https://github.com/rust-lang/libc/compare/0.2.158...0.2.159) - 2024-09-24 + +### Added + +- Android: add more `AT_*` constants in +- Apple: add missing `NOTE_*` constants in +- Hermit: add missing error numbers in +- Hurd: add `__timeval` for 64-bit support in +- Linux: add `epoll_pwait2` in +- Linux: add `mq_notify` in +- Linux: add missing `NFT_CT_*` constants in +- Linux: add the `fchmodat2` syscall in +- Linux: add the `mseal` syscall in +- OpenBSD: add `sendmmsg` and `recvmmsg` in +- Unix: add `IN6ADDR_ANY_INIT` and `IN6ADDR_LOOPBACK_INIT` in +- VxWorks: add `S_ISVTX` in +- VxWorks: add `vxCpuLib` and `taskLib` functions +- WASIp2: add definitions for `std::net` support in + +### Fixed + +- Correctly handle version checks when `clippy-driver` is used + +### Changed + +- EspIdf: change signal constants to c_int in +- HorizonOS: update network definitions in +- Linux: combine `ioctl` APIs in +- WASI: enable CI testing in +- WASIp2: enable CI testing in + +## [0.2.158](https://github.com/rust-lang/libc/compare/0.2.157...0.2.158) - 2024-08-19 + +### Other +- WASI: fix missing `Iterator` with `rustc-dep-of-std` in + +## [0.2.157](https://github.com/rust-lang/libc/compare/0.2.156...0.2.157) - 2024-08-17 + +### Added + +- Apple: add `_NSGetArgv`, `_NSGetArgc` and `_NSGetProgname` in +- Build: add `RUSTC_WRAPPER` support in +- FreeBSD: add `execvpe` support from 14.1 release in +- Fuchsia: add `SO_BINDTOIFINDEX` +- Linux: add `klogctl` in +- MacOS: add `fcntl` OFD commands in +- NetBSD: add `_lwp_park` in +- Solaris: add missing networking support in +- Unix: add `pthread_equal` in +- WASI: add `select`, `FD_SET`, `FD_ZERO`, `FD_ISSET ` in + +### Fixed +- TEEOS: fix octal notation for `O_*` constants in + +### Changed +- FreeBSD: always use freebsd12 when `rustc_dep_of_std` is set in + +## [0.2.156](https://github.com/rust-lang/libc/compare/v0.2.155...v0.2.156) - 2024-08-15 + +### Added +- Apple: add `F_ALLOCATEPERSIST` in +- Apple: add `os_sync_wait_on_address` and related definitions in +- BSD: generalise `IPV6_DONTFRAG` to all BSD targets in +- FreeBSD/DragonFly: add `IP_RECVTTL`/`IPV6_RECVHOPLIMIT` in +- Hurd: add `XATTR_CREATE`, `XATTR_REPLACE` in +- Linux GNU: `confstr` API and `_CS_*` in +- Linux musl: add `preadv2` and `pwritev2` (1.2.5 min.) in +- VxWorks: add the constant `SOMAXCONN` in +- VxWorks: add a few errnoLib related constants in + +### Fixed +- Solaris/illumos: Change `ifa_flags` type to u64 in +- QNX 7.0: Disable `libregex` in + +### Changed +- QNX NTO: update platform support in +- `addr_of!(EXTERN_STATIC)` is now considered safe in + +### Removed +- Apple: remove `rmx_state` in + +### Other +- Update or remove CI tests that have been failing diff --git a/http/vendor/libc/CONTRIBUTING.md b/http/vendor/libc/CONTRIBUTING.md new file mode 100644 index 0000000..f43cda6 --- /dev/null +++ b/http/vendor/libc/CONTRIBUTING.md @@ -0,0 +1,126 @@ +# Contributing to `libc` + +Welcome! If you are reading this document, it means you are interested in +contributing to the `libc` crate. + +## v1.0 Roadmap + +`libc` has two active branches: `main` and `libc-0.2`. `main` is for active +development of the upcoming v1.0 release, and should be the target of all pull +requests. `libc-0.2` is for updates to the currently released version. + +If a pull request to `main` is a good candidate for inclusion in an `0.2.x` +release, include `@rustbot label stable-nominated` in a comment to propose this. +Good candidates will usually meet the following: + +1. The included changes are non-breaking. +2. The change applies cleanly to both branches. +3. There is a usecase that justifies inclusion in a stable release (all + additions should always have a usecase, hopefully). + +Once a `stable-nominated` PR targeting `main` has merged, it can be cherry +picked to the `libc-0.2` branch. A maintainer will likely do these cherry picks +in a batch. + +Alternatively, you can start this process yourself by creating a new branch +based on `libc-0.2` and running `git cherry-pick -xe commit-sha-on-main` +(`git +cherry-pick -xe start-sha^..end-sha` if a range of commits is needed). +`git` will automatically add the "cherry picked from commit" note, but try to +add a backport note so the original PR gets crosslinked: + +``` +# ... original commit message ... + +(backport ) # add manually +(cherry picked from commit 104b6a4ae31c726814c36318dc718470cc96e167) # added by git +``` + +Once the cherry-pick is complete, open a PR targeting `libc-0.2`. + +See the [tracking issue](https://github.com/rust-lang/libc/issues/3248) for +details. + +## Adding an API + +Want to use an API which currently isn't bound in `libc`? It's quite easy to add +one! + +The internal structure of this crate is designed to minimize the number of +`#[cfg]` attributes in order to easily be able to add new items which apply to +all platforms in the future. As a result, the crate is organized hierarchically +based on platform. Each module has a number of `#[cfg]`'d children, but only one +is ever actually compiled. Each module then reexports all the contents of its +children. + +This means that for each platform that libc supports, the path from a leaf +module to the root will contain all bindings for the platform in question. +Consequently, this indicates where an API should be added! Adding an API at a +particular level in the hierarchy means that it is supported on all the child +platforms of that level. For example, when adding a Unix API it should be added +to `src/unix/mod.rs`, but when adding a Linux-only API it should be added to +`src/unix/linux_like/linux/mod.rs`. + +If you're not 100% sure at what level of the hierarchy an API should be added +at, fear not! This crate has CI support which tests any binding against all +platforms supported, so you'll see failures if an API is added at the wrong +level or has different signatures across platforms. + +New symbol(s) (i.e. functions, constants etc.) should also be added to the +symbols list(s) found in the `libc-test/semver` directory. These lists keep +track of what symbols are public in the libc crate and ensures they remain +available between changes to the crate. If the new symbol(s) are available on +all supported Unixes it should be added to `unix.txt` list1, +otherwise they should be added to the OS specific list(s). + +With that in mind, the steps for adding a new API are: + +1. Determine where in the module hierarchy your API should be added. +2. Add the API, including adding new symbol(s) to the semver lists. +3. Send a PR to this repo. +4. Wait for CI to pass, fixing errors. +5. Wait for a merge! + +1: Note that this list has nothing to do with any Unix or Posix +standard, it's just a list shared among all OSs that declare `#[cfg(unix)]`. + +## Test before you commit + +We have two automated tests running on +[GitHub Actions](https://github.com/rust-lang/libc/actions): + +1. `libc-test` + - `cd libc-test && cargo test` + - Use the `skip_*()` functions in `build.rs` if you really need a workaround. +2. Style checker + - [`./ci/style.py`](https://github.com/rust-lang/libc/blob/main/ci/style.py) + +## Breaking change policy + +Sometimes an upstream adds a breaking change to their API e.g. removing outdated +items, changing the type signature, etc. And we probably should follow that +change to build the `libc` crate successfully. It's annoying to do the +equivalent of semver-major versioning for each such change. Instead, we mark the +item as deprecated and do the actual change after a certain period. The steps +are: + +1. Add `#[deprecated(since = "", note="")]` attribute to the item. + - The `since` field should have a next version of `libc` (e.g., if the current + version is `0.2.1`, it should be `0.2.2`). + - The `note` field should have a reason to deprecate and a tracking issue to + call for comments (e.g., "We consider removing this as the upstream removed + it. If you're using it, please comment on #XXX"). +2. If we don't see any concerns for a while, do the change actually. + +## Supported target policy + +When Rust removes a support for a target, the libc crate also may remove the +support at any time. + +## Releasing your change to crates.io + +This repository uses [release-plz] to handle releases. Once your pull request +has been merged, a maintainer just needs to verify the generated changelog, then +merge the bot's release PR. This will automatically publish to crates.io! + +[release-plz]: https://github.com/MarcoIeni/release-plz diff --git a/http/vendor/libc/Cargo.lock b/http/vendor/libc/Cargo.lock new file mode 100644 index 0000000..3f41b68 --- /dev/null +++ b/http/vendor/libc/Cargo.lock @@ -0,0 +1,16 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "libc" +version = "0.2.186" +dependencies = [ + "rustc-std-workspace-core", +] + +[[package]] +name = "rustc-std-workspace-core" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa9c45b374136f52f2d6311062c7146bff20fec063c3f5d46a410bd937746955" diff --git a/http/vendor/libc/Cargo.toml b/http/vendor/libc/Cargo.toml new file mode 100644 index 0000000..991aac2 --- /dev/null +++ b/http/vendor/libc/Cargo.toml @@ -0,0 +1,229 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies. +# +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. + +[package] +edition = "2021" +rust-version = "1.65" +name = "libc" +version = "0.2.186" +authors = ["The Rust Project Developers"] +build = "build.rs" +exclude = [ + "/ci/*", + "/.github/*", + "/triagebot.toml", + "cherry-pick-stable.sh", +] +autolib = false +autobins = false +autoexamples = false +autotests = false +autobenches = false +description = "Raw FFI bindings to platform libraries like libc." +readme = "README.md" +keywords = [ + "libc", + "ffi", + "bindings", + "operating", + "system", +] +categories = [ + "external-ffi-bindings", + "no-std", + "os", +] +license = "MIT OR Apache-2.0" +repository = "https://github.com/rust-lang/libc" + +[package.metadata.docs.rs] +features = ["extra_traits"] +default-target = "x86_64-unknown-linux-gnu" +targets = [ + "aarch64-apple-darwin", + "aarch64-pc-windows-msvc", + "aarch64-unknown-linux-gnu", + "i686-pc-windows-msvc", + "i686-unknown-linux-gnu", + "x86_64-pc-windows-gnu", + "x86_64-pc-windows-msvc", + "x86_64-unknown-linux-gnu", + "aarch64-pc-windows-gnullvm", + "aarch64-unknown-linux-musl", + "aarch64-unknown-linux-ohos", + "arm-unknown-linux-gnueabi", + "arm-unknown-linux-gnueabihf", + "armv7-unknown-linux-gnueabihf", + "armv7-unknown-linux-ohos", + "i686-pc-windows-gnu", + "loongarch64-unknown-linux-gnu", + "loongarch64-unknown-linux-musl", + "powerpc-unknown-linux-gnu", + "powerpc64-unknown-linux-gnu", + "powerpc64le-unknown-linux-gnu", + "powerpc64le-unknown-linux-musl", + "riscv64gc-unknown-linux-gnu", + "s390x-unknown-linux-gnu", + "sparcv9-sun-solaris", + "x86_64-apple-darwin", + "x86_64-pc-solaris", + "x86_64-pc-windows-gnullvm", + "x86_64-unknown-freebsd", + "x86_64-unknown-illumos", + "x86_64-unknown-linux-musl", + "x86_64-unknown-linux-ohos", + "x86_64-unknown-netbsd", + "aarch64-apple-ios", + "aarch64-apple-tvos", + "aarch64-apple-visionos", + "aarch64-apple-watchos", + "aarch64-linux-android", + "aarch64-unknown-fuchsia", + "arm-linux-androideabi", + "arm-unknown-linux-musleabi", + "arm-unknown-linux-musleabihf", + "arm64ec-pc-windows-msvc", + "armv5te-unknown-linux-gnueabi", + "armv5te-unknown-linux-musleabi", + "armv7-linux-androideabi", + "armv7-unknown-linux-musleabihf", + "i586-unknown-linux-gnu", + "i586-unknown-linux-musl", + "i686-linux-android", + "i686-unknown-freebsd", + "i686-unknown-linux-musl", + "nvptx64-nvidia-cuda", + "riscv64gc-unknown-linux-musl", + "sparc64-unknown-linux-gnu", + "thumbv7neon-linux-androideabi", + "thumbv7neon-unknown-linux-gnueabihf", + "wasm32-unknown-emscripten", + "wasm32-unknown-unknown", + "wasm32-wasip1", + "wasm32-wasip2", + "x86_64-fortanix-unknown-sgx", + "x86_64-linux-android", + "x86_64-unknown-fuchsia", + "x86_64-unknown-linux-gnux32", + "x86_64-unknown-redox", + "aarch64-unknown-freebsd", + "aarch64-unknown-hermit", + "aarch64-unknown-illumos", + "aarch64-unknown-netbsd", + "aarch64-unknown-nto-qnx800", + "aarch64-unknown-openbsd", + "aarch64-unknown-redox", + "aarch64-wrs-vxworks", + "aarch64_be-unknown-linux-gnu", + "aarch64_be-unknown-linux-musl", + "armebv7r-none-eabi", + "armebv7r-none-eabihf", + "armv7-linux-androideabi", + "armv7-wrs-vxworks-eabihf", + "armv7r-none-eabi", + "armv7r-none-eabihf", + "hexagon-unknown-linux-musl", + "i686-unknown-haiku", + "i686-unknown-netbsd", + "i686-unknown-openbsd", + "i686-wrs-vxworks", + "mips-unknown-linux-gnu", + "mips-unknown-linux-musl", + "mips64-unknown-linux-gnuabi64", + "mips64-unknown-linux-muslabi64", + "mips64el-unknown-linux-gnuabi64", + "mips64el-unknown-linux-muslabi64", + "mipsel-sony-psp", + "mipsel-unknown-linux-gnu", + "mipsel-unknown-linux-musl", + "powerpc-unknown-linux-gnuspe", + "powerpc-unknown-netbsd", + "powerpc-wrs-vxworks", + "powerpc-wrs-vxworks-spe", + "powerpc64-ibm-aix", + "powerpc64-unknown-freebsd", + "powerpc64-unknown-linux-gnu", + "powerpc64-unknown-linux-musl", + "powerpc64-wrs-vxworks", + "riscv32-wrs-vxworks", + "riscv32gc-unknown-linux-musl", + "riscv32i-unknown-none-elf", + "riscv32imac-unknown-none-elf", + "riscv32imc-unknown-none-elf", + "riscv64-wrs-vxworks", + "riscv64gc-unknown-freebsd", + "riscv64gc-unknown-hermit", + "riscv64gc-unknown-none-elf", + "riscv64imac-unknown-none-elf", + "s390x-unknown-linux-musl", + "sparc-unknown-linux-gnu", + "sparc64-unknown-netbsd", + "thumbv6m-none-eabi", + "thumbv7em-none-eabi", + "thumbv7em-none-eabihf", + "thumbv7m-none-eabi", + "wasm32-wasip3", + "x86_64-apple-ios", + "x86_64-pc-cygwin", + "x86_64-unknown-dragonfly", + "x86_64-unknown-haiku", + "x86_64-unknown-hermit", + "x86_64-unknown-hurd-gnu", + "x86_64-unknown-l4re-uclibc", + "x86_64-unknown-openbsd", + "x86_64-wrs-vxworks", +] +cargo-args = ["-Zbuild-std=core"] + +[package.metadata.cargo-semver-checks.lints] +repr_align_removed = "warn" +global_value_marked_deprecated = "warn" + +[features] +align = [] +const-extern-fn = [] +default = ["std"] +extra_traits = [] +rustc-dep-of-std = [ + "align", + "rustc-std-workspace-core", +] +std = [] +use_std = ["std"] + +[lib] +name = "libc" +path = "src/lib.rs" + +[[test]] +name = "const_fn" +path = "tests/const_fn.rs" + +[dependencies.rustc-std-workspace-core] +version = "1.0.1" +optional = true + +[lints.clippy] +expl_impl_clone_on_copy = "allow" +explicit_iter_loop = "warn" +identity_op = "allow" +manual_assert = "warn" +map_unwrap_or = "warn" +missing_safety_doc = "allow" +non_minimal_cfg = "allow" +ptr_as_ptr = "warn" +uninlined_format_args = "allow" +unnecessary_cast = "allow" +unnecessary_semicolon = "warn" +used_underscore_binding = "allow" + +[lints.rust] +unused_qualifications = "allow" diff --git a/http/vendor/libc/Cargo.toml.orig b/http/vendor/libc/Cargo.toml.orig new file mode 100644 index 0000000..a448d88 --- /dev/null +++ b/http/vendor/libc/Cargo.toml.orig @@ -0,0 +1,218 @@ +[package] +name = "libc" +version = "0.2.186" +keywords = ["libc", "ffi", "bindings", "operating", "system"] +categories = ["external-ffi-bindings", "no-std", "os"] +exclude = ["/ci/*", "/.github/*", "/triagebot.toml", "cherry-pick-stable.sh"] +description = "Raw FFI bindings to platform libraries like libc." +authors = ["The Rust Project Developers"] +edition = "2021" +license = "MIT OR Apache-2.0" +repository = "https://github.com/rust-lang/libc" +rust-version = "1.65" + +[package.metadata.docs.rs] +features = ["extra_traits"] +default-target = "x86_64-unknown-linux-gnu" +targets = [ + # Note: Keep this in sync with ci/verify-build.py + # + # Tier 1 + "aarch64-apple-darwin", + "aarch64-pc-windows-msvc", + "aarch64-unknown-linux-gnu", + "i686-pc-windows-msvc", + "i686-unknown-linux-gnu", + "x86_64-pc-windows-gnu", + "x86_64-pc-windows-msvc", + "x86_64-unknown-linux-gnu", + # + # Tier 2 with host tools + "aarch64-pc-windows-gnullvm", + "aarch64-unknown-linux-musl", + "aarch64-unknown-linux-ohos", + "arm-unknown-linux-gnueabi", + "arm-unknown-linux-gnueabihf", + "armv7-unknown-linux-gnueabihf", + "armv7-unknown-linux-ohos", + "i686-pc-windows-gnu", + "loongarch64-unknown-linux-gnu", + "loongarch64-unknown-linux-musl", + "powerpc-unknown-linux-gnu", + "powerpc64-unknown-linux-gnu", + "powerpc64le-unknown-linux-gnu", + "powerpc64le-unknown-linux-musl", + "riscv64gc-unknown-linux-gnu", + "s390x-unknown-linux-gnu", + "sparcv9-sun-solaris", + "x86_64-apple-darwin", + "x86_64-pc-solaris", + "x86_64-pc-windows-gnullvm", + "x86_64-unknown-freebsd", + "x86_64-unknown-illumos", + "x86_64-unknown-linux-musl", + "x86_64-unknown-linux-ohos", + "x86_64-unknown-netbsd", + # + # Tier 2 without host tools + "aarch64-apple-ios", + "aarch64-apple-tvos", + "aarch64-apple-visionos", + "aarch64-apple-watchos", + "aarch64-linux-android", + "aarch64-unknown-fuchsia", + "arm-linux-androideabi", + "arm-unknown-linux-musleabi", + "arm-unknown-linux-musleabihf", + "arm64ec-pc-windows-msvc", + "armv5te-unknown-linux-gnueabi", + "armv5te-unknown-linux-musleabi", + "armv7-linux-androideabi", + "armv7-unknown-linux-musleabihf", + "i586-unknown-linux-gnu", + "i586-unknown-linux-musl", + "i686-linux-android", + "i686-unknown-freebsd", + "i686-unknown-linux-musl", + "nvptx64-nvidia-cuda", + "riscv64gc-unknown-linux-musl", + "sparc64-unknown-linux-gnu", + "thumbv7neon-linux-androideabi", + "thumbv7neon-unknown-linux-gnueabihf", + "wasm32-unknown-emscripten", + "wasm32-unknown-unknown", + "wasm32-wasip1", + "wasm32-wasip2", + "x86_64-fortanix-unknown-sgx", + "x86_64-linux-android", + "x86_64-unknown-fuchsia", + "x86_64-unknown-linux-gnux32", + "x86_64-unknown-redox", + # + # Tier 3 targets that are distinct enough to be useful, or have historically + # been documented. + "aarch64-unknown-freebsd", + "aarch64-unknown-hermit", + "aarch64-unknown-illumos", + "aarch64-unknown-netbsd", + "aarch64-unknown-nto-qnx800", + "aarch64-unknown-openbsd", + "aarch64-unknown-redox", + "aarch64-wrs-vxworks", + "aarch64_be-unknown-linux-gnu", + "aarch64_be-unknown-linux-musl", + "armebv7r-none-eabi", + "armebv7r-none-eabihf", + "armv7-linux-androideabi", + "armv7-wrs-vxworks-eabihf", + "armv7r-none-eabi", + "armv7r-none-eabihf", + "hexagon-unknown-linux-musl", + "i686-unknown-haiku", + "i686-unknown-netbsd", + "i686-unknown-openbsd", + "i686-wrs-vxworks", + "mips-unknown-linux-gnu", + "mips-unknown-linux-musl", + "mips64-unknown-linux-gnuabi64", + "mips64-unknown-linux-muslabi64", + "mips64el-unknown-linux-gnuabi64", + "mips64el-unknown-linux-muslabi64", + "mipsel-sony-psp", + "mipsel-unknown-linux-gnu", + "mipsel-unknown-linux-musl", + "powerpc-unknown-linux-gnuspe", + "powerpc-unknown-netbsd", + "powerpc-wrs-vxworks", + "powerpc-wrs-vxworks-spe", + "powerpc64-ibm-aix", + "powerpc64-unknown-freebsd", + "powerpc64-unknown-linux-gnu", + "powerpc64-unknown-linux-musl", + "powerpc64-wrs-vxworks", + "riscv32-wrs-vxworks", + "riscv32gc-unknown-linux-musl", + "riscv32i-unknown-none-elf", + "riscv32imac-unknown-none-elf", + "riscv32imc-unknown-none-elf", + "riscv64-wrs-vxworks", + "riscv64gc-unknown-freebsd", + "riscv64gc-unknown-hermit", + "riscv64gc-unknown-none-elf", + "riscv64imac-unknown-none-elf", + "s390x-unknown-linux-musl", + "sparc-unknown-linux-gnu", + "sparc64-unknown-netbsd", + "thumbv6m-none-eabi", + "thumbv7em-none-eabi", + "thumbv7em-none-eabihf", + "thumbv7m-none-eabi", + "wasm32-wasip3", + "x86_64-apple-ios", + "x86_64-pc-cygwin", + "x86_64-unknown-dragonfly", + "x86_64-unknown-haiku", + "x86_64-unknown-hermit", + "x86_64-unknown-hurd-gnu", + "x86_64-unknown-l4re-uclibc", + "x86_64-unknown-openbsd", + "x86_64-wrs-vxworks" +] +cargo-args = ["-Zbuild-std=core"] + +[dependencies] +rustc-std-workspace-core = { version = "1.0.1", optional = true } + +[features] +default = ["std"] +std = [] +rustc-dep-of-std = ['align', 'rustc-std-workspace-core'] +extra_traits = [] + +# `const-extern-function` is deprecated and no longer does anything +const-extern-fn = [] + +# `align` is deprecated and no longer does anything +align = [] + +# use_std is deprecated, use `std` instead +use_std = ['std'] + +[workspace] +members = [ + "ctest", + "libc-test", +] + +# FIXME(msrv): These should be renamed as `[workspace.lints.*]` once MSRV is above 1.64 +# This way all crates can use it with `[lints] workspace=true` section + +[lints.rust] +# FIXME(cleanup): make ident usage consistent in each file +unused_qualifications = "allow" + +[lints.clippy] +# Enable pedantic lints - use this manually once in a while, but don't enable by default +# pedantic = { level = "warn", priority = -1 } + +# We are okay with the current state of these lints +explicit_iter_loop = "warn" +identity_op = "allow" # some expressions like `0 | x` are clearer for bit ops +manual_assert = "warn" +map_unwrap_or = "warn" +missing_safety_doc = "allow" # safety? in libc? seriously? +non_minimal_cfg = "allow" # for some reason cfg_if! sometimes trigger this +ptr_as_ptr = "warn" +unnecessary_semicolon = "warn" + +# FIXME(clippy): these should be fixed if possible +expl_impl_clone_on_copy = "allow" +uninlined_format_args = "allow" +unnecessary_cast = "allow" # some casts like `as usize` are only needed for some targets +used_underscore_binding = "allow" + +[package.metadata.cargo-semver-checks.lints] +# Alignment is an internal detail that users must not rely upon +repr_align_removed = "warn" +# We deprecate things all the time +global_value_marked_deprecated = "warn" diff --git a/http/vendor/libc/LICENSE-APACHE b/http/vendor/libc/LICENSE-APACHE new file mode 100644 index 0000000..1b5ec8b --- /dev/null +++ b/http/vendor/libc/LICENSE-APACHE @@ -0,0 +1,176 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS diff --git a/http/vendor/libc/LICENSE-MIT b/http/vendor/libc/LICENSE-MIT new file mode 100644 index 0000000..f4095b2 --- /dev/null +++ b/http/vendor/libc/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/http/vendor/libc/README.md b/http/vendor/libc/README.md new file mode 100644 index 0000000..76ecb86 --- /dev/null +++ b/http/vendor/libc/README.md @@ -0,0 +1,115 @@ +# libc - Raw FFI bindings to platforms' system libraries + +[![GHA Status]][GitHub Actions] [![Latest Version]][crates.io] [![Documentation]][docs.rs] ![License] + +`libc` provides all of the definitions necessary to easily interoperate with C +code (or "C-like" code) on each of the platforms that Rust supports. This +includes type definitions (e.g. `c_int`), constants (e.g. `EINVAL`) as well as +function headers (e.g. `malloc`). + +This crate exports all underlying platform types, functions, and constants under +the crate root, so all items are accessible as `libc::foo`. The types and values +of all the exported APIs match the platform that libc is compiled for. + +Windows API bindings are not included in this crate. If you are looking for +WinAPI bindings, consider using crates like [windows-sys]. + +More detailed information about the design of this library can be found in its +[associated RFC][rfc]. + +[rfc]: https://github.com/rust-lang/rfcs/blob/HEAD/text/1291-promote-libc.md +[windows-sys]: https://docs.rs/windows-sys + +## v1.0 Roadmap + +Currently, `libc` has two active branches: `main` for the upcoming v1.0 release, +and `libc-0.2` for the currently published version. By default all pull requests +should target `main`; once reviewed, they can be cherry picked to the `libc-0.2` +branch if needed. + +We will stop making new v0.2 releases once v1.0 is released. + +See the section in [CONTRIBUTING.md](CONTRIBUTING.md#v10-roadmap) for more +details. + +## Usage + +Add the following to your `Cargo.toml`: + +```toml +[dependencies] +libc = "0.2" +``` + +## Features + +* `std`: by default `libc` links to the standard library. Disable this feature + to remove this dependency and be able to use `libc` in `#![no_std]` crates. + +* `extra_traits`: all `struct`s implemented in `libc` are `Copy` and `Clone`. + This feature derives `Debug`, `Eq`, `Hash`, and `PartialEq`. + +The following features are deprecated: + +* `use_std`: this is equivalent to `std` +* `const-extern-fn`: this is now enabled by default +* `align`: this is now enabled by default + +## Rust version support + +The minimum supported Rust toolchain version is currently **Rust 1.65**. + +Increases to the MSRV are allowed to change without a major (i.e. semver- +breaking) release in order to avoid a ripple effect in the ecosystem. A policy +for when this may change is a work in progress. + +`libc` may continue to compile with Rust versions older than the current MSRV +but this is not guaranteed. + +## Platform support + +You can see the platform(target)-specific docs on [docs.rs], select a platform +you want to see. + +See [`ci/verify-build.py`](https://github.com/rust-lang/libc/blob/HEAD/ci/verify-build.py) for +the platforms on which `libc` is guaranteed to build for each Rust toolchain. +The test matrices at [GitHub Actions] show the platforms in which `libc` tests +are run. + +

+ +## License + +This project is licensed under either of + +* [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0) + ([LICENSE-APACHE](https://github.com/rust-lang/libc/blob/HEAD/LICENSE-APACHE)) + +* [MIT License](https://opensource.org/licenses/MIT) + ([LICENSE-MIT](https://github.com/rust-lang/libc/blob/HEAD/LICENSE-MIT)) + +at your option. + +## Contributing + +We welcome all people who want to contribute. Please see the +[contributing instructions] for more information. + +[contributing instructions]: https://github.com/rust-lang/libc/blob/HEAD/CONTRIBUTING.md + +Contributions in any form (issues, pull requests, etc.) to this project must +adhere to Rust's [Code of Conduct]. + +[Code of Conduct]: https://www.rust-lang.org/policies/code-of-conduct + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in `libc` by you, as defined in the Apache-2.0 license, shall be +dual licensed as above, without any additional terms or conditions. + +[GitHub Actions]: https://github.com/rust-lang/libc/actions +[GHA Status]: https://github.com/rust-lang/libc/workflows/CI/badge.svg +[crates.io]: https://crates.io/crates/libc +[Latest Version]: https://img.shields.io/crates/v/libc.svg +[Documentation]: https://docs.rs/libc/badge.svg +[docs.rs]: https://docs.rs/libc +[License]: https://img.shields.io/crates/l/libc.svg diff --git a/http/vendor/libc/build.rs b/http/vendor/libc/build.rs new file mode 100644 index 0000000..34df96a --- /dev/null +++ b/http/vendor/libc/build.rs @@ -0,0 +1,346 @@ +use std::env::VarError; +use std::process::{ + Command, + Output, +}; +use std::{ + env, + str, +}; + +// List of cfgs this build script is allowed to set. The list is needed to support check-cfg, as we +// need to know all the possible cfgs that this script will set. If you need to set another cfg +// make sure to add it to this list as well. +const ALLOWED_CFGS: &[&str] = &[ + "emscripten_old_stat_abi", + // Should be enabled by users if esp-idf (>=6.0) is build with picolibc instead of newlib. + "espidf_picolibc", + "espidf_time32", + "freebsd10", + "freebsd11", + "freebsd12", + "freebsd13", + "freebsd14", + "freebsd15", + // Corresponds to `_FILE_OFFSET_BITS=64` in glibc + "gnu_file_offset_bits64", + // Corresponds to `_TIME_BITS=64` in glibc + "gnu_time_bits64", + "libc_deny_warnings", + // Corresponds to `__USE_TIME_BITS64` in UAPI + "linux_time_bits64", + "musl_v1_2_3", + // musl v1.2.3+ && 32-bit: time_t is i64, struct layouts change + "musl32_time64", + // Corresponds to `_REDIR_TIME64` in musl: symbol redirects to __*_time64 + "musl_redir_time64", + "vxworks_lt_25_09", +]; + +// Extra values to allow for check-cfg. +const CHECK_CFG_EXTRA: &[(&str, &[&str])] = &[ + ( + "target_os", + &[ + "switch", "aix", "ohos", "hurd", "rtems", "visionos", "nuttx", "cygwin", "qurt", + ], + ), + ( + "target_env", + &["illumos", "wasi", "aix", "ohos", "nto71_iosock", "nto80"], + ), + ( + "target_arch", + &["loongarch64", "mips32r6", "mips64r6", "csky"], + ), +]; + +/// Musl architectures that define `_REDIR_TIME64` (i.e. those that transitioned +/// from 32-bit to 64-bit `time_t` and need `__*_time64` symbol redirects). +const MUSL_REDIR_TIME64_ARCHES: &[&str] = &["arm", "mips", "powerpc", "x86"]; + +fn main() { + // Avoid unnecessary re-building. + println!("cargo:rerun-if-changed=build.rs"); + + let (rustc_minor_ver, _is_nightly) = rustc_minor_nightly(); + let libc_ci = env_flag("LIBC_CI"); + let target_env = env::var("CARGO_CFG_TARGET_ENV").unwrap_or_default(); + let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap_or_default(); + let target_ptr_width = env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap_or_default(); + let target_arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default(); + + // The ABI of libc used by std is backward compatible with FreeBSD 12. + // The ABI of libc from crates.io is backward compatible with FreeBSD 12. + // + // On CI, we detect the actual FreeBSD version and match its ABI exactly, + // running tests to ensure that the ABI is correct. + println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_FREEBSD_VERSION"); + // Allow overriding the default version for testing + let which_freebsd = if let Ok(version) = env::var("RUST_LIBC_UNSTABLE_FREEBSD_VERSION") { + let vers = version.parse().unwrap(); + println!("cargo:warning=setting FreeBSD version to {vers}"); + vers + } else if libc_ci { + which_freebsd().unwrap_or(12) + } else { + 12 + }; + + match which_freebsd { + x if x < 10 => panic!("FreeBSD older than 10 is not supported"), + 10 => set_cfg("freebsd10"), + 11 => set_cfg("freebsd11"), + 12 => set_cfg("freebsd12"), + 13 => set_cfg("freebsd13"), + 14 => set_cfg("freebsd14"), + _ => set_cfg("freebsd15"), + } + + match emcc_version_code() { + Some(v) if (v < 30142) => set_cfg("emscripten_old_stat_abi"), + // Non-Emscripten or version >= 3.1.42. + _ => (), + } + + match vxworks_version_code() { + Some(v) if (v < (25, 9)) => set_cfg("vxworks_lt_25_09"), + // VxWorks version >= 25.09 + _ => (), + } + + let mut musl_v1_2_3 = env_flag("RUST_LIBC_UNSTABLE_MUSL_V1_2_3"); + println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_MUSL_V1_2_3"); + + // OpenHarmony uses a fork of the musl libc + let musl = target_env == "musl" || target_env == "ohos"; + + // loongarch64, hexagon, and ohos only exist with recent musl + if target_arch == "loongarch64" || target_arch == "hexagon" || target_env == "ohos" { + musl_v1_2_3 = true; + } + + if musl && musl_v1_2_3 { + set_cfg("musl_v1_2_3"); + if target_ptr_width == "32" { + set_cfg("musl32_time64"); + set_cfg("linux_time_bits64"); + } + if MUSL_REDIR_TIME64_ARCHES.contains(&target_arch.as_str()) { + set_cfg("musl_redir_time64"); + } + } + + let linux_time_bits64 = env::var("RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64").is_ok(); + println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64"); + if linux_time_bits64 { + set_cfg("linux_time_bits64"); + } + println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS"); + println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_GNU_TIME_BITS"); + if target_env == "gnu" + && target_os == "linux" + && target_ptr_width == "32" + && target_arch != "riscv32" + && target_arch != "x86_64" + { + let defaultbits = "32".to_string(); + let (timebits, filebits) = match ( + env::var("RUST_LIBC_UNSTABLE_GNU_TIME_BITS"), + env::var("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS"), + ) { + (Ok(_), Ok(_)) => panic!("Do not set both RUST_LIBC_UNSTABLE_GNU_TIME_BITS and RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS"), + (Err(_), Err(_)) => (defaultbits.clone(), defaultbits.clone()), + (Ok(tb), Err(_)) if tb == "64" => (tb.clone(), tb.clone()), + (Ok(tb), Err(_)) if tb == "32" => (tb, defaultbits.clone()), + (Ok(_), Err(_)) => panic!("Invalid value for RUST_LIBC_UNSTABLE_GNU_TIME_BITS, must be 32 or 64"), + (Err(_), Ok(fb)) if fb == "32" || fb == "64" => (defaultbits.clone(), fb), + (Err(_), Ok(_)) => panic!("Invalid value for RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS, must be 32 or 64"), + }; + let valid_bits = ["32", "64"]; + assert!( + valid_bits.contains(&filebits.as_str()) && valid_bits.contains(&timebits.as_str()), + "Invalid value for RUST_LIBC_UNSTABLE_GNU_TIME_BITS or RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS, must be 32, 64 or unset" + ); + assert!( + !(filebits == "32" && timebits == "64"), + "RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS must be 64 or unset if RUST_LIBC_UNSTABLE_GNU_TIME_BITS is 64" + ); + if timebits == "64" { + set_cfg("linux_time_bits64"); + set_cfg("gnu_time_bits64"); + } + if filebits == "64" { + set_cfg("gnu_file_offset_bits64"); + } + } + + // On CI: deny all warnings + if libc_ci { + set_cfg("libc_deny_warnings"); + } + + // Since Rust 1.80, configuration that isn't recognized by default needs to be provided to + // avoid warnings. + if rustc_minor_ver >= 80 { + for cfg in ALLOWED_CFGS { + println!("cargo:rustc-check-cfg=cfg({cfg})"); + } + for &(name, values) in CHECK_CFG_EXTRA { + let values = values.join("\",\""); + println!("cargo:rustc-check-cfg=cfg({name},values(\"{values}\"))"); + } + } +} + +/// Run `rustc --version` and capture the output, adjusting arguments as needed if `clippy-driver` +/// is used instead. +fn rustc_version_cmd(is_clippy_driver: bool) -> Output { + let rustc = env::var_os("RUSTC").expect("Failed to get rustc version: missing RUSTC env"); + + let mut cmd = match env::var_os("RUSTC_WRAPPER") { + Some(ref wrapper) if wrapper.is_empty() => Command::new(rustc), + Some(wrapper) => { + let mut cmd = Command::new(wrapper); + cmd.arg(rustc); + if is_clippy_driver { + cmd.arg("--rustc"); + } + + cmd + } + None => Command::new(rustc), + }; + + cmd.arg("--version"); + + let output = cmd.output().expect("Failed to get rustc version"); + + assert!( + output.status.success(), + "failed to run rustc: {}", + String::from_utf8_lossy(output.stderr.as_slice()) + ); + + output +} + +/// Return the minor version of `rustc`, as well as a bool indicating whether or not the version +/// is a nightly. +fn rustc_minor_nightly() -> (u32, bool) { + macro_rules! otry { + ($e:expr) => { + match $e { + Some(e) => e, + None => panic!("Failed to get rustc version"), + } + }; + } + + let mut output = rustc_version_cmd(false); + + if otry!(str::from_utf8(&output.stdout).ok()).starts_with("clippy") { + output = rustc_version_cmd(true); + } + + let version = otry!(str::from_utf8(&output.stdout).ok()); + + let mut pieces = version.split('.'); + + assert_eq!( + pieces.next(), + Some("rustc 1"), + "Failed to get rustc version" + ); + + let minor = pieces.next(); + + // If `rustc` was built from a tarball, its version string + // will have neither a git hash nor a commit date + // (e.g. "rustc 1.39.0"). Treat this case as non-nightly, + // since a nightly build should either come from CI + // or a git checkout + let nightly_raw = otry!(pieces.next()).split('-').nth(1); + let nightly = nightly_raw.map_or(false, |raw| { + raw.starts_with("dev") || raw.starts_with("nightly") + }); + let minor = otry!(otry!(minor).parse().ok()); + + (minor, nightly) +} + +fn which_freebsd() -> Option { + let output = Command::new("freebsd-version").output().ok()?; + if !output.status.success() { + return None; + } + + let stdout = String::from_utf8(output.stdout).ok()?; + + match &stdout { + s if s.starts_with("10") => Some(10), + s if s.starts_with("11") => Some(11), + s if s.starts_with("12") => Some(12), + s if s.starts_with("13") => Some(13), + s if s.starts_with("14") => Some(14), + s if s.starts_with("15") => Some(15), + _ => None, + } +} + +fn emcc_version_code() -> Option { + let emcc = if cfg!(target_os = "windows") { + "emcc.bat" + } else { + "emcc" + }; + + let output = Command::new(emcc).arg("-dumpversion").output().ok()?; + if !output.status.success() { + return None; + } + + let version = String::from_utf8(output.stdout).ok()?; + + // Some Emscripten versions come with `-git` attached, so split the + // version string also on the `-` char. + let mut pieces = version.trim().split(['.', '-']); + + let major = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0); + let minor = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0); + let patch = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0); + + Some(major * 10000 + minor * 100 + patch) +} + +/// Retrieve the VxWorks release version from the environment variable set by the VxWorks build +/// environment, in `(minor, patch)` form. Currently the only major version supported by Rust +/// is 7. +fn vxworks_version_code() -> Option<(u32, u32)> { + let version = env::var("WIND_RELEASE_ID").ok()?; + + let mut pieces = version.trim().split(['.']); + + let major: u32 = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0); + let minor: u32 = pieces.next().and_then(|x| x.parse().ok()).unwrap_or(0); + + Some((major, minor)) +} + +fn set_cfg(cfg: &str) { + assert!( + ALLOWED_CFGS.contains(&cfg), + "trying to set cfg {cfg}, but it is not in ALLOWED_CFGS", + ); + println!("cargo:rustc-cfg={cfg}"); +} + +/// Return true if the env is set to a value other than `0`. +fn env_flag(key: &str) -> bool { + match env::var(key) { + Ok(x) if x == "0" => false, + Err(VarError::NotPresent) => false, + Err(VarError::NotUnicode(_)) => panic!("non-unicode var for `{key}`"), + Ok(_) => true, + } +} diff --git a/http/vendor/libc/src/fuchsia/aarch64.rs b/http/vendor/libc/src/fuchsia/aarch64.rs new file mode 100644 index 0000000..93090f7 --- /dev/null +++ b/http/vendor/libc/src/fuchsia/aarch64.rs @@ -0,0 +1,69 @@ +use crate::off_t; +use crate::prelude::*; + +pub type __u64 = c_ulonglong; +pub type wchar_t = u32; +pub type nlink_t = c_ulong; +pub type blksize_t = c_long; + +s! { + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + __pad0: Padding, + pub st_size: off_t, + pub st_blksize: crate::blksize_t, + __pad1: Padding, + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + __unused: Padding<[c_uint; 2]>, + } + + pub struct stat64 { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + __pad0: Padding, + pub st_size: off_t, + pub st_blksize: crate::blksize_t, + __pad1: Padding, + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + __unused: Padding<[c_uint; 2]>, + } + + pub struct ipc_perm { + pub __ipc_perm_key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: crate::mode_t, + pub __seq: c_ushort, + __unused1: Padding, + __unused2: Padding, + } +} + +// From https://cs.opensource.google/fuchsia/fuchsia/+/main:zircon/third_party/ulib/musl/include/bits/signal.h;l=20-21;drc=0827b18ab9540c46f8037f407d17ea15a79e9ba7 +pub const MINSIGSTKSZ: size_t = 6144; +pub const SIGSTKSZ: size_t = 12288; diff --git a/http/vendor/libc/src/fuchsia/mod.rs b/http/vendor/libc/src/fuchsia/mod.rs new file mode 100644 index 0000000..3e35faa --- /dev/null +++ b/http/vendor/libc/src/fuchsia/mod.rs @@ -0,0 +1,4026 @@ +//! Definitions found commonly among almost all Unix derivatives +//! +//! More functions and definitions can be found in the more specific modules +//! according to the platform in question. + +use crate::prelude::*; + +// PUB_TYPE + +pub type intmax_t = i64; +pub type uintmax_t = u64; + +pub type locale_t = *mut c_void; + +pub type size_t = usize; +pub type ptrdiff_t = isize; +pub type intptr_t = isize; +pub type uintptr_t = usize; +pub type ssize_t = isize; + +pub type pid_t = i32; +pub type uid_t = u32; +pub type gid_t = u32; +pub type in_addr_t = u32; +pub type in_port_t = u16; +pub type sighandler_t = size_t; +pub type cc_t = c_uchar; +pub type sa_family_t = u16; +pub type pthread_key_t = c_uint; +pub type speed_t = c_uint; +pub type tcflag_t = c_uint; +pub type clockid_t = c_int; +pub type key_t = c_int; +pub type id_t = c_uint; +pub type useconds_t = u32; +pub type dev_t = u64; +pub type socklen_t = u32; +pub type pthread_t = c_ulong; +pub type mode_t = u32; +pub type ino64_t = u64; +pub type off64_t = i64; +pub type blkcnt64_t = i64; +pub type rlim64_t = u64; +pub type mqd_t = c_int; +pub type nfds_t = c_ulong; +pub type nl_item = c_int; +pub type idtype_t = c_uint; +pub type loff_t = c_longlong; + +pub type __u8 = c_uchar; +pub type __u16 = c_ushort; +pub type __s16 = c_short; +pub type __u32 = c_uint; +pub type __s32 = c_int; + +pub type Elf32_Half = u16; +pub type Elf32_Word = u32; +pub type Elf32_Off = u32; +pub type Elf32_Addr = u32; + +pub type Elf64_Half = u16; +pub type Elf64_Word = u32; +pub type Elf64_Off = u64; +pub type Elf64_Addr = u64; +pub type Elf64_Xword = u64; + +pub type clock_t = c_long; +pub type time_t = c_long; +pub type suseconds_t = c_long; +pub type ino_t = u64; +pub type off_t = i64; +pub type blkcnt_t = i64; + +pub type shmatt_t = c_ulong; +pub type msgqnum_t = c_ulong; +pub type msglen_t = c_ulong; +pub type fsblkcnt_t = c_ulonglong; +pub type fsfilcnt_t = c_ulonglong; +pub type rlim_t = c_ulonglong; + +extern_ty! { + pub enum timezone {} + pub enum DIR {} + pub enum fpos64_t {} // FIXME(fuchsia): fill this out with a struct +} + +// PUB_STRUCT + +s! { + pub struct group { + pub gr_name: *mut c_char, + pub gr_passwd: *mut c_char, + pub gr_gid: crate::gid_t, + pub gr_mem: *mut *mut c_char, + } + + pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } + + #[derive(Default)] + pub struct timeval { + pub tv_sec: time_t, + pub tv_usec: suseconds_t, + } + + #[derive(Default)] + pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, + } + + // FIXME(fuchsia): the rlimit and rusage related functions and types don't exist + // within zircon. Are there reasons for keeping them around? + pub struct rlimit { + pub rlim_cur: rlim_t, + pub rlim_max: rlim_t, + } + + pub struct rusage { + pub ru_utime: timeval, + pub ru_stime: timeval, + pub ru_maxrss: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad1: Padding, + pub ru_ixrss: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad2: Padding, + pub ru_idrss: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad3: Padding, + pub ru_isrss: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad4: Padding, + pub ru_minflt: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad5: Padding, + pub ru_majflt: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad6: Padding, + pub ru_nswap: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad7: Padding, + pub ru_inblock: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad8: Padding, + pub ru_oublock: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad9: Padding, + pub ru_msgsnd: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad10: Padding, + pub ru_msgrcv: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad11: Padding, + pub ru_nsignals: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad12: Padding, + pub ru_nvcsw: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad13: Padding, + pub ru_nivcsw: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad14: Padding, + } + + pub struct in_addr { + pub s_addr: in_addr_t, + } + + pub struct in6_addr { + pub s6_addr: [u8; 16], + } + + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct ip_mreqn { + pub imr_multiaddr: in_addr, + pub imr_address: in_addr, + pub imr_ifindex: c_int, + } + + pub struct ipv6_mreq { + pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_interface: c_uint, + } + + pub struct hostent { + pub h_name: *mut c_char, + pub h_aliases: *mut *mut c_char, + pub h_addrtype: c_int, + pub h_length: c_int, + pub h_addr_list: *mut *mut c_char, + } + + pub struct iovec { + pub iov_base: *mut c_void, + pub iov_len: size_t, + } + + pub struct pollfd { + pub fd: c_int, + pub events: c_short, + pub revents: c_short, + } + + pub struct winsize { + pub ws_row: c_ushort, + pub ws_col: c_ushort, + pub ws_xpixel: c_ushort, + pub ws_ypixel: c_ushort, + } + + pub struct linger { + pub l_onoff: c_int, + pub l_linger: c_int, + } + + pub struct sigval { + // Actually a union of an int and a void* + pub sival_ptr: *mut c_void, + } + + // + pub struct itimerval { + pub it_interval: crate::timeval, + pub it_value: crate::timeval, + } + + // + pub struct tms { + pub tms_utime: crate::clock_t, + pub tms_stime: crate::clock_t, + pub tms_cutime: crate::clock_t, + pub tms_cstime: crate::clock_t, + } + + pub struct servent { + pub s_name: *mut c_char, + pub s_aliases: *mut *mut c_char, + pub s_port: c_int, + pub s_proto: *mut c_char, + } + + pub struct protoent { + pub p_name: *mut c_char, + pub p_aliases: *mut *mut c_char, + pub p_proto: c_int, + } + + pub struct aiocb { + pub aio_fildes: c_int, + pub aio_lio_opcode: c_int, + pub aio_reqprio: c_int, + pub aio_buf: *mut c_void, + pub aio_nbytes: size_t, + pub aio_sigevent: crate::sigevent, + __td: *mut c_void, + __lock: [c_int; 2], + __err: c_int, + __ret: ssize_t, + pub aio_offset: off_t, + __next: *mut c_void, + __prev: *mut c_void, + #[cfg(target_pointer_width = "32")] + __dummy4: [c_char; 24], + #[cfg(target_pointer_width = "64")] + __dummy4: [c_char; 16], + } + + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigaction { + pub sa_sigaction: crate::sighandler_t, + pub sa_mask: crate::sigset_t, + pub sa_flags: c_int, + pub sa_restorer: Option, + } + + pub struct termios { + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_line: crate::cc_t, + pub c_cc: [crate::cc_t; crate::NCCS], + pub __c_ispeed: crate::speed_t, + pub __c_ospeed: crate::speed_t, + } + + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off_t, + pub l_len: off_t, + pub l_pid: crate::pid_t, + } + + pub struct ucred { + pub pid: crate::pid_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + } + + pub struct sockaddr { + pub sa_family: sa_family_t, + pub sa_data: [c_char; 14], + } + + pub struct sockaddr_in { + pub sin_family: sa_family_t, + pub sin_port: crate::in_port_t, + pub sin_addr: crate::in_addr, + pub sin_zero: [u8; 8], + } + + pub struct sockaddr_in6 { + pub sin6_family: sa_family_t, + pub sin6_port: crate::in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: crate::in6_addr, + pub sin6_scope_id: u32, + } + + pub struct sockaddr_vm { + pub svm_family: sa_family_t, + svm_reserved1: Padding, + pub svm_port: crate::in_port_t, + pub svm_cid: c_uint, + pub svm_zero: [u8; 4], + } + + pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: socklen_t, + + pub ai_addr: *mut crate::sockaddr, + + pub ai_canonname: *mut c_char, + + pub ai_next: *mut addrinfo, + } + + pub struct sockaddr_ll { + pub sll_family: c_ushort, + pub sll_protocol: c_ushort, + pub sll_ifindex: c_int, + pub sll_hatype: c_ushort, + pub sll_pkttype: c_uchar, + pub sll_halen: c_uchar, + pub sll_addr: [c_uchar; 8], + } + + pub struct fd_set { + fds_bits: [c_ulong; FD_SETSIZE as usize / ULONG_SIZE], + } + + pub struct tm { + pub tm_sec: c_int, + pub tm_min: c_int, + pub tm_hour: c_int, + pub tm_mday: c_int, + pub tm_mon: c_int, + pub tm_year: c_int, + pub tm_wday: c_int, + pub tm_yday: c_int, + pub tm_isdst: c_int, + pub tm_gmtoff: c_long, + pub tm_zone: *const c_char, + } + + pub struct sched_param { + pub sched_priority: c_int, + pub sched_ss_low_priority: c_int, + pub sched_ss_repl_period: crate::timespec, + pub sched_ss_init_budget: crate::timespec, + pub sched_ss_max_repl: c_int, + } + + pub struct Dl_info { + pub dli_fname: *const c_char, + pub dli_fbase: *mut c_void, + pub dli_sname: *const c_char, + pub dli_saddr: *mut c_void, + } + + pub struct epoll_event { + pub events: u32, + pub u64: u64, + } + + pub struct lconv { + pub decimal_point: *mut c_char, + pub thousands_sep: *mut c_char, + pub grouping: *mut c_char, + pub int_curr_symbol: *mut c_char, + pub currency_symbol: *mut c_char, + pub mon_decimal_point: *mut c_char, + pub mon_thousands_sep: *mut c_char, + pub mon_grouping: *mut c_char, + pub positive_sign: *mut c_char, + pub negative_sign: *mut c_char, + pub int_frac_digits: c_char, + pub frac_digits: c_char, + pub p_cs_precedes: c_char, + pub p_sep_by_space: c_char, + pub n_cs_precedes: c_char, + pub n_sep_by_space: c_char, + pub p_sign_posn: c_char, + pub n_sign_posn: c_char, + pub int_p_cs_precedes: c_char, + pub int_p_sep_by_space: c_char, + pub int_n_cs_precedes: c_char, + pub int_n_sep_by_space: c_char, + pub int_p_sign_posn: c_char, + pub int_n_sign_posn: c_char, + } + + pub struct rlimit64 { + pub rlim_cur: rlim64_t, + pub rlim_max: rlim64_t, + } + + pub struct glob_t { + pub gl_pathc: size_t, + pub gl_pathv: *mut *mut c_char, + pub gl_offs: size_t, + pub gl_flags: c_int, + + __unused1: Padding<*mut c_void>, + __unused2: Padding<*mut c_void>, + __unused3: Padding<*mut c_void>, + __unused4: Padding<*mut c_void>, + __unused5: Padding<*mut c_void>, + } + + pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut c_char, + pub ifa_flags: c_uint, + pub ifa_addr: *mut crate::sockaddr, + pub ifa_netmask: *mut crate::sockaddr, + pub ifa_ifu: *mut crate::sockaddr, // FIXME(union) This should be a union + pub ifa_data: *mut c_void, + } + + pub struct passwd { + pub pw_name: *mut c_char, + pub pw_passwd: *mut c_char, + pub pw_uid: crate::uid_t, + pub pw_gid: crate::gid_t, + pub pw_gecos: *mut c_char, + pub pw_dir: *mut c_char, + pub pw_shell: *mut c_char, + } + + pub struct spwd { + pub sp_namp: *mut c_char, + pub sp_pwdp: *mut c_char, + pub sp_lstchg: c_long, + pub sp_min: c_long, + pub sp_max: c_long, + pub sp_warn: c_long, + pub sp_inact: c_long, + pub sp_expire: c_long, + pub sp_flag: c_ulong, + } + + pub struct statvfs { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_favail: crate::fsfilcnt_t, + #[cfg(target_endian = "little")] + pub f_fsid: c_ulong, + #[cfg(all(target_pointer_width = "32", not(target_arch = "x86_64")))] + __f_unused: Padding, + #[cfg(target_endian = "big")] + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: [c_int; 6], + } + + pub struct dqblk { + pub dqb_bhardlimit: u64, + pub dqb_bsoftlimit: u64, + pub dqb_curspace: u64, + pub dqb_ihardlimit: u64, + pub dqb_isoftlimit: u64, + pub dqb_curinodes: u64, + pub dqb_btime: u64, + pub dqb_itime: u64, + pub dqb_valid: u32, + } + + pub struct signalfd_siginfo { + pub ssi_signo: u32, + pub ssi_errno: i32, + pub ssi_code: i32, + pub ssi_pid: u32, + pub ssi_uid: u32, + pub ssi_fd: i32, + pub ssi_tid: u32, + pub ssi_band: u32, + pub ssi_overrun: u32, + pub ssi_trapno: u32, + pub ssi_status: i32, + pub ssi_int: i32, + pub ssi_ptr: u64, + pub ssi_utime: u64, + pub ssi_stime: u64, + pub ssi_addr: u64, + pub ssi_addr_lsb: u16, + _pad2: Padding, + pub ssi_syscall: i32, + pub ssi_call_addr: u64, + pub ssi_arch: u32, + _pad: Padding<[u8; 28]>, + } + + pub struct itimerspec { + pub it_interval: crate::timespec, + pub it_value: crate::timespec, + } + + pub struct fsid_t { + __val: [c_int; 2], + } + + pub struct cpu_set_t { + #[cfg(all(target_pointer_width = "32", not(target_arch = "x86_64")))] + bits: [u32; 32], + #[cfg(not(all(target_pointer_width = "32", not(target_arch = "x86_64"))))] + bits: [u64; 16], + } + + pub struct if_nameindex { + pub if_index: c_uint, + pub if_name: *mut c_char, + } + + // System V IPC + pub struct msginfo { + pub msgpool: c_int, + pub msgmap: c_int, + pub msgmax: c_int, + pub msgmnb: c_int, + pub msgmni: c_int, + pub msgssz: c_int, + pub msgtql: c_int, + pub msgseg: c_ushort, + } + + pub struct mmsghdr { + pub msg_hdr: crate::msghdr, + pub msg_len: c_uint, + } + + pub struct sembuf { + pub sem_num: c_ushort, + pub sem_op: c_short, + pub sem_flg: c_short, + } + + pub struct input_event { + pub time: crate::timeval, + pub type_: crate::__u16, + pub code: crate::__u16, + pub value: crate::__s32, + } + + pub struct input_id { + pub bustype: crate::__u16, + pub vendor: crate::__u16, + pub product: crate::__u16, + pub version: crate::__u16, + } + + pub struct input_absinfo { + pub value: crate::__s32, + pub minimum: crate::__s32, + pub maximum: crate::__s32, + pub fuzz: crate::__s32, + pub flat: crate::__s32, + pub resolution: crate::__s32, + } + + pub struct input_keymap_entry { + pub flags: crate::__u8, + pub len: crate::__u8, + pub index: crate::__u16, + pub keycode: crate::__u32, + pub scancode: [crate::__u8; 32], + } + + pub struct input_mask { + pub type_: crate::__u32, + pub codes_size: crate::__u32, + pub codes_ptr: crate::__u64, + } + + pub struct ff_replay { + pub length: crate::__u16, + pub delay: crate::__u16, + } + + pub struct ff_trigger { + pub button: crate::__u16, + pub interval: crate::__u16, + } + + pub struct ff_envelope { + pub attack_length: crate::__u16, + pub attack_level: crate::__u16, + pub fade_length: crate::__u16, + pub fade_level: crate::__u16, + } + + pub struct ff_constant_effect { + pub level: crate::__s16, + pub envelope: ff_envelope, + } + + pub struct ff_ramp_effect { + pub start_level: crate::__s16, + pub end_level: crate::__s16, + pub envelope: ff_envelope, + } + + pub struct ff_condition_effect { + pub right_saturation: crate::__u16, + pub left_saturation: crate::__u16, + + pub right_coeff: crate::__s16, + pub left_coeff: crate::__s16, + + pub deadband: crate::__u16, + pub center: crate::__s16, + } + + pub struct ff_periodic_effect { + pub waveform: crate::__u16, + pub period: crate::__u16, + pub magnitude: crate::__s16, + pub offset: crate::__s16, + pub phase: crate::__u16, + + pub envelope: ff_envelope, + + pub custom_len: crate::__u32, + pub custom_data: *mut crate::__s16, + } + + pub struct ff_rumble_effect { + pub strong_magnitude: crate::__u16, + pub weak_magnitude: crate::__u16, + } + + pub struct ff_effect { + pub type_: crate::__u16, + pub id: crate::__s16, + pub direction: crate::__u16, + pub trigger: ff_trigger, + pub replay: ff_replay, + // FIXME(1.0): this is actually a union + #[cfg(target_pointer_width = "64")] + pub u: [u64; 4], + #[cfg(target_pointer_width = "32")] + pub u: [u32; 7], + } + + pub struct dl_phdr_info { + #[cfg(target_pointer_width = "64")] + pub dlpi_addr: Elf64_Addr, + #[cfg(target_pointer_width = "32")] + pub dlpi_addr: Elf32_Addr, + + pub dlpi_name: *const c_char, + + #[cfg(target_pointer_width = "64")] + pub dlpi_phdr: *const Elf64_Phdr, + #[cfg(target_pointer_width = "32")] + pub dlpi_phdr: *const Elf32_Phdr, + + #[cfg(target_pointer_width = "64")] + pub dlpi_phnum: Elf64_Half, + #[cfg(target_pointer_width = "32")] + pub dlpi_phnum: Elf32_Half, + + pub dlpi_adds: c_ulonglong, + pub dlpi_subs: c_ulonglong, + pub dlpi_tls_modid: size_t, + pub dlpi_tls_data: *mut c_void, + } + + pub struct Elf32_Phdr { + pub p_type: Elf32_Word, + pub p_offset: Elf32_Off, + pub p_vaddr: Elf32_Addr, + pub p_paddr: Elf32_Addr, + pub p_filesz: Elf32_Word, + pub p_memsz: Elf32_Word, + pub p_flags: Elf32_Word, + pub p_align: Elf32_Word, + } + + pub struct Elf64_Phdr { + pub p_type: Elf64_Word, + pub p_flags: Elf64_Word, + pub p_offset: Elf64_Off, + pub p_vaddr: Elf64_Addr, + pub p_paddr: Elf64_Addr, + pub p_filesz: Elf64_Xword, + pub p_memsz: Elf64_Xword, + pub p_align: Elf64_Xword, + } + + pub struct statfs64 { + pub f_type: c_ulong, + pub f_bsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_fsid: crate::fsid_t, + pub f_namelen: c_ulong, + pub f_frsize: c_ulong, + pub f_flags: c_ulong, + pub f_spare: [c_ulong; 4], + } + + pub struct statvfs64 { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: [c_int; 6], + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_flags: c_int, + pub ss_size: size_t, + } + + pub struct pthread_attr_t { + __size: [u64; 7], + } + + pub struct sigset_t { + __val: [c_ulong; 16], + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, + pub shm_atime: crate::time_t, + pub shm_dtime: crate::time_t, + pub shm_ctime: crate::time_t, + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: c_ulong, + __pad1: Padding, + __pad2: Padding, + } + + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + pub msg_stime: crate::time_t, + pub msg_rtime: crate::time_t, + pub msg_ctime: crate::time_t, + pub __msg_cbytes: c_ulong, + pub msg_qnum: crate::msgqnum_t, + pub msg_qbytes: crate::msglen_t, + pub msg_lspid: crate::pid_t, + pub msg_lrpid: crate::pid_t, + __pad1: Padding, + __pad2: Padding, + } + + pub struct statfs { + pub f_type: c_ulong, + pub f_bsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_fsid: crate::fsid_t, + pub f_namelen: c_ulong, + pub f_frsize: c_ulong, + pub f_flags: c_ulong, + pub f_spare: [c_ulong; 4], + } + + pub struct msghdr { + pub msg_name: *mut c_void, + pub msg_namelen: crate::socklen_t, + pub msg_iov: *mut crate::iovec, + pub msg_iovlen: c_int, + __pad1: Padding, + pub msg_control: *mut c_void, + pub msg_controllen: crate::socklen_t, + __pad2: Padding, + pub msg_flags: c_int, + } + + pub struct cmsghdr { + pub cmsg_len: crate::socklen_t, + pub __pad1: c_int, + pub cmsg_level: c_int, + pub cmsg_type: c_int, + } + + pub struct sem_t { + __val: [c_int; 8], + } + + pub struct siginfo_t { + pub si_signo: c_int, + pub si_errno: c_int, + pub si_code: c_int, + pub _pad: [c_int; 29], + _align: [usize; 0], + } + + pub struct termios2 { + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_line: crate::cc_t, + pub c_cc: [crate::cc_t; 19], + pub c_ispeed: crate::speed_t, + pub c_ospeed: crate::speed_t, + } + + pub struct in6_pktinfo { + pub ipi6_addr: crate::in6_addr, + pub ipi6_ifindex: c_uint, + } + + #[cfg_attr( + any(target_pointer_width = "32", target_arch = "x86_64"), + repr(align(4)) + )] + #[cfg_attr( + not(any(target_pointer_width = "32", target_arch = "x86_64")), + repr(align(8)) + )] + pub struct pthread_mutexattr_t { + size: [u8; crate::__SIZEOF_PTHREAD_MUTEXATTR_T], + } + + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + pub struct pthread_rwlockattr_t { + size: [u8; crate::__SIZEOF_PTHREAD_RWLOCKATTR_T], + } + + #[repr(align(4))] + pub struct pthread_condattr_t { + size: [u8; crate::__SIZEOF_PTHREAD_CONDATTR_T], + } + + pub struct sysinfo { + pub uptime: c_ulong, + pub loads: [c_ulong; 3], + pub totalram: c_ulong, + pub freeram: c_ulong, + pub sharedram: c_ulong, + pub bufferram: c_ulong, + pub totalswap: c_ulong, + pub freeswap: c_ulong, + pub procs: c_ushort, + pub pad: c_ushort, + pub totalhigh: c_ulong, + pub freehigh: c_ulong, + pub mem_unit: c_uint, + __reserved: Padding<[c_char; 256]>, + } + + pub struct sockaddr_un { + pub sun_family: sa_family_t, + pub sun_path: [c_char; 108], + } + + pub struct sockaddr_storage { + pub ss_family: sa_family_t, + __ss_pad2: Padding<[u8; 128 - 2 - 8]>, + __ss_align: size_t, + } + + pub struct utsname { + pub sysname: [c_char; 65], + pub nodename: [c_char; 65], + pub release: [c_char; 65], + pub version: [c_char; 65], + pub machine: [c_char; 65], + pub domainname: [c_char; 65], + } + + pub struct dirent { + pub d_ino: crate::ino_t, + pub d_off: off_t, + pub d_reclen: c_ushort, + pub d_type: c_uchar, + pub d_name: [c_char; 256], + } + + pub struct dirent64 { + pub d_ino: crate::ino64_t, + pub d_off: off64_t, + pub d_reclen: c_ushort, + pub d_type: c_uchar, + pub d_name: [c_char; 256], + } + + // x32 compatibility + // See https://sourceware.org/bugzilla/show_bug.cgi?id=21279 + pub struct mq_attr { + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub mq_flags: i64, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub mq_maxmsg: i64, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub mq_msgsize: i64, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub mq_curmsgs: i64, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pad: Padding<[i64; 4]>, + + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub mq_flags: c_long, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub mq_maxmsg: c_long, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub mq_msgsize: c_long, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub mq_curmsgs: c_long, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pad: Padding<[c_long; 4]>, + } + + pub struct sockaddr_nl { + pub nl_family: crate::sa_family_t, + nl_pad: Padding, + pub nl_pid: u32, + pub nl_groups: u32, + } + + // FIXME(msrv): suggested method was added in 1.85 + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigevent { + pub sigev_value: crate::sigval, + pub sigev_signo: c_int, + pub sigev_notify: c_int, + pub sigev_notify_function: fn(crate::sigval), + pub sigev_notify_attributes: *mut pthread_attr_t, + pub __pad: [c_char; 56 - 3 * 8], + } + + #[cfg_attr( + all( + target_pointer_width = "32", + any(target_arch = "arm", target_arch = "x86_64") + ), + repr(align(4)) + )] + #[cfg_attr( + any( + target_pointer_width = "64", + not(any(target_arch = "arm", target_arch = "x86_64")) + ), + repr(align(8)) + )] + pub struct pthread_mutex_t { + size: [u8; crate::__SIZEOF_PTHREAD_MUTEX_T], + } + + #[cfg_attr( + all( + target_pointer_width = "32", + any(target_arch = "arm", target_arch = "x86_64") + ), + repr(align(4)) + )] + #[cfg_attr( + any( + target_pointer_width = "64", + not(any(target_arch = "arm", target_arch = "x86_64")) + ), + repr(align(8)) + )] + pub struct pthread_rwlock_t { + size: [u8; crate::__SIZEOF_PTHREAD_RWLOCK_T], + } + + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_arch = "x86", repr(align(4)))] + #[cfg_attr(not(target_arch = "x86"), repr(align(8)))] + pub struct pthread_cond_t { + size: [u8; crate::__SIZEOF_PTHREAD_COND_T], + } +} + +// PUB_CONST + +pub const INT_MIN: c_int = -2147483648; +pub const INT_MAX: c_int = 2147483647; + +pub const SIG_DFL: sighandler_t = 0 as sighandler_t; +pub const SIG_IGN: sighandler_t = 1 as sighandler_t; +pub const SIG_ERR: sighandler_t = !0 as sighandler_t; + +pub const DT_UNKNOWN: u8 = 0; +pub const DT_FIFO: u8 = 1; +pub const DT_CHR: u8 = 2; +pub const DT_DIR: u8 = 4; +pub const DT_BLK: u8 = 6; +pub const DT_REG: u8 = 8; +pub const DT_LNK: u8 = 10; +pub const DT_SOCK: u8 = 12; + +pub const FD_CLOEXEC: c_int = 0x1; + +pub const USRQUOTA: c_int = 0; +pub const GRPQUOTA: c_int = 1; + +pub const SIGIOT: c_int = 6; + +pub const S_ISUID: mode_t = 0o4000; +pub const S_ISGID: mode_t = 0o2000; +pub const S_ISVTX: mode_t = 0o1000; + +pub const IF_NAMESIZE: size_t = 16; +pub const IFNAMSIZ: size_t = IF_NAMESIZE; + +pub const LOG_EMERG: c_int = 0; +pub const LOG_ALERT: c_int = 1; +pub const LOG_CRIT: c_int = 2; +pub const LOG_ERR: c_int = 3; +pub const LOG_WARNING: c_int = 4; +pub const LOG_NOTICE: c_int = 5; +pub const LOG_INFO: c_int = 6; +pub const LOG_DEBUG: c_int = 7; + +pub const LOG_KERN: c_int = 0; +pub const LOG_USER: c_int = 1 << 3; +pub const LOG_MAIL: c_int = 2 << 3; +pub const LOG_DAEMON: c_int = 3 << 3; +pub const LOG_AUTH: c_int = 4 << 3; +pub const LOG_SYSLOG: c_int = 5 << 3; +pub const LOG_LPR: c_int = 6 << 3; +pub const LOG_NEWS: c_int = 7 << 3; +pub const LOG_UUCP: c_int = 8 << 3; +pub const LOG_LOCAL0: c_int = 16 << 3; +pub const LOG_LOCAL1: c_int = 17 << 3; +pub const LOG_LOCAL2: c_int = 18 << 3; +pub const LOG_LOCAL3: c_int = 19 << 3; +pub const LOG_LOCAL4: c_int = 20 << 3; +pub const LOG_LOCAL5: c_int = 21 << 3; +pub const LOG_LOCAL6: c_int = 22 << 3; +pub const LOG_LOCAL7: c_int = 23 << 3; + +pub const LOG_PID: c_int = 0x01; +pub const LOG_CONS: c_int = 0x02; +pub const LOG_ODELAY: c_int = 0x04; +pub const LOG_NDELAY: c_int = 0x08; +pub const LOG_NOWAIT: c_int = 0x10; + +pub const LOG_PRIMASK: c_int = 7; +pub const LOG_FACMASK: c_int = 0x3f8; + +pub const PRIO_PROCESS: c_int = 0; +pub const PRIO_PGRP: c_int = 1; +pub const PRIO_USER: c_int = 2; + +pub const PRIO_MIN: c_int = -20; +pub const PRIO_MAX: c_int = 20; + +pub const IPPROTO_ICMP: c_int = 1; +pub const IPPROTO_ICMPV6: c_int = 58; +pub const IPPROTO_TCP: c_int = 6; +pub const IPPROTO_UDP: c_int = 17; +pub const IPPROTO_IP: c_int = 0; +pub const IPPROTO_IPV6: c_int = 41; + +pub const INADDR_LOOPBACK: in_addr_t = 2130706433; +pub const INADDR_ANY: in_addr_t = 0; +pub const INADDR_BROADCAST: in_addr_t = 4294967295; +pub const INADDR_NONE: in_addr_t = 4294967295; + +pub const EXIT_FAILURE: c_int = 1; +pub const EXIT_SUCCESS: c_int = 0; +pub const RAND_MAX: c_int = 2147483647; +pub const EOF: c_int = -1; +pub const SEEK_SET: c_int = 0; +pub const SEEK_CUR: c_int = 1; +pub const SEEK_END: c_int = 2; +pub const _IOFBF: c_int = 0; +pub const _IONBF: c_int = 2; +pub const _IOLBF: c_int = 1; + +pub const F_DUPFD: c_int = 0; +pub const F_GETFD: c_int = 1; +pub const F_SETFD: c_int = 2; +pub const F_GETFL: c_int = 3; +pub const F_SETFL: c_int = 4; + +// Linux-specific fcntls +pub const F_SETLEASE: c_int = 1024; +pub const F_GETLEASE: c_int = 1025; +pub const F_NOTIFY: c_int = 1026; +pub const F_CANCELLK: c_int = 1029; +pub const F_DUPFD_CLOEXEC: c_int = 1030; +pub const F_SETPIPE_SZ: c_int = 1031; +pub const F_GETPIPE_SZ: c_int = 1032; +pub const F_ADD_SEALS: c_int = 1033; +pub const F_GET_SEALS: c_int = 1034; + +pub const F_SEAL_SEAL: c_int = 0x0001; +pub const F_SEAL_SHRINK: c_int = 0x0002; +pub const F_SEAL_GROW: c_int = 0x0004; +pub const F_SEAL_WRITE: c_int = 0x0008; + +// FIXME(#235): Include file sealing fcntls once we have a way to verify them. + +pub const SIGTRAP: c_int = 5; + +pub const PTHREAD_CREATE_JOINABLE: c_int = 0; +pub const PTHREAD_CREATE_DETACHED: c_int = 1; + +pub const CLOCK_REALTIME: crate::clockid_t = 0; +pub const CLOCK_MONOTONIC: crate::clockid_t = 1; +pub const CLOCK_PROCESS_CPUTIME_ID: crate::clockid_t = 2; +pub const CLOCK_THREAD_CPUTIME_ID: crate::clockid_t = 3; +pub const CLOCK_MONOTONIC_RAW: crate::clockid_t = 4; +pub const CLOCK_REALTIME_COARSE: crate::clockid_t = 5; +pub const CLOCK_MONOTONIC_COARSE: crate::clockid_t = 6; +pub const CLOCK_BOOTTIME: crate::clockid_t = 7; +pub const CLOCK_REALTIME_ALARM: crate::clockid_t = 8; +pub const CLOCK_BOOTTIME_ALARM: crate::clockid_t = 9; +pub const CLOCK_SGI_CYCLE: crate::clockid_t = 10; +pub const CLOCK_TAI: crate::clockid_t = 11; +pub const TIMER_ABSTIME: c_int = 1; + +pub const RLIMIT_CPU: c_int = 0; +pub const RLIMIT_FSIZE: c_int = 1; +pub const RLIMIT_DATA: c_int = 2; +pub const RLIMIT_STACK: c_int = 3; +pub const RLIMIT_CORE: c_int = 4; +pub const RLIMIT_LOCKS: c_int = 10; +pub const RLIMIT_SIGPENDING: c_int = 11; +pub const RLIMIT_MSGQUEUE: c_int = 12; +pub const RLIMIT_NICE: c_int = 13; +pub const RLIMIT_RTPRIO: c_int = 14; + +pub const RUSAGE_SELF: c_int = 0; + +pub const O_RDONLY: c_int = 0; +pub const O_WRONLY: c_int = 1; +pub const O_RDWR: c_int = 2; + +pub const S_IFIFO: mode_t = 0o1_0000; +pub const S_IFCHR: mode_t = 0o2_0000; +pub const S_IFBLK: mode_t = 0o6_0000; +pub const S_IFDIR: mode_t = 0o4_0000; +pub const S_IFREG: mode_t = 0o10_0000; +pub const S_IFLNK: mode_t = 0o12_0000; +pub const S_IFSOCK: mode_t = 0o14_0000; +pub const S_IFMT: mode_t = 0o17_0000; +pub const S_IRWXU: mode_t = 0o0700; +pub const S_IXUSR: mode_t = 0o0100; +pub const S_IWUSR: mode_t = 0o0200; +pub const S_IRUSR: mode_t = 0o0400; +pub const S_IRWXG: mode_t = 0o0070; +pub const S_IXGRP: mode_t = 0o0010; +pub const S_IWGRP: mode_t = 0o0020; +pub const S_IRGRP: mode_t = 0o0040; +pub const S_IRWXO: mode_t = 0o0007; +pub const S_IXOTH: mode_t = 0o0001; +pub const S_IWOTH: mode_t = 0o0002; +pub const S_IROTH: mode_t = 0o0004; +pub const F_OK: c_int = 0; +pub const R_OK: c_int = 4; +pub const W_OK: c_int = 2; +pub const X_OK: c_int = 1; +pub const SIGHUP: c_int = 1; +pub const SIGINT: c_int = 2; +pub const SIGQUIT: c_int = 3; +pub const SIGILL: c_int = 4; +pub const SIGABRT: c_int = 6; +pub const SIGFPE: c_int = 8; +pub const SIGKILL: c_int = 9; +pub const SIGSEGV: c_int = 11; +pub const SIGPIPE: c_int = 13; +pub const SIGALRM: c_int = 14; +pub const SIGTERM: c_int = 15; + +pub const PROT_NONE: c_int = 0; +pub const PROT_READ: c_int = 1; +pub const PROT_WRITE: c_int = 2; +pub const PROT_EXEC: c_int = 4; + +pub const LC_CTYPE: c_int = 0; +pub const LC_NUMERIC: c_int = 1; +pub const LC_TIME: c_int = 2; +pub const LC_COLLATE: c_int = 3; +pub const LC_MONETARY: c_int = 4; +pub const LC_MESSAGES: c_int = 5; +pub const LC_ALL: c_int = 6; +pub const LC_CTYPE_MASK: c_int = 1 << LC_CTYPE; +pub const LC_NUMERIC_MASK: c_int = 1 << LC_NUMERIC; +pub const LC_TIME_MASK: c_int = 1 << LC_TIME; +pub const LC_COLLATE_MASK: c_int = 1 << LC_COLLATE; +pub const LC_MONETARY_MASK: c_int = 1 << LC_MONETARY; +pub const LC_MESSAGES_MASK: c_int = 1 << LC_MESSAGES; +// LC_ALL_MASK defined per platform + +pub const MAP_FILE: c_int = 0x0000; +pub const MAP_SHARED: c_int = 0x0001; +pub const MAP_PRIVATE: c_int = 0x0002; +pub const MAP_FIXED: c_int = 0x0010; + +pub const MAP_FAILED: *mut c_void = !0 as *mut c_void; + +// MS_ flags for msync(2) +pub const MS_ASYNC: c_int = 0x0001; +pub const MS_INVALIDATE: c_int = 0x0002; +pub const MS_SYNC: c_int = 0x0004; + +// MS_ flags for mount(2) +pub const MS_RDONLY: c_ulong = 0x01; +pub const MS_NOSUID: c_ulong = 0x02; +pub const MS_NODEV: c_ulong = 0x04; +pub const MS_NOEXEC: c_ulong = 0x08; +pub const MS_SYNCHRONOUS: c_ulong = 0x10; +pub const MS_REMOUNT: c_ulong = 0x20; +pub const MS_MANDLOCK: c_ulong = 0x40; +pub const MS_DIRSYNC: c_ulong = 0x80; +pub const MS_NOATIME: c_ulong = 0x0400; +pub const MS_NODIRATIME: c_ulong = 0x0800; +pub const MS_BIND: c_ulong = 0x1000; +pub const MS_MOVE: c_ulong = 0x2000; +pub const MS_REC: c_ulong = 0x4000; +pub const MS_SILENT: c_ulong = 0x8000; +pub const MS_POSIXACL: c_ulong = 0x010000; +pub const MS_UNBINDABLE: c_ulong = 0x020000; +pub const MS_PRIVATE: c_ulong = 0x040000; +pub const MS_SLAVE: c_ulong = 0x080000; +pub const MS_SHARED: c_ulong = 0x100000; +pub const MS_RELATIME: c_ulong = 0x200000; +pub const MS_KERNMOUNT: c_ulong = 0x400000; +pub const MS_I_VERSION: c_ulong = 0x800000; +pub const MS_STRICTATIME: c_ulong = 0x1000000; +pub const MS_ACTIVE: c_ulong = 0x40000000; +pub const MS_NOUSER: c_ulong = 0x80000000; +pub const MS_MGC_VAL: c_ulong = 0xc0ed0000; +pub const MS_MGC_MSK: c_ulong = 0xffff0000; +pub const MS_RMT_MASK: c_ulong = 0x800051; + +pub const EPERM: c_int = 1; +pub const ENOENT: c_int = 2; +pub const ESRCH: c_int = 3; +pub const EINTR: c_int = 4; +pub const EIO: c_int = 5; +pub const ENXIO: c_int = 6; +pub const E2BIG: c_int = 7; +pub const ENOEXEC: c_int = 8; +pub const EBADF: c_int = 9; +pub const ECHILD: c_int = 10; +pub const EAGAIN: c_int = 11; +pub const ENOMEM: c_int = 12; +pub const EACCES: c_int = 13; +pub const EFAULT: c_int = 14; +pub const ENOTBLK: c_int = 15; +pub const EBUSY: c_int = 16; +pub const EEXIST: c_int = 17; +pub const EXDEV: c_int = 18; +pub const ENODEV: c_int = 19; +pub const ENOTDIR: c_int = 20; +pub const EISDIR: c_int = 21; +pub const EINVAL: c_int = 22; +pub const ENFILE: c_int = 23; +pub const EMFILE: c_int = 24; +pub const ENOTTY: c_int = 25; +pub const ETXTBSY: c_int = 26; +pub const EFBIG: c_int = 27; +pub const ENOSPC: c_int = 28; +pub const ESPIPE: c_int = 29; +pub const EROFS: c_int = 30; +pub const EMLINK: c_int = 31; +pub const EPIPE: c_int = 32; +pub const EDOM: c_int = 33; +pub const ERANGE: c_int = 34; +pub const EWOULDBLOCK: c_int = EAGAIN; + +pub const SCM_RIGHTS: c_int = 0x01; +pub const SCM_CREDENTIALS: c_int = 0x02; + +pub const PROT_GROWSDOWN: c_int = 0x1000000; +pub const PROT_GROWSUP: c_int = 0x2000000; + +pub const MAP_TYPE: c_int = 0x000f; + +pub const MADV_NORMAL: c_int = 0; +pub const MADV_RANDOM: c_int = 1; +pub const MADV_SEQUENTIAL: c_int = 2; +pub const MADV_WILLNEED: c_int = 3; +pub const MADV_DONTNEED: c_int = 4; +pub const MADV_FREE: c_int = 8; +pub const MADV_REMOVE: c_int = 9; +pub const MADV_DONTFORK: c_int = 10; +pub const MADV_DOFORK: c_int = 11; +pub const MADV_MERGEABLE: c_int = 12; +pub const MADV_UNMERGEABLE: c_int = 13; +pub const MADV_HUGEPAGE: c_int = 14; +pub const MADV_NOHUGEPAGE: c_int = 15; +pub const MADV_DONTDUMP: c_int = 16; +pub const MADV_DODUMP: c_int = 17; +pub const MADV_HWPOISON: c_int = 100; +pub const MADV_SOFT_OFFLINE: c_int = 101; + +pub const IFF_UP: c_int = 0x1; +pub const IFF_BROADCAST: c_int = 0x2; +pub const IFF_DEBUG: c_int = 0x4; +pub const IFF_LOOPBACK: c_int = 0x8; +pub const IFF_POINTOPOINT: c_int = 0x10; +pub const IFF_NOTRAILERS: c_int = 0x20; +pub const IFF_RUNNING: c_int = 0x40; +pub const IFF_NOARP: c_int = 0x80; +pub const IFF_PROMISC: c_int = 0x100; +pub const IFF_ALLMULTI: c_int = 0x200; +pub const IFF_MASTER: c_int = 0x400; +pub const IFF_SLAVE: c_int = 0x800; +pub const IFF_MULTICAST: c_int = 0x1000; +pub const IFF_PORTSEL: c_int = 0x2000; +pub const IFF_AUTOMEDIA: c_int = 0x4000; +pub const IFF_DYNAMIC: c_int = 0x8000; +pub const IFF_TUN: c_int = 0x0001; +pub const IFF_TAP: c_int = 0x0002; +pub const IFF_NO_PI: c_int = 0x1000; + +pub const SOL_IP: c_int = 0; +pub const SOL_TCP: c_int = 6; +pub const SOL_UDP: c_int = 17; +pub const SOL_IPV6: c_int = 41; +pub const SOL_ICMPV6: c_int = 58; +pub const SOL_RAW: c_int = 255; +pub const SOL_DECNET: c_int = 261; +pub const SOL_X25: c_int = 262; +pub const SOL_PACKET: c_int = 263; +pub const SOL_ATM: c_int = 264; +pub const SOL_AAL: c_int = 265; +pub const SOL_IRDA: c_int = 266; +pub const SOL_NETBEUI: c_int = 267; +pub const SOL_LLC: c_int = 268; +pub const SOL_DCCP: c_int = 269; +pub const SOL_NETLINK: c_int = 270; +pub const SOL_TIPC: c_int = 271; + +pub const AF_UNSPEC: c_int = 0; +pub const AF_UNIX: c_int = 1; +pub const AF_LOCAL: c_int = 1; +pub const AF_INET: c_int = 2; +pub const AF_AX25: c_int = 3; +pub const AF_IPX: c_int = 4; +pub const AF_APPLETALK: c_int = 5; +pub const AF_NETROM: c_int = 6; +pub const AF_BRIDGE: c_int = 7; +pub const AF_ATMPVC: c_int = 8; +pub const AF_X25: c_int = 9; +pub const AF_INET6: c_int = 10; +pub const AF_ROSE: c_int = 11; +pub const AF_DECnet: c_int = 12; +pub const AF_NETBEUI: c_int = 13; +pub const AF_SECURITY: c_int = 14; +pub const AF_KEY: c_int = 15; +pub const AF_NETLINK: c_int = 16; +pub const AF_ROUTE: c_int = AF_NETLINK; +pub const AF_PACKET: c_int = 17; +pub const AF_ASH: c_int = 18; +pub const AF_ECONET: c_int = 19; +pub const AF_ATMSVC: c_int = 20; +pub const AF_RDS: c_int = 21; +pub const AF_SNA: c_int = 22; +pub const AF_IRDA: c_int = 23; +pub const AF_PPPOX: c_int = 24; +pub const AF_WANPIPE: c_int = 25; +pub const AF_LLC: c_int = 26; +pub const AF_CAN: c_int = 29; +pub const AF_TIPC: c_int = 30; +pub const AF_BLUETOOTH: c_int = 31; +pub const AF_IUCV: c_int = 32; +pub const AF_RXRPC: c_int = 33; +pub const AF_ISDN: c_int = 34; +pub const AF_PHONET: c_int = 35; +pub const AF_IEEE802154: c_int = 36; +pub const AF_CAIF: c_int = 37; +pub const AF_ALG: c_int = 38; + +pub const PF_UNSPEC: c_int = AF_UNSPEC; +pub const PF_UNIX: c_int = AF_UNIX; +pub const PF_LOCAL: c_int = AF_LOCAL; +pub const PF_INET: c_int = AF_INET; +pub const PF_AX25: c_int = AF_AX25; +pub const PF_IPX: c_int = AF_IPX; +pub const PF_APPLETALK: c_int = AF_APPLETALK; +pub const PF_NETROM: c_int = AF_NETROM; +pub const PF_BRIDGE: c_int = AF_BRIDGE; +pub const PF_ATMPVC: c_int = AF_ATMPVC; +pub const PF_X25: c_int = AF_X25; +pub const PF_INET6: c_int = AF_INET6; +pub const PF_ROSE: c_int = AF_ROSE; +pub const PF_DECnet: c_int = AF_DECnet; +pub const PF_NETBEUI: c_int = AF_NETBEUI; +pub const PF_SECURITY: c_int = AF_SECURITY; +pub const PF_KEY: c_int = AF_KEY; +pub const PF_NETLINK: c_int = AF_NETLINK; +pub const PF_ROUTE: c_int = AF_ROUTE; +pub const PF_PACKET: c_int = AF_PACKET; +pub const PF_ASH: c_int = AF_ASH; +pub const PF_ECONET: c_int = AF_ECONET; +pub const PF_ATMSVC: c_int = AF_ATMSVC; +pub const PF_RDS: c_int = AF_RDS; +pub const PF_SNA: c_int = AF_SNA; +pub const PF_IRDA: c_int = AF_IRDA; +pub const PF_PPPOX: c_int = AF_PPPOX; +pub const PF_WANPIPE: c_int = AF_WANPIPE; +pub const PF_LLC: c_int = AF_LLC; +pub const PF_CAN: c_int = AF_CAN; +pub const PF_TIPC: c_int = AF_TIPC; +pub const PF_BLUETOOTH: c_int = AF_BLUETOOTH; +pub const PF_IUCV: c_int = AF_IUCV; +pub const PF_RXRPC: c_int = AF_RXRPC; +pub const PF_ISDN: c_int = AF_ISDN; +pub const PF_PHONET: c_int = AF_PHONET; +pub const PF_IEEE802154: c_int = AF_IEEE802154; +pub const PF_CAIF: c_int = AF_CAIF; +pub const PF_ALG: c_int = AF_ALG; + +pub const SOMAXCONN: c_int = 128; + +pub const MSG_OOB: c_int = 1; +pub const MSG_PEEK: c_int = 2; +pub const MSG_DONTROUTE: c_int = 4; +pub const MSG_CTRUNC: c_int = 8; +pub const MSG_TRUNC: c_int = 0x20; +pub const MSG_DONTWAIT: c_int = 0x40; +pub const MSG_EOR: c_int = 0x80; +pub const MSG_WAITALL: c_int = 0x100; +pub const MSG_FIN: c_int = 0x200; +pub const MSG_SYN: c_int = 0x400; +pub const MSG_CONFIRM: c_int = 0x800; +pub const MSG_RST: c_int = 0x1000; +pub const MSG_ERRQUEUE: c_int = 0x2000; +pub const MSG_NOSIGNAL: c_int = 0x4000; +pub const MSG_MORE: c_int = 0x8000; +pub const MSG_WAITFORONE: c_int = 0x10000; +pub const MSG_FASTOPEN: c_int = 0x20000000; +pub const MSG_CMSG_CLOEXEC: c_int = 0x40000000; + +pub const SCM_TIMESTAMP: c_int = SO_TIMESTAMP; + +pub const SOCK_RAW: c_int = 3; +pub const SOCK_RDM: c_int = 4; + +pub const IP_TOS: c_int = 1; +pub const IP_TTL: c_int = 2; +pub const IP_HDRINCL: c_int = 3; +pub const IP_RECVTOS: c_int = 13; +pub const IP_FREEBIND: c_int = 15; +pub const IP_TRANSPARENT: c_int = 19; +pub const IP_MULTICAST_IF: c_int = 32; +pub const IP_MULTICAST_TTL: c_int = 33; +pub const IP_MULTICAST_LOOP: c_int = 34; +pub const IP_ADD_MEMBERSHIP: c_int = 35; +pub const IP_DROP_MEMBERSHIP: c_int = 36; + +pub const IPV6_UNICAST_HOPS: c_int = 16; +pub const IPV6_MULTICAST_IF: c_int = 17; +pub const IPV6_MULTICAST_HOPS: c_int = 18; +pub const IPV6_MULTICAST_LOOP: c_int = 19; +pub const IPV6_ADD_MEMBERSHIP: c_int = 20; +pub const IPV6_DROP_MEMBERSHIP: c_int = 21; +pub const IPV6_V6ONLY: c_int = 26; +pub const IPV6_RECVPKTINFO: c_int = 49; +pub const IPV6_RECVTCLASS: c_int = 66; +pub const IPV6_TCLASS: c_int = 67; + +pub const TCP_NODELAY: c_int = 1; +pub const TCP_MAXSEG: c_int = 2; +pub const TCP_CORK: c_int = 3; +pub const TCP_KEEPIDLE: c_int = 4; +pub const TCP_KEEPINTVL: c_int = 5; +pub const TCP_KEEPCNT: c_int = 6; +pub const TCP_SYNCNT: c_int = 7; +pub const TCP_LINGER2: c_int = 8; +pub const TCP_DEFER_ACCEPT: c_int = 9; +pub const TCP_WINDOW_CLAMP: c_int = 10; +pub const TCP_INFO: c_int = 11; +pub const TCP_QUICKACK: c_int = 12; +pub const TCP_CONGESTION: c_int = 13; + +pub const SO_DEBUG: c_int = 1; + +pub const SHUT_RD: c_int = 0; +pub const SHUT_WR: c_int = 1; +pub const SHUT_RDWR: c_int = 2; + +pub const LOCK_SH: c_int = 1; +pub const LOCK_EX: c_int = 2; +pub const LOCK_NB: c_int = 4; +pub const LOCK_UN: c_int = 8; + +pub const SS_ONSTACK: c_int = 1; +pub const SS_DISABLE: c_int = 2; + +pub const PATH_MAX: c_int = 4096; + +pub const FD_SETSIZE: usize = 1024; + +pub const EPOLLIN: c_int = 0x1; +pub const EPOLLPRI: c_int = 0x2; +pub const EPOLLOUT: c_int = 0x4; +pub const EPOLLRDNORM: c_int = 0x40; +pub const EPOLLRDBAND: c_int = 0x80; +pub const EPOLLWRNORM: c_int = 0x100; +pub const EPOLLWRBAND: c_int = 0x200; +pub const EPOLLMSG: c_int = 0x400; +pub const EPOLLERR: c_int = 0x8; +pub const EPOLLHUP: c_int = 0x10; +pub const EPOLLET: c_int = 0x80000000; + +pub const EPOLL_CTL_ADD: c_int = 1; +pub const EPOLL_CTL_MOD: c_int = 3; +pub const EPOLL_CTL_DEL: c_int = 2; + +pub const MNT_DETACH: c_int = 0x2; +pub const MNT_EXPIRE: c_int = 0x4; + +pub const Q_GETFMT: c_int = 0x800004; +pub const Q_GETINFO: c_int = 0x800005; +pub const Q_SETINFO: c_int = 0x800006; +pub const QIF_BLIMITS: u32 = 1; +pub const QIF_SPACE: u32 = 2; +pub const QIF_ILIMITS: u32 = 4; +pub const QIF_INODES: u32 = 8; +pub const QIF_BTIME: u32 = 16; +pub const QIF_ITIME: u32 = 32; +pub const QIF_LIMITS: u32 = 5; +pub const QIF_USAGE: u32 = 10; +pub const QIF_TIMES: u32 = 48; +pub const QIF_ALL: u32 = 63; + +pub const MNT_FORCE: c_int = 0x1; + +pub const Q_SYNC: c_int = 0x800001; +pub const Q_QUOTAON: c_int = 0x800002; +pub const Q_QUOTAOFF: c_int = 0x800003; +pub const Q_GETQUOTA: c_int = 0x800007; +pub const Q_SETQUOTA: c_int = 0x800008; + +pub const TCIOFF: c_int = 2; +pub const TCION: c_int = 3; +pub const TCOOFF: c_int = 0; +pub const TCOON: c_int = 1; +pub const TCIFLUSH: c_int = 0; +pub const TCOFLUSH: c_int = 1; +pub const TCIOFLUSH: c_int = 2; +pub const NL0: c_int = 0x00000000; +pub const NL1: c_int = 0x00000100; +pub const TAB0: c_int = 0x00000000; +pub const CR0: c_int = 0x00000000; +pub const FF0: c_int = 0x00000000; +pub const BS0: c_int = 0x00000000; +pub const VT0: c_int = 0x00000000; +pub const VERASE: usize = 2; +pub const VKILL: usize = 3; +pub const VINTR: usize = 0; +pub const VQUIT: usize = 1; +pub const VLNEXT: usize = 15; +pub const IGNBRK: crate::tcflag_t = 0x00000001; +pub const BRKINT: crate::tcflag_t = 0x00000002; +pub const IGNPAR: crate::tcflag_t = 0x00000004; +pub const PARMRK: crate::tcflag_t = 0x00000008; +pub const INPCK: crate::tcflag_t = 0x00000010; +pub const ISTRIP: crate::tcflag_t = 0x00000020; +pub const INLCR: crate::tcflag_t = 0x00000040; +pub const IGNCR: crate::tcflag_t = 0x00000080; +pub const ICRNL: crate::tcflag_t = 0x00000100; +pub const IXANY: crate::tcflag_t = 0x00000800; +pub const IMAXBEL: crate::tcflag_t = 0x00002000; +pub const OPOST: crate::tcflag_t = 0x1; +pub const CS5: crate::tcflag_t = 0x00000000; +pub const CRTSCTS: crate::tcflag_t = 0x80000000; +pub const ECHO: crate::tcflag_t = 0x00000008; +pub const OCRNL: crate::tcflag_t = 0o000010; +pub const ONOCR: crate::tcflag_t = 0o000020; +pub const ONLRET: crate::tcflag_t = 0o000040; +pub const OFILL: crate::tcflag_t = 0o000100; +pub const OFDEL: crate::tcflag_t = 0o000200; + +pub const CLONE_VM: c_int = 0x100; +pub const CLONE_FS: c_int = 0x200; +pub const CLONE_FILES: c_int = 0x400; +pub const CLONE_SIGHAND: c_int = 0x800; +pub const CLONE_PTRACE: c_int = 0x2000; +pub const CLONE_VFORK: c_int = 0x4000; +pub const CLONE_PARENT: c_int = 0x8000; +pub const CLONE_THREAD: c_int = 0x10000; +pub const CLONE_NEWNS: c_int = 0x20000; +pub const CLONE_SYSVSEM: c_int = 0x40000; +pub const CLONE_SETTLS: c_int = 0x80000; +pub const CLONE_PARENT_SETTID: c_int = 0x100000; +pub const CLONE_CHILD_CLEARTID: c_int = 0x200000; +pub const CLONE_DETACHED: c_int = 0x400000; +pub const CLONE_UNTRACED: c_int = 0x800000; +pub const CLONE_CHILD_SETTID: c_int = 0x01000000; +pub const CLONE_NEWUTS: c_int = 0x04000000; +pub const CLONE_NEWIPC: c_int = 0x08000000; +pub const CLONE_NEWUSER: c_int = 0x10000000; +pub const CLONE_NEWPID: c_int = 0x20000000; +pub const CLONE_NEWNET: c_int = 0x40000000; +pub const CLONE_IO: c_int = 0x80000000; +pub const CLONE_NEWCGROUP: c_int = 0x02000000; + +pub const WNOHANG: c_int = 0x00000001; +pub const WUNTRACED: c_int = 0x00000002; +pub const WSTOPPED: c_int = WUNTRACED; +pub const WEXITED: c_int = 0x00000004; +pub const WCONTINUED: c_int = 0x00000008; +pub const WNOWAIT: c_int = 0x01000000; + +// Options set using PTRACE_SETOPTIONS. +pub const PTRACE_O_TRACESYSGOOD: c_int = 0x00000001; +pub const PTRACE_O_TRACEFORK: c_int = 0x00000002; +pub const PTRACE_O_TRACEVFORK: c_int = 0x00000004; +pub const PTRACE_O_TRACECLONE: c_int = 0x00000008; +pub const PTRACE_O_TRACEEXEC: c_int = 0x00000010; +pub const PTRACE_O_TRACEVFORKDONE: c_int = 0x00000020; +pub const PTRACE_O_TRACEEXIT: c_int = 0x00000040; +pub const PTRACE_O_TRACESECCOMP: c_int = 0x00000080; +pub const PTRACE_O_EXITKILL: c_int = 0x00100000; +pub const PTRACE_O_SUSPEND_SECCOMP: c_int = 0x00200000; +pub const PTRACE_O_MASK: c_int = 0x003000ff; + +// Wait extended result codes for the above trace options. +pub const PTRACE_EVENT_FORK: c_int = 1; +pub const PTRACE_EVENT_VFORK: c_int = 2; +pub const PTRACE_EVENT_CLONE: c_int = 3; +pub const PTRACE_EVENT_EXEC: c_int = 4; +pub const PTRACE_EVENT_VFORK_DONE: c_int = 5; +pub const PTRACE_EVENT_EXIT: c_int = 6; +pub const PTRACE_EVENT_SECCOMP: c_int = 7; +// PTRACE_EVENT_STOP was added to glibc in 2.26 +// pub const PTRACE_EVENT_STOP: c_int = 128; + +pub const __WNOTHREAD: c_int = 0x20000000; +pub const __WALL: c_int = 0x40000000; +pub const __WCLONE: c_int = 0x80000000; + +pub const SPLICE_F_MOVE: c_uint = 0x01; +pub const SPLICE_F_NONBLOCK: c_uint = 0x02; +pub const SPLICE_F_MORE: c_uint = 0x04; +pub const SPLICE_F_GIFT: c_uint = 0x08; + +pub const RTLD_LOCAL: c_int = 0; +pub const RTLD_LAZY: c_int = 1; + +pub const POSIX_FADV_NORMAL: c_int = 0; +pub const POSIX_FADV_RANDOM: c_int = 1; +pub const POSIX_FADV_SEQUENTIAL: c_int = 2; +pub const POSIX_FADV_WILLNEED: c_int = 3; + +pub const AT_FDCWD: c_int = -100; +pub const AT_SYMLINK_NOFOLLOW: c_int = 0x100; +pub const AT_REMOVEDIR: c_int = 0x200; +pub const AT_EACCESS: c_int = 0x200; +pub const AT_SYMLINK_FOLLOW: c_int = 0x400; +pub const AT_NO_AUTOMOUNT: c_int = 0x800; +pub const AT_EMPTY_PATH: c_int = 0x1000; + +pub const LOG_CRON: c_int = 9 << 3; +pub const LOG_AUTHPRIV: c_int = 10 << 3; +pub const LOG_FTP: c_int = 11 << 3; +pub const LOG_PERROR: c_int = 0x20; + +pub const PIPE_BUF: usize = 4096; + +pub const SI_LOAD_SHIFT: c_uint = 16; + +pub const CLD_EXITED: c_int = 1; +pub const CLD_KILLED: c_int = 2; +pub const CLD_DUMPED: c_int = 3; +pub const CLD_TRAPPED: c_int = 4; +pub const CLD_STOPPED: c_int = 5; +pub const CLD_CONTINUED: c_int = 6; + +pub const SIGEV_SIGNAL: c_int = 0; +pub const SIGEV_NONE: c_int = 1; +pub const SIGEV_THREAD: c_int = 2; + +pub const P_ALL: idtype_t = 0; +pub const P_PID: idtype_t = 1; +pub const P_PGID: idtype_t = 2; + +pub const UTIME_OMIT: c_long = 1073741822; +pub const UTIME_NOW: c_long = 1073741823; + +pub const POLLIN: c_short = 0x1; +pub const POLLPRI: c_short = 0x2; +pub const POLLOUT: c_short = 0x4; +pub const POLLERR: c_short = 0x8; +pub const POLLHUP: c_short = 0x10; +pub const POLLNVAL: c_short = 0x20; +pub const POLLRDNORM: c_short = 0x040; +pub const POLLRDBAND: c_short = 0x080; + +pub const ABDAY_1: crate::nl_item = 0x20000; +pub const ABDAY_2: crate::nl_item = 0x20001; +pub const ABDAY_3: crate::nl_item = 0x20002; +pub const ABDAY_4: crate::nl_item = 0x20003; +pub const ABDAY_5: crate::nl_item = 0x20004; +pub const ABDAY_6: crate::nl_item = 0x20005; +pub const ABDAY_7: crate::nl_item = 0x20006; + +pub const DAY_1: crate::nl_item = 0x20007; +pub const DAY_2: crate::nl_item = 0x20008; +pub const DAY_3: crate::nl_item = 0x20009; +pub const DAY_4: crate::nl_item = 0x2000A; +pub const DAY_5: crate::nl_item = 0x2000B; +pub const DAY_6: crate::nl_item = 0x2000C; +pub const DAY_7: crate::nl_item = 0x2000D; + +pub const ABMON_1: crate::nl_item = 0x2000E; +pub const ABMON_2: crate::nl_item = 0x2000F; +pub const ABMON_3: crate::nl_item = 0x20010; +pub const ABMON_4: crate::nl_item = 0x20011; +pub const ABMON_5: crate::nl_item = 0x20012; +pub const ABMON_6: crate::nl_item = 0x20013; +pub const ABMON_7: crate::nl_item = 0x20014; +pub const ABMON_8: crate::nl_item = 0x20015; +pub const ABMON_9: crate::nl_item = 0x20016; +pub const ABMON_10: crate::nl_item = 0x20017; +pub const ABMON_11: crate::nl_item = 0x20018; +pub const ABMON_12: crate::nl_item = 0x20019; + +pub const MON_1: crate::nl_item = 0x2001A; +pub const MON_2: crate::nl_item = 0x2001B; +pub const MON_3: crate::nl_item = 0x2001C; +pub const MON_4: crate::nl_item = 0x2001D; +pub const MON_5: crate::nl_item = 0x2001E; +pub const MON_6: crate::nl_item = 0x2001F; +pub const MON_7: crate::nl_item = 0x20020; +pub const MON_8: crate::nl_item = 0x20021; +pub const MON_9: crate::nl_item = 0x20022; +pub const MON_10: crate::nl_item = 0x20023; +pub const MON_11: crate::nl_item = 0x20024; +pub const MON_12: crate::nl_item = 0x20025; + +pub const AM_STR: crate::nl_item = 0x20026; +pub const PM_STR: crate::nl_item = 0x20027; + +pub const D_T_FMT: crate::nl_item = 0x20028; +pub const D_FMT: crate::nl_item = 0x20029; +pub const T_FMT: crate::nl_item = 0x2002A; +pub const T_FMT_AMPM: crate::nl_item = 0x2002B; + +pub const ERA: crate::nl_item = 0x2002C; +pub const ERA_D_FMT: crate::nl_item = 0x2002E; +pub const ALT_DIGITS: crate::nl_item = 0x2002F; +pub const ERA_D_T_FMT: crate::nl_item = 0x20030; +pub const ERA_T_FMT: crate::nl_item = 0x20031; + +pub const CODESET: crate::nl_item = 14; + +pub const CRNCYSTR: crate::nl_item = 0x4000F; + +pub const RUSAGE_THREAD: c_int = 1; +pub const RUSAGE_CHILDREN: c_int = -1; + +pub const RADIXCHAR: crate::nl_item = 0x10000; +pub const THOUSEP: crate::nl_item = 0x10001; + +pub const YESEXPR: crate::nl_item = 0x50000; +pub const NOEXPR: crate::nl_item = 0x50001; +pub const YESSTR: crate::nl_item = 0x50002; +pub const NOSTR: crate::nl_item = 0x50003; + +pub const FILENAME_MAX: c_uint = 4096; +pub const L_tmpnam: c_uint = 20; +pub const _PC_LINK_MAX: c_int = 0; +pub const _PC_MAX_CANON: c_int = 1; +pub const _PC_MAX_INPUT: c_int = 2; +pub const _PC_NAME_MAX: c_int = 3; +pub const _PC_PATH_MAX: c_int = 4; +pub const _PC_PIPE_BUF: c_int = 5; +pub const _PC_CHOWN_RESTRICTED: c_int = 6; +pub const _PC_NO_TRUNC: c_int = 7; +pub const _PC_VDISABLE: c_int = 8; +pub const _PC_SYNC_IO: c_int = 9; +pub const _PC_ASYNC_IO: c_int = 10; +pub const _PC_PRIO_IO: c_int = 11; +pub const _PC_SOCK_MAXBUF: c_int = 12; +pub const _PC_FILESIZEBITS: c_int = 13; +pub const _PC_REC_INCR_XFER_SIZE: c_int = 14; +pub const _PC_REC_MAX_XFER_SIZE: c_int = 15; +pub const _PC_REC_MIN_XFER_SIZE: c_int = 16; +pub const _PC_REC_XFER_ALIGN: c_int = 17; +pub const _PC_ALLOC_SIZE_MIN: c_int = 18; +pub const _PC_SYMLINK_MAX: c_int = 19; +pub const _PC_2_SYMLINKS: c_int = 20; + +pub const _SC_ARG_MAX: c_int = 0; +pub const _SC_CHILD_MAX: c_int = 1; +pub const _SC_CLK_TCK: c_int = 2; +pub const _SC_NGROUPS_MAX: c_int = 3; +pub const _SC_OPEN_MAX: c_int = 4; +pub const _SC_STREAM_MAX: c_int = 5; +pub const _SC_TZNAME_MAX: c_int = 6; +pub const _SC_JOB_CONTROL: c_int = 7; +pub const _SC_SAVED_IDS: c_int = 8; +pub const _SC_REALTIME_SIGNALS: c_int = 9; +pub const _SC_PRIORITY_SCHEDULING: c_int = 10; +pub const _SC_TIMERS: c_int = 11; +pub const _SC_ASYNCHRONOUS_IO: c_int = 12; +pub const _SC_PRIORITIZED_IO: c_int = 13; +pub const _SC_SYNCHRONIZED_IO: c_int = 14; +pub const _SC_FSYNC: c_int = 15; +pub const _SC_MAPPED_FILES: c_int = 16; +pub const _SC_MEMLOCK: c_int = 17; +pub const _SC_MEMLOCK_RANGE: c_int = 18; +pub const _SC_MEMORY_PROTECTION: c_int = 19; +pub const _SC_MESSAGE_PASSING: c_int = 20; +pub const _SC_SEMAPHORES: c_int = 21; +pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 22; +pub const _SC_AIO_LISTIO_MAX: c_int = 23; +pub const _SC_AIO_MAX: c_int = 24; +pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 25; +pub const _SC_DELAYTIMER_MAX: c_int = 26; +pub const _SC_MQ_OPEN_MAX: c_int = 27; +pub const _SC_MQ_PRIO_MAX: c_int = 28; +pub const _SC_VERSION: c_int = 29; +pub const _SC_PAGESIZE: c_int = 30; +pub const _SC_PAGE_SIZE: c_int = _SC_PAGESIZE; +pub const _SC_RTSIG_MAX: c_int = 31; +pub const _SC_SEM_NSEMS_MAX: c_int = 32; +pub const _SC_SEM_VALUE_MAX: c_int = 33; +pub const _SC_SIGQUEUE_MAX: c_int = 34; +pub const _SC_TIMER_MAX: c_int = 35; +pub const _SC_BC_BASE_MAX: c_int = 36; +pub const _SC_BC_DIM_MAX: c_int = 37; +pub const _SC_BC_SCALE_MAX: c_int = 38; +pub const _SC_BC_STRING_MAX: c_int = 39; +pub const _SC_COLL_WEIGHTS_MAX: c_int = 40; +pub const _SC_EXPR_NEST_MAX: c_int = 42; +pub const _SC_LINE_MAX: c_int = 43; +pub const _SC_RE_DUP_MAX: c_int = 44; +pub const _SC_2_VERSION: c_int = 46; +pub const _SC_2_C_BIND: c_int = 47; +pub const _SC_2_C_DEV: c_int = 48; +pub const _SC_2_FORT_DEV: c_int = 49; +pub const _SC_2_FORT_RUN: c_int = 50; +pub const _SC_2_SW_DEV: c_int = 51; +pub const _SC_2_LOCALEDEF: c_int = 52; +pub const _SC_UIO_MAXIOV: c_int = 60; +pub const _SC_IOV_MAX: c_int = 60; +pub const _SC_THREADS: c_int = 67; +pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 68; +pub const _SC_GETGR_R_SIZE_MAX: c_int = 69; +pub const _SC_GETPW_R_SIZE_MAX: c_int = 70; +pub const _SC_LOGIN_NAME_MAX: c_int = 71; +pub const _SC_TTY_NAME_MAX: c_int = 72; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 73; +pub const _SC_THREAD_KEYS_MAX: c_int = 74; +pub const _SC_THREAD_STACK_MIN: c_int = 75; +pub const _SC_THREAD_THREADS_MAX: c_int = 76; +pub const _SC_THREAD_ATTR_STACKADDR: c_int = 77; +pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 78; +pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 79; +pub const _SC_THREAD_PRIO_INHERIT: c_int = 80; +pub const _SC_THREAD_PRIO_PROTECT: c_int = 81; +pub const _SC_THREAD_PROCESS_SHARED: c_int = 82; +pub const _SC_NPROCESSORS_CONF: c_int = 83; +pub const _SC_NPROCESSORS_ONLN: c_int = 84; +pub const _SC_PHYS_PAGES: c_int = 85; +pub const _SC_AVPHYS_PAGES: c_int = 86; +pub const _SC_ATEXIT_MAX: c_int = 87; +pub const _SC_PASS_MAX: c_int = 88; +pub const _SC_XOPEN_VERSION: c_int = 89; +pub const _SC_XOPEN_XCU_VERSION: c_int = 90; +pub const _SC_XOPEN_UNIX: c_int = 91; +pub const _SC_XOPEN_CRYPT: c_int = 92; +pub const _SC_XOPEN_ENH_I18N: c_int = 93; +pub const _SC_XOPEN_SHM: c_int = 94; +pub const _SC_2_CHAR_TERM: c_int = 95; +pub const _SC_2_UPE: c_int = 97; +pub const _SC_XOPEN_XPG2: c_int = 98; +pub const _SC_XOPEN_XPG3: c_int = 99; +pub const _SC_XOPEN_XPG4: c_int = 100; +pub const _SC_NZERO: c_int = 109; +pub const _SC_XBS5_ILP32_OFF32: c_int = 125; +pub const _SC_XBS5_ILP32_OFFBIG: c_int = 126; +pub const _SC_XBS5_LP64_OFF64: c_int = 127; +pub const _SC_XBS5_LPBIG_OFFBIG: c_int = 128; +pub const _SC_XOPEN_LEGACY: c_int = 129; +pub const _SC_XOPEN_REALTIME: c_int = 130; +pub const _SC_XOPEN_REALTIME_THREADS: c_int = 131; +pub const _SC_ADVISORY_INFO: c_int = 132; +pub const _SC_BARRIERS: c_int = 133; +pub const _SC_CLOCK_SELECTION: c_int = 137; +pub const _SC_CPUTIME: c_int = 138; +pub const _SC_THREAD_CPUTIME: c_int = 139; +pub const _SC_MONOTONIC_CLOCK: c_int = 149; +pub const _SC_READER_WRITER_LOCKS: c_int = 153; +pub const _SC_SPIN_LOCKS: c_int = 154; +pub const _SC_REGEXP: c_int = 155; +pub const _SC_SHELL: c_int = 157; +pub const _SC_SPAWN: c_int = 159; +pub const _SC_SPORADIC_SERVER: c_int = 160; +pub const _SC_THREAD_SPORADIC_SERVER: c_int = 161; +pub const _SC_TIMEOUTS: c_int = 164; +pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 165; +pub const _SC_2_PBS: c_int = 168; +pub const _SC_2_PBS_ACCOUNTING: c_int = 169; +pub const _SC_2_PBS_LOCATE: c_int = 170; +pub const _SC_2_PBS_MESSAGE: c_int = 171; +pub const _SC_2_PBS_TRACK: c_int = 172; +pub const _SC_SYMLOOP_MAX: c_int = 173; +pub const _SC_STREAMS: c_int = 174; +pub const _SC_2_PBS_CHECKPOINT: c_int = 175; +pub const _SC_V6_ILP32_OFF32: c_int = 176; +pub const _SC_V6_ILP32_OFFBIG: c_int = 177; +pub const _SC_V6_LP64_OFF64: c_int = 178; +pub const _SC_V6_LPBIG_OFFBIG: c_int = 179; +pub const _SC_HOST_NAME_MAX: c_int = 180; +pub const _SC_TRACE: c_int = 181; +pub const _SC_TRACE_EVENT_FILTER: c_int = 182; +pub const _SC_TRACE_INHERIT: c_int = 183; +pub const _SC_TRACE_LOG: c_int = 184; +pub const _SC_IPV6: c_int = 235; +pub const _SC_RAW_SOCKETS: c_int = 236; +pub const _SC_V7_ILP32_OFF32: c_int = 237; +pub const _SC_V7_ILP32_OFFBIG: c_int = 238; +pub const _SC_V7_LP64_OFF64: c_int = 239; +pub const _SC_V7_LPBIG_OFFBIG: c_int = 240; +pub const _SC_SS_REPL_MAX: c_int = 241; +pub const _SC_TRACE_EVENT_NAME_MAX: c_int = 242; +pub const _SC_TRACE_NAME_MAX: c_int = 243; +pub const _SC_TRACE_SYS_MAX: c_int = 244; +pub const _SC_TRACE_USER_EVENT_MAX: c_int = 245; +pub const _SC_XOPEN_STREAMS: c_int = 246; +pub const _SC_THREAD_ROBUST_PRIO_INHERIT: c_int = 247; +pub const _SC_THREAD_ROBUST_PRIO_PROTECT: c_int = 248; + +pub const RLIM_SAVED_MAX: crate::rlim_t = RLIM_INFINITY; +pub const RLIM_SAVED_CUR: crate::rlim_t = RLIM_INFINITY; + +pub const GLOB_ERR: c_int = 1 << 0; +pub const GLOB_MARK: c_int = 1 << 1; +pub const GLOB_NOSORT: c_int = 1 << 2; +pub const GLOB_DOOFFS: c_int = 1 << 3; +pub const GLOB_NOCHECK: c_int = 1 << 4; +pub const GLOB_APPEND: c_int = 1 << 5; +pub const GLOB_NOESCAPE: c_int = 1 << 6; + +pub const GLOB_NOSPACE: c_int = 1; +pub const GLOB_ABORTED: c_int = 2; +pub const GLOB_NOMATCH: c_int = 3; + +pub const POSIX_MADV_NORMAL: c_int = 0; +pub const POSIX_MADV_RANDOM: c_int = 1; +pub const POSIX_MADV_SEQUENTIAL: c_int = 2; +pub const POSIX_MADV_WILLNEED: c_int = 3; + +pub const S_IEXEC: mode_t = 0o0100; +pub const S_IWRITE: mode_t = 0o0200; +pub const S_IREAD: mode_t = 0o0400; + +pub const F_LOCK: c_int = 1; +pub const F_TEST: c_int = 3; +pub const F_TLOCK: c_int = 2; +pub const F_ULOCK: c_int = 0; + +pub const IFF_LOWER_UP: c_int = 0x10000; +pub const IFF_DORMANT: c_int = 0x20000; +pub const IFF_ECHO: c_int = 0x40000; + +pub const ST_RDONLY: c_ulong = 1; +pub const ST_NOSUID: c_ulong = 2; +pub const ST_NODEV: c_ulong = 4; +pub const ST_NOEXEC: c_ulong = 8; +pub const ST_SYNCHRONOUS: c_ulong = 16; +pub const ST_MANDLOCK: c_ulong = 64; +pub const ST_WRITE: c_ulong = 128; +pub const ST_APPEND: c_ulong = 256; +pub const ST_IMMUTABLE: c_ulong = 512; +pub const ST_NOATIME: c_ulong = 1024; +pub const ST_NODIRATIME: c_ulong = 2048; + +pub const RTLD_NEXT: *mut c_void = -1i64 as *mut c_void; +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); +pub const RTLD_NODELETE: c_int = 0x1000; +pub const RTLD_NOW: c_int = 0x2; + +pub const TCP_MD5SIG: c_int = 14; + +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + size: [0; __SIZEOF_PTHREAD_MUTEX_T], +}; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + size: [0; __SIZEOF_PTHREAD_COND_T], +}; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + size: [0; __SIZEOF_PTHREAD_RWLOCK_T], +}; +pub const PTHREAD_MUTEX_NORMAL: c_int = 0; +pub const PTHREAD_MUTEX_RECURSIVE: c_int = 1; +pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 2; +pub const PTHREAD_MUTEX_DEFAULT: c_int = PTHREAD_MUTEX_NORMAL; +pub const PTHREAD_PROCESS_PRIVATE: c_int = 0; +pub const PTHREAD_PROCESS_SHARED: c_int = 1; +pub const __SIZEOF_PTHREAD_COND_T: usize = 48; + +pub const RENAME_NOREPLACE: c_int = 1; +pub const RENAME_EXCHANGE: c_int = 2; +pub const RENAME_WHITEOUT: c_int = 4; + +pub const SCHED_OTHER: c_int = 0; +pub const SCHED_FIFO: c_int = 1; +pub const SCHED_RR: c_int = 2; +pub const SCHED_BATCH: c_int = 3; +pub const SCHED_IDLE: c_int = 5; + +// netinet/in.h +// NOTE: These are in addition to the constants defined in src/unix/mod.rs + +// IPPROTO_IP defined in src/unix/mod.rs +/// Hop-by-hop option header +pub const IPPROTO_HOPOPTS: c_int = 0; +// IPPROTO_ICMP defined in src/unix/mod.rs +/// group mgmt protocol +pub const IPPROTO_IGMP: c_int = 2; +/// for compatibility +pub const IPPROTO_IPIP: c_int = 4; +// IPPROTO_TCP defined in src/unix/mod.rs +/// exterior gateway protocol +pub const IPPROTO_EGP: c_int = 8; +/// pup +pub const IPPROTO_PUP: c_int = 12; +// IPPROTO_UDP defined in src/unix/mod.rs +/// xns idp +pub const IPPROTO_IDP: c_int = 22; +/// tp-4 w/ class negotiation +pub const IPPROTO_TP: c_int = 29; +/// DCCP +pub const IPPROTO_DCCP: c_int = 33; +// IPPROTO_IPV6 defined in src/unix/mod.rs +/// IP6 routing header +pub const IPPROTO_ROUTING: c_int = 43; +/// IP6 fragmentation header +pub const IPPROTO_FRAGMENT: c_int = 44; +/// resource reservation +pub const IPPROTO_RSVP: c_int = 46; +/// General Routing Encap. +pub const IPPROTO_GRE: c_int = 47; +/// IP6 Encap Sec. Payload +pub const IPPROTO_ESP: c_int = 50; +/// IP6 Auth Header +pub const IPPROTO_AH: c_int = 51; +// IPPROTO_ICMPV6 defined in src/unix/mod.rs +/// IP6 no next header +pub const IPPROTO_NONE: c_int = 59; +/// IP6 destination option +pub const IPPROTO_DSTOPTS: c_int = 60; +pub const IPPROTO_MTP: c_int = 92; +pub const IPPROTO_BEETPH: c_int = 94; +/// encapsulation header +pub const IPPROTO_ENCAP: c_int = 98; +/// Protocol indep. multicast +pub const IPPROTO_PIM: c_int = 103; +/// IP Payload Comp. Protocol +pub const IPPROTO_COMP: c_int = 108; +/// SCTP +pub const IPPROTO_SCTP: c_int = 132; +pub const IPPROTO_MH: c_int = 135; +pub const IPPROTO_UDPLITE: c_int = 136; +pub const IPPROTO_MPLS: c_int = 137; +/// raw IP packet +pub const IPPROTO_RAW: c_int = 255; +pub const IPPROTO_MAX: c_int = 256; + +pub const AF_IB: c_int = 27; +pub const AF_MPLS: c_int = 28; +pub const AF_NFC: c_int = 39; +pub const AF_VSOCK: c_int = 40; +pub const PF_IB: c_int = AF_IB; +pub const PF_MPLS: c_int = AF_MPLS; +pub const PF_NFC: c_int = AF_NFC; +pub const PF_VSOCK: c_int = AF_VSOCK; + +// System V IPC +pub const IPC_PRIVATE: crate::key_t = 0; + +pub const IPC_CREAT: c_int = 0o1000; +pub const IPC_EXCL: c_int = 0o2000; +pub const IPC_NOWAIT: c_int = 0o4000; + +pub const IPC_RMID: c_int = 0; +pub const IPC_SET: c_int = 1; +pub const IPC_STAT: c_int = 2; +pub const IPC_INFO: c_int = 3; +pub const MSG_STAT: c_int = 11; +pub const MSG_INFO: c_int = 12; + +pub const MSG_NOERROR: c_int = 0o10000; +pub const MSG_EXCEPT: c_int = 0o20000; +pub const MSG_COPY: c_int = 0o40000; + +pub const SHM_R: c_int = 0o400; +pub const SHM_W: c_int = 0o200; + +pub const SHM_RDONLY: c_int = 0o10000; +pub const SHM_RND: c_int = 0o20000; +pub const SHM_REMAP: c_int = 0o40000; +pub const SHM_EXEC: c_int = 0o100000; + +pub const SHM_LOCK: c_int = 11; +pub const SHM_UNLOCK: c_int = 12; + +pub const SHM_HUGETLB: c_int = 0o4000; +pub const SHM_NORESERVE: c_int = 0o10000; + +pub const EPOLLRDHUP: c_int = 0x2000; +pub const EPOLLEXCLUSIVE: c_int = 0x10000000; +pub const EPOLLONESHOT: c_int = 0x40000000; + +pub const QFMT_VFS_OLD: c_int = 1; +pub const QFMT_VFS_V0: c_int = 2; +pub const QFMT_VFS_V1: c_int = 4; + +pub const EFD_SEMAPHORE: c_int = 0x1; + +pub const LOG_NFACILITIES: c_int = 24; + +pub const SEM_FAILED: *mut crate::sem_t = ptr::null_mut(); + +pub const RB_AUTOBOOT: c_int = 0x01234567u32 as i32; +pub const RB_HALT_SYSTEM: c_int = 0xcdef0123u32 as i32; +pub const RB_ENABLE_CAD: c_int = 0x89abcdefu32 as i32; +pub const RB_DISABLE_CAD: c_int = 0x00000000u32 as i32; +pub const RB_POWER_OFF: c_int = 0x4321fedcu32 as i32; +pub const RB_SW_SUSPEND: c_int = 0xd000fce2u32 as i32; +pub const RB_KEXEC: c_int = 0x45584543u32 as i32; + +pub const AI_PASSIVE: c_int = 0x0001; +pub const AI_CANONNAME: c_int = 0x0002; +pub const AI_NUMERICHOST: c_int = 0x0004; +pub const AI_V4MAPPED: c_int = 0x0008; +pub const AI_ALL: c_int = 0x0010; +pub const AI_ADDRCONFIG: c_int = 0x0020; + +pub const AI_NUMERICSERV: c_int = 0x0400; + +pub const EAI_BADFLAGS: c_int = -1; +pub const EAI_NONAME: c_int = -2; +pub const EAI_AGAIN: c_int = -3; +pub const EAI_FAIL: c_int = -4; +pub const EAI_FAMILY: c_int = -6; +pub const EAI_SOCKTYPE: c_int = -7; +pub const EAI_SERVICE: c_int = -8; +pub const EAI_MEMORY: c_int = -10; +pub const EAI_OVERFLOW: c_int = -12; + +pub const NI_NUMERICHOST: c_int = 1; +pub const NI_NUMERICSERV: c_int = 2; +pub const NI_NOFQDN: c_int = 4; +pub const NI_NAMEREQD: c_int = 8; +pub const NI_DGRAM: c_int = 16; + +pub const SYNC_FILE_RANGE_WAIT_BEFORE: c_uint = 1; +pub const SYNC_FILE_RANGE_WRITE: c_uint = 2; +pub const SYNC_FILE_RANGE_WAIT_AFTER: c_uint = 4; + +pub const EAI_SYSTEM: c_int = -11; + +pub const AIO_CANCELED: c_int = 0; +pub const AIO_NOTCANCELED: c_int = 1; +pub const AIO_ALLDONE: c_int = 2; +pub const LIO_READ: c_int = 0; +pub const LIO_WRITE: c_int = 1; +pub const LIO_NOP: c_int = 2; +pub const LIO_WAIT: c_int = 0; +pub const LIO_NOWAIT: c_int = 1; + +pub const MREMAP_MAYMOVE: c_int = 1; +pub const MREMAP_FIXED: c_int = 2; + +pub const PR_SET_PDEATHSIG: c_int = 1; +pub const PR_GET_PDEATHSIG: c_int = 2; + +pub const PR_GET_DUMPABLE: c_int = 3; +pub const PR_SET_DUMPABLE: c_int = 4; + +pub const PR_GET_UNALIGN: c_int = 5; +pub const PR_SET_UNALIGN: c_int = 6; +pub const PR_UNALIGN_NOPRINT: c_int = 1; +pub const PR_UNALIGN_SIGBUS: c_int = 2; + +pub const PR_GET_KEEPCAPS: c_int = 7; +pub const PR_SET_KEEPCAPS: c_int = 8; + +pub const PR_GET_FPEMU: c_int = 9; +pub const PR_SET_FPEMU: c_int = 10; +pub const PR_FPEMU_NOPRINT: c_int = 1; +pub const PR_FPEMU_SIGFPE: c_int = 2; + +pub const PR_GET_FPEXC: c_int = 11; +pub const PR_SET_FPEXC: c_int = 12; +pub const PR_FP_EXC_SW_ENABLE: c_int = 0x80; +pub const PR_FP_EXC_DIV: c_int = 0x010000; +pub const PR_FP_EXC_OVF: c_int = 0x020000; +pub const PR_FP_EXC_UND: c_int = 0x040000; +pub const PR_FP_EXC_RES: c_int = 0x080000; +pub const PR_FP_EXC_INV: c_int = 0x100000; +pub const PR_FP_EXC_DISABLED: c_int = 0; +pub const PR_FP_EXC_NONRECOV: c_int = 1; +pub const PR_FP_EXC_ASYNC: c_int = 2; +pub const PR_FP_EXC_PRECISE: c_int = 3; + +pub const PR_GET_TIMING: c_int = 13; +pub const PR_SET_TIMING: c_int = 14; +pub const PR_TIMING_STATISTICAL: c_int = 0; +pub const PR_TIMING_TIMESTAMP: c_int = 1; + +pub const PR_SET_NAME: c_int = 15; +pub const PR_GET_NAME: c_int = 16; + +pub const PR_GET_ENDIAN: c_int = 19; +pub const PR_SET_ENDIAN: c_int = 20; +pub const PR_ENDIAN_BIG: c_int = 0; +pub const PR_ENDIAN_LITTLE: c_int = 1; +pub const PR_ENDIAN_PPC_LITTLE: c_int = 2; + +pub const PR_GET_SECCOMP: c_int = 21; +pub const PR_SET_SECCOMP: c_int = 22; + +pub const PR_CAPBSET_READ: c_int = 23; +pub const PR_CAPBSET_DROP: c_int = 24; + +pub const PR_GET_TSC: c_int = 25; +pub const PR_SET_TSC: c_int = 26; +pub const PR_TSC_ENABLE: c_int = 1; +pub const PR_TSC_SIGSEGV: c_int = 2; + +pub const PR_GET_SECUREBITS: c_int = 27; +pub const PR_SET_SECUREBITS: c_int = 28; + +pub const PR_SET_TIMERSLACK: c_int = 29; +pub const PR_GET_TIMERSLACK: c_int = 30; + +pub const PR_TASK_PERF_EVENTS_DISABLE: c_int = 31; +pub const PR_TASK_PERF_EVENTS_ENABLE: c_int = 32; + +pub const PR_MCE_KILL: c_int = 33; +pub const PR_MCE_KILL_CLEAR: c_int = 0; +pub const PR_MCE_KILL_SET: c_int = 1; + +pub const PR_MCE_KILL_LATE: c_int = 0; +pub const PR_MCE_KILL_EARLY: c_int = 1; +pub const PR_MCE_KILL_DEFAULT: c_int = 2; + +pub const PR_MCE_KILL_GET: c_int = 34; + +pub const PR_SET_MM: c_int = 35; +pub const PR_SET_MM_START_CODE: c_int = 1; +pub const PR_SET_MM_END_CODE: c_int = 2; +pub const PR_SET_MM_START_DATA: c_int = 3; +pub const PR_SET_MM_END_DATA: c_int = 4; +pub const PR_SET_MM_START_STACK: c_int = 5; +pub const PR_SET_MM_START_BRK: c_int = 6; +pub const PR_SET_MM_BRK: c_int = 7; +pub const PR_SET_MM_ARG_START: c_int = 8; +pub const PR_SET_MM_ARG_END: c_int = 9; +pub const PR_SET_MM_ENV_START: c_int = 10; +pub const PR_SET_MM_ENV_END: c_int = 11; +pub const PR_SET_MM_AUXV: c_int = 12; +pub const PR_SET_MM_EXE_FILE: c_int = 13; +pub const PR_SET_MM_MAP: c_int = 14; +pub const PR_SET_MM_MAP_SIZE: c_int = 15; + +pub const PR_SET_PTRACER: c_int = 0x59616d61; +pub const PR_SET_PTRACER_ANY: c_ulong = 0xffffffffffffffff; + +pub const PR_SET_CHILD_SUBREAPER: c_int = 36; +pub const PR_GET_CHILD_SUBREAPER: c_int = 37; + +pub const PR_SET_NO_NEW_PRIVS: c_int = 38; +pub const PR_GET_NO_NEW_PRIVS: c_int = 39; + +pub const PR_GET_TID_ADDRESS: c_int = 40; + +pub const PR_SET_THP_DISABLE: c_int = 41; +pub const PR_GET_THP_DISABLE: c_int = 42; + +pub const PR_MPX_ENABLE_MANAGEMENT: c_int = 43; +pub const PR_MPX_DISABLE_MANAGEMENT: c_int = 44; + +pub const PR_SET_FP_MODE: c_int = 45; +pub const PR_GET_FP_MODE: c_int = 46; +pub const PR_FP_MODE_FR: c_int = 1 << 0; +pub const PR_FP_MODE_FRE: c_int = 1 << 1; + +pub const PR_CAP_AMBIENT: c_int = 47; +pub const PR_CAP_AMBIENT_IS_SET: c_int = 1; +pub const PR_CAP_AMBIENT_RAISE: c_int = 2; +pub const PR_CAP_AMBIENT_LOWER: c_int = 3; +pub const PR_CAP_AMBIENT_CLEAR_ALL: c_int = 4; + +pub const ITIMER_REAL: c_int = 0; +pub const ITIMER_VIRTUAL: c_int = 1; +pub const ITIMER_PROF: c_int = 2; + +pub const TFD_CLOEXEC: c_int = O_CLOEXEC; +pub const TFD_NONBLOCK: c_int = O_NONBLOCK; +pub const TFD_TIMER_ABSTIME: c_int = 1; + +pub const XATTR_CREATE: c_int = 0x1; +pub const XATTR_REPLACE: c_int = 0x2; + +pub const _POSIX_VDISABLE: crate::cc_t = 0; + +pub const FALLOC_FL_KEEP_SIZE: c_int = 0x01; +pub const FALLOC_FL_PUNCH_HOLE: c_int = 0x02; +pub const FALLOC_FL_COLLAPSE_RANGE: c_int = 0x08; +pub const FALLOC_FL_ZERO_RANGE: c_int = 0x10; +pub const FALLOC_FL_INSERT_RANGE: c_int = 0x20; +pub const FALLOC_FL_UNSHARE_RANGE: c_int = 0x40; + +// On Linux, libc doesn't define this constant, libattr does instead. +// We still define it for Linux as it's defined by libc on other platforms, +// and it's mentioned in the man pages for getxattr and setxattr. +pub const ENOATTR: c_int = crate::ENODATA; + +pub const SO_ORIGINAL_DST: c_int = 80; +pub const IUTF8: crate::tcflag_t = 0x00004000; +pub const CMSPAR: crate::tcflag_t = 0o10000000000; + +pub const MFD_CLOEXEC: c_uint = 0x0001; +pub const MFD_ALLOW_SEALING: c_uint = 0x0002; + +// these are used in the p_type field of Elf32_Phdr and Elf64_Phdr, which has +// the type Elf32Word and Elf64Word respectively. Luckily, both of those are u32 +// so we can use that type here to avoid having to cast. +pub const PT_NULL: u32 = 0; +pub const PT_LOAD: u32 = 1; +pub const PT_DYNAMIC: u32 = 2; +pub const PT_INTERP: u32 = 3; +pub const PT_NOTE: u32 = 4; +pub const PT_SHLIB: u32 = 5; +pub const PT_PHDR: u32 = 6; +pub const PT_TLS: u32 = 7; +pub const PT_NUM: u32 = 8; +pub const PT_LOOS: u32 = 0x60000000; +pub const PT_GNU_EH_FRAME: u32 = 0x6474e550; +pub const PT_GNU_STACK: u32 = 0x6474e551; +pub const PT_GNU_RELRO: u32 = 0x6474e552; + +// Ethernet protocol IDs. +pub const ETH_P_LOOP: c_int = 0x0060; +pub const ETH_P_PUP: c_int = 0x0200; +pub const ETH_P_PUPAT: c_int = 0x0201; +pub const ETH_P_IP: c_int = 0x0800; +pub const ETH_P_X25: c_int = 0x0805; +pub const ETH_P_ARP: c_int = 0x0806; +pub const ETH_P_BPQ: c_int = 0x08FF; +pub const ETH_P_IEEEPUP: c_int = 0x0a00; +pub const ETH_P_IEEEPUPAT: c_int = 0x0a01; +pub const ETH_P_BATMAN: c_int = 0x4305; +pub const ETH_P_DEC: c_int = 0x6000; +pub const ETH_P_DNA_DL: c_int = 0x6001; +pub const ETH_P_DNA_RC: c_int = 0x6002; +pub const ETH_P_DNA_RT: c_int = 0x6003; +pub const ETH_P_LAT: c_int = 0x6004; +pub const ETH_P_DIAG: c_int = 0x6005; +pub const ETH_P_CUST: c_int = 0x6006; +pub const ETH_P_SCA: c_int = 0x6007; +pub const ETH_P_TEB: c_int = 0x6558; +pub const ETH_P_RARP: c_int = 0x8035; +pub const ETH_P_ATALK: c_int = 0x809B; +pub const ETH_P_AARP: c_int = 0x80F3; +pub const ETH_P_8021Q: c_int = 0x8100; +pub const ETH_P_IPX: c_int = 0x8137; +pub const ETH_P_IPV6: c_int = 0x86DD; +pub const ETH_P_PAUSE: c_int = 0x8808; +pub const ETH_P_SLOW: c_int = 0x8809; +pub const ETH_P_WCCP: c_int = 0x883E; +pub const ETH_P_MPLS_UC: c_int = 0x8847; +pub const ETH_P_MPLS_MC: c_int = 0x8848; +pub const ETH_P_ATMMPOA: c_int = 0x884c; +pub const ETH_P_PPP_DISC: c_int = 0x8863; +pub const ETH_P_PPP_SES: c_int = 0x8864; +pub const ETH_P_LINK_CTL: c_int = 0x886c; +pub const ETH_P_ATMFATE: c_int = 0x8884; +pub const ETH_P_PAE: c_int = 0x888E; +pub const ETH_P_AOE: c_int = 0x88A2; +pub const ETH_P_8021AD: c_int = 0x88A8; +pub const ETH_P_802_EX1: c_int = 0x88B5; +pub const ETH_P_TIPC: c_int = 0x88CA; +pub const ETH_P_8021AH: c_int = 0x88E7; +pub const ETH_P_MVRP: c_int = 0x88F5; +pub const ETH_P_1588: c_int = 0x88F7; +pub const ETH_P_PRP: c_int = 0x88FB; +pub const ETH_P_FCOE: c_int = 0x8906; +pub const ETH_P_TDLS: c_int = 0x890D; +pub const ETH_P_FIP: c_int = 0x8914; +pub const ETH_P_80221: c_int = 0x8917; +pub const ETH_P_LOOPBACK: c_int = 0x9000; +pub const ETH_P_QINQ1: c_int = 0x9100; +pub const ETH_P_QINQ2: c_int = 0x9200; +pub const ETH_P_QINQ3: c_int = 0x9300; +pub const ETH_P_EDSA: c_int = 0xDADA; +pub const ETH_P_AF_IUCV: c_int = 0xFBFB; + +pub const ETH_P_802_3_MIN: c_int = 0x0600; + +pub const ETH_P_802_3: c_int = 0x0001; +pub const ETH_P_AX25: c_int = 0x0002; +pub const ETH_P_ALL: c_int = 0x0003; +pub const ETH_P_802_2: c_int = 0x0004; +pub const ETH_P_SNAP: c_int = 0x0005; +pub const ETH_P_DDCMP: c_int = 0x0006; +pub const ETH_P_WAN_PPP: c_int = 0x0007; +pub const ETH_P_PPP_MP: c_int = 0x0008; +pub const ETH_P_LOCALTALK: c_int = 0x0009; +pub const ETH_P_CAN: c_int = 0x000C; +pub const ETH_P_CANFD: c_int = 0x000D; +pub const ETH_P_PPPTALK: c_int = 0x0010; +pub const ETH_P_TR_802_2: c_int = 0x0011; +pub const ETH_P_MOBITEX: c_int = 0x0015; +pub const ETH_P_CONTROL: c_int = 0x0016; +pub const ETH_P_IRDA: c_int = 0x0017; +pub const ETH_P_ECONET: c_int = 0x0018; +pub const ETH_P_HDLC: c_int = 0x0019; +pub const ETH_P_ARCNET: c_int = 0x001A; +pub const ETH_P_DSA: c_int = 0x001B; +pub const ETH_P_TRAILER: c_int = 0x001C; +pub const ETH_P_PHONET: c_int = 0x00F5; +pub const ETH_P_IEEE802154: c_int = 0x00F6; +pub const ETH_P_CAIF: c_int = 0x00F7; + +pub const SFD_CLOEXEC: c_int = 0x080000; + +pub const NCCS: usize = 32; + +pub const O_TRUNC: c_int = 0x00040000; +pub const O_NOATIME: c_int = 0x00002000; +pub const O_CLOEXEC: c_int = 0x00000100; +pub const O_TMPFILE: c_int = 0x00004000; + +pub const EBFONT: c_int = 59; +pub const ENOSTR: c_int = 60; +pub const ENODATA: c_int = 61; +pub const ETIME: c_int = 62; +pub const ENOSR: c_int = 63; +pub const ENONET: c_int = 64; +pub const ENOPKG: c_int = 65; +pub const EREMOTE: c_int = 66; +pub const ENOLINK: c_int = 67; +pub const EADV: c_int = 68; +pub const ESRMNT: c_int = 69; +pub const ECOMM: c_int = 70; +pub const EPROTO: c_int = 71; +pub const EDOTDOT: c_int = 73; + +pub const SA_NODEFER: c_int = 0x40000000; +pub const SA_RESETHAND: c_int = 0x80000000; +pub const SA_RESTART: c_int = 0x10000000; +pub const SA_NOCLDSTOP: c_int = 0x00000001; + +pub const EPOLL_CLOEXEC: c_int = 0x80000; + +pub const EFD_CLOEXEC: c_int = 0x80000; + +pub const BUFSIZ: c_uint = 1024; +pub const TMP_MAX: c_uint = 10000; +pub const FOPEN_MAX: c_uint = 1000; +pub const O_PATH: c_int = 0x00400000; +pub const O_EXEC: c_int = O_PATH; +pub const O_SEARCH: c_int = O_PATH; +pub const O_ACCMODE: c_int = 03 | O_SEARCH; +pub const O_NDELAY: c_int = O_NONBLOCK; +pub const NI_MAXHOST: crate::socklen_t = 255; +pub const PTHREAD_STACK_MIN: size_t = 2048; +pub const POSIX_FADV_DONTNEED: c_int = 4; +pub const POSIX_FADV_NOREUSE: c_int = 5; + +pub const POSIX_MADV_DONTNEED: c_int = 4; + +pub const RLIM_INFINITY: crate::rlim_t = !0; +pub const RLIMIT_RTTIME: c_int = 15; +#[deprecated(since = "0.2.64", note = "Not stable across OS versions")] +pub const RLIMIT_NLIMITS: c_int = 16; +#[allow(deprecated)] +#[deprecated(since = "0.2.64", note = "Not stable across OS versions")] +pub const RLIM_NLIMITS: c_int = RLIMIT_NLIMITS; + +pub const MAP_ANONYMOUS: c_int = MAP_ANON; + +pub const SOCK_DCCP: c_int = 6; +pub const SOCK_PACKET: c_int = 10; + +pub const TCP_COOKIE_TRANSACTIONS: c_int = 15; +pub const TCP_THIN_LINEAR_TIMEOUTS: c_int = 16; +pub const TCP_THIN_DUPACK: c_int = 17; +pub const TCP_USER_TIMEOUT: c_int = 18; +pub const TCP_REPAIR: c_int = 19; +pub const TCP_REPAIR_QUEUE: c_int = 20; +pub const TCP_QUEUE_SEQ: c_int = 21; +pub const TCP_REPAIR_OPTIONS: c_int = 22; +pub const TCP_FASTOPEN: c_int = 23; +pub const TCP_TIMESTAMP: c_int = 24; + +pub const SIGUNUSED: c_int = crate::SIGSYS; + +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; + +pub const CPU_SETSIZE: c_int = 128; + +pub const PTRACE_TRACEME: c_int = 0; +pub const PTRACE_PEEKTEXT: c_int = 1; +pub const PTRACE_PEEKDATA: c_int = 2; +pub const PTRACE_PEEKUSER: c_int = 3; +pub const PTRACE_POKETEXT: c_int = 4; +pub const PTRACE_POKEDATA: c_int = 5; +pub const PTRACE_POKEUSER: c_int = 6; +pub const PTRACE_CONT: c_int = 7; +pub const PTRACE_KILL: c_int = 8; +pub const PTRACE_SINGLESTEP: c_int = 9; +pub const PTRACE_GETREGS: c_int = 12; +pub const PTRACE_SETREGS: c_int = 13; +pub const PTRACE_GETFPREGS: c_int = 14; +pub const PTRACE_SETFPREGS: c_int = 15; +pub const PTRACE_ATTACH: c_int = 16; +pub const PTRACE_DETACH: c_int = 17; +pub const PTRACE_GETFPXREGS: c_int = 18; +pub const PTRACE_SETFPXREGS: c_int = 19; +pub const PTRACE_SYSCALL: c_int = 24; +pub const PTRACE_SETOPTIONS: c_int = 0x4200; +pub const PTRACE_GETEVENTMSG: c_int = 0x4201; +pub const PTRACE_GETSIGINFO: c_int = 0x4202; +pub const PTRACE_SETSIGINFO: c_int = 0x4203; +pub const PTRACE_GETREGSET: c_int = 0x4204; +pub const PTRACE_SETREGSET: c_int = 0x4205; +pub const PTRACE_SEIZE: c_int = 0x4206; +pub const PTRACE_INTERRUPT: c_int = 0x4207; +pub const PTRACE_LISTEN: c_int = 0x4208; +pub const PTRACE_PEEKSIGINFO: c_int = 0x4209; + +pub const EPOLLWAKEUP: c_int = 0x20000000; + +pub const EFD_NONBLOCK: c_int = crate::O_NONBLOCK; + +pub const SFD_NONBLOCK: c_int = crate::O_NONBLOCK; + +pub const TCSANOW: c_int = 0; +pub const TCSADRAIN: c_int = 1; +pub const TCSAFLUSH: c_int = 2; + +pub const TIOCINQ: c_int = crate::FIONREAD; + +pub const RTLD_GLOBAL: c_int = 0x100; +pub const RTLD_NOLOAD: c_int = 0x4; + +pub const MCL_CURRENT: c_int = 0x0001; +pub const MCL_FUTURE: c_int = 0x0002; + +pub const CBAUD: crate::tcflag_t = 0o0010017; +pub const TAB1: c_int = 0x00000800; +pub const TAB2: c_int = 0x00001000; +pub const TAB3: c_int = 0x00001800; +pub const CR1: c_int = 0x00000200; +pub const CR2: c_int = 0x00000400; +pub const CR3: c_int = 0x00000600; +pub const FF1: c_int = 0x00008000; +pub const BS1: c_int = 0x00002000; +pub const VT1: c_int = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: crate::tcflag_t = 0x00000400; +pub const IXOFF: crate::tcflag_t = 0x00001000; +pub const ONLCR: crate::tcflag_t = 0x4; +pub const CSIZE: crate::tcflag_t = 0x00000030; +pub const CS6: crate::tcflag_t = 0x00000010; +pub const CS7: crate::tcflag_t = 0x00000020; +pub const CS8: crate::tcflag_t = 0x00000030; +pub const CSTOPB: crate::tcflag_t = 0x00000040; +pub const CREAD: crate::tcflag_t = 0x00000080; +pub const PARENB: crate::tcflag_t = 0x00000100; +pub const PARODD: crate::tcflag_t = 0x00000200; +pub const HUPCL: crate::tcflag_t = 0x00000400; +pub const CLOCAL: crate::tcflag_t = 0x00000800; +pub const ECHOKE: crate::tcflag_t = 0x00000800; +pub const ECHOE: crate::tcflag_t = 0x00000010; +pub const ECHOK: crate::tcflag_t = 0x00000020; +pub const ECHONL: crate::tcflag_t = 0x00000040; +pub const ECHOPRT: crate::tcflag_t = 0x00000400; +pub const ECHOCTL: crate::tcflag_t = 0x00000200; +pub const ISIG: crate::tcflag_t = 0x00000001; +pub const ICANON: crate::tcflag_t = 0x00000002; +pub const PENDIN: crate::tcflag_t = 0x00004000; +pub const NOFLSH: crate::tcflag_t = 0x00000080; +pub const CIBAUD: crate::tcflag_t = 0o02003600000; +pub const CBAUDEX: crate::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: crate::tcflag_t = 0o000002; +pub const NLDLY: crate::tcflag_t = 0o000400; +pub const CRDLY: crate::tcflag_t = 0o003000; +pub const TABDLY: crate::tcflag_t = 0o014000; +pub const BSDLY: crate::tcflag_t = 0o020000; +pub const FFDLY: crate::tcflag_t = 0o100000; +pub const VTDLY: crate::tcflag_t = 0o040000; +pub const XTABS: crate::tcflag_t = 0o014000; + +pub const B0: crate::speed_t = 0o000000; +pub const B50: crate::speed_t = 0o000001; +pub const B75: crate::speed_t = 0o000002; +pub const B110: crate::speed_t = 0o000003; +pub const B134: crate::speed_t = 0o000004; +pub const B150: crate::speed_t = 0o000005; +pub const B200: crate::speed_t = 0o000006; +pub const B300: crate::speed_t = 0o000007; +pub const B600: crate::speed_t = 0o000010; +pub const B1200: crate::speed_t = 0o000011; +pub const B1800: crate::speed_t = 0o000012; +pub const B2400: crate::speed_t = 0o000013; +pub const B4800: crate::speed_t = 0o000014; +pub const B9600: crate::speed_t = 0o000015; +pub const B19200: crate::speed_t = 0o000016; +pub const B38400: crate::speed_t = 0o000017; +pub const EXTA: crate::speed_t = B19200; +pub const EXTB: crate::speed_t = B38400; +pub const B57600: crate::speed_t = 0o010001; +pub const B115200: crate::speed_t = 0o010002; +pub const B230400: crate::speed_t = 0o010003; +pub const B460800: crate::speed_t = 0o010004; +pub const B500000: crate::speed_t = 0o010005; +pub const B576000: crate::speed_t = 0o010006; +pub const B921600: crate::speed_t = 0o010007; +pub const B1000000: crate::speed_t = 0o010010; +pub const B1152000: crate::speed_t = 0o010011; +pub const B1500000: crate::speed_t = 0o010012; +pub const B2000000: crate::speed_t = 0o010013; +pub const B2500000: crate::speed_t = 0o010014; +pub const B3000000: crate::speed_t = 0o010015; +pub const B3500000: crate::speed_t = 0o010016; +pub const B4000000: crate::speed_t = 0o010017; + +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; + +pub const O_ASYNC: c_int = 0x00000400; + +pub const FIOCLEX: c_int = 0x5451; +pub const FIONBIO: c_int = 0x5421; + +pub const RLIMIT_RSS: c_int = 5; +pub const RLIMIT_NOFILE: c_int = 7; +pub const RLIMIT_AS: c_int = 9; +pub const RLIMIT_NPROC: c_int = 6; +pub const RLIMIT_MEMLOCK: c_int = 8; + +pub const O_APPEND: c_int = 0x00100000; +pub const O_CREAT: c_int = 0x00010000; +pub const O_EXCL: c_int = 0x00020000; +pub const O_NOCTTY: c_int = 0x00000200; +pub const O_NONBLOCK: c_int = 0x00000010; +pub const O_SYNC: c_int = 0x00000040 | O_DSYNC; +pub const O_RSYNC: c_int = O_SYNC; +pub const O_DSYNC: c_int = 0x00000020; + +pub const SOCK_CLOEXEC: c_int = 0o2000000; +pub const SOCK_NONBLOCK: c_int = 0o4000; + +pub const MAP_ANON: c_int = 0x0020; +pub const MAP_GROWSDOWN: c_int = 0x0100; +pub const MAP_DENYWRITE: c_int = 0x0800; +pub const MAP_EXECUTABLE: c_int = 0x01000; +pub const MAP_LOCKED: c_int = 0x02000; +pub const MAP_NORESERVE: c_int = 0x04000; +pub const MAP_POPULATE: c_int = 0x08000; +pub const MAP_NONBLOCK: c_int = 0x010000; +pub const MAP_STACK: c_int = 0x020000; + +pub const SOCK_STREAM: c_int = 1; +pub const SOCK_DGRAM: c_int = 2; +pub const SOCK_SEQPACKET: c_int = 5; + +pub const SOL_SOCKET: c_int = 1; + +pub const EDEADLK: c_int = 35; +pub const ENAMETOOLONG: c_int = 36; +pub const ENOLCK: c_int = 37; +pub const ENOSYS: c_int = 38; +pub const ENOTEMPTY: c_int = 39; +pub const ELOOP: c_int = 40; +pub const ENOMSG: c_int = 42; +pub const EIDRM: c_int = 43; +pub const ECHRNG: c_int = 44; +pub const EL2NSYNC: c_int = 45; +pub const EL3HLT: c_int = 46; +pub const EL3RST: c_int = 47; +pub const ELNRNG: c_int = 48; +pub const EUNATCH: c_int = 49; +pub const ENOCSI: c_int = 50; +pub const EL2HLT: c_int = 51; +pub const EBADE: c_int = 52; +pub const EBADR: c_int = 53; +pub const EXFULL: c_int = 54; +pub const ENOANO: c_int = 55; +pub const EBADRQC: c_int = 56; +pub const EBADSLT: c_int = 57; +pub const EDEADLOCK: c_int = EDEADLK; +pub const EMULTIHOP: c_int = 72; +pub const EBADMSG: c_int = 74; +pub const EOVERFLOW: c_int = 75; +pub const ENOTUNIQ: c_int = 76; +pub const EBADFD: c_int = 77; +pub const EREMCHG: c_int = 78; +pub const ELIBACC: c_int = 79; +pub const ELIBBAD: c_int = 80; +pub const ELIBSCN: c_int = 81; +pub const ELIBMAX: c_int = 82; +pub const ELIBEXEC: c_int = 83; +pub const EILSEQ: c_int = 84; +pub const ERESTART: c_int = 85; +pub const ESTRPIPE: c_int = 86; +pub const EUSERS: c_int = 87; +pub const ENOTSOCK: c_int = 88; +pub const EDESTADDRREQ: c_int = 89; +pub const EMSGSIZE: c_int = 90; +pub const EPROTOTYPE: c_int = 91; +pub const ENOPROTOOPT: c_int = 92; +pub const EPROTONOSUPPORT: c_int = 93; +pub const ESOCKTNOSUPPORT: c_int = 94; +pub const EOPNOTSUPP: c_int = 95; +pub const ENOTSUP: c_int = EOPNOTSUPP; +pub const EPFNOSUPPORT: c_int = 96; +pub const EAFNOSUPPORT: c_int = 97; +pub const EADDRINUSE: c_int = 98; +pub const EADDRNOTAVAIL: c_int = 99; +pub const ENETDOWN: c_int = 100; +pub const ENETUNREACH: c_int = 101; +pub const ENETRESET: c_int = 102; +pub const ECONNABORTED: c_int = 103; +pub const ECONNRESET: c_int = 104; +pub const ENOBUFS: c_int = 105; +pub const EISCONN: c_int = 106; +pub const ENOTCONN: c_int = 107; +pub const ESHUTDOWN: c_int = 108; +pub const ETOOMANYREFS: c_int = 109; +pub const ETIMEDOUT: c_int = 110; +pub const ECONNREFUSED: c_int = 111; +pub const EHOSTDOWN: c_int = 112; +pub const EHOSTUNREACH: c_int = 113; +pub const EALREADY: c_int = 114; +pub const EINPROGRESS: c_int = 115; +pub const ESTALE: c_int = 116; +pub const EUCLEAN: c_int = 117; +pub const ENOTNAM: c_int = 118; +pub const ENAVAIL: c_int = 119; +pub const EISNAM: c_int = 120; +pub const EREMOTEIO: c_int = 121; +pub const EDQUOT: c_int = 122; +pub const ENOMEDIUM: c_int = 123; +pub const EMEDIUMTYPE: c_int = 124; +pub const ECANCELED: c_int = 125; +pub const ENOKEY: c_int = 126; +pub const EKEYEXPIRED: c_int = 127; +pub const EKEYREVOKED: c_int = 128; +pub const EKEYREJECTED: c_int = 129; +pub const EOWNERDEAD: c_int = 130; +pub const ENOTRECOVERABLE: c_int = 131; +pub const ERFKILL: c_int = 132; +pub const EHWPOISON: c_int = 133; + +pub const SO_REUSEADDR: c_int = 2; +pub const SO_TYPE: c_int = 3; +pub const SO_ERROR: c_int = 4; +pub const SO_DONTROUTE: c_int = 5; +pub const SO_BROADCAST: c_int = 6; +pub const SO_SNDBUF: c_int = 7; +pub const SO_RCVBUF: c_int = 8; +pub const SO_KEEPALIVE: c_int = 9; +pub const SO_OOBINLINE: c_int = 10; +pub const SO_NO_CHECK: c_int = 11; +pub const SO_PRIORITY: c_int = 12; +pub const SO_LINGER: c_int = 13; +pub const SO_BSDCOMPAT: c_int = 14; +pub const SO_REUSEPORT: c_int = 15; +pub const SO_PASSCRED: c_int = 16; +pub const SO_PEERCRED: c_int = 17; +pub const SO_RCVLOWAT: c_int = 18; +pub const SO_SNDLOWAT: c_int = 19; +pub const SO_RCVTIMEO: c_int = 20; +pub const SO_SNDTIMEO: c_int = 21; +pub const SO_BINDTODEVICE: c_int = 25; +pub const SO_TIMESTAMP: c_int = 29; +pub const SO_ACCEPTCONN: c_int = 30; +pub const SO_SNDBUFFORCE: c_int = 32; +pub const SO_RCVBUFFORCE: c_int = 33; +pub const SO_TIMESTAMPNS: c_int = 35; +pub const SO_MARK: c_int = 36; +pub const SO_PROTOCOL: c_int = 38; +pub const SO_DOMAIN: c_int = 39; +pub const SO_RXQ_OVFL: c_int = 40; +pub const SO_PEEK_OFF: c_int = 42; +pub const SO_BUSY_POLL: c_int = 46; +pub const SO_COOKIE: c_int = 57; +pub const SO_BINDTOIFINDEX: c_int = 62; +pub const SO_FUCHSIA_MARK: c_int = 10000; + +pub const SA_ONSTACK: c_int = 0x08000000; +pub const SA_SIGINFO: c_int = 0x00000004; +pub const SA_NOCLDWAIT: c_int = 0x00000002; + +pub const SIGCHLD: c_int = 17; +pub const SIGBUS: c_int = 7; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGUSR1: c_int = 10; +pub const SIGUSR2: c_int = 12; +pub const SIGCONT: c_int = 18; +pub const SIGSTOP: c_int = 19; +pub const SIGTSTP: c_int = 20; +pub const SIGURG: c_int = 23; +pub const SIGIO: c_int = 29; +pub const SIGSYS: c_int = 31; +pub const SIGSTKFLT: c_int = 16; +pub const SIGPOLL: c_int = 29; +pub const SIGPWR: c_int = 30; +pub const SIG_SETMASK: c_int = 2; +pub const SIG_BLOCK: c_int = 0x000000; +pub const SIG_UNBLOCK: c_int = 0x01; + +pub const EXTPROC: crate::tcflag_t = 0x00010000; + +pub const MAP_HUGETLB: c_int = 0x040000; + +pub const F_GETLK: c_int = 5; +pub const F_GETOWN: c_int = 9; +pub const F_SETLK: c_int = 6; +pub const F_SETLKW: c_int = 7; +pub const F_SETOWN: c_int = 8; + +pub const VEOF: usize = 4; +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: crate::tcflag_t = 0x00008000; +pub const TOSTOP: crate::tcflag_t = 0x00000100; +pub const FLUSHO: crate::tcflag_t = 0x00001000; + +pub const TCGETS: c_int = 0x5401; +pub const TCSETS: c_int = 0x5402; +pub const TCSETSW: c_int = 0x5403; +pub const TCSETSF: c_int = 0x5404; +pub const TCGETA: c_int = 0x5405; +pub const TCSETA: c_int = 0x5406; +pub const TCSETAW: c_int = 0x5407; +pub const TCSETAF: c_int = 0x5408; +pub const TCSBRK: c_int = 0x5409; +pub const TCXONC: c_int = 0x540A; +pub const TCFLSH: c_int = 0x540B; +pub const TIOCGSOFTCAR: c_int = 0x5419; +pub const TIOCSSOFTCAR: c_int = 0x541A; +pub const TIOCLINUX: c_int = 0x541C; +pub const TIOCGSERIAL: c_int = 0x541E; +pub const TIOCEXCL: c_int = 0x540C; +pub const TIOCNXCL: c_int = 0x540D; +pub const TIOCSCTTY: c_int = 0x540E; +pub const TIOCGPGRP: c_int = 0x540F; +pub const TIOCSPGRP: c_int = 0x5410; +pub const TIOCOUTQ: c_int = 0x5411; +pub const TIOCSTI: c_int = 0x5412; +pub const TIOCGWINSZ: c_int = 0x5413; +pub const TIOCSWINSZ: c_int = 0x5414; +pub const TIOCMGET: c_int = 0x5415; +pub const TIOCMBIS: c_int = 0x5416; +pub const TIOCMBIC: c_int = 0x5417; +pub const TIOCMSET: c_int = 0x5418; +pub const FIONREAD: c_int = 0x541B; +pub const TIOCCONS: c_int = 0x541D; + +pub const POLLWRNORM: c_short = 0x100; +pub const POLLWRBAND: c_short = 0x200; + +pub const TIOCM_LE: c_int = 0x001; +pub const TIOCM_DTR: c_int = 0x002; +pub const TIOCM_RTS: c_int = 0x004; +pub const TIOCM_ST: c_int = 0x008; +pub const TIOCM_SR: c_int = 0x010; +pub const TIOCM_CTS: c_int = 0x020; +pub const TIOCM_CAR: c_int = 0x040; +pub const TIOCM_RNG: c_int = 0x080; +pub const TIOCM_DSR: c_int = 0x100; +pub const TIOCM_CD: c_int = TIOCM_CAR; +pub const TIOCM_RI: c_int = TIOCM_RNG; + +pub const O_DIRECTORY: c_int = 0x00080000; +pub const O_DIRECT: c_int = 0x00000800; +pub const O_LARGEFILE: c_int = 0x00001000; +pub const O_NOFOLLOW: c_int = 0x00000080; + +pub const HUGETLB_FLAG_ENCODE_SHIFT: u32 = 26; +pub const MAP_HUGE_SHIFT: u32 = 26; + +// intentionally not public, only used for fd_set +cfg_if! { + if #[cfg(target_pointer_width = "32")] { + const ULONG_SIZE: usize = 32; + } else if #[cfg(target_pointer_width = "64")] { + const ULONG_SIZE: usize = 64; + } else { + // Unknown target_pointer_width + } +} + +// END_PUB_CONST + +f! { + pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { + let fd = fd as usize; + let size = size_of_val(&(*set).fds_bits[0]) * 8; + (*set).fds_bits[fd / size] &= !(1 << (fd % size)); + return; + } + + pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { + let fd = fd as usize; + let size = size_of_val(&(*set).fds_bits[0]) * 8; + return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0; + } + + pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { + let fd = fd as usize; + let size = size_of_val(&(*set).fds_bits[0]) * 8; + (*set).fds_bits[fd / size] |= 1 << (fd % size); + return; + } + + pub fn FD_ZERO(set: *mut fd_set) -> () { + for slot in (*set).fds_bits.iter_mut() { + *slot = 0; + } + } + + pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { + for slot in cpuset.bits.iter_mut() { + *slot = 0; + } + } + + pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc + let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); + cpuset.bits[idx] |= 1 << offset; + () + } + + pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc + let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); + cpuset.bits[idx] &= !(1 << offset); + () + } + + pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); + let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); + 0 != (cpuset.bits[idx] & (1 << offset)) + } + + pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool { + set1.bits == set2.bits + } + + pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { + cmsg.offset(1) as *mut c_uchar + } + + pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { + if ((*cmsg).cmsg_len as size_t) < size_of::() { + core::ptr::null_mut::() + } else if __CMSG_NEXT(cmsg).add(size_of::()) >= __MHDR_END(mhdr) { + core::ptr::null_mut::() + } else { + __CMSG_NEXT(cmsg).cast() + } + } + + pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { + if (*mhdr).msg_controllen as size_t >= size_of::() { + (*mhdr).msg_control.cast() + } else { + core::ptr::null_mut::() + } + } + + pub const fn CMSG_ALIGN(len: size_t) -> size_t { + (len + size_of::() - 1) & !(size_of::() - 1) + } + + pub const fn CMSG_SPACE(len: c_uint) -> c_uint { + (CMSG_ALIGN(len as size_t) + CMSG_ALIGN(size_of::())) as c_uint + } + + pub const fn CMSG_LEN(len: c_uint) -> c_uint { + (CMSG_ALIGN(size_of::()) + len as size_t) as c_uint + } +} + +safe_f! { + pub const fn WIFSTOPPED(status: c_int) -> bool { + (status & 0xff) == 0x7f + } + + pub const fn WSTOPSIG(status: c_int) -> c_int { + (status >> 8) & 0xff + } + + pub const fn WIFCONTINUED(status: c_int) -> bool { + status == 0xffff + } + + pub const fn WIFSIGNALED(status: c_int) -> bool { + ((status & 0x7f) + 1) as i8 >= 2 + } + + pub const fn WTERMSIG(status: c_int) -> c_int { + status & 0x7f + } + + pub const fn WIFEXITED(status: c_int) -> bool { + (status & 0x7f) == 0 + } + + pub const fn WEXITSTATUS(status: c_int) -> c_int { + (status >> 8) & 0xff + } + + pub const fn WCOREDUMP(status: c_int) -> bool { + (status & 0x80) != 0 + } + + pub const fn QCMD(cmd: c_int, type_: c_int) -> c_int { + (cmd << 8) | (type_ & 0x00ff) + } + + pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { + let major = major as crate::dev_t; + let minor = minor as crate::dev_t; + let mut dev = 0; + dev |= (major & 0x00000fff) << 8; + dev |= (major & 0xfffff000) << 32; + dev |= (minor & 0x000000ff) << 0; + dev |= (minor & 0xffffff00) << 12; + dev + } + + pub const fn major(dev: crate::dev_t) -> c_uint { + let mut major = 0; + major |= (dev & 0x00000000000fff00) >> 8; + major |= (dev & 0xfffff00000000000) >> 32; + major as c_uint + } + + pub const fn minor(dev: crate::dev_t) -> c_uint { + let mut minor = 0; + minor |= (dev & 0x00000000000000ff) >> 0; + minor |= (dev & 0x00000ffffff00000) >> 12; + minor as c_uint + } +} + +fn __CMSG_LEN(cmsg: *const cmsghdr) -> ssize_t { + ((unsafe { (*cmsg).cmsg_len as size_t } + size_of::() - 1) & !(size_of::() - 1)) + as ssize_t +} + +fn __CMSG_NEXT(cmsg: *const cmsghdr) -> *mut c_uchar { + (unsafe { cmsg.offset(__CMSG_LEN(cmsg)) }) as *mut c_uchar +} + +fn __MHDR_END(mhdr: *const msghdr) -> *mut c_uchar { + unsafe { (*mhdr).msg_control.offset((*mhdr).msg_controllen as isize) }.cast() +} + +// EXTERN_FN + +#[link(name = "c")] +#[link(name = "fdio")] +extern "C" {} + +extern_ty! { + pub enum FILE {} + pub enum fpos_t {} // FIXME(fuchsia): fill this out with a struct +} + +extern "C" { + pub fn isalnum(c: c_int) -> c_int; + pub fn isalpha(c: c_int) -> c_int; + pub fn iscntrl(c: c_int) -> c_int; + pub fn isdigit(c: c_int) -> c_int; + pub fn isgraph(c: c_int) -> c_int; + pub fn islower(c: c_int) -> c_int; + pub fn isprint(c: c_int) -> c_int; + pub fn ispunct(c: c_int) -> c_int; + pub fn isspace(c: c_int) -> c_int; + pub fn isupper(c: c_int) -> c_int; + pub fn isxdigit(c: c_int) -> c_int; + pub fn isblank(c: c_int) -> c_int; + pub fn tolower(c: c_int) -> c_int; + pub fn toupper(c: c_int) -> c_int; + pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE; + pub fn freopen(filename: *const c_char, mode: *const c_char, file: *mut FILE) -> *mut FILE; + pub fn fflush(file: *mut FILE) -> c_int; + pub fn fclose(file: *mut FILE) -> c_int; + pub fn remove(filename: *const c_char) -> c_int; + pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int; + pub fn tmpfile() -> *mut FILE; + pub fn setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int, size: size_t) -> c_int; + pub fn setbuf(stream: *mut FILE, buf: *mut c_char); + pub fn getchar() -> c_int; + pub fn putchar(c: c_int) -> c_int; + pub fn fgetc(stream: *mut FILE) -> c_int; + pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char; + pub fn fputc(c: c_int, stream: *mut FILE) -> c_int; + pub fn fputs(s: *const c_char, stream: *mut FILE) -> c_int; + pub fn puts(s: *const c_char) -> c_int; + pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int; + pub fn fread(ptr: *mut c_void, size: size_t, nobj: size_t, stream: *mut FILE) -> size_t; + pub fn fwrite(ptr: *const c_void, size: size_t, nobj: size_t, stream: *mut FILE) -> size_t; + pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int; + pub fn ftell(stream: *mut FILE) -> c_long; + pub fn rewind(stream: *mut FILE); + pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int; + pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int; + pub fn feof(stream: *mut FILE) -> c_int; + pub fn ferror(stream: *mut FILE) -> c_int; + pub fn perror(s: *const c_char); + pub fn atof(s: *const c_char) -> c_double; + pub fn atoi(s: *const c_char) -> c_int; + pub fn atol(s: *const c_char) -> c_long; + pub fn atoll(s: *const c_char) -> c_longlong; + pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double; + pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float; + pub fn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long; + pub fn strtoll(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_longlong; + pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong; + pub fn strtoull(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulonglong; + pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; + pub fn malloc(size: size_t) -> *mut c_void; + pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; + pub fn free(p: *mut c_void); + pub fn abort() -> !; + pub fn exit(status: c_int) -> !; + pub fn _exit(status: c_int) -> !; + pub fn atexit(cb: extern "C" fn()) -> c_int; + pub fn system(s: *const c_char) -> c_int; + pub fn getenv(s: *const c_char) -> *mut c_char; + + pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char; + pub fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char; + pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char; + pub fn strncat(s: *mut c_char, ct: *const c_char, n: size_t) -> *mut c_char; + pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int; + pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strdup(cs: *const c_char) -> *mut c_char; + pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strlen(cs: *const c_char) -> size_t; + pub fn strnlen(cs: *const c_char, maxlen: size_t) -> size_t; + pub fn strerror(n: c_int) -> *mut c_char; + pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char; + pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t; + pub fn wcslen(buf: *const wchar_t) -> size_t; + pub fn wcstombs(dest: *mut c_char, src: *const wchar_t, n: size_t) -> size_t; + + pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; + pub fn wmemchr(cx: *const wchar_t, c: wchar_t, n: size_t) -> *mut wchar_t; + pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int; + pub fn memcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; + pub fn memmove(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; + pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void; + + pub fn abs(i: c_int) -> c_int; + pub fn labs(i: c_long) -> c_long; + pub fn rand() -> c_int; + pub fn srand(seed: c_uint); + + pub fn getpwnam(name: *const c_char) -> *mut passwd; + pub fn getpwuid(uid: crate::uid_t) -> *mut passwd; + + pub fn fprintf(stream: *mut crate::FILE, format: *const c_char, ...) -> c_int; + pub fn printf(format: *const c_char, ...) -> c_int; + pub fn snprintf(s: *mut c_char, n: size_t, format: *const c_char, ...) -> c_int; + pub fn sprintf(s: *mut c_char, format: *const c_char, ...) -> c_int; + pub fn fscanf(stream: *mut crate::FILE, format: *const c_char, ...) -> c_int; + pub fn scanf(format: *const c_char, ...) -> c_int; + pub fn sscanf(s: *const c_char, format: *const c_char, ...) -> c_int; + pub fn getchar_unlocked() -> c_int; + pub fn putchar_unlocked(c: c_int) -> c_int; + + pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> c_int; + pub fn connect(socket: c_int, address: *const sockaddr, len: socklen_t) -> c_int; + pub fn listen(socket: c_int, backlog: c_int) -> c_int; + pub fn accept(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> c_int; + pub fn getpeername(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t) + -> c_int; + pub fn getsockname(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t) + -> c_int; + pub fn setsockopt( + socket: c_int, + level: c_int, + name: c_int, + value: *const c_void, + option_len: socklen_t, + ) -> c_int; + pub fn socketpair( + domain: c_int, + type_: c_int, + protocol: c_int, + socket_vector: *mut c_int, + ) -> c_int; + pub fn sendto( + socket: c_int, + buf: *const c_void, + len: size_t, + flags: c_int, + addr: *const sockaddr, + addrlen: socklen_t, + ) -> ssize_t; + pub fn shutdown(socket: c_int, how: c_int) -> c_int; + + pub fn chmod(path: *const c_char, mode: mode_t) -> c_int; + pub fn fchmod(fd: c_int, mode: mode_t) -> c_int; + + pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int; + + pub fn mkdir(path: *const c_char, mode: mode_t) -> c_int; + + pub fn stat(path: *const c_char, buf: *mut stat) -> c_int; + + pub fn pclose(stream: *mut crate::FILE) -> c_int; + pub fn fdopen(fd: c_int, mode: *const c_char) -> *mut crate::FILE; + pub fn fileno(stream: *mut crate::FILE) -> c_int; + + pub fn open(path: *const c_char, oflag: c_int, ...) -> c_int; + pub fn creat(path: *const c_char, mode: mode_t) -> c_int; + pub fn fcntl(fd: c_int, cmd: c_int, ...) -> c_int; + + pub fn opendir(dirname: *const c_char) -> *mut crate::DIR; + pub fn readdir(dirp: *mut crate::DIR) -> *mut crate::dirent; + pub fn readdir_r( + dirp: *mut crate::DIR, + entry: *mut crate::dirent, + result: *mut *mut crate::dirent, + ) -> c_int; + pub fn closedir(dirp: *mut crate::DIR) -> c_int; + pub fn rewinddir(dirp: *mut crate::DIR); + + pub fn openat(dirfd: c_int, pathname: *const c_char, flags: c_int, ...) -> c_int; + pub fn fchmodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, flags: c_int) -> c_int; + pub fn fchown(fd: c_int, owner: crate::uid_t, group: crate::gid_t) -> c_int; + pub fn fchownat( + dirfd: c_int, + pathname: *const c_char, + owner: crate::uid_t, + group: crate::gid_t, + flags: c_int, + ) -> c_int; + pub fn fstatat(dirfd: c_int, pathname: *const c_char, buf: *mut stat, flags: c_int) -> c_int; + pub fn linkat( + olddirfd: c_int, + oldpath: *const c_char, + newdirfd: c_int, + newpath: *const c_char, + flags: c_int, + ) -> c_int; + pub fn mkdirat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; + pub fn readlinkat( + dirfd: c_int, + pathname: *const c_char, + buf: *mut c_char, + bufsiz: size_t, + ) -> ssize_t; + pub fn renameat( + olddirfd: c_int, + oldpath: *const c_char, + newdirfd: c_int, + newpath: *const c_char, + ) -> c_int; + pub fn symlinkat(target: *const c_char, newdirfd: c_int, linkpath: *const c_char) -> c_int; + pub fn unlinkat(dirfd: c_int, pathname: *const c_char, flags: c_int) -> c_int; + + pub fn access(path: *const c_char, amode: c_int) -> c_int; + pub fn alarm(seconds: c_uint) -> c_uint; + pub fn chdir(dir: *const c_char) -> c_int; + pub fn chown(path: *const c_char, uid: uid_t, gid: gid_t) -> c_int; + pub fn lchown(path: *const c_char, uid: uid_t, gid: gid_t) -> c_int; + pub fn close(fd: c_int) -> c_int; + pub fn dup(fd: c_int) -> c_int; + pub fn dup2(src: c_int, dst: c_int) -> c_int; + + pub fn execl(path: *const c_char, arg0: *const c_char, ...) -> c_int; + pub fn execle(path: *const c_char, arg0: *const c_char, ...) -> c_int; + pub fn execlp(file: *const c_char, arg0: *const c_char, ...) -> c_int; + + // DIFF(main): changed to `*const *mut` in e77f551de9 + pub fn execv(prog: *const c_char, argv: *const *const c_char) -> c_int; + pub fn execve( + prog: *const c_char, + argv: *const *const c_char, + envp: *const *const c_char, + ) -> c_int; + pub fn execvp(c: *const c_char, argv: *const *const c_char) -> c_int; + + pub fn fork() -> pid_t; + pub fn fpathconf(filedes: c_int, name: c_int) -> c_long; + pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char; + pub fn getegid() -> gid_t; + pub fn geteuid() -> uid_t; + pub fn getgid() -> gid_t; + pub fn getgroups(ngroups_max: c_int, groups: *mut gid_t) -> c_int; + pub fn getlogin() -> *mut c_char; + pub fn getopt(argc: c_int, argv: *const *mut c_char, optstr: *const c_char) -> c_int; + pub fn getpgid(pid: pid_t) -> pid_t; + pub fn getpgrp() -> pid_t; + pub fn getpid() -> pid_t; + pub fn getppid() -> pid_t; + pub fn getuid() -> uid_t; + pub fn isatty(fd: c_int) -> c_int; + pub fn link(src: *const c_char, dst: *const c_char) -> c_int; + pub fn lseek(fd: c_int, offset: off_t, whence: c_int) -> off_t; + pub fn pathconf(path: *const c_char, name: c_int) -> c_long; + pub fn pause() -> c_int; + pub fn pipe(fds: *mut c_int) -> c_int; + pub fn posix_memalign(memptr: *mut *mut c_void, align: size_t, size: size_t) -> c_int; + pub fn read(fd: c_int, buf: *mut c_void, count: size_t) -> ssize_t; + pub fn rmdir(path: *const c_char) -> c_int; + pub fn seteuid(uid: uid_t) -> c_int; + pub fn setegid(gid: gid_t) -> c_int; + pub fn setgid(gid: gid_t) -> c_int; + pub fn setpgid(pid: pid_t, pgid: pid_t) -> c_int; + pub fn setsid() -> pid_t; + pub fn setuid(uid: uid_t) -> c_int; + pub fn sleep(secs: c_uint) -> c_uint; + pub fn nanosleep(rqtp: *const timespec, rmtp: *mut timespec) -> c_int; + pub fn tcgetpgrp(fd: c_int) -> pid_t; + pub fn tcsetpgrp(fd: c_int, pgrp: crate::pid_t) -> c_int; + pub fn ttyname(fd: c_int) -> *mut c_char; + pub fn unlink(c: *const c_char) -> c_int; + pub fn wait(status: *mut c_int) -> pid_t; + pub fn waitpid(pid: pid_t, status: *mut c_int, options: c_int) -> pid_t; + pub fn write(fd: c_int, buf: *const c_void, count: size_t) -> ssize_t; + pub fn pread(fd: c_int, buf: *mut c_void, count: size_t, offset: off_t) -> ssize_t; + pub fn pwrite(fd: c_int, buf: *const c_void, count: size_t, offset: off_t) -> ssize_t; + pub fn umask(mask: mode_t) -> mode_t; + + pub fn utime(file: *const c_char, buf: *const utimbuf) -> c_int; + + pub fn kill(pid: pid_t, sig: c_int) -> c_int; + + pub fn mlock(addr: *const c_void, len: size_t) -> c_int; + pub fn munlock(addr: *const c_void, len: size_t) -> c_int; + pub fn mlockall(flags: c_int) -> c_int; + pub fn munlockall() -> c_int; + + pub fn mmap( + addr: *mut c_void, + len: size_t, + prot: c_int, + flags: c_int, + fd: c_int, + offset: off_t, + ) -> *mut c_void; + pub fn munmap(addr: *mut c_void, len: size_t) -> c_int; + + pub fn if_nametoindex(ifname: *const c_char) -> c_uint; + pub fn if_indextoname(ifindex: c_uint, ifname: *mut c_char) -> *mut c_char; + + pub fn lstat(path: *const c_char, buf: *mut stat) -> c_int; + + pub fn fsync(fd: c_int) -> c_int; + + pub fn setenv(name: *const c_char, val: *const c_char, overwrite: c_int) -> c_int; + pub fn unsetenv(name: *const c_char) -> c_int; + + pub fn symlink(path1: *const c_char, path2: *const c_char) -> c_int; + + pub fn ftruncate(fd: c_int, length: off_t) -> c_int; + + pub fn signal(signum: c_int, handler: sighandler_t) -> sighandler_t; + + pub fn realpath(pathname: *const c_char, resolved: *mut c_char) -> *mut c_char; + + pub fn flock(fd: c_int, operation: c_int) -> c_int; + + pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut c_void) -> c_int; + pub fn times(buf: *mut crate::tms) -> crate::clock_t; + + pub fn pthread_self() -> crate::pthread_t; + pub fn pthread_join(native: crate::pthread_t, value: *mut *mut c_void) -> c_int; + pub fn pthread_exit(value: *mut c_void) -> !; + pub fn pthread_attr_init(attr: *mut crate::pthread_attr_t) -> c_int; + pub fn pthread_attr_destroy(attr: *mut crate::pthread_attr_t) -> c_int; + pub fn pthread_attr_getstacksize( + attr: *const crate::pthread_attr_t, + stacksize: *mut size_t, + ) -> c_int; + pub fn pthread_attr_setstacksize(attr: *mut crate::pthread_attr_t, stack_size: size_t) + -> c_int; + pub fn pthread_attr_setdetachstate(attr: *mut crate::pthread_attr_t, state: c_int) -> c_int; + pub fn pthread_detach(thread: crate::pthread_t) -> c_int; + pub fn sched_yield() -> c_int; + pub fn pthread_key_create( + key: *mut pthread_key_t, + dtor: Option, + ) -> c_int; + pub fn pthread_key_delete(key: pthread_key_t) -> c_int; + pub fn pthread_getspecific(key: pthread_key_t) -> *mut c_void; + pub fn pthread_setspecific(key: pthread_key_t, value: *const c_void) -> c_int; + pub fn pthread_mutex_init( + lock: *mut pthread_mutex_t, + attr: *const pthread_mutexattr_t, + ) -> c_int; + pub fn pthread_mutex_destroy(lock: *mut pthread_mutex_t) -> c_int; + pub fn pthread_mutex_lock(lock: *mut pthread_mutex_t) -> c_int; + pub fn pthread_mutex_trylock(lock: *mut pthread_mutex_t) -> c_int; + pub fn pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> c_int; + + pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> c_int; + pub fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> c_int; + pub fn pthread_mutexattr_settype(attr: *mut pthread_mutexattr_t, _type: c_int) -> c_int; + + pub fn pthread_cond_init(cond: *mut pthread_cond_t, attr: *const pthread_condattr_t) -> c_int; + pub fn pthread_cond_wait(cond: *mut pthread_cond_t, lock: *mut pthread_mutex_t) -> c_int; + pub fn pthread_cond_timedwait( + cond: *mut pthread_cond_t, + lock: *mut pthread_mutex_t, + abstime: *const crate::timespec, + ) -> c_int; + pub fn pthread_cond_signal(cond: *mut pthread_cond_t) -> c_int; + pub fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> c_int; + pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> c_int; + pub fn pthread_condattr_init(attr: *mut pthread_condattr_t) -> c_int; + pub fn pthread_condattr_destroy(attr: *mut pthread_condattr_t) -> c_int; + pub fn pthread_rwlock_init( + lock: *mut pthread_rwlock_t, + attr: *const pthread_rwlockattr_t, + ) -> c_int; + pub fn pthread_rwlock_destroy(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_rdlock(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_tryrdlock(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_wrlock(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_trywrlock(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_unlock(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlockattr_init(attr: *mut pthread_rwlockattr_t) -> c_int; + pub fn pthread_rwlockattr_destroy(attr: *mut pthread_rwlockattr_t) -> c_int; + pub fn pthread_getname_np(thread: crate::pthread_t, name: *mut c_char, len: size_t) -> c_int; + pub fn pthread_setname_np(thread: crate::pthread_t, name: *const c_char) -> c_int; + pub fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int; + + pub fn getsockopt( + sockfd: c_int, + level: c_int, + optname: c_int, + optval: *mut c_void, + optlen: *mut crate::socklen_t, + ) -> c_int; + pub fn raise(signum: c_int) -> c_int; + pub fn sigaction(signum: c_int, act: *const sigaction, oldact: *mut sigaction) -> c_int; + + pub fn utimes(filename: *const c_char, times: *const crate::timeval) -> c_int; + pub fn dlopen(filename: *const c_char, flag: c_int) -> *mut c_void; + pub fn dlerror() -> *mut c_char; + pub fn dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void; + pub fn dlclose(handle: *mut c_void) -> c_int; + pub fn dladdr(addr: *const c_void, info: *mut Dl_info) -> c_int; + + pub fn getaddrinfo( + node: *const c_char, + service: *const c_char, + hints: *const addrinfo, + res: *mut *mut addrinfo, + ) -> c_int; + pub fn freeaddrinfo(res: *mut addrinfo); + pub fn gai_strerror(errcode: c_int) -> *const c_char; + pub fn res_init() -> c_int; + + pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm; + pub fn localtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm; + pub fn mktime(tm: *mut tm) -> time_t; + pub fn time(time: *mut time_t) -> time_t; + pub fn gmtime(time_p: *const time_t) -> *mut tm; + pub fn localtime(time_p: *const time_t) -> *mut tm; + + pub fn mknod(pathname: *const c_char, mode: mode_t, dev: crate::dev_t) -> c_int; + pub fn uname(buf: *mut crate::utsname) -> c_int; + pub fn gethostname(name: *mut c_char, len: size_t) -> c_int; + pub fn getservbyname(name: *const c_char, proto: *const c_char) -> *mut servent; + pub fn getprotobyname(name: *const c_char) -> *mut protoent; + pub fn getprotobynumber(proto: c_int) -> *mut protoent; + pub fn usleep(secs: c_uint) -> c_int; + pub fn send(socket: c_int, buf: *const c_void, len: size_t, flags: c_int) -> ssize_t; + pub fn recv(socket: c_int, buf: *mut c_void, len: size_t, flags: c_int) -> ssize_t; + pub fn putenv(string: *mut c_char) -> c_int; + pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: c_int) -> c_int; + pub fn select( + nfds: c_int, + readfds: *mut fd_set, + writefds: *mut fd_set, + errorfds: *mut fd_set, + timeout: *mut timeval, + ) -> c_int; + pub fn setlocale(category: c_int, locale: *const c_char) -> *mut c_char; + pub fn localeconv() -> *mut lconv; + + pub fn sem_destroy(sem: *mut sem_t) -> c_int; + pub fn sem_wait(sem: *mut sem_t) -> c_int; + pub fn sem_trywait(sem: *mut sem_t) -> c_int; + pub fn sem_post(sem: *mut sem_t) -> c_int; + pub fn sem_init(sem: *mut sem_t, pshared: c_int, value: c_uint) -> c_int; + pub fn statvfs(path: *const c_char, buf: *mut statvfs) -> c_int; + pub fn fstatvfs(fd: c_int, buf: *mut statvfs) -> c_int; + + pub fn readlink(path: *const c_char, buf: *mut c_char, bufsz: size_t) -> ssize_t; + + pub fn sigemptyset(set: *mut sigset_t) -> c_int; + pub fn sigaddset(set: *mut sigset_t, signum: c_int) -> c_int; + pub fn sigfillset(set: *mut sigset_t) -> c_int; + pub fn sigdelset(set: *mut sigset_t, signum: c_int) -> c_int; + pub fn sigismember(set: *const sigset_t, signum: c_int) -> c_int; + + pub fn sigprocmask(how: c_int, set: *const sigset_t, oldset: *mut sigset_t) -> c_int; + pub fn sigpending(set: *mut sigset_t) -> c_int; + + pub fn timegm(tm: *mut crate::tm) -> time_t; + + pub fn getsid(pid: pid_t) -> pid_t; + + pub fn sysconf(name: c_int) -> c_long; + + pub fn mkfifo(path: *const c_char, mode: mode_t) -> c_int; + + pub fn pselect( + nfds: c_int, + readfds: *mut fd_set, + writefds: *mut fd_set, + errorfds: *mut fd_set, + timeout: *const timespec, + sigmask: *const sigset_t, + ) -> c_int; + pub fn fseeko(stream: *mut crate::FILE, offset: off_t, whence: c_int) -> c_int; + pub fn ftello(stream: *mut crate::FILE) -> off_t; + pub fn tcdrain(fd: c_int) -> c_int; + pub fn cfgetispeed(termios: *const crate::termios) -> crate::speed_t; + pub fn cfgetospeed(termios: *const crate::termios) -> crate::speed_t; + pub fn cfmakeraw(termios: *mut crate::termios); + pub fn cfsetispeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int; + pub fn cfsetospeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int; + pub fn cfsetspeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int; + pub fn tcgetattr(fd: c_int, termios: *mut crate::termios) -> c_int; + pub fn tcsetattr(fd: c_int, optional_actions: c_int, termios: *const crate::termios) -> c_int; + pub fn tcflow(fd: c_int, action: c_int) -> c_int; + pub fn tcflush(fd: c_int, action: c_int) -> c_int; + pub fn tcgetsid(fd: c_int) -> crate::pid_t; + pub fn tcsendbreak(fd: c_int, duration: c_int) -> c_int; + pub fn mkstemp(template: *mut c_char) -> c_int; + pub fn mkdtemp(template: *mut c_char) -> *mut c_char; + + pub fn tmpnam(ptr: *mut c_char) -> *mut c_char; + + pub fn openlog(ident: *const c_char, logopt: c_int, facility: c_int); + pub fn closelog(); + pub fn setlogmask(maskpri: c_int) -> c_int; + pub fn syslog(priority: c_int, message: *const c_char, ...); + + pub fn grantpt(fd: c_int) -> c_int; + pub fn posix_openpt(flags: c_int) -> c_int; + pub fn ptsname(fd: c_int) -> *mut c_char; + pub fn unlockpt(fd: c_int) -> c_int; + + pub fn fdatasync(fd: c_int) -> c_int; + pub fn clock_getres(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; + pub fn clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; + pub fn clock_settime(clk_id: crate::clockid_t, tp: *const crate::timespec) -> c_int; + pub fn dirfd(dirp: *mut crate::DIR) -> c_int; + + pub fn pthread_getattr_np(native: crate::pthread_t, attr: *mut crate::pthread_attr_t) -> c_int; + pub fn pthread_attr_getstack( + attr: *const crate::pthread_attr_t, + stackaddr: *mut *mut c_void, + stacksize: *mut size_t, + ) -> c_int; + pub fn memalign(align: size_t, size: size_t) -> *mut c_void; + pub fn setgroups(ngroups: size_t, ptr: *const crate::gid_t) -> c_int; + pub fn pipe2(fds: *mut c_int, flags: c_int) -> c_int; + pub fn statfs(path: *const c_char, buf: *mut statfs) -> c_int; + pub fn fstatfs(fd: c_int, buf: *mut statfs) -> c_int; + pub fn memrchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; + + pub fn posix_fadvise(fd: c_int, offset: off_t, len: off_t, advise: c_int) -> c_int; + pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int; + pub fn utimensat( + dirfd: c_int, + path: *const c_char, + times: *const crate::timespec, + flag: c_int, + ) -> c_int; + pub fn duplocale(base: crate::locale_t) -> crate::locale_t; + pub fn freelocale(loc: crate::locale_t); + pub fn newlocale(mask: c_int, locale: *const c_char, base: crate::locale_t) -> crate::locale_t; + pub fn uselocale(loc: crate::locale_t) -> crate::locale_t; + + pub fn fdopendir(fd: c_int) -> *mut crate::DIR; + + pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; + pub fn pthread_condattr_getclock( + attr: *const pthread_condattr_t, + clock_id: *mut clockid_t, + ) -> c_int; + pub fn pthread_condattr_setclock( + attr: *mut pthread_condattr_t, + clock_id: crate::clockid_t, + ) -> c_int; + pub fn accept4( + fd: c_int, + addr: *mut crate::sockaddr, + len: *mut crate::socklen_t, + flg: c_int, + ) -> c_int; + pub fn ptsname_r(fd: c_int, buf: *mut c_char, buflen: size_t) -> c_int; + pub fn clearenv() -> c_int; + pub fn waitid( + idtype: idtype_t, + id: id_t, + infop: *mut crate::siginfo_t, + options: c_int, + ) -> c_int; + pub fn setreuid(ruid: crate::uid_t, euid: crate::uid_t) -> c_int; + pub fn setregid(rgid: crate::gid_t, egid: crate::gid_t) -> c_int; + pub fn getresuid( + ruid: *mut crate::uid_t, + euid: *mut crate::uid_t, + suid: *mut crate::uid_t, + ) -> c_int; + pub fn getresgid( + rgid: *mut crate::gid_t, + egid: *mut crate::gid_t, + sgid: *mut crate::gid_t, + ) -> c_int; + pub fn acct(filename: *const c_char) -> c_int; + pub fn brk(addr: *mut c_void) -> c_int; + pub fn setresgid(rgid: crate::gid_t, egid: crate::gid_t, sgid: crate::gid_t) -> c_int; + pub fn setresuid(ruid: crate::uid_t, euid: crate::uid_t, suid: crate::uid_t) -> c_int; + pub fn openpty( + amaster: *mut c_int, + aslave: *mut c_int, + name: *mut c_char, + termp: *const termios, + winp: *const crate::winsize, + ) -> c_int; + + // DIFF(main): changed to `*const *mut` in e77f551de9 + pub fn execvpe( + file: *const c_char, + argv: *const *const c_char, + envp: *const *const c_char, + ) -> c_int; + pub fn fexecve(fd: c_int, argv: *const *const c_char, envp: *const *const c_char) -> c_int; + + pub fn ioctl(fd: c_int, request: c_int, ...) -> c_int; + + pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int; + + pub fn setpwent(); + pub fn endpwent(); + pub fn getpwent() -> *mut passwd; + + pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int; + + // System V IPC + pub fn shmget(key: crate::key_t, size: size_t, shmflg: c_int) -> c_int; + pub fn shmat(shmid: c_int, shmaddr: *const c_void, shmflg: c_int) -> *mut c_void; + pub fn shmdt(shmaddr: *const c_void) -> c_int; + pub fn shmctl(shmid: c_int, cmd: c_int, buf: *mut crate::shmid_ds) -> c_int; + pub fn ftok(pathname: *const c_char, proj_id: c_int) -> crate::key_t; + pub fn semget(key: crate::key_t, nsems: c_int, semflag: c_int) -> c_int; + pub fn semop(semid: c_int, sops: *mut crate::sembuf, nsops: size_t) -> c_int; + pub fn semctl(semid: c_int, semnum: c_int, cmd: c_int, ...) -> c_int; + pub fn msgctl(msqid: c_int, cmd: c_int, buf: *mut msqid_ds) -> c_int; + pub fn msgget(key: crate::key_t, msgflg: c_int) -> c_int; + pub fn msgrcv( + msqid: c_int, + msgp: *mut c_void, + msgsz: size_t, + msgtyp: c_long, + msgflg: c_int, + ) -> ssize_t; + pub fn msgsnd(msqid: c_int, msgp: *const c_void, msgsz: size_t, msgflg: c_int) -> c_int; + + pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; + pub fn __errno_location() -> *mut c_int; + + pub fn fallocate(fd: c_int, mode: c_int, offset: off_t, len: off_t) -> c_int; + pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int; + pub fn readahead(fd: c_int, offset: off64_t, count: size_t) -> ssize_t; + pub fn signalfd(fd: c_int, mask: *const crate::sigset_t, flags: c_int) -> c_int; + pub fn timerfd_create(clockid: c_int, flags: c_int) -> c_int; + pub fn timerfd_gettime(fd: c_int, curr_value: *mut itimerspec) -> c_int; + pub fn timerfd_settime( + fd: c_int, + flags: c_int, + new_value: *const itimerspec, + old_value: *mut itimerspec, + ) -> c_int; + pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t; + pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t; + pub fn quotactl(cmd: c_int, special: *const c_char, id: c_int, data: *mut c_char) -> c_int; + pub fn dup3(oldfd: c_int, newfd: c_int, flags: c_int) -> c_int; + pub fn mkostemp(template: *mut c_char, flags: c_int) -> c_int; + pub fn mkostemps(template: *mut c_char, suffixlen: c_int, flags: c_int) -> c_int; + pub fn sigtimedwait( + set: *const sigset_t, + info: *mut siginfo_t, + timeout: *const crate::timespec, + ) -> c_int; + pub fn sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> c_int; + pub fn nl_langinfo_l(item: crate::nl_item, locale: crate::locale_t) -> *mut c_char; + pub fn getnameinfo( + sa: *const crate::sockaddr, + salen: crate::socklen_t, + host: *mut c_char, + hostlen: crate::socklen_t, + serv: *mut c_char, + servlen: crate::socklen_t, + flags: c_int, + ) -> c_int; + pub fn reboot(how_to: c_int) -> c_int; + pub fn setfsgid(gid: crate::gid_t) -> c_int; + pub fn setfsuid(uid: crate::uid_t) -> c_int; + + // Not available now on Android + pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; + pub fn if_nameindex() -> *mut if_nameindex; + pub fn if_freenameindex(ptr: *mut if_nameindex); + pub fn sync_file_range(fd: c_int, offset: off64_t, nbytes: off64_t, flags: c_uint) -> c_int; + pub fn getifaddrs(ifap: *mut *mut crate::ifaddrs) -> c_int; + pub fn freeifaddrs(ifa: *mut crate::ifaddrs); + + pub fn glob( + pattern: *const c_char, + flags: c_int, + errfunc: Option c_int>, + pglob: *mut crate::glob_t, + ) -> c_int; + pub fn globfree(pglob: *mut crate::glob_t); + + pub fn posix_madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; + + pub fn shm_unlink(name: *const c_char) -> c_int; + + pub fn seekdir(dirp: *mut crate::DIR, loc: c_long); + + pub fn telldir(dirp: *mut crate::DIR) -> c_long; + pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; + + pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int; + + pub fn recvfrom( + socket: c_int, + buf: *mut c_void, + len: size_t, + flags: c_int, + addr: *mut crate::sockaddr, + addrlen: *mut crate::socklen_t, + ) -> ssize_t; + pub fn mkstemps(template: *mut c_char, suffixlen: c_int) -> c_int; + pub fn futimes(fd: c_int, times: *const crate::timeval) -> c_int; + pub fn nl_langinfo(item: crate::nl_item) -> *mut c_char; + + pub fn bind( + socket: c_int, + address: *const crate::sockaddr, + address_len: crate::socklen_t, + ) -> c_int; + + pub fn writev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; + pub fn readv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; + + pub fn sendmsg(fd: c_int, msg: *const crate::msghdr, flags: c_int) -> ssize_t; + pub fn recvmsg(fd: c_int, msg: *mut crate::msghdr, flags: c_int) -> ssize_t; + pub fn getdomainname(name: *mut c_char, len: size_t) -> c_int; + pub fn setdomainname(name: *const c_char, len: size_t) -> c_int; + pub fn vhangup() -> c_int; + pub fn sendmmsg(sockfd: c_int, msgvec: *mut mmsghdr, vlen: c_uint, flags: c_int) -> c_int; + pub fn recvmmsg( + sockfd: c_int, + msgvec: *mut mmsghdr, + vlen: c_uint, + flags: c_int, + timeout: *mut crate::timespec, + ) -> c_int; + pub fn sync(); + pub fn syscall(num: c_long, ...) -> c_long; + pub fn sched_getaffinity( + pid: crate::pid_t, + cpusetsize: size_t, + cpuset: *mut cpu_set_t, + ) -> c_int; + pub fn sched_setaffinity( + pid: crate::pid_t, + cpusetsize: size_t, + cpuset: *const cpu_set_t, + ) -> c_int; + pub fn umount(target: *const c_char) -> c_int; + pub fn sched_get_priority_max(policy: c_int) -> c_int; + pub fn tee(fd_in: c_int, fd_out: c_int, len: size_t, flags: c_uint) -> ssize_t; + pub fn settimeofday(tv: *const crate::timeval, tz: *const crate::timezone) -> c_int; + pub fn splice( + fd_in: c_int, + off_in: *mut crate::loff_t, + fd_out: c_int, + off_out: *mut crate::loff_t, + len: size_t, + flags: c_uint, + ) -> ssize_t; + pub fn eventfd(initval: c_uint, flags: c_int) -> c_int; + pub fn sched_rr_get_interval(pid: crate::pid_t, tp: *mut crate::timespec) -> c_int; + pub fn sem_timedwait(sem: *mut sem_t, abstime: *const crate::timespec) -> c_int; + pub fn sem_getvalue(sem: *mut sem_t, sval: *mut c_int) -> c_int; + pub fn sched_setparam(pid: crate::pid_t, param: *const crate::sched_param) -> c_int; + pub fn swapoff(puath: *const c_char) -> c_int; + pub fn vmsplice(fd: c_int, iov: *const crate::iovec, nr_segs: size_t, flags: c_uint) + -> ssize_t; + pub fn mount( + src: *const c_char, + target: *const c_char, + fstype: *const c_char, + flags: c_ulong, + data: *const c_void, + ) -> c_int; + pub fn personality(persona: c_ulong) -> c_int; + pub fn sched_getparam(pid: crate::pid_t, param: *mut crate::sched_param) -> c_int; + pub fn ppoll( + fds: *mut crate::pollfd, + nfds: nfds_t, + timeout: *const crate::timespec, + sigmask: *const sigset_t, + ) -> c_int; + pub fn pthread_mutex_timedlock( + lock: *mut pthread_mutex_t, + abstime: *const crate::timespec, + ) -> c_int; + pub fn clone( + cb: extern "C" fn(*mut c_void) -> c_int, + child_stack: *mut c_void, + flags: c_int, + arg: *mut c_void, + ... + ) -> c_int; + pub fn sched_getscheduler(pid: crate::pid_t) -> c_int; + pub fn clock_nanosleep( + clk_id: crate::clockid_t, + flags: c_int, + rqtp: *const crate::timespec, + rmtp: *mut crate::timespec, + ) -> c_int; + pub fn pthread_attr_getguardsize( + attr: *const crate::pthread_attr_t, + guardsize: *mut size_t, + ) -> c_int; + pub fn pthread_attr_setguardsize(attr: *mut crate::pthread_attr_t, guardsize: size_t) -> c_int; + pub fn sethostname(name: *const c_char, len: size_t) -> c_int; + pub fn sched_get_priority_min(policy: c_int) -> c_int; + pub fn umount2(target: *const c_char, flags: c_int) -> c_int; + pub fn swapon(path: *const c_char, swapflags: c_int) -> c_int; + pub fn sched_setscheduler( + pid: crate::pid_t, + policy: c_int, + param: *const crate::sched_param, + ) -> c_int; + pub fn sigsuspend(mask: *const crate::sigset_t) -> c_int; + pub fn getgrgid_r( + gid: crate::gid_t, + grp: *mut crate::group, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::group, + ) -> c_int; + pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> c_int; + pub fn sem_close(sem: *mut sem_t) -> c_int; + pub fn getdtablesize() -> c_int; + pub fn getgrnam_r( + name: *const c_char, + grp: *mut crate::group, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::group, + ) -> c_int; + pub fn initgroups(user: *const c_char, group: crate::gid_t) -> c_int; + pub fn pthread_sigmask(how: c_int, set: *const sigset_t, oldset: *mut sigset_t) -> c_int; + pub fn sem_open(name: *const c_char, oflag: c_int, ...) -> *mut sem_t; + pub fn getgrnam(name: *const c_char) -> *mut crate::group; + pub fn pthread_cancel(thread: crate::pthread_t) -> c_int; + pub fn pthread_kill(thread: crate::pthread_t, sig: c_int) -> c_int; + pub fn sem_unlink(name: *const c_char) -> c_int; + pub fn daemon(nochdir: c_int, noclose: c_int) -> c_int; + pub fn getpwnam_r( + name: *const c_char, + pwd: *mut passwd, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut passwd, + ) -> c_int; + pub fn getpwuid_r( + uid: crate::uid_t, + pwd: *mut passwd, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut passwd, + ) -> c_int; + pub fn sigwait(set: *const sigset_t, sig: *mut c_int) -> c_int; + pub fn pthread_atfork( + prepare: Option, + parent: Option, + child: Option, + ) -> c_int; + pub fn getgrgid(gid: crate::gid_t) -> *mut crate::group; + + pub fn setgrent(); + pub fn endgrent(); + pub fn getgrent() -> *mut crate::group; + + pub fn getgrouplist( + user: *const c_char, + group: crate::gid_t, + groups: *mut crate::gid_t, + ngroups: *mut c_int, + ) -> c_int; + pub fn popen(command: *const c_char, mode: *const c_char) -> *mut crate::FILE; + pub fn faccessat(dirfd: c_int, pathname: *const c_char, mode: c_int, flags: c_int) -> c_int; + pub fn pthread_create( + native: *mut crate::pthread_t, + attr: *const crate::pthread_attr_t, + f: extern "C" fn(*mut c_void) -> *mut c_void, + value: *mut c_void, + ) -> c_int; + pub fn dl_iterate_phdr( + callback: Option< + unsafe extern "C" fn( + info: *mut crate::dl_phdr_info, + size: size_t, + data: *mut c_void, + ) -> c_int, + >, + data: *mut c_void, + ) -> c_int; +} + +cfg_if! { + if #[cfg(target_arch = "aarch64")] { + mod aarch64; + pub use self::aarch64::*; + } else if #[cfg(any(target_arch = "x86_64"))] { + mod x86_64; + pub use self::x86_64::*; + } else if #[cfg(any(target_arch = "riscv64"))] { + mod riscv64; + pub use self::riscv64::*; + } else { + // Unknown target_arch + } +} diff --git a/http/vendor/libc/src/fuchsia/riscv64.rs b/http/vendor/libc/src/fuchsia/riscv64.rs new file mode 100644 index 0000000..bc93cc3 --- /dev/null +++ b/http/vendor/libc/src/fuchsia/riscv64.rs @@ -0,0 +1,46 @@ +use crate::off_t; +use crate::prelude::*; + +// From psABI Calling Convention for RV64 +pub type __u64 = c_ulonglong; +pub type wchar_t = i32; + +pub type nlink_t = c_ulong; +pub type blksize_t = c_long; + +pub type stat64 = stat; +s! { + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_nlink: crate::nlink_t, + pub st_mode: crate::mode_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + __pad0: Padding, + pub st_rdev: crate::dev_t, + pub st_size: off_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + __unused: Padding<[c_long; 3]>, + } + + // Not actually used, IPC calls just return ENOSYS + pub struct ipc_perm { + pub __ipc_perm_key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: crate::mode_t, + pub __seq: c_ushort, + __unused1: Padding, + __unused2: Padding, + } +} diff --git a/http/vendor/libc/src/fuchsia/x86_64.rs b/http/vendor/libc/src/fuchsia/x86_64.rs new file mode 100644 index 0000000..fc42cd9 --- /dev/null +++ b/http/vendor/libc/src/fuchsia/x86_64.rs @@ -0,0 +1,110 @@ +use crate::off_t; +use crate::prelude::*; + +pub type wchar_t = i32; +pub type nlink_t = u64; +pub type blksize_t = c_long; +pub type __u64 = c_ulonglong; + +s! { + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_nlink: crate::nlink_t, + pub st_mode: crate::mode_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + __pad0: Padding, + pub st_rdev: crate::dev_t, + pub st_size: off_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + __unused: Padding<[c_long; 3]>, + } + + pub struct stat64 { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino64_t, + pub st_nlink: crate::nlink_t, + pub st_mode: crate::mode_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + __pad0: Padding, + pub st_rdev: crate::dev_t, + pub st_size: off_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt64_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + __reserved: Padding<[c_long; 3]>, + } + + pub struct mcontext_t { + __private: [u64; 32], + } + + pub struct ipc_perm { + pub __ipc_perm_key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: crate::mode_t, + pub __seq: c_int, + __unused1: Padding, + __unused2: Padding, + } + + pub struct ucontext_t { + pub uc_flags: c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: crate::stack_t, + pub uc_mcontext: mcontext_t, + pub uc_sigmask: crate::sigset_t, + __private: [u8; 512], + } +} + +// offsets in user_regs_structs, from sys/reg.h +pub const R15: c_int = 0; +pub const R14: c_int = 1; +pub const R13: c_int = 2; +pub const R12: c_int = 3; +pub const RBP: c_int = 4; +pub const RBX: c_int = 5; +pub const R11: c_int = 6; +pub const R10: c_int = 7; +pub const R9: c_int = 8; +pub const R8: c_int = 9; +pub const RAX: c_int = 10; +pub const RCX: c_int = 11; +pub const RDX: c_int = 12; +pub const RSI: c_int = 13; +pub const RDI: c_int = 14; +pub const ORIG_RAX: c_int = 15; +pub const RIP: c_int = 16; +pub const CS: c_int = 17; +pub const EFLAGS: c_int = 18; +pub const RSP: c_int = 19; +pub const SS: c_int = 20; +pub const FS_BASE: c_int = 21; +pub const GS_BASE: c_int = 22; +pub const DS: c_int = 23; +pub const ES: c_int = 24; +pub const FS: c_int = 25; +pub const GS: c_int = 26; + +pub const MAP_32BIT: c_int = 0x0040; + +pub const SIGSTKSZ: size_t = 8192; +pub const MINSIGSTKSZ: size_t = 2048; diff --git a/http/vendor/libc/src/hermit.rs b/http/vendor/libc/src/hermit.rs new file mode 100644 index 0000000..2cbf573 --- /dev/null +++ b/http/vendor/libc/src/hermit.rs @@ -0,0 +1,562 @@ +//! Hermit C type definitions + +use crate::prelude::*; + +pub type intmax_t = i64; +pub type uintmax_t = u64; +pub type intptr_t = isize; +pub type uintptr_t = usize; + +pub type size_t = usize; +pub type ssize_t = isize; +pub type ptrdiff_t = isize; + +pub type clockid_t = i32; +pub type in_addr_t = u32; +pub type in_port_t = u16; +pub type mode_t = u32; +pub type nfds_t = usize; +pub type pid_t = i32; +pub type sa_family_t = u8; +pub type socklen_t = u32; +pub type time_t = i64; + +s! { + pub struct addrinfo { + pub ai_flags: i32, + pub ai_family: i32, + pub ai_socktype: i32, + pub ai_protocol: i32, + pub ai_addrlen: socklen_t, + pub ai_canonname: *mut c_char, + pub ai_addr: *mut sockaddr, + pub ai_next: *mut addrinfo, + } + + pub struct dirent64 { + pub d_ino: u64, + pub d_off: i64, + pub d_reclen: u16, + pub d_type: u8, + pub d_name: [c_char; 256], + } + + #[repr(align(4))] + pub struct in6_addr { + pub s6_addr: [u8; 16], + } + + pub struct in_addr { + pub s_addr: in_addr_t, + } + + pub struct iovec { + iov_base: *mut c_void, + iov_len: usize, + } + + pub struct pollfd { + pub fd: i32, + pub events: i16, + pub revents: i16, + } + + pub struct sockaddr { + pub sa_len: u8, + pub sa_family: sa_family_t, + pub sa_data: [c_char; 14], + } + + pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: sa_family_t, + pub sin_port: in_port_t, + pub sin_addr: in_addr, + pub sin_zero: [c_char; 8], + } + + pub struct sockaddr_in6 { + pub sin6_len: u8, + pub sin6_family: sa_family_t, + pub sin6_port: in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: in6_addr, + pub sin6_scope_id: u32, + } + + pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: sa_family_t, + __ss_pad1: Padding<[u8; 6]>, + __ss_align: i64, + __ss_pad2: Padding<[u8; 112]>, + } + + pub struct stat { + pub st_dev: u64, + pub st_ino: u64, + pub st_nlink: u64, + pub st_mode: mode_t, + pub st_uid: u32, + pub st_gid: u32, + pub st_rdev: u64, + pub st_size: i64, + pub st_blksize: i64, + pub st_blocks: i64, + pub st_atim: timespec, + pub st_mtim: timespec, + pub st_ctim: timespec, + } + + #[derive(Default)] + pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: i32, + } +} + +pub const AF_UNSPEC: i32 = 0; +pub const AF_INET: i32 = 3; +pub const AF_INET6: i32 = 1; +pub const AF_VSOCK: i32 = 2; + +pub const CLOCK_REALTIME: clockid_t = 1; +pub const CLOCK_MONOTONIC: clockid_t = 4; + +pub const DT_UNKNOWN: u8 = 0; +pub const DT_FIFO: u8 = 1; +pub const DT_CHR: u8 = 2; +pub const DT_DIR: u8 = 4; +pub const DT_BLK: u8 = 6; +pub const DT_REG: u8 = 8; +pub const DT_LNK: u8 = 10; +pub const DT_SOCK: u8 = 12; +pub const DT_WHT: u8 = 14; + +pub const EAI_AGAIN: i32 = 2; +pub const EAI_BADFLAGS: i32 = 3; +pub const EAI_FAIL: i32 = 4; +pub const EAI_FAMILY: i32 = 5; +pub const EAI_MEMORY: i32 = 6; +pub const EAI_NODATA: i32 = 7; +pub const EAI_NONAME: i32 = 8; +pub const EAI_SERVICE: i32 = 9; +pub const EAI_SOCKTYPE: i32 = 10; +pub const EAI_SYSTEM: i32 = 11; +pub const EAI_OVERFLOW: i32 = 14; + +pub const EFD_SEMAPHORE: i16 = 0o1; +pub const EFD_NONBLOCK: i16 = 0o4000; +pub const EFD_CLOEXEC: i16 = 0o40000; + +pub const F_DUPFD: i32 = 0; +pub const F_GETFD: i32 = 1; +pub const F_SETFD: i32 = 2; +pub const F_GETFL: i32 = 3; +pub const F_SETFL: i32 = 4; + +pub const FD_CLOEXEC: i32 = 1; + +pub const FIONBIO: i32 = 0x8008667e; + +pub const FUTEX_RELATIVE_TIMEOUT: u32 = 1; + +pub const IP_TOS: i32 = 1; +pub const IP_TTL: i32 = 2; +pub const IP_ADD_MEMBERSHIP: i32 = 3; +pub const IP_DROP_MEMBERSHIP: i32 = 4; +pub const IP_MULTICAST_TTL: i32 = 5; +pub const IP_MULTICAST_LOOP: i32 = 7; + +pub const IPPROTO_IP: i32 = 0; +pub const IPPROTO_TCP: i32 = 6; +pub const IPPROTO_UDP: i32 = 17; +pub const IPPROTO_IPV6: i32 = 41; + +pub const IPV6_ADD_MEMBERSHIP: i32 = 12; +pub const IPV6_DROP_MEMBERSHIP: i32 = 13; +pub const IPV6_MULTICAST_LOOP: i32 = 19; +pub const IPV6_V6ONLY: i32 = 27; + +pub const MSG_PEEK: i32 = 1; + +pub const O_RDONLY: i32 = 0o0; +pub const O_WRONLY: i32 = 0o1; +pub const O_RDWR: i32 = 0o2; +pub const O_CREAT: i32 = 0o100; +pub const O_EXCL: i32 = 0o200; +pub const O_TRUNC: i32 = 0o1000; +pub const O_APPEND: i32 = 0o2000; +pub const O_NONBLOCK: i32 = 0o4000; +pub const O_DIRECTORY: i32 = 0o200000; + +pub const POLLIN: i16 = 0x1; +pub const POLLPRI: i16 = 0x2; +pub const POLLOUT: i16 = 0x4; +pub const POLLERR: i16 = 0x8; +pub const POLLHUP: i16 = 0x10; +pub const POLLNVAL: i16 = 0x20; +pub const POLLRDNORM: i16 = 0x040; +pub const POLLRDBAND: i16 = 0x080; +pub const POLLWRNORM: i16 = 0x0100; +pub const POLLWRBAND: i16 = 0x0200; +pub const POLLRDHUP: i16 = 0x2000; + +pub const S_IRWXU: mode_t = 0o0700; +pub const S_IRUSR: mode_t = 0o0400; +pub const S_IWUSR: mode_t = 0o0200; +pub const S_IXUSR: mode_t = 0o0100; +pub const S_IRWXG: mode_t = 0o0070; +pub const S_IRGRP: mode_t = 0o0040; +pub const S_IWGRP: mode_t = 0o0020; +pub const S_IXGRP: mode_t = 0o0010; +pub const S_IRWXO: mode_t = 0o0007; +pub const S_IROTH: mode_t = 0o0004; +pub const S_IWOTH: mode_t = 0o0002; +pub const S_IXOTH: mode_t = 0o0001; + +pub const S_IFMT: mode_t = 0o17_0000; +pub const S_IFSOCK: mode_t = 0o14_0000; +pub const S_IFLNK: mode_t = 0o12_0000; +pub const S_IFREG: mode_t = 0o10_0000; +pub const S_IFBLK: mode_t = 0o6_0000; +pub const S_IFDIR: mode_t = 0o4_0000; +pub const S_IFCHR: mode_t = 0o2_0000; +pub const S_IFIFO: mode_t = 0o1_0000; + +pub const SHUT_RD: i32 = 0; +pub const SHUT_WR: i32 = 1; +pub const SHUT_RDWR: i32 = 2; + +pub const SO_REUSEADDR: i32 = 0x0004; +pub const SO_KEEPALIVE: i32 = 0x0008; +pub const SO_BROADCAST: i32 = 0x0020; +pub const SO_LINGER: i32 = 0x0080; +pub const SO_SNDBUF: i32 = 0x1001; +pub const SO_RCVBUF: i32 = 0x1002; +pub const SO_SNDTIMEO: i32 = 0x1005; +pub const SO_RCVTIMEO: i32 = 0x1006; +pub const SO_ERROR: i32 = 0x1007; + +pub const SOCK_STREAM: i32 = 1; +pub const SOCK_DGRAM: i32 = 2; +pub const SOCK_NONBLOCK: i32 = 0o4000; +pub const SOCK_CLOEXEC: i32 = 0o40000; + +pub const SOL_SOCKET: i32 = 4095; + +pub const STDIN_FILENO: c_int = 0; +pub const STDOUT_FILENO: c_int = 1; +pub const STDERR_FILENO: c_int = 2; + +pub const TCP_NODELAY: i32 = 1; + +pub const EPERM: i32 = 1; +pub const ENOENT: i32 = 2; +pub const ESRCH: i32 = 3; +pub const EINTR: i32 = 4; +pub const EIO: i32 = 5; +pub const ENXIO: i32 = 6; +pub const E2BIG: i32 = 7; +pub const ENOEXEC: i32 = 8; +pub const EBADF: i32 = 9; +pub const ECHILD: i32 = 10; +pub const EAGAIN: i32 = 11; +pub const ENOMEM: i32 = 12; +pub const EACCES: i32 = 13; +pub const EFAULT: i32 = 14; +pub const ENOTBLK: i32 = 15; +pub const EBUSY: i32 = 16; +pub const EEXIST: i32 = 17; +pub const EXDEV: i32 = 18; +pub const ENODEV: i32 = 19; +pub const ENOTDIR: i32 = 20; +pub const EISDIR: i32 = 21; +pub const EINVAL: i32 = 22; +pub const ENFILE: i32 = 23; +pub const EMFILE: i32 = 24; +pub const ENOTTY: i32 = 25; +pub const ETXTBSY: i32 = 26; +pub const EFBIG: i32 = 27; +pub const ENOSPC: i32 = 28; +pub const ESPIPE: i32 = 29; +pub const EROFS: i32 = 30; +pub const EMLINK: i32 = 31; +pub const EPIPE: i32 = 32; +pub const EDOM: i32 = 33; +pub const ERANGE: i32 = 34; +pub const EDEADLK: i32 = 35; +pub const ENAMETOOLONG: i32 = 36; +pub const ENOLCK: i32 = 37; +pub const ENOSYS: i32 = 38; +pub const ENOTEMPTY: i32 = 39; +pub const ELOOP: i32 = 40; +pub const EWOULDBLOCK: i32 = EAGAIN; +pub const ENOMSG: i32 = 42; +pub const EIDRM: i32 = 43; +pub const ECHRNG: i32 = 44; +pub const EL2NSYNC: i32 = 45; +pub const EL3HLT: i32 = 46; +pub const EL3RST: i32 = 47; +pub const ELNRNG: i32 = 48; +pub const EUNATCH: i32 = 49; +pub const ENOCSI: i32 = 50; +pub const EL2HLT: i32 = 51; +pub const EBADE: i32 = 52; +pub const EBADR: i32 = 53; +pub const EXFULL: i32 = 54; +pub const ENOANO: i32 = 55; +pub const EBADRQC: i32 = 56; +pub const EBADSLT: i32 = 57; +pub const EDEADLOCK: i32 = EDEADLK; +pub const EBFONT: i32 = 59; +pub const ENOSTR: i32 = 60; +pub const ENODATA: i32 = 61; +pub const ETIME: i32 = 62; +pub const ENOSR: i32 = 63; +pub const ENONET: i32 = 64; +pub const ENOPKG: i32 = 65; +pub const EREMOTE: i32 = 66; +pub const ENOLINK: i32 = 67; +pub const EADV: i32 = 68; +pub const ESRMNT: i32 = 69; +pub const ECOMM: i32 = 70; +pub const EPROTO: i32 = 71; +pub const EMULTIHOP: i32 = 72; +pub const EDOTDOT: i32 = 73; +pub const EBADMSG: i32 = 74; +pub const EOVERFLOW: i32 = 75; +pub const ENOTUNIQ: i32 = 76; +pub const EBADFD: i32 = 77; +pub const EREMCHG: i32 = 78; +pub const ELIBACC: i32 = 79; +pub const ELIBBAD: i32 = 80; +pub const ELIBSCN: i32 = 81; +pub const ELIBMAX: i32 = 82; +pub const ELIBEXEC: i32 = 83; +pub const EILSEQ: i32 = 84; +pub const ERESTART: i32 = 85; +pub const ESTRPIPE: i32 = 86; +pub const EUSERS: i32 = 87; +pub const ENOTSOCK: i32 = 88; +pub const EDESTADDRREQ: i32 = 89; +pub const EMSGSIZE: i32 = 90; +pub const EPROTOTYPE: i32 = 91; +pub const ENOPROTOOPT: i32 = 92; +pub const EPROTONOSUPPORT: i32 = 93; +pub const ESOCKTNOSUPPORT: i32 = 94; +pub const EOPNOTSUPP: i32 = 95; +pub const EPFNOSUPPORT: i32 = 96; +pub const EAFNOSUPPORT: i32 = 97; +pub const EADDRINUSE: i32 = 98; +pub const EADDRNOTAVAIL: i32 = 99; +pub const ENETDOWN: i32 = 100; +pub const ENETUNREACH: i32 = 101; +pub const ENETRESET: i32 = 102; +pub const ECONNABORTED: i32 = 103; +pub const ECONNRESET: i32 = 104; +pub const ENOBUFS: i32 = 105; +pub const EISCONN: i32 = 106; +pub const ENOTCONN: i32 = 107; +pub const ESHUTDOWN: i32 = 108; +pub const ETOOMANYREFS: i32 = 109; +pub const ETIMEDOUT: i32 = 110; +pub const ECONNREFUSED: i32 = 111; +pub const EHOSTDOWN: i32 = 112; +pub const EHOSTUNREACH: i32 = 113; +pub const EALREADY: i32 = 114; +pub const EINPROGRESS: i32 = 115; +pub const ESTALE: i32 = 116; +pub const EUCLEAN: i32 = 117; +pub const ENOTNAM: i32 = 118; +pub const ENAVAIL: i32 = 119; +pub const EISNAM: i32 = 120; +pub const EREMOTEIO: i32 = 121; +pub const EDQUOT: i32 = 122; +pub const ENOMEDIUM: i32 = 123; +pub const EMEDIUMTYPE: i32 = 124; +pub const ECANCELED: i32 = 125; +pub const ENOKEY: i32 = 126; +pub const EKEYEXPIRED: i32 = 127; +pub const EKEYREVOKED: i32 = 128; +pub const EKEYREJECTED: i32 = 129; +pub const EOWNERDEAD: i32 = 130; +pub const ENOTRECOVERABLE: i32 = 131; +pub const ERFKILL: i32 = 132; +pub const EHWPOISON: i32 = 133; + +extern "C" { + #[link_name = "sys_alloc"] + pub fn alloc(size: usize, align: usize) -> *mut u8; + + #[link_name = "sys_alloc_zeroed"] + pub fn alloc_zeroed(size: usize, align: usize) -> *mut u8; + + #[link_name = "sys_realloc"] + pub fn realloc(ptr: *mut u8, size: usize, align: usize, new_size: usize) -> *mut u8; + + #[link_name = "sys_dealloc"] + pub fn dealloc(ptr: *mut u8, size: usize, align: usize); + + #[link_name = "sys_exit"] + pub fn exit(status: i32) -> !; + + #[link_name = "sys_abort"] + pub fn abort() -> !; + + #[link_name = "sys_errno"] + pub fn errno() -> i32; + + #[link_name = "sys_clock_gettime"] + pub fn clock_gettime(clockid: clockid_t, tp: *mut timespec) -> i32; + + #[link_name = "sys_nanosleep"] + pub fn nanosleep(req: *const timespec) -> i32; + + #[link_name = "sys_available_parallelism"] + pub fn available_parallelism() -> usize; + + #[link_name = "sys_futex_wait"] + pub fn futex_wait( + address: *mut u32, + expected: u32, + timeout: *const timespec, + flags: u32, + ) -> i32; + + #[link_name = "sys_futex_wake"] + pub fn futex_wake(address: *mut u32, count: i32) -> i32; + + #[link_name = "sys_stat"] + pub fn stat(path: *const c_char, stat: *mut stat) -> i32; + + #[link_name = "sys_fstat"] + pub fn fstat(fd: i32, stat: *mut stat) -> i32; + + #[link_name = "sys_lstat"] + pub fn lstat(path: *const c_char, stat: *mut stat) -> i32; + + #[link_name = "sys_open"] + pub fn open(path: *const c_char, flags: i32, mode: mode_t) -> i32; + + #[link_name = "sys_unlink"] + pub fn unlink(path: *const c_char) -> i32; + + #[link_name = "sys_mkdir"] + pub fn mkdir(path: *const c_char, mode: mode_t) -> i32; + + #[link_name = "sys_rmdir"] + pub fn rmdir(path: *const c_char) -> i32; + + #[link_name = "sys_read"] + pub fn read(fd: i32, buf: *mut u8, len: usize) -> isize; + + #[link_name = "sys_write"] + pub fn write(fd: i32, buf: *const u8, len: usize) -> isize; + + #[link_name = "sys_readv"] + pub fn readv(fd: i32, iov: *const iovec, iovcnt: usize) -> isize; + + #[link_name = "sys_writev"] + pub fn writev(fd: i32, iov: *const iovec, iovcnt: usize) -> isize; + + #[link_name = "sys_close"] + pub fn close(fd: i32) -> i32; + + #[link_name = "sys_dup"] + pub fn dup(fd: i32) -> i32; + + #[link_name = "sys_fcntl"] + pub fn fcntl(fd: i32, cmd: i32, arg: i32) -> i32; + + #[link_name = "sys_getdents64"] + pub fn getdents64(fd: i32, dirp: *mut dirent64, count: usize) -> isize; + + #[link_name = "sys_getaddrinfo"] + pub fn getaddrinfo( + nodename: *const c_char, + servname: *const c_char, + hints: *const addrinfo, + res: *mut *mut addrinfo, + ) -> i32; + + #[link_name = "sys_freeaddrinfo"] + pub fn freeaddrinfo(ai: *mut addrinfo); + + #[link_name = "sys_socket"] + pub fn socket(domain: i32, ty: i32, protocol: i32) -> i32; + + #[link_name = "sys_bind"] + pub fn bind(sockfd: i32, addr: *const sockaddr, addrlen: socklen_t) -> i32; + + #[link_name = "sys_listen"] + pub fn listen(sockfd: i32, backlog: i32) -> i32; + + #[link_name = "sys_accept"] + pub fn accept(sockfd: i32, addr: *mut sockaddr, addrlen: *mut socklen_t) -> i32; + + #[link_name = "sys_connect"] + pub fn connect(sockfd: i32, addr: *const sockaddr, addrlen: socklen_t) -> i32; + + #[link_name = "sys_recv"] + pub fn recv(sockfd: i32, buf: *mut u8, len: usize, flags: i32) -> isize; + + #[link_name = "sys_recvfrom"] + pub fn recvfrom( + sockfd: i32, + buf: *mut c_void, + len: usize, + flags: i32, + addr: *mut sockaddr, + addrlen: *mut socklen_t, + ) -> isize; + + #[link_name = "sys_send"] + pub fn send(sockfd: i32, buf: *const c_void, len: usize, flags: i32) -> isize; + + #[link_name = "sys_sendto"] + pub fn sendto( + sockfd: i32, + buf: *const c_void, + len: usize, + flags: i32, + to: *const sockaddr, + tolen: socklen_t, + ) -> isize; + + #[link_name = "sys_getpeername"] + pub fn getpeername(sockfd: i32, addr: *mut sockaddr, addrlen: *mut socklen_t) -> i32; + + #[link_name = "sys_getsockname"] + pub fn getsockname(sockfd: i32, addr: *mut sockaddr, addrlen: *mut socklen_t) -> i32; + + #[link_name = "sys_getsockopt"] + pub fn getsockopt( + sockfd: i32, + level: i32, + optname: i32, + optval: *mut c_void, + optlen: *mut socklen_t, + ) -> i32; + + #[link_name = "sys_setsockopt"] + pub fn setsockopt( + sockfd: i32, + level: i32, + optname: i32, + optval: *const c_void, + optlen: socklen_t, + ) -> i32; + + #[link_name = "sys_ioctl"] + pub fn ioctl(sockfd: i32, cmd: i32, argp: *mut c_void) -> i32; + + #[link_name = "sys_shutdown"] + pub fn shutdown(sockfd: i32, how: i32) -> i32; + + #[link_name = "sys_eventfd"] + pub fn eventfd(initval: u64, flags: i16) -> i32; + + #[link_name = "sys_poll"] + pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: i32) -> i32; +} diff --git a/http/vendor/libc/src/lib.rs b/http/vendor/libc/src/lib.rs new file mode 100644 index 0000000..a00de4e --- /dev/null +++ b/http/vendor/libc/src/lib.rs @@ -0,0 +1,168 @@ +//! libc - Raw FFI bindings to platforms' system libraries +#![crate_name = "libc"] +#![crate_type = "rlib"] +#![allow( + renamed_and_removed_lints, // Keep this order. + unknown_lints, // Keep this order. + nonstandard_style, + overflowing_literals, + unused_macros, + unused_macro_rules, +)] +#![warn( + missing_copy_implementations, + missing_debug_implementations, + safe_packed_borrows +)] +// Prepare for a future upgrade +#![warn(rust_2024_compatibility)] +// Things missing for 2024 that are blocked on MSRV or breakage +#![allow( + missing_unsafe_on_extern, + edition_2024_expr_fragment_specifier, + // Allowed globally, the warning is enabled in individual modules as we work through them + unsafe_op_in_unsafe_fn +)] +#![cfg_attr(libc_deny_warnings, deny(warnings))] +// Attributes needed when building as part of the standard library +#![cfg_attr(feature = "rustc-dep-of-std", feature(link_cfg, no_core))] +#![cfg_attr(feature = "rustc-dep-of-std", allow(internal_features))] +// Some targets don't need `link_cfg` and emit a warning. +#![cfg_attr(feature = "rustc-dep-of-std", allow(unused_features))] +// DIFF(1.0): The thread local references that raise this lint were removed in 1.0 +#![cfg_attr(feature = "rustc-dep-of-std", allow(static_mut_refs))] +#![cfg_attr(not(feature = "rustc-dep-of-std"), no_std)] +#![cfg_attr(feature = "rustc-dep-of-std", no_core)] + +#[macro_use] +mod macros; +mod new; + +cfg_if! { + if #[cfg(feature = "rustc-dep-of-std")] { + extern crate rustc_std_workspace_core as core; + } +} + +pub use core::ffi::c_void; + +#[allow(unused_imports)] // needed while the module is empty on some platforms +pub use new::*; + +cfg_if! { + if #[cfg(windows)] { + mod primitives; + pub use crate::primitives::*; + + mod windows; + pub use crate::windows::*; + + prelude!(); + } else if #[cfg(target_os = "fuchsia")] { + mod primitives; + pub use crate::primitives::*; + + mod fuchsia; + pub use crate::fuchsia::*; + + prelude!(); + } else if #[cfg(target_os = "switch")] { + mod primitives; + pub use primitives::*; + + mod switch; + pub use switch::*; + + prelude!(); + } else if #[cfg(target_os = "psp")] { + mod primitives; + pub use primitives::*; + + mod psp; + pub use crate::psp::*; + + prelude!(); + } else if #[cfg(target_os = "vxworks")] { + mod primitives; + pub use crate::primitives::*; + + mod vxworks; + pub use crate::vxworks::*; + + prelude!(); + } else if #[cfg(target_os = "qurt")] { + mod primitives; + pub use crate::primitives::*; + + mod qurt; + pub use crate::qurt::*; + + prelude!(); + } else if #[cfg(target_os = "solid_asp3")] { + mod primitives; + pub use crate::primitives::*; + + mod solid; + pub use crate::solid::*; + + prelude!(); + } else if #[cfg(unix)] { + mod primitives; + pub use crate::primitives::*; + + mod unix; + pub use crate::unix::*; + + prelude!(); + } else if #[cfg(target_os = "hermit")] { + mod primitives; + pub use crate::primitives::*; + + mod hermit; + pub use crate::hermit::*; + + prelude!(); + } else if #[cfg(target_os = "teeos")] { + mod primitives; + pub use primitives::*; + + mod teeos; + pub use teeos::*; + + prelude!(); + } else if #[cfg(target_os = "trusty")] { + mod primitives; + pub use crate::primitives::*; + + mod trusty; + pub use crate::trusty::*; + + prelude!(); + } else if #[cfg(all(target_env = "sgx", target_vendor = "fortanix"))] { + mod primitives; + pub use crate::primitives::*; + + mod sgx; + pub use crate::sgx::*; + + prelude!(); + } else if #[cfg(any(target_env = "wasi", target_os = "wasi"))] { + mod primitives; + pub use crate::primitives::*; + + mod wasi; + pub use crate::wasi::*; + + prelude!(); + } else if #[cfg(target_os = "xous")] { + mod primitives; + pub use crate::primitives::*; + + mod xous; + pub use crate::xous::*; + + prelude!(); + } else { + // non-supported targets: empty... + } +} diff --git a/http/vendor/libc/src/macros.rs b/http/vendor/libc/src/macros.rs new file mode 100644 index 0000000..2d2d390 --- /dev/null +++ b/http/vendor/libc/src/macros.rs @@ -0,0 +1,654 @@ +/// A macro for defining #[cfg] if-else statements. +/// +/// This is similar to the `if/elif` C preprocessor macro by allowing definition +/// of a cascade of `#[cfg]` cases, emitting the implementation which matches +/// first. +/// +/// This allows you to conveniently provide a long list #[cfg]'d blocks of code +/// without having to rewrite each clause multiple times. +macro_rules! cfg_if { + // match if/else chains with a final `else` + ($( + if #[cfg($($meta:meta),*)] { $($it:item)* } + ) else * else { + $($it2:item)* + }) => { + cfg_if! { + @__items + () ; + $( ( ($($meta),*) ($($it)*) ), )* + ( () ($($it2)*) ), + } + }; + + // match if/else chains lacking a final `else` + ( + if #[cfg($($i_met:meta),*)] { $($i_it:item)* } + $( + else if #[cfg($($e_met:meta),*)] { $($e_it:item)* } + )* + ) => { + cfg_if! { + @__items + () ; + ( ($($i_met),*) ($($i_it)*) ), + $( ( ($($e_met),*) ($($e_it)*) ), )* + ( () () ), + } + }; + + // Internal and recursive macro to emit all the items + // + // Collects all the negated `cfg`s in a list at the beginning and after the + // semicolon is all the remaining items + (@__items ($($not:meta,)*) ; ) => {}; + (@__items ($($not:meta,)*) ; ( ($($m:meta),*) ($($it:item)*) ), + $($rest:tt)*) => { + // Emit all items within one block, applying an appropriate #[cfg]. The + // #[cfg] will require all `$m` matchers specified and must also negate + // all previous matchers. + cfg_if! { @__apply cfg(all($($m,)* not(any($($not),*)))), $($it)* } + + // Recurse to emit all other items in `$rest`, and when we do so add all + // our `$m` matchers to the list of `$not` matchers as future emissions + // will have to negate everything we just matched as well. + cfg_if! { @__items ($($not,)* $($m,)*) ; $($rest)* } + }; + + // Internal macro to Apply a cfg attribute to a list of items + (@__apply $m:meta, $($it:item)*) => { + $(#[$m] $it)* + }; +} + +/// Create an internal crate prelude with `core` reexports and common types. +macro_rules! prelude { + () => { + mod types; + + /// Frequently-used types that are available on all platforms + /// + /// We need to reexport the core types so this works with `rust-dep-of-std`. + mod prelude { + // Exports from `core` + #[allow(unused_imports)] + pub(crate) use core::clone::Clone; + #[allow(unused_imports)] + pub(crate) use core::default::Default; + #[allow(unused_imports)] + pub(crate) use core::marker::{ + Copy, + Send, + Sync, + }; + #[allow(unused_imports)] + pub(crate) use core::option::Option; + #[allow(unused_imports)] + pub(crate) use core::prelude::v1::derive; + #[allow(unused_imports)] + pub(crate) use core::{ + cfg, + fmt, + hash, + iter, + mem, + ptr, + }; + + #[allow(unused_imports)] + pub(crate) use fmt::Debug; + #[allow(unused_imports)] + pub(crate) use mem::{ + align_of, + align_of_val, + size_of, + size_of_val, + }; + + #[allow(unused_imports)] + pub(crate) use crate::types::{ + CEnumRepr, + Padding, + }; + // Commonly used types defined in this crate + #[allow(unused_imports)] + pub(crate) use crate::{ + c_char, + c_double, + c_float, + c_int, + c_long, + c_longlong, + c_short, + c_uchar, + c_uint, + c_ulong, + c_ulonglong, + c_ushort, + c_void, + intptr_t, + size_t, + ssize_t, + uintptr_t, + }; + } + }; +} + +/// Implement `Clone`, `Copy`, and `Debug` for one or more structs, as well as `PartialEq`, `Eq`, +/// and `Hash` if the `extra_traits` feature is enabled. +/// +/// Also mark the type with `repr(C)`. +/// +/// Use [`s_no_extra_traits`] for structs where the `extra_traits` feature does not +/// make sense, and for unions. +macro_rules! s { + ($( + $(#[$attr:meta])* + $pub:vis $t:ident $i:ident { $($field:tt)* } + )*) => ($( + s!(it: $(#[$attr])* $pub $t $i { $($field)* }); + )*); + + (it: $(#[$attr:meta])* $pub:vis union $i:ident { $($field:tt)* }) => ( + compile_error!("unions cannot derive extra traits, use s_no_extra_traits instead"); + ); + + (it: $(#[$attr:meta])* $pub:vis struct $i:ident { $($field:tt)* }) => ( + #[repr(C)] + #[::core::prelude::v1::derive( + ::core::clone::Clone, + ::core::marker::Copy, + ::core::fmt::Debug, + )] + #[cfg_attr( + feature = "extra_traits", + ::core::prelude::v1::derive(PartialEq, Eq, Hash) + )] + #[allow(deprecated)] + $(#[$attr])* + $pub struct $i { $($field)* } + ); +} + +/// Implement `Clone`, `Copy`, and `Debug` for a tuple struct, as well as `PartialEq`, `Eq`, +/// and `Hash` if the `extra_traits` feature is enabled. +/// +/// Unlike `s!`, this does *not* mark the type with `repr(C)`. Users should provide their own +/// `repr` attribute via `$attr` as necessary. +macro_rules! s_paren { + ($( + $(#[$attr:meta])* + $pub:vis struct $i:ident ( $($field:tt)* ); + )*) => ($( + #[::core::prelude::v1::derive( + ::core::clone::Clone, + ::core::marker::Copy, + ::core::fmt::Debug, + )] + #[cfg_attr( + feature = "extra_traits", + ::core::prelude::v1::derive(PartialEq, Eq, Hash) + )] + $(#[$attr])* + $pub struct $i ( $($field)* ); + )*); +} + +/// Implement `Clone`, `Copy`, and `Debug` for one or more structs/unions, but exclude `PartialEq`, +/// `Eq`, and `Hash`. +/// +/// Also mark the type with `repr(C)`. +/// +/// Most structs will prefer to use [`s`]. +macro_rules! s_no_extra_traits { + ($( + $(#[$attr:meta])* + $pub:vis $t:ident $i:ident { $($field:tt)* } + )*) => ($( + s_no_extra_traits!(it: $(#[$attr])* $pub $t $i { $($field)* }); + )*); + + (it: $(#[$attr:meta])* $pub:vis union $i:ident { $($field:tt)* }) => ( + #[repr(C)] + #[::core::prelude::v1::derive( + ::core::clone::Clone, + ::core::marker::Copy, + )] + $(#[$attr])* + $pub union $i { $($field)* } + + impl ::core::fmt::Debug for $i { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct(::core::stringify!($i)).finish_non_exhaustive() + } + } + ); + + (it: $(#[$attr:meta])* $pub:vis struct $i:ident { $($field:tt)* }) => ( + #[repr(C)] + #[::core::prelude::v1::derive( + ::core::clone::Clone, + ::core::marker::Copy, + ::core::fmt::Debug, + )] + $(#[$attr])* + $pub struct $i { $($field)* } + ); +} + +/// Create an uninhabited type that can't be constructed. It implements `Debug`, `Clone`, +/// and `Copy`, but these aren't meaningful for extern types so they should eventually +/// be removed. +/// +/// Really what we want here is something that also can't be named without indirection (in +/// ADTs or function signatures), but this doesn't exist. +macro_rules! extern_ty { + ($( + $(#[$attr:meta])* + pub enum $i:ident {} + )*) => ($( + $(#[$attr])* + // FIXME(1.0): the type is uninhabited so these traits are unreachable and could be + // removed. + #[::core::prelude::v1::derive( + ::core::clone::Clone, + ::core::marker::Copy, + ::core::fmt::Debug, + )] + pub enum $i { } + )*); +} + +/// Implement `Clone` and `Copy` for an enum, as well as `Debug`, `Eq`, `Hash`, and +/// `PartialEq` if the `extra_traits` feature is enabled. +// FIXME(#4419): Replace all uses of `e!` with `c_enum!` +macro_rules! e { + ($( + $(#[$attr:meta])* + pub enum $i:ident { $($field:tt)* } + )*) => ($( + #[cfg_attr( + feature = "extra_traits", + ::core::prelude::v1::derive(Eq, Hash, PartialEq) + )] + #[::core::prelude::v1::derive( + ::core::clone::Clone, + ::core::marker::Copy, + ::core::fmt::Debug, + )] + $(#[$attr])* + pub enum $i { $($field)* } + )*); +} + +/// Represent a C enum as Rust constants and a type. +/// +/// C enums can't soundly be mapped to Rust enums since C enums are allowed to have duplicates or +/// unlisted values, but this is UB in Rust. This enum doesn't implement any traits, its main +/// purpose is to calculate the correct enum values. +/// +/// Use the magic name `#anon` if the C enum doesn't create a type. +/// +/// See for more. +macro_rules! c_enum { + // Matcher for multiple enums + ($( + $(#[repr($repr:ty)])? + pub enum $($ty_name:ident)? $(#$anon:ident)? { + $($vis:vis $variant:ident $(= $value:expr)?,)+ + } + )+) => { + $(c_enum!(@single; + $(#[repr($repr)])? + pub enum $($ty_name)? $(#$anon)? { + $($vis $variant $(= $value)?,)+ + } + );)+ + }; + + // Matcher for a single enum + (@single; + $(#[repr($repr:ty)])? + pub enum $ty_name:ident { + $($vis:vis $variant:ident $(= $value:expr)?,)+ + } + ) => { + pub type $ty_name = c_enum!(@ty $($repr)?); + c_enum! { + @variant; + ty: $ty_name; + default: 0; + variants: [$($vis $variant $(= $value)?,)+] + } + }; + + // Matcher for a single anonymous enum + (@single; + $(#[repr($repr:ty)])? + pub enum #anon { + $($vis:vis $variant:ident $(= $value:expr)?,)+ + } + ) => { + c_enum! { + @variant; + ty: c_enum!(@ty $($repr)?); + default: 0; + variants: [$($vis $variant $(= $value)?,)+] + } + }; + + // Matcher for variants: eats a single variant then recurses with the rest + (@variant; ty: $_ty_name:ty; default: $_idx:expr; variants: []) => { /* end of the chain */ }; + ( + @variant; + ty: $ty_name:ty; + default: $default_val:expr; + variants: [ + $vis:vis $variant:ident $(= $value:expr)?, + $($tail:tt)* + ] + ) => { + $vis const $variant: $ty_name = { + #[allow(unused_variables)] + let r = $default_val; + $(let r = $value;)? + r + }; + + // The next value is always one more than the previous value, unless + // set explicitly. + c_enum! { + @variant; + ty: $ty_name; + default: $variant + 1; + variants: [$($tail)*] + } + }; + + // Use a specific type if provided, otherwise default to `CEnumRepr` + (@ty $repr:ty) => { $repr }; + (@ty) => { $crate::prelude::CEnumRepr }; +} + +/// Define a `unsafe` function. +macro_rules! f { + ($( + $(#[$attr:meta])* + // Less than ideal hack to match either `fn` or `const fn`. + pub $(fn $i:ident)? $(const fn $const_i:ident)? + ($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty + $body:block + )+) => {$( + #[inline] + $(#[$attr])* + pub $(unsafe extern "C" fn $i)? $(const unsafe extern "C" fn $const_i)? + ($($arg: $argty),*) -> $ret + $body + )+}; +} + +/// Define a safe function. +macro_rules! safe_f { + ($( + $(#[$attr:meta])* + // Less than ideal hack to match either `fn` or `const fn`. + pub $(fn $i:ident)? $(const fn $const_i:ident)? + ($($arg:ident: $argty:ty),* $(,)*) -> $ret:ty + $body:block + )+) => {$( + #[inline] + $(#[$attr])* + pub $(extern "C" fn $i)? $(const extern "C" fn $const_i)? + ($($arg: $argty),*) -> $ret + $body + )+}; +} + +// This macro is used to deprecate items that should be accessed via the mach2 crate +macro_rules! deprecated_mach { + (pub const $id:ident: $ty:ty = $expr:expr;) => { + #[deprecated( + since = "0.2.55", + note = "Use the `mach2` crate instead", + )] + #[allow(deprecated)] + pub const $id: $ty = $expr; + }; + ($(pub const $id:ident: $ty:ty = $expr:expr;)*) => { + $( + deprecated_mach!( + pub const $id: $ty = $expr; + ); + )* + }; + (pub type $id:ident = $ty:ty;) => { + #[deprecated( + since = "0.2.55", + note = "Use the `mach2` crate instead", + )] + #[allow(deprecated)] + pub type $id = $ty; + }; + ($(pub type $id:ident = $ty:ty;)*) => { + $( + deprecated_mach!( + pub type $id = $ty; + ); + )* + } +} + +/// Polyfill for std's `offset_of`. +// FIXME(msrv): stabilized in std in 1.77 +macro_rules! offset_of { + ($Ty:path, $field:ident) => {{ + // Taken from bytemuck, avoids accidentally calling on deref + #[allow(clippy::unneeded_field_pattern)] + let $Ty { $field: _, .. }; + let data = core::mem::MaybeUninit::<$Ty>::uninit(); + let ptr = data.as_ptr(); + // nested unsafe, see f! + #[allow(unused_unsafe)] + // SAFETY: computed address is inbounds since we have a stack alloc for T + let fptr = unsafe { core::ptr::addr_of!((*ptr).$field) }; + let off = (fptr as usize).checked_sub(ptr as usize).unwrap(); + core::assert!(off <= core::mem::size_of::<$Ty>()); + off + }}; +} + +#[cfg(test)] +mod tests { + use core::any::TypeId; + + use crate::types::CEnumRepr; + + #[test] + fn c_enum_basic() { + // By default, variants get sequential values. + c_enum! { + pub enum e { + VAR0, + VAR1, + VAR2, + } + + // Also check enums that don't create a type. + pub enum #anon { + ANON0, + ANON1, + ANON2, + } + } + + assert_eq!(TypeId::of::(), TypeId::of::()); + assert_eq!(VAR0, 0 as CEnumRepr); + assert_eq!(VAR1, 1 as CEnumRepr); + assert_eq!(VAR2, 2 as CEnumRepr); + + assert_eq!(type_id_of_val(&ANON0), TypeId::of::()); + assert_eq!(ANON0, 0 as CEnumRepr); + assert_eq!(ANON1, 1 as CEnumRepr); + assert_eq!(ANON2, 2 as CEnumRepr); + } + + #[test] + fn c_enum_repr() { + // Check specifying the integer representation + c_enum! { + #[repr(u16)] + pub enum e { + VAR0, + } + + #[repr(u16)] + pub enum #anon { + ANON0, + } + } + + assert_eq!(TypeId::of::(), TypeId::of::()); + assert_eq!(VAR0, 0_u16); + + assert_eq!(type_id_of_val(&ANON0), TypeId::of::()); + assert_eq!(ANON0, 0_u16); + } + + #[test] + fn c_enum_set_value() { + // Setting an explicit value resets the count. + c_enum! { + pub enum e { + VAR2 = 2, + VAR3, + VAR4, + } + } + + assert_eq!(VAR2, 2 as CEnumRepr); + assert_eq!(VAR3, 3 as CEnumRepr); + assert_eq!(VAR4, 4 as CEnumRepr); + } + + #[test] + fn c_enum_multiple_set_value() { + // C enums always take one more than the previous value, unless set to a specific + // value. Duplicates are allowed. + c_enum! { + pub enum e { + VAR0, + VAR2_0 = 2, + VAR3_0, + VAR4_0, + VAR2_1 = 2, + VAR3_1, + VAR4_1, + } + } + + assert_eq!(VAR0, 0 as CEnumRepr); + assert_eq!(VAR2_0, 2 as CEnumRepr); + assert_eq!(VAR3_0, 3 as CEnumRepr); + assert_eq!(VAR4_0, 4 as CEnumRepr); + assert_eq!(VAR2_1, 2 as CEnumRepr); + assert_eq!(VAR3_1, 3 as CEnumRepr); + assert_eq!(VAR4_1, 4 as CEnumRepr); + } + + #[test] + fn c_enum_vis() { + mod priv1 { + c_enum! { + #[repr(u8)] + pub enum e1 { + PRIV_ON_1 = 10, + // Variant should still be usable within its visibility + pub PUB1 = PRIV_ON_1 * 2, + } + } + } + mod priv2 { + c_enum! { + #[repr(u16)] + pub enum e2 { + pub PRIV_ON_1 = 42, + pub PUB2 = PRIV_ON_1 * 2, + } + } + } + + use priv1::*; + use priv2::*; + + assert_eq!(TypeId::of::(), TypeId::of::()); + assert_eq!(TypeId::of::(), TypeId::of::()); + assert_eq!(PUB1, 10u8 * 2); + assert_eq!(PUB2, 42u16 * 2); + // Verify that the default is private. If `PRIV_ON_1` was actually public in `priv1`, this + // would be an ambiguous import and/or type mismatch error. + assert_eq!(PRIV_ON_1, 42u16); + } + + fn type_id_of_val(_: &T) -> TypeId { + TypeId::of::() + } + + #[test] + fn test_offset_of() { + #[repr(C)] + struct Off1 { + a: u8, + b: u32, + c: Off2, + d: u64, + } + + #[repr(C)] + #[repr(align(128))] + struct Off2 {} + + assert_eq!(core::mem::offset_of!(Off1, a), offset_of!(Off1, a)); + assert_eq!(core::mem::offset_of!(Off1, b), offset_of!(Off1, b)); + assert_eq!(core::mem::offset_of!(Off1, c), offset_of!(Off1, c)); + assert_eq!(core::mem::offset_of!(Off1, d), offset_of!(Off1, d)); + } +} + +#[cfg(test)] +#[allow(unused)] +mod macro_checks { + s! { + pub struct S1 { + pub a: u32, + b: u32, + } + + struct S1Priv { + pub a: u32, + b: u32, + } + } + + s_no_extra_traits! { + pub struct S2 { + pub a: u32, + b: u32, + } + + struct S2Priv { + pub a: u32, + b: u32, + } + + pub union U2 { + pub a: u32, + b: f32, + } + + union U2Priv { + pub a: u32, + b: f32, + } + } +} diff --git a/http/vendor/libc/src/new/aix/mod.rs b/http/vendor/libc/src/new/aix/mod.rs new file mode 100644 index 0000000..c99b206 --- /dev/null +++ b/http/vendor/libc/src/new/aix/mod.rs @@ -0,0 +1,6 @@ +//! IBM AIX libc. +//! +//! * Headers are not public +//! * Manual pages: (under "Technical reference" for that version) + +pub(crate) mod unistd; diff --git a/http/vendor/libc/src/new/aix/unistd.rs b/http/vendor/libc/src/new/aix/unistd.rs new file mode 100644 index 0000000..8d55ee5 --- /dev/null +++ b/http/vendor/libc/src/new/aix/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/http/vendor/libc/src/new/apple/libc/signal.rs b/http/vendor/libc/src/new/apple/libc/signal.rs new file mode 100644 index 0000000..b5f8d59 --- /dev/null +++ b/http/vendor/libc/src/new/apple/libc/signal.rs @@ -0,0 +1,5 @@ +//! Header: `signal.h` +//! +//! + +pub use crate::sys::signal::*; diff --git a/http/vendor/libc/src/new/apple/libc/unistd.rs b/http/vendor/libc/src/new/apple/libc/unistd.rs new file mode 100644 index 0000000..8d55ee5 --- /dev/null +++ b/http/vendor/libc/src/new/apple/libc/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/http/vendor/libc/src/new/apple/libpthread/mod.rs b/http/vendor/libc/src/new/apple/libpthread/mod.rs new file mode 100644 index 0000000..66f25e6 --- /dev/null +++ b/http/vendor/libc/src/new/apple/libpthread/mod.rs @@ -0,0 +1,20 @@ +//! Source from libpthread + +/// Directory: `pthread/` +/// +/// Note that this module has a trailing underscore to avoid conflicting with its child `pthread` +/// module. +/// +/// +pub(crate) mod pthread_ { + pub(crate) mod introspection; + pub(crate) mod pthread; + pub(crate) mod pthread_impl; + pub(crate) mod pthread_spis; + pub(crate) mod qos; + pub(crate) mod sched; + pub(crate) mod spawn; + pub(crate) mod stack_np; +} + +pub(crate) mod sys; diff --git a/http/vendor/libc/src/new/apple/libpthread/pthread_/introspection.rs b/http/vendor/libc/src/new/apple/libpthread/pthread_/introspection.rs new file mode 100644 index 0000000..6509e22 --- /dev/null +++ b/http/vendor/libc/src/new/apple/libpthread/pthread_/introspection.rs @@ -0,0 +1,36 @@ +//! Header: `pthread/introspection.h` +//! +//! + +use crate::prelude::*; +pub use crate::pthread_::pthread::*; + +c_enum! { + #[repr(c_uint)] + pub enum #anon { + pub PTHREAD_INTROSPECTION_THREAD_CREATE = 1, + pub PTHREAD_INTROSPECTION_THREAD_START, + pub PTHREAD_INTROSPECTION_THREAD_TERMINATE, + pub PTHREAD_INTROSPECTION_THREAD_DESTROY, + } +} + +pub type pthread_introspection_hook_t = + extern "C" fn(event: c_uint, thread: pthread_t, addr: *mut c_void, size: size_t); + +extern "C" { + // Available from Big Sur + pub fn pthread_introspection_hook_install( + hook: pthread_introspection_hook_t, + ) -> pthread_introspection_hook_t; + pub fn pthread_introspection_setspecific_np( + thread: pthread_t, + key: pthread_key_t, + value: *const c_void, + ) -> c_int; + + pub fn pthread_introspection_getspecific_np( + thread: pthread_t, + key: pthread_key_t, + ) -> *mut c_void; +} diff --git a/http/vendor/libc/src/new/apple/libpthread/pthread_/pthread.rs b/http/vendor/libc/src/new/apple/libpthread/pthread_/pthread.rs new file mode 100644 index 0000000..a7e56be --- /dev/null +++ b/http/vendor/libc/src/new/apple/libpthread/pthread_/pthread.rs @@ -0,0 +1,76 @@ +//! Header: `pthread.h` or `pthread/pthread.h` +//! +//! + +use crate::prelude::*; +pub use crate::pthread_::qos::*; +pub use crate::pthread_::sched::*; +// No need to import from the `_pthread_attr_t` and similar modules since `_pthread_types` has +// everything we need. +pub use crate::sys::_pthread::_pthread_types::*; + +pub const PTHREAD_CREATE_JOINABLE: c_int = 1; +pub const PTHREAD_CREATE_DETACHED: c_int = 2; + +pub const PTHREAD_INHERIT_SCHED: c_int = 1; +pub const PTHREAD_EXPLICIT_SCHED: c_int = 2; + +pub const PTHREAD_CANCEL_ENABLE: c_int = 0x01; +pub const PTHREAD_CANCEL_DISABLE: c_int = 0x00; +pub const PTHREAD_CANCEL_DEFERRED: c_int = 0x02; +pub const PTHREAD_CANCEL_ASYNCHRONOUS: c_int = 0x00; + +pub const PTHREAD_CANCELED: *mut c_void = 1 as *mut c_void; + +pub const PTHREAD_SCOPE_SYSTEM: c_int = 1; +pub const PTHREAD_SCOPE_PROCESS: c_int = 2; + +pub const PTHREAD_PROCESS_SHARED: c_int = 1; +pub const PTHREAD_PROCESS_PRIVATE: c_int = 2; + +pub const PTHREAD_PRIO_NONE: c_int = 0; +pub const PTHREAD_PRIO_INHERIT: c_int = 1; +pub const PTHREAD_PRIO_PROTECT: c_int = 2; + +pub const PTHREAD_MUTEX_NORMAL: c_int = 0; +pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 1; +pub const PTHREAD_MUTEX_RECURSIVE: c_int = 2; +pub const PTHREAD_MUTEX_DEFAULT: c_int = PTHREAD_MUTEX_NORMAL; + +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + __sig: _PTHREAD_RWLOCK_SIG_init, + __opaque: [0; __PTHREAD_RWLOCK_SIZE__], +}; + +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + __sig: _PTHREAD_MUTEX_SIG_init, + __opaque: [0; __PTHREAD_MUTEX_SIZE__], +}; + +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + __sig: _PTHREAD_COND_SIG_init, + __opaque: [0; __PTHREAD_COND_SIZE__], +}; + +pub const PTHREAD_ONCE_INIT: crate::pthread_once_t = crate::pthread_once_t { + __sig: _PTHREAD_ONCE_SIG_INIT, + __opaque: [0; __PTHREAD_ONCE_SIZE__], +}; + +pub use crate::new::common::posix::pthread::{ + pthread_attr_getinheritsched, + pthread_attr_getschedparam, + pthread_attr_getschedpolicy, + pthread_attr_setinheritsched, + pthread_attr_setschedparam, + pthread_attr_setschedpolicy, + pthread_condattr_getpshared, + pthread_condattr_setpshared, + pthread_getschedparam, + pthread_mutexattr_getpshared, + pthread_mutexattr_setpshared, + pthread_once, + pthread_rwlockattr_getpshared, + pthread_rwlockattr_setpshared, + pthread_setschedparam, +}; diff --git a/http/vendor/libc/src/new/apple/libpthread/pthread_/pthread_impl.rs b/http/vendor/libc/src/new/apple/libpthread/pthread_/pthread_impl.rs new file mode 100644 index 0000000..92c5e27 --- /dev/null +++ b/http/vendor/libc/src/new/apple/libpthread/pthread_/pthread_impl.rs @@ -0,0 +1,12 @@ +use crate::prelude::*; + +// FIXME(apple): these should all be `pub(crate)` +pub const _PTHREAD_MUTEX_SIG_init: c_long = 0x32AAABA7; + +pub const _PTHREAD_COND_SIG_init: c_long = 0x3CB0B1BB; +pub(crate) const _PTHREAD_ONCE_SIG_INIT: c_long = 0x30B1BCBA; +pub const _PTHREAD_RWLOCK_SIG_init: c_long = 0x2DA8B3B4; + +pub const SCHED_OTHER: c_int = 1; +pub const SCHED_FIFO: c_int = 4; +pub const SCHED_RR: c_int = 2; diff --git a/http/vendor/libc/src/new/apple/libpthread/pthread_/pthread_spis.rs b/http/vendor/libc/src/new/apple/libpthread/pthread_/pthread_spis.rs new file mode 100644 index 0000000..24e3fed --- /dev/null +++ b/http/vendor/libc/src/new/apple/libpthread/pthread_/pthread_spis.rs @@ -0,0 +1,14 @@ +//! Header: `pthread/pthread_spis.h` +//! +//! + +use crate::prelude::*; + +extern "C" { + pub fn pthread_create_from_mach_thread( + thread: *mut crate::pthread_t, + attr: *const crate::pthread_attr_t, + f: extern "C" fn(*mut c_void) -> *mut c_void, + value: *mut c_void, + ) -> c_int; +} diff --git a/http/vendor/libc/src/new/apple/libpthread/pthread_/qos.rs b/http/vendor/libc/src/new/apple/libpthread/pthread_/qos.rs new file mode 100644 index 0000000..8b68c78 --- /dev/null +++ b/http/vendor/libc/src/new/apple/libpthread/pthread_/qos.rs @@ -0,0 +1,25 @@ +//! Header: `pthread/qos.h` +//! +//! + +use crate::prelude::*; +pub use crate::sys::qos::*; + +extern "C" { + pub fn pthread_attr_set_qos_class_np( + attr: *mut crate::pthread_attr_t, + class: qos_class_t, + priority: c_int, + ) -> c_int; + pub fn pthread_attr_get_qos_class_np( + attr: *mut crate::pthread_attr_t, + class: *mut qos_class_t, + priority: *mut c_int, + ) -> c_int; + pub fn pthread_set_qos_class_self_np(class: qos_class_t, priority: c_int) -> c_int; + pub fn pthread_get_qos_class_np( + thread: crate::pthread_t, + class: *mut qos_class_t, + priority: *mut c_int, + ) -> c_int; +} diff --git a/http/vendor/libc/src/new/apple/libpthread/pthread_/sched.rs b/http/vendor/libc/src/new/apple/libpthread/pthread_/sched.rs new file mode 100644 index 0000000..d25a6cb --- /dev/null +++ b/http/vendor/libc/src/new/apple/libpthread/pthread_/sched.rs @@ -0,0 +1,9 @@ +pub use crate::new::pthread_::pthread_impl::*; +use crate::prelude::*; + +s! { + pub struct sched_param { + pub sched_priority: c_int, + __opaque: [c_char; 4], + } +} diff --git a/http/vendor/libc/src/new/apple/libpthread/pthread_/spawn.rs b/http/vendor/libc/src/new/apple/libpthread/pthread_/spawn.rs new file mode 100644 index 0000000..c5bdb7a --- /dev/null +++ b/http/vendor/libc/src/new/apple/libpthread/pthread_/spawn.rs @@ -0,0 +1,16 @@ +//! Header: `pthread/spawn.h` +//! +//! + +use crate::prelude::*; + +extern "C" { + pub fn posix_spawnattr_set_qos_class_np( + attr: *mut crate::posix_spawnattr_t, + qos_class: crate::qos_class_t, + ) -> c_int; + pub fn posix_spawnattr_get_qos_class_np( + attr: *const crate::posix_spawnattr_t, + qos_class: *mut crate::qos_class_t, + ) -> c_int; +} diff --git a/http/vendor/libc/src/new/apple/libpthread/pthread_/stack_np.rs b/http/vendor/libc/src/new/apple/libpthread/pthread_/stack_np.rs new file mode 100644 index 0000000..0d501cd --- /dev/null +++ b/http/vendor/libc/src/new/apple/libpthread/pthread_/stack_np.rs @@ -0,0 +1,12 @@ +//! Header: `pthread/stack_np.h` +//! +//! + +use crate::prelude::*; + +extern "C" { + pub fn pthread_stack_frame_decode_np( + frame_addr: uintptr_t, + return_addr: *mut uintptr_t, + ) -> uintptr_t; +} diff --git a/http/vendor/libc/src/new/apple/libpthread/sys/_pthread/_pthread_types.rs b/http/vendor/libc/src/new/apple/libpthread/sys/_pthread/_pthread_types.rs new file mode 100644 index 0000000..95e181c --- /dev/null +++ b/http/vendor/libc/src/new/apple/libpthread/sys/_pthread/_pthread_types.rs @@ -0,0 +1,79 @@ +//! Header: `sys/_pthread/_pthread_types.h` +//! +//! +//! +//! Note that the actual header defines `_opaque_pthread_*` structs which are typedefed to +//! `__darwin_pthread*` structs, and typedefed again in separate `_pthread_*.h` files to their final +//! `pthread_` name. This isn't useful for us so we simplify a bit and just define everything here. + +use crate::prelude::*; + +cfg_if! { + if #[cfg(target_pointer_width = "64")] { + pub const __PTHREAD_SIZE__: usize = 8176; + pub const __PTHREAD_ATTR_SIZE__: usize = 56; + pub const __PTHREAD_MUTEXATTR_SIZE__: usize = 8; + pub const __PTHREAD_MUTEX_SIZE__: usize = 56; + pub const __PTHREAD_CONDATTR_SIZE__: usize = 8; + pub const __PTHREAD_COND_SIZE__: usize = 40; + pub const __PTHREAD_ONCE_SIZE__: usize = 8; + pub const __PTHREAD_RWLOCK_SIZE__: usize = 192; + pub const __PTHREAD_RWLOCKATTR_SIZE__: usize = 16; + } else { + pub const __PTHREAD_SIZE__: usize = 4088; + pub const __PTHREAD_ATTR_SIZE__: usize = 36; + pub const __PTHREAD_MUTEXATTR_SIZE__: usize = 8; + pub const __PTHREAD_MUTEX_SIZE__: usize = 40; + pub const __PTHREAD_CONDATTR_SIZE__: usize = 4; + pub const __PTHREAD_COND_SIZE__: usize = 24; + pub const __PTHREAD_ONCE_SIZE__: usize = 4; + pub const __PTHREAD_RWLOCK_SIZE__: usize = 124; + pub const __PTHREAD_RWLOCKATTR_SIZE__: usize = 12; + } +} + +s! { + pub struct pthread_attr_t { + pub(crate) __sig: c_long, + pub(crate) __opaque: [c_char; __PTHREAD_ATTR_SIZE__], + } + + pub struct pthread_cond_t { + pub(crate) __sig: c_long, + pub(crate) __opaque: [u8; __PTHREAD_COND_SIZE__], + } + + pub struct pthread_condattr_t { + pub(crate) __sig: c_long, + pub(crate) __opaque: [u8; __PTHREAD_CONDATTR_SIZE__], + } + + pub struct pthread_mutex_t { + pub(crate) __sig: c_long, + pub(crate) __opaque: [u8; __PTHREAD_MUTEX_SIZE__], + } + + pub struct pthread_mutexattr_t { + pub(crate) __sig: c_long, + pub(crate) __opaque: [u8; __PTHREAD_MUTEXATTR_SIZE__], + } + + pub struct pthread_once_t { + pub(crate) __sig: c_long, + pub(crate) __opaque: [c_char; __PTHREAD_ONCE_SIZE__], + } + + pub struct pthread_rwlock_t { + pub(crate) __sig: c_long, + pub(crate) __opaque: [u8; __PTHREAD_RWLOCK_SIZE__], + } + + pub struct pthread_rwlockattr_t { + pub(crate) __sig: c_long, + pub(crate) __opaque: [u8; __PTHREAD_RWLOCKATTR_SIZE__], + } +} + +pub type pthread_key_t = c_ulong; + +pub use crate::pthread_t; diff --git a/http/vendor/libc/src/new/apple/libpthread/sys/mod.rs b/http/vendor/libc/src/new/apple/libpthread/sys/mod.rs new file mode 100644 index 0000000..da0a229 --- /dev/null +++ b/http/vendor/libc/src/new/apple/libpthread/sys/mod.rs @@ -0,0 +1,14 @@ +//! Directory: `sys/` +//! +//! + +/// Directory: `sys/_pthread/` +/// +/// +pub(crate) mod _pthread { + // We don't have the `_pthread_attr_t` and similar modules to match `_pthread_attr_t.h`, + // everything is defined in `_pthread_types`. + pub(crate) mod _pthread_types; +} + +pub(crate) mod qos; diff --git a/http/vendor/libc/src/new/apple/libpthread/sys/qos.rs b/http/vendor/libc/src/new/apple/libpthread/sys/qos.rs new file mode 100644 index 0000000..9d9a2eb --- /dev/null +++ b/http/vendor/libc/src/new/apple/libpthread/sys/qos.rs @@ -0,0 +1,22 @@ +//! Header: `sys/qos.h` +//! +//! + +use crate::prelude::*; + +#[derive(Debug)] +#[repr(u32)] +pub enum qos_class_t { + QOS_CLASS_USER_INTERACTIVE = 0x21, + QOS_CLASS_USER_INITIATED = 0x19, + QOS_CLASS_DEFAULT = 0x15, + QOS_CLASS_UTILITY = 0x11, + QOS_CLASS_BACKGROUND = 0x09, + QOS_CLASS_UNSPECIFIED = 0x00, +} +impl Copy for qos_class_t {} +impl Clone for qos_class_t { + fn clone(&self) -> qos_class_t { + *self + } +} diff --git a/http/vendor/libc/src/new/apple/mod.rs b/http/vendor/libc/src/new/apple/mod.rs new file mode 100644 index 0000000..beb8caa --- /dev/null +++ b/http/vendor/libc/src/new/apple/mod.rs @@ -0,0 +1,20 @@ +//! Apple interfaces. +//! +//! The Xcode SDK includes interfaces that are split across a couple of different libraries. Most +//! of these are available at . + +/// Entrypoint for Apple headers, usually found as part of the Xcode SDK. +/// +/// +mod libc { + pub(crate) mod signal; + pub(crate) mod unistd; +} + +mod libpthread; +mod xnu; + +pub(crate) use libc::*; +pub(crate) use libpthread::pthread_; +pub(crate) use pthread_::pthread; +pub(crate) use xnu::*; diff --git a/http/vendor/libc/src/new/apple/xnu/arm/_mcontext.rs b/http/vendor/libc/src/new/apple/xnu/arm/_mcontext.rs new file mode 100644 index 0000000..ae22f7a --- /dev/null +++ b/http/vendor/libc/src/new/apple/xnu/arm/_mcontext.rs @@ -0,0 +1,15 @@ +//! Header: `arm/_mcontext.h` +//! +//! + +pub use crate::mach::machine::_structs::*; + +s! { + pub struct __darwin_mcontext64 { + pub __es: __darwin_arm_exception_state64, + pub __ss: __darwin_arm_thread_state64, + pub __ns: __darwin_arm_neon_state64, + } +} + +pub type mcontext_t = *mut __darwin_mcontext64; diff --git a/http/vendor/libc/src/new/apple/xnu/i386/_mcontext.rs b/http/vendor/libc/src/new/apple/xnu/i386/_mcontext.rs new file mode 100644 index 0000000..2b07ad1 --- /dev/null +++ b/http/vendor/libc/src/new/apple/xnu/i386/_mcontext.rs @@ -0,0 +1,15 @@ +//! Header: `i386/_mcontext.h` +//! +//! + +pub use crate::mach::machine::_structs::*; + +s! { + pub struct __darwin_mcontext64 { + pub __es: __darwin_x86_exception_state64, + pub __ss: __darwin_x86_thread_state64, + pub __fs: __darwin_x86_float_state64, + } +} + +pub type mcontext_t = *mut __darwin_mcontext64; diff --git a/http/vendor/libc/src/new/apple/xnu/mach/arm/_structs.rs b/http/vendor/libc/src/new/apple/xnu/mach/arm/_structs.rs new file mode 100644 index 0000000..6160e77 --- /dev/null +++ b/http/vendor/libc/src/new/apple/xnu/mach/arm/_structs.rs @@ -0,0 +1,37 @@ +//! Header: `arm/_structs.h` +//! +//! + +#[cfg(target_arch = "arm")] +use crate::prelude::*; + +s! { + pub struct __darwin_arm_exception_state64 { + pub __far: u64, + pub __esr: u32, + pub __exception: u32, + } + + pub struct __darwin_arm_thread_state64 { + pub __x: [u64; 29], + pub __fp: u64, + pub __lr: u64, + pub __sp: u64, + pub __pc: u64, + pub __cpsr: u32, + pub __pad: u32, + } + + #[cfg(target_arch = "aarch64")] + pub struct __darwin_arm_neon_state64 { + pub __v: [u128; 32], + pub __fpsr: u32, + pub __fpcr: u32, + } + + #[cfg(target_arch = "arm")] + #[repr(align(16))] + pub struct __darwin_arm_neon_state64 { + opaque: [c_char; (32 * 16) + (2 * size_of::())], + } +} diff --git a/http/vendor/libc/src/new/apple/xnu/mach/i386/_structs.rs b/http/vendor/libc/src/new/apple/xnu/mach/i386/_structs.rs new file mode 100644 index 0000000..15822f7 --- /dev/null +++ b/http/vendor/libc/src/new/apple/xnu/mach/i386/_structs.rs @@ -0,0 +1,92 @@ +//! Header: `i386/_structs.h` +//! +//! + +use crate::prelude::*; + +s! { + pub struct __darwin_mmst_reg { + pub __mmst_reg: [c_char; 10], + pub __mmst_rsrv: [c_char; 6], + } + + pub struct __darwin_xmm_reg { + pub __xmm_reg: [c_char; 16], + } + + pub struct __darwin_x86_thread_state64 { + pub __rax: u64, + pub __rbx: u64, + pub __rcx: u64, + pub __rdx: u64, + pub __rdi: u64, + pub __rsi: u64, + pub __rbp: u64, + pub __rsp: u64, + pub __r8: u64, + pub __r9: u64, + pub __r10: u64, + pub __r11: u64, + pub __r12: u64, + pub __r13: u64, + pub __r14: u64, + pub __r15: u64, + pub __rip: u64, + pub __rflags: u64, + pub __cs: u64, + pub __fs: u64, + pub __gs: u64, + } + + pub struct __darwin_x86_exception_state64 { + pub __trapno: u16, + pub __cpu: u16, + pub __err: u32, + pub __faultvaddr: u64, + } + + pub struct __darwin_x86_float_state64 { + pub __fpu_reserved: [c_int; 2], + __fpu_fcw: c_short, + __fpu_fsw: c_short, + pub __fpu_ftw: u8, + pub __fpu_rsrv1: u8, + pub __fpu_fop: u16, + pub __fpu_ip: u32, + pub __fpu_cs: u16, + pub __fpu_rsrv2: u16, + pub __fpu_dp: u32, + pub __fpu_ds: u16, + pub __fpu_rsrv3: u16, + pub __fpu_mxcsr: u32, + pub __fpu_mxcsrmask: u32, + pub __fpu_stmm0: __darwin_mmst_reg, + pub __fpu_stmm1: __darwin_mmst_reg, + pub __fpu_stmm2: __darwin_mmst_reg, + pub __fpu_stmm3: __darwin_mmst_reg, + pub __fpu_stmm4: __darwin_mmst_reg, + pub __fpu_stmm5: __darwin_mmst_reg, + pub __fpu_stmm6: __darwin_mmst_reg, + pub __fpu_stmm7: __darwin_mmst_reg, + pub __fpu_xmm0: __darwin_xmm_reg, + pub __fpu_xmm1: __darwin_xmm_reg, + pub __fpu_xmm2: __darwin_xmm_reg, + pub __fpu_xmm3: __darwin_xmm_reg, + pub __fpu_xmm4: __darwin_xmm_reg, + pub __fpu_xmm5: __darwin_xmm_reg, + pub __fpu_xmm6: __darwin_xmm_reg, + pub __fpu_xmm7: __darwin_xmm_reg, + pub __fpu_xmm8: __darwin_xmm_reg, + pub __fpu_xmm9: __darwin_xmm_reg, + pub __fpu_xmm10: __darwin_xmm_reg, + pub __fpu_xmm11: __darwin_xmm_reg, + pub __fpu_xmm12: __darwin_xmm_reg, + pub __fpu_xmm13: __darwin_xmm_reg, + pub __fpu_xmm14: __darwin_xmm_reg, + pub __fpu_xmm15: __darwin_xmm_reg, + // FIXME(apple): this field is actually [u8; 96], but defining it with a bigger type allows + // us to auto-implement traits for it since the length of the array is less than 32 + __fpu_rsrv4: [u32; 24], + pub __fpu_reserved1: c_int, + } +} diff --git a/http/vendor/libc/src/new/apple/xnu/mach/machine/_structs.rs b/http/vendor/libc/src/new/apple/xnu/mach/machine/_structs.rs new file mode 100644 index 0000000..6acae8d --- /dev/null +++ b/http/vendor/libc/src/new/apple/xnu/mach/machine/_structs.rs @@ -0,0 +1,13 @@ +//! Header: `mach/machine/_structs.h` +//! +//! + +cfg_if! { + if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { + pub use crate::mach::i386::_structs::*; + } else if #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] { + pub use crate::mach::arm::_structs::*; + } else { + // Unsupported arch + } +} diff --git a/http/vendor/libc/src/new/apple/xnu/mach/mod.rs b/http/vendor/libc/src/new/apple/xnu/mach/mod.rs new file mode 100644 index 0000000..9075126 --- /dev/null +++ b/http/vendor/libc/src/new/apple/xnu/mach/mod.rs @@ -0,0 +1,20 @@ +//! Directory: `mach/` +//! +//! + +/// Directory: `mach/arm` +#[cfg(any(target_arch = "arm", target_arch = "aarch64"))] +pub(crate) mod arm { + pub(crate) mod _structs; +} + +/// Directory: `mach/i386` +#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +pub(crate) mod i386 { + pub(crate) mod _structs; +} + +/// Directory: `mach/machine` +pub(crate) mod machine { + pub(crate) mod _structs; +} diff --git a/http/vendor/libc/src/new/apple/xnu/machine/_mcontext.rs b/http/vendor/libc/src/new/apple/xnu/machine/_mcontext.rs new file mode 100644 index 0000000..004b947 --- /dev/null +++ b/http/vendor/libc/src/new/apple/xnu/machine/_mcontext.rs @@ -0,0 +1,11 @@ +//! Header: `machine/_mcontext.h` + +cfg_if! { + if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { + pub use crate::i386::_mcontext::*; + } else if #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] { + pub use crate::arm::_mcontext::*; + } else { + // Unsupported arch + } +} diff --git a/http/vendor/libc/src/new/apple/xnu/mod.rs b/http/vendor/libc/src/new/apple/xnu/mod.rs new file mode 100644 index 0000000..8b8afb6 --- /dev/null +++ b/http/vendor/libc/src/new/apple/xnu/mod.rs @@ -0,0 +1,30 @@ +//! Source from XNU +//! +//! We omit nesting for the `bsd` module since most items of interest are in there. + +/// Directory: `arm/` +/// +/// https://github.com/apple-oss-distributions/xnu/tree/main/bsd/arm +#[cfg(any(target_arch = "arm", target_arch = "aarch64"))] +pub(crate) mod arm { + pub(crate) mod _mcontext; +} + +/// Directory: `i386/` +/// +/// https://github.com/apple-oss-distributions/xnu/tree/main/bsd/i386 +#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +pub(crate) mod i386 { + pub(crate) mod _mcontext; +} + +pub(crate) mod mach; + +/// Directory: `machine/` +/// +/// https://github.com/apple-oss-distributions/xnu/tree/main/bsd/machine +pub(crate) mod machine { + pub(crate) mod _mcontext; +} + +pub(crate) mod sys; diff --git a/http/vendor/libc/src/new/apple/xnu/sys/_types/_ucontext.rs b/http/vendor/libc/src/new/apple/xnu/sys/_types/_ucontext.rs new file mode 100644 index 0000000..53bc0f2 --- /dev/null +++ b/http/vendor/libc/src/new/apple/xnu/sys/_types/_ucontext.rs @@ -0,0 +1,17 @@ +//! Header: `sys/_types/_ucontext.h` + +pub use crate::machine::_mcontext::*; +use crate::prelude::*; + +s! { + pub struct __darwin_ucontext { + pub uc_onstack: c_int, + pub uc_sigmask: crate::sigset_t, + pub uc_stack: crate::stack_t, + pub uc_link: *mut ucontext_t, + pub uc_mcsize: usize, + pub uc_mcontext: mcontext_t, + } +} + +pub type ucontext_t = __darwin_ucontext; diff --git a/http/vendor/libc/src/new/apple/xnu/sys/mod.rs b/http/vendor/libc/src/new/apple/xnu/sys/mod.rs new file mode 100644 index 0000000..ad4a204 --- /dev/null +++ b/http/vendor/libc/src/new/apple/xnu/sys/mod.rs @@ -0,0 +1,15 @@ +//! Directory: `sys/` +//! +//! + +pub(crate) mod signal; + +/// Directory: `sys/_types` +/// +/// https://github.com/apple-oss-distributions/xnu/tree/main/bsd/sys/_types +pub(crate) mod _types { + pub(crate) mod _ucontext; +} + +// Bit of a hack since the directories get merged and we can't have >1 sys module. +pub(crate) use crate::new::apple::libpthread::sys::*; diff --git a/http/vendor/libc/src/new/apple/xnu/sys/signal.rs b/http/vendor/libc/src/new/apple/xnu/sys/signal.rs new file mode 100644 index 0000000..844793e --- /dev/null +++ b/http/vendor/libc/src/new/apple/xnu/sys/signal.rs @@ -0,0 +1,6 @@ +//! Header: `sys/signal.h` +//! +//! + +pub use crate::machine::_mcontext::*; +pub use crate::sys::_types::_ucontext::*; diff --git a/http/vendor/libc/src/new/bionic_libc/mod.rs b/http/vendor/libc/src/new/bionic_libc/mod.rs new file mode 100644 index 0000000..1dd186e --- /dev/null +++ b/http/vendor/libc/src/new/bionic_libc/mod.rs @@ -0,0 +1,7 @@ +//! This directory maps to `bionic/libc/include` in the Android source. +//! +//! + +pub(crate) mod pthread; +pub(crate) mod sys; +pub(crate) mod unistd; diff --git a/http/vendor/libc/src/new/bionic_libc/pthread.rs b/http/vendor/libc/src/new/bionic_libc/pthread.rs new file mode 100644 index 0000000..4997547 --- /dev/null +++ b/http/vendor/libc/src/new/bionic_libc/pthread.rs @@ -0,0 +1,42 @@ +//! Header: `unistd.h` + +pub use crate::new::common::linux_like::pthread::{ + pthread_getattr_np, + pthread_setname_np, +}; +pub use crate::new::common::posix::pthread::{ + pthread_atfork, + pthread_attr_getguardsize, + pthread_attr_getinheritsched, + pthread_attr_getstack, + pthread_attr_setguardsize, + pthread_attr_setinheritsched, + pthread_attr_setstack, + pthread_barrier_destroy, + pthread_barrier_init, + pthread_barrier_wait, + pthread_barrierattr_destroy, + pthread_barrierattr_getpshared, + pthread_barrierattr_init, + pthread_barrierattr_setpshared, + pthread_condattr_getclock, + pthread_condattr_getpshared, + pthread_condattr_setclock, + pthread_condattr_setpshared, + pthread_create, + pthread_getcpuclockid, + pthread_getschedparam, + pthread_kill, + pthread_mutex_timedlock, + pthread_mutexattr_getpshared, + pthread_mutexattr_setpshared, + pthread_rwlockattr_getpshared, + pthread_rwlockattr_setpshared, + pthread_setschedparam, + pthread_sigmask, + pthread_spin_destroy, + pthread_spin_init, + pthread_spin_lock, + pthread_spin_trylock, + pthread_spin_unlock, +}; diff --git a/http/vendor/libc/src/new/bionic_libc/sys/mod.rs b/http/vendor/libc/src/new/bionic_libc/sys/mod.rs new file mode 100644 index 0000000..a882cbd --- /dev/null +++ b/http/vendor/libc/src/new/bionic_libc/sys/mod.rs @@ -0,0 +1,3 @@ +//! Directory: `sys/` + +pub(crate) mod socket; diff --git a/http/vendor/libc/src/new/bionic_libc/sys/socket.rs b/http/vendor/libc/src/new/bionic_libc/sys/socket.rs new file mode 100644 index 0000000..c4a4e78 --- /dev/null +++ b/http/vendor/libc/src/new/bionic_libc/sys/socket.rs @@ -0,0 +1,51 @@ +//! Header: `sys/socket.h` + +use crate::prelude::*; + +s! { + pub struct msghdr { + pub msg_name: *mut c_void, + pub msg_namelen: crate::socklen_t, + pub msg_iov: *mut crate::iovec, + pub msg_iovlen: size_t, + pub msg_control: *mut c_void, + pub msg_controllen: size_t, + pub msg_flags: c_int, + } + + pub struct cmsghdr { + pub cmsg_len: size_t, + pub cmsg_level: c_int, + pub cmsg_type: c_int, + } + + pub struct ucred { + pub pid: crate::pid_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + } +} + +extern "C" { + pub fn recvmmsg( + sockfd: c_int, + msgvec: *mut crate::mmsghdr, + vlen: c_uint, + flags: c_int, + timeout: *const crate::timespec, + ) -> c_int; + pub fn sendmmsg( + sockfd: c_int, + msgvec: *const crate::mmsghdr, + vlen: c_uint, + flags: c_int, + ) -> c_int; + pub fn recvfrom( + socket: c_int, + buf: *mut c_void, + len: size_t, + flags: c_int, + addr: *mut crate::sockaddr, + addrlen: *mut crate::socklen_t, + ) -> ssize_t; +} diff --git a/http/vendor/libc/src/new/bionic_libc/unistd.rs b/http/vendor/libc/src/new/bionic_libc/unistd.rs new file mode 100644 index 0000000..8d55ee5 --- /dev/null +++ b/http/vendor/libc/src/new/bionic_libc/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/http/vendor/libc/src/new/common/bsd.rs b/http/vendor/libc/src/new/common/bsd.rs new file mode 100644 index 0000000..818daf9 --- /dev/null +++ b/http/vendor/libc/src/new/common/bsd.rs @@ -0,0 +1 @@ +//! Interfaces common across the BSD family. diff --git a/http/vendor/libc/src/new/common/freebsd_like.rs b/http/vendor/libc/src/new/common/freebsd_like.rs new file mode 100644 index 0000000..f49f2c9 --- /dev/null +++ b/http/vendor/libc/src/new/common/freebsd_like.rs @@ -0,0 +1 @@ +//! Interfaces common in FreeBSD-derived operating systems. This includes FreeBSD and DragonFlyBSD. diff --git a/http/vendor/libc/src/new/common/linux_like/mod.rs b/http/vendor/libc/src/new/common/linux_like/mod.rs new file mode 100644 index 0000000..9c41fe2 --- /dev/null +++ b/http/vendor/libc/src/new/common/linux_like/mod.rs @@ -0,0 +1,9 @@ +//! API that primarily comes from Linux but is also used other platforms (e.g. Android). + +#[cfg(any( + target_os = "android", + target_os = "emscripten", + target_os = "l4re", + target_os = "linux" +))] +pub(crate) mod pthread; diff --git a/http/vendor/libc/src/new/common/linux_like/pthread.rs b/http/vendor/libc/src/new/common/linux_like/pthread.rs new file mode 100644 index 0000000..b54d385 --- /dev/null +++ b/http/vendor/libc/src/new/common/linux_like/pthread.rs @@ -0,0 +1,25 @@ +use crate::prelude::*; + +extern "C" { + #[cfg(any(target_os = "linux", target_os = "l4re"))] + pub fn pthread_getaffinity_np( + thread: crate::pthread_t, + cpusetsize: size_t, + cpuset: *mut crate::cpu_set_t, + ) -> c_int; + + pub fn pthread_getattr_np(native: crate::pthread_t, attr: *mut crate::pthread_attr_t) -> c_int; + + #[cfg(target_os = "linux")] + pub fn pthread_getname_np(thread: crate::pthread_t, name: *mut c_char, len: size_t) -> c_int; + + #[cfg(any(target_os = "linux", target_os = "l4re"))] + pub fn pthread_setaffinity_np( + thread: crate::pthread_t, + cpusetsize: size_t, + cpuset: *const crate::cpu_set_t, + ) -> c_int; + + #[cfg(any(target_os = "android", target_os = "linux"))] + pub fn pthread_setname_np(thread: crate::pthread_t, name: *const c_char) -> c_int; +} diff --git a/http/vendor/libc/src/new/common/mod.rs b/http/vendor/libc/src/new/common/mod.rs new file mode 100644 index 0000000..acb1891 --- /dev/null +++ b/http/vendor/libc/src/new/common/mod.rs @@ -0,0 +1,39 @@ +//! Interfaces that are common across multiple platforms +//! +//! We make these available everywhere but each platform must opt in to reexporting. +//! +//! There shouldn't be any repeated definitions or complex configuration in this module. On +//! platforms that don't use common APIs it is fine to use `#[cfg(not(...))]`, but if a platform +//! needs a custom definition then it should be defined in the platform-specific module. +//! +//! The goal is that platforms need to opt in to the definitions here, so that worst case we have +//! an unused warning on untested platforms (rather than exposing incorrect API). + +#[cfg(any( + target_vendor = "apple", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd", + target_os = "openbsd", +))] +pub(crate) mod bsd; + +#[cfg(any( + target_os = "android", + target_os = "emscripten", + target_os = "l4re", + target_os = "linux", +))] +pub(crate) mod linux_like; + +#[cfg(any(target_os = "dragonfly", target_os = "freebsd"))] +pub(crate) mod freebsd_like; + +#[cfg(any(target_os = "netbsd", target_os = "openbsd"))] +pub(crate) mod netbsd_like; + +#[cfg(any(target_os = "illumos", target_os = "solaris"))] +pub(crate) mod solarish; + +#[cfg(target_family = "unix")] +pub(crate) mod posix; diff --git a/http/vendor/libc/src/new/common/netbsd_like.rs b/http/vendor/libc/src/new/common/netbsd_like.rs new file mode 100644 index 0000000..4267357 --- /dev/null +++ b/http/vendor/libc/src/new/common/netbsd_like.rs @@ -0,0 +1 @@ +//! Interfaces common in NetBSD-derived operating systems. This includes NetBSD and OpenBSD. diff --git a/http/vendor/libc/src/new/common/posix/mod.rs b/http/vendor/libc/src/new/common/posix/mod.rs new file mode 100644 index 0000000..44ae64a --- /dev/null +++ b/http/vendor/libc/src/new/common/posix/mod.rs @@ -0,0 +1,15 @@ +//! POSIX APIs that are used by a number of platforms +//! +//! These can be found at: . + +// FIXME(pthread): eventually all platforms should use this module +#[cfg(any( + target_os = "android", + target_os = "emscripten", + target_os = "l4re", + target_os = "linux", + target_os = "qurt", + target_vendor = "apple", +))] +pub(crate) mod pthread; +pub(crate) mod unistd; diff --git a/http/vendor/libc/src/new/common/posix/pthread.rs b/http/vendor/libc/src/new/common/posix/pthread.rs new file mode 100644 index 0000000..17d3906 --- /dev/null +++ b/http/vendor/libc/src/new/common/posix/pthread.rs @@ -0,0 +1,322 @@ +//! Header: `pthread.h` +//! +//! + +use crate::prelude::*; + +extern "C" { + #[cfg(any(target_os = "android", target_os = "linux"))] + pub fn pthread_atfork( + prepare: Option, + parent: Option, + child: Option, + ) -> c_int; + + #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + pub fn pthread_attr_getguardsize( + attr: *const crate::pthread_attr_t, + guardsize: *mut size_t, + ) -> c_int; + + #[cfg(any( + target_os = "android", + target_os = "l4re", + target_os = "linux", + target_vendor = "apple", + ))] + pub fn pthread_attr_getinheritsched( + attr: *const crate::pthread_attr_t, + inheritsched: *mut c_int, + ) -> c_int; + + #[cfg(any(target_os = "l4re", target_os = "linux", target_vendor = "apple"))] + pub fn pthread_attr_getschedparam( + attr: *const crate::pthread_attr_t, + param: *mut crate::sched_param, + ) -> c_int; + + #[cfg(any(target_os = "l4re", target_os = "linux", target_vendor = "apple"))] + pub fn pthread_attr_getschedpolicy( + attr: *const crate::pthread_attr_t, + policy: *mut c_int, + ) -> c_int; + + #[cfg(any( + target_os = "android", + target_os = "emscripten", + target_os = "linux", + target_os = "l4re" + ))] + pub fn pthread_attr_getstack( + attr: *const crate::pthread_attr_t, + stackaddr: *mut *mut c_void, + stacksize: *mut size_t, + ) -> c_int; + + #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + pub fn pthread_attr_setguardsize(attr: *mut crate::pthread_attr_t, guardsize: size_t) -> c_int; + + #[cfg(any( + target_os = "android", + target_os = "l4re", + target_os = "linux", + target_vendor = "apple" + ))] + pub fn pthread_attr_setinheritsched( + attr: *mut crate::pthread_attr_t, + inheritsched: c_int, + ) -> c_int; + + #[cfg(any(target_os = "l4re", target_os = "linux", target_vendor = "apple"))] + pub fn pthread_attr_setschedparam( + attr: *mut crate::pthread_attr_t, + param: *const crate::sched_param, + ) -> c_int; + + #[cfg(any(target_os = "l4re", target_os = "linux", target_vendor = "apple"))] + pub fn pthread_attr_setschedpolicy(attr: *mut crate::pthread_attr_t, policy: c_int) -> c_int; + + #[cfg(any( + target_os = "android", + target_os = "emscripten", + target_os = "linux", + target_os = "l4re" + ))] + pub fn pthread_attr_setstack( + attr: *mut crate::pthread_attr_t, + stackaddr: *mut c_void, + stacksize: size_t, + ) -> c_int; + + #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + pub fn pthread_barrier_destroy(barrier: *mut crate::pthread_barrier_t) -> c_int; + + #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + pub fn pthread_barrier_init( + barrier: *mut crate::pthread_barrier_t, + attr: *const crate::pthread_barrierattr_t, + count: c_uint, + ) -> c_int; + + #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + pub fn pthread_barrier_wait(barrier: *mut crate::pthread_barrier_t) -> c_int; + + #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + pub fn pthread_barrierattr_destroy(attr: *mut crate::pthread_barrierattr_t) -> c_int; + + #[cfg(any(target_os = "android", target_os = "linux"))] + pub fn pthread_barrierattr_getpshared( + attr: *const crate::pthread_barrierattr_t, + shared: *mut c_int, + ) -> c_int; + + #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + pub fn pthread_barrierattr_init(attr: *mut crate::pthread_barrierattr_t) -> c_int; + + #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + pub fn pthread_barrierattr_setpshared( + attr: *mut crate::pthread_barrierattr_t, + shared: c_int, + ) -> c_int; + + #[cfg(any(target_os = "l4re", all(target_os = "linux", not(target_env = "ohos"))))] + pub fn pthread_cancel(thread: crate::pthread_t) -> c_int; + + #[cfg(any(target_os = "android", target_os = "emscripten", target_os = "linux",))] + pub fn pthread_condattr_getclock( + attr: *const crate::pthread_condattr_t, + clock_id: *mut crate::clockid_t, + ) -> c_int; + + #[cfg(any( + target_os = "android", + target_os = "l4re", + target_os = "linux", + target_vendor = "apple", + ))] + pub fn pthread_condattr_getpshared( + attr: *const crate::pthread_condattr_t, + pshared: *mut c_int, + ) -> c_int; + + #[cfg(any(target_os = "android", target_os = "emscripten", target_os = "linux",))] + pub fn pthread_condattr_setclock( + attr: *mut crate::pthread_condattr_t, + clock_id: crate::clockid_t, + ) -> c_int; + + #[cfg(any( + target_os = "android", + target_os = "emscripten", + target_os = "linux", + target_os = "l4re", + target_vendor = "apple", + ))] + pub fn pthread_condattr_setpshared( + attr: *mut crate::pthread_condattr_t, + pshared: c_int, + ) -> c_int; + + #[cfg(any( + target_os = "android", + target_os = "emscripten", + target_os = "l4re", + target_os = "linux", + ))] + pub fn pthread_create( + native: *mut crate::pthread_t, + attr: *const crate::pthread_attr_t, + f: extern "C" fn(*mut c_void) -> *mut c_void, + value: *mut c_void, + ) -> c_int; + + #[cfg(any(target_os = "android", target_os = "linux"))] + pub fn pthread_getcpuclockid(thread: crate::pthread_t, clk_id: *mut crate::clockid_t) -> c_int; + + #[cfg(any( + target_os = "android", + target_os = "l4re", + target_os = "linux", + target_vendor = "apple", + ))] + pub fn pthread_getschedparam( + native: crate::pthread_t, + policy: *mut c_int, + param: *mut crate::sched_param, + ) -> c_int; + + // FIXME(reorg): In recent POSIX versions, this is a signal.h function and not required + // in pthread. + #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + pub fn pthread_kill(thread: crate::pthread_t, sig: c_int) -> c_int; + + #[cfg(all(target_os = "linux", not(target_env = "ohos")))] + pub fn pthread_mutex_consistent(mutex: *mut crate::pthread_mutex_t) -> c_int; + + #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + #[cfg_attr(gnu_time_bits64, link_name = "__pthread_mutex_timedlock64")] + #[cfg_attr(musl_redir_time64, link_name = "__pthread_mutex_timedlock_time64")] + pub fn pthread_mutex_timedlock( + lock: *mut crate::pthread_mutex_t, + abstime: *const crate::timespec, + ) -> c_int; + + #[cfg(target_os = "linux")] + pub fn pthread_mutexattr_getprotocol( + attr: *const crate::pthread_mutexattr_t, + protocol: *mut c_int, + ) -> c_int; + + #[cfg(any( + target_os = "android", + target_os = "l4re", + target_os = "linux", + target_vendor = "apple", + ))] + pub fn pthread_mutexattr_getpshared( + attr: *const crate::pthread_mutexattr_t, + pshared: *mut c_int, + ) -> c_int; + + #[cfg(all(target_os = "linux", not(target_env = "ohos")))] + pub fn pthread_mutexattr_getrobust( + attr: *const crate::pthread_mutexattr_t, + robustness: *mut c_int, + ) -> c_int; + + #[cfg(target_os = "linux")] + pub fn pthread_mutexattr_setprotocol( + attr: *mut crate::pthread_mutexattr_t, + protocol: c_int, + ) -> c_int; + + #[cfg(any( + target_os = "android", + target_os = "emscripten", + target_os = "linux", + target_os = "l4re", + target_vendor = "apple", + ))] + pub fn pthread_mutexattr_setpshared( + attr: *mut crate::pthread_mutexattr_t, + pshared: c_int, + ) -> c_int; + + #[cfg(all(target_os = "linux", not(target_env = "ohos")))] + pub fn pthread_mutexattr_setrobust( + attr: *mut crate::pthread_mutexattr_t, + robustness: c_int, + ) -> c_int; + + #[cfg(any( + target_os = "android", + target_os = "emscripten", + target_os = "linux", + target_os = "l4re", + target_vendor = "apple", + ))] + pub fn pthread_rwlockattr_getpshared( + attr: *const crate::pthread_rwlockattr_t, + val: *mut c_int, + ) -> c_int; + + #[cfg(any( + target_os = "android", + target_os = "emscripten", + target_os = "linux", + target_os = "l4re", + target_vendor = "apple", + ))] + pub fn pthread_rwlockattr_setpshared( + attr: *mut crate::pthread_rwlockattr_t, + val: c_int, + ) -> c_int; + + // FIXME(1.0): These shoul be combined to the version that takes an optional unsafe function. + #[cfg(any(target_os = "l4re", target_os = "linux"))] + pub fn pthread_once(control: *mut crate::pthread_once_t, routine: extern "C" fn()) -> c_int; + #[cfg(target_vendor = "apple")] + pub fn pthread_once( + once_control: *mut crate::pthread_once_t, + init_routine: Option, + ) -> c_int; + + #[cfg(any( + target_os = "android", + target_os = "l4re", + target_os = "linux", + target_vendor = "apple", + ))] + pub fn pthread_setschedparam( + native: crate::pthread_t, + policy: c_int, + param: *const crate::sched_param, + ) -> c_int; + + #[cfg(target_os = "linux")] + pub fn pthread_setschedprio(native: crate::pthread_t, priority: c_int) -> c_int; + + // FIXME(reorg): In recent POSIX versions, this is a signal.h function and not required + // in pthread. + #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + pub fn pthread_sigmask( + how: c_int, + set: *const crate::sigset_t, + oldset: *mut crate::sigset_t, + ) -> c_int; + + #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + pub fn pthread_spin_destroy(lock: *mut crate::pthread_spinlock_t) -> c_int; + + #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + pub fn pthread_spin_init(lock: *mut crate::pthread_spinlock_t, pshared: c_int) -> c_int; + + #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + pub fn pthread_spin_lock(lock: *mut crate::pthread_spinlock_t) -> c_int; + + #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + pub fn pthread_spin_trylock(lock: *mut crate::pthread_spinlock_t) -> c_int; + + #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] + pub fn pthread_spin_unlock(lock: *mut crate::pthread_spinlock_t) -> c_int; +} diff --git a/http/vendor/libc/src/new/common/posix/unistd.rs b/http/vendor/libc/src/new/common/posix/unistd.rs new file mode 100644 index 0000000..0c02cba --- /dev/null +++ b/http/vendor/libc/src/new/common/posix/unistd.rs @@ -0,0 +1,9 @@ +//! Header: `unistd.h` +//! +//! + +use crate::prelude::*; + +pub const STDIN_FILENO: c_int = 0; +pub const STDOUT_FILENO: c_int = 1; +pub const STDERR_FILENO: c_int = 2; diff --git a/http/vendor/libc/src/new/common/solarish.rs b/http/vendor/libc/src/new/common/solarish.rs new file mode 100644 index 0000000..f966114 --- /dev/null +++ b/http/vendor/libc/src/new/common/solarish.rs @@ -0,0 +1 @@ +//! Interfaces common in solaris-derived operating systems. This includes Solaris and Illumos. diff --git a/http/vendor/libc/src/new/cygwin/mod.rs b/http/vendor/libc/src/new/cygwin/mod.rs new file mode 100644 index 0000000..356ae58 --- /dev/null +++ b/http/vendor/libc/src/new/cygwin/mod.rs @@ -0,0 +1,5 @@ +//! Cygwin libc. +//! +//! * Headers: + +pub(crate) mod unistd; diff --git a/http/vendor/libc/src/new/cygwin/unistd.rs b/http/vendor/libc/src/new/cygwin/unistd.rs new file mode 100644 index 0000000..8d55ee5 --- /dev/null +++ b/http/vendor/libc/src/new/cygwin/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/http/vendor/libc/src/new/dragonfly/mod.rs b/http/vendor/libc/src/new/dragonfly/mod.rs new file mode 100644 index 0000000..4a1b2c4 --- /dev/null +++ b/http/vendor/libc/src/new/dragonfly/mod.rs @@ -0,0 +1,6 @@ +//! DragonFly BSD libc. +//! +//! * Headers: +//! * Manual pages: + +pub(crate) mod unistd; diff --git a/http/vendor/libc/src/new/dragonfly/unistd.rs b/http/vendor/libc/src/new/dragonfly/unistd.rs new file mode 100644 index 0000000..8d55ee5 --- /dev/null +++ b/http/vendor/libc/src/new/dragonfly/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/http/vendor/libc/src/new/emscripten/mod.rs b/http/vendor/libc/src/new/emscripten/mod.rs new file mode 100644 index 0000000..9b74464 --- /dev/null +++ b/http/vendor/libc/src/new/emscripten/mod.rs @@ -0,0 +1,7 @@ +//! Emscripten libc. +//! +//! * Headers: + +pub(crate) mod pthread; +pub(crate) mod sched; +pub(crate) mod unistd; diff --git a/http/vendor/libc/src/new/emscripten/pthread.rs b/http/vendor/libc/src/new/emscripten/pthread.rs new file mode 100644 index 0000000..21982b7 --- /dev/null +++ b/http/vendor/libc/src/new/emscripten/pthread.rs @@ -0,0 +1,14 @@ +//! Header: `pthread.h` + +pub use crate::new::common::linux_like::pthread::pthread_getattr_np; +pub use crate::new::common::posix::pthread::{ + pthread_attr_getstack, + pthread_attr_setstack, + pthread_condattr_getclock, + pthread_condattr_setclock, + pthread_condattr_setpshared, + pthread_create, + pthread_mutexattr_setpshared, + pthread_rwlockattr_getpshared, + pthread_rwlockattr_setpshared, +}; diff --git a/http/vendor/libc/src/new/emscripten/sched.rs b/http/vendor/libc/src/new/emscripten/sched.rs new file mode 100644 index 0000000..3bf854e --- /dev/null +++ b/http/vendor/libc/src/new/emscripten/sched.rs @@ -0,0 +1,38 @@ +use crate::prelude::*; + +cfg_if! { + if #[cfg(musl_v1_2_3)] { + s! { + struct __c_anon_sched_param__reserved2 { + __reserved1: crate::time_t, + __reserved2: c_long, + } + + pub struct sched_param { + pub sched_priority: c_int, + + __reserved1: Padding, + #[cfg(musl32_time64)] + __reserved2: Padding<[c_long; 4]>, + #[cfg(not(musl32_time64))] + __reserved2: Padding<[__c_anon_sched_param__reserved2; 2]>, + __reserved3: Padding, + } + } + } else { + s! { + pub struct sched_param { + pub sched_priority: c_int, + + #[deprecated(since = "0.2.173", note = "This field has been removed upstream")] + pub sched_ss_low_priority: c_int, + #[deprecated(since = "0.2.173", note = "This field has been removed upstream")] + pub sched_ss_repl_period: crate::timespec, + #[deprecated(since = "0.2.173", note = "This field has been removed upstream")] + pub sched_ss_init_budget: crate::timespec, + #[deprecated(since = "0.2.173", note = "This field has been removed upstream")] + pub sched_ss_max_repl: c_int, + } + } + } +} diff --git a/http/vendor/libc/src/new/emscripten/unistd.rs b/http/vendor/libc/src/new/emscripten/unistd.rs new file mode 100644 index 0000000..8d55ee5 --- /dev/null +++ b/http/vendor/libc/src/new/emscripten/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/http/vendor/libc/src/new/espidf/mod.rs b/http/vendor/libc/src/new/espidf/mod.rs new file mode 100644 index 0000000..061ea6e --- /dev/null +++ b/http/vendor/libc/src/new/espidf/mod.rs @@ -0,0 +1,2 @@ +//! Expressif libc. +// FIXME(espidf): link to headers needed. diff --git a/http/vendor/libc/src/new/freebsd/mod.rs b/http/vendor/libc/src/new/freebsd/mod.rs new file mode 100644 index 0000000..eedf235 --- /dev/null +++ b/http/vendor/libc/src/new/freebsd/mod.rs @@ -0,0 +1,7 @@ +//! FreeBSD libc. +//! +//! * Headers: +//! * Symbol map: + +pub(crate) mod sys; +pub(crate) mod unistd; diff --git a/http/vendor/libc/src/new/freebsd/sys/file.rs b/http/vendor/libc/src/new/freebsd/sys/file.rs new file mode 100644 index 0000000..3072c1d --- /dev/null +++ b/http/vendor/libc/src/new/freebsd/sys/file.rs @@ -0,0 +1,46 @@ +//! Header: `sys/file.h` +//! +//! https://github.com/freebsd/freebsd-src/blob/main/sys/sys/file.h + +use crate::prelude::*; + +pub const DTYPE_NONE: c_int = 0; +pub const DTYPE_VNODE: c_int = 1; +pub const DTYPE_SOCKET: c_int = 2; +pub const DTYPE_PIPE: c_int = 3; +pub const DTYPE_FIFO: c_int = 4; +pub const DTYPE_KQUEUE: c_int = 5; +pub const DTYPE_CRYPTO: c_int = 6; +pub const DTYPE_MQUEUE: c_int = 7; +pub const DTYPE_SHM: c_int = 8; +pub const DTYPE_SEM: c_int = 9; +pub const DTYPE_PTS: c_int = 10; +pub const DTYPE_DEV: c_int = 11; +pub const DTYPE_PROCDESC: c_int = 12; +pub const DTYPE_EVENTFD: c_int = 13; +pub const DTYPE_TIMERFD: c_int = 14; +pub const DTYPE_INOTIFY: c_int = 15; +pub const DTYPE_JAILDESC: c_int = 16; + +s! { + #[cfg(not(any(freebsd10, freebsd11)))] + pub struct xfile { + pub xf_size: crate::ksize_t, + pub xf_pid: crate::pid_t, + pub xf_uid: crate::uid_t, + pub xf_fd: c_int, + _xf_int_pad1: Padding, + pub xf_file: crate::kvaddr_t, + pub xf_type: c_short, + _xf_short_pad1: Padding, + pub xf_count: c_int, + pub xf_msgcount: c_int, + _xf_int_pad2: Padding, + pub xf_offset: crate::off_t, + pub xf_data: crate::kvaddr_t, + pub xf_vnode: crate::kvaddr_t, + pub xf_flag: c_uint, + _xf_int_pad3: Padding, + _xf_int64_pad: Padding<[i64; 6]>, + } +} diff --git a/http/vendor/libc/src/new/freebsd/sys/mod.rs b/http/vendor/libc/src/new/freebsd/sys/mod.rs new file mode 100644 index 0000000..210e674 --- /dev/null +++ b/http/vendor/libc/src/new/freebsd/sys/mod.rs @@ -0,0 +1,5 @@ +//! Directory: `sys/` +//! +//! https://github.com/freebsd/freebsd-src/tree/main/sys/sys' + +pub(crate) mod file; diff --git a/http/vendor/libc/src/new/freebsd/unistd.rs b/http/vendor/libc/src/new/freebsd/unistd.rs new file mode 100644 index 0000000..8d55ee5 --- /dev/null +++ b/http/vendor/libc/src/new/freebsd/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/http/vendor/libc/src/new/fuchsia/mod.rs b/http/vendor/libc/src/new/fuchsia/mod.rs new file mode 100644 index 0000000..b3a9083 --- /dev/null +++ b/http/vendor/libc/src/new/fuchsia/mod.rs @@ -0,0 +1,4 @@ +//! Fuschia libc. +// FIXME(fuchsia): link to headers needed. + +pub(crate) mod unistd; diff --git a/http/vendor/libc/src/new/fuchsia/unistd.rs b/http/vendor/libc/src/new/fuchsia/unistd.rs new file mode 100644 index 0000000..8d55ee5 --- /dev/null +++ b/http/vendor/libc/src/new/fuchsia/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/http/vendor/libc/src/new/glibc/mod.rs b/http/vendor/libc/src/new/glibc/mod.rs new file mode 100644 index 0000000..71d979b --- /dev/null +++ b/http/vendor/libc/src/new/glibc/mod.rs @@ -0,0 +1,31 @@ +//! GNU libc. +//! +//! * Headers: (official) +//! * Headers: (mirror) +//! +//! This module structure is modeled after glibc's source tree. Its build system selects headers +//! from different locations based on the platform, which we mimic here with reexports. + +/// Source directory: `posix/` +/// +/// +mod posix { + pub(crate) mod unistd; +} + +/// Source directory: `sysdeps/` +/// +/// +mod sysdeps { + // FIXME(pthread): eventually all platforms should use this module + #[cfg(target_os = "linux")] + pub(crate) mod nptl; + pub(crate) mod unix; +} + +pub(crate) use posix::*; +// FIXME(pthread): eventually all platforms should use this module +#[cfg(target_os = "linux")] +pub(crate) use sysdeps::nptl::*; +#[cfg(target_os = "linux")] +pub(crate) use sysdeps::unix::linux::*; diff --git a/http/vendor/libc/src/new/glibc/posix/unistd.rs b/http/vendor/libc/src/new/glibc/posix/unistd.rs new file mode 100644 index 0000000..907066c --- /dev/null +++ b/http/vendor/libc/src/new/glibc/posix/unistd.rs @@ -0,0 +1,9 @@ +//! Header: `unistd.h` +//! +//! + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/http/vendor/libc/src/new/glibc/sysdeps/nptl/mod.rs b/http/vendor/libc/src/new/glibc/sysdeps/nptl/mod.rs new file mode 100644 index 0000000..18e82e4 --- /dev/null +++ b/http/vendor/libc/src/new/glibc/sysdeps/nptl/mod.rs @@ -0,0 +1,7 @@ +//! Source directory: `sysdeps/nptl/`o +//! +//! Native POSIX threading library. +//! +//! + +pub(crate) mod pthread; diff --git a/http/vendor/libc/src/new/glibc/sysdeps/nptl/pthread.rs b/http/vendor/libc/src/new/glibc/sysdeps/nptl/pthread.rs new file mode 100644 index 0000000..27b1728 --- /dev/null +++ b/http/vendor/libc/src/new/glibc/sysdeps/nptl/pthread.rs @@ -0,0 +1,59 @@ +//! Source header: `sysdeps/nptl/pthread.h` +//! +//! + +pub use crate::new::common::linux_like::pthread::{ + pthread_getaffinity_np, + pthread_getattr_np, + pthread_getname_np, + pthread_setaffinity_np, + pthread_setname_np, +}; +pub use crate::new::common::posix::pthread::{ + pthread_atfork, + pthread_attr_getguardsize, + pthread_attr_getinheritsched, + pthread_attr_getschedparam, + pthread_attr_getschedpolicy, + pthread_attr_getstack, + pthread_attr_setguardsize, + pthread_attr_setinheritsched, + pthread_attr_setschedparam, + pthread_attr_setschedpolicy, + pthread_attr_setstack, + pthread_barrier_destroy, + pthread_barrier_init, + pthread_barrier_wait, + pthread_barrierattr_destroy, + pthread_barrierattr_getpshared, + pthread_barrierattr_init, + pthread_barrierattr_setpshared, + pthread_cancel, + pthread_condattr_getclock, + pthread_condattr_getpshared, + pthread_condattr_setclock, + pthread_condattr_setpshared, + pthread_create, + pthread_getcpuclockid, + pthread_getschedparam, + pthread_kill, + pthread_mutex_consistent, + pthread_mutex_timedlock, + pthread_mutexattr_getprotocol, + pthread_mutexattr_getpshared, + pthread_mutexattr_getrobust, + pthread_mutexattr_setprotocol, + pthread_mutexattr_setpshared, + pthread_mutexattr_setrobust, + pthread_once, + pthread_rwlockattr_getpshared, + pthread_rwlockattr_setpshared, + pthread_setschedparam, + pthread_setschedprio, + pthread_sigmask, + pthread_spin_destroy, + pthread_spin_init, + pthread_spin_lock, + pthread_spin_trylock, + pthread_spin_unlock, +}; diff --git a/http/vendor/libc/src/new/glibc/sysdeps/unix/linux/mod.rs b/http/vendor/libc/src/new/glibc/sysdeps/unix/linux/mod.rs new file mode 100644 index 0000000..0ecee59 --- /dev/null +++ b/http/vendor/libc/src/new/glibc/sysdeps/unix/linux/mod.rs @@ -0,0 +1,10 @@ +//! Source directory: `sysdeps/unix/sysv/linux` (the `sysv` is flattened). +//! +//! + +/// Directory: `net/` +/// +/// Source directory: `sysdeps/unix/sysv/linux/net` +pub(crate) mod net { + pub(crate) mod route; +} diff --git a/http/vendor/libc/src/new/glibc/sysdeps/unix/linux/net/route.rs b/http/vendor/libc/src/new/glibc/sysdeps/unix/linux/net/route.rs new file mode 100644 index 0000000..2851451 --- /dev/null +++ b/http/vendor/libc/src/new/glibc/sysdeps/unix/linux/net/route.rs @@ -0,0 +1,30 @@ +//! Header: `net/route.h` +//! +//! Source header: `sysdeps/unix/sysv/linux/net/route.h` +//! + +use crate::prelude::*; + +s! { + pub struct rtentry { + pub rt_pad1: c_ulong, + pub rt_dst: crate::sockaddr, + pub rt_gateway: crate::sockaddr, + pub rt_genmask: crate::sockaddr, + pub rt_flags: c_ushort, + pub rt_pad2: c_short, + pub rt_pad3: c_ulong, + pub rt_tos: c_uchar, + pub rt_class: c_uchar, + // FIXME(1.0): private padding fields + #[cfg(target_pointer_width = "64")] + pub rt_pad4: [c_short; 3usize], + #[cfg(not(target_pointer_width = "64"))] + pub rt_pad4: c_short, + pub rt_metric: c_short, + pub rt_dev: *mut c_char, + pub rt_mtu: c_ulong, + pub rt_window: c_ulong, + pub rt_irtt: c_ushort, + } +} diff --git a/http/vendor/libc/src/new/glibc/sysdeps/unix/mod.rs b/http/vendor/libc/src/new/glibc/sysdeps/unix/mod.rs new file mode 100644 index 0000000..55a895d --- /dev/null +++ b/http/vendor/libc/src/new/glibc/sysdeps/unix/mod.rs @@ -0,0 +1,6 @@ +//! Source directory: `sysdeps/unix/` +//! +//! + +#[cfg(target_os = "linux")] +pub(crate) mod linux; diff --git a/http/vendor/libc/src/new/haiku/mod.rs b/http/vendor/libc/src/new/haiku/mod.rs new file mode 100644 index 0000000..a565afe --- /dev/null +++ b/http/vendor/libc/src/new/haiku/mod.rs @@ -0,0 +1,4 @@ +//! Haiku OS libc. +// FIXME(haiku): link to headers needed. + +pub(crate) mod unistd; diff --git a/http/vendor/libc/src/new/haiku/unistd.rs b/http/vendor/libc/src/new/haiku/unistd.rs new file mode 100644 index 0000000..8d55ee5 --- /dev/null +++ b/http/vendor/libc/src/new/haiku/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/http/vendor/libc/src/new/hermit_abi/mod.rs b/http/vendor/libc/src/new/hermit_abi/mod.rs new file mode 100644 index 0000000..65f59fe --- /dev/null +++ b/http/vendor/libc/src/new/hermit_abi/mod.rs @@ -0,0 +1,3 @@ +//! Hermit kernel libc. +//! +//! * Headers: diff --git a/http/vendor/libc/src/new/horizon/mod.rs b/http/vendor/libc/src/new/horizon/mod.rs new file mode 100644 index 0000000..338e9f0 --- /dev/null +++ b/http/vendor/libc/src/new/horizon/mod.rs @@ -0,0 +1,2 @@ +//! Switch libc. +// FIXME(horizon): link to headers or manpages needed. diff --git a/http/vendor/libc/src/new/hurd/mod.rs b/http/vendor/libc/src/new/hurd/mod.rs new file mode 100644 index 0000000..12198d5 --- /dev/null +++ b/http/vendor/libc/src/new/hurd/mod.rs @@ -0,0 +1,2 @@ +//! GNU Hurd libc. +// FIXME(hurd): link to headers needed. diff --git a/http/vendor/libc/src/new/illumos/mod.rs b/http/vendor/libc/src/new/illumos/mod.rs new file mode 100644 index 0000000..83d15da --- /dev/null +++ b/http/vendor/libc/src/new/illumos/mod.rs @@ -0,0 +1,4 @@ +//! Illumos libc. +// FIXME(illumos): link to headers needed. + +pub(crate) mod unistd; diff --git a/http/vendor/libc/src/new/illumos/unistd.rs b/http/vendor/libc/src/new/illumos/unistd.rs new file mode 100644 index 0000000..8d55ee5 --- /dev/null +++ b/http/vendor/libc/src/new/illumos/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/http/vendor/libc/src/new/l4re/mod.rs b/http/vendor/libc/src/new/l4re/mod.rs new file mode 100644 index 0000000..cbf725f --- /dev/null +++ b/http/vendor/libc/src/new/l4re/mod.rs @@ -0,0 +1,3 @@ +//! L4re. +//! +//! * Headers: diff --git a/http/vendor/libc/src/new/linux_uapi/linux/can.rs b/http/vendor/libc/src/new/linux_uapi/linux/can.rs new file mode 100644 index 0000000..c4ae2da --- /dev/null +++ b/http/vendor/libc/src/new/linux_uapi/linux/can.rs @@ -0,0 +1,135 @@ +//! Header: `uapi/linux/can.h` + +pub(crate) mod bcm; +pub(crate) mod error; +pub(crate) mod j1939; +pub(crate) mod netlink; +pub(crate) mod raw; + +use crate::prelude::*; + +pub const CAN_EFF_FLAG: canid_t = 0x80000000; +pub const CAN_RTR_FLAG: canid_t = 0x40000000; +pub const CAN_ERR_FLAG: canid_t = 0x20000000; + +pub const CAN_SFF_MASK: canid_t = 0x000007FF; +pub const CAN_EFF_MASK: canid_t = 0x1FFFFFFF; +pub const CAN_ERR_MASK: canid_t = 0x1FFFFFFF; +pub const CANXL_PRIO_MASK: crate::canid_t = CAN_SFF_MASK; + +pub type canid_t = u32; + +pub const CAN_SFF_ID_BITS: c_int = 11; +pub const CAN_EFF_ID_BITS: c_int = 29; +pub const CANXL_PRIO_BITS: c_int = CAN_SFF_ID_BITS; + +pub type can_err_mask_t = u32; + +pub const CAN_MAX_DLC: c_int = 8; +pub const CAN_MAX_DLEN: usize = 8; + +pub const CANFD_MAX_DLC: c_int = 15; +pub const CANFD_MAX_DLEN: usize = 64; + +pub const CANXL_MIN_DLC: c_int = 0; +pub const CANXL_MAX_DLC: c_int = 2047; +pub const CANXL_MAX_DLC_MASK: c_int = 0x07FF; +pub const CANXL_MIN_DLEN: usize = 1; +pub const CANXL_MAX_DLEN: usize = 2048; + +s! { + #[repr(align(8))] + pub struct can_frame { + pub can_id: canid_t, + // FIXME(1.0): this field was renamed to `len` in Linux 5.11 + pub can_dlc: u8, + __pad: Padding, + __res0: u8, + pub len8_dlc: u8, + pub data: [u8; CAN_MAX_DLEN], + } +} + +pub const CANFD_BRS: c_int = 0x01; +pub const CANFD_ESI: c_int = 0x02; +pub const CANFD_FDF: c_int = 0x04; + +s! { + #[repr(align(8))] + pub struct canfd_frame { + pub can_id: canid_t, + pub len: u8, + pub flags: u8, + __res0: u8, + __res1: u8, + pub data: [u8; CANFD_MAX_DLEN], + } +} + +pub const CANXL_XLF: c_int = 0x80; +pub const CANXL_SEC: c_int = 0x01; + +s! { + pub struct canxl_frame { + pub prio: canid_t, + pub flags: u8, + pub sdt: u8, + pub len: u16, + pub af: u32, + pub data: [u8; CANXL_MAX_DLEN], + } +} + +pub const CAN_MTU: usize = size_of::(); +pub const CANFD_MTU: usize = size_of::(); +pub const CANXL_MTU: usize = size_of::(); +// FIXME(offset_of): use `core::mem::offset_of!` once that is available +// https://github.com/rust-lang/rfcs/pull/3308 +// pub const CANXL_HDR_SIZE: usize = core::mem::offset_of!(canxl_frame, data); +pub const CANXL_HDR_SIZE: usize = 12; +pub const CANXL_MIN_MTU: usize = CANXL_HDR_SIZE + 64; +pub const CANXL_MAX_MTU: usize = CANXL_MTU; + +pub const CAN_RAW: c_int = 1; +pub const CAN_BCM: c_int = 2; +pub const CAN_TP16: c_int = 3; +pub const CAN_TP20: c_int = 4; +pub const CAN_MCNET: c_int = 5; +pub const CAN_ISOTP: c_int = 6; +pub const CAN_J1939: c_int = 7; +pub const CAN_NPROTO: c_int = 8; + +pub const SOL_CAN_BASE: c_int = 100; + +s_no_extra_traits! { + pub struct sockaddr_can { + pub can_family: crate::sa_family_t, + pub can_ifindex: c_int, + pub can_addr: __c_anonymous_sockaddr_can_can_addr, + } + + pub union __c_anonymous_sockaddr_can_can_addr { + pub tp: __c_anonymous_sockaddr_can_tp, + pub j1939: __c_anonymous_sockaddr_can_j1939, + } +} + +s! { + pub struct __c_anonymous_sockaddr_can_tp { + pub rx_id: canid_t, + pub tx_id: canid_t, + } + + pub struct __c_anonymous_sockaddr_can_j1939 { + pub name: u64, + pub pgn: u32, + pub addr: u8, + } + + pub struct can_filter { + pub can_id: canid_t, + pub can_mask: canid_t, + } +} + +pub const CAN_INV_FILTER: canid_t = 0x20000000; diff --git a/http/vendor/libc/src/new/linux_uapi/linux/can/bcm.rs b/http/vendor/libc/src/new/linux_uapi/linux/can/bcm.rs new file mode 100644 index 0000000..853f85f --- /dev/null +++ b/http/vendor/libc/src/new/linux_uapi/linux/can/bcm.rs @@ -0,0 +1,52 @@ +//! Header: `linux/can/bcm.h` + +pub use crate::linux::can::*; + +s! { + pub struct bcm_timeval { + pub tv_sec: c_long, + pub tv_usec: c_long, + } + + pub struct bcm_msg_head { + pub opcode: u32, + pub flags: u32, + pub count: u32, + pub ival1: bcm_timeval, + pub ival2: bcm_timeval, + pub can_id: canid_t, + pub nframes: u32, + pub frames: [can_frame; 0], + } +} + +c_enum! { + #[repr(u32)] + pub enum #anon { + pub TX_SETUP = 1, + pub TX_DELETE, + pub TX_READ, + pub TX_SEND, + pub RX_SETUP, + pub RX_DELETE, + pub RX_READ, + pub TX_STATUS, + pub TX_EXPIRED, + pub RX_STATUS, + pub RX_TIMEOUT, + pub RX_CHANGED, + } +} + +pub const SETTIMER: u32 = 0x0001; +pub const STARTTIMER: u32 = 0x0002; +pub const TX_COUNTEVT: u32 = 0x0004; +pub const TX_ANNOUNCE: u32 = 0x0008; +pub const TX_CP_CAN_ID: u32 = 0x0010; +pub const RX_FILTER_ID: u32 = 0x0020; +pub const RX_CHECK_DLC: u32 = 0x0040; +pub const RX_NO_AUTOTIMER: u32 = 0x0080; +pub const RX_ANNOUNCE_RESUME: u32 = 0x0100; +pub const TX_RESET_MULTI_IDX: u32 = 0x0200; +pub const RX_RTR_FRAME: u32 = 0x0400; +pub const CAN_FD_FRAME: u32 = 0x0800; diff --git a/http/vendor/libc/src/new/linux_uapi/linux/can/error.rs b/http/vendor/libc/src/new/linux_uapi/linux/can/error.rs new file mode 100644 index 0000000..1b298ca --- /dev/null +++ b/http/vendor/libc/src/new/linux_uapi/linux/can/error.rs @@ -0,0 +1,73 @@ +//! Header: `linux/can/error.h` + +pub use crate::linux::can::*; + +pub const CAN_ERR_DLC: c_int = 8; + +pub const CAN_ERR_TX_TIMEOUT: c_uint = 0x00000001; +pub const CAN_ERR_LOSTARB: c_uint = 0x00000002; +pub const CAN_ERR_CRTL: c_uint = 0x00000004; +pub const CAN_ERR_PROT: c_uint = 0x00000008; +pub const CAN_ERR_TRX: c_uint = 0x00000010; +pub const CAN_ERR_ACK: c_uint = 0x00000020; +pub const CAN_ERR_BUSOFF: c_uint = 0x00000040; +pub const CAN_ERR_BUSERROR: c_uint = 0x00000080; +pub const CAN_ERR_RESTARTED: c_uint = 0x00000100; +pub const CAN_ERR_CNT: c_uint = 0x00000200; + +pub const CAN_ERR_LOSTARB_UNSPEC: c_int = 0x00; + +pub const CAN_ERR_CRTL_UNSPEC: c_int = 0x00; +pub const CAN_ERR_CRTL_RX_OVERFLOW: c_int = 0x01; +pub const CAN_ERR_CRTL_TX_OVERFLOW: c_int = 0x02; +pub const CAN_ERR_CRTL_RX_WARNING: c_int = 0x04; +pub const CAN_ERR_CRTL_TX_WARNING: c_int = 0x08; +pub const CAN_ERR_CRTL_RX_PASSIVE: c_int = 0x10; +pub const CAN_ERR_CRTL_TX_PASSIVE: c_int = 0x20; +pub const CAN_ERR_CRTL_ACTIVE: c_int = 0x40; + +pub const CAN_ERR_PROT_UNSPEC: c_int = 0x00; +pub const CAN_ERR_PROT_BIT: c_int = 0x01; +pub const CAN_ERR_PROT_FORM: c_int = 0x02; +pub const CAN_ERR_PROT_STUFF: c_int = 0x04; +pub const CAN_ERR_PROT_BIT0: c_int = 0x08; +pub const CAN_ERR_PROT_BIT1: c_int = 0x10; +pub const CAN_ERR_PROT_OVERLOAD: c_int = 0x20; +pub const CAN_ERR_PROT_ACTIVE: c_int = 0x40; +pub const CAN_ERR_PROT_TX: c_int = 0x80; + +pub const CAN_ERR_PROT_LOC_UNSPEC: c_int = 0x00; +pub const CAN_ERR_PROT_LOC_SOF: c_int = 0x03; +pub const CAN_ERR_PROT_LOC_ID28_21: c_int = 0x02; +pub const CAN_ERR_PROT_LOC_ID20_18: c_int = 0x06; +pub const CAN_ERR_PROT_LOC_SRTR: c_int = 0x04; +pub const CAN_ERR_PROT_LOC_IDE: c_int = 0x05; +pub const CAN_ERR_PROT_LOC_ID17_13: c_int = 0x07; +pub const CAN_ERR_PROT_LOC_ID12_05: c_int = 0x0F; +pub const CAN_ERR_PROT_LOC_ID04_00: c_int = 0x0E; +pub const CAN_ERR_PROT_LOC_RTR: c_int = 0x0C; +pub const CAN_ERR_PROT_LOC_RES1: c_int = 0x0D; +pub const CAN_ERR_PROT_LOC_RES0: c_int = 0x09; +pub const CAN_ERR_PROT_LOC_DLC: c_int = 0x0B; +pub const CAN_ERR_PROT_LOC_DATA: c_int = 0x0A; +pub const CAN_ERR_PROT_LOC_CRC_SEQ: c_int = 0x08; +pub const CAN_ERR_PROT_LOC_CRC_DEL: c_int = 0x18; +pub const CAN_ERR_PROT_LOC_ACK: c_int = 0x19; +pub const CAN_ERR_PROT_LOC_ACK_DEL: c_int = 0x1B; +pub const CAN_ERR_PROT_LOC_EOF: c_int = 0x1A; +pub const CAN_ERR_PROT_LOC_INTERM: c_int = 0x12; + +pub const CAN_ERR_TRX_UNSPEC: c_int = 0x00; +pub const CAN_ERR_TRX_CANH_NO_WIRE: c_int = 0x04; +pub const CAN_ERR_TRX_CANH_SHORT_TO_BAT: c_int = 0x05; +pub const CAN_ERR_TRX_CANH_SHORT_TO_VCC: c_int = 0x06; +pub const CAN_ERR_TRX_CANH_SHORT_TO_GND: c_int = 0x07; +pub const CAN_ERR_TRX_CANL_NO_WIRE: c_int = 0x40; +pub const CAN_ERR_TRX_CANL_SHORT_TO_BAT: c_int = 0x50; +pub const CAN_ERR_TRX_CANL_SHORT_TO_VCC: c_int = 0x60; +pub const CAN_ERR_TRX_CANL_SHORT_TO_GND: c_int = 0x70; +pub const CAN_ERR_TRX_CANL_SHORT_TO_CANH: c_int = 0x80; + +pub const CAN_ERROR_WARNING_THRESHOLD: c_int = 96; +pub const CAN_ERROR_PASSIVE_THRESHOLD: c_int = 128; +pub const CAN_BUS_OFF_THRESHOLD: c_int = 256; diff --git a/http/vendor/libc/src/new/linux_uapi/linux/can/j1939.rs b/http/vendor/libc/src/new/linux_uapi/linux/can/j1939.rs new file mode 100644 index 0000000..fdf425c --- /dev/null +++ b/http/vendor/libc/src/new/linux_uapi/linux/can/j1939.rs @@ -0,0 +1,60 @@ +//! `linux/can/j1939.h` + +pub use crate::linux::can::*; + +pub const J1939_MAX_UNICAST_ADDR: c_uchar = 0xfd; +pub const J1939_IDLE_ADDR: c_uchar = 0xfe; +pub const J1939_NO_ADDR: c_uchar = 0xff; +pub const J1939_NO_NAME: c_ulong = 0; +pub const J1939_PGN_REQUEST: c_uint = 0x0ea00; +pub const J1939_PGN_ADDRESS_CLAIMED: c_uint = 0x0ee00; +pub const J1939_PGN_ADDRESS_COMMANDED: c_uint = 0x0fed8; +pub const J1939_PGN_PDU1_MAX: c_uint = 0x3ff00; +pub const J1939_PGN_MAX: c_uint = 0x3ffff; +pub const J1939_NO_PGN: c_uint = 0x40000; + +pub type pgn_t = u32; +pub type priority_t = u8; +pub type name_t = u64; + +pub const SOL_CAN_J1939: c_int = SOL_CAN_BASE + CAN_J1939; + +// FIXME(cleanup): these could use c_enum if it can accept anonymous enums. + +pub const SO_J1939_FILTER: c_int = 1; +pub const SO_J1939_PROMISC: c_int = 2; +pub const SO_J1939_SEND_PRIO: c_int = 3; +pub const SO_J1939_ERRQUEUE: c_int = 4; + +pub const SCM_J1939_DEST_ADDR: c_int = 1; +pub const SCM_J1939_DEST_NAME: c_int = 2; +pub const SCM_J1939_PRIO: c_int = 3; +pub const SCM_J1939_ERRQUEUE: c_int = 4; + +pub const J1939_NLA_PAD: c_int = 0; +pub const J1939_NLA_BYTES_ACKED: c_int = 1; +pub const J1939_NLA_TOTAL_SIZE: c_int = 2; +pub const J1939_NLA_PGN: c_int = 3; +pub const J1939_NLA_SRC_NAME: c_int = 4; +pub const J1939_NLA_DEST_NAME: c_int = 5; +pub const J1939_NLA_SRC_ADDR: c_int = 6; +pub const J1939_NLA_DEST_ADDR: c_int = 7; + +pub const J1939_EE_INFO_NONE: c_int = 0; +pub const J1939_EE_INFO_TX_ABORT: c_int = 1; +pub const J1939_EE_INFO_RX_RTS: c_int = 2; +pub const J1939_EE_INFO_RX_DPO: c_int = 3; +pub const J1939_EE_INFO_RX_ABORT: c_int = 4; + +s! { + pub struct j1939_filter { + pub name: name_t, + pub name_mask: name_t, + pub pgn: pgn_t, + pub pgn_mask: pgn_t, + pub addr: u8, + pub addr_mask: u8, + } +} + +pub const J1939_FILTER_MAX: c_int = 512; diff --git a/http/vendor/libc/src/new/linux_uapi/linux/can/netlink.rs b/http/vendor/libc/src/new/linux_uapi/linux/can/netlink.rs new file mode 100644 index 0000000..2892941 --- /dev/null +++ b/http/vendor/libc/src/new/linux_uapi/linux/can/netlink.rs @@ -0,0 +1,125 @@ +//! Header: `linux/can/netlink.h` + +use crate::prelude::*; + +s! { + pub struct can_bittiming { + pub bitrate: u32, + pub sample_point: u32, + pub tq: u32, + pub prop_seg: u32, + pub phase_seg1: u32, + pub phase_seg2: u32, + pub sjw: u32, + pub brp: u32, + } + + pub struct can_bittiming_const { + pub name: [c_char; 16], + pub tseg1_min: u32, + pub tseg1_max: u32, + pub tseg2_min: u32, + pub tseg2_max: u32, + pub sjw_max: u32, + pub brp_min: u32, + pub brp_max: u32, + pub brp_inc: u32, + } + + pub struct can_clock { + pub freq: u32, + } + + pub struct can_berr_counter { + pub txerr: u16, + pub rxerr: u16, + } + + pub struct can_ctrlmode { + pub mask: u32, + pub flags: u32, + } + + pub struct can_device_stats { + pub bus_error: u32, + pub error_warning: u32, + pub error_passive: u32, + pub bus_off: u32, + pub arbitration_lost: u32, + pub restarts: u32, + } +} + +c_enum! { + #[repr(c_uint)] + pub enum can_state { + pub CAN_STATE_ERROR_ACTIVE = 0, + pub CAN_STATE_ERROR_WARNING, + pub CAN_STATE_ERROR_PASSIVE, + pub CAN_STATE_BUS_OFF, + pub CAN_STATE_STOPPED, + pub CAN_STATE_SLEEPING, + } +} + +pub const CAN_CTRLMODE_LOOPBACK: u32 = 0x01; +pub const CAN_CTRLMODE_LISTENONLY: u32 = 0x02; +pub const CAN_CTRLMODE_3_SAMPLES: u32 = 0x04; +pub const CAN_CTRLMODE_ONE_SHOT: u32 = 0x08; +pub const CAN_CTRLMODE_BERR_REPORTING: u32 = 0x10; +pub const CAN_CTRLMODE_FD: u32 = 0x20; +pub const CAN_CTRLMODE_PRESUME_ACK: u32 = 0x40; +pub const CAN_CTRLMODE_FD_NON_ISO: u32 = 0x80; +pub const CAN_CTRLMODE_CC_LEN8_DLC: u32 = 0x100; +pub const CAN_CTRLMODE_TDC_AUTO: u32 = 0x200; +pub const CAN_CTRLMODE_TDC_MANUAL: u32 = 0x400; + +c_enum! { + #[repr(c_int)] + pub enum #anon { + pub IFLA_CAN_UNSPEC = 0, + pub IFLA_CAN_BITTIMING, + pub IFLA_CAN_BITTIMING_CONST, + pub IFLA_CAN_CLOCK, + pub IFLA_CAN_STATE, + pub IFLA_CAN_CTRLMODE, + pub IFLA_CAN_RESTART_MS, + pub IFLA_CAN_RESTART, + pub IFLA_CAN_BERR_COUNTER, + pub IFLA_CAN_DATA_BITTIMING, + pub IFLA_CAN_DATA_BITTIMING_CONST, + pub IFLA_CAN_TERMINATION, + pub IFLA_CAN_TERMINATION_CONST, + pub IFLA_CAN_BITRATE_CONST, + pub IFLA_CAN_DATA_BITRATE_CONST, + pub IFLA_CAN_BITRATE_MAX, + pub IFLA_CAN_TDC, + pub IFLA_CAN_CTRLMODE_EXT, + } +} + +c_enum! { + #[repr(c_int)] + pub enum #anon { + pub IFLA_CAN_TDC_UNSPEC = 0, + pub IFLA_CAN_TDC_TDCV_MIN, + pub IFLA_CAN_TDC_TDCV_MAX, + pub IFLA_CAN_TDC_TDCO_MIN, + pub IFLA_CAN_TDC_TDCO_MAX, + pub IFLA_CAN_TDC_TDCF_MIN, + pub IFLA_CAN_TDC_TDCF_MAX, + pub IFLA_CAN_TDC_TDCV, + pub IFLA_CAN_TDC_TDCO, + pub IFLA_CAN_TDC_TDCF, + } +} + +c_enum! { + #[repr(c_int)] + pub enum #anon { + pub IFLA_CAN_CTRLMODE_UNSPEC = 0, + pub IFLA_CAN_CTRLMODE_SUPPORTED, + } +} + +pub const CAN_TERMINATION_DISABLED: u16 = 0; diff --git a/http/vendor/libc/src/new/linux_uapi/linux/can/raw.rs b/http/vendor/libc/src/new/linux_uapi/linux/can/raw.rs new file mode 100644 index 0000000..470334b --- /dev/null +++ b/http/vendor/libc/src/new/linux_uapi/linux/can/raw.rs @@ -0,0 +1,15 @@ +//! Header: `linux/can/raw.h` + +pub use crate::linux::can::*; + +pub const SOL_CAN_RAW: c_int = SOL_CAN_BASE + CAN_RAW; +pub const CAN_RAW_FILTER_MAX: c_int = 512; + +// FIXME(cleanup): use `c_enum!`, which needs to be adapted to allow omitting a type. +pub const CAN_RAW_FILTER: c_int = 1; +pub const CAN_RAW_ERR_FILTER: c_int = 2; +pub const CAN_RAW_LOOPBACK: c_int = 3; +pub const CAN_RAW_RECV_OWN_MSGS: c_int = 4; +pub const CAN_RAW_FD_FRAMES: c_int = 5; +pub const CAN_RAW_JOIN_FILTERS: c_int = 6; +pub const CAN_RAW_XL_FRAMES: c_int = 7; diff --git a/http/vendor/libc/src/new/linux_uapi/linux/keyctl.rs b/http/vendor/libc/src/new/linux_uapi/linux/keyctl.rs new file mode 100644 index 0000000..cc6527a --- /dev/null +++ b/http/vendor/libc/src/new/linux_uapi/linux/keyctl.rs @@ -0,0 +1,69 @@ +//! Header: `linux/keyctl.h` + +pub const KEY_SPEC_THREAD_KEYRING: i32 = -1; +pub const KEY_SPEC_PROCESS_KEYRING: i32 = -2; +pub const KEY_SPEC_SESSION_KEYRING: i32 = -3; +pub const KEY_SPEC_USER_KEYRING: i32 = -4; +pub const KEY_SPEC_USER_SESSION_KEYRING: i32 = -5; +pub const KEY_SPEC_GROUP_KEYRING: i32 = -6; +pub const KEY_SPEC_REQKEY_AUTH_KEY: i32 = -7; +pub const KEY_SPEC_REQUESTOR_KEYRING: i32 = -8; + +pub const KEY_REQKEY_DEFL_NO_CHANGE: i32 = -1; +pub const KEY_REQKEY_DEFL_DEFAULT: i32 = 0; +pub const KEY_REQKEY_DEFL_THREAD_KEYRING: i32 = 1; +pub const KEY_REQKEY_DEFL_PROCESS_KEYRING: i32 = 2; +pub const KEY_REQKEY_DEFL_SESSION_KEYRING: i32 = 3; +pub const KEY_REQKEY_DEFL_USER_KEYRING: i32 = 4; +pub const KEY_REQKEY_DEFL_USER_SESSION_KEYRING: i32 = 5; +pub const KEY_REQKEY_DEFL_GROUP_KEYRING: i32 = 6; +pub const KEY_REQKEY_DEFL_REQUESTOR_KEYRING: i32 = 7; + +pub const KEYCTL_GET_KEYRING_ID: u32 = 0; +pub const KEYCTL_JOIN_SESSION_KEYRING: u32 = 1; +pub const KEYCTL_UPDATE: u32 = 2; +pub const KEYCTL_REVOKE: u32 = 3; +pub const KEYCTL_CHOWN: u32 = 4; +pub const KEYCTL_SETPERM: u32 = 5; +pub const KEYCTL_DESCRIBE: u32 = 6; +pub const KEYCTL_CLEAR: u32 = 7; +pub const KEYCTL_LINK: u32 = 8; +pub const KEYCTL_UNLINK: u32 = 9; +pub const KEYCTL_SEARCH: u32 = 10; +pub const KEYCTL_READ: u32 = 11; +pub const KEYCTL_INSTANTIATE: u32 = 12; +pub const KEYCTL_NEGATE: u32 = 13; +pub const KEYCTL_SET_REQKEY_KEYRING: u32 = 14; +pub const KEYCTL_SET_TIMEOUT: u32 = 15; +pub const KEYCTL_ASSUME_AUTHORITY: u32 = 16; +pub const KEYCTL_GET_SECURITY: u32 = 17; +pub const KEYCTL_SESSION_TO_PARENT: u32 = 18; +pub const KEYCTL_REJECT: u32 = 19; +pub const KEYCTL_INSTANTIATE_IOV: u32 = 20; +pub const KEYCTL_INVALIDATE: u32 = 21; +pub const KEYCTL_GET_PERSISTENT: u32 = 22; +pub const KEYCTL_DH_COMPUTE: u32 = 23; +pub const KEYCTL_PKEY_QUERY: u32 = 24; +pub const KEYCTL_PKEY_ENCRYPT: u32 = 25; +pub const KEYCTL_PKEY_DECRYPT: u32 = 26; +pub const KEYCTL_PKEY_SIGN: u32 = 27; +pub const KEYCTL_PKEY_VERIFY: u32 = 28; +pub const KEYCTL_RESTRICT_KEYRING: u32 = 29; +pub const KEYCTL_MOVE: u32 = 30; +pub const KEYCTL_CAPABILITIES: u32 = 31; + +pub const KEYCTL_SUPPORTS_ENCRYPT: u32 = 0x01; +pub const KEYCTL_SUPPORTS_DECRYPT: u32 = 0x02; +pub const KEYCTL_SUPPORTS_SIGN: u32 = 0x04; +pub const KEYCTL_SUPPORTS_VERIFY: u32 = 0x08; + +pub const KEYCTL_CAPS0_CAPABILITIES: u32 = 0x01; +pub const KEYCTL_CAPS0_PERSISTENT_KEYRINGS: u32 = 0x02; +pub const KEYCTL_CAPS0_DIFFIE_HELLMAN: u32 = 0x04; +pub const KEYCTL_CAPS0_PUBLIC_KEY: u32 = 0x08; +pub const KEYCTL_CAPS0_BIG_KEY: u32 = 0x10; +pub const KEYCTL_CAPS0_INVALIDATE: u32 = 0x20; +pub const KEYCTL_CAPS0_RESTRICT_KEYRING: u32 = 0x40; +pub const KEYCTL_CAPS0_MOVE: u32 = 0x80; +pub const KEYCTL_CAPS1_NS_KEYRING_NAME: u32 = 0x01; +pub const KEYCTL_CAPS1_NS_KEY_TAG: u32 = 0x02; diff --git a/http/vendor/libc/src/new/linux_uapi/linux/membarrier.rs b/http/vendor/libc/src/new/linux_uapi/linux/membarrier.rs new file mode 100644 index 0000000..4446202 --- /dev/null +++ b/http/vendor/libc/src/new/linux_uapi/linux/membarrier.rs @@ -0,0 +1,20 @@ +//! Header: `uapi/linux/membarrier.h` + +use crate::prelude::*; + +c_enum! { + // FIXME(1.0): incorrect repr signedness, this should be removed in a breaking change. + #[repr(c_int)] + pub enum membarrier_cmd { + pub MEMBARRIER_CMD_QUERY = 0, + pub MEMBARRIER_CMD_GLOBAL = 1 << 0, + pub MEMBARRIER_CMD_GLOBAL_EXPEDITED = 1 << 1, + pub MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED = 1 << 2, + pub MEMBARRIER_CMD_PRIVATE_EXPEDITED = 1 << 3, + pub MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED = 1 << 4, + pub MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE = 1 << 5, + pub MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE = 1 << 6, + pub MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ = 1 << 7, + pub MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ = 1 << 8, + } +} diff --git a/http/vendor/libc/src/new/linux_uapi/linux/mod.rs b/http/vendor/libc/src/new/linux_uapi/linux/mod.rs new file mode 100644 index 0000000..09e2c3e --- /dev/null +++ b/http/vendor/libc/src/new/linux_uapi/linux/mod.rs @@ -0,0 +1,9 @@ +//! Directory: `linux/` +//! +//! + +pub(crate) mod can; +pub(crate) mod keyctl; +pub(crate) mod membarrier; +pub(crate) mod netlink; +pub(crate) mod pidfd; diff --git a/http/vendor/libc/src/new/linux_uapi/linux/netlink.rs b/http/vendor/libc/src/new/linux_uapi/linux/netlink.rs new file mode 100644 index 0000000..03e18d7 --- /dev/null +++ b/http/vendor/libc/src/new/linux_uapi/linux/netlink.rs @@ -0,0 +1,136 @@ +//! Header: `uapi/linux/netlink.h` + +use crate::prelude::*; + +pub const NETLINK_ROUTE: c_int = 0; +pub const NETLINK_UNUSED: c_int = 1; +pub const NETLINK_USERSOCK: c_int = 2; +pub const NETLINK_FIREWALL: c_int = 3; +pub const NETLINK_SOCK_DIAG: c_int = 4; +pub const NETLINK_NFLOG: c_int = 5; +pub const NETLINK_XFRM: c_int = 6; +pub const NETLINK_SELINUX: c_int = 7; +pub const NETLINK_ISCSI: c_int = 8; +pub const NETLINK_AUDIT: c_int = 9; +pub const NETLINK_FIB_LOOKUP: c_int = 10; +pub const NETLINK_CONNECTOR: c_int = 11; +pub const NETLINK_NETFILTER: c_int = 12; +pub const NETLINK_IP6_FW: c_int = 13; +pub const NETLINK_DNRTMSG: c_int = 14; +pub const NETLINK_KOBJECT_UEVENT: c_int = 15; +pub const NETLINK_GENERIC: c_int = 16; +pub const NETLINK_SCSITRANSPORT: c_int = 18; +pub const NETLINK_ECRYPTFS: c_int = 19; +pub const NETLINK_RDMA: c_int = 20; +pub const NETLINK_CRYPTO: c_int = 21; + +pub const NETLINK_INET_DIAG: c_int = NETLINK_SOCK_DIAG; + +pub const MAX_LINKS: c_int = 32; + +s! { + pub struct sockaddr_nl { + pub nl_family: crate::sa_family_t, + nl_pad: Padding, + pub nl_pid: u32, + pub nl_groups: u32, + } + + pub struct nlmsghdr { + pub nlmsg_len: u32, + pub nlmsg_type: u16, + pub nlmsg_flags: u16, + pub nlmsg_seq: u32, + pub nlmsg_pid: u32, + } +} + +pub const NLM_F_REQUEST: c_int = 1; +pub const NLM_F_MULTI: c_int = 2; +pub const NLM_F_ACK: c_int = 4; +pub const NLM_F_ECHO: c_int = 8; +pub const NLM_F_DUMP_INTR: c_int = 16; +pub const NLM_F_DUMP_FILTERED: c_int = 32; + +pub const NLM_F_ROOT: c_int = 0x100; +pub const NLM_F_MATCH: c_int = 0x200; +pub const NLM_F_ATOMIC: c_int = 0x400; +pub const NLM_F_DUMP: c_int = NLM_F_ROOT | NLM_F_MATCH; + +pub const NLM_F_REPLACE: c_int = 0x100; +pub const NLM_F_EXCL: c_int = 0x200; +pub const NLM_F_CREATE: c_int = 0x400; +pub const NLM_F_APPEND: c_int = 0x800; + +pub const NLM_F_NONREC: c_int = 0x100; + +pub const NLM_F_CAPPED: c_int = 0x100; +pub const NLM_F_ACK_TLVS: c_int = 0x200; + +pub const NLMSG_NOOP: c_int = 0x1; +pub const NLMSG_ERROR: c_int = 0x2; +pub const NLMSG_DONE: c_int = 0x3; +pub const NLMSG_OVERRUN: c_int = 0x4; + +pub const NLMSG_MIN_TYPE: c_int = 0x10; + +s! { + pub struct nlmsgerr { + pub error: c_int, + pub msg: nlmsghdr, + } +} + +pub const NETLINK_ADD_MEMBERSHIP: c_int = 1; +pub const NETLINK_DROP_MEMBERSHIP: c_int = 2; +pub const NETLINK_PKTINFO: c_int = 3; +pub const NETLINK_BROADCAST_ERROR: c_int = 4; +pub const NETLINK_NO_ENOBUFS: c_int = 5; +pub const NETLINK_RX_RING: c_int = 6; +pub const NETLINK_TX_RING: c_int = 7; +pub const NETLINK_LISTEN_ALL_NSID: c_int = 8; +pub const NETLINK_LIST_MEMBERSHIPS: c_int = 9; +pub const NETLINK_CAP_ACK: c_int = 10; +pub const NETLINK_EXT_ACK: c_int = 11; +pub const NETLINK_GET_STRICT_CHK: c_int = 12; + +s! { + pub struct nl_pktinfo { + pub group: u32, + } + + pub struct nl_mmap_req { + pub nm_block_size: c_uint, + pub nm_block_nr: c_uint, + pub nm_frame_size: c_uint, + pub nm_frame_nr: c_uint, + } + + pub struct nl_mmap_hdr { + pub nm_status: c_uint, + pub nm_len: c_uint, + pub nm_group: u32, + pub nm_pid: u32, + pub nm_uid: u32, + pub nm_gid: u32, + } +} + +s! { + pub struct nlattr { + pub nla_len: u16, + pub nla_type: u16, + } +} + +pub const NLA_F_NESTED: c_int = 1 << 15; +pub const NLA_F_NET_BYTEORDER: c_int = 1 << 14; +pub const NLA_TYPE_MASK: c_int = !(NLA_F_NESTED | NLA_F_NET_BYTEORDER); + +pub const NLA_ALIGNTO: c_int = 4; + +f! { + pub fn NLA_ALIGN(len: c_int) -> c_int { + return ((len) + NLA_ALIGNTO - 1) & !(NLA_ALIGNTO - 1); + } +} diff --git a/http/vendor/libc/src/new/linux_uapi/linux/pidfd.rs b/http/vendor/libc/src/new/linux_uapi/linux/pidfd.rs new file mode 100644 index 0000000..1835184 --- /dev/null +++ b/http/vendor/libc/src/new/linux_uapi/linux/pidfd.rs @@ -0,0 +1,59 @@ +//! Header: `uapi/linux/pidfd.h` + +use crate::prelude::*; +use crate::{ + Ioctl, + _IO, + _IOWR, +}; + +/* Flags for pidfd_open(). */ +pub const PIDFD_NONBLOCK: c_uint = crate::O_NONBLOCK as c_uint; +pub const PIDFD_THREAD: c_uint = crate::O_EXCL as c_uint; + +/* Flags for pidfd_send_signal(). */ +pub const PIDFD_SIGNAL_THREAD: c_uint = 1 << 0; +pub const PIDFD_SIGNAL_THREAD_GROUP: c_uint = 1 << 1; +pub const PIDFD_SIGNAL_PROCESS_GROUP: c_uint = 1 << 2; + +/* Flags for pidfd_info. */ +pub const PIDFD_INFO_PID: c_uint = 1 << 0; +pub const PIDFD_INFO_CREDS: c_uint = 1 << 1; +pub const PIDFD_INFO_CGROUPID: c_uint = 1 << 2; +pub const PIDFD_INFO_EXIT: c_uint = 1 << 3; + +pub const PIDFD_INFO_SIZE_VER0: c_uint = 64; + +s! { + #[non_exhaustive] + pub struct pidfd_info { + pub mask: crate::__u64, + pub cgroupid: crate::__u64, + pub pid: crate::__u32, + pub tgid: crate::__u32, + pub ppid: crate::__u32, + pub ruid: crate::__u32, + pub rgid: crate::__u32, + pub euid: crate::__u32, + pub egid: crate::__u32, + pub suid: crate::__u32, + pub sgid: crate::__u32, + pub fsuid: crate::__u32, + pub fsgid: crate::__u32, + pub exit_code: crate::__s32, + } +} + +const PIDFS_IOCTL_MAGIC: c_uint = 0xFF; + +pub const PIDFD_GET_CGROUP_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 1); +pub const PIDFD_GET_IPC_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 2); +pub const PIDFD_GET_MNT_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 3); +pub const PIDFD_GET_NET_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 4); +pub const PIDFD_GET_PID_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 5); +pub const PIDFD_GET_PID_FOR_CHILDREN_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 6); +pub const PIDFD_GET_TIME_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 7); +pub const PIDFD_GET_TIME_FOR_CHILDREN_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 8); +pub const PIDFD_GET_USER_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 9); +pub const PIDFD_GET_UTS_NAMESPACE: Ioctl = _IO(PIDFS_IOCTL_MAGIC, 10); +pub const PIDFD_GET_INFO: Ioctl = _IOWR::(PIDFS_IOCTL_MAGIC, 11); diff --git a/http/vendor/libc/src/new/linux_uapi/mod.rs b/http/vendor/libc/src/new/linux_uapi/mod.rs new file mode 100644 index 0000000..8ac3022 --- /dev/null +++ b/http/vendor/libc/src/new/linux_uapi/mod.rs @@ -0,0 +1,3 @@ +//! This directory maps to `include/uapi` in the Linux source tree. + +pub(crate) mod linux; diff --git a/http/vendor/libc/src/new/mod.rs b/http/vendor/libc/src/new/mod.rs new file mode 100644 index 0000000..1c5d6a6 --- /dev/null +++ b/http/vendor/libc/src/new/mod.rs @@ -0,0 +1,239 @@ +//! This module contains the future directory structure. If possible, new definitions should +//! get added here. +//! +//! Eventually everything should be moved over, and we will move this directory to the top +//! level in `src`. +//! +//! # Basic structure +//! +//! Each child module here represents a library or group of libraries that we are binding. Each of +//! these has several submodules, representing either a directory or a header file in that library. +//! +//! `#include`s turn into `pub use ...*;` statements. Then at the root level (here), we choose +//! which top-level headers we want to reexport the definitions for. +//! +//! All modules are only crate-public since we don't reexport this structure. + +mod common; + +/* The `pub(crate) use ...` statements are commented while the modules are empty */ + +// Platform libraries and combined platform+libc +// +// Not supported or not needed: +// * amdhsa +// * cuda +// * lynxos178 +// * managarm +// * motor +// * none +// * psp +// * psx +// * uefi +// * unknown +// * vexos +// * zkvm +// +// Combined to target_vendor = "apple" +// * ios +// * macos +// * tvos +// * visionos +// * watchos +cfg_if! { + if #[cfg(target_os = "aix")] { + mod aix; + pub(crate) use aix::*; + } else if #[cfg(target_os = "android")] { + mod bionic_libc; + pub(crate) use bionic_libc::*; + } else if #[cfg(target_vendor = "apple")] { + mod apple; + pub(crate) use apple::*; + } else if #[cfg(target_os = "cygwin")] { + mod cygwin; + pub(crate) use cygwin::*; + } else if #[cfg(target_os = "dragonfly")] { + mod dragonfly; + pub(crate) use dragonfly::*; + } else if #[cfg(target_os = "emscripten")] { + mod emscripten; + pub use emscripten::sched::*; + pub(crate) use emscripten::*; + } else if #[cfg(target_os = "espidf")] { + mod espidf; + // pub(crate) use espidf::*; + } else if #[cfg(target_os = "freebsd")] { + mod freebsd; + pub(crate) use freebsd::*; + } else if #[cfg(target_os = "fuchsia")] { + mod fuchsia; + pub(crate) use fuchsia::*; + } else if #[cfg(target_os = "haiku")] { + mod haiku; + pub(crate) use haiku::*; + } else if #[cfg(target_os = "hermit")] { + mod hermit_abi; + // pub(crate) use hermit_abi::*; + } else if #[cfg(target_os = "horizon")] { + mod horizon; + // pub(crate) use horizon::*; + } else if #[cfg(target_os = "hurd")] { + mod hurd; + // pub(crate) use hurd::*; + } else if #[cfg(target_os = "illumos")] { + mod illumos; + pub(crate) use illumos::*; + } else if #[cfg(target_os = "l4re")] { + mod l4re; + // pub(crate) use l4re::*; + } else if #[cfg(target_os = "linux")] { + mod linux_uapi; + pub(crate) use linux_uapi::*; + } else if #[cfg(target_os = "netbsd")] { + mod netbsd; + pub(crate) use netbsd::*; + } else if #[cfg(target_os = "nto")] { + mod nto; + pub(crate) use nto::*; + } else if #[cfg(target_os = "nuttx")] { + mod nuttx; + pub(crate) use nuttx::*; + } else if #[cfg(target_os = "openbsd")] { + mod openbsd; + pub(crate) use openbsd::*; + } else if #[cfg(target_os = "qurt")] { + pub mod qurt; + pub use qurt::*; + } else if #[cfg(target_os = "redox")] { + mod redox; + // pub(crate) use redox::*; + } else if #[cfg(target_os = "rtems")] { + mod rtems; + // pub(crate) use rtems::*; + } else if #[cfg(target_os = "solaris")] { + mod solaris; + pub(crate) use solaris::*; + } else if #[cfg(target_os = "solid_asp3")] { + mod solid; + // pub(crate) use solid::*; + } else if #[cfg(target_os = "teeos")] { + mod teeos; + // pub(crate) use teeos::*; + } else if #[cfg(target_os = "trusty")] { + mod trusty; + // pub(crate) use trusty::*; + } else if #[cfg(target_os = "vita")] { + mod vita; + // pub(crate) use vita::*; + } else if #[cfg(target_os = "vxworks")] { + mod vxworks; + pub(crate) use vxworks::*; + } else if #[cfg(target_os = "wasi")] { + mod wasi; + // pub(crate) use wasi::*; + } else if #[cfg(target_os = "windows")] { + mod ucrt; + // pub(crate) use ucrt::*; + } else if #[cfg(target_os = "xous")] { + mod xous; + // pub(crate) use xous::*; + } +} + +// Multi-platform libc +cfg_if! { + // FIXME(vxworks): vxworks sets `target_env = "gnu"` but maybe shouldn't. + if #[cfg(all( + target_family = "unix", + target_env = "gnu", + not(target_os = "vxworks") + ))] { + mod glibc; + pub(crate) use glibc::*; + } else if #[cfg(any(target_env = "musl", target_env = "ohos"))] { + // OhOS also uses the musl libc + mod musl; + pub use musl::sched::*; + pub(crate) use musl::*; + } else if #[cfg(target_env = "newlib")] { + mod newlib; + pub(crate) use newlib::*; + } else if #[cfg(target_env = "relibc")] { + mod relibc; + pub(crate) use relibc::*; + } else if #[cfg(target_env = "sgx")] { + mod sgx; + // pub(crate) use sgx::*; + } else if #[cfg(target_env = "uclibc")] { + mod uclibc; + pub(crate) use uclibc::*; + } +} + +// Per-OS headers we export +cfg_if! { + if #[cfg(target_os = "android")] { + pub use sys::socket::*; + } else if #[cfg(target_os = "linux")] { + pub use linux::can::bcm::*; + pub use linux::can::error::*; + pub use linux::can::j1939::*; + pub use linux::can::netlink::*; + pub use linux::can::raw::*; + pub use linux::can::*; + pub use linux::keyctl::*; + pub use linux::membarrier::*; + pub use linux::netlink::*; + pub use linux::pidfd::*; + #[cfg(target_env = "gnu")] + pub use net::route::*; + } else if #[cfg(target_vendor = "apple")] { + pub use pthread::*; + pub use pthread_::introspection::*; + pub use pthread_::pthread_spis::*; + pub use pthread_::spawn::*; + pub use pthread_::stack_np::*; + pub use signal::*; + } else if #[cfg(target_os = "netbsd")] { + pub use net::if_::*; + pub use sys::file::*; + pub use sys::ipc::*; + pub use sys::socket::*; + pub use sys::statvfs::*; + pub use sys::time::*; + pub use sys::timex::*; + pub use sys::types::*; + pub use utmp_::*; + pub use utmpx_::*; + } else if #[cfg(target_os = "openbsd")] { + pub use sys::ipc::*; + } else if #[cfg(target_os = "nto")] { + pub use net::bpf::*; + pub use net::if_::*; + } else if #[cfg(target_os = "freebsd")] { + pub use sys::file::*; + } +} + +// Per-env headers we export +cfg_if! { + if #[cfg(any(target_env = "musl", target_env = "ohos"))] { + pub use sys::socket::*; + } +} + +// Per-family headers we export +cfg_if! { + if #[cfg(all(target_family = "unix", not(target_os = "qurt")))] { + // FIXME(pthread): eventually all platforms should use this module + #[cfg(any( + target_os = "android", + target_os = "emscripten", + target_os = "l4re", + target_os = "linux" + ))] + pub use pthread::*; + pub use unistd::*; + } +} diff --git a/http/vendor/libc/src/new/musl/arch/generic/mod.rs b/http/vendor/libc/src/new/musl/arch/generic/mod.rs new file mode 100644 index 0000000..ac02505 --- /dev/null +++ b/http/vendor/libc/src/new/musl/arch/generic/mod.rs @@ -0,0 +1,7 @@ +//! Source directory: `arch/generic/` +//! +//! + +pub(crate) mod bits { + // Currently unused +} diff --git a/http/vendor/libc/src/new/musl/arch/mips/bits/socket.rs b/http/vendor/libc/src/new/musl/arch/mips/bits/socket.rs new file mode 100644 index 0000000..77b53e4 --- /dev/null +++ b/http/vendor/libc/src/new/musl/arch/mips/bits/socket.rs @@ -0,0 +1,4 @@ +use crate::prelude::*; + +pub const SOCK_STREAM: c_int = 2; +pub const SOCK_DGRAM: c_int = 1; diff --git a/http/vendor/libc/src/new/musl/arch/mips/mod.rs b/http/vendor/libc/src/new/musl/arch/mips/mod.rs new file mode 100644 index 0000000..2f02036 --- /dev/null +++ b/http/vendor/libc/src/new/musl/arch/mips/mod.rs @@ -0,0 +1,7 @@ +//! Source directory: `arch/mips/` +//! +//! + +pub(crate) mod bits { + pub(crate) mod socket; +} diff --git a/http/vendor/libc/src/new/musl/arch/mips64/bits/socket.rs b/http/vendor/libc/src/new/musl/arch/mips64/bits/socket.rs new file mode 100644 index 0000000..77b53e4 --- /dev/null +++ b/http/vendor/libc/src/new/musl/arch/mips64/bits/socket.rs @@ -0,0 +1,4 @@ +use crate::prelude::*; + +pub const SOCK_STREAM: c_int = 2; +pub const SOCK_DGRAM: c_int = 1; diff --git a/http/vendor/libc/src/new/musl/arch/mips64/mod.rs b/http/vendor/libc/src/new/musl/arch/mips64/mod.rs new file mode 100644 index 0000000..6a45b06 --- /dev/null +++ b/http/vendor/libc/src/new/musl/arch/mips64/mod.rs @@ -0,0 +1,7 @@ +//! Source directory: `arch/mips64/` +//! +//! + +pub(crate) mod bits { + pub(crate) mod socket; +} diff --git a/http/vendor/libc/src/new/musl/arch/mod.rs b/http/vendor/libc/src/new/musl/arch/mod.rs new file mode 100644 index 0000000..514d7b4 --- /dev/null +++ b/http/vendor/libc/src/new/musl/arch/mod.rs @@ -0,0 +1,10 @@ +//! Source directory: `arch/` +//! +//! + +pub(crate) mod generic; + +#[cfg(target_arch = "mips")] +pub(crate) mod mips; +#[cfg(target_arch = "mips64")] +pub(crate) mod mips64; diff --git a/http/vendor/libc/src/new/musl/mod.rs b/http/vendor/libc/src/new/musl/mod.rs new file mode 100644 index 0000000..a6551c3 --- /dev/null +++ b/http/vendor/libc/src/new/musl/mod.rs @@ -0,0 +1,33 @@ +//! Musl libc. +//! +//! * Headers: (official) +//! * Headers: (mirror) + +// The musl build system includes `arch/$(ARCH)` (preferred if it exists) and `arch/generic` (used +// as the fallback). We can't exactly mirror this with glob exports, so instead we selectively +// reexport in a new module. +mod arch; + +pub(crate) mod bits { + cfg_if! { + if #[cfg(target_arch = "mips")] { + pub(crate) use super::arch::mips::bits::socket; + } else if #[cfg(target_arch = "mips64")] { + pub(crate) use super::arch::mips64::bits::socket; + } else { + // Reexports from generic will live here once we need them. + } + } +} + +pub(crate) mod pthread; + +/// Directory: `sys/` +/// +/// +pub(crate) mod sys { + pub(crate) mod socket; +} + +pub(crate) mod sched; +pub(crate) mod unistd; diff --git a/http/vendor/libc/src/new/musl/pthread.rs b/http/vendor/libc/src/new/musl/pthread.rs new file mode 100644 index 0000000..0d578bc --- /dev/null +++ b/http/vendor/libc/src/new/musl/pthread.rs @@ -0,0 +1,62 @@ +//! Header: `pthread.h` +//! +//! + +pub use crate::new::common::linux_like::pthread::{ + pthread_getaffinity_np, + pthread_getattr_np, + pthread_getname_np, + pthread_setaffinity_np, + pthread_setname_np, +}; +pub use crate::new::common::posix::pthread::{ + pthread_atfork, + pthread_attr_getguardsize, + pthread_attr_getinheritsched, + pthread_attr_getschedparam, + pthread_attr_getschedpolicy, + pthread_attr_getstack, + pthread_attr_setguardsize, + pthread_attr_setinheritsched, + pthread_attr_setschedparam, + pthread_attr_setschedpolicy, + pthread_attr_setstack, + pthread_barrier_destroy, + pthread_barrier_init, + pthread_barrier_wait, + pthread_barrierattr_destroy, + pthread_barrierattr_getpshared, + pthread_barrierattr_init, + pthread_barrierattr_setpshared, + pthread_condattr_getclock, + pthread_condattr_getpshared, + pthread_condattr_setclock, + pthread_condattr_setpshared, + pthread_create, + pthread_getcpuclockid, + pthread_getschedparam, + pthread_kill, + pthread_mutex_timedlock, + pthread_mutexattr_getprotocol, + pthread_mutexattr_getpshared, + pthread_mutexattr_setprotocol, + pthread_mutexattr_setpshared, + pthread_once, + pthread_rwlockattr_getpshared, + pthread_rwlockattr_setpshared, + pthread_setschedparam, + pthread_setschedprio, + pthread_sigmask, + pthread_spin_destroy, + pthread_spin_init, + pthread_spin_lock, + pthread_spin_trylock, + pthread_spin_unlock, +}; +#[cfg(not(target_env = "ohos"))] +pub use crate::new::common::posix::pthread::{ + pthread_cancel, + pthread_mutex_consistent, + pthread_mutexattr_getrobust, + pthread_mutexattr_setrobust, +}; diff --git a/http/vendor/libc/src/new/musl/sched.rs b/http/vendor/libc/src/new/musl/sched.rs new file mode 100644 index 0000000..3bf854e --- /dev/null +++ b/http/vendor/libc/src/new/musl/sched.rs @@ -0,0 +1,38 @@ +use crate::prelude::*; + +cfg_if! { + if #[cfg(musl_v1_2_3)] { + s! { + struct __c_anon_sched_param__reserved2 { + __reserved1: crate::time_t, + __reserved2: c_long, + } + + pub struct sched_param { + pub sched_priority: c_int, + + __reserved1: Padding, + #[cfg(musl32_time64)] + __reserved2: Padding<[c_long; 4]>, + #[cfg(not(musl32_time64))] + __reserved2: Padding<[__c_anon_sched_param__reserved2; 2]>, + __reserved3: Padding, + } + } + } else { + s! { + pub struct sched_param { + pub sched_priority: c_int, + + #[deprecated(since = "0.2.173", note = "This field has been removed upstream")] + pub sched_ss_low_priority: c_int, + #[deprecated(since = "0.2.173", note = "This field has been removed upstream")] + pub sched_ss_repl_period: crate::timespec, + #[deprecated(since = "0.2.173", note = "This field has been removed upstream")] + pub sched_ss_init_budget: crate::timespec, + #[deprecated(since = "0.2.173", note = "This field has been removed upstream")] + pub sched_ss_max_repl: c_int, + } + } + } +} diff --git a/http/vendor/libc/src/new/musl/sys/socket.rs b/http/vendor/libc/src/new/musl/sys/socket.rs new file mode 100644 index 0000000..7d3f495 --- /dev/null +++ b/http/vendor/libc/src/new/musl/sys/socket.rs @@ -0,0 +1,64 @@ +//! Header: `sys/socket.h` +//! +//! + +use crate::prelude::*; + +s! { + pub struct msghdr { + pub msg_name: *mut c_void, + pub msg_namelen: crate::socklen_t, + pub msg_iov: *mut crate::iovec, + #[cfg(all(target_pointer_width = "64", target_endian = "big"))] + __pad1: Padding, + pub msg_iovlen: c_int, + #[cfg(all(target_pointer_width = "64", target_endian = "little"))] + __pad1: Padding, + pub msg_control: *mut c_void, + #[cfg(all(target_pointer_width = "64", target_endian = "big"))] + __pad2: Padding, + pub msg_controllen: crate::socklen_t, + #[cfg(all(target_pointer_width = "64", target_endian = "little"))] + __pad2: Padding, + pub msg_flags: c_int, + } + + pub struct cmsghdr { + #[cfg(all(target_pointer_width = "64", target_endian = "big"))] + pub __pad1: c_int, + pub cmsg_len: crate::socklen_t, + #[cfg(all(target_pointer_width = "64", target_endian = "little"))] + pub __pad1: c_int, + pub cmsg_level: c_int, + pub cmsg_type: c_int, + } +} + +extern "C" { + pub fn sendmmsg( + sockfd: c_int, + msgvec: *mut crate::mmsghdr, + vlen: c_uint, + flags: c_uint, + ) -> c_int; + #[cfg_attr(musl_redir_time64, link_name = "__recvmmsg_time64")] + pub fn recvmmsg( + sockfd: c_int, + msgvec: *mut crate::mmsghdr, + vlen: c_uint, + flags: c_uint, + timeout: *mut crate::timespec, + ) -> c_int; +} + +cfg_if! { + if #[cfg(any(target_arch = "mips", target_arch = "mips64"))] { + pub use crate::bits::socket::{ + SOCK_DGRAM, + SOCK_STREAM, + }; + } else { + pub const SOCK_STREAM: c_int = 1; + pub const SOCK_DGRAM: c_int = 2; + } +} diff --git a/http/vendor/libc/src/new/musl/unistd.rs b/http/vendor/libc/src/new/musl/unistd.rs new file mode 100644 index 0000000..8d55ee5 --- /dev/null +++ b/http/vendor/libc/src/new/musl/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/http/vendor/libc/src/new/netbsd/mod.rs b/http/vendor/libc/src/new/netbsd/mod.rs new file mode 100644 index 0000000..5db7176 --- /dev/null +++ b/http/vendor/libc/src/new/netbsd/mod.rs @@ -0,0 +1,14 @@ +//! NetBSD libc. +//! +//! * Headers: +//! * Sys headers: +//! * Manual pages: + +pub(crate) mod net { + pub(crate) mod if_; +} + +pub(crate) mod sys; +pub(crate) mod unistd; +pub(crate) mod utmp_; +pub(crate) mod utmpx_; diff --git a/http/vendor/libc/src/new/netbsd/net/if_.rs b/http/vendor/libc/src/new/netbsd/net/if_.rs new file mode 100644 index 0000000..68f2d91 --- /dev/null +++ b/http/vendor/libc/src/new/netbsd/net/if_.rs @@ -0,0 +1,101 @@ +//! Header: `net/if.h` +//! +//! + +use crate::prelude::*; +use crate::IFNAMSIZ; + +s! { + pub struct if_data { + pub ifi_type: c_uchar, + pub ifi_addrlen: c_uchar, + pub ifi_hdrlen: c_uchar, + pub ifi_link_state: c_int, + pub ifi_mtu: u64, + pub ifi_metric: u64, + pub ifi_baudrate: u64, + pub ifi_ipackets: u64, + pub ifi_ierrors: u64, + pub ifi_opackets: u64, + pub ifi_oerrors: u64, + pub ifi_collisions: u64, + pub ifi_ibytes: u64, + pub ifi_obytes: u64, + pub ifi_imcasts: u64, + pub ifi_omcasts: u64, + pub ifi_iqdrops: u64, + pub ifi_noproto: u64, + pub ifi_lastchange: crate::timespec, + } +} + +pub const LINK_STATE_UNKNOWN: c_int = 0; // link invalid/unknown +pub const LINK_STATE_DOWN: c_int = 1; // link is down +pub const LINK_STATE_UP: c_int = 2; // link is up + +pub const IFF_UP: c_int = 0x0001; // interface is up +pub const IFF_BROADCAST: c_int = 0x0002; // broadcast address valid +pub const IFF_DEBUG: c_int = 0x0004; // turn on debugging +pub const IFF_LOOPBACK: c_int = 0x0008; // is a loopback net +pub const IFF_POINTOPOINT: c_int = 0x0010; // interface is point-to-point link +pub const IFF_RUNNING: c_int = 0x0040; // resources allocated +pub const IFF_NOARP: c_int = 0x0080; // no address resolution protocol +pub const IFF_PROMISC: c_int = 0x0100; // receive all packets +pub const IFF_ALLMULTI: c_int = 0x0200; // receive all multicast packets +pub const IFF_OACTIVE: c_int = 0x0400; // transmission in progress +pub const IFF_SIMPLEX: c_int = 0x0800; // can't hear own transmissions +pub const IFF_LINK0: c_int = 0x1000; // per link layer defined bit +pub const IFF_LINK1: c_int = 0x2000; // per link layer defined bit +pub const IFF_LINK2: c_int = 0x4000; // per link layer defined bit +pub const IFF_MULTICAST: c_int = 0x8000; // supports multicast + +s! { + #[repr(C, align(8))] + pub struct if_msghdr { + pub ifm_msglen: c_ushort, + pub ifm_version: c_uchar, + pub ifm_type: c_uchar, + pub ifm_addrs: c_int, + pub ifm_flags: c_int, + pub ifm_index: c_ushort, + pub ifm_data: if_data, + } +} + +s_no_extra_traits! { + pub struct ifreq { + pub ifr_name: [c_char; IFNAMSIZ], + pub ifr_ifru: __c_anonymous_ifr_ifru, + } + + pub union __c_anonymous_ifr_ifru { + pub ifru_addr: crate::sockaddr, + pub ifru_dstaddr: crate::sockaddr, + pub ifru_broadaddr: crate::sockaddr, + pub space: crate::sockaddr_storage, + pub ifru_flags: c_short, + pub ifru_addrflags: c_int, + pub ifru_metrics: c_int, + pub ifru_mtu: c_int, + pub ifru_dlt: c_int, + pub ifru_value: c_uint, + pub ifru_data: *mut c_void, + // buf and buflen are deprecated but they contribute to union size + ifru_b: __c_anonymous_ifr_ifru_ifru_b, + } + + struct __c_anonymous_ifr_ifru_ifru_b { + b_buflen: u32, + b_buf: *mut c_void, + } + + pub struct ifconf { + pub ifc_len: c_int, + pub ifc_ifcu: __c_anonymous_ifc_ifcu, + } + + pub union __c_anonymous_ifc_ifcu { + pub ifcu_buf: *mut c_void, + pub ifcu_req: *mut ifreq, + } +} diff --git a/http/vendor/libc/src/new/netbsd/sys/file.rs b/http/vendor/libc/src/new/netbsd/sys/file.rs new file mode 100644 index 0000000..103b68d --- /dev/null +++ b/http/vendor/libc/src/new/netbsd/sys/file.rs @@ -0,0 +1,16 @@ +//! Header: `sys/file.h` +//! +//! + +use crate::prelude::*; + +pub const DTYPE_VNODE: c_int = 1; +pub const DTYPE_SOCKET: c_int = 2; +pub const DTYPE_PIPE: c_int = 3; +pub const DTYPE_KQUEUE: c_int = 4; +pub const DTYPE_MISC: c_int = 5; +pub const DTYPE_CRYPTO: c_int = 6; +pub const DTYPE_MQUEUE: c_int = 7; +pub const DTYPE_SEM: c_int = 8; +pub const DTYPE_EVENTFD: c_int = 9; +pub const DTYPE_TIMERFD: c_int = 10; diff --git a/http/vendor/libc/src/new/netbsd/sys/ipc.rs b/http/vendor/libc/src/new/netbsd/sys/ipc.rs new file mode 100644 index 0000000..49a1c84 --- /dev/null +++ b/http/vendor/libc/src/new/netbsd/sys/ipc.rs @@ -0,0 +1,17 @@ +//! Header: `sys/ipc.h` +//! +//! + +use crate::prelude::*; + +s! { + pub struct ipc_perm { + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: crate::mode_t, + pub _seq: c_ushort, + pub _key: crate::key_t, + } +} diff --git a/http/vendor/libc/src/new/netbsd/sys/mod.rs b/http/vendor/libc/src/new/netbsd/sys/mod.rs new file mode 100644 index 0000000..b7255d8 --- /dev/null +++ b/http/vendor/libc/src/new/netbsd/sys/mod.rs @@ -0,0 +1,11 @@ +//! Directory: `sys/` +//! +//! https://github.com/NetBSD/src/tree/trunk/sys/sys + +pub(crate) mod file; +pub(crate) mod ipc; +pub(crate) mod socket; +pub(crate) mod statvfs; +pub(crate) mod time; +pub(crate) mod timex; +pub(crate) mod types; diff --git a/http/vendor/libc/src/new/netbsd/sys/socket.rs b/http/vendor/libc/src/new/netbsd/sys/socket.rs new file mode 100644 index 0000000..9535260 --- /dev/null +++ b/http/vendor/libc/src/new/netbsd/sys/socket.rs @@ -0,0 +1,44 @@ +//! Header: `sys/socket.h` +//! +//! +//! + +use crate::prelude::*; + +s_no_extra_traits! { + pub union __c_anonymous_pcb_sockaddr_src { + pub _kis_src: crate::sockaddr, + _kis_pad: Padding<[c_char; 256 + 8]>, + } + + pub union __c_anonymous_pcb_sockaddr_dst { + pub _kid_dst: crate::sockaddr, + _kid_pad: Padding<[c_char; 256 + 8]>, + } + + pub struct kinfo_pcb { + pub ki_pcbaddr: u64, + pub ki_ppcbaddr: u64, + pub ki_sockaddr: u64, + pub ki_family: u32, + pub ki_type: u32, + pub ki_protocol: u32, + pub ki_pflags: u32, + pub ki_sostate: u32, + pub ki_prstate: u32, + pub ki_tstate: i32, + pub ki_tflags: u32, + pub ki_rcvq: u64, + pub ki_sndq: u64, + pub ki_s: __c_anonymous_pcb_sockaddr_src, + pub ki_d: __c_anonymous_pcb_sockaddr_dst, + pub ki_inode: u64, + pub ki_vnode: u64, + pub ki_conn: u64, + pub ki_refs: u64, + pub ki_nextref: u64, + } +} + +pub const PCB_SLOP: c_int = 20; +pub const PCB_ALL: c_int = 0; diff --git a/http/vendor/libc/src/new/netbsd/sys/statvfs.rs b/http/vendor/libc/src/new/netbsd/sys/statvfs.rs new file mode 100644 index 0000000..eee3766 --- /dev/null +++ b/http/vendor/libc/src/new/netbsd/sys/statvfs.rs @@ -0,0 +1,47 @@ +//! Header: `sys/statvfs.h` +//! +//! + +use crate::prelude::*; + +const _VFS_NAMELEN: usize = 32; +const _VFS_MNAMELEN: usize = 1024; + +s! { + pub struct statvfs { + pub f_flag: c_ulong, + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_iosize: c_ulong, + + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_bresvd: crate::fsblkcnt_t, + + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_favail: crate::fsfilcnt_t, + pub f_fresvd: crate::fsfilcnt_t, + + pub f_syncreads: u64, + pub f_syncwrites: u64, + + pub f_asyncreads: u64, + pub f_asyncwrites: u64, + + pub f_fsidx: crate::fsid_t, + pub f_fsid: c_ulong, + pub f_namemax: c_ulong, + pub f_owner: crate::uid_t, + + // This type is updated in a future version + f_spare: [u32; 4], + + pub f_fstypename: [c_char; _VFS_NAMELEN], + pub f_mntonname: [c_char; _VFS_MNAMELEN], + pub f_mntfromname: [c_char; _VFS_MNAMELEN], + // Added in NetBSD10 + // pub f_mntfromlabel: [c_char; _VFS_MNAMELEN], + } +} diff --git a/http/vendor/libc/src/new/netbsd/sys/time.rs b/http/vendor/libc/src/new/netbsd/sys/time.rs new file mode 100644 index 0000000..b776b2a --- /dev/null +++ b/http/vendor/libc/src/new/netbsd/sys/time.rs @@ -0,0 +1,15 @@ +//! Header: `sys/time.h` +//! +//! + +s! { + pub struct itimerspec { + pub it_interval: crate::timespec, + pub it_value: crate::timespec, + } +} + +pub const CLOCK_VIRTUAL: crate::clockid_t = 1; +pub const CLOCK_PROF: crate::clockid_t = 2; +pub const CLOCK_THREAD_CPUTIME_ID: crate::clockid_t = 0x20000000; +pub const CLOCK_PROCESS_CPUTIME_ID: crate::clockid_t = 0x40000000; diff --git a/http/vendor/libc/src/new/netbsd/sys/timex.rs b/http/vendor/libc/src/new/netbsd/sys/timex.rs new file mode 100644 index 0000000..82844bf --- /dev/null +++ b/http/vendor/libc/src/new/netbsd/sys/timex.rs @@ -0,0 +1,95 @@ +//! Header: `sys/timex.h` +//! +//! + +use crate::prelude::*; + +pub const MAXPHASE: c_long = 500000000; +pub const MAXFREQ: c_long = 500000; +pub const MINSEC: c_int = 256; +pub const MAXSEC: c_int = 2048; +pub const NANOSECOND: c_long = 1000000000; +pub const SCALE_PPM: c_int = 65; +pub const MAXTC: c_int = 10; + +pub const MOD_OFFSET: c_uint = 0x0001; +pub const MOD_FREQUENCY: c_uint = 0x0002; +pub const MOD_MAXERROR: c_uint = 0x0004; +pub const MOD_ESTERROR: c_uint = 0x0008; +pub const MOD_STATUS: c_uint = 0x0010; +pub const MOD_TIMECONST: c_uint = 0x0020; +pub const MOD_PPSMAX: c_uint = 0x0040; +pub const MOD_TAI: c_uint = 0x0080; +pub const MOD_MICRO: c_uint = 0x1000; +pub const MOD_NANO: c_uint = 0x2000; +pub const MOD_CLKB: c_uint = 0x4000; +pub const MOD_CLKA: c_uint = 0x8000; + +pub const STA_PLL: c_int = 0x0001; +pub const STA_PPSFREQ: c_int = 0x0002; +pub const STA_PPSTIME: c_int = 0x0004; +pub const STA_FLL: c_int = 0x0008; +pub const STA_INS: c_int = 0x0010; +pub const STA_DEL: c_int = 0x0020; +pub const STA_UNSYNC: c_int = 0x0040; +pub const STA_FREQHOLD: c_int = 0x0080; +pub const STA_PPSSIGNAL: c_int = 0x0100; +pub const STA_PPSJITTER: c_int = 0x0200; +pub const STA_PPSWANDER: c_int = 0x0400; +pub const STA_PPSERROR: c_int = 0x0800; +pub const STA_CLOCKERR: c_int = 0x1000; +pub const STA_NANO: c_int = 0x2000; +pub const STA_MODE: c_int = 0x4000; +pub const STA_CLK: c_int = 0x8000; + +pub const STA_RONLY: c_int = STA_PPSSIGNAL + | STA_PPSJITTER + | STA_PPSWANDER + | STA_PPSERROR + | STA_CLOCKERR + | STA_NANO + | STA_MODE + | STA_CLK; + +pub const TIME_OK: c_int = 0; +pub const TIME_INS: c_int = 1; +pub const TIME_DEL: c_int = 2; +pub const TIME_OOP: c_int = 3; +pub const TIME_WAIT: c_int = 4; +pub const TIME_ERROR: c_int = 5; + +s! { + pub struct ntptimeval { + pub time: crate::timespec, + pub maxerror: c_long, + pub esterror: c_long, + pub tai: c_long, + pub time_state: c_int, + } + + pub struct timex { + pub modes: c_uint, + pub offset: c_long, + pub freq: c_long, + pub maxerror: c_long, + pub esterror: c_long, + pub status: c_int, + pub constant: c_long, + pub precision: c_long, + pub tolerance: c_long, + pub ppsfreq: c_long, + pub jitter: c_long, + pub shift: c_int, + pub stabil: c_long, + pub jitcnt: c_long, + pub calcnt: c_long, + pub errcnt: c_long, + pub stbcnt: c_long, + } +} + +extern "C" { + #[link_name = "__ntp_gettime50"] + pub fn ntp_gettime(buf: *mut ntptimeval) -> c_int; + pub fn ntp_adjtime(buf: *mut timex) -> c_int; +} diff --git a/http/vendor/libc/src/new/netbsd/sys/types.rs b/http/vendor/libc/src/new/netbsd/sys/types.rs new file mode 100644 index 0000000..8dfc049 --- /dev/null +++ b/http/vendor/libc/src/new/netbsd/sys/types.rs @@ -0,0 +1,16 @@ +//! Header: `sys/types.h` +//! +//! + +use crate::prelude::*; + +pub type dev_t = u64; + +pub type lwpid_t = i32; + +pub type mqd_t = c_int; +pub type cpuid_t = c_ulong; + +pub type clock_t = c_uint; +pub type timer_t = c_int; +pub type suseconds_t = c_int; diff --git a/http/vendor/libc/src/new/netbsd/unistd.rs b/http/vendor/libc/src/new/netbsd/unistd.rs new file mode 100644 index 0000000..8d55ee5 --- /dev/null +++ b/http/vendor/libc/src/new/netbsd/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/http/vendor/libc/src/new/netbsd/utmp_.rs b/http/vendor/libc/src/new/netbsd/utmp_.rs new file mode 100644 index 0000000..2047449 --- /dev/null +++ b/http/vendor/libc/src/new/netbsd/utmp_.rs @@ -0,0 +1,33 @@ +//! Header: `utmp.h` +//! +//! + +use crate::prelude::*; + +pub const UT_NAMESIZE: usize = 8; +pub const UT_LINESIZE: usize = 8; +pub const UT_HOSTSIZE: usize = 16; + +s! { + pub struct lastlog { + pub ll_time: crate::time_t, + pub ll_line: [c_char; UT_LINESIZE], + pub ll_host: [c_char; UT_HOSTSIZE], + } + + pub struct utmp { + pub ut_line: [c_char; UT_LINESIZE], + pub ut_name: [c_char; UT_NAMESIZE], + pub ut_host: [c_char; UT_HOSTSIZE], + pub ut_time: crate::time_t, + } +} + +#[link(name = "util")] +extern "C" { + pub fn utmpname(file: *const c_char) -> c_int; + pub fn setutent(); + #[link_name = "__getutent50"] + pub fn getutent() -> *mut utmp; + pub fn endutent(); +} diff --git a/http/vendor/libc/src/new/netbsd/utmpx_.rs b/http/vendor/libc/src/new/netbsd/utmpx_.rs new file mode 100644 index 0000000..7b07b0c --- /dev/null +++ b/http/vendor/libc/src/new/netbsd/utmpx_.rs @@ -0,0 +1,92 @@ +//! Header: `utmpx.h` +//! +//! + +use crate::prelude::*; + +// pub const _PATH_UTMPX: &[c_char; 14] = b"/var/run/utmpx"; +// pub const _PATH_WTMPX: &[c_char; 14] = b"/var/log/wtmpx"; +// pub const _PATH_LASTLOGX: &[c_char; 17] = b"/var/log/lastlogx"; +// pub const _PATH_UTMP_UPDATE: &[c_char; 24] = b"/usr/libexec/utmp_update"; + +pub const _UTX_USERSIZE: usize = 32; +pub const _UTX_LINESIZE: usize = 32; +pub const _UTX_IDSIZE: usize = 4; +pub const _UTX_HOSTSIZE: usize = 256; + +pub const EMPTY: u16 = 0; +pub const RUN_LVL: u16 = 1; +pub const BOOT_TIME: u16 = 2; +pub const OLD_TIME: u16 = 3; +pub const NEW_TIME: u16 = 4; +pub const INIT_PROCESS: u16 = 5; +pub const LOGIN_PROCESS: u16 = 6; +pub const USER_PROCESS: u16 = 7; +pub const DEAD_PROCESS: u16 = 8; +pub const ACCOUNTING: u16 = 9; +pub const SIGNATURE: u16 = 10; +pub const DOWN_TIME: u16 = 11; + +// Expression based on the comment in NetBSD source. +pub const _UTX_PADSIZE: usize = if cfg!(target_pointer_width = "64") { + 36 +} else { + 40 +}; + +s! { + pub struct utmpx { + pub ut_name: [c_char; _UTX_USERSIZE], + pub ut_id: [c_char; _UTX_IDSIZE], + pub ut_line: [c_char; _UTX_LINESIZE], + pub ut_host: [c_char; _UTX_HOSTSIZE], + pub ut_session: u16, + pub ut_type: u16, + pub ut_pid: crate::pid_t, + pub ut_exit: __exit_status, // FIXME(netbsd): when anonymous struct are supported + pub ut_ss: crate::sockaddr_storage, + pub ut_tv: crate::timeval, + ut_pad: Padding<[u8; _UTX_PADSIZE]>, + } + + pub struct __exit_status { + pub e_termination: u16, + pub e_exit: u16, + } + + pub struct lastlogx { + pub ll_tv: crate::timeval, + pub ll_line: [c_char; _UTX_LINESIZE], + pub ll_host: [c_char; _UTX_HOSTSIZE], + pub ll_ss: crate::sockaddr_storage, + } +} + +#[link(name = "util")] +extern "C" { + pub fn setutxent(); + pub fn endutxent(); + + #[link_name = "__getutxent50"] + pub fn getutxent() -> *mut utmpx; + #[link_name = "__getutxid50"] + pub fn getutxid(ut: *const utmpx) -> *mut utmpx; + #[link_name = "__getutxline50"] + pub fn getutxline(ut: *const utmpx) -> *mut utmpx; + #[link_name = "__pututxline50"] + pub fn pututxline(ut: *const utmpx) -> *mut utmpx; + + #[link_name = "__updwtmpx50"] + pub fn updwtmpx(file: *const c_char, ut: *const utmpx) -> c_int; + #[link_name = "__getlastlogx50"] + pub fn getlastlogx(fname: *const c_char, uid: crate::uid_t, ll: *mut lastlogx) + -> *mut lastlogx; + + #[link_name = "__updlastlogx50"] + pub fn updlastlogx(fname: *const c_char, uid: crate::uid_t, ll: *mut lastlogx) -> c_int; + #[link_name = "__getutmp50"] + pub fn getutmp(ux: *const utmpx, u: *mut crate::utmp); + #[link_name = "__getutmpx50"] + pub fn getutmpx(u: *const crate::utmp, ux: *mut utmpx); + pub fn utmpxname(file: *const c_char) -> c_int; +} diff --git a/http/vendor/libc/src/new/newlib/mod.rs b/http/vendor/libc/src/new/newlib/mod.rs new file mode 100644 index 0000000..b5c7e3d --- /dev/null +++ b/http/vendor/libc/src/new/newlib/mod.rs @@ -0,0 +1,4 @@ +//! Newlib libc. +// FIXME(newlib): link to headers needed. + +pub(crate) mod unistd; diff --git a/http/vendor/libc/src/new/newlib/unistd.rs b/http/vendor/libc/src/new/newlib/unistd.rs new file mode 100644 index 0000000..6b240be --- /dev/null +++ b/http/vendor/libc/src/new/newlib/unistd.rs @@ -0,0 +1,159 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; +use crate::prelude::*; + +pub const _SC_ARG_MAX: c_int = 0; +pub const _SC_CHILD_MAX: c_int = 1; +pub const _SC_CLK_TCK: c_int = 2; +pub const _SC_NGROUPS_MAX: c_int = 3; +pub const _SC_OPEN_MAX: c_int = 4; +pub const _SC_JOB_CONTROL: c_int = 5; +pub const _SC_SAVED_IDS: c_int = 6; +pub const _SC_VERSION: c_int = 7; +pub const _SC_PAGESIZE: c_int = 8; +pub const _SC_PAGE_SIZE: c_int = _SC_PAGESIZE; +pub const _SC_NPROCESSORS_CONF: c_int = 9; +pub const _SC_NPROCESSORS_ONLN: c_int = 10; +pub const _SC_PHYS_PAGES: c_int = 11; +pub const _SC_AVPHYS_PAGES: c_int = 12; +pub const _SC_MQ_OPEN_MAX: c_int = 13; +pub const _SC_MQ_PRIO_MAX: c_int = 14; +pub const _SC_RTSIG_MAX: c_int = 15; +pub const _SC_SEM_NSEMS_MAX: c_int = 16; +pub const _SC_SEM_VALUE_MAX: c_int = 17; +pub const _SC_SIGQUEUE_MAX: c_int = 18; +pub const _SC_TIMER_MAX: c_int = 19; +pub const _SC_TZNAME_MAX: c_int = 20; +pub const _SC_ASYNCHRONOUS_IO: c_int = 21; +pub const _SC_FSYNC: c_int = 22; +pub const _SC_MAPPED_FILES: c_int = 23; +pub const _SC_MEMLOCK: c_int = 24; +pub const _SC_MEMLOCK_RANGE: c_int = 25; +pub const _SC_MEMORY_PROTECTION: c_int = 26; +pub const _SC_MESSAGE_PASSING: c_int = 27; +pub const _SC_PRIORITIZED_IO: c_int = 28; +pub const _SC_REALTIME_SIGNALS: c_int = 29; +pub const _SC_SEMAPHORES: c_int = 30; +pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 31; +pub const _SC_SYNCHRONIZED_IO: c_int = 32; +pub const _SC_TIMERS: c_int = 33; +pub const _SC_AIO_LISTIO_MAX: c_int = 34; +pub const _SC_AIO_MAX: c_int = 35; +pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 36; +pub const _SC_DELAYTIMER_MAX: c_int = 37; +pub const _SC_THREAD_KEYS_MAX: c_int = 38; +pub const _SC_THREAD_STACK_MIN: c_int = 39; +pub const _SC_THREAD_THREADS_MAX: c_int = 40; +pub const _SC_TTY_NAME_MAX: c_int = 41; +pub const _SC_THREADS: c_int = 42; +pub const _SC_THREAD_ATTR_STACKADDR: c_int = 43; +pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 44; +pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 45; +pub const _SC_THREAD_PRIO_INHERIT: c_int = 46; +pub const _SC_THREAD_PRIO_PROTECT: c_int = 47; +pub const _SC_THREAD_PRIO_CEILING: c_int = _SC_THREAD_PRIO_PROTECT; +pub const _SC_THREAD_PROCESS_SHARED: c_int = 48; +pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 49; +pub const _SC_GETGR_R_SIZE_MAX: c_int = 50; +pub const _SC_GETPW_R_SIZE_MAX: c_int = 51; +pub const _SC_LOGIN_NAME_MAX: c_int = 52; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 53; +pub const _SC_ADVISORY_INFO: c_int = 54; +pub const _SC_ATEXIT_MAX: c_int = 55; +pub const _SC_BARRIERS: c_int = 56; +pub const _SC_BC_BASE_MAX: c_int = 57; +pub const _SC_BC_DIM_MAX: c_int = 58; +pub const _SC_BC_SCALE_MAX: c_int = 59; +pub const _SC_BC_STRING_MAX: c_int = 60; +pub const _SC_CLOCK_SELECTION: c_int = 61; +pub const _SC_COLL_WEIGHTS_MAX: c_int = 62; +pub const _SC_CPUTIME: c_int = 63; +pub const _SC_EXPR_NEST_MAX: c_int = 64; +pub const _SC_HOST_NAME_MAX: c_int = 65; +pub const _SC_IOV_MAX: c_int = 66; +pub const _SC_IPV6: c_int = 67; +pub const _SC_LINE_MAX: c_int = 68; +pub const _SC_MONOTONIC_CLOCK: c_int = 69; +pub const _SC_RAW_SOCKETS: c_int = 70; +pub const _SC_READER_WRITER_LOCKS: c_int = 71; +pub const _SC_REGEXP: c_int = 72; +pub const _SC_RE_DUP_MAX: c_int = 73; +pub const _SC_SHELL: c_int = 74; +pub const _SC_SPAWN: c_int = 75; +pub const _SC_SPIN_LOCKS: c_int = 76; +pub const _SC_SPORADIC_SERVER: c_int = 77; +pub const _SC_SS_REPL_MAX: c_int = 78; +pub const _SC_SYMLOOP_MAX: c_int = 79; +pub const _SC_THREAD_CPUTIME: c_int = 80; +pub const _SC_THREAD_SPORADIC_SERVER: c_int = 81; +pub const _SC_TIMEOUTS: c_int = 82; +pub const _SC_TRACE: c_int = 83; +pub const _SC_TRACE_EVENT_FILTER: c_int = 84; +pub const _SC_TRACE_EVENT_NAME_MAX: c_int = 85; +pub const _SC_TRACE_INHERIT: c_int = 86; +pub const _SC_TRACE_LOG: c_int = 87; +pub const _SC_TRACE_NAME_MAX: c_int = 88; +pub const _SC_TRACE_SYS_MAX: c_int = 89; +pub const _SC_TRACE_USER_EVENT_MAX: c_int = 90; +pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 91; +pub const _SC_V7_ILP32_OFF32: c_int = 92; +pub const _SC_V6_ILP32_OFF32: c_int = _SC_V7_ILP32_OFF32; +pub const _SC_XBS5_ILP32_OFF32: c_int = _SC_V7_ILP32_OFF32; +pub const _SC_V7_ILP32_OFFBIG: c_int = 93; +pub const _SC_V6_ILP32_OFFBIG: c_int = _SC_V7_ILP32_OFFBIG; +pub const _SC_XBS5_ILP32_OFFBIG: c_int = _SC_V7_ILP32_OFFBIG; +pub const _SC_V7_LP64_OFF64: c_int = 94; +pub const _SC_V6_LP64_OFF64: c_int = _SC_V7_LP64_OFF64; +pub const _SC_XBS5_LP64_OFF64: c_int = _SC_V7_LP64_OFF64; +pub const _SC_V7_LPBIG_OFFBIG: c_int = 95; +pub const _SC_V6_LPBIG_OFFBIG: c_int = _SC_V7_LPBIG_OFFBIG; +pub const _SC_XBS5_LPBIG_OFFBIG: c_int = _SC_V7_LPBIG_OFFBIG; +pub const _SC_XOPEN_CRYPT: c_int = 96; +pub const _SC_XOPEN_ENH_I18N: c_int = 97; +pub const _SC_XOPEN_LEGACY: c_int = 98; +pub const _SC_XOPEN_REALTIME: c_int = 99; +pub const _SC_STREAM_MAX: c_int = 100; +pub const _SC_PRIORITY_SCHEDULING: c_int = 101; +pub const _SC_XOPEN_REALTIME_THREADS: c_int = 102; +pub const _SC_XOPEN_SHM: c_int = 103; +pub const _SC_XOPEN_STREAMS: c_int = 104; +pub const _SC_XOPEN_UNIX: c_int = 105; +pub const _SC_XOPEN_VERSION: c_int = 106; +pub const _SC_2_CHAR_TERM: c_int = 107; +pub const _SC_2_C_BIND: c_int = 108; +pub const _SC_2_C_DEV: c_int = 109; +pub const _SC_2_FORT_DEV: c_int = 110; +pub const _SC_2_FORT_RUN: c_int = 111; +pub const _SC_2_LOCALEDEF: c_int = 112; +pub const _SC_2_PBS: c_int = 113; +pub const _SC_2_PBS_ACCOUNTING: c_int = 114; +pub const _SC_2_PBS_CHECKPOINT: c_int = 115; +pub const _SC_2_PBS_LOCATE: c_int = 116; +pub const _SC_2_PBS_MESSAGE: c_int = 117; +pub const _SC_2_PBS_TRACK: c_int = 118; +pub const _SC_2_SW_DEV: c_int = 119; +pub const _SC_2_UPE: c_int = 120; +pub const _SC_2_VERSION: c_int = 121; +pub const _SC_THREAD_ROBUST_PRIO_INHERIT: c_int = 122; +pub const _SC_THREAD_ROBUST_PRIO_PROTECT: c_int = 123; +pub const _SC_XOPEN_UUCP: c_int = 124; +pub const _SC_LEVEL1_ICACHE_SIZE: c_int = 125; +pub const _SC_LEVEL1_ICACHE_ASSOC: c_int = 126; +pub const _SC_LEVEL1_ICACHE_LINESIZE: c_int = 127; +pub const _SC_LEVEL1_DCACHE_SIZE: c_int = 128; +pub const _SC_LEVEL1_DCACHE_ASSOC: c_int = 129; +pub const _SC_LEVEL1_DCACHE_LINESIZE: c_int = 130; +pub const _SC_LEVEL2_CACHE_SIZE: c_int = 131; +pub const _SC_LEVEL2_CACHE_ASSOC: c_int = 132; +pub const _SC_LEVEL2_CACHE_LINESIZE: c_int = 133; +pub const _SC_LEVEL3_CACHE_SIZE: c_int = 134; +pub const _SC_LEVEL3_CACHE_ASSOC: c_int = 135; +pub const _SC_LEVEL3_CACHE_LINESIZE: c_int = 136; +pub const _SC_LEVEL4_CACHE_SIZE: c_int = 137; +pub const _SC_LEVEL4_CACHE_ASSOC: c_int = 138; +pub const _SC_LEVEL4_CACHE_LINESIZE: c_int = 139; diff --git a/http/vendor/libc/src/new/nto/mod.rs b/http/vendor/libc/src/new/nto/mod.rs new file mode 100644 index 0000000..a625127 --- /dev/null +++ b/http/vendor/libc/src/new/nto/mod.rs @@ -0,0 +1,9 @@ +//! QNX Neutrino libc. +// FIXME(nto): link to manpages needed. + +pub(crate) mod unistd; + +pub(crate) mod net { + pub(crate) mod bpf; + pub(crate) mod if_; +} diff --git a/http/vendor/libc/src/new/nto/net/bpf.rs b/http/vendor/libc/src/new/nto/net/bpf.rs new file mode 100644 index 0000000..8b8dd71 --- /dev/null +++ b/http/vendor/libc/src/new/nto/net/bpf.rs @@ -0,0 +1,83 @@ +use crate::bpf_insn; + +pub const BPF_LD: u16 = 0x00; +pub const BPF_LDX: u16 = 0x01; +pub const BPF_ST: u16 = 0x02; +pub const BPF_STX: u16 = 0x03; +pub const BPF_ALU: u16 = 0x04; +pub const BPF_JMP: u16 = 0x05; +pub const BPF_RET: u16 = 0x06; +pub const BPF_MISC: u16 = 0x07; +pub const BPF_W: u16 = 0x00; +pub const BPF_H: u16 = 0x08; +pub const BPF_B: u16 = 0x10; +pub const BPF_IMM: u16 = 0x00; +pub const BPF_ABS: u16 = 0x20; +pub const BPF_IND: u16 = 0x40; +pub const BPF_MEM: u16 = 0x60; +pub const BPF_LEN: u16 = 0x80; +pub const BPF_MSH: u16 = 0xa0; +pub const BPF_ADD: u16 = 0x00; +pub const BPF_SUB: u16 = 0x10; +pub const BPF_MUL: u16 = 0x20; +pub const BPF_DIV: u16 = 0x30; +pub const BPF_OR: u16 = 0x40; +pub const BPF_AND: u16 = 0x50; +pub const BPF_LSH: u16 = 0x60; +pub const BPF_RSH: u16 = 0x70; +pub const BPF_NEG: u16 = 0x80; +pub const BPF_MOD: u16 = 0x90; +pub const BPF_XOR: u16 = 0xa0; +pub const BPF_JA: u16 = 0x00; +pub const BPF_JEQ: u16 = 0x10; +pub const BPF_JGT: u16 = 0x20; +pub const BPF_JGE: u16 = 0x30; +pub const BPF_JSET: u16 = 0x40; +pub const BPF_K: u16 = 0x00; +pub const BPF_X: u16 = 0x08; +pub const BPF_A: u16 = 0x10; +pub const BPF_TAX: u16 = 0x00; +pub const BPF_TXA: u16 = 0x80; + +f! { + pub fn BPF_CLASS(code: u32) -> u32 { + code & 0x07 + } + + pub fn BPF_SIZE(code: u32) -> u32 { + code & 0x18 + } + + pub fn BPF_MODE(code: u32) -> u32 { + code & 0xe0 + } + + pub fn BPF_OP(code: u32) -> u32 { + code & 0xf0 + } + + pub fn BPF_SRC(code: u32) -> u32 { + code & 0x08 + } + + pub fn BPF_RVAL(code: u32) -> u32 { + code & 0x18 + } + + pub fn BPF_MISCOP(code: u32) -> u32 { + code & 0xf8 + } + + pub fn BPF_STMT(code: u16, k: u32) -> bpf_insn { + bpf_insn { + code, + jt: 0, + jf: 0, + k, + } + } + + pub fn BPF_JUMP(code: u16, k: u32, jt: u8, jf: u8) -> bpf_insn { + bpf_insn { code, jt, jf, k } + } +} diff --git a/http/vendor/libc/src/new/nto/net/if_.rs b/http/vendor/libc/src/new/nto/net/if_.rs new file mode 100644 index 0000000..d71c1bb --- /dev/null +++ b/http/vendor/libc/src/new/nto/net/if_.rs @@ -0,0 +1,32 @@ +use crate::prelude::*; + +s_no_extra_traits! { + pub union __c_anonymous_ifr_ifru { + pub ifru_addr: crate::sockaddr, + pub ifru_dstaddr: crate::sockaddr, + pub ifru_broadaddr: crate::sockaddr, + pub ifru_buffer: ifreq_buffer, + pub ifru_flags: [c_short; 2], + pub ifru_index: c_short, + pub ifru_jid: c_int, + pub ifru_metric: c_int, + pub ifru_mtu: c_int, + pub ifru_phys: c_int, + pub ifru_media: c_int, + pub ifru_data: *mut c_char, + pub ifru_cap: [c_int; 2], + pub ifru_fib: c_uint, + pub ifru_vlan_pcp: c_uchar, + } + + pub struct ifreq { + /// if name, e.g. "en0" + pub ifr_name: [c_char; crate::IFNAMSIZ], + pub ifr_ifru: __c_anonymous_ifr_ifru, + } + + pub struct ifreq_buffer { + pub length: size_t, + pub buffer: *mut c_void, + } +} diff --git a/http/vendor/libc/src/new/nto/unistd.rs b/http/vendor/libc/src/new/nto/unistd.rs new file mode 100644 index 0000000..8d55ee5 --- /dev/null +++ b/http/vendor/libc/src/new/nto/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/http/vendor/libc/src/new/nuttx/mod.rs b/http/vendor/libc/src/new/nuttx/mod.rs new file mode 100644 index 0000000..513c945 --- /dev/null +++ b/http/vendor/libc/src/new/nuttx/mod.rs @@ -0,0 +1,4 @@ +//! RTEMS libc. +// FIXME(nuttx): link to headers needed. + +pub(crate) mod unistd; diff --git a/http/vendor/libc/src/new/nuttx/unistd.rs b/http/vendor/libc/src/new/nuttx/unistd.rs new file mode 100644 index 0000000..8d55ee5 --- /dev/null +++ b/http/vendor/libc/src/new/nuttx/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/http/vendor/libc/src/new/openbsd/mod.rs b/http/vendor/libc/src/new/openbsd/mod.rs new file mode 100644 index 0000000..25fa784 --- /dev/null +++ b/http/vendor/libc/src/new/openbsd/mod.rs @@ -0,0 +1,7 @@ +//! OpenBSD libc. +//! +//! * Headers: +//! * Manual pages: + +pub(crate) mod sys; +pub(crate) mod unistd; diff --git a/http/vendor/libc/src/new/openbsd/sys/ipc.rs b/http/vendor/libc/src/new/openbsd/sys/ipc.rs new file mode 100644 index 0000000..5977440 --- /dev/null +++ b/http/vendor/libc/src/new/openbsd/sys/ipc.rs @@ -0,0 +1,17 @@ +//! Header: `sys/ipc.h` +//! +//! + +use crate::prelude::*; + +s! { + pub struct ipc_perm { + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub mode: crate::mode_t, + pub seq: c_ushort, + pub key: crate::key_t, + } +} diff --git a/http/vendor/libc/src/new/openbsd/sys/mod.rs b/http/vendor/libc/src/new/openbsd/sys/mod.rs new file mode 100644 index 0000000..7ba77c5 --- /dev/null +++ b/http/vendor/libc/src/new/openbsd/sys/mod.rs @@ -0,0 +1,5 @@ +//! Directory: `sys/` +//! +//! https://github.com/openbsd/src/tree/trunk/sys/sys + +pub(crate) mod ipc; diff --git a/http/vendor/libc/src/new/openbsd/unistd.rs b/http/vendor/libc/src/new/openbsd/unistd.rs new file mode 100644 index 0000000..8d55ee5 --- /dev/null +++ b/http/vendor/libc/src/new/openbsd/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/http/vendor/libc/src/new/qurt/dlfcn.rs b/http/vendor/libc/src/new/qurt/dlfcn.rs new file mode 100644 index 0000000..668fcab --- /dev/null +++ b/http/vendor/libc/src/new/qurt/dlfcn.rs @@ -0,0 +1,26 @@ +//! Header: `dlfcn.h` +//! +//! Dynamic linking functions and constants from Hexagon toolchain. + +use crate::prelude::*; + +// Values for dlopen `mode` +pub const RTLD_LAZY: c_int = 1; +pub const RTLD_NOW: c_int = 2; +pub const RTLD_GLOBAL: c_int = 0x100; +pub const RTLD_LOCAL: c_int = 0x200; + +// Compatibility constant +pub const DL_LAZY: c_int = RTLD_LAZY; + +// Special handles +pub const RTLD_NEXT: *mut c_void = -1isize as *mut c_void; +pub const RTLD_DEFAULT: *mut c_void = -2isize as *mut c_void; +pub const RTLD_SELF: *mut c_void = -3isize as *mut c_void; + +extern "C" { + pub fn dlopen(filename: *const c_char, flag: c_int) -> *mut c_void; + pub fn dlclose(handle: *mut c_void) -> c_int; + pub fn dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void; + pub fn dlerror() -> *mut c_char; +} diff --git a/http/vendor/libc/src/new/qurt/errno.rs b/http/vendor/libc/src/new/qurt/errno.rs new file mode 100644 index 0000000..09db55c --- /dev/null +++ b/http/vendor/libc/src/new/qurt/errno.rs @@ -0,0 +1,154 @@ +//! Header: `errno.h` + +use super::*; +use crate::prelude::*; + +// Standard error codes - verified to match QuRT SDK +pub const EPERM: c_int = 1; +pub const ENOENT: c_int = 2; +pub const ESRCH: c_int = 3; +pub const EINTR: c_int = 4; +pub const EIO: c_int = 5; +pub const ENXIO: c_int = 6; +pub const E2BIG: c_int = 7; +pub const ENOEXEC: c_int = 8; +pub const EBADF: c_int = 9; +pub const ECHILD: c_int = 10; +pub const EAGAIN: c_int = 11; +pub const ENOMEM: c_int = 12; +pub const EACCES: c_int = 13; +pub const EFAULT: c_int = 14; +pub const ENOTBLK: c_int = 15; +pub const EBUSY: c_int = 16; +pub const EEXIST: c_int = 17; +pub const EXDEV: c_int = 18; +pub const ENODEV: c_int = 19; +pub const ENOTDIR: c_int = 20; +pub const EISDIR: c_int = 21; +pub const EINVAL: c_int = 22; +pub const ENFILE: c_int = 23; +pub const EMFILE: c_int = 24; +pub const ENOTTY: c_int = 25; +pub const ETXTBSY: c_int = 26; +pub const EFBIG: c_int = 27; +pub const ENOSPC: c_int = 28; +pub const ESPIPE: c_int = 29; +pub const EROFS: c_int = 30; +pub const EMLINK: c_int = 31; +pub const EPIPE: c_int = 32; +pub const EDOM: c_int = 33; +pub const ERANGE: c_int = 34; +pub const EDEADLK: c_int = 35; +pub const ENAMETOOLONG: c_int = 36; +pub const ENOLCK: c_int = 37; +pub const ENOSYS: c_int = 38; +pub const ENOTEMPTY: c_int = 39; +pub const ELOOP: c_int = 40; +pub const EWOULDBLOCK: c_int = EAGAIN; +pub const ENOMSG: c_int = 42; +pub const EIDRM: c_int = 43; +pub const ECHRNG: c_int = 44; +pub const EL2NSYNC: c_int = 45; +pub const EL3HLT: c_int = 46; +pub const EL3RST: c_int = 47; +pub const ELNRNG: c_int = 48; +pub const EUNATCH: c_int = 49; +pub const ENOCSI: c_int = 50; +pub const EL2HLT: c_int = 51; +pub const EBADE: c_int = 52; +pub const EBADR: c_int = 53; +pub const EXFULL: c_int = 54; +pub const ENOANO: c_int = 55; +pub const EBADRQC: c_int = 56; +pub const EBADSLT: c_int = 57; +pub const EDEADLOCK: c_int = EDEADLK; +pub const EBFONT: c_int = 59; +pub const ENOSTR: c_int = 60; +pub const ENODATA: c_int = 61; +pub const ETIME: c_int = 62; +pub const ENOSR: c_int = 63; +pub const ENONET: c_int = 64; +pub const ENOPKG: c_int = 65; +pub const EREMOTE: c_int = 66; +pub const ENOLINK: c_int = 67; +pub const EADV: c_int = 68; +pub const ESRMNT: c_int = 69; +pub const ECOMM: c_int = 70; +pub const EPROTO: c_int = 71; +pub const EMULTIHOP: c_int = 72; +pub const EDOTDOT: c_int = 73; +pub const EBADMSG: c_int = 74; +pub const EOVERFLOW: c_int = 75; +pub const ENOTUNIQ: c_int = 76; +pub const EBADFD: c_int = 77; +pub const EREMCHG: c_int = 78; +pub const ELIBACC: c_int = 79; +pub const ELIBBAD: c_int = 80; +pub const ELIBSCN: c_int = 81; +pub const ELIBMAX: c_int = 82; +pub const ELIBEXEC: c_int = 83; +pub const EILSEQ: c_int = 84; +pub const ERESTART: c_int = 85; +pub const ESTRPIPE: c_int = 86; +pub const EUSERS: c_int = 87; +pub const ENOTSOCK: c_int = 88; +pub const EDESTADDRREQ: c_int = 89; +pub const EMSGSIZE: c_int = 90; +pub const EPROTOTYPE: c_int = 91; +pub const ENOPROTOOPT: c_int = 92; +pub const EPROTONOSUPPORT: c_int = 93; +pub const ESOCKTNOSUPPORT: c_int = 94; +pub const EOPNOTSUPP: c_int = 95; +pub const ENOTSUP: c_int = EOPNOTSUPP; +pub const EPFNOSUPPORT: c_int = 96; +pub const EAFNOSUPPORT: c_int = 97; +pub const EADDRINUSE: c_int = 98; +pub const EADDRNOTAVAIL: c_int = 99; +pub const ENETDOWN: c_int = 100; +pub const ENETUNREACH: c_int = 101; +pub const ENETRESET: c_int = 102; +pub const ECONNABORTED: c_int = 103; +pub const ECONNRESET: c_int = 104; +pub const ENOBUFS: c_int = 105; +pub const EISCONN: c_int = 106; +pub const ENOTCONN: c_int = 107; +pub const ESHUTDOWN: c_int = 108; +pub const ETOOMANYREFS: c_int = 109; +pub const ETIMEDOUT: c_int = 110; +pub const ECONNREFUSED: c_int = 111; +pub const EHOSTDOWN: c_int = 112; +pub const EHOSTUNREACH: c_int = 113; +pub const EALREADY: c_int = 114; +pub const EINPROGRESS: c_int = 115; +pub const ESTALE: c_int = 116; +pub const EUCLEAN: c_int = 117; +pub const ENOTNAM: c_int = 118; +pub const ENAVAIL: c_int = 119; +pub const EISNAM: c_int = 120; +pub const EREMOTEIO: c_int = 121; +pub const EDQUOT: c_int = 122; +pub const ENOMEDIUM: c_int = 123; +pub const EMEDIUMTYPE: c_int = 124; +pub const ECANCELED: c_int = 125; +pub const ENOKEY: c_int = 126; +pub const EKEYEXPIRED: c_int = 127; +pub const EKEYREVOKED: c_int = 128; +pub const EKEYREJECTED: c_int = 129; +pub const EOWNERDEAD: c_int = 130; +pub const ENOTRECOVERABLE: c_int = 131; +pub const ERFKILL: c_int = 132; +pub const EHWPOISON: c_int = 133; + +extern "C" { + // Error number access + #[link_name = "__errno_location"] + pub fn __errno_location() -> *mut c_int; +} + +pub unsafe fn errno() -> c_int { + *__errno_location() +} + +pub unsafe fn set_errno(value: c_int) { + *__errno_location() = value; +} diff --git a/http/vendor/libc/src/new/qurt/fcntl.rs b/http/vendor/libc/src/new/qurt/fcntl.rs new file mode 100644 index 0000000..0287292 --- /dev/null +++ b/http/vendor/libc/src/new/qurt/fcntl.rs @@ -0,0 +1,52 @@ +//! Header: `fcntl.h` + +use super::*; +use crate::prelude::*; + +// File access modes +pub const O_RDONLY: c_int = 0x0000; +pub const O_WRONLY: c_int = 0x0001; +pub const O_RDWR: c_int = 0x0002; +pub const O_ACCMODE: c_int = 0x0003; + +// File creation flags +pub const O_CREAT: c_int = 0x0040; +pub const O_EXCL: c_int = 0x0080; +pub const O_NOCTTY: c_int = 0x0100; +pub const O_TRUNC: c_int = 0x0200; + +// File status flags +pub const O_APPEND: c_int = 0x0400; +pub const O_NONBLOCK: c_int = 0x0800; +pub const O_SYNC: c_int = 0x1000; +pub const O_FSYNC: c_int = O_SYNC; +pub const O_DSYNC: c_int = 0x1000; +pub const O_DIRECTORY: c_int = 0x10000; +pub const O_NOFOLLOW: c_int = 0x20000; +pub const O_CLOEXEC: c_int = 0x80000; + +// fcntl() commands +pub const F_DUPFD: c_int = 0; +pub const F_GETFD: c_int = 1; +pub const F_SETFD: c_int = 2; +pub const F_GETFL: c_int = 3; +pub const F_SETFL: c_int = 4; +pub const F_GETLK: c_int = 5; +pub const F_SETLK: c_int = 6; +pub const F_SETLKW: c_int = 7; +pub const F_DUPFD_CLOEXEC: c_int = 1030; + +// File descriptor flags +pub const FD_CLOEXEC: c_int = 1; + +// Lock types for fcntl() +pub const F_RDLCK: c_int = 0; +pub const F_WRLCK: c_int = 1; +pub const F_UNLCK: c_int = 2; + +// Functions +extern "C" { + pub fn open(pathname: *const c_char, flags: c_int, ...) -> c_int; + pub fn creat(pathname: *const c_char, mode: mode_t) -> c_int; + pub fn fcntl(fd: c_int, cmd: c_int, ...) -> c_int; +} diff --git a/http/vendor/libc/src/new/qurt/limits.rs b/http/vendor/libc/src/new/qurt/limits.rs new file mode 100644 index 0000000..ae1a007 --- /dev/null +++ b/http/vendor/libc/src/new/qurt/limits.rs @@ -0,0 +1,41 @@ +//! Header: `limits.h` + +use super::*; +use crate::prelude::*; + +// Character properties +pub const CHAR_BIT: c_uint = 8; +pub const CHAR_MAX: c_char = 255; // unsigned char on Hexagon +pub const CHAR_MIN: c_char = 0; +pub const SCHAR_MAX: c_schar = 127; +pub const SCHAR_MIN: c_schar = -128; +pub const UCHAR_MAX: c_uchar = 255; + +// Integer properties +pub const INT_MAX: c_int = 2147483647; +pub const INT_MIN: c_int = (-2147483647 - 1); +pub const UINT_MAX: c_uint = 4294967295; + +pub const LONG_MAX: c_long = 2147483647; +pub const LONG_MIN: c_long = (-2147483647 - 1); +pub const ULONG_MAX: c_ulong = 4294967295; + +pub const SHRT_MAX: c_short = 32767; +pub const SHRT_MIN: c_short = (-32768); +pub const USHRT_MAX: c_ushort = 65535; + +// POSIX Limits +pub const ARG_MAX: c_int = 4096; +pub const CHILD_MAX: c_int = 25; +pub const LINK_MAX: c_int = 8; +pub const MAX_CANON: c_int = 255; +pub const MAX_INPUT: c_int = 255; +pub const NAME_MAX: c_int = 255; +pub const OPEN_MAX: c_int = 20; +pub const PATH_MAX: c_int = 260; +pub const PIPE_BUF: c_int = 512; +pub const STREAM_MAX: c_int = 20; +pub const TZNAME_MAX: c_int = 50; + +// Additional limits +pub const IOV_MAX: c_int = 16; diff --git a/http/vendor/libc/src/new/qurt/mod.rs b/http/vendor/libc/src/new/qurt/mod.rs new file mode 100644 index 0000000..52d7ae0 --- /dev/null +++ b/http/vendor/libc/src/new/qurt/mod.rs @@ -0,0 +1,375 @@ +//! QuRT (Qualcomm Real-Time OS) bindings +//! +//! QuRT is Qualcomm's real-time operating system for Hexagon DSP architectures. +//! Headers available via the +//! Hexagon SDK: https://softwarecenter.qualcomm.com/catalog/item/Hexagon_SDK + +use crate::prelude::*; + +// Basic C types for QuRT +pub type intptr_t = isize; +pub type uintptr_t = usize; +pub type ptrdiff_t = isize; +pub type size_t = uintptr_t; +pub type ssize_t = c_int; + +// Process and system types +pub type pid_t = c_int; +pub type uid_t = c_uint; +pub type gid_t = c_uint; + +// Time types +pub type time_t = c_long; +pub type suseconds_t = c_long; +pub type useconds_t = c_ulong; +pub type clockid_t = c_int; +pub type timer_t = *mut c_void; + +// File system types +pub type dev_t = c_ulonglong; +pub type ino_t = c_ulonglong; +pub type mode_t = c_uint; +pub type nlink_t = c_uint; +pub type off_t = c_long; +pub type blkcnt_t = c_long; +pub type blksize_t = c_long; + +// Thread types based on QuRT pthread implementation +pub type pthread_t = c_uint; +pub type pthread_key_t = c_int; +pub type pthread_once_t = c_int; +pub type pthread_mutex_t = c_uint; +pub type pthread_mutexattr_t = c_uint; +pub type pthread_cond_t = c_uint; +pub type pthread_condattr_t = c_uint; +pub type pthread_attr_t = c_uint; +pub type pthread_rwlock_t = c_uint; +pub type pthread_rwlockattr_t = c_uint; +pub type pthread_spinlock_t = c_uint; +pub type pthread_barrier_t = c_uint; +pub type pthread_barrierattr_t = c_uint; + +// Network types +pub type socklen_t = c_uint; +pub type sa_family_t = c_ushort; +pub type in_addr_t = c_uint; +pub type in_port_t = c_ushort; + +// File descriptor types +pub type fd_set = c_ulong; + +// Standard C library types +extern_ty! { + pub enum FILE {} +} +pub type fpos_t = c_long; +pub type clock_t = c_long; + +// POSIX semaphore types +pub type sem_t = c_uint; + +// Message queue types +pub type mqd_t = c_int; + +// Additional file system types +pub type nfds_t = c_ulong; + +// Signal types +pub type sigset_t = c_ulong; + +// Variadic argument list type +pub type va_list = *mut c_char; + +// Additional missing types +pub type c_schar = i8; + +// Wide character type (hexagon-specific) +pub type wchar_t = u32; + +// Error type (compatible with std expectations) +pub type errno_t = c_int; + +// Resource limit type (for compatibility, not fully supported on QuRT) +pub type rlim_t = c_ulong; + +// Terminal types (for compatibility, not fully supported on QuRT) +pub type speed_t = c_uint; +pub type tcflag_t = c_uint; + +// Division result types and structures +s! { + pub struct div_t { + pub quot: c_int, + pub rem: c_int, + } + + pub struct ldiv_t { + pub quot: c_long, + pub rem: c_long, + } + + pub struct lldiv_t { + pub quot: c_longlong, + pub rem: c_longlong, + } + + pub struct stat { + pub st_dev: dev_t, + pub st_ino: ino_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_rdev: dev_t, + pub st_size: off_t, + pub st_atime: time_t, + pub st_mtime: time_t, + pub st_ctime: time_t, + } + + pub struct tm { + pub tm_sec: c_int, + pub tm_min: c_int, + pub tm_hour: c_int, + pub tm_mday: c_int, + pub tm_mon: c_int, + pub tm_year: c_int, + pub tm_wday: c_int, + pub tm_yday: c_int, + pub tm_isdst: c_int, + } + + #[derive(Default)] + pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, + } + + #[derive(Default)] + pub struct timeval { + pub tv_sec: time_t, + pub tv_usec: suseconds_t, + } + + pub struct itimerspec { + pub it_interval: timespec, + pub it_value: timespec, + } + + pub struct dirent { + pub d_ino: c_long, + pub d_name: [c_char; 255], + } + + pub struct DIR { + pub index: c_int, + pub entry: dirent, + } + + // Terminal I/O structure (for compatibility, limited support on QuRT) + pub struct termios { + pub c_iflag: tcflag_t, + pub c_oflag: tcflag_t, + pub c_cflag: tcflag_t, + pub c_lflag: tcflag_t, + pub c_cc: [c_uchar; 32], + pub c_ispeed: speed_t, + pub c_ospeed: speed_t, + } + + // Resource limit structures (for compatibility, limited support on QuRT) + pub struct rlimit { + pub rlim_cur: rlim_t, + pub rlim_max: rlim_t, + } + + pub struct rusage { + pub ru_utime: timeval, + pub ru_stime: timeval, + pub ru_maxrss: c_long, + pub ru_ixrss: c_long, + pub ru_idrss: c_long, + pub ru_isrss: c_long, + pub ru_minflt: c_long, + pub ru_majflt: c_long, + pub ru_nswap: c_long, + pub ru_inblock: c_long, + pub ru_oublock: c_long, + pub ru_msgsnd: c_long, + pub ru_msgrcv: c_long, + pub ru_nsignals: c_long, + pub ru_nvcsw: c_long, + pub ru_nivcsw: c_long, + } + + // File lock structure (for compatibility) + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off_t, + pub l_len: off_t, + pub l_pid: pid_t, + } +} + +// Additional pthread constants +pub const PTHREAD_NAME_LEN: c_int = 16; +pub const PTHREAD_MAX_THREADS: c_uint = 512; +pub const PTHREAD_MIN_STACKSIZE: c_int = 512; +pub const PTHREAD_MAX_STACKSIZE: c_int = 1048576; +pub const PTHREAD_DEFAULT_STACKSIZE: c_int = 16384; +pub const PTHREAD_DEFAULT_PRIORITY: c_int = 1; +pub const PTHREAD_SPINLOCK_UNLOCKED: c_int = 0; +pub const PTHREAD_SPINLOCK_LOCKED: c_int = 1; + +// Additional time constants +pub const TIME_CONV_SCLK_FREQ: c_int = 19200000; +pub const CLOCK_MONOTONIC_RAW: clockid_t = 4; +pub const CLOCK_REALTIME_COARSE: clockid_t = 5; +pub const CLOCK_MONOTONIC_COARSE: clockid_t = 6; +pub const CLOCK_BOOTTIME: clockid_t = 7; + +// Stdio constants +pub const L_tmpnam: c_uint = 260; +pub const TMP_MAX: c_uint = 25; +pub const FOPEN_MAX: c_uint = 20; + +// Error constants +pub const EOK: c_int = 0; + +// Semaphore constants +pub const SEM_FAILED: *mut sem_t = 0 as *mut sem_t; + +// Page size constants (hexagon-specific) +pub const PAGESIZE: size_t = 4096; +pub const PAGE_SIZE: size_t = 4096; + +// Directory entry types (hexagon-specific) +pub const DT_UNKNOWN: c_uchar = 0; +pub const DT_FIFO: c_uchar = 1; +pub const DT_CHR: c_uchar = 2; +pub const DT_DIR: c_uchar = 4; +pub const DT_BLK: c_uchar = 6; +pub const DT_REG: c_uchar = 8; +pub const DT_LNK: c_uchar = 10; +pub const DT_SOCK: c_uchar = 12; + +// Directory functions (dirent.h) +extern "C" { + pub fn opendir(name: *const c_char) -> *mut DIR; + pub fn readdir(dirp: *mut DIR) -> *mut dirent; + pub fn closedir(dirp: *const DIR) -> c_int; + pub fn mkdir(path: *const c_char, mode: mode_t) -> c_int; +} + +// Additional pthread functions +extern "C" { + pub fn pthread_attr_getstack( + attr: *const pthread_attr_t, + stackaddr: *mut *mut c_void, + stacksize: *mut size_t, + ) -> c_int; + pub fn pthread_attr_setstack( + attr: *mut pthread_attr_t, + stackaddr: *mut c_void, + stacksize: size_t, + ) -> c_int; +} + +// Additional time functions +extern "C" { + pub fn clock_getcpuclockid(pid: pid_t, clock_id: *mut clockid_t) -> c_int; +} + +// POSIX semaphore functions +extern "C" { + pub fn sem_open(name: *const c_char, oflag: c_int, ...) -> *mut sem_t; + pub fn sem_close(sem: *mut sem_t) -> c_int; + pub fn sem_unlink(name: *const c_char) -> c_int; +} + +// Additional stdlib functions +extern "C" { + pub fn aligned_alloc(alignment: size_t, size: size_t) -> *mut c_void; +} + +// String functions (string.h) +extern "C" { + pub fn strlen(s: *const c_char) -> size_t; + pub fn strcpy(dest: *mut c_char, src: *const c_char) -> *mut c_char; + pub fn strncpy(dest: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char; + pub fn strcat(dest: *mut c_char, src: *const c_char) -> *mut c_char; + pub fn strncat(dest: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char; + pub fn strcmp(s1: *const c_char, s2: *const c_char) -> c_int; + pub fn strncmp(s1: *const c_char, s2: *const c_char, n: size_t) -> c_int; + pub fn strcoll(s1: *const c_char, s2: *const c_char) -> c_int; + pub fn strxfrm(dest: *mut c_char, src: *const c_char, n: size_t) -> size_t; + pub fn strchr(s: *const c_char, c: c_int) -> *mut c_char; + pub fn strrchr(s: *const c_char, c: c_int) -> *mut c_char; + pub fn strspn(s: *const c_char, accept: *const c_char) -> size_t; + pub fn strcspn(s: *const c_char, reject: *const c_char) -> size_t; + pub fn strpbrk(s: *const c_char, accept: *const c_char) -> *mut c_char; + pub fn strstr(haystack: *const c_char, needle: *const c_char) -> *mut c_char; + pub fn strtok(s: *mut c_char, delim: *const c_char) -> *mut c_char; + pub fn strerror(errnum: c_int) -> *mut c_char; + pub fn memchr(s: *const c_void, c: c_int, n: size_t) -> *mut c_void; + pub fn memcmp(s1: *const c_void, s2: *const c_void, n: size_t) -> c_int; + pub fn memcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; + pub fn memmove(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; + pub fn memset(s: *mut c_void, c: c_int, n: size_t) -> *mut c_void; +} + +// Additional unistd functions +extern "C" { + pub fn fork() -> pid_t; + pub fn execve( + filename: *const c_char, + argv: *const *const c_char, + envp: *const *const c_char, + ) -> c_int; +} + +// Character classification functions (ctype.h) +extern "C" { + pub fn isalnum(c: c_int) -> c_int; + pub fn isalpha(c: c_int) -> c_int; + pub fn iscntrl(c: c_int) -> c_int; + pub fn isdigit(c: c_int) -> c_int; + pub fn isgraph(c: c_int) -> c_int; + pub fn islower(c: c_int) -> c_int; + pub fn isprint(c: c_int) -> c_int; + pub fn ispunct(c: c_int) -> c_int; + pub fn isspace(c: c_int) -> c_int; + pub fn isupper(c: c_int) -> c_int; + pub fn isxdigit(c: c_int) -> c_int; + pub fn tolower(c: c_int) -> c_int; + pub fn toupper(c: c_int) -> c_int; +} + +pub(crate) mod dlfcn; +pub(crate) mod errno; +pub(crate) mod fcntl; +pub(crate) mod limits; +pub(crate) mod pthread; +pub(crate) mod semaphore; +pub(crate) mod signal; +pub(crate) mod stdio; +pub(crate) mod stdlib; +pub(crate) mod sys; +pub(crate) mod time; +pub(crate) mod unistd; + +// Re-export public items from submodules +pub use dlfcn::*; +pub use errno::*; +pub use fcntl::*; +pub use limits::*; +pub use pthread::*; +pub use semaphore::*; +pub use signal::*; +pub use stdio::*; +pub use stdlib::*; +pub use sys::mman::*; +pub use sys::sched::*; +pub use sys::stat::*; +pub use sys::types::*; +pub use time::*; +pub use unistd::*; diff --git a/http/vendor/libc/src/new/qurt/pthread.rs b/http/vendor/libc/src/new/qurt/pthread.rs new file mode 100644 index 0000000..543f787 --- /dev/null +++ b/http/vendor/libc/src/new/qurt/pthread.rs @@ -0,0 +1,129 @@ +//! Header: `pthread.h` +//! +//! QuRT provides a subset of POSIX pthread functionality optimized for real-time systems. + +use super::*; +use crate::prelude::*; + +// Thread creation attributes +pub const PTHREAD_CREATE_JOINABLE: c_int = 0; +pub const PTHREAD_CREATE_DETACHED: c_int = 1; + +// Mutex types +pub const PTHREAD_MUTEX_NORMAL: c_int = 0; +pub const PTHREAD_MUTEX_RECURSIVE: c_int = 1; +pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 2; +pub const PTHREAD_MUTEX_DEFAULT: c_int = PTHREAD_MUTEX_NORMAL; + +// Mutex protocol +pub const PTHREAD_PRIO_NONE: c_int = 0; +pub const PTHREAD_PRIO_INHERIT: c_int = 1; +pub const PTHREAD_PRIO_PROTECT: c_int = 2; + +// Thread priority constants +pub const PTHREAD_MIN_PRIORITY: c_int = 0; +pub const PTHREAD_MAX_PRIORITY: c_int = 255; + +// Initializer constants +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = 0xFFFFFFFF; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = 0xFFFFFFFF; +pub const PTHREAD_ONCE_INIT: pthread_once_t = 0; + +// Stack size +pub const PTHREAD_STACK_MIN: size_t = 8192; + +// Additional pthread types and attributes +pub const PTHREAD_SCOPE_SYSTEM: c_int = 0; +pub const PTHREAD_SCOPE_PROCESS: c_int = 1; + +pub const PTHREAD_INHERIT_SCHED: c_int = 0; +pub const PTHREAD_EXPLICIT_SCHED: c_int = 1; + +extern "C" { + // Thread management + pub fn pthread_create( + thread: *mut pthread_t, + attr: *const pthread_attr_t, + start_routine: extern "C" fn(*mut c_void) -> *mut c_void, + arg: *mut c_void, + ) -> c_int; + pub fn pthread_join(thread: pthread_t, retval: *mut *mut c_void) -> c_int; + pub fn pthread_detach(thread: pthread_t) -> c_int; + pub fn pthread_exit(retval: *mut c_void) -> !; + pub fn pthread_self() -> pthread_t; + pub fn pthread_equal(t1: pthread_t, t2: pthread_t) -> c_int; + + // Thread attributes + pub fn pthread_attr_init(attr: *mut pthread_attr_t) -> c_int; + pub fn pthread_attr_destroy(attr: *mut pthread_attr_t) -> c_int; + pub fn pthread_attr_setstacksize(attr: *mut pthread_attr_t, stacksize: size_t) -> c_int; + pub fn pthread_attr_getstacksize(attr: *const pthread_attr_t, stacksize: *mut size_t) -> c_int; + pub fn pthread_attr_setdetachstate(attr: *mut pthread_attr_t, detachstate: c_int) -> c_int; + pub fn pthread_attr_getdetachstate( + attr: *const pthread_attr_t, + detachstate: *mut c_int, + ) -> c_int; + + // Mutex operations + pub fn pthread_mutex_init( + mutex: *mut pthread_mutex_t, + attr: *const pthread_mutexattr_t, + ) -> c_int; + pub fn pthread_mutex_destroy(mutex: *mut pthread_mutex_t) -> c_int; + pub fn pthread_mutex_lock(mutex: *mut pthread_mutex_t) -> c_int; + pub fn pthread_mutex_trylock(mutex: *mut pthread_mutex_t) -> c_int; + pub fn pthread_mutex_unlock(mutex: *mut pthread_mutex_t) -> c_int; + + // Mutex attributes + pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> c_int; + pub fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> c_int; + pub fn pthread_mutexattr_settype(attr: *mut pthread_mutexattr_t, kind: c_int) -> c_int; + pub fn pthread_mutexattr_gettype(attr: *const pthread_mutexattr_t, kind: *mut c_int) -> c_int; + + // Condition variables + pub fn pthread_cond_init(cond: *mut pthread_cond_t, attr: *const pthread_condattr_t) -> c_int; + pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> c_int; + pub fn pthread_cond_wait(cond: *mut pthread_cond_t, mutex: *mut pthread_mutex_t) -> c_int; + pub fn pthread_cond_timedwait( + cond: *mut pthread_cond_t, + mutex: *mut pthread_mutex_t, + abstime: *const timespec, + ) -> c_int; + pub fn pthread_cond_signal(cond: *mut pthread_cond_t) -> c_int; + pub fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> c_int; + + // Condition variable attributes + pub fn pthread_condattr_init(attr: *mut pthread_condattr_t) -> c_int; + pub fn pthread_condattr_destroy(attr: *mut pthread_condattr_t) -> c_int; + pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t, clock_id: clockid_t) -> c_int; + + // Thread-local storage + pub fn pthread_key_create( + key: *mut pthread_key_t, + destructor: Option, + ) -> c_int; + pub fn pthread_key_delete(key: pthread_key_t) -> c_int; + pub fn pthread_getspecific(key: pthread_key_t) -> *mut c_void; + pub fn pthread_setspecific(key: pthread_key_t, value: *const c_void) -> c_int; + + // One-time initialization + pub fn pthread_once(once_control: *mut pthread_once_t, init_routine: extern "C" fn()) -> c_int; + + // GNU extensions + pub fn pthread_getname_np(thread: pthread_t, name: *mut c_char, len: size_t) -> c_int; + + pub fn pthread_attr_setaffinity_np( + attr: *mut pthread_attr_t, + cpusetsize: size_t, + cpuset: *const cpu_set_t, + ) -> c_int; + + pub fn pthread_attr_getaffinity_np( + attr: *mut pthread_attr_t, + cpusetsize: size_t, + cpuset: *mut cpu_set_t, + ) -> c_int; + + // POSIX standard + pub fn posix_memalign(memptr: *mut *mut c_void, alignment: size_t, size: size_t) -> c_int; +} diff --git a/http/vendor/libc/src/new/qurt/semaphore.rs b/http/vendor/libc/src/new/qurt/semaphore.rs new file mode 100644 index 0000000..86b3743 --- /dev/null +++ b/http/vendor/libc/src/new/qurt/semaphore.rs @@ -0,0 +1,13 @@ +//! Header: `semaphore.h` + +use super::*; +use crate::prelude::*; + +extern "C" { + pub fn sem_init(sem: *mut sem_t, pshared: c_int, value: c_uint) -> c_int; + pub fn sem_destroy(sem: *mut sem_t) -> c_int; + pub fn sem_wait(sem: *mut sem_t) -> c_int; + pub fn sem_trywait(sem: *mut sem_t) -> c_int; + pub fn sem_post(sem: *mut sem_t) -> c_int; + pub fn sem_getvalue(sem: *mut sem_t, sval: *mut c_int) -> c_int; +} diff --git a/http/vendor/libc/src/new/qurt/signal.rs b/http/vendor/libc/src/new/qurt/signal.rs new file mode 100644 index 0000000..f525fa1 --- /dev/null +++ b/http/vendor/libc/src/new/qurt/signal.rs @@ -0,0 +1,117 @@ +//! Header: `signal.h` + +use super::*; +use crate::prelude::*; + +// Standard signal numbers +pub const SIGHUP: c_int = 1; +pub const SIGINT: c_int = 2; +pub const SIGQUIT: c_int = 3; +pub const SIGILL: c_int = 4; +pub const SIGTRAP: c_int = 5; +pub const SIGABRT: c_int = 6; +pub const SIGBUS: c_int = 7; +pub const SIGFPE: c_int = 8; +pub const SIGKILL: c_int = 9; +pub const SIGUSR1: c_int = 10; +pub const SIGSEGV: c_int = 11; +pub const SIGUSR2: c_int = 12; +pub const SIGPIPE: c_int = 13; +pub const SIGALRM: c_int = 14; +pub const SIGTERM: c_int = 15; +pub const SIGSTKFLT: c_int = 16; +pub const SIGCHLD: c_int = 17; +pub const SIGCONT: c_int = 18; +pub const SIGSTOP: c_int = 19; +pub const SIGTSTP: c_int = 20; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGURG: c_int = 23; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGIO: c_int = 29; +pub const SIGPWR: c_int = 30; +pub const SIGSYS: c_int = 31; + +// Signal handling constants +pub const SIG_DFL: sighandler_t = 0 as sighandler_t; +pub const SIG_IGN: sighandler_t = 1 as sighandler_t; +pub const SIG_ERR: sighandler_t = !0 as sighandler_t; + +// Signal mask operations (QuRT uses different values than Linux) +pub const SIG_BLOCK: c_int = 1; +pub const SIG_UNBLOCK: c_int = 2; +pub const SIG_SETMASK: c_int = 3; + +// QuRT-specific signal constants +pub const POSIX_MSG: c_int = 7; +pub const POSIX_NOTIF: c_int = 8; +pub const SIGRTMIN: c_int = 10; +pub const SIGRTMAX: c_int = 32; + +// Notification types (from QuRT signal.h) +pub const SIGEV_NONE: c_int = 0; +pub const SIGEV_SIGNAL: c_int = 1; +pub const SIGEV_THREAD: c_int = 2; +pub const SA_SIGINFO: c_int = 1; + +pub type sighandler_t = size_t; + +// Signal structures based on QuRT SDK headers +s! { + pub struct sigval { + pub sival_int: c_int, + pub sival_ptr: *mut c_void, + } + + pub struct sigevent { + pub sigev_notify: c_int, + pub sigev_signo: c_int, + pub sigev_value: sigval, + pub sigev_notify_function: Option, + pub sigev_notify_attributes: *mut pthread_attr_t, + } + + pub struct siginfo_t { + pub si_signo: c_int, + pub si_code: c_int, + pub si_value: sigval, + } + + pub struct sigaction { + pub sa_handler: Option, + pub sa_mask: sigset_t, + pub sa_flags: c_int, + pub sa_sigaction: Option, + } +} + +extern "C" { + pub fn signal(sig: c_int, handler: sighandler_t) -> sighandler_t; + pub fn kill(pid: pid_t, sig: c_int) -> c_int; + pub fn raise(sig: c_int) -> c_int; + pub fn alarm(seconds: c_uint) -> c_uint; + pub fn pause() -> c_int; + + // Signal mask functions + pub fn sigemptyset(set: *mut sigset_t) -> c_int; + pub fn sigfillset(set: *mut sigset_t) -> c_int; + pub fn sigaddset(set: *mut sigset_t, signum: c_int) -> c_int; + pub fn sigdelset(set: *mut sigset_t, signum: c_int) -> c_int; + pub fn sigismember(set: *const sigset_t, signum: c_int) -> c_int; + pub fn sigprocmask(how: c_int, set: *const sigset_t, oldset: *mut sigset_t) -> c_int; + pub fn sigpending(set: *mut sigset_t) -> c_int; + pub fn sigsuspend(mask: *const sigset_t) -> c_int; + + // QuRT-specific signal functions + pub fn sigwait(set: *const sigset_t, sig: *mut c_int) -> c_int; + pub fn _sigaction(sig: c_int, act: *const sigaction, oact: *mut sigaction) -> c_int; + pub fn sigtimedwait( + set: *const sigset_t, + info: *mut siginfo_t, + timeout: *const timespec, + ) -> c_int; +} diff --git a/http/vendor/libc/src/new/qurt/stdio.rs b/http/vendor/libc/src/new/qurt/stdio.rs new file mode 100644 index 0000000..7130717 --- /dev/null +++ b/http/vendor/libc/src/new/qurt/stdio.rs @@ -0,0 +1,73 @@ +//! Header: `stdio.h` + +use super::*; +use crate::prelude::*; + +// Buffer size +pub const BUFSIZ: c_uint = 1024; +pub const FILENAME_MAX: c_uint = 260; + +// End of file +pub const EOF: c_int = -1; + +extern "C" { + // File operations + pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE; + pub fn freopen(filename: *const c_char, mode: *const c_char, stream: *mut FILE) -> *mut FILE; + pub fn fclose(stream: *mut FILE) -> c_int; + pub fn fflush(stream: *mut FILE) -> c_int; + pub fn fread(ptr: *mut c_void, size: size_t, nmemb: size_t, stream: *mut FILE) -> size_t; + pub fn fwrite(ptr: *const c_void, size: size_t, nmemb: size_t, stream: *mut FILE) -> size_t; + + // Character I/O + pub fn fgetc(stream: *mut FILE) -> c_int; + pub fn fputc(c: c_int, stream: *mut FILE) -> c_int; + pub fn getchar() -> c_int; + pub fn putchar(c: c_int) -> c_int; + pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int; + + // Line I/O + pub fn fgets(s: *mut c_char, size: c_int, stream: *mut FILE) -> *mut c_char; + pub fn fputs(s: *const c_char, stream: *mut FILE) -> c_int; + pub fn gets(s: *mut c_char) -> *mut c_char; + pub fn puts(s: *const c_char) -> c_int; + + // Formatted I/O + pub fn printf(format: *const c_char, ...) -> c_int; + pub fn fprintf(stream: *mut FILE, format: *const c_char, ...) -> c_int; + pub fn sprintf(s: *mut c_char, format: *const c_char, ...) -> c_int; + pub fn snprintf(s: *mut c_char, n: size_t, format: *const c_char, ...) -> c_int; + pub fn vprintf(format: *const c_char, ap: crate::va_list) -> c_int; + pub fn vfprintf(stream: *mut FILE, format: *const c_char, ap: crate::va_list) -> c_int; + pub fn vsprintf(s: *mut c_char, format: *const c_char, ap: crate::va_list) -> c_int; + pub fn vsnprintf(s: *mut c_char, n: size_t, format: *const c_char, ap: crate::va_list) + -> c_int; + + // Input formatted functions + pub fn scanf(format: *const c_char, ...) -> c_int; + pub fn fscanf(stream: *mut FILE, format: *const c_char, ...) -> c_int; + pub fn sscanf(s: *const c_char, format: *const c_char, ...) -> c_int; + + // File positioning + pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int; + pub fn ftell(stream: *mut FILE) -> c_long; + pub fn rewind(stream: *mut FILE); + pub fn fgetpos(stream: *mut FILE, pos: *mut fpos_t) -> c_int; + pub fn fsetpos(stream: *mut FILE, pos: *const fpos_t) -> c_int; + + // Error handling + pub fn clearerr(stream: *mut FILE); + pub fn feof(stream: *mut FILE) -> c_int; + pub fn ferror(stream: *mut FILE) -> c_int; + pub fn perror(s: *const c_char); + + // File management + pub fn remove(filename: *const c_char) -> c_int; + pub fn rename(old: *const c_char, new: *const c_char) -> c_int; + pub fn tmpfile() -> *mut FILE; + pub fn tmpnam(s: *mut c_char) -> *mut c_char; + + // Buffer control + pub fn setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int, size: size_t) -> c_int; + pub fn setbuf(stream: *mut FILE, buffer: *mut c_char); +} diff --git a/http/vendor/libc/src/new/qurt/stdlib.rs b/http/vendor/libc/src/new/qurt/stdlib.rs new file mode 100644 index 0000000..dc96e36 --- /dev/null +++ b/http/vendor/libc/src/new/qurt/stdlib.rs @@ -0,0 +1,67 @@ +//! Header: `stdlib.h` + +use super::*; +use crate::prelude::*; + +// Exit status constants +pub const EXIT_SUCCESS: c_int = 0; +pub const EXIT_FAILURE: c_int = 1; + +// Maximum values +pub const RAND_MAX: c_int = 32767; + +extern "C" { + // Memory management + pub fn malloc(size: size_t) -> *mut c_void; + pub fn calloc(nmemb: size_t, size: size_t) -> *mut c_void; + pub fn realloc(ptr: *mut c_void, size: size_t) -> *mut c_void; + pub fn free(ptr: *mut c_void); + + // Process control + pub fn abort() -> !; + pub fn exit(status: c_int) -> !; + pub fn atexit(function: extern "C" fn()) -> c_int; + + // Environment + pub fn getenv(name: *const c_char) -> *mut c_char; + pub fn setenv(name: *const c_char, value: *const c_char, overwrite: c_int) -> c_int; + pub fn unsetenv(name: *const c_char) -> c_int; + + // String/number conversion + pub fn atoi(nptr: *const c_char) -> c_int; + pub fn atol(nptr: *const c_char) -> c_long; + pub fn atoll(nptr: *const c_char) -> c_longlong; + pub fn strtol(nptr: *const c_char, endptr: *mut *mut c_char, base: c_int) -> c_long; + pub fn strtoul(nptr: *const c_char, endptr: *mut *mut c_char, base: c_int) -> c_ulong; + pub fn strtoll(nptr: *const c_char, endptr: *mut *mut c_char, base: c_int) -> c_longlong; + pub fn strtoull(nptr: *const c_char, endptr: *mut *mut c_char, base: c_int) -> c_ulonglong; + pub fn strtod(nptr: *const c_char, endptr: *mut *mut c_char) -> c_double; + pub fn strtof(nptr: *const c_char, endptr: *mut *mut c_char) -> c_float; + + // Random numbers + pub fn rand() -> c_int; + pub fn srand(seed: c_uint); + + // Searching and sorting + pub fn qsort( + base: *mut c_void, + nmemb: size_t, + size: size_t, + compar: extern "C" fn(*const c_void, *const c_void) -> c_int, + ); + pub fn bsearch( + key: *const c_void, + base: *const c_void, + nmemb: size_t, + size: size_t, + compar: extern "C" fn(*const c_void, *const c_void) -> c_int, + ) -> *mut c_void; + + // Integer arithmetic + pub fn abs(j: c_int) -> c_int; + pub fn labs(j: c_long) -> c_long; + pub fn llabs(j: c_longlong) -> c_longlong; + pub fn div(numer: c_int, denom: c_int) -> div_t; + pub fn ldiv(numer: c_long, denom: c_long) -> ldiv_t; + pub fn lldiv(numer: c_longlong, denom: c_longlong) -> lldiv_t; +} diff --git a/http/vendor/libc/src/new/qurt/sys/mman.rs b/http/vendor/libc/src/new/qurt/sys/mman.rs new file mode 100644 index 0000000..a0a3b3a --- /dev/null +++ b/http/vendor/libc/src/new/qurt/sys/mman.rs @@ -0,0 +1,55 @@ +//! Header: `sys/mman.h` +//! +//! Memory mapping functions and constants from Hexagon toolchain. + +use super::super::*; +use crate::prelude::*; + +// Memory protection constants +pub const PROT_NONE: c_int = 0x00; +pub const PROT_READ: c_int = 0x01; +pub const PROT_WRITE: c_int = 0x02; +pub const PROT_EXEC: c_int = 0x04; + +// Memory mapping constants +pub const MAP_SHARED: c_int = 0x0001; +pub const MAP_PRIVATE: c_int = 0x0002; +pub const MAP_FIXED: c_int = 0x0010; +pub const MAP_ANON: c_int = 0x1000; +pub const MAP_ANONYMOUS: c_int = MAP_ANON; +pub const MAP_FILE: c_int = 0x0000; +pub const MAP_RENAME: c_int = 0x0020; +pub const MAP_NORESERVE: c_int = 0x0040; +pub const MAP_INHERIT: c_int = 0x0080; +pub const MAP_HASSEMAPHORE: c_int = 0x0200; +pub const MAP_TRYFIXED: c_int = 0x0400; +pub const MAP_WIRED: c_int = 0x0800; + +pub const MAP_FAILED: *mut c_void = !0 as *mut c_void; + +// Memory sync constants +pub const MS_ASYNC: c_int = 0x01; +pub const MS_INVALIDATE: c_int = 0x02; +pub const MS_SYNC: c_int = 0x04; + +// Memory lock constants +pub const MCL_CURRENT: c_int = 0x01; +pub const MCL_FUTURE: c_int = 0x02; + +extern "C" { + pub fn mmap( + addr: *mut c_void, + len: size_t, + prot: c_int, + flags: c_int, + fd: c_int, + offset: off_t, + ) -> *mut c_void; + pub fn munmap(addr: *mut c_void, len: size_t) -> c_int; + pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; + pub fn mlock(addr: *const c_void, len: size_t) -> c_int; + pub fn munlock(addr: *const c_void, len: size_t) -> c_int; + pub fn mlockall(flags: c_int) -> c_int; + pub fn munlockall() -> c_int; + pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int; +} diff --git a/http/vendor/libc/src/new/qurt/sys/mod.rs b/http/vendor/libc/src/new/qurt/sys/mod.rs new file mode 100644 index 0000000..f9ef6a4 --- /dev/null +++ b/http/vendor/libc/src/new/qurt/sys/mod.rs @@ -0,0 +1,6 @@ +//! System headers (`sys/*`) + +pub(crate) mod mman; +pub(crate) mod sched; +pub(crate) mod stat; +pub(crate) mod types; diff --git a/http/vendor/libc/src/new/qurt/sys/sched.rs b/http/vendor/libc/src/new/qurt/sys/sched.rs new file mode 100644 index 0000000..56fed5b --- /dev/null +++ b/http/vendor/libc/src/new/qurt/sys/sched.rs @@ -0,0 +1,24 @@ +//! Header: `sys/sched.h` +//! +//! QuRT scheduling parameters and functions. + +use crate::prelude::*; + +// Scheduling policies (from QuRT sys/sched.h) +pub const SCHED_FIFO: c_int = 0; +pub const SCHED_RR: c_int = 1; +pub const SCHED_SPORADIC: c_int = 2; +pub const SCHED_OTHER: c_int = 3; + +s! { + pub struct sched_param { + pub unimplemented: *mut c_void, + pub sched_priority: c_int, + } +} + +extern "C" { + pub fn sched_yield() -> c_int; + pub fn sched_get_priority_max(policy: c_int) -> c_int; + pub fn sched_get_priority_min(policy: c_int) -> c_int; +} diff --git a/http/vendor/libc/src/new/qurt/sys/stat.rs b/http/vendor/libc/src/new/qurt/sys/stat.rs new file mode 100644 index 0000000..a8ee211 --- /dev/null +++ b/http/vendor/libc/src/new/qurt/sys/stat.rs @@ -0,0 +1,36 @@ +//! Header: `sys/stat.h` + +use super::super::*; +use crate::prelude::*; + +// File type constants for stat.st_mode +pub const S_IFMT: mode_t = 0o170000; +pub const S_IFSOCK: mode_t = 0o140000; +pub const S_IFLNK: mode_t = 0o120000; +pub const S_IFREG: mode_t = 0o100000; +pub const S_IFBLK: mode_t = 0o060000; +pub const S_IFDIR: mode_t = 0o040000; +pub const S_IFCHR: mode_t = 0o020000; +pub const S_IFIFO: mode_t = 0o010000; + +// File permission constants +pub const S_ISUID: mode_t = 0o4000; +pub const S_ISGID: mode_t = 0o2000; +pub const S_ISVTX: mode_t = 0o1000; +pub const S_IRWXU: mode_t = 0o0700; +pub const S_IRUSR: mode_t = 0o0400; +pub const S_IWUSR: mode_t = 0o0200; +pub const S_IXUSR: mode_t = 0o0100; +pub const S_IRWXG: mode_t = 0o0070; +pub const S_IRGRP: mode_t = 0o0040; +pub const S_IWGRP: mode_t = 0o0020; +pub const S_IXGRP: mode_t = 0o0010; +pub const S_IRWXO: mode_t = 0o0007; +pub const S_IROTH: mode_t = 0o0004; +pub const S_IWOTH: mode_t = 0o0002; +pub const S_IXOTH: mode_t = 0o0001; + +extern "C" { + pub fn stat(pathname: *const c_char, statbuf: *mut stat) -> c_int; + pub fn fstat(fd: c_int, statbuf: *mut stat) -> c_int; +} diff --git a/http/vendor/libc/src/new/qurt/sys/types.rs b/http/vendor/libc/src/new/qurt/sys/types.rs new file mode 100644 index 0000000..a5db516 --- /dev/null +++ b/http/vendor/libc/src/new/qurt/sys/types.rs @@ -0,0 +1,9 @@ +//! Header: `sys/types.h` +//! +//! Note: Basic types are defined at the crate root level for qurt. +//! This module provides sys/types.h specific functions and constants. + +use super::super::*; +use crate::prelude::*; + +pub type cpu_set_t = c_uint; diff --git a/http/vendor/libc/src/new/qurt/time.rs b/http/vendor/libc/src/new/qurt/time.rs new file mode 100644 index 0000000..ab6f445 --- /dev/null +++ b/http/vendor/libc/src/new/qurt/time.rs @@ -0,0 +1,34 @@ +//! Header: `time.h` + +use super::*; +use crate::prelude::*; + +// Clock types +pub const CLOCK_REALTIME: clockid_t = 0; +pub const CLOCK_MONOTONIC: clockid_t = 1; +pub const CLOCK_THREAD_CPUTIME_ID: clockid_t = 2; +pub const CLOCK_PROCESS_CPUTIME_ID: clockid_t = 3; + +extern "C" { + pub fn time(tloc: *mut time_t) -> time_t; + pub fn clock() -> clock_t; + pub fn difftime(time1: time_t, time0: time_t) -> c_double; + pub fn mktime(tm: *mut tm) -> time_t; + pub fn gmtime(timep: *const time_t) -> *mut tm; + pub fn gmtime_r(timep: *const time_t, result: *mut tm) -> *mut tm; + pub fn localtime(timep: *const time_t) -> *mut tm; + pub fn localtime_r(timep: *const time_t, result: *mut tm) -> *mut tm; + pub fn asctime(tm: *const tm) -> *mut c_char; + pub fn asctime_r(tm: *const tm, buf: *mut c_char) -> *mut c_char; + pub fn ctime(timep: *const time_t) -> *mut c_char; + pub fn ctime_r(timep: *const time_t, buf: *mut c_char) -> *mut c_char; + pub fn strftime( + s: *mut c_char, + maxsize: size_t, + format: *const c_char, + timeptr: *const tm, + ) -> size_t; + pub fn strptime(s: *const c_char, format: *const c_char, tm: *mut tm) -> *mut c_char; + pub fn clock_gettime(clk_id: clockid_t, tp: *mut timespec) -> c_int; + pub fn nanosleep(req: *const timespec, rem: *mut timespec) -> c_int; +} diff --git a/http/vendor/libc/src/new/qurt/unistd.rs b/http/vendor/libc/src/new/qurt/unistd.rs new file mode 100644 index 0000000..b973b60 --- /dev/null +++ b/http/vendor/libc/src/new/qurt/unistd.rs @@ -0,0 +1,248 @@ +//! Header: `unistd.h` + +use super::*; +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; +use crate::prelude::*; + +// Access mode constants +pub const F_OK: c_int = 0; +pub const X_OK: c_int = 1; +pub const W_OK: c_int = 2; +pub const R_OK: c_int = 4; + +// Whence constants for lseek +pub const SEEK_SET: c_int = 0; +pub const SEEK_CUR: c_int = 1; +pub const SEEK_END: c_int = 2; + +// pathconf constants (from bits/confname.h) +pub const _PC_LINK_MAX: c_int = 0; +pub const _PC_MAX_CANON: c_int = 1; +pub const _PC_MAX_INPUT: c_int = 2; +pub const _PC_NAME_MAX: c_int = 3; +pub const _PC_PATH_MAX: c_int = 4; +pub const _PC_PIPE_BUF: c_int = 5; +pub const _PC_CHOWN_RESTRICTED: c_int = 6; +pub const _PC_NO_TRUNC: c_int = 7; +pub const _PC_VDISABLE: c_int = 8; +pub const _PC_SYNC_IO: c_int = 9; +pub const _PC_ASYNC_IO: c_int = 10; +pub const _PC_PRIO_IO: c_int = 11; +pub const _PC_SOCK_MAXBUF: c_int = 12; +pub const _PC_FILESIZEBITS: c_int = 13; +pub const _PC_REC_INCR_XFER_SIZE: c_int = 14; +pub const _PC_REC_MAX_XFER_SIZE: c_int = 15; +pub const _PC_REC_MIN_XFER_SIZE: c_int = 16; +pub const _PC_REC_XFER_ALIGN: c_int = 17; +pub const _PC_ALLOC_SIZE_MIN: c_int = 18; +pub const _PC_SYMLINK_MAX: c_int = 19; +pub const _PC_2_SYMLINKS: c_int = 20; + +// sysconf constants (from bits/confname.h) +pub const _SC_ARG_MAX: c_int = 0; +pub const _SC_CHILD_MAX: c_int = 1; +pub const _SC_CLK_TCK: c_int = 2; +pub const _SC_NGROUPS_MAX: c_int = 3; +pub const _SC_OPEN_MAX: c_int = 4; +pub const _SC_STREAM_MAX: c_int = 5; +pub const _SC_TZNAME_MAX: c_int = 6; +pub const _SC_JOB_CONTROL: c_int = 7; +pub const _SC_SAVED_IDS: c_int = 8; +pub const _SC_REALTIME_SIGNALS: c_int = 9; +pub const _SC_PRIORITY_SCHEDULING: c_int = 10; +pub const _SC_TIMERS: c_int = 11; +pub const _SC_ASYNCHRONOUS_IO: c_int = 12; +pub const _SC_PRIORITIZED_IO: c_int = 13; +pub const _SC_SYNCHRONIZED_IO: c_int = 14; +pub const _SC_FSYNC: c_int = 15; +pub const _SC_MAPPED_FILES: c_int = 16; +pub const _SC_MEMLOCK: c_int = 17; +pub const _SC_MEMLOCK_RANGE: c_int = 18; +pub const _SC_MEMORY_PROTECTION: c_int = 19; +pub const _SC_MESSAGE_PASSING: c_int = 20; +pub const _SC_SEMAPHORES: c_int = 21; +pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 22; +pub const _SC_AIO_LISTIO_MAX: c_int = 23; +pub const _SC_AIO_MAX: c_int = 24; +pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 25; +pub const _SC_DELAYTIMER_MAX: c_int = 26; +pub const _SC_MQ_OPEN_MAX: c_int = 27; +pub const _SC_MQ_PRIO_MAX: c_int = 28; +pub const _SC_VERSION: c_int = 29; +pub const _SC_PAGESIZE: c_int = 30; +pub const _SC_PAGE_SIZE: c_int = _SC_PAGESIZE; +pub const _SC_RTSIG_MAX: c_int = 31; +pub const _SC_SEM_NSEMS_MAX: c_int = 32; +pub const _SC_SEM_VALUE_MAX: c_int = 33; +pub const _SC_SIGQUEUE_MAX: c_int = 34; +pub const _SC_TIMER_MAX: c_int = 35; +pub const _SC_BC_BASE_MAX: c_int = 36; +pub const _SC_BC_DIM_MAX: c_int = 37; +pub const _SC_BC_SCALE_MAX: c_int = 38; +pub const _SC_BC_STRING_MAX: c_int = 39; +pub const _SC_COLL_WEIGHTS_MAX: c_int = 40; +pub const _SC_EQUIV_CLASS_MAX: c_int = 41; +pub const _SC_EXPR_NEST_MAX: c_int = 42; +pub const _SC_LINE_MAX: c_int = 43; +pub const _SC_RE_DUP_MAX: c_int = 44; +pub const _SC_CHARCLASS_NAME_MAX: c_int = 45; +pub const _SC_2_VERSION: c_int = 46; +pub const _SC_2_C_BIND: c_int = 47; +pub const _SC_2_C_DEV: c_int = 48; +pub const _SC_2_FORT_DEV: c_int = 49; +pub const _SC_2_FORT_RUN: c_int = 50; +pub const _SC_2_SW_DEV: c_int = 51; +pub const _SC_2_LOCALEDEF: c_int = 52; +pub const _SC_PII: c_int = 53; +pub const _SC_PII_XTI: c_int = 54; +pub const _SC_PII_SOCKET: c_int = 55; +pub const _SC_PII_INTERNET: c_int = 56; +pub const _SC_PII_OSI: c_int = 57; +pub const _SC_POLL: c_int = 58; +pub const _SC_SELECT: c_int = 59; +pub const _SC_UIO_MAXIOV: c_int = 60; +pub const _SC_IOV_MAX: c_int = _SC_UIO_MAXIOV; +pub const _SC_PII_INTERNET_STREAM: c_int = 61; +pub const _SC_PII_INTERNET_DGRAM: c_int = 62; +pub const _SC_PII_OSI_COTS: c_int = 63; +pub const _SC_PII_OSI_CLTS: c_int = 64; +pub const _SC_PII_OSI_M: c_int = 65; +pub const _SC_T_IOV_MAX: c_int = 66; +pub const _SC_THREADS: c_int = 67; +pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 68; +pub const _SC_GETGR_R_SIZE_MAX: c_int = 69; +pub const _SC_GETPW_R_SIZE_MAX: c_int = 70; +pub const _SC_LOGIN_NAME_MAX: c_int = 71; +pub const _SC_TTY_NAME_MAX: c_int = 72; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 73; +pub const _SC_THREAD_KEYS_MAX: c_int = 74; +pub const _SC_THREAD_STACK_MIN: c_int = 75; +pub const _SC_THREAD_THREADS_MAX: c_int = 76; +pub const _SC_THREAD_ATTR_STACKADDR: c_int = 77; +pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 78; +pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 79; +pub const _SC_THREAD_PRIO_INHERIT: c_int = 80; +pub const _SC_THREAD_PRIO_PROTECT: c_int = 81; +pub const _SC_THREAD_PROCESS_SHARED: c_int = 82; +pub const _SC_NPROCESSORS_CONF: c_int = 83; +pub const _SC_NPROCESSORS_ONLN: c_int = 84; +pub const _SC_PHYS_PAGES: c_int = 85; +pub const _SC_AVPHYS_PAGES: c_int = 86; +pub const _SC_ATEXIT_MAX: c_int = 87; +pub const _SC_PASS_MAX: c_int = 88; +pub const _SC_XOPEN_VERSION: c_int = 89; +pub const _SC_XOPEN_XCU_VERSION: c_int = 90; +pub const _SC_XOPEN_UNIX: c_int = 91; +pub const _SC_XOPEN_CRYPT: c_int = 92; +pub const _SC_XOPEN_ENH_I18N: c_int = 93; +pub const _SC_XOPEN_SHM: c_int = 94; +pub const _SC_2_CHAR_TERM: c_int = 95; +pub const _SC_2_C_VERSION: c_int = 96; +pub const _SC_2_UPE: c_int = 97; +pub const _SC_XOPEN_XPG2: c_int = 98; +pub const _SC_XOPEN_XPG3: c_int = 99; +pub const _SC_XOPEN_XPG4: c_int = 100; +pub const _SC_CHAR_BIT: c_int = 101; +pub const _SC_CHAR_MAX: c_int = 102; +pub const _SC_CHAR_MIN: c_int = 103; +pub const _SC_INT_MAX: c_int = 104; +pub const _SC_INT_MIN: c_int = 105; +pub const _SC_LONG_BIT: c_int = 106; +pub const _SC_WORD_BIT: c_int = 107; +pub const _SC_MB_LEN_MAX: c_int = 108; +pub const _SC_NZERO: c_int = 109; +pub const _SC_SSIZE_MAX: c_int = 110; +pub const _SC_SCHAR_MAX: c_int = 111; +pub const _SC_SCHAR_MIN: c_int = 112; +pub const _SC_SHRT_MAX: c_int = 113; +pub const _SC_SHRT_MIN: c_int = 114; +pub const _SC_UCHAR_MAX: c_int = 115; +pub const _SC_UINT_MAX: c_int = 116; +pub const _SC_ULONG_MAX: c_int = 117; +pub const _SC_USHRT_MAX: c_int = 118; +pub const _SC_NL_ARGMAX: c_int = 119; +pub const _SC_NL_LANGMAX: c_int = 120; +pub const _SC_NL_MSGMAX: c_int = 121; +pub const _SC_NL_NMAX: c_int = 122; +pub const _SC_NL_SETMAX: c_int = 123; +pub const _SC_NL_TEXTMAX: c_int = 124; +pub const _SC_XBS5_ILP32_OFF32: c_int = 125; +pub const _SC_XBS5_ILP32_OFFBIG: c_int = 126; +pub const _SC_XBS5_LP64_OFF64: c_int = 127; +pub const _SC_XBS5_LPBIG_OFFBIG: c_int = 128; +pub const _SC_XOPEN_LEGACY: c_int = 129; +pub const _SC_XOPEN_REALTIME: c_int = 130; +pub const _SC_XOPEN_REALTIME_THREADS: c_int = 131; +pub const _SC_ADVISORY_INFO: c_int = 132; +pub const _SC_BARRIERS: c_int = 133; +pub const _SC_CLOCK_SELECTION: c_int = 137; +pub const _SC_CPUTIME: c_int = 138; +pub const _SC_THREAD_CPUTIME: c_int = 139; +pub const _SC_MONOTONIC_CLOCK: c_int = 149; +pub const _SC_READER_WRITER_LOCKS: c_int = 153; +pub const _SC_SPIN_LOCKS: c_int = 154; +pub const _SC_REGEXP: c_int = 155; +pub const _SC_SHELL: c_int = 157; +pub const _SC_SPAWN: c_int = 159; +pub const _SC_SPORADIC_SERVER: c_int = 160; +pub const _SC_THREAD_SPORADIC_SERVER: c_int = 161; +pub const _SC_TIMEOUTS: c_int = 164; +pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 165; +pub const _SC_2_PBS: c_int = 168; +pub const _SC_2_PBS_ACCOUNTING: c_int = 169; +pub const _SC_2_PBS_LOCATE: c_int = 170; +pub const _SC_2_PBS_MESSAGE: c_int = 171; +pub const _SC_2_PBS_TRACK: c_int = 172; +pub const _SC_SYMLOOP_MAX: c_int = 173; +pub const _SC_2_PBS_CHECKPOINT: c_int = 175; +pub const _SC_V6_ILP32_OFF32: c_int = 176; +pub const _SC_V6_ILP32_OFFBIG: c_int = 177; +pub const _SC_V6_LP64_OFF64: c_int = 178; +pub const _SC_V6_LPBIG_OFFBIG: c_int = 179; +pub const _SC_HOST_NAME_MAX: c_int = 180; +pub const _SC_TRACE: c_int = 181; +pub const _SC_TRACE_EVENT_FILTER: c_int = 182; +pub const _SC_TRACE_INHERIT: c_int = 183; +pub const _SC_TRACE_LOG: c_int = 184; +pub const _SC_IPV6: c_int = 235; +pub const _SC_RAW_SOCKETS: c_int = 236; +pub const _SC_V7_ILP32_OFF32: c_int = 237; +pub const _SC_V7_ILP32_OFFBIG: c_int = 238; +pub const _SC_V7_LP64_OFF64: c_int = 239; +pub const _SC_V7_LPBIG_OFFBIG: c_int = 240; +pub const _SC_SS_REPL_MAX: c_int = 241; +pub const _SC_TRACE_EVENT_NAME_MAX: c_int = 242; +pub const _SC_TRACE_NAME_MAX: c_int = 243; +pub const _SC_TRACE_SYS_MAX: c_int = 244; +pub const _SC_TRACE_USER_EVENT_MAX: c_int = 245; +pub const _SC_XOPEN_STREAMS: c_int = 246; +pub const _SC_THREAD_ROBUST_PRIO_INHERIT: c_int = 247; +pub const _SC_THREAD_ROBUST_PRIO_PROTECT: c_int = 248; + +extern "C" { + // File operations + pub fn access(pathname: *const c_char, mode: c_int) -> c_int; + pub fn close(fd: c_int) -> c_int; + pub fn lseek(fd: c_int, offset: off_t, whence: c_int) -> off_t; + pub fn read(fd: c_int, buf: *mut c_void, count: size_t) -> ssize_t; + pub fn write(fd: c_int, buf: *const c_void, count: size_t) -> ssize_t; + pub fn ftruncate(fd: c_int, length: off_t) -> c_int; + pub fn unlink(pathname: *const c_char) -> c_int; + + // Directory operations + pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char; + pub fn rmdir(pathname: *const c_char) -> c_int; + + // Process operations + pub fn getpid() -> pid_t; + + // Sleep functions + pub fn sleep(seconds: c_uint) -> c_uint; + + // System configuration + pub fn sysconf(name: c_int) -> c_long; +} diff --git a/http/vendor/libc/src/new/redox/mod.rs b/http/vendor/libc/src/new/redox/mod.rs new file mode 100644 index 0000000..cf7806a --- /dev/null +++ b/http/vendor/libc/src/new/redox/mod.rs @@ -0,0 +1,3 @@ +//! Redox libc. +//! +//! * Headers: diff --git a/http/vendor/libc/src/new/relibc/mod.rs b/http/vendor/libc/src/new/relibc/mod.rs new file mode 100644 index 0000000..d244912 --- /dev/null +++ b/http/vendor/libc/src/new/relibc/mod.rs @@ -0,0 +1,5 @@ +//! Redox OS libc. +//! +//! * Headers: + +pub(crate) mod unistd; diff --git a/http/vendor/libc/src/new/relibc/unistd.rs b/http/vendor/libc/src/new/relibc/unistd.rs new file mode 100644 index 0000000..8d55ee5 --- /dev/null +++ b/http/vendor/libc/src/new/relibc/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/http/vendor/libc/src/new/rtems/mod.rs b/http/vendor/libc/src/new/rtems/mod.rs new file mode 100644 index 0000000..bd3dc39 --- /dev/null +++ b/http/vendor/libc/src/new/rtems/mod.rs @@ -0,0 +1,2 @@ +//! RTEMS libc. +// FIXME(rtems): link to headers needed. diff --git a/http/vendor/libc/src/new/sgx/mod.rs b/http/vendor/libc/src/new/sgx/mod.rs new file mode 100644 index 0000000..8c15dad --- /dev/null +++ b/http/vendor/libc/src/new/sgx/mod.rs @@ -0,0 +1 @@ +//! Fortanix SGX. diff --git a/http/vendor/libc/src/new/sgx/unistd.rs b/http/vendor/libc/src/new/sgx/unistd.rs new file mode 100644 index 0000000..8d55ee5 --- /dev/null +++ b/http/vendor/libc/src/new/sgx/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/http/vendor/libc/src/new/solaris/mod.rs b/http/vendor/libc/src/new/solaris/mod.rs new file mode 100644 index 0000000..97ae473 --- /dev/null +++ b/http/vendor/libc/src/new/solaris/mod.rs @@ -0,0 +1,5 @@ +//! Solaris libc. +//! +//! * Manual pages: (under "Reference Manuals") + +pub(crate) mod unistd; diff --git a/http/vendor/libc/src/new/solaris/unistd.rs b/http/vendor/libc/src/new/solaris/unistd.rs new file mode 100644 index 0000000..8d55ee5 --- /dev/null +++ b/http/vendor/libc/src/new/solaris/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/http/vendor/libc/src/new/solid/mod.rs b/http/vendor/libc/src/new/solid/mod.rs new file mode 100644 index 0000000..4a197cf --- /dev/null +++ b/http/vendor/libc/src/new/solid/mod.rs @@ -0,0 +1,2 @@ +//! Kyoto Microcomputer SOLID. +// FIXME(solid): link to headers needed. diff --git a/http/vendor/libc/src/new/teeos/mod.rs b/http/vendor/libc/src/new/teeos/mod.rs new file mode 100644 index 0000000..96f44d3 --- /dev/null +++ b/http/vendor/libc/src/new/teeos/mod.rs @@ -0,0 +1,2 @@ +//! Per the target docs, TEEOS uses part of musl as its libc. +// FIXME(teeos): link to headers needed. diff --git a/http/vendor/libc/src/new/trusty/mod.rs b/http/vendor/libc/src/new/trusty/mod.rs new file mode 100644 index 0000000..261ecb0 --- /dev/null +++ b/http/vendor/libc/src/new/trusty/mod.rs @@ -0,0 +1,2 @@ +//! Trusty libc. +// FIXME(trusty): link to headers needed. diff --git a/http/vendor/libc/src/new/uclibc/mod.rs b/http/vendor/libc/src/new/uclibc/mod.rs new file mode 100644 index 0000000..6bf83ef --- /dev/null +++ b/http/vendor/libc/src/new/uclibc/mod.rs @@ -0,0 +1,7 @@ +//! uClibc. +//! +//! * About: +//! * Headers: (mirror) + +pub(crate) mod pthread; +pub(crate) mod unistd; diff --git a/http/vendor/libc/src/new/uclibc/pthread.rs b/http/vendor/libc/src/new/uclibc/pthread.rs new file mode 100644 index 0000000..c0f1731 --- /dev/null +++ b/http/vendor/libc/src/new/uclibc/pthread.rs @@ -0,0 +1,66 @@ +//! Header: `pthread.h` +//! +//! Note that The l4re port of uclibc doesn't yet support all `pthread_*` API that is +//! available upstream. + +pub use crate::new::common::linux_like::pthread::{ + pthread_getaffinity_np, + pthread_getattr_np, + pthread_setaffinity_np, +}; +#[cfg(not(target_os = "l4re"))] +pub use crate::new::common::linux_like::pthread::{ + pthread_getname_np, + pthread_setname_np, +}; +#[cfg(not(target_os = "l4re"))] +pub use crate::new::common::posix::pthread::{ + pthread_atfork, + pthread_barrierattr_getpshared, + pthread_condattr_getclock, + pthread_condattr_setclock, + pthread_getcpuclockid, + pthread_mutex_consistent, + pthread_mutexattr_getprotocol, + pthread_mutexattr_getrobust, + pthread_mutexattr_setprotocol, + pthread_mutexattr_setrobust, + pthread_setschedprio, +}; +pub use crate::new::common::posix::pthread::{ + pthread_attr_getguardsize, + pthread_attr_getinheritsched, + pthread_attr_getschedparam, + pthread_attr_getschedpolicy, + pthread_attr_getstack, + pthread_attr_setguardsize, + pthread_attr_setinheritsched, + pthread_attr_setschedparam, + pthread_attr_setschedpolicy, + pthread_attr_setstack, + pthread_barrier_destroy, + pthread_barrier_init, + pthread_barrier_wait, + pthread_barrierattr_destroy, + pthread_barrierattr_init, + pthread_barrierattr_setpshared, + pthread_cancel, + pthread_condattr_getpshared, + pthread_condattr_setpshared, + pthread_create, + pthread_getschedparam, + pthread_kill, + pthread_mutex_timedlock, + pthread_mutexattr_getpshared, + pthread_mutexattr_setpshared, + pthread_once, + pthread_rwlockattr_getpshared, + pthread_rwlockattr_setpshared, + pthread_setschedparam, + pthread_sigmask, + pthread_spin_destroy, + pthread_spin_init, + pthread_spin_lock, + pthread_spin_trylock, + pthread_spin_unlock, +}; diff --git a/http/vendor/libc/src/new/uclibc/unistd.rs b/http/vendor/libc/src/new/uclibc/unistd.rs new file mode 100644 index 0000000..8d55ee5 --- /dev/null +++ b/http/vendor/libc/src/new/uclibc/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/http/vendor/libc/src/new/ucrt/mod.rs b/http/vendor/libc/src/new/ucrt/mod.rs new file mode 100644 index 0000000..f6b5f5d --- /dev/null +++ b/http/vendor/libc/src/new/ucrt/mod.rs @@ -0,0 +1,4 @@ +//! Windows Universal C Runtime. +//! +//! * Manual pages: +//! * UCRT information: diff --git a/http/vendor/libc/src/new/vita/mod.rs b/http/vendor/libc/src/new/vita/mod.rs new file mode 100644 index 0000000..21205eb --- /dev/null +++ b/http/vendor/libc/src/new/vita/mod.rs @@ -0,0 +1,2 @@ +//! VITASDK system library. +// FIXME(vita): link to headers or manpages needed. diff --git a/http/vendor/libc/src/new/vxworks/mod.rs b/http/vendor/libc/src/new/vxworks/mod.rs new file mode 100644 index 0000000..6563056 --- /dev/null +++ b/http/vendor/libc/src/new/vxworks/mod.rs @@ -0,0 +1,4 @@ +//! VxWorks libc. +// FIXME(vxworks): link to headers needed. + +pub(crate) mod unistd; diff --git a/http/vendor/libc/src/new/vxworks/unistd.rs b/http/vendor/libc/src/new/vxworks/unistd.rs new file mode 100644 index 0000000..8d55ee5 --- /dev/null +++ b/http/vendor/libc/src/new/vxworks/unistd.rs @@ -0,0 +1,7 @@ +//! Header: `unistd.h` + +pub use crate::new::common::posix::unistd::{ + STDERR_FILENO, + STDIN_FILENO, + STDOUT_FILENO, +}; diff --git a/http/vendor/libc/src/new/wasi/mod.rs b/http/vendor/libc/src/new/wasi/mod.rs new file mode 100644 index 0000000..341e6d5 --- /dev/null +++ b/http/vendor/libc/src/new/wasi/mod.rs @@ -0,0 +1,3 @@ +//! WASI libc. +//! +//! * Headers: diff --git a/http/vendor/libc/src/new/xous/mod.rs b/http/vendor/libc/src/new/xous/mod.rs new file mode 100644 index 0000000..8a9a285 --- /dev/null +++ b/http/vendor/libc/src/new/xous/mod.rs @@ -0,0 +1,2 @@ +//! Xous libc. +// FIXME(xous): link to headers needed. diff --git a/http/vendor/libc/src/primitives.rs b/http/vendor/libc/src/primitives.rs new file mode 100644 index 0000000..228dbc2 --- /dev/null +++ b/http/vendor/libc/src/primitives.rs @@ -0,0 +1,58 @@ +//! This module contains type aliases for C's platform-specific types +//! and fixed-width integer types. +//! +//! The platform-specific types definitions were taken from rust-lang/rust in +//! library/core/src/ffi/primitives.rs +//! +//! The fixed-width integer aliases are deprecated: use the Rust types instead. + +// FIXME(1.0): Deprecate these aliases in a few releases, remove in 1.0. +pub use core::ffi::{ + c_char, + c_double, + c_float, + c_int, + c_long, + c_longlong, + c_schar, + c_short, + c_uchar, + c_uint, + c_ulong, + c_ulonglong, + c_ushort, +}; + +#[deprecated(since = "0.2.55", note = "Use i8 instead.")] +pub type int8_t = i8; +#[deprecated(since = "0.2.55", note = "Use i16 instead.")] +pub type int16_t = i16; +#[deprecated(since = "0.2.55", note = "Use i32 instead.")] +pub type int32_t = i32; +#[deprecated(since = "0.2.55", note = "Use i64 instead.")] +pub type int64_t = i64; +#[deprecated(since = "0.2.55", note = "Use u8 instead.")] +pub type uint8_t = u8; +#[deprecated(since = "0.2.55", note = "Use u16 instead.")] +pub type uint16_t = u16; +#[deprecated(since = "0.2.55", note = "Use u32 instead.")] +pub type uint32_t = u32; +#[deprecated(since = "0.2.55", note = "Use u64 instead.")] +pub type uint64_t = u64; + +cfg_if! { + if #[cfg(all(target_arch = "aarch64", not(target_os = "windows")))] { + /// C `__int128` (a GCC extension that's part of many ABIs) + #[deprecated(since = "0.2.184", note = "Use i128 instead.")] + pub type __int128 = i128; + /// C `unsigned __int128` (a GCC extension that's part of many ABIs) + #[deprecated(since = "0.2.184", note = "Use u128 instead.")] + pub type __uint128 = u128; + /// C __int128_t (alternate name for [__int128][]) + #[deprecated(since = "0.2.184", note = "Use i128 instead.")] + pub type __int128_t = i128; + /// C __uint128_t (alternate name for [__uint128][]) + #[deprecated(since = "0.2.184", note = "Use u128 instead.")] + pub type __uint128_t = u128; + } +} diff --git a/http/vendor/libc/src/psp.rs b/http/vendor/libc/src/psp.rs new file mode 100644 index 0000000..8235671 --- /dev/null +++ b/http/vendor/libc/src/psp.rs @@ -0,0 +1,4131 @@ +//! PSP C type definitions +//! +//! These type declarations are not enough, as they must be ultimately resolved +//! by the linker. Crates that use these definitions must, somewhere in the +//! crate graph, include a stub provider crate such as the `psp` crate. + +use crate::prelude::*; + +pub type intmax_t = i64; +pub type uintmax_t = u64; + +pub type size_t = usize; +pub type ptrdiff_t = isize; +pub type intptr_t = isize; +pub type uintptr_t = usize; +pub type ssize_t = isize; + +pub type SceKernelVTimerHandler = unsafe extern "C" fn( + uid: SceUid, + arg1: *mut SceKernelSysClock, + arg2: *mut SceKernelSysClock, + arg3: *mut c_void, +) -> u32; + +pub type SceKernelVTimerHandlerWide = + unsafe extern "C" fn(uid: SceUid, arg1: i64, arg2: i64, arg3: *mut c_void) -> u32; + +pub type SceKernelThreadEventHandler = + unsafe extern "C" fn(mask: i32, thid: SceUid, common: *mut c_void) -> i32; + +pub type SceKernelAlarmHandler = unsafe extern "C" fn(common: *mut c_void) -> u32; + +pub type SceKernelCallbackFunction = + unsafe extern "C" fn(arg1: i32, arg2: i32, arg: *mut c_void) -> i32; + +pub type SceKernelThreadEntry = unsafe extern "C" fn(args: usize, argp: *mut c_void) -> i32; + +pub type PowerCallback = extern "C" fn(unknown: i32, power_info: i32); + +pub type IoPermissions = i32; + +pub type UmdCallback = fn(unknown: i32, event: i32) -> i32; + +pub type SceMpegRingbufferCb = + Option i32>; + +pub type GuCallback = Option; +pub type GuSwapBuffersCallback = + Option; + +pub type SceNetAdhocctlHandler = + Option; + +pub type AdhocMatchingCallback = Option< + unsafe extern "C" fn( + matching_id: i32, + event: i32, + mac: *mut u8, + opt_len: i32, + opt_data: *mut c_void, + ), +>; + +pub type SceNetApctlHandler = Option< + unsafe extern "C" fn(oldState: i32, newState: i32, event: i32, error: i32, pArg: *mut c_void), +>; + +pub type HttpMallocFunction = Option *mut c_void>; +pub type HttpReallocFunction = + Option *mut c_void>; +pub type HttpFreeFunction = Option; +pub type HttpPasswordCB = Option< + unsafe extern "C" fn( + request: i32, + auth_type: HttpAuthType, + realm: *const u8, + username: *mut u8, + password: *mut u8, + need_entity: i32, + entity_body: *mut *mut u8, + entity_size: *mut usize, + save: *mut i32, + ) -> i32, +>; + +pub type socklen_t = u32; + +e! { + #[repr(u32)] + pub enum AudioFormat { + Stereo = 0, + Mono = 0x10, + } + + #[repr(u32)] + pub enum DisplayMode { + Lcd = 0, + } + + #[repr(u32)] + pub enum DisplayPixelFormat { + Psm5650 = 0, + Psm5551 = 1, + Psm4444 = 2, + Psm8888 = 3, + } + + #[repr(u32)] + pub enum DisplaySetBufSync { + Immediate = 0, + NextFrame = 1, + } + + #[repr(i32)] + pub enum AudioOutputFrequency { + Khz48 = 48000, + Khz44_1 = 44100, + Khz32 = 32000, + Khz24 = 24000, + Khz22_05 = 22050, + Khz16 = 16000, + Khz12 = 12000, + Khz11_025 = 11025, + Khz8 = 8000, + } + + #[repr(i32)] + pub enum AudioInputFrequency { + Khz44_1 = 44100, + Khz22_05 = 22050, + Khz11_025 = 11025, + } + + #[repr(u32)] + pub enum CtrlMode { + Digital = 0, + Analog, + } + + #[repr(i32)] + pub enum GeMatrixType { + Bone0 = 0, + Bone1, + Bone2, + Bone3, + Bone4, + Bone5, + Bone6, + Bone7, + World, + View, + Projection, + TexGen, + } + + #[repr(i32)] + pub enum GeListState { + Done = 0, + Queued, + DrawingDone, + StallReached, + CancelDone, + } + + #[repr(u8)] + pub enum GeCommand { + Nop = 0, + Vaddr = 0x1, + Iaddr = 0x2, + Prim = 0x4, + Bezier = 0x5, + Spline = 0x6, + BoundingBox = 0x7, + Jump = 0x8, + BJump = 0x9, + Call = 0xa, + Ret = 0xb, + End = 0xc, + Signal = 0xe, + Finish = 0xf, + Base = 0x10, + VertexType = 0x12, + OffsetAddr = 0x13, + Origin = 0x14, + Region1 = 0x15, + Region2 = 0x16, + LightingEnable = 0x17, + LightEnable0 = 0x18, + LightEnable1 = 0x19, + LightEnable2 = 0x1a, + LightEnable3 = 0x1b, + DepthClampEnable = 0x1c, + CullFaceEnable = 0x1d, + TextureMapEnable = 0x1e, + FogEnable = 0x1f, + DitherEnable = 0x20, + AlphaBlendEnable = 0x21, + AlphaTestEnable = 0x22, + ZTestEnable = 0x23, + StencilTestEnable = 0x24, + AntiAliasEnable = 0x25, + PatchCullEnable = 0x26, + ColorTestEnable = 0x27, + LogicOpEnable = 0x28, + BoneMatrixNumber = 0x2a, + BoneMatrixData = 0x2b, + MorphWeight0 = 0x2c, + MorphWeight1 = 0x2d, + MorphWeight2 = 0x2e, + MorphWeight3 = 0x2f, + MorphWeight4 = 0x30, + MorphWeight5 = 0x31, + MorphWeight6 = 0x32, + MorphWeight7 = 0x33, + PatchDivision = 0x36, + PatchPrimitive = 0x37, + PatchFacing = 0x38, + WorldMatrixNumber = 0x3a, + WorldMatrixData = 0x3b, + ViewMatrixNumber = 0x3c, + ViewMatrixData = 0x3d, + ProjMatrixNumber = 0x3e, + ProjMatrixData = 0x3f, + TGenMatrixNumber = 0x40, + TGenMatrixData = 0x41, + ViewportXScale = 0x42, + ViewportYScale = 0x43, + ViewportZScale = 0x44, + ViewportXCenter = 0x45, + ViewportYCenter = 0x46, + ViewportZCenter = 0x47, + TexScaleU = 0x48, + TexScaleV = 0x49, + TexOffsetU = 0x4a, + TexOffsetV = 0x4b, + OffsetX = 0x4c, + OffsetY = 0x4d, + ShadeMode = 0x50, + ReverseNormal = 0x51, + MaterialUpdate = 0x53, + MaterialEmissive = 0x54, + MaterialAmbient = 0x55, + MaterialDiffuse = 0x56, + MaterialSpecular = 0x57, + MaterialAlpha = 0x58, + MaterialSpecularCoef = 0x5b, + AmbientColor = 0x5c, + AmbientAlpha = 0x5d, + LightMode = 0x5e, + LightType0 = 0x5f, + LightType1 = 0x60, + LightType2 = 0x61, + LightType3 = 0x62, + Light0X = 0x63, + Light0Y, + Light0Z, + Light1X, + Light1Y, + Light1Z, + Light2X, + Light2Y, + Light2Z, + Light3X, + Light3Y, + Light3Z, + Light0DirectionX = 0x6f, + Light0DirectionY, + Light0DirectionZ, + Light1DirectionX, + Light1DirectionY, + Light1DirectionZ, + Light2DirectionX, + Light2DirectionY, + Light2DirectionZ, + Light3DirectionX, + Light3DirectionY, + Light3DirectionZ, + Light0ConstantAtten = 0x7b, + Light0LinearAtten, + Light0QuadtraticAtten, + Light1ConstantAtten, + Light1LinearAtten, + Light1QuadtraticAtten, + Light2ConstantAtten, + Light2LinearAtten, + Light2QuadtraticAtten, + Light3ConstantAtten, + Light3LinearAtten, + Light3QuadtraticAtten, + Light0ExponentAtten = 0x87, + Light1ExponentAtten, + Light2ExponentAtten, + Light3ExponentAtten, + Light0CutoffAtten = 0x8b, + Light1CutoffAtten, + Light2CutoffAtten, + Light3CutoffAtten, + Light0Ambient = 0x8f, + Light0Diffuse, + Light0Specular, + Light1Ambient, + Light1Diffuse, + Light1Specular, + Light2Ambient, + Light2Diffuse, + Light2Specular, + Light3Ambient, + Light3Diffuse, + Light3Specular, + Cull = 0x9b, + FrameBufPtr = 0x9c, + FrameBufWidth = 0x9d, + ZBufPtr = 0x9e, + ZBufWidth = 0x9f, + TexAddr0 = 0xa0, + TexAddr1, + TexAddr2, + TexAddr3, + TexAddr4, + TexAddr5, + TexAddr6, + TexAddr7, + TexBufWidth0 = 0xa8, + TexBufWidth1, + TexBufWidth2, + TexBufWidth3, + TexBufWidth4, + TexBufWidth5, + TexBufWidth6, + TexBufWidth7, + ClutAddr = 0xb0, + ClutAddrUpper = 0xb1, + TransferSrc, + TransferSrcW, + TransferDst, + TransferDstW, + TexSize0 = 0xb8, + TexSize1, + TexSize2, + TexSize3, + TexSize4, + TexSize5, + TexSize6, + TexSize7, + TexMapMode = 0xc0, + TexShadeLs = 0xc1, + TexMode = 0xc2, + TexFormat = 0xc3, + LoadClut = 0xc4, + ClutFormat = 0xc5, + TexFilter = 0xc6, + TexWrap = 0xc7, + TexLevel = 0xc8, + TexFunc = 0xc9, + TexEnvColor = 0xca, + TexFlush = 0xcb, + TexSync = 0xcc, + Fog1 = 0xcd, + Fog2 = 0xce, + FogColor = 0xcf, + TexLodSlope = 0xd0, + FramebufPixFormat = 0xd2, + ClearMode = 0xd3, + Scissor1 = 0xd4, + Scissor2 = 0xd5, + MinZ = 0xd6, + MaxZ = 0xd7, + ColorTest = 0xd8, + ColorRef = 0xd9, + ColorTestmask = 0xda, + AlphaTest = 0xdb, + StencilTest = 0xdc, + StencilOp = 0xdd, + ZTest = 0xde, + BlendMode = 0xdf, + BlendFixedA = 0xe0, + BlendFixedB = 0xe1, + Dith0 = 0xe2, + Dith1, + Dith2, + Dith3, + LogicOp = 0xe6, + ZWriteDisable = 0xe7, + MaskRgb = 0xe8, + MaskAlpha = 0xe9, + TransferStart = 0xea, + TransferSrcPos = 0xeb, + TransferDstPos = 0xec, + TransferSize = 0xee, + Vscx = 0xf0, + Vscy = 0xf1, + Vscz = 0xf2, + Vtcs = 0xf3, + Vtct = 0xf4, + Vtcq = 0xf5, + Vcv = 0xf6, + Vap = 0xf7, + Vfc = 0xf8, + Vscv = 0xf9, + + Unknown03 = 0x03, + Unknown0D = 0x0d, + Unknown11 = 0x11, + Unknown29 = 0x29, + Unknown34 = 0x34, + Unknown35 = 0x35, + Unknown39 = 0x39, + Unknown4E = 0x4e, + Unknown4F = 0x4f, + Unknown52 = 0x52, + Unknown59 = 0x59, + Unknown5A = 0x5a, + UnknownB6 = 0xb6, + UnknownB7 = 0xb7, + UnknownD1 = 0xd1, + UnknownED = 0xed, + UnknownEF = 0xef, + UnknownFA = 0xfa, + UnknownFB = 0xfb, + UnknownFC = 0xfc, + UnknownFD = 0xfd, + UnknownFE = 0xfe, + NopFF = 0xff, + } + + #[repr(i32)] + pub enum SceSysMemPartitionId { + SceKernelUnknownPartition = 0, + SceKernelPrimaryKernelPartition = 1, + SceKernelPrimaryUserPartition = 2, + SceKernelOtherKernelPartition1 = 3, + SceKernelOtherKernelPartition2 = 4, + SceKernelVshellPARTITION = 5, + SceKernelScUserPartition = 6, + SceKernelMeUserPartition = 7, + SceKernelExtendedScKernelPartition = 8, + SceKernelExtendedSc2KernelPartition = 9, + SceKernelExtendedMeKernelPartition = 10, + SceKernelVshellKernelPartition = 11, + SceKernelExtendedKernelPartition = 12, + } + + #[repr(i32)] + pub enum SceSysMemBlockTypes { + Low = 0, + High, + Addr, + } + + #[repr(u32)] + pub enum Interrupt { + Gpio = 4, + Ata = 5, + Umd = 6, + Mscm0 = 7, + Wlan = 8, + Audio = 10, + I2c = 12, + Sircs = 14, + Systimer0 = 15, + Systimer1 = 16, + Systimer2 = 17, + Systimer3 = 18, + Thread0 = 19, + Nand = 20, + Dmacplus = 21, + Dma0 = 22, + Dma1 = 23, + Memlmd = 24, + Ge = 25, + Vblank = 30, + Mecodec = 31, + Hpremote = 36, + Mscm1 = 60, + Mscm2 = 61, + Thread1 = 65, + Interrupt = 66, + } + + #[repr(u32)] + pub enum SubInterrupt { + Gpio = Interrupt::Gpio as u32, + Ata = Interrupt::Ata as u32, + Umd = Interrupt::Umd as u32, + Dmacplus = Interrupt::Dmacplus as u32, + Ge = Interrupt::Ge as u32, + Display = Interrupt::Vblank as u32, + } + + #[repr(u32)] + pub enum SceKernelIdListType { + Thread = 1, + Semaphore = 2, + EventFlag = 3, + Mbox = 4, + Vpl = 5, + Fpl = 6, + Mpipe = 7, + Callback = 8, + ThreadEventHandler = 9, + Alarm = 10, + VTimer = 11, + SleepThread = 64, + DelayThread = 65, + SuspendThread = 66, + DormantThread = 67, + } + + #[repr(i32)] + pub enum UsbCamResolution { + Px160_120 = 0, + Px176_144 = 1, + Px320_240 = 2, + Px352_288 = 3, + Px640_480 = 4, + Px1024_768 = 5, + Px1280_960 = 6, + Px480_272 = 7, + Px360_272 = 8, + } + + #[repr(i32)] + pub enum UsbCamResolutionEx { + Px160_120 = 0, + Px176_144 = 1, + Px320_240 = 2, + Px352_288 = 3, + Px360_272 = 4, + Px480_272 = 5, + Px640_480 = 6, + Px1024_768 = 7, + Px1280_960 = 8, + } + + #[repr(i32)] + pub enum UsbCamDelay { + NoDelay = 0, + Delay10Sec = 1, + Delay20Sec = 2, + Delay30Sec = 3, + } + + #[repr(i32)] + pub enum UsbCamFrameRate { + Fps3_75 = 0, + Fps5 = 1, + Fps7_5 = 2, + Fps10 = 3, + Fps15 = 4, + Fps20 = 5, + Fps30 = 6, + Fps60 = 7, + } + + #[repr(i32)] + pub enum UsbCamWb { + Auto = 0, + Daylight = 1, + Fluorescent = 2, + Incadescent = 3, + } + + #[repr(i32)] + pub enum UsbCamEffectMode { + Normal = 0, + Negative = 1, + Blackwhite = 2, + Sepia = 3, + Blue = 4, + Red = 5, + Green = 6, + } + + #[repr(i32)] + pub enum UsbCamEvLevel { + Pos2_0 = 0, + Pos1_7 = 1, + Pos1_5 = 2, + Pos1_3 = 3, + Pos1_0 = 4, + Pos0_7 = 5, + Pos0_5 = 6, + Pos0_3 = 7, + Zero = 8, + Neg0_3, + Neg0_5, + Neg0_7, + Neg1_0, + Neg1_3, + Neg1_5, + Neg1_7, + Neg2_0, + } + + #[repr(i32)] + pub enum RtcCheckValidError { + InvalidYear = -1, + InvalidMonth = -2, + InvalidDay = -3, + InvalidHour = -4, + InvalidMinutes = -5, + InvalidSeconds = -6, + InvalidMicroseconds = -7, + } + + #[repr(u32)] + pub enum PowerTick { + All = 0, + Suspend = 1, + Display = 6, + } + + #[repr(u32)] + pub enum IoAssignPerms { + RdWr = 0, + RdOnly = 1, + } + + #[repr(u32)] + pub enum IoWhence { + Set = 0, + Cur = 1, + End = 2, + } + + #[repr(u32)] + pub enum UmdType { + Game = 0x10, + Video = 0x20, + Audio = 0x40, + } + + #[repr(u32)] + pub enum GuPrimitive { + Points = 0, + Lines = 1, + LineStrip = 2, + Triangles = 3, + TriangleStrip = 4, + TriangleFan = 5, + Sprites = 6, + } + + #[repr(u32)] + pub enum PatchPrimitive { + Points = 0, + LineStrip = 2, + TriangleStrip = 4, + } + + #[repr(u32)] + pub enum GuState { + AlphaTest = 0, + DepthTest = 1, + ScissorTest = 2, + StencilTest = 3, + Blend = 4, + CullFace = 5, + Dither = 6, + Fog = 7, + ClipPlanes = 8, + Texture2D = 9, + Lighting = 10, + Light0 = 11, + Light1 = 12, + Light2 = 13, + Light3 = 14, + LineSmooth = 15, + PatchCullFace = 16, + ColorTest = 17, + ColorLogicOp = 18, + FaceNormalReverse = 19, + PatchFace = 20, + Fragment2X = 21, + } + + #[repr(u32)] + pub enum MatrixMode { + Projection = 0, + View = 1, + Model = 2, + Texture = 3, + } + + #[repr(u32)] + pub enum TexturePixelFormat { + Psm5650 = 0, + Psm5551 = 1, + Psm4444 = 2, + Psm8888 = 3, + PsmT4 = 4, + PsmT8 = 5, + PsmT16 = 6, + PsmT32 = 7, + PsmDxt1 = 8, + PsmDxt3 = 9, + PsmDxt5 = 10, + } + + #[repr(u32)] + pub enum SplineMode { + FillFill = 0, + OpenFill = 1, + FillOpen = 2, + OpenOpen = 3, + } + + #[repr(u32)] + pub enum ShadingModel { + Flat = 0, + Smooth = 1, + } + + #[repr(u32)] + pub enum LogicalOperation { + Clear = 0, + And = 1, + AndReverse = 2, + Copy = 3, + AndInverted = 4, + Noop = 5, + Xor = 6, + Or = 7, + Nor = 8, + Equiv = 9, + Inverted = 10, + OrReverse = 11, + CopyInverted = 12, + OrInverted = 13, + Nand = 14, + Set = 15, + } + + #[repr(u32)] + pub enum TextureFilter { + Nearest = 0, + Linear = 1, + NearestMipmapNearest = 4, + LinearMipmapNearest = 5, + NearestMipmapLinear = 6, + LinearMipmapLinear = 7, + } + + #[repr(u32)] + pub enum TextureMapMode { + TextureCoords = 0, + TextureMatrix = 1, + EnvironmentMap = 2, + } + + #[repr(u32)] + pub enum TextureLevelMode { + Auto = 0, + Const = 1, + Slope = 2, + } + + #[repr(u32)] + pub enum TextureProjectionMapMode { + Position = 0, + Uv = 1, + NormalizedNormal = 2, + Normal = 3, + } + + #[repr(u32)] + pub enum GuTexWrapMode { + Repeat = 0, + Clamp = 1, + } + + #[repr(u32)] + pub enum FrontFaceDirection { + Clockwise = 0, + CounterClockwise = 1, + } + + #[repr(u32)] + pub enum AlphaFunc { + Never = 0, + Always, + Equal, + NotEqual, + Less, + LessOrEqual, + Greater, + GreaterOrEqual, + } + + #[repr(u32)] + pub enum StencilFunc { + Never = 0, + Always, + Equal, + NotEqual, + Less, + LessOrEqual, + Greater, + GreaterOrEqual, + } + + #[repr(u32)] + pub enum ColorFunc { + Never = 0, + Always, + Equal, + NotEqual, + } + + #[repr(u32)] + pub enum DepthFunc { + Never = 0, + Always, + Equal, + NotEqual, + Less, + LessOrEqual, + Greater, + GreaterOrEqual, + } + + #[repr(u32)] + pub enum TextureEffect { + Modulate = 0, + Decal = 1, + Blend = 2, + Replace = 3, + Add = 4, + } + + #[repr(u32)] + pub enum TextureColorComponent { + Rgb = 0, + Rgba = 1, + } + + #[repr(u32)] + pub enum MipmapLevel { + None = 0, + Level1, + Level2, + Level3, + Level4, + Level5, + Level6, + Level7, + } + + #[repr(u32)] + pub enum BlendOp { + Add = 0, + Subtract = 1, + ReverseSubtract = 2, + Min = 3, + Max = 4, + Abs = 5, + } + + #[repr(u32)] + pub enum BlendSrc { + SrcColor = 0, + OneMinusSrcColor = 1, + SrcAlpha = 2, + OneMinusSrcAlpha = 3, + Fix = 10, + } + + #[repr(u32)] + pub enum BlendDst { + DstColor = 0, + OneMinusDstColor = 1, + DstAlpha = 4, + OneMinusDstAlpha = 5, + Fix = 10, + } + + #[repr(u32)] + pub enum StencilOperation { + Keep = 0, + Zero = 1, + Replace = 2, + Invert = 3, + Incr = 4, + Decr = 5, + } + + #[repr(u32)] + pub enum LightMode { + SingleColor = 0, + SeparateSpecularColor = 1, + } + + #[repr(u32)] + pub enum LightType { + Directional = 0, + Pointlight = 1, + Spotlight = 2, + } + + #[repr(u32)] + pub enum GuContextType { + Direct = 0, + Call = 1, + Send = 2, + } + + #[repr(u32)] + pub enum GuQueueMode { + Tail = 0, + Head = 1, + } + + #[repr(u32)] + pub enum GuSyncMode { + Finish = 0, + Signal = 1, + Done = 2, + List = 3, + Send = 4, + } + + #[repr(u32)] + pub enum GuSyncBehavior { + Wait = 0, + NoWait = 1, + } + + #[repr(u32)] + pub enum GuCallbackId { + Signal = 1, + Finish = 4, + } + + #[repr(u32)] + pub enum SignalBehavior { + Suspend = 1, + Continue = 2, + } + + #[repr(u32)] + pub enum ClutPixelFormat { + Psm5650 = 0, + Psm5551 = 1, + Psm4444 = 2, + Psm8888 = 3, + } + + #[repr(C)] + pub enum KeyType { + Directory = 1, + Integer = 2, + String = 3, + Bytes = 4, + } + + #[repr(u32)] + pub enum UtilityMsgDialogMode { + Error, + Text, + } + + #[repr(u32)] + pub enum UtilityMsgDialogPressed { + Unknown1, + Yes, + No, + Back, + } + + #[repr(u32)] + pub enum UtilityDialogButtonAccept { + Circle, + Cross, + } + + #[repr(u32)] + pub enum SceUtilityOskInputLanguage { + Default, + Japanese, + English, + French, + Spanish, + German, + Italian, + Dutch, + Portugese, + Russian, + Korean, + } + + #[repr(u32)] + pub enum SceUtilityOskInputType { + All, + LatinDigit, + LatinSymbol, + LatinLowercase = 4, + LatinUppercase = 8, + JapaneseDigit = 0x100, + JapaneseSymbol = 0x200, + JapaneseLowercase = 0x400, + JapaneseUppercase = 0x800, + JapaneseHiragana = 0x1000, + JapaneseHalfWidthKatakana = 0x2000, + JapaneseKatakana = 0x4000, + JapaneseKanji = 0x8000, + RussianLowercase = 0x10000, + RussianUppercase = 0x20000, + Korean = 0x40000, + Url = 0x80000, + } + + #[repr(u32)] + pub enum SceUtilityOskState { + None, + Initializing, + Initialized, + Visible, + Quit, + Finished, + } + + #[repr(u32)] + pub enum SceUtilityOskResult { + Unchanged, + Cancelled, + Changed, + } + + #[repr(u32)] + pub enum SystemParamLanguage { + Japanese, + English, + French, + Spanish, + German, + Italian, + Dutch, + Portugese, + Russian, + Korean, + ChineseTraditional, + ChineseSimplified, + } + + #[repr(u32)] + pub enum SystemParamId { + StringNickname = 1, + AdhocChannel, + WlanPowerSave, + DateFormat, + TimeFormat, + Timezone, + DaylightSavings, + Language, + Unknown, + } + + #[repr(u32)] + pub enum SystemParamAdhocChannel { + ChannelAutomatic = 0, + Channel1 = 1, + Channel6 = 6, + Channel11 = 11, + } + + #[repr(u32)] + pub enum SystemParamWlanPowerSaveState { + Off, + On, + } + + #[repr(u32)] + pub enum SystemParamDateFormat { + YYYYMMDD, + MMDDYYYY, + DDMMYYYY, + } + + #[repr(u32)] + pub enum SystemParamTimeFormat { + Hour24, + Hour12, + } + + #[repr(u32)] + pub enum SystemParamDaylightSavings { + Std, + Dst, + } + + #[repr(u32)] + pub enum AvModule { + AvCodec, + SasCore, + Atrac3Plus, + MpegBase, + Mp3, + Vaudio, + Aac, + G729, + } + + #[repr(u32)] + pub enum Module { + NetCommon = 0x100, + NetAdhoc, + NetInet, + NetParseUri, + NetHttp, + NetSsl, + + UsbPspCm = 0x200, + UsbMic, + UsbCam, + UsbGps, + + AvCodec = 0x300, + AvSascore, + AvAtrac3Plus, + AvMpegBase, + AvMp3, + AvVaudio, + AvAac, + AvG729, + + NpCommon = 0x400, + NpService, + NpMatching2, + NpDrm = 0x500, + + Irda = 0x600, + } + + #[repr(u32)] + pub enum NetModule { + NetCommon = 1, + NetAdhoc, + NetInet, + NetParseUri, + NetHttp, + NetSsl, + } + + #[repr(u32)] + pub enum UsbModule { + UsbPspCm = 1, + UsbAcc, + UsbMic, + UsbCam, + UsbGps, + } + + #[repr(u32)] + pub enum NetParam { + Name, + Ssid, + Secure, + WepKey, + IsStaticIp, + Ip, + NetMask, + Route, + ManualDns, + PrimaryDns, + SecondaryDns, + ProxyUser, + ProxyPass, + UseProxy, + ProxyServer, + ProxyPort, + Unknown1, + Unknown2, + } + + #[repr(u32)] + pub enum UtilityNetconfAction { + ConnectAP, + DisplayStatus, + ConnectAdhoc, + } + + #[repr(u32)] + pub enum UtilitySavedataMode { + AutoLoad, + AutoSave, + Load, + Save, + ListLoad, + ListSave, + ListDelete, + Delete, + } + + #[repr(u32)] + pub enum UtilitySavedataFocus { + Unknown1, + FirstList, + LastList, + Latest, + Oldest, + Unknown2, + Unknown3, + FirstEmpty, + LastEmpty, + } + + #[repr(u32)] + pub enum UtilityGameSharingMode { + Single = 1, + Multiple, + } + + #[repr(u32)] + pub enum UtilityGameSharingDataType { + File = 1, + Memory, + } + + #[repr(u32)] + pub enum UtilityHtmlViewerInterfaceMode { + Full, + Limited, + None, + } + + #[repr(u32)] + pub enum UtilityHtmlViewerCookieMode { + Disabled = 0, + Enabled, + Confirm, + Default, + } + + #[repr(u32)] + pub enum UtilityHtmlViewerTextSize { + Large, + Normal, + Small, + } + + #[repr(u32)] + pub enum UtilityHtmlViewerDisplayMode { + Normal, + Fit, + SmartFit, + } + + #[repr(u32)] + pub enum UtilityHtmlViewerConnectMode { + Last, + ManualOnce, + ManualAll, + } + + #[repr(u32)] + pub enum UtilityHtmlViewerDisconnectMode { + Enable, + Disable, + Confirm, + } + + #[repr(u32)] + pub enum ScePspnetAdhocPtpState { + Closed, + Listen, + SynSent, + SynReceived, + Established, + } + + #[repr(u32)] + pub enum AdhocMatchingMode { + Host = 1, + Client, + Ptp, + } + + #[repr(u32)] + pub enum ApctlState { + Disconnected, + Scanning, + Joining, + GettingIp, + GotIp, + EapAuth, + KeyExchange, + } + + #[repr(u32)] + pub enum ApctlEvent { + ConnectRequest, + ScanRequest, + ScanComplete, + Established, + GetIp, + DisconnectRequest, + Error, + Info, + EapAuth, + KeyExchange, + Reconnect, + } + + #[repr(u32)] + pub enum ApctlInfo { + ProfileName, + Bssid, + Ssid, + SsidLength, + SecurityType, + Strength, + Channel, + PowerSave, + Ip, + SubnetMask, + Gateway, + PrimaryDns, + SecondaryDns, + UseProxy, + ProxyUrl, + ProxyPort, + EapType, + StartBrowser, + Wifisp, + } + + #[repr(u32)] + pub enum ApctlInfoSecurityType { + None, + Wep, + Wpa, + } + + #[repr(u32)] + pub enum HttpMethod { + Get, + Post, + Head, + } + + #[repr(u32)] + pub enum HttpAuthType { + Basic, + Digest, + } +} + +s_paren! { + #[repr(transparent)] + pub struct SceUid(pub i32); + + #[repr(transparent)] + #[allow(dead_code)] + pub struct SceMpeg(*mut *mut c_void); + + #[repr(transparent)] + #[allow(dead_code)] + pub struct SceMpegStream(*mut c_void); + + #[repr(transparent)] + pub struct Mp3Handle(pub i32); + + #[repr(transparent)] + #[allow(dead_code)] + pub struct RegHandle(u32); +} + +s! { + pub struct sockaddr { + pub sa_len: u8, + pub sa_family: u8, + pub sa_data: [u8; 14], + } + + pub struct in_addr { + pub s_addr: u32, + } + + pub struct AudioInputParams { + pub unknown1: i32, + pub gain: i32, + pub unknown2: i32, + pub unknown3: i32, + pub unknown4: i32, + pub unknown5: i32, + } + + pub struct Atrac3BufferInfo { + pub puc_write_position_first_buf: *mut u8, + pub ui_writable_byte_first_buf: u32, + pub ui_min_write_byte_first_buf: u32, + pub ui_read_position_first_buf: u32, + pub puc_write_position_second_buf: *mut u8, + pub ui_writable_byte_second_buf: u32, + pub ui_min_write_byte_second_buf: u32, + pub ui_read_position_second_buf: u32, + } + + pub struct SceCtrlData { + pub timestamp: u32, + pub buttons: i32, + pub lx: u8, + pub ly: u8, + pub rsrv: [u8; 6], + } + + pub struct SceCtrlLatch { + pub ui_make: u32, + pub ui_break: u32, + pub ui_press: u32, + pub ui_release: u32, + } + + pub struct GeStack { + pub stack: [u32; 8], + } + + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct GeCallbackData { + pub signal_func: Option, + pub signal_arg: *mut c_void, + pub finish_func: Option, + pub finish_arg: *mut c_void, + } + + pub struct GeListArgs { + pub size: u32, + pub context: *mut GeContext, + pub num_stacks: u32, + pub stacks: *mut GeStack, + } + + pub struct GeBreakParam { + pub buf: [u32; 4], + } + + pub struct SceKernelLoadExecParam { + pub size: usize, + pub args: usize, + pub argp: *mut c_void, + pub key: *const u8, + } + + pub struct timeval { + pub tv_sec: i32, + pub tv_usec: i32, + } + + pub struct timezone { + pub tz_minutes_west: i32, + pub tz_dst_time: i32, + } + + pub struct IntrHandlerOptionParam { + size: i32, + entry: u32, + common: u32, + gp: u32, + intr_code: u16, + sub_count: u16, + intr_level: u16, + enabled: u16, + calls: u32, + field_1c: u32, + total_clock_lo: u32, + total_clock_hi: u32, + min_clock_lo: u32, + min_clock_hi: u32, + max_clock_lo: u32, + max_clock_hi: u32, + } + + pub struct SceKernelLMOption { + pub size: usize, + pub m_pid_text: SceUid, + pub m_pid_data: SceUid, + pub flags: u32, + pub position: u8, + pub access: u8, + pub c_reserved: [u8; 2usize], + } + + pub struct SceKernelSMOption { + pub size: usize, + pub m_pid_stack: SceUid, + pub stack_size: usize, + pub priority: i32, + pub attribute: u32, + } + + pub struct SceKernelModuleInfo { + pub size: usize, + pub n_segment: u8, + pub reserved: [u8; 3usize], + pub segment_addr: [i32; 4usize], + pub segment_size: [i32; 4usize], + pub entry_addr: u32, + pub gp_value: u32, + pub text_addr: u32, + pub text_size: u32, + pub data_size: u32, + pub bss_size: u32, + pub attribute: u16, + pub version: [u8; 2usize], + pub name: [u8; 28usize], + } + + pub struct DebugProfilerRegs { + pub enable: u32, + pub systemck: u32, + pub cpuck: u32, + pub internal: u32, + pub memory: u32, + pub copz: u32, + pub vfpu: u32, + pub sleep: u32, + pub bus_access: u32, + pub uncached_load: u32, + pub uncached_store: u32, + pub cached_load: u32, + pub cached_store: u32, + pub i_miss: u32, + pub d_miss: u32, + pub d_writeback: u32, + pub cop0_inst: u32, + pub fpu_inst: u32, + pub vfpu_inst: u32, + pub local_bus: u32, + } + + pub struct SceKernelSysClock { + pub low: u32, + pub hi: u32, + } + + pub struct SceKernelThreadOptParam { + pub size: usize, + pub stack_mpid: SceUid, + } + + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct SceKernelThreadInfo { + pub size: usize, + pub name: [u8; 32], + pub attr: u32, + pub status: i32, + pub entry: SceKernelThreadEntry, + pub stack: *mut c_void, + pub stack_size: i32, + pub gp_reg: *mut c_void, + pub init_priority: i32, + pub current_priority: i32, + pub wait_type: i32, + pub wait_id: SceUid, + pub wakeup_count: i32, + pub exit_status: i32, + pub run_clocks: SceKernelSysClock, + pub intr_preempt_count: u32, + pub thread_preempt_count: u32, + pub release_count: u32, + } + + pub struct SceKernelThreadRunStatus { + pub size: usize, + pub status: i32, + pub current_priority: i32, + pub wait_type: i32, + pub wait_id: i32, + pub wakeup_count: i32, + pub run_clocks: SceKernelSysClock, + pub intr_preempt_count: u32, + pub thread_preempt_count: u32, + pub release_count: u32, + } + + pub struct SceKernelSemaOptParam { + pub size: usize, + } + + pub struct SceKernelSemaInfo { + pub size: usize, + pub name: [u8; 32], + pub attr: u32, + pub init_count: i32, + pub current_count: i32, + pub max_count: i32, + pub num_wait_threads: i32, + } + + pub struct SceKernelEventFlagInfo { + pub size: usize, + pub name: [u8; 32], + pub attr: u32, + pub init_pattern: u32, + pub current_pattern: u32, + pub num_wait_threads: i32, + } + + pub struct SceKernelEventFlagOptParam { + pub size: usize, + } + + pub struct SceKernelMbxOptParam { + pub size: usize, + } + + pub struct SceKernelMbxInfo { + pub size: usize, + pub name: [u8; 32usize], + pub attr: u32, + pub num_wait_threads: i32, + pub num_messages: i32, + pub first_message: *mut c_void, + } + + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct SceKernelVTimerInfo { + pub size: usize, + pub name: [u8; 32], + pub active: i32, + pub base: SceKernelSysClock, + pub current: SceKernelSysClock, + pub schedule: SceKernelSysClock, + pub handler: SceKernelVTimerHandler, + pub common: *mut c_void, + } + + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct SceKernelThreadEventHandlerInfo { + pub size: usize, + pub name: [u8; 32], + pub thread_id: SceUid, + pub mask: i32, + pub handler: SceKernelThreadEventHandler, + pub common: *mut c_void, + } + + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct SceKernelAlarmInfo { + pub size: usize, + pub schedule: SceKernelSysClock, + pub handler: SceKernelAlarmHandler, + pub common: *mut c_void, + } + + pub struct SceKernelSystemStatus { + pub size: usize, + pub status: u32, + pub idle_clocks: SceKernelSysClock, + pub comes_out_of_idle_count: u32, + pub thread_switch_count: u32, + pub vfpu_switch_count: u32, + } + + pub struct SceKernelMppInfo { + pub size: usize, + pub name: [u8; 32], + pub attr: u32, + pub buf_size: i32, + pub free_size: i32, + pub num_send_wait_threads: i32, + pub num_receive_wait_threads: i32, + } + + pub struct SceKernelVplOptParam { + pub size: usize, + } + + pub struct SceKernelVplInfo { + pub size: usize, + pub name: [u8; 32], + pub attr: u32, + pub pool_size: i32, + pub free_size: i32, + pub num_wait_threads: i32, + } + + pub struct SceKernelFplOptParam { + pub size: usize, + } + + pub struct SceKernelFplInfo { + pub size: usize, + pub name: [u8; 32usize], + pub attr: u32, + pub block_size: i32, + pub num_blocks: i32, + pub free_blocks: i32, + pub num_wait_threads: i32, + } + + pub struct SceKernelVTimerOptParam { + pub size: usize, + } + + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct SceKernelCallbackInfo { + pub size: usize, + pub name: [u8; 32usize], + pub thread_id: SceUid, + pub callback: SceKernelCallbackFunction, + pub common: *mut c_void, + pub notify_count: i32, + pub notify_arg: i32, + } + + pub struct UsbCamSetupStillParam { + pub size: i32, + pub resolution: UsbCamResolution, + pub jpeg_size: i32, + pub reverse_flags: i32, + pub delay: UsbCamDelay, + pub comp_level: i32, + } + + pub struct UsbCamSetupStillExParam { + pub size: i32, + pub unk: u32, + pub resolution: UsbCamResolutionEx, + pub jpeg_size: i32, + pub comp_level: i32, + pub unk2: u32, + pub unk3: u32, + pub flip: i32, + pub mirror: i32, + pub delay: UsbCamDelay, + pub unk4: [u32; 5usize], + } + + pub struct UsbCamSetupVideoParam { + pub size: i32, + pub resolution: UsbCamResolution, + pub framerate: UsbCamFrameRate, + pub white_balance: UsbCamWb, + pub saturation: i32, + pub brightness: i32, + pub contrast: i32, + pub sharpness: i32, + pub effect_mode: UsbCamEffectMode, + pub frame_size: i32, + pub unk: u32, + pub evl_evel: UsbCamEvLevel, + } + + pub struct UsbCamSetupVideoExParam { + pub size: i32, + pub unk: u32, + pub resolution: UsbCamResolutionEx, + pub framerate: UsbCamFrameRate, + pub unk2: u32, + pub unk3: u32, + pub white_balance: UsbCamWb, + pub saturation: i32, + pub brightness: i32, + pub contrast: i32, + pub sharpness: i32, + pub unk4: u32, + pub unk5: u32, + pub unk6: [u32; 3usize], + pub effect_mode: UsbCamEffectMode, + pub unk7: u32, + pub unk8: u32, + pub unk9: u32, + pub unk10: u32, + pub unk11: u32, + pub frame_size: i32, + pub unk12: u32, + pub ev_level: UsbCamEvLevel, + } + + pub struct ScePspDateTime { + pub year: u16, + pub month: u16, + pub day: u16, + pub hour: u16, + pub minutes: u16, + pub seconds: u16, + pub microseconds: u32, + } + + pub struct SceIoStat { + pub st_mode: i32, + pub st_attr: i32, + pub st_size: i64, + pub st_ctime: ScePspDateTime, + pub st_atime: ScePspDateTime, + pub st_mtime: ScePspDateTime, + pub st_private: [u32; 6usize], + } + + pub struct UmdInfo { + pub size: u32, + pub type_: UmdType, + } + + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct SceMpegRingbuffer { + pub packets: i32, + pub unk0: u32, + pub unk1: u32, + pub unk2: u32, + pub unk3: u32, + pub data: *mut c_void, + pub callback: SceMpegRingbufferCb, + pub cb_param: *mut c_void, + pub unk4: u32, + pub unk5: u32, + pub sce_mpeg: *mut c_void, + } + + pub struct SceMpegAu { + pub pts_msb: u32, + pub pts: u32, + pub dts_msb: u32, + pub dts: u32, + pub es_buffer: u32, + pub au_size: u32, + } + + pub struct SceMpegAvcMode { + pub unk0: i32, + pub pixel_format: super::DisplayPixelFormat, + } + + #[repr(align(64))] + pub struct SceMpegLLI { + pub src: *mut c_void, + pub dst: *mut c_void, + pub next: *mut c_void, + pub size: i32, + } + + #[repr(align(64))] + pub struct SceMpegYCrCbBuffer { + pub frame_buffer_height16: i32, + pub frame_buffer_width16: i32, + pub unknown: i32, + pub unknown2: i32, + pub y_buffer: *mut c_void, + pub y_buffer2: *mut c_void, + pub cr_buffer: *mut c_void, + pub cb_buffer: *mut c_void, + pub cr_buffer2: *mut c_void, + pub cb_buffer2: *mut c_void, + + pub frame_height: i32, + pub frame_width: i32, + pub frame_buffer_width: i32, + pub unknown3: [i32; 11usize], + } + + pub struct ScePspSRect { + pub x: i16, + pub y: i16, + pub w: i16, + pub h: i16, + } + + pub struct ScePspIRect { + pub x: i32, + pub y: i32, + pub w: i32, + pub h: i32, + } + + pub struct ScePspL64Rect { + pub x: u64, + pub y: u64, + pub w: u64, + pub h: u64, + } + + pub struct ScePspSVector2 { + pub x: i16, + pub y: i16, + } + + pub struct ScePspIVector2 { + pub x: i32, + pub y: i32, + } + + pub struct ScePspL64Vector2 { + pub x: u64, + pub y: u64, + } + + pub struct ScePspSVector3 { + pub x: i16, + pub y: i16, + pub z: i16, + } + + pub struct ScePspIVector3 { + pub x: i32, + pub y: i32, + pub z: i32, + } + + pub struct ScePspL64Vector3 { + pub x: u64, + pub y: u64, + pub z: u64, + } + + pub struct ScePspSVector4 { + pub x: i16, + pub y: i16, + pub z: i16, + pub w: i16, + } + + pub struct ScePspIVector4 { + pub x: i32, + pub y: i32, + pub z: i32, + pub w: i32, + } + + pub struct ScePspL64Vector4 { + pub x: u64, + pub y: u64, + pub z: u64, + pub w: u64, + } + + pub struct ScePspIMatrix2 { + pub x: ScePspIVector2, + pub y: ScePspIVector2, + } + + pub struct ScePspIMatrix3 { + pub x: ScePspIVector3, + pub y: ScePspIVector3, + pub z: ScePspIVector3, + } + + #[repr(align(16))] + pub struct ScePspIMatrix4 { + pub x: ScePspIVector4, + pub y: ScePspIVector4, + pub z: ScePspIVector4, + pub w: ScePspIVector4, + } + + pub struct ScePspIMatrix4Unaligned { + pub x: ScePspIVector4, + pub y: ScePspIVector4, + pub z: ScePspIVector4, + pub w: ScePspIVector4, + } + + pub struct SceMp3InitArg { + pub mp3_stream_start: u32, + pub unk1: u32, + pub mp3_stream_end: u32, + pub unk2: u32, + pub mp3_buf: *mut c_void, + pub mp3_buf_size: i32, + pub pcm_buf: *mut c_void, + pub pcm_buf_size: i32, + } + + pub struct OpenPSID { + pub data: [u8; 16usize], + } + + pub struct UtilityDialogCommon { + pub size: u32, + pub language: SystemParamLanguage, + pub button_accept: UtilityDialogButtonAccept, + pub graphics_thread: i32, + pub access_thread: i32, + pub font_thread: i32, + pub sound_thread: i32, + pub result: i32, + pub reserved: [i32; 4usize], + } + + pub struct UtilityNetconfAdhoc { + pub name: [u8; 8usize], + pub timeout: u32, + } + + pub struct UtilityNetconfData { + pub base: UtilityDialogCommon, + pub action: UtilityNetconfAction, + pub adhocparam: *mut UtilityNetconfAdhoc, + pub hotspot: i32, + pub hotspot_connected: i32, + pub wifisp: i32, + } + + pub struct UtilitySavedataFileData { + pub buf: *mut c_void, + pub buf_size: usize, + pub size: usize, + pub unknown: i32, + } + + pub struct UtilitySavedataListSaveNewData { + pub icon0: UtilitySavedataFileData, + pub title: *mut u8, + } + + pub struct UtilityGameSharingParams { + pub base: UtilityDialogCommon, + pub unknown1: i32, + pub unknown2: i32, + pub name: [u8; 8usize], + pub unknown3: i32, + pub unknown4: i32, + pub unknown5: i32, + pub result: i32, + pub filepath: *mut u8, + pub mode: UtilityGameSharingMode, + pub datatype: UtilityGameSharingDataType, + pub data: *mut c_void, + pub datasize: u32, + } + + pub struct UtilityHtmlViewerParam { + pub base: UtilityDialogCommon, + pub memaddr: *mut c_void, + pub memsize: u32, + pub unknown1: i32, + pub unknown2: i32, + pub initialurl: *mut u8, + pub numtabs: u32, + pub interfacemode: UtilityHtmlViewerInterfaceMode, + pub options: i32, + pub dldirname: *mut u8, + pub dlfilename: *mut u8, + pub uldirname: *mut u8, + pub ulfilename: *mut u8, + pub cookiemode: UtilityHtmlViewerCookieMode, + pub unknown3: u32, + pub homeurl: *mut u8, + pub textsize: UtilityHtmlViewerTextSize, + pub displaymode: UtilityHtmlViewerDisplayMode, + pub connectmode: UtilityHtmlViewerConnectMode, + pub disconnectmode: UtilityHtmlViewerDisconnectMode, + pub memused: u32, + pub unknown4: [i32; 10usize], + } + + pub struct SceUtilityOskData { + pub unk_00: i32, + pub unk_04: i32, + pub language: SceUtilityOskInputLanguage, + pub unk_12: i32, + pub inputtype: SceUtilityOskInputType, + pub lines: i32, + pub unk_24: i32, + pub desc: *mut u16, + pub intext: *mut u16, + pub outtextlength: i32, + pub outtext: *mut u16, + pub result: SceUtilityOskResult, + pub outtextlimit: i32, + } + + pub struct SceUtilityOskParams { + pub base: UtilityDialogCommon, + pub datacount: i32, + pub data: *mut SceUtilityOskData, + pub state: SceUtilityOskState, + pub unk_60: i32, + } + + pub struct SceNetMallocStat { + pub pool: i32, + pub maximum: i32, + pub free: i32, + } + + pub struct SceNetAdhocctlAdhocId { + pub unknown: i32, + pub adhoc_id: [u8; 9usize], + pub unk: [u8; 3usize], + } + + pub struct SceNetAdhocctlScanInfo { + pub next: *mut SceNetAdhocctlScanInfo, + pub channel: i32, + pub name: [u8; 8usize], + pub bssid: [u8; 6usize], + pub unknown: [u8; 2usize], + pub unknown2: i32, + } + + pub struct SceNetAdhocctlGameModeInfo { + pub count: i32, + pub macs: [[u8; 6usize]; 16usize], + } + + pub struct SceNetAdhocPtpStat { + pub next: *mut SceNetAdhocPtpStat, + pub ptp_id: i32, + pub mac: [u8; 6usize], + pub peermac: [u8; 6usize], + pub port: u16, + pub peerport: u16, + pub sent_data: u32, + pub rcvd_data: u32, + pub state: ScePspnetAdhocPtpState, + } + + pub struct SceNetAdhocPdpStat { + pub next: *mut SceNetAdhocPdpStat, + pub pdp_id: i32, + pub mac: [u8; 6usize], + pub port: u16, + pub rcvd_data: u32, + } + + pub struct AdhocPoolStat { + pub size: i32, + pub maxsize: i32, + pub freesize: i32, + } +} + +s_no_extra_traits! { + pub struct GeContext { + pub context: [u32; 512], + } + + pub struct SceKernelUtilsSha1Context { + pub h: [u32; 5usize], + pub us_remains: u16, + pub us_computed: u16, + pub ull_total_len: u64, + pub buf: [u8; 64usize], + } + + pub struct SceKernelUtilsMt19937Context { + pub count: u32, + pub state: [u32; 624usize], + } + + pub struct SceKernelUtilsMd5Context { + pub h: [u32; 4usize], + pub pad: u32, + pub us_remains: u16, + pub us_computed: u16, + pub ull_total_len: u64, + pub buf: [u8; 64usize], + } + + pub struct SceIoDirent { + pub d_stat: SceIoStat, + pub d_name: [u8; 256usize], + pub d_private: *mut c_void, + pub dummy: i32, + } + + pub struct ScePspFRect { + pub x: f32, + pub y: f32, + pub w: f32, + pub h: f32, + } + + #[repr(align(16))] + pub struct ScePspFVector3 { + pub x: f32, + pub y: f32, + pub z: f32, + } + + #[repr(align(16))] + pub struct ScePspFVector4 { + pub x: f32, + pub y: f32, + pub z: f32, + pub w: f32, + } + + pub struct ScePspFVector4Unaligned { + pub x: f32, + pub y: f32, + pub z: f32, + pub w: f32, + } + + pub struct ScePspFVector2 { + pub x: f32, + pub y: f32, + } + + pub struct ScePspFMatrix2 { + pub x: ScePspFVector2, + pub y: ScePspFVector2, + } + + pub struct ScePspFMatrix3 { + pub x: ScePspFVector3, + pub y: ScePspFVector3, + pub z: ScePspFVector3, + } + + #[repr(align(16))] + pub struct ScePspFMatrix4 { + pub x: ScePspFVector4, + pub y: ScePspFVector4, + pub z: ScePspFVector4, + pub w: ScePspFVector4, + } + + pub struct ScePspFMatrix4Unaligned { + pub x: ScePspFVector4, + pub y: ScePspFVector4, + pub z: ScePspFVector4, + pub w: ScePspFVector4, + } + + pub union ScePspVector3 { + pub fv: ScePspFVector3, + pub iv: ScePspIVector3, + pub f: [f32; 3usize], + pub i: [i32; 3usize], + } + + pub union ScePspVector4 { + pub fv: ScePspFVector4, + pub iv: ScePspIVector4, + pub qw: u128, + pub f: [f32; 4usize], + pub i: [i32; 4usize], + } + + pub union ScePspMatrix2 { + pub fm: ScePspFMatrix2, + pub im: ScePspIMatrix2, + pub fv: [ScePspFVector2; 2usize], + pub iv: [ScePspIVector2; 2usize], + pub v: [ScePspVector2; 2usize], + pub f: [[f32; 2usize]; 2usize], + pub i: [[i32; 2usize]; 2usize], + } + + pub union ScePspMatrix3 { + pub fm: ScePspFMatrix3, + pub im: ScePspIMatrix3, + pub fv: [ScePspFVector3; 3usize], + pub iv: [ScePspIVector3; 3usize], + pub v: [ScePspVector3; 3usize], + pub f: [[f32; 3usize]; 3usize], + pub i: [[i32; 3usize]; 3usize], + } + + pub union ScePspVector2 { + pub fv: ScePspFVector2, + pub iv: ScePspIVector2, + pub f: [f32; 2usize], + pub i: [i32; 2usize], + } + + pub union ScePspMatrix4 { + pub fm: ScePspFMatrix4, + pub im: ScePspIMatrix4, + pub fv: [ScePspFVector4; 4usize], + pub iv: [ScePspIVector4; 4usize], + pub v: [ScePspVector4; 4usize], + pub f: [[f32; 4usize]; 4usize], + pub i: [[i32; 4usize]; 4usize], + } + + pub struct Key { + pub key_type: KeyType, + pub name: [u8; 256usize], + pub name_len: u32, + pub unk2: u32, + pub unk3: u32, + } + + pub struct UtilityMsgDialogParams { + pub base: UtilityDialogCommon, + pub unknown: i32, + pub mode: UtilityMsgDialogMode, + pub error_value: u32, + pub message: [u8; 512usize], + pub options: i32, + pub button_pressed: UtilityMsgDialogPressed, + } + + pub union UtilityNetData { + pub as_uint: u32, + pub as_string: [u8; 128usize], + } + + pub struct UtilitySavedataSFOParam { + pub title: [u8; 128usize], + pub savedata_title: [u8; 128usize], + pub detail: [u8; 1024usize], + pub parental_level: u8, + pub unknown: [u8; 3usize], + } + + pub struct SceUtilitySavedataParam { + pub base: UtilityDialogCommon, + pub mode: UtilitySavedataMode, + pub unknown1: i32, + pub overwrite: i32, + pub game_name: [u8; 13usize], + pub reserved: [u8; 3usize], + pub save_name: [u8; 20usize], + pub save_name_list: *mut [u8; 20usize], + pub file_name: [u8; 13usize], + pub reserved1: [u8; 3usize], + pub data_buf: *mut c_void, + pub data_buf_size: usize, + pub data_size: usize, + pub sfo_param: UtilitySavedataSFOParam, + pub icon0_file_data: UtilitySavedataFileData, + pub icon1_file_data: UtilitySavedataFileData, + pub pic1_file_data: UtilitySavedataFileData, + pub snd0_file_data: UtilitySavedataFileData, + pub new_data: *mut UtilitySavedataListSaveNewData, + pub focus: UtilitySavedataFocus, + pub unknown2: [i32; 4usize], + pub key: [u8; 16], + pub unknown3: [u8; 20], + } + + pub struct SceNetAdhocctlPeerInfo { + pub next: *mut SceNetAdhocctlPeerInfo, + pub nickname: [u8; 128usize], + pub mac: [u8; 6usize], + pub unknown: [u8; 6usize], + pub timestamp: u32, + } + + pub struct SceNetAdhocctlParams { + pub channel: i32, + pub name: [u8; 8usize], + pub bssid: [u8; 6usize], + pub nickname: [u8; 128usize], + } + + pub union SceNetApctlInfo { + pub name: [u8; 64usize], + pub bssid: [u8; 6usize], + pub ssid: [u8; 32usize], + pub ssid_length: u32, + pub security_type: u32, + pub strength: u8, + pub channel: u8, + pub power_save: u8, + pub ip: [u8; 16usize], + pub sub_net_mask: [u8; 16usize], + pub gateway: [u8; 16usize], + pub primary_dns: [u8; 16usize], + pub secondary_dns: [u8; 16usize], + pub use_proxy: u32, + pub proxy_url: [u8; 128usize], + pub proxy_port: u16, + pub eap_type: u32, + pub start_browser: u32, + pub wifisp: u32, + } +} + +pub const INT_MIN: c_int = -2147483648; +pub const INT_MAX: c_int = 2147483647; + +pub const AUDIO_VOLUME_MAX: u32 = 0x8000; +pub const AUDIO_CHANNEL_MAX: u32 = 8; +pub const AUDIO_NEXT_CHANNEL: i32 = -1; +pub const AUDIO_SAMPLE_MIN: u32 = 64; +pub const AUDIO_SAMPLE_MAX: u32 = 65472; + +pub const PSP_CTRL_SELECT: i32 = 0x000001; +pub const PSP_CTRL_START: i32 = 0x000008; +pub const PSP_CTRL_UP: i32 = 0x000010; +pub const PSP_CTRL_RIGHT: i32 = 0x000020; +pub const PSP_CTRL_DOWN: i32 = 0x000040; +pub const PSP_CTRL_LEFT: i32 = 0x000080; +pub const PSP_CTRL_LTRIGGER: i32 = 0x000100; +pub const PSP_CTRL_RTRIGGER: i32 = 0x000200; +pub const PSP_CTRL_TRIANGLE: i32 = 0x001000; +pub const PSP_CTRL_CIRCLE: i32 = 0x002000; +pub const PSP_CTRL_CROSS: i32 = 0x004000; +pub const PSP_CTRL_SQUARE: i32 = 0x008000; +pub const PSP_CTRL_HOME: i32 = 0x010000; +pub const PSP_CTRL_HOLD: i32 = 0x020000; +pub const PSP_CTRL_NOTE: i32 = 0x800000; +pub const PSP_CTRL_SCREEN: i32 = 0x400000; +pub const PSP_CTRL_VOLUP: i32 = 0x100000; +pub const PSP_CTRL_VOLDOWN: i32 = 0x200000; +pub const PSP_CTRL_WLAN_UP: i32 = 0x040000; +pub const PSP_CTRL_REMOTE: i32 = 0x080000; +pub const PSP_CTRL_DISC: i32 = 0x1000000; +pub const PSP_CTRL_MS: i32 = 0x2000000; + +pub const USB_CAM_PID: i32 = 0x282; +pub const USB_BUS_DRIVER_NAME: &str = "USBBusDriver"; +pub const USB_CAM_DRIVER_NAME: &str = "USBCamDriver"; +pub const USB_CAM_MIC_DRIVER_NAME: &str = "USBCamMicDriver"; +pub const USB_STOR_DRIVER_NAME: &str = "USBStor_Driver"; + +pub const ACTIVATED: i32 = 0x200; +pub const CONNECTED: i32 = 0x020; +pub const ESTABLISHED: i32 = 0x002; + +pub const USB_CAM_FLIP: i32 = 1; +pub const USB_CAM_MIRROR: i32 = 0x100; + +pub const THREAD_ATTR_VFPU: i32 = 0x00004000; +pub const THREAD_ATTR_USER: i32 = 0x80000000; +pub const THREAD_ATTR_USBWLAN: i32 = 0xa0000000; +pub const THREAD_ATTR_VSH: i32 = 0xc0000000; +pub const THREAD_ATTR_SCRATCH_SRAM: i32 = 0x00008000; +pub const THREAD_ATTR_NO_FILLSTACK: i32 = 0x00100000; +pub const THREAD_ATTR_CLEAR_STACK: i32 = 0x00200000; + +pub const EVENT_WAIT_MULTIPLE: i32 = 0x200; + +pub const EVENT_WAIT_AND: i32 = 0; +pub const EVENT_WAIT_OR: i32 = 1; +pub const EVENT_WAIT_CLEAR: i32 = 0x20; + +pub const POWER_INFO_POWER_SWITCH: i32 = 0x80000000; +pub const POWER_INFO_HOLD_SWITCH: i32 = 0x40000000; +pub const POWER_INFO_STANDBY: i32 = 0x00080000; +pub const POWER_INFO_RESUME_COMPLETE: i32 = 0x00040000; +pub const POWER_INFO_RESUMING: i32 = 0x00020000; +pub const POWER_INFO_SUSPENDING: i32 = 0x00010000; +pub const POWER_INFO_AC_POWER: i32 = 0x00001000; +pub const POWER_INFO_BATTERY_LOW: i32 = 0x00000100; +pub const POWER_INFO_BATTERY_EXIST: i32 = 0x00000080; +pub const POWER_INFO_BATTERY_POWER: i32 = 0x0000007; + +pub const FIO_S_IFLNK: i32 = 0x4000; +pub const FIO_S_IFDIR: i32 = 0x1000; +pub const FIO_S_IFREG: i32 = 0x2000; +pub const FIO_S_ISUID: i32 = 0x0800; +pub const FIO_S_ISGID: i32 = 0x0400; +pub const FIO_S_ISVTX: i32 = 0x0200; +pub const FIO_S_IRUSR: i32 = 0x0100; +pub const FIO_S_IWUSR: i32 = 0x0080; +pub const FIO_S_IXUSR: i32 = 0x0040; +pub const FIO_S_IRGRP: i32 = 0x0020; +pub const FIO_S_IWGRP: i32 = 0x0010; +pub const FIO_S_IXGRP: i32 = 0x0008; +pub const FIO_S_IROTH: i32 = 0x0004; +pub const FIO_S_IWOTH: i32 = 0x0002; +pub const FIO_S_IXOTH: i32 = 0x0001; + +pub const FIO_SO_IFLNK: i32 = 0x0008; +pub const FIO_SO_IFDIR: i32 = 0x0010; +pub const FIO_SO_IFREG: i32 = 0x0020; +pub const FIO_SO_IROTH: i32 = 0x0004; +pub const FIO_SO_IWOTH: i32 = 0x0002; +pub const FIO_SO_IXOTH: i32 = 0x0001; + +pub const PSP_O_RD_ONLY: i32 = 0x0001; +pub const PSP_O_WR_ONLY: i32 = 0x0002; +pub const PSP_O_RD_WR: i32 = 0x0003; +pub const PSP_O_NBLOCK: i32 = 0x0004; +pub const PSP_O_DIR: i32 = 0x0008; +pub const PSP_O_APPEND: i32 = 0x0100; +pub const PSP_O_CREAT: i32 = 0x0200; +pub const PSP_O_TRUNC: i32 = 0x0400; +pub const PSP_O_EXCL: i32 = 0x0800; +pub const PSP_O_NO_WAIT: i32 = 0x8000; + +pub const UMD_NOT_PRESENT: i32 = 0x01; +pub const UMD_PRESENT: i32 = 0x02; +pub const UMD_CHANGED: i32 = 0x04; +pub const UMD_INITING: i32 = 0x08; +pub const UMD_INITED: i32 = 0x10; +pub const UMD_READY: i32 = 0x20; + +pub const PLAY_PAUSE: i32 = 0x1; +pub const FORWARD: i32 = 0x4; +pub const BACK: i32 = 0x8; +pub const VOL_UP: i32 = 0x10; +pub const VOL_DOWN: i32 = 0x20; +pub const HOLD: i32 = 0x80; + +pub const GU_PI: f32 = 3.141593; + +pub const GU_TEXTURE_8BIT: i32 = 1; +pub const GU_TEXTURE_16BIT: i32 = 2; +pub const GU_TEXTURE_32BITF: i32 = 3; +pub const GU_COLOR_5650: i32 = 4 << 2; +pub const GU_COLOR_5551: i32 = 5 << 2; +pub const GU_COLOR_4444: i32 = 6 << 2; +pub const GU_COLOR_8888: i32 = 7 << 2; +pub const GU_NORMAL_8BIT: i32 = 1 << 5; +pub const GU_NORMAL_16BIT: i32 = 2 << 5; +pub const GU_NORMAL_32BITF: i32 = 3 << 5; +pub const GU_VERTEX_8BIT: i32 = 1 << 7; +pub const GU_VERTEX_16BIT: i32 = 2 << 7; +pub const GU_VERTEX_32BITF: i32 = 3 << 7; +pub const GU_WEIGHT_8BIT: i32 = 1 << 9; +pub const GU_WEIGHT_16BIT: i32 = 2 << 9; +pub const GU_WEIGHT_32BITF: i32 = 3 << 9; +pub const GU_INDEX_8BIT: i32 = 1 << 11; +pub const GU_INDEX_16BIT: i32 = 2 << 11; +pub const GU_WEIGHTS1: i32 = (((1 - 1) & 7) << 14) as i32; +pub const GU_WEIGHTS2: i32 = (((2 - 1) & 7) << 14) as i32; +pub const GU_WEIGHTS3: i32 = (((3 - 1) & 7) << 14) as i32; +pub const GU_WEIGHTS4: i32 = (((4 - 1) & 7) << 14) as i32; +pub const GU_WEIGHTS5: i32 = (((5 - 1) & 7) << 14) as i32; +pub const GU_WEIGHTS6: i32 = (((6 - 1) & 7) << 14) as i32; +pub const GU_WEIGHTS7: i32 = (((7 - 1) & 7) << 14) as i32; +pub const GU_WEIGHTS8: i32 = (((8 - 1) & 7) << 14) as i32; +pub const GU_VERTICES1: i32 = (((1 - 1) & 7) << 18) as i32; +pub const GU_VERTICES2: i32 = (((2 - 1) & 7) << 18) as i32; +pub const GU_VERTICES3: i32 = (((3 - 1) & 7) << 18) as i32; +pub const GU_VERTICES4: i32 = (((4 - 1) & 7) << 18) as i32; +pub const GU_VERTICES5: i32 = (((5 - 1) & 7) << 18) as i32; +pub const GU_VERTICES6: i32 = (((6 - 1) & 7) << 18) as i32; +pub const GU_VERTICES7: i32 = (((7 - 1) & 7) << 18) as i32; +pub const GU_VERTICES8: i32 = (((8 - 1) & 7) << 18) as i32; +pub const GU_TRANSFORM_2D: i32 = 1 << 23; +pub const GU_TRANSFORM_3D: i32 = 0; + +pub const GU_COLOR_BUFFER_BIT: i32 = 1; +pub const GU_STENCIL_BUFFER_BIT: i32 = 2; +pub const GU_DEPTH_BUFFER_BIT: i32 = 4; +pub const GU_FAST_CLEAR_BIT: i32 = 16; + +pub const GU_AMBIENT: i32 = 1; +pub const GU_DIFFUSE: i32 = 2; +pub const GU_SPECULAR: i32 = 4; +pub const GU_UNKNOWN_LIGHT_COMPONENT: i32 = 8; + +pub const SYSTEM_REGISTRY: [u8; 7] = *b"/system"; +pub const REG_KEYNAME_SIZE: u32 = 27; + +pub const UTILITY_MSGDIALOG_ERROR: i32 = 0; +pub const UTILITY_MSGDIALOG_TEXT: i32 = 1; +pub const UTILITY_MSGDIALOG_YES_NO_BUTTONS: i32 = 0x10; +pub const UTILITY_MSGDIALOG_DEFAULT_NO: i32 = 0x100; + +pub const UTILITY_HTMLVIEWER_OPEN_SCE_START_PAGE: i32 = 0x000001; +pub const UTILITY_HTMLVIEWER_DISABLE_STARTUP_LIMITS: i32 = 0x000002; +pub const UTILITY_HTMLVIEWER_DISABLE_EXIT_DIALOG: i32 = 0x000004; +pub const UTILITY_HTMLVIEWER_DISABLE_CURSOR: i32 = 0x000008; +pub const UTILITY_HTMLVIEWER_DISABLE_DOWNLOAD_COMPLETE_DIALOG: i32 = 0x000010; +pub const UTILITY_HTMLVIEWER_DISABLE_DOWNLOAD_START_DIALOG: i32 = 0x000020; +pub const UTILITY_HTMLVIEWER_DISABLE_DOWNLOAD_DESTINATION_DIALOG: i32 = 0x000040; +pub const UTILITY_HTMLVIEWER_LOCK_DOWNLOAD_DESTINATION_DIALOG: i32 = 0x000080; +pub const UTILITY_HTMLVIEWER_DISABLE_TAB_DISPLAY: i32 = 0x000100; +pub const UTILITY_HTMLVIEWER_ENABLE_ANALOG_HOLD: i32 = 0x000200; +pub const UTILITY_HTMLVIEWER_ENABLE_FLASH: i32 = 0x000400; +pub const UTILITY_HTMLVIEWER_DISABLE_LRTRIGGER: i32 = 0x000800; + +extern "C" { + pub fn sceAudioChReserve(channel: i32, sample_count: i32, format: AudioFormat) -> i32; + pub fn sceAudioChRelease(channel: i32) -> i32; + pub fn sceAudioOutput(channel: i32, vol: i32, buf: *mut c_void) -> i32; + pub fn sceAudioOutputBlocking(channel: i32, vol: i32, buf: *mut c_void) -> i32; + pub fn sceAudioOutputPanned( + channel: i32, + left_vol: i32, + right_vol: i32, + buf: *mut c_void, + ) -> i32; + pub fn sceAudioOutputPannedBlocking( + channel: i32, + left_vol: i32, + right_vol: i32, + buf: *mut c_void, + ) -> i32; + pub fn sceAudioGetChannelRestLen(channel: i32) -> i32; + pub fn sceAudioGetChannelRestLength(channel: i32) -> i32; + pub fn sceAudioSetChannelDataLen(channel: i32, sample_count: i32) -> i32; + pub fn sceAudioChangeChannelConfig(channel: i32, format: AudioFormat) -> i32; + pub fn sceAudioChangeChannelVolume(channel: i32, left_vol: i32, right_vol: i32) -> i32; + pub fn sceAudioOutput2Reserve(sample_count: i32) -> i32; + pub fn sceAudioOutput2Release() -> i32; + pub fn sceAudioOutput2ChangeLength(sample_count: i32) -> i32; + pub fn sceAudioOutput2OutputBlocking(vol: i32, buf: *mut c_void) -> i32; + pub fn sceAudioOutput2GetRestSample() -> i32; + pub fn sceAudioSRCChReserve( + sample_count: i32, + freq: AudioOutputFrequency, + channels: i32, + ) -> i32; + pub fn sceAudioSRCChRelease() -> i32; + pub fn sceAudioSRCOutputBlocking(vol: i32, buf: *mut c_void) -> i32; + pub fn sceAudioInputInit(unknown1: i32, gain: i32, unknown2: i32) -> i32; + pub fn sceAudioInputInitEx(params: *mut AudioInputParams) -> i32; + pub fn sceAudioInputBlocking(sample_count: i32, freq: AudioInputFrequency, buf: *mut c_void); + pub fn sceAudioInput(sample_count: i32, freq: AudioInputFrequency, buf: *mut c_void); + pub fn sceAudioGetInputLength() -> i32; + pub fn sceAudioWaitInputEnd() -> i32; + pub fn sceAudioPollInputEnd() -> i32; + + pub fn sceAtracGetAtracID(ui_codec_type: u32) -> i32; + pub fn sceAtracSetDataAndGetID(buf: *mut c_void, bufsize: usize) -> i32; + pub fn sceAtracDecodeData( + atrac_id: i32, + out_samples: *mut u16, + out_n: *mut i32, + out_end: *mut i32, + out_remain_frame: *mut i32, + ) -> i32; + pub fn sceAtracGetRemainFrame(atrac_id: i32, out_remain_frame: *mut i32) -> i32; + pub fn sceAtracGetStreamDataInfo( + atrac_id: i32, + write_pointer: *mut *mut u8, + available_bytes: *mut u32, + read_offset: *mut u32, + ) -> i32; + pub fn sceAtracAddStreamData(atrac_id: i32, bytes_to_add: u32) -> i32; + pub fn sceAtracGetBitrate(atrac_id: i32, out_bitrate: *mut i32) -> i32; + pub fn sceAtracSetLoopNum(atrac_id: i32, nloops: i32) -> i32; + pub fn sceAtracReleaseAtracID(atrac_id: i32) -> i32; + pub fn sceAtracGetNextSample(atrac_id: i32, out_n: *mut i32) -> i32; + pub fn sceAtracGetMaxSample(atrac_id: i32, out_max: *mut i32) -> i32; + pub fn sceAtracGetBufferInfoForReseting( + atrac_id: i32, + ui_sample: u32, + pbuffer_info: *mut Atrac3BufferInfo, + ) -> i32; + pub fn sceAtracGetChannel(atrac_id: i32, pui_channel: *mut u32) -> i32; + pub fn sceAtracGetInternalErrorInfo(atrac_id: i32, pi_result: *mut i32) -> i32; + pub fn sceAtracGetLoopStatus( + atrac_id: i32, + pi_loop_num: *mut i32, + pui_loop_status: *mut u32, + ) -> i32; + pub fn sceAtracGetNextDecodePosition(atrac_id: i32, pui_sample_position: *mut u32) -> i32; + pub fn sceAtracGetSecondBufferInfo( + atrac_id: i32, + pui_position: *mut u32, + pui_data_byte: *mut u32, + ) -> i32; + pub fn sceAtracGetSoundSample( + atrac_id: i32, + pi_end_sample: *mut i32, + pi_loop_start_sample: *mut i32, + pi_loop_end_sample: *mut i32, + ) -> i32; + pub fn sceAtracResetPlayPosition( + atrac_id: i32, + ui_sample: u32, + ui_write_byte_first_buf: u32, + ui_write_byte_second_buf: u32, + ) -> i32; + pub fn sceAtracSetData(atrac_id: i32, puc_buffer_addr: *mut u8, ui_buffer_byte: u32) -> i32; + pub fn sceAtracSetHalfwayBuffer( + atrac_id: i32, + puc_buffer_addr: *mut u8, + ui_read_byte: u32, + ui_buffer_byte: u32, + ) -> i32; + pub fn sceAtracSetHalfwayBufferAndGetID( + puc_buffer_addr: *mut u8, + ui_read_byte: u32, + ui_buffer_byte: u32, + ) -> i32; + pub fn sceAtracSetSecondBuffer( + atrac_id: i32, + puc_second_buffer_addr: *mut u8, + ui_second_buffer_byte: u32, + ) -> i32; + + pub fn sceCtrlSetSamplingCycle(cycle: i32) -> i32; + pub fn sceCtrlGetSamplingCycle(pcycle: *mut i32) -> i32; + pub fn sceCtrlSetSamplingMode(mode: CtrlMode) -> i32; + pub fn sceCtrlGetSamplingMode(pmode: *mut i32) -> i32; + pub fn sceCtrlPeekBufferPositive(pad_data: *mut SceCtrlData, count: i32) -> i32; + pub fn sceCtrlPeekBufferNegative(pad_data: *mut SceCtrlData, count: i32) -> i32; + pub fn sceCtrlReadBufferPositive(pad_data: *mut SceCtrlData, count: i32) -> i32; + pub fn sceCtrlReadBufferNegative(pad_data: *mut SceCtrlData, count: i32) -> i32; + pub fn sceCtrlPeekLatch(latch_data: *mut SceCtrlLatch) -> i32; + pub fn sceCtrlReadLatch(latch_data: *mut SceCtrlLatch) -> i32; + pub fn sceCtrlSetIdleCancelThreshold(idlereset: i32, idleback: i32) -> i32; + pub fn sceCtrlGetIdleCancelThreshold(idlereset: *mut i32, idleback: *mut i32) -> i32; + + pub fn sceDisplaySetMode(mode: DisplayMode, width: usize, height: usize) -> u32; + pub fn sceDisplayGetMode(pmode: *mut i32, pwidth: *mut i32, pheight: *mut i32) -> i32; + pub fn sceDisplaySetFrameBuf( + top_addr: *const u8, + buffer_width: usize, + pixel_format: DisplayPixelFormat, + sync: DisplaySetBufSync, + ) -> u32; + pub fn sceDisplayGetFrameBuf( + top_addr: *mut *mut c_void, + buffer_width: *mut usize, + pixel_format: *mut DisplayPixelFormat, + sync: DisplaySetBufSync, + ) -> i32; + pub fn sceDisplayGetVcount() -> u32; + pub fn sceDisplayWaitVblank() -> i32; + pub fn sceDisplayWaitVblankCB() -> i32; + pub fn sceDisplayWaitVblankStart() -> i32; + pub fn sceDisplayWaitVblankStartCB() -> i32; + pub fn sceDisplayGetAccumulatedHcount() -> i32; + pub fn sceDisplayGetCurrentHcount() -> i32; + pub fn sceDisplayGetFramePerSec() -> f32; + pub fn sceDisplayIsForeground() -> i32; + pub fn sceDisplayIsVblank() -> i32; + + pub fn sceGeEdramGetSize() -> u32; + pub fn sceGeEdramGetAddr() -> *mut u8; + pub fn sceGeEdramSetAddrTranslation(width: i32) -> i32; + pub fn sceGeGetCmd(cmd: i32) -> u32; + pub fn sceGeGetMtx(type_: GeMatrixType, matrix: *mut c_void) -> i32; + pub fn sceGeGetStack(stack_id: i32, stack: *mut GeStack) -> i32; + pub fn sceGeSaveContext(context: *mut GeContext) -> i32; + pub fn sceGeRestoreContext(context: *const GeContext) -> i32; + pub fn sceGeListEnQueue( + list: *const c_void, + stall: *mut c_void, + cbid: i32, + arg: *mut GeListArgs, + ) -> i32; + pub fn sceGeListEnQueueHead( + list: *const c_void, + stall: *mut c_void, + cbid: i32, + arg: *mut GeListArgs, + ) -> i32; + pub fn sceGeListDeQueue(qid: i32) -> i32; + pub fn sceGeListUpdateStallAddr(qid: i32, stall: *mut c_void) -> i32; + pub fn sceGeListSync(qid: i32, sync_type: i32) -> GeListState; + pub fn sceGeDrawSync(sync_type: i32) -> GeListState; + pub fn sceGeBreak(mode: i32, p_param: *mut GeBreakParam) -> i32; + pub fn sceGeContinue() -> i32; + pub fn sceGeSetCallback(cb: *mut GeCallbackData) -> i32; + pub fn sceGeUnsetCallback(cbid: i32) -> i32; + + pub fn sceKernelExitGame(); + pub fn sceKernelRegisterExitCallback(id: SceUid) -> i32; + pub fn sceKernelLoadExec(file: *const u8, param: *mut SceKernelLoadExecParam) -> i32; + + pub fn sceKernelAllocPartitionMemory( + partition: SceSysMemPartitionId, + name: *const u8, + type_: SceSysMemBlockTypes, + size: u32, + addr: *mut c_void, + ) -> SceUid; + pub fn sceKernelGetBlockHeadAddr(blockid: SceUid) -> *mut c_void; + pub fn sceKernelFreePartitionMemory(blockid: SceUid) -> i32; + pub fn sceKernelTotalFreeMemSize() -> usize; + pub fn sceKernelMaxFreeMemSize() -> usize; + pub fn sceKernelDevkitVersion() -> u32; + pub fn sceKernelSetCompiledSdkVersion(version: u32) -> i32; + pub fn sceKernelGetCompiledSdkVersion() -> u32; + + pub fn sceKernelLibcTime(t: *mut i32) -> i32; + pub fn sceKernelLibcClock() -> u32; + pub fn sceKernelLibcGettimeofday(tp: *mut timeval, tzp: *mut timezone) -> i32; + pub fn sceKernelDcacheWritebackAll(); + pub fn sceKernelDcacheWritebackInvalidateAll(); + pub fn sceKernelDcacheWritebackRange(p: *const c_void, size: u32); + pub fn sceKernelDcacheWritebackInvalidateRange(p: *const c_void, size: u32); + pub fn sceKernelDcacheInvalidateRange(p: *const c_void, size: u32); + pub fn sceKernelIcacheInvalidateAll(); + pub fn sceKernelIcacheInvalidateRange(p: *const c_void, size: u32); + pub fn sceKernelUtilsMt19937Init(ctx: *mut SceKernelUtilsMt19937Context, seed: u32) -> i32; + pub fn sceKernelUtilsMt19937UInt(ctx: *mut SceKernelUtilsMt19937Context) -> u32; + pub fn sceKernelUtilsMd5Digest(data: *mut u8, size: u32, digest: *mut u8) -> i32; + pub fn sceKernelUtilsMd5BlockInit(ctx: *mut SceKernelUtilsMd5Context) -> i32; + pub fn sceKernelUtilsMd5BlockUpdate( + ctx: *mut SceKernelUtilsMd5Context, + data: *mut u8, + size: u32, + ) -> i32; + pub fn sceKernelUtilsMd5BlockResult(ctx: *mut SceKernelUtilsMd5Context, digest: *mut u8) + -> i32; + pub fn sceKernelUtilsSha1Digest(data: *mut u8, size: u32, digest: *mut u8) -> i32; + pub fn sceKernelUtilsSha1BlockInit(ctx: *mut SceKernelUtilsSha1Context) -> i32; + pub fn sceKernelUtilsSha1BlockUpdate( + ctx: *mut SceKernelUtilsSha1Context, + data: *mut u8, + size: u32, + ) -> i32; + pub fn sceKernelUtilsSha1BlockResult( + ctx: *mut SceKernelUtilsSha1Context, + digest: *mut u8, + ) -> i32; + + pub fn sceKernelRegisterSubIntrHandler( + int_no: i32, + no: i32, + handler: *mut c_void, + arg: *mut c_void, + ) -> i32; + pub fn sceKernelReleaseSubIntrHandler(int_no: i32, no: i32) -> i32; + pub fn sceKernelEnableSubIntr(int_no: i32, no: i32) -> i32; + pub fn sceKernelDisableSubIntr(int_no: i32, no: i32) -> i32; + pub fn QueryIntrHandlerInfo( + intr_code: SceUid, + sub_intr_code: SceUid, + data: *mut IntrHandlerOptionParam, + ) -> i32; + + pub fn sceKernelCpuSuspendIntr() -> u32; + pub fn sceKernelCpuResumeIntr(flags: u32); + pub fn sceKernelCpuResumeIntrWithSync(flags: u32); + pub fn sceKernelIsCpuIntrSuspended(flags: u32) -> i32; + pub fn sceKernelIsCpuIntrEnable() -> i32; + + pub fn sceKernelLoadModule( + path: *const u8, + flags: i32, + option: *mut SceKernelLMOption, + ) -> SceUid; + pub fn sceKernelLoadModuleMs( + path: *const u8, + flags: i32, + option: *mut SceKernelLMOption, + ) -> SceUid; + pub fn sceKernelLoadModuleByID( + fid: SceUid, + flags: i32, + option: *mut SceKernelLMOption, + ) -> SceUid; + pub fn sceKernelLoadModuleBufferUsbWlan( + buf_size: usize, + buf: *mut c_void, + flags: i32, + option: *mut SceKernelLMOption, + ) -> SceUid; + pub fn sceKernelStartModule( + mod_id: SceUid, + arg_size: usize, + argp: *mut c_void, + status: *mut i32, + option: *mut SceKernelSMOption, + ) -> i32; + pub fn sceKernelStopModule( + mod_id: SceUid, + arg_size: usize, + argp: *mut c_void, + status: *mut i32, + option: *mut SceKernelSMOption, + ) -> i32; + pub fn sceKernelUnloadModule(mod_id: SceUid) -> i32; + pub fn sceKernelSelfStopUnloadModule(unknown: i32, arg_size: usize, argp: *mut c_void) -> i32; + pub fn sceKernelStopUnloadSelfModule( + arg_size: usize, + argp: *mut c_void, + status: *mut i32, + option: *mut SceKernelSMOption, + ) -> i32; + pub fn sceKernelQueryModuleInfo(mod_id: SceUid, info: *mut SceKernelModuleInfo) -> i32; + pub fn sceKernelGetModuleIdList( + read_buf: *mut SceUid, + read_buf_size: i32, + id_count: *mut i32, + ) -> i32; + + pub fn sceKernelVolatileMemLock(unk: i32, ptr: *mut *mut c_void, size: *mut i32) -> i32; + pub fn sceKernelVolatileMemTryLock(unk: i32, ptr: *mut *mut c_void, size: *mut i32) -> i32; + pub fn sceKernelVolatileMemUnlock(unk: i32) -> i32; + + pub fn sceKernelStdin() -> SceUid; + pub fn sceKernelStdout() -> SceUid; + pub fn sceKernelStderr() -> SceUid; + + pub fn sceKernelGetThreadmanIdType(uid: SceUid) -> SceKernelIdListType; + pub fn sceKernelCreateThread( + name: *const u8, + entry: SceKernelThreadEntry, + init_priority: i32, + stack_size: i32, + attr: i32, + option: *mut SceKernelThreadOptParam, + ) -> SceUid; + pub fn sceKernelDeleteThread(thid: SceUid) -> i32; + pub fn sceKernelStartThread(id: SceUid, arg_len: usize, arg_p: *mut c_void) -> i32; + pub fn sceKernelExitThread(status: i32) -> i32; + pub fn sceKernelExitDeleteThread(status: i32) -> i32; + pub fn sceKernelTerminateThread(thid: SceUid) -> i32; + pub fn sceKernelTerminateDeleteThread(thid: SceUid) -> i32; + pub fn sceKernelSuspendDispatchThread() -> i32; + pub fn sceKernelResumeDispatchThread(state: i32) -> i32; + pub fn sceKernelSleepThread() -> i32; + pub fn sceKernelSleepThreadCB() -> i32; + pub fn sceKernelWakeupThread(thid: SceUid) -> i32; + pub fn sceKernelCancelWakeupThread(thid: SceUid) -> i32; + pub fn sceKernelSuspendThread(thid: SceUid) -> i32; + pub fn sceKernelResumeThread(thid: SceUid) -> i32; + pub fn sceKernelWaitThreadEnd(thid: SceUid, timeout: *mut u32) -> i32; + pub fn sceKernelWaitThreadEndCB(thid: SceUid, timeout: *mut u32) -> i32; + pub fn sceKernelDelayThread(delay: u32) -> i32; + pub fn sceKernelDelayThreadCB(delay: u32) -> i32; + pub fn sceKernelDelaySysClockThread(delay: *mut SceKernelSysClock) -> i32; + pub fn sceKernelDelaySysClockThreadCB(delay: *mut SceKernelSysClock) -> i32; + pub fn sceKernelChangeCurrentThreadAttr(unknown: i32, attr: i32) -> i32; + pub fn sceKernelChangeThreadPriority(thid: SceUid, priority: i32) -> i32; + pub fn sceKernelRotateThreadReadyQueue(priority: i32) -> i32; + pub fn sceKernelReleaseWaitThread(thid: SceUid) -> i32; + pub fn sceKernelGetThreadId() -> i32; + pub fn sceKernelGetThreadCurrentPriority() -> i32; + pub fn sceKernelGetThreadExitStatus(thid: SceUid) -> i32; + pub fn sceKernelCheckThreadStack() -> i32; + pub fn sceKernelGetThreadStackFreeSize(thid: SceUid) -> i32; + pub fn sceKernelReferThreadStatus(thid: SceUid, info: *mut SceKernelThreadInfo) -> i32; + pub fn sceKernelReferThreadRunStatus( + thid: SceUid, + status: *mut SceKernelThreadRunStatus, + ) -> i32; + pub fn sceKernelCreateSema( + name: *const u8, + attr: u32, + init_val: i32, + max_val: i32, + option: *mut SceKernelSemaOptParam, + ) -> SceUid; + pub fn sceKernelDeleteSema(sema_id: SceUid) -> i32; + pub fn sceKernelSignalSema(sema_id: SceUid, signal: i32) -> i32; + pub fn sceKernelWaitSema(sema_id: SceUid, signal: i32, timeout: *mut u32) -> i32; + pub fn sceKernelWaitSemaCB(sema_id: SceUid, signal: i32, timeout: *mut u32) -> i32; + pub fn sceKernelPollSema(sema_id: SceUid, signal: i32) -> i32; + pub fn sceKernelReferSemaStatus(sema_id: SceUid, info: *mut SceKernelSemaInfo) -> i32; + pub fn sceKernelCreateEventFlag( + name: *const u8, + attr: i32, + bits: i32, + opt: *mut SceKernelEventFlagOptParam, + ) -> SceUid; + pub fn sceKernelSetEventFlag(ev_id: SceUid, bits: u32) -> i32; + pub fn sceKernelClearEventFlag(ev_id: SceUid, bits: u32) -> i32; + pub fn sceKernelPollEventFlag(ev_id: SceUid, bits: u32, wait: i32, out_bits: *mut u32) -> i32; + pub fn sceKernelWaitEventFlag( + ev_id: SceUid, + bits: u32, + wait: i32, + out_bits: *mut u32, + timeout: *mut u32, + ) -> i32; + pub fn sceKernelWaitEventFlagCB( + ev_id: SceUid, + bits: u32, + wait: i32, + out_bits: *mut u32, + timeout: *mut u32, + ) -> i32; + pub fn sceKernelDeleteEventFlag(ev_id: SceUid) -> i32; + pub fn sceKernelReferEventFlagStatus(event: SceUid, status: *mut SceKernelEventFlagInfo) + -> i32; + pub fn sceKernelCreateMbx( + name: *const u8, + attr: u32, + option: *mut SceKernelMbxOptParam, + ) -> SceUid; + pub fn sceKernelDeleteMbx(mbx_id: SceUid) -> i32; + pub fn sceKernelSendMbx(mbx_id: SceUid, message: *mut c_void) -> i32; + pub fn sceKernelReceiveMbx(mbx_id: SceUid, message: *mut *mut c_void, timeout: *mut u32) + -> i32; + pub fn sceKernelReceiveMbxCB( + mbx_id: SceUid, + message: *mut *mut c_void, + timeout: *mut u32, + ) -> i32; + pub fn sceKernelPollMbx(mbx_id: SceUid, pmessage: *mut *mut c_void) -> i32; + pub fn sceKernelCancelReceiveMbx(mbx_id: SceUid, num: *mut i32) -> i32; + pub fn sceKernelReferMbxStatus(mbx_id: SceUid, info: *mut SceKernelMbxInfo) -> i32; + pub fn sceKernelSetAlarm( + clock: u32, + handler: SceKernelAlarmHandler, + common: *mut c_void, + ) -> SceUid; + pub fn sceKernelSetSysClockAlarm( + clock: *mut SceKernelSysClock, + handler: *mut SceKernelAlarmHandler, + common: *mut c_void, + ) -> SceUid; + pub fn sceKernelCancelAlarm(alarm_id: SceUid) -> i32; + pub fn sceKernelReferAlarmStatus(alarm_id: SceUid, info: *mut SceKernelAlarmInfo) -> i32; + pub fn sceKernelCreateCallback( + name: *const u8, + func: SceKernelCallbackFunction, + arg: *mut c_void, + ) -> SceUid; + pub fn sceKernelReferCallbackStatus(cb: SceUid, status: *mut SceKernelCallbackInfo) -> i32; + pub fn sceKernelDeleteCallback(cb: SceUid) -> i32; + pub fn sceKernelNotifyCallback(cb: SceUid, arg2: i32) -> i32; + pub fn sceKernelCancelCallback(cb: SceUid) -> i32; + pub fn sceKernelGetCallbackCount(cb: SceUid) -> i32; + pub fn sceKernelCheckCallback() -> i32; + pub fn sceKernelGetThreadmanIdList( + type_: SceKernelIdListType, + read_buf: *mut SceUid, + read_buf_size: i32, + id_count: *mut i32, + ) -> i32; + pub fn sceKernelReferSystemStatus(status: *mut SceKernelSystemStatus) -> i32; + pub fn sceKernelCreateMsgPipe( + name: *const u8, + part: i32, + attr: i32, + unk1: *mut c_void, + opt: *mut c_void, + ) -> SceUid; + pub fn sceKernelDeleteMsgPipe(uid: SceUid) -> i32; + pub fn sceKernelSendMsgPipe( + uid: SceUid, + message: *mut c_void, + size: u32, + unk1: i32, + unk2: *mut c_void, + timeout: *mut u32, + ) -> i32; + pub fn sceKernelSendMsgPipeCB( + uid: SceUid, + message: *mut c_void, + size: u32, + unk1: i32, + unk2: *mut c_void, + timeout: *mut u32, + ) -> i32; + pub fn sceKernelTrySendMsgPipe( + uid: SceUid, + message: *mut c_void, + size: u32, + unk1: i32, + unk2: *mut c_void, + ) -> i32; + pub fn sceKernelReceiveMsgPipe( + uid: SceUid, + message: *mut c_void, + size: u32, + unk1: i32, + unk2: *mut c_void, + timeout: *mut u32, + ) -> i32; + pub fn sceKernelReceiveMsgPipeCB( + uid: SceUid, + message: *mut c_void, + size: u32, + unk1: i32, + unk2: *mut c_void, + timeout: *mut u32, + ) -> i32; + pub fn sceKernelTryReceiveMsgPipe( + uid: SceUid, + message: *mut c_void, + size: u32, + unk1: i32, + unk2: *mut c_void, + ) -> i32; + pub fn sceKernelCancelMsgPipe(uid: SceUid, send: *mut i32, recv: *mut i32) -> i32; + pub fn sceKernelReferMsgPipeStatus(uid: SceUid, info: *mut SceKernelMppInfo) -> i32; + pub fn sceKernelCreateVpl( + name: *const u8, + part: i32, + attr: i32, + size: u32, + opt: *mut SceKernelVplOptParam, + ) -> SceUid; + pub fn sceKernelDeleteVpl(uid: SceUid) -> i32; + pub fn sceKernelAllocateVpl( + uid: SceUid, + size: u32, + data: *mut *mut c_void, + timeout: *mut u32, + ) -> i32; + pub fn sceKernelAllocateVplCB( + uid: SceUid, + size: u32, + data: *mut *mut c_void, + timeout: *mut u32, + ) -> i32; + pub fn sceKernelTryAllocateVpl(uid: SceUid, size: u32, data: *mut *mut c_void) -> i32; + pub fn sceKernelFreeVpl(uid: SceUid, data: *mut c_void) -> i32; + pub fn sceKernelCancelVpl(uid: SceUid, num: *mut i32) -> i32; + pub fn sceKernelReferVplStatus(uid: SceUid, info: *mut SceKernelVplInfo) -> i32; + pub fn sceKernelCreateFpl( + name: *const u8, + part: i32, + attr: i32, + size: u32, + blocks: u32, + opt: *mut SceKernelFplOptParam, + ) -> i32; + pub fn sceKernelDeleteFpl(uid: SceUid) -> i32; + pub fn sceKernelAllocateFpl(uid: SceUid, data: *mut *mut c_void, timeout: *mut u32) -> i32; + pub fn sceKernelAllocateFplCB(uid: SceUid, data: *mut *mut c_void, timeout: *mut u32) -> i32; + pub fn sceKernelTryAllocateFpl(uid: SceUid, data: *mut *mut c_void) -> i32; + pub fn sceKernelFreeFpl(uid: SceUid, data: *mut c_void) -> i32; + pub fn sceKernelCancelFpl(uid: SceUid, pnum: *mut i32) -> i32; + pub fn sceKernelReferFplStatus(uid: SceUid, info: *mut SceKernelFplInfo) -> i32; + pub fn sceKernelUSec2SysClock(usec: u32, clock: *mut SceKernelSysClock) -> i32; + pub fn sceKernelUSec2SysClockWide(usec: u32) -> i64; + pub fn sceKernelSysClock2USec( + clock: *mut SceKernelSysClock, + low: *mut u32, + high: *mut u32, + ) -> i32; + pub fn sceKernelSysClock2USecWide(clock: i64, low: *mut u32, high: *mut u32) -> i32; + pub fn sceKernelGetSystemTime(time: *mut SceKernelSysClock) -> i32; + pub fn sceKernelGetSystemTimeWide() -> i64; + pub fn sceKernelGetSystemTimeLow() -> u32; + pub fn sceKernelCreateVTimer(name: *const u8, opt: *mut SceKernelVTimerOptParam) -> SceUid; + pub fn sceKernelDeleteVTimer(uid: SceUid) -> i32; + pub fn sceKernelGetVTimerBase(uid: SceUid, base: *mut SceKernelSysClock) -> i32; + pub fn sceKernelGetVTimerBaseWide(uid: SceUid) -> i64; + pub fn sceKernelGetVTimerTime(uid: SceUid, time: *mut SceKernelSysClock) -> i32; + pub fn sceKernelGetVTimerTimeWide(uid: SceUid) -> i64; + pub fn sceKernelSetVTimerTime(uid: SceUid, time: *mut SceKernelSysClock) -> i32; + pub fn sceKernelSetVTimerTimeWide(uid: SceUid, time: i64) -> i64; + pub fn sceKernelStartVTimer(uid: SceUid) -> i32; + pub fn sceKernelStopVTimer(uid: SceUid) -> i32; + pub fn sceKernelSetVTimerHandler( + uid: SceUid, + time: *mut SceKernelSysClock, + handler: SceKernelVTimerHandler, + common: *mut c_void, + ) -> i32; + pub fn sceKernelSetVTimerHandlerWide( + uid: SceUid, + time: i64, + handler: SceKernelVTimerHandlerWide, + common: *mut c_void, + ) -> i32; + pub fn sceKernelCancelVTimerHandler(uid: SceUid) -> i32; + pub fn sceKernelReferVTimerStatus(uid: SceUid, info: *mut SceKernelVTimerInfo) -> i32; + pub fn sceKernelRegisterThreadEventHandler( + name: *const u8, + thread_id: SceUid, + mask: i32, + handler: SceKernelThreadEventHandler, + common: *mut c_void, + ) -> SceUid; + pub fn sceKernelReleaseThreadEventHandler(uid: SceUid) -> i32; + pub fn sceKernelReferThreadEventHandlerStatus( + uid: SceUid, + info: *mut SceKernelThreadEventHandlerInfo, + ) -> i32; + pub fn sceKernelReferThreadProfiler() -> *mut DebugProfilerRegs; + pub fn sceKernelReferGlobalProfiler() -> *mut DebugProfilerRegs; + + pub fn sceUsbStart(driver_name: *const u8, size: i32, args: *mut c_void) -> i32; + pub fn sceUsbStop(driver_name: *const u8, size: i32, args: *mut c_void) -> i32; + pub fn sceUsbActivate(pid: u32) -> i32; + pub fn sceUsbDeactivate(pid: u32) -> i32; + pub fn sceUsbGetState() -> i32; + pub fn sceUsbGetDrvState(driver_name: *const u8) -> i32; +} + +extern "C" { + pub fn sceUsbCamSetupStill(param: *mut UsbCamSetupStillParam) -> i32; + pub fn sceUsbCamSetupStillEx(param: *mut UsbCamSetupStillExParam) -> i32; + pub fn sceUsbCamStillInputBlocking(buf: *mut u8, size: usize) -> i32; + pub fn sceUsbCamStillInput(buf: *mut u8, size: usize) -> i32; + pub fn sceUsbCamStillWaitInputEnd() -> i32; + pub fn sceUsbCamStillPollInputEnd() -> i32; + pub fn sceUsbCamStillCancelInput() -> i32; + pub fn sceUsbCamStillGetInputLength() -> i32; + pub fn sceUsbCamSetupVideo( + param: *mut UsbCamSetupVideoParam, + work_area: *mut c_void, + work_area_size: i32, + ) -> i32; + pub fn sceUsbCamSetupVideoEx( + param: *mut UsbCamSetupVideoExParam, + work_area: *mut c_void, + work_area_size: i32, + ) -> i32; + pub fn sceUsbCamStartVideo() -> i32; + pub fn sceUsbCamStopVideo() -> i32; + pub fn sceUsbCamReadVideoFrameBlocking(buf: *mut u8, size: usize) -> i32; + pub fn sceUsbCamReadVideoFrame(buf: *mut u8, size: usize) -> i32; + pub fn sceUsbCamWaitReadVideoFrameEnd() -> i32; + pub fn sceUsbCamPollReadVideoFrameEnd() -> i32; + pub fn sceUsbCamGetReadVideoFrameSize() -> i32; + pub fn sceUsbCamSetSaturation(saturation: i32) -> i32; + pub fn sceUsbCamSetBrightness(brightness: i32) -> i32; + pub fn sceUsbCamSetContrast(contrast: i32) -> i32; + pub fn sceUsbCamSetSharpness(sharpness: i32) -> i32; + pub fn sceUsbCamSetImageEffectMode(effect_mode: UsbCamEffectMode) -> i32; + pub fn sceUsbCamSetEvLevel(exposure_level: UsbCamEvLevel) -> i32; + pub fn sceUsbCamSetReverseMode(reverse_flags: i32) -> i32; + pub fn sceUsbCamSetZoom(zoom: i32) -> i32; + pub fn sceUsbCamGetSaturation(saturation: *mut i32) -> i32; + pub fn sceUsbCamGetBrightness(brightness: *mut i32) -> i32; + pub fn sceUsbCamGetContrast(contrast: *mut i32) -> i32; + pub fn sceUsbCamGetSharpness(sharpness: *mut i32) -> i32; + pub fn sceUsbCamGetImageEffectMode(effect_mode: *mut UsbCamEffectMode) -> i32; + pub fn sceUsbCamGetEvLevel(exposure_level: *mut UsbCamEvLevel) -> i32; + pub fn sceUsbCamGetReverseMode(reverse_flags: *mut i32) -> i32; + pub fn sceUsbCamGetZoom(zoom: *mut i32) -> i32; + pub fn sceUsbCamAutoImageReverseSW(on: i32) -> i32; + pub fn sceUsbCamGetAutoImageReverseState() -> i32; + pub fn sceUsbCamGetLensDirection() -> i32; + + pub fn sceUsbstorBootRegisterNotify(event_flag: SceUid) -> i32; + pub fn sceUsbstorBootUnregisterNotify(event_flag: u32) -> i32; + pub fn sceUsbstorBootSetCapacity(size: u32) -> i32; + + pub fn scePowerRegisterCallback(slot: i32, cbid: SceUid) -> i32; + pub fn scePowerUnregisterCallback(slot: i32) -> i32; + pub fn scePowerIsPowerOnline() -> i32; + pub fn scePowerIsBatteryExist() -> i32; + pub fn scePowerIsBatteryCharging() -> i32; + pub fn scePowerGetBatteryChargingStatus() -> i32; + pub fn scePowerIsLowBattery() -> i32; + pub fn scePowerGetBatteryLifePercent() -> i32; + pub fn scePowerGetBatteryLifeTime() -> i32; + pub fn scePowerGetBatteryTemp() -> i32; + pub fn scePowerGetBatteryElec() -> i32; + pub fn scePowerGetBatteryVolt() -> i32; + pub fn scePowerSetCpuClockFrequency(cpufreq: i32) -> i32; + pub fn scePowerSetBusClockFrequency(busfreq: i32) -> i32; + pub fn scePowerGetCpuClockFrequency() -> i32; + pub fn scePowerGetCpuClockFrequencyInt() -> i32; + pub fn scePowerGetCpuClockFrequencyFloat() -> f32; + pub fn scePowerGetBusClockFrequency() -> i32; + pub fn scePowerGetBusClockFrequencyInt() -> i32; + pub fn scePowerGetBusClockFrequencyFloat() -> f32; + pub fn scePowerSetClockFrequency(pllfreq: i32, cpufreq: i32, busfreq: i32) -> i32; + pub fn scePowerLock(unknown: i32) -> i32; + pub fn scePowerUnlock(unknown: i32) -> i32; + pub fn scePowerTick(t: PowerTick) -> i32; + pub fn scePowerGetIdleTimer() -> i32; + pub fn scePowerIdleTimerEnable(unknown: i32) -> i32; + pub fn scePowerIdleTimerDisable(unknown: i32) -> i32; + pub fn scePowerRequestStandby() -> i32; + pub fn scePowerRequestSuspend() -> i32; + + pub fn sceWlanDevIsPowerOn() -> i32; + pub fn sceWlanGetSwitchState() -> i32; + pub fn sceWlanGetEtherAddr(ether_addr: *mut u8) -> i32; + + pub fn sceWlanDevAttach() -> i32; + pub fn sceWlanDevDetach() -> i32; + + pub fn sceRtcGetTickResolution() -> u32; + pub fn sceRtcGetCurrentTick(tick: *mut u64) -> i32; + pub fn sceRtcGetCurrentClock(tm: *mut ScePspDateTime, tz: i32) -> i32; + pub fn sceRtcGetCurrentClockLocalTime(tm: *mut ScePspDateTime) -> i32; + pub fn sceRtcConvertUtcToLocalTime(tick_utc: *const u64, tick_local: *mut u64) -> i32; + pub fn sceRtcConvertLocalTimeToUTC(tick_local: *const u64, tick_utc: *mut u64) -> i32; + pub fn sceRtcIsLeapYear(year: i32) -> i32; + pub fn sceRtcGetDaysInMonth(year: i32, month: i32) -> i32; + pub fn sceRtcGetDayOfWeek(year: i32, month: i32, day: i32) -> i32; + pub fn sceRtcCheckValid(date: *const ScePspDateTime) -> i32; + pub fn sceRtcSetTick(date: *mut ScePspDateTime, tick: *const u64) -> i32; + pub fn sceRtcGetTick(date: *const ScePspDateTime, tick: *mut u64) -> i32; + pub fn sceRtcCompareTick(tick1: *const u64, tick2: *const u64) -> i32; + pub fn sceRtcTickAddTicks(dest_tick: *mut u64, src_tick: *const u64, num_ticks: u64) -> i32; + pub fn sceRtcTickAddMicroseconds(dest_tick: *mut u64, src_tick: *const u64, num_ms: u64) + -> i32; + pub fn sceRtcTickAddSeconds(dest_tick: *mut u64, src_tick: *const u64, num_seconds: u64) + -> i32; + pub fn sceRtcTickAddMinutes(dest_tick: *mut u64, src_tick: *const u64, num_minutes: u64) + -> i32; + pub fn sceRtcTickAddHours(dest_tick: *mut u64, src_tick: *const u64, num_hours: u64) -> i32; + pub fn sceRtcTickAddDays(dest_tick: *mut u64, src_tick: *const u64, num_days: u64) -> i32; + pub fn sceRtcTickAddWeeks(dest_tick: *mut u64, src_tick: *const u64, num_weeks: u64) -> i32; + pub fn sceRtcTickAddMonths(dest_tick: *mut u64, src_tick: *const u64, num_months: u64) -> i32; + pub fn sceRtcTickAddYears(dest_tick: *mut u64, src_tick: *const u64, num_years: u64) -> i32; + pub fn sceRtcSetTime_t(date: *mut ScePspDateTime, time: u32) -> i32; + pub fn sceRtcGetTime_t(date: *const ScePspDateTime, time: *mut u32) -> i32; + pub fn sceRtcSetTime64_t(date: *mut ScePspDateTime, time: u64) -> i32; + pub fn sceRtcGetTime64_t(date: *const ScePspDateTime, time: *mut u64) -> i32; + pub fn sceRtcSetDosTime(date: *mut ScePspDateTime, dos_time: u32) -> i32; + pub fn sceRtcGetDosTime(date: *mut ScePspDateTime, dos_time: u32) -> i32; + pub fn sceRtcSetWin32FileTime(date: *mut ScePspDateTime, time: *mut u64) -> i32; + pub fn sceRtcGetWin32FileTime(date: *mut ScePspDateTime, time: *mut u64) -> i32; + pub fn sceRtcParseDateTime(dest_tick: *mut u64, date_string: *const u8) -> i32; + pub fn sceRtcFormatRFC3339( + psz_date_time: *mut c_char, + p_utc: *const u64, + time_zone_minutes: i32, + ) -> i32; + pub fn sceRtcFormatRFC3339LocalTime(psz_date_time: *mut c_char, p_utc: *const u64) -> i32; + pub fn sceRtcParseRFC3339(p_utc: *mut u64, psz_date_time: *const u8) -> i32; + pub fn sceRtcFormatRFC2822( + psz_date_time: *mut c_char, + p_utc: *const u64, + time_zone_minutes: i32, + ) -> i32; + pub fn sceRtcFormatRFC2822LocalTime(psz_date_time: *mut c_char, p_utc: *const u64) -> i32; + + pub fn sceIoOpen(file: *const u8, flags: i32, permissions: IoPermissions) -> SceUid; + pub fn sceIoOpenAsync(file: *const u8, flags: i32, permissions: IoPermissions) -> SceUid; + pub fn sceIoClose(fd: SceUid) -> i32; + pub fn sceIoCloseAsync(fd: SceUid) -> i32; + pub fn sceIoRead(fd: SceUid, data: *mut c_void, size: u32) -> i32; + pub fn sceIoReadAsync(fd: SceUid, data: *mut c_void, size: u32) -> i32; + pub fn sceIoWrite(fd: SceUid, data: *const c_void, size: usize) -> i32; + pub fn sceIoWriteAsync(fd: SceUid, data: *const c_void, size: u32) -> i32; + pub fn sceIoLseek(fd: SceUid, offset: i64, whence: IoWhence) -> i64; + pub fn sceIoLseekAsync(fd: SceUid, offset: i64, whence: IoWhence) -> i32; + pub fn sceIoLseek32(fd: SceUid, offset: i32, whence: IoWhence) -> i32; + pub fn sceIoLseek32Async(fd: SceUid, offset: i32, whence: IoWhence) -> i32; + pub fn sceIoRemove(file: *const u8) -> i32; + pub fn sceIoMkdir(dir: *const u8, mode: IoPermissions) -> i32; + pub fn sceIoRmdir(path: *const u8) -> i32; + pub fn sceIoChdir(path: *const u8) -> i32; + pub fn sceIoRename(oldname: *const u8, newname: *const u8) -> i32; + pub fn sceIoDopen(dirname: *const u8) -> SceUid; + pub fn sceIoDread(fd: SceUid, dir: *mut SceIoDirent) -> i32; + pub fn sceIoDclose(fd: SceUid) -> i32; + pub fn sceIoDevctl( + dev: *const u8, + cmd: u32, + indata: *mut c_void, + inlen: i32, + outdata: *mut c_void, + outlen: i32, + ) -> i32; + pub fn sceIoAssign( + dev1: *const u8, + dev2: *const u8, + dev3: *const u8, + mode: IoAssignPerms, + unk1: *mut c_void, + unk2: i32, + ) -> i32; + pub fn sceIoUnassign(dev: *const u8) -> i32; + pub fn sceIoGetstat(file: *const u8, stat: *mut SceIoStat) -> i32; + pub fn sceIoChstat(file: *const u8, stat: *mut SceIoStat, bits: i32) -> i32; + pub fn sceIoIoctl( + fd: SceUid, + cmd: u32, + indata: *mut c_void, + inlen: i32, + outdata: *mut c_void, + outlen: i32, + ) -> i32; + pub fn sceIoIoctlAsync( + fd: SceUid, + cmd: u32, + indata: *mut c_void, + inlen: i32, + outdata: *mut c_void, + outlen: i32, + ) -> i32; + pub fn sceIoSync(device: *const u8, unk: u32) -> i32; + pub fn sceIoWaitAsync(fd: SceUid, res: *mut i64) -> i32; + pub fn sceIoWaitAsyncCB(fd: SceUid, res: *mut i64) -> i32; + pub fn sceIoPollAsync(fd: SceUid, res: *mut i64) -> i32; + pub fn sceIoGetAsyncStat(fd: SceUid, poll: i32, res: *mut i64) -> i32; + pub fn sceIoCancel(fd: SceUid) -> i32; + pub fn sceIoGetDevType(fd: SceUid) -> i32; + pub fn sceIoChangeAsyncPriority(fd: SceUid, pri: i32) -> i32; + pub fn sceIoSetAsyncCallback(fd: SceUid, cb: SceUid, argp: *mut c_void) -> i32; + + pub fn sceJpegInitMJpeg() -> i32; + pub fn sceJpegFinishMJpeg() -> i32; + pub fn sceJpegCreateMJpeg(width: i32, height: i32) -> i32; + pub fn sceJpegDeleteMJpeg() -> i32; + pub fn sceJpegDecodeMJpeg(jpeg_buf: *mut u8, size: usize, rgba: *mut c_void, unk: u32) -> i32; + + pub fn sceUmdCheckMedium() -> i32; + pub fn sceUmdGetDiscInfo(info: *mut UmdInfo) -> i32; + pub fn sceUmdActivate(unit: i32, drive: *const u8) -> i32; + pub fn sceUmdDeactivate(unit: i32, drive: *const u8) -> i32; + pub fn sceUmdWaitDriveStat(state: i32) -> i32; + pub fn sceUmdWaitDriveStatWithTimer(state: i32, timeout: u32) -> i32; + pub fn sceUmdWaitDriveStatCB(state: i32, timeout: u32) -> i32; + pub fn sceUmdCancelWaitDriveStat() -> i32; + pub fn sceUmdGetDriveStat() -> i32; + pub fn sceUmdGetErrorStat() -> i32; + pub fn sceUmdRegisterUMDCallBack(cbid: i32) -> i32; + pub fn sceUmdUnRegisterUMDCallBack(cbid: i32) -> i32; + pub fn sceUmdReplacePermit() -> i32; + pub fn sceUmdReplaceProhibit() -> i32; + + pub fn sceMpegInit() -> i32; + pub fn sceMpegFinish(); + pub fn sceMpegRingbufferQueryMemSize(packets: i32) -> i32; + pub fn sceMpegRingbufferConstruct( + ringbuffer: *mut SceMpegRingbuffer, + packets: i32, + data: *mut c_void, + size: i32, + callback: SceMpegRingbufferCb, + cb_param: *mut c_void, + ) -> i32; + pub fn sceMpegRingbufferDestruct(ringbuffer: *mut SceMpegRingbuffer); + pub fn sceMpegRingbufferAvailableSize(ringbuffer: *mut SceMpegRingbuffer) -> i32; + pub fn sceMpegRingbufferPut( + ringbuffer: *mut SceMpegRingbuffer, + num_packets: i32, + available: i32, + ) -> i32; + pub fn sceMpegQueryMemSize(unk: i32) -> i32; + pub fn sceMpegCreate( + handle: SceMpeg, + data: *mut c_void, + size: i32, + ringbuffer: *mut SceMpegRingbuffer, + frame_width: i32, + unk1: i32, + unk2: i32, + ) -> i32; + pub fn sceMpegDelete(handle: SceMpeg); + pub fn sceMpegQueryStreamOffset(handle: SceMpeg, buffer: *mut c_void, offset: *mut i32) -> i32; + pub fn sceMpegQueryStreamSize(buffer: *mut c_void, size: *mut i32) -> i32; + pub fn sceMpegRegistStream(handle: SceMpeg, stream_id: i32, unk: i32) -> SceMpegStream; + pub fn sceMpegUnRegistStream(handle: SceMpeg, stream: SceMpegStream); + pub fn sceMpegFlushAllStream(handle: SceMpeg) -> i32; + pub fn sceMpegMallocAvcEsBuf(handle: SceMpeg) -> *mut c_void; + pub fn sceMpegFreeAvcEsBuf(handle: SceMpeg, buf: *mut c_void); + pub fn sceMpegQueryAtracEsSize(handle: SceMpeg, es_size: *mut i32, out_size: *mut i32) -> i32; + pub fn sceMpegInitAu(handle: SceMpeg, es_buffer: *mut c_void, au: *mut SceMpegAu) -> i32; + pub fn sceMpegGetAvcAu( + handle: SceMpeg, + stream: SceMpegStream, + au: *mut SceMpegAu, + unk: *mut i32, + ) -> i32; + pub fn sceMpegAvcDecodeMode(handle: SceMpeg, mode: *mut SceMpegAvcMode) -> i32; + pub fn sceMpegAvcDecode( + handle: SceMpeg, + au: *mut SceMpegAu, + iframe_width: i32, + buffer: *mut c_void, + init: *mut i32, + ) -> i32; + pub fn sceMpegAvcDecodeStop( + handle: SceMpeg, + frame_width: i32, + buffer: *mut c_void, + status: *mut i32, + ) -> i32; + pub fn sceMpegGetAtracAu( + handle: SceMpeg, + stream: SceMpegStream, + au: *mut SceMpegAu, + unk: *mut c_void, + ) -> i32; + pub fn sceMpegAtracDecode( + handle: SceMpeg, + au: *mut SceMpegAu, + buffer: *mut c_void, + init: i32, + ) -> i32; + + pub fn sceMpegBaseYCrCbCopyVme(yuv_buffer: *mut c_void, buffer: *mut i32, type_: i32) -> i32; + pub fn sceMpegBaseCscInit(width: i32) -> i32; + pub fn sceMpegBaseCscVme( + rgb_buffer: *mut c_void, + rgb_buffer2: *mut c_void, + width: i32, + y_cr_cb_buffer: *mut SceMpegYCrCbBuffer, + ) -> i32; + pub fn sceMpegbase_BEA18F91(lli: *mut SceMpegLLI) -> i32; + + pub fn sceHprmPeekCurrentKey(key: *mut i32) -> i32; + pub fn sceHprmPeekLatch(latch: *mut [u32; 4]) -> i32; + pub fn sceHprmReadLatch(latch: *mut [u32; 4]) -> i32; + pub fn sceHprmIsHeadphoneExist() -> i32; + pub fn sceHprmIsRemoteExist() -> i32; + pub fn sceHprmIsMicrophoneExist() -> i32; + + pub fn sceGuDepthBuffer(zbp: *mut c_void, zbw: i32); + pub fn sceGuDispBuffer(width: i32, height: i32, dispbp: *mut c_void, dispbw: i32); + pub fn sceGuDrawBuffer(psm: DisplayPixelFormat, fbp: *mut c_void, fbw: i32); + pub fn sceGuDrawBufferList(psm: DisplayPixelFormat, fbp: *mut c_void, fbw: i32); + pub fn sceGuDisplay(state: bool) -> bool; + pub fn sceGuDepthFunc(function: DepthFunc); + pub fn sceGuDepthMask(mask: i32); + pub fn sceGuDepthOffset(offset: i32); + pub fn sceGuDepthRange(near: i32, far: i32); + pub fn sceGuFog(near: f32, far: f32, color: u32); + pub fn sceGuInit(); + pub fn sceGuTerm(); + pub fn sceGuBreak(mode: i32); + pub fn sceGuContinue(); + pub fn sceGuSetCallback(signal: GuCallbackId, callback: GuCallback) -> GuCallback; + pub fn sceGuSignal(behavior: SignalBehavior, signal: i32); + pub fn sceGuSendCommandf(cmd: GeCommand, argument: f32); + pub fn sceGuSendCommandi(cmd: GeCommand, argument: i32); + pub fn sceGuGetMemory(size: i32) -> *mut c_void; + pub fn sceGuStart(context_type: GuContextType, list: *mut c_void); + pub fn sceGuFinish() -> i32; + pub fn sceGuFinishId(id: u32) -> i32; + pub fn sceGuCallList(list: *const c_void); + pub fn sceGuCallMode(mode: i32); + pub fn sceGuCheckList() -> i32; + pub fn sceGuSendList(mode: GuQueueMode, list: *const c_void, context: *mut GeContext); + pub fn sceGuSwapBuffers() -> *mut c_void; + pub fn sceGuSync(mode: GuSyncMode, behavior: GuSyncBehavior) -> GeListState; + pub fn sceGuDrawArray( + prim: GuPrimitive, + vtype: i32, + count: i32, + indices: *const c_void, + vertices: *const c_void, + ); + pub fn sceGuBeginObject( + vtype: i32, + count: i32, + indices: *const c_void, + vertices: *const c_void, + ); + pub fn sceGuEndObject(); + pub fn sceGuSetStatus(state: GuState, status: i32); + pub fn sceGuGetStatus(state: GuState) -> bool; + pub fn sceGuSetAllStatus(status: i32); + pub fn sceGuGetAllStatus() -> i32; + pub fn sceGuEnable(state: GuState); + pub fn sceGuDisable(state: GuState); + pub fn sceGuLight(light: i32, type_: LightType, components: i32, position: &ScePspFVector3); + pub fn sceGuLightAtt(light: i32, atten0: f32, atten1: f32, atten2: f32); + pub fn sceGuLightColor(light: i32, component: i32, color: u32); + pub fn sceGuLightMode(mode: LightMode); + pub fn sceGuLightSpot(light: i32, direction: &ScePspFVector3, exponent: f32, cutoff: f32); + pub fn sceGuClear(flags: i32); + pub fn sceGuClearColor(color: u32); + pub fn sceGuClearDepth(depth: u32); + pub fn sceGuClearStencil(stencil: u32); + pub fn sceGuPixelMask(mask: u32); + pub fn sceGuColor(color: u32); + pub fn sceGuColorFunc(func: ColorFunc, color: u32, mask: u32); + pub fn sceGuColorMaterial(components: i32); + pub fn sceGuAlphaFunc(func: AlphaFunc, value: i32, mask: i32); + pub fn sceGuAmbient(color: u32); + pub fn sceGuAmbientColor(color: u32); + pub fn sceGuBlendFunc(op: BlendOp, src: BlendSrc, dest: BlendDst, src_fix: u32, dest_fix: u32); + pub fn sceGuMaterial(components: i32, color: u32); + pub fn sceGuModelColor(emissive: u32, ambient: u32, diffuse: u32, specular: u32); + pub fn sceGuStencilFunc(func: StencilFunc, ref_: i32, mask: i32); + pub fn sceGuStencilOp(fail: StencilOperation, zfail: StencilOperation, zpass: StencilOperation); + pub fn sceGuSpecular(power: f32); + pub fn sceGuFrontFace(order: FrontFaceDirection); + pub fn sceGuLogicalOp(op: LogicalOperation); + pub fn sceGuSetDither(matrix: &ScePspIMatrix4); + pub fn sceGuShadeModel(mode: ShadingModel); + pub fn sceGuCopyImage( + psm: DisplayPixelFormat, + sx: i32, + sy: i32, + width: i32, + height: i32, + srcw: i32, + src: *mut c_void, + dx: i32, + dy: i32, + destw: i32, + dest: *mut c_void, + ); + pub fn sceGuTexEnvColor(color: u32); + pub fn sceGuTexFilter(min: TextureFilter, mag: TextureFilter); + pub fn sceGuTexFlush(); + pub fn sceGuTexFunc(tfx: TextureEffect, tcc: TextureColorComponent); + pub fn sceGuTexImage( + mipmap: MipmapLevel, + width: i32, + height: i32, + tbw: i32, + tbp: *const c_void, + ); + pub fn sceGuTexLevelMode(mode: TextureLevelMode, bias: f32); + pub fn sceGuTexMapMode(mode: TextureMapMode, a1: u32, a2: u32); + pub fn sceGuTexMode(tpsm: TexturePixelFormat, maxmips: i32, a2: i32, swizzle: i32); + pub fn sceGuTexOffset(u: f32, v: f32); + pub fn sceGuTexProjMapMode(mode: TextureProjectionMapMode); + pub fn sceGuTexScale(u: f32, v: f32); + pub fn sceGuTexSlope(slope: f32); + pub fn sceGuTexSync(); + pub fn sceGuTexWrap(u: GuTexWrapMode, v: GuTexWrapMode); + pub fn sceGuClutLoad(num_blocks: i32, cbp: *const c_void); + pub fn sceGuClutMode(cpsm: ClutPixelFormat, shift: u32, mask: u32, a3: u32); + pub fn sceGuOffset(x: u32, y: u32); + pub fn sceGuScissor(x: i32, y: i32, w: i32, h: i32); + pub fn sceGuViewport(cx: i32, cy: i32, width: i32, height: i32); + pub fn sceGuDrawBezier( + v_type: i32, + u_count: i32, + v_count: i32, + indices: *const c_void, + vertices: *const c_void, + ); + pub fn sceGuPatchDivide(ulevel: u32, vlevel: u32); + pub fn sceGuPatchFrontFace(a0: u32); + pub fn sceGuPatchPrim(prim: PatchPrimitive); + pub fn sceGuDrawSpline( + v_type: i32, + u_count: i32, + v_count: i32, + u_edge: i32, + v_edge: i32, + indices: *const c_void, + vertices: *const c_void, + ); + pub fn sceGuSetMatrix(type_: MatrixMode, matrix: &ScePspFMatrix4); + pub fn sceGuBoneMatrix(index: u32, matrix: &ScePspFMatrix4); + pub fn sceGuMorphWeight(index: i32, weight: f32); + pub fn sceGuDrawArrayN( + primitive_type: GuPrimitive, + v_type: i32, + count: i32, + a3: i32, + indices: *const c_void, + vertices: *const c_void, + ); + + pub fn sceGumDrawArray( + prim: GuPrimitive, + v_type: i32, + count: i32, + indices: *const c_void, + vertices: *const c_void, + ); + pub fn sceGumDrawArrayN( + prim: GuPrimitive, + v_type: i32, + count: i32, + a3: i32, + indices: *const c_void, + vertices: *const c_void, + ); + pub fn sceGumDrawBezier( + v_type: i32, + u_count: i32, + v_count: i32, + indices: *const c_void, + vertices: *const c_void, + ); + pub fn sceGumDrawSpline( + v_type: i32, + u_count: i32, + v_count: i32, + u_edge: i32, + v_edge: i32, + indices: *const c_void, + vertices: *const c_void, + ); + pub fn sceGumFastInverse(); + pub fn sceGumFullInverse(); + pub fn sceGumLoadIdentity(); + pub fn sceGumLoadMatrix(m: &ScePspFMatrix4); + pub fn sceGumLookAt(eye: &ScePspFVector3, center: &ScePspFVector3, up: &ScePspFVector3); + pub fn sceGumMatrixMode(mode: MatrixMode); + pub fn sceGumMultMatrix(m: &ScePspFMatrix4); + pub fn sceGumOrtho(left: f32, right: f32, bottom: f32, top: f32, near: f32, far: f32); + pub fn sceGumPerspective(fovy: f32, aspect: f32, near: f32, far: f32); + pub fn sceGumPopMatrix(); + pub fn sceGumPushMatrix(); + pub fn sceGumRotateX(angle: f32); + pub fn sceGumRotateY(angle: f32); + pub fn sceGumRotateZ(angle: f32); + pub fn sceGumRotateXYZ(v: &ScePspFVector3); + pub fn sceGumRotateZYX(v: &ScePspFVector3); + pub fn sceGumScale(v: &ScePspFVector3); + pub fn sceGumStoreMatrix(m: &mut ScePspFMatrix4); + pub fn sceGumTranslate(v: &ScePspFVector3); + pub fn sceGumUpdateMatrix(); + + pub fn sceMp3ReserveMp3Handle(args: *mut SceMp3InitArg) -> i32; + pub fn sceMp3ReleaseMp3Handle(handle: Mp3Handle) -> i32; + pub fn sceMp3InitResource() -> i32; + pub fn sceMp3TermResource() -> i32; + pub fn sceMp3Init(handle: Mp3Handle) -> i32; + pub fn sceMp3Decode(handle: Mp3Handle, dst: *mut *mut i16) -> i32; + pub fn sceMp3GetInfoToAddStreamData( + handle: Mp3Handle, + dst: *mut *mut u8, + to_write: *mut i32, + src_pos: *mut i32, + ) -> i32; + pub fn sceMp3NotifyAddStreamData(handle: Mp3Handle, size: i32) -> i32; + pub fn sceMp3CheckStreamDataNeeded(handle: Mp3Handle) -> i32; + pub fn sceMp3SetLoopNum(handle: Mp3Handle, loop_: i32) -> i32; + pub fn sceMp3GetLoopNum(handle: Mp3Handle) -> i32; + pub fn sceMp3GetSumDecodedSample(handle: Mp3Handle) -> i32; + pub fn sceMp3GetMaxOutputSample(handle: Mp3Handle) -> i32; + pub fn sceMp3GetSamplingRate(handle: Mp3Handle) -> i32; + pub fn sceMp3GetBitRate(handle: Mp3Handle) -> i32; + pub fn sceMp3GetMp3ChannelNum(handle: Mp3Handle) -> i32; + pub fn sceMp3ResetPlayPosition(handle: Mp3Handle) -> i32; + + pub fn sceRegOpenRegistry(reg: *mut Key, mode: i32, handle: *mut RegHandle) -> i32; + pub fn sceRegFlushRegistry(handle: RegHandle) -> i32; + pub fn sceRegCloseRegistry(handle: RegHandle) -> i32; + pub fn sceRegOpenCategory( + handle: RegHandle, + name: *const u8, + mode: i32, + dir_handle: *mut RegHandle, + ) -> i32; + pub fn sceRegRemoveCategory(handle: RegHandle, name: *const u8) -> i32; + pub fn sceRegCloseCategory(dir_handle: RegHandle) -> i32; + pub fn sceRegFlushCategory(dir_handle: RegHandle) -> i32; + pub fn sceRegGetKeyInfo( + dir_handle: RegHandle, + name: *const u8, + key_handle: *mut RegHandle, + type_: *mut KeyType, + size: *mut usize, + ) -> i32; + pub fn sceRegGetKeyInfoByName( + dir_handle: RegHandle, + name: *const u8, + type_: *mut KeyType, + size: *mut usize, + ) -> i32; + pub fn sceRegGetKeyValue( + dir_handle: RegHandle, + key_handle: RegHandle, + buf: *mut c_void, + size: usize, + ) -> i32; + pub fn sceRegGetKeyValueByName( + dir_handle: RegHandle, + name: *const u8, + buf: *mut c_void, + size: usize, + ) -> i32; + pub fn sceRegSetKeyValue( + dir_handle: RegHandle, + name: *const u8, + buf: *const c_void, + size: usize, + ) -> i32; + pub fn sceRegGetKeysNum(dir_handle: RegHandle, num: *mut i32) -> i32; + pub fn sceRegGetKeys(dir_handle: RegHandle, buf: *mut u8, num: i32) -> i32; + pub fn sceRegCreateKey(dir_handle: RegHandle, name: *const u8, type_: i32, size: usize) -> i32; + pub fn sceRegRemoveRegistry(key: *mut Key) -> i32; + + pub fn sceOpenPSIDGetOpenPSID(openpsid: *mut OpenPSID) -> i32; + + pub fn sceUtilityMsgDialogInitStart(params: *mut UtilityMsgDialogParams) -> i32; + pub fn sceUtilityMsgDialogShutdownStart(); + pub fn sceUtilityMsgDialogGetStatus() -> i32; + pub fn sceUtilityMsgDialogUpdate(n: i32); + pub fn sceUtilityMsgDialogAbort() -> i32; + pub fn sceUtilityNetconfInitStart(data: *mut UtilityNetconfData) -> i32; + pub fn sceUtilityNetconfShutdownStart() -> i32; + pub fn sceUtilityNetconfUpdate(unknown: i32) -> i32; + pub fn sceUtilityNetconfGetStatus() -> i32; + pub fn sceUtilityCheckNetParam(id: i32) -> i32; + pub fn sceUtilityGetNetParam(conf: i32, param: NetParam, data: *mut UtilityNetData) -> i32; + pub fn sceUtilitySavedataInitStart(params: *mut SceUtilitySavedataParam) -> i32; + pub fn sceUtilitySavedataGetStatus() -> i32; + pub fn sceUtilitySavedataShutdownStart() -> i32; + pub fn sceUtilitySavedataUpdate(unknown: i32); + pub fn sceUtilityGameSharingInitStart(params: *mut UtilityGameSharingParams) -> i32; + pub fn sceUtilityGameSharingShutdownStart(); + pub fn sceUtilityGameSharingGetStatus() -> i32; + pub fn sceUtilityGameSharingUpdate(n: i32); + pub fn sceUtilityHtmlViewerInitStart(params: *mut UtilityHtmlViewerParam) -> i32; + pub fn sceUtilityHtmlViewerShutdownStart() -> i32; + pub fn sceUtilityHtmlViewerUpdate(n: i32) -> i32; + pub fn sceUtilityHtmlViewerGetStatus() -> i32; + pub fn sceUtilitySetSystemParamInt(id: SystemParamId, value: i32) -> i32; + pub fn sceUtilitySetSystemParamString(id: SystemParamId, str: *const u8) -> i32; + pub fn sceUtilityGetSystemParamInt(id: SystemParamId, value: *mut i32) -> i32; + pub fn sceUtilityGetSystemParamString(id: SystemParamId, str: *mut u8, len: i32) -> i32; + pub fn sceUtilityOskInitStart(params: *mut SceUtilityOskParams) -> i32; + pub fn sceUtilityOskShutdownStart() -> i32; + pub fn sceUtilityOskUpdate(n: i32) -> i32; + pub fn sceUtilityOskGetStatus() -> i32; + pub fn sceUtilityLoadNetModule(module: NetModule) -> i32; + pub fn sceUtilityUnloadNetModule(module: NetModule) -> i32; + pub fn sceUtilityLoadAvModule(module: AvModule) -> i32; + pub fn sceUtilityUnloadAvModule(module: AvModule) -> i32; + pub fn sceUtilityLoadUsbModule(module: UsbModule) -> i32; + pub fn sceUtilityUnloadUsbModule(module: UsbModule) -> i32; + pub fn sceUtilityLoadModule(module: Module) -> i32; + pub fn sceUtilityUnloadModule(module: Module) -> i32; + pub fn sceUtilityCreateNetParam(conf: i32) -> i32; + pub fn sceUtilitySetNetParam(param: NetParam, val: *const c_void) -> i32; + pub fn sceUtilityCopyNetParam(src: i32, dest: i32) -> i32; + pub fn sceUtilityDeleteNetParam(conf: i32) -> i32; + + pub fn sceNetInit( + poolsize: i32, + calloutprio: i32, + calloutstack: i32, + netintrprio: i32, + netintrstack: i32, + ) -> i32; + pub fn sceNetTerm() -> i32; + pub fn sceNetFreeThreadinfo(thid: i32) -> i32; + pub fn sceNetThreadAbort(thid: i32) -> i32; + pub fn sceNetEtherStrton(name: *mut u8, mac: *mut u8); + pub fn sceNetEtherNtostr(mac: *mut u8, name: *mut u8); + pub fn sceNetGetLocalEtherAddr(mac: *mut u8) -> i32; + pub fn sceNetGetMallocStat(stat: *mut SceNetMallocStat) -> i32; + + pub fn sceNetAdhocctlInit( + stacksize: i32, + priority: i32, + adhoc_id: *mut SceNetAdhocctlAdhocId, + ) -> i32; + pub fn sceNetAdhocctlTerm() -> i32; + pub fn sceNetAdhocctlConnect(name: *const u8) -> i32; + pub fn sceNetAdhocctlDisconnect() -> i32; + pub fn sceNetAdhocctlGetState(event: *mut i32) -> i32; + pub fn sceNetAdhocctlCreate(name: *const u8) -> i32; + pub fn sceNetAdhocctlJoin(scaninfo: *mut SceNetAdhocctlScanInfo) -> i32; + pub fn sceNetAdhocctlGetAdhocId(id: *mut SceNetAdhocctlAdhocId) -> i32; + pub fn sceNetAdhocctlCreateEnterGameMode( + name: *const u8, + unknown: i32, + num: i32, + macs: *mut u8, + timeout: u32, + unknown2: i32, + ) -> i32; + pub fn sceNetAdhocctlJoinEnterGameMode( + name: *const u8, + hostmac: *mut u8, + timeout: u32, + unknown: i32, + ) -> i32; + pub fn sceNetAdhocctlGetGameModeInfo(gamemodeinfo: *mut SceNetAdhocctlGameModeInfo) -> i32; + pub fn sceNetAdhocctlExitGameMode() -> i32; + pub fn sceNetAdhocctlGetPeerList(length: *mut i32, buf: *mut c_void) -> i32; + pub fn sceNetAdhocctlGetPeerInfo( + mac: *mut u8, + size: i32, + peerinfo: *mut SceNetAdhocctlPeerInfo, + ) -> i32; + pub fn sceNetAdhocctlScan() -> i32; + pub fn sceNetAdhocctlGetScanInfo(length: *mut i32, buf: *mut c_void) -> i32; + pub fn sceNetAdhocctlAddHandler(handler: SceNetAdhocctlHandler, unknown: *mut c_void) -> i32; + pub fn sceNetAdhocctlDelHandler(id: i32) -> i32; + pub fn sceNetAdhocctlGetNameByAddr(mac: *mut u8, nickname: *mut u8) -> i32; + pub fn sceNetAdhocctlGetAddrByName( + nickname: *mut u8, + length: *mut i32, + buf: *mut c_void, + ) -> i32; + pub fn sceNetAdhocctlGetParameter(params: *mut SceNetAdhocctlParams) -> i32; + + pub fn sceNetAdhocInit() -> i32; + pub fn sceNetAdhocTerm() -> i32; + pub fn sceNetAdhocPdpCreate(mac: *mut u8, port: u16, buf_size: u32, unk1: i32) -> i32; + pub fn sceNetAdhocPdpDelete(id: i32, unk1: i32) -> i32; + pub fn sceNetAdhocPdpSend( + id: i32, + dest_mac_addr: *mut u8, + port: u16, + data: *mut c_void, + len: u32, + timeout: u32, + nonblock: i32, + ) -> i32; + pub fn sceNetAdhocPdpRecv( + id: i32, + src_mac_addr: *mut u8, + port: *mut u16, + data: *mut c_void, + data_length: *mut c_void, + timeout: u32, + nonblock: i32, + ) -> i32; + pub fn sceNetAdhocGetPdpStat(size: *mut i32, stat: *mut SceNetAdhocPdpStat) -> i32; + pub fn sceNetAdhocGameModeCreateMaster(data: *mut c_void, size: i32) -> i32; + pub fn sceNetAdhocGameModeCreateReplica(mac: *mut u8, data: *mut c_void, size: i32) -> i32; + pub fn sceNetAdhocGameModeUpdateMaster() -> i32; + pub fn sceNetAdhocGameModeUpdateReplica(id: i32, unk1: i32) -> i32; + pub fn sceNetAdhocGameModeDeleteMaster() -> i32; + pub fn sceNetAdhocGameModeDeleteReplica(id: i32) -> i32; + pub fn sceNetAdhocPtpOpen( + srcmac: *mut u8, + srcport: u16, + destmac: *mut u8, + destport: u16, + buf_size: u32, + delay: u32, + count: i32, + unk1: i32, + ) -> i32; + pub fn sceNetAdhocPtpConnect(id: i32, timeout: u32, nonblock: i32) -> i32; + pub fn sceNetAdhocPtpListen( + srcmac: *mut u8, + srcport: u16, + buf_size: u32, + delay: u32, + count: i32, + queue: i32, + unk1: i32, + ) -> i32; + pub fn sceNetAdhocPtpAccept( + id: i32, + mac: *mut u8, + port: *mut u16, + timeout: u32, + nonblock: i32, + ) -> i32; + pub fn sceNetAdhocPtpSend( + id: i32, + data: *mut c_void, + data_size: *mut i32, + timeout: u32, + nonblock: i32, + ) -> i32; + pub fn sceNetAdhocPtpRecv( + id: i32, + data: *mut c_void, + data_size: *mut i32, + timeout: u32, + nonblock: i32, + ) -> i32; + pub fn sceNetAdhocPtpFlush(id: i32, timeout: u32, nonblock: i32) -> i32; + pub fn sceNetAdhocPtpClose(id: i32, unk1: i32) -> i32; + pub fn sceNetAdhocGetPtpStat(size: *mut i32, stat: *mut SceNetAdhocPtpStat) -> i32; +} + +extern "C" { + pub fn sceNetAdhocMatchingInit(memsize: i32) -> i32; + pub fn sceNetAdhocMatchingTerm() -> i32; + pub fn sceNetAdhocMatchingCreate( + mode: AdhocMatchingMode, + max_peers: i32, + port: u16, + buf_size: i32, + hello_delay: u32, + ping_delay: u32, + init_count: i32, + msg_delay: u32, + callback: AdhocMatchingCallback, + ) -> i32; + pub fn sceNetAdhocMatchingDelete(matching_id: i32) -> i32; + pub fn sceNetAdhocMatchingStart( + matching_id: i32, + evth_pri: i32, + evth_stack: i32, + inth_pri: i32, + inth_stack: i32, + opt_len: i32, + opt_data: *mut c_void, + ) -> i32; + pub fn sceNetAdhocMatchingStop(matching_id: i32) -> i32; + pub fn sceNetAdhocMatchingSelectTarget( + matching_id: i32, + mac: *mut u8, + opt_len: i32, + opt_data: *mut c_void, + ) -> i32; + pub fn sceNetAdhocMatchingCancelTarget(matching_id: i32, mac: *mut u8) -> i32; + pub fn sceNetAdhocMatchingCancelTargetWithOpt( + matching_id: i32, + mac: *mut u8, + opt_len: i32, + opt_data: *mut c_void, + ) -> i32; + pub fn sceNetAdhocMatchingSendData( + matching_id: i32, + mac: *mut u8, + data_len: i32, + data: *mut c_void, + ) -> i32; + pub fn sceNetAdhocMatchingAbortSendData(matching_id: i32, mac: *mut u8) -> i32; + pub fn sceNetAdhocMatchingSetHelloOpt( + matching_id: i32, + opt_len: i32, + opt_data: *mut c_void, + ) -> i32; + pub fn sceNetAdhocMatchingGetHelloOpt( + matching_id: i32, + opt_len: *mut i32, + opt_data: *mut c_void, + ) -> i32; + pub fn sceNetAdhocMatchingGetMembers( + matching_id: i32, + length: *mut i32, + buf: *mut c_void, + ) -> i32; + pub fn sceNetAdhocMatchingGetPoolMaxAlloc() -> i32; + pub fn sceNetAdhocMatchingGetPoolStat(poolstat: *mut AdhocPoolStat) -> i32; +} + +extern "C" { + pub fn sceNetApctlInit(stack_size: i32, init_priority: i32) -> i32; + pub fn sceNetApctlTerm() -> i32; + pub fn sceNetApctlGetInfo(code: ApctlInfo, pinfo: *mut SceNetApctlInfo) -> i32; + pub fn sceNetApctlAddHandler(handler: SceNetApctlHandler, parg: *mut c_void) -> i32; + pub fn sceNetApctlDelHandler(handler_id: i32) -> i32; + pub fn sceNetApctlConnect(conn_index: i32) -> i32; + pub fn sceNetApctlDisconnect() -> i32; + pub fn sceNetApctlGetState(pstate: *mut ApctlState) -> i32; + + pub fn sceNetInetInit() -> i32; + pub fn sceNetInetTerm() -> i32; + pub fn sceNetInetAccept(s: i32, addr: *mut sockaddr, addr_len: *mut socklen_t) -> i32; + pub fn sceNetInetBind(s: i32, my_addr: *const sockaddr, addr_len: socklen_t) -> i32; + pub fn sceNetInetConnect(s: i32, serv_addr: *const sockaddr, addr_len: socklen_t) -> i32; + pub fn sceNetInetGetsockopt( + s: i32, + level: i32, + opt_name: i32, + opt_val: *mut c_void, + optl_en: *mut socklen_t, + ) -> i32; + pub fn sceNetInetListen(s: i32, backlog: i32) -> i32; + pub fn sceNetInetRecv(s: i32, buf: *mut c_void, len: usize, flags: i32) -> usize; + pub fn sceNetInetRecvfrom( + s: i32, + buf: *mut c_void, + flags: usize, + arg1: i32, + from: *mut sockaddr, + from_len: *mut socklen_t, + ) -> usize; + pub fn sceNetInetSend(s: i32, buf: *const c_void, len: usize, flags: i32) -> usize; + pub fn sceNetInetSendto( + s: i32, + buf: *const c_void, + len: usize, + flags: i32, + to: *const sockaddr, + to_len: socklen_t, + ) -> usize; + pub fn sceNetInetSetsockopt( + s: i32, + level: i32, + opt_name: i32, + opt_val: *const c_void, + opt_len: socklen_t, + ) -> i32; + pub fn sceNetInetShutdown(s: i32, how: i32) -> i32; + pub fn sceNetInetSocket(domain: i32, type_: i32, protocol: i32) -> i32; + pub fn sceNetInetClose(s: i32) -> i32; + pub fn sceNetInetGetErrno() -> i32; + + pub fn sceSslInit(unknown1: i32) -> i32; + pub fn sceSslEnd() -> i32; + pub fn sceSslGetUsedMemoryMax(memory: *mut u32) -> i32; + pub fn sceSslGetUsedMemoryCurrent(memory: *mut u32) -> i32; + + pub fn sceHttpInit(unknown1: u32) -> i32; + pub fn sceHttpEnd() -> i32; + pub fn sceHttpCreateTemplate(agent: *mut u8, unknown1: i32, unknown2: i32) -> i32; + pub fn sceHttpDeleteTemplate(templateid: i32) -> i32; + pub fn sceHttpCreateConnection( + templateid: i32, + host: *mut u8, + unknown1: *mut u8, + port: u16, + unknown2: i32, + ) -> i32; + pub fn sceHttpCreateConnectionWithURL(templateid: i32, url: *const u8, unknown1: i32) -> i32; + pub fn sceHttpDeleteConnection(connection_id: i32) -> i32; + pub fn sceHttpCreateRequest( + connection_id: i32, + method: HttpMethod, + path: *mut u8, + content_length: u64, + ) -> i32; + pub fn sceHttpCreateRequestWithURL( + connection_id: i32, + method: HttpMethod, + url: *mut u8, + content_length: u64, + ) -> i32; + pub fn sceHttpDeleteRequest(request_id: i32) -> i32; + pub fn sceHttpSendRequest(request_id: i32, data: *mut c_void, data_size: u32) -> i32; + pub fn sceHttpAbortRequest(request_id: i32) -> i32; + pub fn sceHttpReadData(request_id: i32, data: *mut c_void, data_size: u32) -> i32; + pub fn sceHttpGetContentLength(request_id: i32, content_length: *mut u64) -> i32; + pub fn sceHttpGetStatusCode(request_id: i32, status_code: *mut i32) -> i32; + pub fn sceHttpSetResolveTimeOut(id: i32, timeout: u32) -> i32; + pub fn sceHttpSetResolveRetry(id: i32, count: i32) -> i32; + pub fn sceHttpSetConnectTimeOut(id: i32, timeout: u32) -> i32; + pub fn sceHttpSetSendTimeOut(id: i32, timeout: u32) -> i32; + pub fn sceHttpSetRecvTimeOut(id: i32, timeout: u32) -> i32; + pub fn sceHttpEnableKeepAlive(id: i32) -> i32; + pub fn sceHttpDisableKeepAlive(id: i32) -> i32; + pub fn sceHttpEnableRedirect(id: i32) -> i32; + pub fn sceHttpDisableRedirect(id: i32) -> i32; + pub fn sceHttpEnableCookie(id: i32) -> i32; + pub fn sceHttpDisableCookie(id: i32) -> i32; + pub fn sceHttpSaveSystemCookie() -> i32; + pub fn sceHttpLoadSystemCookie() -> i32; + pub fn sceHttpAddExtraHeader(id: i32, name: *mut u8, value: *mut u8, unknown1: i32) -> i32; + pub fn sceHttpDeleteHeader(id: i32, name: *const u8) -> i32; + pub fn sceHttpsInit(unknown1: i32, unknown2: i32, unknown3: i32, unknown4: i32) -> i32; + pub fn sceHttpsEnd() -> i32; + pub fn sceHttpsLoadDefaultCert(unknown1: i32, unknown2: i32) -> i32; + pub fn sceHttpDisableAuth(id: i32) -> i32; + pub fn sceHttpDisableCache(id: i32) -> i32; + pub fn sceHttpEnableAuth(id: i32) -> i32; + pub fn sceHttpEnableCache(id: i32) -> i32; + pub fn sceHttpEndCache() -> i32; + pub fn sceHttpGetAllHeader(request: i32, header: *mut *mut u8, header_size: *mut u32) -> i32; + pub fn sceHttpGetNetworkErrno(request: i32, err_num: *mut i32) -> i32; + pub fn sceHttpGetProxy( + id: i32, + activate_flag: *mut i32, + mode: *mut i32, + proxy_host: *mut u8, + len: usize, + proxy_port: *mut u16, + ) -> i32; + pub fn sceHttpInitCache(max_size: usize) -> i32; + pub fn sceHttpSetAuthInfoCB(id: i32, cbfunc: HttpPasswordCB) -> i32; + pub fn sceHttpSetProxy( + id: i32, + activate_flag: i32, + mode: i32, + new_proxy_host: *const u8, + new_proxy_port: u16, + ) -> i32; + pub fn sceHttpSetResHeaderMaxSize(id: i32, header_size: u32) -> i32; + pub fn sceHttpSetMallocFunction( + malloc_func: HttpMallocFunction, + free_func: HttpFreeFunction, + realloc_func: HttpReallocFunction, + ) -> i32; + + pub fn sceNetResolverInit() -> i32; + pub fn sceNetResolverCreate(rid: *mut i32, buf: *mut c_void, buf_length: u32) -> i32; + pub fn sceNetResolverDelete(rid: i32) -> i32; + pub fn sceNetResolverStartNtoA( + rid: i32, + hostname: *const u8, + addr: *mut in_addr, + timeout: u32, + retry: i32, + ) -> i32; + pub fn sceNetResolverStartAtoN( + rid: i32, + addr: *const in_addr, + hostname: *mut u8, + hostname_len: u32, + timeout: u32, + retry: i32, + ) -> i32; + pub fn sceNetResolverStop(rid: i32) -> i32; + pub fn sceNetResolverTerm() -> i32; +} diff --git a/http/vendor/libc/src/qurt/mod.rs b/http/vendor/libc/src/qurt/mod.rs new file mode 100644 index 0000000..b5e01f9 --- /dev/null +++ b/http/vendor/libc/src/qurt/mod.rs @@ -0,0 +1,18 @@ +//! Interface to QuRT (Qualcomm Real-Time OS) C library +//! +//! This module re-exports items from the new module structure. +//! QuRT was introduced after the `src/new/` module structure was established, +//! so all definitions live in `src/new/qurt/` and are re-exported here +//! for compatibility with the existing libc structure. + +// Re-export everything from the new qurt module +pub use crate::new::qurt::*; + +// Architecture-specific modules (if any are needed in the future) +cfg_if! { + if #[cfg(target_arch = "hexagon")] { + // Currently no hexagon-specific items needed beyond what's in new/qurt + } else { + // Add other architectures as needed + } +} diff --git a/http/vendor/libc/src/sgx.rs b/http/vendor/libc/src/sgx.rs new file mode 100644 index 0000000..9cf9c6d --- /dev/null +++ b/http/vendor/libc/src/sgx.rs @@ -0,0 +1,15 @@ +//! SGX C types definition + +use crate::prelude::*; + +pub type intmax_t = i64; +pub type uintmax_t = u64; + +pub type size_t = usize; +pub type ptrdiff_t = isize; +pub type intptr_t = isize; +pub type uintptr_t = usize; +pub type ssize_t = isize; + +pub const INT_MIN: c_int = -2147483648; +pub const INT_MAX: c_int = 2147483647; diff --git a/http/vendor/libc/src/solid/aarch64.rs b/http/vendor/libc/src/solid/aarch64.rs new file mode 100644 index 0000000..376783c --- /dev/null +++ b/http/vendor/libc/src/solid/aarch64.rs @@ -0,0 +1 @@ +pub type wchar_t = u32; diff --git a/http/vendor/libc/src/solid/arm.rs b/http/vendor/libc/src/solid/arm.rs new file mode 100644 index 0000000..376783c --- /dev/null +++ b/http/vendor/libc/src/solid/arm.rs @@ -0,0 +1 @@ +pub type wchar_t = u32; diff --git a/http/vendor/libc/src/solid/mod.rs b/http/vendor/libc/src/solid/mod.rs new file mode 100644 index 0000000..0182f81 --- /dev/null +++ b/http/vendor/libc/src/solid/mod.rs @@ -0,0 +1,865 @@ +//! Interface to the [SOLID] C library +//! +//! [SOLID]: https://solid.kmckk.com/ + +use crate::prelude::*; + +pub type intmax_t = i64; +pub type uintmax_t = u64; + +pub type uintptr_t = usize; +pub type intptr_t = isize; +pub type ptrdiff_t = isize; +pub type size_t = crate::uintptr_t; +pub type ssize_t = intptr_t; + +pub type clock_t = c_uint; +pub type time_t = i64; +pub type clockid_t = c_int; +pub type timer_t = c_int; +pub type suseconds_t = c_int; +pub type useconds_t = c_uint; + +pub type sighandler_t = size_t; + +// sys/ansi.h +pub type __caddr_t = *mut c_char; +pub type __gid_t = u32; +pub type __in_addr_t = u32; +pub type __in_port_t = u16; +pub type __mode_t = u32; +pub type __off_t = i64; +pub type __pid_t = i32; +pub type __sa_family_t = u8; +pub type __socklen_t = c_uint; +pub type __uid_t = u32; +pub type __fsblkcnt_t = u64; +pub type __fsfilcnt_t = u64; + +// locale.h +pub type locale_t = usize; + +// nl_types.h +pub type nl_item = c_long; + +// sys/types.h +pub type __va_list = *mut c_char; +pub type u_int8_t = u8; +pub type u_int16_t = u16; +pub type u_int32_t = u32; +pub type u_int64_t = u64; +pub type u_char = c_uchar; +pub type u_short = c_ushort; +pub type u_int = c_uint; +pub type u_long = c_ulong; +pub type unchar = c_uchar; +pub type ushort = c_ushort; +pub type uint = c_uint; +pub type ulong = c_ulong; +pub type u_quad_t = u64; +pub type quad_t = i64; +pub type qaddr_t = *mut quad_t; +pub type longlong_t = i64; +pub type u_longlong_t = u64; +pub type blkcnt_t = i64; +pub type blksize_t = i32; +pub type fsblkcnt_t = __fsblkcnt_t; +pub type fsfilcnt_t = __fsfilcnt_t; +pub type caddr_t = __caddr_t; +pub type daddr_t = i64; +pub type dev_t = u64; +pub type fixpt_t = u32; +pub type gid_t = __gid_t; +pub type idtype_t = c_int; +pub type id_t = u32; +pub type ino_t = u64; +pub type key_t = c_long; +pub type mode_t = __mode_t; +pub type nlink_t = u32; +pub type off_t = __off_t; +pub type pid_t = __pid_t; +pub type lwpid_t = i32; +pub type rlim_t = u64; +pub type segsz_t = i32; +pub type swblk_t = i32; +pub type mqd_t = c_int; +pub type cpuid_t = c_ulong; +pub type psetid_t = c_int; + +s! { + // stat.h + pub struct stat { + pub st_dev: dev_t, + pub st_ino: ino_t, + pub st_mode: c_short, + pub st_nlink: c_short, + pub st_uid: c_short, + pub st_gid: c_short, + pub st_rdev: dev_t, + pub st_size: off_t, + pub st_atime: time_t, + pub st_mtime: time_t, + pub st_ctime: time_t, + pub st_blksize: blksize_t, + } + + // time.h + pub struct tm { + pub tm_sec: c_int, + pub tm_min: c_int, + pub tm_hour: c_int, + pub tm_mday: c_int, + pub tm_mon: c_int, + pub tm_year: c_int, + pub tm_wday: c_int, + pub tm_yday: c_int, + pub tm_isdst: c_int, + pub tm_gmtoff: c_long, + pub tm_zone: *mut c_char, + } + + // stdlib.h + pub struct qdiv_t { + pub quot: quad_t, + pub rem: quad_t, + } + pub struct lldiv_t { + pub quot: c_longlong, + pub rem: c_longlong, + } + pub struct div_t { + pub quot: c_int, + pub rem: c_int, + } + pub struct ldiv_t { + pub quot: c_long, + pub rem: c_long, + } + + // locale.h + pub struct lconv { + pub decimal_point: *mut c_char, + pub thousands_sep: *mut c_char, + pub grouping: *mut c_char, + pub int_curr_symbol: *mut c_char, + pub currency_symbol: *mut c_char, + pub mon_decimal_point: *mut c_char, + pub mon_thousands_sep: *mut c_char, + pub mon_grouping: *mut c_char, + pub positive_sign: *mut c_char, + pub negative_sign: *mut c_char, + pub int_frac_digits: c_char, + pub frac_digits: c_char, + pub p_cs_precedes: c_char, + pub p_sep_by_space: c_char, + pub n_cs_precedes: c_char, + pub n_sep_by_space: c_char, + pub p_sign_posn: c_char, + pub n_sign_posn: c_char, + pub int_p_cs_precedes: c_char, + pub int_n_cs_precedes: c_char, + pub int_p_sep_by_space: c_char, + pub int_n_sep_by_space: c_char, + pub int_p_sign_posn: c_char, + pub int_n_sign_posn: c_char, + } + + pub struct iovec { + pub iov_base: *mut c_void, + pub iov_len: size_t, + } + + #[derive(Default)] + pub struct timeval { + pub tv_sec: c_long, + pub tv_usec: c_long, + } +} + +pub const INT_MIN: c_int = -2147483648; +pub const INT_MAX: c_int = 2147483647; + +pub const EXIT_FAILURE: c_int = 1; +pub const EXIT_SUCCESS: c_int = 0; +pub const RAND_MAX: c_int = 0x7fffffff; +pub const EOF: c_int = -1; +pub const SEEK_SET: c_int = 0; +pub const SEEK_CUR: c_int = 1; +pub const SEEK_END: c_int = 2; +pub const _IOFBF: c_int = 0; +pub const _IONBF: c_int = 2; +pub const _IOLBF: c_int = 1; +pub const BUFSIZ: c_uint = 1024; +pub const FOPEN_MAX: c_uint = 20; +pub const FILENAME_MAX: c_uint = 1024; + +pub const O_RDONLY: c_int = 1; +pub const O_WRONLY: c_int = 2; +pub const O_RDWR: c_int = 4; +pub const O_APPEND: c_int = 8; +pub const O_CREAT: c_int = 0x10; +pub const O_EXCL: c_int = 0x400; +pub const O_TEXT: c_int = 0x100; +pub const O_BINARY: c_int = 0x200; +pub const O_TRUNC: c_int = 0x20; +pub const S_IEXEC: c_short = 0o0100; +pub const S_IWRITE: c_short = 0o0200; +pub const S_IREAD: c_short = 0o0400; +pub const S_IFCHR: c_short = 0o2_0000; +pub const S_IFDIR: c_short = 0o4_0000; +pub const S_IFMT: c_short = 0o16_0000; +pub const S_IFIFO: c_short = 0o1_0000; +pub const S_IFBLK: c_short = 0o6_0000; +pub const S_IFREG: c_short = 0o10_0000; + +pub const LC_ALL: c_int = 0; +pub const LC_COLLATE: c_int = 1; +pub const LC_CTYPE: c_int = 2; +pub const LC_MONETARY: c_int = 3; +pub const LC_NUMERIC: c_int = 4; +pub const LC_TIME: c_int = 5; +pub const LC_MESSAGES: c_int = 6; +pub const _LC_LAST: c_int = 7; + +pub const EPERM: c_int = 1; +pub const ENOENT: c_int = 2; +pub const ESRCH: c_int = 3; +pub const EINTR: c_int = 4; +pub const EIO: c_int = 5; +pub const ENXIO: c_int = 6; +pub const E2BIG: c_int = 7; +pub const ENOEXEC: c_int = 8; +pub const EBADF: c_int = 9; +pub const ECHILD: c_int = 10; +pub const EAGAIN: c_int = 11; +pub const ENOMEM: c_int = 12; +pub const EACCES: c_int = 13; +pub const EFAULT: c_int = 14; +pub const ENOTBLK: c_int = 15; +pub const EBUSY: c_int = 16; +pub const EEXIST: c_int = 17; +pub const EXDEV: c_int = 18; +pub const ENODEV: c_int = 19; +pub const ENOTDIR: c_int = 20; +pub const EISDIR: c_int = 21; +pub const EINVAL: c_int = 22; +pub const ENFILE: c_int = 23; +pub const EMFILE: c_int = 24; +pub const ENOTTY: c_int = 25; +pub const ETXTBSY: c_int = 26; +pub const EFBIG: c_int = 27; +pub const ENOSPC: c_int = 28; +pub const ESPIPE: c_int = 29; +pub const EROFS: c_int = 30; +pub const EMLINK: c_int = 31; +pub const EPIPE: c_int = 32; +pub const EDOM: c_int = 33; +pub const ERANGE: c_int = 34; + +pub const EDEADLK: c_int = 35; +pub const ENAMETOOLONG: c_int = 36; +pub const ENOLCK: c_int = 37; +pub const ENOSYS: c_int = 38; +pub const ENOTEMPTY: c_int = 39; +pub const ELOOP: c_int = 40; +pub const EWOULDBLOCK: c_int = EAGAIN; +pub const ENOMSG: c_int = 42; +pub const EIDRM: c_int = 43; +pub const ECHRNG: c_int = 44; +pub const EL2NSYNC: c_int = 45; +pub const EL3HLT: c_int = 46; +pub const EL3RST: c_int = 47; +pub const ELNRNG: c_int = 48; +pub const EUNATCH: c_int = 49; +pub const ENOCSI: c_int = 50; +pub const EL2HLT: c_int = 51; +pub const EBADE: c_int = 52; +pub const EBADR: c_int = 53; +pub const EXFULL: c_int = 54; +pub const ENOANO: c_int = 55; +pub const EBADRQC: c_int = 56; +pub const EBADSLT: c_int = 57; + +pub const EDEADLOCK: c_int = EDEADLK; + +pub const EBFONT: c_int = 59; +pub const ENOSTR: c_int = 60; +pub const ENODATA: c_int = 61; +pub const ETIME: c_int = 62; +pub const ENOSR: c_int = 63; +pub const ENONET: c_int = 64; +pub const ENOPKG: c_int = 65; +pub const EREMOTE: c_int = 66; +pub const ENOLINK: c_int = 67; +pub const EADV: c_int = 68; +pub const ESRMNT: c_int = 69; +pub const ECOMM: c_int = 70; +pub const EPROTO: c_int = 71; +pub const EMULTIHOP: c_int = 72; +pub const EDOTDOT: c_int = 73; +pub const EBADMSG: c_int = 74; +pub const EOVERFLOW: c_int = 75; +pub const ENOTUNIQ: c_int = 76; +pub const EBADFD: c_int = 77; +pub const EREMCHG: c_int = 78; +pub const ELIBACC: c_int = 79; +pub const ELIBBAD: c_int = 80; +pub const ELIBSCN: c_int = 81; +pub const ELIBMAX: c_int = 82; +pub const ELIBEXEC: c_int = 83; +pub const EILSEQ: c_int = 84; +pub const ERESTART: c_int = 85; +pub const ESTRPIPE: c_int = 86; +pub const EUSERS: c_int = 87; +pub const ENOTSOCK: c_int = 88; +pub const EDESTADDRREQ: c_int = 89; +pub const EMSGSIZE: c_int = 90; +pub const EPROTOTYPE: c_int = 91; +pub const ENOPROTOOPT: c_int = 92; +pub const EPROTONOSUPPORT: c_int = 93; +pub const ESOCKTNOSUPPORT: c_int = 94; +pub const EOPNOTSUPP: c_int = 95; +pub const EPFNOSUPPORT: c_int = 96; +pub const EAFNOSUPPORT: c_int = 97; +pub const EADDRINUSE: c_int = 98; +pub const EADDRNOTAVAIL: c_int = 99; +pub const ENETDOWN: c_int = 100; +pub const ENETUNREACH: c_int = 101; +pub const ENETRESET: c_int = 102; +pub const ECONNABORTED: c_int = 103; +pub const ECONNRESET: c_int = 104; +pub const ENOBUFS: c_int = 105; +pub const EISCONN: c_int = 106; +pub const ENOTCONN: c_int = 107; +pub const ESHUTDOWN: c_int = 108; +pub const ETOOMANYREFS: c_int = 109; +pub const ETIMEDOUT: c_int = 110; +pub const ECONNREFUSED: c_int = 111; +pub const EHOSTDOWN: c_int = 112; +pub const EHOSTUNREACH: c_int = 113; +pub const EALREADY: c_int = 114; +pub const EINPROGRESS: c_int = 115; +pub const ESTALE: c_int = 116; +pub const EUCLEAN: c_int = 117; +pub const ENOTNAM: c_int = 118; +pub const ENAVAIL: c_int = 119; +pub const EISNAM: c_int = 120; +pub const EREMOTEIO: c_int = 121; +pub const EDQUOT: c_int = 122; + +pub const ENOMEDIUM: c_int = 123; +pub const EMEDIUMTYPE: c_int = 124; +pub const ECANCELED: c_int = 125; +pub const ENOKEY: c_int = 126; +pub const EKEYEXPIRED: c_int = 127; +pub const EKEYREVOKED: c_int = 128; +pub const EKEYREJECTED: c_int = 129; + +pub const EOWNERDEAD: c_int = 130; +pub const ENOTRECOVERABLE: c_int = 131; + +pub const ENOTSUP: c_int = 132; +pub const EFTYPE: c_int = 133; + +// signal codes +pub const SIGHUP: c_int = 1; +pub const SIGINT: c_int = 2; +pub const SIGQUIT: c_int = 3; +pub const SIGILL: c_int = 4; +pub const SIGTRAP: c_int = 5; +pub const SIGABRT: c_int = 6; +pub const SIGIOT: c_int = SIGABRT; +pub const SIGEMT: c_int = 7; +pub const SIGFPE: c_int = 8; +pub const SIGKILL: c_int = 9; +pub const SIGBUS: c_int = 10; +pub const SIGSEGV: c_int = 11; +pub const SIGSYS: c_int = 12; +pub const SIGPIPE: c_int = 13; +pub const SIGALRM: c_int = 14; +pub const SIGTERM: c_int = 15; +pub const SIGURG: c_int = 16; +pub const SIGSTOP: c_int = 17; +pub const SIGTSTP: c_int = 18; +pub const SIGCONT: c_int = 19; +pub const SIGCHLD: c_int = 20; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGIO: c_int = 23; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGINFO: c_int = 29; +pub const SIGUSR1: c_int = 30; +pub const SIGUSR2: c_int = 31; +pub const SIGPWR: c_int = 32; + +extern_ty! { + pub enum FILE {} + pub enum fpos_t {} +} + +extern "C" { + // ctype.h + pub fn isalnum(c: c_int) -> c_int; + pub fn isalpha(c: c_int) -> c_int; + pub fn iscntrl(c: c_int) -> c_int; + pub fn isdigit(c: c_int) -> c_int; + pub fn isgraph(c: c_int) -> c_int; + pub fn islower(c: c_int) -> c_int; + pub fn isprint(c: c_int) -> c_int; + pub fn ispunct(c: c_int) -> c_int; + pub fn isspace(c: c_int) -> c_int; + pub fn isupper(c: c_int) -> c_int; + pub fn isxdigit(c: c_int) -> c_int; + pub fn isblank(c: c_int) -> c_int; + pub fn tolower(c: c_int) -> c_int; + pub fn toupper(c: c_int) -> c_int; + + // stdio.h + pub fn __get_stdio_file(fileno: c_int) -> *mut FILE; + pub fn clearerr(arg1: *mut FILE); + pub fn fclose(arg1: *mut FILE) -> c_int; + pub fn feof(arg1: *mut FILE) -> c_int; + pub fn ferror(arg1: *mut FILE) -> c_int; + pub fn fflush(arg1: *mut FILE) -> c_int; + pub fn fgetc(arg1: *mut FILE) -> c_int; + pub fn fgets(arg1: *mut c_char, arg2: c_int, arg3: *mut FILE) -> *mut c_char; + pub fn fopen(arg1: *const c_char, arg2: *const c_char) -> *mut FILE; + pub fn fprintf(arg1: *mut FILE, arg2: *const c_char, ...) -> c_int; + pub fn fputc(arg1: c_int, arg2: *mut FILE) -> c_int; + pub fn fputs(arg1: *const c_char, arg2: *mut FILE) -> c_int; + pub fn fread(arg1: *mut c_void, arg2: size_t, arg3: size_t, arg4: *mut FILE) -> size_t; + pub fn freopen(arg1: *const c_char, arg2: *const c_char, arg3: *mut FILE) -> *mut FILE; + pub fn fscanf(arg1: *mut FILE, arg2: *const c_char, ...) -> c_int; + pub fn fseek(arg1: *mut FILE, arg2: c_long, arg3: c_int) -> c_int; + pub fn ftell(arg1: *mut FILE) -> c_long; + pub fn fwrite(arg1: *const c_void, arg2: size_t, arg3: size_t, arg4: *mut FILE) -> size_t; + pub fn getc(arg1: *mut FILE) -> c_int; + pub fn getchar() -> c_int; + pub fn perror(arg1: *const c_char); + pub fn printf(arg1: *const c_char, ...) -> c_int; + pub fn putc(arg1: c_int, arg2: *mut FILE) -> c_int; + pub fn putchar(arg1: c_int) -> c_int; + pub fn puts(arg1: *const c_char) -> c_int; + pub fn remove(arg1: *const c_char) -> c_int; + pub fn rewind(arg1: *mut FILE); + pub fn scanf(arg1: *const c_char, ...) -> c_int; + pub fn setbuf(arg1: *mut FILE, arg2: *mut c_char); + pub fn setvbuf(arg1: *mut FILE, arg2: *mut c_char, arg3: c_int, arg4: size_t) -> c_int; + pub fn sscanf(arg1: *const c_char, arg2: *const c_char, ...) -> c_int; + pub fn tmpfile() -> *mut FILE; + pub fn ungetc(arg1: c_int, arg2: *mut FILE) -> c_int; + pub fn vfprintf(arg1: *mut FILE, arg2: *const c_char, arg3: __va_list) -> c_int; + pub fn vprintf(arg1: *const c_char, arg2: __va_list) -> c_int; + pub fn gets(arg1: *mut c_char) -> *mut c_char; + pub fn sprintf(arg1: *mut c_char, arg2: *const c_char, ...) -> c_int; + pub fn tmpnam(arg1: *const c_char) -> *mut c_char; + pub fn vsprintf(arg1: *mut c_char, arg2: *const c_char, arg3: __va_list) -> c_int; + pub fn rename(arg1: *const c_char, arg2: *const c_char) -> c_int; + pub fn asiprintf(arg1: *mut *mut c_char, arg2: *const c_char, ...) -> c_int; + pub fn fiprintf(arg1: *mut FILE, arg2: *const c_char, ...) -> c_int; + pub fn fiscanf(arg1: *mut FILE, arg2: *const c_char, ...) -> c_int; + pub fn iprintf(arg1: *const c_char, ...) -> c_int; + pub fn iscanf(arg1: *const c_char, ...) -> c_int; + pub fn siprintf(arg1: *mut c_char, arg2: *const c_char, ...) -> c_int; + pub fn siscanf(arg1: *mut c_char, arg2: *const c_char, ...) -> c_int; + pub fn sniprintf(arg1: *mut c_char, arg2: size_t, arg3: *const c_char, ...) -> c_int; + pub fn vasiprintf(arg1: *mut *mut c_char, arg2: *const c_char, arg3: __va_list) -> c_int; + pub fn vfiprintf(arg1: *mut FILE, arg2: *const c_char, arg3: __va_list) -> c_int; + pub fn vfiscanf(arg1: *mut FILE, arg2: *const c_char, arg3: __va_list) -> c_int; + pub fn viprintf(arg1: *const c_char, arg2: __va_list) -> c_int; + pub fn viscanf(arg1: *const c_char, arg2: __va_list) -> c_int; + pub fn vsiprintf(arg1: *mut c_char, arg2: *const c_char, arg3: __va_list) -> c_int; + pub fn vsiscanf(arg1: *const c_char, arg2: *const c_char, arg3: __va_list) -> c_int; + pub fn vsniprintf( + arg1: *mut c_char, + arg2: size_t, + arg3: *const c_char, + arg4: __va_list, + ) -> c_int; + pub fn vdiprintf(arg1: c_int, arg2: *const c_char, arg3: __va_list) -> c_int; + pub fn diprintf(arg1: c_int, arg2: *const c_char, ...) -> c_int; + pub fn fgetpos(arg1: *mut FILE, arg2: *mut fpos_t) -> c_int; + pub fn fsetpos(arg1: *mut FILE, arg2: *const fpos_t) -> c_int; + pub fn fdopen(arg1: c_int, arg2: *const c_char) -> *mut FILE; + pub fn fileno(arg1: *mut FILE) -> c_int; + pub fn flockfile(arg1: *mut FILE); + pub fn ftrylockfile(arg1: *mut FILE) -> c_int; + pub fn funlockfile(arg1: *mut FILE); + pub fn getc_unlocked(arg1: *mut FILE) -> c_int; + pub fn getchar_unlocked() -> c_int; + pub fn putc_unlocked(arg1: c_int, arg2: *mut FILE) -> c_int; + pub fn putchar_unlocked(arg1: c_int) -> c_int; + pub fn snprintf(arg1: *mut c_char, arg2: size_t, arg3: *const c_char, ...) -> c_int; + pub fn vsnprintf( + arg1: *mut c_char, + arg2: size_t, + arg3: *const c_char, + arg4: __va_list, + ) -> c_int; + pub fn getw(arg1: *mut FILE) -> c_int; + pub fn putw(arg1: c_int, arg2: *mut FILE) -> c_int; + pub fn tempnam(arg1: *const c_char, arg2: *const c_char) -> *mut c_char; + pub fn fseeko(stream: *mut FILE, offset: off_t, whence: c_int) -> c_int; + pub fn ftello(stream: *mut FILE) -> off_t; + + // stdlib.h + pub fn atof(arg1: *const c_char) -> f64; + pub fn strtod(arg1: *const c_char, arg2: *mut *mut c_char) -> f64; + pub fn drand48() -> f64; + pub fn erand48(arg1: *mut c_ushort) -> f64; + pub fn strtof(arg1: *const c_char, arg2: *mut *mut c_char) -> f32; + pub fn strtold(arg1: *const c_char, arg2: *mut *mut c_char) -> f64; + pub fn strtod_l(arg1: *const c_char, arg2: *mut *mut c_char, arg3: locale_t) -> f64; + pub fn strtof_l(arg1: *const c_char, arg2: *mut *mut c_char, arg3: locale_t) -> f32; + pub fn strtold_l(arg1: *const c_char, arg2: *mut *mut c_char, arg3: locale_t) -> f64; + pub fn _Exit(arg1: c_int) -> !; + pub fn abort() -> !; + pub fn abs(arg1: c_int) -> c_int; + pub fn atexit(arg1: Option) -> c_int; + pub fn atoi(arg1: *const c_char) -> c_int; + pub fn atol(arg1: *const c_char) -> c_long; + pub fn itoa(arg1: c_int, arg2: *mut c_char, arg3: c_int) -> *mut c_char; + pub fn ltoa(arg1: c_long, arg2: *mut c_char, arg3: c_int) -> *mut c_char; + pub fn ultoa(arg1: c_ulong, arg2: *mut c_char, arg3: c_int) -> *mut c_char; + pub fn bsearch( + arg1: *const c_void, + arg2: *const c_void, + arg3: size_t, + arg4: size_t, + arg5: Option c_int>, + ) -> *mut c_void; + pub fn calloc(arg1: size_t, arg2: size_t) -> *mut c_void; + pub fn div(arg1: c_int, arg2: c_int) -> div_t; + pub fn exit(arg1: c_int) -> !; + pub fn free(arg1: *mut c_void); + pub fn getenv(arg1: *const c_char) -> *mut c_char; + pub fn labs(arg1: c_long) -> c_long; + pub fn ldiv(arg1: c_long, arg2: c_long) -> ldiv_t; + pub fn malloc(arg1: size_t) -> *mut c_void; + pub fn qsort( + arg1: *mut c_void, + arg2: size_t, + arg3: size_t, + arg4: Option c_int>, + ); + pub fn rand() -> c_int; + pub fn realloc(arg1: *mut c_void, arg2: size_t) -> *mut c_void; + pub fn srand(arg1: c_uint); + pub fn strtol(arg1: *const c_char, arg2: *mut *mut c_char, arg3: c_int) -> c_long; + pub fn strtoul(arg1: *const c_char, arg2: *mut *mut c_char, arg3: c_int) -> c_ulong; + pub fn mblen(arg1: *const c_char, arg2: size_t) -> c_int; + pub fn mbstowcs(arg1: *mut wchar_t, arg2: *const c_char, arg3: size_t) -> size_t; + pub fn wctomb(arg1: *mut c_char, arg2: wchar_t) -> c_int; + pub fn mbtowc(arg1: *mut wchar_t, arg2: *const c_char, arg3: size_t) -> c_int; + pub fn wcstombs(arg1: *mut c_char, arg2: *const wchar_t, arg3: size_t) -> size_t; + pub fn rand_r(arg1: *mut c_uint) -> c_int; + pub fn jrand48(arg1: *mut c_ushort) -> c_long; + pub fn lcong48(arg1: *mut c_ushort); + pub fn lrand48() -> c_long; + pub fn mrand48() -> c_long; + pub fn nrand48(arg1: *mut c_ushort) -> c_long; + pub fn seed48(arg1: *mut c_ushort) -> *mut c_ushort; + pub fn srand48(arg1: c_long); + pub fn putenv(arg1: *mut c_char) -> c_int; + pub fn a64l(arg1: *const c_char) -> c_long; + pub fn l64a(arg1: c_long) -> *mut c_char; + pub fn random() -> c_long; + pub fn setstate(arg1: *mut c_char) -> *mut c_char; + pub fn initstate(arg1: c_uint, arg2: *mut c_char, arg3: size_t) -> *mut c_char; + pub fn srandom(arg1: c_uint); + pub fn mkostemp(arg1: *mut c_char, arg2: c_int) -> c_int; + pub fn mkostemps(arg1: *mut c_char, arg2: c_int, arg3: c_int) -> c_int; + pub fn mkdtemp(arg1: *mut c_char) -> *mut c_char; + pub fn mkstemp(arg1: *mut c_char) -> c_int; + pub fn mktemp(arg1: *mut c_char) -> *mut c_char; + pub fn atoll(arg1: *const c_char) -> c_longlong; + pub fn llabs(arg1: c_longlong) -> c_longlong; + pub fn lldiv(arg1: c_longlong, arg2: c_longlong) -> lldiv_t; + pub fn strtoll(arg1: *const c_char, arg2: *mut *mut c_char, arg3: c_int) -> c_longlong; + pub fn strtoull(arg1: *const c_char, arg2: *mut *mut c_char, arg3: c_int) -> c_ulonglong; + pub fn aligned_alloc(arg1: size_t, arg2: size_t) -> *mut c_void; + pub fn at_quick_exit(arg1: Option) -> c_int; + pub fn quick_exit(arg1: c_int); + pub fn setenv(arg1: *const c_char, arg2: *const c_char, arg3: c_int) -> c_int; + pub fn unsetenv(arg1: *const c_char) -> c_int; + pub fn humanize_number( + arg1: *mut c_char, + arg2: size_t, + arg3: i64, + arg4: *const c_char, + arg5: c_int, + arg6: c_int, + ) -> c_int; + pub fn dehumanize_number(arg1: *const c_char, arg2: *mut i64) -> c_int; + pub fn getenv_r(arg1: *const c_char, arg2: *mut c_char, arg3: size_t) -> c_int; + pub fn heapsort( + arg1: *mut c_void, + arg2: size_t, + arg3: size_t, + arg4: Option c_int>, + ) -> c_int; + pub fn mergesort( + arg1: *mut c_void, + arg2: size_t, + arg3: size_t, + arg4: Option c_int>, + ) -> c_int; + pub fn radixsort( + arg1: *mut *const c_uchar, + arg2: c_int, + arg3: *const c_uchar, + arg4: c_uint, + ) -> c_int; + pub fn sradixsort( + arg1: *mut *const c_uchar, + arg2: c_int, + arg3: *const c_uchar, + arg4: c_uint, + ) -> c_int; + pub fn getprogname() -> *const c_char; + pub fn setprogname(arg1: *const c_char); + pub fn qabs(arg1: quad_t) -> quad_t; + pub fn strtoq(arg1: *const c_char, arg2: *mut *mut c_char, arg3: c_int) -> quad_t; + pub fn strtouq(arg1: *const c_char, arg2: *mut *mut c_char, arg3: c_int) -> u_quad_t; + pub fn strsuftoll( + arg1: *const c_char, + arg2: *const c_char, + arg3: c_longlong, + arg4: c_longlong, + ) -> c_longlong; + pub fn strsuftollx( + arg1: *const c_char, + arg2: *const c_char, + arg3: c_longlong, + arg4: c_longlong, + arg5: *mut c_char, + arg6: size_t, + ) -> c_longlong; + pub fn l64a_r(arg1: c_long, arg2: *mut c_char, arg3: c_int) -> c_int; + pub fn qdiv(arg1: quad_t, arg2: quad_t) -> qdiv_t; + pub fn strtol_l( + arg1: *const c_char, + arg2: *mut *mut c_char, + arg3: c_int, + arg4: locale_t, + ) -> c_long; + pub fn strtoul_l( + arg1: *const c_char, + arg2: *mut *mut c_char, + arg3: c_int, + arg4: locale_t, + ) -> c_ulong; + pub fn strtoll_l( + arg1: *const c_char, + arg2: *mut *mut c_char, + arg3: c_int, + arg4: locale_t, + ) -> c_longlong; + pub fn strtoull_l( + arg1: *const c_char, + arg2: *mut *mut c_char, + arg3: c_int, + arg4: locale_t, + ) -> c_ulonglong; + pub fn strtoq_l( + arg1: *const c_char, + arg2: *mut *mut c_char, + arg3: c_int, + arg4: locale_t, + ) -> quad_t; + pub fn strtouq_l( + arg1: *const c_char, + arg2: *mut *mut c_char, + arg3: c_int, + arg4: locale_t, + ) -> u_quad_t; + pub fn _mb_cur_max_l(arg1: locale_t) -> size_t; + pub fn mblen_l(arg1: *const c_char, arg2: size_t, arg3: locale_t) -> c_int; + pub fn mbstowcs_l( + arg1: *mut wchar_t, + arg2: *const c_char, + arg3: size_t, + arg4: locale_t, + ) -> size_t; + pub fn wctomb_l(arg1: *mut c_char, arg2: wchar_t, arg3: locale_t) -> c_int; + pub fn mbtowc_l(arg1: *mut wchar_t, arg2: *const c_char, arg3: size_t, arg4: locale_t) + -> c_int; + pub fn wcstombs_l( + arg1: *mut c_char, + arg2: *const wchar_t, + arg3: size_t, + arg4: locale_t, + ) -> size_t; + + // string.h + pub fn memchr(arg1: *const c_void, arg2: c_int, arg3: size_t) -> *mut c_void; + pub fn memcmp(arg1: *const c_void, arg2: *const c_void, arg3: size_t) -> c_int; + pub fn memcpy(arg1: *mut c_void, arg2: *const c_void, arg3: size_t) -> *mut c_void; + pub fn memmove(arg1: *mut c_void, arg2: *const c_void, arg3: size_t) -> *mut c_void; + pub fn memset(arg1: *mut c_void, arg2: c_int, arg3: size_t) -> *mut c_void; + pub fn strcat(arg1: *mut c_char, arg2: *const c_char) -> *mut c_char; + pub fn strchr(arg1: *const c_char, arg2: c_int) -> *mut c_char; + pub fn strcmp(arg1: *const c_char, arg2: *const c_char) -> c_int; + pub fn strcoll(arg1: *const c_char, arg2: *const c_char) -> c_int; + pub fn strcpy(arg1: *mut c_char, arg2: *const c_char) -> *mut c_char; + pub fn strcspn(arg1: *const c_char, arg2: *const c_char) -> size_t; + pub fn strerror(arg1: c_int) -> *mut c_char; + pub fn strlen(arg1: *const c_char) -> size_t; + pub fn strncat(arg1: *mut c_char, arg2: *const c_char, arg3: size_t) -> *mut c_char; + pub fn strncmp(arg1: *const c_char, arg2: *const c_char, arg3: size_t) -> c_int; + pub fn strncpy(arg1: *mut c_char, arg2: *const c_char, arg3: size_t) -> *mut c_char; + pub fn strpbrk(arg1: *const c_char, arg2: *const c_char) -> *mut c_char; + pub fn strrchr(arg1: *const c_char, arg2: c_int) -> *mut c_char; + pub fn strspn(arg1: *const c_char, arg2: *const c_char) -> size_t; + pub fn strstr(arg1: *const c_char, arg2: *const c_char) -> *mut c_char; + pub fn strtok(arg1: *mut c_char, arg2: *const c_char) -> *mut c_char; + pub fn strtok_r(arg1: *mut c_char, arg2: *const c_char, arg3: *mut *mut c_char) -> *mut c_char; + pub fn strerror_r(arg1: c_int, arg2: *mut c_char, arg3: size_t) -> c_int; + pub fn strxfrm(arg1: *mut c_char, arg2: *const c_char, arg3: size_t) -> size_t; + pub fn memccpy( + arg1: *mut c_void, + arg2: *const c_void, + arg3: c_int, + arg4: size_t, + ) -> *mut c_void; + pub fn strdup(arg1: *const c_char) -> *mut c_char; + pub fn stpcpy(arg1: *mut c_char, arg2: *const c_char) -> *mut c_char; + pub fn stpncpy(arg1: *mut c_char, arg2: *const c_char, arg3: size_t) -> *mut c_char; + pub fn strnlen(arg1: *const c_char, arg2: size_t) -> size_t; + pub fn memmem( + arg1: *const c_void, + arg2: size_t, + arg3: *const c_void, + arg4: size_t, + ) -> *mut c_void; + pub fn strcasestr(arg1: *const c_char, arg2: *const c_char) -> *mut c_char; + pub fn strlcat(arg1: *mut c_char, arg2: *const c_char, arg3: size_t) -> size_t; + pub fn strlcpy(arg1: *mut c_char, arg2: *const c_char, arg3: size_t) -> size_t; + pub fn strsep(arg1: *mut *mut c_char, arg2: *const c_char) -> *mut c_char; + pub fn stresep(arg1: *mut *mut c_char, arg2: *const c_char, arg3: c_int) -> *mut c_char; + pub fn strndup(arg1: *const c_char, arg2: size_t) -> *mut c_char; + pub fn memrchr(arg1: *const c_void, arg2: c_int, arg3: size_t) -> *mut c_void; + pub fn explicit_memset(arg1: *mut c_void, arg2: c_int, arg3: size_t) -> *mut c_void; + pub fn consttime_memequal(arg1: *const c_void, arg2: *const c_void, arg3: size_t) -> c_int; + pub fn strcoll_l(arg1: *const c_char, arg2: *const c_char, arg3: locale_t) -> c_int; + pub fn strxfrm_l( + arg1: *mut c_char, + arg2: *const c_char, + arg3: size_t, + arg4: locale_t, + ) -> size_t; + pub fn strerror_l(arg1: c_int, arg2: locale_t) -> *mut c_char; + + // strings.h + pub fn bcmp(arg1: *const c_void, arg2: *const c_void, arg3: size_t) -> c_int; + pub fn bcopy(arg1: *const c_void, arg2: *mut c_void, arg3: size_t); + pub fn bzero(arg1: *mut c_void, arg2: size_t); + pub fn ffs(arg1: c_int) -> c_int; + pub fn popcount(arg1: c_uint) -> c_uint; + pub fn popcountl(arg1: c_ulong) -> c_uint; + pub fn popcountll(arg1: c_ulonglong) -> c_uint; + pub fn popcount32(arg1: u32) -> c_uint; + pub fn popcount64(arg1: u64) -> c_uint; + pub fn rindex(arg1: *const c_char, arg2: c_int) -> *mut c_char; + pub fn strcasecmp(arg1: *const c_char, arg2: *const c_char) -> c_int; + pub fn strncasecmp(arg1: *const c_char, arg2: *const c_char, arg3: size_t) -> c_int; + + // signal.h + pub fn signal(arg1: c_int, arg2: sighandler_t) -> sighandler_t; + pub fn raise(arg1: c_int) -> c_int; + + // time.h + pub fn asctime(arg1: *const tm) -> *mut c_char; + pub fn clock() -> clock_t; + pub fn ctime(arg1: *const time_t) -> *mut c_char; + pub fn difftime(arg1: time_t, arg2: time_t) -> f64; + pub fn gmtime(arg1: *const time_t) -> *mut tm; + pub fn localtime(arg1: *const time_t) -> *mut tm; + pub fn time(arg1: *mut time_t) -> time_t; + pub fn mktime(arg1: *mut tm) -> time_t; + pub fn strftime( + arg1: *mut c_char, + arg2: size_t, + arg3: *const c_char, + arg4: *const tm, + ) -> size_t; + pub fn utime(arg1: *const c_char, arg2: *mut time_t) -> c_int; + pub fn asctime_r(arg1: *const tm, arg2: *mut c_char) -> *mut c_char; + pub fn ctime_r(arg1: *const time_t, arg2: *mut c_char) -> *mut c_char; + pub fn gmtime_r(arg1: *const time_t, arg2: *mut tm) -> *mut tm; + pub fn localtime_r(arg1: *const time_t, arg2: *mut tm) -> *mut tm; + + // sys/stat.h + pub fn stat(arg1: *const c_char, arg2: *mut stat) -> c_int; + pub fn lstat(arg1: *const c_char, arg2: *mut stat) -> c_int; + pub fn fstat(arg1: c_int, arg2: *mut stat) -> c_int; + pub fn chmod(arg1: *const c_char, arg2: __mode_t) -> c_int; + pub fn mkdir(arg1: *const c_char, arg2: __mode_t) -> c_int; + + // fcntl.h + pub fn open(arg1: *const c_char, arg2: c_int, ...) -> c_int; + pub fn creat(arg1: *const c_char, arg2: c_int) -> c_int; + pub fn close(arg1: c_int) -> c_int; + pub fn read(arg1: c_int, arg2: *mut c_void, arg3: c_int) -> c_int; + pub fn write(arg1: c_int, arg2: *const c_void, arg3: c_int) -> c_int; + pub fn unlink(arg1: *const c_char) -> c_int; + pub fn tell(arg1: c_int) -> c_long; + pub fn dup(arg1: c_int) -> c_int; + pub fn dup2(arg1: c_int, arg2: c_int) -> c_int; + pub fn access(arg1: *const c_char, arg2: c_int) -> c_int; + pub fn rmdir(arg1: *const c_char) -> c_int; + pub fn chdir(arg1: *const c_char) -> c_int; + pub fn _exit(arg1: c_int); + pub fn getwd(arg1: *mut c_char) -> *mut c_char; + pub fn getcwd(arg1: *mut c_char, arg2: size_t) -> *mut c_char; + pub static mut optarg: *mut c_char; + pub static mut opterr: c_int; + pub static mut optind: c_int; + pub static mut optopt: c_int; + pub static mut optreset: c_int; + pub fn getopt(arg1: c_int, arg2: *mut *mut c_char, arg3: *const c_char) -> c_int; + pub static mut suboptarg: *mut c_char; + pub fn getsubopt( + arg1: *mut *mut c_char, + arg2: *const *mut c_char, + arg3: *mut *mut c_char, + ) -> c_int; + pub fn fcntl(arg1: c_int, arg2: c_int, ...) -> c_int; + pub fn getpid() -> pid_t; + pub fn sleep(arg1: c_uint) -> c_uint; + pub fn usleep(arg1: useconds_t) -> c_int; + + // locale.h + pub fn localeconv() -> *mut lconv; + pub fn setlocale(arg1: c_int, arg2: *const c_char) -> *mut c_char; + pub fn duplocale(arg1: locale_t) -> locale_t; + pub fn freelocale(arg1: locale_t); + pub fn localeconv_l(arg1: locale_t) -> *mut lconv; + pub fn newlocale(arg1: c_int, arg2: *const c_char, arg3: locale_t) -> locale_t; + + // langinfo.h + pub fn nl_langinfo(item: crate::nl_item) -> *mut c_char; + pub fn nl_langinfo_l(item: crate::nl_item, locale: locale_t) -> *mut c_char; + + // malloc.h + pub fn memalign(align: size_t, size: size_t) -> *mut c_void; + + // sys/types.h + pub fn lseek(arg1: c_int, arg2: __off_t, arg3: c_int) -> __off_t; +} + +cfg_if! { + if #[cfg(target_arch = "aarch64")] { + mod aarch64; + pub use self::aarch64::*; + } else if #[cfg(any(target_arch = "arm"))] { + mod arm; + pub use self::arm::*; + } else { + // Unknown target_arch + } +} diff --git a/http/vendor/libc/src/switch.rs b/http/vendor/libc/src/switch.rs new file mode 100644 index 0000000..2d202dd --- /dev/null +++ b/http/vendor/libc/src/switch.rs @@ -0,0 +1,17 @@ +//! Switch C type definitions +use crate::prelude::*; + +pub type intmax_t = i64; +pub type uintmax_t = u64; + +pub type size_t = usize; +pub type ptrdiff_t = isize; +pub type intptr_t = isize; +pub type uintptr_t = usize; +pub type ssize_t = isize; + +pub type off_t = i64; +pub type wchar_t = u32; + +pub const INT_MIN: c_int = -2147483648; +pub const INT_MAX: c_int = 2147483647; diff --git a/http/vendor/libc/src/teeos/mod.rs b/http/vendor/libc/src/teeos/mod.rs new file mode 100644 index 0000000..89a30a8 --- /dev/null +++ b/http/vendor/libc/src/teeos/mod.rs @@ -0,0 +1,1349 @@ +//! Libc bindings for teeos +//! +//! Apparently the loader just dynamically links it anyway, but fails +//! when linking is explicitly requested. +#![allow(non_camel_case_types)] +#![allow(non_snake_case)] + +use crate::prelude::*; + +pub type c_bool = i32; + +pub type intmax_t = i64; + +pub type uintmax_t = u64; + +pub type size_t = usize; + +pub type ptrdiff_t = isize; + +pub type intptr_t = isize; + +pub type uintptr_t = usize; + +pub type ssize_t = isize; + +pub type pid_t = c_int; + +pub type wchar_t = u32; + +// long double in C means A float point value, which has 128bit length. +// but some bit maybe not used, so the real length of long double could be 80(x86) or 128(power pc/IEEE) +// this is different from f128(not stable and not included default) in Rust, so we use u128 for FFI(Rust to C). +// this is unstable and will cause to memfault/data abort. +pub type c_longdouble = _CLongDouble; + +pub type pthread_t = c_ulong; + +pub type pthread_key_t = c_uint; + +pub type pthread_spinlock_t = c_int; + +pub type off_t = i64; + +pub type time_t = c_long; + +pub type clock_t = c_long; + +pub type clockid_t = c_int; + +pub type suseconds_t = c_long; + +pub type once_fn = extern "C" fn() -> c_void; + +pub type pthread_once_t = c_int; + +pub type va_list = *mut c_char; + +pub type wint_t = c_uint; + +pub type wctype_t = c_ulong; + +pub type cmpfunc = extern "C" fn(x: *const c_void, y: *const c_void) -> c_int; + +s_paren! { + #[repr(align(16))] + pub struct _CLongDouble(pub u128); +} + +s! { + #[repr(align(8))] + pub struct pthread_cond_t { + #[doc(hidden)] + size: [u8; __SIZEOF_PTHREAD_COND_T], + } + + #[repr(align(8))] + pub struct pthread_mutex_t { + #[doc(hidden)] + size: [u8; __SIZEOF_PTHREAD_MUTEX_T], + } + + #[repr(align(4))] + pub struct pthread_mutexattr_t { + #[doc(hidden)] + size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], + } + + #[repr(align(4))] + pub struct pthread_condattr_t { + #[doc(hidden)] + size: [u8; __SIZEOF_PTHREAD_CONDATTR_T], + } + + pub struct pthread_attr_t { + __size: [u64; 7], + } + + pub struct cpu_set_t { + bits: [c_ulong; 128 / size_of::()], + } + + #[derive(Default)] + pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, + } + + #[derive(Default)] + pub struct timeval { + pub tv_sec: time_t, + pub tv_usec: suseconds_t, + } + + pub struct tm { + pub tm_sec: c_int, + pub tm_min: c_int, + pub tm_hour: c_int, + pub tm_mday: c_int, + pub tm_mon: c_int, + pub tm_year: c_int, + pub tm_wday: c_int, + pub tm_yday: c_int, + pub tm_isdst: c_int, + pub __tm_gmtoff: c_long, + pub __tm_zone: *const c_char, + } + + pub struct mbstate_t { + pub __opaque1: c_uint, + pub __opaque2: c_uint, + } + + pub struct sem_t { + pub __val: [c_int; 4 * size_of::() / size_of::()], + } + + pub struct div_t { + pub quot: c_int, + pub rem: c_int, + } +} + +// fcntl +pub const O_CREAT: u32 = 0o100; + +pub const O_EXCL: u32 = 0o200; + +pub const O_NOCTTY: u32 = 0o400; + +pub const O_TRUNC: u32 = 0o1000; + +pub const O_APPEND: u32 = 0o2000; + +pub const O_NONBLOCK: u32 = 0o4000; + +pub const O_DSYNC: u32 = 0o10000; + +pub const O_SYNC: u32 = 0o4010000; + +pub const O_RSYNC: u32 = 0o4010000; + +pub const O_DIRECTORY: u32 = 0o200000; + +pub const O_NOFOLLOW: u32 = 0o400000; + +pub const O_CLOEXEC: u32 = 0o2000000; + +pub const O_ASYNC: u32 = 0o20000; + +pub const O_DIRECT: u32 = 0o40000; + +pub const O_LARGEFILE: u32 = 0o100000; + +pub const O_NOATIME: u32 = 0o1000000; + +pub const O_PATH: u32 = 0o10000000; + +pub const O_TMPFILE: u32 = 0o20200000; + +pub const O_NDELAY: u32 = O_NONBLOCK; + +pub const F_DUPFD: u32 = 0; + +pub const F_GETFD: u32 = 1; + +pub const F_SETFD: u32 = 2; + +pub const F_GETFL: u32 = 3; + +pub const F_SETFL: u32 = 4; + +pub const F_SETOWN: u32 = 8; + +pub const F_GETOWN: u32 = 9; + +pub const F_SETSIG: u32 = 10; + +pub const F_GETSIG: u32 = 11; + +pub const F_GETLK: u32 = 12; + +pub const F_SETLK: u32 = 13; + +pub const F_SETLKW: u32 = 14; + +pub const F_SETOWN_EX: u32 = 15; + +pub const F_GETOWN_EX: u32 = 16; + +pub const F_GETOWNER_UIDS: u32 = 17; + +// mman +pub const MAP_FAILED: u64 = 0xffffffffffffffff; + +pub const MAP_FIXED_NOREPLACE: u32 = 0x100000; + +pub const MAP_SHARED_VALIDATE: u32 = 0x03; + +pub const MAP_SHARED: u32 = 0x01; + +pub const MAP_PRIVATE: u32 = 0x02; + +pub const MAP_TYPE: u32 = 0x0f; + +pub const MAP_FIXED: u32 = 0x10; + +pub const MAP_ANON: u32 = 0x20; + +pub const MAP_ANONYMOUS: u32 = MAP_ANON; + +pub const MAP_NORESERVE: u32 = 0x4000; + +pub const MAP_GROWSDOWN: u32 = 0x0100; + +pub const MAP_DENYWRITE: u32 = 0x0800; + +pub const MAP_EXECUTABLE: u32 = 0x1000; + +pub const MAP_LOCKED: u32 = 0x2000; + +pub const MAP_POPULATE: u32 = 0x8000; + +pub const MAP_NONBLOCK: u32 = 0x10000; + +pub const MAP_STACK: u32 = 0x20000; + +pub const MAP_HUGETLB: u32 = 0x40000; + +pub const MAP_SYNC: u32 = 0x80000; + +pub const MAP_FILE: u32 = 0; + +pub const MAP_HUGE_SHIFT: u32 = 26; + +pub const MAP_HUGE_MASK: u32 = 0x3f; + +pub const MAP_HUGE_16KB: u32 = 14 << 26; + +pub const MAP_HUGE_64KB: u32 = 16 << 26; + +pub const MAP_HUGE_512KB: u32 = 19 << 26; + +pub const MAP_HUGE_1MB: u32 = 20 << 26; + +pub const MAP_HUGE_2MB: u32 = 21 << 26; + +pub const MAP_HUGE_8MB: u32 = 23 << 26; + +pub const MAP_HUGE_16MB: u32 = 24 << 26; + +pub const MAP_HUGE_32MB: u32 = 25 << 26; + +pub const MAP_HUGE_256MB: u32 = 28 << 26; + +pub const MAP_HUGE_512MB: u32 = 29 << 26; + +pub const MAP_HUGE_1GB: u32 = 30 << 26; + +pub const MAP_HUGE_2GB: u32 = 31 << 26; + +pub const MAP_HUGE_16GB: u32 = 34u32 << 26; + +pub const PROT_NONE: u32 = 0; + +pub const PROT_READ: u32 = 1; + +pub const PROT_WRITE: u32 = 2; + +pub const PROT_EXEC: u32 = 4; + +pub const PROT_GROWSDOWN: u32 = 0x01000000; + +pub const PROT_GROWSUP: u32 = 0x02000000; + +pub const MS_ASYNC: u32 = 1; + +pub const MS_INVALIDATE: u32 = 2; + +pub const MS_SYNC: u32 = 4; + +pub const MCL_CURRENT: u32 = 1; + +pub const MCL_FUTURE: u32 = 2; + +pub const MCL_ONFAULT: u32 = 4; + +pub const POSIX_MADV_NORMAL: u32 = 0; + +pub const POSIX_MADV_RANDOM: u32 = 1; + +pub const POSIX_MADV_SEQUENTIAL: u32 = 2; + +pub const POSIX_MADV_WILLNEED: u32 = 3; + +pub const POSIX_MADV_DONTNEED: u32 = 4; + +// wctype +pub const WCTYPE_ALNUM: u64 = 1; + +pub const WCTYPE_ALPHA: u64 = 2; + +pub const WCTYPE_BLANK: u64 = 3; + +pub const WCTYPE_CNTRL: u64 = 4; + +pub const WCTYPE_DIGIT: u64 = 5; + +pub const WCTYPE_GRAPH: u64 = 6; + +pub const WCTYPE_LOWER: u64 = 7; + +pub const WCTYPE_PRINT: u64 = 8; + +pub const WCTYPE_PUNCT: u64 = 9; + +pub const WCTYPE_SPACE: u64 = 10; + +pub const WCTYPE_UPPER: u64 = 11; + +pub const WCTYPE_XDIGIT: u64 = 12; + +// locale +pub const LC_CTYPE: i32 = 0; + +pub const LC_NUMERIC: i32 = 1; + +pub const LC_TIME: i32 = 2; + +pub const LC_COLLATE: i32 = 3; + +pub const LC_MONETARY: i32 = 4; + +pub const LC_MESSAGES: i32 = 5; + +pub const LC_ALL: i32 = 6; + +// pthread +pub const __SIZEOF_PTHREAD_COND_T: usize = 48; + +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; + +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; + +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; + +// errno.h +pub const EPERM: c_int = 1; + +pub const ENOENT: c_int = 2; + +pub const ESRCH: c_int = 3; + +pub const EINTR: c_int = 4; + +pub const EIO: c_int = 5; + +pub const ENXIO: c_int = 6; + +pub const E2BIG: c_int = 7; + +pub const ENOEXEC: c_int = 8; + +pub const EBADF: c_int = 9; + +pub const ECHILD: c_int = 10; + +pub const EAGAIN: c_int = 11; + +pub const ENOMEM: c_int = 12; + +pub const EACCES: c_int = 13; + +pub const EFAULT: c_int = 14; + +pub const ENOTBLK: c_int = 15; + +pub const EBUSY: c_int = 16; + +pub const EEXIST: c_int = 17; + +pub const EXDEV: c_int = 18; + +pub const ENODEV: c_int = 19; + +pub const ENOTDIR: c_int = 20; + +pub const EISDIR: c_int = 21; + +pub const EINVAL: c_int = 22; + +pub const ENFILE: c_int = 23; + +pub const EMFILE: c_int = 24; + +pub const ENOTTY: c_int = 25; + +pub const ETXTBSY: c_int = 26; + +pub const EFBIG: c_int = 27; + +pub const ENOSPC: c_int = 28; + +pub const ESPIPE: c_int = 29; + +pub const EROFS: c_int = 30; + +pub const EMLINK: c_int = 31; + +pub const EPIPE: c_int = 32; + +pub const EDOM: c_int = 33; + +pub const ERANGE: c_int = 34; + +pub const EDEADLK: c_int = 35; + +pub const ENAMETOOLONG: c_int = 36; + +pub const ENOLCK: c_int = 37; + +pub const ENOSYS: c_int = 38; + +pub const ENOTEMPTY: c_int = 39; + +pub const ELOOP: c_int = 40; + +pub const EWOULDBLOCK: c_int = EAGAIN; + +pub const ENOMSG: c_int = 42; + +pub const EIDRM: c_int = 43; + +pub const ECHRNG: c_int = 44; + +pub const EL2NSYNC: c_int = 45; + +pub const EL3HLT: c_int = 46; + +pub const EL3RST: c_int = 47; + +pub const ELNRNG: c_int = 48; + +pub const EUNATCH: c_int = 49; + +pub const ENOCSI: c_int = 50; + +pub const EL2HLT: c_int = 51; + +pub const EBADE: c_int = 52; + +pub const EBADR: c_int = 53; + +pub const EXFULL: c_int = 54; + +pub const ENOANO: c_int = 55; + +pub const EBADRQC: c_int = 56; + +pub const EBADSLT: c_int = 57; + +pub const EDEADLOCK: c_int = EDEADLK; + +pub const EBFONT: c_int = 59; + +pub const ENOSTR: c_int = 60; + +pub const ENODATA: c_int = 61; + +pub const ETIME: c_int = 62; + +pub const ENOSR: c_int = 63; + +pub const ENONET: c_int = 64; + +pub const ENOPKG: c_int = 65; + +pub const EREMOTE: c_int = 66; + +pub const ENOLINK: c_int = 67; + +pub const EADV: c_int = 68; + +pub const ESRMNT: c_int = 69; + +pub const ECOMM: c_int = 70; + +pub const EPROTO: c_int = 71; + +pub const EMULTIHOP: c_int = 72; + +pub const EDOTDOT: c_int = 73; + +pub const EBADMSG: c_int = 74; + +pub const EOVERFLOW: c_int = 75; + +pub const ENOTUNIQ: c_int = 76; + +pub const EBADFD: c_int = 77; + +pub const EREMCHG: c_int = 78; + +pub const ELIBACC: c_int = 79; + +pub const ELIBBAD: c_int = 80; + +pub const ELIBSCN: c_int = 81; + +pub const ELIBMAX: c_int = 82; + +pub const ELIBEXEC: c_int = 83; + +pub const EILSEQ: c_int = 84; + +pub const ERESTART: c_int = 85; + +pub const ESTRPIPE: c_int = 86; + +pub const EUSERS: c_int = 87; + +pub const ENOTSOCK: c_int = 88; + +pub const EDESTADDRREQ: c_int = 89; + +pub const EMSGSIZE: c_int = 90; + +pub const EPROTOTYPE: c_int = 91; + +pub const ENOPROTOOPT: c_int = 92; + +pub const EPROTONOSUPPOR: c_int = 93; + +pub const ESOCKTNOSUPPOR: c_int = 94; + +pub const EOPNOTSUPP: c_int = 95; + +pub const ENOTSUP: c_int = EOPNOTSUPP; + +pub const EPFNOSUPPORT: c_int = 96; + +pub const EAFNOSUPPORT: c_int = 97; + +pub const EADDRINUSE: c_int = 98; + +pub const EADDRNOTAVAIL: c_int = 99; + +pub const ENETDOWN: c_int = 100; + +pub const ENETUNREACH: c_int = 101; + +pub const ENETRESET: c_int = 102; + +pub const ECONNABORTED: c_int = 103; + +pub const ECONNRESET: c_int = 104; + +pub const ENOBUFS: c_int = 105; + +pub const EISCONN: c_int = 106; + +pub const ENOTCONN: c_int = 107; + +pub const ESHUTDOWN: c_int = 108; + +pub const ETOOMANYREFS: c_int = 109; + +pub const ETIMEDOUT: c_int = 110; + +pub const ECONNREFUSED: c_int = 111; + +pub const EHOSTDOWN: c_int = 112; + +pub const EHOSTUNREACH: c_int = 113; + +pub const EALREADY: c_int = 114; + +pub const EINPROGRESS: c_int = 115; + +pub const ESTALE: c_int = 116; + +pub const EUCLEAN: c_int = 117; + +pub const ENOTNAM: c_int = 118; + +pub const ENAVAIL: c_int = 119; + +pub const EISNAM: c_int = 120; + +pub const EREMOTEIO: c_int = 121; + +pub const EDQUOT: c_int = 122; + +pub const ENOMEDIUM: c_int = 123; + +pub const EMEDIUMTYPE: c_int = 124; + +pub const ECANCELED: c_int = 125; + +pub const ENOKEY: c_int = 126; + +pub const EKEYEXPIRED: c_int = 127; + +pub const EKEYREVOKED: c_int = 128; + +pub const EKEYREJECTED: c_int = 129; + +pub const EOWNERDEAD: c_int = 130; + +pub const ENOTRECOVERABLE: c_int = 131; + +pub const ERFKILL: c_int = 132; + +pub const EHWPOISON: c_int = 133; + +// pthread_attr.h +pub const TEESMP_THREAD_ATTR_CA_WILDCARD: c_int = 0; + +pub const TEESMP_THREAD_ATTR_CA_INHERIT: c_int = -1; + +pub const TEESMP_THREAD_ATTR_TASK_ID_INHERIT: c_int = -1; + +pub const TEESMP_THREAD_ATTR_HAS_SHADOW: c_int = 0x1; + +pub const TEESMP_THREAD_ATTR_NO_SHADOW: c_int = 0x0; + +// unistd.h +pub const _SC_ARG_MAX: c_int = 0; + +pub const _SC_CHILD_MAX: c_int = 1; + +pub const _SC_CLK_TCK: c_int = 2; + +pub const _SC_NGROUPS_MAX: c_int = 3; + +pub const _SC_OPEN_MAX: c_int = 4; + +pub const _SC_STREAM_MAX: c_int = 5; + +pub const _SC_TZNAME_MAX: c_int = 6; + +pub const _SC_JOB_CONTROL: c_int = 7; + +pub const _SC_SAVED_IDS: c_int = 8; + +pub const _SC_REALTIME_SIGNALS: c_int = 9; + +pub const _SC_PRIORITY_SCHEDULING: c_int = 10; + +pub const _SC_TIMERS: c_int = 11; + +pub const _SC_ASYNCHRONOUS_IO: c_int = 12; + +pub const _SC_PRIORITIZED_IO: c_int = 13; + +pub const _SC_SYNCHRONIZED_IO: c_int = 14; + +pub const _SC_FSYNC: c_int = 15; + +pub const _SC_MAPPED_FILES: c_int = 16; + +pub const _SC_MEMLOCK: c_int = 17; + +pub const _SC_MEMLOCK_RANGE: c_int = 18; + +pub const _SC_MEMORY_PROTECTION: c_int = 19; + +pub const _SC_MESSAGE_PASSING: c_int = 20; + +pub const _SC_SEMAPHORES: c_int = 21; + +pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 22; + +pub const _SC_AIO_LISTIO_MAX: c_int = 23; + +pub const _SC_AIO_MAX: c_int = 24; + +pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 25; + +pub const _SC_DELAYTIMER_MAX: c_int = 26; + +pub const _SC_MQ_OPEN_MAX: c_int = 27; + +pub const _SC_MQ_PRIO_MAX: c_int = 28; + +pub const _SC_VERSION: c_int = 29; + +pub const _SC_PAGE_SIZE: c_int = 30; + +pub const _SC_PAGESIZE: c_int = 30; /* !! */ + +pub const _SC_RTSIG_MAX: c_int = 31; + +pub const _SC_SEM_NSEMS_MAX: c_int = 32; + +pub const _SC_SEM_VALUE_MAX: c_int = 33; + +pub const _SC_SIGQUEUE_MAX: c_int = 34; + +pub const _SC_TIMER_MAX: c_int = 35; + +pub const _SC_BC_BASE_MAX: c_int = 36; + +pub const _SC_BC_DIM_MAX: c_int = 37; + +pub const _SC_BC_SCALE_MAX: c_int = 38; + +pub const _SC_BC_STRING_MAX: c_int = 39; + +pub const _SC_COLL_WEIGHTS_MAX: c_int = 40; + +pub const _SC_EXPR_NEST_MAX: c_int = 42; + +pub const _SC_LINE_MAX: c_int = 43; + +pub const _SC_RE_DUP_MAX: c_int = 44; + +pub const _SC_2_VERSION: c_int = 46; + +pub const _SC_2_C_BIND: c_int = 47; + +pub const _SC_2_C_DEV: c_int = 48; + +pub const _SC_2_FORT_DEV: c_int = 49; + +pub const _SC_2_FORT_RUN: c_int = 50; + +pub const _SC_2_SW_DEV: c_int = 51; + +pub const _SC_2_LOCALEDEF: c_int = 52; + +pub const _SC_UIO_MAXIOV: c_int = 60; /* !! */ + +pub const _SC_IOV_MAX: c_int = 60; + +pub const _SC_THREADS: c_int = 67; + +pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 68; + +pub const _SC_GETGR_R_SIZE_MAX: c_int = 69; + +pub const _SC_GETPW_R_SIZE_MAX: c_int = 70; + +pub const _SC_LOGIN_NAME_MAX: c_int = 71; + +pub const _SC_TTY_NAME_MAX: c_int = 72; + +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 73; + +pub const _SC_THREAD_KEYS_MAX: c_int = 74; + +pub const _SC_THREAD_STACK_MIN: c_int = 75; + +pub const _SC_THREAD_THREADS_MAX: c_int = 76; + +pub const _SC_THREAD_ATTR_STACKADDR: c_int = 77; + +pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 78; + +pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 79; + +pub const _SC_THREAD_PRIO_INHERIT: c_int = 80; + +pub const _SC_THREAD_PRIO_PROTECT: c_int = 81; + +pub const _SC_THREAD_PROCESS_SHARED: c_int = 82; + +pub const _SC_NPROCESSORS_CONF: c_int = 83; + +pub const _SC_NPROCESSORS_ONLN: c_int = 84; + +pub const _SC_PHYS_PAGES: c_int = 85; + +pub const _SC_AVPHYS_PAGES: c_int = 86; + +pub const _SC_ATEXIT_MAX: c_int = 87; + +pub const _SC_PASS_MAX: c_int = 88; + +pub const _SC_XOPEN_VERSION: c_int = 89; + +pub const _SC_XOPEN_XCU_VERSION: c_int = 90; + +pub const _SC_XOPEN_UNIX: c_int = 91; + +pub const _SC_XOPEN_CRYPT: c_int = 92; + +pub const _SC_XOPEN_ENH_I18N: c_int = 93; + +pub const _SC_XOPEN_SHM: c_int = 94; + +pub const _SC_2_CHAR_TERM: c_int = 95; + +pub const _SC_2_UPE: c_int = 97; + +pub const _SC_XOPEN_XPG2: c_int = 98; + +pub const _SC_XOPEN_XPG3: c_int = 99; + +pub const _SC_XOPEN_XPG4: c_int = 100; + +pub const _SC_NZERO: c_int = 109; + +pub const _SC_XBS5_ILP32_OFF32: c_int = 125; + +pub const _SC_XBS5_ILP32_OFFBIG: c_int = 126; + +pub const _SC_XBS5_LP64_OFF64: c_int = 127; + +pub const _SC_XBS5_LPBIG_OFFBIG: c_int = 128; + +pub const _SC_XOPEN_LEGACY: c_int = 129; + +pub const _SC_XOPEN_REALTIME: c_int = 130; + +pub const _SC_XOPEN_REALTIME_THREADS: c_int = 131; + +pub const _SC_ADVISORY_INFO: c_int = 132; + +pub const _SC_BARRIERS: c_int = 133; + +pub const _SC_CLOCK_SELECTION: c_int = 137; + +pub const _SC_CPUTIME: c_int = 138; + +pub const _SC_THREAD_CPUTIME: c_int = 139; + +pub const _SC_MONOTONIC_CLOCK: c_int = 149; + +pub const _SC_READER_WRITER_LOCKS: c_int = 153; + +pub const _SC_SPIN_LOCKS: c_int = 154; + +pub const _SC_REGEXP: c_int = 155; + +pub const _SC_SHELL: c_int = 157; + +pub const _SC_SPAWN: c_int = 159; + +pub const _SC_SPORADIC_SERVER: c_int = 160; + +pub const _SC_THREAD_SPORADIC_SERVER: c_int = 161; + +pub const _SC_TIMEOUTS: c_int = 164; + +pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 165; + +pub const _SC_2_PBS: c_int = 168; + +pub const _SC_2_PBS_ACCOUNTING: c_int = 169; + +pub const _SC_2_PBS_LOCATE: c_int = 170; + +pub const _SC_2_PBS_MESSAGE: c_int = 171; + +pub const _SC_2_PBS_TRACK: c_int = 172; + +pub const _SC_SYMLOOP_MAX: c_int = 173; + +pub const _SC_STREAMS: c_int = 174; + +pub const _SC_2_PBS_CHECKPOINT: c_int = 175; + +pub const _SC_V6_ILP32_OFF32: c_int = 176; + +pub const _SC_V6_ILP32_OFFBIG: c_int = 177; + +pub const _SC_V6_LP64_OFF64: c_int = 178; + +pub const _SC_V6_LPBIG_OFFBIG: c_int = 179; + +pub const _SC_HOST_NAME_MAX: c_int = 180; + +pub const _SC_TRACE: c_int = 181; + +pub const _SC_TRACE_EVENT_FILTER: c_int = 182; + +pub const _SC_TRACE_INHERIT: c_int = 183; + +pub const _SC_TRACE_LOG: c_int = 184; + +pub const _SC_IPV6: c_int = 235; + +pub const _SC_RAW_SOCKETS: c_int = 236; + +pub const _SC_V7_ILP32_OFF32: c_int = 237; + +pub const _SC_V7_ILP32_OFFBIG: c_int = 238; + +pub const _SC_V7_LP64_OFF64: c_int = 239; + +pub const _SC_V7_LPBIG_OFFBIG: c_int = 240; + +pub const _SC_SS_REPL_MAX: c_int = 241; + +pub const _SC_TRACE_EVENT_NAME_MAX: c_int = 242; + +pub const _SC_TRACE_NAME_MAX: c_int = 243; + +pub const _SC_TRACE_SYS_MAX: c_int = 244; + +pub const _SC_TRACE_USER_EVENT_MAX: c_int = 245; + +pub const _SC_XOPEN_STREAMS: c_int = 246; + +pub const _SC_THREAD_ROBUST_PRIO_INHERIT: c_int = 247; + +pub const _SC_THREAD_ROBUST_PRIO_PROTECT: c_int = 248; + +// limits.h +pub const PTHREAD_KEYS_MAX: c_int = 128; + +pub const PTHREAD_STACK_MIN: c_int = 2048; + +pub const PTHREAD_DESTRUCTOR_ITERATIONS: c_int = 4; + +pub const SEM_VALUE_MAX: c_int = 0x7fffffff; + +pub const SEM_NSEMS_MAX: c_int = 256; + +pub const DELAYTIMER_MAX: c_int = 0x7fffffff; + +pub const MQ_PRIO_MAX: c_int = 32768; + +pub const LOGIN_NAME_MAX: c_int = 256; + +// time.h +pub const CLOCK_REALTIME: clockid_t = 0; + +pub const CLOCK_MONOTONIC: clockid_t = 1; + +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + size: [0; __SIZEOF_PTHREAD_MUTEX_T], +}; + +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + size: [0; __SIZEOF_PTHREAD_COND_T], +}; + +pub const PTHREAD_MUTEX_NORMAL: c_int = 0; + +pub const PTHREAD_MUTEX_RECURSIVE: c_int = 1; + +pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 2; + +pub const PTHREAD_MUTEX_DEFAULT: c_int = PTHREAD_MUTEX_NORMAL; + +pub const PTHREAD_MUTEX_STALLED: c_int = 0; + +pub const PTHREAD_MUTEX_ROBUST: c_int = 1; + +extern "C" { + // ---- ALLOC ----------------------------------------------------------------------------- + pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; + + pub fn malloc(size: size_t) -> *mut c_void; + + pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; + + pub fn aligned_alloc(align: size_t, len: size_t) -> *mut c_void; + + pub fn free(p: *mut c_void); + + pub fn posix_memalign(memptr: *mut *mut c_void, align: size_t, size: size_t) -> c_int; + + pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; + + pub fn wmemchr(cx: *const wchar_t, c: wchar_t, n: size_t) -> *mut wchar_t; + + pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int; + + pub fn memcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; + + pub fn memmove(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; + + pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void; + + // ----- PTHREAD --------------------------------------------------------------------------- + pub fn pthread_self() -> pthread_t; + + pub fn pthread_join(native: pthread_t, value: *mut *mut c_void) -> c_int; + + // detach or pthread_attr_setdetachstate must not be called! + //pub fn pthread_detach(thread: pthread_t) -> c_int; + + pub fn pthread_exit(value: *mut c_void) -> !; + + pub fn pthread_attr_init(attr: *mut pthread_attr_t) -> c_int; + + pub fn pthread_attr_destroy(attr: *mut pthread_attr_t) -> c_int; + + pub fn pthread_attr_getstack( + attr: *const pthread_attr_t, + stackaddr: *mut *mut c_void, + stacksize: *mut size_t, + ) -> c_int; + + pub fn pthread_attr_setstacksize(attr: *mut pthread_attr_t, stack_size: size_t) -> c_int; + + pub fn pthread_attr_getstacksize(attr: *const pthread_attr_t, size: *mut size_t) -> c_int; + + pub fn pthread_attr_settee( + attr: *mut pthread_attr_t, + ca: c_int, + task_id: c_int, + shadow: c_int, + ) -> c_int; + + // C-TA API do not include this interface, but TA can use. + pub fn sched_yield() -> c_int; + + pub fn pthread_key_create( + key: *mut pthread_key_t, + dtor: Option, + ) -> c_int; + + pub fn pthread_key_delete(key: pthread_key_t) -> c_int; + + pub fn pthread_getspecific(key: pthread_key_t) -> *mut c_void; + + pub fn pthread_setspecific(key: pthread_key_t, value: *const c_void) -> c_int; + + pub fn pthread_mutex_destroy(lock: *mut pthread_mutex_t) -> c_int; + + pub fn pthread_mutex_init( + lock: *mut pthread_mutex_t, + attr: *const pthread_mutexattr_t, + ) -> c_int; + + pub fn pthread_mutex_lock(lock: *mut pthread_mutex_t) -> c_int; + + pub fn pthread_mutex_trylock(lock: *mut pthread_mutex_t) -> c_int; + + pub fn pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> c_int; + + pub fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> c_int; + + pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> c_int; + + pub fn pthread_mutexattr_settype(attr: *mut pthread_mutexattr_t, _type: c_int) -> c_int; + + pub fn pthread_mutexattr_setpshared(attr: *mut pthread_mutexattr_t, pshared: c_int) -> c_int; + + pub fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> c_int; + + pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> c_int; + + pub fn pthread_cond_init(cond: *mut pthread_cond_t, attr: *const pthread_condattr_t) -> c_int; + + pub fn pthread_cond_signal(cond: *mut pthread_cond_t) -> c_int; + + pub fn pthread_cond_wait(cond: *mut pthread_cond_t, lock: *mut pthread_mutex_t) -> c_int; + + pub fn pthread_cond_timedwait( + cond: *mut pthread_cond_t, + lock: *mut pthread_mutex_t, + abstime: *const timespec, + ) -> c_int; + + pub fn pthread_mutexattr_setrobust(attr: *mut pthread_mutexattr_t, robustness: c_int) -> c_int; + + pub fn pthread_create( + native: *mut pthread_t, + attr: *const pthread_attr_t, + f: extern "C" fn(*mut c_void) -> *mut c_void, + value: *mut c_void, + ) -> c_int; + + pub fn pthread_spin_init(lock: *mut pthread_spinlock_t, pshared: c_int) -> c_int; + + pub fn pthread_spin_destroy(lock: *mut pthread_spinlock_t) -> c_int; + + pub fn pthread_spin_lock(lock: *mut pthread_spinlock_t) -> c_int; + + pub fn pthread_spin_trylock(lock: *mut pthread_spinlock_t) -> c_int; + + pub fn pthread_spin_unlock(lock: *mut pthread_spinlock_t) -> c_int; + + pub fn pthread_setschedprio(native: pthread_t, priority: c_int) -> c_int; + + pub fn pthread_once(pot: *mut pthread_once_t, f: Option) -> c_int; + + pub fn pthread_equal(p1: pthread_t, p2: pthread_t) -> c_int; + + pub fn pthread_mutexattr_setprotocol(a: *mut pthread_mutexattr_t, protocol: c_int) -> c_int; + + pub fn pthread_attr_setstack( + attr: *mut pthread_attr_t, + stack: *mut c_void, + size: size_t, + ) -> c_int; + + pub fn pthread_setaffinity_np(td: pthread_t, size: size_t, set: *const cpu_set_t) -> c_int; + + pub fn pthread_getaffinity_np(td: pthread_t, size: size_t, set: *mut cpu_set_t) -> c_int; + + // stdio.h + pub fn printf(fmt: *const c_char, ...) -> c_int; + + pub fn scanf(fmt: *const c_char, ...) -> c_int; + + pub fn snprintf(s: *mut c_char, n: size_t, fmt: *const c_char, ...) -> c_int; + + pub fn sprintf(s: *mut c_char, fmt: *const c_char, ...) -> c_int; + + pub fn vsnprintf(s: *mut c_char, n: size_t, fmt: *const c_char, ap: va_list) -> c_int; + + pub fn vsprintf(s: *mut c_char, fmt: *const c_char, ap: va_list) -> c_int; + + // Not available. + //pub fn pthread_setname_np(thread: pthread_t, name: *const c_char) -> c_int; + + pub fn abort() -> !; + + // Not available. + //pub fn prctl(op: c_int, ...) -> c_int; + + pub fn sched_getaffinity(pid: pid_t, cpusetsize: size_t, cpuset: *mut cpu_set_t) -> c_int; + + pub fn sched_setaffinity(pid: pid_t, cpusetsize: size_t, cpuset: *const cpu_set_t) -> c_int; + + // sysconf is currently only implemented as a stub. + pub fn sysconf(name: c_int) -> c_long; + + // mman.h + pub fn mmap( + addr: *mut c_void, + len: size_t, + prot: c_int, + flags: c_int, + fd: c_int, + offset: off_t, + ) -> *mut c_void; + pub fn munmap(addr: *mut c_void, len: size_t) -> c_int; + + // errno.h + pub fn __errno_location() -> *mut c_int; + + pub fn strerror(e: c_int) -> *mut c_char; + + // time.h + pub fn clock_gettime(clock_id: clockid_t, tp: *mut timespec) -> c_int; + + // unistd + pub fn getpid() -> pid_t; + + // time + pub fn gettimeofday(tv: *mut timeval, tz: *mut c_void) -> c_int; + + pub fn strftime( + restrict: *mut c_char, + sz: size_t, + _restrict: *const c_char, + __restrict: *const tm, + ) -> size_t; + + pub fn time(t: *mut time_t) -> time_t; + + // sem + pub fn sem_close(sem: *mut sem_t) -> c_int; + + pub fn sem_destroy(sem: *mut sem_t) -> c_int; + + pub fn sem_getvalue(sem: *mut sem_t, valp: *mut c_int) -> c_int; + + pub fn sem_init(sem: *mut sem_t, pshared: c_int, value: c_uint) -> c_int; + + pub fn sem_open(name: *const c_char, flags: c_int, ...) -> *mut sem_t; + + pub fn sem_post(sem: *mut sem_t) -> c_int; + + pub fn sem_unlink(name: *const c_char) -> c_int; + + pub fn sem_wait(sem: *mut sem_t) -> c_int; + + // locale + pub fn setlocale(cat: c_int, name: *const c_char) -> *mut c_char; + + pub fn strcoll(l: *const c_char, r: *const c_char) -> c_int; + + pub fn strxfrm(dest: *mut c_char, src: *const c_char, n: size_t) -> size_t; + + pub fn strtod(s: *const c_char, p: *mut *mut c_char) -> c_double; + + // multibyte + pub fn mbrtowc(wc: *mut wchar_t, src: *const c_char, n: size_t, st: *mut mbstate_t) -> size_t; + + pub fn wcrtomb(s: *mut c_char, wc: wchar_t, st: *mut mbstate_t) -> size_t; + + pub fn wctob(c: wint_t) -> c_int; + + // prng + pub fn srandom(seed: c_uint); + + pub fn initstate(seed: c_uint, state: *mut c_char, size: size_t) -> *mut c_char; + + pub fn setstate(state: *mut c_char) -> *mut c_char; + + pub fn random() -> c_long; + + // string + pub fn strchr(s: *const c_char, c: c_int) -> *mut c_char; + + pub fn strlen(cs: *const c_char) -> size_t; + + pub fn strcmp(l: *const c_char, r: *const c_char) -> c_int; + + pub fn strcpy(dest: *mut c_char, src: *const c_char) -> *mut c_char; + + pub fn strncmp(_l: *const c_char, r: *const c_char, n: size_t) -> c_int; + + pub fn strncpy(dest: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char; + + pub fn strnlen(cs: *const c_char, n: size_t) -> size_t; + + pub fn strrchr(s: *const c_char, c: c_int) -> *mut c_char; + + pub fn strstr(h: *const c_char, n: *const c_char) -> *mut c_char; + + pub fn wcschr(s: *const wchar_t, c: wchar_t) -> *mut wchar_t; + + pub fn wcslen(s: *const wchar_t) -> size_t; + + // ctype + pub fn isalpha(c: c_int) -> c_int; + + pub fn isascii(c: c_int) -> c_int; + + pub fn isdigit(c: c_int) -> c_int; + + pub fn islower(c: c_int) -> c_int; + + pub fn isprint(c: c_int) -> c_int; + + pub fn isspace(c: c_int) -> c_int; + + pub fn iswctype(wc: wint_t, ttype: wctype_t) -> c_int; + + pub fn iswdigit(wc: wint_t) -> c_int; + + pub fn iswlower(wc: wint_t) -> c_int; + + pub fn iswspace(wc: wint_t) -> c_int; + + pub fn iswupper(wc: wint_t) -> c_int; + + pub fn towupper(wc: wint_t) -> wint_t; + + pub fn towlower(wc: wint_t) -> wint_t; + + // cmath + pub fn atan(x: c_double) -> c_double; + + pub fn ceil(x: c_double) -> c_double; + + pub fn ceilf(x: c_float) -> c_float; + + pub fn exp(x: c_double) -> c_double; + + pub fn fabs(x: c_double) -> c_double; + + pub fn floor(x: c_double) -> c_double; + + pub fn frexp(x: c_double, e: *mut c_int) -> c_double; + + pub fn log(x: c_double) -> c_double; + + pub fn log2(x: c_double) -> c_double; + + pub fn pow(x: c_double, y: c_double) -> c_double; + + pub fn roundf(x: c_float) -> c_float; + + pub fn scalbn(x: c_double, n: c_int) -> c_double; + + pub fn sqrt(x: c_double) -> c_double; + + // stdlib + pub fn abs(x: c_int) -> c_int; + + pub fn atof(s: *const c_char) -> c_double; + + pub fn atoi(s: *const c_char) -> c_int; + + pub fn atol(s: *const c_char) -> c_long; + + pub fn atoll(s: *const c_char) -> c_longlong; + + pub fn bsearch( + key: *const c_void, + base: *const c_void, + nel: size_t, + width: size_t, + cmp: cmpfunc, + ) -> *mut c_void; + + pub fn div(num: c_int, den: c_int) -> div_t; + + pub fn ecvt(x: c_double, n: c_int, dp: *mut c_int, sign: *mut c_int) -> *mut c_char; + + pub fn imaxabs(a: intmax_t) -> intmax_t; + + pub fn llabs(a: c_longlong) -> c_longlong; + + pub fn qsort(base: *mut c_void, nel: size_t, width: size_t, cmp: cmpfunc); + + pub fn strtoul(s: *const c_char, p: *mut *mut c_char, base: c_int) -> c_ulong; + + pub fn strtol(s: *const c_char, p: *mut *mut c_char, base: c_int) -> c_long; + + pub fn wcstod(s: *const wchar_t, p: *mut *mut wchar_t) -> c_double; +} + +pub fn errno() -> c_int { + unsafe { *__errno_location() } +} + +pub fn CPU_COUNT_S(size: usize, cpuset: &cpu_set_t) -> c_int { + let mut s: u32 = 0; + let size_of_mask = size_of_val(&cpuset.bits[0]); + + for i in cpuset.bits[..(size / size_of_mask)].iter() { + s += i.count_ones(); + } + s as c_int +} + +pub fn CPU_COUNT(cpuset: &cpu_set_t) -> c_int { + CPU_COUNT_S(size_of::(), cpuset) +} diff --git a/http/vendor/libc/src/trusty.rs b/http/vendor/libc/src/trusty.rs new file mode 100644 index 0000000..2cb2d5e --- /dev/null +++ b/http/vendor/libc/src/trusty.rs @@ -0,0 +1,73 @@ +use crate::prelude::*; +pub type size_t = usize; +pub type ssize_t = isize; + +pub type off_t = i64; + +pub type c_uint8_t = u8; +pub type c_uint16_t = u16; +pub type c_uint32_t = u32; +pub type c_uint64_t = u64; + +pub type c_int8_t = i8; +pub type c_int16_t = i16; +pub type c_int32_t = i32; +pub type c_int64_t = i64; + +pub type intptr_t = isize; +pub type uintptr_t = usize; + +pub type time_t = c_long; + +pub type clockid_t = c_int; + +s! { + pub struct iovec { + pub iov_base: *mut c_void, + pub iov_len: size_t, + } + + #[derive(Default)] + pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, + } +} + +pub const PROT_READ: i32 = 1; +pub const PROT_WRITE: i32 = 2; + +// Trusty only supports `CLOCK_BOOTTIME`. +pub const CLOCK_BOOTTIME: clockid_t = 7; + +pub const STDOUT_FILENO: c_int = 1; +pub const STDERR_FILENO: c_int = 2; + +pub const AT_PAGESZ: c_ulong = 6; + +pub const MAP_FAILED: *mut c_void = !0 as *mut c_void; + +extern "C" { + pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; + pub fn malloc(size: size_t) -> *mut c_void; + pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; + pub fn free(p: *mut c_void); + pub fn memalign(align: size_t, size: size_t) -> *mut c_void; + pub fn posix_memalign(memptr: *mut *mut c_void, align: size_t, size: size_t) -> c_int; + pub fn write(fd: c_int, buf: *const c_void, count: size_t) -> ssize_t; + pub fn writev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; + pub fn close(fd: c_int) -> c_int; + pub fn strlen(cs: *const c_char) -> size_t; + pub fn getauxval(type_: c_ulong) -> c_ulong; + pub fn mmap( + addr: *mut c_void, + len: size_t, + prot: c_int, + flags: c_int, + fd: c_int, + offset: off_t, + ) -> *mut c_void; + pub fn munmap(addr: *mut c_void, len: size_t) -> c_int; + pub fn clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; + pub fn nanosleep(rqtp: *const crate::timespec, rmtp: *mut crate::timespec) -> c_int; +} diff --git a/http/vendor/libc/src/types.rs b/http/vendor/libc/src/types.rs new file mode 100644 index 0000000..d786d2c --- /dev/null +++ b/http/vendor/libc/src/types.rs @@ -0,0 +1,67 @@ +//! Platform-agnostic support types. + +#[cfg(feature = "extra_traits")] +use core::hash::Hash; +use core::mem::MaybeUninit; + +use crate::prelude::*; + +/// A transparent wrapper over `MaybeUninit` to represent uninitialized padding +/// while providing `Default`. +// This is restricted to `Copy` types since that's a loose indicator that zeros is actually +// a valid bitpattern. There is no technical reason this is required, though, so it could be +// lifted in the future if it becomes a problem. +#[allow(dead_code)] +#[repr(transparent)] +#[derive(Clone, Copy)] +pub(crate) struct Padding(MaybeUninit); + +impl Default for Padding { + fn default() -> Self { + Self(MaybeUninit::zeroed()) + } +} + +impl Padding { + /// Create a `Padding` initialized with the given value. + #[allow(dead_code)] + pub(crate) const fn new(val: T) -> Self { + Self(MaybeUninit::new(val)) + } +} + +impl fmt::Debug for Padding { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + // Taken from `MaybeUninit`'s debug implementation + // NB: there is no `.pad_fmt` so we can't use a simpler `format_args!("Padding<{..}>"). + let full_name = core::any::type_name::(); + let prefix_len = full_name.find("Padding").unwrap(); + f.pad(&full_name[prefix_len..]) + } +} + +/// Do nothing when hashing to ignore the existence of padding fields. +#[cfg(feature = "extra_traits")] +impl Hash for Padding { + fn hash(&self, _state: &mut H) {} +} + +/// Padding fields are all equal, regardless of what is inside them, so they do not affect anything. +#[cfg(feature = "extra_traits")] +impl PartialEq for Padding { + fn eq(&self, _other: &Self) -> bool { + true + } +} + +/// Mark that `Padding` implements `Eq` so that it can be used in types that implement it. +#[cfg(feature = "extra_traits")] +impl Eq for Padding {} + +/// The default repr type used for C style enums in Rust. +#[cfg(target_env = "msvc")] +#[allow(unused)] +pub(crate) type CEnumRepr = c_int; +#[cfg(not(target_env = "msvc"))] +#[allow(unused)] +pub(crate) type CEnumRepr = c_uint; diff --git a/http/vendor/libc/src/unix/aix/mod.rs b/http/vendor/libc/src/unix/aix/mod.rs new file mode 100644 index 0000000..71d041f --- /dev/null +++ b/http/vendor/libc/src/unix/aix/mod.rs @@ -0,0 +1,3363 @@ +use crate::prelude::*; +use crate::{ + in_addr_t, + in_port_t, +}; + +pub type caddr_t = *mut c_char; +pub type clockid_t = c_longlong; +pub type blkcnt_t = c_long; +pub type clock_t = c_int; +pub type daddr_t = c_long; +pub type dev_t = c_ulong; +pub type fpos64_t = c_longlong; +pub type fsblkcnt_t = c_ulong; +pub type fsfilcnt_t = c_ulong; +pub type ino_t = c_ulong; +pub type key_t = c_int; +pub type mode_t = c_uint; +pub type nlink_t = c_short; +pub type rlim_t = c_ulong; +pub type speed_t = c_uint; +pub type tcflag_t = c_uint; +pub type time_t = c_long; +pub type time64_t = i64; +pub type timer_t = c_long; +pub type wchar_t = c_uint; +pub type nfds_t = c_uint; +pub type projid_t = c_int; +pub type id_t = c_uint; +pub type blksize64_t = c_ulonglong; +pub type blkcnt64_t = c_ulonglong; +pub type suseconds_t = c_int; +pub type useconds_t = c_uint; +pub type off_t = c_long; +pub type offset_t = c_longlong; +pub type off64_t = c_longlong; +pub type idtype_t = c_uint; + +pub type socklen_t = c_uint; +pub type sa_family_t = c_uchar; + +pub type signal_t = c_int; +pub type pthread_t = c_uint; +pub type pthread_key_t = c_uint; +pub type thread_t = pthread_t; +pub type blksize_t = c_long; +pub type nl_item = c_int; +pub type mqd_t = c_int; +pub type shmatt_t = c_ulong; +pub type regoff_t = c_long; +pub type rlim64_t = c_ulonglong; + +pub type sem_t = c_int; +pub type pollset_t = c_int; +pub type sctp_assoc_t = c_uint; + +pub type pthread_rwlockattr_t = *mut c_void; +pub type pthread_condattr_t = *mut c_void; +pub type pthread_mutexattr_t = *mut c_void; +pub type pthread_attr_t = *mut c_void; +pub type pthread_barrierattr_t = *mut c_void; +pub type posix_spawn_file_actions_t = *mut c_char; +pub type iconv_t = *mut c_void; + +e! { + #[repr(u32)] + pub enum uio_rw { + UIO_READ = 0, + UIO_WRITE, + UIO_READ_NO_MOVE, + UIO_WRITE_NO_MOVE, + UIO_PWRITE, + } + #[repr(u32)] + pub enum ACTION { + FIND = 0, + ENTER, + } +} + +s! { + pub struct fsid_t { + pub val: [c_uint; 2], + } + + pub struct fsid64_t { + pub val: [crate::uint64_t; 2], + } + + pub struct timezone { + pub tz_minuteswest: c_int, + pub tz_dsttime: c_int, + } + + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct dirent { + pub d_offset: c_ulong, + pub d_ino: crate::ino_t, + pub d_reclen: c_ushort, + pub d_namlen: c_ushort, + pub d_name: [c_char; 256], + } + + pub struct termios { + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_cc: [crate::cc_t; crate::NCCS], + } + + pub struct flock64 { + pub l_type: c_short, + pub l_whence: c_short, + pub l_sysid: c_uint, + pub l_pid: crate::pid_t, + pub l_vfs: c_int, + pub l_start: off64_t, + pub l_len: off64_t, + } + + pub struct msghdr { + pub msg_name: *mut c_void, + pub msg_namelen: crate::socklen_t, + pub msg_iov: *mut crate::iovec, + pub msg_iovlen: c_int, + pub msg_control: *mut c_void, + pub msg_controllen: socklen_t, + pub msg_flags: c_int, + } + + pub struct statvfs64 { + pub f_bsize: crate::blksize64_t, + pub f_frsize: crate::blksize64_t, + pub f_blocks: crate::blkcnt64_t, + pub f_bfree: crate::blkcnt64_t, + pub f_bavail: crate::blkcnt64_t, + pub f_files: crate::blkcnt64_t, + pub f_ffree: crate::blkcnt64_t, + pub f_favail: crate::blkcnt64_t, + pub f_fsid: fsid64_t, + pub f_basetype: [c_char; 16], + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + pub f_fstr: [c_char; 32], + pub f_filler: [c_ulong; 16], + } + + pub struct lconv { + pub decimal_point: *mut c_char, + pub thousands_sep: *mut c_char, + pub grouping: *mut c_char, + pub int_curr_symbol: *mut c_char, + pub currency_symbol: *mut c_char, + pub mon_decimal_point: *mut c_char, + pub mon_thousands_sep: *mut c_char, + pub mon_grouping: *mut c_char, + pub positive_sign: *mut c_char, + pub negative_sign: *mut c_char, + pub int_frac_digits: c_char, + pub frac_digits: c_char, + pub p_cs_precedes: c_char, + pub p_sep_by_space: c_char, + pub n_cs_precedes: c_char, + pub n_sep_by_space: c_char, + pub p_sign_posn: c_char, + pub n_sign_posn: c_char, + pub left_parenthesis: *mut c_char, + pub right_parenthesis: *mut c_char, + pub int_p_cs_precedes: c_char, + pub int_p_sep_by_space: c_char, + pub int_n_cs_precedes: c_char, + pub int_n_sep_by_space: c_char, + pub int_p_sign_posn: c_char, + pub int_n_sign_posn: c_char, + } + + pub struct tm { + pub tm_sec: c_int, + pub tm_min: c_int, + pub tm_hour: c_int, + pub tm_mday: c_int, + pub tm_mon: c_int, + pub tm_year: c_int, + pub tm_wday: c_int, + pub tm_yday: c_int, + pub tm_isdst: c_int, + } + + pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: c_ulong, + pub ai_canonname: *mut c_char, + pub ai_addr: *mut crate::sockaddr, + pub ai_next: *mut addrinfo, + pub ai_eflags: c_int, + } + + pub struct in_addr { + pub s_addr: in_addr_t, + } + + pub struct ip_mreq_source { + pub imr_multiaddr: in_addr, + pub imr_sourceaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct sockaddr { + pub sa_len: c_uchar, + pub sa_family: sa_family_t, + pub sa_data: [c_char; 14], + } + + pub struct sockaddr_dl { + pub sdl_len: c_uchar, + pub sdl_family: c_uchar, + pub sdl_index: c_ushort, + pub sdl_type: c_uchar, + pub sdl_nlen: c_uchar, + pub sdl_alen: c_uchar, + pub sdl_slen: c_uchar, + pub sdl_data: [c_char; 120], + } + + pub struct sockaddr_in { + pub sin_len: c_uchar, + pub sin_family: sa_family_t, + pub sin_port: in_port_t, + pub sin_addr: in_addr, + pub sin_zero: [c_uchar; 8], + } + + pub struct sockaddr_in6 { + pub sin6_len: c_uchar, + pub sin6_family: c_uchar, + pub sin6_port: crate::uint16_t, + pub sin6_flowinfo: crate::uint32_t, + pub sin6_addr: crate::in6_addr, + pub sin6_scope_id: crate::uint32_t, + } + + pub struct sockaddr_storage { + pub __ss_len: c_uchar, + pub ss_family: sa_family_t, + __ss_pad1: Padding<[c_char; 6]>, + __ss_align: crate::int64_t, + __ss_pad2: Padding<[c_char; 1265]>, + } + + pub struct sockaddr_un { + pub sun_len: c_uchar, + pub sun_family: sa_family_t, + pub sun_path: [c_char; 1023], + } + + pub struct st_timespec { + pub tv_sec: crate::time_t, + pub tv_nsec: c_int, + } + + pub struct statfs64 { + pub f_version: c_int, + pub f_type: c_int, + pub f_bsize: blksize64_t, + pub f_blocks: blkcnt64_t, + pub f_bfree: blkcnt64_t, + pub f_bavail: blkcnt64_t, + pub f_files: crate::uint64_t, + pub f_ffree: crate::uint64_t, + pub f_fsid: fsid64_t, + pub f_vfstype: c_int, + pub f_fsize: blksize64_t, + pub f_vfsnumber: c_int, + pub f_vfsoff: c_int, + pub f_vfslen: c_int, + pub f_vfsvers: c_int, + pub f_fname: [c_char; 32], + pub f_fpack: [c_char; 32], + pub f_name_max: c_int, + } + + pub struct passwd { + pub pw_name: *mut c_char, + pub pw_passwd: *mut c_char, + pub pw_uid: crate::uid_t, + pub pw_gid: crate::gid_t, + pub pw_gecos: *mut c_char, + pub pw_dir: *mut c_char, + pub pw_shell: *mut c_char, + } + + pub struct utsname { + pub sysname: [c_char; 32], + pub nodename: [c_char; 32], + pub release: [c_char; 32], + pub version: [c_char; 32], + pub machine: [c_char; 32], + } + + pub struct xutsname { + pub nid: c_uint, + reserved: Padding, + pub longnid: c_ulonglong, + } + + pub struct cmsghdr { + pub cmsg_len: crate::socklen_t, + pub cmsg_level: c_int, + pub cmsg_type: c_int, + } + + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigevent { + pub sigev_value: crate::sigval, + pub sigev_signo: c_int, + pub sigev_notify: c_int, + pub sigev_notify_function: extern "C" fn(val: crate::sigval), + pub sigev_notify_attributes: *mut pthread_attr_t, + } + + pub struct osigevent { + pub sevt_value: *mut c_void, + pub sevt_signo: signal_t, + } + + pub struct poll_ctl { + pub cmd: c_short, + pub events: c_short, + pub fd: c_int, + } + + pub struct sf_parms { + pub header_data: *mut c_void, + pub header_length: c_uint, + pub file_descriptor: c_int, + pub file_size: crate::uint64_t, + pub file_offset: crate::uint64_t, + pub file_bytes: crate::int64_t, + pub trailer_data: *mut c_void, + pub trailer_length: c_uint, + pub bytes_sent: crate::uint64_t, + } + + pub struct mmsghdr { + pub msg_hdr: crate::msghdr, + pub msg_len: c_uint, + } + + pub struct sched_param { + pub sched_priority: c_int, + pub sched_policy: c_int, + sched_reserved: Padding<[c_int; 6]>, + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_size: size_t, + pub ss_flags: c_int, + pub __pad: [c_int; 4], + } + + pub struct posix_spawnattr_t { + pub posix_attr_flags: c_short, + pub posix_attr_pgroup: crate::pid_t, + pub posix_attr_sigmask: crate::sigset_t, + pub posix_attr_sigdefault: crate::sigset_t, + pub posix_attr_schedpolicy: c_int, + pub posix_attr_schedparam: sched_param, + } + + pub struct glob_t { + pub gl_pathc: size_t, + pub gl_pathv: *mut *mut c_char, + pub gl_offs: size_t, + pub gl_padr: *mut c_void, + pub gl_ptx: *mut c_void, + } + + pub struct mallinfo { + pub arena: c_ulong, + pub ordblks: c_int, + pub smblks: c_int, + pub hblks: c_int, + pub hblkhd: c_int, + pub usmblks: c_ulong, + pub fsmblks: c_ulong, + pub uordblks: c_ulong, + pub fordblks: c_ulong, + pub keepcost: c_int, + } + + pub struct exit_status { + pub e_termination: c_short, + pub e_exit: c_short, + } + + pub struct utmp { + pub ut_user: [c_char; 256], + pub ut_id: [c_char; 14], + pub ut_line: [c_char; 64], + pub ut_pid: crate::pid_t, + pub ut_type: c_short, + pub ut_time: time64_t, + pub ut_exit: exit_status, + pub ut_host: [c_char; 256], + pub __dbl_word_pad: c_int, + pub __reservedA: [c_int; 2], + pub __reservedV: [c_int; 6], + } + + pub struct regmatch_t { + pub rm_so: regoff_t, + pub rm_eo: regoff_t, + } + + pub struct regex_t { + pub re_nsub: size_t, + pub re_comp: *mut c_void, + pub re_cflags: c_int, + pub re_erroff: size_t, + pub re_len: size_t, + pub re_ucoll: [crate::wchar_t; 2], + pub re_lsub: [*mut c_void; 24], + pub re_esub: [*mut c_void; 24], + pub re_map: *mut c_uchar, + pub __maxsub: c_int, + __unused: Padding<[*mut c_void; 34]>, + } + + pub struct rlimit64 { + pub rlim_cur: rlim64_t, + pub rlim_max: rlim64_t, + } + + pub struct shmid_ds { + pub shm_perm: ipc_perm, + pub shm_segsz: size_t, + pub shm_lpid: crate::pid_t, + pub shm_cpid: crate::pid_t, + pub shm_nattch: shmatt_t, + pub shm_cnattch: shmatt_t, + pub shm_atime: time_t, + pub shm_dtime: time_t, + pub shm_ctime: time_t, + pub shm_handle: crate::uint32_t, + pub shm_extshm: c_int, + pub shm_pagesize: crate::int64_t, + pub shm_lba: crate::uint64_t, + shm_reserved0: Padding, + shm_reserved1: Padding, + } + + pub struct stat64 { + pub st_dev: dev_t, + pub st_ino: ino_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_flag: c_ushort, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: dev_t, + pub st_ssize: c_int, + pub st_atim: st_timespec, + pub st_mtim: st_timespec, + pub st_ctim: st_timespec, + pub st_blksize: blksize_t, + pub st_blocks: blkcnt_t, + pub st_vfstype: c_int, + pub st_vfs: c_uint, + pub st_type: c_uint, + pub st_gen: c_uint, + st_reserved: Padding<[c_uint; 10]>, + pub st_size: off64_t, + } + + pub struct mntent { + pub mnt_fsname: *mut c_char, + pub mnt_dir: *mut c_char, + pub mnt_type: *mut c_char, + pub mnt_opts: *mut c_char, + pub mnt_freq: c_int, + pub mnt_passno: c_int, + } + + pub struct ipc_perm { + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: mode_t, + pub seq: c_ushort, + __reserved: Padding, + pub key: key_t, + } + + pub struct entry { + pub key: *mut c_char, + pub data: *mut c_void, + } + + pub struct mq_attr { + pub mq_flags: c_long, + pub mq_maxmsg: c_long, + pub mq_msgsize: c_long, + pub mq_curmsgs: c_long, + } + + pub struct sembuf { + pub sem_num: c_ushort, + pub sem_op: c_short, + pub sem_flg: c_short, + } + + pub struct if_nameindex { + pub if_index: c_uint, + pub if_name: *mut c_char, + } + + pub struct itimerspec { + pub it_interval: crate::timespec, + pub it_value: crate::timespec, + } + + pub struct sigaction { + pub sa_sigaction: crate::sighandler_t, // FIXME(union): this field is actually a union + pub sa_mask: sigset_t, + pub sa_flags: c_int, + } + + pub struct poll_ctl_ext { + pub version: u8, + pub command: u8, + pub events: c_short, + pub fd: c_int, + pub u: __poll_ctl_ext_u, + reserved64: Padding<[u64; 6]>, + } +} + +s_no_extra_traits! { + pub union __poll_ctl_ext_u { + pub addr: *mut c_void, + pub data32: u32, + pub data: u64, + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for __poll_ctl_ext_u { + fn eq(&self, other: &__poll_ctl_ext_u) -> bool { + unsafe { + self.addr == other.addr + && self.data32 == other.data32 + && self.data == other.data + } + } + } + impl Eq for __poll_ctl_ext_u {} + impl hash::Hash for __poll_ctl_ext_u { + fn hash(&self, state: &mut H) { + unsafe { + self.addr.hash(state); + self.data32.hash(state); + self.data.hash(state); + } + } + } + } +} + +// dlfcn.h +pub const RTLD_LAZY: c_int = 0x4; +pub const RTLD_NOW: c_int = 0x2; +pub const RTLD_GLOBAL: c_int = 0x10000; +pub const RTLD_LOCAL: c_int = 0x80000; +pub const RTLD_MEMBER: c_int = 0x40000; +pub const RTLD_NOAUTODEFER: c_int = 0x20000; +pub const RTLD_DEFAULT: *mut c_void = -1isize as *mut c_void; +pub const RTLD_MYSELF: *mut c_void = -2isize as *mut c_void; +pub const RTLD_NEXT: *mut c_void = -3isize as *mut c_void; + +// fcntl.h +pub const O_RDONLY: c_int = 0x0; +pub const O_WRONLY: c_int = 0x1; +pub const O_RDWR: c_int = 0x2; +pub const O_NDELAY: c_int = 0x8000; +pub const O_APPEND: c_int = 0x8; +pub const O_DSYNC: c_int = 0x400000; +pub const O_CREAT: c_int = 0x100; +pub const O_EXCL: c_int = 0x400; +pub const O_NOCTTY: c_int = 0x800; +pub const O_TRUNC: c_int = 0x200; +pub const O_NOFOLLOW: c_int = 0x1000000; +pub const O_DIRECTORY: c_int = 0x80000; +pub const O_SEARCH: c_int = 0x20; +pub const O_EXEC: c_int = 0x20; +pub const O_CLOEXEC: c_int = 0x800000; +pub const O_ACCMODE: c_int = O_RDONLY | O_WRONLY | O_RDWR | O_EXEC | O_SEARCH; +pub const O_DIRECT: c_int = 0x8000000; +pub const O_TTY_INIT: c_int = 0; +pub const O_RSYNC: c_int = 0x200000; +pub const O_LARGEFILE: c_int = 0x4000000; +pub const F_DUPFD: c_int = 0; +pub const F_DUPFD_CLOEXEC: c_int = 16; +pub const F_GETFD: c_int = 1; +pub const F_SETFD: c_int = 2; +pub const F_GETFL: c_int = 3; +pub const F_SETFL: c_int = 4; +pub const F_GETLK: c_int = F_GETLK64; +pub const F_SETLK: c_int = F_SETLK64; +pub const F_SETLKW: c_int = F_SETLKW64; +pub const F_GETOWN: c_int = 8; +pub const F_SETOWN: c_int = 9; +pub const F_CLOSEM: c_int = 10; +pub const F_GETLK64: c_int = 11; +pub const F_SETLK64: c_int = 12; +pub const F_SETLKW64: c_int = 13; +pub const F_DUP2FD: c_int = 14; +pub const F_TSTLK: c_int = 15; +pub const AT_FDCWD: c_int = -2; +pub const AT_SYMLINK_NOFOLLOW: c_int = 1; +pub const AT_SYMLINK_FOLLOW: c_int = 2; +pub const AT_REMOVEDIR: c_int = 1; +pub const AT_EACCESS: c_int = 1; +pub const O_SYNC: c_int = 16; +pub const O_NONBLOCK: c_int = 4; +pub const FASYNC: c_int = 0x20000; +pub const POSIX_FADV_NORMAL: c_int = 1; +pub const POSIX_FADV_SEQUENTIAL: c_int = 2; +pub const POSIX_FADV_RANDOM: c_int = 3; +pub const POSIX_FADV_WILLNEED: c_int = 4; +pub const POSIX_FADV_DONTNEED: c_int = 5; +pub const POSIX_FADV_NOREUSE: c_int = 6; + +// glob.h +pub const GLOB_APPEND: c_int = 0x1; +pub const GLOB_DOOFFS: c_int = 0x2; +pub const GLOB_ERR: c_int = 0x4; +pub const GLOB_MARK: c_int = 0x8; +pub const GLOB_NOCHECK: c_int = 0x10; +pub const GLOB_NOSORT: c_int = 0x20; +pub const GLOB_NOESCAPE: c_int = 0x80; +pub const GLOB_NOSPACE: c_int = 0x2000; +pub const GLOB_ABORTED: c_int = 0x1000; +pub const GLOB_NOMATCH: c_int = 0x4000; +pub const GLOB_NOSYS: c_int = 0x8000; + +// langinfo.h +pub const DAY_1: crate::nl_item = 13; +pub const DAY_2: crate::nl_item = 14; +pub const DAY_3: crate::nl_item = 15; +pub const DAY_4: crate::nl_item = 16; +pub const DAY_5: crate::nl_item = 17; +pub const DAY_6: crate::nl_item = 18; +pub const DAY_7: crate::nl_item = 19; +pub const ABDAY_1: crate::nl_item = 6; +pub const ABDAY_2: crate::nl_item = 7; +pub const ABDAY_3: crate::nl_item = 8; +pub const ABDAY_4: crate::nl_item = 9; +pub const ABDAY_5: crate::nl_item = 10; +pub const ABDAY_6: crate::nl_item = 11; +pub const ABDAY_7: crate::nl_item = 12; +pub const MON_1: crate::nl_item = 32; +pub const MON_2: crate::nl_item = 33; +pub const MON_3: crate::nl_item = 34; +pub const MON_4: crate::nl_item = 35; +pub const MON_5: crate::nl_item = 36; +pub const MON_6: crate::nl_item = 37; +pub const MON_7: crate::nl_item = 38; +pub const MON_8: crate::nl_item = 39; +pub const MON_9: crate::nl_item = 40; +pub const MON_10: crate::nl_item = 41; +pub const MON_11: crate::nl_item = 42; +pub const MON_12: crate::nl_item = 43; +pub const ABMON_1: crate::nl_item = 20; +pub const ABMON_2: crate::nl_item = 21; +pub const ABMON_3: crate::nl_item = 22; +pub const ABMON_4: crate::nl_item = 23; +pub const ABMON_5: crate::nl_item = 24; +pub const ABMON_6: crate::nl_item = 25; +pub const ABMON_7: crate::nl_item = 26; +pub const ABMON_8: crate::nl_item = 27; +pub const ABMON_9: crate::nl_item = 28; +pub const ABMON_10: crate::nl_item = 29; +pub const ABMON_11: crate::nl_item = 30; +pub const ABMON_12: crate::nl_item = 31; +pub const RADIXCHAR: crate::nl_item = 44; +pub const THOUSEP: crate::nl_item = 45; +pub const YESSTR: crate::nl_item = 46; +pub const NOSTR: crate::nl_item = 47; +pub const CRNCYSTR: crate::nl_item = 48; +pub const D_T_FMT: crate::nl_item = 1; +pub const D_FMT: crate::nl_item = 2; +pub const T_FMT: crate::nl_item = 3; +pub const AM_STR: crate::nl_item = 4; +pub const PM_STR: crate::nl_item = 5; +pub const CODESET: crate::nl_item = 49; +pub const T_FMT_AMPM: crate::nl_item = 55; +pub const ERA: crate::nl_item = 56; +pub const ERA_D_FMT: crate::nl_item = 57; +pub const ERA_D_T_FMT: crate::nl_item = 58; +pub const ERA_T_FMT: crate::nl_item = 59; +pub const ALT_DIGITS: crate::nl_item = 60; +pub const YESEXPR: crate::nl_item = 61; +pub const NOEXPR: crate::nl_item = 62; + +// locale.h +pub const LC_GLOBAL_LOCALE: crate::locale_t = -1isize as crate::locale_t; +pub const LC_COLLATE: c_int = 0; +pub const LC_CTYPE: c_int = 1; +pub const LC_MONETARY: c_int = 2; +pub const LC_NUMERIC: c_int = 3; +pub const LC_TIME: c_int = 4; +pub const LC_MESSAGES: c_int = 5; +pub const LC_ALL: c_int = -1; +pub const LC_COLLATE_MASK: c_int = 1; +pub const LC_CTYPE_MASK: c_int = 2; +pub const LC_MESSAGES_MASK: c_int = 4; +pub const LC_MONETARY_MASK: c_int = 8; +pub const LC_NUMERIC_MASK: c_int = 16; +pub const LC_TIME_MASK: c_int = 32; +pub const LC_ALL_MASK: c_int = LC_COLLATE_MASK + | LC_CTYPE_MASK + | LC_MESSAGES_MASK + | LC_MONETARY_MASK + | LC_NUMERIC_MASK + | LC_TIME_MASK; + +// netdb.h +pub const NI_MAXHOST: crate::socklen_t = 1025; +pub const NI_MAXSERV: crate::socklen_t = 32; +pub const NI_NOFQDN: crate::socklen_t = 0x1; +pub const NI_NUMERICHOST: crate::socklen_t = 0x2; +pub const NI_NAMEREQD: crate::socklen_t = 0x4; +pub const NI_NUMERICSERV: crate::socklen_t = 0x8; +pub const NI_DGRAM: crate::socklen_t = 0x10; +pub const NI_NUMERICSCOPE: crate::socklen_t = 0x40; +pub const EAI_AGAIN: c_int = 2; +pub const EAI_BADFLAGS: c_int = 3; +pub const EAI_FAIL: c_int = 4; +pub const EAI_FAMILY: c_int = 5; +pub const EAI_MEMORY: c_int = 6; +pub const EAI_NODATA: c_int = 7; +pub const EAI_NONAME: c_int = 8; +pub const EAI_SERVICE: c_int = 9; +pub const EAI_SOCKTYPE: c_int = 10; +pub const EAI_SYSTEM: c_int = 11; +pub const EAI_OVERFLOW: c_int = 13; +pub const AI_CANONNAME: c_int = 0x01; +pub const AI_PASSIVE: c_int = 0x02; +pub const AI_NUMERICHOST: c_int = 0x04; +pub const AI_ADDRCONFIG: c_int = 0x08; +pub const AI_V4MAPPED: c_int = 0x10; +pub const AI_ALL: c_int = 0x20; +pub const AI_NUMERICSERV: c_int = 0x40; +pub const AI_EXTFLAGS: c_int = 0x80; +pub const AI_DEFAULT: c_int = AI_V4MAPPED | AI_ADDRCONFIG; +pub const IPV6_ADDRFORM: c_int = 22; +pub const IPV6_ADDR_PREFERENCES: c_int = 74; +pub const IPV6_CHECKSUM: c_int = 39; +pub const IPV6_DONTFRAG: c_int = 45; +pub const IPV6_DSTOPTS: c_int = 54; +pub const IPV6_FLOWINFO_FLOWLABEL: c_int = 0x00ffffff; +pub const IPV6_FLOWINFO_PRIORITY: c_int = 0x0f000000; +pub const IPV6_FLOWINFO_PRIFLOW: c_int = 0x0fffffff; +pub const IPV6_FLOWINFO_SRFLAG: c_int = 0x10000000; +pub const IPV6_FLOWINFO_VERSION: c_int = 0xf0000000; +pub const IPV6_HOPLIMIT: c_int = 40; +pub const IPV6_HOPOPTS: c_int = 52; +pub const IPV6_NEXTHOP: c_int = 48; +pub const IPV6_PATHMTU: c_int = 46; +pub const IPV6_PKTINFO: c_int = 33; +pub const IPV6_PREFER_SRC_CGA: c_int = 16; +pub const IPV6_PREFER_SRC_COA: c_int = 2; +pub const IPV6_PREFER_SRC_HOME: c_int = 1; +pub const IPV6_PREFER_SRC_NONCGA: c_int = 32; +pub const IPV6_PREFER_SRC_PUBLIC: c_int = 4; +pub const IPV6_PREFER_SRC_TMP: c_int = 8; +pub const IPV6_RECVDSTOPTS: c_int = 56; +pub const IPV6_RECVHOPLIMIT: c_int = 41; +pub const IPV6_RECVHOPOPTS: c_int = 53; +pub const IPV6_RECVPATHMTU: c_int = 47; +pub const IPV6_RECVRTHDR: c_int = 51; +pub const IPV6_RECVTCLASS: c_int = 42; +pub const IPV6_RTHDR: c_int = 50; +pub const IPV6_RTHDRDSTOPTS: c_int = 55; +pub const IPV6_TCLASS: c_int = 43; + +// net/bpf.h +pub const DLT_NULL: c_int = 0x18; +pub const DLT_EN10MB: c_int = 0x6; +pub const DLT_EN3MB: c_int = 0x1a; +pub const DLT_AX25: c_int = 0x5; +pub const DLT_PRONET: c_int = 0xd; +pub const DLT_IEEE802: c_int = 0x7; +pub const DLT_ARCNET: c_int = 0x23; +pub const DLT_SLIP: c_int = 0x1c; +pub const DLT_PPP: c_int = 0x17; +pub const DLT_FDDI: c_int = 0xf; +pub const DLT_ATM: c_int = 0x25; +pub const DLT_IPOIB: c_int = 0xc7; +pub const BIOCSETF: c_int = 0x80104267; +pub const BIOCGRTIMEOUT: c_int = 0x4010426e; +pub const BIOCGBLEN: c_int = 0x40044266; +pub const BIOCSBLEN: c_int = 0xc0044266; +pub const BIOCFLUSH: c_int = 0x20004268; +pub const BIOCPROMISC: c_int = 0x20004269; +pub const BIOCGDLT: c_int = 0x4004426a; +pub const BIOCSRTIMEOUT: c_int = 0x8010426d; +pub const BIOCGSTATS: c_int = 0x4008426f; +pub const BIOCIMMEDIATE: c_int = 0x80044270; +pub const BIOCVERSION: c_int = 0x40044271; +pub const BIOCSDEVNO: c_int = 0x20004272; +pub const BIOCGETIF: c_int = 0x4020426b; +pub const BIOCSETIF: c_int = 0x8020426c; +pub const BPF_ABS: c_int = 32; +pub const BPF_ADD: c_int = 0; +pub const BPF_ALIGNMENT: c_ulong = 4; +pub const BPF_ALU: c_int = 4; +pub const BPF_AND: c_int = 80; +pub const BPF_B: c_int = 16; +pub const BPF_DIV: c_int = 48; +pub const BPF_H: c_int = 8; +pub const BPF_IMM: c_int = 0; +pub const BPF_IND: c_int = 64; +pub const BPF_JA: c_int = 0; +pub const BPF_JEQ: c_int = 16; +pub const BPF_JGE: c_int = 48; +pub const BPF_JGT: c_int = 32; +pub const BPF_JMP: c_int = 5; +pub const BPF_JSET: c_int = 64; +pub const BPF_K: c_int = 0; +pub const BPF_LD: c_int = 0; +pub const BPF_LDX: c_int = 1; +pub const BPF_LEN: c_int = 128; +pub const BPF_LSH: c_int = 96; +pub const BPF_MAXINSNS: c_int = 512; +pub const BPF_MEM: c_int = 96; +pub const BPF_MEMWORDS: c_int = 16; +pub const BPF_MISC: c_int = 7; +pub const BPF_MSH: c_int = 160; +pub const BPF_MUL: c_int = 32; +pub const BPF_NEG: c_int = 128; +pub const BPF_OR: c_int = 64; +pub const BPF_RET: c_int = 6; +pub const BPF_RSH: c_int = 112; +pub const BPF_ST: c_int = 2; +pub const BPF_STX: c_int = 3; +pub const BPF_SUB: c_int = 16; +pub const BPF_W: c_int = 0; +pub const BPF_X: c_int = 8; + +// net/if.h +pub const IFNET_SLOWHZ: c_int = 1; +pub const IFQ_MAXLEN: c_int = 50; +pub const IFF_UP: c_int = 0x1; +pub const IFF_BROADCAST: c_int = 0x2; +pub const IFF_DEBUG: c_int = 0x4; +pub const IFF_LOOPBACK: c_int = 0x8; +pub const IFF_POINTOPOINT: c_int = 0x10; +pub const IFF_NOTRAILERS: c_int = 0x20; +pub const IFF_RUNNING: c_int = 0x40; +pub const IFF_NOARP: c_int = 0x80; +pub const IFF_PROMISC: c_int = 0x100; +pub const IFF_ALLMULTI: c_int = 0x200; +pub const IFF_MULTICAST: c_int = 0x80000; +pub const IFF_LINK0: c_int = 0x100000; +pub const IFF_LINK1: c_int = 0x200000; +pub const IFF_LINK2: c_int = 0x400000; +pub const IFF_OACTIVE: c_int = 0x400; +pub const IFF_SIMPLEX: c_int = 0x800; + +// net/if_arp.h +pub const ARPHRD_ETHER: c_int = 1; +pub const ARPHRD_802_5: c_int = 6; +pub const ARPHRD_802_3: c_int = 6; +pub const ARPHRD_FDDI: c_int = 1; + +// net/route.h +pub const RTM_ADD: c_int = 0x1; +pub const RTM_DELETE: c_int = 0x2; +pub const RTM_CHANGE: c_int = 0x3; +pub const RTM_GET: c_int = 0x4; +pub const RTM_LOSING: c_int = 0x5; +pub const RTM_REDIRECT: c_int = 0x6; +pub const RTM_MISS: c_int = 0x7; +pub const RTM_LOCK: c_int = 0x8; +pub const RTM_OLDADD: c_int = 0x9; +pub const RTM_OLDDEL: c_int = 0xa; +pub const RTM_RESOLVE: c_int = 0xb; +pub const RTM_NEWADDR: c_int = 0xc; +pub const RTM_DELADDR: c_int = 0xd; +pub const RTM_IFINFO: c_int = 0xe; +pub const RTM_EXPIRE: c_int = 0xf; +pub const RTM_RTLOST: c_int = 0x10; +pub const RTM_GETNEXT: c_int = 0x11; +pub const RTM_SAMEADDR: c_int = 0x12; +pub const RTM_SET: c_int = 0x13; +pub const RTV_MTU: c_int = 0x1; +pub const RTV_HOPCOUNT: c_int = 0x2; +pub const RTV_EXPIRE: c_int = 0x4; +pub const RTV_RPIPE: c_int = 0x8; +pub const RTV_SPIPE: c_int = 0x10; +pub const RTV_SSTHRESH: c_int = 0x20; +pub const RTV_RTT: c_int = 0x40; +pub const RTV_RTTVAR: c_int = 0x80; +pub const RTA_DST: c_int = 0x1; +pub const RTA_GATEWAY: c_int = 0x2; +pub const RTA_NETMASK: c_int = 0x4; +pub const RTA_GENMASK: c_int = 0x8; +pub const RTA_IFP: c_int = 0x10; +pub const RTA_IFA: c_int = 0x20; +pub const RTA_AUTHOR: c_int = 0x40; +pub const RTA_BRD: c_int = 0x80; +pub const RTA_DOWNSTREAM: c_int = 0x100; +pub const RTAX_DST: c_int = 0; +pub const RTAX_GATEWAY: c_int = 1; +pub const RTAX_NETMASK: c_int = 2; +pub const RTAX_GENMASK: c_int = 3; +pub const RTAX_IFP: c_int = 4; +pub const RTAX_IFA: c_int = 5; +pub const RTAX_AUTHOR: c_int = 6; +pub const RTAX_BRD: c_int = 7; +pub const RTAX_MAX: c_int = 8; +pub const RTF_UP: c_int = 0x1; +pub const RTF_GATEWAY: c_int = 0x2; +pub const RTF_HOST: c_int = 0x4; +pub const RTF_REJECT: c_int = 0x8; +pub const RTF_DYNAMIC: c_int = 0x10; +pub const RTF_MODIFIED: c_int = 0x20; +pub const RTF_DONE: c_int = 0x40; +pub const RTF_MASK: c_int = 0x80; +pub const RTF_CLONING: c_int = 0x100; +pub const RTF_XRESOLVE: c_int = 0x200; +pub const RTF_LLINFO: c_int = 0x400; +pub const RTF_STATIC: c_int = 0x800; +pub const RTF_BLACKHOLE: c_int = 0x1000; +pub const RTF_BUL: c_int = 0x2000; +pub const RTF_PROTO2: c_int = 0x4000; +pub const RTF_PROTO1: c_int = 0x8000; +pub const RTF_CLONE: c_int = 0x10000; +pub const RTF_CLONED: c_int = 0x20000; +pub const RTF_PROTO3: c_int = 0x40000; +pub const RTF_BCE: c_int = 0x80000; +pub const RTF_PINNED: c_int = 0x100000; +pub const RTF_LOCAL: c_int = 0x200000; +pub const RTF_BROADCAST: c_int = 0x400000; +pub const RTF_MULTICAST: c_int = 0x800000; +pub const RTF_ACTIVE_DGD: c_int = 0x1000000; +pub const RTF_STOPSRCH: c_int = 0x2000000; +pub const RTF_FREE_IN_PROG: c_int = 0x4000000; +pub const RTF_PERMANENT6: c_int = 0x8000000; +pub const RTF_UNREACHABLE: c_int = 0x10000000; +pub const RTF_CACHED: c_int = 0x20000000; +pub const RTF_SMALLMTU: c_int = 0x40000; + +// netinet/in.h +pub const IPPROTO_HOPOPTS: c_int = 0; +pub const IPPROTO_IGMP: c_int = 2; +pub const IPPROTO_GGP: c_int = 3; +pub const IPPROTO_IPIP: c_int = 4; +pub const IPPROTO_EGP: c_int = 8; +pub const IPPROTO_PUP: c_int = 12; +pub const IPPROTO_IDP: c_int = 22; +pub const IPPROTO_TP: c_int = 29; +pub const IPPROTO_ROUTING: c_int = 43; +pub const IPPROTO_FRAGMENT: c_int = 44; +pub const IPPROTO_QOS: c_int = 45; +pub const IPPROTO_RSVP: c_int = 46; +pub const IPPROTO_GRE: c_int = 47; +pub const IPPROTO_ESP: c_int = 50; +pub const IPPROTO_AH: c_int = 51; +pub const IPPROTO_NONE: c_int = 59; +pub const IPPROTO_DSTOPTS: c_int = 60; +pub const IPPROTO_LOCAL: c_int = 63; +pub const IPPROTO_EON: c_int = 80; +pub const IPPROTO_BIP: c_int = 0x53; +pub const IPPROTO_SCTP: c_int = 132; +pub const IPPROTO_MH: c_int = 135; +pub const IPPROTO_GIF: c_int = 140; +pub const IPPROTO_RAW: c_int = 255; +pub const IP_OPTIONS: c_int = 1; +pub const IP_HDRINCL: c_int = 2; +pub const IP_TOS: c_int = 3; +pub const IP_TTL: c_int = 4; +pub const IP_UNICAST_HOPS: c_int = 4; +pub const IP_RECVOPTS: c_int = 5; +pub const IP_RECVRETOPTS: c_int = 6; +pub const IP_RECVDSTADDR: c_int = 7; +pub const IP_RETOPTS: c_int = 8; +pub const IP_MULTICAST_IF: c_int = 9; +pub const IP_MULTICAST_TTL: c_int = 10; +pub const IP_MULTICAST_HOPS: c_int = 10; +pub const IP_MULTICAST_LOOP: c_int = 11; +pub const IP_ADD_MEMBERSHIP: c_int = 12; +pub const IP_DROP_MEMBERSHIP: c_int = 13; +pub const IP_RECVMACHDR: c_int = 14; +pub const IP_RECVIFINFO: c_int = 15; +pub const IP_BROADCAST_IF: c_int = 16; +pub const IP_DHCPMODE: c_int = 17; +pub const IP_RECVIF: c_int = 20; +pub const IP_ADDRFORM: c_int = 22; +pub const IP_DONTFRAG: c_int = 25; +pub const IP_FINDPMTU: c_int = 26; +pub const IP_PMTUAGE: c_int = 27; +pub const IP_RECVINTERFACE: c_int = 32; +pub const IP_RECVTTL: c_int = 34; +pub const IP_BLOCK_SOURCE: c_int = 58; +pub const IP_UNBLOCK_SOURCE: c_int = 59; +pub const IP_ADD_SOURCE_MEMBERSHIP: c_int = 60; +pub const IP_DROP_SOURCE_MEMBERSHIP: c_int = 61; +pub const IP_DEFAULT_MULTICAST_TTL: c_int = 1; +pub const IP_DEFAULT_MULTICAST_LOOP: c_int = 1; +pub const IP_INC_MEMBERSHIPS: c_int = 20; +pub const IP_INIT_MEMBERSHIP: c_int = 20; +pub const IPV6_UNICAST_HOPS: c_int = IP_TTL; +pub const IPV6_MULTICAST_IF: c_int = IP_MULTICAST_IF; +pub const IPV6_MULTICAST_HOPS: c_int = IP_MULTICAST_TTL; +pub const IPV6_MULTICAST_LOOP: c_int = IP_MULTICAST_LOOP; +pub const IPV6_RECVPKTINFO: c_int = 35; +pub const IPV6_V6ONLY: c_int = 37; +pub const IPV6_ADD_MEMBERSHIP: c_int = IP_ADD_MEMBERSHIP; +pub const IPV6_DROP_MEMBERSHIP: c_int = IP_DROP_MEMBERSHIP; +pub const IPV6_JOIN_GROUP: c_int = IP_ADD_MEMBERSHIP; +pub const IPV6_LEAVE_GROUP: c_int = IP_DROP_MEMBERSHIP; +pub const MCAST_BLOCK_SOURCE: c_int = 64; +pub const MCAST_EXCLUDE: c_int = 2; +pub const MCAST_INCLUDE: c_int = 1; +pub const MCAST_JOIN_GROUP: c_int = 62; +pub const MCAST_JOIN_SOURCE_GROUP: c_int = 66; +pub const MCAST_LEAVE_GROUP: c_int = 63; +pub const MCAST_LEAVE_SOURCE_GROUP: c_int = 67; +pub const MCAST_UNBLOCK_SOURCE: c_int = 65; + +// netinet/ip.h +pub const MAXTTL: c_int = 255; +pub const IPDEFTTL: c_int = 64; +pub const IPOPT_CONTROL: c_int = 0; +pub const IPOPT_EOL: c_int = 0; +pub const IPOPT_LSRR: c_int = 131; +pub const IPOPT_MINOFF: c_int = 4; +pub const IPOPT_NOP: c_int = 1; +pub const IPOPT_OFFSET: c_int = 2; +pub const IPOPT_OLEN: c_int = 1; +pub const IPOPT_OPTVAL: c_int = 0; +pub const IPOPT_RESERVED1: c_int = 0x20; +pub const IPOPT_RESERVED2: c_int = 0x60; +pub const IPOPT_RR: c_int = 7; +pub const IPOPT_SSRR: c_int = 137; +pub const IPOPT_TS: c_int = 68; +pub const IPOPT_TS_PRESPEC: c_int = 3; +pub const IPOPT_TS_TSANDADDR: c_int = 1; +pub const IPOPT_TS_TSONLY: c_int = 0; +pub const IPTOS_LOWDELAY: c_int = 16; +pub const IPTOS_PREC_CRITIC_ECP: c_int = 160; +pub const IPTOS_PREC_FLASH: c_int = 96; +pub const IPTOS_PREC_FLASHOVERRIDE: c_int = 128; +pub const IPTOS_PREC_IMMEDIATE: c_int = 64; +pub const IPTOS_PREC_INTERNETCONTROL: c_int = 192; +pub const IPTOS_PREC_NETCONTROL: c_int = 224; +pub const IPTOS_PREC_PRIORITY: c_int = 32; +pub const IPTOS_PREC_ROUTINE: c_int = 16; +pub const IPTOS_RELIABILITY: c_int = 4; +pub const IPTOS_THROUGHPUT: c_int = 8; +pub const IPVERSION: c_int = 4; + +// netinet/tcp.h +pub const TCP_NODELAY: c_int = 0x1; +pub const TCP_MAXSEG: c_int = 0x2; +pub const TCP_RFC1323: c_int = 0x4; +pub const TCP_KEEPALIVE: c_int = 0x8; +pub const TCP_KEEPIDLE: c_int = 0x11; +pub const TCP_KEEPINTVL: c_int = 0x12; +pub const TCP_KEEPCNT: c_int = 0x13; +pub const TCP_NODELAYACK: c_int = 0x14; + +// pthread.h +pub const PTHREAD_BARRIER_SERIAL_THREAD: c_int = 2; +pub const PTHREAD_CREATE_JOINABLE: c_int = 0; +pub const PTHREAD_CREATE_DETACHED: c_int = 1; +pub const PTHREAD_PROCESS_SHARED: c_int = 0; +pub const PTHREAD_PROCESS_PRIVATE: c_ushort = 1; +pub const PTHREAD_STACK_MIN: size_t = PAGESIZE as size_t * 4; +pub const PTHREAD_MUTEX_NORMAL: c_int = 5; +pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 3; +pub const PTHREAD_MUTEX_RECURSIVE: c_int = 4; +pub const PTHREAD_MUTEX_DEFAULT: c_int = PTHREAD_MUTEX_NORMAL; +pub const PTHREAD_MUTEX_ROBUST: c_int = 1; +pub const PTHREAD_MUTEX_STALLED: c_int = 0; +pub const PTHREAD_PRIO_INHERIT: c_int = 3; +pub const PTHREAD_PRIO_NONE: c_int = 1; +pub const PTHREAD_PRIO_PROTECT: c_int = 2; + +// regex.h +pub const REG_EXTENDED: c_int = 1; +pub const REG_ICASE: c_int = 2; +pub const REG_NEWLINE: c_int = 4; +pub const REG_NOSUB: c_int = 8; +pub const REG_NOTBOL: c_int = 0x100; +pub const REG_NOTEOL: c_int = 0x200; +pub const REG_NOMATCH: c_int = 1; +pub const REG_BADPAT: c_int = 2; +pub const REG_ECOLLATE: c_int = 3; +pub const REG_ECTYPE: c_int = 4; +pub const REG_EESCAPE: c_int = 5; +pub const REG_ESUBREG: c_int = 6; +pub const REG_EBRACK: c_int = 7; +pub const REG_EPAREN: c_int = 8; +pub const REG_EBRACE: c_int = 9; +pub const REG_BADBR: c_int = 10; +pub const REG_ERANGE: c_int = 11; +pub const REG_ESPACE: c_int = 12; +pub const REG_BADRPT: c_int = 13; +pub const REG_ECHAR: c_int = 14; +pub const REG_EBOL: c_int = 15; +pub const REG_EEOL: c_int = 16; +pub const REG_ENOSYS: c_int = 17; + +// rpcsvc/mount.h +pub const NFSMNT_SOFT: c_int = 0x001; +pub const NFSMNT_WSIZE: c_int = 0x002; +pub const NFSMNT_RSIZE: c_int = 0x004; +pub const NFSMNT_TIMEO: c_int = 0x008; +pub const NFSMNT_RETRANS: c_int = 0x010; +pub const NFSMNT_HOSTNAME: c_int = 0x020; +pub const NFSMNT_INT: c_int = 0x040; +pub const NFSMNT_NOAC: c_int = 0x080; +pub const NFSMNT_ACREGMIN: c_int = 0x0100; +pub const NFSMNT_ACREGMAX: c_int = 0x0200; +pub const NFSMNT_ACDIRMIN: c_int = 0x0400; +pub const NFSMNT_ACDIRMAX: c_int = 0x0800; + +// rpcsvc/rstat.h +pub const CPUSTATES: c_int = 4; + +// semaphore.h +pub const SEM_FAILED: *mut sem_t = -1isize as *mut crate::sem_t; + +// spawn.h +// DIFF(main): changed to `c_short` in f62eb023ab +pub const POSIX_SPAWN_SETPGROUP: c_int = 0x1; +pub const POSIX_SPAWN_SETSIGMASK: c_int = 0x2; +pub const POSIX_SPAWN_SETSIGDEF: c_int = 0x4; +pub const POSIX_SPAWN_SETSCHEDULER: c_int = 0x8; +pub const POSIX_SPAWN_SETSCHEDPARAM: c_int = 0x10; +pub const POSIX_SPAWN_RESETIDS: c_int = 0x20; +pub const POSIX_SPAWN_FORK_HANDLERS: c_int = 0x1000; + +// stdio.h +pub const EOF: c_int = -1; +pub const SEEK_SET: c_int = 0; +pub const SEEK_CUR: c_int = 1; +pub const SEEK_END: c_int = 2; +pub const _IOFBF: c_int = 0o000; +pub const _IONBF: c_int = 0o004; +pub const _IOLBF: c_int = 0o100; +pub const BUFSIZ: c_uint = 4096; +pub const FOPEN_MAX: c_uint = 32767; +pub const FILENAME_MAX: c_uint = 255; +pub const L_tmpnam: c_uint = 21; +pub const TMP_MAX: c_uint = 16384; + +// stdlib.h +pub const EXIT_FAILURE: c_int = 1; +pub const EXIT_SUCCESS: c_int = 0; +pub const RAND_MAX: c_int = 32767; + +// sys/access.h +pub const F_OK: c_int = 0; +pub const R_OK: c_int = 4; +pub const W_OK: c_int = 2; +pub const X_OK: c_int = 1; + +// sys/aio.h +pub const LIO_NOP: c_int = 0; +pub const LIO_READ: c_int = 1; +pub const LIO_WRITE: c_int = 2; +pub const LIO_NOWAIT: c_int = 0; +pub const LIO_WAIT: c_int = 1; +pub const AIO_ALLDONE: c_int = 2; +pub const AIO_CANCELED: c_int = 0; +pub const AIO_NOTCANCELED: c_int = 1; + +// sys/errno.h +pub const EPERM: c_int = 1; +pub const ENOENT: c_int = 2; +pub const ESRCH: c_int = 3; +pub const EINTR: c_int = 4; +pub const EIO: c_int = 5; +pub const ENXIO: c_int = 6; +pub const E2BIG: c_int = 7; +pub const ENOEXEC: c_int = 8; +pub const EBADF: c_int = 9; +pub const ECHILD: c_int = 10; +pub const EAGAIN: c_int = 11; +pub const ENOMEM: c_int = 12; +pub const EACCES: c_int = 13; +pub const EFAULT: c_int = 14; +pub const ENOTBLK: c_int = 15; +pub const EBUSY: c_int = 16; +pub const EEXIST: c_int = 17; +pub const EXDEV: c_int = 18; +pub const ENODEV: c_int = 19; +pub const ENOTDIR: c_int = 20; +pub const EISDIR: c_int = 21; +pub const EINVAL: c_int = 22; +pub const ENFILE: c_int = 23; +pub const EMFILE: c_int = 24; +pub const ENOTTY: c_int = 25; +pub const ETXTBSY: c_int = 26; +pub const EFBIG: c_int = 27; +pub const ENOSPC: c_int = 28; +pub const ESPIPE: c_int = 29; +pub const EROFS: c_int = 30; +pub const EMLINK: c_int = 31; +pub const EPIPE: c_int = 32; +pub const EDOM: c_int = 33; +pub const ERANGE: c_int = 34; +pub const ENOMSG: c_int = 35; +pub const EIDRM: c_int = 36; +pub const ECHRNG: c_int = 37; +pub const EL2NSYNC: c_int = 38; +pub const EL3HLT: c_int = 39; +pub const EL3RST: c_int = 40; +pub const ELNRNG: c_int = 41; +pub const EUNATCH: c_int = 42; +pub const ENOCSI: c_int = 43; +pub const EL2HLT: c_int = 44; +pub const EDEADLK: c_int = 45; +pub const ENOTREADY: c_int = 46; +pub const EWRPROTECT: c_int = 47; +pub const EFORMAT: c_int = 48; +pub const ENOLCK: c_int = 49; +pub const ENOCONNECT: c_int = 50; +pub const ESTALE: c_int = 52; +pub const EDIST: c_int = 53; +// POSIX allows EWOULDBLOCK to be the same value as EAGAIN. +pub const EWOULDBLOCK: c_int = EAGAIN; +pub const EINPROGRESS: c_int = 55; +pub const EALREADY: c_int = 56; +pub const ENOTSOCK: c_int = 57; +pub const EDESTADDRREQ: c_int = 58; +pub const EMSGSIZE: c_int = 59; +pub const EPROTOTYPE: c_int = 60; +pub const ENOPROTOOPT: c_int = 61; +pub const EPROTONOSUPPORT: c_int = 62; +pub const ESOCKTNOSUPPORT: c_int = 63; +pub const EOPNOTSUPP: c_int = 64; +pub const EPFNOSUPPORT: c_int = 65; +pub const EAFNOSUPPORT: c_int = 66; +pub const EADDRINUSE: c_int = 67; +pub const EADDRNOTAVAIL: c_int = 68; +pub const ENETDOWN: c_int = 69; +pub const ENETUNREACH: c_int = 70; +pub const ENETRESET: c_int = 71; +pub const ECONNABORTED: c_int = 72; +pub const ECONNRESET: c_int = 73; +pub const ENOBUFS: c_int = 74; +pub const EISCONN: c_int = 75; +pub const ENOTCONN: c_int = 76; +pub const ESHUTDOWN: c_int = 77; +pub const ETIMEDOUT: c_int = 78; +pub const ECONNREFUSED: c_int = 79; +pub const EHOSTDOWN: c_int = 80; +pub const EHOSTUNREACH: c_int = 81; +pub const ERESTART: c_int = 82; +pub const EPROCLIM: c_int = 83; +pub const EUSERS: c_int = 84; +pub const ELOOP: c_int = 85; +pub const ENAMETOOLONG: c_int = 86; +pub const ENOTEMPTY: c_int = 87; +pub const EDQUOT: c_int = 88; +pub const ECORRUPT: c_int = 89; +pub const ESYSERROR: c_int = 90; +pub const EREMOTE: c_int = 93; +pub const ENOTRECOVERABLE: c_int = 94; +pub const EOWNERDEAD: c_int = 95; +// errnos 96-108 reserved for future use compatible with AIX PS/2 +pub const ENOSYS: c_int = 109; +pub const EMEDIA: c_int = 110; +pub const ESOFT: c_int = 111; +pub const ENOATTR: c_int = 112; +pub const ESAD: c_int = 113; +pub const ENOTRUST: c_int = 114; +pub const ETOOMANYREFS: c_int = 115; +pub const EILSEQ: c_int = 116; +pub const ECANCELED: c_int = 117; +pub const ENOSR: c_int = 118; +pub const ETIME: c_int = 119; +pub const EBADMSG: c_int = 120; +pub const EPROTO: c_int = 121; +pub const ENODATA: c_int = 122; +pub const ENOSTR: c_int = 123; +pub const ENOTSUP: c_int = 124; +pub const EMULTIHOP: c_int = 125; +pub const ENOLINK: c_int = 126; +pub const EOVERFLOW: c_int = 127; + +// sys/dr.h +pub const LPAR_INFO_FORMAT1: c_int = 1; +pub const LPAR_INFO_FORMAT2: c_int = 2; +pub const WPAR_INFO_FORMAT: c_int = 3; +pub const PROC_MODULE_INFO: c_int = 4; +pub const NUM_PROC_MODULE_TYPES: c_int = 5; +pub const LPAR_INFO_VRME_NUM_POOLS: c_int = 6; +pub const LPAR_INFO_VRME_POOLS: c_int = 7; +pub const LPAR_INFO_VRME_LPAR: c_int = 8; +pub const LPAR_INFO_VRME_RESET_HWMARKS: c_int = 9; +pub const LPAR_INFO_VRME_ALLOW_DESIRED: c_int = 10; +pub const EMTP_INFO_FORMAT: c_int = 11; +pub const LPAR_INFO_LPM_CAPABILITY: c_int = 12; +pub const ENERGYSCALE_INFO: c_int = 13; + +// sys/file.h +pub const LOCK_SH: c_int = 1; +pub const LOCK_EX: c_int = 2; +pub const LOCK_NB: c_int = 4; +pub const LOCK_UN: c_int = 8; + +// sys/flock.h +pub const F_RDLCK: c_short = 0o01; +pub const F_WRLCK: c_short = 0o02; +pub const F_UNLCK: c_short = 0o03; + +// sys/fs/quota_common.h +pub const Q_QUOTAON: c_int = 0x100; +pub const Q_QUOTAOFF: c_int = 0x200; +pub const Q_SETUSE: c_int = 0x500; +pub const Q_SYNC: c_int = 0x600; +pub const Q_GETQUOTA: c_int = 0x300; +pub const Q_SETQLIM: c_int = 0x400; +pub const Q_SETQUOTA: c_int = 0x400; + +// sys/ioctl.h +pub const IOCPARM_MASK: c_int = 0x7f; +pub const IOC_VOID: c_int = 0x20000000; +pub const IOC_OUT: c_int = 0x40000000; +pub const IOC_IN: c_int = 0x40000000 << 1; +pub const IOC_INOUT: c_int = IOC_IN | IOC_OUT; +pub const FIOCLEX: c_int = 0x20006601; +pub const FIONCLEX: c_int = 0x20006602; +pub const FIONREAD: c_int = 0x4004667f; +pub const FIONBIO: c_int = 0x8004667e; +pub const FIOASYNC: c_int = 0x8004667d; +pub const FIOSETOWN: c_int = 0x8004667c; +pub const FIOGETOWN: c_int = 0x4004667b; +pub const TIOCGETD: c_int = 0x40047400; +pub const TIOCSETD: c_int = 0x80047401; +pub const TIOCHPCL: c_int = 0x20007402; +pub const TIOCMODG: c_int = 0x40047403; +pub const TIOCMODS: c_int = 0x80047404; +pub const TIOCM_LE: c_int = 0x1; +pub const TIOCM_DTR: c_int = 0x2; +pub const TIOCM_RTS: c_int = 0x4; +pub const TIOCM_ST: c_int = 0x8; +pub const TIOCM_SR: c_int = 0x10; +pub const TIOCM_CTS: c_int = 0x20; +pub const TIOCM_CAR: c_int = 0x40; +pub const TIOCM_CD: c_int = 0x40; +pub const TIOCM_RNG: c_int = 0x80; +pub const TIOCM_RI: c_int = 0x80; +pub const TIOCM_DSR: c_int = 0x100; +pub const TIOCGETP: c_int = 0x40067408; +pub const TIOCSETP: c_int = 0x80067409; +pub const TIOCSETN: c_int = 0x8006740a; +pub const TIOCEXCL: c_int = 0x2000740d; +pub const TIOCNXCL: c_int = 0x2000740e; +pub const TIOCFLUSH: c_int = 0x80047410; +pub const TIOCSETC: c_int = 0x80067411; +pub const TIOCGETC: c_int = 0x40067412; +pub const TANDEM: c_int = 0x1; +pub const CBREAK: c_int = 0x2; +pub const LCASE: c_int = 0x4; +pub const MDMBUF: c_int = 0x800000; +pub const XTABS: c_int = 0xc00; +pub const SIOCADDMULTI: c_int = 0x80206931; +pub const SIOCADDRT: c_int = 0x8038720a; +pub const SIOCDARP: c_int = 0x804c6920; +pub const SIOCDELMULTI: c_int = 0x80206932; +pub const SIOCDELRT: c_int = 0x8038720b; +pub const SIOCDIFADDR: c_int = 0x80286919; +pub const SIOCGARP: c_int = 0xc04c6926; +pub const SIOCGIFADDR: c_int = 0xc0286921; +pub const SIOCGIFBRDADDR: c_int = 0xc0286923; +pub const SIOCGIFCONF: c_int = 0xc0106945; +pub const SIOCGIFDSTADDR: c_int = 0xc0286922; +pub const SIOCGIFFLAGS: c_int = 0xc0286911; +pub const SIOCGIFHWADDR: c_int = 0xc0546995; +pub const SIOCGIFMETRIC: c_int = 0xc0286917; +pub const SIOCGIFMTU: c_int = 0xc0286956; +pub const SIOCGIFNETMASK: c_int = 0xc0286925; +pub const SIOCSARP: c_int = 0x804c691e; +pub const SIOCSIFADDR: c_int = 0x8028690c; +pub const SIOCSIFBRDADDR: c_int = 0x80286913; +pub const SIOCSIFDSTADDR: c_int = 0x8028690e; +pub const SIOCSIFFLAGS: c_int = 0x80286910; +pub const SIOCSIFMETRIC: c_int = 0x80286918; +pub const SIOCSIFMTU: c_int = 0x80286958; +pub const SIOCSIFNETMASK: c_int = 0x80286916; +pub const TIOCUCNTL: c_int = 0x80047466; +pub const TIOCCONS: c_int = 0x80047462; +pub const TIOCPKT: c_int = 0x80047470; +pub const TIOCPKT_DATA: c_int = 0; +pub const TIOCPKT_FLUSHREAD: c_int = 1; +pub const TIOCPKT_FLUSHWRITE: c_int = 2; +pub const TIOCPKT_NOSTOP: c_int = 0x10; +pub const TIOCPKT_DOSTOP: c_int = 0x20; +pub const TIOCPKT_START: c_int = 8; +pub const TIOCPKT_STOP: c_int = 4; + +// sys/ipc.h +pub const IPC_ALLOC: c_int = 0o100000; +pub const IPC_CREAT: c_int = 0o020000; +pub const IPC_EXCL: c_int = 0o002000; +pub const IPC_NOWAIT: c_int = 0o004000; +pub const IPC_RMID: c_int = 0; +pub const IPC_SET: c_int = 101; +pub const IPC_R: c_int = 0o0400; +pub const IPC_W: c_int = 0o0200; +pub const IPC_O: c_int = 0o1000; +pub const IPC_NOERROR: c_int = 0o10000; +pub const IPC_STAT: c_int = 102; +pub const IPC_PRIVATE: crate::key_t = -1; +pub const SHM_LOCK: c_int = 201; +pub const SHM_UNLOCK: c_int = 202; + +// sys/ldr.h +pub const L_GETMESSAGES: c_int = 1; +pub const L_GETINFO: c_int = 2; +pub const L_GETLIBPATH: c_int = 3; +pub const L_GETKERNINFO: c_int = 4; +pub const L_GETLIB32INFO: c_int = 5; +pub const L_GETLIB64INFO: c_int = 6; +pub const L_GETPROCINFO: c_int = 7; +pub const L_GETXINFO: c_int = 8; + +// sys/limits.h +pub const PATH_MAX: c_int = 1023; +pub const PAGESIZE: c_int = 4096; +pub const IOV_MAX: c_int = 16; +pub const AIO_LISTIO_MAX: c_int = 4096; +pub const PIPE_BUF: usize = 32768; +pub const OPEN_MAX: c_int = 65534; +pub const MAX_INPUT: c_int = 512; +pub const MAX_CANON: c_int = 256; +pub const ARG_MAX: c_int = 1048576; +pub const BC_BASE_MAX: c_int = 99; +pub const BC_DIM_MAX: c_int = 0x800; +pub const BC_SCALE_MAX: c_int = 99; +pub const BC_STRING_MAX: c_int = 0x800; +pub const CHARCLASS_NAME_MAX: c_int = 14; +pub const CHILD_MAX: c_int = 128; +pub const COLL_WEIGHTS_MAX: c_int = 4; +pub const EXPR_NEST_MAX: c_int = 32; +pub const NZERO: c_int = 20; + +// sys/lockf.h +pub const F_LOCK: c_int = 1; +pub const F_TEST: c_int = 3; +pub const F_TLOCK: c_int = 2; +pub const F_ULOCK: c_int = 0; + +// sys/machine.h +pub const BIG_ENDIAN: c_int = 4321; +pub const LITTLE_ENDIAN: c_int = 1234; +pub const PDP_ENDIAN: c_int = 3412; + +// sys/mman.h +pub const PROT_NONE: c_int = 0; +pub const PROT_READ: c_int = 1; +pub const PROT_WRITE: c_int = 2; +pub const PROT_EXEC: c_int = 4; +pub const MAP_FILE: c_int = 0; +pub const MAP_SHARED: c_int = 1; +pub const MAP_PRIVATE: c_int = 2; +pub const MAP_FIXED: c_int = 0x100; +pub const MAP_ANON: c_int = 0x10; +pub const MAP_ANONYMOUS: c_int = 0x10; +pub const MAP_FAILED: *mut c_void = !0 as *mut c_void; +pub const MAP_TYPE: c_int = 0xf0; +pub const MCL_CURRENT: c_int = 0x100; +pub const MCL_FUTURE: c_int = 0x200; +pub const MS_SYNC: c_int = 0x20; +pub const MS_ASYNC: c_int = 0x10; +pub const MS_INVALIDATE: c_int = 0x40; +pub const POSIX_MADV_NORMAL: c_int = 1; +pub const POSIX_MADV_RANDOM: c_int = 3; +pub const POSIX_MADV_SEQUENTIAL: c_int = 2; +pub const POSIX_MADV_WILLNEED: c_int = 4; +pub const POSIX_MADV_DONTNEED: c_int = 5; +pub const MADV_NORMAL: c_int = 0; +pub const MADV_RANDOM: c_int = 1; +pub const MADV_SEQUENTIAL: c_int = 2; +pub const MADV_WILLNEED: c_int = 3; +pub const MADV_DONTNEED: c_int = 4; + +// sys/mode.h +pub const S_IFMT: mode_t = 0o17_0000; +pub const S_IFREG: mode_t = 0o10_0000; +pub const S_IFDIR: mode_t = 0o4_0000; +pub const S_IFBLK: mode_t = 0o6_0000; +pub const S_IFCHR: mode_t = 0o2_0000; +pub const S_IFIFO: mode_t = 0o1_0000; +pub const S_IRWXU: mode_t = 0o0700; +pub const S_IRUSR: mode_t = 0o0400; +pub const S_IWUSR: mode_t = 0o0200; +pub const S_IXUSR: mode_t = 0o0100; +pub const S_IRWXG: mode_t = 0o0070; +pub const S_IRGRP: mode_t = 0o0040; +pub const S_IWGRP: mode_t = 0o0020; +pub const S_IXGRP: mode_t = 0o0010; +pub const S_IRWXO: mode_t = 0o0007; +pub const S_IROTH: mode_t = 0o0004; +pub const S_IWOTH: mode_t = 0o0002; +pub const S_IXOTH: mode_t = 0o0001; +pub const S_IFLNK: mode_t = 0o12_0000; +pub const S_IFSOCK: mode_t = 0o14_0000; +pub const S_IEXEC: mode_t = 0o0100; +pub const S_IWRITE: mode_t = 0o0200; +pub const S_IREAD: mode_t = 0o0400; + +// sys/msg.h +pub const MSG_NOERROR: c_int = 0o10000; + +// sys/m_signal.h +pub const SIGSTKSZ: size_t = 4096; +pub const MINSIGSTKSZ: size_t = 1200; + +// sys/params.h +pub const MAXPATHLEN: c_int = PATH_MAX + 1; +pub const MAXSYMLINKS: c_int = 20; +pub const MAXHOSTNAMELEN: c_int = 256; +pub const MAXUPRC: c_int = 128; +pub const NGROUPS_MAX: c_ulong = 2048; +pub const NGROUPS: c_ulong = NGROUPS_MAX; +pub const NOFILE: c_int = OPEN_MAX; + +// sys/poll.h +pub const POLLIN: c_short = 0x0001; +pub const POLLPRI: c_short = 0x0004; +pub const POLLOUT: c_short = 0x0002; +pub const POLLERR: c_short = 0x4000; +pub const POLLHUP: c_short = 0x2000; +pub const POLLMSG: c_short = 0x0080; +pub const POLLSYNC: c_short = 0x8000; +pub const POLLNVAL: c_short = POLLSYNC; +pub const POLLNORM: c_short = POLLIN; +pub const POLLRDNORM: c_short = 0x0010; +pub const POLLWRNORM: c_short = POLLOUT; +pub const POLLRDBAND: c_short = 0x0020; +pub const POLLWRBAND: c_short = 0x0040; + +// sys/pollset.h +pub const PS_ADD: c_uchar = 0; +pub const PS_MOD: c_uchar = 1; +pub const PS_DELETE: c_uchar = 2; +pub const PS_REPLACE: c_uchar = 3; + +// sys/ptrace.h +pub const PT_TRACE_ME: c_int = 0; +pub const PT_READ_I: c_int = 1; +pub const PT_READ_D: c_int = 2; +pub const PT_WRITE_I: c_int = 4; +pub const PT_WRITE_D: c_int = 5; +pub const PT_CONTINUE: c_int = 7; +pub const PT_KILL: c_int = 8; +pub const PT_STEP: c_int = 9; +pub const PT_READ_GPR: c_int = 11; +pub const PT_READ_FPR: c_int = 12; +pub const PT_WRITE_GPR: c_int = 14; +pub const PT_WRITE_FPR: c_int = 15; +pub const PT_READ_BLOCK: c_int = 17; +pub const PT_WRITE_BLOCK: c_int = 19; +pub const PT_ATTACH: c_int = 30; +pub const PT_DETACH: c_int = 31; +pub const PT_REGSET: c_int = 32; +pub const PT_REATT: c_int = 33; +pub const PT_LDINFO: c_int = 34; +pub const PT_MULTI: c_int = 35; +pub const PT_NEXT: c_int = 36; +pub const PT_SET: c_int = 37; +pub const PT_CLEAR: c_int = 38; +pub const PT_LDXINFO: c_int = 39; +pub const PT_QUERY: c_int = 40; +pub const PT_WATCH: c_int = 41; +pub const PTT_CONTINUE: c_int = 50; +pub const PTT_STEP: c_int = 51; +pub const PTT_READ_SPRS: c_int = 52; +pub const PTT_WRITE_SPRS: c_int = 53; +pub const PTT_READ_GPRS: c_int = 54; +pub const PTT_WRITE_GPRS: c_int = 55; +pub const PTT_READ_FPRS: c_int = 56; +pub const PTT_WRITE_FPRS: c_int = 57; +pub const PTT_READ_VEC: c_int = 58; +pub const PTT_WRITE_VEC: c_int = 59; +pub const PTT_WATCH: c_int = 60; +pub const PTT_SET_TRAP: c_int = 61; +pub const PTT_CLEAR_TRAP: c_int = 62; +pub const PTT_READ_UKEYSET: c_int = 63; +pub const PT_GET_UKEY: c_int = 64; +pub const PTT_READ_FPSCR_HI: c_int = 65; +pub const PTT_WRITE_FPSCR_HI: c_int = 66; +pub const PTT_READ_VSX: c_int = 67; +pub const PTT_WRITE_VSX: c_int = 68; +pub const PTT_READ_TM: c_int = 69; +pub const PTRACE_ATTACH: c_int = 14; +pub const PTRACE_CONT: c_int = 7; +pub const PTRACE_DETACH: c_int = 15; +pub const PTRACE_GETFPREGS: c_int = 12; +pub const PTRACE_GETREGS: c_int = 10; +pub const PTRACE_KILL: c_int = 8; +pub const PTRACE_PEEKDATA: c_int = 2; +pub const PTRACE_PEEKTEXT: c_int = 1; +pub const PTRACE_PEEKUSER: c_int = 3; +pub const PTRACE_POKEDATA: c_int = 5; +pub const PTRACE_POKETEXT: c_int = 4; +pub const PTRACE_POKEUSER: c_int = 6; +pub const PTRACE_SETFPREGS: c_int = 13; +pub const PTRACE_SETREGS: c_int = 11; +pub const PTRACE_SINGLESTEP: c_int = 9; +pub const PTRACE_SYSCALL: c_int = 16; +pub const PTRACE_TRACEME: c_int = 0; + +// sys/resource.h +pub const RLIMIT_CPU: c_int = 0; +pub const RLIMIT_FSIZE: c_int = 1; +pub const RLIMIT_DATA: c_int = 2; +pub const RLIMIT_STACK: c_int = 3; +pub const RLIMIT_CORE: c_int = 4; +pub const RLIMIT_RSS: c_int = 5; +pub const RLIMIT_AS: c_int = 6; +pub const RLIMIT_NOFILE: c_int = 7; +pub const RLIMIT_THREADS: c_int = 8; +pub const RLIMIT_NPROC: c_int = 9; +pub const RUSAGE_SELF: c_int = 0; +pub const RUSAGE_CHILDREN: c_int = -1; +pub const PRIO_PROCESS: c_int = 0; +pub const PRIO_PGRP: c_int = 1; +pub const PRIO_USER: c_int = 2; +pub const RUSAGE_THREAD: c_int = 1; +pub const RLIM_SAVED_MAX: c_ulong = RLIM_INFINITY - 1; +pub const RLIM_SAVED_CUR: c_ulong = RLIM_INFINITY - 2; +#[deprecated(since = "0.2.64", note = "Not stable across OS versions")] +pub const RLIM_NLIMITS: c_int = 10; + +// sys/sched.h +pub const SCHED_OTHER: c_int = 0; +pub const SCHED_FIFO: c_int = 1; +pub const SCHED_RR: c_int = 2; +pub const SCHED_LOCAL: c_int = 3; +pub const SCHED_GLOBAL: c_int = 4; +pub const SCHED_FIFO2: c_int = 5; +pub const SCHED_FIFO3: c_int = 6; +pub const SCHED_FIFO4: c_int = 7; + +// sys/sem.h +pub const SEM_UNDO: c_int = 0o10000; +pub const GETNCNT: c_int = 3; +pub const GETPID: c_int = 4; +pub const GETVAL: c_int = 5; +pub const GETALL: c_int = 6; +pub const GETZCNT: c_int = 7; +pub const SETVAL: c_int = 8; +pub const SETALL: c_int = 9; + +// sys/shm.h +pub const SHMLBA: c_int = 0x10000000; +pub const SHMLBA_EXTSHM: c_int = 0x1000; +pub const SHM_SHMAT: c_int = 0x80000000; +pub const SHM_RDONLY: c_int = 0o10000; +pub const SHM_RND: c_int = 0o20000; +pub const SHM_PIN: c_int = 0o4000; +pub const SHM_LGPAGE: c_int = 0o20000000000; +pub const SHM_MAP: c_int = 0o4000; +pub const SHM_FMAP: c_int = 0o2000; +pub const SHM_COPY: c_int = 0o40000; +pub const SHM_CLEAR: c_int = 0; +pub const SHM_HGSEG: c_int = 0o10000000000; +pub const SHM_R: c_int = IPC_R; +pub const SHM_W: c_int = IPC_W; +pub const SHM_DEST: c_int = 0o2000; + +// sys/signal.h +pub const SA_ONSTACK: c_int = 0x00000001; +pub const SA_RESETHAND: c_int = 0x00000002; +pub const SA_RESTART: c_int = 0x00000008; +pub const SA_SIGINFO: c_int = 0x00000100; +pub const SA_NODEFER: c_int = 0x00000200; +pub const SA_NOCLDWAIT: c_int = 0x00000400; +pub const SA_NOCLDSTOP: c_int = 0x00000004; +pub const SS_ONSTACK: c_int = 0x00000001; +pub const SS_DISABLE: c_int = 0x00000002; +pub const SIGCHLD: c_int = 20; +pub const SIGBUS: c_int = 10; +pub const SIG_BLOCK: c_int = 0; +pub const SIG_UNBLOCK: c_int = 1; +pub const SIG_SETMASK: c_int = 2; +pub const SIGEV_NONE: c_int = 1; +pub const SIGEV_SIGNAL: c_int = 2; +pub const SIGEV_THREAD: c_int = 3; +pub const SIGHUP: c_int = 1; +pub const SIGINT: c_int = 2; +pub const SIGQUIT: c_int = 3; +pub const SIGILL: c_int = 4; +pub const SIGABRT: c_int = 6; +pub const SIGEMT: c_int = 7; +pub const SIGFPE: c_int = 8; +pub const SIGKILL: c_int = 9; +pub const SIGSEGV: c_int = 11; +pub const SIGSYS: c_int = 12; +pub const SIGPIPE: c_int = 13; +pub const SIGALRM: c_int = 14; +pub const SIGTERM: c_int = 15; +pub const SIGUSR1: c_int = 30; +pub const SIGUSR2: c_int = 31; +pub const SIGPWR: c_int = 29; +pub const SIGWINCH: c_int = 28; +pub const SIGURG: c_int = 16; +pub const SIGPOLL: c_int = SIGIO; +pub const SIGIO: c_int = 23; +pub const SIGSTOP: c_int = 17; +pub const SIGTSTP: c_int = 18; +pub const SIGCONT: c_int = 19; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGVTALRM: c_int = 34; +pub const SIGPROF: c_int = 32; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGTRAP: c_int = 5; +pub const SIGCLD: c_int = 20; +pub const SIGRTMAX: c_int = 57; +pub const SIGRTMIN: c_int = 50; +pub const SI_USER: c_int = 0; +pub const SI_UNDEFINED: c_int = 8; +pub const SI_EMPTY: c_int = 9; +pub const BUS_ADRALN: c_int = 1; +pub const BUS_ADRERR: c_int = 2; +pub const BUS_OBJERR: c_int = 3; +pub const BUS_UEGARD: c_int = 4; +pub const CLD_EXITED: c_int = 10; +pub const CLD_KILLED: c_int = 11; +pub const CLD_DUMPED: c_int = 12; +pub const CLD_TRAPPED: c_int = 13; +pub const CLD_STOPPED: c_int = 14; +pub const CLD_CONTINUED: c_int = 15; +pub const FPE_INTDIV: c_int = 20; +pub const FPE_INTOVF: c_int = 21; +pub const FPE_FLTDIV: c_int = 22; +pub const FPE_FLTOVF: c_int = 23; +pub const FPE_FLTUND: c_int = 24; +pub const FPE_FLTRES: c_int = 25; +pub const FPE_FLTINV: c_int = 26; +pub const FPE_FLTSUB: c_int = 27; +pub const ILL_ILLOPC: c_int = 30; +pub const ILL_ILLOPN: c_int = 31; +pub const ILL_ILLADR: c_int = 32; +pub const ILL_ILLTRP: c_int = 33; +pub const ILL_PRVOPC: c_int = 34; +pub const ILL_PRVREG: c_int = 35; +pub const ILL_COPROC: c_int = 36; +pub const ILL_BADSTK: c_int = 37; +pub const ILL_TMBADTHING: c_int = 38; +pub const POLL_IN: c_int = 40; +pub const POLL_OUT: c_int = 41; +pub const POLL_MSG: c_int = -3; +pub const POLL_ERR: c_int = 43; +pub const POLL_PRI: c_int = 44; +pub const POLL_HUP: c_int = 45; +pub const SEGV_MAPERR: c_int = 50; +pub const SEGV_ACCERR: c_int = 51; +pub const SEGV_KEYERR: c_int = 52; +pub const TRAP_BRKPT: c_int = 60; +pub const TRAP_TRACE: c_int = 61; +pub const SI_QUEUE: c_int = 71; +pub const SI_TIMER: c_int = 72; +pub const SI_ASYNCIO: c_int = 73; +pub const SI_MESGQ: c_int = 74; + +// sys/socket.h +pub const AF_UNSPEC: c_int = 0; +pub const AF_UNIX: c_int = 1; +pub const AF_INET: c_int = 2; +pub const AF_IMPLINK: c_int = 3; +pub const AF_PUP: c_int = 4; +pub const AF_CHAOS: c_int = 5; +pub const AF_NS: c_int = 6; +pub const AF_ECMA: c_int = 8; +pub const AF_DATAKIT: c_int = 9; +pub const AF_CCITT: c_int = 10; +pub const AF_SNA: c_int = 11; +pub const AF_DECnet: c_int = 12; +pub const AF_DLI: c_int = 13; +pub const AF_LAT: c_int = 14; +pub const SO_TIMESTAMPNS: c_int = 0x100a; +pub const SOMAXCONN: c_int = 1024; +pub const AF_LOCAL: c_int = AF_UNIX; +pub const UIO_MAXIOV: c_int = 1024; +pub const pseudo_AF_XTP: c_int = 19; +pub const AF_HYLINK: c_int = 15; +pub const AF_APPLETALK: c_int = 16; +pub const AF_ISO: c_int = 7; +pub const AF_OSI: c_int = AF_ISO; +pub const AF_ROUTE: c_int = 17; +pub const AF_LINK: c_int = 18; +pub const AF_INET6: c_int = 24; +pub const AF_INTF: c_int = 20; +pub const AF_RIF: c_int = 21; +pub const AF_NDD: c_int = 23; +pub const AF_MAX: c_int = 30; +pub const PF_UNSPEC: c_int = AF_UNSPEC; +pub const PF_UNIX: c_int = AF_UNIX; +pub const PF_INET: c_int = AF_INET; +pub const PF_IMPLINK: c_int = AF_IMPLINK; +pub const PF_PUP: c_int = AF_PUP; +pub const PF_CHAOS: c_int = AF_CHAOS; +pub const PF_NS: c_int = AF_NS; +pub const PF_ISO: c_int = AF_ISO; +pub const PF_OSI: c_int = AF_ISO; +pub const PF_ECMA: c_int = AF_ECMA; +pub const PF_DATAKIT: c_int = AF_DATAKIT; +pub const PF_CCITT: c_int = AF_CCITT; +pub const PF_SNA: c_int = AF_SNA; +pub const PF_DECnet: c_int = AF_DECnet; +pub const PF_DLI: c_int = AF_DLI; +pub const PF_LAT: c_int = AF_LAT; +pub const PF_HYLINK: c_int = AF_HYLINK; +pub const PF_APPLETALK: c_int = AF_APPLETALK; +pub const PF_ROUTE: c_int = AF_ROUTE; +pub const PF_LINK: c_int = AF_LINK; +pub const PF_XTP: c_int = 19; +pub const PF_RIF: c_int = AF_RIF; +pub const PF_INTF: c_int = AF_INTF; +pub const PF_NDD: c_int = AF_NDD; +pub const PF_INET6: c_int = AF_INET6; +pub const PF_MAX: c_int = AF_MAX; +pub const SF_CLOSE: c_int = 1; +pub const SF_REUSE: c_int = 2; +pub const SF_DONT_CACHE: c_int = 4; +pub const SF_SYNC_CACHE: c_int = 8; +pub const SOCK_DGRAM: c_int = 2; +pub const SOCK_STREAM: c_int = 1; +pub const SOCK_RAW: c_int = 3; +pub const SOCK_RDM: c_int = 4; +pub const SOCK_SEQPACKET: c_int = 5; +pub const SOL_SOCKET: c_int = 0xffff; +pub const SO_DEBUG: c_int = 0x0001; +pub const SO_ACCEPTCONN: c_int = 0x0002; +pub const SO_REUSEADDR: c_int = 0x0004; +pub const SO_KEEPALIVE: c_int = 0x0008; +pub const SO_DONTROUTE: c_int = 0x0010; +pub const SO_BROADCAST: c_int = 0x0020; +pub const SO_USELOOPBACK: c_int = 0x0040; +pub const SO_LINGER: c_int = 0x0080; +pub const SO_OOBINLINE: c_int = 0x0100; +pub const SO_REUSEPORT: c_int = 0x0200; +pub const SO_USE_IFBUFS: c_int = 0x0400; +pub const SO_CKSUMRECV: c_int = 0x0800; +pub const SO_NOREUSEADDR: c_int = 0x1000; +pub const SO_KERNACCEPT: c_int = 0x2000; +pub const SO_NOMULTIPATH: c_int = 0x4000; +pub const SO_AUDIT: c_int = 0x8000; +pub const SO_SNDBUF: c_int = 0x1001; +pub const SO_RCVBUF: c_int = 0x1002; +pub const SO_SNDLOWAT: c_int = 0x1003; +pub const SO_RCVLOWAT: c_int = 0x1004; +pub const SO_SNDTIMEO: c_int = 0x1005; +pub const SO_RCVTIMEO: c_int = 0x1006; +pub const SO_ERROR: c_int = 0x1007; +pub const SO_TYPE: c_int = 0x1008; +pub const SCM_RIGHTS: c_int = 0x01; +pub const MSG_OOB: c_int = 0x1; +pub const MSG_PEEK: c_int = 0x2; +pub const MSG_DONTROUTE: c_int = 0x4; +pub const MSG_EOR: c_int = 0x8; +pub const MSG_TRUNC: c_int = 0x10; +pub const MSG_CTRUNC: c_int = 0x20; +pub const MSG_WAITALL: c_int = 0x40; +pub const MSG_MPEG2: c_int = 0x80; +pub const MSG_NOSIGNAL: c_int = 0x100; +pub const MSG_WAITFORONE: c_int = 0x200; +pub const MSG_ARGEXT: c_int = 0x400; +pub const MSG_NONBLOCK: c_int = 0x4000; +pub const MSG_COMPAT: c_int = 0x8000; +pub const MSG_MAXIOVLEN: c_int = 16; +pub const SHUT_RD: c_int = 0; +pub const SHUT_WR: c_int = 1; +pub const SHUT_RDWR: c_int = 2; + +// sys/stat.h +pub const UTIME_NOW: c_int = -2; +pub const UTIME_OMIT: c_int = -3; + +// sys/statvfs.h +pub const ST_RDONLY: c_ulong = 0x0001; +pub const ST_NOSUID: c_ulong = 0x0040; +pub const ST_NODEV: c_ulong = 0x0080; + +// sys/stropts.h +pub const I_NREAD: c_int = 0x20005301; +pub const I_PUSH: c_int = 0x20005302; +pub const I_POP: c_int = 0x20005303; +pub const I_LOOK: c_int = 0x20005304; +pub const I_FLUSH: c_int = 0x20005305; +pub const I_SRDOPT: c_int = 0x20005306; +pub const I_GRDOPT: c_int = 0x20005307; +pub const I_STR: c_int = 0x20005308; +pub const I_SETSIG: c_int = 0x20005309; +pub const I_GETSIG: c_int = 0x2000530a; +pub const I_FIND: c_int = 0x2000530b; +pub const I_LINK: c_int = 0x2000530c; +pub const I_UNLINK: c_int = 0x2000530d; +pub const I_PEEK: c_int = 0x2000530f; +pub const I_FDINSERT: c_int = 0x20005310; +pub const I_SENDFD: c_int = 0x20005311; +pub const I_RECVFD: c_int = 0x20005312; +pub const I_SWROPT: c_int = 0x20005314; +pub const I_GWROPT: c_int = 0x20005315; +pub const I_LIST: c_int = 0x20005316; +pub const I_PLINK: c_int = 0x2000531d; +pub const I_PUNLINK: c_int = 0x2000531e; +pub const I_FLUSHBAND: c_int = 0x20005313; +pub const I_CKBAND: c_int = 0x20005318; +pub const I_GETBAND: c_int = 0x20005319; +pub const I_ATMARK: c_int = 0x20005317; +pub const I_SETCLTIME: c_int = 0x2000531b; +pub const I_GETCLTIME: c_int = 0x2000531c; +pub const I_CANPUT: c_int = 0x2000531a; + +// sys/syslog.h +pub const LOG_CRON: c_int = 9 << 3; +pub const LOG_AUTHPRIV: c_int = 10 << 3; +pub const LOG_NFACILITIES: c_int = 24; +pub const LOG_PERROR: c_int = 0x20; + +// sys/systemcfg.h +pub const SC_ARCH: c_int = 1; +pub const SC_IMPL: c_int = 2; +pub const SC_VERS: c_int = 3; +pub const SC_WIDTH: c_int = 4; +pub const SC_NCPUS: c_int = 5; +pub const SC_L1C_ATTR: c_int = 6; +pub const SC_L1C_ISZ: c_int = 7; +pub const SC_L1C_DSZ: c_int = 8; +pub const SC_L1C_ICA: c_int = 9; +pub const SC_L1C_DCA: c_int = 10; +pub const SC_L1C_IBS: c_int = 11; +pub const SC_L1C_DBS: c_int = 12; +pub const SC_L1C_ILS: c_int = 13; +pub const SC_L1C_DLS: c_int = 14; +pub const SC_L2C_SZ: c_int = 15; +pub const SC_L2C_AS: c_int = 16; +pub const SC_TLB_ATTR: c_int = 17; +pub const SC_ITLB_SZ: c_int = 18; +pub const SC_DTLB_SZ: c_int = 19; +pub const SC_ITLB_ATT: c_int = 20; +pub const SC_DTLB_ATT: c_int = 21; +pub const SC_RESRV_SZ: c_int = 22; +pub const SC_PRI_LC: c_int = 23; +pub const SC_PRO_LC: c_int = 24; +pub const SC_RTC_TYPE: c_int = 25; +pub const SC_VIRT_AL: c_int = 26; +pub const SC_CAC_CONG: c_int = 27; +pub const SC_MOD_ARCH: c_int = 28; +pub const SC_MOD_IMPL: c_int = 29; +pub const SC_XINT: c_int = 30; +pub const SC_XFRAC: c_int = 31; +pub const SC_KRN_ATTR: c_int = 32; +pub const SC_PHYSMEM: c_int = 33; +pub const SC_SLB_ATTR: c_int = 34; +pub const SC_SLB_SZ: c_int = 35; +pub const SC_MAX_NCPUS: c_int = 37; +pub const SC_MAX_REALADDR: c_int = 38; +pub const SC_ORIG_ENT_CAP: c_int = 39; +pub const SC_ENT_CAP: c_int = 40; +pub const SC_DISP_WHE: c_int = 41; +pub const SC_CAPINC: c_int = 42; +pub const SC_VCAPW: c_int = 43; +pub const SC_SPLP_STAT: c_int = 44; +pub const SC_SMT_STAT: c_int = 45; +pub const SC_SMT_TC: c_int = 46; +pub const SC_VMX_VER: c_int = 47; +pub const SC_LMB_SZ: c_int = 48; +pub const SC_MAX_XCPU: c_int = 49; +pub const SC_EC_LVL: c_int = 50; +pub const SC_AME_STAT: c_int = 51; +pub const SC_ECO_STAT: c_int = 52; +pub const SC_DFP_VER: c_int = 53; +pub const SC_VRM_STAT: c_int = 54; +pub const SC_PHYS_IMP: c_int = 55; +pub const SC_PHYS_VER: c_int = 56; +pub const SC_SPCM_STATUS: c_int = 57; +pub const SC_SPCM_MAX: c_int = 58; +pub const SC_TM_VER: c_int = 59; +pub const SC_NX_CAP: c_int = 60; +pub const SC_PKS_STATE: c_int = 61; +pub const SC_MMA_VER: c_int = 62; +pub const POWER_RS: c_int = 1; +pub const POWER_PC: c_int = 2; +pub const IA64: c_int = 3; +pub const POWER_RS1: c_int = 0x1; +pub const POWER_RSC: c_int = 0x2; +pub const POWER_RS2: c_int = 0x4; +pub const POWER_601: c_int = 0x8; +pub const POWER_604: c_int = 0x10; +pub const POWER_603: c_int = 0x20; +pub const POWER_620: c_int = 0x40; +pub const POWER_630: c_int = 0x80; +pub const POWER_A35: c_int = 0x100; +pub const POWER_RS64II: c_int = 0x200; +pub const POWER_RS64III: c_int = 0x400; +pub const POWER_4: c_int = 0x800; +pub const POWER_RS64IV: c_int = POWER_4; +pub const POWER_MPC7450: c_int = 0x1000; +pub const POWER_5: c_int = 0x2000; +pub const POWER_6: c_int = 0x4000; +pub const POWER_7: c_int = 0x8000; +pub const POWER_8: c_int = 0x10000; +pub const POWER_9: c_int = 0x20000; + +// sys/time.h +pub const FD_SETSIZE: usize = 65534; +pub const TIMEOFDAY: c_int = 9; +pub const CLOCK_REALTIME: crate::clockid_t = TIMEOFDAY as clockid_t; +pub const CLOCK_MONOTONIC: crate::clockid_t = 10; +pub const TIMER_ABSTIME: c_int = 999; +pub const ITIMER_REAL: c_int = 0; +pub const ITIMER_VIRTUAL: c_int = 1; +pub const ITIMER_PROF: c_int = 2; +pub const ITIMER_VIRT: c_int = 3; +pub const ITIMER_REAL1: c_int = 20; +pub const ITIMER_REAL_TH: c_int = ITIMER_REAL1; +pub const DST_AUST: c_int = 2; +pub const DST_CAN: c_int = 6; +pub const DST_EET: c_int = 5; +pub const DST_MET: c_int = 4; +pub const DST_NONE: c_int = 0; +pub const DST_USA: c_int = 1; +pub const DST_WET: c_int = 3; + +// sys/termio.h +pub const CSTART: crate::tcflag_t = 0o21; +pub const CSTOP: crate::tcflag_t = 0o23; +pub const TCGETA: c_int = TIOC | 5; +pub const TCSETA: c_int = TIOC | 6; +pub const TCSETAW: c_int = TIOC | 7; +pub const TCSETAF: c_int = TIOC | 8; +pub const TCSBRK: c_int = TIOC | 9; +pub const TCXONC: c_int = TIOC | 11; +pub const TCFLSH: c_int = TIOC | 12; +pub const TCGETS: c_int = TIOC | 1; +pub const TCSETS: c_int = TIOC | 2; +pub const TCSANOW: c_int = 0; +pub const TCSETSW: c_int = TIOC | 3; +pub const TCSADRAIN: c_int = 1; +pub const TCSETSF: c_int = TIOC | 4; +pub const TCSAFLUSH: c_int = 2; +pub const TCIFLUSH: c_int = 0; +pub const TCOFLUSH: c_int = 1; +pub const TCIOFLUSH: c_int = 2; +pub const TCOOFF: c_int = 0; +pub const TCOON: c_int = 1; +pub const TCIOFF: c_int = 2; +pub const TCION: c_int = 3; +pub const TIOC: c_int = 0x5400; +pub const TIOCGWINSZ: c_int = 0x40087468; +pub const TIOCSWINSZ: c_int = 0x80087467; +pub const TIOCLBIS: c_int = 0x8004747f; +pub const TIOCLBIC: c_int = 0x8004747e; +pub const TIOCLSET: c_int = 0x8004747d; +pub const TIOCLGET: c_int = 0x4004747c; +pub const TIOCSBRK: c_int = 0x2000747b; +pub const TIOCCBRK: c_int = 0x2000747a; +pub const TIOCSDTR: c_int = 0x20007479; +pub const TIOCCDTR: c_int = 0x20007478; +pub const TIOCSLTC: c_int = 0x80067475; +pub const TIOCGLTC: c_int = 0x40067474; +pub const TIOCOUTQ: c_int = 0x40047473; +pub const TIOCNOTTY: c_int = 0x20007471; +pub const TIOCSTOP: c_int = 0x2000746f; +pub const TIOCSTART: c_int = 0x2000746e; +pub const TIOCGPGRP: c_int = 0x40047477; +pub const TIOCSPGRP: c_int = 0x80047476; +pub const TIOCGSID: c_int = 0x40047448; +pub const TIOCSTI: c_int = 0x80017472; +pub const TIOCMSET: c_int = 0x8004746d; +pub const TIOCMBIS: c_int = 0x8004746c; +pub const TIOCMBIC: c_int = 0x8004746b; +pub const TIOCMGET: c_int = 0x4004746a; +pub const TIOCREMOTE: c_int = 0x80047469; + +// sys/user.h +pub const MAXCOMLEN: c_int = 32; +pub const UF_SYSTEM: c_int = 0x1000; + +// sys/vattr.h +pub const AT_FLAGS: c_int = 0x80; +pub const AT_GID: c_int = 8; +pub const AT_UID: c_int = 4; + +// sys/wait.h +pub const P_ALL: idtype_t = 0; +pub const P_PID: idtype_t = 1; +pub const P_PGID: idtype_t = 2; +pub const WNOHANG: c_int = 0x1; +pub const WUNTRACED: c_int = 0x2; +pub const WEXITED: c_int = 0x04; +pub const WCONTINUED: c_int = 0x01000000; +pub const WNOWAIT: c_int = 0x10; +pub const WSTOPPED: c_int = _W_STOPPED; +pub const _W_STOPPED: c_int = 0x00000040; +pub const _W_SLWTED: c_int = 0x0000007c; +pub const _W_SEWTED: c_int = 0x0000007d; +pub const _W_SFWTED: c_int = 0x0000007e; +pub const _W_STRC: c_int = 0x0000007f; + +// termios.h +pub const NCCS: usize = 16; +pub const OLCUC: crate::tcflag_t = 2; +pub const CSIZE: crate::tcflag_t = 0x00000030; +pub const CS5: crate::tcflag_t = 0x00000000; +pub const CS6: crate::tcflag_t = 0x00000010; +pub const CS7: crate::tcflag_t = 0x00000020; +pub const CS8: crate::tcflag_t = 0x00000030; +pub const CSTOPB: crate::tcflag_t = 0x00000040; +pub const ECHO: crate::tcflag_t = 0x00000008; +pub const ECHOE: crate::tcflag_t = 0x00000010; +pub const ECHOK: crate::tcflag_t = 0x00000020; +pub const ECHONL: crate::tcflag_t = 0x00000040; +pub const ECHOCTL: crate::tcflag_t = 0x00020000; +pub const ECHOPRT: crate::tcflag_t = 0x00040000; +pub const ECHOKE: crate::tcflag_t = 0x00080000; +pub const IGNBRK: crate::tcflag_t = 0x00000001; +pub const BRKINT: crate::tcflag_t = 0x00000002; +pub const IGNPAR: crate::tcflag_t = 0x00000004; +pub const PARMRK: crate::tcflag_t = 0x00000008; +pub const INPCK: crate::tcflag_t = 0x00000010; +pub const ISTRIP: crate::tcflag_t = 0x00000020; +pub const INLCR: crate::tcflag_t = 0x00000040; +pub const IGNCR: crate::tcflag_t = 0x00000080; +pub const ICRNL: crate::tcflag_t = 0x00000100; +pub const IXON: crate::tcflag_t = 0x00000200; +pub const IXOFF: crate::tcflag_t = 0x00000400; +pub const IXANY: crate::tcflag_t = 0x00001000; +pub const IMAXBEL: crate::tcflag_t = 0x00010000; +pub const OPOST: crate::tcflag_t = 0x00000001; +pub const ONLCR: crate::tcflag_t = 0x00000004; +pub const OCRNL: crate::tcflag_t = 0x00000008; +pub const ONOCR: crate::tcflag_t = 0x00000010; +pub const ONLRET: crate::tcflag_t = 0x00000020; +pub const CREAD: crate::tcflag_t = 0x00000080; +pub const IEXTEN: crate::tcflag_t = 0x00200000; +pub const TOSTOP: crate::tcflag_t = 0x00010000; +pub const FLUSHO: crate::tcflag_t = 0x00100000; +pub const PENDIN: crate::tcflag_t = 0x20000000; +pub const NOFLSH: crate::tcflag_t = 0x00000080; +pub const VINTR: usize = 0; +pub const VQUIT: usize = 1; +pub const VERASE: usize = 2; +pub const VKILL: usize = 3; +pub const VEOF: usize = 4; +pub const VEOL: usize = 5; +pub const VSTART: usize = 7; +pub const VSTOP: usize = 8; +pub const VSUSP: usize = 9; +pub const VMIN: usize = 4; +pub const VTIME: usize = 5; +pub const VEOL2: usize = 6; +pub const VDSUSP: usize = 10; +pub const VREPRINT: usize = 11; +pub const VDISCRD: usize = 12; +pub const VWERSE: usize = 13; +pub const VLNEXT: usize = 14; +pub const B0: crate::speed_t = 0x0; +pub const B50: crate::speed_t = 0x1; +pub const B75: crate::speed_t = 0x2; +pub const B110: crate::speed_t = 0x3; +pub const B134: crate::speed_t = 0x4; +pub const B150: crate::speed_t = 0x5; +pub const B200: crate::speed_t = 0x6; +pub const B300: crate::speed_t = 0x7; +pub const B600: crate::speed_t = 0x8; +pub const B1200: crate::speed_t = 0x9; +pub const B1800: crate::speed_t = 0xa; +pub const B2400: crate::speed_t = 0xb; +pub const B4800: crate::speed_t = 0xc; +pub const B9600: crate::speed_t = 0xd; +pub const B19200: crate::speed_t = 0xe; +pub const B38400: crate::speed_t = 0xf; +pub const EXTA: crate::speed_t = B19200; +pub const EXTB: crate::speed_t = B38400; +pub const IUCLC: crate::tcflag_t = 0x00000800; +pub const OFILL: crate::tcflag_t = 0x00000040; +pub const OFDEL: crate::tcflag_t = 0x00000080; +pub const CRDLY: crate::tcflag_t = 0x00000300; +pub const CR0: crate::tcflag_t = 0x00000000; +pub const CR1: crate::tcflag_t = 0x00000100; +pub const CR2: crate::tcflag_t = 0x00000200; +pub const CR3: crate::tcflag_t = 0x00000300; +pub const TABDLY: crate::tcflag_t = 0x00000c00; +pub const TAB0: crate::tcflag_t = 0x00000000; +pub const TAB1: crate::tcflag_t = 0x00000400; +pub const TAB2: crate::tcflag_t = 0x00000800; +pub const TAB3: crate::tcflag_t = 0x00000c00; +pub const BSDLY: crate::tcflag_t = 0x00001000; +pub const BS0: crate::tcflag_t = 0x00000000; +pub const BS1: crate::tcflag_t = 0x00001000; +pub const FFDLY: crate::tcflag_t = 0x00002000; +pub const FF0: crate::tcflag_t = 0x00000000; +pub const FF1: crate::tcflag_t = 0x00002000; +pub const NLDLY: crate::tcflag_t = 0x00004000; +pub const NL0: crate::tcflag_t = 0x00000000; +pub const NL1: crate::tcflag_t = 0x00004000; +pub const VTDLY: crate::tcflag_t = 0x00008000; +pub const VT0: crate::tcflag_t = 0x00000000; +pub const VT1: crate::tcflag_t = 0x00008000; +pub const OXTABS: crate::tcflag_t = 0x00040000; +pub const ONOEOT: crate::tcflag_t = 0x00080000; +pub const CBAUD: crate::tcflag_t = 0x0000000f; +pub const PARENB: crate::tcflag_t = 0x00000100; +pub const PARODD: crate::tcflag_t = 0x00000200; +pub const HUPCL: crate::tcflag_t = 0x00000400; +pub const CLOCAL: crate::tcflag_t = 0x00000800; +pub const CIBAUD: crate::tcflag_t = 0x000f0000; +pub const IBSHIFT: crate::tcflag_t = 16; +pub const PAREXT: crate::tcflag_t = 0x00100000; +pub const ISIG: crate::tcflag_t = 0x00000001; +pub const ICANON: crate::tcflag_t = 0x00000002; +pub const XCASE: crate::tcflag_t = 0x00000004; +pub const ALTWERASE: crate::tcflag_t = 0x00400000; + +// time.h +pub const CLOCK_PROCESS_CPUTIME_ID: crate::clockid_t = 11; +pub const CLOCK_THREAD_CPUTIME_ID: crate::clockid_t = 12; + +// unistd.h +pub const _POSIX_VDISABLE: c_int = 0xff; +pub const _PC_LINK_MAX: c_int = 11; +pub const _PC_MAX_CANON: c_int = 12; +pub const _PC_MAX_INPUT: c_int = 13; +pub const _PC_NAME_MAX: c_int = 14; +pub const _PC_PATH_MAX: c_int = 16; +pub const _PC_PIPE_BUF: c_int = 17; +pub const _PC_NO_TRUNC: c_int = 15; +pub const _PC_VDISABLE: c_int = 18; +pub const _PC_CHOWN_RESTRICTED: c_int = 10; +pub const _PC_ASYNC_IO: c_int = 19; +pub const _PC_PRIO_IO: c_int = 21; +pub const _PC_SYNC_IO: c_int = 20; +pub const _PC_ALLOC_SIZE_MIN: c_int = 26; +pub const _PC_REC_INCR_XFER_SIZE: c_int = 27; +pub const _PC_REC_MAX_XFER_SIZE: c_int = 28; +pub const _PC_REC_MIN_XFER_SIZE: c_int = 29; +pub const _PC_REC_XFER_ALIGN: c_int = 30; +pub const _PC_SYMLINK_MAX: c_int = 25; +pub const _PC_2_SYMLINKS: c_int = 31; +pub const _PC_TIMESTAMP_RESOLUTION: c_int = 32; +pub const _PC_FILESIZEBITS: c_int = 22; +pub const _SC_ARG_MAX: c_int = 0; +pub const _SC_CHILD_MAX: c_int = 1; +pub const _SC_CLK_TCK: c_int = 2; +pub const _SC_NGROUPS_MAX: c_int = 3; +pub const _SC_OPEN_MAX: c_int = 4; +pub const _SC_JOB_CONTROL: c_int = 7; +pub const _SC_SAVED_IDS: c_int = 8; +pub const _SC_VERSION: c_int = 9; +pub const _SC_PASS_MAX: c_int = 45; +pub const _SC_PAGESIZE: c_int = _SC_PAGE_SIZE; +pub const _SC_PAGE_SIZE: c_int = 48; +pub const _SC_XOPEN_VERSION: c_int = 46; +pub const _SC_NPROCESSORS_CONF: c_int = 71; +pub const _SC_NPROCESSORS_ONLN: c_int = 72; +pub const _SC_STREAM_MAX: c_int = 5; +pub const _SC_TZNAME_MAX: c_int = 6; +pub const _SC_AIO_LISTIO_MAX: c_int = 75; +pub const _SC_AIO_MAX: c_int = 76; +pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 77; +pub const _SC_ASYNCHRONOUS_IO: c_int = 78; +pub const _SC_DELAYTIMER_MAX: c_int = 79; +pub const _SC_FSYNC: c_int = 80; +pub const _SC_MAPPED_FILES: c_int = 84; +pub const _SC_MEMLOCK: c_int = 85; +pub const _SC_MEMLOCK_RANGE: c_int = 86; +pub const _SC_MEMORY_PROTECTION: c_int = 87; +pub const _SC_MESSAGE_PASSING: c_int = 88; +pub const _SC_MQ_OPEN_MAX: c_int = 89; +pub const _SC_MQ_PRIO_MAX: c_int = 90; +pub const _SC_PRIORITIZED_IO: c_int = 91; +pub const _SC_PRIORITY_SCHEDULING: c_int = 92; +pub const _SC_REALTIME_SIGNALS: c_int = 93; +pub const _SC_RTSIG_MAX: c_int = 94; +pub const _SC_SEMAPHORES: c_int = 95; +pub const _SC_SEM_NSEMS_MAX: c_int = 96; +pub const _SC_SEM_VALUE_MAX: c_int = 97; +pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 98; +pub const _SC_SIGQUEUE_MAX: c_int = 99; +pub const _SC_SYNCHRONIZED_IO: c_int = 100; +pub const _SC_TIMERS: c_int = 102; +pub const _SC_TIMER_MAX: c_int = 103; +pub const _SC_2_C_BIND: c_int = 51; +pub const _SC_2_C_DEV: c_int = 32; +pub const _SC_2_C_VERSION: c_int = 52; +pub const _SC_2_FORT_DEV: c_int = 33; +pub const _SC_2_FORT_RUN: c_int = 34; +pub const _SC_2_LOCALEDEF: c_int = 35; +pub const _SC_2_SW_DEV: c_int = 36; +pub const _SC_2_UPE: c_int = 53; +pub const _SC_2_VERSION: c_int = 31; +pub const _SC_BC_BASE_MAX: c_int = 23; +pub const _SC_BC_DIM_MAX: c_int = 24; +pub const _SC_BC_SCALE_MAX: c_int = 25; +pub const _SC_BC_STRING_MAX: c_int = 26; +pub const _SC_COLL_WEIGHTS_MAX: c_int = 50; +pub const _SC_EXPR_NEST_MAX: c_int = 28; +pub const _SC_LINE_MAX: c_int = 29; +pub const _SC_RE_DUP_MAX: c_int = 30; +pub const _SC_XOPEN_CRYPT: c_int = 56; +pub const _SC_XOPEN_ENH_I18N: c_int = 57; +pub const _SC_XOPEN_SHM: c_int = 55; +pub const _SC_2_CHAR_TERM: c_int = 54; +pub const _SC_XOPEN_XCU_VERSION: c_int = 109; +pub const _SC_ATEXIT_MAX: c_int = 47; +pub const _SC_IOV_MAX: c_int = 58; +pub const _SC_XOPEN_UNIX: c_int = 73; +pub const _SC_T_IOV_MAX: c_int = 0; +pub const _SC_PHYS_PAGES: c_int = 113; +pub const _SC_AVPHYS_PAGES: c_int = 114; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 101; +pub const _SC_GETGR_R_SIZE_MAX: c_int = 81; +pub const _SC_GETPW_R_SIZE_MAX: c_int = 82; +pub const _SC_LOGIN_NAME_MAX: c_int = 83; +pub const _SC_THREAD_KEYS_MAX: c_int = 68; +pub const _SC_THREAD_STACK_MIN: c_int = 69; +pub const _SC_THREAD_THREADS_MAX: c_int = 70; +pub const _SC_TTY_NAME_MAX: c_int = 104; +pub const _SC_THREADS: c_int = 60; +pub const _SC_THREAD_ATTR_STACKADDR: c_int = 61; +pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 62; +pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 64; +pub const _SC_THREAD_PRIO_INHERIT: c_int = 65; +pub const _SC_THREAD_PRIO_PROTECT: c_int = 66; +pub const _SC_THREAD_PROCESS_SHARED: c_int = 67; +pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 59; +pub const _SC_XOPEN_LEGACY: c_int = 112; +pub const _SC_XOPEN_REALTIME: c_int = 110; +pub const _SC_XOPEN_REALTIME_THREADS: c_int = 111; +pub const _SC_XBS5_ILP32_OFF32: c_int = 105; +pub const _SC_XBS5_ILP32_OFFBIG: c_int = 106; +pub const _SC_XBS5_LP64_OFF64: c_int = 107; +pub const _SC_XBS5_LPBIG_OFFBIG: c_int = 108; +pub const _SC_2_PBS: c_int = 132; +pub const _SC_2_PBS_ACCOUNTING: c_int = 133; +pub const _SC_2_PBS_CHECKPOINT: c_int = 134; +pub const _SC_2_PBS_LOCATE: c_int = 135; +pub const _SC_2_PBS_MESSAGE: c_int = 136; +pub const _SC_2_PBS_TRACK: c_int = 137; +pub const _SC_ADVISORY_INFO: c_int = 130; +pub const _SC_BARRIERS: c_int = 138; +pub const _SC_CLOCK_SELECTION: c_int = 139; +pub const _SC_CPUTIME: c_int = 140; +pub const _SC_HOST_NAME_MAX: c_int = 126; +pub const _SC_MONOTONIC_CLOCK: c_int = 141; +pub const _SC_READER_WRITER_LOCKS: c_int = 142; +pub const _SC_REGEXP: c_int = 127; +pub const _SC_SHELL: c_int = 128; +pub const _SC_SPAWN: c_int = 143; +pub const _SC_SPIN_LOCKS: c_int = 144; +pub const _SC_SPORADIC_SERVER: c_int = 145; +pub const _SC_SS_REPL_MAX: c_int = 156; +pub const _SC_SYMLOOP_MAX: c_int = 129; +pub const _SC_THREAD_CPUTIME: c_int = 146; +pub const _SC_THREAD_SPORADIC_SERVER: c_int = 147; +pub const _SC_TIMEOUTS: c_int = 148; +pub const _SC_TRACE: c_int = 149; +pub const _SC_TRACE_EVENT_FILTER: c_int = 150; +pub const _SC_TRACE_EVENT_NAME_MAX: c_int = 157; +pub const _SC_TRACE_INHERIT: c_int = 151; +pub const _SC_TRACE_LOG: c_int = 152; +pub const _SC_TRACE_NAME_MAX: c_int = 158; +pub const _SC_TRACE_SYS_MAX: c_int = 159; +pub const _SC_TRACE_USER_EVENT_MAX: c_int = 160; +pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 153; +pub const _SC_V6_ILP32_OFF32: c_int = 121; +pub const _SC_V6_ILP32_OFFBIG: c_int = 122; +pub const _SC_V6_LP64_OFF64: c_int = 123; +pub const _SC_V6_LPBIG_OFFBIG: c_int = 124; +pub const _SC_XOPEN_STREAMS: c_int = 125; +pub const _SC_IPV6: c_int = 154; +pub const _SC_RAW_SOCKETS: c_int = 155; + +// utmp.h +pub const EMPTY: c_short = 0; +pub const RUN_LVL: c_short = 1; +pub const BOOT_TIME: c_short = 2; +pub const OLD_TIME: c_short = 3; +pub const NEW_TIME: c_short = 4; +pub const INIT_PROCESS: c_short = 5; +pub const LOGIN_PROCESS: c_short = 6; +pub const USER_PROCESS: c_short = 7; +pub const DEAD_PROCESS: c_short = 8; +pub const ACCOUNTING: c_short = 9; + +f! { + pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { + if (*mhdr).msg_controllen as usize >= size_of::() { + (*mhdr).msg_control as *mut cmsghdr + } else { + core::ptr::null_mut::() + } + } + + pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { + if cmsg.is_null() { + CMSG_FIRSTHDR(mhdr) + } else { + if (cmsg as usize + (*cmsg).cmsg_len as usize + size_of::()) + > ((*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize) + { + core::ptr::null_mut::() + } else { + // AIX does not have any alignment/padding for ancillary data, so we don't need _CMSG_ALIGN here. + (cmsg as usize + (*cmsg).cmsg_len as usize) as *mut cmsghdr + } + } + } + + pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { + (cmsg as *mut c_uchar).offset(size_of::() as isize) + } + + pub const fn CMSG_LEN(length: c_uint) -> c_uint { + size_of::() as c_uint + length + } + + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { + size_of::() as c_uint + length + } + + pub fn FD_ZERO(set: *mut fd_set) -> () { + for slot in (*set).fds_bits.iter_mut() { + *slot = 0; + } + } + + pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { + let bits = size_of::() * 8; + let fd = fd as usize; + (*set).fds_bits[fd / bits] |= 1 << (fd % bits); + return; + } + + pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { + let bits = size_of::() * 8; + let fd = fd as usize; + (*set).fds_bits[fd / bits] &= !(1 << (fd % bits)); + return; + } + + pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { + let bits = size_of::() * 8; + let fd = fd as usize; + return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0; + } +} + +safe_f! { + pub const fn WIFSTOPPED(status: c_int) -> bool { + (status & _W_STOPPED) != 0 + } + + pub const fn WSTOPSIG(status: c_int) -> c_int { + if WIFSTOPPED(status) { + (((status as c_uint) >> 8) & 0xff) as c_int + } else { + -1 + } + } + + pub const fn WIFEXITED(status: c_int) -> bool { + (status & 0xFF) == 0 + } + + pub const fn WEXITSTATUS(status: c_int) -> c_int { + if WIFEXITED(status) { + (((status as c_uint) >> 8) & 0xff) as c_int + } else { + -1 + } + } + + pub const fn WIFSIGNALED(status: c_int) -> bool { + !WIFEXITED(status) && !WIFSTOPPED(status) + } + + pub const fn WTERMSIG(status: c_int) -> c_int { + if WIFSIGNALED(status) { + (((status as c_uint) >> 16) & 0xff) as c_int + } else { + -1 + } + } + + pub const fn WIFCONTINUED(status: c_int) -> bool { + (status & WCONTINUED) != 0 + } + + // AIX doesn't have native WCOREDUMP. + pub const fn WCOREDUMP(_status: c_int) -> bool { + false + } + + pub const fn major(dev: crate::dev_t) -> c_uint { + let x = dev >> 16; + x as c_uint + } + + pub const fn minor(dev: crate::dev_t) -> c_uint { + let y = dev & 0xFFFF; + y as c_uint + } + + pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { + let major = major as crate::dev_t; + let minor = minor as crate::dev_t; + let mut dev = 0; + dev |= major << 16; + dev |= minor; + dev + } +} + +#[link(name = "thread")] +extern "C" { + pub fn thr_kill(id: thread_t, sig: c_int) -> c_int; + pub fn thr_self() -> thread_t; +} + +#[link(name = "pthread")] +extern "C" { + pub fn pthread_atfork( + prepare: Option, + parent: Option, + child: Option, + ) -> c_int; + + pub fn pthread_attr_getdetachstate( + attr: *const crate::pthread_attr_t, + detachstate: *mut c_int, + ) -> c_int; + + pub fn pthread_attr_getguardsize( + attr: *const crate::pthread_attr_t, + guardsize: *mut size_t, + ) -> c_int; + + pub fn pthread_attr_getinheritsched( + attr: *const crate::pthread_attr_t, + inheritsched: *mut c_int, + ) -> c_int; + + pub fn pthread_attr_getschedparam( + attr: *const crate::pthread_attr_t, + param: *mut sched_param, + ) -> c_int; + + pub fn pthread_attr_getstackaddr( + attr: *const crate::pthread_attr_t, + stackaddr: *mut *mut c_void, + ) -> c_int; + + pub fn pthread_attr_getschedpolicy( + attr: *const crate::pthread_attr_t, + policy: *mut c_int, + ) -> c_int; + + pub fn pthread_attr_getscope( + attr: *const crate::pthread_attr_t, + contentionscope: *mut c_int, + ) -> c_int; + + pub fn pthread_attr_getstack( + attr: *const crate::pthread_attr_t, + stackaddr: *mut *mut c_void, + stacksize: *mut size_t, + ) -> c_int; + + pub fn pthread_attr_setguardsize(attr: *mut crate::pthread_attr_t, guardsize: size_t) -> c_int; + + pub fn pthread_attr_setinheritsched( + attr: *mut crate::pthread_attr_t, + inheritsched: c_int, + ) -> c_int; + + pub fn pthread_attr_setschedparam( + attr: *mut crate::pthread_attr_t, + param: *const sched_param, + ) -> c_int; + + pub fn pthread_attr_setschedpolicy(attr: *mut crate::pthread_attr_t, policy: c_int) -> c_int; + + pub fn pthread_attr_setscope(attr: *mut crate::pthread_attr_t, contentionscope: c_int) + -> c_int; + + pub fn pthread_attr_setstack( + attr: *mut crate::pthread_attr_t, + stackaddr: *mut c_void, + stacksize: size_t, + ) -> c_int; + + pub fn pthread_attr_setstackaddr( + attr: *mut crate::pthread_attr_t, + stackaddr: *mut c_void, + ) -> c_int; + + pub fn pthread_barrierattr_destroy(attr: *mut crate::pthread_barrierattr_t) -> c_int; + + pub fn pthread_barrierattr_getpshared( + attr: *const crate::pthread_barrierattr_t, + pshared: *mut c_int, + ) -> c_int; + + pub fn pthread_barrierattr_init(attr: *mut crate::pthread_barrierattr_t) -> c_int; + + pub fn pthread_barrierattr_setpshared( + attr: *mut crate::pthread_barrierattr_t, + pshared: c_int, + ) -> c_int; + + pub fn pthread_barrier_destroy(barrier: *mut pthread_barrier_t) -> c_int; + + pub fn pthread_barrier_init( + barrier: *mut pthread_barrier_t, + attr: *const crate::pthread_barrierattr_t, + count: c_uint, + ) -> c_int; + + pub fn pthread_barrier_wait(barrier: *mut pthread_barrier_t) -> c_int; + + pub fn pthread_cancel(thread: crate::pthread_t) -> c_int; + + pub fn pthread_cleanup_pop(execute: c_int) -> c_void; + + pub fn pthread_cleanup_push( + routine: Option, + arg: *mut c_void, + ) -> c_void; + + pub fn pthread_condattr_getclock( + attr: *const pthread_condattr_t, + clock_id: *mut clockid_t, + ) -> c_int; + + pub fn pthread_condattr_getpshared( + attr: *const pthread_condattr_t, + pshared: *mut c_int, + ) -> c_int; + + pub fn pthread_condattr_setclock( + attr: *mut pthread_condattr_t, + clock_id: crate::clockid_t, + ) -> c_int; + + pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t, pshared: c_int) -> c_int; + + pub fn pthread_create( + thread: *mut crate::pthread_t, + attr: *const crate::pthread_attr_t, + start_routine: extern "C" fn(*mut c_void) -> *mut c_void, + arg: *mut c_void, + ) -> c_int; + + pub fn pthread_getconcurrency() -> c_int; + + pub fn pthread_getcpuclockid( + thread_id: crate::pthread_t, + clock_id: *mut crate::clockid_t, + ) -> c_int; + + pub fn pthread_getschedparam( + thread: crate::pthread_t, + policy: *mut c_int, + param: *mut sched_param, + ) -> c_int; + + pub fn pthread_kill(thread: crate::pthread_t, sig: c_int) -> c_int; + + pub fn pthread_mutexattr_getprioceiling( + attr: *const crate::pthread_mutexattr_t, + prioceiling: *mut c_int, + ) -> c_int; + + pub fn pthread_mutexattr_getprotocol( + attr: *const pthread_mutexattr_t, + protocol: *mut c_int, + ) -> c_int; + + pub fn pthread_mutexattr_getpshared( + attr: *const pthread_mutexattr_t, + pshared: *mut c_int, + ) -> c_int; + + pub fn pthread_mutexattr_getrobust( + attr: *const crate::pthread_mutexattr_t, + robust: *mut c_int, + ) -> c_int; + + pub fn pthread_mutexattr_gettype( + attr: *const crate::pthread_mutexattr_t, + _type: *mut c_int, + ) -> c_int; + + pub fn pthread_mutexattr_setprioceiling( + attr: *mut crate::pthread_mutexattr_t, + prioceiling: c_int, + ) -> c_int; + + pub fn pthread_mutexattr_setprotocol(attr: *mut pthread_mutexattr_t, protocol: c_int) -> c_int; + + pub fn pthread_mutexattr_setpshared(attr: *mut pthread_mutexattr_t, pshared: c_int) -> c_int; + + pub fn pthread_mutexattr_setrobust( + attr: *mut crate::pthread_mutexattr_t, + robust: c_int, + ) -> c_int; + + pub fn pthread_mutex_consistent(mutex: *mut crate::pthread_mutex_t) -> c_int; + + pub fn pthread_mutex_getprioceiling( + mutex: *const crate::pthread_mutex_t, + prioceiling: *mut c_int, + ) -> c_int; + + pub fn pthread_mutex_setprioceiling( + mutex: *mut crate::pthread_mutex_t, + prioceiling: c_int, + old_ceiling: *mut c_int, + ) -> c_int; + + pub fn pthread_mutex_timedlock( + mutex: *mut pthread_mutex_t, + abstime: *const crate::timespec, + ) -> c_int; + + pub fn pthread_once( + once_control: *mut crate::pthread_once_t, + init_routine: Option, + ) -> c_int; + + pub fn pthread_rwlockattr_getpshared( + attr: *const pthread_rwlockattr_t, + pshared: *mut c_int, + ) -> c_int; + + pub fn pthread_rwlockattr_setpshared(attr: *mut pthread_rwlockattr_t, pshared: c_int) -> c_int; + + pub fn pthread_rwlock_timedrdlock( + rwlock: *mut crate::pthread_rwlock_t, + abstime: *const crate::timespec, + ) -> c_int; + + pub fn pthread_rwlock_timedwrlock( + rwlock: *mut crate::pthread_rwlock_t, + abstime: *const crate::timespec, + ) -> c_int; + + pub fn pthread_setcancelstate(state: c_int, oldstate: *mut c_int) -> c_int; + pub fn pthread_setcanceltype(_type: c_int, oldtype: *mut c_int) -> c_int; + + pub fn pthread_setconcurrency(new_level: c_int) -> c_int; + + pub fn pthread_setschedparam( + thread: crate::pthread_t, + policy: c_int, + param: *const sched_param, + ) -> c_int; + + pub fn pthread_setschedprio(thread: crate::pthread_t, prio: c_int) -> c_int; + + pub fn pthread_sigmask(how: c_int, set: *const sigset_t, oset: *mut sigset_t) -> c_int; + + pub fn pthread_spin_destroy(lock: *mut pthread_spinlock_t) -> c_int; + pub fn pthread_spin_init(lock: *mut pthread_spinlock_t, pshared: c_int) -> c_int; + pub fn pthread_spin_lock(lock: *mut pthread_spinlock_t) -> c_int; + pub fn pthread_spin_trylock(lock: *mut pthread_spinlock_t) -> c_int; + pub fn pthread_spin_unlock(lock: *mut pthread_spinlock_t) -> c_int; + + pub fn pthread_testcancel() -> c_void; +} + +#[link(name = "iconv")] +extern "C" { + pub fn iconv( + cd: iconv_t, + inbuf: *mut *mut c_char, + inbytesleft: *mut size_t, + outbuf: *mut *mut c_char, + outbytesleft: *mut size_t, + ) -> size_t; + pub fn iconv_close(cd: iconv_t) -> c_int; + pub fn iconv_open(tocode: *const c_char, fromcode: *const c_char) -> iconv_t; +} + +extern "C" { + pub fn acct(filename: *mut c_char) -> c_int; + #[link_name = "_posix_aio_cancel"] + pub fn aio_cancel(fildes: c_int, aiocbp: *mut crate::aiocb) -> c_int; + #[link_name = "_posix_aio_error"] + pub fn aio_error(aiocbp: *const crate::aiocb) -> c_int; + #[link_name = "_posix_aio_fsync"] + pub fn aio_fsync(op: c_int, aiocbp: *mut crate::aiocb) -> c_int; + #[link_name = "_posix_aio_read"] + pub fn aio_read(aiocbp: *mut crate::aiocb) -> c_int; + #[link_name = "_posix_aio_return"] + pub fn aio_return(aiocbp: *mut crate::aiocb) -> ssize_t; + #[link_name = "_posix_aio_suspend"] + pub fn aio_suspend( + list: *const *const crate::aiocb, + nent: c_int, + timeout: *const crate::timespec, + ) -> c_int; + #[link_name = "_posix_aio_write"] + pub fn aio_write(aiocbp: *mut crate::aiocb) -> c_int; + pub fn basename(path: *mut c_char) -> *mut c_char; + pub fn bind( + socket: c_int, + address: *const crate::sockaddr, + address_len: crate::socklen_t, + ) -> c_int; + pub fn brk(addr: *mut c_void) -> c_int; + pub fn clearenv() -> c_int; + pub fn clock_getcpuclockid(pid: crate::pid_t, clk_id: *mut crate::clockid_t) -> c_int; + pub fn clock_getres(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; + pub fn clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; + pub fn clock_nanosleep( + clk_id: crate::clockid_t, + flags: c_int, + rqtp: *const crate::timespec, + rmtp: *mut crate::timespec, + ) -> c_int; + pub fn clock_settime(clock_id: crate::clockid_t, tp: *const crate::timespec) -> c_int; + pub fn creat64(path: *const c_char, mode: mode_t) -> c_int; + pub fn ctermid(s: *mut c_char) -> *mut c_char; + pub fn dirfd(dirp: *mut crate::DIR) -> c_int; + pub fn dirname(path: *mut c_char) -> *mut c_char; + pub fn drand48() -> c_double; + pub fn duplocale(arg1: crate::locale_t) -> crate::locale_t; + pub fn endgrent(); + pub fn endmntent(streamp: *mut crate::FILE) -> c_int; + pub fn endpwent(); + pub fn endutent(); + pub fn endutxent(); + pub fn erand48(xseed: *mut c_ushort) -> c_double; + pub fn faccessat(dirfd: c_int, pathname: *const c_char, mode: c_int, flags: c_int) -> c_int; + pub fn fattach(fildes: c_int, path: *const c_char) -> c_int; + pub fn fdatasync(fd: c_int) -> c_int; + + // DIFF(main): changed to `*const *mut` in e77f551de9 + pub fn fexecve(fd: c_int, argv: *const *const c_char, envp: *const *const c_char) -> c_int; + + pub fn ffs(value: c_int) -> c_int; + pub fn ffsl(value: c_long) -> c_int; + pub fn ffsll(value: c_longlong) -> c_int; + pub fn fgetgrent(file: *mut crate::FILE) -> *mut crate::group; + pub fn fgetpos64(stream: *mut crate::FILE, ptr: *mut fpos64_t) -> c_int; + pub fn fgetpwent(file: *mut crate::FILE) -> *mut crate::passwd; + pub fn fopen64(filename: *const c_char, mode: *const c_char) -> *mut crate::FILE; + pub fn freelocale(loc: crate::locale_t); + pub fn freopen64( + filename: *const c_char, + mode: *const c_char, + file: *mut crate::FILE, + ) -> *mut crate::FILE; + pub fn fseeko64(stream: *mut crate::FILE, offset: off64_t, whence: c_int) -> c_int; + pub fn fsetpos64(stream: *mut crate::FILE, ptr: *const fpos64_t) -> c_int; + pub fn fstat64(fildes: c_int, buf: *mut stat64) -> c_int; + pub fn fstatfs(fd: c_int, buf: *mut statfs) -> c_int; + pub fn fstatfs64(fd: c_int, buf: *mut statfs64) -> c_int; + pub fn fstatvfs64(fd: c_int, buf: *mut statvfs64) -> c_int; + pub fn ftello64(stream: *mut crate::FILE) -> off64_t; + pub fn ftok(path: *const c_char, id: c_int) -> crate::key_t; + pub fn ftruncate64(fd: c_int, length: off64_t) -> c_int; + pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int; + pub fn getcontext(ucp: *mut ucontext_t) -> c_int; + pub fn getdomainname(name: *mut c_char, len: c_int) -> c_int; + pub fn getdtablesize() -> c_int; + pub fn getgrent() -> *mut crate::group; + pub fn getgrgid(gid: crate::gid_t) -> *mut crate::group; + #[link_name = "_posix_getgrgid_r"] + pub fn getgrgid_r( + gid: crate::gid_t, + grp: *mut crate::group, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::group, + ) -> c_int; + pub fn getgrnam(name: *const c_char) -> *mut crate::group; + #[link_name = "_posix_getgrnam_r"] + pub fn getgrnam_r( + name: *const c_char, + grp: *mut crate::group, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::group, + ) -> c_int; + pub fn getgrset(user: *const c_char) -> *mut c_char; + pub fn gethostid() -> c_long; + pub fn getmntent(stream: *mut crate::FILE) -> *mut crate::mntent; + pub fn getnameinfo( + sa: *const crate::sockaddr, + salen: size_t, + host: *mut c_char, + hostlen: size_t, + serv: *mut c_char, + servlen: size_t, + flags: c_int, + ) -> c_int; + pub fn getpagesize() -> c_int; + pub fn getpeereid(socket: c_int, euid: *mut crate::uid_t, egid: *mut crate::gid_t) -> c_int; + pub fn getpriority(which: c_int, who: crate::id_t) -> c_int; + pub fn getpwent() -> *mut crate::passwd; + #[link_name = "_posix_getpwnam_r"] + pub fn getpwnam_r( + name: *const c_char, + pwd: *mut passwd, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut passwd, + ) -> c_int; + #[link_name = "_posix_getpwuid_r"] + pub fn getpwuid_r( + uid: crate::uid_t, + pwd: *mut passwd, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut passwd, + ) -> c_int; + pub fn getrlimit(resource: c_int, rlim: *mut crate::rlimit) -> c_int; + pub fn getrlimit64(resource: c_int, rlim: *mut rlimit64) -> c_int; + pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut c_void) -> c_int; + pub fn getitimer(which: c_int, curr_value: *mut crate::itimerval) -> c_int; + pub fn getutent() -> *mut utmp; + pub fn getutid(u: *const utmp) -> *mut utmp; + pub fn getutline(u: *const utmp) -> *mut utmp; + pub fn getutxent() -> *mut utmpx; + pub fn getutxid(ut: *const utmpx) -> *mut utmpx; + pub fn getutxline(ut: *const utmpx) -> *mut utmpx; + pub fn glob( + pattern: *const c_char, + flags: c_int, + errfunc: Option c_int>, + pglob: *mut crate::glob_t, + ) -> c_int; + pub fn globfree(pglob: *mut crate::glob_t); + pub fn hasmntopt(mnt: *const crate::mntent, opt: *const c_char) -> *mut c_char; + pub fn hcreate(nelt: size_t) -> c_int; + pub fn hdestroy(); + pub fn hsearch(entry: entry, action: ACTION) -> *mut entry; + pub fn if_freenameindex(ptr: *mut if_nameindex); + pub fn if_nameindex() -> *mut if_nameindex; + pub fn initgroups(name: *const c_char, basegid: crate::gid_t) -> c_int; + pub fn ioctl(fildes: c_int, request: c_int, ...) -> c_int; + pub fn jrand48(xseed: *mut c_ushort) -> c_long; + pub fn lcong48(p: *mut c_ushort); + pub fn lfind( + key: *const c_void, + base: *const c_void, + nelp: *mut size_t, + width: size_t, + compar: Option c_int>, + ) -> *mut c_void; + #[link_name = "_posix_lio_listio"] + pub fn lio_listio( + mode: c_int, + aiocb_list: *const *mut aiocb, + nent: c_int, + sevp: *mut sigevent, + ) -> c_int; + pub fn loadquery(flags: c_int, buf: *mut c_void, buflen: c_uint, ...) -> c_int; + pub fn lpar_get_info(command: c_int, buf: *mut c_void, bufsize: size_t) -> c_int; + pub fn lpar_set_resources(id: c_int, resource: *mut c_void) -> c_int; + pub fn lrand48() -> c_long; + pub fn lsearch( + key: *const c_void, + base: *mut c_void, + nelp: *mut size_t, + width: size_t, + compar: Option c_int>, + ) -> *mut c_void; + pub fn lseek64(fd: c_int, offset: off64_t, whence: c_int) -> off64_t; + pub fn lstat64(path: *const c_char, buf: *mut stat64) -> c_int; + pub fn madvise(addr: caddr_t, len: size_t, advice: c_int) -> c_int; + pub fn makecontext(ucp: *mut crate::ucontext_t, func: extern "C" fn(), argc: c_int, ...); + pub fn mallinfo() -> crate::mallinfo; + pub fn mallopt(param: c_int, value: c_int) -> c_int; + pub fn memmem( + haystack: *const c_void, + haystacklen: size_t, + needle: *const c_void, + needlelen: size_t, + ) -> *mut c_void; + pub fn memset_s(s: *mut c_void, smax: size_t, c: c_int, n: size_t) -> c_int; + pub fn mincore(addr: caddr_t, len: size_t, vec: *mut c_char) -> c_int; + pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; + pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; + pub fn mount(device: *const c_char, path: *const c_char, flags: c_int) -> c_int; + pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; + pub fn mq_close(mqd: crate::mqd_t) -> c_int; + pub fn mq_getattr(mqd: crate::mqd_t, attr: *mut crate::mq_attr) -> c_int; + pub fn mq_notify(mqd: crate::mqd_t, notification: *const crate::sigevent) -> c_int; + pub fn mq_open(name: *const c_char, oflag: c_int, ...) -> crate::mqd_t; + pub fn mq_receive( + mqd: crate::mqd_t, + msg_ptr: *mut c_char, + msg_len: size_t, + msg_prio: *mut c_uint, + ) -> ssize_t; + pub fn mq_send( + mqd: crate::mqd_t, + msg_ptr: *const c_char, + msg_len: size_t, + msg_prio: c_uint, + ) -> c_int; + pub fn mq_setattr( + mqd: crate::mqd_t, + newattr: *const crate::mq_attr, + oldattr: *mut crate::mq_attr, + ) -> c_int; + pub fn mq_timedreceive( + mqd: crate::mqd_t, + msg_ptr: *mut c_char, + msg_len: size_t, + msg_prio: *mut c_uint, + abs_timeout: *const crate::timespec, + ) -> ssize_t; + pub fn mq_timedsend( + mqd: crate::mqd_t, + msg_ptr: *const c_char, + msg_len: size_t, + msg_prio: c_uint, + abs_timeout: *const crate::timespec, + ) -> c_int; + pub fn mq_unlink(name: *const c_char) -> c_int; + pub fn mrand48() -> c_long; + pub fn msgctl(msqid: c_int, cmd: c_int, buf: *mut msqid_ds) -> c_int; + pub fn msgget(key: crate::key_t, msgflg: c_int) -> c_int; + pub fn msgrcv( + msqid: c_int, + msgp: *mut c_void, + msgsz: size_t, + msgtyp: c_long, + msgflg: c_int, + ) -> ssize_t; + pub fn msgsnd(msqid: c_int, msgp: *const c_void, msgsz: size_t, msgflg: c_int) -> c_int; + pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int; + pub fn newlocale(mask: c_int, locale: *const c_char, base: crate::locale_t) -> crate::locale_t; + pub fn nl_langinfo(item: crate::nl_item) -> *mut c_char; + pub fn nl_langinfo_l(item: crate::nl_item, loc: crate::locale_t) -> *mut c_char; + pub fn nrand48(xseed: *mut c_ushort) -> c_long; + pub fn open64(path: *const c_char, oflag: c_int, ...) -> c_int; + pub fn pollset_create(maxfd: c_int) -> pollset_t; + pub fn pollset_ctl(ps: pollset_t, pollctl_array: *mut poll_ctl, array_length: c_int) -> c_int; + pub fn pollset_destroy(ps: pollset_t) -> c_int; + pub fn pollset_poll( + ps: pollset_t, + polldata_array: *mut crate::pollfd, + array_length: c_int, + timeout: c_int, + ) -> c_int; + pub fn pollset_query(ps: pollset_t, pollfd_query: *mut crate::pollfd) -> c_int; + pub fn popen(command: *const c_char, mode: *const c_char) -> *mut crate::FILE; + pub fn posix_fadvise(fd: c_int, offset: off_t, len: off_t, advise: c_int) -> c_int; + pub fn posix_fadvise64(fd: c_int, offset: off64_t, len: off64_t, advise: c_int) -> c_int; + pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int; + pub fn posix_fallocate64(fd: c_int, offset: off64_t, len: off64_t) -> c_int; + pub fn posix_madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; + pub fn posix_spawn( + pid: *mut crate::pid_t, + path: *const c_char, + file_actions: *const crate::posix_spawn_file_actions_t, + attrp: *const crate::posix_spawnattr_t, + argv: *const *mut c_char, + envp: *const *mut c_char, + ) -> c_int; + pub fn posix_spawn_file_actions_addclose( + actions: *mut posix_spawn_file_actions_t, + fd: c_int, + ) -> c_int; + pub fn posix_spawn_file_actions_adddup2( + actions: *mut posix_spawn_file_actions_t, + fd: c_int, + newfd: c_int, + ) -> c_int; + pub fn posix_spawn_file_actions_addopen( + actions: *mut posix_spawn_file_actions_t, + fd: c_int, + path: *const c_char, + oflag: c_int, + mode: mode_t, + ) -> c_int; + pub fn posix_spawn_file_actions_destroy(actions: *mut posix_spawn_file_actions_t) -> c_int; + pub fn posix_spawn_file_actions_init(actions: *mut posix_spawn_file_actions_t) -> c_int; + pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> c_int; + pub fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t, flags: *mut c_short) -> c_int; + pub fn posix_spawnattr_getpgroup( + attr: *const posix_spawnattr_t, + flags: *mut crate::pid_t, + ) -> c_int; + pub fn posix_spawnattr_getschedparam( + attr: *const posix_spawnattr_t, + param: *mut crate::sched_param, + ) -> c_int; + pub fn posix_spawnattr_getschedpolicy( + attr: *const posix_spawnattr_t, + flags: *mut c_int, + ) -> c_int; + pub fn posix_spawnattr_getsigdefault( + attr: *const posix_spawnattr_t, + default: *mut sigset_t, + ) -> c_int; + pub fn posix_spawnattr_getsigmask( + attr: *const posix_spawnattr_t, + default: *mut sigset_t, + ) -> c_int; + pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> c_int; + pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t, flags: c_short) -> c_int; + pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, flags: crate::pid_t) -> c_int; + pub fn posix_spawnattr_setschedparam( + attr: *mut posix_spawnattr_t, + param: *const crate::sched_param, + ) -> c_int; + pub fn posix_spawnattr_setschedpolicy(attr: *mut posix_spawnattr_t, flags: c_int) -> c_int; + pub fn posix_spawnattr_setsigdefault( + attr: *mut posix_spawnattr_t, + default: *const crate::sigset_t, + ) -> c_int; + pub fn posix_spawnattr_setsigmask( + attr: *mut posix_spawnattr_t, + default: *const crate::sigset_t, + ) -> c_int; + pub fn posix_spawnp( + pid: *mut crate::pid_t, + file: *const c_char, + file_actions: *const crate::posix_spawn_file_actions_t, + attrp: *const crate::posix_spawnattr_t, + argv: *const *mut c_char, + envp: *const *mut c_char, + ) -> c_int; + pub fn pread64(fd: c_int, buf: *mut c_void, count: size_t, offset: off64_t) -> ssize_t; + pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: offset_t) -> ssize_t; + pub fn ptrace64( + request: c_int, + id: c_longlong, + addr: c_longlong, + data: c_int, + buff: *mut c_int, + ) -> c_int; + pub fn pututline(u: *const utmp) -> *mut utmp; + pub fn pututxline(ut: *const utmpx) -> *mut utmpx; + pub fn pwrite64(fd: c_int, buf: *const c_void, count: size_t, offset: off64_t) -> ssize_t; + pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: offset_t) + -> ssize_t; + pub fn quotactl(cmd: *mut c_char, special: c_int, id: c_int, data: caddr_t) -> c_int; + pub fn rand() -> c_int; + pub fn readv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; + // AIX header socket.h maps recvfrom() to nrecvfrom() + #[link_name = "nrecvfrom"] + pub fn recvfrom( + socket: c_int, + buf: *mut c_void, + len: size_t, + flags: c_int, + addr: *mut crate::sockaddr, + addrlen: *mut crate::socklen_t, + ) -> ssize_t; + pub fn recvmmsg( + sockfd: c_int, + msgvec: *mut crate::mmsghdr, + vlen: c_uint, + flags: c_int, + timeout: *mut crate::timespec, + ) -> c_int; + // AIX header socket.h maps recvmsg() to nrecvmsg(). + #[link_name = "nrecvmsg"] + pub fn recvmsg(sockfd: c_int, msg: *mut msghdr, flags: c_int) -> ssize_t; + pub fn regcomp(preg: *mut regex_t, pattern: *const c_char, cflags: c_int) -> c_int; + pub fn regerror( + errcode: c_int, + preg: *const crate::regex_t, + errbuf: *mut c_char, + errbuf_size: size_t, + ) -> size_t; + pub fn regexec( + preg: *const regex_t, + input: *const c_char, + nmatch: size_t, + pmatch: *mut regmatch_t, + eflags: c_int, + ) -> c_int; + pub fn regfree(preg: *mut regex_t); + pub fn sbrk(increment: intptr_t) -> *mut c_void; + pub fn sched_getparam(pid: crate::pid_t, param: *mut sched_param) -> c_int; + pub fn sched_getscheduler(pid: crate::pid_t) -> c_int; + pub fn sched_get_priority_max(policy: c_int) -> c_int; + pub fn sched_get_priority_min(policy: c_int) -> c_int; + pub fn sched_rr_get_interval(pid: crate::pid_t, tp: *mut crate::timespec) -> c_int; + pub fn sched_setparam(pid: crate::pid_t, param: *const crate::sched_param) -> c_int; + pub fn sched_setscheduler( + pid: crate::pid_t, + policy: c_int, + param: *const crate::sched_param, + ) -> c_int; + pub fn sctp_opt_info( + sd: c_int, + id: crate::sctp_assoc_t, + opt: c_int, + arg_size: *mut c_void, + size: *mut size_t, + ) -> c_int; + pub fn sctp_peeloff(s: c_int, id: *mut c_uint) -> c_int; + pub fn seed48(xseed: *mut c_ushort) -> *mut c_ushort; + pub fn seekdir(dirp: *mut crate::DIR, loc: c_long); + pub fn sem_close(sem: *mut sem_t) -> c_int; + pub fn sem_destroy(sem: *mut sem_t) -> c_int; + pub fn sem_getvalue(sem: *mut sem_t, sval: *mut c_int) -> c_int; + pub fn sem_init(sem: *mut sem_t, pshared: c_int, value: c_uint) -> c_int; + pub fn sem_open(name: *const c_char, oflag: c_int, ...) -> *mut sem_t; + pub fn sem_timedwait(sem: *mut sem_t, abstime: *const crate::timespec) -> c_int; + pub fn sem_unlink(name: *const c_char) -> c_int; + pub fn semctl(semid: c_int, semnum: c_int, cmd: c_int, ...) -> c_int; + pub fn semget(key: crate::key_t, nsems: c_int, semflag: c_int) -> c_int; + pub fn semop(semid: c_int, sops: *mut sembuf, nsops: size_t) -> c_int; + pub fn send_file(socket: *mut c_int, iobuf: *mut sf_parms, flags: c_uint) -> ssize_t; + pub fn sendmmsg(sockfd: c_int, msgvec: *mut mmsghdr, vlen: c_uint, flags: c_int) -> c_int; + // AIX header socket.h maps sendmsg() to nsendmsg(). + #[link_name = "nsendmsg"] + pub fn sendmsg(sockfd: c_int, msg: *const msghdr, flags: c_int) -> ssize_t; + pub fn setcontext(ucp: *const ucontext_t) -> c_int; + pub fn setdomainname(name: *const c_char, len: c_int) -> c_int; + pub fn setgroups(ngroups: c_int, ptr: *const crate::gid_t) -> c_int; + pub fn setgrent(); + pub fn sethostid(hostid: c_int) -> c_int; + pub fn sethostname(name: *const c_char, len: c_int) -> c_int; + pub fn setmntent(filename: *const c_char, ty: *const c_char) -> *mut crate::FILE; + pub fn setpriority(which: c_int, who: id_t, priority: c_int) -> c_int; + pub fn setpwent(); + pub fn setrlimit(resource: c_int, rlim: *const crate::rlimit) -> c_int; + pub fn setrlimit64(resource: c_int, rlim: *const rlimit64) -> c_int; + pub fn settimeofday(tv: *const crate::timeval, tz: *const crate::timezone) -> c_int; + pub fn setitimer( + which: c_int, + new_value: *const crate::itimerval, + old_value: *mut crate::itimerval, + ) -> c_int; + pub fn setutent(); + pub fn setutxent(); + pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> c_int; + pub fn sigsuspend(mask: *const crate::sigset_t) -> c_int; + pub fn sigtimedwait( + set: *const sigset_t, + info: *mut siginfo_t, + timeout: *const crate::timespec, + ) -> c_int; + pub fn sigwait(set: *const sigset_t, sig: *mut c_int) -> c_int; + pub fn sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> c_int; + pub fn shmat(shmid: c_int, shmaddr: *const c_void, shmflg: c_int) -> *mut c_void; + pub fn shmdt(shmaddr: *const c_void) -> c_int; + pub fn shmctl(shmid: c_int, cmd: c_int, buf: *mut crate::shmid_ds) -> c_int; + pub fn shmget(key: key_t, size: size_t, shmflg: c_int) -> c_int; + pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int; + pub fn shm_unlink(name: *const c_char) -> c_int; + pub fn splice(socket1: c_int, socket2: c_int, flags: c_int) -> c_int; + pub fn srand(seed: c_uint); + pub fn srand48(seed: c_long); + pub fn stat64(path: *const c_char, buf: *mut stat64) -> c_int; + pub fn stat64at(dirfd: c_int, path: *const c_char, buf: *mut stat64, flags: c_int) -> c_int; + pub fn statfs(path: *const c_char, buf: *mut statfs) -> c_int; + pub fn statfs64(path: *const c_char, buf: *mut statfs64) -> c_int; + pub fn statvfs64(path: *const c_char, buf: *mut statvfs64) -> c_int; + pub fn statx(path: *const c_char, buf: *mut stat, length: c_int, command: c_int) -> c_int; + pub fn strcasecmp_l( + string1: *const c_char, + string2: *const c_char, + locale: crate::locale_t, + ) -> c_int; + pub fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int; + pub fn strftime( + arg1: *mut c_char, + arg2: size_t, + arg3: *const c_char, + arg4: *const tm, + ) -> size_t; + pub fn strncasecmp_l( + string1: *const c_char, + string2: *const c_char, + length: size_t, + locale: crate::locale_t, + ) -> c_int; + pub fn strptime(s: *const c_char, format: *const c_char, tm: *mut crate::tm) -> *mut c_char; + pub fn strsep(string: *mut *mut c_char, delim: *const c_char) -> *mut c_char; + pub fn swapcontext(uocp: *mut ucontext_t, ucp: *const ucontext_t) -> c_int; + pub fn swapoff(path: *const c_char) -> c_int; + pub fn swapon(path: *const c_char) -> c_int; + pub fn sync(); + pub fn telldir(dirp: *mut crate::DIR) -> c_long; + pub fn timer_create( + clockid: crate::clockid_t, + sevp: *mut crate::sigevent, + timerid: *mut crate::timer_t, + ) -> c_int; + pub fn timer_delete(timerid: timer_t) -> c_int; + pub fn timer_getoverrun(timerid: timer_t) -> c_int; + pub fn timer_gettime(timerid: timer_t, value: *mut itimerspec) -> c_int; + pub fn timer_settime( + timerid: crate::timer_t, + flags: c_int, + new_value: *const crate::itimerspec, + old_value: *mut crate::itimerspec, + ) -> c_int; + pub fn truncate64(path: *const c_char, length: off64_t) -> c_int; + pub fn uname(buf: *mut crate::utsname) -> c_int; + pub fn updwtmp(file: *const c_char, u: *const utmp); + pub fn uselocale(loc: crate::locale_t) -> crate::locale_t; + pub fn utmpname(file: *const c_char) -> c_int; + pub fn utimensat( + dirfd: c_int, + path: *const c_char, + times: *const crate::timespec, + flag: c_int, + ) -> c_int; + pub fn wait4( + pid: crate::pid_t, + status: *mut c_int, + options: c_int, + rusage: *mut crate::rusage, + ) -> crate::pid_t; + pub fn waitid( + idtype: idtype_t, + id: id_t, + infop: *mut crate::siginfo_t, + options: c_int, + ) -> c_int; + pub fn writev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; + + // Use AIX thread-safe version errno. + pub fn _Errno() -> *mut c_int; +} + +cfg_if! { + if #[cfg(target_arch = "powerpc64")] { + mod powerpc64; + pub use self::powerpc64::*; + } +} diff --git a/http/vendor/libc/src/unix/aix/powerpc64.rs b/http/vendor/libc/src/unix/aix/powerpc64.rs new file mode 100644 index 0000000..0862cbf --- /dev/null +++ b/http/vendor/libc/src/unix/aix/powerpc64.rs @@ -0,0 +1,427 @@ +use crate::off_t; +use crate::prelude::*; + +// Define lock_data_instrumented as an empty enum +extern_ty! { + pub enum lock_data_instrumented {} +} + +s! { + pub struct sigset_t { + pub ss_set: [c_ulong; 4], + } + + pub struct fd_set { + pub fds_bits: [c_long; 1024], + } + + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_sysid: c_uint, + pub l_pid: crate::pid_t, + pub l_vfs: c_int, + pub l_start: off_t, + pub l_len: off_t, + } + + pub struct statvfs { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_favail: crate::fsfilcnt_t, + pub f_fsid: c_ulong, + pub f_basetype: [c_char; 16], + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + pub f_fstr: [c_char; 32], + pub f_filler: [c_ulong; 16], + } + + pub struct pthread_rwlock_t { + __rw_word: [c_long; 10], + } + + pub struct pthread_cond_t { + __cv_word: [c_long; 6], + } + + pub struct pthread_mutex_t { + __mt_word: [c_long; 8], + } + + pub struct pthread_once_t { + __on_word: [c_long; 9], + } + + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_flag: c_ushort, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + pub st_ssize: c_int, + pub st_atim: crate::st_timespec, + pub st_mtim: crate::st_timespec, + pub st_ctim: crate::st_timespec, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + pub st_vfstype: c_int, + pub st_vfs: c_uint, + pub st_type: c_uint, + pub st_gen: c_uint, + st_reserved: Padding<[c_uint; 9]>, + pub st_padto_ll: c_uint, + pub st_size: off_t, + } + + pub struct statfs { + pub f_version: c_int, + pub f_type: c_int, + pub f_bsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsblkcnt_t, + pub f_ffree: crate::fsblkcnt_t, + pub f_fsid: crate::fsid64_t, + pub f_vfstype: c_int, + pub f_fsize: c_ulong, + pub f_vfsnumber: c_int, + pub f_vfsoff: c_int, + pub f_vfslen: c_int, + pub f_vfsvers: c_int, + pub f_fname: [c_char; 32], + pub f_fpack: [c_char; 32], + pub f_name_max: c_int, + } + + pub struct aiocb { + pub aio_lio_opcode: c_int, + pub aio_fildes: c_int, + pub aio_word1: c_int, + pub aio_offset: off_t, + pub aio_buf: *mut c_void, + pub aio_return: ssize_t, + pub aio_errno: c_int, + pub aio_nbytes: size_t, + pub aio_reqprio: c_int, + pub aio_sigevent: crate::sigevent, + pub aio_word2: c_int, + pub aio_fp: c_int, + pub aio_handle: *mut aiocb, + aio_reserved: Padding<[c_uint; 2]>, + pub aio_sigev_tid: c_long, + } + + pub struct __vmxreg_t { + __v: [c_uint; 4], + } + + pub struct __vmx_context_t { + pub __vr: [crate::__vmxreg_t; 32], + pub __pad1: [c_uint; 3], + pub __vscr: c_uint, + pub __vrsave: c_uint, + pub __pad2: [c_uint; 3], + } + + pub struct __vsx_context_t { + pub __vsr_dw1: [c_ulonglong; 32], + } + + pub struct __tm_context_t { + pub vmx: crate::__vmx_context_t, + pub vsx: crate::__vsx_context_t, + pub gpr: [c_ulonglong; 32], + pub lr: c_ulonglong, + pub ctr: c_ulonglong, + pub cr: c_uint, + pub xer: c_uint, + pub amr: c_ulonglong, + pub texasr: c_ulonglong, + pub tfiar: c_ulonglong, + pub tfhar: c_ulonglong, + pub ppr: c_ulonglong, + pub dscr: c_ulonglong, + pub tar: c_ulonglong, + pub fpscr: c_uint, + pub fpscrx: c_uint, + pub fpr: [fpreg_t; 32], + pub tmcontext: c_char, + pub tmstate: c_char, + pub prevowner: c_char, + pub pad: [c_char; 5], + } + + pub struct __context64 { + pub gpr: [c_ulonglong; 32], + pub msr: c_ulonglong, + pub iar: c_ulonglong, + pub lr: c_ulonglong, + pub ctr: c_ulonglong, + pub cr: c_uint, + pub xer: c_uint, + pub fpscr: c_uint, + pub fpscrx: c_uint, + pub except: [c_ulonglong; 1], + pub fpr: [fpreg_t; 32], + pub fpeu: c_char, + pub fpinfo: c_char, + pub fpscr24_31: c_char, + pub pad: [c_char; 1], + pub excp_type: c_int, + } + + pub struct mcontext_t { + pub jmp_context: __context64, + } + + pub struct __extctx_t { + pub __flags: c_uint, + pub __rsvd1: [c_uint; 3], + pub __vmx: crate::__vmx_context_t, + pub __ukeys: [c_uint; 2], + pub __vsx: crate::__vsx_context_t, + pub __tm: crate::__tm_context_t, + __reserved: Padding<[c_char; 1860]>, + pub __extctx_magic: c_int, + } + + pub struct ucontext_t { + pub __sc_onstack: c_int, + pub uc_sigmask: crate::sigset_t, + pub __sc_uerror: c_int, + pub uc_mcontext: crate::mcontext_t, + pub uc_link: *mut ucontext_t, + pub uc_stack: crate::stack_t, + pub __extctx: *mut crate::__extctx_t, + pub __extctx_magic: c_int, + pub __pad: [c_int; 1], + } + + pub struct utmpx { + pub ut_user: [c_char; 256], + pub ut_id: [c_char; 14], + pub ut_line: [c_char; 64], + pub ut_pid: crate::pid_t, + pub ut_type: c_short, + pub ut_tv: crate::timeval, + pub ut_host: [c_char; 256], + pub __dbl_word_pad: c_int, + pub __reservedA: [c_int; 2], + pub __reservedV: [c_int; 6], + } + + pub struct pthread_spinlock_t { + pub __sp_word: [c_long; 3], + } + + pub struct pthread_barrier_t { + pub __br_word: [c_long; 5], + } + + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + pub msg_first: c_uint, + pub msg_last: c_uint, + pub msg_cbytes: c_uint, + pub msg_qnum: c_uint, + pub msg_qbytes: c_ulong, + pub msg_lspid: crate::pid_t, + pub msg_lrpid: crate::pid_t, + pub msg_stime: crate::time_t, + pub msg_rtime: crate::time_t, + pub msg_ctime: crate::time_t, + pub msg_rwait: c_int, + pub msg_wwait: c_int, + pub msg_reqevents: c_ushort, + } + + pub struct siginfo_t { + pub si_signo: c_int, + pub si_errno: c_int, + pub si_code: c_int, + pub si_pid: crate::pid_t, + pub si_uid: crate::uid_t, + pub si_status: c_int, + pub si_addr: *mut c_void, + pub si_band: c_long, + pub si_value: crate::sigval, + pub __si_flags: c_int, + pub __pad: [c_int; 3], + } + + pub struct pollfd_ext { + pub fd: c_int, + pub events: c_short, + pub revents: c_short, + pub data: __pollfd_ext_u, + } +} + +s_no_extra_traits! { + pub union _kernel_simple_lock { + pub _slock: c_long, + pub _slockp: *mut lock_data_instrumented, + } + + pub struct fileops_t { + pub fo_rw: Option< + extern "C" fn( + file: *mut file, + rw: crate::uio_rw, + io: *mut c_void, + ext: c_long, + secattr: *mut c_void, + ) -> c_int, + >, + pub fo_ioctl: Option< + extern "C" fn( + file: *mut file, + a: c_long, + b: crate::caddr_t, + c: c_long, + d: c_long, + ) -> c_int, + >, + pub fo_select: Option< + extern "C" fn(file: *mut file, a: c_int, b: *mut c_ushort, c: extern "C" fn()) -> c_int, + >, + pub fo_close: Option c_int>, + pub fo_fstat: Option c_int>, + } + + pub struct file { + pub f_flag: c_long, + pub f_count: c_int, + pub f_options: c_short, + pub f_type: c_short, + // Should be pointer to 'vnode' + pub f_data: *mut c_void, + pub f_offset: c_longlong, + pub f_dir_off: c_long, + // Should be pointer to 'cred' + pub f_cred: *mut c_void, + pub f_lock: _kernel_simple_lock, + pub f_offset_lock: _kernel_simple_lock, + pub f_vinfo: crate::caddr_t, + pub f_ops: *mut fileops_t, + pub f_parentp: crate::caddr_t, + pub f_fnamep: crate::caddr_t, + pub f_fdata: [c_char; 160], + } + + pub union __ld_info_file { + pub _ldinfo_fd: c_int, + pub _ldinfo_fp: *mut file, + pub _core_offset: c_long, + } + + pub struct ld_info { + pub ldinfo_next: c_uint, + pub ldinfo_flags: c_uint, + pub _file: __ld_info_file, + pub ldinfo_textorg: *mut c_void, + pub ldinfo_textsize: c_ulong, + pub ldinfo_dataorg: *mut c_void, + pub ldinfo_datasize: c_ulong, + pub ldinfo_filename: [c_char; 2], + } + + pub union __pollfd_ext_u { + pub addr: *mut c_void, + pub data32: u32, + pub data: u64, + } + + pub struct fpreg_t { + pub d: c_double, + } +} + +impl siginfo_t { + pub unsafe fn si_addr(&self) -> *mut c_void { + self.si_addr + } + + pub unsafe fn si_value(&self) -> crate::sigval { + self.si_value + } + + pub unsafe fn si_pid(&self) -> crate::pid_t { + self.si_pid + } + + pub unsafe fn si_uid(&self) -> crate::uid_t { + self.si_uid + } + + pub unsafe fn si_status(&self) -> c_int { + self.si_status + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for __pollfd_ext_u { + fn eq(&self, other: &__pollfd_ext_u) -> bool { + unsafe { + self.addr == other.addr + && self.data32 == other.data32 + && self.data == other.data + } + } + } + impl Eq for __pollfd_ext_u {} + impl hash::Hash for __pollfd_ext_u { + fn hash(&self, state: &mut H) { + unsafe { + self.addr.hash(state); + self.data.hash(state); + self.data32.hash(state); + } + } + } + + impl PartialEq for fpreg_t { + fn eq(&self, other: &fpreg_t) -> bool { + self.d == other.d + } + } + impl Eq for fpreg_t {} + impl hash::Hash for fpreg_t { + fn hash(&self, state: &mut H) { + let d: u64 = self.d.to_bits(); + d.hash(state); + } + } + } +} + +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + __mt_word: [0, 2, 0, 0, 0, 0, 0, 0], +}; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + __cv_word: [0, 0, 0, 0, 2, 0], +}; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + __rw_word: [2, 0, 0, 0, 0, 0, 0, 0, 0, 0], +}; + +pub const PTHREAD_ONCE_INIT: pthread_once_t = pthread_once_t { + __on_word: [0, 0, 0, 0, 0, 2, 0, 0, 0], +}; + +pub const RLIM_INFINITY: c_ulong = 0x7fffffffffffffff; + +extern "C" { + pub fn getsystemcfg(label: c_int) -> c_ulong; +} diff --git a/http/vendor/libc/src/unix/bsd/apple/b32/mod.rs b/http/vendor/libc/src/unix/bsd/apple/b32/mod.rs new file mode 100644 index 0000000..ab0c94e --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/apple/b32/mod.rs @@ -0,0 +1,73 @@ +//! 32-bit specific Apple (ios/darwin) definitions + +use crate::prelude::*; + +pub type boolean_t = c_int; + +s! { + pub struct if_data { + pub ifi_type: c_uchar, + pub ifi_typelen: c_uchar, + pub ifi_physical: c_uchar, + pub ifi_addrlen: c_uchar, + pub ifi_hdrlen: c_uchar, + pub ifi_recvquota: c_uchar, + pub ifi_xmitquota: c_uchar, + pub ifi_unused1: c_uchar, + pub ifi_mtu: u32, + pub ifi_metric: u32, + pub ifi_baudrate: u32, + pub ifi_ipackets: u32, + pub ifi_ierrors: u32, + pub ifi_opackets: u32, + pub ifi_oerrors: u32, + pub ifi_collisions: u32, + pub ifi_ibytes: u32, + pub ifi_obytes: u32, + pub ifi_imcasts: u32, + pub ifi_omcasts: u32, + pub ifi_iqdrops: u32, + pub ifi_noproto: u32, + pub ifi_recvtiming: u32, + pub ifi_xmittiming: u32, + pub ifi_lastchange: crate::timeval, + pub ifi_unused2: u32, + pub ifi_hwassist: u32, + pub ifi_reserved1: u32, + pub ifi_reserved2: u32, + } + + pub struct bpf_hdr { + pub bh_tstamp: crate::timeval, + pub bh_caplen: u32, + pub bh_datalen: u32, + pub bh_hdrlen: c_ushort, + } + + pub struct malloc_zone_t { + __private: [crate::uintptr_t; 18], // FIXME(macos): keeping private for now + } +} + +s_no_extra_traits! { + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 2], + } +} + +#[doc(hidden)] +#[deprecated(since = "0.2.55")] +pub const NET_RT_MAXID: c_int = 10; + +pub const TIOCTIMESTAMP: c_ulong = 0x40087459; +pub const TIOCDCDTIMESTAMP: c_ulong = 0x40087458; + +pub const BIOCSETF: c_ulong = 0x80084267; +pub const BIOCSRTIMEOUT: c_ulong = 0x8008426d; +pub const BIOCGRTIMEOUT: c_ulong = 0x4008426e; +pub const BIOCSETFNR: c_ulong = 0x8008427e; + +extern "C" { + pub fn exchangedata(path1: *const c_char, path2: *const c_char, options: c_ulong) -> c_int; +} diff --git a/http/vendor/libc/src/unix/bsd/apple/b64/aarch64/mod.rs b/http/vendor/libc/src/unix/bsd/apple/b64/aarch64/mod.rs new file mode 100644 index 0000000..b5cbe8f --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/apple/b64/aarch64/mod.rs @@ -0,0 +1,15 @@ +use crate::prelude::*; + +pub type boolean_t = c_int; + +s! { + pub struct malloc_zone_t { + __private: [crate::uintptr_t; 18], // FIXME(macos): needs arm64 auth pointers support + } +} + +s_no_extra_traits! { + pub struct max_align_t { + priv_: f64, + } +} diff --git a/http/vendor/libc/src/unix/bsd/apple/b64/mod.rs b/http/vendor/libc/src/unix/bsd/apple/b64/mod.rs new file mode 100644 index 0000000..5ccf65a --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/apple/b64/mod.rs @@ -0,0 +1,78 @@ +//! 64-bit specific Apple (ios/darwin) definitions + +use crate::prelude::*; + +s! { + #[derive(Default)] + pub struct timeval32 { + pub tv_sec: i32, + pub tv_usec: i32, + } + + pub struct if_data { + pub ifi_type: c_uchar, + pub ifi_typelen: c_uchar, + pub ifi_physical: c_uchar, + pub ifi_addrlen: c_uchar, + pub ifi_hdrlen: c_uchar, + pub ifi_recvquota: c_uchar, + pub ifi_xmitquota: c_uchar, + pub ifi_unused1: c_uchar, + pub ifi_mtu: u32, + pub ifi_metric: u32, + pub ifi_baudrate: u32, + pub ifi_ipackets: u32, + pub ifi_ierrors: u32, + pub ifi_opackets: u32, + pub ifi_oerrors: u32, + pub ifi_collisions: u32, + pub ifi_ibytes: u32, + pub ifi_obytes: u32, + pub ifi_imcasts: u32, + pub ifi_omcasts: u32, + pub ifi_iqdrops: u32, + pub ifi_noproto: u32, + pub ifi_recvtiming: u32, + pub ifi_xmittiming: u32, + pub ifi_lastchange: timeval32, + pub ifi_unused2: u32, + pub ifi_hwassist: u32, + pub ifi_reserved1: u32, + pub ifi_reserved2: u32, + } + + pub struct bpf_hdr { + pub bh_tstamp: crate::timeval32, + pub bh_caplen: u32, + pub bh_datalen: u32, + pub bh_hdrlen: c_ushort, + } +} + +#[doc(hidden)] +#[deprecated(since = "0.2.55")] +pub const NET_RT_MAXID: c_int = 11; + +pub const TIOCTIMESTAMP: c_ulong = 0x40107459; +pub const TIOCDCDTIMESTAMP: c_ulong = 0x40107458; + +pub const BIOCSETF: c_ulong = 0x80104267; +pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; +pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e; +pub const BIOCSETFNR: c_ulong = 0x8010427e; + +extern "C" { + pub fn exchangedata(path1: *const c_char, path2: *const c_char, options: c_uint) -> c_int; +} + +cfg_if! { + if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } else if #[cfg(target_arch = "aarch64")] { + mod aarch64; + pub use self::aarch64::*; + } else { + // Unknown target_arch + } +} diff --git a/http/vendor/libc/src/unix/bsd/apple/b64/x86_64/mod.rs b/http/vendor/libc/src/unix/bsd/apple/b64/x86_64/mod.rs new file mode 100644 index 0000000..dac8c9e --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/apple/b64/x86_64/mod.rs @@ -0,0 +1,77 @@ +use crate::prelude::*; + +pub type boolean_t = c_uint; + +s! { + pub struct malloc_introspection_t { + _private: [crate::uintptr_t; 16], // FIXME(macos): keeping private for now + } + + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct malloc_zone_t { + _reserved1: Padding<*mut c_void>, + _reserved2: Padding<*mut c_void>, + pub size: + Option size_t>, + pub malloc: + Option *mut c_void>, + pub calloc: Option< + unsafe extern "C" fn( + zone: *mut malloc_zone_t, + num_items: size_t, + size: size_t, + ) -> *mut c_void, + >, + pub valloc: + Option *mut c_void>, + pub free: Option, + pub realloc: Option< + unsafe extern "C" fn( + zone: *mut malloc_zone_t, + ptr: *mut c_void, + size: size_t, + ) -> *mut c_void, + >, + pub destroy: Option, + pub zone_name: *const c_char, + pub batch_malloc: Option< + unsafe extern "C" fn( + zone: *mut malloc_zone_t, + size: size_t, + results: *mut *mut c_void, + num_requested: c_uint, + ) -> c_uint, + >, + pub batch_free: Option< + unsafe extern "C" fn( + zone: *mut malloc_zone_t, + to_be_freed: *mut *mut c_void, + num_to_be_freed: c_uint, + ), + >, + pub introspect: *mut malloc_introspection_t, + pub version: c_uint, + pub memalign: Option< + unsafe extern "C" fn( + zone: *mut malloc_zone_t, + alignment: size_t, + size: size_t, + ) -> *mut c_void, + >, + pub free_definite_size: + Option, + pub pressure_relief: + Option size_t>, + pub claimed_address: Option< + unsafe extern "C" fn(zone: *mut malloc_zone_t, ptr: *mut c_void) -> crate::boolean_t, + >, + } +} + +s_no_extra_traits! { + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 2], + } +} diff --git a/http/vendor/libc/src/unix/bsd/apple/mod.rs b/http/vendor/libc/src/unix/bsd/apple/mod.rs new file mode 100644 index 0000000..ff0e24a --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/apple/mod.rs @@ -0,0 +1,5190 @@ +//! Apple (ios/darwin)-specific definitions +//! +//! This covers *-apple-* triples currently + +use crate::prelude::*; +use crate::{ + cmsghdr, + off_t, +}; + +pub type wchar_t = i32; +pub type clock_t = c_ulong; +pub type time_t = c_long; +pub type suseconds_t = i32; +pub type dev_t = i32; +pub type ino_t = u64; +pub type mode_t = u16; +pub type nlink_t = u16; +pub type blksize_t = i32; +pub type rlim_t = u64; +pub type sigset_t = u32; +pub type clockid_t = c_uint; +pub type fsblkcnt_t = c_uint; +pub type fsfilcnt_t = c_uint; +pub type speed_t = c_ulong; +pub type tcflag_t = c_ulong; +pub type nl_item = c_int; +pub type id_t = c_uint; +pub type sem_t = c_int; +pub type idtype_t = c_uint; +pub type integer_t = c_int; +pub type cpu_type_t = integer_t; +pub type cpu_subtype_t = integer_t; +pub type natural_t = u32; +pub type mach_msg_type_number_t = natural_t; +pub type kern_return_t = c_int; +pub type uuid_t = [u8; 16]; +pub type task_info_t = *mut integer_t; +pub type host_info_t = *mut integer_t; +pub type task_flavor_t = natural_t; +pub type rusage_info_t = *mut c_void; +pub type vm_offset_t = crate::uintptr_t; +pub type vm_size_t = crate::uintptr_t; +pub type vm_address_t = vm_offset_t; +pub type quad_t = i64; +pub type u_quad_t = u64; + +pub type posix_spawnattr_t = *mut c_void; +pub type posix_spawn_file_actions_t = *mut c_void; +pub type key_t = c_int; +pub type shmatt_t = c_ushort; + +pub type sae_associd_t = u32; +pub type sae_connid_t = u32; + +pub type mach_port_t = c_uint; +pub type host_t = c_uint; +pub type host_flavor_t = integer_t; +pub type host_info64_t = *mut integer_t; +pub type processor_flavor_t = c_int; +pub type thread_flavor_t = natural_t; +pub type thread_inspect_t = crate::mach_port_t; +pub type thread_act_t = crate::mach_port_t; +pub type thread_act_array_t = *mut crate::thread_act_t; +pub type policy_t = c_int; +pub type mach_error_t = crate::kern_return_t; +pub type mach_vm_address_t = u64; +pub type mach_vm_offset_t = u64; +pub type mach_vm_size_t = u64; +pub type vm_map_t = crate::mach_port_t; +pub type mem_entry_name_port_t = crate::mach_port_t; +pub type memory_object_t = crate::mach_port_t; +pub type memory_object_offset_t = c_ulonglong; +pub type vm_inherit_t = c_uint; +pub type vm_prot_t = c_int; + +pub type ledger_t = crate::mach_port_t; +pub type ledger_array_t = *mut crate::ledger_t; + +pub type iconv_t = *mut c_void; + +// mach/host_info.h +pub type host_cpu_load_info_t = *mut host_cpu_load_info; +pub type host_cpu_load_info_data_t = host_cpu_load_info; + +// mach/processor_info.h +pub type processor_cpu_load_info_t = *mut processor_cpu_load_info; +pub type processor_cpu_load_info_data_t = processor_cpu_load_info; +pub type processor_basic_info_t = *mut processor_basic_info; +pub type processor_basic_info_data_t = processor_basic_info; +pub type processor_set_basic_info_data_t = processor_set_basic_info; +pub type processor_set_basic_info_t = *mut processor_set_basic_info; +pub type processor_set_load_info_data_t = processor_set_load_info; +pub type processor_set_load_info_t = *mut processor_set_load_info; +pub type processor_info_t = *mut integer_t; +pub type processor_info_array_t = *mut integer_t; + +pub type mach_task_basic_info_data_t = mach_task_basic_info; +pub type mach_task_basic_info_t = *mut mach_task_basic_info; +pub type task_thread_times_info_data_t = task_thread_times_info; +pub type task_thread_times_info_t = *mut task_thread_times_info; + +pub type thread_info_t = *mut integer_t; +pub type thread_basic_info_t = *mut thread_basic_info; +pub type thread_basic_info_data_t = thread_basic_info; +pub type thread_identifier_info_t = *mut thread_identifier_info; +pub type thread_identifier_info_data_t = thread_identifier_info; +pub type thread_extended_info_t = *mut thread_extended_info; +pub type thread_extended_info_data_t = thread_extended_info; + +pub type thread_t = crate::mach_port_t; +pub type thread_policy_flavor_t = natural_t; +pub type thread_policy_t = *mut integer_t; +pub type thread_latency_qos_t = integer_t; +pub type thread_throughput_qos_t = integer_t; +pub type thread_standard_policy_data_t = thread_standard_policy; +pub type thread_standard_policy_t = *mut thread_standard_policy; +pub type thread_extended_policy_data_t = thread_extended_policy; +pub type thread_extended_policy_t = *mut thread_extended_policy; +pub type thread_time_constraint_policy_data_t = thread_time_constraint_policy; +pub type thread_time_constraint_policy_t = *mut thread_time_constraint_policy; +pub type thread_precedence_policy_data_t = thread_precedence_policy; +pub type thread_precedence_policy_t = *mut thread_precedence_policy; +pub type thread_affinity_policy_data_t = thread_affinity_policy; +pub type thread_affinity_policy_t = *mut thread_affinity_policy; +pub type thread_background_policy_data_t = thread_background_policy; +pub type thread_background_policy_t = *mut thread_background_policy; +pub type thread_latency_qos_policy_data_t = thread_latency_qos_policy; +pub type thread_latency_qos_policy_t = *mut thread_latency_qos_policy; +pub type thread_throughput_qos_policy_data_t = thread_throughput_qos_policy; +pub type thread_throughput_qos_policy_t = *mut thread_throughput_qos_policy; + +pub type pthread_jit_write_callback_t = Option c_int>; + +pub type os_clockid_t = u32; + +pub type os_sync_wait_on_address_flags_t = u32; +pub type os_sync_wake_by_address_flags_t = u32; + +pub type os_unfair_lock = os_unfair_lock_s; +pub type os_unfair_lock_t = *mut os_unfair_lock; + +pub type os_log_t = *mut c_void; +pub type os_log_type_t = u8; +pub type os_signpost_id_t = u64; +pub type os_signpost_type_t = u8; + +pub type vm_statistics_t = *mut vm_statistics; +pub type vm_statistics_data_t = vm_statistics; +pub type vm_statistics64_t = *mut vm_statistics64; +pub type vm_statistics64_data_t = vm_statistics64; + +pub type task_t = crate::mach_port_t; +pub type task_inspect_t = crate::mach_port_t; + +pub type sysdir_search_path_enumeration_state = c_uint; + +pub type CCStatus = i32; +pub type CCCryptorStatus = i32; +pub type CCRNGStatus = crate::CCCryptorStatus; + +pub type copyfile_state_t = *mut c_void; +pub type copyfile_flags_t = u32; +pub type copyfile_callback_t = Option< + extern "C" fn( + c_int, + c_int, + copyfile_state_t, + *const c_char, + *const c_char, + *mut c_void, + ) -> c_int, +>; + +pub type attrgroup_t = u32; +pub type vol_capabilities_set_t = [u32; 4]; + +deprecated_mach! { + pub type mach_timebase_info_data_t = mach_timebase_info; +} + +extern_ty! { + pub enum timezone {} +} + +#[derive(Debug)] +#[repr(u32)] +pub enum sysdir_search_path_directory_t { + SYSDIR_DIRECTORY_APPLICATION = 1, + SYSDIR_DIRECTORY_DEMO_APPLICATION = 2, + SYSDIR_DIRECTORY_DEVELOPER_APPLICATION = 3, + SYSDIR_DIRECTORY_ADMIN_APPLICATION = 4, + SYSDIR_DIRECTORY_LIBRARY = 5, + SYSDIR_DIRECTORY_DEVELOPER = 6, + SYSDIR_DIRECTORY_USER = 7, + SYSDIR_DIRECTORY_DOCUMENTATION = 8, + SYSDIR_DIRECTORY_DOCUMENT = 9, + SYSDIR_DIRECTORY_CORESERVICE = 10, + SYSDIR_DIRECTORY_AUTOSAVED_INFORMATION = 11, + SYSDIR_DIRECTORY_DESKTOP = 12, + SYSDIR_DIRECTORY_CACHES = 13, + SYSDIR_DIRECTORY_APPLICATION_SUPPORT = 14, + SYSDIR_DIRECTORY_DOWNLOADS = 15, + SYSDIR_DIRECTORY_INPUT_METHODS = 16, + SYSDIR_DIRECTORY_MOVIES = 17, + SYSDIR_DIRECTORY_MUSIC = 18, + SYSDIR_DIRECTORY_PICTURES = 19, + SYSDIR_DIRECTORY_PRINTER_DESCRIPTION = 20, + SYSDIR_DIRECTORY_SHARED_PUBLIC = 21, + SYSDIR_DIRECTORY_PREFERENCE_PANES = 22, + SYSDIR_DIRECTORY_ALL_APPLICATIONS = 100, + SYSDIR_DIRECTORY_ALL_LIBRARIES = 101, +} +impl Copy for sysdir_search_path_directory_t {} +impl Clone for sysdir_search_path_directory_t { + fn clone(&self) -> sysdir_search_path_directory_t { + *self + } +} + +#[derive(Debug)] +#[repr(u32)] +pub enum sysdir_search_path_domain_mask_t { + SYSDIR_DOMAIN_MASK_USER = (1 << 0), + SYSDIR_DOMAIN_MASK_LOCAL = (1 << 1), + SYSDIR_DOMAIN_MASK_NETWORK = (1 << 2), + SYSDIR_DOMAIN_MASK_SYSTEM = (1 << 3), + SYSDIR_DOMAIN_MASK_ALL = 0x0ffff, +} +impl Copy for sysdir_search_path_domain_mask_t {} +impl Clone for sysdir_search_path_domain_mask_t { + fn clone(&self) -> sysdir_search_path_domain_mask_t { + *self + } +} + +s! { + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct ip_mreqn { + pub imr_multiaddr: in_addr, + pub imr_address: in_addr, + pub imr_ifindex: c_int, + } + + pub struct ip_mreq_source { + pub imr_multiaddr: in_addr, + pub imr_sourceaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct aiocb { + pub aio_fildes: c_int, + pub aio_offset: off_t, + pub aio_buf: *mut c_void, + pub aio_nbytes: size_t, + pub aio_reqprio: c_int, + pub aio_sigevent: sigevent, + pub aio_lio_opcode: c_int, + } + + pub struct glob_t { + pub gl_pathc: size_t, + __unused1: Padding, + pub gl_offs: size_t, + __unused2: Padding, + pub gl_pathv: *mut *mut c_char, + + __unused3: Padding<*mut c_void>, + + __unused4: Padding<*mut c_void>, + __unused5: Padding<*mut c_void>, + __unused6: Padding<*mut c_void>, + __unused7: Padding<*mut c_void>, + __unused8: Padding<*mut c_void>, + } + + pub struct tm { + pub tm_sec: c_int, + pub tm_min: c_int, + pub tm_hour: c_int, + pub tm_mday: c_int, + pub tm_mon: c_int, + pub tm_year: c_int, + pub tm_wday: c_int, + pub tm_yday: c_int, + pub tm_isdst: c_int, + pub tm_gmtoff: c_long, + pub tm_zone: *mut c_char, + } + + pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: crate::socklen_t, + pub ai_canonname: *mut c_char, + pub ai_addr: *mut crate::sockaddr, + pub ai_next: *mut addrinfo, + } + + #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] + pub struct mach_timebase_info { + pub numer: u32, + pub denom: u32, + } + + pub struct stat { + pub st_dev: dev_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_ino: ino_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: dev_t, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + pub st_birthtime: time_t, + pub st_birthtime_nsec: c_long, + pub st_size: off_t, + pub st_blocks: crate::blkcnt_t, + pub st_blksize: blksize_t, + pub st_flags: u32, + pub st_gen: u32, + pub st_lspare: i32, + pub st_qspare: [i64; 2], + } + + pub struct siginfo_t { + pub si_signo: c_int, + pub si_errno: c_int, + pub si_code: c_int, + pub si_pid: crate::pid_t, + pub si_uid: crate::uid_t, + pub si_status: c_int, + pub si_addr: *mut c_void, + //Requires it to be union for tests + //pub si_value: crate::sigval, + _pad: Padding<[usize; 9]>, + } + + pub struct sigaction { + // FIXME(union): this field is actually a union + pub sa_sigaction: crate::sighandler_t, + pub sa_mask: sigset_t, + pub sa_flags: c_int, + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_size: size_t, + pub ss_flags: c_int, + } + + pub struct fstore_t { + pub fst_flags: c_uint, + pub fst_posmode: c_int, + pub fst_offset: off_t, + pub fst_length: off_t, + pub fst_bytesalloc: off_t, + } + + pub struct fpunchhole_t { + pub fp_flags: c_uint, /* unused */ + pub reserved: c_uint, /* (to maintain 8-byte alignment) */ + pub fp_offset: off_t, /* IN: start of the region */ + pub fp_length: off_t, /* IN: size of the region */ + } + + pub struct ftrimactivefile_t { + pub fta_offset: off_t, + pub fta_length: off_t, + } + + pub struct fspecread_t { + pub fsr_flags: c_uint, + pub reserved: c_uint, + pub fsr_offset: off_t, + pub fsr_length: off_t, + } + + pub struct radvisory { + pub ra_offset: off_t, + pub ra_count: c_int, + } + + pub struct statvfs { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_favail: crate::fsfilcnt_t, + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + } + + pub struct Dl_info { + pub dli_fname: *const c_char, + pub dli_fbase: *mut c_void, + pub dli_sname: *const c_char, + pub dli_saddr: *mut c_void, + } + + pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: crate::sa_family_t, + pub sin_port: crate::in_port_t, + pub sin_addr: crate::in_addr, + pub sin_zero: [c_char; 8], + } + + pub struct kevent64_s { + pub ident: u64, + pub filter: i16, + pub flags: u16, + pub fflags: u32, + pub data: i64, + pub udata: u64, + pub ext: [u64; 2], + } + + pub struct dqblk { + pub dqb_bhardlimit: u64, + pub dqb_bsoftlimit: u64, + pub dqb_curbytes: u64, + pub dqb_ihardlimit: u32, + pub dqb_isoftlimit: u32, + pub dqb_curinodes: u32, + pub dqb_btime: u32, + pub dqb_itime: u32, + pub dqb_id: u32, + pub dqb_spare: [u32; 4], + } + + pub struct if_msghdr { + pub ifm_msglen: c_ushort, + pub ifm_version: c_uchar, + pub ifm_type: c_uchar, + pub ifm_addrs: c_int, + pub ifm_flags: c_int, + pub ifm_index: c_ushort, + pub ifm_data: if_data, + } + + pub struct ifa_msghdr { + pub ifam_msglen: c_ushort, + pub ifam_version: c_uchar, + pub ifam_type: c_uchar, + pub ifam_addrs: c_int, + pub ifam_flags: c_int, + pub ifam_index: c_ushort, + pub ifam_metric: c_int, + } + + pub struct ifma_msghdr { + pub ifmam_msglen: c_ushort, + pub ifmam_version: c_uchar, + pub ifmam_type: c_uchar, + pub ifmam_addrs: c_int, + pub ifmam_flags: c_int, + pub ifmam_index: c_ushort, + } + + pub struct ifma_msghdr2 { + pub ifmam_msglen: c_ushort, + pub ifmam_version: c_uchar, + pub ifmam_type: c_uchar, + pub ifmam_addrs: c_int, + pub ifmam_flags: c_int, + pub ifmam_index: c_ushort, + pub ifmam_refcount: i32, + } + + pub struct rt_metrics { + pub rmx_locks: u32, + pub rmx_mtu: u32, + pub rmx_hopcount: u32, + pub rmx_expire: i32, + pub rmx_recvpipe: u32, + pub rmx_sendpipe: u32, + pub rmx_ssthresh: u32, + pub rmx_rtt: u32, + pub rmx_rttvar: u32, + pub rmx_pksent: u32, + /// This field does not exist anymore, the u32 is now part of a resized + /// `rmx_filler` array. + pub rmx_state: u32, + pub rmx_filler: [u32; 3], + } + + pub struct rt_msghdr { + pub rtm_msglen: c_ushort, + pub rtm_version: c_uchar, + pub rtm_type: c_uchar, + pub rtm_index: c_ushort, + pub rtm_flags: c_int, + pub rtm_addrs: c_int, + pub rtm_pid: crate::pid_t, + pub rtm_seq: c_int, + pub rtm_errno: c_int, + pub rtm_use: c_int, + pub rtm_inits: u32, + pub rtm_rmx: rt_metrics, + } + + pub struct rt_msghdr2 { + pub rtm_msglen: c_ushort, + pub rtm_version: c_uchar, + pub rtm_type: c_uchar, + pub rtm_index: c_ushort, + pub rtm_flags: c_int, + pub rtm_addrs: c_int, + pub rtm_refcnt: i32, + pub rtm_parentflags: c_int, + pub rtm_reserved: c_int, + pub rtm_use: c_int, + pub rtm_inits: u32, + pub rtm_rmx: rt_metrics, + } + + pub struct termios { + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_cc: [crate::cc_t; crate::NCCS], + pub c_ispeed: crate::speed_t, + pub c_ospeed: crate::speed_t, + } + + pub struct flock { + pub l_start: off_t, + pub l_len: off_t, + pub l_pid: crate::pid_t, + pub l_type: c_short, + pub l_whence: c_short, + } + + pub struct sf_hdtr { + pub headers: *mut crate::iovec, + pub hdr_cnt: c_int, + pub trailers: *mut crate::iovec, + pub trl_cnt: c_int, + } + + pub struct lconv { + pub decimal_point: *mut c_char, + pub thousands_sep: *mut c_char, + pub grouping: *mut c_char, + pub int_curr_symbol: *mut c_char, + pub currency_symbol: *mut c_char, + pub mon_decimal_point: *mut c_char, + pub mon_thousands_sep: *mut c_char, + pub mon_grouping: *mut c_char, + pub positive_sign: *mut c_char, + pub negative_sign: *mut c_char, + pub int_frac_digits: c_char, + pub frac_digits: c_char, + pub p_cs_precedes: c_char, + pub p_sep_by_space: c_char, + pub n_cs_precedes: c_char, + pub n_sep_by_space: c_char, + pub p_sign_posn: c_char, + pub n_sign_posn: c_char, + pub int_p_cs_precedes: c_char, + pub int_n_cs_precedes: c_char, + pub int_p_sep_by_space: c_char, + pub int_n_sep_by_space: c_char, + pub int_p_sign_posn: c_char, + pub int_n_sign_posn: c_char, + } + + pub struct proc_taskinfo { + pub pti_virtual_size: u64, + pub pti_resident_size: u64, + pub pti_total_user: u64, + pub pti_total_system: u64, + pub pti_threads_user: u64, + pub pti_threads_system: u64, + pub pti_policy: i32, + pub pti_faults: i32, + pub pti_pageins: i32, + pub pti_cow_faults: i32, + pub pti_messages_sent: i32, + pub pti_messages_received: i32, + pub pti_syscalls_mach: i32, + pub pti_syscalls_unix: i32, + pub pti_csw: i32, + pub pti_threadnum: i32, + pub pti_numrunning: i32, + pub pti_priority: i32, + } + + pub struct proc_bsdinfo { + pub pbi_flags: u32, + pub pbi_status: u32, + pub pbi_xstatus: u32, + pub pbi_pid: u32, + pub pbi_ppid: u32, + pub pbi_uid: crate::uid_t, + pub pbi_gid: crate::gid_t, + pub pbi_ruid: crate::uid_t, + pub pbi_rgid: crate::gid_t, + pub pbi_svuid: crate::uid_t, + pub pbi_svgid: crate::gid_t, + pub rfu_1: u32, + pub pbi_comm: [c_char; MAXCOMLEN], + pub pbi_name: [c_char; 32], // MAXCOMLEN * 2, but macro isn't happy... + pub pbi_nfiles: u32, + pub pbi_pgid: u32, + pub pbi_pjobc: u32, + pub e_tdev: u32, + pub e_tpgid: u32, + pub pbi_nice: i32, + pub pbi_start_tvsec: u64, + pub pbi_start_tvusec: u64, + } + + pub struct proc_taskallinfo { + pub pbsd: proc_bsdinfo, + pub ptinfo: proc_taskinfo, + } + + pub struct xsw_usage { + pub xsu_total: u64, + pub xsu_avail: u64, + pub xsu_used: u64, + pub xsu_pagesize: u32, + pub xsu_encrypted: crate::boolean_t, + } + + pub struct xucred { + pub cr_version: c_uint, + pub cr_uid: crate::uid_t, + pub cr_ngroups: c_short, + pub cr_groups: [crate::gid_t; 16], + } + + #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] + pub struct mach_header { + pub magic: u32, + pub cputype: cpu_type_t, + pub cpusubtype: cpu_subtype_t, + pub filetype: u32, + pub ncmds: u32, + pub sizeofcmds: u32, + pub flags: u32, + } + + #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] + pub struct mach_header_64 { + pub magic: u32, + pub cputype: cpu_type_t, + pub cpusubtype: cpu_subtype_t, + pub filetype: u32, + pub ncmds: u32, + pub sizeofcmds: u32, + pub flags: u32, + pub reserved: u32, + } + + pub struct segment_command { + pub cmd: u32, + pub cmdsize: u32, + pub segname: [c_char; 16], + pub vmaddr: u32, + pub vmsize: u32, + pub fileoff: u32, + pub filesize: u32, + pub maxprot: vm_prot_t, + pub initprot: vm_prot_t, + pub nsects: u32, + pub flags: u32, + } + + pub struct segment_command_64 { + pub cmd: u32, + pub cmdsize: u32, + pub segname: [c_char; 16], + pub vmaddr: u64, + pub vmsize: u64, + pub fileoff: u64, + pub filesize: u64, + pub maxprot: vm_prot_t, + pub initprot: vm_prot_t, + pub nsects: u32, + pub flags: u32, + } + + pub struct load_command { + pub cmd: u32, + pub cmdsize: u32, + } + + pub struct sockaddr_dl { + pub sdl_len: c_uchar, + pub sdl_family: c_uchar, + pub sdl_index: c_ushort, + pub sdl_type: c_uchar, + pub sdl_nlen: c_uchar, + pub sdl_alen: c_uchar, + pub sdl_slen: c_uchar, + pub sdl_data: [c_char; 12], + } + + pub struct sockaddr_inarp { + pub sin_len: c_uchar, + pub sin_family: c_uchar, + pub sin_port: c_ushort, + pub sin_addr: crate::in_addr, + pub sin_srcaddr: crate::in_addr, + pub sin_tos: c_ushort, + pub sin_other: c_ushort, + } + + pub struct sockaddr_ctl { + pub sc_len: c_uchar, + pub sc_family: c_uchar, + pub ss_sysaddr: u16, + pub sc_id: u32, + pub sc_unit: u32, + pub sc_reserved: [u32; 5], + } + + pub struct in_pktinfo { + pub ipi_ifindex: c_uint, + pub ipi_spec_dst: crate::in_addr, + pub ipi_addr: crate::in_addr, + } + + pub struct in6_pktinfo { + pub ipi6_addr: crate::in6_addr, + pub ipi6_ifindex: c_uint, + } + + // sys/ipc.h: + + pub struct ipc_perm { + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: mode_t, + pub _seq: c_ushort, + pub _key: crate::key_t, + } + + // sys/sem.h + + pub struct sembuf { + pub sem_num: c_ushort, + pub sem_op: c_short, + pub sem_flg: c_short, + } + + // sys/shm.h + + pub struct arphdr { + pub ar_hrd: u16, + pub ar_pro: u16, + pub ar_hln: u8, + pub ar_pln: u8, + pub ar_op: u16, + } + + pub struct in_addr { + pub s_addr: crate::in_addr_t, + } + + // net/ndrv.h + pub struct sockaddr_ndrv { + pub snd_len: c_uchar, + pub snd_family: c_uchar, + pub snd_name: [c_uchar; crate::IFNAMSIZ], + } + + // sys/socket.h + + pub struct sa_endpoints_t { + pub sae_srcif: c_uint, // optional source interface + pub sae_srcaddr: *const crate::sockaddr, // optional source address + pub sae_srcaddrlen: crate::socklen_t, // size of source address + pub sae_dstaddr: *const crate::sockaddr, // destination address + pub sae_dstaddrlen: crate::socklen_t, // size of destination address + } + + pub struct timex { + pub modes: c_uint, + pub offset: c_long, + pub freq: c_long, + pub maxerror: c_long, + pub esterror: c_long, + pub status: c_int, + pub constant: c_long, + pub precision: c_long, + pub tolerance: c_long, + pub ppsfreq: c_long, + pub jitter: c_long, + pub shift: c_int, + pub stabil: c_long, + pub jitcnt: c_long, + pub calcnt: c_long, + pub errcnt: c_long, + pub stbcnt: c_long, + } + + pub struct ntptimeval { + pub time: crate::timespec, + pub maxerror: c_long, + pub esterror: c_long, + pub tai: c_long, + pub time_state: c_int, + } + + pub struct thread_standard_policy { + pub no_data: natural_t, + } + + pub struct thread_extended_policy { + pub timeshare: boolean_t, + } + + pub struct thread_time_constraint_policy { + pub period: u32, + pub computation: u32, + pub constraint: u32, + pub preemptible: boolean_t, + } + + pub struct thread_precedence_policy { + pub importance: integer_t, + } + + pub struct thread_affinity_policy { + pub affinity_tag: integer_t, + } + + pub struct thread_background_policy { + pub priority: integer_t, + } + + pub struct thread_latency_qos_policy { + pub thread_latency_qos_tier: thread_latency_qos_t, + } + + pub struct thread_throughput_qos_policy { + pub thread_throughput_qos_tier: thread_throughput_qos_t, + } + + // malloc/malloc.h + pub struct malloc_statistics_t { + pub blocks_in_use: c_uint, + pub size_in_use: size_t, + pub max_size_in_use: size_t, + pub size_allocated: size_t, + } + + pub struct mstats { + pub bytes_total: size_t, + pub chunks_used: size_t, + pub bytes_used: size_t, + pub chunks_free: size_t, + pub bytes_free: size_t, + } + + pub struct vm_range_t { + pub address: crate::vm_address_t, + pub size: crate::vm_size_t, + } + + pub struct vinfo_stat { + pub vst_dev: u32, + pub vst_mode: u16, + pub vst_nlink: u16, + pub vst_ino: u64, + pub vst_uid: crate::uid_t, + pub vst_gid: crate::gid_t, + pub vst_atime: i64, + pub vst_atimensec: i64, + pub vst_mtime: i64, + pub vst_mtimensec: i64, + pub vst_ctime: i64, + pub vst_ctimensec: i64, + pub vst_birthtime: i64, + pub vst_birthtimensec: i64, + pub vst_size: off_t, + pub vst_blocks: i64, + pub vst_blksize: i32, + pub vst_flags: u32, + pub vst_gen: u32, + pub vst_rdev: u32, + pub vst_qspare: [i64; 2], + } + + pub struct vnode_info { + pub vi_stat: vinfo_stat, + pub vi_type: c_int, + pub vi_pad: c_int, + pub vi_fsid: crate::fsid_t, + } + + pub struct vnode_info_path { + pub vip_vi: vnode_info, + // Normally it's `vip_path: [c_char; MAXPATHLEN]` but because libc supports an old rustc + // version, we go around this limitation like this. + pub vip_path: [[c_char; 32]; 32], + } + + pub struct proc_vnodepathinfo { + pub pvi_cdir: vnode_info_path, + pub pvi_rdir: vnode_info_path, + } + + pub struct vm_statistics { + pub free_count: natural_t, + pub active_count: natural_t, + pub inactive_count: natural_t, + pub wire_count: natural_t, + pub zero_fill_count: natural_t, + pub reactivations: natural_t, + pub pageins: natural_t, + pub pageouts: natural_t, + pub faults: natural_t, + pub cow_faults: natural_t, + pub lookups: natural_t, + pub hits: natural_t, + pub purgeable_count: natural_t, + pub purges: natural_t, + pub speculative_count: natural_t, + } + + pub struct task_thread_times_info { + pub user_time: time_value_t, + pub system_time: time_value_t, + } + + pub struct rusage_info_v0 { + pub ri_uuid: [u8; 16], + pub ri_user_time: u64, + pub ri_system_time: u64, + pub ri_pkg_idle_wkups: u64, + pub ri_interrupt_wkups: u64, + pub ri_pageins: u64, + pub ri_wired_size: u64, + pub ri_resident_size: u64, + pub ri_phys_footprint: u64, + pub ri_proc_start_abstime: u64, + pub ri_proc_exit_abstime: u64, + } + + pub struct rusage_info_v1 { + pub ri_uuid: [u8; 16], + pub ri_user_time: u64, + pub ri_system_time: u64, + pub ri_pkg_idle_wkups: u64, + pub ri_interrupt_wkups: u64, + pub ri_pageins: u64, + pub ri_wired_size: u64, + pub ri_resident_size: u64, + pub ri_phys_footprint: u64, + pub ri_proc_start_abstime: u64, + pub ri_proc_exit_abstime: u64, + pub ri_child_user_time: u64, + pub ri_child_system_time: u64, + pub ri_child_pkg_idle_wkups: u64, + pub ri_child_interrupt_wkups: u64, + pub ri_child_pageins: u64, + pub ri_child_elapsed_abstime: u64, + } + + pub struct rusage_info_v2 { + pub ri_uuid: [u8; 16], + pub ri_user_time: u64, + pub ri_system_time: u64, + pub ri_pkg_idle_wkups: u64, + pub ri_interrupt_wkups: u64, + pub ri_pageins: u64, + pub ri_wired_size: u64, + pub ri_resident_size: u64, + pub ri_phys_footprint: u64, + pub ri_proc_start_abstime: u64, + pub ri_proc_exit_abstime: u64, + pub ri_child_user_time: u64, + pub ri_child_system_time: u64, + pub ri_child_pkg_idle_wkups: u64, + pub ri_child_interrupt_wkups: u64, + pub ri_child_pageins: u64, + pub ri_child_elapsed_abstime: u64, + pub ri_diskio_bytesread: u64, + pub ri_diskio_byteswritten: u64, + } + + pub struct rusage_info_v3 { + pub ri_uuid: [u8; 16], + pub ri_user_time: u64, + pub ri_system_time: u64, + pub ri_pkg_idle_wkups: u64, + pub ri_interrupt_wkups: u64, + pub ri_pageins: u64, + pub ri_wired_size: u64, + pub ri_resident_size: u64, + pub ri_phys_footprint: u64, + pub ri_proc_start_abstime: u64, + pub ri_proc_exit_abstime: u64, + pub ri_child_user_time: u64, + pub ri_child_system_time: u64, + pub ri_child_pkg_idle_wkups: u64, + pub ri_child_interrupt_wkups: u64, + pub ri_child_pageins: u64, + pub ri_child_elapsed_abstime: u64, + pub ri_diskio_bytesread: u64, + pub ri_diskio_byteswritten: u64, + pub ri_cpu_time_qos_default: u64, + pub ri_cpu_time_qos_maintenance: u64, + pub ri_cpu_time_qos_background: u64, + pub ri_cpu_time_qos_utility: u64, + pub ri_cpu_time_qos_legacy: u64, + pub ri_cpu_time_qos_user_initiated: u64, + pub ri_cpu_time_qos_user_interactive: u64, + pub ri_billed_system_time: u64, + pub ri_serviced_system_time: u64, + } + + pub struct rusage_info_v4 { + pub ri_uuid: [u8; 16], + pub ri_user_time: u64, + pub ri_system_time: u64, + pub ri_pkg_idle_wkups: u64, + pub ri_interrupt_wkups: u64, + pub ri_pageins: u64, + pub ri_wired_size: u64, + pub ri_resident_size: u64, + pub ri_phys_footprint: u64, + pub ri_proc_start_abstime: u64, + pub ri_proc_exit_abstime: u64, + pub ri_child_user_time: u64, + pub ri_child_system_time: u64, + pub ri_child_pkg_idle_wkups: u64, + pub ri_child_interrupt_wkups: u64, + pub ri_child_pageins: u64, + pub ri_child_elapsed_abstime: u64, + pub ri_diskio_bytesread: u64, + pub ri_diskio_byteswritten: u64, + pub ri_cpu_time_qos_default: u64, + pub ri_cpu_time_qos_maintenance: u64, + pub ri_cpu_time_qos_background: u64, + pub ri_cpu_time_qos_utility: u64, + pub ri_cpu_time_qos_legacy: u64, + pub ri_cpu_time_qos_user_initiated: u64, + pub ri_cpu_time_qos_user_interactive: u64, + pub ri_billed_system_time: u64, + pub ri_serviced_system_time: u64, + pub ri_logical_writes: u64, + pub ri_lifetime_max_phys_footprint: u64, + pub ri_instructions: u64, + pub ri_cycles: u64, + pub ri_billed_energy: u64, + pub ri_serviced_energy: u64, + pub ri_interval_max_phys_footprint: u64, + pub ri_runnable_time: u64, + } + + pub struct image_offset { + pub uuid: crate::uuid_t, + pub offset: u32, + } + + pub struct attrlist { + pub bitmapcount: c_ushort, + pub reserved: u16, + pub commonattr: attrgroup_t, + pub volattr: attrgroup_t, + pub dirattr: attrgroup_t, + pub fileattr: attrgroup_t, + pub forkattr: attrgroup_t, + } + + pub struct attrreference_t { + pub attr_dataoffset: i32, + pub attr_length: u32, + } + + pub struct vol_capabilities_attr_t { + pub capabilities: vol_capabilities_set_t, + pub valid: vol_capabilities_set_t, + } + + pub struct attribute_set_t { + pub commonattr: attrgroup_t, + pub volattr: attrgroup_t, + pub dirattr: attrgroup_t, + pub fileattr: attrgroup_t, + pub forkattr: attrgroup_t, + } + + pub struct vol_attributes_attr_t { + pub validattr: attribute_set_t, + pub nativeattr: attribute_set_t, + } + + #[repr(align(8))] + pub struct tcp_connection_info { + pub tcpi_state: u8, + pub tcpi_snd_wscale: u8, + pub tcpi_rcv_wscale: u8, + __pad1: Padding, + pub tcpi_options: u32, + pub tcpi_flags: u32, + pub tcpi_rto: u32, + pub tcpi_maxseg: u32, + pub tcpi_snd_ssthresh: u32, + pub tcpi_snd_cwnd: u32, + pub tcpi_snd_wnd: u32, + pub tcpi_snd_sbbytes: u32, + pub tcpi_rcv_wnd: u32, + pub tcpi_rttcur: u32, + pub tcpi_srtt: u32, + pub tcpi_rttvar: u32, + pub tcpi_tfo_cookie_req: u32, + pub tcpi_tfo_cookie_rcv: u32, + pub tcpi_tfo_syn_loss: u32, + pub tcpi_tfo_syn_data_sent: u32, + pub tcpi_tfo_syn_data_acked: u32, + pub tcpi_tfo_syn_data_rcv: u32, + pub tcpi_tfo_cookie_req_rcv: u32, + pub tcpi_tfo_cookie_sent: u32, + pub tcpi_tfo_cookie_invalid: u32, + pub tcpi_tfo_cookie_wrong: u32, + pub tcpi_tfo_no_cookie_rcv: u32, + pub tcpi_tfo_heuristics_disable: u32, + pub tcpi_tfo_send_blackhole: u32, + pub tcpi_tfo_recv_blackhole: u32, + pub tcpi_tfo_onebyte_proxy: u32, + __pad2: Padding, + pub tcpi_txpackets: u64, + pub tcpi_txbytes: u64, + pub tcpi_txretransmitbytes: u64, + pub tcpi_rxpackets: u64, + pub tcpi_rxbytes: u64, + pub tcpi_rxoutoforderbytes: u64, + pub tcpi_rxretransmitpackets: u64, + } + + pub struct in6_addrlifetime { + pub ia6t_expire: time_t, + pub ia6t_preferred: time_t, + pub ia6t_vltime: u32, + pub ia6t_pltime: u32, + } + + pub struct in6_ifstat { + pub ifs6_in_receive: crate::u_quad_t, + pub ifs6_in_hdrerr: crate::u_quad_t, + pub ifs6_in_toobig: crate::u_quad_t, + pub ifs6_in_noroute: crate::u_quad_t, + pub ifs6_in_addrerr: crate::u_quad_t, + pub ifs6_in_protounknown: crate::u_quad_t, + pub ifs6_in_truncated: crate::u_quad_t, + pub ifs6_in_discard: crate::u_quad_t, + pub ifs6_in_deliver: crate::u_quad_t, + pub ifs6_out_forward: crate::u_quad_t, + pub ifs6_out_request: crate::u_quad_t, + pub ifs6_out_discard: crate::u_quad_t, + pub ifs6_out_fragok: crate::u_quad_t, + pub ifs6_out_fragfail: crate::u_quad_t, + pub ifs6_out_fragcreat: crate::u_quad_t, + pub ifs6_reass_reqd: crate::u_quad_t, + pub ifs6_reass_ok: crate::u_quad_t, + pub ifs6_atmfrag_rcvd: crate::u_quad_t, + pub ifs6_reass_fail: crate::u_quad_t, + pub ifs6_in_mcast: crate::u_quad_t, + pub ifs6_out_mcast: crate::u_quad_t, + pub ifs6_cantfoward_icmp6: crate::u_quad_t, + pub ifs6_addr_expiry_cnt: crate::u_quad_t, + pub ifs6_pfx_expiry_cnt: crate::u_quad_t, + pub ifs6_defrtr_expiry_cnt: crate::u_quad_t, + } + + pub struct icmp6_ifstat { + pub ifs6_in_msg: crate::u_quad_t, + pub ifs6_in_error: crate::u_quad_t, + pub ifs6_in_dstunreach: crate::u_quad_t, + pub ifs6_in_adminprohib: crate::u_quad_t, + pub ifs6_in_timeexceed: crate::u_quad_t, + pub ifs6_in_paramprob: crate::u_quad_t, + pub ifs6_in_pkttoobig: crate::u_quad_t, + pub ifs6_in_echo: crate::u_quad_t, + pub ifs6_in_echoreply: crate::u_quad_t, + pub ifs6_in_routersolicit: crate::u_quad_t, + pub ifs6_in_routeradvert: crate::u_quad_t, + pub ifs6_in_neighborsolicit: crate::u_quad_t, + pub ifs6_in_neighboradvert: crate::u_quad_t, + pub ifs6_in_redirect: crate::u_quad_t, + pub ifs6_in_mldquery: crate::u_quad_t, + pub ifs6_in_mldreport: crate::u_quad_t, + pub ifs6_in_mlddone: crate::u_quad_t, + pub ifs6_out_msg: crate::u_quad_t, + pub ifs6_out_error: crate::u_quad_t, + pub ifs6_out_dstunreach: crate::u_quad_t, + pub ifs6_out_adminprohib: crate::u_quad_t, + pub ifs6_out_timeexceed: crate::u_quad_t, + pub ifs6_out_paramprob: crate::u_quad_t, + pub ifs6_out_pkttoobig: crate::u_quad_t, + pub ifs6_out_echo: crate::u_quad_t, + pub ifs6_out_echoreply: crate::u_quad_t, + pub ifs6_out_routersolicit: crate::u_quad_t, + pub ifs6_out_routeradvert: crate::u_quad_t, + pub ifs6_out_neighborsolicit: crate::u_quad_t, + pub ifs6_out_neighboradvert: crate::u_quad_t, + pub ifs6_out_redirect: crate::u_quad_t, + pub ifs6_out_mldquery: crate::u_quad_t, + pub ifs6_out_mldreport: crate::u_quad_t, + pub ifs6_out_mlddone: crate::u_quad_t, + } + + // mach/host_info.h + pub struct host_cpu_load_info { + pub cpu_ticks: [crate::natural_t; CPU_STATE_MAX as usize], + } + + // net/if_mib.h + pub struct ifmibdata { + /// Name of interface + pub ifmd_name: [c_char; crate::IFNAMSIZ], + /// Number of promiscuous listeners + pub ifmd_pcount: c_uint, + /// Interface flags + pub ifmd_flags: c_uint, + /// Instantaneous length of send queue + pub ifmd_snd_len: c_uint, + /// Maximum length of send queue + pub ifmd_snd_maxlen: c_uint, + /// Number of drops in send queue + pub ifmd_snd_drops: c_uint, + /// For future expansion + pub ifmd_filler: [c_uint; 4], + /// Generic information and statistics + pub ifmd_data: if_data64, + } + + pub struct ifs_iso_8802_3 { + pub dot3StatsAlignmentErrors: u32, + pub dot3StatsFCSErrors: u32, + pub dot3StatsSingleCollisionFrames: u32, + pub dot3StatsMultipleCollisionFrames: u32, + pub dot3StatsSQETestErrors: u32, + pub dot3StatsDeferredTransmissions: u32, + pub dot3StatsLateCollisions: u32, + pub dot3StatsExcessiveCollisions: u32, + pub dot3StatsInternalMacTransmitErrors: u32, + pub dot3StatsCarrierSenseErrors: u32, + pub dot3StatsFrameTooLongs: u32, + pub dot3StatsInternalMacReceiveErrors: u32, + pub dot3StatsEtherChipSet: u32, + pub dot3StatsMissedFrames: u32, + pub dot3StatsCollFrequencies: [u32; 16], + pub dot3Compliance: u32, + } + + // kern_control.h + pub struct ctl_info { + pub ctl_id: u32, + pub ctl_name: [c_char; MAX_KCTL_NAME], + } + + // sys/proc_info.h + pub struct proc_fdinfo { + pub proc_fd: i32, + pub proc_fdtype: u32, + } + + #[repr(packed(4))] + pub struct kevent { + pub ident: crate::uintptr_t, + pub filter: i16, + pub flags: u16, + pub fflags: u32, + pub data: intptr_t, + pub udata: *mut c_void, + } + + #[repr(packed(4))] + pub struct semid_ds { + // Note the manpage shows different types than the system header. + pub sem_perm: ipc_perm, + pub sem_base: i32, + pub sem_nsems: c_ushort, + pub sem_otime: crate::time_t, + pub sem_pad1: i32, + pub sem_ctime: crate::time_t, + pub sem_pad2: i32, + pub sem_pad3: [i32; 4], + } + + #[repr(packed(4))] + pub struct shmid_ds { + pub shm_perm: ipc_perm, + pub shm_segsz: size_t, + pub shm_lpid: crate::pid_t, + pub shm_cpid: crate::pid_t, + pub shm_nattch: crate::shmatt_t, + pub shm_atime: crate::time_t, // FIXME(macos): 64-bit wrong align => wrong offset + pub shm_dtime: crate::time_t, // FIXME(macos): 64-bit wrong align => wrong offset + pub shm_ctime: crate::time_t, // FIXME(macos): 64-bit wrong align => wrong offset + // FIXME: 64-bit wrong align => wrong offset: + pub shm_internal: *mut c_void, + } + + pub struct proc_threadinfo { + pub pth_user_time: u64, + pub pth_system_time: u64, + pub pth_cpu_usage: i32, + pub pth_policy: i32, + pub pth_run_state: i32, + pub pth_flags: i32, + pub pth_sleep_time: i32, + pub pth_curpri: i32, + pub pth_priority: i32, + pub pth_maxpriority: i32, + pub pth_name: [c_char; MAXTHREADNAMESIZE], + } + + pub struct statfs { + pub f_bsize: u32, + pub f_iosize: i32, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_fsid: crate::fsid_t, + pub f_owner: crate::uid_t, + pub f_type: u32, + pub f_flags: u32, + pub f_fssubtype: u32, + pub f_fstypename: [c_char; 16], + pub f_mntonname: [c_char; 1024], + pub f_mntfromname: [c_char; 1024], + pub f_flags_ext: u32, + pub f_reserved: [u32; 7], + } + + pub struct dirent { + pub d_ino: u64, + pub d_seekoff: u64, + pub d_reclen: u16, + pub d_namlen: u16, + pub d_type: u8, + pub d_name: [c_char; 1024], + } + + pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: crate::sa_family_t, + __ss_pad1: Padding<[u8; 6]>, + __ss_align: i64, + __ss_pad2: Padding<[u8; 112]>, + } + + pub struct utmpx { + pub ut_user: [c_char; _UTX_USERSIZE], + pub ut_id: [c_char; _UTX_IDSIZE], + pub ut_line: [c_char; _UTX_LINESIZE], + pub ut_pid: crate::pid_t, + pub ut_type: c_short, + pub ut_tv: crate::timeval, + pub ut_host: [c_char; _UTX_HOSTSIZE], + ut_pad: Padding<[u32; 16]>, + } + + pub struct sigevent { + pub sigev_notify: c_int, + pub sigev_signo: c_int, + pub sigev_value: crate::sigval, + __unused1: Padding<*mut c_void>, //actually a function pointer + pub sigev_notify_attributes: *mut crate::pthread_attr_t, + } + + pub struct processor_cpu_load_info { + pub cpu_ticks: [c_uint; CPU_STATE_MAX as usize], + } + + pub struct processor_basic_info { + pub cpu_type: cpu_type_t, + pub cpu_subtype: cpu_subtype_t, + pub running: crate::boolean_t, + pub slot_num: c_int, + pub is_master: crate::boolean_t, + } + + pub struct processor_set_basic_info { + pub processor_count: c_int, + pub default_policy: c_int, + } + + pub struct processor_set_load_info { + pub task_count: c_int, + pub thread_count: c_int, + pub load_average: integer_t, + pub mach_factor: integer_t, + } + + pub struct time_value_t { + pub seconds: integer_t, + pub microseconds: integer_t, + } + + pub struct thread_basic_info { + pub user_time: time_value_t, + pub system_time: time_value_t, + pub cpu_usage: crate::integer_t, + pub policy: crate::policy_t, + pub run_state: crate::integer_t, + pub flags: crate::integer_t, + pub suspend_count: crate::integer_t, + pub sleep_time: crate::integer_t, + } + + pub struct thread_identifier_info { + pub thread_id: u64, + pub thread_handle: u64, + pub dispatch_qaddr: u64, + } + + pub struct thread_extended_info { + pub pth_user_time: u64, + pub pth_system_time: u64, + pub pth_cpu_usage: i32, + pub pth_policy: i32, + pub pth_run_state: i32, + pub pth_flags: i32, + pub pth_sleep_time: i32, + pub pth_curpri: i32, + pub pth_priority: i32, + pub pth_maxpriority: i32, + pub pth_name: [c_char; MAXTHREADNAMESIZE], + } + + #[repr(packed(4))] + pub struct if_data64 { + pub ifi_type: c_uchar, + pub ifi_typelen: c_uchar, + pub ifi_physical: c_uchar, + pub ifi_addrlen: c_uchar, + pub ifi_hdrlen: c_uchar, + pub ifi_recvquota: c_uchar, + pub ifi_xmitquota: c_uchar, + pub ifi_unused1: c_uchar, + pub ifi_mtu: u32, + pub ifi_metric: u32, + pub ifi_baudrate: u64, + pub ifi_ipackets: u64, + pub ifi_ierrors: u64, + pub ifi_opackets: u64, + pub ifi_oerrors: u64, + pub ifi_collisions: u64, + pub ifi_ibytes: u64, + pub ifi_obytes: u64, + pub ifi_imcasts: u64, + pub ifi_omcasts: u64, + pub ifi_iqdrops: u64, + pub ifi_noproto: u64, + pub ifi_recvtiming: u32, + pub ifi_xmittiming: u32, + #[cfg(target_pointer_width = "32")] + pub ifi_lastchange: crate::timeval, + #[cfg(not(target_pointer_width = "32"))] + pub ifi_lastchange: timeval32, + } + + #[repr(packed(4))] + pub struct if_msghdr2 { + pub ifm_msglen: c_ushort, + pub ifm_version: c_uchar, + pub ifm_type: c_uchar, + pub ifm_addrs: c_int, + pub ifm_flags: c_int, + pub ifm_index: c_ushort, + pub ifm_snd_len: c_int, + pub ifm_snd_maxlen: c_int, + pub ifm_snd_drops: c_int, + pub ifm_timer: c_int, + pub ifm_data: if_data64, + } + + #[repr(packed(8))] + pub struct vm_statistics64 { + pub free_count: natural_t, + pub active_count: natural_t, + pub inactive_count: natural_t, + pub wire_count: natural_t, + pub zero_fill_count: u64, + pub reactivations: u64, + pub pageins: u64, + pub pageouts: u64, + pub faults: u64, + pub cow_faults: u64, + pub lookups: u64, + pub hits: u64, + pub purges: u64, + pub purgeable_count: natural_t, + pub speculative_count: natural_t, + pub decompressions: u64, + pub compressions: u64, + pub swapins: u64, + pub swapouts: u64, + pub compressor_page_count: natural_t, + pub throttled_count: natural_t, + pub external_page_count: natural_t, + pub internal_page_count: natural_t, + pub total_uncompressed_pages_in_compressor: u64, + } + + #[repr(packed(4))] + pub struct mach_task_basic_info { + pub virtual_size: mach_vm_size_t, + pub resident_size: mach_vm_size_t, + pub resident_size_max: mach_vm_size_t, + pub user_time: time_value_t, + pub system_time: time_value_t, + pub policy: crate::policy_t, + pub suspend_count: integer_t, + } + + #[repr(packed(4))] + pub struct log2phys { + pub l2p_flags: c_uint, + pub l2p_contigbytes: off_t, + pub l2p_devoffset: off_t, + } + + pub struct os_unfair_lock_s { + _os_unfair_lock_opaque: u32, + } + + #[repr(packed(1))] + pub struct sockaddr_vm { + pub svm_len: c_uchar, + pub svm_family: crate::sa_family_t, + pub svm_reserved1: c_ushort, + pub svm_port: c_uint, + pub svm_cid: c_uint, + } + + pub struct ifdevmtu { + pub ifdm_current: c_int, + pub ifdm_min: c_int, + pub ifdm_max: c_int, + } + + #[repr(packed(4))] + pub struct ifkpi { + pub ifk_module_id: c_uint, + pub ifk_type: c_uint, + pub ifk_data: __c_anonymous_ifk_data, + } + + pub struct ifreq { + pub ifr_name: [c_char; crate::IFNAMSIZ], + pub ifr_ifru: __c_anonymous_ifr_ifru, + } + + pub struct in6_ifreq { + pub ifr_name: [c_char; crate::IFNAMSIZ], + pub ifr_ifru: __c_anonymous_ifr_ifru6, + } +} + +s_no_extra_traits! { + #[repr(packed(4))] + pub struct ifconf { + pub ifc_len: c_int, + pub ifc_ifcu: __c_anonymous_ifc_ifcu, + } + pub union __c_anonymous_ifk_data { + pub ifk_ptr: *mut c_void, + pub ifk_value: c_int, + } + + pub union __c_anonymous_ifr_ifru { + pub ifru_addr: crate::sockaddr, + pub ifru_dstaddr: crate::sockaddr, + pub ifru_broadaddr: crate::sockaddr, + pub ifru_flags: c_short, + pub ifru_metrics: c_int, + pub ifru_mtu: c_int, + pub ifru_phys: c_int, + pub ifru_media: c_int, + pub ifru_intval: c_int, + pub ifru_data: *mut c_char, + pub ifru_devmtu: ifdevmtu, + pub ifru_kpi: ifkpi, + pub ifru_wake_flags: u32, + pub ifru_route_refcnt: u32, + pub ifru_cap: [c_int; 2], + pub ifru_functional_type: u32, + } + + pub union __c_anonymous_ifc_ifcu { + pub ifcu_buf: *mut c_char, + pub ifcu_req: *mut ifreq, + } + + pub union __c_anonymous_ifr_ifru6 { + pub ifru_addr: crate::sockaddr_in6, + pub ifru_dstaddr: crate::sockaddr_in6, + pub ifru_flags: c_int, + pub ifru_flags6: c_int, + pub ifru_metrics: c_int, + pub ifru_intval: c_int, + pub ifru_data: *mut c_char, + pub ifru_lifetime: in6_addrlifetime, + pub ifru_stat: in6_ifstat, + pub ifru_icmp6stat: icmp6_ifstat, + pub ifru_scope_id: [u32; SCOPE6_ID_MAX], + } +} + +impl siginfo_t { + pub unsafe fn si_addr(&self) -> *mut c_void { + self.si_addr + } + + pub unsafe fn si_value(&self) -> crate::sigval { + #[repr(C)] + struct siginfo_timer { + _si_signo: c_int, + _si_errno: c_int, + _si_code: c_int, + _si_pid: crate::pid_t, + _si_uid: crate::uid_t, + _si_status: c_int, + _si_addr: *mut c_void, + si_value: crate::sigval, + } + + (*(self as *const siginfo_t).cast::()).si_value + } + + pub unsafe fn si_pid(&self) -> crate::pid_t { + self.si_pid + } + + pub unsafe fn si_uid(&self) -> crate::uid_t { + self.si_uid + } + + pub unsafe fn si_status(&self) -> c_int { + self.si_status + } +} + +s_no_extra_traits! { + pub union semun { + pub val: c_int, + pub buf: *mut semid_ds, + pub array: *mut c_ushort, + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for semun { + fn eq(&self, other: &semun) -> bool { + unsafe { self.val == other.val } + } + } + impl Eq for semun {} + impl hash::Hash for semun { + fn hash(&self, state: &mut H) { + unsafe { self.val.hash(state) }; + } + } + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for ifconf + where + Self: Copy, + { + fn eq(&self, other: &Self) -> bool { + let len_ptr1 = core::ptr::addr_of!(self.ifc_len); + let len_ptr2 = core::ptr::addr_of!(other.ifc_len); + let ifcu_ptr1 = core::ptr::addr_of!(self.ifc_ifcu); + let ifcu_ptr2 = core::ptr::addr_of!(other.ifc_ifcu); + + // SAFETY: `ifconf` implements `Copy` so the reads are valid + let len1 = unsafe { len_ptr1.read_unaligned() }; + let len2 = unsafe { len_ptr2.read_unaligned() }; + let ifcu1 = unsafe { ifcu_ptr1.read_unaligned() }; + let ifcu2 = unsafe { ifcu_ptr2.read_unaligned() }; + + len1 == len2 && ifcu1 == ifcu2 + } + } + impl Eq for ifconf {} + + impl PartialEq for __c_anonymous_ifk_data { + fn eq(&self, other: &__c_anonymous_ifk_data) -> bool { + unsafe { self.ifk_ptr == other.ifk_ptr && self.ifk_value == other.ifk_value } + } + } + + impl Eq for __c_anonymous_ifk_data {} + impl hash::Hash for __c_anonymous_ifk_data { + fn hash(&self, state: &mut H) { + unsafe { + self.ifk_ptr.hash(state); + self.ifk_value.hash(state); + } + } + } + + impl PartialEq for __c_anonymous_ifr_ifru { + fn eq(&self, other: &__c_anonymous_ifr_ifru) -> bool { + unsafe { + self.ifru_addr == other.ifru_addr + && self.ifru_dstaddr == other.ifru_dstaddr + && self.ifru_broadaddr == other.ifru_broadaddr + && self.ifru_flags == other.ifru_flags + && self.ifru_metrics == other.ifru_metrics + && self.ifru_mtu == other.ifru_mtu + && self.ifru_phys == other.ifru_phys + && self.ifru_media == other.ifru_media + && self.ifru_intval == other.ifru_intval + && self.ifru_data == other.ifru_data + && self.ifru_devmtu == other.ifru_devmtu + && self.ifru_kpi == other.ifru_kpi + && self.ifru_wake_flags == other.ifru_wake_flags + && self.ifru_route_refcnt == other.ifru_route_refcnt + && self + .ifru_cap + .iter() + .zip(other.ifru_cap.iter()) + .all(|(a, b)| a == b) + && self.ifru_functional_type == other.ifru_functional_type + } + } + } + + impl Eq for __c_anonymous_ifr_ifru {} + + impl hash::Hash for __c_anonymous_ifr_ifru { + fn hash(&self, state: &mut H) { + unsafe { + self.ifru_addr.hash(state); + self.ifru_dstaddr.hash(state); + self.ifru_broadaddr.hash(state); + self.ifru_flags.hash(state); + self.ifru_metrics.hash(state); + self.ifru_mtu.hash(state); + self.ifru_phys.hash(state); + self.ifru_media.hash(state); + self.ifru_intval.hash(state); + self.ifru_data.hash(state); + self.ifru_devmtu.hash(state); + self.ifru_kpi.hash(state); + self.ifru_wake_flags.hash(state); + self.ifru_route_refcnt.hash(state); + self.ifru_cap.hash(state); + self.ifru_functional_type.hash(state); + } + } + } + + impl Eq for __c_anonymous_ifc_ifcu {} + + impl PartialEq for __c_anonymous_ifc_ifcu { + fn eq(&self, other: &__c_anonymous_ifc_ifcu) -> bool { + unsafe { self.ifcu_buf == other.ifcu_buf && self.ifcu_req == other.ifcu_req } + } + } + + impl hash::Hash for __c_anonymous_ifc_ifcu { + fn hash(&self, state: &mut H) { + unsafe { self.ifcu_buf.hash(state) }; + unsafe { self.ifcu_req.hash(state) }; + } + } + + impl PartialEq for __c_anonymous_ifr_ifru6 { + fn eq(&self, other: &__c_anonymous_ifr_ifru6) -> bool { + unsafe { + self.ifru_addr == other.ifru_addr + && self.ifru_dstaddr == other.ifru_dstaddr + && self.ifru_flags == other.ifru_flags + && self.ifru_flags6 == other.ifru_flags6 + && self.ifru_metrics == other.ifru_metrics + && self.ifru_intval == other.ifru_intval + && self.ifru_data == other.ifru_data + && self + .ifru_scope_id + .iter() + .zip(other.ifru_scope_id.iter()) + .all(|(a, b)| a == b) + } + } + } + + impl Eq for __c_anonymous_ifr_ifru6 {} + + impl hash::Hash for __c_anonymous_ifr_ifru6 { + fn hash(&self, state: &mut H) { + unsafe { + self.ifru_addr.hash(state); + self.ifru_dstaddr.hash(state); + self.ifru_flags.hash(state); + self.ifru_flags6.hash(state); + self.ifru_metrics.hash(state); + self.ifru_intval.hash(state); + self.ifru_data.hash(state); + self.ifru_scope_id.hash(state); + } + } + } + } +} + +pub const _UTX_USERSIZE: usize = 256; +pub const _UTX_LINESIZE: usize = 32; +pub const _UTX_IDSIZE: usize = 4; +pub const _UTX_HOSTSIZE: usize = 256; + +pub const EMPTY: c_short = 0; +pub const RUN_LVL: c_short = 1; +pub const BOOT_TIME: c_short = 2; +pub const OLD_TIME: c_short = 3; +pub const NEW_TIME: c_short = 4; +pub const INIT_PROCESS: c_short = 5; +pub const LOGIN_PROCESS: c_short = 6; +pub const USER_PROCESS: c_short = 7; +pub const DEAD_PROCESS: c_short = 8; +pub const ACCOUNTING: c_short = 9; +pub const SIGNATURE: c_short = 10; +pub const SHUTDOWN_TIME: c_short = 11; + +pub const LC_COLLATE_MASK: c_int = 1 << 0; +pub const LC_CTYPE_MASK: c_int = 1 << 1; +pub const LC_MESSAGES_MASK: c_int = 1 << 2; +pub const LC_MONETARY_MASK: c_int = 1 << 3; +pub const LC_NUMERIC_MASK: c_int = 1 << 4; +pub const LC_TIME_MASK: c_int = 1 << 5; +pub const LC_ALL_MASK: c_int = LC_COLLATE_MASK + | LC_CTYPE_MASK + | LC_MESSAGES_MASK + | LC_MONETARY_MASK + | LC_NUMERIC_MASK + | LC_TIME_MASK; + +pub const CODESET: crate::nl_item = 0; +pub const D_T_FMT: crate::nl_item = 1; +pub const D_FMT: crate::nl_item = 2; +pub const T_FMT: crate::nl_item = 3; +pub const T_FMT_AMPM: crate::nl_item = 4; +pub const AM_STR: crate::nl_item = 5; +pub const PM_STR: crate::nl_item = 6; + +pub const DAY_1: crate::nl_item = 7; +pub const DAY_2: crate::nl_item = 8; +pub const DAY_3: crate::nl_item = 9; +pub const DAY_4: crate::nl_item = 10; +pub const DAY_5: crate::nl_item = 11; +pub const DAY_6: crate::nl_item = 12; +pub const DAY_7: crate::nl_item = 13; + +pub const ABDAY_1: crate::nl_item = 14; +pub const ABDAY_2: crate::nl_item = 15; +pub const ABDAY_3: crate::nl_item = 16; +pub const ABDAY_4: crate::nl_item = 17; +pub const ABDAY_5: crate::nl_item = 18; +pub const ABDAY_6: crate::nl_item = 19; +pub const ABDAY_7: crate::nl_item = 20; + +pub const MON_1: crate::nl_item = 21; +pub const MON_2: crate::nl_item = 22; +pub const MON_3: crate::nl_item = 23; +pub const MON_4: crate::nl_item = 24; +pub const MON_5: crate::nl_item = 25; +pub const MON_6: crate::nl_item = 26; +pub const MON_7: crate::nl_item = 27; +pub const MON_8: crate::nl_item = 28; +pub const MON_9: crate::nl_item = 29; +pub const MON_10: crate::nl_item = 30; +pub const MON_11: crate::nl_item = 31; +pub const MON_12: crate::nl_item = 32; + +pub const ABMON_1: crate::nl_item = 33; +pub const ABMON_2: crate::nl_item = 34; +pub const ABMON_3: crate::nl_item = 35; +pub const ABMON_4: crate::nl_item = 36; +pub const ABMON_5: crate::nl_item = 37; +pub const ABMON_6: crate::nl_item = 38; +pub const ABMON_7: crate::nl_item = 39; +pub const ABMON_8: crate::nl_item = 40; +pub const ABMON_9: crate::nl_item = 41; +pub const ABMON_10: crate::nl_item = 42; +pub const ABMON_11: crate::nl_item = 43; +pub const ABMON_12: crate::nl_item = 44; + +pub const CLOCK_REALTIME: crate::clockid_t = 0; +pub const CLOCK_MONOTONIC_RAW: crate::clockid_t = 4; +pub const CLOCK_MONOTONIC_RAW_APPROX: crate::clockid_t = 5; +pub const CLOCK_MONOTONIC: crate::clockid_t = 6; +pub const CLOCK_UPTIME_RAW: crate::clockid_t = 8; +pub const CLOCK_UPTIME_RAW_APPROX: crate::clockid_t = 9; +pub const CLOCK_PROCESS_CPUTIME_ID: crate::clockid_t = 12; +pub const CLOCK_THREAD_CPUTIME_ID: crate::clockid_t = 16; + +pub const ERA: crate::nl_item = 45; +pub const ERA_D_FMT: crate::nl_item = 46; +pub const ERA_D_T_FMT: crate::nl_item = 47; +pub const ERA_T_FMT: crate::nl_item = 48; +pub const ALT_DIGITS: crate::nl_item = 49; + +pub const RADIXCHAR: crate::nl_item = 50; +pub const THOUSEP: crate::nl_item = 51; + +pub const YESEXPR: crate::nl_item = 52; +pub const NOEXPR: crate::nl_item = 53; + +pub const YESSTR: crate::nl_item = 54; +pub const NOSTR: crate::nl_item = 55; + +pub const CRNCYSTR: crate::nl_item = 56; + +pub const D_MD_ORDER: crate::nl_item = 57; + +pub const EXIT_FAILURE: c_int = 1; +pub const EXIT_SUCCESS: c_int = 0; +pub const RAND_MAX: c_int = 2147483647; +pub const EOF: c_int = -1; +pub const SEEK_SET: c_int = 0; +pub const SEEK_CUR: c_int = 1; +pub const SEEK_END: c_int = 2; +pub const SEEK_HOLE: c_int = 3; +pub const SEEK_DATA: c_int = 4; +pub const _IOFBF: c_int = 0; +pub const _IONBF: c_int = 2; +pub const _IOLBF: c_int = 1; +pub const BUFSIZ: c_uint = 1024; +pub const FOPEN_MAX: c_uint = 20; +pub const FILENAME_MAX: c_uint = 1024; +pub const L_tmpnam: c_uint = 1024; +pub const TMP_MAX: c_uint = 308915776; +pub const _PC_LINK_MAX: c_int = 1; +pub const _PC_MAX_CANON: c_int = 2; +pub const _PC_MAX_INPUT: c_int = 3; +pub const _PC_NAME_MAX: c_int = 4; +pub const _PC_PATH_MAX: c_int = 5; +pub const _PC_PIPE_BUF: c_int = 6; +pub const _PC_CHOWN_RESTRICTED: c_int = 7; +pub const _PC_NO_TRUNC: c_int = 8; +pub const _PC_VDISABLE: c_int = 9; +pub const _PC_NAME_CHARS_MAX: c_int = 10; +pub const _PC_CASE_SENSITIVE: c_int = 11; +pub const _PC_CASE_PRESERVING: c_int = 12; +pub const _PC_EXTENDED_SECURITY_NP: c_int = 13; +pub const _PC_AUTH_OPAQUE_NP: c_int = 14; +pub const _PC_2_SYMLINKS: c_int = 15; +pub const _PC_ALLOC_SIZE_MIN: c_int = 16; +pub const _PC_ASYNC_IO: c_int = 17; +pub const _PC_FILESIZEBITS: c_int = 18; +pub const _PC_PRIO_IO: c_int = 19; +pub const _PC_REC_INCR_XFER_SIZE: c_int = 20; +pub const _PC_REC_MAX_XFER_SIZE: c_int = 21; +pub const _PC_REC_MIN_XFER_SIZE: c_int = 22; +pub const _PC_REC_XFER_ALIGN: c_int = 23; +pub const _PC_SYMLINK_MAX: c_int = 24; +pub const _PC_SYNC_IO: c_int = 25; +pub const _PC_XATTR_SIZE_BITS: c_int = 26; +pub const _PC_MIN_HOLE_SIZE: c_int = 27; +pub const O_EVTONLY: c_int = 0x00008000; +pub const O_NOCTTY: c_int = 0x00020000; +pub const O_DIRECTORY: c_int = 0x00100000; +pub const O_SYMLINK: c_int = 0x00200000; +pub const O_DSYNC: c_int = 0x00400000; +pub const O_CLOEXEC: c_int = 0x01000000; +pub const O_NOFOLLOW_ANY: c_int = 0x20000000; +pub const O_EXEC: c_int = 0x40000000; +pub const O_SEARCH: c_int = O_EXEC | O_DIRECTORY; +pub const S_IFIFO: mode_t = 0o1_0000; +pub const S_IFCHR: mode_t = 0o2_0000; +pub const S_IFBLK: mode_t = 0o6_0000; +pub const S_IFDIR: mode_t = 0o4_0000; +pub const S_IFREG: mode_t = 0o10_0000; +pub const S_IFLNK: mode_t = 0o12_0000; +pub const S_IFSOCK: mode_t = 0o14_0000; +pub const S_IFMT: mode_t = 0o17_0000; +pub const S_IEXEC: mode_t = 0o0100; +pub const S_IWRITE: mode_t = 0o0200; +pub const S_IREAD: mode_t = 0o0400; +pub const S_IRWXU: mode_t = 0o0700; +pub const S_IXUSR: mode_t = 0o0100; +pub const S_IWUSR: mode_t = 0o0200; +pub const S_IRUSR: mode_t = 0o0400; +pub const S_IRWXG: mode_t = 0o0070; +pub const S_IXGRP: mode_t = 0o0010; +pub const S_IWGRP: mode_t = 0o0020; +pub const S_IRGRP: mode_t = 0o0040; +pub const S_IRWXO: mode_t = 0o0007; +pub const S_IXOTH: mode_t = 0o0001; +pub const S_IWOTH: mode_t = 0o0002; +pub const S_IROTH: mode_t = 0o0004; +pub const F_OK: c_int = 0; +pub const R_OK: c_int = 4; +pub const W_OK: c_int = 2; +pub const X_OK: c_int = 1; +pub const F_LOCK: c_int = 1; +pub const F_TEST: c_int = 3; +pub const F_TLOCK: c_int = 2; +pub const F_ULOCK: c_int = 0; +pub const F_GETLK: c_int = 7; +pub const F_SETLK: c_int = 8; +pub const F_SETLKW: c_int = 9; +pub const SIGHUP: c_int = 1; +pub const SIGINT: c_int = 2; +pub const SIGQUIT: c_int = 3; +pub const SIGILL: c_int = 4; +pub const SIGABRT: c_int = 6; +pub const SIGEMT: c_int = 7; +pub const SIGFPE: c_int = 8; +pub const SIGKILL: c_int = 9; +pub const SIGSEGV: c_int = 11; +pub const SIGPIPE: c_int = 13; +pub const SIGALRM: c_int = 14; +pub const SIGTERM: c_int = 15; + +pub const PROT_NONE: c_int = 0; +pub const PROT_READ: c_int = 1; +pub const PROT_WRITE: c_int = 2; +pub const PROT_EXEC: c_int = 4; + +pub const PT_TRACE_ME: c_int = 0; +pub const PT_READ_I: c_int = 1; +pub const PT_READ_D: c_int = 2; +pub const PT_READ_U: c_int = 3; +pub const PT_WRITE_I: c_int = 4; +pub const PT_WRITE_D: c_int = 5; +pub const PT_WRITE_U: c_int = 6; +pub const PT_CONTINUE: c_int = 7; +pub const PT_KILL: c_int = 8; +pub const PT_STEP: c_int = 9; +pub const PT_ATTACH: c_int = 10; +pub const PT_DETACH: c_int = 11; +pub const PT_SIGEXC: c_int = 12; +pub const PT_THUPDATE: c_int = 13; +pub const PT_ATTACHEXC: c_int = 14; + +pub const PT_FORCEQUOTA: c_int = 30; +pub const PT_DENY_ATTACH: c_int = 31; +pub const PT_FIRSTMACH: c_int = 32; + +pub const MAP_FILE: c_int = 0x0000; +pub const MAP_SHARED: c_int = 0x0001; +pub const MAP_PRIVATE: c_int = 0x0002; +pub const MAP_FIXED: c_int = 0x0010; +pub const MAP_ANON: c_int = 0x1000; +pub const MAP_ANONYMOUS: c_int = MAP_ANON; + +pub const CPU_STATE_USER: c_int = 0; +pub const CPU_STATE_SYSTEM: c_int = 1; +pub const CPU_STATE_IDLE: c_int = 2; +pub const CPU_STATE_NICE: c_int = 3; +pub const CPU_STATE_MAX: c_int = 4; + +pub const PROCESSOR_BASIC_INFO: c_int = 1; +pub const PROCESSOR_CPU_LOAD_INFO: c_int = 2; +pub const PROCESSOR_PM_REGS_INFO: c_int = 0x10000001; +pub const PROCESSOR_TEMPERATURE: c_int = 0x10000002; +pub const PROCESSOR_SET_LOAD_INFO: c_int = 4; +pub const PROCESSOR_SET_BASIC_INFO: c_int = 5; + +deprecated_mach! { + pub const VM_FLAGS_FIXED: c_int = 0x0000; + pub const VM_FLAGS_ANYWHERE: c_int = 0x0001; + pub const VM_FLAGS_PURGABLE: c_int = 0x0002; + pub const VM_FLAGS_RANDOM_ADDR: c_int = 0x0008; + pub const VM_FLAGS_NO_CACHE: c_int = 0x0010; + pub const VM_FLAGS_RESILIENT_CODESIGN: c_int = 0x0020; + pub const VM_FLAGS_RESILIENT_MEDIA: c_int = 0x0040; + pub const VM_FLAGS_OVERWRITE: c_int = 0x4000; + pub const VM_FLAGS_SUPERPAGE_MASK: c_int = 0x70000; + pub const VM_FLAGS_RETURN_DATA_ADDR: c_int = 0x100000; + pub const VM_FLAGS_RETURN_4K_DATA_ADDR: c_int = 0x800000; + pub const VM_FLAGS_ALIAS_MASK: c_int = 0xFF000000; + pub const VM_FLAGS_USER_ALLOCATE: c_int = 0xff07401f; + pub const VM_FLAGS_USER_MAP: c_int = 0xff97401f; + pub const VM_FLAGS_USER_REMAP: c_int = VM_FLAGS_FIXED + | VM_FLAGS_ANYWHERE + | VM_FLAGS_RANDOM_ADDR + | VM_FLAGS_OVERWRITE + | VM_FLAGS_RETURN_DATA_ADDR + | VM_FLAGS_RESILIENT_CODESIGN; + + pub const VM_FLAGS_SUPERPAGE_SHIFT: c_int = 16; + pub const SUPERPAGE_NONE: c_int = 0; + pub const SUPERPAGE_SIZE_ANY: c_int = 1; + pub const VM_FLAGS_SUPERPAGE_NONE: c_int = SUPERPAGE_NONE << VM_FLAGS_SUPERPAGE_SHIFT; + pub const VM_FLAGS_SUPERPAGE_SIZE_ANY: c_int = SUPERPAGE_SIZE_ANY << VM_FLAGS_SUPERPAGE_SHIFT; + pub const SUPERPAGE_SIZE_2MB: c_int = 2; + pub const VM_FLAGS_SUPERPAGE_SIZE_2MB: c_int = SUPERPAGE_SIZE_2MB << VM_FLAGS_SUPERPAGE_SHIFT; + + pub const VM_MEMORY_MALLOC: c_int = 1; + pub const VM_MEMORY_MALLOC_SMALL: c_int = 2; + pub const VM_MEMORY_MALLOC_LARGE: c_int = 3; + pub const VM_MEMORY_MALLOC_HUGE: c_int = 4; + pub const VM_MEMORY_SBRK: c_int = 5; + pub const VM_MEMORY_REALLOC: c_int = 6; + pub const VM_MEMORY_MALLOC_TINY: c_int = 7; + pub const VM_MEMORY_MALLOC_LARGE_REUSABLE: c_int = 8; + pub const VM_MEMORY_MALLOC_LARGE_REUSED: c_int = 9; + pub const VM_MEMORY_ANALYSIS_TOOL: c_int = 10; + pub const VM_MEMORY_MALLOC_NANO: c_int = 11; + pub const VM_MEMORY_MACH_MSG: c_int = 20; + pub const VM_MEMORY_IOKIT: c_int = 21; + pub const VM_MEMORY_STACK: c_int = 30; + pub const VM_MEMORY_GUARD: c_int = 31; + pub const VM_MEMORY_SHARED_PMAP: c_int = 32; + pub const VM_MEMORY_DYLIB: c_int = 33; + pub const VM_MEMORY_OBJC_DISPATCHERS: c_int = 34; + pub const VM_MEMORY_UNSHARED_PMAP: c_int = 35; + pub const VM_MEMORY_APPKIT: c_int = 40; + pub const VM_MEMORY_FOUNDATION: c_int = 41; + pub const VM_MEMORY_COREGRAPHICS: c_int = 42; + pub const VM_MEMORY_CORESERVICES: c_int = 43; + pub const VM_MEMORY_CARBON: c_int = VM_MEMORY_CORESERVICES; + pub const VM_MEMORY_JAVA: c_int = 44; + pub const VM_MEMORY_COREDATA: c_int = 45; + pub const VM_MEMORY_COREDATA_OBJECTIDS: c_int = 46; + pub const VM_MEMORY_ATS: c_int = 50; + pub const VM_MEMORY_LAYERKIT: c_int = 51; + pub const VM_MEMORY_CGIMAGE: c_int = 52; + pub const VM_MEMORY_TCMALLOC: c_int = 53; + pub const VM_MEMORY_COREGRAPHICS_DATA: c_int = 54; + pub const VM_MEMORY_COREGRAPHICS_SHARED: c_int = 55; + pub const VM_MEMORY_COREGRAPHICS_FRAMEBUFFERS: c_int = 56; + pub const VM_MEMORY_COREGRAPHICS_BACKINGSTORES: c_int = 57; + pub const VM_MEMORY_COREGRAPHICS_XALLOC: c_int = 58; + pub const VM_MEMORY_COREGRAPHICS_MISC: c_int = VM_MEMORY_COREGRAPHICS; + pub const VM_MEMORY_DYLD: c_int = 60; + pub const VM_MEMORY_DYLD_MALLOC: c_int = 61; + pub const VM_MEMORY_SQLITE: c_int = 62; + pub const VM_MEMORY_JAVASCRIPT_CORE: c_int = 63; + pub const VM_MEMORY_JAVASCRIPT_JIT_EXECUTABLE_ALLOCATOR: c_int = 64; + pub const VM_MEMORY_JAVASCRIPT_JIT_REGISTER_FILE: c_int = 65; + pub const VM_MEMORY_GLSL: c_int = 66; + pub const VM_MEMORY_OPENCL: c_int = 67; + pub const VM_MEMORY_COREIMAGE: c_int = 68; + pub const VM_MEMORY_WEBCORE_PURGEABLE_BUFFERS: c_int = 69; + pub const VM_MEMORY_IMAGEIO: c_int = 70; + pub const VM_MEMORY_COREPROFILE: c_int = 71; + pub const VM_MEMORY_ASSETSD: c_int = 72; + pub const VM_MEMORY_OS_ALLOC_ONCE: c_int = 73; + pub const VM_MEMORY_LIBDISPATCH: c_int = 74; + pub const VM_MEMORY_ACCELERATE: c_int = 75; + pub const VM_MEMORY_COREUI: c_int = 76; + pub const VM_MEMORY_COREUIFILE: c_int = 77; + pub const VM_MEMORY_GENEALOGY: c_int = 78; + pub const VM_MEMORY_RAWCAMERA: c_int = 79; + pub const VM_MEMORY_CORPSEINFO: c_int = 80; + pub const VM_MEMORY_ASL: c_int = 81; + pub const VM_MEMORY_SWIFT_RUNTIME: c_int = 82; + pub const VM_MEMORY_SWIFT_METADATA: c_int = 83; + pub const VM_MEMORY_DHMM: c_int = 84; + pub const VM_MEMORY_SCENEKIT: c_int = 86; + pub const VM_MEMORY_SKYWALK: c_int = 87; + pub const VM_MEMORY_APPLICATION_SPECIFIC_1: c_int = 240; + pub const VM_MEMORY_APPLICATION_SPECIFIC_16: c_int = 255; +} + +pub const MAP_FAILED: *mut c_void = !0 as *mut c_void; + +pub const MCL_CURRENT: c_int = 0x0001; +pub const MCL_FUTURE: c_int = 0x0002; + +pub const MS_ASYNC: c_int = 0x0001; +pub const MS_INVALIDATE: c_int = 0x0002; +pub const MS_SYNC: c_int = 0x0010; + +pub const MS_KILLPAGES: c_int = 0x0004; +pub const MS_DEACTIVATE: c_int = 0x0008; + +pub const EPERM: c_int = 1; +pub const ENOENT: c_int = 2; +pub const ESRCH: c_int = 3; +pub const EINTR: c_int = 4; +pub const EIO: c_int = 5; +pub const ENXIO: c_int = 6; +pub const E2BIG: c_int = 7; +pub const ENOEXEC: c_int = 8; +pub const EBADF: c_int = 9; +pub const ECHILD: c_int = 10; +pub const EDEADLK: c_int = 11; +pub const ENOMEM: c_int = 12; +pub const EACCES: c_int = 13; +pub const EFAULT: c_int = 14; +pub const ENOTBLK: c_int = 15; +pub const EBUSY: c_int = 16; +pub const EEXIST: c_int = 17; +pub const EXDEV: c_int = 18; +pub const ENODEV: c_int = 19; +pub const ENOTDIR: c_int = 20; +pub const EISDIR: c_int = 21; +pub const EINVAL: c_int = 22; +pub const ENFILE: c_int = 23; +pub const EMFILE: c_int = 24; +pub const ENOTTY: c_int = 25; +pub const ETXTBSY: c_int = 26; +pub const EFBIG: c_int = 27; +pub const ENOSPC: c_int = 28; +pub const ESPIPE: c_int = 29; +pub const EROFS: c_int = 30; +pub const EMLINK: c_int = 31; +pub const EPIPE: c_int = 32; +pub const EDOM: c_int = 33; +pub const ERANGE: c_int = 34; +pub const EAGAIN: c_int = 35; +pub const EWOULDBLOCK: c_int = EAGAIN; +pub const EINPROGRESS: c_int = 36; +pub const EALREADY: c_int = 37; +pub const ENOTSOCK: c_int = 38; +pub const EDESTADDRREQ: c_int = 39; +pub const EMSGSIZE: c_int = 40; +pub const EPROTOTYPE: c_int = 41; +pub const ENOPROTOOPT: c_int = 42; +pub const EPROTONOSUPPORT: c_int = 43; +pub const ESOCKTNOSUPPORT: c_int = 44; +pub const ENOTSUP: c_int = 45; +pub const EPFNOSUPPORT: c_int = 46; +pub const EAFNOSUPPORT: c_int = 47; +pub const EADDRINUSE: c_int = 48; +pub const EADDRNOTAVAIL: c_int = 49; +pub const ENETDOWN: c_int = 50; +pub const ENETUNREACH: c_int = 51; +pub const ENETRESET: c_int = 52; +pub const ECONNABORTED: c_int = 53; +pub const ECONNRESET: c_int = 54; +pub const ENOBUFS: c_int = 55; +pub const EISCONN: c_int = 56; +pub const ENOTCONN: c_int = 57; +pub const ESHUTDOWN: c_int = 58; +pub const ETOOMANYREFS: c_int = 59; +pub const ETIMEDOUT: c_int = 60; +pub const ECONNREFUSED: c_int = 61; +pub const ELOOP: c_int = 62; +pub const ENAMETOOLONG: c_int = 63; +pub const EHOSTDOWN: c_int = 64; +pub const EHOSTUNREACH: c_int = 65; +pub const ENOTEMPTY: c_int = 66; +pub const EPROCLIM: c_int = 67; +pub const EUSERS: c_int = 68; +pub const EDQUOT: c_int = 69; +pub const ESTALE: c_int = 70; +pub const EREMOTE: c_int = 71; +pub const EBADRPC: c_int = 72; +pub const ERPCMISMATCH: c_int = 73; +pub const EPROGUNAVAIL: c_int = 74; +pub const EPROGMISMATCH: c_int = 75; +pub const EPROCUNAVAIL: c_int = 76; +pub const ENOLCK: c_int = 77; +pub const ENOSYS: c_int = 78; +pub const EFTYPE: c_int = 79; +pub const EAUTH: c_int = 80; +pub const ENEEDAUTH: c_int = 81; +pub const EPWROFF: c_int = 82; +pub const EDEVERR: c_int = 83; +pub const EOVERFLOW: c_int = 84; +pub const EBADEXEC: c_int = 85; +pub const EBADARCH: c_int = 86; +pub const ESHLIBVERS: c_int = 87; +pub const EBADMACHO: c_int = 88; +pub const ECANCELED: c_int = 89; +pub const EIDRM: c_int = 90; +pub const ENOMSG: c_int = 91; +pub const EILSEQ: c_int = 92; +pub const ENOATTR: c_int = 93; +pub const EBADMSG: c_int = 94; +pub const EMULTIHOP: c_int = 95; +pub const ENODATA: c_int = 96; +pub const ENOLINK: c_int = 97; +pub const ENOSR: c_int = 98; +pub const ENOSTR: c_int = 99; +pub const EPROTO: c_int = 100; +pub const ETIME: c_int = 101; +pub const EOPNOTSUPP: c_int = 102; +pub const ENOPOLICY: c_int = 103; +pub const ENOTRECOVERABLE: c_int = 104; +pub const EOWNERDEAD: c_int = 105; +pub const EQFULL: c_int = 106; +pub const ELAST: c_int = 106; + +pub const EAI_AGAIN: c_int = 2; +pub const EAI_BADFLAGS: c_int = 3; +pub const EAI_FAIL: c_int = 4; +pub const EAI_FAMILY: c_int = 5; +pub const EAI_MEMORY: c_int = 6; +pub const EAI_NODATA: c_int = 7; +pub const EAI_NONAME: c_int = 8; +pub const EAI_SERVICE: c_int = 9; +pub const EAI_SOCKTYPE: c_int = 10; +pub const EAI_SYSTEM: c_int = 11; +pub const EAI_OVERFLOW: c_int = 14; + +pub const F_DUPFD: c_int = 0; +pub const F_DUPFD_CLOEXEC: c_int = 67; +pub const F_GETFD: c_int = 1; +pub const F_SETFD: c_int = 2; +pub const F_GETFL: c_int = 3; +pub const F_SETFL: c_int = 4; +pub const F_PREALLOCATE: c_int = 42; +pub const F_RDADVISE: c_int = 44; +pub const F_RDAHEAD: c_int = 45; +pub const F_NOCACHE: c_int = 48; +pub const F_LOG2PHYS: c_int = 49; +pub const F_GETPATH: c_int = 50; +pub const F_FULLFSYNC: c_int = 51; +pub const F_FREEZE_FS: c_int = 53; +pub const F_THAW_FS: c_int = 54; +pub const F_GLOBAL_NOCACHE: c_int = 55; +pub const F_NODIRECT: c_int = 62; +pub const F_LOG2PHYS_EXT: c_int = 65; +pub const F_BARRIERFSYNC: c_int = 85; +// See https://github.com/apple/darwin-xnu/blob/main/bsd/sys/fcntl.h +pub const F_OFD_SETLK: c_int = 90; /* Acquire or release open file description lock */ +pub const F_OFD_SETLKW: c_int = 91; /* (as F_OFD_SETLK but blocking if conflicting lock) */ +pub const F_OFD_GETLK: c_int = 92; /* Examine OFD lock */ +pub const F_PUNCHHOLE: c_int = 99; +pub const F_TRIM_ACTIVE_FILE: c_int = 100; +pub const F_SPECULATIVE_READ: c_int = 101; +pub const F_GETPATH_NOFIRMLINK: c_int = 102; +pub const F_TRANSFEREXTENTS: c_int = 110; + +pub const F_ALLOCATECONTIG: c_uint = 0x02; +pub const F_ALLOCATEALL: c_uint = 0x04; +pub const F_ALLOCATEPERSIST: c_uint = 0x08; + +pub const F_PEOFPOSMODE: c_int = 3; +pub const F_VOLPOSMODE: c_int = 4; + +pub const AT_FDCWD: c_int = -2; +pub const AT_EACCESS: c_int = 0x0010; +pub const AT_SYMLINK_NOFOLLOW: c_int = 0x0020; +pub const AT_SYMLINK_FOLLOW: c_int = 0x0040; +pub const AT_REMOVEDIR: c_int = 0x0080; + +pub const TIOCMODG: c_ulong = 0x40047403; +pub const TIOCMODS: c_ulong = 0x80047404; +pub const TIOCM_LE: c_int = 0x1; +pub const TIOCM_DTR: c_int = 0x2; +pub const TIOCM_RTS: c_int = 0x4; +pub const TIOCM_ST: c_int = 0x8; +pub const TIOCM_SR: c_int = 0x10; +pub const TIOCM_CTS: c_int = 0x20; +pub const TIOCM_CAR: c_int = 0x40; +pub const TIOCM_CD: c_int = 0x40; +pub const TIOCM_RNG: c_int = 0x80; +pub const TIOCM_RI: c_int = 0x80; +pub const TIOCM_DSR: c_int = 0x100; +pub const TIOCEXCL: c_int = 0x2000740d; +pub const TIOCNXCL: c_int = 0x2000740e; +pub const TIOCFLUSH: c_ulong = 0x80047410; +pub const TIOCGETD: c_ulong = 0x4004741a; +pub const TIOCSETD: c_ulong = 0x8004741b; +pub const TIOCIXON: c_uint = 0x20007481; +pub const TIOCIXOFF: c_uint = 0x20007480; +pub const TIOCSDTR: c_uint = 0x20007479; +pub const TIOCCDTR: c_uint = 0x20007478; +pub const TIOCGPGRP: c_ulong = 0x40047477; +pub const TIOCSPGRP: c_ulong = 0x80047476; +pub const TIOCOUTQ: c_ulong = 0x40047473; +pub const TIOCSTI: c_ulong = 0x80017472; +pub const TIOCNOTTY: c_uint = 0x20007471; +pub const TIOCPKT: c_ulong = 0x80047470; +pub const TIOCPKT_DATA: c_int = 0x0; +pub const TIOCPKT_FLUSHREAD: c_int = 0x1; +pub const TIOCPKT_FLUSHWRITE: c_int = 0x2; +pub const TIOCPKT_STOP: c_int = 0x4; +pub const TIOCPKT_START: c_int = 0x8; +pub const TIOCPKT_NOSTOP: c_int = 0x10; +pub const TIOCPKT_DOSTOP: c_int = 0x20; +pub const TIOCPKT_IOCTL: c_int = 0x40; +pub const TIOCSTOP: c_uint = 0x2000746f; +pub const TIOCSTART: c_uint = 0x2000746e; +pub const TIOCMSET: c_ulong = 0x8004746d; +pub const TIOCMBIS: c_ulong = 0x8004746c; +pub const TIOCMBIC: c_ulong = 0x8004746b; +pub const TIOCMGET: c_ulong = 0x4004746a; +#[deprecated(since = "0.2.178", note = "Removed in MacOSX 12.0.1")] +pub const TIOCREMOTE: c_ulong = 0x80047469; +pub const TIOCGWINSZ: c_ulong = 0x40087468; +pub const TIOCSWINSZ: c_ulong = 0x80087467; +pub const TIOCUCNTL: c_ulong = 0x80047466; +pub const TIOCSTAT: c_uint = 0x20007465; +pub const TIOCSCONS: c_uint = 0x20007463; +pub const TIOCCONS: c_ulong = 0x80047462; +pub const TIOCSCTTY: c_uint = 0x20007461; +pub const TIOCEXT: c_ulong = 0x80047460; +pub const TIOCSIG: c_uint = 0x2000745f; +pub const TIOCDRAIN: c_uint = 0x2000745e; +pub const TIOCMSDTRWAIT: c_ulong = 0x8004745b; +pub const TIOCMGDTRWAIT: c_ulong = 0x4004745a; +pub const TIOCSDRAINWAIT: c_ulong = 0x80047457; +pub const TIOCGDRAINWAIT: c_ulong = 0x40047456; +pub const TIOCDSIMICROCODE: c_uint = 0x20007455; +pub const TIOCPTYGRANT: c_uint = 0x20007454; +pub const TIOCPTYGNAME: c_uint = 0x40807453; +pub const TIOCPTYUNLK: c_uint = 0x20007452; +pub const TIOCGETA: c_ulong = 0x40487413; +pub const TIOCSETA: c_ulong = 0x80487414; +pub const TIOCSETAW: c_ulong = 0x80487415; +pub const TIOCSETAF: c_ulong = 0x80487416; + +pub const BIOCGRSIG: c_ulong = 0x40044272; +pub const BIOCSRSIG: c_ulong = 0x80044273; +pub const BIOCSDLT: c_ulong = 0x80044278; +pub const BIOCGSEESENT: c_ulong = 0x40044276; +pub const BIOCSSEESENT: c_ulong = 0x80044277; +pub const BIOCGDLTLIST: c_ulong = 0xc00c4279; + +pub const FIODTYPE: c_ulong = 0x4004667a; + +pub const B0: speed_t = 0; +pub const B50: speed_t = 50; +pub const B75: speed_t = 75; +pub const B110: speed_t = 110; +pub const B134: speed_t = 134; +pub const B150: speed_t = 150; +pub const B200: speed_t = 200; +pub const B300: speed_t = 300; +pub const B600: speed_t = 600; +pub const B1200: speed_t = 1200; +pub const B1800: speed_t = 1800; +pub const B2400: speed_t = 2400; +pub const B4800: speed_t = 4800; +pub const B9600: speed_t = 9600; +pub const B19200: speed_t = 19200; +pub const B38400: speed_t = 38400; +pub const B7200: speed_t = 7200; +pub const B14400: speed_t = 14400; +pub const B28800: speed_t = 28800; +pub const B57600: speed_t = 57600; +pub const B76800: speed_t = 76800; +pub const B115200: speed_t = 115200; +pub const B230400: speed_t = 230400; +pub const EXTA: speed_t = 19200; +pub const EXTB: speed_t = 38400; + +pub const SIGTRAP: c_int = 5; + +pub const GLOB_APPEND: c_int = 0x0001; +pub const GLOB_DOOFFS: c_int = 0x0002; +pub const GLOB_ERR: c_int = 0x0004; +pub const GLOB_MARK: c_int = 0x0008; +pub const GLOB_NOCHECK: c_int = 0x0010; +pub const GLOB_NOSORT: c_int = 0x0020; +pub const GLOB_NOESCAPE: c_int = 0x2000; + +pub const GLOB_NOSPACE: c_int = -1; +pub const GLOB_ABORTED: c_int = -2; +pub const GLOB_NOMATCH: c_int = -3; + +pub const POSIX_MADV_NORMAL: c_int = 0; +pub const POSIX_MADV_RANDOM: c_int = 1; +pub const POSIX_MADV_SEQUENTIAL: c_int = 2; +pub const POSIX_MADV_WILLNEED: c_int = 3; +pub const POSIX_MADV_DONTNEED: c_int = 4; + +pub const _SC_IOV_MAX: c_int = 56; +pub const _SC_GETGR_R_SIZE_MAX: c_int = 70; +pub const _SC_GETPW_R_SIZE_MAX: c_int = 71; +pub const _SC_LOGIN_NAME_MAX: c_int = 73; +pub const _SC_MQ_PRIO_MAX: c_int = 75; +pub const _SC_THREAD_ATTR_STACKADDR: c_int = 82; +pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 83; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 85; +pub const _SC_THREAD_KEYS_MAX: c_int = 86; +pub const _SC_THREAD_PRIO_INHERIT: c_int = 87; +pub const _SC_THREAD_PRIO_PROTECT: c_int = 88; +pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 89; +pub const _SC_THREAD_PROCESS_SHARED: c_int = 90; +pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 91; +pub const _SC_THREAD_STACK_MIN: c_int = 93; +pub const _SC_THREAD_THREADS_MAX: c_int = 94; +pub const _SC_THREADS: c_int = 96; +pub const _SC_TTY_NAME_MAX: c_int = 101; +pub const _SC_ATEXIT_MAX: c_int = 107; +pub const _SC_XOPEN_CRYPT: c_int = 108; +pub const _SC_XOPEN_ENH_I18N: c_int = 109; +pub const _SC_XOPEN_LEGACY: c_int = 110; +pub const _SC_XOPEN_REALTIME: c_int = 111; +pub const _SC_XOPEN_REALTIME_THREADS: c_int = 112; +pub const _SC_XOPEN_SHM: c_int = 113; +pub const _SC_XOPEN_UNIX: c_int = 115; +pub const _SC_XOPEN_VERSION: c_int = 116; +pub const _SC_XOPEN_XCU_VERSION: c_int = 121; +pub const _SC_PHYS_PAGES: c_int = 200; + +#[cfg(target_arch = "aarch64")] +pub const PTHREAD_STACK_MIN: size_t = 16384; +#[cfg(not(target_arch = "aarch64"))] +pub const PTHREAD_STACK_MIN: size_t = 8192; + +pub const RLIMIT_CPU: c_int = 0; +pub const RLIMIT_FSIZE: c_int = 1; +pub const RLIMIT_DATA: c_int = 2; +pub const RLIMIT_STACK: c_int = 3; +pub const RLIMIT_CORE: c_int = 4; +pub const RLIMIT_AS: c_int = 5; +pub const RLIMIT_RSS: c_int = RLIMIT_AS; +pub const RLIMIT_MEMLOCK: c_int = 6; +pub const RLIMIT_NPROC: c_int = 7; +pub const RLIMIT_NOFILE: c_int = 8; +#[deprecated(since = "0.2.64", note = "Not stable across OS versions")] +pub const RLIM_NLIMITS: c_int = 9; +pub const _RLIMIT_POSIX_FLAG: c_int = 0x1000; + +pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff; + +pub const RUSAGE_SELF: c_int = 0; +pub const RUSAGE_CHILDREN: c_int = -1; + +pub const MADV_NORMAL: c_int = 0; +pub const MADV_RANDOM: c_int = 1; +pub const MADV_SEQUENTIAL: c_int = 2; +pub const MADV_WILLNEED: c_int = 3; +pub const MADV_DONTNEED: c_int = 4; +pub const MADV_FREE: c_int = 5; +pub const MADV_ZERO_WIRED_PAGES: c_int = 6; +pub const MADV_FREE_REUSABLE: c_int = 7; +pub const MADV_FREE_REUSE: c_int = 8; +pub const MADV_CAN_REUSE: c_int = 9; +pub const MADV_ZERO: c_int = 11; + +pub const MINCORE_INCORE: c_int = 0x1; +pub const MINCORE_REFERENCED: c_int = 0x2; +pub const MINCORE_MODIFIED: c_int = 0x4; +pub const MINCORE_REFERENCED_OTHER: c_int = 0x8; +pub const MINCORE_MODIFIED_OTHER: c_int = 0x10; + +pub const CTLIOCGINFO: c_ulong = 0xc0644e03; + +// +// sys/netinet/in.h +// Protocols (RFC 1700) +// NOTE: These are in addition to the constants defined in src/unix/mod.rs + +// IPPROTO_IP defined in src/unix/mod.rs +/// IP6 hop-by-hop options +pub const IPPROTO_HOPOPTS: c_int = 0; +// IPPROTO_ICMP defined in src/unix/mod.rs +/// group mgmt protocol +pub const IPPROTO_IGMP: c_int = 2; +/// gateway2 (deprecated) +pub const IPPROTO_GGP: c_int = 3; +/// for compatibility +pub const IPPROTO_IPIP: c_int = 4; +// IPPROTO_TCP defined in src/unix/mod.rs +/// Stream protocol II. +pub const IPPROTO_ST: c_int = 7; +/// exterior gateway protocol +pub const IPPROTO_EGP: c_int = 8; +/// private interior gateway +pub const IPPROTO_PIGP: c_int = 9; +/// BBN RCC Monitoring +pub const IPPROTO_RCCMON: c_int = 10; +/// network voice protocol +pub const IPPROTO_NVPII: c_int = 11; +/// pup +pub const IPPROTO_PUP: c_int = 12; +/// Argus +pub const IPPROTO_ARGUS: c_int = 13; +/// EMCON +pub const IPPROTO_EMCON: c_int = 14; +/// Cross Net Debugger +pub const IPPROTO_XNET: c_int = 15; +/// Chaos +pub const IPPROTO_CHAOS: c_int = 16; +// IPPROTO_UDP defined in src/unix/mod.rs +/// Multiplexing +pub const IPPROTO_MUX: c_int = 18; +/// DCN Measurement Subsystems +pub const IPPROTO_MEAS: c_int = 19; +/// Host Monitoring +pub const IPPROTO_HMP: c_int = 20; +/// Packet Radio Measurement +pub const IPPROTO_PRM: c_int = 21; +/// xns idp +pub const IPPROTO_IDP: c_int = 22; +/// Trunk-1 +pub const IPPROTO_TRUNK1: c_int = 23; +/// Trunk-2 +pub const IPPROTO_TRUNK2: c_int = 24; +/// Leaf-1 +pub const IPPROTO_LEAF1: c_int = 25; +/// Leaf-2 +pub const IPPROTO_LEAF2: c_int = 26; +/// Reliable Data +pub const IPPROTO_RDP: c_int = 27; +/// Reliable Transaction +pub const IPPROTO_IRTP: c_int = 28; +/// tp-4 w/ class negotiation +pub const IPPROTO_TP: c_int = 29; +/// Bulk Data Transfer +pub const IPPROTO_BLT: c_int = 30; +/// Network Services +pub const IPPROTO_NSP: c_int = 31; +/// Merit Internodal +pub const IPPROTO_INP: c_int = 32; +/// Sequential Exchange +pub const IPPROTO_SEP: c_int = 33; +/// Third Party Connect +pub const IPPROTO_3PC: c_int = 34; +/// InterDomain Policy Routing +pub const IPPROTO_IDPR: c_int = 35; +/// XTP +pub const IPPROTO_XTP: c_int = 36; +/// Datagram Delivery +pub const IPPROTO_DDP: c_int = 37; +/// Control Message Transport +pub const IPPROTO_CMTP: c_int = 38; +/// TP++ Transport +pub const IPPROTO_TPXX: c_int = 39; +/// IL transport protocol +pub const IPPROTO_IL: c_int = 40; +// IPPROTO_IPV6 defined in src/unix/mod.rs +/// Source Demand Routing +pub const IPPROTO_SDRP: c_int = 42; +/// IP6 routing header +pub const IPPROTO_ROUTING: c_int = 43; +/// IP6 fragmentation header +pub const IPPROTO_FRAGMENT: c_int = 44; +/// InterDomain Routing +pub const IPPROTO_IDRP: c_int = 45; +/// resource reservation +pub const IPPROTO_RSVP: c_int = 46; +/// General Routing Encap. +pub const IPPROTO_GRE: c_int = 47; +/// Mobile Host Routing +pub const IPPROTO_MHRP: c_int = 48; +/// BHA +pub const IPPROTO_BHA: c_int = 49; +/// IP6 Encap Sec. Payload +pub const IPPROTO_ESP: c_int = 50; +/// IP6 Auth Header +pub const IPPROTO_AH: c_int = 51; +/// Integ. Net Layer Security +pub const IPPROTO_INLSP: c_int = 52; +/// IP with encryption +pub const IPPROTO_SWIPE: c_int = 53; +/// Next Hop Resolution +pub const IPPROTO_NHRP: c_int = 54; +/* 55-57: Unassigned */ +// IPPROTO_ICMPV6 defined in src/unix/mod.rs +/// IP6 no next header +pub const IPPROTO_NONE: c_int = 59; +/// IP6 destination option +pub const IPPROTO_DSTOPTS: c_int = 60; +/// any host internal protocol +pub const IPPROTO_AHIP: c_int = 61; +/// CFTP +pub const IPPROTO_CFTP: c_int = 62; +/// "hello" routing protocol +pub const IPPROTO_HELLO: c_int = 63; +/// SATNET/Backroom EXPAK +pub const IPPROTO_SATEXPAK: c_int = 64; +/// Kryptolan +pub const IPPROTO_KRYPTOLAN: c_int = 65; +/// Remote Virtual Disk +pub const IPPROTO_RVD: c_int = 66; +/// Pluribus Packet Core +pub const IPPROTO_IPPC: c_int = 67; +/// Any distributed FS +pub const IPPROTO_ADFS: c_int = 68; +/// Satnet Monitoring +pub const IPPROTO_SATMON: c_int = 69; +/// VISA Protocol +pub const IPPROTO_VISA: c_int = 70; +/// Packet Core Utility +pub const IPPROTO_IPCV: c_int = 71; +/// Comp. Prot. Net. Executive +pub const IPPROTO_CPNX: c_int = 72; +/// Comp. Prot. HeartBeat +pub const IPPROTO_CPHB: c_int = 73; +/// Wang Span Network +pub const IPPROTO_WSN: c_int = 74; +/// Packet Video Protocol +pub const IPPROTO_PVP: c_int = 75; +/// BackRoom SATNET Monitoring +pub const IPPROTO_BRSATMON: c_int = 76; +/// Sun net disk proto (temp.) +pub const IPPROTO_ND: c_int = 77; +/// WIDEBAND Monitoring +pub const IPPROTO_WBMON: c_int = 78; +/// WIDEBAND EXPAK +pub const IPPROTO_WBEXPAK: c_int = 79; +/// ISO cnlp +pub const IPPROTO_EON: c_int = 80; +/// VMTP +pub const IPPROTO_VMTP: c_int = 81; +/// Secure VMTP +pub const IPPROTO_SVMTP: c_int = 82; +/// Banyon VINES +pub const IPPROTO_VINES: c_int = 83; +/// TTP +pub const IPPROTO_TTP: c_int = 84; +/// NSFNET-IGP +pub const IPPROTO_IGP: c_int = 85; +/// dissimilar gateway prot. +pub const IPPROTO_DGP: c_int = 86; +/// TCF +pub const IPPROTO_TCF: c_int = 87; +/// Cisco/GXS IGRP +pub const IPPROTO_IGRP: c_int = 88; +/// OSPFIGP +pub const IPPROTO_OSPFIGP: c_int = 89; +/// Strite RPC protocol +pub const IPPROTO_SRPC: c_int = 90; +/// Locus Address Resoloution +pub const IPPROTO_LARP: c_int = 91; +/// Multicast Transport +pub const IPPROTO_MTP: c_int = 92; +/// AX.25 Frames +pub const IPPROTO_AX25: c_int = 93; +/// IP encapsulated in IP +pub const IPPROTO_IPEIP: c_int = 94; +/// Mobile Int.ing control +pub const IPPROTO_MICP: c_int = 95; +/// Semaphore Comm. security +pub const IPPROTO_SCCSP: c_int = 96; +/// Ethernet IP encapsulation +pub const IPPROTO_ETHERIP: c_int = 97; +/// encapsulation header +pub const IPPROTO_ENCAP: c_int = 98; +/// any private encr. scheme +pub const IPPROTO_APES: c_int = 99; +/// GMTP +pub const IPPROTO_GMTP: c_int = 100; + +/* 101-254: Partly Unassigned */ +/// Protocol Independent Mcast +pub const IPPROTO_PIM: c_int = 103; +/// payload compression (IPComp) +pub const IPPROTO_IPCOMP: c_int = 108; +/// PGM +pub const IPPROTO_PGM: c_int = 113; +/// SCTP +pub const IPPROTO_SCTP: c_int = 132; + +/* 255: Reserved */ +/* BSD Private, local use, namespace incursion */ +/// divert pseudo-protocol +pub const IPPROTO_DIVERT: c_int = 254; +/// raw IP packet +pub const IPPROTO_RAW: c_int = 255; +pub const IPPROTO_MAX: c_int = 256; +/// last return value of *_input(), meaning "all job for this pkt is done". +pub const IPPROTO_DONE: c_int = 257; + +pub const AF_UNSPEC: c_int = 0; +pub const AF_LOCAL: c_int = 1; +pub const AF_UNIX: c_int = AF_LOCAL; +pub const AF_INET: c_int = 2; +pub const AF_IMPLINK: c_int = 3; +pub const AF_PUP: c_int = 4; +pub const AF_CHAOS: c_int = 5; +pub const AF_NS: c_int = 6; +pub const AF_ISO: c_int = 7; +pub const AF_OSI: c_int = AF_ISO; +pub const AF_ECMA: c_int = 8; +pub const AF_DATAKIT: c_int = 9; +pub const AF_CCITT: c_int = 10; +pub const AF_SNA: c_int = 11; +pub const AF_DECnet: c_int = 12; +pub const AF_DLI: c_int = 13; +pub const AF_LAT: c_int = 14; +pub const AF_HYLINK: c_int = 15; +pub const AF_APPLETALK: c_int = 16; +pub const AF_ROUTE: c_int = 17; +pub const AF_LINK: c_int = 18; +pub const pseudo_AF_XTP: c_int = 19; +pub const AF_COIP: c_int = 20; +pub const AF_CNT: c_int = 21; +pub const pseudo_AF_RTIP: c_int = 22; +pub const AF_IPX: c_int = 23; +pub const AF_SIP: c_int = 24; +pub const pseudo_AF_PIP: c_int = 25; +pub const AF_NDRV: c_int = 27; +pub const AF_ISDN: c_int = 28; +pub const AF_E164: c_int = AF_ISDN; +pub const pseudo_AF_KEY: c_int = 29; +pub const AF_INET6: c_int = 30; +pub const AF_NATM: c_int = 31; +pub const AF_SYSTEM: c_int = 32; +pub const AF_NETBIOS: c_int = 33; +pub const AF_PPP: c_int = 34; +pub const pseudo_AF_HDRCMPLT: c_int = 35; +pub const AF_IEEE80211: c_int = 37; +pub const AF_UTUN: c_int = 38; +pub const AF_VSOCK: c_int = 40; +pub const AF_SYS_CONTROL: c_int = 2; + +pub const SYSPROTO_EVENT: c_int = 1; +pub const SYSPROTO_CONTROL: c_int = 2; + +pub const PF_UNSPEC: c_int = AF_UNSPEC; +pub const PF_LOCAL: c_int = AF_LOCAL; +pub const PF_UNIX: c_int = PF_LOCAL; +pub const PF_INET: c_int = AF_INET; +pub const PF_IMPLINK: c_int = AF_IMPLINK; +pub const PF_PUP: c_int = AF_PUP; +pub const PF_CHAOS: c_int = AF_CHAOS; +pub const PF_NS: c_int = AF_NS; +pub const PF_ISO: c_int = AF_ISO; +pub const PF_OSI: c_int = AF_ISO; +pub const PF_ECMA: c_int = AF_ECMA; +pub const PF_DATAKIT: c_int = AF_DATAKIT; +pub const PF_CCITT: c_int = AF_CCITT; +pub const PF_SNA: c_int = AF_SNA; +pub const PF_DECnet: c_int = AF_DECnet; +pub const PF_DLI: c_int = AF_DLI; +pub const PF_LAT: c_int = AF_LAT; +pub const PF_HYLINK: c_int = AF_HYLINK; +pub const PF_APPLETALK: c_int = AF_APPLETALK; +pub const PF_ROUTE: c_int = AF_ROUTE; +pub const PF_LINK: c_int = AF_LINK; +pub const PF_XTP: c_int = pseudo_AF_XTP; +pub const PF_COIP: c_int = AF_COIP; +pub const PF_CNT: c_int = AF_CNT; +pub const PF_SIP: c_int = AF_SIP; +pub const PF_IPX: c_int = AF_IPX; +pub const PF_RTIP: c_int = pseudo_AF_RTIP; +pub const PF_PIP: c_int = pseudo_AF_PIP; +pub const PF_NDRV: c_int = AF_NDRV; +pub const PF_ISDN: c_int = AF_ISDN; +pub const PF_KEY: c_int = pseudo_AF_KEY; +pub const PF_INET6: c_int = AF_INET6; +pub const PF_NATM: c_int = AF_NATM; +pub const PF_SYSTEM: c_int = AF_SYSTEM; +pub const PF_NETBIOS: c_int = AF_NETBIOS; +pub const PF_PPP: c_int = AF_PPP; +pub const PF_VSOCK: c_int = AF_VSOCK; + +pub const NET_RT_DUMP: c_int = 1; +pub const NET_RT_FLAGS: c_int = 2; +pub const NET_RT_IFLIST: c_int = 3; + +pub const SOMAXCONN: c_int = 128; + +pub const SOCK_MAXADDRLEN: c_int = 255; + +pub const SOCK_STREAM: c_int = 1; +pub const SOCK_DGRAM: c_int = 2; +pub const SOCK_RAW: c_int = 3; +pub const SOCK_RDM: c_int = 4; +pub const SOCK_SEQPACKET: c_int = 5; +pub const IP_TTL: c_int = 4; +pub const IP_HDRINCL: c_int = 2; +pub const IP_RECVDSTADDR: c_int = 7; +pub const IP_ADD_MEMBERSHIP: c_int = 12; +pub const IP_DROP_MEMBERSHIP: c_int = 13; +pub const IP_RECVIF: c_int = 20; +pub const IP_RECVTTL: c_int = 24; +pub const IP_BOUND_IF: c_int = 25; +pub const IP_PKTINFO: c_int = 26; +pub const IP_RECVTOS: c_int = 27; +pub const IP_DONTFRAG: c_int = 28; +pub const IPV6_JOIN_GROUP: c_int = 12; +pub const IPV6_LEAVE_GROUP: c_int = 13; +pub const IPV6_CHECKSUM: c_int = 26; +pub const IPV6_RECVTCLASS: c_int = 35; +pub const IPV6_TCLASS: c_int = 36; +pub const IPV6_RECVHOPLIMIT: c_int = 37; +pub const IPV6_PKTINFO: c_int = 46; +pub const IPV6_HOPLIMIT: c_int = 47; +pub const IPV6_RECVPKTINFO: c_int = 61; +pub const IP_ADD_SOURCE_MEMBERSHIP: c_int = 70; +pub const IP_DROP_SOURCE_MEMBERSHIP: c_int = 71; +pub const IP_BLOCK_SOURCE: c_int = 72; +pub const IP_UNBLOCK_SOURCE: c_int = 73; +pub const IPV6_BOUND_IF: c_int = 125; + +pub const TCP_NOPUSH: c_int = 4; +pub const TCP_NOOPT: c_int = 8; +pub const TCP_KEEPALIVE: c_int = 0x10; +pub const TCP_KEEPINTVL: c_int = 0x101; +pub const TCP_KEEPCNT: c_int = 0x102; +/// Enable/Disable TCP Fastopen on this socket +pub const TCP_FASTOPEN: c_int = 0x105; +pub const TCP_CONNECTION_INFO: c_int = 0x106; + +pub const SOL_LOCAL: c_int = 0; + +/// Retrieve peer credentials. +pub const LOCAL_PEERCRED: c_int = 0x001; +/// Retrieve peer PID. +pub const LOCAL_PEERPID: c_int = 0x002; +/// Retrieve effective peer PID. +pub const LOCAL_PEEREPID: c_int = 0x003; +/// Retrieve peer UUID. +pub const LOCAL_PEERUUID: c_int = 0x004; +/// Retrieve effective peer UUID. +pub const LOCAL_PEEREUUID: c_int = 0x005; +/// Retrieve peer audit token. +pub const LOCAL_PEERTOKEN: c_int = 0x006; + +pub const SOL_SOCKET: c_int = 0xffff; + +pub const SO_DEBUG: c_int = 0x01; +pub const SO_ACCEPTCONN: c_int = 0x0002; +pub const SO_REUSEADDR: c_int = 0x0004; +pub const SO_KEEPALIVE: c_int = 0x0008; +pub const SO_DONTROUTE: c_int = 0x0010; +pub const SO_BROADCAST: c_int = 0x0020; +pub const SO_USELOOPBACK: c_int = 0x0040; +pub const SO_LINGER: c_int = 0x0080; +pub const SO_OOBINLINE: c_int = 0x0100; +pub const SO_REUSEPORT: c_int = 0x0200; +pub const SO_TIMESTAMP: c_int = 0x0400; +pub const SO_TIMESTAMP_MONOTONIC: c_int = 0x0800; +pub const SO_DONTTRUNC: c_int = 0x2000; +pub const SO_WANTMORE: c_int = 0x4000; +pub const SO_WANTOOBFLAG: c_int = 0x8000; +pub const SO_SNDBUF: c_int = 0x1001; +pub const SO_RCVBUF: c_int = 0x1002; +pub const SO_SNDLOWAT: c_int = 0x1003; +pub const SO_RCVLOWAT: c_int = 0x1004; +pub const SO_SNDTIMEO: c_int = 0x1005; +pub const SO_RCVTIMEO: c_int = 0x1006; +pub const SO_ERROR: c_int = 0x1007; +pub const SO_TYPE: c_int = 0x1008; +pub const SO_LABEL: c_int = 0x1010; +pub const SO_PEERLABEL: c_int = 0x1011; +pub const SO_NREAD: c_int = 0x1020; +pub const SO_NKE: c_int = 0x1021; +pub const SO_NOSIGPIPE: c_int = 0x1022; +pub const SO_NOADDRERR: c_int = 0x1023; +pub const SO_NWRITE: c_int = 0x1024; +pub const SO_REUSESHAREUID: c_int = 0x1025; +pub const SO_NOTIFYCONFLICT: c_int = 0x1026; +pub const SO_LINGER_SEC: c_int = 0x1080; +pub const SO_RANDOMPORT: c_int = 0x1082; +pub const SO_NP_EXTENSIONS: c_int = 0x1083; + +pub const MSG_OOB: c_int = 0x1; +pub const MSG_PEEK: c_int = 0x2; +pub const MSG_DONTROUTE: c_int = 0x4; +pub const MSG_EOR: c_int = 0x8; +pub const MSG_TRUNC: c_int = 0x10; +pub const MSG_CTRUNC: c_int = 0x20; +pub const MSG_WAITALL: c_int = 0x40; +pub const MSG_DONTWAIT: c_int = 0x80; +pub const MSG_EOF: c_int = 0x100; +pub const MSG_FLUSH: c_int = 0x400; +pub const MSG_HOLD: c_int = 0x800; +pub const MSG_SEND: c_int = 0x1000; +pub const MSG_HAVEMORE: c_int = 0x2000; +pub const MSG_RCVMORE: c_int = 0x4000; +pub const MSG_NEEDSA: c_int = 0x10000; +pub const MSG_NOSIGNAL: c_int = 0x80000; + +pub const SCM_TIMESTAMP: c_int = 0x02; +pub const SCM_CREDS: c_int = 0x03; + +// https://github.com/aosm/xnu/blob/HEAD/bsd/net/if.h#L140-L156 +pub const IFF_UP: c_int = 0x1; // interface is up +pub const IFF_BROADCAST: c_int = 0x2; // broadcast address valid +pub const IFF_DEBUG: c_int = 0x4; // turn on debugging +pub const IFF_LOOPBACK: c_int = 0x8; // is a loopback net +pub const IFF_POINTOPOINT: c_int = 0x10; // interface is point-to-point link +pub const IFF_NOTRAILERS: c_int = 0x20; // obsolete: avoid use of trailers +pub const IFF_RUNNING: c_int = 0x40; // resources allocated +pub const IFF_NOARP: c_int = 0x80; // no address resolution protocol +pub const IFF_PROMISC: c_int = 0x100; // receive all packets +pub const IFF_ALLMULTI: c_int = 0x200; // receive all multicast packets +pub const IFF_OACTIVE: c_int = 0x400; // transmission in progress +pub const IFF_SIMPLEX: c_int = 0x800; // can't hear own transmissions +pub const IFF_LINK0: c_int = 0x1000; // per link layer defined bit +pub const IFF_LINK1: c_int = 0x2000; // per link layer defined bit +pub const IFF_LINK2: c_int = 0x4000; // per link layer defined bit +pub const IFF_ALTPHYS: c_int = IFF_LINK2; // use alternate physical connection +pub const IFF_MULTICAST: c_int = 0x8000; // supports multicast + +pub const SCOPE6_ID_MAX: size_t = 16; + +pub const SHUT_RD: c_int = 0; +pub const SHUT_WR: c_int = 1; +pub const SHUT_RDWR: c_int = 2; + +pub const SAE_ASSOCID_ANY: crate::sae_associd_t = 0; +/// ((sae_associd_t)(-1ULL)) +pub const SAE_ASSOCID_ALL: crate::sae_associd_t = 0xffffffff; + +pub const SAE_CONNID_ANY: crate::sae_connid_t = 0; +/// ((sae_connid_t)(-1ULL)) +pub const SAE_CONNID_ALL: crate::sae_connid_t = 0xffffffff; + +// connectx() flag parameters + +/// resume connect() on read/write +pub const CONNECT_RESUME_ON_READ_WRITE: c_uint = 0x1; +/// data is idempotent +pub const CONNECT_DATA_IDEMPOTENT: c_uint = 0x2; +/// data includes security that replaces the TFO-cookie +pub const CONNECT_DATA_AUTHENTICATED: c_uint = 0x4; + +pub const LOCK_SH: c_int = 1; +pub const LOCK_EX: c_int = 2; +pub const LOCK_NB: c_int = 4; +pub const LOCK_UN: c_int = 8; + +pub const MAP_COPY: c_int = 0x0002; +pub const MAP_RENAME: c_int = 0x0020; +pub const MAP_NORESERVE: c_int = 0x0040; +pub const MAP_NOEXTEND: c_int = 0x0100; +pub const MAP_HASSEMAPHORE: c_int = 0x0200; +pub const MAP_NOCACHE: c_int = 0x0400; +pub const MAP_JIT: c_int = 0x0800; + +pub const _SC_ARG_MAX: c_int = 1; +pub const _SC_CHILD_MAX: c_int = 2; +pub const _SC_CLK_TCK: c_int = 3; +pub const _SC_NGROUPS_MAX: c_int = 4; +pub const _SC_OPEN_MAX: c_int = 5; +pub const _SC_JOB_CONTROL: c_int = 6; +pub const _SC_SAVED_IDS: c_int = 7; +pub const _SC_VERSION: c_int = 8; +pub const _SC_BC_BASE_MAX: c_int = 9; +pub const _SC_BC_DIM_MAX: c_int = 10; +pub const _SC_BC_SCALE_MAX: c_int = 11; +pub const _SC_BC_STRING_MAX: c_int = 12; +pub const _SC_COLL_WEIGHTS_MAX: c_int = 13; +pub const _SC_EXPR_NEST_MAX: c_int = 14; +pub const _SC_LINE_MAX: c_int = 15; +pub const _SC_RE_DUP_MAX: c_int = 16; +pub const _SC_2_VERSION: c_int = 17; +pub const _SC_2_C_BIND: c_int = 18; +pub const _SC_2_C_DEV: c_int = 19; +pub const _SC_2_CHAR_TERM: c_int = 20; +pub const _SC_2_FORT_DEV: c_int = 21; +pub const _SC_2_FORT_RUN: c_int = 22; +pub const _SC_2_LOCALEDEF: c_int = 23; +pub const _SC_2_SW_DEV: c_int = 24; +pub const _SC_2_UPE: c_int = 25; +pub const _SC_STREAM_MAX: c_int = 26; +pub const _SC_TZNAME_MAX: c_int = 27; +pub const _SC_ASYNCHRONOUS_IO: c_int = 28; +pub const _SC_PAGESIZE: c_int = 29; +pub const _SC_MEMLOCK: c_int = 30; +pub const _SC_MEMLOCK_RANGE: c_int = 31; +pub const _SC_MEMORY_PROTECTION: c_int = 32; +pub const _SC_MESSAGE_PASSING: c_int = 33; +pub const _SC_PRIORITIZED_IO: c_int = 34; +pub const _SC_PRIORITY_SCHEDULING: c_int = 35; +pub const _SC_REALTIME_SIGNALS: c_int = 36; +pub const _SC_SEMAPHORES: c_int = 37; +pub const _SC_FSYNC: c_int = 38; +pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 39; +pub const _SC_SYNCHRONIZED_IO: c_int = 40; +pub const _SC_TIMERS: c_int = 41; +pub const _SC_AIO_LISTIO_MAX: c_int = 42; +pub const _SC_AIO_MAX: c_int = 43; +pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 44; +pub const _SC_DELAYTIMER_MAX: c_int = 45; +pub const _SC_MQ_OPEN_MAX: c_int = 46; +pub const _SC_MAPPED_FILES: c_int = 47; +pub const _SC_RTSIG_MAX: c_int = 48; +pub const _SC_SEM_NSEMS_MAX: c_int = 49; +pub const _SC_SEM_VALUE_MAX: c_int = 50; +pub const _SC_SIGQUEUE_MAX: c_int = 51; +pub const _SC_TIMER_MAX: c_int = 52; +pub const _SC_NPROCESSORS_CONF: c_int = 57; +pub const _SC_NPROCESSORS_ONLN: c_int = 58; +pub const _SC_2_PBS: c_int = 59; +pub const _SC_2_PBS_ACCOUNTING: c_int = 60; +pub const _SC_2_PBS_CHECKPOINT: c_int = 61; +pub const _SC_2_PBS_LOCATE: c_int = 62; +pub const _SC_2_PBS_MESSAGE: c_int = 63; +pub const _SC_2_PBS_TRACK: c_int = 64; +pub const _SC_ADVISORY_INFO: c_int = 65; +pub const _SC_BARRIERS: c_int = 66; +pub const _SC_CLOCK_SELECTION: c_int = 67; +pub const _SC_CPUTIME: c_int = 68; +pub const _SC_FILE_LOCKING: c_int = 69; +pub const _SC_HOST_NAME_MAX: c_int = 72; +pub const _SC_MONOTONIC_CLOCK: c_int = 74; +pub const _SC_READER_WRITER_LOCKS: c_int = 76; +pub const _SC_REGEXP: c_int = 77; +pub const _SC_SHELL: c_int = 78; +pub const _SC_SPAWN: c_int = 79; +pub const _SC_SPIN_LOCKS: c_int = 80; +pub const _SC_SPORADIC_SERVER: c_int = 81; +pub const _SC_THREAD_CPUTIME: c_int = 84; +pub const _SC_THREAD_SPORADIC_SERVER: c_int = 92; +pub const _SC_TIMEOUTS: c_int = 95; +pub const _SC_TRACE: c_int = 97; +pub const _SC_TRACE_EVENT_FILTER: c_int = 98; +pub const _SC_TRACE_INHERIT: c_int = 99; +pub const _SC_TRACE_LOG: c_int = 100; +pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 102; +pub const _SC_V6_ILP32_OFF32: c_int = 103; +pub const _SC_V6_ILP32_OFFBIG: c_int = 104; +pub const _SC_V6_LP64_OFF64: c_int = 105; +pub const _SC_V6_LPBIG_OFFBIG: c_int = 106; +pub const _SC_IPV6: c_int = 118; +pub const _SC_RAW_SOCKETS: c_int = 119; +pub const _SC_SYMLOOP_MAX: c_int = 120; +pub const _SC_PAGE_SIZE: c_int = _SC_PAGESIZE; +pub const _SC_XOPEN_STREAMS: c_int = 114; +pub const _SC_XBS5_ILP32_OFF32: c_int = 122; +pub const _SC_XBS5_ILP32_OFFBIG: c_int = 123; +pub const _SC_XBS5_LP64_OFF64: c_int = 124; +pub const _SC_XBS5_LPBIG_OFFBIG: c_int = 125; +pub const _SC_SS_REPL_MAX: c_int = 126; +pub const _SC_TRACE_EVENT_NAME_MAX: c_int = 127; +pub const _SC_TRACE_NAME_MAX: c_int = 128; +pub const _SC_TRACE_SYS_MAX: c_int = 129; +pub const _SC_TRACE_USER_EVENT_MAX: c_int = 130; +pub const _SC_PASS_MAX: c_int = 131; +// `confstr` keys (only the values guaranteed by `man confstr`). +pub const _CS_PATH: c_int = 1; +pub const _CS_DARWIN_USER_DIR: c_int = 65536; +pub const _CS_DARWIN_USER_TEMP_DIR: c_int = 65537; +pub const _CS_DARWIN_USER_CACHE_DIR: c_int = 65538; + +pub const OS_UNFAIR_LOCK_INIT: os_unfair_lock = os_unfair_lock { + _os_unfair_lock_opaque: 0, +}; + +pub const OS_LOG_TYPE_DEFAULT: crate::os_log_type_t = 0x00; +pub const OS_LOG_TYPE_INFO: crate::os_log_type_t = 0x01; +pub const OS_LOG_TYPE_DEBUG: crate::os_log_type_t = 0x02; +pub const OS_LOG_TYPE_ERROR: crate::os_log_type_t = 0x10; +pub const OS_LOG_TYPE_FAULT: crate::os_log_type_t = 0x11; + +pub const OS_SIGNPOST_EVENT: crate::os_signpost_type_t = 0x00; +pub const OS_SIGNPOST_INTERVAL_BEGIN: crate::os_signpost_type_t = 0x01; +pub const OS_SIGNPOST_INTERVAL_END: crate::os_signpost_type_t = 0x02; + +pub const MINSIGSTKSZ: size_t = 32768; +pub const SIGSTKSZ: size_t = 131072; + +pub const FD_SETSIZE: usize = 1024; + +pub const ST_NOSUID: c_ulong = 2; + +pub const EVFILT_READ: i16 = -1; +pub const EVFILT_WRITE: i16 = -2; +pub const EVFILT_AIO: i16 = -3; +pub const EVFILT_VNODE: i16 = -4; +pub const EVFILT_PROC: i16 = -5; +pub const EVFILT_SIGNAL: i16 = -6; +pub const EVFILT_TIMER: i16 = -7; +pub const EVFILT_MACHPORT: i16 = -8; +pub const EVFILT_FS: i16 = -9; +pub const EVFILT_USER: i16 = -10; +pub const EVFILT_VM: i16 = -12; + +pub const EV_ADD: u16 = 0x1; +pub const EV_DELETE: u16 = 0x2; +pub const EV_ENABLE: u16 = 0x4; +pub const EV_DISABLE: u16 = 0x8; +pub const EV_ONESHOT: u16 = 0x10; +pub const EV_CLEAR: u16 = 0x20; +pub const EV_RECEIPT: u16 = 0x40; +pub const EV_DISPATCH: u16 = 0x80; +pub const EV_FLAG0: u16 = 0x1000; +pub const EV_POLL: u16 = 0x1000; +pub const EV_FLAG1: u16 = 0x2000; +pub const EV_OOBAND: u16 = 0x2000; +pub const EV_ERROR: u16 = 0x4000; +pub const EV_EOF: u16 = 0x8000; +pub const EV_SYSFLAGS: u16 = 0xf000; + +pub const KEVENT_FLAG_NONE: c_uint = 0x000000; +pub const KEVENT_FLAG_IMMEDIATE: c_uint = 0x000001; +pub const KEVENT_FLAG_ERROR_EVENTS: c_uint = 0x000002; + +pub const NOTE_TRIGGER: u32 = 0x01000000; +pub const NOTE_FFNOP: u32 = 0x00000000; +pub const NOTE_FFAND: u32 = 0x40000000; +pub const NOTE_FFOR: u32 = 0x80000000; +pub const NOTE_FFCOPY: u32 = 0xc0000000; +pub const NOTE_FFCTRLMASK: u32 = 0xc0000000; +pub const NOTE_FFLAGSMASK: u32 = 0x00ffffff; +pub const NOTE_LOWAT: u32 = 0x00000001; +pub const NOTE_DELETE: u32 = 0x00000001; +pub const NOTE_WRITE: u32 = 0x00000002; +pub const NOTE_EXTEND: u32 = 0x00000004; +pub const NOTE_ATTRIB: u32 = 0x00000008; +pub const NOTE_LINK: u32 = 0x00000010; +pub const NOTE_RENAME: u32 = 0x00000020; +pub const NOTE_REVOKE: u32 = 0x00000040; +pub const NOTE_NONE: u32 = 0x00000080; +pub const NOTE_EXIT: u32 = 0x80000000; +pub const NOTE_FORK: u32 = 0x40000000; +pub const NOTE_EXEC: u32 = 0x20000000; +#[doc(hidden)] +#[deprecated(since = "0.2.49", note = "Deprecated since MacOSX 10.9")] +pub const NOTE_REAP: u32 = 0x10000000; +pub const NOTE_SIGNAL: u32 = 0x08000000; +pub const NOTE_EXITSTATUS: u32 = 0x04000000; +pub const NOTE_EXIT_DETAIL: u32 = 0x02000000; +pub const NOTE_PDATAMASK: u32 = 0x000fffff; +pub const NOTE_PCTRLMASK: u32 = 0xfff00000; +#[doc(hidden)] +#[deprecated(since = "0.2.49", note = "Deprecated since MacOSX 10.9")] +pub const NOTE_EXIT_REPARENTED: u32 = 0x00080000; +pub const NOTE_EXIT_DETAIL_MASK: u32 = 0x00070000; +pub const NOTE_EXIT_DECRYPTFAIL: u32 = 0x00010000; +pub const NOTE_EXIT_MEMORY: u32 = 0x00020000; +pub const NOTE_EXIT_CSERROR: u32 = 0x00040000; +pub const NOTE_VM_PRESSURE: u32 = 0x80000000; +pub const NOTE_VM_PRESSURE_TERMINATE: u32 = 0x40000000; +pub const NOTE_VM_PRESSURE_SUDDEN_TERMINATE: u32 = 0x20000000; +pub const NOTE_VM_ERROR: u32 = 0x10000000; +pub const NOTE_SECONDS: u32 = 0x00000001; +pub const NOTE_USECONDS: u32 = 0x00000002; +pub const NOTE_NSECONDS: u32 = 0x00000004; +pub const NOTE_ABSOLUTE: u32 = 0x00000008; +pub const NOTE_LEEWAY: u32 = 0x00000010; +pub const NOTE_CRITICAL: u32 = 0x00000020; +pub const NOTE_BACKGROUND: u32 = 0x00000040; +pub const NOTE_MACH_CONTINUOUS_TIME: u32 = 0x00000080; +pub const NOTE_MACHTIME: u32 = 0x00000100; +pub const NOTE_TRACK: u32 = 0x00000001; +pub const NOTE_TRACKERR: u32 = 0x00000002; +pub const NOTE_CHILD: u32 = 0x00000004; + +pub const OCRNL: crate::tcflag_t = 0x00000010; +pub const ONOCR: crate::tcflag_t = 0x00000020; +pub const ONLRET: crate::tcflag_t = 0x00000040; +pub const OFILL: crate::tcflag_t = 0x00000080; +pub const NLDLY: crate::tcflag_t = 0x00000300; +pub const TABDLY: crate::tcflag_t = 0x00000c04; +pub const CRDLY: crate::tcflag_t = 0x00003000; +pub const FFDLY: crate::tcflag_t = 0x00004000; +pub const BSDLY: crate::tcflag_t = 0x00008000; +pub const VTDLY: crate::tcflag_t = 0x00010000; +pub const OFDEL: crate::tcflag_t = 0x00020000; + +pub const NL0: crate::tcflag_t = 0x00000000; +pub const NL1: crate::tcflag_t = 0x00000100; +pub const TAB0: crate::tcflag_t = 0x00000000; +pub const TAB1: crate::tcflag_t = 0x00000400; +pub const TAB2: crate::tcflag_t = 0x00000800; +pub const CR0: crate::tcflag_t = 0x00000000; +pub const CR1: crate::tcflag_t = 0x00001000; +pub const CR2: crate::tcflag_t = 0x00002000; +pub const CR3: crate::tcflag_t = 0x00003000; +pub const FF0: crate::tcflag_t = 0x00000000; +pub const FF1: crate::tcflag_t = 0x00004000; +pub const BS0: crate::tcflag_t = 0x00000000; +pub const BS1: crate::tcflag_t = 0x00008000; +pub const TAB3: crate::tcflag_t = 0x00000004; +pub const VT0: crate::tcflag_t = 0x00000000; +pub const VT1: crate::tcflag_t = 0x00010000; +pub const IUTF8: crate::tcflag_t = 0x00004000; +pub const CRTSCTS: crate::tcflag_t = 0x00030000; + +pub const NI_MAXHOST: crate::socklen_t = 1025; +pub const NI_MAXSERV: crate::socklen_t = 32; +pub const NI_NOFQDN: c_int = 0x00000001; +pub const NI_NUMERICHOST: c_int = 0x00000002; +pub const NI_NAMEREQD: c_int = 0x00000004; +pub const NI_NUMERICSERV: c_int = 0x00000008; +pub const NI_NUMERICSCOPE: c_int = 0x00000100; +pub const NI_DGRAM: c_int = 0x00000010; + +pub const Q_GETQUOTA: c_int = 0x300; +pub const Q_SETQUOTA: c_int = 0x400; + +pub const RENAME_SWAP: c_uint = 0x00000002; +pub const RENAME_EXCL: c_uint = 0x00000004; + +pub const RTLD_LOCAL: c_int = 0x4; +pub const RTLD_FIRST: c_int = 0x100; +pub const RTLD_NODELETE: c_int = 0x80; +pub const RTLD_NOLOAD: c_int = 0x10; +pub const RTLD_GLOBAL: c_int = 0x8; +pub const RTLD_MAIN_ONLY: *mut c_void = -5isize as *mut c_void; + +pub const _WSTOPPED: c_int = 0o177; + +pub const LOG_NETINFO: c_int = 12 << 3; +pub const LOG_REMOTEAUTH: c_int = 13 << 3; +pub const LOG_INSTALL: c_int = 14 << 3; +pub const LOG_RAS: c_int = 15 << 3; +pub const LOG_LAUNCHD: c_int = 24 << 3; +pub const LOG_NFACILITIES: c_int = 25; + +pub const CTLTYPE: c_int = 0xf; +pub const CTLTYPE_NODE: c_int = 1; +pub const CTLTYPE_INT: c_int = 2; +pub const CTLTYPE_STRING: c_int = 3; +pub const CTLTYPE_QUAD: c_int = 4; +pub const CTLTYPE_OPAQUE: c_int = 5; +pub const CTLTYPE_STRUCT: c_int = CTLTYPE_OPAQUE; +pub const CTLFLAG_RD: c_int = 0x80000000; +pub const CTLFLAG_WR: c_int = 0x40000000; +pub const CTLFLAG_RW: c_int = CTLFLAG_RD | CTLFLAG_WR; +pub const CTLFLAG_NOLOCK: c_int = 0x20000000; +pub const CTLFLAG_ANYBODY: c_int = 0x10000000; +pub const CTLFLAG_SECURE: c_int = 0x08000000; +pub const CTLFLAG_MASKED: c_int = 0x04000000; +pub const CTLFLAG_NOAUTO: c_int = 0x02000000; +pub const CTLFLAG_KERN: c_int = 0x01000000; +pub const CTLFLAG_LOCKED: c_int = 0x00800000; +pub const CTLFLAG_OID2: c_int = 0x00400000; +pub const CTL_UNSPEC: c_int = 0; +pub const CTL_KERN: c_int = 1; +pub const CTL_VM: c_int = 2; +pub const CTL_VFS: c_int = 3; +pub const CTL_NET: c_int = 4; +pub const CTL_DEBUG: c_int = 5; +pub const CTL_HW: c_int = 6; +pub const CTL_MACHDEP: c_int = 7; +pub const CTL_USER: c_int = 8; +pub const CTL_MAXID: c_int = 9; +pub const KERN_OSTYPE: c_int = 1; +pub const KERN_OSRELEASE: c_int = 2; +pub const KERN_OSREV: c_int = 3; +pub const KERN_VERSION: c_int = 4; +pub const KERN_MAXVNODES: c_int = 5; +pub const KERN_MAXPROC: c_int = 6; +pub const KERN_MAXFILES: c_int = 7; +pub const KERN_ARGMAX: c_int = 8; +pub const KERN_SECURELVL: c_int = 9; +pub const KERN_HOSTNAME: c_int = 10; +pub const KERN_HOSTID: c_int = 11; +pub const KERN_CLOCKRATE: c_int = 12; +pub const KERN_VNODE: c_int = 13; +pub const KERN_PROC: c_int = 14; +pub const KERN_FILE: c_int = 15; +pub const KERN_PROF: c_int = 16; +pub const KERN_POSIX1: c_int = 17; +pub const KERN_NGROUPS: c_int = 18; +pub const KERN_JOB_CONTROL: c_int = 19; +pub const KERN_SAVED_IDS: c_int = 20; +pub const KERN_BOOTTIME: c_int = 21; +pub const KERN_NISDOMAINNAME: c_int = 22; +pub const KERN_DOMAINNAME: c_int = KERN_NISDOMAINNAME; +pub const KERN_MAXPARTITIONS: c_int = 23; +pub const KERN_KDEBUG: c_int = 24; +pub const KERN_UPDATEINTERVAL: c_int = 25; +pub const KERN_OSRELDATE: c_int = 26; +pub const KERN_NTP_PLL: c_int = 27; +pub const KERN_BOOTFILE: c_int = 28; +pub const KERN_MAXFILESPERPROC: c_int = 29; +pub const KERN_MAXPROCPERUID: c_int = 30; +pub const KERN_DUMPDEV: c_int = 31; +pub const KERN_IPC: c_int = 32; +pub const KERN_DUMMY: c_int = 33; +pub const KERN_PS_STRINGS: c_int = 34; +pub const KERN_USRSTACK32: c_int = 35; +pub const KERN_LOGSIGEXIT: c_int = 36; +pub const KERN_SYMFILE: c_int = 37; +pub const KERN_PROCARGS: c_int = 38; +pub const KERN_NETBOOT: c_int = 40; +pub const KERN_SYSV: c_int = 42; +pub const KERN_AFFINITY: c_int = 43; +pub const KERN_TRANSLATE: c_int = 44; +pub const KERN_CLASSIC: c_int = KERN_TRANSLATE; +pub const KERN_EXEC: c_int = 45; +pub const KERN_CLASSICHANDLER: c_int = KERN_EXEC; +pub const KERN_AIOMAX: c_int = 46; +pub const KERN_AIOPROCMAX: c_int = 47; +pub const KERN_AIOTHREADS: c_int = 48; +pub const KERN_COREFILE: c_int = 50; +pub const KERN_COREDUMP: c_int = 51; +pub const KERN_SUGID_COREDUMP: c_int = 52; +pub const KERN_PROCDELAYTERM: c_int = 53; +pub const KERN_SHREG_PRIVATIZABLE: c_int = 54; +pub const KERN_LOW_PRI_WINDOW: c_int = 56; +pub const KERN_LOW_PRI_DELAY: c_int = 57; +pub const KERN_POSIX: c_int = 58; +pub const KERN_USRSTACK64: c_int = 59; +pub const KERN_NX_PROTECTION: c_int = 60; +pub const KERN_TFP: c_int = 61; +pub const KERN_PROCNAME: c_int = 62; +pub const KERN_THALTSTACK: c_int = 63; +pub const KERN_SPECULATIVE_READS: c_int = 64; +pub const KERN_OSVERSION: c_int = 65; +pub const KERN_SAFEBOOT: c_int = 66; +pub const KERN_RAGEVNODE: c_int = 68; +pub const KERN_TTY: c_int = 69; +pub const KERN_CHECKOPENEVT: c_int = 70; +pub const KERN_THREADNAME: c_int = 71; +pub const KERN_MAXID: c_int = 72; +pub const KERN_RAGE_PROC: c_int = 1; +pub const KERN_RAGE_THREAD: c_int = 2; +pub const KERN_UNRAGE_PROC: c_int = 3; +pub const KERN_UNRAGE_THREAD: c_int = 4; +pub const KERN_OPENEVT_PROC: c_int = 1; +pub const KERN_UNOPENEVT_PROC: c_int = 2; +pub const KERN_TFP_POLICY: c_int = 1; +pub const KERN_TFP_POLICY_DENY: c_int = 0; +pub const KERN_TFP_POLICY_DEFAULT: c_int = 2; +pub const KERN_KDEFLAGS: c_int = 1; +pub const KERN_KDDFLAGS: c_int = 2; +pub const KERN_KDENABLE: c_int = 3; +pub const KERN_KDSETBUF: c_int = 4; +pub const KERN_KDGETBUF: c_int = 5; +pub const KERN_KDSETUP: c_int = 6; +pub const KERN_KDREMOVE: c_int = 7; +pub const KERN_KDSETREG: c_int = 8; +pub const KERN_KDGETREG: c_int = 9; +pub const KERN_KDREADTR: c_int = 10; +pub const KERN_KDPIDTR: c_int = 11; +pub const KERN_KDTHRMAP: c_int = 12; +pub const KERN_KDPIDEX: c_int = 14; +pub const KERN_KDSETRTCDEC: c_int = 15; +pub const KERN_KDGETENTROPY: c_int = 16; +pub const KERN_KDWRITETR: c_int = 17; +pub const KERN_KDWRITEMAP: c_int = 18; +#[doc(hidden)] +#[deprecated(since = "0.2.49", note = "Removed in MacOSX 10.12")] +pub const KERN_KDENABLE_BG_TRACE: c_int = 19; +#[doc(hidden)] +#[deprecated(since = "0.2.49", note = "Removed in MacOSX 10.12")] +pub const KERN_KDDISABLE_BG_TRACE: c_int = 20; +pub const KERN_KDREADCURTHRMAP: c_int = 21; +pub const KERN_KDSET_TYPEFILTER: c_int = 22; +pub const KERN_KDBUFWAIT: c_int = 23; +pub const KERN_KDCPUMAP: c_int = 24; +pub const KERN_PROC_ALL: c_int = 0; +pub const KERN_PROC_PID: c_int = 1; +pub const KERN_PROC_PGRP: c_int = 2; +pub const KERN_PROC_SESSION: c_int = 3; +pub const KERN_PROC_TTY: c_int = 4; +pub const KERN_PROC_UID: c_int = 5; +pub const KERN_PROC_RUID: c_int = 6; +pub const KERN_PROC_LCID: c_int = 7; +pub const KERN_SUCCESS: c_int = 0; +pub const KERN_INVALID_ADDRESS: c_int = 1; +pub const KERN_PROTECTION_FAILURE: c_int = 2; +pub const KERN_NO_SPACE: c_int = 3; +pub const KERN_INVALID_ARGUMENT: c_int = 4; +pub const KERN_FAILURE: c_int = 5; +pub const KERN_RESOURCE_SHORTAGE: c_int = 6; +pub const KERN_NOT_RECEIVER: c_int = 7; +pub const KERN_NO_ACCESS: c_int = 8; +pub const KERN_MEMORY_FAILURE: c_int = 9; +pub const KERN_MEMORY_ERROR: c_int = 10; +pub const KERN_ALREADY_IN_SET: c_int = 11; +pub const KERN_NOT_IN_SET: c_int = 12; +pub const KERN_NAME_EXISTS: c_int = 13; +pub const KERN_ABORTED: c_int = 14; +pub const KERN_INVALID_NAME: c_int = 15; +pub const KERN_INVALID_TASK: c_int = 16; +pub const KERN_INVALID_RIGHT: c_int = 17; +pub const KERN_INVALID_VALUE: c_int = 18; +pub const KERN_UREFS_OVERFLOW: c_int = 19; +pub const KERN_INVALID_CAPABILITY: c_int = 20; +pub const KERN_RIGHT_EXISTS: c_int = 21; +pub const KERN_INVALID_HOST: c_int = 22; +pub const KERN_MEMORY_PRESENT: c_int = 23; +pub const KERN_MEMORY_DATA_MOVED: c_int = 24; +pub const KERN_MEMORY_RESTART_COPY: c_int = 25; +pub const KERN_INVALID_PROCESSOR_SET: c_int = 26; +pub const KERN_POLICY_LIMIT: c_int = 27; +pub const KERN_INVALID_POLICY: c_int = 28; +pub const KERN_INVALID_OBJECT: c_int = 29; +pub const KERN_ALREADY_WAITING: c_int = 30; +pub const KERN_DEFAULT_SET: c_int = 31; +pub const KERN_EXCEPTION_PROTECTED: c_int = 32; +pub const KERN_INVALID_LEDGER: c_int = 33; +pub const KERN_INVALID_MEMORY_CONTROL: c_int = 34; +pub const KERN_INVALID_SECURITY: c_int = 35; +pub const KERN_NOT_DEPRESSED: c_int = 36; +pub const KERN_TERMINATED: c_int = 37; +pub const KERN_LOCK_SET_DESTROYED: c_int = 38; +pub const KERN_LOCK_UNSTABLE: c_int = 39; +pub const KERN_LOCK_OWNED: c_int = 40; +pub const KERN_LOCK_OWNED_SELF: c_int = 41; +pub const KERN_SEMAPHORE_DESTROYED: c_int = 42; +pub const KERN_RPC_SERVER_TERMINATED: c_int = 43; +pub const KERN_RPC_TERMINATE_ORPHAN: c_int = 44; +pub const KERN_RPC_CONTINUE_ORPHAN: c_int = 45; +pub const KERN_NOT_SUPPORTED: c_int = 46; +pub const KERN_NODE_DOWN: c_int = 47; +pub const KERN_NOT_WAITING: c_int = 48; +pub const KERN_OPERATION_TIMED_OUT: c_int = 49; +pub const KERN_CODESIGN_ERROR: c_int = 50; +pub const KERN_POLICY_STATIC: c_int = 51; +pub const KERN_INSUFFICIENT_BUFFER_SIZE: c_int = 52; +pub const KIPC_MAXSOCKBUF: c_int = 1; +pub const KIPC_SOCKBUF_WASTE: c_int = 2; +pub const KIPC_SOMAXCONN: c_int = 3; +pub const KIPC_MAX_LINKHDR: c_int = 4; +pub const KIPC_MAX_PROTOHDR: c_int = 5; +pub const KIPC_MAX_HDR: c_int = 6; +pub const KIPC_MAX_DATALEN: c_int = 7; +pub const KIPC_MBSTAT: c_int = 8; +pub const KIPC_NMBCLUSTERS: c_int = 9; +pub const KIPC_SOQLIMITCOMPAT: c_int = 10; +pub const VM_METER: c_int = 1; +pub const VM_LOADAVG: c_int = 2; +pub const VM_MACHFACTOR: c_int = 4; +pub const VM_SWAPUSAGE: c_int = 5; +pub const VM_MAXID: c_int = 6; +pub const VM_PROT_NONE: crate::vm_prot_t = 0x00; +pub const VM_PROT_READ: crate::vm_prot_t = 0x01; +pub const VM_PROT_WRITE: crate::vm_prot_t = 0x02; +pub const VM_PROT_EXECUTE: crate::vm_prot_t = 0x04; +pub const MEMORY_OBJECT_NULL: crate::memory_object_t = 0; +pub const HW_MACHINE: c_int = 1; +pub const HW_MODEL: c_int = 2; +pub const HW_NCPU: c_int = 3; +pub const HW_BYTEORDER: c_int = 4; +pub const HW_PHYSMEM: c_int = 5; +pub const HW_USERMEM: c_int = 6; +pub const HW_PAGESIZE: c_int = 7; +pub const HW_DISKNAMES: c_int = 8; +pub const HW_DISKSTATS: c_int = 9; +pub const HW_EPOCH: c_int = 10; +pub const HW_FLOATINGPT: c_int = 11; +pub const HW_MACHINE_ARCH: c_int = 12; +pub const HW_VECTORUNIT: c_int = 13; +pub const HW_BUS_FREQ: c_int = 14; +pub const HW_CPU_FREQ: c_int = 15; +pub const HW_CACHELINE: c_int = 16; +pub const HW_L1ICACHESIZE: c_int = 17; +pub const HW_L1DCACHESIZE: c_int = 18; +pub const HW_L2SETTINGS: c_int = 19; +pub const HW_L2CACHESIZE: c_int = 20; +pub const HW_L3SETTINGS: c_int = 21; +pub const HW_L3CACHESIZE: c_int = 22; +pub const HW_TB_FREQ: c_int = 23; +pub const HW_MEMSIZE: c_int = 24; +pub const HW_AVAILCPU: c_int = 25; +pub const HW_TARGET: c_int = 26; +pub const HW_PRODUCT: c_int = 27; +pub const HW_MAXID: c_int = 28; +pub const USER_CS_PATH: c_int = 1; +pub const USER_BC_BASE_MAX: c_int = 2; +pub const USER_BC_DIM_MAX: c_int = 3; +pub const USER_BC_SCALE_MAX: c_int = 4; +pub const USER_BC_STRING_MAX: c_int = 5; +pub const USER_COLL_WEIGHTS_MAX: c_int = 6; +pub const USER_EXPR_NEST_MAX: c_int = 7; +pub const USER_LINE_MAX: c_int = 8; +pub const USER_RE_DUP_MAX: c_int = 9; +pub const USER_POSIX2_VERSION: c_int = 10; +pub const USER_POSIX2_C_BIND: c_int = 11; +pub const USER_POSIX2_C_DEV: c_int = 12; +pub const USER_POSIX2_CHAR_TERM: c_int = 13; +pub const USER_POSIX2_FORT_DEV: c_int = 14; +pub const USER_POSIX2_FORT_RUN: c_int = 15; +pub const USER_POSIX2_LOCALEDEF: c_int = 16; +pub const USER_POSIX2_SW_DEV: c_int = 17; +pub const USER_POSIX2_UPE: c_int = 18; +pub const USER_STREAM_MAX: c_int = 19; +pub const USER_TZNAME_MAX: c_int = 20; +pub const USER_MAXID: c_int = 21; +pub const CTL_DEBUG_NAME: c_int = 0; +pub const CTL_DEBUG_VALUE: c_int = 1; +pub const CTL_DEBUG_MAXID: c_int = 20; + +pub const PRIO_DARWIN_THREAD: c_int = 3; +pub const PRIO_DARWIN_PROCESS: c_int = 4; +pub const PRIO_DARWIN_BG: c_int = 0x1000; +pub const PRIO_DARWIN_NONUI: c_int = 0x1001; + +pub const SEM_FAILED: *mut sem_t = -1isize as *mut crate::sem_t; + +pub const AI_PASSIVE: c_int = 0x00000001; +pub const AI_CANONNAME: c_int = 0x00000002; +pub const AI_NUMERICHOST: c_int = 0x00000004; +pub const AI_NUMERICSERV: c_int = 0x00001000; +pub const AI_MASK: c_int = + AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | AI_ADDRCONFIG; +pub const AI_ALL: c_int = 0x00000100; +pub const AI_V4MAPPED_CFG: c_int = 0x00000200; +pub const AI_ADDRCONFIG: c_int = 0x00000400; +pub const AI_V4MAPPED: c_int = 0x00000800; +pub const AI_DEFAULT: c_int = AI_V4MAPPED_CFG | AI_ADDRCONFIG; +pub const AI_UNUSABLE: c_int = 0x10000000; + +pub const SIGEV_NONE: c_int = 0; +pub const SIGEV_SIGNAL: c_int = 1; +pub const SIGEV_THREAD: c_int = 3; + +pub const AIO_CANCELED: c_int = 2; +pub const AIO_NOTCANCELED: c_int = 4; +pub const AIO_ALLDONE: c_int = 1; +#[deprecated( + since = "0.2.64", + note = "Can vary at runtime. Use sysconf(3) instead" +)] +pub const AIO_LISTIO_MAX: c_int = 16; +pub const LIO_NOP: c_int = 0; +pub const LIO_WRITE: c_int = 2; +pub const LIO_READ: c_int = 1; +pub const LIO_WAIT: c_int = 2; +pub const LIO_NOWAIT: c_int = 1; + +pub const WEXITED: c_int = 0x00000004; +pub const WSTOPPED: c_int = 0x00000008; +pub const WCONTINUED: c_int = 0x00000010; +pub const WNOWAIT: c_int = 0x00000020; + +pub const P_ALL: idtype_t = 0; +pub const P_PID: idtype_t = 1; +pub const P_PGID: idtype_t = 2; + +pub const UTIME_OMIT: c_long = -2; +pub const UTIME_NOW: c_long = -1; + +pub const XATTR_NOFOLLOW: c_int = 0x0001; +pub const XATTR_CREATE: c_int = 0x0002; +pub const XATTR_REPLACE: c_int = 0x0004; +pub const XATTR_NOSECURITY: c_int = 0x0008; +pub const XATTR_NODEFAULT: c_int = 0x0010; +pub const XATTR_SHOWCOMPRESSION: c_int = 0x0020; + +pub const NET_RT_IFLIST2: c_int = 0x0006; + +// net/route.h +pub const RTF_DELCLONE: c_int = 0x80; +pub const RTF_CLONING: c_int = 0x100; +pub const RTF_XRESOLVE: c_int = 0x200; +pub const RTF_LLINFO: c_int = 0x400; +pub const RTF_NOIFREF: c_int = 0x2000; +pub const RTF_PRCLONING: c_int = 0x10000; +pub const RTF_WASCLONED: c_int = 0x20000; +pub const RTF_PROTO3: c_int = 0x40000; +pub const RTF_PINNED: c_int = 0x100000; +pub const RTF_LOCAL: c_int = 0x200000; +pub const RTF_BROADCAST: c_int = 0x400000; +pub const RTF_MULTICAST: c_int = 0x800000; +pub const RTF_IFSCOPE: c_int = 0x1000000; +pub const RTF_CONDEMNED: c_int = 0x2000000; +pub const RTF_IFREF: c_int = 0x4000000; +pub const RTF_PROXY: c_int = 0x8000000; +pub const RTF_ROUTER: c_int = 0x10000000; +pub const RTF_DEAD: c_int = 0x20000000; +pub const RTF_GLOBAL: c_int = 0x40000000; + +pub const RTM_VERSION: c_int = 5; + +// Message types +pub const RTM_LOCK: c_int = 0x8; +pub const RTM_OLDADD: c_int = 0x9; +pub const RTM_OLDDEL: c_int = 0xa; +pub const RTM_RESOLVE: c_int = 0xb; +pub const RTM_NEWADDR: c_int = 0xc; +pub const RTM_DELADDR: c_int = 0xd; +pub const RTM_IFINFO: c_int = 0xe; +pub const RTM_NEWMADDR: c_int = 0xf; +pub const RTM_DELMADDR: c_int = 0x10; +pub const RTM_IFINFO2: c_int = 0x12; +pub const RTM_NEWMADDR2: c_int = 0x13; +pub const RTM_GET2: c_int = 0x14; + +// Bitmask values for rtm_inits and rmx_locks. +pub const RTV_MTU: c_int = 0x1; +pub const RTV_HOPCOUNT: c_int = 0x2; +pub const RTV_EXPIRE: c_int = 0x4; +pub const RTV_RPIPE: c_int = 0x8; +pub const RTV_SPIPE: c_int = 0x10; +pub const RTV_SSTHRESH: c_int = 0x20; +pub const RTV_RTT: c_int = 0x40; +pub const RTV_RTTVAR: c_int = 0x80; + +pub const RTAX_MAX: c_int = 8; + +pub const KERN_PROCARGS2: c_int = 49; + +pub const PROC_PIDTASKALLINFO: c_int = 2; +pub const PROC_PIDTBSDINFO: c_int = 3; +pub const PROC_PIDTASKINFO: c_int = 4; +pub const PROC_PIDTHREADINFO: c_int = 5; +pub const PROC_PIDVNODEPATHINFO: c_int = 9; +pub const PROC_PIDPATHINFO_MAXSIZE: c_int = 4096; + +pub const PROC_PIDLISTFDS: c_int = 1; +pub const PROC_PIDLISTFD_SIZE: c_int = size_of::() as c_int; +pub const PROX_FDTYPE_ATALK: c_int = 0; +pub const PROX_FDTYPE_VNODE: c_int = 1; +pub const PROX_FDTYPE_SOCKET: c_int = 2; +pub const PROX_FDTYPE_PSHM: c_int = 3; +pub const PROX_FDTYPE_PSEM: c_int = 4; +pub const PROX_FDTYPE_KQUEUE: c_int = 5; +pub const PROX_FDTYPE_PIPE: c_int = 6; +pub const PROX_FDTYPE_FSEVENTS: c_int = 7; +pub const PROX_FDTYPE_NETPOLICY: c_int = 9; +pub const PROX_FDTYPE_CHANNEL: c_int = 10; +pub const PROX_FDTYPE_NEXUS: c_int = 11; + +pub const PROC_CSM_ALL: c_uint = 0x0001; +pub const PROC_CSM_NOSMT: c_uint = 0x0002; +pub const PROC_CSM_TECS: c_uint = 0x0004; +pub const MAXCOMLEN: usize = 16; +pub const MAXTHREADNAMESIZE: usize = 64; + +pub const XUCRED_VERSION: c_uint = 0; + +pub const LC_SEGMENT: u32 = 0x1; +pub const LC_SEGMENT_64: u32 = 0x19; + +pub const MH_MAGIC: u32 = 0xfeedface; +pub const MH_MAGIC_64: u32 = 0xfeedfacf; + +// net/if_utun.h +pub const UTUN_OPT_FLAGS: c_int = 1; +pub const UTUN_OPT_IFNAME: c_int = 2; + +// net/bpf.h +pub const DLT_NULL: c_uint = 0; // no link-layer encapsulation +pub const DLT_EN10MB: c_uint = 1; // Ethernet (10Mb) +pub const DLT_EN3MB: c_uint = 2; // Experimental Ethernet (3Mb) +pub const DLT_AX25: c_uint = 3; // Amateur Radio AX.25 +pub const DLT_PRONET: c_uint = 4; // Proteon ProNET Token Ring +pub const DLT_CHAOS: c_uint = 5; // Chaos +pub const DLT_IEEE802: c_uint = 6; // IEEE 802 Networks +pub const DLT_ARCNET: c_uint = 7; // ARCNET +pub const DLT_SLIP: c_uint = 8; // Serial Line IP +pub const DLT_PPP: c_uint = 9; // Point-to-point Protocol +pub const DLT_FDDI: c_uint = 10; // FDDI +pub const DLT_ATM_RFC1483: c_uint = 11; // LLC/SNAP encapsulated atm +pub const DLT_RAW: c_uint = 12; // raw IP +pub const DLT_LOOP: c_uint = 108; + +// https://github.com/apple/darwin-xnu/blob/HEAD/bsd/net/bpf.h#L100 +// sizeof(i32) +pub const BPF_ALIGNMENT: c_int = 4; + +// sys/mount.h +pub const MNT_NODEV: c_int = 0x00000010; +pub const MNT_UNION: c_int = 0x00000020; +pub const MNT_CPROTECT: c_int = 0x00000080; + +// MAC labeled / "quarantined" flag +pub const MNT_QUARANTINE: c_int = 0x00000400; + +// Flags set by internal operations. +pub const MNT_LOCAL: c_int = 0x00001000; +pub const MNT_QUOTA: c_int = 0x00002000; +pub const MNT_ROOTFS: c_int = 0x00004000; +pub const MNT_DOVOLFS: c_int = 0x00008000; + +pub const MNT_DONTBROWSE: c_int = 0x00100000; +pub const MNT_IGNORE_OWNERSHIP: c_int = 0x00200000; +pub const MNT_AUTOMOUNTED: c_int = 0x00400000; +pub const MNT_JOURNALED: c_int = 0x00800000; +pub const MNT_NOUSERXATTR: c_int = 0x01000000; +pub const MNT_DEFWRITE: c_int = 0x02000000; +pub const MNT_MULTILABEL: c_int = 0x04000000; +pub const MNT_NOATIME: c_int = 0x10000000; +pub const MNT_SNAPSHOT: c_int = 0x40000000; + +// External filesystem command modifier flags. +pub const MNT_NOBLOCK: c_int = 0x00020000; + +// sys/spawn.h: +// DIFF(main): changed to `c_short` in f62eb023ab +pub const POSIX_SPAWN_RESETIDS: c_int = 0x0001; +pub const POSIX_SPAWN_SETPGROUP: c_int = 0x0002; +pub const POSIX_SPAWN_SETSIGDEF: c_int = 0x0004; +pub const POSIX_SPAWN_SETSIGMASK: c_int = 0x0008; +pub const POSIX_SPAWN_SETEXEC: c_int = 0x0040; +pub const POSIX_SPAWN_START_SUSPENDED: c_int = 0x0080; +pub const POSIX_SPAWN_CLOEXEC_DEFAULT: c_int = 0x4000; + +// sys/ipc.h: +pub const IPC_CREAT: c_int = 0x200; +pub const IPC_EXCL: c_int = 0x400; +pub const IPC_NOWAIT: c_int = 0x800; +pub const IPC_PRIVATE: key_t = 0; + +pub const IPC_RMID: c_int = 0; +pub const IPC_SET: c_int = 1; +pub const IPC_STAT: c_int = 2; + +pub const IPC_R: c_int = 0x100; +pub const IPC_W: c_int = 0x80; +pub const IPC_M: c_int = 0x1000; + +// sys/sem.h +pub const SEM_UNDO: c_int = 0o10000; + +pub const GETNCNT: c_int = 3; +pub const GETPID: c_int = 4; +pub const GETVAL: c_int = 5; +pub const GETALL: c_int = 6; +pub const GETZCNT: c_int = 7; +pub const SETVAL: c_int = 8; +pub const SETALL: c_int = 9; + +// sys/shm.h +pub const SHM_RDONLY: c_int = 0x1000; +pub const SHM_RND: c_int = 0x2000; +#[cfg(target_arch = "aarch64")] +pub const SHMLBA: c_int = 16 * 1024; +#[cfg(not(target_arch = "aarch64"))] +pub const SHMLBA: c_int = 4096; +pub const SHM_R: c_int = IPC_R; +pub const SHM_W: c_int = IPC_W; + +// Flags for chflags(2) +pub const UF_SETTABLE: c_uint = 0x0000ffff; +pub const UF_NODUMP: c_uint = 0x00000001; +pub const UF_IMMUTABLE: c_uint = 0x00000002; +pub const UF_APPEND: c_uint = 0x00000004; +pub const UF_OPAQUE: c_uint = 0x00000008; +pub const UF_COMPRESSED: c_uint = 0x00000020; +pub const UF_TRACKED: c_uint = 0x00000040; +pub const SF_SETTABLE: c_uint = 0x3fff0000; +pub const SF_ARCHIVED: c_uint = 0x00010000; +pub const SF_IMMUTABLE: c_uint = 0x00020000; +pub const SF_APPEND: c_uint = 0x00040000; +pub const UF_HIDDEN: c_uint = 0x00008000; + +// +pub const NTP_API: c_int = 4; +pub const MAXPHASE: c_long = 500000000; +pub const MAXFREQ: c_long = 500000; +pub const MINSEC: c_int = 256; +pub const MAXSEC: c_int = 2048; +pub const NANOSECOND: c_long = 1000000000; +pub const SCALE_PPM: c_int = 65; +pub const MAXTC: c_int = 10; +pub const MOD_OFFSET: c_uint = 0x0001; +pub const MOD_FREQUENCY: c_uint = 0x0002; +pub const MOD_MAXERROR: c_uint = 0x0004; +pub const MOD_ESTERROR: c_uint = 0x0008; +pub const MOD_STATUS: c_uint = 0x0010; +pub const MOD_TIMECONST: c_uint = 0x0020; +pub const MOD_PPSMAX: c_uint = 0x0040; +pub const MOD_TAI: c_uint = 0x0080; +pub const MOD_MICRO: c_uint = 0x1000; +pub const MOD_NANO: c_uint = 0x2000; +pub const MOD_CLKB: c_uint = 0x4000; +pub const MOD_CLKA: c_uint = 0x8000; +pub const STA_PLL: c_int = 0x0001; +pub const STA_PPSFREQ: c_int = 0x0002; +pub const STA_PPSTIME: c_int = 0x0004; +pub const STA_FLL: c_int = 0x0008; +pub const STA_INS: c_int = 0x0010; +pub const STA_DEL: c_int = 0x0020; +pub const STA_UNSYNC: c_int = 0x0040; +pub const STA_FREQHOLD: c_int = 0x0080; +pub const STA_PPSSIGNAL: c_int = 0x0100; +pub const STA_PPSJITTER: c_int = 0x0200; +pub const STA_PPSWANDER: c_int = 0x0400; +pub const STA_PPSERROR: c_int = 0x0800; +pub const STA_CLOCKERR: c_int = 0x1000; +pub const STA_NANO: c_int = 0x2000; +pub const STA_MODE: c_int = 0x4000; +pub const STA_CLK: c_int = 0x8000; +pub const STA_RONLY: c_int = STA_PPSSIGNAL + | STA_PPSJITTER + | STA_PPSWANDER + | STA_PPSERROR + | STA_CLOCKERR + | STA_NANO + | STA_MODE + | STA_CLK; +pub const TIME_OK: c_int = 0; +pub const TIME_INS: c_int = 1; +pub const TIME_DEL: c_int = 2; +pub const TIME_OOP: c_int = 3; +pub const TIME_WAIT: c_int = 4; +pub const TIME_ERROR: c_int = 5; + +// +pub const MNT_WAIT: c_int = 1; +pub const MNT_NOWAIT: c_int = 2; + +// +pub const THREAD_STANDARD_POLICY: c_int = 1; +pub const THREAD_STANDARD_POLICY_COUNT: c_int = 0; +pub const THREAD_EXTENDED_POLICY: c_int = 1; +pub const THREAD_TIME_CONSTRAINT_POLICY: c_int = 2; +pub const THREAD_PRECEDENCE_POLICY: c_int = 3; +pub const THREAD_AFFINITY_POLICY: c_int = 4; +pub const THREAD_AFFINITY_TAG_NULL: c_int = 0; +pub const THREAD_BACKGROUND_POLICY: c_int = 5; +pub const THREAD_BACKGROUND_POLICY_DARWIN_BG: c_int = 0x1000; +pub const THREAD_LATENCY_QOS_POLICY: c_int = 7; +pub const THREAD_THROUGHPUT_QOS_POLICY: c_int = 8; + +// +pub const TH_STATE_RUNNING: c_int = 1; +pub const TH_STATE_STOPPED: c_int = 2; +pub const TH_STATE_WAITING: c_int = 3; +pub const TH_STATE_UNINTERRUPTIBLE: c_int = 4; +pub const TH_STATE_HALTED: c_int = 5; +pub const TH_FLAGS_SWAPPED: c_int = 0x1; +pub const TH_FLAGS_IDLE: c_int = 0x2; +pub const TH_FLAGS_GLOBAL_FORCED_IDLE: c_int = 0x4; +pub const THREAD_BASIC_INFO: c_int = 3; +pub const THREAD_IDENTIFIER_INFO: c_int = 4; +pub const THREAD_EXTENDED_INFO: c_int = 5; + +// CommonCrypto/CommonCryptoError.h +pub const kCCSuccess: i32 = 0; +pub const kCCParamError: i32 = -4300; +pub const kCCBufferTooSmall: i32 = -4301; +pub const kCCMemoryFailure: i32 = -4302; +pub const kCCAlignmentError: i32 = -4303; +pub const kCCDecodeError: i32 = -4304; +pub const kCCUnimplemented: i32 = -4305; +pub const kCCOverflow: i32 = -4306; +pub const kCCRNGFailure: i32 = -4307; +pub const kCCUnspecifiedError: i32 = -4308; +pub const kCCCallSequenceError: i32 = -4309; +pub const kCCKeySizeError: i32 = -4310; +pub const kCCInvalidKey: i32 = -4311; + +// mach/host_info.h +pub const HOST_LOAD_INFO: i32 = 1; +pub const HOST_VM_INFO: i32 = 2; +pub const HOST_CPU_LOAD_INFO: i32 = 3; +pub const HOST_VM_INFO64: i32 = 4; +pub const HOST_EXTMOD_INFO64: i32 = 5; +pub const HOST_EXPIRED_TASK_INFO: i32 = 6; + +// mach/vm_statistics.h +pub const VM_PAGE_QUERY_PAGE_PRESENT: i32 = 0x1; +pub const VM_PAGE_QUERY_PAGE_FICTITIOUS: i32 = 0x2; +pub const VM_PAGE_QUERY_PAGE_REF: i32 = 0x4; +pub const VM_PAGE_QUERY_PAGE_DIRTY: i32 = 0x8; +pub const VM_PAGE_QUERY_PAGE_PAGED_OUT: i32 = 0x10; +pub const VM_PAGE_QUERY_PAGE_COPIED: i32 = 0x20; +pub const VM_PAGE_QUERY_PAGE_SPECULATIVE: i32 = 0x40; +pub const VM_PAGE_QUERY_PAGE_EXTERNAL: i32 = 0x80; +pub const VM_PAGE_QUERY_PAGE_CS_VALIDATED: i32 = 0x100; +pub const VM_PAGE_QUERY_PAGE_CS_TAINTED: i32 = 0x200; +pub const VM_PAGE_QUERY_PAGE_CS_NX: i32 = 0x400; + +// mach/task_info.h +pub const TASK_THREAD_TIMES_INFO: u32 = 3; +pub const HOST_CPU_LOAD_INFO_COUNT: u32 = 4; +pub const MACH_TASK_BASIC_INFO: u32 = 20; + +pub const MACH_PORT_NULL: i32 = 0; + +pub const RUSAGE_INFO_V0: c_int = 0; +pub const RUSAGE_INFO_V1: c_int = 1; +pub const RUSAGE_INFO_V2: c_int = 2; +pub const RUSAGE_INFO_V3: c_int = 3; +pub const RUSAGE_INFO_V4: c_int = 4; + +// copyfile.h +pub const COPYFILE_ACL: crate::copyfile_flags_t = 1 << 0; +pub const COPYFILE_STAT: crate::copyfile_flags_t = 1 << 1; +pub const COPYFILE_XATTR: crate::copyfile_flags_t = 1 << 2; +pub const COPYFILE_DATA: crate::copyfile_flags_t = 1 << 3; +pub const COPYFILE_SECURITY: crate::copyfile_flags_t = COPYFILE_STAT | COPYFILE_ACL; +pub const COPYFILE_METADATA: crate::copyfile_flags_t = COPYFILE_SECURITY | COPYFILE_XATTR; +pub const COPYFILE_RECURSIVE: crate::copyfile_flags_t = 1 << 15; +pub const COPYFILE_CHECK: crate::copyfile_flags_t = 1 << 16; +pub const COPYFILE_EXCL: crate::copyfile_flags_t = 1 << 17; +pub const COPYFILE_NOFOLLOW_SRC: crate::copyfile_flags_t = 1 << 18; +pub const COPYFILE_NOFOLLOW_DST: crate::copyfile_flags_t = 1 << 19; +pub const COPYFILE_MOVE: crate::copyfile_flags_t = 1 << 20; +pub const COPYFILE_UNLINK: crate::copyfile_flags_t = 1 << 21; +pub const COPYFILE_NOFOLLOW: crate::copyfile_flags_t = + COPYFILE_NOFOLLOW_SRC | COPYFILE_NOFOLLOW_DST; +pub const COPYFILE_PACK: crate::copyfile_flags_t = 1 << 22; +pub const COPYFILE_UNPACK: crate::copyfile_flags_t = 1 << 23; +pub const COPYFILE_CLONE: crate::copyfile_flags_t = 1 << 24; +pub const COPYFILE_CLONE_FORCE: crate::copyfile_flags_t = 1 << 25; +pub const COPYFILE_RUN_IN_PLACE: crate::copyfile_flags_t = 1 << 26; +pub const COPYFILE_DATA_SPARSE: crate::copyfile_flags_t = 1 << 27; +pub const COPYFILE_PRESERVE_DST_TRACKED: crate::copyfile_flags_t = 1 << 28; +pub const COPYFILE_VERBOSE: crate::copyfile_flags_t = 1 << 30; +pub const COPYFILE_RECURSE_ERROR: c_int = 0; +pub const COPYFILE_RECURSE_FILE: c_int = 1; +pub const COPYFILE_RECURSE_DIR: c_int = 2; +pub const COPYFILE_RECURSE_DIR_CLEANUP: c_int = 3; +pub const COPYFILE_COPY_DATA: c_int = 4; +pub const COPYFILE_COPY_XATTR: c_int = 5; +pub const COPYFILE_START: c_int = 1; +pub const COPYFILE_FINISH: c_int = 2; +pub const COPYFILE_ERR: c_int = 3; +pub const COPYFILE_PROGRESS: c_int = 4; +pub const COPYFILE_CONTINUE: c_int = 0; +pub const COPYFILE_SKIP: c_int = 1; +pub const COPYFILE_QUIT: c_int = 2; +pub const COPYFILE_STATE_SRC_FD: c_int = 1; +pub const COPYFILE_STATE_SRC_FILENAME: c_int = 2; +pub const COPYFILE_STATE_DST_FD: c_int = 3; +pub const COPYFILE_STATE_DST_FILENAME: c_int = 4; +pub const COPYFILE_STATE_QUARANTINE: c_int = 5; +pub const COPYFILE_STATE_STATUS_CB: c_int = 6; +pub const COPYFILE_STATE_STATUS_CTX: c_int = 7; +pub const COPYFILE_STATE_COPIED: c_int = 8; +pub const COPYFILE_STATE_XATTRNAME: c_int = 9; +pub const COPYFILE_STATE_WAS_CLONED: c_int = 10; +pub const COPYFILE_STATE_SRC_BSIZE: c_int = 11; +pub const COPYFILE_STATE_DST_BSIZE: c_int = 12; +pub const COPYFILE_STATE_BSIZE: c_int = 13; + +// +pub const ATTR_BIT_MAP_COUNT: c_ushort = 5; +pub const FSOPT_NOFOLLOW: u32 = 0x1; +pub const FSOPT_NOFOLLOW_ANY: u32 = 0x800; +pub const FSOPT_REPORT_FULLSIZE: u32 = 0x4; +pub const FSOPT_PACK_INVAL_ATTRS: u32 = 0x8; +pub const FSOPT_ATTR_CMN_EXTENDED: u32 = 0x20; +pub const FSOPT_RETURN_REALDEV: u32 = 0x200; +pub const ATTR_CMN_NAME: attrgroup_t = 0x00000001; +pub const ATTR_CMN_DEVID: attrgroup_t = 0x00000002; +pub const ATTR_CMN_FSID: attrgroup_t = 0x00000004; +pub const ATTR_CMN_OBJTYPE: attrgroup_t = 0x00000008; +pub const ATTR_CMN_OBJTAG: attrgroup_t = 0x00000010; +pub const ATTR_CMN_OBJID: attrgroup_t = 0x00000020; +pub const ATTR_CMN_OBJPERMANENTID: attrgroup_t = 0x00000040; +pub const ATTR_CMN_PAROBJID: attrgroup_t = 0x00000080; +pub const ATTR_CMN_SCRIPT: attrgroup_t = 0x00000100; +pub const ATTR_CMN_CRTIME: attrgroup_t = 0x00000200; +pub const ATTR_CMN_MODTIME: attrgroup_t = 0x00000400; +pub const ATTR_CMN_CHGTIME: attrgroup_t = 0x00000800; +pub const ATTR_CMN_ACCTIME: attrgroup_t = 0x00001000; +pub const ATTR_CMN_BKUPTIME: attrgroup_t = 0x00002000; +pub const ATTR_CMN_FNDRINFO: attrgroup_t = 0x00004000; +pub const ATTR_CMN_OWNERID: attrgroup_t = 0x00008000; +pub const ATTR_CMN_GRPID: attrgroup_t = 0x00010000; +pub const ATTR_CMN_ACCESSMASK: attrgroup_t = 0x00020000; +pub const ATTR_CMN_FLAGS: attrgroup_t = 0x00040000; +pub const ATTR_CMN_GEN_COUNT: attrgroup_t = 0x00080000; +pub const ATTR_CMN_DOCUMENT_ID: attrgroup_t = 0x00100000; +pub const ATTR_CMN_USERACCESS: attrgroup_t = 0x00200000; +pub const ATTR_CMN_EXTENDED_SECURITY: attrgroup_t = 0x00400000; +pub const ATTR_CMN_UUID: attrgroup_t = 0x00800000; +pub const ATTR_CMN_GRPUUID: attrgroup_t = 0x01000000; +pub const ATTR_CMN_FILEID: attrgroup_t = 0x02000000; +pub const ATTR_CMN_PARENTID: attrgroup_t = 0x04000000; +pub const ATTR_CMN_FULLPATH: attrgroup_t = 0x08000000; +pub const ATTR_CMN_ADDEDTIME: attrgroup_t = 0x10000000; +pub const ATTR_CMN_DATA_PROTECT_FLAGS: attrgroup_t = 0x40000000; +pub const ATTR_CMN_RETURNED_ATTRS: attrgroup_t = 0x80000000; +pub const ATTR_VOL_FSTYPE: attrgroup_t = 0x00000001; +pub const ATTR_VOL_SIGNATURE: attrgroup_t = 0x00000002; +pub const ATTR_VOL_SIZE: attrgroup_t = 0x00000004; +pub const ATTR_VOL_SPACEFREE: attrgroup_t = 0x00000008; +pub const ATTR_VOL_SPACEAVAIL: attrgroup_t = 0x00000010; +pub const ATTR_VOL_MINALLOCATION: attrgroup_t = 0x00000020; +pub const ATTR_VOL_ALLOCATIONCLUMP: attrgroup_t = 0x00000040; +pub const ATTR_VOL_IOBLOCKSIZE: attrgroup_t = 0x00000080; +pub const ATTR_VOL_OBJCOUNT: attrgroup_t = 0x00000100; +pub const ATTR_VOL_FILECOUNT: attrgroup_t = 0x00000200; +pub const ATTR_VOL_DIRCOUNT: attrgroup_t = 0x00000400; +pub const ATTR_VOL_MAXOBJCOUNT: attrgroup_t = 0x00000800; +pub const ATTR_VOL_MOUNTPOINT: attrgroup_t = 0x00001000; +pub const ATTR_VOL_NAME: attrgroup_t = 0x00002000; +pub const ATTR_VOL_MOUNTFLAGS: attrgroup_t = 0x00004000; +pub const ATTR_VOL_MOUNTEDDEVICE: attrgroup_t = 0x00008000; +pub const ATTR_VOL_ENCODINGSUSED: attrgroup_t = 0x00010000; +pub const ATTR_VOL_CAPABILITIES: attrgroup_t = 0x00020000; +pub const ATTR_VOL_UUID: attrgroup_t = 0x00040000; +pub const ATTR_VOL_SPACEUSED: attrgroup_t = 0x00800000; +pub const ATTR_VOL_QUOTA_SIZE: attrgroup_t = 0x10000000; +pub const ATTR_VOL_RESERVED_SIZE: attrgroup_t = 0x20000000; +pub const ATTR_VOL_ATTRIBUTES: attrgroup_t = 0x40000000; +pub const ATTR_VOL_INFO: attrgroup_t = 0x80000000; +pub const ATTR_DIR_LINKCOUNT: attrgroup_t = 0x00000001; +pub const ATTR_DIR_ENTRYCOUNT: attrgroup_t = 0x00000002; +pub const ATTR_DIR_MOUNTSTATUS: attrgroup_t = 0x00000004; +pub const ATTR_DIR_ALLOCSIZE: attrgroup_t = 0x00000008; +pub const ATTR_DIR_IOBLOCKSIZE: attrgroup_t = 0x00000010; +pub const ATTR_DIR_DATALENGTH: attrgroup_t = 0x00000020; +pub const ATTR_FILE_LINKCOUNT: attrgroup_t = 0x00000001; +pub const ATTR_FILE_TOTALSIZE: attrgroup_t = 0x00000002; +pub const ATTR_FILE_ALLOCSIZE: attrgroup_t = 0x00000004; +pub const ATTR_FILE_IOBLOCKSIZE: attrgroup_t = 0x00000008; +pub const ATTR_FILE_DEVTYPE: attrgroup_t = 0x00000020; +pub const ATTR_FILE_FORKCOUNT: attrgroup_t = 0x00000080; +pub const ATTR_FILE_FORKLIST: attrgroup_t = 0x00000100; +pub const ATTR_FILE_DATALENGTH: attrgroup_t = 0x00000200; +pub const ATTR_FILE_DATAALLOCSIZE: attrgroup_t = 0x00000400; +pub const ATTR_FILE_RSRCLENGTH: attrgroup_t = 0x00001000; +pub const ATTR_FILE_RSRCALLOCSIZE: attrgroup_t = 0x00002000; +pub const ATTR_CMNEXT_RELPATH: attrgroup_t = 0x00000004; +pub const ATTR_CMNEXT_PRIVATESIZE: attrgroup_t = 0x00000008; +pub const ATTR_CMNEXT_LINKID: attrgroup_t = 0x00000010; +pub const ATTR_CMNEXT_NOFIRMLINKPATH: attrgroup_t = 0x00000020; +pub const ATTR_CMNEXT_REALDEVID: attrgroup_t = 0x00000040; +pub const ATTR_CMNEXT_REALFSID: attrgroup_t = 0x00000080; +pub const ATTR_CMNEXT_CLONEID: attrgroup_t = 0x00000100; +pub const ATTR_CMNEXT_EXT_FLAGS: attrgroup_t = 0x00000200; +pub const ATTR_CMNEXT_RECURSIVE_GENCOUNT: attrgroup_t = 0x00000400; +pub const DIR_MNTSTATUS_MNTPOINT: u32 = 0x1; +pub const VOL_CAPABILITIES_FORMAT: usize = 0; +pub const VOL_CAPABILITIES_INTERFACES: usize = 1; +pub const VOL_CAP_FMT_PERSISTENTOBJECTIDS: attrgroup_t = 0x00000001; +pub const VOL_CAP_FMT_SYMBOLICLINKS: attrgroup_t = 0x00000002; +pub const VOL_CAP_FMT_HARDLINKS: attrgroup_t = 0x00000004; +pub const VOL_CAP_FMT_JOURNAL: attrgroup_t = 0x00000008; +pub const VOL_CAP_FMT_JOURNAL_ACTIVE: attrgroup_t = 0x00000010; +pub const VOL_CAP_FMT_NO_ROOT_TIMES: attrgroup_t = 0x00000020; +pub const VOL_CAP_FMT_SPARSE_FILES: attrgroup_t = 0x00000040; +pub const VOL_CAP_FMT_ZERO_RUNS: attrgroup_t = 0x00000080; +pub const VOL_CAP_FMT_CASE_SENSITIVE: attrgroup_t = 0x00000100; +pub const VOL_CAP_FMT_CASE_PRESERVING: attrgroup_t = 0x00000200; +pub const VOL_CAP_FMT_FAST_STATFS: attrgroup_t = 0x00000400; +pub const VOL_CAP_FMT_2TB_FILESIZE: attrgroup_t = 0x00000800; +pub const VOL_CAP_FMT_OPENDENYMODES: attrgroup_t = 0x00001000; +pub const VOL_CAP_FMT_HIDDEN_FILES: attrgroup_t = 0x00002000; +pub const VOL_CAP_FMT_PATH_FROM_ID: attrgroup_t = 0x00004000; +pub const VOL_CAP_FMT_NO_VOLUME_SIZES: attrgroup_t = 0x00008000; +pub const VOL_CAP_FMT_DECMPFS_COMPRESSION: attrgroup_t = 0x00010000; +pub const VOL_CAP_FMT_64BIT_OBJECT_IDS: attrgroup_t = 0x00020000; +pub const VOL_CAP_FMT_DIR_HARDLINKS: attrgroup_t = 0x00040000; +pub const VOL_CAP_FMT_DOCUMENT_ID: attrgroup_t = 0x00080000; +pub const VOL_CAP_FMT_WRITE_GENERATION_COUNT: attrgroup_t = 0x00100000; +pub const VOL_CAP_FMT_NO_IMMUTABLE_FILES: attrgroup_t = 0x00200000; +pub const VOL_CAP_FMT_NO_PERMISSIONS: attrgroup_t = 0x00400000; +pub const VOL_CAP_FMT_SHARED_SPACE: attrgroup_t = 0x00800000; +pub const VOL_CAP_FMT_VOL_GROUPS: attrgroup_t = 0x01000000; +pub const VOL_CAP_FMT_SEALED: attrgroup_t = 0x02000000; +pub const VOL_CAP_INT_SEARCHFS: attrgroup_t = 0x00000001; +pub const VOL_CAP_INT_ATTRLIST: attrgroup_t = 0x00000002; +pub const VOL_CAP_INT_NFSEXPORT: attrgroup_t = 0x00000004; +pub const VOL_CAP_INT_READDIRATTR: attrgroup_t = 0x00000008; +pub const VOL_CAP_INT_EXCHANGEDATA: attrgroup_t = 0x00000010; +pub const VOL_CAP_INT_COPYFILE: attrgroup_t = 0x00000020; +pub const VOL_CAP_INT_ALLOCATE: attrgroup_t = 0x00000040; +pub const VOL_CAP_INT_VOL_RENAME: attrgroup_t = 0x00000080; +pub const VOL_CAP_INT_ADVLOCK: attrgroup_t = 0x00000100; +pub const VOL_CAP_INT_FLOCK: attrgroup_t = 0x00000200; +pub const VOL_CAP_INT_EXTENDED_SECURITY: attrgroup_t = 0x00000400; +pub const VOL_CAP_INT_USERACCESS: attrgroup_t = 0x00000800; +pub const VOL_CAP_INT_MANLOCK: attrgroup_t = 0x00001000; +pub const VOL_CAP_INT_NAMEDSTREAMS: attrgroup_t = 0x00002000; +pub const VOL_CAP_INT_EXTENDED_ATTR: attrgroup_t = 0x00004000; +pub const VOL_CAP_INT_CLONE: attrgroup_t = 0x00010000; +pub const VOL_CAP_INT_SNAPSHOT: attrgroup_t = 0x00020000; +pub const VOL_CAP_INT_RENAME_SWAP: attrgroup_t = 0x00040000; +pub const VOL_CAP_INT_RENAME_EXCL: attrgroup_t = 0x00080000; +pub const VOL_CAP_INT_RENAME_OPENFAIL: attrgroup_t = 0x00100000; + +// os/clock.h +pub const OS_CLOCK_MACH_ABSOLUTE_TIME: os_clockid_t = 32; + +// os/os_sync_wait_on_address.h +pub const OS_SYNC_WAIT_ON_ADDRESS_NONE: os_sync_wait_on_address_flags_t = 0x00000000; +pub const OS_SYNC_WAIT_ON_ADDRESS_SHARED: os_sync_wait_on_address_flags_t = 0x00000001; +pub const OS_SYNC_WAKE_BY_ADDRESS_NONE: os_sync_wake_by_address_flags_t = 0x00000000; +pub const OS_SYNC_WAKE_BY_ADDRESS_SHARED: os_sync_wake_by_address_flags_t = 0x00000001; + +// +/// Process being created by fork. +pub const SIDL: u32 = 1; +/// Currently runnable. +pub const SRUN: u32 = 2; +/// Sleeping on an address. +pub const SSLEEP: u32 = 3; +/// Process debugging or suspension. +pub const SSTOP: u32 = 4; +/// Awaiting collection by parent. +pub const SZOMB: u32 = 5; + +// sys/vsock.h +pub const VMADDR_CID_ANY: c_uint = 0xFFFFFFFF; +pub const VMADDR_CID_HYPERVISOR: c_uint = 0; +pub const VMADDR_CID_RESERVED: c_uint = 1; +pub const VMADDR_CID_HOST: c_uint = 2; +pub const VMADDR_PORT_ANY: c_uint = 0xFFFFFFFF; + +const fn __DARWIN_ALIGN32(p: usize) -> usize { + const __DARWIN_ALIGNBYTES32: usize = size_of::() - 1; + (p + __DARWIN_ALIGNBYTES32) & !__DARWIN_ALIGNBYTES32 +} + +pub const THREAD_EXTENDED_POLICY_COUNT: mach_msg_type_number_t = + (size_of::() / size_of::()) as mach_msg_type_number_t; +pub const THREAD_TIME_CONSTRAINT_POLICY_COUNT: mach_msg_type_number_t = + (size_of::() / size_of::()) + as mach_msg_type_number_t; +pub const THREAD_PRECEDENCE_POLICY_COUNT: mach_msg_type_number_t = + (size_of::() / size_of::()) + as mach_msg_type_number_t; +pub const THREAD_AFFINITY_POLICY_COUNT: mach_msg_type_number_t = + (size_of::() / size_of::()) as mach_msg_type_number_t; +pub const THREAD_BACKGROUND_POLICY_COUNT: mach_msg_type_number_t = + (size_of::() / size_of::()) + as mach_msg_type_number_t; +pub const THREAD_LATENCY_QOS_POLICY_COUNT: mach_msg_type_number_t = + (size_of::() / size_of::()) + as mach_msg_type_number_t; +pub const THREAD_THROUGHPUT_QOS_POLICY_COUNT: mach_msg_type_number_t = + (size_of::() / size_of::()) + as mach_msg_type_number_t; +pub const THREAD_BASIC_INFO_COUNT: mach_msg_type_number_t = + (size_of::() / size_of::()) as mach_msg_type_number_t; +pub const THREAD_IDENTIFIER_INFO_COUNT: mach_msg_type_number_t = + (size_of::() / size_of::()) as mach_msg_type_number_t; +pub const THREAD_EXTENDED_INFO_COUNT: mach_msg_type_number_t = + (size_of::() / size_of::()) as mach_msg_type_number_t; + +pub const TASK_THREAD_TIMES_INFO_COUNT: u32 = + (size_of::() / size_of::()) as u32; +pub const MACH_TASK_BASIC_INFO_COUNT: u32 = + (size_of::() / size_of::()) as u32; +pub const HOST_VM_INFO64_COUNT: mach_msg_type_number_t = + (size_of::() / size_of::()) as mach_msg_type_number_t; + +// bsd/net/if_mib.h +/// Non-interface-specific +pub const IFMIB_SYSTEM: c_int = 1; +/// Per-interface data table +pub const IFMIB_IFDATA: c_int = 2; +/// All interfaces data at once +pub const IFMIB_IFALLDATA: c_int = 3; + +/// Generic stats for all kinds of ifaces +pub const IFDATA_GENERAL: c_int = 1; +/// Specific to the type of interface +pub const IFDATA_LINKSPECIFIC: c_int = 2; +/// Addresses assigned to interface +pub const IFDATA_ADDRS: c_int = 3; +/// Multicast addresses assigned to interface +pub const IFDATA_MULTIADDRS: c_int = 4; + +/// Number of interfaces configured +pub const IFMIB_IFCOUNT: c_int = 1; + +/// Functions not specific to a type of iface +pub const NETLINK_GENERIC: c_int = 0; + +pub const DOT3COMPLIANCE_STATS: c_int = 1; +pub const DOT3COMPLIANCE_COLLS: c_int = 2; + +// kern_control.h +pub const MAX_KCTL_NAME: usize = 96; + +f! { + pub fn CMSG_NXTHDR(mhdr: *const crate::msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { + if cmsg.is_null() { + return crate::CMSG_FIRSTHDR(mhdr); + } + let cmsg_len = (*cmsg).cmsg_len as usize; + let next = cmsg as usize + __DARWIN_ALIGN32(cmsg_len); + let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; + if next + __DARWIN_ALIGN32(size_of::()) > max { + core::ptr::null_mut() + } else { + next as *mut cmsghdr + } + } + + pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { + (cmsg as *mut c_uchar).add(__DARWIN_ALIGN32(size_of::())) + } + + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { + (__DARWIN_ALIGN32(size_of::()) + __DARWIN_ALIGN32(length as usize)) as c_uint + } + + pub const fn CMSG_LEN(length: c_uint) -> c_uint { + (__DARWIN_ALIGN32(size_of::()) + length as usize) as c_uint + } + + pub const fn VM_MAKE_TAG(id: u8) -> u32 { + (id as u32) << 24u32 + } +} + +safe_f! { + pub const fn WSTOPSIG(status: c_int) -> c_int { + status >> 8 + } + + pub const fn _WSTATUS(status: c_int) -> c_int { + status & 0x7f + } + + pub const fn WIFCONTINUED(status: c_int) -> bool { + _WSTATUS(status) == _WSTOPPED && WSTOPSIG(status) == 0x13 + } + + pub const fn WIFSIGNALED(status: c_int) -> bool { + _WSTATUS(status) != _WSTOPPED && _WSTATUS(status) != 0 + } + + pub const fn WIFSTOPPED(status: c_int) -> bool { + _WSTATUS(status) == _WSTOPPED && WSTOPSIG(status) != 0x13 + } + + pub const fn makedev(major: i32, minor: i32) -> dev_t { + (major << 24) | minor + } + + pub const fn major(dev: dev_t) -> i32 { + (dev >> 24) & 0xff + } + + pub const fn minor(dev: dev_t) -> i32 { + dev & 0xffffff + } +} + +extern "C" { + pub fn setgrent(); + #[doc(hidden)] + #[deprecated(since = "0.2.49", note = "Deprecated in MacOSX 10.5")] + #[cfg_attr(not(target_arch = "aarch64"), link_name = "daemon$1050")] + pub fn daemon(nochdir: c_int, noclose: c_int) -> c_int; + #[doc(hidden)] + #[deprecated(since = "0.2.49", note = "Deprecated in MacOSX 10.10")] + pub fn sem_destroy(sem: *mut sem_t) -> c_int; + #[doc(hidden)] + #[deprecated(since = "0.2.49", note = "Deprecated in MacOSX 10.10")] + pub fn sem_init(sem: *mut sem_t, pshared: c_int, value: c_uint) -> c_int; + pub fn aio_read(aiocbp: *mut aiocb) -> c_int; + pub fn aio_write(aiocbp: *mut aiocb) -> c_int; + pub fn aio_fsync(op: c_int, aiocbp: *mut aiocb) -> c_int; + pub fn aio_error(aiocbp: *const aiocb) -> c_int; + pub fn aio_return(aiocbp: *mut aiocb) -> ssize_t; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "aio_suspend$UNIX2003" + )] + pub fn aio_suspend( + aiocb_list: *const *const aiocb, + nitems: c_int, + timeout: *const crate::timespec, + ) -> c_int; + pub fn aio_cancel(fd: c_int, aiocbp: *mut aiocb) -> c_int; + pub fn chflags(path: *const c_char, flags: c_uint) -> c_int; + pub fn fchflags(fd: c_int, flags: c_uint) -> c_int; + pub fn clock_getres(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; + pub fn clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; + pub fn lio_listio( + mode: c_int, + aiocb_list: *const *mut aiocb, + nitems: c_int, + sevp: *mut sigevent, + ) -> c_int; + + pub fn dirfd(dirp: *mut crate::DIR) -> c_int; + + pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int; + + pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut c_void) -> c_int; + pub fn getutxent() -> *mut utmpx; + pub fn getutxid(ut: *const utmpx) -> *mut utmpx; + pub fn getutxline(ut: *const utmpx) -> *mut utmpx; + pub fn pututxline(ut: *const utmpx) -> *mut utmpx; + pub fn setutxent(); + pub fn endutxent(); + pub fn utmpxname(file: *const c_char) -> c_int; + + pub fn asctime(tm: *const crate::tm) -> *mut c_char; + pub fn ctime(clock: *const time_t) -> *mut c_char; + pub fn getdate(datestr: *const c_char) -> *mut crate::tm; + pub fn strptime( + buf: *const c_char, + format: *const c_char, + timeptr: *mut crate::tm, + ) -> *mut c_char; + pub fn asctime_r(tm: *const crate::tm, result: *mut c_char) -> *mut c_char; + pub fn ctime_r(clock: *const time_t, result: *mut c_char) -> *mut c_char; + + pub fn getnameinfo( + sa: *const crate::sockaddr, + salen: crate::socklen_t, + host: *mut c_char, + hostlen: crate::socklen_t, + serv: *mut c_char, + servlen: crate::socklen_t, + flags: c_int, + ) -> c_int; + pub fn mincore(addr: *const c_void, len: size_t, vec: *mut c_char) -> c_int; + pub fn sysctlnametomib(name: *const c_char, mibp: *mut c_int, sizep: *mut size_t) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "mprotect$UNIX2003" + )] + pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; + pub fn semget(key: key_t, nsems: c_int, semflg: c_int) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "semctl$UNIX2003" + )] + pub fn semctl(semid: c_int, semnum: c_int, cmd: c_int, ...) -> c_int; + pub fn semop(semid: c_int, sops: *mut sembuf, nsops: size_t) -> c_int; + pub fn shm_open(name: *const c_char, oflag: c_int, ...) -> c_int; + pub fn ftok(pathname: *const c_char, proj_id: c_int) -> key_t; + pub fn shmat(shmid: c_int, shmaddr: *const c_void, shmflg: c_int) -> *mut c_void; + pub fn shmdt(shmaddr: *const c_void) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "shmctl$UNIX2003" + )] + pub fn shmctl(shmid: c_int, cmd: c_int, buf: *mut crate::shmid_ds) -> c_int; + pub fn shmget(key: key_t, size: size_t, shmflg: c_int) -> c_int; + pub fn sysctl( + name: *mut c_int, + namelen: c_uint, + oldp: *mut c_void, + oldlenp: *mut size_t, + newp: *mut c_void, + newlen: size_t, + ) -> c_int; + pub fn sysctlbyname( + name: *const c_char, + oldp: *mut c_void, + oldlenp: *mut size_t, + newp: *mut c_void, + newlen: size_t, + ) -> c_int; + #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] + pub fn mach_absolute_time() -> u64; + #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] + #[allow(deprecated)] + pub fn mach_timebase_info(info: *mut crate::mach_timebase_info) -> c_int; + #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] + pub fn mach_host_self() -> mach_port_t; + #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] + pub fn mach_thread_self() -> mach_port_t; + pub fn pthread_cond_timedwait_relative_np( + cond: *mut crate::pthread_cond_t, + lock: *mut crate::pthread_mutex_t, + timeout: *const crate::timespec, + ) -> c_int; + pub fn pthread_attr_getscope( + attr: *const crate::pthread_attr_t, + contentionscope: *mut c_int, + ) -> c_int; + pub fn pthread_attr_getstackaddr( + attr: *const crate::pthread_attr_t, + stackaddr: *mut *mut c_void, + ) -> c_int; + pub fn pthread_attr_getdetachstate( + attr: *const crate::pthread_attr_t, + detachstate: *mut c_int, + ) -> c_int; + pub fn pthread_attr_setscope(attr: *mut crate::pthread_attr_t, contentionscope: c_int) + -> c_int; + pub fn pthread_attr_setstackaddr( + attr: *mut crate::pthread_attr_t, + stackaddr: *mut c_void, + ) -> c_int; + pub fn pthread_setname_np(name: *const c_char) -> c_int; + pub fn pthread_getname_np(thread: crate::pthread_t, name: *mut c_char, len: size_t) -> c_int; + pub fn pthread_mach_thread_np(thread: crate::pthread_t) -> crate::mach_port_t; + pub fn pthread_from_mach_thread_np(port: crate::mach_port_t) -> crate::pthread_t; + pub fn pthread_get_stackaddr_np(thread: crate::pthread_t) -> *mut c_void; + pub fn pthread_get_stacksize_np(thread: crate::pthread_t) -> size_t; + pub fn pthread_main_np() -> c_int; + pub fn pthread_threadid_np(thread: crate::pthread_t, thread_id: *mut u64) -> c_int; + + pub fn pthread_jit_write_protect_np(enabled: c_int); + pub fn pthread_jit_write_protect_supported_np() -> c_int; + // An array of pthread_jit_write_with_callback_np must declare + // the list of callbacks e.g. + // #[link_section = "__DATA_CONST,__pth_jit_func"] + // static callbacks: [libc::pthread_jit_write_callback_t; 2] = [native_jit_write_cb, + // std::mem::transmute::(std::ptr::null())]; + // (a handy PTHREAD_JIT_WRITE_CALLBACK_NP macro for other languages). + pub fn pthread_jit_write_with_callback_np( + callback: crate::pthread_jit_write_callback_t, + ctx: *mut c_void, + ) -> c_int; + pub fn pthread_jit_write_freeze_callbacks_np(); + pub fn pthread_cpu_number_np(cpu_number_out: *mut size_t) -> c_int; + + // Available starting with macOS 14.4. + pub fn os_sync_wait_on_address( + addr: *mut c_void, + value: u64, + size: size_t, + flags: os_sync_wait_on_address_flags_t, + ) -> c_int; + pub fn os_sync_wait_on_address_with_deadline( + addr: *mut c_void, + value: u64, + size: size_t, + flags: os_sync_wait_on_address_flags_t, + clockid: os_clockid_t, + deadline: u64, + ) -> c_int; + pub fn os_sync_wait_on_address_with_timeout( + addr: *mut c_void, + value: u64, + size: size_t, + flags: os_sync_wait_on_address_flags_t, + clockid: os_clockid_t, + timeout_ns: u64, + ) -> c_int; + pub fn os_sync_wake_by_address_any( + addr: *mut c_void, + size: size_t, + flags: os_sync_wake_by_address_flags_t, + ) -> c_int; + pub fn os_sync_wake_by_address_all( + addr: *mut c_void, + size: size_t, + flags: os_sync_wake_by_address_flags_t, + ) -> c_int; + + pub fn os_unfair_lock_lock(lock: os_unfair_lock_t); + pub fn os_unfair_lock_trylock(lock: os_unfair_lock_t) -> bool; + pub fn os_unfair_lock_unlock(lock: os_unfair_lock_t); + pub fn os_unfair_lock_assert_owner(lock: os_unfair_lock_t); + pub fn os_unfair_lock_assert_not_owner(lock: os_unfair_lock_t); + + pub fn os_log_create(subsystem: *const c_char, category: *const c_char) -> crate::os_log_t; + pub fn os_log_type_enabled(oslog: crate::os_log_t, tpe: crate::os_log_type_t) -> bool; + pub fn os_signpost_id_make_with_pointer( + log: crate::os_log_t, + ptr: *const c_void, + ) -> crate::os_signpost_id_t; + pub fn os_signpost_id_generate(log: crate::os_log_t) -> crate::os_signpost_id_t; + pub fn os_signpost_enabled(log: crate::os_log_t) -> bool; + + pub fn thread_policy_set( + thread: thread_t, + flavor: thread_policy_flavor_t, + policy_info: thread_policy_t, + count: mach_msg_type_number_t, + ) -> kern_return_t; + pub fn thread_policy_get( + thread: thread_t, + flavor: thread_policy_flavor_t, + policy_info: thread_policy_t, + count: *mut mach_msg_type_number_t, + get_default: *mut boolean_t, + ) -> kern_return_t; + pub fn thread_info( + target_act: thread_inspect_t, + flavor: thread_flavor_t, + thread_info_out: thread_info_t, + thread_info_outCnt: *mut mach_msg_type_number_t, + ) -> kern_return_t; + #[cfg_attr(doc, doc(alias = "__errno_location"))] + #[cfg_attr(doc, doc(alias = "errno"))] + pub fn __error() -> *mut c_int; + pub fn backtrace(buf: *mut *mut c_void, sz: c_int) -> c_int; + pub fn backtrace_symbols(addrs: *const *mut c_void, sz: c_int) -> *mut *mut c_char; + pub fn backtrace_symbols_fd(addrs: *const *mut c_void, sz: c_int, fd: c_int); + pub fn backtrace_from_fp(startfp: *mut c_void, array: *mut *mut c_void, size: c_int) -> c_int; + pub fn backtrace_image_offsets( + array: *const *mut c_void, + image_offsets: *mut image_offset, + size: c_int, + ); + pub fn backtrace_async(array: *mut *mut c_void, length: size_t, task_id: *mut u32) -> size_t; + #[cfg_attr( + all(target_os = "macos", not(target_arch = "aarch64")), + link_name = "statfs$INODE64" + )] + pub fn statfs(path: *const c_char, buf: *mut statfs) -> c_int; + #[cfg_attr( + all(target_os = "macos", not(target_arch = "aarch64")), + link_name = "fstatfs$INODE64" + )] + pub fn fstatfs(fd: c_int, buf: *mut statfs) -> c_int; + pub fn kevent( + kq: c_int, + changelist: *const crate::kevent, + nchanges: c_int, + eventlist: *mut crate::kevent, + nevents: c_int, + timeout: *const crate::timespec, + ) -> c_int; + pub fn kevent64( + kq: c_int, + changelist: *const crate::kevent64_s, + nchanges: c_int, + eventlist: *mut crate::kevent64_s, + nevents: c_int, + flags: c_uint, + timeout: *const crate::timespec, + ) -> c_int; + pub fn mount( + src: *const c_char, + target: *const c_char, + flags: c_int, + data: *mut c_void, + ) -> c_int; + pub fn fmount(src: *const c_char, fd: c_int, flags: c_int, data: *mut c_void) -> c_int; + pub fn ptrace(request: c_int, pid: crate::pid_t, addr: *mut c_char, data: c_int) -> c_int; + pub fn quotactl(special: *const c_char, cmd: c_int, id: c_int, data: *mut c_char) -> c_int; + pub fn sethostname(name: *const c_char, len: c_int) -> c_int; + pub fn sendfile( + fd: c_int, + s: c_int, + offset: off_t, + len: *mut off_t, + hdtr: *mut crate::sf_hdtr, + flags: c_int, + ) -> c_int; + pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int; + pub fn utimensat( + dirfd: c_int, + path: *const c_char, + times: *const crate::timespec, + flag: c_int, + ) -> c_int; + pub fn openpty( + amaster: *mut c_int, + aslave: *mut c_int, + name: *mut c_char, + termp: *mut termios, + winp: *mut crate::winsize, + ) -> c_int; + pub fn forkpty( + amaster: *mut c_int, + name: *mut c_char, + termp: *mut termios, + winp: *mut crate::winsize, + ) -> crate::pid_t; + pub fn login_tty(fd: c_int) -> c_int; + pub fn duplocale(base: crate::locale_t) -> crate::locale_t; + pub fn freelocale(loc: crate::locale_t) -> c_int; + pub fn localeconv_l(loc: crate::locale_t) -> *mut lconv; + pub fn newlocale(mask: c_int, locale: *const c_char, base: crate::locale_t) -> crate::locale_t; + pub fn uselocale(loc: crate::locale_t) -> crate::locale_t; + pub fn querylocale(mask: c_int, loc: crate::locale_t) -> *const c_char; + pub fn getpriority(which: c_int, who: crate::id_t) -> c_int; + pub fn setpriority(which: c_int, who: crate::id_t, prio: c_int) -> c_int; + pub fn getdomainname(name: *mut c_char, len: c_int) -> c_int; + pub fn setdomainname(name: *const c_char, len: c_int) -> c_int; + pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t; + pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t; + pub fn getxattr( + path: *const c_char, + name: *const c_char, + value: *mut c_void, + size: size_t, + position: u32, + flags: c_int, + ) -> ssize_t; + pub fn fgetxattr( + filedes: c_int, + name: *const c_char, + value: *mut c_void, + size: size_t, + position: u32, + flags: c_int, + ) -> ssize_t; + pub fn setxattr( + path: *const c_char, + name: *const c_char, + value: *const c_void, + size: size_t, + position: u32, + flags: c_int, + ) -> c_int; + pub fn fsetxattr( + filedes: c_int, + name: *const c_char, + value: *const c_void, + size: size_t, + position: u32, + flags: c_int, + ) -> c_int; + pub fn listxattr(path: *const c_char, list: *mut c_char, size: size_t, flags: c_int) + -> ssize_t; + pub fn flistxattr(filedes: c_int, list: *mut c_char, size: size_t, flags: c_int) -> ssize_t; + pub fn removexattr(path: *const c_char, name: *const c_char, flags: c_int) -> c_int; + pub fn renamex_np(from: *const c_char, to: *const c_char, flags: c_uint) -> c_int; + pub fn renameatx_np( + fromfd: c_int, + from: *const c_char, + tofd: c_int, + to: *const c_char, + flags: c_uint, + ) -> c_int; + pub fn fremovexattr(filedes: c_int, name: *const c_char, flags: c_int) -> c_int; + + pub fn getgrouplist( + name: *const c_char, + basegid: c_int, + groups: *mut c_int, + ngroups: *mut c_int, + ) -> c_int; + pub fn initgroups(user: *const c_char, basegroup: c_int) -> c_int; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "waitid$UNIX2003" + )] + pub fn waitid( + idtype: idtype_t, + id: id_t, + infop: *mut crate::siginfo_t, + options: c_int, + ) -> c_int; + pub fn brk(addr: *const c_void) -> *mut c_void; + pub fn sbrk(increment: c_int) -> *mut c_void; + pub fn settimeofday(tv: *const crate::timeval, tz: *const crate::timezone) -> c_int; + #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] + pub fn _dyld_image_count() -> u32; + #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] + #[allow(deprecated)] + pub fn _dyld_get_image_header(image_index: u32) -> *const mach_header; + #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] + pub fn _dyld_get_image_vmaddr_slide(image_index: u32) -> intptr_t; + #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] + pub fn _dyld_get_image_name(image_index: u32) -> *const c_char; + + pub fn posix_spawn( + pid: *mut crate::pid_t, + path: *const c_char, + file_actions: *const crate::posix_spawn_file_actions_t, + attrp: *const crate::posix_spawnattr_t, + argv: *const *mut c_char, + envp: *const *mut c_char, + ) -> c_int; + pub fn posix_spawnp( + pid: *mut crate::pid_t, + file: *const c_char, + file_actions: *const crate::posix_spawn_file_actions_t, + attrp: *const crate::posix_spawnattr_t, + argv: *const *mut c_char, + envp: *const *mut c_char, + ) -> c_int; + pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> c_int; + pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> c_int; + pub fn posix_spawnattr_getsigdefault( + attr: *const posix_spawnattr_t, + default: *mut crate::sigset_t, + ) -> c_int; + pub fn posix_spawnattr_setsigdefault( + attr: *mut posix_spawnattr_t, + default: *const crate::sigset_t, + ) -> c_int; + pub fn posix_spawnattr_getsigmask( + attr: *const posix_spawnattr_t, + default: *mut crate::sigset_t, + ) -> c_int; + pub fn posix_spawnattr_setsigmask( + attr: *mut posix_spawnattr_t, + default: *const crate::sigset_t, + ) -> c_int; + pub fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t, flags: *mut c_short) -> c_int; + pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t, flags: c_short) -> c_int; + pub fn posix_spawnattr_getpgroup( + attr: *const posix_spawnattr_t, + flags: *mut crate::pid_t, + ) -> c_int; + pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, flags: crate::pid_t) -> c_int; + pub fn posix_spawnattr_setarchpref_np( + attr: *mut posix_spawnattr_t, + count: size_t, + pref: *mut crate::cpu_type_t, + subpref: *mut crate::cpu_subtype_t, + ocount: *mut size_t, + ) -> c_int; + pub fn posix_spawnattr_getarchpref_np( + attr: *const posix_spawnattr_t, + count: size_t, + pref: *mut crate::cpu_type_t, + subpref: *mut crate::cpu_subtype_t, + ocount: *mut size_t, + ) -> c_int; + pub fn posix_spawnattr_getbinpref_np( + attr: *const posix_spawnattr_t, + count: size_t, + pref: *mut crate::cpu_type_t, + ocount: *mut size_t, + ) -> c_int; + pub fn posix_spawnattr_setbinpref_np( + attr: *mut posix_spawnattr_t, + count: size_t, + pref: *mut crate::cpu_type_t, + ocount: *mut size_t, + ) -> c_int; + + pub fn posix_spawn_file_actions_init(actions: *mut posix_spawn_file_actions_t) -> c_int; + pub fn posix_spawn_file_actions_destroy(actions: *mut posix_spawn_file_actions_t) -> c_int; + pub fn posix_spawn_file_actions_addopen( + actions: *mut posix_spawn_file_actions_t, + fd: c_int, + path: *const c_char, + oflag: c_int, + mode: mode_t, + ) -> c_int; + pub fn posix_spawn_file_actions_addclose( + actions: *mut posix_spawn_file_actions_t, + fd: c_int, + ) -> c_int; + pub fn posix_spawn_file_actions_adddup2( + actions: *mut posix_spawn_file_actions_t, + fd: c_int, + newfd: c_int, + ) -> c_int; + pub fn uname(buf: *mut crate::utsname) -> c_int; + + pub fn connectx( + socket: c_int, + endpoints: *const sa_endpoints_t, + associd: sae_associd_t, + flags: c_uint, + iov: *const crate::iovec, + iovcnt: c_uint, + len: *mut size_t, + connid: *mut sae_connid_t, + ) -> c_int; + pub fn disconnectx(socket: c_int, associd: sae_associd_t, connid: sae_connid_t) -> c_int; + + pub fn ntp_adjtime(buf: *mut timex) -> c_int; + pub fn ntp_gettime(buf: *mut ntptimeval) -> c_int; + + #[cfg_attr( + all(target_os = "macos", not(target_arch = "aarch64")), + link_name = "getmntinfo$INODE64" + )] + pub fn getmntinfo(mntbufp: *mut *mut statfs, flags: c_int) -> c_int; + #[cfg_attr( + all(target_os = "macos", not(target_arch = "aarch64")), + link_name = "getfsstat$INODE64" + )] + pub fn getfsstat(mntbufp: *mut statfs, bufsize: c_int, flags: c_int) -> c_int; + + // Copy-on-write functions. + // According to the man page `flags` is an `int` but in the header + // this is a `uint32_t`. + pub fn clonefile(src: *const c_char, dst: *const c_char, flags: u32) -> c_int; + pub fn clonefileat( + src_dirfd: c_int, + src: *const c_char, + dst_dirfd: c_int, + dst: *const c_char, + flags: u32, + ) -> c_int; + pub fn fclonefileat(srcfd: c_int, dst_dirfd: c_int, dst: *const c_char, flags: u32) -> c_int; + + pub fn copyfile( + from: *const c_char, + to: *const c_char, + state: copyfile_state_t, + flags: copyfile_flags_t, + ) -> c_int; + pub fn fcopyfile( + from: c_int, + to: c_int, + state: copyfile_state_t, + flags: copyfile_flags_t, + ) -> c_int; + pub fn copyfile_state_free(s: copyfile_state_t) -> c_int; + pub fn copyfile_state_alloc() -> copyfile_state_t; + pub fn copyfile_state_get(s: copyfile_state_t, flags: u32, dst: *mut c_void) -> c_int; + pub fn copyfile_state_set(s: copyfile_state_t, flags: u32, src: *const c_void) -> c_int; + + pub fn mach_error_string(error_value: crate::mach_error_t) -> *mut c_char; + + // Added in macOS 10.13 + // ISO/IEC 9899:2011 ("ISO C11") K.3.7.4.1 + pub fn memset_s(s: *mut c_void, smax: size_t, c: c_int, n: size_t) -> c_int; + // Added in macOS 10.5 + pub fn memset_pattern4(b: *mut c_void, pattern4: *const c_void, len: size_t); + pub fn memset_pattern8(b: *mut c_void, pattern8: *const c_void, len: size_t); + pub fn memset_pattern16(b: *mut c_void, pattern16: *const c_void, len: size_t); + + // Inherited from BSD but available from Big Sur only + pub fn strtonum( + __numstr: *const c_char, + __minval: c_longlong, + __maxval: c_longlong, + errstrp: *mut *const c_char, + ) -> c_longlong; + + pub fn mstats() -> mstats; + pub fn malloc_printf(format: *const c_char, ...); + pub fn malloc_zone_check(zone: *mut crate::malloc_zone_t) -> crate::boolean_t; + pub fn malloc_zone_print(zone: *mut crate::malloc_zone_t, verbose: crate::boolean_t); + pub fn malloc_zone_statistics(zone: *mut crate::malloc_zone_t, stats: *mut malloc_statistics_t); + pub fn malloc_zone_log(zone: *mut crate::malloc_zone_t, address: *mut c_void); + pub fn malloc_zone_print_ptr_info(ptr: *mut c_void); + pub fn malloc_default_zone() -> *mut crate::malloc_zone_t; + pub fn malloc_zone_from_ptr(ptr: *const c_void) -> *mut crate::malloc_zone_t; + pub fn malloc_zone_malloc(zone: *mut crate::malloc_zone_t, size: size_t) -> *mut c_void; + pub fn malloc_zone_valloc(zone: *mut crate::malloc_zone_t, size: size_t) -> *mut c_void; + pub fn malloc_zone_calloc( + zone: *mut crate::malloc_zone_t, + num_items: size_t, + size: size_t, + ) -> *mut c_void; + pub fn malloc_zone_realloc( + zone: *mut crate::malloc_zone_t, + ptr: *mut c_void, + size: size_t, + ) -> *mut c_void; + pub fn malloc_zone_free(zone: *mut crate::malloc_zone_t, ptr: *mut c_void); + + pub fn proc_listpids(t: u32, typeinfo: u32, buffer: *mut c_void, buffersize: c_int) -> c_int; + pub fn proc_listallpids(buffer: *mut c_void, buffersize: c_int) -> c_int; + pub fn proc_listpgrppids(pgrpid: crate::pid_t, buffer: *mut c_void, buffersize: c_int) + -> c_int; + pub fn proc_listchildpids(ppid: crate::pid_t, buffer: *mut c_void, buffersize: c_int) -> c_int; + pub fn proc_pidinfo( + pid: c_int, + flavor: c_int, + arg: u64, + buffer: *mut c_void, + buffersize: c_int, + ) -> c_int; + pub fn proc_pidfdinfo( + pid: c_int, + fd: c_int, + flavor: c_int, + buffer: *mut c_void, + buffersize: c_int, + ) -> c_int; + pub fn proc_pidfileportinfo( + pid: c_int, + fileport: u32, + flavor: c_int, + buffer: *mut c_void, + buffersize: c_int, + ) -> c_int; + pub fn proc_pidpath(pid: c_int, buffer: *mut c_void, buffersize: u32) -> c_int; + pub fn proc_name(pid: c_int, buffer: *mut c_void, buffersize: u32) -> c_int; + pub fn proc_regionfilename( + pid: c_int, + address: u64, + buffer: *mut c_void, + buffersize: u32, + ) -> c_int; + pub fn proc_kmsgbuf(buffer: *mut c_void, buffersize: u32) -> c_int; + pub fn proc_libversion(major: *mut c_int, minor: *mut c_int) -> c_int; + pub fn proc_pid_rusage(pid: c_int, flavor: c_int, buffer: *mut rusage_info_t) -> c_int; + + // Available from Big Sur + pub fn proc_set_no_smt() -> c_int; + pub fn proc_setthread_no_smt() -> c_int; + pub fn proc_set_csm(flags: u32) -> c_int; + pub fn proc_setthread_csm(flags: u32) -> c_int; + /// # Notes + /// + /// `id` is of type [`uuid_t`]. + pub fn gethostuuid(id: *mut u8, timeout: *const crate::timespec) -> c_int; + + pub fn gethostid() -> c_long; + pub fn sethostid(hostid: c_long); + + pub fn CCRandomGenerateBytes(bytes: *mut c_void, size: size_t) -> crate::CCRNGStatus; + pub fn getentropy(buf: *mut c_void, buflen: size_t) -> c_int; + + // FIXME(1.0): should this actually be deprecated? + #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] + pub fn _NSGetExecutablePath(buf: *mut c_char, bufsize: *mut u32) -> c_int; + + // crt_externs.h + pub fn _NSGetArgv() -> *mut *mut *mut c_char; + pub fn _NSGetArgc() -> *mut c_int; + pub fn _NSGetEnviron() -> *mut *mut *mut c_char; + pub fn _NSGetProgname() -> *mut *mut c_char; + + #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] + pub fn mach_vm_map( + target_task: crate::vm_map_t, + address: *mut crate::mach_vm_address_t, + size: crate::mach_vm_size_t, + mask: crate::mach_vm_offset_t, + flags: c_int, + object: crate::mem_entry_name_port_t, + offset: crate::memory_object_offset_t, + copy: crate::boolean_t, + cur_protection: crate::vm_prot_t, + max_protection: crate::vm_prot_t, + inheritance: crate::vm_inherit_t, + ) -> crate::kern_return_t; + + pub fn vm_allocate( + target_task: vm_map_t, + address: *mut vm_address_t, + size: vm_size_t, + flags: c_int, + ) -> crate::kern_return_t; + + pub fn vm_deallocate( + target_task: vm_map_t, + address: vm_address_t, + size: vm_size_t, + ) -> crate::kern_return_t; + + pub fn host_statistics64( + host_priv: host_t, + flavor: host_flavor_t, + host_info64_out: host_info64_t, + host_info64_outCnt: *mut mach_msg_type_number_t, + ) -> crate::kern_return_t; + pub fn host_processor_info( + host: host_t, + flavor: processor_flavor_t, + out_processor_count: *mut natural_t, + out_processor_info: *mut processor_info_array_t, + out_processor_infoCnt: *mut mach_msg_type_number_t, + ) -> crate::kern_return_t; + + #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] + pub static mut mach_task_self_: crate::mach_port_t; + pub fn task_for_pid( + host: crate::mach_port_t, + pid: crate::pid_t, + task: *mut crate::mach_port_t, + ) -> crate::kern_return_t; + pub fn task_info( + host: crate::mach_port_t, + flavor: task_flavor_t, + task_info_out: task_info_t, + task_info_count: *mut mach_msg_type_number_t, + ) -> crate::kern_return_t; + pub fn task_create( + target_task: crate::task_t, + ledgers: crate::ledger_array_t, + ledgersCnt: crate::mach_msg_type_number_t, + inherit_memory: crate::boolean_t, + child_task: *mut crate::task_t, + ) -> crate::kern_return_t; + pub fn task_terminate(target_task: crate::task_t) -> crate::kern_return_t; + pub fn task_threads( + target_task: crate::task_inspect_t, + act_list: *mut crate::thread_act_array_t, + act_listCnt: *mut crate::mach_msg_type_number_t, + ) -> crate::kern_return_t; + pub fn host_statistics( + host_priv: host_t, + flavor: host_flavor_t, + host_info_out: host_info_t, + host_info_outCnt: *mut mach_msg_type_number_t, + ) -> crate::kern_return_t; + + // sysdir.h + pub fn sysdir_start_search_path_enumeration( + dir: sysdir_search_path_directory_t, + domainMask: sysdir_search_path_domain_mask_t, + ) -> crate::sysdir_search_path_enumeration_state; + pub fn sysdir_get_next_search_path_enumeration( + state: crate::sysdir_search_path_enumeration_state, + path: *mut c_char, + ) -> crate::sysdir_search_path_enumeration_state; + + pub static vm_page_size: vm_size_t; + + pub fn getattrlist( + path: *const c_char, + attrList: *mut c_void, + attrBuf: *mut c_void, + attrBufSize: size_t, + options: u32, + ) -> c_int; + pub fn fgetattrlist( + fd: c_int, + attrList: *mut c_void, + attrBuf: *mut c_void, + attrBufSize: size_t, + options: u32, + ) -> c_int; + pub fn getattrlistat( + fd: c_int, + path: *const c_char, + attrList: *mut c_void, + attrBuf: *mut c_void, + attrBufSize: size_t, + options: c_ulong, + ) -> c_int; + pub fn setattrlist( + path: *const c_char, + attrList: *mut c_void, + attrBuf: *mut c_void, + attrBufSize: size_t, + options: u32, + ) -> c_int; + pub fn fsetattrlist( + fd: c_int, + attrList: *mut c_void, + attrBuf: *mut c_void, + attrBufSize: size_t, + options: u32, + ) -> c_int; + pub fn setattrlistat( + dir_fd: c_int, + path: *const c_char, + attrList: *mut c_void, + attrBuf: *mut c_void, + attrBufSize: size_t, + options: u32, + ) -> c_int; + pub fn getattrlistbulk( + dirfd: c_int, + attrList: *mut c_void, + attrBuf: *mut c_void, + attrBufSize: size_t, + options: u64, + ) -> c_int; + + pub fn malloc_size(ptr: *const c_void) -> size_t; + pub fn malloc_good_size(size: size_t) -> size_t; + + pub fn dirname(path: *mut c_char) -> *mut c_char; + pub fn basename(path: *mut c_char) -> *mut c_char; + + pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; + pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; + pub fn freadlink(fd: c_int, buf: *mut c_char, size: size_t) -> c_int; + pub fn execvP( + file: *const c_char, + search_path: *const c_char, + argv: *const *mut c_char, + ) -> c_int; + + pub fn qsort_r( + base: *mut c_void, + num: size_t, + size: size_t, + arg: *mut c_void, + compar: Option c_int>, + ); +} + +#[allow(deprecated)] +#[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] +pub unsafe fn mach_task_self() -> crate::mach_port_t { + mach_task_self_ +} + +cfg_if! { + if #[cfg(target_os = "macos")] { + extern "C" { + pub fn clock_settime(clock_id: crate::clockid_t, tp: *const crate::timespec) -> c_int; + } + } +} +cfg_if! { + if #[cfg(any( + target_os = "macos", + target_os = "ios", + target_os = "tvos", + target_os = "visionos" + ))] { + extern "C" { + pub fn memmem( + haystack: *const c_void, + haystacklen: size_t, + needle: *const c_void, + needlelen: size_t, + ) -> *mut c_void; + pub fn task_set_info( + target_task: crate::task_t, + flavor: crate::task_flavor_t, + task_info_in: crate::task_info_t, + task_info_inCnt: crate::mach_msg_type_number_t, + ) -> crate::kern_return_t; + } + } +} + +// These require a dependency on `libiconv`, and including this when built as +// part of `std` means every Rust program gets it. Ideally we would have a link +// modifier to only include these if they are used, but we do not. +#[cfg_attr(not(feature = "rustc-dep-of-std"), link(name = "iconv"))] +extern "C" { + #[deprecated(note = "Will be removed in 1.0 to avoid the `iconv` dependency")] + pub fn iconv_open(tocode: *const c_char, fromcode: *const c_char) -> iconv_t; + #[deprecated(note = "Will be removed in 1.0 to avoid the `iconv` dependency")] + pub fn iconv( + cd: iconv_t, + inbuf: *mut *mut c_char, + inbytesleft: *mut size_t, + outbuf: *mut *mut c_char, + outbytesleft: *mut size_t, + ) -> size_t; + #[deprecated(note = "Will be removed in 1.0 to avoid the `iconv` dependency")] + pub fn iconv_close(cd: iconv_t) -> c_int; +} + +cfg_if! { + if #[cfg(target_pointer_width = "32")] { + mod b32; + pub use self::b32::*; + } else if #[cfg(target_pointer_width = "64")] { + mod b64; + pub use self::b64::*; + } else { + // Unknown target_arch + } +} diff --git a/http/vendor/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/http/vendor/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs new file mode 100644 index 0000000..60e7989 --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -0,0 +1,1374 @@ +use crate::prelude::*; +use crate::{ + cmsghdr, + off_t, +}; + +pub type dev_t = u32; +pub type wchar_t = i32; +pub type clock_t = u64; +pub type ino_t = u64; +pub type lwpid_t = i32; +pub type nlink_t = u32; +pub type blksize_t = i64; +pub type clockid_t = c_ulong; + +pub type time_t = i64; +pub type suseconds_t = i64; + +pub type uuid_t = crate::uuid; + +pub type fsblkcnt_t = u64; +pub type fsfilcnt_t = u64; +pub type idtype_t = c_uint; +pub type shmatt_t = c_uint; + +pub type mqd_t = c_int; +pub type sem_t = *mut sem; + +pub type cpuset_t = cpumask_t; +pub type cpu_set_t = cpumask_t; + +pub type register_t = c_long; +pub type umtx_t = c_int; +pub type pthread_barrierattr_t = c_int; +pub type pthread_barrier_t = crate::uintptr_t; +pub type pthread_spinlock_t = crate::uintptr_t; + +pub type segsz_t = usize; + +pub type vm_prot_t = u8; +pub type vm_maptype_t = u8; +pub type vm_inherit_t = i8; +pub type vm_subsys_t = c_int; +pub type vm_eflags_t = c_uint; + +pub type vm_map_t = *mut __c_anonymous_vm_map; +pub type vm_map_entry_t = *mut vm_map_entry; + +pub type pmap = __c_anonymous_pmap; + +extern_ty! { + pub enum sem {} +} + +e! { + #[repr(u32)] + pub enum lwpstat { + LSRUN = 1, + LSSTOP = 2, + LSSLEEP = 3, + } + + #[repr(u32)] + pub enum procstat { + SIDL = 1, + SACTIVE = 2, + SSTOP = 3, + SZOMB = 4, + SCORE = 5, + } +} + +s! { + pub struct kevent { + pub ident: crate::uintptr_t, + pub filter: c_short, + pub flags: c_ushort, + pub fflags: c_uint, + pub data: intptr_t, + pub udata: *mut c_void, + } + + pub struct exit_status { + pub e_termination: u16, + pub e_exit: u16, + } + + pub struct aiocb { + pub aio_fildes: c_int, + pub aio_offset: off_t, + pub aio_buf: *mut c_void, + pub aio_nbytes: size_t, + pub aio_sigevent: sigevent, + pub aio_lio_opcode: c_int, + pub aio_reqprio: c_int, + _aio_val: c_int, + _aio_err: c_int, + } + + pub struct uuid { + pub time_low: u32, + pub time_mid: u16, + pub time_hi_and_version: u16, + clock_seq_hi_and_reserved: Padding, + pub clock_seq_low: u8, + pub node: [u8; 6], + } + + pub struct mq_attr { + pub mq_flags: c_long, + pub mq_maxmsg: c_long, + pub mq_msgsize: c_long, + pub mq_curmsgs: c_long, + } + + pub struct statvfs { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_favail: crate::fsfilcnt_t, + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + pub f_owner: crate::uid_t, + pub f_type: c_uint, + pub f_syncreads: u64, + pub f_syncwrites: u64, + pub f_asyncreads: u64, + pub f_asyncwrites: u64, + pub f_fsid_uuid: crate::uuid_t, + pub f_uid_uuid: crate::uuid_t, + } + + pub struct stat { + pub st_ino: crate::ino_t, + pub st_nlink: crate::nlink_t, + pub st_dev: crate::dev_t, + pub st_mode: crate::mode_t, + st_padding1: Padding, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + pub st_size: off_t, + pub st_blocks: i64, + pub __old_st_blksize: u32, + pub st_flags: u32, + pub st_gen: u32, + pub st_lspare: i32, + pub st_blksize: i64, + pub st_qspare2: i64, + } + + pub struct if_data { + pub ifi_type: c_uchar, + pub ifi_physical: c_uchar, + pub ifi_addrlen: c_uchar, + pub ifi_hdrlen: c_uchar, + pub ifi_recvquota: c_uchar, + pub ifi_xmitquota: c_uchar, + pub ifi_mtu: c_ulong, + pub ifi_metric: c_ulong, + pub ifi_link_state: c_ulong, + pub ifi_baudrate: u64, + pub ifi_ipackets: c_ulong, + pub ifi_ierrors: c_ulong, + pub ifi_opackets: c_ulong, + pub ifi_oerrors: c_ulong, + pub ifi_collisions: c_ulong, + pub ifi_ibytes: c_ulong, + pub ifi_obytes: c_ulong, + pub ifi_imcasts: c_ulong, + pub ifi_omcasts: c_ulong, + pub ifi_iqdrops: c_ulong, + pub ifi_noproto: c_ulong, + pub ifi_hwassist: c_ulong, + pub ifi_oqdrops: c_ulong, + pub ifi_lastchange: crate::timeval, + } + + pub struct if_msghdr { + pub ifm_msglen: c_ushort, + pub ifm_version: c_uchar, + pub ifm_type: c_uchar, + pub ifm_addrs: c_int, + pub ifm_flags: c_int, + pub ifm_index: c_ushort, + pub ifm_data: if_data, + } + + pub struct sockaddr_dl { + pub sdl_len: c_uchar, + pub sdl_family: c_uchar, + pub sdl_index: c_ushort, + pub sdl_type: c_uchar, + pub sdl_nlen: c_uchar, + pub sdl_alen: c_uchar, + pub sdl_slen: c_uchar, + pub sdl_data: [c_char; 12], + pub sdl_rcf: c_ushort, + pub sdl_route: [c_ushort; 16], + } + + pub struct xucred { + pub cr_version: c_uint, + pub cr_uid: crate::uid_t, + pub cr_ngroups: c_short, + pub cr_groups: [crate::gid_t; 16], + __cr_unused1: Padding<*mut c_void>, + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_size: size_t, + pub ss_flags: c_int, + } + + pub struct cpumask_t { + ary: [u64; 4], + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, + pub shm_lpid: crate::pid_t, + pub shm_cpid: crate::pid_t, + pub shm_nattch: crate::shmatt_t, + pub shm_atime: crate::time_t, + pub shm_dtime: crate::time_t, + pub shm_ctime: crate::time_t, + shm_internal: *mut c_void, + } + + pub struct kinfo_file { + pub f_size: size_t, + pub f_pid: crate::pid_t, + pub f_uid: crate::uid_t, + pub f_fd: c_int, + pub f_file: *mut c_void, + pub f_type: c_short, + pub f_count: c_int, + pub f_msgcount: c_int, + pub f_offset: off_t, + pub f_data: *mut c_void, + pub f_flag: c_uint, + } + + pub struct kinfo_cputime { + pub cp_user: u64, + pub cp_nice: u64, + pub cp_sys: u64, + pub cp_intr: u64, + pub cp_idel: u64, + cp_unused01: Padding, + cp_unused02: Padding, + pub cp_sample_pc: u64, + pub cp_sample_sp: u64, + pub cp_msg: [c_char; 32], + } + + pub struct kinfo_lwp { + pub kl_pid: crate::pid_t, + pub kl_tid: crate::lwpid_t, + pub kl_flags: c_int, + pub kl_stat: crate::lwpstat, + pub kl_lock: c_int, + pub kl_tdflags: c_int, + pub kl_mpcount: c_int, + pub kl_prio: c_int, + pub kl_tdprio: c_int, + pub kl_rtprio: crate::rtprio, + pub kl_uticks: u64, + pub kl_sticks: u64, + pub kl_iticks: u64, + pub kl_cpticks: u64, + pub kl_pctcpu: c_uint, + pub kl_slptime: c_uint, + pub kl_origcpu: c_int, + pub kl_estcpu: c_int, + pub kl_cpuid: c_int, + pub kl_ru: crate::rusage, + pub kl_siglist: crate::sigset_t, + pub kl_sigmask: crate::sigset_t, + pub kl_wchan: crate::uintptr_t, + pub kl_wmesg: [c_char; 9], + pub kl_comm: [c_char; MAXCOMLEN + 1], + } + + pub struct kinfo_proc { + pub kp_paddr: crate::uintptr_t, + pub kp_flags: c_int, + pub kp_stat: crate::procstat, + pub kp_lock: c_int, + pub kp_acflag: c_int, + pub kp_traceflag: c_int, + pub kp_fd: crate::uintptr_t, + pub kp_siglist: crate::sigset_t, + pub kp_sigignore: crate::sigset_t, + pub kp_sigcatch: crate::sigset_t, + pub kp_sigflag: c_int, + pub kp_start: crate::timeval, + pub kp_comm: [c_char; MAXCOMLEN + 1], + pub kp_uid: crate::uid_t, + pub kp_ngroups: c_short, + pub kp_groups: [crate::gid_t; NGROUPS], + pub kp_ruid: crate::uid_t, + pub kp_svuid: crate::uid_t, + pub kp_rgid: crate::gid_t, + pub kp_svgid: crate::gid_t, + pub kp_pid: crate::pid_t, + pub kp_ppid: crate::pid_t, + pub kp_pgid: crate::pid_t, + pub kp_jobc: c_int, + pub kp_sid: crate::pid_t, + pub kp_login: [c_char; 40], // MAXNAMELEN rounded up to the nearest sizeof(long) + pub kp_tdev: crate::dev_t, + pub kp_tpgid: crate::pid_t, + pub kp_tsid: crate::pid_t, + pub kp_exitstat: c_ushort, + pub kp_nthreads: c_int, + pub kp_nice: c_int, + pub kp_swtime: c_uint, + pub kp_vm_map_size: size_t, + pub kp_vm_rssize: crate::segsz_t, + pub kp_vm_swrss: crate::segsz_t, + pub kp_vm_tsize: crate::segsz_t, + pub kp_vm_dsize: crate::segsz_t, + pub kp_vm_ssize: crate::segsz_t, + pub kp_vm_prssize: c_uint, + pub kp_jailid: c_int, + pub kp_ru: crate::rusage, + pub kp_cru: crate::rusage, + pub kp_auxflags: c_int, + pub kp_lwp: crate::kinfo_lwp, + pub kp_ktaddr: crate::uintptr_t, + kp_spare: [c_int; 2], + } + + pub struct __c_anonymous_vm_map { + _priv: [crate::uintptr_t; 36], + } + + pub struct vm_map_entry { + _priv: [crate::uintptr_t; 15], + pub eflags: crate::vm_eflags_t, + pub maptype: crate::vm_maptype_t, + pub protection: crate::vm_prot_t, + pub max_protection: crate::vm_prot_t, + pub inheritance: crate::vm_inherit_t, + pub wired_count: c_int, + pub id: crate::vm_subsys_t, + } + + pub struct __c_anonymous_pmap { + _priv1: [crate::uintptr_t; 32], + _priv2: [crate::uintptr_t; 32], + _priv3: [crate::uintptr_t; 32], + _priv4: [crate::uintptr_t; 32], + _priv5: [crate::uintptr_t; 8], + } + + pub struct vmspace { + vm_map: __c_anonymous_vm_map, + vm_pmap: __c_anonymous_pmap, + pub vm_flags: c_int, + pub vm_shm: *mut c_char, + pub vm_rssize: crate::segsz_t, + pub vm_swrss: crate::segsz_t, + pub vm_tsize: crate::segsz_t, + pub vm_dsize: crate::segsz_t, + pub vm_ssize: crate::segsz_t, + pub vm_taddr: *mut c_char, + pub vm_daddr: *mut c_char, + pub vm_maxsaddr: *mut c_char, + pub vm_minsaddr: *mut c_char, + _unused1: Padding, + _unused2: Padding, + pub vm_pagesupply: c_int, + pub vm_holdcnt: c_uint, + pub vm_refcnt: c_uint, + } + + pub struct cpuctl_msr_args_t { + pub msr: c_int, + pub data: u64, + } + + pub struct cpuctl_cpuid_args_t { + pub level: c_int, + pub data: [u32; 4], + } + + pub struct cpuctl_cpuid_count_args_t { + pub level: c_int, + pub level_type: c_int, + pub data: [u32; 4], + } + + pub struct cpuctl_update_args_t { + pub data: *mut c_void, + pub size: size_t, + } + + pub struct utmpx { + pub ut_name: [c_char; 32], + pub ut_id: [c_char; 4], + + pub ut_line: [c_char; 32], + pub ut_host: [c_char; 256], + + ut_unused: Padding<[u8; 16]>, + pub ut_session: u16, + pub ut_type: u16, + pub ut_pid: crate::pid_t, + ut_exit: exit_status, + ut_ss: crate::sockaddr_storage, + pub ut_tv: crate::timeval, + ut_unused2: Padding<[u8; 16]>, + } + + pub struct lastlogx { + pub ll_tv: crate::timeval, + pub ll_line: [c_char; _UTX_LINESIZE], + pub ll_host: [c_char; _UTX_HOSTSIZE], + pub ll_ss: crate::sockaddr_storage, + } + + pub struct dirent { + pub d_fileno: crate::ino_t, + pub d_namlen: u16, + pub d_type: u8, + __unused1: Padding, + __unused2: Padding, + pub d_name: [c_char; 256], + } + + pub struct statfs { + __spare2: c_long, + pub f_bsize: c_long, + pub f_iosize: c_long, + pub f_blocks: c_long, + pub f_bfree: c_long, + pub f_bavail: c_long, + pub f_files: c_long, + pub f_ffree: c_long, + pub f_fsid: crate::fsid_t, + pub f_owner: crate::uid_t, + pub f_type: c_int, + pub f_flags: c_int, + pub f_syncwrites: c_long, + pub f_asyncwrites: c_long, + pub f_fstypename: [c_char; 16], + pub f_mntonname: [c_char; 80], + pub f_syncreads: c_long, + pub f_asyncreads: c_long, + __spares1: c_short, + pub f_mntfromname: [c_char; 80], + __spares2: c_short, + __spare: [c_long; 2], + } + + pub struct sigevent { + pub sigev_notify: c_int, + // The union is 8-byte in size, so it is aligned at a 8-byte offset. + #[cfg(target_pointer_width = "64")] + __unused1: Padding, + pub sigev_signo: c_int, //actually a union + // pad the union + #[cfg(target_pointer_width = "64")] + __unused2: Padding, + pub sigev_value: crate::sigval, + __unused3: Padding<*mut c_void>, //actually a function pointer + } + + pub struct mcontext_t { + pub mc_onstack: register_t, + pub mc_rdi: register_t, + pub mc_rsi: register_t, + pub mc_rdx: register_t, + pub mc_rcx: register_t, + pub mc_r8: register_t, + pub mc_r9: register_t, + pub mc_rax: register_t, + pub mc_rbx: register_t, + pub mc_rbp: register_t, + pub mc_r10: register_t, + pub mc_r11: register_t, + pub mc_r12: register_t, + pub mc_r13: register_t, + pub mc_r14: register_t, + pub mc_r15: register_t, + pub mc_xflags: register_t, + pub mc_trapno: register_t, + pub mc_addr: register_t, + pub mc_flags: register_t, + pub mc_err: register_t, + pub mc_rip: register_t, + pub mc_cs: register_t, + pub mc_rflags: register_t, + pub mc_rsp: register_t, + pub mc_ss: register_t, + pub mc_len: c_uint, + pub mc_fpformat: c_uint, + pub mc_ownedfp: c_uint, + __reserved: Padding, + __unused: Padding<[c_uint; 8]>, + pub mc_fpregs: [c_uint; 256], + } + + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct ucontext_t { + pub uc_sigmask: crate::sigset_t, + pub uc_mcontext: mcontext_t, + pub uc_link: *mut ucontext_t, + pub uc_stack: stack_t, + pub uc_cofunc: Option, + pub uc_arg: *mut c_void, + __pad: Padding<[c_int; 4]>, + } +} + +pub const RAND_MAX: c_int = 0x7fff_ffff; +pub const PTHREAD_STACK_MIN: size_t = 16384; +pub const SIGSTKSZ: size_t = 40960; +pub const SIGCKPT: c_int = 33; +pub const SIGCKPTEXIT: c_int = 34; +pub const CKPT_FREEZE: c_int = 0x1; +pub const CKPT_THAW: c_int = 0x2; +pub const MADV_INVAL: c_int = 10; +pub const MADV_SETMAP: c_int = 11; +pub const O_CLOEXEC: c_int = 0x00020000; +pub const O_DIRECTORY: c_int = 0x08000000; +pub const F_GETLK: c_int = 7; +pub const F_SETLK: c_int = 8; +pub const F_SETLKW: c_int = 9; +pub const F_GETPATH: c_int = 19; +pub const ENOMEDIUM: c_int = 93; +pub const ENOTRECOVERABLE: c_int = 94; +pub const EOWNERDEAD: c_int = 95; +pub const EASYNC: c_int = 99; +pub const ELAST: c_int = 99; +pub const RLIMIT_POSIXLOCKS: c_int = 11; +#[deprecated(since = "0.2.64", note = "Not stable across OS versions")] +pub const RLIM_NLIMITS: crate::rlim_t = 12; + +pub const Q_GETQUOTA: c_int = 0x300; +pub const Q_SETQUOTA: c_int = 0x400; + +pub const CTL_UNSPEC: c_int = 0; +pub const CTL_KERN: c_int = 1; +pub const CTL_VM: c_int = 2; +pub const CTL_VFS: c_int = 3; +pub const CTL_NET: c_int = 4; +pub const CTL_DEBUG: c_int = 5; +pub const CTL_HW: c_int = 6; +pub const CTL_MACHDEP: c_int = 7; +pub const CTL_USER: c_int = 8; +pub const CTL_P1003_1B: c_int = 9; +pub const CTL_LWKT: c_int = 10; +pub const CTL_MAXID: c_int = 11; +pub const KERN_OSTYPE: c_int = 1; +pub const KERN_OSRELEASE: c_int = 2; +pub const KERN_OSREV: c_int = 3; +pub const KERN_VERSION: c_int = 4; +pub const KERN_MAXVNODES: c_int = 5; +pub const KERN_MAXPROC: c_int = 6; +pub const KERN_MAXFILES: c_int = 7; +pub const KERN_ARGMAX: c_int = 8; +pub const KERN_SECURELVL: c_int = 9; +pub const KERN_HOSTNAME: c_int = 10; +pub const KERN_HOSTID: c_int = 11; +pub const KERN_CLOCKRATE: c_int = 12; +pub const KERN_VNODE: c_int = 13; +pub const KERN_PROC: c_int = 14; +pub const KERN_FILE: c_int = 15; +pub const KERN_PROF: c_int = 16; +pub const KERN_POSIX1: c_int = 17; +pub const KERN_NGROUPS: c_int = 18; +pub const KERN_JOB_CONTROL: c_int = 19; +pub const KERN_SAVED_IDS: c_int = 20; +pub const KERN_BOOTTIME: c_int = 21; +pub const KERN_NISDOMAINNAME: c_int = 22; +pub const KERN_UPDATEINTERVAL: c_int = 23; +pub const KERN_OSRELDATE: c_int = 24; +pub const KERN_NTP_PLL: c_int = 25; +pub const KERN_BOOTFILE: c_int = 26; +pub const KERN_MAXFILESPERPROC: c_int = 27; +pub const KERN_MAXPROCPERUID: c_int = 28; +pub const KERN_DUMPDEV: c_int = 29; +pub const KERN_IPC: c_int = 30; +pub const KERN_DUMMY: c_int = 31; +pub const KERN_PS_STRINGS: c_int = 32; +pub const KERN_USRSTACK: c_int = 33; +pub const KERN_LOGSIGEXIT: c_int = 34; +pub const KERN_IOV_MAX: c_int = 35; +pub const KERN_MAXPOSIXLOCKSPERUID: c_int = 36; +pub const KERN_MAXID: c_int = 37; +pub const KERN_PROC_ALL: c_int = 0; +pub const KERN_PROC_PID: c_int = 1; +pub const KERN_PROC_PGRP: c_int = 2; +pub const KERN_PROC_SESSION: c_int = 3; +pub const KERN_PROC_TTY: c_int = 4; +pub const KERN_PROC_UID: c_int = 5; +pub const KERN_PROC_RUID: c_int = 6; +pub const KERN_PROC_ARGS: c_int = 7; +pub const KERN_PROC_CWD: c_int = 8; +pub const KERN_PROC_PATHNAME: c_int = 9; +pub const KERN_PROC_FLAGMASK: c_int = 0x10; +pub const KERN_PROC_FLAG_LWP: c_int = 0x10; +pub const KIPC_MAXSOCKBUF: c_int = 1; +pub const KIPC_SOCKBUF_WASTE: c_int = 2; +pub const KIPC_SOMAXCONN: c_int = 3; +pub const KIPC_MAX_LINKHDR: c_int = 4; +pub const KIPC_MAX_PROTOHDR: c_int = 5; +pub const KIPC_MAX_HDR: c_int = 6; +pub const KIPC_MAX_DATALEN: c_int = 7; +pub const KIPC_MBSTAT: c_int = 8; +pub const KIPC_NMBCLUSTERS: c_int = 9; +pub const HW_MACHINE: c_int = 1; +pub const HW_MODEL: c_int = 2; +pub const HW_NCPU: c_int = 3; +pub const HW_BYTEORDER: c_int = 4; +pub const HW_PHYSMEM: c_int = 5; +pub const HW_USERMEM: c_int = 6; +pub const HW_PAGESIZE: c_int = 7; +pub const HW_DISKNAMES: c_int = 8; +pub const HW_DISKSTATS: c_int = 9; +pub const HW_FLOATINGPT: c_int = 10; +pub const HW_MACHINE_ARCH: c_int = 11; +pub const HW_MACHINE_PLATFORM: c_int = 12; +pub const HW_SENSORS: c_int = 13; +pub const HW_MAXID: c_int = 14; +pub const USER_CS_PATH: c_int = 1; +pub const USER_BC_BASE_MAX: c_int = 2; +pub const USER_BC_DIM_MAX: c_int = 3; +pub const USER_BC_SCALE_MAX: c_int = 4; +pub const USER_BC_STRING_MAX: c_int = 5; +pub const USER_COLL_WEIGHTS_MAX: c_int = 6; +pub const USER_EXPR_NEST_MAX: c_int = 7; +pub const USER_LINE_MAX: c_int = 8; +pub const USER_RE_DUP_MAX: c_int = 9; +pub const USER_POSIX2_VERSION: c_int = 10; +pub const USER_POSIX2_C_BIND: c_int = 11; +pub const USER_POSIX2_C_DEV: c_int = 12; +pub const USER_POSIX2_CHAR_TERM: c_int = 13; +pub const USER_POSIX2_FORT_DEV: c_int = 14; +pub const USER_POSIX2_FORT_RUN: c_int = 15; +pub const USER_POSIX2_LOCALEDEF: c_int = 16; +pub const USER_POSIX2_SW_DEV: c_int = 17; +pub const USER_POSIX2_UPE: c_int = 18; +pub const USER_STREAM_MAX: c_int = 19; +pub const USER_TZNAME_MAX: c_int = 20; +pub const USER_MAXID: c_int = 21; +pub const CTL_P1003_1B_ASYNCHRONOUS_IO: c_int = 1; +pub const CTL_P1003_1B_MAPPED_FILES: c_int = 2; +pub const CTL_P1003_1B_MEMLOCK: c_int = 3; +pub const CTL_P1003_1B_MEMLOCK_RANGE: c_int = 4; +pub const CTL_P1003_1B_MEMORY_PROTECTION: c_int = 5; +pub const CTL_P1003_1B_MESSAGE_PASSING: c_int = 6; +pub const CTL_P1003_1B_PRIORITIZED_IO: c_int = 7; +pub const CTL_P1003_1B_PRIORITY_SCHEDULING: c_int = 8; +pub const CTL_P1003_1B_REALTIME_SIGNALS: c_int = 9; +pub const CTL_P1003_1B_SEMAPHORES: c_int = 10; +pub const CTL_P1003_1B_FSYNC: c_int = 11; +pub const CTL_P1003_1B_SHARED_MEMORY_OBJECTS: c_int = 12; +pub const CTL_P1003_1B_SYNCHRONIZED_IO: c_int = 13; +pub const CTL_P1003_1B_TIMERS: c_int = 14; +pub const CTL_P1003_1B_AIO_LISTIO_MAX: c_int = 15; +pub const CTL_P1003_1B_AIO_MAX: c_int = 16; +pub const CTL_P1003_1B_AIO_PRIO_DELTA_MAX: c_int = 17; +pub const CTL_P1003_1B_DELAYTIMER_MAX: c_int = 18; +pub const CTL_P1003_1B_UNUSED1: c_int = 19; +pub const CTL_P1003_1B_PAGESIZE: c_int = 20; +pub const CTL_P1003_1B_RTSIG_MAX: c_int = 21; +pub const CTL_P1003_1B_SEM_NSEMS_MAX: c_int = 22; +pub const CTL_P1003_1B_SEM_VALUE_MAX: c_int = 23; +pub const CTL_P1003_1B_SIGQUEUE_MAX: c_int = 24; +pub const CTL_P1003_1B_TIMER_MAX: c_int = 25; +pub const CTL_P1003_1B_MAXID: c_int = 26; + +pub const CPUCTL_RSMSR: c_int = 0xc0106301; +pub const CPUCTL_WRMSR: c_int = 0xc0106302; +pub const CPUCTL_CPUID: c_int = 0xc0106303; +pub const CPUCTL_UPDATE: c_int = 0xc0106304; +pub const CPUCTL_MSRSBIT: c_int = 0xc0106305; +pub const CPUCTL_MSRCBIT: c_int = 0xc0106306; +pub const CPUCTL_CPUID_COUNT: c_int = 0xc0106307; + +pub const CPU_SETSIZE: size_t = size_of::() * 8; + +pub const EVFILT_READ: i16 = -1; +pub const EVFILT_WRITE: i16 = -2; +pub const EVFILT_AIO: i16 = -3; +pub const EVFILT_VNODE: i16 = -4; +pub const EVFILT_PROC: i16 = -5; +pub const EVFILT_SIGNAL: i16 = -6; +pub const EVFILT_TIMER: i16 = -7; +pub const EVFILT_EXCEPT: i16 = -8; +pub const EVFILT_USER: i16 = -9; +pub const EVFILT_FS: i16 = -10; + +pub const EV_ADD: u16 = 0x1; +pub const EV_DELETE: u16 = 0x2; +pub const EV_ENABLE: u16 = 0x4; +pub const EV_DISABLE: u16 = 0x8; +pub const EV_ONESHOT: u16 = 0x10; +pub const EV_CLEAR: u16 = 0x20; +pub const EV_RECEIPT: u16 = 0x40; +pub const EV_DISPATCH: u16 = 0x80; +pub const EV_NODATA: u16 = 0x1000; +pub const EV_FLAG1: u16 = 0x2000; +pub const EV_ERROR: u16 = 0x4000; +pub const EV_EOF: u16 = 0x8000; +pub const EV_HUP: u16 = 0x8000; +pub const EV_SYSFLAGS: u16 = 0xf000; + +pub const FIODNAME: c_ulong = 0x80106678; + +pub const NOTE_TRIGGER: u32 = 0x01000000; +pub const NOTE_FFNOP: u32 = 0x00000000; +pub const NOTE_FFAND: u32 = 0x40000000; +pub const NOTE_FFOR: u32 = 0x80000000; +pub const NOTE_FFCOPY: u32 = 0xc0000000; +pub const NOTE_FFCTRLMASK: u32 = 0xc0000000; +pub const NOTE_FFLAGSMASK: u32 = 0x00ffffff; +pub const NOTE_LOWAT: u32 = 0x00000001; +pub const NOTE_OOB: u32 = 0x00000002; +pub const NOTE_DELETE: u32 = 0x00000001; +pub const NOTE_WRITE: u32 = 0x00000002; +pub const NOTE_EXTEND: u32 = 0x00000004; +pub const NOTE_ATTRIB: u32 = 0x00000008; +pub const NOTE_LINK: u32 = 0x00000010; +pub const NOTE_RENAME: u32 = 0x00000020; +pub const NOTE_REVOKE: u32 = 0x00000040; +pub const NOTE_EXIT: u32 = 0x80000000; +pub const NOTE_FORK: u32 = 0x40000000; +pub const NOTE_EXEC: u32 = 0x20000000; +pub const NOTE_PDATAMASK: u32 = 0x000fffff; +pub const NOTE_PCTRLMASK: u32 = 0xf0000000; +pub const NOTE_TRACK: u32 = 0x00000001; +pub const NOTE_TRACKERR: u32 = 0x00000002; +pub const NOTE_CHILD: u32 = 0x00000004; + +pub const SO_SNDSPACE: c_int = 0x100a; +pub const SO_CPUHINT: c_int = 0x1030; +pub const SO_PASSCRED: c_int = 0x4000; + +pub const PT_FIRSTMACH: c_int = 32; + +pub const PROC_REAP_ACQUIRE: c_int = 0x0001; +pub const PROC_REAP_RELEASE: c_int = 0x0002; +pub const PROC_REAP_STATUS: c_int = 0x0003; +pub const PROC_PDEATHSIG_CTL: c_int = 0x0004; +pub const PROC_PDEATHSIG_STATUS: c_int = 0x0005; + +// https://github.com/DragonFlyBSD/DragonFlyBSD/blob/HEAD/sys/net/if.h#L101 +pub const IFF_UP: c_int = 0x1; // interface is up +pub const IFF_BROADCAST: c_int = 0x2; // broadcast address valid +pub const IFF_DEBUG: c_int = 0x4; // turn on debugging +pub const IFF_LOOPBACK: c_int = 0x8; // is a loopback net +pub const IFF_POINTOPOINT: c_int = 0x10; // interface is point-to-point link +pub const IFF_SMART: c_int = 0x20; // interface manages own routes +pub const IFF_RUNNING: c_int = 0x40; // resources allocated +pub const IFF_NOARP: c_int = 0x80; // no address resolution protocol +pub const IFF_PROMISC: c_int = 0x100; // receive all packets +pub const IFF_ALLMULTI: c_int = 0x200; // receive all multicast packets +pub const IFF_OACTIVE_COMPAT: c_int = 0x400; // was transmission in progress +pub const IFF_SIMPLEX: c_int = 0x800; // can't hear own transmissions +pub const IFF_LINK0: c_int = 0x1000; // per link layer defined bit +pub const IFF_LINK1: c_int = 0x2000; // per link layer defined bit +pub const IFF_LINK2: c_int = 0x4000; // per link layer defined bit +pub const IFF_ALTPHYS: c_int = IFF_LINK2; // use alternate physical connection +pub const IFF_MULTICAST: c_int = 0x8000; // supports multicast + // was interface is in polling mode +pub const IFF_POLLING_COMPAT: c_int = 0x10000; +pub const IFF_PPROMISC: c_int = 0x20000; // user-requested promisc mode +pub const IFF_MONITOR: c_int = 0x40000; // user-requested monitor mode +pub const IFF_STATICARP: c_int = 0x80000; // static ARP +pub const IFF_NPOLLING: c_int = 0x100000; // interface is in polling mode +pub const IFF_IDIRECT: c_int = 0x200000; // direct input + +// +// sys/netinet/in.h +// Protocols (RFC 1700) +// NOTE: These are in addition to the constants defined in src/unix/mod.rs + +// IPPROTO_IP defined in src/unix/mod.rs +/// IP6 hop-by-hop options +pub const IPPROTO_HOPOPTS: c_int = 0; +// IPPROTO_ICMP defined in src/unix/mod.rs +/// group mgmt protocol +pub const IPPROTO_IGMP: c_int = 2; +/// gateway^2 (deprecated) +pub const IPPROTO_GGP: c_int = 3; +/// for compatibility +pub const IPPROTO_IPIP: c_int = 4; +// IPPROTO_TCP defined in src/unix/mod.rs +/// Stream protocol II. +pub const IPPROTO_ST: c_int = 7; +/// exterior gateway protocol +pub const IPPROTO_EGP: c_int = 8; +/// private interior gateway +pub const IPPROTO_PIGP: c_int = 9; +/// BBN RCC Monitoring +pub const IPPROTO_RCCMON: c_int = 10; +/// network voice protocol +pub const IPPROTO_NVPII: c_int = 11; +/// pup +pub const IPPROTO_PUP: c_int = 12; +/// Argus +pub const IPPROTO_ARGUS: c_int = 13; +/// EMCON +pub const IPPROTO_EMCON: c_int = 14; +/// Cross Net Debugger +pub const IPPROTO_XNET: c_int = 15; +/// Chaos +pub const IPPROTO_CHAOS: c_int = 16; +// IPPROTO_UDP defined in src/unix/mod.rs +/// Multiplexing +pub const IPPROTO_MUX: c_int = 18; +/// DCN Measurement Subsystems +pub const IPPROTO_MEAS: c_int = 19; +/// Host Monitoring +pub const IPPROTO_HMP: c_int = 20; +/// Packet Radio Measurement +pub const IPPROTO_PRM: c_int = 21; +/// xns idp +pub const IPPROTO_IDP: c_int = 22; +/// Trunk-1 +pub const IPPROTO_TRUNK1: c_int = 23; +/// Trunk-2 +pub const IPPROTO_TRUNK2: c_int = 24; +/// Leaf-1 +pub const IPPROTO_LEAF1: c_int = 25; +/// Leaf-2 +pub const IPPROTO_LEAF2: c_int = 26; +/// Reliable Data +pub const IPPROTO_RDP: c_int = 27; +/// Reliable Transaction +pub const IPPROTO_IRTP: c_int = 28; +/// tp-4 w/ class negotiation +pub const IPPROTO_TP: c_int = 29; +/// Bulk Data Transfer +pub const IPPROTO_BLT: c_int = 30; +/// Network Services +pub const IPPROTO_NSP: c_int = 31; +/// Merit Internodal +pub const IPPROTO_INP: c_int = 32; +/// Sequential Exchange +pub const IPPROTO_SEP: c_int = 33; +/// Third Party Connect +pub const IPPROTO_3PC: c_int = 34; +/// InterDomain Policy Routing +pub const IPPROTO_IDPR: c_int = 35; +/// XTP +pub const IPPROTO_XTP: c_int = 36; +/// Datagram Delivery +pub const IPPROTO_DDP: c_int = 37; +/// Control Message Transport +pub const IPPROTO_CMTP: c_int = 38; +/// TP++ Transport +pub const IPPROTO_TPXX: c_int = 39; +/// IL transport protocol +pub const IPPROTO_IL: c_int = 40; +// IPPROTO_IPV6 defined in src/unix/mod.rs +/// Source Demand Routing +pub const IPPROTO_SDRP: c_int = 42; +/// IP6 routing header +pub const IPPROTO_ROUTING: c_int = 43; +/// IP6 fragmentation header +pub const IPPROTO_FRAGMENT: c_int = 44; +/// InterDomain Routing +pub const IPPROTO_IDRP: c_int = 45; +/// resource reservation +pub const IPPROTO_RSVP: c_int = 46; +/// General Routing Encap. +pub const IPPROTO_GRE: c_int = 47; +/// Mobile Host Routing +pub const IPPROTO_MHRP: c_int = 48; +/// BHA +pub const IPPROTO_BHA: c_int = 49; +/// IP6 Encap Sec. Payload +pub const IPPROTO_ESP: c_int = 50; +/// IP6 Auth Header +pub const IPPROTO_AH: c_int = 51; +/// Integ. Net Layer Security +pub const IPPROTO_INLSP: c_int = 52; +/// IP with encryption +pub const IPPROTO_SWIPE: c_int = 53; +/// Next Hop Resolution +pub const IPPROTO_NHRP: c_int = 54; +/// IP Mobility +pub const IPPROTO_MOBILE: c_int = 55; +/// Transport Layer Security +pub const IPPROTO_TLSP: c_int = 56; +/// SKIP +pub const IPPROTO_SKIP: c_int = 57; +// IPPROTO_ICMPV6 defined in src/unix/mod.rs +/// IP6 no next header +pub const IPPROTO_NONE: c_int = 59; +/// IP6 destination option +pub const IPPROTO_DSTOPTS: c_int = 60; +/// any host internal protocol +pub const IPPROTO_AHIP: c_int = 61; +/// CFTP +pub const IPPROTO_CFTP: c_int = 62; +/// "hello" routing protocol +pub const IPPROTO_HELLO: c_int = 63; +/// SATNET/Backroom EXPAK +pub const IPPROTO_SATEXPAK: c_int = 64; +/// Kryptolan +pub const IPPROTO_KRYPTOLAN: c_int = 65; +/// Remote Virtual Disk +pub const IPPROTO_RVD: c_int = 66; +/// Pluribus Packet Core +pub const IPPROTO_IPPC: c_int = 67; +/// Any distributed FS +pub const IPPROTO_ADFS: c_int = 68; +/// Satnet Monitoring +pub const IPPROTO_SATMON: c_int = 69; +/// VISA Protocol +pub const IPPROTO_VISA: c_int = 70; +/// Packet Core Utility +pub const IPPROTO_IPCV: c_int = 71; +/// Comp. Prot. Net. Executive +pub const IPPROTO_CPNX: c_int = 72; +/// Comp. Prot. HeartBeat +pub const IPPROTO_CPHB: c_int = 73; +/// Wang Span Network +pub const IPPROTO_WSN: c_int = 74; +/// Packet Video Protocol +pub const IPPROTO_PVP: c_int = 75; +/// BackRoom SATNET Monitoring +pub const IPPROTO_BRSATMON: c_int = 76; +/// Sun net disk proto (temp.) +pub const IPPROTO_ND: c_int = 77; +/// WIDEBAND Monitoring +pub const IPPROTO_WBMON: c_int = 78; +/// WIDEBAND EXPAK +pub const IPPROTO_WBEXPAK: c_int = 79; +/// ISO cnlp +pub const IPPROTO_EON: c_int = 80; +/// VMTP +pub const IPPROTO_VMTP: c_int = 81; +/// Secure VMTP +pub const IPPROTO_SVMTP: c_int = 82; +/// Banyon VINES +pub const IPPROTO_VINES: c_int = 83; +/// TTP +pub const IPPROTO_TTP: c_int = 84; +/// NSFNET-IGP +pub const IPPROTO_IGP: c_int = 85; +/// dissimilar gateway prot. +pub const IPPROTO_DGP: c_int = 86; +/// TCF +pub const IPPROTO_TCF: c_int = 87; +/// Cisco/GXS IGRP +pub const IPPROTO_IGRP: c_int = 88; +/// OSPFIGP +pub const IPPROTO_OSPFIGP: c_int = 89; +/// Strite RPC protocol +pub const IPPROTO_SRPC: c_int = 90; +/// Locus Address Resoloution +pub const IPPROTO_LARP: c_int = 91; +/// Multicast Transport +pub const IPPROTO_MTP: c_int = 92; +/// AX.25 Frames +pub const IPPROTO_AX25: c_int = 93; +/// IP encapsulated in IP +pub const IPPROTO_IPEIP: c_int = 94; +/// Mobile Int.ing control +pub const IPPROTO_MICP: c_int = 95; +/// Semaphore Comm. security +pub const IPPROTO_SCCSP: c_int = 96; +/// Ethernet IP encapsulation +pub const IPPROTO_ETHERIP: c_int = 97; +/// encapsulation header +pub const IPPROTO_ENCAP: c_int = 98; +/// any private encr. scheme +pub const IPPROTO_APES: c_int = 99; +/// GMTP +pub const IPPROTO_GMTP: c_int = 100; +/// payload compression (IPComp) +pub const IPPROTO_IPCOMP: c_int = 108; + +/* 101-254: Partly Unassigned */ +/// Protocol Independent Mcast +pub const IPPROTO_PIM: c_int = 103; +/// CARP +pub const IPPROTO_CARP: c_int = 112; +/// PGM +pub const IPPROTO_PGM: c_int = 113; +/// PFSYNC +pub const IPPROTO_PFSYNC: c_int = 240; + +/* 255: Reserved */ +/* BSD Private, local use, namespace incursion, no longer used */ +/// divert pseudo-protocol +pub const IPPROTO_DIVERT: c_int = 254; +pub const IPPROTO_MAX: c_int = 256; +/// last return value of *_input(), meaning "all job for this pkt is done". +pub const IPPROTO_DONE: c_int = 257; + +/// Used by RSS: the layer3 protocol is unknown +pub const IPPROTO_UNKNOWN: c_int = 258; + +// sys/netinet/tcp.h +pub const TCP_SIGNATURE_ENABLE: c_int = 16; +pub const TCP_KEEPINIT: c_int = 32; +pub const TCP_FASTKEEP: c_int = 128; + +pub const AF_BLUETOOTH: c_int = 33; +pub const AF_MPLS: c_int = 34; +pub const AF_IEEE80211: c_int = 35; + +pub const PF_BLUETOOTH: c_int = AF_BLUETOOTH; + +pub const NET_RT_DUMP: c_int = 1; +pub const NET_RT_FLAGS: c_int = 2; +pub const NET_RT_IFLIST: c_int = 3; +pub const NET_RT_MAXID: c_int = 4; + +pub const SOMAXOPT_SIZE: c_int = 65536; + +pub const MSG_UNUSED09: c_int = 0x00000200; +pub const MSG_NOSIGNAL: c_int = 0x00000400; +pub const MSG_SYNC: c_int = 0x00000800; +pub const MSG_CMSG_CLOEXEC: c_int = 0x00001000; +pub const MSG_FBLOCKING: c_int = 0x00010000; +pub const MSG_FNONBLOCKING: c_int = 0x00020000; +pub const MSG_FMASK: c_int = 0xFFFF0000; + +// sys/mount.h +pub const MNT_NODEV: c_int = 0x00000010; +pub const MNT_AUTOMOUNTED: c_int = 0x00000020; +pub const MNT_TRIM: c_int = 0x01000000; +pub const MNT_LOCAL: c_int = 0x00001000; +pub const MNT_QUOTA: c_int = 0x00002000; +pub const MNT_ROOTFS: c_int = 0x00004000; +pub const MNT_USER: c_int = 0x00008000; +pub const MNT_IGNORE: c_int = 0x00800000; + +// utmpx entry types +pub const EMPTY: c_short = 0; +pub const RUN_LVL: c_short = 1; +pub const BOOT_TIME: c_short = 2; +pub const OLD_TIME: c_short = 3; +pub const NEW_TIME: c_short = 4; +pub const INIT_PROCESS: c_short = 5; +pub const LOGIN_PROCESS: c_short = 6; +pub const USER_PROCESS: c_short = 7; +pub const DEAD_PROCESS: c_short = 8; +pub const ACCOUNTING: c_short = 9; +pub const SIGNATURE: c_short = 10; +pub const DOWNTIME: c_short = 11; +// utmpx database types +pub const UTX_DB_UTMPX: c_uint = 0; +pub const UTX_DB_WTMPX: c_uint = 1; +pub const UTX_DB_LASTLOG: c_uint = 2; +pub const _UTX_LINESIZE: usize = 32; +pub const _UTX_USERSIZE: usize = 32; +pub const _UTX_IDSIZE: usize = 4; +pub const _UTX_HOSTSIZE: usize = 256; + +pub const LC_COLLATE_MASK: c_int = 1 << 0; +pub const LC_CTYPE_MASK: c_int = 1 << 1; +pub const LC_MONETARY_MASK: c_int = 1 << 2; +pub const LC_NUMERIC_MASK: c_int = 1 << 3; +pub const LC_TIME_MASK: c_int = 1 << 4; +pub const LC_MESSAGES_MASK: c_int = 1 << 5; +pub const LC_ALL_MASK: c_int = LC_COLLATE_MASK + | LC_CTYPE_MASK + | LC_MESSAGES_MASK + | LC_MONETARY_MASK + | LC_NUMERIC_MASK + | LC_TIME_MASK; + +pub const TIOCSIG: c_ulong = 0x2000745f; +pub const BTUARTDISC: c_int = 0x7; +pub const TIOCDCDTIMESTAMP: c_ulong = 0x40107458; +pub const TIOCISPTMASTER: c_ulong = 0x20007455; +pub const TIOCMODG: c_ulong = 0x40047403; +pub const TIOCMODS: c_ulong = 0x80047404; +pub const TIOCREMOTE: c_ulong = 0x80047469; +pub const TIOCTIMESTAMP: c_ulong = 0x40107459; + +// Constants used by "at" family of system calls. +pub const AT_FDCWD: c_int = 0xFFFAFDCD; // invalid file descriptor +pub const AT_SYMLINK_NOFOLLOW: c_int = 1; +pub const AT_REMOVEDIR: c_int = 2; +pub const AT_EACCESS: c_int = 4; +pub const AT_SYMLINK_FOLLOW: c_int = 8; + +pub const VCHECKPT: usize = 19; + +pub const _PC_2_SYMLINKS: c_int = 22; +pub const _PC_TIMESTAMP_RESOLUTION: c_int = 23; + +pub const _CS_PATH: c_int = 1; + +pub const _SC_V7_ILP32_OFF32: c_int = 122; +pub const _SC_V7_ILP32_OFFBIG: c_int = 123; +pub const _SC_V7_LP64_OFF64: c_int = 124; +pub const _SC_V7_LPBIG_OFFBIG: c_int = 125; +pub const _SC_THREAD_ROBUST_PRIO_INHERIT: c_int = 126; +pub const _SC_THREAD_ROBUST_PRIO_PROTECT: c_int = 127; + +pub const WCONTINUED: c_int = 0x4; +pub const WSTOPPED: c_int = 0x2; +pub const WNOWAIT: c_int = 0x8; +pub const WEXITED: c_int = 0x10; +pub const WTRAPPED: c_int = 0x20; + +// Similar to FreeBSD, only the standardized ones are exposed. +// There are more. +pub const P_PID: idtype_t = 0; +pub const P_PGID: idtype_t = 2; +pub const P_ALL: idtype_t = 7; + +// Values for struct rtprio (type_ field) +pub const RTP_PRIO_REALTIME: c_ushort = 0; +pub const RTP_PRIO_NORMAL: c_ushort = 1; +pub const RTP_PRIO_IDLE: c_ushort = 2; +pub const RTP_PRIO_THREAD: c_ushort = 3; + +// Flags for chflags(2) +pub const UF_NOHISTORY: c_ulong = 0x00000040; +pub const UF_CACHE: c_ulong = 0x00000080; +pub const UF_XLINK: c_ulong = 0x00000100; +pub const SF_NOHISTORY: c_ulong = 0x00400000; +pub const SF_CACHE: c_ulong = 0x00800000; +pub const SF_XLINK: c_ulong = 0x01000000; + +// timespec constants +pub const UTIME_OMIT: c_long = -2; +pub const UTIME_NOW: c_long = -1; + +pub const MINCORE_SUPER: c_int = 0x20; + +// kinfo_proc constants +pub const MAXCOMLEN: usize = 16; +pub const MAXLOGNAME: usize = 33; +pub const NGROUPS: usize = 16; + +pub const RB_PAUSE: c_int = 0x40000; +pub const RB_VIDEO: c_int = 0x20000000; + +// net/route.h +pub const RTF_CLONING: c_int = 0x100; +pub const RTF_PRCLONING: c_int = 0x10000; +pub const RTF_WASCLONED: c_int = 0x20000; +pub const RTF_MPLSOPS: c_int = 0x1000000; + +pub const RTM_VERSION: c_int = 7; + +pub const RTAX_MPLS1: c_int = 8; +pub const RTAX_MPLS2: c_int = 9; +pub const RTAX_MPLS3: c_int = 10; +pub const RTAX_MAX: c_int = 11; + +const fn _CMSG_ALIGN(n: usize) -> usize { + (n + (size_of::() - 1)) & !(size_of::() - 1) +} + +f! { + pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { + (cmsg as *mut c_uchar).offset(_CMSG_ALIGN(size_of::()) as isize) + } + + pub const fn CMSG_LEN(length: c_uint) -> c_uint { + (_CMSG_ALIGN(size_of::()) + length as usize) as c_uint + } + + pub fn CMSG_NXTHDR(mhdr: *const crate::msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { + let next = cmsg as usize + + _CMSG_ALIGN((*cmsg).cmsg_len as usize) + + _CMSG_ALIGN(size_of::()); + let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; + if next <= max { + (cmsg as usize + _CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr + } else { + core::ptr::null_mut::() + } + } + + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { + (_CMSG_ALIGN(size_of::()) + _CMSG_ALIGN(length as usize)) as c_uint + } + + pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { + for slot in cpuset.ary.iter_mut() { + *slot = 0; + } + } + + pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { + let (idx, offset) = ((cpu >> 6) & 3, cpu & 63); + cpuset.ary[idx] |= 1 << offset; + () + } + + pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { + let (idx, offset) = ((cpu >> 6) & 3, cpu & 63); + cpuset.ary[idx] &= !(1 << offset); + () + } + + pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { + let (idx, offset) = ((cpu >> 6) & 3, cpu & 63); + 0 != cpuset.ary[idx] & (1 << offset) + } +} + +safe_f! { + pub const fn WIFSIGNALED(status: c_int) -> bool { + (status & 0o177) != 0o177 && (status & 0o177) != 0 + } + + pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { + let major = major as crate::dev_t; + let minor = minor as crate::dev_t; + let mut dev = 0; + dev |= major << 8; + dev |= minor; + dev + } + + pub const fn major(dev: crate::dev_t) -> c_int { + ((dev >> 8) & 0xff) as c_int + } + + pub const fn minor(dev: crate::dev_t) -> c_int { + (dev & 0xffff00ff) as c_int + } +} + +extern "C" { + pub fn __errno_location() -> *mut c_int; + pub fn setgrent(); + pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; + + pub fn setutxdb(_type: c_uint, file: *mut c_char) -> c_int; + + pub fn aio_waitcomplete(iocbp: *mut *mut aiocb, timeout: *mut crate::timespec) -> c_int; + + pub fn devname_r( + dev: crate::dev_t, + mode: crate::mode_t, + buf: *mut c_char, + len: size_t, + ) -> *mut c_char; + + pub fn waitid( + idtype: idtype_t, + id: crate::id_t, + infop: *mut crate::siginfo_t, + options: c_int, + ) -> c_int; + + pub fn freelocale(loc: crate::locale_t); + + pub fn lwp_rtprio( + function: c_int, + pid: crate::pid_t, + lwpid: lwpid_t, + rtp: *mut super::rtprio, + ) -> c_int; + + pub fn statfs(path: *const c_char, buf: *mut statfs) -> c_int; + pub fn fstatfs(fd: c_int, buf: *mut statfs) -> c_int; + pub fn uname(buf: *mut crate::utsname) -> c_int; + pub fn memmem( + haystack: *const c_void, + haystacklen: size_t, + needle: *const c_void, + needlelen: size_t, + ) -> *mut c_void; + pub fn pthread_spin_init(lock: *mut pthread_spinlock_t, pshared: c_int) -> c_int; + pub fn pthread_spin_destroy(lock: *mut pthread_spinlock_t) -> c_int; + pub fn pthread_spin_lock(lock: *mut pthread_spinlock_t) -> c_int; + pub fn pthread_spin_trylock(lock: *mut pthread_spinlock_t) -> c_int; + pub fn pthread_spin_unlock(lock: *mut pthread_spinlock_t) -> c_int; + + pub fn sched_getaffinity(pid: crate::pid_t, cpusetsize: size_t, mask: *mut cpu_set_t) -> c_int; + pub fn sched_setaffinity( + pid: crate::pid_t, + cpusetsize: size_t, + mask: *const cpu_set_t, + ) -> c_int; + pub fn sched_getcpu() -> c_int; + pub fn setproctitle(fmt: *const c_char, ...); + + pub fn shmget(key: crate::key_t, size: size_t, shmflg: c_int) -> c_int; + pub fn shmat(shmid: c_int, shmaddr: *const c_void, shmflg: c_int) -> *mut c_void; + pub fn shmdt(shmaddr: *const c_void) -> c_int; + pub fn shmctl(shmid: c_int, cmd: c_int, buf: *mut crate::shmid_ds) -> c_int; + pub fn procctl( + idtype: crate::idtype_t, + id: crate::id_t, + cmd: c_int, + data: *mut c_void, + ) -> c_int; + + pub fn updwtmpx(file: *const c_char, ut: *const utmpx) -> c_int; + pub fn getlastlogx(fname: *const c_char, uid: crate::uid_t, ll: *mut lastlogx) + -> *mut lastlogx; + pub fn updlastlogx(fname: *const c_char, uid: crate::uid_t, ll: *mut lastlogx) -> c_int; + pub fn getutxuser(name: *const c_char) -> utmpx; + pub fn utmpxname(file: *const c_char) -> c_int; + + pub fn sys_checkpoint(tpe: c_int, fd: c_int, pid: crate::pid_t, retval: c_int) -> c_int; + + pub fn umtx_sleep(ptr: *const c_int, value: c_int, timeout: c_int) -> c_int; + pub fn umtx_wakeup(ptr: *const c_int, count: c_int) -> c_int; + + pub fn dirname(path: *mut c_char) -> *mut c_char; + pub fn basename(path: *mut c_char) -> *mut c_char; + pub fn getmntinfo(mntbufp: *mut *mut crate::statfs, flags: c_int) -> c_int; + pub fn getmntvinfo( + mntbufp: *mut *mut crate::statfs, + mntvbufp: *mut *mut crate::statvfs, + flags: c_int, + ) -> c_int; + + pub fn closefrom(lowfd: c_int) -> c_int; +} + +#[link(name = "rt")] +extern "C" { + pub fn aio_cancel(fd: c_int, aiocbp: *mut aiocb) -> c_int; + pub fn aio_error(aiocbp: *const aiocb) -> c_int; + pub fn aio_fsync(op: c_int, aiocbp: *mut aiocb) -> c_int; + pub fn aio_read(aiocbp: *mut aiocb) -> c_int; + pub fn aio_return(aiocbp: *mut aiocb) -> ssize_t; + pub fn aio_suspend( + aiocb_list: *const *const aiocb, + nitems: c_int, + timeout: *const crate::timespec, + ) -> c_int; + pub fn aio_write(aiocbp: *mut aiocb) -> c_int; + pub fn lio_listio( + mode: c_int, + aiocb_list: *const *mut aiocb, + nitems: c_int, + sevp: *mut sigevent, + ) -> c_int; + + pub fn reallocf(ptr: *mut c_void, size: size_t) -> *mut c_void; + pub fn freezero(ptr: *mut c_void, size: size_t); +} + +#[link(name = "kvm")] +extern "C" { + pub fn kvm_vm_map_entry_first( + kvm: *mut crate::kvm_t, + map: vm_map_t, + entry: vm_map_entry_t, + ) -> vm_map_entry_t; + pub fn kvm_vm_map_entry_next( + kvm: *mut crate::kvm_t, + map: vm_map_entry_t, + entry: vm_map_entry_t, + ) -> vm_map_entry_t; +} diff --git a/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/aarch64.rs b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/aarch64.rs new file mode 100644 index 0000000..232770f --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/aarch64.rs @@ -0,0 +1,42 @@ +use crate::prelude::*; + +pub type clock_t = i32; +pub type wchar_t = u32; +pub type time_t = i64; +pub type suseconds_t = i64; +pub type register_t = i64; + +s! { + pub struct gpregs { + pub gp_x: [crate::register_t; 30], + pub gp_lr: crate::register_t, + pub gp_sp: crate::register_t, + pub gp_elr: crate::register_t, + pub gp_spsr: u32, + pub gp_pad: c_int, + } + + pub struct fpregs { + pub fp_q: u128, + pub fp_sr: u32, + pub fp_cr: u32, + pub fp_flags: c_int, + pub fp_pad: c_int, + } + + pub struct mcontext_t { + pub mc_gpregs: gpregs, + pub mc_fpregs: fpregs, + pub mc_flags: c_int, + pub mc_pad: c_int, + pub mc_spare: [u64; 8], + } +} + +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; + +pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; +pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e; +pub const MAP_32BIT: c_int = 0x00080000; +pub const MINSIGSTKSZ: size_t = 4096; // 1024 * 4 +pub const TIOCTIMESTAMP: c_ulong = 0x40107459; diff --git a/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/arm.rs b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/arm.rs new file mode 100644 index 0000000..a0f5183 --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/arm.rs @@ -0,0 +1,27 @@ +use crate::prelude::*; + +pub type clock_t = u32; +pub type wchar_t = u32; +pub type time_t = i64; +pub type suseconds_t = i32; +pub type register_t = i32; +pub type __greg_t = c_uint; +pub type __gregset_t = [crate::__greg_t; 17]; + +s! { + pub struct mcontext_t { + pub __gregs: crate::__gregset_t, + pub mc_vfp_size: usize, + pub mc_vfp_ptr: *mut c_void, + pub mc_spare: [c_uint; 33], + } +} + +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; + +pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; +pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e; + +pub const MAP_32BIT: c_int = 0x00080000; +pub const MINSIGSTKSZ: size_t = 4096; // 1024 * 4 +pub const TIOCTIMESTAMP: c_ulong = 0x40107459; diff --git a/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/b32.rs b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/b32.rs new file mode 100644 index 0000000..cd0c3e0 --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/b32.rs @@ -0,0 +1,29 @@ +use crate::off_t; +use crate::prelude::*; + +s! { + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + pub st_size: off_t, + pub st_blocks: crate::blkcnt_t, + pub st_blksize: crate::blksize_t, + pub st_flags: crate::fflags_t, + pub st_gen: u32, + pub st_lspare: i32, + pub st_birthtime: crate::time_t, + pub st_birthtime_nsec: c_long, + __unused: Padding<[u8; 8]>, + } +} diff --git a/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/b64.rs b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/b64.rs new file mode 100644 index 0000000..9e80a79 --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/b64.rs @@ -0,0 +1,28 @@ +use crate::off_t; +use crate::prelude::*; + +s! { + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + pub st_size: off_t, + pub st_blocks: crate::blkcnt_t, + pub st_blksize: crate::blksize_t, + pub st_flags: crate::fflags_t, + pub st_gen: u32, + pub st_lspare: i32, + pub st_birthtime: crate::time_t, + pub st_birthtime_nsec: c_long, + } +} diff --git a/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs new file mode 100644 index 0000000..e04fcc0 --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs @@ -0,0 +1,330 @@ +use crate::prelude::*; + +// APIs that were changed after FreeBSD 11 + +// The type of `nlink_t` changed from `u16` to `u64` in FreeBSD 12: +pub type nlink_t = u16; +// Type of `dev_t` changed from `u32` to `u64` in FreeBSD 12: +pub type dev_t = u32; +// Type of `ino_t` changed from `__uint32_t` to `__uint64_t` in FreeBSD 12: +pub type ino_t = u32; + +s! { + pub struct kevent { + pub ident: crate::uintptr_t, + pub filter: c_short, + pub flags: c_ushort, + pub fflags: c_uint, + pub data: intptr_t, + pub udata: *mut c_void, + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, + pub shm_lpid: crate::pid_t, + pub shm_cpid: crate::pid_t, + // Type of shm_nattc changed from `int` to `shmatt_t` (aka `unsigned + // int`) in FreeBSD 12: + pub shm_nattch: c_int, + pub shm_atime: crate::time_t, + pub shm_dtime: crate::time_t, + pub shm_ctime: crate::time_t, + } + + pub struct kinfo_proc { + /// Size of this structure. + pub ki_structsize: c_int, + /// Reserved: layout identifier. + pub ki_layout: c_int, + /// Address of command arguments. + pub ki_args: *mut crate::pargs, + // This is normally "struct proc". + /// Address of proc. + pub ki_paddr: *mut c_void, + // This is normally "struct user". + /// Kernel virtual address of u-area. + pub ki_addr: *mut c_void, + // This is normally "struct vnode". + /// Pointer to trace file. + pub ki_tracep: *mut c_void, + // This is normally "struct vnode". + /// Pointer to executable file. + pub ki_textvp: *mut c_void, + /// Pointer to open file info. + pub ki_fd: *mut crate::filedesc, + // This is normally "struct vmspace". + /// Pointer to kernel vmspace struct. + pub ki_vmspace: *mut c_void, + /// Sleep address. + pub ki_wchan: *mut c_void, + /// Process identifier. + pub ki_pid: crate::pid_t, + /// Parent process ID. + pub ki_ppid: crate::pid_t, + /// Process group ID. + pub ki_pgid: crate::pid_t, + /// tty process group ID. + pub ki_tpgid: crate::pid_t, + /// Process session ID. + pub ki_sid: crate::pid_t, + /// Terminal session ID. + pub ki_tsid: crate::pid_t, + /// Job control counter. + pub ki_jobc: c_short, + /// Unused (just here for alignment). + pub ki_spare_short1: c_short, + /// Controlling tty dev. + pub ki_tdev: crate::dev_t, + /// Signals arrived but not delivered. + pub ki_siglist: crate::sigset_t, + /// Current signal mask. + pub ki_sigmask: crate::sigset_t, + /// Signals being ignored. + pub ki_sigignore: crate::sigset_t, + /// Signals being caught by user. + pub ki_sigcatch: crate::sigset_t, + /// Effective user ID. + pub ki_uid: crate::uid_t, + /// Real user ID. + pub ki_ruid: crate::uid_t, + /// Saved effective user ID. + pub ki_svuid: crate::uid_t, + /// Real group ID. + pub ki_rgid: crate::gid_t, + /// Saved effective group ID. + pub ki_svgid: crate::gid_t, + /// Number of groups. + pub ki_ngroups: c_short, + /// Unused (just here for alignment). + pub ki_spare_short2: c_short, + /// Groups. + pub ki_groups: [crate::gid_t; crate::KI_NGROUPS], + /// Virtual size. + pub ki_size: crate::vm_size_t, + /// Current resident set size in pages. + pub ki_rssize: crate::segsz_t, + /// Resident set size before last swap. + pub ki_swrss: crate::segsz_t, + /// Text size (pages) XXX. + pub ki_tsize: crate::segsz_t, + /// Data size (pages) XXX. + pub ki_dsize: crate::segsz_t, + /// Stack size (pages). + pub ki_ssize: crate::segsz_t, + /// Exit status for wait & stop signal. + pub ki_xstat: crate::u_short, + /// Accounting flags. + pub ki_acflag: crate::u_short, + /// %cpu for process during `ki_swtime`. + pub ki_pctcpu: crate::fixpt_t, + /// Time averaged value of `ki_cpticks`. + pub ki_estcpu: crate::u_int, + /// Time since last blocked. + pub ki_slptime: crate::u_int, + /// Time swapped in or out. + pub ki_swtime: crate::u_int, + /// Number of copy-on-write faults. + pub ki_cow: crate::u_int, + /// Real time in microsec. + pub ki_runtime: u64, + /// Starting time. + pub ki_start: crate::timeval, + /// Time used by process children. + pub ki_childtime: crate::timeval, + /// P_* flags. + pub ki_flag: c_long, + /// KI_* flags (below). + pub ki_kiflag: c_long, + /// Kernel trace points. + pub ki_traceflag: c_int, + /// S* process status. + pub ki_stat: c_char, + /// Process "nice" value. + pub ki_nice: i8, // signed char + /// Process lock (prevent swap) count. + pub ki_lock: c_char, + /// Run queue index. + pub ki_rqindex: c_char, + /// Which cpu we are on. + pub ki_oncpu_old: c_uchar, + /// Last cpu we were on. + pub ki_lastcpu_old: c_uchar, + /// Thread name. + pub ki_tdname: [c_char; crate::TDNAMLEN + 1], + /// Wchan message. + pub ki_wmesg: [c_char; crate::WMESGLEN + 1], + /// Setlogin name. + pub ki_login: [c_char; crate::LOGNAMELEN + 1], + /// Lock name. + pub ki_lockname: [c_char; crate::LOCKNAMELEN + 1], + /// Command name. + pub ki_comm: [c_char; crate::COMMLEN + 1], + /// Emulation name. + pub ki_emul: [c_char; crate::KI_EMULNAMELEN + 1], + /// Login class. + pub ki_loginclass: [c_char; crate::LOGINCLASSLEN + 1], + /// More thread name. + pub ki_moretdname: [c_char; crate::MAXCOMLEN - crate::TDNAMLEN + 1], + /// Spare string space. + pub ki_sparestrings: [[c_char; 23]; 2], // little hack to allow PartialEq + /// Spare room for growth. + pub ki_spareints: [c_int; crate::KI_NSPARE_INT], + /// Which cpu we are on. + pub ki_oncpu: c_int, + /// Last cpu we were on. + pub ki_lastcpu: c_int, + /// PID of tracing process. + pub ki_tracer: c_int, + /// P2_* flags. + pub ki_flag2: c_int, + /// Default FIB number. + pub ki_fibnum: c_int, + /// Credential flags. + pub ki_cr_flags: crate::u_int, + /// Process jail ID. + pub ki_jid: c_int, + /// Number of threads in total. + pub ki_numthreads: c_int, + /// Thread ID. + pub ki_tid: crate::lwpid_t, + /// Process priority. + pub ki_pri: crate::priority, + /// Process rusage statistics. + pub ki_rusage: crate::rusage, + /// rusage of children processes. + pub ki_rusage_ch: crate::rusage, + // This is normally "struct pcb". + /// Kernel virtual addr of pcb. + pub ki_pcb: *mut c_void, + /// Kernel virtual addr of stack. + pub ki_kstack: *mut c_void, + /// User convenience pointer. + pub ki_udata: *mut c_void, + // This is normally "struct thread". + pub ki_tdaddr: *mut c_void, + pub ki_spareptrs: [*mut c_void; crate::KI_NSPARE_PTR], + pub ki_sparelongs: [c_long; crate::KI_NSPARE_LONG], + /// PS_* flags. + pub ki_sflag: c_long, + /// kthread flag. + pub ki_tdflags: c_long, + } + pub struct dirent { + pub d_fileno: crate::ino_t, + pub d_reclen: u16, + pub d_type: u8, + // Type of `d_namlen` changed from `char` to `u16` in FreeBSD 12: + pub d_namlen: u8, + pub d_name: [c_char; 256], + } + + pub struct statfs { + pub f_version: u32, + pub f_type: u32, + pub f_flags: u64, + pub f_bsize: u64, + pub f_iosize: u64, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: i64, + pub f_files: u64, + pub f_ffree: i64, + pub f_syncwrites: u64, + pub f_asyncwrites: u64, + pub f_syncreads: u64, + pub f_asyncreads: u64, + f_spare: [u64; 10], + pub f_namemax: u32, + pub f_owner: crate::uid_t, + pub f_fsid: crate::fsid_t, + f_charspare: [c_char; 80], + pub f_fstypename: [c_char; 16], + // Array length changed from 88 to 1024 in FreeBSD 12: + pub f_mntfromname: [c_char; 88], + // Array length changed from 88 to 1024 in FreeBSD 12: + pub f_mntonname: [c_char; 88], + } + + pub struct vnstat { + pub vn_fileid: u64, + pub vn_size: u64, + pub vn_mntdir: *mut c_char, + pub vn_dev: u32, + pub vn_fsid: u32, + pub vn_type: c_int, + pub vn_mode: u16, + pub vn_devname: [c_char; crate::SPECNAMELEN as usize + 1], + } +} + +pub const ELAST: c_int = 96; +pub const RAND_MAX: c_int = 0x7fff_fffd; +pub const KI_NSPARE_PTR: usize = 6; +pub const MINCORE_SUPER: c_int = 0x20; +/// max length of devicename +pub const SPECNAMELEN: c_int = 63; + +safe_f! { + pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { + let major = major as crate::dev_t; + let minor = minor as crate::dev_t; + (major << 8) | minor + } + + pub const fn major(dev: crate::dev_t) -> c_int { + ((dev >> 8) & 0xff) as c_int + } + + pub const fn minor(dev: crate::dev_t) -> c_int { + (dev & 0xffff00ff) as c_int + } +} + +extern "C" { + // Return type c_int was removed in FreeBSD 12 + pub fn setgrent() -> c_int; + + // Type of `addr` argument changed from `const void*` to `void*` + // in FreeBSD 12 + pub fn mprotect(addr: *const c_void, len: size_t, prot: c_int) -> c_int; + + // Return type c_int was removed in FreeBSD 12 + pub fn freelocale(loc: crate::locale_t) -> c_int; + + // Return type c_int changed to ssize_t in FreeBSD 12: + pub fn msgrcv( + msqid: c_int, + msgp: *mut c_void, + msgsz: size_t, + msgtyp: c_long, + msgflg: c_int, + ) -> c_int; + + // Type of `path` argument changed from `const void*` to `void*` + // in FreeBSD 12 + pub fn dirname(path: *const c_char) -> *mut c_char; + pub fn basename(path: *const c_char) -> *mut c_char; + + // Argument order of the function pointer changed in FreeBSD 14. From 14 onwards the signature + // matches the POSIX specification by having the third argument be a mutable pointer, on + // earlier versions the first argument is the mutable pointer. + #[link_name = "qsort_r@FBSD_1.0"] + pub fn qsort_r( + base: *mut c_void, + num: size_t, + size: size_t, + arg: *mut c_void, + compar: Option c_int>, + ); +} + +cfg_if! { + if #[cfg(target_pointer_width = "64")] { + mod b64; + pub use self::b64::*; + } else { + mod b32; + pub use self::b32::*; + } +} diff --git a/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs new file mode 100644 index 0000000..34979f8 --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs @@ -0,0 +1,366 @@ +use crate::off_t; +use crate::prelude::*; + +// APIs in FreeBSD 12 that have changed since 11. + +pub type nlink_t = u64; +pub type dev_t = u64; +pub type ino_t = u64; +pub type shmatt_t = c_uint; + +s! { + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, + pub shm_lpid: crate::pid_t, + pub shm_cpid: crate::pid_t, + pub shm_nattch: crate::shmatt_t, + pub shm_atime: crate::time_t, + pub shm_dtime: crate::time_t, + pub shm_ctime: crate::time_t, + } + + pub struct kevent { + pub ident: crate::uintptr_t, + pub filter: c_short, + pub flags: c_ushort, + pub fflags: c_uint, + pub data: i64, + pub udata: *mut c_void, + pub ext: [u64; 4], + } + + pub struct kvm_page { + pub version: c_uint, + pub paddr: c_ulong, + pub kmap_vaddr: c_ulong, + pub dmap_vaddr: c_ulong, + pub prot: crate::vm_prot_t, + pub offset: crate::u_long, + pub len: size_t, + } + + pub struct kinfo_proc { + /// Size of this structure. + pub ki_structsize: c_int, + /// Reserved: layout identifier. + pub ki_layout: c_int, + /// Address of command arguments. + pub ki_args: *mut crate::pargs, + // This is normally "struct proc". + /// Address of proc. + pub ki_paddr: *mut c_void, + // This is normally "struct user". + /// Kernel virtual address of u-area. + pub ki_addr: *mut c_void, + // This is normally "struct vnode". + /// Pointer to trace file. + pub ki_tracep: *mut c_void, + // This is normally "struct vnode". + /// Pointer to executable file. + pub ki_textvp: *mut c_void, + /// Pointer to open file info. + pub ki_fd: *mut crate::filedesc, + // This is normally "struct vmspace". + /// Pointer to kernel vmspace struct. + pub ki_vmspace: *mut c_void, + /// Sleep address. + pub ki_wchan: *mut c_void, + /// Process identifier. + pub ki_pid: crate::pid_t, + /// Parent process ID. + pub ki_ppid: crate::pid_t, + /// Process group ID. + pub ki_pgid: crate::pid_t, + /// tty process group ID. + pub ki_tpgid: crate::pid_t, + /// Process session ID. + pub ki_sid: crate::pid_t, + /// Terminal session ID. + pub ki_tsid: crate::pid_t, + /// Job control counter. + pub ki_jobc: c_short, + /// Unused (just here for alignment). + pub ki_spare_short1: c_short, + /// Controlling tty dev. + pub ki_tdev_freebsd11: u32, + /// Signals arrived but not delivered. + pub ki_siglist: crate::sigset_t, + /// Current signal mask. + pub ki_sigmask: crate::sigset_t, + /// Signals being ignored. + pub ki_sigignore: crate::sigset_t, + /// Signals being caught by user. + pub ki_sigcatch: crate::sigset_t, + /// Effective user ID. + pub ki_uid: crate::uid_t, + /// Real user ID. + pub ki_ruid: crate::uid_t, + /// Saved effective user ID. + pub ki_svuid: crate::uid_t, + /// Real group ID. + pub ki_rgid: crate::gid_t, + /// Saved effective group ID. + pub ki_svgid: crate::gid_t, + /// Number of groups. + pub ki_ngroups: c_short, + /// Unused (just here for alignment). + pub ki_spare_short2: c_short, + /// Groups. + pub ki_groups: [crate::gid_t; crate::KI_NGROUPS], + /// Virtual size. + pub ki_size: crate::vm_size_t, + /// Current resident set size in pages. + pub ki_rssize: crate::segsz_t, + /// Resident set size before last swap. + pub ki_swrss: crate::segsz_t, + /// Text size (pages) XXX. + pub ki_tsize: crate::segsz_t, + /// Data size (pages) XXX. + pub ki_dsize: crate::segsz_t, + /// Stack size (pages). + pub ki_ssize: crate::segsz_t, + /// Exit status for wait & stop signal. + pub ki_xstat: crate::u_short, + /// Accounting flags. + pub ki_acflag: crate::u_short, + /// %cpu for process during `ki_swtime`. + pub ki_pctcpu: crate::fixpt_t, + /// Time averaged value of `ki_cpticks`. + pub ki_estcpu: crate::u_int, + /// Time since last blocked. + pub ki_slptime: crate::u_int, + /// Time swapped in or out. + pub ki_swtime: crate::u_int, + /// Number of copy-on-write faults. + pub ki_cow: crate::u_int, + /// Real time in microsec. + pub ki_runtime: u64, + /// Starting time. + pub ki_start: crate::timeval, + /// Time used by process children. + pub ki_childtime: crate::timeval, + /// P_* flags. + pub ki_flag: c_long, + /// KI_* flags (below). + pub ki_kiflag: c_long, + /// Kernel trace points. + pub ki_traceflag: c_int, + /// S* process status. + pub ki_stat: c_char, + /// Process "nice" value. + pub ki_nice: i8, // signed char + /// Process lock (prevent swap) count. + pub ki_lock: c_char, + /// Run queue index. + pub ki_rqindex: c_char, + /// Which cpu we are on. + pub ki_oncpu_old: c_uchar, + /// Last cpu we were on. + pub ki_lastcpu_old: c_uchar, + /// Thread name. + pub ki_tdname: [c_char; crate::TDNAMLEN + 1], + /// Wchan message. + pub ki_wmesg: [c_char; crate::WMESGLEN + 1], + /// Setlogin name. + pub ki_login: [c_char; crate::LOGNAMELEN + 1], + /// Lock name. + pub ki_lockname: [c_char; crate::LOCKNAMELEN + 1], + /// Command name. + pub ki_comm: [c_char; crate::COMMLEN + 1], + /// Emulation name. + pub ki_emul: [c_char; crate::KI_EMULNAMELEN + 1], + /// Login class. + pub ki_loginclass: [c_char; crate::LOGINCLASSLEN + 1], + /// More thread name. + pub ki_moretdname: [c_char; crate::MAXCOMLEN - crate::TDNAMLEN + 1], + /// Spare string space. + pub ki_sparestrings: [[c_char; 23]; 2], // little hack to allow PartialEq + /// Spare room for growth. + pub ki_spareints: [c_int; crate::KI_NSPARE_INT], + /// Controlling tty dev. + pub ki_tdev: crate::dev_t, + /// Which cpu we are on. + pub ki_oncpu: c_int, + /// Last cpu we were on. + pub ki_lastcpu: c_int, + /// PID of tracing process. + pub ki_tracer: c_int, + /// P2_* flags. + pub ki_flag2: c_int, + /// Default FIB number. + pub ki_fibnum: c_int, + /// Credential flags. + pub ki_cr_flags: crate::u_int, + /// Process jail ID. + pub ki_jid: c_int, + /// Number of threads in total. + pub ki_numthreads: c_int, + /// Thread ID. + pub ki_tid: crate::lwpid_t, + /// Process priority. + pub ki_pri: crate::priority, + /// Process rusage statistics. + pub ki_rusage: crate::rusage, + /// rusage of children processes. + pub ki_rusage_ch: crate::rusage, + // This is normally "struct pcb". + /// Kernel virtual addr of pcb. + pub ki_pcb: *mut c_void, + /// Kernel virtual addr of stack. + pub ki_kstack: *mut c_void, + /// User convenience pointer. + pub ki_udata: *mut c_void, + // This is normally "struct thread". + pub ki_tdaddr: *mut c_void, + pub ki_spareptrs: [*mut c_void; crate::KI_NSPARE_PTR], + pub ki_sparelongs: [c_long; crate::KI_NSPARE_LONG], + /// PS_* flags. + pub ki_sflag: c_long, + /// kthread flag. + pub ki_tdflags: c_long, + } + + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_nlink: crate::nlink_t, + pub st_mode: crate::mode_t, + st_padding0: Padding, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + st_padding1: Padding, + pub st_rdev: crate::dev_t, + #[cfg(target_arch = "x86")] + st_atim_ext: i32, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + #[cfg(target_arch = "x86")] + st_mtim_ext: i32, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + #[cfg(target_arch = "x86")] + st_ctim_ext: i32, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + #[cfg(target_arch = "x86")] + st_btim_ext: i32, + pub st_birthtime: crate::time_t, + pub st_birthtime_nsec: c_long, + pub st_size: off_t, + pub st_blocks: crate::blkcnt_t, + pub st_blksize: crate::blksize_t, + pub st_flags: crate::fflags_t, + pub st_gen: u64, + pub st_spare: [u64; 10], + } + + pub struct dirent { + pub d_fileno: crate::ino_t, + pub d_off: off_t, + pub d_reclen: u16, + pub d_type: u8, + d_pad0: Padding, + pub d_namlen: u16, + d_pad1: Padding, + pub d_name: [c_char; 256], + } + + pub struct statfs { + pub f_version: u32, + pub f_type: u32, + pub f_flags: u64, + pub f_bsize: u64, + pub f_iosize: u64, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: i64, + pub f_files: u64, + pub f_ffree: i64, + pub f_syncwrites: u64, + pub f_asyncwrites: u64, + pub f_syncreads: u64, + pub f_asyncreads: u64, + f_spare: [u64; 10], + pub f_namemax: u32, + pub f_owner: crate::uid_t, + pub f_fsid: crate::fsid_t, + f_charspare: [c_char; 80], + pub f_fstypename: [c_char; 16], + pub f_mntfromname: [c_char; 1024], + pub f_mntonname: [c_char; 1024], + } + + pub struct vnstat { + pub vn_fileid: u64, + pub vn_size: u64, + pub vn_dev: u64, + pub vn_fsid: u64, + pub vn_mntdir: *mut c_char, + pub vn_type: c_int, + pub vn_mode: u16, + pub vn_devname: [c_char; crate::SPECNAMELEN as usize + 1], + } +} + +pub const RAND_MAX: c_int = 0x7fff_fffd; +pub const ELAST: c_int = 97; + +/// max length of devicename +pub const SPECNAMELEN: c_int = 63; +pub const KI_NSPARE_PTR: usize = 6; + +pub const MINCORE_SUPER: c_int = 0x20; + +safe_f! { + pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { + let major = major as crate::dev_t; + let minor = minor as crate::dev_t; + let mut dev = 0; + dev |= ((major & 0xffffff00) as dev_t) << 32; + dev |= ((major & 0x000000ff) as dev_t) << 8; + dev |= ((minor & 0x0000ff00) as dev_t) << 24; + dev |= ((minor & 0xffff00ff) as dev_t) << 0; + dev + } + + pub const fn major(dev: crate::dev_t) -> c_int { + (((dev >> 32) & 0xffffff00) | ((dev >> 8) & 0xff)) as c_int + } + + pub const fn minor(dev: crate::dev_t) -> c_int { + (((dev >> 24) & 0xff00) | (dev & 0xffff00ff)) as c_int + } +} + +extern "C" { + pub fn setgrent(); + pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; + pub fn freelocale(loc: crate::locale_t); + pub fn msgrcv( + msqid: c_int, + msgp: *mut c_void, + msgsz: size_t, + msgtyp: c_long, + msgflg: c_int, + ) -> ssize_t; + + pub fn dirname(path: *mut c_char) -> *mut c_char; + pub fn basename(path: *mut c_char) -> *mut c_char; + + #[link_name = "qsort_r@FBSD_1.0"] + pub fn qsort_r( + base: *mut c_void, + num: size_t, + size: size_t, + arg: *mut c_void, + compar: Option c_int>, + ); +} + +cfg_if! { + if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } +} diff --git a/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/x86_64.rs b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/x86_64.rs new file mode 100644 index 0000000..b29171c --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/x86_64.rs @@ -0,0 +1,7 @@ +use crate::prelude::*; + +pub const PROC_KPTI_CTL: c_int = crate::PROC_PROCCTL_MD_MIN; +pub const PROC_KPTI_CTL_ENABLE_ON_EXEC: c_int = 1; +pub const PROC_KPTI_CTL_DISABLE_ON_EXEC: c_int = 2; +pub const PROC_KPTI_STATUS: c_int = crate::PROC_PROCCTL_MD_MIN + 1; +pub const PROC_KPTI_STATUS_ACTIVE: c_int = 0x80000000; diff --git a/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs new file mode 100644 index 0000000..6ef62be --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs @@ -0,0 +1,410 @@ +use crate::off_t; +use crate::prelude::*; + +// APIs in FreeBSD 13 that have changed since 11. + +pub type nlink_t = u64; +pub type dev_t = u64; +pub type ino_t = u64; +pub type shmatt_t = c_uint; +pub type kpaddr_t = u64; +pub type kssize_t = i64; +pub type domainset_t = __c_anonymous_domainset; + +s! { + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, + pub shm_lpid: crate::pid_t, + pub shm_cpid: crate::pid_t, + pub shm_nattch: crate::shmatt_t, + pub shm_atime: crate::time_t, + pub shm_dtime: crate::time_t, + pub shm_ctime: crate::time_t, + } + + pub struct kevent { + pub ident: crate::uintptr_t, + pub filter: c_short, + pub flags: c_ushort, + pub fflags: c_uint, + pub data: i64, + pub udata: *mut c_void, + pub ext: [u64; 4], + } + + pub struct kvm_page { + pub kp_version: crate::u_int, + pub kp_paddr: crate::kpaddr_t, + pub kp_kmap_vaddr: crate::kvaddr_t, + pub kp_dmap_vaddr: crate::kvaddr_t, + pub kp_prot: crate::vm_prot_t, + pub kp_offset: off_t, + pub kp_len: size_t, + } + + pub struct __c_anonymous_domainset { + #[cfg(target_pointer_width = "64")] + _priv: [c_ulong; 4], + #[cfg(target_pointer_width = "32")] + _priv: [c_ulong; 8], + } + + pub struct kinfo_proc { + /// Size of this structure. + pub ki_structsize: c_int, + /// Reserved: layout identifier. + pub ki_layout: c_int, + /// Address of command arguments. + pub ki_args: *mut crate::pargs, + // This is normally "struct proc". + /// Address of proc. + pub ki_paddr: *mut c_void, + // This is normally "struct user". + /// Kernel virtual address of u-area. + pub ki_addr: *mut c_void, + // This is normally "struct vnode". + /// Pointer to trace file. + pub ki_tracep: *mut c_void, + // This is normally "struct vnode". + /// Pointer to executable file. + pub ki_textvp: *mut c_void, + /// Pointer to open file info. + pub ki_fd: *mut crate::filedesc, + // This is normally "struct vmspace". + /// Pointer to kernel vmspace struct. + pub ki_vmspace: *mut c_void, + /// Sleep address. + pub ki_wchan: *const c_void, + /// Process identifier. + pub ki_pid: crate::pid_t, + /// Parent process ID. + pub ki_ppid: crate::pid_t, + /// Process group ID. + pub ki_pgid: crate::pid_t, + /// tty process group ID. + pub ki_tpgid: crate::pid_t, + /// Process session ID. + pub ki_sid: crate::pid_t, + /// Terminal session ID. + pub ki_tsid: crate::pid_t, + /// Job control counter. + pub ki_jobc: c_short, + /// Unused (just here for alignment). + pub ki_spare_short1: c_short, + /// Controlling tty dev. + pub ki_tdev_freebsd11: u32, + /// Signals arrived but not delivered. + pub ki_siglist: crate::sigset_t, + /// Current signal mask. + pub ki_sigmask: crate::sigset_t, + /// Signals being ignored. + pub ki_sigignore: crate::sigset_t, + /// Signals being caught by user. + pub ki_sigcatch: crate::sigset_t, + /// Effective user ID. + pub ki_uid: crate::uid_t, + /// Real user ID. + pub ki_ruid: crate::uid_t, + /// Saved effective user ID. + pub ki_svuid: crate::uid_t, + /// Real group ID. + pub ki_rgid: crate::gid_t, + /// Saved effective group ID. + pub ki_svgid: crate::gid_t, + /// Number of groups. + pub ki_ngroups: c_short, + /// Unused (just here for alignment). + pub ki_spare_short2: c_short, + /// Groups. + pub ki_groups: [crate::gid_t; crate::KI_NGROUPS], + /// Virtual size. + pub ki_size: crate::vm_size_t, + /// Current resident set size in pages. + pub ki_rssize: crate::segsz_t, + /// Resident set size before last swap. + pub ki_swrss: crate::segsz_t, + /// Text size (pages) XXX. + pub ki_tsize: crate::segsz_t, + /// Data size (pages) XXX. + pub ki_dsize: crate::segsz_t, + /// Stack size (pages). + pub ki_ssize: crate::segsz_t, + /// Exit status for wait & stop signal. + pub ki_xstat: crate::u_short, + /// Accounting flags. + pub ki_acflag: crate::u_short, + /// %cpu for process during `ki_swtime`. + pub ki_pctcpu: crate::fixpt_t, + /// Time averaged value of `ki_cpticks`. + pub ki_estcpu: crate::u_int, + /// Time since last blocked. + pub ki_slptime: crate::u_int, + /// Time swapped in or out. + pub ki_swtime: crate::u_int, + /// Number of copy-on-write faults. + pub ki_cow: crate::u_int, + /// Real time in microsec. + pub ki_runtime: u64, + /// Starting time. + pub ki_start: crate::timeval, + /// Time used by process children. + pub ki_childtime: crate::timeval, + /// P_* flags. + pub ki_flag: c_long, + /// KI_* flags (below). + pub ki_kiflag: c_long, + /// Kernel trace points. + pub ki_traceflag: c_int, + /// S* process status. + pub ki_stat: c_char, + /// Process "nice" value. + pub ki_nice: i8, // signed char + /// Process lock (prevent swap) count. + pub ki_lock: c_char, + /// Run queue index. + pub ki_rqindex: c_char, + /// Which cpu we are on. + pub ki_oncpu_old: c_uchar, + /// Last cpu we were on. + pub ki_lastcpu_old: c_uchar, + /// Thread name. + pub ki_tdname: [c_char; crate::TDNAMLEN + 1], + /// Wchan message. + pub ki_wmesg: [c_char; crate::WMESGLEN + 1], + /// Setlogin name. + pub ki_login: [c_char; crate::LOGNAMELEN + 1], + /// Lock name. + pub ki_lockname: [c_char; crate::LOCKNAMELEN + 1], + /// Command name. + pub ki_comm: [c_char; crate::COMMLEN + 1], + /// Emulation name. + pub ki_emul: [c_char; crate::KI_EMULNAMELEN + 1], + /// Login class. + pub ki_loginclass: [c_char; crate::LOGINCLASSLEN + 1], + /// More thread name. + pub ki_moretdname: [c_char; crate::MAXCOMLEN - crate::TDNAMLEN + 1], + /// Spare string space. + pub ki_sparestrings: [[c_char; 23]; 2], // little hack to allow PartialEq + /// Spare room for growth. + pub ki_spareints: [c_int; crate::KI_NSPARE_INT], + /// Controlling tty dev. + pub ki_tdev: u64, + /// Which cpu we are on. + pub ki_oncpu: c_int, + /// Last cpu we were on. + pub ki_lastcpu: c_int, + /// PID of tracing process. + pub ki_tracer: c_int, + /// P2_* flags. + pub ki_flag2: c_int, + /// Default FIB number. + pub ki_fibnum: c_int, + /// Credential flags. + pub ki_cr_flags: crate::u_int, + /// Process jail ID. + pub ki_jid: c_int, + /// Number of threads in total. + pub ki_numthreads: c_int, + /// Thread ID. + pub ki_tid: crate::lwpid_t, + /// Process priority. + pub ki_pri: crate::priority, + /// Process rusage statistics. + pub ki_rusage: crate::rusage, + /// rusage of children processes. + pub ki_rusage_ch: crate::rusage, + // This is normally "struct pcb". + /// Kernel virtual addr of pcb. + pub ki_pcb: *mut c_void, + /// Kernel virtual addr of stack. + pub ki_kstack: *mut c_void, + /// User convenience pointer. + pub ki_udata: *mut c_void, + // This is normally "struct thread". + pub ki_tdaddr: *mut c_void, + // This is normally "struct pwddesc". + /// Pointer to process paths info. + pub ki_pd: *mut c_void, + pub ki_spareptrs: [*mut c_void; crate::KI_NSPARE_PTR], + pub ki_sparelongs: [c_long; crate::KI_NSPARE_LONG], + /// PS_* flags. + pub ki_sflag: c_long, + /// kthread flag. + pub ki_tdflags: c_long, + } + + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_nlink: crate::nlink_t, + pub st_mode: crate::mode_t, + st_padding0: Padding, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + st_padding1: Padding, + pub st_rdev: crate::dev_t, + #[cfg(target_arch = "x86")] + st_atim_ext: i32, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + #[cfg(target_arch = "x86")] + st_mtim_ext: i32, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + #[cfg(target_arch = "x86")] + st_ctim_ext: i32, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + #[cfg(target_arch = "x86")] + st_btim_ext: i32, + pub st_birthtime: crate::time_t, + pub st_birthtime_nsec: c_long, + pub st_size: off_t, + pub st_blocks: crate::blkcnt_t, + pub st_blksize: crate::blksize_t, + pub st_flags: crate::fflags_t, + pub st_gen: u64, + pub st_spare: [u64; 10], + } + + pub struct dirent { + pub d_fileno: crate::ino_t, + pub d_off: off_t, + pub d_reclen: u16, + pub d_type: u8, + d_pad0: Padding, + pub d_namlen: u16, + d_pad1: Padding, + pub d_name: [c_char; 256], + } + + pub struct statfs { + pub f_version: u32, + pub f_type: u32, + pub f_flags: u64, + pub f_bsize: u64, + pub f_iosize: u64, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: i64, + pub f_files: u64, + pub f_ffree: i64, + pub f_syncwrites: u64, + pub f_asyncwrites: u64, + pub f_syncreads: u64, + pub f_asyncreads: u64, + f_spare: [u64; 10], + pub f_namemax: u32, + pub f_owner: crate::uid_t, + pub f_fsid: crate::fsid_t, + f_charspare: [c_char; 80], + pub f_fstypename: [c_char; 16], + pub f_mntfromname: [c_char; 1024], + pub f_mntonname: [c_char; 1024], + } + + pub struct vnstat { + pub vn_fileid: u64, + pub vn_size: u64, + pub vn_dev: u64, + pub vn_fsid: u64, + pub vn_mntdir: *mut c_char, + pub vn_type: c_int, + pub vn_mode: u16, + pub vn_devname: [c_char; crate::SPECNAMELEN as usize + 1], + } +} + +pub const RAND_MAX: c_int = 0x7fff_ffff; +pub const ELAST: c_int = 97; + +pub const KF_TYPE_EVENTFD: c_int = 13; + +/// max length of devicename +pub const SPECNAMELEN: c_int = 255; +pub const KI_NSPARE_PTR: usize = 5; + +/// domainset policies +pub const DOMAINSET_POLICY_INVALID: c_int = 0; +pub const DOMAINSET_POLICY_ROUNDROBIN: c_int = 1; +pub const DOMAINSET_POLICY_FIRSTTOUCH: c_int = 2; +pub const DOMAINSET_POLICY_PREFER: c_int = 3; +pub const DOMAINSET_POLICY_INTERLEAVE: c_int = 4; + +pub const MINCORE_SUPER: c_int = 0x20; + +safe_f! { + pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { + let major = major as crate::dev_t; + let minor = minor as crate::dev_t; + let mut dev = 0; + dev |= ((major & 0xffffff00) as dev_t) << 32; + dev |= ((major & 0x000000ff) as dev_t) << 8; + dev |= ((minor & 0x0000ff00) as dev_t) << 24; + dev |= ((minor & 0xffff00ff) as dev_t) << 0; + dev + } + + pub const fn major(dev: crate::dev_t) -> c_int { + (((dev >> 32) & 0xffffff00) | ((dev >> 8) & 0xff)) as c_int + } + + pub const fn minor(dev: crate::dev_t) -> c_int { + (((dev >> 24) & 0xff00) | (dev & 0xffff00ff)) as c_int + } +} + +extern "C" { + pub fn setgrent(); + pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; + pub fn freelocale(loc: crate::locale_t); + pub fn msgrcv( + msqid: c_int, + msgp: *mut c_void, + msgsz: size_t, + msgtyp: c_long, + msgflg: c_int, + ) -> ssize_t; + + pub fn cpuset_getdomain( + level: crate::cpulevel_t, + which: crate::cpuwhich_t, + id: crate::id_t, + setsize: size_t, + mask: *mut crate::domainset_t, + policy: *mut c_int, + ) -> c_int; + pub fn cpuset_setdomain( + level: crate::cpulevel_t, + which: crate::cpuwhich_t, + id: crate::id_t, + setsize: size_t, + mask: *const crate::domainset_t, + policy: c_int, + ) -> c_int; + + pub fn dirname(path: *mut c_char) -> *mut c_char; + pub fn basename(path: *mut c_char) -> *mut c_char; + + #[link_name = "qsort_r@FBSD_1.0"] + pub fn qsort_r( + base: *mut c_void, + num: size_t, + size: size_t, + arg: *mut c_void, + compar: Option c_int>, + ); +} + +#[link(name = "kvm")] +extern "C" { + pub fn kvm_kerndisp(kd: *mut crate::kvm_t) -> crate::kssize_t; +} + +cfg_if! { + if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } +} diff --git a/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd13/x86_64.rs b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd13/x86_64.rs new file mode 100644 index 0000000..b29171c --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd13/x86_64.rs @@ -0,0 +1,7 @@ +use crate::prelude::*; + +pub const PROC_KPTI_CTL: c_int = crate::PROC_PROCCTL_MD_MIN; +pub const PROC_KPTI_CTL_ENABLE_ON_EXEC: c_int = 1; +pub const PROC_KPTI_CTL_DISABLE_ON_EXEC: c_int = 2; +pub const PROC_KPTI_STATUS: c_int = crate::PROC_PROCCTL_MD_MIN + 1; +pub const PROC_KPTI_STATUS_ACTIVE: c_int = 0x80000000; diff --git a/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs new file mode 100644 index 0000000..f2753ce --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs @@ -0,0 +1,411 @@ +use crate::off_t; +use crate::prelude::*; + +// APIs in FreeBSD 14 that have changed since 11. + +pub type nlink_t = u64; +pub type dev_t = u64; +pub type ino_t = u64; +pub type shmatt_t = c_uint; +pub type kpaddr_t = u64; +pub type kssize_t = i64; +pub type domainset_t = __c_anonymous_domainset; + +s! { + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, + pub shm_lpid: crate::pid_t, + pub shm_cpid: crate::pid_t, + pub shm_nattch: crate::shmatt_t, + pub shm_atime: crate::time_t, + pub shm_dtime: crate::time_t, + pub shm_ctime: crate::time_t, + } + + pub struct kevent { + pub ident: crate::uintptr_t, + pub filter: c_short, + pub flags: c_ushort, + pub fflags: c_uint, + pub data: i64, + pub udata: *mut c_void, + pub ext: [u64; 4], + } + + pub struct kvm_page { + pub kp_version: crate::u_int, + pub kp_paddr: crate::kpaddr_t, + pub kp_kmap_vaddr: crate::kvaddr_t, + pub kp_dmap_vaddr: crate::kvaddr_t, + pub kp_prot: crate::vm_prot_t, + pub kp_offset: off_t, + pub kp_len: size_t, + } + + pub struct __c_anonymous_domainset { + #[cfg(target_pointer_width = "64")] + _priv: [c_ulong; 4], + #[cfg(target_pointer_width = "32")] + _priv: [c_ulong; 8], + } + + pub struct kinfo_proc { + /// Size of this structure. + pub ki_structsize: c_int, + /// Reserved: layout identifier. + pub ki_layout: c_int, + /// Address of command arguments. + pub ki_args: *mut crate::pargs, + // This is normally "struct proc". + /// Address of proc. + pub ki_paddr: *mut c_void, + // This is normally "struct user". + /// Kernel virtual address of u-area. + pub ki_addr: *mut c_void, + // This is normally "struct vnode". + /// Pointer to trace file. + pub ki_tracep: *mut c_void, + // This is normally "struct vnode". + /// Pointer to executable file. + pub ki_textvp: *mut c_void, + /// Pointer to open file info. + pub ki_fd: *mut crate::filedesc, + // This is normally "struct vmspace". + /// Pointer to kernel vmspace struct. + pub ki_vmspace: *mut c_void, + /// Sleep address. + pub ki_wchan: *const c_void, + /// Process identifier. + pub ki_pid: crate::pid_t, + /// Parent process ID. + pub ki_ppid: crate::pid_t, + /// Process group ID. + pub ki_pgid: crate::pid_t, + /// tty process group ID. + pub ki_tpgid: crate::pid_t, + /// Process session ID. + pub ki_sid: crate::pid_t, + /// Terminal session ID. + pub ki_tsid: crate::pid_t, + /// Job control counter. + pub ki_jobc: c_short, + /// Unused (just here for alignment). + pub ki_spare_short1: c_short, + /// Controlling tty dev. + pub ki_tdev_freebsd11: u32, + /// Signals arrived but not delivered. + pub ki_siglist: crate::sigset_t, + /// Current signal mask. + pub ki_sigmask: crate::sigset_t, + /// Signals being ignored. + pub ki_sigignore: crate::sigset_t, + /// Signals being caught by user. + pub ki_sigcatch: crate::sigset_t, + /// Effective user ID. + pub ki_uid: crate::uid_t, + /// Real user ID. + pub ki_ruid: crate::uid_t, + /// Saved effective user ID. + pub ki_svuid: crate::uid_t, + /// Real group ID. + pub ki_rgid: crate::gid_t, + /// Saved effective group ID. + pub ki_svgid: crate::gid_t, + /// Number of groups. + pub ki_ngroups: c_short, + /// Unused (just here for alignment). + pub ki_spare_short2: c_short, + /// Groups. + pub ki_groups: [crate::gid_t; crate::KI_NGROUPS], + /// Virtual size. + pub ki_size: crate::vm_size_t, + /// Current resident set size in pages. + pub ki_rssize: crate::segsz_t, + /// Resident set size before last swap. + pub ki_swrss: crate::segsz_t, + /// Text size (pages) XXX. + pub ki_tsize: crate::segsz_t, + /// Data size (pages) XXX. + pub ki_dsize: crate::segsz_t, + /// Stack size (pages). + pub ki_ssize: crate::segsz_t, + /// Exit status for wait & stop signal. + pub ki_xstat: crate::u_short, + /// Accounting flags. + pub ki_acflag: crate::u_short, + /// %cpu for process during `ki_swtime`. + pub ki_pctcpu: crate::fixpt_t, + /// Time averaged value of `ki_cpticks`. + pub ki_estcpu: crate::u_int, + /// Time since last blocked. + pub ki_slptime: crate::u_int, + /// Time swapped in or out. + pub ki_swtime: crate::u_int, + /// Number of copy-on-write faults. + pub ki_cow: crate::u_int, + /// Real time in microsec. + pub ki_runtime: u64, + /// Starting time. + pub ki_start: crate::timeval, + /// Time used by process children. + pub ki_childtime: crate::timeval, + /// P_* flags. + pub ki_flag: c_long, + /// KI_* flags (below). + pub ki_kiflag: c_long, + /// Kernel trace points. + pub ki_traceflag: c_int, + /// S* process status. + pub ki_stat: c_char, + /// Process "nice" value. + pub ki_nice: i8, // signed char + /// Process lock (prevent swap) count. + pub ki_lock: c_char, + /// Run queue index. + pub ki_rqindex: c_char, + /// Which cpu we are on. + pub ki_oncpu_old: c_uchar, + /// Last cpu we were on. + pub ki_lastcpu_old: c_uchar, + /// Thread name. + pub ki_tdname: [c_char; crate::TDNAMLEN + 1], + /// Wchan message. + pub ki_wmesg: [c_char; crate::WMESGLEN + 1], + /// Setlogin name. + pub ki_login: [c_char; crate::LOGNAMELEN + 1], + /// Lock name. + pub ki_lockname: [c_char; crate::LOCKNAMELEN + 1], + /// Command name. + pub ki_comm: [c_char; crate::COMMLEN + 1], + /// Emulation name. + pub ki_emul: [c_char; crate::KI_EMULNAMELEN + 1], + /// Login class. + pub ki_loginclass: [c_char; crate::LOGINCLASSLEN + 1], + /// More thread name. + pub ki_moretdname: [c_char; crate::MAXCOMLEN - crate::TDNAMLEN + 1], + /// Spare string space. + pub ki_sparestrings: [[c_char; 23]; 2], // little hack to allow PartialEq + /// Spare room for growth. + pub ki_spareints: [c_int; crate::KI_NSPARE_INT], + /// Controlling tty dev. + pub ki_tdev: u64, + /// Which cpu we are on. + pub ki_oncpu: c_int, + /// Last cpu we were on. + pub ki_lastcpu: c_int, + /// PID of tracing process. + pub ki_tracer: c_int, + /// P2_* flags. + pub ki_flag2: c_int, + /// Default FIB number. + pub ki_fibnum: c_int, + /// Credential flags. + pub ki_cr_flags: crate::u_int, + /// Process jail ID. + pub ki_jid: c_int, + /// Number of threads in total. + pub ki_numthreads: c_int, + /// Thread ID. + pub ki_tid: crate::lwpid_t, + /// Process priority. + pub ki_pri: crate::priority, + /// Process rusage statistics. + pub ki_rusage: crate::rusage, + /// rusage of children processes. + pub ki_rusage_ch: crate::rusage, + // This is normally "struct pcb". + /// Kernel virtual addr of pcb. + pub ki_pcb: *mut c_void, + /// Kernel virtual addr of stack. + pub ki_kstack: *mut c_void, + /// User convenience pointer. + pub ki_udata: *mut c_void, + // This is normally "struct thread". + pub ki_tdaddr: *mut c_void, + // This is normally "struct pwddesc". + /// Pointer to process paths info. + pub ki_pd: *mut c_void, + pub ki_spareptrs: [*mut c_void; crate::KI_NSPARE_PTR], + pub ki_sparelongs: [c_long; crate::KI_NSPARE_LONG], + /// PS_* flags. + pub ki_sflag: c_long, + /// kthread flag. + pub ki_tdflags: c_long, + } + + #[non_exhaustive] + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_nlink: crate::nlink_t, + pub st_mode: crate::mode_t, + st_padding0: Padding, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + st_padding1: Padding, + pub st_rdev: crate::dev_t, + #[cfg(target_arch = "x86")] + st_atim_ext: i32, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + #[cfg(target_arch = "x86")] + st_mtim_ext: i32, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + #[cfg(target_arch = "x86")] + st_ctim_ext: i32, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + #[cfg(target_arch = "x86")] + st_btim_ext: i32, + pub st_birthtime: crate::time_t, + pub st_birthtime_nsec: c_long, + pub st_size: off_t, + pub st_blocks: crate::blkcnt_t, + pub st_blksize: crate::blksize_t, + pub st_flags: crate::fflags_t, + pub st_gen: u64, + pub st_filerev: u64, + pub st_spare: [u64; 9], + } + + pub struct dirent { + pub d_fileno: crate::ino_t, + pub d_off: off_t, + pub d_reclen: u16, + pub d_type: u8, + d_pad0: Padding, + pub d_namlen: u16, + d_pad1: Padding, + pub d_name: [c_char; 256], + } + + pub struct statfs { + pub f_version: u32, + pub f_type: u32, + pub f_flags: u64, + pub f_bsize: u64, + pub f_iosize: u64, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: i64, + pub f_files: u64, + pub f_ffree: i64, + pub f_syncwrites: u64, + pub f_asyncwrites: u64, + pub f_syncreads: u64, + pub f_asyncreads: u64, + f_spare: [u64; 10], + pub f_namemax: u32, + pub f_owner: crate::uid_t, + pub f_fsid: crate::fsid_t, + f_charspare: [c_char; 80], + pub f_fstypename: [c_char; 16], + pub f_mntfromname: [c_char; 1024], + pub f_mntonname: [c_char; 1024], + } + + pub struct vnstat { + pub vn_fileid: u64, + pub vn_size: u64, + pub vn_dev: u64, + pub vn_fsid: u64, + pub vn_mntdir: *mut c_char, + pub vn_type: c_int, + pub vn_mode: u16, + pub vn_devname: [c_char; crate::SPECNAMELEN as usize + 1], + } +} + +pub const RAND_MAX: c_int = 0x7fff_ffff; +pub const ELAST: c_int = 97; + +pub const KF_TYPE_EVENTFD: c_int = 13; + +/// max length of devicename +pub const SPECNAMELEN: c_int = 255; +pub const KI_NSPARE_PTR: usize = 5; + +/// domainset policies +pub const DOMAINSET_POLICY_INVALID: c_int = 0; +pub const DOMAINSET_POLICY_ROUNDROBIN: c_int = 1; +pub const DOMAINSET_POLICY_FIRSTTOUCH: c_int = 2; +pub const DOMAINSET_POLICY_PREFER: c_int = 3; +pub const DOMAINSET_POLICY_INTERLEAVE: c_int = 4; + +pub const MINCORE_SUPER: c_int = 0x60; + +safe_f! { + pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { + let major = major as crate::dev_t; + let minor = minor as crate::dev_t; + let mut dev = 0; + dev |= ((major & 0xffffff00) as dev_t) << 32; + dev |= ((major & 0x000000ff) as dev_t) << 8; + dev |= ((minor & 0x0000ff00) as dev_t) << 24; + dev |= ((minor & 0xffff00ff) as dev_t) << 0; + dev + } + + pub const fn major(dev: crate::dev_t) -> c_int { + (((dev >> 32) & 0xffffff00) | ((dev >> 8) & 0xff)) as c_int + } + + pub const fn minor(dev: crate::dev_t) -> c_int { + (((dev >> 24) & 0xff00) | (dev & 0xffff00ff)) as c_int + } +} + +extern "C" { + pub fn setgrent(); + pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; + pub fn freelocale(loc: crate::locale_t); + pub fn msgrcv( + msqid: c_int, + msgp: *mut c_void, + msgsz: size_t, + msgtyp: c_long, + msgflg: c_int, + ) -> ssize_t; + + pub fn cpuset_getdomain( + level: crate::cpulevel_t, + which: crate::cpuwhich_t, + id: crate::id_t, + setsize: size_t, + mask: *mut crate::domainset_t, + policy: *mut c_int, + ) -> c_int; + pub fn cpuset_setdomain( + level: crate::cpulevel_t, + which: crate::cpuwhich_t, + id: crate::id_t, + setsize: size_t, + mask: *const crate::domainset_t, + policy: c_int, + ) -> c_int; + + pub fn dirname(path: *mut c_char) -> *mut c_char; + pub fn basename(path: *mut c_char) -> *mut c_char; + + pub fn qsort_r( + base: *mut c_void, + num: size_t, + size: size_t, + compar: Option c_int>, + arg: *mut c_void, + ); +} + +#[link(name = "kvm")] +extern "C" { + pub fn kvm_kerndisp(kd: *mut crate::kvm_t) -> crate::kssize_t; +} + +cfg_if! { + if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } +} diff --git a/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd14/x86_64.rs b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd14/x86_64.rs new file mode 100644 index 0000000..3e03747 --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd14/x86_64.rs @@ -0,0 +1,14 @@ +use crate::prelude::*; + +pub const PROC_KPTI_CTL: c_int = crate::PROC_PROCCTL_MD_MIN; +pub const PROC_KPTI_CTL_ENABLE_ON_EXEC: c_int = 1; +pub const PROC_KPTI_CTL_DISABLE_ON_EXEC: c_int = 2; +pub const PROC_KPTI_STATUS: c_int = crate::PROC_PROCCTL_MD_MIN + 1; +pub const PROC_KPTI_STATUS_ACTIVE: c_int = 0x80000000; +pub const PROC_LA_CTL: c_int = crate::PROC_PROCCTL_MD_MIN + 2; +pub const PROC_LA_STATUS: c_int = crate::PROC_PROCCTL_MD_MIN + 3; +pub const PROC_LA_CTL_LA48_ON_EXEC: c_int = 1; +pub const PROC_LA_CTL_LA57_ON_EXEC: c_int = 2; +pub const PROC_LA_CTL_DEFAULT_ON_EXEC: c_int = 3; +pub const PROC_LA_STATUS_LA48: c_int = 0x01000000; +pub const PROC_LA_STATUS_LA57: c_int = 0x02000000; diff --git a/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs new file mode 100644 index 0000000..d9d9368 --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs @@ -0,0 +1,413 @@ +use crate::off_t; +use crate::prelude::*; + +// APIs in FreeBSD 15 that have changed since 11. + +pub type nlink_t = u64; +pub type dev_t = u64; +pub type ino_t = u64; +pub type shmatt_t = c_uint; +pub type kpaddr_t = u64; +pub type kssize_t = i64; +pub type domainset_t = __c_anonymous_domainset; + +s! { + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, + pub shm_lpid: crate::pid_t, + pub shm_cpid: crate::pid_t, + pub shm_nattch: crate::shmatt_t, + pub shm_atime: crate::time_t, + pub shm_dtime: crate::time_t, + pub shm_ctime: crate::time_t, + } + + pub struct kevent { + pub ident: crate::uintptr_t, + pub filter: c_short, + pub flags: c_ushort, + pub fflags: c_uint, + pub data: i64, + pub udata: *mut c_void, + pub ext: [u64; 4], + } + + pub struct kvm_page { + pub kp_version: crate::u_int, + pub kp_paddr: crate::kpaddr_t, + pub kp_kmap_vaddr: crate::kvaddr_t, + pub kp_dmap_vaddr: crate::kvaddr_t, + pub kp_prot: crate::vm_prot_t, + pub kp_offset: off_t, + pub kp_len: size_t, + } + + pub struct __c_anonymous_domainset { + #[cfg(target_pointer_width = "64")] + _priv: [c_ulong; 4], + #[cfg(target_pointer_width = "32")] + _priv: [c_ulong; 8], + } + + #[non_exhaustive] + pub struct kinfo_proc { + /// Size of this structure. + pub ki_structsize: c_int, + /// Reserved: layout identifier. + pub ki_layout: c_int, + /// Address of command arguments. + pub ki_args: *mut crate::pargs, + // This is normally "struct proc". + /// Address of proc. + pub ki_paddr: *mut c_void, + // This is normally "struct user". + /// Kernel virtual address of u-area. + pub ki_addr: *mut c_void, + // This is normally "struct vnode". + /// Pointer to trace file. + pub ki_tracep: *mut c_void, + // This is normally "struct vnode". + /// Pointer to executable file. + pub ki_textvp: *mut c_void, + /// Pointer to open file info. + pub ki_fd: *mut crate::filedesc, + // This is normally "struct vmspace". + /// Pointer to kernel vmspace struct. + pub ki_vmspace: *mut c_void, + /// Sleep address. + pub ki_wchan: *const c_void, + /// Process identifier. + pub ki_pid: crate::pid_t, + /// Parent process ID. + pub ki_ppid: crate::pid_t, + /// Process group ID. + pub ki_pgid: crate::pid_t, + /// tty process group ID. + pub ki_tpgid: crate::pid_t, + /// Process session ID. + pub ki_sid: crate::pid_t, + /// Terminal session ID. + pub ki_tsid: crate::pid_t, + /// Job control counter. + pub ki_jobc: c_short, + /// Unused (just here for alignment). + pub ki_spare_short1: c_short, + /// Controlling tty dev. + pub ki_tdev_freebsd11: u32, + /// Signals arrived but not delivered. + pub ki_siglist: crate::sigset_t, + /// Current signal mask. + pub ki_sigmask: crate::sigset_t, + /// Signals being ignored. + pub ki_sigignore: crate::sigset_t, + /// Signals being caught by user. + pub ki_sigcatch: crate::sigset_t, + /// Effective user ID. + pub ki_uid: crate::uid_t, + /// Real user ID. + pub ki_ruid: crate::uid_t, + /// Saved effective user ID. + pub ki_svuid: crate::uid_t, + /// Real group ID. + pub ki_rgid: crate::gid_t, + /// Saved effective group ID. + pub ki_svgid: crate::gid_t, + /// Number of groups. + pub ki_ngroups: c_short, + /// Unused (just here for alignment). + pub ki_spare_short2: c_short, + /// Groups. + pub ki_groups: [crate::gid_t; crate::KI_NGROUPS], + /// Virtual size. + pub ki_size: crate::vm_size_t, + /// Current resident set size in pages. + pub ki_rssize: crate::segsz_t, + /// Resident set size before last swap. + pub ki_swrss: crate::segsz_t, + /// Text size (pages) XXX. + pub ki_tsize: crate::segsz_t, + /// Data size (pages) XXX. + pub ki_dsize: crate::segsz_t, + /// Stack size (pages). + pub ki_ssize: crate::segsz_t, + /// Exit status for wait & stop signal. + pub ki_xstat: crate::u_short, + /// Accounting flags. + pub ki_acflag: crate::u_short, + /// %cpu for process during `ki_swtime`. + pub ki_pctcpu: crate::fixpt_t, + /// Time averaged value of `ki_cpticks`. + pub ki_estcpu: crate::u_int, + /// Time since last blocked. + pub ki_slptime: crate::u_int, + /// Time swapped in or out. + pub ki_swtime: crate::u_int, + /// Number of copy-on-write faults. + pub ki_cow: crate::u_int, + /// Real time in microsec. + pub ki_runtime: u64, + /// Starting time. + pub ki_start: crate::timeval, + /// Time used by process children. + pub ki_childtime: crate::timeval, + /// P_* flags. + pub ki_flag: c_long, + /// KI_* flags (below). + pub ki_kiflag: c_long, + /// Kernel trace points. + pub ki_traceflag: c_int, + /// S* process status. + pub ki_stat: c_char, + /// Process "nice" value. + pub ki_nice: i8, // signed char + /// Process lock (prevent swap) count. + pub ki_lock: c_char, + /// Run queue index. + pub ki_rqindex: c_char, + /// Which cpu we are on. + pub ki_oncpu_old: c_uchar, + /// Last cpu we were on. + pub ki_lastcpu_old: c_uchar, + /// Thread name. + pub ki_tdname: [c_char; crate::TDNAMLEN + 1], + /// Wchan message. + pub ki_wmesg: [c_char; crate::WMESGLEN + 1], + /// Setlogin name. + pub ki_login: [c_char; crate::LOGNAMELEN + 1], + /// Lock name. + pub ki_lockname: [c_char; crate::LOCKNAMELEN + 1], + /// Command name. + pub ki_comm: [c_char; crate::COMMLEN + 1], + /// Emulation name. + pub ki_emul: [c_char; crate::KI_EMULNAMELEN + 1], + /// Login class. + pub ki_loginclass: [c_char; crate::LOGINCLASSLEN + 1], + /// More thread name. + pub ki_moretdname: [c_char; crate::MAXCOMLEN - crate::TDNAMLEN + 1], + /// Spare string space. + pub ki_sparestrings: [[c_char; 23]; 2], // little hack to allow PartialEq + /// Spare room for growth. + pub ki_spareints: [c_int; crate::KI_NSPARE_INT], + /// Controlling tty dev. + pub ki_tdev: u64, + /// Which cpu we are on. + pub ki_oncpu: c_int, + /// Last cpu we were on. + pub ki_lastcpu: c_int, + /// PID of tracing process. + pub ki_tracer: c_int, + /// P2_* flags. + pub ki_flag2: c_int, + /// Default FIB number. + pub ki_fibnum: c_int, + /// Credential flags. + pub ki_cr_flags: crate::u_int, + /// Process jail ID. + pub ki_jid: c_int, + /// Number of threads in total. + pub ki_numthreads: c_int, + /// Thread ID. + pub ki_tid: crate::lwpid_t, + /// Process priority. + pub ki_pri: crate::priority, + /// Process rusage statistics. + pub ki_rusage: crate::rusage, + /// rusage of children processes. + pub ki_rusage_ch: crate::rusage, + // This is normally "struct pcb". + /// Kernel virtual addr of pcb. + pub ki_pcb: *mut c_void, + /// Kernel virtual addr of stack. + pub ki_kstack: *mut c_void, + /// User convenience pointer. + pub ki_udata: *mut c_void, + // This is normally "struct thread". + pub ki_tdaddr: *mut c_void, + // This is normally "struct pwddesc". + /// Pointer to process paths info. + pub ki_pd: *mut c_void, + /// Address of the ext err msg place + pub ki_uerrmsg: *mut c_void, + pub ki_spareptrs: [*mut c_void; crate::KI_NSPARE_PTR], + pub ki_sparelongs: [c_long; crate::KI_NSPARE_LONG], + /// PS_* flags. + pub ki_sflag: c_long, + /// kthread flag. + pub ki_tdflags: c_long, + } + + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_nlink: crate::nlink_t, + pub st_mode: crate::mode_t, + st_padding0: Padding, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + st_padding1: Padding, + pub st_rdev: crate::dev_t, + #[cfg(target_arch = "x86")] + st_atim_ext: i32, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + #[cfg(target_arch = "x86")] + st_mtim_ext: i32, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + #[cfg(target_arch = "x86")] + st_ctim_ext: i32, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + #[cfg(target_arch = "x86")] + st_btim_ext: i32, + pub st_birthtime: crate::time_t, + pub st_birthtime_nsec: c_long, + pub st_size: off_t, + pub st_blocks: crate::blkcnt_t, + pub st_blksize: crate::blksize_t, + pub st_flags: crate::fflags_t, + pub st_gen: u64, + pub st_filerev: u64, + pub st_spare: [u64; 9], + } + + pub struct dirent { + pub d_fileno: crate::ino_t, + pub d_off: off_t, + pub d_reclen: u16, + pub d_type: u8, + d_pad0: Padding, + pub d_namlen: u16, + d_pad1: Padding, + pub d_name: [c_char; 256], + } + + pub struct statfs { + pub f_version: u32, + pub f_type: u32, + pub f_flags: u64, + pub f_bsize: u64, + pub f_iosize: u64, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: i64, + pub f_files: u64, + pub f_ffree: i64, + pub f_syncwrites: u64, + pub f_asyncwrites: u64, + pub f_syncreads: u64, + pub f_asyncreads: u64, + f_spare: [u64; 10], + pub f_namemax: u32, + pub f_owner: crate::uid_t, + pub f_fsid: crate::fsid_t, + f_charspare: [c_char; 80], + pub f_fstypename: [c_char; 16], + pub f_mntfromname: [c_char; 1024], + pub f_mntonname: [c_char; 1024], + } + + pub struct vnstat { + pub vn_fileid: u64, + pub vn_size: u64, + pub vn_dev: u64, + pub vn_fsid: u64, + pub vn_mntdir: *mut c_char, + pub vn_type: c_int, + pub vn_mode: u16, + pub vn_devname: [c_char; crate::SPECNAMELEN as usize + 1], + } +} + +pub const RAND_MAX: c_int = 0x7fff_ffff; +pub const ELAST: c_int = 97; + +pub const KF_TYPE_EVENTFD: c_int = 13; + +/// max length of devicename +pub const SPECNAMELEN: c_int = 255; +pub const KI_NSPARE_PTR: usize = 4; + +/// domainset policies +pub const DOMAINSET_POLICY_INVALID: c_int = 0; +pub const DOMAINSET_POLICY_ROUNDROBIN: c_int = 1; +pub const DOMAINSET_POLICY_FIRSTTOUCH: c_int = 2; +pub const DOMAINSET_POLICY_PREFER: c_int = 3; +pub const DOMAINSET_POLICY_INTERLEAVE: c_int = 4; + +pub const MINCORE_SUPER: c_int = 0x60; + +safe_f! { + pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { + let major = major as crate::dev_t; + let minor = minor as crate::dev_t; + let mut dev = 0; + dev |= ((major & 0xffffff00) as dev_t) << 32; + dev |= ((major & 0x000000ff) as dev_t) << 8; + dev |= ((minor & 0x0000ff00) as dev_t) << 24; + dev |= ((minor & 0xffff00ff) as dev_t) << 0; + dev + } + + pub const fn major(dev: crate::dev_t) -> c_int { + (((dev >> 32) & 0xffffff00) | ((dev >> 8) & 0xff)) as c_int + } + + pub const fn minor(dev: crate::dev_t) -> c_int { + (((dev >> 24) & 0xff00) | (dev & 0xffff00ff)) as c_int + } +} + +extern "C" { + pub fn setgrent(); + pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; + pub fn freelocale(loc: crate::locale_t); + pub fn msgrcv( + msqid: c_int, + msgp: *mut c_void, + msgsz: size_t, + msgtyp: c_long, + msgflg: c_int, + ) -> ssize_t; + + pub fn cpuset_getdomain( + level: crate::cpulevel_t, + which: crate::cpuwhich_t, + id: crate::id_t, + setsize: size_t, + mask: *mut crate::domainset_t, + policy: *mut c_int, + ) -> c_int; + pub fn cpuset_setdomain( + level: crate::cpulevel_t, + which: crate::cpuwhich_t, + id: crate::id_t, + setsize: size_t, + mask: *const crate::domainset_t, + policy: c_int, + ) -> c_int; + + pub fn dirname(path: *mut c_char) -> *mut c_char; + pub fn basename(path: *mut c_char) -> *mut c_char; + + pub fn qsort_r( + base: *mut c_void, + num: size_t, + size: size_t, + compar: Option c_int>, + arg: *mut c_void, + ); +} + +#[link(name = "kvm")] +extern "C" { + pub fn kvm_kerndisp(kd: *mut crate::kvm_t) -> crate::kssize_t; +} + +cfg_if! { + if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } +} diff --git a/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd15/x86_64.rs b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd15/x86_64.rs new file mode 100644 index 0000000..3e03747 --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd15/x86_64.rs @@ -0,0 +1,14 @@ +use crate::prelude::*; + +pub const PROC_KPTI_CTL: c_int = crate::PROC_PROCCTL_MD_MIN; +pub const PROC_KPTI_CTL_ENABLE_ON_EXEC: c_int = 1; +pub const PROC_KPTI_CTL_DISABLE_ON_EXEC: c_int = 2; +pub const PROC_KPTI_STATUS: c_int = crate::PROC_PROCCTL_MD_MIN + 1; +pub const PROC_KPTI_STATUS_ACTIVE: c_int = 0x80000000; +pub const PROC_LA_CTL: c_int = crate::PROC_PROCCTL_MD_MIN + 2; +pub const PROC_LA_STATUS: c_int = crate::PROC_PROCCTL_MD_MIN + 3; +pub const PROC_LA_CTL_LA48_ON_EXEC: c_int = 1; +pub const PROC_LA_CTL_LA57_ON_EXEC: c_int = 2; +pub const PROC_LA_CTL_DEFAULT_ON_EXEC: c_int = 3; +pub const PROC_LA_STATUS_LA48: c_int = 0x01000000; +pub const PROC_LA_STATUS_LA57: c_int = 0x02000000; diff --git a/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs new file mode 100644 index 0000000..233026c --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -0,0 +1,5189 @@ +use crate::prelude::*; +use crate::{ + cmsghdr, + off_t, +}; + +pub type fflags_t = u32; + +pub type vm_prot_t = u_char; +pub type kvaddr_t = u64; +pub type segsz_t = isize; +pub type __fixpt_t = u32; +pub type fixpt_t = __fixpt_t; +pub type __lwpid_t = i32; +pub type lwpid_t = __lwpid_t; +pub type blksize_t = i32; +pub type ksize_t = u64; +pub type inp_gen_t = u64; +pub type so_gen_t = u64; +pub type clockid_t = c_int; +pub type sem_t = _sem; +pub type timer_t = *mut __c_anonymous__timer; + +pub type fsblkcnt_t = u64; +pub type fsfilcnt_t = u64; +pub type idtype_t = c_uint; + +pub type msglen_t = c_ulong; +pub type msgqnum_t = c_ulong; + +pub type cpulevel_t = c_int; +pub type cpuwhich_t = c_int; + +pub type mqd_t = *mut c_void; + +pub type pthread_spinlock_t = *mut __c_anonymous_pthread_spinlock; +pub type pthread_barrierattr_t = *mut __c_anonymous_pthread_barrierattr; +pub type pthread_barrier_t = *mut __c_anonymous_pthread_barrier; + +pub type uuid_t = crate::uuid; +pub type u_int = c_uint; +pub type u_char = c_uchar; +pub type u_long = c_ulong; +pub type u_short = c_ushort; + +pub type caddr_t = *mut c_char; + +pub type fhandle_t = fhandle; + +pub type au_id_t = crate::uid_t; +pub type au_asid_t = crate::pid_t; + +pub type cpusetid_t = c_int; + +pub type sctp_assoc_t = u32; + +pub type eventfd_t = u64; + +#[derive(Debug)] +#[cfg_attr(feature = "extra_traits", derive(Hash, PartialEq, Eq))] +#[repr(u32)] +pub enum devstat_support_flags { + DEVSTAT_ALL_SUPPORTED = 0x00, + DEVSTAT_NO_BLOCKSIZE = 0x01, + DEVSTAT_NO_ORDERED_TAGS = 0x02, + DEVSTAT_BS_UNAVAILABLE = 0x04, +} +impl Copy for devstat_support_flags {} +impl Clone for devstat_support_flags { + fn clone(&self) -> devstat_support_flags { + *self + } +} + +#[derive(Debug)] +#[cfg_attr(feature = "extra_traits", derive(Hash, PartialEq, Eq))] +#[repr(u32)] +pub enum devstat_trans_flags { + DEVSTAT_NO_DATA = 0x00, + DEVSTAT_READ = 0x01, + DEVSTAT_WRITE = 0x02, + DEVSTAT_FREE = 0x03, +} + +impl Copy for devstat_trans_flags {} +impl Clone for devstat_trans_flags { + fn clone(&self) -> devstat_trans_flags { + *self + } +} + +#[derive(Debug)] +#[cfg_attr(feature = "extra_traits", derive(Hash, PartialEq, Eq))] +#[repr(u32)] +pub enum devstat_tag_type { + DEVSTAT_TAG_SIMPLE = 0x00, + DEVSTAT_TAG_HEAD = 0x01, + DEVSTAT_TAG_ORDERED = 0x02, + DEVSTAT_TAG_NONE = 0x03, +} +impl Copy for devstat_tag_type {} +impl Clone for devstat_tag_type { + fn clone(&self) -> devstat_tag_type { + *self + } +} + +#[derive(Debug)] +#[cfg_attr(feature = "extra_traits", derive(Hash, PartialEq, Eq))] +#[repr(u32)] +pub enum devstat_match_flags { + DEVSTAT_MATCH_NONE = 0x00, + DEVSTAT_MATCH_TYPE = 0x01, + DEVSTAT_MATCH_IF = 0x02, + DEVSTAT_MATCH_PASS = 0x04, +} +impl Copy for devstat_match_flags {} +impl Clone for devstat_match_flags { + fn clone(&self) -> devstat_match_flags { + *self + } +} + +#[derive(Debug)] +#[cfg_attr(feature = "extra_traits", derive(Hash, PartialEq, Eq))] +#[repr(u32)] +pub enum devstat_priority { + DEVSTAT_PRIORITY_MIN = 0x000, + DEVSTAT_PRIORITY_OTHER = 0x020, + DEVSTAT_PRIORITY_PASS = 0x030, + DEVSTAT_PRIORITY_FD = 0x040, + DEVSTAT_PRIORITY_WFD = 0x050, + DEVSTAT_PRIORITY_TAPE = 0x060, + DEVSTAT_PRIORITY_CD = 0x090, + DEVSTAT_PRIORITY_DISK = 0x110, + DEVSTAT_PRIORITY_ARRAY = 0x120, + DEVSTAT_PRIORITY_MAX = 0xfff, +} +impl Copy for devstat_priority {} +impl Clone for devstat_priority { + fn clone(&self) -> devstat_priority { + *self + } +} + +#[derive(Debug)] +#[cfg_attr(feature = "extra_traits", derive(Hash, PartialEq, Eq))] +#[repr(u32)] +pub enum devstat_type_flags { + DEVSTAT_TYPE_DIRECT = 0x000, + DEVSTAT_TYPE_SEQUENTIAL = 0x001, + DEVSTAT_TYPE_PRINTER = 0x002, + DEVSTAT_TYPE_PROCESSOR = 0x003, + DEVSTAT_TYPE_WORM = 0x004, + DEVSTAT_TYPE_CDROM = 0x005, + DEVSTAT_TYPE_SCANNER = 0x006, + DEVSTAT_TYPE_OPTICAL = 0x007, + DEVSTAT_TYPE_CHANGER = 0x008, + DEVSTAT_TYPE_COMM = 0x009, + DEVSTAT_TYPE_ASC0 = 0x00a, + DEVSTAT_TYPE_ASC1 = 0x00b, + DEVSTAT_TYPE_STORARRAY = 0x00c, + DEVSTAT_TYPE_ENCLOSURE = 0x00d, + DEVSTAT_TYPE_FLOPPY = 0x00e, + DEVSTAT_TYPE_MASK = 0x00f, + DEVSTAT_TYPE_IF_SCSI = 0x010, + DEVSTAT_TYPE_IF_IDE = 0x020, + DEVSTAT_TYPE_IF_OTHER = 0x030, + DEVSTAT_TYPE_IF_MASK = 0x0f0, + DEVSTAT_TYPE_PASS = 0x100, +} +impl Copy for devstat_type_flags {} +impl Clone for devstat_type_flags { + fn clone(&self) -> devstat_type_flags { + *self + } +} + +#[derive(Debug)] +#[cfg_attr(feature = "extra_traits", derive(Hash, PartialEq, Eq))] +#[repr(u32)] +pub enum devstat_metric { + DSM_NONE, + DSM_TOTAL_BYTES, + DSM_TOTAL_BYTES_READ, + DSM_TOTAL_BYTES_WRITE, + DSM_TOTAL_TRANSFERS, + DSM_TOTAL_TRANSFERS_READ, + DSM_TOTAL_TRANSFERS_WRITE, + DSM_TOTAL_TRANSFERS_OTHER, + DSM_TOTAL_BLOCKS, + DSM_TOTAL_BLOCKS_READ, + DSM_TOTAL_BLOCKS_WRITE, + DSM_KB_PER_TRANSFER, + DSM_KB_PER_TRANSFER_READ, + DSM_KB_PER_TRANSFER_WRITE, + DSM_TRANSFERS_PER_SECOND, + DSM_TRANSFERS_PER_SECOND_READ, + DSM_TRANSFERS_PER_SECOND_WRITE, + DSM_TRANSFERS_PER_SECOND_OTHER, + DSM_MB_PER_SECOND, + DSM_MB_PER_SECOND_READ, + DSM_MB_PER_SECOND_WRITE, + DSM_BLOCKS_PER_SECOND, + DSM_BLOCKS_PER_SECOND_READ, + DSM_BLOCKS_PER_SECOND_WRITE, + DSM_MS_PER_TRANSACTION, + DSM_MS_PER_TRANSACTION_READ, + DSM_MS_PER_TRANSACTION_WRITE, + DSM_SKIP, + DSM_TOTAL_BYTES_FREE, + DSM_TOTAL_TRANSFERS_FREE, + DSM_TOTAL_BLOCKS_FREE, + DSM_KB_PER_TRANSFER_FREE, + DSM_MB_PER_SECOND_FREE, + DSM_TRANSFERS_PER_SECOND_FREE, + DSM_BLOCKS_PER_SECOND_FREE, + DSM_MS_PER_TRANSACTION_OTHER, + DSM_MS_PER_TRANSACTION_FREE, + DSM_BUSY_PCT, + DSM_QUEUE_LENGTH, + DSM_TOTAL_DURATION, + DSM_TOTAL_DURATION_READ, + DSM_TOTAL_DURATION_WRITE, + DSM_TOTAL_DURATION_FREE, + DSM_TOTAL_DURATION_OTHER, + DSM_TOTAL_BUSY_TIME, + DSM_MAX, +} +impl Copy for devstat_metric {} +impl Clone for devstat_metric { + fn clone(&self) -> devstat_metric { + *self + } +} + +#[derive(Debug)] +#[cfg_attr(feature = "extra_traits", derive(Hash, PartialEq, Eq))] +#[repr(u32)] +pub enum devstat_select_mode { + DS_SELECT_ADD, + DS_SELECT_ONLY, + DS_SELECT_REMOVE, + DS_SELECT_ADDONLY, +} +impl Copy for devstat_select_mode {} +impl Clone for devstat_select_mode { + fn clone(&self) -> devstat_select_mode { + *self + } +} + +s! { + pub struct aiocb { + pub aio_fildes: c_int, + pub aio_offset: off_t, + pub aio_buf: *mut c_void, + pub aio_nbytes: size_t, + __unused1: [c_int; 2], + __unused2: *mut c_void, + pub aio_lio_opcode: c_int, + pub aio_reqprio: c_int, + // unused 3 through 5 are the __aiocb_private structure + __unused3: c_long, + __unused4: c_long, + __unused5: *mut c_void, + pub aio_sigevent: sigevent, + } + + pub struct jail { + pub version: u32, + pub path: *mut c_char, + pub hostname: *mut c_char, + pub jailname: *mut c_char, + pub ip4s: c_uint, + pub ip6s: c_uint, + pub ip4: *mut crate::in_addr, + pub ip6: *mut crate::in6_addr, + } + + pub struct statvfs { + pub f_bavail: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_blocks: crate::fsblkcnt_t, + pub f_favail: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_bsize: c_ulong, + pub f_flag: c_ulong, + pub f_frsize: c_ulong, + pub f_fsid: c_ulong, + pub f_namemax: c_ulong, + } + + // internal structure has changed over time + pub struct _sem { + data: [u32; 4], + } + pub struct sembuf { + pub sem_num: c_ushort, + pub sem_op: c_short, + pub sem_flg: c_short, + } + + pub struct input_event { + pub time: crate::timeval, + pub type_: crate::u_short, + pub code: crate::u_short, + pub value: i32, + } + + pub struct input_absinfo { + pub value: i32, + pub minimum: i32, + pub maximum: i32, + pub fuzz: i32, + pub flat: i32, + pub resolution: i32, + } + + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + __unused1: Padding<*mut c_void>, + __unused2: Padding<*mut c_void>, + pub msg_cbytes: crate::msglen_t, + pub msg_qnum: crate::msgqnum_t, + pub msg_qbytes: crate::msglen_t, + pub msg_lspid: crate::pid_t, + pub msg_lrpid: crate::pid_t, + pub msg_stime: crate::time_t, + pub msg_rtime: crate::time_t, + pub msg_ctime: crate::time_t, + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_size: size_t, + pub ss_flags: c_int, + } + + pub struct mmsghdr { + pub msg_hdr: crate::msghdr, + pub msg_len: ssize_t, + } + + pub struct sockcred { + pub sc_uid: crate::uid_t, + pub sc_euid: crate::uid_t, + pub sc_gid: crate::gid_t, + pub sc_egid: crate::gid_t, + pub sc_ngroups: c_int, + pub sc_groups: [crate::gid_t; 1], + } + + pub struct ptrace_vm_entry { + pub pve_entry: c_int, + pub pve_timestamp: c_int, + pub pve_start: c_ulong, + pub pve_end: c_ulong, + pub pve_offset: c_ulong, + pub pve_prot: c_uint, + pub pve_pathlen: c_uint, + pub pve_fileid: c_long, + pub pve_fsid: u32, + pub pve_path: *mut c_char, + } + + pub struct ptrace_lwpinfo { + pub pl_lwpid: lwpid_t, + pub pl_event: c_int, + pub pl_flags: c_int, + pub pl_sigmask: crate::sigset_t, + pub pl_siglist: crate::sigset_t, + pub pl_siginfo: crate::siginfo_t, + pub pl_tdname: [c_char; crate::MAXCOMLEN as usize + 1], + pub pl_child_pid: crate::pid_t, + pub pl_syscall_code: c_uint, + pub pl_syscall_narg: c_uint, + } + + pub struct ptrace_sc_ret { + pub sr_retval: [crate::register_t; 2], + pub sr_error: c_int, + } + + pub struct ptrace_coredump { + pub pc_fd: c_int, + pub pc_flags: u32, + pub pc_limit: off_t, + } + + pub struct ptrace_sc_remote { + pub pscr_ret: ptrace_sc_ret, + pub pscr_syscall: c_uint, + pub pscr_nargs: c_uint, + pub pscr_args: *mut crate::register_t, + } + + pub struct cpuset_t { + #[cfg(all(any(freebsd15, freebsd14), target_pointer_width = "64"))] + __bits: [c_long; 16], + #[cfg(all(any(freebsd15, freebsd14), target_pointer_width = "32"))] + __bits: [c_long; 32], + #[cfg(all(not(any(freebsd15, freebsd14)), target_pointer_width = "64"))] + __bits: [c_long; 4], + #[cfg(all(not(any(freebsd15, freebsd14)), target_pointer_width = "32"))] + __bits: [c_long; 8], + } + + pub struct cap_rights_t { + cr_rights: [u64; 2], + } + + pub struct umutex { + m_owner: crate::lwpid_t, + m_flags: u32, + m_ceilings: [u32; 2], + m_rb_link: crate::uintptr_t, + #[cfg(target_pointer_width = "32")] + m_pad: Padding, + m_spare: [u32; 2], + } + + pub struct ucond { + c_has_waiters: u32, + c_flags: u32, + c_clockid: u32, + c_spare: [u32; 1], + } + + pub struct uuid { + pub time_low: u32, + pub time_mid: u16, + pub time_hi_and_version: u16, + clock_seq_hi_and_reserved: Padding, + pub clock_seq_low: u8, + pub node: [u8; _UUID_NODE_LEN], + } + + pub struct __c_anonymous_pthread_spinlock { + s_clock: umutex, + } + + pub struct __c_anonymous_pthread_barrierattr { + pshared: c_int, + } + + pub struct __c_anonymous_pthread_barrier { + b_lock: umutex, + b_cv: ucond, + b_cycle: i64, + b_count: c_int, + b_waiters: c_int, + b_refcount: c_int, + b_destroying: c_int, + } + + pub struct kinfo_vmentry { + pub kve_structsize: c_int, + pub kve_type: c_int, + pub kve_start: u64, + pub kve_end: u64, + pub kve_offset: u64, + pub kve_vn_fileid: u64, + #[cfg(not(freebsd11))] + pub kve_vn_fsid_freebsd11: u32, + #[cfg(freebsd11)] + pub kve_vn_fsid: u32, + pub kve_flags: c_int, + pub kve_resident: c_int, + pub kve_private_resident: c_int, + pub kve_protection: c_int, + pub kve_ref_count: c_int, + pub kve_shadow_count: c_int, + pub kve_vn_type: c_int, + pub kve_vn_size: u64, + #[cfg(not(freebsd11))] + pub kve_vn_rdev_freebsd11: u32, + #[cfg(freebsd11)] + pub kve_vn_rdev: u32, + pub kve_vn_mode: u16, + pub kve_status: u16, + #[cfg(not(freebsd11))] + pub kve_vn_fsid: u64, + #[cfg(not(freebsd11))] + pub kve_vn_rdev: u64, + #[cfg(not(freebsd11))] + _kve_is_spare: [c_int; 8], + #[cfg(freebsd11)] + _kve_is_spare: [c_int; 12], + pub kve_path: [[c_char; 32]; 32], + } + + pub struct __c_anonymous_filestat { + pub stqe_next: *mut filestat, + } + + pub struct filestat { + pub fs_type: c_int, + pub fs_flags: c_int, + pub fs_fflags: c_int, + pub fs_uflags: c_int, + pub fs_fd: c_int, + pub fs_ref_count: c_int, + pub fs_offset: off_t, + pub fs_typedep: *mut c_void, + pub fs_path: *mut c_char, + pub next: __c_anonymous_filestat, + pub fs_cap_rights: cap_rights_t, + } + + pub struct filestat_list { + pub stqh_first: *mut filestat, + pub stqh_last: *mut *mut filestat, + } + + pub struct procstat { + pub tpe: c_int, + pub kd: crate::uintptr_t, + pub vmentries: *mut c_void, + pub files: *mut c_void, + pub argv: *mut c_void, + pub envv: *mut c_void, + pub core: crate::uintptr_t, + } + + pub struct itimerspec { + pub it_interval: crate::timespec, + pub it_value: crate::timespec, + } + + pub struct __c_anonymous__timer { + _priv: [c_int; 3], + } + + /// Used to hold a copy of the command line, if it had a sane length. + pub struct pargs { + /// Reference count. + pub ar_ref: u_int, + /// Length. + pub ar_length: u_int, + /// Arguments. + pub ar_args: [c_uchar; 1], + } + + pub struct priority { + /// Scheduling class. + pub pri_class: u_char, + /// Normal priority level. + pub pri_level: u_char, + /// Priority before propagation. + pub pri_native: u_char, + /// User priority based on p_cpu and p_nice. + pub pri_user: u_char, + } + + pub struct kvm_swap { + pub ksw_devname: [c_char; 32], + pub ksw_used: u_int, + pub ksw_total: u_int, + pub ksw_flags: c_int, + ksw_reserved1: Padding, + ksw_reserved2: Padding, + } + + pub struct nlist { + /// symbol name (in memory) + pub n_name: *const c_char, + /// type defines + pub n_type: c_uchar, + /// "type" and binding information + pub n_other: c_char, + /// used by stab entries + pub n_desc: c_short, + pub n_value: c_ulong, + } + + pub struct kvm_nlist { + pub n_name: *const c_char, + pub n_type: c_uchar, + pub n_value: crate::kvaddr_t, + } + + pub struct __c_anonymous_sem { + _priv: crate::uintptr_t, + } + + pub struct semid_ds { + pub sem_perm: crate::ipc_perm, + pub __sem_base: *mut __c_anonymous_sem, + pub sem_nsems: c_ushort, + pub sem_otime: crate::time_t, + pub sem_ctime: crate::time_t, + } + + pub struct vmtotal { + pub t_vm: u64, + pub t_avm: u64, + pub t_rm: u64, + pub t_arm: u64, + pub t_vmshr: u64, + pub t_avmshr: u64, + pub t_rmshr: u64, + pub t_armshr: u64, + pub t_free: u64, + pub t_rq: i16, + pub t_dw: i16, + pub t_pw: i16, + pub t_sl: i16, + pub t_sw: i16, + pub t_pad: [u16; 3], + } + + pub struct sockstat { + pub inp_ppcb: u64, + pub so_addr: u64, + pub so_pcb: u64, + pub unp_conn: u64, + pub dom_family: c_int, + pub proto: c_int, + pub so_rcv_sb_state: c_int, + pub so_snd_sb_state: c_int, + /// Socket address. + pub sa_local: crate::sockaddr_storage, + /// Peer address. + pub sa_peer: crate::sockaddr_storage, + pub type_: c_int, + pub dname: [c_char; 32], + #[cfg(any(freebsd12, freebsd13, freebsd14, freebsd15))] + pub sendq: c_uint, + #[cfg(any(freebsd12, freebsd13, freebsd14, freebsd15))] + pub recvq: c_uint, + } + + pub struct shmstat { + pub size: u64, + pub mode: u16, + } + + pub struct spacectl_range { + pub r_offset: off_t, + pub r_len: off_t, + } + + pub struct rusage_ext { + pub rux_runtime: u64, + pub rux_uticks: u64, + pub rux_sticks: u64, + pub rux_iticks: u64, + pub rux_uu: u64, + pub rux_su: u64, + pub rux_tu: u64, + } + + pub struct if_clonereq { + pub ifcr_total: c_int, + pub ifcr_count: c_int, + pub ifcr_buffer: *mut c_char, + } + + pub struct if_msghdr { + /// to skip over non-understood messages + pub ifm_msglen: c_ushort, + /// future binary compatibility + pub ifm_version: c_uchar, + /// message type + pub ifm_type: c_uchar, + /// like rtm_addrs + pub ifm_addrs: c_int, + /// value of if_flags + pub ifm_flags: c_int, + /// index for associated ifp + pub ifm_index: c_ushort, + pub _ifm_spare1: c_ushort, + /// statistics and other data about if + pub ifm_data: if_data, + } + + pub struct if_msghdrl { + /// to skip over non-understood messages + pub ifm_msglen: c_ushort, + /// future binary compatibility + pub ifm_version: c_uchar, + /// message type + pub ifm_type: c_uchar, + /// like rtm_addrs + pub ifm_addrs: c_int, + /// value of if_flags + pub ifm_flags: c_int, + /// index for associated ifp + pub ifm_index: c_ushort, + /// spare space to grow if_index, see if_var.h + pub _ifm_spare1: c_ushort, + /// length of if_msghdrl incl. if_data + pub ifm_len: c_ushort, + /// offset of if_data from beginning + pub ifm_data_off: c_ushort, + pub _ifm_spare2: c_int, + /// statistics and other data about if + pub ifm_data: if_data, + } + + pub struct ifa_msghdr { + /// to skip over non-understood messages + pub ifam_msglen: c_ushort, + /// future binary compatibility + pub ifam_version: c_uchar, + /// message type + pub ifam_type: c_uchar, + /// like rtm_addrs + pub ifam_addrs: c_int, + /// value of ifa_flags + pub ifam_flags: c_int, + /// index for associated ifp + pub ifam_index: c_ushort, + pub _ifam_spare1: c_ushort, + /// value of ifa_ifp->if_metric + pub ifam_metric: c_int, + } + + pub struct ifa_msghdrl { + /// to skip over non-understood messages + pub ifam_msglen: c_ushort, + /// future binary compatibility + pub ifam_version: c_uchar, + /// message type + pub ifam_type: c_uchar, + /// like rtm_addrs + pub ifam_addrs: c_int, + /// value of ifa_flags + pub ifam_flags: c_int, + /// index for associated ifp + pub ifam_index: c_ushort, + /// spare space to grow if_index, see if_var.h + pub _ifam_spare1: c_ushort, + /// length of ifa_msghdrl incl. if_data + pub ifam_len: c_ushort, + /// offset of if_data from beginning + pub ifam_data_off: c_ushort, + /// value of ifa_ifp->if_metric + pub ifam_metric: c_int, + /// statistics and other data about if or address + pub ifam_data: if_data, + } + + pub struct ifma_msghdr { + /// to skip over non-understood messages + pub ifmam_msglen: c_ushort, + /// future binary compatibility + pub ifmam_version: c_uchar, + /// message type + pub ifmam_type: c_uchar, + /// like rtm_addrs + pub ifmam_addrs: c_int, + /// value of ifa_flags + pub ifmam_flags: c_int, + /// index for associated ifp + pub ifmam_index: c_ushort, + pub _ifmam_spare1: c_ushort, + } + + pub struct if_announcemsghdr { + /// to skip over non-understood messages + pub ifan_msglen: c_ushort, + /// future binary compatibility + pub ifan_version: c_uchar, + /// message type + pub ifan_type: c_uchar, + /// index for associated ifp + pub ifan_index: c_ushort, + /// if name, e.g. "en0" + pub ifan_name: [c_char; crate::IFNAMSIZ as usize], + /// what type of announcement + pub ifan_what: c_ushort, + } + + pub struct ifreq_buffer { + pub length: size_t, + pub buffer: *mut c_void, + } + + pub struct ifaliasreq { + /// if name, e.g. "en0" + pub ifra_name: [c_char; crate::IFNAMSIZ as usize], + pub ifra_addr: crate::sockaddr, + pub ifra_broadaddr: crate::sockaddr, + pub ifra_mask: crate::sockaddr, + pub ifra_vhid: c_int, + } + + /// 9.x compat + pub struct oifaliasreq { + /// if name, e.g. "en0" + pub ifra_name: [c_char; crate::IFNAMSIZ as usize], + pub ifra_addr: crate::sockaddr, + pub ifra_broadaddr: crate::sockaddr, + pub ifra_mask: crate::sockaddr, + } + + pub struct ifmediareq { + /// if name, e.g. "en0" + pub ifm_name: [c_char; crate::IFNAMSIZ as usize], + /// current media options + pub ifm_current: c_int, + /// don't care mask + pub ifm_mask: c_int, + /// media status + pub ifm_status: c_int, + /// active options + pub ifm_active: c_int, + /// # entries in ifm_ulist array + pub ifm_count: c_int, + /// media words + pub ifm_ulist: *mut c_int, + } + + pub struct ifdrv { + /// if name, e.g. "en0" + pub ifd_name: [c_char; crate::IFNAMSIZ as usize], + pub ifd_cmd: c_ulong, + pub ifd_len: size_t, + pub ifd_data: *mut c_void, + } + + pub struct ifi2creq { + /// i2c address (0xA0, 0xA2) + pub dev_addr: u8, + /// read offset + pub offset: u8, + /// read length + pub len: u8, + pub spare0: u8, + pub spare1: u32, + /// read buffer + pub data: [u8; 8], + } + + pub struct ifrsshash { + /// if name, e.g. "en0" + pub ifrh_name: [c_char; crate::IFNAMSIZ as usize], + /// RSS_FUNC_ + pub ifrh_func: u8, + pub ifrh_spare0: u8, + pub ifrh_spare1: u16, + /// RSS_TYPE_ + pub ifrh_types: u32, + } + + pub struct ifmibdata { + /// name of interface + pub ifmd_name: [c_char; crate::IFNAMSIZ as usize], + /// number of promiscuous listeners + pub ifmd_pcount: c_int, + /// interface flags + pub ifmd_flags: c_int, + /// instantaneous length of send queue + pub ifmd_snd_len: c_int, + /// maximum length of send queue + pub ifmd_snd_maxlen: c_int, + /// number of drops in send queue + pub ifmd_snd_drops: c_int, + /// for future expansion + pub ifmd_filler: [c_int; 4], + /// generic information and statistics + pub ifmd_data: if_data, + } + + pub struct ifmib_iso_8802_3 { + pub dot3StatsAlignmentErrors: u32, + pub dot3StatsFCSErrors: u32, + pub dot3StatsSingleCollisionFrames: u32, + pub dot3StatsMultipleCollisionFrames: u32, + pub dot3StatsSQETestErrors: u32, + pub dot3StatsDeferredTransmissions: u32, + pub dot3StatsLateCollisions: u32, + pub dot3StatsExcessiveCollisions: u32, + pub dot3StatsInternalMacTransmitErrors: u32, + pub dot3StatsCarrierSenseErrors: u32, + pub dot3StatsFrameTooLongs: u32, + pub dot3StatsInternalMacReceiveErrors: u32, + pub dot3StatsEtherChipSet: u32, + pub dot3StatsMissedFrames: u32, + pub dot3StatsCollFrequencies: [u32; 16], + pub dot3Compliance: u32, + } + + pub struct __c_anonymous_ph { + pub ph1: u64, + pub ph2: u64, + } + + pub struct fid { + pub fid_len: c_ushort, + pub fid_data0: c_ushort, + pub fid_data: [c_char; crate::MAXFIDSZ as usize], + } + + pub struct fhandle { + pub fh_fsid: crate::fsid_t, + pub fh_fid: fid, + } + + pub struct bintime { + pub sec: crate::time_t, + pub frac: u64, + } + + pub struct clockinfo { + /// clock frequency + pub hz: c_int, + /// micro-seconds per hz tick + pub tick: c_int, + pub spare: c_int, + /// statistics clock frequency + pub stathz: c_int, + /// profiling clock frequency + pub profhz: c_int, + } + + pub struct __c_anonymous_stailq_entry_devstat { + pub stqe_next: *mut devstat, + } + + pub struct devstat { + /// Update sequence + pub sequence0: crate::u_int, + /// Allocated entry + pub allocated: c_int, + /// started ops + pub start_count: crate::u_int, + /// completed ops + pub end_count: crate::u_int, + /// busy time unaccounted for since this time + pub busy_from: bintime, + pub dev_links: __c_anonymous_stailq_entry_devstat, + /// Devstat device number. + pub device_number: u32, + pub device_name: [c_char; DEVSTAT_NAME_LEN as usize], + pub unit_number: c_int, + pub bytes: [u64; DEVSTAT_N_TRANS_FLAGS as usize], + pub operations: [u64; DEVSTAT_N_TRANS_FLAGS as usize], + pub duration: [bintime; DEVSTAT_N_TRANS_FLAGS as usize], + pub busy_time: bintime, + /// Time the device was created. + pub creation_time: bintime, + /// Block size, bytes + pub block_size: u32, + /// The number of simple, ordered, and head of queue tags sent. + pub tag_types: [u64; 3], + /// Which statistics are supported by a given device. + pub flags: devstat_support_flags, + /// Device type + pub device_type: devstat_type_flags, + /// Controls list pos. + pub priority: devstat_priority, + /// Identification for GEOM nodes + pub id: *const c_void, + /// Update sequence + pub sequence1: crate::u_int, + } + + pub struct devstat_match { + pub match_fields: devstat_match_flags, + pub device_type: devstat_type_flags, + pub num_match_categories: c_int, + } + + pub struct devstat_match_table { + pub match_str: *const c_char, + pub type_: devstat_type_flags, + pub match_field: devstat_match_flags, + } + + pub struct device_selection { + pub device_number: u32, + pub device_name: [c_char; DEVSTAT_NAME_LEN as usize], + pub unit_number: c_int, + pub selected: c_int, + pub bytes: u64, + pub position: c_int, + } + + pub struct devinfo { + pub devices: *mut devstat, + pub mem_ptr: *mut u8, + pub generation: c_long, + pub numdevs: c_int, + } + + pub struct sockcred2 { + pub sc_version: c_int, + pub sc_pid: crate::pid_t, + pub sc_uid: crate::uid_t, + pub sc_euid: crate::uid_t, + pub sc_gid: crate::gid_t, + pub sc_egid: crate::gid_t, + pub sc_ngroups: c_int, + pub sc_groups: [crate::gid_t; 1], + } + + pub struct ifconf { + pub ifc_len: c_int, + pub ifc_ifcu: __c_anonymous_ifc_ifcu, + } + + pub struct au_mask_t { + pub am_success: c_uint, + pub am_failure: c_uint, + } + + pub struct au_tid_t { + pub port: u32, + pub machine: u32, + } + + pub struct auditinfo_t { + pub ai_auid: crate::au_id_t, + pub ai_mask: crate::au_mask_t, + pub ai_termid: au_tid_t, + pub ai_asid: crate::au_asid_t, + } + + pub struct tcp_fastopen { + pub enable: c_int, + pub psk: [u8; crate::TCP_FASTOPEN_PSK_LEN as usize], + } + + pub struct tcp_function_set { + pub function_set_name: [c_char; crate::TCP_FUNCTION_NAME_LEN_MAX as usize], + pub pcbcnt: u32, + } + + // Note: this structure will change in a backwards-incompatible way in + // FreeBSD 15. + pub struct tcp_info { + pub tcpi_state: u8, + pub __tcpi_ca_state: u8, + pub __tcpi_retransmits: u8, + pub __tcpi_probes: u8, + pub __tcpi_backoff: u8, + pub tcpi_options: u8, + pub tcp_snd_wscale: u8, + pub tcp_rcv_wscale: u8, + pub tcpi_rto: u32, + pub __tcpi_ato: u32, + pub tcpi_snd_mss: u32, + pub tcpi_rcv_mss: u32, + pub __tcpi_unacked: u32, + pub __tcpi_sacked: u32, + pub __tcpi_lost: u32, + pub __tcpi_retrans: u32, + pub __tcpi_fackets: u32, + pub __tcpi_last_data_sent: u32, + pub __tcpi_last_ack_sent: u32, + pub tcpi_last_data_recv: u32, + pub __tcpi_last_ack_recv: u32, + pub __tcpi_pmtu: u32, + pub __tcpi_rcv_ssthresh: u32, + pub tcpi_rtt: u32, + pub tcpi_rttvar: u32, + pub tcpi_snd_ssthresh: u32, + pub tcpi_snd_cwnd: u32, + pub __tcpi_advmss: u32, + pub __tcpi_reordering: u32, + pub __tcpi_rcv_rtt: u32, + pub tcpi_rcv_space: u32, + pub tcpi_snd_wnd: u32, + pub tcpi_snd_bwnd: u32, + pub tcpi_snd_nxt: u32, + pub tcpi_rcv_nxt: u32, + pub tcpi_toe_tid: u32, + pub tcpi_snd_rexmitpack: u32, + pub tcpi_rcv_ooopack: u32, + pub tcpi_snd_zerowin: u32, + #[cfg(any(freebsd15, freebsd14))] + pub tcpi_delivered_ce: u32, + #[cfg(any(freebsd15, freebsd14))] + pub tcpi_received_ce: u32, + #[cfg(any(freebsd15, freebsd14))] + pub __tcpi_delivered_e1_bytes: u32, + #[cfg(any(freebsd15, freebsd14))] + pub __tcpi_delivered_e0_bytes: u32, + #[cfg(any(freebsd15, freebsd14))] + pub __tcpi_delivered_ce_bytes: u32, + #[cfg(any(freebsd15, freebsd14))] + pub __tcpi_received_e1_bytes: u32, + #[cfg(any(freebsd15, freebsd14))] + pub __tcpi_received_e0_bytes: u32, + #[cfg(any(freebsd15, freebsd14))] + pub __tcpi_received_ce_bytes: u32, + #[cfg(any(freebsd15, freebsd14))] + pub tcpi_total_tlp: u32, + #[cfg(any(freebsd15, freebsd14))] + pub tcpi_total_tlp_bytes: u64, + #[cfg(any(freebsd15, freebsd14))] + pub tcpi_snd_una: u32, + #[cfg(any(freebsd15, freebsd14))] + pub tcpi_snd_max: u32, + #[cfg(any(freebsd15, freebsd14))] + pub tcpi_rcv_numsacks: u32, + #[cfg(any(freebsd15, freebsd14))] + pub tcpi_rcv_adv: u32, + #[cfg(any(freebsd15, freebsd14))] + pub tcpi_dupacks: u32, + #[cfg(freebsd14)] + pub __tcpi_pad: [u32; 10], + #[cfg(freebsd15)] + pub __tcpi_pad: [u32; 14], + #[cfg(not(any(freebsd15, freebsd14)))] + pub __tcpi_pad: [u32; 26], + } + + pub struct _umtx_time { + pub _timeout: crate::timespec, + pub _flags: u32, + pub _clockid: u32, + } + + pub struct shm_largepage_conf { + pub psind: c_int, + pub alloc_policy: c_int, + __pad: Padding<[c_int; 10]>, + } + + pub struct memory_type { + __priva: [crate::uintptr_t; 32], + __privb: [crate::uintptr_t; 26], + } + + pub struct memory_type_list { + __priv: [crate::uintptr_t; 2], + } + + pub struct pidfh { + __priva: [[crate::uintptr_t; 32]; 8], + __privb: [crate::uintptr_t; 2], + } + + pub struct sctp_event { + pub se_assoc_id: crate::sctp_assoc_t, + pub se_type: u16, + pub se_on: u8, + } + + pub struct sctp_event_subscribe { + pub sctp_data_io_event: u8, + pub sctp_association_event: u8, + pub sctp_address_event: u8, + pub sctp_send_failure_event: u8, + pub sctp_peer_error_event: u8, + pub sctp_shutdown_event: u8, + pub sctp_partial_delivery_event: u8, + pub sctp_adaptation_layer_event: u8, + pub sctp_authentication_event: u8, + pub sctp_sender_dry_event: u8, + pub sctp_stream_reset_event: u8, + } + + pub struct sctp_initmsg { + pub sinit_num_ostreams: u16, + pub sinit_max_instreams: u16, + pub sinit_max_attempts: u16, + pub sinit_max_init_timeo: u16, + } + + pub struct sctp_sndrcvinfo { + pub sinfo_stream: u16, + pub sinfo_ssn: u16, + pub sinfo_flags: u16, + pub sinfo_ppid: u32, + pub sinfo_context: u32, + pub sinfo_timetolive: u32, + pub sinfo_tsn: u32, + pub sinfo_cumtsn: u32, + pub sinfo_assoc_id: crate::sctp_assoc_t, + pub sinfo_keynumber: u16, + pub sinfo_keynumber_valid: u16, + pub __reserve_pad: [[u8; 23]; 4], + } + + pub struct sctp_extrcvinfo { + pub sinfo_stream: u16, + pub sinfo_ssn: u16, + pub sinfo_flags: u16, + pub sinfo_ppid: u32, + pub sinfo_context: u32, + pub sinfo_timetolive: u32, + pub sinfo_tsn: u32, + pub sinfo_cumtsn: u32, + pub sinfo_assoc_id: crate::sctp_assoc_t, + pub serinfo_next_flags: u16, + pub serinfo_next_stream: u16, + pub serinfo_next_aid: u32, + pub serinfo_next_length: u32, + pub serinfo_next_ppid: u32, + pub sinfo_keynumber: u16, + pub sinfo_keynumber_valid: u16, + pub __reserve_pad: [[u8; 19]; 4], + } + + pub struct sctp_sndinfo { + pub snd_sid: u16, + pub snd_flags: u16, + pub snd_ppid: u32, + pub snd_context: u32, + pub snd_assoc_id: crate::sctp_assoc_t, + } + + pub struct sctp_prinfo { + pub pr_policy: u16, + pub pr_value: u32, + } + + pub struct sctp_default_prinfo { + pub pr_policy: u16, + pub pr_value: u32, + pub pr_assoc_id: crate::sctp_assoc_t, + } + + pub struct sctp_authinfo { + pub auth_keynumber: u16, + } + + pub struct sctp_rcvinfo { + pub rcv_sid: u16, + pub rcv_ssn: u16, + pub rcv_flags: u16, + pub rcv_ppid: u32, + pub rcv_tsn: u32, + pub rcv_cumtsn: u32, + pub rcv_context: u32, + pub rcv_assoc_id: crate::sctp_assoc_t, + } + + pub struct sctp_nxtinfo { + pub nxt_sid: u16, + pub nxt_flags: u16, + pub nxt_ppid: u32, + pub nxt_length: u32, + pub nxt_assoc_id: crate::sctp_assoc_t, + } + + pub struct sctp_recvv_rn { + pub recvv_rcvinfo: sctp_rcvinfo, + pub recvv_nxtinfo: sctp_nxtinfo, + } + + pub struct sctp_sendv_spa { + pub sendv_flags: u32, + pub sendv_sndinfo: sctp_sndinfo, + pub sendv_prinfo: sctp_prinfo, + pub sendv_authinfo: sctp_authinfo, + } + + pub struct sctp_snd_all_completes { + pub sall_stream: u16, + pub sall_flags: u16, + pub sall_ppid: u32, + pub sall_context: u32, + pub sall_num_sent: u32, + pub sall_num_failed: u32, + } + + pub struct sctp_pcbinfo { + pub ep_count: u32, + pub asoc_count: u32, + pub laddr_count: u32, + pub raddr_count: u32, + pub chk_count: u32, + pub readq_count: u32, + pub free_chunks: u32, + pub stream_oque: u32, + } + + pub struct sctp_sockstat { + pub ss_assoc_id: crate::sctp_assoc_t, + pub ss_total_sndbuf: u32, + pub ss_total_recv_buf: u32, + } + + pub struct sctp_assoc_change { + pub sac_type: u16, + pub sac_flags: u16, + pub sac_length: u32, + pub sac_state: u16, + pub sac_error: u16, + pub sac_outbound_streams: u16, + pub sac_inbound_streams: u16, + pub sac_assoc_id: crate::sctp_assoc_t, + pub sac_info: [u8; 0], + } + + pub struct sctp_paddr_change { + pub spc_type: u16, + pub spc_flags: u16, + pub spc_length: u32, + pub spc_aaddr: crate::sockaddr_storage, + pub spc_state: u32, + pub spc_error: u32, + pub spc_assoc_id: crate::sctp_assoc_t, + } + + pub struct sctp_remote_error { + pub sre_type: u16, + pub sre_flags: u16, + pub sre_length: u32, + pub sre_error: u16, + pub sre_assoc_id: crate::sctp_assoc_t, + pub sre_data: [u8; 0], + } + + pub struct sctp_send_failed_event { + pub ssfe_type: u16, + pub ssfe_flags: u16, + pub ssfe_length: u32, + pub ssfe_error: u32, + pub ssfe_info: sctp_sndinfo, + pub ssfe_assoc_id: crate::sctp_assoc_t, + pub ssfe_data: [u8; 0], + } + + pub struct sctp_shutdown_event { + pub sse_type: u16, + pub sse_flags: u16, + pub sse_length: u32, + pub sse_assoc_id: crate::sctp_assoc_t, + } + + pub struct sctp_adaptation_event { + pub sai_type: u16, + pub sai_flags: u16, + pub sai_length: u32, + pub sai_adaptation_ind: u32, + pub sai_assoc_id: crate::sctp_assoc_t, + } + + pub struct sctp_setadaptation { + pub ssb_adaptation_ind: u32, + } + + pub struct sctp_pdapi_event { + pub pdapi_type: u16, + pub pdapi_flags: u16, + pub pdapi_length: u32, + pub pdapi_indication: u32, + pub pdapi_stream: u16, + pub pdapi_seq: u16, + pub pdapi_assoc_id: crate::sctp_assoc_t, + } + + pub struct sctp_sender_dry_event { + pub sender_dry_type: u16, + pub sender_dry_flags: u16, + pub sender_dry_length: u32, + pub sender_dry_assoc_id: crate::sctp_assoc_t, + } + + pub struct sctp_stream_reset_event { + pub strreset_type: u16, + pub strreset_flags: u16, + pub strreset_length: u32, + pub strreset_assoc_id: crate::sctp_assoc_t, + pub strreset_stream_list: [u16; 0], + } + + pub struct sctp_stream_change_event { + pub strchange_type: u16, + pub strchange_flags: u16, + pub strchange_length: u32, + pub strchange_assoc_id: crate::sctp_assoc_t, + pub strchange_instrms: u16, + pub strchange_outstrms: u16, + } + + pub struct filedesc { + pub fd_files: *mut fdescenttbl, + pub fd_map: *mut c_ulong, + pub fd_freefile: c_int, + pub fd_refcnt: c_int, + pub fd_holdcnt: c_int, + fd_sx: sx, + fd_kqlist: kqlist, + pub fd_holdleaderscount: c_int, + pub fd_holdleaderswakeup: c_int, + } + + pub struct fdescenttbl { + pub fdt_nfiles: c_int, + fdt_ofiles: [*mut c_void; 0], + } + + // FIXME: Should be private. + #[doc(hidden)] + pub struct sx { + lock_object: lock_object, + sx_lock: crate::uintptr_t, + } + + // FIXME: Should be private. + #[doc(hidden)] + pub struct lock_object { + lo_name: *const c_char, + lo_flags: c_uint, + lo_data: c_uint, + // This is normally `struct witness`. + lo_witness: *mut c_void, + } + + // FIXME: Should be private. + #[doc(hidden)] + pub struct kqlist { + tqh_first: *mut c_void, + tqh_last: *mut *mut c_void, + } + + pub struct splice { + pub sp_fd: c_int, + pub sp_max: off_t, + pub sp_idle: crate::timeval, + } + + pub struct utmpx { + pub ut_type: c_short, + pub ut_tv: crate::timeval, + pub ut_id: [c_char; 8], + pub ut_pid: crate::pid_t, + pub ut_user: [c_char; 32], + pub ut_line: [c_char; 16], + pub ut_host: [c_char; 128], + pub __ut_spare: [c_char; 64], + } + + pub struct xucred { + pub cr_version: c_uint, + pub cr_uid: crate::uid_t, + pub cr_ngroups: c_short, + pub cr_groups: [crate::gid_t; 16], + pub cr_pid__c_anonymous_union: __c_anonymous_cr_pid, + } + + pub struct sockaddr_dl { + pub sdl_len: c_uchar, + pub sdl_family: c_uchar, + pub sdl_index: c_ushort, + pub sdl_type: c_uchar, + pub sdl_nlen: c_uchar, + pub sdl_alen: c_uchar, + pub sdl_slen: c_uchar, + pub sdl_data: [c_char; 46], + } + + pub struct mq_attr { + pub mq_flags: c_long, + pub mq_maxmsg: c_long, + pub mq_msgsize: c_long, + pub mq_curmsgs: c_long, + __reserved: Padding<[c_long; 4]>, + } + + pub struct ptsstat { + #[cfg(any(freebsd12, freebsd13, freebsd14, freebsd15))] + pub dev: u64, + #[cfg(not(any(freebsd12, freebsd13, freebsd14, freebsd15)))] + pub dev: u32, + pub devname: [c_char; SPECNAMELEN as usize + 1], + } + + pub struct Elf32_Auxinfo { + pub a_type: c_int, + pub a_un: __c_anonymous_elf32_auxv_union, + } + + pub struct ifreq { + /// if name, e.g. "en0" + pub ifr_name: [c_char; crate::IFNAMSIZ], + pub ifr_ifru: __c_anonymous_ifr_ifru, + } + + pub struct if_data { + /// ethernet, tokenring, etc + pub ifi_type: u8, + /// e.g., AUI, Thinnet, 10base-T, etc + pub ifi_physical: u8, + /// media address length + pub ifi_addrlen: u8, + /// media header length + pub ifi_hdrlen: u8, + /// current link state + pub ifi_link_state: u8, + /// carp vhid + pub ifi_vhid: u8, + /// length of this data struct + pub ifi_datalen: u16, + /// maximum transmission unit + pub ifi_mtu: u32, + /// routing metric (external only) + pub ifi_metric: u32, + /// linespeed + pub ifi_baudrate: u64, + /// packets received on interface + pub ifi_ipackets: u64, + /// input errors on interface + pub ifi_ierrors: u64, + /// packets sent on interface + pub ifi_opackets: u64, + /// output errors on interface + pub ifi_oerrors: u64, + /// collisions on csma interfaces + pub ifi_collisions: u64, + /// total number of octets received + pub ifi_ibytes: u64, + /// total number of octets sent + pub ifi_obytes: u64, + /// packets received via multicast + pub ifi_imcasts: u64, + /// packets sent via multicast + pub ifi_omcasts: u64, + /// dropped on input + pub ifi_iqdrops: u64, + /// dropped on output + pub ifi_oqdrops: u64, + /// destined for unsupported protocol + pub ifi_noproto: u64, + /// HW offload capabilities, see IFCAP + pub ifi_hwassist: u64, + /// uptime at attach or stat reset + pub __ifi_epoch: __c_anonymous_ifi_epoch, + /// time of last administrative change + pub __ifi_lastchange: __c_anonymous_ifi_lastchange, + } + + pub struct ifstat { + /// if name, e.g. "en0" + pub ifs_name: [c_char; crate::IFNAMSIZ as usize], + pub ascii: [c_char; crate::IFSTATMAX as usize + 1], + } + + pub struct ifrsskey { + /// if name, e.g. "en0" + pub ifrk_name: [c_char; crate::IFNAMSIZ as usize], + /// RSS_FUNC_ + pub ifrk_func: u8, + pub ifrk_spare0: u8, + pub ifrk_keylen: u16, + pub ifrk_key: [u8; crate::RSS_KEYLEN as usize], + } + + pub struct ifdownreason { + pub ifdr_name: [c_char; crate::IFNAMSIZ as usize], + pub ifdr_reason: u32, + pub ifdr_vendor: u32, + pub ifdr_msg: [c_char; crate::IFDR_MSG_SIZE as usize], + } + + #[repr(packed)] + pub struct sctphdr { + pub src_port: u16, + pub dest_port: u16, + pub v_tag: u32, + pub checksum: u32, + } + + #[repr(packed)] + pub struct sctp_chunkhdr { + pub chunk_type: u8, + pub chunk_flags: u8, + pub chunk_length: u16, + } + + #[repr(packed)] + pub struct sctp_paramhdr { + pub param_type: u16, + pub param_length: u16, + } + + #[repr(packed)] + pub struct sctp_gen_error_cause { + pub code: u16, + pub length: u16, + pub info: [u8; 0], + } + + #[repr(packed)] + pub struct sctp_error_cause { + pub code: u16, + pub length: u16, + } + + #[repr(packed)] + pub struct sctp_error_invalid_stream { + pub cause: sctp_error_cause, + pub stream_id: u16, + __reserved: Padding, + } + + #[repr(packed)] + pub struct sctp_error_missing_param { + pub cause: sctp_error_cause, + pub num_missing_params: u32, + pub tpe: [u8; 0], + } + + #[repr(packed)] + pub struct sctp_error_stale_cookie { + pub cause: sctp_error_cause, + pub stale_time: u32, + } + + #[repr(packed)] + pub struct sctp_error_out_of_resource { + pub cause: sctp_error_cause, + } + + #[repr(packed)] + pub struct sctp_error_unresolv_addr { + pub cause: sctp_error_cause, + } + + #[repr(packed)] + pub struct sctp_error_unrecognized_chunk { + pub cause: sctp_error_cause, + pub ch: sctp_chunkhdr, + } + + #[repr(packed)] + pub struct sctp_error_no_user_data { + pub cause: sctp_error_cause, + pub tsn: u32, + } + + #[repr(packed)] + pub struct sctp_error_auth_invalid_hmac { + pub cause: sctp_error_cause, + pub hmac_id: u16, + } + + pub struct kinfo_file { + pub kf_structsize: c_int, + pub kf_type: c_int, + pub kf_fd: c_int, + pub kf_ref_count: c_int, + pub kf_flags: c_int, + _kf_pad0: Padding, + pub kf_offset: i64, + _priv: [u8; 304], // FIXME(freebsd): this is really a giant union + pub kf_status: u16, + _kf_pad1: Padding, + _kf_ispare0: c_int, + pub kf_cap_rights: crate::cap_rights_t, + _kf_cap_spare: u64, + pub kf_path: [c_char; crate::PATH_MAX as usize], + } +} + +s_no_extra_traits! { + pub union __c_anonymous_cr_pid { + __cr_unused: Padding<*mut c_void>, + pub cr_pid: crate::pid_t, + } + + pub struct sigevent { + pub sigev_notify: c_int, + pub sigev_signo: c_int, + pub sigev_value: crate::sigval, + //The rest of the structure is actually a union. We expose only + //sigev_notify_thread_id because it's the most useful union member. + pub sigev_notify_thread_id: crate::lwpid_t, + #[cfg(target_pointer_width = "64")] + __unused1: c_int, + __unused2: [c_long; 7], + } + + pub union __c_anonymous_elf32_auxv_union { + pub a_val: c_int, + } + + pub union __c_anonymous_ifi_epoch { + pub tt: crate::time_t, + pub ph: u64, + } + + pub union __c_anonymous_ifi_lastchange { + pub tv: crate::timeval, + pub ph: __c_anonymous_ph, + } + + pub union __c_anonymous_ifr_ifru { + pub ifru_addr: crate::sockaddr, + pub ifru_dstaddr: crate::sockaddr, + pub ifru_broadaddr: crate::sockaddr, + pub ifru_buffer: ifreq_buffer, + pub ifru_flags: [c_short; 2], + pub ifru_index: c_short, + pub ifru_jid: c_int, + pub ifru_metric: c_int, + pub ifru_mtu: c_int, + pub ifru_phys: c_int, + pub ifru_media: c_int, + pub ifru_data: crate::caddr_t, + pub ifru_cap: [c_int; 2], + pub ifru_fib: c_uint, + pub ifru_vlan_pcp: c_uchar, + } + + pub union __c_anonymous_ifc_ifcu { + pub ifcu_buf: crate::caddr_t, + pub ifcu_req: *mut ifreq, + } + + pub struct ucontext_t { + pub uc_sigmask: crate::sigset_t, + pub uc_mcontext: crate::mcontext_t, + pub uc_link: *mut crate::ucontext_t, + pub uc_stack: crate::stack_t, + pub uc_flags: c_int, + __spare__: [c_int; 4], + } + + #[repr(align(8))] + pub struct xinpgen { + pub xig_len: ksize_t, + pub xig_count: u32, + _xig_spare32: u32, + pub xig_gen: inp_gen_t, + pub xig_sogen: so_gen_t, + _xig_spare64: [u64; 4], + } + + pub struct in_addr_4in6 { + _ia46_pad32: Padding<[u32; 3]>, + pub ia46_addr4: crate::in_addr, + } + + pub union in_dependaddr { + pub id46_addr: crate::in_addr_4in6, + pub id6_addr: crate::in6_addr, + } + + pub struct in_endpoints { + pub ie_fport: u16, + pub ie_lport: u16, + pub ie_dependfaddr: crate::in_dependaddr, + pub ie_dependladdr: crate::in_dependaddr, + pub ie6_zoneid: u32, + } + + pub struct in_conninfo { + pub inc_flags: u8, + pub inc_len: u8, + pub inc_fibnum: u16, + pub inc_ie: crate::in_endpoints, + } + + pub struct xktls_session_onedir { + // Note: this field is called `gen` in upstream FreeBSD, but `gen` is + // reserved keyword in Rust since the 2024 Edition, hence `gennum`. + pub gennum: u64, + _rsrv1: [u64; 8], + _rsrv2: [u32; 8], + pub iv: [u8; 32], + pub cipher_algorithm: i32, + pub auth_algorithm: i32, + pub cipher_key_len: u16, + pub iv_len: u16, + pub auth_key_len: u16, + pub max_frame_len: u16, + pub tls_vmajor: u8, + pub tls_vminor: u8, + pub tls_hlen: u8, + pub tls_tlen: u8, + pub tls_bs: u8, + pub flags: u8, + pub drv_st_len: u16, + pub ifnet: [c_char; 16], + } + + pub struct xktls_session { + pub tsz: u32, + pub fsz: u32, + pub inp_gencnt: u64, + pub so_pcb: kvaddr_t, + pub coninf: crate::in_conninfo, + pub rx_vlan_id: c_ushort, + pub rcv: crate::xktls_session_onedir, + pub snd: crate::xktls_session_onedir, + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for __c_anonymous_cr_pid { + fn eq(&self, other: &__c_anonymous_cr_pid) -> bool { + unsafe { self.cr_pid == other.cr_pid } + } + } + impl Eq for __c_anonymous_cr_pid {} + impl hash::Hash for __c_anonymous_cr_pid { + fn hash(&self, state: &mut H) { + unsafe { self.cr_pid.hash(state) }; + } + } + + impl PartialEq for sigevent { + fn eq(&self, other: &sigevent) -> bool { + self.sigev_notify == other.sigev_notify + && self.sigev_signo == other.sigev_signo + && self.sigev_value == other.sigev_value + && self.sigev_notify_thread_id == other.sigev_notify_thread_id + } + } + impl Eq for sigevent {} + impl hash::Hash for sigevent { + fn hash(&self, state: &mut H) { + self.sigev_notify.hash(state); + self.sigev_signo.hash(state); + self.sigev_value.hash(state); + self.sigev_notify_thread_id.hash(state); + } + } + + impl PartialEq for __c_anonymous_elf32_auxv_union { + fn eq(&self, other: &__c_anonymous_elf32_auxv_union) -> bool { + unsafe { self.a_val == other.a_val } + } + } + impl Eq for __c_anonymous_elf32_auxv_union {} + impl hash::Hash for __c_anonymous_elf32_auxv_union { + fn hash(&self, _state: &mut H) { + unimplemented!("traits"); + } + } + + impl PartialEq for __c_anonymous_ifr_ifru { + fn eq(&self, other: &__c_anonymous_ifr_ifru) -> bool { + unsafe { + self.ifru_addr == other.ifru_addr + && self.ifru_dstaddr == other.ifru_dstaddr + && self.ifru_broadaddr == other.ifru_broadaddr + && self.ifru_buffer == other.ifru_buffer + && self.ifru_flags == other.ifru_flags + && self.ifru_index == other.ifru_index + && self.ifru_jid == other.ifru_jid + && self.ifru_metric == other.ifru_metric + && self.ifru_mtu == other.ifru_mtu + && self.ifru_phys == other.ifru_phys + && self.ifru_media == other.ifru_media + && self.ifru_data == other.ifru_data + && self.ifru_cap == other.ifru_cap + && self.ifru_fib == other.ifru_fib + && self.ifru_vlan_pcp == other.ifru_vlan_pcp + } + } + } + impl Eq for __c_anonymous_ifr_ifru {} + impl hash::Hash for __c_anonymous_ifr_ifru { + fn hash(&self, state: &mut H) { + unsafe { self.ifru_addr.hash(state) }; + unsafe { self.ifru_dstaddr.hash(state) }; + unsafe { self.ifru_broadaddr.hash(state) }; + unsafe { self.ifru_buffer.hash(state) }; + unsafe { self.ifru_flags.hash(state) }; + unsafe { self.ifru_index.hash(state) }; + unsafe { self.ifru_jid.hash(state) }; + unsafe { self.ifru_metric.hash(state) }; + unsafe { self.ifru_mtu.hash(state) }; + unsafe { self.ifru_phys.hash(state) }; + unsafe { self.ifru_media.hash(state) }; + unsafe { self.ifru_data.hash(state) }; + unsafe { self.ifru_cap.hash(state) }; + unsafe { self.ifru_fib.hash(state) }; + unsafe { self.ifru_vlan_pcp.hash(state) }; + } + } + + impl PartialEq for __c_anonymous_ifc_ifcu { + fn eq(&self, other: &__c_anonymous_ifc_ifcu) -> bool { + unsafe { self.ifcu_buf == other.ifcu_buf && self.ifcu_req == other.ifcu_req } + } + } + impl Eq for __c_anonymous_ifc_ifcu {} + impl hash::Hash for __c_anonymous_ifc_ifcu { + fn hash(&self, state: &mut H) { + unsafe { self.ifcu_buf.hash(state) }; + unsafe { self.ifcu_req.hash(state) }; + } + } + + impl PartialEq for __c_anonymous_ifi_epoch { + fn eq(&self, other: &__c_anonymous_ifi_epoch) -> bool { + unsafe { self.tt == other.tt && self.ph == other.ph } + } + } + impl Eq for __c_anonymous_ifi_epoch {} + impl hash::Hash for __c_anonymous_ifi_epoch { + fn hash(&self, state: &mut H) { + unsafe { + self.tt.hash(state); + self.ph.hash(state); + } + } + } + + impl PartialEq for __c_anonymous_ifi_lastchange { + fn eq(&self, other: &__c_anonymous_ifi_lastchange) -> bool { + unsafe { self.tv == other.tv && self.ph == other.ph } + } + } + impl Eq for __c_anonymous_ifi_lastchange {} + impl hash::Hash for __c_anonymous_ifi_lastchange { + fn hash(&self, state: &mut H) { + unsafe { + self.tv.hash(state); + self.ph.hash(state); + } + } + } + } +} + +#[derive(Debug)] +#[repr(u32)] +pub enum dot3Vendors { + dot3VendorAMD = 1, + dot3VendorIntel = 2, + dot3VendorNational = 4, + dot3VendorFujitsu = 5, + dot3VendorDigital = 6, + dot3VendorWesternDigital = 7, +} +impl Copy for dot3Vendors {} +impl Clone for dot3Vendors { + fn clone(&self) -> dot3Vendors { + *self + } +} + +// aio.h +pub const LIO_VECTORED: c_int = 4; +pub const LIO_WRITEV: c_int = 5; +pub const LIO_READV: c_int = 6; + +// sys/caprights.h +pub const CAP_RIGHTS_VERSION_00: i32 = 0; +pub const CAP_RIGHTS_VERSION: i32 = CAP_RIGHTS_VERSION_00; + +// sys/capsicum.h +macro_rules! cap_right { + ($idx:expr, $bit:expr) => { + ((1u64 << (57 + ($idx))) | ($bit)) + }; +} +pub const CAP_READ: u64 = cap_right!(0, 0x0000000000000001u64); +pub const CAP_WRITE: u64 = cap_right!(0, 0x0000000000000002u64); +pub const CAP_SEEK_TELL: u64 = cap_right!(0, 0x0000000000000004u64); +pub const CAP_SEEK: u64 = CAP_SEEK_TELL | 0x0000000000000008u64; +pub const CAP_PREAD: u64 = CAP_SEEK | CAP_READ; +pub const CAP_PWRITE: u64 = CAP_SEEK | CAP_WRITE; +pub const CAP_MMAP: u64 = cap_right!(0, 0x0000000000000010u64); +pub const CAP_MMAP_R: u64 = CAP_MMAP | CAP_SEEK | CAP_READ; +pub const CAP_MMAP_W: u64 = CAP_MMAP | CAP_SEEK | CAP_WRITE; +pub const CAP_MMAP_X: u64 = CAP_MMAP | CAP_SEEK | 0x0000000000000020u64; +pub const CAP_MMAP_RW: u64 = CAP_MMAP_R | CAP_MMAP_W; +pub const CAP_MMAP_RX: u64 = CAP_MMAP_R | CAP_MMAP_X; +pub const CAP_MMAP_WX: u64 = CAP_MMAP_W | CAP_MMAP_X; +pub const CAP_MMAP_RWX: u64 = CAP_MMAP_R | CAP_MMAP_W | CAP_MMAP_X; +pub const CAP_CREATE: u64 = cap_right!(0, 0x0000000000000040u64); +pub const CAP_FEXECVE: u64 = cap_right!(0, 0x0000000000000080u64); +pub const CAP_FSYNC: u64 = cap_right!(0, 0x0000000000000100u64); +pub const CAP_FTRUNCATE: u64 = cap_right!(0, 0x0000000000000200u64); +pub const CAP_LOOKUP: u64 = cap_right!(0, 0x0000000000000400u64); +pub const CAP_FCHDIR: u64 = cap_right!(0, 0x0000000000000800u64); +pub const CAP_FCHFLAGS: u64 = cap_right!(0, 0x0000000000001000u64); +pub const CAP_CHFLAGSAT: u64 = CAP_FCHFLAGS | CAP_LOOKUP; +pub const CAP_FCHMOD: u64 = cap_right!(0, 0x0000000000002000u64); +pub const CAP_FCHMODAT: u64 = CAP_FCHMOD | CAP_LOOKUP; +pub const CAP_FCHOWN: u64 = cap_right!(0, 0x0000000000004000u64); +pub const CAP_FCHOWNAT: u64 = CAP_FCHOWN | CAP_LOOKUP; +pub const CAP_FCNTL: u64 = cap_right!(0, 0x0000000000008000u64); +pub const CAP_FLOCK: u64 = cap_right!(0, 0x0000000000010000u64); +pub const CAP_FPATHCONF: u64 = cap_right!(0, 0x0000000000020000u64); +pub const CAP_FSCK: u64 = cap_right!(0, 0x0000000000040000u64); +pub const CAP_FSTAT: u64 = cap_right!(0, 0x0000000000080000u64); +pub const CAP_FSTATAT: u64 = CAP_FSTAT | CAP_LOOKUP; +pub const CAP_FSTATFS: u64 = cap_right!(0, 0x0000000000100000u64); +pub const CAP_FUTIMES: u64 = cap_right!(0, 0x0000000000200000u64); +pub const CAP_FUTIMESAT: u64 = CAP_FUTIMES | CAP_LOOKUP; +// Note: this was named CAP_LINKAT prior to FreeBSD 11.0. +pub const CAP_LINKAT_TARGET: u64 = CAP_LOOKUP | 0x0000000000400000u64; +pub const CAP_MKDIRAT: u64 = CAP_LOOKUP | 0x0000000000800000u64; +pub const CAP_MKFIFOAT: u64 = CAP_LOOKUP | 0x0000000001000000u64; +pub const CAP_MKNODAT: u64 = CAP_LOOKUP | 0x0000000002000000u64; +// Note: this was named CAP_RENAMEAT prior to FreeBSD 11.0. +pub const CAP_RENAMEAT_SOURCE: u64 = CAP_LOOKUP | 0x0000000004000000u64; +pub const CAP_SYMLINKAT: u64 = CAP_LOOKUP | 0x0000000008000000u64; +pub const CAP_UNLINKAT: u64 = CAP_LOOKUP | 0x0000000010000000u64; +pub const CAP_ACCEPT: u64 = cap_right!(0, 0x0000000020000000u64); +pub const CAP_BIND: u64 = cap_right!(0, 0x0000000040000000u64); +pub const CAP_CONNECT: u64 = cap_right!(0, 0x0000000080000000u64); +pub const CAP_GETPEERNAME: u64 = cap_right!(0, 0x0000000100000000u64); +pub const CAP_GETSOCKNAME: u64 = cap_right!(0, 0x0000000200000000u64); +pub const CAP_GETSOCKOPT: u64 = cap_right!(0, 0x0000000400000000u64); +pub const CAP_LISTEN: u64 = cap_right!(0, 0x0000000800000000u64); +pub const CAP_PEELOFF: u64 = cap_right!(0, 0x0000001000000000u64); +pub const CAP_RECV: u64 = CAP_READ; +pub const CAP_SEND: u64 = CAP_WRITE; +pub const CAP_SETSOCKOPT: u64 = cap_right!(0, 0x0000002000000000u64); +pub const CAP_SHUTDOWN: u64 = cap_right!(0, 0x0000004000000000u64); +pub const CAP_BINDAT: u64 = CAP_LOOKUP | 0x0000008000000000u64; +pub const CAP_CONNECTAT: u64 = CAP_LOOKUP | 0x0000010000000000u64; +pub const CAP_LINKAT_SOURCE: u64 = CAP_LOOKUP | 0x0000020000000000u64; +pub const CAP_RENAMEAT_TARGET: u64 = CAP_LOOKUP | 0x0000040000000000u64; +pub const CAP_SOCK_CLIENT: u64 = CAP_CONNECT + | CAP_GETPEERNAME + | CAP_GETSOCKNAME + | CAP_GETSOCKOPT + | CAP_PEELOFF + | CAP_RECV + | CAP_SEND + | CAP_SETSOCKOPT + | CAP_SHUTDOWN; +pub const CAP_SOCK_SERVER: u64 = CAP_ACCEPT + | CAP_BIND + | CAP_GETPEERNAME + | CAP_GETSOCKNAME + | CAP_GETSOCKOPT + | CAP_LISTEN + | CAP_PEELOFF + | CAP_RECV + | CAP_SEND + | CAP_SETSOCKOPT + | CAP_SHUTDOWN; +#[deprecated(since = "0.2.165", note = "Not stable across OS versions")] +pub const CAP_ALL0: u64 = cap_right!(0, 0x000007FFFFFFFFFFu64); +#[deprecated(since = "0.2.165", note = "Not stable across OS versions")] +pub const CAP_UNUSED0_44: u64 = cap_right!(0, 0x0000080000000000u64); +#[deprecated(since = "0.2.165", note = "Not stable across OS versions")] +pub const CAP_UNUSED0_57: u64 = cap_right!(0, 0x0100000000000000u64); +pub const CAP_MAC_GET: u64 = cap_right!(1, 0x0000000000000001u64); +pub const CAP_MAC_SET: u64 = cap_right!(1, 0x0000000000000002u64); +pub const CAP_SEM_GETVALUE: u64 = cap_right!(1, 0x0000000000000004u64); +pub const CAP_SEM_POST: u64 = cap_right!(1, 0x0000000000000008u64); +pub const CAP_SEM_WAIT: u64 = cap_right!(1, 0x0000000000000010u64); +pub const CAP_EVENT: u64 = cap_right!(1, 0x0000000000000020u64); +pub const CAP_KQUEUE_EVENT: u64 = cap_right!(1, 0x0000000000000040u64); +pub const CAP_IOCTL: u64 = cap_right!(1, 0x0000000000000080u64); +pub const CAP_TTYHOOK: u64 = cap_right!(1, 0x0000000000000100u64); +pub const CAP_PDGETPID: u64 = cap_right!(1, 0x0000000000000200u64); +pub const CAP_PDWAIT: u64 = cap_right!(1, 0x0000000000000400u64); +pub const CAP_PDKILL: u64 = cap_right!(1, 0x0000000000000800u64); +pub const CAP_EXTATTR_DELETE: u64 = cap_right!(1, 0x0000000000001000u64); +pub const CAP_EXTATTR_GET: u64 = cap_right!(1, 0x0000000000002000u64); +pub const CAP_EXTATTR_LIST: u64 = cap_right!(1, 0x0000000000004000u64); +pub const CAP_EXTATTR_SET: u64 = cap_right!(1, 0x0000000000008000u64); +pub const CAP_ACL_CHECK: u64 = cap_right!(1, 0x0000000000010000u64); +pub const CAP_ACL_DELETE: u64 = cap_right!(1, 0x0000000000020000u64); +pub const CAP_ACL_GET: u64 = cap_right!(1, 0x0000000000040000u64); +pub const CAP_ACL_SET: u64 = cap_right!(1, 0x0000000000080000u64); +pub const CAP_KQUEUE_CHANGE: u64 = cap_right!(1, 0x0000000000100000u64); +pub const CAP_KQUEUE: u64 = CAP_KQUEUE_EVENT | CAP_KQUEUE_CHANGE; +#[deprecated(since = "0.2.165", note = "Not stable across OS versions")] +pub const CAP_ALL1: u64 = cap_right!(1, 0x00000000001FFFFFu64); +#[deprecated(since = "0.2.165", note = "Not stable across OS versions")] +pub const CAP_UNUSED1_22: u64 = cap_right!(1, 0x0000000000200000u64); +#[deprecated(since = "0.2.165", note = "Not stable across OS versions")] +pub const CAP_UNUSED1_57: u64 = cap_right!(1, 0x0100000000000000u64); +pub const CAP_FCNTL_GETFL: u32 = 1 << 3; +pub const CAP_FCNTL_SETFL: u32 = 1 << 4; +pub const CAP_FCNTL_GETOWN: u32 = 1 << 5; +pub const CAP_FCNTL_SETOWN: u32 = 1 << 6; + +// sys/devicestat.h +pub const DEVSTAT_N_TRANS_FLAGS: c_int = 4; +pub const DEVSTAT_NAME_LEN: c_int = 16; + +// sys/cpuset.h +cfg_if! { + if #[cfg(any(freebsd15, freebsd14))] { + pub const CPU_SETSIZE: c_int = 1024; + } else { + pub const CPU_SETSIZE: c_int = 256; + } +} + +pub const SIGEV_THREAD_ID: c_int = 4; + +pub const EXTATTR_NAMESPACE_EMPTY: c_int = 0; +pub const EXTATTR_NAMESPACE_USER: c_int = 1; +pub const EXTATTR_NAMESPACE_SYSTEM: c_int = 2; + +pub const PTHREAD_STACK_MIN: size_t = MINSIGSTKSZ; +pub const PTHREAD_MUTEX_ADAPTIVE_NP: c_int = 4; +pub const PTHREAD_MUTEX_STALLED: c_int = 0; +pub const PTHREAD_MUTEX_ROBUST: c_int = 1; +pub const SIGSTKSZ: size_t = MINSIGSTKSZ + 32768; +pub const SF_NODISKIO: c_int = 0x00000001; +pub const SF_MNOWAIT: c_int = 0x00000002; +pub const SF_SYNC: c_int = 0x00000004; +pub const SF_USER_READAHEAD: c_int = 0x00000008; +pub const SF_NOCACHE: c_int = 0x00000010; +pub const O_CLOEXEC: c_int = 0x00100000; +pub const O_DIRECTORY: c_int = 0x00020000; +pub const O_DSYNC: c_int = 0x01000000; +pub const O_EMPTY_PATH: c_int = 0x02000000; +pub const O_EXEC: c_int = 0x00040000; +pub const O_PATH: c_int = 0x00400000; +pub const O_RESOLVE_BENEATH: c_int = 0x00800000; +pub const O_SEARCH: c_int = O_EXEC; +pub const O_TTY_INIT: c_int = 0x00080000; +pub const O_VERIFY: c_int = 0x00200000; +pub const F_GETLK: c_int = 11; +pub const F_SETLK: c_int = 12; +pub const F_SETLKW: c_int = 13; +pub const ENOTCAPABLE: c_int = 93; +pub const ECAPMODE: c_int = 94; +pub const ENOTRECOVERABLE: c_int = 95; +pub const EOWNERDEAD: c_int = 96; +pub const EINTEGRITY: c_int = 97; +pub const RLIMIT_NPTS: c_int = 11; +pub const RLIMIT_SWAP: c_int = 12; +pub const RLIMIT_KQUEUES: c_int = 13; +pub const RLIMIT_UMTXP: c_int = 14; +#[deprecated(since = "0.2.64", note = "Not stable across OS versions")] +pub const RLIM_NLIMITS: crate::rlim_t = 15; +pub const RLIM_SAVED_MAX: crate::rlim_t = crate::RLIM_INFINITY; +pub const RLIM_SAVED_CUR: crate::rlim_t = crate::RLIM_INFINITY; + +pub const CP_USER: c_int = 0; +pub const CP_NICE: c_int = 1; +pub const CP_SYS: c_int = 2; +pub const CP_INTR: c_int = 3; +pub const CP_IDLE: c_int = 4; +pub const CPUSTATES: c_int = 5; + +pub const NI_NOFQDN: c_int = 0x00000001; +pub const NI_NUMERICHOST: c_int = 0x00000002; +pub const NI_NAMEREQD: c_int = 0x00000004; +pub const NI_NUMERICSERV: c_int = 0x00000008; +pub const NI_DGRAM: c_int = 0x00000010; +pub const NI_NUMERICSCOPE: c_int = 0x00000020; + +pub const XU_NGROUPS: c_int = 16; + +pub const Q_GETQUOTA: c_int = 0x700; +pub const Q_SETQUOTA: c_int = 0x800; + +pub const MAP_GUARD: c_int = 0x00002000; +pub const MAP_EXCL: c_int = 0x00004000; +pub const MAP_PREFAULT_READ: c_int = 0x00040000; +pub const MAP_ALIGNMENT_SHIFT: c_int = 24; +pub const MAP_ALIGNMENT_MASK: c_int = 0xff << MAP_ALIGNMENT_SHIFT; +pub const MAP_ALIGNED_SUPER: c_int = 1 << MAP_ALIGNMENT_SHIFT; + +pub const POSIX_FADV_NORMAL: c_int = 0; +pub const POSIX_FADV_RANDOM: c_int = 1; +pub const POSIX_FADV_SEQUENTIAL: c_int = 2; +pub const POSIX_FADV_WILLNEED: c_int = 3; +pub const POSIX_FADV_DONTNEED: c_int = 4; +pub const POSIX_FADV_NOREUSE: c_int = 5; + +pub const POLLINIGNEOF: c_short = 0x2000; +pub const POLLRDHUP: c_short = 0x4000; + +pub const EVFILT_READ: i16 = -1; +pub const EVFILT_WRITE: i16 = -2; +pub const EVFILT_AIO: i16 = -3; +pub const EVFILT_VNODE: i16 = -4; +pub const EVFILT_PROC: i16 = -5; +pub const EVFILT_SIGNAL: i16 = -6; +pub const EVFILT_TIMER: i16 = -7; +pub const EVFILT_PROCDESC: i16 = -8; +pub const EVFILT_FS: i16 = -9; +pub const EVFILT_LIO: i16 = -10; +pub const EVFILT_USER: i16 = -11; +pub const EVFILT_SENDFILE: i16 = -12; +pub const EVFILT_EMPTY: i16 = -13; + +pub const EV_ADD: u16 = 0x1; +pub const EV_DELETE: u16 = 0x2; +pub const EV_ENABLE: u16 = 0x4; +pub const EV_DISABLE: u16 = 0x8; +pub const EV_FORCEONESHOT: u16 = 0x100; +pub const EV_KEEPUDATA: u16 = 0x200; + +pub const EV_ONESHOT: u16 = 0x10; +pub const EV_CLEAR: u16 = 0x20; +pub const EV_RECEIPT: u16 = 0x40; +pub const EV_DISPATCH: u16 = 0x80; +pub const EV_SYSFLAGS: u16 = 0xf000; +pub const EV_DROP: u16 = 0x1000; +pub const EV_FLAG1: u16 = 0x2000; +pub const EV_FLAG2: u16 = 0x4000; + +pub const EV_EOF: u16 = 0x8000; +pub const EV_ERROR: u16 = 0x4000; + +pub const NOTE_TRIGGER: u32 = 0x01000000; +pub const NOTE_FFNOP: u32 = 0x00000000; +pub const NOTE_FFAND: u32 = 0x40000000; +pub const NOTE_FFOR: u32 = 0x80000000; +pub const NOTE_FFCOPY: u32 = 0xc0000000; +pub const NOTE_FFCTRLMASK: u32 = 0xc0000000; +pub const NOTE_FFLAGSMASK: u32 = 0x00ffffff; +pub const NOTE_LOWAT: u32 = 0x00000001; +pub const NOTE_FILE_POLL: u32 = 0x00000002; +pub const NOTE_DELETE: u32 = 0x00000001; +pub const NOTE_WRITE: u32 = 0x00000002; +pub const NOTE_EXTEND: u32 = 0x00000004; +pub const NOTE_ATTRIB: u32 = 0x00000008; +pub const NOTE_LINK: u32 = 0x00000010; +pub const NOTE_RENAME: u32 = 0x00000020; +pub const NOTE_REVOKE: u32 = 0x00000040; +pub const NOTE_OPEN: u32 = 0x00000080; +pub const NOTE_CLOSE: u32 = 0x00000100; +pub const NOTE_CLOSE_WRITE: u32 = 0x00000200; +pub const NOTE_READ: u32 = 0x00000400; +pub const NOTE_EXIT: u32 = 0x80000000; +pub const NOTE_FORK: u32 = 0x40000000; +pub const NOTE_EXEC: u32 = 0x20000000; +pub const NOTE_PDATAMASK: u32 = 0x000fffff; +pub const NOTE_PCTRLMASK: u32 = 0xf0000000; +pub const NOTE_TRACK: u32 = 0x00000001; +pub const NOTE_TRACKERR: u32 = 0x00000002; +pub const NOTE_CHILD: u32 = 0x00000004; +pub const NOTE_SECONDS: u32 = 0x00000001; +pub const NOTE_MSECONDS: u32 = 0x00000002; +pub const NOTE_USECONDS: u32 = 0x00000004; +pub const NOTE_NSECONDS: u32 = 0x00000008; +pub const NOTE_ABSTIME: u32 = 0x00000010; + +pub const MADV_PROTECT: c_int = 10; + +#[doc(hidden)] +#[deprecated( + since = "0.2.72", + note = "CTL_UNSPEC is deprecated. Use CTL_SYSCTL instead" +)] +pub const CTL_UNSPEC: c_int = 0; +pub const CTL_SYSCTL: c_int = 0; +pub const CTL_KERN: c_int = 1; +pub const CTL_VM: c_int = 2; +pub const CTL_VFS: c_int = 3; +pub const CTL_NET: c_int = 4; +pub const CTL_DEBUG: c_int = 5; +pub const CTL_HW: c_int = 6; +pub const CTL_MACHDEP: c_int = 7; +pub const CTL_USER: c_int = 8; +pub const CTL_P1003_1B: c_int = 9; + +// sys/sysctl.h +pub const CTL_MAXNAME: c_int = 24; + +pub const CTLTYPE: c_int = 0xf; +pub const CTLTYPE_NODE: c_int = 1; +pub const CTLTYPE_INT: c_int = 2; +pub const CTLTYPE_STRING: c_int = 3; +pub const CTLTYPE_S64: c_int = 4; +pub const CTLTYPE_OPAQUE: c_int = 5; +pub const CTLTYPE_STRUCT: c_int = CTLTYPE_OPAQUE; +pub const CTLTYPE_UINT: c_int = 6; +pub const CTLTYPE_LONG: c_int = 7; +pub const CTLTYPE_ULONG: c_int = 8; +pub const CTLTYPE_U64: c_int = 9; +pub const CTLTYPE_U8: c_int = 0xa; +pub const CTLTYPE_U16: c_int = 0xb; +pub const CTLTYPE_S8: c_int = 0xc; +pub const CTLTYPE_S16: c_int = 0xd; +pub const CTLTYPE_S32: c_int = 0xe; +pub const CTLTYPE_U32: c_int = 0xf; + +pub const CTLFLAG_RD: c_int = 0x80000000; +pub const CTLFLAG_WR: c_int = 0x40000000; +pub const CTLFLAG_RW: c_int = CTLFLAG_RD | CTLFLAG_WR; +pub const CTLFLAG_DORMANT: c_int = 0x20000000; +pub const CTLFLAG_ANYBODY: c_int = 0x10000000; +pub const CTLFLAG_SECURE: c_int = 0x08000000; +pub const CTLFLAG_PRISON: c_int = 0x04000000; +pub const CTLFLAG_DYN: c_int = 0x02000000; +pub const CTLFLAG_SKIP: c_int = 0x01000000; +pub const CTLMASK_SECURE: c_int = 0x00F00000; +pub const CTLFLAG_TUN: c_int = 0x00080000; +pub const CTLFLAG_RDTUN: c_int = CTLFLAG_RD | CTLFLAG_TUN; +pub const CTLFLAG_RWTUN: c_int = CTLFLAG_RW | CTLFLAG_TUN; +pub const CTLFLAG_MPSAFE: c_int = 0x00040000; +pub const CTLFLAG_VNET: c_int = 0x00020000; +pub const CTLFLAG_DYING: c_int = 0x00010000; +pub const CTLFLAG_CAPRD: c_int = 0x00008000; +pub const CTLFLAG_CAPWR: c_int = 0x00004000; +pub const CTLFLAG_STATS: c_int = 0x00002000; +pub const CTLFLAG_NOFETCH: c_int = 0x00001000; +pub const CTLFLAG_CAPRW: c_int = CTLFLAG_CAPRD | CTLFLAG_CAPWR; +pub const CTLFLAG_NEEDGIANT: c_int = 0x00000800; + +pub const CTLSHIFT_SECURE: c_int = 20; +pub const CTLFLAG_SECURE1: c_int = CTLFLAG_SECURE | (0 << CTLSHIFT_SECURE); +pub const CTLFLAG_SECURE2: c_int = CTLFLAG_SECURE | (1 << CTLSHIFT_SECURE); +pub const CTLFLAG_SECURE3: c_int = CTLFLAG_SECURE | (2 << CTLSHIFT_SECURE); + +pub const OID_AUTO: c_int = -1; + +pub const CTL_SYSCTL_DEBUG: c_int = 0; +pub const CTL_SYSCTL_NAME: c_int = 1; +pub const CTL_SYSCTL_NEXT: c_int = 2; +pub const CTL_SYSCTL_NAME2OID: c_int = 3; +pub const CTL_SYSCTL_OIDFMT: c_int = 4; +pub const CTL_SYSCTL_OIDDESCR: c_int = 5; +pub const CTL_SYSCTL_OIDLABEL: c_int = 6; +pub const CTL_SYSCTL_NEXTNOSKIP: c_int = 7; + +pub const KERN_OSTYPE: c_int = 1; +pub const KERN_OSRELEASE: c_int = 2; +pub const KERN_OSREV: c_int = 3; +pub const KERN_VERSION: c_int = 4; +pub const KERN_MAXVNODES: c_int = 5; +pub const KERN_MAXPROC: c_int = 6; +pub const KERN_MAXFILES: c_int = 7; +pub const KERN_ARGMAX: c_int = 8; +pub const KERN_SECURELVL: c_int = 9; +pub const KERN_HOSTNAME: c_int = 10; +pub const KERN_HOSTID: c_int = 11; +pub const KERN_CLOCKRATE: c_int = 12; +pub const KERN_VNODE: c_int = 13; +pub const KERN_PROC: c_int = 14; +pub const KERN_FILE: c_int = 15; +pub const KERN_PROF: c_int = 16; +pub const KERN_POSIX1: c_int = 17; +pub const KERN_NGROUPS: c_int = 18; +pub const KERN_JOB_CONTROL: c_int = 19; +pub const KERN_SAVED_IDS: c_int = 20; +pub const KERN_BOOTTIME: c_int = 21; +pub const KERN_NISDOMAINNAME: c_int = 22; +pub const KERN_UPDATEINTERVAL: c_int = 23; +pub const KERN_OSRELDATE: c_int = 24; +pub const KERN_NTP_PLL: c_int = 25; +pub const KERN_BOOTFILE: c_int = 26; +pub const KERN_MAXFILESPERPROC: c_int = 27; +pub const KERN_MAXPROCPERUID: c_int = 28; +pub const KERN_DUMPDEV: c_int = 29; +pub const KERN_IPC: c_int = 30; +pub const KERN_DUMMY: c_int = 31; +pub const KERN_PS_STRINGS: c_int = 32; +pub const KERN_USRSTACK: c_int = 33; +pub const KERN_LOGSIGEXIT: c_int = 34; +pub const KERN_IOV_MAX: c_int = 35; +pub const KERN_HOSTUUID: c_int = 36; +pub const KERN_ARND: c_int = 37; +pub const KERN_MAXPHYS: c_int = 38; + +pub const KERN_PROC_ALL: c_int = 0; +pub const KERN_PROC_PID: c_int = 1; +pub const KERN_PROC_PGRP: c_int = 2; +pub const KERN_PROC_SESSION: c_int = 3; +pub const KERN_PROC_TTY: c_int = 4; +pub const KERN_PROC_UID: c_int = 5; +pub const KERN_PROC_RUID: c_int = 6; +pub const KERN_PROC_ARGS: c_int = 7; +pub const KERN_PROC_PROC: c_int = 8; +pub const KERN_PROC_SV_NAME: c_int = 9; +pub const KERN_PROC_RGID: c_int = 10; +pub const KERN_PROC_GID: c_int = 11; +pub const KERN_PROC_PATHNAME: c_int = 12; +pub const KERN_PROC_OVMMAP: c_int = 13; +pub const KERN_PROC_OFILEDESC: c_int = 14; +pub const KERN_PROC_KSTACK: c_int = 15; +pub const KERN_PROC_INC_THREAD: c_int = 0x10; +pub const KERN_PROC_VMMAP: c_int = 32; +pub const KERN_PROC_FILEDESC: c_int = 33; +pub const KERN_PROC_GROUPS: c_int = 34; +pub const KERN_PROC_ENV: c_int = 35; +pub const KERN_PROC_AUXV: c_int = 36; +pub const KERN_PROC_RLIMIT: c_int = 37; +pub const KERN_PROC_PS_STRINGS: c_int = 38; +pub const KERN_PROC_UMASK: c_int = 39; +pub const KERN_PROC_OSREL: c_int = 40; +pub const KERN_PROC_SIGTRAMP: c_int = 41; +pub const KERN_PROC_CWD: c_int = 42; +pub const KERN_PROC_NFDS: c_int = 43; +pub const KERN_PROC_SIGFASTBLK: c_int = 44; + +pub const KIPC_MAXSOCKBUF: c_int = 1; +pub const KIPC_SOCKBUF_WASTE: c_int = 2; +pub const KIPC_SOMAXCONN: c_int = 3; +pub const KIPC_MAX_LINKHDR: c_int = 4; +pub const KIPC_MAX_PROTOHDR: c_int = 5; +pub const KIPC_MAX_HDR: c_int = 6; +pub const KIPC_MAX_DATALEN: c_int = 7; + +pub const HW_MACHINE: c_int = 1; +pub const HW_MODEL: c_int = 2; +pub const HW_NCPU: c_int = 3; +pub const HW_BYTEORDER: c_int = 4; +pub const HW_PHYSMEM: c_int = 5; +pub const HW_USERMEM: c_int = 6; +pub const HW_PAGESIZE: c_int = 7; +pub const HW_DISKNAMES: c_int = 8; +pub const HW_DISKSTATS: c_int = 9; +pub const HW_FLOATINGPT: c_int = 10; +pub const HW_MACHINE_ARCH: c_int = 11; +pub const HW_REALMEM: c_int = 12; + +pub const USER_CS_PATH: c_int = 1; +pub const USER_BC_BASE_MAX: c_int = 2; +pub const USER_BC_DIM_MAX: c_int = 3; +pub const USER_BC_SCALE_MAX: c_int = 4; +pub const USER_BC_STRING_MAX: c_int = 5; +pub const USER_COLL_WEIGHTS_MAX: c_int = 6; +pub const USER_EXPR_NEST_MAX: c_int = 7; +pub const USER_LINE_MAX: c_int = 8; +pub const USER_RE_DUP_MAX: c_int = 9; +pub const USER_POSIX2_VERSION: c_int = 10; +pub const USER_POSIX2_C_BIND: c_int = 11; +pub const USER_POSIX2_C_DEV: c_int = 12; +pub const USER_POSIX2_CHAR_TERM: c_int = 13; +pub const USER_POSIX2_FORT_DEV: c_int = 14; +pub const USER_POSIX2_FORT_RUN: c_int = 15; +pub const USER_POSIX2_LOCALEDEF: c_int = 16; +pub const USER_POSIX2_SW_DEV: c_int = 17; +pub const USER_POSIX2_UPE: c_int = 18; +pub const USER_STREAM_MAX: c_int = 19; +pub const USER_TZNAME_MAX: c_int = 20; +pub const USER_LOCALBASE: c_int = 21; + +pub const CTL_P1003_1B_ASYNCHRONOUS_IO: c_int = 1; +pub const CTL_P1003_1B_MAPPED_FILES: c_int = 2; +pub const CTL_P1003_1B_MEMLOCK: c_int = 3; +pub const CTL_P1003_1B_MEMLOCK_RANGE: c_int = 4; +pub const CTL_P1003_1B_MEMORY_PROTECTION: c_int = 5; +pub const CTL_P1003_1B_MESSAGE_PASSING: c_int = 6; +pub const CTL_P1003_1B_PRIORITIZED_IO: c_int = 7; +pub const CTL_P1003_1B_PRIORITY_SCHEDULING: c_int = 8; +pub const CTL_P1003_1B_REALTIME_SIGNALS: c_int = 9; +pub const CTL_P1003_1B_SEMAPHORES: c_int = 10; +pub const CTL_P1003_1B_FSYNC: c_int = 11; +pub const CTL_P1003_1B_SHARED_MEMORY_OBJECTS: c_int = 12; +pub const CTL_P1003_1B_SYNCHRONIZED_IO: c_int = 13; +pub const CTL_P1003_1B_TIMERS: c_int = 14; +pub const CTL_P1003_1B_AIO_LISTIO_MAX: c_int = 15; +pub const CTL_P1003_1B_AIO_MAX: c_int = 16; +pub const CTL_P1003_1B_AIO_PRIO_DELTA_MAX: c_int = 17; +pub const CTL_P1003_1B_DELAYTIMER_MAX: c_int = 18; +pub const CTL_P1003_1B_MQ_OPEN_MAX: c_int = 19; +pub const CTL_P1003_1B_PAGESIZE: c_int = 20; +pub const CTL_P1003_1B_RTSIG_MAX: c_int = 21; +pub const CTL_P1003_1B_SEM_NSEMS_MAX: c_int = 22; +pub const CTL_P1003_1B_SEM_VALUE_MAX: c_int = 23; +pub const CTL_P1003_1B_SIGQUEUE_MAX: c_int = 24; +pub const CTL_P1003_1B_TIMER_MAX: c_int = 25; + +pub const TIOCGPTN: c_ulong = 0x4004740f; +pub const TIOCPTMASTER: c_ulong = 0x2000741c; +pub const TIOCSIG: c_ulong = 0x2004745f; +pub const TIOCM_DCD: c_int = 0x40; +pub const H4DISC: c_int = 0x7; + +pub const VM_TOTAL: c_int = 1; + +cfg_if! { + if #[cfg(target_pointer_width = "64")] { + pub const BIOCSETFNR: c_ulong = 0x80104282; + } else { + pub const BIOCSETFNR: c_ulong = 0x80084282; + } +} + +cfg_if! { + if #[cfg(target_pointer_width = "64")] { + pub const FIODGNAME: c_ulong = 0x80106678; + } else { + pub const FIODGNAME: c_ulong = 0x80086678; + } +} + +pub const FIONWRITE: c_ulong = 0x40046677; +pub const FIONSPACE: c_ulong = 0x40046676; +pub const FIOSEEKDATA: c_ulong = 0xc0086661; +pub const FIOSEEKHOLE: c_ulong = 0xc0086662; +pub const FIOSSHMLPGCNF: c_ulong = 0x80306664; + +pub const JAIL_API_VERSION: u32 = 2; +pub const JAIL_CREATE: c_int = 0x01; +pub const JAIL_UPDATE: c_int = 0x02; +pub const JAIL_ATTACH: c_int = 0x04; +pub const JAIL_DYING: c_int = 0x08; +pub const JAIL_SYS_DISABLE: c_int = 0; +pub const JAIL_SYS_NEW: c_int = 1; +pub const JAIL_SYS_INHERIT: c_int = 2; + +pub const MNT_ACLS: c_int = 0x08000000; +pub const MNT_BYFSID: c_int = 0x08000000; +pub const MNT_GJOURNAL: c_int = 0x02000000; +pub const MNT_MULTILABEL: c_int = 0x04000000; +pub const MNT_NFS4ACLS: c_int = 0x00000010; +pub const MNT_SNAPSHOT: c_int = 0x01000000; +pub const MNT_UNION: c_int = 0x00000020; +pub const MNT_NONBUSY: c_int = 0x04000000; + +pub const SCM_BINTIME: c_int = 0x04; +pub const SCM_REALTIME: c_int = 0x05; +pub const SCM_MONOTONIC: c_int = 0x06; +pub const SCM_TIME_INFO: c_int = 0x07; +pub const SCM_CREDS2: c_int = 0x08; + +pub const SO_BINTIME: c_int = 0x2000; +pub const SO_NO_OFFLOAD: c_int = 0x4000; +pub const SO_NO_DDP: c_int = 0x8000; +pub const SO_REUSEPORT_LB: c_int = 0x10000; +pub const SO_LABEL: c_int = 0x1009; +pub const SO_PEERLABEL: c_int = 0x1010; +pub const SO_LISTENQLIMIT: c_int = 0x1011; +pub const SO_LISTENQLEN: c_int = 0x1012; +pub const SO_LISTENINCQLEN: c_int = 0x1013; +pub const SO_SETFIB: c_int = 0x1014; +pub const SO_USER_COOKIE: c_int = 0x1015; +pub const SO_PROTOCOL: c_int = 0x1016; +pub const SO_PROTOTYPE: c_int = SO_PROTOCOL; +pub const SO_TS_CLOCK: c_int = 0x1017; +pub const SO_DOMAIN: c_int = 0x1019; +pub const SO_SPLICE: c_int = 0x1023; +pub const SO_VENDOR: c_int = 0x80000000; + +pub const SO_TS_REALTIME_MICRO: c_int = 0; +pub const SO_TS_BINTIME: c_int = 1; +pub const SO_TS_REALTIME: c_int = 2; +pub const SO_TS_MONOTONIC: c_int = 3; +pub const SO_TS_DEFAULT: c_int = SO_TS_REALTIME_MICRO; +pub const SO_TS_CLOCK_MAX: c_int = SO_TS_MONOTONIC; + +pub const LOCAL_CREDS: c_int = 2; +pub const LOCAL_CREDS_PERSISTENT: c_int = 3; +pub const LOCAL_CONNWAIT: c_int = 4; +pub const LOCAL_VENDOR: c_int = SO_VENDOR; + +pub const PL_EVENT_NONE: c_int = 0; +pub const PL_EVENT_SIGNAL: c_int = 1; +pub const PL_FLAG_SA: c_int = 0x01; +pub const PL_FLAG_BOUND: c_int = 0x02; +pub const PL_FLAG_SCE: c_int = 0x04; +pub const PL_FLAG_SCX: c_int = 0x08; +pub const PL_FLAG_EXEC: c_int = 0x10; +pub const PL_FLAG_SI: c_int = 0x20; +pub const PL_FLAG_FORKED: c_int = 0x40; +pub const PL_FLAG_CHILD: c_int = 0x80; +pub const PL_FLAG_BORN: c_int = 0x100; +pub const PL_FLAG_EXITED: c_int = 0x200; +pub const PL_FLAG_VFORKED: c_int = 0x400; +pub const PL_FLAG_VFORK_DONE: c_int = 0x800; + +pub const PT_LWPINFO: c_int = 13; +pub const PT_GETNUMLWPS: c_int = 14; +pub const PT_GETLWPLIST: c_int = 15; +pub const PT_CLEARSTEP: c_int = 16; +pub const PT_SETSTEP: c_int = 17; +pub const PT_SUSPEND: c_int = 18; +pub const PT_RESUME: c_int = 19; +pub const PT_TO_SCE: c_int = 20; +pub const PT_TO_SCX: c_int = 21; +pub const PT_SYSCALL: c_int = 22; +pub const PT_FOLLOW_FORK: c_int = 23; +pub const PT_LWP_EVENTS: c_int = 24; +pub const PT_GET_EVENT_MASK: c_int = 25; +pub const PT_SET_EVENT_MASK: c_int = 26; +pub const PT_GET_SC_ARGS: c_int = 27; +pub const PT_GET_SC_RET: c_int = 28; +pub const PT_COREDUMP: c_int = 29; +pub const PT_GETREGS: c_int = 33; +pub const PT_SETREGS: c_int = 34; +pub const PT_GETFPREGS: c_int = 35; +pub const PT_SETFPREGS: c_int = 36; +pub const PT_GETDBREGS: c_int = 37; +pub const PT_SETDBREGS: c_int = 38; +pub const PT_VM_TIMESTAMP: c_int = 40; +pub const PT_VM_ENTRY: c_int = 41; +pub const PT_GETREGSET: c_int = 42; +pub const PT_SETREGSET: c_int = 43; +pub const PT_SC_REMOTE: c_int = 44; +pub const PT_FIRSTMACH: c_int = 64; + +pub const PTRACE_EXEC: c_int = 0x0001; +pub const PTRACE_SCE: c_int = 0x0002; +pub const PTRACE_SCX: c_int = 0x0004; +pub const PTRACE_SYSCALL: c_int = PTRACE_SCE | PTRACE_SCX; +pub const PTRACE_FORK: c_int = 0x0008; +pub const PTRACE_LWP: c_int = 0x0010; +pub const PTRACE_VFORK: c_int = 0x0020; +pub const PTRACE_DEFAULT: c_int = PTRACE_EXEC; + +pub const PC_COMPRESS: u32 = 0x00000001; +pub const PC_ALL: u32 = 0x00000002; + +pub const PROC_SPROTECT: c_int = 1; +pub const PROC_REAP_ACQUIRE: c_int = 2; +pub const PROC_REAP_RELEASE: c_int = 3; +pub const PROC_REAP_STATUS: c_int = 4; +pub const PROC_REAP_GETPIDS: c_int = 5; +pub const PROC_REAP_KILL: c_int = 6; +pub const PROC_TRACE_CTL: c_int = 7; +pub const PROC_TRACE_STATUS: c_int = 8; +pub const PROC_TRAPCAP_CTL: c_int = 9; +pub const PROC_TRAPCAP_STATUS: c_int = 10; +pub const PROC_PDEATHSIG_CTL: c_int = 11; +pub const PROC_PDEATHSIG_STATUS: c_int = 12; +pub const PROC_ASLR_CTL: c_int = 13; +pub const PROC_ASLR_STATUS: c_int = 14; +pub const PROC_PROTMAX_CTL: c_int = 15; +pub const PROC_PROTMAX_STATUS: c_int = 16; +pub const PROC_STACKGAP_CTL: c_int = 17; +pub const PROC_STACKGAP_STATUS: c_int = 18; +pub const PROC_NO_NEW_PRIVS_CTL: c_int = 19; +pub const PROC_NO_NEW_PRIVS_STATUS: c_int = 20; +pub const PROC_WXMAP_CTL: c_int = 21; +pub const PROC_WXMAP_STATUS: c_int = 22; +pub const PROC_PROCCTL_MD_MIN: c_int = 0x10000000; + +pub const PPROT_SET: c_int = 1; +pub const PPROT_CLEAR: c_int = 2; +pub const PPROT_DESCEND: c_int = 0x10; +pub const PPROT_INHERIT: c_int = 0x20; + +pub const PROC_TRACE_CTL_ENABLE: c_int = 1; +pub const PROC_TRACE_CTL_DISABLE: c_int = 2; +pub const PROC_TRACE_CTL_DISABLE_EXEC: c_int = 3; + +pub const PROC_TRAPCAP_CTL_ENABLE: c_int = 1; +pub const PROC_TRAPCAP_CTL_DISABLE: c_int = 2; + +pub const PROC_ASLR_FORCE_ENABLE: c_int = 1; +pub const PROC_ASLR_FORCE_DISABLE: c_int = 2; +pub const PROC_ASLR_NOFORCE: c_int = 3; +pub const PROC_ASLR_ACTIVE: c_int = 0x80000000; + +pub const PROC_PROTMAX_FORCE_ENABLE: c_int = 1; +pub const PROC_PROTMAX_FORCE_DISABLE: c_int = 2; +pub const PROC_PROTMAX_NOFORCE: c_int = 3; +pub const PROC_PROTMAX_ACTIVE: c_int = 0x80000000; + +pub const PROC_STACKGAP_ENABLE: c_int = 0x0001; +pub const PROC_STACKGAP_DISABLE: c_int = 0x0002; +pub const PROC_STACKGAP_ENABLE_EXEC: c_int = 0x0004; +pub const PROC_STACKGAP_DISABLE_EXEC: c_int = 0x0008; + +pub const PROC_NO_NEW_PRIVS_ENABLE: c_int = 1; +pub const PROC_NO_NEW_PRIVS_DISABLE: c_int = 2; + +pub const PROC_WX_MAPPINGS_PERMIT: c_int = 0x0001; +pub const PROC_WX_MAPPINGS_DISALLOW_EXEC: c_int = 0x0002; +pub const PROC_WXORX_ENFORCE: c_int = 0x80000000; + +pub const AF_SLOW: c_int = 33; +pub const AF_SCLUSTER: c_int = 34; +pub const AF_ARP: c_int = 35; +pub const AF_BLUETOOTH: c_int = 36; +pub const AF_IEEE80211: c_int = 37; +pub const AF_INET_SDP: c_int = 40; +pub const AF_INET6_SDP: c_int = 42; + +// sys/net/if.h +pub const IF_MAXUNIT: c_int = 0x7fff; +/// (n) interface is up +pub const IFF_UP: c_int = 0x1; +/// (i) broadcast address valid +pub const IFF_BROADCAST: c_int = 0x2; +/// (n) turn on debugging +pub const IFF_DEBUG: c_int = 0x4; +/// (i) is a loopback net +pub const IFF_LOOPBACK: c_int = 0x8; +/// (i) is a point-to-point link +pub const IFF_POINTOPOINT: c_int = 0x10; +/// (i) calls if_input in net epoch +#[deprecated(since = "0.2.149", note = "Removed in FreeBSD 14")] +pub const IFF_KNOWSEPOCH: c_int = 0x20; +/// (d) resources allocated +pub const IFF_RUNNING: c_int = 0x40; +#[doc(hidden)] +#[deprecated( + since = "0.2.54", + note = "IFF_DRV_RUNNING is deprecated. Use the portable IFF_RUNNING instead" +)] +/// (d) resources allocate +pub const IFF_DRV_RUNNING: c_int = 0x40; +/// (n) no address resolution protocol +pub const IFF_NOARP: c_int = 0x80; +/// (n) receive all packets +pub const IFF_PROMISC: c_int = 0x100; +/// (n) receive all multicast packets +pub const IFF_ALLMULTI: c_int = 0x200; +/// (d) tx hardware queue is full +pub const IFF_OACTIVE: c_int = 0x400; +#[doc(hidden)] +#[deprecated(since = "0.2.54", note = "Use the portable `IFF_OACTIVE` instead")] +/// (d) tx hardware queue is full +pub const IFF_DRV_OACTIVE: c_int = 0x400; +/// (i) can't hear own transmissions +pub const IFF_SIMPLEX: c_int = 0x800; +/// per link layer defined bit +pub const IFF_LINK0: c_int = 0x1000; +/// per link layer defined bit +pub const IFF_LINK1: c_int = 0x2000; +/// per link layer defined bit +pub const IFF_LINK2: c_int = 0x4000; +/// use alternate physical connection +pub const IFF_ALTPHYS: c_int = IFF_LINK2; +/// (i) supports multicast +pub const IFF_MULTICAST: c_int = 0x8000; +/// (i) unconfigurable using ioctl(2) +pub const IFF_CANTCONFIG: c_int = 0x10000; +/// (n) user-requested promisc mode +pub const IFF_PPROMISC: c_int = 0x20000; +/// (n) user-requested monitor mode +pub const IFF_MONITOR: c_int = 0x40000; +/// (n) static ARP +pub const IFF_STATICARP: c_int = 0x80000; +/// (n) interface is winding down +pub const IFF_DYING: c_int = 0x200000; +/// (n) interface is being renamed +pub const IFF_RENAMING: c_int = 0x400000; +/// interface is not part of any groups +#[deprecated(since = "0.2.149", note = "Removed in FreeBSD 14")] +pub const IFF_NOGROUP: c_int = 0x800000; + +/// link invalid/unknown +pub const LINK_STATE_UNKNOWN: c_int = 0; +/// link is down +pub const LINK_STATE_DOWN: c_int = 1; +/// link is up +pub const LINK_STATE_UP: c_int = 2; + +/// can offload checksum on RX +pub const IFCAP_RXCSUM: c_int = 0x00001; +/// can offload checksum on TX +pub const IFCAP_TXCSUM: c_int = 0x00002; +/// can be a network console +pub const IFCAP_NETCONS: c_int = 0x00004; +/// VLAN-compatible MTU +pub const IFCAP_VLAN_MTU: c_int = 0x00008; +/// hardware VLAN tag support +pub const IFCAP_VLAN_HWTAGGING: c_int = 0x00010; +/// 9000 byte MTU supported +pub const IFCAP_JUMBO_MTU: c_int = 0x00020; +/// driver supports polling +pub const IFCAP_POLLING: c_int = 0x00040; +/// can do IFCAP_HWCSUM on VLANs +pub const IFCAP_VLAN_HWCSUM: c_int = 0x00080; +/// can do TCP Segmentation Offload +pub const IFCAP_TSO4: c_int = 0x00100; +/// can do TCP6 Segmentation Offload +pub const IFCAP_TSO6: c_int = 0x00200; +/// can do Large Receive Offload +pub const IFCAP_LRO: c_int = 0x00400; +/// wake on any unicast frame +pub const IFCAP_WOL_UCAST: c_int = 0x00800; +/// wake on any multicast frame +pub const IFCAP_WOL_MCAST: c_int = 0x01000; +/// wake on any Magic Packet +pub const IFCAP_WOL_MAGIC: c_int = 0x02000; +/// interface can offload TCP +pub const IFCAP_TOE4: c_int = 0x04000; +/// interface can offload TCP6 +pub const IFCAP_TOE6: c_int = 0x08000; +/// interface hw can filter vlan tag +pub const IFCAP_VLAN_HWFILTER: c_int = 0x10000; +/// can do SIOCGIFCAPNV/SIOCSIFCAPNV +pub const IFCAP_NV: c_int = 0x20000; +/// can do IFCAP_TSO on VLANs +pub const IFCAP_VLAN_HWTSO: c_int = 0x40000; +/// the runtime link state is dynamic +pub const IFCAP_LINKSTATE: c_int = 0x80000; +/// netmap mode supported/enabled +pub const IFCAP_NETMAP: c_int = 0x100000; +/// can offload checksum on IPv6 RX +pub const IFCAP_RXCSUM_IPV6: c_int = 0x200000; +/// can offload checksum on IPv6 TX +pub const IFCAP_TXCSUM_IPV6: c_int = 0x400000; +/// manages counters internally +pub const IFCAP_HWSTATS: c_int = 0x800000; +/// hardware supports TX rate limiting +pub const IFCAP_TXRTLMT: c_int = 0x1000000; +/// hardware rx timestamping +pub const IFCAP_HWRXTSTMP: c_int = 0x2000000; +/// understands M_EXTPG mbufs +pub const IFCAP_MEXTPG: c_int = 0x4000000; +/// can do TLS encryption and segmentation for TCP +pub const IFCAP_TXTLS4: c_int = 0x8000000; +/// can do TLS encryption and segmentation for TCP6 +pub const IFCAP_TXTLS6: c_int = 0x10000000; +/// can do IFCAN_HWCSUM on VXLANs +pub const IFCAP_VXLAN_HWCSUM: c_int = 0x20000000; +/// can do IFCAP_TSO on VXLANs +pub const IFCAP_VXLAN_HWTSO: c_int = 0x40000000; +/// can do TLS with rate limiting +pub const IFCAP_TXTLS_RTLMT: c_int = 0x80000000; + +pub const IFCAP_HWCSUM_IPV6: c_int = IFCAP_RXCSUM_IPV6 | IFCAP_TXCSUM_IPV6; +pub const IFCAP_HWCSUM: c_int = IFCAP_RXCSUM | IFCAP_TXCSUM; +pub const IFCAP_TSO: c_int = IFCAP_TSO4 | IFCAP_TSO6; +pub const IFCAP_WOL: c_int = IFCAP_WOL_UCAST | IFCAP_WOL_MCAST | IFCAP_WOL_MAGIC; +pub const IFCAP_TOE: c_int = IFCAP_TOE4 | IFCAP_TOE6; +pub const IFCAP_TXTLS: c_int = IFCAP_TXTLS4 | IFCAP_TXTLS6; +pub const IFCAP_CANTCHANGE: c_int = IFCAP_NETMAP | IFCAP_NV; + +pub const IFQ_MAXLEN: c_int = 50; +pub const IFNET_SLOWHZ: c_int = 1; + +pub const IFAN_ARRIVAL: c_int = 0; +pub const IFAN_DEPARTURE: c_int = 1; + +pub const IFSTATMAX: c_int = 800; + +pub const RSS_FUNC_NONE: c_int = 0; +pub const RSS_FUNC_PRIVATE: c_int = 1; +pub const RSS_FUNC_TOEPLITZ: c_int = 2; + +pub const RSS_TYPE_IPV4: c_int = 0x00000001; +pub const RSS_TYPE_TCP_IPV4: c_int = 0x00000002; +pub const RSS_TYPE_IPV6: c_int = 0x00000004; +pub const RSS_TYPE_IPV6_EX: c_int = 0x00000008; +pub const RSS_TYPE_TCP_IPV6: c_int = 0x00000010; +pub const RSS_TYPE_TCP_IPV6_EX: c_int = 0x00000020; +pub const RSS_TYPE_UDP_IPV4: c_int = 0x00000040; +pub const RSS_TYPE_UDP_IPV6: c_int = 0x00000080; +pub const RSS_TYPE_UDP_IPV6_EX: c_int = 0x00000100; +pub const RSS_KEYLEN: c_int = 128; + +pub const IFNET_PCP_NONE: c_int = 0xff; +pub const IFDR_MSG_SIZE: c_int = 64; +pub const IFDR_REASON_MSG: c_int = 1; +pub const IFDR_REASON_VENDOR: c_int = 2; + +// sys/net/if_mib.h + +/// non-interface-specific +pub const IFMIB_SYSTEM: c_int = 1; +/// per-interface data table +pub const IFMIB_IFDATA: c_int = 2; + +/// generic stats for all kinds of ifaces +pub const IFDATA_GENERAL: c_int = 1; +/// specific to the type of interface +pub const IFDATA_LINKSPECIFIC: c_int = 2; +/// driver name and unit +pub const IFDATA_DRIVERNAME: c_int = 3; + +/// number of interfaces configured +pub const IFMIB_IFCOUNT: c_int = 1; + +/// functions not specific to a type of iface +pub const NETLINK_GENERIC: c_int = 0; + +pub const DOT3COMPLIANCE_STATS: c_int = 1; +pub const DOT3COMPLIANCE_COLLS: c_int = 2; + +pub const dot3ChipSetAMD7990: c_int = 1; +pub const dot3ChipSetAMD79900: c_int = 2; +pub const dot3ChipSetAMD79C940: c_int = 3; + +pub const dot3ChipSetIntel82586: c_int = 1; +pub const dot3ChipSetIntel82596: c_int = 2; +pub const dot3ChipSetIntel82557: c_int = 3; + +pub const dot3ChipSetNational8390: c_int = 1; +pub const dot3ChipSetNationalSonic: c_int = 2; + +pub const dot3ChipSetFujitsu86950: c_int = 1; + +pub const dot3ChipSetDigitalDC21040: c_int = 1; +pub const dot3ChipSetDigitalDC21140: c_int = 2; +pub const dot3ChipSetDigitalDC21041: c_int = 3; +pub const dot3ChipSetDigitalDC21140A: c_int = 4; +pub const dot3ChipSetDigitalDC21142: c_int = 5; + +pub const dot3ChipSetWesternDigital83C690: c_int = 1; +pub const dot3ChipSetWesternDigital83C790: c_int = 2; + +// sys/netinet/in.h +// Protocols (RFC 1700) +// NOTE: These are in addition to the constants defined in src/unix/mod.rs + +// IPPROTO_IP defined in src/unix/mod.rs +/// IP6 hop-by-hop options +pub const IPPROTO_HOPOPTS: c_int = 0; +// IPPROTO_ICMP defined in src/unix/mod.rs +/// group mgmt protocol +pub const IPPROTO_IGMP: c_int = 2; +/// gateway^2 (deprecated) +pub const IPPROTO_GGP: c_int = 3; +/// for compatibility +pub const IPPROTO_IPIP: c_int = 4; +// IPPROTO_TCP defined in src/unix/mod.rs +/// Stream protocol II. +pub const IPPROTO_ST: c_int = 7; +/// exterior gateway protocol +pub const IPPROTO_EGP: c_int = 8; +/// private interior gateway +pub const IPPROTO_PIGP: c_int = 9; +/// BBN RCC Monitoring +pub const IPPROTO_RCCMON: c_int = 10; +/// network voice protocol +pub const IPPROTO_NVPII: c_int = 11; +/// pup +pub const IPPROTO_PUP: c_int = 12; +/// Argus +pub const IPPROTO_ARGUS: c_int = 13; +/// EMCON +pub const IPPROTO_EMCON: c_int = 14; +/// Cross Net Debugger +pub const IPPROTO_XNET: c_int = 15; +/// Chaos +pub const IPPROTO_CHAOS: c_int = 16; +// IPPROTO_UDP defined in src/unix/mod.rs +/// Multiplexing +pub const IPPROTO_MUX: c_int = 18; +/// DCN Measurement Subsystems +pub const IPPROTO_MEAS: c_int = 19; +/// Host Monitoring +pub const IPPROTO_HMP: c_int = 20; +/// Packet Radio Measurement +pub const IPPROTO_PRM: c_int = 21; +/// xns idp +pub const IPPROTO_IDP: c_int = 22; +/// Trunk-1 +pub const IPPROTO_TRUNK1: c_int = 23; +/// Trunk-2 +pub const IPPROTO_TRUNK2: c_int = 24; +/// Leaf-1 +pub const IPPROTO_LEAF1: c_int = 25; +/// Leaf-2 +pub const IPPROTO_LEAF2: c_int = 26; +/// Reliable Data +pub const IPPROTO_RDP: c_int = 27; +/// Reliable Transaction +pub const IPPROTO_IRTP: c_int = 28; +/// tp-4 w/ class negotiation +pub const IPPROTO_TP: c_int = 29; +/// Bulk Data Transfer +pub const IPPROTO_BLT: c_int = 30; +/// Network Services +pub const IPPROTO_NSP: c_int = 31; +/// Merit Internodal +pub const IPPROTO_INP: c_int = 32; +#[doc(hidden)] +#[deprecated( + since = "0.2.72", + note = "IPPROTO_SEP is deprecated. Use IPPROTO_DCCP instead" +)] +pub const IPPROTO_SEP: c_int = 33; +/// Datagram Congestion Control Protocol +pub const IPPROTO_DCCP: c_int = 33; +/// Third Party Connect +pub const IPPROTO_3PC: c_int = 34; +/// InterDomain Policy Routing +pub const IPPROTO_IDPR: c_int = 35; +/// XTP +pub const IPPROTO_XTP: c_int = 36; +/// Datagram Delivery +pub const IPPROTO_DDP: c_int = 37; +/// Control Message Transport +pub const IPPROTO_CMTP: c_int = 38; +/// TP++ Transport +pub const IPPROTO_TPXX: c_int = 39; +/// IL transport protocol +pub const IPPROTO_IL: c_int = 40; +// IPPROTO_IPV6 defined in src/unix/mod.rs +/// Source Demand Routing +pub const IPPROTO_SDRP: c_int = 42; +/// IP6 routing header +pub const IPPROTO_ROUTING: c_int = 43; +/// IP6 fragmentation header +pub const IPPROTO_FRAGMENT: c_int = 44; +/// InterDomain Routing +pub const IPPROTO_IDRP: c_int = 45; +/// resource reservation +pub const IPPROTO_RSVP: c_int = 46; +/// General Routing Encap. +pub const IPPROTO_GRE: c_int = 47; +/// Mobile Host Routing +pub const IPPROTO_MHRP: c_int = 48; +/// BHA +pub const IPPROTO_BHA: c_int = 49; +/// IP6 Encap Sec. Payload +pub const IPPROTO_ESP: c_int = 50; +/// IP6 Auth Header +pub const IPPROTO_AH: c_int = 51; +/// Integ. Net Layer Security +pub const IPPROTO_INLSP: c_int = 52; +/// IP with encryption +pub const IPPROTO_SWIPE: c_int = 53; +/// Next Hop Resolution +pub const IPPROTO_NHRP: c_int = 54; +/// IP Mobility +pub const IPPROTO_MOBILE: c_int = 55; +/// Transport Layer Security +pub const IPPROTO_TLSP: c_int = 56; +/// SKIP +pub const IPPROTO_SKIP: c_int = 57; +// IPPROTO_ICMPV6 defined in src/unix/mod.rs +/// IP6 no next header +pub const IPPROTO_NONE: c_int = 59; +/// IP6 destination option +pub const IPPROTO_DSTOPTS: c_int = 60; +/// any host internal protocol +pub const IPPROTO_AHIP: c_int = 61; +/// CFTP +pub const IPPROTO_CFTP: c_int = 62; +/// "hello" routing protocol +pub const IPPROTO_HELLO: c_int = 63; +/// SATNET/Backroom EXPAK +pub const IPPROTO_SATEXPAK: c_int = 64; +/// Kryptolan +pub const IPPROTO_KRYPTOLAN: c_int = 65; +/// Remote Virtual Disk +pub const IPPROTO_RVD: c_int = 66; +/// Pluribus Packet Core +pub const IPPROTO_IPPC: c_int = 67; +/// Any distributed FS +pub const IPPROTO_ADFS: c_int = 68; +/// Satnet Monitoring +pub const IPPROTO_SATMON: c_int = 69; +/// VISA Protocol +pub const IPPROTO_VISA: c_int = 70; +/// Packet Core Utility +pub const IPPROTO_IPCV: c_int = 71; +/// Comp. Prot. Net. Executive +pub const IPPROTO_CPNX: c_int = 72; +/// Comp. Prot. HeartBeat +pub const IPPROTO_CPHB: c_int = 73; +/// Wang Span Network +pub const IPPROTO_WSN: c_int = 74; +/// Packet Video Protocol +pub const IPPROTO_PVP: c_int = 75; +/// BackRoom SATNET Monitoring +pub const IPPROTO_BRSATMON: c_int = 76; +/// Sun net disk proto (temp.) +pub const IPPROTO_ND: c_int = 77; +/// WIDEBAND Monitoring +pub const IPPROTO_WBMON: c_int = 78; +/// WIDEBAND EXPAK +pub const IPPROTO_WBEXPAK: c_int = 79; +/// ISO cnlp +pub const IPPROTO_EON: c_int = 80; +/// VMTP +pub const IPPROTO_VMTP: c_int = 81; +/// Secure VMTP +pub const IPPROTO_SVMTP: c_int = 82; +/// Banyon VINES +pub const IPPROTO_VINES: c_int = 83; +/// TTP +pub const IPPROTO_TTP: c_int = 84; +/// NSFNET-IGP +pub const IPPROTO_IGP: c_int = 85; +/// dissimilar gateway prot. +pub const IPPROTO_DGP: c_int = 86; +/// TCF +pub const IPPROTO_TCF: c_int = 87; +/// Cisco/GXS IGRP +pub const IPPROTO_IGRP: c_int = 88; +/// OSPFIGP +pub const IPPROTO_OSPFIGP: c_int = 89; +/// Strite RPC protocol +pub const IPPROTO_SRPC: c_int = 90; +/// Locus Address Resoloution +pub const IPPROTO_LARP: c_int = 91; +/// Multicast Transport +pub const IPPROTO_MTP: c_int = 92; +/// AX.25 Frames +pub const IPPROTO_AX25: c_int = 93; +/// IP encapsulated in IP +pub const IPPROTO_IPEIP: c_int = 94; +/// Mobile Int.ing control +pub const IPPROTO_MICP: c_int = 95; +/// Semaphore Comm. security +pub const IPPROTO_SCCSP: c_int = 96; +/// Ethernet IP encapsulation +pub const IPPROTO_ETHERIP: c_int = 97; +/// encapsulation header +pub const IPPROTO_ENCAP: c_int = 98; +/// any private encr. scheme +pub const IPPROTO_APES: c_int = 99; +/// GMTP +pub const IPPROTO_GMTP: c_int = 100; +/// payload compression (IPComp) +pub const IPPROTO_IPCOMP: c_int = 108; +/// SCTP +pub const IPPROTO_SCTP: c_int = 132; +/// IPv6 Mobility Header +pub const IPPROTO_MH: c_int = 135; +/// UDP-Lite +pub const IPPROTO_UDPLITE: c_int = 136; +/// IP6 Host Identity Protocol +pub const IPPROTO_HIP: c_int = 139; +/// IP6 Shim6 Protocol +pub const IPPROTO_SHIM6: c_int = 140; + +/* 101-254: Partly Unassigned */ +/// Protocol Independent Mcast +pub const IPPROTO_PIM: c_int = 103; +/// CARP +pub const IPPROTO_CARP: c_int = 112; +/// PGM +pub const IPPROTO_PGM: c_int = 113; +/// MPLS-in-IP +pub const IPPROTO_MPLS: c_int = 137; +/// PFSYNC +pub const IPPROTO_PFSYNC: c_int = 240; + +/* 255: Reserved */ +/* BSD Private, local use, namespace incursion, no longer used */ +/// OLD divert pseudo-proto +pub const IPPROTO_OLD_DIVERT: c_int = 254; +pub const IPPROTO_MAX: c_int = 256; +/// last return value of *_input(), meaning "all job for this pkt is done". +pub const IPPROTO_DONE: c_int = 257; + +/* Only used internally, so can be outside the range of valid IP protocols. */ +/// divert pseudo-protocol +pub const IPPROTO_DIVERT: c_int = 258; +/// SeND pseudo-protocol +pub const IPPROTO_SEND: c_int = 259; + +// sys/netinet/TCP.h +pub const TCP_MD5SIG: c_int = 16; +pub const TCP_INFO: c_int = 32; +pub const TCP_CONGESTION: c_int = 64; +pub const TCP_CCALGOOPT: c_int = 65; +pub const TCP_MAXUNACKTIME: c_int = 68; +#[deprecated(since = "0.2.160", note = "Removed in FreeBSD 15")] +pub const TCP_MAXPEAKRATE: c_int = 69; +pub const TCP_IDLE_REDUCE: c_int = 70; +pub const TCP_REMOTE_UDP_ENCAPS_PORT: c_int = 71; +pub const TCP_DELACK: c_int = 72; +pub const TCP_FIN_IS_RST: c_int = 73; +pub const TCP_LOG_LIMIT: c_int = 74; +pub const TCP_SHARED_CWND_ALLOWED: c_int = 75; +pub const TCP_PROC_ACCOUNTING: c_int = 76; +pub const TCP_USE_CMP_ACKS: c_int = 77; +pub const TCP_PERF_INFO: c_int = 78; +pub const TCP_LRD: c_int = 79; +pub const TCP_KEEPINIT: c_int = 128; +pub const TCP_FASTOPEN: c_int = 1025; +#[deprecated(since = "0.2.171", note = "removed in FreeBSD 15")] +pub const TCP_PCAP_OUT: c_int = 2048; +#[deprecated(since = "0.2.171", note = "removed in FreeBSD 15")] +pub const TCP_PCAP_IN: c_int = 4096; +pub const TCP_FUNCTION_BLK: c_int = 8192; +pub const TCP_FUNCTION_ALIAS: c_int = 8193; +pub const TCP_FASTOPEN_PSK_LEN: c_int = 16; +pub const TCP_FUNCTION_NAME_LEN_MAX: c_int = 32; + +pub const TCP_REUSPORT_LB_NUMA: c_int = 1026; +pub const TCP_RACK_MBUF_QUEUE: c_int = 1050; +pub const TCP_RACK_TLP_REDUCE: c_int = 1052; +pub const TCP_RACK_PACE_MAX_SEG: c_int = 1054; +pub const TCP_RACK_PACE_ALWAYS: c_int = 1055; +pub const TCP_RACK_PRR_SENDALOT: c_int = 1057; +pub const TCP_RACK_MIN_TO: c_int = 1058; +pub const TCP_RACK_EARLY_SEG: c_int = 1060; +pub const TCP_RACK_REORD_THRESH: c_int = 1061; +pub const TCP_RACK_REORD_FADE: c_int = 1062; +pub const TCP_RACK_TLP_THRESH: c_int = 1063; +pub const TCP_RACK_PKT_DELAY: c_int = 1064; +pub const TCP_BBR_IWINTSO: c_int = 1067; +pub const TCP_BBR_STARTUP_PG: c_int = 1069; +pub const TCP_BBR_DRAIN_PG: c_int = 1070; +pub const TCP_BBR_PROBE_RTT_INT: c_int = 1072; +pub const TCP_BBR_STARTUP_LOSS_EXIT: c_int = 1074; +pub const TCP_BBR_TSLIMITS: c_int = 1076; +pub const TCP_BBR_PACE_OH: c_int = 1077; +pub const TCP_BBR_USEDEL_RATE: c_int = 1079; +pub const TCP_BBR_MIN_RTO: c_int = 1080; +pub const TCP_BBR_MAX_RTO: c_int = 1081; +pub const TCP_BBR_ALGORITHM: c_int = 1083; +pub const TCP_BBR_PACE_PER_SEC: c_int = 1086; +pub const TCP_BBR_PACE_DEL_TAR: c_int = 1087; +pub const TCP_BBR_PACE_SEG_MAX: c_int = 1088; +pub const TCP_BBR_PACE_SEG_MIN: c_int = 1089; +pub const TCP_BBR_PACE_CROSS: c_int = 1090; +pub const TCP_BBR_TMR_PACE_OH: c_int = 1096; +pub const TCP_BBR_RACK_RTT_USE: c_int = 1098; +pub const TCP_BBR_RETRAN_WTSO: c_int = 1099; +pub const TCP_BBR_PROBE_RTT_GAIN: c_int = 1101; +pub const TCP_BBR_PROBE_RTT_LEN: c_int = 1102; +pub const TCP_BBR_SEND_IWND_IN_TSO: c_int = 1103; +pub const TCP_BBR_USE_RACK_RR: c_int = 1104; +pub const TCP_BBR_HDWR_PACE: c_int = 1105; +pub const TCP_BBR_UTTER_MAX_TSO: c_int = 1106; +pub const TCP_BBR_EXTRA_STATE: c_int = 1107; +pub const TCP_BBR_FLOOR_MIN_TSO: c_int = 1108; +pub const TCP_BBR_MIN_TOPACEOUT: c_int = 1109; +pub const TCP_BBR_TSTMP_RAISES: c_int = 1110; +pub const TCP_BBR_POLICER_DETECT: c_int = 1111; +pub const TCP_BBR_RACK_INIT_RATE: c_int = 1112; + +pub const IP_BINDANY: c_int = 24; +pub const IP_BINDMULTI: c_int = 25; +pub const IP_RSS_LISTEN_BUCKET: c_int = 26; +pub const IP_ORIGDSTADDR: c_int = 27; +pub const IP_RECVORIGDSTADDR: c_int = IP_ORIGDSTADDR; + +pub const IP_DONTFRAG: c_int = 67; +pub const IP_RECVTOS: c_int = 68; + +pub const IPV6_BINDANY: c_int = 64; +pub const IPV6_ORIGDSTADDR: c_int = 72; +pub const IPV6_RECVORIGDSTADDR: c_int = IPV6_ORIGDSTADDR; + +pub const PF_SLOW: c_int = AF_SLOW; +pub const PF_SCLUSTER: c_int = AF_SCLUSTER; +pub const PF_ARP: c_int = AF_ARP; +pub const PF_BLUETOOTH: c_int = AF_BLUETOOTH; +pub const PF_IEEE80211: c_int = AF_IEEE80211; +pub const PF_INET_SDP: c_int = AF_INET_SDP; +pub const PF_INET6_SDP: c_int = AF_INET6_SDP; + +pub const NET_RT_DUMP: c_int = 1; +pub const NET_RT_FLAGS: c_int = 2; +pub const NET_RT_IFLIST: c_int = 3; +pub const NET_RT_IFMALIST: c_int = 4; +pub const NET_RT_IFLISTL: c_int = 5; + +// System V IPC +pub const IPC_INFO: c_int = 3; +pub const MSG_NOERROR: c_int = 0o10000; +pub const SHM_LOCK: c_int = 11; +pub const SHM_UNLOCK: c_int = 12; +pub const SHM_STAT: c_int = 13; +pub const SHM_INFO: c_int = 14; +pub const SHM_ANON: *mut c_char = 1 as *mut c_char; + +// The *_MAXID constants never should've been used outside of the +// FreeBSD base system. And with the exception of CTL_P1003_1B_MAXID, +// they were all removed in svn r262489. They remain here for backwards +// compatibility only, and are scheduled to be removed in libc 1.0.0. +#[doc(hidden)] +#[deprecated(since = "0.2.54", note = "Removed in FreeBSD 11")] +pub const CTL_MAXID: c_int = 10; +#[doc(hidden)] +#[deprecated(since = "0.2.54", note = "Removed in FreeBSD 11")] +pub const KERN_MAXID: c_int = 38; +#[doc(hidden)] +#[deprecated(since = "0.2.54", note = "Removed in FreeBSD 11")] +pub const HW_MAXID: c_int = 13; +#[doc(hidden)] +#[deprecated(since = "0.2.54", note = "Removed in FreeBSD 11")] +pub const USER_MAXID: c_int = 21; +#[doc(hidden)] +#[deprecated(since = "0.2.74", note = "Removed in FreeBSD 13")] +pub const CTL_P1003_1B_MAXID: c_int = 26; + +pub const MSG_NOTIFICATION: c_int = 0x00002000; +pub const MSG_NBIO: c_int = 0x00004000; +pub const MSG_COMPAT: c_int = 0x00008000; +pub const MSG_CMSG_CLOEXEC: c_int = 0x00040000; +pub const MSG_NOSIGNAL: c_int = 0x20000; +pub const MSG_WAITFORONE: c_int = 0x00080000; + +// utmpx entry types +pub const EMPTY: c_short = 0; +pub const BOOT_TIME: c_short = 1; +pub const OLD_TIME: c_short = 2; +pub const NEW_TIME: c_short = 3; +pub const USER_PROCESS: c_short = 4; +pub const INIT_PROCESS: c_short = 5; +pub const LOGIN_PROCESS: c_short = 6; +pub const DEAD_PROCESS: c_short = 7; +pub const SHUTDOWN_TIME: c_short = 8; +// utmp database types +pub const UTXDB_ACTIVE: c_int = 0; +pub const UTXDB_LASTLOGIN: c_int = 1; +pub const UTXDB_LOG: c_int = 2; + +pub const LC_COLLATE_MASK: c_int = 1 << 0; +pub const LC_CTYPE_MASK: c_int = 1 << 1; +pub const LC_MONETARY_MASK: c_int = 1 << 2; +pub const LC_NUMERIC_MASK: c_int = 1 << 3; +pub const LC_TIME_MASK: c_int = 1 << 4; +pub const LC_MESSAGES_MASK: c_int = 1 << 5; +pub const LC_ALL_MASK: c_int = LC_COLLATE_MASK + | LC_CTYPE_MASK + | LC_MESSAGES_MASK + | LC_MONETARY_MASK + | LC_NUMERIC_MASK + | LC_TIME_MASK; + +pub const WSTOPPED: c_int = 2; // same as WUNTRACED +pub const WCONTINUED: c_int = 4; +pub const WNOWAIT: c_int = 8; +pub const WEXITED: c_int = 16; +pub const WTRAPPED: c_int = 32; + +// FreeBSD defines a great many more of these, we only expose the +// standardized ones. +pub const P_PID: idtype_t = 0; +pub const P_PGID: idtype_t = 2; +pub const P_ALL: idtype_t = 7; + +pub const UTIME_OMIT: c_long = -2; +pub const UTIME_NOW: c_long = -1; + +pub const B460800: crate::speed_t = 460800; +pub const B921600: crate::speed_t = 921600; + +pub const AT_FDCWD: c_int = -100; +pub const AT_EACCESS: c_int = 0x100; +pub const AT_SYMLINK_NOFOLLOW: c_int = 0x200; +pub const AT_SYMLINK_FOLLOW: c_int = 0x400; +pub const AT_REMOVEDIR: c_int = 0x800; +pub const AT_RESOLVE_BENEATH: c_int = 0x2000; +pub const AT_EMPTY_PATH: c_int = 0x4000; + +pub const AT_NULL: c_int = 0; +pub const AT_IGNORE: c_int = 1; +pub const AT_EXECFD: c_int = 2; +pub const AT_PHDR: c_int = 3; +pub const AT_PHENT: c_int = 4; +pub const AT_PHNUM: c_int = 5; +pub const AT_PAGESZ: c_int = 6; +pub const AT_BASE: c_int = 7; +pub const AT_FLAGS: c_int = 8; +pub const AT_ENTRY: c_int = 9; +pub const AT_NOTELF: c_int = 10; +pub const AT_UID: c_int = 11; +pub const AT_EUID: c_int = 12; +pub const AT_GID: c_int = 13; +pub const AT_EGID: c_int = 14; +pub const AT_EXECPATH: c_int = 15; +pub const AT_CANARY: c_int = 16; +pub const AT_OSRELDATE: c_int = 18; +pub const AT_NCPUS: c_int = 19; +pub const AT_PAGESIZES: c_int = 20; +pub const AT_TIMEKEEP: c_int = 22; +pub const AT_HWCAP: c_int = 25; +pub const AT_HWCAP2: c_int = 26; +pub const AT_USRSTACKBASE: c_int = 35; +pub const AT_USRSTACKLIM: c_int = 36; +pub const AT_HWCAP3: c_int = 38; +pub const AT_HWCAP4: c_int = 39; + +pub const TABDLY: crate::tcflag_t = 0x00000004; +pub const TAB0: crate::tcflag_t = 0x00000000; +pub const TAB3: crate::tcflag_t = 0x00000004; + +pub const _PC_ACL_NFS4: c_int = 64; + +pub const _SC_CPUSET_SIZE: c_int = 122; + +pub const _UUID_NODE_LEN: usize = 6; + +// Flags which can be passed to pdfork(2) +pub const PD_DAEMON: c_int = 0x00000001; +pub const PD_CLOEXEC: c_int = 0x00000002; +pub const PD_ALLOWED_AT_FORK: c_int = PD_DAEMON | PD_CLOEXEC; + +// Values for struct rtprio (type_ field) +pub const RTP_PRIO_REALTIME: c_ushort = 2; +pub const RTP_PRIO_NORMAL: c_ushort = 3; +pub const RTP_PRIO_IDLE: c_ushort = 4; + +// Flags for chflags(2) +pub const UF_SYSTEM: c_ulong = 0x00000080; +pub const UF_SPARSE: c_ulong = 0x00000100; +pub const UF_OFFLINE: c_ulong = 0x00000200; +pub const UF_REPARSE: c_ulong = 0x00000400; +pub const UF_ARCHIVE: c_ulong = 0x00000800; +pub const UF_READONLY: c_ulong = 0x00001000; +pub const UF_HIDDEN: c_ulong = 0x00008000; +pub const SF_SNAPSHOT: c_ulong = 0x00200000; + +// fcntl commands +pub const F_ADD_SEALS: c_int = 19; +pub const F_GET_SEALS: c_int = 20; +pub const F_OGETLK: c_int = 7; +pub const F_OSETLK: c_int = 8; +pub const F_OSETLKW: c_int = 9; +pub const F_RDAHEAD: c_int = 16; +pub const F_READAHEAD: c_int = 15; +pub const F_SETLK_REMOTE: c_int = 14; +pub const F_KINFO: c_int = 22; + +// for use with F_ADD_SEALS +pub const F_SEAL_GROW: c_int = 4; +pub const F_SEAL_SEAL: c_int = 1; +pub const F_SEAL_SHRINK: c_int = 2; +pub const F_SEAL_WRITE: c_int = 8; + +// for use with fspacectl +pub const SPACECTL_DEALLOC: c_int = 1; + +// For realhostname* api +pub const HOSTNAME_FOUND: c_int = 0; +pub const HOSTNAME_INCORRECTNAME: c_int = 1; +pub const HOSTNAME_INVALIDADDR: c_int = 2; +pub const HOSTNAME_INVALIDNAME: c_int = 3; + +// For rfork +pub const RFFDG: c_int = 4; +pub const RFPROC: c_int = 16; +pub const RFMEM: c_int = 32; +pub const RFNOWAIT: c_int = 64; +pub const RFCFDG: c_int = 4096; +pub const RFTHREAD: c_int = 8192; +pub const RFSIGSHARE: c_int = 16384; +pub const RFLINUXTHPN: c_int = 65536; +pub const RFTSIGZMB: c_int = 524288; +pub const RFSPAWN: c_int = 2147483648; + +// For eventfd +pub const EFD_SEMAPHORE: c_int = 0x1; +pub const EFD_NONBLOCK: c_int = 0x4; +pub const EFD_CLOEXEC: c_int = 0x100000; + +pub const MALLOCX_ZERO: c_int = 0x40; + +/// size of returned wchan message +pub const WMESGLEN: usize = 8; +/// size of returned lock name +pub const LOCKNAMELEN: usize = 8; +/// size of returned thread name +pub const TDNAMLEN: usize = 16; +/// size of returned ki_comm name +pub const COMMLEN: usize = 19; +/// size of returned ki_emul +pub const KI_EMULNAMELEN: usize = 16; +/// number of groups in ki_groups +pub const KI_NGROUPS: usize = 16; +cfg_if! { + if #[cfg(freebsd11)] { + pub const KI_NSPARE_INT: usize = 4; + } else { + pub const KI_NSPARE_INT: usize = 2; + } +} +pub const KI_NSPARE_LONG: usize = 12; +/// Flags for the process credential. +pub const KI_CRF_CAPABILITY_MODE: usize = 0x00000001; +/// Steal a bit from ki_cr_flags to indicate that the cred had more than +/// KI_NGROUPS groups. +pub const KI_CRF_GRP_OVERFLOW: usize = 0x80000000; +/// controlling tty vnode active +pub const KI_CTTY: usize = 0x00000001; +/// session leader +pub const KI_SLEADER: usize = 0x00000002; +/// proc blocked on lock ki_lockname +pub const KI_LOCKBLOCK: usize = 0x00000004; +/// size of returned ki_login +pub const LOGNAMELEN: usize = 17; +/// size of returned ki_loginclass +pub const LOGINCLASSLEN: usize = 17; + +pub const KF_ATTR_VALID: c_int = 0x0001; +pub const KF_TYPE_NONE: c_int = 0; +pub const KF_TYPE_VNODE: c_int = 1; +pub const KF_TYPE_SOCKET: c_int = 2; +pub const KF_TYPE_PIPE: c_int = 3; +pub const KF_TYPE_FIFO: c_int = 4; +pub const KF_TYPE_KQUEUE: c_int = 5; +pub const KF_TYPE_MQUEUE: c_int = 7; +pub const KF_TYPE_SHM: c_int = 8; +pub const KF_TYPE_SEM: c_int = 9; +pub const KF_TYPE_PTS: c_int = 10; +pub const KF_TYPE_PROCDESC: c_int = 11; +pub const KF_TYPE_DEV: c_int = 12; +pub const KF_TYPE_UNKNOWN: c_int = 255; + +pub const KF_VTYPE_VNON: c_int = 0; +pub const KF_VTYPE_VREG: c_int = 1; +pub const KF_VTYPE_VDIR: c_int = 2; +pub const KF_VTYPE_VBLK: c_int = 3; +pub const KF_VTYPE_VCHR: c_int = 4; +pub const KF_VTYPE_VLNK: c_int = 5; +pub const KF_VTYPE_VSOCK: c_int = 6; +pub const KF_VTYPE_VFIFO: c_int = 7; +pub const KF_VTYPE_VBAD: c_int = 8; +pub const KF_VTYPE_UNKNOWN: c_int = 255; + +/// Current working directory +pub const KF_FD_TYPE_CWD: c_int = -1; +/// Root directory +pub const KF_FD_TYPE_ROOT: c_int = -2; +/// Jail directory +pub const KF_FD_TYPE_JAIL: c_int = -3; +/// Ktrace vnode +pub const KF_FD_TYPE_TRACE: c_int = -4; +pub const KF_FD_TYPE_TEXT: c_int = -5; +/// Controlling terminal +pub const KF_FD_TYPE_CTTY: c_int = -6; +pub const KF_FLAG_READ: c_int = 0x00000001; +pub const KF_FLAG_WRITE: c_int = 0x00000002; +pub const KF_FLAG_APPEND: c_int = 0x00000004; +pub const KF_FLAG_ASYNC: c_int = 0x00000008; +pub const KF_FLAG_FSYNC: c_int = 0x00000010; +pub const KF_FLAG_NONBLOCK: c_int = 0x00000020; +pub const KF_FLAG_DIRECT: c_int = 0x00000040; +pub const KF_FLAG_HASLOCK: c_int = 0x00000080; +pub const KF_FLAG_SHLOCK: c_int = 0x00000100; +pub const KF_FLAG_EXLOCK: c_int = 0x00000200; +pub const KF_FLAG_NOFOLLOW: c_int = 0x00000400; +pub const KF_FLAG_CREAT: c_int = 0x00000800; +pub const KF_FLAG_TRUNC: c_int = 0x00001000; +pub const KF_FLAG_EXCL: c_int = 0x00002000; +pub const KF_FLAG_EXEC: c_int = 0x00004000; + +pub const KVME_TYPE_NONE: c_int = 0; +pub const KVME_TYPE_DEFAULT: c_int = 1; +pub const KVME_TYPE_VNODE: c_int = 2; +pub const KVME_TYPE_SWAP: c_int = 3; +pub const KVME_TYPE_DEVICE: c_int = 4; +pub const KVME_TYPE_PHYS: c_int = 5; +pub const KVME_TYPE_DEAD: c_int = 6; +pub const KVME_TYPE_SG: c_int = 7; +pub const KVME_TYPE_MGTDEVICE: c_int = 8; +// Present in `sys/user.h` but is undefined for whatever reason... +// pub const KVME_TYPE_GUARD: c_int = 9; +pub const KVME_TYPE_UNKNOWN: c_int = 255; +pub const KVME_PROT_READ: c_int = 0x00000001; +pub const KVME_PROT_WRITE: c_int = 0x00000002; +pub const KVME_PROT_EXEC: c_int = 0x00000004; +pub const KVME_FLAG_COW: c_int = 0x00000001; +pub const KVME_FLAG_NEEDS_COPY: c_int = 0x00000002; +pub const KVME_FLAG_NOCOREDUMP: c_int = 0x00000004; +pub const KVME_FLAG_SUPER: c_int = 0x00000008; +pub const KVME_FLAG_GROWS_UP: c_int = 0x00000010; +pub const KVME_FLAG_GROWS_DOWN: c_int = 0x00000020; +pub const KVME_FLAG_USER_WIRED: c_int = 0x00000040; + +pub const KKST_MAXLEN: c_int = 1024; +/// Stack is valid. +pub const KKST_STATE_STACKOK: c_int = 0; +/// Stack swapped out. +pub const KKST_STATE_SWAPPED: c_int = 1; +pub const KKST_STATE_RUNNING: c_int = 2; + +// Constants about priority. +pub const PRI_MIN: c_int = 0; +pub const PRI_MAX: c_int = 255; +pub const PRI_MIN_ITHD: c_int = PRI_MIN; +#[deprecated(since = "0.2.133", note = "Not stable across OS versions")] +#[allow(deprecated)] +pub const PRI_MAX_ITHD: c_int = PRI_MIN_REALTIME - 1; +pub const PI_REALTIME: c_int = PRI_MIN_ITHD + 0; +#[deprecated(since = "0.2.133", note = "Not stable across OS versions")] +pub const PI_AV: c_int = PRI_MIN_ITHD + 4; +#[deprecated(since = "0.2.133", note = "Not stable across OS versions")] +pub const PI_NET: c_int = PRI_MIN_ITHD + 8; +#[deprecated(since = "0.2.133", note = "Not stable across OS versions")] +pub const PI_DISK: c_int = PRI_MIN_ITHD + 12; +#[deprecated(since = "0.2.133", note = "Not stable across OS versions")] +pub const PI_TTY: c_int = PRI_MIN_ITHD + 16; +#[deprecated(since = "0.2.133", note = "Not stable across OS versions")] +pub const PI_DULL: c_int = PRI_MIN_ITHD + 20; +#[deprecated(since = "0.2.133", note = "Not stable across OS versions")] +pub const PI_SOFT: c_int = PRI_MIN_ITHD + 24; +#[deprecated(since = "0.2.133", note = "Not stable across OS versions")] +pub const PRI_MIN_REALTIME: c_int = 48; +#[deprecated(since = "0.2.133", note = "Not stable across OS versions")] +#[allow(deprecated)] +pub const PRI_MAX_REALTIME: c_int = PRI_MIN_KERN - 1; +#[deprecated(since = "0.2.133", note = "Not stable across OS versions")] +pub const PRI_MIN_KERN: c_int = 80; +#[deprecated(since = "0.2.133", note = "Not stable across OS versions")] +#[allow(deprecated)] +pub const PRI_MAX_KERN: c_int = PRI_MIN_TIMESHARE - 1; +#[deprecated(since = "0.2.133", note = "Not stable across OS versions")] +#[allow(deprecated)] +pub const PSWP: c_int = PRI_MIN_KERN + 0; +#[deprecated(since = "0.2.133", note = "Not stable across OS versions")] +#[allow(deprecated)] +pub const PVM: c_int = PRI_MIN_KERN + 4; +#[deprecated(since = "0.2.133", note = "Not stable across OS versions")] +#[allow(deprecated)] +pub const PINOD: c_int = PRI_MIN_KERN + 8; +#[deprecated(since = "0.2.133", note = "Not stable across OS versions")] +#[allow(deprecated)] +pub const PRIBIO: c_int = PRI_MIN_KERN + 12; +#[deprecated(since = "0.2.133", note = "Not stable across OS versions")] +#[allow(deprecated)] +pub const PVFS: c_int = PRI_MIN_KERN + 16; +#[deprecated(since = "0.2.133", note = "Not stable across OS versions")] +#[allow(deprecated)] +pub const PZERO: c_int = PRI_MIN_KERN + 20; +#[deprecated(since = "0.2.133", note = "Not stable across OS versions")] +#[allow(deprecated)] +pub const PSOCK: c_int = PRI_MIN_KERN + 24; +#[deprecated(since = "0.2.133", note = "Not stable across OS versions")] +#[allow(deprecated)] +pub const PWAIT: c_int = PRI_MIN_KERN + 28; +#[deprecated(since = "0.2.133", note = "Not stable across OS versions")] +#[allow(deprecated)] +pub const PLOCK: c_int = PRI_MIN_KERN + 32; +#[deprecated(since = "0.2.133", note = "Not stable across OS versions")] +#[allow(deprecated)] +pub const PPAUSE: c_int = PRI_MIN_KERN + 36; +#[deprecated(since = "0.2.133", note = "Not stable across OS versions")] +pub const PRI_MIN_TIMESHARE: c_int = 120; +pub const PRI_MAX_TIMESHARE: c_int = PRI_MIN_IDLE - 1; +#[deprecated(since = "0.2.133", note = "Not stable across OS versions")] +#[allow(deprecated)] +pub const PUSER: c_int = PRI_MIN_TIMESHARE; +pub const PRI_MIN_IDLE: c_int = 224; +pub const PRI_MAX_IDLE: c_int = PRI_MAX; + +pub const NZERO: c_int = 0; + +// Resource utilization information. +pub const RUSAGE_THREAD: c_int = 1; + +cfg_if! { + if #[cfg(any(freebsd11, target_pointer_width = "32"))] { + pub const ARG_MAX: c_int = 256 * 1024; + } else { + pub const ARG_MAX: c_int = 2 * 256 * 1024; + } +} +pub const CHILD_MAX: c_int = 40; +/// max command name remembered +pub const MAXCOMLEN: usize = 19; +/// max interpreter file name length +pub const MAXINTERP: c_int = crate::PATH_MAX; +/// max login name length (incl. NUL) +pub const MAXLOGNAME: c_int = 33; +/// max simultaneous processes +pub const MAXUPRC: c_int = CHILD_MAX; +/// max bytes for an exec function +pub const NCARGS: c_int = ARG_MAX; +/// /* max number groups +pub const NGROUPS: c_int = NGROUPS_MAX + 1; +/// max open files per process +pub const NOFILE: c_int = OPEN_MAX; +/// marker for empty group set member +pub const NOGROUP: c_int = 65535; +/// max hostname size +pub const MAXHOSTNAMELEN: c_int = 256; +/// max bytes in term canon input line +pub const MAX_CANON: c_int = 255; +/// max bytes in terminal input +pub const MAX_INPUT: c_int = 255; +/// max bytes in a file name +pub const NAME_MAX: c_int = 255; +pub const MAXSYMLINKS: c_int = 32; +/// max supplemental group id's +pub const NGROUPS_MAX: c_int = 1023; +/// max open files per process +pub const OPEN_MAX: c_int = 64; + +pub const _POSIX_ARG_MAX: c_int = 4096; +pub const _POSIX_LINK_MAX: c_int = 8; +pub const _POSIX_MAX_CANON: c_int = 255; +pub const _POSIX_MAX_INPUT: c_int = 255; +pub const _POSIX_NAME_MAX: c_int = 14; +pub const _POSIX_PIPE_BUF: c_int = 512; +pub const _POSIX_SSIZE_MAX: c_int = 32767; +pub const _POSIX_STREAM_MAX: c_int = 8; + +/// max ibase/obase values in bc(1) +pub const BC_BASE_MAX: c_int = 99; +/// max array elements in bc(1) +pub const BC_DIM_MAX: c_int = 2048; +/// max scale value in bc(1) +pub const BC_SCALE_MAX: c_int = 99; +/// max const string length in bc(1) +pub const BC_STRING_MAX: c_int = 1000; +/// max character class name size +pub const CHARCLASS_NAME_MAX: c_int = 14; +/// max weights for order keyword +pub const COLL_WEIGHTS_MAX: c_int = 10; +/// max expressions nested in expr(1) +pub const EXPR_NEST_MAX: c_int = 32; +/// max bytes in an input line +pub const LINE_MAX: c_int = 2048; +/// max RE's in interval notation +pub const RE_DUP_MAX: c_int = 255; + +pub const _POSIX2_BC_BASE_MAX: c_int = 99; +pub const _POSIX2_BC_DIM_MAX: c_int = 2048; +pub const _POSIX2_BC_SCALE_MAX: c_int = 99; +pub const _POSIX2_BC_STRING_MAX: c_int = 1000; +pub const _POSIX2_CHARCLASS_NAME_MAX: c_int = 14; +pub const _POSIX2_COLL_WEIGHTS_MAX: c_int = 2; +pub const _POSIX2_EQUIV_CLASS_MAX: c_int = 2; +pub const _POSIX2_EXPR_NEST_MAX: c_int = 32; +pub const _POSIX2_LINE_MAX: c_int = 2048; +pub const _POSIX2_RE_DUP_MAX: c_int = 255; + +// sys/proc.h +pub const TDF_BORROWING: c_int = 0x00000001; +pub const TDF_INPANIC: c_int = 0x00000002; +pub const TDF_INMEM: c_int = 0x00000004; +pub const TDF_SINTR: c_int = 0x00000008; +pub const TDF_TIMEOUT: c_int = 0x00000010; +pub const TDF_IDLETD: c_int = 0x00000020; +pub const TDF_CANSWAP: c_int = 0x00000040; +pub const TDF_KTH_SUSP: c_int = 0x00000100; +pub const TDF_ALLPROCSUSP: c_int = 0x00000200; +pub const TDF_BOUNDARY: c_int = 0x00000400; +#[deprecated(since = "0.2.133", note = "Not stable across OS versions")] +pub const TDF_ASTPENDING: c_int = 0x00000800; +pub const TDF_SBDRY: c_int = 0x00002000; +pub const TDF_UPIBLOCKED: c_int = 0x00004000; +#[deprecated(since = "0.2.133", note = "Not stable across OS versions")] +pub const TDF_NEEDSUSPCHK: c_int = 0x00008000; +#[deprecated(since = "0.2.133", note = "Not stable across OS versions")] +pub const TDF_NEEDRESCHED: c_int = 0x00010000; +#[deprecated(since = "0.2.133", note = "Not stable across OS versions")] +pub const TDF_NEEDSIGCHK: c_int = 0x00020000; +pub const TDF_NOLOAD: c_int = 0x00040000; +pub const TDF_SERESTART: c_int = 0x00080000; +pub const TDF_THRWAKEUP: c_int = 0x00100000; +pub const TDF_SEINTR: c_int = 0x00200000; +pub const TDF_SWAPINREQ: c_int = 0x00400000; +#[deprecated(since = "0.2.133", note = "Removed in FreeBSD 14")] +pub const TDF_UNUSED23: c_int = 0x00800000; +pub const TDF_SCHED0: c_int = 0x01000000; +pub const TDF_SCHED1: c_int = 0x02000000; +pub const TDF_SCHED2: c_int = 0x04000000; +pub const TDF_SCHED3: c_int = 0x08000000; +#[deprecated(since = "0.2.133", note = "Not stable across OS versions")] +pub const TDF_ALRMPEND: c_int = 0x10000000; +#[deprecated(since = "0.2.133", note = "Not stable across OS versions")] +pub const TDF_PROFPEND: c_int = 0x20000000; +#[deprecated(since = "0.2.133", note = "Not stable across OS versions")] +pub const TDF_MACPEND: c_int = 0x40000000; + +pub const TDB_SUSPEND: c_int = 0x00000001; +pub const TDB_XSIG: c_int = 0x00000002; +pub const TDB_USERWR: c_int = 0x00000004; +pub const TDB_SCE: c_int = 0x00000008; +pub const TDB_SCX: c_int = 0x00000010; +pub const TDB_EXEC: c_int = 0x00000020; +pub const TDB_FORK: c_int = 0x00000040; +pub const TDB_STOPATFORK: c_int = 0x00000080; +pub const TDB_CHILD: c_int = 0x00000100; +pub const TDB_BORN: c_int = 0x00000200; +pub const TDB_EXIT: c_int = 0x00000400; +pub const TDB_VFORK: c_int = 0x00000800; +pub const TDB_FSTP: c_int = 0x00001000; +pub const TDB_STEP: c_int = 0x00002000; + +pub const TDP_OLDMASK: c_int = 0x00000001; +pub const TDP_INKTR: c_int = 0x00000002; +pub const TDP_INKTRACE: c_int = 0x00000004; +pub const TDP_BUFNEED: c_int = 0x00000008; +pub const TDP_COWINPROGRESS: c_int = 0x00000010; +pub const TDP_ALTSTACK: c_int = 0x00000020; +pub const TDP_DEADLKTREAT: c_int = 0x00000040; +pub const TDP_NOFAULTING: c_int = 0x00000080; +pub const TDP_OWEUPC: c_int = 0x00000200; +pub const TDP_ITHREAD: c_int = 0x00000400; +pub const TDP_SYNCIO: c_int = 0x00000800; +pub const TDP_SCHED1: c_int = 0x00001000; +pub const TDP_SCHED2: c_int = 0x00002000; +pub const TDP_SCHED3: c_int = 0x00004000; +pub const TDP_SCHED4: c_int = 0x00008000; +pub const TDP_GEOM: c_int = 0x00010000; +pub const TDP_SOFTDEP: c_int = 0x00020000; +pub const TDP_NORUNNINGBUF: c_int = 0x00040000; +pub const TDP_WAKEUP: c_int = 0x00080000; +pub const TDP_INBDFLUSH: c_int = 0x00100000; +pub const TDP_KTHREAD: c_int = 0x00200000; +pub const TDP_CALLCHAIN: c_int = 0x00400000; +pub const TDP_IGNSUSP: c_int = 0x00800000; +pub const TDP_AUDITREC: c_int = 0x01000000; +pub const TDP_RFPPWAIT: c_int = 0x02000000; +pub const TDP_RESETSPUR: c_int = 0x04000000; +pub const TDP_NERRNO: c_int = 0x08000000; +pub const TDP_EXECVMSPC: c_int = 0x40000000; + +pub const TDI_SUSPENDED: c_int = 0x0001; +pub const TDI_SLEEPING: c_int = 0x0002; +pub const TDI_SWAPPED: c_int = 0x0004; +pub const TDI_LOCK: c_int = 0x0008; +pub const TDI_IWAIT: c_int = 0x0010; + +pub const P_ADVLOCK: c_int = 0x00000001; +pub const P_CONTROLT: c_int = 0x00000002; +pub const P_KPROC: c_int = 0x00000004; +#[deprecated(since = "1.0", note = "Replaced in FreeBSD 15 by P_IDLEPROC")] +pub const P_UNUSED3: c_int = 0x00000008; +#[cfg(freebsd15)] +pub const P_IDLEPROC: c_int = 0x00000008; +pub const P_PPWAIT: c_int = 0x00000010; +pub const P_PROFIL: c_int = 0x00000020; +pub const P_STOPPROF: c_int = 0x00000040; +pub const P_HADTHREADS: c_int = 0x00000080; +pub const P_SUGID: c_int = 0x00000100; +pub const P_SYSTEM: c_int = 0x00000200; +pub const P_SINGLE_EXIT: c_int = 0x00000400; +pub const P_TRACED: c_int = 0x00000800; +pub const P_WAITED: c_int = 0x00001000; +pub const P_WEXIT: c_int = 0x00002000; +pub const P_EXEC: c_int = 0x00004000; +pub const P_WKILLED: c_int = 0x00008000; +pub const P_CONTINUED: c_int = 0x00010000; +pub const P_STOPPED_SIG: c_int = 0x00020000; +pub const P_STOPPED_TRACE: c_int = 0x00040000; +pub const P_STOPPED_SINGLE: c_int = 0x00080000; +pub const P_PROTECTED: c_int = 0x00100000; +pub const P_SIGEVENT: c_int = 0x00200000; +pub const P_SINGLE_BOUNDARY: c_int = 0x00400000; +pub const P_HWPMC: c_int = 0x00800000; +pub const P_JAILED: c_int = 0x01000000; +pub const P_TOTAL_STOP: c_int = 0x02000000; +pub const P_INEXEC: c_int = 0x04000000; +pub const P_STATCHILD: c_int = 0x08000000; +pub const P_INMEM: c_int = 0x10000000; +pub const P_SWAPPINGOUT: c_int = 0x20000000; +pub const P_SWAPPINGIN: c_int = 0x40000000; +pub const P_PPTRACE: c_int = 0x80000000; +pub const P_STOPPED: c_int = P_STOPPED_SIG | P_STOPPED_SINGLE | P_STOPPED_TRACE; + +pub const P2_INHERIT_PROTECTED: c_int = 0x00000001; +pub const P2_NOTRACE: c_int = 0x00000002; +pub const P2_NOTRACE_EXEC: c_int = 0x00000004; +pub const P2_AST_SU: c_int = 0x00000008; +pub const P2_PTRACE_FSTP: c_int = 0x00000010; +pub const P2_TRAPCAP: c_int = 0x00000020; +pub const P2_STKGAP_DISABLE: c_int = 0x00000800; +pub const P2_STKGAP_DISABLE_EXEC: c_int = 0x00001000; + +pub const P_TREE_ORPHANED: c_int = 0x00000001; +pub const P_TREE_FIRST_ORPHAN: c_int = 0x00000002; +pub const P_TREE_REAPER: c_int = 0x00000004; + +pub const SIDL: c_char = 1; +pub const SRUN: c_char = 2; +pub const SSLEEP: c_char = 3; +pub const SSTOP: c_char = 4; +pub const SZOMB: c_char = 5; +pub const SWAIT: c_char = 6; +pub const SLOCK: c_char = 7; + +pub const P_MAGIC: c_int = 0xbeefface; + +pub const TDP_SIGFASTBLOCK: c_int = 0x00000100; +pub const TDP_UIOHELD: c_int = 0x10000000; +pub const TDP_SIGFASTPENDING: c_int = 0x80000000; +pub const TDP2_COMPAT32RB: c_int = 0x00000002; +pub const P2_PROTMAX_ENABLE: c_int = 0x00000200; +pub const P2_PROTMAX_DISABLE: c_int = 0x00000400; +pub const TDP2_SBPAGES: c_int = 0x00000001; +pub const P2_ASLR_ENABLE: c_int = 0x00000040; +pub const P2_ASLR_DISABLE: c_int = 0x00000080; +pub const P2_ASLR_IGNSTART: c_int = 0x00000100; +pub const P_TREE_GRPEXITED: c_int = 0x00000008; + +// libprocstat.h +pub const PS_FST_VTYPE_VNON: c_int = 1; +pub const PS_FST_VTYPE_VREG: c_int = 2; +pub const PS_FST_VTYPE_VDIR: c_int = 3; +pub const PS_FST_VTYPE_VBLK: c_int = 4; +pub const PS_FST_VTYPE_VCHR: c_int = 5; +pub const PS_FST_VTYPE_VLNK: c_int = 6; +pub const PS_FST_VTYPE_VSOCK: c_int = 7; +pub const PS_FST_VTYPE_VFIFO: c_int = 8; +pub const PS_FST_VTYPE_VBAD: c_int = 9; +pub const PS_FST_VTYPE_UNKNOWN: c_int = 255; + +pub const PS_FST_TYPE_VNODE: c_int = 1; +pub const PS_FST_TYPE_FIFO: c_int = 2; +pub const PS_FST_TYPE_SOCKET: c_int = 3; +pub const PS_FST_TYPE_PIPE: c_int = 4; +pub const PS_FST_TYPE_PTS: c_int = 5; +pub const PS_FST_TYPE_KQUEUE: c_int = 6; +pub const PS_FST_TYPE_MQUEUE: c_int = 8; +pub const PS_FST_TYPE_SHM: c_int = 9; +pub const PS_FST_TYPE_SEM: c_int = 10; +pub const PS_FST_TYPE_UNKNOWN: c_int = 11; +pub const PS_FST_TYPE_NONE: c_int = 12; +pub const PS_FST_TYPE_PROCDESC: c_int = 13; +pub const PS_FST_TYPE_DEV: c_int = 14; +pub const PS_FST_TYPE_EVENTFD: c_int = 15; + +pub const PS_FST_UFLAG_RDIR: c_int = 0x0001; +pub const PS_FST_UFLAG_CDIR: c_int = 0x0002; +pub const PS_FST_UFLAG_JAIL: c_int = 0x0004; +pub const PS_FST_UFLAG_TRACE: c_int = 0x0008; +pub const PS_FST_UFLAG_TEXT: c_int = 0x0010; +pub const PS_FST_UFLAG_MMAP: c_int = 0x0020; +pub const PS_FST_UFLAG_CTTY: c_int = 0x0040; + +pub const PS_FST_FFLAG_READ: c_int = 0x0001; +pub const PS_FST_FFLAG_WRITE: c_int = 0x0002; +pub const PS_FST_FFLAG_NONBLOCK: c_int = 0x0004; +pub const PS_FST_FFLAG_APPEND: c_int = 0x0008; +pub const PS_FST_FFLAG_SHLOCK: c_int = 0x0010; +pub const PS_FST_FFLAG_EXLOCK: c_int = 0x0020; +pub const PS_FST_FFLAG_ASYNC: c_int = 0x0040; +pub const PS_FST_FFLAG_SYNC: c_int = 0x0080; +pub const PS_FST_FFLAG_NOFOLLOW: c_int = 0x0100; +pub const PS_FST_FFLAG_CREAT: c_int = 0x0200; +pub const PS_FST_FFLAG_TRUNC: c_int = 0x0400; +pub const PS_FST_FFLAG_EXCL: c_int = 0x0800; +pub const PS_FST_FFLAG_DIRECT: c_int = 0x1000; +pub const PS_FST_FFLAG_EXEC: c_int = 0x2000; +pub const PS_FST_FFLAG_HASLOCK: c_int = 0x4000; + +// sys/mount.h + +/// File identifier. +/// These are unique per filesystem on a single machine. +/// +/// Note that the offset of fid_data is 4 bytes, so care must be taken to avoid +/// undefined behavior accessing unaligned fields within an embedded struct. +pub const MAXFIDSZ: c_int = 16; +/// Length of type name including null. +pub const MFSNAMELEN: c_int = 16; +cfg_if! { + if #[cfg(any(freebsd10, freebsd11))] { + /// Size of on/from name bufs. + pub const MNAMELEN: c_int = 88; + } else { + /// Size of on/from name bufs. + pub const MNAMELEN: c_int = 1024; + } +} + +/// Using journaled soft updates. +pub const MNT_SUJ: u64 = 0x100000000; +/// Mounted by automountd(8). +pub const MNT_AUTOMOUNTED: u64 = 0x200000000; +/// Filesys metadata untrusted. +pub const MNT_UNTRUSTED: u64 = 0x800000000; + +/// Require TLS. +pub const MNT_EXTLS: u64 = 0x4000000000; +/// Require TLS with client cert. +pub const MNT_EXTLSCERT: u64 = 0x8000000000; +/// Require TLS with user cert. +pub const MNT_EXTLSCERTUSER: u64 = 0x10000000000; + +/// Filesystem is stored locally. +pub const MNT_LOCAL: u64 = 0x000001000; +/// Quotas are enabled on fs. +pub const MNT_QUOTA: u64 = 0x000002000; +/// Identifies the root fs. +pub const MNT_ROOTFS: u64 = 0x000004000; +/// Mounted by a user. +pub const MNT_USER: u64 = 0x000008000; +/// Do not show entry in df. +pub const MNT_IGNORE: u64 = 0x000800000; +/// Filesystem is verified. +pub const MNT_VERIFIED: u64 = 0x400000000; + +/// Do not cover a mount point. +pub const MNT_NOCOVER: u64 = 0x001000000000; +/// Only mount on empty dir. +pub const MNT_EMPTYDIR: u64 = 0x002000000000; +/// Recursively unmount uppers. +pub const MNT_RECURSE: u64 = 0x100000000000; +/// Unmount in async context. +pub const MNT_DEFERRED: u64 = 0x200000000000; + +/// Get configured filesystems. +pub const VFS_VFSCONF: c_int = 0; +/// Generic filesystem information. +pub const VFS_GENERIC: c_int = 0; + +/// int: highest defined filesystem type. +pub const VFS_MAXTYPENUM: c_int = 1; +/// struct: vfsconf for filesystem given as next argument. +pub const VFS_CONF: c_int = 2; + +/// Synchronously wait for I/O to complete. +pub const MNT_WAIT: c_int = 1; +/// Start all I/O, but do not wait for it. +pub const MNT_NOWAIT: c_int = 2; +/// Push data not written by filesystem syncer. +pub const MNT_LAZY: c_int = 3; +/// Suspend file system after sync. +pub const MNT_SUSPEND: c_int = 4; + +pub const MAXSECFLAVORS: c_int = 5; + +/// Statically compiled into kernel. +pub const VFCF_STATIC: c_int = 0x00010000; +/// May get data over the network. +pub const VFCF_NETWORK: c_int = 0x00020000; +/// Writes are not implemented. +pub const VFCF_READONLY: c_int = 0x00040000; +/// Data does not represent real files. +pub const VFCF_SYNTHETIC: c_int = 0x00080000; +/// Aliases some other mounted FS. +pub const VFCF_LOOPBACK: c_int = 0x00100000; +/// Stores file names as Unicode. +pub const VFCF_UNICODE: c_int = 0x00200000; +/// Can be mounted from within a jail. +pub const VFCF_JAIL: c_int = 0x00400000; +/// Supports delegated administration. +pub const VFCF_DELEGADMIN: c_int = 0x00800000; +/// Stop at Boundary: defer stop requests to kernel->user (AST) transition. +pub const VFCF_SBDRY: c_int = 0x01000000; + +// time.h + +/// not on dst +pub const DST_NONE: c_int = 0; +/// USA style dst +pub const DST_USA: c_int = 1; +/// Australian style dst +pub const DST_AUST: c_int = 2; +/// Western European dst +pub const DST_WET: c_int = 3; +/// Middle European dst +pub const DST_MET: c_int = 4; +/// Eastern European dst +pub const DST_EET: c_int = 5; +/// Canada +pub const DST_CAN: c_int = 6; + +pub const CPUCLOCK_WHICH_PID: c_int = 0; +pub const CPUCLOCK_WHICH_TID: c_int = 1; + +pub const MFD_CLOEXEC: c_uint = 0x00000001; +pub const MFD_ALLOW_SEALING: c_uint = 0x00000002; +pub const MFD_HUGETLB: c_uint = 0x00000004; +pub const MFD_HUGE_MASK: c_uint = 0xFC000000; +pub const MFD_HUGE_64KB: c_uint = 16 << 26; +pub const MFD_HUGE_512KB: c_uint = 19 << 26; +pub const MFD_HUGE_1MB: c_uint = 20 << 26; +pub const MFD_HUGE_2MB: c_uint = 21 << 26; +pub const MFD_HUGE_8MB: c_uint = 23 << 26; +pub const MFD_HUGE_16MB: c_uint = 24 << 26; +pub const MFD_HUGE_32MB: c_uint = 25 << 26; +pub const MFD_HUGE_256MB: c_uint = 28 << 26; +pub const MFD_HUGE_512MB: c_uint = 29 << 26; +pub const MFD_HUGE_1GB: c_uint = 30 << 26; +pub const MFD_HUGE_2GB: c_uint = 31 << 26; +pub const MFD_HUGE_16GB: c_uint = 34 << 26; + +pub const SHM_LARGEPAGE_ALLOC_DEFAULT: c_int = 0; +pub const SHM_LARGEPAGE_ALLOC_NOWAIT: c_int = 1; +pub const SHM_LARGEPAGE_ALLOC_HARD: c_int = 2; +pub const SHM_RENAME_NOREPLACE: c_int = 1 << 0; +pub const SHM_RENAME_EXCHANGE: c_int = 1 << 1; + +// sys/umtx.h + +pub const UMTX_OP_WAIT: c_int = 2; +pub const UMTX_OP_WAKE: c_int = 3; +pub const UMTX_OP_MUTEX_TRYLOCK: c_int = 4; +pub const UMTX_OP_MUTEX_LOCK: c_int = 5; +pub const UMTX_OP_MUTEX_UNLOCK: c_int = 6; +pub const UMTX_OP_SET_CEILING: c_int = 7; +pub const UMTX_OP_CV_WAIT: c_int = 8; +pub const UMTX_OP_CV_SIGNAL: c_int = 9; +pub const UMTX_OP_CV_BROADCAST: c_int = 10; +pub const UMTX_OP_WAIT_UINT: c_int = 11; +pub const UMTX_OP_RW_RDLOCK: c_int = 12; +pub const UMTX_OP_RW_WRLOCK: c_int = 13; +pub const UMTX_OP_RW_UNLOCK: c_int = 14; +pub const UMTX_OP_WAIT_UINT_PRIVATE: c_int = 15; +pub const UMTX_OP_WAKE_PRIVATE: c_int = 16; +pub const UMTX_OP_MUTEX_WAIT: c_int = 17; +pub const UMTX_OP_NWAKE_PRIVATE: c_int = 21; +pub const UMTX_OP_MUTEX_WAKE2: c_int = 22; +pub const UMTX_OP_SEM2_WAIT: c_int = 23; +pub const UMTX_OP_SEM2_WAKE: c_int = 24; +pub const UMTX_OP_SHM: c_int = 25; +pub const UMTX_OP_ROBUST_LISTS: c_int = 26; + +pub const UMTX_ABSTIME: u32 = 1; + +pub const CPU_LEVEL_ROOT: c_int = 1; +pub const CPU_LEVEL_CPUSET: c_int = 2; +pub const CPU_LEVEL_WHICH: c_int = 3; + +pub const CPU_WHICH_TID: c_int = 1; +pub const CPU_WHICH_PID: c_int = 2; +pub const CPU_WHICH_CPUSET: c_int = 3; +pub const CPU_WHICH_IRQ: c_int = 4; +pub const CPU_WHICH_JAIL: c_int = 5; + +// net/route.h +pub const RTF_LLDATA: c_int = 0x400; +pub const RTF_FIXEDMTU: c_int = 0x80000; + +pub const RTM_VERSION: c_int = 5; + +pub const RTAX_MAX: c_int = 8; + +// sys/signal.h +pub const SIGTHR: c_int = 32; +pub const SIGLWP: c_int = SIGTHR; +pub const SIGLIBRT: c_int = 33; + +// netinet/sctp.h +pub const SCTP_FUTURE_ASSOC: c_int = 0; +pub const SCTP_CURRENT_ASSOC: c_int = 1; +pub const SCTP_ALL_ASSOC: c_int = 2; + +pub const SCTP_NO_NEXT_MSG: c_int = 0x0000; +pub const SCTP_NEXT_MSG_AVAIL: c_int = 0x0001; +pub const SCTP_NEXT_MSG_ISCOMPLETE: c_int = 0x0002; +pub const SCTP_NEXT_MSG_IS_UNORDERED: c_int = 0x0004; +pub const SCTP_NEXT_MSG_IS_NOTIFICATION: c_int = 0x0008; + +pub const SCTP_RECVV_NOINFO: c_int = 0; +pub const SCTP_RECVV_RCVINFO: c_int = 1; +pub const SCTP_RECVV_NXTINFO: c_int = 2; +pub const SCTP_RECVV_RN: c_int = 3; + +pub const SCTP_SENDV_NOINFO: c_int = 0; +pub const SCTP_SENDV_SNDINFO: c_int = 1; +pub const SCTP_SENDV_PRINFO: c_int = 2; +pub const SCTP_SENDV_AUTHINFO: c_int = 3; +pub const SCTP_SENDV_SPA: c_int = 4; + +pub const SCTP_SEND_SNDINFO_VALID: c_int = 0x00000001; +pub const SCTP_SEND_PRINFO_VALID: c_int = 0x00000002; +pub const SCTP_SEND_AUTHINFO_VALID: c_int = 0x00000004; + +pub const SCTP_NOTIFICATION: c_int = 0x0010; +pub const SCTP_COMPLETE: c_int = 0x0020; +pub const SCTP_EOF: c_int = 0x0100; +pub const SCTP_ABORT: c_int = 0x0200; +pub const SCTP_UNORDERED: c_int = 0x0400; +pub const SCTP_ADDR_OVER: c_int = 0x0800; +pub const SCTP_SENDALL: c_int = 0x1000; +pub const SCTP_EOR: c_int = 0x2000; +pub const SCTP_SACK_IMMEDIATELY: c_int = 0x4000; +pub const SCTP_PR_SCTP_NONE: c_int = 0x0000; +pub const SCTP_PR_SCTP_TTL: c_int = 0x0001; +pub const SCTP_PR_SCTP_PRIO: c_int = 0x0002; +pub const SCTP_PR_SCTP_BUF: c_int = SCTP_PR_SCTP_PRIO; +pub const SCTP_PR_SCTP_RTX: c_int = 0x0003; +pub const SCTP_PR_SCTP_MAX: c_int = SCTP_PR_SCTP_RTX; +pub const SCTP_PR_SCTP_ALL: c_int = 0x000f; + +pub const SCTP_INIT: c_int = 0x0001; +pub const SCTP_SNDRCV: c_int = 0x0002; +pub const SCTP_EXTRCV: c_int = 0x0003; +pub const SCTP_SNDINFO: c_int = 0x0004; +pub const SCTP_RCVINFO: c_int = 0x0005; +pub const SCTP_NXTINFO: c_int = 0x0006; +pub const SCTP_PRINFO: c_int = 0x0007; +pub const SCTP_AUTHINFO: c_int = 0x0008; +pub const SCTP_DSTADDRV4: c_int = 0x0009; +pub const SCTP_DSTADDRV6: c_int = 0x000a; + +pub const SCTP_RTOINFO: c_int = 0x00000001; +pub const SCTP_ASSOCINFO: c_int = 0x00000002; +pub const SCTP_INITMSG: c_int = 0x00000003; +pub const SCTP_NODELAY: c_int = 0x00000004; +pub const SCTP_AUTOCLOSE: c_int = 0x00000005; +pub const SCTP_SET_PEER_PRIMARY_ADDR: c_int = 0x00000006; +pub const SCTP_PRIMARY_ADDR: c_int = 0x00000007; +pub const SCTP_ADAPTATION_LAYER: c_int = 0x00000008; +pub const SCTP_ADAPTION_LAYER: c_int = 0x00000008; +pub const SCTP_DISABLE_FRAGMENTS: c_int = 0x00000009; +pub const SCTP_PEER_ADDR_PARAMS: c_int = 0x0000000a; +pub const SCTP_DEFAULT_SEND_PARAM: c_int = 0x0000000b; +pub const SCTP_EVENTS: c_int = 0x0000000c; +pub const SCTP_I_WANT_MAPPED_V4_ADDR: c_int = 0x0000000d; +pub const SCTP_MAXSEG: c_int = 0x0000000e; +pub const SCTP_DELAYED_SACK: c_int = 0x0000000f; +pub const SCTP_FRAGMENT_INTERLEAVE: c_int = 0x00000010; +pub const SCTP_PARTIAL_DELIVERY_POINT: c_int = 0x00000011; +pub const SCTP_AUTH_CHUNK: c_int = 0x00000012; +pub const SCTP_AUTH_KEY: c_int = 0x00000013; +pub const SCTP_HMAC_IDENT: c_int = 0x00000014; +pub const SCTP_AUTH_ACTIVE_KEY: c_int = 0x00000015; +pub const SCTP_AUTH_DELETE_KEY: c_int = 0x00000016; +pub const SCTP_USE_EXT_RCVINFO: c_int = 0x00000017; +pub const SCTP_AUTO_ASCONF: c_int = 0x00000018; +pub const SCTP_MAXBURST: c_int = 0x00000019; +pub const SCTP_MAX_BURST: c_int = 0x00000019; +pub const SCTP_CONTEXT: c_int = 0x0000001a; +pub const SCTP_EXPLICIT_EOR: c_int = 0x00000001b; +pub const SCTP_REUSE_PORT: c_int = 0x00000001c; +pub const SCTP_AUTH_DEACTIVATE_KEY: c_int = 0x00000001d; +pub const SCTP_EVENT: c_int = 0x0000001e; +pub const SCTP_RECVRCVINFO: c_int = 0x0000001f; +pub const SCTP_RECVNXTINFO: c_int = 0x00000020; +pub const SCTP_DEFAULT_SNDINFO: c_int = 0x00000021; +pub const SCTP_DEFAULT_PRINFO: c_int = 0x00000022; +pub const SCTP_PEER_ADDR_THLDS: c_int = 0x00000023; +pub const SCTP_REMOTE_UDP_ENCAPS_PORT: c_int = 0x00000024; +pub const SCTP_ECN_SUPPORTED: c_int = 0x00000025; +pub const SCTP_AUTH_SUPPORTED: c_int = 0x00000027; +pub const SCTP_ASCONF_SUPPORTED: c_int = 0x00000028; +pub const SCTP_RECONFIG_SUPPORTED: c_int = 0x00000029; +pub const SCTP_NRSACK_SUPPORTED: c_int = 0x00000030; +pub const SCTP_PKTDROP_SUPPORTED: c_int = 0x00000031; +pub const SCTP_MAX_CWND: c_int = 0x00000032; + +pub const SCTP_STATUS: c_int = 0x00000100; +pub const SCTP_GET_PEER_ADDR_INFO: c_int = 0x00000101; +pub const SCTP_PEER_AUTH_CHUNKS: c_int = 0x00000102; +pub const SCTP_LOCAL_AUTH_CHUNKS: c_int = 0x00000103; +pub const SCTP_GET_ASSOC_NUMBER: c_int = 0x00000104; +pub const SCTP_GET_ASSOC_ID_LIST: c_int = 0x00000105; +pub const SCTP_TIMEOUTS: c_int = 0x00000106; +pub const SCTP_PR_STREAM_STATUS: c_int = 0x00000107; +pub const SCTP_PR_ASSOC_STATUS: c_int = 0x00000108; + +pub const SCTP_COMM_UP: c_int = 0x0001; +pub const SCTP_COMM_LOST: c_int = 0x0002; +pub const SCTP_RESTART: c_int = 0x0003; +pub const SCTP_SHUTDOWN_COMP: c_int = 0x0004; +pub const SCTP_CANT_STR_ASSOC: c_int = 0x0005; + +pub const SCTP_ASSOC_SUPPORTS_PR: c_int = 0x01; +pub const SCTP_ASSOC_SUPPORTS_AUTH: c_int = 0x02; +pub const SCTP_ASSOC_SUPPORTS_ASCONF: c_int = 0x03; +pub const SCTP_ASSOC_SUPPORTS_MULTIBUF: c_int = 0x04; +pub const SCTP_ASSOC_SUPPORTS_RE_CONFIG: c_int = 0x05; +pub const SCTP_ASSOC_SUPPORTS_INTERLEAVING: c_int = 0x06; +pub const SCTP_ASSOC_SUPPORTS_MAX: c_int = 0x06; + +pub const SCTP_ADDR_AVAILABLE: c_int = 0x0001; +pub const SCTP_ADDR_UNREACHABLE: c_int = 0x0002; +pub const SCTP_ADDR_REMOVED: c_int = 0x0003; +pub const SCTP_ADDR_ADDED: c_int = 0x0004; +pub const SCTP_ADDR_MADE_PRIM: c_int = 0x0005; +pub const SCTP_ADDR_CONFIRMED: c_int = 0x0006; + +pub const SCTP_ACTIVE: c_int = 0x0001; +pub const SCTP_INACTIVE: c_int = 0x0002; +pub const SCTP_UNCONFIRMED: c_int = 0x0200; + +pub const SCTP_DATA_UNSENT: c_int = 0x0001; +pub const SCTP_DATA_SENT: c_int = 0x0002; + +pub const SCTP_PARTIAL_DELIVERY_ABORTED: c_int = 0x0001; + +pub const SCTP_AUTH_NEW_KEY: c_int = 0x0001; +pub const SCTP_AUTH_NEWKEY: c_int = SCTP_AUTH_NEW_KEY; +pub const SCTP_AUTH_NO_AUTH: c_int = 0x0002; +pub const SCTP_AUTH_FREE_KEY: c_int = 0x0003; + +pub const SCTP_STREAM_RESET_INCOMING_SSN: c_int = 0x0001; +pub const SCTP_STREAM_RESET_OUTGOING_SSN: c_int = 0x0002; +pub const SCTP_STREAM_RESET_DENIED: c_int = 0x0004; +pub const SCTP_STREAM_RESET_FAILED: c_int = 0x0008; + +pub const SCTP_ASSOC_RESET_DENIED: c_int = 0x0004; +pub const SCTP_ASSOC_RESET_FAILED: c_int = 0x0008; + +pub const SCTP_STREAM_CHANGE_DENIED: c_int = 0x0004; +pub const SCTP_STREAM_CHANGE_FAILED: c_int = 0x0008; + +pub const KENV_DUMP_LOADER: c_int = 4; +pub const KENV_DUMP_STATIC: c_int = 5; + +pub const RB_PAUSE: c_int = 0x100000; +pub const RB_REROOT: c_int = 0x200000; +pub const RB_POWERCYCLE: c_int = 0x400000; +pub const RB_PROBE: c_int = 0x10000000; +pub const RB_MULTIPLE: c_int = 0x20000000; + +// netinet/in_pcb.h +pub const INC_ISIPV6: c_uchar = 0x01; +pub const INC_IPV6MINMTU: c_uchar = 0x02; + +// sys/time.h +pub const CLOCK_BOOTTIME: crate::clockid_t = crate::CLOCK_UPTIME; +pub const CLOCK_REALTIME_COARSE: crate::clockid_t = crate::CLOCK_REALTIME_FAST; +pub const CLOCK_MONOTONIC_COARSE: crate::clockid_t = crate::CLOCK_MONOTONIC_FAST; + +// sys/timerfd.h + +pub const TFD_NONBLOCK: c_int = crate::O_NONBLOCK; +pub const TFD_CLOEXEC: c_int = O_CLOEXEC; +pub const TFD_TIMER_ABSTIME: c_int = 0x01; +pub const TFD_TIMER_CANCEL_ON_SET: c_int = 0x02; + +// sys/unistd.h + +pub const CLOSE_RANGE_CLOEXEC: c_uint = 1 << 2; + +pub const KCMP_FILE: c_int = 100; +pub const KCMP_FILEOBJ: c_int = 101; +pub const KCMP_FILES: c_int = 102; +pub const KCMP_SIGHAND: c_int = 103; +pub const KCMP_VM: c_int = 104; + +pub const fn MAP_ALIGNED(a: c_int) -> c_int { + a << 24 +} + +const fn _ALIGN(p: usize) -> usize { + (p + _ALIGNBYTES) & !_ALIGNBYTES +} + +f! { + pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { + (cmsg as *mut c_uchar).add(_ALIGN(size_of::())) + } + + pub const fn CMSG_LEN(length: c_uint) -> c_uint { + _ALIGN(size_of::()) as c_uint + length + } + + pub fn CMSG_NXTHDR(mhdr: *const crate::msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { + if cmsg.is_null() { + return crate::CMSG_FIRSTHDR(mhdr); + } + let next = cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) + _ALIGN(size_of::()); + let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; + if next > max { + core::ptr::null_mut::() + } else { + (cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr + } + } + + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { + (_ALIGN(size_of::()) + _ALIGN(length as usize)) as c_uint + } + + pub fn MALLOCX_ALIGN(lg: c_uint) -> c_int { + ffsl(lg as c_long - 1) + } + + pub const fn MALLOCX_TCACHE(tc: c_int) -> c_int { + (tc + 2) << 8 as c_int + } + + pub const fn MALLOCX_ARENA(a: c_int) -> c_int { + (a + 1) << 20 as c_int + } + + pub fn SOCKCREDSIZE(ngrps: usize) -> usize { + let ngrps = if ngrps > 0 { ngrps - 1 } else { 0 }; + size_of::() + size_of::() * ngrps + } + + pub fn uname(buf: *mut crate::utsname) -> c_int { + __xuname(256, buf as *mut c_void) + } + + pub fn CPU_ZERO(cpuset: &mut cpuset_t) -> () { + for slot in cpuset.__bits.iter_mut() { + *slot = 0; + } + } + + pub fn CPU_FILL(cpuset: &mut cpuset_t) -> () { + for slot in cpuset.__bits.iter_mut() { + *slot = !0; + } + } + + pub fn CPU_SET(cpu: usize, cpuset: &mut cpuset_t) -> () { + let bitset_bits = 8 * size_of::(); + let (idx, offset) = (cpu / bitset_bits, cpu % bitset_bits); + cpuset.__bits[idx] |= 1 << offset; + } + + pub fn CPU_CLR(cpu: usize, cpuset: &mut cpuset_t) -> () { + let bitset_bits = 8 * size_of::(); + let (idx, offset) = (cpu / bitset_bits, cpu % bitset_bits); + cpuset.__bits[idx] &= !(1 << offset); + } + + pub fn CPU_ISSET(cpu: usize, cpuset: &cpuset_t) -> bool { + let bitset_bits = 8 * size_of::(); + let (idx, offset) = (cpu / bitset_bits, cpu % bitset_bits); + 0 != cpuset.__bits[idx] & (1 << offset) + } + + pub fn CPU_COUNT(cpuset: &cpuset_t) -> c_int { + let mut s: u32 = 0; + let cpuset_size = size_of::(); + let bitset_size = size_of::(); + + for i in cpuset.__bits[..(cpuset_size / bitset_size)].iter() { + s += i.count_ones(); + } + s as c_int + } + + pub fn SOCKCRED2SIZE(ngrps: usize) -> usize { + let ngrps = if ngrps > 0 { ngrps - 1 } else { 0 }; + size_of::() + size_of::() * ngrps + } + + pub fn PROT_MAX(x: c_int) -> c_int { + x << 16 + } + + pub fn PROT_MAX_EXTRACT(x: c_int) -> c_int { + (x >> 16) & (crate::PROT_READ | crate::PROT_WRITE | crate::PROT_EXEC) + } +} + +safe_f! { + pub const fn WIFSIGNALED(status: c_int) -> bool { + (status & 0o177) != 0o177 && (status & 0o177) != 0 && status != 0x13 + } + + pub const fn INVALID_SINFO_FLAG(x: c_int) -> bool { + (x) & 0xfffffff0 + & !(SCTP_EOF + | SCTP_ABORT + | SCTP_UNORDERED + | SCTP_ADDR_OVER + | SCTP_SENDALL + | SCTP_EOR + | SCTP_SACK_IMMEDIATELY) + != 0 + } + + pub const fn PR_SCTP_POLICY(x: c_int) -> c_int { + x & 0x0f + } + + pub const fn PR_SCTP_ENABLED(x: c_int) -> bool { + PR_SCTP_POLICY(x) != SCTP_PR_SCTP_NONE && PR_SCTP_POLICY(x) != SCTP_PR_SCTP_ALL + } + + pub const fn PR_SCTP_TTL_ENABLED(x: c_int) -> bool { + PR_SCTP_POLICY(x) == SCTP_PR_SCTP_TTL + } + + pub const fn PR_SCTP_BUF_ENABLED(x: c_int) -> bool { + PR_SCTP_POLICY(x) == SCTP_PR_SCTP_BUF + } + + pub const fn PR_SCTP_RTX_ENABLED(x: c_int) -> bool { + PR_SCTP_POLICY(x) == SCTP_PR_SCTP_RTX + } + + pub const fn PR_SCTP_INVALID_POLICY(x: c_int) -> bool { + PR_SCTP_POLICY(x) > SCTP_PR_SCTP_MAX + } + + pub const fn PR_SCTP_VALID_POLICY(x: c_int) -> bool { + PR_SCTP_POLICY(x) <= SCTP_PR_SCTP_MAX + } +} + +cfg_if! { + if #[cfg(not(any(freebsd10, freebsd11)))] { + extern "C" { + pub fn fhlink(fhp: *mut fhandle_t, to: *const c_char) -> c_int; + pub fn fhlinkat(fhp: *mut fhandle_t, tofd: c_int, to: *const c_char) -> c_int; + pub fn fhreadlink(fhp: *mut fhandle_t, buf: *mut c_char, bufsize: size_t) -> c_int; + pub fn getfhat(fd: c_int, path: *mut c_char, fhp: *mut fhandle, flag: c_int) -> c_int; + } + } +} + +extern "C" { + #[cfg_attr(doc, doc(alias = "__errno_location"))] + #[cfg_attr(doc, doc(alias = "errno"))] + pub fn __error() -> *mut c_int; + + pub fn aio_cancel(fd: c_int, aiocbp: *mut aiocb) -> c_int; + pub fn aio_error(aiocbp: *const aiocb) -> c_int; + pub fn aio_fsync(op: c_int, aiocbp: *mut aiocb) -> c_int; + pub fn aio_read(aiocbp: *mut aiocb) -> c_int; + pub fn aio_readv(aiocbp: *mut crate::aiocb) -> c_int; + pub fn aio_return(aiocbp: *mut aiocb) -> ssize_t; + pub fn aio_suspend( + aiocb_list: *const *const aiocb, + nitems: c_int, + timeout: *const crate::timespec, + ) -> c_int; + pub fn aio_write(aiocbp: *mut aiocb) -> c_int; + pub fn aio_writev(aiocbp: *mut crate::aiocb) -> c_int; + + pub fn copy_file_range( + infd: c_int, + inoffp: *mut off_t, + outfd: c_int, + outoffp: *mut off_t, + len: size_t, + flags: c_uint, + ) -> ssize_t; + + pub fn devname_r( + dev: crate::dev_t, + mode: crate::mode_t, + buf: *mut c_char, + len: c_int, + ) -> *mut c_char; + + pub fn extattr_delete_fd(fd: c_int, attrnamespace: c_int, attrname: *const c_char) -> c_int; + pub fn extattr_delete_file( + path: *const c_char, + attrnamespace: c_int, + attrname: *const c_char, + ) -> c_int; + pub fn extattr_delete_link( + path: *const c_char, + attrnamespace: c_int, + attrname: *const c_char, + ) -> c_int; + pub fn extattr_get_fd( + fd: c_int, + attrnamespace: c_int, + attrname: *const c_char, + data: *mut c_void, + nbytes: size_t, + ) -> ssize_t; + pub fn extattr_get_file( + path: *const c_char, + attrnamespace: c_int, + attrname: *const c_char, + data: *mut c_void, + nbytes: size_t, + ) -> ssize_t; + pub fn extattr_get_link( + path: *const c_char, + attrnamespace: c_int, + attrname: *const c_char, + data: *mut c_void, + nbytes: size_t, + ) -> ssize_t; + pub fn extattr_list_fd( + fd: c_int, + attrnamespace: c_int, + data: *mut c_void, + nbytes: size_t, + ) -> ssize_t; + pub fn extattr_list_file( + path: *const c_char, + attrnamespace: c_int, + data: *mut c_void, + nbytes: size_t, + ) -> ssize_t; + pub fn extattr_list_link( + path: *const c_char, + attrnamespace: c_int, + data: *mut c_void, + nbytes: size_t, + ) -> ssize_t; + pub fn extattr_set_fd( + fd: c_int, + attrnamespace: c_int, + attrname: *const c_char, + data: *const c_void, + nbytes: size_t, + ) -> ssize_t; + pub fn extattr_set_file( + path: *const c_char, + attrnamespace: c_int, + attrname: *const c_char, + data: *const c_void, + nbytes: size_t, + ) -> ssize_t; + pub fn extattr_set_link( + path: *const c_char, + attrnamespace: c_int, + attrname: *const c_char, + data: *const c_void, + nbytes: size_t, + ) -> ssize_t; + + pub fn fspacectl( + fd: c_int, + cmd: c_int, + rqsr: *const spacectl_range, + flags: c_int, + rmsr: *mut spacectl_range, + ) -> c_int; + + pub fn jail(jail: *mut crate::jail) -> c_int; + pub fn jail_attach(jid: c_int) -> c_int; + pub fn jail_remove(jid: c_int) -> c_int; + pub fn jail_get(iov: *mut crate::iovec, niov: c_uint, flags: c_int) -> c_int; + pub fn jail_set(iov: *mut crate::iovec, niov: c_uint, flags: c_int) -> c_int; + + pub fn lio_listio( + mode: c_int, + aiocb_list: *const *mut aiocb, + nitems: c_int, + sevp: *mut sigevent, + ) -> c_int; + + pub fn getutxuser(user: *const c_char) -> *mut utmpx; + pub fn setutxdb(_type: c_int, file: *const c_char) -> c_int; + + pub fn aio_waitcomplete(iocbp: *mut *mut aiocb, timeout: *mut crate::timespec) -> ssize_t; + pub fn mq_getfd_np(mqd: crate::mqd_t) -> c_int; + + pub fn waitid( + idtype: idtype_t, + id: crate::id_t, + infop: *mut crate::siginfo_t, + options: c_int, + ) -> c_int; + pub fn ptsname_r(fd: c_int, buf: *mut c_char, buflen: size_t) -> c_int; + + pub fn ftok(pathname: *const c_char, proj_id: c_int) -> crate::key_t; + pub fn shmget(key: crate::key_t, size: size_t, shmflg: c_int) -> c_int; + pub fn shmat(shmid: c_int, shmaddr: *const c_void, shmflg: c_int) -> *mut c_void; + pub fn shmdt(shmaddr: *const c_void) -> c_int; + pub fn shmctl(shmid: c_int, cmd: c_int, buf: *mut crate::shmid_ds) -> c_int; + pub fn semget(key: crate::key_t, nsems: c_int, semflg: c_int) -> c_int; + pub fn semctl(semid: c_int, semnum: c_int, cmd: c_int, ...) -> c_int; + pub fn semop(semid: c_int, sops: *mut sembuf, nsops: size_t) -> c_int; + pub fn msgctl(msqid: c_int, cmd: c_int, buf: *mut crate::msqid_ds) -> c_int; + pub fn msgget(key: crate::key_t, msgflg: c_int) -> c_int; + pub fn msgsnd(msqid: c_int, msgp: *const c_void, msgsz: size_t, msgflg: c_int) -> c_int; + pub fn cfmakesane(termios: *mut crate::termios); + + pub fn pdfork(fdp: *mut c_int, flags: c_int) -> crate::pid_t; + pub fn pdgetpid(fd: c_int, pidp: *mut crate::pid_t) -> c_int; + pub fn pdkill(fd: c_int, signum: c_int) -> c_int; + + pub fn rtprio_thread(function: c_int, lwpid: crate::lwpid_t, rtp: *mut super::rtprio) -> c_int; + + pub fn uuidgen(store: *mut uuid, count: c_int) -> c_int; + + pub fn thr_kill(id: c_long, sig: c_int) -> c_int; + pub fn thr_kill2(pid: crate::pid_t, id: c_long, sig: c_int) -> c_int; + pub fn thr_self(tid: *mut c_long) -> c_int; + pub fn pthread_getthreadid_np() -> c_int; + pub fn pthread_getaffinity_np( + td: crate::pthread_t, + cpusetsize: size_t, + cpusetp: *mut cpuset_t, + ) -> c_int; + pub fn pthread_setaffinity_np( + td: crate::pthread_t, + cpusetsize: size_t, + cpusetp: *const cpuset_t, + ) -> c_int; + + // sched.h linux compatibility api + pub fn sched_getaffinity( + pid: crate::pid_t, + cpusetsz: size_t, + cpuset: *mut crate::cpuset_t, + ) -> c_int; + pub fn sched_setaffinity( + pid: crate::pid_t, + cpusetsz: size_t, + cpuset: *const crate::cpuset_t, + ) -> c_int; + pub fn sched_getcpu() -> c_int; + + pub fn pthread_mutex_consistent(mutex: *mut crate::pthread_mutex_t) -> c_int; + + pub fn pthread_mutexattr_getrobust( + attr: *mut crate::pthread_mutexattr_t, + robust: *mut c_int, + ) -> c_int; + pub fn pthread_mutexattr_setrobust( + attr: *mut crate::pthread_mutexattr_t, + robust: c_int, + ) -> c_int; + + pub fn pthread_spin_init(lock: *mut pthread_spinlock_t, pshared: c_int) -> c_int; + pub fn pthread_spin_destroy(lock: *mut pthread_spinlock_t) -> c_int; + pub fn pthread_spin_lock(lock: *mut pthread_spinlock_t) -> c_int; + pub fn pthread_spin_trylock(lock: *mut pthread_spinlock_t) -> c_int; + pub fn pthread_spin_unlock(lock: *mut pthread_spinlock_t) -> c_int; + + pub fn pthread_timedjoin_np( + thread: crate::pthread_t, + retval: *mut *mut c_void, + abstime: *const crate::timespec, + ) -> c_int; + + #[cfg_attr(all(target_os = "freebsd", freebsd11), link_name = "statfs@FBSD_1.0")] + pub fn statfs(path: *const c_char, buf: *mut statfs) -> c_int; + #[cfg_attr(all(target_os = "freebsd", freebsd11), link_name = "fstatfs@FBSD_1.0")] + pub fn fstatfs(fd: c_int, buf: *mut statfs) -> c_int; + + pub fn dup3(src: c_int, dst: c_int, flags: c_int) -> c_int; + pub fn __xuname(nmln: c_int, buf: *mut c_void) -> c_int; + + pub fn sendmmsg( + sockfd: c_int, + msgvec: *mut crate::mmsghdr, + vlen: size_t, + flags: c_int, + ) -> ssize_t; + pub fn recvmmsg( + sockfd: c_int, + msgvec: *mut crate::mmsghdr, + vlen: size_t, + flags: c_int, + timeout: *const crate::timespec, + ) -> ssize_t; + pub fn memmem( + haystack: *const c_void, + haystacklen: size_t, + needle: *const c_void, + needlelen: size_t, + ) -> *mut c_void; + + pub fn fhopen(fhp: *const fhandle_t, flags: c_int) -> c_int; + pub fn fhstat(fhp: *const fhandle, buf: *mut crate::stat) -> c_int; + pub fn fhstatfs(fhp: *const fhandle_t, buf: *mut crate::statfs) -> c_int; + pub fn getfh(path: *const c_char, fhp: *mut fhandle_t) -> c_int; + pub fn lgetfh(path: *const c_char, fhp: *mut fhandle_t) -> c_int; + pub fn getfsstat(buf: *mut crate::statfs, bufsize: c_long, mode: c_int) -> c_int; + #[cfg_attr( + all(target_os = "freebsd", freebsd11), + link_name = "getmntinfo@FBSD_1.0" + )] + pub fn getmntinfo(mntbufp: *mut *mut crate::statfs, mode: c_int) -> c_int; + pub fn mount( + type_: *const c_char, + dir: *const c_char, + flags: c_int, + data: *mut c_void, + ) -> c_int; + pub fn nmount(iov: *mut crate::iovec, niov: c_uint, flags: c_int) -> c_int; + + pub fn setproctitle(fmt: *const c_char, ...); + pub fn rfork(flags: c_int) -> c_int; + pub fn cpuset_getaffinity( + level: cpulevel_t, + which: cpuwhich_t, + id: crate::id_t, + setsize: size_t, + mask: *mut cpuset_t, + ) -> c_int; + pub fn cpuset_setaffinity( + level: cpulevel_t, + which: cpuwhich_t, + id: crate::id_t, + setsize: size_t, + mask: *const cpuset_t, + ) -> c_int; + pub fn cpuset(setid: *mut crate::cpusetid_t) -> c_int; + pub fn cpuset_getid( + level: cpulevel_t, + which: cpuwhich_t, + id: crate::id_t, + setid: *mut crate::cpusetid_t, + ) -> c_int; + pub fn cpuset_setid(which: cpuwhich_t, id: crate::id_t, setid: crate::cpusetid_t) -> c_int; + pub fn cap_enter() -> c_int; + pub fn cap_getmode(modep: *mut c_uint) -> c_int; + pub fn cap_fcntls_get(fd: c_int, fcntlrightsp: *mut u32) -> c_int; + pub fn cap_fcntls_limit(fd: c_int, fcntlrights: u32) -> c_int; + pub fn cap_ioctls_get(fd: c_int, cmds: *mut u_long, maxcmds: usize) -> isize; + pub fn cap_ioctls_limit(fd: c_int, cmds: *const u_long, ncmds: usize) -> c_int; + pub fn __cap_rights_init(version: c_int, rights: *mut cap_rights_t, ...) -> *mut cap_rights_t; + pub fn __cap_rights_get(version: c_int, fd: c_int, rightsp: *mut cap_rights_t) -> c_int; + pub fn __cap_rights_set(rights: *mut cap_rights_t, ...) -> *mut cap_rights_t; + pub fn __cap_rights_clear(rights: *mut cap_rights_t, ...) -> *mut cap_rights_t; + pub fn __cap_rights_is_set(rights: *const cap_rights_t, ...) -> bool; + pub fn cap_rights_is_valid(rights: *const cap_rights_t) -> bool; + pub fn cap_rights_limit(fd: c_int, rights: *const cap_rights_t) -> c_int; + pub fn cap_rights_merge(dst: *mut cap_rights_t, src: *const cap_rights_t) -> *mut cap_rights_t; + pub fn cap_rights_remove(dst: *mut cap_rights_t, src: *const cap_rights_t) + -> *mut cap_rights_t; + pub fn cap_rights_contains(big: *const cap_rights_t, little: *const cap_rights_t) -> bool; + pub fn cap_sandboxed() -> bool; + + pub fn reallocarray(ptr: *mut c_void, nmemb: size_t, size: size_t) -> *mut c_void; + + pub fn ffs(value: c_int) -> c_int; + pub fn ffsl(value: c_long) -> c_int; + pub fn ffsll(value: c_longlong) -> c_int; + pub fn fls(value: c_int) -> c_int; + pub fn flsl(value: c_long) -> c_int; + pub fn flsll(value: c_longlong) -> c_int; + pub fn malloc_stats_print( + write_cb: unsafe extern "C" fn(*mut c_void, *const c_char), + cbopaque: *mut c_void, + opt: *const c_char, + ); + pub fn mallctl( + name: *const c_char, + oldp: *mut c_void, + oldlenp: *mut size_t, + newp: *mut c_void, + newlen: size_t, + ) -> c_int; + pub fn mallctlnametomib(name: *const c_char, mibp: *mut size_t, miplen: *mut size_t) -> c_int; + pub fn mallctlbymib( + mib: *const size_t, + mible: size_t, + oldp: *mut c_void, + oldlenp: *mut size_t, + newp: *mut c_void, + newlen: size_t, + ) -> c_int; + pub fn mallocx(size: size_t, flags: c_int) -> *mut c_void; + pub fn rallocx(ptr: *mut c_void, size: size_t, flags: c_int) -> *mut c_void; + pub fn xallocx(ptr: *mut c_void, size: size_t, extra: size_t, flags: c_int) -> size_t; + pub fn sallocx(ptr: *const c_void, flags: c_int) -> size_t; + pub fn dallocx(ptr: *mut c_void, flags: c_int); + pub fn sdallocx(ptr: *mut c_void, size: size_t, flags: c_int); + pub fn nallocx(size: size_t, flags: c_int) -> size_t; + + pub fn procctl( + idtype: crate::idtype_t, + id: crate::id_t, + cmd: c_int, + data: *mut c_void, + ) -> c_int; + + pub fn getpagesize() -> c_int; + pub fn getpagesizes(pagesize: *mut size_t, nelem: c_int) -> c_int; + + pub fn clock_getcpuclockid2(arg1: crate::id_t, arg2: c_int, arg3: *mut clockid_t) -> c_int; + pub fn strchrnul(s: *const c_char, c: c_int) -> *mut c_char; + + pub fn shm_create_largepage( + path: *const c_char, + flags: c_int, + psind: c_int, + alloc_policy: c_int, + mode: crate::mode_t, + ) -> c_int; + pub fn shm_rename(path_from: *const c_char, path_to: *const c_char, flags: c_int) -> c_int; + pub fn memfd_create(name: *const c_char, flags: c_uint) -> c_int; + pub fn setaudit(auditinfo: *const auditinfo_t) -> c_int; + + pub fn eventfd(initval: c_uint, flags: c_int) -> c_int; + pub fn eventfd_read(fd: c_int, value: *mut eventfd_t) -> c_int; + pub fn eventfd_write(fd: c_int, value: eventfd_t) -> c_int; + + pub fn fdatasync(fd: c_int) -> c_int; + + pub fn elf_aux_info(aux: c_int, buf: *mut c_void, buflen: c_int) -> c_int; + pub fn setproctitle_fast(fmt: *const c_char, ...); + pub fn timingsafe_bcmp(a: *const c_void, b: *const c_void, len: size_t) -> c_int; + pub fn timingsafe_memcmp(a: *const c_void, b: *const c_void, len: size_t) -> c_int; + + pub fn _umtx_op( + obj: *mut c_void, + op: c_int, + val: c_ulong, + uaddr: *mut c_void, + uaddr2: *mut c_void, + ) -> c_int; + + pub fn sctp_peeloff(s: c_int, id: crate::sctp_assoc_t) -> c_int; + pub fn sctp_bindx(s: c_int, addrs: *mut crate::sockaddr, num: c_int, tpe: c_int) -> c_int; + pub fn sctp_connectx( + s: c_int, + addrs: *const crate::sockaddr, + addrcnt: c_int, + id: *mut crate::sctp_assoc_t, + ) -> c_int; + pub fn sctp_getaddrlen(family: crate::sa_family_t) -> c_int; + pub fn sctp_getpaddrs( + s: c_int, + asocid: crate::sctp_assoc_t, + addrs: *mut *mut crate::sockaddr, + ) -> c_int; + pub fn sctp_freepaddrs(addrs: *mut crate::sockaddr); + pub fn sctp_getladdrs( + s: c_int, + asocid: crate::sctp_assoc_t, + addrs: *mut *mut crate::sockaddr, + ) -> c_int; + pub fn sctp_freeladdrs(addrs: *mut crate::sockaddr); + pub fn sctp_opt_info( + s: c_int, + id: crate::sctp_assoc_t, + opt: c_int, + arg: *mut c_void, + size: *mut crate::socklen_t, + ) -> c_int; + pub fn sctp_sendv( + sd: c_int, + iov: *const crate::iovec, + iovcnt: c_int, + addrs: *mut crate::sockaddr, + addrcnt: c_int, + info: *mut c_void, + infolen: crate::socklen_t, + infotype: c_uint, + flags: c_int, + ) -> ssize_t; + pub fn sctp_recvv( + sd: c_int, + iov: *const crate::iovec, + iovcnt: c_int, + from: *mut crate::sockaddr, + fromlen: *mut crate::socklen_t, + info: *mut c_void, + infolen: *mut crate::socklen_t, + infotype: *mut c_uint, + flags: *mut c_int, + ) -> ssize_t; + + pub fn timerfd_create(clockid: c_int, flags: c_int) -> c_int; + pub fn timerfd_gettime(fd: c_int, curr_value: *mut itimerspec) -> c_int; + pub fn timerfd_settime( + fd: c_int, + flags: c_int, + new_value: *const itimerspec, + old_value: *mut itimerspec, + ) -> c_int; + pub fn closefrom(lowfd: c_int); + pub fn close_range(lowfd: c_uint, highfd: c_uint, flags: c_int) -> c_int; + + pub fn execvpe( + file: *const c_char, + argv: *const *const c_char, + envp: *const *const c_char, + ) -> c_int; + + pub fn kcmp( + pid1: crate::pid_t, + pid2: crate::pid_t, + type_: c_int, + idx1: c_ulong, + idx2: c_ulong, + ) -> c_int; + pub fn dlvsym( + handle: *mut c_void, + symbol: *const c_char, + version: *const c_char, + ) -> *mut c_void; +} + +#[link(name = "memstat")] +extern "C" { + pub fn memstat_strerror(error: c_int) -> *const c_char; + pub fn memstat_mtl_alloc() -> *mut memory_type_list; + pub fn memstat_mtl_first(list: *mut memory_type_list) -> *mut memory_type; + pub fn memstat_mtl_next(mtp: *mut memory_type) -> *mut memory_type; + pub fn memstat_mtl_find( + list: *mut memory_type_list, + allocator: c_int, + name: *const c_char, + ) -> *mut memory_type; + pub fn memstat_mtl_free(list: *mut memory_type_list); + pub fn memstat_mtl_geterror(list: *mut memory_type_list) -> c_int; + pub fn memstat_get_name(mtp: *const memory_type) -> *const c_char; +} + +#[link(name = "kvm")] +extern "C" { + pub fn kvm_dpcpu_setcpu(kd: *mut crate::kvm_t, cpu: c_uint) -> c_int; + pub fn kvm_getargv( + kd: *mut crate::kvm_t, + p: *const kinfo_proc, + nchr: c_int, + ) -> *mut *mut c_char; + pub fn kvm_getcptime(kd: *mut crate::kvm_t, cp_time: *mut c_long) -> c_int; + pub fn kvm_getenvv( + kd: *mut crate::kvm_t, + p: *const kinfo_proc, + nchr: c_int, + ) -> *mut *mut c_char; + pub fn kvm_geterr(kd: *mut crate::kvm_t) -> *mut c_char; + pub fn kvm_getmaxcpu(kd: *mut crate::kvm_t) -> c_int; + pub fn kvm_getncpus(kd: *mut crate::kvm_t) -> c_int; + pub fn kvm_getpcpu(kd: *mut crate::kvm_t, cpu: c_int) -> *mut c_void; + pub fn kvm_counter_u64_fetch(kd: *mut crate::kvm_t, base: c_ulong) -> u64; + pub fn kvm_getswapinfo( + kd: *mut crate::kvm_t, + info: *mut kvm_swap, + maxswap: c_int, + flags: c_int, + ) -> c_int; + pub fn kvm_native(kd: *mut crate::kvm_t) -> c_int; + pub fn kvm_nlist(kd: *mut crate::kvm_t, nl: *mut nlist) -> c_int; + pub fn kvm_nlist2(kd: *mut crate::kvm_t, nl: *mut kvm_nlist) -> c_int; + pub fn kvm_read_zpcpu( + kd: *mut crate::kvm_t, + base: c_ulong, + buf: *mut c_void, + size: size_t, + cpu: c_int, + ) -> ssize_t; + pub fn kvm_read2( + kd: *mut crate::kvm_t, + addr: kvaddr_t, + buf: *mut c_void, + nbytes: size_t, + ) -> ssize_t; +} + +#[link(name = "util")] +extern "C" { + pub fn extattr_namespace_to_string(attrnamespace: c_int, string: *mut *mut c_char) -> c_int; + pub fn extattr_string_to_namespace(string: *const c_char, attrnamespace: *mut c_int) -> c_int; + pub fn realhostname(host: *mut c_char, hsize: size_t, ip: *const crate::in_addr) -> c_int; + pub fn realhostname_sa( + host: *mut c_char, + hsize: size_t, + addr: *mut crate::sockaddr, + addrlen: c_int, + ) -> c_int; + + pub fn kld_isloaded(name: *const c_char) -> c_int; + pub fn kld_load(name: *const c_char) -> c_int; + + pub fn kinfo_getvmmap(pid: crate::pid_t, cntp: *mut c_int) -> *mut kinfo_vmentry; + + pub fn hexdump(ptr: *const c_void, length: c_int, hdr: *const c_char, flags: c_int); + pub fn humanize_number( + buf: *mut c_char, + len: size_t, + number: i64, + suffix: *const c_char, + scale: c_int, + flags: c_int, + ) -> c_int; + + pub fn flopen(path: *const c_char, flags: c_int, ...) -> c_int; + pub fn flopenat(fd: c_int, path: *const c_char, flags: c_int, ...) -> c_int; + + pub fn getlocalbase() -> *const c_char; + + pub fn pidfile_open( + path: *const c_char, + mode: crate::mode_t, + pidptr: *mut crate::pid_t, + ) -> *mut crate::pidfh; + pub fn pidfile_write(path: *mut crate::pidfh) -> c_int; + pub fn pidfile_close(path: *mut crate::pidfh) -> c_int; + pub fn pidfile_remove(path: *mut crate::pidfh) -> c_int; + pub fn pidfile_fileno(path: *const crate::pidfh) -> c_int; + // FIXME(freebsd): pidfile_signal in due time (both manpage present and updated image snapshot) +} + +#[link(name = "procstat")] +extern "C" { + pub fn procstat_open_sysctl() -> *mut procstat; + pub fn procstat_getfiles( + procstat: *mut procstat, + kp: *mut kinfo_proc, + mmapped: c_int, + ) -> *mut filestat_list; + pub fn procstat_freefiles(procstat: *mut procstat, head: *mut filestat_list); + pub fn procstat_getprocs( + procstat: *mut procstat, + what: c_int, + arg: c_int, + count: *mut c_uint, + ) -> *mut kinfo_proc; + pub fn procstat_freeprocs(procstat: *mut procstat, p: *mut kinfo_proc); + pub fn procstat_getvmmap( + procstat: *mut procstat, + kp: *mut kinfo_proc, + count: *mut c_uint, + ) -> *mut kinfo_vmentry; + pub fn procstat_freevmmap(procstat: *mut procstat, vmmap: *mut kinfo_vmentry); + pub fn procstat_close(procstat: *mut procstat); + pub fn procstat_freeargv(procstat: *mut procstat); + pub fn procstat_freeenvv(procstat: *mut procstat); + pub fn procstat_freegroups(procstat: *mut procstat, groups: *mut crate::gid_t); + pub fn procstat_freeptlwpinfo(procstat: *mut procstat, pl: *mut ptrace_lwpinfo); + pub fn procstat_getargv( + procstat: *mut procstat, + kp: *mut kinfo_proc, + nchr: size_t, + ) -> *mut *mut c_char; + pub fn procstat_getenvv( + procstat: *mut procstat, + kp: *mut kinfo_proc, + nchr: size_t, + ) -> *mut *mut c_char; + pub fn procstat_getgroups( + procstat: *mut procstat, + kp: *mut kinfo_proc, + count: *mut c_uint, + ) -> *mut crate::gid_t; + pub fn procstat_getosrel( + procstat: *mut procstat, + kp: *mut kinfo_proc, + osrelp: *mut c_int, + ) -> c_int; + pub fn procstat_getpathname( + procstat: *mut procstat, + kp: *mut kinfo_proc, + pathname: *mut c_char, + maxlen: size_t, + ) -> c_int; + pub fn procstat_getrlimit( + procstat: *mut procstat, + kp: *mut kinfo_proc, + which: c_int, + rlimit: *mut crate::rlimit, + ) -> c_int; + pub fn procstat_getumask( + procstat: *mut procstat, + kp: *mut kinfo_proc, + maskp: *mut c_ushort, + ) -> c_int; + pub fn procstat_open_core(filename: *const c_char) -> *mut procstat; + pub fn procstat_open_kvm(nlistf: *const c_char, memf: *const c_char) -> *mut procstat; + pub fn procstat_get_socket_info( + proc_: *mut procstat, + fst: *mut filestat, + sock: *mut sockstat, + errbuf: *mut c_char, + ) -> c_int; + pub fn procstat_get_vnode_info( + proc_: *mut procstat, + fst: *mut filestat, + vn: *mut vnstat, + errbuf: *mut c_char, + ) -> c_int; + pub fn procstat_get_pts_info( + proc_: *mut procstat, + fst: *mut filestat, + pts: *mut ptsstat, + errbuf: *mut c_char, + ) -> c_int; + pub fn procstat_get_shm_info( + proc_: *mut procstat, + fst: *mut filestat, + shm: *mut shmstat, + errbuf: *mut c_char, + ) -> c_int; +} + +#[link(name = "rt")] +extern "C" { + pub fn timer_create(clock_id: clockid_t, evp: *mut sigevent, timerid: *mut timer_t) -> c_int; + pub fn timer_delete(timerid: timer_t) -> c_int; + pub fn timer_getoverrun(timerid: timer_t) -> c_int; + pub fn timer_gettime(timerid: timer_t, value: *mut itimerspec) -> c_int; + pub fn timer_settime( + timerid: timer_t, + flags: c_int, + value: *const itimerspec, + ovalue: *mut itimerspec, + ) -> c_int; +} + +#[link(name = "devstat")] +extern "C" { + pub fn devstat_getnumdevs(kd: *mut crate::kvm_t) -> c_int; + pub fn devstat_getgeneration(kd: *mut crate::kvm_t) -> c_long; + pub fn devstat_getversion(kd: *mut crate::kvm_t) -> c_int; + pub fn devstat_checkversion(kd: *mut crate::kvm_t) -> c_int; + pub fn devstat_selectdevs( + dev_select: *mut *mut device_selection, + num_selected: *mut c_int, + num_selections: *mut c_int, + select_generation: *mut c_long, + current_generation: c_long, + devices: *mut devstat, + numdevs: c_int, + matches: *mut devstat_match, + num_matches: c_int, + dev_selections: *mut *mut c_char, + num_dev_selections: c_int, + select_mode: devstat_select_mode, + maxshowdevs: c_int, + perf_select: c_int, + ) -> c_int; + pub fn devstat_buildmatch( + match_str: *mut c_char, + matches: *mut *mut devstat_match, + num_matches: *mut c_int, + ) -> c_int; +} + +cfg_if! { + if #[cfg(freebsd15)] { + mod freebsd15; + pub use self::freebsd15::*; + } else if #[cfg(freebsd14)] { + mod freebsd14; + pub use self::freebsd14::*; + } else if #[cfg(freebsd13)] { + mod freebsd13; + pub use self::freebsd13::*; + } else if #[cfg(freebsd12)] { + mod freebsd12; + pub use self::freebsd12::*; + } else if #[cfg(any(freebsd10, freebsd11))] { + mod freebsd11; + pub use self::freebsd11::*; + } else { + // Unknown freebsd version + } +} + +cfg_if! { + if #[cfg(target_arch = "x86")] { + mod x86; + pub use self::x86::*; + } else if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } else if #[cfg(target_arch = "aarch64")] { + mod aarch64; + pub use self::aarch64::*; + } else if #[cfg(target_arch = "arm")] { + mod arm; + pub use self::arm::*; + } else if #[cfg(target_arch = "powerpc64")] { + mod powerpc64; + pub use self::powerpc64::*; + } else if #[cfg(target_arch = "powerpc")] { + mod powerpc; + pub use self::powerpc::*; + } else if #[cfg(target_arch = "riscv64")] { + mod riscv64; + pub use self::riscv64::*; + } else { + // Unknown target_arch + } +} diff --git a/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/powerpc.rs b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/powerpc.rs new file mode 100644 index 0000000..4c0e165 --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/powerpc.rs @@ -0,0 +1,30 @@ +use crate::prelude::*; + +pub type clock_t = u32; +pub type wchar_t = i32; +pub type time_t = i64; +pub type suseconds_t = i32; +pub type register_t = i32; + +s! { + #[repr(align(16))] + pub struct mcontext_t { + pub mc_vers: c_int, + pub mc_flags: c_int, + pub mc_onstack: c_int, + pub mc_len: c_int, + pub mc_avec: [u64; 64], + pub mc_av: [u32; 2], + pub mc_frame: [crate::register_t; 42], + pub mc_fpreg: [u64; 33], + pub mc_vsxfpreg: [u64; 32], + } +} + +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; + +pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; +pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e; +pub const MAP_32BIT: c_int = 0x00080000; +pub const MINSIGSTKSZ: size_t = 2048; // 512 * 4 +pub const TIOCTIMESTAMP: c_ulong = 0x40107459; diff --git a/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs new file mode 100644 index 0000000..bfc6d5c --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs @@ -0,0 +1,31 @@ +use crate::prelude::*; + +pub type clock_t = u32; +pub type wchar_t = i32; +pub type time_t = i64; +pub type suseconds_t = i64; +pub type register_t = i64; + +s! { + #[repr(align(16))] + pub struct mcontext_t { + pub mc_vers: c_int, + pub mc_flags: c_int, + pub mc_onstack: c_int, + pub mc_len: c_int, + pub mc_avec: [u64; 64], + pub mc_av: [u32; 2], + pub mc_frame: [crate::register_t; 42], + pub mc_fpreg: [u64; 33], + pub mc_vsxfpreg: [u64; 32], + } +} + +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; + +pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; +pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e; + +pub const MAP_32BIT: c_int = 0x00080000; +pub const MINSIGSTKSZ: size_t = 2048; // 512 * 4 +pub const TIOCTIMESTAMP: c_ulong = 0x40107459; diff --git a/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/riscv64.rs b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/riscv64.rs new file mode 100644 index 0000000..e2d7920 --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/riscv64.rs @@ -0,0 +1,44 @@ +use crate::prelude::*; + +pub type clock_t = i32; +pub type wchar_t = c_int; +pub type time_t = i64; +pub type suseconds_t = c_long; +pub type register_t = i64; + +s! { + pub struct gpregs { + pub gp_ra: crate::register_t, + pub gp_sp: crate::register_t, + pub gp_gp: crate::register_t, + pub gp_tp: crate::register_t, + pub gp_t: [crate::register_t; 7], + pub gp_s: [crate::register_t; 12], + pub gp_a: [crate::register_t; 8], + pub gp_sepc: crate::register_t, + pub gp_sstatus: crate::register_t, + } + + pub struct fpregs { + pub fp_x: [[u64; 2]; 32], + pub fp_fcsr: u64, + pub fp_flags: c_int, + pub pad: c_int, + } + + pub struct mcontext_t { + pub mc_gpregs: gpregs, + pub mc_fpregs: fpregs, + pub mc_flags: c_int, + pub mc_pad: c_int, + pub mc_spare: [u64; 8], + } +} + +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; + +pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; +pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e; +pub const MAP_32BIT: c_int = 0x00080000; +pub const MINSIGSTKSZ: size_t = 4096; // 1024 * 4 +pub const TIOCTIMESTAMP: c_ulong = 0x40107459; diff --git a/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/x86.rs b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/x86.rs new file mode 100644 index 0000000..a95914d --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/x86.rs @@ -0,0 +1,52 @@ +use crate::prelude::*; + +pub type clock_t = c_ulong; +pub type wchar_t = i32; +pub type time_t = i32; +pub type suseconds_t = i32; +pub type register_t = i32; + +s! { + #[repr(align(16))] + pub struct mcontext_t { + pub mc_onstack: register_t, + pub mc_gs: register_t, + pub mc_fs: register_t, + pub mc_es: register_t, + pub mc_ds: register_t, + pub mc_edi: register_t, + pub mc_esi: register_t, + pub mc_ebp: register_t, + pub mc_isp: register_t, + pub mc_ebx: register_t, + pub mc_edx: register_t, + pub mc_ecx: register_t, + pub mc_eax: register_t, + pub mc_trapno: register_t, + pub mc_err: register_t, + pub mc_eip: register_t, + pub mc_cs: register_t, + pub mc_eflags: register_t, + pub mc_esp: register_t, + pub mc_ss: register_t, + pub mc_len: c_int, + pub mc_fpformat: c_int, + pub mc_ownedfp: c_int, + pub mc_flags: register_t, + pub mc_fpstate: [c_int; 128], + pub mc_fsbase: register_t, + pub mc_gsbase: register_t, + pub mc_xfpustate: register_t, + pub mc_xfpustate_len: register_t, + pub mc_spare2: [c_int; 4], + } +} + +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; + +pub const MINSIGSTKSZ: size_t = 2048; // 512 * 4 + +pub const BIOCSRTIMEOUT: c_ulong = 0x8008426d; +pub const BIOCGRTIMEOUT: c_ulong = 0x4008426e; +pub const KINFO_FILE_SIZE: c_int = 1392; +pub const TIOCTIMESTAMP: c_ulong = 0x40087459; diff --git a/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs new file mode 100644 index 0000000..9848542 --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs @@ -0,0 +1,187 @@ +use crate::prelude::*; + +pub type clock_t = i32; +pub type wchar_t = i32; +pub type time_t = i64; +pub type suseconds_t = i64; +pub type register_t = i64; + +s! { + pub struct reg32 { + pub r_fs: u32, + pub r_es: u32, + pub r_ds: u32, + pub r_edi: u32, + pub r_esi: u32, + pub r_ebp: u32, + pub r_isp: u32, + pub r_ebx: u32, + pub r_edx: u32, + pub r_ecx: u32, + pub r_eax: u32, + pub r_trapno: u32, + pub r_err: u32, + pub r_eip: u32, + pub r_cs: u32, + pub r_eflags: u32, + pub r_esp: u32, + pub r_ss: u32, + pub r_gs: u32, + } + + pub struct reg { + pub r_r15: i64, + pub r_r14: i64, + pub r_r13: i64, + pub r_r12: i64, + pub r_r11: i64, + pub r_r10: i64, + pub r_r9: i64, + pub r_r8: i64, + pub r_rdi: i64, + pub r_rsi: i64, + pub r_rbp: i64, + pub r_rbx: i64, + pub r_rdx: i64, + pub r_rcx: i64, + pub r_rax: i64, + pub r_trapno: u32, + pub r_fs: u16, + pub r_gs: u16, + pub r_err: u32, + pub r_es: u16, + pub r_ds: u16, + pub r_rip: i64, + pub r_cs: i64, + pub r_rflags: i64, + pub r_rsp: i64, + pub r_ss: i64, + } + + pub struct fpreg32 { + pub fpr_env: [u32; 7], + pub fpr_acc: [[u8; 10]; 8], + pub fpr_ex_sw: u32, + pub fpr_pad: [u8; 64], + } + + pub struct fpreg { + pub fpr_env: [u64; 4], + pub fpr_acc: [[u8; 16]; 8], + pub fpr_xacc: [[u8; 16]; 16], + pub fpr_spare: [u64; 12], + } + + pub struct xmmreg { + pub xmm_env: [u32; 8], + pub xmm_acc: [[u8; 16]; 8], + pub xmm_reg: [[u8; 16]; 8], + pub xmm_pad: [u8; 224], + } + #[repr(align(16))] + #[cfg_attr(not(any(freebsd11, freebsd12, freebsd13, freebsd14)), non_exhaustive)] + pub struct mcontext_t { + pub mc_onstack: register_t, + pub mc_rdi: register_t, + pub mc_rsi: register_t, + pub mc_rdx: register_t, + pub mc_rcx: register_t, + pub mc_r8: register_t, + pub mc_r9: register_t, + pub mc_rax: register_t, + pub mc_rbx: register_t, + pub mc_rbp: register_t, + pub mc_r10: register_t, + pub mc_r11: register_t, + pub mc_r12: register_t, + pub mc_r13: register_t, + pub mc_r14: register_t, + pub mc_r15: register_t, + pub mc_trapno: u32, + pub mc_fs: u16, + pub mc_gs: u16, + pub mc_addr: register_t, + pub mc_flags: u32, + pub mc_es: u16, + pub mc_ds: u16, + pub mc_err: register_t, + pub mc_rip: register_t, + pub mc_cs: register_t, + pub mc_rflags: register_t, + pub mc_rsp: register_t, + pub mc_ss: register_t, + pub mc_len: c_long, + pub mc_fpformat: c_long, + pub mc_ownedfp: c_long, + pub mc_fpstate: [c_long; 64], + pub mc_fsbase: register_t, + pub mc_gsbase: register_t, + pub mc_xfpustate: register_t, + pub mc_xfpustate_len: register_t, + // freebsd < 15 + #[cfg(any(freebsd11, freebsd12, freebsd13))] + pub mc_spare: [c_long; 4], + // freebsd >= 15 + #[cfg(not(any(freebsd11, freebsd12, freebsd13)))] + pub mc_tlsbase: register_t, + #[cfg(not(any(freebsd11, freebsd12, freebsd13)))] + pub mc_spare: [c_long; 3], + } +} + +s_no_extra_traits! { + pub union __c_anonymous_elf64_auxv_union { + pub a_val: c_long, + pub a_ptr: *mut c_void, + pub a_fcn: extern "C" fn(), + } + + pub struct Elf64_Auxinfo { + pub a_type: c_long, + pub a_un: __c_anonymous_elf64_auxv_union, + } + + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 4], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + // FIXME(msrv): suggested method was added in 1.85 + #[allow(unpredictable_function_pointer_comparisons)] + impl PartialEq for __c_anonymous_elf64_auxv_union { + fn eq(&self, other: &__c_anonymous_elf64_auxv_union) -> bool { + unsafe { + self.a_val == other.a_val + || self.a_ptr == other.a_ptr + || self.a_fcn == other.a_fcn + } + } + } + impl Eq for __c_anonymous_elf64_auxv_union {} + } +} + +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; + +pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; +pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e; + +pub const MAP_32BIT: c_int = 0x00080000; +pub const MINSIGSTKSZ: size_t = 2048; // 512 * 4 + +pub const _MC_HASSEGS: u32 = 0x1; +pub const _MC_HASBASES: u32 = 0x2; +pub const _MC_HASFPXSTATE: u32 = 0x4; + +pub const _MC_FPFMT_NODEV: c_long = 0x10000; +pub const _MC_FPFMT_XMM: c_long = 0x10002; +pub const _MC_FPOWNED_NONE: c_long = 0x20000; +pub const _MC_FPOWNED_FPU: c_long = 0x20001; +pub const _MC_FPOWNED_PCB: c_long = 0x20002; + +pub const KINFO_FILE_SIZE: c_int = 1392; + +pub const TIOCTIMESTAMP: c_ulong = 0x40107459; diff --git a/http/vendor/libc/src/unix/bsd/freebsdlike/mod.rs b/http/vendor/libc/src/unix/bsd/freebsdlike/mod.rs new file mode 100644 index 0000000..38fe66a --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/freebsdlike/mod.rs @@ -0,0 +1,1986 @@ +use crate::off_t; +use crate::prelude::*; + +pub type mode_t = u16; +pub type pthread_attr_t = *mut c_void; +pub type rlim_t = i64; +pub type pthread_mutex_t = *mut c_void; +pub type pthread_mutexattr_t = *mut c_void; +pub type pthread_cond_t = *mut c_void; +pub type pthread_condattr_t = *mut c_void; +pub type pthread_rwlock_t = *mut c_void; +pub type pthread_rwlockattr_t = *mut c_void; +pub type pthread_key_t = c_int; +pub type tcflag_t = c_uint; +pub type speed_t = c_uint; +pub type nl_item = c_int; +pub type id_t = i64; +pub type vm_size_t = crate::uintptr_t; +pub type key_t = c_long; + +// elf.h + +pub type Elf32_Addr = u32; +pub type Elf32_Half = u16; +pub type Elf32_Lword = u64; +pub type Elf32_Off = u32; +pub type Elf32_Sword = i32; +pub type Elf32_Word = u32; + +pub type Elf64_Addr = u64; +pub type Elf64_Half = u16; +pub type Elf64_Lword = u64; +pub type Elf64_Off = u64; +pub type Elf64_Sword = i32; +pub type Elf64_Sxword = i64; +pub type Elf64_Word = u32; +pub type Elf64_Xword = u64; + +pub type iconv_t = *mut c_void; + +// It's an alias over "struct __kvm_t". However, its fields aren't supposed to be used directly, +// making the type definition system dependent. Better not bind it exactly. +pub type kvm_t = c_void; + +pub type posix_spawnattr_t = *mut c_void; +pub type posix_spawn_file_actions_t = *mut c_void; + +cfg_if! { + if #[cfg(target_pointer_width = "64")] { + type Elf_Addr = Elf64_Addr; + type Elf_Half = Elf64_Half; + type Elf_Phdr = Elf64_Phdr; + } else if #[cfg(target_pointer_width = "32")] { + type Elf_Addr = Elf32_Addr; + type Elf_Half = Elf32_Half; + type Elf_Phdr = Elf32_Phdr; + } +} + +// link.h + +extern_ty! { + pub enum timezone {} +} + +impl siginfo_t { + pub unsafe fn si_addr(&self) -> *mut c_void { + self.si_addr + } + + pub unsafe fn si_value(&self) -> crate::sigval { + self.si_value + } + + pub unsafe fn si_pid(&self) -> crate::pid_t { + self.si_pid + } + + pub unsafe fn si_uid(&self) -> crate::uid_t { + self.si_uid + } + + pub unsafe fn si_status(&self) -> c_int { + self.si_status + } +} + +s! { + pub struct in_addr { + pub s_addr: crate::in_addr_t, + } + + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct ip_mreqn { + pub imr_multiaddr: in_addr, + pub imr_address: in_addr, + pub imr_ifindex: c_int, + } + + pub struct ip_mreq_source { + pub imr_multiaddr: in_addr, + pub imr_sourceaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct glob_t { + pub gl_pathc: size_t, + pub gl_matchc: size_t, + pub gl_offs: size_t, + pub gl_flags: c_int, + pub gl_pathv: *mut *mut c_char, + __unused3: Padding<*mut c_void>, + __unused4: Padding<*mut c_void>, + __unused5: Padding<*mut c_void>, + __unused6: Padding<*mut c_void>, + __unused7: Padding<*mut c_void>, + __unused8: Padding<*mut c_void>, + } + + pub struct tm { + pub tm_sec: c_int, + pub tm_min: c_int, + pub tm_hour: c_int, + pub tm_mday: c_int, + pub tm_mon: c_int, + pub tm_year: c_int, + pub tm_wday: c_int, + pub tm_yday: c_int, + pub tm_isdst: c_int, + pub tm_gmtoff: c_long, + pub tm_zone: *mut c_char, + } + + pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: crate::socklen_t, + pub ai_canonname: *mut c_char, + pub ai_addr: *mut crate::sockaddr, + pub ai_next: *mut addrinfo, + } + + pub struct sigset_t { + bits: [u32; 4], + } + + pub struct siginfo_t { + pub si_signo: c_int, + pub si_errno: c_int, + pub si_code: c_int, + pub si_pid: crate::pid_t, + pub si_uid: crate::uid_t, + pub si_status: c_int, + pub si_addr: *mut c_void, + pub si_value: crate::sigval, + _pad1: Padding, + _pad2: Padding<[c_int; 7]>, + } + + pub struct sigaction { + pub sa_sigaction: crate::sighandler_t, + pub sa_flags: c_int, + pub sa_mask: sigset_t, + } + + pub struct sched_param { + pub sched_priority: c_int, + } + + pub struct Dl_info { + pub dli_fname: *const c_char, + pub dli_fbase: *mut c_void, + pub dli_sname: *const c_char, + pub dli_saddr: *mut c_void, + } + + pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: crate::sa_family_t, + pub sin_port: crate::in_port_t, + pub sin_addr: crate::in_addr, + pub sin_zero: [c_char; 8], + } + + pub struct termios { + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_cc: [crate::cc_t; crate::NCCS], + pub c_ispeed: crate::speed_t, + pub c_ospeed: crate::speed_t, + } + + pub struct flock { + pub l_start: off_t, + pub l_len: off_t, + pub l_pid: crate::pid_t, + pub l_type: c_short, + pub l_whence: c_short, + #[cfg(not(target_os = "dragonfly"))] + pub l_sysid: c_int, + } + + pub struct sf_hdtr { + pub headers: *mut crate::iovec, + pub hdr_cnt: c_int, + pub trailers: *mut crate::iovec, + pub trl_cnt: c_int, + } + + pub struct lconv { + pub decimal_point: *mut c_char, + pub thousands_sep: *mut c_char, + pub grouping: *mut c_char, + pub int_curr_symbol: *mut c_char, + pub currency_symbol: *mut c_char, + pub mon_decimal_point: *mut c_char, + pub mon_thousands_sep: *mut c_char, + pub mon_grouping: *mut c_char, + pub positive_sign: *mut c_char, + pub negative_sign: *mut c_char, + pub int_frac_digits: c_char, + pub frac_digits: c_char, + pub p_cs_precedes: c_char, + pub p_sep_by_space: c_char, + pub n_cs_precedes: c_char, + pub n_sep_by_space: c_char, + pub p_sign_posn: c_char, + pub n_sign_posn: c_char, + pub int_p_cs_precedes: c_char, + pub int_n_cs_precedes: c_char, + pub int_p_sep_by_space: c_char, + pub int_n_sep_by_space: c_char, + pub int_p_sign_posn: c_char, + pub int_n_sign_posn: c_char, + } + + pub struct cmsgcred { + pub cmcred_pid: crate::pid_t, + pub cmcred_uid: crate::uid_t, + pub cmcred_euid: crate::uid_t, + pub cmcred_gid: crate::gid_t, + pub cmcred_ngroups: c_short, + pub cmcred_groups: [crate::gid_t; CMGROUP_MAX], + } + + pub struct rtprio { + pub type_: c_ushort, + pub prio: c_ushort, + } + + pub struct in6_pktinfo { + pub ipi6_addr: crate::in6_addr, + pub ipi6_ifindex: c_uint, + } + + pub struct arphdr { + pub ar_hrd: u16, + pub ar_pro: u16, + pub ar_hln: u8, + pub ar_pln: u8, + pub ar_op: u16, + } + + pub struct timex { + pub modes: c_uint, + pub offset: c_long, + pub freq: c_long, + pub maxerror: c_long, + pub esterror: c_long, + pub status: c_int, + pub constant: c_long, + pub precision: c_long, + pub tolerance: c_long, + pub ppsfreq: c_long, + pub jitter: c_long, + pub shift: c_int, + pub stabil: c_long, + pub jitcnt: c_long, + pub calcnt: c_long, + pub errcnt: c_long, + pub stbcnt: c_long, + } + + pub struct ntptimeval { + pub time: crate::timespec, + pub maxerror: c_long, + pub esterror: c_long, + pub tai: c_long, + pub time_state: c_int, + } + + pub struct accept_filter_arg { + pub af_name: [c_char; 16], + af_arg: [c_char; 256 - 16], + } + + pub struct ptrace_io_desc { + pub piod_op: c_int, + pub piod_offs: *mut c_void, + pub piod_addr: *mut c_void, + pub piod_len: size_t, + } + + // bpf.h + + pub struct bpf_program { + pub bf_len: c_uint, + pub bf_insns: *mut bpf_insn, + } + + pub struct bpf_stat { + pub bs_recv: c_uint, + pub bs_drop: c_uint, + } + + pub struct bpf_version { + pub bv_major: c_ushort, + pub bv_minor: c_ushort, + } + + pub struct bpf_hdr { + pub bh_tstamp: crate::timeval, + pub bh_caplen: u32, + pub bh_datalen: u32, + pub bh_hdrlen: c_ushort, + } + + pub struct bpf_insn { + pub code: c_ushort, + pub jt: c_uchar, + pub jf: c_uchar, + pub k: u32, + } + + pub struct bpf_dltlist { + bfl_len: c_uint, + bfl_list: *mut c_uint, + } + + // elf.h + + pub struct Elf32_Phdr { + pub p_type: Elf32_Word, + pub p_offset: Elf32_Off, + pub p_vaddr: Elf32_Addr, + pub p_paddr: Elf32_Addr, + pub p_filesz: Elf32_Word, + pub p_memsz: Elf32_Word, + pub p_flags: Elf32_Word, + pub p_align: Elf32_Word, + } + + pub struct Elf64_Phdr { + pub p_type: Elf64_Word, + pub p_flags: Elf64_Word, + pub p_offset: Elf64_Off, + pub p_vaddr: Elf64_Addr, + pub p_paddr: Elf64_Addr, + pub p_filesz: Elf64_Xword, + pub p_memsz: Elf64_Xword, + pub p_align: Elf64_Xword, + } + + // link.h + + pub struct dl_phdr_info { + pub dlpi_addr: Elf_Addr, + pub dlpi_name: *const c_char, + pub dlpi_phdr: *const Elf_Phdr, + pub dlpi_phnum: Elf_Half, + pub dlpi_adds: c_ulonglong, + pub dlpi_subs: c_ulonglong, + pub dlpi_tls_modid: usize, + pub dlpi_tls_data: *mut c_void, + } + + pub struct ipc_perm { + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub mode: mode_t, + pub seq: c_ushort, + pub key: crate::key_t, + } + + pub struct eui64 { + pub octet: [u8; EUI64_LEN], + } + + pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: crate::sa_family_t, + __ss_pad1: Padding<[u8; 6]>, + __ss_align: i64, + __ss_pad2: Padding<[u8; 112]>, + } +} + +// Non-public helper constant +const SIZEOF_LONG: usize = size_of::(); + +#[deprecated( + since = "0.2.64", + note = "Can vary at runtime. Use sysconf(3) instead" +)] +pub const AIO_LISTIO_MAX: c_int = 16; +pub const AIO_CANCELED: c_int = 1; +pub const AIO_NOTCANCELED: c_int = 2; +pub const AIO_ALLDONE: c_int = 3; +pub const LIO_NOP: c_int = 0; +pub const LIO_WRITE: c_int = 1; +pub const LIO_READ: c_int = 2; +pub const LIO_WAIT: c_int = 1; +pub const LIO_NOWAIT: c_int = 0; + +pub const SIGEV_NONE: c_int = 0; +pub const SIGEV_SIGNAL: c_int = 1; +pub const SIGEV_THREAD: c_int = 2; +pub const SIGEV_KEVENT: c_int = 3; + +pub const CODESET: crate::nl_item = 0; +pub const D_T_FMT: crate::nl_item = 1; +pub const D_FMT: crate::nl_item = 2; +pub const T_FMT: crate::nl_item = 3; +pub const T_FMT_AMPM: crate::nl_item = 4; +pub const AM_STR: crate::nl_item = 5; +pub const PM_STR: crate::nl_item = 6; + +pub const DAY_1: crate::nl_item = 7; +pub const DAY_2: crate::nl_item = 8; +pub const DAY_3: crate::nl_item = 9; +pub const DAY_4: crate::nl_item = 10; +pub const DAY_5: crate::nl_item = 11; +pub const DAY_6: crate::nl_item = 12; +pub const DAY_7: crate::nl_item = 13; + +pub const ABDAY_1: crate::nl_item = 14; +pub const ABDAY_2: crate::nl_item = 15; +pub const ABDAY_3: crate::nl_item = 16; +pub const ABDAY_4: crate::nl_item = 17; +pub const ABDAY_5: crate::nl_item = 18; +pub const ABDAY_6: crate::nl_item = 19; +pub const ABDAY_7: crate::nl_item = 20; + +pub const MON_1: crate::nl_item = 21; +pub const MON_2: crate::nl_item = 22; +pub const MON_3: crate::nl_item = 23; +pub const MON_4: crate::nl_item = 24; +pub const MON_5: crate::nl_item = 25; +pub const MON_6: crate::nl_item = 26; +pub const MON_7: crate::nl_item = 27; +pub const MON_8: crate::nl_item = 28; +pub const MON_9: crate::nl_item = 29; +pub const MON_10: crate::nl_item = 30; +pub const MON_11: crate::nl_item = 31; +pub const MON_12: crate::nl_item = 32; + +pub const ABMON_1: crate::nl_item = 33; +pub const ABMON_2: crate::nl_item = 34; +pub const ABMON_3: crate::nl_item = 35; +pub const ABMON_4: crate::nl_item = 36; +pub const ABMON_5: crate::nl_item = 37; +pub const ABMON_6: crate::nl_item = 38; +pub const ABMON_7: crate::nl_item = 39; +pub const ABMON_8: crate::nl_item = 40; +pub const ABMON_9: crate::nl_item = 41; +pub const ABMON_10: crate::nl_item = 42; +pub const ABMON_11: crate::nl_item = 43; +pub const ABMON_12: crate::nl_item = 44; + +pub const ERA: crate::nl_item = 45; +pub const ERA_D_FMT: crate::nl_item = 46; +pub const ERA_D_T_FMT: crate::nl_item = 47; +pub const ERA_T_FMT: crate::nl_item = 48; +pub const ALT_DIGITS: crate::nl_item = 49; + +pub const RADIXCHAR: crate::nl_item = 50; +pub const THOUSEP: crate::nl_item = 51; + +pub const YESEXPR: crate::nl_item = 52; +pub const NOEXPR: crate::nl_item = 53; + +pub const YESSTR: crate::nl_item = 54; +pub const NOSTR: crate::nl_item = 55; + +pub const CRNCYSTR: crate::nl_item = 56; + +pub const D_MD_ORDER: crate::nl_item = 57; + +pub const ALTMON_1: crate::nl_item = 58; +pub const ALTMON_2: crate::nl_item = 59; +pub const ALTMON_3: crate::nl_item = 60; +pub const ALTMON_4: crate::nl_item = 61; +pub const ALTMON_5: crate::nl_item = 62; +pub const ALTMON_6: crate::nl_item = 63; +pub const ALTMON_7: crate::nl_item = 64; +pub const ALTMON_8: crate::nl_item = 65; +pub const ALTMON_9: crate::nl_item = 66; +pub const ALTMON_10: crate::nl_item = 67; +pub const ALTMON_11: crate::nl_item = 68; +pub const ALTMON_12: crate::nl_item = 69; + +pub const EXIT_FAILURE: c_int = 1; +pub const EXIT_SUCCESS: c_int = 0; +pub const EOF: c_int = -1; +pub const SEEK_SET: c_int = 0; +pub const SEEK_CUR: c_int = 1; +pub const SEEK_END: c_int = 2; +pub const SEEK_DATA: c_int = 3; +pub const SEEK_HOLE: c_int = 4; +pub const _IOFBF: c_int = 0; +pub const _IONBF: c_int = 2; +pub const _IOLBF: c_int = 1; +pub const BUFSIZ: c_uint = 1024; +pub const FOPEN_MAX: c_uint = 20; +pub const FILENAME_MAX: c_uint = 1024; +pub const L_tmpnam: c_uint = 1024; +pub const TMP_MAX: c_uint = 308915776; + +pub const O_NOCTTY: c_int = 32768; +pub const O_DIRECT: c_int = 0x00010000; + +pub const S_IFIFO: mode_t = 0o1_0000; +pub const S_IFCHR: mode_t = 0o2_0000; +pub const S_IFBLK: mode_t = 0o6_0000; +pub const S_IFDIR: mode_t = 0o4_0000; +pub const S_IFREG: mode_t = 0o10_0000; +pub const S_IFLNK: mode_t = 0o12_0000; +pub const S_IFSOCK: mode_t = 0o14_0000; +pub const S_IFMT: mode_t = 0o17_0000; +pub const S_IEXEC: mode_t = 0o0100; +pub const S_IWRITE: mode_t = 0o0200; +pub const S_IREAD: mode_t = 0o0400; +pub const S_IRWXU: mode_t = 0o0700; +pub const S_IXUSR: mode_t = 0o0100; +pub const S_IWUSR: mode_t = 0o0200; +pub const S_IRUSR: mode_t = 0o0400; +pub const S_IRWXG: mode_t = 0o0070; +pub const S_IXGRP: mode_t = 0o0010; +pub const S_IWGRP: mode_t = 0o0020; +pub const S_IRGRP: mode_t = 0o0040; +pub const S_IRWXO: mode_t = 0o0007; +pub const S_IXOTH: mode_t = 0o0001; +pub const S_IWOTH: mode_t = 0o0002; +pub const S_IROTH: mode_t = 0o0004; +pub const F_OK: c_int = 0; +pub const R_OK: c_int = 4; +pub const W_OK: c_int = 2; +pub const X_OK: c_int = 1; +pub const F_LOCK: c_int = 1; +pub const F_TEST: c_int = 3; +pub const F_TLOCK: c_int = 2; +pub const F_ULOCK: c_int = 0; +pub const F_DUPFD_CLOEXEC: c_int = 17; +pub const F_DUP2FD: c_int = 10; +pub const F_DUP2FD_CLOEXEC: c_int = 18; +pub const SIGHUP: c_int = 1; +pub const SIGINT: c_int = 2; +pub const SIGQUIT: c_int = 3; +pub const SIGILL: c_int = 4; +pub const SIGABRT: c_int = 6; +pub const SIGEMT: c_int = 7; +pub const SIGFPE: c_int = 8; +pub const SIGKILL: c_int = 9; +pub const SIGSEGV: c_int = 11; +pub const SIGPIPE: c_int = 13; +pub const SIGALRM: c_int = 14; +pub const SIGTERM: c_int = 15; + +pub const PROT_NONE: c_int = 0; +pub const PROT_READ: c_int = 1; +pub const PROT_WRITE: c_int = 2; +pub const PROT_EXEC: c_int = 4; + +pub const MAP_FILE: c_int = 0x0000; +pub const MAP_SHARED: c_int = 0x0001; +pub const MAP_PRIVATE: c_int = 0x0002; +pub const MAP_FIXED: c_int = 0x0010; +pub const MAP_ANON: c_int = 0x1000; +pub const MAP_ANONYMOUS: c_int = MAP_ANON; + +pub const MAP_FAILED: *mut c_void = !0 as *mut c_void; + +pub const MCL_CURRENT: c_int = 0x0001; +pub const MCL_FUTURE: c_int = 0x0002; + +pub const MNT_EXPUBLIC: c_int = 0x20000000; +pub const MNT_NOATIME: c_int = 0x10000000; +pub const MNT_NOCLUSTERR: c_int = 0x40000000; +pub const MNT_NOCLUSTERW: c_int = 0x80000000; +pub const MNT_NOSYMFOLLOW: c_int = 0x00400000; +pub const MNT_SOFTDEP: c_int = 0x00200000; +pub const MNT_SUIDDIR: c_int = 0x00100000; +pub const MNT_EXRDONLY: c_int = 0x00000080; +pub const MNT_DEFEXPORTED: c_int = 0x00000200; +pub const MNT_EXPORTANON: c_int = 0x00000400; +pub const MNT_EXKERB: c_int = 0x00000800; +pub const MNT_DELEXPORT: c_int = 0x00020000; + +pub const MS_SYNC: c_int = 0x0000; +pub const MS_ASYNC: c_int = 0x0001; +pub const MS_INVALIDATE: c_int = 0x0002; + +pub const EPERM: c_int = 1; +pub const ENOENT: c_int = 2; +pub const ESRCH: c_int = 3; +pub const EINTR: c_int = 4; +pub const EIO: c_int = 5; +pub const ENXIO: c_int = 6; +pub const E2BIG: c_int = 7; +pub const ENOEXEC: c_int = 8; +pub const EBADF: c_int = 9; +pub const ECHILD: c_int = 10; +pub const EDEADLK: c_int = 11; +pub const ENOMEM: c_int = 12; +pub const EACCES: c_int = 13; +pub const EFAULT: c_int = 14; +pub const ENOTBLK: c_int = 15; +pub const EBUSY: c_int = 16; +pub const EEXIST: c_int = 17; +pub const EXDEV: c_int = 18; +pub const ENODEV: c_int = 19; +pub const ENOTDIR: c_int = 20; +pub const EISDIR: c_int = 21; +pub const EINVAL: c_int = 22; +pub const ENFILE: c_int = 23; +pub const EMFILE: c_int = 24; +pub const ENOTTY: c_int = 25; +pub const ETXTBSY: c_int = 26; +pub const EFBIG: c_int = 27; +pub const ENOSPC: c_int = 28; +pub const ESPIPE: c_int = 29; +pub const EROFS: c_int = 30; +pub const EMLINK: c_int = 31; +pub const EPIPE: c_int = 32; +pub const EDOM: c_int = 33; +pub const ERANGE: c_int = 34; +pub const EAGAIN: c_int = 35; +pub const EWOULDBLOCK: c_int = 35; +pub const EINPROGRESS: c_int = 36; +pub const EALREADY: c_int = 37; +pub const ENOTSOCK: c_int = 38; +pub const EDESTADDRREQ: c_int = 39; +pub const EMSGSIZE: c_int = 40; +pub const EPROTOTYPE: c_int = 41; +pub const ENOPROTOOPT: c_int = 42; +pub const EPROTONOSUPPORT: c_int = 43; +pub const ESOCKTNOSUPPORT: c_int = 44; +pub const EOPNOTSUPP: c_int = 45; +pub const ENOTSUP: c_int = EOPNOTSUPP; +pub const EPFNOSUPPORT: c_int = 46; +pub const EAFNOSUPPORT: c_int = 47; +pub const EADDRINUSE: c_int = 48; +pub const EADDRNOTAVAIL: c_int = 49; +pub const ENETDOWN: c_int = 50; +pub const ENETUNREACH: c_int = 51; +pub const ENETRESET: c_int = 52; +pub const ECONNABORTED: c_int = 53; +pub const ECONNRESET: c_int = 54; +pub const ENOBUFS: c_int = 55; +pub const EISCONN: c_int = 56; +pub const ENOTCONN: c_int = 57; +pub const ESHUTDOWN: c_int = 58; +pub const ETOOMANYREFS: c_int = 59; +pub const ETIMEDOUT: c_int = 60; +pub const ECONNREFUSED: c_int = 61; +pub const ELOOP: c_int = 62; +pub const ENAMETOOLONG: c_int = 63; +pub const EHOSTDOWN: c_int = 64; +pub const EHOSTUNREACH: c_int = 65; +pub const ENOTEMPTY: c_int = 66; +pub const EPROCLIM: c_int = 67; +pub const EUSERS: c_int = 68; +pub const EDQUOT: c_int = 69; +pub const ESTALE: c_int = 70; +pub const EREMOTE: c_int = 71; +pub const EBADRPC: c_int = 72; +pub const ERPCMISMATCH: c_int = 73; +pub const EPROGUNAVAIL: c_int = 74; +pub const EPROGMISMATCH: c_int = 75; +pub const EPROCUNAVAIL: c_int = 76; +pub const ENOLCK: c_int = 77; +pub const ENOSYS: c_int = 78; +pub const EFTYPE: c_int = 79; +pub const EAUTH: c_int = 80; +pub const ENEEDAUTH: c_int = 81; +pub const EIDRM: c_int = 82; +pub const ENOMSG: c_int = 83; +pub const EOVERFLOW: c_int = 84; +pub const ECANCELED: c_int = 85; +pub const EILSEQ: c_int = 86; +pub const ENOATTR: c_int = 87; +pub const EDOOFUS: c_int = 88; +pub const EBADMSG: c_int = 89; +pub const EMULTIHOP: c_int = 90; +pub const ENOLINK: c_int = 91; +pub const EPROTO: c_int = 92; + +pub const POLLSTANDARD: c_short = crate::POLLIN + | crate::POLLPRI + | crate::POLLOUT + | crate::POLLRDNORM + | crate::POLLRDBAND + | crate::POLLWRBAND + | crate::POLLERR + | crate::POLLHUP + | crate::POLLNVAL; + +pub const AI_PASSIVE: c_int = 0x00000001; +pub const AI_CANONNAME: c_int = 0x00000002; +pub const AI_NUMERICHOST: c_int = 0x00000004; +pub const AI_NUMERICSERV: c_int = 0x00000008; +pub const AI_ALL: c_int = 0x00000100; +pub const AI_ADDRCONFIG: c_int = 0x00000400; +pub const AI_V4MAPPED: c_int = 0x00000800; + +pub const EAI_AGAIN: c_int = 2; +pub const EAI_BADFLAGS: c_int = 3; +pub const EAI_FAIL: c_int = 4; +pub const EAI_FAMILY: c_int = 5; +pub const EAI_MEMORY: c_int = 6; +pub const EAI_NONAME: c_int = 8; +pub const EAI_SERVICE: c_int = 9; +pub const EAI_SOCKTYPE: c_int = 10; +pub const EAI_SYSTEM: c_int = 11; +pub const EAI_OVERFLOW: c_int = 14; + +pub const F_DUPFD: c_int = 0; +pub const F_GETFD: c_int = 1; +pub const F_SETFD: c_int = 2; +pub const F_GETFL: c_int = 3; +pub const F_SETFL: c_int = 4; + +pub const SIGTRAP: c_int = 5; + +pub const GLOB_APPEND: c_int = 0x0001; +pub const GLOB_DOOFFS: c_int = 0x0002; +pub const GLOB_ERR: c_int = 0x0004; +pub const GLOB_MARK: c_int = 0x0008; +pub const GLOB_NOCHECK: c_int = 0x0010; +pub const GLOB_NOSORT: c_int = 0x0020; +pub const GLOB_NOESCAPE: c_int = 0x2000; + +pub const GLOB_NOSPACE: c_int = -1; +pub const GLOB_ABORTED: c_int = -2; +pub const GLOB_NOMATCH: c_int = -3; + +pub const POSIX_MADV_NORMAL: c_int = 0; +pub const POSIX_MADV_RANDOM: c_int = 1; +pub const POSIX_MADV_SEQUENTIAL: c_int = 2; +pub const POSIX_MADV_WILLNEED: c_int = 3; +pub const POSIX_MADV_DONTNEED: c_int = 4; + +pub const PTHREAD_BARRIER_SERIAL_THREAD: c_int = -1; +pub const PTHREAD_PROCESS_PRIVATE: c_int = 0; +pub const PTHREAD_PROCESS_SHARED: c_int = 1; +pub const PTHREAD_CREATE_JOINABLE: c_int = 0; +pub const PTHREAD_CREATE_DETACHED: c_int = 1; + +pub const RLIMIT_CPU: c_int = 0; +pub const RLIMIT_FSIZE: c_int = 1; +pub const RLIMIT_DATA: c_int = 2; +pub const RLIMIT_STACK: c_int = 3; +pub const RLIMIT_CORE: c_int = 4; +pub const RLIMIT_RSS: c_int = 5; +pub const RLIMIT_MEMLOCK: c_int = 6; +pub const RLIMIT_NPROC: c_int = 7; +pub const RLIMIT_NOFILE: c_int = 8; +pub const RLIMIT_SBSIZE: c_int = 9; +pub const RLIMIT_VMEM: c_int = 10; +pub const RLIMIT_AS: c_int = RLIMIT_VMEM; +pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff; + +pub const RUSAGE_SELF: c_int = 0; +pub const RUSAGE_CHILDREN: c_int = -1; + +pub const CLOCK_REALTIME: crate::clockid_t = 0; +pub const CLOCK_VIRTUAL: crate::clockid_t = 1; +pub const CLOCK_PROF: crate::clockid_t = 2; +pub const CLOCK_MONOTONIC: crate::clockid_t = 4; +pub const CLOCK_UPTIME: crate::clockid_t = 5; +pub const CLOCK_UPTIME_PRECISE: crate::clockid_t = 7; +pub const CLOCK_UPTIME_FAST: crate::clockid_t = 8; +pub const CLOCK_REALTIME_PRECISE: crate::clockid_t = 9; +pub const CLOCK_REALTIME_FAST: crate::clockid_t = 10; +pub const CLOCK_MONOTONIC_PRECISE: crate::clockid_t = 11; +pub const CLOCK_MONOTONIC_FAST: crate::clockid_t = 12; +pub const CLOCK_SECOND: crate::clockid_t = 13; +pub const CLOCK_THREAD_CPUTIME_ID: crate::clockid_t = 14; +pub const CLOCK_PROCESS_CPUTIME_ID: crate::clockid_t = 15; + +pub const MADV_NORMAL: c_int = 0; +pub const MADV_RANDOM: c_int = 1; +pub const MADV_SEQUENTIAL: c_int = 2; +pub const MADV_WILLNEED: c_int = 3; +pub const MADV_DONTNEED: c_int = 4; +pub const MADV_FREE: c_int = 5; +pub const MADV_NOSYNC: c_int = 6; +pub const MADV_AUTOSYNC: c_int = 7; +pub const MADV_NOCORE: c_int = 8; +pub const MADV_CORE: c_int = 9; + +pub const MINCORE_INCORE: c_int = 0x1; +pub const MINCORE_REFERENCED: c_int = 0x2; +pub const MINCORE_MODIFIED: c_int = 0x4; +pub const MINCORE_REFERENCED_OTHER: c_int = 0x8; +pub const MINCORE_MODIFIED_OTHER: c_int = 0x10; + +pub const AF_UNSPEC: c_int = 0; +pub const AF_LOCAL: c_int = 1; +pub const AF_UNIX: c_int = AF_LOCAL; +pub const AF_INET: c_int = 2; +pub const AF_IMPLINK: c_int = 3; +pub const AF_PUP: c_int = 4; +pub const AF_CHAOS: c_int = 5; +pub const AF_NETBIOS: c_int = 6; +pub const AF_ISO: c_int = 7; +pub const AF_OSI: c_int = AF_ISO; +pub const AF_ECMA: c_int = 8; +pub const AF_DATAKIT: c_int = 9; +pub const AF_CCITT: c_int = 10; +pub const AF_SNA: c_int = 11; +pub const AF_DECnet: c_int = 12; +pub const AF_DLI: c_int = 13; +pub const AF_LAT: c_int = 14; +pub const AF_HYLINK: c_int = 15; +pub const AF_APPLETALK: c_int = 16; +pub const AF_ROUTE: c_int = 17; +pub const AF_LINK: c_int = 18; +pub const pseudo_AF_XTP: c_int = 19; +pub const AF_COIP: c_int = 20; +pub const AF_CNT: c_int = 21; +pub const pseudo_AF_RTIP: c_int = 22; +pub const AF_IPX: c_int = 23; +pub const AF_SIP: c_int = 24; +pub const pseudo_AF_PIP: c_int = 25; +pub const AF_ISDN: c_int = 26; +pub const AF_E164: c_int = AF_ISDN; +pub const pseudo_AF_KEY: c_int = 27; +pub const AF_INET6: c_int = 28; +pub const AF_NATM: c_int = 29; +pub const AF_ATM: c_int = 30; +pub const pseudo_AF_HDRCMPLT: c_int = 31; +pub const AF_NETGRAPH: c_int = 32; + +pub const PF_UNSPEC: c_int = AF_UNSPEC; +pub const PF_LOCAL: c_int = AF_LOCAL; +pub const PF_UNIX: c_int = PF_LOCAL; +pub const PF_INET: c_int = AF_INET; +pub const PF_IMPLINK: c_int = AF_IMPLINK; +pub const PF_PUP: c_int = AF_PUP; +pub const PF_CHAOS: c_int = AF_CHAOS; +pub const PF_NETBIOS: c_int = AF_NETBIOS; +pub const PF_ISO: c_int = AF_ISO; +pub const PF_OSI: c_int = AF_ISO; +pub const PF_ECMA: c_int = AF_ECMA; +pub const PF_DATAKIT: c_int = AF_DATAKIT; +pub const PF_CCITT: c_int = AF_CCITT; +pub const PF_SNA: c_int = AF_SNA; +pub const PF_DECnet: c_int = AF_DECnet; +pub const PF_DLI: c_int = AF_DLI; +pub const PF_LAT: c_int = AF_LAT; +pub const PF_HYLINK: c_int = AF_HYLINK; +pub const PF_APPLETALK: c_int = AF_APPLETALK; +pub const PF_ROUTE: c_int = AF_ROUTE; +pub const PF_LINK: c_int = AF_LINK; +pub const PF_XTP: c_int = pseudo_AF_XTP; +pub const PF_COIP: c_int = AF_COIP; +pub const PF_CNT: c_int = AF_CNT; +pub const PF_SIP: c_int = AF_SIP; +pub const PF_IPX: c_int = AF_IPX; +pub const PF_RTIP: c_int = pseudo_AF_RTIP; +pub const PF_PIP: c_int = pseudo_AF_PIP; +pub const PF_ISDN: c_int = AF_ISDN; +pub const PF_KEY: c_int = pseudo_AF_KEY; +pub const PF_INET6: c_int = AF_INET6; +pub const PF_NATM: c_int = AF_NATM; +pub const PF_ATM: c_int = AF_ATM; +pub const PF_NETGRAPH: c_int = AF_NETGRAPH; + +pub const PIOD_READ_D: c_int = 1; +pub const PIOD_WRITE_D: c_int = 2; +pub const PIOD_READ_I: c_int = 3; +pub const PIOD_WRITE_I: c_int = 4; + +pub const PT_TRACE_ME: c_int = 0; +pub const PT_READ_I: c_int = 1; +pub const PT_READ_D: c_int = 2; +pub const PT_WRITE_I: c_int = 4; +pub const PT_WRITE_D: c_int = 5; +pub const PT_CONTINUE: c_int = 7; +pub const PT_KILL: c_int = 8; +pub const PT_STEP: c_int = 9; +pub const PT_ATTACH: c_int = 10; +pub const PT_DETACH: c_int = 11; +pub const PT_IO: c_int = 12; + +pub const SOMAXCONN: c_int = 128; + +pub const MSG_OOB: c_int = 0x00000001; +pub const MSG_PEEK: c_int = 0x00000002; +pub const MSG_DONTROUTE: c_int = 0x00000004; +pub const MSG_EOR: c_int = 0x00000008; +pub const MSG_TRUNC: c_int = 0x00000010; +pub const MSG_CTRUNC: c_int = 0x00000020; +pub const MSG_WAITALL: c_int = 0x00000040; +pub const MSG_DONTWAIT: c_int = 0x00000080; +pub const MSG_EOF: c_int = 0x00000100; + +pub const SCM_TIMESTAMP: c_int = 0x02; +pub const SCM_CREDS: c_int = 0x03; + +pub const SOCK_STREAM: c_int = 1; +pub const SOCK_DGRAM: c_int = 2; +pub const SOCK_RAW: c_int = 3; +pub const SOCK_RDM: c_int = 4; +pub const SOCK_SEQPACKET: c_int = 5; +pub const SOCK_CLOEXEC: c_int = 0x10000000; +pub const SOCK_NONBLOCK: c_int = 0x20000000; +pub const SOCK_MAXADDRLEN: c_int = 255; +pub const IP_TTL: c_int = 4; +pub const IP_HDRINCL: c_int = 2; +pub const IP_RECVDSTADDR: c_int = 7; +pub const IP_SENDSRCADDR: c_int = IP_RECVDSTADDR; +pub const IP_ADD_MEMBERSHIP: c_int = 12; +pub const IP_DROP_MEMBERSHIP: c_int = 13; +pub const IP_RECVIF: c_int = 20; +pub const IP_RECVTTL: c_int = 65; +pub const IP_MINTTL: c_int = 66; +pub const IPV6_RECVHOPLIMIT: c_int = 37; +pub const IPV6_JOIN_GROUP: c_int = 12; +pub const IPV6_LEAVE_GROUP: c_int = 13; +pub const IPV6_CHECKSUM: c_int = 26; +pub const IPV6_RECVPKTINFO: c_int = 36; +pub const IPV6_PKTINFO: c_int = 46; +pub const IPV6_HOPLIMIT: c_int = 47; +pub const IPV6_RECVTCLASS: c_int = 57; +pub const IPV6_TCLASS: c_int = 61; +pub const IP_ADD_SOURCE_MEMBERSHIP: c_int = 70; +pub const IP_DROP_SOURCE_MEMBERSHIP: c_int = 71; +pub const IP_BLOCK_SOURCE: c_int = 72; +pub const IP_UNBLOCK_SOURCE: c_int = 73; + +pub const TCP_NOPUSH: c_int = 4; +pub const TCP_NOOPT: c_int = 8; +pub const TCP_KEEPIDLE: c_int = 256; +pub const TCP_KEEPINTVL: c_int = 512; +pub const TCP_KEEPCNT: c_int = 1024; + +pub const SOL_SOCKET: c_int = 0xffff; +pub const SO_DEBUG: c_int = 0x01; +pub const SO_ACCEPTCONN: c_int = 0x0002; +pub const SO_REUSEADDR: c_int = 0x0004; +pub const SO_KEEPALIVE: c_int = 0x0008; +pub const SO_DONTROUTE: c_int = 0x0010; +pub const SO_BROADCAST: c_int = 0x0020; +pub const SO_USELOOPBACK: c_int = 0x0040; +pub const SO_LINGER: c_int = 0x0080; +pub const SO_OOBINLINE: c_int = 0x0100; +pub const SO_REUSEPORT: c_int = 0x0200; +pub const SO_TIMESTAMP: c_int = 0x0400; +pub const SO_NOSIGPIPE: c_int = 0x0800; +pub const SO_ACCEPTFILTER: c_int = 0x1000; +pub const SO_SNDBUF: c_int = 0x1001; +pub const SO_RCVBUF: c_int = 0x1002; +pub const SO_SNDLOWAT: c_int = 0x1003; +pub const SO_RCVLOWAT: c_int = 0x1004; +pub const SO_SNDTIMEO: c_int = 0x1005; +pub const SO_RCVTIMEO: c_int = 0x1006; +pub const SO_ERROR: c_int = 0x1007; +pub const SO_TYPE: c_int = 0x1008; + +pub const LOCAL_PEERCRED: c_int = 1; + +// net/route.h +pub const RTF_XRESOLVE: c_int = 0x200; +pub const RTF_LLINFO: c_int = 0x400; +pub const RTF_PROTO3: c_int = 0x40000; +pub const RTF_PINNED: c_int = 0x100000; +pub const RTF_LOCAL: c_int = 0x200000; +pub const RTF_BROADCAST: c_int = 0x400000; +pub const RTF_MULTICAST: c_int = 0x800000; + +pub const RTM_LOCK: c_int = 0x8; +pub const RTM_RESOLVE: c_int = 0xb; +pub const RTM_NEWADDR: c_int = 0xc; +pub const RTM_DELADDR: c_int = 0xd; +pub const RTM_IFINFO: c_int = 0xe; +pub const RTM_NEWMADDR: c_int = 0xf; +pub const RTM_DELMADDR: c_int = 0x10; +pub const RTM_IFANNOUNCE: c_int = 0x11; +pub const RTM_IEEE80211: c_int = 0x12; + +pub const SHUT_RD: c_int = 0; +pub const SHUT_WR: c_int = 1; +pub const SHUT_RDWR: c_int = 2; + +pub const LOCK_SH: c_int = 1; +pub const LOCK_EX: c_int = 2; +pub const LOCK_NB: c_int = 4; +pub const LOCK_UN: c_int = 8; + +pub const MAP_COPY: c_int = 0x0002; +#[doc(hidden)] +#[deprecated( + since = "0.2.54", + note = "Removed in FreeBSD 11, unused in DragonFlyBSD" +)] +pub const MAP_RENAME: c_int = 0x0020; +#[doc(hidden)] +#[deprecated( + since = "0.2.54", + note = "Removed in FreeBSD 11, unused in DragonFlyBSD" +)] +pub const MAP_NORESERVE: c_int = 0x0040; +pub const MAP_HASSEMAPHORE: c_int = 0x0200; +pub const MAP_STACK: c_int = 0x0400; +pub const MAP_NOSYNC: c_int = 0x0800; +pub const MAP_NOCORE: c_int = 0x020000; + +pub const IPPROTO_RAW: c_int = 255; + +pub const _PC_LINK_MAX: c_int = 1; +pub const _PC_MAX_CANON: c_int = 2; +pub const _PC_MAX_INPUT: c_int = 3; +pub const _PC_NAME_MAX: c_int = 4; +pub const _PC_PATH_MAX: c_int = 5; +pub const _PC_PIPE_BUF: c_int = 6; +pub const _PC_CHOWN_RESTRICTED: c_int = 7; +pub const _PC_NO_TRUNC: c_int = 8; +pub const _PC_VDISABLE: c_int = 9; +pub const _PC_ALLOC_SIZE_MIN: c_int = 10; +pub const _PC_FILESIZEBITS: c_int = 12; +pub const _PC_REC_INCR_XFER_SIZE: c_int = 14; +pub const _PC_REC_MAX_XFER_SIZE: c_int = 15; +pub const _PC_REC_MIN_XFER_SIZE: c_int = 16; +pub const _PC_REC_XFER_ALIGN: c_int = 17; +pub const _PC_SYMLINK_MAX: c_int = 18; +pub const _PC_MIN_HOLE_SIZE: c_int = 21; +pub const _PC_ASYNC_IO: c_int = 53; +pub const _PC_PRIO_IO: c_int = 54; +pub const _PC_SYNC_IO: c_int = 55; +pub const _PC_ACL_EXTENDED: c_int = 59; +pub const _PC_ACL_PATH_MAX: c_int = 60; +pub const _PC_CAP_PRESENT: c_int = 61; +pub const _PC_INF_PRESENT: c_int = 62; +pub const _PC_MAC_PRESENT: c_int = 63; + +pub const _SC_ARG_MAX: c_int = 1; +pub const _SC_CHILD_MAX: c_int = 2; +pub const _SC_CLK_TCK: c_int = 3; +pub const _SC_NGROUPS_MAX: c_int = 4; +pub const _SC_OPEN_MAX: c_int = 5; +pub const _SC_JOB_CONTROL: c_int = 6; +pub const _SC_SAVED_IDS: c_int = 7; +pub const _SC_VERSION: c_int = 8; +pub const _SC_BC_BASE_MAX: c_int = 9; +pub const _SC_BC_DIM_MAX: c_int = 10; +pub const _SC_BC_SCALE_MAX: c_int = 11; +pub const _SC_BC_STRING_MAX: c_int = 12; +pub const _SC_COLL_WEIGHTS_MAX: c_int = 13; +pub const _SC_EXPR_NEST_MAX: c_int = 14; +pub const _SC_LINE_MAX: c_int = 15; +pub const _SC_RE_DUP_MAX: c_int = 16; +pub const _SC_2_VERSION: c_int = 17; +pub const _SC_2_C_BIND: c_int = 18; +pub const _SC_2_C_DEV: c_int = 19; +pub const _SC_2_CHAR_TERM: c_int = 20; +pub const _SC_2_FORT_DEV: c_int = 21; +pub const _SC_2_FORT_RUN: c_int = 22; +pub const _SC_2_LOCALEDEF: c_int = 23; +pub const _SC_2_SW_DEV: c_int = 24; +pub const _SC_2_UPE: c_int = 25; +pub const _SC_STREAM_MAX: c_int = 26; +pub const _SC_TZNAME_MAX: c_int = 27; +pub const _SC_ASYNCHRONOUS_IO: c_int = 28; +pub const _SC_MAPPED_FILES: c_int = 29; +pub const _SC_MEMLOCK: c_int = 30; +pub const _SC_MEMLOCK_RANGE: c_int = 31; +pub const _SC_MEMORY_PROTECTION: c_int = 32; +pub const _SC_MESSAGE_PASSING: c_int = 33; +pub const _SC_PRIORITIZED_IO: c_int = 34; +pub const _SC_PRIORITY_SCHEDULING: c_int = 35; +pub const _SC_REALTIME_SIGNALS: c_int = 36; +pub const _SC_SEMAPHORES: c_int = 37; +pub const _SC_FSYNC: c_int = 38; +pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 39; +pub const _SC_SYNCHRONIZED_IO: c_int = 40; +pub const _SC_TIMERS: c_int = 41; +pub const _SC_AIO_LISTIO_MAX: c_int = 42; +pub const _SC_AIO_MAX: c_int = 43; +pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 44; +pub const _SC_DELAYTIMER_MAX: c_int = 45; +pub const _SC_MQ_OPEN_MAX: c_int = 46; +pub const _SC_PAGESIZE: c_int = 47; +pub const _SC_PAGE_SIZE: c_int = _SC_PAGESIZE; +pub const _SC_RTSIG_MAX: c_int = 48; +pub const _SC_SEM_NSEMS_MAX: c_int = 49; +pub const _SC_SEM_VALUE_MAX: c_int = 50; +pub const _SC_SIGQUEUE_MAX: c_int = 51; +pub const _SC_TIMER_MAX: c_int = 52; +pub const _SC_IOV_MAX: c_int = 56; +pub const _SC_NPROCESSORS_CONF: c_int = 57; +pub const _SC_2_PBS: c_int = 59; +pub const _SC_2_PBS_ACCOUNTING: c_int = 60; +pub const _SC_2_PBS_CHECKPOINT: c_int = 61; +pub const _SC_2_PBS_LOCATE: c_int = 62; +pub const _SC_2_PBS_MESSAGE: c_int = 63; +pub const _SC_2_PBS_TRACK: c_int = 64; +pub const _SC_ADVISORY_INFO: c_int = 65; +pub const _SC_BARRIERS: c_int = 66; +pub const _SC_CLOCK_SELECTION: c_int = 67; +pub const _SC_CPUTIME: c_int = 68; +pub const _SC_FILE_LOCKING: c_int = 69; +pub const _SC_NPROCESSORS_ONLN: c_int = 58; +pub const _SC_GETGR_R_SIZE_MAX: c_int = 70; +pub const _SC_GETPW_R_SIZE_MAX: c_int = 71; +pub const _SC_HOST_NAME_MAX: c_int = 72; +pub const _SC_LOGIN_NAME_MAX: c_int = 73; +pub const _SC_MONOTONIC_CLOCK: c_int = 74; +pub const _SC_MQ_PRIO_MAX: c_int = 75; +pub const _SC_READER_WRITER_LOCKS: c_int = 76; +pub const _SC_REGEXP: c_int = 77; +pub const _SC_SHELL: c_int = 78; +pub const _SC_SPAWN: c_int = 79; +pub const _SC_SPIN_LOCKS: c_int = 80; +pub const _SC_SPORADIC_SERVER: c_int = 81; +pub const _SC_THREAD_ATTR_STACKADDR: c_int = 82; +pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 83; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 85; +pub const _SC_THREAD_KEYS_MAX: c_int = 86; +pub const _SC_THREAD_PRIO_INHERIT: c_int = 87; +pub const _SC_THREAD_PRIO_PROTECT: c_int = 88; +pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 89; +pub const _SC_THREAD_PROCESS_SHARED: c_int = 90; +pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 91; +pub const _SC_THREAD_SPORADIC_SERVER: c_int = 92; +pub const _SC_THREAD_STACK_MIN: c_int = 93; +pub const _SC_THREAD_THREADS_MAX: c_int = 94; +pub const _SC_TIMEOUTS: c_int = 95; +pub const _SC_THREADS: c_int = 96; +pub const _SC_TRACE: c_int = 97; +pub const _SC_TRACE_EVENT_FILTER: c_int = 98; +pub const _SC_TRACE_INHERIT: c_int = 99; +pub const _SC_TRACE_LOG: c_int = 100; +pub const _SC_TTY_NAME_MAX: c_int = 101; +pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 102; +pub const _SC_V6_ILP32_OFF32: c_int = 103; +pub const _SC_V6_ILP32_OFFBIG: c_int = 104; +pub const _SC_V6_LP64_OFF64: c_int = 105; +pub const _SC_V6_LPBIG_OFFBIG: c_int = 106; +pub const _SC_ATEXIT_MAX: c_int = 107; +pub const _SC_XOPEN_CRYPT: c_int = 108; +pub const _SC_XOPEN_ENH_I18N: c_int = 109; +pub const _SC_XOPEN_LEGACY: c_int = 110; +pub const _SC_XOPEN_REALTIME: c_int = 111; +pub const _SC_XOPEN_REALTIME_THREADS: c_int = 112; +pub const _SC_XOPEN_SHM: c_int = 113; +pub const _SC_XOPEN_STREAMS: c_int = 114; +pub const _SC_XOPEN_UNIX: c_int = 115; +pub const _SC_XOPEN_VERSION: c_int = 116; +pub const _SC_XOPEN_XCU_VERSION: c_int = 117; +pub const _SC_IPV6: c_int = 118; +pub const _SC_RAW_SOCKETS: c_int = 119; +pub const _SC_SYMLOOP_MAX: c_int = 120; +pub const _SC_PHYS_PAGES: c_int = 121; + +pub const _CS_PATH: c_int = 1; + +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = ptr::null_mut(); +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = ptr::null_mut(); +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = ptr::null_mut(); +pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 1; +pub const PTHREAD_MUTEX_RECURSIVE: c_int = 2; +pub const PTHREAD_MUTEX_NORMAL: c_int = 3; +pub const PTHREAD_MUTEX_DEFAULT: c_int = PTHREAD_MUTEX_ERRORCHECK; + +pub const SCHED_FIFO: c_int = 1; +pub const SCHED_OTHER: c_int = 2; +pub const SCHED_RR: c_int = 3; + +pub const FD_SETSIZE: usize = 1024; + +pub const ST_NOSUID: c_ulong = 2; + +pub const NI_MAXHOST: size_t = 1025; + +pub const XUCRED_VERSION: c_uint = 0; + +pub const RTLD_LOCAL: c_int = 0; +pub const RTLD_NODELETE: c_int = 0x1000; +pub const RTLD_NOLOAD: c_int = 0x2000; +pub const RTLD_GLOBAL: c_int = 0x100; + +pub const LOG_NTP: c_int = 12 << 3; +pub const LOG_SECURITY: c_int = 13 << 3; +pub const LOG_CONSOLE: c_int = 14 << 3; +pub const LOG_NFACILITIES: c_int = 24; + +pub const TIOCEXCL: c_ulong = 0x2000740d; +pub const TIOCNXCL: c_ulong = 0x2000740e; +pub const TIOCFLUSH: c_ulong = 0x80047410; +pub const TIOCGETA: c_ulong = 0x402c7413; +pub const TIOCSETA: c_ulong = 0x802c7414; +pub const TIOCSETAW: c_ulong = 0x802c7415; +pub const TIOCSETAF: c_ulong = 0x802c7416; +pub const TIOCGETD: c_ulong = 0x4004741a; +pub const TIOCSETD: c_ulong = 0x8004741b; +pub const TIOCGDRAINWAIT: c_ulong = 0x40047456; +pub const TIOCSDRAINWAIT: c_ulong = 0x80047457; +#[cfg_attr( + not(target_os = "dragonfly"), + deprecated = "unused since FreeBSD 8, removed in FreeBSD 15" +)] +pub const TIOCMGDTRWAIT: c_ulong = 0x4004745a; +#[cfg_attr( + not(target_os = "dragonfly"), + deprecated = "unused since FreeBSD 8, removed in FreeBSD 15" +)] +pub const TIOCMSDTRWAIT: c_ulong = 0x8004745b; +pub const TIOCDRAIN: c_ulong = 0x2000745e; +pub const TIOCEXT: c_ulong = 0x80047460; +pub const TIOCSCTTY: c_ulong = 0x20007461; +pub const TIOCCONS: c_ulong = 0x80047462; +pub const TIOCGSID: c_ulong = 0x40047463; +pub const TIOCSTAT: c_ulong = 0x20007465; +pub const TIOCUCNTL: c_ulong = 0x80047466; +pub const TIOCSWINSZ: c_ulong = 0x80087467; +pub const TIOCGWINSZ: c_ulong = 0x40087468; +pub const TIOCMGET: c_ulong = 0x4004746a; +pub const TIOCM_LE: c_int = 0x1; +pub const TIOCM_DTR: c_int = 0x2; +pub const TIOCM_RTS: c_int = 0x4; +pub const TIOCM_ST: c_int = 0x8; +pub const TIOCM_SR: c_int = 0x10; +pub const TIOCM_CTS: c_int = 0x20; +pub const TIOCM_RI: c_int = 0x80; +pub const TIOCM_DSR: c_int = 0x100; +pub const TIOCM_CD: c_int = 0x40; +pub const TIOCM_CAR: c_int = 0x40; +pub const TIOCM_RNG: c_int = 0x80; +pub const TIOCMBIC: c_ulong = 0x8004746b; +pub const TIOCMBIS: c_ulong = 0x8004746c; +pub const TIOCMSET: c_ulong = 0x8004746d; +pub const TIOCSTART: c_ulong = 0x2000746e; +pub const TIOCSTOP: c_ulong = 0x2000746f; +pub const TIOCPKT: c_ulong = 0x80047470; +pub const TIOCPKT_DATA: c_int = 0x0; +pub const TIOCPKT_FLUSHREAD: c_int = 0x1; +pub const TIOCPKT_FLUSHWRITE: c_int = 0x2; +pub const TIOCPKT_STOP: c_int = 0x4; +pub const TIOCPKT_START: c_int = 0x8; +pub const TIOCPKT_NOSTOP: c_int = 0x10; +pub const TIOCPKT_DOSTOP: c_int = 0x20; +pub const TIOCPKT_IOCTL: c_int = 0x40; +pub const TIOCNOTTY: c_ulong = 0x20007471; +pub const TIOCSTI: c_ulong = 0x80017472; +pub const TIOCOUTQ: c_ulong = 0x40047473; +pub const TIOCSPGRP: c_ulong = 0x80047476; +pub const TIOCGPGRP: c_ulong = 0x40047477; +pub const TIOCCDTR: c_ulong = 0x20007478; +pub const TIOCSDTR: c_ulong = 0x20007479; +pub const TTYDISC: c_int = 0x0; +pub const SLIPDISC: c_int = 0x4; +pub const PPPDISC: c_int = 0x5; +pub const NETGRAPHDISC: c_int = 0x6; + +pub const BIOCGRSIG: c_ulong = 0x40044272; +pub const BIOCSRSIG: c_ulong = 0x80044273; +pub const BIOCSDLT: c_ulong = 0x80044278; +pub const BIOCGSEESENT: c_ulong = 0x40044276; +pub const BIOCSSEESENT: c_ulong = 0x80044277; +cfg_if! { + if #[cfg(target_pointer_width = "64")] { + pub const BIOCGDLTLIST: c_ulong = 0xc0104279; + pub const BIOCSETF: c_ulong = 0x80104267; + } else if #[cfg(target_pointer_width = "32")] { + pub const BIOCGDLTLIST: c_ulong = 0xc0084279; + pub const BIOCSETF: c_ulong = 0x80084267; + } +} + +pub const FIODTYPE: c_ulong = 0x4004667a; +pub const FIOGETLBA: c_ulong = 0x40046679; + +pub const B0: speed_t = 0; +pub const B50: speed_t = 50; +pub const B75: speed_t = 75; +pub const B110: speed_t = 110; +pub const B134: speed_t = 134; +pub const B150: speed_t = 150; +pub const B200: speed_t = 200; +pub const B300: speed_t = 300; +pub const B600: speed_t = 600; +pub const B1200: speed_t = 1200; +pub const B1800: speed_t = 1800; +pub const B2400: speed_t = 2400; +pub const B4800: speed_t = 4800; +pub const B9600: speed_t = 9600; +pub const B19200: speed_t = 19200; +pub const B38400: speed_t = 38400; +pub const B7200: speed_t = 7200; +pub const B14400: speed_t = 14400; +pub const B28800: speed_t = 28800; +pub const B57600: speed_t = 57600; +pub const B76800: speed_t = 76800; +pub const B115200: speed_t = 115200; +pub const B230400: speed_t = 230400; +pub const EXTA: speed_t = 19200; +pub const EXTB: speed_t = 38400; + +pub const SEM_FAILED: *mut sem_t = ptr::null_mut(); + +pub const CRTSCTS: crate::tcflag_t = 0x00030000; +pub const CCTS_OFLOW: crate::tcflag_t = 0x00010000; +pub const CRTS_IFLOW: crate::tcflag_t = 0x00020000; +pub const CDTR_IFLOW: crate::tcflag_t = 0x00040000; +pub const CDSR_OFLOW: crate::tcflag_t = 0x00080000; +pub const CCAR_OFLOW: crate::tcflag_t = 0x00100000; +pub const VERASE2: usize = 7; +pub const OCRNL: crate::tcflag_t = 0x10; +pub const ONOCR: crate::tcflag_t = 0x20; +pub const ONLRET: crate::tcflag_t = 0x40; + +pub const CMGROUP_MAX: usize = 16; + +pub const EUI64_LEN: usize = 8; + +// https://github.com/freebsd/freebsd/blob/HEAD/sys/net/bpf.h +pub const BPF_ALIGNMENT: usize = SIZEOF_LONG; + +// Values for rtprio struct (prio field) and syscall (function argument) +pub const RTP_PRIO_MIN: c_ushort = 0; +pub const RTP_PRIO_MAX: c_ushort = 31; +pub const RTP_LOOKUP: c_int = 0; +pub const RTP_SET: c_int = 1; + +// Flags for chflags(2) +pub const UF_SETTABLE: c_ulong = 0x0000ffff; +pub const UF_NODUMP: c_ulong = 0x00000001; +pub const UF_IMMUTABLE: c_ulong = 0x00000002; +pub const UF_APPEND: c_ulong = 0x00000004; +pub const UF_OPAQUE: c_ulong = 0x00000008; +pub const UF_NOUNLINK: c_ulong = 0x00000010; +pub const SF_SETTABLE: c_ulong = 0xffff0000; +pub const SF_ARCHIVED: c_ulong = 0x00010000; +pub const SF_IMMUTABLE: c_ulong = 0x00020000; +pub const SF_APPEND: c_ulong = 0x00040000; +pub const SF_NOUNLINK: c_ulong = 0x00100000; + +pub const TIMER_ABSTIME: c_int = 1; + +// +pub const NTP_API: c_int = 4; +pub const MAXPHASE: c_long = 500000000; +pub const MAXFREQ: c_long = 500000; +pub const MINSEC: c_int = 256; +pub const MAXSEC: c_int = 2048; +pub const NANOSECOND: c_long = 1000000000; +pub const SCALE_PPM: c_int = 65; +pub const MAXTC: c_int = 10; +pub const MOD_OFFSET: c_uint = 0x0001; +pub const MOD_FREQUENCY: c_uint = 0x0002; +pub const MOD_MAXERROR: c_uint = 0x0004; +pub const MOD_ESTERROR: c_uint = 0x0008; +pub const MOD_STATUS: c_uint = 0x0010; +pub const MOD_TIMECONST: c_uint = 0x0020; +pub const MOD_PPSMAX: c_uint = 0x0040; +pub const MOD_TAI: c_uint = 0x0080; +pub const MOD_MICRO: c_uint = 0x1000; +pub const MOD_NANO: c_uint = 0x2000; +pub const MOD_CLKB: c_uint = 0x4000; +pub const MOD_CLKA: c_uint = 0x8000; +pub const STA_PLL: c_int = 0x0001; +pub const STA_PPSFREQ: c_int = 0x0002; +pub const STA_PPSTIME: c_int = 0x0004; +pub const STA_FLL: c_int = 0x0008; +pub const STA_INS: c_int = 0x0010; +pub const STA_DEL: c_int = 0x0020; +pub const STA_UNSYNC: c_int = 0x0040; +pub const STA_FREQHOLD: c_int = 0x0080; +pub const STA_PPSSIGNAL: c_int = 0x0100; +pub const STA_PPSJITTER: c_int = 0x0200; +pub const STA_PPSWANDER: c_int = 0x0400; +pub const STA_PPSERROR: c_int = 0x0800; +pub const STA_CLOCKERR: c_int = 0x1000; +pub const STA_NANO: c_int = 0x2000; +pub const STA_MODE: c_int = 0x4000; +pub const STA_CLK: c_int = 0x8000; +pub const STA_RONLY: c_int = STA_PPSSIGNAL + | STA_PPSJITTER + | STA_PPSWANDER + | STA_PPSERROR + | STA_CLOCKERR + | STA_NANO + | STA_MODE + | STA_CLK; +pub const TIME_OK: c_int = 0; +pub const TIME_INS: c_int = 1; +pub const TIME_DEL: c_int = 2; +pub const TIME_OOP: c_int = 3; +pub const TIME_WAIT: c_int = 4; +pub const TIME_ERROR: c_int = 5; + +pub const REG_ENOSYS: c_int = -1; +pub const REG_ILLSEQ: c_int = 17; + +pub const IPC_PRIVATE: crate::key_t = 0; +pub const IPC_CREAT: c_int = 0o1000; +pub const IPC_EXCL: c_int = 0o2000; +pub const IPC_NOWAIT: c_int = 0o4000; +pub const IPC_RMID: c_int = 0; +pub const IPC_SET: c_int = 1; +pub const IPC_STAT: c_int = 2; +pub const IPC_R: c_int = 0o400; +pub const IPC_W: c_int = 0o200; +pub const IPC_M: c_int = 0o10000; + +pub const SHM_RDONLY: c_int = 0o10000; +pub const SHM_RND: c_int = 0o20000; +pub const SHM_R: c_int = 0o400; +pub const SHM_W: c_int = 0o200; + +pub const KENV_GET: c_int = 0; +pub const KENV_SET: c_int = 1; +pub const KENV_UNSET: c_int = 2; +pub const KENV_DUMP: c_int = 3; +pub const KENV_MNAMELEN: c_int = 128; +pub const KENV_MVALLEN: c_int = 128; + +pub const RB_ASKNAME: c_int = 0x001; +pub const RB_SINGLE: c_int = 0x002; +pub const RB_NOSYNC: c_int = 0x004; +pub const RB_HALT: c_int = 0x008; +pub const RB_INITNAME: c_int = 0x010; +pub const RB_DFLTROOT: c_int = 0x020; +pub const RB_KDB: c_int = 0x040; +pub const RB_RDONLY: c_int = 0x080; +pub const RB_DUMP: c_int = 0x100; +pub const RB_MINIROOT: c_int = 0x200; +pub const RB_VERBOSE: c_int = 0x800; +pub const RB_SERIAL: c_int = 0x1000; +pub const RB_CDROM: c_int = 0x2000; +pub const RB_POWEROFF: c_int = 0x4000; +pub const RB_GDB: c_int = 0x8000; +pub const RB_MUTE: c_int = 0x10000; +pub const RB_SELFTEST: c_int = 0x20000; + +// For getrandom() +pub const GRND_NONBLOCK: c_uint = 0x1; +pub const GRND_RANDOM: c_uint = 0x2; +pub const GRND_INSECURE: c_uint = 0x4; + +// DIFF(main): changed to `c_short` in f62eb023ab +pub const POSIX_SPAWN_RESETIDS: c_int = 0x01; +pub const POSIX_SPAWN_SETPGROUP: c_int = 0x02; +pub const POSIX_SPAWN_SETSCHEDPARAM: c_int = 0x04; +pub const POSIX_SPAWN_SETSCHEDULER: c_int = 0x08; +pub const POSIX_SPAWN_SETSIGDEF: c_int = 0x10; +pub const POSIX_SPAWN_SETSIGMASK: c_int = 0x20; + +safe_f! { + pub const fn WIFCONTINUED(status: c_int) -> bool { + status == 0x13 + } + + pub const fn WSTOPSIG(status: c_int) -> c_int { + status >> 8 + } + + pub const fn WIFSTOPPED(status: c_int) -> bool { + (status & 0o177) == 0o177 + } +} + +extern "C" { + pub fn sem_destroy(sem: *mut sem_t) -> c_int; + pub fn sem_init(sem: *mut sem_t, pshared: c_int, value: c_uint) -> c_int; + + pub fn daemon(nochdir: c_int, noclose: c_int) -> c_int; + pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut crate::timezone) -> c_int; + pub fn accept4( + s: c_int, + addr: *mut crate::sockaddr, + addrlen: *mut crate::socklen_t, + flags: c_int, + ) -> c_int; + pub fn chflags(path: *const c_char, flags: c_ulong) -> c_int; + pub fn chflagsat(fd: c_int, path: *const c_char, flags: c_ulong, atflag: c_int) -> c_int; + + pub fn clock_nanosleep( + clk_id: crate::clockid_t, + flags: c_int, + rqtp: *const crate::timespec, + rmtp: *mut crate::timespec, + ) -> c_int; + + pub fn clock_getres(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; + pub fn clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; + pub fn clock_settime(clk_id: crate::clockid_t, tp: *const crate::timespec) -> c_int; + pub fn clock_getcpuclockid(pid: crate::pid_t, clk_id: *mut crate::clockid_t) -> c_int; + + pub fn pthread_getcpuclockid(thread: crate::pthread_t, clk_id: *mut crate::clockid_t) -> c_int; + + pub fn dirfd(dirp: *mut crate::DIR) -> c_int; + pub fn duplocale(base: crate::locale_t) -> crate::locale_t; + pub fn endutxent(); + pub fn fchflags(fd: c_int, flags: c_ulong) -> c_int; + + // DIFF(main): changed to `*const *mut` in e77f551de9 + pub fn fexecve(fd: c_int, argv: *const *const c_char, envp: *const *const c_char) -> c_int; + + pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int; + pub fn getdomainname(name: *mut c_char, len: c_int) -> c_int; + pub fn getgrent_r( + grp: *mut crate::group, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::group, + ) -> c_int; + pub fn getpwent_r( + pwd: *mut crate::passwd, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::passwd, + ) -> c_int; + pub fn getgrouplist( + name: *const c_char, + basegid: crate::gid_t, + groups: *mut crate::gid_t, + ngroups: *mut c_int, + ) -> c_int; + pub fn getnameinfo( + sa: *const crate::sockaddr, + salen: crate::socklen_t, + host: *mut c_char, + hostlen: size_t, + serv: *mut c_char, + servlen: size_t, + flags: c_int, + ) -> c_int; + pub fn getpriority(which: c_int, who: c_int) -> c_int; + pub fn getresgid( + rgid: *mut crate::gid_t, + egid: *mut crate::gid_t, + sgid: *mut crate::gid_t, + ) -> c_int; + pub fn getresuid( + ruid: *mut crate::uid_t, + euid: *mut crate::uid_t, + suid: *mut crate::uid_t, + ) -> c_int; + pub fn getutxent() -> *mut utmpx; + pub fn getutxid(ut: *const utmpx) -> *mut utmpx; + pub fn getutxline(ut: *const utmpx) -> *mut utmpx; + pub fn initgroups(name: *const c_char, basegid: crate::gid_t) -> c_int; + #[cfg_attr( + all(target_os = "freebsd", any(freebsd11, freebsd10)), + link_name = "kevent@FBSD_1.0" + )] + pub fn kevent( + kq: c_int, + changelist: *const crate::kevent, + nchanges: c_int, + eventlist: *mut crate::kevent, + nevents: c_int, + timeout: *const crate::timespec, + ) -> c_int; + pub fn lchflags(path: *const c_char, flags: c_ulong) -> c_int; + pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int; + pub fn memrchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; + pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; + #[cfg_attr( + all(target_os = "freebsd", any(freebsd11, freebsd10)), + link_name = "mknodat@FBSD_1.1" + )] + pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; + pub fn malloc_usable_size(ptr: *const c_void) -> size_t; + pub fn mincore(addr: *const c_void, len: size_t, vec: *mut c_char) -> c_int; + pub fn newlocale(mask: c_int, locale: *const c_char, base: crate::locale_t) -> crate::locale_t; + pub fn nl_langinfo_l(item: crate::nl_item, locale: crate::locale_t) -> *mut c_char; + pub fn pipe2(fds: *mut c_int, flags: c_int) -> c_int; + pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int; + pub fn posix_fadvise(fd: c_int, offset: off_t, len: off_t, advise: c_int) -> c_int; + pub fn ppoll( + fds: *mut crate::pollfd, + nfds: crate::nfds_t, + timeout: *const crate::timespec, + sigmask: *const sigset_t, + ) -> c_int; + pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t; + pub fn pthread_attr_get_np(tid: crate::pthread_t, attr: *mut crate::pthread_attr_t) -> c_int; + pub fn pthread_attr_getguardsize( + attr: *const crate::pthread_attr_t, + guardsize: *mut size_t, + ) -> c_int; + pub fn pthread_attr_setguardsize(attr: *mut crate::pthread_attr_t, guardsize: size_t) -> c_int; + pub fn pthread_attr_getstack( + attr: *const crate::pthread_attr_t, + stackaddr: *mut *mut c_void, + stacksize: *mut size_t, + ) -> c_int; + pub fn pthread_condattr_getclock( + attr: *const pthread_condattr_t, + clock_id: *mut clockid_t, + ) -> c_int; + pub fn pthread_condattr_getpshared( + attr: *const pthread_condattr_t, + pshared: *mut c_int, + ) -> c_int; + pub fn pthread_condattr_setclock( + attr: *mut pthread_condattr_t, + clock_id: crate::clockid_t, + ) -> c_int; + pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t, pshared: c_int) -> c_int; + pub fn pthread_main_np() -> c_int; + pub fn pthread_mutex_timedlock( + lock: *mut pthread_mutex_t, + abstime: *const crate::timespec, + ) -> c_int; + pub fn pthread_mutexattr_getpshared( + attr: *const pthread_mutexattr_t, + pshared: *mut c_int, + ) -> c_int; + pub fn pthread_mutexattr_setpshared(attr: *mut pthread_mutexattr_t, pshared: c_int) -> c_int; + pub fn pthread_rwlockattr_getpshared( + attr: *const pthread_rwlockattr_t, + val: *mut c_int, + ) -> c_int; + pub fn pthread_rwlockattr_setpshared(attr: *mut pthread_rwlockattr_t, val: c_int) -> c_int; + pub fn pthread_barrierattr_init(attr: *mut crate::pthread_barrierattr_t) -> c_int; + pub fn pthread_barrierattr_destroy(attr: *mut crate::pthread_barrierattr_t) -> c_int; + pub fn pthread_barrierattr_getpshared( + attr: *const crate::pthread_barrierattr_t, + shared: *mut c_int, + ) -> c_int; + pub fn pthread_barrierattr_setpshared( + attr: *mut crate::pthread_barrierattr_t, + shared: c_int, + ) -> c_int; + pub fn pthread_barrier_init( + barrier: *mut pthread_barrier_t, + attr: *const crate::pthread_barrierattr_t, + count: c_uint, + ) -> c_int; + pub fn pthread_barrier_destroy(barrier: *mut pthread_barrier_t) -> c_int; + pub fn pthread_barrier_wait(barrier: *mut pthread_barrier_t) -> c_int; + pub fn pthread_get_name_np(tid: crate::pthread_t, name: *mut c_char, len: size_t); + pub fn pthread_set_name_np(tid: crate::pthread_t, name: *const c_char); + pub fn pthread_getname_np( + thread: crate::pthread_t, + buffer: *mut c_char, + length: size_t, + ) -> c_int; + pub fn pthread_setname_np(thread: crate::pthread_t, name: *const c_char) -> c_int; + pub fn pthread_setschedparam( + native: crate::pthread_t, + policy: c_int, + param: *const sched_param, + ) -> c_int; + pub fn pthread_getschedparam( + native: crate::pthread_t, + policy: *mut c_int, + param: *mut sched_param, + ) -> c_int; + pub fn ptrace(request: c_int, pid: crate::pid_t, addr: *mut c_char, data: c_int) -> c_int; + pub fn utrace(addr: *const c_void, len: size_t) -> c_int; + pub fn pututxline(ut: *const utmpx) -> *mut utmpx; + pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t; + pub fn querylocale(mask: c_int, loc: crate::locale_t) -> *const c_char; + pub fn rtprio(function: c_int, pid: crate::pid_t, rtp: *mut rtprio) -> c_int; + pub fn sched_rr_get_interval(pid: crate::pid_t, t: *mut crate::timespec) -> c_int; + pub fn sched_getparam(pid: crate::pid_t, param: *mut sched_param) -> c_int; + pub fn sched_setparam(pid: crate::pid_t, param: *const sched_param) -> c_int; + pub fn sched_getscheduler(pid: crate::pid_t) -> c_int; + pub fn sched_setscheduler( + pid: crate::pid_t, + policy: c_int, + param: *const crate::sched_param, + ) -> c_int; + pub fn sem_getvalue(sem: *mut sem_t, sval: *mut c_int) -> c_int; + pub fn sem_timedwait(sem: *mut sem_t, abstime: *const crate::timespec) -> c_int; + pub fn sendfile( + fd: c_int, + s: c_int, + offset: off_t, + nbytes: size_t, + hdtr: *mut crate::sf_hdtr, + sbytes: *mut off_t, + flags: c_int, + ) -> c_int; + pub fn setdomainname(name: *const c_char, len: c_int) -> c_int; + pub fn sethostname(name: *const c_char, len: c_int) -> c_int; + pub fn setpriority(which: c_int, who: c_int, prio: c_int) -> c_int; + pub fn setresgid(rgid: crate::gid_t, egid: crate::gid_t, sgid: crate::gid_t) -> c_int; + pub fn setresuid(ruid: crate::uid_t, euid: crate::uid_t, suid: crate::uid_t) -> c_int; + pub fn settimeofday(tv: *const crate::timeval, tz: *const crate::timezone) -> c_int; + pub fn setutxent(); + pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int; + pub fn sigtimedwait( + set: *const sigset_t, + info: *mut siginfo_t, + timeout: *const crate::timespec, + ) -> c_int; + pub fn sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> c_int; + pub fn sysctl( + name: *const c_int, + namelen: c_uint, + oldp: *mut c_void, + oldlenp: *mut size_t, + newp: *const c_void, + newlen: size_t, + ) -> c_int; + pub fn sysctlbyname( + name: *const c_char, + oldp: *mut c_void, + oldlenp: *mut size_t, + newp: *const c_void, + newlen: size_t, + ) -> c_int; + pub fn sysctlnametomib(name: *const c_char, mibp: *mut c_int, sizep: *mut size_t) -> c_int; + pub fn uselocale(loc: crate::locale_t) -> crate::locale_t; + pub fn utimensat( + dirfd: c_int, + path: *const c_char, + times: *const crate::timespec, + flag: c_int, + ) -> c_int; + + pub fn ntp_adjtime(buf: *mut timex) -> c_int; + pub fn ntp_gettime(buf: *mut ntptimeval) -> c_int; + + // #include + pub fn dl_iterate_phdr( + callback: Option< + unsafe extern "C" fn(info: *mut dl_phdr_info, size: usize, data: *mut c_void) -> c_int, + >, + data: *mut c_void, + ) -> c_int; + + pub fn iconv_open(tocode: *const c_char, fromcode: *const c_char) -> iconv_t; + pub fn iconv( + cd: iconv_t, + inbuf: *mut *mut c_char, + inbytesleft: *mut size_t, + outbuf: *mut *mut c_char, + outbytesleft: *mut size_t, + ) -> size_t; + pub fn iconv_close(cd: iconv_t) -> c_int; + + // Added in `FreeBSD` 11.0 + // Added in `DragonFly BSD` 5.4 + pub fn explicit_bzero(s: *mut c_void, len: size_t); + // ISO/IEC 9899:2011 ("ISO C11") K.3.7.4.1 + pub fn memset_s(s: *mut c_void, smax: size_t, c: c_int, n: size_t) -> c_int; + pub fn gethostid() -> c_long; + pub fn sethostid(hostid: c_long); + + pub fn eui64_aton(a: *const c_char, e: *mut eui64) -> c_int; + pub fn eui64_ntoa(id: *const eui64, a: *mut c_char, len: size_t) -> c_int; + pub fn eui64_ntohost(hostname: *mut c_char, len: size_t, id: *const eui64) -> c_int; + pub fn eui64_hostton(hostname: *const c_char, id: *mut eui64) -> c_int; + + pub fn eaccess(path: *const c_char, mode: c_int) -> c_int; + + pub fn kenv(action: c_int, name: *const c_char, value: *mut c_char, len: c_int) -> c_int; + pub fn reboot(howto: c_int) -> c_int; + + pub fn exect(path: *const c_char, argv: *const *mut c_char, envp: *const *mut c_char) -> c_int; + pub fn execvP( + file: *const c_char, + search_path: *const c_char, + argv: *const *mut c_char, + ) -> c_int; + + pub fn mkostemp(template: *mut c_char, flags: c_int) -> c_int; + pub fn mkostemps(template: *mut c_char, suffixlen: c_int, flags: c_int) -> c_int; + + pub fn posix_spawn( + pid: *mut crate::pid_t, + path: *const c_char, + file_actions: *const crate::posix_spawn_file_actions_t, + attrp: *const crate::posix_spawnattr_t, + argv: *const *mut c_char, + envp: *const *mut c_char, + ) -> c_int; + pub fn posix_spawnp( + pid: *mut crate::pid_t, + file: *const c_char, + file_actions: *const crate::posix_spawn_file_actions_t, + attrp: *const crate::posix_spawnattr_t, + argv: *const *mut c_char, + envp: *const *mut c_char, + ) -> c_int; + pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> c_int; + pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> c_int; + pub fn posix_spawnattr_getsigdefault( + attr: *const posix_spawnattr_t, + default: *mut crate::sigset_t, + ) -> c_int; + pub fn posix_spawnattr_setsigdefault( + attr: *mut posix_spawnattr_t, + default: *const crate::sigset_t, + ) -> c_int; + pub fn posix_spawnattr_getsigmask( + attr: *const posix_spawnattr_t, + default: *mut crate::sigset_t, + ) -> c_int; + pub fn posix_spawnattr_setsigmask( + attr: *mut posix_spawnattr_t, + default: *const crate::sigset_t, + ) -> c_int; + pub fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t, flags: *mut c_short) -> c_int; + pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t, flags: c_short) -> c_int; + pub fn posix_spawnattr_getpgroup( + attr: *const posix_spawnattr_t, + flags: *mut crate::pid_t, + ) -> c_int; + pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, flags: crate::pid_t) -> c_int; + pub fn posix_spawnattr_getschedpolicy( + attr: *const posix_spawnattr_t, + flags: *mut c_int, + ) -> c_int; + pub fn posix_spawnattr_setschedpolicy(attr: *mut posix_spawnattr_t, flags: c_int) -> c_int; + pub fn posix_spawnattr_getschedparam( + attr: *const posix_spawnattr_t, + param: *mut crate::sched_param, + ) -> c_int; + pub fn posix_spawnattr_setschedparam( + attr: *mut posix_spawnattr_t, + param: *const crate::sched_param, + ) -> c_int; + + pub fn posix_spawn_file_actions_init(actions: *mut posix_spawn_file_actions_t) -> c_int; + pub fn posix_spawn_file_actions_destroy(actions: *mut posix_spawn_file_actions_t) -> c_int; + pub fn posix_spawn_file_actions_addopen( + actions: *mut posix_spawn_file_actions_t, + fd: c_int, + path: *const c_char, + oflag: c_int, + mode: mode_t, + ) -> c_int; + pub fn posix_spawn_file_actions_addclose( + actions: *mut posix_spawn_file_actions_t, + fd: c_int, + ) -> c_int; + pub fn posix_spawn_file_actions_adddup2( + actions: *mut posix_spawn_file_actions_t, + fd: c_int, + newfd: c_int, + ) -> c_int; +} + +#[link(name = "rt")] +extern "C" { + pub fn mq_close(mqd: crate::mqd_t) -> c_int; + pub fn mq_getattr(mqd: crate::mqd_t, attr: *mut crate::mq_attr) -> c_int; + pub fn mq_notify(mqd: crate::mqd_t, notification: *const crate::sigevent) -> c_int; + pub fn mq_open(name: *const c_char, oflag: c_int, ...) -> crate::mqd_t; + pub fn mq_receive( + mqd: crate::mqd_t, + msg_ptr: *mut c_char, + msg_len: size_t, + msg_prio: *mut c_uint, + ) -> ssize_t; + pub fn mq_send( + mqd: crate::mqd_t, + msg_ptr: *const c_char, + msg_len: size_t, + msg_prio: c_uint, + ) -> c_int; + pub fn mq_setattr( + mqd: crate::mqd_t, + newattr: *const crate::mq_attr, + oldattr: *mut crate::mq_attr, + ) -> c_int; + pub fn mq_timedreceive( + mqd: crate::mqd_t, + msg_ptr: *mut c_char, + msg_len: size_t, + msg_prio: *mut c_uint, + abs_timeout: *const crate::timespec, + ) -> ssize_t; + pub fn mq_timedsend( + mqd: crate::mqd_t, + msg_ptr: *const c_char, + msg_len: size_t, + msg_prio: c_uint, + abs_timeout: *const crate::timespec, + ) -> c_int; + pub fn mq_unlink(name: *const c_char) -> c_int; + + pub fn getrandom(buf: *mut c_void, buflen: size_t, flags: c_uint) -> ssize_t; + pub fn getentropy(buf: *mut c_void, buflen: size_t) -> c_int; +} + +#[link(name = "util")] +extern "C" { + pub fn openpty( + amaster: *mut c_int, + aslave: *mut c_int, + name: *mut c_char, + termp: *mut termios, + winp: *mut crate::winsize, + ) -> c_int; + pub fn forkpty( + amaster: *mut c_int, + name: *mut c_char, + termp: *mut termios, + winp: *mut crate::winsize, + ) -> crate::pid_t; + pub fn login_tty(fd: c_int) -> c_int; + pub fn fparseln( + stream: *mut crate::FILE, + len: *mut size_t, + lineno: *mut size_t, + delim: *const c_char, + flags: c_int, + ) -> *mut c_char; +} + +#[link(name = "execinfo")] +extern "C" { + pub fn backtrace(addrlist: *mut *mut c_void, len: size_t) -> size_t; + pub fn backtrace_symbols(addrlist: *const *mut c_void, len: size_t) -> *mut *mut c_char; + pub fn backtrace_symbols_fd(addrlist: *const *mut c_void, len: size_t, fd: c_int) -> c_int; +} + +#[link(name = "kvm")] +extern "C" { + pub fn kvm_open( + execfile: *const c_char, + corefile: *const c_char, + swapfile: *const c_char, + flags: c_int, + errstr: *const c_char, + ) -> *mut crate::kvm_t; + pub fn kvm_close(kd: *mut crate::kvm_t) -> c_int; + pub fn kvm_getprocs( + kd: *mut crate::kvm_t, + op: c_int, + arg: c_int, + cnt: *mut c_int, + ) -> *mut crate::kinfo_proc; + pub fn kvm_getloadavg(kd: *mut kvm_t, loadavg: *mut c_double, nelem: c_int) -> c_int; + pub fn kvm_openfiles( + execfile: *const c_char, + corefile: *const c_char, + swapfile: *const c_char, + flags: c_int, + errbuf: *mut c_char, + ) -> *mut crate::kvm_t; + pub fn kvm_read( + kd: *mut crate::kvm_t, + addr: c_ulong, + buf: *mut c_void, + nbytes: size_t, + ) -> ssize_t; + pub fn kvm_write( + kd: *mut crate::kvm_t, + addr: c_ulong, + buf: *const c_void, + nbytes: size_t, + ) -> ssize_t; +} + +cfg_if! { + if #[cfg(target_os = "freebsd")] { + mod freebsd; + pub use self::freebsd::*; + } else if #[cfg(target_os = "dragonfly")] { + mod dragonfly; + pub use self::dragonfly::*; + } else { + // ... + } +} diff --git a/http/vendor/libc/src/unix/bsd/mod.rs b/http/vendor/libc/src/unix/bsd/mod.rs new file mode 100644 index 0000000..cb47817 --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/mod.rs @@ -0,0 +1,897 @@ +use crate::prelude::*; + +pub type off_t = i64; +pub type useconds_t = u32; +pub type blkcnt_t = i64; +pub type socklen_t = u32; +pub type sa_family_t = u8; +pub type pthread_t = crate::uintptr_t; +pub type nfds_t = c_uint; +pub type regoff_t = off_t; + +s! { + pub struct sockaddr { + pub sa_len: u8, + pub sa_family: sa_family_t, + pub sa_data: [c_char; 14], + } + + pub struct sockaddr_in6 { + pub sin6_len: u8, + pub sin6_family: sa_family_t, + pub sin6_port: crate::in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: crate::in6_addr, + pub sin6_scope_id: u32, + } + + pub struct passwd { + pub pw_name: *mut c_char, + pub pw_passwd: *mut c_char, + pub pw_uid: crate::uid_t, + pub pw_gid: crate::gid_t, + pub pw_change: crate::time_t, + pub pw_class: *mut c_char, + pub pw_gecos: *mut c_char, + pub pw_dir: *mut c_char, + pub pw_shell: *mut c_char, + pub pw_expire: crate::time_t, + + #[cfg(not(any( + target_os = "macos", + target_os = "ios", + target_os = "tvos", + target_os = "watchos", + target_os = "visionos", + target_os = "netbsd", + target_os = "openbsd" + )))] + pub pw_fields: c_int, + } + + pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut c_char, + pub ifa_flags: c_uint, + pub ifa_addr: *mut crate::sockaddr, + pub ifa_netmask: *mut crate::sockaddr, + pub ifa_dstaddr: *mut crate::sockaddr, + pub ifa_data: *mut c_void, + #[cfg(target_os = "netbsd")] + pub ifa_addrflags: c_uint, + } + + pub struct fd_set { + #[cfg(all( + target_pointer_width = "64", + any(target_os = "freebsd", target_os = "dragonfly") + ))] + fds_bits: [i64; FD_SETSIZE as usize / 64], + #[cfg(not(all( + target_pointer_width = "64", + any(target_os = "freebsd", target_os = "dragonfly") + )))] + fds_bits: [i32; FD_SETSIZE as usize / 32], + } + + pub struct msghdr { + pub msg_name: *mut c_void, + pub msg_namelen: crate::socklen_t, + pub msg_iov: *mut crate::iovec, + pub msg_iovlen: c_int, + pub msg_control: *mut c_void, + pub msg_controllen: crate::socklen_t, + pub msg_flags: c_int, + } + + pub struct cmsghdr { + pub cmsg_len: crate::socklen_t, + pub cmsg_level: c_int, + pub cmsg_type: c_int, + } + + pub struct fsid_t { + __fsid_val: [i32; 2], + } + + pub struct if_nameindex { + pub if_index: c_uint, + pub if_name: *mut c_char, + } + + pub struct regex_t { + __re_magic: c_int, + __re_nsub: size_t, + __re_endp: *const c_char, + __re_g: *mut c_void, + } + + pub struct regmatch_t { + pub rm_so: regoff_t, + pub rm_eo: regoff_t, + } + + pub struct option { + pub name: *const c_char, + pub has_arg: c_int, + pub flag: *mut c_int, + pub val: c_int, + } + pub struct sockaddr_un { + pub sun_len: u8, + pub sun_family: sa_family_t, + pub sun_path: [c_char; 104], + } + + pub struct utsname { + #[cfg(not(target_os = "dragonfly"))] + pub sysname: [c_char; 256], + #[cfg(target_os = "dragonfly")] + pub sysname: [c_char; 32], + #[cfg(not(target_os = "dragonfly"))] + pub nodename: [c_char; 256], + #[cfg(target_os = "dragonfly")] + pub nodename: [c_char; 32], + #[cfg(not(target_os = "dragonfly"))] + pub release: [c_char; 256], + #[cfg(target_os = "dragonfly")] + pub release: [c_char; 32], + #[cfg(not(target_os = "dragonfly"))] + pub version: [c_char; 256], + #[cfg(target_os = "dragonfly")] + pub version: [c_char; 32], + #[cfg(not(target_os = "dragonfly"))] + pub machine: [c_char; 256], + #[cfg(target_os = "dragonfly")] + pub machine: [c_char; 32], + } +} + +pub const LC_ALL: c_int = 0; +pub const LC_COLLATE: c_int = 1; +pub const LC_CTYPE: c_int = 2; +pub const LC_MONETARY: c_int = 3; +pub const LC_NUMERIC: c_int = 4; +pub const LC_TIME: c_int = 5; +pub const LC_MESSAGES: c_int = 6; + +pub const FIOCLEX: c_ulong = 0x20006601; +pub const FIONCLEX: c_ulong = 0x20006602; +pub const FIONREAD: c_ulong = 0x4004667f; +pub const FIONBIO: c_ulong = 0x8004667e; +pub const FIOASYNC: c_ulong = 0x8004667d; +pub const FIOSETOWN: c_ulong = 0x8004667c; +pub const FIOGETOWN: c_ulong = 0x4004667b; + +pub const PATH_MAX: c_int = 1024; +pub const MAXPATHLEN: c_int = PATH_MAX; + +pub const IOV_MAX: c_int = 1024; + +pub const SA_ONSTACK: c_int = 0x0001; +pub const SA_SIGINFO: c_int = 0x0040; +pub const SA_RESTART: c_int = 0x0002; +pub const SA_RESETHAND: c_int = 0x0004; +pub const SA_NOCLDSTOP: c_int = 0x0008; +pub const SA_NODEFER: c_int = 0x0010; +pub const SA_NOCLDWAIT: c_int = 0x0020; + +pub const SS_ONSTACK: c_int = 1; +pub const SS_DISABLE: c_int = 4; + +pub const SIGCHLD: c_int = 20; +pub const SIGBUS: c_int = 10; +pub const SIGUSR1: c_int = 30; +pub const SIGUSR2: c_int = 31; +pub const SIGCONT: c_int = 19; +pub const SIGSTOP: c_int = 17; +pub const SIGTSTP: c_int = 18; +pub const SIGURG: c_int = 16; +pub const SIGIO: c_int = 23; +pub const SIGSYS: c_int = 12; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGINFO: c_int = 29; + +pub const SIG_SETMASK: c_int = 3; +pub const SIG_BLOCK: c_int = 0x1; +pub const SIG_UNBLOCK: c_int = 0x2; + +pub const IP_TOS: c_int = 3; +pub const IP_MULTICAST_IF: c_int = 9; +pub const IP_MULTICAST_TTL: c_int = 10; +pub const IP_MULTICAST_LOOP: c_int = 11; + +pub const IPV6_UNICAST_HOPS: c_int = 4; +pub const IPV6_MULTICAST_IF: c_int = 9; +pub const IPV6_MULTICAST_HOPS: c_int = 10; +pub const IPV6_MULTICAST_LOOP: c_int = 11; +pub const IPV6_V6ONLY: c_int = 27; +pub const IPV6_DONTFRAG: c_int = 62; + +pub const IPTOS_ECN_NOTECT: u8 = 0x00; +pub const IPTOS_ECN_MASK: u8 = 0x03; +pub const IPTOS_ECN_ECT1: u8 = 0x01; +pub const IPTOS_ECN_ECT0: u8 = 0x02; +pub const IPTOS_ECN_CE: u8 = 0x03; + +pub const ST_RDONLY: c_ulong = 1; + +pub const SCM_RIGHTS: c_int = 0x01; + +pub const NCCS: usize = 20; + +pub const O_ACCMODE: c_int = 0x3; +pub const O_RDONLY: c_int = 0; +pub const O_WRONLY: c_int = 1; +pub const O_RDWR: c_int = 2; +pub const O_APPEND: c_int = 8; +pub const O_CREAT: c_int = 512; +pub const O_TRUNC: c_int = 1024; +pub const O_EXCL: c_int = 2048; +pub const O_ASYNC: c_int = 0x40; +pub const O_SYNC: c_int = 0x80; +pub const O_NONBLOCK: c_int = 0x4; +pub const O_NOFOLLOW: c_int = 0x100; +pub const O_SHLOCK: c_int = 0x10; +pub const O_EXLOCK: c_int = 0x20; +pub const O_FSYNC: c_int = O_SYNC; +pub const O_NDELAY: c_int = O_NONBLOCK; + +pub const F_GETOWN: c_int = 5; +pub const F_SETOWN: c_int = 6; + +pub const F_RDLCK: c_short = 1; +pub const F_UNLCK: c_short = 2; +pub const F_WRLCK: c_short = 3; + +pub const MNT_RDONLY: c_int = 0x00000001; +pub const MNT_SYNCHRONOUS: c_int = 0x00000002; +pub const MNT_NOEXEC: c_int = 0x00000004; +pub const MNT_NOSUID: c_int = 0x00000008; +pub const MNT_ASYNC: c_int = 0x00000040; +pub const MNT_EXPORTED: c_int = 0x00000100; +pub const MNT_UPDATE: c_int = 0x00010000; +pub const MNT_RELOAD: c_int = 0x00040000; +pub const MNT_FORCE: c_int = 0x00080000; + +pub const Q_SYNC: c_int = 0x600; +pub const Q_QUOTAON: c_int = 0x100; +pub const Q_QUOTAOFF: c_int = 0x200; + +pub const TCIOFF: c_int = 3; +pub const TCION: c_int = 4; +pub const TCOOFF: c_int = 1; +pub const TCOON: c_int = 2; +pub const TCIFLUSH: c_int = 1; +pub const TCOFLUSH: c_int = 2; +pub const TCIOFLUSH: c_int = 3; +pub const TCSANOW: c_int = 0; +pub const TCSADRAIN: c_int = 1; +pub const TCSAFLUSH: c_int = 2; +pub const VEOF: usize = 0; +pub const VEOL: usize = 1; +pub const VEOL2: usize = 2; +pub const VERASE: usize = 3; +pub const VWERASE: usize = 4; +pub const VKILL: usize = 5; +pub const VREPRINT: usize = 6; +pub const VINTR: usize = 8; +pub const VQUIT: usize = 9; +pub const VSUSP: usize = 10; +pub const VDSUSP: usize = 11; +pub const VSTART: usize = 12; +pub const VSTOP: usize = 13; +pub const VLNEXT: usize = 14; +pub const VDISCARD: usize = 15; +pub const VMIN: usize = 16; +pub const VTIME: usize = 17; +pub const VSTATUS: usize = 18; +pub const _POSIX_VDISABLE: crate::cc_t = 0xff; +pub const IGNBRK: crate::tcflag_t = 0x00000001; +pub const BRKINT: crate::tcflag_t = 0x00000002; +pub const IGNPAR: crate::tcflag_t = 0x00000004; +pub const PARMRK: crate::tcflag_t = 0x00000008; +pub const INPCK: crate::tcflag_t = 0x00000010; +pub const ISTRIP: crate::tcflag_t = 0x00000020; +pub const INLCR: crate::tcflag_t = 0x00000040; +pub const IGNCR: crate::tcflag_t = 0x00000080; +pub const ICRNL: crate::tcflag_t = 0x00000100; +pub const IXON: crate::tcflag_t = 0x00000200; +pub const IXOFF: crate::tcflag_t = 0x00000400; +pub const IXANY: crate::tcflag_t = 0x00000800; +pub const IMAXBEL: crate::tcflag_t = 0x00002000; +pub const OPOST: crate::tcflag_t = 0x1; +pub const ONLCR: crate::tcflag_t = 0x2; +pub const OXTABS: crate::tcflag_t = 0x4; +pub const ONOEOT: crate::tcflag_t = 0x8; +pub const CIGNORE: crate::tcflag_t = 0x00000001; +pub const CSIZE: crate::tcflag_t = 0x00000300; +pub const CS5: crate::tcflag_t = 0x00000000; +pub const CS6: crate::tcflag_t = 0x00000100; +pub const CS7: crate::tcflag_t = 0x00000200; +pub const CS8: crate::tcflag_t = 0x00000300; +pub const CSTOPB: crate::tcflag_t = 0x00000400; +pub const CREAD: crate::tcflag_t = 0x00000800; +pub const PARENB: crate::tcflag_t = 0x00001000; +pub const PARODD: crate::tcflag_t = 0x00002000; +pub const HUPCL: crate::tcflag_t = 0x00004000; +pub const CLOCAL: crate::tcflag_t = 0x00008000; +pub const ECHOKE: crate::tcflag_t = 0x00000001; +pub const ECHOE: crate::tcflag_t = 0x00000002; +pub const ECHOK: crate::tcflag_t = 0x00000004; +pub const ECHO: crate::tcflag_t = 0x00000008; +pub const ECHONL: crate::tcflag_t = 0x00000010; +pub const ECHOPRT: crate::tcflag_t = 0x00000020; +pub const ECHOCTL: crate::tcflag_t = 0x00000040; +pub const ISIG: crate::tcflag_t = 0x00000080; +pub const ICANON: crate::tcflag_t = 0x00000100; +pub const ALTWERASE: crate::tcflag_t = 0x00000200; +pub const IEXTEN: crate::tcflag_t = 0x00000400; +pub const EXTPROC: crate::tcflag_t = 0x00000800; +pub const TOSTOP: crate::tcflag_t = 0x00400000; +pub const FLUSHO: crate::tcflag_t = 0x00800000; +pub const NOKERNINFO: crate::tcflag_t = 0x02000000; +pub const PENDIN: crate::tcflag_t = 0x20000000; +pub const NOFLSH: crate::tcflag_t = 0x80000000; +pub const MDMBUF: crate::tcflag_t = 0x00100000; + +pub const WNOHANG: c_int = 0x00000001; +pub const WUNTRACED: c_int = 0x00000002; + +pub const RTLD_LAZY: c_int = 0x1; +pub const RTLD_NOW: c_int = 0x2; +pub const RTLD_NEXT: *mut c_void = -1isize as *mut c_void; +pub const RTLD_DEFAULT: *mut c_void = -2isize as *mut c_void; +pub const RTLD_SELF: *mut c_void = -3isize as *mut c_void; + +pub const LOG_CRON: c_int = 9 << 3; +pub const LOG_AUTHPRIV: c_int = 10 << 3; +pub const LOG_FTP: c_int = 11 << 3; +pub const LOG_PERROR: c_int = 0x20; + +pub const TCP_NODELAY: c_int = 1; +pub const TCP_MAXSEG: c_int = 2; + +pub const PIPE_BUF: usize = 512; + +// si_code values for SIGBUS signal +pub const BUS_ADRALN: c_int = 1; +pub const BUS_ADRERR: c_int = 2; +pub const BUS_OBJERR: c_int = 3; + +// si_code values for SIGCHLD signal +pub const CLD_EXITED: c_int = 1; +pub const CLD_KILLED: c_int = 2; +pub const CLD_DUMPED: c_int = 3; +pub const CLD_TRAPPED: c_int = 4; +pub const CLD_STOPPED: c_int = 5; +pub const CLD_CONTINUED: c_int = 6; + +pub const POLLIN: c_short = 0x1; +pub const POLLPRI: c_short = 0x2; +pub const POLLOUT: c_short = 0x4; +pub const POLLERR: c_short = 0x8; +pub const POLLHUP: c_short = 0x10; +pub const POLLNVAL: c_short = 0x20; +pub const POLLRDNORM: c_short = 0x040; +pub const POLLWRNORM: c_short = 0x004; +pub const POLLRDBAND: c_short = 0x080; +pub const POLLWRBAND: c_short = 0x100; + +cfg_if! { + // Not yet implemented on NetBSD + if #[cfg(not(any(target_os = "netbsd")))] { + pub const BIOCGBLEN: c_ulong = 0x40044266; + pub const BIOCSBLEN: c_ulong = 0xc0044266; + pub const BIOCFLUSH: c_uint = 0x20004268; + pub const BIOCPROMISC: c_uint = 0x20004269; + pub const BIOCGDLT: c_ulong = 0x4004426a; + pub const BIOCGETIF: c_ulong = 0x4020426b; + pub const BIOCSETIF: c_ulong = 0x8020426c; + pub const BIOCGSTATS: c_ulong = 0x4008426f; + pub const BIOCIMMEDIATE: c_ulong = 0x80044270; + pub const BIOCVERSION: c_ulong = 0x40044271; + pub const BIOCGHDRCMPLT: c_ulong = 0x40044274; + pub const BIOCSHDRCMPLT: c_ulong = 0x80044275; + pub const SIOCGIFADDR: c_ulong = 0xc0206921; + } +} + +pub const REG_BASIC: c_int = 0o0000; +pub const REG_EXTENDED: c_int = 0o0001; +pub const REG_ICASE: c_int = 0o0002; +pub const REG_NOSUB: c_int = 0o0004; +pub const REG_NEWLINE: c_int = 0o0010; +pub const REG_NOSPEC: c_int = 0o0020; +pub const REG_PEND: c_int = 0o0040; +pub const REG_DUMP: c_int = 0o0200; + +pub const REG_NOMATCH: c_int = 1; +pub const REG_BADPAT: c_int = 2; +pub const REG_ECOLLATE: c_int = 3; +pub const REG_ECTYPE: c_int = 4; +pub const REG_EESCAPE: c_int = 5; +pub const REG_ESUBREG: c_int = 6; +pub const REG_EBRACK: c_int = 7; +pub const REG_EPAREN: c_int = 8; +pub const REG_EBRACE: c_int = 9; +pub const REG_BADBR: c_int = 10; +pub const REG_ERANGE: c_int = 11; +pub const REG_ESPACE: c_int = 12; +pub const REG_BADRPT: c_int = 13; +pub const REG_EMPTY: c_int = 14; +pub const REG_ASSERT: c_int = 15; +pub const REG_INVARG: c_int = 16; +pub const REG_ATOI: c_int = 255; +pub const REG_ITOA: c_int = 0o0400; + +pub const REG_NOTBOL: c_int = 0o00001; +pub const REG_NOTEOL: c_int = 0o00002; +pub const REG_STARTEND: c_int = 0o00004; +pub const REG_TRACE: c_int = 0o00400; +pub const REG_LARGE: c_int = 0o01000; +pub const REG_BACKR: c_int = 0o02000; + +pub const TIOCCBRK: c_uint = 0x2000747a; +pub const TIOCSBRK: c_uint = 0x2000747b; + +pub const PRIO_PROCESS: c_int = 0; +pub const PRIO_PGRP: c_int = 1; +pub const PRIO_USER: c_int = 2; + +pub const ITIMER_REAL: c_int = 0; +pub const ITIMER_VIRTUAL: c_int = 1; +pub const ITIMER_PROF: c_int = 2; + +// net/route.h + +pub const RTF_UP: c_int = 0x1; +pub const RTF_GATEWAY: c_int = 0x2; +pub const RTF_HOST: c_int = 0x4; +pub const RTF_REJECT: c_int = 0x8; +pub const RTF_DYNAMIC: c_int = 0x10; +pub const RTF_MODIFIED: c_int = 0x20; +pub const RTF_DONE: c_int = 0x40; +pub const RTF_STATIC: c_int = 0x800; +pub const RTF_BLACKHOLE: c_int = 0x1000; +pub const RTF_PROTO2: c_int = 0x4000; +pub const RTF_PROTO1: c_int = 0x8000; + +// Message types +pub const RTM_ADD: c_int = 0x1; +pub const RTM_DELETE: c_int = 0x2; +pub const RTM_CHANGE: c_int = 0x3; +pub const RTM_GET: c_int = 0x4; +pub const RTM_LOSING: c_int = 0x5; +pub const RTM_REDIRECT: c_int = 0x6; +pub const RTM_MISS: c_int = 0x7; + +// Bitmask values for rtm_addrs. +pub const RTA_DST: c_int = 0x1; +pub const RTA_GATEWAY: c_int = 0x2; +pub const RTA_NETMASK: c_int = 0x4; +pub const RTA_GENMASK: c_int = 0x8; +pub const RTA_IFP: c_int = 0x10; +pub const RTA_IFA: c_int = 0x20; +pub const RTA_AUTHOR: c_int = 0x40; +pub const RTA_BRD: c_int = 0x80; + +// Index offsets for sockaddr array for alternate internal encoding. +pub const RTAX_DST: c_int = 0; +pub const RTAX_GATEWAY: c_int = 1; +pub const RTAX_NETMASK: c_int = 2; +pub const RTAX_GENMASK: c_int = 3; +pub const RTAX_IFP: c_int = 4; +pub const RTAX_IFA: c_int = 5; +pub const RTAX_AUTHOR: c_int = 6; +pub const RTAX_BRD: c_int = 7; + +f! { + pub fn CMSG_FIRSTHDR(mhdr: *const crate::msghdr) -> *mut cmsghdr { + if (*mhdr).msg_controllen as usize >= size_of::() { + (*mhdr).msg_control.cast::() + } else { + core::ptr::null_mut() + } + } + + pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { + let bits = size_of_val(&(*set).fds_bits[0]) * 8; + let fd = fd as usize; + (*set).fds_bits[fd / bits] &= !(1 << (fd % bits)); + return; + } + + pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { + let bits = size_of_val(&(*set).fds_bits[0]) * 8; + let fd = fd as usize; + return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0; + } + + pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { + let bits = size_of_val(&(*set).fds_bits[0]) * 8; + let fd = fd as usize; + (*set).fds_bits[fd / bits] |= 1 << (fd % bits); + return; + } + + pub fn FD_ZERO(set: *mut fd_set) -> () { + for slot in &mut (*set).fds_bits { + *slot = 0; + } + } +} + +safe_f! { + pub const fn WTERMSIG(status: c_int) -> c_int { + status & 0o177 + } + + pub const fn WIFEXITED(status: c_int) -> bool { + (status & 0o177) == 0 + } + + pub const fn WEXITSTATUS(status: c_int) -> c_int { + (status >> 8) & 0x00ff + } + + pub const fn WCOREDUMP(status: c_int) -> bool { + (status & 0o200) != 0 + } + + pub const fn QCMD(cmd: c_int, type_: c_int) -> c_int { + (cmd << 8) | (type_ & 0x00ff) + } +} + +extern "C" { + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "getrlimit$UNIX2003" + )] + pub fn getrlimit(resource: c_int, rlim: *mut crate::rlimit) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "setrlimit$UNIX2003" + )] + pub fn setrlimit(resource: c_int, rlim: *const crate::rlimit) -> c_int; + + pub fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int; + pub fn abs(i: c_int) -> c_int; + pub fn labs(i: c_long) -> c_long; + #[cfg_attr( + all(target_os = "freebsd", any(freebsd12, freebsd11, freebsd10)), + link_name = "rand@FBSD_1.0" + )] + pub fn rand() -> c_int; + #[cfg_attr( + all(target_os = "freebsd", any(freebsd12, freebsd11, freebsd10)), + link_name = "srand@FBSD_1.0" + )] + pub fn srand(seed: c_uint); + + pub fn getifaddrs(ifap: *mut *mut crate::ifaddrs) -> c_int; + pub fn freeifaddrs(ifa: *mut crate::ifaddrs); + pub fn setgroups(ngroups: c_int, ptr: *const crate::gid_t) -> c_int; + pub fn setlogin(name: *const c_char) -> c_int; + pub fn ioctl(fd: c_int, request: c_ulong, ...) -> c_int; + pub fn kqueue() -> c_int; + pub fn unmount(target: *const c_char, arg: c_int) -> c_int; + pub fn syscall(num: c_int, ...) -> c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__getpwent50")] + pub fn getpwent() -> *mut passwd; + pub fn setpwent(); + pub fn endpwent(); + pub fn endgrent(); + pub fn getgrent() -> *mut crate::group; + + pub fn getprogname() -> *const c_char; + pub fn setprogname(name: *const c_char); + pub fn getloadavg(loadavg: *mut c_double, nelem: c_int) -> c_int; + pub fn if_nameindex() -> *mut if_nameindex; + pub fn if_freenameindex(ptr: *mut if_nameindex); + + pub fn getpeereid(socket: c_int, euid: *mut crate::uid_t, egid: *mut crate::gid_t) -> c_int; + + #[cfg_attr( + all(target_os = "macos", not(target_arch = "aarch64")), + link_name = "glob$INODE64" + )] + #[cfg_attr(target_os = "netbsd", link_name = "__glob30")] + #[cfg_attr( + all(target_os = "freebsd", any(freebsd11, freebsd10)), + link_name = "glob@FBSD_1.0" + )] + pub fn glob( + pattern: *const c_char, + flags: c_int, + errfunc: Option c_int>, + pglob: *mut crate::glob_t, + ) -> c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__globfree30")] + #[cfg_attr( + all(target_os = "freebsd", any(freebsd11, freebsd10)), + link_name = "globfree@FBSD_1.0" + )] + pub fn globfree(pglob: *mut crate::glob_t); + + pub fn posix_madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; + + pub fn shm_unlink(name: *const c_char) -> c_int; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86_64"), + link_name = "seekdir$INODE64" + )] + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "seekdir$INODE64$UNIX2003" + )] + pub fn seekdir(dirp: *mut crate::DIR, loc: c_long); + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86_64"), + link_name = "telldir$INODE64" + )] + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "telldir$INODE64$UNIX2003" + )] + pub fn telldir(dirp: *mut crate::DIR) -> c_long; + pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "msync$UNIX2003" + )] + #[cfg_attr(target_os = "netbsd", link_name = "__msync13")] + pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "recvfrom$UNIX2003" + )] + pub fn recvfrom( + socket: c_int, + buf: *mut c_void, + len: size_t, + flags: c_int, + addr: *mut crate::sockaddr, + addrlen: *mut crate::socklen_t, + ) -> ssize_t; + pub fn mkstemps(template: *mut c_char, suffixlen: c_int) -> c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__futimes50")] + pub fn futimes(fd: c_int, times: *const crate::timeval) -> c_int; + pub fn nl_langinfo(item: crate::nl_item) -> *mut c_char; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "bind$UNIX2003" + )] + pub fn bind( + socket: c_int, + address: *const crate::sockaddr, + address_len: crate::socklen_t, + ) -> c_int; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "writev$UNIX2003" + )] + pub fn writev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "readv$UNIX2003" + )] + pub fn readv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "sendmsg$UNIX2003" + )] + pub fn sendmsg(fd: c_int, msg: *const crate::msghdr, flags: c_int) -> ssize_t; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "recvmsg$UNIX2003" + )] + pub fn recvmsg(fd: c_int, msg: *mut crate::msghdr, flags: c_int) -> ssize_t; + + pub fn sync(); + pub fn getgrgid_r( + gid: crate::gid_t, + grp: *mut crate::group, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::group, + ) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "sigaltstack$UNIX2003" + )] + #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")] + pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__sigsuspend14")] + pub fn sigsuspend(mask: *const crate::sigset_t) -> c_int; + pub fn sem_close(sem: *mut sem_t) -> c_int; + pub fn getdtablesize() -> c_int; + pub fn getgrnam_r( + name: *const c_char, + grp: *mut crate::group, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::group, + ) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_sigmask$UNIX2003" + )] + pub fn pthread_sigmask(how: c_int, set: *const sigset_t, oldset: *mut sigset_t) -> c_int; + pub fn sem_open(name: *const c_char, oflag: c_int, ...) -> *mut sem_t; + pub fn getgrnam(name: *const c_char) -> *mut crate::group; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_cancel$UNIX2003" + )] + pub fn pthread_cancel(thread: crate::pthread_t) -> c_int; + pub fn pthread_kill(thread: crate::pthread_t, sig: c_int) -> c_int; + pub fn sched_get_priority_min(policy: c_int) -> c_int; + pub fn sched_get_priority_max(policy: c_int) -> c_int; + pub fn sem_unlink(name: *const c_char) -> c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")] + pub fn getpwnam_r( + name: *const c_char, + pwd: *mut passwd, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut passwd, + ) -> c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")] + pub fn getpwuid_r( + uid: crate::uid_t, + pwd: *mut passwd, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut passwd, + ) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "sigwait$UNIX2003" + )] + pub fn sigwait(set: *const sigset_t, sig: *mut c_int) -> c_int; + pub fn pthread_atfork( + prepare: Option, + parent: Option, + child: Option, + ) -> c_int; + pub fn getgrgid(gid: crate::gid_t) -> *mut crate::group; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "popen$UNIX2003" + )] + pub fn popen(command: *const c_char, mode: *const c_char) -> *mut crate::FILE; + pub fn faccessat(dirfd: c_int, pathname: *const c_char, mode: c_int, flags: c_int) -> c_int; + pub fn pthread_create( + native: *mut crate::pthread_t, + attr: *const crate::pthread_attr_t, + f: extern "C" fn(*mut c_void) -> *mut c_void, + value: *mut c_void, + ) -> c_int; + pub fn acct(filename: *const c_char) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "wait4$UNIX2003" + )] + #[cfg_attr( + all(target_os = "freebsd", any(freebsd12, freebsd11, freebsd10)), + link_name = "wait4@FBSD_1.0" + )] + #[cfg_attr(target_os = "netbsd", link_name = "__wait450")] + pub fn wait4( + pid: crate::pid_t, + status: *mut c_int, + options: c_int, + rusage: *mut crate::rusage, + ) -> crate::pid_t; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "getitimer$UNIX2003" + )] + #[cfg_attr(target_os = "netbsd", link_name = "__getitimer50")] + pub fn getitimer(which: c_int, curr_value: *mut crate::itimerval) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "setitimer$UNIX2003" + )] + #[cfg_attr(target_os = "netbsd", link_name = "__setitimer50")] + pub fn setitimer( + which: c_int, + new_value: *const crate::itimerval, + old_value: *mut crate::itimerval, + ) -> c_int; + + pub fn regcomp(preg: *mut regex_t, pattern: *const c_char, cflags: c_int) -> c_int; + + pub fn regexec( + preg: *const regex_t, + input: *const c_char, + nmatch: size_t, + pmatch: *mut regmatch_t, + eflags: c_int, + ) -> c_int; + + pub fn regerror( + errcode: c_int, + preg: *const regex_t, + errbuf: *mut c_char, + errbuf_size: size_t, + ) -> size_t; + + pub fn regfree(preg: *mut regex_t); + + pub fn arc4random() -> u32; + pub fn arc4random_buf(buf: *mut c_void, size: size_t); + pub fn arc4random_uniform(l: u32) -> u32; + + pub fn drand48() -> c_double; + pub fn erand48(xseed: *mut c_ushort) -> c_double; + pub fn lrand48() -> c_long; + pub fn nrand48(xseed: *mut c_ushort) -> c_long; + pub fn mrand48() -> c_long; + pub fn jrand48(xseed: *mut c_ushort) -> c_long; + pub fn srand48(seed: c_long); + pub fn seed48(xseed: *mut c_ushort) -> *mut c_ushort; + pub fn lcong48(p: *mut c_ushort); + pub fn getopt_long( + argc: c_int, + argv: *const *mut c_char, + optstring: *const c_char, + longopts: *const option, + longindex: *mut c_int, + ) -> c_int; + + pub fn strftime( + buf: *mut c_char, + maxsize: size_t, + format: *const c_char, + timeptr: *const crate::tm, + ) -> size_t; + pub fn strftime_l( + buf: *mut c_char, + maxsize: size_t, + format: *const c_char, + timeptr: *const crate::tm, + locale: crate::locale_t, + ) -> size_t; + + #[cfg_attr(target_os = "netbsd", link_name = "__devname50")] + pub fn devname(dev: crate::dev_t, mode_t: crate::mode_t) -> *mut c_char; + + pub fn issetugid() -> c_int; +} + +cfg_if! { + if #[cfg(any( + target_os = "macos", + target_os = "ios", + target_os = "tvos", + target_os = "watchos", + target_os = "visionos" + ))] { + mod apple; + pub use self::apple::*; + } else if #[cfg(any(target_os = "openbsd", target_os = "netbsd"))] { + mod netbsdlike; + pub use self::netbsdlike::*; + } else if #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] { + mod freebsdlike; + pub use self::freebsdlike::*; + } else { + // Unknown target_os + } +} diff --git a/http/vendor/libc/src/unix/bsd/netbsdlike/mod.rs b/http/vendor/libc/src/unix/bsd/netbsdlike/mod.rs new file mode 100644 index 0000000..ac0d912 --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/netbsdlike/mod.rs @@ -0,0 +1,882 @@ +use crate::off_t; +use crate::prelude::*; + +pub type wchar_t = i32; +pub type time_t = i64; +pub type mode_t = u32; +pub type nlink_t = u32; +pub type ino_t = u64; +pub type pthread_key_t = c_int; +pub type rlim_t = u64; +pub type speed_t = c_uint; +pub type tcflag_t = c_uint; +pub type nl_item = c_long; +pub type clockid_t = c_int; +pub type id_t = u32; +pub type sem_t = *mut sem; +pub type key_t = c_long; + +extern_ty! { + pub enum timezone {} + pub enum sem {} +} + +s! { + pub struct sched_param { + pub sched_priority: c_int, + } + + pub struct sigaction { + pub sa_sigaction: crate::sighandler_t, + pub sa_mask: crate::sigset_t, + pub sa_flags: c_int, + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_size: size_t, + pub ss_flags: c_int, + } + + pub struct in6_pktinfo { + pub ipi6_addr: crate::in6_addr, + pub ipi6_ifindex: c_uint, + } + + pub struct termios { + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_cc: [crate::cc_t; crate::NCCS], + pub c_ispeed: c_int, + pub c_ospeed: c_int, + } + + pub struct flock { + pub l_start: off_t, + pub l_len: off_t, + pub l_pid: crate::pid_t, + pub l_type: c_short, + pub l_whence: c_short, + } + + pub struct ptrace_io_desc { + pub piod_op: c_int, + pub piod_offs: *mut c_void, + pub piod_addr: *mut c_void, + pub piod_len: size_t, + } + + pub struct mmsghdr { + pub msg_hdr: crate::msghdr, + pub msg_len: c_uint, + } +} + +pub const D_T_FMT: crate::nl_item = 0; +pub const D_FMT: crate::nl_item = 1; +pub const T_FMT: crate::nl_item = 2; +pub const T_FMT_AMPM: crate::nl_item = 3; +pub const AM_STR: crate::nl_item = 4; +pub const PM_STR: crate::nl_item = 5; + +pub const DAY_1: crate::nl_item = 6; +pub const DAY_2: crate::nl_item = 7; +pub const DAY_3: crate::nl_item = 8; +pub const DAY_4: crate::nl_item = 9; +pub const DAY_5: crate::nl_item = 10; +pub const DAY_6: crate::nl_item = 11; +pub const DAY_7: crate::nl_item = 12; + +pub const ABDAY_1: crate::nl_item = 13; +pub const ABDAY_2: crate::nl_item = 14; +pub const ABDAY_3: crate::nl_item = 15; +pub const ABDAY_4: crate::nl_item = 16; +pub const ABDAY_5: crate::nl_item = 17; +pub const ABDAY_6: crate::nl_item = 18; +pub const ABDAY_7: crate::nl_item = 19; + +pub const MON_1: crate::nl_item = 20; +pub const MON_2: crate::nl_item = 21; +pub const MON_3: crate::nl_item = 22; +pub const MON_4: crate::nl_item = 23; +pub const MON_5: crate::nl_item = 24; +pub const MON_6: crate::nl_item = 25; +pub const MON_7: crate::nl_item = 26; +pub const MON_8: crate::nl_item = 27; +pub const MON_9: crate::nl_item = 28; +pub const MON_10: crate::nl_item = 29; +pub const MON_11: crate::nl_item = 30; +pub const MON_12: crate::nl_item = 31; + +pub const ABMON_1: crate::nl_item = 32; +pub const ABMON_2: crate::nl_item = 33; +pub const ABMON_3: crate::nl_item = 34; +pub const ABMON_4: crate::nl_item = 35; +pub const ABMON_5: crate::nl_item = 36; +pub const ABMON_6: crate::nl_item = 37; +pub const ABMON_7: crate::nl_item = 38; +pub const ABMON_8: crate::nl_item = 39; +pub const ABMON_9: crate::nl_item = 40; +pub const ABMON_10: crate::nl_item = 41; +pub const ABMON_11: crate::nl_item = 42; +pub const ABMON_12: crate::nl_item = 43; + +pub const RADIXCHAR: crate::nl_item = 44; +pub const THOUSEP: crate::nl_item = 45; +pub const YESSTR: crate::nl_item = 46; +pub const YESEXPR: crate::nl_item = 47; +pub const NOSTR: crate::nl_item = 48; +pub const NOEXPR: crate::nl_item = 49; +pub const CRNCYSTR: crate::nl_item = 50; + +pub const CODESET: crate::nl_item = 51; + +pub const EXIT_FAILURE: c_int = 1; +pub const EXIT_SUCCESS: c_int = 0; +pub const RAND_MAX: c_int = 2147483647; +pub const EOF: c_int = -1; +pub const SEEK_SET: c_int = 0; +pub const SEEK_CUR: c_int = 1; +pub const SEEK_END: c_int = 2; +pub const _IOFBF: c_int = 0; +pub const _IONBF: c_int = 2; +pub const _IOLBF: c_int = 1; +pub const BUFSIZ: c_uint = 1024; +pub const FOPEN_MAX: c_uint = 20; +pub const FILENAME_MAX: c_uint = 1024; +pub const L_tmpnam: c_uint = 1024; +pub const O_NOCTTY: c_int = 32768; +pub const S_IFIFO: mode_t = 0o1_0000; +pub const S_IFCHR: mode_t = 0o2_0000; +pub const S_IFBLK: mode_t = 0o6_0000; +pub const S_IFDIR: mode_t = 0o4_0000; +pub const S_IFREG: mode_t = 0o10_0000; +pub const S_IFLNK: mode_t = 0o12_0000; +pub const S_IFSOCK: mode_t = 0o14_0000; +pub const S_IFMT: mode_t = 0o17_0000; +pub const S_IEXEC: mode_t = 0o0100; +pub const S_IWRITE: mode_t = 0o0200; +pub const S_IREAD: mode_t = 0o0400; +pub const S_IRWXU: mode_t = 0o0700; +pub const S_IXUSR: mode_t = 0o0100; +pub const S_IWUSR: mode_t = 0o0200; +pub const S_IRUSR: mode_t = 0o0400; +pub const S_IRWXG: mode_t = 0o0070; +pub const S_IXGRP: mode_t = 0o0010; +pub const S_IWGRP: mode_t = 0o0020; +pub const S_IRGRP: mode_t = 0o0040; +pub const S_IRWXO: mode_t = 0o0007; +pub const S_IXOTH: mode_t = 0o0001; +pub const S_IWOTH: mode_t = 0o0002; +pub const S_IROTH: mode_t = 0o0004; +pub const F_OK: c_int = 0; +pub const R_OK: c_int = 4; +pub const W_OK: c_int = 2; +pub const X_OK: c_int = 1; +pub const F_LOCK: c_int = 1; +pub const F_TEST: c_int = 3; +pub const F_TLOCK: c_int = 2; +pub const F_ULOCK: c_int = 0; +pub const F_GETLK: c_int = 7; +pub const F_SETLK: c_int = 8; +pub const F_SETLKW: c_int = 9; +pub const SIGHUP: c_int = 1; +pub const SIGINT: c_int = 2; +pub const SIGQUIT: c_int = 3; +pub const SIGILL: c_int = 4; +pub const SIGABRT: c_int = 6; +pub const SIGEMT: c_int = 7; +pub const SIGFPE: c_int = 8; +pub const SIGKILL: c_int = 9; +pub const SIGSEGV: c_int = 11; +pub const SIGPIPE: c_int = 13; +pub const SIGALRM: c_int = 14; +pub const SIGTERM: c_int = 15; + +pub const PROT_NONE: c_int = 0; +pub const PROT_READ: c_int = 1; +pub const PROT_WRITE: c_int = 2; +pub const PROT_EXEC: c_int = 4; + +pub const MAP_FILE: c_int = 0x0000; +pub const MAP_SHARED: c_int = 0x0001; +pub const MAP_PRIVATE: c_int = 0x0002; +pub const MAP_FIXED: c_int = 0x0010; +pub const MAP_ANON: c_int = 0x1000; +pub const MAP_ANONYMOUS: c_int = MAP_ANON; + +pub const MAP_FAILED: *mut c_void = !0 as *mut c_void; + +pub const IPC_CREAT: c_int = 0o001000; +pub const IPC_EXCL: c_int = 0o002000; +pub const IPC_NOWAIT: c_int = 0o004000; + +pub const IPC_PRIVATE: crate::key_t = 0; + +pub const IPC_RMID: c_int = 0; +pub const IPC_SET: c_int = 1; +pub const IPC_STAT: c_int = 2; + +pub const IPC_R: c_int = 0o000400; +pub const IPC_W: c_int = 0o000200; +pub const IPC_M: c_int = 0o010000; + +pub const SHM_R: c_int = IPC_R; +pub const SHM_W: c_int = IPC_W; + +pub const MCL_CURRENT: c_int = 0x0001; +pub const MCL_FUTURE: c_int = 0x0002; + +pub const MS_ASYNC: c_int = 0x0001; + +pub const EPERM: c_int = 1; +pub const ENOENT: c_int = 2; +pub const ESRCH: c_int = 3; +pub const EINTR: c_int = 4; +pub const EIO: c_int = 5; +pub const ENXIO: c_int = 6; +pub const E2BIG: c_int = 7; +pub const ENOEXEC: c_int = 8; +pub const EBADF: c_int = 9; +pub const ECHILD: c_int = 10; +pub const EDEADLK: c_int = 11; +pub const ENOMEM: c_int = 12; +pub const EACCES: c_int = 13; +pub const EFAULT: c_int = 14; +pub const ENOTBLK: c_int = 15; +pub const EBUSY: c_int = 16; +pub const EEXIST: c_int = 17; +pub const EXDEV: c_int = 18; +pub const ENODEV: c_int = 19; +pub const ENOTDIR: c_int = 20; +pub const EISDIR: c_int = 21; +pub const EINVAL: c_int = 22; +pub const ENFILE: c_int = 23; +pub const EMFILE: c_int = 24; +pub const ENOTTY: c_int = 25; +pub const ETXTBSY: c_int = 26; +pub const EFBIG: c_int = 27; +pub const ENOSPC: c_int = 28; +pub const ESPIPE: c_int = 29; +pub const EROFS: c_int = 30; +pub const EMLINK: c_int = 31; +pub const EPIPE: c_int = 32; +pub const EDOM: c_int = 33; +pub const ERANGE: c_int = 34; +pub const EAGAIN: c_int = 35; +pub const EWOULDBLOCK: c_int = 35; +pub const EINPROGRESS: c_int = 36; +pub const EALREADY: c_int = 37; +pub const ENOTSOCK: c_int = 38; +pub const EDESTADDRREQ: c_int = 39; +pub const EMSGSIZE: c_int = 40; +pub const EPROTOTYPE: c_int = 41; +pub const ENOPROTOOPT: c_int = 42; +pub const EPROTONOSUPPORT: c_int = 43; +pub const ESOCKTNOSUPPORT: c_int = 44; +pub const EOPNOTSUPP: c_int = 45; +pub const EPFNOSUPPORT: c_int = 46; +pub const EAFNOSUPPORT: c_int = 47; +pub const EADDRINUSE: c_int = 48; +pub const EADDRNOTAVAIL: c_int = 49; +pub const ENETDOWN: c_int = 50; +pub const ENETUNREACH: c_int = 51; +pub const ENETRESET: c_int = 52; +pub const ECONNABORTED: c_int = 53; +pub const ECONNRESET: c_int = 54; +pub const ENOBUFS: c_int = 55; +pub const EISCONN: c_int = 56; +pub const ENOTCONN: c_int = 57; +pub const ESHUTDOWN: c_int = 58; +pub const ETOOMANYREFS: c_int = 59; +pub const ETIMEDOUT: c_int = 60; +pub const ECONNREFUSED: c_int = 61; +pub const ELOOP: c_int = 62; +pub const ENAMETOOLONG: c_int = 63; +pub const EHOSTDOWN: c_int = 64; +pub const EHOSTUNREACH: c_int = 65; +pub const ENOTEMPTY: c_int = 66; +pub const EPROCLIM: c_int = 67; +pub const EUSERS: c_int = 68; +pub const EDQUOT: c_int = 69; +pub const ESTALE: c_int = 70; +pub const EREMOTE: c_int = 71; +pub const EBADRPC: c_int = 72; +pub const ERPCMISMATCH: c_int = 73; +pub const EPROGUNAVAIL: c_int = 74; +pub const EPROGMISMATCH: c_int = 75; +pub const EPROCUNAVAIL: c_int = 76; +pub const ENOLCK: c_int = 77; +pub const ENOSYS: c_int = 78; +pub const EFTYPE: c_int = 79; +pub const EAUTH: c_int = 80; +pub const ENEEDAUTH: c_int = 81; + +pub const F_DUPFD: c_int = 0; +pub const F_GETFD: c_int = 1; +pub const F_SETFD: c_int = 2; +pub const F_GETFL: c_int = 3; +pub const F_SETFL: c_int = 4; + +pub const SIGTRAP: c_int = 5; + +pub const GLOB_APPEND: c_int = 0x0001; +pub const GLOB_DOOFFS: c_int = 0x0002; +pub const GLOB_ERR: c_int = 0x0004; +pub const GLOB_MARK: c_int = 0x0008; +pub const GLOB_NOCHECK: c_int = 0x0010; +pub const GLOB_NOSORT: c_int = 0x0020; +pub const GLOB_NOESCAPE: c_int = 0x1000; + +pub const GLOB_NOSPACE: c_int = -1; +pub const GLOB_ABORTED: c_int = -2; +pub const GLOB_NOMATCH: c_int = -3; +pub const GLOB_NOSYS: c_int = -4; + +pub const POSIX_MADV_NORMAL: c_int = 0; +pub const POSIX_MADV_RANDOM: c_int = 1; +pub const POSIX_MADV_SEQUENTIAL: c_int = 2; +pub const POSIX_MADV_WILLNEED: c_int = 3; +pub const POSIX_MADV_DONTNEED: c_int = 4; + +// DIFF(main): changed to `c_short` in f62eb023ab +pub const POSIX_SPAWN_RESETIDS: c_int = 0x01; +pub const POSIX_SPAWN_SETPGROUP: c_int = 0x02; +pub const POSIX_SPAWN_SETSCHEDPARAM: c_int = 0x04; +pub const POSIX_SPAWN_SETSCHEDULER: c_int = 0x08; +pub const POSIX_SPAWN_SETSIGDEF: c_int = 0x10; +pub const POSIX_SPAWN_SETSIGMASK: c_int = 0x20; + +pub const PTHREAD_CREATE_JOINABLE: c_int = 0; +pub const PTHREAD_CREATE_DETACHED: c_int = 1; + +pub const PIOD_READ_D: c_int = 1; +pub const PIOD_WRITE_D: c_int = 2; +pub const PIOD_READ_I: c_int = 3; +pub const PIOD_WRITE_I: c_int = 4; +pub const PIOD_READ_AUXV: c_int = 5; + +pub const PT_TRACE_ME: c_int = 0; +pub const PT_READ_I: c_int = 1; +pub const PT_READ_D: c_int = 2; +pub const PT_WRITE_I: c_int = 4; +pub const PT_WRITE_D: c_int = 5; +pub const PT_CONTINUE: c_int = 7; +pub const PT_KILL: c_int = 8; +pub const PT_ATTACH: c_int = 9; +pub const PT_DETACH: c_int = 10; +pub const PT_IO: c_int = 11; + +// http://man.openbsd.org/OpenBSD-current/man2/clock_getres.2 +// The man page says clock_gettime(3) can accept various values as clockid_t but +// http://fxr.watson.org/fxr/source/kern/kern_time.c?v=OPENBSD;im=excerpts#L161 +// the implementation rejects anything other than the below two +// +// http://netbsd.gw.com/cgi-bin/man-cgi?clock_gettime +// https://github.com/jsonn/src/blob/HEAD/sys/kern/subr_time.c#L222 +// Basically the same goes for NetBSD +pub const CLOCK_REALTIME: crate::clockid_t = 0; +pub const CLOCK_MONOTONIC: crate::clockid_t = 3; + +pub const RLIMIT_CPU: c_int = 0; +pub const RLIMIT_FSIZE: c_int = 1; +pub const RLIMIT_DATA: c_int = 2; +pub const RLIMIT_STACK: c_int = 3; +pub const RLIMIT_CORE: c_int = 4; +pub const RLIMIT_RSS: c_int = 5; +pub const RLIMIT_MEMLOCK: c_int = 6; +pub const RLIMIT_NPROC: c_int = 7; +pub const RLIMIT_NOFILE: c_int = 8; + +pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff; +pub const RLIM_SAVED_MAX: rlim_t = RLIM_INFINITY; +pub const RLIM_SAVED_CUR: rlim_t = RLIM_INFINITY; + +pub const RUSAGE_SELF: c_int = 0; +pub const RUSAGE_CHILDREN: c_int = -1; + +pub const MADV_NORMAL: c_int = 0; +pub const MADV_RANDOM: c_int = 1; +pub const MADV_SEQUENTIAL: c_int = 2; +pub const MADV_WILLNEED: c_int = 3; +pub const MADV_DONTNEED: c_int = 4; +pub const MADV_FREE: c_int = 6; + +// sys/fstypes.h in NetBSD, or sys/mount.h in OpenBSD +pub const MNT_NODEV: c_int = 0x00000010; +pub const MNT_LOCAL: c_int = 0x00001000; +pub const MNT_QUOTA: c_int = 0x00002000; + +// sys/ioccom.h in NetBSD and OpenBSD +pub const IOCPARM_MASK: u32 = 0x1fff; + +pub const IOC_VOID: c_ulong = 0x20000000; +pub const IOC_OUT: c_ulong = 0x40000000; +pub const IOC_IN: c_ulong = 0x80000000; +pub const IOC_INOUT: c_ulong = IOC_IN | IOC_OUT; +pub const IOC_DIRMASK: c_ulong = 0xe0000000; + +pub const fn _IO(g: c_ulong, n: c_ulong) -> c_ulong { + _IOC(IOC_VOID, g, n, 0) +} + +/// Build an ioctl number for an read-only ioctl. +pub const fn _IOR(g: c_ulong, n: c_ulong) -> c_ulong { + _IOC(IOC_OUT, g, n, mem::size_of::() as c_ulong) +} + +/// Build an ioctl number for an write-only ioctl. +pub const fn _IOW(g: c_ulong, n: c_ulong) -> c_ulong { + _IOC(IOC_IN, g, n, mem::size_of::() as c_ulong) +} + +/// Build an ioctl number for a read-write ioctl. +pub const fn _IOWR(g: c_ulong, n: c_ulong) -> c_ulong { + _IOC(IOC_INOUT, g, n, mem::size_of::() as c_ulong) +} + +pub const AF_UNSPEC: c_int = 0; +pub const AF_LOCAL: c_int = 1; +pub const AF_UNIX: c_int = AF_LOCAL; +pub const AF_INET: c_int = 2; +pub const AF_IMPLINK: c_int = 3; +pub const AF_PUP: c_int = 4; +pub const AF_CHAOS: c_int = 5; +pub const AF_NS: c_int = 6; +pub const AF_ISO: c_int = 7; +pub const AF_OSI: c_int = AF_ISO; +pub const AF_DATAKIT: c_int = 9; +pub const AF_CCITT: c_int = 10; +pub const AF_SNA: c_int = 11; +pub const AF_DECnet: c_int = 12; +pub const AF_DLI: c_int = 13; +pub const AF_LAT: c_int = 14; +pub const AF_HYLINK: c_int = 15; +pub const AF_APPLETALK: c_int = 16; +pub const AF_LINK: c_int = 18; +pub const pseudo_AF_XTP: c_int = 19; +pub const AF_COIP: c_int = 20; +pub const AF_CNT: c_int = 21; +pub const pseudo_AF_RTIP: c_int = 22; +pub const AF_IPX: c_int = 23; +pub const AF_INET6: c_int = 24; +pub const pseudo_AF_PIP: c_int = 25; +pub const AF_ISDN: c_int = 26; +pub const AF_E164: c_int = AF_ISDN; +pub const AF_NATM: c_int = 27; + +pub const PF_UNSPEC: c_int = AF_UNSPEC; +pub const PF_LOCAL: c_int = AF_LOCAL; +pub const PF_UNIX: c_int = PF_LOCAL; +pub const PF_INET: c_int = AF_INET; +pub const PF_IMPLINK: c_int = AF_IMPLINK; +pub const PF_PUP: c_int = AF_PUP; +pub const PF_CHAOS: c_int = AF_CHAOS; +pub const PF_NS: c_int = AF_NS; +pub const PF_ISO: c_int = AF_ISO; +pub const PF_OSI: c_int = AF_ISO; +pub const PF_DATAKIT: c_int = AF_DATAKIT; +pub const PF_CCITT: c_int = AF_CCITT; +pub const PF_SNA: c_int = AF_SNA; +pub const PF_DECnet: c_int = AF_DECnet; +pub const PF_DLI: c_int = AF_DLI; +pub const PF_LAT: c_int = AF_LAT; +pub const PF_HYLINK: c_int = AF_HYLINK; +pub const PF_APPLETALK: c_int = AF_APPLETALK; +pub const PF_LINK: c_int = AF_LINK; +pub const PF_XTP: c_int = pseudo_AF_XTP; +pub const PF_COIP: c_int = AF_COIP; +pub const PF_CNT: c_int = AF_CNT; +pub const PF_IPX: c_int = AF_IPX; +pub const PF_INET6: c_int = AF_INET6; +pub const PF_RTIP: c_int = pseudo_AF_RTIP; +pub const PF_PIP: c_int = pseudo_AF_PIP; +pub const PF_ISDN: c_int = AF_ISDN; +pub const PF_NATM: c_int = AF_NATM; + +pub const SOCK_STREAM: c_int = 1; +pub const SOCK_DGRAM: c_int = 2; +pub const SOCK_RAW: c_int = 3; +pub const SOCK_RDM: c_int = 4; +pub const SOCK_SEQPACKET: c_int = 5; +pub const IP_TTL: c_int = 4; +pub const IP_HDRINCL: c_int = 2; +pub const IP_ADD_MEMBERSHIP: c_int = 12; +pub const IP_DROP_MEMBERSHIP: c_int = 13; +pub const IPV6_RECVPKTINFO: c_int = 36; +pub const IPV6_PKTINFO: c_int = 46; +pub const IPV6_RECVTCLASS: c_int = 57; +pub const IPV6_TCLASS: c_int = 61; + +pub const SOL_SOCKET: c_int = 0xffff; +pub const SO_DEBUG: c_int = 0x01; +pub const SO_ACCEPTCONN: c_int = 0x0002; +pub const SO_REUSEADDR: c_int = 0x0004; +pub const SO_KEEPALIVE: c_int = 0x0008; +pub const SO_DONTROUTE: c_int = 0x0010; +pub const SO_BROADCAST: c_int = 0x0020; +pub const SO_USELOOPBACK: c_int = 0x0040; +pub const SO_LINGER: c_int = 0x0080; +pub const SO_OOBINLINE: c_int = 0x0100; +pub const SO_REUSEPORT: c_int = 0x0200; +pub const SO_SNDBUF: c_int = 0x1001; +pub const SO_RCVBUF: c_int = 0x1002; +pub const SO_SNDLOWAT: c_int = 0x1003; +pub const SO_RCVLOWAT: c_int = 0x1004; +pub const SO_ERROR: c_int = 0x1007; +pub const SO_TYPE: c_int = 0x1008; + +pub const SOMAXCONN: c_int = 128; + +pub const MSG_OOB: c_int = 0x1; +pub const MSG_PEEK: c_int = 0x2; +pub const MSG_DONTROUTE: c_int = 0x4; +pub const MSG_EOR: c_int = 0x8; +pub const MSG_TRUNC: c_int = 0x10; +pub const MSG_CTRUNC: c_int = 0x20; +pub const MSG_WAITALL: c_int = 0x40; +pub const MSG_DONTWAIT: c_int = 0x80; +pub const MSG_BCAST: c_int = 0x100; +pub const MSG_MCAST: c_int = 0x200; +pub const MSG_NOSIGNAL: c_int = 0x400; +pub const MSG_CMSG_CLOEXEC: c_int = 0x800; + +pub const SHUT_RD: c_int = 0; +pub const SHUT_WR: c_int = 1; +pub const SHUT_RDWR: c_int = 2; + +pub const LOCK_SH: c_int = 1; +pub const LOCK_EX: c_int = 2; +pub const LOCK_NB: c_int = 4; +pub const LOCK_UN: c_int = 8; + +pub const IPPROTO_RAW: c_int = 255; + +pub const _SC_ARG_MAX: c_int = 1; +pub const _SC_CHILD_MAX: c_int = 2; +pub const _SC_NGROUPS_MAX: c_int = 4; +pub const _SC_OPEN_MAX: c_int = 5; +pub const _SC_JOB_CONTROL: c_int = 6; +pub const _SC_SAVED_IDS: c_int = 7; +pub const _SC_VERSION: c_int = 8; +pub const _SC_BC_BASE_MAX: c_int = 9; +pub const _SC_BC_DIM_MAX: c_int = 10; +pub const _SC_BC_SCALE_MAX: c_int = 11; +pub const _SC_BC_STRING_MAX: c_int = 12; +pub const _SC_COLL_WEIGHTS_MAX: c_int = 13; +pub const _SC_EXPR_NEST_MAX: c_int = 14; +pub const _SC_LINE_MAX: c_int = 15; +pub const _SC_RE_DUP_MAX: c_int = 16; +pub const _SC_2_VERSION: c_int = 17; +pub const _SC_2_C_BIND: c_int = 18; +pub const _SC_2_C_DEV: c_int = 19; +pub const _SC_2_CHAR_TERM: c_int = 20; +pub const _SC_2_FORT_DEV: c_int = 21; +pub const _SC_2_FORT_RUN: c_int = 22; +pub const _SC_2_LOCALEDEF: c_int = 23; +pub const _SC_2_SW_DEV: c_int = 24; +pub const _SC_2_UPE: c_int = 25; +pub const _SC_STREAM_MAX: c_int = 26; +pub const _SC_TZNAME_MAX: c_int = 27; +pub const _SC_PAGESIZE: c_int = 28; +pub const _SC_PAGE_SIZE: c_int = _SC_PAGESIZE; +pub const _SC_FSYNC: c_int = 29; +pub const _SC_XOPEN_SHM: c_int = 30; + +pub const Q_GETQUOTA: c_int = 0x300; +pub const Q_SETQUOTA: c_int = 0x400; + +pub const RTLD_GLOBAL: c_int = 0x100; + +pub const LOG_NFACILITIES: c_int = 24; + +pub const HW_NCPU: c_int = 3; + +pub const B0: speed_t = 0; +pub const B50: speed_t = 50; +pub const B75: speed_t = 75; +pub const B110: speed_t = 110; +pub const B134: speed_t = 134; +pub const B150: speed_t = 150; +pub const B200: speed_t = 200; +pub const B300: speed_t = 300; +pub const B600: speed_t = 600; +pub const B1200: speed_t = 1200; +pub const B1800: speed_t = 1800; +pub const B2400: speed_t = 2400; +pub const B4800: speed_t = 4800; +pub const B9600: speed_t = 9600; +pub const B19200: speed_t = 19200; +pub const B38400: speed_t = 38400; +pub const B7200: speed_t = 7200; +pub const B14400: speed_t = 14400; +pub const B28800: speed_t = 28800; +pub const B57600: speed_t = 57600; +pub const B76800: speed_t = 76800; +pub const B115200: speed_t = 115200; +pub const B230400: speed_t = 230400; +pub const EXTA: speed_t = 19200; +pub const EXTB: speed_t = 38400; + +pub const SEM_FAILED: *mut sem_t = ptr::null_mut(); + +pub const CRTSCTS: crate::tcflag_t = 0x00010000; +pub const CRTS_IFLOW: crate::tcflag_t = CRTSCTS; +pub const CCTS_OFLOW: crate::tcflag_t = CRTSCTS; +pub const OCRNL: crate::tcflag_t = 0x10; + +pub const TIOCEXCL: c_ulong = 0x2000740d; +pub const TIOCNXCL: c_ulong = 0x2000740e; +pub const TIOCFLUSH: c_ulong = 0x80047410; +pub const TIOCGETA: c_ulong = 0x402c7413; +pub const TIOCSETA: c_ulong = 0x802c7414; +pub const TIOCSETAW: c_ulong = 0x802c7415; +pub const TIOCSETAF: c_ulong = 0x802c7416; +pub const TIOCGETD: c_ulong = 0x4004741a; +pub const TIOCSETD: c_ulong = 0x8004741b; +pub const TIOCMGET: c_ulong = 0x4004746a; +pub const TIOCMBIC: c_ulong = 0x8004746b; +pub const TIOCMBIS: c_ulong = 0x8004746c; +pub const TIOCMSET: c_ulong = 0x8004746d; +pub const TIOCSTART: c_ulong = 0x2000746e; +pub const TIOCSTOP: c_ulong = 0x2000746f; +pub const TIOCSCTTY: c_ulong = 0x20007461; +pub const TIOCGWINSZ: c_ulong = 0x40087468; +pub const TIOCSWINSZ: c_ulong = 0x80087467; +pub const TIOCM_LE: c_int = 0o0001; +pub const TIOCM_DTR: c_int = 0o0002; +pub const TIOCM_RTS: c_int = 0o0004; +pub const TIOCM_ST: c_int = 0o0010; +pub const TIOCM_SR: c_int = 0o0020; +pub const TIOCM_CTS: c_int = 0o0040; +pub const TIOCM_CAR: c_int = 0o0100; +pub const TIOCM_RNG: c_int = 0o0200; +pub const TIOCM_DSR: c_int = 0o0400; +pub const TIOCM_CD: c_int = TIOCM_CAR; +pub const TIOCM_RI: c_int = TIOCM_RNG; + +pub const TIMER_ABSTIME: c_int = 1; + +// sys/reboot.h + +pub const RB_AUTOBOOT: c_int = 0; + +pub const TCP_INFO: c_int = 9; + +#[link(name = "util")] +extern "C" { + pub fn setgrent(); + pub fn sem_destroy(sem: *mut sem_t) -> c_int; + pub fn sem_init(sem: *mut sem_t, pshared: c_int, value: c_uint) -> c_int; + + pub fn daemon(nochdir: c_int, noclose: c_int) -> c_int; + pub fn accept4( + s: c_int, + addr: *mut crate::sockaddr, + addrlen: *mut crate::socklen_t, + flags: c_int, + ) -> c_int; + pub fn mincore(addr: *mut c_void, len: size_t, vec: *mut c_char) -> c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__clock_getres50")] + pub fn clock_getres(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__clock_gettime50")] + pub fn clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__clock_settime50")] + pub fn clock_settime(clk_id: crate::clockid_t, tp: *const crate::timespec) -> c_int; + pub fn __errno() -> *mut c_int; + pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int; + pub fn memrchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; + pub fn mkostemp(template: *mut c_char, flags: c_int) -> c_int; + pub fn mkostemps(template: *mut c_char, suffixlen: c_int, flags: c_int) -> c_int; + pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t; + pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t; + pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int; + pub fn utimensat( + dirfd: c_int, + path: *const c_char, + times: *const crate::timespec, + flag: c_int, + ) -> c_int; + pub fn fdatasync(fd: c_int) -> c_int; + pub fn login_tty(fd: c_int) -> c_int; + pub fn getpriority(which: c_int, who: crate::id_t) -> c_int; + pub fn setpriority(which: c_int, who: crate::id_t, prio: c_int) -> c_int; + + pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: crate::dev_t) + -> c_int; + pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; + pub fn sem_timedwait(sem: *mut sem_t, abstime: *const crate::timespec) -> c_int; + pub fn sem_getvalue(sem: *mut sem_t, sval: *mut c_int) -> c_int; + pub fn pthread_condattr_setclock( + attr: *mut pthread_condattr_t, + clock_id: crate::clockid_t, + ) -> c_int; + pub fn sethostname(name: *const c_char, len: size_t) -> c_int; + pub fn pthread_mutex_timedlock( + lock: *mut pthread_mutex_t, + abstime: *const crate::timespec, + ) -> c_int; + pub fn pthread_spin_init(lock: *mut pthread_spinlock_t, pshared: c_int) -> c_int; + pub fn pthread_spin_destroy(lock: *mut pthread_spinlock_t) -> c_int; + pub fn pthread_spin_lock(lock: *mut pthread_spinlock_t) -> c_int; + pub fn pthread_spin_trylock(lock: *mut pthread_spinlock_t) -> c_int; + pub fn pthread_spin_unlock(lock: *mut pthread_spinlock_t) -> c_int; + pub fn pthread_setschedparam( + native: crate::pthread_t, + policy: c_int, + param: *const sched_param, + ) -> c_int; + pub fn pthread_getschedparam( + native: crate::pthread_t, + policy: *mut c_int, + param: *mut sched_param, + ) -> c_int; + pub fn pipe2(fds: *mut c_int, flags: c_int) -> c_int; + pub fn ppoll( + fds: *mut crate::pollfd, + nfds: crate::nfds_t, + ts: *const crate::timespec, + sigmask: *const crate::sigset_t, + ) -> c_int; + + pub fn getgrouplist( + name: *const c_char, + basegid: crate::gid_t, + groups: *mut crate::gid_t, + ngroups: *mut c_int, + ) -> c_int; + pub fn initgroups(name: *const c_char, basegid: crate::gid_t) -> c_int; + pub fn getdomainname(name: *mut c_char, len: size_t) -> c_int; + pub fn setdomainname(name: *const c_char, len: size_t) -> c_int; + pub fn uname(buf: *mut crate::utsname) -> c_int; + + pub fn shmget(key: crate::key_t, size: size_t, shmflg: c_int) -> c_int; + pub fn shmat(shmid: c_int, shmaddr: *const c_void, shmflg: c_int) -> *mut c_void; + pub fn shmdt(shmaddr: *const c_void) -> c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__shmctl50")] + pub fn shmctl(shmid: c_int, cmd: c_int, buf: *mut crate::shmid_ds) -> c_int; + + // DIFF(main): changed to `*const *mut` in e77f551de9 + pub fn execvpe( + file: *const c_char, + argv: *const *const c_char, + envp: *const *const c_char, + ) -> c_int; + + pub fn waitid( + idtype: idtype_t, + id: crate::id_t, + infop: *mut crate::siginfo_t, + options: c_int, + ) -> c_int; + + pub fn posix_spawn( + pid: *mut crate::pid_t, + path: *const c_char, + file_actions: *const crate::posix_spawn_file_actions_t, + attrp: *const crate::posix_spawnattr_t, + argv: *const *mut c_char, + envp: *const *mut c_char, + ) -> c_int; + pub fn posix_spawnp( + pid: *mut crate::pid_t, + file: *const c_char, + file_actions: *const crate::posix_spawn_file_actions_t, + attrp: *const crate::posix_spawnattr_t, + argv: *const *mut c_char, + envp: *const *mut c_char, + ) -> c_int; + pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> c_int; + pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> c_int; + pub fn posix_spawnattr_getsigdefault( + attr: *const posix_spawnattr_t, + default: *mut crate::sigset_t, + ) -> c_int; + pub fn posix_spawnattr_setsigdefault( + attr: *mut posix_spawnattr_t, + default: *const crate::sigset_t, + ) -> c_int; + pub fn posix_spawnattr_getsigmask( + attr: *const posix_spawnattr_t, + default: *mut crate::sigset_t, + ) -> c_int; + pub fn posix_spawnattr_setsigmask( + attr: *mut posix_spawnattr_t, + default: *const crate::sigset_t, + ) -> c_int; + pub fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t, flags: *mut c_short) -> c_int; + pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t, flags: c_short) -> c_int; + pub fn posix_spawnattr_getpgroup( + attr: *const posix_spawnattr_t, + flags: *mut crate::pid_t, + ) -> c_int; + pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, flags: crate::pid_t) -> c_int; + pub fn posix_spawnattr_getschedpolicy( + attr: *const posix_spawnattr_t, + flags: *mut c_int, + ) -> c_int; + pub fn posix_spawnattr_setschedpolicy(attr: *mut posix_spawnattr_t, flags: c_int) -> c_int; + pub fn posix_spawnattr_getschedparam( + attr: *const posix_spawnattr_t, + param: *mut crate::sched_param, + ) -> c_int; + pub fn posix_spawnattr_setschedparam( + attr: *mut posix_spawnattr_t, + param: *const crate::sched_param, + ) -> c_int; + + pub fn posix_spawn_file_actions_init(actions: *mut posix_spawn_file_actions_t) -> c_int; + pub fn posix_spawn_file_actions_destroy(actions: *mut posix_spawn_file_actions_t) -> c_int; + pub fn posix_spawn_file_actions_addopen( + actions: *mut posix_spawn_file_actions_t, + fd: c_int, + path: *const c_char, + oflag: c_int, + mode: mode_t, + ) -> c_int; + pub fn posix_spawn_file_actions_addclose( + actions: *mut posix_spawn_file_actions_t, + fd: c_int, + ) -> c_int; + pub fn posix_spawn_file_actions_adddup2( + actions: *mut posix_spawn_file_actions_t, + fd: c_int, + newfd: c_int, + ) -> c_int; +} + +extern "C" { + pub fn reallocarray(ptr: *mut c_void, nmemb: size_t, size: size_t) -> *mut c_void; + pub fn gethostid() -> c_long; + pub fn sethostid(hostid: c_long) -> c_int; + pub fn ftok(path: *const c_char, id: c_int) -> crate::key_t; + + pub fn dirname(path: *mut c_char) -> *mut c_char; + pub fn basename(path: *mut c_char) -> *mut c_char; + pub fn getentropy(buf: *mut c_void, buflen: size_t) -> c_int; + + pub fn sendmmsg(sockfd: c_int, mmsg: *mut crate::mmsghdr, vlen: c_uint, flags: c_int) -> c_int; + pub fn recvmmsg( + sockfd: c_int, + mmsg: *mut crate::mmsghdr, + vlen: c_uint, + flags: c_int, + timeout: *mut crate::timespec, + ) -> c_int; + + pub fn closefrom(lowfd: c_int) -> c_int; +} + +cfg_if! { + if #[cfg(target_os = "netbsd")] { + mod netbsd; + pub use self::netbsd::*; + } else if #[cfg(target_os = "openbsd")] { + mod openbsd; + pub use self::openbsd::*; + } else { + // Unknown target_os + } +} diff --git a/http/vendor/libc/src/unix/bsd/netbsdlike/netbsd/aarch64.rs b/http/vendor/libc/src/unix/bsd/netbsdlike/netbsd/aarch64.rs new file mode 100644 index 0000000..e0206af --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/netbsdlike/netbsd/aarch64.rs @@ -0,0 +1,132 @@ +use crate::prelude::*; +use crate::PT_FIRSTMACH; + +pub type greg_t = u64; +pub type __cpu_simple_lock_nv_t = c_uchar; + +s! { + pub struct __fregset { + pub __qregs: [__c_anonymous__freg; 32], + pub __fpcr: u32, + pub __fpsr: u32, + } + + pub struct mcontext_t { + pub __gregs: [crate::greg_t; 32], + pub __fregs: __fregset, + __spare: [crate::greg_t; 8], + } + + pub struct ucontext_t { + pub uc_flags: c_uint, + pub uc_link: *mut ucontext_t, + pub uc_sigmask: crate::sigset_t, + pub uc_stack: crate::stack_t, + pub uc_mcontext: mcontext_t, + } +} + +s_no_extra_traits! { + #[repr(align(16))] + pub union __c_anonymous__freg { + pub __b8: [u8; 16], + pub __h16: [u16; 8], + pub __s32: [u32; 4], + pub __d64: [u64; 2], + pub __q128: [u128; 1], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for __c_anonymous__freg { + fn eq(&self, other: &__c_anonymous__freg) -> bool { + unsafe { + self.__b8 == other.__b8 + || self.__h16 == other.__h16 + || self.__s32 == other.__s32 + || self.__d64 == other.__d64 + || self.__q128 == other.__q128 + } + } + } + impl Eq for __c_anonymous__freg {} + impl hash::Hash for __c_anonymous__freg { + fn hash(&self, state: &mut H) { + unsafe { + self.__b8.hash(state); + self.__h16.hash(state); + self.__s32.hash(state); + self.__d64.hash(state); + self.__q128.hash(state); + } + } + } + } +} + +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; + +pub const PT_GETREGS: c_int = PT_FIRSTMACH + 0; +pub const PT_SETREGS: c_int = PT_FIRSTMACH + 1; +pub const PT_GETFPREGS: c_int = PT_FIRSTMACH + 2; +pub const PT_SETFPREGS: c_int = PT_FIRSTMACH + 3; + +pub const _REG_R0: c_int = 0; +pub const _REG_R1: c_int = 1; +pub const _REG_R2: c_int = 2; +pub const _REG_R3: c_int = 3; +pub const _REG_R4: c_int = 4; +pub const _REG_R5: c_int = 5; +pub const _REG_R6: c_int = 6; +pub const _REG_R7: c_int = 7; +pub const _REG_R8: c_int = 8; +pub const _REG_R9: c_int = 9; +pub const _REG_R10: c_int = 10; +pub const _REG_R11: c_int = 11; +pub const _REG_R12: c_int = 12; +pub const _REG_R13: c_int = 13; +pub const _REG_R14: c_int = 14; +pub const _REG_R15: c_int = 15; +pub const _REG_CPSR: c_int = 16; +pub const _REG_X0: c_int = 0; +pub const _REG_X1: c_int = 1; +pub const _REG_X2: c_int = 2; +pub const _REG_X3: c_int = 3; +pub const _REG_X4: c_int = 4; +pub const _REG_X5: c_int = 5; +pub const _REG_X6: c_int = 6; +pub const _REG_X7: c_int = 7; +pub const _REG_X8: c_int = 8; +pub const _REG_X9: c_int = 9; +pub const _REG_X10: c_int = 10; +pub const _REG_X11: c_int = 11; +pub const _REG_X12: c_int = 12; +pub const _REG_X13: c_int = 13; +pub const _REG_X14: c_int = 14; +pub const _REG_X15: c_int = 15; +pub const _REG_X16: c_int = 16; +pub const _REG_X17: c_int = 17; +pub const _REG_X18: c_int = 18; +pub const _REG_X19: c_int = 19; +pub const _REG_X20: c_int = 20; +pub const _REG_X21: c_int = 21; +pub const _REG_X22: c_int = 22; +pub const _REG_X23: c_int = 23; +pub const _REG_X24: c_int = 24; +pub const _REG_X25: c_int = 25; +pub const _REG_X26: c_int = 26; +pub const _REG_X27: c_int = 27; +pub const _REG_X28: c_int = 28; +pub const _REG_X29: c_int = 29; +pub const _REG_X30: c_int = 30; +pub const _REG_X31: c_int = 31; +pub const _REG_ELR: c_int = 32; +pub const _REG_SPSR: c_int = 33; +pub const _REG_TIPDR: c_int = 34; + +pub const _REG_RV: c_int = _REG_X0; +pub const _REG_FP: c_int = _REG_X29; +pub const _REG_LR: c_int = _REG_X30; +pub const _REG_SP: c_int = _REG_X31; +pub const _REG_PC: c_int = _REG_ELR; diff --git a/http/vendor/libc/src/unix/bsd/netbsdlike/netbsd/arm.rs b/http/vendor/libc/src/unix/bsd/netbsdlike/netbsd/arm.rs new file mode 100644 index 0000000..1af255e --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/netbsdlike/netbsd/arm.rs @@ -0,0 +1,70 @@ +use crate::prelude::*; +use crate::PT_FIRSTMACH; + +pub type __cpu_simple_lock_nv_t = c_int; + +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; + +pub const PT_GETREGS: c_int = PT_FIRSTMACH + 1; +pub const PT_SETREGS: c_int = PT_FIRSTMACH + 2; +pub const PT_GETFPREGS: c_int = PT_FIRSTMACH + 5; +pub const PT_SETFPREGS: c_int = PT_FIRSTMACH + 6; + +pub const _REG_R0: c_int = 0; +pub const _REG_R1: c_int = 1; +pub const _REG_R2: c_int = 2; +pub const _REG_R3: c_int = 3; +pub const _REG_R4: c_int = 4; +pub const _REG_R5: c_int = 5; +pub const _REG_R6: c_int = 6; +pub const _REG_R7: c_int = 7; +pub const _REG_R8: c_int = 8; +pub const _REG_R9: c_int = 9; +pub const _REG_R10: c_int = 10; +pub const _REG_R11: c_int = 11; +pub const _REG_R12: c_int = 12; +pub const _REG_R13: c_int = 13; +pub const _REG_R14: c_int = 14; +pub const _REG_R15: c_int = 15; +pub const _REG_CPSR: c_int = 16; +pub const _REG_X0: c_int = 0; +pub const _REG_X1: c_int = 1; +pub const _REG_X2: c_int = 2; +pub const _REG_X3: c_int = 3; +pub const _REG_X4: c_int = 4; +pub const _REG_X5: c_int = 5; +pub const _REG_X6: c_int = 6; +pub const _REG_X7: c_int = 7; +pub const _REG_X8: c_int = 8; +pub const _REG_X9: c_int = 9; +pub const _REG_X10: c_int = 10; +pub const _REG_X11: c_int = 11; +pub const _REG_X12: c_int = 12; +pub const _REG_X13: c_int = 13; +pub const _REG_X14: c_int = 14; +pub const _REG_X15: c_int = 15; +pub const _REG_X16: c_int = 16; +pub const _REG_X17: c_int = 17; +pub const _REG_X18: c_int = 18; +pub const _REG_X19: c_int = 19; +pub const _REG_X20: c_int = 20; +pub const _REG_X21: c_int = 21; +pub const _REG_X22: c_int = 22; +pub const _REG_X23: c_int = 23; +pub const _REG_X24: c_int = 24; +pub const _REG_X25: c_int = 25; +pub const _REG_X26: c_int = 26; +pub const _REG_X27: c_int = 27; +pub const _REG_X28: c_int = 28; +pub const _REG_X29: c_int = 29; +pub const _REG_X30: c_int = 30; +pub const _REG_X31: c_int = 31; +pub const _REG_ELR: c_int = 32; +pub const _REG_SPSR: c_int = 33; +pub const _REG_TPIDR: c_int = 34; + +pub const _REG_RV: c_int = _REG_R0; +pub const _REG_FP: c_int = _REG_R11; +pub const _REG_SP: c_int = _REG_R13; +pub const _REG_LR: c_int = _REG_R14; +pub const _REG_PC: c_int = _REG_R15; diff --git a/http/vendor/libc/src/unix/bsd/netbsdlike/netbsd/mips.rs b/http/vendor/libc/src/unix/bsd/netbsdlike/netbsd/mips.rs new file mode 100644 index 0000000..1b24b4f --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/netbsdlike/netbsd/mips.rs @@ -0,0 +1,11 @@ +use crate::prelude::*; +use crate::PT_FIRSTMACH; + +pub type __cpu_simple_lock_nv_t = c_int; + +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; + +pub const PT_GETREGS: c_int = PT_FIRSTMACH + 1; +pub const PT_SETREGS: c_int = PT_FIRSTMACH + 2; +pub const PT_GETFPREGS: c_int = PT_FIRSTMACH + 3; +pub const PT_SETFPREGS: c_int = PT_FIRSTMACH + 4; diff --git a/http/vendor/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs b/http/vendor/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs new file mode 100644 index 0000000..f3d027c --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -0,0 +1,2487 @@ +use crate::prelude::*; +use crate::{ + cmsghdr, + cpuid_t, + lwpid_t, + off_t, +}; + +pub type blksize_t = i32; +pub type eventfd_t = u64; +pub type fsblkcnt_t = u64; +pub type fsfilcnt_t = u64; +pub type idtype_t = c_int; +type __pthread_spin_t = __cpu_simple_lock_nv_t; +pub type shmatt_t = c_uint; +pub type cpuset_t = _cpuset; +pub type pthread_spin_t = __pthread_spin_t; + +// elf.h + +pub type Elf32_Addr = u32; +pub type Elf32_Half = u16; +pub type Elf32_Lword = u64; +pub type Elf32_Off = u32; +pub type Elf32_Sword = i32; +pub type Elf32_Word = u32; + +pub type Elf64_Addr = u64; +pub type Elf64_Half = u16; +pub type Elf64_Lword = u64; +pub type Elf64_Off = u64; +pub type Elf64_Sword = i32; +pub type Elf64_Sxword = i64; +pub type Elf64_Word = u32; +pub type Elf64_Xword = u64; + +pub type iconv_t = *mut c_void; + +e! { + #[repr(C)] + pub enum fae_action { + FAE_OPEN, + FAE_DUP2, + FAE_CLOSE, + } +} + +extern_ty! { + pub enum _cpuset {} +} + +cfg_if! { + if #[cfg(target_pointer_width = "64")] { + type Elf_Addr = Elf64_Addr; + type Elf_Half = Elf64_Half; + type Elf_Phdr = Elf64_Phdr; + } else if #[cfg(target_pointer_width = "32")] { + type Elf_Addr = Elf32_Addr; + type Elf_Half = Elf32_Half; + type Elf_Phdr = Elf32_Phdr; + } +} + +impl siginfo_t { + pub unsafe fn si_addr(&self) -> *mut c_void { + self.si_addr + } + + pub unsafe fn si_code(&self) -> c_int { + self.si_code + } + + pub unsafe fn si_errno(&self) -> c_int { + self.si_errno + } + + pub unsafe fn si_pid(&self) -> crate::pid_t { + #[repr(C)] + struct siginfo_timer { + _si_signo: c_int, + _si_errno: c_int, + _si_code: c_int, + #[cfg(target_pointer_width = "64")] + __pad1: Padding, + _pid: crate::pid_t, + } + (*(self as *const siginfo_t as *const siginfo_timer))._pid + } + + pub unsafe fn si_uid(&self) -> crate::uid_t { + #[repr(C)] + struct siginfo_timer { + _si_signo: c_int, + _si_errno: c_int, + _si_code: c_int, + #[cfg(target_pointer_width = "64")] + __pad1: Padding, + _pid: crate::pid_t, + _uid: crate::uid_t, + } + (*(self as *const siginfo_t as *const siginfo_timer))._uid + } + + pub unsafe fn si_value(&self) -> crate::sigval { + #[repr(C)] + struct siginfo_timer { + _si_signo: c_int, + _si_errno: c_int, + _si_code: c_int, + #[cfg(target_pointer_width = "64")] + __pad1: Padding, + _pid: crate::pid_t, + _uid: crate::uid_t, + value: crate::sigval, + } + (*(self as *const siginfo_t as *const siginfo_timer)).value + } + + pub unsafe fn si_status(&self) -> c_int { + #[repr(C)] + struct siginfo_timer { + _si_signo: c_int, + _si_errno: c_int, + _si_code: c_int, + #[cfg(target_pointer_width = "64")] + __pad1: Padding, + _pid: crate::pid_t, + _uid: crate::uid_t, + status: c_int, + } + (*(self as *const siginfo_t as *const siginfo_timer)).status + } +} + +s! { + pub struct aiocb { + pub aio_offset: off_t, + pub aio_buf: *mut c_void, + pub aio_nbytes: size_t, + pub aio_fildes: c_int, + pub aio_lio_opcode: c_int, + pub aio_reqprio: c_int, + pub aio_sigevent: crate::sigevent, + _state: c_int, + _errno: c_int, + _retval: ssize_t, + } + + pub struct glob_t { + pub gl_pathc: size_t, + pub gl_matchc: size_t, + pub gl_offs: size_t, + pub gl_flags: c_int, + pub gl_pathv: *mut *mut c_char, + + __unused3: Padding<*mut c_void>, + + __unused4: Padding<*mut c_void>, + __unused5: Padding<*mut c_void>, + __unused6: Padding<*mut c_void>, + __unused7: Padding<*mut c_void>, + __unused8: Padding<*mut c_void>, + } + + pub struct tm { + pub tm_sec: c_int, + pub tm_min: c_int, + pub tm_hour: c_int, + pub tm_mday: c_int, + pub tm_mon: c_int, + pub tm_year: c_int, + pub tm_wday: c_int, + pub tm_yday: c_int, + pub tm_isdst: c_int, + pub tm_gmtoff: c_long, + pub tm_zone: *mut c_char, + } + + pub struct mq_attr { + pub mq_flags: c_long, + pub mq_maxmsg: c_long, + pub mq_msgsize: c_long, + pub mq_curmsgs: c_long, + } + + pub struct sigset_t { + __bits: [u32; 4], + } + + pub struct stat { + pub st_dev: crate::dev_t, + pub st_mode: crate::mode_t, + pub st_ino: crate::ino_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + pub st_atime: crate::time_t, + pub st_atimensec: c_long, + pub st_mtime: crate::time_t, + pub st_mtimensec: c_long, + pub st_ctime: crate::time_t, + pub st_ctimensec: c_long, + pub st_birthtime: crate::time_t, + pub st_birthtimensec: c_long, + pub st_size: off_t, + pub st_blocks: crate::blkcnt_t, + pub st_blksize: crate::blksize_t, + pub st_flags: u32, + pub st_gen: u32, + pub st_spare: [u32; 2], + } + + pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: crate::socklen_t, + pub ai_canonname: *mut c_char, + pub ai_addr: *mut crate::sockaddr, + pub ai_next: *mut crate::addrinfo, + } + + pub struct siginfo_t { + pub si_signo: c_int, + pub si_code: c_int, + pub si_errno: c_int, + #[cfg(target_pointer_width = "64")] + __pad1: Padding, + pub si_addr: *mut c_void, + #[cfg(target_pointer_width = "64")] + __pad2: Padding<[u64; 13]>, + #[cfg(target_pointer_width = "32")] + __pad2: Padding<[u64; 14]>, + } + + pub struct pthread_attr_t { + pta_magic: c_uint, + pta_flags: c_int, + pta_private: *mut c_void, + } + + pub struct pthread_mutex_t { + ptm_magic: c_uint, + ptm_errorcheck: __pthread_spin_t, + #[cfg(any( + target_arch = "sparc", + target_arch = "sparc64", + target_arch = "x86", + target_arch = "x86_64" + ))] + ptm_pad1: Padding<[u8; 3]>, + // actually a union with a non-unused, 0-initialized field + ptm_unused: Padding<__pthread_spin_t>, + #[cfg(any( + target_arch = "sparc", + target_arch = "sparc64", + target_arch = "x86", + target_arch = "x86_64" + ))] + ptm_pad2: Padding<[u8; 3]>, + ptm_owner: crate::pthread_t, + ptm_waiters: *mut u8, + ptm_recursed: c_uint, + ptm_spare2: *mut c_void, + } + + pub struct pthread_mutexattr_t { + ptma_magic: c_uint, + ptma_private: *mut c_void, + } + + pub struct pthread_rwlockattr_t { + ptra_magic: c_uint, + ptra_private: *mut c_void, + } + + pub struct pthread_cond_t { + ptc_magic: c_uint, + ptc_lock: __pthread_spin_t, + ptc_waiters_first: *mut u8, + ptc_waiters_last: *mut u8, + ptc_mutex: *mut crate::pthread_mutex_t, + ptc_private: *mut c_void, + } + + pub struct pthread_condattr_t { + ptca_magic: c_uint, + ptca_private: *mut c_void, + } + + pub struct pthread_rwlock_t { + ptr_magic: c_uint, + ptr_interlock: __pthread_spin_t, + ptr_rblocked_first: *mut u8, + ptr_rblocked_last: *mut u8, + ptr_wblocked_first: *mut u8, + ptr_wblocked_last: *mut u8, + ptr_nreaders: c_uint, + ptr_owner: crate::pthread_t, + ptr_private: *mut c_void, + } + + pub struct pthread_spinlock_t { + pts_magic: c_uint, + pts_spin: crate::pthread_spin_t, + pts_flags: c_int, + } + + pub struct kevent { + pub ident: crate::uintptr_t, + pub filter: u32, + pub flags: u32, + pub fflags: u32, + pub data: i64, + pub udata: *mut c_void, + } + + pub struct dqblk { + pub dqb_bhardlimit: u32, + pub dqb_bsoftlimit: u32, + pub dqb_curblocks: u32, + pub dqb_ihardlimit: u32, + pub dqb_isoftlimit: u32, + pub dqb_curinodes: u32, + pub dqb_btime: i32, + pub dqb_itime: i32, + } + + pub struct Dl_info { + pub dli_fname: *const c_char, + pub dli_fbase: *mut c_void, + pub dli_sname: *const c_char, + pub dli_saddr: *const c_void, + } + + pub struct lconv { + pub decimal_point: *mut c_char, + pub thousands_sep: *mut c_char, + pub grouping: *mut c_char, + pub int_curr_symbol: *mut c_char, + pub currency_symbol: *mut c_char, + pub mon_decimal_point: *mut c_char, + pub mon_thousands_sep: *mut c_char, + pub mon_grouping: *mut c_char, + pub positive_sign: *mut c_char, + pub negative_sign: *mut c_char, + pub int_frac_digits: c_char, + pub frac_digits: c_char, + pub p_cs_precedes: c_char, + pub p_sep_by_space: c_char, + pub n_cs_precedes: c_char, + pub n_sep_by_space: c_char, + pub p_sign_posn: c_char, + pub n_sign_posn: c_char, + pub int_p_cs_precedes: c_char, + pub int_n_cs_precedes: c_char, + pub int_p_sep_by_space: c_char, + pub int_n_sep_by_space: c_char, + pub int_p_sign_posn: c_char, + pub int_n_sign_posn: c_char, + } + + pub struct sockcred { + pub sc_pid: crate::pid_t, + pub sc_uid: crate::uid_t, + pub sc_euid: crate::uid_t, + pub sc_gid: crate::gid_t, + pub sc_egid: crate::gid_t, + pub sc_ngroups: c_int, + pub sc_groups: [crate::gid_t; 1], + } + + pub struct uucred { + cr_unused: Padding, + pub cr_uid: crate::uid_t, + pub cr_gid: crate::gid_t, + pub cr_ngroups: c_short, + pub cr_groups: [crate::gid_t; NGROUPS_MAX as usize], + } + + pub struct unpcbid { + pub unp_pid: crate::pid_t, + pub unp_euid: crate::uid_t, + pub unp_egid: crate::gid_t, + } + + pub struct sockaddr_dl { + pub sdl_len: c_uchar, + pub sdl_family: c_uchar, + pub sdl_index: c_ushort, + pub sdl_type: u8, + pub sdl_nlen: u8, + pub sdl_alen: u8, + pub sdl_slen: u8, + pub sdl_data: [c_char; 24], + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, + pub shm_lpid: crate::pid_t, + pub shm_cpid: crate::pid_t, + pub shm_nattch: crate::shmatt_t, + pub shm_atime: crate::time_t, + pub shm_dtime: crate::time_t, + pub shm_ctime: crate::time_t, + _shm_internal: *mut c_void, + } + + // elf.h + + pub struct Elf32_Phdr { + pub p_type: Elf32_Word, + pub p_offset: Elf32_Off, + pub p_vaddr: Elf32_Addr, + pub p_paddr: Elf32_Addr, + pub p_filesz: Elf32_Word, + pub p_memsz: Elf32_Word, + pub p_flags: Elf32_Word, + pub p_align: Elf32_Word, + } + + pub struct Elf64_Phdr { + pub p_type: Elf64_Word, + pub p_flags: Elf64_Word, + pub p_offset: Elf64_Off, + pub p_vaddr: Elf64_Addr, + pub p_paddr: Elf64_Addr, + pub p_filesz: Elf64_Xword, + pub p_memsz: Elf64_Xword, + pub p_align: Elf64_Xword, + } + + pub struct Aux32Info { + pub a_type: Elf32_Word, + pub a_v: Elf32_Word, + } + + pub struct Aux64Info { + pub a_type: Elf64_Word, + pub a_v: Elf64_Xword, + } + + // sys/sysctl.h + + pub struct kinfo_file { + pub ki_fileaddr: u64, + pub ki_flag: u32, + pub ki_iflags: u32, + pub ki_ftype: u32, + pub ki_count: u32, + pub ki_msgcount: u32, + pub ki_usecount: u32, + pub ki_fucred: u64, + pub ki_fuid: u32, + pub ki_fgid: u32, + pub ki_fops: u64, + pub ki_foffset: u64, + pub ki_fdata: u64, + pub ki_vun: u64, + pub ki_vsize: u64, + pub ki_vtype: u32, + pub ki_vtag: u32, + pub ki_vdata: u64, + pub ki_pid: u32, + pub ki_fd: i32, + pub ki_ofileflags: u32, + _ki_padto64bits: Padding, + } + + // link.h + + pub struct dl_phdr_info { + pub dlpi_addr: Elf_Addr, + pub dlpi_name: *const c_char, + pub dlpi_phdr: *const Elf_Phdr, + pub dlpi_phnum: Elf_Half, + pub dlpi_adds: c_ulonglong, + pub dlpi_subs: c_ulonglong, + pub dlpi_tls_modid: usize, + pub dlpi_tls_data: *mut c_void, + } + + pub struct accept_filter_arg { + pub af_name: [c_char; 16], + af_arg: [c_char; 256 - 16], + } + + pub struct ki_sigset_t { + pub __bits: [u32; 4], + } + + pub struct kinfo_proc2 { + pub p_forw: u64, + pub p_back: u64, + pub p_paddr: u64, + pub p_addr: u64, + pub p_fd: u64, + pub p_cwdi: u64, + pub p_stats: u64, + pub p_limit: u64, + pub p_vmspace: u64, + pub p_sigacts: u64, + pub p_sess: u64, + pub p_tsess: u64, + pub p_ru: u64, + pub p_eflag: i32, + pub p_exitsig: i32, + pub p_flag: i32, + pub p_pid: i32, + pub p_ppid: i32, + pub p_sid: i32, + pub p__pgid: i32, + pub p_tpgid: i32, + pub p_uid: u32, + pub p_ruid: u32, + pub p_gid: u32, + pub p_rgid: u32, + pub p_groups: [u32; KI_NGROUPS as usize], + pub p_ngroups: i16, + pub p_jobc: i16, + pub p_tdev: u32, + pub p_estcpu: u32, + pub p_rtime_sec: u32, + pub p_rtime_usec: u32, + pub p_cpticks: i32, + pub p_pctcpu: u32, + pub p_swtime: u32, + pub p_slptime: u32, + pub p_schedflags: i32, + pub p_uticks: u64, + pub p_sticks: u64, + pub p_iticks: u64, + pub p_tracep: u64, + pub p_traceflag: i32, + pub p_holdcnt: i32, + pub p_siglist: ki_sigset_t, + pub p_sigmask: ki_sigset_t, + pub p_sigignore: ki_sigset_t, + pub p_sigcatch: ki_sigset_t, + pub p_stat: i8, + pub p_priority: u8, + pub p_usrpri: u8, + pub p_nice: u8, + pub p_xstat: u16, + pub p_acflag: u16, + pub p_comm: [c_char; KI_MAXCOMLEN as usize], + pub p_wmesg: [c_char; KI_WMESGLEN as usize], + pub p_wchan: u64, + pub p_login: [c_char; KI_MAXLOGNAME as usize], + pub p_vm_rssize: i32, + pub p_vm_tsize: i32, + pub p_vm_dsize: i32, + pub p_vm_ssize: i32, + pub p_uvalid: i64, + pub p_ustart_sec: u32, + pub p_ustart_usec: u32, + pub p_uutime_sec: u32, + pub p_uutime_usec: u32, + pub p_ustime_sec: u32, + pub p_ustime_usec: u32, + pub p_uru_maxrss: u64, + pub p_uru_ixrss: u64, + pub p_uru_idrss: u64, + pub p_uru_isrss: u64, + pub p_uru_minflt: u64, + pub p_uru_majflt: u64, + pub p_uru_nswap: u64, + pub p_uru_inblock: u64, + pub p_uru_oublock: u64, + pub p_uru_msgsnd: u64, + pub p_uru_msgrcv: u64, + pub p_uru_nsignals: u64, + pub p_uru_nvcsw: u64, + pub p_uru_nivcsw: u64, + pub p_uctime_sec: u32, + pub p_uctime_usec: u32, + pub p_cpuid: u64, + pub p_realflag: u64, + pub p_nlwps: u64, + pub p_nrlwps: u64, + pub p_realstat: u64, + pub p_svuid: u32, + pub p_svgid: u32, + pub p_ename: [c_char; KI_MAXEMULLEN as usize], + pub p_vm_vsize: i64, + pub p_vm_msize: i64, + } + + pub struct kinfo_lwp { + pub l_forw: u64, + pub l_back: u64, + pub l_laddr: u64, + pub l_addr: u64, + pub l_lid: i32, + pub l_flag: i32, + pub l_swtime: u32, + pub l_slptime: u32, + pub l_schedflags: i32, + pub l_holdcnt: i32, + pub l_priority: u8, + pub l_usrpri: u8, + pub l_stat: i8, + l_pad1: Padding, + l_pad2: Padding, + pub l_wmesg: [c_char; KI_WMESGLEN as usize], + pub l_wchan: u64, + pub l_cpuid: u64, + pub l_rtime_sec: u32, + pub l_rtime_usec: u32, + pub l_cpticks: u32, + pub l_pctcpu: u32, + pub l_pid: u32, + pub l_name: [c_char; KI_LNAMELEN as usize], + } + + pub struct kinfo_vmentry { + pub kve_start: u64, + pub kve_end: u64, + pub kve_offset: u64, + pub kve_type: u32, + pub kve_flags: u32, + pub kve_count: u32, + pub kve_wired_count: u32, + pub kve_advice: u32, + pub kve_attributes: u32, + pub kve_protection: u32, + pub kve_max_protection: u32, + pub kve_ref_count: u32, + pub kve_inheritance: u32, + pub kve_vn_fileid: u64, + pub kve_vn_size: u64, + pub kve_vn_fsid: u64, + pub kve_vn_rdev: u64, + pub kve_vn_type: u32, + pub kve_vn_mode: u32, + pub kve_path: [c_char; crate::PATH_MAX as usize], + } + + pub struct __c_anonymous_posix_spawn_fae_open { + pub path: *mut c_char, + pub oflag: c_int, + pub mode: crate::mode_t, + } + + pub struct __c_anonymous_posix_spawn_fae_dup2 { + pub newfildes: c_int, + } + + pub struct posix_spawnattr_t { + pub sa_flags: c_short, + pub sa_pgroup: crate::pid_t, + pub sa_schedparam: crate::sched_param, + pub sa_schedpolicy: c_int, + pub sa_sigdefault: sigset_t, + pub sa_sigmask: sigset_t, + } + + pub struct posix_spawn_file_actions_entry_t { + pub fae_action: fae_action, + pub fae_fildes: c_int, + pub fae_data: __c_anonymous_posix_spawn_fae, + } + + pub struct posix_spawn_file_actions_t { + pub size: c_uint, + pub len: c_uint, + pub fae: *mut posix_spawn_file_actions_entry_t, + } + + #[deprecated(since = "0.2.178", note = "obsolete upstream")] + pub struct ptrace_lwpinfo { + pub pl_lwpid: lwpid_t, + pub pl_event: c_int, + } + + pub struct ptrace_lwpstatus { + pub pl_lwpid: lwpid_t, + pub pl_sigpend: sigset_t, + pub pl_sigmask: sigset_t, + pub pl_name: [c_char; 20], + pub pl_private: *mut c_void, + } + + pub struct ptrace_siginfo { + pub psi_siginfo: siginfo_t, + pub psi_lwpid: lwpid_t, + } + + pub struct ptrace_event { + pub pe_set_event: c_int, + } + + pub struct sysctldesc { + pub descr_num: i32, + pub descr_ver: u32, + pub descr_len: u32, + pub descr_str: [c_char; 1], + } + + pub struct tcp_info { + pub tcpi_state: u8, + pub __tcpi_ca_state: u8, + pub __tcpi_retransmits: u8, + pub __tcpi_probes: u8, + pub __tcpi_backoff: u8, + pub tcpi_options: u8, + pub tcp_snd_wscale: u8, + pub tcp_rcv_wscale: u8, + pub tcpi_rto: u32, + pub __tcpi_ato: u32, + pub tcpi_snd_mss: u32, + pub tcpi_rcv_mss: u32, + pub __tcpi_unacked: u32, + pub __tcpi_sacked: u32, + pub __tcpi_lost: u32, + pub __tcpi_retrans: u32, + pub __tcpi_fackets: u32, + pub __tcpi_last_data_sent: u32, + pub __tcpi_last_ack_sent: u32, + pub tcpi_last_data_recv: u32, + pub __tcpi_last_ack_recv: u32, + pub __tcpi_pmtu: u32, + pub __tcpi_rcv_ssthresh: u32, + pub tcpi_rtt: u32, + pub tcpi_rttvar: u32, + pub tcpi_snd_ssthresh: u32, + pub tcpi_snd_cwnd: u32, + pub __tcpi_advmss: u32, + pub __tcpi_reordering: u32, + pub __tcpi_rcv_rtt: u32, + pub tcpi_rcv_space: u32, + pub tcpi_snd_wnd: u32, + pub tcpi_snd_bwnd: u32, + pub tcpi_snd_nxt: u32, + pub tcpi_rcv_nxt: u32, + pub tcpi_toe_tid: u32, + pub tcpi_snd_rexmitpack: u32, + pub tcpi_rcv_ooopack: u32, + pub tcpi_snd_zerowin: u32, + pub __tcpi_pad: [u32; 26], + } + + pub struct in_pktinfo { + pub ipi_addr: crate::in_addr, + pub ipi_ifindex: c_uint, + } + + pub struct arphdr { + pub ar_hrd: u16, + pub ar_pro: u16, + pub ar_hln: u8, + pub ar_pln: u8, + pub ar_op: u16, + } + + pub struct in_addr { + pub s_addr: crate::in_addr_t, + } + + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: crate::sa_family_t, + pub sin_port: crate::in_port_t, + pub sin_addr: crate::in_addr, + pub sin_zero: [i8; 8], + } + + pub struct dirent { + pub d_fileno: crate::ino_t, + pub d_reclen: u16, + pub d_namlen: u16, + pub d_type: u8, + pub d_name: [c_char; 512], + } + + pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: crate::sa_family_t, + __ss_pad1: Padding<[u8; 6]>, + __ss_pad2: Padding, + __ss_pad3: Padding<[u8; 112]>, + } + + pub struct sigevent { + pub sigev_notify: c_int, + pub sigev_signo: c_int, + pub sigev_value: crate::sigval, + __unused1: Padding<*mut c_void>, //actually a function pointer + pub sigev_notify_attributes: *mut c_void, + } +} + +s_no_extra_traits! { + pub union __c_anonymous_posix_spawn_fae { + pub open: __c_anonymous_posix_spawn_fae_open, + pub dup2: __c_anonymous_posix_spawn_fae_dup2, + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl Eq for __c_anonymous_posix_spawn_fae {} + impl PartialEq for __c_anonymous_posix_spawn_fae { + fn eq(&self, other: &__c_anonymous_posix_spawn_fae) -> bool { + unsafe { self.open == other.open || self.dup2 == other.dup2 } + } + } + impl hash::Hash for __c_anonymous_posix_spawn_fae { + fn hash(&self, state: &mut H) { + unsafe { + self.open.hash(state); + self.dup2.hash(state); + } + } + } + } +} + +pub const AT_FDCWD: c_int = -100; +pub const AT_EACCESS: c_int = 0x100; +pub const AT_SYMLINK_NOFOLLOW: c_int = 0x200; +pub const AT_SYMLINK_FOLLOW: c_int = 0x400; +pub const AT_REMOVEDIR: c_int = 0x800; + +pub const AT_NULL: c_int = 0; +pub const AT_IGNORE: c_int = 1; +pub const AT_EXECFD: c_int = 2; +pub const AT_PHDR: c_int = 3; +pub const AT_PHENT: c_int = 4; +pub const AT_PHNUM: c_int = 5; +pub const AT_PAGESZ: c_int = 6; +pub const AT_BASE: c_int = 7; +pub const AT_FLAGS: c_int = 8; +pub const AT_ENTRY: c_int = 9; +pub const AT_DCACHEBSIZE: c_int = 10; +pub const AT_ICACHEBSIZE: c_int = 11; +pub const AT_UCACHEBSIZE: c_int = 12; +pub const AT_STACKBASE: c_int = 13; +pub const AT_EUID: c_int = 2000; +pub const AT_RUID: c_int = 2001; +pub const AT_EGID: c_int = 2002; +pub const AT_RGID: c_int = 2003; +pub const AT_SUN_LDELF: c_int = 2004; +pub const AT_SUN_LDSHDR: c_int = 2005; +pub const AT_SUN_LDNAME: c_int = 2006; +pub const AT_SUN_PLATFORM: c_int = 2008; +pub const AT_SUN_HWCAP: c_int = 2009; +pub const AT_SUN_IFLUSH: c_int = 2010; +pub const AT_SUN_CPU: c_int = 2011; +pub const AT_SUN_EMUL_ENTRY: c_int = 2012; +pub const AT_SUN_EMUL_EXECFD: c_int = 2013; +pub const AT_SUN_EXECNAME: c_int = 2014; + +pub const EXTATTR_NAMESPACE_USER: c_int = 1; +pub const EXTATTR_NAMESPACE_SYSTEM: c_int = 2; + +pub const LC_COLLATE_MASK: c_int = 1 << crate::LC_COLLATE; +pub const LC_CTYPE_MASK: c_int = 1 << crate::LC_CTYPE; +pub const LC_MONETARY_MASK: c_int = 1 << crate::LC_MONETARY; +pub const LC_NUMERIC_MASK: c_int = 1 << crate::LC_NUMERIC; +pub const LC_TIME_MASK: c_int = 1 << crate::LC_TIME; +pub const LC_MESSAGES_MASK: c_int = 1 << crate::LC_MESSAGES; +pub const LC_ALL_MASK: c_int = !0; + +pub const ERA: crate::nl_item = 52; +pub const ERA_D_FMT: crate::nl_item = 53; +pub const ERA_D_T_FMT: crate::nl_item = 54; +pub const ERA_T_FMT: crate::nl_item = 55; +pub const ALT_DIGITS: crate::nl_item = 56; + +pub const O_CLOEXEC: c_int = 0x400000; +pub const O_ALT_IO: c_int = 0x40000; +pub const O_NOSIGPIPE: c_int = 0x1000000; +pub const O_SEARCH: c_int = 0x800000; +pub const O_DIRECTORY: c_int = 0x200000; +pub const O_DIRECT: c_int = 0x00080000; +pub const O_RSYNC: c_int = 0x00020000; + +pub const MS_SYNC: c_int = 0x4; +pub const MS_INVALIDATE: c_int = 0x2; + +// Here because they are not present on OpenBSD +// (https://github.com/openbsd/src/blob/HEAD/sys/sys/resource.h) +pub const RLIMIT_SBSIZE: c_int = 9; +pub const RLIMIT_AS: c_int = 10; +pub const RLIMIT_NTHR: c_int = 11; + +#[deprecated(since = "0.2.64", note = "Not stable across OS versions")] +pub const RLIM_NLIMITS: c_int = 12; + +pub const EIDRM: c_int = 82; +pub const ENOMSG: c_int = 83; +pub const EOVERFLOW: c_int = 84; +pub const EILSEQ: c_int = 85; +pub const ENOTSUP: c_int = 86; +pub const ECANCELED: c_int = 87; +pub const EBADMSG: c_int = 88; +pub const ENODATA: c_int = 89; +pub const ENOSR: c_int = 90; +pub const ENOSTR: c_int = 91; +pub const ETIME: c_int = 92; +pub const ENOATTR: c_int = 93; +pub const EMULTIHOP: c_int = 94; +pub const ENOLINK: c_int = 95; +pub const EPROTO: c_int = 96; +pub const EOWNERDEAD: c_int = 97; +pub const ENOTRECOVERABLE: c_int = 98; +#[deprecated( + since = "0.2.143", + note = "This value will always match the highest defined error number \ + and thus is not stable. \ + See #3040 for more info." +)] +pub const ELAST: c_int = 98; + +pub const F_DUPFD_CLOEXEC: c_int = 12; +pub const F_CLOSEM: c_int = 10; +pub const F_GETNOSIGPIPE: c_int = 13; +pub const F_SETNOSIGPIPE: c_int = 14; +pub const F_MAXFD: c_int = 11; +pub const F_GETPATH: c_int = 15; + +pub const FUTEX_WAIT: c_int = 0; +pub const FUTEX_WAKE: c_int = 1; +pub const FUTEX_FD: c_int = 2; +pub const FUTEX_REQUEUE: c_int = 3; +pub const FUTEX_CMP_REQUEUE: c_int = 4; +pub const FUTEX_WAKE_OP: c_int = 5; +pub const FUTEX_LOCK_PI: c_int = 6; +pub const FUTEX_UNLOCK_PI: c_int = 7; +pub const FUTEX_TRYLOCK_PI: c_int = 8; +pub const FUTEX_WAIT_BITSET: c_int = 9; +pub const FUTEX_WAKE_BITSET: c_int = 10; +pub const FUTEX_WAIT_REQUEUE_PI: c_int = 11; +pub const FUTEX_CMP_REQUEUE_PI: c_int = 12; +pub const FUTEX_PRIVATE_FLAG: c_int = 1 << 7; +pub const FUTEX_CLOCK_REALTIME: c_int = 1 << 8; +pub const FUTEX_CMD_MASK: c_int = !(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME); +pub const FUTEX_WAITERS: u32 = 1 << 31; +pub const FUTEX_OWNER_DIED: u32 = 1 << 30; +pub const FUTEX_SYNCOBJ_1: u32 = 1 << 29; +pub const FUTEX_SYNCOBJ_0: u32 = 1 << 28; +pub const FUTEX_TID_MASK: u32 = (1 << 28) - 1; +pub const FUTEX_BITSET_MATCH_ANY: u32 = !0; + +pub const IP_RECVDSTADDR: c_int = 7; +pub const IP_SENDSRCADDR: c_int = IP_RECVDSTADDR; +pub const IP_RECVIF: c_int = 20; +pub const IP_PKTINFO: c_int = 25; +pub const IP_RECVPKTINFO: c_int = 26; +pub const IPV6_JOIN_GROUP: c_int = 12; +pub const IPV6_LEAVE_GROUP: c_int = 13; + +pub const TCP_KEEPIDLE: c_int = 3; +pub const TCP_KEEPINTVL: c_int = 5; +pub const TCP_KEEPCNT: c_int = 6; +pub const TCP_KEEPINIT: c_int = 7; +pub const TCP_MD5SIG: c_int = 0x10; +pub const TCP_CONGCTL: c_int = 0x20; + +pub const SOCK_CONN_DGRAM: c_int = 6; +pub const SOCK_DCCP: c_int = SOCK_CONN_DGRAM; +pub const SOCK_NOSIGPIPE: c_int = 0x40000000; +pub const SOCK_FLAGS_MASK: c_int = 0xf0000000; + +pub const SO_SNDTIMEO: c_int = 0x100b; +pub const SO_RCVTIMEO: c_int = 0x100c; +pub const SO_NOSIGPIPE: c_int = 0x0800; +pub const SO_ACCEPTFILTER: c_int = 0x1000; +pub const SO_TIMESTAMP: c_int = 0x2000; +pub const SO_OVERFLOWED: c_int = 0x1009; +pub const SO_NOHEADER: c_int = 0x100a; + +// http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/sys/un.h?annotate +pub const LOCAL_OCREDS: c_int = 0x0001; // pass credentials to receiver +pub const LOCAL_CONNWAIT: c_int = 0x0002; // connects block until accepted +pub const LOCAL_PEEREID: c_int = 0x0003; // get peer identification +pub const LOCAL_CREDS: c_int = 0x0004; // pass credentials to receiver + +// https://github.com/NetBSD/src/blob/trunk/sys/net/if.h#L373 + +// sys/netinet/in.h +// Protocols (RFC 1700) +// NOTE: These are in addition to the constants defined in src/unix/mod.rs + +// IPPROTO_IP defined in src/unix/mod.rs +/// Hop-by-hop option header +pub const IPPROTO_HOPOPTS: c_int = 0; +// IPPROTO_ICMP defined in src/unix/mod.rs +/// group mgmt protocol +pub const IPPROTO_IGMP: c_int = 2; +/// gateway^2 (deprecated) +pub const IPPROTO_GGP: c_int = 3; +/// for compatibility +pub const IPPROTO_IPIP: c_int = 4; +// IPPROTO_TCP defined in src/unix/mod.rs +/// exterior gateway protocol +pub const IPPROTO_EGP: c_int = 8; +/// pup +pub const IPPROTO_PUP: c_int = 12; +// IPPROTO_UDP defined in src/unix/mod.rs +/// xns idp +pub const IPPROTO_IDP: c_int = 22; +/// tp-4 w/ class negotiation +pub const IPPROTO_TP: c_int = 29; +/// DCCP +pub const IPPROTO_DCCP: c_int = 33; +// IPPROTO_IPV6 defined in src/unix/mod.rs +/// IP6 routing header +pub const IPPROTO_ROUTING: c_int = 43; +/// IP6 fragmentation header +pub const IPPROTO_FRAGMENT: c_int = 44; +/// resource reservation +pub const IPPROTO_RSVP: c_int = 46; +/// General Routing Encap. +pub const IPPROTO_GRE: c_int = 47; +/// IP6 Encap Sec. Payload +pub const IPPROTO_ESP: c_int = 50; +/// IP6 Auth Header +pub const IPPROTO_AH: c_int = 51; +/// IP Mobility RFC 2004 +pub const IPPROTO_MOBILE: c_int = 55; +/// IPv6 ICMP +pub const IPPROTO_IPV6_ICMP: c_int = 58; +// IPPROTO_ICMPV6 defined in src/unix/mod.rs +/// IP6 no next header +pub const IPPROTO_NONE: c_int = 59; +/// IP6 destination option +pub const IPPROTO_DSTOPTS: c_int = 60; +/// ISO cnlp +pub const IPPROTO_EON: c_int = 80; +/// Ethernet-in-IP +pub const IPPROTO_ETHERIP: c_int = 97; +/// encapsulation header +pub const IPPROTO_ENCAP: c_int = 98; +/// Protocol indep. multicast +pub const IPPROTO_PIM: c_int = 103; +/// IP Payload Comp. Protocol +pub const IPPROTO_IPCOMP: c_int = 108; +/// VRRP RFC 2338 +pub const IPPROTO_VRRP: c_int = 112; +/// Common Address Resolution Protocol +pub const IPPROTO_CARP: c_int = 112; +/// L2TPv3 +pub const IPPROTO_L2TP: c_int = 115; +/// SCTP +pub const IPPROTO_SCTP: c_int = 132; +/// PFSYNC +pub const IPPROTO_PFSYNC: c_int = 240; +pub const IPPROTO_MAX: c_int = 256; + +/// last return value of *_input(), meaning "all job for this pkt is done". +pub const IPPROTO_DONE: c_int = 257; + +/// sysctl placeholder for (FAST_)IPSEC +pub const CTL_IPPROTO_IPSEC: c_int = 258; + +pub const AF_OROUTE: c_int = 17; +pub const AF_ARP: c_int = 28; +pub const pseudo_AF_KEY: c_int = 29; +pub const pseudo_AF_HDRCMPLT: c_int = 30; +pub const AF_BLUETOOTH: c_int = 31; +pub const AF_IEEE80211: c_int = 32; +pub const AF_MPLS: c_int = 33; +pub const AF_ROUTE: c_int = 34; +pub const NET_RT_DUMP: c_int = 1; +pub const NET_RT_FLAGS: c_int = 2; +pub const NET_RT_OOOIFLIST: c_int = 3; +pub const NET_RT_OOIFLIST: c_int = 4; +pub const NET_RT_OIFLIST: c_int = 5; +pub const NET_RT_IFLIST: c_int = 6; + +pub const PF_OROUTE: c_int = AF_OROUTE; +pub const PF_ARP: c_int = AF_ARP; +pub const PF_KEY: c_int = pseudo_AF_KEY; +pub const PF_BLUETOOTH: c_int = AF_BLUETOOTH; +pub const PF_MPLS: c_int = AF_MPLS; +pub const PF_ROUTE: c_int = AF_ROUTE; + +pub const MSG_NBIO: c_int = 0x1000; +pub const MSG_WAITFORONE: c_int = 0x2000; +pub const MSG_NOTIFICATION: c_int = 0x4000; + +pub const SCM_TIMESTAMP: c_int = 0x08; +pub const SCM_CREDS: c_int = 0x10; + +pub const O_DSYNC: c_int = 0x10000; + +pub const MAP_RENAME: c_int = 0x20; +pub const MAP_NORESERVE: c_int = 0x40; +pub const MAP_HASSEMAPHORE: c_int = 0x200; +pub const MAP_TRYFIXED: c_int = 0x400; +pub const MAP_WIRED: c_int = 0x800; +pub const MAP_STACK: c_int = 0x2000; +// map alignment aliases for MAP_ALIGNED +pub const MAP_ALIGNMENT_SHIFT: c_int = 24; +pub const MAP_ALIGNMENT_MASK: c_int = 0xff << MAP_ALIGNMENT_SHIFT; +pub const MAP_ALIGNMENT_64KB: c_int = 16 << MAP_ALIGNMENT_SHIFT; +pub const MAP_ALIGNMENT_16MB: c_int = 24 << MAP_ALIGNMENT_SHIFT; +pub const MAP_ALIGNMENT_4GB: c_int = 32 << MAP_ALIGNMENT_SHIFT; +pub const MAP_ALIGNMENT_1TB: c_int = 40 << MAP_ALIGNMENT_SHIFT; +pub const MAP_ALIGNMENT_256TB: c_int = 48 << MAP_ALIGNMENT_SHIFT; +pub const MAP_ALIGNMENT_64PB: c_int = 56 << MAP_ALIGNMENT_SHIFT; +// mremap flag +pub const MAP_REMAPDUP: c_int = 0x004; + +pub const DCCP_TYPE_REQUEST: c_int = 0; +pub const DCCP_TYPE_RESPONSE: c_int = 1; +pub const DCCP_TYPE_DATA: c_int = 2; +pub const DCCP_TYPE_ACK: c_int = 3; +pub const DCCP_TYPE_DATAACK: c_int = 4; +pub const DCCP_TYPE_CLOSEREQ: c_int = 5; +pub const DCCP_TYPE_CLOSE: c_int = 6; +pub const DCCP_TYPE_RESET: c_int = 7; +pub const DCCP_TYPE_MOVE: c_int = 8; + +pub const DCCP_FEATURE_CC: c_int = 1; +pub const DCCP_FEATURE_ECN: c_int = 2; +pub const DCCP_FEATURE_ACKRATIO: c_int = 3; +pub const DCCP_FEATURE_ACKVECTOR: c_int = 4; +pub const DCCP_FEATURE_MOBILITY: c_int = 5; +pub const DCCP_FEATURE_LOSSWINDOW: c_int = 6; +pub const DCCP_FEATURE_CONN_NONCE: c_int = 8; +pub const DCCP_FEATURE_IDENTREG: c_int = 7; + +pub const DCCP_OPT_PADDING: c_int = 0; +pub const DCCP_OPT_DATA_DISCARD: c_int = 1; +pub const DCCP_OPT_SLOW_RECV: c_int = 2; +pub const DCCP_OPT_BUF_CLOSED: c_int = 3; +pub const DCCP_OPT_CHANGE_L: c_int = 32; +pub const DCCP_OPT_CONFIRM_L: c_int = 33; +pub const DCCP_OPT_CHANGE_R: c_int = 34; +pub const DCCP_OPT_CONFIRM_R: c_int = 35; +pub const DCCP_OPT_INIT_COOKIE: c_int = 36; +pub const DCCP_OPT_NDP_COUNT: c_int = 37; +pub const DCCP_OPT_ACK_VECTOR0: c_int = 38; +pub const DCCP_OPT_ACK_VECTOR1: c_int = 39; +pub const DCCP_OPT_RECV_BUF_DROPS: c_int = 40; +pub const DCCP_OPT_TIMESTAMP: c_int = 41; +pub const DCCP_OPT_TIMESTAMP_ECHO: c_int = 42; +pub const DCCP_OPT_ELAPSEDTIME: c_int = 43; +pub const DCCP_OPT_DATACHECKSUM: c_int = 44; + +pub const DCCP_REASON_UNSPEC: c_int = 0; +pub const DCCP_REASON_CLOSED: c_int = 1; +pub const DCCP_REASON_INVALID: c_int = 2; +pub const DCCP_REASON_OPTION_ERR: c_int = 3; +pub const DCCP_REASON_FEA_ERR: c_int = 4; +pub const DCCP_REASON_CONN_REF: c_int = 5; +pub const DCCP_REASON_BAD_SNAME: c_int = 6; +pub const DCCP_REASON_BAD_COOKIE: c_int = 7; +pub const DCCP_REASON_INV_MOVE: c_int = 8; +pub const DCCP_REASON_UNANSW_CH: c_int = 10; +pub const DCCP_REASON_FRUITLESS_NEG: c_int = 11; + +pub const DCCP_CCID: c_int = 1; +pub const DCCP_CSLEN: c_int = 2; +pub const DCCP_MAXSEG: c_int = 4; +pub const DCCP_SERVICE: c_int = 8; + +pub const DCCP_NDP_LIMIT: c_int = 16; +pub const DCCP_SEQ_NUM_LIMIT: c_int = 16777216; +pub const DCCP_MAX_OPTIONS: c_int = 32; +pub const DCCP_MAX_PKTS: c_int = 100; + +pub const _PC_LINK_MAX: c_int = 1; +pub const _PC_MAX_CANON: c_int = 2; +pub const _PC_MAX_INPUT: c_int = 3; +pub const _PC_NAME_MAX: c_int = 4; +pub const _PC_PATH_MAX: c_int = 5; +pub const _PC_PIPE_BUF: c_int = 6; +pub const _PC_CHOWN_RESTRICTED: c_int = 7; +pub const _PC_NO_TRUNC: c_int = 8; +pub const _PC_VDISABLE: c_int = 9; +pub const _PC_SYNC_IO: c_int = 10; +pub const _PC_FILESIZEBITS: c_int = 11; +pub const _PC_SYMLINK_MAX: c_int = 12; +pub const _PC_2_SYMLINKS: c_int = 13; +pub const _PC_ACL_EXTENDED: c_int = 14; +pub const _PC_MIN_HOLE_SIZE: c_int = 15; + +pub const _CS_PATH: c_int = 1; + +pub const _SC_SYNCHRONIZED_IO: c_int = 31; +pub const _SC_IOV_MAX: c_int = 32; +pub const _SC_MAPPED_FILES: c_int = 33; +pub const _SC_MEMLOCK: c_int = 34; +pub const _SC_MEMLOCK_RANGE: c_int = 35; +pub const _SC_MEMORY_PROTECTION: c_int = 36; +pub const _SC_LOGIN_NAME_MAX: c_int = 37; +pub const _SC_MONOTONIC_CLOCK: c_int = 38; +pub const _SC_CLK_TCK: c_int = 39; +pub const _SC_ATEXIT_MAX: c_int = 40; +pub const _SC_THREADS: c_int = 41; +pub const _SC_SEMAPHORES: c_int = 42; +pub const _SC_BARRIERS: c_int = 43; +pub const _SC_TIMERS: c_int = 44; +pub const _SC_SPIN_LOCKS: c_int = 45; +pub const _SC_READER_WRITER_LOCKS: c_int = 46; +pub const _SC_GETGR_R_SIZE_MAX: c_int = 47; +pub const _SC_GETPW_R_SIZE_MAX: c_int = 48; +pub const _SC_CLOCK_SELECTION: c_int = 49; +pub const _SC_ASYNCHRONOUS_IO: c_int = 50; +pub const _SC_AIO_LISTIO_MAX: c_int = 51; +pub const _SC_AIO_MAX: c_int = 52; +pub const _SC_MESSAGE_PASSING: c_int = 53; +pub const _SC_MQ_OPEN_MAX: c_int = 54; +pub const _SC_MQ_PRIO_MAX: c_int = 55; +pub const _SC_PRIORITY_SCHEDULING: c_int = 56; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 57; +pub const _SC_THREAD_KEYS_MAX: c_int = 58; +pub const _SC_THREAD_STACK_MIN: c_int = 59; +pub const _SC_THREAD_THREADS_MAX: c_int = 60; +pub const _SC_THREAD_ATTR_STACKADDR: c_int = 61; +pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 62; +pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 63; +pub const _SC_THREAD_PRIO_INHERIT: c_int = 64; +pub const _SC_THREAD_PRIO_PROTECT: c_int = 65; +pub const _SC_THREAD_PROCESS_SHARED: c_int = 66; +pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 67; +pub const _SC_TTY_NAME_MAX: c_int = 68; +pub const _SC_HOST_NAME_MAX: c_int = 69; +pub const _SC_PASS_MAX: c_int = 70; +pub const _SC_REGEXP: c_int = 71; +pub const _SC_SHELL: c_int = 72; +pub const _SC_SYMLOOP_MAX: c_int = 73; +pub const _SC_V6_ILP32_OFF32: c_int = 74; +pub const _SC_V6_ILP32_OFFBIG: c_int = 75; +pub const _SC_V6_LP64_OFF64: c_int = 76; +pub const _SC_V6_LPBIG_OFFBIG: c_int = 77; +pub const _SC_2_PBS: c_int = 80; +pub const _SC_2_PBS_ACCOUNTING: c_int = 81; +pub const _SC_2_PBS_CHECKPOINT: c_int = 82; +pub const _SC_2_PBS_LOCATE: c_int = 83; +pub const _SC_2_PBS_MESSAGE: c_int = 84; +pub const _SC_2_PBS_TRACK: c_int = 85; +pub const _SC_SPAWN: c_int = 86; +pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 87; +pub const _SC_TIMER_MAX: c_int = 88; +pub const _SC_SEM_NSEMS_MAX: c_int = 89; +pub const _SC_CPUTIME: c_int = 90; +pub const _SC_THREAD_CPUTIME: c_int = 91; +pub const _SC_DELAYTIMER_MAX: c_int = 92; +// These two variables will be supported in NetBSD 8.0 +// pub const _SC_SIGQUEUE_MAX : c_int = 93; +// pub const _SC_REALTIME_SIGNALS : c_int = 94; +pub const _SC_PHYS_PAGES: c_int = 121; +pub const _SC_NPROCESSORS_CONF: c_int = 1001; +pub const _SC_NPROCESSORS_ONLN: c_int = 1002; +pub const _SC_SCHED_RT_TS: c_int = 2001; +pub const _SC_SCHED_PRI_MIN: c_int = 2002; +pub const _SC_SCHED_PRI_MAX: c_int = 2003; + +pub const FD_SETSIZE: usize = 0x100; + +pub const ST_NOSUID: c_ulong = 8; + +// +pub const MNT_UNION: c_int = 0x00000020; +pub const MNT_NOCOREDUMP: c_int = 0x00008000; +pub const MNT_RELATIME: c_int = 0x00020000; +pub const MNT_IGNORE: c_int = 0x00100000; +pub const MNT_NFS4ACLS: c_int = 0x00200000; +pub const MNT_DISCARD: c_int = 0x00800000; +pub const MNT_EXTATTR: c_int = 0x01000000; +pub const MNT_LOG: c_int = 0x02000000; +pub const MNT_NOATIME: c_int = 0x04000000; +pub const MNT_AUTOMOUNTED: c_int = 0x10000000; +pub const MNT_SYMPERM: c_int = 0x20000000; +pub const MNT_NODEVMTIME: c_int = 0x40000000; +pub const MNT_SOFTDEP: c_int = 0x80000000; +pub const MNT_POSIX1EACLS: c_int = 0x00000800; +pub const MNT_ACLS: c_int = MNT_POSIX1EACLS; +pub const MNT_WAIT: c_int = 1; +pub const MNT_NOWAIT: c_int = 2; +pub const MNT_LAZY: c_int = 3; + +// sys/ioccom.h +pub const IOCPARM_SHIFT: u32 = 16; +pub const IOCGROUP_SHIFT: u32 = 8; + +pub const fn IOCPARM_LEN(x: u32) -> u32 { + (x >> IOCPARM_SHIFT) & crate::IOCPARM_MASK +} + +pub const fn IOCBASECMD(x: u32) -> u32 { + x & (!(crate::IOCPARM_MASK << IOCPARM_SHIFT)) +} + +pub const fn IOCGROUP(x: u32) -> u32 { + (x >> IOCGROUP_SHIFT) & 0xff +} + +pub const fn _IOC(inout: c_ulong, group: c_ulong, num: c_ulong, len: c_ulong) -> c_ulong { + (inout) + | (((len) & crate::IOCPARM_MASK as c_ulong) << IOCPARM_SHIFT) + | ((group) << IOCGROUP_SHIFT) + | (num) +} + +pub const NTP_API: c_int = 4; + +pub const LITTLE_ENDIAN: c_int = 1234; +pub const BIG_ENDIAN: c_int = 4321; + +#[deprecated(since = "0.2.178", note = "obsolete upstream")] +pub const PL_EVENT_NONE: c_int = 0; +#[deprecated(since = "0.2.178", note = "obsolete upstream")] +pub const PL_EVENT_SIGNAL: c_int = 1; +#[deprecated(since = "0.2.178", note = "obsolete upstream")] +pub const PL_EVENT_SUSPENDED: c_int = 2; + +cfg_if! { + if #[cfg(any( + target_arch = "sparc", + target_arch = "sparc64", + target_arch = "x86", + target_arch = "x86_64" + ))] { + pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + ptm_magic: 0x33330003, + ptm_errorcheck: 0, + ptm_pad1: Padding::new([0; 3]), + ptm_unused: Padding::new(0), + ptm_pad2: Padding::new([0; 3]), + ptm_waiters: 0 as *mut _, + ptm_owner: 0, + ptm_recursed: 0, + ptm_spare2: 0 as *mut _, + }; + } else { + pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + ptm_magic: 0x33330003, + ptm_errorcheck: 0, + ptm_unused: Padding::new(0), + ptm_waiters: 0 as *mut _, + ptm_owner: 0, + ptm_recursed: 0, + ptm_spare2: 0 as *mut _, + }; + } +} + +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + ptc_magic: 0x55550005, + ptc_lock: 0, + ptc_waiters_first: 0 as *mut _, + ptc_waiters_last: 0 as *mut _, + ptc_mutex: 0 as *mut _, + ptc_private: 0 as *mut _, +}; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + ptr_magic: 0x99990009, + ptr_interlock: 0, + ptr_rblocked_first: 0 as *mut _, + ptr_rblocked_last: 0 as *mut _, + ptr_wblocked_first: 0 as *mut _, + ptr_wblocked_last: 0 as *mut _, + ptr_nreaders: 0, + ptr_owner: 0, + ptr_private: 0 as *mut _, +}; +pub const PTHREAD_MUTEX_NORMAL: c_int = 0; +pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 1; +pub const PTHREAD_MUTEX_RECURSIVE: c_int = 2; +pub const PTHREAD_MUTEX_DEFAULT: c_int = PTHREAD_MUTEX_NORMAL; + +pub const SCHED_NONE: c_int = -1; +pub const SCHED_OTHER: c_int = 0; +pub const SCHED_FIFO: c_int = 1; +pub const SCHED_RR: c_int = 2; + +pub const EVFILT_AIO: u32 = 2; +pub const EVFILT_PROC: u32 = 4; +pub const EVFILT_READ: u32 = 0; +pub const EVFILT_SIGNAL: u32 = 5; +pub const EVFILT_TIMER: u32 = 6; +pub const EVFILT_VNODE: u32 = 3; +pub const EVFILT_WRITE: u32 = 1; +pub const EVFILT_FS: u32 = 7; +pub const EVFILT_USER: u32 = 8; +pub const EVFILT_EMPTY: u32 = 9; + +pub const EV_ADD: u32 = 0x1; +pub const EV_DELETE: u32 = 0x2; +pub const EV_ENABLE: u32 = 0x4; +pub const EV_DISABLE: u32 = 0x8; +pub const EV_ONESHOT: u32 = 0x10; +pub const EV_CLEAR: u32 = 0x20; +pub const EV_RECEIPT: u32 = 0x40; +pub const EV_DISPATCH: u32 = 0x80; +pub const EV_FLAG1: u32 = 0x2000; +pub const EV_ERROR: u32 = 0x4000; +pub const EV_EOF: u32 = 0x8000; +pub const EV_SYSFLAGS: u32 = 0xf000; + +pub const NOTE_TRIGGER: u32 = 0x01000000; +pub const NOTE_FFNOP: u32 = 0x00000000; +pub const NOTE_FFAND: u32 = 0x40000000; +pub const NOTE_FFOR: u32 = 0x80000000; +pub const NOTE_FFCOPY: u32 = 0xc0000000; +pub const NOTE_FFCTRLMASK: u32 = 0xc0000000; +pub const NOTE_FFLAGSMASK: u32 = 0x00ffffff; +pub const NOTE_LOWAT: u32 = 0x00000001; +pub const NOTE_DELETE: u32 = 0x00000001; +pub const NOTE_WRITE: u32 = 0x00000002; +pub const NOTE_EXTEND: u32 = 0x00000004; +pub const NOTE_ATTRIB: u32 = 0x00000008; +pub const NOTE_LINK: u32 = 0x00000010; +pub const NOTE_RENAME: u32 = 0x00000020; +pub const NOTE_REVOKE: u32 = 0x00000040; +pub const NOTE_EXIT: u32 = 0x80000000; +pub const NOTE_FORK: u32 = 0x40000000; +pub const NOTE_EXEC: u32 = 0x20000000; +pub const NOTE_PDATAMASK: u32 = 0x000fffff; +pub const NOTE_PCTRLMASK: u32 = 0xf0000000; +pub const NOTE_TRACK: u32 = 0x00000001; +pub const NOTE_TRACKERR: u32 = 0x00000002; +pub const NOTE_CHILD: u32 = 0x00000004; +pub const NOTE_MSECONDS: u32 = 0x00000000; +pub const NOTE_SECONDS: u32 = 0x00000001; +pub const NOTE_USECONDS: u32 = 0x00000002; +pub const NOTE_NSECONDS: u32 = 0x00000003; +pub const NOTE_ABSTIME: u32 = 0x000000010; + +pub const TMP_MAX: c_uint = 308915776; + +pub const AI_PASSIVE: c_int = 0x00000001; +pub const AI_CANONNAME: c_int = 0x00000002; +pub const AI_NUMERICHOST: c_int = 0x00000004; +pub const AI_NUMERICSERV: c_int = 0x00000008; +pub const AI_ADDRCONFIG: c_int = 0x00000400; +pub const AI_SRV: c_int = 0x00000800; + +pub const NI_MAXHOST: crate::socklen_t = 1025; +pub const NI_MAXSERV: crate::socklen_t = 32; + +pub const NI_NOFQDN: c_int = 0x00000001; +pub const NI_NUMERICHOST: c_int = 0x000000002; +pub const NI_NAMEREQD: c_int = 0x000000004; +pub const NI_NUMERICSERV: c_int = 0x000000008; +pub const NI_DGRAM: c_int = 0x00000010; +pub const NI_WITHSCOPEID: c_int = 0x00000020; +pub const NI_NUMERICSCOPE: c_int = 0x00000040; + +pub const RTLD_NOLOAD: c_int = 0x2000; +pub const RTLD_LOCAL: c_int = 0x200; + +pub const CTL_MAXNAME: c_int = 12; +pub const SYSCTL_NAMELEN: c_int = 32; +pub const SYSCTL_DEFSIZE: c_int = 8; +pub const CTLTYPE_NODE: c_int = 1; +pub const CTLTYPE_INT: c_int = 2; +pub const CTLTYPE_STRING: c_int = 3; +pub const CTLTYPE_QUAD: c_int = 4; +pub const CTLTYPE_STRUCT: c_int = 5; +pub const CTLTYPE_BOOL: c_int = 6; +pub const CTLFLAG_READONLY: c_int = 0x00000000; +pub const CTLFLAG_READWRITE: c_int = 0x00000070; +pub const CTLFLAG_ANYWRITE: c_int = 0x00000080; +pub const CTLFLAG_PRIVATE: c_int = 0x00000100; +pub const CTLFLAG_PERMANENT: c_int = 0x00000200; +pub const CTLFLAG_OWNDATA: c_int = 0x00000400; +pub const CTLFLAG_IMMEDIATE: c_int = 0x00000800; +pub const CTLFLAG_HEX: c_int = 0x00001000; +pub const CTLFLAG_ROOT: c_int = 0x00002000; +pub const CTLFLAG_ANYNUMBER: c_int = 0x00004000; +pub const CTLFLAG_HIDDEN: c_int = 0x00008000; +pub const CTLFLAG_ALIAS: c_int = 0x00010000; +pub const CTLFLAG_MMAP: c_int = 0x00020000; +pub const CTLFLAG_OWNDESC: c_int = 0x00040000; +pub const CTLFLAG_UNSIGNED: c_int = 0x00080000; +pub const SYSCTL_VERS_MASK: c_int = 0xff000000; +pub const SYSCTL_VERS_0: c_int = 0x00000000; +pub const SYSCTL_VERS_1: c_int = 0x01000000; +pub const SYSCTL_VERSION: c_int = SYSCTL_VERS_1; +pub const CTL_EOL: c_int = -1; +pub const CTL_QUERY: c_int = -2; +pub const CTL_CREATE: c_int = -3; +pub const CTL_CREATESYM: c_int = -4; +pub const CTL_DESTROY: c_int = -5; +pub const CTL_MMAP: c_int = -6; +pub const CTL_DESCRIBE: c_int = -7; +pub const CTL_UNSPEC: c_int = 0; +pub const CTL_KERN: c_int = 1; +pub const CTL_VM: c_int = 2; +pub const CTL_VFS: c_int = 3; +pub const CTL_NET: c_int = 4; +pub const CTL_DEBUG: c_int = 5; +pub const CTL_HW: c_int = 6; +pub const CTL_MACHDEP: c_int = 7; +pub const CTL_USER: c_int = 8; +pub const CTL_DDB: c_int = 9; +pub const CTL_PROC: c_int = 10; +pub const CTL_VENDOR: c_int = 11; +pub const CTL_EMUL: c_int = 12; +pub const CTL_SECURITY: c_int = 13; +pub const KERN_OSTYPE: c_int = 1; +pub const KERN_OSRELEASE: c_int = 2; +pub const KERN_OSREV: c_int = 3; +pub const KERN_VERSION: c_int = 4; +pub const KERN_MAXVNODES: c_int = 5; +pub const KERN_MAXPROC: c_int = 6; +pub const KERN_MAXFILES: c_int = 7; +pub const KERN_ARGMAX: c_int = 8; +pub const KERN_SECURELVL: c_int = 9; +pub const KERN_HOSTNAME: c_int = 10; +pub const KERN_HOSTID: c_int = 11; +pub const KERN_CLOCKRATE: c_int = 12; +pub const KERN_VNODE: c_int = 13; +pub const KERN_PROC: c_int = 14; +pub const KERN_FILE: c_int = 15; +pub const KERN_PROF: c_int = 16; +pub const KERN_POSIX1: c_int = 17; +pub const KERN_NGROUPS: c_int = 18; +pub const KERN_JOB_CONTROL: c_int = 19; +pub const KERN_SAVED_IDS: c_int = 20; +pub const KERN_OBOOTTIME: c_int = 21; +pub const KERN_DOMAINNAME: c_int = 22; +pub const KERN_MAXPARTITIONS: c_int = 23; +pub const KERN_RAWPARTITION: c_int = 24; +pub const KERN_NTPTIME: c_int = 25; +pub const KERN_TIMEX: c_int = 26; +pub const KERN_AUTONICETIME: c_int = 27; +pub const KERN_AUTONICEVAL: c_int = 28; +pub const KERN_RTC_OFFSET: c_int = 29; +pub const KERN_ROOT_DEVICE: c_int = 30; +pub const KERN_MSGBUFSIZE: c_int = 31; +pub const KERN_FSYNC: c_int = 32; +pub const KERN_OLDSYSVMSG: c_int = 33; +pub const KERN_OLDSYSVSEM: c_int = 34; +pub const KERN_OLDSYSVSHM: c_int = 35; +pub const KERN_OLDSHORTCORENAME: c_int = 36; +pub const KERN_SYNCHRONIZED_IO: c_int = 37; +pub const KERN_IOV_MAX: c_int = 38; +pub const KERN_MBUF: c_int = 39; +pub const KERN_MAPPED_FILES: c_int = 40; +pub const KERN_MEMLOCK: c_int = 41; +pub const KERN_MEMLOCK_RANGE: c_int = 42; +pub const KERN_MEMORY_PROTECTION: c_int = 43; +pub const KERN_LOGIN_NAME_MAX: c_int = 44; +pub const KERN_DEFCORENAME: c_int = 45; +pub const KERN_LOGSIGEXIT: c_int = 46; +pub const KERN_PROC2: c_int = 47; +pub const KERN_PROC_ARGS: c_int = 48; +pub const KERN_FSCALE: c_int = 49; +pub const KERN_CCPU: c_int = 50; +pub const KERN_CP_TIME: c_int = 51; +pub const KERN_OLDSYSVIPC_INFO: c_int = 52; +pub const KERN_MSGBUF: c_int = 53; +pub const KERN_CONSDEV: c_int = 54; +pub const KERN_MAXPTYS: c_int = 55; +pub const KERN_PIPE: c_int = 56; +pub const KERN_MAXPHYS: c_int = 57; +pub const KERN_SBMAX: c_int = 58; +pub const KERN_TKSTAT: c_int = 59; +pub const KERN_MONOTONIC_CLOCK: c_int = 60; +pub const KERN_URND: c_int = 61; +pub const KERN_LABELSECTOR: c_int = 62; +pub const KERN_LABELOFFSET: c_int = 63; +pub const KERN_LWP: c_int = 64; +pub const KERN_FORKFSLEEP: c_int = 65; +pub const KERN_POSIX_THREADS: c_int = 66; +pub const KERN_POSIX_SEMAPHORES: c_int = 67; +pub const KERN_POSIX_BARRIERS: c_int = 68; +pub const KERN_POSIX_TIMERS: c_int = 69; +pub const KERN_POSIX_SPIN_LOCKS: c_int = 70; +pub const KERN_POSIX_READER_WRITER_LOCKS: c_int = 71; +pub const KERN_DUMP_ON_PANIC: c_int = 72; +pub const KERN_SOMAXKVA: c_int = 73; +pub const KERN_ROOT_PARTITION: c_int = 74; +pub const KERN_DRIVERS: c_int = 75; +pub const KERN_BUF: c_int = 76; +pub const KERN_FILE2: c_int = 77; +pub const KERN_VERIEXEC: c_int = 78; +pub const KERN_CP_ID: c_int = 79; +pub const KERN_HARDCLOCK_TICKS: c_int = 80; +pub const KERN_ARND: c_int = 81; +pub const KERN_SYSVIPC: c_int = 82; +pub const KERN_BOOTTIME: c_int = 83; +pub const KERN_EVCNT: c_int = 84; +pub const KERN_PROC_ALL: c_int = 0; +pub const KERN_PROC_PID: c_int = 1; +pub const KERN_PROC_PGRP: c_int = 2; +pub const KERN_PROC_SESSION: c_int = 3; +pub const KERN_PROC_TTY: c_int = 4; +pub const KERN_PROC_UID: c_int = 5; +pub const KERN_PROC_RUID: c_int = 6; +pub const KERN_PROC_GID: c_int = 7; +pub const KERN_PROC_RGID: c_int = 8; +pub const KERN_PROC_ARGV: c_int = 1; +pub const KERN_PROC_NARGV: c_int = 2; +pub const KERN_PROC_ENV: c_int = 3; +pub const KERN_PROC_NENV: c_int = 4; +pub const KERN_PROC_PATHNAME: c_int = 5; +pub const VM_PROC: c_int = 16; +pub const VM_PROC_MAP: c_int = 1; + +pub const EAI_AGAIN: c_int = 2; +pub const EAI_BADFLAGS: c_int = 3; +pub const EAI_FAIL: c_int = 4; +pub const EAI_FAMILY: c_int = 5; +pub const EAI_MEMORY: c_int = 6; +pub const EAI_NODATA: c_int = 7; +pub const EAI_NONAME: c_int = 8; +pub const EAI_SERVICE: c_int = 9; +pub const EAI_SOCKTYPE: c_int = 10; +pub const EAI_SYSTEM: c_int = 11; +pub const EAI_OVERFLOW: c_int = 14; + +pub const AIO_CANCELED: c_int = 1; +pub const AIO_NOTCANCELED: c_int = 2; +pub const AIO_ALLDONE: c_int = 3; +pub const LIO_NOP: c_int = 0; +pub const LIO_WRITE: c_int = 1; +pub const LIO_READ: c_int = 2; +pub const LIO_WAIT: c_int = 1; +pub const LIO_NOWAIT: c_int = 0; + +pub const SIGEV_NONE: c_int = 0; +pub const SIGEV_SIGNAL: c_int = 1; +pub const SIGEV_THREAD: c_int = 2; + +pub const WSTOPPED: c_int = 0x00000002; // same as WUNTRACED +pub const WCONTINUED: c_int = 0x00000010; +pub const WEXITED: c_int = 0x000000020; +pub const WNOWAIT: c_int = 0x00010000; + +pub const WALTSIG: c_int = 0x00000004; +pub const WALLSIG: c_int = 0x00000008; +pub const WTRAPPED: c_int = 0x00000040; +pub const WNOZOMBIE: c_int = 0x00020000; + +pub const P_ALL: idtype_t = 0; +pub const P_PID: idtype_t = 1; +pub const P_PGID: idtype_t = 4; + +pub const UTIME_OMIT: c_long = 1073741822; +pub const UTIME_NOW: c_long = 1073741823; + +pub const B460800: crate::speed_t = 460800; +pub const B921600: crate::speed_t = 921600; + +pub const ONOCR: crate::tcflag_t = 0x20; +pub const ONLRET: crate::tcflag_t = 0x40; +pub const CDTRCTS: crate::tcflag_t = 0x00020000; +pub const CHWFLOW: crate::tcflag_t = crate::MDMBUF | crate::CRTSCTS | crate::CDTRCTS; + +pub const SOCK_CLOEXEC: c_int = 0x10000000; +pub const SOCK_NONBLOCK: c_int = 0x20000000; + +// Uncomment on next NetBSD release +// pub const FIOSEEKDATA: c_ulong = 0xc0086661; +// pub const FIOSEEKHOLE: c_ulong = 0xc0086662; +pub const OFIOGETBMAP: c_ulong = 0xc004667a; +pub const FIOGETBMAP: c_ulong = 0xc008667a; +pub const FIONWRITE: c_ulong = 0x40046679; +pub const FIONSPACE: c_ulong = 0x40046678; +pub const FIBMAP: c_ulong = 0xc008667a; + +pub const SIGSTKSZ: size_t = 40960; + +pub const REG_ILLSEQ: c_int = 17; + +pub const PT_DUMPCORE: c_int = 12; +#[deprecated(note = "obsolete operation")] +pub const PT_LWPINFO: c_int = 13; +pub const PT_SYSCALL: c_int = 14; +pub const PT_SYSCALLEMU: c_int = 15; +pub const PT_SET_EVENT_MASK: c_int = 16; +pub const PT_GET_EVENT_MASK: c_int = 17; +pub const PT_GET_PROCESS_STATE: c_int = 18; +pub const PT_SET_SIGINFO: c_int = 19; +pub const PT_GET_SIGINFO: c_int = 20; +pub const PT_RESUME: c_int = 21; +pub const PT_SUSPEND: c_int = 22; +pub const PT_STOP: c_int = 23; +pub const PT_LWPSTATUS: c_int = 24; +pub const PT_LWPNEXT: c_int = 25; +pub const PT_SET_SIGPASS: c_int = 26; +pub const PT_GET_SIGPASS: c_int = 27; +pub const PT_FIRSTMACH: c_int = 32; +pub const POSIX_SPAWN_RETURNERROR: c_int = 0x40; + +// Flags for chflags(2) +pub const SF_APPEND: c_ulong = 0x00040000; +pub const SF_ARCHIVED: c_ulong = 0x00010000; +pub const SF_IMMUTABLE: c_ulong = 0x00020000; +pub const SF_LOG: c_ulong = 0x00400000; +pub const SF_SETTABLE: c_ulong = 0xffff0000; +pub const SF_SNAPINVAL: c_ulong = 0x00800000; +pub const SF_SNAPSHOT: c_ulong = 0x00200000; +pub const UF_APPEND: c_ulong = 0x00000004; +pub const UF_IMMUTABLE: c_ulong = 0x00000002; +pub const UF_NODUMP: c_ulong = 0x00000001; +pub const UF_OPAQUE: c_ulong = 0x00000008; +pub const UF_SETTABLE: c_ulong = 0x0000ffff; + +// sys/sysctl.h +pub const KVME_PROT_READ: c_int = 0x00000001; +pub const KVME_PROT_WRITE: c_int = 0x00000002; +pub const KVME_PROT_EXEC: c_int = 0x00000004; + +pub const KVME_FLAG_COW: c_int = 0x00000001; +pub const KVME_FLAG_NEEDS_COPY: c_int = 0x00000002; +pub const KVME_FLAG_NOCOREDUMP: c_int = 0x000000004; +pub const KVME_FLAG_PAGEABLE: c_int = 0x000000008; +pub const KVME_FLAG_GROWS_UP: c_int = 0x000000010; +pub const KVME_FLAG_GROWS_DOWN: c_int = 0x000000020; + +pub const NGROUPS_MAX: c_int = 16; + +pub const KI_NGROUPS: c_int = 16; +pub const KI_MAXCOMLEN: c_int = 24; +pub const KI_WMESGLEN: c_int = 8; +pub const KI_MAXLOGNAME: c_int = 24; +pub const KI_MAXEMULLEN: c_int = 16; +pub const KI_LNAMELEN: c_int = 20; + +pub const KERN_FILE_BYFILE: c_int = 1; +pub const KERN_FILE_BYPID: c_int = 2; +pub const KERN_FILESLOP: c_int = 10; + +// sys/lwp.h +pub const LSIDL: c_int = 1; +pub const LSRUN: c_int = 2; +pub const LSSLEEP: c_int = 3; +pub const LSSTOP: c_int = 4; +pub const LSZOMB: c_int = 5; +pub const LSONPROC: c_int = 7; +pub const LSSUSPENDED: c_int = 8; + +// sys/xattr.h +pub const XATTR_CREATE: c_int = 0x01; +pub const XATTR_REPLACE: c_int = 0x02; +// sys/extattr.h +pub const EXTATTR_NAMESPACE_EMPTY: c_int = 0; + +// For getrandom() +pub const GRND_NONBLOCK: c_uint = 0x1; +pub const GRND_RANDOM: c_uint = 0x2; +pub const GRND_INSECURE: c_uint = 0x4; + +// sys/reboot.h +pub const RB_ASKNAME: c_int = 0x000000001; +pub const RB_SINGLE: c_int = 0x000000002; +pub const RB_NOSYNC: c_int = 0x000000004; +pub const RB_HALT: c_int = 0x000000008; +pub const RB_INITNAME: c_int = 0x000000010; +pub const RB_KDB: c_int = 0x000000040; +pub const RB_RDONLY: c_int = 0x000000080; +pub const RB_DUMP: c_int = 0x000000100; +pub const RB_MINIROOT: c_int = 0x000000200; +pub const RB_STRING: c_int = 0x000000400; +pub const RB_POWERDOWN: c_int = RB_HALT | 0x000000800; +pub const RB_USERCONF: c_int = 0x000001000; + +pub const fn MAP_ALIGNED(alignment: c_int) -> c_int { + alignment << MAP_ALIGNMENT_SHIFT +} + +// net/route.h +pub const RTF_MASK: c_int = 0x80; +pub const RTF_CONNECTED: c_int = 0x100; +pub const RTF_ANNOUNCE: c_int = 0x20000; +pub const RTF_SRC: c_int = 0x10000; +pub const RTF_LOCAL: c_int = 0x40000; +pub const RTF_BROADCAST: c_int = 0x80000; +pub const RTF_UPDATING: c_int = 0x100000; +pub const RTF_DONTCHANGEIFA: c_int = 0x200000; + +pub const RTM_VERSION: c_int = 4; +pub const RTM_LOCK: c_int = 0x8; +pub const RTM_IFANNOUNCE: c_int = 0x10; +pub const RTM_IEEE80211: c_int = 0x11; +pub const RTM_SETGATE: c_int = 0x12; +pub const RTM_LLINFO_UPD: c_int = 0x13; +pub const RTM_IFINFO: c_int = 0x14; +pub const RTM_OCHGADDR: c_int = 0x15; +pub const RTM_NEWADDR: c_int = 0x16; +pub const RTM_DELADDR: c_int = 0x17; +pub const RTM_CHGADDR: c_int = 0x18; + +pub const RTA_TAG: c_int = 0x100; + +pub const RTAX_TAG: c_int = 8; +pub const RTAX_MAX: c_int = 9; + +// For eventfd +pub const EFD_SEMAPHORE: c_int = crate::O_RDWR; +pub const EFD_NONBLOCK: c_int = crate::O_NONBLOCK; +pub const EFD_CLOEXEC: c_int = crate::O_CLOEXEC; + +// sys/timerfd.h +pub const TFD_CLOEXEC: i32 = crate::O_CLOEXEC; +pub const TFD_NONBLOCK: i32 = crate::O_NONBLOCK; +pub const TFD_TIMER_ABSTIME: i32 = crate::O_WRONLY; +pub const TFD_TIMER_CANCEL_ON_SET: i32 = crate::O_RDWR; + +const fn _ALIGN(p: usize) -> usize { + (p + _ALIGNBYTES) & !_ALIGNBYTES +} + +f! { + pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { + (cmsg as *mut c_uchar).add(_ALIGN(size_of::())) + } + + pub const fn CMSG_LEN(length: c_uint) -> c_uint { + _ALIGN(size_of::()) as c_uint + length + } + + pub fn CMSG_NXTHDR(mhdr: *const crate::msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { + if cmsg.is_null() { + return crate::CMSG_FIRSTHDR(mhdr); + } + let next = cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) + _ALIGN(size_of::()); + let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; + if next > max { + core::ptr::null_mut::() + } else { + (cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr + } + } + + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { + (_ALIGN(size_of::()) + _ALIGN(length as usize)) as c_uint + } + + // dirfd() is a macro on netbsd to access + // the first field of the struct where dirp points to: + // http://cvsweb.netbsd.org/bsdweb.cgi/src/include/dirent.h?rev=1.36 + pub fn dirfd(dirp: *mut crate::DIR) -> c_int { + *(dirp as *const c_int) + } + + pub fn SOCKCREDSIZE(ngrps: usize) -> usize { + let ngrps = if ngrps > 0 { ngrps - 1 } else { 0 }; + size_of::() + size_of::() * ngrps + } + + pub fn PROT_MPROTECT(x: c_int) -> c_int { + x << 3 + } + + pub fn PROT_MPROTECT_EXTRACT(x: c_int) -> c_int { + (x >> 3) & 0x7 + } +} + +safe_f! { + pub const fn WSTOPSIG(status: c_int) -> c_int { + status >> 8 + } + + pub const fn WIFSIGNALED(status: c_int) -> bool { + (status & 0o177) != 0o177 && (status & 0o177) != 0 + } + + pub const fn WIFSTOPPED(status: c_int) -> bool { + (status & 0o177) == 0o177 + } + + pub const fn WIFCONTINUED(status: c_int) -> bool { + status == 0xffff + } + + pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { + let major = major as crate::dev_t; + let minor = minor as crate::dev_t; + let mut dev = 0; + dev |= (major << 8) & 0x000ff00; + dev |= (minor << 12) & 0xfff00000; + dev |= minor & 0xff; + dev + } + + pub const fn major(dev: crate::dev_t) -> c_int { + (((dev as u32) & 0x000fff00) >> 8) as c_int + } + + pub const fn minor(dev: crate::dev_t) -> c_int { + let mut res = 0; + res |= ((dev as u32) & 0xfff00000) >> 12; + res |= (dev as u32) & 0x000000ff; + res as c_int + } +} + +extern "C" { + pub fn clock_nanosleep( + clk_id: crate::clockid_t, + flags: c_int, + rqtp: *const crate::timespec, + rmtp: *mut crate::timespec, + ) -> c_int; + + pub fn reallocarr(ptr: *mut c_void, number: size_t, size: size_t) -> c_int; + + pub fn chflags(path: *const c_char, flags: c_ulong) -> c_int; + pub fn fchflags(fd: c_int, flags: c_ulong) -> c_int; + pub fn lchflags(path: *const c_char, flags: c_ulong) -> c_int; + + pub fn extattr_list_fd( + fd: c_int, + attrnamespace: c_int, + data: *mut c_void, + nbytes: size_t, + ) -> ssize_t; + pub fn extattr_list_file( + path: *const c_char, + attrnamespace: c_int, + data: *mut c_void, + nbytes: size_t, + ) -> ssize_t; + pub fn extattr_list_link( + path: *const c_char, + attrnamespace: c_int, + data: *mut c_void, + nbytes: size_t, + ) -> ssize_t; + pub fn extattr_delete_fd(fd: c_int, attrnamespace: c_int, attrname: *const c_char) -> c_int; + pub fn extattr_delete_file( + path: *const c_char, + attrnamespace: c_int, + attrname: *const c_char, + ) -> c_int; + pub fn extattr_delete_link( + path: *const c_char, + attrnamespace: c_int, + attrname: *const c_char, + ) -> c_int; + pub fn extattr_get_fd( + fd: c_int, + attrnamespace: c_int, + attrname: *const c_char, + data: *mut c_void, + nbytes: size_t, + ) -> ssize_t; + pub fn extattr_get_file( + path: *const c_char, + attrnamespace: c_int, + attrname: *const c_char, + data: *mut c_void, + nbytes: size_t, + ) -> ssize_t; + pub fn extattr_get_link( + path: *const c_char, + attrnamespace: c_int, + attrname: *const c_char, + data: *mut c_void, + nbytes: size_t, + ) -> ssize_t; + pub fn extattr_namespace_to_string(attrnamespace: c_int, string: *mut *mut c_char) -> c_int; + pub fn extattr_set_fd( + fd: c_int, + attrnamespace: c_int, + attrname: *const c_char, + data: *const c_void, + nbytes: size_t, + ) -> c_int; + pub fn extattr_set_file( + path: *const c_char, + attrnamespace: c_int, + attrname: *const c_char, + data: *const c_void, + nbytes: size_t, + ) -> c_int; + pub fn extattr_set_link( + path: *const c_char, + attrnamespace: c_int, + attrname: *const c_char, + data: *const c_void, + nbytes: size_t, + ) -> c_int; + pub fn extattr_string_to_namespace(string: *const c_char, attrnamespace: *mut c_int) -> c_int; + + pub fn openpty( + amaster: *mut c_int, + aslave: *mut c_int, + name: *mut c_char, + termp: *mut crate::termios, + winp: *mut crate::winsize, + ) -> c_int; + pub fn forkpty( + amaster: *mut c_int, + name: *mut c_char, + termp: *mut crate::termios, + winp: *mut crate::winsize, + ) -> crate::pid_t; + + pub fn ptsname_r(fd: c_int, buf: *mut c_char, buflen: size_t) -> c_int; + + #[link_name = "__lutimes50"] + pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int; + #[link_name = "__gettimeofday50"] + pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut c_void) -> c_int; + pub fn getnameinfo( + sa: *const crate::sockaddr, + salen: crate::socklen_t, + host: *mut c_char, + hostlen: crate::socklen_t, + serv: *mut c_char, + servlen: crate::socklen_t, + flags: c_int, + ) -> c_int; + pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; + pub fn sysctl( + name: *const c_int, + namelen: c_uint, + oldp: *mut c_void, + oldlenp: *mut size_t, + newp: *const c_void, + newlen: size_t, + ) -> c_int; + pub fn sysctlbyname( + name: *const c_char, + oldp: *mut c_void, + oldlenp: *mut size_t, + newp: *const c_void, + newlen: size_t, + ) -> c_int; + pub fn sysctlnametomib(sname: *const c_char, name: *mut c_int, namelenp: *mut size_t) -> c_int; + #[link_name = "__kevent50"] + pub fn kevent( + kq: c_int, + changelist: *const crate::kevent, + nchanges: size_t, + eventlist: *mut crate::kevent, + nevents: size_t, + timeout: *const crate::timespec, + ) -> c_int; + #[link_name = "__mount50"] + pub fn mount( + src: *const c_char, + target: *const c_char, + flags: c_int, + data: *mut c_void, + size: size_t, + ) -> c_int; + pub fn mq_open(name: *const c_char, oflag: c_int, ...) -> crate::mqd_t; + pub fn mq_close(mqd: crate::mqd_t) -> c_int; + pub fn mq_getattr(mqd: crate::mqd_t, attr: *mut crate::mq_attr) -> c_int; + pub fn mq_notify(mqd: crate::mqd_t, notification: *const crate::sigevent) -> c_int; + pub fn mq_receive( + mqd: crate::mqd_t, + msg_ptr: *mut c_char, + msg_len: size_t, + msg_prio: *mut c_uint, + ) -> ssize_t; + pub fn mq_send( + mqd: crate::mqd_t, + msg_ptr: *const c_char, + msg_len: size_t, + msg_prio: c_uint, + ) -> c_int; + pub fn mq_setattr( + mqd: crate::mqd_t, + newattr: *const crate::mq_attr, + oldattr: *mut crate::mq_attr, + ) -> c_int; + #[link_name = "__mq_timedreceive50"] + pub fn mq_timedreceive( + mqd: crate::mqd_t, + msg_ptr: *mut c_char, + msg_len: size_t, + msg_prio: *mut c_uint, + abs_timeout: *const crate::timespec, + ) -> ssize_t; + #[link_name = "__mq_timedsend50"] + pub fn mq_timedsend( + mqd: crate::mqd_t, + msg_ptr: *const c_char, + msg_len: size_t, + msg_prio: c_uint, + abs_timeout: *const crate::timespec, + ) -> c_int; + pub fn mq_unlink(name: *const c_char) -> c_int; + pub fn ptrace(request: c_int, pid: crate::pid_t, addr: *mut c_void, data: c_int) -> c_int; + pub fn utrace(label: *const c_char, addr: *mut c_void, len: size_t) -> c_int; + pub fn pthread_getname_np(t: crate::pthread_t, name: *mut c_char, len: size_t) -> c_int; + pub fn pthread_setname_np( + t: crate::pthread_t, + name: *const c_char, + arg: *const c_void, + ) -> c_int; + pub fn pthread_attr_get_np(thread: crate::pthread_t, attr: *mut crate::pthread_attr_t) + -> c_int; + pub fn pthread_getattr_np(native: crate::pthread_t, attr: *mut crate::pthread_attr_t) -> c_int; + pub fn pthread_attr_getguardsize( + attr: *const crate::pthread_attr_t, + guardsize: *mut size_t, + ) -> c_int; + pub fn pthread_attr_setguardsize(attr: *mut crate::pthread_attr_t, guardsize: size_t) -> c_int; + pub fn pthread_attr_getstack( + attr: *const crate::pthread_attr_t, + stackaddr: *mut *mut c_void, + stacksize: *mut size_t, + ) -> c_int; + pub fn pthread_getaffinity_np( + thread: crate::pthread_t, + size: size_t, + set: *mut cpuset_t, + ) -> c_int; + pub fn pthread_setaffinity_np( + thread: crate::pthread_t, + size: size_t, + set: *mut cpuset_t, + ) -> c_int; + + pub fn _cpuset_create() -> *mut cpuset_t; + pub fn _cpuset_destroy(set: *mut cpuset_t); + pub fn _cpuset_clr(cpu: cpuid_t, set: *mut cpuset_t) -> c_int; + pub fn _cpuset_set(cpu: cpuid_t, set: *mut cpuset_t) -> c_int; + pub fn _cpuset_isset(cpu: cpuid_t, set: *const cpuset_t) -> c_int; + pub fn _cpuset_size(set: *const cpuset_t) -> size_t; + pub fn _cpuset_zero(set: *mut cpuset_t); + #[link_name = "__sigtimedwait50"] + pub fn sigtimedwait( + set: *const sigset_t, + info: *mut siginfo_t, + timeout: *const crate::timespec, + ) -> c_int; + pub fn sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> c_int; + + pub fn duplocale(base: crate::locale_t) -> crate::locale_t; + pub fn freelocale(loc: crate::locale_t); + pub fn localeconv_l(loc: crate::locale_t) -> *mut lconv; + pub fn newlocale(mask: c_int, locale: *const c_char, base: crate::locale_t) -> crate::locale_t; + #[link_name = "__settimeofday50"] + pub fn settimeofday(tv: *const crate::timeval, tz: *const c_void) -> c_int; + + pub fn dup3(src: c_int, dst: c_int, flags: c_int) -> c_int; + + pub fn kqueue1(flags: c_int) -> c_int; + + pub fn _lwp_self() -> lwpid_t; + pub fn memmem( + haystack: *const c_void, + haystacklen: size_t, + needle: *const c_void, + needlelen: size_t, + ) -> *mut c_void; + + // link.h + + pub fn dl_iterate_phdr( + callback: Option< + unsafe extern "C" fn(info: *mut dl_phdr_info, size: usize, data: *mut c_void) -> c_int, + >, + data: *mut c_void, + ) -> c_int; + + // dlfcn.h + + pub fn _dlauxinfo() -> *mut c_void; + + pub fn iconv_open(tocode: *const c_char, fromcode: *const c_char) -> iconv_t; + pub fn iconv( + cd: iconv_t, + inbuf: *mut *mut c_char, + inbytesleft: *mut size_t, + outbuf: *mut *mut c_char, + outbytesleft: *mut size_t, + ) -> size_t; + pub fn iconv_close(cd: iconv_t) -> c_int; + + pub fn timer_create( + clockid: crate::clockid_t, + sevp: *mut crate::sigevent, + timerid: *mut crate::timer_t, + ) -> c_int; + pub fn timer_delete(timerid: crate::timer_t) -> c_int; + pub fn timer_getoverrun(timerid: crate::timer_t) -> c_int; + #[link_name = "__timer_gettime50"] + pub fn timer_gettime(timerid: crate::timer_t, curr_value: *mut crate::itimerspec) -> c_int; + #[link_name = "__timer_settime50"] + pub fn timer_settime( + timerid: crate::timer_t, + flags: c_int, + new_value: *const crate::itimerspec, + old_value: *mut crate::itimerspec, + ) -> c_int; + pub fn dlvsym( + handle: *mut c_void, + symbol: *const c_char, + version: *const c_char, + ) -> *mut c_void; + + // Added in `NetBSD` 7.0 + pub fn explicit_memset(b: *mut c_void, c: c_int, len: size_t); + pub fn consttime_memequal(a: *const c_void, b: *const c_void, len: size_t) -> c_int; + + pub fn setproctitle(fmt: *const c_char, ...); + pub fn mremap( + oldp: *mut c_void, + oldsize: size_t, + newp: *mut c_void, + newsize: size_t, + flags: c_int, + ) -> *mut c_void; + + #[link_name = "__sched_rr_get_interval50"] + pub fn sched_rr_get_interval(pid: crate::pid_t, t: *mut crate::timespec) -> c_int; + pub fn sched_setparam(pid: crate::pid_t, param: *const crate::sched_param) -> c_int; + pub fn sched_getparam(pid: crate::pid_t, param: *mut crate::sched_param) -> c_int; + pub fn sched_getscheduler(pid: crate::pid_t) -> c_int; + pub fn sched_setscheduler( + pid: crate::pid_t, + policy: c_int, + param: *const crate::sched_param, + ) -> c_int; + + #[link_name = "__pollts50"] + pub fn pollts( + fds: *mut crate::pollfd, + nfds: crate::nfds_t, + ts: *const crate::timespec, + sigmask: *const crate::sigset_t, + ) -> c_int; + pub fn getrandom(buf: *mut c_void, buflen: size_t, flags: c_uint) -> ssize_t; + + pub fn reboot(mode: c_int, bootstr: *mut c_char) -> c_int; + + #[link_name = "___lwp_park60"] + pub fn _lwp_park( + clock: crate::clockid_t, + flags: c_int, + ts: *const crate::timespec, + unpark: crate::lwpid_t, + hint: *const c_void, + unparkhint: *mut c_void, + ) -> c_int; + pub fn _lwp_unpark(lwp: crate::lwpid_t, hint: *const c_void) -> c_int; + pub fn _lwp_unpark_all( + targets: *const crate::lwpid_t, + ntargets: size_t, + hint: *const c_void, + ) -> c_int; + pub fn getmntinfo(mntbufp: *mut *mut crate::statvfs, flags: c_int) -> c_int; + pub fn getvfsstat(buf: *mut crate::statvfs, bufsize: size_t, flags: c_int) -> c_int; + + pub fn eventfd(val: c_uint, flags: c_int) -> c_int; + pub fn eventfd_read(efd: c_int, valp: *mut eventfd_t) -> c_int; + pub fn eventfd_write(efd: c_int, val: eventfd_t) -> c_int; + + // Added in `NetBSD` 10.0 + pub fn timerfd_create(clockid: crate::clockid_t, flags: c_int) -> c_int; + pub fn timerfd_gettime(fd: c_int, curr_value: *mut crate::itimerspec) -> c_int; + pub fn timerfd_settime( + fd: c_int, + flags: c_int, + new_value: *const crate::itimerspec, + old_value: *mut crate::itimerspec, + ) -> c_int; + + pub fn qsort_r( + base: *mut c_void, + num: size_t, + size: size_t, + compar: Option c_int>, + arg: *mut c_void, + ); +} + +#[link(name = "rt")] +extern "C" { + pub fn aio_read(aiocbp: *mut aiocb) -> c_int; + pub fn aio_write(aiocbp: *mut aiocb) -> c_int; + pub fn aio_fsync(op: c_int, aiocbp: *mut aiocb) -> c_int; + pub fn aio_error(aiocbp: *const aiocb) -> c_int; + pub fn aio_return(aiocbp: *mut aiocb) -> ssize_t; + #[link_name = "__aio_suspend50"] + pub fn aio_suspend( + aiocb_list: *const *const aiocb, + nitems: c_int, + timeout: *const crate::timespec, + ) -> c_int; + pub fn aio_cancel(fd: c_int, aiocbp: *mut aiocb) -> c_int; + pub fn lio_listio( + mode: c_int, + aiocb_list: *const *mut aiocb, + nitems: c_int, + sevp: *mut sigevent, + ) -> c_int; +} + +#[link(name = "util")] +extern "C" { + #[link_name = "__getpwent_r50"] + pub fn getpwent_r( + pwd: *mut crate::passwd, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::passwd, + ) -> c_int; + pub fn getgrent_r( + grp: *mut crate::group, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::group, + ) -> c_int; + + pub fn efopen(p: *const c_char, m: *const c_char) -> crate::FILE; + pub fn emalloc(n: size_t) -> *mut c_void; + pub fn ecalloc(n: size_t, c: size_t) -> *mut c_void; + pub fn erealloc(p: *mut c_void, n: size_t) -> *mut c_void; + pub fn ereallocarr(p: *mut c_void, n: size_t, s: size_t); + pub fn estrdup(s: *const c_char) -> *mut c_char; + pub fn estrndup(s: *const c_char, len: size_t) -> *mut c_char; + pub fn estrlcpy(dst: *mut c_char, src: *const c_char, len: size_t) -> size_t; + pub fn estrlcat(dst: *mut c_char, src: *const c_char, len: size_t) -> size_t; + pub fn estrtoi( + nptr: *const c_char, + base: c_int, + lo: crate::intmax_t, + hi: crate::intmax_t, + ) -> crate::intmax_t; + pub fn estrtou( + nptr: *const c_char, + base: c_int, + lo: crate::uintmax_t, + hi: crate::uintmax_t, + ) -> crate::uintmax_t; + pub fn easprintf(string: *mut *mut c_char, fmt: *const c_char, ...) -> c_int; + pub fn evasprintf(string: *mut *mut c_char, fmt: *const c_char, ...) -> c_int; + pub fn esetfunc( + cb: Option, + ) -> Option; + pub fn secure_path(path: *const c_char) -> c_int; + pub fn snprintb(buf: *mut c_char, buflen: size_t, fmt: *const c_char, val: u64) -> c_int; + pub fn snprintb_m( + buf: *mut c_char, + buflen: size_t, + fmt: *const c_char, + val: u64, + max: size_t, + ) -> c_int; + + pub fn getbootfile() -> *const c_char; + pub fn getbyteorder() -> c_int; + pub fn getdiskrawname(buf: *mut c_char, buflen: size_t, name: *const c_char) -> *const c_char; + pub fn getdiskcookedname( + buf: *mut c_char, + buflen: size_t, + name: *const c_char, + ) -> *const c_char; + pub fn getfsspecname(buf: *mut c_char, buflen: size_t, spec: *const c_char) -> *const c_char; + + pub fn strpct( + buf: *mut c_char, + bufsiz: size_t, + numerator: crate::uintmax_t, + denominator: crate::uintmax_t, + precision: size_t, + ) -> *mut c_char; + pub fn strspct( + buf: *mut c_char, + bufsiz: size_t, + numerator: crate::intmax_t, + denominator: crate::intmax_t, + precision: size_t, + ) -> *mut c_char; + #[link_name = "__login50"] + pub fn login(ut: *const crate::utmp); + #[link_name = "__loginx50"] + pub fn loginx(ut: *const crate::utmpx); + pub fn logout(line: *const c_char); + pub fn logoutx(line: *const c_char, status: c_int, tpe: c_int); + pub fn logwtmp(line: *const c_char, name: *const c_char, host: *const c_char); + pub fn logwtmpx( + line: *const c_char, + name: *const c_char, + host: *const c_char, + status: c_int, + tpe: c_int, + ); + + pub fn getxattr( + path: *const c_char, + name: *const c_char, + value: *mut c_void, + size: size_t, + ) -> ssize_t; + pub fn lgetxattr( + path: *const c_char, + name: *const c_char, + value: *mut c_void, + size: size_t, + ) -> ssize_t; + pub fn fgetxattr( + filedes: c_int, + name: *const c_char, + value: *mut c_void, + size: size_t, + ) -> ssize_t; + pub fn setxattr( + path: *const c_char, + name: *const c_char, + value: *const c_void, + size: size_t, + ) -> c_int; + pub fn lsetxattr( + path: *const c_char, + name: *const c_char, + value: *const c_void, + size: size_t, + ) -> c_int; + pub fn fsetxattr( + filedes: c_int, + name: *const c_char, + value: *const c_void, + size: size_t, + flags: c_int, + ) -> c_int; + pub fn listxattr(path: *const c_char, list: *mut c_char, size: size_t) -> ssize_t; + pub fn llistxattr(path: *const c_char, list: *mut c_char, size: size_t) -> ssize_t; + pub fn flistxattr(filedes: c_int, list: *mut c_char, size: size_t) -> ssize_t; + pub fn removexattr(path: *const c_char, name: *const c_char) -> c_int; + pub fn lremovexattr(path: *const c_char, name: *const c_char) -> c_int; + pub fn fremovexattr(fd: c_int, path: *const c_char, name: *const c_char) -> c_int; + + pub fn string_to_flags( + string_p: *mut *mut c_char, + setp: *mut c_ulong, + clrp: *mut c_ulong, + ) -> c_int; + pub fn flags_to_string(flags: c_ulong, def: *const c_char) -> c_int; + + pub fn kinfo_getvmmap(pid: crate::pid_t, cntp: *mut size_t) -> *mut kinfo_vmentry; +} + +#[link(name = "execinfo")] +extern "C" { + pub fn backtrace(addrlist: *mut *mut c_void, len: size_t) -> size_t; + pub fn backtrace_symbols(addrlist: *const *mut c_void, len: size_t) -> *mut *mut c_char; + pub fn backtrace_symbols_fd(addrlist: *const *mut c_void, len: size_t, fd: c_int) -> c_int; + pub fn backtrace_symbols_fmt( + addrlist: *const *mut c_void, + len: size_t, + fmt: *const c_char, + ) -> *mut *mut c_char; + pub fn backtrace_symbols_fd_fmt( + addrlist: *const *mut c_void, + len: size_t, + fd: c_int, + fmt: *const c_char, + ) -> c_int; +} + +cfg_if! { + if #[cfg(target_arch = "aarch64")] { + mod aarch64; + pub use self::aarch64::*; + } else if #[cfg(target_arch = "arm")] { + mod arm; + pub use self::arm::*; + } else if #[cfg(target_arch = "powerpc")] { + mod powerpc; + pub use self::powerpc::*; + } else if #[cfg(target_arch = "sparc64")] { + mod sparc64; + pub use self::sparc64::*; + } else if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } else if #[cfg(target_arch = "x86")] { + mod x86; + pub use self::x86::*; + } else if #[cfg(target_arch = "mips")] { + mod mips; + pub use self::mips::*; + } else if #[cfg(target_arch = "riscv64")] { + mod riscv64; + pub use self::riscv64::*; + } else { + // Unknown target_arch + } +} diff --git a/http/vendor/libc/src/unix/bsd/netbsdlike/netbsd/powerpc.rs b/http/vendor/libc/src/unix/bsd/netbsdlike/netbsd/powerpc.rs new file mode 100644 index 0000000..f8f2d56 --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/netbsdlike/netbsd/powerpc.rs @@ -0,0 +1,10 @@ +use crate::prelude::*; +use crate::PT_FIRSTMACH; + +pub type __cpu_simple_lock_nv_t = c_int; + +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; + +pub const PT_STEP: c_int = PT_FIRSTMACH + 0; +pub const PT_GETREGS: c_int = PT_FIRSTMACH + 1; +pub const PT_SETREGS: c_int = PT_FIRSTMACH + 2; diff --git a/http/vendor/libc/src/unix/bsd/netbsdlike/netbsd/riscv64.rs b/http/vendor/libc/src/unix/bsd/netbsdlike/netbsd/riscv64.rs new file mode 100644 index 0000000..05c0cd5 --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/netbsdlike/netbsd/riscv64.rs @@ -0,0 +1,97 @@ +use crate::prelude::*; +use crate::PT_FIRSTMACH; + +pub type __greg_t = u64; +pub type __cpu_simple_lock_nv_t = c_uint; +pub type __gregset_t = [__greg_t; _NGREG]; +pub type __fregset_t = [__fpreg; _NFREG]; + +s_no_extra_traits! { + pub union __fpreg { + pub u_u64: u64, + pub u_d: c_double, + } +} + +s! { + pub struct mcontext_t { + pub __gregs: __gregset_t, + pub __fregs: __fregset_t, + __spare: [crate::__greg_t; 7], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for __fpreg { + fn eq(&self, other: &__fpreg) -> bool { + unsafe { self.u_u64 == other.u_u64 || self.u_d == other.u_d } + } + } + impl Eq for __fpreg {} + impl hash::Hash for __fpreg { + fn hash(&self, state: &mut H) { + unsafe { + self.u_u64.hash(state); + } + } + } + } +} + +// gcc for riscv64 defines `BIGGEST_ALIGNMENT`, but it's mesured in bits. +pub(crate) const __BIGGEST_ALIGNMENT_IN_BITS__: usize = 128; +// `_ALIGNBYTES` is measured in, well, bytes. +pub(crate) const _ALIGNBYTES: usize = (__BIGGEST_ALIGNMENT_IN_BITS__ / 8) - 1; + +pub const PT_GETREGS: c_int = PT_FIRSTMACH + 0; +pub const PT_SETREGS: c_int = PT_FIRSTMACH + 1; +pub const PT_GETFPREGS: c_int = PT_FIRSTMACH + 2; +pub const PT_SETFPREGS: c_int = PT_FIRSTMACH + 3; + +pub const _NGREG: usize = 32; +pub const _NFREG: usize = 33; + +pub const _REG_X1: c_int = 0; +pub const _REG_X2: c_int = 1; +pub const _REG_X3: c_int = 2; +pub const _REG_X4: c_int = 3; +pub const _REG_X5: c_int = 4; +pub const _REG_X6: c_int = 5; +pub const _REG_X7: c_int = 6; +pub const _REG_X8: c_int = 7; +pub const _REG_X9: c_int = 8; +pub const _REG_X10: c_int = 9; +pub const _REG_X11: c_int = 10; +pub const _REG_X12: c_int = 11; +pub const _REG_X13: c_int = 12; +pub const _REG_X14: c_int = 13; +pub const _REG_X15: c_int = 14; +pub const _REG_X16: c_int = 15; +pub const _REG_X17: c_int = 16; +pub const _REG_X18: c_int = 17; +pub const _REG_X19: c_int = 18; +pub const _REG_X20: c_int = 19; +pub const _REG_X21: c_int = 20; +pub const _REG_X22: c_int = 21; +pub const _REG_X23: c_int = 22; +pub const _REG_X24: c_int = 23; +pub const _REG_X25: c_int = 24; +pub const _REG_X26: c_int = 25; +pub const _REG_X27: c_int = 26; +pub const _REG_X28: c_int = 27; +pub const _REG_X29: c_int = 28; +pub const _REG_X30: c_int = 29; +pub const _REG_X31: c_int = 30; +pub const _REG_PC: c_int = 31; + +pub const _REG_RA: c_int = _REG_X1; +pub const _REG_SP: c_int = _REG_X2; +pub const _REG_GP: c_int = _REG_X3; +pub const _REG_TP: c_int = _REG_X4; +pub const _REG_S0: c_int = _REG_X8; +pub const _REG_RV: c_int = _REG_X10; +pub const _REG_A0: c_int = _REG_X10; + +pub const _REG_F0: c_int = 0; +pub const _REG_FPCSR: c_int = 32; diff --git a/http/vendor/libc/src/unix/bsd/netbsdlike/netbsd/sparc64.rs b/http/vendor/libc/src/unix/bsd/netbsdlike/netbsd/sparc64.rs new file mode 100644 index 0000000..91622f7 --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/netbsdlike/netbsd/sparc64.rs @@ -0,0 +1,7 @@ +use crate::prelude::*; + +pub type __cpu_simple_lock_nv_t = c_uchar; + +// should be pub(crate), but that requires Rust 1.18.0 +#[doc(hidden)] +pub const _ALIGNBYTES: usize = 0xf; diff --git a/http/vendor/libc/src/unix/bsd/netbsdlike/netbsd/x86.rs b/http/vendor/libc/src/unix/bsd/netbsdlike/netbsd/x86.rs new file mode 100644 index 0000000..95f5576 --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/netbsdlike/netbsd/x86.rs @@ -0,0 +1,5 @@ +use crate::prelude::*; + +pub type __cpu_simple_lock_nv_t = c_uchar; + +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; diff --git a/http/vendor/libc/src/unix/bsd/netbsdlike/netbsd/x86_64.rs b/http/vendor/libc/src/unix/bsd/netbsdlike/netbsd/x86_64.rs new file mode 100644 index 0000000..801b326 --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/netbsdlike/netbsd/x86_64.rs @@ -0,0 +1,59 @@ +use crate::prelude::*; +use crate::PT_FIRSTMACH; + +pub type c___greg_t = u64; +pub type __cpu_simple_lock_nv_t = c_uchar; + +// FIXME(alignment): Type is `__aligned(8)` +type __fpregset_t = [c_char; 512]; + +s! { + pub struct mcontext_t { + pub __gregs: [c___greg_t; 26], + pub _mc_tlsbase: c___greg_t, + pub __fpregs: __fpregset_t, + } + + pub struct ucontext_t { + pub uc_flags: c_uint, + pub uc_link: *mut crate::ucontext_t, + pub uc_sigmask: crate::sigset_t, + pub uc_stack: crate::stack_t, + pub uc_mcontext: crate::mcontext_t, + } +} + +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; + +pub const PT_STEP: c_int = PT_FIRSTMACH + 0; +pub const PT_GETREGS: c_int = PT_FIRSTMACH + 1; +pub const PT_SETREGS: c_int = PT_FIRSTMACH + 2; +pub const PT_GETFPREGS: c_int = PT_FIRSTMACH + 3; +pub const PT_SETFPREGS: c_int = PT_FIRSTMACH + 4; + +pub const _REG_RDI: c_int = 0; +pub const _REG_RSI: c_int = 1; +pub const _REG_RDX: c_int = 2; +pub const _REG_RCX: c_int = 3; +pub const _REG_R8: c_int = 4; +pub const _REG_R9: c_int = 5; +pub const _REG_R10: c_int = 6; +pub const _REG_R11: c_int = 7; +pub const _REG_R12: c_int = 8; +pub const _REG_R13: c_int = 9; +pub const _REG_R14: c_int = 10; +pub const _REG_R15: c_int = 11; +pub const _REG_RBP: c_int = 12; +pub const _REG_RBX: c_int = 13; +pub const _REG_RAX: c_int = 14; +pub const _REG_GS: c_int = 15; +pub const _REG_FS: c_int = 16; +pub const _REG_ES: c_int = 17; +pub const _REG_DS: c_int = 18; +pub const _REG_TRAPNO: c_int = 19; +pub const _REG_ERR: c_int = 20; +pub const _REG_RIP: c_int = 21; +pub const _REG_CS: c_int = 22; +pub const _REG_RFLAGS: c_int = 23; +pub const _REG_RSP: c_int = 24; +pub const _REG_SS: c_int = 25; diff --git a/http/vendor/libc/src/unix/bsd/netbsdlike/openbsd/aarch64.rs b/http/vendor/libc/src/unix/bsd/netbsdlike/openbsd/aarch64.rs new file mode 100644 index 0000000..13142ea --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/netbsdlike/openbsd/aarch64.rs @@ -0,0 +1,20 @@ +use crate::prelude::*; + +pub type ucontext_t = sigcontext; + +s! { + pub struct sigcontext { + __sc_unused: Padding, + pub sc_mask: c_int, + pub sc_sp: c_ulong, + pub sc_lr: c_ulong, + pub sc_elr: c_ulong, + pub sc_spsr: c_ulong, + pub sc_x: [c_ulong; 30], + pub sc_cookie: c_long, + } +} + +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; + +pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/http/vendor/libc/src/unix/bsd/netbsdlike/openbsd/arm.rs b/http/vendor/libc/src/unix/bsd/netbsdlike/openbsd/arm.rs new file mode 100644 index 0000000..8b3f721 --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/netbsdlike/openbsd/arm.rs @@ -0,0 +1,5 @@ +use crate::prelude::*; + +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; + +pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/http/vendor/libc/src/unix/bsd/netbsdlike/openbsd/mips64.rs b/http/vendor/libc/src/unix/bsd/netbsdlike/openbsd/mips64.rs new file mode 100644 index 0000000..162ceda --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/netbsdlike/openbsd/mips64.rs @@ -0,0 +1,4 @@ +#[doc(hidden)] +pub const _ALIGNBYTES: usize = 7; + +pub const _MAX_PAGE_SHIFT: u32 = 14; diff --git a/http/vendor/libc/src/unix/bsd/netbsdlike/openbsd/mod.rs b/http/vendor/libc/src/unix/bsd/netbsdlike/openbsd/mod.rs new file mode 100644 index 0000000..b6e70f9 --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -0,0 +1,2105 @@ +use crate::prelude::*; +use crate::unix::bsd::O_SYNC; +use crate::{ + cmsghdr, + off_t, +}; + +pub type clock_t = i64; +pub type suseconds_t = c_long; +pub type dev_t = i32; +pub type sigset_t = c_uint; +pub type blksize_t = i32; +pub type fsblkcnt_t = u64; +pub type fsfilcnt_t = u64; +pub type idtype_t = c_uint; +pub type pthread_attr_t = *mut c_void; +pub type pthread_mutex_t = *mut c_void; +pub type pthread_mutexattr_t = *mut c_void; +pub type pthread_cond_t = *mut c_void; +pub type pthread_condattr_t = *mut c_void; +pub type pthread_rwlock_t = *mut c_void; +pub type pthread_rwlockattr_t = *mut c_void; +pub type pthread_spinlock_t = crate::uintptr_t; +pub type caddr_t = *mut c_char; + +// elf.h + +pub type Elf32_Addr = u32; +pub type Elf32_Half = u16; +pub type Elf32_Lword = u64; +pub type Elf32_Off = u32; +pub type Elf32_Sword = i32; +pub type Elf32_Word = u32; + +pub type Elf64_Addr = u64; +pub type Elf64_Half = u16; +pub type Elf64_Lword = u64; +pub type Elf64_Off = u64; +pub type Elf64_Sword = i32; +pub type Elf64_Sxword = i64; +pub type Elf64_Word = u32; +pub type Elf64_Xword = u64; + +// search.h + +pub type ENTRY = entry; +pub type ACTION = c_uint; + +// spawn.h +pub type posix_spawnattr_t = *mut c_void; +pub type posix_spawn_file_actions_t = *mut c_void; + +cfg_if! { + if #[cfg(target_pointer_width = "64")] { + type Elf_Addr = Elf64_Addr; + type Elf_Half = Elf64_Half; + type Elf_Phdr = Elf64_Phdr; + } else if #[cfg(target_pointer_width = "32")] { + type Elf_Addr = Elf32_Addr; + type Elf_Half = Elf32_Half; + type Elf_Phdr = Elf32_Phdr; + } +} + +s! { + pub struct ip_mreqn { + pub imr_multiaddr: in_addr, + pub imr_address: in_addr, + pub imr_ifindex: c_int, + } + + pub struct glob_t { + pub gl_pathc: size_t, + pub gl_matchc: size_t, + pub gl_offs: size_t, + pub gl_flags: c_int, + pub gl_pathv: *mut *mut c_char, + __unused1: Padding<*mut c_void>, + __unused2: Padding<*mut c_void>, + __unused3: Padding<*mut c_void>, + __unused4: Padding<*mut c_void>, + __unused5: Padding<*mut c_void>, + __unused6: Padding<*mut c_void>, + __unused7: Padding<*mut c_void>, + } + + pub struct tm { + pub tm_sec: c_int, + pub tm_min: c_int, + pub tm_hour: c_int, + pub tm_mday: c_int, + pub tm_mon: c_int, + pub tm_year: c_int, + pub tm_wday: c_int, + pub tm_yday: c_int, + pub tm_isdst: c_int, + pub tm_gmtoff: c_long, + pub tm_zone: *const c_char, + } + + pub struct lconv { + pub decimal_point: *mut c_char, + pub thousands_sep: *mut c_char, + pub grouping: *mut c_char, + pub int_curr_symbol: *mut c_char, + pub currency_symbol: *mut c_char, + pub mon_decimal_point: *mut c_char, + pub mon_thousands_sep: *mut c_char, + pub mon_grouping: *mut c_char, + pub positive_sign: *mut c_char, + pub negative_sign: *mut c_char, + pub int_frac_digits: c_char, + pub frac_digits: c_char, + pub p_cs_precedes: c_char, + pub p_sep_by_space: c_char, + pub n_cs_precedes: c_char, + pub n_sep_by_space: c_char, + pub p_sign_posn: c_char, + pub n_sign_posn: c_char, + pub int_p_cs_precedes: c_char, + pub int_p_sep_by_space: c_char, + pub int_n_cs_precedes: c_char, + pub int_n_sep_by_space: c_char, + pub int_p_sign_posn: c_char, + pub int_n_sign_posn: c_char, + } + + pub struct ufs_args { + pub fspec: *mut c_char, + pub export_info: export_args, + } + + pub struct mfs_args { + pub fspec: *mut c_char, + pub export_info: export_args, + // https://github.com/openbsd/src/blob/HEAD/sys/sys/types.h#L134 + pub base: *mut c_char, + pub size: c_ulong, + } + + pub struct iso_args { + pub fspec: *mut c_char, + pub export_info: export_args, + pub flags: c_int, + pub sess: c_int, + } + + pub struct nfs_args { + pub version: c_int, + pub addr: *mut crate::sockaddr, + pub addrlen: c_int, + pub sotype: c_int, + pub proto: c_int, + pub fh: *mut c_uchar, + pub fhsize: c_int, + pub flags: c_int, + pub wsize: c_int, + pub rsize: c_int, + pub readdirsize: c_int, + pub timeo: c_int, + pub retrans: c_int, + pub maxgrouplist: c_int, + pub readahead: c_int, + pub leaseterm: c_int, + pub deadthresh: c_int, + pub hostname: *mut c_char, + pub acregmin: c_int, + pub acregmax: c_int, + pub acdirmin: c_int, + pub acdirmax: c_int, + } + + pub struct msdosfs_args { + pub fspec: *mut c_char, + pub export_info: export_args, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub mask: crate::mode_t, + pub flags: c_int, + } + + pub struct ntfs_args { + pub fspec: *mut c_char, + pub export_info: export_args, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub mode: crate::mode_t, + pub flag: c_ulong, + } + + pub struct udf_args { + pub fspec: *mut c_char, + pub lastblock: u32, + } + + pub struct tmpfs_args { + pub ta_version: c_int, + pub ta_nodes_max: crate::ino_t, + pub ta_size_max: off_t, + pub ta_root_uid: crate::uid_t, + pub ta_root_gid: crate::gid_t, + pub ta_root_mode: crate::mode_t, + } + + pub struct fusefs_args { + pub name: *mut c_char, + pub fd: c_int, + pub max_read: c_int, + pub allow_other: c_int, + } + + pub struct xucred { + pub cr_uid: crate::uid_t, + pub cr_gid: crate::gid_t, + pub cr_ngroups: c_short, + //https://github.com/openbsd/src/blob/HEAD/sys/sys/syslimits.h#L44 + pub cr_groups: [crate::gid_t; 16], + } + + pub struct export_args { + pub ex_flags: c_int, + pub ex_root: crate::uid_t, + pub ex_anon: xucred, + pub ex_addr: *mut crate::sockaddr, + pub ex_addrlen: c_int, + pub ex_mask: *mut crate::sockaddr, + pub ex_masklen: c_int, + } + + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct in_addr { + pub s_addr: crate::in_addr_t, + } + + pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: crate::sa_family_t, + pub sin_port: crate::in_port_t, + pub sin_addr: crate::in_addr, + pub sin_zero: [i8; 8], + } + + pub struct splice { + pub sp_fd: c_int, + pub sp_max: off_t, + pub sp_idle: crate::timeval, + } + + pub struct kevent { + pub ident: crate::uintptr_t, + pub filter: c_short, + pub flags: c_ushort, + pub fflags: c_uint, + pub data: i64, + pub udata: *mut c_void, + } + + pub struct stat { + pub st_mode: crate::mode_t, + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + pub st_size: off_t, + pub st_blocks: crate::blkcnt_t, + pub st_blksize: crate::blksize_t, + pub st_flags: u32, + pub st_gen: u32, + pub st_birthtime: crate::time_t, + pub st_birthtime_nsec: c_long, + } + + pub struct statvfs { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_favail: crate::fsfilcnt_t, + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + } + + pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: crate::socklen_t, + pub ai_addr: *mut crate::sockaddr, + pub ai_canonname: *mut c_char, + pub ai_next: *mut crate::addrinfo, + } + + pub struct Dl_info { + pub dli_fname: *const c_char, + pub dli_fbase: *mut c_void, + pub dli_sname: *const c_char, + pub dli_saddr: *mut c_void, + } + + pub struct if_data { + pub ifi_type: c_uchar, + pub ifi_addrlen: c_uchar, + pub ifi_hdrlen: c_uchar, + pub ifi_link_state: c_uchar, + pub ifi_mtu: u32, + pub ifi_metric: u32, + pub ifi_rdomain: u32, + pub ifi_baudrate: u64, + pub ifi_ipackets: u64, + pub ifi_ierrors: u64, + pub ifi_opackets: u64, + pub ifi_oerrors: u64, + pub ifi_collisions: u64, + pub ifi_ibytes: u64, + pub ifi_obytes: u64, + pub ifi_imcasts: u64, + pub ifi_omcasts: u64, + pub ifi_iqdrops: u64, + pub ifi_oqdrops: u64, + pub ifi_noproto: u64, + pub ifi_capabilities: u32, + pub ifi_lastchange: crate::timeval, + } + + pub struct if_msghdr { + pub ifm_msglen: c_ushort, + pub ifm_version: c_uchar, + pub ifm_type: c_uchar, + pub ifm_hdrlen: c_ushort, + pub ifm_index: c_ushort, + pub ifm_tableid: c_ushort, + pub ifm_pad1: c_uchar, + pub ifm_pad2: c_uchar, + pub ifm_addrs: c_int, + pub ifm_flags: c_int, + pub ifm_xflags: c_int, + pub ifm_data: if_data, + } + + pub struct sockaddr_dl { + pub sdl_len: c_uchar, + pub sdl_family: c_uchar, + pub sdl_index: c_ushort, + pub sdl_type: c_uchar, + pub sdl_nlen: c_uchar, + pub sdl_alen: c_uchar, + pub sdl_slen: c_uchar, + pub sdl_data: [c_char; 24], + } + + pub struct sockpeercred { + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub pid: crate::pid_t, + } + + pub struct arphdr { + pub ar_hrd: u16, + pub ar_pro: u16, + pub ar_hln: u8, + pub ar_pln: u8, + pub ar_op: u16, + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: c_int, + pub shm_lpid: crate::pid_t, + pub shm_cpid: crate::pid_t, + pub shm_nattch: c_short, + pub shm_atime: crate::time_t, + __shm_atimensec: c_long, + pub shm_dtime: crate::time_t, + __shm_dtimensec: c_long, + pub shm_ctime: crate::time_t, + __shm_ctimensec: c_long, + pub shm_internal: *mut c_void, + } + + // elf.h + pub struct Elf32_Phdr { + pub p_type: Elf32_Word, + pub p_offset: Elf32_Off, + pub p_vaddr: Elf32_Addr, + pub p_paddr: Elf32_Addr, + pub p_filesz: Elf32_Word, + pub p_memsz: Elf32_Word, + pub p_flags: Elf32_Word, + pub p_align: Elf32_Word, + } + + pub struct Elf64_Phdr { + pub p_type: Elf64_Word, + pub p_flags: Elf64_Word, + pub p_offset: Elf64_Off, + pub p_vaddr: Elf64_Addr, + pub p_paddr: Elf64_Addr, + pub p_filesz: Elf64_Xword, + pub p_memsz: Elf64_Xword, + pub p_align: Elf64_Xword, + } + + // link.h + + pub struct dl_phdr_info { + pub dlpi_addr: Elf_Addr, + pub dlpi_name: *const c_char, + pub dlpi_phdr: *const Elf_Phdr, + pub dlpi_phnum: Elf_Half, + } + + // sys/sysctl.h + pub struct kinfo_proc { + pub p_forw: u64, + pub p_back: u64, + pub p_paddr: u64, + pub p_addr: u64, + pub p_fd: u64, + pub p_stats: u64, + pub p_limit: u64, + pub p_vmspace: u64, + pub p_sigacts: u64, + pub p_sess: u64, + pub p_tsess: u64, + pub p_ru: u64, + pub p_eflag: i32, + pub p_exitsig: i32, + pub p_flag: i32, + pub p_pid: i32, + pub p_ppid: i32, + pub p_sid: i32, + pub p__pgid: i32, + pub p_tpgid: i32, + pub p_uid: u32, + pub p_ruid: u32, + pub p_gid: u32, + pub p_rgid: u32, + pub p_groups: [u32; KI_NGROUPS as usize], + pub p_ngroups: i16, + pub p_jobc: i16, + pub p_tdev: u32, + pub p_estcpu: u32, + pub p_rtime_sec: u32, + pub p_rtime_usec: u32, + pub p_cpticks: i32, + pub p_pctcpu: u32, + pub p_swtime: u32, + pub p_slptime: u32, + pub p_schedflags: i32, + pub p_uticks: u64, + pub p_sticks: u64, + pub p_iticks: u64, + pub p_tracep: u64, + pub p_traceflag: i32, + pub p_holdcnt: i32, + pub p_siglist: i32, + pub p_sigmask: u32, + pub p_sigignore: u32, + pub p_sigcatch: u32, + pub p_stat: i8, + pub p_priority: u8, + pub p_usrpri: u8, + pub p_nice: u8, + pub p_xstat: u16, + pub p_spare: u16, + pub p_comm: [c_char; KI_MAXCOMLEN as usize], + pub p_wmesg: [c_char; KI_WMESGLEN as usize], + pub p_wchan: u64, + pub p_login: [c_char; KI_MAXLOGNAME as usize], + pub p_vm_rssize: i32, + pub p_vm_tsize: i32, + pub p_vm_dsize: i32, + pub p_vm_ssize: i32, + pub p_uvalid: i64, + pub p_ustart_sec: u64, + pub p_ustart_usec: u32, + pub p_uutime_sec: u32, + pub p_uutime_usec: u32, + pub p_ustime_sec: u32, + pub p_ustime_usec: u32, + pub p_uru_maxrss: u64, + pub p_uru_ixrss: u64, + pub p_uru_idrss: u64, + pub p_uru_isrss: u64, + pub p_uru_minflt: u64, + pub p_uru_majflt: u64, + pub p_uru_nswap: u64, + pub p_uru_inblock: u64, + pub p_uru_oublock: u64, + pub p_uru_msgsnd: u64, + pub p_uru_msgrcv: u64, + pub p_uru_nsignals: u64, + pub p_uru_nvcsw: u64, + pub p_uru_nivcsw: u64, + pub p_uctime_sec: u32, + pub p_uctime_usec: u32, + pub p_psflags: u32, + pub p_acflag: u32, + pub p_svuid: u32, + pub p_svgid: u32, + pub p_emul: [c_char; KI_EMULNAMELEN as usize], + pub p_rlim_rss_cur: u64, + pub p_cpuid: u64, + pub p_vm_map_size: u64, + pub p_tid: i32, + pub p_rtableid: u32, + pub p_pledge: u64, + pub p_name: [c_char; KI_MAXCOMLEN as usize], + } + + pub struct kinfo_file { + pub f_fileaddr: u64, + pub f_flag: u32, + pub f_iflags: u32, + pub f_type: u32, + pub f_count: u32, + pub f_msgcount: u32, + pub f_usecount: u32, + pub f_ucred: u64, + pub f_uid: u32, + pub f_gid: u32, + pub f_ops: u64, + pub f_offset: u64, + pub f_data: u64, + pub f_rxfer: u64, + pub f_rwfer: u64, + pub f_seek: u64, + pub f_rbytes: u64, + pub f_wbytes: u64, + pub v_un: u64, + pub v_type: u32, + pub v_tag: u32, + pub v_flag: u32, + pub va_rdev: u32, + pub v_data: u64, + pub v_mount: u64, + pub va_fileid: u64, + pub va_size: u64, + pub va_mode: u32, + pub va_fsid: u32, + pub f_mntonname: [c_char; KI_MNAMELEN as usize], + pub so_type: u32, + pub so_state: u32, + pub so_pcb: u64, + pub so_protocol: u32, + pub so_family: u32, + pub inp_ppcb: u64, + pub inp_lport: u32, + pub inp_laddru: [u32; 4], + pub inp_fport: u32, + pub inp_faddru: [u32; 4], + pub unp_conn: u64, + pub pipe_peer: u64, + pub pipe_state: u32, + pub kq_count: u32, + pub kq_state: u32, + __unused1: Padding, + pub p_pid: u32, + pub fd_fd: i32, + pub fd_ofileflags: u32, + pub p_uid: u32, + pub p_gid: u32, + pub p_tid: u32, + pub p_comm: [c_char; KI_MAXCOMLEN as usize], + pub inp_rtableid: u32, + pub so_splice: u64, + pub so_splicelen: i64, + pub so_rcv_cc: u64, + pub so_snd_cc: u64, + pub unp_refs: u64, + pub unp_nextref: u64, + pub unp_addr: u64, + pub unp_path: [c_char; KI_UNPPATHLEN as usize], + pub inp_proto: u32, + pub t_state: u32, + pub t_rcv_wnd: u64, + pub t_snd_wnd: u64, + pub t_snd_cwnd: u64, + pub va_nlink: u32, + } + + pub struct kinfo_vmentry { + pub kve_start: c_ulong, + pub kve_end: c_ulong, + pub kve_guard: c_ulong, + pub kve_fspace: c_ulong, + pub kve_fspace_augment: c_ulong, + pub kve_offset: u64, + pub kve_wired_count: c_int, + pub kve_etype: c_int, + pub kve_protection: c_int, + pub kve_max_protection: c_int, + pub kve_advice: c_int, + pub kve_inheritance: c_int, + pub kve_flags: u8, + } + + pub struct ptrace_state { + pub pe_report_event: c_int, + pub pe_other_pid: crate::pid_t, + pub pe_tid: crate::pid_t, + } + + pub struct ptrace_thread_state { + pub pts_tid: crate::pid_t, + pub pts_name: [c_char; PT_PTS_NAMELEN as usize], + } + + // search.h + pub struct entry { + pub key: *mut c_char, + pub data: *mut c_void, + } + + pub struct ifreq { + pub ifr_name: [c_char; crate::IFNAMSIZ], + pub ifr_ifru: __c_anonymous_ifr_ifru, + } + + pub struct tcp_info { + pub tcpi_state: u8, + pub __tcpi_ca_state: u8, + pub __tcpi_retransmits: u8, + pub __tcpi_probes: u8, + pub __tcpi_backoff: u8, + pub tcpi_options: u8, + pub tcpi_snd_wscale: u8, + pub tcpi_rcv_wscale: u8, + pub tcpi_rto: u32, + pub __tcpi_ato: u32, + pub tcpi_snd_mss: u32, + pub tcpi_rcv_mss: u32, + pub __tcpi_unacked: u32, + pub __tcpi_sacked: u32, + pub __tcpi_lost: u32, + pub __tcpi_retrans: u32, + pub __tcpi_fackets: u32, + pub tcpi_last_data_sent: u32, + pub tcpi_last_ack_sent: u32, + pub tcpi_last_data_recv: u32, + pub tcpi_last_ack_recv: u32, + pub __tcpi_pmtu: u32, + pub __tcpi_rcv_ssthresh: u32, + pub tcpi_rtt: u32, + pub tcpi_rttvar: u32, + pub tcpi_snd_ssthresh: u32, + pub tcpi_snd_cwnd: u32, + pub __tcpi_advmss: u32, + pub __tcpi_reordering: u32, + pub __tcpi_rcv_rtt: u32, + pub tcpi_rcv_space: u32, + pub tcpi_snd_wnd: u32, + pub tcpi_snd_nxt: u32, + pub tcpi_rcv_nxt: u32, + pub tcpi_toe_tid: u32, + pub tcpi_snd_rexmitpack: u32, + pub tcpi_rcv_ooopack: u32, + pub tcpi_snd_zerowin: u32, + pub tcpi_rttmin: u32, + pub tcpi_max_sndwnd: u32, + pub tcpi_rcv_adv: u32, + pub tcpi_rcv_up: u32, + pub tcpi_snd_una: u32, + pub tcpi_snd_up: u32, + pub tcpi_snd_wl1: u32, + pub tcpi_snd_wl2: u32, + pub tcpi_snd_max: u32, + pub tcpi_ts_recent: u32, + pub tcpi_ts_recent_age: u32, + pub tcpi_rfbuf_cnt: u32, + pub tcpi_rfbuf_ts: u32, + pub tcpi_so_rcv_sb_cc: u32, + pub tcpi_so_rcv_sb_hiwat: u32, + pub tcpi_so_rcv_sb_lowat: u32, + pub tcpi_so_rcv_sb_wat: u32, + pub tcpi_so_snd_sb_cc: u32, + pub tcpi_so_snd_sb_hiwat: u32, + pub tcpi_so_snd_sb_lowat: u32, + pub tcpi_so_snd_sb_wat: u32, + } + + pub struct dirent { + pub d_fileno: crate::ino_t, + pub d_off: off_t, + pub d_reclen: u16, + pub d_type: u8, + pub d_namlen: u8, + __d_padding: Padding<[u8; 4]>, + pub d_name: [c_char; 256], + } + + pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: crate::sa_family_t, + __ss_pad1: Padding<[u8; 6]>, + __ss_pad2: Padding, + __ss_pad3: Padding<[u8; 240]>, + } + + pub struct siginfo_t { + pub si_signo: c_int, + pub si_code: c_int, + pub si_errno: c_int, + pub si_addr: *mut c_char, + #[cfg(target_pointer_width = "32")] + __pad: Padding<[u8; 112]>, + #[cfg(target_pointer_width = "64")] + __pad: Padding<[u8; 108]>, + } + + pub struct lastlog { + ll_time: crate::time_t, + ll_line: [c_char; UT_LINESIZE], + ll_host: [c_char; UT_HOSTSIZE], + } + + pub struct utmp { + pub ut_line: [c_char; UT_LINESIZE], + pub ut_name: [c_char; UT_NAMESIZE], + pub ut_host: [c_char; UT_HOSTSIZE], + pub ut_time: crate::time_t, + } + + pub struct statfs { + pub f_flags: u32, + pub f_bsize: u32, + pub f_iosize: u32, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: i64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: i64, + pub f_syncwrites: u64, + pub f_syncreads: u64, + pub f_asyncwrites: u64, + pub f_asyncreads: u64, + pub f_fsid: crate::fsid_t, + pub f_namemax: u32, + pub f_owner: crate::uid_t, + pub f_ctime: u64, + pub f_fstypename: [c_char; 16], + pub f_mntonname: [c_char; 90], + pub f_mntfromname: [c_char; 90], + pub f_mntfromspec: [c_char; 90], + pub mount_info: mount_info, + } +} + +s_no_extra_traits! { + pub union mount_info { + pub ufs_args: ufs_args, + pub mfs_args: mfs_args, + pub nfs_args: nfs_args, + pub iso_args: iso_args, + pub msdosfs_args: msdosfs_args, + pub ntfs_args: ntfs_args, + pub tmpfs_args: tmpfs_args, + align: [c_char; 160], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for mount_info { + fn eq(&self, other: &mount_info) -> bool { + unsafe { + self.align + .iter() + .zip(other.align.iter()) + .all(|(a, b)| a == b) + } + } + } + + impl Eq for mount_info {} + + impl hash::Hash for mount_info { + fn hash(&self, state: &mut H) { + unsafe { self.align.hash(state) }; + } + } + } +} + +impl siginfo_t { + pub unsafe fn si_addr(&self) -> *mut c_char { + self.si_addr + } + + pub unsafe fn si_code(&self) -> c_int { + self.si_code + } + + pub unsafe fn si_errno(&self) -> c_int { + self.si_errno + } + + pub unsafe fn si_pid(&self) -> crate::pid_t { + #[repr(C)] + struct siginfo_timer { + _si_signo: c_int, + _si_code: c_int, + _si_errno: c_int, + _pad: Padding<[c_int; SI_PAD]>, + _pid: crate::pid_t, + } + (*(self as *const siginfo_t).cast::())._pid + } + + pub unsafe fn si_uid(&self) -> crate::uid_t { + #[repr(C)] + struct siginfo_timer { + _si_signo: c_int, + _si_code: c_int, + _si_errno: c_int, + _pad: Padding<[c_int; SI_PAD]>, + _pid: crate::pid_t, + _uid: crate::uid_t, + } + (*(self as *const siginfo_t).cast::())._uid + } + + pub unsafe fn si_value(&self) -> crate::sigval { + #[repr(C)] + struct siginfo_timer { + _si_signo: c_int, + _si_code: c_int, + _si_errno: c_int, + _pad: Padding<[c_int; SI_PAD]>, + _pid: crate::pid_t, + _uid: crate::uid_t, + value: crate::sigval, + } + (*(self as *const siginfo_t).cast::()).value + } + + pub unsafe fn si_status(&self) -> c_int { + #[repr(C)] + struct siginfo_proc { + _si_signo: c_int, + _si_code: c_int, + _si_errno: c_int, + _pad: Padding<[c_int; SI_PAD]>, + _pid: crate::pid_t, + _uid: crate::uid_t, + _utime: crate::clock_t, + _stime: crate::clock_t, + _status: crate::c_int, + } + (*(self as *const siginfo_t as *const siginfo_proc))._status + } +} + +s_no_extra_traits! { + pub union __c_anonymous_ifr_ifru { + pub ifru_addr: crate::sockaddr, + pub ifru_dstaddr: crate::sockaddr, + pub ifru_broadaddr: crate::sockaddr, + pub ifru_flags: c_short, + pub ifru_metric: c_int, + pub ifru_vnetid: i64, + pub ifru_media: u64, + pub ifru_data: crate::caddr_t, + pub ifru_index: c_uint, + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for __c_anonymous_ifr_ifru { + fn eq(&self, other: &__c_anonymous_ifr_ifru) -> bool { + unsafe { + self.ifru_addr == other.ifru_addr + && self.ifru_dstaddr == other.ifru_dstaddr + && self.ifru_broadaddr == other.ifru_broadaddr + && self.ifru_flags == other.ifru_flags + && self.ifru_metric == other.ifru_metric + && self.ifru_vnetid == other.ifru_vnetid + && self.ifru_media == other.ifru_media + && self.ifru_data == other.ifru_data + && self.ifru_index == other.ifru_index + } + } + } + + impl Eq for __c_anonymous_ifr_ifru {} + + impl hash::Hash for __c_anonymous_ifr_ifru { + fn hash(&self, state: &mut H) { + unsafe { + self.ifru_addr.hash(state); + self.ifru_dstaddr.hash(state); + self.ifru_broadaddr.hash(state); + self.ifru_flags.hash(state); + self.ifru_metric.hash(state); + self.ifru_vnetid.hash(state); + self.ifru_media.hash(state); + self.ifru_data.hash(state); + self.ifru_index.hash(state); + } + } + } + } +} + +pub const UT_NAMESIZE: usize = 32; +pub const UT_LINESIZE: usize = 8; +pub const UT_HOSTSIZE: usize = 256; + +pub const O_CLOEXEC: c_int = 0x10000; +pub const O_DIRECTORY: c_int = 0x20000; +pub const O_RSYNC: c_int = O_SYNC; + +pub const MS_SYNC: c_int = 0x0002; +pub const MS_INVALIDATE: c_int = 0x0004; + +pub const POLLNORM: c_short = crate::POLLRDNORM; + +pub const ENOATTR: c_int = 83; +pub const EILSEQ: c_int = 84; +pub const EOVERFLOW: c_int = 87; +pub const ECANCELED: c_int = 88; +pub const EIDRM: c_int = 89; +pub const ENOMSG: c_int = 90; +pub const ENOTSUP: c_int = 91; +pub const EBADMSG: c_int = 92; +pub const ENOTRECOVERABLE: c_int = 93; +pub const EOWNERDEAD: c_int = 94; +pub const EPROTO: c_int = 95; +pub const ELAST: c_int = 95; + +pub const F_DUPFD_CLOEXEC: c_int = 10; + +pub const UTIME_OMIT: c_long = -1; +pub const UTIME_NOW: c_long = -2; + +pub const AT_FDCWD: c_int = -100; +pub const AT_EACCESS: c_int = 0x01; +pub const AT_SYMLINK_NOFOLLOW: c_int = 0x02; +pub const AT_SYMLINK_FOLLOW: c_int = 0x04; +pub const AT_REMOVEDIR: c_int = 0x08; + +pub const AT_NULL: c_int = 0; +pub const AT_IGNORE: c_int = 1; +pub const AT_PAGESZ: c_int = 6; +pub const AT_HWCAP: c_int = 25; +pub const AT_HWCAP2: c_int = 26; + +#[deprecated(since = "0.2.64", note = "Not stable across OS versions")] +pub const RLIM_NLIMITS: c_int = 9; + +pub const SO_TIMESTAMP: c_int = 0x0800; +pub const SO_SNDTIMEO: c_int = 0x1005; +pub const SO_RCVTIMEO: c_int = 0x1006; +pub const SO_BINDANY: c_int = 0x1000; +pub const SO_NETPROC: c_int = 0x1020; +pub const SO_RTABLE: c_int = 0x1021; +pub const SO_PEERCRED: c_int = 0x1022; +pub const SO_SPLICE: c_int = 0x1023; +pub const SO_DOMAIN: c_int = 0x1024; +pub const SO_PROTOCOL: c_int = 0x1025; + +// sys/netinet/in.h +// Protocols (RFC 1700) +// NOTE: These are in addition to the constants defined in src/unix/mod.rs + +// IPPROTO_IP defined in src/unix/mod.rs +/// Hop-by-hop option header +pub const IPPROTO_HOPOPTS: c_int = 0; +// IPPROTO_ICMP defined in src/unix/mod.rs +/// group mgmt protocol +pub const IPPROTO_IGMP: c_int = 2; +/// gateway^2 (deprecated) +pub const IPPROTO_GGP: c_int = 3; +/// for compatibility +pub const IPPROTO_IPIP: c_int = 4; +// IPPROTO_TCP defined in src/unix/mod.rs +/// exterior gateway protocol +pub const IPPROTO_EGP: c_int = 8; +/// pup +pub const IPPROTO_PUP: c_int = 12; +// IPPROTO_UDP defined in src/unix/mod.rs +/// xns idp +pub const IPPROTO_IDP: c_int = 22; +/// tp-4 w/ class negotiation +pub const IPPROTO_TP: c_int = 29; +// IPPROTO_IPV6 defined in src/unix/mod.rs +/// IP6 routing header +pub const IPPROTO_ROUTING: c_int = 43; +/// IP6 fragmentation header +pub const IPPROTO_FRAGMENT: c_int = 44; +/// resource reservation +pub const IPPROTO_RSVP: c_int = 46; +/// General Routing Encap. +pub const IPPROTO_GRE: c_int = 47; +/// IP6 Encap Sec. Payload +pub const IPPROTO_ESP: c_int = 50; +/// IP6 Auth Header +pub const IPPROTO_AH: c_int = 51; +/// IP Mobility RFC 2004 +pub const IPPROTO_MOBILE: c_int = 55; +// IPPROTO_ICMPV6 defined in src/unix/mod.rs +/// IP6 no next header +pub const IPPROTO_NONE: c_int = 59; +/// IP6 destination option +pub const IPPROTO_DSTOPTS: c_int = 60; +/// ISO cnlp +pub const IPPROTO_EON: c_int = 80; +/// Ethernet-in-IP +pub const IPPROTO_ETHERIP: c_int = 97; +/// encapsulation header +pub const IPPROTO_ENCAP: c_int = 98; +/// Protocol indep. multicast +pub const IPPROTO_PIM: c_int = 103; +/// IP Payload Comp. Protocol +pub const IPPROTO_IPCOMP: c_int = 108; +/// CARP +pub const IPPROTO_CARP: c_int = 112; +/// unicast MPLS packet +pub const IPPROTO_MPLS: c_int = 137; +/// PFSYNC +pub const IPPROTO_PFSYNC: c_int = 240; +pub const IPPROTO_MAX: c_int = 256; + +// Only used internally, so it can be outside the range of valid IP protocols +pub const IPPROTO_DIVERT: c_int = 258; + +pub const IP_RECVDSTADDR: c_int = 7; +pub const IP_SENDSRCADDR: c_int = IP_RECVDSTADDR; +pub const IP_RECVIF: c_int = 30; + +// sys/netinet/in.h +pub const TCP_MD5SIG: c_int = 0x04; +pub const TCP_NOPUSH: c_int = 0x10; + +pub const MSG_WAITFORONE: c_int = 0x1000; + +pub const AF_ECMA: c_int = 8; +pub const AF_ROUTE: c_int = 17; +pub const AF_ENCAP: c_int = 28; +pub const AF_SIP: c_int = 29; +pub const AF_KEY: c_int = 30; +pub const pseudo_AF_HDRCMPLT: c_int = 31; +pub const AF_BLUETOOTH: c_int = 32; +pub const AF_MPLS: c_int = 33; +pub const pseudo_AF_PFLOW: c_int = 34; +pub const pseudo_AF_PIPEX: c_int = 35; +pub const NET_RT_DUMP: c_int = 1; +pub const NET_RT_FLAGS: c_int = 2; +pub const NET_RT_IFLIST: c_int = 3; +pub const NET_RT_STATS: c_int = 4; +pub const NET_RT_TABLE: c_int = 5; +pub const NET_RT_IFNAMES: c_int = 6; +#[doc(hidden)] +#[deprecated( + since = "0.2.95", + note = "Possibly increasing over the releases and might not be so used in the field" +)] +pub const NET_RT_MAXID: c_int = 7; + +pub const IPV6_JOIN_GROUP: c_int = 12; +pub const IPV6_LEAVE_GROUP: c_int = 13; + +pub const PF_ROUTE: c_int = AF_ROUTE; +pub const PF_ECMA: c_int = AF_ECMA; +pub const PF_ENCAP: c_int = AF_ENCAP; +pub const PF_SIP: c_int = AF_SIP; +pub const PF_KEY: c_int = AF_KEY; +pub const PF_BPF: c_int = pseudo_AF_HDRCMPLT; +pub const PF_BLUETOOTH: c_int = AF_BLUETOOTH; +pub const PF_MPLS: c_int = AF_MPLS; +pub const PF_PFLOW: c_int = pseudo_AF_PFLOW; +pub const PF_PIPEX: c_int = pseudo_AF_PIPEX; + +pub const SCM_TIMESTAMP: c_int = 0x04; + +pub const O_DSYNC: c_int = 128; + +pub const MAP_RENAME: c_int = 0x0000; +pub const MAP_NORESERVE: c_int = 0x0000; +pub const MAP_HASSEMAPHORE: c_int = 0x0000; +pub const MAP_TRYFIXED: c_int = 0; + +pub const EIPSEC: c_int = 82; +pub const ENOMEDIUM: c_int = 85; +pub const EMEDIUMTYPE: c_int = 86; + +pub const EAI_BADFLAGS: c_int = -1; +pub const EAI_NONAME: c_int = -2; +pub const EAI_AGAIN: c_int = -3; +pub const EAI_FAIL: c_int = -4; +pub const EAI_NODATA: c_int = -5; +pub const EAI_FAMILY: c_int = -6; +pub const EAI_SOCKTYPE: c_int = -7; +pub const EAI_SERVICE: c_int = -8; +pub const EAI_MEMORY: c_int = -10; +pub const EAI_SYSTEM: c_int = -11; +pub const EAI_OVERFLOW: c_int = -14; + +pub const RUSAGE_THREAD: c_int = 1; + +pub const MAP_COPY: c_int = 0x0002; +pub const MAP_NOEXTEND: c_int = 0x0000; + +pub const _PC_LINK_MAX: c_int = 1; +pub const _PC_MAX_CANON: c_int = 2; +pub const _PC_MAX_INPUT: c_int = 3; +pub const _PC_NAME_MAX: c_int = 4; +pub const _PC_PATH_MAX: c_int = 5; +pub const _PC_PIPE_BUF: c_int = 6; +pub const _PC_CHOWN_RESTRICTED: c_int = 7; +pub const _PC_NO_TRUNC: c_int = 8; +pub const _PC_VDISABLE: c_int = 9; +pub const _PC_2_SYMLINKS: c_int = 10; +pub const _PC_ALLOC_SIZE_MIN: c_int = 11; +pub const _PC_ASYNC_IO: c_int = 12; +pub const _PC_FILESIZEBITS: c_int = 13; +pub const _PC_PRIO_IO: c_int = 14; +pub const _PC_REC_INCR_XFER_SIZE: c_int = 15; +pub const _PC_REC_MAX_XFER_SIZE: c_int = 16; +pub const _PC_REC_MIN_XFER_SIZE: c_int = 17; +pub const _PC_REC_XFER_ALIGN: c_int = 18; +pub const _PC_SYMLINK_MAX: c_int = 19; +pub const _PC_SYNC_IO: c_int = 20; +pub const _PC_TIMESTAMP_RESOLUTION: c_int = 21; + +pub const _CS_PATH: c_int = 1; + +pub const _SC_CLK_TCK: c_int = 3; +pub const _SC_SEM_NSEMS_MAX: c_int = 31; +pub const _SC_SEM_VALUE_MAX: c_int = 32; +pub const _SC_HOST_NAME_MAX: c_int = 33; +pub const _SC_MONOTONIC_CLOCK: c_int = 34; +pub const _SC_2_PBS: c_int = 35; +pub const _SC_2_PBS_ACCOUNTING: c_int = 36; +pub const _SC_2_PBS_CHECKPOINT: c_int = 37; +pub const _SC_2_PBS_LOCATE: c_int = 38; +pub const _SC_2_PBS_MESSAGE: c_int = 39; +pub const _SC_2_PBS_TRACK: c_int = 40; +pub const _SC_ADVISORY_INFO: c_int = 41; +pub const _SC_AIO_LISTIO_MAX: c_int = 42; +pub const _SC_AIO_MAX: c_int = 43; +pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 44; +pub const _SC_ASYNCHRONOUS_IO: c_int = 45; +pub const _SC_ATEXIT_MAX: c_int = 46; +pub const _SC_BARRIERS: c_int = 47; +pub const _SC_CLOCK_SELECTION: c_int = 48; +pub const _SC_CPUTIME: c_int = 49; +pub const _SC_DELAYTIMER_MAX: c_int = 50; +pub const _SC_IOV_MAX: c_int = 51; +pub const _SC_IPV6: c_int = 52; +pub const _SC_MAPPED_FILES: c_int = 53; +pub const _SC_MEMLOCK: c_int = 54; +pub const _SC_MEMLOCK_RANGE: c_int = 55; +pub const _SC_MEMORY_PROTECTION: c_int = 56; +pub const _SC_MESSAGE_PASSING: c_int = 57; +pub const _SC_MQ_OPEN_MAX: c_int = 58; +pub const _SC_MQ_PRIO_MAX: c_int = 59; +pub const _SC_PRIORITIZED_IO: c_int = 60; +pub const _SC_PRIORITY_SCHEDULING: c_int = 61; +pub const _SC_RAW_SOCKETS: c_int = 62; +pub const _SC_READER_WRITER_LOCKS: c_int = 63; +pub const _SC_REALTIME_SIGNALS: c_int = 64; +pub const _SC_REGEXP: c_int = 65; +pub const _SC_RTSIG_MAX: c_int = 66; +pub const _SC_SEMAPHORES: c_int = 67; +pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 68; +pub const _SC_SHELL: c_int = 69; +pub const _SC_SIGQUEUE_MAX: c_int = 70; +pub const _SC_SPAWN: c_int = 71; +pub const _SC_SPIN_LOCKS: c_int = 72; +pub const _SC_SPORADIC_SERVER: c_int = 73; +pub const _SC_SS_REPL_MAX: c_int = 74; +pub const _SC_SYNCHRONIZED_IO: c_int = 75; +pub const _SC_SYMLOOP_MAX: c_int = 76; +pub const _SC_THREAD_ATTR_STACKADDR: c_int = 77; +pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 78; +pub const _SC_THREAD_CPUTIME: c_int = 79; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 80; +pub const _SC_THREAD_KEYS_MAX: c_int = 81; +pub const _SC_THREAD_PRIO_INHERIT: c_int = 82; +pub const _SC_THREAD_PRIO_PROTECT: c_int = 83; +pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 84; +pub const _SC_THREAD_PROCESS_SHARED: c_int = 85; +pub const _SC_THREAD_ROBUST_PRIO_INHERIT: c_int = 86; +pub const _SC_THREAD_ROBUST_PRIO_PROTECT: c_int = 87; +pub const _SC_THREAD_SPORADIC_SERVER: c_int = 88; +pub const _SC_THREAD_STACK_MIN: c_int = 89; +pub const _SC_THREAD_THREADS_MAX: c_int = 90; +pub const _SC_THREADS: c_int = 91; +pub const _SC_TIMEOUTS: c_int = 92; +pub const _SC_TIMER_MAX: c_int = 93; +pub const _SC_TIMERS: c_int = 94; +pub const _SC_TRACE: c_int = 95; +pub const _SC_TRACE_EVENT_FILTER: c_int = 96; +pub const _SC_TRACE_EVENT_NAME_MAX: c_int = 97; +pub const _SC_TRACE_INHERIT: c_int = 98; +pub const _SC_TRACE_LOG: c_int = 99; +pub const _SC_GETGR_R_SIZE_MAX: c_int = 100; +pub const _SC_GETPW_R_SIZE_MAX: c_int = 101; +pub const _SC_LOGIN_NAME_MAX: c_int = 102; +pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 103; +pub const _SC_TRACE_NAME_MAX: c_int = 104; +pub const _SC_TRACE_SYS_MAX: c_int = 105; +pub const _SC_TRACE_USER_EVENT_MAX: c_int = 106; +pub const _SC_TTY_NAME_MAX: c_int = 107; +pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 108; +pub const _SC_V6_ILP32_OFF32: c_int = 109; +pub const _SC_V6_ILP32_OFFBIG: c_int = 110; +pub const _SC_V6_LP64_OFF64: c_int = 111; +pub const _SC_V6_LPBIG_OFFBIG: c_int = 112; +pub const _SC_V7_ILP32_OFF32: c_int = 113; +pub const _SC_V7_ILP32_OFFBIG: c_int = 114; +pub const _SC_V7_LP64_OFF64: c_int = 115; +pub const _SC_V7_LPBIG_OFFBIG: c_int = 116; +pub const _SC_XOPEN_CRYPT: c_int = 117; +pub const _SC_XOPEN_ENH_I18N: c_int = 118; +pub const _SC_XOPEN_LEGACY: c_int = 119; +pub const _SC_XOPEN_REALTIME: c_int = 120; +pub const _SC_XOPEN_REALTIME_THREADS: c_int = 121; +pub const _SC_XOPEN_STREAMS: c_int = 122; +pub const _SC_XOPEN_UNIX: c_int = 123; +pub const _SC_XOPEN_UUCP: c_int = 124; +pub const _SC_XOPEN_VERSION: c_int = 125; +pub const _SC_PHYS_PAGES: c_int = 500; +pub const _SC_AVPHYS_PAGES: c_int = 501; +pub const _SC_NPROCESSORS_CONF: c_int = 502; +pub const _SC_NPROCESSORS_ONLN: c_int = 503; + +pub const FD_SETSIZE: usize = 1024; + +pub const SCHED_FIFO: c_int = 1; +pub const SCHED_OTHER: c_int = 2; +pub const SCHED_RR: c_int = 3; + +pub const ST_NOSUID: c_ulong = 2; + +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = ptr::null_mut(); +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = ptr::null_mut(); +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = ptr::null_mut(); + +pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 1; +pub const PTHREAD_MUTEX_RECURSIVE: c_int = 2; +pub const PTHREAD_MUTEX_NORMAL: c_int = 3; +pub const PTHREAD_MUTEX_STRICT_NP: c_int = 4; +pub const PTHREAD_MUTEX_DEFAULT: c_int = PTHREAD_MUTEX_STRICT_NP; + +pub const EVFILT_READ: i16 = -1; +pub const EVFILT_WRITE: i16 = -2; +pub const EVFILT_AIO: i16 = -3; +pub const EVFILT_VNODE: i16 = -4; +pub const EVFILT_PROC: i16 = -5; +pub const EVFILT_SIGNAL: i16 = -6; +pub const EVFILT_TIMER: i16 = -7; +pub const EVFILT_DEVICE: i16 = -8; +pub const EVFILT_EXCEPT: i16 = -9; +pub const EVFILT_USER: i16 = -10; +pub const EV_ADD: u16 = 0x1; +pub const EV_DELETE: u16 = 0x2; +pub const EV_ENABLE: u16 = 0x4; +pub const EV_DISABLE: u16 = 0x8; +pub const EV_ONESHOT: u16 = 0x10; +pub const EV_CLEAR: u16 = 0x20; +pub const EV_RECEIPT: u16 = 0x40; +pub const EV_DISPATCH: u16 = 0x80; +pub const EV_FLAG1: u16 = 0x2000; +pub const EV_ERROR: u16 = 0x4000; +pub const EV_EOF: u16 = 0x8000; + +#[deprecated(since = "0.2.113", note = "Not stable across OS versions")] +pub const EV_SYSFLAGS: u16 = 0xf800; + +pub const NOTE_TRIGGER: u32 = 0x01000000; +pub const NOTE_FFNOP: u32 = 0x00000000; +pub const NOTE_FFAND: u32 = 0x40000000; +pub const NOTE_FFOR: u32 = 0x80000000; +pub const NOTE_FFCOPY: u32 = 0xc0000000; +pub const NOTE_FFCTRLMASK: u32 = 0xc0000000; +pub const NOTE_FFLAGSMASK: u32 = 0x00ffffff; +pub const NOTE_LOWAT: u32 = 0x00000001; +pub const NOTE_EOF: u32 = 0x00000002; +pub const NOTE_OOB: u32 = 0x00000004; +pub const NOTE_DELETE: u32 = 0x00000001; +pub const NOTE_WRITE: u32 = 0x00000002; +pub const NOTE_EXTEND: u32 = 0x00000004; +pub const NOTE_ATTRIB: u32 = 0x00000008; +pub const NOTE_LINK: u32 = 0x00000010; +pub const NOTE_RENAME: u32 = 0x00000020; +pub const NOTE_REVOKE: u32 = 0x00000040; +pub const NOTE_TRUNCATE: u32 = 0x00000080; +pub const NOTE_EXIT: u32 = 0x80000000; +pub const NOTE_FORK: u32 = 0x40000000; +pub const NOTE_EXEC: u32 = 0x20000000; +pub const NOTE_PDATAMASK: u32 = 0x000fffff; +pub const NOTE_PCTRLMASK: u32 = 0xf0000000; +pub const NOTE_TRACK: u32 = 0x00000001; +pub const NOTE_TRACKERR: u32 = 0x00000002; +pub const NOTE_CHILD: u32 = 0x00000004; +pub const NOTE_CHANGE: u32 = 0x00000001; + +pub const TMP_MAX: c_uint = 0x7fffffff; + +pub const AI_PASSIVE: c_int = 1; +pub const AI_CANONNAME: c_int = 2; +pub const AI_NUMERICHOST: c_int = 4; +pub const AI_EXT: c_int = 8; +pub const AI_NUMERICSERV: c_int = 16; +pub const AI_FQDN: c_int = 32; +pub const AI_ADDRCONFIG: c_int = 64; + +pub const NI_NUMERICHOST: c_int = 1; +pub const NI_NUMERICSERV: c_int = 2; +pub const NI_NOFQDN: c_int = 4; +pub const NI_NAMEREQD: c_int = 8; +pub const NI_DGRAM: c_int = 16; + +pub const NI_MAXHOST: size_t = 256; + +pub const RTLD_LOCAL: c_int = 0; + +pub const CTL_MAXNAME: c_int = 12; + +pub const CTLTYPE_NODE: c_int = 1; +pub const CTLTYPE_INT: c_int = 2; +pub const CTLTYPE_STRING: c_int = 3; +pub const CTLTYPE_QUAD: c_int = 4; +pub const CTLTYPE_STRUCT: c_int = 5; + +pub const CTL_UNSPEC: c_int = 0; +pub const CTL_KERN: c_int = 1; +pub const CTL_VM: c_int = 2; +pub const CTL_FS: c_int = 3; +pub const CTL_NET: c_int = 4; +pub const CTL_DEBUG: c_int = 5; +pub const CTL_HW: c_int = 6; +pub const CTL_MACHDEP: c_int = 7; +pub const CTL_DDB: c_int = 9; +pub const CTL_VFS: c_int = 10; +pub const CTL_MAXID: c_int = 11; + +pub const HW_NCPUONLINE: c_int = 25; + +pub const KERN_OSTYPE: c_int = 1; +pub const KERN_OSRELEASE: c_int = 2; +pub const KERN_OSREV: c_int = 3; +pub const KERN_VERSION: c_int = 4; +pub const KERN_MAXVNODES: c_int = 5; +pub const KERN_MAXPROC: c_int = 6; +pub const KERN_MAXFILES: c_int = 7; +pub const KERN_ARGMAX: c_int = 8; +pub const KERN_SECURELVL: c_int = 9; +pub const KERN_HOSTNAME: c_int = 10; +pub const KERN_HOSTID: c_int = 11; +pub const KERN_CLOCKRATE: c_int = 12; +pub const KERN_PROF: c_int = 16; +pub const KERN_POSIX1: c_int = 17; +pub const KERN_NGROUPS: c_int = 18; +pub const KERN_JOB_CONTROL: c_int = 19; +pub const KERN_SAVED_IDS: c_int = 20; +pub const KERN_BOOTTIME: c_int = 21; +pub const KERN_DOMAINNAME: c_int = 22; +pub const KERN_MAXPARTITIONS: c_int = 23; +pub const KERN_RAWPARTITION: c_int = 24; +pub const KERN_MAXTHREAD: c_int = 25; +pub const KERN_NTHREADS: c_int = 26; +pub const KERN_OSVERSION: c_int = 27; +pub const KERN_SOMAXCONN: c_int = 28; +pub const KERN_SOMINCONN: c_int = 29; +#[deprecated(since = "0.2.71", note = "Removed in OpenBSD 6.0")] +pub const KERN_USERMOUNT: c_int = 30; +pub const KERN_NOSUIDCOREDUMP: c_int = 32; +pub const KERN_FSYNC: c_int = 33; +pub const KERN_SYSVMSG: c_int = 34; +pub const KERN_SYSVSEM: c_int = 35; +pub const KERN_SYSVSHM: c_int = 36; +#[deprecated(since = "0.2.71", note = "Removed in OpenBSD 6.0")] +pub const KERN_ARND: c_int = 37; +pub const KERN_MSGBUFSIZE: c_int = 38; +pub const KERN_MALLOCSTATS: c_int = 39; +pub const KERN_CPTIME: c_int = 40; +pub const KERN_NCHSTATS: c_int = 41; +pub const KERN_FORKSTAT: c_int = 42; +pub const KERN_NSELCOLL: c_int = 43; +pub const KERN_TTY: c_int = 44; +pub const KERN_CCPU: c_int = 45; +pub const KERN_FSCALE: c_int = 46; +pub const KERN_NPROCS: c_int = 47; +pub const KERN_MSGBUF: c_int = 48; +pub const KERN_POOL: c_int = 49; +pub const KERN_STACKGAPRANDOM: c_int = 50; +pub const KERN_SYSVIPC_INFO: c_int = 51; +pub const KERN_SPLASSERT: c_int = 54; +pub const KERN_PROC_ARGS: c_int = 55; +pub const KERN_NFILES: c_int = 56; +pub const KERN_TTYCOUNT: c_int = 57; +pub const KERN_NUMVNODES: c_int = 58; +pub const KERN_MBSTAT: c_int = 59; +pub const KERN_SEMINFO: c_int = 61; +pub const KERN_SHMINFO: c_int = 62; +pub const KERN_INTRCNT: c_int = 63; +pub const KERN_WATCHDOG: c_int = 64; +pub const KERN_PROC: c_int = 66; +pub const KERN_MAXCLUSTERS: c_int = 67; +pub const KERN_EVCOUNT: c_int = 68; +pub const KERN_TIMECOUNTER: c_int = 69; +pub const KERN_MAXLOCKSPERUID: c_int = 70; +pub const KERN_CPTIME2: c_int = 71; +pub const KERN_CACHEPCT: c_int = 72; +pub const KERN_FILE: c_int = 73; +pub const KERN_CONSDEV: c_int = 75; +pub const KERN_NETLIVELOCKS: c_int = 76; +pub const KERN_POOL_DEBUG: c_int = 77; +pub const KERN_PROC_CWD: c_int = 78; +pub const KERN_PROC_NOBROADCASTKILL: c_int = 79; +pub const KERN_PROC_VMMAP: c_int = 80; +pub const KERN_GLOBAL_PTRACE: c_int = 81; +pub const KERN_CONSBUFSIZE: c_int = 82; +pub const KERN_CONSBUF: c_int = 83; +pub const KERN_AUDIO: c_int = 84; +pub const KERN_CPUSTATS: c_int = 85; +pub const KERN_PFSTATUS: c_int = 86; +pub const KERN_TIMEOUT_STATS: c_int = 87; +#[deprecated( + since = "0.2.95", + note = "Possibly increasing over the releases and might not be so used in the field" +)] +pub const KERN_MAXID: c_int = 88; + +pub const KERN_PROC_ALL: c_int = 0; +pub const KERN_PROC_PID: c_int = 1; +pub const KERN_PROC_PGRP: c_int = 2; +pub const KERN_PROC_SESSION: c_int = 3; +pub const KERN_PROC_TTY: c_int = 4; +pub const KERN_PROC_UID: c_int = 5; +pub const KERN_PROC_RUID: c_int = 6; +pub const KERN_PROC_KTHREAD: c_int = 7; +pub const KERN_PROC_SHOW_THREADS: c_int = 0x40000000; + +pub const KERN_SYSVIPC_MSG_INFO: c_int = 1; +pub const KERN_SYSVIPC_SEM_INFO: c_int = 2; +pub const KERN_SYSVIPC_SHM_INFO: c_int = 3; + +pub const KERN_PROC_ARGV: c_int = 1; +pub const KERN_PROC_NARGV: c_int = 2; +pub const KERN_PROC_ENV: c_int = 3; +pub const KERN_PROC_NENV: c_int = 4; + +pub const KI_NGROUPS: c_int = 16; +pub const KI_MAXCOMLEN: c_int = 24; +pub const KI_WMESGLEN: c_int = 8; +pub const KI_MAXLOGNAME: c_int = 32; +pub const KI_EMULNAMELEN: c_int = 8; + +pub const KVE_ET_OBJ: c_int = 0x00000001; +pub const KVE_ET_SUBMAP: c_int = 0x00000002; +pub const KVE_ET_COPYONWRITE: c_int = 0x00000004; +pub const KVE_ET_NEEDSCOPY: c_int = 0x00000008; +pub const KVE_ET_HOLE: c_int = 0x00000010; +pub const KVE_ET_NOFAULT: c_int = 0x00000020; +pub const KVE_ET_STACK: c_int = 0x00000040; +pub const KVE_ET_WC: c_int = 0x000000080; +pub const KVE_ET_CONCEAL: c_int = 0x000000100; +pub const KVE_ET_SYSCALL: c_int = 0x000000200; +pub const KVE_ET_FREEMAPPED: c_int = 0x000000800; + +pub const KVE_PROT_NONE: c_int = 0x00000000; +pub const KVE_PROT_READ: c_int = 0x00000001; +pub const KVE_PROT_WRITE: c_int = 0x00000002; +pub const KVE_PROT_EXEC: c_int = 0x00000004; + +pub const KVE_ADV_NORMAL: c_int = 0x00000000; +pub const KVE_ADV_RANDOM: c_int = 0x00000001; +pub const KVE_ADV_SEQUENTIAL: c_int = 0x00000002; + +pub const KVE_INH_SHARE: c_int = 0x00000000; +pub const KVE_INH_COPY: c_int = 0x00000010; +pub const KVE_INH_NONE: c_int = 0x00000020; +pub const KVE_INH_ZERO: c_int = 0x00000030; + +pub const KVE_F_STATIC: c_int = 0x1; +pub const KVE_F_KMEM: c_int = 0x2; + +pub const KERN_FILE_BYFILE: c_int = 1; +pub const KERN_FILE_BYPID: c_int = 2; +pub const KERN_FILE_BYUID: c_int = 3; +pub const KERN_FILESLOP: c_int = 10; + +pub const KERN_FILE_TEXT: c_int = -1; +pub const KERN_FILE_CDIR: c_int = -2; +pub const KERN_FILE_RDIR: c_int = -3; +pub const KERN_FILE_TRACE: c_int = -4; + +pub const KI_MNAMELEN: c_int = 96; +pub const KI_UNPPATHLEN: c_int = 104; + +pub const CHWFLOW: crate::tcflag_t = crate::MDMBUF | crate::CRTSCTS; +pub const OLCUC: crate::tcflag_t = 0x20; +pub const ONOCR: crate::tcflag_t = 0x40; +pub const ONLRET: crate::tcflag_t = 0x80; + +//https://github.com/openbsd/src/blob/HEAD/sys/sys/mount.h +pub const ISOFSMNT_NORRIP: c_int = 0x1; // disable Rock Ridge Ext +pub const ISOFSMNT_GENS: c_int = 0x2; // enable generation numbers +pub const ISOFSMNT_EXTATT: c_int = 0x4; // enable extended attr +pub const ISOFSMNT_NOJOLIET: c_int = 0x8; // disable Joliet Ext +pub const ISOFSMNT_SESS: c_int = 0x10; // use iso_args.sess + +pub const NFS_ARGSVERSION: c_int = 4; // change when nfs_args changes + +pub const NFSMNT_RESVPORT: c_int = 0; // always use reserved ports +pub const NFSMNT_SOFT: c_int = 0x1; // soft mount (hard is default) +pub const NFSMNT_WSIZE: c_int = 0x2; // set write size +pub const NFSMNT_RSIZE: c_int = 0x4; // set read size +pub const NFSMNT_TIMEO: c_int = 0x8; // set initial timeout +pub const NFSMNT_RETRANS: c_int = 0x10; // set number of request retries +pub const NFSMNT_MAXGRPS: c_int = 0x20; // set maximum grouplist size +pub const NFSMNT_INT: c_int = 0x40; // allow interrupts on hard mount +pub const NFSMNT_NOCONN: c_int = 0x80; // Don't Connect the socket +pub const NFSMNT_NQNFS: c_int = 0x100; // Use Nqnfs protocol +pub const NFSMNT_NFSV3: c_int = 0x200; // Use NFS Version 3 protocol +pub const NFSMNT_KERB: c_int = 0x400; // Use Kerberos authentication +pub const NFSMNT_DUMBTIMR: c_int = 0x800; // Don't estimate rtt dynamically +pub const NFSMNT_LEASETERM: c_int = 0x1000; // set lease term (nqnfs) +pub const NFSMNT_READAHEAD: c_int = 0x2000; // set read ahead +pub const NFSMNT_DEADTHRESH: c_int = 0x4000; // set dead server retry thresh +pub const NFSMNT_NOAC: c_int = 0x8000; // disable attribute cache +pub const NFSMNT_RDIRPLUS: c_int = 0x10000; // Use Readdirplus for V3 +pub const NFSMNT_READDIRSIZE: c_int = 0x20000; // Set readdir size + +/* Flags valid only in mount syscall arguments */ +pub const NFSMNT_ACREGMIN: c_int = 0x40000; // acregmin field valid +pub const NFSMNT_ACREGMAX: c_int = 0x80000; // acregmax field valid +pub const NFSMNT_ACDIRMIN: c_int = 0x100000; // acdirmin field valid +pub const NFSMNT_ACDIRMAX: c_int = 0x200000; // acdirmax field valid + +/* Flags valid only in kernel */ +pub const NFSMNT_INTERNAL: c_int = 0xfffc0000; // Bits set internally +pub const NFSMNT_HASWRITEVERF: c_int = 0x40000; // Has write verifier for V3 +pub const NFSMNT_GOTPATHCONF: c_int = 0x80000; // Got the V3 pathconf info +pub const NFSMNT_GOTFSINFO: c_int = 0x100000; // Got the V3 fsinfo +pub const NFSMNT_MNTD: c_int = 0x200000; // Mnt server for mnt point +pub const NFSMNT_DISMINPROG: c_int = 0x400000; // Dismount in progress +pub const NFSMNT_DISMNT: c_int = 0x800000; // Dismounted +pub const NFSMNT_SNDLOCK: c_int = 0x1000000; // Send socket lock +pub const NFSMNT_WANTSND: c_int = 0x2000000; // Want above +pub const NFSMNT_RCVLOCK: c_int = 0x4000000; // Rcv socket lock +pub const NFSMNT_WANTRCV: c_int = 0x8000000; // Want above +pub const NFSMNT_WAITAUTH: c_int = 0x10000000; // Wait for authentication +pub const NFSMNT_HASAUTH: c_int = 0x20000000; // Has authenticator +pub const NFSMNT_WANTAUTH: c_int = 0x40000000; // Wants an authenticator +pub const NFSMNT_AUTHERR: c_int = 0x80000000; // Authentication error + +pub const MSDOSFSMNT_SHORTNAME: c_int = 0x1; // Force old DOS short names only +pub const MSDOSFSMNT_LONGNAME: c_int = 0x2; // Force Win'95 long names +pub const MSDOSFSMNT_NOWIN95: c_int = 0x4; // Completely ignore Win95 entries + +pub const NTFS_MFLAG_CASEINS: c_int = 0x1; +pub const NTFS_MFLAG_ALLNAMES: c_int = 0x2; + +pub const TMPFS_ARGS_VERSION: c_int = 1; + +const SI_MAXSZ: size_t = 128; +const SI_PAD: size_t = (SI_MAXSZ / size_of::()) - 3; + +pub const MAP_STACK: c_int = 0x4000; +pub const MAP_CONCEAL: c_int = 0x8000; + +// https://github.com/openbsd/src/blob/f8a2f73b6503213f5eb24ca315ac7e1f9421c0c9/sys/net/if.h#L135 +pub const LINK_STATE_UNKNOWN: c_int = 0; // link unknown +pub const LINK_STATE_INVALID: c_int = 1; // link invalid +pub const LINK_STATE_DOWN: c_int = 2; // link is down +pub const LINK_STATE_KALIVE_DOWN: c_int = 3; // keepalive reports down +pub const LINK_STATE_UP: c_int = 4; // link is up +pub const LINK_STATE_HALF_DUPLEX: c_int = 5; // link is up and half duplex +pub const LINK_STATE_FULL_DUPLEX: c_int = 6; // link is up and full duplex + +// https://github.com/openbsd/src/blob/HEAD/sys/net/if.h#L187 +pub const IFF_UP: c_int = 0x1; // interface is up +pub const IFF_BROADCAST: c_int = 0x2; // broadcast address valid +pub const IFF_DEBUG: c_int = 0x4; // turn on debugging +pub const IFF_LOOPBACK: c_int = 0x8; // is a loopback net +pub const IFF_POINTOPOINT: c_int = 0x10; // interface is point-to-point link +pub const IFF_STATICARP: c_int = 0x20; // only static ARP +pub const IFF_RUNNING: c_int = 0x40; // resources allocated +pub const IFF_NOARP: c_int = 0x80; // no address resolution protocol +pub const IFF_PROMISC: c_int = 0x100; // receive all packets +pub const IFF_ALLMULTI: c_int = 0x200; // receive all multicast packets +pub const IFF_OACTIVE: c_int = 0x400; // transmission in progress +pub const IFF_SIMPLEX: c_int = 0x800; // can't hear own transmissions +pub const IFF_LINK0: c_int = 0x1000; // per link layer defined bit +pub const IFF_LINK1: c_int = 0x2000; // per link layer defined bit +pub const IFF_LINK2: c_int = 0x4000; // per link layer defined bit +pub const IFF_MULTICAST: c_int = 0x8000; // supports multicast + +pub const PTHREAD_STACK_MIN: size_t = 1_usize << _MAX_PAGE_SHIFT; +pub const MINSIGSTKSZ: size_t = 3_usize << _MAX_PAGE_SHIFT; +pub const SIGSTKSZ: size_t = MINSIGSTKSZ + (1_usize << _MAX_PAGE_SHIFT) * 4; + +pub const PT_SET_EVENT_MASK: c_int = 12; +pub const PT_GET_EVENT_MASK: c_int = 13; +pub const PT_GET_PROCESS_STATE: c_int = 14; +pub const PT_GET_THREAD_FIRST: c_int = 15; +pub const PT_GET_THREAD_NEXT: c_int = 16; +pub const PT_FIRSTMACH: c_int = 32; + +pub const PT_PTS_NAMELEN: c_int = 32; + +pub const SOCK_CLOEXEC: c_int = 0x8000; +pub const SOCK_NONBLOCK: c_int = 0x4000; +pub const SOCK_DNS: c_int = 0x1000; + +pub const BIOCGRSIG: c_ulong = 0x40044273; +pub const BIOCSRSIG: c_ulong = 0x80044272; +pub const BIOCSDLT: c_ulong = 0x8004427a; + +pub const PTRACE_FORK: c_int = 0x0002; + +pub const WCONTINUED: c_int = 0x08; +pub const WEXITED: c_int = 0x04; +pub const WSTOPPED: c_int = 0x02; // same as WUNTRACED +pub const WNOWAIT: c_int = 0x10; +pub const WTRAPPED: c_int = 0x20; + +pub const P_ALL: crate::idtype_t = 0; +pub const P_PGID: crate::idtype_t = 1; +pub const P_PID: crate::idtype_t = 2; + +// search.h +pub const FIND: crate::ACTION = 0; +pub const ENTER: crate::ACTION = 1; + +// futex.h +pub const FUTEX_WAIT: c_int = 1; +pub const FUTEX_WAKE: c_int = 2; +pub const FUTEX_REQUEUE: c_int = 3; +pub const FUTEX_PRIVATE_FLAG: c_int = 128; + +// sys/file.h +pub const DTYPE_VNODE: c_int = 1; +pub const DTYPE_SOCKET: c_int = 2; +pub const DTYPE_PIPE: c_int = 3; +pub const DTYPE_KQUEUE: c_int = 4; +pub const DTYPE_DMABUF: c_int = 5; +pub const DTYPE_SYNC: c_int = 6; + +// sysctl.h, kinfo_proc p_eflag constants +pub const EPROC_CTTY: i32 = 0x01; // controlling tty vnode active +pub const EPROC_SLEADER: i32 = 0x02; // session leader +pub const EPROC_UNVEIL: i32 = 0x04; // has unveil settings +pub const EPROC_LKUNVEIL: i32 = 0x08; // unveil is locked + +// Flags for chflags(2) +pub const UF_SETTABLE: c_uint = 0x0000ffff; +pub const UF_NODUMP: c_uint = 0x00000001; +pub const UF_IMMUTABLE: c_uint = 0x00000002; +pub const UF_APPEND: c_uint = 0x00000004; +pub const UF_OPAQUE: c_uint = 0x00000008; +pub const SF_SETTABLE: c_uint = 0xffff0000; +pub const SF_ARCHIVED: c_uint = 0x00010000; +pub const SF_IMMUTABLE: c_uint = 0x00020000; +pub const SF_APPEND: c_uint = 0x00040000; + +// sys/exec_elf.h - Legal values for p_type (segment type). +pub const PT_NULL: u32 = 0; +pub const PT_LOAD: u32 = 1; +pub const PT_DYNAMIC: u32 = 2; +pub const PT_INTERP: u32 = 3; +pub const PT_NOTE: u32 = 4; +pub const PT_SHLIB: u32 = 5; +pub const PT_PHDR: u32 = 6; +pub const PT_TLS: u32 = 7; +pub const PT_LOOS: u32 = 0x60000000; +pub const PT_HIOS: u32 = 0x6fffffff; +pub const PT_LOPROC: u32 = 0x70000000; +pub const PT_HIPROC: u32 = 0x7fffffff; + +pub const PT_GNU_EH_FRAME: u32 = 0x6474e550; +pub const PT_GNU_RELRO: u32 = 0x6474e552; + +// sys/exec_elf.h - Legal values for p_flags (segment flags). +pub const PF_X: u32 = 0x1; +pub const PF_W: u32 = 0x2; +pub const PF_R: u32 = 0x4; +pub const PF_MASKOS: u32 = 0x0ff00000; +pub const PF_MASKPROC: u32 = 0xf0000000; + +// sys/ioccom.h +pub const fn IOCPARM_LEN(x: u32) -> u32 { + (x >> 16) & crate::IOCPARM_MASK +} + +pub const fn IOCBASECMD(x: u32) -> u32 { + x & (!(crate::IOCPARM_MASK << 16)) +} + +pub const fn IOCGROUP(x: u32) -> u32 { + (x >> 8) & 0xff +} + +pub const fn _IOC(inout: c_ulong, group: c_ulong, num: c_ulong, len: c_ulong) -> c_ulong { + (inout) | (((len) & crate::IOCPARM_MASK as c_ulong) << 16) | ((group) << 8) | (num) +} + +// sys/mount.h +pub const MNT_NOPERM: c_int = 0x00000020; +pub const MNT_WXALLOWED: c_int = 0x00000800; +pub const MNT_EXRDONLY: c_int = 0x00000080; +pub const MNT_DEFEXPORTED: c_int = 0x00000200; +pub const MNT_EXPORTANON: c_int = 0x00000400; +pub const MNT_ROOTFS: c_int = 0x00004000; +pub const MNT_NOATIME: c_int = 0x00008000; +pub const MNT_DELEXPORT: c_int = 0x00020000; +pub const MNT_STALLED: c_int = 0x00100000; +pub const MNT_SWAPPABLE: c_int = 0x00200000; +pub const MNT_WANTRDWR: c_int = 0x02000000; +pub const MNT_SOFTDEP: c_int = 0x04000000; +pub const MNT_DOOMED: c_int = 0x08000000; + +// For use with vfs_fsync and getfsstat +pub const MNT_WAIT: c_int = 1; +pub const MNT_NOWAIT: c_int = 2; +pub const MNT_LAZY: c_int = 3; + +// sys/_time.h +pub const CLOCK_PROCESS_CPUTIME_ID: crate::clockid_t = 2; +pub const CLOCK_THREAD_CPUTIME_ID: crate::clockid_t = 4; +pub const CLOCK_UPTIME: crate::clockid_t = 5; +pub const CLOCK_BOOTTIME: crate::clockid_t = 6; + +pub const LC_COLLATE_MASK: c_int = 1 << crate::LC_COLLATE; +pub const LC_CTYPE_MASK: c_int = 1 << crate::LC_CTYPE; +pub const LC_MONETARY_MASK: c_int = 1 << crate::LC_MONETARY; +pub const LC_NUMERIC_MASK: c_int = 1 << crate::LC_NUMERIC; +pub const LC_TIME_MASK: c_int = 1 << crate::LC_TIME; +pub const LC_MESSAGES_MASK: c_int = 1 << crate::LC_MESSAGES; + +const _LC_LAST: c_int = 7; +pub const LC_ALL_MASK: c_int = (1 << _LC_LAST) - 2; + +pub const LC_GLOBAL_LOCALE: crate::locale_t = -1isize as crate::locale_t; + +// sys/reboot.h +pub const RB_ASKNAME: c_int = 0x00001; +pub const RB_SINGLE: c_int = 0x00002; +pub const RB_NOSYNC: c_int = 0x00004; +pub const RB_HALT: c_int = 0x00008; +pub const RB_INITNAME: c_int = 0x00010; +pub const RB_KDB: c_int = 0x00040; +pub const RB_RDONLY: c_int = 0x00080; +pub const RB_DUMP: c_int = 0x00100; +pub const RB_MINIROOT: c_int = 0x00200; +pub const RB_CONFIG: c_int = 0x00400; +pub const RB_TIMEBAD: c_int = 0x00800; +pub const RB_POWERDOWN: c_int = 0x01000; +pub const RB_SERCONS: c_int = 0x02000; +pub const RB_USERREQ: c_int = 0x04000; +pub const RB_RESET: c_int = 0x08000; +pub const RB_GOODRANDOM: c_int = 0x10000; +pub const RB_UNHIBERNATE: c_int = 0x20000; + +// net/route.h +pub const RTF_CLONING: c_int = 0x100; +pub const RTF_MULTICAST: c_int = 0x200; +pub const RTF_LLINFO: c_int = 0x400; +pub const RTF_PROTO3: c_int = 0x2000; +pub const RTF_ANNOUNCE: c_int = crate::RTF_PROTO2; + +pub const RTF_CLONED: c_int = 0x10000; +pub const RTF_CACHED: c_int = 0x20000; +pub const RTF_MPATH: c_int = 0x40000; +pub const RTF_MPLS: c_int = 0x100000; +pub const RTF_LOCAL: c_int = 0x200000; +pub const RTF_BROADCAST: c_int = 0x400000; +pub const RTF_CONNECTED: c_int = 0x800000; +pub const RTF_BFD: c_int = 0x1000000; +pub const RTF_FMASK: c_int = crate::RTF_LLINFO + | crate::RTF_PROTO1 + | crate::RTF_PROTO2 + | crate::RTF_PROTO3 + | crate::RTF_BLACKHOLE + | crate::RTF_REJECT + | crate::RTF_STATIC + | crate::RTF_MPLS + | crate::RTF_BFD; + +pub const RTM_VERSION: c_int = 5; +pub const RTM_RESOLVE: c_int = 0xb; +pub const RTM_NEWADDR: c_int = 0xc; +pub const RTM_DELADDR: c_int = 0xd; +pub const RTM_IFINFO: c_int = 0xe; +pub const RTM_IFANNOUNCE: c_int = 0xf; +pub const RTM_DESYNC: c_int = 0x10; +pub const RTM_INVALIDATE: c_int = 0x11; +pub const RTM_BFD: c_int = 0x12; +pub const RTM_PROPOSAL: c_int = 0x13; +pub const RTM_CHGADDRATTR: c_int = 0x14; +pub const RTM_80211INFO: c_int = 0x15; +pub const RTM_SOURCE: c_int = 0x16; + +pub const RTA_SRC: c_int = 0x100; +pub const RTA_SRCMASK: c_int = 0x200; +pub const RTA_LABEL: c_int = 0x400; +pub const RTA_BFD: c_int = 0x800; +pub const RTA_DNS: c_int = 0x1000; +pub const RTA_STATIC: c_int = 0x2000; +pub const RTA_SEARCH: c_int = 0x4000; + +pub const RTAX_SRC: c_int = 8; +pub const RTAX_SRCMASK: c_int = 9; +pub const RTAX_LABEL: c_int = 10; +pub const RTAX_BFD: c_int = 11; +pub const RTAX_DNS: c_int = 12; +pub const RTAX_STATIC: c_int = 13; +pub const RTAX_SEARCH: c_int = 14; +pub const RTAX_MAX: c_int = 15; + +const fn _ALIGN(p: usize) -> usize { + (p + _ALIGNBYTES) & !_ALIGNBYTES +} + +f! { + pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { + (cmsg as *mut c_uchar).offset(_ALIGN(size_of::()) as isize) + } + + pub const fn CMSG_LEN(length: c_uint) -> c_uint { + _ALIGN(size_of::()) as c_uint + length + } + + pub fn CMSG_NXTHDR(mhdr: *const crate::msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { + if cmsg.is_null() { + return crate::CMSG_FIRSTHDR(mhdr); + } + let next = cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) + _ALIGN(size_of::()); + let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; + if next > max { + core::ptr::null_mut::() + } else { + (cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr + } + } + + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { + (_ALIGN(size_of::()) + _ALIGN(length as usize)) as c_uint + } +} + +safe_f! { + pub const fn WSTOPSIG(status: c_int) -> c_int { + status >> 8 + } + + pub const fn WIFSIGNALED(status: c_int) -> bool { + (status & 0o177) != 0o177 && (status & 0o177) != 0 + } + + pub const fn WIFSTOPPED(status: c_int) -> bool { + (status & 0xff) == 0o177 + } + + pub const fn WIFCONTINUED(status: c_int) -> bool { + (status & 0o177777) == 0o177777 + } + + pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { + let major = major as crate::dev_t; + let minor = minor as crate::dev_t; + let mut dev = 0; + dev |= (major & 0xff) << 8; + dev |= minor & 0xff; + dev |= (minor & 0xffff00) << 8; + dev + } + + pub const fn major(dev: crate::dev_t) -> c_uint { + ((dev as c_uint) >> 8) & 0xff + } + + pub const fn minor(dev: crate::dev_t) -> c_uint { + let dev = dev as c_uint; + let mut res = 0; + res |= (dev) & 0xff; + res |= ((dev) & 0xffff0000) >> 8; + res + } +} + +extern "C" { + pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut crate::timezone) -> c_int; + pub fn settimeofday(tp: *const crate::timeval, tz: *const crate::timezone) -> c_int; + pub fn pledge(promises: *const c_char, execpromises: *const c_char) -> c_int; + pub fn unveil(path: *const c_char, permissions: *const c_char) -> c_int; + pub fn strtonum( + nptr: *const c_char, + minval: c_longlong, + maxval: c_longlong, + errstr: *mut *const c_char, + ) -> c_longlong; + pub fn dup3(src: c_int, dst: c_int, flags: c_int) -> c_int; + pub fn chflags(path: *const c_char, flags: c_uint) -> c_int; + pub fn fchflags(fd: c_int, flags: c_uint) -> c_int; + pub fn chflagsat(fd: c_int, path: *const c_char, flags: c_uint, atflag: c_int) -> c_int; + pub fn dirfd(dirp: *mut crate::DIR) -> c_int; + pub fn getnameinfo( + sa: *const crate::sockaddr, + salen: crate::socklen_t, + host: *mut c_char, + hostlen: size_t, + serv: *mut c_char, + servlen: size_t, + flags: c_int, + ) -> c_int; + pub fn getresgid( + rgid: *mut crate::gid_t, + egid: *mut crate::gid_t, + sgid: *mut crate::gid_t, + ) -> c_int; + pub fn getresuid( + ruid: *mut crate::uid_t, + euid: *mut crate::uid_t, + suid: *mut crate::uid_t, + ) -> c_int; + pub fn kevent( + kq: c_int, + changelist: *const crate::kevent, + nchanges: c_int, + eventlist: *mut crate::kevent, + nevents: c_int, + timeout: *const crate::timespec, + ) -> c_int; + pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; + pub fn getthrid() -> crate::pid_t; + pub fn pthread_attr_getguardsize( + attr: *const crate::pthread_attr_t, + guardsize: *mut size_t, + ) -> c_int; + pub fn pthread_attr_setguardsize(attr: *mut crate::pthread_attr_t, guardsize: size_t) -> c_int; + pub fn pthread_attr_getstack( + attr: *const crate::pthread_attr_t, + stackaddr: *mut *mut c_void, + stacksize: *mut size_t, + ) -> c_int; + pub fn pthread_main_np() -> c_int; + pub fn pthread_get_name_np(tid: crate::pthread_t, name: *mut c_char, len: size_t); + pub fn pthread_set_name_np(tid: crate::pthread_t, name: *const c_char); + pub fn pthread_stackseg_np(thread: crate::pthread_t, sinfo: *mut crate::stack_t) -> c_int; + + pub fn openpty( + amaster: *mut c_int, + aslave: *mut c_int, + name: *mut c_char, + termp: *const crate::termios, + winp: *const crate::winsize, + ) -> c_int; + pub fn forkpty( + amaster: *mut c_int, + name: *mut c_char, + termp: *const crate::termios, + winp: *const crate::winsize, + ) -> crate::pid_t; + + pub fn sysctl( + name: *const c_int, + namelen: c_uint, + oldp: *mut c_void, + oldlenp: *mut size_t, + newp: *mut c_void, + newlen: size_t, + ) -> c_int; + pub fn setresgid(rgid: crate::gid_t, egid: crate::gid_t, sgid: crate::gid_t) -> c_int; + pub fn setresuid(ruid: crate::uid_t, euid: crate::uid_t, suid: crate::uid_t) -> c_int; + pub fn ptrace(request: c_int, pid: crate::pid_t, addr: caddr_t, data: c_int) -> c_int; + pub fn utrace(label: *const c_char, addr: *const c_void, len: size_t) -> c_int; + pub fn memmem( + haystack: *const c_void, + haystacklen: size_t, + needle: *const c_void, + needlelen: size_t, + ) -> *mut c_void; + // #include + pub fn dl_iterate_phdr( + callback: Option< + unsafe extern "C" fn(info: *mut dl_phdr_info, size: usize, data: *mut c_void) -> c_int, + >, + data: *mut c_void, + ) -> c_int; + pub fn uselocale(loc: crate::locale_t) -> crate::locale_t; + pub fn freelocale(loc: crate::locale_t); + pub fn newlocale(mask: c_int, locale: *const c_char, base: crate::locale_t) -> crate::locale_t; + pub fn duplocale(base: crate::locale_t) -> crate::locale_t; + + // Added in `OpenBSD` 5.5 + pub fn explicit_bzero(s: *mut c_void, len: size_t); + + pub fn setproctitle(fmt: *const c_char, ...); + + pub fn freezero(ptr: *mut c_void, size: size_t); + pub fn malloc_conceal(size: size_t) -> *mut c_void; + pub fn calloc_conceal(nmemb: size_t, size: size_t) -> *mut c_void; + + pub fn srand48_deterministic(seed: c_long); + pub fn seed48_deterministic(xseed: *mut c_ushort) -> *mut c_ushort; + pub fn lcong48_deterministic(p: *mut c_ushort); + + pub fn lsearch( + key: *const c_void, + base: *mut c_void, + nelp: *mut size_t, + width: size_t, + compar: Option c_int>, + ) -> *mut c_void; + pub fn lfind( + key: *const c_void, + base: *const c_void, + nelp: *mut size_t, + width: size_t, + compar: Option c_int>, + ) -> *mut c_void; + pub fn hcreate(nelt: size_t) -> c_int; + pub fn hdestroy(); + pub fn hsearch(entry: crate::ENTRY, action: crate::ACTION) -> *mut crate::ENTRY; + + // futex.h + pub fn futex( + uaddr: *mut u32, + op: c_int, + val: c_int, + timeout: *const crate::timespec, + uaddr2: *mut u32, + ) -> c_int; + + pub fn mimmutable(addr: *mut c_void, len: size_t) -> c_int; + + pub fn reboot(mode: c_int) -> c_int; + + pub fn statfs(path: *const c_char, buf: *mut statfs) -> c_int; + pub fn fstatfs(fd: c_int, buf: *mut statfs) -> c_int; + pub fn getmntinfo(mntbufp: *mut *mut crate::statfs, flags: c_int) -> c_int; + pub fn getfsstat(buf: *mut statfs, bufsize: size_t, flags: c_int) -> c_int; + + pub fn elf_aux_info(aux: c_int, buf: *mut c_void, buflen: c_int) -> c_int; +} + +#[link(name = "execinfo")] +extern "C" { + pub fn backtrace(addrlist: *mut *mut c_void, len: size_t) -> size_t; + pub fn backtrace_symbols(addrlist: *const *mut c_void, len: size_t) -> *mut *mut c_char; + pub fn backtrace_symbols_fd(addrlist: *const *mut c_void, len: size_t, fd: c_int) -> c_int; + pub fn backtrace_symbols_fmt( + addrlist: *const *mut c_void, + len: size_t, + fmt: *const c_char, + ) -> *mut *mut c_char; +} + +cfg_if! { + if #[cfg(target_arch = "aarch64")] { + mod aarch64; + pub use self::aarch64::*; + } else if #[cfg(target_arch = "arm")] { + mod arm; + pub use self::arm::*; + } else if #[cfg(target_arch = "mips64")] { + mod mips64; + pub use self::mips64::*; + } else if #[cfg(target_arch = "powerpc")] { + mod powerpc; + pub use self::powerpc::*; + } else if #[cfg(target_arch = "powerpc64")] { + mod powerpc64; + pub use self::powerpc64::*; + } else if #[cfg(target_arch = "riscv64")] { + mod riscv64; + pub use self::riscv64::*; + } else if #[cfg(target_arch = "sparc64")] { + mod sparc64; + pub use self::sparc64::*; + } else if #[cfg(target_arch = "x86")] { + mod x86; + pub use self::x86::*; + } else if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } else { + // Unknown target_arch + } +} diff --git a/http/vendor/libc/src/unix/bsd/netbsdlike/openbsd/powerpc.rs b/http/vendor/libc/src/unix/bsd/netbsdlike/openbsd/powerpc.rs new file mode 100644 index 0000000..8b3f721 --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/netbsdlike/openbsd/powerpc.rs @@ -0,0 +1,5 @@ +use crate::prelude::*; + +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; + +pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/http/vendor/libc/src/unix/bsd/netbsdlike/openbsd/powerpc64.rs b/http/vendor/libc/src/unix/bsd/netbsdlike/openbsd/powerpc64.rs new file mode 100644 index 0000000..5ebe857 --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/netbsdlike/openbsd/powerpc64.rs @@ -0,0 +1,5 @@ +use crate::prelude::*; + +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; + +pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/http/vendor/libc/src/unix/bsd/netbsdlike/openbsd/riscv64.rs b/http/vendor/libc/src/unix/bsd/netbsdlike/openbsd/riscv64.rs new file mode 100644 index 0000000..e0ecf2a --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/netbsdlike/openbsd/riscv64.rs @@ -0,0 +1,25 @@ +use crate::prelude::*; + +pub type ucontext_t = sigcontext; + +s! { + pub struct sigcontext { + __sc_unused: Padding, + pub sc_mask: c_int, + pub sc_ra: c_long, + pub sc_sp: c_long, + pub sc_gp: c_long, + pub sc_tp: c_long, + pub sc_t: [c_long; 7], + pub sc_s: [c_long; 12], + pub sc_a: [c_long; 8], + pub sc_sepc: c_long, + pub sc_f: [c_long; 32], + pub sc_fcsr: c_long, + pub sc_cookie: c_long, + } +} + +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; + +pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/http/vendor/libc/src/unix/bsd/netbsdlike/openbsd/sparc64.rs b/http/vendor/libc/src/unix/bsd/netbsdlike/openbsd/sparc64.rs new file mode 100644 index 0000000..88481f4 --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/netbsdlike/openbsd/sparc64.rs @@ -0,0 +1,4 @@ +#[doc(hidden)] +pub const _ALIGNBYTES: usize = 0xf; + +pub const _MAX_PAGE_SHIFT: u32 = 13; diff --git a/http/vendor/libc/src/unix/bsd/netbsdlike/openbsd/x86.rs b/http/vendor/libc/src/unix/bsd/netbsdlike/openbsd/x86.rs new file mode 100644 index 0000000..97dc583 --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/netbsdlike/openbsd/x86.rs @@ -0,0 +1,5 @@ +use crate::prelude::*; + +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; + +pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/http/vendor/libc/src/unix/bsd/netbsdlike/openbsd/x86_64.rs b/http/vendor/libc/src/unix/bsd/netbsdlike/openbsd/x86_64.rs new file mode 100644 index 0000000..74889a7 --- /dev/null +++ b/http/vendor/libc/src/unix/bsd/netbsdlike/openbsd/x86_64.rs @@ -0,0 +1,65 @@ +use crate::prelude::*; +use crate::PT_FIRSTMACH; + +pub type ucontext_t = sigcontext; + +s! { + pub struct sigcontext { + pub sc_rdi: c_long, + pub sc_rsi: c_long, + pub sc_rdx: c_long, + pub sc_rcx: c_long, + pub sc_r8: c_long, + pub sc_r9: c_long, + pub sc_r10: c_long, + pub sc_r11: c_long, + pub sc_r12: c_long, + pub sc_r13: c_long, + pub sc_r14: c_long, + pub sc_r15: c_long, + pub sc_rbp: c_long, + pub sc_rbx: c_long, + pub sc_rax: c_long, + pub sc_gs: c_long, + pub sc_fs: c_long, + pub sc_es: c_long, + pub sc_ds: c_long, + pub sc_trapno: c_long, + pub sc_err: c_long, + pub sc_rip: c_long, + pub sc_cs: c_long, + pub sc_rflags: c_long, + pub sc_rsp: c_long, + pub sc_ss: c_long, + pub sc_fpstate: *mut fxsave64, + __sc_unused: Padding, + pub sc_mask: c_int, + pub sc_cookie: c_long, + } + + #[repr(packed)] + pub struct fxsave64 { + pub fx_fcw: u16, + pub fx_fsw: u16, + pub fx_ftw: u8, + __fx_unused1: Padding, + pub fx_fop: u16, + pub fx_rip: u64, + pub fx_rdp: u64, + pub fx_mxcsr: u32, + pub fx_mxcsr_mask: u32, + pub fx_st: [[u64; 2]; 8], + pub fx_xmm: [[u64; 2]; 16], + __fx_unused3: Padding<[u8; 96]>, + } +} + +pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; + +pub const _MAX_PAGE_SHIFT: u32 = 12; + +pub const PT_STEP: c_int = PT_FIRSTMACH + 0; +pub const PT_GETREGS: c_int = PT_FIRSTMACH + 1; +pub const PT_SETREGS: c_int = PT_FIRSTMACH + 2; +pub const PT_GETFPREGS: c_int = PT_FIRSTMACH + 3; +pub const PT_SETFPREGS: c_int = PT_FIRSTMACH + 4; diff --git a/http/vendor/libc/src/unix/cygwin/mod.rs b/http/vendor/libc/src/unix/cygwin/mod.rs new file mode 100644 index 0000000..0c093a4 --- /dev/null +++ b/http/vendor/libc/src/unix/cygwin/mod.rs @@ -0,0 +1,2389 @@ +use crate::prelude::*; +use crate::*; + +pub type wchar_t = c_ushort; + +pub type blkcnt_t = i64; +pub type blksize_t = i32; +pub type dev_t = u32; +pub type fsblkcnt_t = c_ulong; +pub type fsfilcnt_t = c_ulong; +pub type ino_t = u64; +pub type key_t = c_longlong; +pub type sa_family_t = u16; +pub type socklen_t = c_int; + +pub type off_t = c_long; +pub type id_t = u32; +pub type mode_t = u32; +pub type _off64_t = c_longlong; +pub type loff_t = _off64_t; +pub type iconv_t = *mut c_void; +pub type clock_t = c_ulong; +pub type time_t = c_long; +pub type clockid_t = c_ulong; +pub type timer_t = c_ulong; +pub type nl_item = c_int; +pub type nlink_t = c_ushort; +pub type suseconds_t = c_long; +pub type useconds_t = c_ulong; + +extern_ty! { + pub enum timezone {} +} + +pub type sigset_t = c_ulong; + +pub type fd_mask = c_ulong; + +pub type pthread_t = *mut c_void; +pub type pthread_mutex_t = *mut c_void; + +// Must be usize due to libstd/sys_common/thread_local.rs, +// should technically be *mut c_void +pub type pthread_key_t = usize; + +pub type pthread_attr_t = *mut c_void; +pub type pthread_mutexattr_t = *mut c_void; +pub type pthread_condattr_t = *mut c_void; +pub type pthread_cond_t = *mut c_void; + +// The following ones should be *mut c_void +pub type pthread_barrierattr_t = usize; +pub type pthread_barrier_t = usize; +pub type pthread_spinlock_t = usize; + +pub type pthread_rwlock_t = *mut c_void; +pub type pthread_rwlockattr_t = *mut c_void; + +pub type register_t = intptr_t; +pub type u_char = c_uchar; +pub type u_short = c_ushort; +pub type u_long = c_ulong; +pub type u_int = c_uint; +pub type caddr_t = *mut c_char; +pub type vm_size_t = c_ulong; + +pub type rlim_t = c_ulong; + +pub type nfds_t = c_uint; + +pub type sem_t = *mut sem; + +extern_ty! { + pub enum sem {} +} + +pub type tcflag_t = c_uint; +pub type speed_t = c_uint; + +pub type vm_offset_t = c_ulong; + +pub type posix_spawn_file_actions_t = *mut c_void; +pub type posix_spawnattr_t = *mut c_void; + +s! { + pub struct itimerspec { + pub it_interval: timespec, + pub it_value: timespec, + } + + pub struct cpu_set_t { + bits: [u64; 16], + } + + pub struct sigaction { + pub sa_sigaction: sighandler_t, + pub sa_mask: sigset_t, + pub sa_flags: c_int, + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_flags: c_int, + pub ss_size: size_t, + } + + pub struct tm { + pub tm_sec: c_int, + pub tm_min: c_int, + pub tm_hour: c_int, + pub tm_mday: c_int, + pub tm_mon: c_int, + pub tm_year: c_int, + pub tm_wday: c_int, + pub tm_yday: c_int, + pub tm_isdst: c_int, + pub tm_gmtoff: c_long, + pub tm_zone: *const c_char, + } + + pub struct bintime { + pub sec: time_t, + pub frac: u64, + } + + pub struct passwd { + pub pw_name: *mut c_char, + pub pw_passwd: *mut c_char, + pub pw_uid: uid_t, + pub pw_gid: gid_t, + pub pw_comment: *mut c_char, + pub pw_gecos: *mut c_char, + pub pw_dir: *mut c_char, + pub pw_shell: *mut c_char, + } + + pub struct if_nameindex { + pub if_index: c_uint, + pub if_name: *mut c_char, + } + + pub struct ucred { + pub pid: pid_t, + pub uid: uid_t, + pub gid: gid_t, + } + + pub struct msghdr { + pub msg_name: *mut c_void, + pub msg_namelen: socklen_t, + pub msg_iov: *mut iovec, + pub msg_iovlen: c_int, + pub msg_control: *mut c_void, + pub msg_controllen: socklen_t, + pub msg_flags: c_int, + } + + pub struct cmsghdr { + pub cmsg_len: size_t, + pub cmsg_level: c_int, + pub cmsg_type: c_int, + } + + pub struct Dl_info { + pub dli_fname: [c_char; PATH_MAX as usize], + pub dli_fbase: *mut c_void, + pub dli_sname: *const c_char, + pub dli_saddr: *mut c_void, + } + + pub struct in6_pktinfo { + pub ipi6_addr: in6_addr, + pub ipi6_ifindex: u32, + } + + pub struct sockaddr_in6 { + pub sin6_family: sa_family_t, + pub sin6_port: in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: in6_addr, + pub sin6_scope_id: u32, + } + + pub struct ip_mreq_source { + pub imr_multiaddr: in_addr, + pub imr_sourceaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: socklen_t, + pub ai_canonname: *mut c_char, + pub ai_addr: *mut sockaddr, + pub ai_next: *mut addrinfo, + } + + pub struct lconv { + pub decimal_point: *mut c_char, + pub thousands_sep: *mut c_char, + pub grouping: *mut c_char, + pub int_curr_symbol: *mut c_char, + pub currency_symbol: *mut c_char, + pub mon_decimal_point: *mut c_char, + pub mon_thousands_sep: *mut c_char, + pub mon_grouping: *mut c_char, + pub positive_sign: *mut c_char, + pub negative_sign: *mut c_char, + pub int_frac_digits: c_char, + pub frac_digits: c_char, + pub p_cs_precedes: c_char, + pub p_sep_by_space: c_char, + pub n_cs_precedes: c_char, + pub n_sep_by_space: c_char, + pub p_sign_posn: c_char, + pub n_sign_posn: c_char, + pub int_n_cs_precedes: c_char, + pub int_n_sep_by_space: c_char, + pub int_n_sign_posn: c_char, + pub int_p_cs_precedes: c_char, + pub int_p_sep_by_space: c_char, + pub int_p_sign_posn: c_char, + } + + pub struct termios { + pub c_iflag: tcflag_t, + pub c_oflag: tcflag_t, + pub c_cflag: tcflag_t, + pub c_lflag: tcflag_t, + pub c_line: c_char, + pub c_cc: [cc_t; NCCS], + pub c_ispeed: speed_t, + pub c_ospeed: speed_t, + } + + pub struct sched_param { + pub sched_priority: c_int, + } + + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off_t, + pub l_len: off_t, + pub l_pid: pid_t, + } + + pub struct hostent { + pub h_name: *const c_char, + pub h_aliases: *mut *mut c_char, + pub h_addrtype: c_short, + pub h_length: c_short, + pub h_addr_list: *mut *mut c_char, + } + + pub struct linger { + pub l_onoff: c_ushort, + pub l_linger: c_ushort, + } + + pub struct fd_set { + fds_bits: [fd_mask; FD_SETSIZE / size_of::() / 8], + } + + pub struct _uc_fpxreg { + pub significand: [u16; 4], + pub exponent: u16, + padding: Padding<[u16; 3]>, + } + + pub struct _uc_xmmreg { + pub element: [u32; 4], + } + + pub struct _fpstate { + pub cwd: u16, + pub swd: u16, + pub ftw: u16, + pub fop: u16, + pub rip: u64, + pub rdp: u64, + pub mxcsr: u32, + pub mxcr_mask: u32, + pub st: [_uc_fpxreg; 8], + pub xmm: [_uc_xmmreg; 16], + padding: Padding<[u32; 24]>, + } + + #[repr(align(16))] + pub struct mcontext_t { + pub p1home: u64, + pub p2home: u64, + pub p3home: u64, + pub p4home: u64, + pub p5home: u64, + pub p6home: u64, + pub ctxflags: u32, + pub mxcsr: u32, + pub cs: u16, + pub ds: u16, + pub es: u16, + pub fs: u16, + pub gs: u16, + pub ss: u16, + pub eflags: u32, + pub dr0: u64, + pub dr1: u64, + pub dr2: u64, + pub dr3: u64, + pub dr6: u64, + pub dr7: u64, + pub rax: u64, + pub rcx: u64, + pub rdx: u64, + pub rbx: u64, + pub rsp: u64, + pub rbp: u64, + pub rsi: u64, + pub rdi: u64, + pub r8: u64, + pub r9: u64, + pub r10: u64, + pub r11: u64, + pub r12: u64, + pub r13: u64, + pub r14: u64, + pub r15: u64, + pub rip: u64, + pub fpregs: _fpstate, + pub vregs: [u64; 52], + pub vcx: u64, + pub dbc: u64, + pub btr: u64, + pub bfr: u64, + pub etr: u64, + pub efr: u64, + pub oldmask: u64, + pub cr2: u64, + } + + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigevent { + pub sigev_value: sigval, + pub sigev_signo: c_int, + pub sigev_notify: c_int, + pub sigev_notify_function: Option, + pub sigev_notify_attributes: *mut pthread_attr_t, + } + + #[repr(align(8))] + pub struct ucontext_t { + pub uc_mcontext: mcontext_t, + pub uc_link: *mut ucontext_t, + pub uc_sigmask: sigset_t, + pub uc_stack: stack_t, + pub uc_flags: c_ulong, + } + + pub struct sockaddr { + pub sa_family: sa_family_t, + pub sa_data: [c_char; 14], + } + + pub struct sockaddr_storage { + pub ss_family: sa_family_t, + __ss_pad1: Padding<[c_char; 6]>, + __ss_align: i64, + __ss_pad2: Padding<[c_char; 112]>, + } + + pub struct stat { + pub st_dev: dev_t, + pub st_ino: ino_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + pub st_rdev: dev_t, + pub st_size: off_t, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + pub st_blksize: blksize_t, + pub st_blocks: blkcnt_t, + pub st_birthtime: time_t, + pub st_birthtime_nsec: c_long, + } + + pub struct in_addr { + pub s_addr: in_addr_t, + } + + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct in_pktinfo { + pub ipi_addr: in_addr, + pub ipi_ifindex: u32, + } + + pub struct sockaddr_in { + pub sin_family: sa_family_t, + pub sin_port: in_port_t, + pub sin_addr: in_addr, + pub sin_zero: [u8; 8], + } + + pub struct statvfs { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: fsblkcnt_t, + pub f_bfree: fsblkcnt_t, + pub f_bavail: fsblkcnt_t, + pub f_files: fsfilcnt_t, + pub f_ffree: fsfilcnt_t, + pub f_favail: fsfilcnt_t, + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + } + + pub struct statfs { + pub f_type: c_long, + pub f_bsize: c_long, + pub f_blocks: c_long, + pub f_bfree: c_long, + pub f_bavail: c_long, + pub f_files: c_long, + pub f_ffree: c_long, + pub f_fsid: c_long, + pub f_namelen: c_long, + pub f_spare: [c_long; 6], + } + + pub struct sockaddr_un { + pub sun_family: sa_family_t, + pub sun_path: [c_char; 108], + } + + pub struct utsname { + pub sysname: [c_char; 66], + pub nodename: [c_char; 65], + pub release: [c_char; 65], + pub version: [c_char; 65], + pub machine: [c_char; 65], + pub domainname: [c_char; 65], + } + + pub struct siginfo_t { + pub si_signo: c_int, + pub si_code: c_int, + pub si_pid: pid_t, + pub si_uid: uid_t, + pub si_errno: c_int, + __pad: Padding<[u32; 32]>, + } + + pub struct dirent { + __d_version: u32, + pub d_ino: ino_t, + pub d_type: c_uchar, + __d_unused1: Padding<[c_uchar; 3]>, + __d_internal1: u32, + pub d_name: [c_char; 256], + } +} + +s_no_extra_traits! { + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 4], + } + + pub union __c_anonymous_ifr_ifru { + pub ifru_addr: sockaddr, + pub ifru_broadaddr: sockaddr, + pub ifru_dstaddr: sockaddr, + pub ifru_netmask: sockaddr, + pub ifru_hwaddr: sockaddr, + pub ifru_flags: c_int, + pub ifru_metric: c_int, + pub ifru_mtu: c_int, + pub ifru_ifindex: c_int, + pub ifru_data: *mut c_char, + __ifru_pad: Padding<[c_char; 28]>, + } + + pub struct ifreq { + /// if name, e.g. "en0" + pub ifr_name: [c_char; IFNAMSIZ], + pub ifr_ifru: __c_anonymous_ifr_ifru, + } + + pub union __c_anonymous_ifc_ifcu { + pub ifcu_buf: caddr_t, + pub ifcu_req: *mut ifreq, + } + + pub struct ifconf { + pub ifc_len: c_int, + pub ifc_ifcu: __c_anonymous_ifc_ifcu, + } + + pub struct utmpx { + pub ut_type: c_short, + pub ut_pid: pid_t, + pub ut_line: [c_char; UT_LINESIZE], + pub ut_id: [c_char; UT_IDLEN], + pub ut_time: time_t, + pub ut_user: [c_char; UT_NAMESIZE], + pub ut_host: [c_char; UT_HOSTSIZE], + pub ut_addr: c_long, + pub ut_tv: timeval, + } +} + +impl siginfo_t { + pub unsafe fn si_addr(&self) -> *mut c_void { + #[repr(C)] + struct siginfo_si_addr { + _si_signo: c_int, + _si_code: c_int, + _si_pid: pid_t, + _si_uid: uid_t, + _si_errno: c_int, + si_addr: *mut c_void, + } + (*(self as *const siginfo_t as *const siginfo_si_addr)).si_addr + } + + pub unsafe fn si_status(&self) -> c_int { + #[repr(C)] + struct siginfo_sigchld { + _si_signo: c_int, + _si_code: c_int, + _si_pid: pid_t, + _si_uid: uid_t, + _si_errno: c_int, + si_status: c_int, + } + (*(self as *const siginfo_t as *const siginfo_sigchld)).si_status + } + + pub unsafe fn si_pid(&self) -> pid_t { + self.si_pid + } + + pub unsafe fn si_uid(&self) -> uid_t { + self.si_uid + } + + pub unsafe fn si_value(&self) -> sigval { + #[repr(C)] + struct siginfo_si_value { + _si_signo: c_int, + _si_code: c_int, + _si_pid: pid_t, + _si_uid: uid_t, + _si_errno: c_int, + si_value: sigval, + } + (*(self as *const siginfo_t as *const siginfo_si_value)).si_value + } +} + +pub const FD_SETSIZE: usize = 1024; + +pub const CPU_SETSIZE: c_int = 0x400; + +// si_code values for SIGBUS signal +pub const BUS_ADRALN: c_int = 25; +pub const BUS_ADRERR: c_int = 26; +pub const BUS_OBJERR: c_int = 27; + +// si_code values for SIGCHLD signal +pub const CLD_EXITED: c_int = 28; +pub const CLD_KILLED: c_int = 29; +pub const CLD_DUMPED: c_int = 30; +pub const CLD_TRAPPED: c_int = 31; +pub const CLD_STOPPED: c_int = 32; +pub const CLD_CONTINUED: c_int = 33; + +pub const SIGEV_SIGNAL: c_int = 0; +pub const SIGEV_NONE: c_int = 1; +pub const SIGEV_THREAD: c_int = 2; + +pub const SA_NOCLDSTOP: c_int = 0x00000001; +pub const SA_NOCLDWAIT: c_int = 0; // FIXME: does not exist on Cygwin! +pub const SA_SIGINFO: c_int = 0x00000002; +pub const SA_RESTART: c_int = 0x10000000; +pub const SA_ONSTACK: c_int = 0x20000000; +pub const SA_NODEFER: c_int = 0x40000000; +pub const SA_RESETHAND: c_int = 0x80000000; +pub const MINSIGSTKSZ: size_t = 8192; +pub const SIGSTKSZ: size_t = 32768; +pub const SIGHUP: c_int = 1; +pub const SIGINT: c_int = 2; +pub const SIGQUIT: c_int = 3; +pub const SIGILL: c_int = 4; +pub const SIGTRAP: c_int = 5; +pub const SIGABRT: c_int = 6; +pub const SIGEMT: c_int = 7; +pub const SIGFPE: c_int = 8; +pub const SIGKILL: c_int = 9; +pub const SIGBUS: c_int = 10; +pub const SIGSEGV: c_int = 11; +pub const SIGSYS: c_int = 12; +pub const SIGPIPE: c_int = 13; +pub const SIGALRM: c_int = 14; +pub const SIGTERM: c_int = 15; +pub const SIGURG: c_int = 16; +pub const SIGSTOP: c_int = 17; +pub const SIGTSTP: c_int = 18; +pub const SIGCONT: c_int = 19; +pub const SIGCHLD: c_int = 20; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGIO: c_int = 23; +pub const SIGPOLL: c_int = 23; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGPWR: c_int = 29; +pub const SIGUSR1: c_int = 30; +pub const SIGUSR2: c_int = 31; + +pub const SS_ONSTACK: c_int = 0x1; +pub const SS_DISABLE: c_int = 0x2; + +pub const SIG_SETMASK: c_int = 0; +pub const SIG_BLOCK: c_int = 1; +pub const SIG_UNBLOCK: c_int = 2; + +pub const TIMER_ABSTIME: c_int = 4; +pub const CLOCK_REALTIME_COARSE: clockid_t = 0; +pub const CLOCK_REALTIME: clockid_t = 1; +pub const CLOCK_PROCESS_CPUTIME_ID: clockid_t = 2; +pub const CLOCK_THREAD_CPUTIME_ID: clockid_t = 3; +pub const CLOCK_MONOTONIC: clockid_t = 4; +pub const CLOCK_MONOTONIC_RAW: clockid_t = 5; +pub const CLOCK_MONOTONIC_COARSE: clockid_t = 6; +pub const CLOCK_BOOTTIME: clockid_t = 7; +pub const CLOCK_REALTIME_ALARM: clockid_t = 8; +pub const CLOCK_BOOTTIME_ALARM: clockid_t = 9; + +pub const ITIMER_REAL: c_int = 0; +pub const ITIMER_VIRTUAL: c_int = 1; +pub const ITIMER_PROF: c_int = 2; + +pub const PRIO_PROCESS: c_int = 0; +pub const PRIO_PGRP: c_int = 1; +pub const PRIO_USER: c_int = 2; +pub const RLIMIT_CPU: c_int = 0; +pub const RLIMIT_FSIZE: c_int = 1; +pub const RLIMIT_DATA: c_int = 2; +pub const RLIMIT_STACK: c_int = 3; +pub const RLIMIT_CORE: c_int = 4; +pub const RLIMIT_NOFILE: c_int = 5; +pub const RLIMIT_AS: c_int = 6; +pub const RLIM_NLIMITS: c_int = 7; +pub const RLIMIT_NLIMITS: c_int = RLIM_NLIMITS; +pub const RLIM_INFINITY: rlim_t = !0; +pub const RLIM_SAVED_MAX: rlim_t = RLIM_INFINITY; +pub const RLIM_SAVED_CUR: rlim_t = RLIM_INFINITY; + +pub const RUSAGE_SELF: c_int = 0; +pub const RUSAGE_CHILDREN: c_int = -1; + +pub const IFF_UP: c_int = 0x1; // interface is up +pub const IFF_BROADCAST: c_int = 0x2; // broadcast address valid +pub const IFF_LOOPBACK: c_int = 0x8; // is a loopback net +pub const IFF_POINTOPOINT: c_int = 0x10; // interface is point-to-point link +pub const IFF_NOTRAILERS: c_int = 0x20; // avoid use of trailers +pub const IFF_RUNNING: c_int = 0x40; // resources allocated +pub const IFF_NOARP: c_int = 0x80; // no address resolution protocol +pub const IFF_PROMISC: c_int = 0x100; // receive all packets +pub const IFF_MULTICAST: c_int = 0x1000; // supports multicast +pub const IFF_LOWER_UP: c_int = 0x10000; // driver signals L1 up +pub const IFF_DORMANT: c_int = 0x20000; // driver signals dormant + +pub const IF_NAMESIZE: size_t = 44; +pub const IFNAMSIZ: size_t = IF_NAMESIZE; + +pub const FIONREAD: c_int = 0x4008667f; +pub const FIONBIO: c_int = 0x8004667e; +pub const FIOASYNC: c_int = 0x8008667d; +pub const FIOCLEX: c_int = 0; // FIXME: does not exist on Cygwin! +pub const SIOCGIFCONF: c_ulong = 0x80107364; +pub const SIOCGIFFLAGS: c_ulong = 0x80507365; +pub const SIOCGIFADDR: c_ulong = 0x80507366; +pub const SIOCGIFBRDADDR: c_ulong = 0x80507367; +pub const SIOCGIFNETMASK: c_ulong = 0x80507368; +pub const SIOCGIFHWADDR: c_ulong = 0x80507369; +pub const SIOCGIFMETRIC: c_ulong = 0x8050736a; +pub const SIOCGIFMTU: c_ulong = 0x8050736b; +pub const SIOCGIFINDEX: c_ulong = 0x8050736c; +pub const SIOGIFINDEX: c_ulong = SIOCGIFINDEX; +pub const SIOCGIFDSTADDR: c_ulong = 0x8050736e; +pub const SOL_SOCKET: c_int = 0xffff; +pub const SO_DEBUG: c_int = 1; +pub const SO_ACCEPTCONN: c_int = 0x0002; +pub const SO_REUSEADDR: c_int = 0x0004; +pub const SO_KEEPALIVE: c_int = 0x0008; +pub const SO_DONTROUTE: c_int = 0x0010; +pub const SO_BROADCAST: c_int = 0x0020; +pub const SO_USELOOPBACK: c_int = 0x0040; +pub const SO_LINGER: c_int = 0x0080; +pub const SO_OOBINLINE: c_int = 0x0100; +pub const SO_PEERCRED: c_int = 0x0200; +pub const SO_PASSCRED: c_int = 0x0400; +pub const SO_SNDBUF: c_int = 0x1001; +pub const SO_RCVBUF: c_int = 0x1002; +pub const SO_SNDLOWAT: c_int = 0x1003; +pub const SO_RCVLOWAT: c_int = 0x1004; +pub const SO_SNDTIMEO: c_int = 0x1005; +pub const SO_RCVTIMEO: c_int = 0x1006; +pub const SO_ERROR: c_int = 0x1007; +pub const SO_TYPE: c_int = 0x1008; + +pub const SCM_RIGHTS: c_int = 0x01; +pub const SCM_CREDENTIALS: c_int = 0x02; +pub const SOCK_STREAM: c_int = 1; +pub const SOCK_DGRAM: c_int = 2; +pub const SOCK_RAW: c_int = 3; +pub const SOCK_RDM: c_int = 4; +pub const SOCK_SEQPACKET: c_int = 5; +pub const SOCK_NONBLOCK: c_int = 0x01000000; +pub const SOCK_CLOEXEC: c_int = 0x02000000; +pub const AF_UNSPEC: c_int = 0; +pub const AF_LOCAL: c_int = 1; +pub const AF_UNIX: c_int = AF_LOCAL; +pub const AF_INET: c_int = 2; +pub const AF_IMPLINK: c_int = 3; +pub const AF_PUP: c_int = 4; +pub const AF_CHAOS: c_int = 5; +pub const AF_NS: c_int = 6; +pub const AF_ISO: c_int = 7; +pub const AF_OSI: c_int = AF_ISO; +pub const AF_ECMA: c_int = 8; +pub const AF_DATAKIT: c_int = 9; +pub const AF_CCITT: c_int = 10; +pub const AF_SNA: c_int = 11; +pub const AF_DECnet: c_int = 12; +pub const AF_DLI: c_int = 13; +pub const AF_LAT: c_int = 14; +pub const AF_HYLINK: c_int = 15; +pub const AF_APPLETALK: c_int = 16; +pub const AF_NETBIOS: c_int = 17; +pub const AF_INET6: c_int = 23; +pub const PF_UNSPEC: c_int = AF_UNSPEC; +pub const PF_LOCAL: c_int = AF_LOCAL; +pub const PF_UNIX: c_int = PF_LOCAL; +pub const PF_INET: c_int = AF_INET; +pub const PF_IMPLINK: c_int = AF_IMPLINK; +pub const PF_PUP: c_int = AF_PUP; +pub const PF_CHAOS: c_int = AF_CHAOS; +pub const PF_NS: c_int = AF_NS; +pub const PF_ISO: c_int = AF_ISO; +pub const PF_OSI: c_int = AF_ISO; +pub const PF_DATAKIT: c_int = AF_DATAKIT; +pub const PF_CCITT: c_int = AF_CCITT; +pub const PF_SNA: c_int = AF_SNA; +pub const PF_DECnet: c_int = AF_DECnet; +pub const PF_DLI: c_int = AF_DLI; +pub const PF_LAT: c_int = AF_LAT; +pub const PF_HYLINK: c_int = AF_HYLINK; +pub const PF_APPLETALK: c_int = AF_APPLETALK; +pub const PF_NETBIOS: c_int = AF_NETBIOS; +pub const PF_INET6: c_int = AF_INET6; +pub const SOMAXCONN: c_int = 0x7fffffff; +pub const MSG_OOB: c_int = 0x1; +pub const MSG_PEEK: c_int = 0x2; +pub const MSG_DONTROUTE: c_int = 0x4; +pub const MSG_WAITALL: c_int = 0x8; +pub const MSG_DONTWAIT: c_int = 0x10; +pub const MSG_NOSIGNAL: c_int = 0x20; +pub const MSG_TRUNC: c_int = 0x0100; +pub const MSG_CTRUNC: c_int = 0x0200; +pub const MSG_BCAST: c_int = 0x0400; +pub const MSG_MCAST: c_int = 0x0800; +pub const MSG_CMSG_CLOEXEC: c_int = 0x1000; +pub const MSG_EOR: c_int = 0x8000; +pub const SOL_IP: c_int = 0; +pub const SOL_IPV6: c_int = 41; +pub const SOL_TCP: c_int = 6; +pub const SOL_UDP: c_int = 17; +pub const IPTOS_LOWDELAY: u8 = 0x10; +pub const IPTOS_THROUGHPUT: u8 = 0x08; +pub const IPTOS_RELIABILITY: u8 = 0x04; +pub const IPTOS_LOWCOST: u8 = 0x02; +pub const IPTOS_MINCOST: u8 = IPTOS_LOWCOST; +pub const IP_DEFAULT_MULTICAST_TTL: c_int = 1; +pub const IP_DEFAULT_MULTICAST_LOOP: c_int = 1; +pub const IP_OPTIONS: c_int = 1; +pub const IP_HDRINCL: c_int = 2; +pub const IP_TOS: c_int = 3; +pub const IP_TTL: c_int = 4; +pub const IP_MULTICAST_IF: c_int = 9; +pub const IP_MULTICAST_TTL: c_int = 10; +pub const IP_MULTICAST_LOOP: c_int = 11; +pub const IP_ADD_MEMBERSHIP: c_int = 12; +pub const IP_DROP_MEMBERSHIP: c_int = 13; +pub const IP_ADD_SOURCE_MEMBERSHIP: c_int = 15; +pub const IP_DROP_SOURCE_MEMBERSHIP: c_int = 16; +pub const IP_BLOCK_SOURCE: c_int = 17; +pub const IP_UNBLOCK_SOURCE: c_int = 18; +pub const IP_PKTINFO: c_int = 19; +pub const IP_RECVTTL: c_int = 21; +pub const IP_UNICAST_IF: c_int = 31; +pub const IP_RECVTOS: c_int = 40; +pub const IP_MTU_DISCOVER: c_int = 71; +pub const IP_MTU: c_int = 73; +pub const IP_RECVERR: c_int = 75; +pub const IP_PMTUDISC_WANT: c_int = 0; +pub const IP_PMTUDISC_DO: c_int = 1; +pub const IP_PMTUDISC_DONT: c_int = 2; +pub const IP_PMTUDISC_PROBE: c_int = 3; +pub const IPV6_HOPOPTS: c_int = 1; +pub const IPV6_HDRINCL: c_int = 2; +pub const IPV6_UNICAST_HOPS: c_int = 4; +pub const IPV6_MULTICAST_IF: c_int = 9; +pub const IPV6_MULTICAST_HOPS: c_int = 10; +pub const IPV6_MULTICAST_LOOP: c_int = 11; +pub const IPV6_ADD_MEMBERSHIP: c_int = 12; +pub const IPV6_DROP_MEMBERSHIP: c_int = 13; +pub const IPV6_JOIN_GROUP: c_int = 12; +pub const IPV6_LEAVE_GROUP: c_int = 13; +pub const IPV6_DONTFRAG: c_int = 14; +pub const IPV6_PKTINFO: c_int = 19; +pub const IPV6_HOPLIMIT: c_int = 21; +pub const IPV6_CHECKSUM: c_int = 26; +pub const IPV6_V6ONLY: c_int = 27; +pub const IPV6_UNICAST_IF: c_int = 31; +pub const IPV6_RTHDR: c_int = 32; +pub const IPV6_RECVRTHDR: c_int = 38; +pub const IPV6_TCLASS: c_int = 39; +pub const IPV6_RECVTCLASS: c_int = 40; +pub const IPV6_MTU_DISCOVER: c_int = 71; +pub const IPV6_MTU: c_int = 72; +pub const IPV6_RECVERR: c_int = 75; +pub const IPV6_PMTUDISC_WANT: c_int = 0; +pub const IPV6_PMTUDISC_DO: c_int = 1; +pub const IPV6_PMTUDISC_DONT: c_int = 2; +pub const IPV6_PMTUDISC_PROBE: c_int = 3; +pub const MCAST_JOIN_GROUP: c_int = 41; +pub const MCAST_LEAVE_GROUP: c_int = 42; +pub const MCAST_BLOCK_SOURCE: c_int = 43; +pub const MCAST_UNBLOCK_SOURCE: c_int = 44; +pub const MCAST_JOIN_SOURCE_GROUP: c_int = 45; +pub const MCAST_LEAVE_SOURCE_GROUP: c_int = 46; +pub const MCAST_INCLUDE: c_int = 0; +pub const MCAST_EXCLUDE: c_int = 1; +pub const SHUT_RD: c_int = 0; +pub const SHUT_WR: c_int = 1; +pub const SHUT_RDWR: c_int = 2; + +pub const S_BLKSIZE: mode_t = 1024; +pub const S_IREAD: mode_t = 256; +pub const S_IWRITE: mode_t = 128; +pub const S_IEXEC: mode_t = 64; +pub const S_ENFMT: mode_t = 1024; +pub const S_IFMT: mode_t = 61440; +pub const S_IFDIR: mode_t = 16384; +pub const S_IFCHR: mode_t = 8192; +pub const S_IFBLK: mode_t = 24576; +pub const S_IFREG: mode_t = 32768; +pub const S_IFLNK: mode_t = 40960; +pub const S_IFSOCK: mode_t = 49152; +pub const S_IFIFO: mode_t = 4096; +pub const S_IRWXU: mode_t = 448; +pub const S_IRUSR: mode_t = 256; +pub const S_IWUSR: mode_t = 128; +pub const S_IXUSR: mode_t = 64; +pub const S_IRWXG: mode_t = 56; +pub const S_IRGRP: mode_t = 32; +pub const S_IWGRP: mode_t = 16; +pub const S_IXGRP: mode_t = 8; +pub const S_IRWXO: mode_t = 7; +pub const S_IROTH: mode_t = 4; +pub const S_IWOTH: mode_t = 2; +pub const S_IXOTH: mode_t = 1; +pub const UTIME_NOW: c_long = -2; +pub const UTIME_OMIT: c_long = -1; + +pub const ARG_MAX: c_int = 32000; +pub const CHILD_MAX: c_int = 256; +pub const IOV_MAX: c_int = 1024; +pub const PTHREAD_STACK_MIN: size_t = 65536; +pub const PATH_MAX: c_int = 4096; +pub const PIPE_BUF: usize = 4096; +pub const NGROUPS_MAX: c_int = 1024; + +pub const FILENAME_MAX: c_int = 4096; + +pub const FORK_RELOAD: c_int = 1; +pub const FORK_NO_RELOAD: c_int = 0; + +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); +pub const RTLD_LOCAL: c_int = 0; +pub const RTLD_LAZY: c_int = 1; +pub const RTLD_NOW: c_int = 2; +pub const RTLD_GLOBAL: c_int = 4; +pub const RTLD_NODELETE: c_int = 8; +pub const RTLD_NOLOAD: c_int = 16; +pub const RTLD_DEEPBIND: c_int = 32; + +/// IP6 hop-by-hop options +pub const IPPROTO_HOPOPTS: c_int = 0; + +/// gateway mgmt protocol +pub const IPPROTO_IGMP: c_int = 2; + +/// IPIP tunnels (older KA9Q tunnels use 94) +pub const IPPROTO_IPIP: c_int = 4; + +/// exterior gateway protocol +pub const IPPROTO_EGP: c_int = 8; + +/// pup +pub const IPPROTO_PUP: c_int = 12; + +/// xns idp +pub const IPPROTO_IDP: c_int = 22; + +/// IP6 routing header +pub const IPPROTO_ROUTING: c_int = 43; + +/// IP6 fragmentation header +pub const IPPROTO_FRAGMENT: c_int = 44; + +/// IP6 Encap Sec. Payload +pub const IPPROTO_ESP: c_int = 50; + +/// IP6 Auth Header +pub const IPPROTO_AH: c_int = 51; + +/// IP6 no next header +pub const IPPROTO_NONE: c_int = 59; + +/// IP6 destination option +pub const IPPROTO_DSTOPTS: c_int = 60; + +pub const IPPROTO_RAW: c_int = 255; +pub const IPPROTO_MAX: c_int = 256; + +pub const AI_PASSIVE: c_int = 0x1; +pub const AI_CANONNAME: c_int = 0x2; +pub const AI_NUMERICHOST: c_int = 0x4; +pub const AI_NUMERICSERV: c_int = 0x8; +pub const AI_ALL: c_int = 0x100; +pub const AI_ADDRCONFIG: c_int = 0x400; +pub const AI_V4MAPPED: c_int = 0x800; +pub const NI_NOFQDN: c_int = 0x1; +pub const NI_NUMERICHOST: c_int = 0x2; +pub const NI_NAMEREQD: c_int = 0x4; +pub const NI_NUMERICSERV: c_int = 0x8; +pub const NI_DGRAM: c_int = 0x10; +pub const NI_MAXHOST: c_int = 1025; +pub const NI_MAXSERV: c_int = 32; +pub const EAI_AGAIN: c_int = 2; +pub const EAI_BADFLAGS: c_int = 3; +pub const EAI_FAIL: c_int = 4; +pub const EAI_FAMILY: c_int = 5; +pub const EAI_MEMORY: c_int = 6; +pub const EAI_NODATA: c_int = 7; +pub const EAI_NONAME: c_int = 8; +pub const EAI_SERVICE: c_int = 9; +pub const EAI_SOCKTYPE: c_int = 10; +pub const EAI_SYSTEM: c_int = 11; +pub const EAI_OVERFLOW: c_int = 14; + +pub const UT_LINESIZE: usize = 16; +pub const UT_NAMESIZE: usize = 16; +pub const UT_HOSTSIZE: usize = 256; +pub const UT_IDLEN: usize = 2; +pub const RUN_LVL: c_short = 1; +pub const BOOT_TIME: c_short = 2; +pub const NEW_TIME: c_short = 3; +pub const OLD_TIME: c_short = 4; +pub const INIT_PROCESS: c_short = 5; +pub const LOGIN_PROCESS: c_short = 6; +pub const USER_PROCESS: c_short = 7; +pub const DEAD_PROCESS: c_short = 8; + +pub const POLLIN: c_short = 0x1; +pub const POLLPRI: c_short = 0x2; +pub const POLLOUT: c_short = 0x4; +pub const POLLERR: c_short = 0x8; +pub const POLLHUP: c_short = 0x10; +pub const POLLNVAL: c_short = 0x20; +pub const POLLRDNORM: c_short = 0x1; +pub const POLLRDBAND: c_short = 0x2; +pub const POLLWRNORM: c_short = 0x4; +pub const POLLWRBAND: c_short = 0x4; + +pub const LC_ALL: c_int = 0; +pub const LC_COLLATE: c_int = 1; +pub const LC_CTYPE: c_int = 2; +pub const LC_MONETARY: c_int = 3; +pub const LC_NUMERIC: c_int = 4; +pub const LC_TIME: c_int = 5; +pub const LC_MESSAGES: c_int = 6; +pub const LC_ALL_MASK: c_int = 1 << 0; +pub const LC_COLLATE_MASK: c_int = 1 << 1; +pub const LC_CTYPE_MASK: c_int = 1 << 2; +pub const LC_MONETARY_MASK: c_int = 1 << 3; +pub const LC_NUMERIC_MASK: c_int = 1 << 4; +pub const LC_TIME_MASK: c_int = 1 << 5; +pub const LC_MESSAGES_MASK: c_int = 1 << 6; +pub const LC_GLOBAL_LOCALE: locale_t = -1isize as locale_t; + +pub const SEM_FAILED: *mut sem_t = core::ptr::null_mut(); + +pub const ST_RDONLY: c_ulong = 0x80000; +pub const ST_NOSUID: c_ulong = 0; + +pub const TIOCMGET: c_int = 0x5415; +pub const TIOCMBIS: c_int = 0x5416; +pub const TIOCMBIC: c_int = 0x5417; +pub const TIOCMSET: c_int = 0x5418; +pub const TIOCINQ: c_int = 0x541B; +pub const TIOCSCTTY: c_int = 0x540E; +pub const TIOCSBRK: c_int = 0x5427; +pub const TIOCCBRK: c_int = 0x5428; +pub const TIOCM_DTR: c_int = 0x002; +pub const TIOCM_RTS: c_int = 0x004; +pub const TIOCM_CTS: c_int = 0x020; +pub const TIOCM_CAR: c_int = 0x040; +pub const TIOCM_RNG: c_int = 0x080; +pub const TIOCM_DSR: c_int = 0x100; +pub const TIOCM_CD: c_int = TIOCM_CAR; +pub const TIOCM_RI: c_int = TIOCM_RNG; +pub const TCOOFF: c_int = 0; +pub const TCOON: c_int = 1; +pub const TCIOFF: c_int = 2; +pub const TCION: c_int = 3; +pub const TCGETA: c_int = 5; +pub const TCSETA: c_int = 6; +pub const TCSETAW: c_int = 7; +pub const TCSETAF: c_int = 8; +pub const TCIFLUSH: c_int = 0; +pub const TCOFLUSH: c_int = 1; +pub const TCIOFLUSH: c_int = 2; +pub const TCFLSH: c_int = 3; +pub const TCSAFLUSH: c_int = 1; +pub const TCSANOW: c_int = 2; +pub const TCSADRAIN: c_int = 3; +pub const TIOCPKT: c_int = 6; +pub const TIOCPKT_DATA: c_int = 0x0; +pub const TIOCPKT_FLUSHREAD: c_int = 0x1; +pub const TIOCPKT_FLUSHWRITE: c_int = 0x2; +pub const TIOCPKT_STOP: c_int = 0x4; +pub const TIOCPKT_START: c_int = 0x8; +pub const TIOCPKT_NOSTOP: c_int = 0x10; +pub const TIOCPKT_DOSTOP: c_int = 0x20; +pub const IGNBRK: tcflag_t = 0x00001; +pub const BRKINT: tcflag_t = 0x00002; +pub const IGNPAR: tcflag_t = 0x00004; +pub const IMAXBEL: tcflag_t = 0x00008; +pub const INPCK: tcflag_t = 0x00010; +pub const ISTRIP: tcflag_t = 0x00020; +pub const INLCR: tcflag_t = 0x00040; +pub const IGNCR: tcflag_t = 0x00080; +pub const ICRNL: tcflag_t = 0x00100; +pub const IXON: tcflag_t = 0x00400; +pub const IXOFF: tcflag_t = 0x01000; +pub const IUCLC: tcflag_t = 0x04000; +pub const IXANY: tcflag_t = 0x08000; +pub const PARMRK: tcflag_t = 0x10000; +pub const IUTF8: tcflag_t = 0x20000; +pub const OPOST: tcflag_t = 0x00001; +pub const OLCUC: tcflag_t = 0x00002; +pub const OCRNL: tcflag_t = 0x00004; +pub const ONLCR: tcflag_t = 0x00008; +pub const ONOCR: tcflag_t = 0x00010; +pub const ONLRET: tcflag_t = 0x00020; +pub const OFILL: tcflag_t = 0x00040; +pub const CRDLY: tcflag_t = 0x00180; +pub const CR0: tcflag_t = 0x00000; +pub const CR1: tcflag_t = 0x00080; +pub const CR2: tcflag_t = 0x00100; +pub const CR3: tcflag_t = 0x00180; +pub const NLDLY: tcflag_t = 0x00200; +pub const NL0: tcflag_t = 0x00000; +pub const NL1: tcflag_t = 0x00200; +pub const BSDLY: tcflag_t = 0x00400; +pub const BS0: tcflag_t = 0x00000; +pub const BS1: tcflag_t = 0x00400; +pub const TABDLY: tcflag_t = 0x01800; +pub const TAB0: tcflag_t = 0x00000; +pub const TAB1: tcflag_t = 0x00800; +pub const TAB2: tcflag_t = 0x01000; +pub const TAB3: tcflag_t = 0x01800; +pub const XTABS: tcflag_t = 0x01800; +pub const VTDLY: tcflag_t = 0x02000; +pub const VT0: tcflag_t = 0x00000; +pub const VT1: tcflag_t = 0x02000; +pub const FFDLY: tcflag_t = 0x04000; +pub const FF0: tcflag_t = 0x00000; +pub const FF1: tcflag_t = 0x04000; +pub const OFDEL: tcflag_t = 0x08000; +pub const CBAUD: tcflag_t = 0x0100f; +pub const B0: speed_t = 0x00000; +pub const B50: speed_t = 0x00001; +pub const B75: speed_t = 0x00002; +pub const B110: speed_t = 0x00003; +pub const B134: speed_t = 0x00004; +pub const B150: speed_t = 0x00005; +pub const B200: speed_t = 0x00006; +pub const B300: speed_t = 0x00007; +pub const B600: speed_t = 0x00008; +pub const B1200: speed_t = 0x00009; +pub const B1800: speed_t = 0x0000a; +pub const B2400: speed_t = 0x0000b; +pub const B4800: speed_t = 0x0000c; +pub const B9600: speed_t = 0x0000d; +pub const B19200: speed_t = 0x0000e; +pub const B38400: speed_t = 0x0000f; +pub const CSIZE: tcflag_t = 0x00030; +pub const CS5: tcflag_t = 0x00000; +pub const CS6: tcflag_t = 0x00010; +pub const CS7: tcflag_t = 0x00020; +pub const CS8: tcflag_t = 0x00030; +pub const CSTOPB: tcflag_t = 0x00040; +pub const CREAD: tcflag_t = 0x00080; +pub const PARENB: tcflag_t = 0x00100; +pub const PARODD: tcflag_t = 0x00200; +pub const HUPCL: tcflag_t = 0x00400; +pub const CLOCAL: tcflag_t = 0x00800; +pub const CBAUDEX: tcflag_t = 0x0100f; +pub const B57600: speed_t = 0x01001; +pub const B115200: speed_t = 0x01002; +pub const B230400: speed_t = 0x01004; +pub const B460800: speed_t = 0x01006; +pub const B500000: speed_t = 0x01007; +pub const B576000: speed_t = 0x01008; +pub const B921600: speed_t = 0x01009; +pub const B1000000: speed_t = 0x0100a; +pub const B1152000: speed_t = 0x0100b; +pub const B1500000: speed_t = 0x0100c; +pub const B2000000: speed_t = 0x0100d; +pub const B2500000: speed_t = 0x0100e; +pub const B3000000: speed_t = 0x0100f; +pub const CRTSCTS: tcflag_t = 0x08000; +pub const CMSPAR: tcflag_t = 0x40000000; +pub const ISIG: tcflag_t = 0x0001; +pub const ICANON: tcflag_t = 0x0002; +pub const ECHO: tcflag_t = 0x0004; +pub const ECHOE: tcflag_t = 0x0008; +pub const ECHOK: tcflag_t = 0x0010; +pub const ECHONL: tcflag_t = 0x0020; +pub const NOFLSH: tcflag_t = 0x0040; +pub const TOSTOP: tcflag_t = 0x0080; +pub const IEXTEN: tcflag_t = 0x0100; +pub const FLUSHO: tcflag_t = 0x0200; +pub const ECHOKE: tcflag_t = 0x0400; +pub const ECHOCTL: tcflag_t = 0x0800; +pub const VDISCARD: usize = 1; +pub const VEOL: usize = 2; +pub const VEOL2: usize = 3; +pub const VEOF: usize = 4; +pub const VERASE: usize = 5; +pub const VINTR: usize = 6; +pub const VKILL: usize = 7; +pub const VLNEXT: usize = 8; +pub const VMIN: usize = 9; +pub const VQUIT: usize = 10; +pub const VREPRINT: usize = 11; +pub const VSTART: usize = 12; +pub const VSTOP: usize = 13; +pub const VSUSP: usize = 14; +pub const VSWTC: usize = 15; +pub const VTIME: usize = 16; +pub const VWERASE: usize = 17; +pub const NCCS: usize = 18; + +pub const TIOCGWINSZ: c_int = 0x5401; +pub const TIOCSWINSZ: c_int = 0x5402; +pub const TIOCLINUX: c_int = 0x5403; +pub const TIOCGPGRP: c_int = 0x540f; +pub const TIOCSPGRP: c_int = 0x5410; + +pub const WNOHANG: c_int = 1; +pub const WUNTRACED: c_int = 2; +pub const WCONTINUED: c_int = 8; + +pub const EXIT_FAILURE: c_int = 1; +pub const EXIT_SUCCESS: c_int = 0; + +pub const PROT_NONE: c_int = 0; +pub const PROT_READ: c_int = 1; +pub const PROT_WRITE: c_int = 2; +pub const PROT_EXEC: c_int = 4; +pub const MAP_FILE: c_int = 0; +pub const MAP_SHARED: c_int = 1; +pub const MAP_PRIVATE: c_int = 2; +pub const MAP_TYPE: c_int = 0xf; +pub const MAP_FIXED: c_int = 0x10; +pub const MAP_ANON: c_int = 0x20; +pub const MAP_ANONYMOUS: c_int = MAP_ANON; +pub const MAP_NORESERVE: c_int = 0x4000; +pub const MAP_FAILED: *mut c_void = !0 as *mut c_void; +pub const MS_ASYNC: c_int = 1; +pub const MS_SYNC: c_int = 2; +pub const MS_INVALIDATE: c_int = 4; +pub const POSIX_MADV_NORMAL: c_int = 0; +pub const POSIX_MADV_SEQUENTIAL: c_int = 1; +pub const POSIX_MADV_RANDOM: c_int = 2; +pub const POSIX_MADV_WILLNEED: c_int = 3; +pub const POSIX_MADV_DONTNEED: c_int = 4; +pub const MADV_NORMAL: c_int = 0; +pub const MADV_SEQUENTIAL: c_int = 1; +pub const MADV_RANDOM: c_int = 2; +pub const MADV_WILLNEED: c_int = 3; +pub const MADV_DONTNEED: c_int = 4; + +pub const F_ULOCK: c_int = 0; +pub const F_LOCK: c_int = 1; +pub const F_TLOCK: c_int = 2; +pub const F_TEST: c_int = 3; + +pub const F_OK: c_int = 0; +pub const R_OK: c_int = 4; +pub const W_OK: c_int = 2; +pub const X_OK: c_int = 1; +pub const SEEK_SET: c_int = 0; +pub const SEEK_CUR: c_int = 1; +pub const SEEK_END: c_int = 2; +pub const _SC_ARG_MAX: c_int = 0; +pub const _SC_CHILD_MAX: c_int = 1; +pub const _SC_CLK_TCK: c_int = 2; +pub const _SC_NGROUPS_MAX: c_int = 3; +pub const _SC_OPEN_MAX: c_int = 4; +pub const _SC_JOB_CONTROL: c_int = 5; +pub const _SC_SAVED_IDS: c_int = 6; +pub const _SC_VERSION: c_int = 7; +pub const _SC_PAGESIZE: c_int = 8; +pub const _SC_PAGE_SIZE: c_int = _SC_PAGESIZE; +pub const _SC_NPROCESSORS_CONF: c_int = 9; +pub const _SC_NPROCESSORS_ONLN: c_int = 10; +pub const _SC_PHYS_PAGES: c_int = 11; +pub const _SC_AVPHYS_PAGES: c_int = 12; +pub const _SC_MQ_OPEN_MAX: c_int = 13; +pub const _SC_MQ_PRIO_MAX: c_int = 14; +pub const _SC_RTSIG_MAX: c_int = 15; +pub const _SC_SEM_NSEMS_MAX: c_int = 16; +pub const _SC_SEM_VALUE_MAX: c_int = 17; +pub const _SC_SIGQUEUE_MAX: c_int = 18; +pub const _SC_TIMER_MAX: c_int = 19; +pub const _SC_TZNAME_MAX: c_int = 20; +pub const _SC_ASYNCHRONOUS_IO: c_int = 21; +pub const _SC_FSYNC: c_int = 22; +pub const _SC_MAPPED_FILES: c_int = 23; +pub const _SC_MEMLOCK: c_int = 24; +pub const _SC_MEMLOCK_RANGE: c_int = 25; +pub const _SC_MEMORY_PROTECTION: c_int = 26; +pub const _SC_MESSAGE_PASSING: c_int = 27; +pub const _SC_PRIORITIZED_IO: c_int = 28; +pub const _SC_REALTIME_SIGNALS: c_int = 29; +pub const _SC_SEMAPHORES: c_int = 30; +pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 31; +pub const _SC_SYNCHRONIZED_IO: c_int = 32; +pub const _SC_TIMERS: c_int = 33; +pub const _SC_AIO_LISTIO_MAX: c_int = 34; +pub const _SC_AIO_MAX: c_int = 35; +pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 36; +pub const _SC_DELAYTIMER_MAX: c_int = 37; +pub const _SC_THREAD_KEYS_MAX: c_int = 38; +pub const _SC_THREAD_STACK_MIN: c_int = 39; +pub const _SC_THREAD_THREADS_MAX: c_int = 40; +pub const _SC_TTY_NAME_MAX: c_int = 41; +pub const _SC_THREADS: c_int = 42; +pub const _SC_THREAD_ATTR_STACKADDR: c_int = 43; +pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 44; +pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 45; +pub const _SC_THREAD_PRIO_INHERIT: c_int = 46; +pub const _SC_THREAD_PRIO_PROTECT: c_int = 47; +pub const _SC_THREAD_PRIO_CEILING: c_int = _SC_THREAD_PRIO_PROTECT; +pub const _SC_THREAD_PROCESS_SHARED: c_int = 48; +pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 49; +pub const _SC_GETGR_R_SIZE_MAX: c_int = 50; +pub const _SC_GETPW_R_SIZE_MAX: c_int = 51; +pub const _SC_LOGIN_NAME_MAX: c_int = 52; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 53; +pub const _SC_ADVISORY_INFO: c_int = 54; +pub const _SC_ATEXIT_MAX: c_int = 55; +pub const _SC_BARRIERS: c_int = 56; +pub const _SC_BC_BASE_MAX: c_int = 57; +pub const _SC_BC_DIM_MAX: c_int = 58; +pub const _SC_BC_SCALE_MAX: c_int = 59; +pub const _SC_BC_STRING_MAX: c_int = 60; +pub const _SC_CLOCK_SELECTION: c_int = 61; +pub const _SC_COLL_WEIGHTS_MAX: c_int = 62; +pub const _SC_CPUTIME: c_int = 63; +pub const _SC_EXPR_NEST_MAX: c_int = 64; +pub const _SC_HOST_NAME_MAX: c_int = 65; +pub const _SC_IOV_MAX: c_int = 66; +pub const _SC_IPV6: c_int = 67; +pub const _SC_LINE_MAX: c_int = 68; +pub const _SC_MONOTONIC_CLOCK: c_int = 69; +pub const _SC_RAW_SOCKETS: c_int = 70; +pub const _SC_READER_WRITER_LOCKS: c_int = 71; +pub const _SC_REGEXP: c_int = 72; +pub const _SC_RE_DUP_MAX: c_int = 73; +pub const _SC_SHELL: c_int = 74; +pub const _SC_SPAWN: c_int = 75; +pub const _SC_SPIN_LOCKS: c_int = 76; +pub const _SC_SPORADIC_SERVER: c_int = 77; +pub const _SC_SS_REPL_MAX: c_int = 78; +pub const _SC_SYMLOOP_MAX: c_int = 79; +pub const _SC_THREAD_CPUTIME: c_int = 80; +pub const _SC_THREAD_SPORADIC_SERVER: c_int = 81; +pub const _SC_TIMEOUTS: c_int = 82; +pub const _SC_TRACE: c_int = 83; +pub const _SC_TRACE_EVENT_FILTER: c_int = 84; +pub const _SC_TRACE_EVENT_NAME_MAX: c_int = 85; +pub const _SC_TRACE_INHERIT: c_int = 86; +pub const _SC_TRACE_LOG: c_int = 87; +pub const _SC_TRACE_NAME_MAX: c_int = 88; +pub const _SC_TRACE_SYS_MAX: c_int = 89; +pub const _SC_TRACE_USER_EVENT_MAX: c_int = 90; +pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 91; +pub const _SC_V7_ILP32_OFF32: c_int = 92; +pub const _SC_V6_ILP32_OFF32: c_int = _SC_V7_ILP32_OFF32; +pub const _SC_XBS5_ILP32_OFF32: c_int = _SC_V7_ILP32_OFF32; +pub const _SC_V7_ILP32_OFFBIG: c_int = 93; +pub const _SC_V6_ILP32_OFFBIG: c_int = _SC_V7_ILP32_OFFBIG; +pub const _SC_XBS5_ILP32_OFFBIG: c_int = _SC_V7_ILP32_OFFBIG; +pub const _SC_V7_LP64_OFF64: c_int = 94; +pub const _SC_V6_LP64_OFF64: c_int = _SC_V7_LP64_OFF64; +pub const _SC_XBS5_LP64_OFF64: c_int = _SC_V7_LP64_OFF64; +pub const _SC_V7_LPBIG_OFFBIG: c_int = 95; +pub const _SC_V6_LPBIG_OFFBIG: c_int = _SC_V7_LPBIG_OFFBIG; +pub const _SC_XBS5_LPBIG_OFFBIG: c_int = _SC_V7_LPBIG_OFFBIG; +pub const _SC_XOPEN_CRYPT: c_int = 96; +pub const _SC_XOPEN_ENH_I18N: c_int = 97; +pub const _SC_XOPEN_LEGACY: c_int = 98; +pub const _SC_XOPEN_REALTIME: c_int = 99; +pub const _SC_STREAM_MAX: c_int = 100; +pub const _SC_PRIORITY_SCHEDULING: c_int = 101; +pub const _SC_XOPEN_REALTIME_THREADS: c_int = 102; +pub const _SC_XOPEN_SHM: c_int = 103; +pub const _SC_XOPEN_STREAMS: c_int = 104; +pub const _SC_XOPEN_UNIX: c_int = 105; +pub const _SC_XOPEN_VERSION: c_int = 106; +pub const _SC_2_CHAR_TERM: c_int = 107; +pub const _SC_2_C_BIND: c_int = 108; +pub const _SC_2_C_DEV: c_int = 109; +pub const _SC_2_FORT_DEV: c_int = 110; +pub const _SC_2_FORT_RUN: c_int = 111; +pub const _SC_2_LOCALEDEF: c_int = 112; +pub const _SC_2_PBS: c_int = 113; +pub const _SC_2_PBS_ACCOUNTING: c_int = 114; +pub const _SC_2_PBS_CHECKPOINT: c_int = 115; +pub const _SC_2_PBS_LOCATE: c_int = 116; +pub const _SC_2_PBS_MESSAGE: c_int = 117; +pub const _SC_2_PBS_TRACK: c_int = 118; +pub const _SC_2_SW_DEV: c_int = 119; +pub const _SC_2_UPE: c_int = 120; +pub const _SC_2_VERSION: c_int = 121; +pub const _SC_THREAD_ROBUST_PRIO_INHERIT: c_int = 122; +pub const _SC_THREAD_ROBUST_PRIO_PROTECT: c_int = 123; +pub const _SC_XOPEN_UUCP: c_int = 124; +pub const _SC_LEVEL1_ICACHE_SIZE: c_int = 125; +pub const _SC_LEVEL1_ICACHE_ASSOC: c_int = 126; +pub const _SC_LEVEL1_ICACHE_LINESIZE: c_int = 127; +pub const _SC_LEVEL1_DCACHE_SIZE: c_int = 128; +pub const _SC_LEVEL1_DCACHE_ASSOC: c_int = 129; +pub const _SC_LEVEL1_DCACHE_LINESIZE: c_int = 130; +pub const _SC_LEVEL2_CACHE_SIZE: c_int = 131; +pub const _SC_LEVEL2_CACHE_ASSOC: c_int = 132; +pub const _SC_LEVEL2_CACHE_LINESIZE: c_int = 133; +pub const _SC_LEVEL3_CACHE_SIZE: c_int = 134; +pub const _SC_LEVEL3_CACHE_ASSOC: c_int = 135; +pub const _SC_LEVEL3_CACHE_LINESIZE: c_int = 136; +pub const _SC_LEVEL4_CACHE_SIZE: c_int = 137; +pub const _SC_LEVEL4_CACHE_ASSOC: c_int = 138; +pub const _SC_LEVEL4_CACHE_LINESIZE: c_int = 139; +pub const _PC_LINK_MAX: c_int = 0; +pub const _PC_MAX_CANON: c_int = 1; +pub const _PC_MAX_INPUT: c_int = 2; +pub const _PC_NAME_MAX: c_int = 3; +pub const _PC_PATH_MAX: c_int = 4; +pub const _PC_PIPE_BUF: c_int = 5; +pub const _PC_CHOWN_RESTRICTED: c_int = 6; +pub const _PC_NO_TRUNC: c_int = 7; +pub const _PC_VDISABLE: c_int = 8; +pub const _PC_ASYNC_IO: c_int = 9; +pub const _PC_PRIO_IO: c_int = 10; +pub const _PC_SYNC_IO: c_int = 11; +pub const _PC_FILESIZEBITS: c_int = 12; +pub const _PC_2_SYMLINKS: c_int = 13; +pub const _PC_SYMLINK_MAX: c_int = 14; +pub const _PC_ALLOC_SIZE_MIN: c_int = 15; +pub const _PC_REC_INCR_XFER_SIZE: c_int = 16; +pub const _PC_REC_MAX_XFER_SIZE: c_int = 17; +pub const _PC_REC_MIN_XFER_SIZE: c_int = 18; +pub const _PC_REC_XFER_ALIGN: c_int = 19; +pub const _PC_TIMESTAMP_RESOLUTION: c_int = 20; +pub const _CS_PATH: c_int = 0; + +pub const O_ACCMODE: c_int = 0x3; +pub const O_RDONLY: c_int = 0; +pub const O_WRONLY: c_int = 1; +pub const O_RDWR: c_int = 2; +pub const O_APPEND: c_int = 0x0008; +pub const O_CREAT: c_int = 0x0200; +pub const O_TRUNC: c_int = 0x0400; +pub const O_EXCL: c_int = 0x0800; +pub const O_SYNC: c_int = 0x2000; +pub const O_NONBLOCK: c_int = 0x4000; +pub const O_NOCTTY: c_int = 0x8000; +pub const O_CLOEXEC: c_int = 0x40000; +pub const O_NOFOLLOW: c_int = 0x100000; +pub const O_DIRECTORY: c_int = 0x200000; +pub const O_EXEC: c_int = 0x400000; +pub const O_SEARCH: c_int = 0x400000; +pub const O_DIRECT: c_int = 0x80000; +pub const O_DSYNC: c_int = 0x2000; +pub const O_RSYNC: c_int = 0x2000; +pub const O_TMPFILE: c_int = 0x800000; +pub const O_NOATIME: c_int = 0x1000000; +pub const O_PATH: c_int = 0x2000000; +pub const F_DUPFD: c_int = 0; +pub const F_GETFD: c_int = 1; +pub const F_SETFD: c_int = 2; +pub const F_GETFL: c_int = 3; +pub const F_SETFL: c_int = 4; +pub const F_GETOWN: c_int = 5; +pub const F_SETOWN: c_int = 6; +pub const F_GETLK: c_int = 7; +pub const F_SETLK: c_int = 8; +pub const F_SETLKW: c_int = 9; +pub const F_RGETLK: c_int = 10; +pub const F_RSETLK: c_int = 11; +pub const F_CNVT: c_int = 12; +pub const F_RSETLKW: c_int = 13; +pub const F_DUPFD_CLOEXEC: c_int = 14; +pub const F_RDLCK: c_int = 1; +pub const F_WRLCK: c_int = 2; +pub const F_UNLCK: c_int = 3; +pub const AT_FDCWD: c_int = -2; +pub const AT_EACCESS: c_int = 1; +pub const AT_SYMLINK_NOFOLLOW: c_int = 2; +pub const AT_SYMLINK_FOLLOW: c_int = 4; +pub const AT_REMOVEDIR: c_int = 8; +pub const AT_EMPTY_PATH: c_int = 16; +pub const LOCK_SH: c_int = 1; +pub const LOCK_EX: c_int = 2; +pub const LOCK_NB: c_int = 4; +pub const LOCK_UN: c_int = 8; + +pub const EPERM: c_int = 1; +pub const ENOENT: c_int = 2; +pub const ESRCH: c_int = 3; +pub const EINTR: c_int = 4; +pub const EIO: c_int = 5; +pub const ENXIO: c_int = 6; +pub const E2BIG: c_int = 7; +pub const ENOEXEC: c_int = 8; +pub const EBADF: c_int = 9; +pub const ECHILD: c_int = 10; +pub const EAGAIN: c_int = 11; +pub const ENOMEM: c_int = 12; +pub const EACCES: c_int = 13; +pub const EFAULT: c_int = 14; +pub const ENOTBLK: c_int = 15; +pub const EBUSY: c_int = 16; +pub const EEXIST: c_int = 17; +pub const EXDEV: c_int = 18; +pub const ENODEV: c_int = 19; +pub const ENOTDIR: c_int = 20; +pub const EISDIR: c_int = 21; +pub const EINVAL: c_int = 22; +pub const ENFILE: c_int = 23; +pub const EMFILE: c_int = 24; +pub const ENOTTY: c_int = 25; +pub const ETXTBSY: c_int = 26; +pub const EFBIG: c_int = 27; +pub const ENOSPC: c_int = 28; +pub const ESPIPE: c_int = 29; +pub const EROFS: c_int = 30; +pub const EMLINK: c_int = 31; +pub const EPIPE: c_int = 32; +pub const EDOM: c_int = 33; +pub const ERANGE: c_int = 34; +pub const ENOMSG: c_int = 35; +pub const EIDRM: c_int = 36; +pub const ECHRNG: c_int = 37; +pub const EL2NSYNC: c_int = 38; +pub const EL3HLT: c_int = 39; +pub const EL3RST: c_int = 40; +pub const ELNRNG: c_int = 41; +pub const EUNATCH: c_int = 42; +pub const ENOCSI: c_int = 43; +pub const EL2HLT: c_int = 44; +pub const EDEADLK: c_int = 45; +pub const ENOLCK: c_int = 46; +pub const EBADE: c_int = 50; +pub const EBADR: c_int = 51; +pub const EXFULL: c_int = 52; +pub const ENOANO: c_int = 53; +pub const EBADRQC: c_int = 54; +pub const EBADSLT: c_int = 55; +pub const EDEADLOCK: c_int = 56; +pub const EBFONT: c_int = 57; +pub const ENOSTR: c_int = 60; +pub const ENODATA: c_int = 61; +pub const ETIME: c_int = 62; +pub const ENOSR: c_int = 63; +pub const ENONET: c_int = 64; +pub const ENOPKG: c_int = 65; +pub const EREMOTE: c_int = 66; +pub const ENOLINK: c_int = 67; +pub const EADV: c_int = 68; +pub const ESRMNT: c_int = 69; +pub const ECOMM: c_int = 70; +pub const EPROTO: c_int = 71; +pub const EMULTIHOP: c_int = 74; +pub const EDOTDOT: c_int = 76; +pub const EBADMSG: c_int = 77; +pub const EFTYPE: c_int = 79; +pub const ENOTUNIQ: c_int = 80; +pub const EBADFD: c_int = 81; +pub const EREMCHG: c_int = 82; +pub const ELIBACC: c_int = 83; +pub const ELIBBAD: c_int = 84; +pub const ELIBSCN: c_int = 85; +pub const ELIBMAX: c_int = 86; +pub const ELIBEXEC: c_int = 87; +pub const ENOSYS: c_int = 88; +pub const ENOTEMPTY: c_int = 90; +pub const ENAMETOOLONG: c_int = 91; +pub const ELOOP: c_int = 92; +pub const EOPNOTSUPP: c_int = 95; +pub const EPFNOSUPPORT: c_int = 96; +pub const ECONNRESET: c_int = 104; +pub const ENOBUFS: c_int = 105; +pub const EAFNOSUPPORT: c_int = 106; +pub const EPROTOTYPE: c_int = 107; +pub const ENOTSOCK: c_int = 108; +pub const ENOPROTOOPT: c_int = 109; +pub const ESHUTDOWN: c_int = 110; +pub const ECONNREFUSED: c_int = 111; +pub const EADDRINUSE: c_int = 112; +pub const ECONNABORTED: c_int = 113; +pub const ENETUNREACH: c_int = 114; +pub const ENETDOWN: c_int = 115; +pub const ETIMEDOUT: c_int = 116; +pub const EHOSTDOWN: c_int = 117; +pub const EHOSTUNREACH: c_int = 118; +pub const EINPROGRESS: c_int = 119; +pub const EALREADY: c_int = 120; +pub const EDESTADDRREQ: c_int = 121; +pub const EMSGSIZE: c_int = 122; +pub const EPROTONOSUPPORT: c_int = 123; +pub const ESOCKTNOSUPPORT: c_int = 124; +pub const EADDRNOTAVAIL: c_int = 125; +pub const ENETRESET: c_int = 126; +pub const EISCONN: c_int = 127; +pub const ENOTCONN: c_int = 128; +pub const ETOOMANYREFS: c_int = 129; +pub const EPROCLIM: c_int = 130; +pub const EUSERS: c_int = 131; +pub const EDQUOT: c_int = 132; +pub const ESTALE: c_int = 133; +pub const ENOTSUP: c_int = 134; +pub const ENOMEDIUM: c_int = 135; +pub const EILSEQ: c_int = 138; +pub const EOVERFLOW: c_int = 139; +pub const ECANCELED: c_int = 140; +pub const ENOTRECOVERABLE: c_int = 141; +pub const EOWNERDEAD: c_int = 142; +pub const ESTRPIPE: c_int = 143; +pub const EWOULDBLOCK: c_int = EAGAIN; /* Operation would block */ + +pub const SCHED_OTHER: c_int = 3; +pub const SCHED_FIFO: c_int = 1; +pub const SCHED_RR: c_int = 2; + +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = 21 as *mut _; +pub const PTHREAD_CREATE_DETACHED: c_int = 1; +pub const PTHREAD_CREATE_JOINABLE: c_int = 0; +pub const PTHREAD_MUTEX_RECURSIVE: c_int = 0; +pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 1; +pub const PTHREAD_MUTEX_NORMAL: c_int = 2; +pub const PTHREAD_MUTEX_DEFAULT: c_int = PTHREAD_MUTEX_NORMAL; +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: pthread_mutex_t = 18 as *mut _; +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: pthread_mutex_t = 20 as *mut _; +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = 19 as *mut _; +pub const PTHREAD_PROCESS_SHARED: c_int = 1; +pub const PTHREAD_PROCESS_PRIVATE: c_int = 0; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = 22 as *mut _; + +pub const LITTLE_ENDIAN: c_int = 1234; +pub const BIG_ENDIAN: c_int = 4321; + +pub const TCP_NODELAY: c_int = 1; +pub const TCP_KEEPIDLE: c_int = 3; +pub const TCP_MAXSEG: c_int = 4; +pub const TCP_QUICKACK: c_int = 12; +pub const TCP_USER_TIMEOUT: c_int = 14; +pub const TCP_FASTOPEN: c_int = 15; +pub const TCP_KEEPCNT: c_int = 16; +pub const TCP_KEEPINTVL: c_int = 17; + +pub const WINDOWS_POST: c_int = 0; +pub const WINDOWS_SEND: c_int = 1; +pub const WINDOWS_HWND: c_int = 2; + +pub const MOUNT_TEXT: c_uint = 0x01; +pub const MOUNT_SYSTEM: c_uint = 0x08; +pub const MOUNT_EXEC: c_uint = 0x10; +pub const MOUNT_CYGDRIVE: c_uint = 0x20; +pub const MOUNT_CYGWIN_EXEC: c_uint = 0x40; +pub const MOUNT_SPARSE: c_uint = 0x80; +pub const MOUNT_NOTEXEC: c_uint = 0x100; +pub const MOUNT_DEVFS: c_uint = 0x200; +pub const MOUNT_PROC: c_uint = 0x400; +pub const MOUNT_RO: c_uint = 0x1000; +pub const MOUNT_NOACL: c_uint = 0x2000; +pub const MOUNT_NOPOSIX: c_uint = 0x4000; +pub const MOUNT_OVERRIDE: c_uint = 0x8000; +pub const MOUNT_IMMUTABLE: c_uint = 0x10000; +pub const MOUNT_AUTOMATIC: c_uint = 0x20000; +pub const MOUNT_DOS: c_uint = 0x40000; +pub const MOUNT_IHASH: c_uint = 0x80000; +pub const MOUNT_BIND: c_uint = 0x100000; +pub const MOUNT_USER_TEMP: c_uint = 0x200000; +pub const MOUNT_DONT_USE: c_uint = 0x80000000; + +pub const _POSIX_VDISABLE: cc_t = 0; + +pub const GRND_NONBLOCK: c_uint = 0x1; +pub const GRND_RANDOM: c_uint = 0x2; + +pub const _IOFBF: c_int = 0; +pub const _IOLBF: c_int = 1; +pub const _IONBF: c_int = 2; +pub const BUFSIZ: c_int = 1024; + +pub const POSIX_SPAWN_RESETIDS: c_int = 0x01; +pub const POSIX_SPAWN_SETPGROUP: c_int = 0x02; +pub const POSIX_SPAWN_SETSCHEDPARAM: c_int = 0x04; +pub const POSIX_SPAWN_SETSCHEDULER: c_int = 0x08; +pub const POSIX_SPAWN_SETSIGDEF: c_int = 0x10; +pub const POSIX_SPAWN_SETSIGMASK: c_int = 0x20; + +pub const POSIX_FADV_NORMAL: c_int = 0; +pub const POSIX_FADV_SEQUENTIAL: c_int = 1; +pub const POSIX_FADV_RANDOM: c_int = 2; +pub const POSIX_FADV_WILLNEED: c_int = 3; +pub const POSIX_FADV_DONTNEED: c_int = 4; +pub const POSIX_FADV_NOREUSE: c_int = 5; + +pub const FALLOC_FL_PUNCH_HOLE: c_int = 0x0001; +pub const FALLOC_FL_ZERO_RANGE: c_int = 0x0002; +pub const FALLOC_FL_UNSHARE_RANGE: c_int = 0x0004; +pub const FALLOC_FL_COLLAPSE_RANGE: c_int = 0x0008; +pub const FALLOC_FL_INSERT_RANGE: c_int = 0x0010; +pub const FALLOC_FL_KEEP_SIZE: c_int = 0x1000; + +f! { + pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { + let fd = fd as usize; + let size = size_of_val(&(*set).fds_bits[0]) * 8; + (*set).fds_bits[fd / size] &= !(1 << (fd % size)); + } + + pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { + let fd = fd as usize; + let size = size_of_val(&(*set).fds_bits[0]) * 8; + ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0 + } + + pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { + let fd = fd as usize; + let size = size_of_val(&(*set).fds_bits[0]) * 8; + (*set).fds_bits[fd / size] |= 1 << (fd % size); + } + + pub fn FD_ZERO(set: *mut fd_set) -> () { + for slot in (*set).fds_bits.iter_mut() { + *slot = 0; + } + } + + pub fn CPU_ALLOC_SIZE(count: c_int) -> size_t { + let _dummy: cpu_set_t = cpu_set_t { bits: [0; 16] }; + let size_in_bits = 8 * size_of_val(&_dummy.bits[0]); + ((count as size_t + size_in_bits - 1) / 8) as size_t + } + + pub fn CPU_COUNT_S(size: usize, cpuset: &cpu_set_t) -> c_int { + let mut s: u32 = 0; + let size_of_mask = size_of_val(&cpuset.bits[0]); + for i in cpuset.bits[..(size / size_of_mask)].iter() { + s += i.count_ones(); + } + s as c_int + } + + pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { + for slot in cpuset.bits.iter_mut() { + *slot = 0; + } + } + pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); + if cpu < size_in_bits { + let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); + cpuset.bits[idx] |= 1 << offset; + } + } + + pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); + if cpu < size_in_bits { + let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); + cpuset.bits[idx] &= !(1 << offset); + } + } + + pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); + if cpu < size_in_bits { + let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); + 0 != (cpuset.bits[idx] & (1 << offset)) + } else { + false + } + } + + pub fn CPU_COUNT(cpuset: &cpu_set_t) -> c_int { + CPU_COUNT_S(size_of::(), cpuset) + } + + pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool { + set1.bits == set2.bits + } + + pub fn CMSG_LEN(length: c_uint) -> c_uint { + CMSG_ALIGN(size_of::()) as c_uint + length + } + + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { + (CMSG_ALIGN(length as usize) + CMSG_ALIGN(size_of::())) as c_uint + } + + pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { + if (*mhdr).msg_controllen as usize >= size_of::() { + (*mhdr).msg_control.cast() + } else { + core::ptr::null_mut() + } + } + + pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { + let next = (cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr; + let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; + if next as usize + CMSG_ALIGN(size_of::()) as usize > max { + core::ptr::null_mut() + } else { + next + } + } + + pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { + cmsg.offset(1).cast_mut().cast() + } +} + +safe_f! { + pub const fn makedev(ma: c_uint, mi: c_uint) -> dev_t { + let ma = ma as dev_t; + let mi = mi as dev_t; + (ma << 16) | (mi & 0xffff) + } + + pub const fn major(dev: dev_t) -> c_uint { + ((dev >> 16) & 0xffff) as c_uint + } + + pub const fn minor(dev: dev_t) -> c_uint { + (dev & 0xffff) as c_uint + } + + pub const fn WIFEXITED(status: c_int) -> bool { + (status & 0xff) == 0 + } + + pub const fn WIFSIGNALED(status: c_int) -> bool { + (status & 0o177) != 0o177 && (status & 0o177) != 0 + } + + pub const fn WIFSTOPPED(status: c_int) -> bool { + (status & 0xff) == 0o177 + } + + pub const fn WIFCONTINUED(status: c_int) -> bool { + (status & 0o177777) == 0o177777 + } + + pub const fn WEXITSTATUS(status: c_int) -> c_int { + (status >> 8) & 0xff + } + + pub const fn WTERMSIG(status: c_int) -> c_int { + status & 0o177 + } + + pub const fn WSTOPSIG(status: c_int) -> c_int { + (status >> 8) & 0xff + } + + pub const fn WCOREDUMP(status: c_int) -> bool { + WIFSIGNALED(status) && (status & 0x80) != 0 + } +} + +const fn CMSG_ALIGN(len: usize) -> usize { + len + size_of::() - 1 & !(size_of::() - 1) +} + +extern "C" { + pub fn sigwait(set: *const sigset_t, sig: *mut c_int) -> c_int; + pub fn sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> c_int; + + pub fn pthread_sigmask(how: c_int, set: *const sigset_t, oldset: *mut sigset_t) -> c_int; + pub fn sigsuspend(mask: *const sigset_t) -> c_int; + pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> c_int; + pub fn pthread_kill(thread: pthread_t, sig: c_int) -> c_int; + + pub fn sigtimedwait( + set: *const sigset_t, + info: *mut siginfo_t, + timeout: *const timespec, + ) -> c_int; + + pub fn strftime(s: *mut c_char, max: size_t, format: *const c_char, tm: *const tm) -> size_t; + + pub fn asctime_r(tm: *const tm, buf: *mut c_char) -> *mut c_char; + pub fn ctime_r(timep: *const time_t, buf: *mut c_char) -> *mut c_char; + pub fn strptime(s: *const c_char, format: *const c_char, tm: *mut tm) -> *mut c_char; + pub fn clock_settime(clk_id: clockid_t, tp: *const timespec) -> c_int; + pub fn clock_gettime(clk_id: clockid_t, tp: *mut timespec) -> c_int; + pub fn clock_getres(clk_id: clockid_t, tp: *mut timespec) -> c_int; + + pub fn timer_create(clockid: clockid_t, sevp: *mut sigevent, timerid: *mut timer_t) -> c_int; + + pub fn timer_delete(timerid: timer_t) -> c_int; + + pub fn timer_settime( + timerid: timer_t, + flags: c_int, + new_value: *const itimerspec, + old_value: *mut itimerspec, + ) -> c_int; + + pub fn timer_gettime(timerid: timer_t, curr_value: *mut itimerspec) -> c_int; + pub fn timer_getoverrun(timerid: timer_t) -> c_int; + + pub fn clock_nanosleep( + clk_id: clockid_t, + flags: c_int, + rqtp: *const timespec, + rmtp: *mut timespec, + ) -> c_int; + + pub fn clock_getcpuclockid(pid: pid_t, clk_id: *mut clockid_t) -> c_int; + + pub fn futimes(fd: c_int, times: *const timeval) -> c_int; + pub fn lutimes(file: *const c_char, times: *const timeval) -> c_int; + pub fn settimeofday(tv: *const timeval, tz: *const timezone) -> c_int; + pub fn getitimer(which: c_int, curr_value: *mut itimerval) -> c_int; + + pub fn setitimer(which: c_int, new_value: *const itimerval, old_value: *mut itimerval) + -> c_int; + + pub fn gettimeofday(tp: *mut timeval, tz: *mut c_void) -> c_int; + pub fn futimesat(fd: c_int, path: *const c_char, times: *const timeval) -> c_int; + + pub fn getrlimit(resource: c_int, rlim: *mut rlimit) -> c_int; + pub fn setrlimit(resource: c_int, rlim: *const rlimit) -> c_int; + pub fn getpriority(which: c_int, who: id_t) -> c_int; + pub fn setpriority(which: c_int, who: id_t, prio: c_int) -> c_int; + + pub fn getpwnam_r( + name: *const c_char, + pwd: *mut passwd, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut passwd, + ) -> c_int; + + pub fn getpwuid_r( + uid: uid_t, + pwd: *mut passwd, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut passwd, + ) -> c_int; + + pub fn getpwent() -> *mut passwd; + pub fn setpwent(); + pub fn endpwent(); + + pub fn if_nameindex() -> *mut if_nameindex; + pub fn if_freenameindex(ptr: *mut if_nameindex); + + pub fn readv(fd: c_int, iov: *const iovec, iovcnt: c_int) -> ssize_t; + pub fn writev(fd: c_int, iov: *const iovec, iovcnt: c_int) -> ssize_t; + + pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; + + pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; + + pub fn utimensat( + dirfd: c_int, + path: *const c_char, + times: *const timespec, + flag: c_int, + ) -> c_int; + + pub fn futimens(fd: c_int, times: *const timespec) -> c_int; + + pub fn dlfork(val: c_int); + + pub fn accept4(s: c_int, addr: *mut sockaddr, addrlen: *mut socklen_t, flags: c_int) -> c_int; + + pub fn bind(socket: c_int, address: *const sockaddr, address_len: socklen_t) -> c_int; + + pub fn recvfrom( + socket: c_int, + buf: *mut c_void, + len: size_t, + flags: c_int, + addr: *mut sockaddr, + addrlen: *mut socklen_t, + ) -> ssize_t; + + pub fn recvmsg(fd: c_int, msg: *mut msghdr, flags: c_int) -> ssize_t; + pub fn sendmsg(fd: c_int, msg: *const msghdr, flags: c_int) -> ssize_t; + + pub fn getnameinfo( + sa: *const sockaddr, + salen: socklen_t, + host: *mut c_char, + hostlen: socklen_t, + serv: *mut c_char, + sevlen: socklen_t, + flags: c_int, + ) -> c_int; + + pub fn ppoll( + fds: *mut pollfd, + nfds: nfds_t, + timeout: *const timespec, + sigmask: *const sigset_t, + ) -> c_int; + + pub fn newlocale(mask: c_int, locale: *const c_char, base: locale_t) -> locale_t; + pub fn freelocale(loc: locale_t); + pub fn duplocale(base: locale_t) -> locale_t; + pub fn uselocale(loc: locale_t) -> locale_t; + + pub fn sem_init(sem: *mut sem_t, pshared: c_int, value: c_uint) -> c_int; + pub fn sem_destroy(sem: *mut sem_t) -> c_int; + pub fn sem_open(name: *const c_char, oflag: c_int, ...) -> *mut sem_t; + pub fn sem_close(sem: *mut sem_t) -> c_int; + pub fn sem_unlink(name: *const c_char) -> c_int; + pub fn sem_timedwait(sem: *mut sem_t, abstime: *const timespec) -> c_int; + pub fn sem_getvalue(sem: *mut sem_t, sval: *mut c_int) -> c_int; + + pub fn clearenv() -> c_int; + pub fn ptsname_r(fd: c_int, buf: *mut c_char, buflen: size_t) -> c_int; + pub fn getpt() -> c_int; + pub fn memalign(align: size_t, size: size_t) -> *mut c_void; + pub fn getloadavg(loadavg: *mut c_double, nelem: c_int) -> c_int; + + pub fn abs(i: c_int) -> c_int; + pub fn arc4random() -> u32; + pub fn arc4random_uniform(l: u32) -> u32; + pub fn arc4random_buf(buf: *mut c_void, size: size_t); + pub fn labs(i: c_long) -> c_long; + pub fn mkostemp(template: *mut c_char, flags: c_int) -> c_int; + pub fn mkostemps(template: *mut c_char, suffixlen: c_int, flags: c_int) -> c_int; + pub fn mkstemps(template: *mut c_char, suffixlen: c_int) -> c_int; + pub fn rand() -> c_int; + pub fn reallocarray(ptr: *mut c_void, nmemb: size_t, size: size_t) -> *mut c_void; + pub fn reallocf(ptr: *mut c_void, size: size_t) -> *mut c_void; + pub fn srand(seed: c_uint); + pub fn drand48() -> c_double; + pub fn erand48(xseed: *mut c_ushort) -> c_double; + pub fn jrand48(xseed: *mut c_ushort) -> c_long; + pub fn lcong48(p: *mut c_ushort); + pub fn lrand48() -> c_long; + pub fn mrand48() -> c_long; + pub fn nrand48(xseed: *mut c_ushort) -> c_long; + pub fn seed48(xseed: *mut c_ushort) -> *mut c_ushort; + pub fn srand48(seed: c_long); + + pub fn qsort_r( + base: *mut c_void, + num: size_t, + size: size_t, + compar: Option c_int>, + arg: *mut c_void, + ); + + pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; + pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int; + pub fn posix_madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; + pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; + pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int; + pub fn shm_unlink(name: *const c_char) -> c_int; + + pub fn explicit_bzero(s: *mut c_void, len: size_t); + pub fn ffs(value: c_int) -> c_int; + pub fn ffsl(value: c_long) -> c_int; + pub fn ffsll(value: c_longlong) -> c_int; + pub fn fls(value: c_int) -> c_int; + pub fn flsl(value: c_long) -> c_int; + pub fn flsll(value: c_longlong) -> c_int; + pub fn strcasecmp_l(s1: *const c_char, s2: *const c_char, loc: locale_t) -> c_int; + + pub fn strncasecmp_l(s1: *const c_char, s2: *const c_char, n: size_t, loc: locale_t) -> c_int; + + pub fn timingsafe_bcmp(a: *const c_void, b: *const c_void, len: size_t) -> c_int; + pub fn timingsafe_memcmp(a: *const c_void, b: *const c_void, len: size_t) -> c_int; + + pub fn memmem( + haystack: *const c_void, + haystacklen: size_t, + needle: *const c_void, + needlelen: size_t, + ) -> *mut c_void; + + pub fn memrchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; + #[link_name = "__xpg_strerror_r"] + pub fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int; + pub fn strsep(string: *mut *mut c_char, delim: *const c_char) -> *mut c_char; + + #[link_name = "__gnu_basename"] + pub fn basename(path: *const c_char) -> *mut c_char; + + pub fn daemon(nochdir: c_int, noclose: c_int) -> c_int; + pub fn dup3(src: c_int, dst: c_int, flags: c_int) -> c_int; + pub fn eaccess(pathname: *const c_char, mode: c_int) -> c_int; + pub fn euidaccess(pathname: *const c_char, mode: c_int) -> c_int; + + pub fn execvpe( + file: *const c_char, + argv: *const *mut c_char, + envp: *const *mut c_char, + ) -> c_int; + + pub fn faccessat(dirfd: c_int, pathname: *const c_char, mode: c_int, flags: c_int) -> c_int; + + pub fn fexecve(fd: c_int, argv: *const *mut c_char, envp: *const *mut c_char) -> c_int; + + pub fn fdatasync(fd: c_int) -> c_int; + pub fn getdomainname(name: *mut c_char, len: size_t) -> c_int; + pub fn getentropy(buf: *mut c_void, buflen: size_t) -> c_int; + pub fn gethostid() -> c_long; + pub fn getpagesize() -> c_int; + pub fn getpeereid(socket: c_int, euid: *mut uid_t, egid: *mut gid_t) -> c_int; + + pub fn pthread_atfork( + prepare: Option, + parent: Option, + child: Option, + ) -> c_int; + + pub fn pipe2(fds: *mut c_int, flags: c_int) -> c_int; + pub fn sbrk(increment: intptr_t) -> *mut c_void; + pub fn setgroups(ngroups: c_int, ptr: *const gid_t) -> c_int; + pub fn sethostname(name: *const c_char, len: size_t) -> c_int; + pub fn vhangup() -> c_int; + pub fn getdtablesize() -> c_int; + pub fn sync(); + + pub fn __errno() -> *mut c_int; + + pub fn sched_setparam(pid: pid_t, param: *const sched_param) -> c_int; + pub fn sched_getparam(pid: pid_t, param: *mut sched_param) -> c_int; + + pub fn sched_setscheduler(pid: pid_t, policy: c_int, param: *const sched_param) -> c_int; + + pub fn sched_getscheduler(pid: pid_t) -> c_int; + pub fn sched_get_priority_max(policy: c_int) -> c_int; + pub fn sched_get_priority_min(policy: c_int) -> c_int; + pub fn sched_rr_get_interval(pid: pid_t, t: *mut timespec) -> c_int; + pub fn sched_getcpu() -> c_int; + pub fn sched_getaffinity(pid: pid_t, cpusetsize: size_t, mask: *mut cpu_set_t) -> c_int; + + pub fn sched_setaffinity(pid: pid_t, cpusetsize: size_t, cpuset: *const cpu_set_t) -> c_int; + + pub fn pthread_attr_getguardsize(attr: *const pthread_attr_t, guardsize: *mut size_t) -> c_int; + + pub fn pthread_attr_getschedparam( + attr: *const pthread_attr_t, + param: *mut sched_param, + ) -> c_int; + + pub fn pthread_attr_setschedparam( + attr: *mut pthread_attr_t, + param: *const sched_param, + ) -> c_int; + + pub fn pthread_attr_getstack( + attr: *const pthread_attr_t, + stackaddr: *mut *mut c_void, + stacksize: *mut size_t, + ) -> c_int; + + pub fn pthread_cancel(thread: pthread_t) -> c_int; + + pub fn pthread_condattr_getclock( + attr: *const pthread_condattr_t, + clock_id: *mut clockid_t, + ) -> c_int; + + pub fn pthread_condattr_getpshared( + attr: *const pthread_condattr_t, + pshared: *mut c_int, + ) -> c_int; + + pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t, clock_id: clockid_t) -> c_int; + + pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t, pshared: c_int) -> c_int; + pub fn pthread_barrierattr_init(attr: *mut pthread_barrierattr_t) -> c_int; + + pub fn pthread_barrierattr_setpshared(attr: *mut pthread_barrierattr_t, shared: c_int) + -> c_int; + + pub fn pthread_barrierattr_getpshared( + attr: *const pthread_barrierattr_t, + shared: *mut c_int, + ) -> c_int; + + pub fn pthread_barrierattr_destroy(attr: *mut pthread_barrierattr_t) -> c_int; + + pub fn pthread_barrier_init( + barrier: *mut pthread_barrier_t, + attr: *const pthread_barrierattr_t, + count: c_uint, + ) -> c_int; + + pub fn pthread_barrier_destroy(barrier: *mut pthread_barrier_t) -> c_int; + pub fn pthread_barrier_wait(barrier: *mut pthread_barrier_t) -> c_int; + + pub fn pthread_create( + native: *mut pthread_t, + attr: *const pthread_attr_t, + f: extern "C" fn(*mut c_void) -> *mut c_void, + value: *mut c_void, + ) -> c_int; + + pub fn pthread_getcpuclockid(thread: pthread_t, clk_id: *mut clockid_t) -> c_int; + + pub fn pthread_getschedparam( + native: pthread_t, + policy: *mut c_int, + param: *mut sched_param, + ) -> c_int; + + pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t, abstime: *const timespec) -> c_int; + + pub fn pthread_mutexattr_getprotocol( + attr: *const pthread_mutexattr_t, + protocol: *mut c_int, + ) -> c_int; + + pub fn pthread_mutexattr_getpshared( + attr: *const pthread_mutexattr_t, + pshared: *mut c_int, + ) -> c_int; + + pub fn pthread_mutexattr_setprotocol(attr: *mut pthread_mutexattr_t, protocol: c_int) -> c_int; + + pub fn pthread_mutexattr_setpshared(attr: *mut pthread_mutexattr_t, pshared: c_int) -> c_int; + + pub fn pthread_spin_destroy(lock: *mut pthread_spinlock_t) -> c_int; + pub fn pthread_spin_init(lock: *mut pthread_spinlock_t, pshared: c_int) -> c_int; + pub fn pthread_spin_lock(lock: *mut pthread_spinlock_t) -> c_int; + pub fn pthread_spin_trylock(lock: *mut pthread_spinlock_t) -> c_int; + pub fn pthread_spin_unlock(lock: *mut pthread_spinlock_t) -> c_int; + + pub fn pthread_rwlockattr_getpshared( + attr: *const pthread_rwlockattr_t, + val: *mut c_int, + ) -> c_int; + + pub fn pthread_rwlockattr_setpshared(attr: *mut pthread_rwlockattr_t, val: c_int) -> c_int; + + pub fn pthread_setschedparam( + native: pthread_t, + policy: c_int, + param: *const sched_param, + ) -> c_int; + + pub fn pthread_setschedprio(native: pthread_t, priority: c_int) -> c_int; + + pub fn pthread_getaffinity_np( + thread: pthread_t, + cpusetsize: size_t, + cpuset: *mut cpu_set_t, + ) -> c_int; + + pub fn pthread_getattr_np(native: pthread_t, attr: *mut pthread_attr_t) -> c_int; + pub fn pthread_getname_np(thread: pthread_t, name: *mut c_char, len: size_t) -> c_int; + + pub fn pthread_setaffinity_np( + thread: pthread_t, + cpusetsize: size_t, + cpuset: *const cpu_set_t, + ) -> c_int; + + pub fn pthread_setname_np(thread: pthread_t, name: *const c_char) -> c_int; + pub fn pthread_sigqueue(thread: pthread_t, sig: c_int, value: sigval) -> c_int; + + pub fn ioctl(fd: c_int, request: c_int, ...) -> c_int; + + pub fn getrandom(buf: *mut c_void, buflen: size_t, flags: c_uint) -> ssize_t; + + pub fn mount(src: *const c_char, target: *const c_char, flags: c_uint) -> c_int; + + pub fn umount(target: *const c_char) -> c_int; + pub fn cygwin_umount(target: *const c_char, flags: c_uint) -> c_int; + + pub fn dirfd(dirp: *mut DIR) -> c_int; + pub fn seekdir(dirp: *mut DIR, loc: c_long); + pub fn telldir(dirp: *mut DIR) -> c_long; + + pub fn uname(buf: *mut utsname) -> c_int; + + pub fn posix_spawn( + pid: *mut pid_t, + path: *const c_char, + file_actions: *const posix_spawn_file_actions_t, + attrp: *const posix_spawnattr_t, + argv: *const *mut c_char, + envp: *const *mut c_char, + ) -> c_int; + pub fn posix_spawnp( + pid: *mut pid_t, + file: *const c_char, + file_actions: *const posix_spawn_file_actions_t, + attrp: *const posix_spawnattr_t, + argv: *const *mut c_char, + envp: *const *mut c_char, + ) -> c_int; + pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> c_int; + pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> c_int; + pub fn posix_spawnattr_getsigdefault( + attr: *const posix_spawnattr_t, + default: *mut sigset_t, + ) -> c_int; + pub fn posix_spawnattr_setsigdefault( + attr: *mut posix_spawnattr_t, + default: *const sigset_t, + ) -> c_int; + pub fn posix_spawnattr_getsigmask( + attr: *const posix_spawnattr_t, + default: *mut sigset_t, + ) -> c_int; + pub fn posix_spawnattr_setsigmask( + attr: *mut posix_spawnattr_t, + default: *const sigset_t, + ) -> c_int; + pub fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t, flags: *mut c_short) -> c_int; + pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t, flags: c_short) -> c_int; + pub fn posix_spawnattr_getpgroup(attr: *const posix_spawnattr_t, flags: *mut pid_t) -> c_int; + pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, flags: pid_t) -> c_int; + pub fn posix_spawnattr_getschedpolicy( + attr: *const posix_spawnattr_t, + flags: *mut c_int, + ) -> c_int; + pub fn posix_spawnattr_setschedpolicy(attr: *mut posix_spawnattr_t, flags: c_int) -> c_int; + pub fn posix_spawnattr_getschedparam( + attr: *const posix_spawnattr_t, + param: *mut sched_param, + ) -> c_int; + pub fn posix_spawnattr_setschedparam( + attr: *mut posix_spawnattr_t, + param: *const sched_param, + ) -> c_int; + + pub fn posix_spawn_file_actions_init(actions: *mut posix_spawn_file_actions_t) -> c_int; + pub fn posix_spawn_file_actions_destroy(actions: *mut posix_spawn_file_actions_t) -> c_int; + pub fn posix_spawn_file_actions_addopen( + actions: *mut posix_spawn_file_actions_t, + fd: c_int, + path: *const c_char, + oflag: c_int, + mode: mode_t, + ) -> c_int; + pub fn posix_spawn_file_actions_addclose( + actions: *mut posix_spawn_file_actions_t, + fd: c_int, + ) -> c_int; + pub fn posix_spawn_file_actions_adddup2( + actions: *mut posix_spawn_file_actions_t, + fd: c_int, + newfd: c_int, + ) -> c_int; + pub fn posix_spawn_file_actions_addchdir( + actions: *mut crate::posix_spawn_file_actions_t, + path: *const c_char, + ) -> c_int; + pub fn posix_spawn_file_actions_addfchdir( + actions: *mut crate::posix_spawn_file_actions_t, + fd: c_int, + ) -> c_int; + pub fn posix_spawn_file_actions_addchdir_np( + actions: *mut crate::posix_spawn_file_actions_t, + path: *const c_char, + ) -> c_int; + pub fn posix_spawn_file_actions_addfchdir_np( + actions: *mut crate::posix_spawn_file_actions_t, + fd: c_int, + ) -> c_int; + + pub fn forkpty( + amaster: *mut c_int, + name: *mut c_char, + termp: *const termios, + winp: *const crate::winsize, + ) -> crate::pid_t; + pub fn openpty( + amaster: *mut c_int, + aslave: *mut c_int, + name: *mut c_char, + termp: *const termios, + winp: *const crate::winsize, + ) -> c_int; + + pub fn getgrgid(gid: crate::gid_t) -> *mut crate::group; + pub fn getgrgid_r( + gid: crate::gid_t, + grp: *mut crate::group, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::group, + ) -> c_int; + pub fn getgrouplist( + user: *const c_char, + group: crate::gid_t, + groups: *mut crate::gid_t, + ngroups: *mut c_int, + ) -> c_int; + pub fn getgrnam(name: *const c_char) -> *mut crate::group; + pub fn getgrnam_r( + name: *const c_char, + grp: *mut crate::group, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::group, + ) -> c_int; + pub fn initgroups(user: *const c_char, group: crate::gid_t) -> c_int; + + pub fn statfs(path: *const c_char, buf: *mut statfs) -> c_int; + pub fn fstatfs(fd: c_int, buf: *mut statfs) -> c_int; + + pub fn posix_fadvise(fd: c_int, offset: off_t, len: off_t, advise: c_int) -> c_int; + pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int; + pub fn fallocate(fd: c_int, mode: c_int, offset: off_t, len: off_t) -> c_int; + + pub fn endutxent(); + pub fn getutxent() -> *mut utmpx; + pub fn getutxid(id: *const utmpx) -> *mut utmpx; + pub fn getutxline(line: *const utmpx) -> *mut utmpx; + pub fn pututxline(utmpx: *const utmpx) -> *mut utmpx; + pub fn setutxent(); + pub fn utmpxname(file: *const c_char) -> c_int; + pub fn updwtmpx(file: *const c_char, utmpx: *const utmpx); +} diff --git a/http/vendor/libc/src/unix/haiku/b32.rs b/http/vendor/libc/src/unix/haiku/b32.rs new file mode 100644 index 0000000..1aa27e6 --- /dev/null +++ b/http/vendor/libc/src/unix/haiku/b32.rs @@ -0,0 +1,18 @@ +pub type time_t = i32; + +pub type Elf_Addr = crate::Elf32_Addr; +pub type Elf_Half = crate::Elf32_Half; +pub type Elf_Phdr = crate::Elf32_Phdr; + +s! { + pub struct Elf32_Phdr { + pub p_type: crate::Elf32_Word, + pub p_offset: crate::Elf32_Off, + pub p_vaddr: crate::Elf32_Addr, + pub p_paddr: crate::Elf32_Addr, + pub p_filesz: crate::Elf32_Word, + pub p_memsz: crate::Elf32_Word, + pub p_flags: crate::Elf32_Word, + pub p_align: crate::Elf32_Word, + } +} diff --git a/http/vendor/libc/src/unix/haiku/b64.rs b/http/vendor/libc/src/unix/haiku/b64.rs new file mode 100644 index 0000000..3355241 --- /dev/null +++ b/http/vendor/libc/src/unix/haiku/b64.rs @@ -0,0 +1,18 @@ +pub type time_t = i64; + +pub type Elf_Addr = crate::Elf64_Addr; +pub type Elf_Half = crate::Elf64_Half; +pub type Elf_Phdr = crate::Elf64_Phdr; + +s! { + pub struct Elf64_Phdr { + pub p_type: crate::Elf64_Word, + pub p_flags: crate::Elf64_Word, + pub p_offset: crate::Elf64_Off, + pub p_vaddr: crate::Elf64_Addr, + pub p_paddr: crate::Elf64_Addr, + pub p_filesz: crate::Elf64_Xword, + pub p_memsz: crate::Elf64_Xword, + pub p_align: crate::Elf64_Xword, + } +} diff --git a/http/vendor/libc/src/unix/haiku/bsd.rs b/http/vendor/libc/src/unix/haiku/bsd.rs new file mode 100644 index 0000000..1e3881e --- /dev/null +++ b/http/vendor/libc/src/unix/haiku/bsd.rs @@ -0,0 +1,151 @@ +//! This file contains the BSD APIs available in Haiku. It corresponds to the +//! header files in `headers/compatibility/bsd`. +//! +//! Note that Haiku's BSD compatibility is a combination of system APIs and +//! utility libraries. There should only be system APIs in `libc`. When you are +//! trying to determine whether something should be included in this file, the +//! best indicator is whether it also exists in the BSD-specific definitions in +//! this libc crate. + +use crate::prelude::*; + +// stringlist.h (utility library) +// Note: this is kept because it was previously introduced +pub type StringList = _stringlist; + +s! { + // stringlist.h (utility library) + // Note: this is kept because it was previously introduced + pub struct _stringlist { + pub sl_str: *mut *mut c_char, + pub sl_max: size_t, + pub sl_cur: size_t, + } + + // sys/event.h + pub struct kevent { + pub ident: crate::uintptr_t, + pub filter: c_short, + pub flags: c_ushort, + pub fflags: c_uint, + pub data: i64, + pub udata: *mut c_void, + pub ext: [u64; 4], + } + + // sys/link_elf.h + pub struct dl_phdr_info { + pub dlpi_addr: crate::Elf_Addr, + pub dlpi_name: *const c_char, + pub dlpi_phdr: *const crate::Elf_Phdr, + pub dlpi_phnum: crate::Elf_Half, + } +} + +// sys/event.h +pub const EVFILT_READ: i16 = -1; +pub const EVFILT_WRITE: i16 = -2; +pub const EVFILT_PROC: i16 = -5; +pub const EV_ADD: u16 = 0x0001; +pub const EV_DELETE: u16 = 0x0002; +pub const EV_ONESHOT: u16 = 0x0010; +pub const EV_CLEAR: u16 = 0x0020; +pub const EV_EOF: u16 = 0x8000; +pub const EV_ERROR: u16 = 0x4000; +pub const NOTE_EXIT: u32 = 0x80000000; + +// sys/ioccom.h +pub const IOC_VOID: c_ulong = 0x20000000; +pub const IOC_OUT: c_ulong = 0x40000000; +pub const IOC_IN: c_ulong = 0x80000000; +pub const IOC_INOUT: c_ulong = IOC_IN | IOC_OUT; +pub const IOC_DIRMASK: c_ulong = 0xe0000000; + +#[link(name = "bsd")] +extern "C" { + // stdlib.h + pub fn daemon(nochdir: c_int, noclose: c_int) -> c_int; + pub fn getprogname() -> *const c_char; + pub fn setprogname(progname: *const c_char); + pub fn arc4random() -> u32; + pub fn arc4random_uniform(upper_bound: u32) -> u32; + pub fn arc4random_buf(buf: *mut c_void, n: size_t); + pub fn mkstemps(template: *mut c_char, suffixlen: c_int) -> c_int; + pub fn strtonum( + nptr: *const c_char, + minval: c_longlong, + maxval: c_longlong, + errstr: *mut *const c_char, + ) -> c_longlong; + + // pty.h + pub fn openpty( + amaster: *mut c_int, + aslave: *mut c_int, + name: *mut c_char, + termp: *mut crate::termios, + winp: *mut crate::winsize, + ) -> c_int; + pub fn login_tty(_fd: c_int) -> c_int; + pub fn forkpty( + amaster: *mut c_int, + name: *mut c_char, + termp: *mut crate::termios, + winp: *mut crate::winsize, + ) -> crate::pid_t; + + // string.h + pub fn strsep(string: *mut *mut c_char, delimiters: *const c_char) -> *mut c_char; + pub fn explicit_bzero(buf: *mut c_void, len: size_t); + + // stringlist.h (utility library) + // Note: this is kept because it was previously introduced + pub fn sl_init() -> *mut StringList; + pub fn sl_add(sl: *mut StringList, n: *mut c_char) -> c_int; + pub fn sl_free(sl: *mut StringList, i: c_int); + pub fn sl_find(sl: *mut StringList, n: *mut c_char) -> *mut c_char; + + // sys/event.h + pub fn kqueue() -> c_int; + pub fn kevent( + kq: c_int, + changelist: *const kevent, + nchanges: c_int, + eventlist: *mut kevent, + nevents: c_int, + timeout: *const crate::timespec, + ) -> c_int; + + // sys/link_elf.h + pub fn dl_iterate_phdr( + callback: Option< + unsafe extern "C" fn(info: *mut dl_phdr_info, size: usize, data: *mut c_void) -> c_int, + >, + data: *mut c_void, + ) -> c_int; + + // sys/time.h + pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int; + + // sys/uov.h + pub fn preadv( + fd: c_int, + iov: *const crate::iovec, + iovcnt: c_int, + offset: crate::off_t, + ) -> ssize_t; + pub fn pwritev( + fd: c_int, + iov: *const crate::iovec, + iovcnt: c_int, + offset: crate::off_t, + ) -> ssize_t; + + // sys/wait.h + pub fn wait4( + pid: crate::pid_t, + status: *mut c_int, + options: c_int, + rusage: *mut crate::rusage, + ) -> crate::pid_t; +} diff --git a/http/vendor/libc/src/unix/haiku/mod.rs b/http/vendor/libc/src/unix/haiku/mod.rs new file mode 100644 index 0000000..cbb6464 --- /dev/null +++ b/http/vendor/libc/src/unix/haiku/mod.rs @@ -0,0 +1,1961 @@ +use crate::prelude::*; + +// This module contains bindings to the native Haiku API. The Haiku API +// originates from BeOS, and it was the original way to perform low level +// system and IO operations. The POSIX API was in that era was like a +// compatibility layer. In current Haiku development, both the POSIX API and +// the Haiku API are considered to be co-equal status. However, they are not +// integrated like they are on other UNIX platforms, which means that for many +// low level concepts there are two versions, like processes (POSIX) and +// teams (Haiku), or pthreads and native threads. +// +// Both the POSIX API and the Haiku API live in libroot.so, the library that is +// linked to any binary by default. Additionally, Haiku supports several +// non-POSIX APIs from BSD and GNU, which live in libbsd.so and libgnu.so. These +// modules are also supported. +// +// The module is comprised of the following files: +// - `mod.rs` (this file) implements the C11 and POSIX API found in +// `headers/posix` +// - `b32.rs`, `b64.rs` and `x86_64.rs` contain platform-specific definitions +// of the C11 and POSIX APIs +// - `native.rs` defines the native Haiku API that is implemented in +// `libroot.so` and that are found in `headers/os`. +// - `bsd.rs` defines the BSD customizations available on Haiku found in +// `headers/compatibility/bsd` + +pub type rlim_t = crate::uintptr_t; +pub type sa_family_t = u8; +pub type pthread_key_t = c_int; +pub type nfds_t = c_ulong; +pub type tcflag_t = c_uint; +pub type speed_t = c_uchar; +pub type clock_t = i32; +pub type clockid_t = i32; +pub type suseconds_t = i32; +pub type wchar_t = i32; +pub type off_t = i64; +pub type ino_t = i64; +pub type blkcnt_t = i64; +pub type blksize_t = i32; +pub type dev_t = i32; +pub type mode_t = u32; +pub type nlink_t = i32; +pub type useconds_t = u32; +pub type socklen_t = u32; +pub type pthread_t = crate::uintptr_t; +pub type pthread_condattr_t = crate::uintptr_t; +pub type pthread_mutexattr_t = crate::uintptr_t; +pub type pthread_rwlockattr_t = crate::uintptr_t; +pub type sigset_t = u64; +pub type fsblkcnt_t = i64; +pub type fsfilcnt_t = i64; +pub type pthread_attr_t = *mut c_void; +pub type nl_item = c_int; +pub type id_t = i32; +pub type idtype_t = c_int; +pub type fd_mask = u32; +pub type regoff_t = c_int; +pub type key_t = i32; +pub type msgqnum_t = u32; +pub type msglen_t = u32; + +pub type Elf32_Addr = u32; +pub type Elf32_Half = u16; +pub type Elf32_Off = u32; +pub type Elf32_Sword = i32; +pub type Elf32_Word = u32; + +pub type Elf64_Addr = u64; +pub type Elf64_Half = u16; +pub type Elf64_Off = u64; +pub type Elf64_Sword = i32; +pub type Elf64_Sxword = i64; +pub type Elf64_Word = u32; +pub type Elf64_Xword = u64; + +pub type ENTRY = entry; +pub type ACTION = c_int; + +pub type posix_spawnattr_t = *mut c_void; +pub type posix_spawn_file_actions_t = *mut c_void; + +extern_ty! { + pub enum timezone {} +} + +impl siginfo_t { + pub unsafe fn si_addr(&self) -> *mut c_void { + self.si_addr + } + + pub unsafe fn si_pid(&self) -> crate::pid_t { + self.si_pid + } + + pub unsafe fn si_uid(&self) -> crate::uid_t { + self.si_uid + } + + pub unsafe fn si_status(&self) -> c_int { + self.si_status + } +} + +s! { + pub struct in_addr { + pub s_addr: crate::in_addr_t, + } + + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct sockaddr { + pub sa_len: u8, + pub sa_family: sa_family_t, + pub sa_data: [u8; 30], + } + + pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: sa_family_t, + pub sin_port: crate::in_port_t, + pub sin_addr: crate::in_addr, + pub sin_zero: [i8; 24], + } + + pub struct sockaddr_in6 { + pub sin6_len: u8, + pub sin6_family: u8, + pub sin6_port: u16, + pub sin6_flowinfo: u32, + pub sin6_addr: crate::in6_addr, + pub sin6_scope_id: u32, + } + + pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: socklen_t, + pub ai_canonname: *mut c_char, + pub ai_addr: *mut crate::sockaddr, + pub ai_next: *mut addrinfo, + } + + pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *const c_char, + pub ifa_flags: c_uint, + pub ifa_addr: *mut crate::sockaddr, + pub ifa_netmask: *mut crate::sockaddr, + pub ifa_dstaddr: *mut crate::sockaddr, + pub ifa_data: *mut c_void, + } + + pub struct fd_set { + // size for 1024 bits, and a fd_mask with size u32 + fds_bits: [fd_mask; 32], + } + + pub struct tm { + pub tm_sec: c_int, + pub tm_min: c_int, + pub tm_hour: c_int, + pub tm_mday: c_int, + pub tm_mon: c_int, + pub tm_year: c_int, + pub tm_wday: c_int, + pub tm_yday: c_int, + pub tm_isdst: c_int, + pub tm_gmtoff: c_int, + pub tm_zone: *mut c_char, + } + + pub struct utsname { + pub sysname: [c_char; 32], + pub nodename: [c_char; 32], + pub release: [c_char; 32], + pub version: [c_char; 32], + pub machine: [c_char; 32], + } + + pub struct lconv { + pub decimal_point: *mut c_char, + pub thousands_sep: *mut c_char, + pub grouping: *mut c_char, + pub int_curr_symbol: *mut c_char, + pub currency_symbol: *mut c_char, + pub mon_decimal_point: *mut c_char, + pub mon_thousands_sep: *mut c_char, + pub mon_grouping: *mut c_char, + pub positive_sign: *mut c_char, + pub negative_sign: *mut c_char, + pub int_frac_digits: c_char, + pub frac_digits: c_char, + pub p_cs_precedes: c_char, + pub p_sep_by_space: c_char, + pub n_cs_precedes: c_char, + pub n_sep_by_space: c_char, + pub p_sign_posn: c_char, + pub n_sign_posn: c_char, + pub int_p_cs_precedes: c_char, + pub int_p_sep_by_space: c_char, + pub int_n_cs_precedes: c_char, + pub int_n_sep_by_space: c_char, + pub int_p_sign_posn: c_char, + pub int_n_sign_posn: c_char, + } + + pub struct msghdr { + pub msg_name: *mut c_void, + pub msg_namelen: socklen_t, + pub msg_iov: *mut crate::iovec, + pub msg_iovlen: c_int, + pub msg_control: *mut c_void, + pub msg_controllen: socklen_t, + pub msg_flags: c_int, + } + + pub struct cmsghdr { + pub cmsg_len: crate::socklen_t, + pub cmsg_level: c_int, + pub cmsg_type: c_int, + } + + pub struct Dl_info { + pub dli_fname: *const c_char, + pub dli_fbase: *mut c_void, + pub dli_sname: *const c_char, + pub dli_saddr: *mut c_void, + } + + pub struct termios { + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_line: c_char, + pub c_ispeed: crate::speed_t, + pub c_ospeed: crate::speed_t, + pub c_cc: [crate::cc_t; crate::NCCS], + } + + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off_t, + pub l_len: off_t, + pub l_pid: crate::pid_t, + } + + pub struct stat { + pub st_dev: dev_t, + pub st_ino: ino_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_size: off_t, + pub st_rdev: dev_t, + pub st_blksize: blksize_t, + pub st_atime: time_t, + pub st_atime_nsec: c_long, + pub st_mtime: time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: time_t, + pub st_ctime_nsec: c_long, + pub st_crtime: time_t, + pub st_crtime_nsec: c_long, + pub st_type: u32, + pub st_blocks: blkcnt_t, + } + + pub struct glob_t { + pub gl_pathc: size_t, + __unused1: Padding, + pub gl_offs: size_t, + __unused2: Padding, + pub gl_pathv: *mut *mut c_char, + + __unused3: Padding<*mut c_void>, + __unused4: Padding<*mut c_void>, + __unused5: Padding<*mut c_void>, + __unused6: Padding<*mut c_void>, + __unused7: Padding<*mut c_void>, + __unused8: Padding<*mut c_void>, + } + + pub struct pthread_mutex_t { + flags: u32, + lock: i32, + unused: Padding, + owner: i32, + owner_count: i32, + } + + pub struct pthread_cond_t { + flags: u32, + unused: Padding, + mutex: *mut c_void, + waiter_count: i32, + lock: i32, + } + + pub struct pthread_rwlock_t { + flags: u32, + owner: i32, + lock_sem: i32, // this is actually a union + lock_count: i32, + reader_count: i32, + writer_count: i32, + waiters: [*mut c_void; 2], + } + + pub struct pthread_spinlock_t { + lock: u32, + } + + pub struct passwd { + pub pw_name: *mut c_char, + pub pw_passwd: *mut c_char, + pub pw_uid: crate::uid_t, + pub pw_gid: crate::gid_t, + pub pw_dir: *mut c_char, + pub pw_shell: *mut c_char, + pub pw_gecos: *mut c_char, + } + + pub struct statvfs { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_favail: crate::fsfilcnt_t, + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_size: size_t, + pub ss_flags: c_int, + } + + pub struct siginfo_t { + pub si_signo: c_int, + pub si_code: c_int, + pub si_errno: c_int, + pub si_pid: crate::pid_t, + pub si_uid: crate::uid_t, + pub si_addr: *mut c_void, + pub si_status: c_int, + pub si_band: c_long, + pub sigval: *mut c_void, + } + + pub struct sigaction { + pub sa_sigaction: crate::sighandler_t, //actually a union with sa_handler + pub sa_mask: crate::sigset_t, + pub sa_flags: c_int, + sa_userdata: *mut c_void, + } + + pub struct sem_t { + pub type_: i32, + pub named_sem_id: i32, // actually a union with unnamed_sem (i32) + padding: Padding<[i32; 2]>, + } + + pub struct ucred { + pub pid: crate::pid_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + } + + pub struct sockaddr_dl { + pub sdl_len: u8, + pub sdl_family: u8, + pub sdl_e_type: u16, + pub sdl_index: u32, + pub sdl_type: u8, + pub sdl_nlen: u8, + pub sdl_alen: u8, + pub sdl_slen: u8, + pub sdl_data: [u8; 46], + } + + pub struct spwd { + pub sp_namp: *mut c_char, + pub sp_pwdp: *mut c_char, + pub sp_lstchg: c_int, + pub sp_min: c_int, + pub sp_max: c_int, + pub sp_warn: c_int, + pub sp_inact: c_int, + pub sp_expire: c_int, + pub sp_flag: c_int, + } + + pub struct regex_t { + __buffer: *mut c_void, + __allocated: size_t, + __used: size_t, + __syntax: c_ulong, + __fastmap: *mut c_char, + __translate: *mut c_char, + __re_nsub: size_t, + __bitfield: u8, + } + + pub struct regmatch_t { + pub rm_so: regoff_t, + pub rm_eo: regoff_t, + } + + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + pub msg_qnum: crate::msgqnum_t, + pub msg_qbytes: crate::msglen_t, + pub msg_lspid: crate::pid_t, + pub msg_lrpid: crate::pid_t, + pub msg_stime: crate::time_t, + pub msg_rtime: crate::time_t, + pub msg_ctime: crate::time_t, + } + + pub struct ipc_perm { + pub key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: mode_t, + } + + pub struct sembuf { + pub sem_num: c_ushort, + pub sem_op: c_short, + pub sem_flg: c_short, + } + + pub struct entry { + pub key: *mut c_char, + pub data: *mut c_void, + } + + pub struct option { + pub name: *const c_char, + pub has_arg: c_int, + pub flag: *mut c_int, + pub val: c_int, + } + + pub struct sockaddr_un { + pub sun_len: u8, + pub sun_family: sa_family_t, + pub sun_path: [c_char; 126], + } + pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: sa_family_t, + __ss_pad1: Padding<[u8; 6]>, + __ss_pad2: Padding, + __ss_pad3: Padding<[u8; 112]>, + } + pub struct dirent { + pub d_dev: dev_t, + pub d_pdev: dev_t, + pub d_ino: ino_t, + pub d_pino: i64, + pub d_reclen: c_ushort, + pub d_name: [c_char; 1024], // Max length is _POSIX_PATH_MAX + } + + pub struct sigevent { + pub sigev_notify: c_int, + pub sigev_signo: c_int, + pub sigev_value: crate::sigval, + __unused1: Padding<*mut c_void>, // actually a function pointer + pub sigev_notify_attributes: *mut crate::pthread_attr_t, + } + + pub struct utmpx { + pub ut_type: c_short, + pub ut_tv: crate::timeval, + pub ut_id: [c_char; 8], + pub ut_pid: crate::pid_t, + pub ut_user: [c_char; 32], + pub ut_line: [c_char; 16], + pub ut_host: [c_char; 128], + __ut_reserved: Padding<[c_char; 64]>, + } +} + +pub const EXIT_FAILURE: c_int = 1; +pub const EXIT_SUCCESS: c_int = 0; +pub const RAND_MAX: c_int = 2147483647; +pub const EOF: c_int = -1; +pub const SEEK_SET: c_int = 0; +pub const SEEK_CUR: c_int = 1; +pub const SEEK_END: c_int = 2; +pub const L_SET: c_int = SEEK_SET; +pub const L_INCR: c_int = SEEK_CUR; +pub const L_XTND: c_int = SEEK_END; +pub const _IOFBF: c_int = 0; +pub const _IONBF: c_int = 2; +pub const _IOLBF: c_int = 1; + +pub const F_DUPFD: c_int = 0x0001; +pub const F_GETFD: c_int = 0x0002; +pub const F_SETFD: c_int = 0x0004; +pub const F_GETFL: c_int = 0x0008; +pub const F_SETFL: c_int = 0x0010; +pub const F_GETLK: c_int = 0x0020; +pub const F_SETLK: c_int = 0x0080; +pub const F_SETLKW: c_int = 0x0100; +pub const F_DUPFD_CLOEXEC: c_int = 0x0200; + +pub const F_RDLCK: c_int = 0x0040; +pub const F_UNLCK: c_int = 0x0200; +pub const F_WRLCK: c_int = 0x0400; + +pub const AT_FDCWD: c_int = -100; +pub const AT_SYMLINK_NOFOLLOW: c_int = 0x01; +pub const AT_SYMLINK_FOLLOW: c_int = 0x02; +pub const AT_REMOVEDIR: c_int = 0x04; +pub const AT_EACCESS: c_int = 0x08; + +pub const POLLIN: c_short = 0x0001; +pub const POLLOUT: c_short = 0x0002; +pub const POLLRDNORM: c_short = POLLIN; +pub const POLLWRNORM: c_short = POLLOUT; +pub const POLLRDBAND: c_short = 0x0008; +pub const POLLWRBAND: c_short = 0x0010; +pub const POLLPRI: c_short = 0x0020; +pub const POLLERR: c_short = 0x0004; +pub const POLLHUP: c_short = 0x0080; +pub const POLLNVAL: c_short = 0x1000; + +pub const PTHREAD_CREATE_JOINABLE: c_int = 0; +pub const PTHREAD_CREATE_DETACHED: c_int = 1; + +pub const CLOCK_REALTIME: c_int = -1; +pub const CLOCK_MONOTONIC: c_int = 0; +pub const CLOCK_PROCESS_CPUTIME_ID: c_int = -2; +pub const CLOCK_THREAD_CPUTIME_ID: c_int = -3; + +pub const RLIMIT_CORE: c_int = 0; +pub const RLIMIT_CPU: c_int = 1; +pub const RLIMIT_DATA: c_int = 2; +pub const RLIMIT_FSIZE: c_int = 3; +pub const RLIMIT_NOFILE: c_int = 4; +pub const RLIMIT_STACK: c_int = 5; +pub const RLIMIT_AS: c_int = 6; +pub const RLIM_INFINITY: crate::rlim_t = 0xffffffff; +// Haiku specific +pub const RLIMIT_NOVMON: c_int = 7; +#[deprecated(since = "0.2.64", note = "Not stable across OS versions")] +pub const RLIM_NLIMITS: c_int = 8; + +pub const RUSAGE_SELF: c_int = 0; + +pub const RTLD_LAZY: c_int = 0; + +pub const NCCS: usize = 11; + +pub const O_RDONLY: c_int = 0x0000; +pub const O_WRONLY: c_int = 0x0001; +pub const O_RDWR: c_int = 0x0002; +pub const O_ACCMODE: c_int = 0x0003; + +pub const O_EXCL: c_int = 0x0100; +pub const O_CREAT: c_int = 0x0200; +pub const O_TRUNC: c_int = 0x0400; +pub const O_NOCTTY: c_int = 0x1000; +pub const O_NOTRAVERSE: c_int = 0x2000; + +pub const O_CLOEXEC: c_int = 0x00000040; +pub const O_NONBLOCK: c_int = 0x00000080; +pub const O_APPEND: c_int = 0x00000800; +pub const O_SYNC: c_int = 0x00010000; +pub const O_RSYNC: c_int = 0x00020000; +pub const O_DSYNC: c_int = 0x00040000; +pub const O_NOFOLLOW: c_int = 0x00080000; +pub const O_NOCACHE: c_int = 0x00100000; +pub const O_DIRECTORY: c_int = 0x00200000; + +pub const S_IFIFO: mode_t = 0o1_0000; +pub const S_IFCHR: mode_t = 0o2_0000; +pub const S_IFBLK: mode_t = 0o6_0000; +pub const S_IFDIR: mode_t = 0o4_0000; +pub const S_IFREG: mode_t = 0o10_0000; +pub const S_IFLNK: mode_t = 0o12_0000; +pub const S_IFSOCK: mode_t = 0o14_0000; +pub const S_IFMT: mode_t = 0o17_0000; + +pub const S_IRWXU: mode_t = 0o0700; +pub const S_IRUSR: mode_t = 0o0400; +pub const S_IWUSR: mode_t = 0o0200; +pub const S_IXUSR: mode_t = 0o0100; +pub const S_IRWXG: mode_t = 0o0070; +pub const S_IRGRP: mode_t = 0o0040; +pub const S_IWGRP: mode_t = 0o0020; +pub const S_IXGRP: mode_t = 0o0010; +pub const S_IRWXO: mode_t = 0o0007; +pub const S_IROTH: mode_t = 0o0004; +pub const S_IWOTH: mode_t = 0o0002; +pub const S_IXOTH: mode_t = 0o0001; + +pub const F_OK: c_int = 0; +pub const R_OK: c_int = 4; +pub const W_OK: c_int = 2; +pub const X_OK: c_int = 1; + +pub const SIGHUP: c_int = 1; +pub const SIGINT: c_int = 2; +pub const SIGQUIT: c_int = 3; +pub const SIGILL: c_int = 4; +pub const SIGCHLD: c_int = 5; +pub const SIGABRT: c_int = 6; +pub const SIGPIPE: c_int = 7; +pub const SIGFPE: c_int = 8; +pub const SIGKILL: c_int = 9; +pub const SIGSTOP: c_int = 10; +pub const SIGSEGV: c_int = 11; +pub const SIGCONT: c_int = 12; +pub const SIGTSTP: c_int = 13; +pub const SIGALRM: c_int = 14; +pub const SIGTERM: c_int = 15; +pub const SIGTTIN: c_int = 16; +pub const SIGTTOU: c_int = 17; +pub const SIGUSR1: c_int = 18; +pub const SIGUSR2: c_int = 19; +pub const SIGWINCH: c_int = 20; +pub const SIGKILLTHR: c_int = 21; +pub const SIGTRAP: c_int = 22; +pub const SIGPOLL: c_int = 23; +pub const SIGPROF: c_int = 24; +pub const SIGSYS: c_int = 25; +pub const SIGURG: c_int = 26; +pub const SIGVTALRM: c_int = 27; +pub const SIGXCPU: c_int = 28; +pub const SIGXFSZ: c_int = 29; +pub const SIGBUS: c_int = 30; + +pub const SIG_BLOCK: c_int = 1; +pub const SIG_UNBLOCK: c_int = 2; +pub const SIG_SETMASK: c_int = 3; + +pub const SIGEV_NONE: c_int = 0; +pub const SIGEV_SIGNAL: c_int = 1; +pub const SIGEV_THREAD: c_int = 2; + +pub const EAI_AGAIN: c_int = 2; +pub const EAI_BADFLAGS: c_int = 3; +pub const EAI_FAIL: c_int = 4; +pub const EAI_FAMILY: c_int = 5; +pub const EAI_MEMORY: c_int = 6; +pub const EAI_NODATA: c_int = 7; +pub const EAI_NONAME: c_int = 8; +pub const EAI_SERVICE: c_int = 9; +pub const EAI_SOCKTYPE: c_int = 10; +pub const EAI_SYSTEM: c_int = 11; +pub const EAI_OVERFLOW: c_int = 14; + +pub const PROT_NONE: c_int = 0; +pub const PROT_READ: c_int = 1; +pub const PROT_WRITE: c_int = 2; +pub const PROT_EXEC: c_int = 4; + +pub const LC_ALL: c_int = 0; +pub const LC_COLLATE: c_int = 1; +pub const LC_CTYPE: c_int = 2; +pub const LC_MONETARY: c_int = 3; +pub const LC_NUMERIC: c_int = 4; +pub const LC_TIME: c_int = 5; +pub const LC_MESSAGES: c_int = 6; + +// FIXME(haiku): Haiku does not have MAP_FILE, but library/std/os.rs requires it +pub const MAP_FILE: c_int = 0x00; +pub const MAP_SHARED: c_int = 0x01; +pub const MAP_PRIVATE: c_int = 0x02; +pub const MAP_FIXED: c_int = 0x04; +pub const MAP_ANONYMOUS: c_int = 0x08; +pub const MAP_NORESERVE: c_int = 0x10; +pub const MAP_ANON: c_int = MAP_ANONYMOUS; + +pub const MAP_FAILED: *mut c_void = !0 as *mut c_void; + +pub const MS_ASYNC: c_int = 0x01; +pub const MS_INVALIDATE: c_int = 0x04; +pub const MS_SYNC: c_int = 0x02; + +pub const E2BIG: c_int = -2147454975; +pub const ECHILD: c_int = -2147454974; +pub const EDEADLK: c_int = -2147454973; +pub const EFBIG: c_int = -2147454972; +pub const EMLINK: c_int = -2147454971; +pub const ENFILE: c_int = -2147454970; +pub const ENODEV: c_int = -2147454969; +pub const ENOLCK: c_int = -2147454968; +pub const ENOSYS: c_int = -2147454967; +pub const ENOTTY: c_int = -2147454966; +pub const ENXIO: c_int = -2147454965; +pub const ESPIPE: c_int = -2147454964; +pub const ESRCH: c_int = -2147454963; +pub const EFPOS: c_int = -2147454962; +pub const ESIGPARM: c_int = -2147454961; +pub const EDOM: c_int = -2147454960; +pub const ERANGE: c_int = -2147454959; +pub const EPROTOTYPE: c_int = -2147454958; +pub const EPROTONOSUPPORT: c_int = -2147454957; +pub const EPFNOSUPPORT: c_int = -2147454956; +pub const EAFNOSUPPORT: c_int = -2147454955; +pub const EADDRINUSE: c_int = -2147454954; +pub const EADDRNOTAVAIL: c_int = -2147454953; +pub const ENETDOWN: c_int = -2147454952; +pub const ENETUNREACH: c_int = -2147454951; +pub const ENETRESET: c_int = -2147454950; +pub const ECONNABORTED: c_int = -2147454949; +pub const ECONNRESET: c_int = -2147454948; +pub const EISCONN: c_int = -2147454947; +pub const ENOTCONN: c_int = -2147454946; +pub const ESHUTDOWN: c_int = -2147454945; +pub const ECONNREFUSED: c_int = -2147454944; +pub const EHOSTUNREACH: c_int = -2147454943; +pub const ENOPROTOOPT: c_int = -2147454942; +pub const ENOBUFS: c_int = -2147454941; +pub const EINPROGRESS: c_int = -2147454940; +pub const EALREADY: c_int = -2147454939; +pub const EILSEQ: c_int = -2147454938; +pub const ENOMSG: c_int = -2147454937; +pub const ESTALE: c_int = -2147454936; +pub const EOVERFLOW: c_int = -2147454935; +pub const EMSGSIZE: c_int = -2147454934; +pub const EOPNOTSUPP: c_int = -2147454933; +pub const ENOTSOCK: c_int = -2147454932; +pub const EHOSTDOWN: c_int = -2147454931; +pub const EBADMSG: c_int = -2147454930; +pub const ECANCELED: c_int = -2147454929; +pub const EDESTADDRREQ: c_int = -2147454928; +pub const EDQUOT: c_int = -2147454927; +pub const EIDRM: c_int = -2147454926; +pub const EMULTIHOP: c_int = -2147454925; +pub const ENODATA: c_int = -2147454924; +pub const ENOLINK: c_int = -2147454923; +pub const ENOSR: c_int = -2147454922; +pub const ENOSTR: c_int = -2147454921; +pub const ENOTSUP: c_int = -2147454920; +pub const EPROTO: c_int = -2147454919; +pub const ETIME: c_int = -2147454918; +pub const ETXTBSY: c_int = -2147454917; +pub const ENOATTR: c_int = -2147454916; + +// INT_MIN +pub const ENOMEM: c_int = -2147483648; + +// POSIX errors that can be mapped to BeOS error codes +pub const EACCES: c_int = -2147483646; +pub const EINTR: c_int = -2147483638; +pub const EIO: c_int = -2147483647; +pub const EBUSY: c_int = -2147483634; +pub const EFAULT: c_int = -2147478783; +pub const ETIMEDOUT: c_int = -2147483639; +pub const EAGAIN: c_int = -2147483637; +pub const EWOULDBLOCK: c_int = -2147483637; +pub const EBADF: c_int = -2147459072; +pub const EEXIST: c_int = -2147459070; +pub const EINVAL: c_int = -2147483643; +pub const ENAMETOOLONG: c_int = -2147459068; +pub const ENOENT: c_int = -2147459069; +pub const EPERM: c_int = -2147483633; +pub const ENOTDIR: c_int = -2147459067; +pub const EISDIR: c_int = -2147459063; +pub const ENOTEMPTY: c_int = -2147459066; +pub const ENOSPC: c_int = -2147459065; +pub const EROFS: c_int = -2147459064; +pub const EMFILE: c_int = -2147459062; +pub const EXDEV: c_int = -2147459061; +pub const ELOOP: c_int = -2147459060; +pub const ENOEXEC: c_int = -2147478782; +pub const EPIPE: c_int = -2147459059; + +pub const IPPROTO_RAW: c_int = 255; + +// These are prefixed with POSIX_ on Haiku +pub const MADV_NORMAL: c_int = 1; +pub const MADV_SEQUENTIAL: c_int = 2; +pub const MADV_RANDOM: c_int = 3; +pub const MADV_WILLNEED: c_int = 4; +pub const MADV_DONTNEED: c_int = 5; +pub const MADV_FREE: c_int = 6; + +// https://github.com/haiku/haiku/blob/HEAD/headers/posix/net/if.h#L80 +pub const IFF_UP: c_int = 0x0001; +pub const IFF_BROADCAST: c_int = 0x0002; // valid broadcast address +pub const IFF_LOOPBACK: c_int = 0x0008; +pub const IFF_POINTOPOINT: c_int = 0x0010; // point-to-point link +pub const IFF_NOARP: c_int = 0x0040; // no address resolution +pub const IFF_AUTOUP: c_int = 0x0080; // auto dial +pub const IFF_PROMISC: c_int = 0x0100; // receive all packets +pub const IFF_ALLMULTI: c_int = 0x0200; // receive all multicast packets +pub const IFF_SIMPLEX: c_int = 0x0800; // doesn't receive own transmissions +pub const IFF_LINK: c_int = 0x1000; // has link +pub const IFF_AUTO_CONFIGURED: c_int = 0x2000; +pub const IFF_CONFIGURING: c_int = 0x4000; +pub const IFF_MULTICAST: c_int = 0x8000; // supports multicast + +pub const AF_UNSPEC: c_int = 0; +pub const AF_INET: c_int = 1; +pub const AF_APPLETALK: c_int = 2; +pub const AF_ROUTE: c_int = 3; +pub const AF_LINK: c_int = 4; +pub const AF_INET6: c_int = 5; +pub const AF_DLI: c_int = 6; +pub const AF_IPX: c_int = 7; +pub const AF_NOTIFY: c_int = 8; +pub const AF_LOCAL: c_int = 9; +pub const AF_UNIX: c_int = AF_LOCAL; +pub const AF_BLUETOOTH: c_int = 10; + +pub const PF_UNSPEC: c_int = AF_UNSPEC; +pub const PF_INET: c_int = AF_INET; +pub const PF_ROUTE: c_int = AF_ROUTE; +pub const PF_LINK: c_int = AF_LINK; +pub const PF_INET6: c_int = AF_INET6; +pub const PF_LOCAL: c_int = AF_LOCAL; +pub const PF_UNIX: c_int = AF_UNIX; +pub const PF_BLUETOOTH: c_int = AF_BLUETOOTH; + +pub const IP_OPTIONS: c_int = 1; +pub const IP_HDRINCL: c_int = 2; +pub const IP_TOS: c_int = 3; +pub const IP_TTL: c_int = 4; +pub const IP_RECVOPTS: c_int = 5; +pub const IP_RECVRETOPTS: c_int = 6; +pub const IP_RECVDSTADDR: c_int = 7; +pub const IP_RETOPTS: c_int = 8; +pub const IP_MULTICAST_IF: c_int = 9; +pub const IP_MULTICAST_TTL: c_int = 10; +pub const IP_MULTICAST_LOOP: c_int = 11; +pub const IP_ADD_MEMBERSHIP: c_int = 12; +pub const IP_DROP_MEMBERSHIP: c_int = 13; +pub const IP_BLOCK_SOURCE: c_int = 14; +pub const IP_UNBLOCK_SOURCE: c_int = 15; +pub const IP_ADD_SOURCE_MEMBERSHIP: c_int = 16; +pub const IP_DROP_SOURCE_MEMBERSHIP: c_int = 17; + +pub const TCP_NODELAY: c_int = 0x01; +pub const TCP_MAXSEG: c_int = 0x02; +pub const TCP_NOPUSH: c_int = 0x04; +pub const TCP_NOOPT: c_int = 0x08; + +pub const IF_NAMESIZE: size_t = 32; +pub const IFNAMSIZ: size_t = IF_NAMESIZE; + +pub const IPV6_MULTICAST_IF: c_int = 24; +pub const IPV6_MULTICAST_HOPS: c_int = 25; +pub const IPV6_MULTICAST_LOOP: c_int = 26; +pub const IPV6_UNICAST_HOPS: c_int = 27; +pub const IPV6_JOIN_GROUP: c_int = 28; +pub const IPV6_LEAVE_GROUP: c_int = 29; +pub const IPV6_V6ONLY: c_int = 30; +pub const IPV6_PKTINFO: c_int = 31; +pub const IPV6_RECVPKTINFO: c_int = 32; +pub const IPV6_HOPLIMIT: c_int = 33; +pub const IPV6_RECVHOPLIMIT: c_int = 34; +pub const IPV6_HOPOPTS: c_int = 35; +pub const IPV6_DSTOPTS: c_int = 36; +pub const IPV6_RTHDR: c_int = 37; + +pub const MSG_OOB: c_int = 0x0001; +pub const MSG_PEEK: c_int = 0x0002; +pub const MSG_DONTROUTE: c_int = 0x0004; +pub const MSG_EOR: c_int = 0x0008; +pub const MSG_TRUNC: c_int = 0x0010; +pub const MSG_CTRUNC: c_int = 0x0020; +pub const MSG_WAITALL: c_int = 0x0040; +pub const MSG_DONTWAIT: c_int = 0x0080; +pub const MSG_BCAST: c_int = 0x0100; +pub const MSG_MCAST: c_int = 0x0200; +pub const MSG_EOF: c_int = 0x0400; +pub const MSG_NOSIGNAL: c_int = 0x0800; + +pub const SHUT_RD: c_int = 0; +pub const SHUT_WR: c_int = 1; +pub const SHUT_RDWR: c_int = 2; + +pub const LOCK_SH: c_int = 0x01; +pub const LOCK_EX: c_int = 0x02; +pub const LOCK_NB: c_int = 0x04; +pub const LOCK_UN: c_int = 0x08; + +pub const MINSIGSTKSZ: size_t = 8192; +pub const SIGSTKSZ: size_t = 16384; + +pub const IOV_MAX: c_int = 1024; +pub const PATH_MAX: c_int = 1024; + +pub const SA_NOCLDSTOP: c_int = 0x01; +pub const SA_NOCLDWAIT: c_int = 0x02; +pub const SA_RESETHAND: c_int = 0x04; +pub const SA_NODEFER: c_int = 0x08; +pub const SA_RESTART: c_int = 0x10; +pub const SA_ONSTACK: c_int = 0x20; +pub const SA_SIGINFO: c_int = 0x40; +pub const SA_NOMASK: c_int = SA_NODEFER; +pub const SA_STACK: c_int = SA_ONSTACK; +pub const SA_ONESHOT: c_int = SA_RESETHAND; + +pub const SS_ONSTACK: c_int = 0x1; +pub const SS_DISABLE: c_int = 0x2; + +// DIFF(main): changed to `c_int` in 500365e1 +pub const FD_SETSIZE: usize = 1024; + +pub const RTLD_LOCAL: c_int = 0x0; +pub const RTLD_NOW: c_int = 0x1; +pub const RTLD_GLOBAL: c_int = 0x2; +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); + +pub const BUFSIZ: c_uint = 8192; +pub const FILENAME_MAX: c_uint = 256; +pub const FOPEN_MAX: c_uint = 128; +pub const L_tmpnam: c_uint = 512; +pub const TMP_MAX: c_uint = 32768; + +pub const _PC_CHOWN_RESTRICTED: c_int = 1; +pub const _PC_MAX_CANON: c_int = 2; +pub const _PC_MAX_INPUT: c_int = 3; +pub const _PC_NAME_MAX: c_int = 4; +pub const _PC_NO_TRUNC: c_int = 5; +pub const _PC_PATH_MAX: c_int = 6; +pub const _PC_PIPE_BUF: c_int = 7; +pub const _PC_VDISABLE: c_int = 8; +pub const _PC_LINK_MAX: c_int = 25; +pub const _PC_SYNC_IO: c_int = 26; +pub const _PC_ASYNC_IO: c_int = 27; +pub const _PC_PRIO_IO: c_int = 28; +pub const _PC_SOCK_MAXBUF: c_int = 29; +pub const _PC_FILESIZEBITS: c_int = 30; +pub const _PC_REC_INCR_XFER_SIZE: c_int = 31; +pub const _PC_REC_MAX_XFER_SIZE: c_int = 32; +pub const _PC_REC_MIN_XFER_SIZE: c_int = 33; +pub const _PC_REC_XFER_ALIGN: c_int = 34; +pub const _PC_ALLOC_SIZE_MIN: c_int = 35; +pub const _PC_SYMLINK_MAX: c_int = 36; +pub const _PC_2_SYMLINKS: c_int = 37; +pub const _PC_XATTR_EXISTS: c_int = 38; +pub const _PC_XATTR_ENABLED: c_int = 39; + +pub const FIONBIO: c_ulong = 0xbe000000; +pub const FIONREAD: c_ulong = 0xbe000001; +pub const FIOSEEKDATA: c_ulong = 0xbe000002; +pub const FIOSEEKHOLE: c_ulong = 0xbe000003; + +pub const _SC_ARG_MAX: c_int = 15; +pub const _SC_CHILD_MAX: c_int = 16; +pub const _SC_CLK_TCK: c_int = 17; +pub const _SC_JOB_CONTROL: c_int = 18; +pub const _SC_NGROUPS_MAX: c_int = 19; +pub const _SC_OPEN_MAX: c_int = 20; +pub const _SC_SAVED_IDS: c_int = 21; +pub const _SC_STREAM_MAX: c_int = 22; +pub const _SC_TZNAME_MAX: c_int = 23; +pub const _SC_VERSION: c_int = 24; +pub const _SC_GETGR_R_SIZE_MAX: c_int = 25; +pub const _SC_GETPW_R_SIZE_MAX: c_int = 26; +pub const _SC_PAGESIZE: c_int = 27; +pub const _SC_PAGE_SIZE: c_int = 27; +pub const _SC_SEM_NSEMS_MAX: c_int = 28; +pub const _SC_SEM_VALUE_MAX: c_int = 29; +pub const _SC_SEMAPHORES: c_int = 30; +pub const _SC_THREADS: c_int = 31; +pub const _SC_IOV_MAX: c_int = 32; +pub const _SC_UIO_MAXIOV: c_int = 32; +pub const _SC_NPROCESSORS_CONF: c_int = 34; +pub const _SC_NPROCESSORS_ONLN: c_int = 35; +pub const _SC_ATEXIT_MAX: c_int = 37; +pub const _SC_PASS_MAX: c_int = 39; +pub const _SC_PHYS_PAGES: c_int = 40; +pub const _SC_AVPHYS_PAGES: c_int = 41; +pub const _SC_PIPE: c_int = 42; +pub const _SC_SELECT: c_int = 43; +pub const _SC_POLL: c_int = 44; +pub const _SC_MAPPED_FILES: c_int = 45; +pub const _SC_THREAD_PROCESS_SHARED: c_int = 46; +pub const _SC_THREAD_STACK_MIN: c_int = 47; +pub const _SC_THREAD_ATTR_STACKADDR: c_int = 48; +pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 49; +pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 50; +pub const _SC_REALTIME_SIGNALS: c_int = 51; +pub const _SC_MEMORY_PROTECTION: c_int = 52; +pub const _SC_SIGQUEUE_MAX: c_int = 53; +pub const _SC_RTSIG_MAX: c_int = 54; +pub const _SC_MONOTONIC_CLOCK: c_int = 55; +pub const _SC_DELAYTIMER_MAX: c_int = 56; +pub const _SC_TIMER_MAX: c_int = 57; +pub const _SC_TIMERS: c_int = 58; +pub const _SC_CPUTIME: c_int = 59; +pub const _SC_THREAD_CPUTIME: c_int = 60; +pub const _SC_HOST_NAME_MAX: c_int = 61; +pub const _SC_REGEXP: c_int = 62; +pub const _SC_SYMLOOP_MAX: c_int = 63; +pub const _SC_SHELL: c_int = 64; +pub const _SC_TTY_NAME_MAX: c_int = 65; +pub const _SC_ADVISORY_INFO: c_int = 66; +pub const _SC_BARRIERS: c_int = 67; +pub const _SC_CLOCK_SELECTION: c_int = 68; +pub const _SC_FSYNC: c_int = 69; +pub const _SC_IPV6: c_int = 70; +pub const _SC_MEMLOCK: c_int = 71; +pub const _SC_MEMLOCK_RANGE: c_int = 72; +pub const _SC_MESSAGE_PASSING: c_int = 73; +pub const _SC_PRIORITIZED_IO: c_int = 74; +pub const _SC_PRIORITY_SCHEDULING: c_int = 75; +pub const _SC_READER_WRITER_LOCKS: c_int = 76; +pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 77; +pub const _SC_SPAWN: c_int = 78; +pub const _SC_SPIN_LOCKS: c_int = 79; +pub const _SC_SPORADIC_SERVER: c_int = 80; +pub const _SC_SYNCHRONIZED_IO: c_int = 81; +pub const _SC_THREAD_PRIO_INHERIT: c_int = 82; +pub const _SC_THREAD_PRIO_PROTECT: c_int = 83; +pub const _SC_THREAD_ROBUST_PRIO_INHERIT: c_int = 84; +pub const _SC_THREAD_ROBUST_PRIO_PROTECT: c_int = 85; +pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 86; +pub const _SC_THREAD_SPORADIC_SERVER: c_int = 87; +pub const _SC_TIMEOUTS: c_int = 88; +pub const _SC_TRACE: c_int = 89; +pub const _SC_TRACE_EVENT_FILTER: c_int = 90; +pub const _SC_TRACE_INHERIT: c_int = 91; +pub const _SC_TRACE_LOG: c_int = 92; +pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 93; +pub const _SC_V6_ILP32_OFF32: c_int = 94; +pub const _SC_V6_ILP32_OFFBIG: c_int = 95; +pub const _SC_V6_LP64_OFF64: c_int = 96; +pub const _SC_V6_LPBIG_OFFBIG: c_int = 97; +pub const _SC_V7_ILP32_OFF32: c_int = 98; +pub const _SC_V7_ILP32_OFFBIG: c_int = 99; +pub const _SC_V7_LP64_OFF64: c_int = 100; +pub const _SC_V7_LPBIG_OFFBIG: c_int = 101; +pub const _SC_2_C_BIND: c_int = 102; +pub const _SC_2_C_DEV: c_int = 103; +pub const _SC_2_CHAR_TERM: c_int = 104; +pub const _SC_2_FORT_DEV: c_int = 105; +pub const _SC_2_FORT_RUN: c_int = 106; +pub const _SC_2_LOCALEDEF: c_int = 107; +pub const _SC_2_PBS: c_int = 108; +pub const _SC_2_PBS_ACCOUNTING: c_int = 109; +pub const _SC_2_PBS_CHECKPOINT: c_int = 110; +pub const _SC_2_PBS_LOCATE: c_int = 111; +pub const _SC_2_PBS_MESSAGE: c_int = 112; +pub const _SC_2_PBS_TRACK: c_int = 113; +pub const _SC_2_SW_DEV: c_int = 114; +pub const _SC_2_UPE: c_int = 115; +pub const _SC_2_VERSION: c_int = 116; +pub const _SC_XOPEN_CRYPT: c_int = 117; +pub const _SC_XOPEN_ENH_I18N: c_int = 118; +pub const _SC_XOPEN_REALTIME: c_int = 119; +pub const _SC_XOPEN_REALTIME_THREADS: c_int = 120; +pub const _SC_XOPEN_SHM: c_int = 121; +pub const _SC_XOPEN_STREAMS: c_int = 122; +pub const _SC_XOPEN_UNIX: c_int = 123; +pub const _SC_XOPEN_UUCP: c_int = 124; +pub const _SC_XOPEN_VERSION: c_int = 125; +pub const _SC_BC_BASE_MAX: c_int = 129; +pub const _SC_BC_DIM_MAX: c_int = 130; +pub const _SC_BC_SCALE_MAX: c_int = 131; +pub const _SC_BC_STRING_MAX: c_int = 132; +pub const _SC_COLL_WEIGHTS_MAX: c_int = 133; +pub const _SC_EXPR_NEST_MAX: c_int = 134; +pub const _SC_LINE_MAX: c_int = 135; +pub const _SC_LOGIN_NAME_MAX: c_int = 136; +pub const _SC_MQ_OPEN_MAX: c_int = 137; +pub const _SC_MQ_PRIO_MAX: c_int = 138; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 139; +pub const _SC_THREAD_KEYS_MAX: c_int = 140; +pub const _SC_THREAD_THREADS_MAX: c_int = 141; +pub const _SC_RE_DUP_MAX: c_int = 142; + +pub const PTHREAD_STACK_MIN: size_t = 8192; + +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + flags: 0, + lock: 0, + unused: Padding::new(0), + owner: -1, + owner_count: 0, +}; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + flags: 0, + unused: Padding::new(0), + mutex: 0 as *mut _, + waiter_count: 0, + lock: 0, +}; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + flags: 0, + owner: -1, + lock_sem: 0, + lock_count: 0, + reader_count: 0, + writer_count: 0, + waiters: [0 as *mut _; 2], +}; + +pub const PTHREAD_MUTEX_DEFAULT: c_int = 0; +pub const PTHREAD_MUTEX_NORMAL: c_int = 1; +pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 2; +pub const PTHREAD_MUTEX_RECURSIVE: c_int = 3; + +pub const FIOCLEX: c_ulong = 0; // FIXME(haiku): does not exist on Haiku! + +pub const RUSAGE_CHILDREN: c_int = -1; + +pub const SOCK_STREAM: c_int = 1; +pub const SOCK_DGRAM: c_int = 2; +pub const SOCK_RAW: c_int = 3; +pub const SOCK_SEQPACKET: c_int = 5; +pub const SOCK_NONBLOCK: c_int = 0x00040000; +pub const SOCK_CLOEXEC: c_int = 0x00080000; + +pub const SOL_SOCKET: c_int = -1; +pub const SO_ACCEPTCONN: c_int = 0x00000001; +pub const SO_BROADCAST: c_int = 0x00000002; +pub const SO_DEBUG: c_int = 0x00000004; +pub const SO_DONTROUTE: c_int = 0x00000008; +pub const SO_KEEPALIVE: c_int = 0x00000010; +pub const SO_OOBINLINE: c_int = 0x00000020; +pub const SO_REUSEADDR: c_int = 0x00000040; +pub const SO_REUSEPORT: c_int = 0x00000080; +pub const SO_USELOOPBACK: c_int = 0x00000100; +pub const SO_LINGER: c_int = 0x00000200; +pub const SO_SNDBUF: c_int = 0x40000001; +pub const SO_SNDLOWAT: c_int = 0x40000002; +pub const SO_SNDTIMEO: c_int = 0x40000003; +pub const SO_RCVBUF: c_int = 0x40000004; +pub const SO_RCVLOWAT: c_int = 0x40000005; +pub const SO_RCVTIMEO: c_int = 0x40000006; +pub const SO_ERROR: c_int = 0x40000007; +pub const SO_TYPE: c_int = 0x40000008; +pub const SO_NONBLOCK: c_int = 0x40000009; +pub const SO_BINDTODEVICE: c_int = 0x4000000a; +pub const SO_PEERCRED: c_int = 0x4000000b; + +pub const SCM_RIGHTS: c_int = 0x01; + +pub const SOMAXCONN: c_int = 32; + +pub const NI_MAXHOST: size_t = 1025; + +pub const WNOHANG: c_int = 0x01; +pub const WUNTRACED: c_int = 0x02; +pub const WCONTINUED: c_int = 0x04; +pub const WEXITED: c_int = 0x08; +pub const WSTOPPED: c_int = 0x10; +pub const WNOWAIT: c_int = 0x20; + +// si_code values for SIGBUS signal +pub const BUS_ADRALN: c_int = 40; +pub const BUS_ADRERR: c_int = 41; +pub const BUS_OBJERR: c_int = 42; + +// si_code values for SIGCHLD signal +pub const CLD_EXITED: c_int = 60; +pub const CLD_KILLED: c_int = 61; +pub const CLD_DUMPED: c_int = 62; +pub const CLD_TRAPPED: c_int = 63; +pub const CLD_STOPPED: c_int = 64; +pub const CLD_CONTINUED: c_int = 65; + +pub const P_ALL: idtype_t = 0; +pub const P_PID: idtype_t = 1; +pub const P_PGID: idtype_t = 2; + +pub const UTIME_OMIT: c_long = 1000000001; +pub const UTIME_NOW: c_long = 1000000000; + +pub const VINTR: usize = 0; +pub const VQUIT: usize = 1; +pub const VERASE: usize = 2; +pub const VKILL: usize = 3; +pub const VEOF: usize = 4; +pub const VEOL: usize = 5; +pub const VMIN: usize = 4; +pub const VTIME: usize = 5; +pub const VEOL2: usize = 6; +pub const VSWTCH: usize = 7; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VSUSP: usize = 10; + +pub const IGNBRK: crate::tcflag_t = 0x01; +pub const BRKINT: crate::tcflag_t = 0x02; +pub const IGNPAR: crate::tcflag_t = 0x04; +pub const PARMRK: crate::tcflag_t = 0x08; +pub const INPCK: crate::tcflag_t = 0x10; +pub const ISTRIP: crate::tcflag_t = 0x20; +pub const INLCR: crate::tcflag_t = 0x40; +pub const IGNCR: crate::tcflag_t = 0x80; +pub const ICRNL: crate::tcflag_t = 0x100; +pub const IUCLC: crate::tcflag_t = 0x200; +pub const IXON: crate::tcflag_t = 0x400; +pub const IXANY: crate::tcflag_t = 0x800; +pub const IXOFF: crate::tcflag_t = 0x1000; + +pub const OPOST: crate::tcflag_t = 0x00000001; +pub const OLCUC: crate::tcflag_t = 0x00000002; +pub const ONLCR: crate::tcflag_t = 0x00000004; +pub const OCRNL: crate::tcflag_t = 0x00000008; +pub const ONOCR: crate::tcflag_t = 0x00000010; +pub const ONLRET: crate::tcflag_t = 0x00000020; +pub const OFILL: crate::tcflag_t = 0x00000040; +pub const OFDEL: crate::tcflag_t = 0x00000080; +pub const NLDLY: crate::tcflag_t = 0x00000100; +pub const NL0: crate::tcflag_t = 0x00000000; +pub const NL1: crate::tcflag_t = 0x00000100; +pub const CRDLY: crate::tcflag_t = 0x00000600; +pub const CR0: crate::tcflag_t = 0x00000000; +pub const CR1: crate::tcflag_t = 0x00000200; +pub const CR2: crate::tcflag_t = 0x00000400; +pub const CR3: crate::tcflag_t = 0x00000600; +pub const TABDLY: crate::tcflag_t = 0x00001800; +pub const TAB0: crate::tcflag_t = 0x00000000; +pub const TAB1: crate::tcflag_t = 0x00000800; +pub const TAB2: crate::tcflag_t = 0x00001000; +pub const TAB3: crate::tcflag_t = 0x00001800; +pub const BSDLY: crate::tcflag_t = 0x00002000; +pub const BS0: crate::tcflag_t = 0x00000000; +pub const BS1: crate::tcflag_t = 0x00002000; +pub const VTDLY: crate::tcflag_t = 0x00004000; +pub const VT0: crate::tcflag_t = 0x00000000; +pub const VT1: crate::tcflag_t = 0x00004000; +pub const FFDLY: crate::tcflag_t = 0x00008000; +pub const FF0: crate::tcflag_t = 0x00000000; +pub const FF1: crate::tcflag_t = 0x00008000; + +pub const CSIZE: crate::tcflag_t = 0x00000020; +pub const CS5: crate::tcflag_t = 0x00000000; +pub const CS6: crate::tcflag_t = 0x00000000; +pub const CS7: crate::tcflag_t = 0x00000000; +pub const CS8: crate::tcflag_t = 0x00000020; +pub const CSTOPB: crate::tcflag_t = 0x00000040; +pub const CREAD: crate::tcflag_t = 0x00000080; +pub const PARENB: crate::tcflag_t = 0x00000100; +pub const PARODD: crate::tcflag_t = 0x00000200; +pub const HUPCL: crate::tcflag_t = 0x00000400; +pub const CLOCAL: crate::tcflag_t = 0x00000800; +pub const XLOBLK: crate::tcflag_t = 0x00001000; +pub const CTSFLOW: crate::tcflag_t = 0x00002000; +pub const RTSFLOW: crate::tcflag_t = 0x00004000; +pub const CRTSCTS: crate::tcflag_t = RTSFLOW | CTSFLOW; + +pub const ISIG: crate::tcflag_t = 0x00000001; +pub const ICANON: crate::tcflag_t = 0x00000002; +pub const XCASE: crate::tcflag_t = 0x00000004; +pub const ECHO: crate::tcflag_t = 0x00000008; +pub const ECHOE: crate::tcflag_t = 0x00000010; +pub const ECHOK: crate::tcflag_t = 0x00000020; +pub const ECHONL: crate::tcflag_t = 0x00000040; +pub const NOFLSH: crate::tcflag_t = 0x00000080; +pub const TOSTOP: crate::tcflag_t = 0x00000100; +pub const IEXTEN: crate::tcflag_t = 0x00000200; +pub const ECHOCTL: crate::tcflag_t = 0x00000400; +pub const ECHOPRT: crate::tcflag_t = 0x00000800; +pub const ECHOKE: crate::tcflag_t = 0x00001000; +pub const FLUSHO: crate::tcflag_t = 0x00002000; +pub const PENDIN: crate::tcflag_t = 0x00004000; + +pub const TCGB_CTS: c_int = 0x01; +pub const TCGB_DSR: c_int = 0x02; +pub const TCGB_RI: c_int = 0x04; +pub const TCGB_DCD: c_int = 0x08; +pub const TIOCM_CTS: c_int = TCGB_CTS; +pub const TIOCM_CD: c_int = TCGB_DCD; +pub const TIOCM_CAR: c_int = TCGB_DCD; +pub const TIOCM_RI: c_int = TCGB_RI; +pub const TIOCM_RNG: c_int = TCGB_RI; +pub const TIOCM_DSR: c_int = TCGB_DSR; +pub const TIOCM_DTR: c_int = 0x10; +pub const TIOCM_RTS: c_int = 0x20; + +pub const B0: speed_t = 0x00; +pub const B50: speed_t = 0x01; +pub const B75: speed_t = 0x02; +pub const B110: speed_t = 0x03; +pub const B134: speed_t = 0x04; +pub const B150: speed_t = 0x05; +pub const B200: speed_t = 0x06; +pub const B300: speed_t = 0x07; +pub const B600: speed_t = 0x08; +pub const B1200: speed_t = 0x09; +pub const B1800: speed_t = 0x0A; +pub const B2400: speed_t = 0x0B; +pub const B4800: speed_t = 0x0C; +pub const B9600: speed_t = 0x0D; +pub const B19200: speed_t = 0x0E; +pub const B38400: speed_t = 0x0F; +pub const B57600: speed_t = 0x10; +pub const B115200: speed_t = 0x11; +pub const B230400: speed_t = 0x12; +pub const B31250: speed_t = 0x13; + +pub const TCSANOW: c_int = 0x01; +pub const TCSADRAIN: c_int = 0x02; +pub const TCSAFLUSH: c_int = 0x04; + +pub const TCOOFF: c_int = 0x01; +pub const TCOON: c_int = 0x02; +pub const TCIOFF: c_int = 0x04; +pub const TCION: c_int = 0x08; + +pub const TCIFLUSH: c_int = 0x01; +pub const TCOFLUSH: c_int = 0x02; +pub const TCIOFLUSH: c_int = 0x03; + +pub const TCGETA: c_ulong = 0x8000; +pub const TCSETA: c_ulong = TCGETA + 1; +pub const TCSETAF: c_ulong = TCGETA + 2; +pub const TCSETAW: c_ulong = TCGETA + 3; +pub const TCSBRK: c_ulong = TCGETA + 5; +pub const TCFLSH: c_ulong = TCGETA + 6; +pub const TCXONC: c_ulong = TCGETA + 7; +pub const TCGETBITS: c_ulong = TCGETA + 9; +pub const TCSETDTR: c_ulong = TCGETA + 10; +pub const TCSETRTS: c_ulong = TCGETA + 11; +pub const TIOCGWINSZ: c_ulong = TCGETA + 12; +pub const TIOCSWINSZ: c_ulong = TCGETA + 13; +pub const TIOCGPGRP: c_ulong = TCGETA + 15; +pub const TIOCSPGRP: c_ulong = TCGETA + 16; +pub const TIOCSCTTY: c_ulong = TCGETA + 17; +pub const TIOCMGET: c_ulong = TCGETA + 18; +pub const TIOCMSET: c_ulong = TCGETA + 19; +pub const TIOCSBRK: c_ulong = TCGETA + 20; +pub const TIOCCBRK: c_ulong = TCGETA + 21; +pub const TIOCMBIS: c_ulong = TCGETA + 22; +pub const TIOCMBIC: c_ulong = TCGETA + 23; +pub const TIOCGSID: c_ulong = TCGETA + 24; +pub const TIOCOUTQ: c_ulong = TCGETA + 25; +pub const TIOCEXCL: c_ulong = TCGETA + 26; +pub const TIOCNXCL: c_ulong = TCGETA + 27; + +pub const PRIO_PROCESS: c_int = 0; +pub const PRIO_PGRP: c_int = 1; +pub const PRIO_USER: c_int = 2; + +// utmpx entry types +pub const EMPTY: c_short = 0; +pub const BOOT_TIME: c_short = 1; +pub const OLD_TIME: c_short = 2; +pub const NEW_TIME: c_short = 3; +pub const USER_PROCESS: c_short = 4; +pub const INIT_PROCESS: c_short = 5; +pub const LOGIN_PROCESS: c_short = 6; +pub const DEAD_PROCESS: c_short = 7; + +pub const LOG_PID: c_int = 1 << 12; +pub const LOG_CONS: c_int = 2 << 12; +pub const LOG_ODELAY: c_int = 4 << 12; +pub const LOG_NDELAY: c_int = 8 << 12; +pub const LOG_SERIAL: c_int = 16 << 12; +pub const LOG_PERROR: c_int = 32 << 12; +pub const LOG_NOWAIT: c_int = 64 << 12; + +// spawn.h +// DIFF(main): changed to `c_short` in f62eb023ab +pub const POSIX_SPAWN_RESETIDS: c_int = 0x01; +pub const POSIX_SPAWN_SETPGROUP: c_int = 0x02; +pub const POSIX_SPAWN_SETSIGDEF: c_int = 0x10; +pub const POSIX_SPAWN_SETSIGMASK: c_int = 0x20; +pub const POSIX_SPAWN_SETSID: c_int = 0x40; + +const fn CMSG_ALIGN(len: usize) -> usize { + len + size_of::() - 1 & !(size_of::() - 1) +} + +f! { + pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { + if (*mhdr).msg_controllen as usize >= size_of::() { + (*mhdr).msg_control as *mut cmsghdr + } else { + core::ptr::null_mut::() + } + } + + pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { + (cmsg as *mut c_uchar).offset(CMSG_ALIGN(size_of::()) as isize) + } + + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { + (CMSG_ALIGN(length as usize) + CMSG_ALIGN(size_of::())) as c_uint + } + + pub const fn CMSG_LEN(length: c_uint) -> c_uint { + CMSG_ALIGN(size_of::()) as c_uint + length + } + + pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { + if cmsg.is_null() { + return crate::CMSG_FIRSTHDR(mhdr); + } + let next = cmsg as usize + + CMSG_ALIGN((*cmsg).cmsg_len as usize) + + CMSG_ALIGN(size_of::()); + let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; + if next > max { + core::ptr::null_mut::() + } else { + (cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr + } + } + + pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { + let fd = fd as usize; + let size = size_of_val(&(*set).fds_bits[0]) * 8; + (*set).fds_bits[fd / size] &= !(1 << (fd % size)); + return; + } + + pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { + let fd = fd as usize; + let size = size_of_val(&(*set).fds_bits[0]) * 8; + return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0; + } + + pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { + let fd = fd as usize; + let size = size_of_val(&(*set).fds_bits[0]) * 8; + (*set).fds_bits[fd / size] |= 1 << (fd % size); + return; + } + + pub fn FD_ZERO(set: *mut fd_set) -> () { + for slot in (*set).fds_bits.iter_mut() { + *slot = 0; + } + } +} + +safe_f! { + pub const fn WIFEXITED(status: c_int) -> bool { + (status & !0xff) == 0 + } + + pub const fn WEXITSTATUS(status: c_int) -> c_int { + status & 0xff + } + + pub const fn WIFSIGNALED(status: c_int) -> bool { + ((status >> 8) & 0xff) != 0 + } + + pub const fn WTERMSIG(status: c_int) -> c_int { + (status >> 8) & 0xff + } + + pub const fn WIFSTOPPED(status: c_int) -> bool { + ((status >> 16) & 0xff) != 0 + } + + pub const fn WSTOPSIG(status: c_int) -> c_int { + (status >> 16) & 0xff + } + + // actually WIFCORED, but this is used everywhere else + pub const fn WCOREDUMP(status: c_int) -> bool { + (status & 0x10000) != 0 + } + + pub const fn WIFCONTINUED(status: c_int) -> bool { + (status & 0x20000) != 0 + } +} + +extern "C" { + pub fn getrlimit(resource: c_int, rlim: *mut crate::rlimit) -> c_int; + pub fn setrlimit(resource: c_int, rlim: *const crate::rlimit) -> c_int; + pub fn getpriority(which: c_int, who: id_t) -> c_int; + pub fn setpriority(which: c_int, who: id_t, priority: c_int) -> c_int; + + pub fn endusershell(); + pub fn getpass(prompt: *const c_char) -> *mut c_char; + pub fn getusershell() -> *mut c_char; + pub fn issetugid() -> c_int; + pub fn setusershell(); + + pub fn utimensat( + fd: c_int, + path: *const c_char, + times: *const crate::timespec, + flag: c_int, + ) -> c_int; + pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int; + pub fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int; + pub fn _errnop() -> *mut c_int; + + pub fn abs(i: c_int) -> c_int; + pub fn labs(i: c_long) -> c_long; + pub fn rand() -> c_int; + pub fn srand(seed: c_uint); + pub fn getifaddrs(ifap: *mut *mut crate::ifaddrs) -> c_int; + pub fn freeifaddrs(ifa: *mut crate::ifaddrs); + pub fn ppoll( + fds: *mut crate::pollfd, + numfds: crate::nfds_t, + timeout: *const crate::timespec, + sigMask: *const sigset_t, + ) -> c_int; + + pub fn getspent() -> *mut spwd; + pub fn getspent_r( + pwd: *mut spwd, + buf: *mut c_char, + bufferSize: size_t, + res: *mut *mut spwd, + ) -> c_int; + pub fn setspent(); + pub fn endspent(); + pub fn getspnam(name: *const c_char) -> *mut spwd; + pub fn getspnam_r( + name: *const c_char, + spwd: *mut spwd, + buffer: *mut c_char, + bufferSize: size_t, + res: *mut *mut spwd, + ) -> c_int; + pub fn sgetspent(line: *const c_char) -> *mut spwd; + pub fn sgetspent_r( + line: *const c_char, + spwd: *mut spwd, + buffer: *mut c_char, + bufferSize: size_t, + res: *mut *mut spwd, + ) -> c_int; + pub fn fgetspent(file: *mut crate::FILE) -> *mut spwd; + pub fn fgetspent_r( + file: *mut crate::FILE, + spwd: *mut spwd, + buffer: *mut c_char, + bufferSize: size_t, + res: *mut *mut spwd, + ) -> c_int; + pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; + pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; + pub fn sem_destroy(sem: *mut sem_t) -> c_int; + pub fn sem_init(sem: *mut sem_t, pshared: c_int, value: c_uint) -> c_int; + + pub fn clock_getres(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; + pub fn clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; + pub fn clock_settime(clk_id: crate::clockid_t, tp: *const crate::timespec) -> c_int; + pub fn clock_getcpuclockid(pid: crate::pid_t, clk_id: *mut crate::clockid_t) -> c_int; + pub fn pthread_create( + thread: *mut crate::pthread_t, + attr: *const crate::pthread_attr_t, + f: extern "C" fn(*mut c_void) -> *mut c_void, + value: *mut c_void, + ) -> c_int; + pub fn pthread_attr_getguardsize( + attr: *const crate::pthread_attr_t, + guardsize: *mut size_t, + ) -> c_int; + pub fn pthread_attr_setguardsize(attr: *mut crate::pthread_attr_t, guardsize: size_t) -> c_int; + pub fn pthread_attr_getstack( + attr: *const crate::pthread_attr_t, + stackaddr: *mut *mut c_void, + stacksize: *mut size_t, + ) -> c_int; + pub fn pthread_condattr_getclock( + attr: *const pthread_condattr_t, + clock_id: *mut clockid_t, + ) -> c_int; + pub fn pthread_condattr_setclock( + attr: *mut pthread_condattr_t, + clock_id: crate::clockid_t, + ) -> c_int; + pub fn valloc(numBytes: size_t) -> *mut c_void; + pub fn malloc_usable_size(ptr: *mut c_void) -> size_t; + pub fn memalign(align: size_t, size: size_t) -> *mut c_void; + pub fn setgroups(ngroups: c_int, ptr: *const crate::gid_t) -> c_int; + pub fn initgroups(name: *const c_char, basegid: crate::gid_t) -> c_int; + pub fn ioctl(fd: c_int, request: c_ulong, ...) -> c_int; + pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; + pub fn dirfd(dirp: *mut crate::DIR) -> c_int; + pub fn getnameinfo( + sa: *const crate::sockaddr, + salen: crate::socklen_t, + host: *mut c_char, + hostlen: crate::socklen_t, + serv: *mut c_char, + servlen: crate::socklen_t, + flags: c_int, + ) -> c_int; + pub fn pthread_mutex_timedlock( + lock: *mut pthread_mutex_t, + abstime: *const crate::timespec, + ) -> c_int; + pub fn pthread_sigqueue(thread: crate::pthread_t, sig: c_int, value: crate::sigval) -> c_int; + pub fn pthread_spin_init(lock: *mut crate::pthread_spinlock_t, pshared: c_int) -> c_int; + pub fn pthread_spin_destroy(lock: *mut crate::pthread_spinlock_t) -> c_int; + pub fn pthread_spin_lock(lock: *mut crate::pthread_spinlock_t) -> c_int; + pub fn pthread_spin_trylock(lock: *mut crate::pthread_spinlock_t) -> c_int; + pub fn pthread_spin_unlock(lock: *mut crate::pthread_spinlock_t) -> c_int; + pub fn waitid( + idtype: idtype_t, + id: id_t, + infop: *mut crate::siginfo_t, + options: c_int, + ) -> c_int; + + pub fn glob( + pattern: *const c_char, + flags: c_int, + errfunc: Option c_int>, + pglob: *mut crate::glob_t, + ) -> c_int; + pub fn globfree(pglob: *mut crate::glob_t); + pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut c_void) -> c_int; + pub fn posix_madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; + pub fn posix_fadvise(fd: c_int, offset: off_t, len: off_t, advice: c_int) -> c_int; + pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int; + + pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int; + pub fn shm_unlink(name: *const c_char) -> c_int; + + pub fn seekdir(dirp: *mut crate::DIR, loc: c_long); + + pub fn telldir(dirp: *mut crate::DIR) -> c_long; + pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; + + pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int; + + pub fn recvfrom( + socket: c_int, + buf: *mut c_void, + len: size_t, + flags: c_int, + addr: *mut crate::sockaddr, + addrlen: *mut crate::socklen_t, + ) -> ssize_t; + pub fn nl_langinfo(item: crate::nl_item) -> *mut c_char; + + pub fn bind( + socket: c_int, + address: *const crate::sockaddr, + address_len: crate::socklen_t, + ) -> c_int; + + pub fn accept4( + socket: c_int, + address: *mut crate::sockaddr, + addressLength: *mut crate::socklen_t, + flags: c_int, + ) -> c_int; + + pub fn writev(fd: c_int, iov: *const crate::iovec, count: c_int) -> ssize_t; + pub fn readv(fd: c_int, iov: *const crate::iovec, count: c_int) -> ssize_t; + + pub fn sendmsg(fd: c_int, msg: *const crate::msghdr, flags: c_int) -> ssize_t; + pub fn recvmsg(fd: c_int, msg: *mut crate::msghdr, flags: c_int) -> ssize_t; + + // DIFF(main): changed to `*const *mut` in e77f551de9 + pub fn execvpe( + file: *const c_char, + argv: *const *const c_char, + environment: *const *const c_char, + ) -> c_int; + + pub fn getgrgid_r( + gid: crate::gid_t, + grp: *mut crate::group, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::group, + ) -> c_int; + pub fn getgrouplist( + user: *const c_char, + basegroup: crate::gid_t, + grouplist: *mut crate::gid_t, + groupcount: *mut c_int, + ) -> c_int; + pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> c_int; + pub fn sigsuspend(mask: *const crate::sigset_t) -> c_int; + pub fn sem_close(sem: *mut sem_t) -> c_int; + pub fn getdtablesize() -> c_int; + pub fn getgrnam_r( + name: *const c_char, + grp: *mut crate::group, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::group, + ) -> c_int; + pub fn pthread_sigmask(how: c_int, set: *const sigset_t, oldset: *mut sigset_t) -> c_int; + pub fn sem_open(name: *const c_char, oflag: c_int, ...) -> *mut sem_t; + pub fn getgrnam(name: *const c_char) -> *mut crate::group; + pub fn pthread_kill(thread: crate::pthread_t, sig: c_int) -> c_int; + pub fn sem_unlink(name: *const c_char) -> c_int; + pub fn getpwnam_r( + name: *const c_char, + pwd: *mut passwd, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut passwd, + ) -> c_int; + pub fn getpwuid_r( + uid: crate::uid_t, + pwd: *mut passwd, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut passwd, + ) -> c_int; + pub fn getpwent() -> *mut passwd; + pub fn setpwent(); + pub fn endpwent(); + pub fn endgrent(); + pub fn getgrent() -> *mut crate::group; + pub fn setgrent(); + pub fn sigwait(set: *const sigset_t, sig: *mut c_int) -> c_int; + pub fn pthread_atfork( + prepare: Option, + parent: Option, + child: Option, + ) -> c_int; + pub fn getgrgid(gid: crate::gid_t) -> *mut crate::group; + pub fn popen(command: *const c_char, mode: *const c_char) -> *mut crate::FILE; + pub fn sethostname(name: *const c_char, len: size_t) -> c_int; + pub fn uname(buf: *mut crate::utsname) -> c_int; + pub fn getutxent() -> *mut utmpx; + pub fn getutxid(ut: *const utmpx) -> *mut utmpx; + pub fn getutxline(ut: *const utmpx) -> *mut utmpx; + pub fn pututxline(ut: *const utmpx) -> *mut utmpx; + pub fn setutxent(); + pub fn endutxent(); + pub fn faccessat(dirfd: c_int, pathname: *const c_char, mode: c_int, flags: c_int) -> c_int; + + pub fn sigtimedwait( + set: *const sigset_t, + info: *mut siginfo_t, + timeout: *const crate::timespec, + ) -> c_int; + pub fn sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> c_int; + + pub fn getitimer(which: c_int, curr_value: *mut crate::itimerval) -> c_int; + pub fn setitimer( + which: c_int, + new_value: *const crate::itimerval, + old_value: *mut crate::itimerval, + ) -> c_int; + + pub fn regcomp(preg: *mut regex_t, pattern: *const c_char, cflags: c_int) -> c_int; + + pub fn regexec( + preg: *const regex_t, + input: *const c_char, + nmatch: size_t, + pmatch: *mut regmatch_t, + eflags: c_int, + ) -> c_int; + + pub fn regerror( + errcode: c_int, + preg: *const regex_t, + errbuf: *mut c_char, + errbuf_size: size_t, + ) -> size_t; + + pub fn regfree(preg: *mut regex_t); + + pub fn msgctl(msqid: c_int, cmd: c_int, buf: *mut msqid_ds) -> c_int; + pub fn msgget(key: crate::key_t, msgflg: c_int) -> c_int; + pub fn msgrcv( + msqid: c_int, + msgp: *mut c_void, + msgsz: size_t, + msgtype: c_long, + msgflg: c_int, + ) -> ssize_t; + pub fn msgsnd(msqid: c_int, msgp: *const c_void, msgsz: size_t, msgflg: c_int) -> c_int; + pub fn semget(key: crate::key_t, nsems: c_int, semflg: c_int) -> c_int; + pub fn semctl(semid: c_int, semnum: c_int, cmd: c_int, ...) -> c_int; + pub fn semop(semid: c_int, sops: *mut sembuf, nsops: size_t) -> c_int; + pub fn ftok(pathname: *const c_char, proj_id: c_int) -> crate::key_t; + + pub fn memrchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; + + pub fn lsearch( + key: *const c_void, + base: *mut c_void, + nelp: *mut size_t, + width: size_t, + compar: Option c_int>, + ) -> *mut c_void; + pub fn lfind( + key: *const c_void, + base: *const c_void, + nelp: *mut size_t, + width: size_t, + compar: Option c_int>, + ) -> *mut c_void; + pub fn hcreate(nelt: size_t) -> c_int; + pub fn hdestroy(); + pub fn hsearch(entry: crate::ENTRY, action: crate::ACTION) -> *mut crate::ENTRY; + + pub fn drand48() -> c_double; + pub fn erand48(xseed: *mut c_ushort) -> c_double; + pub fn lrand48() -> c_long; + pub fn nrand48(xseed: *mut c_ushort) -> c_long; + pub fn mrand48() -> c_long; + pub fn jrand48(xseed: *mut c_ushort) -> c_long; + pub fn srand48(seed: c_long); + pub fn seed48(xseed: *mut c_ushort) -> *mut c_ushort; + pub fn lcong48(p: *mut c_ushort); + + pub fn clearenv() -> c_int; + pub fn ctermid(s: *mut c_char) -> *mut c_char; + + pub fn sync(); + pub fn getpagesize() -> c_int; + + pub fn brk(addr: *mut c_void) -> c_int; + pub fn sbrk(increment: intptr_t) -> *mut c_void; + + pub fn posix_spawn( + pid: *mut crate::pid_t, + path: *const c_char, + file_actions: *const crate::posix_spawn_file_actions_t, + attrp: *const crate::posix_spawnattr_t, + argv: *const *mut c_char, + envp: *const *mut c_char, + ) -> c_int; + pub fn posix_spawnp( + pid: *mut crate::pid_t, + file: *const c_char, + file_actions: *const crate::posix_spawn_file_actions_t, + attrp: *const crate::posix_spawnattr_t, + argv: *const *mut c_char, + envp: *const *mut c_char, + ) -> c_int; + + pub fn posix_spawn_file_actions_init(file_actions: *mut posix_spawn_file_actions_t) -> c_int; + pub fn posix_spawn_file_actions_destroy(file_actions: *mut posix_spawn_file_actions_t) + -> c_int; + pub fn posix_spawn_file_actions_addopen( + file_actions: *mut posix_spawn_file_actions_t, + fildes: c_int, + path: *const c_char, + oflag: c_int, + mode: mode_t, + ) -> c_int; + pub fn posix_spawn_file_actions_addclose( + file_actions: *mut posix_spawn_file_actions_t, + fildes: c_int, + ) -> c_int; + pub fn posix_spawn_file_actions_adddup2( + file_actions: *mut posix_spawn_file_actions_t, + fildes: c_int, + newfildes: c_int, + ) -> c_int; + + pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> c_int; + pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> c_int; + pub fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t, _flags: *mut c_short) -> c_int; + pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t, flags: c_short) -> c_int; + pub fn posix_spawnattr_getpgroup( + attr: *const posix_spawnattr_t, + _pgroup: *mut crate::pid_t, + ) -> c_int; + pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, pgroup: crate::pid_t) -> c_int; + pub fn posix_spawnattr_getsigdefault( + attr: *const posix_spawnattr_t, + sigdefault: *mut crate::sigset_t, + ) -> c_int; + pub fn posix_spawnattr_setsigdefault( + attr: *mut posix_spawnattr_t, + sigdefault: *const crate::sigset_t, + ) -> c_int; + pub fn posix_spawnattr_getsigmask( + attr: *const posix_spawnattr_t, + _sigmask: *mut crate::sigset_t, + ) -> c_int; + pub fn posix_spawnattr_setsigmask( + attr: *mut posix_spawnattr_t, + sigmask: *const crate::sigset_t, + ) -> c_int; + pub fn getopt_long( + argc: c_int, + argv: *const *mut c_char, + optstring: *const c_char, + longopts: *const option, + longindex: *mut c_int, + ) -> c_int; + pub fn strcasecmp_l( + string1: *const c_char, + string2: *const c_char, + locale: crate::locale_t, + ) -> c_int; + pub fn strncasecmp_l( + string1: *const c_char, + string2: *const c_char, + length: size_t, + locale: crate::locale_t, + ) -> c_int; + + pub fn getentropy(buf: *mut c_void, buflen: size_t) -> c_int; +} + +#[link(name = "gnu")] +extern "C" { + pub fn memmem( + source: *const c_void, + sourceLength: size_t, + search: *const c_void, + searchLength: size_t, + ) -> *mut c_void; + + pub fn pthread_getattr_np(thread: crate::pthread_t, attr: *mut crate::pthread_attr_t) -> c_int; + pub fn pthread_getname_np( + thread: crate::pthread_t, + buffer: *mut c_char, + length: size_t, + ) -> c_int; + pub fn pthread_setname_np(thread: crate::pthread_t, name: *const c_char) -> c_int; +} + +cfg_if! { + if #[cfg(target_pointer_width = "64")] { + mod b64; + pub use self::b64::*; + } else { + mod b32; + pub use self::b32::*; + } +} + +cfg_if! { + if #[cfg(target_arch = "x86")] { + // TODO + // mod x86; + // pub use self::x86::*; + } else if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } else if #[cfg(target_arch = "aarch64")] { + // TODO + // mod aarch64; + // pub use self::aarch64::*; + } +} + +mod bsd; +pub use self::bsd::*; + +mod native; +pub use self::native::*; diff --git a/http/vendor/libc/src/unix/haiku/native.rs b/http/vendor/libc/src/unix/haiku/native.rs new file mode 100644 index 0000000..99ceab8 --- /dev/null +++ b/http/vendor/libc/src/unix/haiku/native.rs @@ -0,0 +1,1390 @@ +use crate::off_t; +use crate::prelude::*; + +// This file follows the Haiku API for Haiku R1 beta 5. It is organized by the +// C/C++ header files in which the concepts can be found, while adhering to the +// style guide for this crate. + +// Helper macro to generate u32 constants. The Haiku API uses (non-standard) +// multi-character constants (like 'UPDA' or 'MSGM') to represent 32 bit +// integer constants. + +macro_rules! haiku_constant { + ($a:tt, $b:tt, $c:tt, $d:tt) => { + (($a as u32) << 24) + (($b as u32) << 16) + (($c as u32) << 8) + ($d as u32) + }; +} + +// support/SupportDefs.h +pub type status_t = i32; +pub type bigtime_t = i64; +pub type nanotime_t = i64; +pub type type_code = u32; +pub type perform_code = u32; + +// kernel/OS.h +pub type area_id = i32; +pub type port_id = i32; +pub type sem_id = i32; +pub type team_id = i32; +pub type thread_id = i32; + +pub type thread_func = extern "C" fn(*mut c_void) -> status_t; + +// kernel/image.h +pub type image_id = i32; + +c_enum! { + // kernel/OS.h + pub enum thread_state { + pub B_THREAD_RUNNING = 1, + pub B_THREAD_READY, + pub B_THREAD_RECEIVING, + pub B_THREAD_ASLEEP, + pub B_THREAD_SUSPENDED, + pub B_THREAD_WAITING, + } + + // kernel/image.h + pub enum image_type { + pub B_APP_IMAGE = 1, + pub B_LIBRARY_IMAGE, + pub B_ADD_ON_IMAGE, + pub B_SYSTEM_IMAGE, + } + + // kernel/scheduler.h + + pub enum be_task_flags { + pub B_DEFAULT_MEDIA_PRIORITY = 0x000, + pub B_OFFLINE_PROCESSING = 0x001, + pub B_STATUS_RENDERING = 0x002, + pub B_USER_INPUT_HANDLING = 0x004, + pub B_LIVE_VIDEO_MANIPULATION = 0x008, + pub B_VIDEO_PLAYBACK = 0x010, + pub B_VIDEO_RECORDING = 0x020, + pub B_LIVE_AUDIO_MANIPULATION = 0x040, + pub B_AUDIO_PLAYBACK = 0x080, + pub B_AUDIO_RECORDING = 0x100, + pub B_LIVE_3D_RENDERING = 0x200, + pub B_NUMBER_CRUNCHING = 0x400, + pub B_MIDI_PROCESSING = 0x800, + } + + pub enum schduler_mode { + pub SCHEDULER_MODE_LOW_LATENCY, + pub SCHEDULER_MODE_POWER_SAVING, + } + + // FindDirectory.h + pub enum path_base_directory { + pub B_FIND_PATH_INSTALLATION_LOCATION_DIRECTORY, + pub B_FIND_PATH_ADD_ONS_DIRECTORY, + pub B_FIND_PATH_APPS_DIRECTORY, + pub B_FIND_PATH_BIN_DIRECTORY, + pub B_FIND_PATH_BOOT_DIRECTORY, + pub B_FIND_PATH_CACHE_DIRECTORY, + pub B_FIND_PATH_DATA_DIRECTORY, + pub B_FIND_PATH_DEVELOP_DIRECTORY, + pub B_FIND_PATH_DEVELOP_LIB_DIRECTORY, + pub B_FIND_PATH_DOCUMENTATION_DIRECTORY, + pub B_FIND_PATH_ETC_DIRECTORY, + pub B_FIND_PATH_FONTS_DIRECTORY, + pub B_FIND_PATH_HEADERS_DIRECTORY, + pub B_FIND_PATH_LIB_DIRECTORY, + pub B_FIND_PATH_LOG_DIRECTORY, + pub B_FIND_PATH_MEDIA_NODES_DIRECTORY, + pub B_FIND_PATH_PACKAGES_DIRECTORY, + pub B_FIND_PATH_PREFERENCES_DIRECTORY, + pub B_FIND_PATH_SERVERS_DIRECTORY, + pub B_FIND_PATH_SETTINGS_DIRECTORY, + pub B_FIND_PATH_SOUNDS_DIRECTORY, + pub B_FIND_PATH_SPOOL_DIRECTORY, + pub B_FIND_PATH_TRANSLATORS_DIRECTORY, + pub B_FIND_PATH_VAR_DIRECTORY, + pub B_FIND_PATH_IMAGE_PATH = 1000, + pub B_FIND_PATH_PACKAGE_PATH, + } + + pub enum directory_which { + pub B_DESKTOP_DIRECTORY = 0, + pub B_TRASH_DIRECTORY, + pub B_SYSTEM_DIRECTORY = 1000, + pub B_SYSTEM_ADDONS_DIRECTORY = 1002, + pub B_SYSTEM_BOOT_DIRECTORY, + pub B_SYSTEM_FONTS_DIRECTORY, + pub B_SYSTEM_LIB_DIRECTORY, + pub B_SYSTEM_SERVERS_DIRECTORY, + pub B_SYSTEM_APPS_DIRECTORY, + pub B_SYSTEM_BIN_DIRECTORY, + pub B_SYSTEM_DOCUMENTATION_DIRECTORY = 1010, + pub B_SYSTEM_PREFERENCES_DIRECTORY, + pub B_SYSTEM_TRANSLATORS_DIRECTORY, + pub B_SYSTEM_MEDIA_NODES_DIRECTORY, + pub B_SYSTEM_SOUNDS_DIRECTORY, + pub B_SYSTEM_DATA_DIRECTORY, + pub B_SYSTEM_DEVELOP_DIRECTORY, + pub B_SYSTEM_PACKAGES_DIRECTORY, + pub B_SYSTEM_HEADERS_DIRECTORY, + pub B_SYSTEM_ETC_DIRECTORY = 2008, + pub B_SYSTEM_SETTINGS_DIRECTORY = 2010, + pub B_SYSTEM_LOG_DIRECTORY = 2012, + pub B_SYSTEM_SPOOL_DIRECTORY, + pub B_SYSTEM_TEMP_DIRECTORY, + pub B_SYSTEM_VAR_DIRECTORY, + pub B_SYSTEM_CACHE_DIRECTORY = 2020, + pub B_SYSTEM_NONPACKAGED_DIRECTORY = 2023, + pub B_SYSTEM_NONPACKAGED_ADDONS_DIRECTORY, + pub B_SYSTEM_NONPACKAGED_TRANSLATORS_DIRECTORY, + pub B_SYSTEM_NONPACKAGED_MEDIA_NODES_DIRECTORY, + pub B_SYSTEM_NONPACKAGED_BIN_DIRECTORY, + pub B_SYSTEM_NONPACKAGED_DATA_DIRECTORY, + pub B_SYSTEM_NONPACKAGED_FONTS_DIRECTORY, + pub B_SYSTEM_NONPACKAGED_SOUNDS_DIRECTORY, + pub B_SYSTEM_NONPACKAGED_DOCUMENTATION_DIRECTORY, + pub B_SYSTEM_NONPACKAGED_LIB_DIRECTORY, + pub B_SYSTEM_NONPACKAGED_HEADERS_DIRECTORY, + pub B_SYSTEM_NONPACKAGED_DEVELOP_DIRECTORY, + pub B_USER_DIRECTORY = 3000, + pub B_USER_CONFIG_DIRECTORY, + pub B_USER_ADDONS_DIRECTORY, + pub B_USER_BOOT_DIRECTORY, + pub B_USER_FONTS_DIRECTORY, + pub B_USER_LIB_DIRECTORY, + pub B_USER_SETTINGS_DIRECTORY, + pub B_USER_DESKBAR_DIRECTORY, + pub B_USER_PRINTERS_DIRECTORY, + pub B_USER_TRANSLATORS_DIRECTORY, + pub B_USER_MEDIA_NODES_DIRECTORY, + pub B_USER_SOUNDS_DIRECTORY, + pub B_USER_DATA_DIRECTORY, + pub B_USER_CACHE_DIRECTORY, + pub B_USER_PACKAGES_DIRECTORY, + pub B_USER_HEADERS_DIRECTORY, + pub B_USER_NONPACKAGED_DIRECTORY, + pub B_USER_NONPACKAGED_ADDONS_DIRECTORY, + pub B_USER_NONPACKAGED_TRANSLATORS_DIRECTORY, + pub B_USER_NONPACKAGED_MEDIA_NODES_DIRECTORY, + pub B_USER_NONPACKAGED_BIN_DIRECTORY, + pub B_USER_NONPACKAGED_DATA_DIRECTORY, + pub B_USER_NONPACKAGED_FONTS_DIRECTORY, + pub B_USER_NONPACKAGED_SOUNDS_DIRECTORY, + pub B_USER_NONPACKAGED_DOCUMENTATION_DIRECTORY, + pub B_USER_NONPACKAGED_LIB_DIRECTORY, + pub B_USER_NONPACKAGED_HEADERS_DIRECTORY, + pub B_USER_NONPACKAGED_DEVELOP_DIRECTORY, + pub B_USER_DEVELOP_DIRECTORY, + pub B_USER_DOCUMENTATION_DIRECTORY, + pub B_USER_SERVERS_DIRECTORY, + pub B_USER_APPS_DIRECTORY, + pub B_USER_BIN_DIRECTORY, + pub B_USER_PREFERENCES_DIRECTORY, + pub B_USER_ETC_DIRECTORY, + pub B_USER_LOG_DIRECTORY, + pub B_USER_SPOOL_DIRECTORY, + pub B_USER_VAR_DIRECTORY, + pub B_APPS_DIRECTORY = 4000, + pub B_PREFERENCES_DIRECTORY, + pub B_UTILITIES_DIRECTORY, + pub B_PACKAGE_LINKS_DIRECTORY, + } + + // kernel/OS.h + + pub enum topology_level_type { + pub B_TOPOLOGY_UNKNOWN, + pub B_TOPOLOGY_ROOT, + pub B_TOPOLOGY_SMT, + pub B_TOPOLOGY_CORE, + pub B_TOPOLOGY_PACKAGE, + } + + pub enum cpu_platform { + pub B_CPU_UNKNOWN, + pub B_CPU_x86, + pub B_CPU_x86_64, + pub B_CPU_PPC, + pub B_CPU_PPC_64, + pub B_CPU_M68K, + pub B_CPU_ARM, + pub B_CPU_ARM_64, + pub B_CPU_ALPHA, + pub B_CPU_MIPS, + pub B_CPU_SH, + pub B_CPU_SPARC, + pub B_CPU_RISC_V, + } + + pub enum cpu_vendor { + pub B_CPU_VENDOR_UNKNOWN, + pub B_CPU_VENDOR_AMD, + pub B_CPU_VENDOR_CYRIX, + pub B_CPU_VENDOR_IDT, + pub B_CPU_VENDOR_INTEL, + pub B_CPU_VENDOR_NATIONAL_SEMICONDUCTOR, + pub B_CPU_VENDOR_RISE, + pub B_CPU_VENDOR_TRANSMETA, + pub B_CPU_VENDOR_VIA, + pub B_CPU_VENDOR_IBM, + pub B_CPU_VENDOR_MOTOROLA, + pub B_CPU_VENDOR_NEC, + pub B_CPU_VENDOR_HYGON, + pub B_CPU_VENDOR_SUN, + pub B_CPU_VENDOR_FUJITSU, + } +} + +s! { + // kernel/OS.h + pub struct area_info { + pub area: area_id, + pub name: [c_char; B_OS_NAME_LENGTH], + pub size: usize, + pub lock: u32, + pub protection: u32, + pub team: team_id, + pub ram_size: u32, + pub copy_count: u32, + pub in_count: u32, + pub out_count: u32, + pub address: *mut c_void, + } + + pub struct port_info { + pub port: port_id, + pub team: team_id, + pub name: [c_char; B_OS_NAME_LENGTH], + pub capacity: i32, + pub queue_count: i32, + pub total_count: i32, + } + + pub struct port_message_info { + pub size: size_t, + pub sender: crate::uid_t, + pub sender_group: crate::gid_t, + pub sender_team: crate::team_id, + } + + pub struct team_info { + pub team: team_id, + pub thread_count: i32, + pub image_count: i32, + pub area_count: i32, + pub debugger_nub_thread: thread_id, + pub debugger_nub_port: port_id, + pub argc: i32, + pub args: [c_char; 64], + pub uid: crate::uid_t, + pub gid: crate::gid_t, + } + + pub struct sem_info { + pub sem: sem_id, + pub team: team_id, + pub name: [c_char; B_OS_NAME_LENGTH], + pub count: i32, + pub latest_holder: thread_id, + } + + pub struct team_usage_info { + pub user_time: bigtime_t, + pub kernel_time: bigtime_t, + } + + pub struct thread_info { + pub thread: thread_id, + pub team: team_id, + pub name: [c_char; B_OS_NAME_LENGTH], + pub state: thread_state, + pub priority: i32, + pub sem: sem_id, + pub user_time: bigtime_t, + pub kernel_time: bigtime_t, + pub stack_base: *mut c_void, + pub stack_end: *mut c_void, + } + + pub struct cpu_info { + pub active_time: bigtime_t, + pub enabled: bool, + pub current_frequency: u64, + } + + pub struct system_info { + pub boot_time: bigtime_t, + pub cpu_count: u32, + pub max_pages: u64, + pub used_pages: u64, + pub cached_pages: u64, + pub block_cache_pages: u64, + pub ignored_pages: u64, + pub needed_memory: u64, + pub free_memory: u64, + pub max_swap_pages: u64, + pub free_swap_pages: u64, + pub page_faults: u32, + pub max_sems: u32, + pub used_sems: u32, + pub max_ports: u32, + pub used_ports: u32, + pub max_threads: u32, + pub used_threads: u32, + pub max_teams: u32, + pub used_teams: u32, + pub kernel_name: [c_char; B_FILE_NAME_LENGTH], + pub kernel_build_date: [c_char; B_OS_NAME_LENGTH], + pub kernel_build_time: [c_char; B_OS_NAME_LENGTH], + pub kernel_version: i64, + pub abi: u32, + } + + pub struct object_wait_info { + pub object: i32, + pub type_: u16, + pub events: u16, + } + + pub struct cpu_topology_root_info { + pub platform: cpu_platform, + } + + pub struct cpu_topology_package_info { + pub vendor: cpu_vendor, + pub cache_line_size: u32, + } + + pub struct cpu_topology_core_info { + pub model: u32, + pub default_frequency: u64, + } + // kernel/fs_attr.h + pub struct attr_info { + pub type_: u32, + pub size: off_t, + } + + // kernel/fs_index.h + pub struct index_info { + pub type_: u32, + pub size: off_t, + pub modification_time: crate::time_t, + pub creation_time: crate::time_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + } + + //kernel/fs_info.h + pub struct fs_info { + pub dev: crate::dev_t, + pub root: crate::ino_t, + pub flags: u32, + pub block_size: off_t, + pub io_size: off_t, + pub total_blocks: off_t, + pub free_blocks: off_t, + pub total_nodes: off_t, + pub free_nodes: off_t, + pub device_name: [c_char; 128], + pub volume_name: [c_char; B_FILE_NAME_LENGTH], + pub fsh_name: [c_char; B_OS_NAME_LENGTH], + } + + // kernel/image.h + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct image_info { + pub id: image_id, + pub image_type: c_int, + pub sequence: i32, + pub init_order: i32, + // FIXME(1.0): these should be made optional + pub init_routine: extern "C" fn(), + pub term_routine: extern "C" fn(), + pub device: crate::dev_t, + pub node: crate::ino_t, + pub name: [c_char; crate::PATH_MAX as usize], + pub text: *mut c_void, + pub data: *mut c_void, + pub text_size: i32, + pub data_size: i32, + pub api_version: i32, + pub abi: i32, + } + + pub struct __c_anonymous_eax_0 { + pub max_eax: u32, + pub vendor_id: [c_char; 12], + } + + pub struct __c_anonymous_eax_1 { + pub stepping: u32, + pub model: u32, + pub family: u32, + pub tpe: u32, + __reserved_0: Padding, + pub extended_model: u32, + pub extended_family: u32, + __reserved_1: Padding, + pub brand_index: u32, + pub clflush: u32, + pub logical_cpus: u32, + pub apic_id: u32, + pub features: u32, + pub extended_features: u32, + } + + pub struct __c_anonymous_eax_2 { + pub call_num: u8, + pub cache_descriptors: [u8; 15], + } + + pub struct __c_anonymous_eax_3 { + __reserved: Padding<[u32; 2]>, + pub serial_number_high: u32, + pub serial_number_low: u32, + } + + pub struct __c_anonymous_regs { + pub eax: u32, + pub ebx: u32, + pub edx: u32, + pub ecx: u32, + } + + pub struct cpu_topology_node_info { + pub id: u32, + pub type_: topology_level_type, + pub level: u32, + pub data: __c_anonymous_cpu_topology_info_data, + } +} + +s_no_extra_traits! { + pub union cpuid_info { + pub eax_0: __c_anonymous_eax_0, + pub eax_1: __c_anonymous_eax_1, + pub eax_2: __c_anonymous_eax_2, + pub eax_3: __c_anonymous_eax_3, + pub as_chars: [c_char; 16], + pub regs: __c_anonymous_regs, + } + + pub union __c_anonymous_cpu_topology_info_data { + pub root: cpu_topology_root_info, + pub package: cpu_topology_package_info, + pub core: cpu_topology_core_info, + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for cpuid_info { + fn eq(&self, other: &cpuid_info) -> bool { + unsafe { + self.eax_0 == other.eax_0 + || self.eax_1 == other.eax_1 + || self.eax_2 == other.eax_2 + || self.eax_3 == other.eax_3 + || self.as_chars == other.as_chars + || self.regs == other.regs + } + } + } + impl Eq for cpuid_info {} + impl hash::Hash for cpuid_info { + fn hash(&self, _state: &mut H) { + unimplemented!("traits"); + } + } + + impl PartialEq for __c_anonymous_cpu_topology_info_data { + fn eq(&self, other: &__c_anonymous_cpu_topology_info_data) -> bool { + unsafe { + self.root == other.root + || self.package == other.package + || self.core == other.core + } + } + } + impl Eq for __c_anonymous_cpu_topology_info_data {} + impl hash::Hash for __c_anonymous_cpu_topology_info_data { + fn hash(&self, _state: &mut H) { + unimplemented!("traits"); + } + } + } +} + +// kernel/OS.h +pub const B_OS_NAME_LENGTH: usize = 32; +pub const B_PAGE_SIZE: usize = 4096; +pub const B_INFINITE_TIMEOUT: usize = 9223372036854775807; + +pub const B_RELATIVE_TIMEOUT: u32 = 0x8; +pub const B_ABSOLUTE_TIMEOUT: u32 = 0x10; +pub const B_TIMEOUT_REAL_TIME_BASE: u32 = 0x40; +pub const B_ABSOLUTE_REAL_TIME_TIMEOUT: u32 = B_ABSOLUTE_TIMEOUT | B_TIMEOUT_REAL_TIME_BASE; + +pub const B_NO_LOCK: u32 = 0; +pub const B_LAZY_LOCK: u32 = 1; +pub const B_FULL_LOCK: u32 = 2; +pub const B_CONTIGUOUS: u32 = 3; +pub const B_LOMEM: u32 = 4; +pub const B_32_BIT_FULL_LOCK: u32 = 5; +pub const B_32_BIT_CONTIGUOUS: u32 = 6; + +pub const B_ANY_ADDRESS: u32 = 0; +pub const B_EXACT_ADDRESS: u32 = 1; +pub const B_BASE_ADDRESS: u32 = 2; +pub const B_CLONE_ADDRESS: u32 = 3; +pub const B_ANY_KERNEL_ADDRESS: u32 = 4; +pub const B_RANDOMIZED_ANY_ADDRESS: u32 = 6; +pub const B_RANDOMIZED_BASE_ADDRESS: u32 = 7; + +pub const B_READ_AREA: u32 = 1 << 0; +pub const B_WRITE_AREA: u32 = 1 << 1; +pub const B_EXECUTE_AREA: u32 = 1 << 2; +pub const B_STACK_AREA: u32 = 1 << 3; +pub const B_CLONEABLE_AREA: u32 = 1 << 8; + +pub const B_CAN_INTERRUPT: u32 = 0x01; +pub const B_CHECK_PERMISSION: u32 = 0x04; +pub const B_KILL_CAN_INTERRUPT: u32 = 0x20; +pub const B_DO_NOT_RESCHEDULE: u32 = 0x02; +pub const B_RELEASE_ALL: u32 = 0x08; +pub const B_RELEASE_IF_WAITING_ONLY: u32 = 0x10; + +pub const B_CURRENT_TEAM: team_id = 0; +pub const B_SYSTEM_TEAM: team_id = 1; + +pub const B_TEAM_USAGE_SELF: i32 = 0; +pub const B_TEAM_USAGE_CHILDREN: i32 = -1; + +pub const B_IDLE_PRIORITY: i32 = 0; +pub const B_LOWEST_ACTIVE_PRIORITY: i32 = 1; +pub const B_LOW_PRIORITY: i32 = 5; +pub const B_NORMAL_PRIORITY: i32 = 10; +pub const B_DISPLAY_PRIORITY: i32 = 15; +pub const B_URGENT_DISPLAY_PRIORITY: i32 = 20; +pub const B_REAL_TIME_DISPLAY_PRIORITY: i32 = 100; +pub const B_URGENT_PRIORITY: i32 = 110; +pub const B_REAL_TIME_PRIORITY: i32 = 120; + +pub const B_SYSTEM_TIMEBASE: i32 = 0; +pub const B_FIRST_REAL_TIME_PRIORITY: i32 = B_REAL_TIME_DISPLAY_PRIORITY; + +pub const B_ONE_SHOT_ABSOLUTE_ALARM: u32 = 1; +pub const B_ONE_SHOT_RELATIVE_ALARM: u32 = 2; +pub const B_PERIODIC_ALARM: u32 = 3; + +pub const B_OBJECT_TYPE_FD: u16 = 0; +pub const B_OBJECT_TYPE_SEMAPHORE: u16 = 1; +pub const B_OBJECT_TYPE_PORT: u16 = 2; +pub const B_OBJECT_TYPE_THREAD: u16 = 3; + +pub const B_EVENT_READ: u16 = 0x0001; +pub const B_EVENT_WRITE: u16 = 0x0002; +pub const B_EVENT_ERROR: u16 = 0x0004; +pub const B_EVENT_PRIORITY_READ: u16 = 0x0008; +pub const B_EVENT_PRIORITY_WRITE: u16 = 0x0010; +pub const B_EVENT_HIGH_PRIORITY_READ: u16 = 0x0020; +pub const B_EVENT_HIGH_PRIORITY_WRITE: u16 = 0x0040; +pub const B_EVENT_DISCONNECTED: u16 = 0x0080; +pub const B_EVENT_ACQUIRE_SEMAPHORE: u16 = 0x0001; +pub const B_EVENT_INVALID: u16 = 0x1000; + +// kernel/fs_info.h +pub const B_FS_IS_READONLY: u32 = 0x00000001; +pub const B_FS_IS_REMOVABLE: u32 = 0x00000002; +pub const B_FS_IS_PERSISTENT: u32 = 0x00000004; +pub const B_FS_IS_SHARED: u32 = 0x00000008; +pub const B_FS_HAS_MIME: u32 = 0x00010000; +pub const B_FS_HAS_ATTR: u32 = 0x00020000; +pub const B_FS_HAS_QUERY: u32 = 0x00040000; +pub const B_FS_HAS_SELF_HEALING_LINKS: u32 = 0x00080000; +pub const B_FS_HAS_ALIASES: u32 = 0x00100000; +pub const B_FS_SUPPORTS_NODE_MONITORING: u32 = 0x00200000; +pub const B_FS_SUPPORTS_MONITOR_CHILDREN: u32 = 0x00400000; + +// kernel/fs_query.h +pub const B_LIVE_QUERY: u32 = 0x00000001; +pub const B_QUERY_NON_INDEXED: u32 = 0x00000002; + +// kernel/fs_volume.h +pub const B_MOUNT_READ_ONLY: u32 = 1; +pub const B_MOUNT_VIRTUAL_DEVICE: u32 = 2; +pub const B_FORCE_UNMOUNT: u32 = 1; + +// kernel/image.h +pub const B_FLUSH_DCACHE: u32 = 0x0001; +pub const B_FLUSH_ICACHE: u32 = 0x0004; +pub const B_INVALIDATE_DCACHE: u32 = 0x0002; +pub const B_INVALIDATE_ICACHE: u32 = 0x0008; + +pub const B_SYMBOL_TYPE_DATA: i32 = 0x1; +pub const B_SYMBOL_TYPE_TEXT: i32 = 0x2; +pub const B_SYMBOL_TYPE_ANY: i32 = 0x5; + +// storage/StorageDefs.h +pub const B_DEV_NAME_LENGTH: usize = 128; +pub const B_FILE_NAME_LENGTH: usize = crate::FILENAME_MAX as usize; +pub const B_PATH_NAME_LENGTH: usize = crate::PATH_MAX as usize; +pub const B_ATTR_NAME_LENGTH: usize = B_FILE_NAME_LENGTH - 1; +pub const B_MIME_TYPE_LENGTH: usize = B_ATTR_NAME_LENGTH - 15; +pub const B_MAX_SYMLINKS: usize = 16; + +// Haiku open modes in BFile are passed as u32 +pub const B_READ_ONLY: u32 = crate::O_RDONLY as u32; +pub const B_WRITE_ONLY: u32 = crate::O_WRONLY as u32; +pub const B_READ_WRITE: u32 = crate::O_RDWR as u32; + +pub const B_FAIL_IF_EXISTS: u32 = crate::O_EXCL as u32; +pub const B_CREATE_FILE: u32 = crate::O_CREAT as u32; +pub const B_ERASE_FILE: u32 = crate::O_TRUNC as u32; +pub const B_OPEN_AT_END: u32 = crate::O_APPEND as u32; + +pub const B_FILE_NODE: u32 = 0x01; +pub const B_SYMLINK_NODE: u32 = 0x02; +pub const B_DIRECTORY_NODE: u32 = 0x04; +pub const B_ANY_NODE: u32 = 0x07; + +// support/Errors.h +pub const B_GENERAL_ERROR_BASE: status_t = core::i32::MIN; +pub const B_OS_ERROR_BASE: status_t = B_GENERAL_ERROR_BASE + 0x1000; +pub const B_APP_ERROR_BASE: status_t = B_GENERAL_ERROR_BASE + 0x2000; +pub const B_INTERFACE_ERROR_BASE: status_t = B_GENERAL_ERROR_BASE + 0x3000; +pub const B_MEDIA_ERROR_BASE: status_t = B_GENERAL_ERROR_BASE + 0x4000; +pub const B_TRANSLATION_ERROR_BASE: status_t = B_GENERAL_ERROR_BASE + 0x4800; +pub const B_MIDI_ERROR_BASE: status_t = B_GENERAL_ERROR_BASE + 0x5000; +pub const B_STORAGE_ERROR_BASE: status_t = B_GENERAL_ERROR_BASE + 0x6000; +pub const B_POSIX_ERROR_BASE: status_t = B_GENERAL_ERROR_BASE + 0x7000; +pub const B_MAIL_ERROR_BASE: status_t = B_GENERAL_ERROR_BASE + 0x8000; +pub const B_PRINT_ERROR_BASE: status_t = B_GENERAL_ERROR_BASE + 0x9000; +pub const B_DEVICE_ERROR_BASE: status_t = B_GENERAL_ERROR_BASE + 0xa000; +pub const B_ERRORS_END: status_t = B_GENERAL_ERROR_BASE + 0xffff; + +// General errors +pub const B_NO_MEMORY: status_t = B_GENERAL_ERROR_BASE + 0; +pub const B_IO_ERROR: status_t = B_GENERAL_ERROR_BASE + 1; +pub const B_PERMISSION_DENIED: status_t = B_GENERAL_ERROR_BASE + 2; +pub const B_BAD_INDEX: status_t = B_GENERAL_ERROR_BASE + 3; +pub const B_BAD_TYPE: status_t = B_GENERAL_ERROR_BASE + 4; +pub const B_BAD_VALUE: status_t = B_GENERAL_ERROR_BASE + 5; +pub const B_MISMATCHED_VALUES: status_t = B_GENERAL_ERROR_BASE + 6; +pub const B_NAME_NOT_FOUND: status_t = B_GENERAL_ERROR_BASE + 7; +pub const B_NAME_IN_USE: status_t = B_GENERAL_ERROR_BASE + 8; +pub const B_TIMED_OUT: status_t = B_GENERAL_ERROR_BASE + 9; +pub const B_INTERRUPTED: status_t = B_GENERAL_ERROR_BASE + 10; +pub const B_WOULD_BLOCK: status_t = B_GENERAL_ERROR_BASE + 11; +pub const B_CANCELED: status_t = B_GENERAL_ERROR_BASE + 12; +pub const B_NO_INIT: status_t = B_GENERAL_ERROR_BASE + 13; +pub const B_NOT_INITIALIZED: status_t = B_GENERAL_ERROR_BASE + 13; +pub const B_BUSY: status_t = B_GENERAL_ERROR_BASE + 14; +pub const B_NOT_ALLOWED: status_t = B_GENERAL_ERROR_BASE + 15; +pub const B_BAD_DATA: status_t = B_GENERAL_ERROR_BASE + 16; +pub const B_DONT_DO_THAT: status_t = B_GENERAL_ERROR_BASE + 17; + +pub const B_ERROR: status_t = -1; +pub const B_OK: status_t = 0; +pub const B_NO_ERROR: status_t = 0; + +// Kernel kit errors +pub const B_BAD_SEM_ID: status_t = B_OS_ERROR_BASE + 0; +pub const B_NO_MORE_SEMS: status_t = B_OS_ERROR_BASE + 1; + +pub const B_BAD_THREAD_ID: status_t = B_OS_ERROR_BASE + 0x100; +pub const B_NO_MORE_THREADS: status_t = B_OS_ERROR_BASE + 0x101; +pub const B_BAD_THREAD_STATE: status_t = B_OS_ERROR_BASE + 0x102; +pub const B_BAD_TEAM_ID: status_t = B_OS_ERROR_BASE + 0x103; +pub const B_NO_MORE_TEAMS: status_t = B_OS_ERROR_BASE + 0x104; + +pub const B_BAD_PORT_ID: status_t = B_OS_ERROR_BASE + 0x200; +pub const B_NO_MORE_PORTS: status_t = B_OS_ERROR_BASE + 0x201; + +pub const B_BAD_IMAGE_ID: status_t = B_OS_ERROR_BASE + 0x300; +pub const B_BAD_ADDRESS: status_t = B_OS_ERROR_BASE + 0x301; +pub const B_NOT_AN_EXECUTABLE: status_t = B_OS_ERROR_BASE + 0x302; +pub const B_MISSING_LIBRARY: status_t = B_OS_ERROR_BASE + 0x303; +pub const B_MISSING_SYMBOL: status_t = B_OS_ERROR_BASE + 0x304; +pub const B_UNKNOWN_EXECUTABLE: status_t = B_OS_ERROR_BASE + 0x305; +pub const B_LEGACY_EXECUTABLE: status_t = B_OS_ERROR_BASE + 0x306; + +pub const B_DEBUGGER_ALREADY_INSTALLED: status_t = B_OS_ERROR_BASE + 0x400; + +// Application kit errors +pub const B_BAD_REPLY: status_t = B_APP_ERROR_BASE + 0; +pub const B_DUPLICATE_REPLY: status_t = B_APP_ERROR_BASE + 1; +pub const B_MESSAGE_TO_SELF: status_t = B_APP_ERROR_BASE + 2; +pub const B_BAD_HANDLER: status_t = B_APP_ERROR_BASE + 3; +pub const B_ALREADY_RUNNING: status_t = B_APP_ERROR_BASE + 4; +pub const B_LAUNCH_FAILED: status_t = B_APP_ERROR_BASE + 5; +pub const B_AMBIGUOUS_APP_LAUNCH: status_t = B_APP_ERROR_BASE + 6; +pub const B_UNKNOWN_MIME_TYPE: status_t = B_APP_ERROR_BASE + 7; +pub const B_BAD_SCRIPT_SYNTAX: status_t = B_APP_ERROR_BASE + 8; +pub const B_LAUNCH_FAILED_NO_RESOLVE_LINK: status_t = B_APP_ERROR_BASE + 9; +pub const B_LAUNCH_FAILED_EXECUTABLE: status_t = B_APP_ERROR_BASE + 10; +pub const B_LAUNCH_FAILED_APP_NOT_FOUND: status_t = B_APP_ERROR_BASE + 11; +pub const B_LAUNCH_FAILED_APP_IN_TRASH: status_t = B_APP_ERROR_BASE + 12; +pub const B_LAUNCH_FAILED_NO_PREFERRED_APP: status_t = B_APP_ERROR_BASE + 13; +pub const B_LAUNCH_FAILED_FILES_APP_NOT_FOUND: status_t = B_APP_ERROR_BASE + 14; +pub const B_BAD_MIME_SNIFFER_RULE: status_t = B_APP_ERROR_BASE + 15; +pub const B_NOT_A_MESSAGE: status_t = B_APP_ERROR_BASE + 16; +pub const B_SHUTDOWN_CANCELLED: status_t = B_APP_ERROR_BASE + 17; +pub const B_SHUTTING_DOWN: status_t = B_APP_ERROR_BASE + 18; + +// Storage kit errors +pub const B_FILE_ERROR: status_t = B_STORAGE_ERROR_BASE + 0; +pub const B_FILE_EXISTS: status_t = B_STORAGE_ERROR_BASE + 2; +pub const B_ENTRY_NOT_FOUND: status_t = B_STORAGE_ERROR_BASE + 3; +pub const B_NAME_TOO_LONG: status_t = B_STORAGE_ERROR_BASE + 4; +pub const B_NOT_A_DIRECTORY: status_t = B_STORAGE_ERROR_BASE + 5; +pub const B_DIRECTORY_NOT_EMPTY: status_t = B_STORAGE_ERROR_BASE + 6; +pub const B_DEVICE_FULL: status_t = B_STORAGE_ERROR_BASE + 7; +pub const B_READ_ONLY_DEVICE: status_t = B_STORAGE_ERROR_BASE + 8; +pub const B_IS_A_DIRECTORY: status_t = B_STORAGE_ERROR_BASE + 9; +pub const B_NO_MORE_FDS: status_t = B_STORAGE_ERROR_BASE + 10; +pub const B_CROSS_DEVICE_LINK: status_t = B_STORAGE_ERROR_BASE + 11; +pub const B_LINK_LIMIT: status_t = B_STORAGE_ERROR_BASE + 12; +pub const B_BUSTED_PIPE: status_t = B_STORAGE_ERROR_BASE + 13; +pub const B_UNSUPPORTED: status_t = B_STORAGE_ERROR_BASE + 14; +pub const B_PARTITION_TOO_SMALL: status_t = B_STORAGE_ERROR_BASE + 15; +pub const B_PARTIAL_READ: status_t = B_STORAGE_ERROR_BASE + 16; +pub const B_PARTIAL_WRITE: status_t = B_STORAGE_ERROR_BASE + 17; + +// Mapped posix errors +pub const B_BUFFER_OVERFLOW: status_t = crate::EOVERFLOW; +pub const B_TOO_MANY_ARGS: status_t = crate::E2BIG; +pub const B_FILE_TOO_LARGE: status_t = crate::EFBIG; +pub const B_RESULT_NOT_REPRESENTABLE: status_t = crate::ERANGE; +pub const B_DEVICE_NOT_FOUND: status_t = crate::ENODEV; +pub const B_NOT_SUPPORTED: status_t = crate::EOPNOTSUPP; + +// Media kit errors +pub const B_STREAM_NOT_FOUND: status_t = B_MEDIA_ERROR_BASE + 0; +pub const B_SERVER_NOT_FOUND: status_t = B_MEDIA_ERROR_BASE + 1; +pub const B_RESOURCE_NOT_FOUND: status_t = B_MEDIA_ERROR_BASE + 2; +pub const B_RESOURCE_UNAVAILABLE: status_t = B_MEDIA_ERROR_BASE + 3; +pub const B_BAD_SUBSCRIBER: status_t = B_MEDIA_ERROR_BASE + 4; +pub const B_SUBSCRIBER_NOT_ENTERED: status_t = B_MEDIA_ERROR_BASE + 5; +pub const B_BUFFER_NOT_AVAILABLE: status_t = B_MEDIA_ERROR_BASE + 6; +pub const B_LAST_BUFFER_ERROR: status_t = B_MEDIA_ERROR_BASE + 7; + +pub const B_MEDIA_SYSTEM_FAILURE: status_t = B_MEDIA_ERROR_BASE + 100; +pub const B_MEDIA_BAD_NODE: status_t = B_MEDIA_ERROR_BASE + 101; +pub const B_MEDIA_NODE_BUSY: status_t = B_MEDIA_ERROR_BASE + 102; +pub const B_MEDIA_BAD_FORMAT: status_t = B_MEDIA_ERROR_BASE + 103; +pub const B_MEDIA_BAD_BUFFER: status_t = B_MEDIA_ERROR_BASE + 104; +pub const B_MEDIA_TOO_MANY_NODES: status_t = B_MEDIA_ERROR_BASE + 105; +pub const B_MEDIA_TOO_MANY_BUFFERS: status_t = B_MEDIA_ERROR_BASE + 106; +pub const B_MEDIA_NODE_ALREADY_EXISTS: status_t = B_MEDIA_ERROR_BASE + 107; +pub const B_MEDIA_BUFFER_ALREADY_EXISTS: status_t = B_MEDIA_ERROR_BASE + 108; +pub const B_MEDIA_CANNOT_SEEK: status_t = B_MEDIA_ERROR_BASE + 109; +pub const B_MEDIA_CANNOT_CHANGE_RUN_MODE: status_t = B_MEDIA_ERROR_BASE + 110; +pub const B_MEDIA_APP_ALREADY_REGISTERED: status_t = B_MEDIA_ERROR_BASE + 111; +pub const B_MEDIA_APP_NOT_REGISTERED: status_t = B_MEDIA_ERROR_BASE + 112; +pub const B_MEDIA_CANNOT_RECLAIM_BUFFERS: status_t = B_MEDIA_ERROR_BASE + 113; +pub const B_MEDIA_BUFFERS_NOT_RECLAIMED: status_t = B_MEDIA_ERROR_BASE + 114; +pub const B_MEDIA_TIME_SOURCE_STOPPED: status_t = B_MEDIA_ERROR_BASE + 115; +pub const B_MEDIA_TIME_SOURCE_BUSY: status_t = B_MEDIA_ERROR_BASE + 116; +pub const B_MEDIA_BAD_SOURCE: status_t = B_MEDIA_ERROR_BASE + 117; +pub const B_MEDIA_BAD_DESTINATION: status_t = B_MEDIA_ERROR_BASE + 118; +pub const B_MEDIA_ALREADY_CONNECTED: status_t = B_MEDIA_ERROR_BASE + 119; +pub const B_MEDIA_NOT_CONNECTED: status_t = B_MEDIA_ERROR_BASE + 120; +pub const B_MEDIA_BAD_CLIP_FORMAT: status_t = B_MEDIA_ERROR_BASE + 121; +pub const B_MEDIA_ADDON_FAILED: status_t = B_MEDIA_ERROR_BASE + 122; +pub const B_MEDIA_ADDON_DISABLED: status_t = B_MEDIA_ERROR_BASE + 123; +pub const B_MEDIA_CHANGE_IN_PROGRESS: status_t = B_MEDIA_ERROR_BASE + 124; +pub const B_MEDIA_STALE_CHANGE_COUNT: status_t = B_MEDIA_ERROR_BASE + 125; +pub const B_MEDIA_ADDON_RESTRICTED: status_t = B_MEDIA_ERROR_BASE + 126; +pub const B_MEDIA_NO_HANDLER: status_t = B_MEDIA_ERROR_BASE + 127; +pub const B_MEDIA_DUPLICATE_FORMAT: status_t = B_MEDIA_ERROR_BASE + 128; +pub const B_MEDIA_REALTIME_DISABLED: status_t = B_MEDIA_ERROR_BASE + 129; +pub const B_MEDIA_REALTIME_UNAVAILABLE: status_t = B_MEDIA_ERROR_BASE + 130; + +// Mail kit errors +pub const B_MAIL_NO_DAEMON: status_t = B_MAIL_ERROR_BASE + 0; +pub const B_MAIL_UNKNOWN_USER: status_t = B_MAIL_ERROR_BASE + 1; +pub const B_MAIL_WRONG_PASSWORD: status_t = B_MAIL_ERROR_BASE + 2; +pub const B_MAIL_UNKNOWN_HOST: status_t = B_MAIL_ERROR_BASE + 3; +pub const B_MAIL_ACCESS_ERROR: status_t = B_MAIL_ERROR_BASE + 4; +pub const B_MAIL_UNKNOWN_FIELD: status_t = B_MAIL_ERROR_BASE + 5; +pub const B_MAIL_NO_RECIPIENT: status_t = B_MAIL_ERROR_BASE + 6; +pub const B_MAIL_INVALID_MAIL: status_t = B_MAIL_ERROR_BASE + 7; + +// Print kit errors +pub const B_NO_PRINT_SERVER: status_t = B_PRINT_ERROR_BASE + 0; + +// Device kit errors +pub const B_DEV_INVALID_IOCTL: status_t = B_DEVICE_ERROR_BASE + 0; +pub const B_DEV_NO_MEMORY: status_t = B_DEVICE_ERROR_BASE + 1; +pub const B_DEV_BAD_DRIVE_NUM: status_t = B_DEVICE_ERROR_BASE + 2; +pub const B_DEV_NO_MEDIA: status_t = B_DEVICE_ERROR_BASE + 3; +pub const B_DEV_UNREADABLE: status_t = B_DEVICE_ERROR_BASE + 4; +pub const B_DEV_FORMAT_ERROR: status_t = B_DEVICE_ERROR_BASE + 5; +pub const B_DEV_TIMEOUT: status_t = B_DEVICE_ERROR_BASE + 6; +pub const B_DEV_RECALIBRATE_ERROR: status_t = B_DEVICE_ERROR_BASE + 7; +pub const B_DEV_SEEK_ERROR: status_t = B_DEVICE_ERROR_BASE + 8; +pub const B_DEV_ID_ERROR: status_t = B_DEVICE_ERROR_BASE + 9; +pub const B_DEV_READ_ERROR: status_t = B_DEVICE_ERROR_BASE + 10; +pub const B_DEV_WRITE_ERROR: status_t = B_DEVICE_ERROR_BASE + 11; +pub const B_DEV_NOT_READY: status_t = B_DEVICE_ERROR_BASE + 12; +pub const B_DEV_MEDIA_CHANGED: status_t = B_DEVICE_ERROR_BASE + 13; +pub const B_DEV_MEDIA_CHANGE_REQUESTED: status_t = B_DEVICE_ERROR_BASE + 14; +pub const B_DEV_RESOURCE_CONFLICT: status_t = B_DEVICE_ERROR_BASE + 15; +pub const B_DEV_CONFIGURATION_ERROR: status_t = B_DEVICE_ERROR_BASE + 16; +pub const B_DEV_DISABLED_BY_USER: status_t = B_DEVICE_ERROR_BASE + 17; +pub const B_DEV_DOOR_OPEN: status_t = B_DEVICE_ERROR_BASE + 18; + +pub const B_DEV_INVALID_PIPE: status_t = B_DEVICE_ERROR_BASE + 19; +pub const B_DEV_CRC_ERROR: status_t = B_DEVICE_ERROR_BASE + 20; +pub const B_DEV_STALLED: status_t = B_DEVICE_ERROR_BASE + 21; +pub const B_DEV_BAD_PID: status_t = B_DEVICE_ERROR_BASE + 22; +pub const B_DEV_UNEXPECTED_PID: status_t = B_DEVICE_ERROR_BASE + 23; +pub const B_DEV_DATA_OVERRUN: status_t = B_DEVICE_ERROR_BASE + 24; +pub const B_DEV_DATA_UNDERRUN: status_t = B_DEVICE_ERROR_BASE + 25; +pub const B_DEV_FIFO_OVERRUN: status_t = B_DEVICE_ERROR_BASE + 26; +pub const B_DEV_FIFO_UNDERRUN: status_t = B_DEVICE_ERROR_BASE + 27; +pub const B_DEV_PENDING: status_t = B_DEVICE_ERROR_BASE + 28; +pub const B_DEV_MULTIPLE_ERRORS: status_t = B_DEVICE_ERROR_BASE + 29; +pub const B_DEV_TOO_LATE: status_t = B_DEVICE_ERROR_BASE + 30; + +// translation kit errors +pub const B_TRANSLATION_BASE_ERROR: status_t = B_TRANSLATION_ERROR_BASE + 0; +pub const B_NO_TRANSLATOR: status_t = B_TRANSLATION_ERROR_BASE + 1; +pub const B_ILLEGAL_DATA: status_t = B_TRANSLATION_ERROR_BASE + 2; + +// support/TypeConstants.h +pub const B_AFFINE_TRANSFORM_TYPE: u32 = haiku_constant!('A', 'M', 'T', 'X'); +pub const B_ALIGNMENT_TYPE: u32 = haiku_constant!('A', 'L', 'G', 'N'); +pub const B_ANY_TYPE: u32 = haiku_constant!('A', 'N', 'Y', 'T'); +pub const B_ATOM_TYPE: u32 = haiku_constant!('A', 'T', 'O', 'M'); +pub const B_ATOMREF_TYPE: u32 = haiku_constant!('A', 'T', 'M', 'R'); +pub const B_BOOL_TYPE: u32 = haiku_constant!('B', 'O', 'O', 'L'); +pub const B_CHAR_TYPE: u32 = haiku_constant!('C', 'H', 'A', 'R'); +pub const B_COLOR_8_BIT_TYPE: u32 = haiku_constant!('C', 'L', 'R', 'B'); +pub const B_DOUBLE_TYPE: u32 = haiku_constant!('D', 'B', 'L', 'E'); +pub const B_FLOAT_TYPE: u32 = haiku_constant!('F', 'L', 'O', 'T'); +pub const B_GRAYSCALE_8_BIT_TYPE: u32 = haiku_constant!('G', 'R', 'Y', 'B'); +pub const B_INT16_TYPE: u32 = haiku_constant!('S', 'H', 'R', 'T'); +pub const B_INT32_TYPE: u32 = haiku_constant!('L', 'O', 'N', 'G'); +pub const B_INT64_TYPE: u32 = haiku_constant!('L', 'L', 'N', 'G'); +pub const B_INT8_TYPE: u32 = haiku_constant!('B', 'Y', 'T', 'E'); +pub const B_LARGE_ICON_TYPE: u32 = haiku_constant!('I', 'C', 'O', 'N'); +pub const B_MEDIA_PARAMETER_GROUP_TYPE: u32 = haiku_constant!('B', 'M', 'C', 'G'); +pub const B_MEDIA_PARAMETER_TYPE: u32 = haiku_constant!('B', 'M', 'C', 'T'); +pub const B_MEDIA_PARAMETER_WEB_TYPE: u32 = haiku_constant!('B', 'M', 'C', 'W'); +pub const B_MESSAGE_TYPE: u32 = haiku_constant!('M', 'S', 'G', 'G'); +pub const B_MESSENGER_TYPE: u32 = haiku_constant!('M', 'S', 'N', 'G'); +pub const B_MIME_TYPE: u32 = haiku_constant!('M', 'I', 'M', 'E'); +pub const B_MINI_ICON_TYPE: u32 = haiku_constant!('M', 'I', 'C', 'N'); +pub const B_MONOCHROME_1_BIT_TYPE: u32 = haiku_constant!('M', 'N', 'O', 'B'); +pub const B_OBJECT_TYPE: u32 = haiku_constant!('O', 'P', 'T', 'R'); +pub const B_OFF_T_TYPE: u32 = haiku_constant!('O', 'F', 'F', 'T'); +pub const B_PATTERN_TYPE: u32 = haiku_constant!('P', 'A', 'T', 'N'); +pub const B_POINTER_TYPE: u32 = haiku_constant!('P', 'N', 'T', 'R'); +pub const B_POINT_TYPE: u32 = haiku_constant!('B', 'P', 'N', 'T'); +pub const B_PROPERTY_INFO_TYPE: u32 = haiku_constant!('S', 'C', 'T', 'D'); +pub const B_RAW_TYPE: u32 = haiku_constant!('R', 'A', 'W', 'T'); +pub const B_RECT_TYPE: u32 = haiku_constant!('R', 'E', 'C', 'T'); +pub const B_REF_TYPE: u32 = haiku_constant!('R', 'R', 'E', 'F'); +pub const B_RGB_32_BIT_TYPE: u32 = haiku_constant!('R', 'G', 'B', 'B'); +pub const B_RGB_COLOR_TYPE: u32 = haiku_constant!('R', 'G', 'B', 'C'); +pub const B_SIZE_TYPE: u32 = haiku_constant!('S', 'I', 'Z', 'E'); +pub const B_SIZE_T_TYPE: u32 = haiku_constant!('S', 'I', 'Z', 'T'); +pub const B_SSIZE_T_TYPE: u32 = haiku_constant!('S', 'S', 'Z', 'T'); +pub const B_STRING_TYPE: u32 = haiku_constant!('C', 'S', 'T', 'R'); +pub const B_STRING_LIST_TYPE: u32 = haiku_constant!('S', 'T', 'R', 'L'); +pub const B_TIME_TYPE: u32 = haiku_constant!('T', 'I', 'M', 'E'); +pub const B_UINT16_TYPE: u32 = haiku_constant!('U', 'S', 'H', 'T'); +pub const B_UINT32_TYPE: u32 = haiku_constant!('U', 'L', 'N', 'G'); +pub const B_UINT64_TYPE: u32 = haiku_constant!('U', 'L', 'L', 'G'); +pub const B_UINT8_TYPE: u32 = haiku_constant!('U', 'B', 'Y', 'T'); +pub const B_VECTOR_ICON_TYPE: u32 = haiku_constant!('V', 'I', 'C', 'N'); +pub const B_XATTR_TYPE: u32 = haiku_constant!('X', 'A', 'T', 'R'); +pub const B_NETWORK_ADDRESS_TYPE: u32 = haiku_constant!('N', 'W', 'A', 'D'); +pub const B_MIME_STRING_TYPE: u32 = haiku_constant!('M', 'I', 'M', 'S'); +pub const B_ASCII_TYPE: u32 = haiku_constant!('T', 'E', 'X', 'T'); +pub const B_APP_IMAGE_SYMBOL: *const c_void = core::ptr::null(); + +extern "C" { + // kernel/OS.h + pub fn create_area( + name: *const c_char, + startAddress: *mut *mut c_void, + addressSpec: u32, + size: usize, + lock: u32, + protection: u32, + ) -> area_id; + pub fn clone_area( + name: *const c_char, + destAddress: *mut *mut c_void, + addressSpec: u32, + protection: u32, + source: area_id, + ) -> area_id; + pub fn find_area(name: *const c_char) -> area_id; + pub fn area_for(address: *mut c_void) -> area_id; + pub fn delete_area(id: area_id) -> status_t; + pub fn resize_area(id: area_id, newSize: usize) -> status_t; + pub fn set_area_protection(id: area_id, newProtection: u32) -> status_t; + pub fn _get_area_info(id: area_id, areaInfo: *mut area_info, size: usize) -> status_t; + pub fn _get_next_area_info( + team: team_id, + cookie: *mut isize, + areaInfo: *mut area_info, + size: usize, + ) -> status_t; + + pub fn create_port(capacity: i32, name: *const c_char) -> port_id; + pub fn find_port(name: *const c_char) -> port_id; + pub fn read_port( + port: port_id, + code: *mut i32, + buffer: *mut c_void, + bufferSize: size_t, + ) -> ssize_t; + pub fn read_port_etc( + port: port_id, + code: *mut i32, + buffer: *mut c_void, + bufferSize: size_t, + flags: u32, + timeout: bigtime_t, + ) -> ssize_t; + pub fn write_port( + port: port_id, + code: i32, + buffer: *const c_void, + bufferSize: size_t, + ) -> status_t; + pub fn write_port_etc( + port: port_id, + code: i32, + buffer: *const c_void, + bufferSize: size_t, + flags: u32, + timeout: bigtime_t, + ) -> status_t; + pub fn close_port(port: port_id) -> status_t; + pub fn delete_port(port: port_id) -> status_t; + pub fn port_buffer_size(port: port_id) -> ssize_t; + pub fn port_buffer_size_etc(port: port_id, flags: u32, timeout: bigtime_t) -> ssize_t; + pub fn port_count(port: port_id) -> ssize_t; + pub fn set_port_owner(port: port_id, team: team_id) -> status_t; + + pub fn _get_port_info(port: port_id, buf: *mut port_info, portInfoSize: size_t) -> status_t; + pub fn _get_next_port_info( + port: port_id, + cookie: *mut i32, + portInfo: *mut port_info, + portInfoSize: size_t, + ) -> status_t; + pub fn _get_port_message_info_etc( + port: port_id, + info: *mut port_message_info, + infoSize: size_t, + flags: u32, + timeout: bigtime_t, + ) -> status_t; + + pub fn create_sem(count: i32, name: *const c_char) -> sem_id; + pub fn delete_sem(id: sem_id) -> status_t; + pub fn acquire_sem(id: sem_id) -> status_t; + pub fn acquire_sem_etc(id: sem_id, count: i32, flags: u32, timeout: bigtime_t) -> status_t; + pub fn release_sem(id: sem_id) -> status_t; + pub fn release_sem_etc(id: sem_id, count: i32, flags: u32) -> status_t; + pub fn switch_sem(semToBeReleased: sem_id, id: sem_id) -> status_t; + pub fn switch_sem_etc( + semToBeReleased: sem_id, + id: sem_id, + count: i32, + flags: u32, + timeout: bigtime_t, + ) -> status_t; + pub fn get_sem_count(id: sem_id, threadCount: *mut i32) -> status_t; + pub fn set_sem_owner(id: sem_id, team: team_id) -> status_t; + pub fn _get_sem_info(id: sem_id, info: *mut sem_info, infoSize: size_t) -> status_t; + pub fn _get_next_sem_info( + team: team_id, + cookie: *mut i32, + info: *mut sem_info, + infoSize: size_t, + ) -> status_t; + + pub fn kill_team(team: team_id) -> status_t; + pub fn _get_team_info(team: team_id, info: *mut team_info, size: size_t) -> status_t; + pub fn _get_next_team_info(cookie: *mut i32, info: *mut team_info, size: size_t) -> status_t; + + pub fn spawn_thread( + func: thread_func, + name: *const c_char, + priority: i32, + data: *mut c_void, + ) -> thread_id; + pub fn kill_thread(thread: thread_id) -> status_t; + pub fn resume_thread(thread: thread_id) -> status_t; + pub fn suspend_thread(thread: thread_id) -> status_t; + + pub fn rename_thread(thread: thread_id, newName: *const c_char) -> status_t; + pub fn set_thread_priority(thread: thread_id, newPriority: i32) -> status_t; + pub fn suggest_thread_priority( + what: u32, + period: i32, + jitter: crate::bigtime_t, + length: crate::bigtime_t, + ) -> i32; + pub fn estimate_max_scheduling_latency(th: crate::thread_id) -> crate::bigtime_t; + pub fn exit_thread(status: status_t); + pub fn wait_for_thread(thread: thread_id, returnValue: *mut status_t) -> status_t; + pub fn on_exit_thread(callback: extern "C" fn(*mut c_void), data: *mut c_void) -> status_t; + + pub fn find_thread(name: *const c_char) -> thread_id; + + pub fn get_scheduler_mode() -> i32; + pub fn set_scheduler_mode(mode: i32) -> status_t; + + pub fn send_data( + thread: thread_id, + code: i32, + buffer: *const c_void, + bufferSize: size_t, + ) -> status_t; + pub fn receive_data(sender: *mut thread_id, buffer: *mut c_void, bufferSize: size_t) -> i32; + pub fn has_data(thread: thread_id) -> bool; + + pub fn snooze(amount: bigtime_t) -> status_t; + pub fn snooze_etc(amount: bigtime_t, timeBase: c_int, flags: u32) -> status_t; + pub fn snooze_until(time: bigtime_t, timeBase: c_int) -> status_t; + + pub fn _get_thread_info(id: thread_id, info: *mut thread_info, size: size_t) -> status_t; + pub fn _get_next_thread_info( + team: team_id, + cookie: *mut i32, + info: *mut thread_info, + size: size_t, + ) -> status_t; + + pub fn get_pthread_thread_id(thread: crate::pthread_t) -> thread_id; + + pub fn _get_team_usage_info( + team: team_id, + who: i32, + info: *mut team_usage_info, + size: size_t, + ) -> status_t; + + pub fn real_time_clock() -> c_ulong; + pub fn set_real_time_clock(secsSinceJan1st1970: c_ulong); + pub fn real_time_clock_usecs() -> bigtime_t; + pub fn system_time() -> bigtime_t; + pub fn system_time_nsecs() -> nanotime_t; + // set_timezone() is deprecated and a no-op + + pub fn set_alarm(when: bigtime_t, flags: u32) -> bigtime_t; + pub fn debugger(message: *const c_char); + pub fn disable_debugger(state: c_int) -> c_int; + + pub fn get_system_info(info: *mut system_info) -> status_t; + pub fn _get_cpu_info_etc( + firstCPU: u32, + cpuCount: u32, + info: *mut cpu_info, + size: size_t, + ) -> status_t; + pub fn get_cpu_topology_info( + topologyInfos: *mut cpu_topology_node_info, + topologyInfoCount: *mut u32, + ) -> status_t; + pub fn is_computer_on() -> i32; + pub fn is_computer_on_fire() -> c_double; + pub fn send_signal(threadID: thread_id, signal: c_uint) -> c_int; + pub fn set_signal_stack(base: *mut c_void, size: size_t); + + pub fn wait_for_objects(infos: *mut object_wait_info, numInfos: c_int) -> ssize_t; + pub fn wait_for_objects_etc( + infos: *mut object_wait_info, + numInfos: c_int, + flags: u32, + timeout: bigtime_t, + ) -> ssize_t; + + // kernel/fs_attr.h + pub fn fs_read_attr( + fd: c_int, + attribute: *const c_char, + type_: u32, + pos: off_t, + buffer: *mut c_void, + readBytes: size_t, + ) -> ssize_t; + pub fn fs_write_attr( + fd: c_int, + attribute: *const c_char, + type_: u32, + pos: off_t, + buffer: *const c_void, + writeBytes: size_t, + ) -> ssize_t; + pub fn fs_remove_attr(fd: c_int, attribute: *const c_char) -> c_int; + pub fn fs_stat_attr(fd: c_int, attribute: *const c_char, attrInfo: *mut attr_info) -> c_int; + + pub fn fs_open_attr( + path: *const c_char, + attribute: *const c_char, + type_: u32, + openMode: c_int, + ) -> c_int; + pub fn fs_fopen_attr(fd: c_int, attribute: *const c_char, type_: u32, openMode: c_int) + -> c_int; + pub fn fs_close_attr(fd: c_int) -> c_int; + + pub fn fs_open_attr_dir(path: *const c_char) -> *mut crate::DIR; + pub fn fs_lopen_attr_dir(path: *const c_char) -> *mut crate::DIR; + pub fn fs_fopen_attr_dir(fd: c_int) -> *mut crate::DIR; + pub fn fs_close_attr_dir(dir: *mut crate::DIR) -> c_int; + pub fn fs_read_attr_dir(dir: *mut crate::DIR) -> *mut crate::dirent; + pub fn fs_rewind_attr_dir(dir: *mut crate::DIR); + + // kernel/fs_image.h + pub fn fs_create_index( + device: crate::dev_t, + name: *const c_char, + type_: u32, + flags: u32, + ) -> c_int; + pub fn fs_remove_index(device: crate::dev_t, name: *const c_char) -> c_int; + pub fn fs_stat_index( + device: crate::dev_t, + name: *const c_char, + indexInfo: *mut index_info, + ) -> c_int; + + pub fn fs_open_index_dir(device: crate::dev_t) -> *mut crate::DIR; + pub fn fs_close_index_dir(indexDirectory: *mut crate::DIR) -> c_int; + pub fn fs_read_index_dir(indexDirectory: *mut crate::DIR) -> *mut crate::dirent; + pub fn fs_rewind_index_dir(indexDirectory: *mut crate::DIR); + + // kernel/fs_info.h + pub fn dev_for_path(path: *const c_char) -> crate::dev_t; + pub fn next_dev(pos: *mut i32) -> crate::dev_t; + pub fn fs_stat_dev(dev: crate::dev_t, info: *mut fs_info) -> c_int; + + // kernel/fs_query.h + pub fn fs_open_query(device: crate::dev_t, query: *const c_char, flags: u32) + -> *mut crate::DIR; + pub fn fs_open_live_query( + device: crate::dev_t, + query: *const c_char, + flags: u32, + port: port_id, + token: i32, + ) -> *mut crate::DIR; + pub fn fs_close_query(d: *mut crate::DIR) -> c_int; + pub fn fs_read_query(d: *mut crate::DIR) -> *mut crate::dirent; + pub fn get_path_for_dirent(dent: *mut crate::dirent, buf: *mut c_char, len: size_t) + -> status_t; + + // kernel/fs_volume.h + pub fn fs_mount_volume( + where_: *const c_char, + device: *const c_char, + filesystem: *const c_char, + flags: u32, + parameters: *const c_char, + ) -> crate::dev_t; + pub fn fs_unmount_volume(path: *const c_char, flags: u32) -> status_t; + + // kernel/image.h + pub fn load_image( + argc: i32, + argv: *mut *const c_char, + environ: *mut *const c_char, + ) -> thread_id; + pub fn load_add_on(path: *const c_char) -> image_id; + pub fn unload_add_on(image: image_id) -> status_t; + pub fn get_image_symbol( + image: image_id, + name: *const c_char, + symbolType: i32, + symbolLocation: *mut *mut c_void, + ) -> status_t; + pub fn get_nth_image_symbol( + image: image_id, + n: i32, + nameBuffer: *mut c_char, + nameLength: *mut i32, + symbolType: *mut i32, + symbolLocation: *mut *mut c_void, + ) -> status_t; + pub fn clear_caches(address: *mut c_void, length: size_t, flags: u32); + pub fn _get_image_info(image: image_id, info: *mut image_info, size: size_t) -> status_t; + pub fn _get_next_image_info( + team: team_id, + cookie: *mut i32, + info: *mut image_info, + size: size_t, + ) -> status_t; + pub fn find_path( + codePointer: *const c_void, + baseDirectory: path_base_directory, + subPath: *const c_char, + pathBuffer: *mut c_char, + bufferSize: usize, + ) -> status_t; + pub fn find_path_etc( + codePointer: *const c_void, + dependency: *const c_char, + architecture: *const c_char, + baseDirectory: path_base_directory, + subPath: *const c_char, + flags: u32, + pathBuffer: *mut c_char, + bufferSize: size_t, + ) -> status_t; + pub fn find_path_for_path( + path: *const c_char, + baseDirectory: path_base_directory, + subPath: *const c_char, + pathBuffer: *mut c_char, + bufferSize: size_t, + ) -> status_t; + pub fn find_path_for_path_etc( + path: *const c_char, + dependency: *const c_char, + architecture: *const c_char, + baseDirectory: path_base_directory, + subPath: *const c_char, + flags: u32, + pathBuffer: *mut c_char, + bufferSize: size_t, + ) -> status_t; + pub fn find_paths( + baseDirectory: path_base_directory, + subPath: *const c_char, + _paths: *mut *mut *mut c_char, + pathCount: *mut size_t, + ) -> status_t; + pub fn find_paths_etc( + architecture: *const c_char, + baseDirectory: path_base_directory, + subPath: *const c_char, + flags: u32, + _paths: *mut *mut *mut c_char, + pathCount: *mut size_t, + ) -> status_t; + pub fn find_directory( + which: directory_which, + volume: crate::dev_t, + createIt: bool, + pathString: *mut c_char, + length: i32, + ) -> status_t; + + pub fn get_cpuid(info: *mut cpuid_info, eaxRegister: u32, cpuNum: u32) -> status_t; +} + +// The following functions are defined as macros in C/C++ +#[inline] +pub unsafe fn get_cpu_info(firstCPU: u32, cpuCount: u32, info: *mut cpu_info) -> status_t { + _get_cpu_info_etc(firstCPU, cpuCount, info, size_of::() as size_t) +} + +#[inline] +pub unsafe fn get_area_info(id: area_id, info: *mut area_info) -> status_t { + _get_area_info(id, info, size_of::() as usize) +} + +#[inline] +pub unsafe fn get_next_area_info( + team: team_id, + cookie: *mut isize, + info: *mut area_info, +) -> status_t { + _get_next_area_info(team, cookie, info, size_of::() as usize) +} + +#[inline] +pub unsafe fn get_port_info(port: port_id, buf: *mut port_info) -> status_t { + _get_port_info(port, buf, size_of::() as size_t) +} + +#[inline] +pub unsafe fn get_next_port_info( + port: port_id, + cookie: *mut i32, + portInfo: *mut port_info, +) -> status_t { + _get_next_port_info(port, cookie, portInfo, size_of::() as size_t) +} + +#[inline] +pub unsafe fn get_port_message_info_etc( + port: port_id, + info: *mut port_message_info, + flags: u32, + timeout: bigtime_t, +) -> status_t { + _get_port_message_info_etc( + port, + info, + size_of::() as size_t, + flags, + timeout, + ) +} + +#[inline] +pub unsafe fn get_sem_info(id: sem_id, info: *mut sem_info) -> status_t { + _get_sem_info(id, info, size_of::() as size_t) +} + +#[inline] +pub unsafe fn get_next_sem_info(team: team_id, cookie: *mut i32, info: *mut sem_info) -> status_t { + _get_next_sem_info(team, cookie, info, size_of::() as size_t) +} + +#[inline] +pub unsafe fn get_team_info(team: team_id, info: *mut team_info) -> status_t { + _get_team_info(team, info, size_of::() as size_t) +} + +#[inline] +pub unsafe fn get_next_team_info(cookie: *mut i32, info: *mut team_info) -> status_t { + _get_next_team_info(cookie, info, size_of::() as size_t) +} + +#[inline] +pub unsafe fn get_team_usage_info(team: team_id, who: i32, info: *mut team_usage_info) -> status_t { + _get_team_usage_info(team, who, info, size_of::() as size_t) +} + +#[inline] +pub unsafe fn get_thread_info(id: thread_id, info: *mut thread_info) -> status_t { + _get_thread_info(id, info, size_of::() as size_t) +} + +#[inline] +pub unsafe fn get_next_thread_info( + team: team_id, + cookie: *mut i32, + info: *mut thread_info, +) -> status_t { + _get_next_thread_info(team, cookie, info, size_of::() as size_t) +} + +// kernel/image.h +#[inline] +pub unsafe fn get_image_info(image: image_id, info: *mut image_info) -> status_t { + _get_image_info(image, info, size_of::() as size_t) +} + +#[inline] +pub unsafe fn get_next_image_info( + team: team_id, + cookie: *mut i32, + info: *mut image_info, +) -> status_t { + _get_next_image_info(team, cookie, info, size_of::() as size_t) +} diff --git a/http/vendor/libc/src/unix/haiku/x86_64.rs b/http/vendor/libc/src/unix/haiku/x86_64.rs new file mode 100644 index 0000000..4a6921d --- /dev/null +++ b/http/vendor/libc/src/unix/haiku/x86_64.rs @@ -0,0 +1,58 @@ +use crate::prelude::*; + +s! { + pub struct fpu_state { + pub control: c_ushort, + pub status: c_ushort, + pub tag: c_ushort, + pub opcode: c_ushort, + pub rip: c_ulong, + pub rdp: c_ulong, + pub mxcsr: c_uint, + pub mscsr_mask: c_uint, + pub _fpreg: [[c_uchar; 8]; 16], + pub _xmm: [[c_uchar; 16]; 16], + _reserved_416_511: Padding<[c_uchar; 96]>, + } + + pub struct xstate_hdr { + pub bv: c_ulong, + pub xcomp_bv: c_ulong, + _reserved: Padding<[c_uchar; 48]>, + } + + pub struct savefpu { + pub fp_fxsave: fpu_state, + pub fp_xstate: xstate_hdr, + pub _fp_ymm: [[c_uchar; 16]; 16], + } + + pub struct mcontext_t { + pub rax: c_ulong, + pub rbx: c_ulong, + pub rcx: c_ulong, + pub rdx: c_ulong, + pub rdi: c_ulong, + pub rsi: c_ulong, + pub rbp: c_ulong, + pub r8: c_ulong, + pub r9: c_ulong, + pub r10: c_ulong, + pub r11: c_ulong, + pub r12: c_ulong, + pub r13: c_ulong, + pub r14: c_ulong, + pub r15: c_ulong, + pub rsp: c_ulong, + pub rip: c_ulong, + pub rflags: c_ulong, + pub fpu: savefpu, + } + + pub struct ucontext_t { + pub uc_link: *mut ucontext_t, + pub uc_sigmask: crate::sigset_t, + pub uc_stack: crate::stack_t, + pub uc_mcontext: mcontext_t, + } +} diff --git a/http/vendor/libc/src/unix/hurd/b32.rs b/http/vendor/libc/src/unix/hurd/b32.rs new file mode 100644 index 0000000..e706789 --- /dev/null +++ b/http/vendor/libc/src/unix/hurd/b32.rs @@ -0,0 +1,92 @@ +use crate::prelude::*; + +pub type __int64_t = c_longlong; +pub type __uint64_t = c_ulonglong; + +pub type int_fast16_t = c_int; +pub type int_fast32_t = c_int; +pub type int_fast64_t = c_longlong; +pub type uint_fast16_t = c_uint; +pub type uint_fast32_t = c_uint; +pub type uint_fast64_t = c_ulonglong; + +pub type __quad_t = c_longlong; +pub type __u_quad_t = c_ulonglong; +pub type __intmax_t = c_longlong; +pub type __uintmax_t = c_ulonglong; + +pub type __squad_type = crate::__int64_t; +pub type __uquad_type = crate::__uint64_t; +pub type __sword_type = c_int; +pub type __uword_type = c_uint; +pub type __slong32_type = c_long; +pub type __ulong32_type = c_ulong; +pub type __s64_type = crate::__int64_t; +pub type __u64_type = crate::__uint64_t; + +pub type __ipc_pid_t = c_ushort; + +pub type Elf32_Half = u16; +pub type Elf32_Word = u32; +pub type Elf32_Off = u32; +pub type Elf32_Addr = u32; +pub type Elf32_Section = u16; + +pub type Elf_Addr = crate::Elf32_Addr; +pub type Elf_Half = crate::Elf32_Half; +pub type Elf_Ehdr = crate::Elf32_Ehdr; +pub type Elf_Phdr = crate::Elf32_Phdr; +pub type Elf_Shdr = crate::Elf32_Shdr; +pub type Elf_Sym = crate::Elf32_Sym; + +s! { + pub struct Elf32_Ehdr { + pub e_ident: [c_uchar; 16], + pub e_type: Elf32_Half, + pub e_machine: Elf32_Half, + pub e_version: Elf32_Word, + pub e_entry: Elf32_Addr, + pub e_phoff: Elf32_Off, + pub e_shoff: Elf32_Off, + pub e_flags: Elf32_Word, + pub e_ehsize: Elf32_Half, + pub e_phentsize: Elf32_Half, + pub e_phnum: Elf32_Half, + pub e_shentsize: Elf32_Half, + pub e_shnum: Elf32_Half, + pub e_shstrndx: Elf32_Half, + } + + pub struct Elf32_Shdr { + pub sh_name: Elf32_Word, + pub sh_type: Elf32_Word, + pub sh_flags: Elf32_Word, + pub sh_addr: Elf32_Addr, + pub sh_offset: Elf32_Off, + pub sh_size: Elf32_Word, + pub sh_link: Elf32_Word, + pub sh_info: Elf32_Word, + pub sh_addralign: Elf32_Word, + pub sh_entsize: Elf32_Word, + } + + pub struct Elf32_Sym { + pub st_name: Elf32_Word, + pub st_value: Elf32_Addr, + pub st_size: Elf32_Word, + pub st_info: c_uchar, + pub st_other: c_uchar, + pub st_shndx: Elf32_Section, + } + + pub struct Elf32_Phdr { + pub p_type: crate::Elf32_Word, + pub p_offset: crate::Elf32_Off, + pub p_vaddr: crate::Elf32_Addr, + pub p_paddr: crate::Elf32_Addr, + pub p_filesz: crate::Elf32_Word, + pub p_memsz: crate::Elf32_Word, + pub p_flags: crate::Elf32_Word, + pub p_align: crate::Elf32_Word, + } +} diff --git a/http/vendor/libc/src/unix/hurd/b64.rs b/http/vendor/libc/src/unix/hurd/b64.rs new file mode 100644 index 0000000..a44428c --- /dev/null +++ b/http/vendor/libc/src/unix/hurd/b64.rs @@ -0,0 +1,94 @@ +use crate::prelude::*; + +pub type __int64_t = c_long; +pub type __uint64_t = c_ulong; + +pub type int_fast16_t = c_long; +pub type int_fast32_t = c_long; +pub type int_fast64_t = c_long; +pub type uint_fast16_t = c_ulong; +pub type uint_fast32_t = c_ulong; +pub type uint_fast64_t = c_ulong; + +pub type __quad_t = c_long; +pub type __u_quad_t = c_ulong; +pub type __intmax_t = c_long; +pub type __uintmax_t = c_ulong; + +pub type __squad_type = c_long; +pub type __uquad_type = c_ulong; +pub type __sword_type = c_long; +pub type __uword_type = c_ulong; +pub type __slong32_type = c_int; +pub type __ulong32_type = c_uint; +pub type __s64_type = c_long; +pub type __u64_type = c_ulong; + +pub type __ipc_pid_t = c_int; + +pub type Elf64_Half = u16; +pub type Elf64_Word = u32; +pub type Elf64_Off = u64; +pub type Elf64_Addr = u64; +pub type Elf64_Xword = u64; +pub type Elf64_Sxword = i64; +pub type Elf64_Section = u16; + +pub type Elf_Addr = crate::Elf64_Addr; +pub type Elf_Half = crate::Elf64_Half; +pub type Elf_Ehdr = crate::Elf64_Ehdr; +pub type Elf_Phdr = crate::Elf64_Phdr; +pub type Elf_Shdr = crate::Elf64_Shdr; +pub type Elf_Sym = crate::Elf64_Sym; + +s! { + pub struct Elf64_Ehdr { + pub e_ident: [c_uchar; 16], + pub e_type: Elf64_Half, + pub e_machine: Elf64_Half, + pub e_version: Elf64_Word, + pub e_entry: Elf64_Addr, + pub e_phoff: Elf64_Off, + pub e_shoff: Elf64_Off, + pub e_flags: Elf64_Word, + pub e_ehsize: Elf64_Half, + pub e_phentsize: Elf64_Half, + pub e_phnum: Elf64_Half, + pub e_shentsize: Elf64_Half, + pub e_shnum: Elf64_Half, + pub e_shstrndx: Elf64_Half, + } + + pub struct Elf64_Shdr { + pub sh_name: Elf64_Word, + pub sh_type: Elf64_Word, + pub sh_flags: Elf64_Xword, + pub sh_addr: Elf64_Addr, + pub sh_offset: Elf64_Off, + pub sh_size: Elf64_Xword, + pub sh_link: Elf64_Word, + pub sh_info: Elf64_Word, + pub sh_addralign: Elf64_Xword, + pub sh_entsize: Elf64_Xword, + } + + pub struct Elf64_Sym { + pub st_name: Elf64_Word, + pub st_info: c_uchar, + pub st_other: c_uchar, + pub st_shndx: Elf64_Section, + pub st_value: Elf64_Addr, + pub st_size: Elf64_Xword, + } + + pub struct Elf64_Phdr { + pub p_type: crate::Elf64_Word, + pub p_flags: crate::Elf64_Word, + pub p_offset: crate::Elf64_Off, + pub p_vaddr: crate::Elf64_Addr, + pub p_paddr: crate::Elf64_Addr, + pub p_filesz: crate::Elf64_Xword, + pub p_memsz: crate::Elf64_Xword, + pub p_align: crate::Elf64_Xword, + } +} diff --git a/http/vendor/libc/src/unix/hurd/mod.rs b/http/vendor/libc/src/unix/hurd/mod.rs new file mode 100644 index 0000000..74b77d9 --- /dev/null +++ b/http/vendor/libc/src/unix/hurd/mod.rs @@ -0,0 +1,4564 @@ +#![allow(dead_code)] + +use crate::c_schar; +use crate::prelude::*; + +// types +pub type __s16_type = c_short; +pub type __u16_type = c_ushort; +pub type __s32_type = c_int; +pub type __u32_type = c_uint; +pub type __slongword_type = c_long; +pub type __ulongword_type = c_ulong; + +pub type __u_char = c_uchar; +pub type __u_short = c_ushort; +pub type __u_int = c_uint; +pub type __u_long = c_ulong; +pub type __int8_t = c_schar; +pub type __uint8_t = c_uchar; +pub type __int16_t = c_short; +pub type __uint16_t = c_ushort; +pub type __int32_t = c_int; +pub type __uint32_t = c_uint; +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 __dev_t = __uword_type; +pub type __uid_t = __u32_type; +pub type __gid_t = __u32_type; +pub type __ino_t = __ulongword_type; +pub type __ino64_t = __uquad_type; +pub type __mode_t = __u32_type; +pub type __nlink_t = __uword_type; +pub type __off_t = __slongword_type; +pub type __off64_t = __squad_type; +pub type __pid_t = __s32_type; +pub type __rlim_t = __ulongword_type; +pub type __rlim64_t = __uquad_type; +pub type __blkcnt_t = __slongword_type; +pub type __blkcnt64_t = __squad_type; +pub type __fsblkcnt_t = __ulongword_type; +pub type __fsblkcnt64_t = __uquad_type; +pub type __fsfilcnt_t = __ulongword_type; +pub type __fsfilcnt64_t = __uquad_type; +pub type __fsword_t = __sword_type; +pub type __id_t = __u32_type; +pub type __clock_t = __slongword_type; +pub type __time_t = __slongword_type; +pub type __useconds_t = __u32_type; +pub type __suseconds_t = __slongword_type; +pub type __suseconds64_t = __squad_type; +pub type __daddr_t = __s32_type; +pub type __key_t = __s32_type; +pub type __clockid_t = __s32_type; +pub type __timer_t = __uword_type; +pub type __blksize_t = __slongword_type; +pub type __fsid_t = __uquad_type; +pub type __ssize_t = __sword_type; +pub type __syscall_slong_t = __slongword_type; +pub type __syscall_ulong_t = __ulongword_type; +pub type __cpu_mask = __ulongword_type; + +pub type __loff_t = __off64_t; +pub type __caddr_t = *mut c_char; +pub type __intptr_t = __sword_type; +pub type __ptrdiff_t = __sword_type; +pub type __socklen_t = __u32_type; +pub type __sig_atomic_t = c_int; +pub type __time64_t = __int64_t; +pub type wchar_t = c_int; +pub type wint_t = c_uint; +pub type gid_t = __gid_t; +pub type uid_t = __uid_t; +pub type off_t = __off_t; +pub type off64_t = __off64_t; +pub type useconds_t = __useconds_t; +pub type pid_t = __pid_t; +pub type socklen_t = __socklen_t; + +pub type in_addr_t = u32; + +pub type _Float32 = f32; +pub type _Float64 = f64; +pub type _Float32x = f64; +pub type _Float64x = f64; + +pub type __locale_t = *mut __locale_struct; +pub type locale_t = __locale_t; + +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 ino64_t = __ino64_t; +pub type dev_t = __dev_t; +pub type mode_t = __mode_t; +pub type nlink_t = __nlink_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 suseconds_t = __suseconds_t; +pub type ulong = c_ulong; +pub type ushort = c_ushort; +pub type uint = 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 = c_int; +pub type __sigset_t = c_ulong; +pub type sigset_t = __sigset_t; + +pub type __fd_mask = c_long; +pub type fd_mask = __fd_mask; +pub type blksize_t = __blksize_t; +pub type blkcnt_t = __blkcnt_t; +pub type fsblkcnt_t = __fsblkcnt_t; +pub type fsfilcnt_t = __fsfilcnt_t; +pub type blkcnt64_t = __blkcnt64_t; +pub type fsblkcnt64_t = __fsblkcnt64_t; +pub type fsfilcnt64_t = __fsfilcnt64_t; + +pub type __pthread_spinlock_t = c_int; +pub type __tss_t = c_int; +pub type __thrd_t = c_long; +pub type __pthread_t = c_long; +pub type pthread_t = __pthread_t; +pub type __pthread_process_shared = c_uint; +pub type __pthread_inheritsched = c_uint; +pub type __pthread_contentionscope = c_uint; +pub type __pthread_detachstate = c_uint; +pub type pthread_attr_t = __pthread_attr; +pub type __pthread_mutex_protocol = c_uint; +pub type __pthread_mutex_type = c_uint; +pub type __pthread_mutex_robustness = c_uint; +pub type pthread_mutexattr_t = __pthread_mutexattr; +pub type pthread_mutex_t = __pthread_mutex; +pub type pthread_condattr_t = __pthread_condattr; +pub type pthread_cond_t = __pthread_cond; +pub type pthread_spinlock_t = __pthread_spinlock_t; +pub type pthread_rwlockattr_t = __pthread_rwlockattr; +pub type pthread_rwlock_t = __pthread_rwlock; +pub type pthread_barrierattr_t = __pthread_barrierattr; +pub type pthread_barrier_t = __pthread_barrier; +pub type __pthread_key = c_int; +pub type pthread_key_t = __pthread_key; +pub type pthread_once_t = __pthread_once; + +pub type __rlimit_resource = c_uint; +pub type __rlimit_resource_t = __rlimit_resource; +pub type rlim_t = __rlim_t; +pub type rlim64_t = __rlim64_t; + +pub type __rusage_who = c_int; + +pub type __priority_which = c_uint; + +pub type sa_family_t = c_uchar; + +pub type in_port_t = u16; + +pub type __sigval_t = crate::sigval; + +pub type sigevent_t = sigevent; + +pub type nfds_t = c_ulong; + +pub type tcflag_t = c_uint; +pub type cc_t = c_uchar; +pub type speed_t = c_int; + +pub type sigval_t = crate::sigval; + +pub type greg_t = c_int; +pub type gregset_t = [greg_t; 19usize]; + +pub type __ioctl_dir = c_uint; + +pub type __ioctl_datum = c_uint; + +pub type __error_t_codes = 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 = c_schar; +pub type uint_fast8_t = c_uchar; +pub type intmax_t = __intmax_t; +pub type uintmax_t = __uintmax_t; + +pub type tcp_seq = u32; + +pub type tcp_ca_state = c_uint; + +pub type idtype_t = c_uint; + +pub type mqd_t = c_int; + +pub type Lmid_t = c_long; + +pub type regoff_t = c_int; + +pub type nl_item = c_int; + +pub type iconv_t = *mut c_void; + +extern_ty! { + pub enum fpos64_t {} // FIXME(hurd): fill this out with a struct + pub enum timezone {} +} + +// structs +s! { + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct ip_mreqn { + pub imr_multiaddr: in_addr, + pub imr_address: in_addr, + pub imr_ifindex: c_int, + } + + pub struct ip_mreq_source { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + pub imr_sourceaddr: in_addr, + } + + pub struct sockaddr { + pub sa_len: c_uchar, + pub sa_family: sa_family_t, + pub sa_data: [c_char; 14usize], + } + + pub struct in_addr { + pub s_addr: in_addr_t, + } + + pub struct sockaddr_in { + pub sin_len: c_uchar, + pub sin_family: sa_family_t, + pub sin_port: in_port_t, + pub sin_addr: crate::in_addr, + pub sin_zero: [c_uchar; 8usize], + } + + pub struct sockaddr_in6 { + pub sin6_len: c_uchar, + pub sin6_family: sa_family_t, + pub sin6_port: in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: crate::in6_addr, + pub sin6_scope_id: u32, + } + + pub struct sockaddr_un { + pub sun_len: c_uchar, + pub sun_family: sa_family_t, + pub sun_path: [c_char; 108usize], + } + + pub struct sockaddr_storage { + pub ss_len: c_uchar, + pub ss_family: sa_family_t, + __ss_padding: Padding<[c_char; 122usize]>, + __ss_align: __uint32_t, + } + + pub struct sockaddr_at { + pub _address: u8, + } + + pub struct sockaddr_ax25 { + pub _address: u8, + } + + pub struct sockaddr_x25 { + pub _address: u8, + } + + pub struct sockaddr_dl { + pub _address: u8, + } + pub struct sockaddr_eon { + pub _address: u8, + } + pub struct sockaddr_inarp { + pub _address: u8, + } + + pub struct sockaddr_ipx { + pub _address: u8, + } + pub struct sockaddr_iso { + pub _address: u8, + } + + pub struct sockaddr_ns { + pub _address: u8, + } + + pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: crate::socklen_t, + pub ai_addr: *mut sockaddr, + pub ai_canonname: *mut c_char, + pub ai_next: *mut addrinfo, + } + + pub struct msghdr { + pub msg_name: *mut c_void, + pub msg_namelen: crate::socklen_t, + pub msg_iov: *mut crate::iovec, + pub msg_iovlen: c_int, + pub msg_control: *mut c_void, + pub msg_controllen: crate::socklen_t, + pub msg_flags: c_int, + } + + pub struct cmsghdr { + pub cmsg_len: crate::socklen_t, + pub cmsg_level: c_int, + pub cmsg_type: c_int, + } + + pub struct dirent { + pub d_ino: __ino_t, + pub d_reclen: c_ushort, + pub d_type: c_uchar, + pub d_namlen: c_uchar, + pub d_name: [c_char; 1usize], + } + + pub struct dirent64 { + pub d_ino: __ino64_t, + pub d_reclen: c_ushort, + pub d_type: c_uchar, + pub d_namlen: c_uchar, + pub d_name: [c_char; 1usize], + } + + pub struct fd_set { + pub fds_bits: [__fd_mask; 8usize], + } + + pub struct termios { + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_cc: [crate::cc_t; 20usize], + pub __ispeed: crate::speed_t, + pub __ospeed: crate::speed_t, + } + + pub struct mallinfo { + pub arena: c_int, + pub ordblks: c_int, + pub smblks: c_int, + pub hblks: c_int, + pub hblkhd: c_int, + pub usmblks: c_int, + pub fsmblks: c_int, + pub uordblks: c_int, + pub fordblks: c_int, + pub keepcost: c_int, + } + + pub struct mallinfo2 { + pub arena: size_t, + pub ordblks: size_t, + pub smblks: size_t, + pub hblks: size_t, + pub hblkhd: size_t, + pub usmblks: size_t, + pub fsmblks: size_t, + pub uordblks: size_t, + pub fordblks: size_t, + pub keepcost: size_t, + } + + pub struct sigaction { + pub sa_sigaction: crate::sighandler_t, + pub sa_mask: __sigset_t, + pub sa_flags: c_int, + } + + pub struct sigevent { + pub sigev_value: crate::sigval, + pub sigev_signo: c_int, + pub sigev_notify: c_int, + __unused1: Padding<*mut c_void>, //actually a function pointer + pub sigev_notify_attributes: *mut pthread_attr_t, + } + + pub struct siginfo_t { + pub si_signo: c_int, + pub si_errno: c_int, + pub si_code: c_int, + pub si_pid: __pid_t, + pub si_uid: __uid_t, + pub si_addr: *mut c_void, + pub si_status: c_int, + pub si_band: c_long, + pub si_value: crate::sigval, + } + + #[derive(Default)] + pub struct timespec { + pub tv_sec: __time_t, + pub tv_nsec: __syscall_slong_t, + } + + pub struct __timeval { + pub tv_sec: i32, + pub tv_usec: i32, + } + + pub struct __locale_data { + pub _address: u8, + } + + pub struct stat { + pub st_fstype: c_int, + pub st_dev: __fsid_t, /* Actually st_fsid */ + pub st_ino: __ino_t, + pub st_gen: c_uint, + pub st_rdev: __dev_t, + pub st_mode: __mode_t, + pub st_nlink: __nlink_t, + pub st_uid: __uid_t, + pub st_gid: __gid_t, + pub st_size: __off_t, + pub st_atim: crate::timespec, + pub st_mtim: crate::timespec, + pub st_ctim: crate::timespec, + pub st_blksize: __blksize_t, + pub st_blocks: __blkcnt_t, + pub st_author: __uid_t, + pub st_flags: c_uint, + pub st_spare: [c_int; 11usize], + } + + pub struct stat64 { + pub st_fstype: c_int, + pub st_dev: __fsid_t, /* Actually st_fsid */ + pub st_ino: __ino64_t, + pub st_gen: c_uint, + pub st_rdev: __dev_t, + pub st_mode: __mode_t, + pub st_nlink: __nlink_t, + pub st_uid: __uid_t, + pub st_gid: __gid_t, + pub st_size: __off64_t, + pub st_atim: crate::timespec, + pub st_mtim: crate::timespec, + pub st_ctim: crate::timespec, + pub st_blksize: __blksize_t, + pub st_blocks: __blkcnt64_t, + pub st_author: __uid_t, + pub st_flags: c_uint, + pub st_spare: [c_int; 8usize], + } + + pub struct statx { + pub stx_mask: u32, + pub stx_blksize: u32, + pub stx_attributes: u64, + pub stx_nlink: u32, + pub stx_uid: u32, + pub stx_gid: u32, + pub stx_mode: u16, + __statx_pad1: Padding<[u16; 1]>, + pub stx_ino: u64, + pub stx_size: u64, + pub stx_blocks: u64, + pub stx_attributes_mask: u64, + pub stx_atime: crate::statx_timestamp, + pub stx_btime: crate::statx_timestamp, + pub stx_ctime: crate::statx_timestamp, + pub stx_mtime: crate::statx_timestamp, + pub stx_rdev_major: u32, + pub stx_rdev_minor: u32, + pub stx_dev_major: u32, + pub stx_dev_minor: u32, + __statx_pad2: Padding<[u64; 14]>, + } + + pub struct statx_timestamp { + pub tv_sec: i64, + pub tv_nsec: u32, + pub __statx_timestamp_pad1: [i32; 1], + } + + pub struct statfs { + pub f_type: c_uint, + pub f_bsize: c_ulong, + pub f_blocks: __fsblkcnt_t, + pub f_bfree: __fsblkcnt_t, + pub f_bavail: __fsblkcnt_t, + pub f_files: __fsblkcnt_t, + pub f_ffree: __fsblkcnt_t, + pub f_fsid: __fsid_t, + pub f_namelen: c_ulong, + pub f_favail: __fsfilcnt_t, + pub f_frsize: c_ulong, + pub f_flag: c_ulong, + pub f_spare: [c_uint; 3usize], + } + + pub struct statfs64 { + pub f_type: c_uint, + pub f_bsize: c_ulong, + pub f_blocks: __fsblkcnt64_t, + pub f_bfree: __fsblkcnt64_t, + pub f_bavail: __fsblkcnt64_t, + pub f_files: __fsblkcnt64_t, + pub f_ffree: __fsblkcnt64_t, + pub f_fsid: __fsid_t, + pub f_namelen: c_ulong, + pub f_favail: __fsfilcnt64_t, + pub f_frsize: c_ulong, + pub f_flag: c_ulong, + pub f_spare: [c_uint; 3usize], + } + + pub struct statvfs { + pub __f_type: c_uint, + pub f_bsize: c_ulong, + pub f_blocks: __fsblkcnt_t, + pub f_bfree: __fsblkcnt_t, + pub f_bavail: __fsblkcnt_t, + pub f_files: __fsfilcnt_t, + pub f_ffree: __fsfilcnt_t, + pub f_fsid: __fsid_t, + pub f_namemax: c_ulong, + pub f_favail: __fsfilcnt_t, + pub f_frsize: c_ulong, + pub f_flag: c_ulong, + pub f_spare: [c_uint; 3usize], + } + + pub struct statvfs64 { + pub __f_type: c_uint, + pub f_bsize: c_ulong, + pub f_blocks: __fsblkcnt64_t, + pub f_bfree: __fsblkcnt64_t, + pub f_bavail: __fsblkcnt64_t, + pub f_files: __fsfilcnt64_t, + pub f_ffree: __fsfilcnt64_t, + pub f_fsid: __fsid_t, + pub f_namemax: c_ulong, + pub f_favail: __fsfilcnt64_t, + pub f_frsize: c_ulong, + pub f_flag: c_ulong, + pub f_spare: [c_uint; 3usize], + } + + pub struct aiocb { + pub aio_fildes: c_int, + pub aio_lio_opcode: c_int, + pub aio_reqprio: c_int, + pub aio_buf: *mut c_void, + pub aio_nbytes: size_t, + pub aio_sigevent: crate::sigevent, + __next_prio: *mut aiocb, + __abs_prio: c_int, + __policy: c_int, + __error_code: c_int, + __return_value: ssize_t, + pub aio_offset: off_t, + #[cfg(all(not(target_arch = "x86_64"), target_pointer_width = "32"))] + __unused1: Padding<[c_char; 4]>, + __glibc_reserved: Padding<[c_char; 32]>, + } + + pub struct mq_attr { + pub mq_flags: c_long, + pub mq_maxmsg: c_long, + pub mq_msgsize: c_long, + pub mq_curmsgs: c_long, + } + + pub struct __exit_status { + pub e_termination: c_short, + pub e_exit: c_short, + } + + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + pub struct sem_t { + __size: [c_char; 20usize], + } + + pub struct __pthread { + pub _address: u8, + } + + pub struct __pthread_mutexattr { + pub __prioceiling: c_int, + pub __protocol: __pthread_mutex_protocol, + pub __pshared: __pthread_process_shared, + pub __mutex_type: __pthread_mutex_type, + } + pub struct __pthread_mutex { + pub __lock: c_uint, + pub __owner_id: c_uint, + pub __cnt: c_uint, + pub __shpid: c_int, + pub __type: c_int, + pub __flags: c_int, + __reserved1: Padding, + __reserved2: Padding, + } + + pub struct __pthread_condattr { + pub __pshared: __pthread_process_shared, + pub __clock: __clockid_t, + } + + pub struct __pthread_rwlockattr { + pub __pshared: __pthread_process_shared, + } + + pub struct __pthread_barrierattr { + pub __pshared: __pthread_process_shared, + } + + pub struct __pthread_once { + pub __run: c_int, + pub __lock: __pthread_spinlock_t, + } + + pub struct __pthread_cond { + pub __lock: __pthread_spinlock_t, + pub __queue: *mut __pthread, + pub __attr: *mut __pthread_condattr, + pub __wrefs: c_uint, + pub __data: *mut c_void, + } + + pub struct __pthread_attr { + pub __schedparam: sched_param, + pub __stackaddr: *mut c_void, + pub __stacksize: size_t, + pub __guardsize: size_t, + pub __detachstate: __pthread_detachstate, + pub __inheritsched: __pthread_inheritsched, + pub __contentionscope: __pthread_contentionscope, + pub __schedpolicy: c_int, + } + + pub struct __pthread_rwlock { + pub __held: __pthread_spinlock_t, + pub __lock: __pthread_spinlock_t, + pub __readers: c_int, + pub __readerqueue: *mut __pthread, + pub __writerqueue: *mut __pthread, + pub __attr: *mut __pthread_rwlockattr, + pub __data: *mut c_void, + } + + pub struct __pthread_barrier { + pub __lock: __pthread_spinlock_t, + pub __queue: *mut __pthread, + pub __pending: c_uint, + pub __count: c_uint, + pub __attr: *mut __pthread_barrierattr, + pub __data: *mut c_void, + } + + pub struct seminfo { + pub semmap: c_int, + pub semmni: c_int, + pub semmns: c_int, + pub semmnu: c_int, + pub semmsl: c_int, + pub semopm: c_int, + pub semume: c_int, + pub semusz: c_int, + pub semvmx: c_int, + pub semaem: c_int, + } + + pub struct _IO_FILE { + _unused: Padding<[u8; 0]>, + } + + pub struct sched_param { + pub sched_priority: c_int, + } + + pub struct iovec { + pub iov_base: *mut c_void, + pub iov_len: size_t, + } + + pub struct passwd { + pub pw_name: *mut c_char, + pub pw_passwd: *mut c_char, + pub pw_uid: __uid_t, + pub pw_gid: __gid_t, + pub pw_gecos: *mut c_char, + pub pw_dir: *mut c_char, + pub pw_shell: *mut c_char, + } + + pub struct spwd { + pub sp_namp: *mut c_char, + pub sp_pwdp: *mut c_char, + pub sp_lstchg: c_long, + pub sp_min: c_long, + pub sp_max: c_long, + pub sp_warn: c_long, + pub sp_inact: c_long, + pub sp_expire: c_long, + pub sp_flag: c_ulong, + } + + pub struct itimerspec { + pub it_interval: crate::timespec, + pub it_value: crate::timespec, + } + + pub struct tm { + pub tm_sec: c_int, + pub tm_min: c_int, + pub tm_hour: c_int, + pub tm_mday: c_int, + pub tm_mon: c_int, + pub tm_year: c_int, + pub tm_wday: c_int, + pub tm_yday: c_int, + pub tm_isdst: c_int, + pub tm_gmtoff: c_long, + pub tm_zone: *const c_char, + } + + pub struct lconv { + pub decimal_point: *mut c_char, + pub thousands_sep: *mut c_char, + pub grouping: *mut c_char, + pub int_curr_symbol: *mut c_char, + pub currency_symbol: *mut c_char, + pub mon_decimal_point: *mut c_char, + pub mon_thousands_sep: *mut c_char, + pub mon_grouping: *mut c_char, + pub positive_sign: *mut c_char, + pub negative_sign: *mut c_char, + pub int_frac_digits: c_char, + pub frac_digits: c_char, + pub p_cs_precedes: c_char, + pub p_sep_by_space: c_char, + pub n_cs_precedes: c_char, + pub n_sep_by_space: c_char, + pub p_sign_posn: c_char, + pub n_sign_posn: c_char, + pub int_p_cs_precedes: c_char, + pub int_p_sep_by_space: c_char, + pub int_n_cs_precedes: c_char, + pub int_n_sep_by_space: c_char, + pub int_p_sign_posn: c_char, + pub int_n_sign_posn: c_char, + } + + pub struct Dl_info { + pub dli_fname: *const c_char, + pub dli_fbase: *mut c_void, + pub dli_sname: *const c_char, + pub dli_saddr: *mut c_void, + } + + pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut c_char, + pub ifa_flags: c_uint, + pub ifa_addr: *mut crate::sockaddr, + pub ifa_netmask: *mut crate::sockaddr, + pub ifa_ifu: *mut crate::sockaddr, // FIXME(union) This should be a union + pub ifa_data: *mut c_void, + } + + pub struct arpreq { + pub arp_pa: crate::sockaddr, + pub arp_ha: crate::sockaddr, + pub arp_flags: c_int, + pub arp_netmask: crate::sockaddr, + pub arp_dev: [c_char; 16], + } + + pub struct arpreq_old { + pub arp_pa: crate::sockaddr, + pub arp_ha: crate::sockaddr, + pub arp_flags: c_int, + pub arp_netmask: crate::sockaddr, + } + + pub struct arphdr { + pub ar_hrd: u16, + pub ar_pro: u16, + pub ar_hln: u8, + pub ar_pln: u8, + pub ar_op: u16, + } + + pub struct arpd_request { + pub req: c_ushort, + pub ip: u32, + pub dev: c_ulong, + pub stamp: c_ulong, + pub updated: c_ulong, + pub ha: [c_uchar; crate::MAX_ADDR_LEN], + } + + pub struct mmsghdr { + pub msg_hdr: crate::msghdr, + pub msg_len: c_uint, + } + + pub struct ifreq { + /// interface name, e.g. "en0" + pub ifr_name: [c_char; crate::IFNAMSIZ], + pub ifr_ifru: crate::sockaddr, + } + + pub struct __locale_struct { + pub __locales: [*mut __locale_data; 13usize], + pub __ctype_b: *const c_ushort, + pub __ctype_tolower: *const c_int, + pub __ctype_toupper: *const c_int, + pub __names: [*const c_char; 13usize], + } + + pub struct utsname { + pub sysname: [c_char; _UTSNAME_LENGTH], + pub nodename: [c_char; _UTSNAME_LENGTH], + pub release: [c_char; _UTSNAME_LENGTH], + pub version: [c_char; _UTSNAME_LENGTH], + pub machine: [c_char; _UTSNAME_LENGTH], + pub domainname: [c_char; _UTSNAME_LENGTH], + } + + pub struct rlimit64 { + pub rlim_cur: rlim64_t, + pub rlim_max: rlim64_t, + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_size: size_t, + pub ss_flags: c_int, + } + + pub struct dl_phdr_info { + pub dlpi_addr: Elf_Addr, + pub dlpi_name: *const c_char, + pub dlpi_phdr: *const Elf_Phdr, + pub dlpi_phnum: Elf_Half, + pub dlpi_adds: c_ulonglong, + pub dlpi_subs: c_ulonglong, + pub dlpi_tls_modid: size_t, + pub dlpi_tls_data: *mut c_void, + } + + pub struct flock { + #[cfg(target_pointer_width = "32")] + pub l_type: c_int, + #[cfg(target_pointer_width = "32")] + pub l_whence: c_int, + #[cfg(target_pointer_width = "64")] + pub l_type: c_short, + #[cfg(target_pointer_width = "64")] + pub l_whence: c_short, + pub l_start: __off_t, + pub l_len: __off_t, + pub l_pid: __pid_t, + } + + pub struct flock64 { + #[cfg(target_pointer_width = "32")] + pub l_type: c_int, + #[cfg(target_pointer_width = "32")] + pub l_whence: c_int, + #[cfg(target_pointer_width = "64")] + pub l_type: c_short, + #[cfg(target_pointer_width = "64")] + pub l_whence: c_short, + pub l_start: __off_t, + pub l_len: __off64_t, + pub l_pid: __pid_t, + } + + pub struct glob_t { + pub gl_pathc: size_t, + pub gl_pathv: *mut *mut c_char, + pub gl_offs: size_t, + pub gl_flags: c_int, + + __unused1: Padding<*mut c_void>, + __unused2: Padding<*mut c_void>, + __unused3: Padding<*mut c_void>, + __unused4: Padding<*mut c_void>, + __unused5: Padding<*mut c_void>, + } + + pub struct glob64_t { + pub gl_pathc: size_t, + pub gl_pathv: *mut *mut c_char, + pub gl_offs: size_t, + pub gl_flags: c_int, + + __unused1: Padding<*mut c_void>, + __unused2: Padding<*mut c_void>, + __unused3: Padding<*mut c_void>, + __unused4: Padding<*mut c_void>, + __unused5: Padding<*mut c_void>, + } + + pub struct regex_t { + __buffer: *mut c_void, + __allocated: size_t, + __used: size_t, + __syntax: c_ulong, + __fastmap: *mut c_char, + __translate: *mut c_char, + __re_nsub: size_t, + __bitfield: u8, + } + + pub struct cpu_set_t { + #[cfg(all(target_pointer_width = "32", not(target_arch = "x86_64")))] + bits: [u32; 32], + #[cfg(not(all(target_pointer_width = "32", not(target_arch = "x86_64"))))] + bits: [u64; 16], + } + + pub struct if_nameindex { + pub if_index: c_uint, + pub if_name: *mut c_char, + } + + // System V IPC + pub struct msginfo { + pub msgpool: c_int, + pub msgmap: c_int, + pub msgmax: c_int, + pub msgmnb: c_int, + pub msgmni: c_int, + pub msgssz: c_int, + pub msgtql: c_int, + pub msgseg: c_ushort, + } + + pub struct sembuf { + pub sem_num: c_ushort, + pub sem_op: c_short, + pub sem_flg: c_short, + } + + pub struct mntent { + pub mnt_fsname: *mut c_char, + pub mnt_dir: *mut c_char, + pub mnt_type: *mut c_char, + pub mnt_opts: *mut c_char, + pub mnt_freq: c_int, + pub mnt_passno: c_int, + } + + pub struct posix_spawn_file_actions_t { + __allocated: c_int, + __used: c_int, + __actions: *mut c_int, + __pad: Padding<[c_int; 16]>, + } + + pub struct posix_spawnattr_t { + __flags: c_short, + __pgrp: crate::pid_t, + __sd: crate::sigset_t, + __ss: crate::sigset_t, + __sp: crate::sched_param, + __policy: c_int, + __pad: Padding<[c_int; 16]>, + } + + pub struct regmatch_t { + pub rm_so: regoff_t, + pub rm_eo: regoff_t, + } + + pub struct option { + pub name: *const c_char, + pub has_arg: c_int, + pub flag: *mut c_int, + pub val: c_int, + } + + pub struct utmpx { + pub ut_type: c_short, + pub ut_pid: crate::pid_t, + pub ut_line: [c_char; __UT_LINESIZE], + pub ut_id: [c_char; 4], + + pub ut_user: [c_char; __UT_NAMESIZE], + pub ut_host: [c_char; __UT_HOSTSIZE], + pub ut_exit: __exit_status, + + #[cfg(any(all(target_pointer_width = "32", not(target_arch = "x86_64"))))] + pub ut_session: c_long, + #[cfg(any(all(target_pointer_width = "32", not(target_arch = "x86_64"))))] + pub ut_tv: crate::timeval, + + #[cfg(not(any(all(target_pointer_width = "32", not(target_arch = "x86_64")))))] + pub ut_session: i32, + #[cfg(not(any(all(target_pointer_width = "32", not(target_arch = "x86_64")))))] + pub ut_tv: __timeval, + + pub ut_addr_v6: [i32; 4], + __glibc_reserved: Padding<[c_char; 20]>, + } +} + +impl siginfo_t { + pub unsafe fn si_addr(&self) -> *mut c_void { + self.si_addr + } + + pub unsafe fn si_value(&self) -> crate::sigval { + self.si_value + } + + pub unsafe fn si_pid(&self) -> crate::pid_t { + self.si_pid + } + + pub unsafe fn si_uid(&self) -> crate::uid_t { + self.si_uid + } + + pub unsafe fn si_status(&self) -> c_int { + self.si_status + } +} + +// const + +// aio.h +pub const AIO_CANCELED: c_int = 0; +pub const AIO_NOTCANCELED: c_int = 1; +pub const AIO_ALLDONE: c_int = 2; +pub const LIO_READ: c_int = 0; +pub const LIO_WRITE: c_int = 1; +pub const LIO_NOP: c_int = 2; +pub const LIO_WAIT: c_int = 0; +pub const LIO_NOWAIT: c_int = 1; + +// glob.h +pub const GLOB_ERR: c_int = 1 << 0; +pub const GLOB_MARK: c_int = 1 << 1; +pub const GLOB_NOSORT: c_int = 1 << 2; +pub const GLOB_DOOFFS: c_int = 1 << 3; +pub const GLOB_NOCHECK: c_int = 1 << 4; +pub const GLOB_APPEND: c_int = 1 << 5; +pub const GLOB_NOESCAPE: c_int = 1 << 6; + +pub const GLOB_NOSPACE: c_int = 1; +pub const GLOB_ABORTED: c_int = 2; +pub const GLOB_NOMATCH: c_int = 3; + +pub const GLOB_PERIOD: c_int = 1 << 7; +pub const GLOB_ALTDIRFUNC: c_int = 1 << 9; +pub const GLOB_BRACE: c_int = 1 << 10; +pub const GLOB_NOMAGIC: c_int = 1 << 11; +pub const GLOB_TILDE: c_int = 1 << 12; +pub const GLOB_ONLYDIR: c_int = 1 << 13; +pub const GLOB_TILDE_CHECK: c_int = 1 << 14; + +// ipc.h +pub const IPC_PRIVATE: crate::key_t = 0; + +pub const IPC_CREAT: c_int = 0o1000; +pub const IPC_EXCL: c_int = 0o2000; +pub const IPC_NOWAIT: c_int = 0o4000; + +pub const IPC_RMID: c_int = 0; +pub const IPC_SET: c_int = 1; +pub const IPC_STAT: c_int = 2; +pub const IPC_INFO: c_int = 3; +pub const MSG_STAT: c_int = 11; +pub const MSG_INFO: c_int = 12; + +pub const MSG_NOERROR: c_int = 0o10000; +pub const MSG_EXCEPT: c_int = 0o20000; + +// shm.h +pub const SHM_R: c_int = 0o400; +pub const SHM_W: c_int = 0o200; + +pub const SHM_RDONLY: c_int = 0o10000; +pub const SHM_RND: c_int = 0o20000; +pub const SHM_REMAP: c_int = 0o40000; + +pub const SHM_LOCK: c_int = 11; +pub const SHM_UNLOCK: c_int = 12; +// unistd.h +pub const __FD_SETSIZE: usize = 256; +pub const R_OK: c_int = 4; +pub const W_OK: c_int = 2; +pub const X_OK: c_int = 1; +pub const F_OK: c_int = 0; +pub const SEEK_SET: c_int = 0; +pub const SEEK_CUR: c_int = 1; +pub const SEEK_END: c_int = 2; +pub const SEEK_DATA: c_int = 3; +pub const SEEK_HOLE: c_int = 4; +pub const L_SET: c_int = 0; +pub const L_INCR: c_int = 1; +pub const L_XTND: c_int = 2; +pub const F_ULOCK: c_int = 0; +pub const F_LOCK: c_int = 1; +pub const F_TLOCK: c_int = 2; +pub const F_TEST: c_int = 3; +pub const CLOSE_RANGE_CLOEXEC: c_int = 4; + +// stdio.h +pub const EOF: c_int = -1; + +// stdlib.h +pub const WNOHANG: c_int = 1; +pub const WUNTRACED: c_int = 2; +pub const WSTOPPED: c_int = 2; +pub const WCONTINUED: c_int = 4; +pub const WNOWAIT: c_int = 8; +pub const WEXITED: c_int = 16; +pub const __W_CONTINUED: c_int = 65535; +pub const __WCOREFLAG: c_int = 128; +pub const RAND_MAX: c_int = 2147483647; +pub const EXIT_FAILURE: c_int = 1; +pub const EXIT_SUCCESS: c_int = 0; +pub const __LITTLE_ENDIAN: usize = 1234; +pub const __BIG_ENDIAN: usize = 4321; +pub const __PDP_ENDIAN: usize = 3412; +pub const __BYTE_ORDER: usize = 1234; +pub const __FLOAT_WORD_ORDER: usize = 1234; +pub const LITTLE_ENDIAN: usize = 1234; +pub const BIG_ENDIAN: usize = 4321; +pub const PDP_ENDIAN: usize = 3412; +pub const BYTE_ORDER: usize = 1234; + +// sys/select.h +pub const FD_SETSIZE: usize = 256; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 32; +pub const __SIZEOF_PTHREAD_ATTR_T: usize = 32; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 28; +pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 24; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 16; +pub const __SIZEOF_PTHREAD_COND_T: usize = 20; +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 8; +pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_ONCE_T: usize = 8; +pub const __PTHREAD_SPIN_LOCK_INITIALIZER: c_int = 0; +pub const PTHREAD_MUTEX_NORMAL: c_int = 0; + +// sys/resource.h +pub const RLIM_INFINITY: crate::rlim_t = 2147483647; +pub const RLIM64_INFINITY: crate::rlim64_t = 9223372036854775807; +pub const RLIM_SAVED_MAX: crate::rlim_t = RLIM_INFINITY; +pub const RLIM_SAVED_CUR: crate::rlim_t = RLIM_INFINITY; +pub const PRIO_MIN: c_int = -20; +pub const PRIO_MAX: c_int = 20; + +// pwd.h +pub const NSS_BUFLEN_PASSWD: usize = 1024; + +// sys/socket.h +pub const SOCK_TYPE_MASK: usize = 15; +pub const PF_UNSPEC: c_int = 0; +pub const PF_LOCAL: c_int = 1; +pub const PF_UNIX: c_int = 1; +pub const PF_FILE: c_int = 1; +pub const PF_INET: c_int = 2; +pub const PF_IMPLINK: c_int = 3; +pub const PF_PUP: c_int = 4; +pub const PF_CHAOS: c_int = 5; +pub const PF_NS: c_int = 6; +pub const PF_ISO: c_int = 7; +pub const PF_OSI: c_int = 7; +pub const PF_ECMA: c_int = 8; +pub const PF_DATAKIT: c_int = 9; +pub const PF_CCITT: c_int = 10; +pub const PF_SNA: c_int = 11; +pub const PF_DECnet: c_int = 12; +pub const PF_DLI: c_int = 13; +pub const PF_LAT: c_int = 14; +pub const PF_HYLINK: c_int = 15; +pub const PF_APPLETALK: c_int = 16; +pub const PF_ROUTE: c_int = 17; +pub const PF_XTP: c_int = 19; +pub const PF_COIP: c_int = 20; +pub const PF_CNT: c_int = 21; +pub const PF_RTIP: c_int = 22; +pub const PF_IPX: c_int = 23; +pub const PF_SIP: c_int = 24; +pub const PF_PIP: c_int = 25; +pub const PF_INET6: c_int = 26; +pub const PF_MAX: c_int = 27; +pub const AF_UNSPEC: c_int = 0; +pub const AF_LOCAL: c_int = 1; +pub const AF_UNIX: c_int = 1; +pub const AF_FILE: c_int = 1; +pub const AF_INET: c_int = 2; +pub const AF_IMPLINK: c_int = 3; +pub const AF_PUP: c_int = 4; +pub const AF_CHAOS: c_int = 5; +pub const AF_NS: c_int = 6; +pub const AF_ISO: c_int = 7; +pub const AF_OSI: c_int = 7; +pub const AF_ECMA: c_int = 8; +pub const AF_DATAKIT: c_int = 9; +pub const AF_CCITT: c_int = 10; +pub const AF_SNA: c_int = 11; +pub const AF_DECnet: c_int = 12; +pub const AF_DLI: c_int = 13; +pub const AF_LAT: c_int = 14; +pub const AF_HYLINK: c_int = 15; +pub const AF_APPLETALK: c_int = 16; +pub const AF_ROUTE: c_int = 17; +pub const pseudo_AF_XTP: c_int = 19; +pub const AF_COIP: c_int = 20; +pub const AF_CNT: c_int = 21; +pub const pseudo_AF_RTIP: c_int = 22; +pub const AF_IPX: c_int = 23; +pub const AF_SIP: c_int = 24; +pub const pseudo_AF_PIP: c_int = 25; +pub const AF_INET6: c_int = 26; +pub const AF_MAX: c_int = 27; +pub const SOMAXCONN: c_int = 4096; +pub const _SS_SIZE: usize = 128; +pub const CMGROUP_MAX: usize = 16; +pub const SOL_SOCKET: c_int = 65535; + +// sys/time.h +pub const ITIMER_REAL: c_int = 0; +pub const ITIMER_VIRTUAL: c_int = 1; +pub const ITIMER_PROF: c_int = 2; + +// netinet/in.h +pub const SOL_IP: c_int = 0; +pub const SOL_TCP: c_int = 6; +pub const SOL_UDP: c_int = 17; +pub const SOL_IPV6: c_int = 41; +pub const SOL_ICMPV6: c_int = 58; +pub const IP_OPTIONS: c_int = 1; +pub const IP_HDRINCL: c_int = 2; +pub const IP_TOS: c_int = 3; +pub const IP_TTL: c_int = 4; +pub const IP_RECVOPTS: c_int = 5; +pub const IP_RECVRETOPTS: c_int = 6; +pub const IP_RECVDSTADDR: c_int = 7; +pub const IP_RETOPTS: c_int = 8; +pub const IP_MULTICAST_IF: c_int = 9; +pub const IP_MULTICAST_TTL: c_int = 10; +pub const IP_MULTICAST_LOOP: c_int = 11; +pub const IP_ADD_MEMBERSHIP: c_int = 12; +pub const IP_DROP_MEMBERSHIP: c_int = 13; +pub const IPV6_ADDRFORM: c_int = 1; +pub const IPV6_2292PKTINFO: c_int = 2; +pub const IPV6_2292HOPOPTS: c_int = 3; +pub const IPV6_2292DSTOPTS: c_int = 4; +pub const IPV6_2292RTHDR: c_int = 5; +pub const IPV6_2292PKTOPTIONS: c_int = 6; +pub const IPV6_CHECKSUM: c_int = 7; +pub const IPV6_2292HOPLIMIT: c_int = 8; +pub const IPV6_RXINFO: c_int = 2; +pub const IPV6_TXINFO: c_int = 2; +pub const SCM_SRCINFO: c_int = 2; +pub const IPV6_UNICAST_HOPS: c_int = 16; +pub const IPV6_MULTICAST_IF: c_int = 17; +pub const IPV6_MULTICAST_HOPS: c_int = 18; +pub const IPV6_MULTICAST_LOOP: c_int = 19; +pub const IPV6_JOIN_GROUP: c_int = 20; +pub const IPV6_LEAVE_GROUP: c_int = 21; +pub const IPV6_ROUTER_ALERT: c_int = 22; +pub const IPV6_MTU_DISCOVER: c_int = 23; +pub const IPV6_MTU: c_int = 24; +pub const IPV6_RECVERR: c_int = 25; +pub const IPV6_V6ONLY: c_int = 26; +pub const IPV6_JOIN_ANYCAST: c_int = 27; +pub const IPV6_LEAVE_ANYCAST: c_int = 28; +pub const IPV6_RECVPKTINFO: c_int = 49; +pub const IPV6_PKTINFO: c_int = 50; +pub const IPV6_RECVHOPLIMIT: c_int = 51; +pub const IPV6_HOPLIMIT: c_int = 52; +pub const IPV6_RECVHOPOPTS: c_int = 53; +pub const IPV6_HOPOPTS: c_int = 54; +pub const IPV6_RTHDRDSTOPTS: c_int = 55; +pub const IPV6_RECVRTHDR: c_int = 56; +pub const IPV6_RTHDR: c_int = 57; +pub const IPV6_RECVDSTOPTS: c_int = 58; +pub const IPV6_DSTOPTS: c_int = 59; +pub const IPV6_RECVPATHMTU: c_int = 60; +pub const IPV6_PATHMTU: c_int = 61; +pub const IPV6_DONTFRAG: c_int = 62; +pub const IPV6_RECVTCLASS: c_int = 66; +pub const IPV6_TCLASS: c_int = 67; +pub const IPV6_ADDR_PREFERENCES: c_int = 72; +pub const IPV6_MINHOPCOUNT: c_int = 73; +pub const IPV6_ADD_MEMBERSHIP: c_int = 20; +pub const IPV6_DROP_MEMBERSHIP: c_int = 21; +pub const IPV6_RXHOPOPTS: c_int = 3; +pub const IPV6_RXDSTOPTS: c_int = 4; +pub const IPV6_RTHDR_LOOSE: c_int = 0; +pub const IPV6_RTHDR_STRICT: c_int = 1; +pub const IPV6_RTHDR_TYPE_0: c_int = 0; +pub const IN_CLASSA_NET: u32 = 4278190080; +pub const IN_CLASSA_NSHIFT: usize = 24; +pub const IN_CLASSA_HOST: u32 = 16777215; +pub const IN_CLASSA_MAX: u32 = 128; +pub const IN_CLASSB_NET: u32 = 4294901760; +pub const IN_CLASSB_NSHIFT: usize = 16; +pub const IN_CLASSB_HOST: u32 = 65535; +pub const IN_CLASSB_MAX: u32 = 65536; +pub const IN_CLASSC_NET: u32 = 4294967040; +pub const IN_CLASSC_NSHIFT: usize = 8; +pub const IN_CLASSC_HOST: u32 = 255; +pub const IN_LOOPBACKNET: u32 = 127; +pub const INET_ADDRSTRLEN: usize = 16; +pub const INET6_ADDRSTRLEN: usize = 46; + +// netinet/ip.h +pub const IPTOS_TOS_MASK: u8 = 0x1E; +pub const IPTOS_PREC_MASK: u8 = 0xE0; + +pub const IPTOS_ECN_NOT_ECT: u8 = 0x00; + +pub const IPTOS_LOWDELAY: u8 = 0x10; +pub const IPTOS_THROUGHPUT: u8 = 0x08; +pub const IPTOS_RELIABILITY: u8 = 0x04; +pub const IPTOS_MINCOST: u8 = 0x02; + +pub const IPTOS_PREC_NETCONTROL: u8 = 0xe0; +pub const IPTOS_PREC_INTERNETCONTROL: u8 = 0xc0; +pub const IPTOS_PREC_CRITIC_ECP: u8 = 0xa0; +pub const IPTOS_PREC_FLASHOVERRIDE: u8 = 0x80; +pub const IPTOS_PREC_FLASH: u8 = 0x60; +pub const IPTOS_PREC_IMMEDIATE: u8 = 0x40; +pub const IPTOS_PREC_PRIORITY: u8 = 0x20; +pub const IPTOS_PREC_ROUTINE: u8 = 0x00; + +pub const IPTOS_ECN_MASK: u8 = 0x03; +pub const IPTOS_ECN_ECT1: u8 = 0x01; +pub const IPTOS_ECN_ECT0: u8 = 0x02; +pub const IPTOS_ECN_CE: u8 = 0x03; + +pub const IPOPT_COPY: u8 = 0x80; +pub const IPOPT_CLASS_MASK: u8 = 0x60; +pub const IPOPT_NUMBER_MASK: u8 = 0x1f; + +pub const IPOPT_CONTROL: u8 = 0x00; +pub const IPOPT_RESERVED1: u8 = 0x20; +pub const IPOPT_MEASUREMENT: u8 = 0x40; +pub const IPOPT_RESERVED2: u8 = 0x60; +pub const IPOPT_END: u8 = 0 | IPOPT_CONTROL; +pub const IPOPT_NOOP: u8 = 1 | IPOPT_CONTROL; +pub const IPOPT_SEC: u8 = 2 | IPOPT_CONTROL | IPOPT_COPY; +pub const IPOPT_LSRR: u8 = 3 | IPOPT_CONTROL | IPOPT_COPY; +pub const IPOPT_TIMESTAMP: u8 = 4 | IPOPT_MEASUREMENT; +pub const IPOPT_RR: u8 = 7 | IPOPT_CONTROL; +pub const IPOPT_SID: u8 = 8 | IPOPT_CONTROL | IPOPT_COPY; +pub const IPOPT_SSRR: u8 = 9 | IPOPT_CONTROL | IPOPT_COPY; +pub const IPOPT_RA: u8 = 20 | IPOPT_CONTROL | IPOPT_COPY; +pub const IPVERSION: u8 = 4; +pub const MAXTTL: u8 = 255; +pub const IPDEFTTL: u8 = 64; +pub const IPOPT_OPTVAL: u8 = 0; +pub const IPOPT_OLEN: u8 = 1; +pub const IPOPT_OFFSET: u8 = 2; +pub const IPOPT_MINOFF: u8 = 4; +pub const MAX_IPOPTLEN: u8 = 40; +pub const IPOPT_NOP: u8 = IPOPT_NOOP; +pub const IPOPT_EOL: u8 = IPOPT_END; +pub const IPOPT_TS: u8 = IPOPT_TIMESTAMP; +pub const IPOPT_TS_TSONLY: u8 = 0; +pub const IPOPT_TS_TSANDADDR: u8 = 1; +pub const IPOPT_TS_PRESPEC: u8 = 3; + +// net/if_arp.h +pub const ARPOP_REQUEST: u16 = 1; +pub const ARPOP_REPLY: u16 = 2; +pub const ARPOP_RREQUEST: u16 = 3; +pub const ARPOP_RREPLY: u16 = 4; +pub const ARPOP_InREQUEST: u16 = 8; +pub const ARPOP_InREPLY: u16 = 9; +pub const ARPOP_NAK: u16 = 10; + +pub const MAX_ADDR_LEN: usize = 7; +pub const ARPD_UPDATE: c_ushort = 0x01; +pub const ARPD_LOOKUP: c_ushort = 0x02; +pub const ARPD_FLUSH: c_ushort = 0x03; +pub const ATF_MAGIC: c_int = 0x80; + +pub const ATF_NETMASK: c_int = 0x20; +pub const ATF_DONTPUB: c_int = 0x40; + +pub const ARPHRD_NETROM: u16 = 0; +pub const ARPHRD_ETHER: u16 = 1; +pub const ARPHRD_EETHER: u16 = 2; +pub const ARPHRD_AX25: u16 = 3; +pub const ARPHRD_PRONET: u16 = 4; +pub const ARPHRD_CHAOS: u16 = 5; +pub const ARPHRD_IEEE802: u16 = 6; +pub const ARPHRD_ARCNET: u16 = 7; +pub const ARPHRD_APPLETLK: u16 = 8; +pub const ARPHRD_DLCI: u16 = 15; +pub const ARPHRD_ATM: u16 = 19; +pub const ARPHRD_METRICOM: u16 = 23; +pub const ARPHRD_IEEE1394: u16 = 24; +pub const ARPHRD_EUI64: u16 = 27; +pub const ARPHRD_INFINIBAND: u16 = 32; + +pub const ARPHRD_SLIP: u16 = 256; +pub const ARPHRD_CSLIP: u16 = 257; +pub const ARPHRD_SLIP6: u16 = 258; +pub const ARPHRD_CSLIP6: u16 = 259; +pub const ARPHRD_RSRVD: u16 = 260; +pub const ARPHRD_ADAPT: u16 = 264; +pub const ARPHRD_ROSE: u16 = 270; +pub const ARPHRD_X25: u16 = 271; +pub const ARPHRD_HWX25: u16 = 272; +pub const ARPHRD_CAN: u16 = 280; +pub const ARPHRD_PPP: u16 = 512; +pub const ARPHRD_CISCO: u16 = 513; +pub const ARPHRD_HDLC: u16 = ARPHRD_CISCO; +pub const ARPHRD_LAPB: u16 = 516; +pub const ARPHRD_DDCMP: u16 = 517; +pub const ARPHRD_RAWHDLC: u16 = 518; + +pub const ARPHRD_TUNNEL: u16 = 768; +pub const ARPHRD_TUNNEL6: u16 = 769; +pub const ARPHRD_FRAD: u16 = 770; +pub const ARPHRD_SKIP: u16 = 771; +pub const ARPHRD_LOOPBACK: u16 = 772; +pub const ARPHRD_LOCALTLK: u16 = 773; +pub const ARPHRD_FDDI: u16 = 774; +pub const ARPHRD_BIF: u16 = 775; +pub const ARPHRD_SIT: u16 = 776; +pub const ARPHRD_IPDDP: u16 = 777; +pub const ARPHRD_IPGRE: u16 = 778; +pub const ARPHRD_PIMREG: u16 = 779; +pub const ARPHRD_HIPPI: u16 = 780; +pub const ARPHRD_ASH: u16 = 781; +pub const ARPHRD_ECONET: u16 = 782; +pub const ARPHRD_IRDA: u16 = 783; +pub const ARPHRD_FCPP: u16 = 784; +pub const ARPHRD_FCAL: u16 = 785; +pub const ARPHRD_FCPL: u16 = 786; +pub const ARPHRD_FCFABRIC: u16 = 787; +pub const ARPHRD_IEEE802_TR: u16 = 800; +pub const ARPHRD_IEEE80211: u16 = 801; +pub const ARPHRD_IEEE80211_PRISM: u16 = 802; +pub const ARPHRD_IEEE80211_RADIOTAP: u16 = 803; +pub const ARPHRD_IEEE802154: u16 = 804; + +pub const ARPHRD_VOID: u16 = 0xFFFF; +pub const ARPHRD_NONE: u16 = 0xFFFE; + +// bits/posix1_lim.h +pub const _POSIX_AIO_LISTIO_MAX: usize = 2; +pub const _POSIX_AIO_MAX: usize = 1; +pub const _POSIX_ARG_MAX: usize = 4096; +pub const _POSIX_CHILD_MAX: usize = 25; +pub const _POSIX_DELAYTIMER_MAX: usize = 32; +pub const _POSIX_HOST_NAME_MAX: usize = 255; +pub const _POSIX_LINK_MAX: usize = 8; +pub const _POSIX_LOGIN_NAME_MAX: usize = 9; +pub const _POSIX_MAX_CANON: usize = 255; +pub const _POSIX_MAX_INPUT: usize = 255; +pub const _POSIX_MQ_OPEN_MAX: usize = 8; +pub const _POSIX_MQ_PRIO_MAX: usize = 32; +pub const _POSIX_NAME_MAX: usize = 14; +pub const _POSIX_NGROUPS_MAX: usize = 8; +pub const _POSIX_OPEN_MAX: usize = 20; +pub const _POSIX_FD_SETSIZE: usize = 20; +pub const _POSIX_PATH_MAX: usize = 256; +pub const _POSIX_PIPE_BUF: usize = 512; +pub const _POSIX_RE_DUP_MAX: usize = 255; +pub const _POSIX_RTSIG_MAX: usize = 8; +pub const _POSIX_SEM_NSEMS_MAX: usize = 256; +pub const _POSIX_SEM_VALUE_MAX: usize = 32767; +pub const _POSIX_SIGQUEUE_MAX: usize = 32; +pub const _POSIX_SSIZE_MAX: usize = 32767; +pub const _POSIX_STREAM_MAX: usize = 8; +pub const _POSIX_SYMLINK_MAX: usize = 255; +pub const _POSIX_SYMLOOP_MAX: usize = 8; +pub const _POSIX_TIMER_MAX: usize = 32; +pub const _POSIX_TTY_NAME_MAX: usize = 9; +pub const _POSIX_TZNAME_MAX: usize = 6; +pub const _POSIX_QLIMIT: usize = 1; +pub const _POSIX_HIWAT: usize = 512; +pub const _POSIX_UIO_MAXIOV: usize = 16; +pub const _POSIX_CLOCKRES_MIN: usize = 20000000; +pub const NAME_MAX: usize = 255; +pub const NGROUPS_MAX: usize = 256; +pub const _POSIX_THREAD_KEYS_MAX: usize = 128; +pub const _POSIX_THREAD_DESTRUCTOR_ITERATIONS: usize = 4; +pub const _POSIX_THREAD_THREADS_MAX: usize = 64; +pub const SEM_VALUE_MAX: c_int = 2147483647; +pub const MAXNAMLEN: usize = 255; + +// netdb.h +pub const _PATH_HEQUIV: &[u8; 17usize] = b"/etc/hosts.equiv\0"; +pub const _PATH_HOSTS: &[u8; 11usize] = b"/etc/hosts\0"; +pub const _PATH_NETWORKS: &[u8; 14usize] = b"/etc/networks\0"; +pub const _PATH_NSSWITCH_CONF: &[u8; 19usize] = b"/etc/nsswitch.conf\0"; +pub const _PATH_PROTOCOLS: &[u8; 15usize] = b"/etc/protocols\0"; +pub const _PATH_SERVICES: &[u8; 14usize] = b"/etc/services\0"; +pub const HOST_NOT_FOUND: c_int = 1; +pub const TRY_AGAIN: c_int = 2; +pub const NO_RECOVERY: c_int = 3; +pub const NO_DATA: c_int = 4; +pub const NETDB_INTERNAL: c_int = -1; +pub const NETDB_SUCCESS: c_int = 0; +pub const NO_ADDRESS: c_int = 4; +pub const IPPORT_RESERVED: c_int = 1024; +pub const SCOPE_DELIMITER: u8 = 37u8; +pub const GAI_WAIT: c_int = 0; +pub const GAI_NOWAIT: c_int = 1; +pub const AI_PASSIVE: c_int = 1; +pub const AI_CANONNAME: c_int = 2; +pub const AI_NUMERICHOST: c_int = 4; +pub const AI_V4MAPPED: c_int = 8; +pub const AI_ALL: c_int = 16; +pub const AI_ADDRCONFIG: c_int = 32; +pub const AI_IDN: c_int = 64; +pub const AI_CANONIDN: c_int = 128; +pub const AI_NUMERICSERV: c_int = 1024; +pub const EAI_BADFLAGS: c_int = -1; +pub const EAI_NONAME: c_int = -2; +pub const EAI_AGAIN: c_int = -3; +pub const EAI_FAIL: c_int = -4; +pub const EAI_FAMILY: c_int = -6; +pub const EAI_SOCKTYPE: c_int = -7; +pub const EAI_SERVICE: c_int = -8; +pub const EAI_MEMORY: c_int = -10; +pub const EAI_SYSTEM: c_int = -11; +pub const EAI_OVERFLOW: c_int = -12; +pub const EAI_NODATA: c_int = -5; +pub const EAI_ADDRFAMILY: c_int = -9; +pub const EAI_INPROGRESS: c_int = -100; +pub const EAI_CANCELED: c_int = -101; +pub const EAI_NOTCANCELED: c_int = -102; +pub const EAI_ALLDONE: c_int = -103; +pub const EAI_INTR: c_int = -104; +pub const EAI_IDN_ENCODE: c_int = -105; +pub const NI_MAXHOST: usize = 1025; +pub const NI_MAXSERV: usize = 32; +pub const NI_NUMERICHOST: c_int = 1; +pub const NI_NUMERICSERV: c_int = 2; +pub const NI_NOFQDN: c_int = 4; +pub const NI_NAMEREQD: c_int = 8; +pub const NI_DGRAM: c_int = 16; +pub const NI_IDN: c_int = 32; + +// time.h +pub const CLOCK_REALTIME: crate::clockid_t = 0; +pub const CLOCK_MONOTONIC: crate::clockid_t = 1; +pub const CLOCK_PROCESS_CPUTIME_ID: crate::clockid_t = 2; +pub const CLOCK_THREAD_CPUTIME_ID: crate::clockid_t = 3; +pub const CLOCK_MONOTONIC_RAW: crate::clockid_t = 4; +pub const CLOCK_REALTIME_COARSE: crate::clockid_t = 5; +pub const CLOCK_MONOTONIC_COARSE: crate::clockid_t = 6; +pub const TIMER_ABSTIME: c_int = 1; +pub const TIME_UTC: c_int = 1; + +// sys/poll.h +pub const POLLIN: i16 = 1; +pub const POLLPRI: i16 = 2; +pub const POLLOUT: i16 = 4; +pub const POLLRDNORM: i16 = 1; +pub const POLLRDBAND: i16 = 2; +pub const POLLWRNORM: i16 = 4; +pub const POLLWRBAND: i16 = 4; +pub const POLLERR: i16 = 8; +pub const POLLHUP: i16 = 16; +pub const POLLNVAL: i16 = 32; + +// locale.h +pub const __LC_CTYPE: usize = 0; +pub const __LC_NUMERIC: usize = 1; +pub const __LC_TIME: usize = 2; +pub const __LC_COLLATE: usize = 3; +pub const __LC_MONETARY: usize = 4; +pub const __LC_MESSAGES: usize = 5; +pub const __LC_ALL: usize = 6; +pub const __LC_PAPER: usize = 7; +pub const __LC_NAME: usize = 8; +pub const __LC_ADDRESS: usize = 9; +pub const __LC_TELEPHONE: usize = 10; +pub const __LC_MEASUREMENT: usize = 11; +pub const __LC_IDENTIFICATION: usize = 12; +pub const LC_CTYPE: c_int = 0; +pub const LC_NUMERIC: c_int = 1; +pub const LC_TIME: c_int = 2; +pub const LC_COLLATE: c_int = 3; +pub const LC_MONETARY: c_int = 4; +pub const LC_MESSAGES: c_int = 5; +pub const LC_ALL: c_int = 6; +pub const LC_PAPER: c_int = 7; +pub const LC_NAME: c_int = 8; +pub const LC_ADDRESS: c_int = 9; +pub const LC_TELEPHONE: c_int = 10; +pub const LC_MEASUREMENT: c_int = 11; +pub const LC_IDENTIFICATION: c_int = 12; +pub const LC_CTYPE_MASK: c_int = 1; +pub const LC_NUMERIC_MASK: c_int = 2; +pub const LC_TIME_MASK: c_int = 4; +pub const LC_COLLATE_MASK: c_int = 8; +pub const LC_MONETARY_MASK: c_int = 16; +pub const LC_MESSAGES_MASK: c_int = 32; +pub const LC_PAPER_MASK: c_int = 128; +pub const LC_NAME_MASK: c_int = 256; +pub const LC_ADDRESS_MASK: c_int = 512; +pub const LC_TELEPHONE_MASK: c_int = 1024; +pub const LC_MEASUREMENT_MASK: c_int = 2048; +pub const LC_IDENTIFICATION_MASK: c_int = 4096; +pub const LC_ALL_MASK: c_int = 8127; + +pub const ABDAY_1: crate::nl_item = 0x20000; +pub const ABDAY_2: crate::nl_item = 0x20001; +pub const ABDAY_3: crate::nl_item = 0x20002; +pub const ABDAY_4: crate::nl_item = 0x20003; +pub const ABDAY_5: crate::nl_item = 0x20004; +pub const ABDAY_6: crate::nl_item = 0x20005; +pub const ABDAY_7: crate::nl_item = 0x20006; + +pub const DAY_1: crate::nl_item = 0x20007; +pub const DAY_2: crate::nl_item = 0x20008; +pub const DAY_3: crate::nl_item = 0x20009; +pub const DAY_4: crate::nl_item = 0x2000A; +pub const DAY_5: crate::nl_item = 0x2000B; +pub const DAY_6: crate::nl_item = 0x2000C; +pub const DAY_7: crate::nl_item = 0x2000D; + +pub const ABMON_1: crate::nl_item = 0x2000E; +pub const ABMON_2: crate::nl_item = 0x2000F; +pub const ABMON_3: crate::nl_item = 0x20010; +pub const ABMON_4: crate::nl_item = 0x20011; +pub const ABMON_5: crate::nl_item = 0x20012; +pub const ABMON_6: crate::nl_item = 0x20013; +pub const ABMON_7: crate::nl_item = 0x20014; +pub const ABMON_8: crate::nl_item = 0x20015; +pub const ABMON_9: crate::nl_item = 0x20016; +pub const ABMON_10: crate::nl_item = 0x20017; +pub const ABMON_11: crate::nl_item = 0x20018; +pub const ABMON_12: crate::nl_item = 0x20019; + +pub const MON_1: crate::nl_item = 0x2001A; +pub const MON_2: crate::nl_item = 0x2001B; +pub const MON_3: crate::nl_item = 0x2001C; +pub const MON_4: crate::nl_item = 0x2001D; +pub const MON_5: crate::nl_item = 0x2001E; +pub const MON_6: crate::nl_item = 0x2001F; +pub const MON_7: crate::nl_item = 0x20020; +pub const MON_8: crate::nl_item = 0x20021; +pub const MON_9: crate::nl_item = 0x20022; +pub const MON_10: crate::nl_item = 0x20023; +pub const MON_11: crate::nl_item = 0x20024; +pub const MON_12: crate::nl_item = 0x20025; + +pub const AM_STR: crate::nl_item = 0x20026; +pub const PM_STR: crate::nl_item = 0x20027; + +pub const D_T_FMT: crate::nl_item = 0x20028; +pub const D_FMT: crate::nl_item = 0x20029; +pub const T_FMT: crate::nl_item = 0x2002A; +pub const T_FMT_AMPM: crate::nl_item = 0x2002B; + +pub const ERA: crate::nl_item = 0x2002C; +pub const ERA_D_FMT: crate::nl_item = 0x2002E; +pub const ALT_DIGITS: crate::nl_item = 0x2002F; +pub const ERA_D_T_FMT: crate::nl_item = 0x20030; +pub const ERA_T_FMT: crate::nl_item = 0x20031; + +pub const CODESET: crate::nl_item = 14; +pub const CRNCYSTR: crate::nl_item = 0x4000F; +pub const RADIXCHAR: crate::nl_item = 0x10000; +pub const THOUSEP: crate::nl_item = 0x10001; +pub const YESEXPR: crate::nl_item = 0x50000; +pub const NOEXPR: crate::nl_item = 0x50001; +pub const YESSTR: crate::nl_item = 0x50002; +pub const NOSTR: crate::nl_item = 0x50003; + +// reboot.h +pub const RB_AUTOBOOT: c_int = 0x0; +pub const RB_ASKNAME: c_int = 0x1; +pub const RB_SINGLE: c_int = 0x2; +pub const RB_KBD: c_int = 0x4; +pub const RB_HALT: c_int = 0x8; +pub const RB_INITNAME: c_int = 0x10; +pub const RB_DFLTROOT: c_int = 0x20; +pub const RB_NOBOOTRC: c_int = 0x20; +pub const RB_ALTBOOT: c_int = 0x40; +pub const RB_UNIPROC: c_int = 0x80; +pub const RB_DEBUGGER: c_int = 0x1000; + +// semaphore.h +pub const __SIZEOF_SEM_T: usize = 20; +pub const SEM_FAILED: *mut crate::sem_t = ptr::null_mut(); + +// termios.h +pub const IGNBRK: crate::tcflag_t = 1; +pub const BRKINT: crate::tcflag_t = 2; +pub const IGNPAR: crate::tcflag_t = 4; +pub const PARMRK: crate::tcflag_t = 8; +pub const INPCK: crate::tcflag_t = 16; +pub const ISTRIP: crate::tcflag_t = 32; +pub const INLCR: crate::tcflag_t = 64; +pub const IGNCR: crate::tcflag_t = 128; +pub const ICRNL: crate::tcflag_t = 256; +pub const IXON: crate::tcflag_t = 512; +pub const IXOFF: crate::tcflag_t = 1024; +pub const IXANY: crate::tcflag_t = 2048; +pub const IMAXBEL: crate::tcflag_t = 8192; +pub const IUCLC: crate::tcflag_t = 16384; +pub const OPOST: crate::tcflag_t = 1; +pub const ONLCR: crate::tcflag_t = 2; +pub const ONOEOT: crate::tcflag_t = 8; +pub const OCRNL: crate::tcflag_t = 16; +pub const ONOCR: crate::tcflag_t = 32; +pub const ONLRET: crate::tcflag_t = 64; +pub const NLDLY: crate::tcflag_t = 768; +pub const NL0: crate::tcflag_t = 0; +pub const NL1: crate::tcflag_t = 256; +pub const TABDLY: crate::tcflag_t = 3076; +pub const TAB0: crate::tcflag_t = 0; +pub const TAB1: crate::tcflag_t = 1024; +pub const TAB2: crate::tcflag_t = 2048; +pub const TAB3: crate::tcflag_t = 4; +pub const CRDLY: crate::tcflag_t = 12288; +pub const CR0: crate::tcflag_t = 0; +pub const CR1: crate::tcflag_t = 4096; +pub const CR2: crate::tcflag_t = 8192; +pub const CR3: crate::tcflag_t = 12288; +pub const FFDLY: crate::tcflag_t = 16384; +pub const FF0: crate::tcflag_t = 0; +pub const FF1: crate::tcflag_t = 16384; +pub const BSDLY: crate::tcflag_t = 32768; +pub const BS0: crate::tcflag_t = 0; +pub const BS1: crate::tcflag_t = 32768; +pub const VTDLY: crate::tcflag_t = 65536; +pub const VT0: crate::tcflag_t = 0; +pub const VT1: crate::tcflag_t = 65536; +pub const OLCUC: crate::tcflag_t = 131072; +pub const OFILL: crate::tcflag_t = 262144; +pub const OFDEL: crate::tcflag_t = 524288; +pub const CIGNORE: crate::tcflag_t = 1; +pub const CSIZE: crate::tcflag_t = 768; +pub const CS5: crate::tcflag_t = 0; +pub const CS6: crate::tcflag_t = 256; +pub const CS7: crate::tcflag_t = 512; +pub const CS8: crate::tcflag_t = 768; +pub const CSTOPB: crate::tcflag_t = 1024; +pub const CREAD: crate::tcflag_t = 2048; +pub const PARENB: crate::tcflag_t = 4096; +pub const PARODD: crate::tcflag_t = 8192; +pub const HUPCL: crate::tcflag_t = 16384; +pub const CLOCAL: crate::tcflag_t = 32768; +pub const CRTSCTS: crate::tcflag_t = 65536; +pub const CRTS_IFLOW: crate::tcflag_t = 65536; +pub const CCTS_OFLOW: crate::tcflag_t = 65536; +pub const CDTRCTS: crate::tcflag_t = 131072; +pub const MDMBUF: crate::tcflag_t = 1048576; +pub const CHWFLOW: crate::tcflag_t = 1245184; +pub const ECHOKE: crate::tcflag_t = 1; +pub const _ECHOE: crate::tcflag_t = 2; +pub const ECHOE: crate::tcflag_t = 2; +pub const _ECHOK: crate::tcflag_t = 4; +pub const ECHOK: crate::tcflag_t = 4; +pub const _ECHO: crate::tcflag_t = 8; +pub const ECHO: crate::tcflag_t = 8; +pub const _ECHONL: crate::tcflag_t = 16; +pub const ECHONL: crate::tcflag_t = 16; +pub const ECHOPRT: crate::tcflag_t = 32; +pub const ECHOCTL: crate::tcflag_t = 64; +pub const _ISIG: crate::tcflag_t = 128; +pub const ISIG: crate::tcflag_t = 128; +pub const _ICANON: crate::tcflag_t = 256; +pub const ICANON: crate::tcflag_t = 256; +pub const ALTWERASE: crate::tcflag_t = 512; +pub const _IEXTEN: crate::tcflag_t = 1024; +pub const IEXTEN: crate::tcflag_t = 1024; +pub const EXTPROC: crate::tcflag_t = 2048; +pub const _TOSTOP: crate::tcflag_t = 4194304; +pub const TOSTOP: crate::tcflag_t = 4194304; +pub const FLUSHO: crate::tcflag_t = 8388608; +pub const NOKERNINFO: crate::tcflag_t = 33554432; +pub const PENDIN: crate::tcflag_t = 536870912; +pub const _NOFLSH: crate::tcflag_t = 2147483648; +pub const NOFLSH: crate::tcflag_t = 2147483648; +pub const VEOF: usize = 0; +pub const VEOL: usize = 1; +pub const VEOL2: usize = 2; +pub const VERASE: usize = 3; +pub const VWERASE: usize = 4; +pub const VKILL: usize = 5; +pub const VREPRINT: usize = 6; +pub const VINTR: usize = 8; +pub const VQUIT: usize = 9; +pub const VSUSP: usize = 10; +pub const VDSUSP: usize = 11; +pub const VSTART: usize = 12; +pub const VSTOP: usize = 13; +pub const VLNEXT: usize = 14; +pub const VDISCARD: usize = 15; +pub const VMIN: usize = 16; +pub const VTIME: usize = 17; +pub const VSTATUS: usize = 18; +pub const NCCS: usize = 20; +pub const B0: crate::speed_t = 0; +pub const B50: crate::speed_t = 50; +pub const B75: crate::speed_t = 75; +pub const B110: crate::speed_t = 110; +pub const B134: crate::speed_t = 134; +pub const B150: crate::speed_t = 150; +pub const B200: crate::speed_t = 200; +pub const B300: crate::speed_t = 300; +pub const B600: crate::speed_t = 600; +pub const B1200: crate::speed_t = 1200; +pub const B1800: crate::speed_t = 1800; +pub const B2400: crate::speed_t = 2400; +pub const B4800: crate::speed_t = 4800; +pub const B9600: crate::speed_t = 9600; +pub const B7200: crate::speed_t = 7200; +pub const B14400: crate::speed_t = 14400; +pub const B19200: crate::speed_t = 19200; +pub const B28800: crate::speed_t = 28800; +pub const B38400: crate::speed_t = 38400; +pub const EXTA: crate::speed_t = B19200; +pub const EXTB: crate::speed_t = B38400; +pub const B57600: crate::speed_t = 57600; +pub const B76800: crate::speed_t = 76800; +pub const B115200: crate::speed_t = 115200; +pub const B230400: crate::speed_t = 230400; +pub const B460800: crate::speed_t = 460800; +pub const B500000: crate::speed_t = 500000; +pub const B576000: crate::speed_t = 576000; +pub const B921600: crate::speed_t = 921600; +pub const B1000000: crate::speed_t = 1000000; +pub const B1152000: crate::speed_t = 1152000; +pub const B1500000: crate::speed_t = 1500000; +pub const B2000000: crate::speed_t = 2000000; +pub const B2500000: crate::speed_t = 2500000; +pub const B3000000: crate::speed_t = 3000000; +pub const B3500000: crate::speed_t = 3500000; +pub const B4000000: crate::speed_t = 4000000; +pub const TCSANOW: c_int = 0; +pub const TCSADRAIN: c_int = 1; +pub const TCSAFLUSH: c_int = 2; +pub const TCSASOFT: c_int = 16; +pub const TCIFLUSH: c_int = 1; +pub const TCOFLUSH: c_int = 2; +pub const TCIOFLUSH: c_int = 3; +pub const TCOOFF: c_int = 1; +pub const TCOON: c_int = 2; +pub const TCIOFF: c_int = 3; +pub const TCION: c_int = 4; +pub const TTYDEF_IFLAG: crate::tcflag_t = 11042; +pub const TTYDEF_LFLAG: crate::tcflag_t = 1483; +pub const TTYDEF_CFLAG: crate::tcflag_t = 23040; +pub const TTYDEF_SPEED: crate::tcflag_t = 9600; +pub const CEOL: u8 = 0u8; +pub const CERASE: u8 = 127; +pub const CMIN: u8 = 1; +pub const CQUIT: u8 = 28; +pub const CTIME: u8 = 0; +pub const CBRK: u8 = 0u8; + +// dlfcn.h +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); +pub const RTLD_NEXT: *mut c_void = -1i64 as *mut c_void; +pub const RTLD_LAZY: c_int = 1; +pub const RTLD_NOW: c_int = 2; +pub const RTLD_BINDING_MASK: c_int = 3; +pub const RTLD_NOLOAD: c_int = 4; +pub const RTLD_DEEPBIND: c_int = 8; +pub const RTLD_GLOBAL: c_int = 256; +pub const RTLD_LOCAL: c_int = 0; +pub const RTLD_NODELETE: c_int = 4096; +pub const DLFO_STRUCT_HAS_EH_DBASE: usize = 1; +pub const DLFO_STRUCT_HAS_EH_COUNT: usize = 0; +pub const LM_ID_BASE: c_long = 0; +pub const LM_ID_NEWLM: c_long = -1; + +// bits/signum_generic.h +pub const SIGINT: c_int = 2; +pub const SIGILL: c_int = 4; +pub const SIGABRT: c_int = 6; +pub const SIGFPE: c_int = 8; +pub const SIGSEGV: c_int = 11; +pub const SIGTERM: c_int = 15; +pub const SIGHUP: c_int = 1; +pub const SIGQUIT: c_int = 3; +pub const SIGTRAP: c_int = 5; +pub const SIGKILL: c_int = 9; +pub const SIGPIPE: c_int = 13; +pub const SIGALRM: c_int = 14; +pub const SIGIOT: c_int = 6; +pub const SIGBUS: c_int = 10; +pub const SIGSYS: c_int = 12; +pub const SIGEMT: c_int = 7; +pub const SIGINFO: c_int = 29; +pub const SIGLOST: c_int = 32; +pub const SIGURG: c_int = 16; +pub const SIGSTOP: c_int = 17; +pub const SIGTSTP: c_int = 18; +pub const SIGCONT: c_int = 19; +pub const SIGCHLD: c_int = 20; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGPOLL: c_int = 23; +pub const SIGXCPU: c_int = 24; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGXFSZ: c_int = 25; +pub const SIGUSR1: c_int = 30; +pub const SIGUSR2: c_int = 31; +pub const SIGWINCH: c_int = 28; +pub const SIGIO: c_int = 23; +pub const SIGCLD: c_int = 20; +pub const __SIGRTMIN: usize = 32; +pub const __SIGRTMAX: usize = 32; +pub const _NSIG: usize = 33; +pub const NSIG: usize = 33; + +// bits/sigaction.h +pub const SA_ONSTACK: c_int = 1; +pub const SA_RESTART: c_int = 2; +pub const SA_NODEFER: c_int = 16; +pub const SA_RESETHAND: c_int = 4; +pub const SA_NOCLDSTOP: c_int = 8; +pub const SA_SIGINFO: c_int = 64; +pub const SA_INTERRUPT: c_int = 0; +pub const SA_NOMASK: c_int = 16; +pub const SA_ONESHOT: c_int = 4; +pub const SA_STACK: c_int = 1; +pub const SIG_BLOCK: c_int = 1; +pub const SIG_UNBLOCK: c_int = 2; +pub const SIG_SETMASK: c_int = 3; + +// bits/sigcontext.h +pub const FPC_IE: u16 = 1; +pub const FPC_IM: u16 = 1; +pub const FPC_DE: u16 = 2; +pub const FPC_DM: u16 = 2; +pub const FPC_ZE: u16 = 4; +pub const FPC_ZM: u16 = 4; +pub const FPC_OE: u16 = 8; +pub const FPC_OM: u16 = 8; +pub const FPC_UE: u16 = 16; +pub const FPC_PE: u16 = 32; +pub const FPC_PC: u16 = 768; +pub const FPC_PC_24: u16 = 0; +pub const FPC_PC_53: u16 = 512; +pub const FPC_PC_64: u16 = 768; +pub const FPC_RC: u16 = 3072; +pub const FPC_RC_RN: u16 = 0; +pub const FPC_RC_RD: u16 = 1024; +pub const FPC_RC_RU: u16 = 2048; +pub const FPC_RC_CHOP: u16 = 3072; +pub const FPC_IC: u16 = 4096; +pub const FPC_IC_PROJ: u16 = 0; +pub const FPC_IC_AFF: u16 = 4096; +pub const FPS_IE: u16 = 1; +pub const FPS_DE: u16 = 2; +pub const FPS_ZE: u16 = 4; +pub const FPS_OE: u16 = 8; +pub const FPS_UE: u16 = 16; +pub const FPS_PE: u16 = 32; +pub const FPS_SF: u16 = 64; +pub const FPS_ES: u16 = 128; +pub const FPS_C0: u16 = 256; +pub const FPS_C1: u16 = 512; +pub const FPS_C2: u16 = 1024; +pub const FPS_TOS: u16 = 14336; +pub const FPS_TOS_SHIFT: u16 = 11; +pub const FPS_C3: u16 = 16384; +pub const FPS_BUSY: u16 = 32768; +pub const FPE_INTOVF_TRAP: c_int = 1; +pub const FPE_INTDIV_FAULT: c_int = 2; +pub const FPE_FLTOVF_FAULT: c_int = 3; +pub const FPE_FLTDIV_FAULT: c_int = 4; +pub const FPE_FLTUND_FAULT: c_int = 5; +pub const FPE_SUBRNG_FAULT: c_int = 7; +pub const FPE_FLTDNR_FAULT: c_int = 8; +pub const FPE_FLTINX_FAULT: c_int = 9; +pub const FPE_EMERR_FAULT: c_int = 10; +pub const FPE_EMBND_FAULT: c_int = 11; +pub const ILL_INVOPR_FAULT: c_int = 1; +pub const ILL_STACK_FAULT: c_int = 2; +pub const ILL_FPEOPR_FAULT: c_int = 3; +pub const DBG_SINGLE_TRAP: c_int = 1; +pub const DBG_BRKPNT_FAULT: c_int = 2; +pub const __NGREG: usize = 19; +pub const NGREG: usize = 19; + +// bits/sigstack.h +pub const MINSIGSTKSZ: usize = 8192; +pub const SIGSTKSZ: usize = 40960; + +// sys/stat.h +pub const __S_IFMT: mode_t = 0o17_0000; +pub const __S_IFDIR: mode_t = 0o4_0000; +pub const __S_IFCHR: mode_t = 0o2_0000; +pub const __S_IFBLK: mode_t = 0o6_0000; +pub const __S_IFREG: mode_t = 0o10_0000; +pub const __S_IFLNK: mode_t = 0o12_0000; +pub const __S_IFSOCK: mode_t = 0o14_0000; +pub const __S_IFIFO: mode_t = 0o1_0000; +pub const __S_ISUID: mode_t = 0o4000; +pub const __S_ISGID: mode_t = 0o2000; +pub const __S_ISVTX: mode_t = 0o1000; +pub const __S_IREAD: mode_t = 0o0400; +pub const __S_IWRITE: mode_t = 0o0200; +pub const __S_IEXEC: mode_t = 0o0100; +pub const S_INOCACHE: mode_t = 0o20_0000; +pub const S_IUSEUNK: mode_t = 0o40_0000; +pub const S_IUNKNOWN: mode_t = 0o700_0000; +pub const S_IUNKSHIFT: mode_t = 0o0014; +pub const S_IPTRANS: mode_t = 0o1000_0000; +pub const S_IATRANS: mode_t = 0o2000_0000; +pub const S_IROOT: mode_t = 0o4000_0000; +pub const S_ITRANS: mode_t = 0o7000_0000; +pub const S_IMMAP0: mode_t = 0o10000_0000; +pub const CMASK: mode_t = 18; +pub const UF_SETTABLE: c_uint = 65535; +pub const UF_NODUMP: c_uint = 1; +pub const UF_IMMUTABLE: c_uint = 2; +pub const UF_APPEND: c_uint = 4; +pub const UF_OPAQUE: c_uint = 8; +pub const UF_NOUNLINK: c_uint = 16; +pub const SF_SETTABLE: c_uint = 4294901760; +pub const SF_ARCHIVED: c_uint = 65536; +pub const SF_IMMUTABLE: c_uint = 131072; +pub const SF_APPEND: c_uint = 262144; +pub const SF_NOUNLINK: c_uint = 1048576; +pub const SF_SNAPSHOT: c_uint = 2097152; +pub const UTIME_NOW: c_long = -1; +pub const UTIME_OMIT: c_long = -2; +pub const S_IFMT: mode_t = 0o17_0000; +pub const S_IFDIR: mode_t = 0o4_0000; +pub const S_IFCHR: mode_t = 0o2_0000; +pub const S_IFBLK: mode_t = 0o6_0000; +pub const S_IFREG: mode_t = 0o10_0000; +pub const S_IFIFO: mode_t = 0o1_0000; +pub const S_IFLNK: mode_t = 0o12_0000; +pub const S_IFSOCK: mode_t = 0o14_0000; +pub const S_ISUID: mode_t = 0o4000; +pub const S_ISGID: mode_t = 0o2000; +pub const S_ISVTX: mode_t = 0o1000; +pub const S_IRUSR: mode_t = 0o0400; +pub const S_IWUSR: mode_t = 0o0200; +pub const S_IXUSR: mode_t = 0o0100; +pub const S_IRWXU: mode_t = 0o0700; +pub const S_IREAD: mode_t = 0o0400; +pub const S_IWRITE: mode_t = 0o0200; +pub const S_IEXEC: mode_t = 0o0100; +pub const S_IRGRP: mode_t = 0o0040; +pub const S_IWGRP: mode_t = 0o0020; +pub const S_IXGRP: mode_t = 0o0010; +pub const S_IRWXG: mode_t = 0o0070; +pub const S_IROTH: mode_t = 0o0004; +pub const S_IWOTH: mode_t = 0o0002; +pub const S_IXOTH: mode_t = 0o0001; +pub const S_IRWXO: mode_t = 0o0007; +pub const ACCESSPERMS: mode_t = 511; +pub const ALLPERMS: mode_t = 4095; +pub const DEFFILEMODE: mode_t = 438; +pub const S_BLKSIZE: usize = 512; +pub const STATX_TYPE: c_uint = 1; +pub const STATX_MODE: c_uint = 2; +pub const STATX_NLINK: c_uint = 4; +pub const STATX_UID: c_uint = 8; +pub const STATX_GID: c_uint = 16; +pub const STATX_ATIME: c_uint = 32; +pub const STATX_MTIME: c_uint = 64; +pub const STATX_CTIME: c_uint = 128; +pub const STATX_INO: c_uint = 256; +pub const STATX_SIZE: c_uint = 512; +pub const STATX_BLOCKS: c_uint = 1024; +pub const STATX_BASIC_STATS: c_uint = 2047; +pub const STATX_ALL: c_uint = 4095; +pub const STATX_BTIME: c_uint = 2048; +pub const STATX_MNT_ID: c_uint = 4096; +pub const STATX_DIOALIGN: c_uint = 8192; +pub const STATX__RESERVED: c_uint = 2147483648; +pub const STATX_ATTR_COMPRESSED: c_uint = 4; +pub const STATX_ATTR_IMMUTABLE: c_uint = 16; +pub const STATX_ATTR_APPEND: c_uint = 32; +pub const STATX_ATTR_NODUMP: c_uint = 64; +pub const STATX_ATTR_ENCRYPTED: c_uint = 2048; +pub const STATX_ATTR_AUTOMOUNT: c_uint = 4096; +pub const STATX_ATTR_MOUNT_ROOT: c_uint = 8192; +pub const STATX_ATTR_VERITY: c_uint = 1048576; +pub const STATX_ATTR_DAX: c_uint = 2097152; + +// sys/ioctl.h +pub const TIOCM_LE: c_int = 1; +pub const TIOCM_DTR: c_int = 2; +pub const TIOCM_RTS: c_int = 4; +pub const TIOCM_ST: c_int = 8; +pub const TIOCM_SR: c_int = 16; +pub const TIOCM_CTS: c_int = 32; +pub const TIOCM_CAR: c_int = 64; +pub const TIOCM_CD: c_int = 64; +pub const TIOCM_RNG: c_int = 128; +pub const TIOCM_RI: c_int = 128; +pub const TIOCM_DSR: c_int = 256; +pub const TIOCPKT_DATA: c_int = 0; +pub const TIOCPKT_FLUSHREAD: c_int = 1; +pub const TIOCPKT_FLUSHWRITE: c_int = 2; +pub const TIOCPKT_STOP: c_int = 4; +pub const TIOCPKT_START: c_int = 8; +pub const TIOCPKT_NOSTOP: c_int = 16; +pub const TIOCPKT_DOSTOP: c_int = 32; +pub const TIOCPKT_IOCTL: c_int = 64; +pub const TTYDISC: c_int = 0; +pub const TABLDISC: c_int = 3; +pub const SLIPDISC: c_int = 4; +pub const TANDEM: crate::tcflag_t = 1; +pub const CBREAK: crate::tcflag_t = 2; +pub const LCASE: crate::tcflag_t = 4; +pub const CRMOD: crate::tcflag_t = 16; +pub const RAW: crate::tcflag_t = 32; +pub const ODDP: crate::tcflag_t = 64; +pub const EVENP: crate::tcflag_t = 128; +pub const ANYP: crate::tcflag_t = 192; +pub const NLDELAY: crate::tcflag_t = 768; +pub const NL2: crate::tcflag_t = 512; +pub const NL3: crate::tcflag_t = 768; +pub const TBDELAY: crate::tcflag_t = 3072; +pub const XTABS: crate::tcflag_t = 3072; +pub const CRDELAY: crate::tcflag_t = 12288; +pub const VTDELAY: crate::tcflag_t = 16384; +pub const BSDELAY: crate::tcflag_t = 32768; +pub const ALLDELAY: crate::tcflag_t = 65280; +pub const CRTBS: crate::tcflag_t = 65536; +pub const PRTERA: crate::tcflag_t = 131072; +pub const CRTERA: crate::tcflag_t = 262144; +pub const TILDE: crate::tcflag_t = 524288; +pub const LITOUT: crate::tcflag_t = 2097152; +pub const NOHANG: crate::tcflag_t = 16777216; +pub const L001000: crate::tcflag_t = 33554432; +pub const CRTKIL: crate::tcflag_t = 67108864; +pub const PASS8: crate::tcflag_t = 134217728; +pub const CTLECH: crate::tcflag_t = 268435456; +pub const DECCTQ: crate::tcflag_t = 1073741824; + +pub const FIONBIO: c_ulong = 0xa008007e; +pub const FIONREAD: c_ulong = 0x6008007f; +pub const TIOCSWINSZ: c_ulong = 0x90200767; +pub const TIOCGWINSZ: c_ulong = 0x50200768; +pub const TIOCEXCL: c_ulong = 0x70d; +pub const TIOCNXCL: c_ulong = 0x70e; +pub const TIOCSCTTY: c_ulong = 0x761; + +pub const FIOCLEX: c_ulong = 1; + +// fcntl.h +pub const O_EXEC: c_int = 4; +pub const O_NORW: c_int = 0; +pub const O_RDONLY: c_int = 1; +pub const O_WRONLY: c_int = 2; +pub const O_RDWR: c_int = 3; +pub const O_ACCMODE: c_int = 3; +pub const O_LARGEFILE: c_int = 0; +pub const O_CREAT: c_int = 16; +pub const O_EXCL: c_int = 32; +pub const O_NOLINK: c_int = 64; +pub const O_NOTRANS: c_int = 128; +pub const O_NOFOLLOW: c_int = 1048576; +pub const O_DIRECTORY: c_int = 2097152; +pub const O_APPEND: c_int = 256; +pub const O_ASYNC: c_int = 512; +pub const O_FSYNC: c_int = 1024; +pub const O_SYNC: c_int = 1024; +pub const O_NOATIME: c_int = 2048; +pub const O_SHLOCK: c_int = 131072; +pub const O_EXLOCK: c_int = 262144; +pub const O_DSYNC: c_int = 1024; +pub const O_RSYNC: c_int = 1024; +pub const O_NONBLOCK: c_int = 8; +pub const O_NDELAY: c_int = 8; +pub const O_HURD: c_int = 458751; +pub const O_TRUNC: c_int = 65536; +pub const O_CLOEXEC: c_int = 4194304; +pub const O_IGNORE_CTTY: c_int = 524288; +pub const O_TMPFILE: c_int = 8388608; +pub const O_NOCTTY: c_int = 0; +pub const FREAD: c_int = 1; +pub const FWRITE: c_int = 2; +pub const FASYNC: c_int = 512; +pub const FCREAT: c_int = 16; +pub const FEXCL: c_int = 32; +pub const FTRUNC: c_int = 65536; +pub const FNOCTTY: c_int = 0; +pub const FFSYNC: c_int = 1024; +pub const FSYNC: c_int = 1024; +pub const FAPPEND: c_int = 256; +pub const FNONBLOCK: c_int = 8; +pub const FNDELAY: c_int = 8; +pub const F_DUPFD: c_int = 0; +pub const F_GETFD: c_int = 1; +pub const F_SETFD: c_int = 2; +pub const F_GETFL: c_int = 3; +pub const F_SETFL: c_int = 4; +pub const F_GETOWN: c_int = 5; +pub const F_SETOWN: c_int = 6; +pub const F_GETLK: c_int = 7; +pub const F_SETLK: c_int = 8; +pub const F_SETLKW: c_int = 9; +pub const F_GETLK64: c_int = 10; +pub const F_SETLK64: c_int = 11; +pub const F_SETLKW64: c_int = 12; +pub const F_DUPFD_CLOEXEC: c_int = 1030; +pub const FD_CLOEXEC: c_int = 1; +pub const F_RDLCK: c_int = 1; +pub const F_WRLCK: c_int = 2; +pub const F_UNLCK: c_int = 3; +pub const POSIX_FADV_NORMAL: c_int = 0; +pub const POSIX_FADV_RANDOM: c_int = 1; +pub const POSIX_FADV_SEQUENTIAL: c_int = 2; +pub const POSIX_FADV_WILLNEED: c_int = 3; +pub const POSIX_FADV_DONTNEED: c_int = 4; +pub const POSIX_FADV_NOREUSE: c_int = 5; +pub const AT_FDCWD: c_int = -100; +pub const AT_SYMLINK_NOFOLLOW: c_int = 256; +pub const AT_REMOVEDIR: c_int = 512; +pub const AT_SYMLINK_FOLLOW: c_int = 1024; +pub const AT_NO_AUTOMOUNT: c_int = 2048; +pub const AT_EMPTY_PATH: c_int = 4096; +pub const AT_STATX_SYNC_TYPE: c_int = 24576; +pub const AT_STATX_SYNC_AS_STAT: c_int = 0; +pub const AT_STATX_FORCE_SYNC: c_int = 8192; +pub const AT_STATX_DONT_SYNC: c_int = 16384; +pub const AT_RECURSIVE: c_int = 32768; +pub const AT_EACCESS: c_int = 512; + +// sys/uio.h +pub const RWF_HIPRI: c_int = 1; +pub const RWF_DSYNC: c_int = 2; +pub const RWF_SYNC: c_int = 4; +pub const RWF_NOWAIT: c_int = 8; +pub const RWF_APPEND: c_int = 16; + +// errno.h +pub const EPERM: c_int = 1073741825; +pub const ENOENT: c_int = 1073741826; +pub const ESRCH: c_int = 1073741827; +pub const EINTR: c_int = 1073741828; +pub const EIO: c_int = 1073741829; +pub const ENXIO: c_int = 1073741830; +pub const E2BIG: c_int = 1073741831; +pub const ENOEXEC: c_int = 1073741832; +pub const EBADF: c_int = 1073741833; +pub const ECHILD: c_int = 1073741834; +pub const EDEADLK: c_int = 1073741835; +pub const ENOMEM: c_int = 1073741836; +pub const EACCES: c_int = 1073741837; +pub const EFAULT: c_int = 1073741838; +pub const ENOTBLK: c_int = 1073741839; +pub const EBUSY: c_int = 1073741840; +pub const EEXIST: c_int = 1073741841; +pub const EXDEV: c_int = 1073741842; +pub const ENODEV: c_int = 1073741843; +pub const ENOTDIR: c_int = 1073741844; +pub const EISDIR: c_int = 1073741845; +pub const EINVAL: c_int = 1073741846; +pub const EMFILE: c_int = 1073741848; +pub const ENFILE: c_int = 1073741847; +pub const ENOTTY: c_int = 1073741849; +pub const ETXTBSY: c_int = 1073741850; +pub const EFBIG: c_int = 1073741851; +pub const ENOSPC: c_int = 1073741852; +pub const ESPIPE: c_int = 1073741853; +pub const EROFS: c_int = 1073741854; +pub const EMLINK: c_int = 1073741855; +pub const EPIPE: c_int = 1073741856; +pub const EDOM: c_int = 1073741857; +pub const ERANGE: c_int = 1073741858; +pub const EAGAIN: c_int = 1073741859; +pub const EWOULDBLOCK: c_int = 1073741859; +pub const EINPROGRESS: c_int = 1073741860; +pub const EALREADY: c_int = 1073741861; +pub const ENOTSOCK: c_int = 1073741862; +pub const EMSGSIZE: c_int = 1073741864; +pub const EPROTOTYPE: c_int = 1073741865; +pub const ENOPROTOOPT: c_int = 1073741866; +pub const EPROTONOSUPPORT: c_int = 1073741867; +pub const ESOCKTNOSUPPORT: c_int = 1073741868; +pub const EOPNOTSUPP: c_int = 1073741869; +pub const EPFNOSUPPORT: c_int = 1073741870; +pub const EAFNOSUPPORT: c_int = 1073741871; +pub const EADDRINUSE: c_int = 1073741872; +pub const EADDRNOTAVAIL: c_int = 1073741873; +pub const ENETDOWN: c_int = 1073741874; +pub const ENETUNREACH: c_int = 1073741875; +pub const ENETRESET: c_int = 1073741876; +pub const ECONNABORTED: c_int = 1073741877; +pub const ECONNRESET: c_int = 1073741878; +pub const ENOBUFS: c_int = 1073741879; +pub const EISCONN: c_int = 1073741880; +pub const ENOTCONN: c_int = 1073741881; +pub const EDESTADDRREQ: c_int = 1073741863; +pub const ESHUTDOWN: c_int = 1073741882; +pub const ETOOMANYREFS: c_int = 1073741883; +pub const ETIMEDOUT: c_int = 1073741884; +pub const ECONNREFUSED: c_int = 1073741885; +pub const ELOOP: c_int = 1073741886; +pub const ENAMETOOLONG: c_int = 1073741887; +pub const EHOSTDOWN: c_int = 1073741888; +pub const EHOSTUNREACH: c_int = 1073741889; +pub const ENOTEMPTY: c_int = 1073741890; +pub const EPROCLIM: c_int = 1073741891; +pub const EUSERS: c_int = 1073741892; +pub const EDQUOT: c_int = 1073741893; +pub const ESTALE: c_int = 1073741894; +pub const EREMOTE: c_int = 1073741895; +pub const EBADRPC: c_int = 1073741896; +pub const ERPCMISMATCH: c_int = 1073741897; +pub const EPROGUNAVAIL: c_int = 1073741898; +pub const EPROGMISMATCH: c_int = 1073741899; +pub const EPROCUNAVAIL: c_int = 1073741900; +pub const ENOLCK: c_int = 1073741901; +pub const EFTYPE: c_int = 1073741903; +pub const EAUTH: c_int = 1073741904; +pub const ENEEDAUTH: c_int = 1073741905; +pub const ENOSYS: c_int = 1073741902; +pub const ELIBEXEC: c_int = 1073741907; +pub const ENOTSUP: c_int = 1073741942; +pub const EILSEQ: c_int = 1073741930; +pub const EBACKGROUND: c_int = 1073741924; +pub const EDIED: c_int = 1073741925; +pub const EGREGIOUS: c_int = 1073741927; +pub const EIEIO: c_int = 1073741928; +pub const EGRATUITOUS: c_int = 1073741929; +pub const EBADMSG: c_int = 1073741931; +pub const EIDRM: c_int = 1073741932; +pub const EMULTIHOP: c_int = 1073741933; +pub const ENODATA: c_int = 1073741934; +pub const ENOLINK: c_int = 1073741935; +pub const ENOMSG: c_int = 1073741936; +pub const ENOSR: c_int = 1073741937; +pub const ENOSTR: c_int = 1073741938; +pub const EOVERFLOW: c_int = 1073741939; +pub const EPROTO: c_int = 1073741940; +pub const ETIME: c_int = 1073741941; +pub const ECANCELED: c_int = 1073741943; +pub const EOWNERDEAD: c_int = 1073741944; +pub const ENOTRECOVERABLE: c_int = 1073741945; +pub const EMACH_SEND_IN_PROGRESS: c_int = 268435457; +pub const EMACH_SEND_INVALID_DATA: c_int = 268435458; +pub const EMACH_SEND_INVALID_DEST: c_int = 268435459; +pub const EMACH_SEND_TIMED_OUT: c_int = 268435460; +pub const EMACH_SEND_WILL_NOTIFY: c_int = 268435461; +pub const EMACH_SEND_NOTIFY_IN_PROGRESS: c_int = 268435462; +pub const EMACH_SEND_INTERRUPTED: c_int = 268435463; +pub const EMACH_SEND_MSG_TOO_SMALL: c_int = 268435464; +pub const EMACH_SEND_INVALID_REPLY: c_int = 268435465; +pub const EMACH_SEND_INVALID_RIGHT: c_int = 268435466; +pub const EMACH_SEND_INVALID_NOTIFY: c_int = 268435467; +pub const EMACH_SEND_INVALID_MEMORY: c_int = 268435468; +pub const EMACH_SEND_NO_BUFFER: c_int = 268435469; +pub const EMACH_SEND_NO_NOTIFY: c_int = 268435470; +pub const EMACH_SEND_INVALID_TYPE: c_int = 268435471; +pub const EMACH_SEND_INVALID_HEADER: c_int = 268435472; +pub const EMACH_RCV_IN_PROGRESS: c_int = 268451841; +pub const EMACH_RCV_INVALID_NAME: c_int = 268451842; +pub const EMACH_RCV_TIMED_OUT: c_int = 268451843; +pub const EMACH_RCV_TOO_LARGE: c_int = 268451844; +pub const EMACH_RCV_INTERRUPTED: c_int = 268451845; +pub const EMACH_RCV_PORT_CHANGED: c_int = 268451846; +pub const EMACH_RCV_INVALID_NOTIFY: c_int = 268451847; +pub const EMACH_RCV_INVALID_DATA: c_int = 268451848; +pub const EMACH_RCV_PORT_DIED: c_int = 268451849; +pub const EMACH_RCV_IN_SET: c_int = 268451850; +pub const EMACH_RCV_HEADER_ERROR: c_int = 268451851; +pub const EMACH_RCV_BODY_ERROR: c_int = 268451852; +pub const EKERN_INVALID_ADDRESS: c_int = 1; +pub const EKERN_PROTECTION_FAILURE: c_int = 2; +pub const EKERN_NO_SPACE: c_int = 3; +pub const EKERN_INVALID_ARGUMENT: c_int = 4; +pub const EKERN_FAILURE: c_int = 5; +pub const EKERN_RESOURCE_SHORTAGE: c_int = 6; +pub const EKERN_NOT_RECEIVER: c_int = 7; +pub const EKERN_NO_ACCESS: c_int = 8; +pub const EKERN_MEMORY_FAILURE: c_int = 9; +pub const EKERN_MEMORY_ERROR: c_int = 10; +pub const EKERN_NOT_IN_SET: c_int = 12; +pub const EKERN_NAME_EXISTS: c_int = 13; +pub const EKERN_ABORTED: c_int = 14; +pub const EKERN_INVALID_NAME: c_int = 15; +pub const EKERN_INVALID_TASK: c_int = 16; +pub const EKERN_INVALID_RIGHT: c_int = 17; +pub const EKERN_INVALID_VALUE: c_int = 18; +pub const EKERN_UREFS_OVERFLOW: c_int = 19; +pub const EKERN_INVALID_CAPABILITY: c_int = 20; +pub const EKERN_RIGHT_EXISTS: c_int = 21; +pub const EKERN_INVALID_HOST: c_int = 22; +pub const EKERN_MEMORY_PRESENT: c_int = 23; +pub const EKERN_WRITE_PROTECTION_FAILURE: c_int = 24; +pub const EKERN_TERMINATED: c_int = 26; +pub const EKERN_TIMEDOUT: c_int = 27; +pub const EKERN_INTERRUPTED: c_int = 28; +pub const EMIG_TYPE_ERROR: c_int = -300; +pub const EMIG_REPLY_MISMATCH: c_int = -301; +pub const EMIG_REMOTE_ERROR: c_int = -302; +pub const EMIG_BAD_ID: c_int = -303; +pub const EMIG_BAD_ARGUMENTS: c_int = -304; +pub const EMIG_NO_REPLY: c_int = -305; +pub const EMIG_EXCEPTION: c_int = -306; +pub const EMIG_ARRAY_TOO_LARGE: c_int = -307; +pub const EMIG_SERVER_DIED: c_int = -308; +pub const EMIG_DESTROY_REQUEST: c_int = -309; +pub const ED_IO_ERROR: c_int = 2500; +pub const ED_WOULD_BLOCK: c_int = 2501; +pub const ED_NO_SUCH_DEVICE: c_int = 2502; +pub const ED_ALREADY_OPEN: c_int = 2503; +pub const ED_DEVICE_DOWN: c_int = 2504; +pub const ED_INVALID_OPERATION: c_int = 2505; +pub const ED_INVALID_RECNUM: c_int = 2506; +pub const ED_INVALID_SIZE: c_int = 2507; +pub const ED_NO_MEMORY: c_int = 2508; +pub const ED_READ_ONLY: c_int = 2509; +pub const _HURD_ERRNOS: usize = 122; + +// sched.h +pub const SCHED_OTHER: c_int = 0; +pub const SCHED_FIFO: c_int = 1; +pub const SCHED_RR: c_int = 2; +pub const _BITS_TYPES_STRUCT_SCHED_PARAM: usize = 1; +pub const __CPU_SETSIZE: usize = 1024; +pub const CPU_SETSIZE: usize = 1024; + +// pthread.h +pub const PTHREAD_SPINLOCK_INITIALIZER: c_int = 0; +pub const PTHREAD_CANCEL_DISABLE: c_int = 0; +pub const PTHREAD_CANCEL_ENABLE: c_int = 1; +pub const PTHREAD_CANCEL_DEFERRED: c_int = 0; +pub const PTHREAD_CANCEL_ASYNCHRONOUS: c_int = 1; +pub const PTHREAD_BARRIER_SERIAL_THREAD: c_int = -1; + +// netinet/tcp.h +pub const TCP_NODELAY: c_int = 1; +pub const TCP_MAXSEG: c_int = 2; +pub const TCP_CORK: c_int = 3; +pub const TCP_KEEPIDLE: c_int = 4; +pub const TCP_KEEPINTVL: c_int = 5; +pub const TCP_KEEPCNT: c_int = 6; +pub const TCP_SYNCNT: c_int = 7; +pub const TCP_LINGER2: c_int = 8; +pub const TCP_DEFER_ACCEPT: c_int = 9; +pub const TCP_WINDOW_CLAMP: c_int = 10; +pub const TCP_INFO: c_int = 11; +pub const TCP_QUICKACK: c_int = 12; +pub const TCP_CONGESTION: c_int = 13; +pub const TCP_MD5SIG: c_int = 14; +pub const TCP_COOKIE_TRANSACTIONS: c_int = 15; +pub const TCP_THIN_LINEAR_TIMEOUTS: c_int = 16; +pub const TCP_THIN_DUPACK: c_int = 17; +pub const TCP_USER_TIMEOUT: c_int = 18; +pub const TCP_REPAIR: c_int = 19; +pub const TCP_REPAIR_QUEUE: c_int = 20; +pub const TCP_QUEUE_SEQ: c_int = 21; +pub const TCP_REPAIR_OPTIONS: c_int = 22; +pub const TCP_FASTOPEN: c_int = 23; +pub const TCP_TIMESTAMP: c_int = 24; +pub const TCP_NOTSENT_LOWAT: c_int = 25; +pub const TCP_CC_INFO: c_int = 26; +pub const TCP_SAVE_SYN: c_int = 27; +pub const TCP_SAVED_SYN: c_int = 28; +pub const TCP_REPAIR_WINDOW: c_int = 29; +pub const TCP_FASTOPEN_CONNECT: c_int = 30; +pub const TCP_ULP: c_int = 31; +pub const TCP_MD5SIG_EXT: c_int = 32; +pub const TCP_FASTOPEN_KEY: c_int = 33; +pub const TCP_FASTOPEN_NO_COOKIE: c_int = 34; +pub const TCP_ZEROCOPY_RECEIVE: c_int = 35; +pub const TCP_INQ: c_int = 36; +pub const TCP_CM_INQ: c_int = 36; +pub const TCP_TX_DELAY: c_int = 37; +pub const TCP_REPAIR_ON: c_int = 1; +pub const TCP_REPAIR_OFF: c_int = 0; +pub const TCP_REPAIR_OFF_NO_WP: c_int = -1; + +// stdint.h +pub const INT8_MIN: i8 = -128; +pub const INT16_MIN: i16 = -32768; +pub const INT32_MIN: i32 = -2147483648; +pub const INT8_MAX: i8 = 127; +pub const INT16_MAX: i16 = 32767; +pub const INT32_MAX: i32 = 2147483647; +pub const UINT8_MAX: u8 = 255; +pub const UINT16_MAX: u16 = 65535; +pub const UINT32_MAX: u32 = 4294967295; +pub const INT_LEAST8_MIN: int_least8_t = -128; +pub const INT_LEAST16_MIN: int_least16_t = -32768; +pub const INT_LEAST32_MIN: int_least32_t = -2147483648; +pub const INT_LEAST8_MAX: int_least8_t = 127; +pub const INT_LEAST16_MAX: int_least16_t = 32767; +pub const INT_LEAST32_MAX: int_least32_t = 2147483647; +pub const UINT_LEAST8_MAX: uint_least8_t = 255; +pub const UINT_LEAST16_MAX: uint_least16_t = 65535; +pub const UINT_LEAST32_MAX: uint_least32_t = 4294967295; +pub const INT_FAST8_MIN: int_fast8_t = -128; +pub const INT_FAST16_MIN: int_fast16_t = -2147483648; +pub const INT_FAST32_MIN: int_fast32_t = -2147483648; +pub const INT_FAST8_MAX: int_fast8_t = 127; +pub const INT_FAST16_MAX: int_fast16_t = 2147483647; +pub const INT_FAST32_MAX: int_fast32_t = 2147483647; +pub const UINT_FAST8_MAX: uint_fast8_t = 255; +pub const UINT_FAST16_MAX: uint_fast16_t = 4294967295; +pub const UINT_FAST32_MAX: uint_fast32_t = 4294967295; +pub const INTPTR_MIN: __intptr_t = -2147483648; +pub const INTPTR_MAX: __intptr_t = 2147483647; +pub const UINTPTR_MAX: usize = 4294967295; +pub const PTRDIFF_MIN: __ptrdiff_t = -2147483648; +pub const PTRDIFF_MAX: __ptrdiff_t = 2147483647; +pub const SIG_ATOMIC_MIN: __sig_atomic_t = -2147483648; +pub const SIG_ATOMIC_MAX: __sig_atomic_t = 2147483647; +pub const SIZE_MAX: usize = 4294967295; +pub const WINT_MIN: wint_t = 0; +pub const WINT_MAX: wint_t = 4294967295; +pub const INT8_WIDTH: usize = 8; +pub const UINT8_WIDTH: usize = 8; +pub const INT16_WIDTH: usize = 16; +pub const UINT16_WIDTH: usize = 16; +pub const INT32_WIDTH: usize = 32; +pub const UINT32_WIDTH: usize = 32; +pub const INT64_WIDTH: usize = 64; +pub const UINT64_WIDTH: usize = 64; +pub const INT_LEAST8_WIDTH: usize = 8; +pub const UINT_LEAST8_WIDTH: usize = 8; +pub const INT_LEAST16_WIDTH: usize = 16; +pub const UINT_LEAST16_WIDTH: usize = 16; +pub const INT_LEAST32_WIDTH: usize = 32; +pub const UINT_LEAST32_WIDTH: usize = 32; +pub const INT_LEAST64_WIDTH: usize = 64; +pub const UINT_LEAST64_WIDTH: usize = 64; +pub const INT_FAST8_WIDTH: usize = 8; +pub const UINT_FAST8_WIDTH: usize = 8; +pub const INT_FAST16_WIDTH: usize = 32; +pub const UINT_FAST16_WIDTH: usize = 32; +pub const INT_FAST32_WIDTH: usize = 32; +pub const UINT_FAST32_WIDTH: usize = 32; +pub const INT_FAST64_WIDTH: usize = 64; +pub const UINT_FAST64_WIDTH: usize = 64; +pub const INTPTR_WIDTH: usize = 32; +pub const UINTPTR_WIDTH: usize = 32; +pub const INTMAX_WIDTH: usize = 64; +pub const UINTMAX_WIDTH: usize = 64; +pub const PTRDIFF_WIDTH: usize = 32; +pub const SIG_ATOMIC_WIDTH: usize = 32; +pub const SIZE_WIDTH: usize = 32; +pub const WCHAR_WIDTH: usize = 32; +pub const WINT_WIDTH: usize = 32; + +pub const TH_FIN: u8 = 1; +pub const TH_SYN: u8 = 2; +pub const TH_RST: u8 = 4; +pub const TH_PUSH: u8 = 8; +pub const TH_ACK: u8 = 16; +pub const TH_URG: u8 = 32; +pub const TCPOPT_EOL: u8 = 0; +pub const TCPOPT_NOP: u8 = 1; +pub const TCPOPT_MAXSEG: u8 = 2; +pub const TCPOLEN_MAXSEG: u8 = 4; +pub const TCPOPT_WINDOW: u8 = 3; +pub const TCPOLEN_WINDOW: u8 = 3; +pub const TCPOPT_SACK_PERMITTED: u8 = 4; +pub const TCPOLEN_SACK_PERMITTED: u8 = 2; +pub const TCPOPT_SACK: u8 = 5; +pub const TCPOPT_TIMESTAMP: u8 = 8; +pub const TCPOLEN_TIMESTAMP: u8 = 10; +pub const TCPOLEN_TSTAMP_APPA: u8 = 12; +pub const TCPOPT_TSTAMP_HDR: u32 = 16844810; +pub const TCP_MSS: usize = 512; +pub const TCP_MAXWIN: usize = 65535; +pub const TCP_MAX_WINSHIFT: usize = 14; +pub const TCPI_OPT_TIMESTAMPS: u8 = 1; +pub const TCPI_OPT_SACK: u8 = 2; +pub const TCPI_OPT_WSCALE: u8 = 4; +pub const TCPI_OPT_ECN: u8 = 8; +pub const TCPI_OPT_ECN_SEEN: u8 = 16; +pub const TCPI_OPT_SYN_DATA: u8 = 32; +pub const TCP_MD5SIG_MAXKEYLEN: usize = 80; +pub const TCP_MD5SIG_FLAG_PREFIX: usize = 1; +pub const TCP_COOKIE_MIN: usize = 8; +pub const TCP_COOKIE_MAX: usize = 16; +pub const TCP_COOKIE_PAIR_SIZE: usize = 32; +pub const TCP_COOKIE_IN_ALWAYS: c_int = 1; +pub const TCP_COOKIE_OUT_NEVER: c_int = 2; +pub const TCP_S_DATA_IN: c_int = 4; +pub const TCP_S_DATA_OUT: c_int = 8; +pub const TCP_MSS_DEFAULT: usize = 536; +pub const TCP_MSS_DESIRED: usize = 1220; + +// sys/wait.h +pub const WCOREFLAG: c_int = 128; +pub const WAIT_ANY: pid_t = -1; +pub const WAIT_MYPGRP: pid_t = 0; + +// sys/file.h +pub const LOCK_SH: c_int = 1; +pub const LOCK_EX: c_int = 2; +pub const LOCK_UN: c_int = 8; +pub const LOCK_NB: c_int = 4; + +// sys/mman.h +pub const PROT_NONE: c_int = 0; +pub const PROT_READ: c_int = 4; +pub const PROT_WRITE: c_int = 2; +pub const PROT_EXEC: c_int = 1; +pub const MAP_FILE: c_int = 1; +pub const MAP_ANON: c_int = 2; +pub const MAP_ANONYMOUS: c_int = MAP_ANON; +pub const MAP_TYPE: c_int = 15; +pub const MAP_COPY: c_int = 32; +pub const MAP_SHARED: c_int = 16; +pub const MAP_PRIVATE: c_int = 0; +pub const MAP_FIXED: c_int = 256; +pub const MAP_NOEXTEND: c_int = 512; +pub const MAP_HASSEMAPHORE: c_int = 1024; +pub const MAP_INHERIT: c_int = 2048; +pub const MAP_32BIT: c_int = 4096; +pub const MAP_EXCL: c_int = 16384; +pub const MAP_FAILED: *mut c_void = !0 as *mut c_void; +pub const MADV_NORMAL: c_int = 0; +pub const MADV_RANDOM: c_int = 1; +pub const MADV_SEQUENTIAL: c_int = 2; +pub const MADV_WILLNEED: c_int = 3; +pub const MADV_DONTNEED: c_int = 4; +pub const POSIX_MADV_NORMAL: c_int = 0; +pub const POSIX_MADV_RANDOM: c_int = 1; +pub const POSIX_MADV_SEQUENTIAL: c_int = 2; +pub const POSIX_MADV_WILLNEED: c_int = 3; +pub const POSIX_MADV_WONTNEED: c_int = 4; + +pub const MS_ASYNC: c_int = 1; +pub const MS_SYNC: c_int = 0; +pub const MS_INVALIDATE: c_int = 2; +pub const MREMAP_MAYMOVE: c_int = 1; +pub const MREMAP_FIXED: c_int = 2; +pub const MCL_CURRENT: c_int = 0x0001; +pub const MCL_FUTURE: c_int = 0x0002; + +// sys/xattr.h +pub const XATTR_CREATE: c_int = 0x1; +pub const XATTR_REPLACE: c_int = 0x2; + +// spawn.h +pub const POSIX_SPAWN_USEVFORK: c_int = 64; +pub const POSIX_SPAWN_SETSID: c_int = 128; + +// sys/syslog.h +pub const LOG_CRON: c_int = 9 << 3; +pub const LOG_AUTHPRIV: c_int = 10 << 3; +pub const LOG_FTP: c_int = 11 << 3; +pub const LOG_PERROR: c_int = 0x20; + +// net/if.h +pub const IFF_UP: c_int = 0x1; +pub const IFF_BROADCAST: c_int = 0x2; +pub const IFF_DEBUG: c_int = 0x4; +pub const IFF_LOOPBACK: c_int = 0x8; +pub const IFF_POINTOPOINT: c_int = 0x10; +pub const IFF_NOTRAILERS: c_int = 0x20; +pub const IFF_RUNNING: c_int = 0x40; +pub const IFF_NOARP: c_int = 0x80; +pub const IFF_PROMISC: c_int = 0x100; +pub const IFF_ALLMULTI: c_int = 0x200; +pub const IFF_MASTER: c_int = 0x400; +pub const IFF_SLAVE: c_int = 0x800; +pub const IFF_MULTICAST: c_int = 0x1000; +pub const IFF_PORTSEL: c_int = 0x2000; +pub const IFF_AUTOMEDIA: c_int = 0x4000; +pub const IFF_DYNAMIC: c_int = 0x8000; + +// random.h +pub const GRND_NONBLOCK: c_uint = 1; +pub const GRND_RANDOM: c_uint = 2; +pub const GRND_INSECURE: c_uint = 4; + +pub const _PC_LINK_MAX: c_int = 0; +pub const _PC_MAX_CANON: c_int = 1; +pub const _PC_MAX_INPUT: c_int = 2; +pub const _PC_NAME_MAX: c_int = 3; +pub const _PC_PATH_MAX: c_int = 4; +pub const _PC_PIPE_BUF: c_int = 5; +pub const _PC_CHOWN_RESTRICTED: c_int = 6; +pub const _PC_NO_TRUNC: c_int = 7; +pub const _PC_VDISABLE: c_int = 8; +pub const _PC_SYNC_IO: c_int = 9; +pub const _PC_ASYNC_IO: c_int = 10; +pub const _PC_PRIO_IO: c_int = 11; +pub const _PC_SOCK_MAXBUF: c_int = 12; +pub const _PC_FILESIZEBITS: c_int = 13; +pub const _PC_REC_INCR_XFER_SIZE: c_int = 14; +pub const _PC_REC_MAX_XFER_SIZE: c_int = 15; +pub const _PC_REC_MIN_XFER_SIZE: c_int = 16; +pub const _PC_REC_XFER_ALIGN: c_int = 17; +pub const _PC_ALLOC_SIZE_MIN: c_int = 18; +pub const _PC_SYMLINK_MAX: c_int = 19; +pub const _PC_2_SYMLINKS: c_int = 20; +pub const _SC_ARG_MAX: c_int = 0; +pub const _SC_CHILD_MAX: c_int = 1; +pub const _SC_CLK_TCK: c_int = 2; +pub const _SC_NGROUPS_MAX: c_int = 3; +pub const _SC_OPEN_MAX: c_int = 4; +pub const _SC_STREAM_MAX: c_int = 5; +pub const _SC_TZNAME_MAX: c_int = 6; +pub const _SC_JOB_CONTROL: c_int = 7; +pub const _SC_SAVED_IDS: c_int = 8; +pub const _SC_REALTIME_SIGNALS: c_int = 9; +pub const _SC_PRIORITY_SCHEDULING: c_int = 10; +pub const _SC_TIMERS: c_int = 11; +pub const _SC_ASYNCHRONOUS_IO: c_int = 12; +pub const _SC_PRIORITIZED_IO: c_int = 13; +pub const _SC_SYNCHRONIZED_IO: c_int = 14; +pub const _SC_FSYNC: c_int = 15; +pub const _SC_MAPPED_FILES: c_int = 16; +pub const _SC_MEMLOCK: c_int = 17; +pub const _SC_MEMLOCK_RANGE: c_int = 18; +pub const _SC_MEMORY_PROTECTION: c_int = 19; +pub const _SC_MESSAGE_PASSING: c_int = 20; +pub const _SC_SEMAPHORES: c_int = 21; +pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 22; +pub const _SC_AIO_LISTIO_MAX: c_int = 23; +pub const _SC_AIO_MAX: c_int = 24; +pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 25; +pub const _SC_DELAYTIMER_MAX: c_int = 26; +pub const _SC_MQ_OPEN_MAX: c_int = 27; +pub const _SC_MQ_PRIO_MAX: c_int = 28; +pub const _SC_VERSION: c_int = 29; +pub const _SC_PAGESIZE: c_int = 30; +pub const _SC_PAGE_SIZE: c_int = 30; +pub const _SC_RTSIG_MAX: c_int = 31; +pub const _SC_SEM_NSEMS_MAX: c_int = 32; +pub const _SC_SEM_VALUE_MAX: c_int = 33; +pub const _SC_SIGQUEUE_MAX: c_int = 34; +pub const _SC_TIMER_MAX: c_int = 35; +pub const _SC_BC_BASE_MAX: c_int = 36; +pub const _SC_BC_DIM_MAX: c_int = 37; +pub const _SC_BC_SCALE_MAX: c_int = 38; +pub const _SC_BC_STRING_MAX: c_int = 39; +pub const _SC_COLL_WEIGHTS_MAX: c_int = 40; +pub const _SC_EQUIV_CLASS_MAX: c_int = 41; +pub const _SC_EXPR_NEST_MAX: c_int = 42; +pub const _SC_LINE_MAX: c_int = 43; +pub const _SC_RE_DUP_MAX: c_int = 44; +pub const _SC_CHARCLASS_NAME_MAX: c_int = 45; +pub const _SC_2_VERSION: c_int = 46; +pub const _SC_2_C_BIND: c_int = 47; +pub const _SC_2_C_DEV: c_int = 48; +pub const _SC_2_FORT_DEV: c_int = 49; +pub const _SC_2_FORT_RUN: c_int = 50; +pub const _SC_2_SW_DEV: c_int = 51; +pub const _SC_2_LOCALEDEF: c_int = 52; +pub const _SC_PII: c_int = 53; +pub const _SC_PII_XTI: c_int = 54; +pub const _SC_PII_SOCKET: c_int = 55; +pub const _SC_PII_INTERNET: c_int = 56; +pub const _SC_PII_OSI: c_int = 57; +pub const _SC_POLL: c_int = 58; +pub const _SC_SELECT: c_int = 59; +pub const _SC_UIO_MAXIOV: c_int = 60; +pub const _SC_IOV_MAX: c_int = 60; +pub const _SC_PII_INTERNET_STREAM: c_int = 61; +pub const _SC_PII_INTERNET_DGRAM: c_int = 62; +pub const _SC_PII_OSI_COTS: c_int = 63; +pub const _SC_PII_OSI_CLTS: c_int = 64; +pub const _SC_PII_OSI_M: c_int = 65; +pub const _SC_T_IOV_MAX: c_int = 66; +pub const _SC_THREADS: c_int = 67; +pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 68; +pub const _SC_GETGR_R_SIZE_MAX: c_int = 69; +pub const _SC_GETPW_R_SIZE_MAX: c_int = 70; +pub const _SC_LOGIN_NAME_MAX: c_int = 71; +pub const _SC_TTY_NAME_MAX: c_int = 72; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 73; +pub const _SC_THREAD_KEYS_MAX: c_int = 74; +pub const _SC_THREAD_STACK_MIN: c_int = 75; +pub const _SC_THREAD_THREADS_MAX: c_int = 76; +pub const _SC_THREAD_ATTR_STACKADDR: c_int = 77; +pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 78; +pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 79; +pub const _SC_THREAD_PRIO_INHERIT: c_int = 80; +pub const _SC_THREAD_PRIO_PROTECT: c_int = 81; +pub const _SC_THREAD_PROCESS_SHARED: c_int = 82; +pub const _SC_NPROCESSORS_CONF: c_int = 83; +pub const _SC_NPROCESSORS_ONLN: c_int = 84; +pub const _SC_PHYS_PAGES: c_int = 85; +pub const _SC_AVPHYS_PAGES: c_int = 86; +pub const _SC_ATEXIT_MAX: c_int = 87; +pub const _SC_PASS_MAX: c_int = 88; +pub const _SC_XOPEN_VERSION: c_int = 89; +pub const _SC_XOPEN_XCU_VERSION: c_int = 90; +pub const _SC_XOPEN_UNIX: c_int = 91; +pub const _SC_XOPEN_CRYPT: c_int = 92; +pub const _SC_XOPEN_ENH_I18N: c_int = 93; +pub const _SC_XOPEN_SHM: c_int = 94; +pub const _SC_2_CHAR_TERM: c_int = 95; +pub const _SC_2_C_VERSION: c_int = 96; +pub const _SC_2_UPE: c_int = 97; +pub const _SC_XOPEN_XPG2: c_int = 98; +pub const _SC_XOPEN_XPG3: c_int = 99; +pub const _SC_XOPEN_XPG4: c_int = 100; +pub const _SC_CHAR_BIT: c_int = 101; +pub const _SC_CHAR_MAX: c_int = 102; +pub const _SC_CHAR_MIN: c_int = 103; +pub const _SC_INT_MAX: c_int = 104; +pub const _SC_INT_MIN: c_int = 105; +pub const _SC_LONG_BIT: c_int = 106; +pub const _SC_WORD_BIT: c_int = 107; +pub const _SC_MB_LEN_MAX: c_int = 108; +pub const _SC_NZERO: c_int = 109; +pub const _SC_SSIZE_MAX: c_int = 110; +pub const _SC_SCHAR_MAX: c_int = 111; +pub const _SC_SCHAR_MIN: c_int = 112; +pub const _SC_SHRT_MAX: c_int = 113; +pub const _SC_SHRT_MIN: c_int = 114; +pub const _SC_UCHAR_MAX: c_int = 115; +pub const _SC_UINT_MAX: c_int = 116; +pub const _SC_ULONG_MAX: c_int = 117; +pub const _SC_USHRT_MAX: c_int = 118; +pub const _SC_NL_ARGMAX: c_int = 119; +pub const _SC_NL_LANGMAX: c_int = 120; +pub const _SC_NL_MSGMAX: c_int = 121; +pub const _SC_NL_NMAX: c_int = 122; +pub const _SC_NL_SETMAX: c_int = 123; +pub const _SC_NL_TEXTMAX: c_int = 124; +pub const _SC_XBS5_ILP32_OFF32: c_int = 125; +pub const _SC_XBS5_ILP32_OFFBIG: c_int = 126; +pub const _SC_XBS5_LP64_OFF64: c_int = 127; +pub const _SC_XBS5_LPBIG_OFFBIG: c_int = 128; +pub const _SC_XOPEN_LEGACY: c_int = 129; +pub const _SC_XOPEN_REALTIME: c_int = 130; +pub const _SC_XOPEN_REALTIME_THREADS: c_int = 131; +pub const _SC_ADVISORY_INFO: c_int = 132; +pub const _SC_BARRIERS: c_int = 133; +pub const _SC_BASE: c_int = 134; +pub const _SC_C_LANG_SUPPORT: c_int = 135; +pub const _SC_C_LANG_SUPPORT_R: c_int = 136; +pub const _SC_CLOCK_SELECTION: c_int = 137; +pub const _SC_CPUTIME: c_int = 138; +pub const _SC_THREAD_CPUTIME: c_int = 139; +pub const _SC_DEVICE_IO: c_int = 140; +pub const _SC_DEVICE_SPECIFIC: c_int = 141; +pub const _SC_DEVICE_SPECIFIC_R: c_int = 142; +pub const _SC_FD_MGMT: c_int = 143; +pub const _SC_FIFO: c_int = 144; +pub const _SC_PIPE: c_int = 145; +pub const _SC_FILE_ATTRIBUTES: c_int = 146; +pub const _SC_FILE_LOCKING: c_int = 147; +pub const _SC_FILE_SYSTEM: c_int = 148; +pub const _SC_MONOTONIC_CLOCK: c_int = 149; +pub const _SC_MULTI_PROCESS: c_int = 150; +pub const _SC_SINGLE_PROCESS: c_int = 151; +pub const _SC_NETWORKING: c_int = 152; +pub const _SC_READER_WRITER_LOCKS: c_int = 153; +pub const _SC_SPIN_LOCKS: c_int = 154; +pub const _SC_REGEXP: c_int = 155; +pub const _SC_REGEX_VERSION: c_int = 156; +pub const _SC_SHELL: c_int = 157; +pub const _SC_SIGNALS: c_int = 158; +pub const _SC_SPAWN: c_int = 159; +pub const _SC_SPORADIC_SERVER: c_int = 160; +pub const _SC_THREAD_SPORADIC_SERVER: c_int = 161; +pub const _SC_SYSTEM_DATABASE: c_int = 162; +pub const _SC_SYSTEM_DATABASE_R: c_int = 163; +pub const _SC_TIMEOUTS: c_int = 164; +pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 165; +pub const _SC_USER_GROUPS: c_int = 166; +pub const _SC_USER_GROUPS_R: c_int = 167; +pub const _SC_2_PBS: c_int = 168; +pub const _SC_2_PBS_ACCOUNTING: c_int = 169; +pub const _SC_2_PBS_LOCATE: c_int = 170; +pub const _SC_2_PBS_MESSAGE: c_int = 171; +pub const _SC_2_PBS_TRACK: c_int = 172; +pub const _SC_SYMLOOP_MAX: c_int = 173; +pub const _SC_STREAMS: c_int = 174; +pub const _SC_2_PBS_CHECKPOINT: c_int = 175; +pub const _SC_V6_ILP32_OFF32: c_int = 176; +pub const _SC_V6_ILP32_OFFBIG: c_int = 177; +pub const _SC_V6_LP64_OFF64: c_int = 178; +pub const _SC_V6_LPBIG_OFFBIG: c_int = 179; +pub const _SC_HOST_NAME_MAX: c_int = 180; +pub const _SC_TRACE: c_int = 181; +pub const _SC_TRACE_EVENT_FILTER: c_int = 182; +pub const _SC_TRACE_INHERIT: c_int = 183; +pub const _SC_TRACE_LOG: c_int = 184; +pub const _SC_LEVEL1_ICACHE_SIZE: c_int = 185; +pub const _SC_LEVEL1_ICACHE_ASSOC: c_int = 186; +pub const _SC_LEVEL1_ICACHE_LINESIZE: c_int = 187; +pub const _SC_LEVEL1_DCACHE_SIZE: c_int = 188; +pub const _SC_LEVEL1_DCACHE_ASSOC: c_int = 189; +pub const _SC_LEVEL1_DCACHE_LINESIZE: c_int = 190; +pub const _SC_LEVEL2_CACHE_SIZE: c_int = 191; +pub const _SC_LEVEL2_CACHE_ASSOC: c_int = 192; +pub const _SC_LEVEL2_CACHE_LINESIZE: c_int = 193; +pub const _SC_LEVEL3_CACHE_SIZE: c_int = 194; +pub const _SC_LEVEL3_CACHE_ASSOC: c_int = 195; +pub const _SC_LEVEL3_CACHE_LINESIZE: c_int = 196; +pub const _SC_LEVEL4_CACHE_SIZE: c_int = 197; +pub const _SC_LEVEL4_CACHE_ASSOC: c_int = 198; +pub const _SC_LEVEL4_CACHE_LINESIZE: c_int = 199; +pub const _SC_IPV6: c_int = 235; +pub const _SC_RAW_SOCKETS: c_int = 236; +pub const _SC_V7_ILP32_OFF32: c_int = 237; +pub const _SC_V7_ILP32_OFFBIG: c_int = 238; +pub const _SC_V7_LP64_OFF64: c_int = 239; +pub const _SC_V7_LPBIG_OFFBIG: c_int = 240; +pub const _SC_SS_REPL_MAX: c_int = 241; +pub const _SC_TRACE_EVENT_NAME_MAX: c_int = 242; +pub const _SC_TRACE_NAME_MAX: c_int = 243; +pub const _SC_TRACE_SYS_MAX: c_int = 244; +pub const _SC_TRACE_USER_EVENT_MAX: c_int = 245; +pub const _SC_XOPEN_STREAMS: c_int = 246; +pub const _SC_THREAD_ROBUST_PRIO_INHERIT: c_int = 247; +pub const _SC_THREAD_ROBUST_PRIO_PROTECT: c_int = 248; +pub const _SC_MINSIGSTKSZ: c_int = 249; +pub const _SC_SIGSTKSZ: c_int = 250; + +pub const _CS_PATH: c_int = 0; +pub const _CS_V6_WIDTH_RESTRICTED_ENVS: c_int = 1; +pub const _CS_GNU_LIBC_VERSION: c_int = 2; +pub const _CS_GNU_LIBPTHREAD_VERSION: c_int = 3; +pub const _CS_V5_WIDTH_RESTRICTED_ENVS: c_int = 4; +pub const _CS_V7_WIDTH_RESTRICTED_ENVS: c_int = 5; +pub const _CS_LFS_CFLAGS: c_int = 1000; +pub const _CS_LFS_LDFLAGS: c_int = 1001; +pub const _CS_LFS_LIBS: c_int = 1002; +pub const _CS_LFS_LINTFLAGS: c_int = 1003; +pub const _CS_LFS64_CFLAGS: c_int = 1004; +pub const _CS_LFS64_LDFLAGS: c_int = 1005; +pub const _CS_LFS64_LIBS: c_int = 1006; +pub const _CS_LFS64_LINTFLAGS: c_int = 1007; +pub const _CS_XBS5_ILP32_OFF32_CFLAGS: c_int = 1100; +pub const _CS_XBS5_ILP32_OFF32_LDFLAGS: c_int = 1101; +pub const _CS_XBS5_ILP32_OFF32_LIBS: c_int = 1102; +pub const _CS_XBS5_ILP32_OFF32_LINTFLAGS: c_int = 1103; +pub const _CS_XBS5_ILP32_OFFBIG_CFLAGS: c_int = 1104; +pub const _CS_XBS5_ILP32_OFFBIG_LDFLAGS: c_int = 1105; +pub const _CS_XBS5_ILP32_OFFBIG_LIBS: c_int = 1106; +pub const _CS_XBS5_ILP32_OFFBIG_LINTFLAGS: c_int = 1107; +pub const _CS_XBS5_LP64_OFF64_CFLAGS: c_int = 1108; +pub const _CS_XBS5_LP64_OFF64_LDFLAGS: c_int = 1109; +pub const _CS_XBS5_LP64_OFF64_LIBS: c_int = 1110; +pub const _CS_XBS5_LP64_OFF64_LINTFLAGS: c_int = 1111; +pub const _CS_XBS5_LPBIG_OFFBIG_CFLAGS: c_int = 1112; +pub const _CS_XBS5_LPBIG_OFFBIG_LDFLAGS: c_int = 1113; +pub const _CS_XBS5_LPBIG_OFFBIG_LIBS: c_int = 1114; +pub const _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS: c_int = 1115; +pub const _CS_POSIX_V6_ILP32_OFF32_CFLAGS: c_int = 1116; +pub const _CS_POSIX_V6_ILP32_OFF32_LDFLAGS: c_int = 1117; +pub const _CS_POSIX_V6_ILP32_OFF32_LIBS: c_int = 1118; +pub const _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS: c_int = 1119; +pub const _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS: c_int = 1120; +pub const _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS: c_int = 1121; +pub const _CS_POSIX_V6_ILP32_OFFBIG_LIBS: c_int = 1122; +pub const _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS: c_int = 1123; +pub const _CS_POSIX_V6_LP64_OFF64_CFLAGS: c_int = 1124; +pub const _CS_POSIX_V6_LP64_OFF64_LDFLAGS: c_int = 1125; +pub const _CS_POSIX_V6_LP64_OFF64_LIBS: c_int = 1126; +pub const _CS_POSIX_V6_LP64_OFF64_LINTFLAGS: c_int = 1127; +pub const _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS: c_int = 1128; +pub const _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS: c_int = 1129; +pub const _CS_POSIX_V6_LPBIG_OFFBIG_LIBS: c_int = 1130; +pub const _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS: c_int = 1131; +pub const _CS_POSIX_V7_ILP32_OFF32_CFLAGS: c_int = 1132; +pub const _CS_POSIX_V7_ILP32_OFF32_LDFLAGS: c_int = 1133; +pub const _CS_POSIX_V7_ILP32_OFF32_LIBS: c_int = 1134; +pub const _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS: c_int = 1135; +pub const _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS: c_int = 1136; +pub const _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS: c_int = 1137; +pub const _CS_POSIX_V7_ILP32_OFFBIG_LIBS: c_int = 1138; +pub const _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS: c_int = 1139; +pub const _CS_POSIX_V7_LP64_OFF64_CFLAGS: c_int = 1140; +pub const _CS_POSIX_V7_LP64_OFF64_LDFLAGS: c_int = 1141; +pub const _CS_POSIX_V7_LP64_OFF64_LIBS: c_int = 1142; +pub const _CS_POSIX_V7_LP64_OFF64_LINTFLAGS: c_int = 1143; +pub const _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS: c_int = 1144; +pub const _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS: c_int = 1145; +pub const _CS_POSIX_V7_LPBIG_OFFBIG_LIBS: c_int = 1146; +pub const _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS: c_int = 1147; +pub const _CS_V6_ENV: c_int = 1148; +pub const _CS_V7_ENV: c_int = 1149; + +pub const PTHREAD_PROCESS_PRIVATE: __pthread_process_shared = 0; +pub const PTHREAD_PROCESS_SHARED: __pthread_process_shared = 1; + +pub const PTHREAD_EXPLICIT_SCHED: __pthread_inheritsched = 0; +pub const PTHREAD_INHERIT_SCHED: __pthread_inheritsched = 1; + +pub const PTHREAD_SCOPE_SYSTEM: __pthread_contentionscope = 0; +pub const PTHREAD_SCOPE_PROCESS: __pthread_contentionscope = 1; + +pub const PTHREAD_CREATE_JOINABLE: __pthread_detachstate = 0; +pub const PTHREAD_CREATE_DETACHED: __pthread_detachstate = 1; + +pub const PTHREAD_PRIO_NONE: __pthread_mutex_protocol = 0; +pub const PTHREAD_PRIO_INHERIT: __pthread_mutex_protocol = 1; +pub const PTHREAD_PRIO_PROTECT: __pthread_mutex_protocol = 2; + +pub const PTHREAD_MUTEX_TIMED: __pthread_mutex_type = 0; +pub const PTHREAD_MUTEX_ERRORCHECK: __pthread_mutex_type = 1; +pub const PTHREAD_MUTEX_RECURSIVE: __pthread_mutex_type = 2; + +pub const PTHREAD_MUTEX_STALLED: __pthread_mutex_robustness = 0; +pub const PTHREAD_MUTEX_ROBUST: __pthread_mutex_robustness = 256; + +pub const RLIMIT_CPU: crate::__rlimit_resource_t = 0; +pub const RLIMIT_FSIZE: crate::__rlimit_resource_t = 1; +pub const RLIMIT_DATA: crate::__rlimit_resource_t = 2; +pub const RLIMIT_STACK: crate::__rlimit_resource_t = 3; +pub const RLIMIT_CORE: crate::__rlimit_resource_t = 4; +pub const RLIMIT_RSS: crate::__rlimit_resource_t = 5; +pub const RLIMIT_MEMLOCK: crate::__rlimit_resource_t = 6; +pub const RLIMIT_NPROC: crate::__rlimit_resource_t = 7; +pub const RLIMIT_OFILE: crate::__rlimit_resource_t = 8; +pub const RLIMIT_NOFILE: crate::__rlimit_resource_t = 8; +pub const RLIMIT_SBSIZE: crate::__rlimit_resource_t = 9; +pub const RLIMIT_AS: crate::__rlimit_resource_t = 10; +pub const RLIMIT_VMEM: crate::__rlimit_resource_t = 10; +pub const RLIMIT_NLIMITS: crate::__rlimit_resource_t = 11; +pub const RLIM_NLIMITS: crate::__rlimit_resource_t = 11; + +pub const RUSAGE_SELF: __rusage_who = 0; +pub const RUSAGE_CHILDREN: __rusage_who = -1; + +pub const PRIO_PROCESS: __priority_which = 0; +pub const PRIO_PGRP: __priority_which = 1; +pub const PRIO_USER: __priority_which = 2; + +pub const __UT_LINESIZE: usize = 32; +pub const __UT_NAMESIZE: usize = 32; +pub const __UT_HOSTSIZE: usize = 256; + +pub const SOCK_STREAM: c_int = 1; +pub const SOCK_DGRAM: c_int = 2; +pub const SOCK_RAW: c_int = 3; +pub const SOCK_RDM: c_int = 4; +pub const SOCK_SEQPACKET: c_int = 5; +pub const SOCK_CLOEXEC: c_int = 4194304; +pub const SOCK_NONBLOCK: c_int = 2048; + +pub const MSG_OOB: c_int = 1; +pub const MSG_PEEK: c_int = 2; +pub const MSG_DONTROUTE: c_int = 4; +pub const MSG_EOR: c_int = 8; +pub const MSG_TRUNC: c_int = 16; +pub const MSG_CTRUNC: c_int = 32; +pub const MSG_WAITALL: c_int = 64; +pub const MSG_DONTWAIT: c_int = 128; +pub const MSG_NOSIGNAL: c_int = 1024; +pub const MSG_CMSG_CLOEXEC: c_int = 0x40000000; + +pub const SCM_RIGHTS: c_int = 1; +pub const SCM_TIMESTAMP: c_int = 2; +pub const SCM_CREDS: c_int = 3; + +pub const SO_DEBUG: c_int = 1; +pub const SO_ACCEPTCONN: c_int = 2; +pub const SO_REUSEADDR: c_int = 4; +pub const SO_KEEPALIVE: c_int = 8; +pub const SO_DONTROUTE: c_int = 16; +pub const SO_BROADCAST: c_int = 32; +pub const SO_USELOOPBACK: c_int = 64; +pub const SO_LINGER: c_int = 128; +pub const SO_OOBINLINE: c_int = 256; +pub const SO_REUSEPORT: c_int = 512; +pub const SO_SNDBUF: c_int = 4097; +pub const SO_RCVBUF: c_int = 4098; +pub const SO_SNDLOWAT: c_int = 4099; +pub const SO_RCVLOWAT: c_int = 4100; +pub const SO_SNDTIMEO: c_int = 4101; +pub const SO_RCVTIMEO: c_int = 4102; +pub const SO_ERROR: c_int = 4103; +pub const SO_STYLE: c_int = 4104; +pub const SO_TYPE: c_int = 4104; + +pub const IPPROTO_IP: c_int = 0; +pub const IPPROTO_ICMP: c_int = 1; +pub const IPPROTO_IGMP: c_int = 2; +pub const IPPROTO_IPIP: c_int = 4; +pub const IPPROTO_TCP: c_int = 6; +pub const IPPROTO_EGP: c_int = 8; +pub const IPPROTO_PUP: c_int = 12; +pub const IPPROTO_UDP: c_int = 17; +pub const IPPROTO_IDP: c_int = 22; +pub const IPPROTO_TP: c_int = 29; +pub const IPPROTO_DCCP: c_int = 33; +pub const IPPROTO_IPV6: c_int = 41; +pub const IPPROTO_RSVP: c_int = 46; +pub const IPPROTO_GRE: c_int = 47; +pub const IPPROTO_ESP: c_int = 50; +pub const IPPROTO_AH: c_int = 51; +pub const IPPROTO_MTP: c_int = 92; +pub const IPPROTO_BEETPH: c_int = 94; +pub const IPPROTO_ENCAP: c_int = 98; +pub const IPPROTO_PIM: c_int = 103; +pub const IPPROTO_COMP: c_int = 108; +pub const IPPROTO_L2TP: c_int = 115; +pub const IPPROTO_SCTP: c_int = 132; +pub const IPPROTO_UDPLITE: c_int = 136; +pub const IPPROTO_MPLS: c_int = 137; +pub const IPPROTO_ETHERNET: c_int = 143; +pub const IPPROTO_RAW: c_int = 255; +pub const IPPROTO_MPTCP: c_int = 262; +pub const IPPROTO_MAX: c_int = 263; + +pub const IPPROTO_HOPOPTS: c_int = 0; +pub const IPPROTO_ROUTING: c_int = 43; +pub const IPPROTO_FRAGMENT: c_int = 44; +pub const IPPROTO_ICMPV6: c_int = 58; +pub const IPPROTO_NONE: c_int = 59; +pub const IPPROTO_DSTOPTS: c_int = 60; +pub const IPPROTO_MH: c_int = 135; + +pub const IPPORT_ECHO: in_port_t = 7; +pub const IPPORT_DISCARD: in_port_t = 9; +pub const IPPORT_SYSTAT: in_port_t = 11; +pub const IPPORT_DAYTIME: in_port_t = 13; +pub const IPPORT_NETSTAT: in_port_t = 15; +pub const IPPORT_FTP: in_port_t = 21; +pub const IPPORT_TELNET: in_port_t = 23; +pub const IPPORT_SMTP: in_port_t = 25; +pub const IPPORT_TIMESERVER: in_port_t = 37; +pub const IPPORT_NAMESERVER: in_port_t = 42; +pub const IPPORT_WHOIS: in_port_t = 43; +pub const IPPORT_MTP: in_port_t = 57; +pub const IPPORT_TFTP: in_port_t = 69; +pub const IPPORT_RJE: in_port_t = 77; +pub const IPPORT_FINGER: in_port_t = 79; +pub const IPPORT_TTYLINK: in_port_t = 87; +pub const IPPORT_SUPDUP: in_port_t = 95; +pub const IPPORT_EXECSERVER: in_port_t = 512; +pub const IPPORT_LOGINSERVER: in_port_t = 513; +pub const IPPORT_CMDSERVER: in_port_t = 514; +pub const IPPORT_EFSSERVER: in_port_t = 520; +pub const IPPORT_BIFFUDP: in_port_t = 512; +pub const IPPORT_WHOSERVER: in_port_t = 513; +pub const IPPORT_ROUTESERVER: in_port_t = 520; +pub const IPPORT_USERRESERVED: in_port_t = 5000; + +pub const DT_UNKNOWN: c_uchar = 0; +pub const DT_FIFO: c_uchar = 1; +pub const DT_CHR: c_uchar = 2; +pub const DT_DIR: c_uchar = 4; +pub const DT_BLK: c_uchar = 6; +pub const DT_REG: c_uchar = 8; +pub const DT_LNK: c_uchar = 10; +pub const DT_SOCK: c_uchar = 12; +pub const DT_WHT: c_uchar = 14; + +pub const ST_RDONLY: c_ulong = 1; +pub const ST_NOSUID: c_ulong = 2; +pub const ST_NOEXEC: c_ulong = 8; +pub const ST_SYNCHRONOUS: c_ulong = 16; +pub const ST_NOATIME: c_ulong = 32; +pub const ST_RELATIME: c_ulong = 64; + +pub const RTLD_DI_LMID: c_int = 1; +pub const RTLD_DI_LINKMAP: c_int = 2; +pub const RTLD_DI_CONFIGADDR: c_int = 3; +pub const RTLD_DI_SERINFO: c_int = 4; +pub const RTLD_DI_SERINFOSIZE: c_int = 5; +pub const RTLD_DI_ORIGIN: c_int = 6; +pub const RTLD_DI_PROFILENAME: c_int = 7; +pub const RTLD_DI_PROFILEOUT: c_int = 8; +pub const RTLD_DI_TLS_MODID: c_int = 9; +pub const RTLD_DI_TLS_DATA: c_int = 10; +pub const RTLD_DI_PHDR: c_int = 11; +pub const RTLD_DI_MAX: c_int = 11; + +pub const SI_ASYNCIO: c_int = -4; +pub const SI_MESGQ: c_int = -3; +pub const SI_TIMER: c_int = -2; +pub const SI_QUEUE: c_int = -1; +pub const SI_USER: c_int = 0; + +pub const ILL_ILLOPC: c_int = 1; +pub const ILL_ILLOPN: c_int = 2; +pub const ILL_ILLADR: c_int = 3; +pub const ILL_ILLTRP: c_int = 4; +pub const ILL_PRVOPC: c_int = 5; +pub const ILL_PRVREG: c_int = 6; +pub const ILL_COPROC: c_int = 7; +pub const ILL_BADSTK: c_int = 8; + +pub const FPE_INTDIV: c_int = 1; +pub const FPE_INTOVF: c_int = 2; +pub const FPE_FLTDIV: c_int = 3; +pub const FPE_FLTOVF: c_int = 4; +pub const FPE_FLTUND: c_int = 5; +pub const FPE_FLTRES: c_int = 6; +pub const FPE_FLTINV: c_int = 7; +pub const FPE_FLTSUB: c_int = 8; + +pub const SEGV_MAPERR: c_int = 1; +pub const SEGV_ACCERR: c_int = 2; + +pub const BUS_ADRALN: c_int = 1; +pub const BUS_ADRERR: c_int = 2; +pub const BUS_OBJERR: c_int = 3; + +pub const TRAP_BRKPT: c_int = 1; +pub const TRAP_TRACE: c_int = 2; + +pub const CLD_EXITED: c_int = 1; +pub const CLD_KILLED: c_int = 2; +pub const CLD_DUMPED: c_int = 3; +pub const CLD_TRAPPED: c_int = 4; +pub const CLD_STOPPED: c_int = 5; +pub const CLD_CONTINUED: c_int = 6; + +pub const POLL_IN: c_int = 1; +pub const POLL_OUT: c_int = 2; +pub const POLL_MSG: c_int = 3; +pub const POLL_ERR: c_int = 4; +pub const POLL_PRI: c_int = 5; +pub const POLL_HUP: c_int = 6; + +pub const SIGEV_SIGNAL: c_int = 0; +pub const SIGEV_NONE: c_int = 1; +pub const SIGEV_THREAD: c_int = 2; + +pub const REG_GS: c_uint = 0; +pub const REG_FS: c_uint = 1; +pub const REG_ES: c_uint = 2; +pub const REG_DS: c_uint = 3; +pub const REG_EDI: c_uint = 4; +pub const REG_ESI: c_uint = 5; +pub const REG_EBP: c_uint = 6; +pub const REG_ESP: c_uint = 7; +pub const REG_EBX: c_uint = 8; +pub const REG_EDX: c_uint = 9; +pub const REG_ECX: c_uint = 10; +pub const REG_EAX: c_uint = 11; +pub const REG_TRAPNO: c_uint = 12; +pub const REG_ERR: c_uint = 13; +pub const REG_EIP: c_uint = 14; +pub const REG_CS: c_uint = 15; +pub const REG_EFL: c_uint = 16; +pub const REG_UESP: c_uint = 17; +pub const REG_SS: c_uint = 18; + +pub const IOC_VOID: __ioctl_dir = 0; +pub const IOC_OUT: __ioctl_dir = 1; +pub const IOC_IN: __ioctl_dir = 2; +pub const IOC_INOUT: __ioctl_dir = 3; + +pub const IOC_8: __ioctl_datum = 0; +pub const IOC_16: __ioctl_datum = 1; +pub const IOC_32: __ioctl_datum = 2; +pub const IOC_64: __ioctl_datum = 3; + +pub const TCP_ESTABLISHED: c_uint = 1; +pub const TCP_SYN_SENT: c_uint = 2; +pub const TCP_SYN_RECV: c_uint = 3; +pub const TCP_FIN_WAIT1: c_uint = 4; +pub const TCP_FIN_WAIT2: c_uint = 5; +pub const TCP_TIME_WAIT: c_uint = 6; +pub const TCP_CLOSE: c_uint = 7; +pub const TCP_CLOSE_WAIT: c_uint = 8; +pub const TCP_LAST_ACK: c_uint = 9; +pub const TCP_LISTEN: c_uint = 10; +pub const TCP_CLOSING: c_uint = 11; + +pub const TCP_CA_Open: tcp_ca_state = 0; +pub const TCP_CA_Disorder: tcp_ca_state = 1; +pub const TCP_CA_CWR: tcp_ca_state = 2; +pub const TCP_CA_Recovery: tcp_ca_state = 3; +pub const TCP_CA_Loss: tcp_ca_state = 4; + +pub const TCP_NO_QUEUE: c_uint = 0; +pub const TCP_RECV_QUEUE: c_uint = 1; +pub const TCP_SEND_QUEUE: c_uint = 2; +pub const TCP_QUEUES_NR: c_uint = 3; + +pub const P_ALL: idtype_t = 0; +pub const P_PID: idtype_t = 1; +pub const P_PGID: idtype_t = 2; + +pub const SS_ONSTACK: c_int = 1; +pub const SS_DISABLE: c_int = 4; + +pub const SHUT_RD: c_int = 0; +pub const SHUT_WR: c_int = 1; +pub const SHUT_RDWR: c_int = 2; +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + __lock: 0, + __owner_id: 0, + __cnt: 0, + __shpid: 0, + __type: PTHREAD_MUTEX_TIMED as c_int, + __flags: 0, + __reserved1: Padding::new(0), + __reserved2: Padding::new(0), +}; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + __lock: __PTHREAD_SPIN_LOCK_INITIALIZER, + __queue: 0i64 as *mut __pthread, + __attr: 0i64 as *mut __pthread_condattr, + __wrefs: 0, + __data: 0i64 as *mut c_void, +}; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + __held: __PTHREAD_SPIN_LOCK_INITIALIZER, + __lock: __PTHREAD_SPIN_LOCK_INITIALIZER, + __readers: 0, + __readerqueue: 0i64 as *mut __pthread, + __writerqueue: 0i64 as *mut __pthread, + __attr: 0i64 as *mut __pthread_rwlockattr, + __data: 0i64 as *mut c_void, +}; +pub const PTHREAD_STACK_MIN: size_t = 0; + +// Non-public helper constants +const _UTSNAME_LENGTH: usize = 1024; + +const fn CMSG_ALIGN(len: usize) -> usize { + (len + size_of::() - 1) & !(size_of::() - 1) +} + +// functions +f! { + pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { + if (*mhdr).msg_controllen as usize >= size_of::() { + (*mhdr).msg_control.cast::() + } else { + core::ptr::null_mut::() + } + } + + pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { + (cmsg as *mut c_uchar).offset(CMSG_ALIGN(size_of::()) as isize) + } + + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { + (CMSG_ALIGN(length as usize) + CMSG_ALIGN(size_of::())) as c_uint + } + + pub const fn CMSG_LEN(length: c_uint) -> c_uint { + CMSG_ALIGN(size_of::()) as c_uint + length + } + + pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { + if ((*cmsg).cmsg_len as usize) < size_of::() { + return core::ptr::null_mut::(); + } + let next = (cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr; + let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; + if (next.offset(1)) as usize > max + || next as usize + CMSG_ALIGN((*next).cmsg_len as usize) > max + { + core::ptr::null_mut::() + } else { + next.cast::() + } + } + + pub fn CPU_ALLOC_SIZE(count: c_int) -> size_t { + let _dummy: cpu_set_t = mem::zeroed(); + let size_in_bits = 8 * size_of_val(&_dummy.bits[0]); + ((count as size_t + size_in_bits - 1) / 8) as size_t + } + + pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { + for slot in cpuset.bits.iter_mut() { + *slot = 0; + } + } + + pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc + let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); + cpuset.bits[idx] |= 1 << offset; + } + + pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc + let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); + cpuset.bits[idx] &= !(1 << offset); + } + + pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); + let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); + 0 != (cpuset.bits[idx] & (1 << offset)) + } + + pub fn CPU_COUNT_S(size: usize, cpuset: &cpu_set_t) -> c_int { + let mut s: u32 = 0; + let size_of_mask = size_of_val(&cpuset.bits[0]); + for i in cpuset.bits[..(size / size_of_mask)].iter() { + s += i.count_ones(); + } + s as c_int + } + + pub fn CPU_COUNT(cpuset: &cpu_set_t) -> c_int { + CPU_COUNT_S(size_of::(), cpuset) + } + + pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool { + set1.bits == set2.bits + } + + pub fn IPTOS_TOS(tos: u8) -> u8 { + tos & IPTOS_TOS_MASK + } + + pub fn IPTOS_PREC(tos: u8) -> u8 { + tos & IPTOS_PREC_MASK + } + + pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { + let fd = fd as usize; + let size = size_of_val(&(*set).fds_bits[0]) * 8; + (*set).fds_bits[fd / size] &= !(1 << (fd % size)); + return; + } + + pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { + let fd = fd as usize; + let size = size_of_val(&(*set).fds_bits[0]) * 8; + return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0; + } + + pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { + let fd = fd as usize; + let size = size_of_val(&(*set).fds_bits[0]) * 8; + (*set).fds_bits[fd / size] |= 1 << (fd % size); + return; + } + + pub fn FD_ZERO(set: *mut fd_set) -> () { + for slot in (*set).fds_bits.iter_mut() { + *slot = 0; + } + } +} + +extern "C" { + pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int; + + pub fn futimes(fd: c_int, times: *const crate::timeval) -> c_int; + pub fn futimens(__fd: c_int, __times: *const crate::timespec) -> c_int; + + pub fn utimensat( + dirfd: c_int, + path: *const c_char, + times: *const crate::timespec, + flag: c_int, + ) -> c_int; + + pub fn mkfifoat(__fd: c_int, __path: *const c_char, __mode: __mode_t) -> c_int; + + pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; + + pub fn __libc_current_sigrtmin() -> c_int; + + pub fn __libc_current_sigrtmax() -> c_int; + + pub fn wait4( + pid: crate::pid_t, + status: *mut c_int, + options: c_int, + rusage: *mut crate::rusage, + ) -> crate::pid_t; + + pub fn waitid( + idtype: idtype_t, + id: id_t, + infop: *mut crate::siginfo_t, + options: c_int, + ) -> c_int; + + pub fn sigwait(__set: *const sigset_t, __sig: *mut c_int) -> c_int; + + pub fn sigsuspend(mask: *const crate::sigset_t) -> c_int; + pub fn sigtimedwait( + set: *const sigset_t, + info: *mut siginfo_t, + timeout: *const crate::timespec, + ) -> c_int; + pub fn sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> c_int; + + pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> c_int; + + pub fn ioctl(__fd: c_int, __request: c_ulong, ...) -> c_int; + + pub fn pipe2(fds: *mut c_int, flags: c_int) -> c_int; + + pub fn dup3(oldfd: c_int, newfd: c_int, flags: c_int) -> c_int; + + pub fn pread64(fd: c_int, buf: *mut c_void, count: size_t, offset: off64_t) -> ssize_t; + pub fn pwrite64(fd: c_int, buf: *const c_void, count: size_t, offset: off64_t) -> ssize_t; + + pub fn readv(__fd: c_int, __iovec: *const crate::iovec, __count: c_int) -> ssize_t; + pub fn writev(__fd: c_int, __iovec: *const crate::iovec, __count: c_int) -> ssize_t; + + pub fn preadv( + __fd: c_int, + __iovec: *const crate::iovec, + __count: c_int, + __offset: __off_t, + ) -> ssize_t; + pub fn pwritev( + __fd: c_int, + __iovec: *const crate::iovec, + __count: c_int, + __offset: __off_t, + ) -> ssize_t; + + pub fn preadv64(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off64_t) + -> ssize_t; + pub fn pwritev64( + fd: c_int, + iov: *const crate::iovec, + iovcnt: c_int, + offset: off64_t, + ) -> ssize_t; + + pub fn fread_unlocked( + buf: *mut c_void, + size: size_t, + nobj: size_t, + stream: *mut crate::FILE, + ) -> size_t; + + pub fn aio_read(aiocbp: *mut aiocb) -> c_int; + pub fn aio_write(aiocbp: *mut aiocb) -> c_int; + pub fn aio_fsync(op: c_int, aiocbp: *mut aiocb) -> c_int; + pub fn aio_error(aiocbp: *const aiocb) -> c_int; + pub fn aio_return(aiocbp: *mut aiocb) -> ssize_t; + pub fn aio_suspend( + aiocb_list: *const *const aiocb, + nitems: c_int, + timeout: *const crate::timespec, + ) -> c_int; + pub fn aio_cancel(fd: c_int, aiocbp: *mut aiocb) -> c_int; + pub fn lio_listio( + mode: c_int, + aiocb_list: *const *mut aiocb, + nitems: c_int, + sevp: *mut crate::sigevent, + ) -> c_int; + + pub fn mq_open(name: *const c_char, oflag: c_int, ...) -> crate::mqd_t; + pub fn mq_close(mqd: crate::mqd_t) -> c_int; + pub fn mq_unlink(name: *const c_char) -> c_int; + pub fn mq_receive( + mqd: crate::mqd_t, + msg_ptr: *mut c_char, + msg_len: size_t, + msg_prio: *mut c_uint, + ) -> ssize_t; + pub fn mq_timedreceive( + mqd: crate::mqd_t, + msg_ptr: *mut c_char, + msg_len: size_t, + msg_prio: *mut c_uint, + abs_timeout: *const crate::timespec, + ) -> ssize_t; + pub fn mq_send( + mqd: crate::mqd_t, + msg_ptr: *const c_char, + msg_len: size_t, + msg_prio: c_uint, + ) -> c_int; + pub fn mq_timedsend( + mqd: crate::mqd_t, + msg_ptr: *const c_char, + msg_len: size_t, + msg_prio: c_uint, + abs_timeout: *const crate::timespec, + ) -> c_int; + pub fn mq_getattr(mqd: crate::mqd_t, attr: *mut crate::mq_attr) -> c_int; + pub fn mq_setattr( + mqd: crate::mqd_t, + newattr: *const crate::mq_attr, + oldattr: *mut crate::mq_attr, + ) -> c_int; + + pub fn lseek64(__fd: c_int, __offset: __off64_t, __whence: c_int) -> __off64_t; + + pub fn lseek(__fd: c_int, __offset: __off_t, __whence: c_int) -> __off_t; + + pub fn fgetpos64(stream: *mut crate::FILE, ptr: *mut fpos64_t) -> c_int; + pub fn fseeko64(stream: *mut crate::FILE, offset: off64_t, whence: c_int) -> c_int; + pub fn fsetpos64(stream: *mut crate::FILE, ptr: *const fpos64_t) -> c_int; + pub fn ftello64(stream: *mut crate::FILE) -> off64_t; + + pub fn bind(__fd: c_int, __addr: *const sockaddr, __len: crate::socklen_t) -> c_int; + + pub fn accept4( + fd: c_int, + addr: *mut crate::sockaddr, + len: *mut crate::socklen_t, + flg: c_int, + ) -> c_int; + + pub fn ppoll( + fds: *mut crate::pollfd, + nfds: nfds_t, + timeout: *const crate::timespec, + sigmask: *const sigset_t, + ) -> c_int; + + pub fn recvmsg(__fd: c_int, __message: *mut msghdr, __flags: c_int) -> ssize_t; + + pub fn sendmsg(__fd: c_int, __message: *const msghdr, __flags: c_int) -> ssize_t; + + pub fn recvfrom( + socket: c_int, + buf: *mut c_void, + len: size_t, + flags: c_int, + addr: *mut crate::sockaddr, + addrlen: *mut crate::socklen_t, + ) -> ssize_t; + + pub fn sendfile(out_fd: c_int, in_fd: c_int, offset: *mut off_t, count: size_t) -> ssize_t; + pub fn sendfile64(out_fd: c_int, in_fd: c_int, offset: *mut off64_t, count: size_t) -> ssize_t; + + pub fn shutdown(__fd: c_int, __how: c_int) -> c_int; + + pub fn sethostname(name: *const c_char, len: size_t) -> c_int; + pub fn getdomainname(name: *mut c_char, len: size_t) -> c_int; + pub fn setdomainname(name: *const c_char, len: size_t) -> c_int; + pub fn if_nameindex() -> *mut if_nameindex; + pub fn if_freenameindex(ptr: *mut if_nameindex); + + pub fn getnameinfo( + sa: *const crate::sockaddr, + salen: crate::socklen_t, + host: *mut c_char, + hostlen: crate::socklen_t, + serv: *mut c_char, + servlen: crate::socklen_t, + flags: c_int, + ) -> c_int; + + pub fn getifaddrs(ifap: *mut *mut crate::ifaddrs) -> c_int; + pub fn freeifaddrs(ifa: *mut crate::ifaddrs); + + pub fn uname(buf: *mut crate::utsname) -> c_int; + + pub fn gethostid() -> c_long; + pub fn sethostid(hostid: c_long) -> c_int; + + pub fn setpwent(); + pub fn endpwent(); + pub fn getpwent() -> *mut passwd; + pub fn setgrent(); + pub fn endgrent(); + pub fn getgrent() -> *mut crate::group; + pub fn setspent(); + pub fn endspent(); + pub fn getspent() -> *mut spwd; + + pub fn getspnam(name: *const c_char) -> *mut spwd; + + pub fn getpwent_r( + pwd: *mut crate::passwd, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::passwd, + ) -> c_int; + pub fn getgrent_r( + grp: *mut crate::group, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::group, + ) -> c_int; + pub fn fgetpwent_r( + stream: *mut crate::FILE, + pwd: *mut crate::passwd, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::passwd, + ) -> c_int; + pub fn fgetgrent_r( + stream: *mut crate::FILE, + grp: *mut crate::group, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::group, + ) -> c_int; + + pub fn putpwent(p: *const crate::passwd, stream: *mut crate::FILE) -> c_int; + pub fn putgrent(grp: *const crate::group, stream: *mut crate::FILE) -> c_int; + + pub fn getpwnam_r( + name: *const c_char, + pwd: *mut passwd, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut passwd, + ) -> c_int; + + pub fn getpwuid_r( + uid: crate::uid_t, + pwd: *mut passwd, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut passwd, + ) -> c_int; + + pub fn fgetspent_r( + fp: *mut crate::FILE, + spbuf: *mut crate::spwd, + buf: *mut c_char, + buflen: size_t, + spbufp: *mut *mut crate::spwd, + ) -> c_int; + pub fn sgetspent_r( + s: *const c_char, + spbuf: *mut crate::spwd, + buf: *mut c_char, + buflen: size_t, + spbufp: *mut *mut crate::spwd, + ) -> c_int; + pub fn getspent_r( + spbuf: *mut crate::spwd, + buf: *mut c_char, + buflen: size_t, + spbufp: *mut *mut crate::spwd, + ) -> c_int; + + pub fn getspnam_r( + name: *const c_char, + spbuf: *mut spwd, + buf: *mut c_char, + buflen: size_t, + spbufp: *mut *mut spwd, + ) -> c_int; + + // mntent.h + pub fn getmntent_r( + stream: *mut crate::FILE, + mntbuf: *mut crate::mntent, + buf: *mut c_char, + buflen: c_int, + ) -> *mut crate::mntent; + + pub fn utmpname(file: *const c_char) -> c_int; + pub fn utmpxname(file: *const c_char) -> c_int; + pub fn getutxent() -> *mut utmpx; + pub fn getutxid(ut: *const utmpx) -> *mut utmpx; + pub fn getutxline(ut: *const utmpx) -> *mut utmpx; + pub fn pututxline(ut: *const utmpx) -> *mut utmpx; + pub fn setutxent(); + pub fn endutxent(); + + pub fn getresuid( + ruid: *mut crate::uid_t, + euid: *mut crate::uid_t, + suid: *mut crate::uid_t, + ) -> c_int; + pub fn getresgid( + rgid: *mut crate::gid_t, + egid: *mut crate::gid_t, + sgid: *mut crate::gid_t, + ) -> c_int; + pub fn setresuid(ruid: crate::uid_t, euid: crate::uid_t, suid: crate::uid_t) -> c_int; + pub fn setresgid(rgid: crate::gid_t, egid: crate::gid_t, sgid: crate::gid_t) -> c_int; + + pub fn initgroups(user: *const c_char, group: crate::gid_t) -> c_int; + + pub fn getgrgid(gid: crate::gid_t) -> *mut crate::group; + pub fn getgrgid_r( + gid: crate::gid_t, + grp: *mut crate::group, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::group, + ) -> c_int; + + pub fn getgrnam(name: *const c_char) -> *mut crate::group; + pub fn getgrnam_r( + name: *const c_char, + grp: *mut crate::group, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::group, + ) -> c_int; + + pub fn getgrouplist( + user: *const c_char, + group: crate::gid_t, + groups: *mut crate::gid_t, + ngroups: *mut c_int, + ) -> c_int; + + pub fn setgroups(ngroups: size_t, ptr: *const crate::gid_t) -> c_int; + + pub fn acct(filename: *const c_char) -> c_int; + + pub fn setmntent(filename: *const c_char, ty: *const c_char) -> *mut crate::FILE; + pub fn getmntent(stream: *mut crate::FILE) -> *mut crate::mntent; + pub fn addmntent(stream: *mut crate::FILE, mnt: *const crate::mntent) -> c_int; + pub fn endmntent(streamp: *mut crate::FILE) -> c_int; + pub fn hasmntopt(mnt: *const crate::mntent, opt: *const c_char) -> *mut c_char; + + pub fn pthread_create( + native: *mut crate::pthread_t, + attr: *const crate::pthread_attr_t, + f: extern "C" fn(*mut c_void) -> *mut c_void, + value: *mut c_void, + ) -> c_int; + pub fn pthread_kill(__threadid: crate::pthread_t, __signo: c_int) -> c_int; + pub fn pthread_cancel(thread: crate::pthread_t) -> c_int; + pub fn __pthread_equal(__t1: __pthread_t, __t2: __pthread_t) -> c_int; + + pub fn pthread_getattr_np(__thr: crate::pthread_t, __attr: *mut pthread_attr_t) -> c_int; + + pub fn pthread_attr_getguardsize( + __attr: *const pthread_attr_t, + __guardsize: *mut size_t, + ) -> c_int; + pub fn pthread_attr_setguardsize(attr: *mut crate::pthread_attr_t, guardsize: size_t) -> c_int; + + pub fn pthread_attr_getstack( + __attr: *const pthread_attr_t, + __stackaddr: *mut *mut c_void, + __stacksize: *mut size_t, + ) -> c_int; + + pub fn pthread_mutexattr_getpshared( + attr: *const pthread_mutexattr_t, + pshared: *mut c_int, + ) -> c_int; + pub fn pthread_mutexattr_setpshared(attr: *mut pthread_mutexattr_t, pshared: c_int) -> c_int; + + pub fn pthread_mutex_timedlock( + lock: *mut pthread_mutex_t, + abstime: *const crate::timespec, + ) -> c_int; + + pub fn pthread_rwlockattr_getpshared( + attr: *const pthread_rwlockattr_t, + val: *mut c_int, + ) -> c_int; + pub fn pthread_rwlockattr_setpshared(attr: *mut pthread_rwlockattr_t, val: c_int) -> c_int; + + pub fn pthread_condattr_getclock( + attr: *const pthread_condattr_t, + clock_id: *mut clockid_t, + ) -> c_int; + pub fn pthread_condattr_setclock( + __attr: *mut pthread_condattr_t, + __clock_id: __clockid_t, + ) -> c_int; + pub fn pthread_condattr_getpshared( + attr: *const pthread_condattr_t, + pshared: *mut c_int, + ) -> c_int; + pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t, pshared: c_int) -> c_int; + + pub fn pthread_once(control: *mut pthread_once_t, routine: extern "C" fn()) -> c_int; + + pub fn pthread_barrierattr_init(attr: *mut crate::pthread_barrierattr_t) -> c_int; + pub fn pthread_barrierattr_destroy(attr: *mut crate::pthread_barrierattr_t) -> c_int; + pub fn pthread_barrierattr_getpshared( + attr: *const crate::pthread_barrierattr_t, + shared: *mut c_int, + ) -> c_int; + pub fn pthread_barrierattr_setpshared( + attr: *mut crate::pthread_barrierattr_t, + shared: c_int, + ) -> c_int; + pub fn pthread_barrier_init( + barrier: *mut pthread_barrier_t, + attr: *const crate::pthread_barrierattr_t, + count: c_uint, + ) -> c_int; + pub fn pthread_barrier_destroy(barrier: *mut pthread_barrier_t) -> c_int; + pub fn pthread_barrier_wait(barrier: *mut pthread_barrier_t) -> c_int; + pub fn pthread_spin_init(lock: *mut crate::pthread_spinlock_t, pshared: c_int) -> c_int; + pub fn pthread_spin_destroy(lock: *mut crate::pthread_spinlock_t) -> c_int; + pub fn pthread_spin_lock(lock: *mut crate::pthread_spinlock_t) -> c_int; + pub fn pthread_spin_trylock(lock: *mut crate::pthread_spinlock_t) -> c_int; + pub fn pthread_spin_unlock(lock: *mut crate::pthread_spinlock_t) -> c_int; + pub fn pthread_atfork( + prepare: Option, + parent: Option, + child: Option, + ) -> c_int; + + pub fn pthread_sigmask( + __how: c_int, + __newmask: *const __sigset_t, + __oldmask: *mut __sigset_t, + ) -> c_int; + + pub fn sched_getparam(pid: crate::pid_t, param: *mut crate::sched_param) -> c_int; + pub fn sched_setparam(pid: crate::pid_t, param: *const crate::sched_param) -> c_int; + pub fn sched_getscheduler(pid: crate::pid_t) -> c_int; + pub fn sched_setscheduler( + pid: crate::pid_t, + policy: c_int, + param: *const crate::sched_param, + ) -> c_int; + pub fn pthread_getschedparam( + native: crate::pthread_t, + policy: *mut c_int, + param: *mut crate::sched_param, + ) -> c_int; + pub fn pthread_setschedparam( + native: crate::pthread_t, + policy: c_int, + param: *const crate::sched_param, + ) -> c_int; + + pub fn pthread_getcpuclockid(thread: crate::pthread_t, clk_id: *mut crate::clockid_t) -> c_int; + + pub fn sem_init(sem: *mut sem_t, pshared: c_int, value: c_uint) -> c_int; + pub fn sem_destroy(sem: *mut sem_t) -> c_int; + pub fn sem_timedwait(sem: *mut sem_t, abstime: *const crate::timespec) -> c_int; + pub fn sem_getvalue(sem: *mut sem_t, sval: *mut c_int) -> c_int; + + pub fn clock_getres(__clock_id: clockid_t, __res: *mut crate::timespec) -> c_int; + pub fn clock_gettime(__clock_id: clockid_t, __tp: *mut crate::timespec) -> c_int; + pub fn clock_settime(__clock_id: clockid_t, __tp: *const crate::timespec) -> c_int; + pub fn clock_getcpuclockid(pid: crate::pid_t, clk_id: *mut crate::clockid_t) -> c_int; + + pub fn clock_nanosleep( + clk_id: crate::clockid_t, + flags: c_int, + rqtp: *const crate::timespec, + rmtp: *mut crate::timespec, + ) -> c_int; + + pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut crate::timezone) -> c_int; + pub fn settimeofday(tv: *const crate::timeval, tz: *const crate::timezone) -> c_int; + + pub fn asctime_r(tm: *const crate::tm, buf: *mut c_char) -> *mut c_char; + pub fn ctime_r(timep: *const time_t, buf: *mut c_char) -> *mut c_char; + + pub fn strftime( + s: *mut c_char, + max: size_t, + format: *const c_char, + tm: *const crate::tm, + ) -> size_t; + pub fn strptime(s: *const c_char, format: *const c_char, tm: *mut crate::tm) -> *mut c_char; + + pub fn timer_create( + clockid: crate::clockid_t, + sevp: *mut crate::sigevent, + timerid: *mut crate::timer_t, + ) -> c_int; + pub fn timer_delete(timerid: crate::timer_t) -> c_int; + pub fn timer_getoverrun(timerid: crate::timer_t) -> c_int; + pub fn timer_gettime(timerid: crate::timer_t, curr_value: *mut crate::itimerspec) -> c_int; + pub fn timer_settime( + timerid: crate::timer_t, + flags: c_int, + new_value: *const crate::itimerspec, + old_value: *mut crate::itimerspec, + ) -> c_int; + + pub fn fstat(__fd: c_int, __buf: *mut stat) -> c_int; + pub fn fstat64(__fd: c_int, __buf: *mut stat64) -> c_int; + + pub fn fstatat(__fd: c_int, __file: *const c_char, __buf: *mut stat, __flag: c_int) -> c_int; + pub fn fstatat64( + __fd: c_int, + __file: *const c_char, + __buf: *mut stat64, + __flag: c_int, + ) -> c_int; + + pub fn statx( + dirfd: c_int, + pathname: *const c_char, + flags: c_int, + mask: c_uint, + statxbuf: *mut statx, + ) -> c_int; + + pub fn ftruncate(__fd: c_int, __length: __off_t) -> c_int; + pub fn ftruncate64(__fd: c_int, __length: __off64_t) -> c_int; + pub fn truncate64(__file: *const c_char, __length: __off64_t) -> c_int; + + pub fn lstat(__file: *const c_char, __buf: *mut stat) -> c_int; + pub fn lstat64(__file: *const c_char, __buf: *mut stat64) -> c_int; + + pub fn statfs(path: *const c_char, buf: *mut statfs) -> c_int; + pub fn statfs64(__file: *const c_char, __buf: *mut statfs64) -> c_int; + pub fn fstatfs(fd: c_int, buf: *mut statfs) -> c_int; + pub fn fstatfs64(__fildes: c_int, __buf: *mut statfs64) -> c_int; + + pub fn statvfs(__file: *const c_char, __buf: *mut statvfs) -> c_int; + pub fn statvfs64(__file: *const c_char, __buf: *mut statvfs64) -> c_int; + pub fn fstatvfs(__fildes: c_int, __buf: *mut statvfs) -> c_int; + pub fn fstatvfs64(__fildes: c_int, __buf: *mut statvfs64) -> c_int; + + pub fn open(__file: *const c_char, __oflag: c_int, ...) -> c_int; + pub fn open64(__file: *const c_char, __oflag: c_int, ...) -> c_int; + + pub fn openat(__fd: c_int, __file: *const c_char, __oflag: c_int, ...) -> c_int; + pub fn openat64(__fd: c_int, __file: *const c_char, __oflag: c_int, ...) -> c_int; + + pub fn fopen64(filename: *const c_char, mode: *const c_char) -> *mut crate::FILE; + pub fn freopen64( + filename: *const c_char, + mode: *const c_char, + file: *mut crate::FILE, + ) -> *mut crate::FILE; + + pub fn creat64(path: *const c_char, mode: mode_t) -> c_int; + + pub fn mkostemp(template: *mut c_char, flags: c_int) -> c_int; + pub fn mkostemps(template: *mut c_char, suffixlen: c_int, flags: c_int) -> c_int; + pub fn mkstemps(template: *mut c_char, suffixlen: c_int) -> c_int; + pub fn tmpfile64() -> *mut crate::FILE; + + pub fn popen(command: *const c_char, mode: *const c_char) -> *mut crate::FILE; + + pub fn getdtablesize() -> c_int; + + // Added in `glibc` 2.34 + pub fn close_range(first: c_uint, last: c_uint, flags: c_int) -> c_int; + + pub fn openpty( + __amaster: *mut c_int, + __aslave: *mut c_int, + __name: *mut c_char, + __termp: *const termios, + __winp: *const crate::winsize, + ) -> c_int; + + pub fn forkpty( + __amaster: *mut c_int, + __name: *mut c_char, + __termp: *const termios, + __winp: *const crate::winsize, + ) -> crate::pid_t; + + pub fn getpt() -> c_int; + pub fn ptsname_r(fd: c_int, buf: *mut c_char, buflen: size_t) -> c_int; + pub fn login_tty(fd: c_int) -> c_int; + + pub fn ctermid(s: *mut c_char) -> *mut c_char; + + pub fn clearenv() -> c_int; + + pub fn execveat( + dirfd: c_int, + pathname: *const c_char, + argv: *const *mut c_char, + envp: *const *mut c_char, + flags: c_int, + ) -> c_int; + + // DIFF(main): changed to `*const *mut` in e77f551de9 + pub fn execvpe( + file: *const c_char, + argv: *const *const c_char, + envp: *const *const c_char, + ) -> c_int; + pub fn fexecve(fd: c_int, argv: *const *const c_char, envp: *const *const c_char) -> c_int; + + pub fn daemon(nochdir: c_int, noclose: c_int) -> c_int; + + // posix/spawn.h + pub fn posix_spawn( + pid: *mut crate::pid_t, + path: *const c_char, + file_actions: *const crate::posix_spawn_file_actions_t, + attrp: *const crate::posix_spawnattr_t, + argv: *const *mut c_char, + envp: *const *mut c_char, + ) -> c_int; + pub fn posix_spawnp( + pid: *mut crate::pid_t, + file: *const c_char, + file_actions: *const crate::posix_spawn_file_actions_t, + attrp: *const crate::posix_spawnattr_t, + argv: *const *mut c_char, + envp: *const *mut c_char, + ) -> c_int; + pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> c_int; + pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> c_int; + pub fn posix_spawnattr_getsigdefault( + attr: *const posix_spawnattr_t, + default: *mut crate::sigset_t, + ) -> c_int; + pub fn posix_spawnattr_setsigdefault( + attr: *mut posix_spawnattr_t, + default: *const crate::sigset_t, + ) -> c_int; + pub fn posix_spawnattr_getsigmask( + attr: *const posix_spawnattr_t, + default: *mut crate::sigset_t, + ) -> c_int; + pub fn posix_spawnattr_setsigmask( + attr: *mut posix_spawnattr_t, + default: *const crate::sigset_t, + ) -> c_int; + pub fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t, flags: *mut c_short) -> c_int; + pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t, flags: c_short) -> c_int; + pub fn posix_spawnattr_getpgroup( + attr: *const posix_spawnattr_t, + flags: *mut crate::pid_t, + ) -> c_int; + pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, flags: crate::pid_t) -> c_int; + pub fn posix_spawnattr_getschedpolicy( + attr: *const posix_spawnattr_t, + flags: *mut c_int, + ) -> c_int; + pub fn posix_spawnattr_setschedpolicy(attr: *mut posix_spawnattr_t, flags: c_int) -> c_int; + pub fn posix_spawnattr_getschedparam( + attr: *const posix_spawnattr_t, + param: *mut crate::sched_param, + ) -> c_int; + pub fn posix_spawnattr_setschedparam( + attr: *mut posix_spawnattr_t, + param: *const crate::sched_param, + ) -> c_int; + + pub fn posix_spawn_file_actions_init(actions: *mut posix_spawn_file_actions_t) -> c_int; + pub fn posix_spawn_file_actions_destroy(actions: *mut posix_spawn_file_actions_t) -> c_int; + pub fn posix_spawn_file_actions_addopen( + actions: *mut posix_spawn_file_actions_t, + fd: c_int, + path: *const c_char, + oflag: c_int, + mode: mode_t, + ) -> c_int; + pub fn posix_spawn_file_actions_addclose( + actions: *mut posix_spawn_file_actions_t, + fd: c_int, + ) -> c_int; + pub fn posix_spawn_file_actions_adddup2( + actions: *mut posix_spawn_file_actions_t, + fd: c_int, + newfd: c_int, + ) -> c_int; + + // Added in `glibc` 2.29 + pub fn posix_spawn_file_actions_addchdir_np( + actions: *mut crate::posix_spawn_file_actions_t, + path: *const c_char, + ) -> c_int; + // Added in `glibc` 2.29 + pub fn posix_spawn_file_actions_addfchdir_np( + actions: *mut crate::posix_spawn_file_actions_t, + fd: c_int, + ) -> c_int; + // Added in `glibc` 2.34 + pub fn posix_spawn_file_actions_addclosefrom_np( + actions: *mut crate::posix_spawn_file_actions_t, + from: c_int, + ) -> c_int; + // Added in `glibc` 2.35 + pub fn posix_spawn_file_actions_addtcsetpgrp_np( + actions: *mut crate::posix_spawn_file_actions_t, + tcfd: c_int, + ) -> c_int; + + pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int; + pub fn shm_unlink(name: *const c_char) -> c_int; + + pub fn euidaccess(pathname: *const c_char, mode: c_int) -> c_int; + pub fn eaccess(pathname: *const c_char, mode: c_int) -> c_int; + + pub fn faccessat(dirfd: c_int, pathname: *const c_char, mode: c_int, flags: c_int) -> c_int; + + pub fn stat(__file: *const c_char, __buf: *mut stat) -> c_int; + pub fn stat64(__file: *const c_char, __buf: *mut stat64) -> c_int; + + pub fn readdir(dirp: *mut crate::DIR) -> *mut crate::dirent; + pub fn readdir64(dirp: *mut crate::DIR) -> *mut crate::dirent64; + pub fn readdir_r( + dirp: *mut crate::DIR, + entry: *mut crate::dirent, + result: *mut *mut crate::dirent, + ) -> c_int; + pub fn readdir64_r( + dirp: *mut crate::DIR, + entry: *mut crate::dirent64, + result: *mut *mut crate::dirent64, + ) -> c_int; + pub fn seekdir(dirp: *mut crate::DIR, loc: c_long); + pub fn telldir(dirp: *mut crate::DIR) -> c_long; + + pub fn dirfd(dirp: *mut crate::DIR) -> c_int; + + #[link_name = "__xpg_strerror_r"] + pub fn strerror_r(__errnum: c_int, __buf: *mut c_char, __buflen: size_t) -> c_int; + + pub fn __errno_location() -> *mut c_int; + + pub fn mmap64( + __addr: *mut c_void, + __len: size_t, + __prot: c_int, + __flags: c_int, + __fd: c_int, + __offset: __off64_t, + ) -> *mut c_void; + + pub fn mremap( + addr: *mut c_void, + len: size_t, + new_len: size_t, + flags: c_int, + ... + ) -> *mut c_void; + + pub fn mprotect(__addr: *mut c_void, __len: size_t, __prot: c_int) -> c_int; + + pub fn msync(__addr: *mut c_void, __len: size_t, __flags: c_int) -> c_int; + pub fn sync(); + pub fn syncfs(fd: c_int) -> c_int; + pub fn fdatasync(fd: c_int) -> c_int; + + pub fn fallocate64(fd: c_int, mode: c_int, offset: off64_t, len: off64_t) -> c_int; + pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int; + pub fn posix_fallocate64(fd: c_int, offset: off64_t, len: off64_t) -> c_int; + + pub fn posix_fadvise(fd: c_int, offset: off_t, len: off_t, advise: c_int) -> c_int; + + pub fn posix_fadvise64(fd: c_int, offset: off64_t, len: off64_t, advise: c_int) -> c_int; + + pub fn madvise(__addr: *mut c_void, __len: size_t, __advice: c_int) -> c_int; + + pub fn posix_madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; + + pub fn getrlimit(resource: crate::__rlimit_resource_t, rlim: *mut crate::rlimit) -> c_int; + pub fn getrlimit64(resource: crate::__rlimit_resource_t, rlim: *mut crate::rlimit64) -> c_int; + pub fn setrlimit(resource: crate::__rlimit_resource_t, rlim: *const crate::rlimit) -> c_int; + pub fn setrlimit64(resource: crate::__rlimit_resource_t, rlim: *const crate::rlimit64) + -> c_int; + + pub fn getpriority(which: crate::__priority_which, who: crate::id_t) -> c_int; + pub fn setpriority(which: crate::__priority_which, who: crate::id_t, prio: c_int) -> c_int; + + pub fn getrandom(__buffer: *mut c_void, __length: size_t, __flags: c_uint) -> ssize_t; + pub fn getentropy(__buffer: *mut c_void, __length: size_t) -> c_int; + + pub fn memrchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; + pub fn memmem( + haystack: *const c_void, + haystacklen: size_t, + needle: *const c_void, + needlelen: size_t, + ) -> *mut c_void; + pub fn strchrnul(s: *const c_char, c: c_int) -> *mut c_char; + + pub fn abs(i: c_int) -> c_int; + pub fn labs(i: c_long) -> c_long; + pub fn rand() -> c_int; + pub fn srand(seed: c_uint); + + pub fn drand48() -> c_double; + pub fn erand48(xseed: *mut c_ushort) -> c_double; + pub fn lrand48() -> c_long; + pub fn nrand48(xseed: *mut c_ushort) -> c_long; + pub fn mrand48() -> c_long; + pub fn jrand48(xseed: *mut c_ushort) -> c_long; + pub fn srand48(seed: c_long); + pub fn seed48(xseed: *mut c_ushort) -> *mut c_ushort; + pub fn lcong48(p: *mut c_ushort); + + pub fn qsort_r( + base: *mut c_void, + num: size_t, + size: size_t, + compar: Option c_int>, + arg: *mut c_void, + ); + + pub fn brk(addr: *mut c_void) -> c_int; + pub fn sbrk(increment: intptr_t) -> *mut c_void; + + pub fn memalign(align: size_t, size: size_t) -> *mut c_void; + pub fn mallopt(param: c_int, value: c_int) -> c_int; + + pub fn mallinfo() -> crate::mallinfo; + pub fn mallinfo2() -> crate::mallinfo2; + pub fn malloc_info(options: c_int, stream: *mut crate::FILE) -> c_int; + pub fn malloc_usable_size(ptr: *mut c_void) -> size_t; + pub fn malloc_trim(__pad: size_t) -> c_int; + + pub fn iconv_open(tocode: *const c_char, fromcode: *const c_char) -> iconv_t; + pub fn iconv( + cd: iconv_t, + inbuf: *mut *mut c_char, + inbytesleft: *mut size_t, + outbuf: *mut *mut c_char, + outbytesleft: *mut size_t, + ) -> size_t; + pub fn iconv_close(cd: iconv_t) -> c_int; + + pub fn getopt_long( + argc: c_int, + argv: *const *mut c_char, + optstring: *const c_char, + longopts: *const option, + longindex: *mut c_int, + ) -> c_int; + + pub fn backtrace(buf: *mut *mut c_void, sz: c_int) -> c_int; + + pub fn reboot(how_to: c_int) -> c_int; + + pub fn getloadavg(loadavg: *mut c_double, nelem: c_int) -> c_int; + + pub fn regexec( + preg: *const crate::regex_t, + input: *const c_char, + nmatch: size_t, + pmatch: *mut regmatch_t, + eflags: c_int, + ) -> c_int; + + pub fn regerror( + errcode: c_int, + preg: *const crate::regex_t, + errbuf: *mut c_char, + errbuf_size: size_t, + ) -> size_t; + + pub fn regfree(preg: *mut crate::regex_t); + + pub fn glob( + pattern: *const c_char, + flags: c_int, + errfunc: Option c_int>, + pglob: *mut crate::glob_t, + ) -> c_int; + pub fn globfree(pglob: *mut crate::glob_t); + + pub fn glob64( + pattern: *const c_char, + flags: c_int, + errfunc: Option c_int>, + pglob: *mut glob64_t, + ) -> c_int; + pub fn globfree64(pglob: *mut glob64_t); + + pub fn getxattr( + path: *const c_char, + name: *const c_char, + value: *mut c_void, + size: size_t, + ) -> ssize_t; + pub fn lgetxattr( + path: *const c_char, + name: *const c_char, + value: *mut c_void, + size: size_t, + ) -> ssize_t; + pub fn fgetxattr( + filedes: c_int, + name: *const c_char, + value: *mut c_void, + size: size_t, + ) -> ssize_t; + pub fn setxattr( + path: *const c_char, + name: *const c_char, + value: *const c_void, + size: size_t, + flags: c_int, + ) -> c_int; + pub fn lsetxattr( + path: *const c_char, + name: *const c_char, + value: *const c_void, + size: size_t, + flags: c_int, + ) -> c_int; + pub fn fsetxattr( + filedes: c_int, + name: *const c_char, + value: *const c_void, + size: size_t, + flags: c_int, + ) -> c_int; + pub fn listxattr(path: *const c_char, list: *mut c_char, size: size_t) -> ssize_t; + pub fn llistxattr(path: *const c_char, list: *mut c_char, size: size_t) -> ssize_t; + pub fn flistxattr(filedes: c_int, list: *mut c_char, size: size_t) -> ssize_t; + pub fn removexattr(path: *const c_char, name: *const c_char) -> c_int; + pub fn lremovexattr(path: *const c_char, name: *const c_char) -> c_int; + pub fn fremovexattr(filedes: c_int, name: *const c_char) -> c_int; + + pub fn dirname(path: *mut c_char) -> *mut c_char; + /// POSIX version of `basename(3)`, defined in `libgen.h`. + #[link_name = "__xpg_basename"] + pub fn posix_basename(path: *mut c_char) -> *mut c_char; + /// GNU version of `basename(3)`, defined in `string.h`. + #[link_name = "basename"] + pub fn gnu_basename(path: *const c_char) -> *mut c_char; + + pub fn dlmopen(lmid: Lmid_t, filename: *const c_char, flag: c_int) -> *mut c_void; + pub fn dlinfo(handle: *mut c_void, request: c_int, info: *mut c_void) -> c_int; + pub fn dladdr1( + addr: *const c_void, + info: *mut crate::Dl_info, + extra_info: *mut *mut c_void, + flags: c_int, + ) -> c_int; + + pub fn duplocale(base: crate::locale_t) -> crate::locale_t; + pub fn freelocale(loc: crate::locale_t); + pub fn newlocale(mask: c_int, locale: *const c_char, base: crate::locale_t) -> crate::locale_t; + pub fn uselocale(loc: crate::locale_t) -> crate::locale_t; + pub fn nl_langinfo(item: crate::nl_item) -> *mut c_char; + pub fn nl_langinfo_l(item: crate::nl_item, locale: crate::locale_t) -> *mut c_char; + + pub fn dl_iterate_phdr( + callback: Option< + unsafe extern "C" fn( + info: *mut crate::dl_phdr_info, + size: size_t, + data: *mut c_void, + ) -> c_int, + >, + data: *mut c_void, + ) -> c_int; + + pub fn gnu_get_libc_release() -> *const c_char; + pub fn gnu_get_libc_version() -> *const c_char; +} + +safe_f! { + pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { + let major = major as crate::dev_t; + let minor = minor as crate::dev_t; + let mut dev = 0; + dev |= major << 8; + dev |= minor; + dev + } + + pub const fn major(dev: crate::dev_t) -> c_uint { + ((dev >> 8) & 0xff) as c_uint + } + + pub const fn minor(dev: crate::dev_t) -> c_uint { + (dev & 0xffff00ff) as c_uint + } + + pub fn SIGRTMAX() -> c_int { + unsafe { __libc_current_sigrtmax() } + } + + pub fn SIGRTMIN() -> c_int { + unsafe { __libc_current_sigrtmin() } + } + + pub const fn WIFSTOPPED(status: c_int) -> bool { + (status & 0xff) == 0x7f + } + + pub const fn WSTOPSIG(status: c_int) -> c_int { + (status >> 8) & 0xff + } + + pub const fn WIFCONTINUED(status: c_int) -> bool { + status == 0xffff + } + + pub const fn WIFSIGNALED(status: c_int) -> bool { + ((status & 0x7f) + 1) as i8 >= 2 + } + + pub const fn WTERMSIG(status: c_int) -> c_int { + status & 0x7f + } + + pub const fn WIFEXITED(status: c_int) -> bool { + (status & 0x7f) == 0 + } + + pub const fn WEXITSTATUS(status: c_int) -> c_int { + (status >> 8) & 0xff + } + + pub const fn WCOREDUMP(status: c_int) -> bool { + (status & 0x80) != 0 + } + + pub const fn W_EXITCODE(ret: c_int, sig: c_int) -> c_int { + (ret << 8) | sig + } + + pub const fn W_STOPCODE(sig: c_int) -> c_int { + (sig << 8) | 0x7f + } + + pub const fn QCMD(cmd: c_int, type_: c_int) -> c_int { + (cmd << 8) | (type_ & 0x00ff) + } + + pub const fn IPOPT_COPIED(o: u8) -> u8 { + o & IPOPT_COPY + } + + pub const fn IPOPT_CLASS(o: u8) -> u8 { + o & IPOPT_CLASS_MASK + } + + pub const fn IPOPT_NUMBER(o: u8) -> u8 { + o & IPOPT_NUMBER_MASK + } + + pub const fn IPTOS_ECN(x: u8) -> u8 { + x & crate::IPTOS_ECN_MASK + } +} + +cfg_if! { + if #[cfg(target_pointer_width = "64")] { + mod b64; + pub use self::b64::*; + } else { + mod b32; + pub use self::b32::*; + } +} diff --git a/http/vendor/libc/src/unix/linux_like/android/b32/arm.rs b/http/vendor/libc/src/unix/linux_like/android/b32/arm.rs new file mode 100644 index 0000000..6637587 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/android/b32/arm.rs @@ -0,0 +1,494 @@ +use crate::prelude::*; + +pub type wchar_t = u32; +pub type greg_t = i32; +pub type mcontext_t = sigcontext; + +s! { + pub struct sigcontext { + pub trap_no: c_ulong, + pub error_code: c_ulong, + pub oldmask: c_ulong, + pub arm_r0: c_ulong, + pub arm_r1: c_ulong, + pub arm_r2: c_ulong, + pub arm_r3: c_ulong, + pub arm_r4: c_ulong, + pub arm_r5: c_ulong, + pub arm_r6: c_ulong, + pub arm_r7: c_ulong, + pub arm_r8: c_ulong, + pub arm_r9: c_ulong, + pub arm_r10: c_ulong, + pub arm_fp: c_ulong, + pub arm_ip: c_ulong, + pub arm_sp: c_ulong, + pub arm_lr: c_ulong, + pub arm_pc: c_ulong, + pub arm_cpsr: c_ulong, + pub fault_address: c_ulong, + } + + pub struct __c_anonymous_uc_sigmask_with_padding { + pub uc_sigmask: crate::sigset_t, + /* Android has a wrong (smaller) sigset_t on x86. */ + __padding_rt_sigset: Padding, + } + + pub struct ucontext_t { + pub uc_flags: c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: crate::stack_t, + pub uc_mcontext: mcontext_t, + pub uc_sigmask__c_anonymous_union: __c_anonymous_uc_sigmask, + /* The kernel adds extra padding after uc_sigmask to match + * glibc sigset_t on ARM. */ + __padding: Padding<[c_char; 120]>, + __align: [c_longlong; 0], + uc_regspace: [c_ulong; 128], + } +} + +s_no_extra_traits! { + pub union __c_anonymous_uc_sigmask { + uc_sigmask: __c_anonymous_uc_sigmask_with_padding, + uc_sigmask64: crate::sigset64_t, + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for __c_anonymous_uc_sigmask { + fn eq(&self, other: &__c_anonymous_uc_sigmask) -> bool { + unsafe { self.uc_sigmask == other.uc_sigmask } + } + } + impl Eq for __c_anonymous_uc_sigmask {} + impl hash::Hash for __c_anonymous_uc_sigmask { + fn hash(&self, state: &mut H) { + unsafe { self.uc_sigmask.hash(state) } + } + } + } +} + +pub const O_DIRECT: c_int = 0x10000; +pub const O_DIRECTORY: c_int = 0x4000; +pub const O_NOFOLLOW: c_int = 0x8000; +pub const O_LARGEFILE: c_int = 0o400000; + +pub const SYS_restart_syscall: c_long = 0; +pub const SYS_exit: c_long = 1; +pub const SYS_fork: c_long = 2; +pub const SYS_read: c_long = 3; +pub const SYS_write: c_long = 4; +pub const SYS_open: c_long = 5; +pub const SYS_close: c_long = 6; +pub const SYS_creat: c_long = 8; +pub const SYS_link: c_long = 9; +pub const SYS_unlink: c_long = 10; +pub const SYS_execve: c_long = 11; +pub const SYS_chdir: c_long = 12; +pub const SYS_mknod: c_long = 14; +pub const SYS_chmod: c_long = 15; +pub const SYS_lchown: c_long = 16; +pub const SYS_lseek: c_long = 19; +pub const SYS_getpid: c_long = 20; +pub const SYS_mount: c_long = 21; +pub const SYS_setuid: c_long = 23; +pub const SYS_getuid: c_long = 24; +pub const SYS_ptrace: c_long = 26; +pub const SYS_pause: c_long = 29; +pub const SYS_access: c_long = 33; +pub const SYS_nice: c_long = 34; +pub const SYS_sync: c_long = 36; +pub const SYS_kill: c_long = 37; +pub const SYS_rename: c_long = 38; +pub const SYS_mkdir: c_long = 39; +pub const SYS_rmdir: c_long = 40; +pub const SYS_dup: c_long = 41; +pub const SYS_pipe: c_long = 42; +pub const SYS_times: c_long = 43; +pub const SYS_brk: c_long = 45; +pub const SYS_setgid: c_long = 46; +pub const SYS_getgid: c_long = 47; +pub const SYS_geteuid: c_long = 49; +pub const SYS_getegid: c_long = 50; +pub const SYS_acct: c_long = 51; +pub const SYS_umount2: c_long = 52; +pub const SYS_ioctl: c_long = 54; +pub const SYS_fcntl: c_long = 55; +pub const SYS_setpgid: c_long = 57; +pub const SYS_umask: c_long = 60; +pub const SYS_chroot: c_long = 61; +pub const SYS_ustat: c_long = 62; +pub const SYS_dup2: c_long = 63; +pub const SYS_getppid: c_long = 64; +pub const SYS_getpgrp: c_long = 65; +pub const SYS_setsid: c_long = 66; +pub const SYS_sigaction: c_long = 67; +pub const SYS_setreuid: c_long = 70; +pub const SYS_setregid: c_long = 71; +pub const SYS_sigsuspend: c_long = 72; +pub const SYS_sigpending: c_long = 73; +pub const SYS_sethostname: c_long = 74; +pub const SYS_setrlimit: c_long = 75; +pub const SYS_getrusage: c_long = 77; +pub const SYS_gettimeofday: c_long = 78; +pub const SYS_settimeofday: c_long = 79; +pub const SYS_getgroups: c_long = 80; +pub const SYS_setgroups: c_long = 81; +pub const SYS_symlink: c_long = 83; +pub const SYS_readlink: c_long = 85; +pub const SYS_uselib: c_long = 86; +pub const SYS_swapon: c_long = 87; +pub const SYS_reboot: c_long = 88; +pub const SYS_munmap: c_long = 91; +pub const SYS_truncate: c_long = 92; +pub const SYS_ftruncate: c_long = 93; +pub const SYS_fchmod: c_long = 94; +pub const SYS_fchown: c_long = 95; +pub const SYS_getpriority: c_long = 96; +pub const SYS_setpriority: c_long = 97; +pub const SYS_statfs: c_long = 99; +pub const SYS_fstatfs: c_long = 100; +pub const SYS_syslog: c_long = 103; +pub const SYS_setitimer: c_long = 104; +pub const SYS_getitimer: c_long = 105; +pub const SYS_stat: c_long = 106; +pub const SYS_lstat: c_long = 107; +pub const SYS_fstat: c_long = 108; +pub const SYS_vhangup: c_long = 111; +pub const SYS_wait4: c_long = 114; +pub const SYS_swapoff: c_long = 115; +pub const SYS_sysinfo: c_long = 116; +pub const SYS_fsync: c_long = 118; +pub const SYS_sigreturn: c_long = 119; +pub const SYS_clone: c_long = 120; +pub const SYS_setdomainname: c_long = 121; +pub const SYS_uname: c_long = 122; +pub const SYS_adjtimex: c_long = 124; +pub const SYS_mprotect: c_long = 125; +pub const SYS_sigprocmask: c_long = 126; +pub const SYS_init_module: c_long = 128; +pub const SYS_delete_module: c_long = 129; +pub const SYS_quotactl: c_long = 131; +pub const SYS_getpgid: c_long = 132; +pub const SYS_fchdir: c_long = 133; +pub const SYS_bdflush: c_long = 134; +pub const SYS_sysfs: c_long = 135; +pub const SYS_personality: c_long = 136; +pub const SYS_setfsuid: c_long = 138; +pub const SYS_setfsgid: c_long = 139; +pub const SYS_getdents: c_long = 141; +pub const SYS_flock: c_long = 143; +pub const SYS_msync: c_long = 144; +pub const SYS_readv: c_long = 145; +pub const SYS_writev: c_long = 146; +pub const SYS_getsid: c_long = 147; +pub const SYS_fdatasync: c_long = 148; +pub const SYS_mlock: c_long = 150; +pub const SYS_munlock: c_long = 151; +pub const SYS_mlockall: c_long = 152; +pub const SYS_munlockall: c_long = 153; +pub const SYS_sched_setparam: c_long = 154; +pub const SYS_sched_getparam: c_long = 155; +pub const SYS_sched_setscheduler: c_long = 156; +pub const SYS_sched_getscheduler: c_long = 157; +pub const SYS_sched_yield: c_long = 158; +pub const SYS_sched_get_priority_max: c_long = 159; +pub const SYS_sched_get_priority_min: c_long = 160; +pub const SYS_sched_rr_get_interval: c_long = 161; +pub const SYS_nanosleep: c_long = 162; +pub const SYS_mremap: c_long = 163; +pub const SYS_setresuid: c_long = 164; +pub const SYS_getresuid: c_long = 165; +pub const SYS_poll: c_long = 168; +pub const SYS_nfsservctl: c_long = 169; +pub const SYS_setresgid: c_long = 170; +pub const SYS_getresgid: c_long = 171; +pub const SYS_prctl: c_long = 172; +pub const SYS_rt_sigreturn: c_long = 173; +pub const SYS_rt_sigaction: c_long = 174; +pub const SYS_rt_sigprocmask: c_long = 175; +pub const SYS_rt_sigpending: c_long = 176; +pub const SYS_rt_sigtimedwait: c_long = 177; +pub const SYS_rt_sigqueueinfo: c_long = 178; +pub const SYS_rt_sigsuspend: c_long = 179; +pub const SYS_pread64: c_long = 180; +pub const SYS_pwrite64: c_long = 181; +pub const SYS_chown: c_long = 182; +pub const SYS_getcwd: c_long = 183; +pub const SYS_capget: c_long = 184; +pub const SYS_capset: c_long = 185; +pub const SYS_sigaltstack: c_long = 186; +pub const SYS_sendfile: c_long = 187; +pub const SYS_vfork: c_long = 190; +pub const SYS_ugetrlimit: c_long = 191; +pub const SYS_mmap2: c_long = 192; +pub const SYS_truncate64: c_long = 193; +pub const SYS_ftruncate64: c_long = 194; +pub const SYS_stat64: c_long = 195; +pub const SYS_lstat64: c_long = 196; +pub const SYS_fstat64: c_long = 197; +pub const SYS_lchown32: c_long = 198; +pub const SYS_getuid32: c_long = 199; +pub const SYS_getgid32: c_long = 200; +pub const SYS_geteuid32: c_long = 201; +pub const SYS_getegid32: c_long = 202; +pub const SYS_setreuid32: c_long = 203; +pub const SYS_setregid32: c_long = 204; +pub const SYS_getgroups32: c_long = 205; +pub const SYS_setgroups32: c_long = 206; +pub const SYS_fchown32: c_long = 207; +pub const SYS_setresuid32: c_long = 208; +pub const SYS_getresuid32: c_long = 209; +pub const SYS_setresgid32: c_long = 210; +pub const SYS_getresgid32: c_long = 211; +pub const SYS_chown32: c_long = 212; +pub const SYS_setuid32: c_long = 213; +pub const SYS_setgid32: c_long = 214; +pub const SYS_setfsuid32: c_long = 215; +pub const SYS_setfsgid32: c_long = 216; +pub const SYS_getdents64: c_long = 217; +pub const SYS_pivot_root: c_long = 218; +pub const SYS_mincore: c_long = 219; +pub const SYS_madvise: c_long = 220; +pub const SYS_fcntl64: c_long = 221; +pub const SYS_gettid: c_long = 224; +pub const SYS_readahead: c_long = 225; +pub const SYS_setxattr: c_long = 226; +pub const SYS_lsetxattr: c_long = 227; +pub const SYS_fsetxattr: c_long = 228; +pub const SYS_getxattr: c_long = 229; +pub const SYS_lgetxattr: c_long = 230; +pub const SYS_fgetxattr: c_long = 231; +pub const SYS_listxattr: c_long = 232; +pub const SYS_llistxattr: c_long = 233; +pub const SYS_flistxattr: c_long = 234; +pub const SYS_removexattr: c_long = 235; +pub const SYS_lremovexattr: c_long = 236; +pub const SYS_fremovexattr: c_long = 237; +pub const SYS_tkill: c_long = 238; +pub const SYS_sendfile64: c_long = 239; +pub const SYS_futex: c_long = 240; +pub const SYS_sched_setaffinity: c_long = 241; +pub const SYS_sched_getaffinity: c_long = 242; +pub const SYS_io_setup: c_long = 243; +pub const SYS_io_destroy: c_long = 244; +pub const SYS_io_getevents: c_long = 245; +pub const SYS_io_submit: c_long = 246; +pub const SYS_io_cancel: c_long = 247; +pub const SYS_exit_group: c_long = 248; +pub const SYS_lookup_dcookie: c_long = 249; +pub const SYS_epoll_create: c_long = 250; +pub const SYS_epoll_ctl: c_long = 251; +pub const SYS_epoll_wait: c_long = 252; +pub const SYS_remap_file_pages: c_long = 253; +pub const SYS_set_tid_address: c_long = 256; +pub const SYS_timer_create: c_long = 257; +pub const SYS_timer_settime: c_long = 258; +pub const SYS_timer_gettime: c_long = 259; +pub const SYS_timer_getoverrun: c_long = 260; +pub const SYS_timer_delete: c_long = 261; +pub const SYS_clock_settime: c_long = 262; +pub const SYS_clock_gettime: c_long = 263; +pub const SYS_clock_getres: c_long = 264; +pub const SYS_clock_nanosleep: c_long = 265; +pub const SYS_statfs64: c_long = 266; +pub const SYS_fstatfs64: c_long = 267; +pub const SYS_tgkill: c_long = 268; +pub const SYS_utimes: c_long = 269; +pub const SYS_arm_fadvise64_64: c_long = 270; +pub const SYS_pciconfig_iobase: c_long = 271; +pub const SYS_pciconfig_read: c_long = 272; +pub const SYS_pciconfig_write: c_long = 273; +pub const SYS_mq_open: c_long = 274; +pub const SYS_mq_unlink: c_long = 275; +pub const SYS_mq_timedsend: c_long = 276; +pub const SYS_mq_timedreceive: c_long = 277; +pub const SYS_mq_notify: c_long = 278; +pub const SYS_mq_getsetattr: c_long = 279; +pub const SYS_waitid: c_long = 280; +pub const SYS_socket: c_long = 281; +pub const SYS_bind: c_long = 282; +pub const SYS_connect: c_long = 283; +pub const SYS_listen: c_long = 284; +pub const SYS_accept: c_long = 285; +pub const SYS_getsockname: c_long = 286; +pub const SYS_getpeername: c_long = 287; +pub const SYS_socketpair: c_long = 288; +pub const SYS_send: c_long = 289; +pub const SYS_sendto: c_long = 290; +pub const SYS_recv: c_long = 291; +pub const SYS_recvfrom: c_long = 292; +pub const SYS_shutdown: c_long = 293; +pub const SYS_setsockopt: c_long = 294; +pub const SYS_getsockopt: c_long = 295; +pub const SYS_sendmsg: c_long = 296; +pub const SYS_recvmsg: c_long = 297; +pub const SYS_semop: c_long = 298; +pub const SYS_semget: c_long = 299; +pub const SYS_semctl: c_long = 300; +pub const SYS_msgsnd: c_long = 301; +pub const SYS_msgrcv: c_long = 302; +pub const SYS_msgget: c_long = 303; +pub const SYS_msgctl: c_long = 304; +pub const SYS_shmat: c_long = 305; +pub const SYS_shmdt: c_long = 306; +pub const SYS_shmget: c_long = 307; +pub const SYS_shmctl: c_long = 308; +pub const SYS_add_key: c_long = 309; +pub const SYS_request_key: c_long = 310; +pub const SYS_keyctl: c_long = 311; +pub const SYS_semtimedop: c_long = 312; +pub const SYS_vserver: c_long = 313; +pub const SYS_ioprio_set: c_long = 314; +pub const SYS_ioprio_get: c_long = 315; +pub const SYS_inotify_init: c_long = 316; +pub const SYS_inotify_add_watch: c_long = 317; +pub const SYS_inotify_rm_watch: c_long = 318; +pub const SYS_mbind: c_long = 319; +pub const SYS_get_mempolicy: c_long = 320; +pub const SYS_set_mempolicy: c_long = 321; +pub const SYS_openat: c_long = 322; +pub const SYS_mkdirat: c_long = 323; +pub const SYS_mknodat: c_long = 324; +pub const SYS_fchownat: c_long = 325; +pub const SYS_futimesat: c_long = 326; +pub const SYS_fstatat64: c_long = 327; +pub const SYS_unlinkat: c_long = 328; +pub const SYS_renameat: c_long = 329; +pub const SYS_linkat: c_long = 330; +pub const SYS_symlinkat: c_long = 331; +pub const SYS_readlinkat: c_long = 332; +pub const SYS_fchmodat: c_long = 333; +pub const SYS_faccessat: c_long = 334; +pub const SYS_pselect6: c_long = 335; +pub const SYS_ppoll: c_long = 336; +pub const SYS_unshare: c_long = 337; +pub const SYS_set_robust_list: c_long = 338; +pub const SYS_get_robust_list: c_long = 339; +pub const SYS_splice: c_long = 340; +pub const SYS_arm_sync_file_range: c_long = 341; +pub const SYS_tee: c_long = 342; +pub const SYS_vmsplice: c_long = 343; +pub const SYS_move_pages: c_long = 344; +pub const SYS_getcpu: c_long = 345; +pub const SYS_epoll_pwait: c_long = 346; +pub const SYS_kexec_load: c_long = 347; +pub const SYS_utimensat: c_long = 348; +pub const SYS_signalfd: c_long = 349; +pub const SYS_timerfd_create: c_long = 350; +pub const SYS_eventfd: c_long = 351; +pub const SYS_fallocate: c_long = 352; +pub const SYS_timerfd_settime: c_long = 353; +pub const SYS_timerfd_gettime: c_long = 354; +pub const SYS_signalfd4: c_long = 355; +pub const SYS_eventfd2: c_long = 356; +pub const SYS_epoll_create1: c_long = 357; +pub const SYS_dup3: c_long = 358; +pub const SYS_pipe2: c_long = 359; +pub const SYS_inotify_init1: c_long = 360; +pub const SYS_preadv: c_long = 361; +pub const SYS_pwritev: c_long = 362; +pub const SYS_rt_tgsigqueueinfo: c_long = 363; +pub const SYS_perf_event_open: c_long = 364; +pub const SYS_recvmmsg: c_long = 365; +pub const SYS_accept4: c_long = 366; +pub const SYS_fanotify_init: c_long = 367; +pub const SYS_fanotify_mark: c_long = 368; +pub const SYS_prlimit64: c_long = 369; +pub const SYS_name_to_handle_at: c_long = 370; +pub const SYS_open_by_handle_at: c_long = 371; +pub const SYS_clock_adjtime: c_long = 372; +pub const SYS_syncfs: c_long = 373; +pub const SYS_sendmmsg: c_long = 374; +pub const SYS_setns: c_long = 375; +pub const SYS_process_vm_readv: c_long = 376; +pub const SYS_process_vm_writev: c_long = 377; +pub const SYS_kcmp: c_long = 378; +pub const SYS_finit_module: c_long = 379; +pub const SYS_sched_setattr: c_long = 380; +pub const SYS_sched_getattr: c_long = 381; +pub const SYS_renameat2: c_long = 382; +pub const SYS_seccomp: c_long = 383; +pub const SYS_getrandom: c_long = 384; +pub const SYS_memfd_create: c_long = 385; +pub const SYS_bpf: c_long = 386; +pub const SYS_execveat: c_long = 387; +pub const SYS_userfaultfd: c_long = 388; +pub const SYS_membarrier: c_long = 389; +pub const SYS_mlock2: c_long = 390; +pub const SYS_copy_file_range: c_long = 391; +pub const SYS_preadv2: c_long = 392; +pub const SYS_pwritev2: c_long = 393; +pub const SYS_pkey_mprotect: c_long = 394; +pub const SYS_pkey_alloc: c_long = 395; +pub const SYS_pkey_free: c_long = 396; +pub const SYS_statx: c_long = 397; +pub const SYS_pidfd_send_signal: c_long = 424; +pub const SYS_io_uring_setup: c_long = 425; +pub const SYS_io_uring_enter: c_long = 426; +pub const SYS_io_uring_register: c_long = 427; +pub const SYS_open_tree: c_long = 428; +pub const SYS_move_mount: c_long = 429; +pub const SYS_fsopen: c_long = 430; +pub const SYS_fsconfig: c_long = 431; +pub const SYS_fsmount: c_long = 432; +pub const SYS_fspick: c_long = 433; +pub const SYS_pidfd_open: c_long = 434; +pub const SYS_clone3: c_long = 435; +pub const SYS_close_range: c_long = 436; +pub const SYS_openat2: c_long = 437; +pub const SYS_pidfd_getfd: c_long = 438; +pub const SYS_faccessat2: c_long = 439; +pub const SYS_process_madvise: c_long = 440; +pub const SYS_epoll_pwait2: c_long = 441; +pub const SYS_mount_setattr: c_long = 442; +pub const SYS_quotactl_fd: c_long = 443; +pub const SYS_landlock_create_ruleset: c_long = 444; +pub const SYS_landlock_add_rule: c_long = 445; +pub const SYS_landlock_restrict_self: c_long = 446; +pub const SYS_process_mrelease: c_long = 448; +pub const SYS_futex_waitv: c_long = 449; +pub const SYS_set_mempolicy_home_node: c_long = 450; + +// offsets in mcontext_t.gregs from sys/ucontext.h +pub const REG_R0: c_int = 0; +pub const REG_R1: c_int = 1; +pub const REG_R2: c_int = 2; +pub const REG_R3: c_int = 3; +pub const REG_R4: c_int = 4; +pub const REG_R5: c_int = 5; +pub const REG_R6: c_int = 6; +pub const REG_R7: c_int = 7; +pub const REG_R8: c_int = 8; +pub const REG_R9: c_int = 9; +pub const REG_R10: c_int = 10; +pub const REG_R11: c_int = 11; +pub const REG_R12: c_int = 12; +pub const REG_R13: c_int = 13; +pub const REG_R14: c_int = 14; +pub const REG_R15: c_int = 15; + +pub const NGREG: c_int = 18; + +// From NDK's asm/auxvec.h +pub const AT_SYSINFO_EHDR: c_ulong = 33; + +f! { + // Sadly, Android before 5.0 (API level 21), the accept4 syscall is not + // exposed by the libc. As work-around, we implement it through `syscall` + // directly. This workaround can be removed if the minimum version of + // Android is bumped. When the workaround is removed, `accept4` can be + // moved back to `linux_like/mod.rs` + pub fn accept4( + fd: c_int, + addr: *mut crate::sockaddr, + len: *mut crate::socklen_t, + flg: c_int, + ) -> c_int { + crate::syscall(SYS_accept4, fd, addr, len, flg) as c_int + } +} diff --git a/http/vendor/libc/src/unix/linux_like/android/b32/mod.rs b/http/vendor/libc/src/unix/linux_like/android/b32/mod.rs new file mode 100644 index 0000000..d0c2349 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/android/b32/mod.rs @@ -0,0 +1,239 @@ +use crate::prelude::*; + +// The following definitions are correct for arm and i686, +// but may be wrong for mips + +pub type mode_t = u16; +pub type off64_t = c_longlong; +pub type sigset_t = c_ulong; +pub type socklen_t = i32; +pub type time64_t = i64; +pub type __u64 = c_ulonglong; +pub type __s64 = c_longlong; + +s! { + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigaction { + pub sa_sigaction: crate::sighandler_t, + pub sa_mask: crate::sigset_t, + pub sa_flags: c_int, + pub sa_restorer: Option, + } + + pub struct rlimit64 { + pub rlim_cur: u64, + pub rlim_max: u64, + } + + pub struct stat { + pub st_dev: c_ulonglong, + __pad0: Padding<[c_uchar; 4]>, + __st_ino: crate::ino_t, + pub st_mode: c_uint, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: c_ulonglong, + __pad3: Padding<[c_uchar; 4]>, + pub st_size: c_longlong, + pub st_blksize: crate::blksize_t, + pub st_blocks: c_ulonglong, + pub st_atime: c_long, + pub st_atime_nsec: c_long, + pub st_mtime: c_long, + pub st_mtime_nsec: c_long, + pub st_ctime: c_long, + pub st_ctime_nsec: c_long, + pub st_ino: c_ulonglong, + } + + pub struct stat64 { + pub st_dev: c_ulonglong, + __pad0: Padding<[c_uchar; 4]>, + __st_ino: crate::ino_t, + pub st_mode: c_uint, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: c_ulonglong, + __pad3: Padding<[c_uchar; 4]>, + pub st_size: c_longlong, + pub st_blksize: crate::blksize_t, + pub st_blocks: c_ulonglong, + pub st_atime: c_long, + pub st_atime_nsec: c_long, + pub st_mtime: c_long, + pub st_mtime_nsec: c_long, + pub st_ctime: c_long, + pub st_ctime_nsec: c_long, + pub st_ino: c_ulonglong, + } + + pub struct statfs64 { + pub f_type: u32, + pub f_bsize: u32, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_fsid: crate::__fsid_t, + pub f_namelen: u32, + pub f_frsize: u32, + pub f_flags: u32, + pub f_spare: [u32; 4], + } + + pub struct statvfs64 { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: c_ulong, + pub f_bfree: c_ulong, + pub f_bavail: c_ulong, + pub f_files: c_ulong, + pub f_ffree: c_ulong, + pub f_favail: c_ulong, + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + } + + pub struct pthread_attr_t { + pub flags: u32, + pub stack_base: *mut c_void, + pub stack_size: size_t, + pub guard_size: size_t, + pub sched_policy: i32, + pub sched_priority: i32, + } + + pub struct pthread_mutex_t { + value: c_int, + } + + pub struct pthread_cond_t { + value: c_int, + } + + pub struct pthread_rwlock_t { + lock: pthread_mutex_t, + cond: pthread_cond_t, + numLocks: c_int, + writerThreadId: c_int, + pendingReaders: c_int, + pendingWriters: c_int, + attr: i32, + __reserved: Padding<[c_char; 12]>, + } + + pub struct pthread_barrier_t { + __private: [i32; 8], + } + + pub struct pthread_spinlock_t { + __private: [i32; 2], + } + + pub struct passwd { + pub pw_name: *mut c_char, + pub pw_passwd: *mut c_char, + pub pw_uid: crate::uid_t, + pub pw_gid: crate::gid_t, + pub pw_dir: *mut c_char, + pub pw_shell: *mut c_char, + } + + pub struct statfs { + pub f_type: u32, + pub f_bsize: u32, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_fsid: crate::__fsid_t, + pub f_namelen: u32, + pub f_frsize: u32, + pub f_flags: u32, + pub f_spare: [u32; 4], + } + + pub struct sysinfo { + pub uptime: c_long, + pub loads: [c_ulong; 3], + pub totalram: c_ulong, + pub freeram: c_ulong, + pub sharedram: c_ulong, + pub bufferram: c_ulong, + pub totalswap: c_ulong, + pub freeswap: c_ulong, + pub procs: c_ushort, + pub pad: c_ushort, + pub totalhigh: c_ulong, + pub freehigh: c_ulong, + pub mem_unit: c_uint, + pub _f: [c_char; 8], + } +} + +s_no_extra_traits! { + pub struct sigset64_t { + __bits: [c_ulong; 2], + } +} + +// These constants must be of the same type of sigaction.sa_flags +pub const SA_NOCLDSTOP: c_int = 0x00000001; +pub const SA_NOCLDWAIT: c_int = 0x00000002; +pub const SA_NODEFER: c_int = 0x40000000; +pub const SA_ONSTACK: c_int = 0x08000000; +pub const SA_RESETHAND: c_int = 0x80000000; +pub const SA_RESTART: c_int = 0x10000000; +pub const SA_SIGINFO: c_int = 0x00000004; + +pub const RTLD_GLOBAL: c_int = 2; +pub const RTLD_NOW: c_int = 0; +pub const RTLD_DEFAULT: *mut c_void = -1isize as *mut c_void; + +pub const PTRACE_GETFPREGS: c_int = 14; +pub const PTRACE_SETFPREGS: c_int = 15; + +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { value: 0 }; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { value: 0 }; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + lock: PTHREAD_MUTEX_INITIALIZER, + cond: PTHREAD_COND_INITIALIZER, + numLocks: 0, + writerThreadId: 0, + pendingReaders: 0, + pendingWriters: 0, + attr: 0, + __reserved: Padding::new([0; 12]), +}; +pub const PTHREAD_STACK_MIN: size_t = 4096 * 2; +pub const CPU_SETSIZE: size_t = 32; +pub const __CPU_BITS: size_t = 32; + +pub const UT_LINESIZE: usize = 8; +pub const UT_NAMESIZE: usize = 8; +pub const UT_HOSTSIZE: usize = 16; + +pub const SIGSTKSZ: size_t = 8192; +pub const MINSIGSTKSZ: size_t = 2048; + +extern "C" { + pub fn timegm64(tm: *const crate::tm) -> crate::time64_t; +} + +cfg_if! { + if #[cfg(target_arch = "x86")] { + mod x86; + pub use self::x86::*; + } else if #[cfg(target_arch = "arm")] { + mod arm; + pub use self::arm::*; + } else { + // Unknown target_arch + } +} diff --git a/http/vendor/libc/src/unix/linux_like/android/b32/x86/mod.rs b/http/vendor/libc/src/unix/linux_like/android/b32/x86/mod.rs new file mode 100644 index 0000000..7266cf2 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/android/b32/x86/mod.rs @@ -0,0 +1,568 @@ +use crate::prelude::*; + +pub type wchar_t = i32; +pub type greg_t = i32; + +s! { + pub struct _libc_fpreg { + pub significand: [u16; 4], + pub exponent: u16, + } + + pub struct _libc_fpstate { + pub cw: c_ulong, + pub sw: c_ulong, + pub tag: c_ulong, + pub ipoff: c_ulong, + pub cssel: c_ulong, + pub dataoff: c_ulong, + pub datasel: c_ulong, + pub _st: [_libc_fpreg; 8], + pub status: c_ulong, + } + + pub struct mcontext_t { + pub gregs: [greg_t; 19], + pub fpregs: *mut _libc_fpstate, + pub oldmask: c_ulong, + pub cr2: c_ulong, + } + + pub struct __c_anonymous_uc_sigmask_with_padding { + pub uc_sigmask: crate::sigset_t, + /* Android has a wrong (smaller) sigset_t on x86. */ + __padding_rt_sigset: Padding, + } + + pub struct ucontext_t { + pub uc_flags: c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: crate::stack_t, + pub uc_mcontext: mcontext_t, + pub uc_sigmask__c_anonymous_union: __c_anonymous_uc_sigmask, + __padding_rt_sigset: Padding, + __fpregs_mem: _libc_fpstate, + } +} + +s_no_extra_traits! { + pub union __c_anonymous_uc_sigmask { + uc_sigmask: __c_anonymous_uc_sigmask_with_padding, + uc_sigmask64: crate::sigset64_t, + } + + #[repr(align(8))] + pub struct max_align_t { + priv_: [f64; 2], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for __c_anonymous_uc_sigmask { + fn eq(&self, other: &__c_anonymous_uc_sigmask) -> bool { + unsafe { self.uc_sigmask == other.uc_sigmask } + } + } + impl Eq for __c_anonymous_uc_sigmask {} + impl hash::Hash for __c_anonymous_uc_sigmask { + fn hash(&self, state: &mut H) { + unsafe { self.uc_sigmask.hash(state) } + } + } + } +} + +pub const O_DIRECT: c_int = 0x4000; +pub const O_DIRECTORY: c_int = 0x10000; +pub const O_NOFOLLOW: c_int = 0x20000; +pub const O_LARGEFILE: c_int = 0o0100000; + +pub const MAP_32BIT: c_int = 0x40; + +// Syscall table +pub const SYS_restart_syscall: c_long = 0; +pub const SYS_exit: c_long = 1; +pub const SYS_fork: c_long = 2; +pub const SYS_read: c_long = 3; +pub const SYS_write: c_long = 4; +pub const SYS_open: c_long = 5; +pub const SYS_close: c_long = 6; +pub const SYS_waitpid: c_long = 7; +pub const SYS_creat: c_long = 8; +pub const SYS_link: c_long = 9; +pub const SYS_unlink: c_long = 10; +pub const SYS_execve: c_long = 11; +pub const SYS_chdir: c_long = 12; +pub const SYS_time: c_long = 13; +pub const SYS_mknod: c_long = 14; +pub const SYS_chmod: c_long = 15; +pub const SYS_lchown: c_long = 16; +pub const SYS_break: c_long = 17; +pub const SYS_oldstat: c_long = 18; +pub const SYS_lseek: c_long = 19; +pub const SYS_getpid: c_long = 20; +pub const SYS_mount: c_long = 21; +pub const SYS_umount: c_long = 22; +pub const SYS_setuid: c_long = 23; +pub const SYS_getuid: c_long = 24; +pub const SYS_stime: c_long = 25; +pub const SYS_ptrace: c_long = 26; +pub const SYS_alarm: c_long = 27; +pub const SYS_oldfstat: c_long = 28; +pub const SYS_pause: c_long = 29; +pub const SYS_utime: c_long = 30; +pub const SYS_stty: c_long = 31; +pub const SYS_gtty: c_long = 32; +pub const SYS_access: c_long = 33; +pub const SYS_nice: c_long = 34; +pub const SYS_ftime: c_long = 35; +pub const SYS_sync: c_long = 36; +pub const SYS_kill: c_long = 37; +pub const SYS_rename: c_long = 38; +pub const SYS_mkdir: c_long = 39; +pub const SYS_rmdir: c_long = 40; +pub const SYS_dup: c_long = 41; +pub const SYS_pipe: c_long = 42; +pub const SYS_times: c_long = 43; +pub const SYS_prof: c_long = 44; +pub const SYS_brk: c_long = 45; +pub const SYS_setgid: c_long = 46; +pub const SYS_getgid: c_long = 47; +pub const SYS_signal: c_long = 48; +pub const SYS_geteuid: c_long = 49; +pub const SYS_getegid: c_long = 50; +pub const SYS_acct: c_long = 51; +pub const SYS_umount2: c_long = 52; +pub const SYS_lock: c_long = 53; +pub const SYS_ioctl: c_long = 54; +pub const SYS_fcntl: c_long = 55; +pub const SYS_mpx: c_long = 56; +pub const SYS_setpgid: c_long = 57; +pub const SYS_ulimit: c_long = 58; +pub const SYS_oldolduname: c_long = 59; +pub const SYS_umask: c_long = 60; +pub const SYS_chroot: c_long = 61; +pub const SYS_ustat: c_long = 62; +pub const SYS_dup2: c_long = 63; +pub const SYS_getppid: c_long = 64; +pub const SYS_getpgrp: c_long = 65; +pub const SYS_setsid: c_long = 66; +pub const SYS_sigaction: c_long = 67; +pub const SYS_sgetmask: c_long = 68; +pub const SYS_ssetmask: c_long = 69; +pub const SYS_setreuid: c_long = 70; +pub const SYS_setregid: c_long = 71; +pub const SYS_sigsuspend: c_long = 72; +pub const SYS_sigpending: c_long = 73; +pub const SYS_sethostname: c_long = 74; +pub const SYS_setrlimit: c_long = 75; +pub const SYS_getrlimit: c_long = 76; +pub const SYS_getrusage: c_long = 77; +pub const SYS_gettimeofday: c_long = 78; +pub const SYS_settimeofday: c_long = 79; +pub const SYS_getgroups: c_long = 80; +pub const SYS_setgroups: c_long = 81; +pub const SYS_select: c_long = 82; +pub const SYS_symlink: c_long = 83; +pub const SYS_oldlstat: c_long = 84; +pub const SYS_readlink: c_long = 85; +pub const SYS_uselib: c_long = 86; +pub const SYS_swapon: c_long = 87; +pub const SYS_reboot: c_long = 88; +pub const SYS_readdir: c_long = 89; +pub const SYS_mmap: c_long = 90; +pub const SYS_munmap: c_long = 91; +pub const SYS_truncate: c_long = 92; +pub const SYS_ftruncate: c_long = 93; +pub const SYS_fchmod: c_long = 94; +pub const SYS_fchown: c_long = 95; +pub const SYS_getpriority: c_long = 96; +pub const SYS_setpriority: c_long = 97; +pub const SYS_profil: c_long = 98; +pub const SYS_statfs: c_long = 99; +pub const SYS_fstatfs: c_long = 100; +pub const SYS_ioperm: c_long = 101; +pub const SYS_socketcall: c_long = 102; +pub const SYS_syslog: c_long = 103; +pub const SYS_setitimer: c_long = 104; +pub const SYS_getitimer: c_long = 105; +pub const SYS_stat: c_long = 106; +pub const SYS_lstat: c_long = 107; +pub const SYS_fstat: c_long = 108; +pub const SYS_olduname: c_long = 109; +pub const SYS_iopl: c_long = 110; +pub const SYS_vhangup: c_long = 111; +pub const SYS_idle: c_long = 112; +pub const SYS_vm86old: c_long = 113; +pub const SYS_wait4: c_long = 114; +pub const SYS_swapoff: c_long = 115; +pub const SYS_sysinfo: c_long = 116; +pub const SYS_ipc: c_long = 117; +pub const SYS_fsync: c_long = 118; +pub const SYS_sigreturn: c_long = 119; +pub const SYS_clone: c_long = 120; +pub const SYS_setdomainname: c_long = 121; +pub const SYS_uname: c_long = 122; +pub const SYS_modify_ldt: c_long = 123; +pub const SYS_adjtimex: c_long = 124; +pub const SYS_mprotect: c_long = 125; +pub const SYS_sigprocmask: c_long = 126; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_create_module: c_long = 127; +pub const SYS_init_module: c_long = 128; +pub const SYS_delete_module: c_long = 129; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_get_kernel_syms: c_long = 130; +pub const SYS_quotactl: c_long = 131; +pub const SYS_getpgid: c_long = 132; +pub const SYS_fchdir: c_long = 133; +pub const SYS_bdflush: c_long = 134; +pub const SYS_sysfs: c_long = 135; +pub const SYS_personality: c_long = 136; +pub const SYS_afs_syscall: c_long = 137; +pub const SYS_setfsuid: c_long = 138; +pub const SYS_setfsgid: c_long = 139; +// FIXME(android): SYS__llseek is in the NDK sources but for some reason is +// not available in the tests +// pub const SYS__llseek: c_long = 140; +pub const SYS_getdents: c_long = 141; +// FIXME(android): SYS__newselect is in the NDK sources but for some reason is +// not available in the tests +// pub const SYS__newselect: c_long = 142; +pub const SYS_flock: c_long = 143; +pub const SYS_msync: c_long = 144; +pub const SYS_readv: c_long = 145; +pub const SYS_writev: c_long = 146; +pub const SYS_getsid: c_long = 147; +pub const SYS_fdatasync: c_long = 148; +// FIXME(android): SYS__llseek is in the NDK sources but for some reason is +// not available in the tests +// pub const SYS__sysctl: c_long = 149; +pub const SYS_mlock: c_long = 150; +pub const SYS_munlock: c_long = 151; +pub const SYS_mlockall: c_long = 152; +pub const SYS_munlockall: c_long = 153; +pub const SYS_sched_setparam: c_long = 154; +pub const SYS_sched_getparam: c_long = 155; +pub const SYS_sched_setscheduler: c_long = 156; +pub const SYS_sched_getscheduler: c_long = 157; +pub const SYS_sched_yield: c_long = 158; +pub const SYS_sched_get_priority_max: c_long = 159; +pub const SYS_sched_get_priority_min: c_long = 160; +pub const SYS_sched_rr_get_interval: c_long = 161; +pub const SYS_nanosleep: c_long = 162; +pub const SYS_mremap: c_long = 163; +pub const SYS_setresuid: c_long = 164; +pub const SYS_getresuid: c_long = 165; +pub const SYS_vm86: c_long = 166; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_query_module: c_long = 167; +pub const SYS_poll: c_long = 168; +pub const SYS_nfsservctl: c_long = 169; +pub const SYS_setresgid: c_long = 170; +pub const SYS_getresgid: c_long = 171; +pub const SYS_prctl: c_long = 172; +pub const SYS_rt_sigreturn: c_long = 173; +pub const SYS_rt_sigaction: c_long = 174; +pub const SYS_rt_sigprocmask: c_long = 175; +pub const SYS_rt_sigpending: c_long = 176; +pub const SYS_rt_sigtimedwait: c_long = 177; +pub const SYS_rt_sigqueueinfo: c_long = 178; +pub const SYS_rt_sigsuspend: c_long = 179; +pub const SYS_pread64: c_long = 180; +pub const SYS_pwrite64: c_long = 181; +pub const SYS_chown: c_long = 182; +pub const SYS_getcwd: c_long = 183; +pub const SYS_capget: c_long = 184; +pub const SYS_capset: c_long = 185; +pub const SYS_sigaltstack: c_long = 186; +pub const SYS_sendfile: c_long = 187; +pub const SYS_getpmsg: c_long = 188; +pub const SYS_putpmsg: c_long = 189; +pub const SYS_vfork: c_long = 190; +pub const SYS_ugetrlimit: c_long = 191; +pub const SYS_mmap2: c_long = 192; +pub const SYS_truncate64: c_long = 193; +pub const SYS_ftruncate64: c_long = 194; +pub const SYS_stat64: c_long = 195; +pub const SYS_lstat64: c_long = 196; +pub const SYS_fstat64: c_long = 197; +pub const SYS_lchown32: c_long = 198; +pub const SYS_getuid32: c_long = 199; +pub const SYS_getgid32: c_long = 200; +pub const SYS_geteuid32: c_long = 201; +pub const SYS_getegid32: c_long = 202; +pub const SYS_setreuid32: c_long = 203; +pub const SYS_setregid32: c_long = 204; +pub const SYS_getgroups32: c_long = 205; +pub const SYS_setgroups32: c_long = 206; +pub const SYS_fchown32: c_long = 207; +pub const SYS_setresuid32: c_long = 208; +pub const SYS_getresuid32: c_long = 209; +pub const SYS_setresgid32: c_long = 210; +pub const SYS_getresgid32: c_long = 211; +pub const SYS_chown32: c_long = 212; +pub const SYS_setuid32: c_long = 213; +pub const SYS_setgid32: c_long = 214; +pub const SYS_setfsuid32: c_long = 215; +pub const SYS_setfsgid32: c_long = 216; +pub const SYS_pivot_root: c_long = 217; +pub const SYS_mincore: c_long = 218; +pub const SYS_madvise: c_long = 219; +pub const SYS_getdents64: c_long = 220; +pub const SYS_fcntl64: c_long = 221; +pub const SYS_gettid: c_long = 224; +pub const SYS_readahead: c_long = 225; +pub const SYS_setxattr: c_long = 226; +pub const SYS_lsetxattr: c_long = 227; +pub const SYS_fsetxattr: c_long = 228; +pub const SYS_getxattr: c_long = 229; +pub const SYS_lgetxattr: c_long = 230; +pub const SYS_fgetxattr: c_long = 231; +pub const SYS_listxattr: c_long = 232; +pub const SYS_llistxattr: c_long = 233; +pub const SYS_flistxattr: c_long = 234; +pub const SYS_removexattr: c_long = 235; +pub const SYS_lremovexattr: c_long = 236; +pub const SYS_fremovexattr: c_long = 237; +pub const SYS_tkill: c_long = 238; +pub const SYS_sendfile64: c_long = 239; +pub const SYS_futex: c_long = 240; +pub const SYS_sched_setaffinity: c_long = 241; +pub const SYS_sched_getaffinity: c_long = 242; +pub const SYS_set_thread_area: c_long = 243; +pub const SYS_get_thread_area: c_long = 244; +pub const SYS_io_setup: c_long = 245; +pub const SYS_io_destroy: c_long = 246; +pub const SYS_io_getevents: c_long = 247; +pub const SYS_io_submit: c_long = 248; +pub const SYS_io_cancel: c_long = 249; +pub const SYS_fadvise64: c_long = 250; +pub const SYS_exit_group: c_long = 252; +pub const SYS_lookup_dcookie: c_long = 253; +pub const SYS_epoll_create: c_long = 254; +pub const SYS_epoll_ctl: c_long = 255; +pub const SYS_epoll_wait: c_long = 256; +pub const SYS_remap_file_pages: c_long = 257; +pub const SYS_set_tid_address: c_long = 258; +pub const SYS_timer_create: c_long = 259; +pub const SYS_timer_settime: c_long = 260; +pub const SYS_timer_gettime: c_long = 261; +pub const SYS_timer_getoverrun: c_long = 262; +pub const SYS_timer_delete: c_long = 263; +pub const SYS_clock_settime: c_long = 264; +pub const SYS_clock_gettime: c_long = 265; +pub const SYS_clock_getres: c_long = 266; +pub const SYS_clock_nanosleep: c_long = 267; +pub const SYS_statfs64: c_long = 268; +pub const SYS_fstatfs64: c_long = 269; +pub const SYS_tgkill: c_long = 270; +pub const SYS_utimes: c_long = 271; +pub const SYS_fadvise64_64: c_long = 272; +pub const SYS_vserver: c_long = 273; +pub const SYS_mbind: c_long = 274; +pub const SYS_get_mempolicy: c_long = 275; +pub const SYS_set_mempolicy: c_long = 276; +pub const SYS_mq_open: c_long = 277; +pub const SYS_mq_unlink: c_long = 278; +pub const SYS_mq_timedsend: c_long = 279; +pub const SYS_mq_timedreceive: c_long = 280; +pub const SYS_mq_notify: c_long = 281; +pub const SYS_mq_getsetattr: c_long = 282; +pub const SYS_kexec_load: c_long = 283; +pub const SYS_waitid: c_long = 284; +pub const SYS_add_key: c_long = 286; +pub const SYS_request_key: c_long = 287; +pub const SYS_keyctl: c_long = 288; +pub const SYS_ioprio_set: c_long = 289; +pub const SYS_ioprio_get: c_long = 290; +pub const SYS_inotify_init: c_long = 291; +pub const SYS_inotify_add_watch: c_long = 292; +pub const SYS_inotify_rm_watch: c_long = 293; +pub const SYS_migrate_pages: c_long = 294; +pub const SYS_openat: c_long = 295; +pub const SYS_mkdirat: c_long = 296; +pub const SYS_mknodat: c_long = 297; +pub const SYS_fchownat: c_long = 298; +pub const SYS_futimesat: c_long = 299; +pub const SYS_fstatat64: c_long = 300; +pub const SYS_unlinkat: c_long = 301; +pub const SYS_renameat: c_long = 302; +pub const SYS_linkat: c_long = 303; +pub const SYS_symlinkat: c_long = 304; +pub const SYS_readlinkat: c_long = 305; +pub const SYS_fchmodat: c_long = 306; +pub const SYS_faccessat: c_long = 307; +pub const SYS_pselect6: c_long = 308; +pub const SYS_ppoll: c_long = 309; +pub const SYS_unshare: c_long = 310; +pub const SYS_set_robust_list: c_long = 311; +pub const SYS_get_robust_list: c_long = 312; +pub const SYS_splice: c_long = 313; +pub const SYS_sync_file_range: c_long = 314; +pub const SYS_tee: c_long = 315; +pub const SYS_vmsplice: c_long = 316; +pub const SYS_move_pages: c_long = 317; +pub const SYS_getcpu: c_long = 318; +pub const SYS_epoll_pwait: c_long = 319; +pub const SYS_utimensat: c_long = 320; +pub const SYS_signalfd: c_long = 321; +pub const SYS_timerfd_create: c_long = 322; +pub const SYS_eventfd: c_long = 323; +pub const SYS_fallocate: c_long = 324; +pub const SYS_timerfd_settime: c_long = 325; +pub const SYS_timerfd_gettime: c_long = 326; +pub const SYS_signalfd4: c_long = 327; +pub const SYS_eventfd2: c_long = 328; +pub const SYS_epoll_create1: c_long = 329; +pub const SYS_dup3: c_long = 330; +pub const SYS_pipe2: c_long = 331; +pub const SYS_inotify_init1: c_long = 332; +pub const SYS_preadv: c_long = 333; +pub const SYS_pwritev: c_long = 334; +pub const SYS_rt_tgsigqueueinfo: c_long = 335; +pub const SYS_perf_event_open: c_long = 336; +pub const SYS_recvmmsg: c_long = 337; +pub const SYS_fanotify_init: c_long = 338; +pub const SYS_fanotify_mark: c_long = 339; +pub const SYS_prlimit64: c_long = 340; +pub const SYS_name_to_handle_at: c_long = 341; +pub const SYS_open_by_handle_at: c_long = 342; +pub const SYS_clock_adjtime: c_long = 343; +pub const SYS_syncfs: c_long = 344; +pub const SYS_sendmmsg: c_long = 345; +pub const SYS_setns: c_long = 346; +pub const SYS_process_vm_readv: c_long = 347; +pub const SYS_process_vm_writev: c_long = 348; +pub const SYS_kcmp: c_long = 349; +pub const SYS_finit_module: c_long = 350; +pub const SYS_sched_setattr: c_long = 351; +pub const SYS_sched_getattr: c_long = 352; +pub const SYS_renameat2: c_long = 353; +pub const SYS_seccomp: c_long = 354; +pub const SYS_getrandom: c_long = 355; +pub const SYS_memfd_create: c_long = 356; +pub const SYS_bpf: c_long = 357; +pub const SYS_execveat: c_long = 358; +pub const SYS_socket: c_long = 359; +pub const SYS_socketpair: c_long = 360; +pub const SYS_bind: c_long = 361; +pub const SYS_connect: c_long = 362; +pub const SYS_listen: c_long = 363; +pub const SYS_accept4: c_long = 364; +pub const SYS_getsockopt: c_long = 365; +pub const SYS_setsockopt: c_long = 366; +pub const SYS_getsockname: c_long = 367; +pub const SYS_getpeername: c_long = 368; +pub const SYS_sendto: c_long = 369; +pub const SYS_sendmsg: c_long = 370; +pub const SYS_recvfrom: c_long = 371; +pub const SYS_recvmsg: c_long = 372; +pub const SYS_shutdown: c_long = 373; +pub const SYS_userfaultfd: c_long = 374; +pub const SYS_membarrier: c_long = 375; +pub const SYS_mlock2: c_long = 376; +pub const SYS_copy_file_range: c_long = 377; +pub const SYS_preadv2: c_long = 378; +pub const SYS_pwritev2: c_long = 379; +pub const SYS_pkey_mprotect: c_long = 380; +pub const SYS_pkey_alloc: c_long = 381; +pub const SYS_pkey_free: c_long = 382; +pub const SYS_statx: c_long = 383; +pub const SYS_pidfd_send_signal: c_long = 424; +pub const SYS_io_uring_setup: c_long = 425; +pub const SYS_io_uring_enter: c_long = 426; +pub const SYS_io_uring_register: c_long = 427; +pub const SYS_open_tree: c_long = 428; +pub const SYS_move_mount: c_long = 429; +pub const SYS_fsopen: c_long = 430; +pub const SYS_fsconfig: c_long = 431; +pub const SYS_fsmount: c_long = 432; +pub const SYS_fspick: c_long = 433; +pub const SYS_pidfd_open: c_long = 434; +pub const SYS_clone3: c_long = 435; +pub const SYS_close_range: c_long = 436; +pub const SYS_openat2: c_long = 437; +pub const SYS_pidfd_getfd: c_long = 438; +pub const SYS_faccessat2: c_long = 439; +pub const SYS_process_madvise: c_long = 440; +pub const SYS_epoll_pwait2: c_long = 441; +pub const SYS_mount_setattr: c_long = 442; +pub const SYS_quotactl_fd: c_long = 443; +pub const SYS_landlock_create_ruleset: c_long = 444; +pub const SYS_landlock_add_rule: c_long = 445; +pub const SYS_landlock_restrict_self: c_long = 446; +pub const SYS_memfd_secret: c_long = 447; +pub const SYS_process_mrelease: c_long = 448; +pub const SYS_futex_waitv: c_long = 449; +pub const SYS_set_mempolicy_home_node: c_long = 450; + +// offsets in user_regs_structs, from sys/reg.h +pub const EBX: c_int = 0; +pub const ECX: c_int = 1; +pub const EDX: c_int = 2; +pub const ESI: c_int = 3; +pub const EDI: c_int = 4; +pub const EBP: c_int = 5; +pub const EAX: c_int = 6; +pub const DS: c_int = 7; +pub const ES: c_int = 8; +pub const FS: c_int = 9; +pub const GS: c_int = 10; +pub const ORIG_EAX: c_int = 11; +pub const EIP: c_int = 12; +pub const CS: c_int = 13; +pub const EFL: c_int = 14; +pub const UESP: c_int = 15; +pub const SS: c_int = 16; + +// offsets in mcontext_t.gregs from sys/ucontext.h +pub const REG_GS: c_int = 0; +pub const REG_FS: c_int = 1; +pub const REG_ES: c_int = 2; +pub const REG_DS: c_int = 3; +pub const REG_EDI: c_int = 4; +pub const REG_ESI: c_int = 5; +pub const REG_EBP: c_int = 6; +pub const REG_ESP: c_int = 7; +pub const REG_EBX: c_int = 8; +pub const REG_EDX: c_int = 9; +pub const REG_ECX: c_int = 10; +pub const REG_EAX: c_int = 11; +pub const REG_TRAPNO: c_int = 12; +pub const REG_ERR: c_int = 13; +pub const REG_EIP: c_int = 14; +pub const REG_CS: c_int = 15; +pub const REG_EFL: c_int = 16; +pub const REG_UESP: c_int = 17; +pub const REG_SS: c_int = 18; + +// From NDK's asm/auxvec.h +pub const AT_SYSINFO: c_ulong = 32; +pub const AT_SYSINFO_EHDR: c_ulong = 33; +pub const AT_VECTOR_SIZE_ARCH: c_ulong = 3; + +// socketcall values from linux/net.h (only the needed ones, and not public) +const SYS_ACCEPT4: c_int = 18; + +f! { + // Sadly, Android before 5.0 (API level 21), the accept4 syscall is not + // exposed by the libc. As work-around, we implement it as raw syscall. + // Note that for x86, the `accept4` syscall is not available either, + // and we must use the `socketcall` syscall instead. + // This workaround can be removed if the minimum Android version is bumped. + // When the workaround is removed, `accept4` can be moved back + // to `linux_like/mod.rs` + pub fn accept4( + fd: c_int, + addr: *mut crate::sockaddr, + len: *mut crate::socklen_t, + flg: c_int, + ) -> c_int { + // Arguments are passed as array of `long int` + // (which is big enough on x86 for a pointer). + let mut args = [fd as c_long, addr as c_long, len as c_long, flg as c_long]; + crate::syscall(SYS_socketcall, SYS_ACCEPT4, args[..].as_mut_ptr()) + } +} diff --git a/http/vendor/libc/src/unix/linux_like/android/b64/aarch64/mod.rs b/http/vendor/libc/src/unix/linux_like/android/b64/aarch64/mod.rs new file mode 100644 index 0000000..3cc6fc8 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/android/b64/aarch64/mod.rs @@ -0,0 +1,473 @@ +use crate::off64_t; +use crate::prelude::*; + +pub type wchar_t = u32; +pub type __u64 = c_ulonglong; +pub type __s64 = c_longlong; + +s! { + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_mode: c_uint, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + __pad1: Padding, + pub st_size: off64_t, + pub st_blksize: c_int, + __pad2: Padding, + pub st_blocks: c_long, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + __unused4: Padding, + __unused5: Padding, + } + + pub struct stat64 { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_mode: c_uint, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + __pad1: Padding, + pub st_size: off64_t, + pub st_blksize: c_int, + __pad2: Padding, + pub st_blocks: c_long, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + __unused4: Padding, + __unused5: Padding, + } + + pub struct user_regs_struct { + pub regs: [u64; 31], + pub sp: u64, + pub pc: u64, + pub pstate: u64, + } + + pub struct ucontext_t { + pub uc_flags: c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: crate::stack_t, + pub uc_sigmask: crate::sigset_t, + pub uc_mcontext: mcontext_t, + } + + #[repr(align(16))] + pub struct mcontext_t { + pub fault_address: c_ulonglong, + pub regs: [c_ulonglong; 31], + pub sp: c_ulonglong, + pub pc: c_ulonglong, + pub pstate: c_ulonglong, + __reserved: Padding<[u64; 512]>, + } + + pub struct user_fpsimd_struct { + pub vregs: [u128; 32], + pub fpsr: u32, + pub fpcr: u32, + } +} + +s_no_extra_traits! { + #[repr(align(16))] + pub struct max_align_t { + priv_: [f32; 8], + } +} + +pub const O_DIRECT: c_int = 0x10000; +pub const O_DIRECTORY: c_int = 0x4000; +pub const O_NOFOLLOW: c_int = 0x8000; +pub const O_LARGEFILE: c_int = 0o400000; + +pub const SIGSTKSZ: size_t = 16384; +pub const MINSIGSTKSZ: size_t = 5120; + +// From NDK's asm/hwcap.h +pub const HWCAP_FP: c_ulong = 1 << 0; +pub const HWCAP_ASIMD: c_ulong = 1 << 1; +pub const HWCAP_EVTSTRM: c_ulong = 1 << 2; +pub const HWCAP_AES: c_ulong = 1 << 3; +pub const HWCAP_PMULL: c_ulong = 1 << 4; +pub const HWCAP_SHA1: c_ulong = 1 << 5; +pub const HWCAP_SHA2: c_ulong = 1 << 6; +pub const HWCAP_CRC32: c_ulong = 1 << 7; +pub const HWCAP_ATOMICS: c_ulong = 1 << 8; +pub const HWCAP_FPHP: c_ulong = 1 << 9; +pub const HWCAP_ASIMDHP: c_ulong = 1 << 10; +pub const HWCAP_CPUID: c_ulong = 1 << 11; +pub const HWCAP_ASIMDRDM: c_ulong = 1 << 12; +pub const HWCAP_JSCVT: c_ulong = 1 << 13; +pub const HWCAP_FCMA: c_ulong = 1 << 14; +pub const HWCAP_LRCPC: c_ulong = 1 << 15; +pub const HWCAP_DCPOP: c_ulong = 1 << 16; +pub const HWCAP_SHA3: c_ulong = 1 << 17; +pub const HWCAP_SM3: c_ulong = 1 << 18; +pub const HWCAP_SM4: c_ulong = 1 << 19; +pub const HWCAP_ASIMDDP: c_ulong = 1 << 20; +pub const HWCAP_SHA512: c_ulong = 1 << 21; +pub const HWCAP_SVE: c_ulong = 1 << 22; +pub const HWCAP_ASIMDFHM: c_ulong = 1 << 23; +pub const HWCAP_DIT: c_ulong = 1 << 24; +pub const HWCAP_USCAT: c_ulong = 1 << 25; +pub const HWCAP_ILRCPC: c_ulong = 1 << 26; +pub const HWCAP_FLAGM: c_ulong = 1 << 27; +pub const HWCAP_SSBS: c_ulong = 1 << 28; +pub const HWCAP_SB: c_ulong = 1 << 29; +pub const HWCAP_PACA: c_ulong = 1 << 30; +pub const HWCAP_PACG: c_ulong = 1 << 31; +pub const HWCAP2_DCPODP: c_ulong = 1 << 0; +pub const HWCAP2_SVE2: c_ulong = 1 << 1; +pub const HWCAP2_SVEAES: c_ulong = 1 << 2; +pub const HWCAP2_SVEPMULL: c_ulong = 1 << 3; +pub const HWCAP2_SVEBITPERM: c_ulong = 1 << 4; +pub const HWCAP2_SVESHA3: c_ulong = 1 << 5; +pub const HWCAP2_SVESM4: c_ulong = 1 << 6; +pub const HWCAP2_FLAGM2: c_ulong = 1 << 7; +pub const HWCAP2_FRINT: c_ulong = 1 << 8; +pub const HWCAP2_SVEI8MM: c_ulong = 1 << 9; +pub const HWCAP2_SVEF32MM: c_ulong = 1 << 10; +pub const HWCAP2_SVEF64MM: c_ulong = 1 << 11; +pub const HWCAP2_SVEBF16: c_ulong = 1 << 12; +pub const HWCAP2_I8MM: c_ulong = 1 << 13; +pub const HWCAP2_BF16: c_ulong = 1 << 14; +pub const HWCAP2_DGH: c_ulong = 1 << 15; +pub const HWCAP2_RNG: c_ulong = 1 << 16; +pub const HWCAP2_BTI: c_ulong = 1 << 17; +pub const HWCAP2_MTE: c_ulong = 1 << 18; +pub const HWCAP2_ECV: c_ulong = 1 << 19; +pub const HWCAP2_AFP: c_ulong = 1 << 20; +pub const HWCAP2_RPRES: c_ulong = 1 << 21; +pub const HWCAP2_MTE3: c_ulong = 1 << 22; +pub const HWCAP2_SME: c_ulong = 1 << 23; +pub const HWCAP2_SME_I16I64: c_ulong = 1 << 24; +pub const HWCAP2_SME_F64F64: c_ulong = 1 << 25; +pub const HWCAP2_SME_I8I32: c_ulong = 1 << 26; +pub const HWCAP2_SME_F16F32: c_ulong = 1 << 27; +pub const HWCAP2_SME_B16F32: c_ulong = 1 << 28; +pub const HWCAP2_SME_F32F32: c_ulong = 1 << 29; +pub const HWCAP2_SME_FA64: c_ulong = 1 << 30; +pub const HWCAP2_WFXT: c_ulong = 1 << 31; +pub const HWCAP2_EBF16: c_ulong = 1 << 32; +pub const HWCAP2_SVE_EBF16: c_ulong = 1 << 33; + +pub const SYS_io_setup: c_long = 0; +pub const SYS_io_destroy: c_long = 1; +pub const SYS_io_submit: c_long = 2; +pub const SYS_io_cancel: c_long = 3; +pub const SYS_io_getevents: c_long = 4; +pub const SYS_setxattr: c_long = 5; +pub const SYS_lsetxattr: c_long = 6; +pub const SYS_fsetxattr: c_long = 7; +pub const SYS_getxattr: c_long = 8; +pub const SYS_lgetxattr: c_long = 9; +pub const SYS_fgetxattr: c_long = 10; +pub const SYS_listxattr: c_long = 11; +pub const SYS_llistxattr: c_long = 12; +pub const SYS_flistxattr: c_long = 13; +pub const SYS_removexattr: c_long = 14; +pub const SYS_lremovexattr: c_long = 15; +pub const SYS_fremovexattr: c_long = 16; +pub const SYS_getcwd: c_long = 17; +pub const SYS_lookup_dcookie: c_long = 18; +pub const SYS_eventfd2: c_long = 19; +pub const SYS_epoll_create1: c_long = 20; +pub const SYS_epoll_ctl: c_long = 21; +pub const SYS_epoll_pwait: c_long = 22; +pub const SYS_dup: c_long = 23; +pub const SYS_dup3: c_long = 24; +pub const SYS_fcntl: c_long = 25; +pub const SYS_inotify_init1: c_long = 26; +pub const SYS_inotify_add_watch: c_long = 27; +pub const SYS_inotify_rm_watch: c_long = 28; +pub const SYS_ioctl: c_long = 29; +pub const SYS_ioprio_set: c_long = 30; +pub const SYS_ioprio_get: c_long = 31; +pub const SYS_flock: c_long = 32; +pub const SYS_mknodat: c_long = 33; +pub const SYS_mkdirat: c_long = 34; +pub const SYS_unlinkat: c_long = 35; +pub const SYS_symlinkat: c_long = 36; +pub const SYS_linkat: c_long = 37; +pub const SYS_renameat: c_long = 38; +pub const SYS_umount2: c_long = 39; +pub const SYS_mount: c_long = 40; +pub const SYS_pivot_root: c_long = 41; +pub const SYS_nfsservctl: c_long = 42; +pub const SYS_fallocate: c_long = 47; +pub const SYS_faccessat: c_long = 48; +pub const SYS_chdir: c_long = 49; +pub const SYS_fchdir: c_long = 50; +pub const SYS_chroot: c_long = 51; +pub const SYS_fchmod: c_long = 52; +pub const SYS_fchmodat: c_long = 53; +pub const SYS_fchownat: c_long = 54; +pub const SYS_fchown: c_long = 55; +pub const SYS_openat: c_long = 56; +pub const SYS_close: c_long = 57; +pub const SYS_vhangup: c_long = 58; +pub const SYS_pipe2: c_long = 59; +pub const SYS_quotactl: c_long = 60; +pub const SYS_getdents64: c_long = 61; +pub const SYS_lseek: c_long = 62; +pub const SYS_read: c_long = 63; +pub const SYS_write: c_long = 64; +pub const SYS_readv: c_long = 65; +pub const SYS_writev: c_long = 66; +pub const SYS_pread64: c_long = 67; +pub const SYS_pwrite64: c_long = 68; +pub const SYS_preadv: c_long = 69; +pub const SYS_pwritev: c_long = 70; +pub const SYS_pselect6: c_long = 72; +pub const SYS_ppoll: c_long = 73; +pub const SYS_signalfd4: c_long = 74; +pub const SYS_vmsplice: c_long = 75; +pub const SYS_splice: c_long = 76; +pub const SYS_tee: c_long = 77; +pub const SYS_readlinkat: c_long = 78; +pub const SYS_sync: c_long = 81; +pub const SYS_fsync: c_long = 82; +pub const SYS_fdatasync: c_long = 83; +pub const SYS_sync_file_range: c_long = 84; +pub const SYS_timerfd_create: c_long = 85; +pub const SYS_timerfd_settime: c_long = 86; +pub const SYS_timerfd_gettime: c_long = 87; +pub const SYS_utimensat: c_long = 88; +pub const SYS_acct: c_long = 89; +pub const SYS_capget: c_long = 90; +pub const SYS_capset: c_long = 91; +pub const SYS_personality: c_long = 92; +pub const SYS_exit: c_long = 93; +pub const SYS_exit_group: c_long = 94; +pub const SYS_waitid: c_long = 95; +pub const SYS_set_tid_address: c_long = 96; +pub const SYS_unshare: c_long = 97; +pub const SYS_futex: c_long = 98; +pub const SYS_set_robust_list: c_long = 99; +pub const SYS_get_robust_list: c_long = 100; +pub const SYS_nanosleep: c_long = 101; +pub const SYS_getitimer: c_long = 102; +pub const SYS_setitimer: c_long = 103; +pub const SYS_kexec_load: c_long = 104; +pub const SYS_init_module: c_long = 105; +pub const SYS_delete_module: c_long = 106; +pub const SYS_timer_create: c_long = 107; +pub const SYS_timer_gettime: c_long = 108; +pub const SYS_timer_getoverrun: c_long = 109; +pub const SYS_timer_settime: c_long = 110; +pub const SYS_timer_delete: c_long = 111; +pub const SYS_clock_settime: c_long = 112; +pub const SYS_clock_gettime: c_long = 113; +pub const SYS_clock_getres: c_long = 114; +pub const SYS_clock_nanosleep: c_long = 115; +pub const SYS_syslog: c_long = 116; +pub const SYS_ptrace: c_long = 117; +pub const SYS_sched_setparam: c_long = 118; +pub const SYS_sched_setscheduler: c_long = 119; +pub const SYS_sched_getscheduler: c_long = 120; +pub const SYS_sched_getparam: c_long = 121; +pub const SYS_sched_setaffinity: c_long = 122; +pub const SYS_sched_getaffinity: c_long = 123; +pub const SYS_sched_yield: c_long = 124; +pub const SYS_sched_get_priority_max: c_long = 125; +pub const SYS_sched_get_priority_min: c_long = 126; +pub const SYS_sched_rr_get_interval: c_long = 127; +pub const SYS_restart_syscall: c_long = 128; +pub const SYS_kill: c_long = 129; +pub const SYS_tkill: c_long = 130; +pub const SYS_tgkill: c_long = 131; +pub const SYS_sigaltstack: c_long = 132; +pub const SYS_rt_sigsuspend: c_long = 133; +pub const SYS_rt_sigaction: c_long = 134; +pub const SYS_rt_sigprocmask: c_long = 135; +pub const SYS_rt_sigpending: c_long = 136; +pub const SYS_rt_sigtimedwait: c_long = 137; +pub const SYS_rt_sigqueueinfo: c_long = 138; +pub const SYS_rt_sigreturn: c_long = 139; +pub const SYS_setpriority: c_long = 140; +pub const SYS_getpriority: c_long = 141; +pub const SYS_reboot: c_long = 142; +pub const SYS_setregid: c_long = 143; +pub const SYS_setgid: c_long = 144; +pub const SYS_setreuid: c_long = 145; +pub const SYS_setuid: c_long = 146; +pub const SYS_setresuid: c_long = 147; +pub const SYS_getresuid: c_long = 148; +pub const SYS_setresgid: c_long = 149; +pub const SYS_getresgid: c_long = 150; +pub const SYS_setfsuid: c_long = 151; +pub const SYS_setfsgid: c_long = 152; +pub const SYS_times: c_long = 153; +pub const SYS_setpgid: c_long = 154; +pub const SYS_getpgid: c_long = 155; +pub const SYS_getsid: c_long = 156; +pub const SYS_setsid: c_long = 157; +pub const SYS_getgroups: c_long = 158; +pub const SYS_setgroups: c_long = 159; +pub const SYS_uname: c_long = 160; +pub const SYS_sethostname: c_long = 161; +pub const SYS_setdomainname: c_long = 162; +pub const SYS_getrlimit: c_long = 163; +pub const SYS_setrlimit: c_long = 164; +pub const SYS_getrusage: c_long = 165; +pub const SYS_umask: c_long = 166; +pub const SYS_prctl: c_long = 167; +pub const SYS_getcpu: c_long = 168; +pub const SYS_gettimeofday: c_long = 169; +pub const SYS_settimeofday: c_long = 170; +pub const SYS_adjtimex: c_long = 171; +pub const SYS_getpid: c_long = 172; +pub const SYS_getppid: c_long = 173; +pub const SYS_getuid: c_long = 174; +pub const SYS_geteuid: c_long = 175; +pub const SYS_getgid: c_long = 176; +pub const SYS_getegid: c_long = 177; +pub const SYS_gettid: c_long = 178; +pub const SYS_sysinfo: c_long = 179; +pub const SYS_mq_open: c_long = 180; +pub const SYS_mq_unlink: c_long = 181; +pub const SYS_mq_timedsend: c_long = 182; +pub const SYS_mq_timedreceive: c_long = 183; +pub const SYS_mq_notify: c_long = 184; +pub const SYS_mq_getsetattr: c_long = 185; +pub const SYS_msgget: c_long = 186; +pub const SYS_msgctl: c_long = 187; +pub const SYS_msgrcv: c_long = 188; +pub const SYS_msgsnd: c_long = 189; +pub const SYS_semget: c_long = 190; +pub const SYS_semctl: c_long = 191; +pub const SYS_semtimedop: c_long = 192; +pub const SYS_semop: c_long = 193; +pub const SYS_shmget: c_long = 194; +pub const SYS_shmctl: c_long = 195; +pub const SYS_shmat: c_long = 196; +pub const SYS_shmdt: c_long = 197; +pub const SYS_socket: c_long = 198; +pub const SYS_socketpair: c_long = 199; +pub const SYS_bind: c_long = 200; +pub const SYS_listen: c_long = 201; +pub const SYS_accept: c_long = 202; +pub const SYS_connect: c_long = 203; +pub const SYS_getsockname: c_long = 204; +pub const SYS_getpeername: c_long = 205; +pub const SYS_sendto: c_long = 206; +pub const SYS_recvfrom: c_long = 207; +pub const SYS_setsockopt: c_long = 208; +pub const SYS_getsockopt: c_long = 209; +pub const SYS_shutdown: c_long = 210; +pub const SYS_sendmsg: c_long = 211; +pub const SYS_recvmsg: c_long = 212; +pub const SYS_readahead: c_long = 213; +pub const SYS_brk: c_long = 214; +pub const SYS_munmap: c_long = 215; +pub const SYS_mremap: c_long = 216; +pub const SYS_add_key: c_long = 217; +pub const SYS_request_key: c_long = 218; +pub const SYS_keyctl: c_long = 219; +pub const SYS_clone: c_long = 220; +pub const SYS_execve: c_long = 221; +pub const SYS_mmap: c_long = 222; +pub const SYS_swapon: c_long = 224; +pub const SYS_swapoff: c_long = 225; +pub const SYS_mprotect: c_long = 226; +pub const SYS_msync: c_long = 227; +pub const SYS_mlock: c_long = 228; +pub const SYS_munlock: c_long = 229; +pub const SYS_mlockall: c_long = 230; +pub const SYS_munlockall: c_long = 231; +pub const SYS_mincore: c_long = 232; +pub const SYS_madvise: c_long = 233; +pub const SYS_remap_file_pages: c_long = 234; +pub const SYS_mbind: c_long = 235; +pub const SYS_get_mempolicy: c_long = 236; +pub const SYS_set_mempolicy: c_long = 237; +pub const SYS_migrate_pages: c_long = 238; +pub const SYS_move_pages: c_long = 239; +pub const SYS_rt_tgsigqueueinfo: c_long = 240; +pub const SYS_perf_event_open: c_long = 241; +pub const SYS_accept4: c_long = 242; +pub const SYS_recvmmsg: c_long = 243; +pub const SYS_arch_specific_syscall: c_long = 244; +pub const SYS_wait4: c_long = 260; +pub const SYS_prlimit64: c_long = 261; +pub const SYS_fanotify_init: c_long = 262; +pub const SYS_fanotify_mark: c_long = 263; +pub const SYS_name_to_handle_at: c_long = 264; +pub const SYS_open_by_handle_at: c_long = 265; +pub const SYS_clock_adjtime: c_long = 266; +pub const SYS_syncfs: c_long = 267; +pub const SYS_setns: c_long = 268; +pub const SYS_sendmmsg: c_long = 269; +pub const SYS_process_vm_readv: c_long = 270; +pub const SYS_process_vm_writev: c_long = 271; +pub const SYS_kcmp: c_long = 272; +pub const SYS_finit_module: c_long = 273; +pub const SYS_sched_setattr: c_long = 274; +pub const SYS_sched_getattr: c_long = 275; +pub const SYS_renameat2: c_long = 276; +pub const SYS_seccomp: c_long = 277; +pub const SYS_getrandom: c_long = 278; +pub const SYS_memfd_create: c_long = 279; +pub const SYS_bpf: c_long = 280; +pub const SYS_execveat: c_long = 281; +pub const SYS_userfaultfd: c_long = 282; +pub const SYS_membarrier: c_long = 283; +pub const SYS_mlock2: c_long = 284; +pub const SYS_copy_file_range: c_long = 285; +pub const SYS_preadv2: c_long = 286; +pub const SYS_pwritev2: c_long = 287; +pub const SYS_pkey_mprotect: c_long = 288; +pub const SYS_pkey_alloc: c_long = 289; +pub const SYS_pkey_free: c_long = 290; +pub const SYS_statx: c_long = 291; +pub const SYS_pidfd_send_signal: c_long = 424; +pub const SYS_io_uring_setup: c_long = 425; +pub const SYS_io_uring_enter: c_long = 426; +pub const SYS_io_uring_register: c_long = 427; +pub const SYS_open_tree: c_long = 428; +pub const SYS_move_mount: c_long = 429; +pub const SYS_fsopen: c_long = 430; +pub const SYS_fsconfig: c_long = 431; +pub const SYS_fsmount: c_long = 432; +pub const SYS_fspick: c_long = 433; +pub const SYS_pidfd_open: c_long = 434; +pub const SYS_clone3: c_long = 435; +pub const SYS_close_range: c_long = 436; +pub const SYS_openat2: c_long = 437; +pub const SYS_pidfd_getfd: c_long = 438; +pub const SYS_faccessat2: c_long = 439; +pub const SYS_process_madvise: c_long = 440; +pub const SYS_epoll_pwait2: c_long = 441; +pub const SYS_mount_setattr: c_long = 442; +pub const SYS_quotactl_fd: c_long = 443; +pub const SYS_landlock_create_ruleset: c_long = 444; +pub const SYS_landlock_add_rule: c_long = 445; +pub const SYS_landlock_restrict_self: c_long = 446; +pub const SYS_memfd_secret: c_long = 447; +pub const SYS_process_mrelease: c_long = 448; +pub const SYS_futex_waitv: c_long = 449; +pub const SYS_set_mempolicy_home_node: c_long = 450; +pub const SYS_syscalls: c_long = 451; + +pub const PROT_BTI: c_int = 0x10; +pub const PROT_MTE: c_int = 0x20; + +// From NDK's asm/auxvec.h +pub const AT_SYSINFO_EHDR: c_ulong = 33; +pub const AT_VECTOR_SIZE_ARCH: c_ulong = 2; diff --git a/http/vendor/libc/src/unix/linux_like/android/b64/mod.rs b/http/vendor/libc/src/unix/linux_like/android/b64/mod.rs new file mode 100644 index 0000000..84c35a5 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/android/b64/mod.rs @@ -0,0 +1,218 @@ +use crate::prelude::*; + +// The following definitions are correct for aarch64 and x86_64, +// but may be wrong for mips64 + +pub type mode_t = u32; +pub type off64_t = i64; +pub type socklen_t = u32; + +s! { + pub struct sigset_t { + __val: [c_ulong; 1], + } + + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigaction { + pub sa_flags: c_int, + pub sa_sigaction: crate::sighandler_t, + pub sa_mask: crate::sigset_t, + pub sa_restorer: Option, + } + + pub struct rlimit64 { + pub rlim_cur: c_ulonglong, + pub rlim_max: c_ulonglong, + } + + pub struct pthread_attr_t { + pub flags: u32, + pub stack_base: *mut c_void, + pub stack_size: size_t, + pub guard_size: size_t, + pub sched_policy: i32, + pub sched_priority: i32, + __reserved: Padding<[c_char; 16]>, + } + + pub struct passwd { + pub pw_name: *mut c_char, + pub pw_passwd: *mut c_char, + pub pw_uid: crate::uid_t, + pub pw_gid: crate::gid_t, + pub pw_gecos: *mut c_char, + pub pw_dir: *mut c_char, + pub pw_shell: *mut c_char, + } + + pub struct statfs { + pub f_type: u64, + pub f_bsize: u64, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_fsid: crate::__fsid_t, + pub f_namelen: u64, + pub f_frsize: u64, + pub f_flags: u64, + pub f_spare: [u64; 4], + } + + pub struct sysinfo { + pub uptime: c_long, + pub loads: [c_ulong; 3], + pub totalram: c_ulong, + pub freeram: c_ulong, + pub sharedram: c_ulong, + pub bufferram: c_ulong, + pub totalswap: c_ulong, + pub freeswap: c_ulong, + pub procs: c_ushort, + pub pad: c_ushort, + pub totalhigh: c_ulong, + pub freehigh: c_ulong, + pub mem_unit: c_uint, + pub _f: [c_char; 0], + } + + pub struct statfs64 { + pub f_type: u64, + pub f_bsize: u64, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_fsid: crate::__fsid_t, + pub f_namelen: u64, + pub f_frsize: u64, + pub f_flags: u64, + pub f_spare: [u64; 4], + } + + pub struct statvfs64 { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: [c_int; 6], + } + + pub struct pthread_barrier_t { + __private: [i64; 4], + } + + pub struct pthread_spinlock_t { + __private: i64, + } + + pub struct pthread_mutex_t { + value: c_int, + __reserved: Padding<[c_char; 36]>, + } + + pub struct pthread_cond_t { + value: c_int, + __reserved: Padding<[c_char; 44]>, + } + + pub struct pthread_rwlock_t { + numLocks: c_int, + writerThreadId: c_int, + pendingReaders: c_int, + pendingWriters: c_int, + attr: i32, + __reserved: Padding<[c_char; 36]>, + } + + pub struct sigset64_t { + __bits: [c_ulong; 1], + } +} + +// These constants must be of the same type of sigaction.sa_flags +pub const SA_NOCLDSTOP: c_int = 0x00000001; +pub const SA_NOCLDWAIT: c_int = 0x00000002; +pub const SA_NODEFER: c_int = 0x40000000; +pub const SA_ONSTACK: c_int = 0x08000000; +pub const SA_RESETHAND: c_int = 0x80000000; +pub const SA_RESTART: c_int = 0x10000000; +pub const SA_SIGINFO: c_int = 0x00000004; + +pub const RTLD_GLOBAL: c_int = 0x00100; +pub const RTLD_NOW: c_int = 2; +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); + +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + value: 0, + __reserved: Padding::new([0; 36]), +}; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + value: 0, + __reserved: Padding::new([0; 44]), +}; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + numLocks: 0, + writerThreadId: 0, + pendingReaders: 0, + pendingWriters: 0, + attr: 0, + __reserved: Padding::new([0; 36]), +}; +pub const PTHREAD_STACK_MIN: size_t = 4096 * 4; +pub const CPU_SETSIZE: size_t = 1024; +pub const __CPU_BITS: size_t = 64; + +pub const UT_LINESIZE: usize = 32; +pub const UT_NAMESIZE: usize = 32; +pub const UT_HOSTSIZE: usize = 256; + +f! { + // Sadly, Android before 5.0 (API level 21), the accept4 syscall is not + // exposed by the libc. As work-around, we implement it through `syscall` + // directly. This workaround can be removed if the minimum version of + // Android is bumped. When the workaround is removed, `accept4` can be + // moved back to `linux_like/mod.rs` + pub fn accept4( + fd: c_int, + addr: *mut crate::sockaddr, + len: *mut crate::socklen_t, + flg: c_int, + ) -> c_int { + crate::syscall(SYS_accept4, fd, addr, len, flg) as c_int + } +} + +extern "C" { + pub fn __system_property_wait( + pi: *const crate::prop_info, + __old_serial: u32, + __new_serial_ptr: *mut u32, + __relative_timeout: *const crate::timespec, + ) -> bool; +} + +cfg_if! { + if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } else if #[cfg(target_arch = "aarch64")] { + mod aarch64; + pub use self::aarch64::*; + } else if #[cfg(target_arch = "riscv64")] { + mod riscv64; + pub use self::riscv64::*; + } else { + // Unknown target_arch + } +} diff --git a/http/vendor/libc/src/unix/linux_like/android/b64/riscv64/mod.rs b/http/vendor/libc/src/unix/linux_like/android/b64/riscv64/mod.rs new file mode 100644 index 0000000..dded129 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/android/b64/riscv64/mod.rs @@ -0,0 +1,384 @@ +use crate::off64_t; +use crate::prelude::*; + +pub type wchar_t = u32; +pub type greg_t = i64; +pub type __u64 = c_ulonglong; +pub type __s64 = c_longlong; + +s! { + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_mode: c_uint, + pub st_nlink: c_uint, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + __pad1: Padding, + pub st_size: off64_t, + pub st_blksize: c_int, + __pad2: Padding, + pub st_blocks: c_long, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + __unused4: Padding, + __unused5: Padding, + } + + pub struct stat64 { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_mode: c_uint, + pub st_nlink: c_uint, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + __pad1: Padding, + pub st_size: off64_t, + pub st_blksize: c_int, + __pad2: Padding, + pub st_blocks: c_long, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + __unused4: Padding, + __unused5: Padding, + } +} + +s_no_extra_traits! { + #[repr(align(16))] + pub struct max_align_t { + priv_: [f32; 8], + } +} + +pub const O_DIRECT: c_int = 0x40000; +pub const O_DIRECTORY: c_int = 0x200000; +pub const O_NOFOLLOW: c_int = 0x400000; +pub const O_LARGEFILE: c_int = 0x100000; + +pub const SIGSTKSZ: size_t = 8192; +pub const MINSIGSTKSZ: size_t = 2048; + +// From NDK's asm/hwcap.h +pub const COMPAT_HWCAP_ISA_I: c_ulong = 1 << (b'I' - b'A'); +pub const COMPAT_HWCAP_ISA_M: c_ulong = 1 << (b'M' - b'A'); +pub const COMPAT_HWCAP_ISA_A: c_ulong = 1 << (b'A' - b'A'); +pub const COMPAT_HWCAP_ISA_F: c_ulong = 1 << (b'F' - b'A'); +pub const COMPAT_HWCAP_ISA_D: c_ulong = 1 << (b'D' - b'A'); +pub const COMPAT_HWCAP_ISA_C: c_ulong = 1 << (b'C' - b'A'); + +pub const SYS_io_setup: c_long = 0; +pub const SYS_io_destroy: c_long = 1; +pub const SYS_io_submit: c_long = 2; +pub const SYS_io_cancel: c_long = 3; +pub const SYS_io_getevents: c_long = 4; +pub const SYS_setxattr: c_long = 5; +pub const SYS_lsetxattr: c_long = 6; +pub const SYS_fsetxattr: c_long = 7; +pub const SYS_getxattr: c_long = 8; +pub const SYS_lgetxattr: c_long = 9; +pub const SYS_fgetxattr: c_long = 10; +pub const SYS_listxattr: c_long = 11; +pub const SYS_llistxattr: c_long = 12; +pub const SYS_flistxattr: c_long = 13; +pub const SYS_removexattr: c_long = 14; +pub const SYS_lremovexattr: c_long = 15; +pub const SYS_fremovexattr: c_long = 16; +pub const SYS_getcwd: c_long = 17; +pub const SYS_lookup_dcookie: c_long = 18; +pub const SYS_eventfd2: c_long = 19; +pub const SYS_epoll_create1: c_long = 20; +pub const SYS_epoll_ctl: c_long = 21; +pub const SYS_epoll_pwait: c_long = 22; +pub const SYS_dup: c_long = 23; +pub const SYS_dup3: c_long = 24; +pub const SYS_inotify_init1: c_long = 26; +pub const SYS_inotify_add_watch: c_long = 27; +pub const SYS_inotify_rm_watch: c_long = 28; +pub const SYS_ioctl: c_long = 29; +pub const SYS_ioprio_set: c_long = 30; +pub const SYS_ioprio_get: c_long = 31; +pub const SYS_flock: c_long = 32; +pub const SYS_mknodat: c_long = 33; +pub const SYS_mkdirat: c_long = 34; +pub const SYS_unlinkat: c_long = 35; +pub const SYS_symlinkat: c_long = 36; +pub const SYS_linkat: c_long = 37; +pub const SYS_renameat: c_long = 38; +pub const SYS_umount2: c_long = 39; +pub const SYS_mount: c_long = 40; +pub const SYS_pivot_root: c_long = 41; +pub const SYS_nfsservctl: c_long = 42; +pub const SYS_fallocate: c_long = 47; +pub const SYS_faccessat: c_long = 48; +pub const SYS_chdir: c_long = 49; +pub const SYS_fchdir: c_long = 50; +pub const SYS_chroot: c_long = 51; +pub const SYS_fchmod: c_long = 52; +pub const SYS_fchmodat: c_long = 53; +pub const SYS_fchownat: c_long = 54; +pub const SYS_fchown: c_long = 55; +pub const SYS_openat: c_long = 56; +pub const SYS_close: c_long = 57; +pub const SYS_vhangup: c_long = 58; +pub const SYS_pipe2: c_long = 59; +pub const SYS_quotactl: c_long = 60; +pub const SYS_getdents64: c_long = 61; +pub const SYS_read: c_long = 63; +pub const SYS_write: c_long = 64; +pub const SYS_readv: c_long = 65; +pub const SYS_writev: c_long = 66; +pub const SYS_pread64: c_long = 67; +pub const SYS_pwrite64: c_long = 68; +pub const SYS_preadv: c_long = 69; +pub const SYS_pwritev: c_long = 70; +pub const SYS_pselect6: c_long = 72; +pub const SYS_ppoll: c_long = 73; +pub const SYS_signalfd4: c_long = 74; +pub const SYS_vmsplice: c_long = 75; +pub const SYS_splice: c_long = 76; +pub const SYS_tee: c_long = 77; +pub const SYS_readlinkat: c_long = 78; +pub const SYS_sync: c_long = 81; +pub const SYS_fsync: c_long = 82; +pub const SYS_fdatasync: c_long = 83; +pub const SYS_sync_file_range: c_long = 84; +pub const SYS_timerfd_create: c_long = 85; +pub const SYS_timerfd_settime: c_long = 86; +pub const SYS_timerfd_gettime: c_long = 87; +pub const SYS_utimensat: c_long = 88; +pub const SYS_acct: c_long = 89; +pub const SYS_capget: c_long = 90; +pub const SYS_capset: c_long = 91; +pub const SYS_personality: c_long = 92; +pub const SYS_exit: c_long = 93; +pub const SYS_exit_group: c_long = 94; +pub const SYS_waitid: c_long = 95; +pub const SYS_set_tid_address: c_long = 96; +pub const SYS_unshare: c_long = 97; +pub const SYS_futex: c_long = 98; +pub const SYS_set_robust_list: c_long = 99; +pub const SYS_get_robust_list: c_long = 100; +pub const SYS_nanosleep: c_long = 101; +pub const SYS_getitimer: c_long = 102; +pub const SYS_setitimer: c_long = 103; +pub const SYS_kexec_load: c_long = 104; +pub const SYS_init_module: c_long = 105; +pub const SYS_delete_module: c_long = 106; +pub const SYS_timer_create: c_long = 107; +pub const SYS_timer_gettime: c_long = 108; +pub const SYS_timer_getoverrun: c_long = 109; +pub const SYS_timer_settime: c_long = 110; +pub const SYS_timer_delete: c_long = 111; +pub const SYS_clock_settime: c_long = 112; +pub const SYS_clock_gettime: c_long = 113; +pub const SYS_clock_getres: c_long = 114; +pub const SYS_clock_nanosleep: c_long = 115; +pub const SYS_syslog: c_long = 116; +pub const SYS_ptrace: c_long = 117; +pub const SYS_sched_setparam: c_long = 118; +pub const SYS_sched_setscheduler: c_long = 119; +pub const SYS_sched_getscheduler: c_long = 120; +pub const SYS_sched_getparam: c_long = 121; +pub const SYS_sched_setaffinity: c_long = 122; +pub const SYS_sched_getaffinity: c_long = 123; +pub const SYS_sched_yield: c_long = 124; +pub const SYS_sched_get_priority_max: c_long = 125; +pub const SYS_sched_get_priority_min: c_long = 126; +pub const SYS_sched_rr_get_interval: c_long = 127; +pub const SYS_restart_syscall: c_long = 128; +pub const SYS_kill: c_long = 129; +pub const SYS_tkill: c_long = 130; +pub const SYS_tgkill: c_long = 131; +pub const SYS_sigaltstack: c_long = 132; +pub const SYS_rt_sigsuspend: c_long = 133; +pub const SYS_rt_sigaction: c_long = 134; +pub const SYS_rt_sigprocmask: c_long = 135; +pub const SYS_rt_sigpending: c_long = 136; +pub const SYS_rt_sigtimedwait: c_long = 137; +pub const SYS_rt_sigqueueinfo: c_long = 138; +pub const SYS_rt_sigreturn: c_long = 139; +pub const SYS_setpriority: c_long = 140; +pub const SYS_getpriority: c_long = 141; +pub const SYS_reboot: c_long = 142; +pub const SYS_setregid: c_long = 143; +pub const SYS_setgid: c_long = 144; +pub const SYS_setreuid: c_long = 145; +pub const SYS_setuid: c_long = 146; +pub const SYS_setresuid: c_long = 147; +pub const SYS_getresuid: c_long = 148; +pub const SYS_setresgid: c_long = 149; +pub const SYS_getresgid: c_long = 150; +pub const SYS_setfsuid: c_long = 151; +pub const SYS_setfsgid: c_long = 152; +pub const SYS_times: c_long = 153; +pub const SYS_setpgid: c_long = 154; +pub const SYS_getpgid: c_long = 155; +pub const SYS_getsid: c_long = 156; +pub const SYS_setsid: c_long = 157; +pub const SYS_getgroups: c_long = 158; +pub const SYS_setgroups: c_long = 159; +pub const SYS_uname: c_long = 160; +pub const SYS_sethostname: c_long = 161; +pub const SYS_setdomainname: c_long = 162; +pub const SYS_getrlimit: c_long = 163; +pub const SYS_setrlimit: c_long = 164; +pub const SYS_getrusage: c_long = 165; +pub const SYS_umask: c_long = 166; +pub const SYS_prctl: c_long = 167; +pub const SYS_getcpu: c_long = 168; +pub const SYS_gettimeofday: c_long = 169; +pub const SYS_settimeofday: c_long = 170; +pub const SYS_adjtimex: c_long = 171; +pub const SYS_getpid: c_long = 172; +pub const SYS_getppid: c_long = 173; +pub const SYS_getuid: c_long = 174; +pub const SYS_geteuid: c_long = 175; +pub const SYS_getgid: c_long = 176; +pub const SYS_getegid: c_long = 177; +pub const SYS_gettid: c_long = 178; +pub const SYS_sysinfo: c_long = 179; +pub const SYS_mq_open: c_long = 180; +pub const SYS_mq_unlink: c_long = 181; +pub const SYS_mq_timedsend: c_long = 182; +pub const SYS_mq_timedreceive: c_long = 183; +pub const SYS_mq_notify: c_long = 184; +pub const SYS_mq_getsetattr: c_long = 185; +pub const SYS_msgget: c_long = 186; +pub const SYS_msgctl: c_long = 187; +pub const SYS_msgrcv: c_long = 188; +pub const SYS_msgsnd: c_long = 189; +pub const SYS_semget: c_long = 190; +pub const SYS_semctl: c_long = 191; +pub const SYS_semtimedop: c_long = 192; +pub const SYS_semop: c_long = 193; +pub const SYS_shmget: c_long = 194; +pub const SYS_shmctl: c_long = 195; +pub const SYS_shmat: c_long = 196; +pub const SYS_shmdt: c_long = 197; +pub const SYS_socket: c_long = 198; +pub const SYS_socketpair: c_long = 199; +pub const SYS_bind: c_long = 200; +pub const SYS_listen: c_long = 201; +pub const SYS_accept: c_long = 202; +pub const SYS_connect: c_long = 203; +pub const SYS_getsockname: c_long = 204; +pub const SYS_getpeername: c_long = 205; +pub const SYS_sendto: c_long = 206; +pub const SYS_recvfrom: c_long = 207; +pub const SYS_setsockopt: c_long = 208; +pub const SYS_getsockopt: c_long = 209; +pub const SYS_shutdown: c_long = 210; +pub const SYS_sendmsg: c_long = 211; +pub const SYS_recvmsg: c_long = 212; +pub const SYS_readahead: c_long = 213; +pub const SYS_brk: c_long = 214; +pub const SYS_munmap: c_long = 215; +pub const SYS_mremap: c_long = 216; +pub const SYS_add_key: c_long = 217; +pub const SYS_request_key: c_long = 218; +pub const SYS_keyctl: c_long = 219; +pub const SYS_clone: c_long = 220; +pub const SYS_execve: c_long = 221; +pub const SYS_swapon: c_long = 224; +pub const SYS_swapoff: c_long = 225; +pub const SYS_mprotect: c_long = 226; +pub const SYS_msync: c_long = 227; +pub const SYS_mlock: c_long = 228; +pub const SYS_munlock: c_long = 229; +pub const SYS_mlockall: c_long = 230; +pub const SYS_munlockall: c_long = 231; +pub const SYS_mincore: c_long = 232; +pub const SYS_madvise: c_long = 233; +pub const SYS_remap_file_pages: c_long = 234; +pub const SYS_mbind: c_long = 235; +pub const SYS_get_mempolicy: c_long = 236; +pub const SYS_set_mempolicy: c_long = 237; +pub const SYS_migrate_pages: c_long = 238; +pub const SYS_move_pages: c_long = 239; +pub const SYS_rt_tgsigqueueinfo: c_long = 240; +pub const SYS_perf_event_open: c_long = 241; +pub const SYS_accept4: c_long = 242; +pub const SYS_recvmmsg: c_long = 243; +pub const SYS_arch_specific_syscall: c_long = 244; +pub const SYS_wait4: c_long = 260; +pub const SYS_prlimit64: c_long = 261; +pub const SYS_fanotify_init: c_long = 262; +pub const SYS_fanotify_mark: c_long = 263; +pub const SYS_name_to_handle_at: c_long = 264; +pub const SYS_open_by_handle_at: c_long = 265; +pub const SYS_clock_adjtime: c_long = 266; +pub const SYS_syncfs: c_long = 267; +pub const SYS_setns: c_long = 268; +pub const SYS_sendmmsg: c_long = 269; +pub const SYS_process_vm_readv: c_long = 270; +pub const SYS_process_vm_writev: c_long = 271; +pub const SYS_kcmp: c_long = 272; +pub const SYS_finit_module: c_long = 273; +pub const SYS_sched_setattr: c_long = 274; +pub const SYS_sched_getattr: c_long = 275; +pub const SYS_renameat2: c_long = 276; +pub const SYS_seccomp: c_long = 277; +pub const SYS_getrandom: c_long = 278; +pub const SYS_memfd_create: c_long = 279; +pub const SYS_bpf: c_long = 280; +pub const SYS_execveat: c_long = 281; +pub const SYS_userfaultfd: c_long = 282; +pub const SYS_membarrier: c_long = 283; +pub const SYS_mlock2: c_long = 284; +pub const SYS_copy_file_range: c_long = 285; +pub const SYS_preadv2: c_long = 286; +pub const SYS_pwritev2: c_long = 287; +pub const SYS_pkey_mprotect: c_long = 288; +pub const SYS_pkey_alloc: c_long = 289; +pub const SYS_pkey_free: c_long = 290; +pub const SYS_statx: c_long = 291; +pub const SYS_pidfd_send_signal: c_long = 424; +pub const SYS_io_uring_setup: c_long = 425; +pub const SYS_io_uring_enter: c_long = 426; +pub const SYS_io_uring_register: c_long = 427; +pub const SYS_open_tree: c_long = 428; +pub const SYS_move_mount: c_long = 429; +pub const SYS_fsopen: c_long = 430; +pub const SYS_fsconfig: c_long = 431; +pub const SYS_fsmount: c_long = 432; +pub const SYS_fspick: c_long = 433; +pub const SYS_pidfd_open: c_long = 434; +pub const SYS_clone3: c_long = 435; +pub const SYS_close_range: c_long = 436; +pub const SYS_openat2: c_long = 437; +pub const SYS_pidfd_getfd: c_long = 438; +pub const SYS_faccessat2: c_long = 439; +pub const SYS_process_madvise: c_long = 440; +pub const SYS_epoll_pwait2: c_long = 441; +pub const SYS_mount_setattr: c_long = 442; +pub const SYS_quotactl_fd: c_long = 443; +pub const SYS_landlock_create_ruleset: c_long = 444; +pub const SYS_landlock_add_rule: c_long = 445; +pub const SYS_landlock_restrict_self: c_long = 446; +pub const SYS_memfd_secret: c_long = 447; +pub const SYS_process_mrelease: c_long = 448; +pub const SYS_futex_waitv: c_long = 449; +pub const SYS_set_mempolicy_home_node: c_long = 450; + +// From NDK's asm/auxvec.h +pub const AT_SYSINFO_EHDR: c_ulong = 33; +pub const AT_L1I_CACHESIZE: c_ulong = 40; +pub const AT_L1I_CACHEGEOMETRY: c_ulong = 41; +pub const AT_L1D_CACHESIZE: c_ulong = 42; +pub const AT_L1D_CACHEGEOMETRY: c_ulong = 43; +pub const AT_L2_CACHESIZE: c_ulong = 44; +pub const AT_L2_CACHEGEOMETRY: c_ulong = 45; +pub const AT_L3_CACHESIZE: c_ulong = 46; +pub const AT_L3_CACHEGEOMETRY: c_ulong = 47; +pub const AT_VECTOR_SIZE_ARCH: c_ulong = 9; diff --git a/http/vendor/libc/src/unix/linux_like/android/b64/x86_64/mod.rs b/http/vendor/libc/src/unix/linux_like/android/b64/x86_64/mod.rs new file mode 100644 index 0000000..0f3b741 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/android/b64/x86_64/mod.rs @@ -0,0 +1,620 @@ +use crate::off64_t; +use crate::prelude::*; + +pub type wchar_t = i32; +pub type greg_t = i64; +pub type __u64 = c_ulonglong; +pub type __s64 = c_longlong; + +s! { + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_nlink: c_ulong, + pub st_mode: c_uint, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + pub st_size: off64_t, + pub st_blksize: c_long, + pub st_blocks: c_long, + pub st_atime: c_long, + pub st_atime_nsec: c_long, + pub st_mtime: c_long, + pub st_mtime_nsec: c_long, + pub st_ctime: c_long, + pub st_ctime_nsec: c_long, + __unused: Padding<[c_long; 3]>, + } + + pub struct stat64 { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_nlink: c_ulong, + pub st_mode: c_uint, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + pub st_size: off64_t, + pub st_blksize: c_long, + pub st_blocks: c_long, + pub st_atime: c_long, + pub st_atime_nsec: c_long, + pub st_mtime: c_long, + pub st_mtime_nsec: c_long, + pub st_ctime: c_long, + pub st_ctime_nsec: c_long, + __unused: Padding<[c_long; 3]>, + } + + pub struct _libc_xmmreg { + pub element: [u32; 4], + } + + pub struct user_regs_struct { + pub r15: c_ulong, + pub r14: c_ulong, + pub r13: c_ulong, + pub r12: c_ulong, + pub rbp: c_ulong, + pub rbx: c_ulong, + pub r11: c_ulong, + pub r10: c_ulong, + pub r9: c_ulong, + pub r8: c_ulong, + pub rax: c_ulong, + pub rcx: c_ulong, + pub rdx: c_ulong, + pub rsi: c_ulong, + pub rdi: c_ulong, + pub orig_rax: c_ulong, + pub rip: c_ulong, + pub cs: c_ulong, + pub eflags: c_ulong, + pub rsp: c_ulong, + pub ss: c_ulong, + pub fs_base: c_ulong, + pub gs_base: c_ulong, + pub ds: c_ulong, + pub es: c_ulong, + pub fs: c_ulong, + pub gs: c_ulong, + } + + pub struct user { + pub regs: user_regs_struct, + pub u_fpvalid: c_int, + pub i387: user_fpregs_struct, + pub u_tsize: c_ulong, + pub u_dsize: c_ulong, + pub u_ssize: c_ulong, + pub start_code: c_ulong, + pub start_stack: c_ulong, + pub signal: c_long, + __reserved: Padding, + #[cfg(target_pointer_width = "32")] + __pad1: Padding, + pub u_ar0: *mut user_regs_struct, + #[cfg(target_pointer_width = "32")] + __pad2: Padding, + pub u_fpstate: *mut user_fpregs_struct, + pub magic: c_ulong, + pub u_comm: [c_char; 32], + pub u_debugreg: [c_ulong; 8], + pub error_code: c_ulong, + pub fault_address: c_ulong, + } + + pub struct _libc_fpxreg { + pub significand: [u16; 4], + pub exponent: u16, + __padding: Padding<[u16; 3]>, + } + + pub struct _libc_fpstate { + pub cwd: u16, + pub swd: u16, + pub ftw: u16, + pub fop: u16, + pub rip: u64, + pub rdp: u64, + pub mxcsr: u32, + pub mxcr_mask: u32, + pub _st: [_libc_fpxreg; 8], + pub _xmm: [_libc_xmmreg; 16], + __private: [u32; 24], + } + + pub struct mcontext_t { + pub gregs: [greg_t; 23], + pub fpregs: *mut _libc_fpstate, + __private: [u64; 8], + } + + pub struct ucontext_t { + pub uc_flags: c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: crate::stack_t, + pub uc_mcontext: mcontext_t, + pub uc_sigmask64: __c_anonymous_uc_sigmask, + __fpregs_mem: _libc_fpstate, + } + + pub struct user_fpregs_struct { + pub cwd: c_ushort, + pub swd: c_ushort, + pub ftw: c_ushort, + pub fop: c_ushort, + pub rip: c_ulong, + pub rdp: c_ulong, + pub mxcsr: c_uint, + pub mxcr_mask: c_uint, + pub st_space: [c_uint; 32], + pub xmm_space: [c_uint; 64], + padding: Padding<[c_uint; 24]>, + } +} + +s_no_extra_traits! { + pub union __c_anonymous_uc_sigmask { + uc_sigmask: crate::sigset_t, + uc_sigmask64: crate::sigset64_t, + } + + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 4], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for __c_anonymous_uc_sigmask { + fn eq(&self, other: &__c_anonymous_uc_sigmask) -> bool { + unsafe { self.uc_sigmask == other.uc_sigmask } + } + } + impl Eq for __c_anonymous_uc_sigmask {} + impl hash::Hash for __c_anonymous_uc_sigmask { + fn hash(&self, state: &mut H) { + unsafe { self.uc_sigmask.hash(state) } + } + } + } +} + +pub const O_DIRECT: c_int = 0x4000; +pub const O_DIRECTORY: c_int = 0x10000; +pub const O_NOFOLLOW: c_int = 0x20000; +pub const O_LARGEFILE: c_int = 0o0100000; + +pub const SIGSTKSZ: size_t = 8192; +pub const MINSIGSTKSZ: size_t = 2048; + +pub const MAP_32BIT: c_int = 0x40; + +// Syscall table + +pub const SYS_read: c_long = 0; +pub const SYS_write: c_long = 1; +pub const SYS_open: c_long = 2; +pub const SYS_close: c_long = 3; +pub const SYS_stat: c_long = 4; +pub const SYS_fstat: c_long = 5; +pub const SYS_lstat: c_long = 6; +pub const SYS_poll: c_long = 7; +pub const SYS_lseek: c_long = 8; +pub const SYS_mmap: c_long = 9; +pub const SYS_mprotect: c_long = 10; +pub const SYS_munmap: c_long = 11; +pub const SYS_brk: c_long = 12; +pub const SYS_rt_sigaction: c_long = 13; +pub const SYS_rt_sigprocmask: c_long = 14; +pub const SYS_rt_sigreturn: c_long = 15; +pub const SYS_ioctl: c_long = 16; +pub const SYS_pread64: c_long = 17; +pub const SYS_pwrite64: c_long = 18; +pub const SYS_readv: c_long = 19; +pub const SYS_writev: c_long = 20; +pub const SYS_access: c_long = 21; +pub const SYS_pipe: c_long = 22; +pub const SYS_select: c_long = 23; +pub const SYS_sched_yield: c_long = 24; +pub const SYS_mremap: c_long = 25; +pub const SYS_msync: c_long = 26; +pub const SYS_mincore: c_long = 27; +pub const SYS_madvise: c_long = 28; +pub const SYS_shmget: c_long = 29; +pub const SYS_shmat: c_long = 30; +pub const SYS_shmctl: c_long = 31; +pub const SYS_dup: c_long = 32; +pub const SYS_dup2: c_long = 33; +pub const SYS_pause: c_long = 34; +pub const SYS_nanosleep: c_long = 35; +pub const SYS_getitimer: c_long = 36; +pub const SYS_alarm: c_long = 37; +pub const SYS_setitimer: c_long = 38; +pub const SYS_getpid: c_long = 39; +pub const SYS_sendfile: c_long = 40; +pub const SYS_socket: c_long = 41; +pub const SYS_connect: c_long = 42; +pub const SYS_accept: c_long = 43; +pub const SYS_sendto: c_long = 44; +pub const SYS_recvfrom: c_long = 45; +pub const SYS_sendmsg: c_long = 46; +pub const SYS_recvmsg: c_long = 47; +pub const SYS_shutdown: c_long = 48; +pub const SYS_bind: c_long = 49; +pub const SYS_listen: c_long = 50; +pub const SYS_getsockname: c_long = 51; +pub const SYS_getpeername: c_long = 52; +pub const SYS_socketpair: c_long = 53; +pub const SYS_setsockopt: c_long = 54; +pub const SYS_getsockopt: c_long = 55; +pub const SYS_clone: c_long = 56; +pub const SYS_fork: c_long = 57; +pub const SYS_vfork: c_long = 58; +pub const SYS_execve: c_long = 59; +pub const SYS_exit: c_long = 60; +pub const SYS_wait4: c_long = 61; +pub const SYS_kill: c_long = 62; +pub const SYS_uname: c_long = 63; +pub const SYS_semget: c_long = 64; +pub const SYS_semop: c_long = 65; +pub const SYS_semctl: c_long = 66; +pub const SYS_shmdt: c_long = 67; +pub const SYS_msgget: c_long = 68; +pub const SYS_msgsnd: c_long = 69; +pub const SYS_msgrcv: c_long = 70; +pub const SYS_msgctl: c_long = 71; +pub const SYS_fcntl: c_long = 72; +pub const SYS_flock: c_long = 73; +pub const SYS_fsync: c_long = 74; +pub const SYS_fdatasync: c_long = 75; +pub const SYS_truncate: c_long = 76; +pub const SYS_ftruncate: c_long = 77; +pub const SYS_getdents: c_long = 78; +pub const SYS_getcwd: c_long = 79; +pub const SYS_chdir: c_long = 80; +pub const SYS_fchdir: c_long = 81; +pub const SYS_rename: c_long = 82; +pub const SYS_mkdir: c_long = 83; +pub const SYS_rmdir: c_long = 84; +pub const SYS_creat: c_long = 85; +pub const SYS_link: c_long = 86; +pub const SYS_unlink: c_long = 87; +pub const SYS_symlink: c_long = 88; +pub const SYS_readlink: c_long = 89; +pub const SYS_chmod: c_long = 90; +pub const SYS_fchmod: c_long = 91; +pub const SYS_chown: c_long = 92; +pub const SYS_fchown: c_long = 93; +pub const SYS_lchown: c_long = 94; +pub const SYS_umask: c_long = 95; +pub const SYS_gettimeofday: c_long = 96; +pub const SYS_getrlimit: c_long = 97; +pub const SYS_getrusage: c_long = 98; +pub const SYS_sysinfo: c_long = 99; +pub const SYS_times: c_long = 100; +pub const SYS_ptrace: c_long = 101; +pub const SYS_getuid: c_long = 102; +pub const SYS_syslog: c_long = 103; +pub const SYS_getgid: c_long = 104; +pub const SYS_setuid: c_long = 105; +pub const SYS_setgid: c_long = 106; +pub const SYS_geteuid: c_long = 107; +pub const SYS_getegid: c_long = 108; +pub const SYS_setpgid: c_long = 109; +pub const SYS_getppid: c_long = 110; +pub const SYS_getpgrp: c_long = 111; +pub const SYS_setsid: c_long = 112; +pub const SYS_setreuid: c_long = 113; +pub const SYS_setregid: c_long = 114; +pub const SYS_getgroups: c_long = 115; +pub const SYS_setgroups: c_long = 116; +pub const SYS_setresuid: c_long = 117; +pub const SYS_getresuid: c_long = 118; +pub const SYS_setresgid: c_long = 119; +pub const SYS_getresgid: c_long = 120; +pub const SYS_getpgid: c_long = 121; +pub const SYS_setfsuid: c_long = 122; +pub const SYS_setfsgid: c_long = 123; +pub const SYS_getsid: c_long = 124; +pub const SYS_capget: c_long = 125; +pub const SYS_capset: c_long = 126; +pub const SYS_rt_sigpending: c_long = 127; +pub const SYS_rt_sigtimedwait: c_long = 128; +pub const SYS_rt_sigqueueinfo: c_long = 129; +pub const SYS_rt_sigsuspend: c_long = 130; +pub const SYS_sigaltstack: c_long = 131; +pub const SYS_utime: c_long = 132; +pub const SYS_mknod: c_long = 133; +pub const SYS_uselib: c_long = 134; +pub const SYS_personality: c_long = 135; +pub const SYS_ustat: c_long = 136; +pub const SYS_statfs: c_long = 137; +pub const SYS_fstatfs: c_long = 138; +pub const SYS_sysfs: c_long = 139; +pub const SYS_getpriority: c_long = 140; +pub const SYS_setpriority: c_long = 141; +pub const SYS_sched_setparam: c_long = 142; +pub const SYS_sched_getparam: c_long = 143; +pub const SYS_sched_setscheduler: c_long = 144; +pub const SYS_sched_getscheduler: c_long = 145; +pub const SYS_sched_get_priority_max: c_long = 146; +pub const SYS_sched_get_priority_min: c_long = 147; +pub const SYS_sched_rr_get_interval: c_long = 148; +pub const SYS_mlock: c_long = 149; +pub const SYS_munlock: c_long = 150; +pub const SYS_mlockall: c_long = 151; +pub const SYS_munlockall: c_long = 152; +pub const SYS_vhangup: c_long = 153; +pub const SYS_modify_ldt: c_long = 154; +pub const SYS_pivot_root: c_long = 155; +// FIXME(android): SYS__sysctl is in the NDK sources but for some reason is +// not available in the tests +// pub const SYS__sysctl: c_long = 156; +pub const SYS_prctl: c_long = 157; +pub const SYS_arch_prctl: c_long = 158; +pub const SYS_adjtimex: c_long = 159; +pub const SYS_setrlimit: c_long = 160; +pub const SYS_chroot: c_long = 161; +pub const SYS_sync: c_long = 162; +pub const SYS_acct: c_long = 163; +pub const SYS_settimeofday: c_long = 164; +pub const SYS_mount: c_long = 165; +pub const SYS_umount2: c_long = 166; +pub const SYS_swapon: c_long = 167; +pub const SYS_swapoff: c_long = 168; +pub const SYS_reboot: c_long = 169; +pub const SYS_sethostname: c_long = 170; +pub const SYS_setdomainname: c_long = 171; +pub const SYS_iopl: c_long = 172; +pub const SYS_ioperm: c_long = 173; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_create_module: c_long = 174; +pub const SYS_init_module: c_long = 175; +pub const SYS_delete_module: c_long = 176; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_get_kernel_syms: c_long = 177; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_query_module: c_long = 178; +pub const SYS_quotactl: c_long = 179; +pub const SYS_nfsservctl: c_long = 180; +pub const SYS_getpmsg: c_long = 181; +pub const SYS_putpmsg: c_long = 182; +pub const SYS_afs_syscall: c_long = 183; +pub const SYS_tuxcall: c_long = 184; +pub const SYS_security: c_long = 185; +pub const SYS_gettid: c_long = 186; +pub const SYS_readahead: c_long = 187; +pub const SYS_setxattr: c_long = 188; +pub const SYS_lsetxattr: c_long = 189; +pub const SYS_fsetxattr: c_long = 190; +pub const SYS_getxattr: c_long = 191; +pub const SYS_lgetxattr: c_long = 192; +pub const SYS_fgetxattr: c_long = 193; +pub const SYS_listxattr: c_long = 194; +pub const SYS_llistxattr: c_long = 195; +pub const SYS_flistxattr: c_long = 196; +pub const SYS_removexattr: c_long = 197; +pub const SYS_lremovexattr: c_long = 198; +pub const SYS_fremovexattr: c_long = 199; +pub const SYS_tkill: c_long = 200; +pub const SYS_time: c_long = 201; +pub const SYS_futex: c_long = 202; +pub const SYS_sched_setaffinity: c_long = 203; +pub const SYS_sched_getaffinity: c_long = 204; +pub const SYS_set_thread_area: c_long = 205; +pub const SYS_io_setup: c_long = 206; +pub const SYS_io_destroy: c_long = 207; +pub const SYS_io_getevents: c_long = 208; +pub const SYS_io_submit: c_long = 209; +pub const SYS_io_cancel: c_long = 210; +pub const SYS_get_thread_area: c_long = 211; +pub const SYS_lookup_dcookie: c_long = 212; +pub const SYS_epoll_create: c_long = 213; +pub const SYS_epoll_ctl_old: c_long = 214; +pub const SYS_epoll_wait_old: c_long = 215; +pub const SYS_remap_file_pages: c_long = 216; +pub const SYS_getdents64: c_long = 217; +pub const SYS_set_tid_address: c_long = 218; +pub const SYS_restart_syscall: c_long = 219; +pub const SYS_semtimedop: c_long = 220; +pub const SYS_fadvise64: c_long = 221; +pub const SYS_timer_create: c_long = 222; +pub const SYS_timer_settime: c_long = 223; +pub const SYS_timer_gettime: c_long = 224; +pub const SYS_timer_getoverrun: c_long = 225; +pub const SYS_timer_delete: c_long = 226; +pub const SYS_clock_settime: c_long = 227; +pub const SYS_clock_gettime: c_long = 228; +pub const SYS_clock_getres: c_long = 229; +pub const SYS_clock_nanosleep: c_long = 230; +pub const SYS_exit_group: c_long = 231; +pub const SYS_epoll_wait: c_long = 232; +pub const SYS_epoll_ctl: c_long = 233; +pub const SYS_tgkill: c_long = 234; +pub const SYS_utimes: c_long = 235; +pub const SYS_vserver: c_long = 236; +pub const SYS_mbind: c_long = 237; +pub const SYS_set_mempolicy: c_long = 238; +pub const SYS_get_mempolicy: c_long = 239; +pub const SYS_mq_open: c_long = 240; +pub const SYS_mq_unlink: c_long = 241; +pub const SYS_mq_timedsend: c_long = 242; +pub const SYS_mq_timedreceive: c_long = 243; +pub const SYS_mq_notify: c_long = 244; +pub const SYS_mq_getsetattr: c_long = 245; +pub const SYS_kexec_load: c_long = 246; +pub const SYS_waitid: c_long = 247; +pub const SYS_add_key: c_long = 248; +pub const SYS_request_key: c_long = 249; +pub const SYS_keyctl: c_long = 250; +pub const SYS_ioprio_set: c_long = 251; +pub const SYS_ioprio_get: c_long = 252; +pub const SYS_inotify_init: c_long = 253; +pub const SYS_inotify_add_watch: c_long = 254; +pub const SYS_inotify_rm_watch: c_long = 255; +pub const SYS_migrate_pages: c_long = 256; +pub const SYS_openat: c_long = 257; +pub const SYS_mkdirat: c_long = 258; +pub const SYS_mknodat: c_long = 259; +pub const SYS_fchownat: c_long = 260; +pub const SYS_futimesat: c_long = 261; +pub const SYS_newfstatat: c_long = 262; +pub const SYS_unlinkat: c_long = 263; +pub const SYS_renameat: c_long = 264; +pub const SYS_linkat: c_long = 265; +pub const SYS_symlinkat: c_long = 266; +pub const SYS_readlinkat: c_long = 267; +pub const SYS_fchmodat: c_long = 268; +pub const SYS_faccessat: c_long = 269; +pub const SYS_pselect6: c_long = 270; +pub const SYS_ppoll: c_long = 271; +pub const SYS_unshare: c_long = 272; +pub const SYS_set_robust_list: c_long = 273; +pub const SYS_get_robust_list: c_long = 274; +pub const SYS_splice: c_long = 275; +pub const SYS_tee: c_long = 276; +pub const SYS_sync_file_range: c_long = 277; +pub const SYS_vmsplice: c_long = 278; +pub const SYS_move_pages: c_long = 279; +pub const SYS_utimensat: c_long = 280; +pub const SYS_epoll_pwait: c_long = 281; +pub const SYS_signalfd: c_long = 282; +pub const SYS_timerfd_create: c_long = 283; +pub const SYS_eventfd: c_long = 284; +pub const SYS_fallocate: c_long = 285; +pub const SYS_timerfd_settime: c_long = 286; +pub const SYS_timerfd_gettime: c_long = 287; +pub const SYS_accept4: c_long = 288; +pub const SYS_signalfd4: c_long = 289; +pub const SYS_eventfd2: c_long = 290; +pub const SYS_epoll_create1: c_long = 291; +pub const SYS_dup3: c_long = 292; +pub const SYS_pipe2: c_long = 293; +pub const SYS_inotify_init1: c_long = 294; +pub const SYS_preadv: c_long = 295; +pub const SYS_pwritev: c_long = 296; +pub const SYS_rt_tgsigqueueinfo: c_long = 297; +pub const SYS_perf_event_open: c_long = 298; +pub const SYS_recvmmsg: c_long = 299; +pub const SYS_fanotify_init: c_long = 300; +pub const SYS_fanotify_mark: c_long = 301; +pub const SYS_prlimit64: c_long = 302; +pub const SYS_name_to_handle_at: c_long = 303; +pub const SYS_open_by_handle_at: c_long = 304; +pub const SYS_clock_adjtime: c_long = 305; +pub const SYS_syncfs: c_long = 306; +pub const SYS_sendmmsg: c_long = 307; +pub const SYS_setns: c_long = 308; +pub const SYS_getcpu: c_long = 309; +pub const SYS_process_vm_readv: c_long = 310; +pub const SYS_process_vm_writev: c_long = 311; +pub const SYS_kcmp: c_long = 312; +pub const SYS_finit_module: c_long = 313; +pub const SYS_sched_setattr: c_long = 314; +pub const SYS_sched_getattr: c_long = 315; +pub const SYS_renameat2: c_long = 316; +pub const SYS_seccomp: c_long = 317; +pub const SYS_getrandom: c_long = 318; +pub const SYS_memfd_create: c_long = 319; +pub const SYS_kexec_file_load: c_long = 320; +pub const SYS_bpf: c_long = 321; +pub const SYS_execveat: c_long = 322; +pub const SYS_userfaultfd: c_long = 323; +pub const SYS_membarrier: c_long = 324; +pub const SYS_mlock2: c_long = 325; +pub const SYS_copy_file_range: c_long = 326; +pub const SYS_preadv2: c_long = 327; +pub const SYS_pwritev2: c_long = 328; +pub const SYS_pkey_mprotect: c_long = 329; +pub const SYS_pkey_alloc: c_long = 330; +pub const SYS_pkey_free: c_long = 331; +pub const SYS_statx: c_long = 332; +pub const SYS_pidfd_send_signal: c_long = 424; +pub const SYS_io_uring_setup: c_long = 425; +pub const SYS_io_uring_enter: c_long = 426; +pub const SYS_io_uring_register: c_long = 427; +pub const SYS_open_tree: c_long = 428; +pub const SYS_move_mount: c_long = 429; +pub const SYS_fsopen: c_long = 430; +pub const SYS_fsconfig: c_long = 431; +pub const SYS_fsmount: c_long = 432; +pub const SYS_fspick: c_long = 433; +pub const SYS_pidfd_open: c_long = 434; +pub const SYS_clone3: c_long = 435; +pub const SYS_close_range: c_long = 436; +pub const SYS_openat2: c_long = 437; +pub const SYS_pidfd_getfd: c_long = 438; +pub const SYS_faccessat2: c_long = 439; +pub const SYS_process_madvise: c_long = 440; +pub const SYS_epoll_pwait2: c_long = 441; +pub const SYS_mount_setattr: c_long = 442; +pub const SYS_quotactl_fd: c_long = 443; +pub const SYS_landlock_create_ruleset: c_long = 444; +pub const SYS_landlock_add_rule: c_long = 445; +pub const SYS_landlock_restrict_self: c_long = 446; +pub const SYS_memfd_secret: c_long = 447; +pub const SYS_process_mrelease: c_long = 448; +pub const SYS_futex_waitv: c_long = 449; +pub const SYS_set_mempolicy_home_node: c_long = 450; + +// offsets in user_regs_structs, from sys/reg.h +pub const R15: c_int = 0; +pub const R14: c_int = 1; +pub const R13: c_int = 2; +pub const R12: c_int = 3; +pub const RBP: c_int = 4; +pub const RBX: c_int = 5; +pub const R11: c_int = 6; +pub const R10: c_int = 7; +pub const R9: c_int = 8; +pub const R8: c_int = 9; +pub const RAX: c_int = 10; +pub const RCX: c_int = 11; +pub const RDX: c_int = 12; +pub const RSI: c_int = 13; +pub const RDI: c_int = 14; +pub const ORIG_RAX: c_int = 15; +pub const RIP: c_int = 16; +pub const CS: c_int = 17; +pub const EFLAGS: c_int = 18; +pub const RSP: c_int = 19; +pub const SS: c_int = 20; +pub const FS_BASE: c_int = 21; +pub const GS_BASE: c_int = 22; +pub const DS: c_int = 23; +pub const ES: c_int = 24; +pub const FS: c_int = 25; +pub const GS: c_int = 26; + +// offsets in mcontext_t.gregs from sys/ucontext.h +pub const REG_R8: c_int = 0; +pub const REG_R9: c_int = 1; +pub const REG_R10: c_int = 2; +pub const REG_R11: c_int = 3; +pub const REG_R12: c_int = 4; +pub const REG_R13: c_int = 5; +pub const REG_R14: c_int = 6; +pub const REG_R15: c_int = 7; +pub const REG_RDI: c_int = 8; +pub const REG_RSI: c_int = 9; +pub const REG_RBP: c_int = 10; +pub const REG_RBX: c_int = 11; +pub const REG_RDX: c_int = 12; +pub const REG_RAX: c_int = 13; +pub const REG_RCX: c_int = 14; +pub const REG_RSP: c_int = 15; +pub const REG_RIP: c_int = 16; +pub const REG_EFL: c_int = 17; +pub const REG_CSGSFS: c_int = 18; +pub const REG_ERR: c_int = 19; +pub const REG_TRAPNO: c_int = 20; +pub const REG_OLDMASK: c_int = 21; +pub const REG_CR2: c_int = 22; + +// From NDK's asm/auxvec.h +pub const AT_SYSINFO_EHDR: c_ulong = 33; +pub const AT_VECTOR_SIZE_ARCH: c_ulong = 3; diff --git a/http/vendor/libc/src/unix/linux_like/android/mod.rs b/http/vendor/libc/src/unix/linux_like/android/mod.rs new file mode 100644 index 0000000..31d1dba --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/android/mod.rs @@ -0,0 +1,3832 @@ +//! Android-specific definitions for linux-like values + +use crate::prelude::*; +use crate::{ + cmsghdr, + msghdr, +}; + +cfg_if! { + if #[cfg(doc)] { + pub(crate) type Ioctl = c_int; + } else { + #[doc(hidden)] + pub type Ioctl = c_int; + } +} + +pub type clock_t = c_long; +pub type time_t = c_long; +pub type suseconds_t = c_long; +pub type off_t = c_long; +pub type blkcnt_t = c_ulong; +pub type blksize_t = c_ulong; +pub type nlink_t = u32; +pub type pthread_t = c_long; +pub type pthread_mutexattr_t = c_long; +pub type pthread_rwlockattr_t = c_long; +pub type pthread_barrierattr_t = c_int; +pub type pthread_condattr_t = c_long; +pub type pthread_key_t = c_int; +pub type fsfilcnt_t = c_ulong; +pub type fsblkcnt_t = c_ulong; +pub type nfds_t = c_uint; +pub type rlim_t = c_ulong; +pub type dev_t = c_ulong; +pub type ino_t = c_ulong; +pub type ino64_t = u64; +pub type __CPU_BITTYPE = c_ulong; +pub type idtype_t = c_int; +pub type loff_t = c_longlong; +pub type __kernel_loff_t = c_longlong; +pub type __kernel_pid_t = c_int; + +pub type __u8 = c_uchar; +pub type __u16 = c_ushort; +pub type __s16 = c_short; +pub type __u32 = c_uint; +pub type __s32 = c_int; +pub type __be16 = __u16; + +// linux/elf.h + +pub type Elf32_Addr = u32; +pub type Elf32_Half = u16; +pub type Elf32_Off = u32; +pub type Elf32_Word = u32; + +pub type Elf64_Addr = u64; +pub type Elf64_Half = u16; +pub type Elf64_Off = u64; +pub type Elf64_Word = u32; +pub type Elf64_Xword = u64; + +pub type eventfd_t = u64; + +// these structs sit behind a heap allocation on Android +pub type posix_spawn_file_actions_t = *mut c_void; +pub type posix_spawnattr_t = *mut c_void; + +s! { + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_flags: c_int, + pub ss_size: size_t, + } + + pub struct __fsid_t { + __val: [c_int; 2], + } + + pub struct termios { + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_line: crate::cc_t, + pub c_cc: [crate::cc_t; crate::NCCS], + } + + pub struct termios2 { + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_line: crate::cc_t, + pub c_cc: [crate::cc_t; 19], + pub c_ispeed: crate::speed_t, + pub c_ospeed: crate::speed_t, + } + + pub struct mallinfo { + pub arena: size_t, + pub ordblks: size_t, + pub smblks: size_t, + pub hblks: size_t, + pub hblkhd: size_t, + pub usmblks: size_t, + pub fsmblks: size_t, + pub uordblks: size_t, + pub fordblks: size_t, + pub keepcost: size_t, + } + + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off_t, + pub l_len: off_t, + pub l_pid: crate::pid_t, + } + + pub struct flock64 { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: crate::__kernel_loff_t, + pub l_len: crate::__kernel_loff_t, + pub l_pid: crate::__kernel_pid_t, + } + + pub struct cpu_set_t { + #[cfg(target_pointer_width = "64")] + __bits: [__CPU_BITTYPE; 16], + #[cfg(target_pointer_width = "32")] + __bits: [__CPU_BITTYPE; 1], + } + + pub struct sem_t { + count: c_uint, + #[cfg(target_pointer_width = "64")] + __reserved: Padding<[c_int; 3]>, + } + + pub struct exit_status { + pub e_termination: c_short, + pub e_exit: c_short, + } + + pub struct statvfs { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_favail: crate::fsfilcnt_t, + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + #[cfg(target_pointer_width = "64")] + __f_reserved: Padding<[u32; 6]>, + } + + pub struct signalfd_siginfo { + pub ssi_signo: u32, + pub ssi_errno: i32, + pub ssi_code: i32, + pub ssi_pid: u32, + pub ssi_uid: u32, + pub ssi_fd: i32, + pub ssi_tid: u32, + pub ssi_band: u32, + pub ssi_overrun: u32, + pub ssi_trapno: u32, + pub ssi_status: i32, + pub ssi_int: i32, + pub ssi_ptr: c_ulonglong, + pub ssi_utime: c_ulonglong, + pub ssi_stime: c_ulonglong, + pub ssi_addr: c_ulonglong, + pub ssi_addr_lsb: u16, + _pad2: Padding, + pub ssi_syscall: i32, + pub ssi_call_addr: u64, + pub ssi_arch: u32, + _pad: Padding<[u8; 28]>, + } + + pub struct itimerspec { + pub it_interval: crate::timespec, + pub it_value: crate::timespec, + } + + pub struct genlmsghdr { + pub cmd: u8, + pub version: u8, + pub reserved: u16, + } + + pub struct nlmsghdr { + pub nlmsg_len: u32, + pub nlmsg_type: u16, + pub nlmsg_flags: u16, + pub nlmsg_seq: u32, + pub nlmsg_pid: u32, + } + + pub struct nlmsgerr { + pub error: c_int, + pub msg: nlmsghdr, + } + + pub struct nl_pktinfo { + pub group: u32, + } + + pub struct nl_mmap_req { + pub nm_block_size: c_uint, + pub nm_block_nr: c_uint, + pub nm_frame_size: c_uint, + pub nm_frame_nr: c_uint, + } + + pub struct nl_mmap_hdr { + pub nm_status: c_uint, + pub nm_len: c_uint, + pub nm_group: u32, + pub nm_pid: u32, + pub nm_uid: u32, + pub nm_gid: u32, + } + + pub struct nlattr { + pub nla_len: u16, + pub nla_type: u16, + } + + pub struct in6_pktinfo { + pub ipi6_addr: crate::in6_addr, + pub ipi6_ifindex: c_int, + } + + pub struct inotify_event { + pub wd: c_int, + pub mask: u32, + pub cookie: u32, + pub len: u32, + } + + pub struct sock_extended_err { + pub ee_errno: u32, + pub ee_origin: u8, + pub ee_type: u8, + pub ee_code: u8, + pub ee_pad: u8, + pub ee_info: u32, + pub ee_data: u32, + } + + pub struct regex_t { + re_magic: c_int, + re_nsub: size_t, + re_endp: *const c_char, + re_guts: *mut c_void, + } + + pub struct regmatch_t { + pub rm_so: ssize_t, + pub rm_eo: ssize_t, + } + + pub struct sockaddr_vm { + pub svm_family: crate::sa_family_t, + pub svm_reserved1: c_ushort, + pub svm_port: c_uint, + pub svm_cid: c_uint, + pub svm_zero: [u8; 4], + } + + // linux/elf.h + + pub struct Elf32_Phdr { + pub p_type: Elf32_Word, + pub p_offset: Elf32_Off, + pub p_vaddr: Elf32_Addr, + pub p_paddr: Elf32_Addr, + pub p_filesz: Elf32_Word, + pub p_memsz: Elf32_Word, + pub p_flags: Elf32_Word, + pub p_align: Elf32_Word, + } + + pub struct Elf64_Phdr { + pub p_type: Elf64_Word, + pub p_flags: Elf64_Word, + pub p_offset: Elf64_Off, + pub p_vaddr: Elf64_Addr, + pub p_paddr: Elf64_Addr, + pub p_filesz: Elf64_Xword, + pub p_memsz: Elf64_Xword, + pub p_align: Elf64_Xword, + } + + // link.h + + pub struct dl_phdr_info { + #[cfg(target_pointer_width = "64")] + pub dlpi_addr: Elf64_Addr, + #[cfg(target_pointer_width = "32")] + pub dlpi_addr: Elf32_Addr, + + pub dlpi_name: *const c_char, + + #[cfg(target_pointer_width = "64")] + pub dlpi_phdr: *const Elf64_Phdr, + #[cfg(target_pointer_width = "32")] + pub dlpi_phdr: *const Elf32_Phdr, + + #[cfg(target_pointer_width = "64")] + pub dlpi_phnum: Elf64_Half, + #[cfg(target_pointer_width = "32")] + pub dlpi_phnum: Elf32_Half, + + // These fields were added in Android R + pub dlpi_adds: c_ulonglong, + pub dlpi_subs: c_ulonglong, + pub dlpi_tls_modid: size_t, + pub dlpi_tls_data: *mut c_void, + } + + // linux/seccomp.h + pub struct seccomp_data { + pub nr: c_int, + pub arch: crate::__u32, + pub instruction_pointer: crate::__u64, + pub args: [crate::__u64; 6], + } + + pub struct seccomp_metadata { + pub filter_off: crate::__u64, + pub flags: crate::__u64, + } + + pub struct ptrace_peeksiginfo_args { + pub off: crate::__u64, + pub flags: crate::__u32, + pub nr: crate::__s32, + } + + // linux/input.h + pub struct input_event { + pub time: crate::timeval, + pub type_: crate::__u16, + pub code: crate::__u16, + pub value: crate::__s32, + } + + pub struct input_id { + pub bustype: crate::__u16, + pub vendor: crate::__u16, + pub product: crate::__u16, + pub version: crate::__u16, + } + + pub struct input_absinfo { + pub value: crate::__s32, + pub minimum: crate::__s32, + pub maximum: crate::__s32, + pub fuzz: crate::__s32, + pub flat: crate::__s32, + pub resolution: crate::__s32, + } + + pub struct input_keymap_entry { + pub flags: crate::__u8, + pub len: crate::__u8, + pub index: crate::__u16, + pub keycode: crate::__u32, + pub scancode: [crate::__u8; 32], + } + + pub struct input_mask { + pub type_: crate::__u32, + pub codes_size: crate::__u32, + pub codes_ptr: crate::__u64, + } + + pub struct ff_replay { + pub length: crate::__u16, + pub delay: crate::__u16, + } + + pub struct ff_trigger { + pub button: crate::__u16, + pub interval: crate::__u16, + } + + pub struct ff_envelope { + pub attack_length: crate::__u16, + pub attack_level: crate::__u16, + pub fade_length: crate::__u16, + pub fade_level: crate::__u16, + } + + pub struct ff_constant_effect { + pub level: crate::__s16, + pub envelope: ff_envelope, + } + + pub struct ff_ramp_effect { + pub start_level: crate::__s16, + pub end_level: crate::__s16, + pub envelope: ff_envelope, + } + + pub struct ff_condition_effect { + pub right_saturation: crate::__u16, + pub left_saturation: crate::__u16, + + pub right_coeff: crate::__s16, + pub left_coeff: crate::__s16, + + pub deadband: crate::__u16, + pub center: crate::__s16, + } + + pub struct ff_periodic_effect { + pub waveform: crate::__u16, + pub period: crate::__u16, + pub magnitude: crate::__s16, + pub offset: crate::__s16, + pub phase: crate::__u16, + + pub envelope: ff_envelope, + + pub custom_len: crate::__u32, + pub custom_data: *mut crate::__s16, + } + + pub struct ff_rumble_effect { + pub strong_magnitude: crate::__u16, + pub weak_magnitude: crate::__u16, + } + + pub struct ff_effect { + pub type_: crate::__u16, + pub id: crate::__s16, + pub direction: crate::__u16, + pub trigger: ff_trigger, + pub replay: ff_replay, + // FIXME(1.0): this is actually a union + #[cfg(target_pointer_width = "64")] + pub u: [u64; 4], + #[cfg(target_pointer_width = "32")] + pub u: [u32; 7], + } + + // linux/uinput.h + pub struct uinput_ff_upload { + pub request_id: crate::__u32, + pub retval: crate::__s32, + pub effect: ff_effect, + pub old: ff_effect, + } + + pub struct uinput_ff_erase { + pub request_id: crate::__u32, + pub retval: crate::__s32, + pub effect_id: crate::__u32, + } + + pub struct uinput_abs_setup { + pub code: crate::__u16, + pub absinfo: input_absinfo, + } + + pub struct option { + pub name: *const c_char, + pub has_arg: c_int, + pub flag: *mut c_int, + pub val: c_int, + } + + pub struct __c_anonymous_ifru_map { + pub mem_start: c_ulong, + pub mem_end: c_ulong, + pub base_addr: c_ushort, + pub irq: c_uchar, + pub dma: c_uchar, + pub port: c_uchar, + } + + pub struct in6_ifreq { + pub ifr6_addr: crate::in6_addr, + pub ifr6_prefixlen: u32, + pub ifr6_ifindex: c_int, + } + + pub struct sockaddr_nl { + pub nl_family: crate::sa_family_t, + nl_pad: Padding, + pub nl_pid: u32, + pub nl_groups: u32, + } + + pub struct dirent { + pub d_ino: u64, + pub d_off: i64, + pub d_reclen: c_ushort, + pub d_type: c_uchar, + pub d_name: [c_char; 256], + } + + pub struct dirent64 { + pub d_ino: u64, + pub d_off: i64, + pub d_reclen: c_ushort, + pub d_type: c_uchar, + pub d_name: [c_char; 256], + } + + pub struct siginfo_t { + pub si_signo: c_int, + pub si_errno: c_int, + pub si_code: c_int, + pub _pad: [c_int; 29], + _align: [usize; 0], + } + + pub struct lastlog { + ll_time: crate::time_t, + ll_line: [c_char; UT_LINESIZE], + ll_host: [c_char; UT_HOSTSIZE], + } + + pub struct utmp { + pub ut_type: c_short, + pub ut_pid: crate::pid_t, + pub ut_line: [c_char; UT_LINESIZE], + pub ut_id: [c_char; 4], + pub ut_user: [c_char; UT_NAMESIZE], + pub ut_host: [c_char; UT_HOSTSIZE], + pub ut_exit: exit_status, + pub ut_session: c_long, + pub ut_tv: crate::timeval, + pub ut_addr_v6: [i32; 4], + unused: Padding<[c_char; 20]>, + } + + pub struct sockaddr_alg { + pub salg_family: crate::sa_family_t, + pub salg_type: [c_uchar; 14], + pub salg_feat: u32, + pub salg_mask: u32, + pub salg_name: [c_uchar; 64], + } + + pub struct uinput_setup { + pub id: input_id, + pub name: [c_char; UINPUT_MAX_NAME_SIZE], + pub ff_effects_max: crate::__u32, + } + + pub struct uinput_user_dev { + pub name: [c_char; UINPUT_MAX_NAME_SIZE], + pub id: input_id, + pub ff_effects_max: crate::__u32, + pub absmax: [crate::__s32; ABS_CNT], + pub absmin: [crate::__s32; ABS_CNT], + pub absfuzz: [crate::__s32; ABS_CNT], + pub absflat: [crate::__s32; ABS_CNT], + } + + pub struct prop_info { + __name: [c_char; 32], + __serial: c_uint, + __value: [c_char; 92], + } +} + +s_no_extra_traits! { + /// WARNING: The `PartialEq`, `Eq` and `Hash` implementations of this + /// type are unsound and will be removed in the future. + #[deprecated( + note = "this struct has unsafe trait implementations that will be \ + removed in the future", + since = "0.2.80" + )] + pub struct af_alg_iv { + pub ivlen: u32, + pub iv: [c_uchar; 0], + } + + pub union __c_anonymous_ifr_ifru { + pub ifru_addr: crate::sockaddr, + pub ifru_dstaddr: crate::sockaddr, + pub ifru_broadaddr: crate::sockaddr, + pub ifru_netmask: crate::sockaddr, + pub ifru_hwaddr: crate::sockaddr, + pub ifru_flags: c_short, + pub ifru_ifindex: c_int, + pub ifru_metric: c_int, + pub ifru_mtu: c_int, + pub ifru_map: __c_anonymous_ifru_map, + pub ifru_slave: [c_char; crate::IFNAMSIZ], + pub ifru_newname: [c_char; crate::IFNAMSIZ], + pub ifru_data: *mut c_char, + } + + pub struct ifreq { + /// interface name, e.g. "en0" + pub ifr_name: [c_char; crate::IFNAMSIZ], + pub ifr_ifru: __c_anonymous_ifr_ifru, + } + + pub union __c_anonymous_ifc_ifcu { + pub ifcu_buf: *mut c_char, + pub ifcu_req: *mut crate::ifreq, + } + + /* Structure used in SIOCGIFCONF request. Used to retrieve interface + configuration for machine (useful for programs which must know all + networks accessible). */ + pub struct ifconf { + pub ifc_len: c_int, /* Size of buffer. */ + pub ifc_ifcu: __c_anonymous_ifc_ifcu, + } + + // linux/if_ether.h + + #[repr(C, packed)] + pub struct ethhdr { + pub h_dest: [c_uchar; crate::ETH_ALEN as usize], + pub h_source: [c_uchar; crate::ETH_ALEN as usize], + pub h_proto: crate::__be16, + } + + // Internal, for casts to access union fields + struct sifields_sigchld { + si_pid: crate::pid_t, + si_uid: crate::uid_t, + si_status: c_int, + si_utime: c_long, + si_stime: c_long, + } + + // Internal, for casts to access union fields + union sifields { + _align_pointer: *mut c_void, + sigchld: sifields_sigchld, + } + + // Internal, for casts to access union fields. Note that some variants + // of sifields start with a pointer, which makes the alignment of + // sifields vary on 32-bit and 64-bit architectures. + struct siginfo_f { + _siginfo_base: [c_int; 3], + sifields: sifields, + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + #[allow(deprecated)] + impl af_alg_iv { + fn as_slice(&self) -> &[u8] { + unsafe { ::core::slice::from_raw_parts(self.iv.as_ptr(), self.ivlen as usize) } + } + } + + #[allow(deprecated)] + impl PartialEq for af_alg_iv { + fn eq(&self, other: &af_alg_iv) -> bool { + *self.as_slice() == *other.as_slice() + } + } + + #[allow(deprecated)] + impl Eq for af_alg_iv {} + + #[allow(deprecated)] + impl hash::Hash for af_alg_iv { + fn hash(&self, state: &mut H) { + self.as_slice().hash(state); + } + } + } +} + +pub const MADV_SOFT_OFFLINE: c_int = 101; +pub const MS_NOUSER: c_ulong = 0xffffffff80000000; +pub const MS_RMT_MASK: c_ulong = 0x02800051; + +pub const O_TRUNC: c_int = 512; +pub const O_CLOEXEC: c_int = 0x80000; +pub const O_PATH: c_int = 0o10000000; +pub const O_NOATIME: c_int = 0o1000000; + +pub const EBFONT: c_int = 59; +pub const ENOSTR: c_int = 60; +pub const ENODATA: c_int = 61; +pub const ETIME: c_int = 62; +pub const ENOSR: c_int = 63; +pub const ENONET: c_int = 64; +pub const ENOPKG: c_int = 65; +pub const EREMOTE: c_int = 66; +pub const ENOLINK: c_int = 67; +pub const EADV: c_int = 68; +pub const ESRMNT: c_int = 69; +pub const ECOMM: c_int = 70; +pub const EPROTO: c_int = 71; +pub const EDOTDOT: c_int = 73; + +pub const EPOLL_CLOEXEC: c_int = 0x80000; + +// sys/eventfd.h +pub const EFD_SEMAPHORE: c_int = 0x1; +pub const EFD_CLOEXEC: c_int = O_CLOEXEC; +pub const EFD_NONBLOCK: c_int = O_NONBLOCK; + +// sys/timerfd.h +pub const TFD_CLOEXEC: c_int = O_CLOEXEC; +pub const TFD_NONBLOCK: c_int = O_NONBLOCK; +pub const TFD_TIMER_ABSTIME: c_int = 1; +pub const TFD_TIMER_CANCEL_ON_SET: c_int = 2; + +pub const USER_PROCESS: c_short = 7; + +pub const _POSIX_VDISABLE: crate::cc_t = 0; + +// linux/falloc.h +pub const FALLOC_FL_KEEP_SIZE: c_int = 0x01; +pub const FALLOC_FL_PUNCH_HOLE: c_int = 0x02; +pub const FALLOC_FL_NO_HIDE_STALE: c_int = 0x04; +pub const FALLOC_FL_COLLAPSE_RANGE: c_int = 0x08; +pub const FALLOC_FL_ZERO_RANGE: c_int = 0x10; +pub const FALLOC_FL_INSERT_RANGE: c_int = 0x20; +pub const FALLOC_FL_UNSHARE_RANGE: c_int = 0x40; + +pub const BUFSIZ: c_uint = 1024; +pub const FILENAME_MAX: c_uint = 4096; +pub const FOPEN_MAX: c_uint = 20; +pub const POSIX_FADV_DONTNEED: c_int = 4; +pub const POSIX_FADV_NOREUSE: c_int = 5; +pub const L_tmpnam: c_uint = 4096; +pub const TMP_MAX: c_uint = 308915776; +pub const _PC_LINK_MAX: c_int = 1; +pub const _PC_MAX_CANON: c_int = 2; +pub const _PC_MAX_INPUT: c_int = 3; +pub const _PC_NAME_MAX: c_int = 4; +pub const _PC_PATH_MAX: c_int = 5; +pub const _PC_PIPE_BUF: c_int = 6; +pub const _PC_2_SYMLINKS: c_int = 7; +pub const _PC_ALLOC_SIZE_MIN: c_int = 8; +pub const _PC_REC_INCR_XFER_SIZE: c_int = 9; +pub const _PC_REC_MAX_XFER_SIZE: c_int = 10; +pub const _PC_REC_MIN_XFER_SIZE: c_int = 11; +pub const _PC_REC_XFER_ALIGN: c_int = 12; +pub const _PC_SYMLINK_MAX: c_int = 13; +pub const _PC_CHOWN_RESTRICTED: c_int = 14; +pub const _PC_NO_TRUNC: c_int = 15; +pub const _PC_VDISABLE: c_int = 16; +pub const _PC_ASYNC_IO: c_int = 17; +pub const _PC_PRIO_IO: c_int = 18; +pub const _PC_SYNC_IO: c_int = 19; + +pub const FIONBIO: c_int = 0x5421; + +pub const _SC_ARG_MAX: c_int = 0x0000; +pub const _SC_BC_BASE_MAX: c_int = 0x0001; +pub const _SC_BC_DIM_MAX: c_int = 0x0002; +pub const _SC_BC_SCALE_MAX: c_int = 0x0003; +pub const _SC_BC_STRING_MAX: c_int = 0x0004; +pub const _SC_CHILD_MAX: c_int = 0x0005; +pub const _SC_CLK_TCK: c_int = 0x0006; +pub const _SC_COLL_WEIGHTS_MAX: c_int = 0x0007; +pub const _SC_EXPR_NEST_MAX: c_int = 0x0008; +pub const _SC_LINE_MAX: c_int = 0x0009; +pub const _SC_NGROUPS_MAX: c_int = 0x000a; +pub const _SC_OPEN_MAX: c_int = 0x000b; +pub const _SC_PASS_MAX: c_int = 0x000c; +pub const _SC_2_C_BIND: c_int = 0x000d; +pub const _SC_2_C_DEV: c_int = 0x000e; +pub const _SC_2_C_VERSION: c_int = 0x000f; +pub const _SC_2_CHAR_TERM: c_int = 0x0010; +pub const _SC_2_FORT_DEV: c_int = 0x0011; +pub const _SC_2_FORT_RUN: c_int = 0x0012; +pub const _SC_2_LOCALEDEF: c_int = 0x0013; +pub const _SC_2_SW_DEV: c_int = 0x0014; +pub const _SC_2_UPE: c_int = 0x0015; +pub const _SC_2_VERSION: c_int = 0x0016; +pub const _SC_JOB_CONTROL: c_int = 0x0017; +pub const _SC_SAVED_IDS: c_int = 0x0018; +pub const _SC_VERSION: c_int = 0x0019; +pub const _SC_RE_DUP_MAX: c_int = 0x001a; +pub const _SC_STREAM_MAX: c_int = 0x001b; +pub const _SC_TZNAME_MAX: c_int = 0x001c; +pub const _SC_XOPEN_CRYPT: c_int = 0x001d; +pub const _SC_XOPEN_ENH_I18N: c_int = 0x001e; +pub const _SC_XOPEN_SHM: c_int = 0x001f; +pub const _SC_XOPEN_VERSION: c_int = 0x0020; +pub const _SC_XOPEN_XCU_VERSION: c_int = 0x0021; +pub const _SC_XOPEN_REALTIME: c_int = 0x0022; +pub const _SC_XOPEN_REALTIME_THREADS: c_int = 0x0023; +pub const _SC_XOPEN_LEGACY: c_int = 0x0024; +pub const _SC_ATEXIT_MAX: c_int = 0x0025; +pub const _SC_IOV_MAX: c_int = 0x0026; +pub const _SC_UIO_MAXIOV: c_int = _SC_IOV_MAX; +pub const _SC_PAGESIZE: c_int = 0x0027; +pub const _SC_PAGE_SIZE: c_int = 0x0028; +pub const _SC_XOPEN_UNIX: c_int = 0x0029; +pub const _SC_XBS5_ILP32_OFF32: c_int = 0x002a; +pub const _SC_XBS5_ILP32_OFFBIG: c_int = 0x002b; +pub const _SC_XBS5_LP64_OFF64: c_int = 0x002c; +pub const _SC_XBS5_LPBIG_OFFBIG: c_int = 0x002d; +pub const _SC_AIO_LISTIO_MAX: c_int = 0x002e; +pub const _SC_AIO_MAX: c_int = 0x002f; +pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 0x0030; +pub const _SC_DELAYTIMER_MAX: c_int = 0x0031; +pub const _SC_MQ_OPEN_MAX: c_int = 0x0032; +pub const _SC_MQ_PRIO_MAX: c_int = 0x0033; +pub const _SC_RTSIG_MAX: c_int = 0x0034; +pub const _SC_SEM_NSEMS_MAX: c_int = 0x0035; +pub const _SC_SEM_VALUE_MAX: c_int = 0x0036; +pub const _SC_SIGQUEUE_MAX: c_int = 0x0037; +pub const _SC_TIMER_MAX: c_int = 0x0038; +pub const _SC_ASYNCHRONOUS_IO: c_int = 0x0039; +pub const _SC_FSYNC: c_int = 0x003a; +pub const _SC_MAPPED_FILES: c_int = 0x003b; +pub const _SC_MEMLOCK: c_int = 0x003c; +pub const _SC_MEMLOCK_RANGE: c_int = 0x003d; +pub const _SC_MEMORY_PROTECTION: c_int = 0x003e; +pub const _SC_MESSAGE_PASSING: c_int = 0x003f; +pub const _SC_PRIORITIZED_IO: c_int = 0x0040; +pub const _SC_PRIORITY_SCHEDULING: c_int = 0x0041; +pub const _SC_REALTIME_SIGNALS: c_int = 0x0042; +pub const _SC_SEMAPHORES: c_int = 0x0043; +pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 0x0044; +pub const _SC_SYNCHRONIZED_IO: c_int = 0x0045; +pub const _SC_TIMERS: c_int = 0x0046; +pub const _SC_GETGR_R_SIZE_MAX: c_int = 0x0047; +pub const _SC_GETPW_R_SIZE_MAX: c_int = 0x0048; +pub const _SC_LOGIN_NAME_MAX: c_int = 0x0049; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 0x004a; +pub const _SC_THREAD_KEYS_MAX: c_int = 0x004b; +pub const _SC_THREAD_STACK_MIN: c_int = 0x004c; +pub const _SC_THREAD_THREADS_MAX: c_int = 0x004d; +pub const _SC_TTY_NAME_MAX: c_int = 0x004e; +pub const _SC_THREADS: c_int = 0x004f; +pub const _SC_THREAD_ATTR_STACKADDR: c_int = 0x0050; +pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 0x0051; +pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 0x0052; +pub const _SC_THREAD_PRIO_INHERIT: c_int = 0x0053; +pub const _SC_THREAD_PRIO_PROTECT: c_int = 0x0054; +pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 0x0055; +pub const _SC_NPROCESSORS_CONF: c_int = 0x0060; +pub const _SC_NPROCESSORS_ONLN: c_int = 0x0061; +pub const _SC_PHYS_PAGES: c_int = 0x0062; +pub const _SC_AVPHYS_PAGES: c_int = 0x0063; +pub const _SC_MONOTONIC_CLOCK: c_int = 0x0064; +pub const _SC_2_PBS: c_int = 0x0065; +pub const _SC_2_PBS_ACCOUNTING: c_int = 0x0066; +pub const _SC_2_PBS_CHECKPOINT: c_int = 0x0067; +pub const _SC_2_PBS_LOCATE: c_int = 0x0068; +pub const _SC_2_PBS_MESSAGE: c_int = 0x0069; +pub const _SC_2_PBS_TRACK: c_int = 0x006a; +pub const _SC_ADVISORY_INFO: c_int = 0x006b; +pub const _SC_BARRIERS: c_int = 0x006c; +pub const _SC_CLOCK_SELECTION: c_int = 0x006d; +pub const _SC_CPUTIME: c_int = 0x006e; +pub const _SC_HOST_NAME_MAX: c_int = 0x006f; +pub const _SC_IPV6: c_int = 0x0070; +pub const _SC_RAW_SOCKETS: c_int = 0x0071; +pub const _SC_READER_WRITER_LOCKS: c_int = 0x0072; +pub const _SC_REGEXP: c_int = 0x0073; +pub const _SC_SHELL: c_int = 0x0074; +pub const _SC_SPAWN: c_int = 0x0075; +pub const _SC_SPIN_LOCKS: c_int = 0x0076; +pub const _SC_SPORADIC_SERVER: c_int = 0x0077; +pub const _SC_SS_REPL_MAX: c_int = 0x0078; +pub const _SC_SYMLOOP_MAX: c_int = 0x0079; +pub const _SC_THREAD_CPUTIME: c_int = 0x007a; +pub const _SC_THREAD_PROCESS_SHARED: c_int = 0x007b; +pub const _SC_THREAD_ROBUST_PRIO_INHERIT: c_int = 0x007c; +pub const _SC_THREAD_ROBUST_PRIO_PROTECT: c_int = 0x007d; +pub const _SC_THREAD_SPORADIC_SERVER: c_int = 0x007e; +pub const _SC_TIMEOUTS: c_int = 0x007f; +pub const _SC_TRACE: c_int = 0x0080; +pub const _SC_TRACE_EVENT_FILTER: c_int = 0x0081; +pub const _SC_TRACE_EVENT_NAME_MAX: c_int = 0x0082; +pub const _SC_TRACE_INHERIT: c_int = 0x0083; +pub const _SC_TRACE_LOG: c_int = 0x0084; +pub const _SC_TRACE_NAME_MAX: c_int = 0x0085; +pub const _SC_TRACE_SYS_MAX: c_int = 0x0086; +pub const _SC_TRACE_USER_EVENT_MAX: c_int = 0x0087; +pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 0x0088; +pub const _SC_V7_ILP32_OFF32: c_int = 0x0089; +pub const _SC_V7_ILP32_OFFBIG: c_int = 0x008a; +pub const _SC_V7_LP64_OFF64: c_int = 0x008b; +pub const _SC_V7_LPBIG_OFFBIG: c_int = 0x008c; +pub const _SC_XOPEN_STREAMS: c_int = 0x008d; +pub const _SC_XOPEN_UUCP: c_int = 0x008e; +pub const _SC_LEVEL1_ICACHE_SIZE: c_int = 0x008f; +pub const _SC_LEVEL1_ICACHE_ASSOC: c_int = 0x0090; +pub const _SC_LEVEL1_ICACHE_LINESIZE: c_int = 0x0091; +pub const _SC_LEVEL1_DCACHE_SIZE: c_int = 0x0092; +pub const _SC_LEVEL1_DCACHE_ASSOC: c_int = 0x0093; +pub const _SC_LEVEL1_DCACHE_LINESIZE: c_int = 0x0094; +pub const _SC_LEVEL2_CACHE_SIZE: c_int = 0x0095; +pub const _SC_LEVEL2_CACHE_ASSOC: c_int = 0x0096; +pub const _SC_LEVEL2_CACHE_LINESIZE: c_int = 0x0097; +pub const _SC_LEVEL3_CACHE_SIZE: c_int = 0x0098; +pub const _SC_LEVEL3_CACHE_ASSOC: c_int = 0x0099; +pub const _SC_LEVEL3_CACHE_LINESIZE: c_int = 0x009a; +pub const _SC_LEVEL4_CACHE_SIZE: c_int = 0x009b; +pub const _SC_LEVEL4_CACHE_ASSOC: c_int = 0x009c; +pub const _SC_LEVEL4_CACHE_LINESIZE: c_int = 0x009d; + +pub const F_LOCK: c_int = 1; +pub const F_TEST: c_int = 3; +pub const F_TLOCK: c_int = 2; +pub const F_ULOCK: c_int = 0; + +pub const F_SEAL_FUTURE_WRITE: c_int = 0x0010; +pub const F_SEAL_EXEC: c_int = 0x0020; + +pub const IFF_LOWER_UP: c_int = 0x10000; +pub const IFF_DORMANT: c_int = 0x20000; +pub const IFF_ECHO: c_int = 0x40000; + +pub const PTHREAD_BARRIER_SERIAL_THREAD: c_int = -1; +pub const PTHREAD_MUTEX_NORMAL: c_int = 0; +pub const PTHREAD_MUTEX_RECURSIVE: c_int = 1; +pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 2; +pub const PTHREAD_MUTEX_DEFAULT: c_int = PTHREAD_MUTEX_NORMAL; + +pub const PTHREAD_EXPLICIT_SCHED: c_int = 0; +pub const PTHREAD_INHERIT_SCHED: c_int = 1; + +// stdio.h +pub const RENAME_NOREPLACE: c_int = 1; +pub const RENAME_EXCHANGE: c_int = 2; +pub const RENAME_WHITEOUT: c_int = 4; + +pub const FIOCLEX: c_int = 0x5451; +pub const FIONCLEX: c_int = 0x5450; + +pub const SIGCHLD: c_int = 17; +pub const SIGBUS: c_int = 7; +pub const SIGUSR1: c_int = 10; +pub const SIGUSR2: c_int = 12; +pub const SIGCONT: c_int = 18; +pub const SIGSTOP: c_int = 19; +pub const SIGTSTP: c_int = 20; +pub const SIGURG: c_int = 23; +pub const SIGIO: c_int = 29; +pub const SIGSYS: c_int = 31; +pub const SIGSTKFLT: c_int = 16; +#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] +pub const SIGUNUSED: c_int = 31; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGPOLL: c_int = 29; +pub const SIGPWR: c_int = 30; +pub const SIG_SETMASK: c_int = 2; +pub const SIG_BLOCK: c_int = 0x000000; +pub const SIG_UNBLOCK: c_int = 0x01; + +pub const RUSAGE_CHILDREN: c_int = -1; + +pub const LC_PAPER: c_int = 7; +pub const LC_NAME: c_int = 8; +pub const LC_ADDRESS: c_int = 9; +pub const LC_TELEPHONE: c_int = 10; +pub const LC_MEASUREMENT: c_int = 11; +pub const LC_IDENTIFICATION: c_int = 12; +pub const LC_PAPER_MASK: c_int = 1 << LC_PAPER; +pub const LC_NAME_MASK: c_int = 1 << LC_NAME; +pub const LC_ADDRESS_MASK: c_int = 1 << LC_ADDRESS; +pub const LC_TELEPHONE_MASK: c_int = 1 << LC_TELEPHONE; +pub const LC_MEASUREMENT_MASK: c_int = 1 << LC_MEASUREMENT; +pub const LC_IDENTIFICATION_MASK: c_int = 1 << LC_IDENTIFICATION; +pub const LC_ALL_MASK: c_int = crate::LC_CTYPE_MASK + | crate::LC_NUMERIC_MASK + | crate::LC_TIME_MASK + | crate::LC_COLLATE_MASK + | crate::LC_MONETARY_MASK + | crate::LC_MESSAGES_MASK + | LC_PAPER_MASK + | LC_NAME_MASK + | LC_ADDRESS_MASK + | LC_TELEPHONE_MASK + | LC_MEASUREMENT_MASK + | LC_IDENTIFICATION_MASK; + +pub const MAP_ANON: c_int = 0x0020; +pub const MAP_ANONYMOUS: c_int = 0x0020; +pub const MAP_GROWSDOWN: c_int = 0x0100; +pub const MAP_DENYWRITE: c_int = 0x0800; +pub const MAP_EXECUTABLE: c_int = 0x01000; +pub const MAP_LOCKED: c_int = 0x02000; +pub const MAP_NORESERVE: c_int = 0x04000; +pub const MAP_POPULATE: c_int = 0x08000; +pub const MAP_NONBLOCK: c_int = 0x010000; +pub const MAP_STACK: c_int = 0x020000; + +pub const EDEADLK: c_int = 35; +pub const ENAMETOOLONG: c_int = 36; +pub const ENOLCK: c_int = 37; +pub const ENOSYS: c_int = 38; +pub const ENOTEMPTY: c_int = 39; +pub const ELOOP: c_int = 40; +pub const ENOMSG: c_int = 42; +pub const EIDRM: c_int = 43; +pub const ECHRNG: c_int = 44; +pub const EL2NSYNC: c_int = 45; +pub const EL3HLT: c_int = 46; +pub const EL3RST: c_int = 47; +pub const ELNRNG: c_int = 48; +pub const EUNATCH: c_int = 49; +pub const ENOCSI: c_int = 50; +pub const EL2HLT: c_int = 51; +pub const EBADE: c_int = 52; +pub const EBADR: c_int = 53; +pub const EXFULL: c_int = 54; +pub const ENOANO: c_int = 55; +pub const EBADRQC: c_int = 56; +pub const EBADSLT: c_int = 57; + +pub const EMULTIHOP: c_int = 72; +pub const EBADMSG: c_int = 74; +pub const EOVERFLOW: c_int = 75; +pub const ENOTUNIQ: c_int = 76; +pub const EBADFD: c_int = 77; +pub const EREMCHG: c_int = 78; +pub const ELIBACC: c_int = 79; +pub const ELIBBAD: c_int = 80; +pub const ELIBSCN: c_int = 81; +pub const ELIBMAX: c_int = 82; +pub const ELIBEXEC: c_int = 83; +pub const EILSEQ: c_int = 84; +pub const ERESTART: c_int = 85; +pub const ESTRPIPE: c_int = 86; +pub const EUSERS: c_int = 87; +pub const ENOTSOCK: c_int = 88; +pub const EDESTADDRREQ: c_int = 89; +pub const EMSGSIZE: c_int = 90; +pub const EPROTOTYPE: c_int = 91; +pub const ENOPROTOOPT: c_int = 92; +pub const EPROTONOSUPPORT: c_int = 93; +pub const ESOCKTNOSUPPORT: c_int = 94; +pub const EOPNOTSUPP: c_int = 95; +pub const ENOTSUP: c_int = EOPNOTSUPP; +pub const EPFNOSUPPORT: c_int = 96; +pub const EAFNOSUPPORT: c_int = 97; +pub const EADDRINUSE: c_int = 98; +pub const EADDRNOTAVAIL: c_int = 99; +pub const ENETDOWN: c_int = 100; +pub const ENETUNREACH: c_int = 101; +pub const ENETRESET: c_int = 102; +pub const ECONNABORTED: c_int = 103; +pub const ECONNRESET: c_int = 104; +pub const ENOBUFS: c_int = 105; +pub const EISCONN: c_int = 106; +pub const ENOTCONN: c_int = 107; +pub const ESHUTDOWN: c_int = 108; +pub const ETOOMANYREFS: c_int = 109; +pub const ETIMEDOUT: c_int = 110; +pub const ECONNREFUSED: c_int = 111; +pub const EHOSTDOWN: c_int = 112; +pub const EHOSTUNREACH: c_int = 113; +pub const EALREADY: c_int = 114; +pub const EINPROGRESS: c_int = 115; +pub const ESTALE: c_int = 116; +pub const EUCLEAN: c_int = 117; +pub const ENOTNAM: c_int = 118; +pub const ENAVAIL: c_int = 119; +pub const EISNAM: c_int = 120; +pub const EREMOTEIO: c_int = 121; +pub const EDQUOT: c_int = 122; +pub const ENOMEDIUM: c_int = 123; +pub const EMEDIUMTYPE: c_int = 124; +pub const ECANCELED: c_int = 125; +pub const ENOKEY: c_int = 126; +pub const EKEYEXPIRED: c_int = 127; +pub const EKEYREVOKED: c_int = 128; +pub const EKEYREJECTED: c_int = 129; +pub const EOWNERDEAD: c_int = 130; +pub const ENOTRECOVERABLE: c_int = 131; + +pub const SOCK_STREAM: c_int = 1; +pub const SOCK_DGRAM: c_int = 2; +pub const SOCK_SEQPACKET: c_int = 5; +pub const SOCK_DCCP: c_int = 6; +#[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")] +pub const SOCK_PACKET: c_int = 10; + +pub const IPPROTO_MAX: c_int = 256; + +pub const SOL_SOCKET: c_int = 1; +pub const SOL_SCTP: c_int = 132; +pub const SOL_IPX: c_int = 256; +pub const SOL_AX25: c_int = 257; +pub const SOL_ATALK: c_int = 258; +pub const SOL_NETROM: c_int = 259; +pub const SOL_ROSE: c_int = 260; + +/* UDP socket options */ +// include/uapi/linux/udp.h +pub const UDP_CORK: c_int = 1; +pub const UDP_ENCAP: c_int = 100; +pub const UDP_NO_CHECK6_TX: c_int = 101; +pub const UDP_NO_CHECK6_RX: c_int = 102; +pub const UDP_SEGMENT: c_int = 103; +pub const UDP_GRO: c_int = 104; + +/* DCCP socket options */ +pub const DCCP_SOCKOPT_PACKET_SIZE: c_int = 1; +pub const DCCP_SOCKOPT_SERVICE: c_int = 2; +pub const DCCP_SOCKOPT_CHANGE_L: c_int = 3; +pub const DCCP_SOCKOPT_CHANGE_R: c_int = 4; +pub const DCCP_SOCKOPT_GET_CUR_MPS: c_int = 5; +pub const DCCP_SOCKOPT_SERVER_TIMEWAIT: c_int = 6; +pub const DCCP_SOCKOPT_SEND_CSCOV: c_int = 10; +pub const DCCP_SOCKOPT_RECV_CSCOV: c_int = 11; +pub const DCCP_SOCKOPT_AVAILABLE_CCIDS: c_int = 12; +pub const DCCP_SOCKOPT_CCID: c_int = 13; +pub const DCCP_SOCKOPT_TX_CCID: c_int = 14; +pub const DCCP_SOCKOPT_RX_CCID: c_int = 15; +pub const DCCP_SOCKOPT_QPOLICY_ID: c_int = 16; +pub const DCCP_SOCKOPT_QPOLICY_TXQLEN: c_int = 17; +pub const DCCP_SOCKOPT_CCID_RX_INFO: c_int = 128; +pub const DCCP_SOCKOPT_CCID_TX_INFO: c_int = 192; + +/// maximum number of services provided on the same listening port +pub const DCCP_SERVICE_LIST_MAX_LEN: c_int = 32; + +pub const SO_REUSEADDR: c_int = 2; +pub const SO_TYPE: c_int = 3; +pub const SO_ERROR: c_int = 4; +pub const SO_DONTROUTE: c_int = 5; +pub const SO_BROADCAST: c_int = 6; +pub const SO_SNDBUF: c_int = 7; +pub const SO_RCVBUF: c_int = 8; +pub const SO_KEEPALIVE: c_int = 9; +pub const SO_OOBINLINE: c_int = 10; +pub const SO_PRIORITY: c_int = 12; +pub const SO_LINGER: c_int = 13; +pub const SO_BSDCOMPAT: c_int = 14; +pub const SO_REUSEPORT: c_int = 15; +pub const SO_PASSCRED: c_int = 16; +pub const SO_PEERCRED: c_int = 17; +pub const SO_RCVLOWAT: c_int = 18; +pub const SO_SNDLOWAT: c_int = 19; +pub const SO_RCVTIMEO: c_int = 20; +pub const SO_SNDTIMEO: c_int = 21; +pub const SO_BINDTODEVICE: c_int = 25; +pub const SO_ATTACH_FILTER: c_int = 26; +pub const SO_DETACH_FILTER: c_int = 27; +pub const SO_GET_FILTER: c_int = SO_ATTACH_FILTER; +pub const SO_TIMESTAMP: c_int = 29; +pub const SO_ACCEPTCONN: c_int = 30; +pub const SO_PEERSEC: c_int = 31; +pub const SO_SNDBUFFORCE: c_int = 32; +pub const SO_RCVBUFFORCE: c_int = 33; +pub const SO_PASSSEC: c_int = 34; +pub const SO_TIMESTAMPNS: c_int = 35; +// pub const SO_TIMESTAMPNS_OLD: c_int = 35; +pub const SO_MARK: c_int = 36; +pub const SO_TIMESTAMPING: c_int = 37; +// pub const SO_TIMESTAMPING_OLD: c_int = 37; +pub const SO_PROTOCOL: c_int = 38; +pub const SO_DOMAIN: c_int = 39; +pub const SO_RXQ_OVFL: c_int = 40; +pub const SO_PEEK_OFF: c_int = 42; +pub const SO_BUSY_POLL: c_int = 46; +pub const SCM_TIMESTAMPING_OPT_STATS: c_int = 54; +pub const SCM_TIMESTAMPING_PKTINFO: c_int = 58; +pub const SO_BINDTOIFINDEX: c_int = 62; +pub const SO_TIMESTAMP_NEW: c_int = 63; +pub const SO_TIMESTAMPNS_NEW: c_int = 64; +pub const SO_TIMESTAMPING_NEW: c_int = 65; + +// Defined in unix/linux_like/mod.rs +// pub const SCM_TIMESTAMP: c_int = SO_TIMESTAMP; +pub const SCM_TIMESTAMPNS: c_int = SO_TIMESTAMPNS; +pub const SCM_TIMESTAMPING: c_int = SO_TIMESTAMPING; + +pub const IPTOS_ECN_NOTECT: u8 = 0x00; + +pub const O_ACCMODE: c_int = 3; +pub const O_APPEND: c_int = 1024; +pub const O_CREAT: c_int = 64; +pub const O_EXCL: c_int = 128; +pub const O_NOCTTY: c_int = 256; +pub const O_NONBLOCK: c_int = 2048; +pub const O_SYNC: c_int = 0x101000; +pub const O_ASYNC: c_int = 0x2000; +pub const O_NDELAY: c_int = 0x800; +pub const O_DSYNC: c_int = 4096; +pub const O_RSYNC: c_int = O_SYNC; + +pub const NI_MAXHOST: size_t = 1025; +pub const NI_MAXSERV: size_t = 32; + +pub const NI_NOFQDN: c_int = 0x00000001; +pub const NI_NUMERICHOST: c_int = 0x00000002; +pub const NI_NAMEREQD: c_int = 0x00000004; +pub const NI_NUMERICSERV: c_int = 0x00000008; +pub const NI_DGRAM: c_int = 0x00000010; + +pub const NCCS: usize = 19; +pub const TCSBRKP: c_int = 0x5425; +pub const TCSANOW: c_int = 0; +pub const TCSADRAIN: c_int = 0x1; +pub const TCSAFLUSH: c_int = 0x2; +pub const VEOF: usize = 4; +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: crate::tcflag_t = 0x00008000; +pub const TOSTOP: crate::tcflag_t = 0x00000100; +pub const FLUSHO: crate::tcflag_t = 0x00001000; +pub const EXTPROC: crate::tcflag_t = 0o200000; + +pub const MAP_HUGETLB: c_int = 0x040000; + +pub const PTRACE_TRACEME: c_int = 0; +pub const PTRACE_PEEKTEXT: c_int = 1; +pub const PTRACE_PEEKDATA: c_int = 2; +pub const PTRACE_PEEKUSER: c_int = 3; +pub const PTRACE_POKETEXT: c_int = 4; +pub const PTRACE_POKEDATA: c_int = 5; +pub const PTRACE_POKEUSER: c_int = 6; +pub const PTRACE_CONT: c_int = 7; +pub const PTRACE_KILL: c_int = 8; +pub const PTRACE_SINGLESTEP: c_int = 9; +pub const PTRACE_GETREGS: c_int = 12; +pub const PTRACE_SETREGS: c_int = 13; +pub const PTRACE_ATTACH: c_int = 16; +pub const PTRACE_DETACH: c_int = 17; +pub const PTRACE_SYSCALL: c_int = 24; +pub const PTRACE_SETOPTIONS: c_int = 0x4200; +pub const PTRACE_GETEVENTMSG: c_int = 0x4201; +pub const PTRACE_GETSIGINFO: c_int = 0x4202; +pub const PTRACE_SETSIGINFO: c_int = 0x4203; +pub const PTRACE_GETREGSET: c_int = 0x4204; +pub const PTRACE_SETREGSET: c_int = 0x4205; +pub const PTRACE_SECCOMP_GET_METADATA: c_int = 0x420d; + +pub const PTRACE_EVENT_STOP: c_int = 128; + +pub const F_GETLK: c_int = 5; +pub const F_GETOWN: c_int = 9; +pub const F_SETOWN: c_int = 8; +pub const F_SETLK: c_int = 6; +pub const F_SETLKW: c_int = 7; +pub const F_RDLCK: c_int = 0; +pub const F_WRLCK: c_int = 1; +pub const F_UNLCK: c_int = 2; +pub const F_OFD_GETLK: c_int = 36; +pub const F_OFD_SETLK: c_int = 37; +pub const F_OFD_SETLKW: c_int = 38; + +pub const RLIMIT_CPU: c_int = 0; +pub const RLIMIT_FSIZE: c_int = 1; +pub const RLIMIT_DATA: c_int = 2; +pub const RLIMIT_STACK: c_int = 3; +pub const RLIMIT_CORE: c_int = 4; +pub const RLIMIT_RSS: c_int = 5; +pub const RLIMIT_NPROC: c_int = 6; +pub const RLIMIT_NOFILE: c_int = 7; +pub const RLIMIT_MEMLOCK: c_int = 8; +pub const RLIMIT_AS: c_int = 9; +pub const RLIMIT_LOCKS: c_int = 10; +pub const RLIMIT_SIGPENDING: c_int = 11; +pub const RLIMIT_MSGQUEUE: c_int = 12; +pub const RLIMIT_NICE: c_int = 13; +pub const RLIMIT_RTPRIO: c_int = 14; + +#[deprecated(since = "0.2.64", note = "Not stable across OS versions")] +pub const RLIM_NLIMITS: c_int = 16; +pub const RLIM_INFINITY: crate::rlim_t = !0; + +pub const TCGETS: c_int = 0x5401; +pub const TCSETS: c_int = 0x5402; +pub const TCSETSW: c_int = 0x5403; +pub const TCSETSF: c_int = 0x5404; +pub const TCGETS2: c_int = 0x802c542a; +pub const TCSETS2: c_int = 0x402c542b; +pub const TCSETSW2: c_int = 0x402c542c; +pub const TCSETSF2: c_int = 0x402c542d; +pub const TCGETA: c_int = 0x5405; +pub const TCSETA: c_int = 0x5406; +pub const TCSETAW: c_int = 0x5407; +pub const TCSETAF: c_int = 0x5408; +pub const TCSBRK: c_int = 0x5409; +pub const TCXONC: c_int = 0x540A; +pub const TCFLSH: c_int = 0x540B; +pub const TIOCGSOFTCAR: c_int = 0x5419; +pub const TIOCSSOFTCAR: c_int = 0x541A; +pub const TIOCINQ: c_int = 0x541B; +pub const TIOCLINUX: c_int = 0x541C; +pub const TIOCGSERIAL: c_int = 0x541E; +pub const TIOCEXCL: c_int = 0x540C; +pub const TIOCNXCL: c_int = 0x540D; +pub const TIOCSCTTY: c_int = 0x540E; +pub const TIOCGPGRP: c_int = 0x540F; +pub const TIOCSPGRP: c_int = 0x5410; +pub const TIOCOUTQ: c_int = 0x5411; +pub const TIOCSTI: c_int = 0x5412; +pub const TIOCGWINSZ: c_int = 0x5413; +pub const TIOCSWINSZ: c_int = 0x5414; +pub const TIOCMGET: c_int = 0x5415; +pub const TIOCMBIS: c_int = 0x5416; +pub const TIOCMBIC: c_int = 0x5417; +pub const TIOCMSET: c_int = 0x5418; +pub const FIONREAD: c_int = 0x541B; +pub const TIOCCONS: c_int = 0x541D; +pub const TIOCSBRK: c_int = 0x5427; +pub const TIOCCBRK: c_int = 0x5428; + +pub const ST_RDONLY: c_ulong = 1; +pub const ST_NOSUID: c_ulong = 2; +pub const ST_NODEV: c_ulong = 4; +pub const ST_NOEXEC: c_ulong = 8; +pub const ST_SYNCHRONOUS: c_ulong = 16; +pub const ST_MANDLOCK: c_ulong = 64; +pub const ST_NOATIME: c_ulong = 1024; +pub const ST_NODIRATIME: c_ulong = 2048; +pub const ST_RELATIME: c_ulong = 4096; + +pub const RTLD_NOLOAD: c_int = 0x4; +pub const RTLD_NODELETE: c_int = 0x1000; + +pub const SEM_FAILED: *mut sem_t = ptr::null_mut(); + +pub const AI_PASSIVE: c_int = 0x00000001; +pub const AI_CANONNAME: c_int = 0x00000002; +pub const AI_NUMERICHOST: c_int = 0x00000004; +pub const AI_NUMERICSERV: c_int = 0x00000008; +pub const AI_MASK: c_int = + AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | AI_ADDRCONFIG; +pub const AI_ALL: c_int = 0x00000100; +pub const AI_V4MAPPED_CFG: c_int = 0x00000200; +pub const AI_ADDRCONFIG: c_int = 0x00000400; +pub const AI_V4MAPPED: c_int = 0x00000800; +pub const AI_DEFAULT: c_int = AI_V4MAPPED_CFG | AI_ADDRCONFIG; + +// linux/kexec.h +pub const KEXEC_ON_CRASH: c_int = 0x00000001; +pub const KEXEC_PRESERVE_CONTEXT: c_int = 0x00000002; +pub const KEXEC_ARCH_MASK: c_int = 0xffff0000; +pub const KEXEC_FILE_UNLOAD: c_int = 0x00000001; +pub const KEXEC_FILE_ON_CRASH: c_int = 0x00000002; +pub const KEXEC_FILE_NO_INITRAMFS: c_int = 0x00000004; + +pub const LINUX_REBOOT_MAGIC1: c_int = 0xfee1dead; +pub const LINUX_REBOOT_MAGIC2: c_int = 672274793; +pub const LINUX_REBOOT_MAGIC2A: c_int = 85072278; +pub const LINUX_REBOOT_MAGIC2B: c_int = 369367448; +pub const LINUX_REBOOT_MAGIC2C: c_int = 537993216; + +pub const LINUX_REBOOT_CMD_RESTART: c_int = 0x01234567; +pub const LINUX_REBOOT_CMD_HALT: c_int = 0xCDEF0123; +pub const LINUX_REBOOT_CMD_CAD_ON: c_int = 0x89ABCDEF; +pub const LINUX_REBOOT_CMD_CAD_OFF: c_int = 0x00000000; +pub const LINUX_REBOOT_CMD_POWER_OFF: c_int = 0x4321FEDC; +pub const LINUX_REBOOT_CMD_RESTART2: c_int = 0xA1B2C3D4; +pub const LINUX_REBOOT_CMD_SW_SUSPEND: c_int = 0xD000FCE2; +pub const LINUX_REBOOT_CMD_KEXEC: c_int = 0x45584543; + +pub const REG_BASIC: c_int = 0; +pub const REG_EXTENDED: c_int = 1; +pub const REG_ICASE: c_int = 2; +pub const REG_NOSUB: c_int = 4; +pub const REG_NEWLINE: c_int = 8; +pub const REG_NOSPEC: c_int = 16; +pub const REG_PEND: c_int = 32; +pub const REG_DUMP: c_int = 128; + +pub const REG_NOMATCH: c_int = 1; +pub const REG_BADPAT: c_int = 2; +pub const REG_ECOLLATE: c_int = 3; +pub const REG_ECTYPE: c_int = 4; +pub const REG_EESCAPE: c_int = 5; +pub const REG_ESUBREG: c_int = 6; +pub const REG_EBRACK: c_int = 7; +pub const REG_EPAREN: c_int = 8; +pub const REG_EBRACE: c_int = 9; +pub const REG_BADBR: c_int = 10; +pub const REG_ERANGE: c_int = 11; +pub const REG_ESPACE: c_int = 12; +pub const REG_BADRPT: c_int = 13; +pub const REG_EMPTY: c_int = 14; +pub const REG_ASSERT: c_int = 15; +pub const REG_INVARG: c_int = 16; +pub const REG_ATOI: c_int = 255; +pub const REG_ITOA: c_int = 256; + +pub const REG_NOTBOL: c_int = 1; +pub const REG_NOTEOL: c_int = 2; +pub const REG_STARTEND: c_int = 4; +pub const REG_TRACE: c_int = 256; +pub const REG_LARGE: c_int = 512; +pub const REG_BACKR: c_int = 1024; + +pub const MCL_CURRENT: c_int = 0x0001; +pub const MCL_FUTURE: c_int = 0x0002; +pub const MCL_ONFAULT: c_int = 0x0004; + +pub const CBAUD: crate::tcflag_t = 0o0010017; +pub const TAB1: crate::tcflag_t = 0x00000800; +pub const TAB2: crate::tcflag_t = 0x00001000; +pub const TAB3: crate::tcflag_t = 0x00001800; +pub const CR1: crate::tcflag_t = 0x00000200; +pub const CR2: crate::tcflag_t = 0x00000400; +pub const CR3: crate::tcflag_t = 0x00000600; +pub const FF1: crate::tcflag_t = 0x00008000; +pub const BS1: crate::tcflag_t = 0x00002000; +pub const VT1: crate::tcflag_t = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IUCLC: crate::tcflag_t = 0x00000200; +pub const IXON: crate::tcflag_t = 0x00000400; +pub const IXOFF: crate::tcflag_t = 0x00001000; +pub const ONLCR: crate::tcflag_t = 0x4; +pub const CSIZE: crate::tcflag_t = 0x00000030; +pub const CS6: crate::tcflag_t = 0x00000010; +pub const CS7: crate::tcflag_t = 0x00000020; +pub const CS8: crate::tcflag_t = 0x00000030; +pub const CSTOPB: crate::tcflag_t = 0x00000040; +pub const CREAD: crate::tcflag_t = 0x00000080; +pub const PARENB: crate::tcflag_t = 0x00000100; +pub const PARODD: crate::tcflag_t = 0x00000200; +pub const HUPCL: crate::tcflag_t = 0x00000400; +pub const CLOCAL: crate::tcflag_t = 0x00000800; +pub const ECHOKE: crate::tcflag_t = 0x00000800; +pub const ECHOE: crate::tcflag_t = 0x00000010; +pub const ECHOK: crate::tcflag_t = 0x00000020; +pub const ECHONL: crate::tcflag_t = 0x00000040; +pub const ECHOPRT: crate::tcflag_t = 0x00000400; +pub const ECHOCTL: crate::tcflag_t = 0x00000200; +pub const ISIG: crate::tcflag_t = 0x00000001; +pub const ICANON: crate::tcflag_t = 0x00000002; +pub const PENDIN: crate::tcflag_t = 0x00004000; +pub const NOFLSH: crate::tcflag_t = 0x00000080; +pub const VSWTC: usize = 7; +pub const OLCUC: crate::tcflag_t = 0o000002; +pub const NLDLY: crate::tcflag_t = 0o000400; +pub const CRDLY: crate::tcflag_t = 0o003000; +pub const TABDLY: crate::tcflag_t = 0o014000; +pub const BSDLY: crate::tcflag_t = 0o020000; +pub const FFDLY: crate::tcflag_t = 0o100000; +pub const VTDLY: crate::tcflag_t = 0o040000; +pub const XCASE: crate::tcflag_t = 0o000004; +pub const XTABS: crate::tcflag_t = 0o014000; + +pub const B0: crate::speed_t = 0o000000; +pub const B50: crate::speed_t = 0o000001; +pub const B75: crate::speed_t = 0o000002; +pub const B110: crate::speed_t = 0o000003; +pub const B134: crate::speed_t = 0o000004; +pub const B150: crate::speed_t = 0o000005; +pub const B200: crate::speed_t = 0o000006; +pub const B300: crate::speed_t = 0o000007; +pub const B600: crate::speed_t = 0o000010; +pub const B1200: crate::speed_t = 0o000011; +pub const B1800: crate::speed_t = 0o000012; +pub const B2400: crate::speed_t = 0o000013; +pub const B4800: crate::speed_t = 0o000014; +pub const B9600: crate::speed_t = 0o000015; +pub const B19200: crate::speed_t = 0o000016; +pub const B38400: crate::speed_t = 0o000017; +pub const EXTA: crate::speed_t = B19200; +pub const EXTB: crate::speed_t = B38400; +pub const BOTHER: crate::speed_t = 0o010000; +pub const B57600: crate::speed_t = 0o010001; +pub const B115200: crate::speed_t = 0o010002; +pub const B230400: crate::speed_t = 0o010003; +pub const B460800: crate::speed_t = 0o010004; +pub const B500000: crate::speed_t = 0o010005; +pub const B576000: crate::speed_t = 0o010006; +pub const B921600: crate::speed_t = 0o010007; +pub const B1000000: crate::speed_t = 0o010010; +pub const B1152000: crate::speed_t = 0o010011; +pub const B1500000: crate::speed_t = 0o010012; +pub const B2000000: crate::speed_t = 0o010013; +pub const B2500000: crate::speed_t = 0o010014; +pub const B3000000: crate::speed_t = 0o010015; +pub const B3500000: crate::speed_t = 0o010016; +pub const B4000000: crate::speed_t = 0o010017; +pub const IBSHIFT: crate::tcflag_t = 16; + +pub const BLKIOMIN: c_int = 0x1278; +pub const BLKIOOPT: c_int = 0x1279; +pub const BLKSSZGET: c_int = 0x1268; +pub const BLKPBSZGET: c_int = 0x127B; + +pub const EAI_AGAIN: c_int = 2; +pub const EAI_BADFLAGS: c_int = 3; +pub const EAI_FAIL: c_int = 4; +pub const EAI_FAMILY: c_int = 5; +pub const EAI_MEMORY: c_int = 6; +pub const EAI_NODATA: c_int = 7; +pub const EAI_NONAME: c_int = 8; +pub const EAI_SERVICE: c_int = 9; +pub const EAI_SOCKTYPE: c_int = 10; +pub const EAI_SYSTEM: c_int = 11; +pub const EAI_OVERFLOW: c_int = 14; + +pub const NETLINK_ROUTE: c_int = 0; +pub const NETLINK_UNUSED: c_int = 1; +pub const NETLINK_USERSOCK: c_int = 2; +pub const NETLINK_FIREWALL: c_int = 3; +pub const NETLINK_SOCK_DIAG: c_int = 4; +pub const NETLINK_NFLOG: c_int = 5; +pub const NETLINK_XFRM: c_int = 6; +pub const NETLINK_SELINUX: c_int = 7; +pub const NETLINK_ISCSI: c_int = 8; +pub const NETLINK_AUDIT: c_int = 9; +pub const NETLINK_FIB_LOOKUP: c_int = 10; +pub const NETLINK_CONNECTOR: c_int = 11; +pub const NETLINK_NETFILTER: c_int = 12; +pub const NETLINK_IP6_FW: c_int = 13; +pub const NETLINK_DNRTMSG: c_int = 14; +pub const NETLINK_KOBJECT_UEVENT: c_int = 15; +pub const NETLINK_GENERIC: c_int = 16; +pub const NETLINK_SCSITRANSPORT: c_int = 18; +pub const NETLINK_ECRYPTFS: c_int = 19; +pub const NETLINK_RDMA: c_int = 20; +pub const NETLINK_CRYPTO: c_int = 21; +pub const NETLINK_INET_DIAG: c_int = NETLINK_SOCK_DIAG; + +pub const MAX_LINKS: c_int = 32; + +pub const NLM_F_REQUEST: c_int = 1; +pub const NLM_F_MULTI: c_int = 2; +pub const NLM_F_ACK: c_int = 4; +pub const NLM_F_ECHO: c_int = 8; +pub const NLM_F_DUMP_INTR: c_int = 16; +pub const NLM_F_DUMP_FILTERED: c_int = 32; + +pub const NLM_F_ROOT: c_int = 0x100; +pub const NLM_F_MATCH: c_int = 0x200; +pub const NLM_F_ATOMIC: c_int = 0x400; +pub const NLM_F_DUMP: c_int = NLM_F_ROOT | NLM_F_MATCH; + +pub const NLM_F_REPLACE: c_int = 0x100; +pub const NLM_F_EXCL: c_int = 0x200; +pub const NLM_F_CREATE: c_int = 0x400; +pub const NLM_F_APPEND: c_int = 0x800; + +pub const NLM_F_NONREC: c_int = 0x100; +pub const NLM_F_BULK: c_int = 0x200; + +pub const NLM_F_CAPPED: c_int = 0x100; +pub const NLM_F_ACK_TLVS: c_int = 0x200; + +pub const NLMSG_NOOP: c_int = 0x1; +pub const NLMSG_ERROR: c_int = 0x2; +pub const NLMSG_DONE: c_int = 0x3; +pub const NLMSG_OVERRUN: c_int = 0x4; +pub const NLMSG_MIN_TYPE: c_int = 0x10; + +// linux/netfilter/nfnetlink.h +pub const NFNLGRP_NONE: c_int = 0; +pub const NFNLGRP_CONNTRACK_NEW: c_int = 1; +pub const NFNLGRP_CONNTRACK_UPDATE: c_int = 2; +pub const NFNLGRP_CONNTRACK_DESTROY: c_int = 3; +pub const NFNLGRP_CONNTRACK_EXP_NEW: c_int = 4; +pub const NFNLGRP_CONNTRACK_EXP_UPDATE: c_int = 5; +pub const NFNLGRP_CONNTRACK_EXP_DESTROY: c_int = 6; +pub const NFNLGRP_NFTABLES: c_int = 7; +pub const NFNLGRP_ACCT_QUOTA: c_int = 8; + +pub const NFNETLINK_V0: c_int = 0; + +pub const NFNL_SUBSYS_NONE: c_int = 0; +pub const NFNL_SUBSYS_CTNETLINK: c_int = 1; +pub const NFNL_SUBSYS_CTNETLINK_EXP: c_int = 2; +pub const NFNL_SUBSYS_QUEUE: c_int = 3; +pub const NFNL_SUBSYS_ULOG: c_int = 4; +pub const NFNL_SUBSYS_OSF: c_int = 5; +pub const NFNL_SUBSYS_IPSET: c_int = 6; +pub const NFNL_SUBSYS_ACCT: c_int = 7; +pub const NFNL_SUBSYS_CTNETLINK_TIMEOUT: c_int = 8; +pub const NFNL_SUBSYS_CTHELPER: c_int = 9; +pub const NFNL_SUBSYS_NFTABLES: c_int = 10; +pub const NFNL_SUBSYS_NFT_COMPAT: c_int = 11; +pub const NFNL_SUBSYS_COUNT: c_int = 12; + +pub const NFNL_MSG_BATCH_BEGIN: c_int = NLMSG_MIN_TYPE; +pub const NFNL_MSG_BATCH_END: c_int = NLMSG_MIN_TYPE + 1; + +// linux/netfilter/nfnetlink_log.h +pub const NFULNL_MSG_PACKET: c_int = 0; +pub const NFULNL_MSG_CONFIG: c_int = 1; + +pub const NFULA_UNSPEC: c_int = 0; +pub const NFULA_PACKET_HDR: c_int = 1; +pub const NFULA_MARK: c_int = 2; +pub const NFULA_TIMESTAMP: c_int = 3; +pub const NFULA_IFINDEX_INDEV: c_int = 4; +pub const NFULA_IFINDEX_OUTDEV: c_int = 5; +pub const NFULA_IFINDEX_PHYSINDEV: c_int = 6; +pub const NFULA_IFINDEX_PHYSOUTDEV: c_int = 7; +pub const NFULA_HWADDR: c_int = 8; +pub const NFULA_PAYLOAD: c_int = 9; +pub const NFULA_PREFIX: c_int = 10; +pub const NFULA_UID: c_int = 11; +pub const NFULA_SEQ: c_int = 12; +pub const NFULA_SEQ_GLOBAL: c_int = 13; +pub const NFULA_GID: c_int = 14; +pub const NFULA_HWTYPE: c_int = 15; +pub const NFULA_HWHEADER: c_int = 16; +pub const NFULA_HWLEN: c_int = 17; +pub const NFULA_CT: c_int = 18; +pub const NFULA_CT_INFO: c_int = 19; + +pub const NFULNL_CFG_CMD_NONE: c_int = 0; +pub const NFULNL_CFG_CMD_BIND: c_int = 1; +pub const NFULNL_CFG_CMD_UNBIND: c_int = 2; +pub const NFULNL_CFG_CMD_PF_BIND: c_int = 3; +pub const NFULNL_CFG_CMD_PF_UNBIND: c_int = 4; + +pub const NFULA_CFG_UNSPEC: c_int = 0; +pub const NFULA_CFG_CMD: c_int = 1; +pub const NFULA_CFG_MODE: c_int = 2; +pub const NFULA_CFG_NLBUFSIZ: c_int = 3; +pub const NFULA_CFG_TIMEOUT: c_int = 4; +pub const NFULA_CFG_QTHRESH: c_int = 5; +pub const NFULA_CFG_FLAGS: c_int = 6; + +pub const NFULNL_COPY_NONE: c_int = 0x00; +pub const NFULNL_COPY_META: c_int = 0x01; +pub const NFULNL_COPY_PACKET: c_int = 0x02; + +pub const NFULNL_CFG_F_SEQ: c_int = 0x0001; +pub const NFULNL_CFG_F_SEQ_GLOBAL: c_int = 0x0002; +pub const NFULNL_CFG_F_CONNTRACK: c_int = 0x0004; + +// linux/netfilter/nfnetlink_log.h +pub const NFQNL_MSG_PACKET: c_int = 0; +pub const NFQNL_MSG_VERDICT: c_int = 1; +pub const NFQNL_MSG_CONFIG: c_int = 2; +pub const NFQNL_MSG_VERDICT_BATCH: c_int = 3; + +pub const NFQA_UNSPEC: c_int = 0; +pub const NFQA_PACKET_HDR: c_int = 1; +pub const NFQA_VERDICT_HDR: c_int = 2; +pub const NFQA_MARK: c_int = 3; +pub const NFQA_TIMESTAMP: c_int = 4; +pub const NFQA_IFINDEX_INDEV: c_int = 5; +pub const NFQA_IFINDEX_OUTDEV: c_int = 6; +pub const NFQA_IFINDEX_PHYSINDEV: c_int = 7; +pub const NFQA_IFINDEX_PHYSOUTDEV: c_int = 8; +pub const NFQA_HWADDR: c_int = 9; +pub const NFQA_PAYLOAD: c_int = 10; +pub const NFQA_CT: c_int = 11; +pub const NFQA_CT_INFO: c_int = 12; +pub const NFQA_CAP_LEN: c_int = 13; +pub const NFQA_SKB_INFO: c_int = 14; +pub const NFQA_EXP: c_int = 15; +pub const NFQA_UID: c_int = 16; +pub const NFQA_GID: c_int = 17; +pub const NFQA_SECCTX: c_int = 18; +/* + FIXME: These are not yet available in musl sanitized kernel headers and + make the tests fail. Enable them once musl has them. + + See https://github.com/rust-lang/libc/pull/1628 for more details. +pub const NFQA_VLAN: c_int = 19; +pub const NFQA_L2HDR: c_int = 20; + +pub const NFQA_VLAN_UNSPEC: c_int = 0; +pub const NFQA_VLAN_PROTO: c_int = 1; +pub const NFQA_VLAN_TCI: c_int = 2; +*/ + +pub const NFQNL_CFG_CMD_NONE: c_int = 0; +pub const NFQNL_CFG_CMD_BIND: c_int = 1; +pub const NFQNL_CFG_CMD_UNBIND: c_int = 2; +pub const NFQNL_CFG_CMD_PF_BIND: c_int = 3; +pub const NFQNL_CFG_CMD_PF_UNBIND: c_int = 4; + +pub const NFQNL_COPY_NONE: c_int = 0; +pub const NFQNL_COPY_META: c_int = 1; +pub const NFQNL_COPY_PACKET: c_int = 2; + +pub const NFQA_CFG_UNSPEC: c_int = 0; +pub const NFQA_CFG_CMD: c_int = 1; +pub const NFQA_CFG_PARAMS: c_int = 2; +pub const NFQA_CFG_QUEUE_MAXLEN: c_int = 3; +pub const NFQA_CFG_MASK: c_int = 4; +pub const NFQA_CFG_FLAGS: c_int = 5; + +pub const NFQA_CFG_F_FAIL_OPEN: c_int = 0x0001; +pub const NFQA_CFG_F_CONNTRACK: c_int = 0x0002; +pub const NFQA_CFG_F_GSO: c_int = 0x0004; +pub const NFQA_CFG_F_UID_GID: c_int = 0x0008; +pub const NFQA_CFG_F_SECCTX: c_int = 0x0010; +pub const NFQA_CFG_F_MAX: c_int = 0x0020; + +pub const NFQA_SKB_CSUMNOTREADY: c_int = 0x0001; +pub const NFQA_SKB_GSO: c_int = 0x0002; +pub const NFQA_SKB_CSUM_NOTVERIFIED: c_int = 0x0004; + +pub const GENL_NAMSIZ: c_int = 16; + +pub const GENL_MIN_ID: c_int = NLMSG_MIN_TYPE; +pub const GENL_MAX_ID: c_int = 1023; + +pub const GENL_ADMIN_PERM: c_int = 0x01; +pub const GENL_CMD_CAP_DO: c_int = 0x02; +pub const GENL_CMD_CAP_DUMP: c_int = 0x04; +pub const GENL_CMD_CAP_HASPOL: c_int = 0x08; +pub const GENL_UNS_ADMIN_PERM: c_int = 0x10; + +pub const GENL_ID_CTRL: c_int = NLMSG_MIN_TYPE; +pub const GENL_ID_VFS_DQUOT: c_int = NLMSG_MIN_TYPE + 1; +pub const GENL_ID_PMCRAID: c_int = NLMSG_MIN_TYPE + 2; + +pub const CTRL_CMD_UNSPEC: c_int = 0; +pub const CTRL_CMD_NEWFAMILY: c_int = 1; +pub const CTRL_CMD_DELFAMILY: c_int = 2; +pub const CTRL_CMD_GETFAMILY: c_int = 3; +pub const CTRL_CMD_NEWOPS: c_int = 4; +pub const CTRL_CMD_DELOPS: c_int = 5; +pub const CTRL_CMD_GETOPS: c_int = 6; +pub const CTRL_CMD_NEWMCAST_GRP: c_int = 7; +pub const CTRL_CMD_DELMCAST_GRP: c_int = 8; +pub const CTRL_CMD_GETMCAST_GRP: c_int = 9; + +pub const CTRL_ATTR_UNSPEC: c_int = 0; +pub const CTRL_ATTR_FAMILY_ID: c_int = 1; +pub const CTRL_ATTR_FAMILY_NAME: c_int = 2; +pub const CTRL_ATTR_VERSION: c_int = 3; +pub const CTRL_ATTR_HDRSIZE: c_int = 4; +pub const CTRL_ATTR_MAXATTR: c_int = 5; +pub const CTRL_ATTR_OPS: c_int = 6; +pub const CTRL_ATTR_MCAST_GROUPS: c_int = 7; + +pub const CTRL_ATTR_OP_UNSPEC: c_int = 0; +pub const CTRL_ATTR_OP_ID: c_int = 1; +pub const CTRL_ATTR_OP_FLAGS: c_int = 2; + +pub const CTRL_ATTR_MCAST_GRP_UNSPEC: c_int = 0; +pub const CTRL_ATTR_MCAST_GRP_NAME: c_int = 1; +pub const CTRL_ATTR_MCAST_GRP_ID: c_int = 2; + +pub const NETLINK_ADD_MEMBERSHIP: c_int = 1; +pub const NETLINK_DROP_MEMBERSHIP: c_int = 2; +pub const NETLINK_PKTINFO: c_int = 3; +pub const NETLINK_BROADCAST_ERROR: c_int = 4; +pub const NETLINK_NO_ENOBUFS: c_int = 5; +pub const NETLINK_RX_RING: c_int = 6; +pub const NETLINK_TX_RING: c_int = 7; +pub const NETLINK_LISTEN_ALL_NSID: c_int = 8; +pub const NETLINK_LIST_MEMBERSHIPS: c_int = 9; +pub const NETLINK_CAP_ACK: c_int = 10; +pub const NETLINK_EXT_ACK: c_int = 11; +pub const NETLINK_GET_STRICT_CHK: c_int = 12; + +pub const GRND_NONBLOCK: c_uint = 0x0001; +pub const GRND_RANDOM: c_uint = 0x0002; +pub const GRND_INSECURE: c_uint = 0x0004; + +// +pub const SECCOMP_MODE_DISABLED: c_uint = 0; +pub const SECCOMP_MODE_STRICT: c_uint = 1; +pub const SECCOMP_MODE_FILTER: c_uint = 2; + +pub const SECCOMP_SET_MODE_STRICT: c_uint = 0; +pub const SECCOMP_SET_MODE_FILTER: c_uint = 1; +pub const SECCOMP_GET_ACTION_AVAIL: c_uint = 2; +pub const SECCOMP_GET_NOTIF_SIZES: c_uint = 3; + +pub const SECCOMP_FILTER_FLAG_TSYNC: c_ulong = 1 << 0; +pub const SECCOMP_FILTER_FLAG_LOG: c_ulong = 1 << 1; +pub const SECCOMP_FILTER_FLAG_SPEC_ALLOW: c_ulong = 1 << 2; +pub const SECCOMP_FILTER_FLAG_NEW_LISTENER: c_ulong = 1 << 3; +pub const SECCOMP_FILTER_FLAG_TSYNC_ESRCH: c_ulong = 1 << 4; +pub const SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV: c_ulong = 1 << 5; + +pub const SECCOMP_RET_KILL_PROCESS: c_uint = 0x80000000; +pub const SECCOMP_RET_KILL_THREAD: c_uint = 0x00000000; +pub const SECCOMP_RET_KILL: c_uint = SECCOMP_RET_KILL_THREAD; +pub const SECCOMP_RET_TRAP: c_uint = 0x00030000; +pub const SECCOMP_RET_ERRNO: c_uint = 0x00050000; +pub const SECCOMP_RET_USER_NOTIF: c_uint = 0x7fc00000; +pub const SECCOMP_RET_TRACE: c_uint = 0x7ff00000; +pub const SECCOMP_RET_LOG: c_uint = 0x7ffc0000; +pub const SECCOMP_RET_ALLOW: c_uint = 0x7fff0000; + +pub const SECCOMP_RET_ACTION_FULL: c_uint = 0xffff0000; +pub const SECCOMP_RET_ACTION: c_uint = 0x7fff0000; +pub const SECCOMP_RET_DATA: c_uint = 0x0000ffff; + +pub const SECCOMP_USER_NOTIF_FLAG_CONTINUE: c_ulong = 1; + +pub const SECCOMP_ADDFD_FLAG_SETFD: c_ulong = 1; +pub const SECCOMP_ADDFD_FLAG_SEND: c_ulong = 2; + +pub const NLA_F_NESTED: c_int = 1 << 15; +pub const NLA_F_NET_BYTEORDER: c_int = 1 << 14; +pub const NLA_TYPE_MASK: c_int = !(NLA_F_NESTED | NLA_F_NET_BYTEORDER); + +pub const NLA_ALIGNTO: c_int = 4; + +pub const SIGEV_THREAD_ID: c_int = 4; + +pub const CIBAUD: crate::tcflag_t = 0o02003600000; +pub const CBAUDEX: crate::tcflag_t = 0o010000; + +pub const TIOCM_LE: c_int = 0x001; +pub const TIOCM_DTR: c_int = 0x002; +pub const TIOCM_RTS: c_int = 0x004; +pub const TIOCM_ST: c_int = 0x008; +pub const TIOCM_SR: c_int = 0x010; +pub const TIOCM_CTS: c_int = 0x020; +pub const TIOCM_CAR: c_int = 0x040; +pub const TIOCM_RNG: c_int = 0x080; +pub const TIOCM_DSR: c_int = 0x100; +pub const TIOCM_CD: c_int = TIOCM_CAR; +pub const TIOCM_RI: c_int = TIOCM_RNG; + +pub const POLLWRNORM: c_short = 0x100; +pub const POLLWRBAND: c_short = 0x200; + +pub const SFD_CLOEXEC: c_int = O_CLOEXEC; +pub const SFD_NONBLOCK: c_int = O_NONBLOCK; + +pub const SOCK_NONBLOCK: c_int = O_NONBLOCK; + +pub const SO_ORIGINAL_DST: c_int = 80; + +pub const IP_RECVFRAGSIZE: c_int = 25; + +pub const IPV6_FLOWINFO: c_int = 11; +pub const IPV6_MULTICAST_ALL: c_int = 29; +pub const IPV6_ROUTER_ALERT_ISOLATE: c_int = 30; +pub const IPV6_FLOWLABEL_MGR: c_int = 32; +pub const IPV6_FLOWINFO_SEND: c_int = 33; +pub const IPV6_RECVFRAGSIZE: c_int = 77; +pub const IPV6_FREEBIND: c_int = 78; +pub const IPV6_FLOWINFO_FLOWLABEL: c_int = 0x000fffff; +pub const IPV6_FLOWINFO_PRIORITY: c_int = 0x0ff00000; + +pub const IUTF8: crate::tcflag_t = 0x00004000; +pub const CMSPAR: crate::tcflag_t = 0o10000000000; +pub const O_TMPFILE: c_int = 0o20000000 | O_DIRECTORY; + +pub const MFD_CLOEXEC: c_uint = 0x0001; +pub const MFD_ALLOW_SEALING: c_uint = 0x0002; +pub const MFD_HUGETLB: c_uint = 0x0004; +pub const MFD_NOEXEC_SEAL: c_uint = 0x0008; +pub const MFD_EXEC: c_uint = 0x0010; +pub const MFD_HUGE_64KB: c_uint = 0x40000000; +pub const MFD_HUGE_512KB: c_uint = 0x4c000000; +pub const MFD_HUGE_1MB: c_uint = 0x50000000; +pub const MFD_HUGE_2MB: c_uint = 0x54000000; +pub const MFD_HUGE_8MB: c_uint = 0x5c000000; +pub const MFD_HUGE_16MB: c_uint = 0x60000000; +pub const MFD_HUGE_32MB: c_uint = 0x64000000; +pub const MFD_HUGE_256MB: c_uint = 0x70000000; +pub const MFD_HUGE_512MB: c_uint = 0x74000000; +pub const MFD_HUGE_1GB: c_uint = 0x78000000; +pub const MFD_HUGE_2GB: c_uint = 0x7c000000; +pub const MFD_HUGE_16GB: c_uint = 0x88000000; +pub const MFD_HUGE_MASK: c_uint = 63; +pub const MFD_HUGE_SHIFT: c_uint = 26; + +// these are used in the p_type field of Elf32_Phdr and Elf64_Phdr, which has +// the type Elf32Word and Elf64Word respectively. Luckily, both of those are u32 +// so we can use that type here to avoid having to cast. +pub const PT_NULL: u32 = 0; +pub const PT_LOAD: u32 = 1; +pub const PT_DYNAMIC: u32 = 2; +pub const PT_INTERP: u32 = 3; +pub const PT_NOTE: u32 = 4; +pub const PT_SHLIB: u32 = 5; +pub const PT_PHDR: u32 = 6; +pub const PT_TLS: u32 = 7; +pub const PT_LOOS: u32 = 0x60000000; +pub const PT_GNU_EH_FRAME: u32 = 0x6474e550; +pub const PT_GNU_STACK: u32 = 0x6474e551; +pub const PT_GNU_RELRO: u32 = 0x6474e552; +pub const PT_HIOS: u32 = 0x6fffffff; +pub const PT_LOPROC: u32 = 0x70000000; +pub const PT_HIPROC: u32 = 0x7fffffff; + +// uapi/linux/mount.h +pub const OPEN_TREE_CLONE: c_uint = 0x01; +pub const OPEN_TREE_CLOEXEC: c_uint = O_CLOEXEC as c_uint; + +// linux/netfilter.h +pub const NF_DROP: c_int = 0; +pub const NF_ACCEPT: c_int = 1; +pub const NF_STOLEN: c_int = 2; +pub const NF_QUEUE: c_int = 3; +pub const NF_REPEAT: c_int = 4; +pub const NF_STOP: c_int = 5; +pub const NF_MAX_VERDICT: c_int = NF_STOP; + +pub const NF_VERDICT_MASK: c_int = 0x000000ff; +pub const NF_VERDICT_FLAG_QUEUE_BYPASS: c_int = 0x00008000; + +pub const NF_VERDICT_QMASK: c_int = 0xffff0000; +pub const NF_VERDICT_QBITS: c_int = 16; + +pub const NF_VERDICT_BITS: c_int = 16; + +pub const NF_INET_PRE_ROUTING: c_int = 0; +pub const NF_INET_LOCAL_IN: c_int = 1; +pub const NF_INET_FORWARD: c_int = 2; +pub const NF_INET_LOCAL_OUT: c_int = 3; +pub const NF_INET_POST_ROUTING: c_int = 4; +pub const NF_INET_NUMHOOKS: c_int = 5; +pub const NF_INET_INGRESS: c_int = NF_INET_NUMHOOKS; + +pub const NF_NETDEV_INGRESS: c_int = 0; +pub const NF_NETDEV_EGRESS: c_int = 1; +pub const NF_NETDEV_NUMHOOKS: c_int = 2; + +pub const NFPROTO_UNSPEC: c_int = 0; +pub const NFPROTO_INET: c_int = 1; +pub const NFPROTO_IPV4: c_int = 2; +pub const NFPROTO_ARP: c_int = 3; +pub const NFPROTO_NETDEV: c_int = 5; +pub const NFPROTO_BRIDGE: c_int = 7; +pub const NFPROTO_IPV6: c_int = 10; +pub const NFPROTO_DECNET: c_int = 12; +pub const NFPROTO_NUMPROTO: c_int = 13; + +// linux/netfilter_arp.h +pub const NF_ARP: c_int = 0; +pub const NF_ARP_IN: c_int = 0; +pub const NF_ARP_OUT: c_int = 1; +pub const NF_ARP_FORWARD: c_int = 2; +pub const NF_ARP_NUMHOOKS: c_int = 3; + +// linux/netfilter_bridge.h +pub const NF_BR_PRE_ROUTING: c_int = 0; +pub const NF_BR_LOCAL_IN: c_int = 1; +pub const NF_BR_FORWARD: c_int = 2; +pub const NF_BR_LOCAL_OUT: c_int = 3; +pub const NF_BR_POST_ROUTING: c_int = 4; +pub const NF_BR_BROUTING: c_int = 5; +pub const NF_BR_NUMHOOKS: c_int = 6; + +pub const NF_BR_PRI_FIRST: c_int = crate::INT_MIN; +pub const NF_BR_PRI_NAT_DST_BRIDGED: c_int = -300; +pub const NF_BR_PRI_FILTER_BRIDGED: c_int = -200; +pub const NF_BR_PRI_BRNF: c_int = 0; +pub const NF_BR_PRI_NAT_DST_OTHER: c_int = 100; +pub const NF_BR_PRI_FILTER_OTHER: c_int = 200; +pub const NF_BR_PRI_NAT_SRC: c_int = 300; +pub const NF_BR_PRI_LAST: c_int = crate::INT_MAX; + +// linux/netfilter_ipv4.h +pub const NF_IP_PRE_ROUTING: c_int = 0; +pub const NF_IP_LOCAL_IN: c_int = 1; +pub const NF_IP_FORWARD: c_int = 2; +pub const NF_IP_LOCAL_OUT: c_int = 3; +pub const NF_IP_POST_ROUTING: c_int = 4; +pub const NF_IP_NUMHOOKS: c_int = 5; + +pub const NF_IP_PRI_FIRST: c_int = crate::INT_MIN; +pub const NF_IP_PRI_RAW_BEFORE_DEFRAG: c_int = -450; +pub const NF_IP_PRI_CONNTRACK_DEFRAG: c_int = -400; +pub const NF_IP_PRI_RAW: c_int = -300; +pub const NF_IP_PRI_SELINUX_FIRST: c_int = -225; +pub const NF_IP_PRI_CONNTRACK: c_int = -200; +pub const NF_IP_PRI_MANGLE: c_int = -150; +pub const NF_IP_PRI_NAT_DST: c_int = -100; +pub const NF_IP_PRI_FILTER: c_int = 0; +pub const NF_IP_PRI_SECURITY: c_int = 50; +pub const NF_IP_PRI_NAT_SRC: c_int = 100; +pub const NF_IP_PRI_SELINUX_LAST: c_int = 225; +pub const NF_IP_PRI_CONNTRACK_HELPER: c_int = 300; +pub const NF_IP_PRI_CONNTRACK_CONFIRM: c_int = crate::INT_MAX; +pub const NF_IP_PRI_LAST: c_int = crate::INT_MAX; + +// linux/netfilter_ipv6.h +pub const NF_IP6_PRE_ROUTING: c_int = 0; +pub const NF_IP6_LOCAL_IN: c_int = 1; +pub const NF_IP6_FORWARD: c_int = 2; +pub const NF_IP6_LOCAL_OUT: c_int = 3; +pub const NF_IP6_POST_ROUTING: c_int = 4; +pub const NF_IP6_NUMHOOKS: c_int = 5; + +pub const NF_IP6_PRI_FIRST: c_int = crate::INT_MIN; +pub const NF_IP6_PRI_RAW_BEFORE_DEFRAG: c_int = -450; +pub const NF_IP6_PRI_CONNTRACK_DEFRAG: c_int = -400; +pub const NF_IP6_PRI_RAW: c_int = -300; +pub const NF_IP6_PRI_SELINUX_FIRST: c_int = -225; +pub const NF_IP6_PRI_CONNTRACK: c_int = -200; +pub const NF_IP6_PRI_MANGLE: c_int = -150; +pub const NF_IP6_PRI_NAT_DST: c_int = -100; +pub const NF_IP6_PRI_FILTER: c_int = 0; +pub const NF_IP6_PRI_SECURITY: c_int = 50; +pub const NF_IP6_PRI_NAT_SRC: c_int = 100; +pub const NF_IP6_PRI_SELINUX_LAST: c_int = 225; +pub const NF_IP6_PRI_CONNTRACK_HELPER: c_int = 300; +pub const NF_IP6_PRI_LAST: c_int = crate::INT_MAX; + +// linux/netfilter_ipv6/ip6_tables.h +pub const IP6T_SO_ORIGINAL_DST: c_int = 80; + +// linux/netfilter/nf_tables.h +pub const NFT_TABLE_MAXNAMELEN: c_int = 256; +pub const NFT_CHAIN_MAXNAMELEN: c_int = 256; +pub const NFT_SET_MAXNAMELEN: c_int = 256; +pub const NFT_OBJ_MAXNAMELEN: c_int = 256; +pub const NFT_USERDATA_MAXLEN: c_int = 256; + +pub const NFT_REG_VERDICT: c_int = 0; +pub const NFT_REG_1: c_int = 1; +pub const NFT_REG_2: c_int = 2; +pub const NFT_REG_3: c_int = 3; +pub const NFT_REG_4: c_int = 4; +pub const __NFT_REG_MAX: c_int = 5; +pub const NFT_REG32_00: c_int = 8; +pub const NFT_REG32_01: c_int = 9; +pub const NFT_REG32_02: c_int = 10; +pub const NFT_REG32_03: c_int = 11; +pub const NFT_REG32_04: c_int = 12; +pub const NFT_REG32_05: c_int = 13; +pub const NFT_REG32_06: c_int = 14; +pub const NFT_REG32_07: c_int = 15; +pub const NFT_REG32_08: c_int = 16; +pub const NFT_REG32_09: c_int = 17; +pub const NFT_REG32_10: c_int = 18; +pub const NFT_REG32_11: c_int = 19; +pub const NFT_REG32_12: c_int = 20; +pub const NFT_REG32_13: c_int = 21; +pub const NFT_REG32_14: c_int = 22; +pub const NFT_REG32_15: c_int = 23; + +pub const NFT_REG_SIZE: c_int = 16; +pub const NFT_REG32_SIZE: c_int = 4; + +pub const NFT_CONTINUE: c_int = -1; +pub const NFT_BREAK: c_int = -2; +pub const NFT_JUMP: c_int = -3; +pub const NFT_GOTO: c_int = -4; +pub const NFT_RETURN: c_int = -5; + +pub const NFT_MSG_NEWTABLE: c_int = 0; +pub const NFT_MSG_GETTABLE: c_int = 1; +pub const NFT_MSG_DELTABLE: c_int = 2; +pub const NFT_MSG_NEWCHAIN: c_int = 3; +pub const NFT_MSG_GETCHAIN: c_int = 4; +pub const NFT_MSG_DELCHAIN: c_int = 5; +pub const NFT_MSG_NEWRULE: c_int = 6; +pub const NFT_MSG_GETRULE: c_int = 7; +pub const NFT_MSG_DELRULE: c_int = 8; +pub const NFT_MSG_NEWSET: c_int = 9; +pub const NFT_MSG_GETSET: c_int = 10; +pub const NFT_MSG_DELSET: c_int = 11; +pub const NFT_MSG_NEWSETELEM: c_int = 12; +pub const NFT_MSG_GETSETELEM: c_int = 13; +pub const NFT_MSG_DELSETELEM: c_int = 14; +pub const NFT_MSG_NEWGEN: c_int = 15; +pub const NFT_MSG_GETGEN: c_int = 16; +pub const NFT_MSG_TRACE: c_int = 17; +pub const NFT_MSG_NEWOBJ: c_int = 18; +pub const NFT_MSG_GETOBJ: c_int = 19; +pub const NFT_MSG_DELOBJ: c_int = 20; +pub const NFT_MSG_GETOBJ_RESET: c_int = 21; +pub const NFT_MSG_MAX: c_int = 25; + +pub const NFT_SET_ANONYMOUS: c_int = 0x1; +pub const NFT_SET_CONSTANT: c_int = 0x2; +pub const NFT_SET_INTERVAL: c_int = 0x4; +pub const NFT_SET_MAP: c_int = 0x8; +pub const NFT_SET_TIMEOUT: c_int = 0x10; +pub const NFT_SET_EVAL: c_int = 0x20; + +pub const NFT_SET_POL_PERFORMANCE: c_int = 0; +pub const NFT_SET_POL_MEMORY: c_int = 1; + +pub const NFT_SET_ELEM_INTERVAL_END: c_int = 0x1; + +pub const NFT_DATA_VALUE: c_uint = 0; +pub const NFT_DATA_VERDICT: c_uint = 0xffffff00; + +pub const NFT_DATA_RESERVED_MASK: c_uint = 0xffffff00; + +pub const NFT_DATA_VALUE_MAXLEN: c_int = 64; + +pub const NFT_BYTEORDER_NTOH: c_int = 0; +pub const NFT_BYTEORDER_HTON: c_int = 1; + +pub const NFT_CMP_EQ: c_int = 0; +pub const NFT_CMP_NEQ: c_int = 1; +pub const NFT_CMP_LT: c_int = 2; +pub const NFT_CMP_LTE: c_int = 3; +pub const NFT_CMP_GT: c_int = 4; +pub const NFT_CMP_GTE: c_int = 5; + +pub const NFT_RANGE_EQ: c_int = 0; +pub const NFT_RANGE_NEQ: c_int = 1; + +pub const NFT_LOOKUP_F_INV: c_int = 1 << 0; + +pub const NFT_DYNSET_OP_ADD: c_int = 0; +pub const NFT_DYNSET_OP_UPDATE: c_int = 1; + +pub const NFT_DYNSET_F_INV: c_int = 1 << 0; + +pub const NFT_PAYLOAD_LL_HEADER: c_int = 0; +pub const NFT_PAYLOAD_NETWORK_HEADER: c_int = 1; +pub const NFT_PAYLOAD_TRANSPORT_HEADER: c_int = 2; + +pub const NFT_PAYLOAD_CSUM_NONE: c_int = 0; +pub const NFT_PAYLOAD_CSUM_INET: c_int = 1; + +pub const NFT_META_LEN: c_int = 0; +pub const NFT_META_PROTOCOL: c_int = 1; +pub const NFT_META_PRIORITY: c_int = 2; +pub const NFT_META_MARK: c_int = 3; +pub const NFT_META_IIF: c_int = 4; +pub const NFT_META_OIF: c_int = 5; +pub const NFT_META_IIFNAME: c_int = 6; +pub const NFT_META_OIFNAME: c_int = 7; +pub const NFT_META_IIFTYPE: c_int = 8; +pub const NFT_META_OIFTYPE: c_int = 9; +pub const NFT_META_SKUID: c_int = 10; +pub const NFT_META_SKGID: c_int = 11; +pub const NFT_META_NFTRACE: c_int = 12; +pub const NFT_META_RTCLASSID: c_int = 13; +pub const NFT_META_SECMARK: c_int = 14; +pub const NFT_META_NFPROTO: c_int = 15; +pub const NFT_META_L4PROTO: c_int = 16; +pub const NFT_META_BRI_IIFNAME: c_int = 17; +pub const NFT_META_BRI_OIFNAME: c_int = 18; +pub const NFT_META_PKTTYPE: c_int = 19; +pub const NFT_META_CPU: c_int = 20; +pub const NFT_META_IIFGROUP: c_int = 21; +pub const NFT_META_OIFGROUP: c_int = 22; +pub const NFT_META_CGROUP: c_int = 23; +pub const NFT_META_PRANDOM: c_int = 24; + +pub const NFT_CT_STATE: c_int = 0; +pub const NFT_CT_DIRECTION: c_int = 1; +pub const NFT_CT_STATUS: c_int = 2; +pub const NFT_CT_MARK: c_int = 3; +pub const NFT_CT_SECMARK: c_int = 4; +pub const NFT_CT_EXPIRATION: c_int = 5; +pub const NFT_CT_HELPER: c_int = 6; +pub const NFT_CT_L3PROTOCOL: c_int = 7; +pub const NFT_CT_SRC: c_int = 8; +pub const NFT_CT_DST: c_int = 9; +pub const NFT_CT_PROTOCOL: c_int = 10; +pub const NFT_CT_PROTO_SRC: c_int = 11; +pub const NFT_CT_PROTO_DST: c_int = 12; +pub const NFT_CT_LABELS: c_int = 13; +pub const NFT_CT_PKTS: c_int = 14; +pub const NFT_CT_BYTES: c_int = 15; +pub const NFT_CT_AVGPKT: c_int = 16; +pub const NFT_CT_ZONE: c_int = 17; +pub const NFT_CT_EVENTMASK: c_int = 18; +pub const NFT_CT_SRC_IP: c_int = 19; +pub const NFT_CT_DST_IP: c_int = 20; +pub const NFT_CT_SRC_IP6: c_int = 21; +pub const NFT_CT_DST_IP6: c_int = 22; +pub const NFT_CT_ID: c_int = 23; + +pub const NFT_LIMIT_PKTS: c_int = 0; +pub const NFT_LIMIT_PKT_BYTES: c_int = 1; + +pub const NFT_LIMIT_F_INV: c_int = 1 << 0; + +pub const NFT_QUEUE_FLAG_BYPASS: c_int = 0x01; +pub const NFT_QUEUE_FLAG_CPU_FANOUT: c_int = 0x02; +pub const NFT_QUEUE_FLAG_MASK: c_int = 0x03; + +pub const NFT_QUOTA_F_INV: c_int = 1 << 0; + +pub const NFT_REJECT_ICMP_UNREACH: c_int = 0; +pub const NFT_REJECT_TCP_RST: c_int = 1; +pub const NFT_REJECT_ICMPX_UNREACH: c_int = 2; + +pub const NFT_REJECT_ICMPX_NO_ROUTE: c_int = 0; +pub const NFT_REJECT_ICMPX_PORT_UNREACH: c_int = 1; +pub const NFT_REJECT_ICMPX_HOST_UNREACH: c_int = 2; +pub const NFT_REJECT_ICMPX_ADMIN_PROHIBITED: c_int = 3; + +pub const NFT_NAT_SNAT: c_int = 0; +pub const NFT_NAT_DNAT: c_int = 1; + +pub const NFT_TRACETYPE_UNSPEC: c_int = 0; +pub const NFT_TRACETYPE_POLICY: c_int = 1; +pub const NFT_TRACETYPE_RETURN: c_int = 2; +pub const NFT_TRACETYPE_RULE: c_int = 3; + +pub const NFT_NG_INCREMENTAL: c_int = 0; +pub const NFT_NG_RANDOM: c_int = 1; + +// linux/input.h +pub const FF_MAX: crate::__u16 = 0x7f; +pub const FF_CNT: usize = FF_MAX as usize + 1; + +// linux/input-event-codes.h +pub const INPUT_PROP_MAX: crate::__u16 = 0x1f; +pub const INPUT_PROP_CNT: usize = INPUT_PROP_MAX as usize + 1; +pub const EV_MAX: crate::__u16 = 0x1f; +pub const EV_CNT: usize = EV_MAX as usize + 1; +pub const SYN_MAX: crate::__u16 = 0xf; +pub const SYN_CNT: usize = SYN_MAX as usize + 1; +pub const KEY_MAX: crate::__u16 = 0x2ff; +pub const KEY_CNT: usize = KEY_MAX as usize + 1; +pub const REL_MAX: crate::__u16 = 0x0f; +pub const REL_CNT: usize = REL_MAX as usize + 1; +pub const ABS_MAX: crate::__u16 = 0x3f; +pub const ABS_CNT: usize = ABS_MAX as usize + 1; +pub const SW_MAX: crate::__u16 = 0x0f; +pub const SW_CNT: usize = SW_MAX as usize + 1; +pub const MSC_MAX: crate::__u16 = 0x07; +pub const MSC_CNT: usize = MSC_MAX as usize + 1; +pub const LED_MAX: crate::__u16 = 0x0f; +pub const LED_CNT: usize = LED_MAX as usize + 1; +pub const REP_MAX: crate::__u16 = 0x01; +pub const REP_CNT: usize = REP_MAX as usize + 1; +pub const SND_MAX: crate::__u16 = 0x07; +pub const SND_CNT: usize = SND_MAX as usize + 1; + +// linux/uinput.h +pub const UINPUT_VERSION: c_uint = 5; +pub const UINPUT_MAX_NAME_SIZE: usize = 80; + +// start android/platform/bionic/libc/kernel/uapi/linux/if_ether.h +// from https://android.googlesource.com/platform/bionic/+/HEAD/libc/kernel/uapi/linux/if_ether.h +pub const ETH_ALEN: c_int = 6; +pub const ETH_HLEN: c_int = 14; +pub const ETH_ZLEN: c_int = 60; +pub const ETH_DATA_LEN: c_int = 1500; +pub const ETH_FRAME_LEN: c_int = 1514; +pub const ETH_FCS_LEN: c_int = 4; +pub const ETH_MIN_MTU: c_int = 68; +pub const ETH_MAX_MTU: c_int = 0xFFFF; +pub const ETH_P_LOOP: c_int = 0x0060; +pub const ETH_P_PUP: c_int = 0x0200; +pub const ETH_P_PUPAT: c_int = 0x0201; +pub const ETH_P_TSN: c_int = 0x22F0; +pub const ETH_P_IP: c_int = 0x0800; +pub const ETH_P_X25: c_int = 0x0805; +pub const ETH_P_ARP: c_int = 0x0806; +pub const ETH_P_BPQ: c_int = 0x08FF; +pub const ETH_P_IEEEPUP: c_int = 0x0a00; +pub const ETH_P_IEEEPUPAT: c_int = 0x0a01; +pub const ETH_P_BATMAN: c_int = 0x4305; +pub const ETH_P_DEC: c_int = 0x6000; +pub const ETH_P_DNA_DL: c_int = 0x6001; +pub const ETH_P_DNA_RC: c_int = 0x6002; +pub const ETH_P_DNA_RT: c_int = 0x6003; +pub const ETH_P_LAT: c_int = 0x6004; +pub const ETH_P_DIAG: c_int = 0x6005; +pub const ETH_P_CUST: c_int = 0x6006; +pub const ETH_P_SCA: c_int = 0x6007; +pub const ETH_P_TEB: c_int = 0x6558; +pub const ETH_P_RARP: c_int = 0x8035; +pub const ETH_P_ATALK: c_int = 0x809B; +pub const ETH_P_AARP: c_int = 0x80F3; +pub const ETH_P_8021Q: c_int = 0x8100; +/* see rust-lang/libc#924 pub const ETH_P_ERSPAN: c_int = 0x88BE;*/ +pub const ETH_P_IPX: c_int = 0x8137; +pub const ETH_P_IPV6: c_int = 0x86DD; +pub const ETH_P_PAUSE: c_int = 0x8808; +pub const ETH_P_SLOW: c_int = 0x8809; +pub const ETH_P_WCCP: c_int = 0x883E; +pub const ETH_P_MPLS_UC: c_int = 0x8847; +pub const ETH_P_MPLS_MC: c_int = 0x8848; +pub const ETH_P_ATMMPOA: c_int = 0x884c; +pub const ETH_P_PPP_DISC: c_int = 0x8863; +pub const ETH_P_PPP_SES: c_int = 0x8864; +pub const ETH_P_LINK_CTL: c_int = 0x886c; +pub const ETH_P_ATMFATE: c_int = 0x8884; +pub const ETH_P_PAE: c_int = 0x888E; +pub const ETH_P_AOE: c_int = 0x88A2; +pub const ETH_P_8021AD: c_int = 0x88A8; +pub const ETH_P_802_EX1: c_int = 0x88B5; +pub const ETH_P_TIPC: c_int = 0x88CA; +pub const ETH_P_MACSEC: c_int = 0x88E5; +pub const ETH_P_8021AH: c_int = 0x88E7; +pub const ETH_P_MVRP: c_int = 0x88F5; +pub const ETH_P_1588: c_int = 0x88F7; +pub const ETH_P_NCSI: c_int = 0x88F8; +pub const ETH_P_PRP: c_int = 0x88FB; +pub const ETH_P_FCOE: c_int = 0x8906; +/* see rust-lang/libc#924 pub const ETH_P_IBOE: c_int = 0x8915;*/ +pub const ETH_P_TDLS: c_int = 0x890D; +pub const ETH_P_FIP: c_int = 0x8914; +pub const ETH_P_80221: c_int = 0x8917; +pub const ETH_P_HSR: c_int = 0x892F; +/* see rust-lang/libc#924 pub const ETH_P_NSH: c_int = 0x894F;*/ +pub const ETH_P_LOOPBACK: c_int = 0x9000; +pub const ETH_P_QINQ1: c_int = 0x9100; +pub const ETH_P_QINQ2: c_int = 0x9200; +pub const ETH_P_QINQ3: c_int = 0x9300; +pub const ETH_P_EDSA: c_int = 0xDADA; +/* see rust-lang/libc#924 pub const ETH_P_IFE: c_int = 0xED3E;*/ +pub const ETH_P_AF_IUCV: c_int = 0xFBFB; +pub const ETH_P_802_3_MIN: c_int = 0x0600; +pub const ETH_P_802_3: c_int = 0x0001; +pub const ETH_P_AX25: c_int = 0x0002; +pub const ETH_P_ALL: c_int = 0x0003; +pub const ETH_P_802_2: c_int = 0x0004; +pub const ETH_P_SNAP: c_int = 0x0005; +pub const ETH_P_DDCMP: c_int = 0x0006; +pub const ETH_P_WAN_PPP: c_int = 0x0007; +pub const ETH_P_PPP_MP: c_int = 0x0008; +pub const ETH_P_LOCALTALK: c_int = 0x0009; +pub const ETH_P_CAN: c_int = 0x000C; +pub const ETH_P_CANFD: c_int = 0x000D; +pub const ETH_P_PPPTALK: c_int = 0x0010; +pub const ETH_P_TR_802_2: c_int = 0x0011; +pub const ETH_P_MOBITEX: c_int = 0x0015; +pub const ETH_P_CONTROL: c_int = 0x0016; +pub const ETH_P_IRDA: c_int = 0x0017; +pub const ETH_P_ECONET: c_int = 0x0018; +pub const ETH_P_HDLC: c_int = 0x0019; +pub const ETH_P_ARCNET: c_int = 0x001A; +pub const ETH_P_DSA: c_int = 0x001B; +pub const ETH_P_TRAILER: c_int = 0x001C; +pub const ETH_P_PHONET: c_int = 0x00F5; +pub const ETH_P_IEEE802154: c_int = 0x00F6; +pub const ETH_P_CAIF: c_int = 0x00F7; +pub const ETH_P_XDSA: c_int = 0x00F8; +/* see rust-lang/libc#924 pub const ETH_P_MAP: c_int = 0x00F9;*/ +// end android/platform/bionic/libc/kernel/uapi/linux/if_ether.h + +// start android/platform/bionic/libc/kernel/uapi/linux/neighbour.h +pub const NDA_UNSPEC: c_ushort = 0; +pub const NDA_DST: c_ushort = 1; +pub const NDA_LLADDR: c_ushort = 2; +pub const NDA_CACHEINFO: c_ushort = 3; +pub const NDA_PROBES: c_ushort = 4; +pub const NDA_VLAN: c_ushort = 5; +pub const NDA_PORT: c_ushort = 6; +pub const NDA_VNI: c_ushort = 7; +pub const NDA_IFINDEX: c_ushort = 8; +pub const NDA_MASTER: c_ushort = 9; +pub const NDA_LINK_NETNSID: c_ushort = 10; +pub const NDA_SRC_VNI: c_ushort = 11; +pub const NDA_PROTOCOL: c_ushort = 12; +pub const NDA_NH_ID: c_ushort = 13; +pub const NDA_FDB_EXT_ATTRS: c_ushort = 14; +pub const NDA_FLAGS_EXT: c_ushort = 15; +pub const NDA_NDM_STATE_MASK: c_ushort = 16; +pub const NDA_NDM_FLAGS_MASK: c_ushort = 17; + +pub const NTF_USE: u8 = 0x01; +pub const NTF_SELF: u8 = 0x02; +pub const NTF_MASTER: u8 = 0x04; +pub const NTF_PROXY: u8 = 0x08; +pub const NTF_EXT_LEARNED: u8 = 0x10; +pub const NTF_OFFLOADED: u8 = 0x20; +pub const NTF_STICKY: u8 = 0x40; +pub const NTF_ROUTER: u8 = 0x80; + +pub const NTF_EXT_MANAGED: u8 = 0x01; +pub const NTF_EXT_LOCKED: u8 = 0x02; + +pub const NUD_NONE: u16 = 0x00; +pub const NUD_INCOMPLETE: u16 = 0x01; +pub const NUD_REACHABLE: u16 = 0x02; +pub const NUD_STALE: u16 = 0x04; +pub const NUD_DELAY: u16 = 0x08; +pub const NUD_PROBE: u16 = 0x10; +pub const NUD_FAILED: u16 = 0x20; +pub const NUD_NOARP: u16 = 0x40; +pub const NUD_PERMANENT: u16 = 0x80; + +pub const NDTPA_UNSPEC: c_ushort = 0; +pub const NDTPA_IFINDEX: c_ushort = 1; +pub const NDTPA_REFCNT: c_ushort = 2; +pub const NDTPA_REACHABLE_TIME: c_ushort = 3; +pub const NDTPA_BASE_REACHABLE_TIME: c_ushort = 4; +pub const NDTPA_RETRANS_TIME: c_ushort = 5; +pub const NDTPA_GC_STALETIME: c_ushort = 6; +pub const NDTPA_DELAY_PROBE_TIME: c_ushort = 7; +pub const NDTPA_QUEUE_LEN: c_ushort = 8; +pub const NDTPA_APP_PROBES: c_ushort = 9; +pub const NDTPA_UCAST_PROBES: c_ushort = 10; +pub const NDTPA_MCAST_PROBES: c_ushort = 11; +pub const NDTPA_ANYCAST_DELAY: c_ushort = 12; +pub const NDTPA_PROXY_DELAY: c_ushort = 13; +pub const NDTPA_PROXY_QLEN: c_ushort = 14; +pub const NDTPA_LOCKTIME: c_ushort = 15; +pub const NDTPA_QUEUE_LENBYTES: c_ushort = 16; +pub const NDTPA_MCAST_REPROBES: c_ushort = 17; +pub const NDTPA_PAD: c_ushort = 18; +pub const NDTPA_INTERVAL_PROBE_TIME_MS: c_ushort = 19; + +pub const NDTA_UNSPEC: c_ushort = 0; +pub const NDTA_NAME: c_ushort = 1; +pub const NDTA_THRESH1: c_ushort = 2; +pub const NDTA_THRESH2: c_ushort = 3; +pub const NDTA_THRESH3: c_ushort = 4; +pub const NDTA_CONFIG: c_ushort = 5; +pub const NDTA_PARMS: c_ushort = 6; +pub const NDTA_STATS: c_ushort = 7; +pub const NDTA_GC_INTERVAL: c_ushort = 8; +pub const NDTA_PAD: c_ushort = 9; + +pub const FDB_NOTIFY_BIT: u16 = 0x01; +pub const FDB_NOTIFY_INACTIVE_BIT: u16 = 0x02; + +pub const NFEA_UNSPEC: c_ushort = 0; +pub const NFEA_ACTIVITY_NOTIFY: c_ushort = 1; +pub const NFEA_DONT_REFRESH: c_ushort = 2; +// end android/platform/bionic/libc/kernel/uapi/linux/neighbour.h + +pub const SIOCADDRT: c_ulong = 0x0000890B; +pub const SIOCDELRT: c_ulong = 0x0000890C; +pub const SIOCRTMSG: c_ulong = 0x0000890D; +pub const SIOCGIFNAME: c_ulong = 0x00008910; +pub const SIOCSIFLINK: c_ulong = 0x00008911; +pub const SIOCGIFCONF: c_ulong = 0x00008912; +pub const SIOCGIFFLAGS: c_ulong = 0x00008913; +pub const SIOCSIFFLAGS: c_ulong = 0x00008914; +pub const SIOCGIFADDR: c_ulong = 0x00008915; +pub const SIOCSIFADDR: c_ulong = 0x00008916; +pub const SIOCGIFDSTADDR: c_ulong = 0x00008917; +pub const SIOCSIFDSTADDR: c_ulong = 0x00008918; +pub const SIOCGIFBRDADDR: c_ulong = 0x00008919; +pub const SIOCSIFBRDADDR: c_ulong = 0x0000891A; +pub const SIOCGIFNETMASK: c_ulong = 0x0000891B; +pub const SIOCSIFNETMASK: c_ulong = 0x0000891C; +pub const SIOCGIFMETRIC: c_ulong = 0x0000891D; +pub const SIOCSIFMETRIC: c_ulong = 0x0000891E; +pub const SIOCGIFMEM: c_ulong = 0x0000891F; +pub const SIOCSIFMEM: c_ulong = 0x00008920; +pub const SIOCGIFMTU: c_ulong = 0x00008921; +pub const SIOCSIFMTU: c_ulong = 0x00008922; +pub const SIOCSIFNAME: c_ulong = 0x00008923; +pub const SIOCSIFHWADDR: c_ulong = 0x00008924; +pub const SIOCGIFENCAP: c_ulong = 0x00008925; +pub const SIOCSIFENCAP: c_ulong = 0x00008926; +pub const SIOCGIFHWADDR: c_ulong = 0x00008927; +pub const SIOCGIFSLAVE: c_ulong = 0x00008929; +pub const SIOCSIFSLAVE: c_ulong = 0x00008930; +pub const SIOCADDMULTI: c_ulong = 0x00008931; +pub const SIOCDELMULTI: c_ulong = 0x00008932; +pub const SIOCGIFINDEX: c_ulong = 0x00008933; +pub const SIOGIFINDEX: c_ulong = SIOCGIFINDEX; +pub const SIOCSIFPFLAGS: c_ulong = 0x00008934; +pub const SIOCGIFPFLAGS: c_ulong = 0x00008935; +pub const SIOCDIFADDR: c_ulong = 0x00008936; +pub const SIOCSIFHWBROADCAST: c_ulong = 0x00008937; +pub const SIOCGIFCOUNT: c_ulong = 0x00008938; +pub const SIOCGIFBR: c_ulong = 0x00008940; +pub const SIOCSIFBR: c_ulong = 0x00008941; +pub const SIOCGIFTXQLEN: c_ulong = 0x00008942; +pub const SIOCSIFTXQLEN: c_ulong = 0x00008943; +pub const SIOCETHTOOL: c_ulong = 0x00008946; +pub const SIOCGMIIPHY: c_ulong = 0x00008947; +pub const SIOCGMIIREG: c_ulong = 0x00008948; +pub const SIOCSMIIREG: c_ulong = 0x00008949; +pub const SIOCWANDEV: c_ulong = 0x0000894A; +pub const SIOCOUTQNSD: c_ulong = 0x0000894B; +pub const SIOCGSKNS: c_ulong = 0x0000894C; +pub const SIOCDARP: c_ulong = 0x00008953; +pub const SIOCGARP: c_ulong = 0x00008954; +pub const SIOCSARP: c_ulong = 0x00008955; +pub const SIOCDRARP: c_ulong = 0x00008960; +pub const SIOCGRARP: c_ulong = 0x00008961; +pub const SIOCSRARP: c_ulong = 0x00008962; +pub const SIOCGIFMAP: c_ulong = 0x00008970; +pub const SIOCSIFMAP: c_ulong = 0x00008971; +pub const SIOCADDDLCI: c_ulong = 0x00008980; +pub const SIOCDELDLCI: c_ulong = 0x00008981; +pub const SIOCGIFVLAN: c_ulong = 0x00008982; +pub const SIOCSIFVLAN: c_ulong = 0x00008983; +pub const SIOCBONDENSLAVE: c_ulong = 0x00008990; +pub const SIOCBONDRELEASE: c_ulong = 0x00008991; +pub const SIOCBONDSETHWADDR: c_ulong = 0x00008992; +pub const SIOCBONDSLAVEINFOQUERY: c_ulong = 0x00008993; +pub const SIOCBONDINFOQUERY: c_ulong = 0x00008994; +pub const SIOCBONDCHANGEACTIVE: c_ulong = 0x00008995; +pub const SIOCBRADDBR: c_ulong = 0x000089a0; +pub const SIOCBRDELBR: c_ulong = 0x000089a1; +pub const SIOCBRADDIF: c_ulong = 0x000089a2; +pub const SIOCBRDELIF: c_ulong = 0x000089a3; +pub const SIOCSHWTSTAMP: c_ulong = 0x000089b0; +pub const SIOCGHWTSTAMP: c_ulong = 0x000089b1; +pub const SIOCDEVPRIVATE: c_ulong = 0x000089F0; +pub const SIOCPROTOPRIVATE: c_ulong = 0x000089E0; + +// linux/module.h +pub const MODULE_INIT_IGNORE_MODVERSIONS: c_uint = 0x0001; +pub const MODULE_INIT_IGNORE_VERMAGIC: c_uint = 0x0002; + +// linux/net_tstamp.h +pub const SOF_TIMESTAMPING_TX_HARDWARE: c_uint = 1 << 0; +pub const SOF_TIMESTAMPING_TX_SOFTWARE: c_uint = 1 << 1; +pub const SOF_TIMESTAMPING_RX_HARDWARE: c_uint = 1 << 2; +pub const SOF_TIMESTAMPING_RX_SOFTWARE: c_uint = 1 << 3; +pub const SOF_TIMESTAMPING_SOFTWARE: c_uint = 1 << 4; +pub const SOF_TIMESTAMPING_SYS_HARDWARE: c_uint = 1 << 5; +pub const SOF_TIMESTAMPING_RAW_HARDWARE: c_uint = 1 << 6; +pub const SOF_TIMESTAMPING_OPT_ID: c_uint = 1 << 7; +pub const SOF_TIMESTAMPING_TX_SCHED: c_uint = 1 << 8; +pub const SOF_TIMESTAMPING_TX_ACK: c_uint = 1 << 9; +pub const SOF_TIMESTAMPING_OPT_CMSG: c_uint = 1 << 10; +pub const SOF_TIMESTAMPING_OPT_TSONLY: c_uint = 1 << 11; +pub const SOF_TIMESTAMPING_OPT_STATS: c_uint = 1 << 12; +pub const SOF_TIMESTAMPING_OPT_PKTINFO: c_uint = 1 << 13; +pub const SOF_TIMESTAMPING_OPT_TX_SWHW: c_uint = 1 << 14; +pub const SOF_TIMESTAMPING_BIND_PHC: c_uint = 1 << 15; +pub const SOF_TIMESTAMPING_OPT_ID_TCP: c_uint = 1 << 16; +pub const SOF_TIMESTAMPING_OPT_RX_FILTER: c_uint = 1 << 17; + +#[deprecated( + since = "0.2.55", + note = "ENOATTR is not available on Android; use ENODATA instead" +)] +pub const ENOATTR: c_int = crate::ENODATA; + +// linux/if_alg.h +pub const ALG_SET_KEY: c_int = 1; +pub const ALG_SET_IV: c_int = 2; +pub const ALG_SET_OP: c_int = 3; +pub const ALG_SET_AEAD_ASSOCLEN: c_int = 4; +pub const ALG_SET_AEAD_AUTHSIZE: c_int = 5; +pub const ALG_SET_DRBG_ENTROPY: c_int = 6; + +pub const ALG_OP_DECRYPT: c_int = 0; +pub const ALG_OP_ENCRYPT: c_int = 1; + +// sys/mman.h +pub const MLOCK_ONFAULT: c_int = 0x01; + +// uapi/linux/vm_sockets.h +pub const VMADDR_CID_ANY: c_uint = 0xFFFFFFFF; +pub const VMADDR_CID_HYPERVISOR: c_uint = 0; +pub const VMADDR_CID_LOCAL: c_uint = 1; +pub const VMADDR_CID_HOST: c_uint = 2; +pub const VMADDR_PORT_ANY: c_uint = 0xFFFFFFFF; + +// uapi/linux/inotify.h +pub const IN_ACCESS: u32 = 0x0000_0001; +pub const IN_MODIFY: u32 = 0x0000_0002; +pub const IN_ATTRIB: u32 = 0x0000_0004; +pub const IN_CLOSE_WRITE: u32 = 0x0000_0008; +pub const IN_CLOSE_NOWRITE: u32 = 0x0000_0010; +pub const IN_CLOSE: u32 = IN_CLOSE_WRITE | IN_CLOSE_NOWRITE; +pub const IN_OPEN: u32 = 0x0000_0020; +pub const IN_MOVED_FROM: u32 = 0x0000_0040; +pub const IN_MOVED_TO: u32 = 0x0000_0080; +pub const IN_MOVE: u32 = IN_MOVED_FROM | IN_MOVED_TO; +pub const IN_CREATE: u32 = 0x0000_0100; +pub const IN_DELETE: u32 = 0x0000_0200; +pub const IN_DELETE_SELF: u32 = 0x0000_0400; +pub const IN_MOVE_SELF: u32 = 0x0000_0800; +pub const IN_UNMOUNT: u32 = 0x0000_2000; +pub const IN_Q_OVERFLOW: u32 = 0x0000_4000; +pub const IN_IGNORED: u32 = 0x0000_8000; +pub const IN_ONLYDIR: u32 = 0x0100_0000; +pub const IN_DONT_FOLLOW: u32 = 0x0200_0000; +pub const IN_EXCL_UNLINK: u32 = 0x0400_0000; + +pub const IN_MASK_CREATE: u32 = 0x1000_0000; +pub const IN_MASK_ADD: u32 = 0x2000_0000; +pub const IN_ISDIR: u32 = 0x4000_0000; +pub const IN_ONESHOT: u32 = 0x8000_0000; + +pub const IN_ALL_EVENTS: u32 = IN_ACCESS + | IN_MODIFY + | IN_ATTRIB + | IN_CLOSE_WRITE + | IN_CLOSE_NOWRITE + | IN_OPEN + | IN_MOVED_FROM + | IN_MOVED_TO + | IN_DELETE + | IN_CREATE + | IN_DELETE_SELF + | IN_MOVE_SELF; + +pub const IN_CLOEXEC: c_int = O_CLOEXEC; +pub const IN_NONBLOCK: c_int = O_NONBLOCK; + +pub const FUTEX_WAIT: c_int = 0; +pub const FUTEX_WAKE: c_int = 1; +pub const FUTEX_FD: c_int = 2; +pub const FUTEX_REQUEUE: c_int = 3; +pub const FUTEX_CMP_REQUEUE: c_int = 4; +pub const FUTEX_WAKE_OP: c_int = 5; +pub const FUTEX_LOCK_PI: c_int = 6; +pub const FUTEX_UNLOCK_PI: c_int = 7; +pub const FUTEX_TRYLOCK_PI: c_int = 8; +pub const FUTEX_WAIT_BITSET: c_int = 9; +pub const FUTEX_WAKE_BITSET: c_int = 10; +pub const FUTEX_WAIT_REQUEUE_PI: c_int = 11; +pub const FUTEX_CMP_REQUEUE_PI: c_int = 12; +pub const FUTEX_LOCK_PI2: c_int = 13; + +pub const FUTEX_PRIVATE_FLAG: c_int = 128; +pub const FUTEX_CLOCK_REALTIME: c_int = 256; +pub const FUTEX_CMD_MASK: c_int = !(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME); + +// linux/errqueue.h +pub const SO_EE_ORIGIN_NONE: u8 = 0; +pub const SO_EE_ORIGIN_LOCAL: u8 = 1; +pub const SO_EE_ORIGIN_ICMP: u8 = 2; +pub const SO_EE_ORIGIN_ICMP6: u8 = 3; +pub const SO_EE_ORIGIN_TXSTATUS: u8 = 4; +pub const SO_EE_ORIGIN_TIMESTAMPING: u8 = SO_EE_ORIGIN_TXSTATUS; + +// errno.h +pub const EPERM: c_int = 1; +pub const ENOENT: c_int = 2; +pub const ESRCH: c_int = 3; +pub const EINTR: c_int = 4; +pub const EIO: c_int = 5; +pub const ENXIO: c_int = 6; +pub const E2BIG: c_int = 7; +pub const ENOEXEC: c_int = 8; +pub const EBADF: c_int = 9; +pub const ECHILD: c_int = 10; +pub const EAGAIN: c_int = 11; +pub const ENOMEM: c_int = 12; +pub const EACCES: c_int = 13; +pub const EFAULT: c_int = 14; +pub const ENOTBLK: c_int = 15; +pub const EBUSY: c_int = 16; +pub const EEXIST: c_int = 17; +pub const EXDEV: c_int = 18; +pub const ENODEV: c_int = 19; +pub const ENOTDIR: c_int = 20; +pub const EISDIR: c_int = 21; +pub const EINVAL: c_int = 22; +pub const ENFILE: c_int = 23; +pub const EMFILE: c_int = 24; +pub const ENOTTY: c_int = 25; +pub const ETXTBSY: c_int = 26; +pub const EFBIG: c_int = 27; +pub const ENOSPC: c_int = 28; +pub const ESPIPE: c_int = 29; +pub const EROFS: c_int = 30; +pub const EMLINK: c_int = 31; +pub const EPIPE: c_int = 32; +pub const EDOM: c_int = 33; +pub const ERANGE: c_int = 34; +pub const EWOULDBLOCK: c_int = EAGAIN; + +pub const PRIO_PROCESS: c_int = 0; +pub const PRIO_PGRP: c_int = 1; +pub const PRIO_USER: c_int = 2; + +// linux/sched.h +pub const SCHED_NORMAL: c_int = 0; +pub const SCHED_FIFO: c_int = 1; +pub const SCHED_RR: c_int = 2; +pub const SCHED_BATCH: c_int = 3; +pub const SCHED_IDLE: c_int = 5; +pub const SCHED_DEADLINE: c_int = 6; + +pub const SCHED_RESET_ON_FORK: c_int = 0x40000000; + +pub const CLONE_PIDFD: c_int = 0x1000; +pub const CLONE_CLEAR_SIGHAND: c_ulonglong = 0x100000000; +pub const CLONE_INTO_CGROUP: c_ulonglong = 0x200000000; + +// linux/membarrier.h +pub const MEMBARRIER_CMD_QUERY: c_int = 0; +pub const MEMBARRIER_CMD_GLOBAL: c_int = 1 << 0; +pub const MEMBARRIER_CMD_GLOBAL_EXPEDITED: c_int = 1 << 1; +pub const MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED: c_int = 1 << 2; +pub const MEMBARRIER_CMD_PRIVATE_EXPEDITED: c_int = 1 << 3; +pub const MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED: c_int = 1 << 4; +pub const MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE: c_int = 1 << 5; +pub const MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE: c_int = 1 << 6; +pub const MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ: c_int = 1 << 7; +pub const MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ: c_int = 1 << 8; + +// linux/mempolicy.h +pub const MPOL_DEFAULT: c_int = 0; +pub const MPOL_PREFERRED: c_int = 1; +pub const MPOL_BIND: c_int = 2; +pub const MPOL_INTERLEAVE: c_int = 3; +pub const MPOL_LOCAL: c_int = 4; +pub const MPOL_F_NUMA_BALANCING: c_int = 1 << 13; +pub const MPOL_F_RELATIVE_NODES: c_int = 1 << 14; +pub const MPOL_F_STATIC_NODES: c_int = 1 << 15; + +// bits/seek_constants.h +pub const SEEK_DATA: c_int = 3; +pub const SEEK_HOLE: c_int = 4; + +// sys/socket.h +pub const AF_NFC: c_int = 39; +pub const AF_VSOCK: c_int = 40; +pub const PF_NFC: c_int = AF_NFC; +pub const PF_VSOCK: c_int = AF_VSOCK; + +pub const SOMAXCONN: c_int = 128; + +// sys/system_properties.h +pub const PROP_VALUE_MAX: c_int = 92; +pub const PROP_NAME_MAX: c_int = 32; + +// sys/prctl.h +pub const PR_SET_PDEATHSIG: c_int = 1; +pub const PR_GET_PDEATHSIG: c_int = 2; +pub const PR_GET_DUMPABLE: c_int = 3; +pub const PR_SET_DUMPABLE: c_int = 4; +pub const PR_GET_UNALIGN: c_int = 5; +pub const PR_SET_UNALIGN: c_int = 6; +pub const PR_UNALIGN_NOPRINT: c_int = 1; +pub const PR_UNALIGN_SIGBUS: c_int = 2; +pub const PR_GET_KEEPCAPS: c_int = 7; +pub const PR_SET_KEEPCAPS: c_int = 8; +pub const PR_GET_FPEMU: c_int = 9; +pub const PR_SET_FPEMU: c_int = 10; +pub const PR_FPEMU_NOPRINT: c_int = 1; +pub const PR_FPEMU_SIGFPE: c_int = 2; +pub const PR_GET_FPEXC: c_int = 11; +pub const PR_SET_FPEXC: c_int = 12; +pub const PR_FP_EXC_SW_ENABLE: c_int = 0x80; +pub const PR_FP_EXC_DIV: c_int = 0x010000; +pub const PR_FP_EXC_OVF: c_int = 0x020000; +pub const PR_FP_EXC_UND: c_int = 0x040000; +pub const PR_FP_EXC_RES: c_int = 0x080000; +pub const PR_FP_EXC_INV: c_int = 0x100000; +pub const PR_FP_EXC_DISABLED: c_int = 0; +pub const PR_FP_EXC_NONRECOV: c_int = 1; +pub const PR_FP_EXC_ASYNC: c_int = 2; +pub const PR_FP_EXC_PRECISE: c_int = 3; +pub const PR_GET_TIMING: c_int = 13; +pub const PR_SET_TIMING: c_int = 14; +pub const PR_TIMING_STATISTICAL: c_int = 0; +pub const PR_TIMING_TIMESTAMP: c_int = 1; +pub const PR_SET_NAME: c_int = 15; +pub const PR_GET_NAME: c_int = 16; +pub const PR_GET_ENDIAN: c_int = 19; +pub const PR_SET_ENDIAN: c_int = 20; +pub const PR_ENDIAN_BIG: c_int = 0; +pub const PR_ENDIAN_LITTLE: c_int = 1; +pub const PR_ENDIAN_PPC_LITTLE: c_int = 2; +pub const PR_GET_SECCOMP: c_int = 21; +pub const PR_SET_SECCOMP: c_int = 22; +pub const PR_CAPBSET_READ: c_int = 23; +pub const PR_CAPBSET_DROP: c_int = 24; +pub const PR_GET_TSC: c_int = 25; +pub const PR_SET_TSC: c_int = 26; +pub const PR_TSC_ENABLE: c_int = 1; +pub const PR_TSC_SIGSEGV: c_int = 2; +pub const PR_GET_SECUREBITS: c_int = 27; +pub const PR_SET_SECUREBITS: c_int = 28; +pub const PR_SET_TIMERSLACK: c_int = 29; +pub const PR_GET_TIMERSLACK: c_int = 30; +pub const PR_TASK_PERF_EVENTS_DISABLE: c_int = 31; +pub const PR_TASK_PERF_EVENTS_ENABLE: c_int = 32; +pub const PR_MCE_KILL: c_int = 33; +pub const PR_MCE_KILL_CLEAR: c_int = 0; +pub const PR_MCE_KILL_SET: c_int = 1; +pub const PR_MCE_KILL_LATE: c_int = 0; +pub const PR_MCE_KILL_EARLY: c_int = 1; +pub const PR_MCE_KILL_DEFAULT: c_int = 2; +pub const PR_MCE_KILL_GET: c_int = 34; +pub const PR_SET_MM: c_int = 35; +pub const PR_SET_MM_START_CODE: c_int = 1; +pub const PR_SET_MM_END_CODE: c_int = 2; +pub const PR_SET_MM_START_DATA: c_int = 3; +pub const PR_SET_MM_END_DATA: c_int = 4; +pub const PR_SET_MM_START_STACK: c_int = 5; +pub const PR_SET_MM_START_BRK: c_int = 6; +pub const PR_SET_MM_BRK: c_int = 7; +pub const PR_SET_MM_ARG_START: c_int = 8; +pub const PR_SET_MM_ARG_END: c_int = 9; +pub const PR_SET_MM_ENV_START: c_int = 10; +pub const PR_SET_MM_ENV_END: c_int = 11; +pub const PR_SET_MM_AUXV: c_int = 12; +pub const PR_SET_MM_EXE_FILE: c_int = 13; +pub const PR_SET_MM_MAP: c_int = 14; +pub const PR_SET_MM_MAP_SIZE: c_int = 15; +pub const PR_SET_PTRACER: c_int = 0x59616d61; +pub const PR_SET_PTRACER_ANY: c_ulong = 0xffffffffffffffff; +pub const PR_SET_CHILD_SUBREAPER: c_int = 36; +pub const PR_GET_CHILD_SUBREAPER: c_int = 37; +pub const PR_SET_NO_NEW_PRIVS: c_int = 38; +pub const PR_GET_NO_NEW_PRIVS: c_int = 39; +pub const PR_GET_TID_ADDRESS: c_int = 40; +pub const PR_SET_THP_DISABLE: c_int = 41; +pub const PR_GET_THP_DISABLE: c_int = 42; +pub const PR_MPX_ENABLE_MANAGEMENT: c_int = 43; +pub const PR_MPX_DISABLE_MANAGEMENT: c_int = 44; +pub const PR_SET_FP_MODE: c_int = 45; +pub const PR_GET_FP_MODE: c_int = 46; +pub const PR_FP_MODE_FR: c_int = 1 << 0; +pub const PR_FP_MODE_FRE: c_int = 1 << 1; +pub const PR_CAP_AMBIENT: c_int = 47; +pub const PR_CAP_AMBIENT_IS_SET: c_int = 1; +pub const PR_CAP_AMBIENT_RAISE: c_int = 2; +pub const PR_CAP_AMBIENT_LOWER: c_int = 3; +pub const PR_CAP_AMBIENT_CLEAR_ALL: c_int = 4; +pub const PR_SVE_SET_VL: c_int = 50; +pub const PR_SVE_SET_VL_ONEXEC: c_int = 1 << 18; +pub const PR_SVE_GET_VL: c_int = 51; +pub const PR_SVE_VL_LEN_MASK: c_int = 0xffff; +pub const PR_SVE_VL_INHERIT: c_int = 1 << 17; +pub const PR_GET_SPECULATION_CTRL: c_int = 52; +pub const PR_SET_SPECULATION_CTRL: c_int = 53; +pub const PR_SPEC_STORE_BYPASS: c_int = 0; +pub const PR_SPEC_INDIRECT_BRANCH: c_int = 1; +pub const PR_SPEC_L1D_FLUSH: c_int = 2; +pub const PR_SPEC_NOT_AFFECTED: c_int = 0; +pub const PR_SPEC_PRCTL: c_ulong = 1 << 0; +pub const PR_SPEC_ENABLE: c_ulong = 1 << 1; +pub const PR_SPEC_DISABLE: c_ulong = 1 << 2; +pub const PR_SPEC_FORCE_DISABLE: c_ulong = 1 << 3; +pub const PR_SPEC_DISABLE_NOEXEC: c_ulong = 1 << 4; +pub const PR_PAC_RESET_KEYS: c_int = 54; +pub const PR_PAC_APIAKEY: c_ulong = 1 << 0; +pub const PR_PAC_APIBKEY: c_ulong = 1 << 1; +pub const PR_PAC_APDAKEY: c_ulong = 1 << 2; +pub const PR_PAC_APDBKEY: c_ulong = 1 << 3; +pub const PR_PAC_APGAKEY: c_ulong = 1 << 4; +pub const PR_SET_TAGGED_ADDR_CTRL: c_int = 55; +pub const PR_GET_TAGGED_ADDR_CTRL: c_int = 56; +pub const PR_TAGGED_ADDR_ENABLE: c_ulong = 1 << 0; +pub const PR_MTE_TCF_NONE: c_ulong = 0; +pub const PR_MTE_TCF_SYNC: c_ulong = 1 << 1; +pub const PR_MTE_TCF_ASYNC: c_ulong = 1 << 2; +pub const PR_MTE_TCF_MASK: c_ulong = PR_MTE_TCF_SYNC | PR_MTE_TCF_ASYNC; +pub const PR_MTE_TAG_SHIFT: c_ulong = 3; +pub const PR_MTE_TAG_MASK: c_ulong = 0xffff << PR_MTE_TAG_SHIFT; +pub const PR_MTE_TCF_SHIFT: c_ulong = 1; +pub const PR_SET_IO_FLUSHER: c_int = 57; +pub const PR_GET_IO_FLUSHER: c_int = 58; +pub const PR_SET_SYSCALL_USER_DISPATCH: c_int = 59; +pub const PR_SYS_DISPATCH_OFF: c_int = 0; +pub const PR_SYS_DISPATCH_ON: c_int = 1; +pub const SYSCALL_DISPATCH_FILTER_ALLOW: c_int = 0; +pub const SYSCALL_DISPATCH_FILTER_BLOCK: c_int = 1; +pub const PR_PAC_SET_ENABLED_KEYS: c_int = 60; +pub const PR_PAC_GET_ENABLED_KEYS: c_int = 61; +pub const PR_SCHED_CORE: c_int = 62; +pub const PR_SCHED_CORE_GET: c_int = 0; +pub const PR_SCHED_CORE_CREATE: c_int = 1; +pub const PR_SCHED_CORE_SHARE_TO: c_int = 2; +pub const PR_SCHED_CORE_SHARE_FROM: c_int = 3; +pub const PR_SCHED_CORE_MAX: c_int = 4; +pub const PR_SCHED_CORE_SCOPE_THREAD: c_int = 0; +pub const PR_SCHED_CORE_SCOPE_THREAD_GROUP: c_int = 1; +pub const PR_SCHED_CORE_SCOPE_PROCESS_GROUP: c_int = 2; +pub const PR_SME_SET_VL: c_int = 63; +pub const PR_SME_SET_VL_ONEXEC: c_int = 1 << 18; +pub const PR_SME_GET_VL: c_int = 64; +pub const PR_SME_VL_LEN_MASK: c_int = 0xffff; +pub const PR_SME_VL_INHERIT: c_int = 1 << 17; +pub const PR_SET_MDWE: c_int = 65; +pub const PR_MDWE_REFUSE_EXEC_GAIN: c_ulong = 1 << 0; +pub const PR_MDWE_NO_INHERIT: c_ulong = 1 << 1; +pub const PR_GET_MDWE: c_int = 66; +pub const PR_SET_VMA: c_int = 0x53564d41; +pub const PR_SET_VMA_ANON_NAME: c_int = 0; +pub const PR_GET_AUXV: c_int = 0x41555856; +pub const PR_SET_MEMORY_MERGE: c_int = 67; +pub const PR_GET_MEMORY_MERGE: c_int = 68; +pub const PR_RISCV_V_SET_CONTROL: c_int = 69; +pub const PR_RISCV_V_GET_CONTROL: c_int = 70; +pub const PR_RISCV_V_VSTATE_CTRL_DEFAULT: c_int = 0; +pub const PR_RISCV_V_VSTATE_CTRL_OFF: c_int = 1; +pub const PR_RISCV_V_VSTATE_CTRL_ON: c_int = 2; +pub const PR_RISCV_V_VSTATE_CTRL_INHERIT: c_int = 1 << 4; +pub const PR_RISCV_V_VSTATE_CTRL_CUR_MASK: c_int = 0x3; +pub const PR_RISCV_V_VSTATE_CTRL_NEXT_MASK: c_int = 0xc; +pub const PR_RISCV_V_VSTATE_CTRL_MASK: c_int = 0x1f; + +// linux/if_addr.h +pub const IFA_UNSPEC: c_ushort = 0; +pub const IFA_ADDRESS: c_ushort = 1; +pub const IFA_LOCAL: c_ushort = 2; +pub const IFA_LABEL: c_ushort = 3; +pub const IFA_BROADCAST: c_ushort = 4; +pub const IFA_ANYCAST: c_ushort = 5; +pub const IFA_CACHEINFO: c_ushort = 6; +pub const IFA_MULTICAST: c_ushort = 7; + +pub const IFA_F_SECONDARY: u32 = 0x01; +pub const IFA_F_TEMPORARY: u32 = 0x01; +pub const IFA_F_NODAD: u32 = 0x02; +pub const IFA_F_OPTIMISTIC: u32 = 0x04; +pub const IFA_F_DADFAILED: u32 = 0x08; +pub const IFA_F_HOMEADDRESS: u32 = 0x10; +pub const IFA_F_DEPRECATED: u32 = 0x20; +pub const IFA_F_TENTATIVE: u32 = 0x40; +pub const IFA_F_PERMANENT: u32 = 0x80; + +// linux/if_link.h +pub const IFLA_UNSPEC: c_ushort = 0; +pub const IFLA_ADDRESS: c_ushort = 1; +pub const IFLA_BROADCAST: c_ushort = 2; +pub const IFLA_IFNAME: c_ushort = 3; +pub const IFLA_MTU: c_ushort = 4; +pub const IFLA_LINK: c_ushort = 5; +pub const IFLA_QDISC: c_ushort = 6; +pub const IFLA_STATS: c_ushort = 7; +pub const IFLA_COST: c_ushort = 8; +pub const IFLA_PRIORITY: c_ushort = 9; +pub const IFLA_MASTER: c_ushort = 10; +pub const IFLA_WIRELESS: c_ushort = 11; +pub const IFLA_PROTINFO: c_ushort = 12; +pub const IFLA_TXQLEN: c_ushort = 13; +pub const IFLA_MAP: c_ushort = 14; +pub const IFLA_WEIGHT: c_ushort = 15; +pub const IFLA_OPERSTATE: c_ushort = 16; +pub const IFLA_LINKMODE: c_ushort = 17; +pub const IFLA_LINKINFO: c_ushort = 18; +pub const IFLA_NET_NS_PID: c_ushort = 19; +pub const IFLA_IFALIAS: c_ushort = 20; +pub const IFLA_NUM_VF: c_ushort = 21; +pub const IFLA_VFINFO_LIST: c_ushort = 22; +pub const IFLA_STATS64: c_ushort = 23; +pub const IFLA_VF_PORTS: c_ushort = 24; +pub const IFLA_PORT_SELF: c_ushort = 25; +pub const IFLA_AF_SPEC: c_ushort = 26; +pub const IFLA_GROUP: c_ushort = 27; +pub const IFLA_NET_NS_FD: c_ushort = 28; +pub const IFLA_EXT_MASK: c_ushort = 29; +pub const IFLA_PROMISCUITY: c_ushort = 30; +pub const IFLA_NUM_TX_QUEUES: c_ushort = 31; +pub const IFLA_NUM_RX_QUEUES: c_ushort = 32; +pub const IFLA_CARRIER: c_ushort = 33; +pub const IFLA_PHYS_PORT_ID: c_ushort = 34; +pub const IFLA_CARRIER_CHANGES: c_ushort = 35; +pub const IFLA_PHYS_SWITCH_ID: c_ushort = 36; +pub const IFLA_LINK_NETNSID: c_ushort = 37; +pub const IFLA_PHYS_PORT_NAME: c_ushort = 38; +pub const IFLA_PROTO_DOWN: c_ushort = 39; +pub const IFLA_GSO_MAX_SEGS: c_ushort = 40; +pub const IFLA_GSO_MAX_SIZE: c_ushort = 41; +pub const IFLA_PAD: c_ushort = 42; +pub const IFLA_XDP: c_ushort = 43; +pub const IFLA_EVENT: c_ushort = 44; +pub const IFLA_NEW_NETNSID: c_ushort = 45; +pub const IFLA_IF_NETNSID: c_ushort = 46; +pub const IFLA_TARGET_NETNSID: c_ushort = IFLA_IF_NETNSID; +pub const IFLA_CARRIER_UP_COUNT: c_ushort = 47; +pub const IFLA_CARRIER_DOWN_COUNT: c_ushort = 48; +pub const IFLA_NEW_IFINDEX: c_ushort = 49; +pub const IFLA_MIN_MTU: c_ushort = 50; +pub const IFLA_MAX_MTU: c_ushort = 51; +pub const IFLA_PROP_LIST: c_ushort = 52; +pub const IFLA_ALT_IFNAME: c_ushort = 53; +pub const IFLA_PERM_ADDRESS: c_ushort = 54; +pub const IFLA_PROTO_DOWN_REASON: c_ushort = 55; +pub const IFLA_PARENT_DEV_NAME: c_ushort = 56; +pub const IFLA_PARENT_DEV_BUS_NAME: c_ushort = 57; +pub const IFLA_GRO_MAX_SIZE: c_ushort = 58; +pub const IFLA_TSO_MAX_SIZE: c_ushort = 59; +pub const IFLA_TSO_MAX_SEGS: c_ushort = 60; +pub const IFLA_ALLMULTI: c_ushort = 61; +pub const IFLA_DEVLINK_PORT: c_ushort = 62; +pub const IFLA_GSO_IPV4_MAX_SIZE: c_ushort = 63; +pub const IFLA_GRO_IPV4_MAX_SIZE: c_ushort = 64; + +pub const IFLA_INFO_UNSPEC: c_ushort = 0; +pub const IFLA_INFO_KIND: c_ushort = 1; +pub const IFLA_INFO_DATA: c_ushort = 2; +pub const IFLA_INFO_XSTATS: c_ushort = 3; +pub const IFLA_INFO_SLAVE_KIND: c_ushort = 4; +pub const IFLA_INFO_SLAVE_DATA: c_ushort = 5; + +// linux/rtnetlink.h +pub const TCA_UNSPEC: c_ushort = 0; +pub const TCA_KIND: c_ushort = 1; +pub const TCA_OPTIONS: c_ushort = 2; +pub const TCA_STATS: c_ushort = 3; +pub const TCA_XSTATS: c_ushort = 4; +pub const TCA_RATE: c_ushort = 5; +pub const TCA_FCNT: c_ushort = 6; +pub const TCA_STATS2: c_ushort = 7; +pub const TCA_STAB: c_ushort = 8; + +pub const RTM_NEWLINK: u16 = 16; +pub const RTM_DELLINK: u16 = 17; +pub const RTM_GETLINK: u16 = 18; +pub const RTM_SETLINK: u16 = 19; +pub const RTM_NEWADDR: u16 = 20; +pub const RTM_DELADDR: u16 = 21; +pub const RTM_GETADDR: u16 = 22; +pub const RTM_NEWROUTE: u16 = 24; +pub const RTM_DELROUTE: u16 = 25; +pub const RTM_GETROUTE: u16 = 26; +pub const RTM_NEWNEIGH: u16 = 28; +pub const RTM_DELNEIGH: u16 = 29; +pub const RTM_GETNEIGH: u16 = 30; +pub const RTM_NEWRULE: u16 = 32; +pub const RTM_DELRULE: u16 = 33; +pub const RTM_GETRULE: u16 = 34; +pub const RTM_NEWQDISC: u16 = 36; +pub const RTM_DELQDISC: u16 = 37; +pub const RTM_GETQDISC: u16 = 38; +pub const RTM_NEWTCLASS: u16 = 40; +pub const RTM_DELTCLASS: u16 = 41; +pub const RTM_GETTCLASS: u16 = 42; +pub const RTM_NEWTFILTER: u16 = 44; +pub const RTM_DELTFILTER: u16 = 45; +pub const RTM_GETTFILTER: u16 = 46; +pub const RTM_NEWACTION: u16 = 48; +pub const RTM_DELACTION: u16 = 49; +pub const RTM_GETACTION: u16 = 50; +pub const RTM_NEWPREFIX: u16 = 52; +pub const RTM_GETMULTICAST: u16 = 58; +pub const RTM_GETANYCAST: u16 = 62; +pub const RTM_NEWNEIGHTBL: u16 = 64; +pub const RTM_GETNEIGHTBL: u16 = 66; +pub const RTM_SETNEIGHTBL: u16 = 67; +pub const RTM_NEWNDUSEROPT: u16 = 68; +pub const RTM_NEWADDRLABEL: u16 = 72; +pub const RTM_DELADDRLABEL: u16 = 73; +pub const RTM_GETADDRLABEL: u16 = 74; +pub const RTM_GETDCB: u16 = 78; +pub const RTM_SETDCB: u16 = 79; +pub const RTM_NEWNETCONF: u16 = 80; +pub const RTM_GETNETCONF: u16 = 82; +pub const RTM_NEWMDB: u16 = 84; +pub const RTM_DELMDB: u16 = 85; +pub const RTM_GETMDB: u16 = 86; +pub const RTM_NEWNSID: u16 = 88; +pub const RTM_DELNSID: u16 = 89; +pub const RTM_GETNSID: u16 = 90; + +pub const RTM_F_NOTIFY: c_uint = 0x100; +pub const RTM_F_CLONED: c_uint = 0x200; +pub const RTM_F_EQUALIZE: c_uint = 0x400; +pub const RTM_F_PREFIX: c_uint = 0x800; + +pub const RTA_UNSPEC: c_ushort = 0; +pub const RTA_DST: c_ushort = 1; +pub const RTA_SRC: c_ushort = 2; +pub const RTA_IIF: c_ushort = 3; +pub const RTA_OIF: c_ushort = 4; +pub const RTA_GATEWAY: c_ushort = 5; +pub const RTA_PRIORITY: c_ushort = 6; +pub const RTA_PREFSRC: c_ushort = 7; +pub const RTA_METRICS: c_ushort = 8; +pub const RTA_MULTIPATH: c_ushort = 9; +pub const RTA_PROTOINFO: c_ushort = 10; // No longer used +pub const RTA_FLOW: c_ushort = 11; +pub const RTA_CACHEINFO: c_ushort = 12; +pub const RTA_SESSION: c_ushort = 13; // No longer used +pub const RTA_MP_ALGO: c_ushort = 14; // No longer used +pub const RTA_TABLE: c_ushort = 15; +pub const RTA_MARK: c_ushort = 16; +pub const RTA_MFC_STATS: c_ushort = 17; + +pub const RTN_UNSPEC: c_uchar = 0; +pub const RTN_UNICAST: c_uchar = 1; +pub const RTN_LOCAL: c_uchar = 2; +pub const RTN_BROADCAST: c_uchar = 3; +pub const RTN_ANYCAST: c_uchar = 4; +pub const RTN_MULTICAST: c_uchar = 5; +pub const RTN_BLACKHOLE: c_uchar = 6; +pub const RTN_UNREACHABLE: c_uchar = 7; +pub const RTN_PROHIBIT: c_uchar = 8; +pub const RTN_THROW: c_uchar = 9; +pub const RTN_NAT: c_uchar = 10; +pub const RTN_XRESOLVE: c_uchar = 11; + +pub const RTPROT_UNSPEC: c_uchar = 0; +pub const RTPROT_REDIRECT: c_uchar = 1; +pub const RTPROT_KERNEL: c_uchar = 2; +pub const RTPROT_BOOT: c_uchar = 3; +pub const RTPROT_STATIC: c_uchar = 4; + +pub const RT_SCOPE_UNIVERSE: c_uchar = 0; +pub const RT_SCOPE_SITE: c_uchar = 200; +pub const RT_SCOPE_LINK: c_uchar = 253; +pub const RT_SCOPE_HOST: c_uchar = 254; +pub const RT_SCOPE_NOWHERE: c_uchar = 255; + +pub const RT_TABLE_UNSPEC: c_uchar = 0; +pub const RT_TABLE_COMPAT: c_uchar = 252; +pub const RT_TABLE_DEFAULT: c_uchar = 253; +pub const RT_TABLE_MAIN: c_uchar = 254; +pub const RT_TABLE_LOCAL: c_uchar = 255; + +pub const RTMSG_NEWDEVICE: u32 = 0x11; +pub const RTMSG_DELDEVICE: u32 = 0x12; +pub const RTMSG_NEWROUTE: u32 = 0x21; +pub const RTMSG_DELROUTE: u32 = 0x22; + +pub const CTL_KERN: c_int = 1; +pub const CTL_VM: c_int = 2; +pub const CTL_NET: c_int = 3; +pub const CTL_FS: c_int = 5; +pub const CTL_DEBUG: c_int = 6; +pub const CTL_DEV: c_int = 7; +pub const CTL_BUS: c_int = 8; +pub const CTL_ABI: c_int = 9; +pub const CTL_CPU: c_int = 10; + +pub const CTL_BUS_ISA: c_int = 1; + +pub const INOTIFY_MAX_USER_INSTANCES: c_int = 1; +pub const INOTIFY_MAX_USER_WATCHES: c_int = 2; +pub const INOTIFY_MAX_QUEUED_EVENTS: c_int = 3; + +pub const KERN_OSTYPE: c_int = 1; +pub const KERN_OSRELEASE: c_int = 2; +pub const KERN_OSREV: c_int = 3; +pub const KERN_VERSION: c_int = 4; +pub const KERN_SECUREMASK: c_int = 5; +pub const KERN_PROF: c_int = 6; +pub const KERN_NODENAME: c_int = 7; +pub const KERN_DOMAINNAME: c_int = 8; +pub const KERN_PANIC: c_int = 15; +pub const KERN_REALROOTDEV: c_int = 16; +pub const KERN_SPARC_REBOOT: c_int = 21; +pub const KERN_CTLALTDEL: c_int = 22; +pub const KERN_PRINTK: c_int = 23; +pub const KERN_NAMETRANS: c_int = 24; +pub const KERN_PPC_HTABRECLAIM: c_int = 25; +pub const KERN_PPC_ZEROPAGED: c_int = 26; +pub const KERN_PPC_POWERSAVE_NAP: c_int = 27; +pub const KERN_MODPROBE: c_int = 28; +pub const KERN_SG_BIG_BUFF: c_int = 29; +pub const KERN_ACCT: c_int = 30; +pub const KERN_PPC_L2CR: c_int = 31; +pub const KERN_RTSIGNR: c_int = 32; +pub const KERN_RTSIGMAX: c_int = 33; +pub const KERN_SHMMAX: c_int = 34; +pub const KERN_MSGMAX: c_int = 35; +pub const KERN_MSGMNB: c_int = 36; +pub const KERN_MSGPOOL: c_int = 37; +pub const KERN_SYSRQ: c_int = 38; +pub const KERN_MAX_THREADS: c_int = 39; +pub const KERN_RANDOM: c_int = 40; +pub const KERN_SHMALL: c_int = 41; +pub const KERN_MSGMNI: c_int = 42; +pub const KERN_SEM: c_int = 43; +pub const KERN_SPARC_STOP_A: c_int = 44; +pub const KERN_SHMMNI: c_int = 45; +pub const KERN_OVERFLOWUID: c_int = 46; +pub const KERN_OVERFLOWGID: c_int = 47; +pub const KERN_SHMPATH: c_int = 48; +pub const KERN_HOTPLUG: c_int = 49; +pub const KERN_IEEE_EMULATION_WARNINGS: c_int = 50; +pub const KERN_S390_USER_DEBUG_LOGGING: c_int = 51; +pub const KERN_CORE_USES_PID: c_int = 52; +pub const KERN_TAINTED: c_int = 53; +pub const KERN_CADPID: c_int = 54; +pub const KERN_PIDMAX: c_int = 55; +pub const KERN_CORE_PATTERN: c_int = 56; +pub const KERN_PANIC_ON_OOPS: c_int = 57; +pub const KERN_HPPA_PWRSW: c_int = 58; +pub const KERN_HPPA_UNALIGNED: c_int = 59; +pub const KERN_PRINTK_RATELIMIT: c_int = 60; +pub const KERN_PRINTK_RATELIMIT_BURST: c_int = 61; +pub const KERN_PTY: c_int = 62; +pub const KERN_NGROUPS_MAX: c_int = 63; +pub const KERN_SPARC_SCONS_PWROFF: c_int = 64; +pub const KERN_HZ_TIMER: c_int = 65; +pub const KERN_UNKNOWN_NMI_PANIC: c_int = 66; +pub const KERN_BOOTLOADER_TYPE: c_int = 67; +pub const KERN_RANDOMIZE: c_int = 68; +pub const KERN_SETUID_DUMPABLE: c_int = 69; +pub const KERN_SPIN_RETRY: c_int = 70; +pub const KERN_ACPI_VIDEO_FLAGS: c_int = 71; +pub const KERN_IA64_UNALIGNED: c_int = 72; +pub const KERN_COMPAT_LOG: c_int = 73; +pub const KERN_MAX_LOCK_DEPTH: c_int = 74; + +pub const VM_OVERCOMMIT_MEMORY: c_int = 5; +pub const VM_PAGE_CLUSTER: c_int = 10; +pub const VM_DIRTY_BACKGROUND: c_int = 11; +pub const VM_DIRTY_RATIO: c_int = 12; +pub const VM_DIRTY_WB_CS: c_int = 13; +pub const VM_DIRTY_EXPIRE_CS: c_int = 14; +pub const VM_NR_PDFLUSH_THREADS: c_int = 15; +pub const VM_OVERCOMMIT_RATIO: c_int = 16; +pub const VM_PAGEBUF: c_int = 17; +pub const VM_HUGETLB_PAGES: c_int = 18; +pub const VM_SWAPPINESS: c_int = 19; +pub const VM_LOWMEM_RESERVE_RATIO: c_int = 20; +pub const VM_MIN_FREE_KBYTES: c_int = 21; +pub const VM_MAX_MAP_COUNT: c_int = 22; +pub const VM_LAPTOP_MODE: c_int = 23; +pub const VM_BLOCK_DUMP: c_int = 24; +pub const VM_HUGETLB_GROUP: c_int = 25; +pub const VM_VFS_CACHE_PRESSURE: c_int = 26; +pub const VM_LEGACY_VA_LAYOUT: c_int = 27; +pub const VM_SWAP_TOKEN_TIMEOUT: c_int = 28; +pub const VM_DROP_PAGECACHE: c_int = 29; +pub const VM_PERCPU_PAGELIST_FRACTION: c_int = 30; +pub const VM_ZONE_RECLAIM_MODE: c_int = 31; +pub const VM_MIN_UNMAPPED: c_int = 32; +pub const VM_PANIC_ON_OOM: c_int = 33; +pub const VM_VDSO_ENABLED: c_int = 34; + +pub const NET_CORE: c_int = 1; +pub const NET_ETHER: c_int = 2; +pub const NET_802: c_int = 3; +pub const NET_UNIX: c_int = 4; +pub const NET_IPV4: c_int = 5; +pub const NET_IPX: c_int = 6; +pub const NET_ATALK: c_int = 7; +pub const NET_NETROM: c_int = 8; +pub const NET_AX25: c_int = 9; +pub const NET_BRIDGE: c_int = 10; +pub const NET_ROSE: c_int = 11; +pub const NET_IPV6: c_int = 12; +pub const NET_X25: c_int = 13; +pub const NET_TR: c_int = 14; +pub const NET_DECNET: c_int = 15; +pub const NET_ECONET: c_int = 16; +pub const NET_SCTP: c_int = 17; +pub const NET_LLC: c_int = 18; +pub const NET_NETFILTER: c_int = 19; +pub const NET_DCCP: c_int = 20; +pub const HUGETLB_FLAG_ENCODE_SHIFT: c_int = 26; +pub const MAP_HUGE_SHIFT: c_int = HUGETLB_FLAG_ENCODE_SHIFT; + +// include/linux/sched.h +pub const PF_VCPU: c_int = 0x00000001; +pub const PF_IDLE: c_int = 0x00000002; +pub const PF_EXITING: c_int = 0x00000004; +pub const PF_POSTCOREDUMP: c_int = 0x00000008; +pub const PF_IO_WORKER: c_int = 0x00000010; +pub const PF_WQ_WORKER: c_int = 0x00000020; +pub const PF_FORKNOEXEC: c_int = 0x00000040; +pub const PF_MCE_PROCESS: c_int = 0x00000080; +pub const PF_SUPERPRIV: c_int = 0x00000100; +pub const PF_DUMPCORE: c_int = 0x00000200; +pub const PF_SIGNALED: c_int = 0x00000400; +pub const PF_MEMALLOC: c_int = 0x00000800; +pub const PF_NPROC_EXCEEDED: c_int = 0x00001000; +pub const PF_USED_MATH: c_int = 0x00002000; +pub const PF_USER_WORKER: c_int = 0x00004000; +pub const PF_NOFREEZE: c_int = 0x00008000; + +pub const PF_KSWAPD: c_int = 0x00020000; +pub const PF_MEMALLOC_NOFS: c_int = 0x00040000; +pub const PF_MEMALLOC_NOIO: c_int = 0x00080000; +pub const PF_LOCAL_THROTTLE: c_int = 0x00100000; +pub const PF_KTHREAD: c_int = 0x00200000; +pub const PF_RANDOMIZE: c_int = 0x00400000; + +pub const PF_NO_SETAFFINITY: c_int = 0x04000000; +pub const PF_MCE_EARLY: c_int = 0x08000000; +pub const PF_MEMALLOC_PIN: c_int = 0x10000000; + +pub const PF_SUSPEND_TASK: c_int = 0x80000000; + +pub const KLOG_CLOSE: c_int = 0; +pub const KLOG_OPEN: c_int = 1; +pub const KLOG_READ: c_int = 2; +pub const KLOG_READ_ALL: c_int = 3; +pub const KLOG_READ_CLEAR: c_int = 4; +pub const KLOG_CLEAR: c_int = 5; +pub const KLOG_CONSOLE_OFF: c_int = 6; +pub const KLOG_CONSOLE_ON: c_int = 7; +pub const KLOG_CONSOLE_LEVEL: c_int = 8; +pub const KLOG_SIZE_UNREAD: c_int = 9; +pub const KLOG_SIZE_BUFFER: c_int = 10; + +// From NDK's linux/auxvec.h +pub const AT_NULL: c_ulong = 0; +pub const AT_IGNORE: c_ulong = 1; +pub const AT_EXECFD: c_ulong = 2; +pub const AT_PHDR: c_ulong = 3; +pub const AT_PHENT: c_ulong = 4; +pub const AT_PHNUM: c_ulong = 5; +pub const AT_PAGESZ: c_ulong = 6; +pub const AT_BASE: c_ulong = 7; +pub const AT_FLAGS: c_ulong = 8; +pub const AT_ENTRY: c_ulong = 9; +pub const AT_NOTELF: c_ulong = 10; +pub const AT_UID: c_ulong = 11; +pub const AT_EUID: c_ulong = 12; +pub const AT_GID: c_ulong = 13; +pub const AT_EGID: c_ulong = 14; +pub const AT_PLATFORM: c_ulong = 15; +pub const AT_HWCAP: c_ulong = 16; +pub const AT_CLKTCK: c_ulong = 17; +pub const AT_SECURE: c_ulong = 23; +pub const AT_BASE_PLATFORM: c_ulong = 24; +pub const AT_RANDOM: c_ulong = 25; +pub const AT_HWCAP2: c_ulong = 26; +pub const AT_RSEQ_FEATURE_SIZE: c_ulong = 27; +pub const AT_RSEQ_ALIGN: c_ulong = 28; +pub const AT_HWCAP3: c_ulong = 29; +pub const AT_HWCAP4: c_ulong = 30; +pub const AT_EXECFN: c_ulong = 31; +pub const AT_MINSIGSTKSZ: c_ulong = 51; + +// siginfo.h +pub const SI_DETHREAD: c_int = -7; +pub const TRAP_PERF: c_int = 6; + +// Most `*_SUPER_MAGIC` constants are defined at the `linux_like` level; the +// following are only available on newer Linux versions than the versions +// currently used in CI in some configurations, so we define them here. +cfg_if! { + if #[cfg(not(target_arch = "s390x"))] { + pub const XFS_SUPER_MAGIC: c_long = 0x58465342; + } else if #[cfg(target_arch = "s390x")] { + pub const XFS_SUPER_MAGIC: c_uint = 0x58465342; + } +} + +f! { + pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { + let next = (cmsg as usize + super::CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr; + let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; + if (next.offset(1)) as usize > max { + core::ptr::null_mut::() + } else { + next as *mut cmsghdr + } + } + + pub fn CPU_ALLOC_SIZE(count: c_int) -> size_t { + let _dummy: cpu_set_t = mem::zeroed(); + let size_in_bits = 8 * size_of_val(&_dummy.__bits[0]); + ((count as size_t + size_in_bits - 1) / 8) as size_t + } + + pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { + for slot in cpuset.__bits.iter_mut() { + *slot = 0; + } + } + + pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { + let size_in_bits = 8 * size_of_val(&cpuset.__bits[0]); // 32, 64 etc + let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); + cpuset.__bits[idx] |= 1 << offset; + () + } + + pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { + let size_in_bits = 8 * size_of_val(&cpuset.__bits[0]); // 32, 64 etc + let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); + cpuset.__bits[idx] &= !(1 << offset); + () + } + + pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { + let size_in_bits = 8 * size_of_val(&cpuset.__bits[0]); + let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); + 0 != (cpuset.__bits[idx] & (1 << offset)) + } + + pub fn CPU_COUNT_S(size: usize, cpuset: &cpu_set_t) -> c_int { + let mut s: u32 = 0; + let size_of_mask = size_of_val(&cpuset.__bits[0]); + for i in cpuset.__bits[..(size / size_of_mask)].iter() { + s += i.count_ones(); + } + s as c_int + } + + pub fn CPU_COUNT(cpuset: &cpu_set_t) -> c_int { + CPU_COUNT_S(size_of::(), cpuset) + } + + pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool { + set1.__bits == set2.__bits + } + + pub fn NLA_ALIGN(len: c_int) -> c_int { + return ((len) + NLA_ALIGNTO - 1) & !(NLA_ALIGNTO - 1); + } + + pub fn SO_EE_OFFENDER(ee: *const crate::sock_extended_err) -> *mut crate::sockaddr { + ee.offset(1) as *mut crate::sockaddr + } +} + +safe_f! { + pub const fn makedev(ma: c_uint, mi: c_uint) -> crate::dev_t { + let ma = ma as crate::dev_t; + let mi = mi as crate::dev_t; + ((ma & 0xfff) << 8) | (mi & 0xff) | ((mi & 0xfff00) << 12) + } + + pub const fn major(dev: crate::dev_t) -> c_int { + ((dev >> 8) & 0xfff) as c_int + } + + pub const fn minor(dev: crate::dev_t) -> c_int { + ((dev & 0xff) | ((dev >> 12) & 0xfff00)) as c_int + } +} + +extern "C" { + pub fn setgrent(); + pub fn endgrent(); + pub fn getgrent() -> *mut crate::group; + pub fn getrlimit64(resource: c_int, rlim: *mut rlimit64) -> c_int; + pub fn setrlimit64(resource: c_int, rlim: *const rlimit64) -> c_int; + pub fn getrlimit(resource: c_int, rlim: *mut crate::rlimit) -> c_int; + pub fn setrlimit(resource: c_int, rlim: *const crate::rlimit) -> c_int; + pub fn prlimit( + pid: crate::pid_t, + resource: c_int, + new_limit: *const crate::rlimit, + old_limit: *mut crate::rlimit, + ) -> c_int; + pub fn prlimit64( + pid: crate::pid_t, + resource: c_int, + new_limit: *const crate::rlimit64, + old_limit: *mut crate::rlimit64, + ) -> c_int; + pub fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int; + + pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut crate::timezone) -> c_int; + pub fn mlock2(addr: *const c_void, len: size_t, flags: c_int) -> c_int; + pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; + pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int; + pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; + pub fn getnameinfo( + sa: *const crate::sockaddr, + salen: crate::socklen_t, + host: *mut c_char, + hostlen: size_t, + serv: *mut c_char, + servlen: size_t, + flags: c_int, + ) -> c_int; + pub fn preadv(fd: c_int, iov: *const crate::iovec, count: c_int, offset: off_t) -> ssize_t; + pub fn pwritev(fd: c_int, iov: *const crate::iovec, count: c_int, offset: off_t) -> ssize_t; + pub fn process_vm_readv( + pid: crate::pid_t, + local_iov: *const crate::iovec, + local_iov_count: c_ulong, + remote_iov: *const crate::iovec, + remote_iov_count: c_ulong, + flags: c_ulong, + ) -> ssize_t; + pub fn process_vm_writev( + pid: crate::pid_t, + local_iov: *const crate::iovec, + local_iov_count: c_ulong, + remote_iov: *const crate::iovec, + remote_iov_count: c_ulong, + flags: c_ulong, + ) -> ssize_t; + pub fn ptrace(request: c_int, ...) -> c_long; + pub fn getpriority(which: c_int, who: crate::id_t) -> c_int; + pub fn setpriority(which: c_int, who: crate::id_t, prio: c_int) -> c_int; + pub fn __sched_cpualloc(count: size_t) -> *mut crate::cpu_set_t; + pub fn __sched_cpufree(set: *mut crate::cpu_set_t); + pub fn __sched_cpucount(setsize: size_t, set: *const cpu_set_t) -> c_int; + pub fn sched_getcpu() -> c_int; + pub fn mallinfo() -> crate::mallinfo; + // available from API 23 + pub fn malloc_info(options: c_int, stream: *mut crate::FILE) -> c_int; + + pub fn malloc_usable_size(ptr: *const c_void) -> size_t; + + pub fn utmpname(name: *const c_char) -> c_int; + pub fn setutent(); + pub fn getutent() -> *mut utmp; + + pub fn seekdir(dirp: *mut crate::DIR, loc: c_long); + pub fn telldir(dirp: *mut crate::DIR) -> c_long; + pub fn fallocate(fd: c_int, mode: c_int, offset: off_t, len: off_t) -> c_int; + pub fn fallocate64(fd: c_int, mode: c_int, offset: off64_t, len: off64_t) -> c_int; + pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int; + pub fn posix_fallocate64(fd: c_int, offset: off64_t, len: off64_t) -> c_int; + pub fn getxattr( + path: *const c_char, + name: *const c_char, + value: *mut c_void, + size: size_t, + ) -> ssize_t; + pub fn lgetxattr( + path: *const c_char, + name: *const c_char, + value: *mut c_void, + size: size_t, + ) -> ssize_t; + pub fn fgetxattr( + filedes: c_int, + name: *const c_char, + value: *mut c_void, + size: size_t, + ) -> ssize_t; + pub fn setxattr( + path: *const c_char, + name: *const c_char, + value: *const c_void, + size: size_t, + flags: c_int, + ) -> c_int; + pub fn lsetxattr( + path: *const c_char, + name: *const c_char, + value: *const c_void, + size: size_t, + flags: c_int, + ) -> c_int; + pub fn fsetxattr( + filedes: c_int, + name: *const c_char, + value: *const c_void, + size: size_t, + flags: c_int, + ) -> c_int; + pub fn listxattr(path: *const c_char, list: *mut c_char, size: size_t) -> ssize_t; + pub fn llistxattr(path: *const c_char, list: *mut c_char, size: size_t) -> ssize_t; + pub fn flistxattr(filedes: c_int, list: *mut c_char, size: size_t) -> ssize_t; + pub fn removexattr(path: *const c_char, name: *const c_char) -> c_int; + pub fn lremovexattr(path: *const c_char, name: *const c_char) -> c_int; + pub fn fremovexattr(filedes: c_int, name: *const c_char) -> c_int; + pub fn signalfd(fd: c_int, mask: *const crate::sigset_t, flags: c_int) -> c_int; + pub fn timerfd_create(clock: crate::clockid_t, flags: c_int) -> c_int; + pub fn timerfd_gettime(fd: c_int, current_value: *mut itimerspec) -> c_int; + pub fn timerfd_settime( + fd: c_int, + flags: c_int, + new_value: *const itimerspec, + old_value: *mut itimerspec, + ) -> c_int; + pub fn syscall(num: c_long, ...) -> c_long; + pub fn sched_getaffinity( + pid: crate::pid_t, + cpusetsize: size_t, + cpuset: *mut cpu_set_t, + ) -> c_int; + pub fn sched_setaffinity( + pid: crate::pid_t, + cpusetsize: size_t, + cpuset: *const cpu_set_t, + ) -> c_int; + pub fn epoll_create(size: c_int) -> c_int; + pub fn epoll_create1(flags: c_int) -> c_int; + pub fn epoll_wait( + epfd: c_int, + events: *mut crate::epoll_event, + maxevents: c_int, + timeout: c_int, + ) -> c_int; + pub fn epoll_ctl(epfd: c_int, op: c_int, fd: c_int, event: *mut crate::epoll_event) -> c_int; + pub fn unshare(flags: c_int) -> c_int; + pub fn umount(target: *const c_char) -> c_int; + pub fn sched_get_priority_max(policy: c_int) -> c_int; + pub fn tee(fd_in: c_int, fd_out: c_int, len: size_t, flags: c_uint) -> ssize_t; + pub fn settimeofday(tv: *const crate::timeval, tz: *const crate::timezone) -> c_int; + pub fn splice( + fd_in: c_int, + off_in: *mut crate::loff_t, + fd_out: c_int, + off_out: *mut crate::loff_t, + len: size_t, + flags: c_uint, + ) -> ssize_t; + pub fn eventfd(initval: c_uint, flags: c_int) -> c_int; + pub fn eventfd_read(fd: c_int, value: *mut eventfd_t) -> c_int; + pub fn eventfd_write(fd: c_int, value: eventfd_t) -> c_int; + pub fn sched_rr_get_interval(pid: crate::pid_t, tp: *mut crate::timespec) -> c_int; + pub fn sem_timedwait(sem: *mut sem_t, abstime: *const crate::timespec) -> c_int; + pub fn sem_getvalue(sem: *mut sem_t, sval: *mut c_int) -> c_int; + pub fn sched_setparam(pid: crate::pid_t, param: *const crate::sched_param) -> c_int; + pub fn setns(fd: c_int, nstype: c_int) -> c_int; + pub fn swapoff(puath: *const c_char) -> c_int; + pub fn vmsplice(fd: c_int, iov: *const crate::iovec, nr_segs: size_t, flags: c_uint) + -> ssize_t; + pub fn mount( + src: *const c_char, + target: *const c_char, + fstype: *const c_char, + flags: c_ulong, + data: *const c_void, + ) -> c_int; + pub fn personality(persona: c_uint) -> c_int; + pub fn prctl(option: c_int, ...) -> c_int; + pub fn sched_getparam(pid: crate::pid_t, param: *mut crate::sched_param) -> c_int; + pub fn ppoll( + fds: *mut crate::pollfd, + nfds: nfds_t, + timeout: *const crate::timespec, + sigmask: *const sigset_t, + ) -> c_int; + + pub fn clone( + cb: extern "C" fn(*mut c_void) -> c_int, + child_stack: *mut c_void, + flags: c_int, + arg: *mut c_void, + ... + ) -> c_int; + pub fn sched_getscheduler(pid: crate::pid_t) -> c_int; + pub fn clock_nanosleep( + clk_id: crate::clockid_t, + flags: c_int, + rqtp: *const crate::timespec, + rmtp: *mut crate::timespec, + ) -> c_int; + + pub fn sethostname(name: *const c_char, len: size_t) -> c_int; + pub fn sched_get_priority_min(policy: c_int) -> c_int; + pub fn sysinfo(info: *mut crate::sysinfo) -> c_int; + pub fn umount2(target: *const c_char, flags: c_int) -> c_int; + pub fn swapon(path: *const c_char, swapflags: c_int) -> c_int; + pub fn sched_setscheduler( + pid: crate::pid_t, + policy: c_int, + param: *const crate::sched_param, + ) -> c_int; + pub fn sendfile(out_fd: c_int, in_fd: c_int, offset: *mut off_t, count: size_t) -> ssize_t; + pub fn sendfile64(out_fd: c_int, in_fd: c_int, offset: *mut off64_t, count: size_t) -> ssize_t; + pub fn setfsgid(gid: crate::gid_t) -> c_int; + pub fn setfsuid(uid: crate::uid_t) -> c_int; + pub fn sigsuspend(mask: *const crate::sigset_t) -> c_int; + pub fn getgrgid_r( + gid: crate::gid_t, + grp: *mut crate::group, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::group, + ) -> c_int; + pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> c_int; + pub fn sem_close(sem: *mut sem_t) -> c_int; + pub fn getgrnam_r( + name: *const c_char, + grp: *mut crate::group, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::group, + ) -> c_int; + pub fn sem_open(name: *const c_char, oflag: c_int, ...) -> *mut sem_t; + pub fn getgrnam(name: *const c_char) -> *mut crate::group; + pub fn sem_unlink(name: *const c_char) -> c_int; + pub fn daemon(nochdir: c_int, noclose: c_int) -> c_int; + pub fn sigtimedwait( + set: *const sigset_t, + info: *mut siginfo_t, + timeout: *const crate::timespec, + ) -> c_int; + pub fn sigwait(set: *const sigset_t, sig: *mut c_int) -> c_int; + pub fn getgrgid(gid: crate::gid_t) -> *mut crate::group; + pub fn getgrouplist( + user: *const c_char, + group: crate::gid_t, + groups: *mut crate::gid_t, + ngroups: *mut c_int, + ) -> c_int; + pub fn initgroups(user: *const c_char, group: crate::gid_t) -> c_int; + pub fn popen(command: *const c_char, mode: *const c_char) -> *mut crate::FILE; + pub fn faccessat(dirfd: c_int, pathname: *const c_char, mode: c_int, flags: c_int) -> c_int; + pub fn __errno() -> *mut c_int; + pub fn inotify_rm_watch(fd: c_int, wd: u32) -> c_int; + pub fn inotify_init() -> c_int; + pub fn inotify_init1(flags: c_int) -> c_int; + pub fn inotify_add_watch(fd: c_int, path: *const c_char, mask: u32) -> c_int; + + pub fn regcomp(preg: *mut crate::regex_t, pattern: *const c_char, cflags: c_int) -> c_int; + + pub fn regexec( + preg: *const crate::regex_t, + input: *const c_char, + nmatch: size_t, + pmatch: *mut regmatch_t, + eflags: c_int, + ) -> c_int; + + pub fn regerror( + errcode: c_int, + preg: *const crate::regex_t, + errbuf: *mut c_char, + errbuf_size: size_t, + ) -> size_t; + + pub fn regfree(preg: *mut crate::regex_t); + + pub fn android_set_abort_message(msg: *const c_char); + + pub fn gettid() -> crate::pid_t; + + pub fn tgkill(tgid: crate::pid_t, tid: crate::pid_t, sig: c_int) -> c_int; + + pub fn getauxval(type_: c_ulong) -> c_ulong; + + /// Only available in API Version 28+ + pub fn getrandom(buf: *mut c_void, buflen: size_t, flags: c_uint) -> ssize_t; + pub fn getentropy(buf: *mut c_void, buflen: size_t) -> c_int; + + pub fn __system_property_set(__name: *const c_char, __value: *const c_char) -> c_int; + pub fn __system_property_get(__name: *const c_char, __value: *mut c_char) -> c_int; + pub fn __system_property_find(__name: *const c_char) -> *const prop_info; + pub fn __system_property_find_nth(__n: c_uint) -> *const prop_info; + pub fn __system_property_foreach( + __callback: unsafe extern "C" fn(__pi: *const prop_info, __cookie: *mut c_void), + __cookie: *mut c_void, + ) -> c_int; + + // #include + /// Only available in API Version 21+ + pub fn dl_iterate_phdr( + callback: Option< + unsafe extern "C" fn(info: *mut dl_phdr_info, size: usize, data: *mut c_void) -> c_int, + >, + data: *mut c_void, + ) -> c_int; + + pub fn arc4random() -> u32; + pub fn arc4random_uniform(__upper_bound: u32) -> u32; + pub fn arc4random_buf(__buf: *mut c_void, __n: size_t); + + pub fn reallocarray(ptr: *mut c_void, nmemb: size_t, size: size_t) -> *mut c_void; + + pub fn dirname(path: *const c_char) -> *mut c_char; + pub fn basename(path: *const c_char) -> *mut c_char; + pub fn getopt_long( + argc: c_int, + argv: *const *mut c_char, + optstring: *const c_char, + longopts: *const option, + longindex: *mut c_int, + ) -> c_int; + + pub fn sync(); + pub fn syncfs(fd: c_int) -> c_int; + + pub fn memmem( + haystack: *const c_void, + haystacklen: size_t, + needle: *const c_void, + needlelen: size_t, + ) -> *mut c_void; + pub fn fread_unlocked( + buf: *mut c_void, + size: size_t, + nobj: size_t, + stream: *mut crate::FILE, + ) -> size_t; + pub fn fwrite_unlocked( + buf: *const c_void, + size: size_t, + nobj: size_t, + stream: *mut crate::FILE, + ) -> size_t; + pub fn fflush_unlocked(stream: *mut crate::FILE) -> c_int; + pub fn fgets_unlocked(buf: *mut c_char, size: c_int, stream: *mut crate::FILE) -> *mut c_char; + + pub fn klogctl(syslog_type: c_int, bufp: *mut c_char, len: c_int) -> c_int; + + pub fn memfd_create(name: *const c_char, flags: c_uint) -> c_int; + pub fn renameat2( + olddirfd: c_int, + oldpath: *const c_char, + newdirfd: c_int, + newpath: *const c_char, + flags: c_uint, + ) -> c_int; +} + +cfg_if! { + if #[cfg(target_pointer_width = "32")] { + mod b32; + pub use self::b32::*; + } else if #[cfg(target_pointer_width = "64")] { + mod b64; + pub use self::b64::*; + } else { + // Unknown target_pointer_width + } +} + +impl siginfo_t { + pub unsafe fn si_addr(&self) -> *mut c_void { + #[repr(C)] + struct siginfo_sigfault { + _si_signo: c_int, + _si_errno: c_int, + _si_code: c_int, + si_addr: *mut c_void, + } + (*(self as *const siginfo_t as *const siginfo_sigfault)).si_addr + } + + pub unsafe fn si_value(&self) -> crate::sigval { + #[repr(C)] + struct siginfo_timer { + _si_signo: c_int, + _si_errno: c_int, + _si_code: c_int, + _si_tid: c_int, + _si_overrun: c_int, + si_sigval: crate::sigval, + } + (*(self as *const siginfo_t as *const siginfo_timer)).si_sigval + } +} + +impl siginfo_t { + unsafe fn sifields(&self) -> &sifields { + &(*(self as *const siginfo_t as *const siginfo_f)).sifields + } + + pub unsafe fn si_pid(&self) -> crate::pid_t { + self.sifields().sigchld.si_pid + } + + pub unsafe fn si_uid(&self) -> crate::uid_t { + self.sifields().sigchld.si_uid + } + + pub unsafe fn si_status(&self) -> c_int { + self.sifields().sigchld.si_status + } + + pub unsafe fn si_utime(&self) -> c_long { + self.sifields().sigchld.si_utime + } + + pub unsafe fn si_stime(&self) -> c_long { + self.sifields().sigchld.si_stime + } +} diff --git a/http/vendor/libc/src/unix/linux_like/emscripten/lfs64.rs b/http/vendor/libc/src/unix/linux_like/emscripten/lfs64.rs new file mode 100644 index 0000000..5015409 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/emscripten/lfs64.rs @@ -0,0 +1,214 @@ +use crate::off64_t; +use crate::prelude::*; + +// In-sync with ../linux/musl/lfs64.rs except for fallocate64, prlimit64 and sendfile64 + +#[inline] +pub unsafe extern "C" fn creat64(path: *const c_char, mode: crate::mode_t) -> c_int { + crate::creat(path, mode) +} + +#[inline] +pub unsafe extern "C" fn fgetpos64(stream: *mut crate::FILE, pos: *mut crate::fpos64_t) -> c_int { + crate::fgetpos(stream, pos as *mut _) +} + +#[inline] +pub unsafe extern "C" fn fopen64(pathname: *const c_char, mode: *const c_char) -> *mut crate::FILE { + crate::fopen(pathname, mode) +} + +#[inline] +pub unsafe extern "C" fn freopen64( + pathname: *const c_char, + mode: *const c_char, + stream: *mut crate::FILE, +) -> *mut crate::FILE { + crate::freopen(pathname, mode, stream) +} + +#[inline] +pub unsafe extern "C" fn fseeko64( + stream: *mut crate::FILE, + offset: off64_t, + whence: c_int, +) -> c_int { + crate::fseeko(stream, offset, whence) +} + +#[inline] +pub unsafe extern "C" fn fsetpos64(stream: *mut crate::FILE, pos: *const crate::fpos64_t) -> c_int { + crate::fsetpos(stream, pos as *mut _) +} + +#[inline] +pub unsafe extern "C" fn fstat64(fildes: c_int, buf: *mut crate::stat64) -> c_int { + crate::fstat(fildes, buf as *mut _) +} + +#[inline] +pub unsafe extern "C" fn fstatat64( + fd: c_int, + path: *const c_char, + buf: *mut crate::stat64, + flag: c_int, +) -> c_int { + crate::fstatat(fd, path, buf as *mut _, flag) +} + +#[inline] +pub unsafe extern "C" fn fstatfs64(fd: c_int, buf: *mut crate::statfs64) -> c_int { + crate::fstatfs(fd, buf as *mut _) +} + +#[inline] +pub unsafe extern "C" fn fstatvfs64(fd: c_int, buf: *mut crate::statvfs64) -> c_int { + crate::fstatvfs(fd, buf as *mut _) +} + +#[inline] +pub unsafe extern "C" fn ftello64(stream: *mut crate::FILE) -> off64_t { + crate::ftello(stream) +} + +#[inline] +pub unsafe extern "C" fn ftruncate64(fd: c_int, length: off64_t) -> c_int { + crate::ftruncate(fd, length) +} + +#[inline] +pub unsafe extern "C" fn getrlimit64(resource: c_int, rlim: *mut crate::rlimit64) -> c_int { + crate::getrlimit(resource, rlim as *mut _) +} + +#[inline] +pub unsafe extern "C" fn lseek64(fd: c_int, offset: off64_t, whence: c_int) -> off64_t { + crate::lseek(fd, offset, whence) +} + +#[inline] +pub unsafe extern "C" fn lstat64(path: *const c_char, buf: *mut crate::stat64) -> c_int { + crate::lstat(path, buf as *mut _) +} + +#[inline] +pub unsafe extern "C" fn mmap64( + addr: *mut c_void, + length: size_t, + prot: c_int, + flags: c_int, + fd: c_int, + offset: off64_t, +) -> *mut c_void { + crate::mmap(addr, length, prot, flags, fd, offset) +} + +// These functions are variadic in the C ABI since the `mode` argument is "optional". Variadic +// `extern "C"` functions are unstable in Rust so we cannot write a shim function for these +// entrypoints. See https://github.com/rust-lang/rust/issues/44930. +// +// These aliases are mostly fine though, neither function takes a LFS64-namespaced type as an +// argument, nor do their names clash with any declared types. +pub use crate::{ + open as open64, + openat as openat64, +}; + +#[inline] +pub unsafe extern "C" fn posix_fadvise64( + fd: c_int, + offset: off64_t, + len: off64_t, + advice: c_int, +) -> c_int { + crate::posix_fadvise(fd, offset, len, advice) +} + +#[inline] +pub unsafe extern "C" fn posix_fallocate64(fd: c_int, offset: off64_t, len: off64_t) -> c_int { + crate::posix_fallocate(fd, offset, len) +} + +#[inline] +pub unsafe extern "C" fn pread64( + fd: c_int, + buf: *mut c_void, + count: size_t, + offset: off64_t, +) -> ssize_t { + crate::pread(fd, buf, count, offset) +} + +#[inline] +pub unsafe extern "C" fn preadv64( + fd: c_int, + iov: *const crate::iovec, + iovcnt: c_int, + offset: off64_t, +) -> ssize_t { + crate::preadv(fd, iov, iovcnt, offset) +} + +#[inline] +pub unsafe extern "C" fn pwrite64( + fd: c_int, + buf: *const c_void, + count: size_t, + offset: off64_t, +) -> ssize_t { + crate::pwrite(fd, buf, count, offset) +} + +#[inline] +pub unsafe extern "C" fn pwritev64( + fd: c_int, + iov: *const crate::iovec, + iovcnt: c_int, + offset: off64_t, +) -> ssize_t { + crate::pwritev(fd, iov, iovcnt, offset) +} + +#[inline] +pub unsafe extern "C" fn readdir64(dirp: *mut crate::DIR) -> *mut crate::dirent64 { + crate::readdir(dirp) as *mut _ +} + +#[inline] +pub unsafe extern "C" fn readdir64_r( + dirp: *mut crate::DIR, + entry: *mut crate::dirent64, + result: *mut *mut crate::dirent64, +) -> c_int { + crate::readdir_r(dirp, entry as *mut _, result as *mut _) +} + +#[inline] +pub unsafe extern "C" fn setrlimit64(resource: c_int, rlim: *const crate::rlimit64) -> c_int { + crate::setrlimit(resource, rlim as *mut _) +} + +#[inline] +pub unsafe extern "C" fn stat64(pathname: *const c_char, statbuf: *mut crate::stat64) -> c_int { + crate::stat(pathname, statbuf as *mut _) +} + +#[inline] +pub unsafe extern "C" fn statfs64(pathname: *const c_char, buf: *mut crate::statfs64) -> c_int { + crate::statfs(pathname, buf as *mut _) +} + +#[inline] +pub unsafe extern "C" fn statvfs64(path: *const c_char, buf: *mut crate::statvfs64) -> c_int { + crate::statvfs(path, buf as *mut _) +} + +#[inline] +pub unsafe extern "C" fn tmpfile64() -> *mut crate::FILE { + crate::tmpfile() +} + +#[inline] +pub unsafe extern "C" fn truncate64(path: *const c_char, length: off64_t) -> c_int { + crate::truncate(path, length) +} diff --git a/http/vendor/libc/src/unix/linux_like/emscripten/mod.rs b/http/vendor/libc/src/unix/linux_like/emscripten/mod.rs new file mode 100644 index 0000000..711ed8f --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/emscripten/mod.rs @@ -0,0 +1,1455 @@ +use crate::prelude::*; + +pub type wchar_t = i32; +pub type dev_t = u32; +pub type socklen_t = u32; +pub type pthread_t = c_ulong; +pub type mode_t = u32; +pub type shmatt_t = c_ulong; +pub type mqd_t = c_int; +pub type msgqnum_t = c_ulong; +pub type msglen_t = c_ulong; +pub type nfds_t = c_ulong; +pub type nl_item = c_int; +pub type idtype_t = c_uint; +pub type loff_t = i64; +pub type pthread_key_t = c_uint; + +pub type clock_t = c_long; +pub type time_t = i64; +pub type suseconds_t = c_long; +pub type ino_t = u64; +pub type off_t = i64; +pub type blkcnt_t = i32; + +pub type blksize_t = c_long; +pub type fsblkcnt_t = u32; +pub type fsfilcnt_t = u32; +pub type rlim_t = u64; +pub type nlink_t = u32; + +pub type ino64_t = crate::ino_t; +pub type off64_t = off_t; +pub type blkcnt64_t = crate::blkcnt_t; +pub type rlim64_t = crate::rlim_t; + +pub type rlimit64 = crate::rlimit; +pub type flock64 = crate::flock; +pub type stat64 = crate::stat; +pub type statfs64 = crate::statfs; +pub type statvfs64 = crate::statvfs; +pub type dirent64 = crate::dirent; + +extern_ty! { + pub enum fpos64_t {} // FIXME(emscripten): fill this out with a struct +} + +s! { + pub struct glob_t { + pub gl_pathc: size_t, + pub gl_pathv: *mut *mut c_char, + pub gl_offs: size_t, + pub gl_flags: c_int, + + __unused1: Padding<*mut c_void>, + __unused2: Padding<*mut c_void>, + __unused3: Padding<*mut c_void>, + __unused4: Padding<*mut c_void>, + __unused5: Padding<*mut c_void>, + } + + pub struct passwd { + pub pw_name: *mut c_char, + pub pw_passwd: *mut c_char, + pub pw_uid: crate::uid_t, + pub pw_gid: crate::gid_t, + pub pw_gecos: *mut c_char, + pub pw_dir: *mut c_char, + pub pw_shell: *mut c_char, + } + + pub struct spwd { + pub sp_namp: *mut c_char, + pub sp_pwdp: *mut c_char, + pub sp_lstchg: c_long, + pub sp_min: c_long, + pub sp_max: c_long, + pub sp_warn: c_long, + pub sp_inact: c_long, + pub sp_expire: c_long, + pub sp_flag: c_ulong, + } + + pub struct statvfs { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_favail: crate::fsfilcnt_t, + pub f_fsid: c_ulong, + __f_unused: Padding, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: [c_int; 6], + } + + pub struct signalfd_siginfo { + pub ssi_signo: u32, + pub ssi_errno: i32, + pub ssi_code: i32, + pub ssi_pid: u32, + pub ssi_uid: u32, + pub ssi_fd: i32, + pub ssi_tid: u32, + pub ssi_band: u32, + pub ssi_overrun: u32, + pub ssi_trapno: u32, + pub ssi_status: i32, + pub ssi_int: i32, + pub ssi_ptr: u64, + pub ssi_utime: u64, + pub ssi_stime: u64, + pub ssi_addr: u64, + pub ssi_addr_lsb: u16, + _pad2: Padding, + pub ssi_syscall: i32, + pub ssi_call_addr: u64, + pub ssi_arch: u32, + _pad: Padding<[u8; 28]>, + } + + pub struct fsid_t { + __val: [c_int; 2], + } + + pub struct cpu_set_t { + bits: [u32; 32], + } + + // System V IPC + pub struct msginfo { + pub msgpool: c_int, + pub msgmap: c_int, + pub msgmax: c_int, + pub msgmnb: c_int, + pub msgmni: c_int, + pub msgssz: c_int, + pub msgtql: c_int, + pub msgseg: c_ushort, + } + + pub struct sembuf { + pub sem_num: c_ushort, + pub sem_op: c_short, + pub sem_flg: c_short, + } + + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigaction { + pub sa_sigaction: crate::sighandler_t, + pub sa_mask: crate::sigset_t, + pub sa_flags: c_int, + pub sa_restorer: Option, + } + + pub struct ipc_perm { + pub __ipc_perm_key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: mode_t, + pub __seq: c_int, + __unused1: Padding, + __unused2: Padding, + } + + pub struct termios { + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_line: crate::cc_t, + pub c_cc: [crate::cc_t; crate::NCCS], + pub __c_ispeed: crate::speed_t, + pub __c_ospeed: crate::speed_t, + } + + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off_t, + pub l_len: off_t, + pub l_pid: crate::pid_t, + } + + pub struct pthread_attr_t { + __size: [u32; 11], + } + + pub struct sigset_t { + __val: [c_ulong; 32], + } + + pub struct msghdr { + pub msg_name: *mut c_void, + pub msg_namelen: crate::socklen_t, + pub msg_iov: *mut crate::iovec, + pub msg_iovlen: c_int, + pub msg_control: *mut c_void, + pub msg_controllen: crate::socklen_t, + pub msg_flags: c_int, + } + + pub struct cmsghdr { + pub cmsg_len: crate::socklen_t, + pub cmsg_level: c_int, + pub cmsg_type: c_int, + } + + pub struct sem_t { + __val: [c_int; 4], + } + pub struct stat { + pub st_dev: crate::dev_t, + #[cfg(emscripten_old_stat_abi)] + __st_dev_padding: Padding, + #[cfg(emscripten_old_stat_abi)] + __st_ino_truncated: c_long, + pub st_mode: mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + #[cfg(emscripten_old_stat_abi)] + __st_rdev_padding: Padding, + pub st_size: off_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + pub st_ino: crate::ino_t, + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_flags: c_int, + pub ss_size: size_t, + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, + pub shm_atime: crate::time_t, + pub shm_dtime: crate::time_t, + pub shm_ctime: crate::time_t, + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: c_ulong, + __pad1: Padding, + __pad2: Padding, + } + + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + pub msg_stime: crate::time_t, + pub msg_rtime: crate::time_t, + pub msg_ctime: crate::time_t, + pub __msg_cbytes: c_ulong, + pub msg_qnum: crate::msgqnum_t, + pub msg_qbytes: crate::msglen_t, + pub msg_lspid: crate::pid_t, + pub msg_lrpid: crate::pid_t, + __pad1: Padding, + __pad2: Padding, + } + + pub struct statfs { + pub f_type: c_ulong, + pub f_bsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_fsid: crate::fsid_t, + pub f_namelen: c_ulong, + pub f_frsize: c_ulong, + pub f_flags: c_ulong, + pub f_spare: [c_ulong; 4], + } + + pub struct siginfo_t { + pub si_signo: c_int, + pub si_errno: c_int, + pub si_code: c_int, + pub _pad: [c_int; 29], + _align: [usize; 0], + } + + pub struct arpd_request { + pub req: c_ushort, + pub ip: u32, + pub dev: c_ulong, + pub stamp: c_ulong, + pub updated: c_ulong, + pub ha: [c_uchar; crate::MAX_ADDR_LEN], + } + + #[repr(align(4))] + pub struct pthread_mutex_t { + size: [u8; crate::__SIZEOF_PTHREAD_MUTEX_T], + } + + #[repr(align(4))] + pub struct pthread_rwlock_t { + size: [u8; crate::__SIZEOF_PTHREAD_RWLOCK_T], + } + + #[repr(align(4))] + pub struct pthread_mutexattr_t { + size: [u8; crate::__SIZEOF_PTHREAD_MUTEXATTR_T], + } + + #[repr(align(4))] + pub struct pthread_rwlockattr_t { + size: [u8; crate::__SIZEOF_PTHREAD_RWLOCKATTR_T], + } + + #[repr(align(4))] + pub struct pthread_condattr_t { + size: [u8; crate::__SIZEOF_PTHREAD_CONDATTR_T], + } + + pub struct dirent { + pub d_ino: crate::ino_t, + pub d_off: off_t, + pub d_reclen: c_ushort, + pub d_type: c_uchar, + pub d_name: [c_char; 256], + } + + pub struct sysinfo { + pub uptime: c_ulong, + pub loads: [c_ulong; 3], + pub totalram: c_ulong, + pub freeram: c_ulong, + pub sharedram: c_ulong, + pub bufferram: c_ulong, + pub totalswap: c_ulong, + pub freeswap: c_ulong, + pub procs: c_ushort, + pub pad: c_ushort, + pub totalhigh: c_ulong, + pub freehigh: c_ulong, + pub mem_unit: c_uint, + pub __reserved: [c_char; 256], + } + + pub struct mq_attr { + pub mq_flags: c_long, + pub mq_maxmsg: c_long, + pub mq_msgsize: c_long, + pub mq_curmsgs: c_long, + pad: Padding<[c_long; 4]>, + } + + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + pub struct pthread_cond_t { + size: [u8; crate::__SIZEOF_PTHREAD_COND_T], + } +} + +s_no_extra_traits! { + #[repr(align(8))] + pub struct max_align_t { + priv_: [f64; 3], + } +} + +pub const MADV_SOFT_OFFLINE: c_int = 101; +pub const MS_NOUSER: c_ulong = 0x80000000; +pub const MS_RMT_MASK: c_ulong = 0x02800051; + +pub const ABDAY_1: crate::nl_item = 0x20000; +pub const ABDAY_2: crate::nl_item = 0x20001; +pub const ABDAY_3: crate::nl_item = 0x20002; +pub const ABDAY_4: crate::nl_item = 0x20003; +pub const ABDAY_5: crate::nl_item = 0x20004; +pub const ABDAY_6: crate::nl_item = 0x20005; +pub const ABDAY_7: crate::nl_item = 0x20006; + +pub const DAY_1: crate::nl_item = 0x20007; +pub const DAY_2: crate::nl_item = 0x20008; +pub const DAY_3: crate::nl_item = 0x20009; +pub const DAY_4: crate::nl_item = 0x2000A; +pub const DAY_5: crate::nl_item = 0x2000B; +pub const DAY_6: crate::nl_item = 0x2000C; +pub const DAY_7: crate::nl_item = 0x2000D; + +pub const ABMON_1: crate::nl_item = 0x2000E; +pub const ABMON_2: crate::nl_item = 0x2000F; +pub const ABMON_3: crate::nl_item = 0x20010; +pub const ABMON_4: crate::nl_item = 0x20011; +pub const ABMON_5: crate::nl_item = 0x20012; +pub const ABMON_6: crate::nl_item = 0x20013; +pub const ABMON_7: crate::nl_item = 0x20014; +pub const ABMON_8: crate::nl_item = 0x20015; +pub const ABMON_9: crate::nl_item = 0x20016; +pub const ABMON_10: crate::nl_item = 0x20017; +pub const ABMON_11: crate::nl_item = 0x20018; +pub const ABMON_12: crate::nl_item = 0x20019; + +pub const MON_1: crate::nl_item = 0x2001A; +pub const MON_2: crate::nl_item = 0x2001B; +pub const MON_3: crate::nl_item = 0x2001C; +pub const MON_4: crate::nl_item = 0x2001D; +pub const MON_5: crate::nl_item = 0x2001E; +pub const MON_6: crate::nl_item = 0x2001F; +pub const MON_7: crate::nl_item = 0x20020; +pub const MON_8: crate::nl_item = 0x20021; +pub const MON_9: crate::nl_item = 0x20022; +pub const MON_10: crate::nl_item = 0x20023; +pub const MON_11: crate::nl_item = 0x20024; +pub const MON_12: crate::nl_item = 0x20025; + +pub const AM_STR: crate::nl_item = 0x20026; +pub const PM_STR: crate::nl_item = 0x20027; + +pub const D_T_FMT: crate::nl_item = 0x20028; +pub const D_FMT: crate::nl_item = 0x20029; +pub const T_FMT: crate::nl_item = 0x2002A; +pub const T_FMT_AMPM: crate::nl_item = 0x2002B; + +pub const ERA: crate::nl_item = 0x2002C; +pub const ERA_D_FMT: crate::nl_item = 0x2002E; +pub const ALT_DIGITS: crate::nl_item = 0x2002F; +pub const ERA_D_T_FMT: crate::nl_item = 0x20030; +pub const ERA_T_FMT: crate::nl_item = 0x20031; + +pub const CODESET: crate::nl_item = 14; + +pub const CRNCYSTR: crate::nl_item = 0x4000F; + +pub const RUSAGE_THREAD: c_int = 1; +pub const RUSAGE_CHILDREN: c_int = -1; + +pub const RADIXCHAR: crate::nl_item = 0x10000; +pub const THOUSEP: crate::nl_item = 0x10001; + +pub const YESEXPR: crate::nl_item = 0x50000; +pub const NOEXPR: crate::nl_item = 0x50001; +pub const YESSTR: crate::nl_item = 0x50002; +pub const NOSTR: crate::nl_item = 0x50003; + +pub const FILENAME_MAX: c_uint = 4096; +pub const L_tmpnam: c_uint = 20; +pub const _PC_LINK_MAX: c_int = 0; +pub const _PC_MAX_CANON: c_int = 1; +pub const _PC_MAX_INPUT: c_int = 2; +pub const _PC_NAME_MAX: c_int = 3; +pub const _PC_PATH_MAX: c_int = 4; +pub const _PC_PIPE_BUF: c_int = 5; +pub const _PC_CHOWN_RESTRICTED: c_int = 6; +pub const _PC_NO_TRUNC: c_int = 7; +pub const _PC_VDISABLE: c_int = 8; +pub const _PC_SYNC_IO: c_int = 9; +pub const _PC_ASYNC_IO: c_int = 10; +pub const _PC_PRIO_IO: c_int = 11; +pub const _PC_SOCK_MAXBUF: c_int = 12; +pub const _PC_FILESIZEBITS: c_int = 13; +pub const _PC_REC_INCR_XFER_SIZE: c_int = 14; +pub const _PC_REC_MAX_XFER_SIZE: c_int = 15; +pub const _PC_REC_MIN_XFER_SIZE: c_int = 16; +pub const _PC_REC_XFER_ALIGN: c_int = 17; +pub const _PC_ALLOC_SIZE_MIN: c_int = 18; +pub const _PC_SYMLINK_MAX: c_int = 19; +pub const _PC_2_SYMLINKS: c_int = 20; + +pub const _SC_ARG_MAX: c_int = 0; +pub const _SC_CHILD_MAX: c_int = 1; +pub const _SC_CLK_TCK: c_int = 2; +pub const _SC_NGROUPS_MAX: c_int = 3; +pub const _SC_OPEN_MAX: c_int = 4; +pub const _SC_STREAM_MAX: c_int = 5; +pub const _SC_TZNAME_MAX: c_int = 6; +pub const _SC_JOB_CONTROL: c_int = 7; +pub const _SC_SAVED_IDS: c_int = 8; +pub const _SC_REALTIME_SIGNALS: c_int = 9; +pub const _SC_PRIORITY_SCHEDULING: c_int = 10; +pub const _SC_TIMERS: c_int = 11; +pub const _SC_ASYNCHRONOUS_IO: c_int = 12; +pub const _SC_PRIORITIZED_IO: c_int = 13; +pub const _SC_SYNCHRONIZED_IO: c_int = 14; +pub const _SC_FSYNC: c_int = 15; +pub const _SC_MAPPED_FILES: c_int = 16; +pub const _SC_MEMLOCK: c_int = 17; +pub const _SC_MEMLOCK_RANGE: c_int = 18; +pub const _SC_MEMORY_PROTECTION: c_int = 19; +pub const _SC_MESSAGE_PASSING: c_int = 20; +pub const _SC_SEMAPHORES: c_int = 21; +pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 22; +pub const _SC_AIO_LISTIO_MAX: c_int = 23; +pub const _SC_AIO_MAX: c_int = 24; +pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 25; +pub const _SC_DELAYTIMER_MAX: c_int = 26; +pub const _SC_MQ_OPEN_MAX: c_int = 27; +pub const _SC_MQ_PRIO_MAX: c_int = 28; +pub const _SC_VERSION: c_int = 29; +pub const _SC_PAGESIZE: c_int = 30; +pub const _SC_PAGE_SIZE: c_int = _SC_PAGESIZE; +pub const _SC_RTSIG_MAX: c_int = 31; +pub const _SC_SEM_NSEMS_MAX: c_int = 32; +pub const _SC_SEM_VALUE_MAX: c_int = 33; +pub const _SC_SIGQUEUE_MAX: c_int = 34; +pub const _SC_TIMER_MAX: c_int = 35; +pub const _SC_BC_BASE_MAX: c_int = 36; +pub const _SC_BC_DIM_MAX: c_int = 37; +pub const _SC_BC_SCALE_MAX: c_int = 38; +pub const _SC_BC_STRING_MAX: c_int = 39; +pub const _SC_COLL_WEIGHTS_MAX: c_int = 40; +pub const _SC_EXPR_NEST_MAX: c_int = 42; +pub const _SC_LINE_MAX: c_int = 43; +pub const _SC_RE_DUP_MAX: c_int = 44; +pub const _SC_2_VERSION: c_int = 46; +pub const _SC_2_C_BIND: c_int = 47; +pub const _SC_2_C_DEV: c_int = 48; +pub const _SC_2_FORT_DEV: c_int = 49; +pub const _SC_2_FORT_RUN: c_int = 50; +pub const _SC_2_SW_DEV: c_int = 51; +pub const _SC_2_LOCALEDEF: c_int = 52; +pub const _SC_UIO_MAXIOV: c_int = 60; +pub const _SC_IOV_MAX: c_int = 60; +pub const _SC_THREADS: c_int = 67; +pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 68; +pub const _SC_GETGR_R_SIZE_MAX: c_int = 69; +pub const _SC_GETPW_R_SIZE_MAX: c_int = 70; +pub const _SC_LOGIN_NAME_MAX: c_int = 71; +pub const _SC_TTY_NAME_MAX: c_int = 72; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 73; +pub const _SC_THREAD_KEYS_MAX: c_int = 74; +pub const _SC_THREAD_STACK_MIN: c_int = 75; +pub const _SC_THREAD_THREADS_MAX: c_int = 76; +pub const _SC_THREAD_ATTR_STACKADDR: c_int = 77; +pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 78; +pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 79; +pub const _SC_THREAD_PRIO_INHERIT: c_int = 80; +pub const _SC_THREAD_PRIO_PROTECT: c_int = 81; +pub const _SC_THREAD_PROCESS_SHARED: c_int = 82; +pub const _SC_NPROCESSORS_CONF: c_int = 83; +pub const _SC_NPROCESSORS_ONLN: c_int = 84; +pub const _SC_PHYS_PAGES: c_int = 85; +pub const _SC_AVPHYS_PAGES: c_int = 86; +pub const _SC_ATEXIT_MAX: c_int = 87; +pub const _SC_PASS_MAX: c_int = 88; +pub const _SC_XOPEN_VERSION: c_int = 89; +pub const _SC_XOPEN_XCU_VERSION: c_int = 90; +pub const _SC_XOPEN_UNIX: c_int = 91; +pub const _SC_XOPEN_CRYPT: c_int = 92; +pub const _SC_XOPEN_ENH_I18N: c_int = 93; +pub const _SC_XOPEN_SHM: c_int = 94; +pub const _SC_2_CHAR_TERM: c_int = 95; +pub const _SC_2_UPE: c_int = 97; +pub const _SC_XOPEN_XPG2: c_int = 98; +pub const _SC_XOPEN_XPG3: c_int = 99; +pub const _SC_XOPEN_XPG4: c_int = 100; +pub const _SC_NZERO: c_int = 109; +pub const _SC_XBS5_ILP32_OFF32: c_int = 125; +pub const _SC_XBS5_ILP32_OFFBIG: c_int = 126; +pub const _SC_XBS5_LP64_OFF64: c_int = 127; +pub const _SC_XBS5_LPBIG_OFFBIG: c_int = 128; +pub const _SC_XOPEN_LEGACY: c_int = 129; +pub const _SC_XOPEN_REALTIME: c_int = 130; +pub const _SC_XOPEN_REALTIME_THREADS: c_int = 131; +pub const _SC_ADVISORY_INFO: c_int = 132; +pub const _SC_BARRIERS: c_int = 133; +pub const _SC_CLOCK_SELECTION: c_int = 137; +pub const _SC_CPUTIME: c_int = 138; +pub const _SC_THREAD_CPUTIME: c_int = 139; +pub const _SC_MONOTONIC_CLOCK: c_int = 149; +pub const _SC_READER_WRITER_LOCKS: c_int = 153; +pub const _SC_SPIN_LOCKS: c_int = 154; +pub const _SC_REGEXP: c_int = 155; +pub const _SC_SHELL: c_int = 157; +pub const _SC_SPAWN: c_int = 159; +pub const _SC_SPORADIC_SERVER: c_int = 160; +pub const _SC_THREAD_SPORADIC_SERVER: c_int = 161; +pub const _SC_TIMEOUTS: c_int = 164; +pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 165; +pub const _SC_2_PBS: c_int = 168; +pub const _SC_2_PBS_ACCOUNTING: c_int = 169; +pub const _SC_2_PBS_LOCATE: c_int = 170; +pub const _SC_2_PBS_MESSAGE: c_int = 171; +pub const _SC_2_PBS_TRACK: c_int = 172; +pub const _SC_SYMLOOP_MAX: c_int = 173; +pub const _SC_STREAMS: c_int = 174; +pub const _SC_2_PBS_CHECKPOINT: c_int = 175; +pub const _SC_V6_ILP32_OFF32: c_int = 176; +pub const _SC_V6_ILP32_OFFBIG: c_int = 177; +pub const _SC_V6_LP64_OFF64: c_int = 178; +pub const _SC_V6_LPBIG_OFFBIG: c_int = 179; +pub const _SC_HOST_NAME_MAX: c_int = 180; +pub const _SC_TRACE: c_int = 181; +pub const _SC_TRACE_EVENT_FILTER: c_int = 182; +pub const _SC_TRACE_INHERIT: c_int = 183; +pub const _SC_TRACE_LOG: c_int = 184; +pub const _SC_IPV6: c_int = 235; +pub const _SC_RAW_SOCKETS: c_int = 236; +pub const _SC_V7_ILP32_OFF32: c_int = 237; +pub const _SC_V7_ILP32_OFFBIG: c_int = 238; +pub const _SC_V7_LP64_OFF64: c_int = 239; +pub const _SC_V7_LPBIG_OFFBIG: c_int = 240; +pub const _SC_SS_REPL_MAX: c_int = 241; +pub const _SC_TRACE_EVENT_NAME_MAX: c_int = 242; +pub const _SC_TRACE_NAME_MAX: c_int = 243; +pub const _SC_TRACE_SYS_MAX: c_int = 244; +pub const _SC_TRACE_USER_EVENT_MAX: c_int = 245; +pub const _SC_XOPEN_STREAMS: c_int = 246; +pub const _SC_THREAD_ROBUST_PRIO_INHERIT: c_int = 247; +pub const _SC_THREAD_ROBUST_PRIO_PROTECT: c_int = 248; + +pub const RLIM_SAVED_MAX: crate::rlim_t = RLIM_INFINITY; +pub const RLIM_SAVED_CUR: crate::rlim_t = RLIM_INFINITY; + +pub const GLOB_ERR: c_int = 1 << 0; +pub const GLOB_MARK: c_int = 1 << 1; +pub const GLOB_NOSORT: c_int = 1 << 2; +pub const GLOB_DOOFFS: c_int = 1 << 3; +pub const GLOB_NOCHECK: c_int = 1 << 4; +pub const GLOB_APPEND: c_int = 1 << 5; +pub const GLOB_NOESCAPE: c_int = 1 << 6; + +pub const GLOB_NOSPACE: c_int = 1; +pub const GLOB_ABORTED: c_int = 2; +pub const GLOB_NOMATCH: c_int = 3; + +pub const POSIX_MADV_NORMAL: c_int = 0; +pub const POSIX_MADV_RANDOM: c_int = 1; +pub const POSIX_MADV_SEQUENTIAL: c_int = 2; +pub const POSIX_MADV_WILLNEED: c_int = 3; + +pub const AT_EACCESS: c_int = 0x200; + +pub const S_IEXEC: mode_t = 0o0100; +pub const S_IWRITE: mode_t = 0o0200; +pub const S_IREAD: mode_t = 0o0400; + +pub const F_LOCK: c_int = 1; +pub const F_TEST: c_int = 3; +pub const F_TLOCK: c_int = 2; +pub const F_ULOCK: c_int = 0; + +pub const ST_RDONLY: c_ulong = 1; +pub const ST_NOSUID: c_ulong = 2; +pub const ST_NODEV: c_ulong = 4; +pub const ST_NOEXEC: c_ulong = 8; +pub const ST_SYNCHRONOUS: c_ulong = 16; +pub const ST_MANDLOCK: c_ulong = 64; +pub const ST_WRITE: c_ulong = 128; +pub const ST_APPEND: c_ulong = 256; +pub const ST_IMMUTABLE: c_ulong = 512; +pub const ST_NOATIME: c_ulong = 1024; +pub const ST_NODIRATIME: c_ulong = 2048; + +pub const RTLD_NEXT: *mut c_void = -1i64 as *mut c_void; +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); +pub const RTLD_NODELETE: c_int = 0x1000; +pub const RTLD_NOW: c_int = 0x2; + +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + size: [0; __SIZEOF_PTHREAD_MUTEX_T], +}; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + size: [0; __SIZEOF_PTHREAD_COND_T], +}; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + size: [0; __SIZEOF_PTHREAD_RWLOCK_T], +}; + +pub const PTHREAD_MUTEX_NORMAL: c_int = 0; +pub const PTHREAD_MUTEX_RECURSIVE: c_int = 1; +pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 2; +pub const PTHREAD_MUTEX_DEFAULT: c_int = PTHREAD_MUTEX_NORMAL; +pub const PTHREAD_PROCESS_PRIVATE: c_int = 0; +pub const PTHREAD_PROCESS_SHARED: c_int = 1; +pub const __SIZEOF_PTHREAD_COND_T: usize = 48; + +pub const SCHED_OTHER: c_int = 0; +pub const SCHED_FIFO: c_int = 1; +pub const SCHED_RR: c_int = 2; +pub const SCHED_BATCH: c_int = 3; +pub const SCHED_IDLE: c_int = 5; + +pub const AF_IB: c_int = 27; +pub const AF_MPLS: c_int = 28; +pub const AF_NFC: c_int = 39; +pub const AF_VSOCK: c_int = 40; +pub const PF_IB: c_int = AF_IB; +pub const PF_MPLS: c_int = AF_MPLS; +pub const PF_NFC: c_int = AF_NFC; +pub const PF_VSOCK: c_int = AF_VSOCK; + +// System V IPC +pub const IPC_PRIVATE: crate::key_t = 0; + +pub const IPC_CREAT: c_int = 0o1000; +pub const IPC_EXCL: c_int = 0o2000; +pub const IPC_NOWAIT: c_int = 0o4000; + +pub const IPC_RMID: c_int = 0; +pub const IPC_SET: c_int = 1; +pub const IPC_STAT: c_int = 2; +pub const IPC_INFO: c_int = 3; +pub const MSG_STAT: c_int = 11; +pub const MSG_INFO: c_int = 12; + +pub const MSG_NOERROR: c_int = 0o10000; +pub const MSG_EXCEPT: c_int = 0o20000; + +pub const SHM_R: c_int = 0o400; +pub const SHM_W: c_int = 0o200; + +pub const SHM_RDONLY: c_int = 0o10000; +pub const SHM_RND: c_int = 0o20000; +pub const SHM_REMAP: c_int = 0o40000; +pub const SHM_EXEC: c_int = 0o100000; + +pub const SHM_LOCK: c_int = 11; +pub const SHM_UNLOCK: c_int = 12; + +pub const SHM_HUGETLB: c_int = 0o4000; +pub const SHM_NORESERVE: c_int = 0o10000; + +pub const LOG_NFACILITIES: c_int = 24; + +pub const SEM_FAILED: *mut crate::sem_t = ptr::null_mut(); + +pub const AI_PASSIVE: c_int = 0x0001; +pub const AI_CANONNAME: c_int = 0x0002; +pub const AI_NUMERICHOST: c_int = 0x0004; +pub const AI_V4MAPPED: c_int = 0x0008; +pub const AI_ALL: c_int = 0x0010; +pub const AI_ADDRCONFIG: c_int = 0x0020; + +pub const AI_NUMERICSERV: c_int = 0x0400; + +pub const EAI_BADFLAGS: c_int = -1; +pub const EAI_NONAME: c_int = -2; +pub const EAI_AGAIN: c_int = -3; +pub const EAI_FAIL: c_int = -4; +pub const EAI_FAMILY: c_int = -6; +pub const EAI_SOCKTYPE: c_int = -7; +pub const EAI_SERVICE: c_int = -8; +pub const EAI_MEMORY: c_int = -10; +pub const EAI_OVERFLOW: c_int = -12; + +pub const NI_NUMERICHOST: c_int = 1; +pub const NI_NUMERICSERV: c_int = 2; +pub const NI_NOFQDN: c_int = 4; +pub const NI_NAMEREQD: c_int = 8; +pub const NI_DGRAM: c_int = 16; + +pub const SYNC_FILE_RANGE_WAIT_BEFORE: c_uint = 1; +pub const SYNC_FILE_RANGE_WRITE: c_uint = 2; +pub const SYNC_FILE_RANGE_WAIT_AFTER: c_uint = 4; + +pub const EAI_SYSTEM: c_int = -11; + +pub const MREMAP_MAYMOVE: c_int = 1; +pub const MREMAP_FIXED: c_int = 2; + +pub const ITIMER_REAL: c_int = 0; +pub const ITIMER_VIRTUAL: c_int = 1; +pub const ITIMER_PROF: c_int = 2; + +pub const _POSIX_VDISABLE: crate::cc_t = 0; + +pub const FALLOC_FL_KEEP_SIZE: c_int = 0x01; +pub const FALLOC_FL_PUNCH_HOLE: c_int = 0x02; + +pub const NCCS: usize = 32; + +pub const O_TRUNC: c_int = 512; +pub const O_NOATIME: c_int = 0o1000000; +pub const O_CLOEXEC: c_int = 0x80000; + +// Defined as wasi value. +pub const EPERM: c_int = 63; +pub const ENOENT: c_int = 44; +pub const ESRCH: c_int = 71; +pub const EINTR: c_int = 27; +pub const EIO: c_int = 29; +pub const ENXIO: c_int = 60; +pub const E2BIG: c_int = 1; +pub const ENOEXEC: c_int = 45; +pub const EBADF: c_int = 8; +pub const ECHILD: c_int = 12; +pub const EAGAIN: c_int = 6; +pub const ENOMEM: c_int = 48; +pub const EACCES: c_int = 2; +pub const EFAULT: c_int = 21; +pub const ENOTBLK: c_int = 105; +pub const EBUSY: c_int = 10; +pub const EEXIST: c_int = 20; +pub const EXDEV: c_int = 75; +pub const ENODEV: c_int = 43; +pub const ENOTDIR: c_int = 54; +pub const EISDIR: c_int = 31; +pub const EINVAL: c_int = 28; +pub const ENFILE: c_int = 41; +pub const EMFILE: c_int = 33; +pub const ENOTTY: c_int = 59; +pub const ETXTBSY: c_int = 74; +pub const EFBIG: c_int = 22; +pub const ENOSPC: c_int = 51; +pub const ESPIPE: c_int = 70; +pub const EROFS: c_int = 69; +pub const EMLINK: c_int = 34; +pub const EPIPE: c_int = 64; +pub const EDOM: c_int = 18; +pub const ERANGE: c_int = 68; +pub const EWOULDBLOCK: c_int = EAGAIN; +pub const ENOLINK: c_int = 47; +pub const EPROTO: c_int = 65; +pub const EDEADLK: c_int = 16; +pub const EDEADLOCK: c_int = EDEADLK; +pub const ENAMETOOLONG: c_int = 37; +pub const ENOLCK: c_int = 46; +pub const ENOSYS: c_int = 52; +pub const ENOTEMPTY: c_int = 55; +pub const ELOOP: c_int = 32; +pub const ENOMSG: c_int = 49; +pub const EIDRM: c_int = 24; +pub const EMULTIHOP: c_int = 36; +pub const EBADMSG: c_int = 9; +pub const EOVERFLOW: c_int = 61; +pub const EILSEQ: c_int = 25; +pub const ENOTSOCK: c_int = 57; +pub const EDESTADDRREQ: c_int = 17; +pub const EMSGSIZE: c_int = 35; +pub const EPROTOTYPE: c_int = 67; +pub const ENOPROTOOPT: c_int = 50; +pub const EPROTONOSUPPORT: c_int = 66; +pub const EAFNOSUPPORT: c_int = 5; +pub const EADDRINUSE: c_int = 3; +pub const EADDRNOTAVAIL: c_int = 4; +pub const ENETDOWN: c_int = 38; +pub const ENETUNREACH: c_int = 40; +pub const ENETRESET: c_int = 39; +pub const ECONNABORTED: c_int = 13; +pub const ECONNRESET: c_int = 15; +pub const ENOBUFS: c_int = 42; +pub const EISCONN: c_int = 30; +pub const ENOTCONN: c_int = 53; +pub const ETIMEDOUT: c_int = 73; +pub const ECONNREFUSED: c_int = 14; +pub const EHOSTUNREACH: c_int = 23; +pub const EALREADY: c_int = 7; +pub const EINPROGRESS: c_int = 26; +pub const ESTALE: c_int = 72; +pub const EDQUOT: c_int = 19; +pub const ECANCELED: c_int = 11; +pub const EOWNERDEAD: c_int = 62; +pub const ENOTRECOVERABLE: c_int = 56; + +pub const ENOSTR: c_int = 100; +pub const EBFONT: c_int = 101; +pub const EBADSLT: c_int = 102; +pub const EBADRQC: c_int = 103; +pub const ENOANO: c_int = 104; +pub const ECHRNG: c_int = 106; +pub const EL3HLT: c_int = 107; +pub const EL3RST: c_int = 108; +pub const ELNRNG: c_int = 109; +pub const EUNATCH: c_int = 110; +pub const ENOCSI: c_int = 111; +pub const EL2HLT: c_int = 112; +pub const EBADE: c_int = 113; +pub const EBADR: c_int = 114; +pub const EXFULL: c_int = 115; +pub const ENODATA: c_int = 116; +pub const ETIME: c_int = 117; +pub const ENOSR: c_int = 118; +pub const ENONET: c_int = 119; +pub const ENOPKG: c_int = 120; +pub const EREMOTE: c_int = 121; +pub const EADV: c_int = 122; +pub const ESRMNT: c_int = 123; +pub const ECOMM: c_int = 124; +pub const EDOTDOT: c_int = 125; +pub const ENOTUNIQ: c_int = 126; +pub const EBADFD: c_int = 127; +pub const EREMCHG: c_int = 128; +pub const ELIBACC: c_int = 129; +pub const ELIBBAD: c_int = 130; +pub const ELIBSCN: c_int = 131; +pub const ELIBMAX: c_int = 132; +pub const ELIBEXEC: c_int = 133; +pub const ERESTART: c_int = 134; +pub const ESTRPIPE: c_int = 135; +pub const EUSERS: c_int = 136; +pub const ESOCKTNOSUPPORT: c_int = 137; +pub const EOPNOTSUPP: c_int = 138; +pub const ENOTSUP: c_int = EOPNOTSUPP; +pub const EPFNOSUPPORT: c_int = 139; +pub const ESHUTDOWN: c_int = 140; +pub const ETOOMANYREFS: c_int = 141; +pub const EHOSTDOWN: c_int = 142; +pub const EUCLEAN: c_int = 143; +pub const ENOTNAM: c_int = 144; +pub const ENAVAIL: c_int = 145; +pub const EISNAM: c_int = 146; +pub const EREMOTEIO: c_int = 147; +pub const ENOMEDIUM: c_int = 148; +pub const EMEDIUMTYPE: c_int = 149; +pub const ENOKEY: c_int = 150; +pub const EKEYEXPIRED: c_int = 151; +pub const EKEYREVOKED: c_int = 152; +pub const EKEYREJECTED: c_int = 153; +pub const ERFKILL: c_int = 154; +pub const EHWPOISON: c_int = 155; +pub const EL2NSYNC: c_int = 156; + +pub const SA_NODEFER: c_int = 0x40000000; +pub const SA_RESETHAND: c_int = 0x80000000; +pub const SA_RESTART: c_int = 0x10000000; +pub const SA_NOCLDSTOP: c_int = 0x00000001; + +pub const BUFSIZ: c_uint = 1024; +pub const TMP_MAX: c_uint = 10000; +pub const FOPEN_MAX: c_uint = 1000; +pub const O_PATH: c_int = 0o10000000; +pub const O_EXEC: c_int = 0o10000000; +pub const O_SEARCH: c_int = 0o10000000; +pub const O_ACCMODE: c_int = 0o10000003; +pub const O_NDELAY: c_int = O_NONBLOCK; +pub const NI_MAXHOST: crate::socklen_t = 255; +pub const PTHREAD_STACK_MIN: size_t = 2048; +pub const POSIX_FADV_DONTNEED: c_int = 4; +pub const POSIX_FADV_NOREUSE: c_int = 5; + +pub const POSIX_MADV_DONTNEED: c_int = 4; + +pub const RLIM_INFINITY: crate::rlim_t = !0; +#[deprecated(since = "0.2.64", note = "Not stable across OS versions")] +pub const RLIMIT_NLIMITS: c_int = 16; +#[allow(deprecated)] +#[deprecated(since = "0.2.64", note = "Not stable across OS versions")] +pub const RLIM_NLIMITS: c_int = RLIMIT_NLIMITS; + +pub const MAP_ANONYMOUS: c_int = MAP_ANON; + +#[doc(hidden)] +#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] +pub const SIGUNUSED: c_int = crate::SIGSYS; + +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; + +pub const CPU_SETSIZE: c_int = 1024; + +pub const TCSANOW: c_int = 0; +pub const TCSADRAIN: c_int = 1; +pub const TCSAFLUSH: c_int = 2; + +pub const TIOCINQ: c_int = crate::FIONREAD; + +pub const RTLD_GLOBAL: c_int = 0x100; +pub const RTLD_NOLOAD: c_int = 0x4; + +pub const CLOCK_SGI_CYCLE: crate::clockid_t = 10; + +pub const MCL_CURRENT: c_int = 0x0001; +pub const MCL_FUTURE: c_int = 0x0002; + +pub const SIGSTKSZ: size_t = 8192; +pub const MINSIGSTKSZ: size_t = 2048; +pub const CBAUD: crate::tcflag_t = 0o0010017; +pub const TAB1: c_int = 0x00000800; +pub const TAB2: c_int = 0x00001000; +pub const TAB3: c_int = 0x00001800; +pub const CR1: c_int = 0x00000200; +pub const CR2: c_int = 0x00000400; +pub const CR3: c_int = 0x00000600; +pub const FF1: c_int = 0x00008000; +pub const BS1: c_int = 0x00002000; +pub const VT1: c_int = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: crate::tcflag_t = 0x00000400; +pub const IXOFF: crate::tcflag_t = 0x00001000; +pub const ONLCR: crate::tcflag_t = 0x4; +pub const CSIZE: crate::tcflag_t = 0x00000030; +pub const CS6: crate::tcflag_t = 0x00000010; +pub const CS7: crate::tcflag_t = 0x00000020; +pub const CS8: crate::tcflag_t = 0x00000030; +pub const CSTOPB: crate::tcflag_t = 0x00000040; +pub const CREAD: crate::tcflag_t = 0x00000080; +pub const PARENB: crate::tcflag_t = 0x00000100; +pub const PARODD: crate::tcflag_t = 0x00000200; +pub const HUPCL: crate::tcflag_t = 0x00000400; +pub const CLOCAL: crate::tcflag_t = 0x00000800; +pub const ECHOKE: crate::tcflag_t = 0x00000800; +pub const ECHOE: crate::tcflag_t = 0x00000010; +pub const ECHOK: crate::tcflag_t = 0x00000020; +pub const ECHONL: crate::tcflag_t = 0x00000040; +pub const ECHOPRT: crate::tcflag_t = 0x00000400; +pub const ECHOCTL: crate::tcflag_t = 0x00000200; +pub const ISIG: crate::tcflag_t = 0x00000001; +pub const ICANON: crate::tcflag_t = 0x00000002; +pub const PENDIN: crate::tcflag_t = 0x00004000; +pub const NOFLSH: crate::tcflag_t = 0x00000080; +pub const CBAUDEX: crate::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: crate::tcflag_t = 0o000002; +pub const NLDLY: crate::tcflag_t = 0o000400; +pub const CRDLY: crate::tcflag_t = 0o003000; +pub const TABDLY: crate::tcflag_t = 0o014000; +pub const BSDLY: crate::tcflag_t = 0o020000; +pub const FFDLY: crate::tcflag_t = 0o100000; +pub const VTDLY: crate::tcflag_t = 0o040000; +pub const XTABS: crate::tcflag_t = 0o014000; + +pub const B0: crate::speed_t = 0o000000; +pub const B50: crate::speed_t = 0o000001; +pub const B75: crate::speed_t = 0o000002; +pub const B110: crate::speed_t = 0o000003; +pub const B134: crate::speed_t = 0o000004; +pub const B150: crate::speed_t = 0o000005; +pub const B200: crate::speed_t = 0o000006; +pub const B300: crate::speed_t = 0o000007; +pub const B600: crate::speed_t = 0o000010; +pub const B1200: crate::speed_t = 0o000011; +pub const B1800: crate::speed_t = 0o000012; +pub const B2400: crate::speed_t = 0o000013; +pub const B4800: crate::speed_t = 0o000014; +pub const B9600: crate::speed_t = 0o000015; +pub const B19200: crate::speed_t = 0o000016; +pub const B38400: crate::speed_t = 0o000017; +pub const B57600: crate::speed_t = 0o010001; +pub const B115200: crate::speed_t = 0o010002; +pub const B230400: crate::speed_t = 0o010003; +pub const B460800: crate::speed_t = 0o010004; +pub const B500000: crate::speed_t = 0o010005; +pub const B576000: crate::speed_t = 0o010006; +pub const B921600: crate::speed_t = 0o010007; +pub const B1000000: crate::speed_t = 0o010010; +pub const B1152000: crate::speed_t = 0o010011; +pub const B1500000: crate::speed_t = 0o010012; +pub const B2000000: crate::speed_t = 0o010013; +pub const B2500000: crate::speed_t = 0o010014; +pub const B3000000: crate::speed_t = 0o010015; +pub const B3500000: crate::speed_t = 0o010016; +pub const B4000000: crate::speed_t = 0o010017; + +pub const SO_BINDTODEVICE: c_int = 25; +pub const SO_TIMESTAMP: c_int = 63; +pub const SO_MARK: c_int = 36; +pub const SO_RXQ_OVFL: c_int = 40; +pub const SO_PEEK_OFF: c_int = 42; +pub const SO_BUSY_POLL: c_int = 46; + +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; + +pub const O_DIRECT: c_int = 0x4000; +pub const O_DIRECTORY: c_int = 0x10000; +pub const O_NOFOLLOW: c_int = 0x20000; +pub const O_ASYNC: c_int = 0x2000; + +pub const FIOCLEX: c_int = 0x5451; +pub const FIONBIO: c_int = 0x5421; + +pub const RLIMIT_RSS: c_int = 5; +pub const RLIMIT_NOFILE: c_int = 7; +pub const RLIMIT_AS: c_int = 9; +pub const RLIMIT_NPROC: c_int = 6; +pub const RLIMIT_MEMLOCK: c_int = 8; +pub const RLIMIT_CPU: c_int = 0; +pub const RLIMIT_FSIZE: c_int = 1; +pub const RLIMIT_DATA: c_int = 2; +pub const RLIMIT_STACK: c_int = 3; +pub const RLIMIT_CORE: c_int = 4; +pub const RLIMIT_LOCKS: c_int = 10; +pub const RLIMIT_SIGPENDING: c_int = 11; +pub const RLIMIT_MSGQUEUE: c_int = 12; +pub const RLIMIT_NICE: c_int = 13; +pub const RLIMIT_RTPRIO: c_int = 14; + +pub const O_APPEND: c_int = 1024; +pub const O_CREAT: c_int = 64; +pub const O_EXCL: c_int = 128; +pub const O_NOCTTY: c_int = 256; +pub const O_NONBLOCK: c_int = 2048; +pub const O_SYNC: c_int = 1052672; +pub const O_RSYNC: c_int = 1052672; +pub const O_DSYNC: c_int = 4096; + +pub const SOCK_NONBLOCK: c_int = 2048; + +pub const MAP_ANON: c_int = 0x0020; +pub const MAP_GROWSDOWN: c_int = 0x0100; +pub const MAP_DENYWRITE: c_int = 0x0800; +pub const MAP_EXECUTABLE: c_int = 0x01000; +pub const MAP_LOCKED: c_int = 0x02000; +pub const MAP_NORESERVE: c_int = 0x04000; +pub const MAP_POPULATE: c_int = 0x08000; +pub const MAP_NONBLOCK: c_int = 0x010000; +pub const MAP_STACK: c_int = 0x020000; + +pub const SOCK_STREAM: c_int = 1; +pub const SOCK_DGRAM: c_int = 2; +pub const SOCK_SEQPACKET: c_int = 5; + +pub const IPPROTO_MAX: c_int = 263; + +pub const SOL_SOCKET: c_int = 1; + +pub const SO_REUSEADDR: c_int = 2; +pub const SO_TYPE: c_int = 3; +pub const SO_ERROR: c_int = 4; +pub const SO_DONTROUTE: c_int = 5; +pub const SO_BROADCAST: c_int = 6; +pub const SO_SNDBUF: c_int = 7; +pub const SO_RCVBUF: c_int = 8; +pub const SO_KEEPALIVE: c_int = 9; +pub const SO_OOBINLINE: c_int = 10; +pub const SO_LINGER: c_int = 13; +pub const SO_REUSEPORT: c_int = 15; +pub const SO_RCVLOWAT: c_int = 18; +pub const SO_SNDLOWAT: c_int = 19; +pub const SO_RCVTIMEO: c_int = 66; +pub const SO_SNDTIMEO: c_int = 67; +pub const SO_ACCEPTCONN: c_int = 30; + +pub const IPV6_RTHDR_LOOSE: c_int = 0; +pub const IPV6_RTHDR_STRICT: c_int = 1; + +pub const SA_ONSTACK: c_int = 0x08000000; +pub const SA_SIGINFO: c_int = 0x00000004; +pub const SA_NOCLDWAIT: c_int = 0x00000002; + +pub const SIGCHLD: c_int = 17; +pub const SIGBUS: c_int = 7; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGUSR1: c_int = 10; +pub const SIGUSR2: c_int = 12; +pub const SIGCONT: c_int = 18; +pub const SIGSTOP: c_int = 19; +pub const SIGTSTP: c_int = 20; +pub const SIGURG: c_int = 23; +pub const SIGIO: c_int = 29; +pub const SIGSYS: c_int = 31; +pub const SIGSTKFLT: c_int = 16; +pub const SIGPOLL: c_int = 29; +pub const SIGPWR: c_int = 30; +pub const SIG_SETMASK: c_int = 2; +pub const SIG_BLOCK: c_int = 0x000000; +pub const SIG_UNBLOCK: c_int = 0x01; + +pub const EXTPROC: crate::tcflag_t = 0x00010000; + +pub const MAP_HUGETLB: c_int = 0x040000; + +pub const F_GETLK: c_int = 12; +pub const F_GETOWN: c_int = 9; +pub const F_SETLK: c_int = 13; +pub const F_SETLKW: c_int = 14; +pub const F_SETOWN: c_int = 8; +pub const F_OFD_GETLK: c_int = 36; +pub const F_OFD_SETLK: c_int = 37; +pub const F_OFD_SETLKW: c_int = 38; + +pub const VEOF: usize = 4; +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: crate::tcflag_t = 0x00008000; +pub const TOSTOP: crate::tcflag_t = 0x00000100; +pub const FLUSHO: crate::tcflag_t = 0x00001000; + +pub const TCGETS: c_int = 0x5401; +pub const TCSETS: c_int = 0x5402; +pub const TCSETSW: c_int = 0x5403; +pub const TCSETSF: c_int = 0x5404; +pub const TCGETA: c_int = 0x5405; +pub const TCSETA: c_int = 0x5406; +pub const TCSETAW: c_int = 0x5407; +pub const TCSETAF: c_int = 0x5408; +pub const TCSBRK: c_int = 0x5409; +pub const TCXONC: c_int = 0x540A; +pub const TCFLSH: c_int = 0x540B; +pub const TIOCGSOFTCAR: c_int = 0x5419; +pub const TIOCSSOFTCAR: c_int = 0x541A; +pub const TIOCLINUX: c_int = 0x541C; +pub const TIOCGSERIAL: c_int = 0x541E; +pub const TIOCEXCL: c_int = 0x540C; +pub const TIOCNXCL: c_int = 0x540D; +pub const TIOCSCTTY: c_int = 0x540E; +pub const TIOCGPGRP: c_int = 0x540F; +pub const TIOCSPGRP: c_int = 0x5410; +pub const TIOCOUTQ: c_int = 0x5411; +pub const TIOCSTI: c_int = 0x5412; +pub const TIOCGWINSZ: c_int = 0x5413; +pub const TIOCSWINSZ: c_int = 0x5414; +pub const TIOCMGET: c_int = 0x5415; +pub const TIOCMBIS: c_int = 0x5416; +pub const TIOCMBIC: c_int = 0x5417; +pub const TIOCMSET: c_int = 0x5418; +pub const FIONREAD: c_int = 0x541B; +pub const TIOCCONS: c_int = 0x541D; + +pub const SYS_gettid: c_long = 224; // Valid for arm (32-bit) and x86 (32-bit) + +pub const POLLWRNORM: c_short = 0x100; +pub const POLLWRBAND: c_short = 0x200; + +pub const TIOCM_LE: c_int = 0x001; +pub const TIOCM_DTR: c_int = 0x002; +pub const TIOCM_RTS: c_int = 0x004; +pub const TIOCM_ST: c_int = 0x008; +pub const TIOCM_SR: c_int = 0x010; +pub const TIOCM_CTS: c_int = 0x020; +pub const TIOCM_CAR: c_int = 0x040; +pub const TIOCM_RNG: c_int = 0x080; +pub const TIOCM_DSR: c_int = 0x100; +pub const TIOCM_CD: c_int = TIOCM_CAR; +pub const TIOCM_RI: c_int = TIOCM_RNG; +pub const O_TMPFILE: c_int = 0x410000; + +pub const MAX_ADDR_LEN: usize = 7; +pub const ARPD_UPDATE: c_ushort = 0x01; +pub const ARPD_LOOKUP: c_ushort = 0x02; +pub const ARPD_FLUSH: c_ushort = 0x03; +pub const ATF_MAGIC: c_int = 0x80; + +pub const PRIO_PROCESS: c_int = 0; +pub const PRIO_PGRP: c_int = 1; +pub const PRIO_USER: c_int = 2; + +pub const SOMAXCONN: c_int = 128; + +f! { + pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { + if ((*cmsg).cmsg_len as usize) < size_of::() { + return core::ptr::null_mut::(); + } + let next = (cmsg as usize + super::CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr; + let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; + if (next.offset(1)) as usize >= max { + core::ptr::null_mut::() + } else { + next as *mut cmsghdr + } + } + + pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { + for slot in cpuset.bits.iter_mut() { + *slot = 0; + } + } + + pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc + let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); + cpuset.bits[idx] |= 1 << offset; + () + } + + pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc + let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); + cpuset.bits[idx] &= !(1 << offset); + () + } + + pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); + let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); + 0 != (cpuset.bits[idx] & (1 << offset)) + } + + pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool { + set1.bits == set2.bits + } +} + +safe_f! { + pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { + let major = major as crate::dev_t; + let minor = minor as crate::dev_t; + let mut dev = 0; + dev |= (major & 0xfffff000) << 31 << 1; + dev |= (major & 0x00000fff) << 8; + dev |= (minor & 0xffffff00) << 12; + dev |= minor & 0x000000ff; + dev + } + + pub const fn major(dev: crate::dev_t) -> c_uint { + // see + // https://github.com/emscripten-core/emscripten/blob/ + // main/system/lib/libc/musl/include/sys/sysmacros.h + let mut major = 0; + major |= (dev >> 31 >> 1) & 0xfffff000; + major |= (dev >> 8) & 0x00000fff; + major as c_uint + } + + pub const fn minor(dev: crate::dev_t) -> c_uint { + // see + // https://github.com/emscripten-core/emscripten/blob/ + // main/system/lib/libc/musl/include/sys/sysmacros.h + let mut minor = 0; + minor |= (dev >> 12) & 0xffffff00; + minor |= dev & 0x000000ff; + minor as c_uint + } +} + +extern "C" { + pub fn getrlimit(resource: c_int, rlim: *mut crate::rlimit) -> c_int; + pub fn setrlimit(resource: c_int, rlim: *const crate::rlimit) -> c_int; + pub fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int; + + pub fn abs(i: c_int) -> c_int; + pub fn labs(i: c_long) -> c_long; + pub fn rand() -> c_int; + pub fn srand(seed: c_uint); + + pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut c_void) -> c_int; + + pub fn setpwent(); + pub fn endpwent(); + pub fn getpwent() -> *mut passwd; + + pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int; + + pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; + pub fn __errno_location() -> *mut c_int; + + pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int; + pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t; + pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t; + pub fn dup3(oldfd: c_int, newfd: c_int, flags: c_int) -> c_int; + pub fn nl_langinfo_l(item: crate::nl_item, locale: crate::locale_t) -> *mut c_char; + pub fn accept4( + fd: c_int, + addr: *mut crate::sockaddr, + len: *mut crate::socklen_t, + flg: c_int, + ) -> c_int; + pub fn getnameinfo( + sa: *const crate::sockaddr, + salen: crate::socklen_t, + host: *mut c_char, + hostlen: crate::socklen_t, + serv: *mut c_char, + servlen: crate::socklen_t, + flags: c_int, + ) -> c_int; + pub fn getloadavg(loadavg: *mut c_double, nelem: c_int) -> c_int; + + pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; + + pub fn mremap( + addr: *mut c_void, + len: size_t, + new_len: size_t, + flags: c_int, + ... + ) -> *mut c_void; + + pub fn glob( + pattern: *const c_char, + flags: c_int, + errfunc: Option c_int>, + pglob: *mut crate::glob_t, + ) -> c_int; + pub fn globfree(pglob: *mut crate::glob_t); + + pub fn posix_madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; + + pub fn shm_unlink(name: *const c_char) -> c_int; + + pub fn seekdir(dirp: *mut crate::DIR, loc: c_long); + + pub fn telldir(dirp: *mut crate::DIR) -> c_long; + pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; + + pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int; + + pub fn recvfrom( + socket: c_int, + buf: *mut c_void, + len: size_t, + flags: c_int, + addr: *mut crate::sockaddr, + addrlen: *mut crate::socklen_t, + ) -> ssize_t; + pub fn mkstemps(template: *mut c_char, suffixlen: c_int) -> c_int; + pub fn nl_langinfo(item: crate::nl_item) -> *mut c_char; + + pub fn sendmmsg( + sockfd: c_int, + msgvec: *mut crate::mmsghdr, + vlen: c_uint, + flags: c_uint, + ) -> c_int; + pub fn recvmmsg( + sockfd: c_int, + msgvec: *mut crate::mmsghdr, + vlen: c_uint, + flags: c_uint, + timeout: *mut crate::timespec, + ) -> c_int; + pub fn sync(); + pub fn ioctl(fd: c_int, request: c_int, ...) -> c_int; + pub fn getpriority(which: c_int, who: crate::id_t) -> c_int; + pub fn setpriority(which: c_int, who: crate::id_t, prio: c_int) -> c_int; + + pub fn getentropy(buf: *mut c_void, buflen: size_t) -> c_int; + + // grp.h + pub fn getgrgid(gid: crate::gid_t) -> *mut crate::group; + pub fn getgrnam(name: *const c_char) -> *mut crate::group; + pub fn getgrnam_r( + name: *const c_char, + grp: *mut crate::group, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::group, + ) -> c_int; + pub fn getgrgid_r( + gid: crate::gid_t, + grp: *mut crate::group, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::group, + ) -> c_int; +} + +// Alias to 64 to mimic glibc's LFS64 support +mod lfs64; +pub use self::lfs64::*; diff --git a/http/vendor/libc/src/unix/linux_like/l4re/mod.rs b/http/vendor/libc/src/unix/linux_like/l4re/mod.rs new file mode 100644 index 0000000..5ac4868 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/l4re/mod.rs @@ -0,0 +1,204 @@ +///! L4Re specifics +///! This module contains definitions required by various L4Re libc backends. +///! Some of them are formally not part of the libc, but are a dependency of the +///! libc and hence we should provide them here. +use crate::prelude::*; + +pub type l4_umword_t = c_ulong; // Unsigned machine word. +pub type pthread_t = *mut c_void; + +pub type dev_t = u64; +pub type socklen_t = u32; +pub type mode_t = u32; +pub type ino64_t = u64; +pub type off64_t = i64; +pub type blkcnt64_t = i64; +pub type rlim64_t = u64; +pub type nfds_t = c_ulong; +pub type nl_item = c_int; +pub type idtype_t = c_uint; +pub type loff_t = c_longlong; +pub type pthread_key_t = c_uint; +pub type pthread_once_t = c_int; +pub type pthread_spinlock_t = c_int; + +s! { + /// CPU sets. + pub struct l4_sched_cpu_set_t { + // from the L4Re docs + /// Combination of granularity and offset. + /// + /// The granularity defines how many CPUs each bit in map describes. + /// The offset is the number of the first CPU described by the first + /// bit in the bitmap. + /// offset must be a multiple of 2^graularity. + /// + /// | MSB | LSB | + /// | ---------------- | ------------------- | + /// | 8bit granularity | 24bit offset .. | + gran_offset: l4_umword_t, + /// Bitmap of CPUs. + map: l4_umword_t, + } + + pub struct pthread_attr_t { + __detachstate: c_int, + __schedpolicy: c_int, + __schedparam: super::__sched_param, + __inheritsched: c_int, + __scope: c_int, + __guardsize: size_t, + __stackaddr_set: c_int, + __stackaddr: *mut c_void, // better don't use it + __stacksize: size_t, + // L4Re specifics + pub affinity: l4_sched_cpu_set_t, + pub create_flags: c_uint, + } +} + +// L4Re requires a min stack size of 64k; that isn't defined in uClibc, but +// somewhere in the core libraries. uClibc wants 16k, but that's not enough. +pub const PTHREAD_STACK_MIN: usize = 65536; + +pub const BOTHER: crate::speed_t = 0o010000; + +pub const RLIMIT_CPU: crate::__rlimit_resource_t = 0; +pub const RLIMIT_FSIZE: crate::__rlimit_resource_t = 1; +pub const RLIMIT_DATA: crate::__rlimit_resource_t = 2; +pub const RLIMIT_STACK: crate::__rlimit_resource_t = 3; +pub const RLIMIT_CORE: crate::__rlimit_resource_t = 4; +pub const RLIMIT_RSS: crate::__rlimit_resource_t = 5; +pub const RLIMIT_NPROC: crate::__rlimit_resource_t = 6; +pub const RLIMIT_NOFILE: crate::__rlimit_resource_t = 7; +pub const RLIMIT_MEMLOCK: crate::__rlimit_resource_t = 8; +pub const RLIMIT_AS: crate::__rlimit_resource_t = 9; +pub const RLIMIT_LOCKS: crate::__rlimit_resource_t = 10; +pub const RLIMIT_SIGPENDING: crate::__rlimit_resource_t = 11; +pub const RLIMIT_MSGQUEUE: crate::__rlimit_resource_t = 12; +pub const RLIMIT_NICE: crate::__rlimit_resource_t = 13; +pub const RLIMIT_RTPRIO: crate::__rlimit_resource_t = 14; +pub const RLIMIT_RTTIME: crate::__rlimit_resource_t = 15; +pub const RLIMIT_NLIMITS: crate::__rlimit_resource_t = RLIM_NLIMITS; +pub const RLIM_NLIMITS: crate::__rlimit_resource_t = 16; + +pub const SOL_SOCKET: c_int = 1; + +// pub const SO_DEBUG: c_int = 1; +pub const SO_REUSEADDR: c_int = 2; +pub const SO_TYPE: c_int = 3; +pub const SO_ERROR: c_int = 4; +pub const SO_DONTROUTE: c_int = 5; +pub const SO_BROADCAST: c_int = 6; +pub const SO_SNDBUF: c_int = 7; +pub const SO_RCVBUF: c_int = 8; +pub const SO_KEEPALIVE: c_int = 9; +pub const SO_OOBINLINE: c_int = 10; +pub const SO_NO_CHECK: c_int = 11; +pub const SO_PRIORITY: c_int = 12; +pub const SO_LINGER: c_int = 13; +pub const SO_BSDCOMPAT: c_int = 14; +pub const SO_PASSCRED: c_int = 16; +pub const SO_PEERCRED: c_int = 17; +pub const SO_RCVLOWAT: c_int = 18; +pub const SO_SNDLOWAT: c_int = 19; +pub const SO_RCVTIMEO: c_int = 20; +pub const SO_SNDTIMEO: c_int = 21; +pub const SO_SECURITY_AUTHENTICATION: c_int = 22; +pub const SO_SECURITY_ENCRYPTION_TRANSPORT: c_int = 23; +pub const SO_SECURITY_ENCRYPTION_NETWORK: c_int = 24; +pub const SO_BINDTODEVICE: c_int = 25; +pub const SO_ATTACH_FILTER: c_int = 26; +pub const SO_DETACH_FILTER: c_int = 27; +pub const SO_PEERNAME: c_int = 28; + +pub const SO_ACCEPTCONN: c_int = 30; +pub const SO_PEERSEC: c_int = 31; + +pub const TCGETS: Ioctl = 0x5401; +pub const TCSETS: Ioctl = 0x5402; +pub const TCSETSW: Ioctl = 0x5403; +pub const TCSETSF: Ioctl = 0x5404; +pub const TCGETA: Ioctl = 0x5405; +pub const TCSETA: Ioctl = 0x5406; +pub const TCSETAW: Ioctl = 0x5407; +pub const TCSETAF: Ioctl = 0x5408; +pub const TCSBRK: Ioctl = 0x5409; +pub const TCXONC: Ioctl = 0x540A; +pub const TCFLSH: Ioctl = 0x540B; +pub const TIOCM_LE: c_int = 0x001; +pub const TIOCM_DTR: c_int = 0x002; +pub const TIOCM_RTS: c_int = 0x004; +pub const TIOCM_ST: c_int = 0x008; +pub const TIOCM_SR: c_int = 0x010; +pub const TIOCM_CTS: c_int = 0x020; +pub const TIOCM_CAR: c_int = 0x040; +pub const TIOCM_CD: c_int = TIOCM_CAR; +pub const TIOCM_RNG: c_int = 0x080; +pub const TIOCM_RI: c_int = TIOCM_RNG; +pub const TIOCM_DSR: c_int = 0x100; +pub const TIOCEXCL: Ioctl = 0x540C; +pub const TIOCNXCL: Ioctl = 0x540D; +pub const TIOCSCTTY: Ioctl = 0x540E; +pub const TIOCGPGRP: Ioctl = 0x540F; +pub const TIOCSPGRP: Ioctl = 0x5410; +pub const TIOCOUTQ: Ioctl = 0x5411; +pub const TIOCSTI: Ioctl = 0x5412; +pub const TIOCGWINSZ: Ioctl = 0x5413; +pub const TIOCSWINSZ: Ioctl = 0x5414; +pub const TIOCMGET: Ioctl = 0x5415; +pub const TIOCMBIS: Ioctl = 0x5416; +pub const TIOCMBIC: Ioctl = 0x5417; +pub const TIOCMSET: Ioctl = 0x5418; +pub const TIOCGSOFTCAR: Ioctl = 0x5419; +pub const TIOCSSOFTCAR: Ioctl = 0x541A; +pub const FIONREAD: Ioctl = 0x541B; +pub const TIOCINQ: Ioctl = FIONREAD; +pub const TIOCLINUX: Ioctl = 0x541C; +pub const TIOCCONS: Ioctl = 0x541D; +pub const TIOCGSERIAL: Ioctl = 0x541E; +pub const TIOCSSERIAL: Ioctl = 0x541F; +pub const TIOCPKT: Ioctl = 0x5420; +pub const FIONBIO: Ioctl = 0x5421; +pub const TIOCNOTTY: Ioctl = 0x5422; +pub const TIOCSETD: Ioctl = 0x5423; +pub const TIOCGETD: Ioctl = 0x5424; +pub const TCSBRKP: Ioctl = 0x5425; +pub const TIOCSBRK: Ioctl = 0x5427; +pub const TIOCCBRK: Ioctl = 0x5428; +pub const TIOCGSID: Ioctl = 0x5429; +pub const TIOCGPTN: Ioctl = 0x80045430; +pub const TIOCSPTLCK: Ioctl = 0x40045431; +pub const FIONCLEX: Ioctl = 0x5450; +pub const FIOCLEX: Ioctl = 0x5451; +pub const FIOASYNC: Ioctl = 0x5452; +pub const TIOCSERCONFIG: Ioctl = 0x5453; +pub const TIOCSERGWILD: Ioctl = 0x5454; +pub const TIOCSERSWILD: Ioctl = 0x5455; +pub const TIOCGLCKTRMIOS: Ioctl = 0x5456; +pub const TIOCSLCKTRMIOS: Ioctl = 0x5457; +pub const TIOCSERGSTRUCT: Ioctl = 0x5458; +pub const TIOCSERGETLSR: Ioctl = 0x5459; +pub const TIOCSERGETMULTI: Ioctl = 0x545A; +pub const TIOCSERSETMULTI: Ioctl = 0x545B; +pub const TIOCMIWAIT: Ioctl = 0x545C; +pub const TIOCGICOUNT: Ioctl = 0x545D; + +pub const BLKSSZGET: Ioctl = 0x1268; + +cfg_if! { + if #[cfg(not(target_env = "uclibc"))] { + pub const NLMSG_NOOP: c_int = 0x1; + pub const NLMSG_ERROR: c_int = 0x2; + pub const NLMSG_DONE: c_int = 0x3; + pub const NLMSG_OVERRUN: c_int = 0x4; + pub const NLMSG_MIN_TYPE: c_int = 0x10; + } +} + +cfg_if! { + if #[cfg(target_env = "uclibc")] { + mod uclibc; + pub use self::uclibc::*; + } +} diff --git a/http/vendor/libc/src/unix/linux_like/l4re/uclibc/aarch64/mod.rs b/http/vendor/libc/src/unix/linux_like/l4re/uclibc/aarch64/mod.rs new file mode 100644 index 0000000..3a47170 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/l4re/uclibc/aarch64/mod.rs @@ -0,0 +1,414 @@ +use crate::prelude::*; + +pub type wchar_t = c_uint; +pub type time_t = c_long; + +pub type clock_t = c_long; +pub type fsblkcnt_t = c_ulong; +pub type fsfilcnt_t = c_ulong; +pub type ino_t = c_ulong; +pub type nlink_t = c_ulong; +pub type off_t = c_long; +pub type fsword_t = c_long; +pub type suseconds_t = c_long; + +pub type blksize_t = c_long; +pub type blkcnt_t = c_long; + +pub type fsblkcnt64_t = c_ulong; +pub type fsfilcnt64_t = c_ulong; +pub type __u64 = c_ulong; + +s! { + pub struct stat { + pub st_dev: c_ulong, + pub __pad1: c_ushort, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: c_ulong, + pub __pad2: c_ushort, + pub st_size: crate::off64_t, + pub st_blksize: blksize_t, + pub st_blocks: crate::blkcnt64_t, + pub st_atim: crate::timespec, + pub st_mtim: crate::timespec, + pub st_ctim: crate::timespec, + pub __uclibc_unused4: c_ulong, + pub __uclibc_unused5: c_ulong, + } + + pub struct stat64 { + pub st_dev: c_ulong, + pub __pad1: c_uint, + pub __st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: c_ulong, + pub __pad2: c_uint, + pub st_size: crate::off64_t, + pub st_blksize: blksize_t, + pub st_blocks: crate::blkcnt64_t, + pub st_atim: crate::timespec, + pub st_mtim: crate::timespec, + pub st_ctim: crate::timespec, + pub st_ino: crate::ino64_t, + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: crate::size_t, + pub shm_atime: crate::time_t, + __unused1: c_ulong, + pub shm_dtime: crate::time_t, + __unused2: c_ulong, + pub shm_ctime: crate::time_t, + __unused3: c_ulong, + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: crate::shmatt_t, + __unused4: c_ulong, + __unused5: c_ulong, + } + + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigaction { + pub sa_handler: crate::sighandler_t, + pub sa_flags: c_ulong, + pub sa_restorer: Option, + pub sa_mask: sigset_t, + } + + pub struct sigset_t { + __val: [c_ulong; 1], + } + + #[repr(align(8))] + pub struct siginfo_t { + pub si_signo: c_int, + pub si_errno: c_int, + pub si_code: c_int, + pub _pad: [c_int; 28], + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_flags: c_int, + pub ss_size: crate::size_t, + } + + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off_t, + pub l_len: off_t, + pub l_pid: crate::pid_t, + } + + pub struct termios { + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_line: crate::cc_t, + pub c_cc: [crate::cc_t; crate::NCCS], + pub c_ispeed: crate::speed_t, + pub c_ospeed: crate::speed_t, + } +} + +s_no_extra_traits! { + pub union sem_t { + __size: [c_char; 32], + __align: c_longlong, + } +} + +pub const O_CLOEXEC: c_int = 0o2000000; +pub const __SIZEOF_PTHREAD_ATTR_T: usize = 36; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_COND_T: usize = 48; +pub const __SIZEOF_PTHREAD_COND_COMPAT_T: usize = 12; +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; +pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; +pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; +pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; + +pub const NCCS: usize = 32; + +pub const FIOQSIZE: crate::Ioctl = 0x545E; + +// I wasn't able to find those constants +// in uclibc build environment for armv7 +pub const MAP_HUGETLB: c_int = 0x040000; // from linux/other/mod.rs + +// autogenerated constants with hand tuned types +pub const B0: crate::speed_t = 0; +pub const B1000000: crate::speed_t = 0x1008; +pub const B110: crate::speed_t = 0x3; +pub const B115200: crate::speed_t = 0x1002; +pub const B1152000: crate::speed_t = 0x1009; +pub const B1200: crate::speed_t = 0x9; +pub const B134: crate::speed_t = 0x4; +pub const B150: crate::speed_t = 0x5; +pub const B1500000: crate::speed_t = 0x100a; +pub const B1800: crate::speed_t = 0xa; +pub const B19200: crate::speed_t = 0xe; +pub const B200: crate::speed_t = 0x6; +pub const B2000000: crate::speed_t = 0x100b; +pub const B230400: crate::speed_t = 0x1003; +pub const B2400: crate::speed_t = 0xb; +pub const B2500000: crate::speed_t = 0x100c; +pub const B300: crate::speed_t = 0x7; +pub const B3000000: crate::speed_t = 0x100d; +pub const B3500000: crate::speed_t = 0x100e; +pub const B38400: crate::speed_t = 0xf; +pub const B4000000: crate::speed_t = 0x100f; +pub const B460800: crate::speed_t = 0x1004; +pub const B4800: crate::speed_t = 0xc; +pub const B50: crate::speed_t = 0x1; +pub const B500000: crate::speed_t = 0x1005; +pub const B57600: crate::speed_t = 0x1001; +pub const B576000: crate::speed_t = 0x1006; +pub const B600: crate::speed_t = 0x8; +pub const B75: crate::speed_t = 0x2; +pub const B921600: crate::speed_t = 0x1007; +pub const B9600: crate::speed_t = 0xd; +pub const BS1: c_int = 0x2000; +pub const BSDLY: c_int = 0x2000; +pub const CBAUD: crate::tcflag_t = 0x100f; +pub const CBAUDEX: crate::tcflag_t = 0x1000; +pub const CIBAUD: crate::tcflag_t = 0x100f0000; +pub const CLOCAL: crate::tcflag_t = 0x800; +pub const CPU_SETSIZE: c_int = 0x400; +pub const CR1: c_int = 0x200; +pub const CR2: c_int = 0x400; +pub const CR3: c_int = 0x600; +pub const CRDLY: c_int = 0x600; +pub const CREAD: crate::tcflag_t = 0x80; +pub const CS6: crate::tcflag_t = 0x10; +pub const CS7: crate::tcflag_t = 0x20; +pub const CS8: crate::tcflag_t = 0x30; +pub const CSIZE: crate::tcflag_t = 0x30; +pub const CSTOPB: crate::tcflag_t = 0x40; +pub const EADDRINUSE: c_int = 0x62; +pub const EADDRNOTAVAIL: c_int = 0x63; +pub const EADV: c_int = 0x44; +pub const EAFNOSUPPORT: c_int = 0x61; +pub const EALREADY: c_int = 0x72; +pub const EBADE: c_int = 0x34; +pub const EBADFD: c_int = 0x4d; +pub const EBADMSG: c_int = 0x4a; +pub const EBADR: c_int = 0x35; +pub const EBADRQC: c_int = 0x38; +pub const EBADSLT: c_int = 0x39; +pub const EBFONT: c_int = 0x3b; +pub const ECANCELED: c_int = 0x7d; +pub const ECHOCTL: crate::tcflag_t = 0x200; +pub const ECHOE: crate::tcflag_t = 0x10; +pub const ECHOK: crate::tcflag_t = 0x20; +pub const ECHOKE: crate::tcflag_t = 0x800; +pub const ECHONL: crate::tcflag_t = 0x40; +pub const ECHOPRT: crate::tcflag_t = 0x400; +pub const ECHRNG: c_int = 0x2c; +pub const ECOMM: c_int = 0x46; +pub const ECONNABORTED: c_int = 0x67; +pub const ECONNREFUSED: c_int = 0x6f; +pub const ECONNRESET: c_int = 0x68; +pub const EDESTADDRREQ: c_int = 0x59; +pub const EDOTDOT: c_int = 0x49; +pub const EDQUOT: c_int = 0x7a; +pub const EHOSTDOWN: c_int = 0x70; +pub const EHOSTUNREACH: c_int = 0x71; +pub const EIDRM: c_int = 0x2b; +pub const EILSEQ: c_int = 0x54; +pub const EINPROGRESS: c_int = 0x73; +pub const EISCONN: c_int = 0x6a; +pub const EISNAM: c_int = 0x78; +pub const EKEYEXPIRED: c_int = 0x7f; +pub const EKEYREJECTED: c_int = 0x81; +pub const EKEYREVOKED: c_int = 0x80; +pub const EL2HLT: c_int = 0x33; +pub const EL2NSYNC: c_int = 0x2d; +pub const EL3HLT: c_int = 0x2e; +pub const EL3RST: c_int = 0x2f; +pub const ELIBACC: c_int = 0x4f; +pub const ELIBBAD: c_int = 0x50; +pub const ELIBEXEC: c_int = 0x53; +pub const ELIBMAX: c_int = 0x52; +pub const ELIBSCN: c_int = 0x51; +pub const ELNRNG: c_int = 0x30; +pub const ELOOP: c_int = 0x28; +pub const EMEDIUMTYPE: c_int = 0x7c; +pub const EMSGSIZE: c_int = 0x5a; +pub const EMULTIHOP: c_int = 0x48; +pub const ENAMETOOLONG: c_int = 0x24; +pub const ENAVAIL: c_int = 0x77; +pub const ENETDOWN: c_int = 0x64; +pub const ENETRESET: c_int = 0x66; +pub const ENETUNREACH: c_int = 0x65; +pub const ENOANO: c_int = 0x37; +pub const ENOBUFS: c_int = 0x69; +pub const ENOCSI: c_int = 0x32; +pub const ENODATA: c_int = 0x3d; +pub const ENOKEY: c_int = 0x7e; +pub const ENOLCK: c_int = 0x25; +pub const ENOLINK: c_int = 0x43; +pub const ENOMEDIUM: c_int = 0x7b; +pub const ENOMSG: c_int = 0x2a; +pub const ENONET: c_int = 0x40; +pub const ENOPKG: c_int = 0x41; +pub const ENOPROTOOPT: c_int = 0x5c; +pub const ENOSR: c_int = 0x3f; +pub const ENOSTR: c_int = 0x3c; +pub const ENOSYS: c_int = 0x26; +pub const ENOTCONN: c_int = 0x6b; +pub const ENOTEMPTY: c_int = 0x27; +pub const ENOTNAM: c_int = 0x76; +pub const ENOTRECOVERABLE: c_int = 0x83; +pub const ENOTSOCK: c_int = 0x58; +pub const ENOTUNIQ: c_int = 0x4c; +pub const EOPNOTSUPP: c_int = 0x5f; +pub const EOVERFLOW: c_int = 0x4b; +pub const EOWNERDEAD: c_int = 0x82; +pub const EPFNOSUPPORT: c_int = 0x60; +pub const EPOLL_CLOEXEC: c_int = 0x80000; +pub const EPROTO: c_int = 0x47; +pub const EPROTONOSUPPORT: c_int = 0x5d; +pub const EPROTOTYPE: c_int = 0x5b; +pub const EREMCHG: c_int = 0x4e; +pub const EREMOTE: c_int = 0x42; +pub const EREMOTEIO: c_int = 0x79; +pub const ERESTART: c_int = 0x55; +pub const ESHUTDOWN: c_int = 0x6c; +pub const ESOCKTNOSUPPORT: c_int = 0x5e; +pub const ESRMNT: c_int = 0x45; +pub const ESTALE: c_int = 0x74; +pub const ESTRPIPE: c_int = 0x56; +pub const ETIME: c_int = 0x3e; +pub const ETIMEDOUT: c_int = 0x6e; +pub const ETOOMANYREFS: c_int = 0x6d; +pub const EUCLEAN: c_int = 0x75; +pub const EUNATCH: c_int = 0x31; +pub const EUSERS: c_int = 0x57; +pub const EXFULL: c_int = 0x36; +pub const FF1: c_int = 0x8000; +pub const FFDLY: c_int = 0x8000; +pub const FLUSHO: crate::tcflag_t = 0x1000; +pub const F_GETLK: c_int = 0x5; +pub const F_SETLK: c_int = 0x6; +pub const F_SETLKW: c_int = 0x7; +pub const HUPCL: crate::tcflag_t = 0x400; +pub const ICANON: crate::tcflag_t = 0x2; +pub const IEXTEN: crate::tcflag_t = 0x8000; +pub const ISIG: crate::tcflag_t = 0x1; +pub const IXOFF: crate::tcflag_t = 0x1000; +pub const IXON: crate::tcflag_t = 0x400; +pub const MAP_ANON: c_int = 0x20; +pub const MAP_ANONYMOUS: c_int = 0x20; +pub const MAP_DENYWRITE: c_int = 0x800; +pub const MAP_EXECUTABLE: c_int = 0x1000; +pub const MAP_GROWSDOWN: c_int = 0x100; +pub const MAP_LOCKED: c_int = 0x2000; +pub const MAP_NONBLOCK: c_int = 0x10000; +pub const MAP_NORESERVE: c_int = 0x4000; +pub const MAP_POPULATE: c_int = 0x8000; +pub const MAP_STACK: c_int = 0x20000; +pub const MINSIGSTKSZ: c_int = 5120; +pub const NLDLY: crate::tcflag_t = 0x100; +pub const NOFLSH: crate::tcflag_t = 0x80; +pub const OLCUC: crate::tcflag_t = 0x2; +pub const ONLCR: crate::tcflag_t = 0x4; +pub const O_ACCMODE: c_int = 0x3; +pub const O_APPEND: c_int = 0x400; +pub const O_ASYNC: c_int = 0o20000; +pub const O_CREAT: c_int = 0x40; +pub const O_DIRECT: c_int = 0x10000; +pub const O_DIRECTORY: c_int = 0x4000; +pub const O_DSYNC: c_int = O_SYNC; +pub const O_EXCL: c_int = 0x80; +pub const O_FSYNC: c_int = O_SYNC; +pub const O_LARGEFILE: c_int = 0o400000; +pub const O_NDELAY: c_int = O_NONBLOCK; +pub const O_NOATIME: c_int = 0o1000000; +pub const O_NOCTTY: c_int = 0x100; +pub const O_NOFOLLOW: c_int = 0x8000; +pub const O_NONBLOCK: c_int = 0x800; +pub const O_PATH: c_int = 0o10000000; +pub const O_RSYNC: c_int = O_SYNC; +pub const O_SYNC: c_int = 0o10000; +pub const O_TRUNC: c_int = 0x200; +pub const PARENB: crate::tcflag_t = 0x100; +pub const PARODD: crate::tcflag_t = 0x200; +pub const PENDIN: crate::tcflag_t = 0x4000; +pub const POLLWRBAND: c_short = 0x200; +pub const POLLWRNORM: c_short = 0x100; +pub const RTLD_GLOBAL: c_int = 0x00100; + +// These are typed unsigned to match sigaction +pub const SA_NOCLDSTOP: c_ulong = 0x1; +pub const SA_NOCLDWAIT: c_ulong = 0x2; +pub const SA_SIGINFO: c_ulong = 0x4; +pub const SA_NODEFER: c_ulong = 0x40000000; +pub const SA_ONSTACK: c_ulong = 0x8000000; +pub const SA_RESETHAND: c_ulong = 0x80000000; +pub const SA_RESTART: c_ulong = 0x10000000; + +pub const SIGBUS: c_int = 0x7; +pub const SIGCHLD: c_int = 0x11; +pub const SIGCONT: c_int = 0x12; +pub const SIGIO: c_int = 0x1d; +pub const SIGPOLL: c_int = SIGIO; +pub const SIGPROF: c_int = 0x1b; +pub const SIGPWR: c_int = 0x1e; +pub const SIGSTKFLT: c_int = 0x10; +pub const SIGSTKSZ: c_int = 16384; +pub const SIGSTOP: c_int = 0x13; +pub const SIGSYS: c_int = 0x1f; +pub const SIGTSTP: c_int = 0x14; +pub const SIGTTIN: c_int = 0x15; +pub const SIGTTOU: c_int = 0x16; +pub const SIGURG: c_int = 0x17; +pub const SIGUSR1: c_int = 0xa; +pub const SIGUSR2: c_int = 0xc; +pub const SIGVTALRM: c_int = 0x1a; +pub const SIGWINCH: c_int = 0x1c; +pub const SIGXCPU: c_int = 0x18; +pub const SIGXFSZ: c_int = 0x19; +pub const SIG_BLOCK: c_int = 0; +pub const SIG_UNBLOCK: c_int = 0x1; +pub const SIG_SETMASK: c_int = 0x2; +pub const SOCK_DGRAM: c_int = 0x2; +pub const SOCK_NONBLOCK: c_int = 0o0004000; +pub const SOCK_SEQPACKET: c_int = 0x5; +pub const SOCK_STREAM: c_int = 0x1; + +pub const TAB1: c_int = 0x800; +pub const TAB2: c_int = 0x1000; +pub const TAB3: c_int = 0x1800; +pub const TABDLY: c_int = 0x1800; +pub const TCSADRAIN: c_int = 0x1; +pub const TCSAFLUSH: c_int = 0x2; +pub const TCSANOW: c_int = 0; +pub const TOSTOP: crate::tcflag_t = 0x100; +pub const VDISCARD: usize = 0xd; +pub const VEOF: usize = 0x4; +pub const VEOL: usize = 0xb; +pub const VEOL2: usize = 0x10; +pub const VMIN: usize = 0x6; +pub const VREPRINT: usize = 0xc; +pub const VSTART: usize = 0x8; +pub const VSTOP: usize = 0x9; +pub const VSUSP: usize = 0xa; +pub const VSWTC: usize = 0x7; +pub const VT1: c_int = 0x4000; +pub const VTDLY: c_int = 0x4000; +pub const VTIME: usize = 0x5; +pub const VWERASE: usize = 0xe; +pub const XTABS: crate::tcflag_t = 0x1800; diff --git a/http/vendor/libc/src/unix/linux_like/l4re/uclibc/mod.rs b/http/vendor/libc/src/unix/linux_like/l4re/uclibc/mod.rs new file mode 100644 index 0000000..e593ad7 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/l4re/uclibc/mod.rs @@ -0,0 +1,538 @@ +use crate::off64_t; +use crate::prelude::*; + +pub type shmatt_t = c_ulong; +pub type regoff_t = c_int; +pub type rlim_t = c_ulong; +pub type __rlimit_resource_t = c_int; +pub type __priority_which_t = c_uint; + +pub type _pthread_descr = *mut c_void; +pub type __pthread_cond_align_t = c_long; + +cfg_if! { + if #[cfg(doc)] { + // Used in `linux::arch` to define ioctl constants. + pub(crate) type Ioctl = c_ulong; + } else { + #[doc(hidden)] + pub type Ioctl = c_ulong; + } +} + +s! { + pub struct cmsghdr { + pub cmsg_len: crate::size_t, + pub cmsg_level: c_int, + pub cmsg_type: c_int, + } + + pub struct msghdr { + pub msg_name: *mut c_void, + pub msg_namelen: crate::socklen_t, + pub msg_iov: *mut crate::iovec, + #[cfg(target_pointer_width = "32")] + pub msg_iovlen: c_int, + #[cfg(target_pointer_width = "64")] + pub msg_iovlen: crate::size_t, + pub msg_control: *mut c_void, + #[cfg(target_pointer_width = "32")] + pub msg_controllen: crate::socklen_t, + #[cfg(target_pointer_width = "64")] + pub msg_controllen: crate::size_t, + pub msg_flags: c_int, + } + + pub struct statfs { + pub f_type: fsword_t, + pub f_bsize: fsword_t, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_fsid: crate::fsid_t, + pub f_namelen: fsword_t, + pub f_frsize: fsword_t, + pub f_flags: fsword_t, + pub f_spare: [fsword_t; 4], + } + + pub struct statfs64 { + pub f_type: fsword_t, + pub f_bsize: fsword_t, + pub f_blocks: crate::fsblkcnt64_t, + pub f_bfree: crate::fsblkcnt64_t, + pub f_bavail: crate::fsblkcnt64_t, + pub f_files: crate::fsfilcnt64_t, + pub f_ffree: crate::fsfilcnt64_t, + pub f_fsid: crate::fsid_t, + pub f_namelen: fsword_t, + pub f_frsize: fsword_t, + pub f_flags: fsword_t, + pub f_spare: [fsword_t; 4], + } + + pub struct statvfs64 { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsfilcnt64_t, + pub f_bfree: crate::fsfilcnt64_t, + pub f_bavail: crate::fsfilcnt64_t, + pub f_files: crate::fsfilcnt64_t, + pub f_ffree: crate::fsfilcnt64_t, + pub f_favail: crate::fsfilcnt64_t, + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + pub __f_spare: [c_int; 6], + } + + pub struct ipc_perm { + pub __key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + #[cfg(target_pointer_width = "32")] + pub mode: c_ushort, + #[cfg(target_pointer_width = "64")] + pub mode: c_uint, + #[cfg(target_pointer_width = "32")] + __pad1: c_ushort, + pub __seq: c_ushort, + __pad2: c_ushort, + __unused1: c_ulong, + __unused2: c_ulong, + } + + pub struct statvfs { + // Different than GNU! + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_favail: crate::fsfilcnt_t, + #[cfg(target_endian = "little")] + pub f_fsid: c_ulong, + #[cfg(target_pointer_width = "32")] + __f_unused: c_int, + #[cfg(target_endian = "big")] + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: [c_int; 6], + } + + pub struct sysinfo { + pub uptime: c_long, + pub loads: [c_ulong; 3], + pub totalram: c_ulong, + pub freeram: c_ulong, + pub sharedram: c_ulong, + pub bufferram: c_ulong, + pub totalswap: c_ulong, + pub freeswap: c_ulong, + pub procs: c_ushort, + pub pad: c_ushort, + pub totalhigh: c_ulong, + pub freehigh: c_ulong, + pub mem_unit: c_uint, + #[cfg(target_pointer_width = "32")] + pub _f: [c_char; 8], + #[cfg(target_pointer_width = "64")] + pub _f: [c_char; 0], + } + + pub struct regex_t { + __buffer: *mut c_void, + __allocated: size_t, + __used: size_t, + __syntax: c_ulong, + __fastmap: *mut c_char, + __translate: *mut c_char, + __re_nsub: size_t, + __bitfield: u8, + } + + pub struct rtentry { + pub rt_pad1: c_ulong, + pub rt_dst: crate::sockaddr, + pub rt_gateway: crate::sockaddr, + pub rt_genmask: crate::sockaddr, + pub rt_flags: c_ushort, + pub rt_pad2: c_short, + pub rt_pad3: c_ulong, + pub rt_tos: c_uchar, + pub rt_class: c_uchar, + #[cfg(target_pointer_width = "64")] + pub rt_pad4: [c_short; 3usize], + #[cfg(not(target_pointer_width = "64"))] + pub rt_pad4: c_short, + pub rt_metric: c_short, + pub rt_dev: *mut c_char, + pub rt_mtu: c_ulong, + pub rt_window: c_ulong, + pub rt_irtt: c_ushort, + } + + pub struct __exit_status { + pub e_termination: c_short, + pub e_exit: c_short, + } + + pub struct tcp_info { + pub tcpi_state: u8, + pub tcpi_ca_state: u8, + pub tcpi_retransmits: u8, + pub tcpi_probes: u8, + pub tcpi_backoff: u8, + pub tcpi_options: u8, + /// This contains the bitfields `tcpi_snd_wscale` and `tcpi_rcv_wscale`. + /// Each is 4 bits. + pub tcpi_snd_rcv_wscale: u8, + pub tcpi_rto: u32, + pub tcpi_ato: u32, + pub tcpi_snd_mss: u32, + pub tcpi_rcv_mss: u32, + pub tcpi_unacked: u32, + pub tcpi_sacked: u32, + pub tcpi_lost: u32, + pub tcpi_retrans: u32, + pub tcpi_fackets: u32, + pub tcpi_last_data_sent: u32, + pub tcpi_last_ack_sent: u32, + pub tcpi_last_data_recv: u32, + pub tcpi_last_ack_recv: u32, + pub tcpi_pmtu: u32, + pub tcpi_rcv_ssthresh: u32, + pub tcpi_rtt: u32, + pub tcpi_rttvar: u32, + pub tcpi_snd_ssthresh: u32, + pub tcpi_snd_cwnd: u32, + pub tcpi_advmss: u32, + pub tcpi_reordering: u32, + pub tcpi_rcv_rtt: u32, + pub tcpi_rcv_space: u32, + pub tcpi_total_retrans: u32, + } + + pub struct __sched_param { + __sched_priority: c_int, + } + + pub struct _pthread_fastlock { + __status: c_long, + __spinlock: c_int, + } + + pub struct pthread_cond_t { + __c_lock: _pthread_fastlock, + __c_waiting: _pthread_descr, + __padding: [u8; PTHREAD_COND_PADDING_SIZE], + __align: __pthread_cond_align_t, + } + + pub struct pthread_condattr_t { + __dummy: c_int, + } + + pub struct pthread_mutex_t { + __m_reserved: c_int, + __m_count: c_int, + __m_owner: _pthread_descr, + __m_kind: c_int, + __m_lock: _pthread_fastlock, + } + + pub struct pthread_mutexattr_t { + __mutexkind: c_int, + } + + pub struct pthread_rwlock_t { + __rw_lock: _pthread_fastlock, + __rw_readers: c_int, + __rw_writer: _pthread_descr, + __rw_read_waiting: _pthread_descr, + __rw_write_waiting: _pthread_descr, + __rw_kind: c_int, + __rw_pshared: c_int, + } + + pub struct pthread_rwlockattr_t { + __lockkind: c_int, + __pshared: c_int, + } + + pub struct pthread_barrier_t { + __ba_lock: _pthread_fastlock, + __ba_required: c_int, + __ba_present: c_int, + __ba_waiting: _pthread_descr, + } + + pub struct pthread_barrierattr_t { + __pshared: c_int, + } +} + +impl siginfo_t { + pub unsafe fn si_addr(&self) -> *mut c_void { + #[repr(C)] + struct siginfo_sigfault { + _si_signo: c_int, + _si_errno: c_int, + _si_code: c_int, + si_addr: *mut c_void, + } + (*core::ptr::from_ref(self).cast::()).si_addr + } + + pub unsafe fn si_value(&self) -> crate::sigval { + #[repr(C)] + struct siginfo_si_value { + _si_signo: c_int, + _si_errno: c_int, + _si_code: c_int, + _si_timerid: c_int, + _si_overrun: c_int, + si_value: crate::sigval, + } + (*core::ptr::from_ref(self).cast::()).si_value + } +} + +s_no_extra_traits! { + // Internal, for casts to access union fields + struct sifields_sigchld { + si_pid: crate::pid_t, + si_uid: crate::uid_t, + si_status: c_int, + si_utime: c_long, + si_stime: c_long, + } + + // Internal, for casts to access union fields + union sifields { + _align_pointer: *mut c_void, + sigchld: sifields_sigchld, + } + + // Internal, for casts to access union fields. Note that some variants + // of sifields start with a pointer, which makes the alignment of + // sifields vary on 32-bit and 64-bit architectures. + struct siginfo_f { + _siginfo_base: [c_int; 3], + sifields: sifields, + } +} + +impl siginfo_t { + unsafe fn sifields(&self) -> &sifields { + &(*core::ptr::from_ref(self).cast::()).sifields + } + + pub unsafe fn si_pid(&self) -> crate::pid_t { + self.sifields().sigchld.si_pid + } + + pub unsafe fn si_uid(&self) -> crate::uid_t { + self.sifields().sigchld.si_uid + } + + pub unsafe fn si_status(&self) -> c_int { + self.sifields().sigchld.si_status + } + + pub unsafe fn si_utime(&self) -> c_long { + self.sifields().sigchld.si_utime + } + + pub unsafe fn si_stime(&self) -> c_long { + self.sifields().sigchld.si_stime + } +} + +pub const MCL_CURRENT: c_int = 0x0001; +pub const MCL_FUTURE: c_int = 0x0002; +pub const MCL_ONFAULT: c_int = 0x0004; + +pub const SIGEV_THREAD_ID: c_int = 4; + +pub const AF_VSOCK: c_int = 40; + +pub const POSIX_FADV_DONTNEED: c_int = 4; +pub const POSIX_FADV_NOREUSE: c_int = 5; + +// These are different than GNU! +pub const LC_CTYPE: c_int = 0; +pub const LC_NUMERIC: c_int = 1; +pub const LC_TIME: c_int = 3; +pub const LC_COLLATE: c_int = 4; +pub const LC_MONETARY: c_int = 2; +pub const LC_MESSAGES: c_int = 5; +pub const LC_ALL: c_int = 6; +// end different section + +// MS_ flags for mount(2) +pub const MS_RMT_MASK: c_ulong = + crate::MS_RDONLY | crate::MS_SYNCHRONOUS | crate::MS_MANDLOCK | crate::MS_I_VERSION; + +pub const ENOTSUP: c_int = EOPNOTSUPP; + +pub const IPV6_JOIN_GROUP: c_int = 20; +pub const IPV6_LEAVE_GROUP: c_int = 21; + +// Different than Gnu. +pub const FILENAME_MAX: c_uint = 4095; + +pub const PRIO_PROCESS: c_int = 0; +pub const PRIO_PGRP: c_int = 1; +pub const PRIO_USER: c_int = 2; + +pub const SOMAXCONN: c_int = 128; + +pub const ST_RELATIME: c_ulong = 4096; + +pub const SO_TIMESTAMP: c_int = 29; + +pub const RLIM_INFINITY: crate::rlim_t = !0; + +pub const AF_NFC: c_int = PF_NFC; +pub const BUFSIZ: c_int = 256; +pub const EDEADLK: c_int = 0x23; +pub const EDEADLOCK: c_int = EDEADLK; +pub const EXTA: c_uint = B19200; +pub const EXTB: c_uint = B38400; +pub const EXTPROC: crate::tcflag_t = 0o200000; +pub const FOPEN_MAX: c_int = 16; +pub const F_GETOWN: c_int = 9; +pub const F_OFD_GETLK: c_int = 36; +pub const F_OFD_SETLK: c_int = 37; +pub const F_OFD_SETLKW: c_int = 38; +pub const F_RDLCK: c_int = 0; +pub const F_SETOWN: c_int = 8; +pub const F_UNLCK: c_int = 2; +pub const F_WRLCK: c_int = 1; +pub const IPV6_MULTICAST_ALL: c_int = 29; +pub const IPV6_ROUTER_ALERT_ISOLATE: c_int = 30; +pub const MAP_HUGE_SHIFT: c_int = 26; +pub const MAP_HUGE_MASK: c_int = 0x3f; +pub const MSG_COPY: c_int = 0o40000; +pub const NI_MAXHOST: crate::socklen_t = 1025; +pub const O_TMPFILE: c_int = 0o20000000 | O_DIRECTORY; +pub const PACKET_MR_UNICAST: c_int = 3; +pub const PF_NFC: c_int = 39; +pub const PF_VSOCK: c_int = 40; +pub const RTLD_NOLOAD: c_int = 0x00004; +pub const RUSAGE_THREAD: c_int = 1; +pub const SHM_EXEC: c_int = 0o100000; +pub const SOCK_DCCP: c_int = 6; +pub const SOCK_PACKET: c_int = 10; +pub const TCP_COOKIE_TRANSACTIONS: c_int = 15; +pub const UDP_GRO: c_int = 104; +pub const UDP_SEGMENT: c_int = 103; + +pub const PTHREAD_RWLOCK_PREFER_READER_NP: c_int = 0; +pub const PTHREAD_RWLOCK_PREFER_WRITER_NP: c_int = 1; +pub const PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP: c_int = 2; +pub const PTHREAD_RWLOCK_DEFAULT_NP: c_int = PTHREAD_RWLOCK_PREFER_WRITER_NP; + +pub const PTHREAD_MUTEX_TIMED_NP: c_int = 0; +pub const PTHREAD_MUTEX_RECURSIVE_NP: c_int = 1; +pub const PTHREAD_MUTEX_ERRORCHECK_NP: c_int = 2; +pub const PTHREAD_MUTEX_ADAPTIVE_NP: c_int = 3; + +pub const __LT_SPINLOCK_INIT: c_int = 0; + +pub const __LOCK_INITIALIZER: _pthread_fastlock = _pthread_fastlock { + __status: 0, + __spinlock: __LT_SPINLOCK_INIT, +}; + +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + __m_reserved: 0, + __m_count: 0, + __m_owner: core::ptr::null_mut(), + __m_kind: PTHREAD_MUTEX_TIMED_NP, + __m_lock: __LOCK_INITIALIZER, +}; + +const PTHREAD_COND_PADDING_SIZE: usize = 48 + - size_of::<_pthread_fastlock>() + - size_of::<_pthread_descr>() + - size_of::<__pthread_cond_align_t>(); + +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + __c_lock: __LOCK_INITIALIZER, + __c_waiting: core::ptr::null_mut(), + __padding: [0; PTHREAD_COND_PADDING_SIZE], + __align: 0, +}; + +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + __rw_lock: __LOCK_INITIALIZER, + __rw_readers: 0, + __rw_writer: core::ptr::null_mut(), + __rw_read_waiting: core::ptr::null_mut(), + __rw_write_waiting: core::ptr::null_mut(), + __rw_kind: PTHREAD_RWLOCK_DEFAULT_NP, + __rw_pshared: crate::PTHREAD_PROCESS_PRIVATE, +}; + +extern "C" { + pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut crate::timezone) -> c_int; + + pub fn pthread_rwlockattr_getkind_np( + attr: *const crate::pthread_rwlockattr_t, + val: *mut c_int, + ) -> c_int; + pub fn pthread_rwlockattr_setkind_np( + attr: *mut crate::pthread_rwlockattr_t, + val: c_int, + ) -> c_int; + + pub fn openpty( + amaster: *mut c_int, + aslave: *mut c_int, + name: *mut c_char, + termp: *mut termios, + winp: *mut crate::winsize, + ) -> c_int; + + pub fn getnameinfo( + sa: *const crate::sockaddr, + salen: crate::socklen_t, + host: *mut c_char, + hostlen: crate::socklen_t, + serv: *mut c_char, + servlen: crate::socklen_t, + flags: c_int, + ) -> c_int; + + pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off64_t) -> ssize_t; + pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off64_t) -> ssize_t; + + pub fn getrlimit64(resource: crate::__rlimit_resource_t, rlim: *mut crate::rlimit64) -> c_int; + pub fn setrlimit64(resource: crate::__rlimit_resource_t, rlim: *const crate::rlimit64) + -> c_int; + pub fn getrlimit(resource: crate::__rlimit_resource_t, rlim: *mut crate::rlimit) -> c_int; + pub fn setrlimit(resource: crate::__rlimit_resource_t, rlim: *const crate::rlimit) -> c_int; + pub fn getauxval(type_: c_ulong) -> c_ulong; + +} + +cfg_if! { + if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } else if #[cfg(target_arch = "aarch64")] { + mod aarch64; + pub use self::aarch64::*; + } else { + // unsupported target + } +} diff --git a/http/vendor/libc/src/unix/linux_like/l4re/uclibc/x86_64/mod.rs b/http/vendor/libc/src/unix/linux_like/l4re/uclibc/x86_64/mod.rs new file mode 100644 index 0000000..bb4b2ed --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/l4re/uclibc/x86_64/mod.rs @@ -0,0 +1,416 @@ +//! Definitions for uclibc on 64bit systems + +use crate::prelude::*; + +pub type wchar_t = c_int; +pub type time_t = c_long; + +pub type clock_t = c_long; +pub type fsblkcnt_t = c_ulong; +pub type fsfilcnt_t = c_ulong; +pub type ino_t = c_ulong; +pub type nlink_t = c_ulong; +pub type off_t = c_long; +pub type fsword_t = c_long; +pub type suseconds_t = c_long; + +pub type blksize_t = c_long; +pub type blkcnt_t = c_long; + +pub type fsblkcnt64_t = c_ulong; +pub type fsfilcnt64_t = c_ulong; + +pub type __u32 = c_uint; +pub type __u64 = c_ulong; + +s! { + pub struct stat { + pub st_dev: c_ulong, + pub st_ino: crate::ino_t, + // According to uclibc/libc/sysdeps/linux/x86_64/bits/stat.h, order of + // nlink and mode are swapped on 64 bit systems. + pub st_nlink: nlink_t, + pub st_mode: crate::mode_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + __pad0: c_int, + pub st_rdev: c_ulong, + pub st_size: crate::off_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt64_t, + pub st_atim: crate::timespec, + pub st_mtim: crate::timespec, + pub st_ctim: crate::timespec, + __uclibc_unused: [c_long; 3], + } + + pub struct stat64 { + pub st_dev: c_ulong, + pub st_ino: crate::ino_t, + pub st_nlink: nlink_t, + pub st_mode: crate::mode_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + __pad0: c_int, + pub st_rdev: c_ulong, + pub st_size: crate::off_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt64_t, + pub st_atim: crate::timespec, + pub st_mtim: crate::timespec, + pub st_ctim: crate::timespec, + st_pad4: [c_long; 3], + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: crate::size_t, + pub shm_atime: crate::time_t, + pub shm_dtime: crate::time_t, + pub shm_ctime: crate::time_t, + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: crate::shmatt_t, + __unused4: c_ulong, + __unused5: c_ulong, + } + + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigaction { + pub sa_handler: crate::sighandler_t, + pub sa_flags: c_ulong, + pub sa_restorer: Option, + pub sa_mask: sigset_t, + } + + pub struct sigset_t { + __val: [c_ulong; 1], + } + + #[repr(align(8))] + pub struct siginfo_t { + pub si_signo: c_int, + pub si_errno: c_int, + pub si_code: c_int, + pub _pad: [c_int; 28], + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_flags: c_int, + pub ss_size: crate::size_t, + } + + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off_t, + pub l_len: off_t, + pub l_pid: crate::pid_t, + } + + pub struct termios { + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_line: crate::cc_t, + pub c_cc: [crate::cc_t; crate::NCCS], + pub c_ispeed: crate::speed_t, + pub c_ospeed: crate::speed_t, + } +} + +s_no_extra_traits! { + pub union sem_t { + #[cfg(target_pointer_width = "32")] + __size: [c_char; 16], + #[cfg(target_pointer_width = "64")] + __size: [c_char; 32], + __align: [c_long; 0], + } +} + +pub const O_CLOEXEC: c_int = 0o2000000; +pub const __SIZEOF_PTHREAD_ATTR_T: usize = 36; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_COND_T: usize = 48; +pub const __SIZEOF_PTHREAD_COND_COMPAT_T: usize = 12; +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; +pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; +pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; +pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; + +pub const NCCS: usize = 32; + +pub const FIOQSIZE: crate::Ioctl = 0x5460; + +// I wasn't able to find those constants +// in uclibc build environment for armv7 +pub const MAP_HUGETLB: c_int = 0x040000; // from linux/other/mod.rs + +// autogenerated constants with hand tuned types +pub const B0: crate::speed_t = 0; +pub const B1000000: crate::speed_t = 0x1008; +pub const B110: crate::speed_t = 0x3; +pub const B115200: crate::speed_t = 0x1002; +pub const B1152000: crate::speed_t = 0x1009; +pub const B1200: crate::speed_t = 0x9; +pub const B134: crate::speed_t = 0x4; +pub const B150: crate::speed_t = 0x5; +pub const B1500000: crate::speed_t = 0x100a; +pub const B1800: crate::speed_t = 0xa; +pub const B19200: crate::speed_t = 0xe; +pub const B200: crate::speed_t = 0x6; +pub const B2000000: crate::speed_t = 0x100b; +pub const B230400: crate::speed_t = 0x1003; +pub const B2400: crate::speed_t = 0xb; +pub const B2500000: crate::speed_t = 0x100c; +pub const B300: crate::speed_t = 0x7; +pub const B3000000: crate::speed_t = 0x100d; +pub const B3500000: crate::speed_t = 0x100e; +pub const B38400: crate::speed_t = 0xf; +pub const B4000000: crate::speed_t = 0x100f; +pub const B460800: crate::speed_t = 0x1004; +pub const B4800: crate::speed_t = 0xc; +pub const B50: crate::speed_t = 0x1; +pub const B500000: crate::speed_t = 0x1005; +pub const B57600: crate::speed_t = 0x1001; +pub const B576000: crate::speed_t = 0x1006; +pub const B600: crate::speed_t = 0x8; +pub const B75: crate::speed_t = 0x2; +pub const B921600: crate::speed_t = 0x1007; +pub const B9600: crate::speed_t = 0xd; +pub const BS1: c_int = 0x2000; +pub const BSDLY: c_int = 0x2000; +pub const CBAUD: crate::tcflag_t = 0x100f; +pub const CBAUDEX: crate::tcflag_t = 0x1000; +pub const CIBAUD: crate::tcflag_t = 0x100f0000; +pub const CLOCAL: crate::tcflag_t = 0x800; +pub const CPU_SETSIZE: c_int = 0x400; +pub const CR1: c_int = 0x200; +pub const CR2: c_int = 0x400; +pub const CR3: c_int = 0x600; +pub const CRDLY: c_int = 0x600; +pub const CREAD: crate::tcflag_t = 0x80; +pub const CS6: crate::tcflag_t = 0x10; +pub const CS7: crate::tcflag_t = 0x20; +pub const CS8: crate::tcflag_t = 0x30; +pub const CSIZE: crate::tcflag_t = 0x30; +pub const CSTOPB: crate::tcflag_t = 0x40; +pub const EADDRINUSE: c_int = 0x62; +pub const EADDRNOTAVAIL: c_int = 0x63; +pub const EADV: c_int = 0x44; +pub const EAFNOSUPPORT: c_int = 0x61; +pub const EALREADY: c_int = 0x72; +pub const EBADE: c_int = 0x34; +pub const EBADFD: c_int = 0x4d; +pub const EBADMSG: c_int = 0x4a; +pub const EBADR: c_int = 0x35; +pub const EBADRQC: c_int = 0x38; +pub const EBADSLT: c_int = 0x39; +pub const EBFONT: c_int = 0x3b; +pub const ECANCELED: c_int = 0x7d; +pub const ECHOCTL: crate::tcflag_t = 0x200; +pub const ECHOE: crate::tcflag_t = 0x10; +pub const ECHOK: crate::tcflag_t = 0x20; +pub const ECHOKE: crate::tcflag_t = 0x800; +pub const ECHONL: crate::tcflag_t = 0x40; +pub const ECHOPRT: crate::tcflag_t = 0x400; +pub const ECHRNG: c_int = 0x2c; +pub const ECOMM: c_int = 0x46; +pub const ECONNABORTED: c_int = 0x67; +pub const ECONNREFUSED: c_int = 0x6f; +pub const ECONNRESET: c_int = 0x68; +pub const EDESTADDRREQ: c_int = 0x59; +pub const EDOTDOT: c_int = 0x49; +pub const EDQUOT: c_int = 0x7a; +pub const EHOSTDOWN: c_int = 0x70; +pub const EHOSTUNREACH: c_int = 0x71; +pub const EIDRM: c_int = 0x2b; +pub const EILSEQ: c_int = 0x54; +pub const EINPROGRESS: c_int = 0x73; +pub const EISCONN: c_int = 0x6a; +pub const EISNAM: c_int = 0x78; +pub const EKEYEXPIRED: c_int = 0x7f; +pub const EKEYREJECTED: c_int = 0x81; +pub const EKEYREVOKED: c_int = 0x80; +pub const EL2HLT: c_int = 0x33; +pub const EL2NSYNC: c_int = 0x2d; +pub const EL3HLT: c_int = 0x2e; +pub const EL3RST: c_int = 0x2f; +pub const ELIBACC: c_int = 0x4f; +pub const ELIBBAD: c_int = 0x50; +pub const ELIBEXEC: c_int = 0x53; +pub const ELIBMAX: c_int = 0x52; +pub const ELIBSCN: c_int = 0x51; +pub const ELNRNG: c_int = 0x30; +pub const ELOOP: c_int = 0x28; +pub const EMEDIUMTYPE: c_int = 0x7c; +pub const EMSGSIZE: c_int = 0x5a; +pub const EMULTIHOP: c_int = 0x48; +pub const ENAMETOOLONG: c_int = 0x24; +pub const ENAVAIL: c_int = 0x77; +pub const ENETDOWN: c_int = 0x64; +pub const ENETRESET: c_int = 0x66; +pub const ENETUNREACH: c_int = 0x65; +pub const ENOANO: c_int = 0x37; +pub const ENOBUFS: c_int = 0x69; +pub const ENOCSI: c_int = 0x32; +pub const ENODATA: c_int = 0x3d; +pub const ENOKEY: c_int = 0x7e; +pub const ENOLCK: c_int = 0x25; +pub const ENOLINK: c_int = 0x43; +pub const ENOMEDIUM: c_int = 0x7b; +pub const ENOMSG: c_int = 0x2a; +pub const ENONET: c_int = 0x40; +pub const ENOPKG: c_int = 0x41; +pub const ENOPROTOOPT: c_int = 0x5c; +pub const ENOSR: c_int = 0x3f; +pub const ENOSTR: c_int = 0x3c; +pub const ENOSYS: c_int = 0x26; +pub const ENOTCONN: c_int = 0x6b; +pub const ENOTEMPTY: c_int = 0x27; +pub const ENOTNAM: c_int = 0x76; +pub const ENOTRECOVERABLE: c_int = 0x83; +pub const ENOTSOCK: c_int = 0x58; +pub const ENOTUNIQ: c_int = 0x4c; +pub const EOPNOTSUPP: c_int = 0x5f; +pub const EOVERFLOW: c_int = 0x4b; +pub const EOWNERDEAD: c_int = 0x82; +pub const EPFNOSUPPORT: c_int = 0x60; +pub const EPOLL_CLOEXEC: c_int = 0x80000; +pub const EPROTO: c_int = 0x47; +pub const EPROTONOSUPPORT: c_int = 0x5d; +pub const EPROTOTYPE: c_int = 0x5b; +pub const EREMCHG: c_int = 0x4e; +pub const EREMOTE: c_int = 0x42; +pub const EREMOTEIO: c_int = 0x79; +pub const ERESTART: c_int = 0x55; +pub const ESHUTDOWN: c_int = 0x6c; +pub const ESOCKTNOSUPPORT: c_int = 0x5e; +pub const ESRMNT: c_int = 0x45; +pub const ESTALE: c_int = 0x74; +pub const ESTRPIPE: c_int = 0x56; +pub const ETIME: c_int = 0x3e; +pub const ETIMEDOUT: c_int = 0x6e; +pub const ETOOMANYREFS: c_int = 0x6d; +pub const EUCLEAN: c_int = 0x75; +pub const EUNATCH: c_int = 0x31; +pub const EUSERS: c_int = 0x57; +pub const EXFULL: c_int = 0x36; +pub const FF1: c_int = 0x8000; +pub const FFDLY: c_int = 0x8000; +pub const FLUSHO: crate::tcflag_t = 0x1000; +pub const F_GETLK: c_int = 0x5; +pub const F_SETLK: c_int = 0x6; +pub const F_SETLKW: c_int = 0x7; +pub const HUPCL: crate::tcflag_t = 0x400; +pub const ICANON: crate::tcflag_t = 0x2; +pub const IEXTEN: crate::tcflag_t = 0x8000; +pub const ISIG: crate::tcflag_t = 0x1; +pub const IXOFF: crate::tcflag_t = 0x1000; +pub const IXON: crate::tcflag_t = 0x400; +pub const MAP_ANON: c_int = 0x20; +pub const MAP_ANONYMOUS: c_int = 0x20; +pub const MAP_DENYWRITE: c_int = 0x800; +pub const MAP_EXECUTABLE: c_int = 0x1000; +pub const MAP_GROWSDOWN: c_int = 0x100; +pub const MAP_LOCKED: c_int = 0x2000; +pub const MAP_NONBLOCK: c_int = 0x10000; +pub const MAP_NORESERVE: c_int = 0x4000; +pub const MAP_POPULATE: c_int = 0x8000; +pub const MAP_STACK: c_int = 0x20000; +pub const MINSIGSTKSZ: c_int = 2048; +pub const NLDLY: crate::tcflag_t = 0x100; +pub const NOFLSH: crate::tcflag_t = 0x80; +pub const OLCUC: crate::tcflag_t = 0x2; +pub const ONLCR: crate::tcflag_t = 0x4; +pub const O_ACCMODE: c_int = 0x3; +pub const O_APPEND: c_int = 0x400; +pub const O_ASYNC: c_int = 0o20000; +pub const O_CREAT: c_int = 0x40; +pub const O_DIRECT: c_int = 0o40000; +pub const O_DIRECTORY: c_int = 0o200000; +pub const O_DSYNC: c_int = O_SYNC; +pub const O_EXCL: c_int = 0x80; +pub const O_FSYNC: c_int = O_SYNC; +pub const O_LARGEFILE: c_int = 0; +pub const O_NDELAY: c_int = O_NONBLOCK; +pub const O_NOATIME: c_int = 0o1000000; +pub const O_NOCTTY: c_int = 0x100; +pub const O_NOFOLLOW: c_int = 0o400000; +pub const O_NONBLOCK: c_int = 0x800; +pub const O_PATH: c_int = 0o10000000; +pub const O_RSYNC: c_int = O_SYNC; +pub const O_SYNC: c_int = 0o10000; +pub const O_TRUNC: c_int = 0x200; +pub const PARENB: crate::tcflag_t = 0x100; +pub const PARODD: crate::tcflag_t = 0x200; +pub const PENDIN: crate::tcflag_t = 0x4000; +pub const POLLWRBAND: c_short = 0x200; +pub const POLLWRNORM: c_short = 0x100; +pub const RTLD_GLOBAL: c_int = 0x00100; + +// These are typed unsigned to match sigaction +pub const SA_NOCLDSTOP: c_ulong = 0x1; +pub const SA_NOCLDWAIT: c_ulong = 0x2; +pub const SA_SIGINFO: c_ulong = 0x4; +pub const SA_NODEFER: c_ulong = 0x40000000; +pub const SA_ONSTACK: c_ulong = 0x8000000; +pub const SA_RESETHAND: c_ulong = 0x80000000; +pub const SA_RESTART: c_ulong = 0x10000000; + +pub const SIGBUS: c_int = 0x7; +pub const SIGCHLD: c_int = 0x11; +pub const SIGCONT: c_int = 0x12; +pub const SIGIO: c_int = 0x1d; +pub const SIGPOLL: c_int = SIGIO; +pub const SIGPROF: c_int = 0x1b; +pub const SIGPWR: c_int = 0x1e; +pub const SIGSTKFLT: c_int = 0x10; +pub const SIGSTKSZ: c_int = 8192; +pub const SIGSTOP: c_int = 0x13; +pub const SIGSYS: c_int = 0x1f; +pub const SIGTSTP: c_int = 0x14; +pub const SIGTTIN: c_int = 0x15; +pub const SIGTTOU: c_int = 0x16; +pub const SIGURG: c_int = 0x17; +pub const SIGUSR1: c_int = 0xa; +pub const SIGUSR2: c_int = 0xc; +pub const SIGVTALRM: c_int = 0x1a; +pub const SIGWINCH: c_int = 0x1c; +pub const SIGXCPU: c_int = 0x18; +pub const SIGXFSZ: c_int = 0x19; +pub const SIG_BLOCK: c_int = 0; +pub const SIG_UNBLOCK: c_int = 0x1; +pub const SIG_SETMASK: c_int = 0x2; +pub const SOCK_DGRAM: c_int = 0x2; +pub const SOCK_NONBLOCK: c_int = 0o0004000; +pub const SOCK_SEQPACKET: c_int = 0x5; +pub const SOCK_STREAM: c_int = 0x1; +pub const TAB1: c_int = 0x800; +pub const TAB2: c_int = 0x1000; +pub const TAB3: c_int = 0x1800; +pub const TABDLY: c_int = 0x1800; +pub const TCSADRAIN: c_int = 0x1; +pub const TCSAFLUSH: c_int = 0x2; +pub const TCSANOW: c_int = 0; +pub const TOSTOP: crate::tcflag_t = 0x100; +pub const VDISCARD: usize = 0xd; +pub const VEOF: usize = 0x4; +pub const VEOL: usize = 0xb; +pub const VEOL2: usize = 0x10; +pub const VMIN: usize = 0x6; +pub const VREPRINT: usize = 0xc; +pub const VSTART: usize = 0x8; +pub const VSTOP: usize = 0x9; +pub const VSUSP: usize = 0xa; +pub const VSWTC: usize = 0x7; +pub const VT1: c_int = 0x4000; +pub const VTDLY: c_int = 0x4000; +pub const VTIME: usize = 0x5; +pub const VWERASE: usize = 0xe; +pub const XTABS: crate::tcflag_t = 0x1800; diff --git a/http/vendor/libc/src/unix/linux_like/linux/arch/generic/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/arch/generic/mod.rs new file mode 100644 index 0000000..37b7517 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/arch/generic/mod.rs @@ -0,0 +1,336 @@ +use crate::prelude::*; +use crate::Ioctl; + +s! { + pub struct termios2 { + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_line: crate::cc_t, + pub c_cc: [crate::cc_t; 19], + pub c_ispeed: crate::speed_t, + pub c_ospeed: crate::speed_t, + } +} + +// include/uapi/asm-generic/socket.h +// arch/alpha/include/uapi/asm/socket.h +// tools/include/uapi/asm-generic/socket.h +// arch/mips/include/uapi/asm/socket.h +pub const SOL_SOCKET: c_int = 1; + +// Defined in unix/linux_like/mod.rs +// pub const SO_DEBUG: c_int = 1; +pub const SO_REUSEADDR: c_int = 2; +pub const SO_TYPE: c_int = 3; +pub const SO_ERROR: c_int = 4; +pub const SO_DONTROUTE: c_int = 5; +pub const SO_BROADCAST: c_int = 6; +pub const SO_SNDBUF: c_int = 7; +pub const SO_RCVBUF: c_int = 8; +pub const SO_KEEPALIVE: c_int = 9; +pub const SO_OOBINLINE: c_int = 10; +pub const SO_NO_CHECK: c_int = 11; +pub const SO_PRIORITY: c_int = 12; +pub const SO_LINGER: c_int = 13; +pub const SO_BSDCOMPAT: c_int = 14; +pub const SO_REUSEPORT: c_int = 15; +pub const SO_PASSCRED: c_int = 16; +pub const SO_PEERCRED: c_int = 17; +pub const SO_RCVLOWAT: c_int = 18; +pub const SO_SNDLOWAT: c_int = 19; +pub const SO_SECURITY_AUTHENTICATION: c_int = 22; +pub const SO_SECURITY_ENCRYPTION_TRANSPORT: c_int = 23; +pub const SO_SECURITY_ENCRYPTION_NETWORK: c_int = 24; +pub const SO_BINDTODEVICE: c_int = 25; +pub const SO_ATTACH_FILTER: c_int = 26; +pub const SO_DETACH_FILTER: c_int = 27; +pub const SO_GET_FILTER: c_int = SO_ATTACH_FILTER; +pub const SO_PEERNAME: c_int = 28; + +cfg_if! { + if #[cfg(all( + linux_time_bits64, + any(target_arch = "arm", target_arch = "x86"), + not(any(target_env = "musl", target_env = "ohos")) + ))] { + pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_NEW; + pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_NEW; + pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_NEW; + pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_NEW; + pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_NEW; + } else if #[cfg(all( + linux_time_bits64, + any(target_arch = "arm", target_arch = "x86"), + any(target_env = "musl", target_env = "ohos") + ))] { + pub const SO_TIMESTAMP: c_int = 63; + pub const SO_TIMESTAMPNS: c_int = 64; + pub const SO_TIMESTAMPING: c_int = 65; + pub const SO_RCVTIMEO: c_int = 66; + pub const SO_SNDTIMEO: c_int = 67; + } else { + const SO_TIMESTAMP_OLD: c_int = 29; + const SO_TIMESTAMPNS_OLD: c_int = 35; + const SO_TIMESTAMPING_OLD: c_int = 37; + const SO_RCVTIMEO_OLD: c_int = 20; + const SO_SNDTIMEO_OLD: c_int = 21; + + pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_OLD; + pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_OLD; + pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_OLD; + pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_OLD; + pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_OLD; + } +} + +pub const SO_ACCEPTCONN: c_int = 30; +pub const SO_PEERSEC: c_int = 31; +pub const SO_SNDBUFFORCE: c_int = 32; +pub const SO_RCVBUFFORCE: c_int = 33; +pub const SO_PASSSEC: c_int = 34; +pub const SO_MARK: c_int = 36; +pub const SO_PROTOCOL: c_int = 38; +pub const SO_DOMAIN: c_int = 39; +pub const SO_RXQ_OVFL: c_int = 40; +pub const SO_WIFI_STATUS: c_int = 41; +pub const SCM_WIFI_STATUS: c_int = SO_WIFI_STATUS; +pub const SO_PEEK_OFF: c_int = 42; +pub const SO_NOFCS: c_int = 43; +pub const SO_LOCK_FILTER: c_int = 44; +pub const SO_SELECT_ERR_QUEUE: c_int = 45; +pub const SO_BUSY_POLL: c_int = 46; +pub const SO_MAX_PACING_RATE: c_int = 47; +pub const SO_BPF_EXTENSIONS: c_int = 48; +pub const SO_INCOMING_CPU: c_int = 49; +pub const SO_ATTACH_BPF: c_int = 50; +pub const SO_DETACH_BPF: c_int = SO_DETACH_FILTER; +pub const SO_ATTACH_REUSEPORT_CBPF: c_int = 51; +pub const SO_ATTACH_REUSEPORT_EBPF: c_int = 52; +pub const SO_CNX_ADVICE: c_int = 53; +pub const SCM_TIMESTAMPING_OPT_STATS: c_int = 54; +pub const SO_MEMINFO: c_int = 55; +pub const SO_INCOMING_NAPI_ID: c_int = 56; +pub const SO_COOKIE: c_int = 57; +pub const SCM_TIMESTAMPING_PKTINFO: c_int = 58; +pub const SO_PEERGROUPS: c_int = 59; +pub const SO_ZEROCOPY: c_int = 60; +pub const SO_TXTIME: c_int = 61; +pub const SCM_TXTIME: c_int = SO_TXTIME; +pub const SO_BINDTOIFINDEX: c_int = 62; +cfg_if! { + // Some of these platforms in CI already have these constants. + // But they may still not have those _OLD ones. + if #[cfg(all( + any( + target_arch = "x86", + target_arch = "x86_64", + target_arch = "arm", + target_arch = "aarch64", + target_arch = "csky", + target_arch = "loongarch64" + ), + // FIXME(musl): + // Musl hardcodes the SO_* constants instead + // of inheriting them from the kernel headers. + // For new constants you might need consider updating + // musl in the CI as well. + not(any(target_env = "musl", target_env = "ohos")) + ))] { + pub const SO_TIMESTAMP_NEW: c_int = 63; + pub const SO_TIMESTAMPNS_NEW: c_int = 64; + pub const SO_TIMESTAMPING_NEW: c_int = 65; + pub const SO_RCVTIMEO_NEW: c_int = 66; + pub const SO_SNDTIMEO_NEW: c_int = 67; + pub const SO_DETACH_REUSEPORT_BPF: c_int = 68; + } +} +pub const SO_PREFER_BUSY_POLL: c_int = 69; +pub const SO_BUSY_POLL_BUDGET: c_int = 70; +pub const SO_NETNS_COOKIE: c_int = 71; +pub const SO_BUF_LOCK: c_int = 72; +pub const SO_RESERVE_MEM: c_int = 73; +pub const SO_TXREHASH: c_int = 74; +pub const SO_RCVMARK: c_int = 75; +pub const SO_PASSPIDFD: c_int = 76; +pub const SO_PEERPIDFD: c_int = 77; +pub const SO_DEVMEM_LINEAR: c_int = 78; +pub const SO_DEVMEM_DMABUF: c_int = 79; +pub const SO_DEVMEM_DONTNEED: c_int = 80; + +// Defined in unix/linux_like/mod.rs +// pub const SCM_TIMESTAMP: c_int = SO_TIMESTAMP; +pub const SCM_TIMESTAMPNS: c_int = SO_TIMESTAMPNS; +pub const SCM_TIMESTAMPING: c_int = SO_TIMESTAMPING; + +pub const SCM_DEVMEM_LINEAR: c_int = SO_DEVMEM_LINEAR; +pub const SCM_DEVMEM_DMABUF: c_int = SO_DEVMEM_DMABUF; + +// Ioctl Constants + +pub const TCGETS: Ioctl = 0x5401; +pub const TCSETS: Ioctl = 0x5402; +pub const TCSETSW: Ioctl = 0x5403; +pub const TCSETSF: Ioctl = 0x5404; +pub const TCGETA: Ioctl = 0x5405; +pub const TCSETA: Ioctl = 0x5406; +pub const TCSETAW: Ioctl = 0x5407; +pub const TCSETAF: Ioctl = 0x5408; +pub const TCSBRK: Ioctl = 0x5409; +pub const TCXONC: Ioctl = 0x540A; +pub const TCFLSH: Ioctl = 0x540B; +pub const TIOCEXCL: Ioctl = 0x540C; +pub const TIOCNXCL: Ioctl = 0x540D; +pub const TIOCSCTTY: Ioctl = 0x540E; +pub const TIOCGPGRP: Ioctl = 0x540F; +pub const TIOCSPGRP: Ioctl = 0x5410; +pub const TIOCOUTQ: Ioctl = 0x5411; +pub const TIOCSTI: Ioctl = 0x5412; +pub const TIOCGWINSZ: Ioctl = 0x5413; +pub const TIOCSWINSZ: Ioctl = 0x5414; +pub const TIOCMGET: Ioctl = 0x5415; +pub const TIOCMBIS: Ioctl = 0x5416; +pub const TIOCMBIC: Ioctl = 0x5417; +pub const TIOCMSET: Ioctl = 0x5418; +pub const TIOCGSOFTCAR: Ioctl = 0x5419; +pub const TIOCSSOFTCAR: Ioctl = 0x541A; +pub const FIONREAD: Ioctl = 0x541B; +pub const TIOCINQ: Ioctl = FIONREAD; +pub const TIOCLINUX: Ioctl = 0x541C; +pub const TIOCCONS: Ioctl = 0x541D; +pub const TIOCGSERIAL: Ioctl = 0x541E; +pub const TIOCSSERIAL: Ioctl = 0x541F; +pub const TIOCPKT: Ioctl = 0x5420; +pub const FIONBIO: Ioctl = 0x5421; +pub const TIOCNOTTY: Ioctl = 0x5422; +pub const TIOCSETD: Ioctl = 0x5423; +pub const TIOCGETD: Ioctl = 0x5424; +pub const TCSBRKP: Ioctl = 0x5425; +pub const TIOCSBRK: Ioctl = 0x5427; +pub const TIOCCBRK: Ioctl = 0x5428; +pub const TIOCGSID: Ioctl = 0x5429; +pub const TCGETS2: Ioctl = 0x802c542a; +pub const TCSETS2: Ioctl = 0x402c542b; +pub const TCSETSW2: Ioctl = 0x402c542c; +pub const TCSETSF2: Ioctl = 0x402c542d; +pub const TIOCGRS485: Ioctl = 0x542E; +pub const TIOCSRS485: Ioctl = 0x542F; +pub const TIOCGPTN: Ioctl = 0x80045430; +pub const TIOCSPTLCK: Ioctl = 0x40045431; +pub const TIOCGDEV: Ioctl = 0x80045432; +pub const TCGETX: Ioctl = 0x5432; +pub const TCSETX: Ioctl = 0x5433; +pub const TCSETXF: Ioctl = 0x5434; +pub const TCSETXW: Ioctl = 0x5435; +pub const TIOCSIG: Ioctl = 0x40045436; +pub const TIOCVHANGUP: Ioctl = 0x5437; +pub const TIOCGPKT: Ioctl = 0x80045438; +pub const TIOCGPTLCK: Ioctl = 0x80045439; +pub const TIOCGEXCL: Ioctl = 0x80045440; +pub const TIOCGPTPEER: Ioctl = 0x5441; +// pub const TIOCGISO7816: Ioctl = 0x80285442; +// pub const TIOCSISO7816: Ioctl = 0xc0285443; +pub const FIONCLEX: Ioctl = 0x5450; +pub const FIOCLEX: Ioctl = 0x5451; +pub const FIOASYNC: Ioctl = 0x5452; +pub const TIOCSERCONFIG: Ioctl = 0x5453; +pub const TIOCSERGWILD: Ioctl = 0x5454; +pub const TIOCSERSWILD: Ioctl = 0x5455; +pub const TIOCGLCKTRMIOS: Ioctl = 0x5456; +pub const TIOCSLCKTRMIOS: Ioctl = 0x5457; +pub const TIOCSERGSTRUCT: Ioctl = 0x5458; +pub const TIOCSERGETLSR: Ioctl = 0x5459; +pub const TIOCSERGETMULTI: Ioctl = 0x545A; +pub const TIOCSERSETMULTI: Ioctl = 0x545B; +pub const TIOCMIWAIT: Ioctl = 0x545C; +pub const TIOCGICOUNT: Ioctl = 0x545D; +pub const BLKIOMIN: Ioctl = 0x1278; +pub const BLKIOOPT: Ioctl = 0x1279; +pub const BLKSSZGET: Ioctl = 0x1268; +pub const BLKPBSZGET: Ioctl = 0x127B; + +cfg_if! { + if #[cfg(any(target_arch = "arm", target_arch = "s390x"))] { + pub const FIOQSIZE: Ioctl = 0x545E; + } else { + pub const FIOQSIZE: Ioctl = 0x5460; + } +} + +pub const TIOCM_LE: c_int = 0x001; +pub const TIOCM_DTR: c_int = 0x002; +pub const TIOCM_RTS: c_int = 0x004; +pub const TIOCM_ST: c_int = 0x008; +pub const TIOCM_SR: c_int = 0x010; +pub const TIOCM_CTS: c_int = 0x020; +pub const TIOCM_CAR: c_int = 0x040; +pub const TIOCM_CD: c_int = TIOCM_CAR; +pub const TIOCM_RNG: c_int = 0x080; +pub const TIOCM_RI: c_int = TIOCM_RNG; +pub const TIOCM_DSR: c_int = 0x100; + +pub const BOTHER: crate::speed_t = 0o010000; +pub const IBSHIFT: crate::tcflag_t = 16; +pub const IUCLC: crate::tcflag_t = 0o0001000; +pub const XCASE: crate::tcflag_t = 0o0000004; + +// RLIMIT Constants + +cfg_if! { + if #[cfg(any(target_env = "gnu", target_env = "uclibc"))] { + pub const RLIMIT_CPU: crate::__rlimit_resource_t = 0; + pub const RLIMIT_FSIZE: crate::__rlimit_resource_t = 1; + pub const RLIMIT_DATA: crate::__rlimit_resource_t = 2; + pub const RLIMIT_STACK: crate::__rlimit_resource_t = 3; + pub const RLIMIT_CORE: crate::__rlimit_resource_t = 4; + pub const RLIMIT_RSS: crate::__rlimit_resource_t = 5; + pub const RLIMIT_NPROC: crate::__rlimit_resource_t = 6; + pub const RLIMIT_NOFILE: crate::__rlimit_resource_t = 7; + pub const RLIMIT_MEMLOCK: crate::__rlimit_resource_t = 8; + pub const RLIMIT_AS: crate::__rlimit_resource_t = 9; + pub const RLIMIT_LOCKS: crate::__rlimit_resource_t = 10; + pub const RLIMIT_SIGPENDING: crate::__rlimit_resource_t = 11; + pub const RLIMIT_MSGQUEUE: crate::__rlimit_resource_t = 12; + pub const RLIMIT_NICE: crate::__rlimit_resource_t = 13; + pub const RLIMIT_RTPRIO: crate::__rlimit_resource_t = 14; + pub const RLIMIT_RTTIME: crate::__rlimit_resource_t = 15; + #[allow(deprecated)] + #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] + pub const RLIMIT_NLIMITS: crate::__rlimit_resource_t = RLIM_NLIMITS; + } else if #[cfg(any(target_env = "musl", target_env = "ohos"))] { + pub const RLIMIT_CPU: c_int = 0; + pub const RLIMIT_FSIZE: c_int = 1; + pub const RLIMIT_DATA: c_int = 2; + pub const RLIMIT_STACK: c_int = 3; + pub const RLIMIT_CORE: c_int = 4; + pub const RLIMIT_RSS: c_int = 5; + pub const RLIMIT_NPROC: c_int = 6; + pub const RLIMIT_NOFILE: c_int = 7; + pub const RLIMIT_MEMLOCK: c_int = 8; + pub const RLIMIT_AS: c_int = 9; + pub const RLIMIT_LOCKS: c_int = 10; + pub const RLIMIT_SIGPENDING: c_int = 11; + pub const RLIMIT_MSGQUEUE: c_int = 12; + pub const RLIMIT_NICE: c_int = 13; + pub const RLIMIT_RTPRIO: c_int = 14; + pub const RLIMIT_RTTIME: c_int = 15; + #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] + pub const RLIM_NLIMITS: c_int = 16; + #[allow(deprecated)] + #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] + pub const RLIMIT_NLIMITS: c_int = RLIM_NLIMITS; + } +} + +cfg_if! { + if #[cfg(target_env = "gnu")] { + #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] + pub const RLIM_NLIMITS: crate::__rlimit_resource_t = 16; + } else if #[cfg(target_env = "uclibc")] { + #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] + pub const RLIM_NLIMITS: crate::__rlimit_resource_t = 15; + } +} + +pub const RLIM_INFINITY: crate::rlim_t = !0; diff --git a/http/vendor/libc/src/unix/linux_like/linux/arch/mips/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/arch/mips/mod.rs new file mode 100644 index 0000000..78eec0f --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/arch/mips/mod.rs @@ -0,0 +1,335 @@ +use crate::prelude::*; +use crate::Ioctl; + +s! { + pub struct termios2 { + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_line: crate::cc_t, + pub c_cc: [crate::cc_t; 23], + pub c_ispeed: crate::speed_t, + pub c_ospeed: crate::speed_t, + } +} + +// arch/mips/include/uapi/asm/socket.h +pub const SOL_SOCKET: c_int = 0xffff; + +// Defined in unix/linux_like/mod.rs +// pub const SO_DEBUG: c_int = 0x0001; +pub const SO_REUSEADDR: c_int = 0x0004; +pub const SO_KEEPALIVE: c_int = 0x0008; +pub const SO_DONTROUTE: c_int = 0x0010; +pub const SO_BROADCAST: c_int = 0x0020; +pub const SO_LINGER: c_int = 0x0080; +pub const SO_OOBINLINE: c_int = 0x0100; +pub const SO_REUSEPORT: c_int = 0x0200; +pub const SO_TYPE: c_int = 0x1008; +// pub const SO_STYLE: c_int = SO_TYPE; +pub const SO_ERROR: c_int = 0x1007; +pub const SO_SNDBUF: c_int = 0x1001; +pub const SO_RCVBUF: c_int = 0x1002; +pub const SO_SNDLOWAT: c_int = 0x1003; +pub const SO_RCVLOWAT: c_int = 0x1004; +cfg_if! { + if #[cfg(linux_time_bits64)] { + const SO_RCVTIMEO_NEW: c_int = 66; + const SO_SNDTIMEO_NEW: c_int = 67; + + pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_NEW; + pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_NEW; + } else { + const SO_SNDTIMEO_OLD: c_int = 0x1005; + const SO_RCVTIMEO_OLD: c_int = 0x1006; + + pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_OLD; + pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_OLD; + } +} +pub const SO_ACCEPTCONN: c_int = 0x1009; +pub const SO_PROTOCOL: c_int = 0x1028; +pub const SO_DOMAIN: c_int = 0x1029; + +pub const SO_NO_CHECK: c_int = 11; +pub const SO_PRIORITY: c_int = 12; +pub const SO_BSDCOMPAT: c_int = 14; +pub const SO_PASSCRED: c_int = 17; +pub const SO_PEERCRED: c_int = 18; +pub const SO_SECURITY_AUTHENTICATION: c_int = 22; +pub const SO_SECURITY_ENCRYPTION_TRANSPORT: c_int = 23; +pub const SO_SECURITY_ENCRYPTION_NETWORK: c_int = 24; +pub const SO_BINDTODEVICE: c_int = 25; +pub const SO_ATTACH_FILTER: c_int = 26; +pub const SO_DETACH_FILTER: c_int = 27; +pub const SO_GET_FILTER: c_int = SO_ATTACH_FILTER; +pub const SO_PEERNAME: c_int = 28; +pub const SO_PEERSEC: c_int = 30; +pub const SO_SNDBUFFORCE: c_int = 31; +pub const SO_RCVBUFFORCE: c_int = 33; +pub const SO_PASSSEC: c_int = 34; +pub const SO_MARK: c_int = 36; +pub const SO_RXQ_OVFL: c_int = 40; +pub const SO_WIFI_STATUS: c_int = 41; +pub const SCM_WIFI_STATUS: c_int = SO_WIFI_STATUS; +pub const SO_PEEK_OFF: c_int = 42; +pub const SO_NOFCS: c_int = 43; +pub const SO_LOCK_FILTER: c_int = 44; +pub const SO_SELECT_ERR_QUEUE: c_int = 45; +pub const SO_BUSY_POLL: c_int = 46; +pub const SO_MAX_PACING_RATE: c_int = 47; +pub const SO_BPF_EXTENSIONS: c_int = 48; +pub const SO_INCOMING_CPU: c_int = 49; +pub const SO_ATTACH_BPF: c_int = 50; +pub const SO_DETACH_BPF: c_int = SO_DETACH_FILTER; +pub const SO_ATTACH_REUSEPORT_CBPF: c_int = 51; +pub const SO_ATTACH_REUSEPORT_EBPF: c_int = 52; +pub const SO_CNX_ADVICE: c_int = 53; +pub const SCM_TIMESTAMPING_OPT_STATS: c_int = 54; +pub const SO_MEMINFO: c_int = 55; +pub const SO_INCOMING_NAPI_ID: c_int = 56; +pub const SO_COOKIE: c_int = 57; +pub const SCM_TIMESTAMPING_PKTINFO: c_int = 58; +pub const SO_PEERGROUPS: c_int = 59; +pub const SO_ZEROCOPY: c_int = 60; +pub const SO_TXTIME: c_int = 61; +pub const SCM_TXTIME: c_int = SO_TXTIME; +pub const SO_BINDTOIFINDEX: c_int = 62; + +cfg_if! { + if #[cfg(linux_time_bits64)] { + const SO_TIMESTAMP_NEW: c_int = 63; + const SO_TIMESTAMPNS_NEW: c_int = 64; + const SO_TIMESTAMPING_NEW: c_int = 65; + + pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_NEW; + pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_NEW; + pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_NEW; + } else { + const SO_TIMESTAMP_OLD: c_int = 29; + const SO_TIMESTAMPNS_OLD: c_int = 35; + const SO_TIMESTAMPING_OLD: c_int = 37; + + pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_OLD; + pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_OLD; + pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_OLD; + } +} + +// pub const SO_DETACH_REUSEPORT_BPF: c_int = 68; +pub const SO_PREFER_BUSY_POLL: c_int = 69; +pub const SO_BUSY_POLL_BUDGET: c_int = 70; +pub const SO_NETNS_COOKIE: c_int = 71; +pub const SO_BUF_LOCK: c_int = 72; +pub const SO_RESERVE_MEM: c_int = 73; +pub const SO_TXREHASH: c_int = 74; +pub const SO_RCVMARK: c_int = 75; +pub const SO_PASSPIDFD: c_int = 76; +pub const SO_PEERPIDFD: c_int = 77; +pub const SO_DEVMEM_LINEAR: c_int = 78; +pub const SO_DEVMEM_DMABUF: c_int = 79; +pub const SO_DEVMEM_DONTNEED: c_int = 80; + +// Defined in unix/linux_like/mod.rs +// pub const SCM_TIMESTAMP: c_int = SO_TIMESTAMP; +pub const SCM_TIMESTAMPNS: c_int = SO_TIMESTAMPNS; +pub const SCM_TIMESTAMPING: c_int = SO_TIMESTAMPING; + +pub const SCM_DEVMEM_LINEAR: c_int = SO_DEVMEM_LINEAR; +pub const SCM_DEVMEM_DMABUF: c_int = SO_DEVMEM_DMABUF; + +// Ioctl Constants + +pub const TCGETS: Ioctl = 0x540d; +pub const TCSETS: Ioctl = 0x540e; +pub const TCSETSW: Ioctl = 0x540f; +pub const TCSETSF: Ioctl = 0x5410; +pub const TCGETA: Ioctl = 0x5401; +pub const TCSETA: Ioctl = 0x5402; +pub const TCSETAW: Ioctl = 0x5403; +pub const TCSETAF: Ioctl = 0x5404; +pub const TCSBRK: Ioctl = 0x5405; +pub const TCXONC: Ioctl = 0x5406; +pub const TCFLSH: Ioctl = 0x5407; +pub const TIOCEXCL: Ioctl = 0x740d; +pub const TIOCNXCL: Ioctl = 0x740e; +pub const TIOCSCTTY: Ioctl = 0x5480; +pub const TIOCGPGRP: Ioctl = 0x40047477; +pub const TIOCSPGRP: Ioctl = 0x80047476; +pub const TIOCOUTQ: Ioctl = 0x7472; +pub const TIOCSTI: Ioctl = 0x5472; +pub const TIOCGWINSZ: Ioctl = 0x40087468; +pub const TIOCSWINSZ: Ioctl = 0x80087467; +pub const TIOCMGET: Ioctl = 0x741d; +pub const TIOCMBIS: Ioctl = 0x741b; +pub const TIOCMBIC: Ioctl = 0x741c; +pub const TIOCMSET: Ioctl = 0x741a; +pub const TIOCGSOFTCAR: Ioctl = 0x5481; +pub const TIOCSSOFTCAR: Ioctl = 0x5482; +pub const FIONREAD: Ioctl = 0x467f; +pub const TIOCINQ: Ioctl = FIONREAD; +pub const TIOCLINUX: Ioctl = 0x5483; +pub const TIOCCONS: Ioctl = 0x80047478; +pub const TIOCGSERIAL: Ioctl = 0x5484; +pub const TIOCSSERIAL: Ioctl = 0x5485; +pub const TIOCPKT: Ioctl = 0x5470; +pub const FIONBIO: Ioctl = 0x667e; +pub const TIOCNOTTY: Ioctl = 0x5471; +pub const TIOCSETD: Ioctl = 0x7401; +pub const TIOCGETD: Ioctl = 0x7400; +pub const TCSBRKP: Ioctl = 0x5486; +pub const TIOCSBRK: Ioctl = 0x5427; +pub const TIOCCBRK: Ioctl = 0x5428; +pub const TIOCGSID: Ioctl = 0x7416; +pub const TCGETS2: Ioctl = 0x4030542a; +pub const TCSETS2: Ioctl = 0x8030542b; +pub const TCSETSW2: Ioctl = 0x8030542c; +pub const TCSETSF2: Ioctl = 0x8030542d; +pub const TIOCGPTN: Ioctl = 0x40045430; +pub const TIOCSPTLCK: Ioctl = 0x80045431; +pub const TIOCGDEV: Ioctl = 0x40045432; +pub const TIOCSIG: Ioctl = 0x80045436; +pub const TIOCVHANGUP: Ioctl = 0x5437; +pub const TIOCGPKT: Ioctl = 0x40045438; +pub const TIOCGPTLCK: Ioctl = 0x40045439; +pub const TIOCGEXCL: Ioctl = 0x40045440; +pub const TIOCGPTPEER: Ioctl = 0x20005441; +//pub const TIOCGISO7816: Ioctl = 0x40285442; +//pub const TIOCSISO7816: Ioctl = 0xc0285443; +pub const FIONCLEX: Ioctl = 0x6602; +pub const FIOCLEX: Ioctl = 0x6601; +pub const FIOASYNC: Ioctl = 0x667d; +pub const TIOCSERCONFIG: Ioctl = 0x5488; +pub const TIOCSERGWILD: Ioctl = 0x5489; +pub const TIOCSERSWILD: Ioctl = 0x548a; +pub const TIOCGLCKTRMIOS: Ioctl = 0x548b; +pub const TIOCSLCKTRMIOS: Ioctl = 0x548c; +pub const TIOCSERGSTRUCT: Ioctl = 0x548d; +pub const TIOCSERGETLSR: Ioctl = 0x548e; +pub const TIOCSERGETMULTI: Ioctl = 0x548f; +pub const TIOCSERSETMULTI: Ioctl = 0x5490; +pub const TIOCMIWAIT: Ioctl = 0x5491; +pub const TIOCGICOUNT: Ioctl = 0x5492; +pub const FIOQSIZE: Ioctl = 0x667f; +pub const TIOCSLTC: Ioctl = 0x7475; +pub const TIOCGETP: Ioctl = 0x7408; +pub const TIOCSETP: Ioctl = 0x7409; +pub const TIOCSETN: Ioctl = 0x740a; +pub const BLKIOMIN: Ioctl = 0x20001278; +pub const BLKIOOPT: Ioctl = 0x20001279; +pub const BLKSSZGET: Ioctl = 0x20001268; +pub const BLKPBSZGET: Ioctl = 0x2000127B; + +cfg_if! { + if #[cfg(target_env = "musl")] { + pub const TIOCGRS485: Ioctl = 0x4020542e; + pub const TIOCSRS485: Ioctl = 0xc020542f; + } +} + +pub const TIOCM_LE: c_int = 0x001; +pub const TIOCM_DTR: c_int = 0x002; +pub const TIOCM_RTS: c_int = 0x004; +pub const TIOCM_ST: c_int = 0x010; +pub const TIOCM_SR: c_int = 0x020; +pub const TIOCM_CTS: c_int = 0x040; +pub const TIOCM_CAR: c_int = 0x100; +pub const TIOCM_CD: c_int = TIOCM_CAR; +pub const TIOCM_RNG: c_int = 0x200; +pub const TIOCM_RI: c_int = TIOCM_RNG; +pub const TIOCM_DSR: c_int = 0x400; + +pub const BOTHER: crate::speed_t = 0o010000; +pub const IBSHIFT: crate::tcflag_t = 16; +pub const IUCLC: crate::tcflag_t = 0o0001000; +pub const XCASE: crate::tcflag_t = 0o0000004; + +// RLIMIT Constants + +cfg_if! { + if #[cfg(any(target_env = "gnu", target_env = "uclibc"))] { + pub const RLIMIT_CPU: crate::__rlimit_resource_t = 0; + pub const RLIMIT_FSIZE: crate::__rlimit_resource_t = 1; + pub const RLIMIT_DATA: crate::__rlimit_resource_t = 2; + pub const RLIMIT_STACK: crate::__rlimit_resource_t = 3; + pub const RLIMIT_CORE: crate::__rlimit_resource_t = 4; + pub const RLIMIT_NOFILE: crate::__rlimit_resource_t = 5; + pub const RLIMIT_AS: crate::__rlimit_resource_t = 6; + pub const RLIMIT_RSS: crate::__rlimit_resource_t = 7; + pub const RLIMIT_NPROC: crate::__rlimit_resource_t = 8; + pub const RLIMIT_MEMLOCK: crate::__rlimit_resource_t = 9; + pub const RLIMIT_LOCKS: crate::__rlimit_resource_t = 10; + pub const RLIMIT_SIGPENDING: crate::__rlimit_resource_t = 11; + pub const RLIMIT_MSGQUEUE: crate::__rlimit_resource_t = 12; + pub const RLIMIT_NICE: crate::__rlimit_resource_t = 13; + pub const RLIMIT_RTPRIO: crate::__rlimit_resource_t = 14; + pub const RLIMIT_RTTIME: crate::__rlimit_resource_t = 15; + #[allow(deprecated)] + #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] + pub const RLIMIT_NLIMITS: crate::__rlimit_resource_t = RLIM_NLIMITS; + } else if #[cfg(target_env = "musl")] { + pub const RLIMIT_CPU: c_int = 0; + pub const RLIMIT_FSIZE: c_int = 1; + pub const RLIMIT_DATA: c_int = 2; + pub const RLIMIT_STACK: c_int = 3; + pub const RLIMIT_CORE: c_int = 4; + pub const RLIMIT_NOFILE: c_int = 5; + pub const RLIMIT_AS: c_int = 6; + pub const RLIMIT_RSS: c_int = 7; + pub const RLIMIT_NPROC: c_int = 8; + pub const RLIMIT_MEMLOCK: c_int = 9; + pub const RLIMIT_LOCKS: c_int = 10; + pub const RLIMIT_SIGPENDING: c_int = 11; + pub const RLIMIT_MSGQUEUE: c_int = 12; + pub const RLIMIT_NICE: c_int = 13; + pub const RLIMIT_RTPRIO: c_int = 14; + pub const RLIMIT_RTTIME: c_int = 15; + #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] + pub const RLIM_NLIMITS: c_int = 16; + #[allow(deprecated)] + #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] + pub const RLIMIT_NLIMITS: c_int = RLIM_NLIMITS; + pub const RLIM_INFINITY: crate::rlim_t = !0; + } +} + +cfg_if! { + if #[cfg(target_env = "gnu")] { + #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] + pub const RLIM_NLIMITS: crate::__rlimit_resource_t = 16; + } else if #[cfg(target_env = "uclibc")] { + #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] + pub const RLIM_NLIMITS: crate::__rlimit_resource_t = 15; + } +} + +cfg_if! { + if #[cfg( + any(target_arch = "mips64", target_arch = "mips64r6"), + any(target_env = "gnu", target_env = "uclibc") + )] { + pub const RLIM_INFINITY: crate::rlim_t = !0; + } +} + +cfg_if! { + if #[cfg(all( + any(target_arch = "mips", target_arch = "mips32r6"), + any( + all(target_env = "uclibc", linux_time_bits64), + all( + target_env = "gnu", + any(linux_time_bits64, gnu_file_offset_bits64) + ) + ) + ))] { + pub const RLIM_INFINITY: crate::rlim_t = !0; + } else if #[cfg(all( + any(target_arch = "mips", target_arch = "mips32r6"), + any(target_env = "uclibc", target_env = "gnu"), + not(linux_time_bits64) + ))] { + pub const RLIM_INFINITY: crate::rlim_t = 0x7fffffff; + } +} diff --git a/http/vendor/libc/src/unix/linux_like/linux/arch/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/arch/mod.rs new file mode 100644 index 0000000..00914a4 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/arch/mod.rs @@ -0,0 +1,20 @@ +cfg_if! { + if #[cfg(any( + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "mips64", + target_arch = "mips64r6" + ))] { + mod mips; + pub use self::mips::*; + } else if #[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))] { + mod powerpc; + pub use self::powerpc::*; + } else if #[cfg(any(target_arch = "sparc", target_arch = "sparc64"))] { + mod sparc; + pub use self::sparc::*; + } else { + mod generic; + pub use self::generic::*; + } +} diff --git a/http/vendor/libc/src/unix/linux_like/linux/arch/powerpc/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/arch/powerpc/mod.rs new file mode 100644 index 0000000..b5a3557 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/arch/powerpc/mod.rs @@ -0,0 +1,282 @@ +use crate::prelude::*; +use crate::Ioctl; + +// arch/powerpc/include/uapi/asm/socket.h + +pub const SOL_SOCKET: c_int = 1; + +// Defined in unix/linux_like/mod.rs +// pub const SO_DEBUG: c_int = 1; +pub const SO_REUSEADDR: c_int = 2; +pub const SO_TYPE: c_int = 3; +pub const SO_ERROR: c_int = 4; +pub const SO_DONTROUTE: c_int = 5; +pub const SO_BROADCAST: c_int = 6; +pub const SO_SNDBUF: c_int = 7; +pub const SO_RCVBUF: c_int = 8; +pub const SO_KEEPALIVE: c_int = 9; +pub const SO_OOBINLINE: c_int = 10; +pub const SO_NO_CHECK: c_int = 11; +pub const SO_PRIORITY: c_int = 12; +pub const SO_LINGER: c_int = 13; +pub const SO_BSDCOMPAT: c_int = 14; +pub const SO_REUSEPORT: c_int = 15; +// powerpc only differs in these +pub const SO_RCVLOWAT: c_int = 16; +pub const SO_SNDLOWAT: c_int = 17; + +cfg_if! { + if #[cfg(linux_time_bits64)] { + const SO_RCVTIMEO_NEW: c_int = 66; + const SO_SNDTIMEO_NEW: c_int = 67; + + pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_NEW; + pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_NEW; + } else { + const SO_RCVTIMEO_OLD: c_int = 18; + const SO_SNDTIMEO_OLD: c_int = 19; + + pub const SO_RCVTIMEO: c_int = SO_RCVTIMEO_OLD; + pub const SO_SNDTIMEO: c_int = SO_SNDTIMEO_OLD; + } +} + +pub const SO_PASSCRED: c_int = 20; +pub const SO_PEERCRED: c_int = 21; +// end +pub const SO_SECURITY_AUTHENTICATION: c_int = 22; +pub const SO_SECURITY_ENCRYPTION_TRANSPORT: c_int = 23; +pub const SO_SECURITY_ENCRYPTION_NETWORK: c_int = 24; +pub const SO_BINDTODEVICE: c_int = 25; +pub const SO_ATTACH_FILTER: c_int = 26; +pub const SO_DETACH_FILTER: c_int = 27; +pub const SO_GET_FILTER: c_int = SO_ATTACH_FILTER; +pub const SO_PEERNAME: c_int = 28; +cfg_if! { + if #[cfg(linux_time_bits64)] { + const SO_TIMESTAMP_NEW: c_int = 63; + const SO_TIMESTAMPNS_NEW: c_int = 64; + const SO_TIMESTAMPING_NEW: c_int = 65; + + pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_NEW; + pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_NEW; + pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_NEW; + } else { + const SO_TIMESTAMP_OLD: c_int = 29; + const SO_TIMESTAMPNS_OLD: c_int = 35; + const SO_TIMESTAMPING_OLD: c_int = 37; + + pub const SO_TIMESTAMP: c_int = SO_TIMESTAMP_OLD; + pub const SO_TIMESTAMPNS: c_int = SO_TIMESTAMPNS_OLD; + pub const SO_TIMESTAMPING: c_int = SO_TIMESTAMPING_OLD; + } +} +pub const SO_ACCEPTCONN: c_int = 30; +pub const SO_PEERSEC: c_int = 31; +pub const SO_SNDBUFFORCE: c_int = 32; +pub const SO_RCVBUFFORCE: c_int = 33; +pub const SO_PASSSEC: c_int = 34; +pub const SO_MARK: c_int = 36; +pub const SO_PROTOCOL: c_int = 38; +pub const SO_DOMAIN: c_int = 39; +pub const SO_RXQ_OVFL: c_int = 40; +pub const SO_WIFI_STATUS: c_int = 41; +pub const SCM_WIFI_STATUS: c_int = SO_WIFI_STATUS; +pub const SO_PEEK_OFF: c_int = 42; +pub const SO_NOFCS: c_int = 43; +pub const SO_LOCK_FILTER: c_int = 44; +pub const SO_SELECT_ERR_QUEUE: c_int = 45; +pub const SO_BUSY_POLL: c_int = 46; +pub const SO_MAX_PACING_RATE: c_int = 47; +pub const SO_BPF_EXTENSIONS: c_int = 48; +pub const SO_INCOMING_CPU: c_int = 49; +pub const SO_ATTACH_BPF: c_int = 50; +pub const SO_DETACH_BPF: c_int = SO_DETACH_FILTER; +pub const SO_ATTACH_REUSEPORT_CBPF: c_int = 51; +pub const SO_ATTACH_REUSEPORT_EBPF: c_int = 52; +pub const SO_CNX_ADVICE: c_int = 53; +pub const SCM_TIMESTAMPING_OPT_STATS: c_int = 54; +pub const SO_MEMINFO: c_int = 55; +pub const SO_INCOMING_NAPI_ID: c_int = 56; +pub const SO_COOKIE: c_int = 57; +pub const SCM_TIMESTAMPING_PKTINFO: c_int = 58; +pub const SO_PEERGROUPS: c_int = 59; +pub const SO_ZEROCOPY: c_int = 60; +pub const SO_TXTIME: c_int = 61; +pub const SCM_TXTIME: c_int = SO_TXTIME; +pub const SO_BINDTOIFINDEX: c_int = 62; +// pub const SO_DETACH_REUSEPORT_BPF: c_int = 68; +pub const SO_PREFER_BUSY_POLL: c_int = 69; +pub const SO_BUSY_POLL_BUDGET: c_int = 70; +pub const SO_NETNS_COOKIE: c_int = 71; +pub const SO_BUF_LOCK: c_int = 72; +pub const SO_RESERVE_MEM: c_int = 73; +pub const SO_TXREHASH: c_int = 74; +pub const SO_RCVMARK: c_int = 75; +pub const SO_PASSPIDFD: c_int = 76; +pub const SO_PEERPIDFD: c_int = 77; +pub const SO_DEVMEM_LINEAR: c_int = 78; +pub const SO_DEVMEM_DMABUF: c_int = 79; +pub const SO_DEVMEM_DONTNEED: c_int = 80; + +// Defined in unix/linux_like/mod.rs +// pub const SCM_TIMESTAMP: c_int = SO_TIMESTAMP; +pub const SCM_TIMESTAMPNS: c_int = SO_TIMESTAMPNS; +pub const SCM_TIMESTAMPING: c_int = SO_TIMESTAMPING; + +pub const SCM_DEVMEM_LINEAR: c_int = SO_DEVMEM_LINEAR; +pub const SCM_DEVMEM_DMABUF: c_int = SO_DEVMEM_DMABUF; + +// Ioctl Constants + +cfg_if! { + if #[cfg(target_env = "gnu")] { + pub const TCGETS: Ioctl = 0x403c7413; + pub const TCSETS: Ioctl = 0x803c7414; + pub const TCSETSW: Ioctl = 0x803c7415; + pub const TCSETSF: Ioctl = 0x803c7416; + } else if #[cfg(target_env = "musl")] { + pub const TCGETS: Ioctl = 0x402c7413; + pub const TCSETS: Ioctl = 0x802c7414; + pub const TCSETSW: Ioctl = 0x802c7415; + pub const TCSETSF: Ioctl = 0x802c7416; + } +} + +pub const TCGETA: Ioctl = 0x40147417; +pub const TCSETA: Ioctl = 0x80147418; +pub const TCSETAW: Ioctl = 0x80147419; +pub const TCSETAF: Ioctl = 0x8014741C; +pub const TCSBRK: Ioctl = 0x2000741D; +pub const TCXONC: Ioctl = 0x2000741E; +pub const TCFLSH: Ioctl = 0x2000741F; +pub const TIOCEXCL: Ioctl = 0x540C; +pub const TIOCNXCL: Ioctl = 0x540D; +pub const TIOCSCTTY: Ioctl = 0x540E; +pub const TIOCGPGRP: Ioctl = 0x40047477; +pub const TIOCSPGRP: Ioctl = 0x80047476; +pub const TIOCOUTQ: Ioctl = 0x40047473; +pub const TIOCSTI: Ioctl = 0x5412; +pub const TIOCGWINSZ: Ioctl = 0x40087468; +pub const TIOCSWINSZ: Ioctl = 0x80087467; +pub const TIOCMGET: Ioctl = 0x5415; +pub const TIOCMBIS: Ioctl = 0x5416; +pub const TIOCMBIC: Ioctl = 0x5417; +pub const TIOCMSET: Ioctl = 0x5418; +pub const TIOCGSOFTCAR: Ioctl = 0x5419; +pub const TIOCSSOFTCAR: Ioctl = 0x541A; +pub const FIONREAD: Ioctl = 0x4004667F; +pub const TIOCINQ: Ioctl = FIONREAD; +pub const TIOCLINUX: Ioctl = 0x541C; +pub const TIOCCONS: Ioctl = 0x541D; +pub const TIOCGSERIAL: Ioctl = 0x541E; +pub const TIOCSSERIAL: Ioctl = 0x541F; +pub const TIOCPKT: Ioctl = 0x5420; +pub const FIONBIO: Ioctl = 0x8004667e; +pub const TIOCNOTTY: Ioctl = 0x5422; +pub const TIOCSETD: Ioctl = 0x5423; +pub const TIOCGETD: Ioctl = 0x5424; +pub const TCSBRKP: Ioctl = 0x5425; +pub const TIOCSBRK: Ioctl = 0x5427; +pub const TIOCCBRK: Ioctl = 0x5428; +pub const TIOCGSID: Ioctl = 0x5429; +pub const TIOCGRS485: Ioctl = 0x542e; +pub const TIOCSRS485: Ioctl = 0x542f; +pub const TIOCGPTN: Ioctl = 0x40045430; +pub const TIOCSPTLCK: Ioctl = 0x80045431; +pub const TIOCGDEV: Ioctl = 0x40045432; +pub const TIOCSIG: Ioctl = 0x80045436; +pub const TIOCVHANGUP: Ioctl = 0x5437; +pub const TIOCGPKT: Ioctl = 0x40045438; +pub const TIOCGPTLCK: Ioctl = 0x40045439; +pub const TIOCGEXCL: Ioctl = 0x40045440; +pub const TIOCGPTPEER: Ioctl = 0x20005441; +//pub const TIOCGISO7816: Ioctl = 0x40285442; +//pub const TIOCSISO7816: Ioctl = 0xc0285443; +pub const FIONCLEX: Ioctl = 0x20006602; +pub const FIOCLEX: Ioctl = 0x20006601; +pub const FIOASYNC: Ioctl = 0x8004667d; +pub const TIOCSERCONFIG: Ioctl = 0x5453; +pub const TIOCSERGWILD: Ioctl = 0x5454; +pub const TIOCSERSWILD: Ioctl = 0x5455; +pub const TIOCGLCKTRMIOS: Ioctl = 0x5456; +pub const TIOCSLCKTRMIOS: Ioctl = 0x5457; +pub const TIOCSERGSTRUCT: Ioctl = 0x5458; +pub const TIOCSERGETLSR: Ioctl = 0x5459; +pub const TIOCSERGETMULTI: Ioctl = 0x545A; +pub const TIOCSERSETMULTI: Ioctl = 0x545B; +pub const TIOCMIWAIT: Ioctl = 0x545C; +pub const TIOCGICOUNT: Ioctl = 0x545D; +pub const BLKIOMIN: Ioctl = 0x20001278; +pub const BLKIOOPT: Ioctl = 0x20001279; +pub const BLKSSZGET: Ioctl = 0x20001268; +pub const BLKPBSZGET: Ioctl = 0x2000127B; +//pub const FIOQSIZE: Ioctl = 0x40086680; + +pub const TIOCM_LE: c_int = 0x001; +pub const TIOCM_DTR: c_int = 0x002; +pub const TIOCM_RTS: c_int = 0x004; +pub const TIOCM_ST: c_int = 0x008; +pub const TIOCM_SR: c_int = 0x010; +pub const TIOCM_CTS: c_int = 0x020; +pub const TIOCM_CAR: c_int = 0x040; +pub const TIOCM_CD: c_int = TIOCM_CAR; +pub const TIOCM_RNG: c_int = 0x080; +pub const TIOCM_RI: c_int = TIOCM_RNG; +pub const TIOCM_DSR: c_int = 0x100; + +pub const BOTHER: crate::speed_t = 0o0037; +pub const IBSHIFT: crate::tcflag_t = 16; +pub const IUCLC: crate::tcflag_t = 0o0010000; +pub const XCASE: crate::tcflag_t = 0o0040000; + +// RLIMIT Constants + +cfg_if! { + if #[cfg(target_env = "gnu")] { + pub const RLIMIT_CPU: crate::__rlimit_resource_t = 0; + pub const RLIMIT_FSIZE: crate::__rlimit_resource_t = 1; + pub const RLIMIT_DATA: crate::__rlimit_resource_t = 2; + pub const RLIMIT_STACK: crate::__rlimit_resource_t = 3; + pub const RLIMIT_CORE: crate::__rlimit_resource_t = 4; + pub const RLIMIT_RSS: crate::__rlimit_resource_t = 5; + pub const RLIMIT_NPROC: crate::__rlimit_resource_t = 6; + pub const RLIMIT_NOFILE: crate::__rlimit_resource_t = 7; + pub const RLIMIT_MEMLOCK: crate::__rlimit_resource_t = 8; + pub const RLIMIT_AS: crate::__rlimit_resource_t = 9; + pub const RLIMIT_LOCKS: crate::__rlimit_resource_t = 10; + pub const RLIMIT_SIGPENDING: crate::__rlimit_resource_t = 11; + pub const RLIMIT_MSGQUEUE: crate::__rlimit_resource_t = 12; + pub const RLIMIT_NICE: crate::__rlimit_resource_t = 13; + pub const RLIMIT_RTPRIO: crate::__rlimit_resource_t = 14; + pub const RLIMIT_RTTIME: crate::__rlimit_resource_t = 15; + #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] + pub const RLIM_NLIMITS: crate::__rlimit_resource_t = 16; + #[allow(deprecated)] + #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] + pub const RLIMIT_NLIMITS: crate::__rlimit_resource_t = RLIM_NLIMITS; + } else if #[cfg(target_env = "musl")] { + pub const RLIMIT_CPU: c_int = 0; + pub const RLIMIT_FSIZE: c_int = 1; + pub const RLIMIT_DATA: c_int = 2; + pub const RLIMIT_STACK: c_int = 3; + pub const RLIMIT_CORE: c_int = 4; + pub const RLIMIT_RSS: c_int = 5; + pub const RLIMIT_NPROC: c_int = 6; + pub const RLIMIT_NOFILE: c_int = 7; + pub const RLIMIT_MEMLOCK: c_int = 8; + pub const RLIMIT_AS: c_int = 9; + pub const RLIMIT_LOCKS: c_int = 10; + pub const RLIMIT_SIGPENDING: c_int = 11; + pub const RLIMIT_MSGQUEUE: c_int = 12; + pub const RLIMIT_NICE: c_int = 13; + pub const RLIMIT_RTPRIO: c_int = 14; + pub const RLIMIT_RTTIME: c_int = 15; + #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] + pub const RLIM_NLIMITS: c_int = 16; + #[allow(deprecated)] + #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] + pub const RLIMIT_NLIMITS: c_int = RLIM_NLIMITS; + } +} +pub const RLIM_INFINITY: crate::rlim_t = !0; diff --git a/http/vendor/libc/src/unix/linux_like/linux/arch/sparc/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/arch/sparc/mod.rs new file mode 100644 index 0000000..006156e --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/arch/sparc/mod.rs @@ -0,0 +1,249 @@ +use crate::prelude::*; +use crate::Ioctl; + +s! { + pub struct termios2 { + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_line: crate::cc_t, + pub c_cc: [crate::cc_t; 19], + pub c_ispeed: crate::speed_t, + pub c_ospeed: crate::speed_t, + } +} + +// arch/sparc/include/uapi/asm/socket.h +pub const SOL_SOCKET: c_int = 0xffff; + +// Defined in unix/linux_like/mod.rs +// pub const SO_DEBUG: c_int = 0x0001; +pub const SO_PASSCRED: c_int = 0x0002; +pub const SO_REUSEADDR: c_int = 0x0004; +pub const SO_KEEPALIVE: c_int = 0x0008; +pub const SO_DONTROUTE: c_int = 0x0010; +pub const SO_BROADCAST: c_int = 0x0020; +pub const SO_PEERCRED: c_int = 0x0040; +pub const SO_LINGER: c_int = 0x0080; +pub const SO_OOBINLINE: c_int = 0x0100; +pub const SO_REUSEPORT: c_int = 0x0200; +pub const SO_BSDCOMPAT: c_int = 0x0400; +pub const SO_RCVLOWAT: c_int = 0x0800; +pub const SO_SNDLOWAT: c_int = 0x1000; +pub const SO_RCVTIMEO: c_int = 0x2000; +pub const SO_SNDTIMEO: c_int = 0x4000; +// pub const SO_RCVTIMEO_OLD: c_int = 0x2000; +// pub const SO_SNDTIMEO_OLD: c_int = 0x4000; +pub const SO_ACCEPTCONN: c_int = 0x8000; +pub const SO_SNDBUF: c_int = 0x1001; +pub const SO_RCVBUF: c_int = 0x1002; +pub const SO_SNDBUFFORCE: c_int = 0x100a; +pub const SO_RCVBUFFORCE: c_int = 0x100b; +pub const SO_ERROR: c_int = 0x1007; +pub const SO_TYPE: c_int = 0x1008; +pub const SO_PROTOCOL: c_int = 0x1028; +pub const SO_DOMAIN: c_int = 0x1029; +pub const SO_NO_CHECK: c_int = 0x000b; +pub const SO_PRIORITY: c_int = 0x000c; +pub const SO_BINDTODEVICE: c_int = 0x000d; +pub const SO_ATTACH_FILTER: c_int = 0x001a; +pub const SO_DETACH_FILTER: c_int = 0x001b; +pub const SO_GET_FILTER: c_int = SO_ATTACH_FILTER; +pub const SO_PEERNAME: c_int = 0x001c; +pub const SO_PEERSEC: c_int = 0x001e; +pub const SO_PASSSEC: c_int = 0x001f; +pub const SO_MARK: c_int = 0x0022; +pub const SO_RXQ_OVFL: c_int = 0x0024; +pub const SO_WIFI_STATUS: c_int = 0x0025; +pub const SCM_WIFI_STATUS: c_int = SO_WIFI_STATUS; +pub const SO_PEEK_OFF: c_int = 0x0026; +pub const SO_NOFCS: c_int = 0x0027; +pub const SO_LOCK_FILTER: c_int = 0x0028; +pub const SO_SELECT_ERR_QUEUE: c_int = 0x0029; +pub const SO_BUSY_POLL: c_int = 0x0030; +pub const SO_MAX_PACING_RATE: c_int = 0x0031; +pub const SO_BPF_EXTENSIONS: c_int = 0x0032; +pub const SO_INCOMING_CPU: c_int = 0x0033; +pub const SO_ATTACH_BPF: c_int = 0x0034; +pub const SO_DETACH_BPF: c_int = SO_DETACH_FILTER; +pub const SO_ATTACH_REUSEPORT_CBPF: c_int = 0x0035; +pub const SO_ATTACH_REUSEPORT_EBPF: c_int = 0x0036; +pub const SO_CNX_ADVICE: c_int = 0x0037; +pub const SCM_TIMESTAMPING_OPT_STATS: c_int = 0x0038; +pub const SO_MEMINFO: c_int = 0x0039; +pub const SO_INCOMING_NAPI_ID: c_int = 0x003a; +pub const SO_COOKIE: c_int = 0x003b; +pub const SCM_TIMESTAMPING_PKTINFO: c_int = 0x003c; +pub const SO_PEERGROUPS: c_int = 0x003d; +pub const SO_ZEROCOPY: c_int = 0x003e; +pub const SO_TXTIME: c_int = 0x003f; +pub const SCM_TXTIME: c_int = SO_TXTIME; +pub const SO_BINDTOIFINDEX: c_int = 0x0041; +pub const SO_SECURITY_AUTHENTICATION: c_int = 0x5001; +pub const SO_SECURITY_ENCRYPTION_TRANSPORT: c_int = 0x5002; +pub const SO_SECURITY_ENCRYPTION_NETWORK: c_int = 0x5004; +pub const SO_TIMESTAMP: c_int = 0x001d; +pub const SO_TIMESTAMPNS: c_int = 0x0021; +pub const SO_TIMESTAMPING: c_int = 0x0023; +// pub const SO_TIMESTAMP_OLD: c_int = 0x001d; +// pub const SO_TIMESTAMPNS_OLD: c_int = 0x0021; +// pub const SO_TIMESTAMPING_OLD: c_int = 0x0023; +// pub const SO_TIMESTAMP_NEW: c_int = 0x0046; +// pub const SO_TIMESTAMPNS_NEW: c_int = 0x0042; +// pub const SO_TIMESTAMPING_NEW: c_int = 0x0043; +// pub const SO_RCVTIMEO_NEW: c_int = 0x0044; +// pub const SO_SNDTIMEO_NEW: c_int = 0x0045; +// pub const SO_DETACH_REUSEPORT_BPF: c_int = 0x0047; +pub const SO_PREFER_BUSY_POLL: c_int = 0x0048; +pub const SO_BUSY_POLL_BUDGET: c_int = 0x0049; +pub const SO_NETNS_COOKIE: c_int = 0x0050; +pub const SO_BUF_LOCK: c_int = 0x0051; +pub const SO_RESERVE_MEM: c_int = 0x0052; +pub const SO_TXREHASH: c_int = 0x0053; +pub const SO_RCVMARK: c_int = 0x0054; +pub const SO_PASSPIDFD: c_int = 0x0055; +pub const SO_PEERPIDFD: c_int = 0x0056; +pub const SO_DEVMEM_LINEAR: c_int = 0x0057; +pub const SO_DEVMEM_DMABUF: c_int = 0x0058; +pub const SO_DEVMEM_DONTNEED: c_int = 0x0059; + +// Defined in unix/linux_like/mod.rs +// pub const SCM_TIMESTAMP: c_int = SO_TIMESTAMP; +pub const SCM_TIMESTAMPNS: c_int = SO_TIMESTAMPNS; +pub const SCM_TIMESTAMPING: c_int = SO_TIMESTAMPING; + +pub const SCM_DEVMEM_LINEAR: c_int = SO_DEVMEM_LINEAR; +pub const SCM_DEVMEM_DMABUF: c_int = SO_DEVMEM_DMABUF; + +// Ioctl Constants + +pub const TCGETS: Ioctl = 0x40245408; +pub const TCSETS: Ioctl = 0x80245409; +pub const TCSETSW: Ioctl = 0x8024540a; +pub const TCSETSF: Ioctl = 0x8024540b; +pub const TCGETA: Ioctl = 0x40125401; +pub const TCSETA: Ioctl = 0x80125402; +pub const TCSETAW: Ioctl = 0x80125403; +pub const TCSETAF: Ioctl = 0x80125404; +pub const TCSBRK: Ioctl = 0x20005405; +pub const TCXONC: Ioctl = 0x20005406; +pub const TCFLSH: Ioctl = 0x20005407; +pub const TIOCEXCL: Ioctl = 0x2000740d; +pub const TIOCNXCL: Ioctl = 0x2000740e; +pub const TIOCSCTTY: Ioctl = 0x20007484; +pub const TIOCGPGRP: Ioctl = 0x40047483; +pub const TIOCSPGRP: Ioctl = 0x80047482; +pub const TIOCOUTQ: Ioctl = 0x40047473; +pub const TIOCSTI: Ioctl = 0x80017472; +pub const TIOCGWINSZ: Ioctl = 0x40087468; +pub const TIOCSWINSZ: Ioctl = 0x80087467; +pub const TIOCMGET: Ioctl = 0x4004746a; +pub const TIOCMBIS: Ioctl = 0x8004746c; +pub const TIOCMBIC: Ioctl = 0x8004746b; +pub const TIOCMSET: Ioctl = 0x8004746d; +pub const TIOCGSOFTCAR: Ioctl = 0x40047464; +pub const TIOCSSOFTCAR: Ioctl = 0x80047465; +pub const FIONREAD: Ioctl = 0x4004667f; +pub const TIOCINQ: Ioctl = FIONREAD; +pub const TIOCLINUX: Ioctl = 0x541C; +pub const TIOCCONS: Ioctl = 0x20007424; +pub const TIOCGSERIAL: Ioctl = 0x541E; +pub const TIOCSSERIAL: Ioctl = 0x541F; +pub const TIOCPKT: Ioctl = 0x80047470; +pub const FIONBIO: Ioctl = 0x8004667e; +pub const TIOCNOTTY: Ioctl = 0x20007471; +pub const TIOCSETD: Ioctl = 0x80047401; +pub const TIOCGETD: Ioctl = 0x40047400; +pub const TCSBRKP: Ioctl = 0x5425; +pub const TIOCSBRK: Ioctl = 0x2000747b; +pub const TIOCCBRK: Ioctl = 0x2000747a; +pub const TIOCGSID: Ioctl = 0x40047485; +pub const TCGETS2: Ioctl = 0x402c540c; +pub const TCSETS2: Ioctl = 0x802c540d; +pub const TCSETSW2: Ioctl = 0x802c540e; +pub const TCSETSF2: Ioctl = 0x802c540f; +pub const TIOCGPTN: Ioctl = 0x40047486; +pub const TIOCSPTLCK: Ioctl = 0x80047487; +pub const TIOCGDEV: Ioctl = 0x40045432; +pub const TIOCSIG: Ioctl = 0x80047488; +pub const TIOCVHANGUP: Ioctl = 0x20005437; +pub const TIOCGPKT: Ioctl = 0x40045438; +pub const TIOCGPTLCK: Ioctl = 0x40045439; +pub const TIOCGEXCL: Ioctl = 0x40045440; +pub const TIOCGPTPEER: Ioctl = 0x20007489; +pub const FIONCLEX: Ioctl = 0x20006602; +pub const FIOCLEX: Ioctl = 0x20006601; +pub const TIOCSERCONFIG: Ioctl = 0x5453; +pub const TIOCSERGWILD: Ioctl = 0x5454; +pub const TIOCSERSWILD: Ioctl = 0x5455; +pub const TIOCGLCKTRMIOS: Ioctl = 0x5456; +pub const TIOCSLCKTRMIOS: Ioctl = 0x5457; +pub const TIOCSERGSTRUCT: Ioctl = 0x5458; +pub const TIOCSERGETLSR: Ioctl = 0x5459; +pub const TIOCSERGETMULTI: Ioctl = 0x545A; +pub const TIOCSERSETMULTI: Ioctl = 0x545B; +pub const TIOCMIWAIT: Ioctl = 0x545C; +pub const TIOCGICOUNT: Ioctl = 0x545D; +pub const TIOCSTART: Ioctl = 0x2000746e; +pub const TIOCSTOP: Ioctl = 0x2000746f; +pub const BLKIOMIN: Ioctl = 0x20001278; +pub const BLKIOOPT: Ioctl = 0x20001279; +pub const BLKSSZGET: Ioctl = 0x20001268; +pub const BLKPBSZGET: Ioctl = 0x2000127B; + +//pub const FIOASYNC: Ioctl = 0x4004667d; +//pub const FIOQSIZE: Ioctl = ; +//pub const TIOCGISO7816: Ioctl = 0x40285443; +//pub const TIOCSISO7816: Ioctl = 0xc0285444; +//pub const TIOCGRS485: Ioctl = 0x40205441; +//pub const TIOCSRS485: Ioctl = 0xc0205442; + +pub const TIOCM_LE: c_int = 0x001; +pub const TIOCM_DTR: c_int = 0x002; +pub const TIOCM_RTS: c_int = 0x004; +pub const TIOCM_ST: c_int = 0x008; +pub const TIOCM_SR: c_int = 0x010; +pub const TIOCM_CTS: c_int = 0x020; +pub const TIOCM_CAR: c_int = 0x040; +pub const TIOCM_CD: c_int = TIOCM_CAR; +pub const TIOCM_RNG: c_int = 0x080; +pub const TIOCM_RI: c_int = TIOCM_RNG; +pub const TIOCM_DSR: c_int = 0x100; + +pub const BOTHER: crate::speed_t = 0x1000; +pub const IBSHIFT: crate::tcflag_t = 16; +pub const IUCLC: crate::tcflag_t = 0o0001000; +pub const XCASE: crate::tcflag_t = 0o0000004; + +// RLIMIT Constants + +pub const RLIMIT_CPU: crate::__rlimit_resource_t = 0; +pub const RLIMIT_FSIZE: crate::__rlimit_resource_t = 1; +pub const RLIMIT_DATA: crate::__rlimit_resource_t = 2; +pub const RLIMIT_STACK: crate::__rlimit_resource_t = 3; +pub const RLIMIT_CORE: crate::__rlimit_resource_t = 4; +pub const RLIMIT_RSS: crate::__rlimit_resource_t = 5; +pub const RLIMIT_NOFILE: crate::__rlimit_resource_t = 6; +pub const RLIMIT_NPROC: crate::__rlimit_resource_t = 7; +pub const RLIMIT_MEMLOCK: crate::__rlimit_resource_t = 8; +pub const RLIMIT_AS: crate::__rlimit_resource_t = 9; +pub const RLIMIT_LOCKS: crate::__rlimit_resource_t = 10; +pub const RLIMIT_SIGPENDING: crate::__rlimit_resource_t = 11; +pub const RLIMIT_MSGQUEUE: crate::__rlimit_resource_t = 12; +pub const RLIMIT_NICE: crate::__rlimit_resource_t = 13; +pub const RLIMIT_RTPRIO: crate::__rlimit_resource_t = 14; +pub const RLIMIT_RTTIME: crate::__rlimit_resource_t = 15; +#[deprecated(since = "0.2.64", note = "Not stable across OS versions")] +pub const RLIM_NLIMITS: crate::__rlimit_resource_t = 16; +#[allow(deprecated)] +#[deprecated(since = "0.2.64", note = "Not stable across OS versions")] +pub const RLIMIT_NLIMITS: crate::__rlimit_resource_t = RLIM_NLIMITS; + +cfg_if! { + if #[cfg(target_arch = "sparc64")] { + pub const RLIM_INFINITY: crate::rlim_t = !0; + } else if #[cfg(target_arch = "sparc")] { + pub const RLIM_INFINITY: crate::rlim_t = 0x7fffffff; + } +} diff --git a/http/vendor/libc/src/unix/linux_like/linux/gnu/b32/arm/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/gnu/b32/arm/mod.rs new file mode 100644 index 0000000..d05bccf --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/gnu/b32/arm/mod.rs @@ -0,0 +1,907 @@ +use crate::prelude::*; +use crate::{ + off64_t, + off_t, +}; + +pub type wchar_t = u32; + +s! { + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigaction { + pub sa_sigaction: crate::sighandler_t, + pub sa_mask: crate::sigset_t, + pub sa_flags: c_int, + pub sa_restorer: Option, + } + + pub struct statfs { + pub f_type: crate::__fsword_t, + pub f_bsize: crate::__fsword_t, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_fsid: crate::fsid_t, + + pub f_namelen: crate::__fsword_t, + pub f_frsize: crate::__fsword_t, + pub f_flags: crate::__fsword_t, + f_spare: [crate::__fsword_t; 4], + } + + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off_t, + pub l_len: off_t, + pub l_pid: crate::pid_t, + } + + pub struct flock64 { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off64_t, + pub l_len: off64_t, + pub l_pid: crate::pid_t, + } + + pub struct ipc_perm { + pub __key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: c_ushort, + __pad1: Padding, + pub __seq: c_ushort, + __pad2: Padding, + __unused1: Padding, + __unused2: Padding, + } + + pub struct stat64 { + pub st_dev: crate::dev_t, + #[cfg(not(gnu_time_bits64))] + __pad1: Padding, + #[cfg(not(gnu_time_bits64))] + __st_ino: c_ulong, + #[cfg(gnu_time_bits64)] + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + #[cfg(not(gnu_time_bits64))] + __pad2: Padding, + pub st_size: off64_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt64_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + #[cfg(gnu_time_bits64)] + _atime_pad: Padding, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + #[cfg(gnu_time_bits64)] + _mtime_pad: Padding, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + #[cfg(gnu_time_bits64)] + _ctime_pad: Padding, + #[cfg(not(gnu_time_bits64))] + pub st_ino: crate::ino64_t, + } + + pub struct statfs64 { + pub f_type: crate::__fsword_t, + pub f_bsize: crate::__fsword_t, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_fsid: crate::fsid_t, + pub f_namelen: crate::__fsword_t, + pub f_frsize: crate::__fsword_t, + pub f_flags: crate::__fsword_t, + pub f_spare: [crate::__fsword_t; 4], + } + + pub struct statvfs64 { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: c_ulong, + __f_unused: Padding, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: [c_int; 6], + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, + pub shm_atime: crate::time_t, + #[cfg(not(gnu_time_bits64))] + __unused1: Padding, + pub shm_dtime: crate::time_t, + #[cfg(not(gnu_time_bits64))] + __unused2: Padding, + pub shm_ctime: crate::time_t, + #[cfg(not(gnu_time_bits64))] + __unused3: Padding, + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: crate::shmatt_t, + __unused4: Padding, + __unused5: Padding, + } + + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + pub msg_stime: crate::time_t, + #[cfg(not(gnu_time_bits64))] + __glibc_reserved1: Padding, + pub msg_rtime: crate::time_t, + #[cfg(not(gnu_time_bits64))] + __glibc_reserved2: Padding, + pub msg_ctime: crate::time_t, + #[cfg(not(gnu_time_bits64))] + __glibc_reserved3: Padding, + pub __msg_cbytes: c_ulong, + pub msg_qnum: crate::msgqnum_t, + pub msg_qbytes: crate::msglen_t, + pub msg_lspid: crate::pid_t, + pub msg_lrpid: crate::pid_t, + __glibc_reserved4: Padding, + __glibc_reserved5: Padding, + } + + pub struct siginfo_t { + pub si_signo: c_int, + pub si_errno: c_int, + pub si_code: c_int, + #[doc(hidden)] + #[deprecated( + since = "0.2.54", + note = "Please leave a comment on \ + https://github.com/rust-lang/libc/pull/1316 if you're using \ + this field" + )] + pub _pad: [c_int; 29], + _align: [usize; 0], + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_flags: c_int, + pub ss_size: size_t, + } + + pub struct mcontext_t { + pub trap_no: c_ulong, + pub error_code: c_ulong, + pub oldmask: c_ulong, + pub arm_r0: c_ulong, + pub arm_r1: c_ulong, + pub arm_r2: c_ulong, + pub arm_r3: c_ulong, + pub arm_r4: c_ulong, + pub arm_r5: c_ulong, + pub arm_r6: c_ulong, + pub arm_r7: c_ulong, + pub arm_r8: c_ulong, + pub arm_r9: c_ulong, + pub arm_r10: c_ulong, + pub arm_fp: c_ulong, + pub arm_ip: c_ulong, + pub arm_sp: c_ulong, + pub arm_lr: c_ulong, + pub arm_pc: c_ulong, + pub arm_cpsr: c_ulong, + pub fault_address: c_ulong, + } + + pub struct user_regs { + pub arm_r0: c_ulong, + pub arm_r1: c_ulong, + pub arm_r2: c_ulong, + pub arm_r3: c_ulong, + pub arm_r4: c_ulong, + pub arm_r5: c_ulong, + pub arm_r6: c_ulong, + pub arm_r7: c_ulong, + pub arm_r8: c_ulong, + pub arm_r9: c_ulong, + pub arm_r10: c_ulong, + pub arm_fp: c_ulong, + pub arm_ip: c_ulong, + pub arm_sp: c_ulong, + pub arm_lr: c_ulong, + pub arm_pc: c_ulong, + pub arm_cpsr: c_ulong, + pub arm_orig_r0: c_ulong, + } + + #[repr(align(8))] + pub struct ucontext_t { + pub uc_flags: c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: crate::stack_t, + pub uc_mcontext: crate::mcontext_t, + pub uc_sigmask: crate::sigset_t, + pub uc_regspace: [c_ulong; 128], + } +} + +s_no_extra_traits! { + #[repr(align(8))] + pub struct max_align_t { + priv_: [i64; 2], + } +} + +pub const VEOF: usize = 4; +pub const RTLD_DEEPBIND: c_int = 0x8; +pub const RTLD_GLOBAL: c_int = 0x100; +pub const RTLD_NOLOAD: c_int = 0x4; +pub const O_DIRECT: c_int = 0x10000; +pub const O_DIRECTORY: c_int = 0x4000; +pub const O_NOFOLLOW: c_int = 0x8000; +pub const O_LARGEFILE: c_int = 0o400000; +pub const O_APPEND: c_int = 1024; +pub const O_CREAT: c_int = 64; +pub const O_EXCL: c_int = 128; +pub const O_NOCTTY: c_int = 256; +pub const O_NONBLOCK: c_int = 2048; +pub const O_SYNC: c_int = 1052672; +pub const O_RSYNC: c_int = 1052672; +pub const O_DSYNC: c_int = 4096; +pub const O_FSYNC: c_int = 0x101000; +pub const O_ASYNC: c_int = 0x2000; +pub const O_NDELAY: c_int = 0x800; + +pub const MADV_SOFT_OFFLINE: c_int = 101; +pub const MAP_LOCKED: c_int = 0x02000; +pub const MAP_NORESERVE: c_int = 0x04000; +pub const MAP_ANON: c_int = 0x0020; +pub const MAP_ANONYMOUS: c_int = 0x0020; +pub const MAP_DENYWRITE: c_int = 0x0800; +pub const MAP_EXECUTABLE: c_int = 0x01000; +pub const MAP_POPULATE: c_int = 0x08000; +pub const MAP_NONBLOCK: c_int = 0x010000; +pub const MAP_STACK: c_int = 0x020000; +pub const MAP_HUGETLB: c_int = 0x040000; +pub const MAP_GROWSDOWN: c_int = 0x0100; +pub const MAP_SYNC: c_int = 0x080000; + +pub const EDEADLOCK: c_int = 35; +pub const EUCLEAN: c_int = 117; +pub const ENOTNAM: c_int = 118; +pub const ENAVAIL: c_int = 119; +pub const EISNAM: c_int = 120; +pub const EREMOTEIO: c_int = 121; +pub const EDEADLK: c_int = 35; +pub const ENAMETOOLONG: c_int = 36; +pub const ENOLCK: c_int = 37; +pub const ENOSYS: c_int = 38; +pub const ENOTEMPTY: c_int = 39; +pub const ELOOP: c_int = 40; +pub const ENOMSG: c_int = 42; +pub const EIDRM: c_int = 43; +pub const ECHRNG: c_int = 44; +pub const EL2NSYNC: c_int = 45; +pub const EL3HLT: c_int = 46; +pub const EL3RST: c_int = 47; +pub const ELNRNG: c_int = 48; +pub const EUNATCH: c_int = 49; +pub const ENOCSI: c_int = 50; +pub const EL2HLT: c_int = 51; +pub const EBADE: c_int = 52; +pub const EBADR: c_int = 53; +pub const EXFULL: c_int = 54; +pub const ENOANO: c_int = 55; +pub const EBADRQC: c_int = 56; +pub const EBADSLT: c_int = 57; +pub const EMULTIHOP: c_int = 72; +pub const EOVERFLOW: c_int = 75; +pub const ENOTUNIQ: c_int = 76; +pub const EBADFD: c_int = 77; +pub const EBADMSG: c_int = 74; +pub const EREMCHG: c_int = 78; +pub const ELIBACC: c_int = 79; +pub const ELIBBAD: c_int = 80; +pub const ELIBSCN: c_int = 81; +pub const ELIBMAX: c_int = 82; +pub const ELIBEXEC: c_int = 83; +pub const EILSEQ: c_int = 84; +pub const ERESTART: c_int = 85; +pub const ESTRPIPE: c_int = 86; +pub const EUSERS: c_int = 87; +pub const ENOTSOCK: c_int = 88; +pub const EDESTADDRREQ: c_int = 89; +pub const EMSGSIZE: c_int = 90; +pub const EPROTOTYPE: c_int = 91; +pub const ENOPROTOOPT: c_int = 92; +pub const EPROTONOSUPPORT: c_int = 93; +pub const ESOCKTNOSUPPORT: c_int = 94; +pub const EOPNOTSUPP: c_int = 95; +pub const EPFNOSUPPORT: c_int = 96; +pub const EAFNOSUPPORT: c_int = 97; +pub const EADDRINUSE: c_int = 98; +pub const EADDRNOTAVAIL: c_int = 99; +pub const ENETDOWN: c_int = 100; +pub const ENETUNREACH: c_int = 101; +pub const ENETRESET: c_int = 102; +pub const ECONNABORTED: c_int = 103; +pub const ECONNRESET: c_int = 104; +pub const ENOBUFS: c_int = 105; +pub const EISCONN: c_int = 106; +pub const ENOTCONN: c_int = 107; +pub const ESHUTDOWN: c_int = 108; +pub const ETOOMANYREFS: c_int = 109; +pub const ETIMEDOUT: c_int = 110; +pub const ECONNREFUSED: c_int = 111; +pub const EHOSTDOWN: c_int = 112; +pub const EHOSTUNREACH: c_int = 113; +pub const EALREADY: c_int = 114; +pub const EINPROGRESS: c_int = 115; +pub const ESTALE: c_int = 116; +pub const EDQUOT: c_int = 122; +pub const ENOMEDIUM: c_int = 123; +pub const EMEDIUMTYPE: c_int = 124; +pub const ECANCELED: c_int = 125; +pub const ENOKEY: c_int = 126; +pub const EKEYEXPIRED: c_int = 127; +pub const EKEYREVOKED: c_int = 128; +pub const EKEYREJECTED: c_int = 129; +pub const EOWNERDEAD: c_int = 130; +pub const ENOTRECOVERABLE: c_int = 131; +pub const EHWPOISON: c_int = 133; +pub const ERFKILL: c_int = 132; + +pub const SA_SIGINFO: c_int = 0x00000004; +pub const SA_NOCLDWAIT: c_int = 0x00000002; + +pub const SOCK_STREAM: c_int = 1; +pub const SOCK_DGRAM: c_int = 2; + +pub const MCL_CURRENT: c_int = 0x0001; +pub const MCL_FUTURE: c_int = 0x0002; +pub const MCL_ONFAULT: c_int = 0x0004; + +pub const POLLWRNORM: c_short = 0x100; +pub const POLLWRBAND: c_short = 0x200; + +cfg_if! { + if #[cfg(gnu_file_offset_bits64)] { + pub const F_GETLK: c_int = 12; + } else { + pub const F_GETLK: c_int = 5; + } +} +pub const F_GETOWN: c_int = 9; +pub const F_SETOWN: c_int = 8; + +pub const EFD_NONBLOCK: c_int = 0x800; +pub const SFD_NONBLOCK: c_int = 0x0800; + +pub const SIGCHLD: c_int = 17; +pub const SIGBUS: c_int = 7; +pub const SIGUSR1: c_int = 10; +pub const SIGUSR2: c_int = 12; +pub const SIGCONT: c_int = 18; +pub const SIGSTOP: c_int = 19; +pub const SIGTSTP: c_int = 20; +pub const SIGURG: c_int = 23; +pub const SIGIO: c_int = 29; +pub const SIGSYS: c_int = 31; +pub const SIGSTKFLT: c_int = 16; +#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] +pub const SIGUNUSED: c_int = 31; +pub const SIGPOLL: c_int = 29; +pub const SIGPWR: c_int = 30; +pub const SIG_SETMASK: c_int = 2; +pub const SIG_BLOCK: c_int = 0x000000; +pub const SIG_UNBLOCK: c_int = 0x01; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGSTKSZ: size_t = 8192; +pub const MINSIGSTKSZ: size_t = 2048; +pub const CBAUD: crate::tcflag_t = 0o0010017; +pub const TAB1: crate::tcflag_t = 0x00000800; +pub const TAB2: crate::tcflag_t = 0x00001000; +pub const TAB3: crate::tcflag_t = 0x00001800; +pub const CR1: crate::tcflag_t = 0x00000200; +pub const CR2: crate::tcflag_t = 0x00000400; +pub const CR3: crate::tcflag_t = 0x00000600; +pub const FF1: crate::tcflag_t = 0x00008000; +pub const BS1: crate::tcflag_t = 0x00002000; +pub const VT1: crate::tcflag_t = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: crate::tcflag_t = 0x00000400; +pub const IXOFF: crate::tcflag_t = 0x00001000; +pub const ONLCR: crate::tcflag_t = 0x4; +pub const CSIZE: crate::tcflag_t = 0x00000030; +pub const CS6: crate::tcflag_t = 0x00000010; +pub const CS7: crate::tcflag_t = 0x00000020; +pub const CS8: crate::tcflag_t = 0x00000030; +pub const CSTOPB: crate::tcflag_t = 0x00000040; +pub const CREAD: crate::tcflag_t = 0x00000080; +pub const PARENB: crate::tcflag_t = 0x00000100; +pub const PARODD: crate::tcflag_t = 0x00000200; +pub const HUPCL: crate::tcflag_t = 0x00000400; +pub const CLOCAL: crate::tcflag_t = 0x00000800; +pub const ECHOKE: crate::tcflag_t = 0x00000800; +pub const ECHOE: crate::tcflag_t = 0x00000010; +pub const ECHOK: crate::tcflag_t = 0x00000020; +pub const ECHONL: crate::tcflag_t = 0x00000040; +pub const ECHOPRT: crate::tcflag_t = 0x00000400; +pub const ECHOCTL: crate::tcflag_t = 0x00000200; +pub const ISIG: crate::tcflag_t = 0x00000001; +pub const ICANON: crate::tcflag_t = 0x00000002; +pub const PENDIN: crate::tcflag_t = 0x00004000; +pub const NOFLSH: crate::tcflag_t = 0x00000080; +pub const CIBAUD: crate::tcflag_t = 0o02003600000; +pub const CBAUDEX: crate::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: crate::tcflag_t = 0o000002; +pub const NLDLY: crate::tcflag_t = 0o000400; +pub const CRDLY: crate::tcflag_t = 0o003000; +pub const TABDLY: crate::tcflag_t = 0o014000; +pub const BSDLY: crate::tcflag_t = 0o020000; +pub const FFDLY: crate::tcflag_t = 0o100000; +pub const VTDLY: crate::tcflag_t = 0o040000; +pub const XTABS: crate::tcflag_t = 0o014000; + +pub const B0: crate::speed_t = 0o000000; +pub const B50: crate::speed_t = 0o000001; +pub const B75: crate::speed_t = 0o000002; +pub const B110: crate::speed_t = 0o000003; +pub const B134: crate::speed_t = 0o000004; +pub const B150: crate::speed_t = 0o000005; +pub const B200: crate::speed_t = 0o000006; +pub const B300: crate::speed_t = 0o000007; +pub const B600: crate::speed_t = 0o000010; +pub const B1200: crate::speed_t = 0o000011; +pub const B1800: crate::speed_t = 0o000012; +pub const B2400: crate::speed_t = 0o000013; +pub const B4800: crate::speed_t = 0o000014; +pub const B9600: crate::speed_t = 0o000015; +pub const B19200: crate::speed_t = 0o000016; +pub const B38400: crate::speed_t = 0o000017; +pub const EXTA: crate::speed_t = B19200; +pub const EXTB: crate::speed_t = B38400; +pub const B57600: crate::speed_t = 0o010001; +pub const B115200: crate::speed_t = 0o010002; +pub const B230400: crate::speed_t = 0o010003; +pub const B460800: crate::speed_t = 0o010004; +pub const B500000: crate::speed_t = 0o010005; +pub const B576000: crate::speed_t = 0o010006; +pub const B921600: crate::speed_t = 0o010007; +pub const B1000000: crate::speed_t = 0o010010; +pub const B1152000: crate::speed_t = 0o010011; +pub const B1500000: crate::speed_t = 0o010012; +pub const B2000000: crate::speed_t = 0o010013; +pub const B2500000: crate::speed_t = 0o010014; +pub const B3000000: crate::speed_t = 0o010015; +pub const B3500000: crate::speed_t = 0o010016; +pub const B4000000: crate::speed_t = 0o010017; + +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: crate::tcflag_t = 0x00008000; +pub const TOSTOP: crate::tcflag_t = 0x00000100; +pub const FLUSHO: crate::tcflag_t = 0x00001000; +pub const EXTPROC: crate::tcflag_t = 0x00010000; + +pub const TCSANOW: c_int = 0; +pub const TCSADRAIN: c_int = 1; +pub const TCSAFLUSH: c_int = 2; + +// Syscall table +pub const SYS_restart_syscall: c_long = 0; +pub const SYS_exit: c_long = 1; +pub const SYS_fork: c_long = 2; +pub const SYS_read: c_long = 3; +pub const SYS_write: c_long = 4; +pub const SYS_open: c_long = 5; +pub const SYS_close: c_long = 6; +pub const SYS_creat: c_long = 8; +pub const SYS_link: c_long = 9; +pub const SYS_unlink: c_long = 10; +pub const SYS_execve: c_long = 11; +pub const SYS_chdir: c_long = 12; +pub const SYS_mknod: c_long = 14; +pub const SYS_chmod: c_long = 15; +pub const SYS_lchown: c_long = 16; +pub const SYS_lseek: c_long = 19; +pub const SYS_getpid: c_long = 20; +pub const SYS_mount: c_long = 21; +pub const SYS_setuid: c_long = 23; +pub const SYS_getuid: c_long = 24; +pub const SYS_ptrace: c_long = 26; +pub const SYS_pause: c_long = 29; +pub const SYS_access: c_long = 33; +pub const SYS_nice: c_long = 34; +pub const SYS_sync: c_long = 36; +pub const SYS_kill: c_long = 37; +pub const SYS_rename: c_long = 38; +pub const SYS_mkdir: c_long = 39; +pub const SYS_rmdir: c_long = 40; +pub const SYS_dup: c_long = 41; +pub const SYS_pipe: c_long = 42; +pub const SYS_times: c_long = 43; +pub const SYS_brk: c_long = 45; +pub const SYS_setgid: c_long = 46; +pub const SYS_getgid: c_long = 47; +pub const SYS_geteuid: c_long = 49; +pub const SYS_getegid: c_long = 50; +pub const SYS_acct: c_long = 51; +pub const SYS_umount2: c_long = 52; +pub const SYS_ioctl: c_long = 54; +pub const SYS_fcntl: c_long = 55; +pub const SYS_setpgid: c_long = 57; +pub const SYS_umask: c_long = 60; +pub const SYS_chroot: c_long = 61; +pub const SYS_ustat: c_long = 62; +pub const SYS_dup2: c_long = 63; +pub const SYS_getppid: c_long = 64; +pub const SYS_getpgrp: c_long = 65; +pub const SYS_setsid: c_long = 66; +pub const SYS_sigaction: c_long = 67; +pub const SYS_setreuid: c_long = 70; +pub const SYS_setregid: c_long = 71; +pub const SYS_sigsuspend: c_long = 72; +pub const SYS_sigpending: c_long = 73; +pub const SYS_sethostname: c_long = 74; +pub const SYS_setrlimit: c_long = 75; +pub const SYS_getrusage: c_long = 77; +pub const SYS_gettimeofday: c_long = 78; +pub const SYS_settimeofday: c_long = 79; +pub const SYS_getgroups: c_long = 80; +pub const SYS_setgroups: c_long = 81; +pub const SYS_symlink: c_long = 83; +pub const SYS_readlink: c_long = 85; +pub const SYS_uselib: c_long = 86; +pub const SYS_swapon: c_long = 87; +pub const SYS_reboot: c_long = 88; +pub const SYS_munmap: c_long = 91; +pub const SYS_truncate: c_long = 92; +pub const SYS_ftruncate: c_long = 93; +pub const SYS_fchmod: c_long = 94; +pub const SYS_fchown: c_long = 95; +pub const SYS_getpriority: c_long = 96; +pub const SYS_setpriority: c_long = 97; +pub const SYS_statfs: c_long = 99; +pub const SYS_fstatfs: c_long = 100; +pub const SYS_syslog: c_long = 103; +pub const SYS_setitimer: c_long = 104; +pub const SYS_getitimer: c_long = 105; +pub const SYS_stat: c_long = 106; +pub const SYS_lstat: c_long = 107; +pub const SYS_fstat: c_long = 108; +pub const SYS_vhangup: c_long = 111; +pub const SYS_wait4: c_long = 114; +pub const SYS_swapoff: c_long = 115; +pub const SYS_sysinfo: c_long = 116; +pub const SYS_fsync: c_long = 118; +pub const SYS_sigreturn: c_long = 119; +pub const SYS_clone: c_long = 120; +pub const SYS_setdomainname: c_long = 121; +pub const SYS_uname: c_long = 122; +pub const SYS_adjtimex: c_long = 124; +pub const SYS_mprotect: c_long = 125; +pub const SYS_sigprocmask: c_long = 126; +pub const SYS_init_module: c_long = 128; +pub const SYS_delete_module: c_long = 129; +pub const SYS_quotactl: c_long = 131; +pub const SYS_getpgid: c_long = 132; +pub const SYS_fchdir: c_long = 133; +pub const SYS_bdflush: c_long = 134; +pub const SYS_sysfs: c_long = 135; +pub const SYS_personality: c_long = 136; +pub const SYS_setfsuid: c_long = 138; +pub const SYS_setfsgid: c_long = 139; +pub const SYS__llseek: c_long = 140; +pub const SYS_getdents: c_long = 141; +pub const SYS__newselect: c_long = 142; +pub const SYS_flock: c_long = 143; +pub const SYS_msync: c_long = 144; +pub const SYS_readv: c_long = 145; +pub const SYS_writev: c_long = 146; +pub const SYS_getsid: c_long = 147; +pub const SYS_fdatasync: c_long = 148; +pub const SYS__sysctl: c_long = 149; +pub const SYS_mlock: c_long = 150; +pub const SYS_munlock: c_long = 151; +pub const SYS_mlockall: c_long = 152; +pub const SYS_munlockall: c_long = 153; +pub const SYS_sched_setparam: c_long = 154; +pub const SYS_sched_getparam: c_long = 155; +pub const SYS_sched_setscheduler: c_long = 156; +pub const SYS_sched_getscheduler: c_long = 157; +pub const SYS_sched_yield: c_long = 158; +pub const SYS_sched_get_priority_max: c_long = 159; +pub const SYS_sched_get_priority_min: c_long = 160; +pub const SYS_sched_rr_get_interval: c_long = 161; +pub const SYS_nanosleep: c_long = 162; +pub const SYS_mremap: c_long = 163; +pub const SYS_setresuid: c_long = 164; +pub const SYS_getresuid: c_long = 165; +pub const SYS_poll: c_long = 168; +pub const SYS_nfsservctl: c_long = 169; +pub const SYS_setresgid: c_long = 170; +pub const SYS_getresgid: c_long = 171; +pub const SYS_prctl: c_long = 172; +pub const SYS_rt_sigreturn: c_long = 173; +pub const SYS_rt_sigaction: c_long = 174; +pub const SYS_rt_sigprocmask: c_long = 175; +pub const SYS_rt_sigpending: c_long = 176; +pub const SYS_rt_sigtimedwait: c_long = 177; +pub const SYS_rt_sigqueueinfo: c_long = 178; +pub const SYS_rt_sigsuspend: c_long = 179; +pub const SYS_pread64: c_long = 180; +pub const SYS_pwrite64: c_long = 181; +pub const SYS_chown: c_long = 182; +pub const SYS_getcwd: c_long = 183; +pub const SYS_capget: c_long = 184; +pub const SYS_capset: c_long = 185; +pub const SYS_sigaltstack: c_long = 186; +pub const SYS_sendfile: c_long = 187; +pub const SYS_vfork: c_long = 190; +pub const SYS_ugetrlimit: c_long = 191; +pub const SYS_mmap2: c_long = 192; +pub const SYS_truncate64: c_long = 193; +pub const SYS_ftruncate64: c_long = 194; +pub const SYS_stat64: c_long = 195; +pub const SYS_lstat64: c_long = 196; +pub const SYS_fstat64: c_long = 197; +pub const SYS_lchown32: c_long = 198; +pub const SYS_getuid32: c_long = 199; +pub const SYS_getgid32: c_long = 200; +pub const SYS_geteuid32: c_long = 201; +pub const SYS_getegid32: c_long = 202; +pub const SYS_setreuid32: c_long = 203; +pub const SYS_setregid32: c_long = 204; +pub const SYS_getgroups32: c_long = 205; +pub const SYS_setgroups32: c_long = 206; +pub const SYS_fchown32: c_long = 207; +pub const SYS_setresuid32: c_long = 208; +pub const SYS_getresuid32: c_long = 209; +pub const SYS_setresgid32: c_long = 210; +pub const SYS_getresgid32: c_long = 211; +pub const SYS_chown32: c_long = 212; +pub const SYS_setuid32: c_long = 213; +pub const SYS_setgid32: c_long = 214; +pub const SYS_setfsuid32: c_long = 215; +pub const SYS_setfsgid32: c_long = 216; +pub const SYS_getdents64: c_long = 217; +pub const SYS_pivot_root: c_long = 218; +pub const SYS_mincore: c_long = 219; +pub const SYS_madvise: c_long = 220; +pub const SYS_fcntl64: c_long = 221; +pub const SYS_gettid: c_long = 224; +pub const SYS_readahead: c_long = 225; +pub const SYS_setxattr: c_long = 226; +pub const SYS_lsetxattr: c_long = 227; +pub const SYS_fsetxattr: c_long = 228; +pub const SYS_getxattr: c_long = 229; +pub const SYS_lgetxattr: c_long = 230; +pub const SYS_fgetxattr: c_long = 231; +pub const SYS_listxattr: c_long = 232; +pub const SYS_llistxattr: c_long = 233; +pub const SYS_flistxattr: c_long = 234; +pub const SYS_removexattr: c_long = 235; +pub const SYS_lremovexattr: c_long = 236; +pub const SYS_fremovexattr: c_long = 237; +pub const SYS_tkill: c_long = 238; +pub const SYS_sendfile64: c_long = 239; +pub const SYS_futex: c_long = 240; +pub const SYS_sched_setaffinity: c_long = 241; +pub const SYS_sched_getaffinity: c_long = 242; +pub const SYS_io_setup: c_long = 243; +pub const SYS_io_destroy: c_long = 244; +pub const SYS_io_getevents: c_long = 245; +pub const SYS_io_submit: c_long = 246; +pub const SYS_io_cancel: c_long = 247; +pub const SYS_exit_group: c_long = 248; +pub const SYS_lookup_dcookie: c_long = 249; +pub const SYS_epoll_create: c_long = 250; +pub const SYS_epoll_ctl: c_long = 251; +pub const SYS_epoll_wait: c_long = 252; +pub const SYS_remap_file_pages: c_long = 253; +pub const SYS_set_tid_address: c_long = 256; +pub const SYS_timer_create: c_long = 257; +pub const SYS_timer_settime: c_long = 258; +pub const SYS_timer_gettime: c_long = 259; +pub const SYS_timer_getoverrun: c_long = 260; +pub const SYS_timer_delete: c_long = 261; +pub const SYS_clock_settime: c_long = 262; +pub const SYS_clock_gettime: c_long = 263; +pub const SYS_clock_getres: c_long = 264; +pub const SYS_clock_nanosleep: c_long = 265; +pub const SYS_statfs64: c_long = 266; +pub const SYS_fstatfs64: c_long = 267; +pub const SYS_tgkill: c_long = 268; +pub const SYS_utimes: c_long = 269; +pub const SYS_arm_fadvise64_64: c_long = 270; +pub const SYS_pciconfig_iobase: c_long = 271; +pub const SYS_pciconfig_read: c_long = 272; +pub const SYS_pciconfig_write: c_long = 273; +pub const SYS_mq_open: c_long = 274; +pub const SYS_mq_unlink: c_long = 275; +pub const SYS_mq_timedsend: c_long = 276; +pub const SYS_mq_timedreceive: c_long = 277; +pub const SYS_mq_notify: c_long = 278; +pub const SYS_mq_getsetattr: c_long = 279; +pub const SYS_waitid: c_long = 280; +pub const SYS_socket: c_long = 281; +pub const SYS_bind: c_long = 282; +pub const SYS_connect: c_long = 283; +pub const SYS_listen: c_long = 284; +pub const SYS_accept: c_long = 285; +pub const SYS_getsockname: c_long = 286; +pub const SYS_getpeername: c_long = 287; +pub const SYS_socketpair: c_long = 288; +pub const SYS_send: c_long = 289; +pub const SYS_sendto: c_long = 290; +pub const SYS_recv: c_long = 291; +pub const SYS_recvfrom: c_long = 292; +pub const SYS_shutdown: c_long = 293; +pub const SYS_setsockopt: c_long = 294; +pub const SYS_getsockopt: c_long = 295; +pub const SYS_sendmsg: c_long = 296; +pub const SYS_recvmsg: c_long = 297; +pub const SYS_semop: c_long = 298; +pub const SYS_semget: c_long = 299; +pub const SYS_semctl: c_long = 300; +pub const SYS_msgsnd: c_long = 301; +pub const SYS_msgrcv: c_long = 302; +pub const SYS_msgget: c_long = 303; +pub const SYS_msgctl: c_long = 304; +pub const SYS_shmat: c_long = 305; +pub const SYS_shmdt: c_long = 306; +pub const SYS_shmget: c_long = 307; +pub const SYS_shmctl: c_long = 308; +pub const SYS_add_key: c_long = 309; +pub const SYS_request_key: c_long = 310; +pub const SYS_keyctl: c_long = 311; +pub const SYS_semtimedop: c_long = 312; +pub const SYS_vserver: c_long = 313; +pub const SYS_ioprio_set: c_long = 314; +pub const SYS_ioprio_get: c_long = 315; +pub const SYS_inotify_init: c_long = 316; +pub const SYS_inotify_add_watch: c_long = 317; +pub const SYS_inotify_rm_watch: c_long = 318; +pub const SYS_mbind: c_long = 319; +pub const SYS_get_mempolicy: c_long = 320; +pub const SYS_set_mempolicy: c_long = 321; +pub const SYS_openat: c_long = 322; +pub const SYS_mkdirat: c_long = 323; +pub const SYS_mknodat: c_long = 324; +pub const SYS_fchownat: c_long = 325; +pub const SYS_futimesat: c_long = 326; +pub const SYS_fstatat64: c_long = 327; +pub const SYS_unlinkat: c_long = 328; +pub const SYS_renameat: c_long = 329; +pub const SYS_linkat: c_long = 330; +pub const SYS_symlinkat: c_long = 331; +pub const SYS_readlinkat: c_long = 332; +pub const SYS_fchmodat: c_long = 333; +pub const SYS_faccessat: c_long = 334; +pub const SYS_pselect6: c_long = 335; +pub const SYS_ppoll: c_long = 336; +pub const SYS_unshare: c_long = 337; +pub const SYS_set_robust_list: c_long = 338; +pub const SYS_get_robust_list: c_long = 339; +pub const SYS_splice: c_long = 340; +pub const SYS_arm_sync_file_range: c_long = 341; +pub const SYS_tee: c_long = 342; +pub const SYS_vmsplice: c_long = 343; +pub const SYS_move_pages: c_long = 344; +pub const SYS_getcpu: c_long = 345; +pub const SYS_epoll_pwait: c_long = 346; +pub const SYS_kexec_load: c_long = 347; +pub const SYS_utimensat: c_long = 348; +pub const SYS_signalfd: c_long = 349; +pub const SYS_timerfd_create: c_long = 350; +pub const SYS_eventfd: c_long = 351; +pub const SYS_fallocate: c_long = 352; +pub const SYS_timerfd_settime: c_long = 353; +pub const SYS_timerfd_gettime: c_long = 354; +pub const SYS_signalfd4: c_long = 355; +pub const SYS_eventfd2: c_long = 356; +pub const SYS_epoll_create1: c_long = 357; +pub const SYS_dup3: c_long = 358; +pub const SYS_pipe2: c_long = 359; +pub const SYS_inotify_init1: c_long = 360; +pub const SYS_preadv: c_long = 361; +pub const SYS_pwritev: c_long = 362; +pub const SYS_rt_tgsigqueueinfo: c_long = 363; +pub const SYS_perf_event_open: c_long = 364; +pub const SYS_recvmmsg: c_long = 365; +pub const SYS_accept4: c_long = 366; +pub const SYS_fanotify_init: c_long = 367; +pub const SYS_fanotify_mark: c_long = 368; +pub const SYS_prlimit64: c_long = 369; +pub const SYS_name_to_handle_at: c_long = 370; +pub const SYS_open_by_handle_at: c_long = 371; +pub const SYS_clock_adjtime: c_long = 372; +pub const SYS_syncfs: c_long = 373; +pub const SYS_sendmmsg: c_long = 374; +pub const SYS_setns: c_long = 375; +pub const SYS_process_vm_readv: c_long = 376; +pub const SYS_process_vm_writev: c_long = 377; +pub const SYS_kcmp: c_long = 378; +pub const SYS_finit_module: c_long = 379; +pub const SYS_sched_setattr: c_long = 380; +pub const SYS_sched_getattr: c_long = 381; +pub const SYS_renameat2: c_long = 382; +pub const SYS_seccomp: c_long = 383; +pub const SYS_getrandom: c_long = 384; +pub const SYS_memfd_create: c_long = 385; +pub const SYS_bpf: c_long = 386; +pub const SYS_execveat: c_long = 387; +pub const SYS_userfaultfd: c_long = 388; +pub const SYS_membarrier: c_long = 389; +pub const SYS_mlock2: c_long = 390; +pub const SYS_copy_file_range: c_long = 391; +pub const SYS_preadv2: c_long = 392; +pub const SYS_pwritev2: c_long = 393; +pub const SYS_pkey_mprotect: c_long = 394; +pub const SYS_pkey_alloc: c_long = 395; +pub const SYS_pkey_free: c_long = 396; +pub const SYS_statx: c_long = 397; +pub const SYS_rseq: c_long = 398; +pub const SYS_kexec_file_load: c_long = 401; +pub const SYS_pidfd_send_signal: c_long = 424; +pub const SYS_io_uring_setup: c_long = 425; +pub const SYS_io_uring_enter: c_long = 426; +pub const SYS_io_uring_register: c_long = 427; +pub const SYS_open_tree: c_long = 428; +pub const SYS_move_mount: c_long = 429; +pub const SYS_fsopen: c_long = 430; +pub const SYS_fsconfig: c_long = 431; +pub const SYS_fsmount: c_long = 432; +pub const SYS_fspick: c_long = 433; +pub const SYS_pidfd_open: c_long = 434; +pub const SYS_clone3: c_long = 435; +pub const SYS_close_range: c_long = 436; +pub const SYS_openat2: c_long = 437; +pub const SYS_pidfd_getfd: c_long = 438; +pub const SYS_faccessat2: c_long = 439; +pub const SYS_process_madvise: c_long = 440; +pub const SYS_epoll_pwait2: c_long = 441; +pub const SYS_mount_setattr: c_long = 442; +pub const SYS_quotactl_fd: c_long = 443; +pub const SYS_landlock_create_ruleset: c_long = 444; +pub const SYS_landlock_add_rule: c_long = 445; +pub const SYS_landlock_restrict_self: c_long = 446; +pub const SYS_memfd_secret: c_long = 447; +pub const SYS_process_mrelease: c_long = 448; +pub const SYS_futex_waitv: c_long = 449; +pub const SYS_set_mempolicy_home_node: c_long = 450; +pub const SYS_mseal: c_long = 462; diff --git a/http/vendor/libc/src/unix/linux_like/linux/gnu/b32/csky/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/gnu/b32/csky/mod.rs new file mode 100644 index 0000000..dc88c63 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/gnu/b32/csky/mod.rs @@ -0,0 +1,748 @@ +use crate::prelude::*; +use crate::{ + off64_t, + off_t, +}; + +pub type wchar_t = u32; + +s! { + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigaction { + pub sa_sigaction: crate::sighandler_t, + pub sa_mask: crate::sigset_t, + pub sa_flags: c_int, + pub sa_restorer: Option, + } + + pub struct statfs { + pub f_type: crate::__fsword_t, + pub f_bsize: crate::__fsword_t, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_fsid: crate::fsid_t, + + pub f_namelen: crate::__fsword_t, + pub f_frsize: crate::__fsword_t, + f_spare: [crate::__fsword_t; 5], + } + + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off_t, + pub l_len: off_t, + pub l_pid: crate::pid_t, + } + + pub struct flock64 { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off64_t, + pub l_len: off64_t, + pub l_pid: crate::pid_t, + } + + pub struct ipc_perm { + pub __key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: c_ushort, + __pad1: Padding, + pub __seq: c_ushort, + __pad2: Padding, + __unused1: Padding, + __unused2: Padding, + } + + pub struct stat64 { + pub st_dev: crate::dev_t, + __pad1: Padding, + __st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + __pad2: Padding, + pub st_size: off64_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt64_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + pub st_ino: crate::ino64_t, + } + + pub struct statfs64 { + pub f_type: crate::__fsword_t, + pub f_bsize: crate::__fsword_t, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_fsid: crate::fsid_t, + pub f_namelen: crate::__fsword_t, + pub f_frsize: crate::__fsword_t, + pub f_flags: crate::__fsword_t, + pub f_spare: [crate::__fsword_t; 4], + } + + pub struct statvfs64 { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: c_ulong, + __f_unused: Padding, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: [c_int; 6], + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, + pub shm_atime: crate::time_t, + __unused1: Padding, + pub shm_dtime: crate::time_t, + __unused2: Padding, + pub shm_ctime: crate::time_t, + __unused3: Padding, + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: crate::shmatt_t, + __unused4: Padding, + __unused5: Padding, + } + + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + pub msg_stime: crate::time_t, + __glibc_reserved1: Padding, + pub msg_rtime: crate::time_t, + __glibc_reserved2: Padding, + pub msg_ctime: crate::time_t, + __glibc_reserved3: Padding, + pub __msg_cbytes: c_ulong, + pub msg_qnum: crate::msgqnum_t, + pub msg_qbytes: crate::msglen_t, + pub msg_lspid: crate::pid_t, + pub msg_lrpid: crate::pid_t, + __glibc_reserved4: Padding, + __glibc_reserved5: Padding, + } + + pub struct siginfo_t { + pub si_signo: c_int, + pub si_errno: c_int, + pub si_code: c_int, + #[doc(hidden)] + #[deprecated( + since = "0.2.54", + note = "Please leave a comment on \ + https://github.com/rust-lang/libc/pull/1316 if you're using \ + this field" + )] + pub _pad: [c_int; 29], + _align: [usize; 0], + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_flags: c_int, + pub ss_size: size_t, + } +} + +s_no_extra_traits! { + #[repr(align(8))] + pub struct max_align_t { + priv_: [i64; 2], + } +} + +pub const VEOF: usize = 4; +pub const RTLD_DEEPBIND: c_int = 0x8; +pub const RTLD_GLOBAL: c_int = 0x100; +pub const RTLD_NOLOAD: c_int = 0x4; +pub const O_DIRECT: c_int = 0x4000; +pub const O_DIRECTORY: c_int = 0x10000; +pub const O_NOFOLLOW: c_int = 0x20000; +pub const O_LARGEFILE: c_int = 0o100000; +pub const O_APPEND: c_int = 1024; +pub const O_CREAT: c_int = 64; +pub const O_EXCL: c_int = 128; +pub const O_NOCTTY: c_int = 256; +pub const O_NONBLOCK: c_int = 2048; +pub const O_SYNC: c_int = 1052672; +pub const O_RSYNC: c_int = 1052672; +pub const O_DSYNC: c_int = 4096; +pub const O_FSYNC: c_int = 0x101000; +pub const O_ASYNC: c_int = 0x2000; +pub const O_NDELAY: c_int = 0x800; + +pub const MADV_SOFT_OFFLINE: c_int = 101; +pub const MAP_LOCKED: c_int = 0x02000; +pub const MAP_NORESERVE: c_int = 0x04000; +pub const MAP_ANON: c_int = 0x0020; +pub const MAP_ANONYMOUS: c_int = 0x0020; +pub const MAP_DENYWRITE: c_int = 0x0800; +pub const MAP_EXECUTABLE: c_int = 0x01000; +pub const MAP_POPULATE: c_int = 0x08000; +pub const MAP_NONBLOCK: c_int = 0x010000; +pub const MAP_STACK: c_int = 0x020000; +pub const MAP_HUGETLB: c_int = 0x040000; +pub const MAP_GROWSDOWN: c_int = 0x0100; +pub const MAP_SYNC: c_int = 0x080000; + +pub const EDEADLOCK: c_int = 35; +pub const EUCLEAN: c_int = 117; +pub const ENOTNAM: c_int = 118; +pub const ENAVAIL: c_int = 119; +pub const EISNAM: c_int = 120; +pub const EREMOTEIO: c_int = 121; +pub const EDEADLK: c_int = 35; +pub const ENAMETOOLONG: c_int = 36; +pub const ENOLCK: c_int = 37; +pub const ENOSYS: c_int = 38; +pub const ENOTEMPTY: c_int = 39; +pub const ELOOP: c_int = 40; +pub const ENOMSG: c_int = 42; +pub const EIDRM: c_int = 43; +pub const ECHRNG: c_int = 44; +pub const EL2NSYNC: c_int = 45; +pub const EL3HLT: c_int = 46; +pub const EL3RST: c_int = 47; +pub const ELNRNG: c_int = 48; +pub const EUNATCH: c_int = 49; +pub const ENOCSI: c_int = 50; +pub const EL2HLT: c_int = 51; +pub const EBADE: c_int = 52; +pub const EBADR: c_int = 53; +pub const EXFULL: c_int = 54; +pub const ENOANO: c_int = 55; +pub const EBADRQC: c_int = 56; +pub const EBADSLT: c_int = 57; +pub const EMULTIHOP: c_int = 72; +pub const EOVERFLOW: c_int = 75; +pub const ENOTUNIQ: c_int = 76; +pub const EBADFD: c_int = 77; +pub const EBADMSG: c_int = 74; +pub const EREMCHG: c_int = 78; +pub const ELIBACC: c_int = 79; +pub const ELIBBAD: c_int = 80; +pub const ELIBSCN: c_int = 81; +pub const ELIBMAX: c_int = 82; +pub const ELIBEXEC: c_int = 83; +pub const EILSEQ: c_int = 84; +pub const ERESTART: c_int = 85; +pub const ESTRPIPE: c_int = 86; +pub const EUSERS: c_int = 87; +pub const ENOTSOCK: c_int = 88; +pub const EDESTADDRREQ: c_int = 89; +pub const EMSGSIZE: c_int = 90; +pub const EPROTOTYPE: c_int = 91; +pub const ENOPROTOOPT: c_int = 92; +pub const EPROTONOSUPPORT: c_int = 93; +pub const ESOCKTNOSUPPORT: c_int = 94; +pub const EOPNOTSUPP: c_int = 95; +pub const EPFNOSUPPORT: c_int = 96; +pub const EAFNOSUPPORT: c_int = 97; +pub const EADDRINUSE: c_int = 98; +pub const EADDRNOTAVAIL: c_int = 99; +pub const ENETDOWN: c_int = 100; +pub const ENETUNREACH: c_int = 101; +pub const ENETRESET: c_int = 102; +pub const ECONNABORTED: c_int = 103; +pub const ECONNRESET: c_int = 104; +pub const ENOBUFS: c_int = 105; +pub const EISCONN: c_int = 106; +pub const ENOTCONN: c_int = 107; +pub const ESHUTDOWN: c_int = 108; +pub const ETOOMANYREFS: c_int = 109; +pub const ETIMEDOUT: c_int = 110; +pub const ECONNREFUSED: c_int = 111; +pub const EHOSTDOWN: c_int = 112; +pub const EHOSTUNREACH: c_int = 113; +pub const EALREADY: c_int = 114; +pub const EINPROGRESS: c_int = 115; +pub const ESTALE: c_int = 116; +pub const EDQUOT: c_int = 122; +pub const ENOMEDIUM: c_int = 123; +pub const EMEDIUMTYPE: c_int = 124; +pub const ECANCELED: c_int = 125; +pub const ENOKEY: c_int = 126; +pub const EKEYEXPIRED: c_int = 127; +pub const EKEYREVOKED: c_int = 128; +pub const EKEYREJECTED: c_int = 129; +pub const EOWNERDEAD: c_int = 130; +pub const ENOTRECOVERABLE: c_int = 131; +pub const EHWPOISON: c_int = 133; +pub const ERFKILL: c_int = 132; + +pub const SA_SIGINFO: c_int = 0x00000004; +pub const SA_NOCLDWAIT: c_int = 0x00000002; + +pub const SOCK_STREAM: c_int = 1; +pub const SOCK_DGRAM: c_int = 2; + +pub const MCL_CURRENT: c_int = 0x0001; +pub const MCL_FUTURE: c_int = 0x0002; +pub const MCL_ONFAULT: c_int = 0x0004; + +pub const POLLWRNORM: c_short = 0x100; +pub const POLLWRBAND: c_short = 0x200; + +pub const F_GETLK: c_int = 5; +pub const F_GETOWN: c_int = 9; +pub const F_SETOWN: c_int = 8; + +pub const EFD_NONBLOCK: c_int = 0x800; +pub const SFD_NONBLOCK: c_int = 0x0800; + +pub const SIGCHLD: c_int = 17; +pub const SIGBUS: c_int = 7; +pub const SIGUSR1: c_int = 10; +pub const SIGUSR2: c_int = 12; +pub const SIGCONT: c_int = 18; +pub const SIGSTOP: c_int = 19; +pub const SIGTSTP: c_int = 20; +pub const SIGURG: c_int = 23; +pub const SIGIO: c_int = 29; +pub const SIGSYS: c_int = 31; +pub const SIGSTKFLT: c_int = 16; +#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] +pub const SIGUNUSED: c_int = 31; +pub const SIGPOLL: c_int = 29; +pub const SIGPWR: c_int = 30; +pub const SIG_SETMASK: c_int = 2; +pub const SIG_BLOCK: c_int = 0x000000; +pub const SIG_UNBLOCK: c_int = 0x01; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGSTKSZ: size_t = 8192; +pub const MINSIGSTKSZ: size_t = 2048; +pub const CBAUD: crate::tcflag_t = 0o0010017; +pub const TAB1: crate::tcflag_t = 0x00000800; +pub const TAB2: crate::tcflag_t = 0x00001000; +pub const TAB3: crate::tcflag_t = 0x00001800; +pub const CR1: crate::tcflag_t = 0x00000200; +pub const CR2: crate::tcflag_t = 0x00000400; +pub const CR3: crate::tcflag_t = 0x00000600; +pub const FF1: crate::tcflag_t = 0x00008000; +pub const BS1: crate::tcflag_t = 0x00002000; +pub const VT1: crate::tcflag_t = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: crate::tcflag_t = 0x00000400; +pub const IXOFF: crate::tcflag_t = 0x00001000; +pub const ONLCR: crate::tcflag_t = 0x4; +pub const CSIZE: crate::tcflag_t = 0x00000030; +pub const CS6: crate::tcflag_t = 0x00000010; +pub const CS7: crate::tcflag_t = 0x00000020; +pub const CS8: crate::tcflag_t = 0x00000030; +pub const CSTOPB: crate::tcflag_t = 0x00000040; +pub const CREAD: crate::tcflag_t = 0x00000080; +pub const PARENB: crate::tcflag_t = 0x00000100; +pub const PARODD: crate::tcflag_t = 0x00000200; +pub const HUPCL: crate::tcflag_t = 0x00000400; +pub const CLOCAL: crate::tcflag_t = 0x00000800; +pub const ECHOKE: crate::tcflag_t = 0x00000800; +pub const ECHOE: crate::tcflag_t = 0x00000010; +pub const ECHOK: crate::tcflag_t = 0x00000020; +pub const ECHONL: crate::tcflag_t = 0x00000040; +pub const ECHOPRT: crate::tcflag_t = 0x00000400; +pub const ECHOCTL: crate::tcflag_t = 0x00000200; +pub const ISIG: crate::tcflag_t = 0x00000001; +pub const ICANON: crate::tcflag_t = 0x00000002; +pub const PENDIN: crate::tcflag_t = 0x00004000; +pub const NOFLSH: crate::tcflag_t = 0x00000080; +pub const CIBAUD: crate::tcflag_t = 0o02003600000; +pub const CBAUDEX: crate::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: crate::tcflag_t = 0o000002; +pub const NLDLY: crate::tcflag_t = 0o000400; +pub const CRDLY: crate::tcflag_t = 0o003000; +pub const TABDLY: crate::tcflag_t = 0o014000; +pub const BSDLY: crate::tcflag_t = 0o020000; +pub const FFDLY: crate::tcflag_t = 0o100000; +pub const VTDLY: crate::tcflag_t = 0o040000; +pub const XTABS: crate::tcflag_t = 0o014000; + +pub const B0: crate::speed_t = 0o000000; +pub const B50: crate::speed_t = 0o000001; +pub const B75: crate::speed_t = 0o000002; +pub const B110: crate::speed_t = 0o000003; +pub const B134: crate::speed_t = 0o000004; +pub const B150: crate::speed_t = 0o000005; +pub const B200: crate::speed_t = 0o000006; +pub const B300: crate::speed_t = 0o000007; +pub const B600: crate::speed_t = 0o000010; +pub const B1200: crate::speed_t = 0o000011; +pub const B1800: crate::speed_t = 0o000012; +pub const B2400: crate::speed_t = 0o000013; +pub const B4800: crate::speed_t = 0o000014; +pub const B9600: crate::speed_t = 0o000015; +pub const B19200: crate::speed_t = 0o000016; +pub const B38400: crate::speed_t = 0o000017; +pub const EXTA: crate::speed_t = B19200; +pub const EXTB: crate::speed_t = B38400; +pub const B57600: crate::speed_t = 0o010001; +pub const B115200: crate::speed_t = 0o010002; +pub const B230400: crate::speed_t = 0o010003; +pub const B460800: crate::speed_t = 0o010004; +pub const B500000: crate::speed_t = 0o010005; +pub const B576000: crate::speed_t = 0o010006; +pub const B921600: crate::speed_t = 0o010007; +pub const B1000000: crate::speed_t = 0o010010; +pub const B1152000: crate::speed_t = 0o010011; +pub const B1500000: crate::speed_t = 0o010012; +pub const B2000000: crate::speed_t = 0o010013; +pub const B2500000: crate::speed_t = 0o010014; +pub const B3000000: crate::speed_t = 0o010015; +pub const B3500000: crate::speed_t = 0o010016; +pub const B4000000: crate::speed_t = 0o010017; + +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: crate::tcflag_t = 0x00008000; +pub const TOSTOP: crate::tcflag_t = 0x00000100; +pub const FLUSHO: crate::tcflag_t = 0x00001000; +pub const EXTPROC: crate::tcflag_t = 0x00010000; + +pub const TCSANOW: c_int = 0; +pub const TCSADRAIN: c_int = 1; +pub const TCSAFLUSH: c_int = 2; + +// Syscall table +pub const SYS_read: c_long = 63; +pub const SYS_write: c_long = 64; +pub const SYS_close: c_long = 57; +pub const SYS_fstat: c_long = 80; +pub const SYS_lseek: c_long = 62; +pub const SYS_mmap: c_long = 222; +pub const SYS_mprotect: c_long = 226; +pub const SYS_munmap: c_long = 215; +pub const SYS_brk: c_long = 214; +pub const SYS_rt_sigaction: c_long = 134; +pub const SYS_rt_sigprocmask: c_long = 135; +pub const SYS_rt_sigreturn: c_long = 139; +pub const SYS_ioctl: c_long = 29; +pub const SYS_pread64: c_long = 67; +pub const SYS_pwrite64: c_long = 68; +pub const SYS_readv: c_long = 65; +pub const SYS_writev: c_long = 66; +pub const SYS_sched_yield: c_long = 124; +pub const SYS_mremap: c_long = 216; +pub const SYS_msync: c_long = 227; +pub const SYS_mincore: c_long = 232; +pub const SYS_madvise: c_long = 233; +pub const SYS_shmget: c_long = 194; +pub const SYS_shmat: c_long = 196; +pub const SYS_shmctl: c_long = 195; +pub const SYS_dup: c_long = 23; +pub const SYS_nanosleep: c_long = 101; +pub const SYS_getitimer: c_long = 102; +pub const SYS_setitimer: c_long = 103; +pub const SYS_getpid: c_long = 172; +pub const SYS_sendfile: c_long = 71; +pub const SYS_socket: c_long = 198; +pub const SYS_connect: c_long = 203; +pub const SYS_accept: c_long = 202; +pub const SYS_sendto: c_long = 206; +pub const SYS_recvfrom: c_long = 207; +pub const SYS_sendmsg: c_long = 211; +pub const SYS_recvmsg: c_long = 212; +pub const SYS_shutdown: c_long = 210; +pub const SYS_bind: c_long = 200; +pub const SYS_listen: c_long = 201; +pub const SYS_getsockname: c_long = 204; +pub const SYS_getpeername: c_long = 205; +pub const SYS_socketpair: c_long = 199; +pub const SYS_setsockopt: c_long = 208; +pub const SYS_getsockopt: c_long = 209; +pub const SYS_clone: c_long = 220; +pub const SYS_execve: c_long = 221; +pub const SYS_exit: c_long = 93; +pub const SYS_wait4: c_long = 260; +pub const SYS_kill: c_long = 129; +pub const SYS_uname: c_long = 160; +pub const SYS_semget: c_long = 190; +pub const SYS_semop: c_long = 193; +pub const SYS_semctl: c_long = 191; +pub const SYS_shmdt: c_long = 197; +pub const SYS_msgget: c_long = 186; +pub const SYS_msgsnd: c_long = 189; +pub const SYS_msgrcv: c_long = 188; +pub const SYS_msgctl: c_long = 187; +pub const SYS_fcntl: c_long = 25; +pub const SYS_flock: c_long = 32; +pub const SYS_fsync: c_long = 82; +pub const SYS_fdatasync: c_long = 83; +pub const SYS_truncate: c_long = 45; +pub const SYS_ftruncate: c_long = 46; +pub const SYS_getcwd: c_long = 17; +pub const SYS_chdir: c_long = 49; +pub const SYS_fchdir: c_long = 50; +pub const SYS_fchmod: c_long = 52; +pub const SYS_fchown: c_long = 55; +pub const SYS_umask: c_long = 166; +pub const SYS_gettimeofday: c_long = 169; +pub const SYS_getrlimit: c_long = 163; +pub const SYS_getrusage: c_long = 165; +pub const SYS_sysinfo: c_long = 179; +pub const SYS_times: c_long = 153; +pub const SYS_ptrace: c_long = 117; +pub const SYS_getuid: c_long = 174; +pub const SYS_syslog: c_long = 116; +pub const SYS_getgid: c_long = 176; +pub const SYS_setuid: c_long = 146; +pub const SYS_setgid: c_long = 144; +pub const SYS_geteuid: c_long = 175; +pub const SYS_getegid: c_long = 177; +pub const SYS_setpgid: c_long = 154; +pub const SYS_getppid: c_long = 173; +pub const SYS_setsid: c_long = 157; +pub const SYS_setreuid: c_long = 145; +pub const SYS_setregid: c_long = 143; +pub const SYS_getgroups: c_long = 158; +pub const SYS_setgroups: c_long = 159; +pub const SYS_setresuid: c_long = 147; +pub const SYS_getresuid: c_long = 148; +pub const SYS_setresgid: c_long = 149; +pub const SYS_getresgid: c_long = 150; +pub const SYS_getpgid: c_long = 155; +pub const SYS_setfsuid: c_long = 151; +pub const SYS_setfsgid: c_long = 152; +pub const SYS_getsid: c_long = 156; +pub const SYS_capget: c_long = 90; +pub const SYS_capset: c_long = 91; +pub const SYS_rt_sigpending: c_long = 136; +pub const SYS_rt_sigtimedwait: c_long = 137; +pub const SYS_rt_sigqueueinfo: c_long = 138; +pub const SYS_rt_sigsuspend: c_long = 133; +pub const SYS_sigaltstack: c_long = 132; +pub const SYS_personality: c_long = 92; +pub const SYS_statfs: c_long = 43; +pub const SYS_fstatfs: c_long = 44; +pub const SYS_getpriority: c_long = 141; +pub const SYS_setpriority: c_long = 140; +pub const SYS_sched_setparam: c_long = 118; +pub const SYS_sched_getparam: c_long = 121; +pub const SYS_sched_setscheduler: c_long = 119; +pub const SYS_sched_getscheduler: c_long = 120; +pub const SYS_sched_get_priority_max: c_long = 125; +pub const SYS_sched_get_priority_min: c_long = 126; +pub const SYS_sched_rr_get_interval: c_long = 127; +pub const SYS_mlock: c_long = 228; +pub const SYS_munlock: c_long = 229; +pub const SYS_mlockall: c_long = 230; +pub const SYS_munlockall: c_long = 231; +pub const SYS_vhangup: c_long = 58; +pub const SYS_pivot_root: c_long = 41; +pub const SYS_prctl: c_long = 167; +pub const SYS_adjtimex: c_long = 171; +pub const SYS_setrlimit: c_long = 164; +pub const SYS_chroot: c_long = 51; +pub const SYS_sync: c_long = 81; +pub const SYS_acct: c_long = 89; +pub const SYS_settimeofday: c_long = 170; +pub const SYS_mount: c_long = 40; +pub const SYS_umount2: c_long = 39; +pub const SYS_swapon: c_long = 224; +pub const SYS_swapoff: c_long = 225; +pub const SYS_reboot: c_long = 142; +pub const SYS_sethostname: c_long = 161; +pub const SYS_setdomainname: c_long = 162; +pub const SYS_init_module: c_long = 105; +pub const SYS_delete_module: c_long = 106; +pub const SYS_quotactl: c_long = 60; +pub const SYS_nfsservctl: c_long = 42; +pub const SYS_gettid: c_long = 178; +pub const SYS_readahead: c_long = 213; +pub const SYS_setxattr: c_long = 5; +pub const SYS_lsetxattr: c_long = 6; +pub const SYS_fsetxattr: c_long = 7; +pub const SYS_getxattr: c_long = 8; +pub const SYS_lgetxattr: c_long = 9; +pub const SYS_fgetxattr: c_long = 10; +pub const SYS_listxattr: c_long = 11; +pub const SYS_llistxattr: c_long = 12; +pub const SYS_flistxattr: c_long = 13; +pub const SYS_removexattr: c_long = 14; +pub const SYS_lremovexattr: c_long = 15; +pub const SYS_fremovexattr: c_long = 16; +pub const SYS_tkill: c_long = 130; +pub const SYS_futex: c_long = 98; +pub const SYS_sched_setaffinity: c_long = 122; +pub const SYS_sched_getaffinity: c_long = 123; +pub const SYS_io_setup: c_long = 0; +pub const SYS_io_destroy: c_long = 1; +pub const SYS_io_getevents: c_long = 4; +pub const SYS_io_submit: c_long = 2; +pub const SYS_io_cancel: c_long = 3; +pub const SYS_lookup_dcookie: c_long = 18; +pub const SYS_remap_file_pages: c_long = 234; +pub const SYS_getdents64: c_long = 61; +pub const SYS_set_tid_address: c_long = 96; +pub const SYS_restart_syscall: c_long = 128; +pub const SYS_semtimedop: c_long = 192; +pub const SYS_fadvise64: c_long = 223; +pub const SYS_timer_create: c_long = 107; +pub const SYS_timer_settime: c_long = 110; +pub const SYS_timer_gettime: c_long = 108; +pub const SYS_timer_getoverrun: c_long = 109; +pub const SYS_timer_delete: c_long = 111; +pub const SYS_clock_settime: c_long = 112; +pub const SYS_clock_gettime: c_long = 113; +pub const SYS_clock_getres: c_long = 114; +pub const SYS_clock_nanosleep: c_long = 115; +pub const SYS_exit_group: c_long = 94; +pub const SYS_epoll_ctl: c_long = 21; +pub const SYS_tgkill: c_long = 131; +pub const SYS_mbind: c_long = 235; +pub const SYS_set_mempolicy: c_long = 237; +pub const SYS_get_mempolicy: c_long = 236; +pub const SYS_mq_open: c_long = 180; +pub const SYS_mq_unlink: c_long = 181; +pub const SYS_mq_timedsend: c_long = 182; +pub const SYS_mq_timedreceive: c_long = 183; +pub const SYS_mq_notify: c_long = 184; +pub const SYS_mq_getsetattr: c_long = 185; +pub const SYS_kexec_load: c_long = 104; +pub const SYS_waitid: c_long = 95; +pub const SYS_add_key: c_long = 217; +pub const SYS_request_key: c_long = 218; +pub const SYS_keyctl: c_long = 219; +pub const SYS_ioprio_set: c_long = 30; +pub const SYS_ioprio_get: c_long = 31; +pub const SYS_inotify_add_watch: c_long = 27; +pub const SYS_inotify_rm_watch: c_long = 28; +pub const SYS_migrate_pages: c_long = 238; +pub const SYS_openat: c_long = 56; +pub const SYS_mkdirat: c_long = 34; +pub const SYS_mknodat: c_long = 33; +pub const SYS_fchownat: c_long = 54; +pub const SYS_newfstatat: c_long = 79; +pub const SYS_unlinkat: c_long = 35; +pub const SYS_linkat: c_long = 37; +pub const SYS_symlinkat: c_long = 36; +pub const SYS_readlinkat: c_long = 78; +pub const SYS_fchmodat: c_long = 53; +pub const SYS_faccessat: c_long = 48; +pub const SYS_pselect6: c_long = 72; +pub const SYS_ppoll: c_long = 73; +pub const SYS_unshare: c_long = 97; +pub const SYS_set_robust_list: c_long = 99; +pub const SYS_get_robust_list: c_long = 100; +pub const SYS_splice: c_long = 76; +pub const SYS_tee: c_long = 77; +pub const SYS_sync_file_range: c_long = 84; +pub const SYS_vmsplice: c_long = 75; +pub const SYS_move_pages: c_long = 239; +pub const SYS_utimensat: c_long = 88; +pub const SYS_epoll_pwait: c_long = 22; +pub const SYS_timerfd_create: c_long = 85; +pub const SYS_fallocate: c_long = 47; +pub const SYS_timerfd_settime: c_long = 86; +pub const SYS_timerfd_gettime: c_long = 87; +pub const SYS_accept4: c_long = 242; +pub const SYS_signalfd4: c_long = 74; +pub const SYS_eventfd2: c_long = 19; +pub const SYS_epoll_create1: c_long = 20; +pub const SYS_dup3: c_long = 24; +pub const SYS_pipe2: c_long = 59; +pub const SYS_inotify_init1: c_long = 26; +pub const SYS_preadv: c_long = 69; +pub const SYS_pwritev: c_long = 70; +pub const SYS_rt_tgsigqueueinfo: c_long = 240; +pub const SYS_perf_event_open: c_long = 241; +pub const SYS_recvmmsg: c_long = 243; +pub const SYS_fanotify_init: c_long = 262; +pub const SYS_fanotify_mark: c_long = 263; +pub const SYS_prlimit64: c_long = 261; +pub const SYS_name_to_handle_at: c_long = 264; +pub const SYS_open_by_handle_at: c_long = 265; +pub const SYS_clock_adjtime: c_long = 266; +pub const SYS_syncfs: c_long = 267; +pub const SYS_sendmmsg: c_long = 269; +pub const SYS_setns: c_long = 268; +pub const SYS_getcpu: c_long = 168; +pub const SYS_process_vm_readv: c_long = 270; +pub const SYS_process_vm_writev: c_long = 271; +pub const SYS_kcmp: c_long = 272; +pub const SYS_finit_module: c_long = 273; +pub const SYS_sched_setattr: c_long = 274; +pub const SYS_sched_getattr: c_long = 275; +pub const SYS_renameat2: c_long = 276; +pub const SYS_seccomp: c_long = 277; +pub const SYS_getrandom: c_long = 278; +pub const SYS_memfd_create: c_long = 279; +pub const SYS_bpf: c_long = 280; +pub const SYS_execveat: c_long = 281; +pub const SYS_userfaultfd: c_long = 282; +pub const SYS_membarrier: c_long = 283; +pub const SYS_mlock2: c_long = 284; +pub const SYS_copy_file_range: c_long = 285; +pub const SYS_preadv2: c_long = 286; +pub const SYS_pwritev2: c_long = 287; +pub const SYS_pkey_mprotect: c_long = 288; +pub const SYS_pkey_alloc: c_long = 289; +pub const SYS_pkey_free: c_long = 290; +pub const SYS_statx: c_long = 291; +pub const SYS_rseq: c_long = 293; +pub const SYS_syscall: c_long = 294; +pub const SYS_pidfd_send_signal: c_long = 424; +pub const SYS_io_uring_setup: c_long = 425; +pub const SYS_io_uring_enter: c_long = 426; +pub const SYS_io_uring_register: c_long = 427; +pub const SYS_open_tree: c_long = 428; +pub const SYS_move_mount: c_long = 429; +pub const SYS_fsopen: c_long = 430; +pub const SYS_fsconfig: c_long = 431; +pub const SYS_fsmount: c_long = 432; +pub const SYS_fspick: c_long = 433; +pub const SYS_pidfd_open: c_long = 434; +pub const SYS_clone3: c_long = 435; +pub const SYS_close_range: c_long = 436; +pub const SYS_openat2: c_long = 437; +pub const SYS_pidfd_getfd: c_long = 438; +pub const SYS_faccessat2: c_long = 439; +pub const SYS_process_madvise: c_long = 440; +pub const SYS_epoll_pwait2: c_long = 441; +pub const SYS_mount_setattr: c_long = 442; +pub const SYS_quotactl_fd: c_long = 443; +pub const SYS_landlock_create_ruleset: c_long = 444; +pub const SYS_landlock_add_rule: c_long = 445; +pub const SYS_landlock_restrict_self: c_long = 446; +pub const SYS_memfd_secret: c_long = 447; +pub const SYS_process_mrelease: c_long = 448; +pub const SYS_futex_waitv: c_long = 449; +pub const SYS_set_mempolicy_home_node: c_long = 450; diff --git a/http/vendor/libc/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs new file mode 100644 index 0000000..2d91f98 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs @@ -0,0 +1,885 @@ +use crate::prelude::*; +use crate::{ + off64_t, + off_t, +}; + +pub type wchar_t = i32; + +s! { + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigaction { + pub sa_sigaction: crate::sighandler_t, + pub sa_mask: crate::sigset_t, + pub sa_flags: c_int, + pub sa_restorer: Option, + } + + pub struct statfs { + pub f_type: crate::__fsword_t, + pub f_bsize: crate::__fsword_t, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_fsid: crate::fsid_t, + + pub f_namelen: crate::__fsword_t, + pub f_frsize: crate::__fsword_t, + pub f_flags: crate::__fsword_t, + f_spare: [crate::__fsword_t; 4], + } + + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off_t, + pub l_len: off_t, + pub l_pid: crate::pid_t, + } + + pub struct flock64 { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off64_t, + pub l_len: off64_t, + pub l_pid: crate::pid_t, + } + + pub struct ipc_perm { + __key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: crate::mode_t, + __seq: c_ushort, + __pad1: Padding, + __glibc_reserved1: Padding, + __glibc_reserved2: Padding, + } + + pub struct stat64 { + pub st_dev: crate::dev_t, + __pad1: Padding, + pub __st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + __pad2: Padding, + pub st_size: off64_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt64_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_ulong, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_ulong, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_ulong, + pub st_ino: crate::ino64_t, + } + + pub struct statfs64 { + pub f_type: crate::__fsword_t, + pub f_bsize: crate::__fsword_t, + pub f_blocks: crate::fsblkcnt64_t, + pub f_bfree: crate::fsblkcnt64_t, + pub f_bavail: crate::fsblkcnt64_t, + pub f_files: crate::fsblkcnt64_t, + pub f_ffree: crate::fsblkcnt64_t, + pub f_fsid: crate::fsid_t, + pub f_namelen: crate::__fsword_t, + pub f_frsize: crate::__fsword_t, + pub f_flags: crate::__fsword_t, + pub f_spare: [crate::__fsword_t; 4], + } + + pub struct statvfs64 { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt64_t, + pub f_bfree: crate::fsblkcnt64_t, + pub f_bavail: crate::fsblkcnt64_t, + pub f_files: crate::fsblkcnt64_t, + pub f_ffree: crate::fsblkcnt64_t, + pub f_favail: crate::fsblkcnt64_t, + pub f_fsid: c_ulong, + __f_unused: Padding, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: [c_int; 6], + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, + pub shm_atime: crate::time_t, + __glibc_reserved1: Padding, + pub shm_dtime: crate::time_t, + __glibc_reserved2: Padding, + pub shm_ctime: crate::time_t, + __glibc_reserved3: Padding, + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: crate::shmatt_t, + __glibc_reserved5: Padding, + __glibc_reserved6: Padding, + } + + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + pub msg_stime: crate::time_t, + __glibc_reserved1: Padding, + pub msg_rtime: crate::time_t, + __glibc_reserved2: Padding, + pub msg_ctime: crate::time_t, + __glibc_reserved3: Padding, + pub __msg_cbytes: c_ulong, + pub msg_qnum: crate::msgqnum_t, + pub msg_qbytes: crate::msglen_t, + pub msg_lspid: crate::pid_t, + pub msg_lrpid: crate::pid_t, + __glibc_reserved4: Padding, + __glibc_reserved5: Padding, + } + + pub struct siginfo_t { + pub si_signo: c_int, + pub si_code: c_int, + pub si_errno: c_int, + _pad: Padding<[c_int; 29]>, + _align: [usize; 0], + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_flags: c_int, + pub ss_size: size_t, + } +} + +s_no_extra_traits! { + #[repr(align(2))] + pub struct max_align_t { + priv_: [i8; 20], + } +} + +pub const VEOF: usize = 4; +pub const RTLD_DEEPBIND: c_int = 0x8; +pub const RTLD_GLOBAL: c_int = 0x100; +pub const RTLD_NOLOAD: c_int = 0x4; +pub const O_DIRECT: c_int = 0x10000; +pub const O_DIRECTORY: c_int = 0x4000; +pub const O_NOFOLLOW: c_int = 0x8000; +pub const O_LARGEFILE: c_int = 0x20000; +pub const O_APPEND: c_int = 1024; +pub const O_CREAT: c_int = 64; +pub const O_EXCL: c_int = 128; +pub const O_NOCTTY: c_int = 256; +pub const O_NONBLOCK: c_int = 2048; +pub const O_SYNC: c_int = 1052672; +pub const O_RSYNC: c_int = 1052672; +pub const O_DSYNC: c_int = 4096; +pub const O_FSYNC: c_int = 0x101000; +pub const O_ASYNC: c_int = 0x2000; +pub const O_NDELAY: c_int = 0x800; + +pub const MADV_SOFT_OFFLINE: c_int = 101; +pub const MAP_LOCKED: c_int = 0x02000; +pub const MAP_NORESERVE: c_int = 0x04000; +pub const MAP_ANON: c_int = 0x0020; +pub const MAP_ANONYMOUS: c_int = 0x0020; +pub const MAP_DENYWRITE: c_int = 0x0800; +pub const MAP_EXECUTABLE: c_int = 0x01000; +pub const MAP_POPULATE: c_int = 0x08000; +pub const MAP_NONBLOCK: c_int = 0x010000; +pub const MAP_STACK: c_int = 0x020000; +pub const MAP_HUGETLB: c_int = 0x040000; +pub const MAP_GROWSDOWN: c_int = 0x0100; +pub const MAP_SYNC: c_int = 0x080000; + +pub const EDEADLOCK: c_int = 35; +pub const EUCLEAN: c_int = 117; +pub const ENOTNAM: c_int = 118; +pub const ENAVAIL: c_int = 119; +pub const EISNAM: c_int = 120; +pub const EREMOTEIO: c_int = 121; +pub const EDEADLK: c_int = 35; +pub const ENAMETOOLONG: c_int = 36; +pub const ENOLCK: c_int = 37; +pub const ENOSYS: c_int = 38; +pub const ENOTEMPTY: c_int = 39; +pub const ELOOP: c_int = 40; +pub const ENOMSG: c_int = 42; +pub const EIDRM: c_int = 43; +pub const ECHRNG: c_int = 44; +pub const EL2NSYNC: c_int = 45; +pub const EL3HLT: c_int = 46; +pub const EL3RST: c_int = 47; +pub const ELNRNG: c_int = 48; +pub const EUNATCH: c_int = 49; +pub const ENOCSI: c_int = 50; +pub const EL2HLT: c_int = 51; +pub const EBADE: c_int = 52; +pub const EBADR: c_int = 53; +pub const EXFULL: c_int = 54; +pub const ENOANO: c_int = 55; +pub const EBADRQC: c_int = 56; +pub const EBADSLT: c_int = 57; +pub const EMULTIHOP: c_int = 72; +pub const EOVERFLOW: c_int = 75; +pub const ENOTUNIQ: c_int = 76; +pub const EBADFD: c_int = 77; +pub const EBADMSG: c_int = 74; +pub const EREMCHG: c_int = 78; +pub const ELIBACC: c_int = 79; +pub const ELIBBAD: c_int = 80; +pub const ELIBSCN: c_int = 81; +pub const ELIBMAX: c_int = 82; +pub const ELIBEXEC: c_int = 83; +pub const EILSEQ: c_int = 84; +pub const ERESTART: c_int = 85; +pub const ESTRPIPE: c_int = 86; +pub const EUSERS: c_int = 87; +pub const ENOTSOCK: c_int = 88; +pub const EDESTADDRREQ: c_int = 89; +pub const EMSGSIZE: c_int = 90; +pub const EPROTOTYPE: c_int = 91; +pub const ENOPROTOOPT: c_int = 92; +pub const EPROTONOSUPPORT: c_int = 93; +pub const ESOCKTNOSUPPORT: c_int = 94; +pub const EOPNOTSUPP: c_int = 95; +pub const EPFNOSUPPORT: c_int = 96; +pub const EAFNOSUPPORT: c_int = 97; +pub const EADDRINUSE: c_int = 98; +pub const EADDRNOTAVAIL: c_int = 99; +pub const ENETDOWN: c_int = 100; +pub const ENETUNREACH: c_int = 101; +pub const ENETRESET: c_int = 102; +pub const ECONNABORTED: c_int = 103; +pub const ECONNRESET: c_int = 104; +pub const ENOBUFS: c_int = 105; +pub const EISCONN: c_int = 106; +pub const ENOTCONN: c_int = 107; +pub const ESHUTDOWN: c_int = 108; +pub const ETOOMANYREFS: c_int = 109; +pub const ETIMEDOUT: c_int = 110; +pub const ECONNREFUSED: c_int = 111; +pub const EHOSTDOWN: c_int = 112; +pub const EHOSTUNREACH: c_int = 113; +pub const EALREADY: c_int = 114; +pub const EINPROGRESS: c_int = 115; +pub const ESTALE: c_int = 116; +pub const EDQUOT: c_int = 122; +pub const ENOMEDIUM: c_int = 123; +pub const EMEDIUMTYPE: c_int = 124; +pub const ECANCELED: c_int = 125; +pub const ENOKEY: c_int = 126; +pub const EKEYEXPIRED: c_int = 127; +pub const EKEYREVOKED: c_int = 128; +pub const EKEYREJECTED: c_int = 129; +pub const EOWNERDEAD: c_int = 130; +pub const ENOTRECOVERABLE: c_int = 131; +pub const EHWPOISON: c_int = 133; +pub const ERFKILL: c_int = 132; + +pub const SA_SIGINFO: c_int = 0x00000004; +pub const SA_NOCLDWAIT: c_int = 0x00000002; + +pub const SOCK_STREAM: c_int = 1; +pub const SOCK_DGRAM: c_int = 2; + +pub const F_GETLK: c_int = 5; +pub const F_GETOWN: c_int = 9; +pub const F_SETOWN: c_int = 8; + +pub const PTRACE_GETFPXREGS: c_uint = 18; +pub const PTRACE_SETFPXREGS: c_uint = 19; +pub const PTRACE_SYSEMU: c_uint = 31; +pub const PTRACE_SYSEMU_SINGLESTEP: c_uint = 32; + +pub const MCL_CURRENT: c_int = 0x0001; +pub const MCL_FUTURE: c_int = 0x0002; +pub const MCL_ONFAULT: c_int = 0x0004; + +pub const POLLWRNORM: c_short = 0x100; +pub const POLLWRBAND: c_short = 0x200; + +pub const EFD_NONBLOCK: c_int = 0x800; +pub const SFD_NONBLOCK: c_int = 0x0800; + +pub const SIGCHLD: c_int = 17; +pub const SIGBUS: c_int = 7; +pub const SIGUSR1: c_int = 10; +pub const SIGUSR2: c_int = 12; +pub const SIGCONT: c_int = 18; +pub const SIGSTOP: c_int = 19; +pub const SIGTSTP: c_int = 20; +pub const SIGURG: c_int = 23; +pub const SIGIO: c_int = 29; +pub const SIGSYS: c_int = 31; +pub const SIGSTKFLT: c_int = 16; +#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] +pub const SIGUNUSED: c_int = 31; +pub const SIGPOLL: c_int = 29; +pub const SIGPWR: c_int = 30; +pub const SIG_SETMASK: c_int = 2; +pub const SIG_BLOCK: c_int = 0x000000; +pub const SIG_UNBLOCK: c_int = 0x01; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGSTKSZ: size_t = 8192; +pub const MINSIGSTKSZ: size_t = 2048; +pub const CBAUD: crate::tcflag_t = 0o0010017; +pub const TAB1: crate::tcflag_t = 0x00000800; +pub const TAB2: crate::tcflag_t = 0x00001000; +pub const TAB3: crate::tcflag_t = 0x00001800; +pub const CR1: crate::tcflag_t = 0x00000200; +pub const CR2: crate::tcflag_t = 0x00000400; +pub const CR3: crate::tcflag_t = 0x00000600; +pub const FF1: crate::tcflag_t = 0x00008000; +pub const BS1: crate::tcflag_t = 0x00002000; +pub const VT1: crate::tcflag_t = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: crate::tcflag_t = 0x00000400; +pub const IXOFF: crate::tcflag_t = 0x00001000; +pub const ONLCR: crate::tcflag_t = 0x4; +pub const CSIZE: crate::tcflag_t = 0x00000030; +pub const CS6: crate::tcflag_t = 0x00000010; +pub const CS7: crate::tcflag_t = 0x00000020; +pub const CS8: crate::tcflag_t = 0x00000030; +pub const CSTOPB: crate::tcflag_t = 0x00000040; +pub const CREAD: crate::tcflag_t = 0x00000080; +pub const PARENB: crate::tcflag_t = 0x00000100; +pub const PARODD: crate::tcflag_t = 0x00000200; +pub const HUPCL: crate::tcflag_t = 0x00000400; +pub const CLOCAL: crate::tcflag_t = 0x00000800; +pub const ECHOKE: crate::tcflag_t = 0x00000800; +pub const ECHOE: crate::tcflag_t = 0x00000010; +pub const ECHOK: crate::tcflag_t = 0x00000020; +pub const ECHONL: crate::tcflag_t = 0x00000040; +pub const ECHOPRT: crate::tcflag_t = 0x00000400; +pub const ECHOCTL: crate::tcflag_t = 0x00000200; +pub const ISIG: crate::tcflag_t = 0x00000001; +pub const ICANON: crate::tcflag_t = 0x00000002; +pub const PENDIN: crate::tcflag_t = 0x00004000; +pub const NOFLSH: crate::tcflag_t = 0x00000080; +pub const CIBAUD: crate::tcflag_t = 0o02003600000; +pub const CBAUDEX: crate::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: crate::tcflag_t = 0o000002; +pub const NLDLY: crate::tcflag_t = 0o000400; +pub const CRDLY: crate::tcflag_t = 0o003000; +pub const TABDLY: crate::tcflag_t = 0o014000; +pub const BSDLY: crate::tcflag_t = 0o020000; +pub const FFDLY: crate::tcflag_t = 0o100000; +pub const VTDLY: crate::tcflag_t = 0o040000; +pub const XTABS: crate::tcflag_t = 0o014000; + +pub const B0: crate::speed_t = 0o000000; +pub const B50: crate::speed_t = 0o000001; +pub const B75: crate::speed_t = 0o000002; +pub const B110: crate::speed_t = 0o000003; +pub const B134: crate::speed_t = 0o000004; +pub const B150: crate::speed_t = 0o000005; +pub const B200: crate::speed_t = 0o000006; +pub const B300: crate::speed_t = 0o000007; +pub const B600: crate::speed_t = 0o000010; +pub const B1200: crate::speed_t = 0o000011; +pub const B1800: crate::speed_t = 0o000012; +pub const B2400: crate::speed_t = 0o000013; +pub const B4800: crate::speed_t = 0o000014; +pub const B9600: crate::speed_t = 0o000015; +pub const B19200: crate::speed_t = 0o000016; +pub const B38400: crate::speed_t = 0o000017; +pub const EXTA: crate::speed_t = B19200; +pub const EXTB: crate::speed_t = B38400; +pub const B57600: crate::speed_t = 0o010001; +pub const B115200: crate::speed_t = 0o010002; +pub const B230400: crate::speed_t = 0o010003; +pub const B460800: crate::speed_t = 0o010004; +pub const B500000: crate::speed_t = 0o010005; +pub const B576000: crate::speed_t = 0o010006; +pub const B921600: crate::speed_t = 0o010007; +pub const B1000000: crate::speed_t = 0o010010; +pub const B1152000: crate::speed_t = 0o010011; +pub const B1500000: crate::speed_t = 0o010012; +pub const B2000000: crate::speed_t = 0o010013; +pub const B2500000: crate::speed_t = 0o010014; +pub const B3000000: crate::speed_t = 0o010015; +pub const B3500000: crate::speed_t = 0o010016; +pub const B4000000: crate::speed_t = 0o010017; + +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: crate::tcflag_t = 0x00008000; +pub const TOSTOP: crate::tcflag_t = 0x00000100; +pub const FLUSHO: crate::tcflag_t = 0x00001000; +pub const EXTPROC: crate::tcflag_t = 0x00010000; + +pub const TCSANOW: c_int = 0; +pub const TCSADRAIN: c_int = 1; +pub const TCSAFLUSH: c_int = 2; + +pub const SYS_restart_syscall: c_long = 0; +pub const SYS_exit: c_long = 1; +pub const SYS_fork: c_long = 2; +pub const SYS_read: c_long = 3; +pub const SYS_write: c_long = 4; +pub const SYS_open: c_long = 5; +pub const SYS_close: c_long = 6; +pub const SYS_waitpid: c_long = 7; +pub const SYS_creat: c_long = 8; +pub const SYS_link: c_long = 9; +pub const SYS_unlink: c_long = 10; +pub const SYS_execve: c_long = 11; +pub const SYS_chdir: c_long = 12; +pub const SYS_time32: c_long = 13; +pub const SYS_mknod: c_long = 14; +pub const SYS_chmod: c_long = 15; +pub const SYS_chown16: c_long = 16; +pub const SYS_stat: c_long = 18; +pub const SYS_lseek: c_long = 19; +pub const SYS_getpid: c_long = 20; +pub const SYS_mount: c_long = 21; +pub const SYS_oldumount: c_long = 22; +pub const SYS_setuid16: c_long = 23; +pub const SYS_getuid16: c_long = 24; +pub const SYS_stime32: c_long = 25; +pub const SYS_ptrace: c_long = 26; +pub const SYS_alarm: c_long = 27; +pub const SYS_fstat: c_long = 28; +pub const SYS_pause: c_long = 29; +pub const SYS_utime32: c_long = 30; +pub const SYS_access: c_long = 33; +pub const SYS_nice: c_long = 34; +pub const SYS_sync: c_long = 36; +pub const SYS_kill: c_long = 37; +pub const SYS_rename: c_long = 38; +pub const SYS_mkdir: c_long = 39; +pub const SYS_rmdir: c_long = 40; +pub const SYS_dup: c_long = 41; +pub const SYS_pipe: c_long = 42; +pub const SYS_times: c_long = 43; +pub const SYS_brk: c_long = 45; +pub const SYS_setgid16: c_long = 46; +pub const SYS_getgid16: c_long = 47; +pub const SYS_signal: c_long = 48; +pub const SYS_geteuid16: c_long = 49; +pub const SYS_getegid16: c_long = 50; +pub const SYS_acct: c_long = 51; +pub const SYS_umount: c_long = 52; +pub const SYS_ioctl: c_long = 54; +pub const SYS_fcntl: c_long = 55; +pub const SYS_setpgid: c_long = 57; +pub const SYS_umask: c_long = 60; +pub const SYS_chroot: c_long = 61; +pub const SYS_ustat: c_long = 62; +pub const SYS_dup2: c_long = 63; +pub const SYS_getppid: c_long = 64; +pub const SYS_getpgrp: c_long = 65; +pub const SYS_setsid: c_long = 66; +pub const SYS_sigaction: c_long = 67; +pub const SYS_sgetmask: c_long = 68; +pub const SYS_ssetmask: c_long = 69; +pub const SYS_setreuid16: c_long = 70; +pub const SYS_setregid16: c_long = 71; +pub const SYS_sigsuspend: c_long = 72; +pub const SYS_sigpending: c_long = 73; +pub const SYS_sethostname: c_long = 74; +pub const SYS_setrlimit: c_long = 75; +pub const SYS_old_getrlimit: c_long = 76; +pub const SYS_getrusage: c_long = 77; +pub const SYS_gettimeofday: c_long = 78; +pub const SYS_settimeofday: c_long = 79; +pub const SYS_getgroups16: c_long = 80; +pub const SYS_setgroups16: c_long = 81; +pub const SYS_old_select: c_long = 82; +pub const SYS_symlink: c_long = 83; +pub const SYS_lstat: c_long = 84; +pub const SYS_readlink: c_long = 85; +pub const SYS_uselib: c_long = 86; +pub const SYS_swapon: c_long = 87; +pub const SYS_reboot: c_long = 88; +pub const SYS_old_readdir: c_long = 89; +pub const SYS_old_mmap: c_long = 90; +pub const SYS_munmap: c_long = 91; +pub const SYS_truncate: c_long = 92; +pub const SYS_ftruncate: c_long = 93; +pub const SYS_fchmod: c_long = 94; +pub const SYS_fchown16: c_long = 95; +pub const SYS_getpriority: c_long = 96; +pub const SYS_setpriority: c_long = 97; +pub const SYS_statfs: c_long = 99; +pub const SYS_fstatfs: c_long = 100; +pub const SYS_socketcall: c_long = 102; +pub const SYS_syslog: c_long = 103; +pub const SYS_setitimer: c_long = 104; +pub const SYS_getitimer: c_long = 105; +pub const SYS_newstat: c_long = 106; +pub const SYS_newlstat: c_long = 107; +pub const SYS_newfstat: c_long = 108; +pub const SYS_vhangup: c_long = 111; +pub const SYS_wait4: c_long = 114; +pub const SYS_swapoff: c_long = 115; +pub const SYS_sysinfo: c_long = 116; +pub const SYS_ipc: c_long = 117; +pub const SYS_fsync: c_long = 118; +pub const SYS_sigreturn: c_long = 119; +pub const SYS_clone: c_long = 120; +pub const SYS_setdomainname: c_long = 121; +pub const SYS_newuname: c_long = 122; +pub const SYS_cacheflush: c_long = 123; +pub const SYS_adjtimex_time32: c_long = 124; +pub const SYS_mprotect: c_long = 125; +pub const SYS_sigprocmask: c_long = 126; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_create_module: c_long = 127; +pub const SYS_init_module: c_long = 128; +pub const SYS_delete_module: c_long = 129; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_get_kernel_syms: c_long = 130; +pub const SYS_quotactl: c_long = 131; +pub const SYS_getpgid: c_long = 132; +pub const SYS_fchdir: c_long = 133; +pub const SYS_bdflush: c_long = 134; +pub const SYS_sysfs: c_long = 135; +pub const SYS_personality: c_long = 136; +pub const SYS_setfsuid16: c_long = 138; +pub const SYS_setfsgid16: c_long = 139; +pub const SYS_llseek: c_long = 140; +pub const SYS_getdents: c_long = 141; +pub const SYS_select: c_long = 142; +pub const SYS_flock: c_long = 143; +pub const SYS_msync: c_long = 144; +pub const SYS_readv: c_long = 145; +pub const SYS_writev: c_long = 146; +pub const SYS_getsid: c_long = 147; +pub const SYS_fdatasync: c_long = 148; +pub const SYS__sysctl: c_long = 149; +pub const SYS_mlock: c_long = 150; +pub const SYS_munlock: c_long = 151; +pub const SYS_mlockall: c_long = 152; +pub const SYS_munlockall: c_long = 153; +pub const SYS_sched_setparam: c_long = 154; +pub const SYS_sched_getparam: c_long = 155; +pub const SYS_sched_setscheduler: c_long = 156; +pub const SYS_sched_getscheduler: c_long = 157; +pub const SYS_sched_yield: c_long = 158; +pub const SYS_sched_get_priority_max: c_long = 159; +pub const SYS_sched_get_priority_min: c_long = 160; +pub const SYS_sched_rr_get_interval_time32: c_long = 161; +pub const SYS_nanosleep_time32: c_long = 162; +pub const SYS_mremap: c_long = 163; +pub const SYS_setresuid16: c_long = 164; +pub const SYS_getresuid16: c_long = 165; +pub const SYS_getpagesize: c_long = 166; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_query_module: c_long = 167; +pub const SYS_poll: c_long = 168; +pub const SYS_nfsservctl: c_long = 169; +pub const SYS_setresgid16: c_long = 170; +pub const SYS_getresgid16: c_long = 171; +pub const SYS_prctl: c_long = 172; +pub const SYS_rt_sigreturn: c_long = 173; +pub const SYS_rt_sigaction: c_long = 174; +pub const SYS_rt_sigprocmask: c_long = 175; +pub const SYS_rt_sigpending: c_long = 176; +pub const SYS_rt_sigtimedwait_time32: c_long = 177; +pub const SYS_rt_sigqueueinfo: c_long = 178; +pub const SYS_rt_sigsuspend: c_long = 179; +pub const SYS_pread64: c_long = 180; +pub const SYS_pwrite64: c_long = 181; +pub const SYS_lchown16: c_long = 182; +pub const SYS_getcwd: c_long = 183; +pub const SYS_capget: c_long = 184; +pub const SYS_capset: c_long = 185; +pub const SYS_sigaltstack: c_long = 186; +pub const SYS_sendfile: c_long = 187; +pub const SYS_getpmsg: c_long = 188; +pub const SYS_putpmsg: c_long = 189; +pub const SYS_vfork: c_long = 190; +pub const SYS_getrlimit: c_long = 191; +pub const SYS_mmap2: c_long = 192; +pub const SYS_truncate64: c_long = 193; +pub const SYS_ftruncate64: c_long = 194; +pub const SYS_stat64: c_long = 195; +pub const SYS_lstat64: c_long = 196; +pub const SYS_fstat64: c_long = 197; +pub const SYS_chown: c_long = 198; +pub const SYS_getuid: c_long = 199; +pub const SYS_getgid: c_long = 200; +pub const SYS_geteuid: c_long = 201; +pub const SYS_getegid: c_long = 202; +pub const SYS_setreuid: c_long = 203; +pub const SYS_setregid: c_long = 204; +pub const SYS_getgroups: c_long = 205; +pub const SYS_setgroups: c_long = 206; +pub const SYS_fchown: c_long = 207; +pub const SYS_setresuid: c_long = 208; +pub const SYS_getresuid: c_long = 209; +pub const SYS_setresgid: c_long = 210; +pub const SYS_getresgid: c_long = 211; +pub const SYS_lchown: c_long = 212; +pub const SYS_setuid: c_long = 213; +pub const SYS_setgid: c_long = 214; +pub const SYS_setfsuid: c_long = 215; +pub const SYS_setfsgid: c_long = 216; +pub const SYS_pivot_root: c_long = 217; +pub const SYS_getdents64: c_long = 220; +pub const SYS_gettid: c_long = 221; +pub const SYS_tkill: c_long = 222; +pub const SYS_setxattr: c_long = 223; +pub const SYS_lsetxattr: c_long = 224; +pub const SYS_fsetxattr: c_long = 225; +pub const SYS_getxattr: c_long = 226; +pub const SYS_lgetxattr: c_long = 227; +pub const SYS_fgetxattr: c_long = 228; +pub const SYS_listxattr: c_long = 229; +pub const SYS_llistxattr: c_long = 230; +pub const SYS_flistxattr: c_long = 231; +pub const SYS_removexattr: c_long = 232; +pub const SYS_lremovexattr: c_long = 233; +pub const SYS_fremovexattr: c_long = 234; +pub const SYS_futex_time32: c_long = 235; +pub const SYS_sendfile64: c_long = 236; +pub const SYS_mincore: c_long = 237; +pub const SYS_madvise: c_long = 238; +pub const SYS_fcntl64: c_long = 239; +pub const SYS_readahead: c_long = 240; +pub const SYS_io_setup: c_long = 241; +pub const SYS_io_destroy: c_long = 242; +pub const SYS_io_getevents_time32: c_long = 243; +pub const SYS_io_submit: c_long = 244; +pub const SYS_io_cancel: c_long = 245; +pub const SYS_fadvise64: c_long = 246; +pub const SYS_exit_group: c_long = 247; +pub const SYS_lookup_dcookie: c_long = 248; +pub const SYS_epoll_create: c_long = 249; +pub const SYS_epoll_ctl: c_long = 250; +pub const SYS_epoll_wait: c_long = 251; +pub const SYS_remap_file_pages: c_long = 252; +pub const SYS_set_tid_address: c_long = 253; +pub const SYS_timer_create: c_long = 254; +pub const SYS_timer_settime32: c_long = 255; +pub const SYS_timer_gettime32: c_long = 256; +pub const SYS_timer_getoverrun: c_long = 257; +pub const SYS_timer_delete: c_long = 258; +pub const SYS_clock_settime32: c_long = 259; +pub const SYS_clock_gettime32: c_long = 260; +pub const SYS_clock_getres_time32: c_long = 261; +pub const SYS_clock_nanosleep_time32: c_long = 262; +pub const SYS_statfs64: c_long = 263; +pub const SYS_fstatfs64: c_long = 264; +pub const SYS_tgkill: c_long = 265; +pub const SYS_utimes_time32: c_long = 266; +pub const SYS_fadvise64_64: c_long = 267; +pub const SYS_mbind: c_long = 268; +pub const SYS_get_mempolicy: c_long = 269; +pub const SYS_set_mempolicy: c_long = 270; +pub const SYS_mq_open: c_long = 271; +pub const SYS_mq_unlink: c_long = 272; +pub const SYS_mq_timedsend_time32: c_long = 273; +pub const SYS_mq_timedreceive_time32: c_long = 274; +pub const SYS_mq_notify: c_long = 275; +pub const SYS_mq_getsetattr: c_long = 276; +pub const SYS_waitid: c_long = 277; +pub const SYS_add_key: c_long = 279; +pub const SYS_request_key: c_long = 280; +pub const SYS_keyctl: c_long = 281; +pub const SYS_ioprio_set: c_long = 282; +pub const SYS_ioprio_get: c_long = 283; +pub const SYS_inotify_init: c_long = 284; +pub const SYS_inotify_add_watch: c_long = 285; +pub const SYS_inotify_rm_watch: c_long = 286; +pub const SYS_migrate_pages: c_long = 287; +pub const SYS_openat: c_long = 288; +pub const SYS_mkdirat: c_long = 289; +pub const SYS_mknodat: c_long = 290; +pub const SYS_fchownat: c_long = 291; +pub const SYS_futimesat_time32: c_long = 292; +pub const SYS_fstatat64: c_long = 293; +pub const SYS_unlinkat: c_long = 294; +pub const SYS_renameat: c_long = 295; +pub const SYS_linkat: c_long = 296; +pub const SYS_symlinkat: c_long = 297; +pub const SYS_readlinkat: c_long = 298; +pub const SYS_fchmodat: c_long = 299; +pub const SYS_faccessat: c_long = 300; +pub const SYS_pselect6_time32: c_long = 301; +pub const SYS_ppoll_time32: c_long = 302; +pub const SYS_unshare: c_long = 303; +pub const SYS_set_robust_list: c_long = 304; +pub const SYS_get_robust_list: c_long = 305; +pub const SYS_splice: c_long = 306; +pub const SYS_sync_file_range: c_long = 307; +pub const SYS_tee: c_long = 308; +pub const SYS_vmsplice: c_long = 309; +pub const SYS_move_pages: c_long = 310; +pub const SYS_sched_setaffinity: c_long = 311; +pub const SYS_sched_getaffinity: c_long = 312; +pub const SYS_kexec_load: c_long = 313; +pub const SYS_getcpu: c_long = 314; +pub const SYS_epoll_pwait: c_long = 315; +pub const SYS_utimensat_time32: c_long = 316; +pub const SYS_signalfd: c_long = 317; +pub const SYS_timerfd_create: c_long = 318; +pub const SYS_eventfd: c_long = 319; +pub const SYS_fallocate: c_long = 320; +pub const SYS_timerfd_settime32: c_long = 321; +pub const SYS_timerfd_gettime32: c_long = 322; +pub const SYS_signalfd4: c_long = 323; +pub const SYS_eventfd2: c_long = 324; +pub const SYS_epoll_create1: c_long = 325; +pub const SYS_dup3: c_long = 326; +pub const SYS_pipe2: c_long = 327; +pub const SYS_inotify_init1: c_long = 328; +pub const SYS_preadv: c_long = 329; +pub const SYS_pwritev: c_long = 330; +pub const SYS_rt_tgsigqueueinfo: c_long = 331; +pub const SYS_perf_event_open: c_long = 332; +pub const SYS_get_thread_area: c_long = 333; +pub const SYS_set_thread_area: c_long = 334; +pub const SYS_atomic_cmpxchg_32: c_long = 335; +pub const SYS_atomic_barrier: c_long = 336; +pub const SYS_fanotify_init: c_long = 337; +pub const SYS_fanotify_mark: c_long = 338; +pub const SYS_prlimit64: c_long = 339; +pub const SYS_name_to_handle_at: c_long = 340; +pub const SYS_open_by_handle_at: c_long = 341; +pub const SYS_clock_adjtime32: c_long = 342; +pub const SYS_syncfs: c_long = 343; +pub const SYS_setns: c_long = 344; +pub const SYS_process_vm_readv: c_long = 345; +pub const SYS_process_vm_writev: c_long = 346; +pub const SYS_kcmp: c_long = 347; +pub const SYS_finit_module: c_long = 348; +pub const SYS_sched_setattr: c_long = 349; +pub const SYS_sched_getattr: c_long = 350; +pub const SYS_renameat2: c_long = 351; +pub const SYS_getrandom: c_long = 352; +pub const SYS_memfd_create: c_long = 353; +pub const SYS_bpf: c_long = 354; +pub const SYS_execveat: c_long = 355; +pub const SYS_socket: c_long = 356; +pub const SYS_socketpair: c_long = 357; +pub const SYS_bind: c_long = 358; +pub const SYS_connect: c_long = 359; +pub const SYS_listen: c_long = 360; +pub const SYS_accept4: c_long = 361; +pub const SYS_getsockopt: c_long = 362; +pub const SYS_setsockopt: c_long = 363; +pub const SYS_getsockname: c_long = 364; +pub const SYS_getpeername: c_long = 365; +pub const SYS_sendto: c_long = 366; +pub const SYS_sendmsg: c_long = 367; +pub const SYS_recvfrom: c_long = 368; +pub const SYS_recvmsg: c_long = 369; +pub const SYS_shutdown: c_long = 370; +pub const SYS_recvmmsg_time32: c_long = 371; +pub const SYS_sendmmsg: c_long = 372; +pub const SYS_userfaultfd: c_long = 373; +pub const SYS_membarrier: c_long = 374; +pub const SYS_mlock2: c_long = 375; +pub const SYS_copy_file_range: c_long = 376; +pub const SYS_preadv2: c_long = 377; +pub const SYS_pwritev2: c_long = 378; +pub const SYS_statx: c_long = 379; +pub const SYS_seccomp: c_long = 380; +pub const SYS_pkey_mprotect: c_long = 381; +pub const SYS_pkey_alloc: c_long = 382; +pub const SYS_pkey_free: c_long = 383; +pub const SYS_rseq: c_long = 384; +pub const SYS_semget: c_long = 393; +pub const SYS_semctl: c_long = 394; +pub const SYS_shmget: c_long = 395; +pub const SYS_shmctl: c_long = 396; +pub const SYS_shmat: c_long = 397; +pub const SYS_shmdt: c_long = 398; +pub const SYS_msgget: c_long = 399; +pub const SYS_msgsnd: c_long = 400; +pub const SYS_msgrcv: c_long = 401; +pub const SYS_msgctl: c_long = 402; +pub const SYS_clock_gettime: c_long = 403; +pub const SYS_clock_settime: c_long = 404; +pub const SYS_clock_adjtime: c_long = 405; +pub const SYS_clock_getres: c_long = 406; +pub const SYS_clock_nanosleep: c_long = 407; +pub const SYS_timer_gettime: c_long = 408; +pub const SYS_timer_settime: c_long = 409; +pub const SYS_timerfd_gettime: c_long = 410; +pub const SYS_timerfd_settime: c_long = 411; +pub const SYS_utimensat: c_long = 412; +pub const SYS_pselect6: c_long = 413; +pub const SYS_ppoll: c_long = 414; +pub const SYS_io_pgetevents: c_long = 416; +pub const SYS_recvmmsg: c_long = 417; +pub const SYS_mq_timedsend: c_long = 418; +pub const SYS_mq_timedreceive: c_long = 419; +pub const SYS_semtimedop: c_long = 420; +pub const SYS_rt_sigtimedwait: c_long = 421; +pub const SYS_futex: c_long = 422; +pub const SYS_sched_rr_get_interval: c_long = 423; +pub const SYS_pidfd_send_signal: c_long = 424; +pub const SYS_io_uring_setup: c_long = 425; +pub const SYS_io_uring_enter: c_long = 426; +pub const SYS_io_uring_register: c_long = 427; +pub const SYS_open_tree: c_long = 428; +pub const SYS_move_mount: c_long = 429; +pub const SYS_fsopen: c_long = 430; +pub const SYS_fsconfig: c_long = 431; +pub const SYS_fsmount: c_long = 432; +pub const SYS_fspick: c_long = 433; +pub const SYS_pidfd_open: c_long = 434; +pub const SYS_clone3: c_long = 435; +pub const SYS_close_range: c_long = 436; +pub const SYS_openat2: c_long = 437; +pub const SYS_pidfd_getfd: c_long = 438; +pub const SYS_faccessat2: c_long = 439; +pub const SYS_process_madvise: c_long = 440; +pub const SYS_epoll_pwait2: c_long = 441; +pub const SYS_mount_setattr: c_long = 442; +pub const SYS_quotactl_fd: c_long = 443; +pub const SYS_landlock_create_ruleset: c_long = 444; +pub const SYS_landlock_add_rule: c_long = 445; +pub const SYS_landlock_restrict_self: c_long = 446; +pub const SYS_process_mrelease: c_long = 448; +pub const SYS_futex_waitv: c_long = 449; +pub const SYS_set_mempolicy_home_node: c_long = 450; +pub const SYS_cachestat: c_long = 451; +pub const SYS_fchmodat2: c_long = 452; +pub const SYS_map_shadow_stack: c_long = 453; +pub const SYS_futex_wake: c_long = 454; +pub const SYS_futex_wait: c_long = 455; +pub const SYS_futex_requeue: c_long = 456; +pub const SYS_statmount: c_long = 457; +pub const SYS_listmount: c_long = 458; +pub const SYS_lsm_get_self_attr: c_long = 459; +pub const SYS_lsm_set_self_attr: c_long = 460; +pub const SYS_lsm_list_modules: c_long = 461; +pub const SYS_mseal: c_long = 462; +pub const SYS_setxattrat: c_long = 463; +pub const SYS_getxattrat: c_long = 464; +pub const SYS_listxattrat: c_long = 465; +pub const SYS_removexattrat: c_long = 466; +pub const SYS_open_tree_attr: c_long = 467; +pub const SYS_file_get_attr: c_long = 468; +pub const SYS_file_set_attr: c_long = 469; diff --git a/http/vendor/libc/src/unix/linux_like/linux/gnu/b32/mips/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/gnu/b32/mips/mod.rs new file mode 100644 index 0000000..18bb193 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/gnu/b32/mips/mod.rs @@ -0,0 +1,928 @@ +use crate::prelude::*; +use crate::{ + off64_t, + off_t, +}; + +pub type wchar_t = i32; + +s! { + pub struct stat { + #[cfg(not(gnu_time_bits64))] + pub st_dev: c_ulong, + #[cfg(gnu_time_bits64)] + pub st_dev: crate::dev_t, + + #[cfg(not(gnu_time_bits64))] + st_pad1: Padding<[c_long; 3]>, + + pub st_ino: crate::ino_t, + + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + + #[cfg(not(gnu_time_bits64))] + pub st_rdev: c_ulong, + #[cfg(gnu_time_bits64)] + pub st_rdev: crate::dev_t, + + #[cfg(not(gnu_file_offset_bits64))] + st_pad2: Padding<[c_long; 2]>, + #[cfg(all(not(gnu_time_bits64), gnu_file_offset_bits64))] + st_pad2: Padding<[c_long; 3]>, + + pub st_size: off_t, + + #[cfg(not(gnu_file_offset_bits64))] + st_pad3: Padding, + + #[cfg(gnu_time_bits64)] + pub st_blksize: crate::blksize_t, + #[cfg(gnu_time_bits64)] + pub st_blocks: crate::blkcnt_t, + + pub st_atime: crate::time_t, + #[cfg(gnu_time_bits64)] + _atime_pad: Padding, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + #[cfg(gnu_time_bits64)] + _mtime_pad: Padding, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + #[cfg(gnu_time_bits64)] + _ctime_pad: Padding, + pub st_ctime_nsec: c_long, + + #[cfg(not(gnu_time_bits64))] + pub st_blksize: crate::blksize_t, + #[cfg(all(not(gnu_time_bits64), gnu_file_offset_bits64))] + st_pad4: Padding, + #[cfg(not(gnu_time_bits64))] + pub st_blocks: crate::blkcnt_t, + #[cfg(not(gnu_time_bits64))] + st_pad5: Padding<[c_long; 14]>, + } + + pub struct stat64 { + #[cfg(not(gnu_time_bits64))] + pub st_dev: c_ulong, + #[cfg(gnu_time_bits64)] + pub st_dev: crate::dev_t, + + #[cfg(not(gnu_time_bits64))] + st_pad1: Padding<[c_long; 3]>, + + pub st_ino: crate::ino64_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + + #[cfg(not(gnu_time_bits64))] + pub st_rdev: c_ulong, + #[cfg(gnu_time_bits64)] + pub st_rdev: crate::dev_t, + + #[cfg(not(gnu_time_bits64))] + st_pad2: Padding<[c_long; 3]>, + + pub st_size: off64_t, + + #[cfg(gnu_time_bits64)] + pub st_blksize: crate::blksize_t, + #[cfg(gnu_time_bits64)] + pub st_blocks: crate::blkcnt_t, + + pub st_atime: crate::time_t, + #[cfg(gnu_time_bits64)] + _atime_pad: Padding, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + #[cfg(gnu_time_bits64)] + _mtime_pad: Padding, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + #[cfg(gnu_time_bits64)] + _ctime_pad: Padding, + pub st_ctime_nsec: c_long, + + #[cfg(not(gnu_time_bits64))] + pub st_blksize: crate::blksize_t, + #[cfg(not(gnu_time_bits64))] + st_pad3: Padding, + #[cfg(not(gnu_time_bits64))] + pub st_blocks: crate::blkcnt64_t, + #[cfg(not(gnu_time_bits64))] + st_pad5: Padding<[c_long; 14]>, + } + + pub struct statfs { + pub f_type: c_long, + pub f_bsize: c_long, + pub f_frsize: c_long, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_files: crate::fsblkcnt_t, + pub f_ffree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_fsid: crate::fsid_t, + + pub f_namelen: c_long, + pub f_flags: c_long, + f_spare: [c_long; 5], + } + + pub struct statfs64 { + pub f_type: c_long, + pub f_bsize: c_long, + pub f_frsize: c_long, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_bavail: u64, + pub f_fsid: crate::fsid_t, + pub f_namelen: c_long, + pub f_flags: c_long, + pub f_spare: [c_long; 5], + } + + pub struct statvfs64 { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: c_ulong, + __f_unused: Padding, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: [c_int; 6], + } + + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigaction { + pub sa_flags: c_int, + pub sa_sigaction: crate::sighandler_t, + pub sa_mask: crate::sigset_t, + pub sa_restorer: Option, + _resv: [c_int; 1], + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_size: size_t, + pub ss_flags: c_int, + } + + pub struct siginfo_t { + pub si_signo: c_int, + pub si_code: c_int, + pub si_errno: c_int, + pub _pad: [c_int; 29], + } + + pub struct ipc_perm { + pub __key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: c_uint, + pub __seq: c_ushort, + __pad1: Padding, + __unused1: Padding, + __unused2: Padding, + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, + pub shm_atime: crate::time_t, + pub shm_dtime: crate::time_t, + pub shm_ctime: crate::time_t, + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: crate::shmatt_t, + __unused4: Padding, + __unused5: Padding, + } + + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + #[cfg(all(not(gnu_time_bits64), target_endian = "big"))] + __glibc_reserved1: Padding, + pub msg_stime: crate::time_t, + #[cfg(all(not(gnu_time_bits64), target_endian = "little"))] + __glibc_reserved1: Padding, + #[cfg(all(not(gnu_time_bits64), target_endian = "big"))] + __glibc_reserved2: Padding, + pub msg_rtime: crate::time_t, + #[cfg(all(not(gnu_time_bits64), target_endian = "little"))] + __glibc_reserved2: Padding, + #[cfg(all(not(gnu_time_bits64), target_endian = "big"))] + __glibc_reserved3: Padding, + pub msg_ctime: crate::time_t, + #[cfg(target_endian = "little")] + __glibc_reserved3: Padding, + __msg_cbytes: c_ulong, + pub msg_qnum: crate::msgqnum_t, + pub msg_qbytes: crate::msglen_t, + pub msg_lspid: crate::pid_t, + pub msg_lrpid: crate::pid_t, + __glibc_reserved4: Padding, + __glibc_reserved5: Padding, + } + + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off_t, + pub l_len: off_t, + #[cfg(not(gnu_file_offset_bits64))] + pub l_sysid: c_long, + pub l_pid: crate::pid_t, + #[cfg(not(gnu_file_offset_bits64))] + __glibc_reserved0: Padding<[c_long; 4]>, + } +} + +s_no_extra_traits! { + #[repr(align(8))] + pub struct max_align_t { + priv_: [f32; 4], + } +} + +pub const O_LARGEFILE: c_int = 0x2000; + +pub const SYS_syscall: c_long = 4000 + 0; +pub const SYS_exit: c_long = 4000 + 1; +pub const SYS_fork: c_long = 4000 + 2; +pub const SYS_read: c_long = 4000 + 3; +pub const SYS_write: c_long = 4000 + 4; +pub const SYS_open: c_long = 4000 + 5; +pub const SYS_close: c_long = 4000 + 6; +pub const SYS_waitpid: c_long = 4000 + 7; +pub const SYS_creat: c_long = 4000 + 8; +pub const SYS_link: c_long = 4000 + 9; +pub const SYS_unlink: c_long = 4000 + 10; +pub const SYS_execve: c_long = 4000 + 11; +pub const SYS_chdir: c_long = 4000 + 12; +pub const SYS_time: c_long = 4000 + 13; +pub const SYS_mknod: c_long = 4000 + 14; +pub const SYS_chmod: c_long = 4000 + 15; +pub const SYS_lchown: c_long = 4000 + 16; +pub const SYS_break: c_long = 4000 + 17; +pub const SYS_lseek: c_long = 4000 + 19; +pub const SYS_getpid: c_long = 4000 + 20; +pub const SYS_mount: c_long = 4000 + 21; +pub const SYS_umount: c_long = 4000 + 22; +pub const SYS_setuid: c_long = 4000 + 23; +pub const SYS_getuid: c_long = 4000 + 24; +pub const SYS_stime: c_long = 4000 + 25; +pub const SYS_ptrace: c_long = 4000 + 26; +pub const SYS_alarm: c_long = 4000 + 27; +pub const SYS_pause: c_long = 4000 + 29; +pub const SYS_utime: c_long = 4000 + 30; +pub const SYS_stty: c_long = 4000 + 31; +pub const SYS_gtty: c_long = 4000 + 32; +pub const SYS_access: c_long = 4000 + 33; +pub const SYS_nice: c_long = 4000 + 34; +pub const SYS_ftime: c_long = 4000 + 35; +pub const SYS_sync: c_long = 4000 + 36; +pub const SYS_kill: c_long = 4000 + 37; +pub const SYS_rename: c_long = 4000 + 38; +pub const SYS_mkdir: c_long = 4000 + 39; +pub const SYS_rmdir: c_long = 4000 + 40; +pub const SYS_dup: c_long = 4000 + 41; +pub const SYS_pipe: c_long = 4000 + 42; +pub const SYS_times: c_long = 4000 + 43; +pub const SYS_prof: c_long = 4000 + 44; +pub const SYS_brk: c_long = 4000 + 45; +pub const SYS_setgid: c_long = 4000 + 46; +pub const SYS_getgid: c_long = 4000 + 47; +pub const SYS_signal: c_long = 4000 + 48; +pub const SYS_geteuid: c_long = 4000 + 49; +pub const SYS_getegid: c_long = 4000 + 50; +pub const SYS_acct: c_long = 4000 + 51; +pub const SYS_umount2: c_long = 4000 + 52; +pub const SYS_lock: c_long = 4000 + 53; +pub const SYS_ioctl: c_long = 4000 + 54; +pub const SYS_fcntl: c_long = 4000 + 55; +pub const SYS_mpx: c_long = 4000 + 56; +pub const SYS_setpgid: c_long = 4000 + 57; +pub const SYS_ulimit: c_long = 4000 + 58; +pub const SYS_umask: c_long = 4000 + 60; +pub const SYS_chroot: c_long = 4000 + 61; +pub const SYS_ustat: c_long = 4000 + 62; +pub const SYS_dup2: c_long = 4000 + 63; +pub const SYS_getppid: c_long = 4000 + 64; +pub const SYS_getpgrp: c_long = 4000 + 65; +pub const SYS_setsid: c_long = 4000 + 66; +pub const SYS_sigaction: c_long = 4000 + 67; +pub const SYS_sgetmask: c_long = 4000 + 68; +pub const SYS_ssetmask: c_long = 4000 + 69; +pub const SYS_setreuid: c_long = 4000 + 70; +pub const SYS_setregid: c_long = 4000 + 71; +pub const SYS_sigsuspend: c_long = 4000 + 72; +pub const SYS_sigpending: c_long = 4000 + 73; +pub const SYS_sethostname: c_long = 4000 + 74; +pub const SYS_setrlimit: c_long = 4000 + 75; +pub const SYS_getrlimit: c_long = 4000 + 76; +pub const SYS_getrusage: c_long = 4000 + 77; +pub const SYS_gettimeofday: c_long = 4000 + 78; +pub const SYS_settimeofday: c_long = 4000 + 79; +pub const SYS_getgroups: c_long = 4000 + 80; +pub const SYS_setgroups: c_long = 4000 + 81; +pub const SYS_symlink: c_long = 4000 + 83; +pub const SYS_readlink: c_long = 4000 + 85; +pub const SYS_uselib: c_long = 4000 + 86; +pub const SYS_swapon: c_long = 4000 + 87; +pub const SYS_reboot: c_long = 4000 + 88; +pub const SYS_readdir: c_long = 4000 + 89; +pub const SYS_mmap: c_long = 4000 + 90; +pub const SYS_munmap: c_long = 4000 + 91; +pub const SYS_truncate: c_long = 4000 + 92; +pub const SYS_ftruncate: c_long = 4000 + 93; +pub const SYS_fchmod: c_long = 4000 + 94; +pub const SYS_fchown: c_long = 4000 + 95; +pub const SYS_getpriority: c_long = 4000 + 96; +pub const SYS_setpriority: c_long = 4000 + 97; +pub const SYS_profil: c_long = 4000 + 98; +pub const SYS_statfs: c_long = 4000 + 99; +pub const SYS_fstatfs: c_long = 4000 + 100; +pub const SYS_ioperm: c_long = 4000 + 101; +pub const SYS_socketcall: c_long = 4000 + 102; +pub const SYS_syslog: c_long = 4000 + 103; +pub const SYS_setitimer: c_long = 4000 + 104; +pub const SYS_getitimer: c_long = 4000 + 105; +pub const SYS_stat: c_long = 4000 + 106; +pub const SYS_lstat: c_long = 4000 + 107; +pub const SYS_fstat: c_long = 4000 + 108; +pub const SYS_iopl: c_long = 4000 + 110; +pub const SYS_vhangup: c_long = 4000 + 111; +pub const SYS_idle: c_long = 4000 + 112; +pub const SYS_vm86: c_long = 4000 + 113; +pub const SYS_wait4: c_long = 4000 + 114; +pub const SYS_swapoff: c_long = 4000 + 115; +pub const SYS_sysinfo: c_long = 4000 + 116; +pub const SYS_ipc: c_long = 4000 + 117; +pub const SYS_fsync: c_long = 4000 + 118; +pub const SYS_sigreturn: c_long = 4000 + 119; +pub const SYS_clone: c_long = 4000 + 120; +pub const SYS_setdomainname: c_long = 4000 + 121; +pub const SYS_uname: c_long = 4000 + 122; +pub const SYS_modify_ldt: c_long = 4000 + 123; +pub const SYS_adjtimex: c_long = 4000 + 124; +pub const SYS_mprotect: c_long = 4000 + 125; +pub const SYS_sigprocmask: c_long = 4000 + 126; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_create_module: c_long = 4000 + 127; +pub const SYS_init_module: c_long = 4000 + 128; +pub const SYS_delete_module: c_long = 4000 + 129; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_get_kernel_syms: c_long = 4000 + 130; +pub const SYS_quotactl: c_long = 4000 + 131; +pub const SYS_getpgid: c_long = 4000 + 132; +pub const SYS_fchdir: c_long = 4000 + 133; +pub const SYS_bdflush: c_long = 4000 + 134; +pub const SYS_sysfs: c_long = 4000 + 135; +pub const SYS_personality: c_long = 4000 + 136; +pub const SYS_afs_syscall: c_long = 4000 + 137; +pub const SYS_setfsuid: c_long = 4000 + 138; +pub const SYS_setfsgid: c_long = 4000 + 139; +pub const SYS__llseek: c_long = 4000 + 140; +pub const SYS_getdents: c_long = 4000 + 141; +pub const SYS__newselect: c_long = 4000 + 142; +pub const SYS_flock: c_long = 4000 + 143; +pub const SYS_msync: c_long = 4000 + 144; +pub const SYS_readv: c_long = 4000 + 145; +pub const SYS_writev: c_long = 4000 + 146; +pub const SYS_cacheflush: c_long = 4000 + 147; +pub const SYS_cachectl: c_long = 4000 + 148; +pub const SYS_sysmips: c_long = 4000 + 149; +pub const SYS_getsid: c_long = 4000 + 151; +pub const SYS_fdatasync: c_long = 4000 + 152; +pub const SYS__sysctl: c_long = 4000 + 153; +pub const SYS_mlock: c_long = 4000 + 154; +pub const SYS_munlock: c_long = 4000 + 155; +pub const SYS_mlockall: c_long = 4000 + 156; +pub const SYS_munlockall: c_long = 4000 + 157; +pub const SYS_sched_setparam: c_long = 4000 + 158; +pub const SYS_sched_getparam: c_long = 4000 + 159; +pub const SYS_sched_setscheduler: c_long = 4000 + 160; +pub const SYS_sched_getscheduler: c_long = 4000 + 161; +pub const SYS_sched_yield: c_long = 4000 + 162; +pub const SYS_sched_get_priority_max: c_long = 4000 + 163; +pub const SYS_sched_get_priority_min: c_long = 4000 + 164; +pub const SYS_sched_rr_get_interval: c_long = 4000 + 165; +pub const SYS_nanosleep: c_long = 4000 + 166; +pub const SYS_mremap: c_long = 4000 + 167; +pub const SYS_accept: c_long = 4000 + 168; +pub const SYS_bind: c_long = 4000 + 169; +pub const SYS_connect: c_long = 4000 + 170; +pub const SYS_getpeername: c_long = 4000 + 171; +pub const SYS_getsockname: c_long = 4000 + 172; +pub const SYS_getsockopt: c_long = 4000 + 173; +pub const SYS_listen: c_long = 4000 + 174; +pub const SYS_recv: c_long = 4000 + 175; +pub const SYS_recvfrom: c_long = 4000 + 176; +pub const SYS_recvmsg: c_long = 4000 + 177; +pub const SYS_send: c_long = 4000 + 178; +pub const SYS_sendmsg: c_long = 4000 + 179; +pub const SYS_sendto: c_long = 4000 + 180; +pub const SYS_setsockopt: c_long = 4000 + 181; +pub const SYS_shutdown: c_long = 4000 + 182; +pub const SYS_socket: c_long = 4000 + 183; +pub const SYS_socketpair: c_long = 4000 + 184; +pub const SYS_setresuid: c_long = 4000 + 185; +pub const SYS_getresuid: c_long = 4000 + 186; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_query_module: c_long = 4000 + 187; +pub const SYS_poll: c_long = 4000 + 188; +pub const SYS_nfsservctl: c_long = 4000 + 189; +pub const SYS_setresgid: c_long = 4000 + 190; +pub const SYS_getresgid: c_long = 4000 + 191; +pub const SYS_prctl: c_long = 4000 + 192; +pub const SYS_rt_sigreturn: c_long = 4000 + 193; +pub const SYS_rt_sigaction: c_long = 4000 + 194; +pub const SYS_rt_sigprocmask: c_long = 4000 + 195; +pub const SYS_rt_sigpending: c_long = 4000 + 196; +pub const SYS_rt_sigtimedwait: c_long = 4000 + 197; +pub const SYS_rt_sigqueueinfo: c_long = 4000 + 198; +pub const SYS_rt_sigsuspend: c_long = 4000 + 199; +pub const SYS_pread64: c_long = 4000 + 200; +pub const SYS_pwrite64: c_long = 4000 + 201; +pub const SYS_chown: c_long = 4000 + 202; +pub const SYS_getcwd: c_long = 4000 + 203; +pub const SYS_capget: c_long = 4000 + 204; +pub const SYS_capset: c_long = 4000 + 205; +pub const SYS_sigaltstack: c_long = 4000 + 206; +pub const SYS_sendfile: c_long = 4000 + 207; +pub const SYS_getpmsg: c_long = 4000 + 208; +pub const SYS_putpmsg: c_long = 4000 + 209; +pub const SYS_mmap2: c_long = 4000 + 210; +pub const SYS_truncate64: c_long = 4000 + 211; +pub const SYS_ftruncate64: c_long = 4000 + 212; +pub const SYS_stat64: c_long = 4000 + 213; +pub const SYS_lstat64: c_long = 4000 + 214; +pub const SYS_fstat64: c_long = 4000 + 215; +pub const SYS_pivot_root: c_long = 4000 + 216; +pub const SYS_mincore: c_long = 4000 + 217; +pub const SYS_madvise: c_long = 4000 + 218; +pub const SYS_getdents64: c_long = 4000 + 219; +pub const SYS_fcntl64: c_long = 4000 + 220; +pub const SYS_gettid: c_long = 4000 + 222; +pub const SYS_readahead: c_long = 4000 + 223; +pub const SYS_setxattr: c_long = 4000 + 224; +pub const SYS_lsetxattr: c_long = 4000 + 225; +pub const SYS_fsetxattr: c_long = 4000 + 226; +pub const SYS_getxattr: c_long = 4000 + 227; +pub const SYS_lgetxattr: c_long = 4000 + 228; +pub const SYS_fgetxattr: c_long = 4000 + 229; +pub const SYS_listxattr: c_long = 4000 + 230; +pub const SYS_llistxattr: c_long = 4000 + 231; +pub const SYS_flistxattr: c_long = 4000 + 232; +pub const SYS_removexattr: c_long = 4000 + 233; +pub const SYS_lremovexattr: c_long = 4000 + 234; +pub const SYS_fremovexattr: c_long = 4000 + 235; +pub const SYS_tkill: c_long = 4000 + 236; +pub const SYS_sendfile64: c_long = 4000 + 237; +pub const SYS_futex: c_long = 4000 + 238; +pub const SYS_sched_setaffinity: c_long = 4000 + 239; +pub const SYS_sched_getaffinity: c_long = 4000 + 240; +pub const SYS_io_setup: c_long = 4000 + 241; +pub const SYS_io_destroy: c_long = 4000 + 242; +pub const SYS_io_getevents: c_long = 4000 + 243; +pub const SYS_io_submit: c_long = 4000 + 244; +pub const SYS_io_cancel: c_long = 4000 + 245; +pub const SYS_exit_group: c_long = 4000 + 246; +pub const SYS_lookup_dcookie: c_long = 4000 + 247; +pub const SYS_epoll_create: c_long = 4000 + 248; +pub const SYS_epoll_ctl: c_long = 4000 + 249; +pub const SYS_epoll_wait: c_long = 4000 + 250; +pub const SYS_remap_file_pages: c_long = 4000 + 251; +pub const SYS_set_tid_address: c_long = 4000 + 252; +pub const SYS_restart_syscall: c_long = 4000 + 253; +pub const SYS_fadvise64: c_long = 4000 + 254; +pub const SYS_statfs64: c_long = 4000 + 255; +pub const SYS_fstatfs64: c_long = 4000 + 256; +pub const SYS_timer_create: c_long = 4000 + 257; +pub const SYS_timer_settime: c_long = 4000 + 258; +pub const SYS_timer_gettime: c_long = 4000 + 259; +pub const SYS_timer_getoverrun: c_long = 4000 + 260; +pub const SYS_timer_delete: c_long = 4000 + 261; +pub const SYS_clock_settime: c_long = 4000 + 262; +pub const SYS_clock_gettime: c_long = 4000 + 263; +pub const SYS_clock_getres: c_long = 4000 + 264; +pub const SYS_clock_nanosleep: c_long = 4000 + 265; +pub const SYS_tgkill: c_long = 4000 + 266; +pub const SYS_utimes: c_long = 4000 + 267; +pub const SYS_mbind: c_long = 4000 + 268; +pub const SYS_get_mempolicy: c_long = 4000 + 269; +pub const SYS_set_mempolicy: c_long = 4000 + 270; +pub const SYS_mq_open: c_long = 4000 + 271; +pub const SYS_mq_unlink: c_long = 4000 + 272; +pub const SYS_mq_timedsend: c_long = 4000 + 273; +pub const SYS_mq_timedreceive: c_long = 4000 + 274; +pub const SYS_mq_notify: c_long = 4000 + 275; +pub const SYS_mq_getsetattr: c_long = 4000 + 276; +pub const SYS_vserver: c_long = 4000 + 277; +pub const SYS_waitid: c_long = 4000 + 278; +/* pub const SYS_sys_setaltroot: c_long = 4000 + 279; */ +pub const SYS_add_key: c_long = 4000 + 280; +pub const SYS_request_key: c_long = 4000 + 281; +pub const SYS_keyctl: c_long = 4000 + 282; +pub const SYS_set_thread_area: c_long = 4000 + 283; +pub const SYS_inotify_init: c_long = 4000 + 284; +pub const SYS_inotify_add_watch: c_long = 4000 + 285; +pub const SYS_inotify_rm_watch: c_long = 4000 + 286; +pub const SYS_migrate_pages: c_long = 4000 + 287; +pub const SYS_openat: c_long = 4000 + 288; +pub const SYS_mkdirat: c_long = 4000 + 289; +pub const SYS_mknodat: c_long = 4000 + 290; +pub const SYS_fchownat: c_long = 4000 + 291; +pub const SYS_futimesat: c_long = 4000 + 292; +pub const SYS_fstatat64: c_long = 4000 + 293; +pub const SYS_unlinkat: c_long = 4000 + 294; +pub const SYS_renameat: c_long = 4000 + 295; +pub const SYS_linkat: c_long = 4000 + 296; +pub const SYS_symlinkat: c_long = 4000 + 297; +pub const SYS_readlinkat: c_long = 4000 + 298; +pub const SYS_fchmodat: c_long = 4000 + 299; +pub const SYS_faccessat: c_long = 4000 + 300; +pub const SYS_pselect6: c_long = 4000 + 301; +pub const SYS_ppoll: c_long = 4000 + 302; +pub const SYS_unshare: c_long = 4000 + 303; +pub const SYS_splice: c_long = 4000 + 304; +pub const SYS_sync_file_range: c_long = 4000 + 305; +pub const SYS_tee: c_long = 4000 + 306; +pub const SYS_vmsplice: c_long = 4000 + 307; +pub const SYS_move_pages: c_long = 4000 + 308; +pub const SYS_set_robust_list: c_long = 4000 + 309; +pub const SYS_get_robust_list: c_long = 4000 + 310; +pub const SYS_kexec_load: c_long = 4000 + 311; +pub const SYS_getcpu: c_long = 4000 + 312; +pub const SYS_epoll_pwait: c_long = 4000 + 313; +pub const SYS_ioprio_set: c_long = 4000 + 314; +pub const SYS_ioprio_get: c_long = 4000 + 315; +pub const SYS_utimensat: c_long = 4000 + 316; +pub const SYS_signalfd: c_long = 4000 + 317; +pub const SYS_timerfd: c_long = 4000 + 318; +pub const SYS_eventfd: c_long = 4000 + 319; +pub const SYS_fallocate: c_long = 4000 + 320; +pub const SYS_timerfd_create: c_long = 4000 + 321; +pub const SYS_timerfd_gettime: c_long = 4000 + 322; +pub const SYS_timerfd_settime: c_long = 4000 + 323; +pub const SYS_signalfd4: c_long = 4000 + 324; +pub const SYS_eventfd2: c_long = 4000 + 325; +pub const SYS_epoll_create1: c_long = 4000 + 326; +pub const SYS_dup3: c_long = 4000 + 327; +pub const SYS_pipe2: c_long = 4000 + 328; +pub const SYS_inotify_init1: c_long = 4000 + 329; +pub const SYS_preadv: c_long = 4000 + 330; +pub const SYS_pwritev: c_long = 4000 + 331; +pub const SYS_rt_tgsigqueueinfo: c_long = 4000 + 332; +pub const SYS_perf_event_open: c_long = 4000 + 333; +pub const SYS_accept4: c_long = 4000 + 334; +pub const SYS_recvmmsg: c_long = 4000 + 335; +pub const SYS_fanotify_init: c_long = 4000 + 336; +pub const SYS_fanotify_mark: c_long = 4000 + 337; +pub const SYS_prlimit64: c_long = 4000 + 338; +pub const SYS_name_to_handle_at: c_long = 4000 + 339; +pub const SYS_open_by_handle_at: c_long = 4000 + 340; +pub const SYS_clock_adjtime: c_long = 4000 + 341; +pub const SYS_syncfs: c_long = 4000 + 342; +pub const SYS_sendmmsg: c_long = 4000 + 343; +pub const SYS_setns: c_long = 4000 + 344; +pub const SYS_process_vm_readv: c_long = 4000 + 345; +pub const SYS_process_vm_writev: c_long = 4000 + 346; +pub const SYS_kcmp: c_long = 4000 + 347; +pub const SYS_finit_module: c_long = 4000 + 348; +pub const SYS_sched_setattr: c_long = 4000 + 349; +pub const SYS_sched_getattr: c_long = 4000 + 350; +pub const SYS_renameat2: c_long = 4000 + 351; +pub const SYS_seccomp: c_long = 4000 + 352; +pub const SYS_getrandom: c_long = 4000 + 353; +pub const SYS_memfd_create: c_long = 4000 + 354; +pub const SYS_bpf: c_long = 4000 + 355; +pub const SYS_execveat: c_long = 4000 + 356; +pub const SYS_userfaultfd: c_long = 4000 + 357; +pub const SYS_membarrier: c_long = 4000 + 358; +pub const SYS_mlock2: c_long = 4000 + 359; +pub const SYS_copy_file_range: c_long = 4000 + 360; +pub const SYS_preadv2: c_long = 4000 + 361; +pub const SYS_pwritev2: c_long = 4000 + 362; +pub const SYS_pkey_mprotect: c_long = 4000 + 363; +pub const SYS_pkey_alloc: c_long = 4000 + 364; +pub const SYS_pkey_free: c_long = 4000 + 365; +pub const SYS_statx: c_long = 4000 + 366; +pub const SYS_rseq: c_long = 4000 + 367; +pub const SYS_pidfd_send_signal: c_long = 4000 + 424; +pub const SYS_io_uring_setup: c_long = 4000 + 425; +pub const SYS_io_uring_enter: c_long = 4000 + 426; +pub const SYS_io_uring_register: c_long = 4000 + 427; +pub const SYS_open_tree: c_long = 4000 + 428; +pub const SYS_move_mount: c_long = 4000 + 429; +pub const SYS_fsopen: c_long = 4000 + 430; +pub const SYS_fsconfig: c_long = 4000 + 431; +pub const SYS_fsmount: c_long = 4000 + 432; +pub const SYS_fspick: c_long = 4000 + 433; +pub const SYS_pidfd_open: c_long = 4000 + 434; +pub const SYS_clone3: c_long = 4000 + 435; +pub const SYS_close_range: c_long = 4000 + 436; +pub const SYS_openat2: c_long = 4000 + 437; +pub const SYS_pidfd_getfd: c_long = 4000 + 438; +pub const SYS_faccessat2: c_long = 4000 + 439; +pub const SYS_process_madvise: c_long = 4000 + 440; +pub const SYS_epoll_pwait2: c_long = 4000 + 441; +pub const SYS_mount_setattr: c_long = 4000 + 442; +pub const SYS_quotactl_fd: c_long = 4000 + 443; +pub const SYS_landlock_create_ruleset: c_long = 4000 + 444; +pub const SYS_landlock_add_rule: c_long = 4000 + 445; +pub const SYS_landlock_restrict_self: c_long = 4000 + 446; +pub const SYS_memfd_secret: c_long = 4000 + 447; +pub const SYS_process_mrelease: c_long = 4000 + 448; +pub const SYS_futex_waitv: c_long = 4000 + 449; +pub const SYS_set_mempolicy_home_node: c_long = 4000 + 450; + +pub const O_DIRECT: c_int = 0x8000; +pub const O_DIRECTORY: c_int = 0x10000; +pub const O_NOFOLLOW: c_int = 0x20000; + +pub const O_APPEND: c_int = 8; +pub const O_CREAT: c_int = 256; +pub const O_EXCL: c_int = 1024; +pub const O_NOCTTY: c_int = 2048; +pub const O_NONBLOCK: c_int = 128; +pub const O_SYNC: c_int = 0x4010; +pub const O_RSYNC: c_int = 0x4010; +pub const O_DSYNC: c_int = 0x10; +pub const O_FSYNC: c_int = 0x4010; +pub const O_ASYNC: c_int = 0x1000; +pub const O_NDELAY: c_int = 0x80; + +pub const EDEADLK: c_int = 45; +pub const ENAMETOOLONG: c_int = 78; +pub const ENOLCK: c_int = 46; +pub const ENOSYS: c_int = 89; +pub const ENOTEMPTY: c_int = 93; +pub const ELOOP: c_int = 90; +pub const ENOMSG: c_int = 35; +pub const EIDRM: c_int = 36; +pub const ECHRNG: c_int = 37; +pub const EL2NSYNC: c_int = 38; +pub const EL3HLT: c_int = 39; +pub const EL3RST: c_int = 40; +pub const ELNRNG: c_int = 41; +pub const EUNATCH: c_int = 42; +pub const ENOCSI: c_int = 43; +pub const EL2HLT: c_int = 44; +pub const EBADE: c_int = 50; +pub const EBADR: c_int = 51; +pub const EXFULL: c_int = 52; +pub const ENOANO: c_int = 53; +pub const EBADRQC: c_int = 54; +pub const EBADSLT: c_int = 55; +pub const EDEADLOCK: c_int = 56; +pub const EMULTIHOP: c_int = 74; +pub const EOVERFLOW: c_int = 79; +pub const ENOTUNIQ: c_int = 80; +pub const EBADFD: c_int = 81; +pub const EBADMSG: c_int = 77; +pub const EREMCHG: c_int = 82; +pub const ELIBACC: c_int = 83; +pub const ELIBBAD: c_int = 84; +pub const ELIBSCN: c_int = 85; +pub const ELIBMAX: c_int = 86; +pub const ELIBEXEC: c_int = 87; +pub const EILSEQ: c_int = 88; +pub const ERESTART: c_int = 91; +pub const ESTRPIPE: c_int = 92; +pub const EUSERS: c_int = 94; +pub const ENOTSOCK: c_int = 95; +pub const EDESTADDRREQ: c_int = 96; +pub const EMSGSIZE: c_int = 97; +pub const EPROTOTYPE: c_int = 98; +pub const ENOPROTOOPT: c_int = 99; +pub const EPROTONOSUPPORT: c_int = 120; +pub const ESOCKTNOSUPPORT: c_int = 121; +pub const EOPNOTSUPP: c_int = 122; +pub const EPFNOSUPPORT: c_int = 123; +pub const EAFNOSUPPORT: c_int = 124; +pub const EADDRINUSE: c_int = 125; +pub const EADDRNOTAVAIL: c_int = 126; +pub const ENETDOWN: c_int = 127; +pub const ENETUNREACH: c_int = 128; +pub const ENETRESET: c_int = 129; +pub const ECONNABORTED: c_int = 130; +pub const ECONNRESET: c_int = 131; +pub const ENOBUFS: c_int = 132; +pub const EISCONN: c_int = 133; +pub const ENOTCONN: c_int = 134; +pub const ESHUTDOWN: c_int = 143; +pub const ETOOMANYREFS: c_int = 144; +pub const ETIMEDOUT: c_int = 145; +pub const ECONNREFUSED: c_int = 146; +pub const EHOSTDOWN: c_int = 147; +pub const EHOSTUNREACH: c_int = 148; +pub const EALREADY: c_int = 149; +pub const EINPROGRESS: c_int = 150; +pub const ESTALE: c_int = 151; +pub const EUCLEAN: c_int = 135; +pub const ENOTNAM: c_int = 137; +pub const ENAVAIL: c_int = 138; +pub const EISNAM: c_int = 139; +pub const EREMOTEIO: c_int = 140; +pub const EDQUOT: c_int = 1133; +pub const ENOMEDIUM: c_int = 159; +pub const EMEDIUMTYPE: c_int = 160; +pub const ECANCELED: c_int = 158; +pub const ENOKEY: c_int = 161; +pub const EKEYEXPIRED: c_int = 162; +pub const EKEYREVOKED: c_int = 163; +pub const EKEYREJECTED: c_int = 164; +pub const EOWNERDEAD: c_int = 165; +pub const ENOTRECOVERABLE: c_int = 166; +pub const ERFKILL: c_int = 167; + +pub const MAP_NORESERVE: c_int = 0x400; +pub const MAP_ANON: c_int = 0x800; +pub const MAP_ANONYMOUS: c_int = 0x800; +pub const MAP_GROWSDOWN: c_int = 0x1000; +pub const MAP_DENYWRITE: c_int = 0x2000; +pub const MAP_EXECUTABLE: c_int = 0x4000; +pub const MAP_LOCKED: c_int = 0x8000; +pub const MAP_POPULATE: c_int = 0x10000; +pub const MAP_NONBLOCK: c_int = 0x20000; +pub const MAP_STACK: c_int = 0x40000; + +pub const SOCK_STREAM: c_int = 2; +pub const SOCK_DGRAM: c_int = 1; + +pub const SA_SIGINFO: c_int = 0x00000008; +pub const SA_NOCLDWAIT: c_int = 0x00010000; + +pub const SIGEMT: c_int = 7; +pub const SIGCHLD: c_int = 18; +pub const SIGBUS: c_int = 10; +pub const SIGTTIN: c_int = 26; +pub const SIGTTOU: c_int = 27; +pub const SIGXCPU: c_int = 30; +pub const SIGXFSZ: c_int = 31; +pub const SIGVTALRM: c_int = 28; +pub const SIGPROF: c_int = 29; +pub const SIGWINCH: c_int = 20; +pub const SIGUSR1: c_int = 16; +pub const SIGUSR2: c_int = 17; +pub const SIGCONT: c_int = 25; +pub const SIGSTOP: c_int = 23; +pub const SIGTSTP: c_int = 24; +pub const SIGURG: c_int = 21; +pub const SIGIO: c_int = 22; +pub const SIGSYS: c_int = 12; +pub const SIGPOLL: c_int = 22; +pub const SIGPWR: c_int = 19; +pub const SIG_SETMASK: c_int = 3; +pub const SIG_BLOCK: c_int = 0x1; +pub const SIG_UNBLOCK: c_int = 0x2; + +pub const POLLWRNORM: c_short = 0x004; +pub const POLLWRBAND: c_short = 0x100; + +pub const VEOF: usize = 16; +pub const VEOL: usize = 17; +pub const VEOL2: usize = 6; +pub const VMIN: usize = 4; +pub const IEXTEN: crate::tcflag_t = 0x00000100; +pub const TOSTOP: crate::tcflag_t = 0x00008000; +pub const FLUSHO: crate::tcflag_t = 0x00002000; +pub const EXTPROC: crate::tcflag_t = 0o200000; +pub const TCSANOW: c_int = 0x540e; +pub const TCSADRAIN: c_int = 0x540f; +pub const TCSAFLUSH: c_int = 0x5410; + +pub const PTRACE_GETFPXREGS: c_uint = 18; +pub const PTRACE_SETFPXREGS: c_uint = 19; + +pub const MAP_HUGETLB: c_int = 0x080000; + +pub const EFD_NONBLOCK: c_int = 0x80; + +cfg_if! { + if #[cfg(gnu_file_offset_bits64)] { + pub const F_GETLK: c_int = 33; + } else { + pub const F_GETLK: c_int = 14; + } +} +pub const F_GETOWN: c_int = 23; +pub const F_SETOWN: c_int = 24; + +pub const SFD_NONBLOCK: c_int = 0x80; + +pub const RTLD_DEEPBIND: c_int = 0x10; +pub const RTLD_GLOBAL: c_int = 0x4; +pub const RTLD_NOLOAD: c_int = 0x8; + +pub const MCL_CURRENT: c_int = 0x0001; +pub const MCL_FUTURE: c_int = 0x0002; +pub const MCL_ONFAULT: c_int = 0x0004; + +pub const SIGSTKSZ: size_t = 8192; +pub const MINSIGSTKSZ: size_t = 2048; +pub const CBAUD: crate::tcflag_t = 0o0010017; +pub const TAB1: crate::tcflag_t = 0x00000800; +pub const TAB2: crate::tcflag_t = 0x00001000; +pub const TAB3: crate::tcflag_t = 0x00001800; +pub const CR1: crate::tcflag_t = 0x00000200; +pub const CR2: crate::tcflag_t = 0x00000400; +pub const CR3: crate::tcflag_t = 0x00000600; +pub const FF1: crate::tcflag_t = 0x00008000; +pub const BS1: crate::tcflag_t = 0x00002000; +pub const VT1: crate::tcflag_t = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: crate::tcflag_t = 0x00000400; +pub const IXOFF: crate::tcflag_t = 0x00001000; +pub const ONLCR: crate::tcflag_t = 0x4; +pub const CSIZE: crate::tcflag_t = 0x00000030; +pub const CS6: crate::tcflag_t = 0x00000010; +pub const CS7: crate::tcflag_t = 0x00000020; +pub const CS8: crate::tcflag_t = 0x00000030; +pub const CSTOPB: crate::tcflag_t = 0x00000040; +pub const CREAD: crate::tcflag_t = 0x00000080; +pub const PARENB: crate::tcflag_t = 0x00000100; +pub const PARODD: crate::tcflag_t = 0x00000200; +pub const HUPCL: crate::tcflag_t = 0x00000400; +pub const CLOCAL: crate::tcflag_t = 0x00000800; +pub const ECHOKE: crate::tcflag_t = 0x00000800; +pub const ECHOE: crate::tcflag_t = 0x00000010; +pub const ECHOK: crate::tcflag_t = 0x00000020; +pub const ECHONL: crate::tcflag_t = 0x00000040; +pub const ECHOPRT: crate::tcflag_t = 0x00000400; +pub const ECHOCTL: crate::tcflag_t = 0x00000200; +pub const ISIG: crate::tcflag_t = 0x00000001; +pub const ICANON: crate::tcflag_t = 0x00000002; +pub const PENDIN: crate::tcflag_t = 0x00004000; +pub const NOFLSH: crate::tcflag_t = 0x00000080; +pub const CIBAUD: crate::tcflag_t = 0o02003600000; +pub const CBAUDEX: crate::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: crate::tcflag_t = 0o000002; +pub const NLDLY: crate::tcflag_t = 0o000400; +pub const CRDLY: crate::tcflag_t = 0o003000; +pub const TABDLY: crate::tcflag_t = 0o014000; +pub const BSDLY: crate::tcflag_t = 0o020000; +pub const FFDLY: crate::tcflag_t = 0o100000; +pub const VTDLY: crate::tcflag_t = 0o040000; +pub const XTABS: crate::tcflag_t = 0o014000; + +pub const B0: crate::speed_t = 0o000000; +pub const B50: crate::speed_t = 0o000001; +pub const B75: crate::speed_t = 0o000002; +pub const B110: crate::speed_t = 0o000003; +pub const B134: crate::speed_t = 0o000004; +pub const B150: crate::speed_t = 0o000005; +pub const B200: crate::speed_t = 0o000006; +pub const B300: crate::speed_t = 0o000007; +pub const B600: crate::speed_t = 0o000010; +pub const B1200: crate::speed_t = 0o000011; +pub const B1800: crate::speed_t = 0o000012; +pub const B2400: crate::speed_t = 0o000013; +pub const B4800: crate::speed_t = 0o000014; +pub const B9600: crate::speed_t = 0o000015; +pub const B19200: crate::speed_t = 0o000016; +pub const B38400: crate::speed_t = 0o000017; +pub const EXTA: crate::speed_t = B19200; +pub const EXTB: crate::speed_t = B38400; +pub const B57600: crate::speed_t = 0o010001; +pub const B115200: crate::speed_t = 0o010002; +pub const B230400: crate::speed_t = 0o010003; +pub const B460800: crate::speed_t = 0o010004; +pub const B500000: crate::speed_t = 0o010005; +pub const B576000: crate::speed_t = 0o010006; +pub const B921600: crate::speed_t = 0o010007; +pub const B1000000: crate::speed_t = 0o010010; +pub const B1152000: crate::speed_t = 0o010011; +pub const B1500000: crate::speed_t = 0o010012; +pub const B2000000: crate::speed_t = 0o010013; +pub const B2500000: crate::speed_t = 0o010014; +pub const B3000000: crate::speed_t = 0o010015; +pub const B3500000: crate::speed_t = 0o010016; +pub const B4000000: crate::speed_t = 0o010017; + +pub const EHWPOISON: c_int = 168; diff --git a/http/vendor/libc/src/unix/linux_like/linux/gnu/b32/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/gnu/b32/mod.rs new file mode 100644 index 0000000..d9aebbe --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/gnu/b32/mod.rs @@ -0,0 +1,491 @@ +//! 32-bit specific definitions for linux-like values + +use crate::prelude::*; +use crate::pthread_mutex_t; + +pub type clock_t = i32; + +pub type shmatt_t = c_ulong; +pub type msgqnum_t = c_ulong; +pub type msglen_t = c_ulong; +pub type nlink_t = u32; +pub type __u64 = c_ulonglong; +pub type __s64 = c_longlong; +pub type __fsword_t = i32; +pub type fsblkcnt64_t = u64; +pub type fsfilcnt64_t = u64; +pub type __syscall_ulong_t = c_ulong; +pub type __suseconds64_t = i64; + +cfg_if! { + if #[cfg(target_arch = "riscv32")] { + pub type time_t = i64; + pub type suseconds_t = i64; + type __ino_t = c_ulong; + type __ino64_t = u64; + pub type ino_t = __ino64_t; + pub type off_t = i64; + pub type blkcnt_t = i64; + pub type fsblkcnt_t = u64; + pub type fsfilcnt_t = u64; + pub type rlim_t = u64; + pub type blksize_t = i64; + } else if #[cfg(gnu_time_bits64)] { + pub type time_t = i64; + pub type suseconds_t = i32; + type __ino_t = c_ulong; + type __ino64_t = u64; + pub type ino_t = __ino64_t; + pub type off_t = i64; + pub type blkcnt_t = i64; + pub type fsblkcnt_t = u64; + pub type fsfilcnt_t = u64; + pub type rlim_t = u64; + pub type blksize_t = i32; + } else if #[cfg(gnu_file_offset_bits64)] { + pub type time_t = i32; + pub type suseconds_t = i32; + type __ino_t = c_ulong; + type __ino64_t = u64; + pub type ino_t = __ino64_t; + pub type off_t = i64; + pub type blkcnt_t = i64; + pub type fsblkcnt_t = u64; + pub type fsfilcnt_t = u64; + pub type rlim_t = u64; + pub type blksize_t = i32; + } else { + pub type time_t = i32; + pub type suseconds_t = i32; + type __ino_t = c_ulong; + type __ino64_t = u64; + pub type ino_t = __ino_t; + pub type off_t = i32; + pub type blkcnt_t = i32; + pub type fsblkcnt_t = c_ulong; + pub type fsfilcnt_t = c_ulong; + pub type rlim_t = c_ulong; + pub type blksize_t = i32; + } +} + +cfg_if! { + if #[cfg(not(any( + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "powerpc", + target_arch = "sparc" + )))] { + s! { + pub struct stat { + pub st_dev: crate::dev_t, + + #[cfg(not(gnu_time_bits64))] + __pad1: Padding, + + #[cfg(any(gnu_time_bits64, not(gnu_file_offset_bits64)))] + pub st_ino: crate::ino_t, + #[cfg(all(not(gnu_time_bits64), gnu_file_offset_bits64))] + __st_ino: __ino_t, + + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + + pub st_rdev: crate::dev_t, + + #[cfg(not(gnu_time_bits64))] + __pad2: Padding, + + pub st_size: off_t, + + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + #[cfg(gnu_time_bits64)] + _atime_pad: Padding, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + #[cfg(gnu_time_bits64)] + _mtime_pad: Padding, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + #[cfg(gnu_time_bits64)] + _ctime_pad: Padding, + + #[cfg(not(gnu_file_offset_bits64))] + __glibc_reserved4: Padding, + #[cfg(not(gnu_file_offset_bits64))] + __glibc_reserved5: Padding, + #[cfg(all(not(gnu_time_bits64), gnu_file_offset_bits64))] + pub st_ino: crate::ino_t, + } + } + } +} + +s! { + pub struct statvfs { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_favail: crate::fsfilcnt_t, + pub f_fsid: c_ulong, + __f_unused: Padding, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: [c_int; 6], + } + + pub struct pthread_attr_t { + __size: [u32; 9], + } + + pub struct sigset_t { + __val: [c_ulong; 32], + } + + pub struct sysinfo { + pub uptime: c_long, + pub loads: [c_ulong; 3], + pub totalram: c_ulong, + pub freeram: c_ulong, + pub sharedram: c_ulong, + pub bufferram: c_ulong, + pub totalswap: c_ulong, + pub freeswap: c_ulong, + pub procs: c_ushort, + #[deprecated( + since = "0.2.58", + note = "This padding field might become private in the future" + )] + pub pad: c_ushort, + pub totalhigh: c_ulong, + pub freehigh: c_ulong, + pub mem_unit: c_uint, + pub _f: [c_char; 8], + } + + pub struct semid_ds { + pub sem_perm: ipc_perm, + #[cfg(all(not(gnu_time_bits64), target_arch = "powerpc"))] + __reserved: Padding, + pub sem_otime: crate::time_t, + #[cfg(not(any( + gnu_time_bits64, + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "powerpc" + )))] + __reserved: Padding, + #[cfg(all(not(gnu_time_bits64), target_arch = "powerpc"))] + __reserved2: Padding, + pub sem_ctime: crate::time_t, + #[cfg(not(any( + gnu_time_bits64, + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "powerpc" + )))] + __reserved2: Padding, + pub sem_nsems: crate::__syscall_ulong_t, + #[cfg(all( + gnu_time_bits64, + not(any( + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "powerpc", + target_arch = "arm", + target_arch = "x86" + )) + ))] + __reserved2: Padding, + __glibc_reserved3: Padding, + __glibc_reserved4: Padding, + } + + #[cfg(gnu_time_bits64)] + pub struct timex { + pub modes: c_uint, + _pad1: Padding, + pub offset: c_longlong, + pub freq: c_longlong, + pub maxerror: c_longlong, + pub esterror: c_longlong, + pub status: c_int, + _pad2: Padding, + pub constant: c_longlong, + pub precision: c_longlong, + pub tolerance: c_longlong, + pub time: crate::timeval, + pub tick: c_longlong, + pub ppsfreq: c_longlong, + pub jitter: c_longlong, + pub shift: c_int, + _pad3: Padding, + pub stabil: c_longlong, + pub jitcnt: c_longlong, + pub calcnt: c_longlong, + pub errcnt: c_longlong, + pub stbcnt: c_longlong, + pub tai: c_int, + pub __unused1: i32, + pub __unused2: i32, + pub __unused3: i32, + pub __unused4: i32, + pub __unused5: i32, + pub __unused6: i32, + pub __unused7: i32, + pub __unused8: i32, + pub __unused9: i32, + pub __unused10: i32, + pub __unused11: i32, + } + + #[cfg(not(gnu_time_bits64))] + pub struct timex { + pub modes: c_uint, + pub offset: c_long, + pub freq: c_long, + pub maxerror: c_long, + pub esterror: c_long, + pub status: c_int, + pub constant: c_long, + pub precision: c_long, + pub tolerance: c_long, + pub time: crate::timeval, + pub tick: c_long, + pub ppsfreq: c_long, + pub jitter: c_long, + pub shift: c_int, + pub stabil: c_long, + pub jitcnt: c_long, + pub calcnt: c_long, + pub errcnt: c_long, + pub stbcnt: c_long, + pub tai: c_int, + pub __unused1: i32, + pub __unused2: i32, + pub __unused3: i32, + pub __unused4: i32, + pub __unused5: i32, + pub __unused6: i32, + pub __unused7: i32, + pub __unused8: i32, + pub __unused9: i32, + pub __unused10: i32, + pub __unused11: i32, + } +} + +pub const POSIX_FADV_DONTNEED: c_int = 4; +pub const POSIX_FADV_NOREUSE: c_int = 5; + +pub const F_OFD_GETLK: c_int = 36; +pub const F_OFD_SETLK: c_int = 37; +pub const F_OFD_SETLKW: c_int = 38; + +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; +pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 20; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; +pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; + +cfg_if! { + if #[cfg(target_arch = "sparc")] { + pub const O_NOATIME: c_int = 0x200000; + pub const O_PATH: c_int = 0x1000000; + pub const O_TMPFILE: c_int = 0x2000000 | O_DIRECTORY; + + pub const SA_ONSTACK: c_int = 1; + + pub const PTRACE_DETACH: c_uint = 11; + + pub const F_RDLCK: c_int = 1; + pub const F_WRLCK: c_int = 2; + pub const F_UNLCK: c_int = 3; + + pub const SFD_CLOEXEC: c_int = 0x400000; + + pub const NCCS: usize = 17; + + pub const O_TRUNC: c_int = 0x400; + pub const O_CLOEXEC: c_int = 0x400000; + + pub const EBFONT: c_int = 109; + pub const ENOSTR: c_int = 72; + pub const ENODATA: c_int = 111; + pub const ETIME: c_int = 73; + pub const ENOSR: c_int = 74; + pub const ENONET: c_int = 80; + pub const ENOPKG: c_int = 113; + pub const EREMOTE: c_int = 71; + pub const ENOLINK: c_int = 82; + pub const EADV: c_int = 83; + pub const ESRMNT: c_int = 84; + pub const ECOMM: c_int = 85; + pub const EPROTO: c_int = 86; + pub const EDOTDOT: c_int = 88; + + pub const SA_NODEFER: c_int = 0x20; + pub const SA_RESETHAND: c_int = 0x4; + pub const SA_RESTART: c_int = 0x2; + pub const SA_NOCLDSTOP: c_int = 0x00000008; + + pub const EPOLL_CLOEXEC: c_int = 0x400000; + + pub const EFD_CLOEXEC: c_int = 0x400000; + } else { + pub const O_NOATIME: c_int = 0o1000000; + pub const O_PATH: c_int = 0o10000000; + pub const O_TMPFILE: c_int = 0o20000000 | O_DIRECTORY; + + pub const SA_ONSTACK: c_int = 0x08000000; + + pub const PTRACE_DETACH: c_uint = 17; + + pub const F_RDLCK: c_int = 0; + pub const F_WRLCK: c_int = 1; + pub const F_UNLCK: c_int = 2; + + pub const SFD_CLOEXEC: c_int = 0x080000; + + pub const NCCS: usize = 32; + + pub const O_TRUNC: c_int = 512; + pub const O_CLOEXEC: c_int = 0x80000; + pub const EBFONT: c_int = 59; + pub const ENOSTR: c_int = 60; + pub const ENODATA: c_int = 61; + pub const ETIME: c_int = 62; + pub const ENOSR: c_int = 63; + pub const ENONET: c_int = 64; + pub const ENOPKG: c_int = 65; + pub const EREMOTE: c_int = 66; + pub const ENOLINK: c_int = 67; + pub const EADV: c_int = 68; + pub const ESRMNT: c_int = 69; + pub const ECOMM: c_int = 70; + pub const EPROTO: c_int = 71; + pub const EDOTDOT: c_int = 73; + + pub const SA_NODEFER: c_int = 0x40000000; + pub const SA_RESETHAND: c_int = 0x80000000; + pub const SA_RESTART: c_int = 0x10000000; + pub const SA_NOCLDSTOP: c_int = 0x00000001; + + pub const EPOLL_CLOEXEC: c_int = 0x80000; + + pub const EFD_CLOEXEC: c_int = 0x80000; + } +} +cfg_if! { + if #[cfg(target_arch = "sparc")] { + pub const F_SETLK: c_int = 8; + pub const F_SETLKW: c_int = 9; + } else if #[cfg(all( + gnu_file_offset_bits64, + any(target_arch = "mips", target_arch = "mips32r6") + ))] { + pub const F_SETLK: c_int = 34; + pub const F_SETLKW: c_int = 35; + } else if #[cfg(gnu_file_offset_bits64)] { + pub const F_SETLK: c_int = 13; + pub const F_SETLKW: c_int = 14; + } else { + pub const F_SETLK: c_int = 6; + pub const F_SETLKW: c_int = 7; + } +} + +#[cfg(target_endian = "little")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; + +pub const PTRACE_GETFPREGS: c_uint = 14; +pub const PTRACE_SETFPREGS: c_uint = 15; +pub const PTRACE_GETREGS: c_uint = 12; +pub const PTRACE_SETREGS: c_uint = 13; + +extern "C" { + pub fn sysctl( + name: *mut c_int, + namelen: c_int, + oldp: *mut c_void, + oldlenp: *mut size_t, + newp: *mut c_void, + newlen: size_t, + ) -> c_int; +} + +cfg_if! { + if #[cfg(target_arch = "x86")] { + mod x86; + pub use self::x86::*; + } else if #[cfg(target_arch = "arm")] { + mod arm; + pub use self::arm::*; + } else if #[cfg(any(target_arch = "mips", target_arch = "mips32r6"))] { + mod mips; + pub use self::mips::*; + } else if #[cfg(target_arch = "m68k")] { + mod m68k; + pub use self::m68k::*; + } else if #[cfg(target_arch = "powerpc")] { + mod powerpc; + pub use self::powerpc::*; + } else if #[cfg(target_arch = "sparc")] { + mod sparc; + pub use self::sparc::*; + } else if #[cfg(target_arch = "riscv32")] { + mod riscv32; + pub use self::riscv32::*; + } else if #[cfg(target_arch = "csky")] { + mod csky; + pub use self::csky::*; + } else { + // Unknown target_arch + } +} diff --git a/http/vendor/libc/src/unix/linux_like/linux/gnu/b32/powerpc.rs b/http/vendor/libc/src/unix/linux_like/linux/gnu/b32/powerpc.rs new file mode 100644 index 0000000..b5d3631 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/gnu/b32/powerpc.rs @@ -0,0 +1,895 @@ +use crate::prelude::*; +use crate::{ + off64_t, + off_t, +}; + +pub type wchar_t = i32; + +s! { + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigaction { + pub sa_sigaction: crate::sighandler_t, + pub sa_mask: crate::sigset_t, + pub sa_flags: c_int, + pub sa_restorer: Option, + } + + pub struct statfs { + pub f_type: crate::__fsword_t, + pub f_bsize: crate::__fsword_t, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_fsid: crate::fsid_t, + + pub f_namelen: crate::__fsword_t, + pub f_frsize: crate::__fsword_t, + pub f_flags: crate::__fsword_t, + f_spare: [crate::__fsword_t; 4], + } + + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off_t, + pub l_len: off_t, + pub l_pid: crate::pid_t, + } + + pub struct flock64 { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off64_t, + pub l_len: off64_t, + pub l_pid: crate::pid_t, + } + + pub struct ipc_perm { + __key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: crate::mode_t, + __seq: u32, + __pad1: Padding, + __glibc_reserved1: Padding, + __glibc_reserved2: Padding, + } + + pub struct stat { + pub st_dev: crate::dev_t, + #[cfg(not(gnu_file_offset_bits64))] + __pad1: Padding, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + #[cfg(not(gnu_time_bits64))] + __pad2: Padding, + pub st_size: off_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + #[cfg(gnu_time_bits64)] + _atime_pad: Padding, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + #[cfg(gnu_time_bits64)] + _mtime_pad: Padding, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + #[cfg(gnu_time_bits64)] + _ctime_pad: Padding, + pub st_ctime_nsec: c_long, + #[cfg(not(gnu_time_bits64))] + __glibc_reserved4: Padding, + #[cfg(not(gnu_time_bits64))] + __glibc_reserved5: Padding, + } + + pub struct stat64 { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino64_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + #[cfg(not(gnu_time_bits64))] + __pad2: Padding, + pub st_size: off64_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt64_t, + pub st_atime: crate::time_t, + #[cfg(gnu_time_bits64)] + _atime_pad: Padding, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + #[cfg(gnu_time_bits64)] + _mtime_pad: Padding, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + #[cfg(gnu_time_bits64)] + _ctime_pad: Padding, + pub st_ctime_nsec: c_long, + #[cfg(not(gnu_time_bits64))] + __glibc_reserved4: Padding, + #[cfg(not(gnu_time_bits64))] + __glibc_reserved5: Padding, + } + + pub struct statfs64 { + pub f_type: crate::__fsword_t, + pub f_bsize: crate::__fsword_t, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_fsid: crate::fsid_t, + pub f_namelen: crate::__fsword_t, + pub f_frsize: crate::__fsword_t, + pub f_flags: crate::__fsword_t, + pub f_spare: [crate::__fsword_t; 4], + } + + pub struct statvfs64 { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: c_ulong, + __f_unused: Padding, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: [c_int; 6], + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + #[cfg(gnu_time_bits64)] + pub shm_segsz: size_t, + #[cfg(not(gnu_time_bits64))] + __glibc_reserved1: Padding, + pub shm_atime: crate::time_t, + #[cfg(not(gnu_time_bits64))] + __glibc_reserved2: Padding, + pub shm_dtime: crate::time_t, + #[cfg(not(gnu_time_bits64))] + __glibc_reserved3: Padding, + pub shm_ctime: crate::time_t, + #[cfg(not(gnu_time_bits64))] + __glibc_reserved4: Padding, + #[cfg(not(gnu_time_bits64))] + pub shm_segsz: size_t, + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: crate::shmatt_t, + __glibc_reserved5: Padding, + __glibc_reserved6: Padding, + } + + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + #[cfg(not(gnu_time_bits64))] + __glibc_reserved1: Padding, + pub msg_stime: crate::time_t, + #[cfg(not(gnu_time_bits64))] + __glibc_reserved2: Padding, + pub msg_rtime: crate::time_t, + #[cfg(not(gnu_time_bits64))] + __glibc_reserved3: Padding, + pub msg_ctime: crate::time_t, + pub __msg_cbytes: c_ulong, + pub msg_qnum: crate::msgqnum_t, + pub msg_qbytes: crate::msglen_t, + pub msg_lspid: crate::pid_t, + pub msg_lrpid: crate::pid_t, + __glibc_reserved4: Padding, + __glibc_reserved5: Padding, + } + + pub struct siginfo_t { + pub si_signo: c_int, + pub si_errno: c_int, + pub si_code: c_int, + #[doc(hidden)] + #[deprecated( + since = "0.2.54", + note = "Please leave a comment on \ + https://github.com/rust-lang/libc/pull/1316 if you're using \ + this field" + )] + pub _pad: [c_int; 29], + _align: [usize; 0], + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_flags: c_int, + pub ss_size: size_t, + } +} + +pub const VEOF: usize = 4; +pub const RTLD_DEEPBIND: c_int = 0x8; +pub const RTLD_GLOBAL: c_int = 0x100; +pub const RTLD_NOLOAD: c_int = 0x4; +pub const O_DIRECT: c_int = 0x20000; +pub const O_DIRECTORY: c_int = 0x4000; +pub const O_NOFOLLOW: c_int = 0x8000; +pub const O_LARGEFILE: c_int = 0o200000; +pub const O_APPEND: c_int = 1024; +pub const O_CREAT: c_int = 64; +pub const O_EXCL: c_int = 128; +pub const O_NOCTTY: c_int = 256; +pub const O_NONBLOCK: c_int = 2048; +pub const O_SYNC: c_int = 1052672; +pub const O_RSYNC: c_int = 1052672; +pub const O_DSYNC: c_int = 4096; +pub const O_FSYNC: c_int = 0x101000; +pub const O_ASYNC: c_int = 0x2000; +pub const O_NDELAY: c_int = 0x800; +pub const TCSANOW: c_int = 0; +pub const TCSADRAIN: c_int = 1; +pub const TCSAFLUSH: c_int = 2; + +pub const MADV_SOFT_OFFLINE: c_int = 101; +pub const MAP_LOCKED: c_int = 0x00080; +pub const MAP_NORESERVE: c_int = 0x00040; +pub const MAP_ANON: c_int = 0x0020; +pub const MAP_ANONYMOUS: c_int = 0x0020; +pub const MAP_DENYWRITE: c_int = 0x0800; +pub const MAP_EXECUTABLE: c_int = 0x01000; +pub const MAP_POPULATE: c_int = 0x08000; +pub const MAP_NONBLOCK: c_int = 0x010000; +pub const MAP_STACK: c_int = 0x020000; +pub const MAP_HUGETLB: c_int = 0x040000; +pub const MAP_GROWSDOWN: c_int = 0x0100; +pub const MAP_SYNC: c_int = 0x080000; + +pub const EDEADLOCK: c_int = 58; +pub const EUCLEAN: c_int = 117; +pub const ENOTNAM: c_int = 118; +pub const ENAVAIL: c_int = 119; +pub const EISNAM: c_int = 120; +pub const EREMOTEIO: c_int = 121; +pub const EDEADLK: c_int = 35; +pub const ENAMETOOLONG: c_int = 36; +pub const ENOLCK: c_int = 37; +pub const ENOSYS: c_int = 38; +pub const ENOTEMPTY: c_int = 39; +pub const ELOOP: c_int = 40; +pub const ENOMSG: c_int = 42; +pub const EIDRM: c_int = 43; +pub const ECHRNG: c_int = 44; +pub const EL2NSYNC: c_int = 45; +pub const EL3HLT: c_int = 46; +pub const EL3RST: c_int = 47; +pub const ELNRNG: c_int = 48; +pub const EUNATCH: c_int = 49; +pub const ENOCSI: c_int = 50; +pub const EL2HLT: c_int = 51; +pub const EBADE: c_int = 52; +pub const EBADR: c_int = 53; +pub const EXFULL: c_int = 54; +pub const ENOANO: c_int = 55; +pub const EBADRQC: c_int = 56; +pub const EBADSLT: c_int = 57; +pub const EMULTIHOP: c_int = 72; +pub const EOVERFLOW: c_int = 75; +pub const ENOTUNIQ: c_int = 76; +pub const EBADFD: c_int = 77; +pub const EBADMSG: c_int = 74; +pub const EREMCHG: c_int = 78; +pub const ELIBACC: c_int = 79; +pub const ELIBBAD: c_int = 80; +pub const ELIBSCN: c_int = 81; +pub const ELIBMAX: c_int = 82; +pub const ELIBEXEC: c_int = 83; +pub const EILSEQ: c_int = 84; +pub const ERESTART: c_int = 85; +pub const ESTRPIPE: c_int = 86; +pub const EUSERS: c_int = 87; +pub const ENOTSOCK: c_int = 88; +pub const EDESTADDRREQ: c_int = 89; +pub const EMSGSIZE: c_int = 90; +pub const EPROTOTYPE: c_int = 91; +pub const ENOPROTOOPT: c_int = 92; +pub const EPROTONOSUPPORT: c_int = 93; +pub const ESOCKTNOSUPPORT: c_int = 94; +pub const EOPNOTSUPP: c_int = 95; +pub const EPFNOSUPPORT: c_int = 96; +pub const EAFNOSUPPORT: c_int = 97; +pub const EADDRINUSE: c_int = 98; +pub const EADDRNOTAVAIL: c_int = 99; +pub const ENETDOWN: c_int = 100; +pub const ENETUNREACH: c_int = 101; +pub const ENETRESET: c_int = 102; +pub const ECONNABORTED: c_int = 103; +pub const ECONNRESET: c_int = 104; +pub const ENOBUFS: c_int = 105; +pub const EISCONN: c_int = 106; +pub const ENOTCONN: c_int = 107; +pub const ESHUTDOWN: c_int = 108; +pub const ETOOMANYREFS: c_int = 109; +pub const ETIMEDOUT: c_int = 110; +pub const ECONNREFUSED: c_int = 111; +pub const EHOSTDOWN: c_int = 112; +pub const EHOSTUNREACH: c_int = 113; +pub const EALREADY: c_int = 114; +pub const EINPROGRESS: c_int = 115; +pub const ESTALE: c_int = 116; +pub const EDQUOT: c_int = 122; +pub const ENOMEDIUM: c_int = 123; +pub const EMEDIUMTYPE: c_int = 124; +pub const ECANCELED: c_int = 125; +pub const ENOKEY: c_int = 126; +pub const EKEYEXPIRED: c_int = 127; +pub const EKEYREVOKED: c_int = 128; +pub const EKEYREJECTED: c_int = 129; +pub const EOWNERDEAD: c_int = 130; +pub const ENOTRECOVERABLE: c_int = 131; +pub const EHWPOISON: c_int = 133; +pub const ERFKILL: c_int = 132; + +pub const SA_SIGINFO: c_int = 0x00000004; +pub const SA_NOCLDWAIT: c_int = 0x00000002; + +pub const SOCK_STREAM: c_int = 1; +pub const SOCK_DGRAM: c_int = 2; + +pub const MCL_CURRENT: c_int = 0x2000; +pub const MCL_FUTURE: c_int = 0x4000; +pub const MCL_ONFAULT: c_int = 0x8000; + +pub const POLLWRNORM: c_short = 0x100; +pub const POLLWRBAND: c_short = 0x200; + +cfg_if! { + if #[cfg(gnu_file_offset_bits64)] { + pub const F_GETLK: c_int = 12; + } else { + pub const F_GETLK: c_int = 5; + } +} +pub const F_GETOWN: c_int = 9; +pub const F_SETOWN: c_int = 8; + +pub const EFD_NONBLOCK: c_int = 0x800; +pub const SFD_NONBLOCK: c_int = 0x0800; + +pub const SIGCHLD: c_int = 17; +pub const SIGBUS: c_int = 7; +pub const SIGUSR1: c_int = 10; +pub const SIGUSR2: c_int = 12; +pub const SIGCONT: c_int = 18; +pub const SIGSTOP: c_int = 19; +pub const SIGTSTP: c_int = 20; +pub const SIGURG: c_int = 23; +pub const SIGIO: c_int = 29; +pub const SIGSYS: c_int = 31; +pub const SIGSTKFLT: c_int = 16; +#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] +pub const SIGUNUSED: c_int = 31; +pub const SIGPOLL: c_int = 29; +pub const SIGPWR: c_int = 30; +pub const SIG_SETMASK: c_int = 2; +pub const SIG_BLOCK: c_int = 0x000000; +pub const SIG_UNBLOCK: c_int = 0x01; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGSTKSZ: size_t = 0x4000; +pub const MINSIGSTKSZ: size_t = 4096; +pub const CBAUD: crate::tcflag_t = 0xff; +pub const TAB1: crate::tcflag_t = 0x400; +pub const TAB2: crate::tcflag_t = 0x800; +pub const TAB3: crate::tcflag_t = 0xc00; +pub const CR1: crate::tcflag_t = 0x1000; +pub const CR2: crate::tcflag_t = 0x2000; +pub const CR3: crate::tcflag_t = 0x3000; +pub const FF1: crate::tcflag_t = 0x4000; +pub const BS1: crate::tcflag_t = 0x8000; +pub const VT1: crate::tcflag_t = 0x10000; +pub const VWERASE: usize = 0xa; +pub const VREPRINT: usize = 0xb; +pub const VSUSP: usize = 0xc; +pub const VSTART: usize = 0xd; +pub const VSTOP: usize = 0xe; +pub const VDISCARD: usize = 0x10; +pub const VTIME: usize = 0x7; +pub const IXON: crate::tcflag_t = 0x200; +pub const IXOFF: crate::tcflag_t = 0x400; +pub const ONLCR: crate::tcflag_t = 0x2; +pub const CSIZE: crate::tcflag_t = 0x300; +pub const CS6: crate::tcflag_t = 0x100; +pub const CS7: crate::tcflag_t = 0x200; +pub const CS8: crate::tcflag_t = 0x300; +pub const CSTOPB: crate::tcflag_t = 0x400; +pub const CREAD: crate::tcflag_t = 0x800; +pub const PARENB: crate::tcflag_t = 0x1000; +pub const PARODD: crate::tcflag_t = 0x2000; +pub const HUPCL: crate::tcflag_t = 0x4000; +pub const CLOCAL: crate::tcflag_t = 0x8000; +pub const ECHOKE: crate::tcflag_t = 0x1; +pub const ECHOE: crate::tcflag_t = 0x2; +pub const ECHOK: crate::tcflag_t = 0x4; +pub const ECHONL: crate::tcflag_t = 0x10; +pub const ECHOPRT: crate::tcflag_t = 0x20; +pub const ECHOCTL: crate::tcflag_t = 0x40; +pub const ISIG: crate::tcflag_t = 0x80; +pub const ICANON: crate::tcflag_t = 0x100; +pub const PENDIN: crate::tcflag_t = 0x20000000; +pub const NOFLSH: crate::tcflag_t = 0x80000000; +pub const VSWTC: usize = 9; +pub const OLCUC: crate::tcflag_t = 0o000004; +pub const NLDLY: crate::tcflag_t = 0o001400; +pub const CRDLY: crate::tcflag_t = 0o030000; +pub const TABDLY: crate::tcflag_t = 0o006000; +pub const BSDLY: crate::tcflag_t = 0o100000; +pub const FFDLY: crate::tcflag_t = 0o040000; +pub const VTDLY: crate::tcflag_t = 0o200000; +pub const XTABS: crate::tcflag_t = 0o006000; + +pub const B0: crate::speed_t = 0o000000; +pub const B50: crate::speed_t = 0o000001; +pub const B75: crate::speed_t = 0o000002; +pub const B110: crate::speed_t = 0o000003; +pub const B134: crate::speed_t = 0o000004; +pub const B150: crate::speed_t = 0o000005; +pub const B200: crate::speed_t = 0o000006; +pub const B300: crate::speed_t = 0o000007; +pub const B600: crate::speed_t = 0o000010; +pub const B1200: crate::speed_t = 0o000011; +pub const B1800: crate::speed_t = 0o000012; +pub const B2400: crate::speed_t = 0o000013; +pub const B4800: crate::speed_t = 0o000014; +pub const B9600: crate::speed_t = 0o000015; +pub const B19200: crate::speed_t = 0o000016; +pub const B38400: crate::speed_t = 0o000017; +pub const EXTA: crate::speed_t = B19200; +pub const EXTB: crate::speed_t = B38400; +pub const CBAUDEX: crate::speed_t = 0o000020; +pub const B57600: crate::speed_t = 0o0020; +pub const B115200: crate::speed_t = 0o0021; +pub const B230400: crate::speed_t = 0o0022; +pub const B460800: crate::speed_t = 0o0023; +pub const B500000: crate::speed_t = 0o0024; +pub const B576000: crate::speed_t = 0o0025; +pub const B921600: crate::speed_t = 0o0026; +pub const B1000000: crate::speed_t = 0o0027; +pub const B1152000: crate::speed_t = 0o0030; +pub const B1500000: crate::speed_t = 0o0031; +pub const B2000000: crate::speed_t = 0o0032; +pub const B2500000: crate::speed_t = 0o0033; +pub const B3000000: crate::speed_t = 0o0034; +pub const B3500000: crate::speed_t = 0o0035; +pub const B4000000: crate::speed_t = 0o0036; + +pub const VEOL: usize = 6; +pub const VEOL2: usize = 8; +pub const VMIN: usize = 5; +pub const IEXTEN: crate::tcflag_t = 0x400; +pub const TOSTOP: crate::tcflag_t = 0x400000; +pub const FLUSHO: crate::tcflag_t = 0x800000; +pub const EXTPROC: crate::tcflag_t = 0x10000000; + +pub const SYS_restart_syscall: c_long = 0; +pub const SYS_exit: c_long = 1; +pub const SYS_fork: c_long = 2; +pub const SYS_read: c_long = 3; +pub const SYS_write: c_long = 4; +pub const SYS_open: c_long = 5; +pub const SYS_close: c_long = 6; +pub const SYS_waitpid: c_long = 7; +pub const SYS_creat: c_long = 8; +pub const SYS_link: c_long = 9; +pub const SYS_unlink: c_long = 10; +pub const SYS_execve: c_long = 11; +pub const SYS_chdir: c_long = 12; +pub const SYS_time: c_long = 13; +pub const SYS_mknod: c_long = 14; +pub const SYS_chmod: c_long = 15; +pub const SYS_lchown: c_long = 16; +pub const SYS_break: c_long = 17; +pub const SYS_oldstat: c_long = 18; +pub const SYS_lseek: c_long = 19; +pub const SYS_getpid: c_long = 20; +pub const SYS_mount: c_long = 21; +pub const SYS_umount: c_long = 22; +pub const SYS_setuid: c_long = 23; +pub const SYS_getuid: c_long = 24; +pub const SYS_stime: c_long = 25; +pub const SYS_ptrace: c_long = 26; +pub const SYS_alarm: c_long = 27; +pub const SYS_oldfstat: c_long = 28; +pub const SYS_pause: c_long = 29; +pub const SYS_utime: c_long = 30; +pub const SYS_stty: c_long = 31; +pub const SYS_gtty: c_long = 32; +pub const SYS_access: c_long = 33; +pub const SYS_nice: c_long = 34; +pub const SYS_ftime: c_long = 35; +pub const SYS_sync: c_long = 36; +pub const SYS_kill: c_long = 37; +pub const SYS_rename: c_long = 38; +pub const SYS_mkdir: c_long = 39; +pub const SYS_rmdir: c_long = 40; +pub const SYS_dup: c_long = 41; +pub const SYS_pipe: c_long = 42; +pub const SYS_times: c_long = 43; +pub const SYS_prof: c_long = 44; +pub const SYS_brk: c_long = 45; +pub const SYS_setgid: c_long = 46; +pub const SYS_getgid: c_long = 47; +pub const SYS_signal: c_long = 48; +pub const SYS_geteuid: c_long = 49; +pub const SYS_getegid: c_long = 50; +pub const SYS_acct: c_long = 51; +pub const SYS_umount2: c_long = 52; +pub const SYS_lock: c_long = 53; +pub const SYS_ioctl: c_long = 54; +pub const SYS_fcntl: c_long = 55; +pub const SYS_mpx: c_long = 56; +pub const SYS_setpgid: c_long = 57; +pub const SYS_ulimit: c_long = 58; +pub const SYS_oldolduname: c_long = 59; +pub const SYS_umask: c_long = 60; +pub const SYS_chroot: c_long = 61; +pub const SYS_ustat: c_long = 62; +pub const SYS_dup2: c_long = 63; +pub const SYS_getppid: c_long = 64; +pub const SYS_getpgrp: c_long = 65; +pub const SYS_setsid: c_long = 66; +pub const SYS_sigaction: c_long = 67; +pub const SYS_sgetmask: c_long = 68; +pub const SYS_ssetmask: c_long = 69; +pub const SYS_setreuid: c_long = 70; +pub const SYS_setregid: c_long = 71; +pub const SYS_sigsuspend: c_long = 72; +pub const SYS_sigpending: c_long = 73; +pub const SYS_sethostname: c_long = 74; +pub const SYS_setrlimit: c_long = 75; +pub const SYS_getrlimit: c_long = 76; +pub const SYS_getrusage: c_long = 77; +pub const SYS_gettimeofday: c_long = 78; +pub const SYS_settimeofday: c_long = 79; +pub const SYS_getgroups: c_long = 80; +pub const SYS_setgroups: c_long = 81; +pub const SYS_select: c_long = 82; +pub const SYS_symlink: c_long = 83; +pub const SYS_oldlstat: c_long = 84; +pub const SYS_readlink: c_long = 85; +pub const SYS_uselib: c_long = 86; +pub const SYS_swapon: c_long = 87; +pub const SYS_reboot: c_long = 88; +pub const SYS_readdir: c_long = 89; +pub const SYS_mmap: c_long = 90; +pub const SYS_munmap: c_long = 91; +pub const SYS_truncate: c_long = 92; +pub const SYS_ftruncate: c_long = 93; +pub const SYS_fchmod: c_long = 94; +pub const SYS_fchown: c_long = 95; +pub const SYS_getpriority: c_long = 96; +pub const SYS_setpriority: c_long = 97; +pub const SYS_profil: c_long = 98; +pub const SYS_statfs: c_long = 99; +pub const SYS_fstatfs: c_long = 100; +pub const SYS_ioperm: c_long = 101; +pub const SYS_socketcall: c_long = 102; +pub const SYS_syslog: c_long = 103; +pub const SYS_setitimer: c_long = 104; +pub const SYS_getitimer: c_long = 105; +pub const SYS_stat: c_long = 106; +pub const SYS_lstat: c_long = 107; +pub const SYS_fstat: c_long = 108; +pub const SYS_olduname: c_long = 109; +pub const SYS_iopl: c_long = 110; +pub const SYS_vhangup: c_long = 111; +pub const SYS_idle: c_long = 112; +pub const SYS_vm86: c_long = 113; +pub const SYS_wait4: c_long = 114; +pub const SYS_swapoff: c_long = 115; +pub const SYS_sysinfo: c_long = 116; +pub const SYS_ipc: c_long = 117; +pub const SYS_fsync: c_long = 118; +pub const SYS_sigreturn: c_long = 119; +pub const SYS_clone: c_long = 120; +pub const SYS_setdomainname: c_long = 121; +pub const SYS_uname: c_long = 122; +pub const SYS_modify_ldt: c_long = 123; +pub const SYS_adjtimex: c_long = 124; +pub const SYS_mprotect: c_long = 125; +pub const SYS_sigprocmask: c_long = 126; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_create_module: c_long = 127; +pub const SYS_init_module: c_long = 128; +pub const SYS_delete_module: c_long = 129; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_get_kernel_syms: c_long = 130; +pub const SYS_quotactl: c_long = 131; +pub const SYS_getpgid: c_long = 132; +pub const SYS_fchdir: c_long = 133; +pub const SYS_bdflush: c_long = 134; +pub const SYS_sysfs: c_long = 135; +pub const SYS_personality: c_long = 136; +pub const SYS_afs_syscall: c_long = 137; /* Syscall for Andrew File System */ +pub const SYS_setfsuid: c_long = 138; +pub const SYS_setfsgid: c_long = 139; +pub const SYS__llseek: c_long = 140; +pub const SYS_getdents: c_long = 141; +pub const SYS__newselect: c_long = 142; +pub const SYS_flock: c_long = 143; +pub const SYS_msync: c_long = 144; +pub const SYS_readv: c_long = 145; +pub const SYS_writev: c_long = 146; +pub const SYS_getsid: c_long = 147; +pub const SYS_fdatasync: c_long = 148; +pub const SYS__sysctl: c_long = 149; +pub const SYS_mlock: c_long = 150; +pub const SYS_munlock: c_long = 151; +pub const SYS_mlockall: c_long = 152; +pub const SYS_munlockall: c_long = 153; +pub const SYS_sched_setparam: c_long = 154; +pub const SYS_sched_getparam: c_long = 155; +pub const SYS_sched_setscheduler: c_long = 156; +pub const SYS_sched_getscheduler: c_long = 157; +pub const SYS_sched_yield: c_long = 158; +pub const SYS_sched_get_priority_max: c_long = 159; +pub const SYS_sched_get_priority_min: c_long = 160; +pub const SYS_sched_rr_get_interval: c_long = 161; +pub const SYS_nanosleep: c_long = 162; +pub const SYS_mremap: c_long = 163; +pub const SYS_setresuid: c_long = 164; +pub const SYS_getresuid: c_long = 165; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_query_module: c_long = 166; +pub const SYS_poll: c_long = 167; +pub const SYS_nfsservctl: c_long = 168; +pub const SYS_setresgid: c_long = 169; +pub const SYS_getresgid: c_long = 170; +pub const SYS_prctl: c_long = 171; +pub const SYS_rt_sigreturn: c_long = 172; +pub const SYS_rt_sigaction: c_long = 173; +pub const SYS_rt_sigprocmask: c_long = 174; +pub const SYS_rt_sigpending: c_long = 175; +pub const SYS_rt_sigtimedwait: c_long = 176; +pub const SYS_rt_sigqueueinfo: c_long = 177; +pub const SYS_rt_sigsuspend: c_long = 178; +pub const SYS_pread64: c_long = 179; +pub const SYS_pwrite64: c_long = 180; +pub const SYS_chown: c_long = 181; +pub const SYS_getcwd: c_long = 182; +pub const SYS_capget: c_long = 183; +pub const SYS_capset: c_long = 184; +pub const SYS_sigaltstack: c_long = 185; +pub const SYS_sendfile: c_long = 186; +pub const SYS_getpmsg: c_long = 187; /* some people actually want streams */ +pub const SYS_putpmsg: c_long = 188; /* some people actually want streams */ +pub const SYS_vfork: c_long = 189; +pub const SYS_ugetrlimit: c_long = 190; /* SuS compliant getrlimit */ +pub const SYS_readahead: c_long = 191; +pub const SYS_mmap2: c_long = 192; +pub const SYS_truncate64: c_long = 193; +pub const SYS_ftruncate64: c_long = 194; +pub const SYS_stat64: c_long = 195; +pub const SYS_lstat64: c_long = 196; +pub const SYS_fstat64: c_long = 197; +pub const SYS_pciconfig_read: c_long = 198; +pub const SYS_pciconfig_write: c_long = 199; +pub const SYS_pciconfig_iobase: c_long = 200; +pub const SYS_multiplexer: c_long = 201; +pub const SYS_getdents64: c_long = 202; +pub const SYS_pivot_root: c_long = 203; +pub const SYS_fcntl64: c_long = 204; +pub const SYS_madvise: c_long = 205; +pub const SYS_mincore: c_long = 206; +pub const SYS_gettid: c_long = 207; +pub const SYS_tkill: c_long = 208; +pub const SYS_setxattr: c_long = 209; +pub const SYS_lsetxattr: c_long = 210; +pub const SYS_fsetxattr: c_long = 211; +pub const SYS_getxattr: c_long = 212; +pub const SYS_lgetxattr: c_long = 213; +pub const SYS_fgetxattr: c_long = 214; +pub const SYS_listxattr: c_long = 215; +pub const SYS_llistxattr: c_long = 216; +pub const SYS_flistxattr: c_long = 217; +pub const SYS_removexattr: c_long = 218; +pub const SYS_lremovexattr: c_long = 219; +pub const SYS_fremovexattr: c_long = 220; +pub const SYS_futex: c_long = 221; +pub const SYS_sched_setaffinity: c_long = 222; +pub const SYS_sched_getaffinity: c_long = 223; +pub const SYS_tuxcall: c_long = 225; +pub const SYS_sendfile64: c_long = 226; +pub const SYS_io_setup: c_long = 227; +pub const SYS_io_destroy: c_long = 228; +pub const SYS_io_getevents: c_long = 229; +pub const SYS_io_submit: c_long = 230; +pub const SYS_io_cancel: c_long = 231; +pub const SYS_set_tid_address: c_long = 232; +pub const SYS_fadvise64: c_long = 233; +pub const SYS_exit_group: c_long = 234; +pub const SYS_lookup_dcookie: c_long = 235; +pub const SYS_epoll_create: c_long = 236; +pub const SYS_epoll_ctl: c_long = 237; +pub const SYS_epoll_wait: c_long = 238; +pub const SYS_remap_file_pages: c_long = 239; +pub const SYS_timer_create: c_long = 240; +pub const SYS_timer_settime: c_long = 241; +pub const SYS_timer_gettime: c_long = 242; +pub const SYS_timer_getoverrun: c_long = 243; +pub const SYS_timer_delete: c_long = 244; +pub const SYS_clock_settime: c_long = 245; +pub const SYS_clock_gettime: c_long = 246; +pub const SYS_clock_getres: c_long = 247; +pub const SYS_clock_nanosleep: c_long = 248; +pub const SYS_swapcontext: c_long = 249; +pub const SYS_tgkill: c_long = 250; +pub const SYS_utimes: c_long = 251; +pub const SYS_statfs64: c_long = 252; +pub const SYS_fstatfs64: c_long = 253; +pub const SYS_fadvise64_64: c_long = 254; +pub const SYS_rtas: c_long = 255; +pub const SYS_sys_debug_setcontext: c_long = 256; +pub const SYS_migrate_pages: c_long = 258; +pub const SYS_mbind: c_long = 259; +pub const SYS_get_mempolicy: c_long = 260; +pub const SYS_set_mempolicy: c_long = 261; +pub const SYS_mq_open: c_long = 262; +pub const SYS_mq_unlink: c_long = 263; +pub const SYS_mq_timedsend: c_long = 264; +pub const SYS_mq_timedreceive: c_long = 265; +pub const SYS_mq_notify: c_long = 266; +pub const SYS_mq_getsetattr: c_long = 267; +pub const SYS_kexec_load: c_long = 268; +pub const SYS_add_key: c_long = 269; +pub const SYS_request_key: c_long = 270; +pub const SYS_keyctl: c_long = 271; +pub const SYS_waitid: c_long = 272; +pub const SYS_ioprio_set: c_long = 273; +pub const SYS_ioprio_get: c_long = 274; +pub const SYS_inotify_init: c_long = 275; +pub const SYS_inotify_add_watch: c_long = 276; +pub const SYS_inotify_rm_watch: c_long = 277; +pub const SYS_spu_run: c_long = 278; +pub const SYS_spu_create: c_long = 279; +pub const SYS_pselect6: c_long = 280; +pub const SYS_ppoll: c_long = 281; +pub const SYS_unshare: c_long = 282; +pub const SYS_splice: c_long = 283; +pub const SYS_tee: c_long = 284; +pub const SYS_vmsplice: c_long = 285; +pub const SYS_openat: c_long = 286; +pub const SYS_mkdirat: c_long = 287; +pub const SYS_mknodat: c_long = 288; +pub const SYS_fchownat: c_long = 289; +pub const SYS_futimesat: c_long = 290; +pub const SYS_fstatat64: c_long = 291; +pub const SYS_unlinkat: c_long = 292; +pub const SYS_renameat: c_long = 293; +pub const SYS_linkat: c_long = 294; +pub const SYS_symlinkat: c_long = 295; +pub const SYS_readlinkat: c_long = 296; +pub const SYS_fchmodat: c_long = 297; +pub const SYS_faccessat: c_long = 298; +pub const SYS_get_robust_list: c_long = 299; +pub const SYS_set_robust_list: c_long = 300; +pub const SYS_move_pages: c_long = 301; +pub const SYS_getcpu: c_long = 302; +pub const SYS_epoll_pwait: c_long = 303; +pub const SYS_utimensat: c_long = 304; +pub const SYS_signalfd: c_long = 305; +pub const SYS_timerfd_create: c_long = 306; +pub const SYS_eventfd: c_long = 307; +pub const SYS_sync_file_range2: c_long = 308; +pub const SYS_fallocate: c_long = 309; +pub const SYS_subpage_prot: c_long = 310; +pub const SYS_timerfd_settime: c_long = 311; +pub const SYS_timerfd_gettime: c_long = 312; +pub const SYS_signalfd4: c_long = 313; +pub const SYS_eventfd2: c_long = 314; +pub const SYS_epoll_create1: c_long = 315; +pub const SYS_dup3: c_long = 316; +pub const SYS_pipe2: c_long = 317; +pub const SYS_inotify_init1: c_long = 318; +pub const SYS_perf_event_open: c_long = 319; +pub const SYS_preadv: c_long = 320; +pub const SYS_pwritev: c_long = 321; +pub const SYS_rt_tgsigqueueinfo: c_long = 322; +pub const SYS_fanotify_init: c_long = 323; +pub const SYS_fanotify_mark: c_long = 324; +pub const SYS_prlimit64: c_long = 325; +pub const SYS_socket: c_long = 326; +pub const SYS_bind: c_long = 327; +pub const SYS_connect: c_long = 328; +pub const SYS_listen: c_long = 329; +pub const SYS_accept: c_long = 330; +pub const SYS_getsockname: c_long = 331; +pub const SYS_getpeername: c_long = 332; +pub const SYS_socketpair: c_long = 333; +pub const SYS_send: c_long = 334; +pub const SYS_sendto: c_long = 335; +pub const SYS_recv: c_long = 336; +pub const SYS_recvfrom: c_long = 337; +pub const SYS_shutdown: c_long = 338; +pub const SYS_setsockopt: c_long = 339; +pub const SYS_getsockopt: c_long = 340; +pub const SYS_sendmsg: c_long = 341; +pub const SYS_recvmsg: c_long = 342; +pub const SYS_recvmmsg: c_long = 343; +pub const SYS_accept4: c_long = 344; +pub const SYS_name_to_handle_at: c_long = 345; +pub const SYS_open_by_handle_at: c_long = 346; +pub const SYS_clock_adjtime: c_long = 347; +pub const SYS_syncfs: c_long = 348; +pub const SYS_sendmmsg: c_long = 349; +pub const SYS_setns: c_long = 350; +pub const SYS_process_vm_readv: c_long = 351; +pub const SYS_process_vm_writev: c_long = 352; +pub const SYS_finit_module: c_long = 353; +pub const SYS_kcmp: c_long = 354; +pub const SYS_sched_setattr: c_long = 355; +pub const SYS_sched_getattr: c_long = 356; +pub const SYS_renameat2: c_long = 357; +pub const SYS_seccomp: c_long = 358; +pub const SYS_getrandom: c_long = 359; +pub const SYS_memfd_create: c_long = 360; +pub const SYS_bpf: c_long = 361; +pub const SYS_execveat: c_long = 362; +pub const SYS_switch_endian: c_long = 363; +pub const SYS_userfaultfd: c_long = 364; +pub const SYS_membarrier: c_long = 365; +pub const SYS_mlock2: c_long = 378; +pub const SYS_copy_file_range: c_long = 379; +pub const SYS_preadv2: c_long = 380; +pub const SYS_pwritev2: c_long = 381; +pub const SYS_kexec_file_load: c_long = 382; +pub const SYS_statx: c_long = 383; +pub const SYS_rseq: c_long = 387; +pub const SYS_pidfd_send_signal: c_long = 424; +pub const SYS_io_uring_setup: c_long = 425; +pub const SYS_io_uring_enter: c_long = 426; +pub const SYS_io_uring_register: c_long = 427; +pub const SYS_open_tree: c_long = 428; +pub const SYS_move_mount: c_long = 429; +pub const SYS_fsopen: c_long = 430; +pub const SYS_fsconfig: c_long = 431; +pub const SYS_fsmount: c_long = 432; +pub const SYS_fspick: c_long = 433; +pub const SYS_pidfd_open: c_long = 434; +pub const SYS_clone3: c_long = 435; +pub const SYS_close_range: c_long = 436; +pub const SYS_openat2: c_long = 437; +pub const SYS_pidfd_getfd: c_long = 438; +pub const SYS_faccessat2: c_long = 439; +pub const SYS_process_madvise: c_long = 440; +pub const SYS_epoll_pwait2: c_long = 441; +pub const SYS_mount_setattr: c_long = 442; +pub const SYS_quotactl_fd: c_long = 443; +pub const SYS_landlock_create_ruleset: c_long = 444; +pub const SYS_landlock_add_rule: c_long = 445; +pub const SYS_landlock_restrict_self: c_long = 446; +pub const SYS_memfd_secret: c_long = 447; +pub const SYS_process_mrelease: c_long = 448; +pub const SYS_futex_waitv: c_long = 449; +pub const SYS_set_mempolicy_home_node: c_long = 450; +pub const SYS_mseal: c_long = 462; diff --git a/http/vendor/libc/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs new file mode 100644 index 0000000..5484a68 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs @@ -0,0 +1,811 @@ +//! RISC-V-specific definitions for 32-bit linux-like values + +use crate::prelude::*; +use crate::{ + off64_t, + off_t, +}; + +pub type wchar_t = c_int; + +s! { + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + pub msg_stime: crate::time_t, + pub msg_rtime: crate::time_t, + pub msg_ctime: crate::time_t, + pub __msg_cbytes: c_ulong, + pub msg_qnum: crate::msgqnum_t, + pub msg_qbytes: crate::msglen_t, + pub msg_lspid: crate::pid_t, + pub msg_lrpid: crate::pid_t, + __glibc_reserved4: Padding, + __glibc_reserved5: Padding, + } + + pub struct stat64 { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino64_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + pub __pad1: crate::dev_t, + pub st_size: off64_t, + pub st_blksize: crate::blksize_t, + pub __pad2: c_int, + pub st_blocks: crate::blkcnt64_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + __unused: Padding<[c_int; 2]>, + } + + pub struct statfs { + pub f_type: c_long, + pub f_bsize: c_long, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_fsid: crate::fsid_t, + pub f_namelen: c_long, + pub f_frsize: c_long, + pub f_flags: c_long, + pub f_spare: [c_long; 4], + } + + pub struct statfs64 { + pub f_type: c_long, + pub f_bsize: c_long, + pub f_blocks: crate::fsblkcnt64_t, + pub f_bfree: crate::fsblkcnt64_t, + pub f_bavail: crate::fsblkcnt64_t, + pub f_files: crate::fsfilcnt64_t, + pub f_ffree: crate::fsfilcnt64_t, + pub f_fsid: crate::fsid_t, + pub f_namelen: c_long, + pub f_frsize: c_long, + pub f_flags: c_long, + pub f_spare: [c_long; 4], + } + + pub struct statvfs64 { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt64_t, + pub f_bfree: crate::fsblkcnt64_t, + pub f_bavail: crate::fsblkcnt64_t, + pub f_files: crate::fsfilcnt64_t, + pub f_ffree: crate::fsfilcnt64_t, + pub f_favail: crate::fsfilcnt64_t, + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + pub __f_spare: [c_int; 6], + } + + pub struct siginfo_t { + pub si_signo: c_int, + pub si_errno: c_int, + pub si_code: c_int, + #[doc(hidden)] + #[deprecated( + since = "0.2.54", + note = "Please leave a comment on \ + https://github.com/rust-lang/libc/pull/1316 if you're using \ + this field" + )] + pub _pad: [c_int; 29], + _align: [u64; 0], + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_flags: c_int, + pub ss_size: size_t, + } + + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigaction { + pub sa_sigaction: crate::sighandler_t, + pub sa_mask: crate::sigset_t, + pub sa_flags: c_int, + pub sa_restorer: Option, + } + + pub struct ipc_perm { + pub __key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: c_ushort, + __pad1: Padding, + pub __seq: c_ushort, + __pad2: Padding, + __unused1: Padding, + __unused2: Padding, + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, + pub shm_atime: crate::time_t, + pub shm_dtime: crate::time_t, + pub shm_ctime: crate::time_t, + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: crate::shmatt_t, + __unused5: Padding, + __unused6: Padding, + } + + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off_t, + pub l_len: off_t, + pub l_pid: crate::pid_t, + } + + pub struct flock64 { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off64_t, + pub l_len: off64_t, + pub l_pid: crate::pid_t, + } + + pub struct user_regs_struct { + pub pc: c_ulong, + pub ra: c_ulong, + pub sp: c_ulong, + pub gp: c_ulong, + pub tp: c_ulong, + pub t0: c_ulong, + pub t1: c_ulong, + pub t2: c_ulong, + pub s0: c_ulong, + pub s1: c_ulong, + pub a0: c_ulong, + pub a1: c_ulong, + pub a2: c_ulong, + pub a3: c_ulong, + pub a4: c_ulong, + pub a5: c_ulong, + pub a6: c_ulong, + pub a7: c_ulong, + pub s2: c_ulong, + pub s3: c_ulong, + pub s4: c_ulong, + pub s5: c_ulong, + pub s6: c_ulong, + pub s7: c_ulong, + pub s8: c_ulong, + pub s9: c_ulong, + pub s10: c_ulong, + pub s11: c_ulong, + pub t3: c_ulong, + pub t4: c_ulong, + pub t5: c_ulong, + pub t6: c_ulong, + } +} + +s_no_extra_traits! { + pub struct ucontext_t { + pub __uc_flags: c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: crate::stack_t, + pub uc_sigmask: crate::sigset_t, + pub uc_mcontext: mcontext_t, + } + + #[repr(align(16))] + pub struct mcontext_t { + pub __gregs: [c_ulong; 32], + pub __fpregs: __riscv_mc_fp_state, + } + + pub union __riscv_mc_fp_state { + pub __f: __riscv_mc_f_ext_state, + pub __d: __riscv_mc_d_ext_state, + pub __q: __riscv_mc_q_ext_state, + } + + pub struct __riscv_mc_f_ext_state { + pub __f: [c_uint; 32], + pub __fcsr: c_uint, + } + + pub struct __riscv_mc_d_ext_state { + pub __f: [c_ulonglong; 32], + pub __fcsr: c_uint, + } + + #[repr(align(16))] + pub struct __riscv_mc_q_ext_state { + pub __f: [c_ulonglong; 64], + pub __fcsr: c_uint, + pub __glibc_reserved: [c_uint; 3], + } +} + +pub const O_LARGEFILE: c_int = 0; +pub const VEOF: usize = 4; +pub const RTLD_DEEPBIND: c_int = 0x8; +pub const RTLD_GLOBAL: c_int = 0x100; +pub const RTLD_NOLOAD: c_int = 0x4; +pub const O_APPEND: c_int = 1024; +pub const O_CREAT: c_int = 64; +pub const O_EXCL: c_int = 128; +pub const O_NOCTTY: c_int = 256; +pub const O_NONBLOCK: c_int = 2048; +pub const O_SYNC: c_int = 1052672; +pub const O_RSYNC: c_int = 1052672; +pub const O_DSYNC: c_int = 4096; +pub const O_FSYNC: c_int = 1052672; +pub const MADV_SOFT_OFFLINE: c_int = 101; +pub const MAP_GROWSDOWN: c_int = 256; +pub const EDEADLK: c_int = 35; +pub const ENAMETOOLONG: c_int = 36; +pub const ENOLCK: c_int = 37; +pub const ENOSYS: c_int = 38; +pub const ENOTEMPTY: c_int = 39; +pub const ELOOP: c_int = 40; +pub const ENOMSG: c_int = 42; +pub const EIDRM: c_int = 43; +pub const ECHRNG: c_int = 44; +pub const EL2NSYNC: c_int = 45; +pub const EL3HLT: c_int = 46; +pub const EL3RST: c_int = 47; +pub const ELNRNG: c_int = 48; +pub const EUNATCH: c_int = 49; +pub const ENOCSI: c_int = 50; +pub const EL2HLT: c_int = 51; +pub const EBADE: c_int = 52; +pub const EBADR: c_int = 53; +pub const EXFULL: c_int = 54; +pub const ENOANO: c_int = 55; +pub const EBADRQC: c_int = 56; +pub const EBADSLT: c_int = 57; +pub const EMULTIHOP: c_int = 72; +pub const EOVERFLOW: c_int = 75; +pub const ENOTUNIQ: c_int = 76; +pub const EBADFD: c_int = 77; +pub const EBADMSG: c_int = 74; +pub const EREMCHG: c_int = 78; +pub const ELIBACC: c_int = 79; +pub const ELIBBAD: c_int = 80; +pub const ELIBSCN: c_int = 81; +pub const ELIBMAX: c_int = 82; +pub const ELIBEXEC: c_int = 83; +pub const EILSEQ: c_int = 84; +pub const ERESTART: c_int = 85; +pub const ESTRPIPE: c_int = 86; +pub const EUSERS: c_int = 87; +pub const ENOTSOCK: c_int = 88; +pub const EDESTADDRREQ: c_int = 89; +pub const EMSGSIZE: c_int = 90; +pub const EPROTOTYPE: c_int = 91; +pub const ENOPROTOOPT: c_int = 92; +pub const EPROTONOSUPPORT: c_int = 93; +pub const ESOCKTNOSUPPORT: c_int = 94; +pub const EOPNOTSUPP: c_int = 95; +pub const EPFNOSUPPORT: c_int = 96; +pub const EAFNOSUPPORT: c_int = 97; +pub const EADDRINUSE: c_int = 98; +pub const EADDRNOTAVAIL: c_int = 99; +pub const ENETDOWN: c_int = 100; +pub const ENETUNREACH: c_int = 101; +pub const ENETRESET: c_int = 102; +pub const ECONNABORTED: c_int = 103; +pub const ECONNRESET: c_int = 104; +pub const ENOBUFS: c_int = 105; +pub const EISCONN: c_int = 106; +pub const ENOTCONN: c_int = 107; +pub const ESHUTDOWN: c_int = 108; +pub const ETOOMANYREFS: c_int = 109; +pub const ETIMEDOUT: c_int = 110; +pub const ECONNREFUSED: c_int = 111; +pub const EHOSTDOWN: c_int = 112; +pub const EHOSTUNREACH: c_int = 113; +pub const EALREADY: c_int = 114; +pub const EINPROGRESS: c_int = 115; +pub const ESTALE: c_int = 116; +pub const EDQUOT: c_int = 122; +pub const ENOMEDIUM: c_int = 123; +pub const EMEDIUMTYPE: c_int = 124; +pub const ECANCELED: c_int = 125; +pub const ENOKEY: c_int = 126; +pub const EKEYEXPIRED: c_int = 127; +pub const EKEYREVOKED: c_int = 128; +pub const EKEYREJECTED: c_int = 129; +pub const EOWNERDEAD: c_int = 130; +pub const ENOTRECOVERABLE: c_int = 131; +pub const EHWPOISON: c_int = 133; +pub const ERFKILL: c_int = 132; + +pub const SOCK_STREAM: c_int = 1; +pub const SOCK_DGRAM: c_int = 2; +pub const SA_SIGINFO: c_int = 4; +pub const SA_NOCLDWAIT: c_int = 2; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGCHLD: c_int = 17; +pub const SIGBUS: c_int = 7; +pub const SIGUSR1: c_int = 10; +pub const SIGUSR2: c_int = 12; +pub const SIGCONT: c_int = 18; +pub const SIGSTOP: c_int = 19; +pub const SIGTSTP: c_int = 20; +pub const SIGURG: c_int = 23; +pub const SIGIO: c_int = 29; +pub const SIGSYS: c_int = 31; +pub const SIGSTKFLT: c_int = 16; +pub const SIGPOLL: c_int = 29; +pub const SIGPWR: c_int = 30; +pub const SIG_SETMASK: c_int = 2; +pub const SIG_BLOCK: c_int = 0; +pub const SIG_UNBLOCK: c_int = 1; +pub const POLLWRNORM: c_short = 256; +pub const POLLWRBAND: c_short = 512; +pub const O_ASYNC: c_int = 8192; +pub const O_NDELAY: c_int = 2048; +pub const EFD_NONBLOCK: c_int = 2048; +pub const F_GETLK: c_int = 5; +pub const F_GETOWN: c_int = 9; +pub const F_SETOWN: c_int = 8; +pub const SFD_NONBLOCK: c_int = 2048; +pub const TCSANOW: c_int = 0; +pub const TCSADRAIN: c_int = 1; +pub const TCSAFLUSH: c_int = 2; + +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; +pub const O_DIRECT: c_int = 16384; +pub const O_DIRECTORY: c_int = 65536; +pub const O_NOFOLLOW: c_int = 131072; +pub const MAP_HUGETLB: c_int = 262144; +pub const MAP_LOCKED: c_int = 8192; +pub const MAP_NORESERVE: c_int = 16384; +pub const MAP_ANON: c_int = 32; +pub const MAP_ANONYMOUS: c_int = 32; +pub const MAP_DENYWRITE: c_int = 2048; +pub const MAP_EXECUTABLE: c_int = 4096; +pub const MAP_POPULATE: c_int = 32768; +pub const MAP_NONBLOCK: c_int = 65536; +pub const MAP_STACK: c_int = 131072; +pub const MAP_SYNC: c_int = 0x080000; +pub const EDEADLOCK: c_int = 35; +pub const EUCLEAN: c_int = 117; +pub const ENOTNAM: c_int = 118; +pub const ENAVAIL: c_int = 119; +pub const EISNAM: c_int = 120; +pub const EREMOTEIO: c_int = 121; +pub const MCL_CURRENT: c_int = 1; +pub const MCL_FUTURE: c_int = 2; +pub const MCL_ONFAULT: c_int = 4; +pub const SIGSTKSZ: size_t = 8192; +pub const MINSIGSTKSZ: size_t = 2048; +pub const CBAUD: crate::tcflag_t = 4111; +pub const TAB1: crate::tcflag_t = 2048; +pub const TAB2: crate::tcflag_t = 4096; +pub const TAB3: crate::tcflag_t = 6144; +pub const CR1: crate::tcflag_t = 512; +pub const CR2: crate::tcflag_t = 1024; +pub const CR3: crate::tcflag_t = 1536; +pub const FF1: crate::tcflag_t = 32768; +pub const BS1: crate::tcflag_t = 8192; +pub const VT1: crate::tcflag_t = 16384; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: crate::tcflag_t = 1024; +pub const IXOFF: crate::tcflag_t = 4096; +pub const ONLCR: crate::tcflag_t = 4; +pub const CSIZE: crate::tcflag_t = 48; +pub const CS6: crate::tcflag_t = 16; +pub const CS7: crate::tcflag_t = 32; +pub const CS8: crate::tcflag_t = 48; +pub const CSTOPB: crate::tcflag_t = 64; +pub const CREAD: crate::tcflag_t = 128; +pub const PARENB: crate::tcflag_t = 256; +pub const PARODD: crate::tcflag_t = 512; +pub const HUPCL: crate::tcflag_t = 1024; +pub const CLOCAL: crate::tcflag_t = 2048; +pub const ECHOKE: crate::tcflag_t = 2048; +pub const ECHOE: crate::tcflag_t = 16; +pub const ECHOK: crate::tcflag_t = 32; +pub const ECHONL: crate::tcflag_t = 64; +pub const ECHOPRT: crate::tcflag_t = 1024; +pub const ECHOCTL: crate::tcflag_t = 512; +pub const ISIG: crate::tcflag_t = 1; +pub const ICANON: crate::tcflag_t = 2; +pub const PENDIN: crate::tcflag_t = 16384; +pub const NOFLSH: crate::tcflag_t = 128; +pub const CIBAUD: crate::tcflag_t = 269418496; +pub const CBAUDEX: crate::tcflag_t = 4096; +pub const VSWTC: usize = 7; +pub const OLCUC: crate::tcflag_t = 2; +pub const NLDLY: crate::tcflag_t = 256; +pub const CRDLY: crate::tcflag_t = 1536; +pub const TABDLY: crate::tcflag_t = 6144; +pub const BSDLY: crate::tcflag_t = 8192; +pub const FFDLY: crate::tcflag_t = 32768; +pub const VTDLY: crate::tcflag_t = 16384; +pub const XTABS: crate::tcflag_t = 6144; +pub const B0: crate::speed_t = 0; +pub const B50: crate::speed_t = 1; +pub const B75: crate::speed_t = 2; +pub const B110: crate::speed_t = 3; +pub const B134: crate::speed_t = 4; +pub const B150: crate::speed_t = 5; +pub const B200: crate::speed_t = 6; +pub const B300: crate::speed_t = 7; +pub const B600: crate::speed_t = 8; +pub const B1200: crate::speed_t = 9; +pub const B1800: crate::speed_t = 10; +pub const B2400: crate::speed_t = 11; +pub const B4800: crate::speed_t = 12; +pub const B9600: crate::speed_t = 13; +pub const B19200: crate::speed_t = 14; +pub const B38400: crate::speed_t = 15; +pub const EXTA: crate::speed_t = 14; +pub const EXTB: crate::speed_t = 15; +pub const B57600: crate::speed_t = 4097; +pub const B115200: crate::speed_t = 4098; +pub const B230400: crate::speed_t = 4099; +pub const B460800: crate::speed_t = 4100; +pub const B500000: crate::speed_t = 4101; +pub const B576000: crate::speed_t = 4102; +pub const B921600: crate::speed_t = 4103; +pub const B1000000: crate::speed_t = 4104; +pub const B1152000: crate::speed_t = 4105; +pub const B1500000: crate::speed_t = 4106; +pub const B2000000: crate::speed_t = 4107; +pub const B2500000: crate::speed_t = 4108; +pub const B3000000: crate::speed_t = 4109; +pub const B3500000: crate::speed_t = 4110; +pub const B4000000: crate::speed_t = 4111; +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: crate::tcflag_t = 32768; +pub const TOSTOP: crate::tcflag_t = 256; +pub const FLUSHO: crate::tcflag_t = 4096; +pub const EXTPROC: crate::tcflag_t = 65536; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; +pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; +pub const NGREG: usize = 32; +pub const REG_PC: usize = 0; +pub const REG_RA: usize = 1; +pub const REG_SP: usize = 2; +pub const REG_TP: usize = 4; +pub const REG_S0: usize = 8; +pub const REG_S1: usize = 9; +pub const REG_A0: usize = 10; +pub const REG_S2: usize = 18; +pub const REG_NARGS: usize = 8; + +pub const SYS_read: c_long = 63; +pub const SYS_write: c_long = 64; +pub const SYS_close: c_long = 57; +pub const SYS_fstat: c_long = 80; +pub const SYS_lseek: c_long = 62; +pub const SYS_mmap: c_long = 222; +pub const SYS_mprotect: c_long = 226; +pub const SYS_munmap: c_long = 215; +pub const SYS_brk: c_long = 214; +pub const SYS_rt_sigaction: c_long = 134; +pub const SYS_rt_sigprocmask: c_long = 135; +pub const SYS_rt_sigreturn: c_long = 139; +pub const SYS_ioctl: c_long = 29; +pub const SYS_pread64: c_long = 67; +pub const SYS_pwrite64: c_long = 68; +pub const SYS_readv: c_long = 65; +pub const SYS_writev: c_long = 66; +pub const SYS_sched_yield: c_long = 124; +pub const SYS_mremap: c_long = 216; +pub const SYS_msync: c_long = 227; +pub const SYS_mincore: c_long = 232; +pub const SYS_madvise: c_long = 233; +pub const SYS_shmget: c_long = 194; +pub const SYS_shmat: c_long = 196; +pub const SYS_shmctl: c_long = 195; +pub const SYS_dup: c_long = 23; +pub const SYS_nanosleep: c_long = 101; +pub const SYS_getitimer: c_long = 102; +pub const SYS_setitimer: c_long = 103; +pub const SYS_getpid: c_long = 172; +pub const SYS_sendfile: c_long = 71; +pub const SYS_socket: c_long = 198; +pub const SYS_connect: c_long = 203; +pub const SYS_accept: c_long = 202; +pub const SYS_sendto: c_long = 206; +pub const SYS_recvfrom: c_long = 207; +pub const SYS_sendmsg: c_long = 211; +pub const SYS_recvmsg: c_long = 212; +pub const SYS_shutdown: c_long = 210; +pub const SYS_bind: c_long = 200; +pub const SYS_listen: c_long = 201; +pub const SYS_getsockname: c_long = 204; +pub const SYS_getpeername: c_long = 205; +pub const SYS_socketpair: c_long = 199; +pub const SYS_setsockopt: c_long = 208; +pub const SYS_getsockopt: c_long = 209; +pub const SYS_clone: c_long = 220; +pub const SYS_execve: c_long = 221; +pub const SYS_exit: c_long = 93; +pub const SYS_wait4: c_long = 260; +pub const SYS_kill: c_long = 129; +pub const SYS_uname: c_long = 160; +pub const SYS_semget: c_long = 190; +pub const SYS_semop: c_long = 193; +pub const SYS_semctl: c_long = 191; +pub const SYS_shmdt: c_long = 197; +pub const SYS_msgget: c_long = 186; +pub const SYS_msgsnd: c_long = 189; +pub const SYS_msgrcv: c_long = 188; +pub const SYS_msgctl: c_long = 187; +pub const SYS_fcntl: c_long = 25; +pub const SYS_flock: c_long = 32; +pub const SYS_fsync: c_long = 82; +pub const SYS_fdatasync: c_long = 83; +pub const SYS_truncate: c_long = 45; +pub const SYS_ftruncate: c_long = 46; +pub const SYS_getcwd: c_long = 17; +pub const SYS_chdir: c_long = 49; +pub const SYS_fchdir: c_long = 50; +pub const SYS_fchmod: c_long = 52; +pub const SYS_fchown: c_long = 55; +pub const SYS_umask: c_long = 166; +pub const SYS_gettimeofday: c_long = 169; +pub const SYS_getrlimit: c_long = 163; +pub const SYS_getrusage: c_long = 165; +pub const SYS_sysinfo: c_long = 179; +pub const SYS_times: c_long = 153; +pub const SYS_ptrace: c_long = 117; +pub const SYS_getuid: c_long = 174; +pub const SYS_syslog: c_long = 116; +pub const SYS_getgid: c_long = 176; +pub const SYS_setuid: c_long = 146; +pub const SYS_setgid: c_long = 144; +pub const SYS_geteuid: c_long = 175; +pub const SYS_getegid: c_long = 177; +pub const SYS_setpgid: c_long = 154; +pub const SYS_getppid: c_long = 173; +pub const SYS_setsid: c_long = 157; +pub const SYS_setreuid: c_long = 145; +pub const SYS_setregid: c_long = 143; +pub const SYS_getgroups: c_long = 158; +pub const SYS_setgroups: c_long = 159; +pub const SYS_setresuid: c_long = 147; +pub const SYS_getresuid: c_long = 148; +pub const SYS_setresgid: c_long = 149; +pub const SYS_getresgid: c_long = 150; +pub const SYS_getpgid: c_long = 155; +pub const SYS_setfsuid: c_long = 151; +pub const SYS_setfsgid: c_long = 152; +pub const SYS_getsid: c_long = 156; +pub const SYS_capget: c_long = 90; +pub const SYS_capset: c_long = 91; +pub const SYS_rt_sigpending: c_long = 136; +pub const SYS_rt_sigtimedwait: c_long = 137; +pub const SYS_rt_sigqueueinfo: c_long = 138; +pub const SYS_rt_sigsuspend: c_long = 133; +pub const SYS_sigaltstack: c_long = 132; +pub const SYS_personality: c_long = 92; +pub const SYS_statfs: c_long = 43; +pub const SYS_fstatfs: c_long = 44; +pub const SYS_getpriority: c_long = 141; +pub const SYS_setpriority: c_long = 140; +pub const SYS_sched_setparam: c_long = 118; +pub const SYS_sched_getparam: c_long = 121; +pub const SYS_sched_setscheduler: c_long = 119; +pub const SYS_sched_getscheduler: c_long = 120; +pub const SYS_sched_get_priority_max: c_long = 125; +pub const SYS_sched_get_priority_min: c_long = 126; +pub const SYS_sched_rr_get_interval: c_long = 127; +pub const SYS_mlock: c_long = 228; +pub const SYS_munlock: c_long = 229; +pub const SYS_mlockall: c_long = 230; +pub const SYS_munlockall: c_long = 231; +pub const SYS_vhangup: c_long = 58; +pub const SYS_pivot_root: c_long = 41; +pub const SYS_prctl: c_long = 167; +pub const SYS_adjtimex: c_long = 171; +pub const SYS_setrlimit: c_long = 164; +pub const SYS_chroot: c_long = 51; +pub const SYS_sync: c_long = 81; +pub const SYS_acct: c_long = 89; +pub const SYS_settimeofday: c_long = 170; +pub const SYS_mount: c_long = 40; +pub const SYS_umount2: c_long = 39; +pub const SYS_swapon: c_long = 224; +pub const SYS_swapoff: c_long = 225; +pub const SYS_reboot: c_long = 142; +pub const SYS_sethostname: c_long = 161; +pub const SYS_setdomainname: c_long = 162; +pub const SYS_init_module: c_long = 105; +pub const SYS_delete_module: c_long = 106; +pub const SYS_quotactl: c_long = 60; +pub const SYS_nfsservctl: c_long = 42; +pub const SYS_gettid: c_long = 178; +pub const SYS_readahead: c_long = 213; +pub const SYS_setxattr: c_long = 5; +pub const SYS_lsetxattr: c_long = 6; +pub const SYS_fsetxattr: c_long = 7; +pub const SYS_getxattr: c_long = 8; +pub const SYS_lgetxattr: c_long = 9; +pub const SYS_fgetxattr: c_long = 10; +pub const SYS_listxattr: c_long = 11; +pub const SYS_llistxattr: c_long = 12; +pub const SYS_flistxattr: c_long = 13; +pub const SYS_removexattr: c_long = 14; +pub const SYS_lremovexattr: c_long = 15; +pub const SYS_fremovexattr: c_long = 16; +pub const SYS_tkill: c_long = 130; +pub const SYS_futex: c_long = 98; +pub const SYS_sched_setaffinity: c_long = 122; +pub const SYS_sched_getaffinity: c_long = 123; +pub const SYS_io_setup: c_long = 0; +pub const SYS_io_destroy: c_long = 1; +pub const SYS_io_getevents: c_long = 4; +pub const SYS_io_submit: c_long = 2; +pub const SYS_io_cancel: c_long = 3; +pub const SYS_lookup_dcookie: c_long = 18; +pub const SYS_remap_file_pages: c_long = 234; +pub const SYS_getdents64: c_long = 61; +pub const SYS_set_tid_address: c_long = 96; +pub const SYS_restart_syscall: c_long = 128; +pub const SYS_semtimedop: c_long = 192; +pub const SYS_fadvise64: c_long = 223; +pub const SYS_timer_create: c_long = 107; +pub const SYS_timer_settime: c_long = 110; +pub const SYS_timer_gettime: c_long = 108; +pub const SYS_timer_getoverrun: c_long = 109; +pub const SYS_timer_delete: c_long = 111; +pub const SYS_clock_settime: c_long = 112; +pub const SYS_clock_gettime: c_long = 113; +pub const SYS_clock_getres: c_long = 114; +pub const SYS_clock_nanosleep: c_long = 115; +pub const SYS_exit_group: c_long = 94; +pub const SYS_epoll_ctl: c_long = 21; +pub const SYS_tgkill: c_long = 131; +pub const SYS_mbind: c_long = 235; +pub const SYS_set_mempolicy: c_long = 237; +pub const SYS_get_mempolicy: c_long = 236; +pub const SYS_mq_open: c_long = 180; +pub const SYS_mq_unlink: c_long = 181; +pub const SYS_mq_timedsend: c_long = 182; +pub const SYS_mq_timedreceive: c_long = 183; +pub const SYS_mq_notify: c_long = 184; +pub const SYS_mq_getsetattr: c_long = 185; +pub const SYS_kexec_load: c_long = 104; +pub const SYS_waitid: c_long = 95; +pub const SYS_add_key: c_long = 217; +pub const SYS_request_key: c_long = 218; +pub const SYS_keyctl: c_long = 219; +pub const SYS_ioprio_set: c_long = 30; +pub const SYS_ioprio_get: c_long = 31; +pub const SYS_inotify_add_watch: c_long = 27; +pub const SYS_inotify_rm_watch: c_long = 28; +pub const SYS_migrate_pages: c_long = 238; +pub const SYS_openat: c_long = 56; +pub const SYS_mkdirat: c_long = 34; +pub const SYS_mknodat: c_long = 33; +pub const SYS_fchownat: c_long = 54; +pub const SYS_newfstatat: c_long = 79; +pub const SYS_unlinkat: c_long = 35; +pub const SYS_linkat: c_long = 37; +pub const SYS_symlinkat: c_long = 36; +pub const SYS_readlinkat: c_long = 78; +pub const SYS_fchmodat: c_long = 53; +pub const SYS_faccessat: c_long = 48; +pub const SYS_pselect6: c_long = 72; +pub const SYS_ppoll: c_long = 73; +pub const SYS_unshare: c_long = 97; +pub const SYS_set_robust_list: c_long = 99; +pub const SYS_get_robust_list: c_long = 100; +pub const SYS_splice: c_long = 76; +pub const SYS_tee: c_long = 77; +pub const SYS_sync_file_range: c_long = 84; +pub const SYS_vmsplice: c_long = 75; +pub const SYS_move_pages: c_long = 239; +pub const SYS_utimensat: c_long = 88; +pub const SYS_epoll_pwait: c_long = 22; +pub const SYS_timerfd_create: c_long = 85; +pub const SYS_fallocate: c_long = 47; +pub const SYS_timerfd_settime: c_long = 86; +pub const SYS_timerfd_gettime: c_long = 87; +pub const SYS_accept4: c_long = 242; +pub const SYS_signalfd4: c_long = 74; +pub const SYS_eventfd2: c_long = 19; +pub const SYS_epoll_create1: c_long = 20; +pub const SYS_dup3: c_long = 24; +pub const SYS_pipe2: c_long = 59; +pub const SYS_inotify_init1: c_long = 26; +pub const SYS_preadv: c_long = 69; +pub const SYS_pwritev: c_long = 70; +pub const SYS_rt_tgsigqueueinfo: c_long = 240; +pub const SYS_perf_event_open: c_long = 241; +pub const SYS_recvmmsg: c_long = 243; +pub const SYS_fanotify_init: c_long = 262; +pub const SYS_fanotify_mark: c_long = 263; +pub const SYS_prlimit64: c_long = 261; +pub const SYS_name_to_handle_at: c_long = 264; +pub const SYS_open_by_handle_at: c_long = 265; +pub const SYS_clock_adjtime: c_long = 266; +pub const SYS_syncfs: c_long = 267; +pub const SYS_sendmmsg: c_long = 269; +pub const SYS_setns: c_long = 268; +pub const SYS_getcpu: c_long = 168; +pub const SYS_process_vm_readv: c_long = 270; +pub const SYS_process_vm_writev: c_long = 271; +pub const SYS_kcmp: c_long = 272; +pub const SYS_finit_module: c_long = 273; +pub const SYS_sched_setattr: c_long = 274; +pub const SYS_sched_getattr: c_long = 275; +pub const SYS_renameat2: c_long = 276; +pub const SYS_seccomp: c_long = 277; +pub const SYS_getrandom: c_long = 278; +pub const SYS_memfd_create: c_long = 279; +pub const SYS_bpf: c_long = 280; +pub const SYS_execveat: c_long = 281; +pub const SYS_userfaultfd: c_long = 282; +pub const SYS_membarrier: c_long = 283; +pub const SYS_mlock2: c_long = 284; +pub const SYS_copy_file_range: c_long = 285; +pub const SYS_preadv2: c_long = 286; +pub const SYS_pwritev2: c_long = 287; +pub const SYS_pkey_mprotect: c_long = 288; +pub const SYS_pkey_alloc: c_long = 289; +pub const SYS_pkey_free: c_long = 290; +pub const SYS_statx: c_long = 291; +pub const SYS_rseq: c_long = 293; +pub const SYS_pidfd_send_signal: c_long = 424; +pub const SYS_io_uring_setup: c_long = 425; +pub const SYS_io_uring_enter: c_long = 426; +pub const SYS_io_uring_register: c_long = 427; +pub const SYS_open_tree: c_long = 428; +pub const SYS_move_mount: c_long = 429; +pub const SYS_fsopen: c_long = 430; +pub const SYS_fsconfig: c_long = 431; +pub const SYS_fsmount: c_long = 432; +pub const SYS_fspick: c_long = 433; +pub const SYS_pidfd_open: c_long = 434; +pub const SYS_clone3: c_long = 435; +pub const SYS_close_range: c_long = 436; +pub const SYS_openat2: c_long = 437; +pub const SYS_pidfd_getfd: c_long = 438; +pub const SYS_faccessat2: c_long = 439; +pub const SYS_process_madvise: c_long = 440; +pub const SYS_epoll_pwait2: c_long = 441; +pub const SYS_mount_setattr: c_long = 442; +pub const SYS_quotactl_fd: c_long = 443; +pub const SYS_landlock_create_ruleset: c_long = 444; +pub const SYS_landlock_add_rule: c_long = 445; +pub const SYS_landlock_restrict_self: c_long = 446; +pub const SYS_memfd_secret: c_long = 447; +pub const SYS_process_mrelease: c_long = 448; +pub const SYS_futex_waitv: c_long = 449; +pub const SYS_set_mempolicy_home_node: c_long = 450; diff --git a/http/vendor/libc/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs new file mode 100644 index 0000000..75fefcd --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs @@ -0,0 +1,868 @@ +//! SPARC-specific definitions for 32-bit linux-like values + +use crate::prelude::*; +use crate::{ + off64_t, + off_t, +}; + +pub type wchar_t = i32; + +s! { + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigaction { + pub sa_sigaction: crate::sighandler_t, + pub sa_mask: crate::sigset_t, + pub sa_flags: c_int, + pub sa_restorer: Option, + } + + pub struct statfs { + pub f_type: crate::__fsword_t, + pub f_bsize: crate::__fsword_t, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_fsid: crate::fsid_t, + + pub f_namelen: crate::__fsword_t, + pub f_frsize: crate::__fsword_t, + pub f_flags: crate::__fsword_t, + f_spare: [crate::__fsword_t; 4], + } + + pub struct siginfo_t { + pub si_signo: c_int, + pub si_errno: c_int, + pub si_code: c_int, + _pad: Padding<[c_int; 29]>, + _align: [usize; 0], + } + + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off_t, + pub l_len: off_t, + pub l_pid: crate::pid_t, + } + + pub struct flock64 { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off64_t, + pub l_len: off64_t, + pub l_pid: crate::pid_t, + __reserved: Padding, + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_flags: c_int, + pub ss_size: size_t, + } + + pub struct stat { + pub st_dev: crate::dev_t, + #[cfg(not(gnu_file_offset_bits64))] + __pad1: Padding, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + __pad2: Padding, + pub st_size: off_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + __glibc_reserved4: Padding, + __glibc_reserved5: Padding, + } + + pub struct stat64 { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino64_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + __pad2: Padding, + pub st_size: off64_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt64_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + __glibc_reserved4: Padding, + __glibc_reserved5: Padding, + } + + pub struct statfs64 { + pub f_type: crate::__fsword_t, + pub f_bsize: crate::__fsword_t, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_fsid: crate::fsid_t, + pub f_namelen: crate::__fsword_t, + pub f_frsize: crate::__fsword_t, + pub f_flags: crate::__fsword_t, + pub f_spare: [crate::__fsword_t; 4], + } + + pub struct statvfs64 { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: c_ulong, + __f_unused: Padding, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: [c_int; 6], + } + + pub struct ipc_perm { + pub __key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + __pad1: Padding, + pub mode: c_ushort, + __pad2: Padding, + pub __seq: c_ushort, + __unused1: Padding, + __unused2: Padding, + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + #[cfg(gnu_time_bits64)] + pub shm_segsz: size_t, + #[cfg(not(gnu_time_bits64))] + __pad1: Padding, + pub shm_atime: crate::time_t, + #[cfg(not(gnu_time_bits64))] + __pad2: Padding, + pub shm_dtime: crate::time_t, + #[cfg(not(gnu_time_bits64))] + __pad3: Padding, + pub shm_ctime: crate::time_t, + #[cfg(not(gnu_time_bits64))] + pub shm_segsz: size_t, + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: crate::shmatt_t, + __reserved1: Padding, + __reserved2: Padding, + } + + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + #[cfg(not(gnu_time_bits64))] + __pad1: Padding, + pub msg_stime: crate::time_t, + #[cfg(not(gnu_time_bits64))] + __pad2: Padding, + pub msg_rtime: crate::time_t, + #[cfg(not(gnu_time_bits64))] + __pad3: Padding, + pub msg_ctime: crate::time_t, + pub __msg_cbytes: c_ulong, + pub msg_qnum: crate::msgqnum_t, + pub msg_qbytes: crate::msglen_t, + pub msg_lspid: crate::pid_t, + pub msg_lrpid: crate::pid_t, + __glibc_reserved4: Padding, + __glibc_reserved5: Padding, + } +} + +s_no_extra_traits! { + #[repr(align(8))] + pub struct max_align_t { + priv_: [i64; 3], + } +} + +pub const VEOF: usize = 4; +pub const RTLD_DEEPBIND: c_int = 0x8; +pub const RTLD_GLOBAL: c_int = 0x100; +pub const RTLD_NOLOAD: c_int = 0x4; + +pub const O_APPEND: c_int = 0x8; +pub const O_CREAT: c_int = 0x200; +pub const O_EXCL: c_int = 0x800; +pub const O_NOCTTY: c_int = 0x8000; +pub const O_NONBLOCK: c_int = 0x4000; +pub const O_SYNC: c_int = 0x802000; +pub const O_RSYNC: c_int = 0x802000; +pub const O_DSYNC: c_int = 0x2000; +pub const O_FSYNC: c_int = 0x802000; + +pub const MADV_SOFT_OFFLINE: c_int = 101; +pub const MAP_GROWSDOWN: c_int = 0x0200; +pub const MAP_ANON: c_int = 0x0020; +pub const MAP_ANONYMOUS: c_int = 0x0020; +pub const MAP_DENYWRITE: c_int = 0x0800; +pub const MAP_EXECUTABLE: c_int = 0x01000; +pub const MAP_POPULATE: c_int = 0x08000; +pub const MAP_NONBLOCK: c_int = 0x010000; +pub const MAP_STACK: c_int = 0x020000; +pub const MAP_HUGETLB: c_int = 0x040000; +pub const MAP_SYNC: c_int = 0x080000; + +pub const EDEADLK: c_int = 78; +pub const ENAMETOOLONG: c_int = 63; +pub const ENOLCK: c_int = 79; +pub const ENOSYS: c_int = 90; +pub const ENOTEMPTY: c_int = 66; +pub const ELOOP: c_int = 62; +pub const ENOMSG: c_int = 75; +pub const EIDRM: c_int = 77; +pub const ECHRNG: c_int = 94; +pub const EL2NSYNC: c_int = 95; +pub const EL3HLT: c_int = 96; +pub const EL3RST: c_int = 97; +pub const ELNRNG: c_int = 98; +pub const EUNATCH: c_int = 99; +pub const ENOCSI: c_int = 100; +pub const EL2HLT: c_int = 101; +pub const EBADE: c_int = 102; +pub const EBADR: c_int = 103; +pub const EXFULL: c_int = 104; +pub const ENOANO: c_int = 105; +pub const EBADRQC: c_int = 106; +pub const EBADSLT: c_int = 107; +pub const EMULTIHOP: c_int = 87; +pub const EOVERFLOW: c_int = 92; +pub const ENOTUNIQ: c_int = 115; +pub const EBADFD: c_int = 93; +pub const EBADMSG: c_int = 76; +pub const EREMCHG: c_int = 89; +pub const ELIBACC: c_int = 114; +pub const ELIBBAD: c_int = 112; +pub const ELIBSCN: c_int = 124; +pub const ELIBMAX: c_int = 123; +pub const ELIBEXEC: c_int = 110; +pub const EILSEQ: c_int = 122; +pub const ERESTART: c_int = 116; +pub const ESTRPIPE: c_int = 91; +pub const EUSERS: c_int = 68; +pub const ENOTSOCK: c_int = 38; +pub const EDESTADDRREQ: c_int = 39; +pub const EMSGSIZE: c_int = 40; +pub const EPROTOTYPE: c_int = 41; +pub const ENOPROTOOPT: c_int = 42; +pub const EPROTONOSUPPORT: c_int = 43; +pub const ESOCKTNOSUPPORT: c_int = 44; +pub const EOPNOTSUPP: c_int = 45; +pub const EPFNOSUPPORT: c_int = 46; +pub const EAFNOSUPPORT: c_int = 47; +pub const EADDRINUSE: c_int = 48; +pub const EADDRNOTAVAIL: c_int = 49; +pub const ENETDOWN: c_int = 50; +pub const ENETUNREACH: c_int = 51; +pub const ENETRESET: c_int = 52; +pub const ECONNABORTED: c_int = 53; +pub const ECONNRESET: c_int = 54; +pub const ENOBUFS: c_int = 55; +pub const EISCONN: c_int = 56; +pub const ENOTCONN: c_int = 57; +pub const ESHUTDOWN: c_int = 58; +pub const ETOOMANYREFS: c_int = 59; +pub const ETIMEDOUT: c_int = 60; +pub const ECONNREFUSED: c_int = 61; +pub const EHOSTDOWN: c_int = 64; +pub const EHOSTUNREACH: c_int = 65; +pub const EALREADY: c_int = 37; +pub const EINPROGRESS: c_int = 36; +pub const ESTALE: c_int = 70; +pub const EDQUOT: c_int = 69; +pub const ENOMEDIUM: c_int = 125; +pub const EMEDIUMTYPE: c_int = 126; +pub const ECANCELED: c_int = 127; +pub const ENOKEY: c_int = 128; +pub const EKEYEXPIRED: c_int = 129; +pub const EKEYREVOKED: c_int = 130; +pub const EKEYREJECTED: c_int = 131; +pub const EOWNERDEAD: c_int = 132; +pub const ENOTRECOVERABLE: c_int = 133; +pub const EHWPOISON: c_int = 135; +pub const ERFKILL: c_int = 134; + +pub const SOCK_STREAM: c_int = 1; +pub const SOCK_DGRAM: c_int = 2; + +pub const SA_SIGINFO: c_int = 0x200; +pub const SA_NOCLDWAIT: c_int = 0x100; + +pub const SIGEMT: c_int = 7; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGCHLD: c_int = 20; +pub const SIGBUS: c_int = 10; +pub const SIGUSR1: c_int = 30; +pub const SIGUSR2: c_int = 31; +pub const SIGCONT: c_int = 19; +pub const SIGSTOP: c_int = 17; +pub const SIGTSTP: c_int = 18; +pub const SIGURG: c_int = 16; +pub const SIGIO: c_int = 23; +pub const SIGSYS: c_int = 12; +pub const SIGPOLL: c_int = 23; +pub const SIGPWR: c_int = 29; +pub const SIG_SETMASK: c_int = 4; +pub const SIG_BLOCK: c_int = 1; +pub const SIG_UNBLOCK: c_int = 2; + +pub const POLLWRNORM: c_short = 4; +pub const POLLWRBAND: c_short = 0x100; + +pub const O_ASYNC: c_int = 0x40; +pub const O_NDELAY: c_int = 0x4004; + +pub const EFD_NONBLOCK: c_int = 0x4000; + +pub const F_GETLK: c_int = 7; +pub const F_GETOWN: c_int = 5; +pub const F_SETOWN: c_int = 6; + +pub const SFD_NONBLOCK: c_int = 0x4000; + +pub const TCSANOW: c_int = 0; +pub const TCSADRAIN: c_int = 1; +pub const TCSAFLUSH: c_int = 2; + +pub const O_DIRECTORY: c_int = 0o200000; +pub const O_NOFOLLOW: c_int = 0o400000; +pub const O_LARGEFILE: c_int = 0x40000; +pub const O_DIRECT: c_int = 0x100000; + +pub const MAP_LOCKED: c_int = 0x0100; +pub const MAP_NORESERVE: c_int = 0x00040; + +pub const EDEADLOCK: c_int = 108; +pub const EUCLEAN: c_int = 117; +pub const ENOTNAM: c_int = 118; +pub const ENAVAIL: c_int = 119; +pub const EISNAM: c_int = 120; +pub const EREMOTEIO: c_int = 121; + +pub const MCL_CURRENT: c_int = 0x2000; +pub const MCL_FUTURE: c_int = 0x4000; +pub const MCL_ONFAULT: c_int = 0x8000; + +pub const SIGSTKSZ: size_t = 16384; +pub const MINSIGSTKSZ: size_t = 4096; +pub const CBAUD: crate::tcflag_t = 0x0000100f; +pub const TAB1: crate::tcflag_t = 0x800; +pub const TAB2: crate::tcflag_t = 0x1000; +pub const TAB3: crate::tcflag_t = 0x1800; +pub const CR1: crate::tcflag_t = 0x200; +pub const CR2: crate::tcflag_t = 0x400; +pub const CR3: crate::tcflag_t = 0x600; +pub const FF1: crate::tcflag_t = 0x8000; +pub const BS1: crate::tcflag_t = 0x2000; +pub const VT1: crate::tcflag_t = 0x4000; +pub const VWERASE: usize = 0xe; +pub const VREPRINT: usize = 0xc; +pub const VSUSP: usize = 0xa; +pub const VSTART: usize = 0x8; +pub const VSTOP: usize = 0x9; +pub const VDISCARD: usize = 0xd; +pub const VTIME: usize = 0x5; +pub const IXON: crate::tcflag_t = 0x400; +pub const IXOFF: crate::tcflag_t = 0x1000; +pub const ONLCR: crate::tcflag_t = 0x4; +pub const CSIZE: crate::tcflag_t = 0x30; +pub const CS6: crate::tcflag_t = 0x10; +pub const CS7: crate::tcflag_t = 0x20; +pub const CS8: crate::tcflag_t = 0x30; +pub const CSTOPB: crate::tcflag_t = 0x40; +pub const CREAD: crate::tcflag_t = 0x80; +pub const PARENB: crate::tcflag_t = 0x100; +pub const PARODD: crate::tcflag_t = 0x200; +pub const HUPCL: crate::tcflag_t = 0x400; +pub const CLOCAL: crate::tcflag_t = 0x800; +pub const ECHOKE: crate::tcflag_t = 0x800; +pub const ECHOE: crate::tcflag_t = 0x10; +pub const ECHOK: crate::tcflag_t = 0x20; +pub const ECHONL: crate::tcflag_t = 0x40; +pub const ECHOPRT: crate::tcflag_t = 0x400; +pub const ECHOCTL: crate::tcflag_t = 0x200; +pub const ISIG: crate::tcflag_t = 0x1; +pub const ICANON: crate::tcflag_t = 0x2; +pub const PENDIN: crate::tcflag_t = 0x4000; +pub const NOFLSH: crate::tcflag_t = 0x80; +pub const CIBAUD: crate::tcflag_t = 0o02003600000; +pub const CBAUDEX: crate::tcflag_t = 0x00001000; +pub const VSWTC: usize = 7; +pub const OLCUC: crate::tcflag_t = 0o000002; +pub const NLDLY: crate::tcflag_t = 0o000400; +pub const CRDLY: crate::tcflag_t = 0o003000; +pub const TABDLY: crate::tcflag_t = 0o014000; +pub const BSDLY: crate::tcflag_t = 0o020000; +pub const FFDLY: crate::tcflag_t = 0o100000; +pub const VTDLY: crate::tcflag_t = 0o040000; +pub const XTABS: crate::tcflag_t = 0o014000; + +pub const B0: crate::speed_t = 0o000000; +pub const B50: crate::speed_t = 0o000001; +pub const B75: crate::speed_t = 0o000002; +pub const B110: crate::speed_t = 0o000003; +pub const B134: crate::speed_t = 0o000004; +pub const B150: crate::speed_t = 0o000005; +pub const B200: crate::speed_t = 0o000006; +pub const B300: crate::speed_t = 0o000007; +pub const B600: crate::speed_t = 0o000010; +pub const B1200: crate::speed_t = 0o000011; +pub const B1800: crate::speed_t = 0o000012; +pub const B2400: crate::speed_t = 0o000013; +pub const B4800: crate::speed_t = 0o000014; +pub const B9600: crate::speed_t = 0o000015; +pub const B19200: crate::speed_t = 0o000016; +pub const B38400: crate::speed_t = 0o000017; +pub const EXTA: crate::speed_t = B19200; +pub const EXTB: crate::speed_t = B38400; +pub const B57600: crate::speed_t = 0x1001; +pub const B115200: crate::speed_t = 0x1002; +pub const B230400: crate::speed_t = 0x1003; +pub const B460800: crate::speed_t = 0x1004; +pub const B76800: crate::speed_t = 0x1005; +pub const B153600: crate::speed_t = 0x1006; +pub const B307200: crate::speed_t = 0x1007; +pub const B614400: crate::speed_t = 0x1008; +pub const B921600: crate::speed_t = 0x1009; +pub const B500000: crate::speed_t = 0x100a; +pub const B576000: crate::speed_t = 0x100b; +pub const B1000000: crate::speed_t = 0x100c; +pub const B1152000: crate::speed_t = 0x100d; +pub const B1500000: crate::speed_t = 0x100e; +pub const B2000000: crate::speed_t = 0x100f; + +pub const VEOL: usize = 5; +pub const VEOL2: usize = 6; +pub const VMIN: usize = 4; +pub const IEXTEN: crate::tcflag_t = 0x8000; +pub const TOSTOP: crate::tcflag_t = 0x100; +pub const FLUSHO: crate::tcflag_t = 0x1000; +pub const EXTPROC: crate::tcflag_t = 0x10000; + +pub const SYS_restart_syscall: c_long = 0; +pub const SYS_exit: c_long = 1; +pub const SYS_fork: c_long = 2; +pub const SYS_read: c_long = 3; +pub const SYS_write: c_long = 4; +pub const SYS_open: c_long = 5; +pub const SYS_close: c_long = 6; +pub const SYS_wait4: c_long = 7; +pub const SYS_creat: c_long = 8; +pub const SYS_link: c_long = 9; +pub const SYS_unlink: c_long = 10; +pub const SYS_execv: c_long = 11; +pub const SYS_chdir: c_long = 12; +pub const SYS_chown: c_long = 13; +pub const SYS_mknod: c_long = 14; +pub const SYS_chmod: c_long = 15; +pub const SYS_lchown: c_long = 16; +pub const SYS_brk: c_long = 17; +pub const SYS_perfctr: c_long = 18; +pub const SYS_lseek: c_long = 19; +pub const SYS_getpid: c_long = 20; +pub const SYS_capget: c_long = 21; +pub const SYS_capset: c_long = 22; +pub const SYS_setuid: c_long = 23; +pub const SYS_getuid: c_long = 24; +pub const SYS_vmsplice: c_long = 25; +pub const SYS_ptrace: c_long = 26; +pub const SYS_alarm: c_long = 27; +pub const SYS_sigaltstack: c_long = 28; +pub const SYS_pause: c_long = 29; +pub const SYS_utime: c_long = 30; +pub const SYS_lchown32: c_long = 31; +pub const SYS_fchown32: c_long = 32; +pub const SYS_access: c_long = 33; +pub const SYS_nice: c_long = 34; +pub const SYS_chown32: c_long = 35; +pub const SYS_sync: c_long = 36; +pub const SYS_kill: c_long = 37; +pub const SYS_stat: c_long = 38; +pub const SYS_sendfile: c_long = 39; +pub const SYS_lstat: c_long = 40; +pub const SYS_dup: c_long = 41; +pub const SYS_pipe: c_long = 42; +pub const SYS_times: c_long = 43; +pub const SYS_getuid32: c_long = 44; +pub const SYS_umount2: c_long = 45; +pub const SYS_setgid: c_long = 46; +pub const SYS_getgid: c_long = 47; +pub const SYS_signal: c_long = 48; +pub const SYS_geteuid: c_long = 49; +pub const SYS_getegid: c_long = 50; +pub const SYS_acct: c_long = 51; +pub const SYS_getgid32: c_long = 53; +pub const SYS_ioctl: c_long = 54; +pub const SYS_reboot: c_long = 55; +pub const SYS_mmap2: c_long = 56; +pub const SYS_symlink: c_long = 57; +pub const SYS_readlink: c_long = 58; +pub const SYS_execve: c_long = 59; +pub const SYS_umask: c_long = 60; +pub const SYS_chroot: c_long = 61; +pub const SYS_fstat: c_long = 62; +pub const SYS_fstat64: c_long = 63; +pub const SYS_getpagesize: c_long = 64; +pub const SYS_msync: c_long = 65; +pub const SYS_vfork: c_long = 66; +pub const SYS_pread64: c_long = 67; +pub const SYS_pwrite64: c_long = 68; +pub const SYS_geteuid32: c_long = 69; +pub const SYS_getegid32: c_long = 70; +pub const SYS_mmap: c_long = 71; +pub const SYS_setreuid32: c_long = 72; +pub const SYS_munmap: c_long = 73; +pub const SYS_mprotect: c_long = 74; +pub const SYS_madvise: c_long = 75; +pub const SYS_vhangup: c_long = 76; +pub const SYS_truncate64: c_long = 77; +pub const SYS_mincore: c_long = 78; +pub const SYS_getgroups: c_long = 79; +pub const SYS_setgroups: c_long = 80; +pub const SYS_getpgrp: c_long = 81; +pub const SYS_setgroups32: c_long = 82; +pub const SYS_setitimer: c_long = 83; +pub const SYS_ftruncate64: c_long = 84; +pub const SYS_swapon: c_long = 85; +pub const SYS_getitimer: c_long = 86; +pub const SYS_setuid32: c_long = 87; +pub const SYS_sethostname: c_long = 88; +pub const SYS_setgid32: c_long = 89; +pub const SYS_dup2: c_long = 90; +pub const SYS_setfsuid32: c_long = 91; +pub const SYS_fcntl: c_long = 92; +pub const SYS_select: c_long = 93; +pub const SYS_setfsgid32: c_long = 94; +pub const SYS_fsync: c_long = 95; +pub const SYS_setpriority: c_long = 96; +pub const SYS_socket: c_long = 97; +pub const SYS_connect: c_long = 98; +pub const SYS_accept: c_long = 99; +pub const SYS_getpriority: c_long = 100; +pub const SYS_rt_sigreturn: c_long = 101; +pub const SYS_rt_sigaction: c_long = 102; +pub const SYS_rt_sigprocmask: c_long = 103; +pub const SYS_rt_sigpending: c_long = 104; +pub const SYS_rt_sigtimedwait: c_long = 105; +pub const SYS_rt_sigqueueinfo: c_long = 106; +pub const SYS_rt_sigsuspend: c_long = 107; +pub const SYS_setresuid32: c_long = 108; +pub const SYS_getresuid32: c_long = 109; +pub const SYS_setresgid32: c_long = 110; +pub const SYS_getresgid32: c_long = 111; +pub const SYS_setregid32: c_long = 112; +pub const SYS_recvmsg: c_long = 113; +pub const SYS_sendmsg: c_long = 114; +pub const SYS_getgroups32: c_long = 115; +pub const SYS_gettimeofday: c_long = 116; +pub const SYS_getrusage: c_long = 117; +pub const SYS_getsockopt: c_long = 118; +pub const SYS_getcwd: c_long = 119; +pub const SYS_readv: c_long = 120; +pub const SYS_writev: c_long = 121; +pub const SYS_settimeofday: c_long = 122; +pub const SYS_fchown: c_long = 123; +pub const SYS_fchmod: c_long = 124; +pub const SYS_recvfrom: c_long = 125; +pub const SYS_setreuid: c_long = 126; +pub const SYS_setregid: c_long = 127; +pub const SYS_rename: c_long = 128; +pub const SYS_truncate: c_long = 129; +pub const SYS_ftruncate: c_long = 130; +pub const SYS_flock: c_long = 131; +pub const SYS_lstat64: c_long = 132; +pub const SYS_sendto: c_long = 133; +pub const SYS_shutdown: c_long = 134; +pub const SYS_socketpair: c_long = 135; +pub const SYS_mkdir: c_long = 136; +pub const SYS_rmdir: c_long = 137; +pub const SYS_utimes: c_long = 138; +pub const SYS_stat64: c_long = 139; +pub const SYS_sendfile64: c_long = 140; +pub const SYS_getpeername: c_long = 141; +pub const SYS_futex: c_long = 142; +pub const SYS_gettid: c_long = 143; +pub const SYS_getrlimit: c_long = 144; +pub const SYS_setrlimit: c_long = 145; +pub const SYS_pivot_root: c_long = 146; +pub const SYS_prctl: c_long = 147; +pub const SYS_pciconfig_read: c_long = 148; +pub const SYS_pciconfig_write: c_long = 149; +pub const SYS_getsockname: c_long = 150; +pub const SYS_inotify_init: c_long = 151; +pub const SYS_inotify_add_watch: c_long = 152; +pub const SYS_poll: c_long = 153; +pub const SYS_getdents64: c_long = 154; +pub const SYS_fcntl64: c_long = 155; +pub const SYS_inotify_rm_watch: c_long = 156; +pub const SYS_statfs: c_long = 157; +pub const SYS_fstatfs: c_long = 158; +pub const SYS_umount: c_long = 159; +pub const SYS_sched_set_affinity: c_long = 160; +pub const SYS_sched_get_affinity: c_long = 161; +pub const SYS_getdomainname: c_long = 162; +pub const SYS_setdomainname: c_long = 163; +pub const SYS_quotactl: c_long = 165; +pub const SYS_set_tid_address: c_long = 166; +pub const SYS_mount: c_long = 167; +pub const SYS_ustat: c_long = 168; +pub const SYS_setxattr: c_long = 169; +pub const SYS_lsetxattr: c_long = 170; +pub const SYS_fsetxattr: c_long = 171; +pub const SYS_getxattr: c_long = 172; +pub const SYS_lgetxattr: c_long = 173; +pub const SYS_getdents: c_long = 174; +pub const SYS_setsid: c_long = 175; +pub const SYS_fchdir: c_long = 176; +pub const SYS_fgetxattr: c_long = 177; +pub const SYS_listxattr: c_long = 178; +pub const SYS_llistxattr: c_long = 179; +pub const SYS_flistxattr: c_long = 180; +pub const SYS_removexattr: c_long = 181; +pub const SYS_lremovexattr: c_long = 182; +pub const SYS_sigpending: c_long = 183; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_query_module: c_long = 184; +pub const SYS_setpgid: c_long = 185; +pub const SYS_fremovexattr: c_long = 186; +pub const SYS_tkill: c_long = 187; +pub const SYS_exit_group: c_long = 188; +pub const SYS_uname: c_long = 189; +pub const SYS_init_module: c_long = 190; +pub const SYS_personality: c_long = 191; +pub const SYS_remap_file_pages: c_long = 192; +pub const SYS_epoll_create: c_long = 193; +pub const SYS_epoll_ctl: c_long = 194; +pub const SYS_epoll_wait: c_long = 195; +pub const SYS_ioprio_set: c_long = 196; +pub const SYS_getppid: c_long = 197; +pub const SYS_sigaction: c_long = 198; +pub const SYS_sgetmask: c_long = 199; +pub const SYS_ssetmask: c_long = 200; +pub const SYS_sigsuspend: c_long = 201; +pub const SYS_oldlstat: c_long = 202; +pub const SYS_uselib: c_long = 203; +pub const SYS_readdir: c_long = 204; +pub const SYS_readahead: c_long = 205; +pub const SYS_socketcall: c_long = 206; +pub const SYS_syslog: c_long = 207; +pub const SYS_lookup_dcookie: c_long = 208; +pub const SYS_fadvise64: c_long = 209; +pub const SYS_fadvise64_64: c_long = 210; +pub const SYS_tgkill: c_long = 211; +pub const SYS_waitpid: c_long = 212; +pub const SYS_swapoff: c_long = 213; +pub const SYS_sysinfo: c_long = 214; +pub const SYS_ipc: c_long = 215; +pub const SYS_sigreturn: c_long = 216; +pub const SYS_clone: c_long = 217; +pub const SYS_ioprio_get: c_long = 218; +pub const SYS_adjtimex: c_long = 219; +pub const SYS_sigprocmask: c_long = 220; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_create_module: c_long = 221; +pub const SYS_delete_module: c_long = 222; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_get_kernel_syms: c_long = 223; +pub const SYS_getpgid: c_long = 224; +pub const SYS_bdflush: c_long = 225; +pub const SYS_sysfs: c_long = 226; +pub const SYS_afs_syscall: c_long = 227; +pub const SYS_setfsuid: c_long = 228; +pub const SYS_setfsgid: c_long = 229; +pub const SYS__newselect: c_long = 230; +pub const SYS_time: c_long = 231; +pub const SYS_splice: c_long = 232; +pub const SYS_stime: c_long = 233; +pub const SYS_statfs64: c_long = 234; +pub const SYS_fstatfs64: c_long = 235; +pub const SYS__llseek: c_long = 236; +pub const SYS_mlock: c_long = 237; +pub const SYS_munlock: c_long = 238; +pub const SYS_mlockall: c_long = 239; +pub const SYS_munlockall: c_long = 240; +pub const SYS_sched_setparam: c_long = 241; +pub const SYS_sched_getparam: c_long = 242; +pub const SYS_sched_setscheduler: c_long = 243; +pub const SYS_sched_getscheduler: c_long = 244; +pub const SYS_sched_yield: c_long = 245; +pub const SYS_sched_get_priority_max: c_long = 246; +pub const SYS_sched_get_priority_min: c_long = 247; +pub const SYS_sched_rr_get_interval: c_long = 248; +pub const SYS_nanosleep: c_long = 249; +pub const SYS_mremap: c_long = 250; +pub const SYS__sysctl: c_long = 251; +pub const SYS_getsid: c_long = 252; +pub const SYS_fdatasync: c_long = 253; +pub const SYS_nfsservctl: c_long = 254; +pub const SYS_sync_file_range: c_long = 255; +pub const SYS_clock_settime: c_long = 256; +pub const SYS_clock_gettime: c_long = 257; +pub const SYS_clock_getres: c_long = 258; +pub const SYS_clock_nanosleep: c_long = 259; +pub const SYS_sched_getaffinity: c_long = 260; +pub const SYS_sched_setaffinity: c_long = 261; +pub const SYS_timer_settime: c_long = 262; +pub const SYS_timer_gettime: c_long = 263; +pub const SYS_timer_getoverrun: c_long = 264; +pub const SYS_timer_delete: c_long = 265; +pub const SYS_timer_create: c_long = 266; +pub const SYS_io_setup: c_long = 268; +pub const SYS_io_destroy: c_long = 269; +pub const SYS_io_submit: c_long = 270; +pub const SYS_io_cancel: c_long = 271; +pub const SYS_io_getevents: c_long = 272; +pub const SYS_mq_open: c_long = 273; +pub const SYS_mq_unlink: c_long = 274; +pub const SYS_mq_timedsend: c_long = 275; +pub const SYS_mq_timedreceive: c_long = 276; +pub const SYS_mq_notify: c_long = 277; +pub const SYS_mq_getsetattr: c_long = 278; +pub const SYS_waitid: c_long = 279; +pub const SYS_tee: c_long = 280; +pub const SYS_add_key: c_long = 281; +pub const SYS_request_key: c_long = 282; +pub const SYS_keyctl: c_long = 283; +pub const SYS_openat: c_long = 284; +pub const SYS_mkdirat: c_long = 285; +pub const SYS_mknodat: c_long = 286; +pub const SYS_fchownat: c_long = 287; +pub const SYS_futimesat: c_long = 288; +pub const SYS_fstatat64: c_long = 289; +pub const SYS_unlinkat: c_long = 290; +pub const SYS_renameat: c_long = 291; +pub const SYS_linkat: c_long = 292; +pub const SYS_symlinkat: c_long = 293; +pub const SYS_readlinkat: c_long = 294; +pub const SYS_fchmodat: c_long = 295; +pub const SYS_faccessat: c_long = 296; +pub const SYS_pselect6: c_long = 297; +pub const SYS_ppoll: c_long = 298; +pub const SYS_unshare: c_long = 299; +pub const SYS_set_robust_list: c_long = 300; +pub const SYS_get_robust_list: c_long = 301; +pub const SYS_migrate_pages: c_long = 302; +pub const SYS_mbind: c_long = 303; +pub const SYS_get_mempolicy: c_long = 304; +pub const SYS_set_mempolicy: c_long = 305; +pub const SYS_kexec_load: c_long = 306; +pub const SYS_move_pages: c_long = 307; +pub const SYS_getcpu: c_long = 308; +pub const SYS_epoll_pwait: c_long = 309; +pub const SYS_utimensat: c_long = 310; +pub const SYS_signalfd: c_long = 311; +pub const SYS_timerfd_create: c_long = 312; +pub const SYS_eventfd: c_long = 313; +pub const SYS_fallocate: c_long = 314; +pub const SYS_timerfd_settime: c_long = 315; +pub const SYS_timerfd_gettime: c_long = 316; +pub const SYS_signalfd4: c_long = 317; +pub const SYS_eventfd2: c_long = 318; +pub const SYS_epoll_create1: c_long = 319; +pub const SYS_dup3: c_long = 320; +pub const SYS_pipe2: c_long = 321; +pub const SYS_inotify_init1: c_long = 322; +pub const SYS_accept4: c_long = 323; +pub const SYS_preadv: c_long = 324; +pub const SYS_pwritev: c_long = 325; +pub const SYS_rt_tgsigqueueinfo: c_long = 326; +pub const SYS_perf_event_open: c_long = 327; +pub const SYS_recvmmsg: c_long = 328; +pub const SYS_fanotify_init: c_long = 329; +pub const SYS_fanotify_mark: c_long = 330; +pub const SYS_prlimit64: c_long = 331; +pub const SYS_name_to_handle_at: c_long = 332; +pub const SYS_open_by_handle_at: c_long = 333; +pub const SYS_clock_adjtime: c_long = 334; +pub const SYS_syncfs: c_long = 335; +pub const SYS_sendmmsg: c_long = 336; +pub const SYS_setns: c_long = 337; +pub const SYS_process_vm_readv: c_long = 338; +pub const SYS_process_vm_writev: c_long = 339; +pub const SYS_kern_features: c_long = 340; +pub const SYS_kcmp: c_long = 341; +pub const SYS_finit_module: c_long = 342; +pub const SYS_sched_setattr: c_long = 343; +pub const SYS_sched_getattr: c_long = 344; +pub const SYS_renameat2: c_long = 345; +pub const SYS_seccomp: c_long = 346; +pub const SYS_getrandom: c_long = 347; +pub const SYS_memfd_create: c_long = 348; +pub const SYS_bpf: c_long = 349; +pub const SYS_execveat: c_long = 350; +pub const SYS_membarrier: c_long = 351; +pub const SYS_userfaultfd: c_long = 352; +pub const SYS_bind: c_long = 353; +pub const SYS_listen: c_long = 354; +pub const SYS_setsockopt: c_long = 355; +pub const SYS_mlock2: c_long = 356; +pub const SYS_copy_file_range: c_long = 357; +pub const SYS_preadv2: c_long = 358; +pub const SYS_pwritev2: c_long = 359; +pub const SYS_statx: c_long = 360; +pub const SYS_rseq: c_long = 365; +pub const SYS_pidfd_send_signal: c_long = 424; +pub const SYS_io_uring_setup: c_long = 425; +pub const SYS_io_uring_enter: c_long = 426; +pub const SYS_io_uring_register: c_long = 427; +pub const SYS_open_tree: c_long = 428; +pub const SYS_move_mount: c_long = 429; +pub const SYS_fsopen: c_long = 430; +pub const SYS_fsconfig: c_long = 431; +pub const SYS_fsmount: c_long = 432; +pub const SYS_fspick: c_long = 433; +pub const SYS_pidfd_open: c_long = 434; +// Reserved in the kernel, but not actually implemented yet +pub const SYS_clone3: c_long = 435; +pub const SYS_close_range: c_long = 436; +pub const SYS_openat2: c_long = 437; +pub const SYS_pidfd_getfd: c_long = 438; +pub const SYS_faccessat2: c_long = 439; +pub const SYS_process_madvise: c_long = 440; +pub const SYS_epoll_pwait2: c_long = 441; +pub const SYS_mount_setattr: c_long = 442; +pub const SYS_quotactl_fd: c_long = 443; +pub const SYS_landlock_create_ruleset: c_long = 444; +pub const SYS_landlock_add_rule: c_long = 445; +pub const SYS_landlock_restrict_self: c_long = 446; +pub const SYS_memfd_secret: c_long = 447; +pub const SYS_process_mrelease: c_long = 448; +pub const SYS_futex_waitv: c_long = 449; +pub const SYS_set_mempolicy_home_node: c_long = 450; diff --git a/http/vendor/libc/src/unix/linux_like/linux/gnu/b32/x86/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/gnu/b32/x86/mod.rs new file mode 100644 index 0000000..97429da --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/gnu/b32/x86/mod.rs @@ -0,0 +1,1035 @@ +use crate::prelude::*; +use crate::{ + off64_t, + off_t, +}; + +pub type wchar_t = i32; +pub type greg_t = i32; + +s! { + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigaction { + pub sa_sigaction: crate::sighandler_t, + pub sa_mask: crate::sigset_t, + pub sa_flags: c_int, + pub sa_restorer: Option, + } + + pub struct statfs { + pub f_type: crate::__fsword_t, + pub f_bsize: crate::__fsword_t, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_fsid: crate::fsid_t, + + pub f_namelen: crate::__fsword_t, + pub f_frsize: crate::__fsword_t, + pub f_flags: crate::__fsword_t, + f_spare: [crate::__fsword_t; 4], + } + + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off_t, + pub l_len: off_t, + pub l_pid: crate::pid_t, + } + + pub struct flock64 { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off64_t, + pub l_len: off64_t, + pub l_pid: crate::pid_t, + } + + pub struct _libc_fpreg { + pub significand: [u16; 4], + pub exponent: u16, + } + + pub struct _libc_fpstate { + pub cw: c_ulong, + pub sw: c_ulong, + pub tag: c_ulong, + pub ipoff: c_ulong, + pub cssel: c_ulong, + pub dataoff: c_ulong, + pub datasel: c_ulong, + pub _st: [_libc_fpreg; 8], + pub status: c_ulong, + } + + pub struct user_fpregs_struct { + pub cwd: c_long, + pub swd: c_long, + pub twd: c_long, + pub fip: c_long, + pub fcs: c_long, + pub foo: c_long, + pub fos: c_long, + pub st_space: [c_long; 20], + } + + pub struct user_regs_struct { + pub ebx: c_long, + pub ecx: c_long, + pub edx: c_long, + pub esi: c_long, + pub edi: c_long, + pub ebp: c_long, + pub eax: c_long, + pub xds: c_long, + pub xes: c_long, + pub xfs: c_long, + pub xgs: c_long, + pub orig_eax: c_long, + pub eip: c_long, + pub xcs: c_long, + pub eflags: c_long, + pub esp: c_long, + pub xss: c_long, + } + + pub struct user { + pub regs: user_regs_struct, + pub u_fpvalid: c_int, + pub i387: user_fpregs_struct, + pub u_tsize: c_ulong, + pub u_dsize: c_ulong, + pub u_ssize: c_ulong, + pub start_code: c_ulong, + pub start_stack: c_ulong, + pub signal: c_long, + __reserved: Padding, + pub u_ar0: *mut user_regs_struct, + pub u_fpstate: *mut user_fpregs_struct, + pub magic: c_ulong, + pub u_comm: [c_char; 32], + pub u_debugreg: [c_int; 8], + } + + pub struct mcontext_t { + pub gregs: [greg_t; 19], + pub fpregs: *mut _libc_fpstate, + pub oldmask: c_ulong, + pub cr2: c_ulong, + } + + pub struct ipc_perm { + pub __key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: c_ushort, + __pad1: Padding, + pub __seq: c_ushort, + __pad2: Padding, + __unused1: Padding, + __unused2: Padding, + } + + pub struct stat64 { + pub st_dev: crate::dev_t, + #[cfg(not(gnu_time_bits64))] + __pad1: Padding, + #[cfg(not(gnu_time_bits64))] + __st_ino: c_ulong, + #[cfg(gnu_time_bits64)] + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + #[cfg(not(gnu_time_bits64))] + __pad2: Padding, + pub st_size: off64_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt64_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + #[cfg(gnu_time_bits64)] + _atime_pad: Padding, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + #[cfg(gnu_time_bits64)] + _mtime_pad: Padding, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + #[cfg(gnu_time_bits64)] + _ctime_pad: Padding, + #[cfg(not(gnu_time_bits64))] + pub st_ino: crate::ino64_t, + } + + pub struct statfs64 { + pub f_type: crate::__fsword_t, + pub f_bsize: crate::__fsword_t, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_fsid: crate::fsid_t, + pub f_namelen: crate::__fsword_t, + pub f_frsize: crate::__fsword_t, + pub f_flags: crate::__fsword_t, + pub f_spare: [crate::__fsword_t; 4], + } + + pub struct statvfs64 { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: c_ulong, + __f_unused: Padding, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: [c_int; 6], + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, + pub shm_atime: crate::time_t, + #[cfg(not(gnu_time_bits64))] + __unused1: Padding, + pub shm_dtime: crate::time_t, + #[cfg(not(gnu_time_bits64))] + __unused2: Padding, + pub shm_ctime: crate::time_t, + #[cfg(not(gnu_time_bits64))] + __unused3: Padding, + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: crate::shmatt_t, + __unused4: Padding, + __unused5: Padding, + } + + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + pub msg_stime: crate::time_t, + #[cfg(not(gnu_time_bits64))] + __glibc_reserved1: Padding, + pub msg_rtime: crate::time_t, + #[cfg(not(gnu_time_bits64))] + __glibc_reserved2: Padding, + pub msg_ctime: crate::time_t, + #[cfg(not(gnu_time_bits64))] + __glibc_reserved3: Padding, + pub __msg_cbytes: c_ulong, + pub msg_qnum: crate::msgqnum_t, + pub msg_qbytes: crate::msglen_t, + pub msg_lspid: crate::pid_t, + pub msg_lrpid: crate::pid_t, + __glibc_reserved4: Padding, + __glibc_reserved5: Padding, + } + + pub struct siginfo_t { + pub si_signo: c_int, + pub si_errno: c_int, + pub si_code: c_int, + #[doc(hidden)] + #[deprecated( + since = "0.2.54", + note = "Please leave a comment on \ + https://github.com/rust-lang/libc/pull/1316 if you're using \ + this field" + )] + pub _pad: [c_int; 29], + _align: [usize; 0], + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_flags: c_int, + pub ss_size: size_t, + } + + pub struct user_fpxregs_struct { + pub cwd: c_ushort, + pub swd: c_ushort, + pub twd: c_ushort, + pub fop: c_ushort, + pub fip: c_long, + pub fcs: c_long, + pub foo: c_long, + pub fos: c_long, + pub mxcsr: c_long, + __reserved: Padding, + pub st_space: [c_long; 32], + pub xmm_space: [c_long; 32], + padding: Padding<[c_long; 56]>, + } + + pub struct ucontext_t { + pub uc_flags: c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: crate::stack_t, + pub uc_mcontext: mcontext_t, + pub uc_sigmask: crate::sigset_t, + __private: [u8; 112], + __ssp: [c_ulong; 4], + } +} + +s_no_extra_traits! { + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 6], + } +} + +pub const VEOF: usize = 4; +pub const RTLD_DEEPBIND: c_int = 0x8; +pub const RTLD_GLOBAL: c_int = 0x100; +pub const RTLD_NOLOAD: c_int = 0x4; +pub const O_DIRECT: c_int = 0x4000; +pub const O_DIRECTORY: c_int = 0x10000; +pub const O_NOFOLLOW: c_int = 0x20000; +pub const O_LARGEFILE: c_int = 0o0100000; +pub const O_APPEND: c_int = 1024; +pub const O_CREAT: c_int = 64; +pub const O_EXCL: c_int = 128; +pub const O_NOCTTY: c_int = 256; +pub const O_NONBLOCK: c_int = 2048; +pub const O_SYNC: c_int = 1052672; +pub const O_RSYNC: c_int = 1052672; +pub const O_DSYNC: c_int = 4096; +pub const O_FSYNC: c_int = 0x101000; +pub const O_ASYNC: c_int = 0x2000; +pub const O_NDELAY: c_int = 0x800; + +pub const MADV_SOFT_OFFLINE: c_int = 101; +pub const MAP_LOCKED: c_int = 0x02000; +pub const MAP_NORESERVE: c_int = 0x04000; +pub const MAP_32BIT: c_int = 0x0040; +pub const MAP_ANON: c_int = 0x0020; +pub const MAP_ANONYMOUS: c_int = 0x0020; +pub const MAP_DENYWRITE: c_int = 0x0800; +pub const MAP_EXECUTABLE: c_int = 0x01000; +pub const MAP_POPULATE: c_int = 0x08000; +pub const MAP_NONBLOCK: c_int = 0x010000; +pub const MAP_STACK: c_int = 0x020000; +pub const MAP_HUGETLB: c_int = 0x040000; +pub const MAP_GROWSDOWN: c_int = 0x0100; +pub const MAP_SYNC: c_int = 0x080000; + +pub const EDEADLOCK: c_int = 35; +pub const EUCLEAN: c_int = 117; +pub const ENOTNAM: c_int = 118; +pub const ENAVAIL: c_int = 119; +pub const EISNAM: c_int = 120; +pub const EREMOTEIO: c_int = 121; +pub const EDEADLK: c_int = 35; +pub const ENAMETOOLONG: c_int = 36; +pub const ENOLCK: c_int = 37; +pub const ENOSYS: c_int = 38; +pub const ENOTEMPTY: c_int = 39; +pub const ELOOP: c_int = 40; +pub const ENOMSG: c_int = 42; +pub const EIDRM: c_int = 43; +pub const ECHRNG: c_int = 44; +pub const EL2NSYNC: c_int = 45; +pub const EL3HLT: c_int = 46; +pub const EL3RST: c_int = 47; +pub const ELNRNG: c_int = 48; +pub const EUNATCH: c_int = 49; +pub const ENOCSI: c_int = 50; +pub const EL2HLT: c_int = 51; +pub const EBADE: c_int = 52; +pub const EBADR: c_int = 53; +pub const EXFULL: c_int = 54; +pub const ENOANO: c_int = 55; +pub const EBADRQC: c_int = 56; +pub const EBADSLT: c_int = 57; +pub const EMULTIHOP: c_int = 72; +pub const EOVERFLOW: c_int = 75; +pub const ENOTUNIQ: c_int = 76; +pub const EBADFD: c_int = 77; +pub const EBADMSG: c_int = 74; +pub const EREMCHG: c_int = 78; +pub const ELIBACC: c_int = 79; +pub const ELIBBAD: c_int = 80; +pub const ELIBSCN: c_int = 81; +pub const ELIBMAX: c_int = 82; +pub const ELIBEXEC: c_int = 83; +pub const EILSEQ: c_int = 84; +pub const ERESTART: c_int = 85; +pub const ESTRPIPE: c_int = 86; +pub const EUSERS: c_int = 87; +pub const ENOTSOCK: c_int = 88; +pub const EDESTADDRREQ: c_int = 89; +pub const EMSGSIZE: c_int = 90; +pub const EPROTOTYPE: c_int = 91; +pub const ENOPROTOOPT: c_int = 92; +pub const EPROTONOSUPPORT: c_int = 93; +pub const ESOCKTNOSUPPORT: c_int = 94; +pub const EOPNOTSUPP: c_int = 95; +pub const EPFNOSUPPORT: c_int = 96; +pub const EAFNOSUPPORT: c_int = 97; +pub const EADDRINUSE: c_int = 98; +pub const EADDRNOTAVAIL: c_int = 99; +pub const ENETDOWN: c_int = 100; +pub const ENETUNREACH: c_int = 101; +pub const ENETRESET: c_int = 102; +pub const ECONNABORTED: c_int = 103; +pub const ECONNRESET: c_int = 104; +pub const ENOBUFS: c_int = 105; +pub const EISCONN: c_int = 106; +pub const ENOTCONN: c_int = 107; +pub const ESHUTDOWN: c_int = 108; +pub const ETOOMANYREFS: c_int = 109; +pub const ETIMEDOUT: c_int = 110; +pub const ECONNREFUSED: c_int = 111; +pub const EHOSTDOWN: c_int = 112; +pub const EHOSTUNREACH: c_int = 113; +pub const EALREADY: c_int = 114; +pub const EINPROGRESS: c_int = 115; +pub const ESTALE: c_int = 116; +pub const EDQUOT: c_int = 122; +pub const ENOMEDIUM: c_int = 123; +pub const EMEDIUMTYPE: c_int = 124; +pub const ECANCELED: c_int = 125; +pub const ENOKEY: c_int = 126; +pub const EKEYEXPIRED: c_int = 127; +pub const EKEYREVOKED: c_int = 128; +pub const EKEYREJECTED: c_int = 129; +pub const EOWNERDEAD: c_int = 130; +pub const ENOTRECOVERABLE: c_int = 131; +pub const EHWPOISON: c_int = 133; +pub const ERFKILL: c_int = 132; + +pub const SA_SIGINFO: c_int = 0x00000004; +pub const SA_NOCLDWAIT: c_int = 0x00000002; + +pub const SOCK_STREAM: c_int = 1; +pub const SOCK_DGRAM: c_int = 2; + +cfg_if! { + if #[cfg(gnu_file_offset_bits64)] { + pub const F_GETLK: c_int = 12; + } else { + pub const F_GETLK: c_int = 5; + } +} +pub const F_GETOWN: c_int = 9; +pub const F_SETOWN: c_int = 8; + +pub const PTRACE_GETFPXREGS: c_uint = 18; +pub const PTRACE_SETFPXREGS: c_uint = 19; +pub const PTRACE_SYSEMU: c_uint = 31; +pub const PTRACE_SYSEMU_SINGLESTEP: c_uint = 32; + +pub const MCL_CURRENT: c_int = 0x0001; +pub const MCL_FUTURE: c_int = 0x0002; +pub const MCL_ONFAULT: c_int = 0x0004; + +pub const POLLWRNORM: c_short = 0x100; +pub const POLLWRBAND: c_short = 0x200; + +pub const EFD_NONBLOCK: c_int = 0x800; +pub const SFD_NONBLOCK: c_int = 0x0800; + +pub const SIGCHLD: c_int = 17; +pub const SIGBUS: c_int = 7; +pub const SIGUSR1: c_int = 10; +pub const SIGUSR2: c_int = 12; +pub const SIGCONT: c_int = 18; +pub const SIGSTOP: c_int = 19; +pub const SIGTSTP: c_int = 20; +pub const SIGURG: c_int = 23; +pub const SIGIO: c_int = 29; +pub const SIGSYS: c_int = 31; +pub const SIGSTKFLT: c_int = 16; +#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] +pub const SIGUNUSED: c_int = 31; +pub const SIGPOLL: c_int = 29; +pub const SIGPWR: c_int = 30; +pub const SIG_SETMASK: c_int = 2; +pub const SIG_BLOCK: c_int = 0x000000; +pub const SIG_UNBLOCK: c_int = 0x01; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGSTKSZ: size_t = 8192; +pub const MINSIGSTKSZ: size_t = 2048; +pub const CBAUD: crate::tcflag_t = 0o0010017; +pub const TAB1: crate::tcflag_t = 0x00000800; +pub const TAB2: crate::tcflag_t = 0x00001000; +pub const TAB3: crate::tcflag_t = 0x00001800; +pub const CR1: crate::tcflag_t = 0x00000200; +pub const CR2: crate::tcflag_t = 0x00000400; +pub const CR3: crate::tcflag_t = 0x00000600; +pub const FF1: crate::tcflag_t = 0x00008000; +pub const BS1: crate::tcflag_t = 0x00002000; +pub const VT1: crate::tcflag_t = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: crate::tcflag_t = 0x00000400; +pub const IXOFF: crate::tcflag_t = 0x00001000; +pub const ONLCR: crate::tcflag_t = 0x4; +pub const CSIZE: crate::tcflag_t = 0x00000030; +pub const CS6: crate::tcflag_t = 0x00000010; +pub const CS7: crate::tcflag_t = 0x00000020; +pub const CS8: crate::tcflag_t = 0x00000030; +pub const CSTOPB: crate::tcflag_t = 0x00000040; +pub const CREAD: crate::tcflag_t = 0x00000080; +pub const PARENB: crate::tcflag_t = 0x00000100; +pub const PARODD: crate::tcflag_t = 0x00000200; +pub const HUPCL: crate::tcflag_t = 0x00000400; +pub const CLOCAL: crate::tcflag_t = 0x00000800; +pub const ECHOKE: crate::tcflag_t = 0x00000800; +pub const ECHOE: crate::tcflag_t = 0x00000010; +pub const ECHOK: crate::tcflag_t = 0x00000020; +pub const ECHONL: crate::tcflag_t = 0x00000040; +pub const ECHOPRT: crate::tcflag_t = 0x00000400; +pub const ECHOCTL: crate::tcflag_t = 0x00000200; +pub const ISIG: crate::tcflag_t = 0x00000001; +pub const ICANON: crate::tcflag_t = 0x00000002; +pub const PENDIN: crate::tcflag_t = 0x00004000; +pub const NOFLSH: crate::tcflag_t = 0x00000080; +pub const CIBAUD: crate::tcflag_t = 0o02003600000; +pub const CBAUDEX: crate::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: crate::tcflag_t = 0o000002; +pub const NLDLY: crate::tcflag_t = 0o000400; +pub const CRDLY: crate::tcflag_t = 0o003000; +pub const TABDLY: crate::tcflag_t = 0o014000; +pub const BSDLY: crate::tcflag_t = 0o020000; +pub const FFDLY: crate::tcflag_t = 0o100000; +pub const VTDLY: crate::tcflag_t = 0o040000; +pub const XTABS: crate::tcflag_t = 0o014000; + +pub const B0: crate::speed_t = 0o000000; +pub const B50: crate::speed_t = 0o000001; +pub const B75: crate::speed_t = 0o000002; +pub const B110: crate::speed_t = 0o000003; +pub const B134: crate::speed_t = 0o000004; +pub const B150: crate::speed_t = 0o000005; +pub const B200: crate::speed_t = 0o000006; +pub const B300: crate::speed_t = 0o000007; +pub const B600: crate::speed_t = 0o000010; +pub const B1200: crate::speed_t = 0o000011; +pub const B1800: crate::speed_t = 0o000012; +pub const B2400: crate::speed_t = 0o000013; +pub const B4800: crate::speed_t = 0o000014; +pub const B9600: crate::speed_t = 0o000015; +pub const B19200: crate::speed_t = 0o000016; +pub const B38400: crate::speed_t = 0o000017; +pub const EXTA: crate::speed_t = B19200; +pub const EXTB: crate::speed_t = B38400; +pub const B57600: crate::speed_t = 0o010001; +pub const B115200: crate::speed_t = 0o010002; +pub const B230400: crate::speed_t = 0o010003; +pub const B460800: crate::speed_t = 0o010004; +pub const B500000: crate::speed_t = 0o010005; +pub const B576000: crate::speed_t = 0o010006; +pub const B921600: crate::speed_t = 0o010007; +pub const B1000000: crate::speed_t = 0o010010; +pub const B1152000: crate::speed_t = 0o010011; +pub const B1500000: crate::speed_t = 0o010012; +pub const B2000000: crate::speed_t = 0o010013; +pub const B2500000: crate::speed_t = 0o010014; +pub const B3000000: crate::speed_t = 0o010015; +pub const B3500000: crate::speed_t = 0o010016; +pub const B4000000: crate::speed_t = 0o010017; + +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: crate::tcflag_t = 0x00008000; +pub const TOSTOP: crate::tcflag_t = 0x00000100; +pub const FLUSHO: crate::tcflag_t = 0x00001000; +pub const EXTPROC: crate::tcflag_t = 0x00010000; + +pub const TCSANOW: c_int = 0; +pub const TCSADRAIN: c_int = 1; +pub const TCSAFLUSH: c_int = 2; + +// Syscall table +pub const SYS_restart_syscall: c_long = 0; +pub const SYS_exit: c_long = 1; +pub const SYS_fork: c_long = 2; +pub const SYS_read: c_long = 3; +pub const SYS_write: c_long = 4; +pub const SYS_open: c_long = 5; +pub const SYS_close: c_long = 6; +pub const SYS_waitpid: c_long = 7; +pub const SYS_creat: c_long = 8; +pub const SYS_link: c_long = 9; +pub const SYS_unlink: c_long = 10; +pub const SYS_execve: c_long = 11; +pub const SYS_chdir: c_long = 12; +pub const SYS_time: c_long = 13; +pub const SYS_mknod: c_long = 14; +pub const SYS_chmod: c_long = 15; +pub const SYS_lchown: c_long = 16; +pub const SYS_break: c_long = 17; +pub const SYS_oldstat: c_long = 18; +pub const SYS_lseek: c_long = 19; +pub const SYS_getpid: c_long = 20; +pub const SYS_mount: c_long = 21; +pub const SYS_umount: c_long = 22; +pub const SYS_setuid: c_long = 23; +pub const SYS_getuid: c_long = 24; +pub const SYS_stime: c_long = 25; +pub const SYS_ptrace: c_long = 26; +pub const SYS_alarm: c_long = 27; +pub const SYS_oldfstat: c_long = 28; +pub const SYS_pause: c_long = 29; +pub const SYS_utime: c_long = 30; +pub const SYS_stty: c_long = 31; +pub const SYS_gtty: c_long = 32; +pub const SYS_access: c_long = 33; +pub const SYS_nice: c_long = 34; +pub const SYS_ftime: c_long = 35; +pub const SYS_sync: c_long = 36; +pub const SYS_kill: c_long = 37; +pub const SYS_rename: c_long = 38; +pub const SYS_mkdir: c_long = 39; +pub const SYS_rmdir: c_long = 40; +pub const SYS_dup: c_long = 41; +pub const SYS_pipe: c_long = 42; +pub const SYS_times: c_long = 43; +pub const SYS_prof: c_long = 44; +pub const SYS_brk: c_long = 45; +pub const SYS_setgid: c_long = 46; +pub const SYS_getgid: c_long = 47; +pub const SYS_signal: c_long = 48; +pub const SYS_geteuid: c_long = 49; +pub const SYS_getegid: c_long = 50; +pub const SYS_acct: c_long = 51; +pub const SYS_umount2: c_long = 52; +pub const SYS_lock: c_long = 53; +pub const SYS_ioctl: c_long = 54; +pub const SYS_fcntl: c_long = 55; +pub const SYS_mpx: c_long = 56; +pub const SYS_setpgid: c_long = 57; +pub const SYS_ulimit: c_long = 58; +pub const SYS_oldolduname: c_long = 59; +pub const SYS_umask: c_long = 60; +pub const SYS_chroot: c_long = 61; +pub const SYS_ustat: c_long = 62; +pub const SYS_dup2: c_long = 63; +pub const SYS_getppid: c_long = 64; +pub const SYS_getpgrp: c_long = 65; +pub const SYS_setsid: c_long = 66; +pub const SYS_sigaction: c_long = 67; +pub const SYS_sgetmask: c_long = 68; +pub const SYS_ssetmask: c_long = 69; +pub const SYS_setreuid: c_long = 70; +pub const SYS_setregid: c_long = 71; +pub const SYS_sigsuspend: c_long = 72; +pub const SYS_sigpending: c_long = 73; +pub const SYS_sethostname: c_long = 74; +pub const SYS_setrlimit: c_long = 75; +pub const SYS_getrlimit: c_long = 76; +pub const SYS_getrusage: c_long = 77; +pub const SYS_gettimeofday: c_long = 78; +pub const SYS_settimeofday: c_long = 79; +pub const SYS_getgroups: c_long = 80; +pub const SYS_setgroups: c_long = 81; +pub const SYS_select: c_long = 82; +pub const SYS_symlink: c_long = 83; +pub const SYS_oldlstat: c_long = 84; +pub const SYS_readlink: c_long = 85; +pub const SYS_uselib: c_long = 86; +pub const SYS_swapon: c_long = 87; +pub const SYS_reboot: c_long = 88; +pub const SYS_readdir: c_long = 89; +pub const SYS_mmap: c_long = 90; +pub const SYS_munmap: c_long = 91; +pub const SYS_truncate: c_long = 92; +pub const SYS_ftruncate: c_long = 93; +pub const SYS_fchmod: c_long = 94; +pub const SYS_fchown: c_long = 95; +pub const SYS_getpriority: c_long = 96; +pub const SYS_setpriority: c_long = 97; +pub const SYS_profil: c_long = 98; +pub const SYS_statfs: c_long = 99; +pub const SYS_fstatfs: c_long = 100; +pub const SYS_ioperm: c_long = 101; +pub const SYS_socketcall: c_long = 102; +pub const SYS_syslog: c_long = 103; +pub const SYS_setitimer: c_long = 104; +pub const SYS_getitimer: c_long = 105; +pub const SYS_stat: c_long = 106; +pub const SYS_lstat: c_long = 107; +pub const SYS_fstat: c_long = 108; +pub const SYS_olduname: c_long = 109; +pub const SYS_iopl: c_long = 110; +pub const SYS_vhangup: c_long = 111; +pub const SYS_idle: c_long = 112; +pub const SYS_vm86old: c_long = 113; +pub const SYS_wait4: c_long = 114; +pub const SYS_swapoff: c_long = 115; +pub const SYS_sysinfo: c_long = 116; +pub const SYS_ipc: c_long = 117; +pub const SYS_fsync: c_long = 118; +pub const SYS_sigreturn: c_long = 119; +pub const SYS_clone: c_long = 120; +pub const SYS_setdomainname: c_long = 121; +pub const SYS_uname: c_long = 122; +pub const SYS_modify_ldt: c_long = 123; +pub const SYS_adjtimex: c_long = 124; +pub const SYS_mprotect: c_long = 125; +pub const SYS_sigprocmask: c_long = 126; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_create_module: c_long = 127; +pub const SYS_init_module: c_long = 128; +pub const SYS_delete_module: c_long = 129; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_get_kernel_syms: c_long = 130; +pub const SYS_quotactl: c_long = 131; +pub const SYS_getpgid: c_long = 132; +pub const SYS_fchdir: c_long = 133; +pub const SYS_bdflush: c_long = 134; +pub const SYS_sysfs: c_long = 135; +pub const SYS_personality: c_long = 136; +pub const SYS_afs_syscall: c_long = 137; +pub const SYS_setfsuid: c_long = 138; +pub const SYS_setfsgid: c_long = 139; +pub const SYS__llseek: c_long = 140; +pub const SYS_getdents: c_long = 141; +pub const SYS__newselect: c_long = 142; +pub const SYS_flock: c_long = 143; +pub const SYS_msync: c_long = 144; +pub const SYS_readv: c_long = 145; +pub const SYS_writev: c_long = 146; +pub const SYS_getsid: c_long = 147; +pub const SYS_fdatasync: c_long = 148; +pub const SYS__sysctl: c_long = 149; +pub const SYS_mlock: c_long = 150; +pub const SYS_munlock: c_long = 151; +pub const SYS_mlockall: c_long = 152; +pub const SYS_munlockall: c_long = 153; +pub const SYS_sched_setparam: c_long = 154; +pub const SYS_sched_getparam: c_long = 155; +pub const SYS_sched_setscheduler: c_long = 156; +pub const SYS_sched_getscheduler: c_long = 157; +pub const SYS_sched_yield: c_long = 158; +pub const SYS_sched_get_priority_max: c_long = 159; +pub const SYS_sched_get_priority_min: c_long = 160; +pub const SYS_sched_rr_get_interval: c_long = 161; +pub const SYS_nanosleep: c_long = 162; +pub const SYS_mremap: c_long = 163; +pub const SYS_setresuid: c_long = 164; +pub const SYS_getresuid: c_long = 165; +pub const SYS_vm86: c_long = 166; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_query_module: c_long = 167; +pub const SYS_poll: c_long = 168; +pub const SYS_nfsservctl: c_long = 169; +pub const SYS_setresgid: c_long = 170; +pub const SYS_getresgid: c_long = 171; +pub const SYS_prctl: c_long = 172; +pub const SYS_rt_sigreturn: c_long = 173; +pub const SYS_rt_sigaction: c_long = 174; +pub const SYS_rt_sigprocmask: c_long = 175; +pub const SYS_rt_sigpending: c_long = 176; +pub const SYS_rt_sigtimedwait: c_long = 177; +pub const SYS_rt_sigqueueinfo: c_long = 178; +pub const SYS_rt_sigsuspend: c_long = 179; +pub const SYS_pread64: c_long = 180; +pub const SYS_pwrite64: c_long = 181; +pub const SYS_chown: c_long = 182; +pub const SYS_getcwd: c_long = 183; +pub const SYS_capget: c_long = 184; +pub const SYS_capset: c_long = 185; +pub const SYS_sigaltstack: c_long = 186; +pub const SYS_sendfile: c_long = 187; +pub const SYS_getpmsg: c_long = 188; +pub const SYS_putpmsg: c_long = 189; +pub const SYS_vfork: c_long = 190; +pub const SYS_ugetrlimit: c_long = 191; +pub const SYS_mmap2: c_long = 192; +pub const SYS_truncate64: c_long = 193; +pub const SYS_ftruncate64: c_long = 194; +pub const SYS_stat64: c_long = 195; +pub const SYS_lstat64: c_long = 196; +pub const SYS_fstat64: c_long = 197; +pub const SYS_lchown32: c_long = 198; +pub const SYS_getuid32: c_long = 199; +pub const SYS_getgid32: c_long = 200; +pub const SYS_geteuid32: c_long = 201; +pub const SYS_getegid32: c_long = 202; +pub const SYS_setreuid32: c_long = 203; +pub const SYS_setregid32: c_long = 204; +pub const SYS_getgroups32: c_long = 205; +pub const SYS_setgroups32: c_long = 206; +pub const SYS_fchown32: c_long = 207; +pub const SYS_setresuid32: c_long = 208; +pub const SYS_getresuid32: c_long = 209; +pub const SYS_setresgid32: c_long = 210; +pub const SYS_getresgid32: c_long = 211; +pub const SYS_chown32: c_long = 212; +pub const SYS_setuid32: c_long = 213; +pub const SYS_setgid32: c_long = 214; +pub const SYS_setfsuid32: c_long = 215; +pub const SYS_setfsgid32: c_long = 216; +pub const SYS_pivot_root: c_long = 217; +pub const SYS_mincore: c_long = 218; +pub const SYS_madvise: c_long = 219; +pub const SYS_getdents64: c_long = 220; +pub const SYS_fcntl64: c_long = 221; +pub const SYS_gettid: c_long = 224; +pub const SYS_readahead: c_long = 225; +pub const SYS_setxattr: c_long = 226; +pub const SYS_lsetxattr: c_long = 227; +pub const SYS_fsetxattr: c_long = 228; +pub const SYS_getxattr: c_long = 229; +pub const SYS_lgetxattr: c_long = 230; +pub const SYS_fgetxattr: c_long = 231; +pub const SYS_listxattr: c_long = 232; +pub const SYS_llistxattr: c_long = 233; +pub const SYS_flistxattr: c_long = 234; +pub const SYS_removexattr: c_long = 235; +pub const SYS_lremovexattr: c_long = 236; +pub const SYS_fremovexattr: c_long = 237; +pub const SYS_tkill: c_long = 238; +pub const SYS_sendfile64: c_long = 239; +pub const SYS_futex: c_long = 240; +pub const SYS_sched_setaffinity: c_long = 241; +pub const SYS_sched_getaffinity: c_long = 242; +pub const SYS_set_thread_area: c_long = 243; +pub const SYS_get_thread_area: c_long = 244; +pub const SYS_io_setup: c_long = 245; +pub const SYS_io_destroy: c_long = 246; +pub const SYS_io_getevents: c_long = 247; +pub const SYS_io_submit: c_long = 248; +pub const SYS_io_cancel: c_long = 249; +pub const SYS_fadvise64: c_long = 250; +pub const SYS_exit_group: c_long = 252; +pub const SYS_lookup_dcookie: c_long = 253; +pub const SYS_epoll_create: c_long = 254; +pub const SYS_epoll_ctl: c_long = 255; +pub const SYS_epoll_wait: c_long = 256; +pub const SYS_remap_file_pages: c_long = 257; +pub const SYS_set_tid_address: c_long = 258; +pub const SYS_timer_create: c_long = 259; +pub const SYS_timer_settime: c_long = 260; +pub const SYS_timer_gettime: c_long = 261; +pub const SYS_timer_getoverrun: c_long = 262; +pub const SYS_timer_delete: c_long = 263; +pub const SYS_clock_settime: c_long = 264; +pub const SYS_clock_gettime: c_long = 265; +pub const SYS_clock_getres: c_long = 266; +pub const SYS_clock_nanosleep: c_long = 267; +pub const SYS_statfs64: c_long = 268; +pub const SYS_fstatfs64: c_long = 269; +pub const SYS_tgkill: c_long = 270; +pub const SYS_utimes: c_long = 271; +pub const SYS_fadvise64_64: c_long = 272; +pub const SYS_vserver: c_long = 273; +pub const SYS_mbind: c_long = 274; +pub const SYS_get_mempolicy: c_long = 275; +pub const SYS_set_mempolicy: c_long = 276; +pub const SYS_mq_open: c_long = 277; +pub const SYS_mq_unlink: c_long = 278; +pub const SYS_mq_timedsend: c_long = 279; +pub const SYS_mq_timedreceive: c_long = 280; +pub const SYS_mq_notify: c_long = 281; +pub const SYS_mq_getsetattr: c_long = 282; +pub const SYS_kexec_load: c_long = 283; +pub const SYS_waitid: c_long = 284; +pub const SYS_add_key: c_long = 286; +pub const SYS_request_key: c_long = 287; +pub const SYS_keyctl: c_long = 288; +pub const SYS_ioprio_set: c_long = 289; +pub const SYS_ioprio_get: c_long = 290; +pub const SYS_inotify_init: c_long = 291; +pub const SYS_inotify_add_watch: c_long = 292; +pub const SYS_inotify_rm_watch: c_long = 293; +pub const SYS_migrate_pages: c_long = 294; +pub const SYS_openat: c_long = 295; +pub const SYS_mkdirat: c_long = 296; +pub const SYS_mknodat: c_long = 297; +pub const SYS_fchownat: c_long = 298; +pub const SYS_futimesat: c_long = 299; +pub const SYS_fstatat64: c_long = 300; +pub const SYS_unlinkat: c_long = 301; +pub const SYS_renameat: c_long = 302; +pub const SYS_linkat: c_long = 303; +pub const SYS_symlinkat: c_long = 304; +pub const SYS_readlinkat: c_long = 305; +pub const SYS_fchmodat: c_long = 306; +pub const SYS_faccessat: c_long = 307; +pub const SYS_pselect6: c_long = 308; +pub const SYS_ppoll: c_long = 309; +pub const SYS_unshare: c_long = 310; +pub const SYS_set_robust_list: c_long = 311; +pub const SYS_get_robust_list: c_long = 312; +pub const SYS_splice: c_long = 313; +pub const SYS_sync_file_range: c_long = 314; +pub const SYS_tee: c_long = 315; +pub const SYS_vmsplice: c_long = 316; +pub const SYS_move_pages: c_long = 317; +pub const SYS_getcpu: c_long = 318; +pub const SYS_epoll_pwait: c_long = 319; +pub const SYS_utimensat: c_long = 320; +pub const SYS_signalfd: c_long = 321; +pub const SYS_timerfd_create: c_long = 322; +pub const SYS_eventfd: c_long = 323; +pub const SYS_fallocate: c_long = 324; +pub const SYS_timerfd_settime: c_long = 325; +pub const SYS_timerfd_gettime: c_long = 326; +pub const SYS_signalfd4: c_long = 327; +pub const SYS_eventfd2: c_long = 328; +pub const SYS_epoll_create1: c_long = 329; +pub const SYS_dup3: c_long = 330; +pub const SYS_pipe2: c_long = 331; +pub const SYS_inotify_init1: c_long = 332; +pub const SYS_preadv: c_long = 333; +pub const SYS_pwritev: c_long = 334; +pub const SYS_rt_tgsigqueueinfo: c_long = 335; +pub const SYS_perf_event_open: c_long = 336; +pub const SYS_recvmmsg: c_long = 337; +pub const SYS_fanotify_init: c_long = 338; +pub const SYS_fanotify_mark: c_long = 339; +pub const SYS_prlimit64: c_long = 340; +pub const SYS_name_to_handle_at: c_long = 341; +pub const SYS_open_by_handle_at: c_long = 342; +pub const SYS_clock_adjtime: c_long = 343; +pub const SYS_syncfs: c_long = 344; +pub const SYS_sendmmsg: c_long = 345; +pub const SYS_setns: c_long = 346; +pub const SYS_process_vm_readv: c_long = 347; +pub const SYS_process_vm_writev: c_long = 348; +pub const SYS_kcmp: c_long = 349; +pub const SYS_finit_module: c_long = 350; +pub const SYS_sched_setattr: c_long = 351; +pub const SYS_sched_getattr: c_long = 352; +pub const SYS_renameat2: c_long = 353; +pub const SYS_seccomp: c_long = 354; +pub const SYS_getrandom: c_long = 355; +pub const SYS_memfd_create: c_long = 356; +pub const SYS_bpf: c_long = 357; +pub const SYS_execveat: c_long = 358; +pub const SYS_socket: c_long = 359; +pub const SYS_socketpair: c_long = 360; +pub const SYS_bind: c_long = 361; +pub const SYS_connect: c_long = 362; +pub const SYS_listen: c_long = 363; +pub const SYS_accept4: c_long = 364; +pub const SYS_getsockopt: c_long = 365; +pub const SYS_setsockopt: c_long = 366; +pub const SYS_getsockname: c_long = 367; +pub const SYS_getpeername: c_long = 368; +pub const SYS_sendto: c_long = 369; +pub const SYS_sendmsg: c_long = 370; +pub const SYS_recvfrom: c_long = 371; +pub const SYS_recvmsg: c_long = 372; +pub const SYS_shutdown: c_long = 373; +pub const SYS_userfaultfd: c_long = 374; +pub const SYS_membarrier: c_long = 375; +pub const SYS_mlock2: c_long = 376; +pub const SYS_copy_file_range: c_long = 377; +pub const SYS_preadv2: c_long = 378; +pub const SYS_pwritev2: c_long = 379; +pub const SYS_pkey_mprotect: c_long = 380; +pub const SYS_pkey_alloc: c_long = 381; +pub const SYS_pkey_free: c_long = 382; +pub const SYS_statx: c_long = 383; +pub const SYS_rseq: c_long = 386; +pub const SYS_pidfd_send_signal: c_long = 424; +pub const SYS_io_uring_setup: c_long = 425; +pub const SYS_io_uring_enter: c_long = 426; +pub const SYS_io_uring_register: c_long = 427; +pub const SYS_open_tree: c_long = 428; +pub const SYS_move_mount: c_long = 429; +pub const SYS_fsopen: c_long = 430; +pub const SYS_fsconfig: c_long = 431; +pub const SYS_fsmount: c_long = 432; +pub const SYS_fspick: c_long = 433; +pub const SYS_pidfd_open: c_long = 434; +pub const SYS_clone3: c_long = 435; +pub const SYS_close_range: c_long = 436; +pub const SYS_openat2: c_long = 437; +pub const SYS_pidfd_getfd: c_long = 438; +pub const SYS_faccessat2: c_long = 439; +pub const SYS_process_madvise: c_long = 440; +pub const SYS_epoll_pwait2: c_long = 441; +pub const SYS_mount_setattr: c_long = 442; +pub const SYS_quotactl_fd: c_long = 443; +pub const SYS_landlock_create_ruleset: c_long = 444; +pub const SYS_landlock_add_rule: c_long = 445; +pub const SYS_landlock_restrict_self: c_long = 446; +pub const SYS_memfd_secret: c_long = 447; +pub const SYS_process_mrelease: c_long = 448; +pub const SYS_futex_waitv: c_long = 449; +pub const SYS_set_mempolicy_home_node: c_long = 450; +pub const SYS_fchmodat2: c_long = 452; +pub const SYS_mseal: c_long = 462; + +// offsets in user_regs_structs, from sys/reg.h +pub const EBX: c_int = 0; +pub const ECX: c_int = 1; +pub const EDX: c_int = 2; +pub const ESI: c_int = 3; +pub const EDI: c_int = 4; +pub const EBP: c_int = 5; +pub const EAX: c_int = 6; +pub const DS: c_int = 7; +pub const ES: c_int = 8; +pub const FS: c_int = 9; +pub const GS: c_int = 10; +pub const ORIG_EAX: c_int = 11; +pub const EIP: c_int = 12; +pub const CS: c_int = 13; +pub const EFL: c_int = 14; +pub const UESP: c_int = 15; +pub const SS: c_int = 16; + +// offsets in mcontext_t.gregs from sys/ucontext.h +pub const REG_GS: c_int = 0; +pub const REG_FS: c_int = 1; +pub const REG_ES: c_int = 2; +pub const REG_DS: c_int = 3; +pub const REG_EDI: c_int = 4; +pub const REG_ESI: c_int = 5; +pub const REG_EBP: c_int = 6; +pub const REG_ESP: c_int = 7; +pub const REG_EBX: c_int = 8; +pub const REG_EDX: c_int = 9; +pub const REG_ECX: c_int = 10; +pub const REG_EAX: c_int = 11; +pub const REG_TRAPNO: c_int = 12; +pub const REG_ERR: c_int = 13; +pub const REG_EIP: c_int = 14; +pub const REG_CS: c_int = 15; +pub const REG_EFL: c_int = 16; +pub const REG_UESP: c_int = 17; +pub const REG_SS: c_int = 18; + +extern "C" { + pub fn getcontext(ucp: *mut ucontext_t) -> c_int; + pub fn setcontext(ucp: *const ucontext_t) -> c_int; + pub fn makecontext(ucp: *mut ucontext_t, func: extern "C" fn(), argc: c_int, ...); + pub fn swapcontext(uocp: *mut ucontext_t, ucp: *const ucontext_t) -> c_int; +} diff --git a/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/aarch64/ilp32.rs b/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/aarch64/ilp32.rs new file mode 100644 index 0000000..f808ff3 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/aarch64/ilp32.rs @@ -0,0 +1,54 @@ +use crate::prelude::*; +use crate::pthread_mutex_t; + +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 32; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 48; +pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 20; + +#[cfg(target_endian = "little")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ], +}; + +pub const SYS_sync_file_range2: c_long = 84; diff --git a/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/aarch64/lp64.rs b/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/aarch64/lp64.rs new file mode 100644 index 0000000..960e512 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/aarch64/lp64.rs @@ -0,0 +1,57 @@ +use crate::prelude::*; +use crate::pthread_mutex_t; + +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 8; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 48; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 8; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; +pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 8; +pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; + +#[cfg(target_endian = "little")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; + +pub const SYS_renameat: c_long = 38; +pub const SYS_sync_file_range: c_long = 84; +pub const SYS_getrlimit: c_long = 163; +pub const SYS_setrlimit: c_long = 164; diff --git a/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs new file mode 100644 index 0000000..b8c55dc --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -0,0 +1,976 @@ +//! AArch64-specific definitions for 64-bit linux-like values + +use crate::prelude::*; +use crate::{ + off64_t, + off_t, +}; + +pub type wchar_t = u32; +pub type nlink_t = u32; +pub type blksize_t = i32; +pub type suseconds_t = i64; +pub type __u64 = c_ulonglong; +pub type __s64 = c_longlong; + +s! { + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigaction { + pub sa_sigaction: crate::sighandler_t, + pub sa_mask: crate::sigset_t, + #[cfg(target_arch = "sparc64")] + __reserved0: Padding, + pub sa_flags: c_int, + pub sa_restorer: Option, + } + + pub struct statfs { + pub f_type: crate::__fsword_t, + pub f_bsize: crate::__fsword_t, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_fsid: crate::fsid_t, + + pub f_namelen: crate::__fsword_t, + pub f_frsize: crate::__fsword_t, + f_spare: [crate::__fsword_t; 5], + } + + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off_t, + pub l_len: off_t, + pub l_pid: crate::pid_t, + } + + pub struct flock64 { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off64_t, + pub l_len: off64_t, + pub l_pid: crate::pid_t, + } + + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + __pad1: Padding, + pub st_size: off_t, + pub st_blksize: crate::blksize_t, + __pad2: Padding, + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + __unused: Padding<[c_int; 2]>, + } + + pub struct stat64 { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + __pad1: Padding, + pub st_size: off64_t, + pub st_blksize: crate::blksize_t, + __pad2: Padding, + pub st_blocks: crate::blkcnt64_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + __unused: Padding<[c_int; 2]>, + } + + pub struct statfs64 { + pub f_type: crate::__fsword_t, + pub f_bsize: crate::__fsword_t, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_fsid: crate::fsid_t, + pub f_namelen: crate::__fsword_t, + pub f_frsize: crate::__fsword_t, + pub f_flags: crate::__fsword_t, + pub f_spare: [crate::__fsword_t; 4], + } + + pub struct statvfs { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_favail: crate::fsfilcnt_t, + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: [c_int; 6], + } + + pub struct statvfs64 { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: [c_int; 6], + } + + pub struct pthread_attr_t { + __size: [usize; 8], + } + + pub struct user_regs_struct { + pub regs: [c_ulonglong; 31], + pub sp: c_ulonglong, + pub pc: c_ulonglong, + pub pstate: c_ulonglong, + } + + pub struct ipc_perm { + pub __key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: c_uint, + pub __seq: c_ushort, + __pad1: Padding, + __unused1: Padding, + __unused2: Padding, + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, + pub shm_atime: crate::time_t, + pub shm_dtime: crate::time_t, + pub shm_ctime: crate::time_t, + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: crate::shmatt_t, + __unused4: Padding, + __unused5: Padding, + } + + pub struct siginfo_t { + pub si_signo: c_int, + pub si_errno: c_int, + pub si_code: c_int, + #[doc(hidden)] + #[deprecated( + since = "0.2.54", + note = "Please leave a comment on \ + https://github.com/rust-lang/libc/pull/1316 if you're using \ + this field" + )] + pub _pad: [c_int; 29], + _align: [usize; 0], + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_flags: c_int, + pub ss_size: size_t, + } + + pub struct ucontext_t { + pub uc_flags: c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: crate::stack_t, + pub uc_sigmask: crate::sigset_t, + pub uc_mcontext: mcontext_t, + } + + #[repr(align(16))] + pub struct mcontext_t { + pub fault_address: c_ulonglong, + pub regs: [c_ulonglong; 31], + pub sp: c_ulonglong, + pub pc: c_ulonglong, + pub pstate: c_ulonglong, + __reserved: Padding<[u64; 512]>, + } + + pub struct user_fpsimd_struct { + pub vregs: [u128; 32], + pub fpsr: c_uint, + pub fpcr: c_uint, + } + + #[repr(align(8))] + pub struct clone_args { + pub flags: c_ulonglong, + pub pidfd: c_ulonglong, + pub child_tid: c_ulonglong, + pub parent_tid: c_ulonglong, + pub exit_signal: c_ulonglong, + pub stack: c_ulonglong, + pub stack_size: c_ulonglong, + pub tls: c_ulonglong, + pub set_tid: c_ulonglong, + pub set_tid_size: c_ulonglong, + pub cgroup: c_ulonglong, + } +} + +s_no_extra_traits! { + #[repr(align(16))] + pub struct max_align_t { + priv_: [f32; 8], + } +} + +pub const VEOF: usize = 4; + +pub const RTLD_DEEPBIND: c_int = 0x8; +pub const RTLD_GLOBAL: c_int = 0x100; +pub const RTLD_NOLOAD: c_int = 0x4; + +pub const O_APPEND: c_int = 1024; +pub const O_CREAT: c_int = 64; +pub const O_EXCL: c_int = 128; +pub const O_NOCTTY: c_int = 256; +pub const O_NONBLOCK: c_int = 2048; +pub const O_SYNC: c_int = 1052672; +pub const O_RSYNC: c_int = 1052672; +pub const O_DSYNC: c_int = 4096; +pub const O_FSYNC: c_int = 0x101000; +pub const O_NOATIME: c_int = 0o1000000; +pub const O_PATH: c_int = 0o10000000; +pub const O_TMPFILE: c_int = 0o20000000 | O_DIRECTORY; + +pub const MADV_SOFT_OFFLINE: c_int = 101; +pub const MAP_GROWSDOWN: c_int = 0x0100; + +pub const EUCLEAN: c_int = 117; +pub const ENOTNAM: c_int = 118; +pub const ENAVAIL: c_int = 119; +pub const EISNAM: c_int = 120; +pub const EREMOTEIO: c_int = 121; +pub const EDEADLK: c_int = 35; +pub const ENAMETOOLONG: c_int = 36; +pub const ENOLCK: c_int = 37; +pub const ENOSYS: c_int = 38; +pub const ENOTEMPTY: c_int = 39; +pub const ELOOP: c_int = 40; +pub const ENOMSG: c_int = 42; +pub const EIDRM: c_int = 43; +pub const ECHRNG: c_int = 44; +pub const EL2NSYNC: c_int = 45; +pub const EL3HLT: c_int = 46; +pub const EL3RST: c_int = 47; +pub const ELNRNG: c_int = 48; +pub const EUNATCH: c_int = 49; +pub const ENOCSI: c_int = 50; +pub const EL2HLT: c_int = 51; +pub const EBADE: c_int = 52; +pub const EBADR: c_int = 53; +pub const EXFULL: c_int = 54; +pub const ENOANO: c_int = 55; +pub const EBADRQC: c_int = 56; +pub const EBADSLT: c_int = 57; +pub const EMULTIHOP: c_int = 72; +pub const EOVERFLOW: c_int = 75; +pub const ENOTUNIQ: c_int = 76; +pub const EBADFD: c_int = 77; +pub const EBADMSG: c_int = 74; +pub const EREMCHG: c_int = 78; +pub const ELIBACC: c_int = 79; +pub const ELIBBAD: c_int = 80; +pub const ELIBSCN: c_int = 81; +pub const ELIBMAX: c_int = 82; +pub const ELIBEXEC: c_int = 83; +pub const EILSEQ: c_int = 84; +pub const ERESTART: c_int = 85; +pub const ESTRPIPE: c_int = 86; +pub const EUSERS: c_int = 87; +pub const ENOTSOCK: c_int = 88; +pub const EDESTADDRREQ: c_int = 89; +pub const EMSGSIZE: c_int = 90; +pub const EPROTOTYPE: c_int = 91; +pub const ENOPROTOOPT: c_int = 92; +pub const EPROTONOSUPPORT: c_int = 93; +pub const ESOCKTNOSUPPORT: c_int = 94; +pub const EOPNOTSUPP: c_int = 95; +pub const EPFNOSUPPORT: c_int = 96; +pub const EAFNOSUPPORT: c_int = 97; +pub const EADDRINUSE: c_int = 98; +pub const EADDRNOTAVAIL: c_int = 99; +pub const ENETDOWN: c_int = 100; +pub const ENETUNREACH: c_int = 101; +pub const ENETRESET: c_int = 102; +pub const ECONNABORTED: c_int = 103; +pub const ECONNRESET: c_int = 104; +pub const ENOBUFS: c_int = 105; +pub const EISCONN: c_int = 106; +pub const ENOTCONN: c_int = 107; +pub const ESHUTDOWN: c_int = 108; +pub const ETOOMANYREFS: c_int = 109; +pub const ETIMEDOUT: c_int = 110; +pub const ECONNREFUSED: c_int = 111; +pub const EHOSTDOWN: c_int = 112; +pub const EHOSTUNREACH: c_int = 113; +pub const EALREADY: c_int = 114; +pub const EINPROGRESS: c_int = 115; +pub const ESTALE: c_int = 116; +pub const EDQUOT: c_int = 122; +pub const ENOMEDIUM: c_int = 123; +pub const EMEDIUMTYPE: c_int = 124; +pub const ECANCELED: c_int = 125; +pub const ENOKEY: c_int = 126; +pub const EKEYEXPIRED: c_int = 127; +pub const EKEYREVOKED: c_int = 128; +pub const EKEYREJECTED: c_int = 129; +pub const EOWNERDEAD: c_int = 130; +pub const ENOTRECOVERABLE: c_int = 131; +pub const EHWPOISON: c_int = 133; +pub const ERFKILL: c_int = 132; + +pub const POSIX_FADV_DONTNEED: c_int = 4; +pub const POSIX_FADV_NOREUSE: c_int = 5; + +pub const SOCK_STREAM: c_int = 1; +pub const SOCK_DGRAM: c_int = 2; + +pub const SA_ONSTACK: c_int = 0x08000000; +pub const SA_SIGINFO: c_int = 0x00000004; +pub const SA_NOCLDWAIT: c_int = 0x00000002; + +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGCHLD: c_int = 17; +pub const SIGBUS: c_int = 7; +pub const SIGUSR1: c_int = 10; +pub const SIGUSR2: c_int = 12; +pub const SIGCONT: c_int = 18; +pub const SIGSTOP: c_int = 19; +pub const SIGTSTP: c_int = 20; +pub const SIGURG: c_int = 23; +pub const SIGIO: c_int = 29; +pub const SIGSYS: c_int = 31; +pub const SIGSTKFLT: c_int = 16; +#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] +pub const SIGUNUSED: c_int = 31; +pub const SIGPOLL: c_int = 29; +pub const SIGPWR: c_int = 30; +pub const SIG_SETMASK: c_int = 2; +pub const SIG_BLOCK: c_int = 0x000000; +pub const SIG_UNBLOCK: c_int = 0x01; + +pub const POLLWRNORM: c_short = 0x100; +pub const POLLWRBAND: c_short = 0x200; + +pub const O_ASYNC: c_int = 0x2000; +pub const O_NDELAY: c_int = 0x800; + +pub const PTRACE_DETACH: c_uint = 17; + +pub const EFD_NONBLOCK: c_int = 0x800; + +pub const F_GETLK: c_int = 5; +pub const F_GETOWN: c_int = 9; +pub const F_SETOWN: c_int = 8; +pub const F_SETLK: c_int = 6; +pub const F_SETLKW: c_int = 7; +pub const F_OFD_GETLK: c_int = 36; +pub const F_OFD_SETLK: c_int = 37; +pub const F_OFD_SETLKW: c_int = 38; + +pub const F_RDLCK: c_int = 0; +pub const F_WRLCK: c_int = 1; +pub const F_UNLCK: c_int = 2; + +pub const SFD_NONBLOCK: c_int = 0x0800; + +pub const SFD_CLOEXEC: c_int = 0x080000; + +pub const NCCS: usize = 32; + +pub const O_TRUNC: c_int = 512; + +pub const O_CLOEXEC: c_int = 0x80000; + +pub const EBFONT: c_int = 59; +pub const ENOSTR: c_int = 60; +pub const ENODATA: c_int = 61; +pub const ETIME: c_int = 62; +pub const ENOSR: c_int = 63; +pub const ENONET: c_int = 64; +pub const ENOPKG: c_int = 65; +pub const EREMOTE: c_int = 66; +pub const ENOLINK: c_int = 67; +pub const EADV: c_int = 68; +pub const ESRMNT: c_int = 69; +pub const ECOMM: c_int = 70; +pub const EPROTO: c_int = 71; +pub const EDOTDOT: c_int = 73; + +pub const SA_NODEFER: c_int = 0x40000000; +pub const SA_RESETHAND: c_int = 0x80000000; +pub const SA_RESTART: c_int = 0x10000000; +pub const SA_NOCLDSTOP: c_int = 0x00000001; + +pub const EPOLL_CLOEXEC: c_int = 0x80000; + +pub const EFD_CLOEXEC: c_int = 0x80000; + +pub const O_DIRECT: c_int = 0x10000; +pub const O_DIRECTORY: c_int = 0x4000; +pub const O_NOFOLLOW: c_int = 0x8000; + +pub const MAP_LOCKED: c_int = 0x02000; +pub const MAP_NORESERVE: c_int = 0x04000; +pub const MAP_ANON: c_int = 0x0020; +pub const MAP_ANONYMOUS: c_int = 0x0020; +pub const MAP_DENYWRITE: c_int = 0x0800; +pub const MAP_EXECUTABLE: c_int = 0x01000; +pub const MAP_POPULATE: c_int = 0x08000; +pub const MAP_NONBLOCK: c_int = 0x010000; +pub const MAP_STACK: c_int = 0x020000; +pub const MAP_HUGETLB: c_int = 0x040000; +pub const MAP_SYNC: c_int = 0x080000; + +pub const EDEADLOCK: c_int = 35; + +pub const MCL_CURRENT: c_int = 0x0001; +pub const MCL_FUTURE: c_int = 0x0002; +pub const MCL_ONFAULT: c_int = 0x0004; + +pub const SIGSTKSZ: size_t = 16384; +pub const MINSIGSTKSZ: size_t = 5120; +pub const CBAUD: crate::tcflag_t = 0o0010017; +pub const TAB1: crate::tcflag_t = 0x00000800; +pub const TAB2: crate::tcflag_t = 0x00001000; +pub const TAB3: crate::tcflag_t = 0x00001800; +pub const CR1: crate::tcflag_t = 0x00000200; +pub const CR2: crate::tcflag_t = 0x00000400; +pub const CR3: crate::tcflag_t = 0x00000600; +pub const FF1: crate::tcflag_t = 0x00008000; +pub const BS1: crate::tcflag_t = 0x00002000; +pub const VT1: crate::tcflag_t = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: crate::tcflag_t = 0x00000400; +pub const IXOFF: crate::tcflag_t = 0x00001000; +pub const ONLCR: crate::tcflag_t = 0x4; +pub const CSIZE: crate::tcflag_t = 0x00000030; +pub const CS6: crate::tcflag_t = 0x00000010; +pub const CS7: crate::tcflag_t = 0x00000020; +pub const CS8: crate::tcflag_t = 0x00000030; +pub const CSTOPB: crate::tcflag_t = 0x00000040; +pub const CREAD: crate::tcflag_t = 0x00000080; +pub const PARENB: crate::tcflag_t = 0x00000100; +pub const PARODD: crate::tcflag_t = 0x00000200; +pub const HUPCL: crate::tcflag_t = 0x00000400; +pub const CLOCAL: crate::tcflag_t = 0x00000800; +pub const ECHOKE: crate::tcflag_t = 0x00000800; +pub const ECHOE: crate::tcflag_t = 0x00000010; +pub const ECHOK: crate::tcflag_t = 0x00000020; +pub const ECHONL: crate::tcflag_t = 0x00000040; +pub const ECHOPRT: crate::tcflag_t = 0x00000400; +pub const ECHOCTL: crate::tcflag_t = 0x00000200; +pub const ISIG: crate::tcflag_t = 0x00000001; +pub const ICANON: crate::tcflag_t = 0x00000002; +pub const PENDIN: crate::tcflag_t = 0x00004000; +pub const NOFLSH: crate::tcflag_t = 0x00000080; +pub const CIBAUD: crate::tcflag_t = 0o02003600000; +pub const CBAUDEX: crate::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: crate::tcflag_t = 0o000002; +pub const NLDLY: crate::tcflag_t = 0o000400; +pub const CRDLY: crate::tcflag_t = 0o003000; +pub const TABDLY: crate::tcflag_t = 0o014000; +pub const BSDLY: crate::tcflag_t = 0o020000; +pub const FFDLY: crate::tcflag_t = 0o100000; +pub const VTDLY: crate::tcflag_t = 0o040000; +pub const XTABS: crate::tcflag_t = 0o014000; + +pub const B0: crate::speed_t = 0o000000; +pub const B50: crate::speed_t = 0o000001; +pub const B75: crate::speed_t = 0o000002; +pub const B110: crate::speed_t = 0o000003; +pub const B134: crate::speed_t = 0o000004; +pub const B150: crate::speed_t = 0o000005; +pub const B200: crate::speed_t = 0o000006; +pub const B300: crate::speed_t = 0o000007; +pub const B600: crate::speed_t = 0o000010; +pub const B1200: crate::speed_t = 0o000011; +pub const B1800: crate::speed_t = 0o000012; +pub const B2400: crate::speed_t = 0o000013; +pub const B4800: crate::speed_t = 0o000014; +pub const B9600: crate::speed_t = 0o000015; +pub const B19200: crate::speed_t = 0o000016; +pub const B38400: crate::speed_t = 0o000017; +pub const EXTA: crate::speed_t = B19200; +pub const EXTB: crate::speed_t = B38400; +pub const B57600: crate::speed_t = 0o010001; +pub const B115200: crate::speed_t = 0o010002; +pub const B230400: crate::speed_t = 0o010003; +pub const B460800: crate::speed_t = 0o010004; +pub const B500000: crate::speed_t = 0o010005; +pub const B576000: crate::speed_t = 0o010006; +pub const B921600: crate::speed_t = 0o010007; +pub const B1000000: crate::speed_t = 0o010010; +pub const B1152000: crate::speed_t = 0o010011; +pub const B1500000: crate::speed_t = 0o010012; +pub const B2000000: crate::speed_t = 0o010013; +pub const B2500000: crate::speed_t = 0o010014; +pub const B3000000: crate::speed_t = 0o010015; +pub const B3500000: crate::speed_t = 0o010016; +pub const B4000000: crate::speed_t = 0o010017; + +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: crate::tcflag_t = 0x00008000; +pub const TOSTOP: crate::tcflag_t = 0x00000100; +pub const FLUSHO: crate::tcflag_t = 0x00001000; +pub const EXTPROC: crate::tcflag_t = 0x00010000; + +pub const TCSANOW: c_int = 0; +pub const TCSADRAIN: c_int = 1; +pub const TCSAFLUSH: c_int = 2; + +// sys/auxv.h +pub const HWCAP_FP: c_ulong = 1 << 0; +pub const HWCAP_ASIMD: c_ulong = 1 << 1; +pub const HWCAP_EVTSTRM: c_ulong = 1 << 2; +pub const HWCAP_AES: c_ulong = 1 << 3; +pub const HWCAP_PMULL: c_ulong = 1 << 4; +pub const HWCAP_SHA1: c_ulong = 1 << 5; +pub const HWCAP_SHA2: c_ulong = 1 << 6; +pub const HWCAP_CRC32: c_ulong = 1 << 7; +pub const HWCAP_ATOMICS: c_ulong = 1 << 8; +pub const HWCAP_FPHP: c_ulong = 1 << 9; +pub const HWCAP_ASIMDHP: c_ulong = 1 << 10; +pub const HWCAP_CPUID: c_ulong = 1 << 11; +pub const HWCAP_ASIMDRDM: c_ulong = 1 << 12; +pub const HWCAP_JSCVT: c_ulong = 1 << 13; +pub const HWCAP_FCMA: c_ulong = 1 << 14; +pub const HWCAP_LRCPC: c_ulong = 1 << 15; +pub const HWCAP_DCPOP: c_ulong = 1 << 16; +pub const HWCAP_SHA3: c_ulong = 1 << 17; +pub const HWCAP_SM3: c_ulong = 1 << 18; +pub const HWCAP_SM4: c_ulong = 1 << 19; +pub const HWCAP_ASIMDDP: c_ulong = 1 << 20; +pub const HWCAP_SHA512: c_ulong = 1 << 21; +pub const HWCAP_SVE: c_ulong = 1 << 22; +pub const HWCAP_ASIMDFHM: c_ulong = 1 << 23; +pub const HWCAP_DIT: c_ulong = 1 << 24; +pub const HWCAP_USCAT: c_ulong = 1 << 25; +pub const HWCAP_ILRCPC: c_ulong = 1 << 26; +pub const HWCAP_FLAGM: c_ulong = 1 << 27; +pub const HWCAP_SSBS: c_ulong = 1 << 28; +pub const HWCAP_SB: c_ulong = 1 << 29; +pub const HWCAP_PACA: c_ulong = 1 << 30; +pub const HWCAP_PACG: c_ulong = 1 << 31; +// FIXME(linux): enable these again once linux-api-headers are up to date enough on CI. +// See discussion in https://github.com/rust-lang/libc/pull/1638 +//pub const HWCAP2_DCPODP: c_ulong = 1 << 0; +//pub const HWCAP2_SVE2: c_ulong = 1 << 1; +//pub const HWCAP2_SVEAES: c_ulong = 1 << 2; +//pub const HWCAP2_SVEPMULL: c_ulong = 1 << 3; +//pub const HWCAP2_SVEBITPERM: c_ulong = 1 << 4; +//pub const HWCAP2_SVESHA3: c_ulong = 1 << 5; +//pub const HWCAP2_SVESM4: c_ulong = 1 << 6; +//pub const HWCAP2_FLAGM2: c_ulong = 1 << 7; +//pub const HWCAP2_FRINT: c_ulong = 1 << 8; +//pub const HWCAP2_MTE: c_ulong = 1 << 18; + +// linux/prctl.h +pub const PR_PAC_RESET_KEYS: c_int = 54; +pub const PR_SET_TAGGED_ADDR_CTRL: c_int = 55; +pub const PR_GET_TAGGED_ADDR_CTRL: c_int = 56; +pub const PR_PAC_SET_ENABLED_KEYS: c_int = 60; +pub const PR_PAC_GET_ENABLED_KEYS: c_int = 61; + +pub const PR_TAGGED_ADDR_ENABLE: c_ulong = 1; + +pub const PR_PAC_APIAKEY: c_ulong = 1 << 0; +pub const PR_PAC_APIBKEY: c_ulong = 1 << 1; +pub const PR_PAC_APDAKEY: c_ulong = 1 << 2; +pub const PR_PAC_APDBKEY: c_ulong = 1 << 3; +pub const PR_PAC_APGAKEY: c_ulong = 1 << 4; + +pub const PR_SME_SET_VL: c_int = 63; +pub const PR_SME_GET_VL: c_int = 64; +pub const PR_SME_VL_LEN_MAX: c_int = 0xffff; + +pub const PR_SME_SET_VL_INHERIT: c_ulong = 1 << 17; +pub const PR_SME_SET_VL_ONE_EXEC: c_ulong = 1 << 18; + +// Syscall table +pub const SYS_io_setup: c_long = 0; +pub const SYS_io_destroy: c_long = 1; +pub const SYS_io_submit: c_long = 2; +pub const SYS_io_cancel: c_long = 3; +pub const SYS_io_getevents: c_long = 4; +pub const SYS_setxattr: c_long = 5; +pub const SYS_lsetxattr: c_long = 6; +pub const SYS_fsetxattr: c_long = 7; +pub const SYS_getxattr: c_long = 8; +pub const SYS_lgetxattr: c_long = 9; +pub const SYS_fgetxattr: c_long = 10; +pub const SYS_listxattr: c_long = 11; +pub const SYS_llistxattr: c_long = 12; +pub const SYS_flistxattr: c_long = 13; +pub const SYS_removexattr: c_long = 14; +pub const SYS_lremovexattr: c_long = 15; +pub const SYS_fremovexattr: c_long = 16; +pub const SYS_getcwd: c_long = 17; +pub const SYS_lookup_dcookie: c_long = 18; +pub const SYS_eventfd2: c_long = 19; +pub const SYS_epoll_create1: c_long = 20; +pub const SYS_epoll_ctl: c_long = 21; +pub const SYS_epoll_pwait: c_long = 22; +pub const SYS_dup: c_long = 23; +pub const SYS_dup3: c_long = 24; +pub const SYS_fcntl: c_long = 25; +pub const SYS_inotify_init1: c_long = 26; +pub const SYS_inotify_add_watch: c_long = 27; +pub const SYS_inotify_rm_watch: c_long = 28; +pub const SYS_ioctl: c_long = 29; +pub const SYS_ioprio_set: c_long = 30; +pub const SYS_ioprio_get: c_long = 31; +pub const SYS_flock: c_long = 32; +pub const SYS_mknodat: c_long = 33; +pub const SYS_mkdirat: c_long = 34; +pub const SYS_unlinkat: c_long = 35; +pub const SYS_symlinkat: c_long = 36; +pub const SYS_linkat: c_long = 37; +// 38 is renameat only on LP64 +pub const SYS_umount2: c_long = 39; +pub const SYS_mount: c_long = 40; +pub const SYS_pivot_root: c_long = 41; +pub const SYS_nfsservctl: c_long = 42; +pub const SYS_statfs: c_long = 43; +pub const SYS_fstatfs: c_long = 44; +pub const SYS_truncate: c_long = 45; +pub const SYS_ftruncate: c_long = 46; +pub const SYS_fallocate: c_long = 47; +pub const SYS_faccessat: c_long = 48; +pub const SYS_chdir: c_long = 49; +pub const SYS_fchdir: c_long = 50; +pub const SYS_chroot: c_long = 51; +pub const SYS_fchmod: c_long = 52; +pub const SYS_fchmodat: c_long = 53; +pub const SYS_fchownat: c_long = 54; +pub const SYS_fchown: c_long = 55; +pub const SYS_openat: c_long = 56; +pub const SYS_close: c_long = 57; +pub const SYS_vhangup: c_long = 58; +pub const SYS_pipe2: c_long = 59; +pub const SYS_quotactl: c_long = 60; +pub const SYS_getdents64: c_long = 61; +pub const SYS_lseek: c_long = 62; +pub const SYS_read: c_long = 63; +pub const SYS_write: c_long = 64; +pub const SYS_readv: c_long = 65; +pub const SYS_writev: c_long = 66; +pub const SYS_pread64: c_long = 67; +pub const SYS_pwrite64: c_long = 68; +pub const SYS_preadv: c_long = 69; +pub const SYS_pwritev: c_long = 70; +pub const SYS_pselect6: c_long = 72; +pub const SYS_ppoll: c_long = 73; +pub const SYS_signalfd4: c_long = 74; +pub const SYS_vmsplice: c_long = 75; +pub const SYS_splice: c_long = 76; +pub const SYS_tee: c_long = 77; +pub const SYS_readlinkat: c_long = 78; +pub const SYS_newfstatat: c_long = 79; +pub const SYS_fstat: c_long = 80; +pub const SYS_sync: c_long = 81; +pub const SYS_fsync: c_long = 82; +pub const SYS_fdatasync: c_long = 83; +// 84 sync_file_range on LP64 and sync_file_range2 on ILP32 +pub const SYS_timerfd_create: c_long = 85; +pub const SYS_timerfd_settime: c_long = 86; +pub const SYS_timerfd_gettime: c_long = 87; +pub const SYS_utimensat: c_long = 88; +pub const SYS_acct: c_long = 89; +pub const SYS_capget: c_long = 90; +pub const SYS_capset: c_long = 91; +pub const SYS_personality: c_long = 92; +pub const SYS_exit: c_long = 93; +pub const SYS_exit_group: c_long = 94; +pub const SYS_waitid: c_long = 95; +pub const SYS_set_tid_address: c_long = 96; +pub const SYS_unshare: c_long = 97; +pub const SYS_futex: c_long = 98; +pub const SYS_set_robust_list: c_long = 99; +pub const SYS_get_robust_list: c_long = 100; +pub const SYS_nanosleep: c_long = 101; +pub const SYS_getitimer: c_long = 102; +pub const SYS_setitimer: c_long = 103; +pub const SYS_kexec_load: c_long = 104; +pub const SYS_init_module: c_long = 105; +pub const SYS_delete_module: c_long = 106; +pub const SYS_timer_create: c_long = 107; +pub const SYS_timer_gettime: c_long = 108; +pub const SYS_timer_getoverrun: c_long = 109; +pub const SYS_timer_settime: c_long = 110; +pub const SYS_timer_delete: c_long = 111; +pub const SYS_clock_settime: c_long = 112; +pub const SYS_clock_gettime: c_long = 113; +pub const SYS_clock_getres: c_long = 114; +pub const SYS_clock_nanosleep: c_long = 115; +pub const SYS_syslog: c_long = 116; +pub const SYS_ptrace: c_long = 117; +pub const SYS_sched_setparam: c_long = 118; +pub const SYS_sched_setscheduler: c_long = 119; +pub const SYS_sched_getscheduler: c_long = 120; +pub const SYS_sched_getparam: c_long = 121; +pub const SYS_sched_setaffinity: c_long = 122; +pub const SYS_sched_getaffinity: c_long = 123; +pub const SYS_sched_yield: c_long = 124; +pub const SYS_sched_get_priority_max: c_long = 125; +pub const SYS_sched_get_priority_min: c_long = 126; +pub const SYS_sched_rr_get_interval: c_long = 127; +pub const SYS_restart_syscall: c_long = 128; +pub const SYS_kill: c_long = 129; +pub const SYS_tkill: c_long = 130; +pub const SYS_tgkill: c_long = 131; +pub const SYS_sigaltstack: c_long = 132; +pub const SYS_rt_sigsuspend: c_long = 133; +pub const SYS_rt_sigaction: c_long = 134; +pub const SYS_rt_sigprocmask: c_long = 135; +pub const SYS_rt_sigpending: c_long = 136; +pub const SYS_rt_sigtimedwait: c_long = 137; +pub const SYS_rt_sigqueueinfo: c_long = 138; +pub const SYS_rt_sigreturn: c_long = 139; +pub const SYS_setpriority: c_long = 140; +pub const SYS_getpriority: c_long = 141; +pub const SYS_reboot: c_long = 142; +pub const SYS_setregid: c_long = 143; +pub const SYS_setgid: c_long = 144; +pub const SYS_setreuid: c_long = 145; +pub const SYS_setuid: c_long = 146; +pub const SYS_setresuid: c_long = 147; +pub const SYS_getresuid: c_long = 148; +pub const SYS_setresgid: c_long = 149; +pub const SYS_getresgid: c_long = 150; +pub const SYS_setfsuid: c_long = 151; +pub const SYS_setfsgid: c_long = 152; +pub const SYS_times: c_long = 153; +pub const SYS_setpgid: c_long = 154; +pub const SYS_getpgid: c_long = 155; +pub const SYS_getsid: c_long = 156; +pub const SYS_setsid: c_long = 157; +pub const SYS_getgroups: c_long = 158; +pub const SYS_setgroups: c_long = 159; +pub const SYS_uname: c_long = 160; +pub const SYS_sethostname: c_long = 161; +pub const SYS_setdomainname: c_long = 162; +// 163 is getrlimit only on LP64 +// 164 is setrlimit only on LP64 +pub const SYS_getrusage: c_long = 165; +pub const SYS_umask: c_long = 166; +pub const SYS_prctl: c_long = 167; +pub const SYS_getcpu: c_long = 168; +pub const SYS_gettimeofday: c_long = 169; +pub const SYS_settimeofday: c_long = 170; +pub const SYS_adjtimex: c_long = 171; +pub const SYS_getpid: c_long = 172; +pub const SYS_getppid: c_long = 173; +pub const SYS_getuid: c_long = 174; +pub const SYS_geteuid: c_long = 175; +pub const SYS_getgid: c_long = 176; +pub const SYS_getegid: c_long = 177; +pub const SYS_gettid: c_long = 178; +pub const SYS_sysinfo: c_long = 179; +pub const SYS_mq_open: c_long = 180; +pub const SYS_mq_unlink: c_long = 181; +pub const SYS_mq_timedsend: c_long = 182; +pub const SYS_mq_timedreceive: c_long = 183; +pub const SYS_mq_notify: c_long = 184; +pub const SYS_mq_getsetattr: c_long = 185; +pub const SYS_msgget: c_long = 186; +pub const SYS_msgctl: c_long = 187; +pub const SYS_msgrcv: c_long = 188; +pub const SYS_msgsnd: c_long = 189; +pub const SYS_semget: c_long = 190; +pub const SYS_semctl: c_long = 191; +pub const SYS_semtimedop: c_long = 192; +pub const SYS_semop: c_long = 193; +pub const SYS_shmget: c_long = 194; +pub const SYS_shmctl: c_long = 195; +pub const SYS_shmat: c_long = 196; +pub const SYS_shmdt: c_long = 197; +pub const SYS_socket: c_long = 198; +pub const SYS_socketpair: c_long = 199; +pub const SYS_bind: c_long = 200; +pub const SYS_listen: c_long = 201; +pub const SYS_accept: c_long = 202; +pub const SYS_connect: c_long = 203; +pub const SYS_getsockname: c_long = 204; +pub const SYS_getpeername: c_long = 205; +pub const SYS_sendto: c_long = 206; +pub const SYS_recvfrom: c_long = 207; +pub const SYS_setsockopt: c_long = 208; +pub const SYS_getsockopt: c_long = 209; +pub const SYS_shutdown: c_long = 210; +pub const SYS_sendmsg: c_long = 211; +pub const SYS_recvmsg: c_long = 212; +pub const SYS_readahead: c_long = 213; +pub const SYS_brk: c_long = 214; +pub const SYS_munmap: c_long = 215; +pub const SYS_mremap: c_long = 216; +pub const SYS_add_key: c_long = 217; +pub const SYS_request_key: c_long = 218; +pub const SYS_keyctl: c_long = 219; +pub const SYS_clone: c_long = 220; +pub const SYS_execve: c_long = 221; +pub const SYS_mmap: c_long = 222; +pub const SYS_swapon: c_long = 224; +pub const SYS_swapoff: c_long = 225; +pub const SYS_mprotect: c_long = 226; +pub const SYS_msync: c_long = 227; +pub const SYS_mlock: c_long = 228; +pub const SYS_munlock: c_long = 229; +pub const SYS_mlockall: c_long = 230; +pub const SYS_munlockall: c_long = 231; +pub const SYS_mincore: c_long = 232; +pub const SYS_madvise: c_long = 233; +pub const SYS_remap_file_pages: c_long = 234; +pub const SYS_mbind: c_long = 235; +pub const SYS_get_mempolicy: c_long = 236; +pub const SYS_set_mempolicy: c_long = 237; +pub const SYS_migrate_pages: c_long = 238; +pub const SYS_move_pages: c_long = 239; +pub const SYS_rt_tgsigqueueinfo: c_long = 240; +pub const SYS_perf_event_open: c_long = 241; +pub const SYS_accept4: c_long = 242; +pub const SYS_recvmmsg: c_long = 243; +pub const SYS_wait4: c_long = 260; +pub const SYS_prlimit64: c_long = 261; +pub const SYS_fanotify_init: c_long = 262; +pub const SYS_fanotify_mark: c_long = 263; +pub const SYS_name_to_handle_at: c_long = 264; +pub const SYS_open_by_handle_at: c_long = 265; +pub const SYS_clock_adjtime: c_long = 266; +pub const SYS_syncfs: c_long = 267; +pub const SYS_setns: c_long = 268; +pub const SYS_sendmmsg: c_long = 269; +pub const SYS_process_vm_readv: c_long = 270; +pub const SYS_process_vm_writev: c_long = 271; +pub const SYS_kcmp: c_long = 272; +pub const SYS_finit_module: c_long = 273; +pub const SYS_sched_setattr: c_long = 274; +pub const SYS_sched_getattr: c_long = 275; +pub const SYS_renameat2: c_long = 276; +pub const SYS_seccomp: c_long = 277; +pub const SYS_getrandom: c_long = 278; +pub const SYS_memfd_create: c_long = 279; +pub const SYS_bpf: c_long = 280; +pub const SYS_execveat: c_long = 281; +pub const SYS_userfaultfd: c_long = 282; +pub const SYS_membarrier: c_long = 283; +pub const SYS_mlock2: c_long = 284; +pub const SYS_copy_file_range: c_long = 285; +pub const SYS_preadv2: c_long = 286; +pub const SYS_pwritev2: c_long = 287; +pub const SYS_pkey_mprotect: c_long = 288; +pub const SYS_pkey_alloc: c_long = 289; +pub const SYS_pkey_free: c_long = 290; +pub const SYS_statx: c_long = 291; +pub const SYS_rseq: c_long = 293; +pub const SYS_kexec_file_load: c_long = 294; +pub const SYS_pidfd_send_signal: c_long = 424; +pub const SYS_io_uring_setup: c_long = 425; +pub const SYS_io_uring_enter: c_long = 426; +pub const SYS_io_uring_register: c_long = 427; +pub const SYS_open_tree: c_long = 428; +pub const SYS_move_mount: c_long = 429; +pub const SYS_fsopen: c_long = 430; +pub const SYS_fsconfig: c_long = 431; +pub const SYS_fsmount: c_long = 432; +pub const SYS_fspick: c_long = 433; +pub const SYS_pidfd_open: c_long = 434; +pub const SYS_clone3: c_long = 435; +pub const SYS_close_range: c_long = 436; +pub const SYS_openat2: c_long = 437; +pub const SYS_pidfd_getfd: c_long = 438; +pub const SYS_faccessat2: c_long = 439; +pub const SYS_process_madvise: c_long = 440; +pub const SYS_epoll_pwait2: c_long = 441; +pub const SYS_mount_setattr: c_long = 442; +pub const SYS_quotactl_fd: c_long = 443; +pub const SYS_landlock_create_ruleset: c_long = 444; +pub const SYS_landlock_add_rule: c_long = 445; +pub const SYS_landlock_restrict_self: c_long = 446; +pub const SYS_memfd_secret: c_long = 447; +pub const SYS_process_mrelease: c_long = 448; +pub const SYS_futex_waitv: c_long = 449; +pub const SYS_set_mempolicy_home_node: c_long = 450; +pub const SYS_mseal: c_long = 462; + +pub const PROT_BTI: c_int = 0x10; +pub const PROT_MTE: c_int = 0x20; + +extern "C" { + pub fn sysctl( + name: *mut c_int, + namelen: c_int, + oldp: *mut c_void, + oldlenp: *mut size_t, + newp: *mut c_void, + newlen: size_t, + ) -> c_int; + + pub fn getcontext(ucp: *mut ucontext_t) -> c_int; + pub fn setcontext(ucp: *const ucontext_t) -> c_int; + pub fn makecontext(ucp: *mut ucontext_t, func: extern "C" fn(), argc: c_int, ...); + pub fn swapcontext(uocp: *mut ucontext_t, ucp: *const ucontext_t) -> c_int; +} + +cfg_if! { + if #[cfg(target_pointer_width = "32")] { + mod ilp32; + pub use self::ilp32::*; + } else { + mod lp64; + pub use self::lp64::*; + } +} diff --git a/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs new file mode 100644 index 0000000..3f01da8 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs @@ -0,0 +1,925 @@ +use crate::prelude::*; +use crate::{ + off64_t, + off_t, + pthread_mutex_t, +}; + +pub type wchar_t = i32; + +pub type blksize_t = i32; +pub type nlink_t = u32; +pub type suseconds_t = i64; +pub type __u64 = c_ulonglong; +pub type __s64 = c_longlong; + +s! { + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + __pad1: Padding, + pub st_size: off_t, + pub st_blksize: crate::blksize_t, + __pad2: Padding, + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + __unused: Padding<[c_int; 2]>, + } + + pub struct stat64 { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino64_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + pub __pad1: crate::dev_t, + pub st_size: off64_t, + pub st_blksize: crate::blksize_t, + pub __pad2: c_int, + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + __unused: Padding<[c_int; 2]>, + } + + pub struct statfs { + pub f_type: crate::__fsword_t, + pub f_bsize: crate::__fsword_t, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_fsid: crate::fsid_t, + pub f_namelen: crate::__fsword_t, + pub f_frsize: crate::__fsword_t, + pub f_flags: crate::__fsword_t, + pub f_spare: [crate::__fsword_t; 4], + } + + pub struct statfs64 { + pub f_type: crate::__fsword_t, + pub f_bsize: crate::__fsword_t, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_fsid: crate::fsid_t, + pub f_namelen: crate::__fsword_t, + pub f_frsize: crate::__fsword_t, + pub f_flags: crate::__fsword_t, + pub f_spare: [crate::__fsword_t; 4], + } + + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off_t, + pub l_len: off_t, + pub l_pid: crate::pid_t, + } + + pub struct flock64 { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off64_t, + pub l_len: off64_t, + pub l_pid: crate::pid_t, + } + + pub struct statvfs { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_favail: crate::fsfilcnt_t, + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: [c_int; 6], + } + + pub struct statvfs64 { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: [c_int; 6], + } + + pub struct pthread_attr_t { + __size: [c_ulong; 7], + } + + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigaction { + pub sa_sigaction: crate::sighandler_t, + pub sa_mask: crate::sigset_t, + pub sa_flags: c_int, + pub sa_restorer: Option, + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_flags: c_int, + pub ss_size: size_t, + } + + pub struct siginfo_t { + pub si_signo: c_int, + pub si_errno: c_int, + pub si_code: c_int, + #[doc(hidden)] + #[deprecated( + since = "0.2.54", + note = "Please leave a comment on \ + https://github.com/rust-lang/libc/pull/1316 if you're using \ + this field" + )] + pub _pad: [c_int; 29], + _align: [u64; 0], + } + + pub struct ipc_perm { + pub __key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: c_uint, + pub __seq: c_ushort, + __pad2: Padding, + __unused1: Padding, + __unused2: Padding, + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, + pub shm_atime: crate::time_t, + pub shm_dtime: crate::time_t, + pub shm_ctime: crate::time_t, + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: crate::shmatt_t, + __unused4: Padding, + __unused5: Padding, + } + + pub struct user_regs_struct { + pub regs: [u64; 32], + pub orig_a0: u64, + pub csr_era: u64, + pub csr_badv: u64, + pub reserved: [u64; 10], + } + + pub struct user_fp_struct { + pub fpr: [u64; 32], + pub fcc: u64, + pub fcsr: u32, + } + + pub struct ucontext_t { + pub uc_flags: c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: crate::stack_t, + pub uc_sigmask: crate::sigset_t, + pub uc_mcontext: mcontext_t, + } + + #[repr(align(16))] + pub struct mcontext_t { + pub __pc: c_ulonglong, + pub __gregs: [c_ulonglong; 32], + pub __flags: c_uint, + pub __extcontext: [c_ulonglong; 0], + } + + #[repr(align(8))] + pub struct clone_args { + pub flags: c_ulonglong, + pub pidfd: c_ulonglong, + pub child_tid: c_ulonglong, + pub parent_tid: c_ulonglong, + pub exit_signal: c_ulonglong, + pub stack: c_ulonglong, + pub stack_size: c_ulonglong, + pub tls: c_ulonglong, + pub set_tid: c_ulonglong, + pub set_tid_size: c_ulonglong, + pub cgroup: c_ulonglong, + } +} + +s_no_extra_traits! { + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 4], + } +} + +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; +pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; + +#[cfg(target_endian = "little")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; + +pub const HWCAP_LOONGARCH_CPUCFG: c_ulong = 1 << 0; +pub const HWCAP_LOONGARCH_LAM: c_ulong = 1 << 1; +pub const HWCAP_LOONGARCH_UAL: c_ulong = 1 << 2; +pub const HWCAP_LOONGARCH_FPU: c_ulong = 1 << 3; +pub const HWCAP_LOONGARCH_LSX: c_ulong = 1 << 4; +pub const HWCAP_LOONGARCH_LASX: c_ulong = 1 << 5; +pub const HWCAP_LOONGARCH_CRC32: c_ulong = 1 << 6; +pub const HWCAP_LOONGARCH_COMPLEX: c_ulong = 1 << 7; +pub const HWCAP_LOONGARCH_CRYPTO: c_ulong = 1 << 8; +pub const HWCAP_LOONGARCH_LVZ: c_ulong = 1 << 9; +pub const HWCAP_LOONGARCH_LBT_X86: c_ulong = 1 << 10; +pub const HWCAP_LOONGARCH_LBT_ARM: c_ulong = 1 << 11; +pub const HWCAP_LOONGARCH_LBT_MIPS: c_ulong = 1 << 12; +pub const HWCAP_LOONGARCH_PTW: c_ulong = 1 << 13; + +pub const SYS_io_setup: c_long = 0; +pub const SYS_io_destroy: c_long = 1; +pub const SYS_io_submit: c_long = 2; +pub const SYS_io_cancel: c_long = 3; +pub const SYS_io_getevents: c_long = 4; +pub const SYS_setxattr: c_long = 5; +pub const SYS_lsetxattr: c_long = 6; +pub const SYS_fsetxattr: c_long = 7; +pub const SYS_getxattr: c_long = 8; +pub const SYS_lgetxattr: c_long = 9; +pub const SYS_fgetxattr: c_long = 10; +pub const SYS_listxattr: c_long = 11; +pub const SYS_llistxattr: c_long = 12; +pub const SYS_flistxattr: c_long = 13; +pub const SYS_removexattr: c_long = 14; +pub const SYS_lremovexattr: c_long = 15; +pub const SYS_fremovexattr: c_long = 16; +pub const SYS_getcwd: c_long = 17; +pub const SYS_lookup_dcookie: c_long = 18; +pub const SYS_eventfd2: c_long = 19; +pub const SYS_epoll_create1: c_long = 20; +pub const SYS_epoll_ctl: c_long = 21; +pub const SYS_epoll_pwait: c_long = 22; +pub const SYS_dup: c_long = 23; +pub const SYS_dup3: c_long = 24; +pub const SYS_fcntl: c_long = 25; +pub const SYS_inotify_init1: c_long = 26; +pub const SYS_inotify_add_watch: c_long = 27; +pub const SYS_inotify_rm_watch: c_long = 28; +pub const SYS_ioctl: c_long = 29; +pub const SYS_ioprio_set: c_long = 30; +pub const SYS_ioprio_get: c_long = 31; +pub const SYS_flock: c_long = 32; +pub const SYS_mknodat: c_long = 33; +pub const SYS_mkdirat: c_long = 34; +pub const SYS_unlinkat: c_long = 35; +pub const SYS_symlinkat: c_long = 36; +pub const SYS_linkat: c_long = 37; +pub const SYS_umount2: c_long = 39; +pub const SYS_mount: c_long = 40; +pub const SYS_pivot_root: c_long = 41; +pub const SYS_nfsservctl: c_long = 42; +pub const SYS_statfs: c_long = 43; +pub const SYS_fstatfs: c_long = 44; +pub const SYS_truncate: c_long = 45; +pub const SYS_ftruncate: c_long = 46; +pub const SYS_fallocate: c_long = 47; +pub const SYS_faccessat: c_long = 48; +pub const SYS_chdir: c_long = 49; +pub const SYS_fchdir: c_long = 50; +pub const SYS_chroot: c_long = 51; +pub const SYS_fchmod: c_long = 52; +pub const SYS_fchmodat: c_long = 53; +pub const SYS_fchownat: c_long = 54; +pub const SYS_fchown: c_long = 55; +pub const SYS_openat: c_long = 56; +pub const SYS_close: c_long = 57; +pub const SYS_vhangup: c_long = 58; +pub const SYS_pipe2: c_long = 59; +pub const SYS_quotactl: c_long = 60; +pub const SYS_getdents64: c_long = 61; +pub const SYS_lseek: c_long = 62; +pub const SYS_read: c_long = 63; +pub const SYS_write: c_long = 64; +pub const SYS_readv: c_long = 65; +pub const SYS_writev: c_long = 66; +pub const SYS_pread64: c_long = 67; +pub const SYS_pwrite64: c_long = 68; +pub const SYS_preadv: c_long = 69; +pub const SYS_pwritev: c_long = 70; +pub const SYS_sendfile: c_long = 71; +pub const SYS_pselect6: c_long = 72; +pub const SYS_ppoll: c_long = 73; +pub const SYS_signalfd4: c_long = 74; +pub const SYS_vmsplice: c_long = 75; +pub const SYS_splice: c_long = 76; +pub const SYS_tee: c_long = 77; +pub const SYS_readlinkat: c_long = 78; +pub const SYS_sync: c_long = 81; +pub const SYS_fsync: c_long = 82; +pub const SYS_fdatasync: c_long = 83; +pub const SYS_sync_file_range: c_long = 84; +pub const SYS_timerfd_create: c_long = 85; +pub const SYS_timerfd_settime: c_long = 86; +pub const SYS_timerfd_gettime: c_long = 87; +pub const SYS_utimensat: c_long = 88; +pub const SYS_acct: c_long = 89; +pub const SYS_capget: c_long = 90; +pub const SYS_capset: c_long = 91; +pub const SYS_personality: c_long = 92; +pub const SYS_exit: c_long = 93; +pub const SYS_exit_group: c_long = 94; +pub const SYS_waitid: c_long = 95; +pub const SYS_set_tid_address: c_long = 96; +pub const SYS_unshare: c_long = 97; +pub const SYS_futex: c_long = 98; +pub const SYS_set_robust_list: c_long = 99; +pub const SYS_get_robust_list: c_long = 100; +pub const SYS_nanosleep: c_long = 101; +pub const SYS_getitimer: c_long = 102; +pub const SYS_setitimer: c_long = 103; +pub const SYS_kexec_load: c_long = 104; +pub const SYS_init_module: c_long = 105; +pub const SYS_delete_module: c_long = 106; +pub const SYS_timer_create: c_long = 107; +pub const SYS_timer_gettime: c_long = 108; +pub const SYS_timer_getoverrun: c_long = 109; +pub const SYS_timer_settime: c_long = 110; +pub const SYS_timer_delete: c_long = 111; +pub const SYS_clock_settime: c_long = 112; +pub const SYS_clock_gettime: c_long = 113; +pub const SYS_clock_getres: c_long = 114; +pub const SYS_clock_nanosleep: c_long = 115; +pub const SYS_syslog: c_long = 116; +pub const SYS_ptrace: c_long = 117; +pub const SYS_sched_setparam: c_long = 118; +pub const SYS_sched_setscheduler: c_long = 119; +pub const SYS_sched_getscheduler: c_long = 120; +pub const SYS_sched_getparam: c_long = 121; +pub const SYS_sched_setaffinity: c_long = 122; +pub const SYS_sched_getaffinity: c_long = 123; +pub const SYS_sched_yield: c_long = 124; +pub const SYS_sched_get_priority_max: c_long = 125; +pub const SYS_sched_get_priority_min: c_long = 126; +pub const SYS_sched_rr_get_interval: c_long = 127; +pub const SYS_restart_syscall: c_long = 128; +pub const SYS_kill: c_long = 129; +pub const SYS_tkill: c_long = 130; +pub const SYS_tgkill: c_long = 131; +pub const SYS_sigaltstack: c_long = 132; +pub const SYS_rt_sigsuspend: c_long = 133; +pub const SYS_rt_sigaction: c_long = 134; +pub const SYS_rt_sigprocmask: c_long = 135; +pub const SYS_rt_sigpending: c_long = 136; +pub const SYS_rt_sigtimedwait: c_long = 137; +pub const SYS_rt_sigqueueinfo: c_long = 138; +pub const SYS_rt_sigreturn: c_long = 139; +pub const SYS_setpriority: c_long = 140; +pub const SYS_getpriority: c_long = 141; +pub const SYS_reboot: c_long = 142; +pub const SYS_setregid: c_long = 143; +pub const SYS_setgid: c_long = 144; +pub const SYS_setreuid: c_long = 145; +pub const SYS_setuid: c_long = 146; +pub const SYS_setresuid: c_long = 147; +pub const SYS_getresuid: c_long = 148; +pub const SYS_setresgid: c_long = 149; +pub const SYS_getresgid: c_long = 150; +pub const SYS_setfsuid: c_long = 151; +pub const SYS_setfsgid: c_long = 152; +pub const SYS_times: c_long = 153; +pub const SYS_setpgid: c_long = 154; +pub const SYS_getpgid: c_long = 155; +pub const SYS_getsid: c_long = 156; +pub const SYS_setsid: c_long = 157; +pub const SYS_getgroups: c_long = 158; +pub const SYS_setgroups: c_long = 159; +pub const SYS_uname: c_long = 160; +pub const SYS_sethostname: c_long = 161; +pub const SYS_setdomainname: c_long = 162; +pub const SYS_getrusage: c_long = 165; +pub const SYS_umask: c_long = 166; +pub const SYS_prctl: c_long = 167; +pub const SYS_getcpu: c_long = 168; +pub const SYS_gettimeofday: c_long = 169; +pub const SYS_settimeofday: c_long = 170; +pub const SYS_adjtimex: c_long = 171; +pub const SYS_getpid: c_long = 172; +pub const SYS_getppid: c_long = 173; +pub const SYS_getuid: c_long = 174; +pub const SYS_geteuid: c_long = 175; +pub const SYS_getgid: c_long = 176; +pub const SYS_getegid: c_long = 177; +pub const SYS_gettid: c_long = 178; +pub const SYS_sysinfo: c_long = 179; +pub const SYS_mq_open: c_long = 180; +pub const SYS_mq_unlink: c_long = 181; +pub const SYS_mq_timedsend: c_long = 182; +pub const SYS_mq_timedreceive: c_long = 183; +pub const SYS_mq_notify: c_long = 184; +pub const SYS_mq_getsetattr: c_long = 185; +pub const SYS_msgget: c_long = 186; +pub const SYS_msgctl: c_long = 187; +pub const SYS_msgrcv: c_long = 188; +pub const SYS_msgsnd: c_long = 189; +pub const SYS_semget: c_long = 190; +pub const SYS_semctl: c_long = 191; +pub const SYS_semtimedop: c_long = 192; +pub const SYS_semop: c_long = 193; +pub const SYS_shmget: c_long = 194; +pub const SYS_shmctl: c_long = 195; +pub const SYS_shmat: c_long = 196; +pub const SYS_shmdt: c_long = 197; +pub const SYS_socket: c_long = 198; +pub const SYS_socketpair: c_long = 199; +pub const SYS_bind: c_long = 200; +pub const SYS_listen: c_long = 201; +pub const SYS_accept: c_long = 202; +pub const SYS_connect: c_long = 203; +pub const SYS_getsockname: c_long = 204; +pub const SYS_getpeername: c_long = 205; +pub const SYS_sendto: c_long = 206; +pub const SYS_recvfrom: c_long = 207; +pub const SYS_setsockopt: c_long = 208; +pub const SYS_getsockopt: c_long = 209; +pub const SYS_shutdown: c_long = 210; +pub const SYS_sendmsg: c_long = 211; +pub const SYS_recvmsg: c_long = 212; +pub const SYS_readahead: c_long = 213; +pub const SYS_brk: c_long = 214; +pub const SYS_munmap: c_long = 215; +pub const SYS_mremap: c_long = 216; +pub const SYS_add_key: c_long = 217; +pub const SYS_request_key: c_long = 218; +pub const SYS_keyctl: c_long = 219; +pub const SYS_clone: c_long = 220; +pub const SYS_execve: c_long = 221; +pub const SYS_mmap: c_long = 222; +pub const SYS_fadvise64: c_long = 223; +pub const SYS_swapon: c_long = 224; +pub const SYS_swapoff: c_long = 225; +pub const SYS_mprotect: c_long = 226; +pub const SYS_msync: c_long = 227; +pub const SYS_mlock: c_long = 228; +pub const SYS_munlock: c_long = 229; +pub const SYS_mlockall: c_long = 230; +pub const SYS_munlockall: c_long = 231; +pub const SYS_mincore: c_long = 232; +pub const SYS_madvise: c_long = 233; +pub const SYS_remap_file_pages: c_long = 234; +pub const SYS_mbind: c_long = 235; +pub const SYS_get_mempolicy: c_long = 236; +pub const SYS_set_mempolicy: c_long = 237; +pub const SYS_migrate_pages: c_long = 238; +pub const SYS_move_pages: c_long = 239; +pub const SYS_rt_tgsigqueueinfo: c_long = 240; +pub const SYS_perf_event_open: c_long = 241; +pub const SYS_accept4: c_long = 242; +pub const SYS_recvmmsg: c_long = 243; +//pub const SYS_arch_specific_syscall: c_long = 244; +pub const SYS_wait4: c_long = 260; +pub const SYS_prlimit64: c_long = 261; +pub const SYS_fanotify_init: c_long = 262; +pub const SYS_fanotify_mark: c_long = 263; +pub const SYS_name_to_handle_at: c_long = 264; +pub const SYS_open_by_handle_at: c_long = 265; +pub const SYS_clock_adjtime: c_long = 266; +pub const SYS_syncfs: c_long = 267; +pub const SYS_setns: c_long = 268; +pub const SYS_sendmmsg: c_long = 269; +pub const SYS_process_vm_readv: c_long = 270; +pub const SYS_process_vm_writev: c_long = 271; +pub const SYS_kcmp: c_long = 272; +pub const SYS_finit_module: c_long = 273; +pub const SYS_sched_setattr: c_long = 274; +pub const SYS_sched_getattr: c_long = 275; +pub const SYS_renameat2: c_long = 276; +pub const SYS_seccomp: c_long = 277; +pub const SYS_getrandom: c_long = 278; +pub const SYS_memfd_create: c_long = 279; +pub const SYS_bpf: c_long = 280; +pub const SYS_execveat: c_long = 281; +pub const SYS_userfaultfd: c_long = 282; +pub const SYS_membarrier: c_long = 283; +pub const SYS_mlock2: c_long = 284; +pub const SYS_copy_file_range: c_long = 285; +pub const SYS_preadv2: c_long = 286; +pub const SYS_pwritev2: c_long = 287; +pub const SYS_pkey_mprotect: c_long = 288; +pub const SYS_pkey_alloc: c_long = 289; +pub const SYS_pkey_free: c_long = 290; +pub const SYS_statx: c_long = 291; +pub const SYS_io_pgetevents: c_long = 292; +pub const SYS_rseq: c_long = 293; +pub const SYS_kexec_file_load: c_long = 294; +pub const SYS_pidfd_send_signal: c_long = 424; +pub const SYS_io_uring_setup: c_long = 425; +pub const SYS_io_uring_enter: c_long = 426; +pub const SYS_io_uring_register: c_long = 427; +pub const SYS_open_tree: c_long = 428; +pub const SYS_move_mount: c_long = 429; +pub const SYS_fsopen: c_long = 430; +pub const SYS_fsconfig: c_long = 431; +pub const SYS_fsmount: c_long = 432; +pub const SYS_fspick: c_long = 433; +pub const SYS_pidfd_open: c_long = 434; +pub const SYS_clone3: c_long = 435; +pub const SYS_close_range: c_long = 436; +pub const SYS_openat2: c_long = 437; +pub const SYS_pidfd_getfd: c_long = 438; +pub const SYS_faccessat2: c_long = 439; +pub const SYS_process_madvise: c_long = 440; +pub const SYS_epoll_pwait2: c_long = 441; +pub const SYS_mount_setattr: c_long = 442; +pub const SYS_quotactl_fd: c_long = 443; +pub const SYS_landlock_create_ruleset: c_long = 444; +pub const SYS_landlock_add_rule: c_long = 445; +pub const SYS_landlock_restrict_self: c_long = 446; +pub const SYS_process_mrelease: c_long = 448; +pub const SYS_futex_waitv: c_long = 449; +pub const SYS_set_mempolicy_home_node: c_long = 450; + +pub const POSIX_FADV_DONTNEED: c_int = 4; +pub const POSIX_FADV_NOREUSE: c_int = 5; +pub const O_DIRECT: c_int = 0o00040000; +pub const O_DIRECTORY: c_int = 0o00200000; +pub const O_NOFOLLOW: c_int = 0o00400000; +pub const O_TRUNC: c_int = 0o00001000; +pub const O_NOATIME: c_int = 0o1000000; +pub const O_CLOEXEC: c_int = 0o02000000; +pub const O_PATH: c_int = 0o10000000; +pub const O_TMPFILE: c_int = 0o20000000 | O_DIRECTORY; +pub const O_APPEND: c_int = 0o00002000; +pub const O_CREAT: c_int = 0o00000100; +pub const O_EXCL: c_int = 0o00000200; +pub const O_NOCTTY: c_int = 0o00000400; +pub const O_NONBLOCK: c_int = 0o00004000; +pub const FASYNC: c_int = 0o00020000; +pub const O_SYNC: c_int = 0o04010000; +pub const O_RSYNC: c_int = 0o04010000; +pub const O_FSYNC: c_int = O_SYNC; +pub const O_ASYNC: c_int = 0o00020000; +pub const O_DSYNC: c_int = 0o00010000; +pub const O_NDELAY: c_int = O_NONBLOCK; +pub const F_RDLCK: c_int = 0; +pub const F_WRLCK: c_int = 1; +pub const F_UNLCK: c_int = 2; +pub const F_GETLK: c_int = 5; +pub const F_SETLK: c_int = 6; +pub const F_SETLKW: c_int = 7; +pub const F_SETOWN: c_int = 8; +pub const F_GETOWN: c_int = 9; +pub const F_OFD_GETLK: c_int = 36; +pub const F_OFD_SETLK: c_int = 37; +pub const F_OFD_SETLKW: c_int = 38; + +pub const EDEADLK: c_int = 35; +pub const EDEADLOCK: c_int = 35; +pub const ENAMETOOLONG: c_int = 36; +pub const ENOLCK: c_int = 37; +pub const ENOSYS: c_int = 38; +pub const ENOTEMPTY: c_int = 39; +pub const ELOOP: c_int = 40; +pub const ENOMSG: c_int = 42; +pub const EIDRM: c_int = 43; +pub const ECHRNG: c_int = 44; +pub const EL2NSYNC: c_int = 45; +pub const EL3HLT: c_int = 46; +pub const EL3RST: c_int = 47; +pub const ELNRNG: c_int = 48; +pub const EUNATCH: c_int = 49; +pub const ENOCSI: c_int = 50; +pub const EL2HLT: c_int = 51; +pub const EBADE: c_int = 52; +pub const EBADR: c_int = 53; +pub const EXFULL: c_int = 54; +pub const ENOANO: c_int = 55; +pub const EBADRQC: c_int = 56; +pub const EBADSLT: c_int = 57; +pub const EBFONT: c_int = 59; +pub const ENOSTR: c_int = 60; +pub const ENODATA: c_int = 61; +pub const ETIME: c_int = 62; +pub const ENOSR: c_int = 63; +pub const ENONET: c_int = 64; +pub const ENOPKG: c_int = 65; +pub const EREMOTE: c_int = 66; +pub const ENOLINK: c_int = 67; +pub const EADV: c_int = 68; +pub const ESRMNT: c_int = 69; +pub const ECOMM: c_int = 70; +pub const EPROTO: c_int = 71; +pub const EDOTDOT: c_int = 73; +pub const EMULTIHOP: c_int = 72; +pub const EOVERFLOW: c_int = 75; +pub const ENOTUNIQ: c_int = 76; +pub const EBADFD: c_int = 77; +pub const EBADMSG: c_int = 74; +pub const EREMCHG: c_int = 78; +pub const ELIBACC: c_int = 79; +pub const ELIBBAD: c_int = 80; +pub const ELIBSCN: c_int = 81; +pub const ELIBMAX: c_int = 82; +pub const ELIBEXEC: c_int = 83; +pub const EILSEQ: c_int = 84; +pub const ERESTART: c_int = 85; +pub const ESTRPIPE: c_int = 86; +pub const EUSERS: c_int = 87; +pub const ENOTSOCK: c_int = 88; +pub const EDESTADDRREQ: c_int = 89; +pub const EMSGSIZE: c_int = 90; +pub const EPROTOTYPE: c_int = 91; +pub const ENOPROTOOPT: c_int = 92; +pub const EPROTONOSUPPORT: c_int = 93; +pub const ESOCKTNOSUPPORT: c_int = 94; +pub const EOPNOTSUPP: c_int = 95; +pub const EPFNOSUPPORT: c_int = 96; +pub const EAFNOSUPPORT: c_int = 97; +pub const EADDRINUSE: c_int = 98; +pub const EADDRNOTAVAIL: c_int = 99; +pub const ENETDOWN: c_int = 100; +pub const ENETUNREACH: c_int = 101; +pub const ENETRESET: c_int = 102; +pub const ECONNABORTED: c_int = 103; +pub const ECONNRESET: c_int = 104; +pub const ENOBUFS: c_int = 105; +pub const EISCONN: c_int = 106; +pub const ENOTCONN: c_int = 107; +pub const ESHUTDOWN: c_int = 108; +pub const ETOOMANYREFS: c_int = 109; +pub const ETIMEDOUT: c_int = 110; +pub const ECONNREFUSED: c_int = 111; +pub const EHOSTDOWN: c_int = 112; +pub const EHOSTUNREACH: c_int = 113; +pub const EALREADY: c_int = 114; +pub const EINPROGRESS: c_int = 115; +pub const ESTALE: c_int = 116; +pub const EUCLEAN: c_int = 117; +pub const ENOTNAM: c_int = 118; +pub const ENAVAIL: c_int = 119; +pub const EISNAM: c_int = 120; +pub const EREMOTEIO: c_int = 121; +pub const EDQUOT: c_int = 122; +pub const ENOMEDIUM: c_int = 123; +pub const EMEDIUMTYPE: c_int = 124; +pub const ECANCELED: c_int = 125; +pub const ENOKEY: c_int = 126; +pub const EKEYEXPIRED: c_int = 127; +pub const EKEYREVOKED: c_int = 128; +pub const EKEYREJECTED: c_int = 129; +pub const EOWNERDEAD: c_int = 130; +pub const ENOTRECOVERABLE: c_int = 131; +pub const ERFKILL: c_int = 132; +pub const EHWPOISON: c_int = 133; + +pub const MADV_SOFT_OFFLINE: c_int = 101; + +pub const MAP_NORESERVE: c_int = 0x4000; +pub const MAP_ANONYMOUS: c_int = 0x0020; +pub const MAP_ANON: c_int = 0x0020; +pub const MAP_GROWSDOWN: c_int = 0x0100; +pub const MAP_DENYWRITE: c_int = 0x0800; +pub const MAP_EXECUTABLE: c_int = 0x1000; +pub const MAP_LOCKED: c_int = 0x2000; +pub const MAP_POPULATE: c_int = 0x8000; +pub const MAP_NONBLOCK: c_int = 0x10000; +pub const MAP_STACK: c_int = 0x20000; +pub const MAP_HUGETLB: c_int = 0x40000; +pub const MAP_SYNC: c_int = 0x080000; +pub const MCL_CURRENT: c_int = 0x0001; +pub const MCL_FUTURE: c_int = 0x0002; +pub const MCL_ONFAULT: c_int = 0x0004; + +pub const SOCK_STREAM: c_int = 1; +pub const SOCK_DGRAM: c_int = 2; + +pub const SFD_NONBLOCK: c_int = 0x800; +pub const SFD_CLOEXEC: c_int = 0x080000; +pub const SA_NODEFER: c_int = 0x40000000; +pub const SA_RESETHAND: c_int = 0x80000000; +pub const SA_RESTART: c_int = 0x10000000; +pub const SA_NOCLDSTOP: c_int = 0x00000001; +pub const SA_ONSTACK: c_int = 0x08000000; +pub const SA_SIGINFO: c_int = 0x00000004; +pub const SA_NOCLDWAIT: c_int = 0x00000002; +pub const SIG_BLOCK: c_int = 0; +pub const SIG_UNBLOCK: c_int = 1; +pub const SIG_SETMASK: c_int = 2; +pub const SIGBUS: c_int = 7; +pub const SIGUSR1: c_int = 10; +pub const SIGUSR2: c_int = 12; +pub const SIGSTKFLT: c_int = 16; +pub const SIGCHLD: c_int = 17; +pub const SIGCONT: c_int = 18; +pub const SIGSTOP: c_int = 19; +pub const SIGTSTP: c_int = 20; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGURG: c_int = 23; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGIO: c_int = 29; +pub const SIGPOLL: c_int = 29; +pub const SIGPWR: c_int = 30; +pub const SIGSYS: c_int = 31; +pub const SIGUNUSED: c_int = 31; + +pub const POLLWRNORM: c_short = 0x100; +pub const POLLWRBAND: c_short = 0x200; + +pub const PTRACE_GETFPREGS: c_uint = 14; +pub const PTRACE_SETFPREGS: c_uint = 15; +pub const PTRACE_DETACH: c_uint = 17; +pub const PTRACE_GETFPXREGS: c_uint = 18; +pub const PTRACE_SETFPXREGS: c_uint = 19; +pub const PTRACE_GETREGS: c_uint = 12; +pub const PTRACE_SETREGS: c_uint = 13; +pub const PTRACE_SYSEMU: c_uint = 31; +pub const PTRACE_SYSEMU_SINGLESTEP: c_uint = 32; + +pub const RTLD_DEEPBIND: c_int = 0x8; +pub const RTLD_GLOBAL: c_int = 0x100; +pub const RTLD_NOLOAD: c_int = 0x4; + +pub const VEOF: usize = 4; +pub const VTIME: usize = 5; +pub const VMIN: usize = 6; +pub const VSWTC: usize = 7; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VSUSP: usize = 10; +pub const VEOL: usize = 11; +pub const VREPRINT: usize = 12; +pub const VDISCARD: usize = 13; +pub const VWERASE: usize = 14; +pub const VEOL2: usize = 16; +pub const IEXTEN: crate::tcflag_t = 0x00008000; +pub const TOSTOP: crate::tcflag_t = 0x00000100; +pub const FLUSHO: crate::tcflag_t = 0x00001000; +pub const EXTPROC: crate::tcflag_t = 0x00010000; +pub const TCSANOW: c_int = 0; +pub const TCSADRAIN: c_int = 1; +pub const TCSAFLUSH: c_int = 2; +pub const SIGSTKSZ: size_t = 16384; +pub const MINSIGSTKSZ: size_t = 4096; +pub const CBAUD: crate::tcflag_t = 0o0010017; +pub const CSIZE: crate::tcflag_t = 0x00000030; +pub const CS6: crate::tcflag_t = 0x00000010; +pub const CS7: crate::tcflag_t = 0x00000020; +pub const CS8: crate::tcflag_t = 0x00000030; +pub const CSTOPB: crate::tcflag_t = 0x00000040; +pub const CREAD: crate::tcflag_t = 0x00000080; +pub const PARENB: crate::tcflag_t = 0x00000100; +pub const PARODD: crate::tcflag_t = 0x00000200; +pub const HUPCL: crate::tcflag_t = 0x00000400; +pub const CLOCAL: crate::tcflag_t = 0x00000800; +pub const CIBAUD: crate::tcflag_t = 0o02003600000; +pub const CBAUDEX: crate::tcflag_t = 0o010000; +pub const B0: crate::speed_t = 0o000000; +pub const B50: crate::speed_t = 0o000001; +pub const B75: crate::speed_t = 0o000002; +pub const B110: crate::speed_t = 0o000003; +pub const B134: crate::speed_t = 0o000004; +pub const B150: crate::speed_t = 0o000005; +pub const B200: crate::speed_t = 0o000006; +pub const B300: crate::speed_t = 0o000007; +pub const B600: crate::speed_t = 0o000010; +pub const B1200: crate::speed_t = 0o000011; +pub const B1800: crate::speed_t = 0o000012; +pub const B2400: crate::speed_t = 0o000013; +pub const B4800: crate::speed_t = 0o000014; +pub const B9600: crate::speed_t = 0o000015; +pub const B19200: crate::speed_t = 0o000016; +pub const B38400: crate::speed_t = 0o000017; +pub const EXTA: crate::speed_t = B19200; +pub const EXTB: crate::speed_t = B38400; +pub const B57600: crate::speed_t = 0o010001; +pub const B115200: crate::speed_t = 0o010002; +pub const B230400: crate::speed_t = 0o010003; +pub const B460800: crate::speed_t = 0o010004; +pub const B500000: crate::speed_t = 0o010005; +pub const B576000: crate::speed_t = 0o010006; +pub const B921600: crate::speed_t = 0o010007; +pub const B1000000: crate::speed_t = 0o010010; +pub const B1152000: crate::speed_t = 0o010011; +pub const B1500000: crate::speed_t = 0o010012; +pub const B2000000: crate::speed_t = 0o010013; +pub const B2500000: crate::speed_t = 0o010014; +pub const B3000000: crate::speed_t = 0o010015; +pub const B3500000: crate::speed_t = 0o010016; +pub const B4000000: crate::speed_t = 0o010017; +pub const TAB1: crate::tcflag_t = 0x00000800; +pub const TAB2: crate::tcflag_t = 0x00001000; +pub const TAB3: crate::tcflag_t = 0x00001800; +pub const CR1: crate::tcflag_t = 0x00000200; +pub const CR2: crate::tcflag_t = 0x00000400; +pub const CR3: crate::tcflag_t = 0x00000600; +pub const FF1: crate::tcflag_t = 0x00008000; +pub const BS1: crate::tcflag_t = 0x00002000; +pub const OLCUC: crate::tcflag_t = 0o000002; +pub const NLDLY: crate::tcflag_t = 0o000400; +pub const CRDLY: crate::tcflag_t = 0o003000; +pub const TABDLY: crate::tcflag_t = 0o014000; +pub const BSDLY: crate::tcflag_t = 0o020000; +pub const FFDLY: crate::tcflag_t = 0o100000; +pub const VTDLY: crate::tcflag_t = 0o040000; +pub const XTABS: crate::tcflag_t = 0o014000; +pub const VT1: crate::tcflag_t = 0x00004000; +pub const ONLCR: crate::tcflag_t = 0x4; +pub const IXON: crate::tcflag_t = 0x00000400; +pub const IXOFF: crate::tcflag_t = 0x00001000; +pub const ECHOKE: crate::tcflag_t = 0x00000800; +pub const ECHOE: crate::tcflag_t = 0x00000010; +pub const ECHOK: crate::tcflag_t = 0x00000020; +pub const ECHONL: crate::tcflag_t = 0x00000040; +pub const ECHOPRT: crate::tcflag_t = 0x00000400; +pub const ECHOCTL: crate::tcflag_t = 0x00000200; +pub const ISIG: crate::tcflag_t = 0x00000001; +pub const ICANON: crate::tcflag_t = 0x00000002; +pub const PENDIN: crate::tcflag_t = 0x00004000; +pub const NOFLSH: crate::tcflag_t = 0x00000080; + +pub const NCCS: usize = 32; + +pub const EPOLL_CLOEXEC: c_int = 0x80000; + +pub const EFD_CLOEXEC: c_int = 0x80000; +pub const EFD_NONBLOCK: c_int = 0x800; diff --git a/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs new file mode 100644 index 0000000..dfec920 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs @@ -0,0 +1,934 @@ +use crate::prelude::*; +use crate::{ + off64_t, + off_t, + pthread_mutex_t, +}; + +pub type blksize_t = i64; +pub type nlink_t = u64; +pub type suseconds_t = i64; +pub type wchar_t = i32; +pub type __u64 = c_ulong; +pub type __s64 = c_long; + +s! { + pub struct stat { + pub st_dev: c_ulong, + st_pad1: Padding<[c_long; 2]>, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: c_ulong, + st_pad2: Padding<[c_ulong; 1]>, + pub st_size: off_t, + st_pad3: Padding, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + pub st_blksize: crate::blksize_t, + st_pad4: Padding, + pub st_blocks: crate::blkcnt_t, + st_pad5: Padding<[c_long; 7]>, + } + + pub struct statfs { + pub f_type: c_long, + pub f_bsize: c_long, + pub f_frsize: c_long, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_files: crate::fsblkcnt_t, + pub f_ffree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_fsid: crate::fsid_t, + + pub f_namelen: c_long, + f_spare: [c_long; 6], + } + + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off_t, + pub l_len: off_t, + pub l_pid: crate::pid_t, + } + + pub struct flock64 { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off64_t, + pub l_len: off64_t, + pub l_pid: crate::pid_t, + } + + pub struct stat64 { + pub st_dev: c_ulong, + st_pad1: Padding<[c_long; 2]>, + pub st_ino: crate::ino64_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: c_ulong, + st_pad2: Padding<[c_long; 2]>, + pub st_size: off64_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + pub st_blksize: crate::blksize_t, + st_pad3: Padding, + pub st_blocks: crate::blkcnt64_t, + st_pad5: Padding<[c_long; 7]>, + } + + pub struct statfs64 { + pub f_type: c_long, + pub f_bsize: c_long, + pub f_frsize: c_long, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_bavail: u64, + pub f_fsid: crate::fsid_t, + pub f_namelen: c_long, + pub f_flags: c_long, + pub f_spare: [c_long; 5], + } + + pub struct statvfs { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_favail: crate::fsfilcnt_t, + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: [c_int; 6], + } + + pub struct statvfs64 { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: [c_int; 6], + } + + pub struct pthread_attr_t { + __size: [c_ulong; 7], + } + + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigaction { + pub sa_flags: c_int, + pub sa_sigaction: crate::sighandler_t, + pub sa_mask: crate::sigset_t, + pub sa_restorer: Option, + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_size: size_t, + pub ss_flags: c_int, + } + + pub struct siginfo_t { + pub si_signo: c_int, + pub si_code: c_int, + pub si_errno: c_int, + _pad: Padding, + _pad2: Padding<[c_long; 14]>, + } + + pub struct ipc_perm { + pub __key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: c_uint, + pub __seq: c_ushort, + __pad1: Padding, + __unused1: Padding, + __unused2: Padding, + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, + pub shm_atime: crate::time_t, + pub shm_dtime: crate::time_t, + pub shm_ctime: crate::time_t, + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: crate::shmatt_t, + __unused4: Padding, + __unused5: Padding, + } +} + +s_no_extra_traits! { + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 4], + } +} + +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; +pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; + +#[cfg(target_endian = "little")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; + +pub const SYS_read: c_long = 5000 + 0; +pub const SYS_write: c_long = 5000 + 1; +pub const SYS_open: c_long = 5000 + 2; +pub const SYS_close: c_long = 5000 + 3; +pub const SYS_stat: c_long = 5000 + 4; +pub const SYS_fstat: c_long = 5000 + 5; +pub const SYS_lstat: c_long = 5000 + 6; +pub const SYS_poll: c_long = 5000 + 7; +pub const SYS_lseek: c_long = 5000 + 8; +pub const SYS_mmap: c_long = 5000 + 9; +pub const SYS_mprotect: c_long = 5000 + 10; +pub const SYS_munmap: c_long = 5000 + 11; +pub const SYS_brk: c_long = 5000 + 12; +pub const SYS_rt_sigaction: c_long = 5000 + 13; +pub const SYS_rt_sigprocmask: c_long = 5000 + 14; +pub const SYS_ioctl: c_long = 5000 + 15; +pub const SYS_pread64: c_long = 5000 + 16; +pub const SYS_pwrite64: c_long = 5000 + 17; +pub const SYS_readv: c_long = 5000 + 18; +pub const SYS_writev: c_long = 5000 + 19; +pub const SYS_access: c_long = 5000 + 20; +pub const SYS_pipe: c_long = 5000 + 21; +pub const SYS__newselect: c_long = 5000 + 22; +pub const SYS_sched_yield: c_long = 5000 + 23; +pub const SYS_mremap: c_long = 5000 + 24; +pub const SYS_msync: c_long = 5000 + 25; +pub const SYS_mincore: c_long = 5000 + 26; +pub const SYS_madvise: c_long = 5000 + 27; +pub const SYS_shmget: c_long = 5000 + 28; +pub const SYS_shmat: c_long = 5000 + 29; +pub const SYS_shmctl: c_long = 5000 + 30; +pub const SYS_dup: c_long = 5000 + 31; +pub const SYS_dup2: c_long = 5000 + 32; +pub const SYS_pause: c_long = 5000 + 33; +pub const SYS_nanosleep: c_long = 5000 + 34; +pub const SYS_getitimer: c_long = 5000 + 35; +pub const SYS_setitimer: c_long = 5000 + 36; +pub const SYS_alarm: c_long = 5000 + 37; +pub const SYS_getpid: c_long = 5000 + 38; +pub const SYS_sendfile: c_long = 5000 + 39; +pub const SYS_socket: c_long = 5000 + 40; +pub const SYS_connect: c_long = 5000 + 41; +pub const SYS_accept: c_long = 5000 + 42; +pub const SYS_sendto: c_long = 5000 + 43; +pub const SYS_recvfrom: c_long = 5000 + 44; +pub const SYS_sendmsg: c_long = 5000 + 45; +pub const SYS_recvmsg: c_long = 5000 + 46; +pub const SYS_shutdown: c_long = 5000 + 47; +pub const SYS_bind: c_long = 5000 + 48; +pub const SYS_listen: c_long = 5000 + 49; +pub const SYS_getsockname: c_long = 5000 + 50; +pub const SYS_getpeername: c_long = 5000 + 51; +pub const SYS_socketpair: c_long = 5000 + 52; +pub const SYS_setsockopt: c_long = 5000 + 53; +pub const SYS_getsockopt: c_long = 5000 + 54; +pub const SYS_clone: c_long = 5000 + 55; +pub const SYS_fork: c_long = 5000 + 56; +pub const SYS_execve: c_long = 5000 + 57; +pub const SYS_exit: c_long = 5000 + 58; +pub const SYS_wait4: c_long = 5000 + 59; +pub const SYS_kill: c_long = 5000 + 60; +pub const SYS_uname: c_long = 5000 + 61; +pub const SYS_semget: c_long = 5000 + 62; +pub const SYS_semop: c_long = 5000 + 63; +pub const SYS_semctl: c_long = 5000 + 64; +pub const SYS_shmdt: c_long = 5000 + 65; +pub const SYS_msgget: c_long = 5000 + 66; +pub const SYS_msgsnd: c_long = 5000 + 67; +pub const SYS_msgrcv: c_long = 5000 + 68; +pub const SYS_msgctl: c_long = 5000 + 69; +pub const SYS_fcntl: c_long = 5000 + 70; +pub const SYS_flock: c_long = 5000 + 71; +pub const SYS_fsync: c_long = 5000 + 72; +pub const SYS_fdatasync: c_long = 5000 + 73; +pub const SYS_truncate: c_long = 5000 + 74; +pub const SYS_ftruncate: c_long = 5000 + 75; +pub const SYS_getdents: c_long = 5000 + 76; +pub const SYS_getcwd: c_long = 5000 + 77; +pub const SYS_chdir: c_long = 5000 + 78; +pub const SYS_fchdir: c_long = 5000 + 79; +pub const SYS_rename: c_long = 5000 + 80; +pub const SYS_mkdir: c_long = 5000 + 81; +pub const SYS_rmdir: c_long = 5000 + 82; +pub const SYS_creat: c_long = 5000 + 83; +pub const SYS_link: c_long = 5000 + 84; +pub const SYS_unlink: c_long = 5000 + 85; +pub const SYS_symlink: c_long = 5000 + 86; +pub const SYS_readlink: c_long = 5000 + 87; +pub const SYS_chmod: c_long = 5000 + 88; +pub const SYS_fchmod: c_long = 5000 + 89; +pub const SYS_chown: c_long = 5000 + 90; +pub const SYS_fchown: c_long = 5000 + 91; +pub const SYS_lchown: c_long = 5000 + 92; +pub const SYS_umask: c_long = 5000 + 93; +pub const SYS_gettimeofday: c_long = 5000 + 94; +pub const SYS_getrlimit: c_long = 5000 + 95; +pub const SYS_getrusage: c_long = 5000 + 96; +pub const SYS_sysinfo: c_long = 5000 + 97; +pub const SYS_times: c_long = 5000 + 98; +pub const SYS_ptrace: c_long = 5000 + 99; +pub const SYS_getuid: c_long = 5000 + 100; +pub const SYS_syslog: c_long = 5000 + 101; +pub const SYS_getgid: c_long = 5000 + 102; +pub const SYS_setuid: c_long = 5000 + 103; +pub const SYS_setgid: c_long = 5000 + 104; +pub const SYS_geteuid: c_long = 5000 + 105; +pub const SYS_getegid: c_long = 5000 + 106; +pub const SYS_setpgid: c_long = 5000 + 107; +pub const SYS_getppid: c_long = 5000 + 108; +pub const SYS_getpgrp: c_long = 5000 + 109; +pub const SYS_setsid: c_long = 5000 + 110; +pub const SYS_setreuid: c_long = 5000 + 111; +pub const SYS_setregid: c_long = 5000 + 112; +pub const SYS_getgroups: c_long = 5000 + 113; +pub const SYS_setgroups: c_long = 5000 + 114; +pub const SYS_setresuid: c_long = 5000 + 115; +pub const SYS_getresuid: c_long = 5000 + 116; +pub const SYS_setresgid: c_long = 5000 + 117; +pub const SYS_getresgid: c_long = 5000 + 118; +pub const SYS_getpgid: c_long = 5000 + 119; +pub const SYS_setfsuid: c_long = 5000 + 120; +pub const SYS_setfsgid: c_long = 5000 + 121; +pub const SYS_getsid: c_long = 5000 + 122; +pub const SYS_capget: c_long = 5000 + 123; +pub const SYS_capset: c_long = 5000 + 124; +pub const SYS_rt_sigpending: c_long = 5000 + 125; +pub const SYS_rt_sigtimedwait: c_long = 5000 + 126; +pub const SYS_rt_sigqueueinfo: c_long = 5000 + 127; +pub const SYS_rt_sigsuspend: c_long = 5000 + 128; +pub const SYS_sigaltstack: c_long = 5000 + 129; +pub const SYS_utime: c_long = 5000 + 130; +pub const SYS_mknod: c_long = 5000 + 131; +pub const SYS_personality: c_long = 5000 + 132; +pub const SYS_ustat: c_long = 5000 + 133; +pub const SYS_statfs: c_long = 5000 + 134; +pub const SYS_fstatfs: c_long = 5000 + 135; +pub const SYS_sysfs: c_long = 5000 + 136; +pub const SYS_getpriority: c_long = 5000 + 137; +pub const SYS_setpriority: c_long = 5000 + 138; +pub const SYS_sched_setparam: c_long = 5000 + 139; +pub const SYS_sched_getparam: c_long = 5000 + 140; +pub const SYS_sched_setscheduler: c_long = 5000 + 141; +pub const SYS_sched_getscheduler: c_long = 5000 + 142; +pub const SYS_sched_get_priority_max: c_long = 5000 + 143; +pub const SYS_sched_get_priority_min: c_long = 5000 + 144; +pub const SYS_sched_rr_get_interval: c_long = 5000 + 145; +pub const SYS_mlock: c_long = 5000 + 146; +pub const SYS_munlock: c_long = 5000 + 147; +pub const SYS_mlockall: c_long = 5000 + 148; +pub const SYS_munlockall: c_long = 5000 + 149; +pub const SYS_vhangup: c_long = 5000 + 150; +pub const SYS_pivot_root: c_long = 5000 + 151; +pub const SYS__sysctl: c_long = 5000 + 152; +pub const SYS_prctl: c_long = 5000 + 153; +pub const SYS_adjtimex: c_long = 5000 + 154; +pub const SYS_setrlimit: c_long = 5000 + 155; +pub const SYS_chroot: c_long = 5000 + 156; +pub const SYS_sync: c_long = 5000 + 157; +pub const SYS_acct: c_long = 5000 + 158; +pub const SYS_settimeofday: c_long = 5000 + 159; +pub const SYS_mount: c_long = 5000 + 160; +pub const SYS_umount2: c_long = 5000 + 161; +pub const SYS_swapon: c_long = 5000 + 162; +pub const SYS_swapoff: c_long = 5000 + 163; +pub const SYS_reboot: c_long = 5000 + 164; +pub const SYS_sethostname: c_long = 5000 + 165; +pub const SYS_setdomainname: c_long = 5000 + 166; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_create_module: c_long = 5000 + 167; +pub const SYS_init_module: c_long = 5000 + 168; +pub const SYS_delete_module: c_long = 5000 + 169; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_get_kernel_syms: c_long = 5000 + 170; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_query_module: c_long = 5000 + 171; +pub const SYS_quotactl: c_long = 5000 + 172; +pub const SYS_nfsservctl: c_long = 5000 + 173; +pub const SYS_getpmsg: c_long = 5000 + 174; +pub const SYS_putpmsg: c_long = 5000 + 175; +pub const SYS_afs_syscall: c_long = 5000 + 176; +pub const SYS_gettid: c_long = 5000 + 178; +pub const SYS_readahead: c_long = 5000 + 179; +pub const SYS_setxattr: c_long = 5000 + 180; +pub const SYS_lsetxattr: c_long = 5000 + 181; +pub const SYS_fsetxattr: c_long = 5000 + 182; +pub const SYS_getxattr: c_long = 5000 + 183; +pub const SYS_lgetxattr: c_long = 5000 + 184; +pub const SYS_fgetxattr: c_long = 5000 + 185; +pub const SYS_listxattr: c_long = 5000 + 186; +pub const SYS_llistxattr: c_long = 5000 + 187; +pub const SYS_flistxattr: c_long = 5000 + 188; +pub const SYS_removexattr: c_long = 5000 + 189; +pub const SYS_lremovexattr: c_long = 5000 + 190; +pub const SYS_fremovexattr: c_long = 5000 + 191; +pub const SYS_tkill: c_long = 5000 + 192; +pub const SYS_futex: c_long = 5000 + 194; +pub const SYS_sched_setaffinity: c_long = 5000 + 195; +pub const SYS_sched_getaffinity: c_long = 5000 + 196; +pub const SYS_cacheflush: c_long = 5000 + 197; +pub const SYS_cachectl: c_long = 5000 + 198; +pub const SYS_sysmips: c_long = 5000 + 199; +pub const SYS_io_setup: c_long = 5000 + 200; +pub const SYS_io_destroy: c_long = 5000 + 201; +pub const SYS_io_getevents: c_long = 5000 + 202; +pub const SYS_io_submit: c_long = 5000 + 203; +pub const SYS_io_cancel: c_long = 5000 + 204; +pub const SYS_exit_group: c_long = 5000 + 205; +pub const SYS_lookup_dcookie: c_long = 5000 + 206; +pub const SYS_epoll_create: c_long = 5000 + 207; +pub const SYS_epoll_ctl: c_long = 5000 + 208; +pub const SYS_epoll_wait: c_long = 5000 + 209; +pub const SYS_remap_file_pages: c_long = 5000 + 210; +pub const SYS_rt_sigreturn: c_long = 5000 + 211; +pub const SYS_set_tid_address: c_long = 5000 + 212; +pub const SYS_restart_syscall: c_long = 5000 + 213; +pub const SYS_semtimedop: c_long = 5000 + 214; +pub const SYS_fadvise64: c_long = 5000 + 215; +pub const SYS_timer_create: c_long = 5000 + 216; +pub const SYS_timer_settime: c_long = 5000 + 217; +pub const SYS_timer_gettime: c_long = 5000 + 218; +pub const SYS_timer_getoverrun: c_long = 5000 + 219; +pub const SYS_timer_delete: c_long = 5000 + 220; +pub const SYS_clock_settime: c_long = 5000 + 221; +pub const SYS_clock_gettime: c_long = 5000 + 222; +pub const SYS_clock_getres: c_long = 5000 + 223; +pub const SYS_clock_nanosleep: c_long = 5000 + 224; +pub const SYS_tgkill: c_long = 5000 + 225; +pub const SYS_utimes: c_long = 5000 + 226; +pub const SYS_mbind: c_long = 5000 + 227; +pub const SYS_get_mempolicy: c_long = 5000 + 228; +pub const SYS_set_mempolicy: c_long = 5000 + 229; +pub const SYS_mq_open: c_long = 5000 + 230; +pub const SYS_mq_unlink: c_long = 5000 + 231; +pub const SYS_mq_timedsend: c_long = 5000 + 232; +pub const SYS_mq_timedreceive: c_long = 5000 + 233; +pub const SYS_mq_notify: c_long = 5000 + 234; +pub const SYS_mq_getsetattr: c_long = 5000 + 235; +pub const SYS_vserver: c_long = 5000 + 236; +pub const SYS_waitid: c_long = 5000 + 237; +/* pub const SYS_sys_setaltroot: c_long = 5000 + 238; */ +pub const SYS_add_key: c_long = 5000 + 239; +pub const SYS_request_key: c_long = 5000 + 240; +pub const SYS_keyctl: c_long = 5000 + 241; +pub const SYS_set_thread_area: c_long = 5000 + 242; +pub const SYS_inotify_init: c_long = 5000 + 243; +pub const SYS_inotify_add_watch: c_long = 5000 + 244; +pub const SYS_inotify_rm_watch: c_long = 5000 + 245; +pub const SYS_migrate_pages: c_long = 5000 + 246; +pub const SYS_openat: c_long = 5000 + 247; +pub const SYS_mkdirat: c_long = 5000 + 248; +pub const SYS_mknodat: c_long = 5000 + 249; +pub const SYS_fchownat: c_long = 5000 + 250; +pub const SYS_futimesat: c_long = 5000 + 251; +pub const SYS_newfstatat: c_long = 5000 + 252; +pub const SYS_unlinkat: c_long = 5000 + 253; +pub const SYS_renameat: c_long = 5000 + 254; +pub const SYS_linkat: c_long = 5000 + 255; +pub const SYS_symlinkat: c_long = 5000 + 256; +pub const SYS_readlinkat: c_long = 5000 + 257; +pub const SYS_fchmodat: c_long = 5000 + 258; +pub const SYS_faccessat: c_long = 5000 + 259; +pub const SYS_pselect6: c_long = 5000 + 260; +pub const SYS_ppoll: c_long = 5000 + 261; +pub const SYS_unshare: c_long = 5000 + 262; +pub const SYS_splice: c_long = 5000 + 263; +pub const SYS_sync_file_range: c_long = 5000 + 264; +pub const SYS_tee: c_long = 5000 + 265; +pub const SYS_vmsplice: c_long = 5000 + 266; +pub const SYS_move_pages: c_long = 5000 + 267; +pub const SYS_set_robust_list: c_long = 5000 + 268; +pub const SYS_get_robust_list: c_long = 5000 + 269; +pub const SYS_kexec_load: c_long = 5000 + 270; +pub const SYS_getcpu: c_long = 5000 + 271; +pub const SYS_epoll_pwait: c_long = 5000 + 272; +pub const SYS_ioprio_set: c_long = 5000 + 273; +pub const SYS_ioprio_get: c_long = 5000 + 274; +pub const SYS_utimensat: c_long = 5000 + 275; +pub const SYS_signalfd: c_long = 5000 + 276; +pub const SYS_timerfd: c_long = 5000 + 277; +pub const SYS_eventfd: c_long = 5000 + 278; +pub const SYS_fallocate: c_long = 5000 + 279; +pub const SYS_timerfd_create: c_long = 5000 + 280; +pub const SYS_timerfd_gettime: c_long = 5000 + 281; +pub const SYS_timerfd_settime: c_long = 5000 + 282; +pub const SYS_signalfd4: c_long = 5000 + 283; +pub const SYS_eventfd2: c_long = 5000 + 284; +pub const SYS_epoll_create1: c_long = 5000 + 285; +pub const SYS_dup3: c_long = 5000 + 286; +pub const SYS_pipe2: c_long = 5000 + 287; +pub const SYS_inotify_init1: c_long = 5000 + 288; +pub const SYS_preadv: c_long = 5000 + 289; +pub const SYS_pwritev: c_long = 5000 + 290; +pub const SYS_rt_tgsigqueueinfo: c_long = 5000 + 291; +pub const SYS_perf_event_open: c_long = 5000 + 292; +pub const SYS_accept4: c_long = 5000 + 293; +pub const SYS_recvmmsg: c_long = 5000 + 294; +pub const SYS_fanotify_init: c_long = 5000 + 295; +pub const SYS_fanotify_mark: c_long = 5000 + 296; +pub const SYS_prlimit64: c_long = 5000 + 297; +pub const SYS_name_to_handle_at: c_long = 5000 + 298; +pub const SYS_open_by_handle_at: c_long = 5000 + 299; +pub const SYS_clock_adjtime: c_long = 5000 + 300; +pub const SYS_syncfs: c_long = 5000 + 301; +pub const SYS_sendmmsg: c_long = 5000 + 302; +pub const SYS_setns: c_long = 5000 + 303; +pub const SYS_process_vm_readv: c_long = 5000 + 304; +pub const SYS_process_vm_writev: c_long = 5000 + 305; +pub const SYS_kcmp: c_long = 5000 + 306; +pub const SYS_finit_module: c_long = 5000 + 307; +pub const SYS_getdents64: c_long = 5000 + 308; +pub const SYS_sched_setattr: c_long = 5000 + 309; +pub const SYS_sched_getattr: c_long = 5000 + 310; +pub const SYS_renameat2: c_long = 5000 + 311; +pub const SYS_seccomp: c_long = 5000 + 312; +pub const SYS_getrandom: c_long = 5000 + 313; +pub const SYS_memfd_create: c_long = 5000 + 314; +pub const SYS_bpf: c_long = 5000 + 315; +pub const SYS_execveat: c_long = 5000 + 316; +pub const SYS_userfaultfd: c_long = 5000 + 317; +pub const SYS_membarrier: c_long = 5000 + 318; +pub const SYS_mlock2: c_long = 5000 + 319; +pub const SYS_copy_file_range: c_long = 5000 + 320; +pub const SYS_preadv2: c_long = 5000 + 321; +pub const SYS_pwritev2: c_long = 5000 + 322; +pub const SYS_pkey_mprotect: c_long = 5000 + 323; +pub const SYS_pkey_alloc: c_long = 5000 + 324; +pub const SYS_pkey_free: c_long = 5000 + 325; +pub const SYS_statx: c_long = 5000 + 326; +pub const SYS_rseq: c_long = 5000 + 327; +pub const SYS_pidfd_send_signal: c_long = 5000 + 424; +pub const SYS_io_uring_setup: c_long = 5000 + 425; +pub const SYS_io_uring_enter: c_long = 5000 + 426; +pub const SYS_io_uring_register: c_long = 5000 + 427; +pub const SYS_open_tree: c_long = 5000 + 428; +pub const SYS_move_mount: c_long = 5000 + 429; +pub const SYS_fsopen: c_long = 5000 + 430; +pub const SYS_fsconfig: c_long = 5000 + 431; +pub const SYS_fsmount: c_long = 5000 + 432; +pub const SYS_fspick: c_long = 5000 + 433; +pub const SYS_pidfd_open: c_long = 5000 + 434; +pub const SYS_clone3: c_long = 5000 + 435; +pub const SYS_close_range: c_long = 5000 + 436; +pub const SYS_openat2: c_long = 5000 + 437; +pub const SYS_pidfd_getfd: c_long = 5000 + 438; +pub const SYS_faccessat2: c_long = 5000 + 439; +pub const SYS_process_madvise: c_long = 5000 + 440; +pub const SYS_epoll_pwait2: c_long = 5000 + 441; +pub const SYS_mount_setattr: c_long = 5000 + 442; +pub const SYS_quotactl_fd: c_long = 5000 + 443; +pub const SYS_landlock_create_ruleset: c_long = 5000 + 444; +pub const SYS_landlock_add_rule: c_long = 5000 + 445; +pub const SYS_landlock_restrict_self: c_long = 5000 + 446; +pub const SYS_memfd_secret: c_long = 5000 + 447; +pub const SYS_process_mrelease: c_long = 5000 + 448; +pub const SYS_futex_waitv: c_long = 5000 + 449; +pub const SYS_set_mempolicy_home_node: c_long = 5000 + 450; + +pub const SFD_CLOEXEC: c_int = 0x080000; + +pub const NCCS: usize = 32; + +pub const O_TRUNC: c_int = 512; + +pub const O_NOATIME: c_int = 0o1000000; +pub const O_CLOEXEC: c_int = 0x80000; +pub const O_PATH: c_int = 0o10000000; +pub const O_TMPFILE: c_int = 0o20000000 | O_DIRECTORY; + +pub const EBFONT: c_int = 59; +pub const ENOSTR: c_int = 60; +pub const ENODATA: c_int = 61; +pub const ETIME: c_int = 62; +pub const ENOSR: c_int = 63; +pub const ENONET: c_int = 64; +pub const ENOPKG: c_int = 65; +pub const EREMOTE: c_int = 66; +pub const ENOLINK: c_int = 67; +pub const EADV: c_int = 68; +pub const ESRMNT: c_int = 69; +pub const ECOMM: c_int = 70; +pub const EPROTO: c_int = 71; +pub const EDOTDOT: c_int = 73; + +pub const SA_NODEFER: c_int = 0x40000000; +pub const SA_RESETHAND: c_int = 0x80000000; +pub const SA_RESTART: c_int = 0x10000000; +pub const SA_NOCLDSTOP: c_int = 0x00000001; + +pub const POSIX_FADV_DONTNEED: c_int = 4; +pub const POSIX_FADV_NOREUSE: c_int = 5; + +pub const EPOLL_CLOEXEC: c_int = 0x80000; + +pub const EFD_CLOEXEC: c_int = 0x80000; + +pub const O_DIRECT: c_int = 0x8000; +pub const O_DIRECTORY: c_int = 0x10000; +pub const O_NOFOLLOW: c_int = 0x20000; + +pub const O_APPEND: c_int = 8; +pub const O_CREAT: c_int = 256; +pub const O_EXCL: c_int = 1024; +pub const O_NOCTTY: c_int = 2048; +pub const O_NONBLOCK: c_int = 128; +pub const O_SYNC: c_int = 0x4010; +pub const O_RSYNC: c_int = 0x4010; +pub const O_DSYNC: c_int = 0x10; +pub const O_FSYNC: c_int = 0x4010; +pub const O_ASYNC: c_int = 0x1000; +pub const O_NDELAY: c_int = 0x80; + +pub const EDEADLK: c_int = 45; +pub const ENAMETOOLONG: c_int = 78; +pub const ENOLCK: c_int = 46; +pub const ENOSYS: c_int = 89; +pub const ENOTEMPTY: c_int = 93; +pub const ELOOP: c_int = 90; +pub const ENOMSG: c_int = 35; +pub const EIDRM: c_int = 36; +pub const ECHRNG: c_int = 37; +pub const EL2NSYNC: c_int = 38; +pub const EL3HLT: c_int = 39; +pub const EL3RST: c_int = 40; +pub const ELNRNG: c_int = 41; +pub const EUNATCH: c_int = 42; +pub const ENOCSI: c_int = 43; +pub const EL2HLT: c_int = 44; +pub const EBADE: c_int = 50; +pub const EBADR: c_int = 51; +pub const EXFULL: c_int = 52; +pub const ENOANO: c_int = 53; +pub const EBADRQC: c_int = 54; +pub const EBADSLT: c_int = 55; +pub const EDEADLOCK: c_int = 56; +pub const EMULTIHOP: c_int = 74; +pub const EOVERFLOW: c_int = 79; +pub const ENOTUNIQ: c_int = 80; +pub const EBADFD: c_int = 81; +pub const EBADMSG: c_int = 77; +pub const EREMCHG: c_int = 82; +pub const ELIBACC: c_int = 83; +pub const ELIBBAD: c_int = 84; +pub const ELIBSCN: c_int = 85; +pub const ELIBMAX: c_int = 86; +pub const ELIBEXEC: c_int = 87; +pub const EILSEQ: c_int = 88; +pub const ERESTART: c_int = 91; +pub const ESTRPIPE: c_int = 92; +pub const EUSERS: c_int = 94; +pub const ENOTSOCK: c_int = 95; +pub const EDESTADDRREQ: c_int = 96; +pub const EMSGSIZE: c_int = 97; +pub const EPROTOTYPE: c_int = 98; +pub const ENOPROTOOPT: c_int = 99; +pub const EPROTONOSUPPORT: c_int = 120; +pub const ESOCKTNOSUPPORT: c_int = 121; +pub const EOPNOTSUPP: c_int = 122; +pub const EPFNOSUPPORT: c_int = 123; +pub const EAFNOSUPPORT: c_int = 124; +pub const EADDRINUSE: c_int = 125; +pub const EADDRNOTAVAIL: c_int = 126; +pub const ENETDOWN: c_int = 127; +pub const ENETUNREACH: c_int = 128; +pub const ENETRESET: c_int = 129; +pub const ECONNABORTED: c_int = 130; +pub const ECONNRESET: c_int = 131; +pub const ENOBUFS: c_int = 132; +pub const EISCONN: c_int = 133; +pub const ENOTCONN: c_int = 134; +pub const ESHUTDOWN: c_int = 143; +pub const ETOOMANYREFS: c_int = 144; +pub const ETIMEDOUT: c_int = 145; +pub const ECONNREFUSED: c_int = 146; +pub const EHOSTDOWN: c_int = 147; +pub const EHOSTUNREACH: c_int = 148; +pub const EALREADY: c_int = 149; +pub const EINPROGRESS: c_int = 150; +pub const ESTALE: c_int = 151; +pub const EUCLEAN: c_int = 135; +pub const ENOTNAM: c_int = 137; +pub const ENAVAIL: c_int = 138; +pub const EISNAM: c_int = 139; +pub const EREMOTEIO: c_int = 140; +pub const EDQUOT: c_int = 1133; +pub const ENOMEDIUM: c_int = 159; +pub const EMEDIUMTYPE: c_int = 160; +pub const ECANCELED: c_int = 158; +pub const ENOKEY: c_int = 161; +pub const EKEYEXPIRED: c_int = 162; +pub const EKEYREVOKED: c_int = 163; +pub const EKEYREJECTED: c_int = 164; +pub const EOWNERDEAD: c_int = 165; +pub const ENOTRECOVERABLE: c_int = 166; +pub const ERFKILL: c_int = 167; + +pub const MAP_NORESERVE: c_int = 0x400; +pub const MAP_ANON: c_int = 0x800; +pub const MAP_ANONYMOUS: c_int = 0x800; +pub const MAP_GROWSDOWN: c_int = 0x1000; +pub const MAP_DENYWRITE: c_int = 0x2000; +pub const MAP_EXECUTABLE: c_int = 0x4000; +pub const MAP_LOCKED: c_int = 0x8000; +pub const MAP_POPULATE: c_int = 0x10000; +pub const MAP_NONBLOCK: c_int = 0x20000; +pub const MAP_STACK: c_int = 0x40000; +pub const MAP_HUGETLB: c_int = 0x080000; + +pub const SOCK_STREAM: c_int = 2; +pub const SOCK_DGRAM: c_int = 1; + +pub const SA_ONSTACK: c_int = 0x08000000; +pub const SA_SIGINFO: c_int = 0x00000008; +pub const SA_NOCLDWAIT: c_int = 0x00010000; + +pub const SIGEMT: c_int = 7; +pub const SIGCHLD: c_int = 18; +pub const SIGBUS: c_int = 10; +pub const SIGTTIN: c_int = 26; +pub const SIGTTOU: c_int = 27; +pub const SIGXCPU: c_int = 30; +pub const SIGXFSZ: c_int = 31; +pub const SIGVTALRM: c_int = 28; +pub const SIGPROF: c_int = 29; +pub const SIGWINCH: c_int = 20; +pub const SIGUSR1: c_int = 16; +pub const SIGUSR2: c_int = 17; +pub const SIGCONT: c_int = 25; +pub const SIGSTOP: c_int = 23; +pub const SIGTSTP: c_int = 24; +pub const SIGURG: c_int = 21; +pub const SIGIO: c_int = 22; +pub const SIGSYS: c_int = 12; +pub const SIGPOLL: c_int = 22; +pub const SIGPWR: c_int = 19; +pub const SIG_SETMASK: c_int = 3; +pub const SIG_BLOCK: c_int = 0x1; +pub const SIG_UNBLOCK: c_int = 0x2; + +pub const POLLWRNORM: c_short = 0x004; +pub const POLLWRBAND: c_short = 0x100; + +pub const VEOF: usize = 16; +pub const VEOL: usize = 17; +pub const VEOL2: usize = 6; +pub const VMIN: usize = 4; +pub const IEXTEN: crate::tcflag_t = 0x00000100; +pub const TOSTOP: crate::tcflag_t = 0x00008000; +pub const FLUSHO: crate::tcflag_t = 0x00002000; +pub const EXTPROC: crate::tcflag_t = 0o200000; +pub const TCSANOW: c_int = 0x540e; +pub const TCSADRAIN: c_int = 0x540f; +pub const TCSAFLUSH: c_int = 0x5410; + +pub const PTRACE_GETFPREGS: c_uint = 14; +pub const PTRACE_SETFPREGS: c_uint = 15; +pub const PTRACE_DETACH: c_uint = 17; +pub const PTRACE_GETFPXREGS: c_uint = 18; +pub const PTRACE_SETFPXREGS: c_uint = 19; +pub const PTRACE_GETREGS: c_uint = 12; +pub const PTRACE_SETREGS: c_uint = 13; + +pub const EFD_NONBLOCK: c_int = 0x80; + +pub const F_RDLCK: c_int = 0; +pub const F_WRLCK: c_int = 1; +pub const F_UNLCK: c_int = 2; +pub const F_GETLK: c_int = 14; +pub const F_GETOWN: c_int = 23; +pub const F_SETOWN: c_int = 24; +pub const F_SETLK: c_int = 6; +pub const F_SETLKW: c_int = 7; +pub const F_OFD_GETLK: c_int = 36; +pub const F_OFD_SETLK: c_int = 37; +pub const F_OFD_SETLKW: c_int = 38; + +pub const SFD_NONBLOCK: c_int = 0x80; + +pub const RTLD_DEEPBIND: c_int = 0x10; +pub const RTLD_GLOBAL: c_int = 0x4; +pub const RTLD_NOLOAD: c_int = 0x8; + +pub const MCL_CURRENT: c_int = 0x0001; +pub const MCL_FUTURE: c_int = 0x0002; +pub const MCL_ONFAULT: c_int = 0x0004; + +pub const SIGSTKSZ: size_t = 8192; +pub const MINSIGSTKSZ: size_t = 2048; +pub const CBAUD: crate::tcflag_t = 0o0010017; +pub const TAB1: crate::tcflag_t = 0x00000800; +pub const TAB2: crate::tcflag_t = 0x00001000; +pub const TAB3: crate::tcflag_t = 0x00001800; +pub const CR1: crate::tcflag_t = 0x00000200; +pub const CR2: crate::tcflag_t = 0x00000400; +pub const CR3: crate::tcflag_t = 0x00000600; +pub const FF1: crate::tcflag_t = 0x00008000; +pub const BS1: crate::tcflag_t = 0x00002000; +pub const VT1: crate::tcflag_t = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: crate::tcflag_t = 0x00000400; +pub const IXOFF: crate::tcflag_t = 0x00001000; +pub const ONLCR: crate::tcflag_t = 0x4; +pub const CSIZE: crate::tcflag_t = 0x00000030; +pub const CS6: crate::tcflag_t = 0x00000010; +pub const CS7: crate::tcflag_t = 0x00000020; +pub const CS8: crate::tcflag_t = 0x00000030; +pub const CSTOPB: crate::tcflag_t = 0x00000040; +pub const CREAD: crate::tcflag_t = 0x00000080; +pub const PARENB: crate::tcflag_t = 0x00000100; +pub const PARODD: crate::tcflag_t = 0x00000200; +pub const HUPCL: crate::tcflag_t = 0x00000400; +pub const CLOCAL: crate::tcflag_t = 0x00000800; +pub const ECHOKE: crate::tcflag_t = 0x00000800; +pub const ECHOE: crate::tcflag_t = 0x00000010; +pub const ECHOK: crate::tcflag_t = 0x00000020; +pub const ECHONL: crate::tcflag_t = 0x00000040; +pub const ECHOPRT: crate::tcflag_t = 0x00000400; +pub const ECHOCTL: crate::tcflag_t = 0x00000200; +pub const ISIG: crate::tcflag_t = 0x00000001; +pub const ICANON: crate::tcflag_t = 0x00000002; +pub const PENDIN: crate::tcflag_t = 0x00004000; +pub const NOFLSH: crate::tcflag_t = 0x00000080; +pub const CIBAUD: crate::tcflag_t = 0o02003600000; +pub const CBAUDEX: crate::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: crate::tcflag_t = 0o000002; +pub const NLDLY: crate::tcflag_t = 0o000400; +pub const CRDLY: crate::tcflag_t = 0o003000; +pub const TABDLY: crate::tcflag_t = 0o014000; +pub const BSDLY: crate::tcflag_t = 0o020000; +pub const FFDLY: crate::tcflag_t = 0o100000; +pub const VTDLY: crate::tcflag_t = 0o040000; +pub const XTABS: crate::tcflag_t = 0o014000; + +pub const B0: crate::speed_t = 0o000000; +pub const B50: crate::speed_t = 0o000001; +pub const B75: crate::speed_t = 0o000002; +pub const B110: crate::speed_t = 0o000003; +pub const B134: crate::speed_t = 0o000004; +pub const B150: crate::speed_t = 0o000005; +pub const B200: crate::speed_t = 0o000006; +pub const B300: crate::speed_t = 0o000007; +pub const B600: crate::speed_t = 0o000010; +pub const B1200: crate::speed_t = 0o000011; +pub const B1800: crate::speed_t = 0o000012; +pub const B2400: crate::speed_t = 0o000013; +pub const B4800: crate::speed_t = 0o000014; +pub const B9600: crate::speed_t = 0o000015; +pub const B19200: crate::speed_t = 0o000016; +pub const B38400: crate::speed_t = 0o000017; +pub const EXTA: crate::speed_t = B19200; +pub const EXTB: crate::speed_t = B38400; +pub const B57600: crate::speed_t = 0o010001; +pub const B115200: crate::speed_t = 0o010002; +pub const B230400: crate::speed_t = 0o010003; +pub const B460800: crate::speed_t = 0o010004; +pub const B500000: crate::speed_t = 0o010005; +pub const B576000: crate::speed_t = 0o010006; +pub const B921600: crate::speed_t = 0o010007; +pub const B1000000: crate::speed_t = 0o010010; +pub const B1152000: crate::speed_t = 0o010011; +pub const B1500000: crate::speed_t = 0o010012; +pub const B2000000: crate::speed_t = 0o010013; +pub const B2500000: crate::speed_t = 0o010014; +pub const B3000000: crate::speed_t = 0o010015; +pub const B3500000: crate::speed_t = 0o010016; +pub const B4000000: crate::speed_t = 0o010017; + +pub const EHWPOISON: c_int = 168; + +extern "C" { + pub fn sysctl( + name: *mut c_int, + namelen: c_int, + oldp: *mut c_void, + oldlenp: *mut size_t, + newp: *mut c_void, + newlen: size_t, + ) -> c_int; +} diff --git a/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/mod.rs new file mode 100644 index 0000000..3d442a6 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/mod.rs @@ -0,0 +1,213 @@ +//! 64-bit specific definitions for linux-like values + +use crate::prelude::*; + +pub type ino_t = u64; +pub type off_t = i64; +pub type blkcnt_t = i64; +pub type shmatt_t = u64; +pub type msgqnum_t = u64; +pub type msglen_t = u64; +pub type fsblkcnt_t = u64; +pub type fsfilcnt_t = u64; +pub type rlim_t = u64; +#[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] +pub type __syscall_ulong_t = c_ulonglong; +#[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] +pub type __syscall_ulong_t = c_ulong; + +cfg_if! { + if #[cfg(all(target_arch = "aarch64", target_pointer_width = "32"))] { + pub type clock_t = i32; + pub type time_t = i32; + pub type __fsword_t = i32; + } else { + pub type __fsword_t = i64; + pub type clock_t = i64; + pub type time_t = i64; + } +} + +s! { + pub struct sigset_t { + #[cfg(target_pointer_width = "32")] + __val: [u32; 32], + #[cfg(target_pointer_width = "64")] + __val: [u64; 16], + } + + pub struct sysinfo { + pub uptime: i64, + pub loads: [u64; 3], + pub totalram: u64, + pub freeram: u64, + pub sharedram: u64, + pub bufferram: u64, + pub totalswap: u64, + pub freeswap: u64, + pub procs: c_ushort, + pub pad: c_ushort, + pub totalhigh: u64, + pub freehigh: u64, + pub mem_unit: c_uint, + pub _f: [c_char; 0], + } + + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + pub msg_stime: crate::time_t, + pub msg_rtime: crate::time_t, + pub msg_ctime: crate::time_t, + pub __msg_cbytes: u64, + pub msg_qnum: crate::msgqnum_t, + pub msg_qbytes: crate::msglen_t, + pub msg_lspid: crate::pid_t, + pub msg_lrpid: crate::pid_t, + __glibc_reserved4: Padding, + __glibc_reserved5: Padding, + } + + pub struct semid_ds { + pub sem_perm: ipc_perm, + pub sem_otime: crate::time_t, + #[cfg(not(any( + target_arch = "aarch64", + target_arch = "loongarch64", + target_arch = "mips64", + target_arch = "mips64r6", + target_arch = "powerpc64", + target_arch = "riscv64", + target_arch = "sparc64", + target_arch = "s390x", + )))] + __reserved: Padding, + pub sem_ctime: crate::time_t, + #[cfg(not(any( + target_arch = "aarch64", + target_arch = "loongarch64", + target_arch = "mips64", + target_arch = "mips64r6", + target_arch = "powerpc64", + target_arch = "riscv64", + target_arch = "sparc64", + target_arch = "s390x", + )))] + __reserved2: Padding, + pub sem_nsems: crate::__syscall_ulong_t, + __glibc_reserved3: Padding, + __glibc_reserved4: Padding, + } + + pub struct timex { + pub modes: c_uint, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub offset: i64, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub offset: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub freq: i64, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub freq: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub maxerror: i64, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub maxerror: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub esterror: i64, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub esterror: c_long, + pub status: c_int, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub constant: i64, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub constant: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub precision: i64, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub precision: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub tolerance: i64, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub tolerance: c_long, + pub time: crate::timeval, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub tick: i64, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub tick: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub ppsfreq: i64, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub ppsfreq: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub jitter: i64, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub jitter: c_long, + pub shift: c_int, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub stabil: i64, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub stabil: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub jitcnt: i64, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub jitcnt: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub calcnt: i64, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub calcnt: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub errcnt: i64, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub errcnt: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub stbcnt: i64, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub stbcnt: c_long, + pub tai: c_int, + pub __unused1: i32, + pub __unused2: i32, + pub __unused3: i32, + pub __unused4: i32, + pub __unused5: i32, + pub __unused6: i32, + pub __unused7: i32, + pub __unused8: i32, + pub __unused9: i32, + pub __unused10: i32, + pub __unused11: i32, + } +} + +pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; + +pub const O_LARGEFILE: c_int = 0; + +cfg_if! { + if #[cfg(target_arch = "aarch64")] { + mod aarch64; + pub use self::aarch64::*; + } else if #[cfg(any(target_arch = "powerpc64"))] { + mod powerpc64; + pub use self::powerpc64::*; + } else if #[cfg(any(target_arch = "sparc64"))] { + mod sparc64; + pub use self::sparc64::*; + } else if #[cfg(any(target_arch = "mips64", target_arch = "mips64r6"))] { + mod mips64; + pub use self::mips64::*; + } else if #[cfg(any(target_arch = "s390x"))] { + mod s390x; + pub use self::s390x::*; + } else if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } else if #[cfg(any(target_arch = "riscv64"))] { + mod riscv64; + pub use self::riscv64::*; + } else if #[cfg(any(target_arch = "loongarch64"))] { + mod loongarch64; + pub use self::loongarch64::*; + } else { + // Unknown target_arch + } +} diff --git a/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs new file mode 100644 index 0000000..ee2cd21 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs @@ -0,0 +1,1062 @@ +//! PowerPC64-specific definitions for 64-bit linux-like values + +use crate::prelude::*; +use crate::{ + off64_t, + off_t, + pthread_mutex_t, +}; + +pub type wchar_t = i32; +pub type nlink_t = u64; +pub type blksize_t = i64; +pub type suseconds_t = i64; +pub type __u64 = c_ulong; +pub type __s64 = c_long; +pub type gregset_t = [c_ulong; __NGREG]; +pub type fpregset_t = [c_ulong; __NFPREG]; + +s! { + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigaction { + pub sa_sigaction: crate::sighandler_t, + pub sa_mask: crate::sigset_t, + #[cfg(target_arch = "sparc64")] + __reserved0: Padding, + pub sa_flags: c_int, + pub sa_restorer: Option, + } + + pub struct statfs { + pub f_type: crate::__fsword_t, + pub f_bsize: crate::__fsword_t, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_fsid: crate::fsid_t, + + pub f_namelen: crate::__fsword_t, + pub f_frsize: crate::__fsword_t, + f_spare: [crate::__fsword_t; 5], + } + + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off_t, + pub l_len: off_t, + pub l_pid: crate::pid_t, + } + + pub struct flock64 { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off64_t, + pub l_len: off64_t, + pub l_pid: crate::pid_t, + } + + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_nlink: crate::nlink_t, + pub st_mode: crate::mode_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + __pad0: Padding, + pub st_rdev: crate::dev_t, + pub st_size: off_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + __unused: Padding<[c_long; 3]>, + } + + pub struct stat64 { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino64_t, + pub st_nlink: crate::nlink_t, + pub st_mode: crate::mode_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + __pad0: Padding, + pub st_rdev: crate::dev_t, + pub st_size: off64_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt64_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + __reserved: Padding<[c_long; 3]>, + } + + pub struct statfs64 { + pub f_type: crate::__fsword_t, + pub f_bsize: crate::__fsword_t, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_fsid: crate::fsid_t, + pub f_namelen: crate::__fsword_t, + pub f_frsize: crate::__fsword_t, + pub f_flags: crate::__fsword_t, + pub f_spare: [crate::__fsword_t; 4], + } + + pub struct statvfs { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_favail: crate::fsfilcnt_t, + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: [c_int; 6], + } + + pub struct statvfs64 { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: [c_int; 6], + } + + pub struct pthread_attr_t { + __size: [u64; 7], + } + + pub struct ipc_perm { + pub __key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: crate::mode_t, + pub __seq: u32, + __pad1: Padding, + __unused1: Padding, + __unused2: Padding, + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_atime: crate::time_t, + pub shm_dtime: crate::time_t, + pub shm_ctime: crate::time_t, + pub shm_segsz: size_t, + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: crate::shmatt_t, + __unused4: Padding, + __unused5: Padding, + } + + pub struct siginfo_t { + pub si_signo: c_int, + pub si_errno: c_int, + pub si_code: c_int, + #[doc(hidden)] + #[deprecated( + since = "0.2.54", + note = "Please leave a comment on \ + https://github.com/rust-lang/libc/pull/1316 if you're using \ + this field" + )] + pub _pad: [c_int; 29], + _align: [usize; 0], + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_flags: c_int, + pub ss_size: size_t, + } + + #[repr(align(8))] + pub struct clone_args { + pub flags: c_ulonglong, + pub pidfd: c_ulonglong, + pub child_tid: c_ulonglong, + pub parent_tid: c_ulonglong, + pub exit_signal: c_ulonglong, + pub stack: c_ulonglong, + pub stack_size: c_ulonglong, + pub tls: c_ulonglong, + pub set_tid: c_ulonglong, + pub set_tid_size: c_ulonglong, + pub cgroup: c_ulonglong, + } +} + +s_no_extra_traits! { + #[repr(align(16))] + pub struct max_align_t { + priv_: [i64; 4], + } + + pub struct ucontext_t { + pub uc_flags: c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: crate::stack_t, + pub uc_sigmask: crate::sigset_t, + pub uc_mcontext: mcontext_t, + } + + pub struct pt_regs { + pub gpr: [c_ulong; 32], + pub nip: c_ulong, + pub msr: c_ulong, + pub orig_gpr3: c_ulong, + pub ctr: c_ulong, + pub link: c_ulong, + pub xer: c_ulong, + pub ccr: c_ulong, + pub softe: c_ulong, + pub trap: c_ulong, + pub dar: c_ulong, + pub dsisr: c_ulong, + pub result: c_ulong, + } + + pub struct mcontext_t { + __glibc_reserved: Padding<[c_ulong; 4]>, + pub signal: c_int, + __pad0: Padding, + pub handler: c_ulong, + pub oldmask: c_ulong, + pub regs: *mut pt_regs, + pub gp_regs: crate::gregset_t, + pub fp_regs: crate::fpregset_t, + pub v_regs: *mut vrregset_t, + pub vmx_reserve: [c_long; __NVRREG + __NVRREG + 1], + } + + #[repr(align(16))] + pub struct vrregset_t { + pub vrregs: [[c_uint; 4]; 32], + pub vscr: vscr_t, + pub vrsave: c_uint, + __pad: Padding<[c_uint; 3]>, + } + + #[repr(align(4))] + pub struct vscr_t { + #[cfg(target_endian = "big")] + __pad: Padding<[c_uint; 3]>, + #[cfg(target_endian = "big")] + pub vscr_word: c_uint, + + #[cfg(target_endian = "little")] + pub vscr_word: c_uint, + #[cfg(target_endian = "little")] + __pad: Padding<[c_uint; 3]>, + } +} + +pub const POSIX_FADV_DONTNEED: c_int = 4; +pub const POSIX_FADV_NOREUSE: c_int = 5; + +pub const RTLD_DEEPBIND: c_int = 0x8; +pub const RTLD_GLOBAL: c_int = 0x100; +pub const RTLD_NOLOAD: c_int = 0x4; +pub const VEOF: usize = 4; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; +pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; + +pub const __NGREG: usize = 48; +pub const __NFPREG: usize = 33; +pub const __NVRREG: usize = 34; + +pub const O_APPEND: c_int = 1024; +pub const O_CREAT: c_int = 64; +pub const O_EXCL: c_int = 128; +pub const O_NOCTTY: c_int = 256; +pub const O_NONBLOCK: c_int = 2048; +pub const O_SYNC: c_int = 1052672; +pub const O_RSYNC: c_int = 1052672; +pub const O_DSYNC: c_int = 4096; +pub const O_FSYNC: c_int = 0x101000; +pub const O_NOATIME: c_int = 0o1000000; +pub const O_PATH: c_int = 0o10000000; +pub const O_TMPFILE: c_int = 0o20000000 | O_DIRECTORY; + +pub const MADV_SOFT_OFFLINE: c_int = 101; +pub const MAP_GROWSDOWN: c_int = 0x0100; +pub const MAP_ANON: c_int = 0x0020; +pub const MAP_ANONYMOUS: c_int = 0x0020; +pub const MAP_DENYWRITE: c_int = 0x0800; +pub const MAP_EXECUTABLE: c_int = 0x01000; +pub const MAP_POPULATE: c_int = 0x08000; +pub const MAP_NONBLOCK: c_int = 0x010000; +pub const MAP_STACK: c_int = 0x020000; +pub const MAP_HUGETLB: c_int = 0x040000; + +pub const EDEADLK: c_int = 35; +pub const ENAMETOOLONG: c_int = 36; +pub const ENOLCK: c_int = 37; +pub const ENOSYS: c_int = 38; +pub const ENOTEMPTY: c_int = 39; +pub const ELOOP: c_int = 40; +pub const ENOMSG: c_int = 42; +pub const EIDRM: c_int = 43; +pub const ECHRNG: c_int = 44; +pub const EL2NSYNC: c_int = 45; +pub const EL3HLT: c_int = 46; +pub const EL3RST: c_int = 47; +pub const ELNRNG: c_int = 48; +pub const EUNATCH: c_int = 49; +pub const ENOCSI: c_int = 50; +pub const EL2HLT: c_int = 51; +pub const EBADE: c_int = 52; +pub const EBADR: c_int = 53; +pub const EXFULL: c_int = 54; +pub const ENOANO: c_int = 55; +pub const EBADRQC: c_int = 56; +pub const EBADSLT: c_int = 57; +pub const EMULTIHOP: c_int = 72; +pub const EOVERFLOW: c_int = 75; +pub const ENOTUNIQ: c_int = 76; +pub const EBADFD: c_int = 77; +pub const EBADMSG: c_int = 74; +pub const EREMCHG: c_int = 78; +pub const ELIBACC: c_int = 79; +pub const ELIBBAD: c_int = 80; +pub const ELIBSCN: c_int = 81; +pub const ELIBMAX: c_int = 82; +pub const ELIBEXEC: c_int = 83; +pub const EILSEQ: c_int = 84; +pub const ERESTART: c_int = 85; +pub const ESTRPIPE: c_int = 86; +pub const EUSERS: c_int = 87; +pub const ENOTSOCK: c_int = 88; +pub const EDESTADDRREQ: c_int = 89; +pub const EMSGSIZE: c_int = 90; +pub const EPROTOTYPE: c_int = 91; +pub const ENOPROTOOPT: c_int = 92; +pub const EPROTONOSUPPORT: c_int = 93; +pub const ESOCKTNOSUPPORT: c_int = 94; +pub const EOPNOTSUPP: c_int = 95; +pub const EPFNOSUPPORT: c_int = 96; +pub const EAFNOSUPPORT: c_int = 97; +pub const EADDRINUSE: c_int = 98; +pub const EADDRNOTAVAIL: c_int = 99; +pub const ENETDOWN: c_int = 100; +pub const ENETUNREACH: c_int = 101; +pub const ENETRESET: c_int = 102; +pub const ECONNABORTED: c_int = 103; +pub const ECONNRESET: c_int = 104; +pub const ENOBUFS: c_int = 105; +pub const EISCONN: c_int = 106; +pub const ENOTCONN: c_int = 107; +pub const ESHUTDOWN: c_int = 108; +pub const ETOOMANYREFS: c_int = 109; +pub const ETIMEDOUT: c_int = 110; +pub const ECONNREFUSED: c_int = 111; +pub const EHOSTDOWN: c_int = 112; +pub const EHOSTUNREACH: c_int = 113; +pub const EALREADY: c_int = 114; +pub const EINPROGRESS: c_int = 115; +pub const ESTALE: c_int = 116; +pub const EDQUOT: c_int = 122; +pub const ENOMEDIUM: c_int = 123; +pub const EMEDIUMTYPE: c_int = 124; +pub const ECANCELED: c_int = 125; +pub const ENOKEY: c_int = 126; +pub const EKEYEXPIRED: c_int = 127; +pub const EKEYREVOKED: c_int = 128; +pub const EKEYREJECTED: c_int = 129; +pub const EOWNERDEAD: c_int = 130; +pub const ENOTRECOVERABLE: c_int = 131; +pub const EHWPOISON: c_int = 133; +pub const ERFKILL: c_int = 132; + +pub const SOCK_STREAM: c_int = 1; +pub const SOCK_DGRAM: c_int = 2; + +pub const SA_ONSTACK: c_int = 0x08000000; +pub const SA_SIGINFO: c_int = 0x00000004; +pub const SA_NOCLDWAIT: c_int = 0x00000002; + +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGCHLD: c_int = 17; +pub const SIGBUS: c_int = 7; +pub const SIGUSR1: c_int = 10; +pub const SIGUSR2: c_int = 12; +pub const SIGCONT: c_int = 18; +pub const SIGSTOP: c_int = 19; +pub const SIGTSTP: c_int = 20; +pub const SIGURG: c_int = 23; +pub const SIGIO: c_int = 29; +pub const SIGSYS: c_int = 31; +pub const SIGSTKFLT: c_int = 16; +#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] +pub const SIGUNUSED: c_int = 31; +pub const SIGPOLL: c_int = 29; +pub const SIGPWR: c_int = 30; +pub const SIG_SETMASK: c_int = 2; +pub const SIG_BLOCK: c_int = 0x000000; +pub const SIG_UNBLOCK: c_int = 0x01; + +pub const POLLWRNORM: c_short = 0x100; +pub const POLLWRBAND: c_short = 0x200; + +pub const O_ASYNC: c_int = 0x2000; +pub const O_NDELAY: c_int = 0x800; + +pub const PTRACE_DETACH: c_uint = 17; + +pub const EFD_NONBLOCK: c_int = 0x800; + +pub const F_GETLK: c_int = 5; +pub const F_GETOWN: c_int = 9; +pub const F_SETOWN: c_int = 8; +pub const F_SETLK: c_int = 6; +pub const F_SETLKW: c_int = 7; +pub const F_OFD_GETLK: c_int = 36; +pub const F_OFD_SETLK: c_int = 37; +pub const F_OFD_SETLKW: c_int = 38; + +pub const F_RDLCK: c_int = 0; +pub const F_WRLCK: c_int = 1; +pub const F_UNLCK: c_int = 2; + +pub const SFD_NONBLOCK: c_int = 0x0800; + +pub const TCSANOW: c_int = 0; +pub const TCSADRAIN: c_int = 1; +pub const TCSAFLUSH: c_int = 2; + +pub const SFD_CLOEXEC: c_int = 0x080000; + +pub const NCCS: usize = 32; + +pub const O_TRUNC: c_int = 512; + +pub const O_CLOEXEC: c_int = 0x80000; + +pub const EBFONT: c_int = 59; +pub const ENOSTR: c_int = 60; +pub const ENODATA: c_int = 61; +pub const ETIME: c_int = 62; +pub const ENOSR: c_int = 63; +pub const ENONET: c_int = 64; +pub const ENOPKG: c_int = 65; +pub const EREMOTE: c_int = 66; +pub const ENOLINK: c_int = 67; +pub const EADV: c_int = 68; +pub const ESRMNT: c_int = 69; +pub const ECOMM: c_int = 70; +pub const EPROTO: c_int = 71; +pub const EDOTDOT: c_int = 73; + +pub const SA_NODEFER: c_int = 0x40000000; +pub const SA_RESETHAND: c_int = 0x80000000; +pub const SA_RESTART: c_int = 0x10000000; +pub const SA_NOCLDSTOP: c_int = 0x00000001; + +pub const EPOLL_CLOEXEC: c_int = 0x80000; + +pub const EFD_CLOEXEC: c_int = 0x80000; + +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; + +#[cfg(target_endian = "little")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; + +pub const O_DIRECTORY: c_int = 0x4000; +pub const O_NOFOLLOW: c_int = 0x8000; +pub const O_DIRECT: c_int = 0x20000; + +pub const MAP_LOCKED: c_int = 0x00080; +pub const MAP_NORESERVE: c_int = 0x00040; +pub const MAP_SYNC: c_int = 0x080000; + +pub const EDEADLOCK: c_int = 58; +pub const EUCLEAN: c_int = 117; +pub const ENOTNAM: c_int = 118; +pub const ENAVAIL: c_int = 119; +pub const EISNAM: c_int = 120; +pub const EREMOTEIO: c_int = 121; + +pub const MCL_CURRENT: c_int = 0x2000; +pub const MCL_FUTURE: c_int = 0x4000; +pub const MCL_ONFAULT: c_int = 0x8000; + +pub const SIGSTKSZ: size_t = 0x4000; +pub const MINSIGSTKSZ: size_t = 4096; +pub const CBAUD: crate::tcflag_t = 0xff; +pub const TAB1: crate::tcflag_t = 0x400; +pub const TAB2: crate::tcflag_t = 0x800; +pub const TAB3: crate::tcflag_t = 0xc00; +pub const CR1: crate::tcflag_t = 0x1000; +pub const CR2: crate::tcflag_t = 0x2000; +pub const CR3: crate::tcflag_t = 0x3000; +pub const FF1: crate::tcflag_t = 0x4000; +pub const BS1: crate::tcflag_t = 0x8000; +pub const VT1: crate::tcflag_t = 0x10000; +pub const VWERASE: usize = 0xa; +pub const VREPRINT: usize = 0xb; +pub const VSUSP: usize = 0xc; +pub const VSTART: usize = 0xd; +pub const VSTOP: usize = 0xe; +pub const VDISCARD: usize = 0x10; +pub const VTIME: usize = 0x7; +pub const IXON: crate::tcflag_t = 0x200; +pub const IXOFF: crate::tcflag_t = 0x400; +pub const ONLCR: crate::tcflag_t = 0x2; +pub const CSIZE: crate::tcflag_t = 0x300; +pub const CS6: crate::tcflag_t = 0x100; +pub const CS7: crate::tcflag_t = 0x200; +pub const CS8: crate::tcflag_t = 0x300; +pub const CSTOPB: crate::tcflag_t = 0x400; +pub const CREAD: crate::tcflag_t = 0x800; +pub const PARENB: crate::tcflag_t = 0x1000; +pub const PARODD: crate::tcflag_t = 0x2000; +pub const HUPCL: crate::tcflag_t = 0x4000; +pub const CLOCAL: crate::tcflag_t = 0x8000; +pub const ECHOKE: crate::tcflag_t = 0x1; +pub const ECHOE: crate::tcflag_t = 0x2; +pub const ECHOK: crate::tcflag_t = 0x4; +pub const ECHONL: crate::tcflag_t = 0x10; +pub const ECHOPRT: crate::tcflag_t = 0x20; +pub const ECHOCTL: crate::tcflag_t = 0x40; +pub const ISIG: crate::tcflag_t = 0x80; +pub const ICANON: crate::tcflag_t = 0x100; +pub const PENDIN: crate::tcflag_t = 0x20000000; +pub const NOFLSH: crate::tcflag_t = 0x80000000; +pub const VSWTC: usize = 9; +pub const OLCUC: crate::tcflag_t = 0o000004; +pub const NLDLY: crate::tcflag_t = 0o001400; +pub const CRDLY: crate::tcflag_t = 0o030000; +pub const TABDLY: crate::tcflag_t = 0o006000; +pub const BSDLY: crate::tcflag_t = 0o100000; +pub const FFDLY: crate::tcflag_t = 0o040000; +pub const VTDLY: crate::tcflag_t = 0o200000; +pub const XTABS: crate::tcflag_t = 0o006000; + +pub const B0: crate::speed_t = 0o000000; +pub const B50: crate::speed_t = 0o000001; +pub const B75: crate::speed_t = 0o000002; +pub const B110: crate::speed_t = 0o000003; +pub const B134: crate::speed_t = 0o000004; +pub const B150: crate::speed_t = 0o000005; +pub const B200: crate::speed_t = 0o000006; +pub const B300: crate::speed_t = 0o000007; +pub const B600: crate::speed_t = 0o000010; +pub const B1200: crate::speed_t = 0o000011; +pub const B1800: crate::speed_t = 0o000012; +pub const B2400: crate::speed_t = 0o000013; +pub const B4800: crate::speed_t = 0o000014; +pub const B9600: crate::speed_t = 0o000015; +pub const B19200: crate::speed_t = 0o000016; +pub const B38400: crate::speed_t = 0o000017; +pub const EXTA: crate::speed_t = B19200; +pub const EXTB: crate::speed_t = B38400; +pub const CBAUDEX: crate::speed_t = 0o000020; +pub const B57600: crate::speed_t = 0o0020; +pub const B115200: crate::speed_t = 0o0021; +pub const B230400: crate::speed_t = 0o0022; +pub const B460800: crate::speed_t = 0o0023; +pub const B500000: crate::speed_t = 0o0024; +pub const B576000: crate::speed_t = 0o0025; +pub const B921600: crate::speed_t = 0o0026; +pub const B1000000: crate::speed_t = 0o0027; +pub const B1152000: crate::speed_t = 0o0030; +pub const B1500000: crate::speed_t = 0o0031; +pub const B2000000: crate::speed_t = 0o0032; +pub const B2500000: crate::speed_t = 0o0033; +pub const B3000000: crate::speed_t = 0o0034; +pub const B3500000: crate::speed_t = 0o0035; +pub const B4000000: crate::speed_t = 0o0036; + +pub const VEOL: usize = 6; +pub const VEOL2: usize = 8; +pub const VMIN: usize = 5; +pub const IEXTEN: crate::tcflag_t = 0x400; +pub const TOSTOP: crate::tcflag_t = 0x400000; +pub const FLUSHO: crate::tcflag_t = 0x800000; +pub const EXTPROC: crate::tcflag_t = 0x10000000; + +// Syscall table +pub const SYS_restart_syscall: c_long = 0; +pub const SYS_exit: c_long = 1; +pub const SYS_fork: c_long = 2; +pub const SYS_read: c_long = 3; +pub const SYS_write: c_long = 4; +pub const SYS_open: c_long = 5; +pub const SYS_close: c_long = 6; +pub const SYS_waitpid: c_long = 7; +pub const SYS_creat: c_long = 8; +pub const SYS_link: c_long = 9; +pub const SYS_unlink: c_long = 10; +pub const SYS_execve: c_long = 11; +pub const SYS_chdir: c_long = 12; +pub const SYS_time: c_long = 13; +pub const SYS_mknod: c_long = 14; +pub const SYS_chmod: c_long = 15; +pub const SYS_lchown: c_long = 16; +pub const SYS_break: c_long = 17; +pub const SYS_oldstat: c_long = 18; +pub const SYS_lseek: c_long = 19; +pub const SYS_getpid: c_long = 20; +pub const SYS_mount: c_long = 21; +pub const SYS_umount: c_long = 22; +pub const SYS_setuid: c_long = 23; +pub const SYS_getuid: c_long = 24; +pub const SYS_stime: c_long = 25; +pub const SYS_ptrace: c_long = 26; +pub const SYS_alarm: c_long = 27; +pub const SYS_oldfstat: c_long = 28; +pub const SYS_pause: c_long = 29; +pub const SYS_utime: c_long = 30; +pub const SYS_stty: c_long = 31; +pub const SYS_gtty: c_long = 32; +pub const SYS_access: c_long = 33; +pub const SYS_nice: c_long = 34; +pub const SYS_ftime: c_long = 35; +pub const SYS_sync: c_long = 36; +pub const SYS_kill: c_long = 37; +pub const SYS_rename: c_long = 38; +pub const SYS_mkdir: c_long = 39; +pub const SYS_rmdir: c_long = 40; +pub const SYS_dup: c_long = 41; +pub const SYS_pipe: c_long = 42; +pub const SYS_times: c_long = 43; +pub const SYS_prof: c_long = 44; +pub const SYS_brk: c_long = 45; +pub const SYS_setgid: c_long = 46; +pub const SYS_getgid: c_long = 47; +pub const SYS_signal: c_long = 48; +pub const SYS_geteuid: c_long = 49; +pub const SYS_getegid: c_long = 50; +pub const SYS_acct: c_long = 51; +pub const SYS_umount2: c_long = 52; +pub const SYS_lock: c_long = 53; +pub const SYS_ioctl: c_long = 54; +pub const SYS_fcntl: c_long = 55; +pub const SYS_mpx: c_long = 56; +pub const SYS_setpgid: c_long = 57; +pub const SYS_ulimit: c_long = 58; +pub const SYS_oldolduname: c_long = 59; +pub const SYS_umask: c_long = 60; +pub const SYS_chroot: c_long = 61; +pub const SYS_ustat: c_long = 62; +pub const SYS_dup2: c_long = 63; +pub const SYS_getppid: c_long = 64; +pub const SYS_getpgrp: c_long = 65; +pub const SYS_setsid: c_long = 66; +pub const SYS_sigaction: c_long = 67; +pub const SYS_sgetmask: c_long = 68; +pub const SYS_ssetmask: c_long = 69; +pub const SYS_setreuid: c_long = 70; +pub const SYS_setregid: c_long = 71; +pub const SYS_sigsuspend: c_long = 72; +pub const SYS_sigpending: c_long = 73; +pub const SYS_sethostname: c_long = 74; +pub const SYS_setrlimit: c_long = 75; +pub const SYS_getrlimit: c_long = 76; +pub const SYS_getrusage: c_long = 77; +pub const SYS_gettimeofday: c_long = 78; +pub const SYS_settimeofday: c_long = 79; +pub const SYS_getgroups: c_long = 80; +pub const SYS_setgroups: c_long = 81; +pub const SYS_select: c_long = 82; +pub const SYS_symlink: c_long = 83; +pub const SYS_oldlstat: c_long = 84; +pub const SYS_readlink: c_long = 85; +pub const SYS_uselib: c_long = 86; +pub const SYS_swapon: c_long = 87; +pub const SYS_reboot: c_long = 88; +pub const SYS_readdir: c_long = 89; +pub const SYS_mmap: c_long = 90; +pub const SYS_munmap: c_long = 91; +pub const SYS_truncate: c_long = 92; +pub const SYS_ftruncate: c_long = 93; +pub const SYS_fchmod: c_long = 94; +pub const SYS_fchown: c_long = 95; +pub const SYS_getpriority: c_long = 96; +pub const SYS_setpriority: c_long = 97; +pub const SYS_profil: c_long = 98; +pub const SYS_statfs: c_long = 99; +pub const SYS_fstatfs: c_long = 100; +pub const SYS_ioperm: c_long = 101; +pub const SYS_socketcall: c_long = 102; +pub const SYS_syslog: c_long = 103; +pub const SYS_setitimer: c_long = 104; +pub const SYS_getitimer: c_long = 105; +pub const SYS_stat: c_long = 106; +pub const SYS_lstat: c_long = 107; +pub const SYS_fstat: c_long = 108; +pub const SYS_olduname: c_long = 109; +pub const SYS_iopl: c_long = 110; +pub const SYS_vhangup: c_long = 111; +pub const SYS_idle: c_long = 112; +pub const SYS_vm86: c_long = 113; +pub const SYS_wait4: c_long = 114; +pub const SYS_swapoff: c_long = 115; +pub const SYS_sysinfo: c_long = 116; +pub const SYS_ipc: c_long = 117; +pub const SYS_fsync: c_long = 118; +pub const SYS_sigreturn: c_long = 119; +pub const SYS_clone: c_long = 120; +pub const SYS_setdomainname: c_long = 121; +pub const SYS_uname: c_long = 122; +pub const SYS_modify_ldt: c_long = 123; +pub const SYS_adjtimex: c_long = 124; +pub const SYS_mprotect: c_long = 125; +pub const SYS_sigprocmask: c_long = 126; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_create_module: c_long = 127; +pub const SYS_init_module: c_long = 128; +pub const SYS_delete_module: c_long = 129; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_get_kernel_syms: c_long = 130; +pub const SYS_quotactl: c_long = 131; +pub const SYS_getpgid: c_long = 132; +pub const SYS_fchdir: c_long = 133; +pub const SYS_bdflush: c_long = 134; +pub const SYS_sysfs: c_long = 135; +pub const SYS_personality: c_long = 136; +pub const SYS_afs_syscall: c_long = 137; /* Syscall for Andrew File System */ +pub const SYS_setfsuid: c_long = 138; +pub const SYS_setfsgid: c_long = 139; +pub const SYS__llseek: c_long = 140; +pub const SYS_getdents: c_long = 141; +pub const SYS__newselect: c_long = 142; +pub const SYS_flock: c_long = 143; +pub const SYS_msync: c_long = 144; +pub const SYS_readv: c_long = 145; +pub const SYS_writev: c_long = 146; +pub const SYS_getsid: c_long = 147; +pub const SYS_fdatasync: c_long = 148; +pub const SYS__sysctl: c_long = 149; +pub const SYS_mlock: c_long = 150; +pub const SYS_munlock: c_long = 151; +pub const SYS_mlockall: c_long = 152; +pub const SYS_munlockall: c_long = 153; +pub const SYS_sched_setparam: c_long = 154; +pub const SYS_sched_getparam: c_long = 155; +pub const SYS_sched_setscheduler: c_long = 156; +pub const SYS_sched_getscheduler: c_long = 157; +pub const SYS_sched_yield: c_long = 158; +pub const SYS_sched_get_priority_max: c_long = 159; +pub const SYS_sched_get_priority_min: c_long = 160; +pub const SYS_sched_rr_get_interval: c_long = 161; +pub const SYS_nanosleep: c_long = 162; +pub const SYS_mremap: c_long = 163; +pub const SYS_setresuid: c_long = 164; +pub const SYS_getresuid: c_long = 165; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_query_module: c_long = 166; +pub const SYS_poll: c_long = 167; +pub const SYS_nfsservctl: c_long = 168; +pub const SYS_setresgid: c_long = 169; +pub const SYS_getresgid: c_long = 170; +pub const SYS_prctl: c_long = 171; +pub const SYS_rt_sigreturn: c_long = 172; +pub const SYS_rt_sigaction: c_long = 173; +pub const SYS_rt_sigprocmask: c_long = 174; +pub const SYS_rt_sigpending: c_long = 175; +pub const SYS_rt_sigtimedwait: c_long = 176; +pub const SYS_rt_sigqueueinfo: c_long = 177; +pub const SYS_rt_sigsuspend: c_long = 178; +pub const SYS_pread64: c_long = 179; +pub const SYS_pwrite64: c_long = 180; +pub const SYS_chown: c_long = 181; +pub const SYS_getcwd: c_long = 182; +pub const SYS_capget: c_long = 183; +pub const SYS_capset: c_long = 184; +pub const SYS_sigaltstack: c_long = 185; +pub const SYS_sendfile: c_long = 186; +pub const SYS_getpmsg: c_long = 187; /* some people actually want streams */ +pub const SYS_putpmsg: c_long = 188; /* some people actually want streams */ +pub const SYS_vfork: c_long = 189; +pub const SYS_ugetrlimit: c_long = 190; /* SuS compliant getrlimit */ +pub const SYS_readahead: c_long = 191; +pub const SYS_pciconfig_read: c_long = 198; +pub const SYS_pciconfig_write: c_long = 199; +pub const SYS_pciconfig_iobase: c_long = 200; +pub const SYS_multiplexer: c_long = 201; +pub const SYS_getdents64: c_long = 202; +pub const SYS_pivot_root: c_long = 203; +pub const SYS_madvise: c_long = 205; +pub const SYS_mincore: c_long = 206; +pub const SYS_gettid: c_long = 207; +pub const SYS_tkill: c_long = 208; +pub const SYS_setxattr: c_long = 209; +pub const SYS_lsetxattr: c_long = 210; +pub const SYS_fsetxattr: c_long = 211; +pub const SYS_getxattr: c_long = 212; +pub const SYS_lgetxattr: c_long = 213; +pub const SYS_fgetxattr: c_long = 214; +pub const SYS_listxattr: c_long = 215; +pub const SYS_llistxattr: c_long = 216; +pub const SYS_flistxattr: c_long = 217; +pub const SYS_removexattr: c_long = 218; +pub const SYS_lremovexattr: c_long = 219; +pub const SYS_fremovexattr: c_long = 220; +pub const SYS_futex: c_long = 221; +pub const SYS_sched_setaffinity: c_long = 222; +pub const SYS_sched_getaffinity: c_long = 223; +pub const SYS_tuxcall: c_long = 225; +pub const SYS_io_setup: c_long = 227; +pub const SYS_io_destroy: c_long = 228; +pub const SYS_io_getevents: c_long = 229; +pub const SYS_io_submit: c_long = 230; +pub const SYS_io_cancel: c_long = 231; +pub const SYS_set_tid_address: c_long = 232; +pub const SYS_exit_group: c_long = 234; +pub const SYS_lookup_dcookie: c_long = 235; +pub const SYS_epoll_create: c_long = 236; +pub const SYS_epoll_ctl: c_long = 237; +pub const SYS_epoll_wait: c_long = 238; +pub const SYS_remap_file_pages: c_long = 239; +pub const SYS_timer_create: c_long = 240; +pub const SYS_timer_settime: c_long = 241; +pub const SYS_timer_gettime: c_long = 242; +pub const SYS_timer_getoverrun: c_long = 243; +pub const SYS_timer_delete: c_long = 244; +pub const SYS_clock_settime: c_long = 245; +pub const SYS_clock_gettime: c_long = 246; +pub const SYS_clock_getres: c_long = 247; +pub const SYS_clock_nanosleep: c_long = 248; +pub const SYS_swapcontext: c_long = 249; +pub const SYS_tgkill: c_long = 250; +pub const SYS_utimes: c_long = 251; +pub const SYS_statfs64: c_long = 252; +pub const SYS_fstatfs64: c_long = 253; +pub const SYS_rtas: c_long = 255; +pub const SYS_sys_debug_setcontext: c_long = 256; +pub const SYS_migrate_pages: c_long = 258; +pub const SYS_mbind: c_long = 259; +pub const SYS_get_mempolicy: c_long = 260; +pub const SYS_set_mempolicy: c_long = 261; +pub const SYS_mq_open: c_long = 262; +pub const SYS_mq_unlink: c_long = 263; +pub const SYS_mq_timedsend: c_long = 264; +pub const SYS_mq_timedreceive: c_long = 265; +pub const SYS_mq_notify: c_long = 266; +pub const SYS_mq_getsetattr: c_long = 267; +pub const SYS_kexec_load: c_long = 268; +pub const SYS_add_key: c_long = 269; +pub const SYS_request_key: c_long = 270; +pub const SYS_keyctl: c_long = 271; +pub const SYS_waitid: c_long = 272; +pub const SYS_ioprio_set: c_long = 273; +pub const SYS_ioprio_get: c_long = 274; +pub const SYS_inotify_init: c_long = 275; +pub const SYS_inotify_add_watch: c_long = 276; +pub const SYS_inotify_rm_watch: c_long = 277; +pub const SYS_spu_run: c_long = 278; +pub const SYS_spu_create: c_long = 279; +pub const SYS_pselect6: c_long = 280; +pub const SYS_ppoll: c_long = 281; +pub const SYS_unshare: c_long = 282; +pub const SYS_splice: c_long = 283; +pub const SYS_tee: c_long = 284; +pub const SYS_vmsplice: c_long = 285; +pub const SYS_openat: c_long = 286; +pub const SYS_mkdirat: c_long = 287; +pub const SYS_mknodat: c_long = 288; +pub const SYS_fchownat: c_long = 289; +pub const SYS_futimesat: c_long = 290; +pub const SYS_newfstatat: c_long = 291; +pub const SYS_unlinkat: c_long = 292; +pub const SYS_renameat: c_long = 293; +pub const SYS_linkat: c_long = 294; +pub const SYS_symlinkat: c_long = 295; +pub const SYS_readlinkat: c_long = 296; +pub const SYS_fchmodat: c_long = 297; +pub const SYS_faccessat: c_long = 298; +pub const SYS_get_robust_list: c_long = 299; +pub const SYS_set_robust_list: c_long = 300; +pub const SYS_move_pages: c_long = 301; +pub const SYS_getcpu: c_long = 302; +pub const SYS_epoll_pwait: c_long = 303; +pub const SYS_utimensat: c_long = 304; +pub const SYS_signalfd: c_long = 305; +pub const SYS_timerfd_create: c_long = 306; +pub const SYS_eventfd: c_long = 307; +pub const SYS_sync_file_range2: c_long = 308; +pub const SYS_fallocate: c_long = 309; +pub const SYS_subpage_prot: c_long = 310; +pub const SYS_timerfd_settime: c_long = 311; +pub const SYS_timerfd_gettime: c_long = 312; +pub const SYS_signalfd4: c_long = 313; +pub const SYS_eventfd2: c_long = 314; +pub const SYS_epoll_create1: c_long = 315; +pub const SYS_dup3: c_long = 316; +pub const SYS_pipe2: c_long = 317; +pub const SYS_inotify_init1: c_long = 318; +pub const SYS_perf_event_open: c_long = 319; +pub const SYS_preadv: c_long = 320; +pub const SYS_pwritev: c_long = 321; +pub const SYS_rt_tgsigqueueinfo: c_long = 322; +pub const SYS_fanotify_init: c_long = 323; +pub const SYS_fanotify_mark: c_long = 324; +pub const SYS_prlimit64: c_long = 325; +pub const SYS_socket: c_long = 326; +pub const SYS_bind: c_long = 327; +pub const SYS_connect: c_long = 328; +pub const SYS_listen: c_long = 329; +pub const SYS_accept: c_long = 330; +pub const SYS_getsockname: c_long = 331; +pub const SYS_getpeername: c_long = 332; +pub const SYS_socketpair: c_long = 333; +pub const SYS_send: c_long = 334; +pub const SYS_sendto: c_long = 335; +pub const SYS_recv: c_long = 336; +pub const SYS_recvfrom: c_long = 337; +pub const SYS_shutdown: c_long = 338; +pub const SYS_setsockopt: c_long = 339; +pub const SYS_getsockopt: c_long = 340; +pub const SYS_sendmsg: c_long = 341; +pub const SYS_recvmsg: c_long = 342; +pub const SYS_recvmmsg: c_long = 343; +pub const SYS_accept4: c_long = 344; +pub const SYS_name_to_handle_at: c_long = 345; +pub const SYS_open_by_handle_at: c_long = 346; +pub const SYS_clock_adjtime: c_long = 347; +pub const SYS_syncfs: c_long = 348; +pub const SYS_sendmmsg: c_long = 349; +pub const SYS_setns: c_long = 350; +pub const SYS_process_vm_readv: c_long = 351; +pub const SYS_process_vm_writev: c_long = 352; +pub const SYS_finit_module: c_long = 353; +pub const SYS_kcmp: c_long = 354; +pub const SYS_sched_setattr: c_long = 355; +pub const SYS_sched_getattr: c_long = 356; +pub const SYS_renameat2: c_long = 357; +pub const SYS_seccomp: c_long = 358; +pub const SYS_getrandom: c_long = 359; +pub const SYS_memfd_create: c_long = 360; +pub const SYS_bpf: c_long = 361; +pub const SYS_execveat: c_long = 362; +pub const SYS_switch_endian: c_long = 363; +pub const SYS_userfaultfd: c_long = 364; +pub const SYS_membarrier: c_long = 365; +pub const SYS_mlock2: c_long = 378; +pub const SYS_copy_file_range: c_long = 379; +pub const SYS_preadv2: c_long = 380; +pub const SYS_pwritev2: c_long = 381; +pub const SYS_kexec_file_load: c_long = 382; +pub const SYS_statx: c_long = 383; +pub const SYS_rseq: c_long = 387; +pub const SYS_pidfd_send_signal: c_long = 424; +pub const SYS_io_uring_setup: c_long = 425; +pub const SYS_io_uring_enter: c_long = 426; +pub const SYS_io_uring_register: c_long = 427; +pub const SYS_open_tree: c_long = 428; +pub const SYS_move_mount: c_long = 429; +pub const SYS_fsopen: c_long = 430; +pub const SYS_fsconfig: c_long = 431; +pub const SYS_fsmount: c_long = 432; +pub const SYS_fspick: c_long = 433; +pub const SYS_pidfd_open: c_long = 434; +pub const SYS_clone3: c_long = 435; +pub const SYS_close_range: c_long = 436; +pub const SYS_openat2: c_long = 437; +pub const SYS_pidfd_getfd: c_long = 438; +pub const SYS_faccessat2: c_long = 439; +pub const SYS_process_madvise: c_long = 440; +pub const SYS_epoll_pwait2: c_long = 441; +pub const SYS_mount_setattr: c_long = 442; +pub const SYS_quotactl_fd: c_long = 443; +pub const SYS_landlock_create_ruleset: c_long = 444; +pub const SYS_landlock_add_rule: c_long = 445; +pub const SYS_landlock_restrict_self: c_long = 446; +pub const SYS_memfd_secret: c_long = 447; +pub const SYS_process_mrelease: c_long = 448; +pub const SYS_futex_waitv: c_long = 449; +pub const SYS_set_mempolicy_home_node: c_long = 450; + +extern "C" { + pub fn sysctl( + name: *mut c_int, + namelen: c_int, + oldp: *mut c_void, + oldlenp: *mut size_t, + newp: *mut c_void, + newlen: size_t, + ) -> c_int; + + pub fn getcontext(ucp: *mut ucontext_t) -> c_int; + pub fn setcontext(ucp: *const ucontext_t) -> c_int; + pub fn swapcontext(oucp: *mut ucontext_t, ucp: *const ucontext_t) -> c_int; + pub fn makecontext(ucp: *mut ucontext_t, func: extern "C" fn(), argc: c_int, ...); +} diff --git a/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs new file mode 100644 index 0000000..cbb1502 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs @@ -0,0 +1,918 @@ +//! RISC-V-specific definitions for 64-bit linux-like values + +use crate::prelude::*; +use crate::{ + off64_t, + off_t, +}; + +pub type wchar_t = c_int; + +pub type nlink_t = c_uint; +pub type blksize_t = c_int; +pub type fsblkcnt64_t = c_ulong; +pub type fsfilcnt64_t = c_ulong; +pub type suseconds_t = i64; +pub type __u64 = c_ulonglong; +pub type __s64 = c_longlong; + +s! { + pub struct pthread_attr_t { + __size: [c_ulong; 7], + } + + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + pub __pad1: crate::dev_t, + pub st_size: off_t, + pub st_blksize: crate::blksize_t, + pub __pad2: c_int, + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + __unused: Padding<[c_int; 2usize]>, + } + + pub struct stat64 { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino64_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + pub __pad1: crate::dev_t, + pub st_size: off64_t, + pub st_blksize: crate::blksize_t, + pub __pad2: c_int, + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + __unused: Padding<[c_int; 2]>, + } + + pub struct statfs { + pub f_type: c_long, + pub f_bsize: c_long, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_fsid: crate::fsid_t, + pub f_namelen: c_long, + pub f_frsize: c_long, + pub f_flags: c_long, + pub f_spare: [c_long; 4], + } + + pub struct statfs64 { + pub f_type: c_long, + pub f_bsize: c_long, + pub f_blocks: crate::fsblkcnt64_t, + pub f_bfree: crate::fsblkcnt64_t, + pub f_bavail: crate::fsblkcnt64_t, + pub f_files: crate::fsfilcnt64_t, + pub f_ffree: crate::fsfilcnt64_t, + pub f_fsid: crate::fsid_t, + pub f_namelen: c_long, + pub f_frsize: c_long, + pub f_flags: c_long, + pub f_spare: [c_long; 4], + } + + pub struct statvfs { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_favail: crate::fsfilcnt_t, + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + pub __f_spare: [c_int; 6], + } + + pub struct statvfs64 { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt64_t, + pub f_bfree: crate::fsblkcnt64_t, + pub f_bavail: crate::fsblkcnt64_t, + pub f_files: crate::fsfilcnt64_t, + pub f_ffree: crate::fsfilcnt64_t, + pub f_favail: crate::fsfilcnt64_t, + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + pub __f_spare: [c_int; 6], + } + + pub struct siginfo_t { + pub si_signo: c_int, + pub si_errno: c_int, + pub si_code: c_int, + #[doc(hidden)] + #[deprecated( + since = "0.2.54", + note = "Please leave a comment on \ + https://github.com/rust-lang/libc/pull/1316 if you're using \ + this field" + )] + pub _pad: [c_int; 29], + _align: [u64; 0], + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_flags: c_int, + pub ss_size: size_t, + } + + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigaction { + pub sa_sigaction: crate::sighandler_t, + pub sa_mask: crate::sigset_t, + pub sa_flags: c_int, + pub sa_restorer: Option, + } + + pub struct ipc_perm { + pub __key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: c_ushort, + __pad1: Padding, + pub __seq: c_ushort, + __pad2: Padding, + __unused1: Padding, + __unused2: Padding, + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, + pub shm_atime: crate::time_t, + pub shm_dtime: crate::time_t, + pub shm_ctime: crate::time_t, + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: crate::shmatt_t, + __unused5: Padding, + __unused6: Padding, + } + + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off_t, + pub l_len: off_t, + pub l_pid: crate::pid_t, + } + + pub struct flock64 { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off64_t, + pub l_len: off64_t, + pub l_pid: crate::pid_t, + } + + pub struct user_regs_struct { + pub pc: c_ulong, + pub ra: c_ulong, + pub sp: c_ulong, + pub gp: c_ulong, + pub tp: c_ulong, + pub t0: c_ulong, + pub t1: c_ulong, + pub t2: c_ulong, + pub s0: c_ulong, + pub s1: c_ulong, + pub a0: c_ulong, + pub a1: c_ulong, + pub a2: c_ulong, + pub a3: c_ulong, + pub a4: c_ulong, + pub a5: c_ulong, + pub a6: c_ulong, + pub a7: c_ulong, + pub s2: c_ulong, + pub s3: c_ulong, + pub s4: c_ulong, + pub s5: c_ulong, + pub s6: c_ulong, + pub s7: c_ulong, + pub s8: c_ulong, + pub s9: c_ulong, + pub s10: c_ulong, + pub s11: c_ulong, + pub t3: c_ulong, + pub t4: c_ulong, + pub t5: c_ulong, + pub t6: c_ulong, + } + + #[repr(align(8))] + pub struct clone_args { + pub flags: c_ulonglong, + pub pidfd: c_ulonglong, + pub child_tid: c_ulonglong, + pub parent_tid: c_ulonglong, + pub exit_signal: c_ulonglong, + pub stack: c_ulonglong, + pub stack_size: c_ulonglong, + pub tls: c_ulonglong, + pub set_tid: c_ulonglong, + pub set_tid_size: c_ulonglong, + pub cgroup: c_ulonglong, + } +} + +s_no_extra_traits! { + pub struct ucontext_t { + pub __uc_flags: c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: crate::stack_t, + pub uc_sigmask: crate::sigset_t, + pub uc_mcontext: mcontext_t, + } + + #[repr(align(16))] + pub struct mcontext_t { + pub __gregs: [c_ulong; 32], + pub __fpregs: __riscv_mc_fp_state, + } + + pub union __riscv_mc_fp_state { + pub __f: __riscv_mc_f_ext_state, + pub __d: __riscv_mc_d_ext_state, + pub __q: __riscv_mc_q_ext_state, + } + + pub struct __riscv_mc_f_ext_state { + pub __f: [c_uint; 32], + pub __fcsr: c_uint, + } + + pub struct __riscv_mc_d_ext_state { + pub __f: [c_ulonglong; 32], + pub __fcsr: c_uint, + } + + #[repr(align(16))] + pub struct __riscv_mc_q_ext_state { + pub __f: [c_ulonglong; 64], + pub __fcsr: c_uint, + pub __glibc_reserved: [c_uint; 3], + } + + #[repr(align(16))] + pub struct max_align_t { + priv_: [f32; 8], + } +} + +pub const POSIX_FADV_DONTNEED: c_int = 4; +pub const POSIX_FADV_NOREUSE: c_int = 5; +pub const VEOF: usize = 4; +pub const RTLD_DEEPBIND: c_int = 0x8; +pub const RTLD_GLOBAL: c_int = 0x100; +pub const RTLD_NOLOAD: c_int = 0x4; +pub const O_APPEND: c_int = 1024; +pub const O_CREAT: c_int = 64; +pub const O_EXCL: c_int = 128; +pub const O_NOCTTY: c_int = 256; +pub const O_NONBLOCK: c_int = 2048; +pub const O_SYNC: c_int = 1052672; +pub const O_RSYNC: c_int = 1052672; +pub const O_DSYNC: c_int = 4096; +pub const O_FSYNC: c_int = 1052672; +pub const O_NOATIME: c_int = 262144; +pub const O_PATH: c_int = 2097152; +pub const O_TMPFILE: c_int = 4259840; +pub const MADV_SOFT_OFFLINE: c_int = 101; +pub const MAP_GROWSDOWN: c_int = 256; +pub const EDEADLK: c_int = 35; +pub const ENAMETOOLONG: c_int = 36; +pub const ENOLCK: c_int = 37; +pub const ENOSYS: c_int = 38; +pub const ENOTEMPTY: c_int = 39; +pub const ELOOP: c_int = 40; +pub const ENOMSG: c_int = 42; +pub const EIDRM: c_int = 43; +pub const ECHRNG: c_int = 44; +pub const EL2NSYNC: c_int = 45; +pub const EL3HLT: c_int = 46; +pub const EL3RST: c_int = 47; +pub const ELNRNG: c_int = 48; +pub const EUNATCH: c_int = 49; +pub const ENOCSI: c_int = 50; +pub const EL2HLT: c_int = 51; +pub const EBADE: c_int = 52; +pub const EBADR: c_int = 53; +pub const EXFULL: c_int = 54; +pub const ENOANO: c_int = 55; +pub const EBADRQC: c_int = 56; +pub const EBADSLT: c_int = 57; +pub const EMULTIHOP: c_int = 72; +pub const EOVERFLOW: c_int = 75; +pub const ENOTUNIQ: c_int = 76; +pub const EBADFD: c_int = 77; +pub const EBADMSG: c_int = 74; +pub const EREMCHG: c_int = 78; +pub const ELIBACC: c_int = 79; +pub const ELIBBAD: c_int = 80; +pub const ELIBSCN: c_int = 81; +pub const ELIBMAX: c_int = 82; +pub const ELIBEXEC: c_int = 83; +pub const EILSEQ: c_int = 84; +pub const ERESTART: c_int = 85; +pub const ESTRPIPE: c_int = 86; +pub const EUSERS: c_int = 87; +pub const ENOTSOCK: c_int = 88; +pub const EDESTADDRREQ: c_int = 89; +pub const EMSGSIZE: c_int = 90; +pub const EPROTOTYPE: c_int = 91; +pub const ENOPROTOOPT: c_int = 92; +pub const EPROTONOSUPPORT: c_int = 93; +pub const ESOCKTNOSUPPORT: c_int = 94; +pub const EOPNOTSUPP: c_int = 95; +pub const EPFNOSUPPORT: c_int = 96; +pub const EAFNOSUPPORT: c_int = 97; +pub const EADDRINUSE: c_int = 98; +pub const EADDRNOTAVAIL: c_int = 99; +pub const ENETDOWN: c_int = 100; +pub const ENETUNREACH: c_int = 101; +pub const ENETRESET: c_int = 102; +pub const ECONNABORTED: c_int = 103; +pub const ECONNRESET: c_int = 104; +pub const ENOBUFS: c_int = 105; +pub const EISCONN: c_int = 106; +pub const ENOTCONN: c_int = 107; +pub const ESHUTDOWN: c_int = 108; +pub const ETOOMANYREFS: c_int = 109; +pub const ETIMEDOUT: c_int = 110; +pub const ECONNREFUSED: c_int = 111; +pub const EHOSTDOWN: c_int = 112; +pub const EHOSTUNREACH: c_int = 113; +pub const EALREADY: c_int = 114; +pub const EINPROGRESS: c_int = 115; +pub const ESTALE: c_int = 116; +pub const EDQUOT: c_int = 122; +pub const ENOMEDIUM: c_int = 123; +pub const EMEDIUMTYPE: c_int = 124; +pub const ECANCELED: c_int = 125; +pub const ENOKEY: c_int = 126; +pub const EKEYEXPIRED: c_int = 127; +pub const EKEYREVOKED: c_int = 128; +pub const EKEYREJECTED: c_int = 129; +pub const EOWNERDEAD: c_int = 130; +pub const ENOTRECOVERABLE: c_int = 131; +pub const EHWPOISON: c_int = 133; +pub const ERFKILL: c_int = 132; + +pub const SOCK_STREAM: c_int = 1; +pub const SOCK_DGRAM: c_int = 2; +pub const SA_ONSTACK: c_int = 134217728; +pub const SA_SIGINFO: c_int = 4; +pub const SA_NOCLDWAIT: c_int = 2; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGCHLD: c_int = 17; +pub const SIGBUS: c_int = 7; +pub const SIGUSR1: c_int = 10; +pub const SIGUSR2: c_int = 12; +pub const SIGCONT: c_int = 18; +pub const SIGSTOP: c_int = 19; +pub const SIGTSTP: c_int = 20; +pub const SIGURG: c_int = 23; +pub const SIGIO: c_int = 29; +pub const SIGSYS: c_int = 31; +pub const SIGSTKFLT: c_int = 16; +pub const SIGPOLL: c_int = 29; +pub const SIGPWR: c_int = 30; +pub const SIG_SETMASK: c_int = 2; +pub const SIG_BLOCK: c_int = 0; +pub const SIG_UNBLOCK: c_int = 1; +pub const POLLWRNORM: c_short = 256; +pub const POLLWRBAND: c_short = 512; +pub const O_ASYNC: c_int = 8192; +pub const O_NDELAY: c_int = 2048; +pub const PTRACE_DETACH: c_uint = 17; +pub const EFD_NONBLOCK: c_int = 2048; +pub const F_GETLK: c_int = 5; +pub const F_GETOWN: c_int = 9; +pub const F_SETOWN: c_int = 8; +pub const F_SETLK: c_int = 6; +pub const F_SETLKW: c_int = 7; +pub const F_RDLCK: c_int = 0; +pub const F_WRLCK: c_int = 1; +pub const F_UNLCK: c_int = 2; +pub const F_OFD_GETLK: c_int = 36; +pub const F_OFD_SETLK: c_int = 37; +pub const F_OFD_SETLKW: c_int = 38; +pub const SFD_NONBLOCK: c_int = 2048; +pub const TCSANOW: c_int = 0; +pub const TCSADRAIN: c_int = 1; +pub const TCSAFLUSH: c_int = 2; +pub const SFD_CLOEXEC: c_int = 524288; +pub const NCCS: usize = 32; +pub const O_TRUNC: c_int = 512; +pub const O_CLOEXEC: c_int = 524288; +pub const EBFONT: c_int = 59; +pub const ENOSTR: c_int = 60; +pub const ENODATA: c_int = 61; +pub const ETIME: c_int = 62; +pub const ENOSR: c_int = 63; +pub const ENONET: c_int = 64; +pub const ENOPKG: c_int = 65; +pub const EREMOTE: c_int = 66; +pub const ENOLINK: c_int = 67; +pub const EADV: c_int = 68; +pub const ESRMNT: c_int = 69; +pub const ECOMM: c_int = 70; +pub const EPROTO: c_int = 71; +pub const EDOTDOT: c_int = 73; +pub const SA_NODEFER: c_int = 1073741824; +pub const SA_RESETHAND: c_int = -2147483648; +pub const SA_RESTART: c_int = 268435456; +pub const SA_NOCLDSTOP: c_int = 1; +pub const EPOLL_CLOEXEC: c_int = 524288; +pub const EFD_CLOEXEC: c_int = 524288; +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; +pub const O_DIRECT: c_int = 16384; +pub const O_DIRECTORY: c_int = 65536; +pub const O_NOFOLLOW: c_int = 131072; +pub const MAP_HUGETLB: c_int = 262144; +pub const MAP_LOCKED: c_int = 8192; +pub const MAP_NORESERVE: c_int = 16384; +pub const MAP_ANON: c_int = 32; +pub const MAP_ANONYMOUS: c_int = 32; +pub const MAP_DENYWRITE: c_int = 2048; +pub const MAP_EXECUTABLE: c_int = 4096; +pub const MAP_POPULATE: c_int = 32768; +pub const MAP_NONBLOCK: c_int = 65536; +pub const MAP_STACK: c_int = 131072; +pub const MAP_SYNC: c_int = 0x080000; +pub const EDEADLOCK: c_int = 35; +pub const EUCLEAN: c_int = 117; +pub const ENOTNAM: c_int = 118; +pub const ENAVAIL: c_int = 119; +pub const EISNAM: c_int = 120; +pub const EREMOTEIO: c_int = 121; +pub const PTRACE_GETFPREGS: c_uint = 14; +pub const PTRACE_SETFPREGS: c_uint = 15; +pub const PTRACE_GETFPXREGS: c_uint = 18; +pub const PTRACE_SETFPXREGS: c_uint = 19; +pub const PTRACE_GETREGS: c_uint = 12; +pub const PTRACE_SETREGS: c_uint = 13; +pub const MCL_CURRENT: c_int = 1; +pub const MCL_FUTURE: c_int = 2; +pub const MCL_ONFAULT: c_int = 4; +pub const SIGSTKSZ: size_t = 8192; +pub const MINSIGSTKSZ: size_t = 2048; +pub const CBAUD: crate::tcflag_t = 4111; +pub const TAB1: crate::tcflag_t = 2048; +pub const TAB2: crate::tcflag_t = 4096; +pub const TAB3: crate::tcflag_t = 6144; +pub const CR1: crate::tcflag_t = 512; +pub const CR2: crate::tcflag_t = 1024; +pub const CR3: crate::tcflag_t = 1536; +pub const FF1: crate::tcflag_t = 32768; +pub const BS1: crate::tcflag_t = 8192; +pub const VT1: crate::tcflag_t = 16384; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: crate::tcflag_t = 1024; +pub const IXOFF: crate::tcflag_t = 4096; +pub const ONLCR: crate::tcflag_t = 4; +pub const CSIZE: crate::tcflag_t = 48; +pub const CS6: crate::tcflag_t = 16; +pub const CS7: crate::tcflag_t = 32; +pub const CS8: crate::tcflag_t = 48; +pub const CSTOPB: crate::tcflag_t = 64; +pub const CREAD: crate::tcflag_t = 128; +pub const PARENB: crate::tcflag_t = 256; +pub const PARODD: crate::tcflag_t = 512; +pub const HUPCL: crate::tcflag_t = 1024; +pub const CLOCAL: crate::tcflag_t = 2048; +pub const ECHOKE: crate::tcflag_t = 2048; +pub const ECHOE: crate::tcflag_t = 16; +pub const ECHOK: crate::tcflag_t = 32; +pub const ECHONL: crate::tcflag_t = 64; +pub const ECHOPRT: crate::tcflag_t = 1024; +pub const ECHOCTL: crate::tcflag_t = 512; +pub const ISIG: crate::tcflag_t = 1; +pub const ICANON: crate::tcflag_t = 2; +pub const PENDIN: crate::tcflag_t = 16384; +pub const NOFLSH: crate::tcflag_t = 128; +pub const CIBAUD: crate::tcflag_t = 269418496; +pub const CBAUDEX: crate::tcflag_t = 4096; +pub const VSWTC: usize = 7; +pub const OLCUC: crate::tcflag_t = 2; +pub const NLDLY: crate::tcflag_t = 256; +pub const CRDLY: crate::tcflag_t = 1536; +pub const TABDLY: crate::tcflag_t = 6144; +pub const BSDLY: crate::tcflag_t = 8192; +pub const FFDLY: crate::tcflag_t = 32768; +pub const VTDLY: crate::tcflag_t = 16384; +pub const XTABS: crate::tcflag_t = 6144; +pub const B0: crate::speed_t = 0; +pub const B50: crate::speed_t = 1; +pub const B75: crate::speed_t = 2; +pub const B110: crate::speed_t = 3; +pub const B134: crate::speed_t = 4; +pub const B150: crate::speed_t = 5; +pub const B200: crate::speed_t = 6; +pub const B300: crate::speed_t = 7; +pub const B600: crate::speed_t = 8; +pub const B1200: crate::speed_t = 9; +pub const B1800: crate::speed_t = 10; +pub const B2400: crate::speed_t = 11; +pub const B4800: crate::speed_t = 12; +pub const B9600: crate::speed_t = 13; +pub const B19200: crate::speed_t = 14; +pub const B38400: crate::speed_t = 15; +pub const EXTA: crate::speed_t = 14; +pub const EXTB: crate::speed_t = 15; +pub const B57600: crate::speed_t = 4097; +pub const B115200: crate::speed_t = 4098; +pub const B230400: crate::speed_t = 4099; +pub const B460800: crate::speed_t = 4100; +pub const B500000: crate::speed_t = 4101; +pub const B576000: crate::speed_t = 4102; +pub const B921600: crate::speed_t = 4103; +pub const B1000000: crate::speed_t = 4104; +pub const B1152000: crate::speed_t = 4105; +pub const B1500000: crate::speed_t = 4106; +pub const B2000000: crate::speed_t = 4107; +pub const B2500000: crate::speed_t = 4108; +pub const B3000000: crate::speed_t = 4109; +pub const B3500000: crate::speed_t = 4110; +pub const B4000000: crate::speed_t = 4111; +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: crate::tcflag_t = 32768; +pub const TOSTOP: crate::tcflag_t = 256; +pub const FLUSHO: crate::tcflag_t = 4096; +pub const EXTPROC: crate::tcflag_t = 65536; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; +pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; +pub const NGREG: usize = 32; +pub const REG_PC: usize = 0; +pub const REG_RA: usize = 1; +pub const REG_SP: usize = 2; +pub const REG_TP: usize = 4; +pub const REG_S0: usize = 8; +pub const REG_S1: usize = 9; +pub const REG_A0: usize = 10; +pub const REG_S2: usize = 18; +pub const REG_NARGS: usize = 8; + +pub const COMPAT_HWCAP_ISA_I: c_ulong = 1 << (b'I' - b'A'); +pub const COMPAT_HWCAP_ISA_M: c_ulong = 1 << (b'M' - b'A'); +#[allow(clippy::eq_op)] +pub const COMPAT_HWCAP_ISA_A: c_ulong = 1 << (b'A' - b'A'); +pub const COMPAT_HWCAP_ISA_F: c_ulong = 1 << (b'F' - b'A'); +pub const COMPAT_HWCAP_ISA_D: c_ulong = 1 << (b'D' - b'A'); +pub const COMPAT_HWCAP_ISA_C: c_ulong = 1 << (b'C' - b'A'); +pub const COMPAT_HWCAP_ISA_V: c_ulong = 1 << (b'V' - b'A'); + +pub const SYS_read: c_long = 63; +pub const SYS_write: c_long = 64; +pub const SYS_close: c_long = 57; +pub const SYS_fstat: c_long = 80; +pub const SYS_lseek: c_long = 62; +pub const SYS_mmap: c_long = 222; +pub const SYS_mprotect: c_long = 226; +pub const SYS_munmap: c_long = 215; +pub const SYS_brk: c_long = 214; +pub const SYS_rt_sigaction: c_long = 134; +pub const SYS_rt_sigprocmask: c_long = 135; +pub const SYS_rt_sigreturn: c_long = 139; +pub const SYS_ioctl: c_long = 29; +pub const SYS_pread64: c_long = 67; +pub const SYS_pwrite64: c_long = 68; +pub const SYS_readv: c_long = 65; +pub const SYS_writev: c_long = 66; +pub const SYS_sched_yield: c_long = 124; +pub const SYS_mremap: c_long = 216; +pub const SYS_msync: c_long = 227; +pub const SYS_mincore: c_long = 232; +pub const SYS_madvise: c_long = 233; +pub const SYS_shmget: c_long = 194; +pub const SYS_shmat: c_long = 196; +pub const SYS_shmctl: c_long = 195; +pub const SYS_dup: c_long = 23; +pub const SYS_nanosleep: c_long = 101; +pub const SYS_getitimer: c_long = 102; +pub const SYS_setitimer: c_long = 103; +pub const SYS_getpid: c_long = 172; +pub const SYS_sendfile: c_long = 71; +pub const SYS_socket: c_long = 198; +pub const SYS_connect: c_long = 203; +pub const SYS_accept: c_long = 202; +pub const SYS_sendto: c_long = 206; +pub const SYS_recvfrom: c_long = 207; +pub const SYS_sendmsg: c_long = 211; +pub const SYS_recvmsg: c_long = 212; +pub const SYS_shutdown: c_long = 210; +pub const SYS_bind: c_long = 200; +pub const SYS_listen: c_long = 201; +pub const SYS_getsockname: c_long = 204; +pub const SYS_getpeername: c_long = 205; +pub const SYS_socketpair: c_long = 199; +pub const SYS_setsockopt: c_long = 208; +pub const SYS_getsockopt: c_long = 209; +pub const SYS_clone: c_long = 220; +pub const SYS_execve: c_long = 221; +pub const SYS_exit: c_long = 93; +pub const SYS_wait4: c_long = 260; +pub const SYS_kill: c_long = 129; +pub const SYS_uname: c_long = 160; +pub const SYS_semget: c_long = 190; +pub const SYS_semop: c_long = 193; +pub const SYS_semctl: c_long = 191; +pub const SYS_shmdt: c_long = 197; +pub const SYS_msgget: c_long = 186; +pub const SYS_msgsnd: c_long = 189; +pub const SYS_msgrcv: c_long = 188; +pub const SYS_msgctl: c_long = 187; +pub const SYS_fcntl: c_long = 25; +pub const SYS_flock: c_long = 32; +pub const SYS_fsync: c_long = 82; +pub const SYS_fdatasync: c_long = 83; +pub const SYS_truncate: c_long = 45; +pub const SYS_ftruncate: c_long = 46; +pub const SYS_getcwd: c_long = 17; +pub const SYS_chdir: c_long = 49; +pub const SYS_fchdir: c_long = 50; +pub const SYS_fchmod: c_long = 52; +pub const SYS_fchown: c_long = 55; +pub const SYS_umask: c_long = 166; +pub const SYS_gettimeofday: c_long = 169; +pub const SYS_getrlimit: c_long = 163; +pub const SYS_getrusage: c_long = 165; +pub const SYS_sysinfo: c_long = 179; +pub const SYS_times: c_long = 153; +pub const SYS_ptrace: c_long = 117; +pub const SYS_getuid: c_long = 174; +pub const SYS_syslog: c_long = 116; +pub const SYS_getgid: c_long = 176; +pub const SYS_setuid: c_long = 146; +pub const SYS_setgid: c_long = 144; +pub const SYS_geteuid: c_long = 175; +pub const SYS_getegid: c_long = 177; +pub const SYS_setpgid: c_long = 154; +pub const SYS_getppid: c_long = 173; +pub const SYS_setsid: c_long = 157; +pub const SYS_setreuid: c_long = 145; +pub const SYS_setregid: c_long = 143; +pub const SYS_getgroups: c_long = 158; +pub const SYS_setgroups: c_long = 159; +pub const SYS_setresuid: c_long = 147; +pub const SYS_getresuid: c_long = 148; +pub const SYS_setresgid: c_long = 149; +pub const SYS_getresgid: c_long = 150; +pub const SYS_getpgid: c_long = 155; +pub const SYS_setfsuid: c_long = 151; +pub const SYS_setfsgid: c_long = 152; +pub const SYS_getsid: c_long = 156; +pub const SYS_capget: c_long = 90; +pub const SYS_capset: c_long = 91; +pub const SYS_rt_sigpending: c_long = 136; +pub const SYS_rt_sigtimedwait: c_long = 137; +pub const SYS_rt_sigqueueinfo: c_long = 138; +pub const SYS_rt_sigsuspend: c_long = 133; +pub const SYS_sigaltstack: c_long = 132; +pub const SYS_personality: c_long = 92; +pub const SYS_statfs: c_long = 43; +pub const SYS_fstatfs: c_long = 44; +pub const SYS_getpriority: c_long = 141; +pub const SYS_setpriority: c_long = 140; +pub const SYS_sched_setparam: c_long = 118; +pub const SYS_sched_getparam: c_long = 121; +pub const SYS_sched_setscheduler: c_long = 119; +pub const SYS_sched_getscheduler: c_long = 120; +pub const SYS_sched_get_priority_max: c_long = 125; +pub const SYS_sched_get_priority_min: c_long = 126; +pub const SYS_sched_rr_get_interval: c_long = 127; +pub const SYS_mlock: c_long = 228; +pub const SYS_munlock: c_long = 229; +pub const SYS_mlockall: c_long = 230; +pub const SYS_munlockall: c_long = 231; +pub const SYS_vhangup: c_long = 58; +pub const SYS_pivot_root: c_long = 41; +pub const SYS_prctl: c_long = 167; +pub const SYS_adjtimex: c_long = 171; +pub const SYS_setrlimit: c_long = 164; +pub const SYS_chroot: c_long = 51; +pub const SYS_sync: c_long = 81; +pub const SYS_acct: c_long = 89; +pub const SYS_settimeofday: c_long = 170; +pub const SYS_mount: c_long = 40; +pub const SYS_umount2: c_long = 39; +pub const SYS_swapon: c_long = 224; +pub const SYS_swapoff: c_long = 225; +pub const SYS_reboot: c_long = 142; +pub const SYS_sethostname: c_long = 161; +pub const SYS_setdomainname: c_long = 162; +pub const SYS_init_module: c_long = 105; +pub const SYS_delete_module: c_long = 106; +pub const SYS_quotactl: c_long = 60; +pub const SYS_nfsservctl: c_long = 42; +pub const SYS_gettid: c_long = 178; +pub const SYS_readahead: c_long = 213; +pub const SYS_setxattr: c_long = 5; +pub const SYS_lsetxattr: c_long = 6; +pub const SYS_fsetxattr: c_long = 7; +pub const SYS_getxattr: c_long = 8; +pub const SYS_lgetxattr: c_long = 9; +pub const SYS_fgetxattr: c_long = 10; +pub const SYS_listxattr: c_long = 11; +pub const SYS_llistxattr: c_long = 12; +pub const SYS_flistxattr: c_long = 13; +pub const SYS_removexattr: c_long = 14; +pub const SYS_lremovexattr: c_long = 15; +pub const SYS_fremovexattr: c_long = 16; +pub const SYS_tkill: c_long = 130; +pub const SYS_futex: c_long = 98; +pub const SYS_sched_setaffinity: c_long = 122; +pub const SYS_sched_getaffinity: c_long = 123; +pub const SYS_io_setup: c_long = 0; +pub const SYS_io_destroy: c_long = 1; +pub const SYS_io_getevents: c_long = 4; +pub const SYS_io_submit: c_long = 2; +pub const SYS_io_cancel: c_long = 3; +pub const SYS_lookup_dcookie: c_long = 18; +pub const SYS_remap_file_pages: c_long = 234; +pub const SYS_getdents64: c_long = 61; +pub const SYS_set_tid_address: c_long = 96; +pub const SYS_restart_syscall: c_long = 128; +pub const SYS_semtimedop: c_long = 192; +pub const SYS_fadvise64: c_long = 223; +pub const SYS_timer_create: c_long = 107; +pub const SYS_timer_settime: c_long = 110; +pub const SYS_timer_gettime: c_long = 108; +pub const SYS_timer_getoverrun: c_long = 109; +pub const SYS_timer_delete: c_long = 111; +pub const SYS_clock_settime: c_long = 112; +pub const SYS_clock_gettime: c_long = 113; +pub const SYS_clock_getres: c_long = 114; +pub const SYS_clock_nanosleep: c_long = 115; +pub const SYS_exit_group: c_long = 94; +pub const SYS_epoll_ctl: c_long = 21; +pub const SYS_tgkill: c_long = 131; +pub const SYS_mbind: c_long = 235; +pub const SYS_set_mempolicy: c_long = 237; +pub const SYS_get_mempolicy: c_long = 236; +pub const SYS_mq_open: c_long = 180; +pub const SYS_mq_unlink: c_long = 181; +pub const SYS_mq_timedsend: c_long = 182; +pub const SYS_mq_timedreceive: c_long = 183; +pub const SYS_mq_notify: c_long = 184; +pub const SYS_mq_getsetattr: c_long = 185; +pub const SYS_kexec_load: c_long = 104; +pub const SYS_waitid: c_long = 95; +pub const SYS_add_key: c_long = 217; +pub const SYS_request_key: c_long = 218; +pub const SYS_keyctl: c_long = 219; +pub const SYS_ioprio_set: c_long = 30; +pub const SYS_ioprio_get: c_long = 31; +pub const SYS_inotify_add_watch: c_long = 27; +pub const SYS_inotify_rm_watch: c_long = 28; +pub const SYS_migrate_pages: c_long = 238; +pub const SYS_openat: c_long = 56; +pub const SYS_mkdirat: c_long = 34; +pub const SYS_mknodat: c_long = 33; +pub const SYS_fchownat: c_long = 54; +pub const SYS_newfstatat: c_long = 79; +pub const SYS_unlinkat: c_long = 35; +pub const SYS_linkat: c_long = 37; +pub const SYS_symlinkat: c_long = 36; +pub const SYS_readlinkat: c_long = 78; +pub const SYS_fchmodat: c_long = 53; +pub const SYS_faccessat: c_long = 48; +pub const SYS_pselect6: c_long = 72; +pub const SYS_ppoll: c_long = 73; +pub const SYS_unshare: c_long = 97; +pub const SYS_set_robust_list: c_long = 99; +pub const SYS_get_robust_list: c_long = 100; +pub const SYS_splice: c_long = 76; +pub const SYS_tee: c_long = 77; +pub const SYS_sync_file_range: c_long = 84; +pub const SYS_vmsplice: c_long = 75; +pub const SYS_move_pages: c_long = 239; +pub const SYS_utimensat: c_long = 88; +pub const SYS_epoll_pwait: c_long = 22; +pub const SYS_timerfd_create: c_long = 85; +pub const SYS_fallocate: c_long = 47; +pub const SYS_timerfd_settime: c_long = 86; +pub const SYS_timerfd_gettime: c_long = 87; +pub const SYS_accept4: c_long = 242; +pub const SYS_signalfd4: c_long = 74; +pub const SYS_eventfd2: c_long = 19; +pub const SYS_epoll_create1: c_long = 20; +pub const SYS_dup3: c_long = 24; +pub const SYS_pipe2: c_long = 59; +pub const SYS_inotify_init1: c_long = 26; +pub const SYS_preadv: c_long = 69; +pub const SYS_pwritev: c_long = 70; +pub const SYS_rt_tgsigqueueinfo: c_long = 240; +pub const SYS_perf_event_open: c_long = 241; +pub const SYS_recvmmsg: c_long = 243; +pub const SYS_fanotify_init: c_long = 262; +pub const SYS_fanotify_mark: c_long = 263; +pub const SYS_prlimit64: c_long = 261; +pub const SYS_name_to_handle_at: c_long = 264; +pub const SYS_open_by_handle_at: c_long = 265; +pub const SYS_clock_adjtime: c_long = 266; +pub const SYS_syncfs: c_long = 267; +pub const SYS_sendmmsg: c_long = 269; +pub const SYS_setns: c_long = 268; +pub const SYS_getcpu: c_long = 168; +pub const SYS_process_vm_readv: c_long = 270; +pub const SYS_process_vm_writev: c_long = 271; +pub const SYS_kcmp: c_long = 272; +pub const SYS_finit_module: c_long = 273; +pub const SYS_sched_setattr: c_long = 274; +pub const SYS_sched_getattr: c_long = 275; +pub const SYS_renameat2: c_long = 276; +pub const SYS_seccomp: c_long = 277; +pub const SYS_getrandom: c_long = 278; +pub const SYS_memfd_create: c_long = 279; +pub const SYS_bpf: c_long = 280; +pub const SYS_execveat: c_long = 281; +pub const SYS_userfaultfd: c_long = 282; +pub const SYS_membarrier: c_long = 283; +pub const SYS_mlock2: c_long = 284; +pub const SYS_copy_file_range: c_long = 285; +pub const SYS_preadv2: c_long = 286; +pub const SYS_pwritev2: c_long = 287; +pub const SYS_pkey_mprotect: c_long = 288; +pub const SYS_pkey_alloc: c_long = 289; +pub const SYS_pkey_free: c_long = 290; +pub const SYS_statx: c_long = 291; +pub const SYS_rseq: c_long = 293; +pub const SYS_pidfd_send_signal: c_long = 424; +pub const SYS_io_uring_setup: c_long = 425; +pub const SYS_io_uring_enter: c_long = 426; +pub const SYS_io_uring_register: c_long = 427; +pub const SYS_open_tree: c_long = 428; +pub const SYS_move_mount: c_long = 429; +pub const SYS_fsopen: c_long = 430; +pub const SYS_fsconfig: c_long = 431; +pub const SYS_fsmount: c_long = 432; +pub const SYS_fspick: c_long = 433; +pub const SYS_pidfd_open: c_long = 434; +pub const SYS_clone3: c_long = 435; +pub const SYS_close_range: c_long = 436; +pub const SYS_openat2: c_long = 437; +pub const SYS_pidfd_getfd: c_long = 438; +pub const SYS_faccessat2: c_long = 439; +pub const SYS_process_madvise: c_long = 440; +pub const SYS_epoll_pwait2: c_long = 441; +pub const SYS_mount_setattr: c_long = 442; +pub const SYS_quotactl_fd: c_long = 443; +pub const SYS_landlock_create_ruleset: c_long = 444; +pub const SYS_landlock_add_rule: c_long = 445; +pub const SYS_landlock_restrict_self: c_long = 446; +pub const SYS_memfd_secret: c_long = 447; +pub const SYS_process_mrelease: c_long = 448; +pub const SYS_futex_waitv: c_long = 449; +pub const SYS_set_mempolicy_home_node: c_long = 450; diff --git a/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/s390x.rs b/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/s390x.rs new file mode 100644 index 0000000..28e02c4 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/s390x.rs @@ -0,0 +1,958 @@ +//! s390x + +use crate::prelude::*; +use crate::{ + off64_t, + off_t, + pthread_mutex_t, +}; + +pub type blksize_t = i64; +pub type nlink_t = u64; +pub type suseconds_t = i64; +pub type wchar_t = i32; +pub type greg_t = u64; +pub type __u64 = u64; +pub type __s64 = i64; + +s! { + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigaction { + pub sa_sigaction: crate::sighandler_t, + __glibc_reserved0: Padding, + pub sa_flags: c_int, + pub sa_restorer: Option, + pub sa_mask: crate::sigset_t, + } + + pub struct statfs { + pub f_type: c_uint, + pub f_bsize: c_uint, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_fsid: crate::fsid_t, + pub f_namelen: c_uint, + pub f_frsize: c_uint, + pub f_flags: c_uint, + f_spare: [c_uint; 4], + } + + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off_t, + pub l_len: off_t, + pub l_pid: crate::pid_t, + } + + pub struct flock64 { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off64_t, + pub l_len: off64_t, + pub l_pid: crate::pid_t, + } + + pub struct siginfo_t { + pub si_signo: c_int, + pub si_errno: c_int, + pub si_code: c_int, + _pad: Padding, + _pad2: Padding<[c_long; 14]>, + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_flags: c_int, + pub ss_size: size_t, + } + + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_nlink: crate::nlink_t, + pub st_mode: crate::mode_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + st_pad0: Padding, + pub st_rdev: crate::dev_t, + pub st_size: off_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + __glibc_reserved: Padding<[c_long; 3]>, + } + + pub struct stat64 { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino64_t, + pub st_nlink: crate::nlink_t, + pub st_mode: crate::mode_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + st_pad0: Padding, + pub st_rdev: crate::dev_t, + pub st_size: off_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt64_t, + __glibc_reserved: Padding<[c_long; 3]>, + } + + pub struct pthread_attr_t { + __size: [c_ulong; 7], + } + + pub struct ipc_perm { + pub __key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: crate::mode_t, + pub __seq: c_ushort, + __pad1: Padding, + __unused1: Padding, + __unused2: Padding, + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, + pub shm_atime: crate::time_t, + pub shm_dtime: crate::time_t, + pub shm_ctime: crate::time_t, + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: crate::shmatt_t, + __unused4: Padding, + __unused5: Padding, + } + + pub struct statvfs { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_favail: crate::fsfilcnt_t, + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: [c_int; 6], + } + + pub struct __psw_t { + pub mask: u64, + pub addr: u64, + } + + pub struct fpregset_t { + pub fpc: u32, + __pad: Padding, + pub fprs: [fpreg_t; 16], + } + + pub struct mcontext_t { + pub psw: __psw_t, + pub gregs: [u64; 16], + pub aregs: [u32; 16], + pub fpregs: fpregset_t, + } + + pub struct ucontext_t { + pub uc_flags: c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: crate::stack_t, + pub uc_mcontext: mcontext_t, + pub uc_sigmask: crate::sigset_t, + } + + pub struct statfs64 { + pub f_type: c_uint, + pub f_bsize: c_uint, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_fsid: crate::fsid_t, + pub f_namelen: c_uint, + pub f_frsize: c_uint, + pub f_flags: c_uint, + pub f_spare: [c_uint; 4], + } + + pub struct statvfs64 { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: [c_int; 6], + } +} + +s_no_extra_traits! { + // FIXME(union): This is actually a union. + pub struct fpreg_t { + pub d: c_double, + // f: c_float, + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for fpreg_t { + fn eq(&self, other: &fpreg_t) -> bool { + self.d == other.d + } + } + + impl Eq for fpreg_t {} + + impl hash::Hash for fpreg_t { + fn hash(&self, state: &mut H) { + let d: u64 = self.d.to_bits(); + d.hash(state); + } + } + } +} + +pub const POSIX_FADV_DONTNEED: c_int = 6; +pub const POSIX_FADV_NOREUSE: c_int = 7; + +pub const VEOF: usize = 4; +pub const RTLD_DEEPBIND: c_int = 0x8; +pub const RTLD_GLOBAL: c_int = 0x100; +pub const RTLD_NOLOAD: c_int = 0x4; +pub const SFD_CLOEXEC: c_int = 0x080000; + +pub const NCCS: usize = 32; + +pub const O_TRUNC: c_int = 512; +pub const O_NOATIME: c_int = 0o1000000; +pub const O_CLOEXEC: c_int = 0x80000; +pub const O_PATH: c_int = 0o10000000; +pub const O_TMPFILE: c_int = 0o20000000 | O_DIRECTORY; + +pub const EBFONT: c_int = 59; +pub const ENOSTR: c_int = 60; +pub const ENODATA: c_int = 61; +pub const ETIME: c_int = 62; +pub const ENOSR: c_int = 63; +pub const ENONET: c_int = 64; +pub const ENOPKG: c_int = 65; +pub const EREMOTE: c_int = 66; +pub const ENOLINK: c_int = 67; +pub const EADV: c_int = 68; +pub const ESRMNT: c_int = 69; +pub const ECOMM: c_int = 70; +pub const EPROTO: c_int = 71; +pub const EDOTDOT: c_int = 73; + +pub const SA_NODEFER: c_int = 0x40000000; +pub const SA_RESETHAND: c_int = 0x80000000; +pub const SA_RESTART: c_int = 0x10000000; +pub const SA_NOCLDSTOP: c_int = 0x00000001; + +pub const EPOLL_CLOEXEC: c_int = 0x80000; + +pub const EFD_CLOEXEC: c_int = 0x80000; + +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; +pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; + +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; + +pub const EUCLEAN: c_int = 117; +pub const ENOTNAM: c_int = 118; +pub const ENAVAIL: c_int = 119; +pub const EISNAM: c_int = 120; +pub const EREMOTEIO: c_int = 121; +pub const EADDRINUSE: c_int = 98; +pub const EADDRNOTAVAIL: c_int = 99; +pub const ECONNABORTED: c_int = 103; +pub const ECONNREFUSED: c_int = 111; +pub const ECONNRESET: c_int = 104; +pub const EDEADLK: c_int = 35; +pub const ENOSYS: c_int = 38; +pub const ENOTCONN: c_int = 107; +pub const ETIMEDOUT: c_int = 110; +pub const O_APPEND: c_int = 1024; +pub const O_CREAT: c_int = 64; +pub const O_EXCL: c_int = 128; +pub const O_NONBLOCK: c_int = 2048; +pub const SA_NOCLDWAIT: c_int = 2; +pub const SA_ONSTACK: c_int = 0x08000000; +pub const SA_SIGINFO: c_int = 4; +pub const SIGBUS: c_int = 7; +pub const SIGSTKSZ: size_t = 0x2000; +pub const MINSIGSTKSZ: size_t = 2048; +pub const SIG_SETMASK: c_int = 2; + +pub const SOCK_STREAM: c_int = 1; +pub const SOCK_DGRAM: c_int = 2; + +pub const O_NOCTTY: c_int = 256; +pub const O_SYNC: c_int = 1052672; +pub const O_RSYNC: c_int = 1052672; +pub const O_DSYNC: c_int = 4096; +pub const O_FSYNC: c_int = 0x101000; +pub const O_DIRECT: c_int = 0x4000; +pub const O_DIRECTORY: c_int = 0x10000; +pub const O_NOFOLLOW: c_int = 0x20000; + +pub const MADV_SOFT_OFFLINE: c_int = 101; +pub const MAP_GROWSDOWN: c_int = 0x0100; +pub const MAP_LOCKED: c_int = 0x02000; +pub const MAP_NORESERVE: c_int = 0x04000; +pub const MAP_ANON: c_int = 0x0020; +pub const MAP_ANONYMOUS: c_int = 0x0020; +pub const MAP_DENYWRITE: c_int = 0x0800; +pub const MAP_EXECUTABLE: c_int = 0x01000; +pub const MAP_POPULATE: c_int = 0x08000; +pub const MAP_NONBLOCK: c_int = 0x010000; +pub const MAP_STACK: c_int = 0x020000; +pub const MAP_HUGETLB: c_int = 0x040000; +pub const MAP_SYNC: c_int = 0x080000; + +pub const EDEADLOCK: c_int = 35; +pub const ENAMETOOLONG: c_int = 36; +pub const ENOLCK: c_int = 37; +pub const ENOTEMPTY: c_int = 39; +pub const ELOOP: c_int = 40; +pub const ENOMSG: c_int = 42; +pub const EIDRM: c_int = 43; +pub const ECHRNG: c_int = 44; +pub const EL2NSYNC: c_int = 45; +pub const EL3HLT: c_int = 46; +pub const EL3RST: c_int = 47; +pub const ELNRNG: c_int = 48; +pub const EUNATCH: c_int = 49; +pub const ENOCSI: c_int = 50; +pub const EL2HLT: c_int = 51; +pub const EBADE: c_int = 52; +pub const EBADR: c_int = 53; +pub const EXFULL: c_int = 54; +pub const ENOANO: c_int = 55; +pub const EBADRQC: c_int = 56; +pub const EBADSLT: c_int = 57; +pub const EMULTIHOP: c_int = 72; +pub const EOVERFLOW: c_int = 75; +pub const ENOTUNIQ: c_int = 76; +pub const EBADFD: c_int = 77; +pub const EBADMSG: c_int = 74; +pub const EREMCHG: c_int = 78; +pub const ELIBACC: c_int = 79; +pub const ELIBBAD: c_int = 80; +pub const ELIBSCN: c_int = 81; +pub const ELIBMAX: c_int = 82; +pub const ELIBEXEC: c_int = 83; +pub const EILSEQ: c_int = 84; +pub const ERESTART: c_int = 85; +pub const ESTRPIPE: c_int = 86; +pub const EUSERS: c_int = 87; +pub const ENOTSOCK: c_int = 88; +pub const EDESTADDRREQ: c_int = 89; +pub const EMSGSIZE: c_int = 90; +pub const EPROTOTYPE: c_int = 91; +pub const ENOPROTOOPT: c_int = 92; +pub const EPROTONOSUPPORT: c_int = 93; +pub const ESOCKTNOSUPPORT: c_int = 94; +pub const EOPNOTSUPP: c_int = 95; +pub const EPFNOSUPPORT: c_int = 96; +pub const EAFNOSUPPORT: c_int = 97; +pub const ENETDOWN: c_int = 100; +pub const ENETUNREACH: c_int = 101; +pub const ENETRESET: c_int = 102; +pub const ENOBUFS: c_int = 105; +pub const EISCONN: c_int = 106; +pub const ESHUTDOWN: c_int = 108; +pub const ETOOMANYREFS: c_int = 109; +pub const EHOSTDOWN: c_int = 112; +pub const EHOSTUNREACH: c_int = 113; +pub const EALREADY: c_int = 114; +pub const EINPROGRESS: c_int = 115; +pub const ESTALE: c_int = 116; +pub const EDQUOT: c_int = 122; +pub const ENOMEDIUM: c_int = 123; +pub const EMEDIUMTYPE: c_int = 124; +pub const ECANCELED: c_int = 125; +pub const ENOKEY: c_int = 126; +pub const EKEYEXPIRED: c_int = 127; +pub const EKEYREVOKED: c_int = 128; +pub const EKEYREJECTED: c_int = 129; +pub const EOWNERDEAD: c_int = 130; +pub const ENOTRECOVERABLE: c_int = 131; +pub const EHWPOISON: c_int = 133; +pub const ERFKILL: c_int = 132; + +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGCHLD: c_int = 17; +pub const SIGUSR1: c_int = 10; +pub const SIGUSR2: c_int = 12; +pub const SIGCONT: c_int = 18; +pub const SIGSTOP: c_int = 19; +pub const SIGTSTP: c_int = 20; +pub const SIGURG: c_int = 23; +pub const SIGIO: c_int = 29; +pub const SIGSYS: c_int = 31; +pub const SIGSTKFLT: c_int = 16; +#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] +pub const SIGUNUSED: c_int = 31; +pub const SIGPOLL: c_int = 29; +pub const SIGPWR: c_int = 30; +pub const SIG_BLOCK: c_int = 0x000000; +pub const SIG_UNBLOCK: c_int = 0x01; + +pub const O_ASYNC: c_int = 0x2000; +pub const O_NDELAY: c_int = 0x800; + +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: crate::tcflag_t = 0x00008000; +pub const TOSTOP: crate::tcflag_t = 0x00000100; +pub const FLUSHO: crate::tcflag_t = 0x00001000; + +pub const EXTPROC: crate::tcflag_t = 0x00010000; + +pub const PTRACE_DETACH: c_uint = 17; + +pub const MCL_CURRENT: c_int = 0x0001; +pub const MCL_FUTURE: c_int = 0x0002; +pub const MCL_ONFAULT: c_int = 0x0004; + +pub const EFD_NONBLOCK: c_int = 0x800; + +pub const F_RDLCK: c_int = 0; +pub const F_WRLCK: c_int = 1; +pub const F_UNLCK: c_int = 2; +pub const F_GETLK: c_int = 5; +pub const F_GETOWN: c_int = 9; +pub const F_SETOWN: c_int = 8; +pub const F_SETLK: c_int = 6; +pub const F_SETLKW: c_int = 7; +pub const F_OFD_GETLK: c_int = 36; +pub const F_OFD_SETLK: c_int = 37; +pub const F_OFD_SETLKW: c_int = 38; + +pub const SFD_NONBLOCK: c_int = 0x0800; + +pub const TCSANOW: c_int = 0; +pub const TCSADRAIN: c_int = 1; +pub const TCSAFLUSH: c_int = 2; + +pub const VTIME: usize = 5; +pub const VSWTC: usize = 7; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VSUSP: usize = 10; +pub const VREPRINT: usize = 12; +pub const VDISCARD: usize = 13; +pub const VWERASE: usize = 14; +pub const OLCUC: crate::tcflag_t = 0o000002; +pub const ONLCR: crate::tcflag_t = 0o000004; +pub const NLDLY: crate::tcflag_t = 0o000400; +pub const CRDLY: crate::tcflag_t = 0o003000; +pub const CR1: crate::tcflag_t = 0x00000200; +pub const CR2: crate::tcflag_t = 0x00000400; +pub const CR3: crate::tcflag_t = 0x00000600; +pub const TABDLY: crate::tcflag_t = 0o014000; +pub const TAB1: crate::tcflag_t = 0x00000800; +pub const TAB2: crate::tcflag_t = 0x00001000; +pub const TAB3: crate::tcflag_t = 0x00001800; +pub const BSDLY: crate::tcflag_t = 0o020000; +pub const BS1: crate::tcflag_t = 0x00002000; +pub const FFDLY: crate::tcflag_t = 0o100000; +pub const FF1: crate::tcflag_t = 0x00008000; +pub const VTDLY: crate::tcflag_t = 0o040000; +pub const VT1: crate::tcflag_t = 0x00004000; +pub const XTABS: crate::tcflag_t = 0o014000; + +pub const CBAUD: crate::speed_t = 0o010017; +pub const B0: crate::speed_t = 0o000000; +pub const B50: crate::speed_t = 0o000001; +pub const B75: crate::speed_t = 0o000002; +pub const B110: crate::speed_t = 0o000003; +pub const B134: crate::speed_t = 0o000004; +pub const B150: crate::speed_t = 0o000005; +pub const B200: crate::speed_t = 0o000006; +pub const B300: crate::speed_t = 0o000007; +pub const B600: crate::speed_t = 0o000010; +pub const B1200: crate::speed_t = 0o000011; +pub const B1800: crate::speed_t = 0o000012; +pub const B2400: crate::speed_t = 0o000013; +pub const B4800: crate::speed_t = 0o000014; +pub const B9600: crate::speed_t = 0o000015; +pub const B19200: crate::speed_t = 0o000016; +pub const B38400: crate::speed_t = 0o000017; +pub const EXTA: crate::speed_t = B19200; +pub const EXTB: crate::speed_t = B38400; +pub const CSIZE: crate::tcflag_t = 0o000060; +pub const CS6: crate::tcflag_t = 0o000020; +pub const CS7: crate::tcflag_t = 0o000040; +pub const CS8: crate::tcflag_t = 0o000060; +pub const CSTOPB: crate::tcflag_t = 0o000100; +pub const CREAD: crate::tcflag_t = 0o000200; +pub const PARENB: crate::tcflag_t = 0o000400; +pub const PARODD: crate::tcflag_t = 0o001000; +pub const HUPCL: crate::tcflag_t = 0o002000; +pub const CLOCAL: crate::tcflag_t = 0o004000; +pub const CBAUDEX: crate::tcflag_t = 0o010000; +pub const B57600: crate::speed_t = 0o010001; +pub const B115200: crate::speed_t = 0o010002; +pub const B230400: crate::speed_t = 0o010003; +pub const B460800: crate::speed_t = 0o010004; +pub const B500000: crate::speed_t = 0o010005; +pub const B576000: crate::speed_t = 0o010006; +pub const B921600: crate::speed_t = 0o010007; +pub const B1000000: crate::speed_t = 0o010010; +pub const B1152000: crate::speed_t = 0o010011; +pub const B1500000: crate::speed_t = 0o010012; +pub const B2000000: crate::speed_t = 0o010013; +pub const B2500000: crate::speed_t = 0o010014; +pub const B3000000: crate::speed_t = 0o010015; +pub const B3500000: crate::speed_t = 0o010016; +pub const B4000000: crate::speed_t = 0o010017; +pub const CIBAUD: crate::tcflag_t = 0o02003600000; + +pub const ISIG: crate::tcflag_t = 0o000001; +pub const ICANON: crate::tcflag_t = 0o000002; +pub const ECHOE: crate::tcflag_t = 0o000020; +pub const ECHOK: crate::tcflag_t = 0o000040; +pub const ECHONL: crate::tcflag_t = 0o000100; +pub const NOFLSH: crate::tcflag_t = 0o000200; +pub const ECHOCTL: crate::tcflag_t = 0o001000; +pub const ECHOPRT: crate::tcflag_t = 0o002000; +pub const ECHOKE: crate::tcflag_t = 0o004000; +pub const PENDIN: crate::tcflag_t = 0o040000; + +pub const POLLWRNORM: c_short = 0x100; +pub const POLLWRBAND: c_short = 0x200; + +pub const IXON: crate::tcflag_t = 0o002000; +pub const IXOFF: crate::tcflag_t = 0o010000; + +pub const SYS_exit: c_long = 1; +pub const SYS_fork: c_long = 2; +pub const SYS_read: c_long = 3; +pub const SYS_write: c_long = 4; +pub const SYS_open: c_long = 5; +pub const SYS_close: c_long = 6; +pub const SYS_restart_syscall: c_long = 7; +pub const SYS_creat: c_long = 8; +pub const SYS_link: c_long = 9; +pub const SYS_unlink: c_long = 10; +pub const SYS_execve: c_long = 11; +pub const SYS_chdir: c_long = 12; +pub const SYS_mknod: c_long = 14; +pub const SYS_chmod: c_long = 15; +pub const SYS_lseek: c_long = 19; +pub const SYS_getpid: c_long = 20; +pub const SYS_mount: c_long = 21; +pub const SYS_umount: c_long = 22; +pub const SYS_ptrace: c_long = 26; +pub const SYS_alarm: c_long = 27; +pub const SYS_pause: c_long = 29; +pub const SYS_utime: c_long = 30; +pub const SYS_access: c_long = 33; +pub const SYS_nice: c_long = 34; +pub const SYS_sync: c_long = 36; +pub const SYS_kill: c_long = 37; +pub const SYS_rename: c_long = 38; +pub const SYS_mkdir: c_long = 39; +pub const SYS_rmdir: c_long = 40; +pub const SYS_dup: c_long = 41; +pub const SYS_pipe: c_long = 42; +pub const SYS_times: c_long = 43; +pub const SYS_brk: c_long = 45; +pub const SYS_signal: c_long = 48; +pub const SYS_acct: c_long = 51; +pub const SYS_umount2: c_long = 52; +pub const SYS_ioctl: c_long = 54; +pub const SYS_fcntl: c_long = 55; +pub const SYS_setpgid: c_long = 57; +pub const SYS_umask: c_long = 60; +pub const SYS_chroot: c_long = 61; +pub const SYS_ustat: c_long = 62; +pub const SYS_dup2: c_long = 63; +pub const SYS_getppid: c_long = 64; +pub const SYS_getpgrp: c_long = 65; +pub const SYS_setsid: c_long = 66; +pub const SYS_sigaction: c_long = 67; +pub const SYS_sigsuspend: c_long = 72; +pub const SYS_sigpending: c_long = 73; +pub const SYS_sethostname: c_long = 74; +pub const SYS_setrlimit: c_long = 75; +pub const SYS_getrusage: c_long = 77; +pub const SYS_gettimeofday: c_long = 78; +pub const SYS_settimeofday: c_long = 79; +pub const SYS_symlink: c_long = 83; +pub const SYS_readlink: c_long = 85; +pub const SYS_uselib: c_long = 86; +pub const SYS_swapon: c_long = 87; +pub const SYS_reboot: c_long = 88; +pub const SYS_readdir: c_long = 89; +pub const SYS_mmap: c_long = 90; +pub const SYS_munmap: c_long = 91; +pub const SYS_truncate: c_long = 92; +pub const SYS_ftruncate: c_long = 93; +pub const SYS_fchmod: c_long = 94; +pub const SYS_getpriority: c_long = 96; +pub const SYS_setpriority: c_long = 97; +pub const SYS_statfs: c_long = 99; +pub const SYS_fstatfs: c_long = 100; +pub const SYS_socketcall: c_long = 102; +pub const SYS_syslog: c_long = 103; +pub const SYS_setitimer: c_long = 104; +pub const SYS_getitimer: c_long = 105; +pub const SYS_stat: c_long = 106; +pub const SYS_lstat: c_long = 107; +pub const SYS_fstat: c_long = 108; +pub const SYS_lookup_dcookie: c_long = 110; +pub const SYS_vhangup: c_long = 111; +pub const SYS_idle: c_long = 112; +pub const SYS_wait4: c_long = 114; +pub const SYS_swapoff: c_long = 115; +pub const SYS_sysinfo: c_long = 116; +pub const SYS_ipc: c_long = 117; +pub const SYS_fsync: c_long = 118; +pub const SYS_sigreturn: c_long = 119; +pub const SYS_clone: c_long = 120; +pub const SYS_setdomainname: c_long = 121; +pub const SYS_uname: c_long = 122; +pub const SYS_adjtimex: c_long = 124; +pub const SYS_mprotect: c_long = 125; +pub const SYS_sigprocmask: c_long = 126; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_create_module: c_long = 127; +pub const SYS_init_module: c_long = 128; +pub const SYS_delete_module: c_long = 129; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_get_kernel_syms: c_long = 130; +pub const SYS_quotactl: c_long = 131; +pub const SYS_getpgid: c_long = 132; +pub const SYS_fchdir: c_long = 133; +pub const SYS_bdflush: c_long = 134; +pub const SYS_sysfs: c_long = 135; +pub const SYS_personality: c_long = 136; +pub const SYS_afs_syscall: c_long = 137; /* Syscall for Andrew File System */ +pub const SYS_getdents: c_long = 141; +pub const SYS_flock: c_long = 143; +pub const SYS_msync: c_long = 144; +pub const SYS_readv: c_long = 145; +pub const SYS_writev: c_long = 146; +pub const SYS_getsid: c_long = 147; +pub const SYS_fdatasync: c_long = 148; +pub const SYS__sysctl: c_long = 149; +pub const SYS_mlock: c_long = 150; +pub const SYS_munlock: c_long = 151; +pub const SYS_mlockall: c_long = 152; +pub const SYS_munlockall: c_long = 153; +pub const SYS_sched_setparam: c_long = 154; +pub const SYS_sched_getparam: c_long = 155; +pub const SYS_sched_setscheduler: c_long = 156; +pub const SYS_sched_getscheduler: c_long = 157; +pub const SYS_sched_yield: c_long = 158; +pub const SYS_sched_get_priority_max: c_long = 159; +pub const SYS_sched_get_priority_min: c_long = 160; +pub const SYS_sched_rr_get_interval: c_long = 161; +pub const SYS_nanosleep: c_long = 162; +pub const SYS_mremap: c_long = 163; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_query_module: c_long = 167; +pub const SYS_poll: c_long = 168; +pub const SYS_nfsservctl: c_long = 169; +pub const SYS_prctl: c_long = 172; +pub const SYS_rt_sigreturn: c_long = 173; +pub const SYS_rt_sigaction: c_long = 174; +pub const SYS_rt_sigprocmask: c_long = 175; +pub const SYS_rt_sigpending: c_long = 176; +pub const SYS_rt_sigtimedwait: c_long = 177; +pub const SYS_rt_sigqueueinfo: c_long = 178; +pub const SYS_rt_sigsuspend: c_long = 179; +pub const SYS_pread64: c_long = 180; +pub const SYS_pwrite64: c_long = 181; +pub const SYS_getcwd: c_long = 183; +pub const SYS_capget: c_long = 184; +pub const SYS_capset: c_long = 185; +pub const SYS_sigaltstack: c_long = 186; +pub const SYS_sendfile: c_long = 187; +pub const SYS_getpmsg: c_long = 188; +pub const SYS_putpmsg: c_long = 189; +pub const SYS_vfork: c_long = 190; +pub const SYS_pivot_root: c_long = 217; +pub const SYS_mincore: c_long = 218; +pub const SYS_madvise: c_long = 219; +pub const SYS_getdents64: c_long = 220; +pub const SYS_readahead: c_long = 222; +pub const SYS_setxattr: c_long = 224; +pub const SYS_lsetxattr: c_long = 225; +pub const SYS_fsetxattr: c_long = 226; +pub const SYS_getxattr: c_long = 227; +pub const SYS_lgetxattr: c_long = 228; +pub const SYS_fgetxattr: c_long = 229; +pub const SYS_listxattr: c_long = 230; +pub const SYS_llistxattr: c_long = 231; +pub const SYS_flistxattr: c_long = 232; +pub const SYS_removexattr: c_long = 233; +pub const SYS_lremovexattr: c_long = 234; +pub const SYS_fremovexattr: c_long = 235; +pub const SYS_gettid: c_long = 236; +pub const SYS_tkill: c_long = 237; +pub const SYS_futex: c_long = 238; +pub const SYS_sched_setaffinity: c_long = 239; +pub const SYS_sched_getaffinity: c_long = 240; +pub const SYS_tgkill: c_long = 241; +pub const SYS_io_setup: c_long = 243; +pub const SYS_io_destroy: c_long = 244; +pub const SYS_io_getevents: c_long = 245; +pub const SYS_io_submit: c_long = 246; +pub const SYS_io_cancel: c_long = 247; +pub const SYS_exit_group: c_long = 248; +pub const SYS_epoll_create: c_long = 249; +pub const SYS_epoll_ctl: c_long = 250; +pub const SYS_epoll_wait: c_long = 251; +pub const SYS_set_tid_address: c_long = 252; +pub const SYS_fadvise64: c_long = 253; +pub const SYS_timer_create: c_long = 254; +pub const SYS_timer_settime: c_long = 255; +pub const SYS_timer_gettime: c_long = 256; +pub const SYS_timer_getoverrun: c_long = 257; +pub const SYS_timer_delete: c_long = 258; +pub const SYS_clock_settime: c_long = 259; +pub const SYS_clock_gettime: c_long = 260; +pub const SYS_clock_getres: c_long = 261; +pub const SYS_clock_nanosleep: c_long = 262; +pub const SYS_statfs64: c_long = 265; +pub const SYS_fstatfs64: c_long = 266; +pub const SYS_remap_file_pages: c_long = 267; +pub const SYS_mbind: c_long = 268; +pub const SYS_get_mempolicy: c_long = 269; +pub const SYS_set_mempolicy: c_long = 270; +pub const SYS_mq_open: c_long = 271; +pub const SYS_mq_unlink: c_long = 272; +pub const SYS_mq_timedsend: c_long = 273; +pub const SYS_mq_timedreceive: c_long = 274; +pub const SYS_mq_notify: c_long = 275; +pub const SYS_mq_getsetattr: c_long = 276; +pub const SYS_kexec_load: c_long = 277; +pub const SYS_add_key: c_long = 278; +pub const SYS_request_key: c_long = 279; +pub const SYS_keyctl: c_long = 280; +pub const SYS_waitid: c_long = 281; +pub const SYS_ioprio_set: c_long = 282; +pub const SYS_ioprio_get: c_long = 283; +pub const SYS_inotify_init: c_long = 284; +pub const SYS_inotify_add_watch: c_long = 285; +pub const SYS_inotify_rm_watch: c_long = 286; +pub const SYS_migrate_pages: c_long = 287; +pub const SYS_openat: c_long = 288; +pub const SYS_mkdirat: c_long = 289; +pub const SYS_mknodat: c_long = 290; +pub const SYS_fchownat: c_long = 291; +pub const SYS_futimesat: c_long = 292; +pub const SYS_unlinkat: c_long = 294; +pub const SYS_renameat: c_long = 295; +pub const SYS_linkat: c_long = 296; +pub const SYS_symlinkat: c_long = 297; +pub const SYS_readlinkat: c_long = 298; +pub const SYS_fchmodat: c_long = 299; +pub const SYS_faccessat: c_long = 300; +pub const SYS_pselect6: c_long = 301; +pub const SYS_ppoll: c_long = 302; +pub const SYS_unshare: c_long = 303; +pub const SYS_set_robust_list: c_long = 304; +pub const SYS_get_robust_list: c_long = 305; +pub const SYS_splice: c_long = 306; +pub const SYS_sync_file_range: c_long = 307; +pub const SYS_tee: c_long = 308; +pub const SYS_vmsplice: c_long = 309; +pub const SYS_move_pages: c_long = 310; +pub const SYS_getcpu: c_long = 311; +pub const SYS_epoll_pwait: c_long = 312; +pub const SYS_utimes: c_long = 313; +pub const SYS_fallocate: c_long = 314; +pub const SYS_utimensat: c_long = 315; +pub const SYS_signalfd: c_long = 316; +pub const SYS_timerfd: c_long = 317; +pub const SYS_eventfd: c_long = 318; +pub const SYS_timerfd_create: c_long = 319; +pub const SYS_timerfd_settime: c_long = 320; +pub const SYS_timerfd_gettime: c_long = 321; +pub const SYS_signalfd4: c_long = 322; +pub const SYS_eventfd2: c_long = 323; +pub const SYS_inotify_init1: c_long = 324; +pub const SYS_pipe2: c_long = 325; +pub const SYS_dup3: c_long = 326; +pub const SYS_epoll_create1: c_long = 327; +pub const SYS_preadv: c_long = 328; +pub const SYS_pwritev: c_long = 329; +pub const SYS_rt_tgsigqueueinfo: c_long = 330; +pub const SYS_perf_event_open: c_long = 331; +pub const SYS_fanotify_init: c_long = 332; +pub const SYS_fanotify_mark: c_long = 333; +pub const SYS_prlimit64: c_long = 334; +pub const SYS_name_to_handle_at: c_long = 335; +pub const SYS_open_by_handle_at: c_long = 336; +pub const SYS_clock_adjtime: c_long = 337; +pub const SYS_syncfs: c_long = 338; +pub const SYS_setns: c_long = 339; +pub const SYS_process_vm_readv: c_long = 340; +pub const SYS_process_vm_writev: c_long = 341; +pub const SYS_s390_runtime_instr: c_long = 342; +pub const SYS_kcmp: c_long = 343; +pub const SYS_finit_module: c_long = 344; +pub const SYS_sched_setattr: c_long = 345; +pub const SYS_sched_getattr: c_long = 346; +pub const SYS_renameat2: c_long = 347; +pub const SYS_seccomp: c_long = 348; +pub const SYS_getrandom: c_long = 349; +pub const SYS_memfd_create: c_long = 350; +pub const SYS_bpf: c_long = 351; +pub const SYS_s390_pci_mmio_write: c_long = 352; +pub const SYS_s390_pci_mmio_read: c_long = 353; +pub const SYS_execveat: c_long = 354; +pub const SYS_userfaultfd: c_long = 355; +pub const SYS_membarrier: c_long = 356; +pub const SYS_recvmmsg: c_long = 357; +pub const SYS_sendmmsg: c_long = 358; +pub const SYS_socket: c_long = 359; +pub const SYS_socketpair: c_long = 360; +pub const SYS_bind: c_long = 361; +pub const SYS_connect: c_long = 362; +pub const SYS_listen: c_long = 363; +pub const SYS_accept4: c_long = 364; +pub const SYS_getsockopt: c_long = 365; +pub const SYS_setsockopt: c_long = 366; +pub const SYS_getsockname: c_long = 367; +pub const SYS_getpeername: c_long = 368; +pub const SYS_sendto: c_long = 369; +pub const SYS_sendmsg: c_long = 370; +pub const SYS_recvfrom: c_long = 371; +pub const SYS_recvmsg: c_long = 372; +pub const SYS_shutdown: c_long = 373; +pub const SYS_mlock2: c_long = 374; +pub const SYS_copy_file_range: c_long = 375; +pub const SYS_preadv2: c_long = 376; +pub const SYS_pwritev2: c_long = 377; +pub const SYS_lchown: c_long = 198; +pub const SYS_setuid: c_long = 213; +pub const SYS_getuid: c_long = 199; +pub const SYS_setgid: c_long = 214; +pub const SYS_getgid: c_long = 200; +pub const SYS_geteuid: c_long = 201; +pub const SYS_setreuid: c_long = 203; +pub const SYS_setregid: c_long = 204; +pub const SYS_getrlimit: c_long = 191; +pub const SYS_getgroups: c_long = 205; +pub const SYS_fchown: c_long = 207; +pub const SYS_setresuid: c_long = 208; +pub const SYS_setresgid: c_long = 210; +pub const SYS_getresgid: c_long = 211; +pub const SYS_select: c_long = 142; +pub const SYS_getegid: c_long = 202; +pub const SYS_setgroups: c_long = 206; +pub const SYS_getresuid: c_long = 209; +pub const SYS_chown: c_long = 212; +pub const SYS_setfsuid: c_long = 215; +pub const SYS_setfsgid: c_long = 216; +pub const SYS_newfstatat: c_long = 293; +pub const SYS_statx: c_long = 379; +pub const SYS_rseq: c_long = 383; +pub const SYS_pidfd_send_signal: c_long = 424; +pub const SYS_io_uring_setup: c_long = 425; +pub const SYS_io_uring_enter: c_long = 426; +pub const SYS_io_uring_register: c_long = 427; +pub const SYS_open_tree: c_long = 428; +pub const SYS_move_mount: c_long = 429; +pub const SYS_fsopen: c_long = 430; +pub const SYS_fsconfig: c_long = 431; +pub const SYS_fsmount: c_long = 432; +pub const SYS_fspick: c_long = 433; +pub const SYS_pidfd_open: c_long = 434; +pub const SYS_clone3: c_long = 435; +pub const SYS_close_range: c_long = 436; +pub const SYS_openat2: c_long = 437; +pub const SYS_pidfd_getfd: c_long = 438; +pub const SYS_faccessat2: c_long = 439; +pub const SYS_process_madvise: c_long = 440; +pub const SYS_epoll_pwait2: c_long = 441; +pub const SYS_mount_setattr: c_long = 442; +pub const SYS_quotactl_fd: c_long = 443; +pub const SYS_landlock_create_ruleset: c_long = 444; +pub const SYS_landlock_add_rule: c_long = 445; +pub const SYS_landlock_restrict_self: c_long = 446; +pub const SYS_memfd_secret: c_long = 447; +pub const SYS_process_mrelease: c_long = 448; +pub const SYS_futex_waitv: c_long = 449; +pub const SYS_set_mempolicy_home_node: c_long = 450; +pub const SYS_mseal: c_long = 462; + +extern "C" { + + pub fn sysctl( + name: *mut c_int, + namelen: c_int, + oldp: *mut c_void, + oldlenp: *mut size_t, + newp: *mut c_void, + newlen: size_t, + ) -> c_int; + pub fn getcontext(ucp: *mut crate::ucontext_t) -> c_int; + pub fn setcontext(ucp: *const crate::ucontext_t) -> c_int; + pub fn makecontext(ucp: *mut crate::ucontext_t, func: extern "C" fn(), argc: c_int, ...); + pub fn swapcontext(uocp: *mut crate::ucontext_t, ucp: *const crate::ucontext_t) -> c_int; +} diff --git a/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs new file mode 100644 index 0000000..0b32562 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs @@ -0,0 +1,934 @@ +//! SPARC64-specific definitions for 64-bit linux-like values + +use crate::prelude::*; +use crate::{ + off64_t, + off_t, + pthread_mutex_t, +}; + +pub type wchar_t = i32; +pub type nlink_t = u32; +pub type blksize_t = i64; +pub type suseconds_t = i32; +pub type __u64 = c_ulonglong; +pub type __s64 = c_longlong; + +s! { + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigaction { + pub sa_sigaction: crate::sighandler_t, + pub sa_mask: crate::sigset_t, + #[cfg(target_arch = "sparc64")] + __reserved0: Padding, + pub sa_flags: c_int, + pub sa_restorer: Option, + } + + pub struct statfs { + pub f_type: crate::__fsword_t, + pub f_bsize: crate::__fsword_t, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_fsid: crate::fsid_t, + + pub f_namelen: crate::__fsword_t, + pub f_frsize: crate::__fsword_t, + f_spare: [crate::__fsword_t; 5], + } + + pub struct siginfo_t { + pub si_signo: c_int, + pub si_errno: c_int, + pub si_code: c_int, + #[doc(hidden)] + #[deprecated( + since = "0.2.54", + note = "Please leave a comment on \ + https://github.com/rust-lang/libc/pull/1316 if you're using \ + this field" + )] + pub _pad: [c_int; 29], + _align: [usize; 0], + } + + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off_t, + pub l_len: off_t, + pub l_pid: crate::pid_t, + } + + pub struct flock64 { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off64_t, + pub l_len: off64_t, + pub l_pid: crate::pid_t, + __reserved: Padding, + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_flags: c_int, + pub ss_size: size_t, + } + + pub struct stat { + pub st_dev: crate::dev_t, + __pad0: Padding, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + __pad1: Padding, + pub st_size: off_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + __unused: Padding<[c_long; 2]>, + } + + pub struct stat64 { + pub st_dev: crate::dev_t, + __pad0: Padding, + pub st_ino: crate::ino64_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + __pad2: Padding, + pub st_size: off64_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt64_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + __reserved: Padding<[c_long; 2]>, + } + + pub struct statfs64 { + pub f_type: crate::__fsword_t, + pub f_bsize: crate::__fsword_t, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_fsid: crate::fsid_t, + pub f_namelen: crate::__fsword_t, + pub f_frsize: crate::__fsword_t, + pub f_flags: crate::__fsword_t, + pub f_spare: [crate::__fsword_t; 4], + } + + pub struct statvfs { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_favail: crate::fsfilcnt_t, + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: [c_int; 6], + } + + pub struct statvfs64 { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: [c_int; 6], + } + + pub struct pthread_attr_t { + __size: [u64; 7], + } + + pub struct ipc_perm { + pub __key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: crate::mode_t, + __pad0: Padding, + pub __seq: c_ushort, + __unused1: Padding, + __unused2: Padding, + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_atime: crate::time_t, + pub shm_dtime: crate::time_t, + pub shm_ctime: crate::time_t, + pub shm_segsz: size_t, + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: crate::shmatt_t, + __reserved1: Padding, + __reserved2: Padding, + } +} + +s_no_extra_traits! { + #[repr(align(16))] + pub struct max_align_t { + priv_: [i64; 4], + } +} + +pub const POSIX_FADV_DONTNEED: c_int = 4; +pub const POSIX_FADV_NOREUSE: c_int = 5; + +pub const VEOF: usize = 4; +pub const RTLD_DEEPBIND: c_int = 0x8; +pub const RTLD_GLOBAL: c_int = 0x100; +pub const RTLD_NOLOAD: c_int = 0x4; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; +pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; + +pub const O_APPEND: c_int = 0x8; +pub const O_CREAT: c_int = 0x200; +pub const O_EXCL: c_int = 0x800; +pub const O_NOCTTY: c_int = 0x8000; +pub const O_NONBLOCK: c_int = 0x4000; +pub const O_SYNC: c_int = 0x802000; +pub const O_RSYNC: c_int = 0x802000; +pub const O_DSYNC: c_int = 0x2000; +pub const O_FSYNC: c_int = 0x802000; +pub const O_NOATIME: c_int = 0x200000; +pub const O_PATH: c_int = 0x1000000; +pub const O_TMPFILE: c_int = 0x2000000 | O_DIRECTORY; + +pub const MADV_SOFT_OFFLINE: c_int = 101; +pub const MAP_GROWSDOWN: c_int = 0x0200; +pub const MAP_ANON: c_int = 0x0020; +pub const MAP_ANONYMOUS: c_int = 0x0020; +pub const MAP_DENYWRITE: c_int = 0x0800; +pub const MAP_EXECUTABLE: c_int = 0x01000; +pub const MAP_POPULATE: c_int = 0x08000; +pub const MAP_NONBLOCK: c_int = 0x010000; +pub const MAP_STACK: c_int = 0x020000; +pub const MAP_HUGETLB: c_int = 0x040000; +pub const MAP_SYNC: c_int = 0x080000; + +pub const EDEADLK: c_int = 78; +pub const ENAMETOOLONG: c_int = 63; +pub const ENOLCK: c_int = 79; +pub const ENOSYS: c_int = 90; +pub const ENOTEMPTY: c_int = 66; +pub const ELOOP: c_int = 62; +pub const ENOMSG: c_int = 75; +pub const EIDRM: c_int = 77; +pub const ECHRNG: c_int = 94; +pub const EL2NSYNC: c_int = 95; +pub const EL3HLT: c_int = 96; +pub const EL3RST: c_int = 97; +pub const ELNRNG: c_int = 98; +pub const EUNATCH: c_int = 99; +pub const ENOCSI: c_int = 100; +pub const EL2HLT: c_int = 101; +pub const EBADE: c_int = 102; +pub const EBADR: c_int = 103; +pub const EXFULL: c_int = 104; +pub const ENOANO: c_int = 105; +pub const EBADRQC: c_int = 106; +pub const EBADSLT: c_int = 107; +pub const EMULTIHOP: c_int = 87; +pub const EOVERFLOW: c_int = 92; +pub const ENOTUNIQ: c_int = 115; +pub const EBADFD: c_int = 93; +pub const EBADMSG: c_int = 76; +pub const EREMCHG: c_int = 89; +pub const ELIBACC: c_int = 114; +pub const ELIBBAD: c_int = 112; +pub const ELIBSCN: c_int = 124; +pub const ELIBMAX: c_int = 123; +pub const ELIBEXEC: c_int = 110; +pub const EILSEQ: c_int = 122; +pub const ERESTART: c_int = 116; +pub const ESTRPIPE: c_int = 91; +pub const EUSERS: c_int = 68; +pub const ENOTSOCK: c_int = 38; +pub const EDESTADDRREQ: c_int = 39; +pub const EMSGSIZE: c_int = 40; +pub const EPROTOTYPE: c_int = 41; +pub const ENOPROTOOPT: c_int = 42; +pub const EPROTONOSUPPORT: c_int = 43; +pub const ESOCKTNOSUPPORT: c_int = 44; +pub const EOPNOTSUPP: c_int = 45; +pub const EPFNOSUPPORT: c_int = 46; +pub const EAFNOSUPPORT: c_int = 47; +pub const EADDRINUSE: c_int = 48; +pub const EADDRNOTAVAIL: c_int = 49; +pub const ENETDOWN: c_int = 50; +pub const ENETUNREACH: c_int = 51; +pub const ENETRESET: c_int = 52; +pub const ECONNABORTED: c_int = 53; +pub const ECONNRESET: c_int = 54; +pub const ENOBUFS: c_int = 55; +pub const EISCONN: c_int = 56; +pub const ENOTCONN: c_int = 57; +pub const ESHUTDOWN: c_int = 58; +pub const ETOOMANYREFS: c_int = 59; +pub const ETIMEDOUT: c_int = 60; +pub const ECONNREFUSED: c_int = 61; +pub const EHOSTDOWN: c_int = 64; +pub const EHOSTUNREACH: c_int = 65; +pub const EALREADY: c_int = 37; +pub const EINPROGRESS: c_int = 36; +pub const ESTALE: c_int = 70; +pub const EDQUOT: c_int = 69; +pub const ENOMEDIUM: c_int = 125; +pub const EMEDIUMTYPE: c_int = 126; +pub const ECANCELED: c_int = 127; +pub const ENOKEY: c_int = 128; +pub const EKEYEXPIRED: c_int = 129; +pub const EKEYREVOKED: c_int = 130; +pub const EKEYREJECTED: c_int = 131; +pub const EOWNERDEAD: c_int = 132; +pub const ENOTRECOVERABLE: c_int = 133; +pub const EHWPOISON: c_int = 135; +pub const ERFKILL: c_int = 134; + +pub const SOCK_STREAM: c_int = 1; +pub const SOCK_DGRAM: c_int = 2; + +pub const SA_ONSTACK: c_int = 1; +pub const SA_SIGINFO: c_int = 0x200; +pub const SA_NOCLDWAIT: c_int = 0x100; + +pub const SIGEMT: c_int = 7; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGCHLD: c_int = 20; +pub const SIGBUS: c_int = 10; +pub const SIGUSR1: c_int = 30; +pub const SIGUSR2: c_int = 31; +pub const SIGCONT: c_int = 19; +pub const SIGSTOP: c_int = 17; +pub const SIGTSTP: c_int = 18; +pub const SIGURG: c_int = 16; +pub const SIGIO: c_int = 23; +pub const SIGSYS: c_int = 12; +pub const SIGPOLL: c_int = 23; +pub const SIGPWR: c_int = 29; +pub const SIG_SETMASK: c_int = 4; +pub const SIG_BLOCK: c_int = 1; +pub const SIG_UNBLOCK: c_int = 2; + +pub const POLLWRNORM: c_short = 4; +pub const POLLWRBAND: c_short = 0x100; + +pub const O_ASYNC: c_int = 0x40; +pub const O_NDELAY: c_int = 0x4004; + +pub const PTRACE_DETACH: c_uint = 17; + +pub const EFD_NONBLOCK: c_int = 0x4000; + +pub const F_GETLK: c_int = 7; +pub const F_GETOWN: c_int = 5; +pub const F_SETOWN: c_int = 6; +pub const F_SETLK: c_int = 8; +pub const F_SETLKW: c_int = 9; +pub const F_OFD_GETLK: c_int = 36; +pub const F_OFD_SETLK: c_int = 37; +pub const F_OFD_SETLKW: c_int = 38; + +pub const F_RDLCK: c_int = 1; +pub const F_WRLCK: c_int = 2; +pub const F_UNLCK: c_int = 3; + +pub const SFD_NONBLOCK: c_int = 0x4000; + +pub const TCSANOW: c_int = 0; +pub const TCSADRAIN: c_int = 1; +pub const TCSAFLUSH: c_int = 2; + +pub const SFD_CLOEXEC: c_int = 0x400000; + +pub const NCCS: usize = 17; +pub const O_TRUNC: c_int = 0x400; + +pub const O_CLOEXEC: c_int = 0x400000; + +pub const EBFONT: c_int = 109; +pub const ENOSTR: c_int = 72; +pub const ENODATA: c_int = 111; +pub const ETIME: c_int = 73; +pub const ENOSR: c_int = 74; +pub const ENONET: c_int = 80; +pub const ENOPKG: c_int = 113; +pub const EREMOTE: c_int = 71; +pub const ENOLINK: c_int = 82; +pub const EADV: c_int = 83; +pub const ESRMNT: c_int = 84; +pub const ECOMM: c_int = 85; +pub const EPROTO: c_int = 86; +pub const EDOTDOT: c_int = 88; + +pub const SA_NODEFER: c_int = 0x20; +pub const SA_RESETHAND: c_int = 0x4; +pub const SA_RESTART: c_int = 0x2; +pub const SA_NOCLDSTOP: c_int = 0x00000008; + +pub const EPOLL_CLOEXEC: c_int = 0x400000; + +pub const EFD_CLOEXEC: c_int = 0x400000; +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; + +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; + +pub const O_DIRECTORY: c_int = 0o200000; +pub const O_NOFOLLOW: c_int = 0o400000; +pub const O_DIRECT: c_int = 0x100000; + +pub const MAP_LOCKED: c_int = 0x0100; +pub const MAP_NORESERVE: c_int = 0x00040; + +pub const EDEADLOCK: c_int = 108; +pub const EUCLEAN: c_int = 117; +pub const ENOTNAM: c_int = 118; +pub const ENAVAIL: c_int = 119; +pub const EISNAM: c_int = 120; +pub const EREMOTEIO: c_int = 121; + +pub const MCL_CURRENT: c_int = 0x2000; +pub const MCL_FUTURE: c_int = 0x4000; +pub const MCL_ONFAULT: c_int = 0x8000; + +pub const SIGSTKSZ: size_t = 16384; +pub const MINSIGSTKSZ: size_t = 4096; +pub const CBAUD: crate::tcflag_t = 0x0000100f; +pub const TAB1: crate::tcflag_t = 0x800; +pub const TAB2: crate::tcflag_t = 0x1000; +pub const TAB3: crate::tcflag_t = 0x1800; +pub const CR1: crate::tcflag_t = 0x200; +pub const CR2: crate::tcflag_t = 0x400; +pub const CR3: crate::tcflag_t = 0x600; +pub const FF1: crate::tcflag_t = 0x8000; +pub const BS1: crate::tcflag_t = 0x2000; +pub const VT1: crate::tcflag_t = 0x4000; +pub const VWERASE: usize = 0xe; +pub const VREPRINT: usize = 0xc; +pub const VSUSP: usize = 0xa; +pub const VSTART: usize = 0x8; +pub const VSTOP: usize = 0x9; +pub const VDISCARD: usize = 0xd; +pub const VTIME: usize = 0x5; +pub const IXON: crate::tcflag_t = 0x400; +pub const IXOFF: crate::tcflag_t = 0x1000; +pub const ONLCR: crate::tcflag_t = 0x4; +pub const CSIZE: crate::tcflag_t = 0x30; +pub const CS6: crate::tcflag_t = 0x10; +pub const CS7: crate::tcflag_t = 0x20; +pub const CS8: crate::tcflag_t = 0x30; +pub const CSTOPB: crate::tcflag_t = 0x40; +pub const CREAD: crate::tcflag_t = 0x80; +pub const PARENB: crate::tcflag_t = 0x100; +pub const PARODD: crate::tcflag_t = 0x200; +pub const HUPCL: crate::tcflag_t = 0x400; +pub const CLOCAL: crate::tcflag_t = 0x800; +pub const ECHOKE: crate::tcflag_t = 0x800; +pub const ECHOE: crate::tcflag_t = 0x10; +pub const ECHOK: crate::tcflag_t = 0x20; +pub const ECHONL: crate::tcflag_t = 0x40; +pub const ECHOPRT: crate::tcflag_t = 0x400; +pub const ECHOCTL: crate::tcflag_t = 0x200; +pub const ISIG: crate::tcflag_t = 0x1; +pub const ICANON: crate::tcflag_t = 0x2; +pub const PENDIN: crate::tcflag_t = 0x4000; +pub const NOFLSH: crate::tcflag_t = 0x80; +pub const CIBAUD: crate::tcflag_t = 0o02003600000; +pub const CBAUDEX: crate::tcflag_t = 0x00001000; +pub const VSWTC: usize = 7; +pub const OLCUC: crate::tcflag_t = 0o000002; +pub const NLDLY: crate::tcflag_t = 0o000400; +pub const CRDLY: crate::tcflag_t = 0o003000; +pub const TABDLY: crate::tcflag_t = 0o014000; +pub const BSDLY: crate::tcflag_t = 0o020000; +pub const FFDLY: crate::tcflag_t = 0o100000; +pub const VTDLY: crate::tcflag_t = 0o040000; +pub const XTABS: crate::tcflag_t = 0o014000; + +pub const B0: crate::speed_t = 0o000000; +pub const B50: crate::speed_t = 0o000001; +pub const B75: crate::speed_t = 0o000002; +pub const B110: crate::speed_t = 0o000003; +pub const B134: crate::speed_t = 0o000004; +pub const B150: crate::speed_t = 0o000005; +pub const B200: crate::speed_t = 0o000006; +pub const B300: crate::speed_t = 0o000007; +pub const B600: crate::speed_t = 0o000010; +pub const B1200: crate::speed_t = 0o000011; +pub const B1800: crate::speed_t = 0o000012; +pub const B2400: crate::speed_t = 0o000013; +pub const B4800: crate::speed_t = 0o000014; +pub const B9600: crate::speed_t = 0o000015; +pub const B19200: crate::speed_t = 0o000016; +pub const B38400: crate::speed_t = 0o000017; +pub const EXTA: crate::speed_t = B19200; +pub const EXTB: crate::speed_t = B38400; +pub const B57600: crate::speed_t = 0x1001; +pub const B115200: crate::speed_t = 0x1002; +pub const B230400: crate::speed_t = 0x1003; +pub const B460800: crate::speed_t = 0x1004; +pub const B76800: crate::speed_t = 0x1005; +pub const B153600: crate::speed_t = 0x1006; +pub const B307200: crate::speed_t = 0x1007; +pub const B614400: crate::speed_t = 0x1008; +pub const B921600: crate::speed_t = 0x1009; +pub const B500000: crate::speed_t = 0x100a; +pub const B576000: crate::speed_t = 0x100b; +pub const B1000000: crate::speed_t = 0x100c; +pub const B1152000: crate::speed_t = 0x100d; +pub const B1500000: crate::speed_t = 0x100e; +pub const B2000000: crate::speed_t = 0x100f; + +pub const VEOL: usize = 5; +pub const VEOL2: usize = 6; +pub const VMIN: usize = 4; +pub const IEXTEN: crate::tcflag_t = 0x8000; +pub const TOSTOP: crate::tcflag_t = 0x100; +pub const FLUSHO: crate::tcflag_t = 0x1000; +pub const EXTPROC: crate::tcflag_t = 0x10000; + +pub const SYS_restart_syscall: c_long = 0; +pub const SYS_exit: c_long = 1; +pub const SYS_fork: c_long = 2; +pub const SYS_read: c_long = 3; +pub const SYS_write: c_long = 4; +pub const SYS_open: c_long = 5; +pub const SYS_close: c_long = 6; +pub const SYS_wait4: c_long = 7; +pub const SYS_creat: c_long = 8; +pub const SYS_link: c_long = 9; +pub const SYS_unlink: c_long = 10; +pub const SYS_execv: c_long = 11; +pub const SYS_chdir: c_long = 12; +pub const SYS_chown: c_long = 13; +pub const SYS_mknod: c_long = 14; +pub const SYS_chmod: c_long = 15; +pub const SYS_lchown: c_long = 16; +pub const SYS_brk: c_long = 17; +pub const SYS_perfctr: c_long = 18; +pub const SYS_lseek: c_long = 19; +pub const SYS_getpid: c_long = 20; +pub const SYS_capget: c_long = 21; +pub const SYS_capset: c_long = 22; +pub const SYS_setuid: c_long = 23; +pub const SYS_getuid: c_long = 24; +pub const SYS_vmsplice: c_long = 25; +pub const SYS_ptrace: c_long = 26; +pub const SYS_alarm: c_long = 27; +pub const SYS_sigaltstack: c_long = 28; +pub const SYS_pause: c_long = 29; +pub const SYS_utime: c_long = 30; +pub const SYS_access: c_long = 33; +pub const SYS_nice: c_long = 34; +pub const SYS_sync: c_long = 36; +pub const SYS_kill: c_long = 37; +pub const SYS_stat: c_long = 38; +pub const SYS_sendfile: c_long = 39; +pub const SYS_lstat: c_long = 40; +pub const SYS_dup: c_long = 41; +pub const SYS_pipe: c_long = 42; +pub const SYS_times: c_long = 43; +pub const SYS_umount2: c_long = 45; +pub const SYS_setgid: c_long = 46; +pub const SYS_getgid: c_long = 47; +pub const SYS_signal: c_long = 48; +pub const SYS_geteuid: c_long = 49; +pub const SYS_getegid: c_long = 50; +pub const SYS_acct: c_long = 51; +pub const SYS_memory_ordering: c_long = 52; +pub const SYS_ioctl: c_long = 54; +pub const SYS_reboot: c_long = 55; +pub const SYS_symlink: c_long = 57; +pub const SYS_readlink: c_long = 58; +pub const SYS_execve: c_long = 59; +pub const SYS_umask: c_long = 60; +pub const SYS_chroot: c_long = 61; +pub const SYS_fstat: c_long = 62; +pub const SYS_fstat64: c_long = 63; +pub const SYS_getpagesize: c_long = 64; +pub const SYS_msync: c_long = 65; +pub const SYS_vfork: c_long = 66; +pub const SYS_pread64: c_long = 67; +pub const SYS_pwrite64: c_long = 68; +pub const SYS_mmap: c_long = 71; +pub const SYS_munmap: c_long = 73; +pub const SYS_mprotect: c_long = 74; +pub const SYS_madvise: c_long = 75; +pub const SYS_vhangup: c_long = 76; +pub const SYS_mincore: c_long = 78; +pub const SYS_getgroups: c_long = 79; +pub const SYS_setgroups: c_long = 80; +pub const SYS_getpgrp: c_long = 81; +pub const SYS_setitimer: c_long = 83; +pub const SYS_swapon: c_long = 85; +pub const SYS_getitimer: c_long = 86; +pub const SYS_sethostname: c_long = 88; +pub const SYS_dup2: c_long = 90; +pub const SYS_fcntl: c_long = 92; +pub const SYS_select: c_long = 93; +pub const SYS_fsync: c_long = 95; +pub const SYS_setpriority: c_long = 96; +pub const SYS_socket: c_long = 97; +pub const SYS_connect: c_long = 98; +pub const SYS_accept: c_long = 99; +pub const SYS_getpriority: c_long = 100; +pub const SYS_rt_sigreturn: c_long = 101; +pub const SYS_rt_sigaction: c_long = 102; +pub const SYS_rt_sigprocmask: c_long = 103; +pub const SYS_rt_sigpending: c_long = 104; +pub const SYS_rt_sigtimedwait: c_long = 105; +pub const SYS_rt_sigqueueinfo: c_long = 106; +pub const SYS_rt_sigsuspend: c_long = 107; +pub const SYS_setresuid: c_long = 108; +pub const SYS_getresuid: c_long = 109; +pub const SYS_setresgid: c_long = 110; +pub const SYS_getresgid: c_long = 111; +pub const SYS_recvmsg: c_long = 113; +pub const SYS_sendmsg: c_long = 114; +pub const SYS_gettimeofday: c_long = 116; +pub const SYS_getrusage: c_long = 117; +pub const SYS_getsockopt: c_long = 118; +pub const SYS_getcwd: c_long = 119; +pub const SYS_readv: c_long = 120; +pub const SYS_writev: c_long = 121; +pub const SYS_settimeofday: c_long = 122; +pub const SYS_fchown: c_long = 123; +pub const SYS_fchmod: c_long = 124; +pub const SYS_recvfrom: c_long = 125; +pub const SYS_setreuid: c_long = 126; +pub const SYS_setregid: c_long = 127; +pub const SYS_rename: c_long = 128; +pub const SYS_truncate: c_long = 129; +pub const SYS_ftruncate: c_long = 130; +pub const SYS_flock: c_long = 131; +pub const SYS_lstat64: c_long = 132; +pub const SYS_sendto: c_long = 133; +pub const SYS_shutdown: c_long = 134; +pub const SYS_socketpair: c_long = 135; +pub const SYS_mkdir: c_long = 136; +pub const SYS_rmdir: c_long = 137; +pub const SYS_utimes: c_long = 138; +pub const SYS_stat64: c_long = 139; +pub const SYS_sendfile64: c_long = 140; +pub const SYS_getpeername: c_long = 141; +pub const SYS_futex: c_long = 142; +pub const SYS_gettid: c_long = 143; +pub const SYS_getrlimit: c_long = 144; +pub const SYS_setrlimit: c_long = 145; +pub const SYS_pivot_root: c_long = 146; +pub const SYS_prctl: c_long = 147; +pub const SYS_pciconfig_read: c_long = 148; +pub const SYS_pciconfig_write: c_long = 149; +pub const SYS_getsockname: c_long = 150; +pub const SYS_inotify_init: c_long = 151; +pub const SYS_inotify_add_watch: c_long = 152; +pub const SYS_poll: c_long = 153; +pub const SYS_getdents64: c_long = 154; +pub const SYS_inotify_rm_watch: c_long = 156; +pub const SYS_statfs: c_long = 157; +pub const SYS_fstatfs: c_long = 158; +pub const SYS_umount: c_long = 159; +pub const SYS_sched_set_affinity: c_long = 160; +pub const SYS_sched_get_affinity: c_long = 161; +pub const SYS_getdomainname: c_long = 162; +pub const SYS_setdomainname: c_long = 163; +pub const SYS_utrap_install: c_long = 164; +pub const SYS_quotactl: c_long = 165; +pub const SYS_set_tid_address: c_long = 166; +pub const SYS_mount: c_long = 167; +pub const SYS_ustat: c_long = 168; +pub const SYS_setxattr: c_long = 169; +pub const SYS_lsetxattr: c_long = 170; +pub const SYS_fsetxattr: c_long = 171; +pub const SYS_getxattr: c_long = 172; +pub const SYS_lgetxattr: c_long = 173; +pub const SYS_getdents: c_long = 174; +pub const SYS_setsid: c_long = 175; +pub const SYS_fchdir: c_long = 176; +pub const SYS_fgetxattr: c_long = 177; +pub const SYS_listxattr: c_long = 178; +pub const SYS_llistxattr: c_long = 179; +pub const SYS_flistxattr: c_long = 180; +pub const SYS_removexattr: c_long = 181; +pub const SYS_lremovexattr: c_long = 182; +pub const SYS_sigpending: c_long = 183; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_query_module: c_long = 184; +pub const SYS_setpgid: c_long = 185; +pub const SYS_fremovexattr: c_long = 186; +pub const SYS_tkill: c_long = 187; +pub const SYS_exit_group: c_long = 188; +pub const SYS_uname: c_long = 189; +pub const SYS_init_module: c_long = 190; +pub const SYS_personality: c_long = 191; +pub const SYS_remap_file_pages: c_long = 192; +pub const SYS_epoll_create: c_long = 193; +pub const SYS_epoll_ctl: c_long = 194; +pub const SYS_epoll_wait: c_long = 195; +pub const SYS_ioprio_set: c_long = 196; +pub const SYS_getppid: c_long = 197; +pub const SYS_sigaction: c_long = 198; +pub const SYS_sgetmask: c_long = 199; +pub const SYS_ssetmask: c_long = 200; +pub const SYS_sigsuspend: c_long = 201; +pub const SYS_oldlstat: c_long = 202; +pub const SYS_uselib: c_long = 203; +pub const SYS_readdir: c_long = 204; +pub const SYS_readahead: c_long = 205; +pub const SYS_socketcall: c_long = 206; +pub const SYS_syslog: c_long = 207; +pub const SYS_lookup_dcookie: c_long = 208; +pub const SYS_fadvise64: c_long = 209; +pub const SYS_fadvise64_64: c_long = 210; +pub const SYS_tgkill: c_long = 211; +pub const SYS_waitpid: c_long = 212; +pub const SYS_swapoff: c_long = 213; +pub const SYS_sysinfo: c_long = 214; +pub const SYS_ipc: c_long = 215; +pub const SYS_sigreturn: c_long = 216; +pub const SYS_clone: c_long = 217; +pub const SYS_ioprio_get: c_long = 218; +pub const SYS_adjtimex: c_long = 219; +pub const SYS_sigprocmask: c_long = 220; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_create_module: c_long = 221; +pub const SYS_delete_module: c_long = 222; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_get_kernel_syms: c_long = 223; +pub const SYS_getpgid: c_long = 224; +pub const SYS_bdflush: c_long = 225; +pub const SYS_sysfs: c_long = 226; +pub const SYS_afs_syscall: c_long = 227; +pub const SYS_setfsuid: c_long = 228; +pub const SYS_setfsgid: c_long = 229; +pub const SYS__newselect: c_long = 230; +pub const SYS_splice: c_long = 232; +pub const SYS_stime: c_long = 233; +pub const SYS_statfs64: c_long = 234; +pub const SYS_fstatfs64: c_long = 235; +pub const SYS__llseek: c_long = 236; +pub const SYS_mlock: c_long = 237; +pub const SYS_munlock: c_long = 238; +pub const SYS_mlockall: c_long = 239; +pub const SYS_munlockall: c_long = 240; +pub const SYS_sched_setparam: c_long = 241; +pub const SYS_sched_getparam: c_long = 242; +pub const SYS_sched_setscheduler: c_long = 243; +pub const SYS_sched_getscheduler: c_long = 244; +pub const SYS_sched_yield: c_long = 245; +pub const SYS_sched_get_priority_max: c_long = 246; +pub const SYS_sched_get_priority_min: c_long = 247; +pub const SYS_sched_rr_get_interval: c_long = 248; +pub const SYS_nanosleep: c_long = 249; +pub const SYS_mremap: c_long = 250; +pub const SYS__sysctl: c_long = 251; +pub const SYS_getsid: c_long = 252; +pub const SYS_fdatasync: c_long = 253; +pub const SYS_nfsservctl: c_long = 254; +pub const SYS_sync_file_range: c_long = 255; +pub const SYS_clock_settime: c_long = 256; +pub const SYS_clock_gettime: c_long = 257; +pub const SYS_clock_getres: c_long = 258; +pub const SYS_clock_nanosleep: c_long = 259; +pub const SYS_sched_getaffinity: c_long = 260; +pub const SYS_sched_setaffinity: c_long = 261; +pub const SYS_timer_settime: c_long = 262; +pub const SYS_timer_gettime: c_long = 263; +pub const SYS_timer_getoverrun: c_long = 264; +pub const SYS_timer_delete: c_long = 265; +pub const SYS_timer_create: c_long = 266; +pub const SYS_io_setup: c_long = 268; +pub const SYS_io_destroy: c_long = 269; +pub const SYS_io_submit: c_long = 270; +pub const SYS_io_cancel: c_long = 271; +pub const SYS_io_getevents: c_long = 272; +pub const SYS_mq_open: c_long = 273; +pub const SYS_mq_unlink: c_long = 274; +pub const SYS_mq_timedsend: c_long = 275; +pub const SYS_mq_timedreceive: c_long = 276; +pub const SYS_mq_notify: c_long = 277; +pub const SYS_mq_getsetattr: c_long = 278; +pub const SYS_waitid: c_long = 279; +pub const SYS_tee: c_long = 280; +pub const SYS_add_key: c_long = 281; +pub const SYS_request_key: c_long = 282; +pub const SYS_keyctl: c_long = 283; +pub const SYS_openat: c_long = 284; +pub const SYS_mkdirat: c_long = 285; +pub const SYS_mknodat: c_long = 286; +pub const SYS_fchownat: c_long = 287; +pub const SYS_futimesat: c_long = 288; +pub const SYS_fstatat64: c_long = 289; +pub const SYS_unlinkat: c_long = 290; +pub const SYS_renameat: c_long = 291; +pub const SYS_linkat: c_long = 292; +pub const SYS_symlinkat: c_long = 293; +pub const SYS_readlinkat: c_long = 294; +pub const SYS_fchmodat: c_long = 295; +pub const SYS_faccessat: c_long = 296; +pub const SYS_pselect6: c_long = 297; +pub const SYS_ppoll: c_long = 298; +pub const SYS_unshare: c_long = 299; +pub const SYS_set_robust_list: c_long = 300; +pub const SYS_get_robust_list: c_long = 301; +pub const SYS_migrate_pages: c_long = 302; +pub const SYS_mbind: c_long = 303; +pub const SYS_get_mempolicy: c_long = 304; +pub const SYS_set_mempolicy: c_long = 305; +pub const SYS_kexec_load: c_long = 306; +pub const SYS_move_pages: c_long = 307; +pub const SYS_getcpu: c_long = 308; +pub const SYS_epoll_pwait: c_long = 309; +pub const SYS_utimensat: c_long = 310; +pub const SYS_signalfd: c_long = 311; +pub const SYS_timerfd_create: c_long = 312; +pub const SYS_eventfd: c_long = 313; +pub const SYS_fallocate: c_long = 314; +pub const SYS_timerfd_settime: c_long = 315; +pub const SYS_timerfd_gettime: c_long = 316; +pub const SYS_signalfd4: c_long = 317; +pub const SYS_eventfd2: c_long = 318; +pub const SYS_epoll_create1: c_long = 319; +pub const SYS_dup3: c_long = 320; +pub const SYS_pipe2: c_long = 321; +pub const SYS_inotify_init1: c_long = 322; +pub const SYS_accept4: c_long = 323; +pub const SYS_preadv: c_long = 324; +pub const SYS_pwritev: c_long = 325; +pub const SYS_rt_tgsigqueueinfo: c_long = 326; +pub const SYS_perf_event_open: c_long = 327; +pub const SYS_recvmmsg: c_long = 328; +pub const SYS_fanotify_init: c_long = 329; +pub const SYS_fanotify_mark: c_long = 330; +pub const SYS_prlimit64: c_long = 331; +pub const SYS_name_to_handle_at: c_long = 332; +pub const SYS_open_by_handle_at: c_long = 333; +pub const SYS_clock_adjtime: c_long = 334; +pub const SYS_syncfs: c_long = 335; +pub const SYS_sendmmsg: c_long = 336; +pub const SYS_setns: c_long = 337; +pub const SYS_process_vm_readv: c_long = 338; +pub const SYS_process_vm_writev: c_long = 339; +pub const SYS_kern_features: c_long = 340; +pub const SYS_kcmp: c_long = 341; +pub const SYS_finit_module: c_long = 342; +pub const SYS_sched_setattr: c_long = 343; +pub const SYS_sched_getattr: c_long = 344; +pub const SYS_renameat2: c_long = 345; +pub const SYS_seccomp: c_long = 346; +pub const SYS_getrandom: c_long = 347; +pub const SYS_memfd_create: c_long = 348; +pub const SYS_bpf: c_long = 349; +pub const SYS_execveat: c_long = 350; +pub const SYS_membarrier: c_long = 351; +pub const SYS_userfaultfd: c_long = 352; +pub const SYS_bind: c_long = 353; +pub const SYS_listen: c_long = 354; +pub const SYS_setsockopt: c_long = 355; +pub const SYS_mlock2: c_long = 356; +pub const SYS_copy_file_range: c_long = 357; +pub const SYS_preadv2: c_long = 358; +pub const SYS_pwritev2: c_long = 359; +pub const SYS_statx: c_long = 360; +pub const SYS_rseq: c_long = 365; +pub const SYS_pidfd_send_signal: c_long = 424; +pub const SYS_io_uring_setup: c_long = 425; +pub const SYS_io_uring_enter: c_long = 426; +pub const SYS_io_uring_register: c_long = 427; +pub const SYS_open_tree: c_long = 428; +pub const SYS_move_mount: c_long = 429; +pub const SYS_fsopen: c_long = 430; +pub const SYS_fsconfig: c_long = 431; +pub const SYS_fsmount: c_long = 432; +pub const SYS_fspick: c_long = 433; +pub const SYS_pidfd_open: c_long = 434; +// Reserved in the kernel, but not actually implemented yet +pub const SYS_clone3: c_long = 435; +pub const SYS_close_range: c_long = 436; +pub const SYS_openat2: c_long = 437; +pub const SYS_pidfd_getfd: c_long = 438; +pub const SYS_faccessat2: c_long = 439; +pub const SYS_process_madvise: c_long = 440; +pub const SYS_epoll_pwait2: c_long = 441; +pub const SYS_mount_setattr: c_long = 442; +pub const SYS_quotactl_fd: c_long = 443; +pub const SYS_landlock_create_ruleset: c_long = 444; +pub const SYS_landlock_add_rule: c_long = 445; +pub const SYS_landlock_restrict_self: c_long = 446; +pub const SYS_memfd_secret: c_long = 447; +pub const SYS_process_mrelease: c_long = 448; +pub const SYS_futex_waitv: c_long = 449; +pub const SYS_set_mempolicy_home_node: c_long = 450; + +extern "C" { + pub fn sysctl( + name: *mut c_int, + namelen: c_int, + oldp: *mut c_void, + oldlenp: *mut size_t, + newp: *mut c_void, + newlen: size_t, + ) -> c_int; +} diff --git a/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs new file mode 100644 index 0000000..7edd7c5 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs @@ -0,0 +1,743 @@ +//! x86_64-specific definitions for 64-bit linux-like values + +use crate::prelude::*; +use crate::{ + off64_t, + off_t, +}; + +pub type wchar_t = i32; +pub type nlink_t = u64; +pub type blksize_t = i64; +pub type greg_t = i64; +pub type suseconds_t = i64; +pub type __u64 = c_ulonglong; +pub type __s64 = c_longlong; + +s! { + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigaction { + pub sa_sigaction: crate::sighandler_t, + pub sa_mask: crate::sigset_t, + #[cfg(target_arch = "sparc64")] + __reserved0: Padding, + pub sa_flags: c_int, + pub sa_restorer: Option, + } + + pub struct statfs { + pub f_type: crate::__fsword_t, + pub f_bsize: crate::__fsword_t, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_fsid: crate::fsid_t, + + pub f_namelen: crate::__fsword_t, + pub f_frsize: crate::__fsword_t, + f_spare: [crate::__fsword_t; 5], + } + + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off_t, + pub l_len: off_t, + pub l_pid: crate::pid_t, + } + + pub struct flock64 { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off64_t, + pub l_len: off64_t, + pub l_pid: crate::pid_t, + } + + pub struct siginfo_t { + pub si_signo: c_int, + pub si_errno: c_int, + pub si_code: c_int, + #[doc(hidden)] + #[deprecated( + since = "0.2.54", + note = "Please leave a comment on \ + https://github.com/rust-lang/libc/pull/1316 if you're using \ + this field" + )] + pub _pad: [c_int; 29], + _align: [u64; 0], + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_flags: c_int, + pub ss_size: size_t, + } + + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_nlink: crate::nlink_t, + pub st_mode: crate::mode_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + __pad0: Padding, + pub st_rdev: crate::dev_t, + pub st_size: off_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: i64, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: i64, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: i64, + __unused: Padding<[i64; 3]>, + } + + pub struct stat64 { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino64_t, + pub st_nlink: crate::nlink_t, + pub st_mode: crate::mode_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + __pad0: Padding, + pub st_rdev: crate::dev_t, + pub st_size: off_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt64_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: i64, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: i64, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: i64, + __reserved: Padding<[i64; 3]>, + } + + pub struct statfs64 { + pub f_type: crate::__fsword_t, + pub f_bsize: crate::__fsword_t, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_fsid: crate::fsid_t, + pub f_namelen: crate::__fsword_t, + pub f_frsize: crate::__fsword_t, + pub f_flags: crate::__fsword_t, + pub f_spare: [crate::__fsword_t; 4], + } + + pub struct statvfs64 { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: [c_int; 6], + } + + pub struct pthread_attr_t { + #[cfg(target_pointer_width = "32")] + __size: [u32; 8], + #[cfg(target_pointer_width = "64")] + __size: [u64; 7], + } + + pub struct _libc_fpxreg { + pub significand: [u16; 4], + pub exponent: u16, + __private: [u16; 3], + } + + pub struct _libc_xmmreg { + pub element: [u32; 4], + } + + pub struct _libc_fpstate { + pub cwd: u16, + pub swd: u16, + pub ftw: u16, + pub fop: u16, + pub rip: u64, + pub rdp: u64, + pub mxcsr: u32, + pub mxcr_mask: u32, + pub _st: [_libc_fpxreg; 8], + pub _xmm: [_libc_xmmreg; 16], + __private: [u64; 12], + } + + pub struct user_regs_struct { + pub r15: c_ulonglong, + pub r14: c_ulonglong, + pub r13: c_ulonglong, + pub r12: c_ulonglong, + pub rbp: c_ulonglong, + pub rbx: c_ulonglong, + pub r11: c_ulonglong, + pub r10: c_ulonglong, + pub r9: c_ulonglong, + pub r8: c_ulonglong, + pub rax: c_ulonglong, + pub rcx: c_ulonglong, + pub rdx: c_ulonglong, + pub rsi: c_ulonglong, + pub rdi: c_ulonglong, + pub orig_rax: c_ulonglong, + pub rip: c_ulonglong, + pub cs: c_ulonglong, + pub eflags: c_ulonglong, + pub rsp: c_ulonglong, + pub ss: c_ulonglong, + pub fs_base: c_ulonglong, + pub gs_base: c_ulonglong, + pub ds: c_ulonglong, + pub es: c_ulonglong, + pub fs: c_ulonglong, + pub gs: c_ulonglong, + } + + pub struct user { + pub regs: user_regs_struct, + pub u_fpvalid: c_int, + pub i387: user_fpregs_struct, + pub u_tsize: c_ulonglong, + pub u_dsize: c_ulonglong, + pub u_ssize: c_ulonglong, + pub start_code: c_ulonglong, + pub start_stack: c_ulonglong, + pub signal: c_longlong, + __reserved: Padding, + #[cfg(target_pointer_width = "32")] + __pad1: Padding, + pub u_ar0: *mut user_regs_struct, + #[cfg(target_pointer_width = "32")] + __pad2: Padding, + pub u_fpstate: *mut user_fpregs_struct, + pub magic: c_ulonglong, + pub u_comm: [c_char; 32], + pub u_debugreg: [c_ulonglong; 8], + } + + pub struct mcontext_t { + pub gregs: [greg_t; 23], + pub fpregs: *mut _libc_fpstate, + __private: [u64; 8], + } + + pub struct ipc_perm { + pub __key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: c_ushort, + __pad1: Padding, + pub __seq: c_ushort, + __pad2: Padding, + __unused1: Padding, + __unused2: Padding, + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, + pub shm_atime: crate::time_t, + pub shm_dtime: crate::time_t, + pub shm_ctime: crate::time_t, + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: crate::shmatt_t, + __unused4: Padding, + __unused5: Padding, + } + + pub struct ptrace_rseq_configuration { + pub rseq_abi_pointer: crate::__u64, + pub rseq_abi_size: crate::__u32, + pub signature: crate::__u32, + pub flags: crate::__u32, + pub pad: crate::__u32, + } + + #[repr(align(8))] + pub struct clone_args { + pub flags: c_ulonglong, + pub pidfd: c_ulonglong, + pub child_tid: c_ulonglong, + pub parent_tid: c_ulonglong, + pub exit_signal: c_ulonglong, + pub stack: c_ulonglong, + pub stack_size: c_ulonglong, + pub tls: c_ulonglong, + pub set_tid: c_ulonglong, + pub set_tid_size: c_ulonglong, + pub cgroup: c_ulonglong, + } + + pub struct user_fpregs_struct { + pub cwd: c_ushort, + pub swd: c_ushort, + pub ftw: c_ushort, + pub fop: c_ushort, + pub rip: c_ulonglong, + pub rdp: c_ulonglong, + pub mxcsr: c_uint, + pub mxcr_mask: c_uint, + pub st_space: [c_uint; 32], + pub xmm_space: [c_uint; 64], + padding: Padding<[c_uint; 24]>, + } + + pub struct ucontext_t { + pub uc_flags: c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: crate::stack_t, + pub uc_mcontext: mcontext_t, + pub uc_sigmask: crate::sigset_t, + __private: [u8; 512], + __ssp: [c_ulonglong; 4], + } +} + +s_no_extra_traits! { + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 4], + } +} + +pub const POSIX_FADV_DONTNEED: c_int = 4; +pub const POSIX_FADV_NOREUSE: c_int = 5; + +pub const VEOF: usize = 4; +pub const RTLD_DEEPBIND: c_int = 0x8; +pub const RTLD_GLOBAL: c_int = 0x100; +pub const RTLD_NOLOAD: c_int = 0x4; + +pub const O_APPEND: c_int = 1024; +pub const O_CREAT: c_int = 64; +pub const O_EXCL: c_int = 128; +pub const O_NOCTTY: c_int = 256; +pub const O_NONBLOCK: c_int = 2048; +pub const O_SYNC: c_int = 1052672; +pub const O_RSYNC: c_int = 1052672; +pub const O_DSYNC: c_int = 4096; +pub const O_FSYNC: c_int = 0x101000; +pub const O_NOATIME: c_int = 0o1000000; +pub const O_PATH: c_int = 0o10000000; +pub const O_TMPFILE: c_int = 0o20000000 | O_DIRECTORY; + +pub const MADV_SOFT_OFFLINE: c_int = 101; +pub const MAP_GROWSDOWN: c_int = 0x0100; + +pub const EDEADLK: c_int = 35; +pub const ENAMETOOLONG: c_int = 36; +pub const ENOLCK: c_int = 37; +pub const ENOSYS: c_int = 38; +pub const ENOTEMPTY: c_int = 39; +pub const ELOOP: c_int = 40; +pub const ENOMSG: c_int = 42; +pub const EIDRM: c_int = 43; +pub const ECHRNG: c_int = 44; +pub const EL2NSYNC: c_int = 45; +pub const EL3HLT: c_int = 46; +pub const EL3RST: c_int = 47; +pub const ELNRNG: c_int = 48; +pub const EUNATCH: c_int = 49; +pub const ENOCSI: c_int = 50; +pub const EL2HLT: c_int = 51; +pub const EBADE: c_int = 52; +pub const EBADR: c_int = 53; +pub const EXFULL: c_int = 54; +pub const ENOANO: c_int = 55; +pub const EBADRQC: c_int = 56; +pub const EBADSLT: c_int = 57; +pub const EMULTIHOP: c_int = 72; +pub const EOVERFLOW: c_int = 75; +pub const ENOTUNIQ: c_int = 76; +pub const EBADFD: c_int = 77; +pub const EBADMSG: c_int = 74; +pub const EREMCHG: c_int = 78; +pub const ELIBACC: c_int = 79; +pub const ELIBBAD: c_int = 80; +pub const ELIBSCN: c_int = 81; +pub const ELIBMAX: c_int = 82; +pub const ELIBEXEC: c_int = 83; +pub const EILSEQ: c_int = 84; +pub const ERESTART: c_int = 85; +pub const ESTRPIPE: c_int = 86; +pub const EUSERS: c_int = 87; +pub const ENOTSOCK: c_int = 88; +pub const EDESTADDRREQ: c_int = 89; +pub const EMSGSIZE: c_int = 90; +pub const EPROTOTYPE: c_int = 91; +pub const ENOPROTOOPT: c_int = 92; +pub const EPROTONOSUPPORT: c_int = 93; +pub const ESOCKTNOSUPPORT: c_int = 94; +pub const EOPNOTSUPP: c_int = 95; +pub const EPFNOSUPPORT: c_int = 96; +pub const EAFNOSUPPORT: c_int = 97; +pub const EADDRINUSE: c_int = 98; +pub const EADDRNOTAVAIL: c_int = 99; +pub const ENETDOWN: c_int = 100; +pub const ENETUNREACH: c_int = 101; +pub const ENETRESET: c_int = 102; +pub const ECONNABORTED: c_int = 103; +pub const ECONNRESET: c_int = 104; +pub const ENOBUFS: c_int = 105; +pub const EISCONN: c_int = 106; +pub const ENOTCONN: c_int = 107; +pub const ESHUTDOWN: c_int = 108; +pub const ETOOMANYREFS: c_int = 109; +pub const ETIMEDOUT: c_int = 110; +pub const ECONNREFUSED: c_int = 111; +pub const EHOSTDOWN: c_int = 112; +pub const EHOSTUNREACH: c_int = 113; +pub const EALREADY: c_int = 114; +pub const EINPROGRESS: c_int = 115; +pub const ESTALE: c_int = 116; +pub const EDQUOT: c_int = 122; +pub const ENOMEDIUM: c_int = 123; +pub const EMEDIUMTYPE: c_int = 124; +pub const ECANCELED: c_int = 125; +pub const ENOKEY: c_int = 126; +pub const EKEYEXPIRED: c_int = 127; +pub const EKEYREVOKED: c_int = 128; +pub const EKEYREJECTED: c_int = 129; +pub const EOWNERDEAD: c_int = 130; +pub const ENOTRECOVERABLE: c_int = 131; +pub const EHWPOISON: c_int = 133; +pub const ERFKILL: c_int = 132; + +pub const SOCK_STREAM: c_int = 1; +pub const SOCK_DGRAM: c_int = 2; + +pub const SA_ONSTACK: c_int = 0x08000000; +pub const SA_SIGINFO: c_int = 0x00000004; +pub const SA_NOCLDWAIT: c_int = 0x00000002; + +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGCHLD: c_int = 17; +pub const SIGBUS: c_int = 7; +pub const SIGUSR1: c_int = 10; +pub const SIGUSR2: c_int = 12; +pub const SIGCONT: c_int = 18; +pub const SIGSTOP: c_int = 19; +pub const SIGTSTP: c_int = 20; +pub const SIGURG: c_int = 23; +pub const SIGIO: c_int = 29; +pub const SIGSYS: c_int = 31; +pub const SIGSTKFLT: c_int = 16; +#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] +pub const SIGUNUSED: c_int = 31; +pub const SIGPOLL: c_int = 29; +pub const SIGPWR: c_int = 30; +pub const SIG_SETMASK: c_int = 2; +pub const SIG_BLOCK: c_int = 0x000000; +pub const SIG_UNBLOCK: c_int = 0x01; + +pub const POLLWRNORM: c_short = 0x100; +pub const POLLWRBAND: c_short = 0x200; + +pub const O_ASYNC: c_int = 0x2000; +pub const O_NDELAY: c_int = 0x800; + +pub const PTRACE_DETACH: c_uint = 17; +pub const PTRACE_GET_RSEQ_CONFIGURATION: c_uint = 0x420f; + +pub const EFD_NONBLOCK: c_int = 0x800; + +pub const F_GETLK: c_int = 5; +pub const F_GETOWN: c_int = 9; +pub const F_SETOWN: c_int = 8; +pub const F_SETLK: c_int = 6; +pub const F_SETLKW: c_int = 7; +pub const F_OFD_GETLK: c_int = 36; +pub const F_OFD_SETLK: c_int = 37; +pub const F_OFD_SETLKW: c_int = 38; + +pub const F_RDLCK: c_int = 0; +pub const F_WRLCK: c_int = 1; +pub const F_UNLCK: c_int = 2; + +pub const SFD_NONBLOCK: c_int = 0x0800; + +pub const TCSANOW: c_int = 0; +pub const TCSADRAIN: c_int = 1; +pub const TCSAFLUSH: c_int = 2; + +pub const SFD_CLOEXEC: c_int = 0x080000; + +pub const NCCS: usize = 32; + +pub const O_TRUNC: c_int = 512; + +pub const O_CLOEXEC: c_int = 0x80000; + +pub const EBFONT: c_int = 59; +pub const ENOSTR: c_int = 60; +pub const ENODATA: c_int = 61; +pub const ETIME: c_int = 62; +pub const ENOSR: c_int = 63; +pub const ENONET: c_int = 64; +pub const ENOPKG: c_int = 65; +pub const EREMOTE: c_int = 66; +pub const ENOLINK: c_int = 67; +pub const EADV: c_int = 68; +pub const ESRMNT: c_int = 69; +pub const ECOMM: c_int = 70; +pub const EPROTO: c_int = 71; +pub const EDOTDOT: c_int = 73; + +pub const SA_NODEFER: c_int = 0x40000000; +pub const SA_RESETHAND: c_int = 0x80000000; +pub const SA_RESTART: c_int = 0x10000000; +pub const SA_NOCLDSTOP: c_int = 0x00000001; + +pub const EPOLL_CLOEXEC: c_int = 0x80000; + +pub const EFD_CLOEXEC: c_int = 0x80000; + +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; + +pub const O_DIRECT: c_int = 0x4000; +pub const O_DIRECTORY: c_int = 0x10000; +pub const O_NOFOLLOW: c_int = 0x20000; + +pub const MAP_HUGETLB: c_int = 0x040000; +pub const MAP_LOCKED: c_int = 0x02000; +pub const MAP_NORESERVE: c_int = 0x04000; +pub const MAP_32BIT: c_int = 0x0040; +pub const MAP_ANON: c_int = 0x0020; +pub const MAP_ANONYMOUS: c_int = 0x0020; +pub const MAP_DENYWRITE: c_int = 0x0800; +pub const MAP_EXECUTABLE: c_int = 0x01000; +pub const MAP_POPULATE: c_int = 0x08000; +pub const MAP_NONBLOCK: c_int = 0x010000; +pub const MAP_STACK: c_int = 0x020000; +pub const MAP_SYNC: c_int = 0x080000; + +pub const EDEADLOCK: c_int = 35; +pub const EUCLEAN: c_int = 117; +pub const ENOTNAM: c_int = 118; +pub const ENAVAIL: c_int = 119; +pub const EISNAM: c_int = 120; +pub const EREMOTEIO: c_int = 121; + +pub const PTRACE_GETFPREGS: c_uint = 14; +pub const PTRACE_SETFPREGS: c_uint = 15; +pub const PTRACE_GETFPXREGS: c_uint = 18; +pub const PTRACE_SETFPXREGS: c_uint = 19; +pub const PTRACE_GETREGS: c_uint = 12; +pub const PTRACE_SETREGS: c_uint = 13; +pub const PTRACE_PEEKSIGINFO_SHARED: c_uint = 1; +pub const PTRACE_SYSEMU: c_uint = 31; +pub const PTRACE_SYSEMU_SINGLESTEP: c_uint = 32; + +pub const PR_GET_SPECULATION_CTRL: c_int = 52; +pub const PR_SET_SPECULATION_CTRL: c_int = 53; +pub const PR_SPEC_NOT_AFFECTED: c_uint = 0; +pub const PR_SPEC_PRCTL: c_uint = 1 << 0; +pub const PR_SPEC_ENABLE: c_uint = 1 << 1; +pub const PR_SPEC_DISABLE: c_uint = 1 << 2; +pub const PR_SPEC_FORCE_DISABLE: c_uint = 1 << 3; +pub const PR_SPEC_DISABLE_NOEXEC: c_uint = 1 << 4; +pub const PR_SPEC_STORE_BYPASS: c_int = 0; +pub const PR_SPEC_INDIRECT_BRANCH: c_int = 1; +// FIXME(linux): perharps for later +//pub const PR_SPEC_L1D_FLUSH: c_int = 2; + +pub const MCL_CURRENT: c_int = 0x0001; +pub const MCL_FUTURE: c_int = 0x0002; +pub const MCL_ONFAULT: c_int = 0x0004; + +pub const SIGSTKSZ: size_t = 8192; +pub const MINSIGSTKSZ: size_t = 2048; +pub const CBAUD: crate::tcflag_t = 0o0010017; +pub const TAB1: crate::tcflag_t = 0x00000800; +pub const TAB2: crate::tcflag_t = 0x00001000; +pub const TAB3: crate::tcflag_t = 0x00001800; +pub const CR1: crate::tcflag_t = 0x00000200; +pub const CR2: crate::tcflag_t = 0x00000400; +pub const CR3: crate::tcflag_t = 0x00000600; +pub const FF1: crate::tcflag_t = 0x00008000; +pub const BS1: crate::tcflag_t = 0x00002000; +pub const VT1: crate::tcflag_t = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: crate::tcflag_t = 0x00000400; +pub const IXOFF: crate::tcflag_t = 0x00001000; +pub const ONLCR: crate::tcflag_t = 0x4; +pub const CSIZE: crate::tcflag_t = 0x00000030; +pub const CS6: crate::tcflag_t = 0x00000010; +pub const CS7: crate::tcflag_t = 0x00000020; +pub const CS8: crate::tcflag_t = 0x00000030; +pub const CSTOPB: crate::tcflag_t = 0x00000040; +pub const CREAD: crate::tcflag_t = 0x00000080; +pub const PARENB: crate::tcflag_t = 0x00000100; +pub const PARODD: crate::tcflag_t = 0x00000200; +pub const HUPCL: crate::tcflag_t = 0x00000400; +pub const CLOCAL: crate::tcflag_t = 0x00000800; +pub const ECHOKE: crate::tcflag_t = 0x00000800; +pub const ECHOE: crate::tcflag_t = 0x00000010; +pub const ECHOK: crate::tcflag_t = 0x00000020; +pub const ECHONL: crate::tcflag_t = 0x00000040; +pub const ECHOPRT: crate::tcflag_t = 0x00000400; +pub const ECHOCTL: crate::tcflag_t = 0x00000200; +pub const ISIG: crate::tcflag_t = 0x00000001; +pub const ICANON: crate::tcflag_t = 0x00000002; +pub const PENDIN: crate::tcflag_t = 0x00004000; +pub const NOFLSH: crate::tcflag_t = 0x00000080; +pub const CIBAUD: crate::tcflag_t = 0o02003600000; +pub const CBAUDEX: crate::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: crate::tcflag_t = 0o000002; +pub const NLDLY: crate::tcflag_t = 0o000400; +pub const CRDLY: crate::tcflag_t = 0o003000; +pub const TABDLY: crate::tcflag_t = 0o014000; +pub const BSDLY: crate::tcflag_t = 0o020000; +pub const FFDLY: crate::tcflag_t = 0o100000; +pub const VTDLY: crate::tcflag_t = 0o040000; +pub const XTABS: crate::tcflag_t = 0o014000; + +pub const B0: crate::speed_t = 0o000000; +pub const B50: crate::speed_t = 0o000001; +pub const B75: crate::speed_t = 0o000002; +pub const B110: crate::speed_t = 0o000003; +pub const B134: crate::speed_t = 0o000004; +pub const B150: crate::speed_t = 0o000005; +pub const B200: crate::speed_t = 0o000006; +pub const B300: crate::speed_t = 0o000007; +pub const B600: crate::speed_t = 0o000010; +pub const B1200: crate::speed_t = 0o000011; +pub const B1800: crate::speed_t = 0o000012; +pub const B2400: crate::speed_t = 0o000013; +pub const B4800: crate::speed_t = 0o000014; +pub const B9600: crate::speed_t = 0o000015; +pub const B19200: crate::speed_t = 0o000016; +pub const B38400: crate::speed_t = 0o000017; +pub const EXTA: crate::speed_t = B19200; +pub const EXTB: crate::speed_t = B38400; +pub const B57600: crate::speed_t = 0o010001; +pub const B115200: crate::speed_t = 0o010002; +pub const B230400: crate::speed_t = 0o010003; +pub const B460800: crate::speed_t = 0o010004; +pub const B500000: crate::speed_t = 0o010005; +pub const B576000: crate::speed_t = 0o010006; +pub const B921600: crate::speed_t = 0o010007; +pub const B1000000: crate::speed_t = 0o010010; +pub const B1152000: crate::speed_t = 0o010011; +pub const B1500000: crate::speed_t = 0o010012; +pub const B2000000: crate::speed_t = 0o010013; +pub const B2500000: crate::speed_t = 0o010014; +pub const B3000000: crate::speed_t = 0o010015; +pub const B3500000: crate::speed_t = 0o010016; +pub const B4000000: crate::speed_t = 0o010017; + +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: crate::tcflag_t = 0x00008000; +pub const TOSTOP: crate::tcflag_t = 0x00000100; +pub const FLUSHO: crate::tcflag_t = 0x00001000; +pub const EXTPROC: crate::tcflag_t = 0x00010000; + +// offsets in user_regs_structs, from sys/reg.h +pub const R15: c_int = 0; +pub const R14: c_int = 1; +pub const R13: c_int = 2; +pub const R12: c_int = 3; +pub const RBP: c_int = 4; +pub const RBX: c_int = 5; +pub const R11: c_int = 6; +pub const R10: c_int = 7; +pub const R9: c_int = 8; +pub const R8: c_int = 9; +pub const RAX: c_int = 10; +pub const RCX: c_int = 11; +pub const RDX: c_int = 12; +pub const RSI: c_int = 13; +pub const RDI: c_int = 14; +pub const ORIG_RAX: c_int = 15; +pub const RIP: c_int = 16; +pub const CS: c_int = 17; +pub const EFLAGS: c_int = 18; +pub const RSP: c_int = 19; +pub const SS: c_int = 20; +pub const FS_BASE: c_int = 21; +pub const GS_BASE: c_int = 22; +pub const DS: c_int = 23; +pub const ES: c_int = 24; +pub const FS: c_int = 25; +pub const GS: c_int = 26; + +// offsets in mcontext_t.gregs from sys/ucontext.h +pub const REG_R8: c_int = 0; +pub const REG_R9: c_int = 1; +pub const REG_R10: c_int = 2; +pub const REG_R11: c_int = 3; +pub const REG_R12: c_int = 4; +pub const REG_R13: c_int = 5; +pub const REG_R14: c_int = 6; +pub const REG_R15: c_int = 7; +pub const REG_RDI: c_int = 8; +pub const REG_RSI: c_int = 9; +pub const REG_RBP: c_int = 10; +pub const REG_RBX: c_int = 11; +pub const REG_RDX: c_int = 12; +pub const REG_RAX: c_int = 13; +pub const REG_RCX: c_int = 14; +pub const REG_RSP: c_int = 15; +pub const REG_RIP: c_int = 16; +pub const REG_EFL: c_int = 17; +pub const REG_CSGSFS: c_int = 18; +pub const REG_ERR: c_int = 19; +pub const REG_TRAPNO: c_int = 20; +pub const REG_OLDMASK: c_int = 21; +pub const REG_CR2: c_int = 22; + +extern "C" { + pub fn getcontext(ucp: *mut ucontext_t) -> c_int; + pub fn setcontext(ucp: *const ucontext_t) -> c_int; + pub fn makecontext(ucp: *mut ucontext_t, func: extern "C" fn(), argc: c_int, ...); + pub fn swapcontext(uocp: *mut ucontext_t, ucp: *const ucontext_t) -> c_int; +} + +cfg_if! { + if #[cfg(target_pointer_width = "32")] { + mod x32; + pub use self::x32::*; + } else { + mod not_x32; + pub use self::not_x32::*; + } +} diff --git a/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs b/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs new file mode 100644 index 0000000..27b96a6 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs @@ -0,0 +1,446 @@ +use crate::prelude::*; +use crate::pthread_mutex_t; + +s! { + pub struct statvfs { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_favail: crate::fsfilcnt_t, + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: [c_int; 6], + } +} + +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; +pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; + +#[cfg(target_endian = "little")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "little")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; +#[cfg(target_endian = "big")] +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ], +}; + +// Syscall table + +pub const SYS_read: c_long = 0; +pub const SYS_write: c_long = 1; +pub const SYS_open: c_long = 2; +pub const SYS_close: c_long = 3; +pub const SYS_stat: c_long = 4; +pub const SYS_fstat: c_long = 5; +pub const SYS_lstat: c_long = 6; +pub const SYS_poll: c_long = 7; +pub const SYS_lseek: c_long = 8; +pub const SYS_mmap: c_long = 9; +pub const SYS_mprotect: c_long = 10; +pub const SYS_munmap: c_long = 11; +pub const SYS_brk: c_long = 12; +pub const SYS_rt_sigaction: c_long = 13; +pub const SYS_rt_sigprocmask: c_long = 14; +pub const SYS_rt_sigreturn: c_long = 15; +pub const SYS_ioctl: c_long = 16; +pub const SYS_pread64: c_long = 17; +pub const SYS_pwrite64: c_long = 18; +pub const SYS_readv: c_long = 19; +pub const SYS_writev: c_long = 20; +pub const SYS_access: c_long = 21; +pub const SYS_pipe: c_long = 22; +pub const SYS_select: c_long = 23; +pub const SYS_sched_yield: c_long = 24; +pub const SYS_mremap: c_long = 25; +pub const SYS_msync: c_long = 26; +pub const SYS_mincore: c_long = 27; +pub const SYS_madvise: c_long = 28; +pub const SYS_shmget: c_long = 29; +pub const SYS_shmat: c_long = 30; +pub const SYS_shmctl: c_long = 31; +pub const SYS_dup: c_long = 32; +pub const SYS_dup2: c_long = 33; +pub const SYS_pause: c_long = 34; +pub const SYS_nanosleep: c_long = 35; +pub const SYS_getitimer: c_long = 36; +pub const SYS_alarm: c_long = 37; +pub const SYS_setitimer: c_long = 38; +pub const SYS_getpid: c_long = 39; +pub const SYS_sendfile: c_long = 40; +pub const SYS_socket: c_long = 41; +pub const SYS_connect: c_long = 42; +pub const SYS_accept: c_long = 43; +pub const SYS_sendto: c_long = 44; +pub const SYS_recvfrom: c_long = 45; +pub const SYS_sendmsg: c_long = 46; +pub const SYS_recvmsg: c_long = 47; +pub const SYS_shutdown: c_long = 48; +pub const SYS_bind: c_long = 49; +pub const SYS_listen: c_long = 50; +pub const SYS_getsockname: c_long = 51; +pub const SYS_getpeername: c_long = 52; +pub const SYS_socketpair: c_long = 53; +pub const SYS_setsockopt: c_long = 54; +pub const SYS_getsockopt: c_long = 55; +pub const SYS_clone: c_long = 56; +pub const SYS_fork: c_long = 57; +pub const SYS_vfork: c_long = 58; +pub const SYS_execve: c_long = 59; +pub const SYS_exit: c_long = 60; +pub const SYS_wait4: c_long = 61; +pub const SYS_kill: c_long = 62; +pub const SYS_uname: c_long = 63; +pub const SYS_semget: c_long = 64; +pub const SYS_semop: c_long = 65; +pub const SYS_semctl: c_long = 66; +pub const SYS_shmdt: c_long = 67; +pub const SYS_msgget: c_long = 68; +pub const SYS_msgsnd: c_long = 69; +pub const SYS_msgrcv: c_long = 70; +pub const SYS_msgctl: c_long = 71; +pub const SYS_fcntl: c_long = 72; +pub const SYS_flock: c_long = 73; +pub const SYS_fsync: c_long = 74; +pub const SYS_fdatasync: c_long = 75; +pub const SYS_truncate: c_long = 76; +pub const SYS_ftruncate: c_long = 77; +pub const SYS_getdents: c_long = 78; +pub const SYS_getcwd: c_long = 79; +pub const SYS_chdir: c_long = 80; +pub const SYS_fchdir: c_long = 81; +pub const SYS_rename: c_long = 82; +pub const SYS_mkdir: c_long = 83; +pub const SYS_rmdir: c_long = 84; +pub const SYS_creat: c_long = 85; +pub const SYS_link: c_long = 86; +pub const SYS_unlink: c_long = 87; +pub const SYS_symlink: c_long = 88; +pub const SYS_readlink: c_long = 89; +pub const SYS_chmod: c_long = 90; +pub const SYS_fchmod: c_long = 91; +pub const SYS_chown: c_long = 92; +pub const SYS_fchown: c_long = 93; +pub const SYS_lchown: c_long = 94; +pub const SYS_umask: c_long = 95; +pub const SYS_gettimeofday: c_long = 96; +pub const SYS_getrlimit: c_long = 97; +pub const SYS_getrusage: c_long = 98; +pub const SYS_sysinfo: c_long = 99; +pub const SYS_times: c_long = 100; +pub const SYS_ptrace: c_long = 101; +pub const SYS_getuid: c_long = 102; +pub const SYS_syslog: c_long = 103; +pub const SYS_getgid: c_long = 104; +pub const SYS_setuid: c_long = 105; +pub const SYS_setgid: c_long = 106; +pub const SYS_geteuid: c_long = 107; +pub const SYS_getegid: c_long = 108; +pub const SYS_setpgid: c_long = 109; +pub const SYS_getppid: c_long = 110; +pub const SYS_getpgrp: c_long = 111; +pub const SYS_setsid: c_long = 112; +pub const SYS_setreuid: c_long = 113; +pub const SYS_setregid: c_long = 114; +pub const SYS_getgroups: c_long = 115; +pub const SYS_setgroups: c_long = 116; +pub const SYS_setresuid: c_long = 117; +pub const SYS_getresuid: c_long = 118; +pub const SYS_setresgid: c_long = 119; +pub const SYS_getresgid: c_long = 120; +pub const SYS_getpgid: c_long = 121; +pub const SYS_setfsuid: c_long = 122; +pub const SYS_setfsgid: c_long = 123; +pub const SYS_getsid: c_long = 124; +pub const SYS_capget: c_long = 125; +pub const SYS_capset: c_long = 126; +pub const SYS_rt_sigpending: c_long = 127; +pub const SYS_rt_sigtimedwait: c_long = 128; +pub const SYS_rt_sigqueueinfo: c_long = 129; +pub const SYS_rt_sigsuspend: c_long = 130; +pub const SYS_sigaltstack: c_long = 131; +pub const SYS_utime: c_long = 132; +pub const SYS_mknod: c_long = 133; +pub const SYS_uselib: c_long = 134; +pub const SYS_personality: c_long = 135; +pub const SYS_ustat: c_long = 136; +pub const SYS_statfs: c_long = 137; +pub const SYS_fstatfs: c_long = 138; +pub const SYS_sysfs: c_long = 139; +pub const SYS_getpriority: c_long = 140; +pub const SYS_setpriority: c_long = 141; +pub const SYS_sched_setparam: c_long = 142; +pub const SYS_sched_getparam: c_long = 143; +pub const SYS_sched_setscheduler: c_long = 144; +pub const SYS_sched_getscheduler: c_long = 145; +pub const SYS_sched_get_priority_max: c_long = 146; +pub const SYS_sched_get_priority_min: c_long = 147; +pub const SYS_sched_rr_get_interval: c_long = 148; +pub const SYS_mlock: c_long = 149; +pub const SYS_munlock: c_long = 150; +pub const SYS_mlockall: c_long = 151; +pub const SYS_munlockall: c_long = 152; +pub const SYS_vhangup: c_long = 153; +pub const SYS_modify_ldt: c_long = 154; +pub const SYS_pivot_root: c_long = 155; +pub const SYS__sysctl: c_long = 156; +pub const SYS_prctl: c_long = 157; +pub const SYS_arch_prctl: c_long = 158; +pub const SYS_adjtimex: c_long = 159; +pub const SYS_setrlimit: c_long = 160; +pub const SYS_chroot: c_long = 161; +pub const SYS_sync: c_long = 162; +pub const SYS_acct: c_long = 163; +pub const SYS_settimeofday: c_long = 164; +pub const SYS_mount: c_long = 165; +pub const SYS_umount2: c_long = 166; +pub const SYS_swapon: c_long = 167; +pub const SYS_swapoff: c_long = 168; +pub const SYS_reboot: c_long = 169; +pub const SYS_sethostname: c_long = 170; +pub const SYS_setdomainname: c_long = 171; +pub const SYS_iopl: c_long = 172; +pub const SYS_ioperm: c_long = 173; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_create_module: c_long = 174; +pub const SYS_init_module: c_long = 175; +pub const SYS_delete_module: c_long = 176; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_get_kernel_syms: c_long = 177; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_query_module: c_long = 178; +pub const SYS_quotactl: c_long = 179; +pub const SYS_nfsservctl: c_long = 180; +pub const SYS_getpmsg: c_long = 181; +pub const SYS_putpmsg: c_long = 182; +pub const SYS_afs_syscall: c_long = 183; +pub const SYS_tuxcall: c_long = 184; +pub const SYS_security: c_long = 185; +pub const SYS_gettid: c_long = 186; +pub const SYS_readahead: c_long = 187; +pub const SYS_setxattr: c_long = 188; +pub const SYS_lsetxattr: c_long = 189; +pub const SYS_fsetxattr: c_long = 190; +pub const SYS_getxattr: c_long = 191; +pub const SYS_lgetxattr: c_long = 192; +pub const SYS_fgetxattr: c_long = 193; +pub const SYS_listxattr: c_long = 194; +pub const SYS_llistxattr: c_long = 195; +pub const SYS_flistxattr: c_long = 196; +pub const SYS_removexattr: c_long = 197; +pub const SYS_lremovexattr: c_long = 198; +pub const SYS_fremovexattr: c_long = 199; +pub const SYS_tkill: c_long = 200; +pub const SYS_time: c_long = 201; +pub const SYS_futex: c_long = 202; +pub const SYS_sched_setaffinity: c_long = 203; +pub const SYS_sched_getaffinity: c_long = 204; +pub const SYS_set_thread_area: c_long = 205; +pub const SYS_io_setup: c_long = 206; +pub const SYS_io_destroy: c_long = 207; +pub const SYS_io_getevents: c_long = 208; +pub const SYS_io_submit: c_long = 209; +pub const SYS_io_cancel: c_long = 210; +pub const SYS_get_thread_area: c_long = 211; +pub const SYS_lookup_dcookie: c_long = 212; +pub const SYS_epoll_create: c_long = 213; +pub const SYS_epoll_ctl_old: c_long = 214; +pub const SYS_epoll_wait_old: c_long = 215; +pub const SYS_remap_file_pages: c_long = 216; +pub const SYS_getdents64: c_long = 217; +pub const SYS_set_tid_address: c_long = 218; +pub const SYS_restart_syscall: c_long = 219; +pub const SYS_semtimedop: c_long = 220; +pub const SYS_fadvise64: c_long = 221; +pub const SYS_timer_create: c_long = 222; +pub const SYS_timer_settime: c_long = 223; +pub const SYS_timer_gettime: c_long = 224; +pub const SYS_timer_getoverrun: c_long = 225; +pub const SYS_timer_delete: c_long = 226; +pub const SYS_clock_settime: c_long = 227; +pub const SYS_clock_gettime: c_long = 228; +pub const SYS_clock_getres: c_long = 229; +pub const SYS_clock_nanosleep: c_long = 230; +pub const SYS_exit_group: c_long = 231; +pub const SYS_epoll_wait: c_long = 232; +pub const SYS_epoll_ctl: c_long = 233; +pub const SYS_tgkill: c_long = 234; +pub const SYS_utimes: c_long = 235; +pub const SYS_vserver: c_long = 236; +pub const SYS_mbind: c_long = 237; +pub const SYS_set_mempolicy: c_long = 238; +pub const SYS_get_mempolicy: c_long = 239; +pub const SYS_mq_open: c_long = 240; +pub const SYS_mq_unlink: c_long = 241; +pub const SYS_mq_timedsend: c_long = 242; +pub const SYS_mq_timedreceive: c_long = 243; +pub const SYS_mq_notify: c_long = 244; +pub const SYS_mq_getsetattr: c_long = 245; +pub const SYS_kexec_load: c_long = 246; +pub const SYS_waitid: c_long = 247; +pub const SYS_add_key: c_long = 248; +pub const SYS_request_key: c_long = 249; +pub const SYS_keyctl: c_long = 250; +pub const SYS_ioprio_set: c_long = 251; +pub const SYS_ioprio_get: c_long = 252; +pub const SYS_inotify_init: c_long = 253; +pub const SYS_inotify_add_watch: c_long = 254; +pub const SYS_inotify_rm_watch: c_long = 255; +pub const SYS_migrate_pages: c_long = 256; +pub const SYS_openat: c_long = 257; +pub const SYS_mkdirat: c_long = 258; +pub const SYS_mknodat: c_long = 259; +pub const SYS_fchownat: c_long = 260; +pub const SYS_futimesat: c_long = 261; +pub const SYS_newfstatat: c_long = 262; +pub const SYS_unlinkat: c_long = 263; +pub const SYS_renameat: c_long = 264; +pub const SYS_linkat: c_long = 265; +pub const SYS_symlinkat: c_long = 266; +pub const SYS_readlinkat: c_long = 267; +pub const SYS_fchmodat: c_long = 268; +pub const SYS_faccessat: c_long = 269; +pub const SYS_pselect6: c_long = 270; +pub const SYS_ppoll: c_long = 271; +pub const SYS_unshare: c_long = 272; +pub const SYS_set_robust_list: c_long = 273; +pub const SYS_get_robust_list: c_long = 274; +pub const SYS_splice: c_long = 275; +pub const SYS_tee: c_long = 276; +pub const SYS_sync_file_range: c_long = 277; +pub const SYS_vmsplice: c_long = 278; +pub const SYS_move_pages: c_long = 279; +pub const SYS_utimensat: c_long = 280; +pub const SYS_epoll_pwait: c_long = 281; +pub const SYS_signalfd: c_long = 282; +pub const SYS_timerfd_create: c_long = 283; +pub const SYS_eventfd: c_long = 284; +pub const SYS_fallocate: c_long = 285; +pub const SYS_timerfd_settime: c_long = 286; +pub const SYS_timerfd_gettime: c_long = 287; +pub const SYS_accept4: c_long = 288; +pub const SYS_signalfd4: c_long = 289; +pub const SYS_eventfd2: c_long = 290; +pub const SYS_epoll_create1: c_long = 291; +pub const SYS_dup3: c_long = 292; +pub const SYS_pipe2: c_long = 293; +pub const SYS_inotify_init1: c_long = 294; +pub const SYS_preadv: c_long = 295; +pub const SYS_pwritev: c_long = 296; +pub const SYS_rt_tgsigqueueinfo: c_long = 297; +pub const SYS_perf_event_open: c_long = 298; +pub const SYS_recvmmsg: c_long = 299; +pub const SYS_fanotify_init: c_long = 300; +pub const SYS_fanotify_mark: c_long = 301; +pub const SYS_prlimit64: c_long = 302; +pub const SYS_name_to_handle_at: c_long = 303; +pub const SYS_open_by_handle_at: c_long = 304; +pub const SYS_clock_adjtime: c_long = 305; +pub const SYS_syncfs: c_long = 306; +pub const SYS_sendmmsg: c_long = 307; +pub const SYS_setns: c_long = 308; +pub const SYS_getcpu: c_long = 309; +pub const SYS_process_vm_readv: c_long = 310; +pub const SYS_process_vm_writev: c_long = 311; +pub const SYS_kcmp: c_long = 312; +pub const SYS_finit_module: c_long = 313; +pub const SYS_sched_setattr: c_long = 314; +pub const SYS_sched_getattr: c_long = 315; +pub const SYS_renameat2: c_long = 316; +pub const SYS_seccomp: c_long = 317; +pub const SYS_getrandom: c_long = 318; +pub const SYS_memfd_create: c_long = 319; +pub const SYS_kexec_file_load: c_long = 320; +pub const SYS_bpf: c_long = 321; +pub const SYS_execveat: c_long = 322; +pub const SYS_userfaultfd: c_long = 323; +pub const SYS_membarrier: c_long = 324; +pub const SYS_mlock2: c_long = 325; +pub const SYS_copy_file_range: c_long = 326; +pub const SYS_preadv2: c_long = 327; +pub const SYS_pwritev2: c_long = 328; +pub const SYS_pkey_mprotect: c_long = 329; +pub const SYS_pkey_alloc: c_long = 330; +pub const SYS_pkey_free: c_long = 331; +pub const SYS_statx: c_long = 332; +pub const SYS_rseq: c_long = 334; +pub const SYS_pidfd_send_signal: c_long = 424; +pub const SYS_io_uring_setup: c_long = 425; +pub const SYS_io_uring_enter: c_long = 426; +pub const SYS_io_uring_register: c_long = 427; +pub const SYS_open_tree: c_long = 428; +pub const SYS_move_mount: c_long = 429; +pub const SYS_fsopen: c_long = 430; +pub const SYS_fsconfig: c_long = 431; +pub const SYS_fsmount: c_long = 432; +pub const SYS_fspick: c_long = 433; +pub const SYS_pidfd_open: c_long = 434; +pub const SYS_clone3: c_long = 435; +pub const SYS_close_range: c_long = 436; +pub const SYS_openat2: c_long = 437; +pub const SYS_pidfd_getfd: c_long = 438; +pub const SYS_faccessat2: c_long = 439; +pub const SYS_process_madvise: c_long = 440; +pub const SYS_epoll_pwait2: c_long = 441; +pub const SYS_mount_setattr: c_long = 442; +pub const SYS_quotactl_fd: c_long = 443; +pub const SYS_landlock_create_ruleset: c_long = 444; +pub const SYS_landlock_add_rule: c_long = 445; +pub const SYS_landlock_restrict_self: c_long = 446; +pub const SYS_memfd_secret: c_long = 447; +pub const SYS_process_mrelease: c_long = 448; +pub const SYS_futex_waitv: c_long = 449; +pub const SYS_set_mempolicy_home_node: c_long = 450; +pub const SYS_fchmodat2: c_long = 452; +pub const SYS_mseal: c_long = 462; + +extern "C" { + pub fn sysctl( + name: *mut c_int, + namelen: c_int, + oldp: *mut c_void, + oldlenp: *mut size_t, + newp: *mut c_void, + newlen: size_t, + ) -> c_int; +} diff --git a/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs b/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs new file mode 100644 index 0000000..1a1cd34 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs @@ -0,0 +1,398 @@ +use crate::prelude::*; +use crate::pthread_mutex_t; + +s! { + pub struct statvfs { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_favail: crate::fsfilcnt_t, + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: [c_int; 6], + } +} + +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 32; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 44; +pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 20; + +pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ], +}; +pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ], +}; +pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: crate::pthread_mutex_t = pthread_mutex_t { + size: [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, + ], +}; + +// Syscall table + +pub const __X32_SYSCALL_BIT: c_long = 0x40000000; + +pub const SYS_read: c_long = __X32_SYSCALL_BIT + 0; +pub const SYS_write: c_long = __X32_SYSCALL_BIT + 1; +pub const SYS_open: c_long = __X32_SYSCALL_BIT + 2; +pub const SYS_close: c_long = __X32_SYSCALL_BIT + 3; +pub const SYS_stat: c_long = __X32_SYSCALL_BIT + 4; +pub const SYS_fstat: c_long = __X32_SYSCALL_BIT + 5; +pub const SYS_lstat: c_long = __X32_SYSCALL_BIT + 6; +pub const SYS_poll: c_long = __X32_SYSCALL_BIT + 7; +pub const SYS_lseek: c_long = __X32_SYSCALL_BIT + 8; +pub const SYS_mmap: c_long = __X32_SYSCALL_BIT + 9; +pub const SYS_mprotect: c_long = __X32_SYSCALL_BIT + 10; +pub const SYS_munmap: c_long = __X32_SYSCALL_BIT + 11; +pub const SYS_brk: c_long = __X32_SYSCALL_BIT + 12; +pub const SYS_rt_sigprocmask: c_long = __X32_SYSCALL_BIT + 14; +pub const SYS_pread64: c_long = __X32_SYSCALL_BIT + 17; +pub const SYS_pwrite64: c_long = __X32_SYSCALL_BIT + 18; +pub const SYS_access: c_long = __X32_SYSCALL_BIT + 21; +pub const SYS_pipe: c_long = __X32_SYSCALL_BIT + 22; +pub const SYS_select: c_long = __X32_SYSCALL_BIT + 23; +pub const SYS_sched_yield: c_long = __X32_SYSCALL_BIT + 24; +pub const SYS_mremap: c_long = __X32_SYSCALL_BIT + 25; +pub const SYS_msync: c_long = __X32_SYSCALL_BIT + 26; +pub const SYS_mincore: c_long = __X32_SYSCALL_BIT + 27; +pub const SYS_madvise: c_long = __X32_SYSCALL_BIT + 28; +pub const SYS_shmget: c_long = __X32_SYSCALL_BIT + 29; +pub const SYS_shmat: c_long = __X32_SYSCALL_BIT + 30; +pub const SYS_shmctl: c_long = __X32_SYSCALL_BIT + 31; +pub const SYS_dup: c_long = __X32_SYSCALL_BIT + 32; +pub const SYS_dup2: c_long = __X32_SYSCALL_BIT + 33; +pub const SYS_pause: c_long = __X32_SYSCALL_BIT + 34; +pub const SYS_nanosleep: c_long = __X32_SYSCALL_BIT + 35; +pub const SYS_getitimer: c_long = __X32_SYSCALL_BIT + 36; +pub const SYS_alarm: c_long = __X32_SYSCALL_BIT + 37; +pub const SYS_setitimer: c_long = __X32_SYSCALL_BIT + 38; +pub const SYS_getpid: c_long = __X32_SYSCALL_BIT + 39; +pub const SYS_sendfile: c_long = __X32_SYSCALL_BIT + 40; +pub const SYS_socket: c_long = __X32_SYSCALL_BIT + 41; +pub const SYS_connect: c_long = __X32_SYSCALL_BIT + 42; +pub const SYS_accept: c_long = __X32_SYSCALL_BIT + 43; +pub const SYS_sendto: c_long = __X32_SYSCALL_BIT + 44; +pub const SYS_shutdown: c_long = __X32_SYSCALL_BIT + 48; +pub const SYS_bind: c_long = __X32_SYSCALL_BIT + 49; +pub const SYS_listen: c_long = __X32_SYSCALL_BIT + 50; +pub const SYS_getsockname: c_long = __X32_SYSCALL_BIT + 51; +pub const SYS_getpeername: c_long = __X32_SYSCALL_BIT + 52; +pub const SYS_socketpair: c_long = __X32_SYSCALL_BIT + 53; +pub const SYS_clone: c_long = __X32_SYSCALL_BIT + 56; +pub const SYS_fork: c_long = __X32_SYSCALL_BIT + 57; +pub const SYS_vfork: c_long = __X32_SYSCALL_BIT + 58; +pub const SYS_exit: c_long = __X32_SYSCALL_BIT + 60; +pub const SYS_wait4: c_long = __X32_SYSCALL_BIT + 61; +pub const SYS_kill: c_long = __X32_SYSCALL_BIT + 62; +pub const SYS_uname: c_long = __X32_SYSCALL_BIT + 63; +pub const SYS_semget: c_long = __X32_SYSCALL_BIT + 64; +pub const SYS_semop: c_long = __X32_SYSCALL_BIT + 65; +pub const SYS_semctl: c_long = __X32_SYSCALL_BIT + 66; +pub const SYS_shmdt: c_long = __X32_SYSCALL_BIT + 67; +pub const SYS_msgget: c_long = __X32_SYSCALL_BIT + 68; +pub const SYS_msgsnd: c_long = __X32_SYSCALL_BIT + 69; +pub const SYS_msgrcv: c_long = __X32_SYSCALL_BIT + 70; +pub const SYS_msgctl: c_long = __X32_SYSCALL_BIT + 71; +pub const SYS_fcntl: c_long = __X32_SYSCALL_BIT + 72; +pub const SYS_flock: c_long = __X32_SYSCALL_BIT + 73; +pub const SYS_fsync: c_long = __X32_SYSCALL_BIT + 74; +pub const SYS_fdatasync: c_long = __X32_SYSCALL_BIT + 75; +pub const SYS_truncate: c_long = __X32_SYSCALL_BIT + 76; +pub const SYS_ftruncate: c_long = __X32_SYSCALL_BIT + 77; +pub const SYS_getdents: c_long = __X32_SYSCALL_BIT + 78; +pub const SYS_getcwd: c_long = __X32_SYSCALL_BIT + 79; +pub const SYS_chdir: c_long = __X32_SYSCALL_BIT + 80; +pub const SYS_fchdir: c_long = __X32_SYSCALL_BIT + 81; +pub const SYS_rename: c_long = __X32_SYSCALL_BIT + 82; +pub const SYS_mkdir: c_long = __X32_SYSCALL_BIT + 83; +pub const SYS_rmdir: c_long = __X32_SYSCALL_BIT + 84; +pub const SYS_creat: c_long = __X32_SYSCALL_BIT + 85; +pub const SYS_link: c_long = __X32_SYSCALL_BIT + 86; +pub const SYS_unlink: c_long = __X32_SYSCALL_BIT + 87; +pub const SYS_symlink: c_long = __X32_SYSCALL_BIT + 88; +pub const SYS_readlink: c_long = __X32_SYSCALL_BIT + 89; +pub const SYS_chmod: c_long = __X32_SYSCALL_BIT + 90; +pub const SYS_fchmod: c_long = __X32_SYSCALL_BIT + 91; +pub const SYS_chown: c_long = __X32_SYSCALL_BIT + 92; +pub const SYS_fchown: c_long = __X32_SYSCALL_BIT + 93; +pub const SYS_lchown: c_long = __X32_SYSCALL_BIT + 94; +pub const SYS_umask: c_long = __X32_SYSCALL_BIT + 95; +pub const SYS_gettimeofday: c_long = __X32_SYSCALL_BIT + 96; +pub const SYS_getrlimit: c_long = __X32_SYSCALL_BIT + 97; +pub const SYS_getrusage: c_long = __X32_SYSCALL_BIT + 98; +pub const SYS_sysinfo: c_long = __X32_SYSCALL_BIT + 99; +pub const SYS_times: c_long = __X32_SYSCALL_BIT + 100; +pub const SYS_getuid: c_long = __X32_SYSCALL_BIT + 102; +pub const SYS_syslog: c_long = __X32_SYSCALL_BIT + 103; +pub const SYS_getgid: c_long = __X32_SYSCALL_BIT + 104; +pub const SYS_setuid: c_long = __X32_SYSCALL_BIT + 105; +pub const SYS_setgid: c_long = __X32_SYSCALL_BIT + 106; +pub const SYS_geteuid: c_long = __X32_SYSCALL_BIT + 107; +pub const SYS_getegid: c_long = __X32_SYSCALL_BIT + 108; +pub const SYS_setpgid: c_long = __X32_SYSCALL_BIT + 109; +pub const SYS_getppid: c_long = __X32_SYSCALL_BIT + 110; +pub const SYS_getpgrp: c_long = __X32_SYSCALL_BIT + 111; +pub const SYS_setsid: c_long = __X32_SYSCALL_BIT + 112; +pub const SYS_setreuid: c_long = __X32_SYSCALL_BIT + 113; +pub const SYS_setregid: c_long = __X32_SYSCALL_BIT + 114; +pub const SYS_getgroups: c_long = __X32_SYSCALL_BIT + 115; +pub const SYS_setgroups: c_long = __X32_SYSCALL_BIT + 116; +pub const SYS_setresuid: c_long = __X32_SYSCALL_BIT + 117; +pub const SYS_getresuid: c_long = __X32_SYSCALL_BIT + 118; +pub const SYS_setresgid: c_long = __X32_SYSCALL_BIT + 119; +pub const SYS_getresgid: c_long = __X32_SYSCALL_BIT + 120; +pub const SYS_getpgid: c_long = __X32_SYSCALL_BIT + 121; +pub const SYS_setfsuid: c_long = __X32_SYSCALL_BIT + 122; +pub const SYS_setfsgid: c_long = __X32_SYSCALL_BIT + 123; +pub const SYS_getsid: c_long = __X32_SYSCALL_BIT + 124; +pub const SYS_capget: c_long = __X32_SYSCALL_BIT + 125; +pub const SYS_capset: c_long = __X32_SYSCALL_BIT + 126; +pub const SYS_rt_sigsuspend: c_long = __X32_SYSCALL_BIT + 130; +pub const SYS_utime: c_long = __X32_SYSCALL_BIT + 132; +pub const SYS_mknod: c_long = __X32_SYSCALL_BIT + 133; +pub const SYS_personality: c_long = __X32_SYSCALL_BIT + 135; +pub const SYS_ustat: c_long = __X32_SYSCALL_BIT + 136; +pub const SYS_statfs: c_long = __X32_SYSCALL_BIT + 137; +pub const SYS_fstatfs: c_long = __X32_SYSCALL_BIT + 138; +pub const SYS_sysfs: c_long = __X32_SYSCALL_BIT + 139; +pub const SYS_getpriority: c_long = __X32_SYSCALL_BIT + 140; +pub const SYS_setpriority: c_long = __X32_SYSCALL_BIT + 141; +pub const SYS_sched_setparam: c_long = __X32_SYSCALL_BIT + 142; +pub const SYS_sched_getparam: c_long = __X32_SYSCALL_BIT + 143; +pub const SYS_sched_setscheduler: c_long = __X32_SYSCALL_BIT + 144; +pub const SYS_sched_getscheduler: c_long = __X32_SYSCALL_BIT + 145; +pub const SYS_sched_get_priority_max: c_long = __X32_SYSCALL_BIT + 146; +pub const SYS_sched_get_priority_min: c_long = __X32_SYSCALL_BIT + 147; +pub const SYS_sched_rr_get_interval: c_long = __X32_SYSCALL_BIT + 148; +pub const SYS_mlock: c_long = __X32_SYSCALL_BIT + 149; +pub const SYS_munlock: c_long = __X32_SYSCALL_BIT + 150; +pub const SYS_mlockall: c_long = __X32_SYSCALL_BIT + 151; +pub const SYS_munlockall: c_long = __X32_SYSCALL_BIT + 152; +pub const SYS_vhangup: c_long = __X32_SYSCALL_BIT + 153; +pub const SYS_modify_ldt: c_long = __X32_SYSCALL_BIT + 154; +pub const SYS_pivot_root: c_long = __X32_SYSCALL_BIT + 155; +pub const SYS_prctl: c_long = __X32_SYSCALL_BIT + 157; +pub const SYS_arch_prctl: c_long = __X32_SYSCALL_BIT + 158; +pub const SYS_adjtimex: c_long = __X32_SYSCALL_BIT + 159; +pub const SYS_setrlimit: c_long = __X32_SYSCALL_BIT + 160; +pub const SYS_chroot: c_long = __X32_SYSCALL_BIT + 161; +pub const SYS_sync: c_long = __X32_SYSCALL_BIT + 162; +pub const SYS_acct: c_long = __X32_SYSCALL_BIT + 163; +pub const SYS_settimeofday: c_long = __X32_SYSCALL_BIT + 164; +pub const SYS_mount: c_long = __X32_SYSCALL_BIT + 165; +pub const SYS_umount2: c_long = __X32_SYSCALL_BIT + 166; +pub const SYS_swapon: c_long = __X32_SYSCALL_BIT + 167; +pub const SYS_swapoff: c_long = __X32_SYSCALL_BIT + 168; +pub const SYS_reboot: c_long = __X32_SYSCALL_BIT + 169; +pub const SYS_sethostname: c_long = __X32_SYSCALL_BIT + 170; +pub const SYS_setdomainname: c_long = __X32_SYSCALL_BIT + 171; +pub const SYS_iopl: c_long = __X32_SYSCALL_BIT + 172; +pub const SYS_ioperm: c_long = __X32_SYSCALL_BIT + 173; +pub const SYS_init_module: c_long = __X32_SYSCALL_BIT + 175; +pub const SYS_delete_module: c_long = __X32_SYSCALL_BIT + 176; +pub const SYS_quotactl: c_long = __X32_SYSCALL_BIT + 179; +pub const SYS_getpmsg: c_long = __X32_SYSCALL_BIT + 181; +pub const SYS_putpmsg: c_long = __X32_SYSCALL_BIT + 182; +pub const SYS_afs_syscall: c_long = __X32_SYSCALL_BIT + 183; +pub const SYS_tuxcall: c_long = __X32_SYSCALL_BIT + 184; +pub const SYS_security: c_long = __X32_SYSCALL_BIT + 185; +pub const SYS_gettid: c_long = __X32_SYSCALL_BIT + 186; +pub const SYS_readahead: c_long = __X32_SYSCALL_BIT + 187; +pub const SYS_setxattr: c_long = __X32_SYSCALL_BIT + 188; +pub const SYS_lsetxattr: c_long = __X32_SYSCALL_BIT + 189; +pub const SYS_fsetxattr: c_long = __X32_SYSCALL_BIT + 190; +pub const SYS_getxattr: c_long = __X32_SYSCALL_BIT + 191; +pub const SYS_lgetxattr: c_long = __X32_SYSCALL_BIT + 192; +pub const SYS_fgetxattr: c_long = __X32_SYSCALL_BIT + 193; +pub const SYS_listxattr: c_long = __X32_SYSCALL_BIT + 194; +pub const SYS_llistxattr: c_long = __X32_SYSCALL_BIT + 195; +pub const SYS_flistxattr: c_long = __X32_SYSCALL_BIT + 196; +pub const SYS_removexattr: c_long = __X32_SYSCALL_BIT + 197; +pub const SYS_lremovexattr: c_long = __X32_SYSCALL_BIT + 198; +pub const SYS_fremovexattr: c_long = __X32_SYSCALL_BIT + 199; +pub const SYS_tkill: c_long = __X32_SYSCALL_BIT + 200; +pub const SYS_time: c_long = __X32_SYSCALL_BIT + 201; +pub const SYS_futex: c_long = __X32_SYSCALL_BIT + 202; +pub const SYS_sched_setaffinity: c_long = __X32_SYSCALL_BIT + 203; +pub const SYS_sched_getaffinity: c_long = __X32_SYSCALL_BIT + 204; +pub const SYS_io_destroy: c_long = __X32_SYSCALL_BIT + 207; +pub const SYS_io_getevents: c_long = __X32_SYSCALL_BIT + 208; +pub const SYS_io_cancel: c_long = __X32_SYSCALL_BIT + 210; +pub const SYS_lookup_dcookie: c_long = __X32_SYSCALL_BIT + 212; +pub const SYS_epoll_create: c_long = __X32_SYSCALL_BIT + 213; +pub const SYS_remap_file_pages: c_long = __X32_SYSCALL_BIT + 216; +pub const SYS_getdents64: c_long = __X32_SYSCALL_BIT + 217; +pub const SYS_set_tid_address: c_long = __X32_SYSCALL_BIT + 218; +pub const SYS_restart_syscall: c_long = __X32_SYSCALL_BIT + 219; +pub const SYS_semtimedop: c_long = __X32_SYSCALL_BIT + 220; +pub const SYS_fadvise64: c_long = __X32_SYSCALL_BIT + 221; +pub const SYS_timer_settime: c_long = __X32_SYSCALL_BIT + 223; +pub const SYS_timer_gettime: c_long = __X32_SYSCALL_BIT + 224; +pub const SYS_timer_getoverrun: c_long = __X32_SYSCALL_BIT + 225; +pub const SYS_timer_delete: c_long = __X32_SYSCALL_BIT + 226; +pub const SYS_clock_settime: c_long = __X32_SYSCALL_BIT + 227; +pub const SYS_clock_gettime: c_long = __X32_SYSCALL_BIT + 228; +pub const SYS_clock_getres: c_long = __X32_SYSCALL_BIT + 229; +pub const SYS_clock_nanosleep: c_long = __X32_SYSCALL_BIT + 230; +pub const SYS_exit_group: c_long = __X32_SYSCALL_BIT + 231; +pub const SYS_epoll_wait: c_long = __X32_SYSCALL_BIT + 232; +pub const SYS_epoll_ctl: c_long = __X32_SYSCALL_BIT + 233; +pub const SYS_tgkill: c_long = __X32_SYSCALL_BIT + 234; +pub const SYS_utimes: c_long = __X32_SYSCALL_BIT + 235; +pub const SYS_mbind: c_long = __X32_SYSCALL_BIT + 237; +pub const SYS_set_mempolicy: c_long = __X32_SYSCALL_BIT + 238; +pub const SYS_get_mempolicy: c_long = __X32_SYSCALL_BIT + 239; +pub const SYS_mq_open: c_long = __X32_SYSCALL_BIT + 240; +pub const SYS_mq_unlink: c_long = __X32_SYSCALL_BIT + 241; +pub const SYS_mq_timedsend: c_long = __X32_SYSCALL_BIT + 242; +pub const SYS_mq_timedreceive: c_long = __X32_SYSCALL_BIT + 243; +pub const SYS_mq_getsetattr: c_long = __X32_SYSCALL_BIT + 245; +pub const SYS_add_key: c_long = __X32_SYSCALL_BIT + 248; +pub const SYS_request_key: c_long = __X32_SYSCALL_BIT + 249; +pub const SYS_keyctl: c_long = __X32_SYSCALL_BIT + 250; +pub const SYS_ioprio_set: c_long = __X32_SYSCALL_BIT + 251; +pub const SYS_ioprio_get: c_long = __X32_SYSCALL_BIT + 252; +pub const SYS_inotify_init: c_long = __X32_SYSCALL_BIT + 253; +pub const SYS_inotify_add_watch: c_long = __X32_SYSCALL_BIT + 254; +pub const SYS_inotify_rm_watch: c_long = __X32_SYSCALL_BIT + 255; +pub const SYS_migrate_pages: c_long = __X32_SYSCALL_BIT + 256; +pub const SYS_openat: c_long = __X32_SYSCALL_BIT + 257; +pub const SYS_mkdirat: c_long = __X32_SYSCALL_BIT + 258; +pub const SYS_mknodat: c_long = __X32_SYSCALL_BIT + 259; +pub const SYS_fchownat: c_long = __X32_SYSCALL_BIT + 260; +pub const SYS_futimesat: c_long = __X32_SYSCALL_BIT + 261; +pub const SYS_newfstatat: c_long = __X32_SYSCALL_BIT + 262; +pub const SYS_unlinkat: c_long = __X32_SYSCALL_BIT + 263; +pub const SYS_renameat: c_long = __X32_SYSCALL_BIT + 264; +pub const SYS_linkat: c_long = __X32_SYSCALL_BIT + 265; +pub const SYS_symlinkat: c_long = __X32_SYSCALL_BIT + 266; +pub const SYS_readlinkat: c_long = __X32_SYSCALL_BIT + 267; +pub const SYS_fchmodat: c_long = __X32_SYSCALL_BIT + 268; +pub const SYS_faccessat: c_long = __X32_SYSCALL_BIT + 269; +pub const SYS_pselect6: c_long = __X32_SYSCALL_BIT + 270; +pub const SYS_ppoll: c_long = __X32_SYSCALL_BIT + 271; +pub const SYS_unshare: c_long = __X32_SYSCALL_BIT + 272; +pub const SYS_splice: c_long = __X32_SYSCALL_BIT + 275; +pub const SYS_tee: c_long = __X32_SYSCALL_BIT + 276; +pub const SYS_sync_file_range: c_long = __X32_SYSCALL_BIT + 277; +pub const SYS_utimensat: c_long = __X32_SYSCALL_BIT + 280; +pub const SYS_epoll_pwait: c_long = __X32_SYSCALL_BIT + 281; +pub const SYS_signalfd: c_long = __X32_SYSCALL_BIT + 282; +pub const SYS_timerfd_create: c_long = __X32_SYSCALL_BIT + 283; +pub const SYS_eventfd: c_long = __X32_SYSCALL_BIT + 284; +pub const SYS_fallocate: c_long = __X32_SYSCALL_BIT + 285; +pub const SYS_timerfd_settime: c_long = __X32_SYSCALL_BIT + 286; +pub const SYS_timerfd_gettime: c_long = __X32_SYSCALL_BIT + 287; +pub const SYS_accept4: c_long = __X32_SYSCALL_BIT + 288; +pub const SYS_signalfd4: c_long = __X32_SYSCALL_BIT + 289; +pub const SYS_eventfd2: c_long = __X32_SYSCALL_BIT + 290; +pub const SYS_epoll_create1: c_long = __X32_SYSCALL_BIT + 291; +pub const SYS_dup3: c_long = __X32_SYSCALL_BIT + 292; +pub const SYS_pipe2: c_long = __X32_SYSCALL_BIT + 293; +pub const SYS_inotify_init1: c_long = __X32_SYSCALL_BIT + 294; +pub const SYS_perf_event_open: c_long = __X32_SYSCALL_BIT + 298; +pub const SYS_fanotify_init: c_long = __X32_SYSCALL_BIT + 300; +pub const SYS_fanotify_mark: c_long = __X32_SYSCALL_BIT + 301; +pub const SYS_prlimit64: c_long = __X32_SYSCALL_BIT + 302; +pub const SYS_name_to_handle_at: c_long = __X32_SYSCALL_BIT + 303; +pub const SYS_open_by_handle_at: c_long = __X32_SYSCALL_BIT + 304; +pub const SYS_clock_adjtime: c_long = __X32_SYSCALL_BIT + 305; +pub const SYS_syncfs: c_long = __X32_SYSCALL_BIT + 306; +pub const SYS_setns: c_long = __X32_SYSCALL_BIT + 308; +pub const SYS_getcpu: c_long = __X32_SYSCALL_BIT + 309; +pub const SYS_kcmp: c_long = __X32_SYSCALL_BIT + 312; +pub const SYS_finit_module: c_long = __X32_SYSCALL_BIT + 313; +pub const SYS_sched_setattr: c_long = __X32_SYSCALL_BIT + 314; +pub const SYS_sched_getattr: c_long = __X32_SYSCALL_BIT + 315; +pub const SYS_renameat2: c_long = __X32_SYSCALL_BIT + 316; +pub const SYS_seccomp: c_long = __X32_SYSCALL_BIT + 317; +pub const SYS_getrandom: c_long = __X32_SYSCALL_BIT + 318; +pub const SYS_memfd_create: c_long = __X32_SYSCALL_BIT + 319; +pub const SYS_kexec_file_load: c_long = __X32_SYSCALL_BIT + 320; +pub const SYS_bpf: c_long = __X32_SYSCALL_BIT + 321; +pub const SYS_userfaultfd: c_long = __X32_SYSCALL_BIT + 323; +pub const SYS_membarrier: c_long = __X32_SYSCALL_BIT + 324; +pub const SYS_mlock2: c_long = __X32_SYSCALL_BIT + 325; +pub const SYS_copy_file_range: c_long = __X32_SYSCALL_BIT + 326; +pub const SYS_pkey_mprotect: c_long = __X32_SYSCALL_BIT + 329; +pub const SYS_pkey_alloc: c_long = __X32_SYSCALL_BIT + 330; +pub const SYS_pkey_free: c_long = __X32_SYSCALL_BIT + 331; +pub const SYS_statx: c_long = __X32_SYSCALL_BIT + 332; +pub const SYS_rseq: c_long = __X32_SYSCALL_BIT + 334; +pub const SYS_pidfd_send_signal: c_long = __X32_SYSCALL_BIT + 424; +pub const SYS_io_uring_setup: c_long = __X32_SYSCALL_BIT + 425; +pub const SYS_io_uring_enter: c_long = __X32_SYSCALL_BIT + 426; +pub const SYS_io_uring_register: c_long = __X32_SYSCALL_BIT + 427; +pub const SYS_open_tree: c_long = __X32_SYSCALL_BIT + 428; +pub const SYS_move_mount: c_long = __X32_SYSCALL_BIT + 429; +pub const SYS_fsopen: c_long = __X32_SYSCALL_BIT + 430; +pub const SYS_fsconfig: c_long = __X32_SYSCALL_BIT + 431; +pub const SYS_fsmount: c_long = __X32_SYSCALL_BIT + 432; +pub const SYS_fspick: c_long = __X32_SYSCALL_BIT + 433; +pub const SYS_pidfd_open: c_long = __X32_SYSCALL_BIT + 434; +pub const SYS_clone3: c_long = __X32_SYSCALL_BIT + 435; +pub const SYS_close_range: c_long = __X32_SYSCALL_BIT + 436; +pub const SYS_openat2: c_long = __X32_SYSCALL_BIT + 437; +pub const SYS_pidfd_getfd: c_long = __X32_SYSCALL_BIT + 438; +pub const SYS_faccessat2: c_long = __X32_SYSCALL_BIT + 439; +pub const SYS_process_madvise: c_long = __X32_SYSCALL_BIT + 440; +pub const SYS_epoll_pwait2: c_long = __X32_SYSCALL_BIT + 441; +pub const SYS_mount_setattr: c_long = __X32_SYSCALL_BIT + 442; +pub const SYS_quotactl_fd: c_long = __X32_SYSCALL_BIT + 443; +pub const SYS_landlock_create_ruleset: c_long = __X32_SYSCALL_BIT + 444; +pub const SYS_landlock_add_rule: c_long = __X32_SYSCALL_BIT + 445; +pub const SYS_landlock_restrict_self: c_long = __X32_SYSCALL_BIT + 446; +pub const SYS_memfd_secret: c_long = __X32_SYSCALL_BIT + 447; +pub const SYS_process_mrelease: c_long = __X32_SYSCALL_BIT + 448; +pub const SYS_futex_waitv: c_long = __X32_SYSCALL_BIT + 449; +pub const SYS_set_mempolicy_home_node: c_long = __X32_SYSCALL_BIT + 450; +pub const SYS_fchmodat2: c_long = __X32_SYSCALL_BIT + 452; +pub const SYS_rt_sigaction: c_long = __X32_SYSCALL_BIT + 512; +pub const SYS_rt_sigreturn: c_long = __X32_SYSCALL_BIT + 513; +pub const SYS_ioctl: c_long = __X32_SYSCALL_BIT + 514; +pub const SYS_readv: c_long = __X32_SYSCALL_BIT + 515; +pub const SYS_writev: c_long = __X32_SYSCALL_BIT + 516; +pub const SYS_recvfrom: c_long = __X32_SYSCALL_BIT + 517; +pub const SYS_sendmsg: c_long = __X32_SYSCALL_BIT + 518; +pub const SYS_recvmsg: c_long = __X32_SYSCALL_BIT + 519; +pub const SYS_execve: c_long = __X32_SYSCALL_BIT + 520; +pub const SYS_ptrace: c_long = __X32_SYSCALL_BIT + 521; +pub const SYS_rt_sigpending: c_long = __X32_SYSCALL_BIT + 522; +pub const SYS_rt_sigtimedwait: c_long = __X32_SYSCALL_BIT + 523; +pub const SYS_rt_sigqueueinfo: c_long = __X32_SYSCALL_BIT + 524; +pub const SYS_sigaltstack: c_long = __X32_SYSCALL_BIT + 525; +pub const SYS_timer_create: c_long = __X32_SYSCALL_BIT + 526; +pub const SYS_mq_notify: c_long = __X32_SYSCALL_BIT + 527; +pub const SYS_kexec_load: c_long = __X32_SYSCALL_BIT + 528; +pub const SYS_waitid: c_long = __X32_SYSCALL_BIT + 529; +pub const SYS_set_robust_list: c_long = __X32_SYSCALL_BIT + 530; +pub const SYS_get_robust_list: c_long = __X32_SYSCALL_BIT + 531; +pub const SYS_vmsplice: c_long = __X32_SYSCALL_BIT + 532; +pub const SYS_move_pages: c_long = __X32_SYSCALL_BIT + 533; +pub const SYS_preadv: c_long = __X32_SYSCALL_BIT + 534; +pub const SYS_pwritev: c_long = __X32_SYSCALL_BIT + 535; +pub const SYS_rt_tgsigqueueinfo: c_long = __X32_SYSCALL_BIT + 536; +pub const SYS_recvmmsg: c_long = __X32_SYSCALL_BIT + 537; +pub const SYS_sendmmsg: c_long = __X32_SYSCALL_BIT + 538; +pub const SYS_process_vm_readv: c_long = __X32_SYSCALL_BIT + 539; +pub const SYS_process_vm_writev: c_long = __X32_SYSCALL_BIT + 540; +pub const SYS_setsockopt: c_long = __X32_SYSCALL_BIT + 541; +pub const SYS_getsockopt: c_long = __X32_SYSCALL_BIT + 542; +pub const SYS_io_setup: c_long = __X32_SYSCALL_BIT + 543; +pub const SYS_io_submit: c_long = __X32_SYSCALL_BIT + 544; +pub const SYS_execveat: c_long = __X32_SYSCALL_BIT + 545; +pub const SYS_preadv2: c_long = __X32_SYSCALL_BIT + 546; +pub const SYS_pwritev2: c_long = __X32_SYSCALL_BIT + 547; diff --git a/http/vendor/libc/src/unix/linux_like/linux/gnu/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/gnu/mod.rs new file mode 100644 index 0000000..65e94a1 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/gnu/mod.rs @@ -0,0 +1,1283 @@ +use crate::off64_t; +use crate::prelude::*; + +pub type pthread_t = c_ulong; +pub type __priority_which_t = c_uint; +pub type __rlimit_resource_t = c_uint; +pub type Lmid_t = c_long; +pub type regoff_t = c_int; +pub type __kernel_rwf_t = c_int; +pub type __be16 = crate::__u16; + +cfg_if! { + if #[cfg(doc)] { + // Used in `linux::arch` to define ioctl constants. + pub(crate) type Ioctl = c_ulong; + } else { + #[doc(hidden)] + pub type Ioctl = c_ulong; + } +} + +s! { + pub struct aiocb { + pub aio_fildes: c_int, + pub aio_lio_opcode: c_int, + pub aio_reqprio: c_int, + pub aio_buf: *mut c_void, + pub aio_nbytes: size_t, + pub aio_sigevent: crate::sigevent, + __next_prio: *mut aiocb, + __abs_prio: c_int, + __policy: c_int, + __error_code: c_int, + __return_value: ssize_t, + pub aio_offset: off_t, + #[cfg(all( + not(gnu_file_offset_bits64), + not(target_arch = "x86_64"), + target_pointer_width = "32" + ))] + __unused1: Padding<[c_char; 4]>, + __glibc_reserved: Padding<[c_char; 32]>, + } + + pub struct __exit_status { + pub e_termination: c_short, + pub e_exit: c_short, + } + + pub struct __timeval { + pub tv_sec: i32, + pub tv_usec: i32, + } + + pub struct glob64_t { + pub gl_pathc: size_t, + pub gl_pathv: *mut *mut c_char, + pub gl_offs: size_t, + pub gl_flags: c_int, + + __unused1: Padding<*mut c_void>, + __unused2: Padding<*mut c_void>, + __unused3: Padding<*mut c_void>, + __unused4: Padding<*mut c_void>, + __unused5: Padding<*mut c_void>, + } + + pub struct msghdr { + pub msg_name: *mut c_void, + pub msg_namelen: crate::socklen_t, + pub msg_iov: *mut crate::iovec, + pub msg_iovlen: size_t, + pub msg_control: *mut c_void, + pub msg_controllen: size_t, + pub msg_flags: c_int, + } + + pub struct cmsghdr { + pub cmsg_len: size_t, + pub cmsg_level: c_int, + pub cmsg_type: c_int, + } + + pub struct termios { + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_line: crate::cc_t, + pub c_cc: [crate::cc_t; crate::NCCS], + #[cfg(not(any( + target_arch = "sparc", + target_arch = "sparc64", + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "mips64", + target_arch = "mips64r6" + )))] + pub c_ispeed: crate::speed_t, + #[cfg(not(any( + target_arch = "sparc", + target_arch = "sparc64", + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "mips64", + target_arch = "mips64r6" + )))] + pub c_ospeed: crate::speed_t, + } + + pub struct mallinfo { + pub arena: c_int, + pub ordblks: c_int, + pub smblks: c_int, + pub hblks: c_int, + pub hblkhd: c_int, + pub usmblks: c_int, + pub fsmblks: c_int, + pub uordblks: c_int, + pub fordblks: c_int, + pub keepcost: c_int, + } + + pub struct mallinfo2 { + pub arena: size_t, + pub ordblks: size_t, + pub smblks: size_t, + pub hblks: size_t, + pub hblkhd: size_t, + pub usmblks: size_t, + pub fsmblks: size_t, + pub uordblks: size_t, + pub fordblks: size_t, + pub keepcost: size_t, + } + + pub struct ntptimeval { + pub time: crate::timeval, + pub maxerror: c_long, + pub esterror: c_long, + pub tai: c_long, + pub __glibc_reserved1: c_long, + pub __glibc_reserved2: c_long, + pub __glibc_reserved3: c_long, + pub __glibc_reserved4: c_long, + } + + pub struct regex_t { + __buffer: *mut c_void, + __allocated: size_t, + __used: size_t, + __syntax: c_ulong, + __fastmap: *mut c_char, + __translate: *mut c_char, + __re_nsub: size_t, + __bitfield: u8, + } + + pub struct Elf64_Chdr { + pub ch_type: crate::Elf64_Word, + pub ch_reserved: crate::Elf64_Word, + pub ch_size: crate::Elf64_Xword, + pub ch_addralign: crate::Elf64_Xword, + } + + pub struct Elf32_Chdr { + pub ch_type: crate::Elf32_Word, + pub ch_size: crate::Elf32_Word, + pub ch_addralign: crate::Elf32_Word, + } + + pub struct seminfo { + pub semmap: c_int, + pub semmni: c_int, + pub semmns: c_int, + pub semmnu: c_int, + pub semmsl: c_int, + pub semopm: c_int, + pub semume: c_int, + pub semusz: c_int, + pub semvmx: c_int, + pub semaem: c_int, + } + + pub struct ptrace_peeksiginfo_args { + pub off: crate::__u64, + pub flags: crate::__u32, + pub nr: crate::__s32, + } + + pub struct __c_anonymous_ptrace_syscall_info_entry { + pub nr: crate::__u64, + pub args: [crate::__u64; 6], + } + + pub struct __c_anonymous_ptrace_syscall_info_exit { + pub sval: crate::__s64, + pub is_error: crate::__u8, + } + + pub struct __c_anonymous_ptrace_syscall_info_seccomp { + pub nr: crate::__u64, + pub args: [crate::__u64; 6], + pub ret_data: crate::__u32, + reserved2: Padding, + } + + pub struct ptrace_syscall_info { + pub op: crate::__u8, + reserved: Padding, + pub flags: crate::__u16, + pub arch: crate::__u32, + pub instruction_pointer: crate::__u64, + pub stack_pointer: crate::__u64, + pub u: __c_anonymous_ptrace_syscall_info_data, + } + + pub struct ptrace_sud_config { + pub mode: crate::__u64, + pub selector: crate::__u64, + pub offset: crate::__u64, + pub len: crate::__u64, + } + + pub struct iocb { + pub aio_data: crate::__u64, + #[cfg(target_endian = "little")] + pub aio_key: crate::__u32, + #[cfg(target_endian = "little")] + pub aio_rw_flags: crate::__kernel_rwf_t, + #[cfg(target_endian = "big")] + pub aio_rw_flags: crate::__kernel_rwf_t, + #[cfg(target_endian = "big")] + pub aio_key: crate::__u32, + pub aio_lio_opcode: crate::__u16, + pub aio_reqprio: crate::__s16, + pub aio_fildes: crate::__u32, + pub aio_buf: crate::__u64, + pub aio_nbytes: crate::__u64, + pub aio_offset: crate::__s64, + aio_reserved2: Padding, + pub aio_flags: crate::__u32, + pub aio_resfd: crate::__u32, + } + + // netinet/tcp.h + + pub struct tcp_info { + pub tcpi_state: u8, + pub tcpi_ca_state: u8, + pub tcpi_retransmits: u8, + pub tcpi_probes: u8, + pub tcpi_backoff: u8, + pub tcpi_options: u8, + /// This contains the bitfields `tcpi_snd_wscale` and `tcpi_rcv_wscale`. + /// Each is 4 bits. + pub tcpi_snd_rcv_wscale: u8, + pub tcpi_rto: u32, + pub tcpi_ato: u32, + pub tcpi_snd_mss: u32, + pub tcpi_rcv_mss: u32, + pub tcpi_unacked: u32, + pub tcpi_sacked: u32, + pub tcpi_lost: u32, + pub tcpi_retrans: u32, + pub tcpi_fackets: u32, + pub tcpi_last_data_sent: u32, + pub tcpi_last_ack_sent: u32, + pub tcpi_last_data_recv: u32, + pub tcpi_last_ack_recv: u32, + pub tcpi_pmtu: u32, + pub tcpi_rcv_ssthresh: u32, + pub tcpi_rtt: u32, + pub tcpi_rttvar: u32, + pub tcpi_snd_ssthresh: u32, + pub tcpi_snd_cwnd: u32, + pub tcpi_advmss: u32, + pub tcpi_reordering: u32, + pub tcpi_rcv_rtt: u32, + pub tcpi_rcv_space: u32, + pub tcpi_total_retrans: u32, + } + + pub struct fanotify_event_info_pidfd { + pub hdr: crate::fanotify_event_info_header, + pub pidfd: crate::__s32, + } + + pub struct fanotify_event_info_error { + pub hdr: crate::fanotify_event_info_header, + pub error: crate::__s32, + pub error_count: crate::__u32, + } + + // FIXME(1.0) this is actually a union + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + pub struct sem_t { + #[cfg(target_pointer_width = "32")] + __size: [c_char; 16], + #[cfg(target_pointer_width = "64")] + __size: [c_char; 32], + } + + pub struct mbstate_t { + __count: c_int, + __wchb: [c_char; 4], + } + + pub struct fpos64_t { + __pos: off64_t, + __state: crate::mbstate_t, + } + + pub struct fpos_t { + #[cfg(not(gnu_file_offset_bits64))] + __pos: off_t, + #[cfg(gnu_file_offset_bits64)] + __pos: off64_t, + __state: crate::mbstate_t, + } + + // linux x32 compatibility + // See https://sourceware.org/bugzilla/show_bug.cgi?id=16437 + #[derive(Default)] + pub struct timespec { + pub tv_sec: time_t, + #[cfg(all(gnu_time_bits64, target_endian = "big"))] + __pad: Padding, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub tv_nsec: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub tv_nsec: i64, + #[cfg(all(gnu_time_bits64, target_endian = "little"))] + __pad: Padding, + } + + pub struct utmpx { + pub ut_type: c_short, + pub ut_pid: crate::pid_t, + pub ut_line: [c_char; __UT_LINESIZE], + pub ut_id: [c_char; 4], + + pub ut_user: [c_char; __UT_NAMESIZE], + pub ut_host: [c_char; __UT_HOSTSIZE], + pub ut_exit: __exit_status, + + #[cfg(any( + target_arch = "aarch64", + target_arch = "s390x", + target_arch = "loongarch64", + all(target_pointer_width = "32", not(target_arch = "x86_64")) + ))] + pub ut_session: c_long, + #[cfg(any( + target_arch = "aarch64", + target_arch = "s390x", + target_arch = "loongarch64", + all(target_pointer_width = "32", not(target_arch = "x86_64")) + ))] + pub ut_tv: crate::timeval, + + #[cfg(not(any( + target_arch = "aarch64", + target_arch = "s390x", + target_arch = "loongarch64", + all(target_pointer_width = "32", not(target_arch = "x86_64")) + )))] + pub ut_session: i32, + #[cfg(not(any( + target_arch = "aarch64", + target_arch = "s390x", + target_arch = "loongarch64", + all(target_pointer_width = "32", not(target_arch = "x86_64")) + )))] + pub ut_tv: __timeval, + + pub ut_addr_v6: [i32; 4], + __glibc_reserved: Padding<[c_char; 20]>, + } +} + +impl siginfo_t { + pub unsafe fn si_addr(&self) -> *mut c_void { + #[repr(C)] + struct siginfo_sigfault { + _si_signo: c_int, + _si_errno: c_int, + _si_code: c_int, + si_addr: *mut c_void, + } + (*(self as *const siginfo_t).cast::()).si_addr + } + + pub unsafe fn si_value(&self) -> crate::sigval { + #[repr(C)] + struct siginfo_timer { + _si_signo: c_int, + _si_errno: c_int, + _si_code: c_int, + _si_tid: c_int, + _si_overrun: c_int, + si_sigval: crate::sigval, + } + (*(self as *const siginfo_t).cast::()).si_sigval + } +} + +s_no_extra_traits! { + // linux/if_ether.h + + #[repr(C, packed)] + pub struct ethhdr { + pub h_dest: [c_uchar; crate::ETH_ALEN as usize], + pub h_source: [c_uchar; crate::ETH_ALEN as usize], + pub h_proto: crate::__be16, + } + + // Internal, for casts to access union fields + struct sifields_sigchld { + si_pid: crate::pid_t, + si_uid: crate::uid_t, + si_status: c_int, + si_utime: c_long, + si_stime: c_long, + } + + // Internal, for casts to access union fields + union sifields { + _align_pointer: *mut c_void, + sigchld: sifields_sigchld, + } + + // Internal, for casts to access union fields. Note that some variants + // of sifields start with a pointer, which makes the alignment of + // sifields vary on 32-bit and 64-bit architectures. + struct siginfo_f { + _siginfo_base: [c_int; 3], + sifields: sifields, + } +} + +impl siginfo_t { + unsafe fn sifields(&self) -> &sifields { + &(*(self as *const siginfo_t).cast::()).sifields + } + + pub unsafe fn si_pid(&self) -> crate::pid_t { + self.sifields().sigchld.si_pid + } + + pub unsafe fn si_uid(&self) -> crate::uid_t { + self.sifields().sigchld.si_uid + } + + pub unsafe fn si_status(&self) -> c_int { + self.sifields().sigchld.si_status + } + + pub unsafe fn si_utime(&self) -> c_long { + self.sifields().sigchld.si_utime + } + + pub unsafe fn si_stime(&self) -> c_long { + self.sifields().sigchld.si_stime + } +} + +s_no_extra_traits! { + pub union __c_anonymous_ptrace_syscall_info_data { + pub entry: __c_anonymous_ptrace_syscall_info_entry, + pub exit: __c_anonymous_ptrace_syscall_info_exit, + pub seccomp: __c_anonymous_ptrace_syscall_info_seccomp, + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for __c_anonymous_ptrace_syscall_info_data { + fn eq(&self, other: &__c_anonymous_ptrace_syscall_info_data) -> bool { + unsafe { + self.entry == other.entry + || self.exit == other.exit + || self.seccomp == other.seccomp + } + } + } + + impl Eq for __c_anonymous_ptrace_syscall_info_data {} + + impl hash::Hash for __c_anonymous_ptrace_syscall_info_data { + fn hash(&self, state: &mut H) { + unsafe { + self.entry.hash(state); + self.exit.hash(state); + self.seccomp.hash(state); + } + } + } + } +} + +// include/uapi/asm-generic/hugetlb_encode.h +pub const HUGETLB_FLAG_ENCODE_SHIFT: c_int = 26; +pub const HUGETLB_FLAG_ENCODE_MASK: c_int = 0x3f; + +pub const HUGETLB_FLAG_ENCODE_64KB: c_int = 16 << HUGETLB_FLAG_ENCODE_SHIFT; +pub const HUGETLB_FLAG_ENCODE_512KB: c_int = 19 << HUGETLB_FLAG_ENCODE_SHIFT; +pub const HUGETLB_FLAG_ENCODE_1MB: c_int = 20 << HUGETLB_FLAG_ENCODE_SHIFT; +pub const HUGETLB_FLAG_ENCODE_2MB: c_int = 21 << HUGETLB_FLAG_ENCODE_SHIFT; +pub const HUGETLB_FLAG_ENCODE_8MB: c_int = 23 << HUGETLB_FLAG_ENCODE_SHIFT; +pub const HUGETLB_FLAG_ENCODE_16MB: c_int = 24 << HUGETLB_FLAG_ENCODE_SHIFT; +pub const HUGETLB_FLAG_ENCODE_32MB: c_int = 25 << HUGETLB_FLAG_ENCODE_SHIFT; +pub const HUGETLB_FLAG_ENCODE_256MB: c_int = 28 << HUGETLB_FLAG_ENCODE_SHIFT; +pub const HUGETLB_FLAG_ENCODE_512MB: c_int = 29 << HUGETLB_FLAG_ENCODE_SHIFT; +pub const HUGETLB_FLAG_ENCODE_1GB: c_int = 30 << HUGETLB_FLAG_ENCODE_SHIFT; +pub const HUGETLB_FLAG_ENCODE_2GB: c_int = 31 << HUGETLB_FLAG_ENCODE_SHIFT; +pub const HUGETLB_FLAG_ENCODE_16GB: c_int = 34 << HUGETLB_FLAG_ENCODE_SHIFT; + +// include/uapi/linux/mman.h +/* + * Huge page size encoding when MAP_HUGETLB is specified, and a huge page + * size other than the default is desired. See hugetlb_encode.h. + * All known huge page size encodings are provided here. It is the + * responsibility of the application to know which sizes are supported on + * the running system. See mmap(2) man page for details. + */ +pub const MAP_HUGE_SHIFT: c_int = HUGETLB_FLAG_ENCODE_SHIFT; +pub const MAP_HUGE_MASK: c_int = HUGETLB_FLAG_ENCODE_MASK; + +pub const MAP_HUGE_64KB: c_int = HUGETLB_FLAG_ENCODE_64KB; +pub const MAP_HUGE_512KB: c_int = HUGETLB_FLAG_ENCODE_512KB; +pub const MAP_HUGE_1MB: c_int = HUGETLB_FLAG_ENCODE_1MB; +pub const MAP_HUGE_2MB: c_int = HUGETLB_FLAG_ENCODE_2MB; +pub const MAP_HUGE_8MB: c_int = HUGETLB_FLAG_ENCODE_8MB; +pub const MAP_HUGE_16MB: c_int = HUGETLB_FLAG_ENCODE_16MB; +pub const MAP_HUGE_32MB: c_int = HUGETLB_FLAG_ENCODE_32MB; +pub const MAP_HUGE_256MB: c_int = HUGETLB_FLAG_ENCODE_256MB; +pub const MAP_HUGE_512MB: c_int = HUGETLB_FLAG_ENCODE_512MB; +pub const MAP_HUGE_1GB: c_int = HUGETLB_FLAG_ENCODE_1GB; +pub const MAP_HUGE_2GB: c_int = HUGETLB_FLAG_ENCODE_2GB; +pub const MAP_HUGE_16GB: c_int = HUGETLB_FLAG_ENCODE_16GB; + +pub const PRIO_PROCESS: crate::__priority_which_t = 0; +pub const PRIO_PGRP: crate::__priority_which_t = 1; +pub const PRIO_USER: crate::__priority_which_t = 2; + +pub const MS_RMT_MASK: c_ulong = 0x02800051; + +pub const __UT_LINESIZE: usize = 32; +pub const __UT_NAMESIZE: usize = 32; +pub const __UT_HOSTSIZE: usize = 256; +pub const EMPTY: c_short = 0; +pub const RUN_LVL: c_short = 1; +pub const BOOT_TIME: c_short = 2; +pub const NEW_TIME: c_short = 3; +pub const OLD_TIME: c_short = 4; +pub const INIT_PROCESS: c_short = 5; +pub const LOGIN_PROCESS: c_short = 6; +pub const USER_PROCESS: c_short = 7; +pub const DEAD_PROCESS: c_short = 8; +pub const ACCOUNTING: c_short = 9; + +// dlfcn.h +pub const LM_ID_BASE: c_long = 0; +pub const LM_ID_NEWLM: c_long = -1; + +pub const RTLD_DI_LMID: c_int = 1; +pub const RTLD_DI_LINKMAP: c_int = 2; +pub const RTLD_DI_CONFIGADDR: c_int = 3; +pub const RTLD_DI_SERINFO: c_int = 4; +pub const RTLD_DI_SERINFOSIZE: c_int = 5; +pub const RTLD_DI_ORIGIN: c_int = 6; +pub const RTLD_DI_PROFILENAME: c_int = 7; +pub const RTLD_DI_PROFILEOUT: c_int = 8; +pub const RTLD_DI_TLS_MODID: c_int = 9; +pub const RTLD_DI_TLS_DATA: c_int = 10; + +pub const SOCK_NONBLOCK: c_int = O_NONBLOCK; + +pub const SOL_RXRPC: c_int = 272; +pub const SOL_PPPOL2TP: c_int = 273; +pub const SOL_PNPIPE: c_int = 275; +pub const SOL_RDS: c_int = 276; +pub const SOL_IUCV: c_int = 277; +pub const SOL_CAIF: c_int = 278; +pub const SOL_NFC: c_int = 280; + +pub const MSG_TRYHARD: c_int = 4; + +pub const LC_PAPER: c_int = 7; +pub const LC_NAME: c_int = 8; +pub const LC_ADDRESS: c_int = 9; +pub const LC_TELEPHONE: c_int = 10; +pub const LC_MEASUREMENT: c_int = 11; +pub const LC_IDENTIFICATION: c_int = 12; +pub const LC_PAPER_MASK: c_int = 1 << LC_PAPER; +pub const LC_NAME_MASK: c_int = 1 << LC_NAME; +pub const LC_ADDRESS_MASK: c_int = 1 << LC_ADDRESS; +pub const LC_TELEPHONE_MASK: c_int = 1 << LC_TELEPHONE; +pub const LC_MEASUREMENT_MASK: c_int = 1 << LC_MEASUREMENT; +pub const LC_IDENTIFICATION_MASK: c_int = 1 << LC_IDENTIFICATION; +pub const LC_ALL_MASK: c_int = crate::LC_CTYPE_MASK + | crate::LC_NUMERIC_MASK + | crate::LC_TIME_MASK + | crate::LC_COLLATE_MASK + | crate::LC_MONETARY_MASK + | crate::LC_MESSAGES_MASK + | LC_PAPER_MASK + | LC_NAME_MASK + | LC_ADDRESS_MASK + | LC_TELEPHONE_MASK + | LC_MEASUREMENT_MASK + | LC_IDENTIFICATION_MASK; + +pub const ENOTSUP: c_int = EOPNOTSUPP; + +pub const SOCK_SEQPACKET: c_int = 5; +pub const SOCK_DCCP: c_int = 6; +#[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")] +pub const SOCK_PACKET: c_int = 10; + +pub const AF_IB: c_int = 27; +pub const AF_MPLS: c_int = 28; +pub const AF_NFC: c_int = 39; +pub const AF_VSOCK: c_int = 40; +pub const AF_XDP: c_int = 44; +pub const PF_IB: c_int = AF_IB; +pub const PF_MPLS: c_int = AF_MPLS; +pub const PF_NFC: c_int = AF_NFC; +pub const PF_VSOCK: c_int = AF_VSOCK; +pub const PF_XDP: c_int = AF_XDP; + +pub const SIGEV_THREAD_ID: c_int = 4; + +pub const BUFSIZ: c_uint = 8192; +pub const TMP_MAX: c_uint = 238328; +pub const FOPEN_MAX: c_uint = 16; +pub const FILENAME_MAX: c_uint = 4096; +pub const _CS_GNU_LIBC_VERSION: c_int = 2; +pub const _CS_GNU_LIBPTHREAD_VERSION: c_int = 3; +pub const _CS_V6_ENV: c_int = 1148; +pub const _CS_V7_ENV: c_int = 1149; +pub const _SC_EQUIV_CLASS_MAX: c_int = 41; +pub const _SC_CHARCLASS_NAME_MAX: c_int = 45; +pub const _SC_PII: c_int = 53; +pub const _SC_PII_XTI: c_int = 54; +pub const _SC_PII_SOCKET: c_int = 55; +pub const _SC_PII_INTERNET: c_int = 56; +pub const _SC_PII_OSI: c_int = 57; +pub const _SC_POLL: c_int = 58; +pub const _SC_SELECT: c_int = 59; +pub const _SC_PII_INTERNET_STREAM: c_int = 61; +pub const _SC_PII_INTERNET_DGRAM: c_int = 62; +pub const _SC_PII_OSI_COTS: c_int = 63; +pub const _SC_PII_OSI_CLTS: c_int = 64; +pub const _SC_PII_OSI_M: c_int = 65; +pub const _SC_T_IOV_MAX: c_int = 66; +pub const _SC_2_C_VERSION: c_int = 96; +pub const _SC_CHAR_BIT: c_int = 101; +pub const _SC_CHAR_MAX: c_int = 102; +pub const _SC_CHAR_MIN: c_int = 103; +pub const _SC_INT_MAX: c_int = 104; +pub const _SC_INT_MIN: c_int = 105; +pub const _SC_LONG_BIT: c_int = 106; +pub const _SC_WORD_BIT: c_int = 107; +pub const _SC_MB_LEN_MAX: c_int = 108; +pub const _SC_SSIZE_MAX: c_int = 110; +pub const _SC_SCHAR_MAX: c_int = 111; +pub const _SC_SCHAR_MIN: c_int = 112; +pub const _SC_SHRT_MAX: c_int = 113; +pub const _SC_SHRT_MIN: c_int = 114; +pub const _SC_UCHAR_MAX: c_int = 115; +pub const _SC_UINT_MAX: c_int = 116; +pub const _SC_ULONG_MAX: c_int = 117; +pub const _SC_USHRT_MAX: c_int = 118; +pub const _SC_NL_ARGMAX: c_int = 119; +pub const _SC_NL_LANGMAX: c_int = 120; +pub const _SC_NL_MSGMAX: c_int = 121; +pub const _SC_NL_NMAX: c_int = 122; +pub const _SC_NL_SETMAX: c_int = 123; +pub const _SC_NL_TEXTMAX: c_int = 124; +pub const _SC_BASE: c_int = 134; +pub const _SC_C_LANG_SUPPORT: c_int = 135; +pub const _SC_C_LANG_SUPPORT_R: c_int = 136; +pub const _SC_DEVICE_IO: c_int = 140; +pub const _SC_DEVICE_SPECIFIC: c_int = 141; +pub const _SC_DEVICE_SPECIFIC_R: c_int = 142; +pub const _SC_FD_MGMT: c_int = 143; +pub const _SC_FIFO: c_int = 144; +pub const _SC_PIPE: c_int = 145; +pub const _SC_FILE_ATTRIBUTES: c_int = 146; +pub const _SC_FILE_LOCKING: c_int = 147; +pub const _SC_FILE_SYSTEM: c_int = 148; +pub const _SC_MULTI_PROCESS: c_int = 150; +pub const _SC_SINGLE_PROCESS: c_int = 151; +pub const _SC_NETWORKING: c_int = 152; +pub const _SC_REGEX_VERSION: c_int = 156; +pub const _SC_SIGNALS: c_int = 158; +pub const _SC_SYSTEM_DATABASE: c_int = 162; +pub const _SC_SYSTEM_DATABASE_R: c_int = 163; +pub const _SC_USER_GROUPS: c_int = 166; +pub const _SC_USER_GROUPS_R: c_int = 167; +pub const _SC_LEVEL1_ICACHE_SIZE: c_int = 185; +pub const _SC_LEVEL1_ICACHE_ASSOC: c_int = 186; +pub const _SC_LEVEL1_ICACHE_LINESIZE: c_int = 187; +pub const _SC_LEVEL1_DCACHE_SIZE: c_int = 188; +pub const _SC_LEVEL1_DCACHE_ASSOC: c_int = 189; +pub const _SC_LEVEL1_DCACHE_LINESIZE: c_int = 190; +pub const _SC_LEVEL2_CACHE_SIZE: c_int = 191; +pub const _SC_LEVEL2_CACHE_ASSOC: c_int = 192; +pub const _SC_LEVEL2_CACHE_LINESIZE: c_int = 193; +pub const _SC_LEVEL3_CACHE_SIZE: c_int = 194; +pub const _SC_LEVEL3_CACHE_ASSOC: c_int = 195; +pub const _SC_LEVEL3_CACHE_LINESIZE: c_int = 196; +pub const _SC_LEVEL4_CACHE_SIZE: c_int = 197; +pub const _SC_LEVEL4_CACHE_ASSOC: c_int = 198; +pub const _SC_LEVEL4_CACHE_LINESIZE: c_int = 199; +pub const O_ACCMODE: c_int = 3; +pub const ST_RELATIME: c_ulong = 4096; +pub const NI_MAXHOST: crate::socklen_t = 1025; + +// Most `*_SUPER_MAGIC` constants are defined at the `linux_like` level; the +// following are only available on newer Linux versions than the versions +// currently used in CI in some configurations, so we define them here. +cfg_if! { + if #[cfg(not(target_arch = "s390x"))] { + pub const BINDERFS_SUPER_MAGIC: c_long = 0x6c6f6f70; + pub const XFS_SUPER_MAGIC: c_long = 0x58465342; + } else if #[cfg(target_arch = "s390x")] { + pub const BINDERFS_SUPER_MAGIC: c_uint = 0x6c6f6f70; + pub const XFS_SUPER_MAGIC: c_uint = 0x58465342; + } +} + +pub const CPU_SETSIZE: c_int = 0x400; + +pub const PTRACE_TRACEME: c_uint = 0; +pub const PTRACE_PEEKTEXT: c_uint = 1; +pub const PTRACE_PEEKDATA: c_uint = 2; +pub const PTRACE_PEEKUSER: c_uint = 3; +pub const PTRACE_POKETEXT: c_uint = 4; +pub const PTRACE_POKEDATA: c_uint = 5; +pub const PTRACE_POKEUSER: c_uint = 6; +pub const PTRACE_CONT: c_uint = 7; +pub const PTRACE_KILL: c_uint = 8; +pub const PTRACE_SINGLESTEP: c_uint = 9; +pub const PTRACE_ATTACH: c_uint = 16; +pub const PTRACE_SYSCALL: c_uint = 24; +pub const PTRACE_SETOPTIONS: c_uint = 0x4200; +pub const PTRACE_GETEVENTMSG: c_uint = 0x4201; +pub const PTRACE_GETSIGINFO: c_uint = 0x4202; +pub const PTRACE_SETSIGINFO: c_uint = 0x4203; +pub const PTRACE_GETREGSET: c_uint = 0x4204; +pub const PTRACE_SETREGSET: c_uint = 0x4205; +pub const PTRACE_SEIZE: c_uint = 0x4206; +pub const PTRACE_INTERRUPT: c_uint = 0x4207; +pub const PTRACE_LISTEN: c_uint = 0x4208; +pub const PTRACE_PEEKSIGINFO: c_uint = 0x4209; +pub const PTRACE_GETSIGMASK: c_uint = 0x420a; +pub const PTRACE_SETSIGMASK: c_uint = 0x420b; +pub const PTRACE_GET_SYSCALL_INFO: c_uint = 0x420e; +pub const PTRACE_SET_SYSCALL_INFO: c_uint = 0x4212; +pub const PTRACE_SYSCALL_INFO_NONE: crate::__u8 = 0; +pub const PTRACE_SYSCALL_INFO_ENTRY: crate::__u8 = 1; +pub const PTRACE_SYSCALL_INFO_EXIT: crate::__u8 = 2; +pub const PTRACE_SYSCALL_INFO_SECCOMP: crate::__u8 = 3; +pub const PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG: crate::__u8 = 0x4210; +pub const PTRACE_GET_SYSCALL_USER_DISPATCH_CONFIG: crate::__u8 = 0x4211; + +// linux/rtnetlink.h +pub const TCA_PAD: c_ushort = 9; +pub const TCA_DUMP_INVISIBLE: c_ushort = 10; +pub const TCA_CHAIN: c_ushort = 11; +pub const TCA_HW_OFFLOAD: c_ushort = 12; + +pub const RTM_DELNETCONF: u16 = 81; +pub const RTM_NEWSTATS: u16 = 92; +pub const RTM_GETSTATS: u16 = 94; +pub const RTM_NEWCACHEREPORT: u16 = 96; + +pub const RTM_F_LOOKUP_TABLE: c_uint = 0x1000; +pub const RTM_F_FIB_MATCH: c_uint = 0x2000; + +pub const RTA_VIA: c_ushort = 18; +pub const RTA_NEWDST: c_ushort = 19; +pub const RTA_PREF: c_ushort = 20; +pub const RTA_ENCAP_TYPE: c_ushort = 21; +pub const RTA_ENCAP: c_ushort = 22; +pub const RTA_EXPIRES: c_ushort = 23; +pub const RTA_PAD: c_ushort = 24; +pub const RTA_UID: c_ushort = 25; +pub const RTA_TTL_PROPAGATE: c_ushort = 26; + +// linux/neighbor.h +pub const NTF_EXT_LEARNED: u8 = 0x10; +pub const NTF_OFFLOADED: u8 = 0x20; + +pub const NDA_MASTER: c_ushort = 9; +pub const NDA_LINK_NETNSID: c_ushort = 10; +pub const NDA_SRC_VNI: c_ushort = 11; + +// linux/personality.h +pub const UNAME26: c_int = 0x0020000; +pub const FDPIC_FUNCPTRS: c_int = 0x0080000; + +pub const GENL_UNS_ADMIN_PERM: c_int = 0x10; + +pub const GENL_ID_VFS_DQUOT: c_int = crate::NLMSG_MIN_TYPE + 1; +pub const GENL_ID_PMCRAID: c_int = crate::NLMSG_MIN_TYPE + 2; + +pub const ELFOSABI_ARM_AEABI: u8 = 64; + +// linux/sched.h +pub const CLONE_NEWTIME: c_int = 0x80; +// DIFF(main): changed to `c_ulonglong` in e9abac9ac2 +pub const CLONE_CLEAR_SIGHAND: c_int = 0x100000000; +pub const CLONE_INTO_CGROUP: c_int = 0x200000000; + +pub const M_MXFAST: c_int = 1; +pub const M_NLBLKS: c_int = 2; +pub const M_GRAIN: c_int = 3; +pub const M_KEEP: c_int = 4; +pub const M_TRIM_THRESHOLD: c_int = -1; +pub const M_TOP_PAD: c_int = -2; +pub const M_MMAP_THRESHOLD: c_int = -3; +pub const M_MMAP_MAX: c_int = -4; +pub const M_CHECK_ACTION: c_int = -5; +pub const M_PERTURB: c_int = -6; +pub const M_ARENA_TEST: c_int = -7; +pub const M_ARENA_MAX: c_int = -8; + +pub const SOMAXCONN: c_int = 4096; + +// linux/mount.h +pub const MOVE_MOUNT_F_SYMLINKS: c_uint = 0x00000001; +pub const MOVE_MOUNT_F_AUTOMOUNTS: c_uint = 0x00000002; +pub const MOVE_MOUNT_F_EMPTY_PATH: c_uint = 0x00000004; +pub const MOVE_MOUNT_T_SYMLINKS: c_uint = 0x00000010; +pub const MOVE_MOUNT_T_AUTOMOUNTS: c_uint = 0x00000020; +pub const MOVE_MOUNT_T_EMPTY_PATH: c_uint = 0x00000040; +pub const MOVE_MOUNT_SET_GROUP: c_uint = 0x00000100; +pub const MOVE_MOUNT_BENEATH: c_uint = 0x00000200; + +// sys/timex.h +pub const ADJ_OFFSET: c_uint = 0x0001; +pub const ADJ_FREQUENCY: c_uint = 0x0002; +pub const ADJ_MAXERROR: c_uint = 0x0004; +pub const ADJ_ESTERROR: c_uint = 0x0008; +pub const ADJ_STATUS: c_uint = 0x0010; +pub const ADJ_TIMECONST: c_uint = 0x0020; +pub const ADJ_TAI: c_uint = 0x0080; +pub const ADJ_SETOFFSET: c_uint = 0x0100; +pub const ADJ_MICRO: c_uint = 0x1000; +pub const ADJ_NANO: c_uint = 0x2000; +pub const ADJ_TICK: c_uint = 0x4000; +pub const ADJ_OFFSET_SINGLESHOT: c_uint = 0x8001; +pub const ADJ_OFFSET_SS_READ: c_uint = 0xa001; +pub const MOD_OFFSET: c_uint = ADJ_OFFSET; +pub const MOD_FREQUENCY: c_uint = ADJ_FREQUENCY; +pub const MOD_MAXERROR: c_uint = ADJ_MAXERROR; +pub const MOD_ESTERROR: c_uint = ADJ_ESTERROR; +pub const MOD_STATUS: c_uint = ADJ_STATUS; +pub const MOD_TIMECONST: c_uint = ADJ_TIMECONST; +pub const MOD_CLKB: c_uint = ADJ_TICK; +pub const MOD_CLKA: c_uint = ADJ_OFFSET_SINGLESHOT; +pub const MOD_TAI: c_uint = ADJ_TAI; +pub const MOD_MICRO: c_uint = ADJ_MICRO; +pub const MOD_NANO: c_uint = ADJ_NANO; +pub const STA_PLL: c_int = 0x0001; +pub const STA_PPSFREQ: c_int = 0x0002; +pub const STA_PPSTIME: c_int = 0x0004; +pub const STA_FLL: c_int = 0x0008; +pub const STA_INS: c_int = 0x0010; +pub const STA_DEL: c_int = 0x0020; +pub const STA_UNSYNC: c_int = 0x0040; +pub const STA_FREQHOLD: c_int = 0x0080; +pub const STA_PPSSIGNAL: c_int = 0x0100; +pub const STA_PPSJITTER: c_int = 0x0200; +pub const STA_PPSWANDER: c_int = 0x0400; +pub const STA_PPSERROR: c_int = 0x0800; +pub const STA_CLOCKERR: c_int = 0x1000; +pub const STA_NANO: c_int = 0x2000; +pub const STA_MODE: c_int = 0x4000; +pub const STA_CLK: c_int = 0x8000; +pub const STA_RONLY: c_int = STA_PPSSIGNAL + | STA_PPSJITTER + | STA_PPSWANDER + | STA_PPSERROR + | STA_CLOCKERR + | STA_NANO + | STA_MODE + | STA_CLK; +pub const NTP_API: c_int = 4; +pub const TIME_OK: c_int = 0; +pub const TIME_INS: c_int = 1; +pub const TIME_DEL: c_int = 2; +pub const TIME_OOP: c_int = 3; +pub const TIME_WAIT: c_int = 4; +pub const TIME_ERROR: c_int = 5; +pub const TIME_BAD: c_int = TIME_ERROR; +pub const MAXTC: c_long = 6; + +// Portable GLOB_* flags are defined at the `linux_like` level. +// The following are GNU extensions. +pub const GLOB_PERIOD: c_int = 1 << 7; +pub const GLOB_ALTDIRFUNC: c_int = 1 << 9; +pub const GLOB_BRACE: c_int = 1 << 10; +pub const GLOB_NOMAGIC: c_int = 1 << 11; +pub const GLOB_TILDE: c_int = 1 << 12; +pub const GLOB_ONLYDIR: c_int = 1 << 13; +pub const GLOB_TILDE_CHECK: c_int = 1 << 14; + +pub const MADV_COLLAPSE: c_int = 25; + +cfg_if! { + if #[cfg(any( + target_arch = "arm", + target_arch = "x86", + target_arch = "x86_64", + target_arch = "s390x", + target_arch = "riscv64", + target_arch = "riscv32" + ))] { + pub const PTHREAD_STACK_MIN: size_t = 16384; + } else if #[cfg(any(target_arch = "sparc", target_arch = "sparc64"))] { + pub const PTHREAD_STACK_MIN: size_t = 0x6000; + } else { + pub const PTHREAD_STACK_MIN: size_t = 131072; + } +} +pub const PTHREAD_MUTEX_ADAPTIVE_NP: c_int = 3; + +pub const REG_STARTEND: c_int = 4; + +pub const REG_EEND: c_int = 14; +pub const REG_ESIZE: c_int = 15; +pub const REG_ERPAREN: c_int = 16; + +extern "C" { + pub fn fgetspent_r( + fp: *mut crate::FILE, + spbuf: *mut crate::spwd, + buf: *mut c_char, + buflen: size_t, + spbufp: *mut *mut crate::spwd, + ) -> c_int; + pub fn sgetspent_r( + s: *const c_char, + spbuf: *mut crate::spwd, + buf: *mut c_char, + buflen: size_t, + spbufp: *mut *mut crate::spwd, + ) -> c_int; + pub fn getspent_r( + spbuf: *mut crate::spwd, + buf: *mut c_char, + buflen: size_t, + spbufp: *mut *mut crate::spwd, + ) -> c_int; + pub fn qsort_r( + base: *mut c_void, + num: size_t, + size: size_t, + compar: Option c_int>, + arg: *mut c_void, + ); + #[cfg_attr(gnu_time_bits64, link_name = "__sendmmsg64")] + pub fn sendmmsg( + sockfd: c_int, + msgvec: *mut crate::mmsghdr, + vlen: c_uint, + flags: c_int, + ) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__recvmmsg64")] + pub fn recvmmsg( + sockfd: c_int, + msgvec: *mut crate::mmsghdr, + vlen: c_uint, + flags: c_int, + timeout: *mut crate::timespec, + ) -> c_int; + + pub fn getrlimit64(resource: crate::__rlimit_resource_t, rlim: *mut crate::rlimit64) -> c_int; + pub fn setrlimit64(resource: crate::__rlimit_resource_t, rlim: *const crate::rlimit64) + -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "getrlimit64")] + pub fn getrlimit(resource: crate::__rlimit_resource_t, rlim: *mut crate::rlimit) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "setrlimit64")] + pub fn setrlimit(resource: crate::__rlimit_resource_t, rlim: *const crate::rlimit) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "prlimit64")] + pub fn prlimit( + pid: crate::pid_t, + resource: crate::__rlimit_resource_t, + new_limit: *const crate::rlimit, + old_limit: *mut crate::rlimit, + ) -> c_int; + pub fn prlimit64( + pid: crate::pid_t, + resource: crate::__rlimit_resource_t, + new_limit: *const crate::rlimit64, + old_limit: *mut crate::rlimit64, + ) -> c_int; + pub fn utmpname(file: *const c_char) -> c_int; + pub fn utmpxname(file: *const c_char) -> c_int; + pub fn getutxent() -> *mut utmpx; + pub fn getutxid(ut: *const utmpx) -> *mut utmpx; + pub fn getutxline(ut: *const utmpx) -> *mut utmpx; + pub fn pututxline(ut: *const utmpx) -> *mut utmpx; + pub fn setutxent(); + pub fn endutxent(); + pub fn getpt() -> c_int; + pub fn mallopt(param: c_int, value: c_int) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__gettimeofday64")] + pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut crate::timezone) -> c_int; + pub fn getentropy(buf: *mut c_void, buflen: size_t) -> c_int; + pub fn getrandom(buf: *mut c_void, buflen: size_t, flags: c_uint) -> ssize_t; + pub fn getauxval(type_: c_ulong) -> c_ulong; + + #[cfg_attr(gnu_time_bits64, link_name = "___adjtimex64")] + pub fn adjtimex(buf: *mut timex) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "___adjtimex64")] + pub fn ntp_adjtime(buf: *mut timex) -> c_int; + #[cfg_attr(not(gnu_time_bits64), link_name = "ntp_gettimex")] + #[cfg_attr(gnu_time_bits64, link_name = "__ntp_gettime64")] + pub fn ntp_gettime(buf: *mut ntptimeval) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__clock_adjtime64")] + pub fn clock_adjtime(clk_id: crate::clockid_t, buf: *mut crate::timex) -> c_int; + + pub fn fanotify_mark( + fd: c_int, + flags: c_uint, + mask: u64, + dirfd: c_int, + path: *const c_char, + ) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "preadv64v2")] + pub fn preadv2( + fd: c_int, + iov: *const crate::iovec, + iovcnt: c_int, + offset: off_t, + flags: c_int, + ) -> ssize_t; + #[cfg_attr(gnu_file_offset_bits64, link_name = "pwritev64v2")] + pub fn pwritev2( + fd: c_int, + iov: *const crate::iovec, + iovcnt: c_int, + offset: off_t, + flags: c_int, + ) -> ssize_t; + pub fn preadv64v2( + fd: c_int, + iov: *const crate::iovec, + iovcnt: c_int, + offset: off64_t, + flags: c_int, + ) -> ssize_t; + pub fn pwritev64v2( + fd: c_int, + iov: *const crate::iovec, + iovcnt: c_int, + offset: off64_t, + flags: c_int, + ) -> ssize_t; + pub fn renameat2( + olddirfd: c_int, + oldpath: *const c_char, + newdirfd: c_int, + newpath: *const c_char, + flags: c_uint, + ) -> c_int; + + // Added in `glibc` 2.25 + pub fn explicit_bzero(s: *mut c_void, len: size_t); + // Added in `glibc` 2.29 + pub fn reallocarray(ptr: *mut c_void, nmemb: size_t, size: size_t) -> *mut c_void; + + pub fn ctermid(s: *mut c_char) -> *mut c_char; + pub fn backtrace(buf: *mut *mut c_void, sz: c_int) -> c_int; + pub fn backtrace_symbols(buffer: *const *mut c_void, len: c_int) -> *mut *mut c_char; + pub fn backtrace_symbols_fd(buffer: *const *mut c_void, len: c_int, fd: c_int); + #[cfg_attr(gnu_time_bits64, link_name = "__glob64_time64")] + pub fn glob64( + pattern: *const c_char, + flags: c_int, + errfunc: Option c_int>, + pglob: *mut glob64_t, + ) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__globfree64_time64")] + pub fn globfree64(pglob: *mut glob64_t); + pub fn ptrace(request: c_uint, ...) -> c_long; + pub fn pthread_attr_getaffinity_np( + attr: *const crate::pthread_attr_t, + cpusetsize: size_t, + cpuset: *mut crate::cpu_set_t, + ) -> c_int; + pub fn pthread_attr_setaffinity_np( + attr: *mut crate::pthread_attr_t, + cpusetsize: size_t, + cpuset: *const crate::cpu_set_t, + ) -> c_int; + pub fn getpriority(which: crate::__priority_which_t, who: crate::id_t) -> c_int; + pub fn setpriority(which: crate::__priority_which_t, who: crate::id_t, prio: c_int) -> c_int; + pub fn pthread_rwlockattr_getkind_np( + attr: *const crate::pthread_rwlockattr_t, + val: *mut c_int, + ) -> c_int; + pub fn pthread_rwlockattr_setkind_np( + attr: *mut crate::pthread_rwlockattr_t, + val: c_int, + ) -> c_int; + pub fn pthread_sigqueue(thread: crate::pthread_t, sig: c_int, value: crate::sigval) -> c_int; + pub fn pthread_tryjoin_np(thread: crate::pthread_t, retval: *mut *mut c_void) -> c_int; + #[cfg_attr( + all(target_pointer_width = "32", gnu_time_bits64), + link_name = "__pthread_timedjoin_np64" + )] + pub fn pthread_timedjoin_np( + thread: crate::pthread_t, + retval: *mut *mut c_void, + abstime: *const crate::timespec, + ) -> c_int; + pub fn mallinfo() -> crate::mallinfo; + pub fn mallinfo2() -> crate::mallinfo2; + pub fn malloc_stats(); + pub fn malloc_info(options: c_int, stream: *mut crate::FILE) -> c_int; + pub fn malloc_usable_size(ptr: *mut c_void) -> size_t; + pub fn getpwent_r( + pwd: *mut crate::passwd, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::passwd, + ) -> c_int; + pub fn getgrent_r( + grp: *mut crate::group, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::group, + ) -> c_int; + pub fn fgetpwent_r( + stream: *mut crate::FILE, + pwd: *mut crate::passwd, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::passwd, + ) -> c_int; + pub fn fgetgrent_r( + stream: *mut crate::FILE, + grp: *mut crate::group, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::group, + ) -> c_int; + + pub fn putpwent(p: *const crate::passwd, stream: *mut crate::FILE) -> c_int; + pub fn putgrent(grp: *const crate::group, stream: *mut crate::FILE) -> c_int; + + pub fn sethostid(hostid: c_long) -> c_int; + + pub fn memfd_create(name: *const c_char, flags: c_uint) -> c_int; + pub fn mlock2(addr: *const c_void, len: size_t, flags: c_uint) -> c_int; + + pub fn euidaccess(pathname: *const c_char, mode: c_int) -> c_int; + pub fn eaccess(pathname: *const c_char, mode: c_int) -> c_int; + + pub fn asctime_r(tm: *const crate::tm, buf: *mut c_char) -> *mut c_char; + #[cfg_attr(gnu_time_bits64, link_name = "__ctime64_r")] + pub fn ctime_r(timep: *const time_t, buf: *mut c_char) -> *mut c_char; + + pub fn dirname(path: *mut c_char) -> *mut c_char; + /// POSIX version of `basename(3)`, defined in `libgen.h`. + #[link_name = "__xpg_basename"] + pub fn posix_basename(path: *mut c_char) -> *mut c_char; + /// GNU version of `basename(3)`, defined in `string.h`. + #[link_name = "basename"] + pub fn gnu_basename(path: *const c_char) -> *mut c_char; + pub fn dlmopen(lmid: Lmid_t, filename: *const c_char, flag: c_int) -> *mut c_void; + pub fn dlinfo(handle: *mut c_void, request: c_int, info: *mut c_void) -> c_int; + pub fn dladdr1( + addr: *const c_void, + info: *mut crate::Dl_info, + extra_info: *mut *mut c_void, + flags: c_int, + ) -> c_int; + pub fn dlvsym( + handle: *mut c_void, + symbol: *const c_char, + version: *const c_char, + ) -> *mut c_void; + pub fn malloc_trim(__pad: size_t) -> c_int; + pub fn gnu_get_libc_release() -> *const c_char; + pub fn gnu_get_libc_version() -> *const c_char; + + // posix/spawn.h + // Added in `glibc` 2.29 + pub fn posix_spawn_file_actions_addchdir_np( + actions: *mut crate::posix_spawn_file_actions_t, + path: *const c_char, + ) -> c_int; + // Added in `glibc` 2.29 + pub fn posix_spawn_file_actions_addfchdir_np( + actions: *mut crate::posix_spawn_file_actions_t, + fd: c_int, + ) -> c_int; + // Added in `glibc` 2.34 + pub fn posix_spawn_file_actions_addclosefrom_np( + actions: *mut crate::posix_spawn_file_actions_t, + from: c_int, + ) -> c_int; + // Added in `glibc` 2.35 + pub fn posix_spawn_file_actions_addtcsetpgrp_np( + actions: *mut crate::posix_spawn_file_actions_t, + tcfd: c_int, + ) -> c_int; + + // mntent.h + pub fn getmntent_r( + stream: *mut crate::FILE, + mntbuf: *mut crate::mntent, + buf: *mut c_char, + buflen: c_int, + ) -> *mut crate::mntent; + + pub fn execveat( + dirfd: c_int, + pathname: *const c_char, + argv: *const *mut c_char, + envp: *const *mut c_char, + flags: c_int, + ) -> c_int; + + // Added in `glibc` 2.34 + pub fn close_range(first: c_uint, last: c_uint, flags: c_int) -> c_int; + + pub fn mq_notify(mqdes: crate::mqd_t, sevp: *const crate::sigevent) -> c_int; + + #[cfg_attr(gnu_time_bits64, link_name = "__epoll_pwait2_time64")] + pub fn epoll_pwait2( + epfd: c_int, + events: *mut crate::epoll_event, + maxevents: c_int, + timeout: *const crate::timespec, + sigmask: *const crate::sigset_t, + ) -> c_int; + + pub fn mempcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; + + pub fn tgkill(tgid: crate::pid_t, tid: crate::pid_t, sig: c_int) -> c_int; +} + +cfg_if! { + if #[cfg(any( + target_arch = "x86", + target_arch = "arm", + target_arch = "m68k", + target_arch = "csky", + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "powerpc", + target_arch = "sparc", + target_arch = "riscv32" + ))] { + mod b32; + pub use self::b32::*; + } else if #[cfg(any( + target_arch = "x86_64", + target_arch = "aarch64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "mips64r6", + target_arch = "s390x", + target_arch = "sparc64", + target_arch = "riscv64", + target_arch = "loongarch64" + ))] { + mod b64; + pub use self::b64::*; + } else { + // Unknown target_arch + } +} diff --git a/http/vendor/libc/src/unix/linux_like/linux/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/mod.rs new file mode 100644 index 0000000..e58849b --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/mod.rs @@ -0,0 +1,4436 @@ +//! Linux-specific definitions for linux-like values +use crate::prelude::*; +use crate::{ + sock_filter, + _IO, + _IOR, + _IOW, + _IOWR, +}; + +pub type dev_t = u64; +pub type socklen_t = u32; +pub type mode_t = u32; +pub type ino64_t = u64; +pub type off64_t = i64; +pub type blkcnt64_t = i64; +pub type rlim64_t = u64; +pub type mqd_t = c_int; +pub type nfds_t = c_ulong; +pub type nl_item = c_int; +pub type idtype_t = c_uint; +pub type loff_t = c_longlong; +pub type pthread_key_t = c_uint; +pub type pthread_once_t = c_int; +pub type pthread_spinlock_t = c_int; +pub type __kernel_fsid_t = __c_anonymous__kernel_fsid_t; +pub type __kernel_clockid_t = c_int; + +pub type __u8 = c_uchar; +pub type __u16 = c_ushort; +pub type __s16 = c_short; +pub type __u32 = c_uint; +pub type __s32 = c_int; + +// linux/sctp.h +pub type sctp_assoc_t = __s32; + +pub type eventfd_t = u64; + +e! { + #[repr(u32)] + pub enum tpacket_versions { + TPACKET_V1, + TPACKET_V2, + TPACKET_V3, + } +} + +c_enum! { + pub enum pid_type { + pub PIDTYPE_PID, + pub PIDTYPE_TGID, + pub PIDTYPE_PGID, + pub PIDTYPE_SID, + pub PIDTYPE_MAX, + } +} + +s! { + pub struct dqblk { + pub dqb_bhardlimit: u64, + pub dqb_bsoftlimit: u64, + pub dqb_curspace: u64, + pub dqb_ihardlimit: u64, + pub dqb_isoftlimit: u64, + pub dqb_curinodes: u64, + pub dqb_btime: u64, + pub dqb_itime: u64, + pub dqb_valid: u32, + } + + pub struct signalfd_siginfo { + pub ssi_signo: u32, + pub ssi_errno: i32, + pub ssi_code: i32, + pub ssi_pid: u32, + pub ssi_uid: u32, + pub ssi_fd: i32, + pub ssi_tid: u32, + pub ssi_band: u32, + pub ssi_overrun: u32, + pub ssi_trapno: u32, + pub ssi_status: i32, + pub ssi_int: i32, + pub ssi_ptr: u64, + pub ssi_utime: u64, + pub ssi_stime: u64, + pub ssi_addr: u64, + pub ssi_addr_lsb: u16, + _pad2: Padding, + pub ssi_syscall: i32, + pub ssi_call_addr: u64, + pub ssi_arch: u32, + _pad: Padding<[u8; 28]>, + } + + pub struct fanout_args { + #[cfg(target_endian = "little")] + pub id: __u16, + pub type_flags: __u16, + #[cfg(target_endian = "big")] + pub id: __u16, + pub max_num_members: __u32, + } + + #[deprecated(since = "0.2.70", note = "sockaddr_ll type must be used instead")] + pub struct sockaddr_pkt { + pub spkt_family: c_ushort, + pub spkt_device: [c_uchar; 14], + pub spkt_protocol: c_ushort, + } + + pub struct tpacket_auxdata { + pub tp_status: __u32, + pub tp_len: __u32, + pub tp_snaplen: __u32, + pub tp_mac: __u16, + pub tp_net: __u16, + pub tp_vlan_tci: __u16, + pub tp_vlan_tpid: __u16, + } + + pub struct tpacket_hdr { + pub tp_status: c_ulong, + pub tp_len: c_uint, + pub tp_snaplen: c_uint, + pub tp_mac: c_ushort, + pub tp_net: c_ushort, + pub tp_sec: c_uint, + pub tp_usec: c_uint, + } + + pub struct tpacket_hdr_variant1 { + pub tp_rxhash: __u32, + pub tp_vlan_tci: __u32, + pub tp_vlan_tpid: __u16, + pub tp_padding: __u16, + } + + pub struct tpacket2_hdr { + pub tp_status: __u32, + pub tp_len: __u32, + pub tp_snaplen: __u32, + pub tp_mac: __u16, + pub tp_net: __u16, + pub tp_sec: __u32, + pub tp_nsec: __u32, + pub tp_vlan_tci: __u16, + pub tp_vlan_tpid: __u16, + pub tp_padding: [__u8; 4], + } + + pub struct tpacket_req { + pub tp_block_size: c_uint, + pub tp_block_nr: c_uint, + pub tp_frame_size: c_uint, + pub tp_frame_nr: c_uint, + } + + pub struct tpacket_req3 { + pub tp_block_size: c_uint, + pub tp_block_nr: c_uint, + pub tp_frame_size: c_uint, + pub tp_frame_nr: c_uint, + pub tp_retire_blk_tov: c_uint, + pub tp_sizeof_priv: c_uint, + pub tp_feature_req_word: c_uint, + } + + #[repr(align(8))] + pub struct tpacket_rollover_stats { + pub tp_all: crate::__u64, + pub tp_huge: crate::__u64, + pub tp_failed: crate::__u64, + } + + pub struct tpacket_stats { + pub tp_packets: c_uint, + pub tp_drops: c_uint, + } + + pub struct tpacket_stats_v3 { + pub tp_packets: c_uint, + pub tp_drops: c_uint, + pub tp_freeze_q_cnt: c_uint, + } + + pub struct tpacket3_hdr { + pub tp_next_offset: __u32, + pub tp_sec: __u32, + pub tp_nsec: __u32, + pub tp_snaplen: __u32, + pub tp_len: __u32, + pub tp_status: __u32, + pub tp_mac: __u16, + pub tp_net: __u16, + pub hv1: crate::tpacket_hdr_variant1, + pub tp_padding: [__u8; 8], + } + + pub struct tpacket_bd_ts { + pub ts_sec: c_uint, + pub ts_usec: c_uint, + } + + #[repr(align(8))] + pub struct tpacket_hdr_v1 { + pub block_status: __u32, + pub num_pkts: __u32, + pub offset_to_first_pkt: __u32, + pub blk_len: __u32, + pub seq_num: crate::__u64, + pub ts_first_pkt: crate::tpacket_bd_ts, + pub ts_last_pkt: crate::tpacket_bd_ts, + } + + // System V IPC + pub struct msginfo { + pub msgpool: c_int, + pub msgmap: c_int, + pub msgmax: c_int, + pub msgmnb: c_int, + pub msgmni: c_int, + pub msgssz: c_int, + pub msgtql: c_int, + pub msgseg: c_ushort, + } + + pub struct input_event { + // FIXME(1.0): Change to the commented variant, see https://github.com/rust-lang/libc/pull/4148#discussion_r1857511742 + #[cfg(any(target_pointer_width = "64", not(linux_time_bits64)))] + pub time: crate::timeval, + // #[cfg(any(target_pointer_width = "64", not(linux_time_bits64)))] + // pub input_event_sec: time_t, + // #[cfg(any(target_pointer_width = "64", not(linux_time_bits64)))] + // pub input_event_usec: suseconds_t, + // #[cfg(target_arch = "sparc64")] + // _pad1: c_int, + #[cfg(all(target_pointer_width = "32", linux_time_bits64))] + pub input_event_sec: c_ulong, + + #[cfg(all(target_pointer_width = "32", linux_time_bits64))] + pub input_event_usec: c_ulong, + + pub type_: __u16, + pub code: __u16, + pub value: __s32, + } + + pub struct input_id { + pub bustype: __u16, + pub vendor: __u16, + pub product: __u16, + pub version: __u16, + } + + pub struct input_absinfo { + pub value: __s32, + pub minimum: __s32, + pub maximum: __s32, + pub fuzz: __s32, + pub flat: __s32, + pub resolution: __s32, + } + + pub struct input_keymap_entry { + pub flags: __u8, + pub len: __u8, + pub index: __u16, + pub keycode: __u32, + pub scancode: [__u8; 32], + } + + pub struct input_mask { + pub type_: __u32, + pub codes_size: __u32, + pub codes_ptr: crate::__u64, + } + + pub struct ff_replay { + pub length: __u16, + pub delay: __u16, + } + + pub struct ff_trigger { + pub button: __u16, + pub interval: __u16, + } + + pub struct ff_envelope { + pub attack_length: __u16, + pub attack_level: __u16, + pub fade_length: __u16, + pub fade_level: __u16, + } + + pub struct ff_constant_effect { + pub level: __s16, + pub envelope: ff_envelope, + } + + pub struct ff_ramp_effect { + pub start_level: __s16, + pub end_level: __s16, + pub envelope: ff_envelope, + } + + pub struct ff_condition_effect { + pub right_saturation: __u16, + pub left_saturation: __u16, + + pub right_coeff: __s16, + pub left_coeff: __s16, + + pub deadband: __u16, + pub center: __s16, + } + + pub struct ff_periodic_effect { + pub waveform: __u16, + pub period: __u16, + pub magnitude: __s16, + pub offset: __s16, + pub phase: __u16, + + pub envelope: ff_envelope, + + pub custom_len: __u32, + pub custom_data: *mut __s16, + } + + pub struct ff_rumble_effect { + pub strong_magnitude: __u16, + pub weak_magnitude: __u16, + } + + pub struct ff_effect { + pub type_: __u16, + pub id: __s16, + pub direction: __u16, + pub trigger: ff_trigger, + pub replay: ff_replay, + // FIXME(1.0): this is actually a union + #[cfg(target_pointer_width = "64")] + pub u: [u64; 4], + #[cfg(target_pointer_width = "32")] + pub u: [u32; 7], + } + + pub struct uinput_ff_upload { + pub request_id: __u32, + pub retval: __s32, + pub effect: ff_effect, + pub old: ff_effect, + } + + pub struct uinput_ff_erase { + pub request_id: __u32, + pub retval: __s32, + pub effect_id: __u32, + } + + pub struct uinput_abs_setup { + pub code: __u16, + pub absinfo: input_absinfo, + } + + pub struct __c_anonymous__kernel_fsid_t { + pub val: [c_int; 2], + } + + pub struct posix_spawn_file_actions_t { + __allocated: c_int, + __used: c_int, + __actions: *mut c_int, + __pad: Padding<[c_int; 16]>, + } + + pub struct posix_spawnattr_t { + __flags: c_short, + __pgrp: crate::pid_t, + __sd: crate::sigset_t, + __ss: crate::sigset_t, + #[cfg(any(target_env = "musl", target_env = "ohos"))] + __prio: c_int, + #[cfg(not(any(target_env = "musl", target_env = "ohos")))] + __sp: crate::sched_param, + __policy: c_int, + __pad: Padding<[c_int; 16]>, + } + + pub struct genlmsghdr { + pub cmd: u8, + pub version: u8, + pub reserved: u16, + } + + pub struct inotify_event { + pub wd: c_int, + pub mask: u32, + pub cookie: u32, + pub len: u32, + } + + pub struct fanotify_response { + pub fd: c_int, + pub response: __u32, + } + + pub struct fanotify_event_info_header { + pub info_type: __u8, + pub pad: __u8, + pub len: __u16, + } + + pub struct fanotify_event_info_fid { + pub hdr: fanotify_event_info_header, + pub fsid: __kernel_fsid_t, + pub handle: [c_uchar; 0], + } + + pub struct sockaddr_vm { + pub svm_family: crate::sa_family_t, + pub svm_reserved1: c_ushort, + pub svm_port: c_uint, + pub svm_cid: c_uint, + pub svm_zero: [u8; 4], + } + + pub struct sock_extended_err { + pub ee_errno: u32, + pub ee_origin: u8, + pub ee_type: u8, + pub ee_code: u8, + pub ee_pad: u8, + pub ee_info: u32, + pub ee_data: u32, + } + + // linux/seccomp.h + pub struct seccomp_data { + pub nr: c_int, + pub arch: __u32, + pub instruction_pointer: crate::__u64, + pub args: [crate::__u64; 6], + } + + pub struct seccomp_notif_sizes { + pub seccomp_notif: __u16, + pub seccomp_notif_resp: __u16, + pub seccomp_data: __u16, + } + + pub struct seccomp_notif { + pub id: crate::__u64, + pub pid: __u32, + pub flags: __u32, + pub data: seccomp_data, + } + + pub struct seccomp_notif_resp { + pub id: crate::__u64, + pub val: crate::__s64, + pub error: __s32, + pub flags: __u32, + } + + pub struct seccomp_notif_addfd { + pub id: crate::__u64, + pub flags: __u32, + pub srcfd: __u32, + pub newfd: __u32, + pub newfd_flags: __u32, + } + + pub struct in6_ifreq { + pub ifr6_addr: crate::in6_addr, + pub ifr6_prefixlen: u32, + pub ifr6_ifindex: c_int, + } + + // linux/openat2.h + #[non_exhaustive] + pub struct open_how { + pub flags: crate::__u64, + pub mode: crate::__u64, + pub resolve: crate::__u64, + } + + // linux/ptp_clock.h + pub struct ptp_clock_time { + pub sec: crate::__s64, + pub nsec: __u32, + pub reserved: __u32, + } + + pub struct ptp_extts_request { + pub index: c_uint, + pub flags: c_uint, + pub rsv: [c_uint; 2], + } + + pub struct ptp_sys_offset_extended { + pub n_samples: c_uint, + pub clockid: __kernel_clockid_t, + pub rsv: [c_uint; 2], + pub ts: [[ptp_clock_time; 3]; PTP_MAX_SAMPLES as usize], + } + + pub struct ptp_sys_offset_precise { + pub device: ptp_clock_time, + pub sys_realtime: ptp_clock_time, + pub sys_monoraw: ptp_clock_time, + pub rsv: [c_uint; 4], + } + + pub struct ptp_extts_event { + pub t: ptp_clock_time, + index: c_uint, + flags: c_uint, + rsv: [c_uint; 2], + } + + // linux/sctp.h + + pub struct sctp_initmsg { + pub sinit_num_ostreams: __u16, + pub sinit_max_instreams: __u16, + pub sinit_max_attempts: __u16, + pub sinit_max_init_timeo: __u16, + } + + pub struct sctp_sndrcvinfo { + pub sinfo_stream: __u16, + pub sinfo_ssn: __u16, + pub sinfo_flags: __u16, + pub sinfo_ppid: __u32, + pub sinfo_context: __u32, + pub sinfo_timetolive: __u32, + pub sinfo_tsn: __u32, + pub sinfo_cumtsn: __u32, + pub sinfo_assoc_id: crate::sctp_assoc_t, + } + + pub struct sctp_sndinfo { + pub snd_sid: __u16, + pub snd_flags: __u16, + pub snd_ppid: __u32, + pub snd_context: __u32, + pub snd_assoc_id: crate::sctp_assoc_t, + } + + pub struct sctp_rcvinfo { + pub rcv_sid: __u16, + pub rcv_ssn: __u16, + pub rcv_flags: __u16, + pub rcv_ppid: __u32, + pub rcv_tsn: __u32, + pub rcv_cumtsn: __u32, + pub rcv_context: __u32, + pub rcv_assoc_id: crate::sctp_assoc_t, + } + + pub struct sctp_nxtinfo { + pub nxt_sid: __u16, + pub nxt_flags: __u16, + pub nxt_ppid: __u32, + pub nxt_length: __u32, + pub nxt_assoc_id: crate::sctp_assoc_t, + } + + pub struct sctp_prinfo { + pub pr_policy: __u16, + pub pr_value: __u32, + } + + pub struct sctp_authinfo { + pub auth_keynumber: __u16, + } + + // linux/tls.h + + pub struct tls_crypto_info { + pub version: __u16, + pub cipher_type: __u16, + } + + pub struct tls12_crypto_info_aes_gcm_128 { + pub info: tls_crypto_info, + pub iv: [c_uchar; TLS_CIPHER_AES_GCM_128_IV_SIZE], + pub key: [c_uchar; TLS_CIPHER_AES_GCM_128_KEY_SIZE], + pub salt: [c_uchar; TLS_CIPHER_AES_GCM_128_SALT_SIZE], + pub rec_seq: [c_uchar; TLS_CIPHER_AES_GCM_128_REC_SEQ_SIZE], + } + + pub struct tls12_crypto_info_aes_gcm_256 { + pub info: tls_crypto_info, + pub iv: [c_uchar; TLS_CIPHER_AES_GCM_256_IV_SIZE], + pub key: [c_uchar; TLS_CIPHER_AES_GCM_256_KEY_SIZE], + pub salt: [c_uchar; TLS_CIPHER_AES_GCM_256_SALT_SIZE], + pub rec_seq: [c_uchar; TLS_CIPHER_AES_GCM_256_REC_SEQ_SIZE], + } + + pub struct tls12_crypto_info_aes_ccm_128 { + pub info: tls_crypto_info, + pub iv: [c_uchar; TLS_CIPHER_AES_CCM_128_IV_SIZE], + pub key: [c_uchar; TLS_CIPHER_AES_CCM_128_KEY_SIZE], + pub salt: [c_uchar; TLS_CIPHER_AES_CCM_128_SALT_SIZE], + pub rec_seq: [c_uchar; TLS_CIPHER_AES_CCM_128_REC_SEQ_SIZE], + } + + pub struct tls12_crypto_info_chacha20_poly1305 { + pub info: tls_crypto_info, + pub iv: [c_uchar; TLS_CIPHER_CHACHA20_POLY1305_IV_SIZE], + pub key: [c_uchar; TLS_CIPHER_CHACHA20_POLY1305_KEY_SIZE], + pub salt: [c_uchar; TLS_CIPHER_CHACHA20_POLY1305_SALT_SIZE], + pub rec_seq: [c_uchar; TLS_CIPHER_CHACHA20_POLY1305_REC_SEQ_SIZE], + } + + pub struct tls12_crypto_info_sm4_gcm { + pub info: tls_crypto_info, + pub iv: [c_uchar; TLS_CIPHER_SM4_GCM_IV_SIZE], + pub key: [c_uchar; TLS_CIPHER_SM4_GCM_KEY_SIZE], + pub salt: [c_uchar; TLS_CIPHER_SM4_GCM_SALT_SIZE], + pub rec_seq: [c_uchar; TLS_CIPHER_SM4_GCM_REC_SEQ_SIZE], + } + + pub struct tls12_crypto_info_sm4_ccm { + pub info: tls_crypto_info, + pub iv: [c_uchar; TLS_CIPHER_SM4_CCM_IV_SIZE], + pub key: [c_uchar; TLS_CIPHER_SM4_CCM_KEY_SIZE], + pub salt: [c_uchar; TLS_CIPHER_SM4_CCM_SALT_SIZE], + pub rec_seq: [c_uchar; TLS_CIPHER_SM4_CCM_REC_SEQ_SIZE], + } + + pub struct tls12_crypto_info_aria_gcm_128 { + pub info: tls_crypto_info, + pub iv: [c_uchar; TLS_CIPHER_ARIA_GCM_128_IV_SIZE], + pub key: [c_uchar; TLS_CIPHER_ARIA_GCM_128_KEY_SIZE], + pub salt: [c_uchar; TLS_CIPHER_ARIA_GCM_128_SALT_SIZE], + pub rec_seq: [c_uchar; TLS_CIPHER_ARIA_GCM_128_REC_SEQ_SIZE], + } + + pub struct tls12_crypto_info_aria_gcm_256 { + pub info: tls_crypto_info, + pub iv: [c_uchar; TLS_CIPHER_ARIA_GCM_256_IV_SIZE], + pub key: [c_uchar; TLS_CIPHER_ARIA_GCM_256_KEY_SIZE], + pub salt: [c_uchar; TLS_CIPHER_ARIA_GCM_256_SALT_SIZE], + pub rec_seq: [c_uchar; TLS_CIPHER_ARIA_GCM_256_REC_SEQ_SIZE], + } + + // linux/wireless.h + + pub struct iw_param { + pub value: __s32, + pub fixed: __u8, + pub disabled: __u8, + pub flags: __u16, + } + + pub struct iw_point { + pub pointer: *mut c_void, + pub length: __u16, + pub flags: __u16, + } + + pub struct iw_freq { + pub m: __s32, + pub e: __s16, + pub i: __u8, + pub flags: __u8, + } + + pub struct iw_quality { + pub qual: __u8, + pub level: __u8, + pub noise: __u8, + pub updated: __u8, + } + + pub struct iw_discarded { + pub nwid: __u32, + pub code: __u32, + pub fragment: __u32, + pub retries: __u32, + pubmisc: __u32, + } + + pub struct iw_missed { + pub beacon: __u32, + } + + pub struct iw_scan_req { + pub scan_type: __u8, + pub essid_len: __u8, + pub num_channels: __u8, + pub flags: __u8, + pub bssid: crate::sockaddr, + pub essid: [__u8; IW_ESSID_MAX_SIZE], + pub min_channel_time: __u32, + pub max_channel_time: __u32, + pub channel_list: [iw_freq; IW_MAX_FREQUENCIES], + } + + pub struct iw_encode_ext { + pub ext_flags: __u32, + pub tx_seq: [__u8; IW_ENCODE_SEQ_MAX_SIZE], + pub rx_seq: [__u8; IW_ENCODE_SEQ_MAX_SIZE], + pub addr: crate::sockaddr, + pub alg: __u16, + pub key_len: __u16, + pub key: [__u8; 0], + } + + pub struct iw_pmksa { + pub cmd: __u32, + pub bssid: crate::sockaddr, + pub pmkid: [__u8; IW_PMKID_LEN], + } + + pub struct iw_pmkid_cand { + pub flags: __u32, + pub index: __u32, + pub bssid: crate::sockaddr, + } + + pub struct iw_statistics { + pub status: __u16, + pub qual: iw_quality, + pub discard: iw_discarded, + pub miss: iw_missed, + } + + pub struct iw_range { + pub throughput: __u32, + pub min_nwid: __u32, + pub max_nwid: __u32, + pub old_num_channels: __u16, + pub old_num_frequency: __u8, + pub scan_capa: __u8, + pub event_capa: [__u32; 6], + pub sensitivity: __s32, + pub max_qual: iw_quality, + pub avg_qual: iw_quality, + pub num_bitrates: __u8, + pub bitrate: [__s32; IW_MAX_BITRATES], + pub min_rts: __s32, + pub max_rts: __s32, + pub min_frag: __s32, + pub max_frag: __s32, + pub min_pmp: __s32, + pub max_pmp: __s32, + pub min_pmt: __s32, + pub max_pmt: __s32, + pub pmp_flags: __u16, + pub pmt_flags: __u16, + pub pm_capa: __u16, + pub encoding_size: [__u16; IW_MAX_ENCODING_SIZES], + pub num_encoding_sizes: __u8, + pub max_encoding_tokens: __u8, + pub encoding_login_index: __u8, + pub txpower_capa: __u16, + pub num_txpower: __u8, + pub txpower: [__s32; IW_MAX_TXPOWER], + pub we_version_compiled: __u8, + pub we_version_source: __u8, + pub retry_capa: __u16, + pub retry_flags: __u16, + pub r_time_flags: __u16, + pub min_retry: __s32, + pub max_retry: __s32, + pub min_r_time: __s32, + pub max_r_time: __s32, + pub num_channels: __u16, + pub num_frequency: __u8, + pub freq: [iw_freq; IW_MAX_FREQUENCIES], + pub enc_capa: __u32, + } + + pub struct iw_priv_args { + pub cmd: __u32, + pub set_args: __u16, + pub get_args: __u16, + pub name: [c_char; crate::IFNAMSIZ], + } + + // #include + + pub struct epoll_params { + pub busy_poll_usecs: u32, + pub busy_poll_budget: u16, + pub prefer_busy_poll: u8, + pub __pad: u8, // Must be zero + } + + #[cfg_attr( + any( + target_pointer_width = "32", + target_arch = "x86_64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "mips64r6", + target_arch = "s390x", + target_arch = "sparc64", + target_arch = "aarch64", + target_arch = "riscv64", + target_arch = "riscv32", + target_arch = "loongarch64" + ), + repr(align(4)) + )] + #[cfg_attr( + not(any( + target_pointer_width = "32", + target_arch = "x86_64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "mips64r6", + target_arch = "s390x", + target_arch = "sparc64", + target_arch = "aarch64", + target_arch = "riscv64", + target_arch = "riscv32", + target_arch = "loongarch64" + )), + repr(align(8)) + )] + pub struct pthread_mutexattr_t { + #[doc(hidden)] + size: [u8; crate::__SIZEOF_PTHREAD_MUTEXATTR_T], + } + + #[cfg_attr( + any( + target_env = "musl", + target_env = "ohos", + target_env = "uclibc", + target_pointer_width = "32" + ), + repr(align(4)) + )] + #[cfg_attr( + all( + not(target_env = "musl"), + not(target_env = "ohos"), + not(target_env = "uclibc"), + target_pointer_width = "64" + ), + repr(align(8)) + )] + pub struct pthread_rwlockattr_t { + #[doc(hidden)] + size: [u8; crate::__SIZEOF_PTHREAD_RWLOCKATTR_T], + } + + #[repr(align(4))] + pub struct pthread_condattr_t { + #[doc(hidden)] + size: [u8; crate::__SIZEOF_PTHREAD_CONDATTR_T], + } + + #[repr(align(4))] + pub struct pthread_barrierattr_t { + #[doc(hidden)] + size: [u8; crate::__SIZEOF_PTHREAD_BARRIERATTR_T], + } + + #[cfg(not(any(target_env = "musl", target_env = "ohos")))] + #[repr(align(8))] + pub struct fanotify_event_metadata { + pub event_len: __u32, + pub vers: __u8, + pub reserved: __u8, + pub metadata_len: __u16, + pub mask: __u64, + pub fd: c_int, + pub pid: c_int, + } + + // linux/ptp_clock.h + + pub struct ptp_sys_offset { + pub n_samples: c_uint, + pub rsv: [c_uint; 3], + // FIXME(garando): replace length with `2 * PTP_MAX_SAMPLES + 1` when supported + pub ts: [ptp_clock_time; 51], + } + + pub struct ptp_pin_desc { + pub name: [c_char; 64], + pub index: c_uint, + pub func: c_uint, + pub chan: c_uint, + pub rsv: [c_uint; 5], + } + + pub struct ptp_clock_caps { + pub max_adj: c_int, + pub n_alarm: c_int, + pub n_ext_ts: c_int, + pub n_per_out: c_int, + pub pps: c_int, + pub n_pins: c_int, + pub cross_timestamping: c_int, + pub adjust_phase: c_int, + pub max_phase_adj: c_int, + pub rsv: [c_int; 11], + } + + // linux/if_xdp.h + + pub struct sockaddr_xdp { + pub sxdp_family: crate::__u16, + pub sxdp_flags: crate::__u16, + pub sxdp_ifindex: crate::__u32, + pub sxdp_queue_id: crate::__u32, + pub sxdp_shared_umem_fd: crate::__u32, + } + + pub struct xdp_ring_offset { + pub producer: crate::__u64, + pub consumer: crate::__u64, + pub desc: crate::__u64, + pub flags: crate::__u64, + } + + pub struct xdp_mmap_offsets { + pub rx: xdp_ring_offset, + pub tx: xdp_ring_offset, + pub fr: xdp_ring_offset, + pub cr: xdp_ring_offset, + } + + pub struct xdp_ring_offset_v1 { + pub producer: crate::__u64, + pub consumer: crate::__u64, + pub desc: crate::__u64, + } + + pub struct xdp_mmap_offsets_v1 { + pub rx: xdp_ring_offset_v1, + pub tx: xdp_ring_offset_v1, + pub fr: xdp_ring_offset_v1, + pub cr: xdp_ring_offset_v1, + } + + pub struct xdp_umem_reg { + pub addr: crate::__u64, + pub len: crate::__u64, + pub chunk_size: crate::__u32, + pub headroom: crate::__u32, + pub flags: crate::__u32, + pub tx_metadata_len: crate::__u32, + } + + pub struct xdp_umem_reg_v1 { + pub addr: crate::__u64, + pub len: crate::__u64, + pub chunk_size: crate::__u32, + pub headroom: crate::__u32, + } + + pub struct xdp_statistics { + pub rx_dropped: crate::__u64, + pub rx_invalid_descs: crate::__u64, + pub tx_invalid_descs: crate::__u64, + pub rx_ring_full: crate::__u64, + pub rx_fill_ring_empty_descs: crate::__u64, + pub tx_ring_empty_descs: crate::__u64, + } + + pub struct xdp_statistics_v1 { + pub rx_dropped: crate::__u64, + pub rx_invalid_descs: crate::__u64, + pub tx_invalid_descs: crate::__u64, + } + + pub struct xdp_options { + pub flags: crate::__u32, + } + + pub struct xdp_desc { + pub addr: crate::__u64, + pub len: crate::__u32, + pub options: crate::__u32, + } + + pub struct xsk_tx_metadata_completion { + pub tx_timestamp: crate::__u64, + } + + pub struct xsk_tx_metadata_request { + pub csum_start: __u16, + pub csum_offset: __u16, + } + + // linux/mount.h + + pub struct mount_attr { + pub attr_set: crate::__u64, + pub attr_clr: crate::__u64, + pub propagation: crate::__u64, + pub userns_fd: crate::__u64, + } + + // linux/nsfs.h + pub struct mnt_ns_info { + pub size: crate::__u32, + pub nr_mounts: crate::__u32, + pub mnt_ns_id: crate::__u64, + } + + // linux/pidfd.h + + // linux/uio.h + + pub struct dmabuf_cmsg { + pub frag_offset: crate::__u64, + pub frag_size: crate::__u32, + pub frag_token: crate::__u32, + pub dmabuf_id: crate::__u32, + pub flags: crate::__u32, + } + + pub struct dmabuf_token { + pub token_start: crate::__u32, + pub token_count: crate::__u32, + } + + pub struct sockaddr_alg { + pub salg_family: crate::sa_family_t, + pub salg_type: [c_uchar; 14], + pub salg_feat: u32, + pub salg_mask: u32, + pub salg_name: [c_uchar; 64], + } + + #[cfg_attr( + all( + any(target_env = "musl", target_env = "ohos"), + target_pointer_width = "32" + ), + repr(align(4)) + )] + #[cfg_attr( + all( + any(target_env = "musl", target_env = "ohos"), + target_pointer_width = "64" + ), + repr(align(8)) + )] + #[cfg_attr( + all( + not(any(target_env = "musl", target_env = "ohos")), + target_arch = "x86" + ), + repr(align(4)) + )] + #[cfg_attr( + all( + not(any(target_env = "musl", target_env = "ohos")), + not(target_arch = "x86") + ), + repr(align(8)) + )] + pub struct pthread_cond_t { + #[doc(hidden)] + size: [u8; crate::__SIZEOF_PTHREAD_COND_T], + } + + #[cfg_attr( + all( + target_pointer_width = "32", + any( + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "arm", + target_arch = "hexagon", + target_arch = "m68k", + target_arch = "csky", + target_arch = "powerpc", + target_arch = "sparc", + target_arch = "x86_64", + target_arch = "x86", + ) + ), + repr(align(4)) + )] + #[cfg_attr( + any( + target_pointer_width = "64", + not(any( + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "arm", + target_arch = "hexagon", + target_arch = "m68k", + target_arch = "csky", + target_arch = "powerpc", + target_arch = "sparc", + target_arch = "x86_64", + target_arch = "x86", + )) + ), + repr(align(8)) + )] + pub struct pthread_mutex_t { + #[doc(hidden)] + size: [c_char; crate::__SIZEOF_PTHREAD_MUTEX_T], + } + + #[cfg_attr( + all( + target_pointer_width = "32", + any( + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "arm", + target_arch = "hexagon", + target_arch = "m68k", + target_arch = "csky", + target_arch = "powerpc", + target_arch = "sparc", + target_arch = "x86_64", + target_arch = "x86" + ) + ), + repr(align(4)) + )] + #[cfg_attr( + any( + target_pointer_width = "64", + not(any( + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "arm", + target_arch = "hexagon", + target_arch = "m68k", + target_arch = "powerpc", + target_arch = "sparc", + target_arch = "x86_64", + target_arch = "x86" + )) + ), + repr(align(8)) + )] + pub struct pthread_rwlock_t { + size: [u8; crate::__SIZEOF_PTHREAD_RWLOCK_T], + } + + #[cfg_attr( + all( + target_pointer_width = "32", + any( + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "arm", + target_arch = "hexagon", + target_arch = "m68k", + target_arch = "csky", + target_arch = "powerpc", + target_arch = "sparc", + target_arch = "x86_64", + target_arch = "x86" + ) + ), + repr(align(4)) + )] + #[cfg_attr( + any( + target_pointer_width = "64", + not(any( + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "arm", + target_arch = "hexagon", + target_arch = "m68k", + target_arch = "csky", + target_arch = "powerpc", + target_arch = "sparc", + target_arch = "x86_64", + target_arch = "x86" + )) + ), + repr(align(8)) + )] + pub struct pthread_barrier_t { + size: [u8; crate::__SIZEOF_PTHREAD_BARRIER_T], + } + + pub struct uinput_setup { + pub id: input_id, + pub name: [c_char; UINPUT_MAX_NAME_SIZE], + pub ff_effects_max: __u32, + } + + pub struct uinput_user_dev { + pub name: [c_char; UINPUT_MAX_NAME_SIZE], + pub id: input_id, + pub ff_effects_max: __u32, + pub absmax: [__s32; ABS_CNT], + pub absmin: [__s32; ABS_CNT], + pub absfuzz: [__s32; ABS_CNT], + pub absflat: [__s32; ABS_CNT], + } + + // x32 compatibility + // See https://sourceware.org/bugzilla/show_bug.cgi?id=21279 + pub struct mq_attr { + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub mq_flags: i64, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub mq_maxmsg: i64, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub mq_msgsize: i64, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub mq_curmsgs: i64, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pad: Padding<[i64; 4]>, + + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub mq_flags: c_long, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub mq_maxmsg: c_long, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub mq_msgsize: c_long, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub mq_curmsgs: c_long, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pad: Padding<[c_long; 4]>, + } + + pub struct hwtstamp_config { + pub flags: c_int, + pub tx_type: c_int, + pub rx_filter: c_int, + } + + pub struct sched_attr { + pub size: __u32, + pub sched_policy: __u32, + pub sched_flags: crate::__u64, + pub sched_nice: __s32, + pub sched_priority: __u32, + pub sched_runtime: crate::__u64, + pub sched_deadline: crate::__u64, + pub sched_period: crate::__u64, + } + + // linux/fcntl.h + + pub struct file_handle { + pub handle_bytes: c_uint, + pub handle_type: c_int, + pub f_handle: [c_uchar; 0], + } + + // include/uapi/linux/rtnetlink.h + pub struct ifinfomsg { + pub ifi_family: c_uchar, + __ifi_pad: Padding, + pub ifi_type: c_ushort, + pub ifi_index: c_int, + pub ifi_flags: c_uint, + pub ifi_change: c_uint, + } +} + +cfg_if! { + if #[cfg(not(target_arch = "sparc64"))] { + s! { + pub struct iw_thrspy { + pub addr: crate::sockaddr, + pub qual: iw_quality, + pub low: iw_quality, + pub high: iw_quality, + } + + pub struct iw_mlme { + pub cmd: __u16, + pub reason_code: __u16, + pub addr: crate::sockaddr, + } + + pub struct iw_michaelmicfailure { + pub flags: __u32, + pub src_addr: crate::sockaddr, + pub tsc: [__u8; IW_ENCODE_SEQ_MAX_SIZE], + } + } + } +} + +s_no_extra_traits! { + /// WARNING: The `PartialEq`, `Eq` and `Hash` implementations of this + /// type are unsound and will be removed in the future. + #[deprecated( + note = "this struct has unsafe trait implementations that will be \ + removed in the future", + since = "0.2.80" + )] + pub struct af_alg_iv { + pub ivlen: u32, + pub iv: [c_uchar; 0], + } + + pub union tpacket_req_u { + pub req: crate::tpacket_req, + pub req3: crate::tpacket_req3, + } + + pub union tpacket_bd_header_u { + pub bh1: crate::tpacket_hdr_v1, + } + + pub struct tpacket_block_desc { + pub version: __u32, + pub offset_to_priv: __u32, + pub hdr: crate::tpacket_bd_header_u, + } + + // linux/net_tstamp.h + pub struct sock_txtime { + pub clockid: crate::clockid_t, + pub flags: __u32, + } + + // linux/wireless.h + pub union iwreq_data { + pub name: [c_char; crate::IFNAMSIZ], + pub essid: iw_point, + pub nwid: iw_param, + pub freq: iw_freq, + pub sens: iw_param, + pub bitrate: iw_param, + pub txpower: iw_param, + pub rts: iw_param, + pub frag: iw_param, + pub mode: __u32, + pub retry: iw_param, + pub encoding: iw_point, + pub power: iw_param, + pub qual: iw_quality, + pub ap_addr: crate::sockaddr, + pub addr: crate::sockaddr, + pub param: iw_param, + pub data: iw_point, + } + + pub struct iw_event { + pub len: __u16, + pub cmd: __u16, + pub u: iwreq_data, + } + + pub union __c_anonymous_iwreq { + pub ifrn_name: [c_char; crate::IFNAMSIZ], + } + + pub struct iwreq { + pub ifr_ifrn: __c_anonymous_iwreq, + pub u: iwreq_data, + } + + // linux/ptp_clock.h + pub union __c_anonymous_ptp_perout_request_1 { + pub start: ptp_clock_time, + pub phase: ptp_clock_time, + } + + pub union __c_anonymous_ptp_perout_request_2 { + pub on: ptp_clock_time, + pub rsv: [c_uint; 4], + } + + pub struct ptp_perout_request { + pub anonymous_1: __c_anonymous_ptp_perout_request_1, + pub period: ptp_clock_time, + pub index: c_uint, + pub flags: c_uint, + pub anonymous_2: __c_anonymous_ptp_perout_request_2, + } + + // linux/if_xdp.h + pub struct xsk_tx_metadata { + pub flags: crate::__u64, + pub xsk_tx_metadata_union: __c_anonymous_xsk_tx_metadata_union, + } + + pub union __c_anonymous_xsk_tx_metadata_union { + pub request: xsk_tx_metadata_request, + pub completion: xsk_tx_metadata_completion, + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + #[allow(deprecated)] + impl af_alg_iv { + fn as_slice(&self) -> &[u8] { + unsafe { ::core::slice::from_raw_parts(self.iv.as_ptr(), self.ivlen as usize) } + } + } + + #[allow(deprecated)] + impl PartialEq for af_alg_iv { + fn eq(&self, other: &af_alg_iv) -> bool { + *self.as_slice() == *other.as_slice() + } + } + + #[allow(deprecated)] + impl Eq for af_alg_iv {} + + #[allow(deprecated)] + impl hash::Hash for af_alg_iv { + fn hash(&self, state: &mut H) { + self.as_slice().hash(state); + } + } + } +} + +pub const POSIX_SPAWN_USEVFORK: c_int = 64; +pub const POSIX_SPAWN_SETSID: c_int = 128; + +pub const F_SEAL_FUTURE_WRITE: c_int = 0x0010; +pub const F_SEAL_EXEC: c_int = 0x0020; + +pub const IFF_LOWER_UP: c_int = 0x10000; +pub const IFF_DORMANT: c_int = 0x20000; +pub const IFF_ECHO: c_int = 0x40000; + +// linux/fcntl.h +pub const AT_EXECVE_CHECK: c_int = 0x10000; + +pub const MAX_HANDLE_SZ: c_int = 128; +pub const AT_HANDLE_FID: c_int = 0x200; +pub const AT_HANDLE_MNT_ID_UNIQUE: c_int = 0x001; +pub const AT_HANDLE_CONNECTABLE: c_int = 0x002; + +// linux/if_addr.h +pub const IFA_UNSPEC: c_ushort = 0; +pub const IFA_ADDRESS: c_ushort = 1; +pub const IFA_LOCAL: c_ushort = 2; +pub const IFA_LABEL: c_ushort = 3; +pub const IFA_BROADCAST: c_ushort = 4; +pub const IFA_ANYCAST: c_ushort = 5; +pub const IFA_CACHEINFO: c_ushort = 6; +pub const IFA_MULTICAST: c_ushort = 7; +pub const IFA_FLAGS: c_ushort = 8; + +pub const IFA_F_SECONDARY: u32 = 0x01; +pub const IFA_F_TEMPORARY: u32 = 0x01; +pub const IFA_F_NODAD: u32 = 0x02; +pub const IFA_F_OPTIMISTIC: u32 = 0x04; +pub const IFA_F_DADFAILED: u32 = 0x08; +pub const IFA_F_HOMEADDRESS: u32 = 0x10; +pub const IFA_F_DEPRECATED: u32 = 0x20; +pub const IFA_F_TENTATIVE: u32 = 0x40; +pub const IFA_F_PERMANENT: u32 = 0x80; +pub const IFA_F_MANAGETEMPADDR: u32 = 0x100; +pub const IFA_F_NOPREFIXROUTE: u32 = 0x200; +pub const IFA_F_MCAUTOJOIN: u32 = 0x400; +pub const IFA_F_STABLE_PRIVACY: u32 = 0x800; + +// linux/fs.h + +// Flags for preadv2/pwritev2 +pub const RWF_HIPRI: c_int = 0x00000001; +pub const RWF_DSYNC: c_int = 0x00000002; +pub const RWF_SYNC: c_int = 0x00000004; +pub const RWF_NOWAIT: c_int = 0x00000008; +pub const RWF_APPEND: c_int = 0x00000010; +pub const RWF_NOAPPEND: c_int = 0x00000020; +pub const RWF_ATOMIC: c_int = 0x00000040; +pub const RWF_DONTCACHE: c_int = 0x00000080; + +// linux/if_link.h +pub const IFLA_UNSPEC: c_ushort = 0; +pub const IFLA_ADDRESS: c_ushort = 1; +pub const IFLA_BROADCAST: c_ushort = 2; +pub const IFLA_IFNAME: c_ushort = 3; +pub const IFLA_MTU: c_ushort = 4; +pub const IFLA_LINK: c_ushort = 5; +pub const IFLA_QDISC: c_ushort = 6; +pub const IFLA_STATS: c_ushort = 7; +pub const IFLA_COST: c_ushort = 8; +pub const IFLA_PRIORITY: c_ushort = 9; +pub const IFLA_MASTER: c_ushort = 10; +pub const IFLA_WIRELESS: c_ushort = 11; +pub const IFLA_PROTINFO: c_ushort = 12; +pub const IFLA_TXQLEN: c_ushort = 13; +pub const IFLA_MAP: c_ushort = 14; +pub const IFLA_WEIGHT: c_ushort = 15; +pub const IFLA_OPERSTATE: c_ushort = 16; +pub const IFLA_LINKMODE: c_ushort = 17; +pub const IFLA_LINKINFO: c_ushort = 18; +pub const IFLA_NET_NS_PID: c_ushort = 19; +pub const IFLA_IFALIAS: c_ushort = 20; +pub const IFLA_NUM_VF: c_ushort = 21; +pub const IFLA_VFINFO_LIST: c_ushort = 22; +pub const IFLA_STATS64: c_ushort = 23; +pub const IFLA_VF_PORTS: c_ushort = 24; +pub const IFLA_PORT_SELF: c_ushort = 25; +pub const IFLA_AF_SPEC: c_ushort = 26; +pub const IFLA_GROUP: c_ushort = 27; +pub const IFLA_NET_NS_FD: c_ushort = 28; +pub const IFLA_EXT_MASK: c_ushort = 29; +pub const IFLA_PROMISCUITY: c_ushort = 30; +pub const IFLA_NUM_TX_QUEUES: c_ushort = 31; +pub const IFLA_NUM_RX_QUEUES: c_ushort = 32; +pub const IFLA_CARRIER: c_ushort = 33; +pub const IFLA_PHYS_PORT_ID: c_ushort = 34; +pub const IFLA_CARRIER_CHANGES: c_ushort = 35; +pub const IFLA_PHYS_SWITCH_ID: c_ushort = 36; +pub const IFLA_LINK_NETNSID: c_ushort = 37; +pub const IFLA_PHYS_PORT_NAME: c_ushort = 38; +pub const IFLA_PROTO_DOWN: c_ushort = 39; +pub const IFLA_GSO_MAX_SEGS: c_ushort = 40; +pub const IFLA_GSO_MAX_SIZE: c_ushort = 41; +pub const IFLA_PAD: c_ushort = 42; +pub const IFLA_XDP: c_ushort = 43; +pub const IFLA_EVENT: c_ushort = 44; +pub const IFLA_NEW_NETNSID: c_ushort = 45; +pub const IFLA_IF_NETNSID: c_ushort = 46; +pub const IFLA_TARGET_NETNSID: c_ushort = IFLA_IF_NETNSID; +pub const IFLA_CARRIER_UP_COUNT: c_ushort = 47; +pub const IFLA_CARRIER_DOWN_COUNT: c_ushort = 48; +pub const IFLA_NEW_IFINDEX: c_ushort = 49; +pub const IFLA_MIN_MTU: c_ushort = 50; +pub const IFLA_MAX_MTU: c_ushort = 51; +pub const IFLA_PROP_LIST: c_ushort = 52; +pub const IFLA_ALT_IFNAME: c_ushort = 53; +pub const IFLA_PERM_ADDRESS: c_ushort = 54; +pub const IFLA_PROTO_DOWN_REASON: c_ushort = 55; +pub const IFLA_PARENT_DEV_NAME: c_ushort = 56; +pub const IFLA_PARENT_DEV_BUS_NAME: c_ushort = 57; +pub const IFLA_GRO_MAX_SIZE: c_ushort = 58; +pub const IFLA_TSO_MAX_SIZE: c_ushort = 59; +pub const IFLA_TSO_MAX_SEGS: c_ushort = 60; +pub const IFLA_ALLMULTI: c_ushort = 61; + +pub const IFLA_INFO_UNSPEC: c_ushort = 0; +pub const IFLA_INFO_KIND: c_ushort = 1; +pub const IFLA_INFO_DATA: c_ushort = 2; +pub const IFLA_INFO_XSTATS: c_ushort = 3; +pub const IFLA_INFO_SLAVE_KIND: c_ushort = 4; +pub const IFLA_INFO_SLAVE_DATA: c_ushort = 5; + +// Since Linux 3.1 +pub const SEEK_DATA: c_int = 3; +pub const SEEK_HOLE: c_int = 4; + +// linux/mempolicy.h +pub const MPOL_DEFAULT: c_int = 0; +pub const MPOL_PREFERRED: c_int = 1; +pub const MPOL_BIND: c_int = 2; +pub const MPOL_INTERLEAVE: c_int = 3; +pub const MPOL_LOCAL: c_int = 4; +pub const MPOL_F_NUMA_BALANCING: c_int = 1 << 13; +pub const MPOL_F_RELATIVE_NODES: c_int = 1 << 14; +pub const MPOL_F_STATIC_NODES: c_int = 1 << 15; + +pub const PTHREAD_MUTEX_INITIALIZER: crate::pthread_mutex_t = crate::pthread_mutex_t { + size: [0; crate::__SIZEOF_PTHREAD_MUTEX_T], +}; +pub const PTHREAD_COND_INITIALIZER: crate::pthread_cond_t = crate::pthread_cond_t { + size: [0; crate::__SIZEOF_PTHREAD_COND_T], +}; +pub const PTHREAD_RWLOCK_INITIALIZER: crate::pthread_rwlock_t = crate::pthread_rwlock_t { + size: [0; crate::__SIZEOF_PTHREAD_RWLOCK_T], +}; + +pub const RENAME_NOREPLACE: c_uint = 1; +pub const RENAME_EXCHANGE: c_uint = 2; +pub const RENAME_WHITEOUT: c_uint = 4; + +pub const MSG_STAT: c_int = 11 | (crate::IPC_STAT & 0x100); +pub const MSG_INFO: c_int = 12; +pub const MSG_NOTIFICATION: c_int = 0x8000; + +pub const MSG_NOERROR: c_int = 0o10000; +pub const MSG_EXCEPT: c_int = 0o20000; +pub const MSG_ZEROCOPY: c_int = 0x4000000; + +pub const SEM_UNDO: c_int = 0x1000; + +pub const GETPID: c_int = 11; +pub const GETVAL: c_int = 12; +pub const GETALL: c_int = 13; +pub const GETNCNT: c_int = 14; +pub const GETZCNT: c_int = 15; +pub const SETVAL: c_int = 16; +pub const SETALL: c_int = 17; +pub const SEM_STAT: c_int = 18 | (crate::IPC_STAT & 0x100); +pub const SEM_INFO: c_int = 19; +pub const SEM_STAT_ANY: c_int = 20 | (crate::IPC_STAT & 0x100); + +pub const QFMT_VFS_OLD: c_int = 1; +pub const QFMT_VFS_V0: c_int = 2; +pub const QFMT_VFS_V1: c_int = 4; + +pub const EFD_SEMAPHORE: c_int = 0x1; + +pub const RB_AUTOBOOT: c_int = 0x01234567u32 as i32; +pub const RB_HALT_SYSTEM: c_int = 0xcdef0123u32 as i32; +pub const RB_ENABLE_CAD: c_int = 0x89abcdefu32 as i32; +pub const RB_DISABLE_CAD: c_int = 0x00000000u32 as i32; +pub const RB_POWER_OFF: c_int = 0x4321fedcu32 as i32; +pub const RB_SW_SUSPEND: c_int = 0xd000fce2u32 as i32; +pub const RB_KEXEC: c_int = 0x45584543u32 as i32; + +pub const SYNC_FILE_RANGE_WAIT_BEFORE: c_uint = 1; +pub const SYNC_FILE_RANGE_WRITE: c_uint = 2; +pub const SYNC_FILE_RANGE_WAIT_AFTER: c_uint = 4; + +pub const MREMAP_MAYMOVE: c_int = 1; +pub const MREMAP_FIXED: c_int = 2; +pub const MREMAP_DONTUNMAP: c_int = 4; + +// linux/nsfs.h +const NSIO: c_uint = 0xb7; + +pub const NS_GET_USERNS: Ioctl = _IO(NSIO, 0x1); +pub const NS_GET_PARENT: Ioctl = _IO(NSIO, 0x2); +pub const NS_GET_NSTYPE: Ioctl = _IO(NSIO, 0x3); +pub const NS_GET_OWNER_UID: Ioctl = _IO(NSIO, 0x4); + +pub const NS_GET_MNTNS_ID: Ioctl = _IOR::<__u64>(NSIO, 0x5); + +pub const NS_GET_PID_FROM_PIDNS: Ioctl = _IOR::(NSIO, 0x6); +pub const NS_GET_TGID_FROM_PIDNS: Ioctl = _IOR::(NSIO, 0x7); +pub const NS_GET_PID_IN_PIDNS: Ioctl = _IOR::(NSIO, 0x8); +pub const NS_GET_TGID_IN_PIDNS: Ioctl = _IOR::(NSIO, 0x9); + +pub const MNT_NS_INFO_SIZE_VER0: Ioctl = 16; + +pub const NS_MNT_GET_INFO: Ioctl = _IOR::(NSIO, 10); +pub const NS_MNT_GET_NEXT: Ioctl = _IOR::(NSIO, 11); +pub const NS_MNT_GET_PREV: Ioctl = _IOR::(NSIO, 12); + +pub const PR_SET_MDWE: c_int = 65; +pub const PR_GET_MDWE: c_int = 66; +pub const PR_MDWE_REFUSE_EXEC_GAIN: c_uint = 1 << 0; +pub const PR_MDWE_NO_INHERIT: c_uint = 1 << 1; +pub const PR_SET_MEMORY_MERGE: c_int = 67; +pub const PR_GET_MEMORY_MERGE: c_int = 68; + +pub const GRND_NONBLOCK: c_uint = 0x0001; +pub const GRND_RANDOM: c_uint = 0x0002; +pub const GRND_INSECURE: c_uint = 0x0004; + +// +pub const SECCOMP_MODE_DISABLED: c_uint = 0; +pub const SECCOMP_MODE_STRICT: c_uint = 1; +pub const SECCOMP_MODE_FILTER: c_uint = 2; + +pub const SECCOMP_SET_MODE_STRICT: c_uint = 0; +pub const SECCOMP_SET_MODE_FILTER: c_uint = 1; +pub const SECCOMP_GET_ACTION_AVAIL: c_uint = 2; +pub const SECCOMP_GET_NOTIF_SIZES: c_uint = 3; + +pub const SECCOMP_FILTER_FLAG_TSYNC: c_ulong = 1 << 0; +pub const SECCOMP_FILTER_FLAG_LOG: c_ulong = 1 << 1; +pub const SECCOMP_FILTER_FLAG_SPEC_ALLOW: c_ulong = 1 << 2; +pub const SECCOMP_FILTER_FLAG_NEW_LISTENER: c_ulong = 1 << 3; +pub const SECCOMP_FILTER_FLAG_TSYNC_ESRCH: c_ulong = 1 << 4; +pub const SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV: c_ulong = 1 << 5; + +pub const SECCOMP_RET_KILL_PROCESS: c_uint = 0x80000000; +pub const SECCOMP_RET_KILL_THREAD: c_uint = 0x00000000; +pub const SECCOMP_RET_KILL: c_uint = SECCOMP_RET_KILL_THREAD; +pub const SECCOMP_RET_TRAP: c_uint = 0x00030000; +pub const SECCOMP_RET_ERRNO: c_uint = 0x00050000; +pub const SECCOMP_RET_USER_NOTIF: c_uint = 0x7fc00000; +pub const SECCOMP_RET_TRACE: c_uint = 0x7ff00000; +pub const SECCOMP_RET_LOG: c_uint = 0x7ffc0000; +pub const SECCOMP_RET_ALLOW: c_uint = 0x7fff0000; + +pub const SECCOMP_RET_ACTION_FULL: c_uint = 0xffff0000; +pub const SECCOMP_RET_ACTION: c_uint = 0x7fff0000; +pub const SECCOMP_RET_DATA: c_uint = 0x0000ffff; + +pub const SECCOMP_USER_NOTIF_FLAG_CONTINUE: c_ulong = 1; + +pub const SECCOMP_ADDFD_FLAG_SETFD: c_ulong = 1; +pub const SECCOMP_ADDFD_FLAG_SEND: c_ulong = 2; + +pub const TFD_CLOEXEC: c_int = O_CLOEXEC; +pub const TFD_NONBLOCK: c_int = O_NONBLOCK; +pub const TFD_TIMER_ABSTIME: c_int = 1; +pub const TFD_TIMER_CANCEL_ON_SET: c_int = 2; + +pub const FALLOC_FL_KEEP_SIZE: c_int = 0x01; +pub const FALLOC_FL_PUNCH_HOLE: c_int = 0x02; +pub const FALLOC_FL_COLLAPSE_RANGE: c_int = 0x08; +pub const FALLOC_FL_ZERO_RANGE: c_int = 0x10; +pub const FALLOC_FL_INSERT_RANGE: c_int = 0x20; +pub const FALLOC_FL_UNSHARE_RANGE: c_int = 0x40; + +#[deprecated( + since = "0.2.55", + note = "ENOATTR is not available on Linux; use ENODATA instead" +)] +pub const ENOATTR: c_int = crate::ENODATA; + +pub const SO_ORIGINAL_DST: c_int = 80; + +pub const IP_RECVFRAGSIZE: c_int = 25; + +pub const IPV6_FLOWINFO: c_int = 11; +pub const IPV6_FLOWLABEL_MGR: c_int = 32; +pub const IPV6_FLOWINFO_SEND: c_int = 33; +pub const IPV6_RECVFRAGSIZE: c_int = 77; +pub const IPV6_FREEBIND: c_int = 78; +pub const IPV6_FLOWINFO_FLOWLABEL: c_int = 0x000fffff; +pub const IPV6_FLOWINFO_PRIORITY: c_int = 0x0ff00000; + +// SO_MEMINFO offsets +pub const SK_MEMINFO_RMEM_ALLOC: c_int = 0; +pub const SK_MEMINFO_RCVBUF: c_int = 1; +pub const SK_MEMINFO_WMEM_ALLOC: c_int = 2; +pub const SK_MEMINFO_SNDBUF: c_int = 3; +pub const SK_MEMINFO_FWD_ALLOC: c_int = 4; +pub const SK_MEMINFO_WMEM_QUEUED: c_int = 5; +pub const SK_MEMINFO_OPTMEM: c_int = 6; +pub const SK_MEMINFO_BACKLOG: c_int = 7; +pub const SK_MEMINFO_DROPS: c_int = 8; + +// linux/close_range.h +pub const CLOSE_RANGE_UNSHARE: c_uint = 1 << 1; +pub const CLOSE_RANGE_CLOEXEC: c_uint = 1 << 2; + +// linux/filter.h +pub const SKF_AD_OFF: c_int = -0x1000; +pub const SKF_AD_PROTOCOL: c_int = 0; +pub const SKF_AD_PKTTYPE: c_int = 4; +pub const SKF_AD_IFINDEX: c_int = 8; +pub const SKF_AD_NLATTR: c_int = 12; +pub const SKF_AD_NLATTR_NEST: c_int = 16; +pub const SKF_AD_MARK: c_int = 20; +pub const SKF_AD_QUEUE: c_int = 24; +pub const SKF_AD_HATYPE: c_int = 28; +pub const SKF_AD_RXHASH: c_int = 32; +pub const SKF_AD_CPU: c_int = 36; +pub const SKF_AD_ALU_XOR_X: c_int = 40; +pub const SKF_AD_VLAN_TAG: c_int = 44; +pub const SKF_AD_VLAN_TAG_PRESENT: c_int = 48; +pub const SKF_AD_PAY_OFFSET: c_int = 52; +pub const SKF_AD_RANDOM: c_int = 56; +pub const SKF_AD_VLAN_TPID: c_int = 60; +pub const SKF_AD_MAX: c_int = 64; +pub const SKF_NET_OFF: c_int = -0x100000; +pub const SKF_LL_OFF: c_int = -0x200000; +pub const BPF_NET_OFF: c_int = SKF_NET_OFF; +pub const BPF_LL_OFF: c_int = SKF_LL_OFF; +pub const BPF_MEMWORDS: c_int = 16; +pub const BPF_MAXINSNS: c_int = 4096; + +// linux/bpf_common.h +pub const BPF_LD: __u32 = 0x00; +pub const BPF_LDX: __u32 = 0x01; +pub const BPF_ST: __u32 = 0x02; +pub const BPF_STX: __u32 = 0x03; +pub const BPF_ALU: __u32 = 0x04; +pub const BPF_JMP: __u32 = 0x05; +pub const BPF_RET: __u32 = 0x06; +pub const BPF_MISC: __u32 = 0x07; +pub const BPF_W: __u32 = 0x00; +pub const BPF_H: __u32 = 0x08; +pub const BPF_B: __u32 = 0x10; +pub const BPF_IMM: __u32 = 0x00; +pub const BPF_ABS: __u32 = 0x20; +pub const BPF_IND: __u32 = 0x40; +pub const BPF_MEM: __u32 = 0x60; +pub const BPF_LEN: __u32 = 0x80; +pub const BPF_MSH: __u32 = 0xa0; +pub const BPF_ADD: __u32 = 0x00; +pub const BPF_SUB: __u32 = 0x10; +pub const BPF_MUL: __u32 = 0x20; +pub const BPF_DIV: __u32 = 0x30; +pub const BPF_OR: __u32 = 0x40; +pub const BPF_AND: __u32 = 0x50; +pub const BPF_LSH: __u32 = 0x60; +pub const BPF_RSH: __u32 = 0x70; +pub const BPF_NEG: __u32 = 0x80; +pub const BPF_MOD: __u32 = 0x90; +pub const BPF_XOR: __u32 = 0xa0; +pub const BPF_JA: __u32 = 0x00; +pub const BPF_JEQ: __u32 = 0x10; +pub const BPF_JGT: __u32 = 0x20; +pub const BPF_JGE: __u32 = 0x30; +pub const BPF_JSET: __u32 = 0x40; +pub const BPF_K: __u32 = 0x00; +pub const BPF_X: __u32 = 0x08; + +// linux/filter.h + +pub const BPF_A: __u32 = 0x10; +pub const BPF_TAX: __u32 = 0x00; +pub const BPF_TXA: __u32 = 0x80; + +// linux/openat2.h +pub const RESOLVE_NO_XDEV: crate::__u64 = 0x01; +pub const RESOLVE_NO_MAGICLINKS: crate::__u64 = 0x02; +pub const RESOLVE_NO_SYMLINKS: crate::__u64 = 0x04; +pub const RESOLVE_BENEATH: crate::__u64 = 0x08; +pub const RESOLVE_IN_ROOT: crate::__u64 = 0x10; +pub const RESOLVE_CACHED: crate::__u64 = 0x20; + +// linux/if_ether.h +pub const ETH_ALEN: c_int = 6; +pub const ETH_HLEN: c_int = 14; +pub const ETH_ZLEN: c_int = 60; +pub const ETH_DATA_LEN: c_int = 1500; +pub const ETH_FRAME_LEN: c_int = 1514; +pub const ETH_FCS_LEN: c_int = 4; + +// These are the defined Ethernet Protocol ID's. +pub const ETH_P_LOOP: c_int = 0x0060; +pub const ETH_P_PUP: c_int = 0x0200; +pub const ETH_P_PUPAT: c_int = 0x0201; +pub const ETH_P_IP: c_int = 0x0800; +pub const ETH_P_X25: c_int = 0x0805; +pub const ETH_P_ARP: c_int = 0x0806; +pub const ETH_P_BPQ: c_int = 0x08FF; +pub const ETH_P_IEEEPUP: c_int = 0x0a00; +pub const ETH_P_IEEEPUPAT: c_int = 0x0a01; +pub const ETH_P_BATMAN: c_int = 0x4305; +pub const ETH_P_DEC: c_int = 0x6000; +pub const ETH_P_DNA_DL: c_int = 0x6001; +pub const ETH_P_DNA_RC: c_int = 0x6002; +pub const ETH_P_DNA_RT: c_int = 0x6003; +pub const ETH_P_LAT: c_int = 0x6004; +pub const ETH_P_DIAG: c_int = 0x6005; +pub const ETH_P_CUST: c_int = 0x6006; +pub const ETH_P_SCA: c_int = 0x6007; +pub const ETH_P_TEB: c_int = 0x6558; +pub const ETH_P_RARP: c_int = 0x8035; +pub const ETH_P_ATALK: c_int = 0x809B; +pub const ETH_P_AARP: c_int = 0x80F3; +pub const ETH_P_8021Q: c_int = 0x8100; +pub const ETH_P_IPX: c_int = 0x8137; +pub const ETH_P_IPV6: c_int = 0x86DD; +pub const ETH_P_PAUSE: c_int = 0x8808; +pub const ETH_P_SLOW: c_int = 0x8809; +pub const ETH_P_WCCP: c_int = 0x883E; +pub const ETH_P_MPLS_UC: c_int = 0x8847; +pub const ETH_P_MPLS_MC: c_int = 0x8848; +pub const ETH_P_ATMMPOA: c_int = 0x884c; +pub const ETH_P_PPP_DISC: c_int = 0x8863; +pub const ETH_P_PPP_SES: c_int = 0x8864; +pub const ETH_P_LINK_CTL: c_int = 0x886c; +pub const ETH_P_ATMFATE: c_int = 0x8884; +pub const ETH_P_PAE: c_int = 0x888E; +pub const ETH_P_AOE: c_int = 0x88A2; +pub const ETH_P_8021AD: c_int = 0x88A8; +pub const ETH_P_802_EX1: c_int = 0x88B5; +pub const ETH_P_TIPC: c_int = 0x88CA; +pub const ETH_P_MACSEC: c_int = 0x88E5; +pub const ETH_P_8021AH: c_int = 0x88E7; +pub const ETH_P_MVRP: c_int = 0x88F5; +pub const ETH_P_1588: c_int = 0x88F7; +pub const ETH_P_PRP: c_int = 0x88FB; +pub const ETH_P_FCOE: c_int = 0x8906; +pub const ETH_P_TDLS: c_int = 0x890D; +pub const ETH_P_FIP: c_int = 0x8914; +pub const ETH_P_80221: c_int = 0x8917; +pub const ETH_P_LOOPBACK: c_int = 0x9000; +pub const ETH_P_QINQ1: c_int = 0x9100; +pub const ETH_P_QINQ2: c_int = 0x9200; +pub const ETH_P_QINQ3: c_int = 0x9300; +pub const ETH_P_EDSA: c_int = 0xDADA; +pub const ETH_P_AF_IUCV: c_int = 0xFBFB; + +pub const ETH_P_802_3_MIN: c_int = 0x0600; + +// Non DIX types. Won't clash for 1500 types. +pub const ETH_P_802_3: c_int = 0x0001; +pub const ETH_P_AX25: c_int = 0x0002; +pub const ETH_P_ALL: c_int = 0x0003; +pub const ETH_P_802_2: c_int = 0x0004; +pub const ETH_P_SNAP: c_int = 0x0005; +pub const ETH_P_DDCMP: c_int = 0x0006; +pub const ETH_P_WAN_PPP: c_int = 0x0007; +pub const ETH_P_PPP_MP: c_int = 0x0008; +pub const ETH_P_LOCALTALK: c_int = 0x0009; +pub const ETH_P_CANFD: c_int = 0x000D; +pub const ETH_P_PPPTALK: c_int = 0x0010; +pub const ETH_P_TR_802_2: c_int = 0x0011; +pub const ETH_P_MOBITEX: c_int = 0x0015; +pub const ETH_P_CONTROL: c_int = 0x0016; +pub const ETH_P_IRDA: c_int = 0x0017; +pub const ETH_P_ECONET: c_int = 0x0018; +pub const ETH_P_HDLC: c_int = 0x0019; +pub const ETH_P_ARCNET: c_int = 0x001A; +pub const ETH_P_DSA: c_int = 0x001B; +pub const ETH_P_TRAILER: c_int = 0x001C; +pub const ETH_P_PHONET: c_int = 0x00F5; +pub const ETH_P_IEEE802154: c_int = 0x00F6; +pub const ETH_P_CAIF: c_int = 0x00F7; + +// DIFF(main): changed to `c_short` in f62eb023ab +pub const POSIX_SPAWN_RESETIDS: c_int = 0x01; +pub const POSIX_SPAWN_SETPGROUP: c_int = 0x02; +pub const POSIX_SPAWN_SETSIGDEF: c_int = 0x04; +pub const POSIX_SPAWN_SETSIGMASK: c_int = 0x08; +pub const POSIX_SPAWN_SETSCHEDPARAM: c_int = 0x10; +pub const POSIX_SPAWN_SETSCHEDULER: c_int = 0x20; + +// linux/netfilter/nfnetlink.h +pub const NFNLGRP_NONE: c_int = 0; +pub const NFNLGRP_CONNTRACK_NEW: c_int = 1; +pub const NFNLGRP_CONNTRACK_UPDATE: c_int = 2; +pub const NFNLGRP_CONNTRACK_DESTROY: c_int = 3; +pub const NFNLGRP_CONNTRACK_EXP_NEW: c_int = 4; +pub const NFNLGRP_CONNTRACK_EXP_UPDATE: c_int = 5; +pub const NFNLGRP_CONNTRACK_EXP_DESTROY: c_int = 6; +pub const NFNLGRP_NFTABLES: c_int = 7; +pub const NFNLGRP_ACCT_QUOTA: c_int = 8; +pub const NFNLGRP_NFTRACE: c_int = 9; + +pub const NFNETLINK_V0: c_int = 0; + +pub const NFNL_SUBSYS_NONE: c_int = 0; +pub const NFNL_SUBSYS_CTNETLINK: c_int = 1; +pub const NFNL_SUBSYS_CTNETLINK_EXP: c_int = 2; +pub const NFNL_SUBSYS_QUEUE: c_int = 3; +pub const NFNL_SUBSYS_ULOG: c_int = 4; +pub const NFNL_SUBSYS_OSF: c_int = 5; +pub const NFNL_SUBSYS_IPSET: c_int = 6; +pub const NFNL_SUBSYS_ACCT: c_int = 7; +pub const NFNL_SUBSYS_CTNETLINK_TIMEOUT: c_int = 8; +pub const NFNL_SUBSYS_CTHELPER: c_int = 9; +pub const NFNL_SUBSYS_NFTABLES: c_int = 10; +pub const NFNL_SUBSYS_NFT_COMPAT: c_int = 11; +pub const NFNL_SUBSYS_HOOK: c_int = 12; +pub const NFNL_SUBSYS_COUNT: c_int = 13; + +pub const NFNL_MSG_BATCH_BEGIN: c_int = crate::NLMSG_MIN_TYPE; +pub const NFNL_MSG_BATCH_END: c_int = crate::NLMSG_MIN_TYPE + 1; + +pub const NFNL_BATCH_UNSPEC: c_int = 0; +pub const NFNL_BATCH_GENID: c_int = 1; + +// linux/netfilter/nfnetlink_log.h +pub const NFULNL_MSG_PACKET: c_int = 0; +pub const NFULNL_MSG_CONFIG: c_int = 1; + +pub const NFULA_VLAN_UNSPEC: c_int = 0; +pub const NFULA_VLAN_PROTO: c_int = 1; +pub const NFULA_VLAN_TCI: c_int = 2; + +pub const NFULA_UNSPEC: c_int = 0; +pub const NFULA_PACKET_HDR: c_int = 1; +pub const NFULA_MARK: c_int = 2; +pub const NFULA_TIMESTAMP: c_int = 3; +pub const NFULA_IFINDEX_INDEV: c_int = 4; +pub const NFULA_IFINDEX_OUTDEV: c_int = 5; +pub const NFULA_IFINDEX_PHYSINDEV: c_int = 6; +pub const NFULA_IFINDEX_PHYSOUTDEV: c_int = 7; +pub const NFULA_HWADDR: c_int = 8; +pub const NFULA_PAYLOAD: c_int = 9; +pub const NFULA_PREFIX: c_int = 10; +pub const NFULA_UID: c_int = 11; +pub const NFULA_SEQ: c_int = 12; +pub const NFULA_SEQ_GLOBAL: c_int = 13; +pub const NFULA_GID: c_int = 14; +pub const NFULA_HWTYPE: c_int = 15; +pub const NFULA_HWHEADER: c_int = 16; +pub const NFULA_HWLEN: c_int = 17; +pub const NFULA_CT: c_int = 18; +pub const NFULA_CT_INFO: c_int = 19; +pub const NFULA_VLAN: c_int = 20; +pub const NFULA_L2HDR: c_int = 21; + +pub const NFULNL_CFG_CMD_NONE: c_int = 0; +pub const NFULNL_CFG_CMD_BIND: c_int = 1; +pub const NFULNL_CFG_CMD_UNBIND: c_int = 2; +pub const NFULNL_CFG_CMD_PF_BIND: c_int = 3; +pub const NFULNL_CFG_CMD_PF_UNBIND: c_int = 4; + +pub const NFULA_CFG_UNSPEC: c_int = 0; +pub const NFULA_CFG_CMD: c_int = 1; +pub const NFULA_CFG_MODE: c_int = 2; +pub const NFULA_CFG_NLBUFSIZ: c_int = 3; +pub const NFULA_CFG_TIMEOUT: c_int = 4; +pub const NFULA_CFG_QTHRESH: c_int = 5; +pub const NFULA_CFG_FLAGS: c_int = 6; + +pub const NFULNL_COPY_NONE: c_int = 0x00; +pub const NFULNL_COPY_META: c_int = 0x01; +pub const NFULNL_COPY_PACKET: c_int = 0x02; + +pub const NFULNL_CFG_F_SEQ: c_int = 0x0001; +pub const NFULNL_CFG_F_SEQ_GLOBAL: c_int = 0x0002; +pub const NFULNL_CFG_F_CONNTRACK: c_int = 0x0004; + +// linux/netfilter/nfnetlink_queue.h +pub const NFQNL_MSG_PACKET: c_int = 0; +pub const NFQNL_MSG_VERDICT: c_int = 1; +pub const NFQNL_MSG_CONFIG: c_int = 2; +pub const NFQNL_MSG_VERDICT_BATCH: c_int = 3; + +pub const NFQA_UNSPEC: c_int = 0; +pub const NFQA_PACKET_HDR: c_int = 1; +pub const NFQA_VERDICT_HDR: c_int = 2; +pub const NFQA_MARK: c_int = 3; +pub const NFQA_TIMESTAMP: c_int = 4; +pub const NFQA_IFINDEX_INDEV: c_int = 5; +pub const NFQA_IFINDEX_OUTDEV: c_int = 6; +pub const NFQA_IFINDEX_PHYSINDEV: c_int = 7; +pub const NFQA_IFINDEX_PHYSOUTDEV: c_int = 8; +pub const NFQA_HWADDR: c_int = 9; +pub const NFQA_PAYLOAD: c_int = 10; +pub const NFQA_CT: c_int = 11; +pub const NFQA_CT_INFO: c_int = 12; +pub const NFQA_CAP_LEN: c_int = 13; +pub const NFQA_SKB_INFO: c_int = 14; +pub const NFQA_EXP: c_int = 15; +pub const NFQA_UID: c_int = 16; +pub const NFQA_GID: c_int = 17; +pub const NFQA_SECCTX: c_int = 18; +pub const NFQA_VLAN: c_int = 19; +pub const NFQA_L2HDR: c_int = 20; +pub const NFQA_PRIORITY: c_int = 21; + +pub const NFQA_VLAN_UNSPEC: c_int = 0; +pub const NFQA_VLAN_PROTO: c_int = 1; +pub const NFQA_VLAN_TCI: c_int = 2; + +pub const NFQNL_CFG_CMD_NONE: c_int = 0; +pub const NFQNL_CFG_CMD_BIND: c_int = 1; +pub const NFQNL_CFG_CMD_UNBIND: c_int = 2; +pub const NFQNL_CFG_CMD_PF_BIND: c_int = 3; +pub const NFQNL_CFG_CMD_PF_UNBIND: c_int = 4; + +pub const NFQNL_COPY_NONE: c_int = 0; +pub const NFQNL_COPY_META: c_int = 1; +pub const NFQNL_COPY_PACKET: c_int = 2; + +pub const NFQA_CFG_UNSPEC: c_int = 0; +pub const NFQA_CFG_CMD: c_int = 1; +pub const NFQA_CFG_PARAMS: c_int = 2; +pub const NFQA_CFG_QUEUE_MAXLEN: c_int = 3; +pub const NFQA_CFG_MASK: c_int = 4; +pub const NFQA_CFG_FLAGS: c_int = 5; + +pub const NFQA_CFG_F_FAIL_OPEN: c_int = 0x0001; +pub const NFQA_CFG_F_CONNTRACK: c_int = 0x0002; +pub const NFQA_CFG_F_GSO: c_int = 0x0004; +pub const NFQA_CFG_F_UID_GID: c_int = 0x0008; +pub const NFQA_CFG_F_SECCTX: c_int = 0x0010; +pub const NFQA_CFG_F_MAX: c_int = 0x0020; + +pub const NFQA_SKB_CSUMNOTREADY: c_int = 0x0001; +pub const NFQA_SKB_GSO: c_int = 0x0002; +pub const NFQA_SKB_CSUM_NOTVERIFIED: c_int = 0x0004; + +// linux/genetlink.h + +pub const GENL_NAMSIZ: c_int = 16; + +pub const GENL_MIN_ID: c_int = crate::NLMSG_MIN_TYPE; +pub const GENL_MAX_ID: c_int = 1023; + +pub const GENL_ADMIN_PERM: c_int = 0x01; +pub const GENL_CMD_CAP_DO: c_int = 0x02; +pub const GENL_CMD_CAP_DUMP: c_int = 0x04; +pub const GENL_CMD_CAP_HASPOL: c_int = 0x08; + +pub const GENL_ID_CTRL: c_int = crate::NLMSG_MIN_TYPE; + +pub const CTRL_CMD_UNSPEC: c_int = 0; +pub const CTRL_CMD_NEWFAMILY: c_int = 1; +pub const CTRL_CMD_DELFAMILY: c_int = 2; +pub const CTRL_CMD_GETFAMILY: c_int = 3; +pub const CTRL_CMD_NEWOPS: c_int = 4; +pub const CTRL_CMD_DELOPS: c_int = 5; +pub const CTRL_CMD_GETOPS: c_int = 6; +pub const CTRL_CMD_NEWMCAST_GRP: c_int = 7; +pub const CTRL_CMD_DELMCAST_GRP: c_int = 8; +pub const CTRL_CMD_GETMCAST_GRP: c_int = 9; + +pub const CTRL_ATTR_UNSPEC: c_int = 0; +pub const CTRL_ATTR_FAMILY_ID: c_int = 1; +pub const CTRL_ATTR_FAMILY_NAME: c_int = 2; +pub const CTRL_ATTR_VERSION: c_int = 3; +pub const CTRL_ATTR_HDRSIZE: c_int = 4; +pub const CTRL_ATTR_MAXATTR: c_int = 5; +pub const CTRL_ATTR_OPS: c_int = 6; +pub const CTRL_ATTR_MCAST_GROUPS: c_int = 7; + +pub const CTRL_ATTR_OP_UNSPEC: c_int = 0; +pub const CTRL_ATTR_OP_ID: c_int = 1; +pub const CTRL_ATTR_OP_FLAGS: c_int = 2; + +pub const CTRL_ATTR_MCAST_GRP_UNSPEC: c_int = 0; +pub const CTRL_ATTR_MCAST_GRP_NAME: c_int = 1; +pub const CTRL_ATTR_MCAST_GRP_ID: c_int = 2; + +pub const PACKET_FANOUT: c_int = 18; +pub const PACKET_TX_HAS_OFF: c_int = 19; +pub const PACKET_QDISC_BYPASS: c_int = 20; +pub const PACKET_ROLLOVER_STATS: c_int = 21; +pub const PACKET_FANOUT_DATA: c_int = 22; +pub const PACKET_IGNORE_OUTGOING: c_int = 23; +pub const PACKET_VNET_HDR_SZ: c_int = 24; + +pub const PACKET_FANOUT_HASH: c_uint = 0; +pub const PACKET_FANOUT_LB: c_uint = 1; +pub const PACKET_FANOUT_CPU: c_uint = 2; +pub const PACKET_FANOUT_ROLLOVER: c_uint = 3; +pub const PACKET_FANOUT_RND: c_uint = 4; +pub const PACKET_FANOUT_QM: c_uint = 5; +pub const PACKET_FANOUT_CBPF: c_uint = 6; +pub const PACKET_FANOUT_EBPF: c_uint = 7; +pub const PACKET_FANOUT_FLAG_ROLLOVER: c_uint = 0x1000; +pub const PACKET_FANOUT_FLAG_UNIQUEID: c_uint = 0x2000; +pub const PACKET_FANOUT_FLAG_IGNORE_OUTGOING: c_uint = 0x4000; +pub const PACKET_FANOUT_FLAG_DEFRAG: c_uint = 0x8000; + +pub const TP_STATUS_KERNEL: __u32 = 0; +pub const TP_STATUS_USER: __u32 = 1 << 0; +pub const TP_STATUS_COPY: __u32 = 1 << 1; +pub const TP_STATUS_LOSING: __u32 = 1 << 2; +pub const TP_STATUS_CSUMNOTREADY: __u32 = 1 << 3; +pub const TP_STATUS_VLAN_VALID: __u32 = 1 << 4; +pub const TP_STATUS_BLK_TMO: __u32 = 1 << 5; +pub const TP_STATUS_VLAN_TPID_VALID: __u32 = 1 << 6; +pub const TP_STATUS_CSUM_VALID: __u32 = 1 << 7; + +pub const TP_STATUS_AVAILABLE: __u32 = 0; +pub const TP_STATUS_SEND_REQUEST: __u32 = 1 << 0; +pub const TP_STATUS_SENDING: __u32 = 1 << 1; +pub const TP_STATUS_WRONG_FORMAT: __u32 = 1 << 2; + +pub const TP_STATUS_TS_SOFTWARE: __u32 = 1 << 29; +pub const TP_STATUS_TS_SYS_HARDWARE: __u32 = 1 << 30; +pub const TP_STATUS_TS_RAW_HARDWARE: __u32 = 1 << 31; + +pub const TP_FT_REQ_FILL_RXHASH: __u32 = 1; + +pub const TPACKET_ALIGNMENT: usize = 16; + +pub const TPACKET_HDRLEN: usize = ((size_of::() + TPACKET_ALIGNMENT - 1) + & !(TPACKET_ALIGNMENT - 1)) + + size_of::(); +pub const TPACKET2_HDRLEN: usize = ((size_of::() + TPACKET_ALIGNMENT - 1) + & !(TPACKET_ALIGNMENT - 1)) + + size_of::(); +pub const TPACKET3_HDRLEN: usize = ((size_of::() + TPACKET_ALIGNMENT - 1) + & !(TPACKET_ALIGNMENT - 1)) + + size_of::(); + +// linux/netfilter.h +pub const NF_DROP: c_int = 0; +pub const NF_ACCEPT: c_int = 1; +pub const NF_STOLEN: c_int = 2; +pub const NF_QUEUE: c_int = 3; +pub const NF_REPEAT: c_int = 4; +pub const NF_STOP: c_int = 5; +pub const NF_MAX_VERDICT: c_int = NF_STOP; + +pub const NF_VERDICT_MASK: c_int = 0x000000ff; +pub const NF_VERDICT_FLAG_QUEUE_BYPASS: c_int = 0x00008000; + +pub const NF_VERDICT_QMASK: c_int = 0xffff0000; +pub const NF_VERDICT_QBITS: c_int = 16; + +pub const NF_VERDICT_BITS: c_int = 16; + +pub const NF_INET_PRE_ROUTING: c_int = 0; +pub const NF_INET_LOCAL_IN: c_int = 1; +pub const NF_INET_FORWARD: c_int = 2; +pub const NF_INET_LOCAL_OUT: c_int = 3; +pub const NF_INET_POST_ROUTING: c_int = 4; +pub const NF_INET_NUMHOOKS: c_int = 5; +pub const NF_INET_INGRESS: c_int = NF_INET_NUMHOOKS; + +pub const NF_NETDEV_INGRESS: c_int = 0; +pub const NF_NETDEV_EGRESS: c_int = 1; +pub const NF_NETDEV_NUMHOOKS: c_int = 2; + +// Some NFPROTO are not compatible with musl and are defined in submodules. +pub const NFPROTO_UNSPEC: c_int = 0; +pub const NFPROTO_INET: c_int = 1; +pub const NFPROTO_IPV4: c_int = 2; +pub const NFPROTO_ARP: c_int = 3; +pub const NFPROTO_NETDEV: c_int = 5; +pub const NFPROTO_BRIDGE: c_int = 7; +pub const NFPROTO_IPV6: c_int = 10; +pub const NFPROTO_DECNET: c_int = 12; +pub const NFPROTO_NUMPROTO: c_int = 13; + +// linux/netfilter_arp.h +pub const NF_ARP: c_int = 0; +pub const NF_ARP_IN: c_int = 0; +pub const NF_ARP_OUT: c_int = 1; +pub const NF_ARP_FORWARD: c_int = 2; +pub const NF_ARP_NUMHOOKS: c_int = 3; + +// linux/netfilter_bridge.h +pub const NF_BR_PRE_ROUTING: c_int = 0; +pub const NF_BR_LOCAL_IN: c_int = 1; +pub const NF_BR_FORWARD: c_int = 2; +pub const NF_BR_LOCAL_OUT: c_int = 3; +pub const NF_BR_POST_ROUTING: c_int = 4; +pub const NF_BR_BROUTING: c_int = 5; +pub const NF_BR_NUMHOOKS: c_int = 6; + +pub const NF_BR_PRI_FIRST: c_int = crate::INT_MIN; +pub const NF_BR_PRI_NAT_DST_BRIDGED: c_int = -300; +pub const NF_BR_PRI_FILTER_BRIDGED: c_int = -200; +pub const NF_BR_PRI_BRNF: c_int = 0; +pub const NF_BR_PRI_NAT_DST_OTHER: c_int = 100; +pub const NF_BR_PRI_FILTER_OTHER: c_int = 200; +pub const NF_BR_PRI_NAT_SRC: c_int = 300; +pub const NF_BR_PRI_LAST: c_int = crate::INT_MAX; + +// linux/netfilter_ipv4.h +pub const NF_IP_PRE_ROUTING: c_int = 0; +pub const NF_IP_LOCAL_IN: c_int = 1; +pub const NF_IP_FORWARD: c_int = 2; +pub const NF_IP_LOCAL_OUT: c_int = 3; +pub const NF_IP_POST_ROUTING: c_int = 4; +pub const NF_IP_NUMHOOKS: c_int = 5; + +pub const NF_IP_PRI_FIRST: c_int = crate::INT_MIN; +pub const NF_IP_PRI_RAW_BEFORE_DEFRAG: c_int = -450; +pub const NF_IP_PRI_CONNTRACK_DEFRAG: c_int = -400; +pub const NF_IP_PRI_RAW: c_int = -300; +pub const NF_IP_PRI_SELINUX_FIRST: c_int = -225; +pub const NF_IP_PRI_CONNTRACK: c_int = -200; +pub const NF_IP_PRI_MANGLE: c_int = -150; +pub const NF_IP_PRI_NAT_DST: c_int = -100; +pub const NF_IP_PRI_FILTER: c_int = 0; +pub const NF_IP_PRI_SECURITY: c_int = 50; +pub const NF_IP_PRI_NAT_SRC: c_int = 100; +pub const NF_IP_PRI_SELINUX_LAST: c_int = 225; +pub const NF_IP_PRI_CONNTRACK_HELPER: c_int = 300; +pub const NF_IP_PRI_CONNTRACK_CONFIRM: c_int = crate::INT_MAX; +pub const NF_IP_PRI_LAST: c_int = crate::INT_MAX; + +// linux/netfilter_ipv6.h +pub const NF_IP6_PRE_ROUTING: c_int = 0; +pub const NF_IP6_LOCAL_IN: c_int = 1; +pub const NF_IP6_FORWARD: c_int = 2; +pub const NF_IP6_LOCAL_OUT: c_int = 3; +pub const NF_IP6_POST_ROUTING: c_int = 4; +pub const NF_IP6_NUMHOOKS: c_int = 5; + +pub const NF_IP6_PRI_FIRST: c_int = crate::INT_MIN; +pub const NF_IP6_PRI_RAW_BEFORE_DEFRAG: c_int = -450; +pub const NF_IP6_PRI_CONNTRACK_DEFRAG: c_int = -400; +pub const NF_IP6_PRI_RAW: c_int = -300; +pub const NF_IP6_PRI_SELINUX_FIRST: c_int = -225; +pub const NF_IP6_PRI_CONNTRACK: c_int = -200; +pub const NF_IP6_PRI_MANGLE: c_int = -150; +pub const NF_IP6_PRI_NAT_DST: c_int = -100; +pub const NF_IP6_PRI_FILTER: c_int = 0; +pub const NF_IP6_PRI_SECURITY: c_int = 50; +pub const NF_IP6_PRI_NAT_SRC: c_int = 100; +pub const NF_IP6_PRI_SELINUX_LAST: c_int = 225; +pub const NF_IP6_PRI_CONNTRACK_HELPER: c_int = 300; +pub const NF_IP6_PRI_LAST: c_int = crate::INT_MAX; + +// linux/netfilter_ipv6/ip6_tables.h +pub const IP6T_SO_ORIGINAL_DST: c_int = 80; + +pub const SIOCSHWTSTAMP: c_ulong = 0x000089b0; +pub const SIOCGHWTSTAMP: c_ulong = 0x000089b1; + +// wireless.h +pub const WIRELESS_EXT: c_ulong = 0x16; + +pub const SIOCSIWCOMMIT: c_ulong = 0x8B00; +pub const SIOCGIWNAME: c_ulong = 0x8B01; + +pub const SIOCSIWNWID: c_ulong = 0x8B02; +pub const SIOCGIWNWID: c_ulong = 0x8B03; +pub const SIOCSIWFREQ: c_ulong = 0x8B04; +pub const SIOCGIWFREQ: c_ulong = 0x8B05; +pub const SIOCSIWMODE: c_ulong = 0x8B06; +pub const SIOCGIWMODE: c_ulong = 0x8B07; +pub const SIOCSIWSENS: c_ulong = 0x8B08; +pub const SIOCGIWSENS: c_ulong = 0x8B09; + +pub const SIOCSIWRANGE: c_ulong = 0x8B0A; +pub const SIOCGIWRANGE: c_ulong = 0x8B0B; +pub const SIOCSIWPRIV: c_ulong = 0x8B0C; +pub const SIOCGIWPRIV: c_ulong = 0x8B0D; +pub const SIOCSIWSTATS: c_ulong = 0x8B0E; +pub const SIOCGIWSTATS: c_ulong = 0x8B0F; + +pub const SIOCSIWSPY: c_ulong = 0x8B10; +pub const SIOCGIWSPY: c_ulong = 0x8B11; +pub const SIOCSIWTHRSPY: c_ulong = 0x8B12; +pub const SIOCGIWTHRSPY: c_ulong = 0x8B13; + +pub const SIOCSIWAP: c_ulong = 0x8B14; +pub const SIOCGIWAP: c_ulong = 0x8B15; +pub const SIOCGIWAPLIST: c_ulong = 0x8B17; +pub const SIOCSIWSCAN: c_ulong = 0x8B18; +pub const SIOCGIWSCAN: c_ulong = 0x8B19; + +pub const SIOCSIWESSID: c_ulong = 0x8B1A; +pub const SIOCGIWESSID: c_ulong = 0x8B1B; +pub const SIOCSIWNICKN: c_ulong = 0x8B1C; +pub const SIOCGIWNICKN: c_ulong = 0x8B1D; + +pub const SIOCSIWRATE: c_ulong = 0x8B20; +pub const SIOCGIWRATE: c_ulong = 0x8B21; +pub const SIOCSIWRTS: c_ulong = 0x8B22; +pub const SIOCGIWRTS: c_ulong = 0x8B23; +pub const SIOCSIWFRAG: c_ulong = 0x8B24; +pub const SIOCGIWFRAG: c_ulong = 0x8B25; +pub const SIOCSIWTXPOW: c_ulong = 0x8B26; +pub const SIOCGIWTXPOW: c_ulong = 0x8B27; +pub const SIOCSIWRETRY: c_ulong = 0x8B28; +pub const SIOCGIWRETRY: c_ulong = 0x8B29; + +pub const SIOCSIWENCODE: c_ulong = 0x8B2A; +pub const SIOCGIWENCODE: c_ulong = 0x8B2B; + +pub const SIOCSIWPOWER: c_ulong = 0x8B2C; +pub const SIOCGIWPOWER: c_ulong = 0x8B2D; + +pub const SIOCSIWGENIE: c_ulong = 0x8B30; +pub const SIOCGIWGENIE: c_ulong = 0x8B31; + +pub const SIOCSIWMLME: c_ulong = 0x8B16; + +pub const SIOCSIWAUTH: c_ulong = 0x8B32; +pub const SIOCGIWAUTH: c_ulong = 0x8B33; + +pub const SIOCSIWENCODEEXT: c_ulong = 0x8B34; +pub const SIOCGIWENCODEEXT: c_ulong = 0x8B35; + +pub const SIOCSIWPMKSA: c_ulong = 0x8B36; + +pub const SIOCIWFIRSTPRIV: c_ulong = 0x8BE0; +pub const SIOCIWLASTPRIV: c_ulong = 0x8BFF; + +pub const SIOCIWFIRST: c_ulong = 0x8B00; +pub const SIOCIWLAST: c_ulong = SIOCIWLASTPRIV; + +pub const IWEVTXDROP: c_ulong = 0x8C00; +pub const IWEVQUAL: c_ulong = 0x8C01; +pub const IWEVCUSTOM: c_ulong = 0x8C02; +pub const IWEVREGISTERED: c_ulong = 0x8C03; +pub const IWEVEXPIRED: c_ulong = 0x8C04; +pub const IWEVGENIE: c_ulong = 0x8C05; +pub const IWEVMICHAELMICFAILURE: c_ulong = 0x8C06; +pub const IWEVASSOCREQIE: c_ulong = 0x8C07; +pub const IWEVASSOCRESPIE: c_ulong = 0x8C08; +pub const IWEVPMKIDCAND: c_ulong = 0x8C09; +pub const IWEVFIRST: c_ulong = 0x8C00; + +pub const IW_PRIV_TYPE_MASK: c_ulong = 0x7000; +pub const IW_PRIV_TYPE_NONE: c_ulong = 0x0000; +pub const IW_PRIV_TYPE_BYTE: c_ulong = 0x1000; +pub const IW_PRIV_TYPE_CHAR: c_ulong = 0x2000; +pub const IW_PRIV_TYPE_INT: c_ulong = 0x4000; +pub const IW_PRIV_TYPE_FLOAT: c_ulong = 0x5000; +pub const IW_PRIV_TYPE_ADDR: c_ulong = 0x6000; + +pub const IW_PRIV_SIZE_FIXED: c_ulong = 0x0800; + +pub const IW_PRIV_SIZE_MASK: c_ulong = 0x07FF; + +pub const IW_MAX_FREQUENCIES: usize = 32; +pub const IW_MAX_BITRATES: usize = 32; +pub const IW_MAX_TXPOWER: usize = 8; +pub const IW_MAX_SPY: usize = 8; +pub const IW_MAX_AP: usize = 64; +pub const IW_ESSID_MAX_SIZE: usize = 32; + +pub const IW_MODE_AUTO: usize = 0; +pub const IW_MODE_ADHOC: usize = 1; +pub const IW_MODE_INFRA: usize = 2; +pub const IW_MODE_MASTER: usize = 3; +pub const IW_MODE_REPEAT: usize = 4; +pub const IW_MODE_SECOND: usize = 5; +pub const IW_MODE_MONITOR: usize = 6; +pub const IW_MODE_MESH: usize = 7; + +pub const IW_QUAL_QUAL_UPDATED: c_ulong = 0x01; +pub const IW_QUAL_LEVEL_UPDATED: c_ulong = 0x02; +pub const IW_QUAL_NOISE_UPDATED: c_ulong = 0x04; +pub const IW_QUAL_ALL_UPDATED: c_ulong = 0x07; +pub const IW_QUAL_DBM: c_ulong = 0x08; +pub const IW_QUAL_QUAL_INVALID: c_ulong = 0x10; +pub const IW_QUAL_LEVEL_INVALID: c_ulong = 0x20; +pub const IW_QUAL_NOISE_INVALID: c_ulong = 0x40; +pub const IW_QUAL_RCPI: c_ulong = 0x80; +pub const IW_QUAL_ALL_INVALID: c_ulong = 0x70; + +pub const IW_FREQ_AUTO: c_ulong = 0x00; +pub const IW_FREQ_FIXED: c_ulong = 0x01; + +pub const IW_MAX_ENCODING_SIZES: usize = 8; +pub const IW_ENCODING_TOKEN_MAX: usize = 64; + +pub const IW_ENCODE_INDEX: c_ulong = 0x00FF; +pub const IW_ENCODE_FLAGS: c_ulong = 0xFF00; +pub const IW_ENCODE_MODE: c_ulong = 0xF000; +pub const IW_ENCODE_DISABLED: c_ulong = 0x8000; +pub const IW_ENCODE_ENABLED: c_ulong = 0x0000; +pub const IW_ENCODE_RESTRICTED: c_ulong = 0x4000; +pub const IW_ENCODE_OPEN: c_ulong = 0x2000; +pub const IW_ENCODE_NOKEY: c_ulong = 0x0800; +pub const IW_ENCODE_TEMP: c_ulong = 0x0400; + +pub const IW_POWER_ON: c_ulong = 0x0000; +pub const IW_POWER_TYPE: c_ulong = 0xF000; +pub const IW_POWER_PERIOD: c_ulong = 0x1000; +pub const IW_POWER_TIMEOUT: c_ulong = 0x2000; +pub const IW_POWER_MODE: c_ulong = 0x0F00; +pub const IW_POWER_UNICAST_R: c_ulong = 0x0100; +pub const IW_POWER_MULTICAST_R: c_ulong = 0x0200; +pub const IW_POWER_ALL_R: c_ulong = 0x0300; +pub const IW_POWER_FORCE_S: c_ulong = 0x0400; +pub const IW_POWER_REPEATER: c_ulong = 0x0800; +pub const IW_POWER_MODIFIER: c_ulong = 0x000F; +pub const IW_POWER_MIN: c_ulong = 0x0001; +pub const IW_POWER_MAX: c_ulong = 0x0002; +pub const IW_POWER_RELATIVE: c_ulong = 0x0004; + +pub const IW_TXPOW_TYPE: c_ulong = 0x00FF; +pub const IW_TXPOW_DBM: c_ulong = 0x0000; +pub const IW_TXPOW_MWATT: c_ulong = 0x0001; +pub const IW_TXPOW_RELATIVE: c_ulong = 0x0002; +pub const IW_TXPOW_RANGE: c_ulong = 0x1000; + +pub const IW_RETRY_ON: c_ulong = 0x0000; +pub const IW_RETRY_TYPE: c_ulong = 0xF000; +pub const IW_RETRY_LIMIT: c_ulong = 0x1000; +pub const IW_RETRY_LIFETIME: c_ulong = 0x2000; +pub const IW_RETRY_MODIFIER: c_ulong = 0x00FF; +pub const IW_RETRY_MIN: c_ulong = 0x0001; +pub const IW_RETRY_MAX: c_ulong = 0x0002; +pub const IW_RETRY_RELATIVE: c_ulong = 0x0004; +pub const IW_RETRY_SHORT: c_ulong = 0x0010; +pub const IW_RETRY_LONG: c_ulong = 0x0020; + +pub const IW_SCAN_DEFAULT: c_ulong = 0x0000; +pub const IW_SCAN_ALL_ESSID: c_ulong = 0x0001; +pub const IW_SCAN_THIS_ESSID: c_ulong = 0x0002; +pub const IW_SCAN_ALL_FREQ: c_ulong = 0x0004; +pub const IW_SCAN_THIS_FREQ: c_ulong = 0x0008; +pub const IW_SCAN_ALL_MODE: c_ulong = 0x0010; +pub const IW_SCAN_THIS_MODE: c_ulong = 0x0020; +pub const IW_SCAN_ALL_RATE: c_ulong = 0x0040; +pub const IW_SCAN_THIS_RATE: c_ulong = 0x0080; + +pub const IW_SCAN_TYPE_ACTIVE: usize = 0; +pub const IW_SCAN_TYPE_PASSIVE: usize = 1; + +pub const IW_SCAN_MAX_DATA: usize = 4096; + +pub const IW_SCAN_CAPA_NONE: c_ulong = 0x00; +pub const IW_SCAN_CAPA_ESSID: c_ulong = 0x01; +pub const IW_SCAN_CAPA_BSSID: c_ulong = 0x02; +pub const IW_SCAN_CAPA_CHANNEL: c_ulong = 0x04; +pub const IW_SCAN_CAPA_MODE: c_ulong = 0x08; +pub const IW_SCAN_CAPA_RATE: c_ulong = 0x10; +pub const IW_SCAN_CAPA_TYPE: c_ulong = 0x20; +pub const IW_SCAN_CAPA_TIME: c_ulong = 0x40; + +pub const IW_CUSTOM_MAX: c_ulong = 256; + +pub const IW_GENERIC_IE_MAX: c_ulong = 1024; + +pub const IW_MLME_DEAUTH: c_ulong = 0; +pub const IW_MLME_DISASSOC: c_ulong = 1; +pub const IW_MLME_AUTH: c_ulong = 2; +pub const IW_MLME_ASSOC: c_ulong = 3; + +pub const IW_AUTH_INDEX: c_ulong = 0x0FFF; +pub const IW_AUTH_FLAGS: c_ulong = 0xF000; + +pub const IW_AUTH_WPA_VERSION: usize = 0; +pub const IW_AUTH_CIPHER_PAIRWISE: usize = 1; +pub const IW_AUTH_CIPHER_GROUP: usize = 2; +pub const IW_AUTH_KEY_MGMT: usize = 3; +pub const IW_AUTH_TKIP_COUNTERMEASURES: usize = 4; +pub const IW_AUTH_DROP_UNENCRYPTED: usize = 5; +pub const IW_AUTH_80211_AUTH_ALG: usize = 6; +pub const IW_AUTH_WPA_ENABLED: usize = 7; +pub const IW_AUTH_RX_UNENCRYPTED_EAPOL: usize = 8; +pub const IW_AUTH_ROAMING_CONTROL: usize = 9; +pub const IW_AUTH_PRIVACY_INVOKED: usize = 10; +pub const IW_AUTH_CIPHER_GROUP_MGMT: usize = 11; +pub const IW_AUTH_MFP: usize = 12; + +pub const IW_AUTH_WPA_VERSION_DISABLED: c_ulong = 0x00000001; +pub const IW_AUTH_WPA_VERSION_WPA: c_ulong = 0x00000002; +pub const IW_AUTH_WPA_VERSION_WPA2: c_ulong = 0x00000004; + +pub const IW_AUTH_CIPHER_NONE: c_ulong = 0x00000001; +pub const IW_AUTH_CIPHER_WEP40: c_ulong = 0x00000002; +pub const IW_AUTH_CIPHER_TKIP: c_ulong = 0x00000004; +pub const IW_AUTH_CIPHER_CCMP: c_ulong = 0x00000008; +pub const IW_AUTH_CIPHER_WEP104: c_ulong = 0x00000010; +pub const IW_AUTH_CIPHER_AES_CMAC: c_ulong = 0x00000020; + +pub const IW_AUTH_KEY_MGMT_802_1X: usize = 1; +pub const IW_AUTH_KEY_MGMT_PSK: usize = 2; + +pub const IW_AUTH_ALG_OPEN_SYSTEM: c_ulong = 0x00000001; +pub const IW_AUTH_ALG_SHARED_KEY: c_ulong = 0x00000002; +pub const IW_AUTH_ALG_LEAP: c_ulong = 0x00000004; + +pub const IW_AUTH_ROAMING_ENABLE: usize = 0; +pub const IW_AUTH_ROAMING_DISABLE: usize = 1; + +pub const IW_AUTH_MFP_DISABLED: usize = 0; +pub const IW_AUTH_MFP_OPTIONAL: usize = 1; +pub const IW_AUTH_MFP_REQUIRED: usize = 2; + +pub const IW_ENCODE_SEQ_MAX_SIZE: usize = 8; + +pub const IW_ENCODE_ALG_NONE: usize = 0; +pub const IW_ENCODE_ALG_WEP: usize = 1; +pub const IW_ENCODE_ALG_TKIP: usize = 2; +pub const IW_ENCODE_ALG_CCMP: usize = 3; +pub const IW_ENCODE_ALG_PMK: usize = 4; +pub const IW_ENCODE_ALG_AES_CMAC: usize = 5; + +pub const IW_ENCODE_EXT_TX_SEQ_VALID: c_ulong = 0x00000001; +pub const IW_ENCODE_EXT_RX_SEQ_VALID: c_ulong = 0x00000002; +pub const IW_ENCODE_EXT_GROUP_KEY: c_ulong = 0x00000004; +pub const IW_ENCODE_EXT_SET_TX_KEY: c_ulong = 0x00000008; + +pub const IW_MICFAILURE_KEY_ID: c_ulong = 0x00000003; +pub const IW_MICFAILURE_GROUP: c_ulong = 0x00000004; +pub const IW_MICFAILURE_PAIRWISE: c_ulong = 0x00000008; +pub const IW_MICFAILURE_STAKEY: c_ulong = 0x00000010; +pub const IW_MICFAILURE_COUNT: c_ulong = 0x00000060; + +pub const IW_ENC_CAPA_WPA: c_ulong = 0x00000001; +pub const IW_ENC_CAPA_WPA2: c_ulong = 0x00000002; +pub const IW_ENC_CAPA_CIPHER_TKIP: c_ulong = 0x00000004; +pub const IW_ENC_CAPA_CIPHER_CCMP: c_ulong = 0x00000008; +pub const IW_ENC_CAPA_4WAY_HANDSHAKE: c_ulong = 0x00000010; + +pub const IW_EVENT_CAPA_K_0: c_ulong = 0x4000050; // IW_EVENT_CAPA_MASK(0x8B04) | IW_EVENT_CAPA_MASK(0x8B06) | IW_EVENT_CAPA_MASK(0x8B1A); +pub const IW_EVENT_CAPA_K_1: c_ulong = 0x400; // W_EVENT_CAPA_MASK(0x8B2A); + +pub const IW_PMKSA_ADD: usize = 1; +pub const IW_PMKSA_REMOVE: usize = 2; +pub const IW_PMKSA_FLUSH: usize = 3; + +pub const IW_PMKID_LEN: usize = 16; + +pub const IW_PMKID_CAND_PREAUTH: c_ulong = 0x00000001; + +pub const IW_EV_LCP_PK_LEN: usize = 4; + +pub const IW_EV_CHAR_PK_LEN: usize = 20; // IW_EV_LCP_PK_LEN + crate::IFNAMSIZ; +pub const IW_EV_UINT_PK_LEN: usize = 8; // IW_EV_LCP_PK_LEN + size_of::(); +pub const IW_EV_FREQ_PK_LEN: usize = 12; // IW_EV_LCP_PK_LEN + size_of::(); +pub const IW_EV_PARAM_PK_LEN: usize = 12; // IW_EV_LCP_PK_LEN + size_of::(); +pub const IW_EV_ADDR_PK_LEN: usize = 20; // IW_EV_LCP_PK_LEN + size_of::(); +pub const IW_EV_QUAL_PK_LEN: usize = 8; // IW_EV_LCP_PK_LEN + size_of::(); +pub const IW_EV_POINT_PK_LEN: usize = 8; // IW_EV_LCP_PK_LEN + 4; + +// linux/neighbor.h +pub const NUD_NONE: u16 = 0x00; +pub const NUD_INCOMPLETE: u16 = 0x01; +pub const NUD_REACHABLE: u16 = 0x02; +pub const NUD_STALE: u16 = 0x04; +pub const NUD_DELAY: u16 = 0x08; +pub const NUD_PROBE: u16 = 0x10; +pub const NUD_FAILED: u16 = 0x20; +pub const NUD_NOARP: u16 = 0x40; +pub const NUD_PERMANENT: u16 = 0x80; + +pub const NTF_USE: u8 = 0x01; +pub const NTF_SELF: u8 = 0x02; +pub const NTF_MASTER: u8 = 0x04; +pub const NTF_PROXY: u8 = 0x08; +pub const NTF_ROUTER: u8 = 0x80; + +pub const NDA_UNSPEC: c_ushort = 0; +pub const NDA_DST: c_ushort = 1; +pub const NDA_LLADDR: c_ushort = 2; +pub const NDA_CACHEINFO: c_ushort = 3; +pub const NDA_PROBES: c_ushort = 4; +pub const NDA_VLAN: c_ushort = 5; +pub const NDA_PORT: c_ushort = 6; +pub const NDA_VNI: c_ushort = 7; +pub const NDA_IFINDEX: c_ushort = 8; + +// linux/netlink.h + +pub const NLM_F_BULK: c_int = 0x200; + +// linux/rtnetlink.h +pub const TCA_UNSPEC: c_ushort = 0; +pub const TCA_KIND: c_ushort = 1; +pub const TCA_OPTIONS: c_ushort = 2; +pub const TCA_STATS: c_ushort = 3; +pub const TCA_XSTATS: c_ushort = 4; +pub const TCA_RATE: c_ushort = 5; +pub const TCA_FCNT: c_ushort = 6; +pub const TCA_STATS2: c_ushort = 7; +pub const TCA_STAB: c_ushort = 8; + +pub const RTM_NEWLINK: u16 = 16; +pub const RTM_DELLINK: u16 = 17; +pub const RTM_GETLINK: u16 = 18; +pub const RTM_SETLINK: u16 = 19; +pub const RTM_NEWADDR: u16 = 20; +pub const RTM_DELADDR: u16 = 21; +pub const RTM_GETADDR: u16 = 22; +pub const RTM_NEWROUTE: u16 = 24; +pub const RTM_DELROUTE: u16 = 25; +pub const RTM_GETROUTE: u16 = 26; +pub const RTM_NEWNEIGH: u16 = 28; +pub const RTM_DELNEIGH: u16 = 29; +pub const RTM_GETNEIGH: u16 = 30; +pub const RTM_NEWRULE: u16 = 32; +pub const RTM_DELRULE: u16 = 33; +pub const RTM_GETRULE: u16 = 34; +pub const RTM_NEWQDISC: u16 = 36; +pub const RTM_DELQDISC: u16 = 37; +pub const RTM_GETQDISC: u16 = 38; +pub const RTM_NEWTCLASS: u16 = 40; +pub const RTM_DELTCLASS: u16 = 41; +pub const RTM_GETTCLASS: u16 = 42; +pub const RTM_NEWTFILTER: u16 = 44; +pub const RTM_DELTFILTER: u16 = 45; +pub const RTM_GETTFILTER: u16 = 46; +pub const RTM_NEWACTION: u16 = 48; +pub const RTM_DELACTION: u16 = 49; +pub const RTM_GETACTION: u16 = 50; +pub const RTM_NEWPREFIX: u16 = 52; +pub const RTM_GETMULTICAST: u16 = 58; +pub const RTM_GETANYCAST: u16 = 62; +pub const RTM_NEWNEIGHTBL: u16 = 64; +pub const RTM_GETNEIGHTBL: u16 = 66; +pub const RTM_SETNEIGHTBL: u16 = 67; +pub const RTM_NEWNDUSEROPT: u16 = 68; +pub const RTM_NEWADDRLABEL: u16 = 72; +pub const RTM_DELADDRLABEL: u16 = 73; +pub const RTM_GETADDRLABEL: u16 = 74; +pub const RTM_GETDCB: u16 = 78; +pub const RTM_SETDCB: u16 = 79; +pub const RTM_NEWNETCONF: u16 = 80; +pub const RTM_GETNETCONF: u16 = 82; +pub const RTM_NEWMDB: u16 = 84; +pub const RTM_DELMDB: u16 = 85; +pub const RTM_GETMDB: u16 = 86; +pub const RTM_NEWNSID: u16 = 88; +pub const RTM_DELNSID: u16 = 89; +pub const RTM_GETNSID: u16 = 90; + +pub const RTM_F_NOTIFY: c_uint = 0x100; +pub const RTM_F_CLONED: c_uint = 0x200; +pub const RTM_F_EQUALIZE: c_uint = 0x400; +pub const RTM_F_PREFIX: c_uint = 0x800; + +pub const RTA_UNSPEC: c_ushort = 0; +pub const RTA_DST: c_ushort = 1; +pub const RTA_SRC: c_ushort = 2; +pub const RTA_IIF: c_ushort = 3; +pub const RTA_OIF: c_ushort = 4; +pub const RTA_GATEWAY: c_ushort = 5; +pub const RTA_PRIORITY: c_ushort = 6; +pub const RTA_PREFSRC: c_ushort = 7; +pub const RTA_METRICS: c_ushort = 8; +pub const RTA_MULTIPATH: c_ushort = 9; +pub const RTA_PROTOINFO: c_ushort = 10; // No longer used +pub const RTA_FLOW: c_ushort = 11; +pub const RTA_CACHEINFO: c_ushort = 12; +pub const RTA_SESSION: c_ushort = 13; // No longer used +pub const RTA_MP_ALGO: c_ushort = 14; // No longer used +pub const RTA_TABLE: c_ushort = 15; +pub const RTA_MARK: c_ushort = 16; +pub const RTA_MFC_STATS: c_ushort = 17; + +pub const RTN_UNSPEC: c_uchar = 0; +pub const RTN_UNICAST: c_uchar = 1; +pub const RTN_LOCAL: c_uchar = 2; +pub const RTN_BROADCAST: c_uchar = 3; +pub const RTN_ANYCAST: c_uchar = 4; +pub const RTN_MULTICAST: c_uchar = 5; +pub const RTN_BLACKHOLE: c_uchar = 6; +pub const RTN_UNREACHABLE: c_uchar = 7; +pub const RTN_PROHIBIT: c_uchar = 8; +pub const RTN_THROW: c_uchar = 9; +pub const RTN_NAT: c_uchar = 10; +pub const RTN_XRESOLVE: c_uchar = 11; + +pub const RTPROT_UNSPEC: c_uchar = 0; +pub const RTPROT_REDIRECT: c_uchar = 1; +pub const RTPROT_KERNEL: c_uchar = 2; +pub const RTPROT_BOOT: c_uchar = 3; +pub const RTPROT_STATIC: c_uchar = 4; + +pub const RT_SCOPE_UNIVERSE: c_uchar = 0; +pub const RT_SCOPE_SITE: c_uchar = 200; +pub const RT_SCOPE_LINK: c_uchar = 253; +pub const RT_SCOPE_HOST: c_uchar = 254; +pub const RT_SCOPE_NOWHERE: c_uchar = 255; + +pub const RT_TABLE_UNSPEC: c_uchar = 0; +pub const RT_TABLE_COMPAT: c_uchar = 252; +pub const RT_TABLE_DEFAULT: c_uchar = 253; +pub const RT_TABLE_MAIN: c_uchar = 254; +pub const RT_TABLE_LOCAL: c_uchar = 255; + +pub const RTMSG_OVERRUN: u32 = crate::NLMSG_OVERRUN as u32; +pub const RTMSG_NEWDEVICE: u32 = 0x11; +pub const RTMSG_DELDEVICE: u32 = 0x12; +pub const RTMSG_NEWROUTE: u32 = 0x21; +pub const RTMSG_DELROUTE: u32 = 0x22; +pub const RTMSG_NEWRULE: u32 = 0x31; +pub const RTMSG_DELRULE: u32 = 0x32; +pub const RTMSG_CONTROL: u32 = 0x40; +pub const RTMSG_AR_FAILED: u32 = 0x51; + +pub const RTEXT_FILTER_VF: c_int = 1 << 0; +pub const RTEXT_FILTER_BRVLAN: c_int = 1 << 1; +pub const RTEXT_FILTER_BRVLAN_COMPRESSED: c_int = 1 << 2; +pub const RTEXT_FILTER_SKIP_STATS: c_int = 1 << 3; +pub const RTEXT_FILTER_MRP: c_int = 1 << 4; +pub const RTEXT_FILTER_CFM_CONFIG: c_int = 1 << 5; +pub const RTEXT_FILTER_CFM_STATUS: c_int = 1 << 6; + +// userspace compat definitions for RTNLGRP_* +pub const RTMGRP_LINK: c_int = 0x00001; +pub const RTMGRP_NOTIFY: c_int = 0x00002; +pub const RTMGRP_NEIGH: c_int = 0x00004; +pub const RTMGRP_TC: c_int = 0x00008; +pub const RTMGRP_IPV4_IFADDR: c_int = 0x00010; +pub const RTMGRP_IPV4_MROUTE: c_int = 0x00020; +pub const RTMGRP_IPV4_ROUTE: c_int = 0x00040; +pub const RTMGRP_IPV4_RULE: c_int = 0x00080; +pub const RTMGRP_IPV6_IFADDR: c_int = 0x00100; +pub const RTMGRP_IPV6_MROUTE: c_int = 0x00200; +pub const RTMGRP_IPV6_ROUTE: c_int = 0x00400; +pub const RTMGRP_IPV6_IFINFO: c_int = 0x00800; +pub const RTMGRP_DECnet_IFADDR: c_int = 0x01000; +pub const RTMGRP_DECnet_ROUTE: c_int = 0x04000; +pub const RTMGRP_IPV6_PREFIX: c_int = 0x20000; + +// enum rtnetlink_groups +pub const RTNLGRP_NONE: c_uint = 0x00; +pub const RTNLGRP_LINK: c_uint = 0x01; +pub const RTNLGRP_NOTIFY: c_uint = 0x02; +pub const RTNLGRP_NEIGH: c_uint = 0x03; +pub const RTNLGRP_TC: c_uint = 0x04; +pub const RTNLGRP_IPV4_IFADDR: c_uint = 0x05; +pub const RTNLGRP_IPV4_MROUTE: c_uint = 0x06; +pub const RTNLGRP_IPV4_ROUTE: c_uint = 0x07; +pub const RTNLGRP_IPV4_RULE: c_uint = 0x08; +pub const RTNLGRP_IPV6_IFADDR: c_uint = 0x09; +pub const RTNLGRP_IPV6_MROUTE: c_uint = 0x0a; +pub const RTNLGRP_IPV6_ROUTE: c_uint = 0x0b; +pub const RTNLGRP_IPV6_IFINFO: c_uint = 0x0c; +pub const RTNLGRP_DECnet_IFADDR: c_uint = 0x0d; +pub const RTNLGRP_NOP2: c_uint = 0x0e; +pub const RTNLGRP_DECnet_ROUTE: c_uint = 0x0f; +pub const RTNLGRP_DECnet_RULE: c_uint = 0x10; +pub const RTNLGRP_NOP4: c_uint = 0x11; +pub const RTNLGRP_IPV6_PREFIX: c_uint = 0x12; +pub const RTNLGRP_IPV6_RULE: c_uint = 0x13; +pub const RTNLGRP_ND_USEROPT: c_uint = 0x14; +pub const RTNLGRP_PHONET_IFADDR: c_uint = 0x15; +pub const RTNLGRP_PHONET_ROUTE: c_uint = 0x16; +pub const RTNLGRP_DCB: c_uint = 0x17; +pub const RTNLGRP_IPV4_NETCONF: c_uint = 0x18; +pub const RTNLGRP_IPV6_NETCONF: c_uint = 0x19; +pub const RTNLGRP_MDB: c_uint = 0x1a; +pub const RTNLGRP_MPLS_ROUTE: c_uint = 0x1b; +pub const RTNLGRP_NSID: c_uint = 0x1c; +pub const RTNLGRP_MPLS_NETCONF: c_uint = 0x1d; +pub const RTNLGRP_IPV4_MROUTE_R: c_uint = 0x1e; +pub const RTNLGRP_IPV6_MROUTE_R: c_uint = 0x1f; +pub const RTNLGRP_NEXTHOP: c_uint = 0x20; +pub const RTNLGRP_BRVLAN: c_uint = 0x21; +pub const RTNLGRP_MCTP_IFADDR: c_uint = 0x22; +pub const RTNLGRP_TUNNEL: c_uint = 0x23; +pub const RTNLGRP_STATS: c_uint = 0x24; + +// linux/cn_proc.h +c_enum! { + pub enum proc_cn_mcast_op { + pub PROC_CN_MCAST_LISTEN = 1, + pub PROC_CN_MCAST_IGNORE = 2, + } + + pub enum proc_cn_event { + pub PROC_EVENT_NONE = 0x00000000, + pub PROC_EVENT_FORK = 0x00000001, + pub PROC_EVENT_EXEC = 0x00000002, + pub PROC_EVENT_UID = 0x00000004, + pub PROC_EVENT_GID = 0x00000040, + pub PROC_EVENT_SID = 0x00000080, + pub PROC_EVENT_PTRACE = 0x00000100, + pub PROC_EVENT_COMM = 0x00000200, + pub PROC_EVENT_NONZERO_EXIT = 0x20000000, + pub PROC_EVENT_COREDUMP = 0x40000000, + pub PROC_EVENT_EXIT = 0x80000000, + } +} + +// linux/connector.h +pub const CN_IDX_PROC: c_uint = 0x1; +pub const CN_VAL_PROC: c_uint = 0x1; +pub const CN_IDX_CIFS: c_uint = 0x2; +pub const CN_VAL_CIFS: c_uint = 0x1; +pub const CN_W1_IDX: c_uint = 0x3; +pub const CN_W1_VAL: c_uint = 0x1; +pub const CN_IDX_V86D: c_uint = 0x4; +pub const CN_VAL_V86D_UVESAFB: c_uint = 0x1; +pub const CN_IDX_BB: c_uint = 0x5; +pub const CN_DST_IDX: c_uint = 0x6; +pub const CN_DST_VAL: c_uint = 0x1; +pub const CN_IDX_DM: c_uint = 0x7; +pub const CN_VAL_DM_USERSPACE_LOG: c_uint = 0x1; +pub const CN_IDX_DRBD: c_uint = 0x8; +pub const CN_VAL_DRBD: c_uint = 0x1; +pub const CN_KVP_IDX: c_uint = 0x9; +pub const CN_KVP_VAL: c_uint = 0x1; +pub const CN_VSS_IDX: c_uint = 0xA; +pub const CN_VSS_VAL: c_uint = 0x1; + +// linux/module.h +pub const MODULE_INIT_IGNORE_MODVERSIONS: c_uint = 0x0001; +pub const MODULE_INIT_IGNORE_VERMAGIC: c_uint = 0x0002; + +// linux/net_tstamp.h +pub const SOF_TIMESTAMPING_TX_HARDWARE: c_uint = 1 << 0; +pub const SOF_TIMESTAMPING_TX_SOFTWARE: c_uint = 1 << 1; +pub const SOF_TIMESTAMPING_RX_HARDWARE: c_uint = 1 << 2; +pub const SOF_TIMESTAMPING_RX_SOFTWARE: c_uint = 1 << 3; +pub const SOF_TIMESTAMPING_SOFTWARE: c_uint = 1 << 4; +pub const SOF_TIMESTAMPING_SYS_HARDWARE: c_uint = 1 << 5; +pub const SOF_TIMESTAMPING_RAW_HARDWARE: c_uint = 1 << 6; +pub const SOF_TIMESTAMPING_OPT_ID: c_uint = 1 << 7; +pub const SOF_TIMESTAMPING_TX_SCHED: c_uint = 1 << 8; +pub const SOF_TIMESTAMPING_TX_ACK: c_uint = 1 << 9; +pub const SOF_TIMESTAMPING_OPT_CMSG: c_uint = 1 << 10; +pub const SOF_TIMESTAMPING_OPT_TSONLY: c_uint = 1 << 11; +pub const SOF_TIMESTAMPING_OPT_STATS: c_uint = 1 << 12; +pub const SOF_TIMESTAMPING_OPT_PKTINFO: c_uint = 1 << 13; +pub const SOF_TIMESTAMPING_OPT_TX_SWHW: c_uint = 1 << 14; +pub const SOF_TIMESTAMPING_BIND_PHC: c_uint = 1 << 15; +pub const SOF_TIMESTAMPING_OPT_ID_TCP: c_uint = 1 << 16; +pub const SOF_TIMESTAMPING_OPT_RX_FILTER: c_uint = 1 << 17; +pub const SOF_TXTIME_DEADLINE_MODE: u32 = 1 << 0; +pub const SOF_TXTIME_REPORT_ERRORS: u32 = 1 << 1; + +pub const HWTSTAMP_TX_OFF: c_uint = 0; +pub const HWTSTAMP_TX_ON: c_uint = 1; +pub const HWTSTAMP_TX_ONESTEP_SYNC: c_uint = 2; +pub const HWTSTAMP_TX_ONESTEP_P2P: c_uint = 3; + +pub const HWTSTAMP_FILTER_NONE: c_uint = 0; +pub const HWTSTAMP_FILTER_ALL: c_uint = 1; +pub const HWTSTAMP_FILTER_SOME: c_uint = 2; +pub const HWTSTAMP_FILTER_PTP_V1_L4_EVENT: c_uint = 3; +pub const HWTSTAMP_FILTER_PTP_V1_L4_SYNC: c_uint = 4; +pub const HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ: c_uint = 5; +pub const HWTSTAMP_FILTER_PTP_V2_L4_EVENT: c_uint = 6; +pub const HWTSTAMP_FILTER_PTP_V2_L4_SYNC: c_uint = 7; +pub const HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ: c_uint = 8; +pub const HWTSTAMP_FILTER_PTP_V2_L2_EVENT: c_uint = 9; +pub const HWTSTAMP_FILTER_PTP_V2_L2_SYNC: c_uint = 10; +pub const HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ: c_uint = 11; +pub const HWTSTAMP_FILTER_PTP_V2_EVENT: c_uint = 12; +pub const HWTSTAMP_FILTER_PTP_V2_SYNC: c_uint = 13; +pub const HWTSTAMP_FILTER_PTP_V2_DELAY_REQ: c_uint = 14; +pub const HWTSTAMP_FILTER_NTP_ALL: c_uint = 15; + +// linux/ptp_clock.h +pub const PTP_MAX_SAMPLES: c_uint = 25; // Maximum allowed offset measurement samples. + +const PTP_CLK_MAGIC: u32 = b'=' as u32; + +pub const PTP_CLOCK_GETCAPS: Ioctl = _IOR::(PTP_CLK_MAGIC, 1); +pub const PTP_EXTTS_REQUEST: Ioctl = _IOW::(PTP_CLK_MAGIC, 2); +pub const PTP_PEROUT_REQUEST: Ioctl = _IOW::(PTP_CLK_MAGIC, 3); +pub const PTP_ENABLE_PPS: Ioctl = _IOW::(PTP_CLK_MAGIC, 4); +pub const PTP_SYS_OFFSET: Ioctl = _IOW::(PTP_CLK_MAGIC, 5); +pub const PTP_PIN_GETFUNC: Ioctl = _IOWR::(PTP_CLK_MAGIC, 6); +pub const PTP_PIN_SETFUNC: Ioctl = _IOW::(PTP_CLK_MAGIC, 7); +pub const PTP_SYS_OFFSET_PRECISE: Ioctl = _IOWR::(PTP_CLK_MAGIC, 8); +pub const PTP_SYS_OFFSET_EXTENDED: Ioctl = _IOWR::(PTP_CLK_MAGIC, 9); + +pub const PTP_CLOCK_GETCAPS2: Ioctl = _IOR::(PTP_CLK_MAGIC, 10); +pub const PTP_EXTTS_REQUEST2: Ioctl = _IOW::(PTP_CLK_MAGIC, 11); +pub const PTP_PEROUT_REQUEST2: Ioctl = _IOW::(PTP_CLK_MAGIC, 12); +pub const PTP_ENABLE_PPS2: Ioctl = _IOW::(PTP_CLK_MAGIC, 13); +pub const PTP_SYS_OFFSET2: Ioctl = _IOW::(PTP_CLK_MAGIC, 14); +pub const PTP_PIN_GETFUNC2: Ioctl = _IOWR::(PTP_CLK_MAGIC, 15); +pub const PTP_PIN_SETFUNC2: Ioctl = _IOW::(PTP_CLK_MAGIC, 16); +pub const PTP_SYS_OFFSET_PRECISE2: Ioctl = _IOWR::(PTP_CLK_MAGIC, 17); +pub const PTP_SYS_OFFSET_EXTENDED2: Ioctl = _IOWR::(PTP_CLK_MAGIC, 18); + +// enum ptp_pin_function +pub const PTP_PF_NONE: c_uint = 0; +pub const PTP_PF_EXTTS: c_uint = 1; +pub const PTP_PF_PEROUT: c_uint = 2; +pub const PTP_PF_PHYSYNC: c_uint = 3; + +// linux/tls.h +pub const TLS_TX: c_int = 1; +pub const TLS_RX: c_int = 2; + +pub const TLS_TX_ZEROCOPY_RO: c_int = 3; +pub const TLS_RX_EXPECT_NO_PAD: c_int = 4; + +pub const TLS_1_2_VERSION_MAJOR: __u8 = 0x3; +pub const TLS_1_2_VERSION_MINOR: __u8 = 0x3; +pub const TLS_1_2_VERSION: __u16 = + ((TLS_1_2_VERSION_MAJOR as __u16) << 8) | (TLS_1_2_VERSION_MINOR as __u16); + +pub const TLS_1_3_VERSION_MAJOR: __u8 = 0x3; +pub const TLS_1_3_VERSION_MINOR: __u8 = 0x4; +pub const TLS_1_3_VERSION: __u16 = + ((TLS_1_3_VERSION_MAJOR as __u16) << 8) | (TLS_1_3_VERSION_MINOR as __u16); + +pub const TLS_CIPHER_AES_GCM_128: __u16 = 51; +pub const TLS_CIPHER_AES_GCM_128_IV_SIZE: usize = 8; +pub const TLS_CIPHER_AES_GCM_128_KEY_SIZE: usize = 16; +pub const TLS_CIPHER_AES_GCM_128_SALT_SIZE: usize = 4; +pub const TLS_CIPHER_AES_GCM_128_TAG_SIZE: usize = 16; +pub const TLS_CIPHER_AES_GCM_128_REC_SEQ_SIZE: usize = 8; + +pub const TLS_CIPHER_AES_GCM_256: __u16 = 52; +pub const TLS_CIPHER_AES_GCM_256_IV_SIZE: usize = 8; +pub const TLS_CIPHER_AES_GCM_256_KEY_SIZE: usize = 32; +pub const TLS_CIPHER_AES_GCM_256_SALT_SIZE: usize = 4; +pub const TLS_CIPHER_AES_GCM_256_TAG_SIZE: usize = 16; +pub const TLS_CIPHER_AES_GCM_256_REC_SEQ_SIZE: usize = 8; + +pub const TLS_CIPHER_AES_CCM_128: __u16 = 53; +pub const TLS_CIPHER_AES_CCM_128_IV_SIZE: usize = 8; +pub const TLS_CIPHER_AES_CCM_128_KEY_SIZE: usize = 16; +pub const TLS_CIPHER_AES_CCM_128_SALT_SIZE: usize = 4; +pub const TLS_CIPHER_AES_CCM_128_TAG_SIZE: usize = 16; +pub const TLS_CIPHER_AES_CCM_128_REC_SEQ_SIZE: usize = 8; + +pub const TLS_CIPHER_CHACHA20_POLY1305: __u16 = 54; +pub const TLS_CIPHER_CHACHA20_POLY1305_IV_SIZE: usize = 12; +pub const TLS_CIPHER_CHACHA20_POLY1305_KEY_SIZE: usize = 32; +pub const TLS_CIPHER_CHACHA20_POLY1305_SALT_SIZE: usize = 0; +pub const TLS_CIPHER_CHACHA20_POLY1305_TAG_SIZE: usize = 16; +pub const TLS_CIPHER_CHACHA20_POLY1305_REC_SEQ_SIZE: usize = 8; + +pub const TLS_CIPHER_SM4_GCM: __u16 = 55; +pub const TLS_CIPHER_SM4_GCM_IV_SIZE: usize = 8; +pub const TLS_CIPHER_SM4_GCM_KEY_SIZE: usize = 16; +pub const TLS_CIPHER_SM4_GCM_SALT_SIZE: usize = 4; +pub const TLS_CIPHER_SM4_GCM_TAG_SIZE: usize = 16; +pub const TLS_CIPHER_SM4_GCM_REC_SEQ_SIZE: usize = 8; + +pub const TLS_CIPHER_SM4_CCM: __u16 = 56; +pub const TLS_CIPHER_SM4_CCM_IV_SIZE: usize = 8; +pub const TLS_CIPHER_SM4_CCM_KEY_SIZE: usize = 16; +pub const TLS_CIPHER_SM4_CCM_SALT_SIZE: usize = 4; +pub const TLS_CIPHER_SM4_CCM_TAG_SIZE: usize = 16; +pub const TLS_CIPHER_SM4_CCM_REC_SEQ_SIZE: usize = 8; + +pub const TLS_CIPHER_ARIA_GCM_128: __u16 = 57; +pub const TLS_CIPHER_ARIA_GCM_128_IV_SIZE: usize = 8; +pub const TLS_CIPHER_ARIA_GCM_128_KEY_SIZE: usize = 16; +pub const TLS_CIPHER_ARIA_GCM_128_SALT_SIZE: usize = 4; +pub const TLS_CIPHER_ARIA_GCM_128_TAG_SIZE: usize = 16; +pub const TLS_CIPHER_ARIA_GCM_128_REC_SEQ_SIZE: usize = 8; + +pub const TLS_CIPHER_ARIA_GCM_256: __u16 = 58; +pub const TLS_CIPHER_ARIA_GCM_256_IV_SIZE: usize = 8; +pub const TLS_CIPHER_ARIA_GCM_256_KEY_SIZE: usize = 32; +pub const TLS_CIPHER_ARIA_GCM_256_SALT_SIZE: usize = 4; +pub const TLS_CIPHER_ARIA_GCM_256_TAG_SIZE: usize = 16; +pub const TLS_CIPHER_ARIA_GCM_256_REC_SEQ_SIZE: usize = 8; + +pub const TLS_SET_RECORD_TYPE: c_int = 1; +pub const TLS_GET_RECORD_TYPE: c_int = 2; + +pub const SOL_TLS: c_int = 282; + +// enum +pub const TLS_INFO_UNSPEC: c_int = 0x00; +pub const TLS_INFO_VERSION: c_int = 0x01; +pub const TLS_INFO_CIPHER: c_int = 0x02; +pub const TLS_INFO_TXCONF: c_int = 0x03; +pub const TLS_INFO_RXCONF: c_int = 0x04; +pub const TLS_INFO_ZC_RO_TX: c_int = 0x05; +pub const TLS_INFO_RX_NO_PAD: c_int = 0x06; + +pub const TLS_CONF_BASE: c_int = 1; +pub const TLS_CONF_SW: c_int = 2; +pub const TLS_CONF_HW: c_int = 3; +pub const TLS_CONF_HW_RECORD: c_int = 4; + +// linux/if_alg.h +pub const ALG_SET_KEY: c_int = 1; +pub const ALG_SET_IV: c_int = 2; +pub const ALG_SET_OP: c_int = 3; +pub const ALG_SET_AEAD_ASSOCLEN: c_int = 4; +pub const ALG_SET_AEAD_AUTHSIZE: c_int = 5; +pub const ALG_SET_DRBG_ENTROPY: c_int = 6; +pub const ALG_SET_KEY_BY_KEY_SERIAL: c_int = 7; + +pub const ALG_OP_DECRYPT: c_int = 0; +pub const ALG_OP_ENCRYPT: c_int = 1; + +// include/uapi/linux/if.h +pub const IF_OPER_UNKNOWN: c_int = 0; +pub const IF_OPER_NOTPRESENT: c_int = 1; +pub const IF_OPER_DOWN: c_int = 2; +pub const IF_OPER_LOWERLAYERDOWN: c_int = 3; +pub const IF_OPER_TESTING: c_int = 4; +pub const IF_OPER_DORMANT: c_int = 5; +pub const IF_OPER_UP: c_int = 6; + +pub const IF_LINK_MODE_DEFAULT: c_int = 0; +pub const IF_LINK_MODE_DORMANT: c_int = 1; +pub const IF_LINK_MODE_TESTING: c_int = 2; + +// include/uapi/linux/mman.h +pub const MAP_SHARED_VALIDATE: c_int = 0x3; +pub const MAP_DROPPABLE: c_int = 0x8; + +// uapi/linux/vm_sockets.h +pub const VMADDR_CID_ANY: c_uint = 0xFFFFFFFF; +pub const VMADDR_CID_HYPERVISOR: c_uint = 0; +#[deprecated( + since = "0.2.74", + note = "VMADDR_CID_RESERVED is removed since Linux v5.6 and \ + replaced with VMADDR_CID_LOCAL" +)] +pub const VMADDR_CID_RESERVED: c_uint = 1; +pub const VMADDR_CID_LOCAL: c_uint = 1; +pub const VMADDR_CID_HOST: c_uint = 2; +pub const VMADDR_PORT_ANY: c_uint = 0xFFFFFFFF; + +// uapi/linux/inotify.h +pub const IN_ACCESS: u32 = 0x0000_0001; +pub const IN_MODIFY: u32 = 0x0000_0002; +pub const IN_ATTRIB: u32 = 0x0000_0004; +pub const IN_CLOSE_WRITE: u32 = 0x0000_0008; +pub const IN_CLOSE_NOWRITE: u32 = 0x0000_0010; +pub const IN_CLOSE: u32 = IN_CLOSE_WRITE | IN_CLOSE_NOWRITE; +pub const IN_OPEN: u32 = 0x0000_0020; +pub const IN_MOVED_FROM: u32 = 0x0000_0040; +pub const IN_MOVED_TO: u32 = 0x0000_0080; +pub const IN_MOVE: u32 = IN_MOVED_FROM | IN_MOVED_TO; +pub const IN_CREATE: u32 = 0x0000_0100; +pub const IN_DELETE: u32 = 0x0000_0200; +pub const IN_DELETE_SELF: u32 = 0x0000_0400; +pub const IN_MOVE_SELF: u32 = 0x0000_0800; +pub const IN_UNMOUNT: u32 = 0x0000_2000; +pub const IN_Q_OVERFLOW: u32 = 0x0000_4000; +pub const IN_IGNORED: u32 = 0x0000_8000; +pub const IN_ONLYDIR: u32 = 0x0100_0000; +pub const IN_DONT_FOLLOW: u32 = 0x0200_0000; +pub const IN_EXCL_UNLINK: u32 = 0x0400_0000; + +// uapi/linux/securebits.h +const SECURE_NOROOT: c_int = 0; +const SECURE_NOROOT_LOCKED: c_int = 1; + +pub const SECBIT_NOROOT: c_int = issecure_mask(SECURE_NOROOT); +pub const SECBIT_NOROOT_LOCKED: c_int = issecure_mask(SECURE_NOROOT_LOCKED); + +const SECURE_NO_SETUID_FIXUP: c_int = 2; +const SECURE_NO_SETUID_FIXUP_LOCKED: c_int = 3; + +pub const SECBIT_NO_SETUID_FIXUP: c_int = issecure_mask(SECURE_NO_SETUID_FIXUP); +pub const SECBIT_NO_SETUID_FIXUP_LOCKED: c_int = issecure_mask(SECURE_NO_SETUID_FIXUP_LOCKED); + +const SECURE_KEEP_CAPS: c_int = 4; +const SECURE_KEEP_CAPS_LOCKED: c_int = 5; + +pub const SECBIT_KEEP_CAPS: c_int = issecure_mask(SECURE_KEEP_CAPS); +pub const SECBIT_KEEP_CAPS_LOCKED: c_int = issecure_mask(SECURE_KEEP_CAPS_LOCKED); + +const SECURE_NO_CAP_AMBIENT_RAISE: c_int = 6; +const SECURE_NO_CAP_AMBIENT_RAISE_LOCKED: c_int = 7; + +pub const SECBIT_NO_CAP_AMBIENT_RAISE: c_int = issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE); +pub const SECBIT_NO_CAP_AMBIENT_RAISE_LOCKED: c_int = + issecure_mask(SECURE_NO_CAP_AMBIENT_RAISE_LOCKED); + +const SECURE_EXEC_RESTRICT_FILE: c_int = 8; +const SECURE_EXEC_RESTRICT_FILE_LOCKED: c_int = 9; + +pub const SECBIT_EXEC_RESTRICT_FILE: c_int = issecure_mask(SECURE_EXEC_RESTRICT_FILE); +pub const SECBIT_EXEC_RESTRICT_FILE_LOCKED: c_int = issecure_mask(SECURE_EXEC_RESTRICT_FILE_LOCKED); + +const SECURE_EXEC_DENY_INTERACTIVE: c_int = 10; +const SECURE_EXEC_DENY_INTERACTIVE_LOCKED: c_int = 11; + +pub const SECBIT_EXEC_DENY_INTERACTIVE: c_int = issecure_mask(SECURE_EXEC_DENY_INTERACTIVE); +pub const SECBIT_EXEC_DENY_INTERACTIVE_LOCKED: c_int = + issecure_mask(SECURE_EXEC_DENY_INTERACTIVE_LOCKED); + +pub const SECUREBITS_DEFAULT: c_int = 0x00000000; +pub const SECURE_ALL_BITS: c_int = SECBIT_NOROOT + | SECBIT_NO_SETUID_FIXUP + | SECBIT_KEEP_CAPS + | SECBIT_NO_CAP_AMBIENT_RAISE + | SECBIT_EXEC_RESTRICT_FILE + | SECBIT_EXEC_DENY_INTERACTIVE; +pub const SECURE_ALL_LOCKS: c_int = SECURE_ALL_BITS << 1; + +pub const SECURE_ALL_UNPRIVILEGED: c_int = + issecure_mask(SECURE_EXEC_RESTRICT_FILE) | issecure_mask(SECURE_EXEC_DENY_INTERACTIVE); + +const fn issecure_mask(x: c_int) -> c_int { + 1 << x +} + +pub const IN_MASK_CREATE: u32 = 0x1000_0000; +pub const IN_MASK_ADD: u32 = 0x2000_0000; +pub const IN_ISDIR: u32 = 0x4000_0000; +pub const IN_ONESHOT: u32 = 0x8000_0000; + +pub const IN_ALL_EVENTS: u32 = IN_ACCESS + | IN_MODIFY + | IN_ATTRIB + | IN_CLOSE_WRITE + | IN_CLOSE_NOWRITE + | IN_OPEN + | IN_MOVED_FROM + | IN_MOVED_TO + | IN_DELETE + | IN_CREATE + | IN_DELETE_SELF + | IN_MOVE_SELF; + +pub const IN_CLOEXEC: c_int = O_CLOEXEC; +pub const IN_NONBLOCK: c_int = O_NONBLOCK; + +// uapi/linux/mount.h +pub const OPEN_TREE_CLONE: c_uint = 0x01; +pub const OPEN_TREE_CLOEXEC: c_uint = O_CLOEXEC as c_uint; + +// uapi/linux/netfilter/nf_tables.h +pub const NFT_TABLE_MAXNAMELEN: c_int = 256; +pub const NFT_CHAIN_MAXNAMELEN: c_int = 256; +pub const NFT_SET_MAXNAMELEN: c_int = 256; +pub const NFT_OBJ_MAXNAMELEN: c_int = 256; +pub const NFT_USERDATA_MAXLEN: c_int = 256; + +pub const NFT_REG_VERDICT: c_int = 0; +pub const NFT_REG_1: c_int = 1; +pub const NFT_REG_2: c_int = 2; +pub const NFT_REG_3: c_int = 3; +pub const NFT_REG_4: c_int = 4; +pub const __NFT_REG_MAX: c_int = 5; +pub const NFT_REG32_00: c_int = 8; +pub const NFT_REG32_01: c_int = 9; +pub const NFT_REG32_02: c_int = 10; +pub const NFT_REG32_03: c_int = 11; +pub const NFT_REG32_04: c_int = 12; +pub const NFT_REG32_05: c_int = 13; +pub const NFT_REG32_06: c_int = 14; +pub const NFT_REG32_07: c_int = 15; +pub const NFT_REG32_08: c_int = 16; +pub const NFT_REG32_09: c_int = 17; +pub const NFT_REG32_10: c_int = 18; +pub const NFT_REG32_11: c_int = 19; +pub const NFT_REG32_12: c_int = 20; +pub const NFT_REG32_13: c_int = 21; +pub const NFT_REG32_14: c_int = 22; +pub const NFT_REG32_15: c_int = 23; + +pub const NFT_REG_SIZE: c_int = 16; +pub const NFT_REG32_SIZE: c_int = 4; + +pub const NFT_CONTINUE: c_int = -1; +pub const NFT_BREAK: c_int = -2; +pub const NFT_JUMP: c_int = -3; +pub const NFT_GOTO: c_int = -4; +pub const NFT_RETURN: c_int = -5; + +pub const NFT_MSG_NEWTABLE: c_int = 0; +pub const NFT_MSG_GETTABLE: c_int = 1; +pub const NFT_MSG_DELTABLE: c_int = 2; +pub const NFT_MSG_NEWCHAIN: c_int = 3; +pub const NFT_MSG_GETCHAIN: c_int = 4; +pub const NFT_MSG_DELCHAIN: c_int = 5; +pub const NFT_MSG_NEWRULE: c_int = 6; +pub const NFT_MSG_GETRULE: c_int = 7; +pub const NFT_MSG_DELRULE: c_int = 8; +pub const NFT_MSG_NEWSET: c_int = 9; +pub const NFT_MSG_GETSET: c_int = 10; +pub const NFT_MSG_DELSET: c_int = 11; +pub const NFT_MSG_NEWSETELEM: c_int = 12; +pub const NFT_MSG_GETSETELEM: c_int = 13; +pub const NFT_MSG_DELSETELEM: c_int = 14; +pub const NFT_MSG_NEWGEN: c_int = 15; +pub const NFT_MSG_GETGEN: c_int = 16; +pub const NFT_MSG_TRACE: c_int = 17; +cfg_if! { + if #[cfg(not(target_arch = "sparc64"))] { + pub const NFT_MSG_NEWOBJ: c_int = 18; + pub const NFT_MSG_GETOBJ: c_int = 19; + pub const NFT_MSG_DELOBJ: c_int = 20; + pub const NFT_MSG_GETOBJ_RESET: c_int = 21; + } +} + +pub const NFT_MSG_MAX: c_int = 34; + +pub const NFT_SET_ANONYMOUS: c_int = 0x1; +pub const NFT_SET_CONSTANT: c_int = 0x2; +pub const NFT_SET_INTERVAL: c_int = 0x4; +pub const NFT_SET_MAP: c_int = 0x8; +pub const NFT_SET_TIMEOUT: c_int = 0x10; +pub const NFT_SET_EVAL: c_int = 0x20; + +pub const NFT_SET_POL_PERFORMANCE: c_int = 0; +pub const NFT_SET_POL_MEMORY: c_int = 1; + +pub const NFT_SET_ELEM_INTERVAL_END: c_int = 0x1; + +pub const NFT_DATA_VALUE: c_uint = 0; +pub const NFT_DATA_VERDICT: c_uint = 0xffffff00; + +pub const NFT_DATA_RESERVED_MASK: c_uint = 0xffffff00; + +pub const NFT_DATA_VALUE_MAXLEN: c_int = 64; + +pub const NFT_BYTEORDER_NTOH: c_int = 0; +pub const NFT_BYTEORDER_HTON: c_int = 1; + +pub const NFT_CMP_EQ: c_int = 0; +pub const NFT_CMP_NEQ: c_int = 1; +pub const NFT_CMP_LT: c_int = 2; +pub const NFT_CMP_LTE: c_int = 3; +pub const NFT_CMP_GT: c_int = 4; +pub const NFT_CMP_GTE: c_int = 5; + +pub const NFT_RANGE_EQ: c_int = 0; +pub const NFT_RANGE_NEQ: c_int = 1; + +pub const NFT_LOOKUP_F_INV: c_int = 1 << 0; + +pub const NFT_DYNSET_OP_ADD: c_int = 0; +pub const NFT_DYNSET_OP_UPDATE: c_int = 1; + +pub const NFT_DYNSET_F_INV: c_int = 1 << 0; + +pub const NFT_PAYLOAD_LL_HEADER: c_int = 0; +pub const NFT_PAYLOAD_NETWORK_HEADER: c_int = 1; +pub const NFT_PAYLOAD_TRANSPORT_HEADER: c_int = 2; + +pub const NFT_PAYLOAD_CSUM_NONE: c_int = 0; +pub const NFT_PAYLOAD_CSUM_INET: c_int = 1; + +pub const NFT_META_LEN: c_int = 0; +pub const NFT_META_PROTOCOL: c_int = 1; +pub const NFT_META_PRIORITY: c_int = 2; +pub const NFT_META_MARK: c_int = 3; +pub const NFT_META_IIF: c_int = 4; +pub const NFT_META_OIF: c_int = 5; +pub const NFT_META_IIFNAME: c_int = 6; +pub const NFT_META_OIFNAME: c_int = 7; +pub const NFT_META_IIFTYPE: c_int = 8; +pub const NFT_META_OIFTYPE: c_int = 9; +pub const NFT_META_SKUID: c_int = 10; +pub const NFT_META_SKGID: c_int = 11; +pub const NFT_META_NFTRACE: c_int = 12; +pub const NFT_META_RTCLASSID: c_int = 13; +pub const NFT_META_SECMARK: c_int = 14; +pub const NFT_META_NFPROTO: c_int = 15; +pub const NFT_META_L4PROTO: c_int = 16; +pub const NFT_META_BRI_IIFNAME: c_int = 17; +pub const NFT_META_BRI_OIFNAME: c_int = 18; +pub const NFT_META_PKTTYPE: c_int = 19; +pub const NFT_META_CPU: c_int = 20; +pub const NFT_META_IIFGROUP: c_int = 21; +pub const NFT_META_OIFGROUP: c_int = 22; +pub const NFT_META_CGROUP: c_int = 23; +pub const NFT_META_PRANDOM: c_int = 24; + +pub const NFT_CT_STATE: c_int = 0; +pub const NFT_CT_DIRECTION: c_int = 1; +pub const NFT_CT_STATUS: c_int = 2; +pub const NFT_CT_MARK: c_int = 3; +pub const NFT_CT_SECMARK: c_int = 4; +pub const NFT_CT_EXPIRATION: c_int = 5; +pub const NFT_CT_HELPER: c_int = 6; +pub const NFT_CT_L3PROTOCOL: c_int = 7; +pub const NFT_CT_SRC: c_int = 8; +pub const NFT_CT_DST: c_int = 9; +pub const NFT_CT_PROTOCOL: c_int = 10; +pub const NFT_CT_PROTO_SRC: c_int = 11; +pub const NFT_CT_PROTO_DST: c_int = 12; +pub const NFT_CT_LABELS: c_int = 13; +pub const NFT_CT_PKTS: c_int = 14; +pub const NFT_CT_BYTES: c_int = 15; +pub const NFT_CT_AVGPKT: c_int = 16; +pub const NFT_CT_ZONE: c_int = 17; +pub const NFT_CT_EVENTMASK: c_int = 18; +pub const NFT_CT_SRC_IP: c_int = 19; +pub const NFT_CT_DST_IP: c_int = 20; +pub const NFT_CT_SRC_IP6: c_int = 21; +pub const NFT_CT_DST_IP6: c_int = 22; + +pub const NFT_LIMIT_PKTS: c_int = 0; +pub const NFT_LIMIT_PKT_BYTES: c_int = 1; + +pub const NFT_LIMIT_F_INV: c_int = 1 << 0; + +pub const NFT_QUEUE_FLAG_BYPASS: c_int = 0x01; +pub const NFT_QUEUE_FLAG_CPU_FANOUT: c_int = 0x02; +pub const NFT_QUEUE_FLAG_MASK: c_int = 0x03; + +pub const NFT_QUOTA_F_INV: c_int = 1 << 0; + +pub const NFT_REJECT_ICMP_UNREACH: c_int = 0; +pub const NFT_REJECT_TCP_RST: c_int = 1; +pub const NFT_REJECT_ICMPX_UNREACH: c_int = 2; + +pub const NFT_REJECT_ICMPX_NO_ROUTE: c_int = 0; +pub const NFT_REJECT_ICMPX_PORT_UNREACH: c_int = 1; +pub const NFT_REJECT_ICMPX_HOST_UNREACH: c_int = 2; +pub const NFT_REJECT_ICMPX_ADMIN_PROHIBITED: c_int = 3; + +pub const NFT_NAT_SNAT: c_int = 0; +pub const NFT_NAT_DNAT: c_int = 1; + +pub const NFT_TRACETYPE_UNSPEC: c_int = 0; +pub const NFT_TRACETYPE_POLICY: c_int = 1; +pub const NFT_TRACETYPE_RETURN: c_int = 2; +pub const NFT_TRACETYPE_RULE: c_int = 3; + +pub const NFT_NG_INCREMENTAL: c_int = 0; +pub const NFT_NG_RANDOM: c_int = 1; + +// linux/input.h +pub const FF_MAX: __u16 = 0x7f; +pub const FF_CNT: usize = FF_MAX as usize + 1; + +// linux/input-event-codes.h +pub const INPUT_PROP_POINTER: __u16 = 0x00; +pub const INPUT_PROP_DIRECT: __u16 = 0x01; +pub const INPUT_PROP_BUTTONPAD: __u16 = 0x02; +pub const INPUT_PROP_SEMI_MT: __u16 = 0x03; +pub const INPUT_PROP_TOPBUTTONPAD: __u16 = 0x04; +pub const INPUT_PROP_POINTING_STICK: __u16 = 0x05; +pub const INPUT_PROP_ACCELEROMETER: __u16 = 0x06; +pub const INPUT_PROP_MAX: __u16 = 0x1f; +pub const INPUT_PROP_CNT: usize = INPUT_PROP_MAX as usize + 1; +pub const EV_MAX: __u16 = 0x1f; +pub const EV_CNT: usize = EV_MAX as usize + 1; +pub const SYN_MAX: __u16 = 0xf; +pub const SYN_CNT: usize = SYN_MAX as usize + 1; +pub const KEY_MAX: __u16 = 0x2ff; +pub const KEY_CNT: usize = KEY_MAX as usize + 1; +pub const REL_MAX: __u16 = 0x0f; +pub const REL_CNT: usize = REL_MAX as usize + 1; +pub const ABS_MAX: __u16 = 0x3f; +pub const ABS_CNT: usize = ABS_MAX as usize + 1; +pub const SW_MAX: __u16 = 0x10; +pub const SW_CNT: usize = SW_MAX as usize + 1; +pub const MSC_MAX: __u16 = 0x07; +pub const MSC_CNT: usize = MSC_MAX as usize + 1; +pub const LED_MAX: __u16 = 0x0f; +pub const LED_CNT: usize = LED_MAX as usize + 1; +pub const REP_MAX: __u16 = 0x01; +pub const REP_CNT: usize = REP_MAX as usize + 1; +pub const SND_MAX: __u16 = 0x07; +pub const SND_CNT: usize = SND_MAX as usize + 1; + +// linux/uinput.h +pub const UINPUT_VERSION: c_uint = 5; +pub const UINPUT_MAX_NAME_SIZE: usize = 80; + +// uapi/linux/fanotify.h +pub const FAN_ACCESS: u64 = 0x0000_0001; +pub const FAN_MODIFY: u64 = 0x0000_0002; +pub const FAN_ATTRIB: u64 = 0x0000_0004; +pub const FAN_CLOSE_WRITE: u64 = 0x0000_0008; +pub const FAN_CLOSE_NOWRITE: u64 = 0x0000_0010; +pub const FAN_OPEN: u64 = 0x0000_0020; +pub const FAN_MOVED_FROM: u64 = 0x0000_0040; +pub const FAN_MOVED_TO: u64 = 0x0000_0080; +pub const FAN_CREATE: u64 = 0x0000_0100; +pub const FAN_DELETE: u64 = 0x0000_0200; +pub const FAN_DELETE_SELF: u64 = 0x0000_0400; +pub const FAN_MOVE_SELF: u64 = 0x0000_0800; +pub const FAN_OPEN_EXEC: u64 = 0x0000_1000; + +pub const FAN_Q_OVERFLOW: u64 = 0x0000_4000; +pub const FAN_FS_ERROR: u64 = 0x0000_8000; + +pub const FAN_OPEN_PERM: u64 = 0x0001_0000; +pub const FAN_ACCESS_PERM: u64 = 0x0002_0000; +pub const FAN_OPEN_EXEC_PERM: u64 = 0x0004_0000; + +pub const FAN_EVENT_ON_CHILD: u64 = 0x0800_0000; + +pub const FAN_RENAME: u64 = 0x1000_0000; + +pub const FAN_ONDIR: u64 = 0x4000_0000; + +pub const FAN_CLOSE: u64 = FAN_CLOSE_WRITE | FAN_CLOSE_NOWRITE; +pub const FAN_MOVE: u64 = FAN_MOVED_FROM | FAN_MOVED_TO; + +pub const FAN_CLOEXEC: c_uint = 0x0000_0001; +pub const FAN_NONBLOCK: c_uint = 0x0000_0002; + +pub const FAN_CLASS_NOTIF: c_uint = 0x0000_0000; +pub const FAN_CLASS_CONTENT: c_uint = 0x0000_0004; +pub const FAN_CLASS_PRE_CONTENT: c_uint = 0x0000_0008; + +pub const FAN_UNLIMITED_QUEUE: c_uint = 0x0000_0010; +pub const FAN_UNLIMITED_MARKS: c_uint = 0x0000_0020; +pub const FAN_ENABLE_AUDIT: c_uint = 0x0000_0040; + +pub const FAN_REPORT_PIDFD: c_uint = 0x0000_0080; +pub const FAN_REPORT_TID: c_uint = 0x0000_0100; +pub const FAN_REPORT_FID: c_uint = 0x0000_0200; +pub const FAN_REPORT_DIR_FID: c_uint = 0x0000_0400; +pub const FAN_REPORT_NAME: c_uint = 0x0000_0800; +pub const FAN_REPORT_TARGET_FID: c_uint = 0x0000_1000; + +pub const FAN_REPORT_DFID_NAME: c_uint = FAN_REPORT_DIR_FID | FAN_REPORT_NAME; +pub const FAN_REPORT_DFID_NAME_TARGET: c_uint = + FAN_REPORT_DFID_NAME | FAN_REPORT_FID | FAN_REPORT_TARGET_FID; + +pub const FAN_MARK_ADD: c_uint = 0x0000_0001; +pub const FAN_MARK_REMOVE: c_uint = 0x0000_0002; +pub const FAN_MARK_DONT_FOLLOW: c_uint = 0x0000_0004; +pub const FAN_MARK_ONLYDIR: c_uint = 0x0000_0008; +pub const FAN_MARK_IGNORED_MASK: c_uint = 0x0000_0020; +pub const FAN_MARK_IGNORED_SURV_MODIFY: c_uint = 0x0000_0040; +pub const FAN_MARK_FLUSH: c_uint = 0x0000_0080; +pub const FAN_MARK_EVICTABLE: c_uint = 0x0000_0200; +pub const FAN_MARK_IGNORE: c_uint = 0x0000_0400; + +pub const FAN_MARK_INODE: c_uint = 0x0000_0000; +pub const FAN_MARK_MOUNT: c_uint = 0x0000_0010; +pub const FAN_MARK_FILESYSTEM: c_uint = 0x0000_0100; + +pub const FAN_MARK_IGNORE_SURV: c_uint = FAN_MARK_IGNORE | FAN_MARK_IGNORED_SURV_MODIFY; + +pub const FANOTIFY_METADATA_VERSION: u8 = 3; + +pub const FAN_EVENT_INFO_TYPE_FID: u8 = 1; +pub const FAN_EVENT_INFO_TYPE_DFID_NAME: u8 = 2; +pub const FAN_EVENT_INFO_TYPE_DFID: u8 = 3; +pub const FAN_EVENT_INFO_TYPE_PIDFD: u8 = 4; +pub const FAN_EVENT_INFO_TYPE_ERROR: u8 = 5; + +pub const FAN_EVENT_INFO_TYPE_OLD_DFID_NAME: u8 = 10; +pub const FAN_EVENT_INFO_TYPE_NEW_DFID_NAME: u8 = 12; + +pub const FAN_RESPONSE_INFO_NONE: u8 = 0; +pub const FAN_RESPONSE_INFO_AUDIT_RULE: u8 = 1; + +pub const FAN_ALLOW: u32 = 0x01; +pub const FAN_DENY: u32 = 0x02; +pub const FAN_AUDIT: u32 = 0x10; +pub const FAN_INFO: u32 = 0x20; + +pub const FAN_NOFD: c_int = -1; +pub const FAN_NOPIDFD: c_int = FAN_NOFD; +pub const FAN_EPIDFD: c_int = -2; + +// linux/futex.h +pub const FUTEX_WAIT: c_int = 0; +pub const FUTEX_WAKE: c_int = 1; +pub const FUTEX_FD: c_int = 2; +pub const FUTEX_REQUEUE: c_int = 3; +pub const FUTEX_CMP_REQUEUE: c_int = 4; +pub const FUTEX_WAKE_OP: c_int = 5; +pub const FUTEX_LOCK_PI: c_int = 6; +pub const FUTEX_UNLOCK_PI: c_int = 7; +pub const FUTEX_TRYLOCK_PI: c_int = 8; +pub const FUTEX_WAIT_BITSET: c_int = 9; +pub const FUTEX_WAKE_BITSET: c_int = 10; +pub const FUTEX_WAIT_REQUEUE_PI: c_int = 11; +pub const FUTEX_CMP_REQUEUE_PI: c_int = 12; +pub const FUTEX_LOCK_PI2: c_int = 13; + +pub const FUTEX_PRIVATE_FLAG: c_int = 128; +pub const FUTEX_CLOCK_REALTIME: c_int = 256; +pub const FUTEX_CMD_MASK: c_int = !(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME); + +pub const FUTEX_WAITERS: u32 = 0x80000000; +pub const FUTEX_OWNER_DIED: u32 = 0x40000000; +pub const FUTEX_TID_MASK: u32 = 0x3fffffff; + +pub const FUTEX_BITSET_MATCH_ANY: c_int = 0xffffffff; + +pub const FUTEX_OP_SET: c_int = 0; +pub const FUTEX_OP_ADD: c_int = 1; +pub const FUTEX_OP_OR: c_int = 2; +pub const FUTEX_OP_ANDN: c_int = 3; +pub const FUTEX_OP_XOR: c_int = 4; + +pub const FUTEX_OP_OPARG_SHIFT: c_int = 8; + +pub const FUTEX_OP_CMP_EQ: c_int = 0; +pub const FUTEX_OP_CMP_NE: c_int = 1; +pub const FUTEX_OP_CMP_LT: c_int = 2; +pub const FUTEX_OP_CMP_LE: c_int = 3; +pub const FUTEX_OP_CMP_GT: c_int = 4; +pub const FUTEX_OP_CMP_GE: c_int = 5; + +pub fn FUTEX_OP(op: c_int, oparg: c_int, cmp: c_int, cmparg: c_int) -> c_int { + ((op & 0xf) << 28) | ((cmp & 0xf) << 24) | ((oparg & 0xfff) << 12) | (cmparg & 0xfff) +} + +// linux/kexec.h +pub const KEXEC_ON_CRASH: c_int = 0x00000001; +pub const KEXEC_PRESERVE_CONTEXT: c_int = 0x00000002; +pub const KEXEC_ARCH_MASK: c_int = 0xffff0000; +pub const KEXEC_FILE_UNLOAD: c_int = 0x00000001; +pub const KEXEC_FILE_ON_CRASH: c_int = 0x00000002; +pub const KEXEC_FILE_NO_INITRAMFS: c_int = 0x00000004; + +// linux/reboot.h +pub const LINUX_REBOOT_MAGIC1: c_int = 0xfee1dead; +pub const LINUX_REBOOT_MAGIC2: c_int = 672274793; +pub const LINUX_REBOOT_MAGIC2A: c_int = 85072278; +pub const LINUX_REBOOT_MAGIC2B: c_int = 369367448; +pub const LINUX_REBOOT_MAGIC2C: c_int = 537993216; + +pub const LINUX_REBOOT_CMD_RESTART: c_int = 0x01234567; +pub const LINUX_REBOOT_CMD_HALT: c_int = 0xCDEF0123; +pub const LINUX_REBOOT_CMD_CAD_ON: c_int = 0x89ABCDEF; +pub const LINUX_REBOOT_CMD_CAD_OFF: c_int = 0x00000000; +pub const LINUX_REBOOT_CMD_POWER_OFF: c_int = 0x4321FEDC; +pub const LINUX_REBOOT_CMD_RESTART2: c_int = 0xA1B2C3D4; +pub const LINUX_REBOOT_CMD_SW_SUSPEND: c_int = 0xD000FCE2; +pub const LINUX_REBOOT_CMD_KEXEC: c_int = 0x45584543; + +// linux/errqueue.h +pub const SO_EE_ORIGIN_NONE: u8 = 0; +pub const SO_EE_ORIGIN_LOCAL: u8 = 1; +pub const SO_EE_ORIGIN_ICMP: u8 = 2; +pub const SO_EE_ORIGIN_ICMP6: u8 = 3; +pub const SO_EE_ORIGIN_TXSTATUS: u8 = 4; +pub const SO_EE_ORIGIN_TIMESTAMPING: u8 = SO_EE_ORIGIN_TXSTATUS; + +// linux/sctp.h +pub const SCTP_FUTURE_ASSOC: c_int = 0; +pub const SCTP_CURRENT_ASSOC: c_int = 1; +pub const SCTP_ALL_ASSOC: c_int = 2; +pub const SCTP_RTOINFO: c_int = 0; +pub const SCTP_ASSOCINFO: c_int = 1; +pub const SCTP_INITMSG: c_int = 2; +pub const SCTP_NODELAY: c_int = 3; +pub const SCTP_AUTOCLOSE: c_int = 4; +pub const SCTP_SET_PEER_PRIMARY_ADDR: c_int = 5; +pub const SCTP_PRIMARY_ADDR: c_int = 6; +pub const SCTP_ADAPTATION_LAYER: c_int = 7; +pub const SCTP_DISABLE_FRAGMENTS: c_int = 8; +pub const SCTP_PEER_ADDR_PARAMS: c_int = 9; +pub const SCTP_DEFAULT_SEND_PARAM: c_int = 10; +pub const SCTP_EVENTS: c_int = 11; +pub const SCTP_I_WANT_MAPPED_V4_ADDR: c_int = 12; +pub const SCTP_MAXSEG: c_int = 13; +pub const SCTP_STATUS: c_int = 14; +pub const SCTP_GET_PEER_ADDR_INFO: c_int = 15; +pub const SCTP_DELAYED_ACK_TIME: c_int = 16; +pub const SCTP_DELAYED_ACK: c_int = SCTP_DELAYED_ACK_TIME; +pub const SCTP_DELAYED_SACK: c_int = SCTP_DELAYED_ACK_TIME; +pub const SCTP_CONTEXT: c_int = 17; +pub const SCTP_FRAGMENT_INTERLEAVE: c_int = 18; +pub const SCTP_PARTIAL_DELIVERY_POINT: c_int = 19; +pub const SCTP_MAX_BURST: c_int = 20; +pub const SCTP_AUTH_CHUNK: c_int = 21; +pub const SCTP_HMAC_IDENT: c_int = 22; +pub const SCTP_AUTH_KEY: c_int = 23; +pub const SCTP_AUTH_ACTIVE_KEY: c_int = 24; +pub const SCTP_AUTH_DELETE_KEY: c_int = 25; +pub const SCTP_PEER_AUTH_CHUNKS: c_int = 26; +pub const SCTP_LOCAL_AUTH_CHUNKS: c_int = 27; +pub const SCTP_GET_ASSOC_NUMBER: c_int = 28; +pub const SCTP_GET_ASSOC_ID_LIST: c_int = 29; +pub const SCTP_AUTO_ASCONF: c_int = 30; +pub const SCTP_PEER_ADDR_THLDS: c_int = 31; +pub const SCTP_RECVRCVINFO: c_int = 32; +pub const SCTP_RECVNXTINFO: c_int = 33; +pub const SCTP_DEFAULT_SNDINFO: c_int = 34; +pub const SCTP_AUTH_DEACTIVATE_KEY: c_int = 35; +pub const SCTP_REUSE_PORT: c_int = 36; +pub const SCTP_PEER_ADDR_THLDS_V2: c_int = 37; +pub const SCTP_PR_SCTP_NONE: c_int = 0x0000; +pub const SCTP_PR_SCTP_TTL: c_int = 0x0010; +pub const SCTP_PR_SCTP_RTX: c_int = 0x0020; +pub const SCTP_PR_SCTP_PRIO: c_int = 0x0030; +pub const SCTP_PR_SCTP_MAX: c_int = SCTP_PR_SCTP_PRIO; +pub const SCTP_PR_SCTP_MASK: c_int = 0x0030; +pub const SCTP_ENABLE_RESET_STREAM_REQ: c_int = 0x01; +pub const SCTP_ENABLE_RESET_ASSOC_REQ: c_int = 0x02; +pub const SCTP_ENABLE_CHANGE_ASSOC_REQ: c_int = 0x04; +pub const SCTP_ENABLE_STRRESET_MASK: c_int = 0x07; +pub const SCTP_STREAM_RESET_INCOMING: c_int = 0x01; +pub const SCTP_STREAM_RESET_OUTGOING: c_int = 0x02; + +pub const SCTP_INIT: c_int = 0; +pub const SCTP_SNDRCV: c_int = 1; +pub const SCTP_SNDINFO: c_int = 2; +pub const SCTP_RCVINFO: c_int = 3; +pub const SCTP_NXTINFO: c_int = 4; +pub const SCTP_PRINFO: c_int = 5; +pub const SCTP_AUTHINFO: c_int = 6; +pub const SCTP_DSTADDRV4: c_int = 7; +pub const SCTP_DSTADDRV6: c_int = 8; + +pub const SCTP_UNORDERED: c_int = 1 << 0; +pub const SCTP_ADDR_OVER: c_int = 1 << 1; +pub const SCTP_ABORT: c_int = 1 << 2; +pub const SCTP_SACK_IMMEDIATELY: c_int = 1 << 3; +pub const SCTP_SENDALL: c_int = 1 << 6; +pub const SCTP_PR_SCTP_ALL: c_int = 1 << 7; +pub const SCTP_NOTIFICATION: c_int = MSG_NOTIFICATION; +pub const SCTP_EOF: c_int = crate::MSG_FIN; + +/* DCCP socket options */ +pub const DCCP_SOCKOPT_PACKET_SIZE: c_int = 1; +pub const DCCP_SOCKOPT_SERVICE: c_int = 2; +pub const DCCP_SOCKOPT_CHANGE_L: c_int = 3; +pub const DCCP_SOCKOPT_CHANGE_R: c_int = 4; +pub const DCCP_SOCKOPT_GET_CUR_MPS: c_int = 5; +pub const DCCP_SOCKOPT_SERVER_TIMEWAIT: c_int = 6; +pub const DCCP_SOCKOPT_SEND_CSCOV: c_int = 10; +pub const DCCP_SOCKOPT_RECV_CSCOV: c_int = 11; +pub const DCCP_SOCKOPT_AVAILABLE_CCIDS: c_int = 12; +pub const DCCP_SOCKOPT_CCID: c_int = 13; +pub const DCCP_SOCKOPT_TX_CCID: c_int = 14; +pub const DCCP_SOCKOPT_RX_CCID: c_int = 15; +pub const DCCP_SOCKOPT_QPOLICY_ID: c_int = 16; +pub const DCCP_SOCKOPT_QPOLICY_TXQLEN: c_int = 17; +pub const DCCP_SOCKOPT_CCID_RX_INFO: c_int = 128; +pub const DCCP_SOCKOPT_CCID_TX_INFO: c_int = 192; + +/// maximum number of services provided on the same listening port +pub const DCCP_SERVICE_LIST_MAX_LEN: c_int = 32; + +pub const CTL_KERN: c_int = 1; +pub const CTL_VM: c_int = 2; +pub const CTL_NET: c_int = 3; +pub const CTL_FS: c_int = 5; +pub const CTL_DEBUG: c_int = 6; +pub const CTL_DEV: c_int = 7; +pub const CTL_BUS: c_int = 8; +pub const CTL_ABI: c_int = 9; +pub const CTL_CPU: c_int = 10; + +pub const CTL_BUS_ISA: c_int = 1; + +pub const INOTIFY_MAX_USER_INSTANCES: c_int = 1; +pub const INOTIFY_MAX_USER_WATCHES: c_int = 2; +pub const INOTIFY_MAX_QUEUED_EVENTS: c_int = 3; + +pub const KERN_OSTYPE: c_int = 1; +pub const KERN_OSRELEASE: c_int = 2; +pub const KERN_OSREV: c_int = 3; +pub const KERN_VERSION: c_int = 4; +pub const KERN_SECUREMASK: c_int = 5; +pub const KERN_PROF: c_int = 6; +pub const KERN_NODENAME: c_int = 7; +pub const KERN_DOMAINNAME: c_int = 8; +pub const KERN_PANIC: c_int = 15; +pub const KERN_REALROOTDEV: c_int = 16; +pub const KERN_SPARC_REBOOT: c_int = 21; +pub const KERN_CTLALTDEL: c_int = 22; +pub const KERN_PRINTK: c_int = 23; +pub const KERN_NAMETRANS: c_int = 24; +pub const KERN_PPC_HTABRECLAIM: c_int = 25; +pub const KERN_PPC_ZEROPAGED: c_int = 26; +pub const KERN_PPC_POWERSAVE_NAP: c_int = 27; +pub const KERN_MODPROBE: c_int = 28; +pub const KERN_SG_BIG_BUFF: c_int = 29; +pub const KERN_ACCT: c_int = 30; +pub const KERN_PPC_L2CR: c_int = 31; +pub const KERN_RTSIGNR: c_int = 32; +pub const KERN_RTSIGMAX: c_int = 33; +pub const KERN_SHMMAX: c_int = 34; +pub const KERN_MSGMAX: c_int = 35; +pub const KERN_MSGMNB: c_int = 36; +pub const KERN_MSGPOOL: c_int = 37; +pub const KERN_SYSRQ: c_int = 38; +pub const KERN_MAX_THREADS: c_int = 39; +pub const KERN_RANDOM: c_int = 40; +pub const KERN_SHMALL: c_int = 41; +pub const KERN_MSGMNI: c_int = 42; +pub const KERN_SEM: c_int = 43; +pub const KERN_SPARC_STOP_A: c_int = 44; +pub const KERN_SHMMNI: c_int = 45; +pub const KERN_OVERFLOWUID: c_int = 46; +pub const KERN_OVERFLOWGID: c_int = 47; +pub const KERN_SHMPATH: c_int = 48; +pub const KERN_HOTPLUG: c_int = 49; +pub const KERN_IEEE_EMULATION_WARNINGS: c_int = 50; +pub const KERN_S390_USER_DEBUG_LOGGING: c_int = 51; +pub const KERN_CORE_USES_PID: c_int = 52; +pub const KERN_TAINTED: c_int = 53; +pub const KERN_CADPID: c_int = 54; +pub const KERN_PIDMAX: c_int = 55; +pub const KERN_CORE_PATTERN: c_int = 56; +pub const KERN_PANIC_ON_OOPS: c_int = 57; +pub const KERN_HPPA_PWRSW: c_int = 58; +pub const KERN_HPPA_UNALIGNED: c_int = 59; +pub const KERN_PRINTK_RATELIMIT: c_int = 60; +pub const KERN_PRINTK_RATELIMIT_BURST: c_int = 61; +pub const KERN_PTY: c_int = 62; +pub const KERN_NGROUPS_MAX: c_int = 63; +pub const KERN_SPARC_SCONS_PWROFF: c_int = 64; +pub const KERN_HZ_TIMER: c_int = 65; +pub const KERN_UNKNOWN_NMI_PANIC: c_int = 66; +pub const KERN_BOOTLOADER_TYPE: c_int = 67; +pub const KERN_RANDOMIZE: c_int = 68; +pub const KERN_SETUID_DUMPABLE: c_int = 69; +pub const KERN_SPIN_RETRY: c_int = 70; +pub const KERN_ACPI_VIDEO_FLAGS: c_int = 71; +pub const KERN_IA64_UNALIGNED: c_int = 72; +pub const KERN_COMPAT_LOG: c_int = 73; +pub const KERN_MAX_LOCK_DEPTH: c_int = 74; +pub const KERN_NMI_WATCHDOG: c_int = 75; +pub const KERN_PANIC_ON_NMI: c_int = 76; + +pub const VM_OVERCOMMIT_MEMORY: c_int = 5; +pub const VM_PAGE_CLUSTER: c_int = 10; +pub const VM_DIRTY_BACKGROUND: c_int = 11; +pub const VM_DIRTY_RATIO: c_int = 12; +pub const VM_DIRTY_WB_CS: c_int = 13; +pub const VM_DIRTY_EXPIRE_CS: c_int = 14; +pub const VM_NR_PDFLUSH_THREADS: c_int = 15; +pub const VM_OVERCOMMIT_RATIO: c_int = 16; +pub const VM_PAGEBUF: c_int = 17; +pub const VM_HUGETLB_PAGES: c_int = 18; +pub const VM_SWAPPINESS: c_int = 19; +pub const VM_LOWMEM_RESERVE_RATIO: c_int = 20; +pub const VM_MIN_FREE_KBYTES: c_int = 21; +pub const VM_MAX_MAP_COUNT: c_int = 22; +pub const VM_LAPTOP_MODE: c_int = 23; +pub const VM_BLOCK_DUMP: c_int = 24; +pub const VM_HUGETLB_GROUP: c_int = 25; +pub const VM_VFS_CACHE_PRESSURE: c_int = 26; +pub const VM_LEGACY_VA_LAYOUT: c_int = 27; +pub const VM_SWAP_TOKEN_TIMEOUT: c_int = 28; +pub const VM_DROP_PAGECACHE: c_int = 29; +pub const VM_PERCPU_PAGELIST_FRACTION: c_int = 30; +pub const VM_ZONE_RECLAIM_MODE: c_int = 31; +pub const VM_MIN_UNMAPPED: c_int = 32; +pub const VM_PANIC_ON_OOM: c_int = 33; +pub const VM_VDSO_ENABLED: c_int = 34; +pub const VM_MIN_SLAB: c_int = 35; + +pub const NET_CORE: c_int = 1; +pub const NET_ETHER: c_int = 2; +pub const NET_802: c_int = 3; +pub const NET_UNIX: c_int = 4; +pub const NET_IPV4: c_int = 5; +pub const NET_IPX: c_int = 6; +pub const NET_ATALK: c_int = 7; +pub const NET_NETROM: c_int = 8; +pub const NET_AX25: c_int = 9; +pub const NET_BRIDGE: c_int = 10; +pub const NET_ROSE: c_int = 11; +pub const NET_IPV6: c_int = 12; +pub const NET_X25: c_int = 13; +pub const NET_TR: c_int = 14; +pub const NET_DECNET: c_int = 15; +pub const NET_ECONET: c_int = 16; +pub const NET_SCTP: c_int = 17; +pub const NET_LLC: c_int = 18; +pub const NET_NETFILTER: c_int = 19; +pub const NET_DCCP: c_int = 20; +pub const NET_IRDA: c_int = 412; + +// include/linux/sched.h +/// I'm a virtual CPU. +pub const PF_VCPU: c_int = 0x00000001; +/// I am an IDLE thread. +pub const PF_IDLE: c_int = 0x00000002; +/// Getting shut down. +pub const PF_EXITING: c_int = 0x00000004; +/// Coredumps should ignore this task. +pub const PF_POSTCOREDUMP: c_int = 0x00000008; +/// Task is an IO worker. +pub const PF_IO_WORKER: c_int = 0x00000010; +/// I'm a workqueue worker. +pub const PF_WQ_WORKER: c_int = 0x00000020; +/// Forked but didn't exec. +pub const PF_FORKNOEXEC: c_int = 0x00000040; +/// Process policy on mce errors. +pub const PF_MCE_PROCESS: c_int = 0x00000080; +/// Used super-user privileges. +pub const PF_SUPERPRIV: c_int = 0x00000100; +/// Dumped core. +pub const PF_DUMPCORE: c_int = 0x00000200; +/// Killed by a signal. +pub const PF_SIGNALED: c_int = 0x00000400; +/// Allocating memory to free memory. +/// +/// See `memalloc_noreclaim_save()`. +pub const PF_MEMALLOC: c_int = 0x00000800; +/// `set_user()` noticed that `RLIMIT_NPROC` was exceeded. +pub const PF_NPROC_EXCEEDED: c_int = 0x00001000; +/// If unset the fpu must be initialized before use. +pub const PF_USED_MATH: c_int = 0x00002000; +/// Kernel thread cloned from userspace thread. +pub const PF_USER_WORKER: c_int = 0x00004000; +/// This thread should not be frozen. +pub const PF_NOFREEZE: c_int = 0x00008000; +/// I am `kswapd`. +pub const PF_KSWAPD: c_int = 0x00020000; +/// All allocations inherit `GFP_NOFS`. +/// +/// See `memalloc_nfs_save()`. +pub const PF_MEMALLOC_NOFS: c_int = 0x00040000; +/// All allocations inherit `GFP_NOIO`. +/// +/// See `memalloc_noio_save()`. +pub const PF_MEMALLOC_NOIO: c_int = 0x00080000; +/// Throttle writes only against the bdi I write to, I am cleaning +/// dirty pages from some other bdi. +pub const PF_LOCAL_THROTTLE: c_int = 0x00100000; +/// I am a kernel thread. +pub const PF_KTHREAD: c_int = 0x00200000; +/// Randomize virtual address space. +pub const PF_RANDOMIZE: c_int = 0x00400000; +/// Userland is not allowed to meddle with `cpus_mask`. +pub const PF_NO_SETAFFINITY: c_int = 0x04000000; +/// Early kill for mce process policy. +pub const PF_MCE_EARLY: c_int = 0x08000000; +/// Allocations constrained to zones which allow long term pinning. +/// +/// See `memalloc_pin_save()`. +pub const PF_MEMALLOC_PIN: c_int = 0x10000000; +/// Plug has ts that needs updating. +pub const PF_BLOCK_TS: c_int = 0x20000000; +/// This thread called `freeze_processes()` and should not be frozen. +pub const PF_SUSPEND_TASK: c_int = PF_SUSPEND_TASK_UINT as _; +// The used value is the highest possible bit fitting on 32 bits, so directly +// defining it as a signed integer causes the compiler to report an overflow. +// Use instead a private intermediary that assuringly has the correct type and +// cast it where necessary to the wanted final type, which preserves the +// desired information as-is in terms of integer representation. +const PF_SUSPEND_TASK_UINT: c_uint = 0x80000000; + +pub const CLONE_PIDFD: c_int = 0x1000; + +pub const SCHED_FLAG_RESET_ON_FORK: c_int = 0x01; +pub const SCHED_FLAG_RECLAIM: c_int = 0x02; +pub const SCHED_FLAG_DL_OVERRUN: c_int = 0x04; +pub const SCHED_FLAG_KEEP_POLICY: c_int = 0x08; +pub const SCHED_FLAG_KEEP_PARAMS: c_int = 0x10; +pub const SCHED_FLAG_UTIL_CLAMP_MIN: c_int = 0x20; +pub const SCHED_FLAG_UTIL_CLAMP_MAX: c_int = 0x40; + +// linux/if_xdp.h +pub const XDP_SHARED_UMEM: crate::__u16 = 1 << 0; +pub const XDP_COPY: crate::__u16 = 1 << 1; +pub const XDP_ZEROCOPY: crate::__u16 = 1 << 2; +pub const XDP_USE_NEED_WAKEUP: crate::__u16 = 1 << 3; +pub const XDP_USE_SG: crate::__u16 = 1 << 4; + +pub const XDP_UMEM_UNALIGNED_CHUNK_FLAG: crate::__u32 = 1 << 0; + +pub const XDP_RING_NEED_WAKEUP: crate::__u32 = 1 << 0; + +pub const XDP_MMAP_OFFSETS: c_int = 1; +pub const XDP_RX_RING: c_int = 2; +pub const XDP_TX_RING: c_int = 3; +pub const XDP_UMEM_REG: c_int = 4; +pub const XDP_UMEM_FILL_RING: c_int = 5; +pub const XDP_UMEM_COMPLETION_RING: c_int = 6; +pub const XDP_STATISTICS: c_int = 7; +pub const XDP_OPTIONS: c_int = 8; + +pub const XDP_OPTIONS_ZEROCOPY: crate::__u32 = 1 << 0; + +pub const XDP_PGOFF_RX_RING: crate::off_t = 0; +pub const XDP_PGOFF_TX_RING: crate::off_t = 0x80000000; +pub const XDP_UMEM_PGOFF_FILL_RING: crate::c_ulonglong = 0x100000000; +pub const XDP_UMEM_PGOFF_COMPLETION_RING: crate::c_ulonglong = 0x180000000; + +pub const XSK_UNALIGNED_BUF_OFFSET_SHIFT: crate::c_int = 48; +pub const XSK_UNALIGNED_BUF_ADDR_MASK: crate::c_ulonglong = + (1 << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1; + +pub const XDP_PKT_CONTD: crate::__u32 = 1 << 0; + +pub const XDP_UMEM_TX_SW_CSUM: crate::__u32 = 1 << 1; +pub const XDP_UMEM_TX_METADATA_LEN: crate::__u32 = 1 << 2; + +pub const XDP_TXMD_FLAGS_TIMESTAMP: crate::__u32 = 1 << 0; +pub const XDP_TXMD_FLAGS_CHECKSUM: crate::__u32 = 1 << 1; + +pub const XDP_TX_METADATA: crate::__u32 = 1 << 1; + +pub const SOL_XDP: c_int = 283; + +// linux/mount.h +pub const MOUNT_ATTR_RDONLY: crate::__u64 = 0x00000001; +pub const MOUNT_ATTR_NOSUID: crate::__u64 = 0x00000002; +pub const MOUNT_ATTR_NODEV: crate::__u64 = 0x00000004; +pub const MOUNT_ATTR_NOEXEC: crate::__u64 = 0x00000008; +pub const MOUNT_ATTR__ATIME: crate::__u64 = 0x00000070; +pub const MOUNT_ATTR_RELATIME: crate::__u64 = 0x00000000; +pub const MOUNT_ATTR_NOATIME: crate::__u64 = 0x00000010; +pub const MOUNT_ATTR_STRICTATIME: crate::__u64 = 0x00000020; +pub const MOUNT_ATTR_NODIRATIME: crate::__u64 = 0x00000080; +pub const MOUNT_ATTR_IDMAP: crate::__u64 = 0x00100000; +pub const MOUNT_ATTR_NOSYMFOLLOW: crate::__u64 = 0x00200000; + +pub const MOUNT_ATTR_SIZE_VER0: c_int = 32; + +pub const SCHED_FLAG_KEEP_ALL: c_int = SCHED_FLAG_KEEP_POLICY | SCHED_FLAG_KEEP_PARAMS; + +pub const SCHED_FLAG_UTIL_CLAMP: c_int = SCHED_FLAG_UTIL_CLAMP_MIN | SCHED_FLAG_UTIL_CLAMP_MAX; + +pub const SCHED_FLAG_ALL: c_int = SCHED_FLAG_RESET_ON_FORK + | SCHED_FLAG_RECLAIM + | SCHED_FLAG_DL_OVERRUN + | SCHED_FLAG_KEEP_ALL + | SCHED_FLAG_UTIL_CLAMP; + +// ioctl_eventpoll: added in Linux 6.9 +pub const EPIOCSPARAMS: Ioctl = 0x40088a01; +pub const EPIOCGPARAMS: Ioctl = 0x80088a02; + +// siginfo.h +pub const SI_DETHREAD: c_int = -7; +pub const TRAP_PERF: c_int = 6; + +f! { + pub fn SCTP_PR_INDEX(policy: c_int) -> c_int { + policy >> (4 - 1) + } + + pub fn SCTP_PR_POLICY(policy: c_int) -> c_int { + policy & SCTP_PR_SCTP_MASK + } + + pub fn SCTP_PR_SET_POLICY(flags: &mut c_int, policy: c_int) -> () { + *flags &= !SCTP_PR_SCTP_MASK; + *flags |= policy; + } + + pub fn SO_EE_OFFENDER(ee: *const crate::sock_extended_err) -> *mut crate::sockaddr { + ee.offset(1) as *mut crate::sockaddr + } + + pub fn TPACKET_ALIGN(x: usize) -> usize { + (x + TPACKET_ALIGNMENT - 1) & !(TPACKET_ALIGNMENT - 1) + } + + pub fn BPF_CLASS(code: __u32) -> __u32 { + code & 0x07 + } + + pub fn BPF_SIZE(code: __u32) -> __u32 { + code & 0x18 + } + + pub fn BPF_MODE(code: __u32) -> __u32 { + code & 0xe0 + } + + pub fn BPF_OP(code: __u32) -> __u32 { + code & 0xf0 + } + + pub fn BPF_SRC(code: __u32) -> __u32 { + code & 0x08 + } + + pub fn BPF_RVAL(code: __u32) -> __u32 { + code & 0x18 + } + + pub fn BPF_MISCOP(code: __u32) -> __u32 { + code & 0xf8 + } + + pub fn BPF_STMT(code: __u16, k: __u32) -> sock_filter { + sock_filter { + code, + jt: 0, + jf: 0, + k, + } + } + + pub fn BPF_JUMP(code: __u16, k: __u32, jt: __u8, jf: __u8) -> sock_filter { + sock_filter { code, jt, jf, k } + } + + #[cfg(target_env = "gnu")] + pub fn SUN_LEN(s: crate::sockaddr_un) -> usize { + offset_of!(crate::sockaddr_un, sun_path) + crate::strlen(s.sun_path.as_ptr()) + } + + #[cfg(target_env = "musl")] + pub fn SUN_LEN(s: crate::sockaddr_un) -> usize { + 2 * crate::strlen(s.sun_path.as_ptr()) + } +} + +safe_f! { + pub const fn SCTP_PR_TTL_ENABLED(policy: c_int) -> bool { + policy == SCTP_PR_SCTP_TTL + } + + pub const fn SCTP_PR_RTX_ENABLED(policy: c_int) -> bool { + policy == SCTP_PR_SCTP_RTX + } + + pub const fn SCTP_PR_PRIO_ENABLED(policy: c_int) -> bool { + policy == SCTP_PR_SCTP_PRIO + } +} + +// These functions are not available on OpenHarmony +cfg_if! { + if #[cfg(not(target_env = "ohos"))] { + extern "C" { + // Only `getspnam_r` is implemented for musl, out of all of the reenterant + // functions from `shadow.h`. + // https://git.musl-libc.org/cgit/musl/tree/include/shadow.h + pub fn getspnam_r( + name: *const c_char, + spbuf: *mut crate::spwd, + buf: *mut c_char, + buflen: size_t, + spbufp: *mut *mut crate::spwd, + ) -> c_int; + + pub fn mq_open(name: *const c_char, oflag: c_int, ...) -> mqd_t; + pub fn mq_close(mqd: mqd_t) -> c_int; + pub fn mq_unlink(name: *const c_char) -> c_int; + pub fn mq_receive( + mqd: mqd_t, + msg_ptr: *mut c_char, + msg_len: size_t, + msg_prio: *mut c_uint, + ) -> ssize_t; + #[cfg_attr( + any(gnu_time_bits64, musl_redir_time64), + link_name = "__mq_timedreceive_time64" + )] + pub fn mq_timedreceive( + mqd: mqd_t, + msg_ptr: *mut c_char, + msg_len: size_t, + msg_prio: *mut c_uint, + abs_timeout: *const crate::timespec, + ) -> ssize_t; + pub fn mq_send( + mqd: mqd_t, + msg_ptr: *const c_char, + msg_len: size_t, + msg_prio: c_uint, + ) -> c_int; + #[cfg_attr( + any(gnu_time_bits64, musl_redir_time64), + link_name = "__mq_timedsend_time64" + )] + pub fn mq_timedsend( + mqd: mqd_t, + msg_ptr: *const c_char, + msg_len: size_t, + msg_prio: c_uint, + abs_timeout: *const crate::timespec, + ) -> c_int; + pub fn mq_getattr(mqd: mqd_t, attr: *mut crate::mq_attr) -> c_int; + pub fn mq_setattr( + mqd: mqd_t, + newattr: *const crate::mq_attr, + oldattr: *mut crate::mq_attr, + ) -> c_int; + } + } +} + +extern "C" { + pub fn mrand48() -> c_long; + pub fn seed48(xseed: *mut c_ushort) -> *mut c_ushort; + pub fn lcong48(p: *mut c_ushort); + + #[cfg_attr(gnu_time_bits64, link_name = "__lutimes64")] + #[cfg_attr(musl_redir_time64, link_name = "__lutimes_time64")] + pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int; + + pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int; + pub fn shm_unlink(name: *const c_char) -> c_int; + + // System V IPC + pub fn ftok(pathname: *const c_char, proj_id: c_int) -> crate::key_t; + pub fn semget(key: crate::key_t, nsems: c_int, semflag: c_int) -> c_int; + pub fn semop(semid: c_int, sops: *mut crate::sembuf, nsops: size_t) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__semctl64")] + pub fn semctl(semid: c_int, semnum: c_int, cmd: c_int, ...) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__msgctl64")] + pub fn msgctl(msqid: c_int, cmd: c_int, buf: *mut msqid_ds) -> c_int; + pub fn msgget(key: crate::key_t, msgflg: c_int) -> c_int; + pub fn msgrcv( + msqid: c_int, + msgp: *mut c_void, + msgsz: size_t, + msgtyp: c_long, + msgflg: c_int, + ) -> ssize_t; + pub fn msgsnd(msqid: c_int, msgp: *const c_void, msgsz: size_t, msgflg: c_int) -> c_int; + + #[cfg_attr(gnu_file_offset_bits64, link_name = "fallocate64")] + pub fn fallocate(fd: c_int, mode: c_int, offset: off_t, len: off_t) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "posix_fallocate64")] + pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int; + pub fn readahead(fd: c_int, offset: off64_t, count: size_t) -> ssize_t; + pub fn getxattr( + path: *const c_char, + name: *const c_char, + value: *mut c_void, + size: size_t, + ) -> ssize_t; + pub fn lgetxattr( + path: *const c_char, + name: *const c_char, + value: *mut c_void, + size: size_t, + ) -> ssize_t; + pub fn fgetxattr( + filedes: c_int, + name: *const c_char, + value: *mut c_void, + size: size_t, + ) -> ssize_t; + pub fn setxattr( + path: *const c_char, + name: *const c_char, + value: *const c_void, + size: size_t, + flags: c_int, + ) -> c_int; + pub fn lsetxattr( + path: *const c_char, + name: *const c_char, + value: *const c_void, + size: size_t, + flags: c_int, + ) -> c_int; + pub fn fsetxattr( + filedes: c_int, + name: *const c_char, + value: *const c_void, + size: size_t, + flags: c_int, + ) -> c_int; + pub fn listxattr(path: *const c_char, list: *mut c_char, size: size_t) -> ssize_t; + pub fn llistxattr(path: *const c_char, list: *mut c_char, size: size_t) -> ssize_t; + pub fn flistxattr(filedes: c_int, list: *mut c_char, size: size_t) -> ssize_t; + pub fn removexattr(path: *const c_char, name: *const c_char) -> c_int; + pub fn lremovexattr(path: *const c_char, name: *const c_char) -> c_int; + pub fn fremovexattr(filedes: c_int, name: *const c_char) -> c_int; + pub fn signalfd(fd: c_int, mask: *const crate::sigset_t, flags: c_int) -> c_int; + pub fn timerfd_create(clockid: crate::clockid_t, flags: c_int) -> c_int; + #[cfg_attr( + any(gnu_time_bits64, musl_redir_time64), + link_name = "__timerfd_gettime64" + )] + pub fn timerfd_gettime(fd: c_int, curr_value: *mut crate::itimerspec) -> c_int; + #[cfg_attr( + any(gnu_time_bits64, musl_redir_time64), + link_name = "__timerfd_settime64" + )] + pub fn timerfd_settime( + fd: c_int, + flags: c_int, + new_value: *const crate::itimerspec, + old_value: *mut crate::itimerspec, + ) -> c_int; + pub fn quotactl(cmd: c_int, special: *const c_char, id: c_int, data: *mut c_char) -> c_int; + pub fn epoll_pwait( + epfd: c_int, + events: *mut crate::epoll_event, + maxevents: c_int, + timeout: c_int, + sigmask: *const crate::sigset_t, + ) -> c_int; + pub fn dup3(oldfd: c_int, newfd: c_int, flags: c_int) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__sigtimedwait64")] + #[cfg_attr(musl_redir_time64, link_name = "__sigtimedwait_time64")] + pub fn sigtimedwait( + set: *const sigset_t, + info: *mut siginfo_t, + timeout: *const crate::timespec, + ) -> c_int; + pub fn sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> c_int; + pub fn accept4(fd: c_int, addr: *mut crate::sockaddr, len: *mut socklen_t, flg: c_int) + -> c_int; + pub fn reboot(how_to: c_int) -> c_int; + pub fn setfsgid(gid: crate::gid_t) -> c_int; + pub fn setfsuid(uid: crate::uid_t) -> c_int; + + // Not available now on Android + pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; + pub fn sync_file_range(fd: c_int, offset: off64_t, nbytes: off64_t, flags: c_uint) -> c_int; + + pub fn posix_madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; + + pub fn remap_file_pages( + addr: *mut c_void, + size: size_t, + prot: c_int, + pgoff: size_t, + flags: c_int, + ) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "mkstemps64")] + pub fn mkstemps(template: *mut c_char, suffixlen: c_int) -> c_int; + + pub fn vhangup() -> c_int; + pub fn sync(); + pub fn syncfs(fd: c_int) -> c_int; + pub fn syscall(num: c_long, ...) -> c_long; + pub fn sched_setaffinity( + pid: crate::pid_t, + cpusetsize: size_t, + cpuset: *const crate::cpu_set_t, + ) -> c_int; + pub fn epoll_create(size: c_int) -> c_int; + pub fn epoll_create1(flags: c_int) -> c_int; + pub fn epoll_wait( + epfd: c_int, + events: *mut crate::epoll_event, + maxevents: c_int, + timeout: c_int, + ) -> c_int; + pub fn epoll_ctl(epfd: c_int, op: c_int, fd: c_int, event: *mut crate::epoll_event) -> c_int; + pub fn unshare(flags: c_int) -> c_int; + pub fn umount(target: *const c_char) -> c_int; + pub fn tee(fd_in: c_int, fd_out: c_int, len: size_t, flags: c_uint) -> ssize_t; + pub fn splice( + fd_in: c_int, + off_in: *mut loff_t, + fd_out: c_int, + off_out: *mut loff_t, + len: size_t, + flags: c_uint, + ) -> ssize_t; + pub fn eventfd(initval: c_uint, flags: c_int) -> c_int; + pub fn eventfd_read(fd: c_int, value: *mut eventfd_t) -> c_int; + pub fn eventfd_write(fd: c_int, value: eventfd_t) -> c_int; + + #[cfg_attr(gnu_time_bits64, link_name = "__sched_rr_get_interval64")] + #[cfg_attr(musl_redir_time64, link_name = "__sched_rr_get_interval_time64")] + pub fn sched_rr_get_interval(pid: crate::pid_t, tp: *mut crate::timespec) -> c_int; + pub fn sched_setparam(pid: crate::pid_t, param: *const crate::sched_param) -> c_int; + pub fn setns(fd: c_int, nstype: c_int) -> c_int; + pub fn swapoff(path: *const c_char) -> c_int; + pub fn vmsplice(fd: c_int, iov: *const crate::iovec, nr_segs: size_t, flags: c_uint) + -> ssize_t; + pub fn personality(persona: c_ulong) -> c_int; + pub fn sched_getparam(pid: crate::pid_t, param: *mut crate::sched_param) -> c_int; + pub fn clone( + cb: extern "C" fn(*mut c_void) -> c_int, + child_stack: *mut c_void, + flags: c_int, + arg: *mut c_void, + ... + ) -> c_int; + pub fn sched_getscheduler(pid: crate::pid_t) -> c_int; + #[cfg_attr( + any(gnu_time_bits64, musl_redir_time64), + link_name = "__clock_nanosleep_time64" + )] + pub fn clock_nanosleep( + clk_id: crate::clockid_t, + flags: c_int, + rqtp: *const crate::timespec, + rmtp: *mut crate::timespec, + ) -> c_int; + pub fn umount2(target: *const c_char, flags: c_int) -> c_int; + pub fn swapon(path: *const c_char, swapflags: c_int) -> c_int; + pub fn sched_setscheduler( + pid: crate::pid_t, + policy: c_int, + param: *const crate::sched_param, + ) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "sendfile64")] + pub fn sendfile(out_fd: c_int, in_fd: c_int, offset: *mut off_t, count: size_t) -> ssize_t; + pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> c_int; + pub fn getdtablesize() -> c_int; + pub fn getgrouplist( + user: *const c_char, + group: crate::gid_t, + groups: *mut crate::gid_t, + ngroups: *mut c_int, + ) -> c_int; + pub fn posix_spawn( + pid: *mut crate::pid_t, + path: *const c_char, + file_actions: *const crate::posix_spawn_file_actions_t, + attrp: *const crate::posix_spawnattr_t, + argv: *const *mut c_char, + envp: *const *mut c_char, + ) -> c_int; + pub fn posix_spawnp( + pid: *mut crate::pid_t, + file: *const c_char, + file_actions: *const crate::posix_spawn_file_actions_t, + attrp: *const crate::posix_spawnattr_t, + argv: *const *mut c_char, + envp: *const *mut c_char, + ) -> c_int; + pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> c_int; + pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> c_int; + pub fn posix_spawnattr_getsigdefault( + attr: *const posix_spawnattr_t, + default: *mut crate::sigset_t, + ) -> c_int; + pub fn posix_spawnattr_setsigdefault( + attr: *mut posix_spawnattr_t, + default: *const crate::sigset_t, + ) -> c_int; + pub fn posix_spawnattr_getsigmask( + attr: *const posix_spawnattr_t, + default: *mut crate::sigset_t, + ) -> c_int; + pub fn posix_spawnattr_setsigmask( + attr: *mut posix_spawnattr_t, + default: *const crate::sigset_t, + ) -> c_int; + pub fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t, flags: *mut c_short) -> c_int; + pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t, flags: c_short) -> c_int; + pub fn posix_spawnattr_getpgroup( + attr: *const posix_spawnattr_t, + flags: *mut crate::pid_t, + ) -> c_int; + pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, flags: crate::pid_t) -> c_int; + pub fn posix_spawnattr_getschedpolicy( + attr: *const posix_spawnattr_t, + flags: *mut c_int, + ) -> c_int; + pub fn posix_spawnattr_setschedpolicy(attr: *mut posix_spawnattr_t, flags: c_int) -> c_int; + pub fn posix_spawnattr_getschedparam( + attr: *const posix_spawnattr_t, + param: *mut crate::sched_param, + ) -> c_int; + pub fn posix_spawnattr_setschedparam( + attr: *mut posix_spawnattr_t, + param: *const crate::sched_param, + ) -> c_int; + + pub fn posix_spawn_file_actions_init(actions: *mut posix_spawn_file_actions_t) -> c_int; + pub fn posix_spawn_file_actions_destroy(actions: *mut posix_spawn_file_actions_t) -> c_int; + pub fn posix_spawn_file_actions_addopen( + actions: *mut posix_spawn_file_actions_t, + fd: c_int, + path: *const c_char, + oflag: c_int, + mode: mode_t, + ) -> c_int; + pub fn posix_spawn_file_actions_addclose( + actions: *mut posix_spawn_file_actions_t, + fd: c_int, + ) -> c_int; + pub fn posix_spawn_file_actions_adddup2( + actions: *mut posix_spawn_file_actions_t, + fd: c_int, + newfd: c_int, + ) -> c_int; + pub fn fread_unlocked( + buf: *mut c_void, + size: size_t, + nobj: size_t, + stream: *mut crate::FILE, + ) -> size_t; + pub fn inotify_rm_watch(fd: c_int, wd: c_int) -> c_int; + pub fn inotify_init() -> c_int; + pub fn inotify_init1(flags: c_int) -> c_int; + pub fn inotify_add_watch(fd: c_int, path: *const c_char, mask: u32) -> c_int; + pub fn fanotify_init(flags: c_uint, event_f_flags: c_uint) -> c_int; + + pub fn gethostid() -> c_long; + + pub fn klogctl(syslog_type: c_int, bufp: *mut c_char, len: c_int) -> c_int; + + pub fn name_to_handle_at( + dirfd: c_int, + path: *const c_char, + handle: *mut file_handle, + mount_id: *mut c_int, + flags: c_int, + ) -> c_int; + pub fn open_by_handle_at(mount_fd: c_int, handle: *mut file_handle, flags: c_int) -> c_int; +} + +// LFS64 extensions +// +// * musl has 64-bit versions only so aliases the LFS64 symbols to the standard ones +cfg_if! { + if #[cfg(not(any(target_env = "musl", target_env = "ohos")))] { + extern "C" { + pub fn fallocate64(fd: c_int, mode: c_int, offset: off64_t, len: off64_t) -> c_int; + pub fn fgetpos64(stream: *mut crate::FILE, ptr: *mut crate::fpos64_t) -> c_int; + pub fn fopen64(filename: *const c_char, mode: *const c_char) -> *mut crate::FILE; + pub fn posix_fallocate64(fd: c_int, offset: off64_t, len: off64_t) -> c_int; + pub fn sendfile64( + out_fd: c_int, + in_fd: c_int, + offset: *mut off64_t, + count: size_t, + ) -> ssize_t; + pub fn tmpfile64() -> *mut crate::FILE; + } + } +} + +cfg_if! { + if #[cfg(target_env = "uclibc")] { + mod uclibc; + pub use self::uclibc::*; + } else if #[cfg(any(target_env = "musl", target_env = "ohos"))] { + mod musl; + pub use self::musl::*; + } else if #[cfg(target_env = "gnu")] { + mod gnu; + pub use self::gnu::*; + } +} + +mod arch; +pub use self::arch::*; diff --git a/http/vendor/libc/src/unix/linux_like/linux/musl/b32/arm/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/musl/b32/arm/mod.rs new file mode 100644 index 0000000..26d3380 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -0,0 +1,832 @@ +use crate::off_t; +use crate::prelude::*; + +pub type wchar_t = u32; + +pub type stat64 = stat; + +s! { + pub struct stat { + pub st_dev: crate::dev_t, + __st_dev_padding: Padding, + __st_ino_truncated: c_long, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + __st_rdev_padding: Padding, + pub st_size: off_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + + #[cfg(musl32_time64)] + __st_atim32: Padding<__c_anonymous_timespec32>, + #[cfg(musl32_time64)] + __st_mtim32: Padding<__c_anonymous_timespec32>, + #[cfg(musl32_time64)] + __st_ctim32: Padding<__c_anonymous_timespec32>, + + #[cfg(musl_v1_2_3)] + pub st_ino: crate::ino_t, + + pub st_atime: crate::time_t, + #[cfg(all(musl32_time64, target_endian = "big"))] + __pad0: Padding, + pub st_atime_nsec: c_long, + #[cfg(all(musl32_time64, target_endian = "little"))] + __pad0: Padding, + pub st_mtime: crate::time_t, + #[cfg(all(musl32_time64, target_endian = "big"))] + __pad1: Padding, + pub st_mtime_nsec: c_long, + #[cfg(all(musl32_time64, target_endian = "little"))] + __pad1: Padding, + pub st_ctime: crate::time_t, + #[cfg(all(musl32_time64, target_endian = "big"))] + __pad2: Padding, + pub st_ctime_nsec: c_long, + #[cfg(all(musl32_time64, target_endian = "little"))] + __pad2: Padding, + + #[cfg(not(musl_v1_2_3))] + pub st_ino: crate::ino_t, + } + + struct __c_anonymous_timespec32 { + __tv_sec: c_long, + __tv_nsec: c_long, + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_flags: c_int, + pub ss_size: size_t, + } + + pub struct ipc_perm { + #[cfg(musl_v1_2_3)] + pub __key: crate::key_t, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "This field is incorrectly named and will be changed + to __key in a future release." + )] + pub __ipc_perm_key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: crate::mode_t, + pub __seq: c_int, + __unused1: Padding, + __unused2: Padding, + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, + + #[cfg(musl32_time64)] + __shm_atime_lo: Padding, + #[cfg(musl32_time64)] + __shm_atime_hi: Padding, + #[cfg(musl32_time64)] + __shm_dtime_lo: Padding, + #[cfg(musl32_time64)] + __shm_dtime_hi: Padding, + #[cfg(musl32_time64)] + __msg_ctime_lo: Padding, + #[cfg(musl32_time64)] + __msg_ctime_hi: Padding, + + #[cfg(not(musl32_time64))] + pub shm_atime: crate::time_t, + #[cfg(not(musl32_time64))] + __unused1: Padding, + #[cfg(not(musl32_time64))] + pub shm_dtime: crate::time_t, + #[cfg(not(musl32_time64))] + __unused2: Padding, + #[cfg(not(musl32_time64))] + pub shm_ctime: crate::time_t, + #[cfg(not(musl32_time64))] + __unused3: Padding, + + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: c_ulong, + __pad1: Padding, + __pad2: Padding, + + #[cfg(musl32_time64)] + __pad3: c_ulong, + #[cfg(musl32_time64)] + shm_atime: crate::time_t, + #[cfg(musl32_time64)] + shm_dtime: crate::time_t, + #[cfg(musl32_time64)] + shm_ctime: crate::time_t, + } + + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + + #[cfg(musl32_time64)] + __msg_stime_lo: Padding, + #[cfg(musl32_time64)] + __msg_stime_hi: Padding, + #[cfg(musl32_time64)] + __msg_rtime_lo: Padding, + #[cfg(musl32_time64)] + __msg_rtime_hi: Padding, + #[cfg(musl32_time64)] + __msg_ctime_lo: Padding, + #[cfg(musl32_time64)] + __msg_ctime_hi: Padding, + + #[cfg(not(musl32_time64))] + pub msg_stime: crate::time_t, + #[cfg(not(musl32_time64))] + __unused1: Padding, + #[cfg(not(musl32_time64))] + pub msg_rtime: crate::time_t, + #[cfg(not(musl32_time64))] + __unused2: Padding, + #[cfg(not(musl32_time64))] + pub msg_ctime: crate::time_t, + #[cfg(not(musl32_time64))] + __unused3: Padding, + + pub __msg_cbytes: c_ulong, + pub msg_qnum: crate::msgqnum_t, + pub msg_qbytes: crate::msglen_t, + pub msg_lspid: crate::pid_t, + pub msg_lrpid: crate::pid_t, + __pad1: Padding, + __pad2: Padding, + + #[cfg(musl32_time64)] + pub msg_stime: crate::time_t, + #[cfg(musl32_time64)] + pub msg_rtime: crate::time_t, + #[cfg(musl32_time64)] + pub msg_ctime: crate::time_t, + } + + pub struct mcontext_t { + pub trap_no: c_ulong, + pub error_code: c_ulong, + pub oldmask: c_ulong, + pub arm_r0: c_ulong, + pub arm_r1: c_ulong, + pub arm_r2: c_ulong, + pub arm_r3: c_ulong, + pub arm_r4: c_ulong, + pub arm_r5: c_ulong, + pub arm_r6: c_ulong, + pub arm_r7: c_ulong, + pub arm_r8: c_ulong, + pub arm_r9: c_ulong, + pub arm_r10: c_ulong, + pub arm_fp: c_ulong, + pub arm_ip: c_ulong, + pub arm_sp: c_ulong, + pub arm_lr: c_ulong, + pub arm_pc: c_ulong, + pub arm_cpsr: c_ulong, + pub fault_address: c_ulong, + } + pub struct ucontext_t { + pub uc_flags: c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: crate::stack_t, + pub uc_mcontext: mcontext_t, + pub uc_sigmask: crate::sigset_t, + pub uc_regspace: [c_ulonglong; 64], + } +} + +s_no_extra_traits! { + #[repr(align(8))] + pub struct max_align_t { + priv_: (i64, i64), + } +} + +pub const SIGSTKSZ: size_t = 8192; +pub const MINSIGSTKSZ: size_t = 2048; + +pub const O_DIRECT: c_int = 0x10000; +pub const O_DIRECTORY: c_int = 0x4000; +pub const O_NOFOLLOW: c_int = 0x8000; +pub const O_ASYNC: c_int = 0x2000; +pub const O_LARGEFILE: c_int = 0o400000; + +pub const MADV_SOFT_OFFLINE: c_int = 101; +pub const MCL_CURRENT: c_int = 0x0001; +pub const MCL_FUTURE: c_int = 0x0002; +pub const MCL_ONFAULT: c_int = 0x0004; +pub const CBAUD: crate::tcflag_t = 0o0010017; +pub const TAB1: c_int = 0x00000800; +pub const TAB2: c_int = 0x00001000; +pub const TAB3: c_int = 0x00001800; +pub const CR1: c_int = 0x00000200; +pub const CR2: c_int = 0x00000400; +pub const CR3: c_int = 0x00000600; +pub const FF1: c_int = 0x00008000; +pub const BS1: c_int = 0x00002000; +pub const VT1: c_int = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: crate::tcflag_t = 0x00000400; +pub const IXOFF: crate::tcflag_t = 0x00001000; +pub const ONLCR: crate::tcflag_t = 0x4; +pub const CSIZE: crate::tcflag_t = 0x00000030; +pub const CS6: crate::tcflag_t = 0x00000010; +pub const CS7: crate::tcflag_t = 0x00000020; +pub const CS8: crate::tcflag_t = 0x00000030; +pub const CSTOPB: crate::tcflag_t = 0x00000040; +pub const CREAD: crate::tcflag_t = 0x00000080; +pub const PARENB: crate::tcflag_t = 0x00000100; +pub const PARODD: crate::tcflag_t = 0x00000200; +pub const HUPCL: crate::tcflag_t = 0x00000400; +pub const CLOCAL: crate::tcflag_t = 0x00000800; +pub const ECHOKE: crate::tcflag_t = 0x00000800; +pub const ECHOE: crate::tcflag_t = 0x00000010; +pub const ECHOK: crate::tcflag_t = 0x00000020; +pub const ECHONL: crate::tcflag_t = 0x00000040; +pub const ECHOPRT: crate::tcflag_t = 0x00000400; +pub const ECHOCTL: crate::tcflag_t = 0x00000200; +pub const ISIG: crate::tcflag_t = 0x00000001; +pub const ICANON: crate::tcflag_t = 0x00000002; +pub const PENDIN: crate::tcflag_t = 0x00004000; +pub const NOFLSH: crate::tcflag_t = 0x00000080; +pub const CIBAUD: crate::tcflag_t = 0o02003600000; +pub const CBAUDEX: crate::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: crate::tcflag_t = 0o000002; +pub const NLDLY: crate::tcflag_t = 0o000400; +pub const CRDLY: crate::tcflag_t = 0o003000; +pub const TABDLY: crate::tcflag_t = 0o014000; +pub const BSDLY: crate::tcflag_t = 0o020000; +pub const FFDLY: crate::tcflag_t = 0o100000; +pub const VTDLY: crate::tcflag_t = 0o040000; +pub const XTABS: crate::tcflag_t = 0o014000; +pub const B57600: crate::speed_t = 0o010001; +pub const B115200: crate::speed_t = 0o010002; +pub const B230400: crate::speed_t = 0o010003; +pub const B460800: crate::speed_t = 0o010004; +pub const B500000: crate::speed_t = 0o010005; +pub const B576000: crate::speed_t = 0o010006; +pub const B921600: crate::speed_t = 0o010007; +pub const B1000000: crate::speed_t = 0o010010; +pub const B1152000: crate::speed_t = 0o010011; +pub const B1500000: crate::speed_t = 0o010012; +pub const B2000000: crate::speed_t = 0o010013; +pub const B2500000: crate::speed_t = 0o010014; +pub const B3000000: crate::speed_t = 0o010015; +pub const B3500000: crate::speed_t = 0o010016; +pub const B4000000: crate::speed_t = 0o010017; + +pub const O_APPEND: c_int = 1024; +pub const O_CREAT: c_int = 64; +pub const O_EXCL: c_int = 128; +pub const O_NOCTTY: c_int = 256; +pub const O_NONBLOCK: c_int = 2048; +pub const O_SYNC: c_int = 1052672; +pub const O_RSYNC: c_int = 1052672; +pub const O_DSYNC: c_int = 4096; + +pub const MAP_ANON: c_int = 0x0020; +pub const MAP_GROWSDOWN: c_int = 0x0100; +pub const MAP_DENYWRITE: c_int = 0x0800; +pub const MAP_EXECUTABLE: c_int = 0x01000; +pub const MAP_LOCKED: c_int = 0x02000; +pub const MAP_NORESERVE: c_int = 0x04000; +pub const MAP_POPULATE: c_int = 0x08000; +pub const MAP_NONBLOCK: c_int = 0x010000; +pub const MAP_STACK: c_int = 0x020000; +pub const MAP_SYNC: c_int = 0x080000; + +pub const EDEADLK: c_int = 35; +pub const ENAMETOOLONG: c_int = 36; +pub const ENOLCK: c_int = 37; +pub const ENOSYS: c_int = 38; +pub const ENOTEMPTY: c_int = 39; +pub const ELOOP: c_int = 40; +pub const ENOMSG: c_int = 42; +pub const EIDRM: c_int = 43; +pub const ECHRNG: c_int = 44; +pub const EL2NSYNC: c_int = 45; +pub const EL3HLT: c_int = 46; +pub const EL3RST: c_int = 47; +pub const ELNRNG: c_int = 48; +pub const EUNATCH: c_int = 49; +pub const ENOCSI: c_int = 50; +pub const EL2HLT: c_int = 51; +pub const EBADE: c_int = 52; +pub const EBADR: c_int = 53; +pub const EXFULL: c_int = 54; +pub const ENOANO: c_int = 55; +pub const EBADRQC: c_int = 56; +pub const EBADSLT: c_int = 57; +pub const EDEADLOCK: c_int = EDEADLK; +pub const EMULTIHOP: c_int = 72; +pub const EBADMSG: c_int = 74; +pub const EOVERFLOW: c_int = 75; +pub const ENOTUNIQ: c_int = 76; +pub const EBADFD: c_int = 77; +pub const EREMCHG: c_int = 78; +pub const ELIBACC: c_int = 79; +pub const ELIBBAD: c_int = 80; +pub const ELIBSCN: c_int = 81; +pub const ELIBMAX: c_int = 82; +pub const ELIBEXEC: c_int = 83; +pub const EILSEQ: c_int = 84; +pub const ERESTART: c_int = 85; +pub const ESTRPIPE: c_int = 86; +pub const EUSERS: c_int = 87; +pub const ENOTSOCK: c_int = 88; +pub const EDESTADDRREQ: c_int = 89; +pub const EMSGSIZE: c_int = 90; +pub const EPROTOTYPE: c_int = 91; +pub const ENOPROTOOPT: c_int = 92; +pub const EPROTONOSUPPORT: c_int = 93; +pub const ESOCKTNOSUPPORT: c_int = 94; +pub const EOPNOTSUPP: c_int = 95; +pub const ENOTSUP: c_int = EOPNOTSUPP; +pub const EPFNOSUPPORT: c_int = 96; +pub const EAFNOSUPPORT: c_int = 97; +pub const EADDRINUSE: c_int = 98; +pub const EADDRNOTAVAIL: c_int = 99; +pub const ENETDOWN: c_int = 100; +pub const ENETUNREACH: c_int = 101; +pub const ENETRESET: c_int = 102; +pub const ECONNABORTED: c_int = 103; +pub const ECONNRESET: c_int = 104; +pub const ENOBUFS: c_int = 105; +pub const EISCONN: c_int = 106; +pub const ENOTCONN: c_int = 107; +pub const ESHUTDOWN: c_int = 108; +pub const ETOOMANYREFS: c_int = 109; +pub const ETIMEDOUT: c_int = 110; +pub const ECONNREFUSED: c_int = 111; +pub const EHOSTDOWN: c_int = 112; +pub const EHOSTUNREACH: c_int = 113; +pub const EALREADY: c_int = 114; +pub const EINPROGRESS: c_int = 115; +pub const ESTALE: c_int = 116; +pub const EUCLEAN: c_int = 117; +pub const ENOTNAM: c_int = 118; +pub const ENAVAIL: c_int = 119; +pub const EISNAM: c_int = 120; +pub const EREMOTEIO: c_int = 121; +pub const EDQUOT: c_int = 122; +pub const ENOMEDIUM: c_int = 123; +pub const EMEDIUMTYPE: c_int = 124; +pub const ECANCELED: c_int = 125; +pub const ENOKEY: c_int = 126; +pub const EKEYEXPIRED: c_int = 127; +pub const EKEYREVOKED: c_int = 128; +pub const EKEYREJECTED: c_int = 129; +pub const EOWNERDEAD: c_int = 130; +pub const ENOTRECOVERABLE: c_int = 131; +pub const ERFKILL: c_int = 132; +pub const EHWPOISON: c_int = 133; + +pub const SA_ONSTACK: c_int = 0x08000000; +pub const SA_SIGINFO: c_int = 0x00000004; +pub const SA_NOCLDWAIT: c_int = 0x00000002; + +pub const SIGCHLD: c_int = 17; +pub const SIGBUS: c_int = 7; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGUSR1: c_int = 10; +pub const SIGUSR2: c_int = 12; +pub const SIGCONT: c_int = 18; +pub const SIGSTOP: c_int = 19; +pub const SIGTSTP: c_int = 20; +pub const SIGURG: c_int = 23; +pub const SIGIO: c_int = 29; +pub const SIGSYS: c_int = 31; +pub const SIGSTKFLT: c_int = 16; +pub const SIGPOLL: c_int = 29; +pub const SIGPWR: c_int = 30; +pub const SIG_SETMASK: c_int = 2; +pub const SIG_BLOCK: c_int = 0x000000; +pub const SIG_UNBLOCK: c_int = 0x01; + +pub const EXTPROC: crate::tcflag_t = 0x00010000; + +pub const MAP_HUGETLB: c_int = 0x040000; + +pub const F_GETLK: c_int = 12; +pub const F_GETOWN: c_int = 9; +pub const F_SETLK: c_int = 13; +pub const F_SETLKW: c_int = 14; +pub const F_SETOWN: c_int = 8; + +pub const VEOF: usize = 4; +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: crate::tcflag_t = 0x00008000; +pub const TOSTOP: crate::tcflag_t = 0x00000100; +pub const FLUSHO: crate::tcflag_t = 0x00001000; + +pub const POLLWRNORM: c_short = 0x100; +pub const POLLWRBAND: c_short = 0x200; + +// Syscall table +pub const SYS_restart_syscall: c_long = 0; +pub const SYS_exit: c_long = 1; +pub const SYS_fork: c_long = 2; +pub const SYS_read: c_long = 3; +pub const SYS_write: c_long = 4; +pub const SYS_open: c_long = 5; +pub const SYS_close: c_long = 6; +pub const SYS_creat: c_long = 8; +pub const SYS_link: c_long = 9; +pub const SYS_unlink: c_long = 10; +pub const SYS_execve: c_long = 11; +pub const SYS_chdir: c_long = 12; +pub const SYS_mknod: c_long = 14; +pub const SYS_chmod: c_long = 15; +pub const SYS_lchown: c_long = 16; +pub const SYS_lseek: c_long = 19; +pub const SYS_getpid: c_long = 20; +pub const SYS_mount: c_long = 21; +pub const SYS_setuid: c_long = 23; +pub const SYS_getuid: c_long = 24; +pub const SYS_ptrace: c_long = 26; +pub const SYS_pause: c_long = 29; +pub const SYS_access: c_long = 33; +pub const SYS_nice: c_long = 34; +pub const SYS_sync: c_long = 36; +pub const SYS_kill: c_long = 37; +pub const SYS_rename: c_long = 38; +pub const SYS_mkdir: c_long = 39; +pub const SYS_rmdir: c_long = 40; +pub const SYS_dup: c_long = 41; +pub const SYS_pipe: c_long = 42; +pub const SYS_times: c_long = 43; +pub const SYS_brk: c_long = 45; +pub const SYS_setgid: c_long = 46; +pub const SYS_getgid: c_long = 47; +pub const SYS_geteuid: c_long = 49; +pub const SYS_getegid: c_long = 50; +pub const SYS_acct: c_long = 51; +pub const SYS_umount2: c_long = 52; +pub const SYS_ioctl: c_long = 54; +pub const SYS_fcntl: c_long = 55; +pub const SYS_setpgid: c_long = 57; +pub const SYS_umask: c_long = 60; +pub const SYS_chroot: c_long = 61; +pub const SYS_ustat: c_long = 62; +pub const SYS_dup2: c_long = 63; +pub const SYS_getppid: c_long = 64; +pub const SYS_getpgrp: c_long = 65; +pub const SYS_setsid: c_long = 66; +pub const SYS_sigaction: c_long = 67; +pub const SYS_setreuid: c_long = 70; +pub const SYS_setregid: c_long = 71; +pub const SYS_sigsuspend: c_long = 72; +pub const SYS_sigpending: c_long = 73; +pub const SYS_sethostname: c_long = 74; +pub const SYS_setrlimit: c_long = 75; +pub const SYS_getrusage: c_long = 77; +pub const SYS_gettimeofday: c_long = 78; +pub const SYS_settimeofday: c_long = 79; +pub const SYS_getgroups: c_long = 80; +pub const SYS_setgroups: c_long = 81; +pub const SYS_symlink: c_long = 83; +pub const SYS_readlink: c_long = 85; +pub const SYS_uselib: c_long = 86; +pub const SYS_swapon: c_long = 87; +pub const SYS_reboot: c_long = 88; +pub const SYS_munmap: c_long = 91; +pub const SYS_truncate: c_long = 92; +pub const SYS_ftruncate: c_long = 93; +pub const SYS_fchmod: c_long = 94; +pub const SYS_fchown: c_long = 95; +pub const SYS_getpriority: c_long = 96; +pub const SYS_setpriority: c_long = 97; +pub const SYS_statfs: c_long = 99; +pub const SYS_fstatfs: c_long = 100; +pub const SYS_syslog: c_long = 103; +pub const SYS_setitimer: c_long = 104; +pub const SYS_getitimer: c_long = 105; +pub const SYS_stat: c_long = 106; +pub const SYS_lstat: c_long = 107; +pub const SYS_fstat: c_long = 108; +pub const SYS_vhangup: c_long = 111; +pub const SYS_wait4: c_long = 114; +pub const SYS_swapoff: c_long = 115; +pub const SYS_sysinfo: c_long = 116; +pub const SYS_fsync: c_long = 118; +pub const SYS_sigreturn: c_long = 119; +pub const SYS_clone: c_long = 120; +pub const SYS_setdomainname: c_long = 121; +pub const SYS_uname: c_long = 122; +pub const SYS_adjtimex: c_long = 124; +pub const SYS_mprotect: c_long = 125; +pub const SYS_sigprocmask: c_long = 126; +pub const SYS_init_module: c_long = 128; +pub const SYS_delete_module: c_long = 129; +pub const SYS_quotactl: c_long = 131; +pub const SYS_getpgid: c_long = 132; +pub const SYS_fchdir: c_long = 133; +pub const SYS_bdflush: c_long = 134; +pub const SYS_sysfs: c_long = 135; +pub const SYS_personality: c_long = 136; +pub const SYS_setfsuid: c_long = 138; +pub const SYS_setfsgid: c_long = 139; +pub const SYS__llseek: c_long = 140; +pub const SYS_getdents: c_long = 141; +pub const SYS__newselect: c_long = 142; +pub const SYS_flock: c_long = 143; +pub const SYS_msync: c_long = 144; +pub const SYS_readv: c_long = 145; +pub const SYS_writev: c_long = 146; +pub const SYS_getsid: c_long = 147; +pub const SYS_fdatasync: c_long = 148; +pub const SYS__sysctl: c_long = 149; +pub const SYS_mlock: c_long = 150; +pub const SYS_munlock: c_long = 151; +pub const SYS_mlockall: c_long = 152; +pub const SYS_munlockall: c_long = 153; +pub const SYS_sched_setparam: c_long = 154; +pub const SYS_sched_getparam: c_long = 155; +pub const SYS_sched_setscheduler: c_long = 156; +pub const SYS_sched_getscheduler: c_long = 157; +pub const SYS_sched_yield: c_long = 158; +pub const SYS_sched_get_priority_max: c_long = 159; +pub const SYS_sched_get_priority_min: c_long = 160; +pub const SYS_sched_rr_get_interval: c_long = 161; +pub const SYS_nanosleep: c_long = 162; +pub const SYS_mremap: c_long = 163; +pub const SYS_setresuid: c_long = 164; +pub const SYS_getresuid: c_long = 165; +pub const SYS_poll: c_long = 168; +pub const SYS_nfsservctl: c_long = 169; +pub const SYS_setresgid: c_long = 170; +pub const SYS_getresgid: c_long = 171; +pub const SYS_prctl: c_long = 172; +pub const SYS_rt_sigreturn: c_long = 173; +pub const SYS_rt_sigaction: c_long = 174; +pub const SYS_rt_sigprocmask: c_long = 175; +pub const SYS_rt_sigpending: c_long = 176; +pub const SYS_rt_sigtimedwait: c_long = 177; +pub const SYS_rt_sigqueueinfo: c_long = 178; +pub const SYS_rt_sigsuspend: c_long = 179; +pub const SYS_pread64: c_long = 180; +pub const SYS_pwrite64: c_long = 181; +pub const SYS_chown: c_long = 182; +pub const SYS_getcwd: c_long = 183; +pub const SYS_capget: c_long = 184; +pub const SYS_capset: c_long = 185; +pub const SYS_sigaltstack: c_long = 186; +pub const SYS_sendfile: c_long = 187; +pub const SYS_vfork: c_long = 190; +pub const SYS_ugetrlimit: c_long = 191; +pub const SYS_mmap2: c_long = 192; +pub const SYS_truncate64: c_long = 193; +pub const SYS_ftruncate64: c_long = 194; +pub const SYS_stat64: c_long = 195; +pub const SYS_lstat64: c_long = 196; +pub const SYS_fstat64: c_long = 197; +pub const SYS_lchown32: c_long = 198; +pub const SYS_getuid32: c_long = 199; +pub const SYS_getgid32: c_long = 200; +pub const SYS_geteuid32: c_long = 201; +pub const SYS_getegid32: c_long = 202; +pub const SYS_setreuid32: c_long = 203; +pub const SYS_setregid32: c_long = 204; +pub const SYS_getgroups32: c_long = 205; +pub const SYS_setgroups32: c_long = 206; +pub const SYS_fchown32: c_long = 207; +pub const SYS_setresuid32: c_long = 208; +pub const SYS_getresuid32: c_long = 209; +pub const SYS_setresgid32: c_long = 210; +pub const SYS_getresgid32: c_long = 211; +pub const SYS_chown32: c_long = 212; +pub const SYS_setuid32: c_long = 213; +pub const SYS_setgid32: c_long = 214; +pub const SYS_setfsuid32: c_long = 215; +pub const SYS_setfsgid32: c_long = 216; +pub const SYS_getdents64: c_long = 217; +pub const SYS_pivot_root: c_long = 218; +pub const SYS_mincore: c_long = 219; +pub const SYS_madvise: c_long = 220; +pub const SYS_fcntl64: c_long = 221; +pub const SYS_gettid: c_long = 224; +pub const SYS_readahead: c_long = 225; +pub const SYS_setxattr: c_long = 226; +pub const SYS_lsetxattr: c_long = 227; +pub const SYS_fsetxattr: c_long = 228; +pub const SYS_getxattr: c_long = 229; +pub const SYS_lgetxattr: c_long = 230; +pub const SYS_fgetxattr: c_long = 231; +pub const SYS_listxattr: c_long = 232; +pub const SYS_llistxattr: c_long = 233; +pub const SYS_flistxattr: c_long = 234; +pub const SYS_removexattr: c_long = 235; +pub const SYS_lremovexattr: c_long = 236; +pub const SYS_fremovexattr: c_long = 237; +pub const SYS_tkill: c_long = 238; +pub const SYS_sendfile64: c_long = 239; +pub const SYS_futex: c_long = 240; +pub const SYS_sched_setaffinity: c_long = 241; +pub const SYS_sched_getaffinity: c_long = 242; +pub const SYS_io_setup: c_long = 243; +pub const SYS_io_destroy: c_long = 244; +pub const SYS_io_getevents: c_long = 245; +pub const SYS_io_submit: c_long = 246; +pub const SYS_io_cancel: c_long = 247; +pub const SYS_exit_group: c_long = 248; +pub const SYS_lookup_dcookie: c_long = 249; +pub const SYS_epoll_create: c_long = 250; +pub const SYS_epoll_ctl: c_long = 251; +pub const SYS_epoll_wait: c_long = 252; +pub const SYS_remap_file_pages: c_long = 253; +pub const SYS_set_tid_address: c_long = 256; +pub const SYS_timer_create: c_long = 257; +pub const SYS_timer_settime: c_long = 258; +pub const SYS_timer_gettime: c_long = 259; +pub const SYS_timer_getoverrun: c_long = 260; +pub const SYS_timer_delete: c_long = 261; +pub const SYS_clock_settime: c_long = 262; +pub const SYS_clock_gettime: c_long = 263; +pub const SYS_clock_getres: c_long = 264; +pub const SYS_clock_nanosleep: c_long = 265; +pub const SYS_statfs64: c_long = 266; +pub const SYS_fstatfs64: c_long = 267; +pub const SYS_tgkill: c_long = 268; +pub const SYS_utimes: c_long = 269; +pub const SYS_pciconfig_iobase: c_long = 271; +pub const SYS_pciconfig_read: c_long = 272; +pub const SYS_pciconfig_write: c_long = 273; +pub const SYS_mq_open: c_long = 274; +pub const SYS_mq_unlink: c_long = 275; +pub const SYS_mq_timedsend: c_long = 276; +pub const SYS_mq_timedreceive: c_long = 277; +pub const SYS_mq_notify: c_long = 278; +pub const SYS_mq_getsetattr: c_long = 279; +pub const SYS_waitid: c_long = 280; +pub const SYS_socket: c_long = 281; +pub const SYS_bind: c_long = 282; +pub const SYS_connect: c_long = 283; +pub const SYS_listen: c_long = 284; +pub const SYS_accept: c_long = 285; +pub const SYS_getsockname: c_long = 286; +pub const SYS_getpeername: c_long = 287; +pub const SYS_socketpair: c_long = 288; +pub const SYS_send: c_long = 289; +pub const SYS_sendto: c_long = 290; +pub const SYS_recv: c_long = 291; +pub const SYS_recvfrom: c_long = 292; +pub const SYS_shutdown: c_long = 293; +pub const SYS_setsockopt: c_long = 294; +pub const SYS_getsockopt: c_long = 295; +pub const SYS_sendmsg: c_long = 296; +pub const SYS_recvmsg: c_long = 297; +pub const SYS_semop: c_long = 298; +pub const SYS_semget: c_long = 299; +pub const SYS_semctl: c_long = 300; +pub const SYS_msgsnd: c_long = 301; +pub const SYS_msgrcv: c_long = 302; +pub const SYS_msgget: c_long = 303; +pub const SYS_msgctl: c_long = 304; +pub const SYS_shmat: c_long = 305; +pub const SYS_shmdt: c_long = 306; +pub const SYS_shmget: c_long = 307; +pub const SYS_shmctl: c_long = 308; +pub const SYS_add_key: c_long = 309; +pub const SYS_request_key: c_long = 310; +pub const SYS_keyctl: c_long = 311; +pub const SYS_semtimedop: c_long = 312; +pub const SYS_vserver: c_long = 313; +pub const SYS_ioprio_set: c_long = 314; +pub const SYS_ioprio_get: c_long = 315; +pub const SYS_inotify_init: c_long = 316; +pub const SYS_inotify_add_watch: c_long = 317; +pub const SYS_inotify_rm_watch: c_long = 318; +pub const SYS_mbind: c_long = 319; +pub const SYS_get_mempolicy: c_long = 320; +pub const SYS_set_mempolicy: c_long = 321; +pub const SYS_openat: c_long = 322; +pub const SYS_mkdirat: c_long = 323; +pub const SYS_mknodat: c_long = 324; +pub const SYS_fchownat: c_long = 325; +pub const SYS_futimesat: c_long = 326; +pub const SYS_fstatat64: c_long = 327; +pub const SYS_unlinkat: c_long = 328; +pub const SYS_renameat: c_long = 329; +pub const SYS_linkat: c_long = 330; +pub const SYS_symlinkat: c_long = 331; +pub const SYS_readlinkat: c_long = 332; +pub const SYS_fchmodat: c_long = 333; +pub const SYS_faccessat: c_long = 334; +pub const SYS_pselect6: c_long = 335; +pub const SYS_ppoll: c_long = 336; +pub const SYS_unshare: c_long = 337; +pub const SYS_set_robust_list: c_long = 338; +pub const SYS_get_robust_list: c_long = 339; +pub const SYS_splice: c_long = 340; +pub const SYS_tee: c_long = 342; +pub const SYS_vmsplice: c_long = 343; +pub const SYS_move_pages: c_long = 344; +pub const SYS_getcpu: c_long = 345; +pub const SYS_epoll_pwait: c_long = 346; +pub const SYS_kexec_load: c_long = 347; +pub const SYS_utimensat: c_long = 348; +pub const SYS_signalfd: c_long = 349; +pub const SYS_timerfd_create: c_long = 350; +pub const SYS_eventfd: c_long = 351; +pub const SYS_fallocate: c_long = 352; +pub const SYS_timerfd_settime: c_long = 353; +pub const SYS_timerfd_gettime: c_long = 354; +pub const SYS_signalfd4: c_long = 355; +pub const SYS_eventfd2: c_long = 356; +pub const SYS_epoll_create1: c_long = 357; +pub const SYS_dup3: c_long = 358; +pub const SYS_pipe2: c_long = 359; +pub const SYS_inotify_init1: c_long = 360; +pub const SYS_preadv: c_long = 361; +pub const SYS_pwritev: c_long = 362; +pub const SYS_rt_tgsigqueueinfo: c_long = 363; +pub const SYS_perf_event_open: c_long = 364; +pub const SYS_recvmmsg: c_long = 365; +pub const SYS_accept4: c_long = 366; +pub const SYS_fanotify_init: c_long = 367; +pub const SYS_fanotify_mark: c_long = 368; +pub const SYS_prlimit64: c_long = 369; +pub const SYS_name_to_handle_at: c_long = 370; +pub const SYS_open_by_handle_at: c_long = 371; +pub const SYS_clock_adjtime: c_long = 372; +pub const SYS_syncfs: c_long = 373; +pub const SYS_sendmmsg: c_long = 374; +pub const SYS_setns: c_long = 375; +pub const SYS_process_vm_readv: c_long = 376; +pub const SYS_process_vm_writev: c_long = 377; +pub const SYS_kcmp: c_long = 378; +pub const SYS_finit_module: c_long = 379; +pub const SYS_sched_setattr: c_long = 380; +pub const SYS_sched_getattr: c_long = 381; +pub const SYS_renameat2: c_long = 382; +pub const SYS_seccomp: c_long = 383; +pub const SYS_getrandom: c_long = 384; +pub const SYS_memfd_create: c_long = 385; +pub const SYS_bpf: c_long = 386; +pub const SYS_execveat: c_long = 387; +pub const SYS_userfaultfd: c_long = 388; +pub const SYS_membarrier: c_long = 389; +pub const SYS_mlock2: c_long = 390; +pub const SYS_copy_file_range: c_long = 391; +pub const SYS_preadv2: c_long = 392; +pub const SYS_pwritev2: c_long = 393; +pub const SYS_pkey_mprotect: c_long = 394; +pub const SYS_pkey_alloc: c_long = 395; +pub const SYS_pkey_free: c_long = 396; +pub const SYS_statx: c_long = 397; +pub const SYS_pidfd_send_signal: c_long = 424; +pub const SYS_io_uring_setup: c_long = 425; +pub const SYS_io_uring_enter: c_long = 426; +pub const SYS_io_uring_register: c_long = 427; +pub const SYS_open_tree: c_long = 428; +pub const SYS_move_mount: c_long = 429; +pub const SYS_fsopen: c_long = 430; +pub const SYS_fsconfig: c_long = 431; +pub const SYS_fsmount: c_long = 432; +pub const SYS_fspick: c_long = 433; +pub const SYS_pidfd_open: c_long = 434; +pub const SYS_clone3: c_long = 435; +pub const SYS_close_range: c_long = 436; +pub const SYS_openat2: c_long = 437; +pub const SYS_pidfd_getfd: c_long = 438; +pub const SYS_faccessat2: c_long = 439; +pub const SYS_process_madvise: c_long = 440; +pub const SYS_epoll_pwait2: c_long = 441; +pub const SYS_mount_setattr: c_long = 442; +pub const SYS_quotactl_fd: c_long = 443; +pub const SYS_landlock_create_ruleset: c_long = 444; +pub const SYS_landlock_add_rule: c_long = 445; +pub const SYS_landlock_restrict_self: c_long = 446; +pub const SYS_memfd_secret: c_long = 447; +pub const SYS_process_mrelease: c_long = 448; +pub const SYS_futex_waitv: c_long = 449; +pub const SYS_set_mempolicy_home_node: c_long = 450; +pub const SYS_mseal: c_long = 462; diff --git a/http/vendor/libc/src/unix/linux_like/linux/musl/b32/hexagon.rs b/http/vendor/libc/src/unix/linux_like/linux/musl/b32/hexagon.rs new file mode 100644 index 0000000..fa5ebf3 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/musl/b32/hexagon.rs @@ -0,0 +1,719 @@ +use crate::prelude::*; + +pub type wchar_t = u32; +pub type stat64 = crate::stat; + +s! { + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: c_ulonglong, + pub st_mode: c_uint, + pub st_nlink: c_uint, + pub st_uid: c_uint, + pub st_gid: c_uint, + pub st_rdev: c_ulonglong, + __st_rdev_padding: Padding, + pub st_size: c_longlong, + pub st_blksize: crate::blksize_t, + __st_blksize_padding: Padding, + pub st_blocks: crate::blkcnt_t, + + pub st_atime: crate::time_t, + #[cfg(all(musl32_time64, target_endian = "big"))] + __pad0: Padding, + pub st_atime_nsec: c_long, + #[cfg(all(musl32_time64, target_endian = "little"))] + __pad0: Padding, + pub st_mtime: crate::time_t, + #[cfg(all(musl32_time64, target_endian = "big"))] + __pad1: Padding, + pub st_mtime_nsec: c_long, + #[cfg(all(musl32_time64, target_endian = "little"))] + __pad1: Padding, + pub st_ctime: crate::time_t, + #[cfg(all(musl32_time64, target_endian = "big"))] + __pad2: Padding, + pub st_ctime_nsec: c_long, + #[cfg(all(musl32_time64, target_endian = "little"))] + __pad2: Padding, + + __unused: Padding<[c_int; 2]>, + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_flags: c_int, + pub ss_size: size_t, + } + + pub struct ipc_perm { + #[cfg(musl_v1_2_3)] + pub __key: crate::key_t, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "This field is incorrectly named and will be changed + to __key in a future release" + )] + pub __ipc_perm_key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: crate::mode_t, + pub __seq: c_int, + __pad1: Padding, + __pad2: Padding, + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, + pub shm_atime: crate::time_t, + __unused1: Padding, + pub shm_dtime: crate::time_t, + __unused2: Padding, + pub shm_ctime: crate::time_t, + __unused3: Padding, + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: c_ulong, + __pad1: Padding, + __pad2: Padding, + } + + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + pub msg_stime: crate::time_t, + __unused1: Padding, + pub msg_rtime: crate::time_t, + __unused2: Padding, + pub msg_ctime: crate::time_t, + __unused3: Padding, + pub __msg_cbytes: c_ulong, + pub msg_qnum: crate::msgqnum_t, + pub msg_qbytes: crate::msglen_t, + pub msg_lspid: crate::pid_t, + pub msg_lrpid: crate::pid_t, + __pad1: Padding, + __pad2: Padding, + } +} + +pub const AF_FILE: c_int = 1; +pub const AF_KCM: c_int = 41; +pub const AF_MAX: c_int = 43; +pub const AF_QIPCRTR: c_int = 42; +pub const EADDRINUSE: c_int = 98; +pub const EADDRNOTAVAIL: c_int = 99; +pub const EAFNOSUPPORT: c_int = 97; +pub const EALREADY: c_int = 114; +pub const EBADE: c_int = 52; +pub const EBADFD: c_int = 77; +pub const EBADMSG: c_int = 74; +pub const EBADR: c_int = 53; +pub const EBADRQC: c_int = 56; +pub const EBADSLT: c_int = 57; +pub const ECANCELED: c_int = 125; +pub const ECHRNG: c_int = 44; +pub const ECONNABORTED: c_int = 103; +pub const ECONNREFUSED: c_int = 111; +pub const ECONNRESET: c_int = 104; +pub const EDEADLK: c_int = 35; +pub const EDEADLOCK: c_int = 35; +pub const EDESTADDRREQ: c_int = 89; +pub const EDQUOT: c_int = 122; +pub const EHOSTDOWN: c_int = 112; +pub const EHOSTUNREACH: c_int = 113; +pub const EHWPOISON: c_int = 133; +pub const EIDRM: c_int = 43; +pub const EILSEQ: c_int = 84; +pub const EINPROGRESS: c_int = 115; +pub const EISCONN: c_int = 106; +pub const EISNAM: c_int = 120; +pub const EKEYEXPIRED: c_int = 127; +pub const EKEYREJECTED: c_int = 129; +pub const EKEYREVOKED: c_int = 128; +pub const EL2HLT: c_int = 51; +pub const EL2NSYNC: c_int = 45; +pub const EL3HLT: c_int = 46; +pub const EL3RST: c_int = 47; +pub const ELIBACC: c_int = 79; +pub const ELIBBAD: c_int = 80; +pub const ELIBEXEC: c_int = 83; +pub const ELIBMAX: c_int = 82; +pub const ELIBSCN: c_int = 81; +pub const ELNRNG: c_int = 48; +pub const ELOOP: c_int = 40; +pub const EMEDIUMTYPE: c_int = 124; +pub const EMSGSIZE: c_int = 90; +pub const EMULTIHOP: c_int = 72; +pub const ENAMETOOLONG: c_int = 36; +pub const ENAVAIL: c_int = 119; +pub const ENETDOWN: c_int = 100; +pub const ENETRESET: c_int = 102; +pub const ENETUNREACH: c_int = 101; +pub const ENOANO: c_int = 55; +pub const ENOBUFS: c_int = 105; +pub const ENOCSI: c_int = 50; +pub const ENOKEY: c_int = 126; +pub const ENOLCK: c_int = 37; +pub const ENOMEDIUM: c_int = 123; +pub const ENOMSG: c_int = 42; +pub const ENOPROTOOPT: c_int = 92; +pub const ENOSYS: c_int = 38; +pub const ENOTCONN: c_int = 107; +pub const ENOTEMPTY: c_int = 39; +pub const ENOTNAM: c_int = 118; +pub const ENOTRECOVERABLE: c_int = 131; +pub const ENOTSOCK: c_int = 88; +pub const ENOTSUP: c_int = 95; +pub const ENOTUNIQ: c_int = 76; +pub const EOPNOTSUPP: c_int = 95; +pub const EOVERFLOW: c_int = 75; +pub const EOWNERDEAD: c_int = 130; +pub const EPFNOSUPPORT: c_int = 96; +pub const EPROTOTYPE: c_int = 91; +pub const EPROTONOSUPPORT: c_int = 93; +pub const EREMCHG: c_int = 78; +pub const ERESTART: c_int = 85; +pub const EREMOTEIO: c_int = 121; +pub const ERFKILL: c_int = 132; +pub const ESHUTDOWN: c_int = 108; +pub const ESOCKTNOSUPPORT: c_int = 94; +pub const ESTALE: c_int = 116; +pub const ESTRPIPE: c_int = 86; +pub const ETOOMANYREFS: c_int = 109; +pub const ETIMEDOUT: c_int = 110; +pub const EUCLEAN: c_int = 117; +pub const EUNATCH: c_int = 49; +pub const EUSERS: c_int = 87; +pub const EXFULL: c_int = 54; +pub const EXTPROC: crate::tcflag_t = 65536; +pub const F_EXLCK: c_int = 4; +pub const F_GETLK: c_int = 12; +pub const F_GETOWN: c_int = 9; +pub const F_GETOWNER_UIDS: c_int = 17; +pub const F_GETOWN_EX: c_int = 16; +pub const F_GETSIG: c_int = 11; +pub const F_LINUX_SPECIFIC_BASE: c_int = 1024; +pub const FLUSHO: crate::tcflag_t = 4096; +pub const F_OWNER_PGRP: c_int = 2; +pub const F_OWNER_PID: c_int = 1; +pub const F_OWNER_TID: c_int = 0; +pub const F_SETLK: c_int = 13; +pub const F_SETLKW: c_int = 14; +pub const F_SETOWN: c_int = 8; +pub const F_SETOWN_EX: c_int = 15; +pub const F_SETSIG: c_int = 10; +pub const F_SHLCK: c_int = 8; +pub const IEXTEN: crate::tcflag_t = 32768; +pub const MAP_ANON: c_int = 32; +pub const MAP_DENYWRITE: c_int = 2048; +pub const MAP_EXECUTABLE: c_int = 4096; +pub const MAP_GROWSDOWN: c_int = 256; +pub const MAP_HUGETLB: c_int = 262144; +pub const MAP_LOCKED: c_int = 8192; +pub const MAP_NONBLOCK: c_int = 65536; +pub const MAP_NORESERVE: c_int = 16384; +pub const MAP_POPULATE: c_int = 32768; +pub const MAP_STACK: c_int = 131072; +pub const MAP_SYNC: c_int = 0x080000; +pub const MAP_UNINITIALIZED: c_int = 0; +pub const O_APPEND: c_int = 1024; +pub const O_ASYNC: c_int = 8192; +pub const O_CREAT: c_int = 64; +pub const O_DIRECT: c_int = 16384; +pub const O_DIRECTORY: c_int = 65536; +pub const O_DSYNC: c_int = 4096; +pub const O_EXCL: c_int = 128; +pub const O_LARGEFILE: c_int = 32768; +pub const O_NOCTTY: c_int = 256; +pub const O_NOFOLLOW: c_int = 131072; +pub const O_NONBLOCK: c_int = 2048; +pub const O_SYNC: c_int = 1052672; +pub const O_RSYNC: c_int = 1052672; +pub const PF_FILE: c_int = 1; +pub const PF_KCM: c_int = 41; +pub const PF_MAX: c_int = 43; +pub const PF_QIPCRTR: c_int = 42; +pub const SA_ONSTACK: c_int = 0x08000000; +pub const SA_SIGINFO: c_int = 0x00000004; +pub const SA_NOCLDWAIT: c_int = 0x00000002; +pub const SIGBUS: c_int = 7; +pub const SIGCHLD: c_int = 17; +pub const SIGCONT: c_int = 18; +pub const SIGIO: c_int = 29; +pub const SIGPOLL: c_int = 29; +pub const SIGPROF: c_int = 27; +pub const SIGPWR: c_int = 30; +pub const SIGSTKFLT: c_int = 16; +pub const SIGSTKSZ: size_t = 8192; +pub const MINSIGSTKSZ: size_t = 2048; +pub const SIGSTOP: c_int = 19; +pub const SIGSYS: c_int = 31; +pub const SIGTSTP: c_int = 20; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGURG: c_int = 23; +pub const SIGUSR1: c_int = 10; +pub const SIGUSR2: c_int = 12; +pub const SIGVTALRM: c_int = 26; +pub const SIGWINCH: c_int = 28; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIG_SETMASK: c_int = 2; // FIXME(musl) check these +pub const SIG_BLOCK: c_int = 0x000000; +pub const SIG_UNBLOCK: c_int = 0x01; +pub const SOL_CAIF: c_int = 278; +pub const SOL_IUCV: c_int = 277; +pub const SOL_KCM: c_int = 281; +pub const SOL_NFC: c_int = 280; +pub const SOL_PNPIPE: c_int = 275; +pub const SOL_PPPOL2TP: c_int = 273; +pub const SOL_RDS: c_int = 276; +pub const SOL_RXRPC: c_int = 272; +pub const POLLWRNORM: c_short = 256; +pub const POLLWRBAND: c_short = 512; +pub const MADV_SOFT_OFFLINE: c_int = 101; +pub const MCL_CURRENT: c_int = 1; +pub const MCL_FUTURE: c_int = 2; +pub const MCL_ONFAULT: c_int = 4; + +pub const SYS3264_fadvise64: c_int = 223; +pub const SYS3264_fcntl: c_int = 25; +pub const SYS3264_fstatat: c_int = 79; +pub const SYS3264_fstat: c_int = 80; +pub const SYS3264_fstatfs: c_int = 44; +pub const SYS3264_ftruncate: c_int = 46; +pub const SYS3264_lseek: c_int = 62; +pub const SYS3264_lstat: c_int = 1039; +pub const SYS3264_mmap: c_int = 222; +pub const SYS3264_sendfile: c_int = 71; +pub const SYS3264_stat: c_int = 1038; +pub const SYS3264_statfs: c_int = 43; +pub const SYS3264_truncate: c_int = 45; +pub const SYS_accept4: c_int = 242; +pub const SYS_accept: c_int = 202; +pub const SYS_access: c_int = 1033; +pub const SYS_acct: c_int = 89; +pub const SYS_add_key: c_int = 217; +pub const SYS_adjtimex: c_int = 171; +pub const SYS_alarm: c_int = 1059; +pub const SYS_arch_specific_syscall: c_int = 244; +pub const SYS_bdflush: c_int = 1075; +pub const SYS_bind: c_int = 200; +pub const SYS_bpf: c_int = 280; +pub const SYS_brk: c_int = 214; +pub const SYS_capget: c_int = 90; +pub const SYS_capset: c_int = 91; +pub const SYS_chdir: c_int = 49; +pub const SYS_chmod: c_int = 1028; +pub const SYS_chown: c_int = 1029; +pub const SYS_chroot: c_int = 51; +pub const SYS_clock_adjtime: c_int = 266; +pub const SYS_clock_getres: c_int = 114; +pub const SYS_clock_gettime: c_int = 113; +pub const SYS_clock_nanosleep: c_int = 115; +pub const SYS_clock_settime: c_int = 112; +pub const SYS_clone: c_int = 220; +pub const SYS_close: c_int = 57; +pub const SYS_connect: c_int = 203; +pub const SYS_copy_file_range: c_long = 285; +pub const SYS_creat: c_int = 1064; +pub const SYS_delete_module: c_int = 106; +pub const SYS_dup2: c_int = 1041; +pub const SYS_dup3: c_int = 24; +pub const SYS_dup: c_int = 23; +pub const SYS_epoll_create1: c_int = 20; +pub const SYS_epoll_create: c_int = 1042; +pub const SYS_epoll_ctl: c_int = 21; +pub const SYS_epoll_pwait: c_int = 22; +pub const SYS_epoll_wait: c_int = 1069; +pub const SYS_eventfd2: c_int = 19; +pub const SYS_eventfd: c_int = 1044; +pub const SYS_execveat: c_int = 281; +pub const SYS_execve: c_int = 221; +pub const SYS_exit: c_int = 93; +pub const SYS_exit_group: c_int = 94; +pub const SYS_faccessat: c_int = 48; +pub const SYS_fadvise64_64: c_int = 223; +pub const SYS_fallocate: c_int = 47; +pub const SYS_fanotify_init: c_int = 262; +pub const SYS_fanotify_mark: c_int = 263; +pub const SYS_fchdir: c_int = 50; +pub const SYS_fchmodat: c_int = 53; +pub const SYS_fchmod: c_int = 52; +pub const SYS_fchownat: c_int = 54; +pub const SYS_fchown: c_int = 55; +pub const SYS_fcntl64: c_int = 25; +pub const SYS_fcntl: c_int = 25; +pub const SYS_fdatasync: c_int = 83; +pub const SYS_fgetxattr: c_int = 10; +pub const SYS_finit_module: c_int = 273; +pub const SYS_flistxattr: c_int = 13; +pub const SYS_flock: c_int = 32; +pub const SYS_fork: c_int = 1079; +pub const SYS_fremovexattr: c_int = 16; +pub const SYS_fsetxattr: c_int = 7; +pub const SYS_fstat64: c_int = 80; +pub const SYS_fstatat64: c_int = 79; +pub const SYS_fstatfs64: c_int = 44; +pub const SYS_fstatfs: c_int = 44; +pub const SYS_fsync: c_int = 82; +pub const SYS_ftruncate64: c_int = 46; +pub const SYS_ftruncate: c_int = 46; +pub const SYS_futex: c_int = 98; +pub const SYS_futimesat: c_int = 1066; +pub const SYS_getcpu: c_int = 168; +pub const SYS_getcwd: c_int = 17; +pub const SYS_getdents64: c_int = 61; +pub const SYS_getdents: c_int = 1065; +pub const SYS_getegid: c_int = 177; +pub const SYS_geteuid: c_int = 175; +pub const SYS_getgid: c_int = 176; +pub const SYS_getgroups: c_int = 158; +pub const SYS_getitimer: c_int = 102; +pub const SYS_get_mempolicy: c_int = 236; +pub const SYS_getpeername: c_int = 205; +pub const SYS_getpgid: c_int = 155; +pub const SYS_getpgrp: c_int = 1060; +pub const SYS_getpid: c_int = 172; +pub const SYS_getppid: c_int = 173; +pub const SYS_getpriority: c_int = 141; +pub const SYS_getrandom: c_int = 278; +pub const SYS_getresgid: c_int = 150; +pub const SYS_getresuid: c_int = 148; +pub const SYS_getrlimit: c_int = 163; +pub const SYS_get_robust_list: c_int = 100; +pub const SYS_getrusage: c_int = 165; +pub const SYS_getsid: c_int = 156; +pub const SYS_getsockname: c_int = 204; +pub const SYS_getsockopt: c_int = 209; +pub const SYS_gettid: c_int = 178; +pub const SYS_gettimeofday: c_int = 169; +pub const SYS_getuid: c_int = 174; +pub const SYS_getxattr: c_int = 8; +pub const SYS_init_module: c_int = 105; +pub const SYS_inotify_add_watch: c_int = 27; +pub const SYS_inotify_init1: c_int = 26; +pub const SYS_inotify_init: c_int = 1043; +pub const SYS_inotify_rm_watch: c_int = 28; +pub const SYS_io_cancel: c_int = 3; +pub const SYS_ioctl: c_int = 29; +pub const SYS_io_destroy: c_int = 1; +pub const SYS_io_getevents: c_int = 4; +pub const SYS_ioprio_get: c_int = 31; +pub const SYS_ioprio_set: c_int = 30; +pub const SYS_io_setup: c_int = 0; +pub const SYS_io_submit: c_int = 2; +pub const SYS_kcmp: c_int = 272; +pub const SYS_kexec_load: c_int = 104; +pub const SYS_keyctl: c_int = 219; +pub const SYS_kill: c_int = 129; +pub const SYS_lchown: c_int = 1032; +pub const SYS_lgetxattr: c_int = 9; +pub const SYS_linkat: c_int = 37; +pub const SYS_link: c_int = 1025; +pub const SYS_listen: c_int = 201; +pub const SYS_listxattr: c_int = 11; +pub const SYS_llistxattr: c_int = 12; +pub const SYS__llseek: c_int = 62; +pub const SYS_lookup_dcookie: c_int = 18; +pub const SYS_lremovexattr: c_int = 15; +pub const SYS_lseek: c_int = 62; +pub const SYS_lsetxattr: c_int = 6; +pub const SYS_lstat64: c_int = 1039; +pub const SYS_lstat: c_int = 1039; +pub const SYS_madvise: c_int = 233; +pub const SYS_mbind: c_int = 235; +pub const SYS_memfd_create: c_int = 279; +pub const SYS_migrate_pages: c_int = 238; +pub const SYS_mincore: c_int = 232; +pub const SYS_mkdirat: c_int = 34; +pub const SYS_mkdir: c_int = 1030; +pub const SYS_mknodat: c_int = 33; +pub const SYS_mknod: c_int = 1027; +pub const SYS_mlockall: c_int = 230; +pub const SYS_mlock: c_int = 228; +pub const SYS_mmap2: c_int = 222; +pub const SYS_mount: c_int = 40; +pub const SYS_move_pages: c_int = 239; +pub const SYS_mprotect: c_int = 226; +pub const SYS_mq_getsetattr: c_int = 185; +pub const SYS_mq_notify: c_int = 184; +pub const SYS_mq_open: c_int = 180; +pub const SYS_mq_timedreceive: c_int = 183; +pub const SYS_mq_timedsend: c_int = 182; +pub const SYS_mq_unlink: c_int = 181; +pub const SYS_mremap: c_int = 216; +pub const SYS_msgctl: c_int = 187; +pub const SYS_msgget: c_int = 186; +pub const SYS_msgrcv: c_int = 188; +pub const SYS_msgsnd: c_int = 189; +pub const SYS_msync: c_int = 227; +pub const SYS_munlockall: c_int = 231; +pub const SYS_munlock: c_int = 229; +pub const SYS_munmap: c_int = 215; +pub const SYS_name_to_handle_at: c_int = 264; +pub const SYS_nanosleep: c_int = 101; +pub const SYS_newfstatat: c_int = 79; +pub const SYS_nfsservctl: c_int = 42; +pub const SYS_oldwait4: c_int = 1072; +pub const SYS_openat: c_int = 56; +pub const SYS_open_by_handle_at: c_int = 265; +pub const SYS_open: c_int = 1024; +pub const SYS_pause: c_int = 1061; +pub const SYS_perf_event_open: c_int = 241; +pub const SYS_personality: c_int = 92; +pub const SYS_pipe2: c_int = 59; +pub const SYS_pipe: c_int = 1040; +pub const SYS_pivot_root: c_int = 41; +pub const SYS_poll: c_int = 1068; +pub const SYS_ppoll: c_int = 73; +pub const SYS_prctl: c_int = 167; +pub const SYS_pread64: c_int = 67; +pub const SYS_preadv: c_int = 69; +pub const SYS_prlimit64: c_int = 261; +pub const SYS_process_vm_readv: c_int = 270; +pub const SYS_process_vm_writev: c_int = 271; +pub const SYS_pselect6: c_int = 72; +pub const SYS_ptrace: c_int = 117; +pub const SYS_pwrite64: c_int = 68; +pub const SYS_pwritev: c_int = 70; +pub const SYS_quotactl: c_int = 60; +pub const SYS_readahead: c_int = 213; +pub const SYS_read: c_int = 63; +pub const SYS_readlinkat: c_int = 78; +pub const SYS_readlink: c_int = 1035; +pub const SYS_readv: c_int = 65; +pub const SYS_reboot: c_int = 142; +pub const SYS_recv: c_int = 1073; +pub const SYS_recvfrom: c_int = 207; +pub const SYS_recvmmsg: c_int = 243; +pub const SYS_recvmsg: c_int = 212; +pub const SYS_remap_file_pages: c_int = 234; +pub const SYS_removexattr: c_int = 14; +pub const SYS_renameat2: c_int = 276; +pub const SYS_renameat: c_int = 38; +pub const SYS_rename: c_int = 1034; +pub const SYS_request_key: c_int = 218; +pub const SYS_restart_syscall: c_int = 128; +pub const SYS_rmdir: c_int = 1031; +pub const SYS_rt_sigaction: c_int = 134; +pub const SYS_rt_sigpending: c_int = 136; +pub const SYS_rt_sigprocmask: c_int = 135; +pub const SYS_rt_sigqueueinfo: c_int = 138; +pub const SYS_rt_sigreturn: c_int = 139; +pub const SYS_rt_sigsuspend: c_int = 133; +pub const SYS_rt_sigtimedwait: c_int = 137; +pub const SYS_rt_tgsigqueueinfo: c_int = 240; +pub const SYS_sched_getaffinity: c_int = 123; +pub const SYS_sched_getattr: c_int = 275; +pub const SYS_sched_getparam: c_int = 121; +pub const SYS_sched_get_priority_max: c_int = 125; +pub const SYS_sched_get_priority_min: c_int = 126; +pub const SYS_sched_getscheduler: c_int = 120; +pub const SYS_sched_rr_get_interval: c_int = 127; +pub const SYS_sched_setaffinity: c_int = 122; +pub const SYS_sched_setattr: c_int = 274; +pub const SYS_sched_setparam: c_int = 118; +pub const SYS_sched_setscheduler: c_int = 119; +pub const SYS_sched_yield: c_int = 124; +pub const SYS_seccomp: c_int = 277; +pub const SYS_select: c_int = 1067; +pub const SYS_semctl: c_int = 191; +pub const SYS_semget: c_int = 190; +pub const SYS_semop: c_int = 193; +pub const SYS_semtimedop: c_int = 192; +pub const SYS_send: c_int = 1074; +pub const SYS_sendfile64: c_int = 71; +pub const SYS_sendfile: c_int = 71; +pub const SYS_sendmmsg: c_int = 269; +pub const SYS_sendmsg: c_int = 211; +pub const SYS_sendto: c_int = 206; +pub const SYS_setdomainname: c_int = 162; +pub const SYS_setfsgid: c_int = 152; +pub const SYS_setfsuid: c_int = 151; +pub const SYS_setgid: c_int = 144; +pub const SYS_setgroups: c_int = 159; +pub const SYS_sethostname: c_int = 161; +pub const SYS_setitimer: c_int = 103; +pub const SYS_set_mempolicy: c_int = 237; +pub const SYS_setns: c_int = 268; +pub const SYS_setpgid: c_int = 154; +pub const SYS_setpriority: c_int = 140; +pub const SYS_setregid: c_int = 143; +pub const SYS_setresgid: c_int = 149; +pub const SYS_setresuid: c_int = 147; +pub const SYS_setreuid: c_int = 145; +pub const SYS_setrlimit: c_int = 164; +pub const SYS_set_robust_list: c_int = 99; +pub const SYS_setsid: c_int = 157; +pub const SYS_setsockopt: c_int = 208; +pub const SYS_set_tid_address: c_int = 96; +pub const SYS_settimeofday: c_int = 170; +pub const SYS_setuid: c_int = 146; +pub const SYS_setxattr: c_int = 5; +pub const SYS_shmat: c_int = 196; +pub const SYS_shmctl: c_int = 195; +pub const SYS_shmdt: c_int = 197; +pub const SYS_shmget: c_int = 194; +pub const SYS_shutdown: c_int = 210; +pub const SYS_sigaltstack: c_int = 132; +pub const SYS_signalfd4: c_int = 74; +pub const SYS_signalfd: c_int = 1045; +pub const SYS_socket: c_int = 198; +pub const SYS_socketpair: c_int = 199; +pub const SYS_splice: c_int = 76; +pub const SYS_stat64: c_int = 1038; +pub const SYS_stat: c_int = 1038; +pub const SYS_statfs64: c_int = 43; +pub const SYS_statfs: c_int = 43; +pub const SYS_swapoff: c_int = 225; +pub const SYS_swapon: c_int = 224; +pub const SYS_symlinkat: c_int = 36; +pub const SYS_symlink: c_int = 1036; +pub const SYS_sync: c_int = 81; +pub const SYS_sync_file_range2: c_int = 84; +pub const SYS_sync_file_range: c_int = 84; +pub const SYS_syncfs: c_int = 267; +pub const SYS_syscalls: c_int = 1080; +pub const SYS__sysctl: c_int = 1078; +pub const SYS_sysinfo: c_int = 179; +pub const SYS_syslog: c_int = 116; +pub const SYS_tee: c_int = 77; +pub const SYS_tgkill: c_int = 131; +pub const SYS_time: c_int = 1062; +pub const SYS_timer_create: c_int = 107; +pub const SYS_timer_delete: c_int = 111; +pub const SYS_timerfd_create: c_int = 85; +pub const SYS_timerfd_gettime: c_int = 87; +pub const SYS_timerfd_settime: c_int = 86; +pub const SYS_timer_getoverrun: c_int = 109; +pub const SYS_timer_gettime: c_int = 108; +pub const SYS_timer_settime: c_int = 110; +pub const SYS_times: c_int = 153; +pub const SYS_tkill: c_int = 130; +pub const SYS_truncate64: c_int = 45; +pub const SYS_truncate: c_int = 45; +pub const SYS_umask: c_int = 166; +pub const SYS_umount2: c_int = 39; +pub const SYS_umount: c_int = 1076; +pub const SYS_uname: c_int = 160; +pub const SYS_unlinkat: c_int = 35; +pub const SYS_unlink: c_int = 1026; +pub const SYS_unshare: c_int = 97; +pub const SYS_uselib: c_int = 1077; +pub const SYS_ustat: c_int = 1070; +pub const SYS_utime: c_int = 1063; +pub const SYS_utimensat: c_int = 88; +pub const SYS_utimes: c_int = 1037; +pub const SYS_vfork: c_int = 1071; +pub const SYS_vhangup: c_int = 58; +pub const SYS_vmsplice: c_int = 75; +pub const SYS_wait4: c_int = 260; +pub const SYS_waitid: c_int = 95; +pub const SYS_write: c_int = 64; +pub const SYS_writev: c_int = 66; +pub const SYS_statx: c_int = 291; +pub const SYS_pidfd_send_signal: c_long = 424; +pub const SYS_io_uring_setup: c_long = 425; +pub const SYS_io_uring_enter: c_long = 426; +pub const SYS_io_uring_register: c_long = 427; +pub const SYS_open_tree: c_long = 428; +pub const SYS_move_mount: c_long = 429; +pub const SYS_fsopen: c_long = 430; +pub const SYS_fsconfig: c_long = 431; +pub const SYS_fsmount: c_long = 432; +pub const SYS_fspick: c_long = 433; +pub const SYS_pidfd_open: c_long = 434; +pub const SYS_clone3: c_long = 435; +pub const SYS_close_range: c_long = 436; +pub const SYS_openat2: c_long = 437; +pub const SYS_pidfd_getfd: c_long = 438; +pub const SYS_faccessat2: c_long = 439; +pub const SYS_process_madvise: c_long = 440; +pub const SYS_epoll_pwait2: c_long = 441; +pub const SYS_mount_setattr: c_long = 442; +pub const SYS_userfaultfd: c_long = 282; +pub const SYS_membarrier: c_long = 283; +pub const SYS_mlock2: c_long = 284; +pub const SYS_preadv2: c_long = 286; +pub const SYS_pwritev2: c_long = 287; +pub const SYS_futex_waitv: c_long = 449; +pub const TIOCM_LOOP: c_int = 32768; +pub const TIOCM_OUT1: c_int = 8192; +pub const TIOCM_OUT2: c_int = 16384; +pub const TIOCSER_TEMT: c_int = 1; +pub const TOSTOP: crate::tcflag_t = 256; +pub const VEOF: c_int = 4; +pub const VEOL2: c_int = 16; +pub const VEOL: c_int = 11; +pub const VMIN: c_int = 6; +pub const CBAUD: crate::tcflag_t = 4111; +pub const CIBAUD: crate::tcflag_t = 269418496; +pub const CLOCAL: crate::tcflag_t = 2048; +pub const CREAD: crate::tcflag_t = 128; +pub const CS6: crate::tcflag_t = 16; +pub const CS7: crate::tcflag_t = 32; +pub const CS8: crate::tcflag_t = 48; +pub const CSIZE: crate::tcflag_t = 48; +pub const CSTOPB: crate::tcflag_t = 64; +pub const HUPCL: crate::tcflag_t = 1024; +pub const PARENB: crate::tcflag_t = 256; +pub const PARODD: crate::tcflag_t = 512; +pub const ECHOCTL: crate::tcflag_t = 512; +pub const ECHOE: crate::tcflag_t = 16; +pub const ECHOK: crate::tcflag_t = 32; +pub const ECHOKE: crate::tcflag_t = 2048; +pub const ECHONL: crate::tcflag_t = 64; +pub const ECHOPRT: crate::tcflag_t = 1024; +pub const ICANON: crate::tcflag_t = 2; +pub const ISIG: crate::tcflag_t = 1; +pub const IXOFF: crate::tcflag_t = 4096; +pub const IXON: crate::tcflag_t = 1024; +pub const NOFLSH: crate::tcflag_t = 128; +pub const PENDIN: crate::tcflag_t = 16384; +pub const BSDLY: crate::tcflag_t = 8192; +pub const CRDLY: crate::tcflag_t = 1536; +pub const FFDLY: crate::tcflag_t = 32768; +pub const NLDLY: crate::tcflag_t = 256; +pub const OLCUC: crate::tcflag_t = 2; +pub const ONLCR: crate::tcflag_t = 4; +pub const TABDLY: crate::tcflag_t = 6144; +pub const VTDLY: crate::tcflag_t = 16384; +pub const XTABS: crate::tcflag_t = 6144; +pub const BS1: crate::tcflag_t = 8192; +pub const CBAUDEX: crate::tcflag_t = 4096; +pub const CR1: crate::tcflag_t = 512; +pub const CR2: crate::tcflag_t = 1024; +pub const CR3: crate::tcflag_t = 1536; +pub const FF1: crate::tcflag_t = 32768; +pub const TAB1: crate::tcflag_t = 2048; +pub const TAB2: crate::tcflag_t = 4096; +pub const TAB3: crate::tcflag_t = 6144; +pub const VT1: crate::tcflag_t = 16384; +pub const VDISCARD: usize = 13; +pub const VREPRINT: usize = 12; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VSUSP: usize = 10; +pub const VSWTC: usize = 7; +pub const VTIME: usize = 5; +pub const VWERASE: usize = 14; +pub const B57600: crate::speed_t = 4097; +pub const B115200: crate::speed_t = 4098; +pub const B230400: crate::speed_t = 4099; +pub const B460800: crate::speed_t = 4100; +pub const B500000: crate::speed_t = 4101; +pub const B576000: crate::speed_t = 4102; +pub const B921600: crate::speed_t = 4103; +pub const B1000000: crate::speed_t = 4104; +pub const B1152000: crate::speed_t = 4105; +pub const B1500000: crate::speed_t = 4106; +pub const B2000000: crate::speed_t = 4107; +pub const B2500000: crate::speed_t = 4108; +pub const B3000000: crate::speed_t = 4109; +pub const B3500000: crate::speed_t = 4110; +pub const B4000000: crate::speed_t = 4111; diff --git a/http/vendor/libc/src/unix/linux_like/linux/musl/b32/mips/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/musl/b32/mips/mod.rs new file mode 100644 index 0000000..7edcf57 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -0,0 +1,878 @@ +use crate::off_t; +use crate::prelude::*; + +pub type wchar_t = c_int; + +pub type stat64 = stat; + +s! { + pub struct stat { + pub st_dev: crate::dev_t, + __st_padding1: Padding<[c_long; 2]>, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + __st_padding2: Padding<[c_long; 2]>, + pub st_size: off_t, + + #[cfg(musl32_time64)] + __st_atim32: Padding<__c_anonymous_timespec32>, + #[cfg(musl32_time64)] + __st_mtim32: Padding<__c_anonymous_timespec32>, + #[cfg(musl32_time64)] + __st_ctim32: Padding<__c_anonymous_timespec32>, + + #[cfg(musl_v1_2_3)] + pub st_blksize: crate::blksize_t, + #[cfg(musl_v1_2_3)] + __st_padding3: Padding, + #[cfg(musl_v1_2_3)] + pub st_blocks: crate::blkcnt_t, + + pub st_atime: crate::time_t, + #[cfg(all(musl32_time64, target_endian = "big"))] + __pad0: Padding, + pub st_atime_nsec: c_long, + #[cfg(all(musl32_time64, target_endian = "little"))] + __pad0: Padding, + pub st_mtime: crate::time_t, + #[cfg(all(musl32_time64, target_endian = "big"))] + __pad1: Padding, + pub st_mtime_nsec: c_long, + #[cfg(all(musl32_time64, target_endian = "little"))] + __pad1: Padding, + pub st_ctime: crate::time_t, + #[cfg(all(musl32_time64, target_endian = "big"))] + __pad2: Padding, + pub st_ctime_nsec: c_long, + #[cfg(all(musl32_time64, target_endian = "little"))] + __pad2: Padding, + + #[cfg(not(musl_v1_2_3))] + pub st_blksize: crate::blksize_t, + #[cfg(not(musl_v1_2_3))] + __st_padding3: Padding, + #[cfg(not(musl_v1_2_3))] + pub st_blocks: crate::blkcnt_t, + + #[cfg(not(musl_v1_2_3))] + __st_padding4: Padding<[c_long; 14]>, + #[cfg(musl_v1_2_3)] + __st_padding4: Padding<[c_long; 2]>, + } + + struct __c_anonymous_timespec32 { + __tv_sec: c_long, + __tv_nsec: c_long, + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_size: size_t, + pub ss_flags: c_int, + } + + pub struct ipc_perm { + #[cfg(musl_v1_2_3)] + pub __key: crate::key_t, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "This field is incorrectly named and will be changed + to __key in a future release." + )] + pub __ipc_perm_key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: crate::mode_t, + pub __seq: c_int, + __unused1: Padding, + __unused2: Padding, + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, + #[cfg(not(musl32_time64))] + pub shm_atime: crate::time_t, + #[cfg(not(musl32_time64))] + pub shm_dtime: crate::time_t, + #[cfg(not(musl32_time64))] + pub shm_ctime: crate::time_t, + #[cfg(musl32_time64)] + __shm_atime_lo: Padding, + #[cfg(musl32_time64)] + __shm_dtime_lo: Padding, + #[cfg(musl32_time64)] + __shm_ctime_lo: Padding, + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: c_ulong, + #[cfg(not(musl32_time64))] + __pad1: Padding, + #[cfg(not(musl32_time64))] + __pad2: Padding, + + #[cfg(musl32_time64)] + __shm_atime_hi: Padding, + #[cfg(musl32_time64)] + __shm_dtime_hi: Padding, + #[cfg(musl32_time64)] + __shm_ctime_hi: Padding, + #[cfg(musl32_time64)] + __pad1: Padding, + #[cfg(musl32_time64)] + pub shm_atime: crate::time_t, + #[cfg(musl32_time64)] + pub shm_dtime: crate::time_t, + #[cfg(musl32_time64)] + pub shm_ctime: crate::time_t, + } + + pub struct statfs { + pub f_type: c_ulong, + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_fsid: crate::fsid_t, + pub f_namelen: c_ulong, + pub f_flags: c_ulong, + pub f_spare: [c_ulong; 5], + } + + pub struct statfs64 { + pub f_type: c_ulong, + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_fsid: crate::fsid_t, + pub f_namelen: c_ulong, + pub f_flags: c_ulong, + pub f_spare: [c_ulong; 5], + } +} + +cfg_if! { + if #[cfg(musl32_time64)] { + s! { + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + + #[cfg(target_endian = "big")] + __msg_stime_hi: Padding, + #[cfg(target_endian = "big")] + __msg_stime_lo: Padding, + #[cfg(target_endian = "big")] + __msg_rtime_hi: Padding, + #[cfg(target_endian = "big")] + __msg_rtime_lo: Padding, + #[cfg(target_endian = "big")] + __msg_ctime_hi: Padding, + #[cfg(target_endian = "big")] + __msg_ctime_lo: Padding, + + #[cfg(target_endian = "little")] + __msg_stime_lo: Padding, + #[cfg(target_endian = "little")] + __msg_stime_hi: Padding, + #[cfg(target_endian = "little")] + __msg_rtime_lo: Padding, + #[cfg(target_endian = "little")] + __msg_rtime_hi: Padding, + #[cfg(target_endian = "little")] + __msg_ctime_lo: Padding, + #[cfg(target_endian = "little")] + __msg_ctime_hi: Padding, + + pub __msg_cbytes: c_ulong, + pub msg_qnum: crate::msgqnum_t, + pub msg_qbytes: crate::msglen_t, + pub msg_lspid: crate::pid_t, + pub msg_lrpid: crate::pid_t, + __pad1: Padding, + __pad2: Padding, + + pub msg_stime: crate::time_t, + pub msg_rtime: crate::time_t, + pub msg_ctime: crate::time_t, + } + } + } else { + s! { + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + + #[cfg(target_endian = "big")] + __unused1: Padding, + #[cfg(target_endian = "big")] + pub msg_stime: crate::time_t, + #[cfg(target_endian = "big")] + __unused2: Padding, + #[cfg(target_endian = "big")] + pub msg_rtime: crate::time_t, + #[cfg(target_endian = "big")] + __unused3: Padding, + #[cfg(target_endian = "big")] + pub msg_ctime: crate::time_t, + + #[cfg(target_endian = "little")] + pub msg_stime: crate::time_t, + #[cfg(target_endian = "little")] + __unused1: Padding, + #[cfg(target_endian = "little")] + pub msg_rtime: crate::time_t, + #[cfg(target_endian = "little")] + __unused2: Padding, + #[cfg(target_endian = "little")] + pub msg_ctime: crate::time_t, + #[cfg(target_endian = "little")] + __unused3: Padding, + + pub __msg_cbytes: c_ulong, + pub msg_qnum: crate::msgqnum_t, + pub msg_qbytes: crate::msglen_t, + pub msg_lspid: crate::pid_t, + pub msg_lrpid: crate::pid_t, + __pad1: Padding, + __pad2: Padding, + } + } + } +} + +s_no_extra_traits! { + #[repr(align(8))] + pub struct max_align_t { + priv_: [f32; 4], + } +} + +pub const SIGSTKSZ: size_t = 8192; +pub const MINSIGSTKSZ: size_t = 2048; + +pub const O_DIRECT: c_int = 0o100000; +pub const O_DIRECTORY: c_int = 0o200000; +pub const O_NOFOLLOW: c_int = 0o400000; +pub const O_ASYNC: c_int = 0o10000; +pub const O_LARGEFILE: c_int = 0x2000; + +pub const MCL_CURRENT: c_int = 0x0001; +pub const MCL_FUTURE: c_int = 0x0002; +pub const MCL_ONFAULT: c_int = 0x0004; +pub const CBAUD: crate::tcflag_t = 0o0010017; +pub const TAB1: c_int = 0x00000800; +pub const TAB2: c_int = 0x00001000; +pub const TAB3: c_int = 0x00001800; +pub const CR1: c_int = 0x00000200; +pub const CR2: c_int = 0x00000400; +pub const CR3: c_int = 0x00000600; +pub const FF1: c_int = 0x00008000; +pub const BS1: c_int = 0x00002000; +pub const VT1: c_int = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: crate::tcflag_t = 0x00000400; +pub const IXOFF: crate::tcflag_t = 0x00001000; +pub const ONLCR: crate::tcflag_t = 0x4; +pub const CSIZE: crate::tcflag_t = 0x00000030; +pub const CS6: crate::tcflag_t = 0x00000010; +pub const CS7: crate::tcflag_t = 0x00000020; +pub const CS8: crate::tcflag_t = 0x00000030; +pub const CSTOPB: crate::tcflag_t = 0x00000040; +pub const CREAD: crate::tcflag_t = 0x00000080; +pub const PARENB: crate::tcflag_t = 0x00000100; +pub const PARODD: crate::tcflag_t = 0x00000200; +pub const HUPCL: crate::tcflag_t = 0x00000400; +pub const CLOCAL: crate::tcflag_t = 0x00000800; +pub const ECHOKE: crate::tcflag_t = 0x00000800; +pub const ECHOE: crate::tcflag_t = 0x00000010; +pub const ECHOK: crate::tcflag_t = 0x00000020; +pub const ECHONL: crate::tcflag_t = 0x00000040; +pub const ECHOPRT: crate::tcflag_t = 0x00000400; +pub const ECHOCTL: crate::tcflag_t = 0x00000200; +pub const ISIG: crate::tcflag_t = 0x00000001; +pub const ICANON: crate::tcflag_t = 0x00000002; +pub const PENDIN: crate::tcflag_t = 0x00004000; +pub const NOFLSH: crate::tcflag_t = 0x00000080; +pub const CIBAUD: crate::tcflag_t = 0o02003600000; +pub const CBAUDEX: crate::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: crate::tcflag_t = 0o000002; +pub const NLDLY: crate::tcflag_t = 0o000400; +pub const CRDLY: crate::tcflag_t = 0o003000; +pub const TABDLY: crate::tcflag_t = 0o014000; +pub const BSDLY: crate::tcflag_t = 0o020000; +pub const FFDLY: crate::tcflag_t = 0o100000; +pub const VTDLY: crate::tcflag_t = 0o040000; +pub const XTABS: crate::tcflag_t = 0o014000; +pub const B57600: crate::speed_t = 0o010001; +pub const B115200: crate::speed_t = 0o010002; +pub const B230400: crate::speed_t = 0o010003; +pub const B460800: crate::speed_t = 0o010004; +pub const B500000: crate::speed_t = 0o010005; +pub const B576000: crate::speed_t = 0o010006; +pub const B921600: crate::speed_t = 0o010007; +pub const B1000000: crate::speed_t = 0o010010; +pub const B1152000: crate::speed_t = 0o010011; +pub const B1500000: crate::speed_t = 0o010012; +pub const B2000000: crate::speed_t = 0o010013; +pub const B2500000: crate::speed_t = 0o010014; +pub const B3000000: crate::speed_t = 0o010015; +pub const B3500000: crate::speed_t = 0o010016; +pub const B4000000: crate::speed_t = 0o010017; + +pub const O_APPEND: c_int = 0o010; +pub const O_CREAT: c_int = 0o400; +pub const O_EXCL: c_int = 0o2000; +pub const O_NOCTTY: c_int = 0o4000; +pub const O_NONBLOCK: c_int = 0o200; +pub const O_SYNC: c_int = 0o40020; +pub const O_RSYNC: c_int = 0o40020; +pub const O_DSYNC: c_int = 0o020; + +pub const MAP_ANON: c_int = 0x800; +pub const MAP_GROWSDOWN: c_int = 0x1000; +pub const MAP_DENYWRITE: c_int = 0x2000; +pub const MAP_EXECUTABLE: c_int = 0x4000; +pub const MAP_LOCKED: c_int = 0x8000; +pub const MAP_NORESERVE: c_int = 0x0400; +pub const MAP_POPULATE: c_int = 0x10000; +pub const MAP_NONBLOCK: c_int = 0x20000; +pub const MAP_STACK: c_int = 0x40000; +pub const MAP_HUGETLB: c_int = 0x80000; + +pub const EDEADLK: c_int = 45; +pub const ENAMETOOLONG: c_int = 78; +pub const ENOLCK: c_int = 46; +pub const ENOSYS: c_int = 89; +pub const ENOTEMPTY: c_int = 93; +pub const ELOOP: c_int = 90; +pub const ENOMSG: c_int = 35; +pub const EIDRM: c_int = 36; +pub const ECHRNG: c_int = 37; +pub const EL2NSYNC: c_int = 38; +pub const EL3HLT: c_int = 39; +pub const EL3RST: c_int = 40; +pub const ELNRNG: c_int = 41; +pub const EUNATCH: c_int = 42; +pub const ENOCSI: c_int = 43; +pub const EL2HLT: c_int = 44; +pub const EBADE: c_int = 50; +pub const EBADR: c_int = 51; +pub const EXFULL: c_int = 52; +pub const ENOANO: c_int = 53; +pub const EBADRQC: c_int = 54; +pub const EBADSLT: c_int = 55; +pub const EDEADLOCK: c_int = 56; +pub const EMULTIHOP: c_int = 74; +pub const EOVERFLOW: c_int = 79; +pub const ENOTUNIQ: c_int = 80; +pub const EBADFD: c_int = 81; +pub const EBADMSG: c_int = 77; +pub const EREMCHG: c_int = 82; +pub const ELIBACC: c_int = 83; +pub const ELIBBAD: c_int = 84; +pub const ELIBSCN: c_int = 85; +pub const ELIBMAX: c_int = 86; +pub const ELIBEXEC: c_int = 87; +pub const EILSEQ: c_int = 88; +pub const ERESTART: c_int = 91; +pub const ESTRPIPE: c_int = 92; +pub const EUSERS: c_int = 94; +pub const ENOTSOCK: c_int = 95; +pub const EDESTADDRREQ: c_int = 96; +pub const EMSGSIZE: c_int = 97; +pub const EPROTOTYPE: c_int = 98; +pub const ENOPROTOOPT: c_int = 99; +pub const EPROTONOSUPPORT: c_int = 120; +pub const ESOCKTNOSUPPORT: c_int = 121; +pub const EOPNOTSUPP: c_int = 122; +pub const ENOTSUP: c_int = EOPNOTSUPP; +pub const EPFNOSUPPORT: c_int = 123; +pub const EAFNOSUPPORT: c_int = 124; +pub const EADDRINUSE: c_int = 125; +pub const EADDRNOTAVAIL: c_int = 126; +pub const ENETDOWN: c_int = 127; +pub const ENETUNREACH: c_int = 128; +pub const ENETRESET: c_int = 129; +pub const ECONNABORTED: c_int = 130; +pub const ECONNRESET: c_int = 131; +pub const ENOBUFS: c_int = 132; +pub const EISCONN: c_int = 133; +pub const ENOTCONN: c_int = 134; +pub const ESHUTDOWN: c_int = 143; +pub const ETOOMANYREFS: c_int = 144; +pub const ETIMEDOUT: c_int = 145; +pub const ECONNREFUSED: c_int = 146; +pub const EHOSTDOWN: c_int = 147; +pub const EHOSTUNREACH: c_int = 148; +pub const EALREADY: c_int = 149; +pub const EINPROGRESS: c_int = 150; +pub const ESTALE: c_int = 151; +pub const EUCLEAN: c_int = 135; +pub const ENOTNAM: c_int = 137; +pub const ENAVAIL: c_int = 138; +pub const EISNAM: c_int = 139; +pub const EREMOTEIO: c_int = 140; +pub const EDQUOT: c_int = 1133; +pub const ENOMEDIUM: c_int = 159; +pub const EMEDIUMTYPE: c_int = 160; +pub const ECANCELED: c_int = 158; +pub const ENOKEY: c_int = 161; +pub const EKEYEXPIRED: c_int = 162; +pub const EKEYREVOKED: c_int = 163; +pub const EKEYREJECTED: c_int = 164; +pub const EOWNERDEAD: c_int = 165; +pub const ENOTRECOVERABLE: c_int = 166; +pub const EHWPOISON: c_int = 168; +pub const ERFKILL: c_int = 167; + +pub const SA_ONSTACK: c_int = 0x08000000; +pub const SA_SIGINFO: c_int = 8; +pub const SA_NOCLDWAIT: c_int = 0x10000; + +pub const SIGEMT: c_int = 7; +pub const SIGCHLD: c_int = 18; +pub const SIGBUS: c_int = 10; +pub const SIGTTIN: c_int = 26; +pub const SIGTTOU: c_int = 27; +pub const SIGXCPU: c_int = 30; +pub const SIGXFSZ: c_int = 31; +pub const SIGVTALRM: c_int = 28; +pub const SIGPROF: c_int = 29; +pub const SIGWINCH: c_int = 20; +pub const SIGUSR1: c_int = 16; +pub const SIGUSR2: c_int = 17; +pub const SIGCONT: c_int = 25; +pub const SIGSTOP: c_int = 23; +pub const SIGTSTP: c_int = 24; +pub const SIGURG: c_int = 21; +pub const SIGIO: c_int = 22; +pub const SIGSYS: c_int = 12; +pub const SIGPOLL: c_int = crate::SIGIO; +pub const SIGPWR: c_int = 19; +pub const SIG_SETMASK: c_int = 3; +pub const SIG_BLOCK: c_int = 1; +pub const SIG_UNBLOCK: c_int = 2; + +pub const EXTPROC: crate::tcflag_t = 0o200000; + +pub const F_GETLK: c_int = 33; +pub const F_GETOWN: c_int = 23; +pub const F_SETLK: c_int = 34; +pub const F_SETLKW: c_int = 35; +pub const F_SETOWN: c_int = 24; + +pub const VEOF: usize = 16; +pub const VEOL: usize = 17; +pub const VEOL2: usize = 6; +pub const VMIN: usize = 4; +pub const IEXTEN: crate::tcflag_t = 0o000400; +pub const TOSTOP: crate::tcflag_t = 0o100000; +pub const FLUSHO: crate::tcflag_t = 0o020000; + +pub const POLLWRNORM: c_short = 0x4; +pub const POLLWRBAND: c_short = 0x100; + +pub const SYS_syscall: c_long = 4000 + 0; +pub const SYS_exit: c_long = 4000 + 1; +pub const SYS_fork: c_long = 4000 + 2; +pub const SYS_read: c_long = 4000 + 3; +pub const SYS_write: c_long = 4000 + 4; +pub const SYS_open: c_long = 4000 + 5; +pub const SYS_close: c_long = 4000 + 6; +pub const SYS_waitpid: c_long = 4000 + 7; +pub const SYS_creat: c_long = 4000 + 8; +pub const SYS_link: c_long = 4000 + 9; +pub const SYS_unlink: c_long = 4000 + 10; +pub const SYS_execve: c_long = 4000 + 11; +pub const SYS_chdir: c_long = 4000 + 12; +pub const SYS_time: c_long = 4000 + 13; +pub const SYS_mknod: c_long = 4000 + 14; +pub const SYS_chmod: c_long = 4000 + 15; +pub const SYS_lchown: c_long = 4000 + 16; +pub const SYS_break: c_long = 4000 + 17; +pub const SYS_lseek: c_long = 4000 + 19; +pub const SYS_getpid: c_long = 4000 + 20; +pub const SYS_mount: c_long = 4000 + 21; +pub const SYS_umount: c_long = 4000 + 22; +pub const SYS_setuid: c_long = 4000 + 23; +pub const SYS_getuid: c_long = 4000 + 24; +pub const SYS_stime: c_long = 4000 + 25; +pub const SYS_ptrace: c_long = 4000 + 26; +pub const SYS_alarm: c_long = 4000 + 27; +pub const SYS_pause: c_long = 4000 + 29; +pub const SYS_utime: c_long = 4000 + 30; +pub const SYS_stty: c_long = 4000 + 31; +pub const SYS_gtty: c_long = 4000 + 32; +pub const SYS_access: c_long = 4000 + 33; +pub const SYS_nice: c_long = 4000 + 34; +pub const SYS_ftime: c_long = 4000 + 35; +pub const SYS_sync: c_long = 4000 + 36; +pub const SYS_kill: c_long = 4000 + 37; +pub const SYS_rename: c_long = 4000 + 38; +pub const SYS_mkdir: c_long = 4000 + 39; +pub const SYS_rmdir: c_long = 4000 + 40; +pub const SYS_dup: c_long = 4000 + 41; +pub const SYS_pipe: c_long = 4000 + 42; +pub const SYS_times: c_long = 4000 + 43; +pub const SYS_prof: c_long = 4000 + 44; +pub const SYS_brk: c_long = 4000 + 45; +pub const SYS_setgid: c_long = 4000 + 46; +pub const SYS_getgid: c_long = 4000 + 47; +pub const SYS_signal: c_long = 4000 + 48; +pub const SYS_geteuid: c_long = 4000 + 49; +pub const SYS_getegid: c_long = 4000 + 50; +pub const SYS_acct: c_long = 4000 + 51; +pub const SYS_umount2: c_long = 4000 + 52; +pub const SYS_lock: c_long = 4000 + 53; +pub const SYS_ioctl: c_long = 4000 + 54; +pub const SYS_fcntl: c_long = 4000 + 55; +pub const SYS_mpx: c_long = 4000 + 56; +pub const SYS_setpgid: c_long = 4000 + 57; +pub const SYS_ulimit: c_long = 4000 + 58; +pub const SYS_umask: c_long = 4000 + 60; +pub const SYS_chroot: c_long = 4000 + 61; +pub const SYS_ustat: c_long = 4000 + 62; +pub const SYS_dup2: c_long = 4000 + 63; +pub const SYS_getppid: c_long = 4000 + 64; +pub const SYS_getpgrp: c_long = 4000 + 65; +pub const SYS_setsid: c_long = 4000 + 66; +pub const SYS_sigaction: c_long = 4000 + 67; +pub const SYS_sgetmask: c_long = 4000 + 68; +pub const SYS_ssetmask: c_long = 4000 + 69; +pub const SYS_setreuid: c_long = 4000 + 70; +pub const SYS_setregid: c_long = 4000 + 71; +pub const SYS_sigsuspend: c_long = 4000 + 72; +pub const SYS_sigpending: c_long = 4000 + 73; +pub const SYS_sethostname: c_long = 4000 + 74; +pub const SYS_setrlimit: c_long = 4000 + 75; +pub const SYS_getrlimit: c_long = 4000 + 76; +pub const SYS_getrusage: c_long = 4000 + 77; +pub const SYS_gettimeofday: c_long = 4000 + 78; +pub const SYS_settimeofday: c_long = 4000 + 79; +pub const SYS_getgroups: c_long = 4000 + 80; +pub const SYS_setgroups: c_long = 4000 + 81; +pub const SYS_symlink: c_long = 4000 + 83; +pub const SYS_readlink: c_long = 4000 + 85; +pub const SYS_uselib: c_long = 4000 + 86; +pub const SYS_swapon: c_long = 4000 + 87; +pub const SYS_reboot: c_long = 4000 + 88; +pub const SYS_readdir: c_long = 4000 + 89; +pub const SYS_mmap: c_long = 4000 + 90; +pub const SYS_munmap: c_long = 4000 + 91; +pub const SYS_truncate: c_long = 4000 + 92; +pub const SYS_ftruncate: c_long = 4000 + 93; +pub const SYS_fchmod: c_long = 4000 + 94; +pub const SYS_fchown: c_long = 4000 + 95; +pub const SYS_getpriority: c_long = 4000 + 96; +pub const SYS_setpriority: c_long = 4000 + 97; +pub const SYS_profil: c_long = 4000 + 98; +pub const SYS_statfs: c_long = 4000 + 99; +pub const SYS_fstatfs: c_long = 4000 + 100; +pub const SYS_ioperm: c_long = 4000 + 101; +pub const SYS_socketcall: c_long = 4000 + 102; +pub const SYS_syslog: c_long = 4000 + 103; +pub const SYS_setitimer: c_long = 4000 + 104; +pub const SYS_getitimer: c_long = 4000 + 105; +pub const SYS_stat: c_long = 4000 + 106; +pub const SYS_lstat: c_long = 4000 + 107; +pub const SYS_fstat: c_long = 4000 + 108; +pub const SYS_iopl: c_long = 4000 + 110; +pub const SYS_vhangup: c_long = 4000 + 111; +pub const SYS_idle: c_long = 4000 + 112; +pub const SYS_vm86: c_long = 4000 + 113; +pub const SYS_wait4: c_long = 4000 + 114; +pub const SYS_swapoff: c_long = 4000 + 115; +pub const SYS_sysinfo: c_long = 4000 + 116; +pub const SYS_ipc: c_long = 4000 + 117; +pub const SYS_fsync: c_long = 4000 + 118; +pub const SYS_sigreturn: c_long = 4000 + 119; +pub const SYS_clone: c_long = 4000 + 120; +pub const SYS_setdomainname: c_long = 4000 + 121; +pub const SYS_uname: c_long = 4000 + 122; +pub const SYS_modify_ldt: c_long = 4000 + 123; +pub const SYS_adjtimex: c_long = 4000 + 124; +pub const SYS_mprotect: c_long = 4000 + 125; +pub const SYS_sigprocmask: c_long = 4000 + 126; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_create_module: c_long = 4000 + 127; +pub const SYS_init_module: c_long = 4000 + 128; +pub const SYS_delete_module: c_long = 4000 + 129; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_get_kernel_syms: c_long = 4000 + 130; +pub const SYS_quotactl: c_long = 4000 + 131; +pub const SYS_getpgid: c_long = 4000 + 132; +pub const SYS_fchdir: c_long = 4000 + 133; +pub const SYS_bdflush: c_long = 4000 + 134; +pub const SYS_sysfs: c_long = 4000 + 135; +pub const SYS_personality: c_long = 4000 + 136; +pub const SYS_afs_syscall: c_long = 4000 + 137; +pub const SYS_setfsuid: c_long = 4000 + 138; +pub const SYS_setfsgid: c_long = 4000 + 139; +pub const SYS__llseek: c_long = 4000 + 140; +pub const SYS_getdents: c_long = 4000 + 141; +pub const SYS_flock: c_long = 4000 + 143; +pub const SYS_msync: c_long = 4000 + 144; +pub const SYS_readv: c_long = 4000 + 145; +pub const SYS_writev: c_long = 4000 + 146; +pub const SYS_cacheflush: c_long = 4000 + 147; +pub const SYS_cachectl: c_long = 4000 + 148; +pub const SYS_sysmips: c_long = 4000 + 149; +pub const SYS_getsid: c_long = 4000 + 151; +pub const SYS_fdatasync: c_long = 4000 + 152; +pub const SYS__sysctl: c_long = 4000 + 153; +pub const SYS_mlock: c_long = 4000 + 154; +pub const SYS_munlock: c_long = 4000 + 155; +pub const SYS_mlockall: c_long = 4000 + 156; +pub const SYS_munlockall: c_long = 4000 + 157; +pub const SYS_sched_setparam: c_long = 4000 + 158; +pub const SYS_sched_getparam: c_long = 4000 + 159; +pub const SYS_sched_setscheduler: c_long = 4000 + 160; +pub const SYS_sched_getscheduler: c_long = 4000 + 161; +pub const SYS_sched_yield: c_long = 4000 + 162; +pub const SYS_sched_get_priority_max: c_long = 4000 + 163; +pub const SYS_sched_get_priority_min: c_long = 4000 + 164; +pub const SYS_sched_rr_get_interval: c_long = 4000 + 165; +pub const SYS_nanosleep: c_long = 4000 + 166; +pub const SYS_mremap: c_long = 4000 + 167; +pub const SYS_accept: c_long = 4000 + 168; +pub const SYS_bind: c_long = 4000 + 169; +pub const SYS_connect: c_long = 4000 + 170; +pub const SYS_getpeername: c_long = 4000 + 171; +pub const SYS_getsockname: c_long = 4000 + 172; +pub const SYS_getsockopt: c_long = 4000 + 173; +pub const SYS_listen: c_long = 4000 + 174; +pub const SYS_recv: c_long = 4000 + 175; +pub const SYS_recvfrom: c_long = 4000 + 176; +pub const SYS_recvmsg: c_long = 4000 + 177; +pub const SYS_send: c_long = 4000 + 178; +pub const SYS_sendmsg: c_long = 4000 + 179; +pub const SYS_sendto: c_long = 4000 + 180; +pub const SYS_setsockopt: c_long = 4000 + 181; +pub const SYS_shutdown: c_long = 4000 + 182; +pub const SYS_socket: c_long = 4000 + 183; +pub const SYS_socketpair: c_long = 4000 + 184; +pub const SYS_setresuid: c_long = 4000 + 185; +pub const SYS_getresuid: c_long = 4000 + 186; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_query_module: c_long = 4000 + 187; +pub const SYS_poll: c_long = 4000 + 188; +pub const SYS_nfsservctl: c_long = 4000 + 189; +pub const SYS_setresgid: c_long = 4000 + 190; +pub const SYS_getresgid: c_long = 4000 + 191; +pub const SYS_prctl: c_long = 4000 + 192; +pub const SYS_rt_sigreturn: c_long = 4000 + 193; +pub const SYS_rt_sigaction: c_long = 4000 + 194; +pub const SYS_rt_sigprocmask: c_long = 4000 + 195; +pub const SYS_rt_sigpending: c_long = 4000 + 196; +pub const SYS_rt_sigtimedwait: c_long = 4000 + 197; +pub const SYS_rt_sigqueueinfo: c_long = 4000 + 198; +pub const SYS_rt_sigsuspend: c_long = 4000 + 199; +pub const SYS_chown: c_long = 4000 + 202; +pub const SYS_getcwd: c_long = 4000 + 203; +pub const SYS_capget: c_long = 4000 + 204; +pub const SYS_capset: c_long = 4000 + 205; +pub const SYS_sigaltstack: c_long = 4000 + 206; +pub const SYS_sendfile: c_long = 4000 + 207; +pub const SYS_getpmsg: c_long = 4000 + 208; +pub const SYS_putpmsg: c_long = 4000 + 209; +pub const SYS_mmap2: c_long = 4000 + 210; +pub const SYS_truncate64: c_long = 4000 + 211; +pub const SYS_ftruncate64: c_long = 4000 + 212; +pub const SYS_stat64: c_long = 4000 + 213; +pub const SYS_lstat64: c_long = 4000 + 214; +pub const SYS_fstat64: c_long = 4000 + 215; +pub const SYS_pivot_root: c_long = 4000 + 216; +pub const SYS_mincore: c_long = 4000 + 217; +pub const SYS_madvise: c_long = 4000 + 218; +pub const SYS_getdents64: c_long = 4000 + 219; +pub const SYS_fcntl64: c_long = 4000 + 220; +pub const SYS_gettid: c_long = 4000 + 222; +pub const SYS_readahead: c_long = 4000 + 223; +pub const SYS_setxattr: c_long = 4000 + 224; +pub const SYS_lsetxattr: c_long = 4000 + 225; +pub const SYS_fsetxattr: c_long = 4000 + 226; +pub const SYS_getxattr: c_long = 4000 + 227; +pub const SYS_lgetxattr: c_long = 4000 + 228; +pub const SYS_fgetxattr: c_long = 4000 + 229; +pub const SYS_listxattr: c_long = 4000 + 230; +pub const SYS_llistxattr: c_long = 4000 + 231; +pub const SYS_flistxattr: c_long = 4000 + 232; +pub const SYS_removexattr: c_long = 4000 + 233; +pub const SYS_lremovexattr: c_long = 4000 + 234; +pub const SYS_fremovexattr: c_long = 4000 + 235; +pub const SYS_tkill: c_long = 4000 + 236; +pub const SYS_sendfile64: c_long = 4000 + 237; +pub const SYS_futex: c_long = 4000 + 238; +pub const SYS_sched_setaffinity: c_long = 4000 + 239; +pub const SYS_sched_getaffinity: c_long = 4000 + 240; +pub const SYS_io_setup: c_long = 4000 + 241; +pub const SYS_io_destroy: c_long = 4000 + 242; +pub const SYS_io_getevents: c_long = 4000 + 243; +pub const SYS_io_submit: c_long = 4000 + 244; +pub const SYS_io_cancel: c_long = 4000 + 245; +pub const SYS_exit_group: c_long = 4000 + 246; +pub const SYS_lookup_dcookie: c_long = 4000 + 247; +pub const SYS_epoll_create: c_long = 4000 + 248; +pub const SYS_epoll_ctl: c_long = 4000 + 249; +pub const SYS_epoll_wait: c_long = 4000 + 250; +pub const SYS_remap_file_pages: c_long = 4000 + 251; +pub const SYS_set_tid_address: c_long = 4000 + 252; +pub const SYS_restart_syscall: c_long = 4000 + 253; +pub const SYS_statfs64: c_long = 4000 + 255; +pub const SYS_fstatfs64: c_long = 4000 + 256; +pub const SYS_timer_create: c_long = 4000 + 257; +pub const SYS_timer_settime: c_long = 4000 + 258; +pub const SYS_timer_gettime: c_long = 4000 + 259; +pub const SYS_timer_getoverrun: c_long = 4000 + 260; +pub const SYS_timer_delete: c_long = 4000 + 261; +pub const SYS_clock_settime: c_long = 4000 + 262; +pub const SYS_clock_gettime: c_long = 4000 + 263; +pub const SYS_clock_getres: c_long = 4000 + 264; +pub const SYS_clock_nanosleep: c_long = 4000 + 265; +pub const SYS_tgkill: c_long = 4000 + 266; +pub const SYS_utimes: c_long = 4000 + 267; +pub const SYS_mbind: c_long = 4000 + 268; +pub const SYS_get_mempolicy: c_long = 4000 + 269; +pub const SYS_set_mempolicy: c_long = 4000 + 270; +pub const SYS_mq_open: c_long = 4000 + 271; +pub const SYS_mq_unlink: c_long = 4000 + 272; +pub const SYS_mq_timedsend: c_long = 4000 + 273; +pub const SYS_mq_timedreceive: c_long = 4000 + 274; +pub const SYS_mq_notify: c_long = 4000 + 275; +pub const SYS_mq_getsetattr: c_long = 4000 + 276; +pub const SYS_vserver: c_long = 4000 + 277; +pub const SYS_waitid: c_long = 4000 + 278; +/* pub const SYS_sys_setaltroot: c_long = 4000 + 279; */ +pub const SYS_add_key: c_long = 4000 + 280; +pub const SYS_request_key: c_long = 4000 + 281; +pub const SYS_keyctl: c_long = 4000 + 282; +pub const SYS_set_thread_area: c_long = 4000 + 283; +pub const SYS_inotify_init: c_long = 4000 + 284; +pub const SYS_inotify_add_watch: c_long = 4000 + 285; +pub const SYS_inotify_rm_watch: c_long = 4000 + 286; +pub const SYS_migrate_pages: c_long = 4000 + 287; +pub const SYS_openat: c_long = 4000 + 288; +pub const SYS_mkdirat: c_long = 4000 + 289; +pub const SYS_mknodat: c_long = 4000 + 290; +pub const SYS_fchownat: c_long = 4000 + 291; +pub const SYS_futimesat: c_long = 4000 + 292; +pub const SYS_unlinkat: c_long = 4000 + 294; +pub const SYS_renameat: c_long = 4000 + 295; +pub const SYS_linkat: c_long = 4000 + 296; +pub const SYS_symlinkat: c_long = 4000 + 297; +pub const SYS_readlinkat: c_long = 4000 + 298; +pub const SYS_fchmodat: c_long = 4000 + 299; +pub const SYS_faccessat: c_long = 4000 + 300; +pub const SYS_pselect6: c_long = 4000 + 301; +pub const SYS_ppoll: c_long = 4000 + 302; +pub const SYS_unshare: c_long = 4000 + 303; +pub const SYS_splice: c_long = 4000 + 304; +pub const SYS_sync_file_range: c_long = 4000 + 305; +pub const SYS_tee: c_long = 4000 + 306; +pub const SYS_vmsplice: c_long = 4000 + 307; +pub const SYS_move_pages: c_long = 4000 + 308; +pub const SYS_set_robust_list: c_long = 4000 + 309; +pub const SYS_get_robust_list: c_long = 4000 + 310; +pub const SYS_kexec_load: c_long = 4000 + 311; +pub const SYS_getcpu: c_long = 4000 + 312; +pub const SYS_epoll_pwait: c_long = 4000 + 313; +pub const SYS_ioprio_set: c_long = 4000 + 314; +pub const SYS_ioprio_get: c_long = 4000 + 315; +pub const SYS_utimensat: c_long = 4000 + 316; +pub const SYS_signalfd: c_long = 4000 + 317; +pub const SYS_timerfd: c_long = 4000 + 318; +pub const SYS_eventfd: c_long = 4000 + 319; +pub const SYS_fallocate: c_long = 4000 + 320; +pub const SYS_timerfd_create: c_long = 4000 + 321; +pub const SYS_timerfd_gettime: c_long = 4000 + 322; +pub const SYS_timerfd_settime: c_long = 4000 + 323; +pub const SYS_signalfd4: c_long = 4000 + 324; +pub const SYS_eventfd2: c_long = 4000 + 325; +pub const SYS_epoll_create1: c_long = 4000 + 326; +pub const SYS_dup3: c_long = 4000 + 327; +pub const SYS_pipe2: c_long = 4000 + 328; +pub const SYS_inotify_init1: c_long = 4000 + 329; +pub const SYS_preadv: c_long = 4000 + 330; +pub const SYS_pwritev: c_long = 4000 + 331; +pub const SYS_rt_tgsigqueueinfo: c_long = 4000 + 332; +pub const SYS_perf_event_open: c_long = 4000 + 333; +pub const SYS_accept4: c_long = 4000 + 334; +pub const SYS_recvmmsg: c_long = 4000 + 335; +pub const SYS_fanotify_init: c_long = 4000 + 336; +pub const SYS_fanotify_mark: c_long = 4000 + 337; +pub const SYS_prlimit64: c_long = 4000 + 338; +pub const SYS_name_to_handle_at: c_long = 4000 + 339; +pub const SYS_open_by_handle_at: c_long = 4000 + 340; +pub const SYS_clock_adjtime: c_long = 4000 + 341; +pub const SYS_syncfs: c_long = 4000 + 342; +pub const SYS_sendmmsg: c_long = 4000 + 343; +pub const SYS_setns: c_long = 4000 + 344; +pub const SYS_process_vm_readv: c_long = 4000 + 345; +pub const SYS_process_vm_writev: c_long = 4000 + 346; +pub const SYS_kcmp: c_long = 4000 + 347; +pub const SYS_finit_module: c_long = 4000 + 348; +pub const SYS_sched_setattr: c_long = 4000 + 349; +pub const SYS_sched_getattr: c_long = 4000 + 350; +pub const SYS_renameat2: c_long = 4000 + 351; +pub const SYS_seccomp: c_long = 4000 + 352; +pub const SYS_getrandom: c_long = 4000 + 353; +pub const SYS_memfd_create: c_long = 4000 + 354; +pub const SYS_bpf: c_long = 4000 + 355; +pub const SYS_execveat: c_long = 4000 + 356; +pub const SYS_userfaultfd: c_long = 4000 + 357; +pub const SYS_membarrier: c_long = 4000 + 358; +pub const SYS_mlock2: c_long = 4000 + 359; +pub const SYS_copy_file_range: c_long = 4000 + 360; +pub const SYS_preadv2: c_long = 4000 + 361; +pub const SYS_pwritev2: c_long = 4000 + 362; +pub const SYS_pkey_mprotect: c_long = 4000 + 363; +pub const SYS_pkey_alloc: c_long = 4000 + 364; +pub const SYS_pkey_free: c_long = 4000 + 365; +pub const SYS_statx: c_long = 4000 + 366; +pub const SYS_pidfd_send_signal: c_long = 4000 + 424; +pub const SYS_io_uring_setup: c_long = 4000 + 425; +pub const SYS_io_uring_enter: c_long = 4000 + 426; +pub const SYS_io_uring_register: c_long = 4000 + 427; +pub const SYS_open_tree: c_long = 4000 + 428; +pub const SYS_move_mount: c_long = 4000 + 429; +pub const SYS_fsopen: c_long = 4000 + 430; +pub const SYS_fsconfig: c_long = 4000 + 431; +pub const SYS_fsmount: c_long = 4000 + 432; +pub const SYS_fspick: c_long = 4000 + 433; +pub const SYS_pidfd_open: c_long = 4000 + 434; +pub const SYS_clone3: c_long = 4000 + 435; +pub const SYS_close_range: c_long = 4000 + 436; +pub const SYS_openat2: c_long = 4000 + 437; +pub const SYS_pidfd_getfd: c_long = 4000 + 438; +pub const SYS_faccessat2: c_long = 4000 + 439; +pub const SYS_process_madvise: c_long = 4000 + 440; +pub const SYS_epoll_pwait2: c_long = 4000 + 441; +pub const SYS_mount_setattr: c_long = 4000 + 442; +pub const SYS_quotactl_fd: c_long = 4000 + 443; +pub const SYS_landlock_create_ruleset: c_long = 4000 + 444; +pub const SYS_landlock_add_rule: c_long = 4000 + 445; +pub const SYS_landlock_restrict_self: c_long = 4000 + 446; +pub const SYS_memfd_secret: c_long = 4000 + 447; +pub const SYS_process_mrelease: c_long = 4000 + 448; +pub const SYS_futex_waitv: c_long = 4000 + 449; +pub const SYS_set_mempolicy_home_node: c_long = 4000 + 450; diff --git a/http/vendor/libc/src/unix/linux_like/linux/musl/b32/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/musl/b32/mod.rs new file mode 100644 index 0000000..ac76d3c --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/musl/b32/mod.rs @@ -0,0 +1,49 @@ +use crate::prelude::*; + +pub type nlink_t = u32; +pub type blksize_t = c_long; +pub type __u64 = c_ulonglong; +pub type __s64 = c_longlong; +pub type regoff_t = c_int; + +s! { + pub struct pthread_attr_t { + __size: [u32; 9], + } + + pub struct sigset_t { + __val: [c_ulong; 32], + } + + pub struct sem_t { + __val: [c_int; 4], + } +} + +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; +pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 20; + +cfg_if! { + if #[cfg(any(target_arch = "x86"))] { + mod x86; + pub use self::x86::*; + } else if #[cfg(any(target_arch = "mips"))] { + mod mips; + pub use self::mips::*; + } else if #[cfg(any(target_arch = "arm"))] { + mod arm; + pub use self::arm::*; + } else if #[cfg(any(target_arch = "powerpc"))] { + mod powerpc; + pub use self::powerpc::*; + } else if #[cfg(any(target_arch = "hexagon"))] { + mod hexagon; + pub use self::hexagon::*; + } else if #[cfg(any(target_arch = "riscv32"))] { + mod riscv32; + pub use self::riscv32::*; + } else { + // Unknown target_arch + } +} diff --git a/http/vendor/libc/src/unix/linux_like/linux/musl/b32/powerpc.rs b/http/vendor/libc/src/unix/linux_like/linux/musl/b32/powerpc.rs new file mode 100644 index 0000000..f0d92c0 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/musl/b32/powerpc.rs @@ -0,0 +1,835 @@ +use crate::off_t; +use crate::prelude::*; + +pub type wchar_t = i32; + +pub type stat64 = stat; + +s! { + pub struct termios { + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_cc: [crate::cc_t; crate::NCCS], + pub c_line: crate::cc_t, + pub __c_ispeed: crate::speed_t, + pub __c_ospeed: crate::speed_t, + } + + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + __st_rdev_padding: Padding, + pub st_size: off_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + + #[cfg(musl32_time64)] + __st_atim32: Padding<__c_anonymous_timespec32>, + #[cfg(musl32_time64)] + __st_mtim32: Padding<__c_anonymous_timespec32>, + #[cfg(musl32_time64)] + __st_ctim32: Padding<__c_anonymous_timespec32>, + + #[cfg(musl_v1_2_3)] + __unused: Padding<[c_long; 2]>, + + pub st_atime: crate::time_t, + #[cfg(all(musl32_time64, target_endian = "big"))] + __pad0: Padding, + pub st_atime_nsec: c_long, + #[cfg(all(musl32_time64, target_endian = "little"))] + __pad0: Padding, + pub st_mtime: crate::time_t, + #[cfg(all(musl32_time64, target_endian = "big"))] + __pad1: Padding, + pub st_mtime_nsec: c_long, + #[cfg(all(musl32_time64, target_endian = "little"))] + __pad1: Padding, + pub st_ctime: crate::time_t, + #[cfg(all(musl32_time64, target_endian = "big"))] + __pad2: Padding, + pub st_ctime_nsec: c_long, + #[cfg(all(musl32_time64, target_endian = "little"))] + __pad2: Padding, + + #[cfg(not(musl_v1_2_3))] + __unused: Padding<[c_long; 2]>, + } + + struct __c_anonymous_timespec32 { + __tv_sec: c_long, + __tv_nsec: c_long, + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_flags: c_int, + pub ss_size: size_t, + } + + pub struct ipc_perm { + #[cfg(musl_v1_2_3)] + pub __key: crate::key_t, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "This field is incorrectly named and will be changed + to __key in a future release." + )] + pub __ipc_perm_key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: crate::mode_t, + pub __seq: c_int, + __pad1: Padding, + __pad2: Padding, + __pad3: Padding, + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + + #[cfg(musl32_time64)] + __shm_atime_hi: Padding, + #[cfg(musl32_time64)] + __shm_atime_lo: Padding, + #[cfg(musl32_time64)] + __shm_dtime_hi: Padding, + #[cfg(musl32_time64)] + __shm_dtime_lo: Padding, + #[cfg(musl32_time64)] + __shm_ctime_hi: Padding, + #[cfg(musl32_time64)] + __shm_ctime_lo: Padding, + + #[cfg(not(musl32_time64))] + __unused1: Padding, + #[cfg(not(musl32_time64))] + pub shm_atime: crate::time_t, + #[cfg(not(musl32_time64))] + __unused2: Padding, + #[cfg(not(musl32_time64))] + pub shm_dtime: crate::time_t, + #[cfg(not(musl32_time64))] + __unused3: Padding, + #[cfg(not(musl32_time64))] + pub shm_ctime: crate::time_t, + #[cfg(not(musl32_time64))] + __unused4: Padding, + + #[cfg(musl32_time64)] + __pad1: Padding, + + pub shm_segsz: size_t, + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: c_ulong, + #[cfg(not(musl32_time64))] + __pad1: Padding, + __pad2: Padding, + + #[cfg(musl32_time64)] + pub shm_atime: crate::time_t, + #[cfg(musl32_time64)] + pub shm_dtime: crate::time_t, + #[cfg(musl32_time64)] + pub shm_ctime: crate::time_t, + } + + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + + #[cfg(musl32_time64)] + __msg_stime_hi: Padding, + #[cfg(musl32_time64)] + __msg_stime_lo: Padding, + #[cfg(musl32_time64)] + __msg_rtime_hi: Padding, + #[cfg(musl32_time64)] + __msg_rtime_lo: Padding, + #[cfg(musl32_time64)] + __msg_ctime_hi: Padding, + #[cfg(musl32_time64)] + __msg_ctime_lo: Padding, + + #[cfg(not(musl32_time64))] + __unused1: Padding, + #[cfg(not(musl32_time64))] + pub msg_stime: crate::time_t, + #[cfg(not(musl32_time64))] + __unused2: Padding, + #[cfg(not(musl32_time64))] + pub msg_rtime: crate::time_t, + #[cfg(not(musl32_time64))] + __unused3: Padding, + #[cfg(not(musl32_time64))] + pub msg_ctime: crate::time_t, + + pub __msg_cbytes: c_ulong, + pub msg_qnum: crate::msgqnum_t, + pub msg_qbytes: crate::msglen_t, + pub msg_lspid: crate::pid_t, + pub msg_lrpid: crate::pid_t, + __pad1: Padding, + __pad2: Padding, + + #[cfg(musl32_time64)] + pub msg_stime: crate::time_t, + #[cfg(musl32_time64)] + pub msg_rtime: crate::time_t, + #[cfg(musl32_time64)] + pub msg_ctime: crate::time_t, + } +} + +pub const MADV_SOFT_OFFLINE: c_int = 101; +pub const SIGSTKSZ: size_t = 10240; +pub const MINSIGSTKSZ: size_t = 4096; + +pub const O_DIRECT: c_int = 0x20000; +pub const O_DIRECTORY: c_int = 0x4000; +pub const O_NOFOLLOW: c_int = 0x8000; +pub const O_ASYNC: c_int = 0x2000; +pub const O_LARGEFILE: c_int = 0x10000; + +pub const MCL_CURRENT: c_int = 0x2000; +pub const MCL_FUTURE: c_int = 0x4000; +pub const MCL_ONFAULT: c_int = 0x8000; +pub const CBAUD: crate::tcflag_t = 0o0000377; +pub const TAB1: c_int = 0x00000400; +pub const TAB2: c_int = 0x00000800; +pub const TAB3: c_int = 0x00000C00; +pub const CR1: c_int = 0x00001000; +pub const CR2: c_int = 0x00002000; +pub const CR3: c_int = 0x00003000; +pub const FF1: c_int = 0x00004000; +pub const BS1: c_int = 0x00008000; +pub const VT1: c_int = 0x00010000; +pub const VWERASE: usize = 10; +pub const VREPRINT: usize = 11; +pub const VSUSP: usize = 12; +pub const VSTART: usize = 13; +pub const VSTOP: usize = 14; +pub const VDISCARD: usize = 16; +pub const VTIME: usize = 7; +pub const IXON: crate::tcflag_t = 0x00000200; +pub const IXOFF: crate::tcflag_t = 0x00000400; +pub const ONLCR: crate::tcflag_t = 0x00000002; +pub const CSIZE: crate::tcflag_t = 0x00000300; +pub const CS6: crate::tcflag_t = 0x00000100; +pub const CS7: crate::tcflag_t = 0x00000200; +pub const CS8: crate::tcflag_t = 0x00000300; +pub const CSTOPB: crate::tcflag_t = 0x00000400; +pub const CREAD: crate::tcflag_t = 0x00000800; +pub const PARENB: crate::tcflag_t = 0x00001000; +pub const PARODD: crate::tcflag_t = 0x00002000; +pub const HUPCL: crate::tcflag_t = 0x00004000; +pub const CLOCAL: crate::tcflag_t = 0x00008000; +pub const ECHOKE: crate::tcflag_t = 0x00000001; +pub const ECHOE: crate::tcflag_t = 0x00000002; +pub const ECHOK: crate::tcflag_t = 0x00000004; +pub const ECHONL: crate::tcflag_t = 0x00000010; +pub const ECHOPRT: crate::tcflag_t = 0x00000020; +pub const ECHOCTL: crate::tcflag_t = 0x00000040; +pub const ISIG: crate::tcflag_t = 0x00000080; +pub const ICANON: crate::tcflag_t = 0x00000100; +pub const PENDIN: crate::tcflag_t = 0x20000000; +pub const NOFLSH: crate::tcflag_t = 0x80000000; +pub const CIBAUD: crate::tcflag_t = 0o00077600000; +pub const CBAUDEX: crate::tcflag_t = 0o000020; +pub const VSWTC: usize = 9; +pub const OLCUC: crate::tcflag_t = 0o000004; +pub const NLDLY: crate::tcflag_t = 0o001400; +pub const CRDLY: crate::tcflag_t = 0o030000; +pub const TABDLY: crate::tcflag_t = 0o006000; +pub const BSDLY: crate::tcflag_t = 0o100000; +pub const FFDLY: crate::tcflag_t = 0o040000; +pub const VTDLY: crate::tcflag_t = 0o200000; +pub const XTABS: crate::tcflag_t = 0o006000; +pub const B57600: crate::speed_t = 0o000020; +pub const B115200: crate::speed_t = 0o000021; +pub const B230400: crate::speed_t = 0o000022; +pub const B460800: crate::speed_t = 0o000023; +pub const B500000: crate::speed_t = 0o000024; +pub const B576000: crate::speed_t = 0o000025; +pub const B921600: crate::speed_t = 0o000026; +pub const B1000000: crate::speed_t = 0o000027; +pub const B1152000: crate::speed_t = 0o000030; +pub const B1500000: crate::speed_t = 0o000031; +pub const B2000000: crate::speed_t = 0o000032; +pub const B2500000: crate::speed_t = 0o000033; +pub const B3000000: crate::speed_t = 0o000034; +pub const B3500000: crate::speed_t = 0o000035; +pub const B4000000: crate::speed_t = 0o000036; + +pub const O_APPEND: c_int = 1024; +pub const O_CREAT: c_int = 64; +pub const O_EXCL: c_int = 128; +pub const O_NOCTTY: c_int = 256; +pub const O_NONBLOCK: c_int = 2048; +pub const O_SYNC: c_int = 1052672; +pub const O_RSYNC: c_int = 1052672; +pub const O_DSYNC: c_int = 4096; + +pub const MAP_ANON: c_int = 0x0020; +pub const MAP_GROWSDOWN: c_int = 0x0100; +pub const MAP_DENYWRITE: c_int = 0x0800; +pub const MAP_EXECUTABLE: c_int = 0x01000; +pub const MAP_LOCKED: c_int = 0x00080; +pub const MAP_NORESERVE: c_int = 0x00040; +pub const MAP_POPULATE: c_int = 0x08000; +pub const MAP_NONBLOCK: c_int = 0x010000; +pub const MAP_STACK: c_int = 0x020000; +pub const MAP_HUGETLB: c_int = 0x040000; +pub const MAP_SYNC: c_int = 0x080000; + +pub const PTRACE_SYSEMU: c_int = 0x1d; +pub const PTRACE_SYSEMU_SINGLESTEP: c_int = 0x1e; + +pub const EDEADLK: c_int = 35; +pub const ENAMETOOLONG: c_int = 36; +pub const ENOLCK: c_int = 37; +pub const ENOSYS: c_int = 38; +pub const ENOTEMPTY: c_int = 39; +pub const ELOOP: c_int = 40; +pub const ENOMSG: c_int = 42; +pub const EIDRM: c_int = 43; +pub const ECHRNG: c_int = 44; +pub const EL2NSYNC: c_int = 45; +pub const EL3HLT: c_int = 46; +pub const EL3RST: c_int = 47; +pub const ELNRNG: c_int = 48; +pub const EUNATCH: c_int = 49; +pub const ENOCSI: c_int = 50; +pub const EL2HLT: c_int = 51; +pub const EBADE: c_int = 52; +pub const EBADR: c_int = 53; +pub const EXFULL: c_int = 54; +pub const ENOANO: c_int = 55; +pub const EBADRQC: c_int = 56; +pub const EBADSLT: c_int = 57; +pub const EDEADLOCK: c_int = 58; +pub const EMULTIHOP: c_int = 72; +pub const EBADMSG: c_int = 74; +pub const EOVERFLOW: c_int = 75; +pub const ENOTUNIQ: c_int = 76; +pub const EBADFD: c_int = 77; +pub const EREMCHG: c_int = 78; +pub const ELIBACC: c_int = 79; +pub const ELIBBAD: c_int = 80; +pub const ELIBSCN: c_int = 81; +pub const ELIBMAX: c_int = 82; +pub const ELIBEXEC: c_int = 83; +pub const EILSEQ: c_int = 84; +pub const ERESTART: c_int = 85; +pub const ESTRPIPE: c_int = 86; +pub const EUSERS: c_int = 87; +pub const ENOTSOCK: c_int = 88; +pub const EDESTADDRREQ: c_int = 89; +pub const EMSGSIZE: c_int = 90; +pub const EPROTOTYPE: c_int = 91; +pub const ENOPROTOOPT: c_int = 92; +pub const EPROTONOSUPPORT: c_int = 93; +pub const ESOCKTNOSUPPORT: c_int = 94; +pub const EOPNOTSUPP: c_int = 95; +pub const ENOTSUP: c_int = EOPNOTSUPP; +pub const EPFNOSUPPORT: c_int = 96; +pub const EAFNOSUPPORT: c_int = 97; +pub const EADDRINUSE: c_int = 98; +pub const EADDRNOTAVAIL: c_int = 99; +pub const ENETDOWN: c_int = 100; +pub const ENETUNREACH: c_int = 101; +pub const ENETRESET: c_int = 102; +pub const ECONNABORTED: c_int = 103; +pub const ECONNRESET: c_int = 104; +pub const ENOBUFS: c_int = 105; +pub const EISCONN: c_int = 106; +pub const ENOTCONN: c_int = 107; +pub const ESHUTDOWN: c_int = 108; +pub const ETOOMANYREFS: c_int = 109; +pub const ETIMEDOUT: c_int = 110; +pub const ECONNREFUSED: c_int = 111; +pub const EHOSTDOWN: c_int = 112; +pub const EHOSTUNREACH: c_int = 113; +pub const EALREADY: c_int = 114; +pub const EINPROGRESS: c_int = 115; +pub const ESTALE: c_int = 116; +pub const EUCLEAN: c_int = 117; +pub const ENOTNAM: c_int = 118; +pub const ENAVAIL: c_int = 119; +pub const EISNAM: c_int = 120; +pub const EREMOTEIO: c_int = 121; +pub const EDQUOT: c_int = 122; +pub const ENOMEDIUM: c_int = 123; +pub const EMEDIUMTYPE: c_int = 124; +pub const ECANCELED: c_int = 125; +pub const ENOKEY: c_int = 126; +pub const EKEYEXPIRED: c_int = 127; +pub const EKEYREVOKED: c_int = 128; +pub const EKEYREJECTED: c_int = 129; +pub const EOWNERDEAD: c_int = 130; +pub const ENOTRECOVERABLE: c_int = 131; +pub const ERFKILL: c_int = 132; +pub const EHWPOISON: c_int = 133; + +pub const SA_ONSTACK: c_int = 0x08000000; +pub const SA_SIGINFO: c_int = 0x00000004; +pub const SA_NOCLDWAIT: c_int = 0x00000002; + +pub const SIGCHLD: c_int = 17; +pub const SIGBUS: c_int = 7; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGUSR1: c_int = 10; +pub const SIGUSR2: c_int = 12; +pub const SIGCONT: c_int = 18; +pub const SIGSTOP: c_int = 19; +pub const SIGTSTP: c_int = 20; +pub const SIGURG: c_int = 23; +pub const SIGIO: c_int = 29; +pub const SIGSYS: c_int = 31; +pub const SIGSTKFLT: c_int = 16; +pub const SIGPOLL: c_int = 29; +pub const SIGPWR: c_int = 30; +pub const SIG_SETMASK: c_int = 2; +pub const SIG_BLOCK: c_int = 0x000000; +pub const SIG_UNBLOCK: c_int = 0x01; + +pub const EXTPROC: crate::tcflag_t = 0x10000000; + +pub const F_GETLK: c_int = 12; +pub const F_GETOWN: c_int = 9; +pub const F_SETLK: c_int = 13; +pub const F_SETLKW: c_int = 14; +pub const F_SETOWN: c_int = 8; + +pub const VEOF: usize = 4; +pub const VEOL: usize = 6; +pub const VEOL2: usize = 8; +pub const VMIN: usize = 5; +pub const IEXTEN: crate::tcflag_t = 0x00000400; +pub const TOSTOP: crate::tcflag_t = 0x00400000; +pub const FLUSHO: crate::tcflag_t = 0x00800000; + +pub const POLLWRNORM: c_short = 0x100; +pub const POLLWRBAND: c_short = 0x200; + +// Syscall table +pub const SYS_restart_syscall: c_long = 0; +pub const SYS_exit: c_long = 1; +pub const SYS_fork: c_long = 2; +pub const SYS_read: c_long = 3; +pub const SYS_write: c_long = 4; +pub const SYS_open: c_long = 5; +pub const SYS_close: c_long = 6; +pub const SYS_waitpid: c_long = 7; +pub const SYS_creat: c_long = 8; +pub const SYS_link: c_long = 9; +pub const SYS_unlink: c_long = 10; +pub const SYS_execve: c_long = 11; +pub const SYS_chdir: c_long = 12; +pub const SYS_time: c_long = 13; +pub const SYS_mknod: c_long = 14; +pub const SYS_chmod: c_long = 15; +pub const SYS_lchown: c_long = 16; +pub const SYS_break: c_long = 17; +pub const SYS_oldstat: c_long = 18; +pub const SYS_lseek: c_long = 19; +pub const SYS_getpid: c_long = 20; +pub const SYS_mount: c_long = 21; +pub const SYS_umount: c_long = 22; +pub const SYS_setuid: c_long = 23; +pub const SYS_getuid: c_long = 24; +pub const SYS_stime: c_long = 25; +pub const SYS_ptrace: c_long = 26; +pub const SYS_alarm: c_long = 27; +pub const SYS_oldfstat: c_long = 28; +pub const SYS_pause: c_long = 29; +pub const SYS_utime: c_long = 30; +pub const SYS_stty: c_long = 31; +pub const SYS_gtty: c_long = 32; +pub const SYS_access: c_long = 33; +pub const SYS_nice: c_long = 34; +pub const SYS_ftime: c_long = 35; +pub const SYS_sync: c_long = 36; +pub const SYS_kill: c_long = 37; +pub const SYS_rename: c_long = 38; +pub const SYS_mkdir: c_long = 39; +pub const SYS_rmdir: c_long = 40; +pub const SYS_dup: c_long = 41; +pub const SYS_pipe: c_long = 42; +pub const SYS_times: c_long = 43; +pub const SYS_prof: c_long = 44; +pub const SYS_brk: c_long = 45; +pub const SYS_setgid: c_long = 46; +pub const SYS_getgid: c_long = 47; +pub const SYS_signal: c_long = 48; +pub const SYS_geteuid: c_long = 49; +pub const SYS_getegid: c_long = 50; +pub const SYS_acct: c_long = 51; +pub const SYS_umount2: c_long = 52; +pub const SYS_lock: c_long = 53; +pub const SYS_ioctl: c_long = 54; +pub const SYS_fcntl: c_long = 55; +pub const SYS_mpx: c_long = 56; +pub const SYS_setpgid: c_long = 57; +pub const SYS_ulimit: c_long = 58; +pub const SYS_oldolduname: c_long = 59; +pub const SYS_umask: c_long = 60; +pub const SYS_chroot: c_long = 61; +pub const SYS_ustat: c_long = 62; +pub const SYS_dup2: c_long = 63; +pub const SYS_getppid: c_long = 64; +pub const SYS_getpgrp: c_long = 65; +pub const SYS_setsid: c_long = 66; +pub const SYS_sigaction: c_long = 67; +pub const SYS_sgetmask: c_long = 68; +pub const SYS_ssetmask: c_long = 69; +pub const SYS_setreuid: c_long = 70; +pub const SYS_setregid: c_long = 71; +pub const SYS_sigsuspend: c_long = 72; +pub const SYS_sigpending: c_long = 73; +pub const SYS_sethostname: c_long = 74; +pub const SYS_setrlimit: c_long = 75; +pub const SYS_getrlimit: c_long = 76; +pub const SYS_getrusage: c_long = 77; +pub const SYS_gettimeofday: c_long = 78; +pub const SYS_settimeofday: c_long = 79; +pub const SYS_getgroups: c_long = 80; +pub const SYS_setgroups: c_long = 81; +pub const SYS_select: c_long = 82; +pub const SYS_symlink: c_long = 83; +pub const SYS_oldlstat: c_long = 84; +pub const SYS_readlink: c_long = 85; +pub const SYS_uselib: c_long = 86; +pub const SYS_swapon: c_long = 87; +pub const SYS_reboot: c_long = 88; +pub const SYS_readdir: c_long = 89; +pub const SYS_mmap: c_long = 90; +pub const SYS_munmap: c_long = 91; +pub const SYS_truncate: c_long = 92; +pub const SYS_ftruncate: c_long = 93; +pub const SYS_fchmod: c_long = 94; +pub const SYS_fchown: c_long = 95; +pub const SYS_getpriority: c_long = 96; +pub const SYS_setpriority: c_long = 97; +pub const SYS_profil: c_long = 98; +pub const SYS_statfs: c_long = 99; +pub const SYS_fstatfs: c_long = 100; +pub const SYS_ioperm: c_long = 101; +pub const SYS_socketcall: c_long = 102; +pub const SYS_syslog: c_long = 103; +pub const SYS_setitimer: c_long = 104; +pub const SYS_getitimer: c_long = 105; +pub const SYS_stat: c_long = 106; +pub const SYS_lstat: c_long = 107; +pub const SYS_fstat: c_long = 108; +pub const SYS_olduname: c_long = 109; +pub const SYS_iopl: c_long = 110; +pub const SYS_vhangup: c_long = 111; +pub const SYS_idle: c_long = 112; +pub const SYS_vm86: c_long = 113; +pub const SYS_wait4: c_long = 114; +pub const SYS_swapoff: c_long = 115; +pub const SYS_sysinfo: c_long = 116; +pub const SYS_ipc: c_long = 117; +pub const SYS_fsync: c_long = 118; +pub const SYS_sigreturn: c_long = 119; +pub const SYS_clone: c_long = 120; +pub const SYS_setdomainname: c_long = 121; +pub const SYS_uname: c_long = 122; +pub const SYS_modify_ldt: c_long = 123; +pub const SYS_adjtimex: c_long = 124; +pub const SYS_mprotect: c_long = 125; +pub const SYS_sigprocmask: c_long = 126; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_create_module: c_long = 127; +pub const SYS_init_module: c_long = 128; +pub const SYS_delete_module: c_long = 129; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_get_kernel_syms: c_long = 130; +pub const SYS_quotactl: c_long = 131; +pub const SYS_getpgid: c_long = 132; +pub const SYS_fchdir: c_long = 133; +pub const SYS_bdflush: c_long = 134; +pub const SYS_sysfs: c_long = 135; +pub const SYS_personality: c_long = 136; +pub const SYS_afs_syscall: c_long = 137; +pub const SYS_setfsuid: c_long = 138; +pub const SYS_setfsgid: c_long = 139; +pub const SYS__llseek: c_long = 140; +pub const SYS_getdents: c_long = 141; +pub const SYS__newselect: c_long = 142; +pub const SYS_flock: c_long = 143; +pub const SYS_msync: c_long = 144; +pub const SYS_readv: c_long = 145; +pub const SYS_writev: c_long = 146; +pub const SYS_getsid: c_long = 147; +pub const SYS_fdatasync: c_long = 148; +pub const SYS__sysctl: c_long = 149; +pub const SYS_mlock: c_long = 150; +pub const SYS_munlock: c_long = 151; +pub const SYS_mlockall: c_long = 152; +pub const SYS_munlockall: c_long = 153; +pub const SYS_sched_setparam: c_long = 154; +pub const SYS_sched_getparam: c_long = 155; +pub const SYS_sched_setscheduler: c_long = 156; +pub const SYS_sched_getscheduler: c_long = 157; +pub const SYS_sched_yield: c_long = 158; +pub const SYS_sched_get_priority_max: c_long = 159; +pub const SYS_sched_get_priority_min: c_long = 160; +pub const SYS_sched_rr_get_interval: c_long = 161; +pub const SYS_nanosleep: c_long = 162; +pub const SYS_mremap: c_long = 163; +pub const SYS_setresuid: c_long = 164; +pub const SYS_getresuid: c_long = 165; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_query_module: c_long = 166; +pub const SYS_poll: c_long = 167; +pub const SYS_nfsservctl: c_long = 168; +pub const SYS_setresgid: c_long = 169; +pub const SYS_getresgid: c_long = 170; +pub const SYS_prctl: c_long = 171; +pub const SYS_rt_sigreturn: c_long = 172; +pub const SYS_rt_sigaction: c_long = 173; +pub const SYS_rt_sigprocmask: c_long = 174; +pub const SYS_rt_sigpending: c_long = 175; +pub const SYS_rt_sigtimedwait: c_long = 176; +pub const SYS_rt_sigqueueinfo: c_long = 177; +pub const SYS_rt_sigsuspend: c_long = 178; +pub const SYS_pread64: c_long = 179; +pub const SYS_pwrite64: c_long = 180; +pub const SYS_chown: c_long = 181; +pub const SYS_getcwd: c_long = 182; +pub const SYS_capget: c_long = 183; +pub const SYS_capset: c_long = 184; +pub const SYS_sigaltstack: c_long = 185; +pub const SYS_sendfile: c_long = 186; +pub const SYS_getpmsg: c_long = 187; +pub const SYS_putpmsg: c_long = 188; +pub const SYS_vfork: c_long = 189; +pub const SYS_ugetrlimit: c_long = 190; +pub const SYS_readahead: c_long = 191; +pub const SYS_mmap2: c_long = 192; +pub const SYS_truncate64: c_long = 193; +pub const SYS_ftruncate64: c_long = 194; +pub const SYS_stat64: c_long = 195; +pub const SYS_lstat64: c_long = 196; +pub const SYS_fstat64: c_long = 197; +pub const SYS_pciconfig_read: c_long = 198; +pub const SYS_pciconfig_write: c_long = 199; +pub const SYS_pciconfig_iobase: c_long = 200; +pub const SYS_multiplexer: c_long = 201; +pub const SYS_getdents64: c_long = 202; +pub const SYS_pivot_root: c_long = 203; +pub const SYS_fcntl64: c_long = 204; +pub const SYS_madvise: c_long = 205; +pub const SYS_mincore: c_long = 206; +pub const SYS_gettid: c_long = 207; +pub const SYS_tkill: c_long = 208; +pub const SYS_setxattr: c_long = 209; +pub const SYS_lsetxattr: c_long = 210; +pub const SYS_fsetxattr: c_long = 211; +pub const SYS_getxattr: c_long = 212; +pub const SYS_lgetxattr: c_long = 213; +pub const SYS_fgetxattr: c_long = 214; +pub const SYS_listxattr: c_long = 215; +pub const SYS_llistxattr: c_long = 216; +pub const SYS_flistxattr: c_long = 217; +pub const SYS_removexattr: c_long = 218; +pub const SYS_lremovexattr: c_long = 219; +pub const SYS_fremovexattr: c_long = 220; +pub const SYS_futex: c_long = 221; +pub const SYS_sched_setaffinity: c_long = 222; +pub const SYS_sched_getaffinity: c_long = 223; +pub const SYS_tuxcall: c_long = 225; +pub const SYS_sendfile64: c_long = 226; +pub const SYS_io_setup: c_long = 227; +pub const SYS_io_destroy: c_long = 228; +pub const SYS_io_getevents: c_long = 229; +pub const SYS_io_submit: c_long = 230; +pub const SYS_io_cancel: c_long = 231; +pub const SYS_set_tid_address: c_long = 232; +pub const SYS_fadvise64: c_long = 233; +pub const SYS_exit_group: c_long = 234; +pub const SYS_lookup_dcookie: c_long = 235; +pub const SYS_epoll_create: c_long = 236; +pub const SYS_epoll_ctl: c_long = 237; +pub const SYS_epoll_wait: c_long = 238; +pub const SYS_remap_file_pages: c_long = 239; +pub const SYS_timer_create: c_long = 240; +pub const SYS_timer_settime: c_long = 241; +pub const SYS_timer_gettime: c_long = 242; +pub const SYS_timer_getoverrun: c_long = 243; +pub const SYS_timer_delete: c_long = 244; +pub const SYS_clock_settime: c_long = 245; +pub const SYS_clock_gettime: c_long = 246; +pub const SYS_clock_getres: c_long = 247; +pub const SYS_clock_nanosleep: c_long = 248; +pub const SYS_swapcontext: c_long = 249; +pub const SYS_tgkill: c_long = 250; +pub const SYS_utimes: c_long = 251; +pub const SYS_statfs64: c_long = 252; +pub const SYS_fstatfs64: c_long = 253; +pub const SYS_fadvise64_64: c_long = 254; +pub const SYS_rtas: c_long = 255; +pub const SYS_sys_debug_setcontext: c_long = 256; +pub const SYS_migrate_pages: c_long = 258; +pub const SYS_mbind: c_long = 259; +pub const SYS_get_mempolicy: c_long = 260; +pub const SYS_set_mempolicy: c_long = 261; +pub const SYS_mq_open: c_long = 262; +pub const SYS_mq_unlink: c_long = 263; +pub const SYS_mq_timedsend: c_long = 264; +pub const SYS_mq_timedreceive: c_long = 265; +pub const SYS_mq_notify: c_long = 266; +pub const SYS_mq_getsetattr: c_long = 267; +pub const SYS_kexec_load: c_long = 268; +pub const SYS_add_key: c_long = 269; +pub const SYS_request_key: c_long = 270; +pub const SYS_keyctl: c_long = 271; +pub const SYS_waitid: c_long = 272; +pub const SYS_ioprio_set: c_long = 273; +pub const SYS_ioprio_get: c_long = 274; +pub const SYS_inotify_init: c_long = 275; +pub const SYS_inotify_add_watch: c_long = 276; +pub const SYS_inotify_rm_watch: c_long = 277; +pub const SYS_spu_run: c_long = 278; +pub const SYS_spu_create: c_long = 279; +pub const SYS_pselect6: c_long = 280; +pub const SYS_ppoll: c_long = 281; +pub const SYS_unshare: c_long = 282; +pub const SYS_splice: c_long = 283; +pub const SYS_tee: c_long = 284; +pub const SYS_vmsplice: c_long = 285; +pub const SYS_openat: c_long = 286; +pub const SYS_mkdirat: c_long = 287; +pub const SYS_mknodat: c_long = 288; +pub const SYS_fchownat: c_long = 289; +pub const SYS_futimesat: c_long = 290; +pub const SYS_fstatat64: c_long = 291; +pub const SYS_unlinkat: c_long = 292; +pub const SYS_renameat: c_long = 293; +pub const SYS_linkat: c_long = 294; +pub const SYS_symlinkat: c_long = 295; +pub const SYS_readlinkat: c_long = 296; +pub const SYS_fchmodat: c_long = 297; +pub const SYS_faccessat: c_long = 298; +pub const SYS_get_robust_list: c_long = 299; +pub const SYS_set_robust_list: c_long = 300; +pub const SYS_move_pages: c_long = 301; +pub const SYS_getcpu: c_long = 302; +pub const SYS_epoll_pwait: c_long = 303; +pub const SYS_utimensat: c_long = 304; +pub const SYS_signalfd: c_long = 305; +pub const SYS_timerfd_create: c_long = 306; +pub const SYS_eventfd: c_long = 307; +pub const SYS_sync_file_range2: c_long = 308; +pub const SYS_fallocate: c_long = 309; +pub const SYS_subpage_prot: c_long = 310; +pub const SYS_timerfd_settime: c_long = 311; +pub const SYS_timerfd_gettime: c_long = 312; +pub const SYS_signalfd4: c_long = 313; +pub const SYS_eventfd2: c_long = 314; +pub const SYS_epoll_create1: c_long = 315; +pub const SYS_dup3: c_long = 316; +pub const SYS_pipe2: c_long = 317; +pub const SYS_inotify_init1: c_long = 318; +pub const SYS_perf_event_open: c_long = 319; +pub const SYS_preadv: c_long = 320; +pub const SYS_pwritev: c_long = 321; +pub const SYS_rt_tgsigqueueinfo: c_long = 322; +pub const SYS_fanotify_init: c_long = 323; +pub const SYS_fanotify_mark: c_long = 324; +pub const SYS_prlimit64: c_long = 325; +pub const SYS_socket: c_long = 326; +pub const SYS_bind: c_long = 327; +pub const SYS_connect: c_long = 328; +pub const SYS_listen: c_long = 329; +pub const SYS_accept: c_long = 330; +pub const SYS_getsockname: c_long = 331; +pub const SYS_getpeername: c_long = 332; +pub const SYS_socketpair: c_long = 333; +pub const SYS_send: c_long = 334; +pub const SYS_sendto: c_long = 335; +pub const SYS_recv: c_long = 336; +pub const SYS_recvfrom: c_long = 337; +pub const SYS_shutdown: c_long = 338; +pub const SYS_setsockopt: c_long = 339; +pub const SYS_getsockopt: c_long = 340; +pub const SYS_sendmsg: c_long = 341; +pub const SYS_recvmsg: c_long = 342; +pub const SYS_recvmmsg: c_long = 343; +pub const SYS_accept4: c_long = 344; +pub const SYS_name_to_handle_at: c_long = 345; +pub const SYS_open_by_handle_at: c_long = 346; +pub const SYS_clock_adjtime: c_long = 347; +pub const SYS_syncfs: c_long = 348; +pub const SYS_sendmmsg: c_long = 349; +pub const SYS_setns: c_long = 350; +pub const SYS_process_vm_readv: c_long = 351; +pub const SYS_process_vm_writev: c_long = 352; +pub const SYS_finit_module: c_long = 353; +pub const SYS_kcmp: c_long = 354; +pub const SYS_sched_setattr: c_long = 355; +pub const SYS_sched_getattr: c_long = 356; +pub const SYS_renameat2: c_long = 357; +pub const SYS_seccomp: c_long = 358; +pub const SYS_getrandom: c_long = 359; +pub const SYS_memfd_create: c_long = 360; +pub const SYS_bpf: c_long = 361; +pub const SYS_execveat: c_long = 362; +pub const SYS_switch_endian: c_long = 363; +pub const SYS_userfaultfd: c_long = 364; +pub const SYS_membarrier: c_long = 365; +pub const SYS_mlock2: c_long = 378; +pub const SYS_copy_file_range: c_long = 379; +pub const SYS_preadv2: c_long = 380; +pub const SYS_pwritev2: c_long = 381; +pub const SYS_kexec_file_load: c_long = 382; +pub const SYS_statx: c_long = 383; +pub const SYS_pkey_alloc: c_long = 384; +pub const SYS_pkey_free: c_long = 385; +pub const SYS_pkey_mprotect: c_long = 386; +pub const SYS_pidfd_send_signal: c_long = 424; +pub const SYS_io_uring_setup: c_long = 425; +pub const SYS_io_uring_enter: c_long = 426; +pub const SYS_io_uring_register: c_long = 427; +pub const SYS_open_tree: c_long = 428; +pub const SYS_move_mount: c_long = 429; +pub const SYS_fsopen: c_long = 430; +pub const SYS_fsconfig: c_long = 431; +pub const SYS_fsmount: c_long = 432; +pub const SYS_fspick: c_long = 433; +pub const SYS_pidfd_open: c_long = 434; +pub const SYS_clone3: c_long = 435; +pub const SYS_close_range: c_long = 436; +pub const SYS_openat2: c_long = 437; +pub const SYS_pidfd_getfd: c_long = 438; +pub const SYS_faccessat2: c_long = 439; +pub const SYS_process_madvise: c_long = 440; +pub const SYS_epoll_pwait2: c_long = 441; +pub const SYS_mount_setattr: c_long = 442; +pub const SYS_quotactl_fd: c_long = 443; +pub const SYS_landlock_create_ruleset: c_long = 444; +pub const SYS_landlock_add_rule: c_long = 445; +pub const SYS_landlock_restrict_self: c_long = 446; +pub const SYS_memfd_secret: c_long = 447; +pub const SYS_process_mrelease: c_long = 448; +pub const SYS_futex_waitv: c_long = 449; +pub const SYS_set_mempolicy_home_node: c_long = 450; +pub const SYS_mseal: c_long = 462; diff --git a/http/vendor/libc/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs new file mode 100644 index 0000000..8589e46 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs @@ -0,0 +1,645 @@ +//! RISC-V-specific definitions for 32-bit linux-like values + +use crate::off_t; +use crate::prelude::*; + +pub type wchar_t = c_int; + +pub type stat64 = stat; + +s! { + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + pub __pad1: crate::dev_t, + pub st_size: off_t, + pub st_blksize: crate::blksize_t, + pub __pad2: c_int, + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + #[cfg(all(musl32_time64, target_endian = "big"))] + __pad0: Padding, + pub st_atime_nsec: c_long, + #[cfg(all(musl32_time64, target_endian = "little"))] + __pad0: Padding, + pub st_mtime: crate::time_t, + #[cfg(all(musl32_time64, target_endian = "big"))] + __pad1: Padding, + pub st_mtime_nsec: c_long, + #[cfg(all(musl32_time64, target_endian = "little"))] + __pad1: Padding, + pub st_ctime: crate::time_t, + #[cfg(all(musl32_time64, target_endian = "big"))] + __pad2: Padding, + pub st_ctime_nsec: c_long, + #[cfg(all(musl32_time64, target_endian = "little"))] + __pad2: Padding, + __unused: Padding<[c_int; 2usize]>, + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_flags: c_int, + pub ss_size: size_t, + } + + pub struct ipc_perm { + pub __key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: c_ushort, + __pad1: Padding, + pub __seq: c_ushort, + __pad2: Padding, + __unused1: Padding, + __unused2: Padding, + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, + pub shm_atime: crate::time_t, + pub shm_dtime: crate::time_t, + pub shm_ctime: crate::time_t, + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: crate::shmatt_t, + __unused5: Padding, + __unused6: Padding, + } + + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + pub msg_stime: crate::time_t, + __unused1: Padding, + pub msg_rtime: crate::time_t, + __unused2: Padding, + pub msg_ctime: crate::time_t, + __unused3: Padding, + pub __msg_cbytes: c_ulong, + pub msg_qnum: crate::msgqnum_t, + pub msg_qbytes: crate::msglen_t, + pub msg_lspid: crate::pid_t, + pub msg_lrpid: crate::pid_t, + __pad1: Padding, + __pad2: Padding, + } +} + +s_no_extra_traits! { + #[repr(align(8))] + pub struct max_align_t { + priv_: (i64, f64), + } +} + +//pub const RLIM_INFINITY: crate::rlim_t = !0; +pub const VEOF: usize = 4; +//pub const RLIMIT_RSS: crate::__rlimit_resource_t = 5; +//pub const RLIMIT_AS: crate::__rlimit_resource_t = 9; +//pub const RLIMIT_MEMLOCK: crate::__rlimit_resource_t = 8; +//pub const RLIMIT_NOFILE: crate::__rlimit_resource_t = 7; +//pub const RLIMIT_NPROC: crate::__rlimit_resource_t = 6; +pub const O_APPEND: c_int = 1024; +pub const O_CREAT: c_int = 64; +pub const O_EXCL: c_int = 128; +pub const O_NOCTTY: c_int = 256; +pub const O_NONBLOCK: c_int = 2048; +pub const O_SYNC: c_int = 1052672; +pub const O_RSYNC: c_int = 1052672; +pub const O_DSYNC: c_int = 4096; +pub const MAP_GROWSDOWN: c_int = 256; +pub const EDEADLK: c_int = 35; +pub const ENAMETOOLONG: c_int = 36; +pub const ENOLCK: c_int = 37; +pub const ENOSYS: c_int = 38; +pub const ENOTEMPTY: c_int = 39; +pub const ELOOP: c_int = 40; +pub const ENOMSG: c_int = 42; +pub const EIDRM: c_int = 43; +pub const ECHRNG: c_int = 44; +pub const EL2NSYNC: c_int = 45; +pub const EL3HLT: c_int = 46; +pub const EL3RST: c_int = 47; +pub const ELNRNG: c_int = 48; +pub const EUNATCH: c_int = 49; +pub const ENOCSI: c_int = 50; +pub const EL2HLT: c_int = 51; +pub const EBADE: c_int = 52; +pub const EBADR: c_int = 53; +pub const EXFULL: c_int = 54; +pub const ENOANO: c_int = 55; +pub const EBADRQC: c_int = 56; +pub const EBADSLT: c_int = 57; +pub const EMULTIHOP: c_int = 72; +pub const EOVERFLOW: c_int = 75; +pub const ENOTUNIQ: c_int = 76; +pub const EBADFD: c_int = 77; +pub const EBADMSG: c_int = 74; +pub const EREMCHG: c_int = 78; +pub const ELIBACC: c_int = 79; +pub const ELIBBAD: c_int = 80; +pub const ELIBSCN: c_int = 81; +pub const ELIBMAX: c_int = 82; +pub const ELIBEXEC: c_int = 83; +pub const EILSEQ: c_int = 84; +pub const ERESTART: c_int = 85; +pub const ESTRPIPE: c_int = 86; +pub const EUSERS: c_int = 87; +pub const ENOTSOCK: c_int = 88; +pub const EDESTADDRREQ: c_int = 89; +pub const EMSGSIZE: c_int = 90; +pub const EPROTOTYPE: c_int = 91; +pub const ENOPROTOOPT: c_int = 92; +pub const EPROTONOSUPPORT: c_int = 93; +pub const ESOCKTNOSUPPORT: c_int = 94; +pub const EOPNOTSUPP: c_int = 95; +pub const ENOTSUP: c_int = EOPNOTSUPP; +pub const EPFNOSUPPORT: c_int = 96; +pub const EAFNOSUPPORT: c_int = 97; +pub const EADDRINUSE: c_int = 98; +pub const EADDRNOTAVAIL: c_int = 99; +pub const ENETDOWN: c_int = 100; +pub const ENETUNREACH: c_int = 101; +pub const ENETRESET: c_int = 102; +pub const ECONNABORTED: c_int = 103; +pub const ECONNRESET: c_int = 104; +pub const ENOBUFS: c_int = 105; +pub const EISCONN: c_int = 106; +pub const ENOTCONN: c_int = 107; +pub const ESHUTDOWN: c_int = 108; +pub const ETOOMANYREFS: c_int = 109; +pub const ETIMEDOUT: c_int = 110; +pub const ECONNREFUSED: c_int = 111; +pub const EHOSTDOWN: c_int = 112; +pub const EHOSTUNREACH: c_int = 113; +pub const EALREADY: c_int = 114; +pub const EINPROGRESS: c_int = 115; +pub const ESTALE: c_int = 116; +pub const EDQUOT: c_int = 122; +pub const ENOMEDIUM: c_int = 123; +pub const EMEDIUMTYPE: c_int = 124; +pub const ECANCELED: c_int = 125; +pub const ENOKEY: c_int = 126; +pub const EKEYEXPIRED: c_int = 127; +pub const EKEYREVOKED: c_int = 128; +pub const EKEYREJECTED: c_int = 129; +pub const EOWNERDEAD: c_int = 130; +pub const ENOTRECOVERABLE: c_int = 131; +pub const EHWPOISON: c_int = 133; +pub const ERFKILL: c_int = 132; + +pub const SA_ONSTACK: c_int = 0x08000000; +pub const SA_SIGINFO: c_int = 4; +pub const SA_NOCLDWAIT: c_int = 2; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGCHLD: c_int = 17; +pub const SIGBUS: c_int = 7; +pub const SIGUSR1: c_int = 10; +pub const SIGUSR2: c_int = 12; +pub const SIGCONT: c_int = 18; +pub const SIGSTOP: c_int = 19; +pub const SIGTSTP: c_int = 20; +pub const SIGURG: c_int = 23; +pub const SIGIO: c_int = 29; +pub const SIGSYS: c_int = 31; +pub const SIGSTKFLT: c_int = 16; +pub const SIGPOLL: c_int = 29; +pub const SIGPWR: c_int = 30; +pub const SIG_SETMASK: c_int = 2; +pub const SIG_BLOCK: c_int = 0; +pub const SIG_UNBLOCK: c_int = 1; +pub const POLLWRNORM: c_short = 256; +pub const POLLWRBAND: c_short = 512; +pub const O_ASYNC: c_int = 8192; +pub const F_SETOWN: c_int = 8; +pub const F_GETOWN: c_int = 9; +pub const F_GETLK: c_int = 12; +pub const F_SETLK: c_int = 13; +pub const F_SETLKW: c_int = 14; + +pub const O_DIRECT: c_int = 16384; +pub const O_DIRECTORY: c_int = 65536; +pub const O_LARGEFILE: c_int = 0o0100000; +pub const O_NOFOLLOW: c_int = 131072; +pub const MADV_SOFT_OFFLINE: c_int = 101; +pub const MAP_HUGETLB: c_int = 262144; +pub const MAP_LOCKED: c_int = 8192; +pub const MAP_NORESERVE: c_int = 16384; +pub const MAP_ANON: c_int = 32; +pub const MAP_DENYWRITE: c_int = 2048; +pub const MAP_EXECUTABLE: c_int = 4096; +pub const MAP_POPULATE: c_int = 32768; +pub const MAP_NONBLOCK: c_int = 65536; +pub const MAP_STACK: c_int = 131072; +pub const MAP_SYNC: c_int = 0x080000; +pub const EDEADLOCK: c_int = 35; +pub const EUCLEAN: c_int = 117; +pub const ENOTNAM: c_int = 118; +pub const ENAVAIL: c_int = 119; +pub const EISNAM: c_int = 120; +pub const EREMOTEIO: c_int = 121; +pub const MCL_CURRENT: c_int = 1; +pub const MCL_FUTURE: c_int = 2; +pub const MCL_ONFAULT: c_int = 4; +pub const SIGSTKSZ: size_t = 8192; +pub const MINSIGSTKSZ: size_t = 2048; +pub const CBAUD: crate::tcflag_t = 4111; +pub const TAB1: crate::tcflag_t = 2048; +pub const TAB2: crate::tcflag_t = 4096; +pub const TAB3: crate::tcflag_t = 6144; +pub const CR1: crate::tcflag_t = 512; +pub const CR2: crate::tcflag_t = 1024; +pub const CR3: crate::tcflag_t = 1536; +pub const FF1: crate::tcflag_t = 32768; +pub const BS1: crate::tcflag_t = 8192; +pub const VT1: crate::tcflag_t = 16384; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: crate::tcflag_t = 1024; +pub const IXOFF: crate::tcflag_t = 4096; +pub const ONLCR: crate::tcflag_t = 4; +pub const CSIZE: crate::tcflag_t = 48; +pub const CS6: crate::tcflag_t = 16; +pub const CS7: crate::tcflag_t = 32; +pub const CS8: crate::tcflag_t = 48; +pub const CSTOPB: crate::tcflag_t = 64; +pub const CREAD: crate::tcflag_t = 128; +pub const PARENB: crate::tcflag_t = 256; +pub const PARODD: crate::tcflag_t = 512; +pub const HUPCL: crate::tcflag_t = 1024; +pub const CLOCAL: crate::tcflag_t = 2048; +pub const ECHOKE: crate::tcflag_t = 2048; +pub const ECHOE: crate::tcflag_t = 16; +pub const ECHOK: crate::tcflag_t = 32; +pub const ECHONL: crate::tcflag_t = 64; +pub const ECHOPRT: crate::tcflag_t = 1024; +pub const ECHOCTL: crate::tcflag_t = 512; +pub const ISIG: crate::tcflag_t = 1; +pub const ICANON: crate::tcflag_t = 2; +pub const PENDIN: crate::tcflag_t = 16384; +pub const NOFLSH: crate::tcflag_t = 128; +pub const CIBAUD: crate::tcflag_t = 269418496; +pub const CBAUDEX: crate::tcflag_t = 4096; +pub const VSWTC: usize = 7; +pub const OLCUC: crate::tcflag_t = 2; +pub const NLDLY: crate::tcflag_t = 256; +pub const CRDLY: crate::tcflag_t = 1536; +pub const TABDLY: crate::tcflag_t = 6144; +pub const BSDLY: crate::tcflag_t = 8192; +pub const FFDLY: crate::tcflag_t = 32768; +pub const VTDLY: crate::tcflag_t = 16384; +pub const XTABS: crate::tcflag_t = 6144; +pub const B57600: crate::speed_t = 4097; +pub const B115200: crate::speed_t = 4098; +pub const B230400: crate::speed_t = 4099; +pub const B460800: crate::speed_t = 4100; +pub const B500000: crate::speed_t = 4101; +pub const B576000: crate::speed_t = 4102; +pub const B921600: crate::speed_t = 4103; +pub const B1000000: crate::speed_t = 4104; +pub const B1152000: crate::speed_t = 4105; +pub const B1500000: crate::speed_t = 4106; +pub const B2000000: crate::speed_t = 4107; +pub const B2500000: crate::speed_t = 4108; +pub const B3000000: crate::speed_t = 4109; +pub const B3500000: crate::speed_t = 4110; +pub const B4000000: crate::speed_t = 4111; +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: crate::tcflag_t = 32768; +pub const TOSTOP: crate::tcflag_t = 256; +pub const FLUSHO: crate::tcflag_t = 4096; +pub const EXTPROC: crate::tcflag_t = 65536; + +pub const SYS_read: c_long = 63; +pub const SYS_write: c_long = 64; +pub const SYS_close: c_long = 57; +// RISC-V don't have SYS_fstat, use statx instead. +pub const SYS_lseek: c_long = 62; +pub const SYS_mmap: c_long = 222; +pub const SYS_mprotect: c_long = 226; +pub const SYS_munmap: c_long = 215; +pub const SYS_brk: c_long = 214; +pub const SYS_rt_sigaction: c_long = 134; +pub const SYS_rt_sigprocmask: c_long = 135; +pub const SYS_rt_sigreturn: c_long = 139; +pub const SYS_ioctl: c_long = 29; +pub const SYS_pread64: c_long = 67; +pub const SYS_pwrite64: c_long = 68; +pub const SYS_readv: c_long = 65; +pub const SYS_writev: c_long = 66; +pub const SYS_sched_yield: c_long = 124; +pub const SYS_mremap: c_long = 216; +pub const SYS_msync: c_long = 227; +pub const SYS_mincore: c_long = 232; +pub const SYS_madvise: c_long = 233; +pub const SYS_shmget: c_long = 194; +pub const SYS_shmat: c_long = 196; +pub const SYS_shmctl: c_long = 195; +pub const SYS_dup: c_long = 23; +pub const SYS_getitimer: c_long = 102; +pub const SYS_setitimer: c_long = 103; +pub const SYS_getpid: c_long = 172; +pub const SYS_sendfile: c_long = 71; +pub const SYS_socket: c_long = 198; +pub const SYS_connect: c_long = 203; +pub const SYS_accept: c_long = 202; +pub const SYS_sendto: c_long = 206; +pub const SYS_recvfrom: c_long = 207; +pub const SYS_sendmsg: c_long = 211; +pub const SYS_recvmsg: c_long = 212; +pub const SYS_shutdown: c_long = 210; +pub const SYS_bind: c_long = 200; +pub const SYS_listen: c_long = 201; +pub const SYS_getsockname: c_long = 204; +pub const SYS_getpeername: c_long = 205; +pub const SYS_socketpair: c_long = 199; +pub const SYS_setsockopt: c_long = 208; +pub const SYS_getsockopt: c_long = 209; +pub const SYS_clone: c_long = 220; +pub const SYS_execve: c_long = 221; +pub const SYS_exit: c_long = 93; +// RISC-V don't have wait4, use waitid instead. +pub const SYS_kill: c_long = 129; +pub const SYS_uname: c_long = 160; +pub const SYS_semget: c_long = 190; +pub const SYS_semop: c_long = 193; +pub const SYS_semctl: c_long = 191; +pub const SYS_shmdt: c_long = 197; +pub const SYS_msgget: c_long = 186; +pub const SYS_msgsnd: c_long = 189; +pub const SYS_msgrcv: c_long = 188; +pub const SYS_msgctl: c_long = 187; +pub const SYS_fcntl: c_long = 25; +pub const SYS_flock: c_long = 32; +pub const SYS_fsync: c_long = 82; +pub const SYS_fdatasync: c_long = 83; +pub const SYS_truncate: c_long = 45; +pub const SYS_ftruncate: c_long = 46; +pub const SYS_getcwd: c_long = 17; +pub const SYS_chdir: c_long = 49; +pub const SYS_fchdir: c_long = 50; +pub const SYS_fchmod: c_long = 52; +pub const SYS_fchown: c_long = 55; +pub const SYS_umask: c_long = 166; +// RISC-V don't have gettimeofday, use clock_gettime64 instead. +// RISC-V don't have getrlimit, use prlimit64 instead. +pub const SYS_getrusage: c_long = 165; +pub const SYS_sysinfo: c_long = 179; +pub const SYS_times: c_long = 153; +pub const SYS_ptrace: c_long = 117; +pub const SYS_getuid: c_long = 174; +pub const SYS_syslog: c_long = 116; +pub const SYS_getgid: c_long = 176; +pub const SYS_setuid: c_long = 146; +pub const SYS_setgid: c_long = 144; +pub const SYS_geteuid: c_long = 175; +pub const SYS_getegid: c_long = 177; +pub const SYS_setpgid: c_long = 154; +pub const SYS_getppid: c_long = 173; +pub const SYS_setsid: c_long = 157; +pub const SYS_setreuid: c_long = 145; +pub const SYS_setregid: c_long = 143; +pub const SYS_getgroups: c_long = 158; +pub const SYS_setgroups: c_long = 159; +pub const SYS_setresuid: c_long = 147; +pub const SYS_getresuid: c_long = 148; +pub const SYS_setresgid: c_long = 149; +pub const SYS_getresgid: c_long = 150; +pub const SYS_getpgid: c_long = 155; +pub const SYS_setfsuid: c_long = 151; +pub const SYS_setfsgid: c_long = 152; +pub const SYS_getsid: c_long = 156; +pub const SYS_capget: c_long = 90; +pub const SYS_capset: c_long = 91; +pub const SYS_rt_sigpending: c_long = 136; +pub const SYS_rt_sigtimedwait_time64: c_long = 421; +pub const SYS_rt_sigqueueinfo: c_long = 138; +pub const SYS_rt_sigsuspend: c_long = 133; +pub const SYS_sigaltstack: c_long = 132; +pub const SYS_personality: c_long = 92; +pub const SYS_statfs: c_long = 43; +pub const SYS_fstatfs: c_long = 44; +pub const SYS_getpriority: c_long = 141; +pub const SYS_setpriority: c_long = 140; +pub const SYS_sched_setparam: c_long = 118; +pub const SYS_sched_getparam: c_long = 121; +pub const SYS_sched_setscheduler: c_long = 119; +pub const SYS_sched_getscheduler: c_long = 120; +pub const SYS_sched_get_priority_max: c_long = 125; +pub const SYS_sched_get_priority_min: c_long = 126; +pub const SYS_sched_rr_get_interval_time64: c_long = 423; +pub const SYS_mlock: c_long = 228; +pub const SYS_munlock: c_long = 229; +pub const SYS_mlockall: c_long = 230; +pub const SYS_munlockall: c_long = 231; +pub const SYS_vhangup: c_long = 58; +pub const SYS_pivot_root: c_long = 41; +pub const SYS_prctl: c_long = 167; +// RISC-V don't have setrlimit, use prlimit64 instead. +pub const SYS_chroot: c_long = 51; +pub const SYS_sync: c_long = 81; +pub const SYS_acct: c_long = 89; +// RISC-V don't have settimeofday, use clock_settime64 instead. +pub const SYS_mount: c_long = 40; +pub const SYS_umount2: c_long = 39; +pub const SYS_swapon: c_long = 224; +pub const SYS_swapoff: c_long = 225; +pub const SYS_reboot: c_long = 142; +pub const SYS_sethostname: c_long = 161; +pub const SYS_setdomainname: c_long = 162; +pub const SYS_init_module: c_long = 105; +pub const SYS_delete_module: c_long = 106; +pub const SYS_quotactl: c_long = 60; +pub const SYS_nfsservctl: c_long = 42; +pub const SYS_gettid: c_long = 178; +pub const SYS_readahead: c_long = 213; +pub const SYS_setxattr: c_long = 5; +pub const SYS_lsetxattr: c_long = 6; +pub const SYS_fsetxattr: c_long = 7; +pub const SYS_getxattr: c_long = 8; +pub const SYS_lgetxattr: c_long = 9; +pub const SYS_fgetxattr: c_long = 10; +pub const SYS_listxattr: c_long = 11; +pub const SYS_llistxattr: c_long = 12; +pub const SYS_flistxattr: c_long = 13; +pub const SYS_removexattr: c_long = 14; +pub const SYS_lremovexattr: c_long = 15; +pub const SYS_fremovexattr: c_long = 16; +pub const SYS_tkill: c_long = 130; +pub const SYS_futex_time64: c_long = 422; +pub const SYS_sched_setaffinity: c_long = 122; +pub const SYS_sched_getaffinity: c_long = 123; +pub const SYS_io_setup: c_long = 0; +pub const SYS_io_destroy: c_long = 1; +pub const SYS_io_pgetevents_time64: c_long = 416; +pub const SYS_io_submit: c_long = 2; +pub const SYS_io_cancel: c_long = 3; +pub const SYS_lookup_dcookie: c_long = 18; +pub const SYS_remap_file_pages: c_long = 234; +pub const SYS_getdents64: c_long = 61; +pub const SYS_set_tid_address: c_long = 96; +pub const SYS_restart_syscall: c_long = 128; +pub const SYS_semtimedop_time64: c_long = 420; +pub const SYS_fadvise64: c_long = 223; +pub const SYS_timer_create: c_long = 107; +pub const SYS_timer_settime64: c_long = 409; +pub const SYS_timer_gettime64: c_long = 408; +pub const SYS_timer_getoverrun: c_long = 109; +pub const SYS_timer_delete: c_long = 111; +pub const SYS_clock_settime64: c_long = 404; +pub const SYS_clock_gettime64: c_long = 403; +pub const SYS_clock_getres_time64: c_long = 406; +pub const SYS_clock_nanosleep_time64: c_long = 407; +pub const SYS_exit_group: c_long = 94; +pub const SYS_epoll_ctl: c_long = 21; +pub const SYS_tgkill: c_long = 131; +pub const SYS_mbind: c_long = 235; +pub const SYS_set_mempolicy: c_long = 237; +pub const SYS_get_mempolicy: c_long = 236; +pub const SYS_mq_open: c_long = 180; +pub const SYS_mq_unlink: c_long = 181; +pub const SYS_mq_timedsend_time64: c_long = 418; +pub const SYS_mq_timedreceive_time64: c_long = 419; +pub const SYS_mq_notify: c_long = 184; +pub const SYS_mq_getsetattr: c_long = 185; +pub const SYS_kexec_load: c_long = 104; +pub const SYS_waitid: c_long = 95; +pub const SYS_add_key: c_long = 217; +pub const SYS_request_key: c_long = 218; +pub const SYS_keyctl: c_long = 219; +pub const SYS_ioprio_set: c_long = 30; +pub const SYS_ioprio_get: c_long = 31; +pub const SYS_inotify_add_watch: c_long = 27; +pub const SYS_inotify_rm_watch: c_long = 28; +pub const SYS_migrate_pages: c_long = 238; +pub const SYS_openat: c_long = 56; +pub const SYS_mkdirat: c_long = 34; +pub const SYS_mknodat: c_long = 33; +pub const SYS_fchownat: c_long = 54; +// RISC-V don't have newfstatat, use statx instead. +pub const SYS_unlinkat: c_long = 35; +pub const SYS_linkat: c_long = 37; +pub const SYS_symlinkat: c_long = 36; +pub const SYS_readlinkat: c_long = 78; +pub const SYS_fchmodat: c_long = 53; +pub const SYS_faccessat: c_long = 48; +pub const SYS_pselect6_time64: c_long = 413; +pub const SYS_ppoll_time64: c_long = 414; +pub const SYS_unshare: c_long = 97; +pub const SYS_set_robust_list: c_long = 99; +pub const SYS_get_robust_list: c_long = 100; +pub const SYS_splice: c_long = 76; +pub const SYS_tee: c_long = 77; +pub const SYS_sync_file_range: c_long = 84; +pub const SYS_vmsplice: c_long = 75; +pub const SYS_move_pages: c_long = 239; +pub const SYS_utimensat_time64: c_long = 412; +pub const SYS_epoll_pwait: c_long = 22; +pub const SYS_timerfd_create: c_long = 85; +pub const SYS_fallocate: c_long = 47; +pub const SYS_timerfd_settime64: c_long = 411; +pub const SYS_timerfd_gettime64: c_long = 410; +pub const SYS_accept4: c_long = 242; +pub const SYS_signalfd4: c_long = 74; +pub const SYS_eventfd2: c_long = 19; +pub const SYS_epoll_create1: c_long = 20; +pub const SYS_dup3: c_long = 24; +pub const SYS_pipe2: c_long = 59; +pub const SYS_inotify_init1: c_long = 26; +pub const SYS_preadv: c_long = 69; +pub const SYS_pwritev: c_long = 70; +pub const SYS_rt_tgsigqueueinfo: c_long = 240; +pub const SYS_perf_event_open: c_long = 241; +pub const SYS_recvmmsg_time64: c_long = 417; +pub const SYS_fanotify_init: c_long = 262; +pub const SYS_fanotify_mark: c_long = 263; +pub const SYS_prlimit64: c_long = 261; +pub const SYS_name_to_handle_at: c_long = 264; +pub const SYS_open_by_handle_at: c_long = 265; +pub const SYS_clock_adjtime64: c_long = 405; +pub const SYS_syncfs: c_long = 267; +pub const SYS_sendmmsg: c_long = 269; +pub const SYS_setns: c_long = 268; +pub const SYS_getcpu: c_long = 168; +pub const SYS_process_vm_readv: c_long = 270; +pub const SYS_process_vm_writev: c_long = 271; +pub const SYS_kcmp: c_long = 272; +pub const SYS_finit_module: c_long = 273; +pub const SYS_sched_setattr: c_long = 274; +pub const SYS_sched_getattr: c_long = 275; +pub const SYS_renameat2: c_long = 276; +pub const SYS_seccomp: c_long = 277; +pub const SYS_getrandom: c_long = 278; +pub const SYS_memfd_create: c_long = 279; +pub const SYS_bpf: c_long = 280; +pub const SYS_execveat: c_long = 281; +pub const SYS_userfaultfd: c_long = 282; +pub const SYS_membarrier: c_long = 283; +pub const SYS_mlock2: c_long = 284; +pub const SYS_copy_file_range: c_long = 285; +pub const SYS_preadv2: c_long = 286; +pub const SYS_pwritev2: c_long = 287; +pub const SYS_pkey_mprotect: c_long = 288; +pub const SYS_pkey_alloc: c_long = 289; +pub const SYS_pkey_free: c_long = 290; +pub const SYS_statx: c_long = 291; +pub const SYS_pidfd_send_signal: c_long = 424; +pub const SYS_io_uring_setup: c_long = 425; +pub const SYS_io_uring_enter: c_long = 426; +pub const SYS_io_uring_register: c_long = 427; +pub const SYS_open_tree: c_long = 428; +pub const SYS_move_mount: c_long = 429; +pub const SYS_fsopen: c_long = 430; +pub const SYS_fsconfig: c_long = 431; +pub const SYS_fsmount: c_long = 432; +pub const SYS_fspick: c_long = 433; +pub const SYS_pidfd_open: c_long = 434; +pub const SYS_clone3: c_long = 435; +pub const SYS_close_range: c_long = 436; +pub const SYS_openat2: c_long = 437; +pub const SYS_pidfd_getfd: c_long = 438; +pub const SYS_faccessat2: c_long = 439; +pub const SYS_process_madvise: c_long = 440; +pub const SYS_epoll_pwait2: c_long = 441; +pub const SYS_mount_setattr: c_long = 442; + +// Plain syscalls aliased to their time64 variants +pub const SYS_clock_gettime: c_long = SYS_clock_gettime64; +pub const SYS_clock_settime: c_long = SYS_clock_settime64; +pub const SYS_clock_adjtime: c_long = SYS_clock_adjtime64; +pub const SYS_clock_getres: c_long = SYS_clock_getres_time64; +pub const SYS_clock_nanosleep: c_long = SYS_clock_nanosleep_time64; +pub const SYS_timer_gettime: c_long = SYS_timer_gettime64; +pub const SYS_timer_settime: c_long = SYS_timer_settime64; +pub const SYS_timerfd_gettime: c_long = SYS_timerfd_gettime64; +pub const SYS_timerfd_settime: c_long = SYS_timerfd_settime64; +pub const SYS_utimensat: c_long = SYS_utimensat_time64; +pub const SYS_pselect6: c_long = SYS_pselect6_time64; +pub const SYS_ppoll: c_long = SYS_ppoll_time64; +pub const SYS_recvmmsg: c_long = SYS_recvmmsg_time64; +pub const SYS_mq_timedsend: c_long = SYS_mq_timedsend_time64; +pub const SYS_mq_timedreceive: c_long = SYS_mq_timedreceive_time64; +pub const SYS_rt_sigtimedwait: c_long = SYS_rt_sigtimedwait_time64; +pub const SYS_futex: c_long = SYS_futex_time64; +pub const SYS_sched_rr_get_interval: c_long = SYS_sched_rr_get_interval_time64; diff --git a/http/vendor/libc/src/unix/linux_like/linux/musl/b32/x86/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/musl/b32/x86/mod.rs new file mode 100644 index 0000000..1a34807 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -0,0 +1,878 @@ +use crate::off_t; +use crate::prelude::*; + +pub type wchar_t = i32; + +pub type stat64 = stat; + +s! { + pub struct stat { + pub st_dev: crate::dev_t, + __st_dev_padding: Padding, + __st_ino_truncated: c_long, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + __st_rdev_padding: Padding, + pub st_size: off_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + + #[cfg(musl32_time64)] + __st_atim32: Padding<__c_anonymous_timespec32>, + #[cfg(musl32_time64)] + __st_mtim32: Padding<__c_anonymous_timespec32>, + #[cfg(musl32_time64)] + __st_ctim32: Padding<__c_anonymous_timespec32>, + + #[cfg(musl_v1_2_3)] + pub st_ino: crate::ino_t, + + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + #[cfg(musl32_time64)] + __pad0: Padding, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + #[cfg(musl32_time64)] + __pad1: Padding, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + #[cfg(musl32_time64)] + __pad2: Padding, + + #[cfg(not(musl_v1_2_3))] + pub st_ino: crate::ino_t, + } + + struct __c_anonymous_timespec32 { + __tv_sec: c_long, + __tv_nsec: c_long, + } + + pub struct mcontext_t { + __private: [u32; 22], + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_flags: c_int, + pub ss_size: size_t, + } + + pub struct ipc_perm { + #[cfg(musl_v1_2_3)] + pub __key: crate::key_t, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "This field is incorrectly named and will be changed + to __key in a future release." + )] + pub __ipc_perm_key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: crate::mode_t, + pub __seq: c_int, + __unused1: Padding, + __unused2: Padding, + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, + + #[cfg(musl32_time64)] + __shm_atime_lo: c_ulong, + #[cfg(musl32_time64)] + __shm_atime_hi: c_ulong, + #[cfg(musl32_time64)] + __shm_dtime_lo: c_ulong, + #[cfg(musl32_time64)] + __shm_dtime_hi: c_ulong, + #[cfg(musl32_time64)] + __msg_ctime_lo: c_ulong, + #[cfg(musl32_time64)] + __msg_ctime_hi: c_ulong, + + #[cfg(not(musl32_time64))] + pub shm_atime: crate::time_t, + #[cfg(not(musl32_time64))] + __unused1: Padding, + #[cfg(not(musl32_time64))] + pub shm_dtime: crate::time_t, + #[cfg(not(musl32_time64))] + __unused2: Padding, + #[cfg(not(musl32_time64))] + pub shm_ctime: crate::time_t, + #[cfg(not(musl32_time64))] + __unused3: Padding, + + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: c_ulong, + __pad1: Padding, + __pad2: Padding, + + #[cfg(musl32_time64)] + __pad3: c_ulong, + #[cfg(musl32_time64)] + shm_atime: crate::time_t, + #[cfg(musl32_time64)] + shm_dtime: crate::time_t, + #[cfg(musl32_time64)] + shm_ctime: crate::time_t, + } + + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + + #[cfg(musl32_time64)] + __msg_stime_lo: c_ulong, + #[cfg(musl32_time64)] + __msg_stime_hi: c_ulong, + #[cfg(musl32_time64)] + __msg_rtime_lo: c_ulong, + #[cfg(musl32_time64)] + __msg_rtime_hi: c_ulong, + #[cfg(musl32_time64)] + __msg_ctime_lo: c_ulong, + #[cfg(musl32_time64)] + __msg_ctime_hi: c_ulong, + + #[cfg(not(musl32_time64))] + pub msg_stime: crate::time_t, + #[cfg(not(musl32_time64))] + __unused1: Padding, + #[cfg(not(musl32_time64))] + pub msg_rtime: crate::time_t, + #[cfg(not(musl32_time64))] + __unused2: Padding, + #[cfg(not(musl32_time64))] + pub msg_ctime: crate::time_t, + #[cfg(not(musl32_time64))] + __unused3: Padding, + + pub __msg_cbytes: c_ulong, + pub msg_qnum: crate::msgqnum_t, + pub msg_qbytes: crate::msglen_t, + pub msg_lspid: crate::pid_t, + pub msg_lrpid: crate::pid_t, + __pad1: Padding, + __pad2: Padding, + + #[cfg(musl32_time64)] + pub msg_stime: crate::time_t, + #[cfg(musl32_time64)] + pub msg_rtime: crate::time_t, + #[cfg(musl32_time64)] + pub msg_ctime: crate::time_t, + } + + pub struct user_fpxregs_struct { + pub cwd: c_ushort, + pub swd: c_ushort, + pub twd: c_ushort, + pub fop: c_ushort, + pub fip: c_long, + pub fcs: c_long, + pub foo: c_long, + pub fos: c_long, + pub mxcsr: c_long, + __reserved: Padding, + pub st_space: [c_long; 32], + pub xmm_space: [c_long; 32], + padding: Padding<[c_long; 56]>, + } + + pub struct ucontext_t { + pub uc_flags: c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: crate::stack_t, + pub uc_mcontext: mcontext_t, + pub uc_sigmask: crate::sigset_t, + __private: [u8; 112], + } +} + +s_no_extra_traits! { + #[repr(align(8))] + pub struct max_align_t { + priv_: [f64; 3], + } +} + +pub const SIGSTKSZ: size_t = 8192; +pub const MINSIGSTKSZ: size_t = 2048; + +pub const O_DIRECT: c_int = 0x4000; +pub const O_DIRECTORY: c_int = 0x10000; +pub const O_NOFOLLOW: c_int = 0x20000; +pub const O_ASYNC: c_int = 0x2000; +pub const O_LARGEFILE: c_int = 0o0100000; + +pub const MADV_SOFT_OFFLINE: c_int = 101; +pub const MCL_CURRENT: c_int = 0x0001; +pub const MCL_FUTURE: c_int = 0x0002; +pub const MCL_ONFAULT: c_int = 0x0004; +pub const CBAUD: crate::tcflag_t = 0o0010017; +pub const TAB1: c_int = 0x00000800; +pub const TAB2: c_int = 0x00001000; +pub const TAB3: c_int = 0x00001800; +pub const CR1: c_int = 0x00000200; +pub const CR2: c_int = 0x00000400; +pub const CR3: c_int = 0x00000600; +pub const FF1: c_int = 0x00008000; +pub const BS1: c_int = 0x00002000; +pub const VT1: c_int = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: crate::tcflag_t = 0x00000400; +pub const IXOFF: crate::tcflag_t = 0x00001000; +pub const ONLCR: crate::tcflag_t = 0x4; +pub const CSIZE: crate::tcflag_t = 0x00000030; +pub const CS6: crate::tcflag_t = 0x00000010; +pub const CS7: crate::tcflag_t = 0x00000020; +pub const CS8: crate::tcflag_t = 0x00000030; +pub const CSTOPB: crate::tcflag_t = 0x00000040; +pub const CREAD: crate::tcflag_t = 0x00000080; +pub const PARENB: crate::tcflag_t = 0x00000100; +pub const PARODD: crate::tcflag_t = 0x00000200; +pub const HUPCL: crate::tcflag_t = 0x00000400; +pub const CLOCAL: crate::tcflag_t = 0x00000800; +pub const ECHOKE: crate::tcflag_t = 0x00000800; +pub const ECHOE: crate::tcflag_t = 0x00000010; +pub const ECHOK: crate::tcflag_t = 0x00000020; +pub const ECHONL: crate::tcflag_t = 0x00000040; +pub const ECHOPRT: crate::tcflag_t = 0x00000400; +pub const ECHOCTL: crate::tcflag_t = 0x00000200; +pub const ISIG: crate::tcflag_t = 0x00000001; +pub const ICANON: crate::tcflag_t = 0x00000002; +pub const PENDIN: crate::tcflag_t = 0x00004000; +pub const NOFLSH: crate::tcflag_t = 0x00000080; +pub const CIBAUD: crate::tcflag_t = 0o02003600000; +pub const CBAUDEX: crate::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: crate::tcflag_t = 0o000002; +pub const NLDLY: crate::tcflag_t = 0o000400; +pub const CRDLY: crate::tcflag_t = 0o003000; +pub const TABDLY: crate::tcflag_t = 0o014000; +pub const BSDLY: crate::tcflag_t = 0o020000; +pub const FFDLY: crate::tcflag_t = 0o100000; +pub const VTDLY: crate::tcflag_t = 0o040000; +pub const XTABS: crate::tcflag_t = 0o014000; +pub const B57600: crate::speed_t = 0o010001; +pub const B115200: crate::speed_t = 0o010002; +pub const B230400: crate::speed_t = 0o010003; +pub const B460800: crate::speed_t = 0o010004; +pub const B500000: crate::speed_t = 0o010005; +pub const B576000: crate::speed_t = 0o010006; +pub const B921600: crate::speed_t = 0o010007; +pub const B1000000: crate::speed_t = 0o010010; +pub const B1152000: crate::speed_t = 0o010011; +pub const B1500000: crate::speed_t = 0o010012; +pub const B2000000: crate::speed_t = 0o010013; +pub const B2500000: crate::speed_t = 0o010014; +pub const B3000000: crate::speed_t = 0o010015; +pub const B3500000: crate::speed_t = 0o010016; +pub const B4000000: crate::speed_t = 0o010017; + +pub const O_APPEND: c_int = 1024; +pub const O_CREAT: c_int = 64; +pub const O_EXCL: c_int = 128; +pub const O_NOCTTY: c_int = 256; +pub const O_NONBLOCK: c_int = 2048; +pub const O_SYNC: c_int = 1052672; +pub const O_RSYNC: c_int = 1052672; +pub const O_DSYNC: c_int = 4096; + +pub const MAP_ANON: c_int = 0x0020; +pub const MAP_GROWSDOWN: c_int = 0x0100; +pub const MAP_DENYWRITE: c_int = 0x0800; +pub const MAP_EXECUTABLE: c_int = 0x01000; +pub const MAP_LOCKED: c_int = 0x02000; +pub const MAP_NORESERVE: c_int = 0x04000; +pub const MAP_POPULATE: c_int = 0x08000; +pub const MAP_NONBLOCK: c_int = 0x010000; +pub const MAP_STACK: c_int = 0x020000; +pub const MAP_SYNC: c_int = 0x080000; + +pub const EDEADLK: c_int = 35; +pub const ENAMETOOLONG: c_int = 36; +pub const ENOLCK: c_int = 37; +pub const ENOSYS: c_int = 38; +pub const ENOTEMPTY: c_int = 39; +pub const ELOOP: c_int = 40; +pub const ENOMSG: c_int = 42; +pub const EIDRM: c_int = 43; +pub const ECHRNG: c_int = 44; +pub const EL2NSYNC: c_int = 45; +pub const EL3HLT: c_int = 46; +pub const EL3RST: c_int = 47; +pub const ELNRNG: c_int = 48; +pub const EUNATCH: c_int = 49; +pub const ENOCSI: c_int = 50; +pub const EL2HLT: c_int = 51; +pub const EBADE: c_int = 52; +pub const EBADR: c_int = 53; +pub const EXFULL: c_int = 54; +pub const ENOANO: c_int = 55; +pub const EBADRQC: c_int = 56; +pub const EBADSLT: c_int = 57; +pub const EDEADLOCK: c_int = EDEADLK; +pub const EMULTIHOP: c_int = 72; +pub const EBADMSG: c_int = 74; +pub const EOVERFLOW: c_int = 75; +pub const ENOTUNIQ: c_int = 76; +pub const EBADFD: c_int = 77; +pub const EREMCHG: c_int = 78; +pub const ELIBACC: c_int = 79; +pub const ELIBBAD: c_int = 80; +pub const ELIBSCN: c_int = 81; +pub const ELIBMAX: c_int = 82; +pub const ELIBEXEC: c_int = 83; +pub const EILSEQ: c_int = 84; +pub const ERESTART: c_int = 85; +pub const ESTRPIPE: c_int = 86; +pub const EUSERS: c_int = 87; +pub const ENOTSOCK: c_int = 88; +pub const EDESTADDRREQ: c_int = 89; +pub const EMSGSIZE: c_int = 90; +pub const EPROTOTYPE: c_int = 91; +pub const ENOPROTOOPT: c_int = 92; +pub const EPROTONOSUPPORT: c_int = 93; +pub const ESOCKTNOSUPPORT: c_int = 94; +pub const EOPNOTSUPP: c_int = 95; +pub const ENOTSUP: c_int = EOPNOTSUPP; +pub const EPFNOSUPPORT: c_int = 96; +pub const EAFNOSUPPORT: c_int = 97; +pub const EADDRINUSE: c_int = 98; +pub const EADDRNOTAVAIL: c_int = 99; +pub const ENETDOWN: c_int = 100; +pub const ENETUNREACH: c_int = 101; +pub const ENETRESET: c_int = 102; +pub const ECONNABORTED: c_int = 103; +pub const ECONNRESET: c_int = 104; +pub const ENOBUFS: c_int = 105; +pub const EISCONN: c_int = 106; +pub const ENOTCONN: c_int = 107; +pub const ESHUTDOWN: c_int = 108; +pub const ETOOMANYREFS: c_int = 109; +pub const ETIMEDOUT: c_int = 110; +pub const ECONNREFUSED: c_int = 111; +pub const EHOSTDOWN: c_int = 112; +pub const EHOSTUNREACH: c_int = 113; +pub const EALREADY: c_int = 114; +pub const EINPROGRESS: c_int = 115; +pub const ESTALE: c_int = 116; +pub const EUCLEAN: c_int = 117; +pub const ENOTNAM: c_int = 118; +pub const ENAVAIL: c_int = 119; +pub const EISNAM: c_int = 120; +pub const EREMOTEIO: c_int = 121; +pub const EDQUOT: c_int = 122; +pub const ENOMEDIUM: c_int = 123; +pub const EMEDIUMTYPE: c_int = 124; +pub const ECANCELED: c_int = 125; +pub const ENOKEY: c_int = 126; +pub const EKEYEXPIRED: c_int = 127; +pub const EKEYREVOKED: c_int = 128; +pub const EKEYREJECTED: c_int = 129; +pub const EOWNERDEAD: c_int = 130; +pub const ENOTRECOVERABLE: c_int = 131; +pub const ERFKILL: c_int = 132; +pub const EHWPOISON: c_int = 133; + +pub const SA_ONSTACK: c_int = 0x08000000; +pub const SA_SIGINFO: c_int = 0x00000004; +pub const SA_NOCLDWAIT: c_int = 0x00000002; + +pub const SIGCHLD: c_int = 17; +pub const SIGBUS: c_int = 7; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGUSR1: c_int = 10; +pub const SIGUSR2: c_int = 12; +pub const SIGCONT: c_int = 18; +pub const SIGSTOP: c_int = 19; +pub const SIGTSTP: c_int = 20; +pub const SIGURG: c_int = 23; +pub const SIGIO: c_int = 29; +pub const SIGSYS: c_int = 31; +pub const SIGSTKFLT: c_int = 16; +pub const SIGPOLL: c_int = 29; +pub const SIGPWR: c_int = 30; +pub const SIG_SETMASK: c_int = 2; +pub const SIG_BLOCK: c_int = 0x000000; +pub const SIG_UNBLOCK: c_int = 0x01; + +pub const EXTPROC: crate::tcflag_t = 0x00010000; + +pub const MAP_HUGETLB: c_int = 0x040000; +pub const MAP_32BIT: c_int = 0x0040; + +pub const F_GETLK: c_int = 12; +pub const F_GETOWN: c_int = 9; +pub const F_SETLK: c_int = 13; +pub const F_SETLKW: c_int = 14; +pub const F_SETOWN: c_int = 8; + +pub const VEOF: usize = 4; +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: crate::tcflag_t = 0x00008000; +pub const TOSTOP: crate::tcflag_t = 0x00000100; +pub const FLUSHO: crate::tcflag_t = 0x00001000; + +pub const POLLWRNORM: c_short = 0x100; +pub const POLLWRBAND: c_short = 0x200; + +pub const PTRACE_SYSEMU: c_int = 31; +pub const PTRACE_SYSEMU_SINGLESTEP: c_int = 32; + +// Syscall table +pub const SYS_restart_syscall: c_long = 0; +pub const SYS_exit: c_long = 1; +pub const SYS_fork: c_long = 2; +pub const SYS_read: c_long = 3; +pub const SYS_write: c_long = 4; +pub const SYS_open: c_long = 5; +pub const SYS_close: c_long = 6; +pub const SYS_waitpid: c_long = 7; +pub const SYS_creat: c_long = 8; +pub const SYS_link: c_long = 9; +pub const SYS_unlink: c_long = 10; +pub const SYS_execve: c_long = 11; +pub const SYS_chdir: c_long = 12; +pub const SYS_time: c_long = 13; +pub const SYS_mknod: c_long = 14; +pub const SYS_chmod: c_long = 15; +pub const SYS_lchown: c_long = 16; +pub const SYS_break: c_long = 17; +pub const SYS_oldstat: c_long = 18; +pub const SYS_lseek: c_long = 19; +pub const SYS_getpid: c_long = 20; +pub const SYS_mount: c_long = 21; +pub const SYS_umount: c_long = 22; +pub const SYS_setuid: c_long = 23; +pub const SYS_getuid: c_long = 24; +pub const SYS_stime: c_long = 25; +pub const SYS_ptrace: c_long = 26; +pub const SYS_alarm: c_long = 27; +pub const SYS_oldfstat: c_long = 28; +pub const SYS_pause: c_long = 29; +pub const SYS_utime: c_long = 30; +pub const SYS_stty: c_long = 31; +pub const SYS_gtty: c_long = 32; +pub const SYS_access: c_long = 33; +pub const SYS_nice: c_long = 34; +pub const SYS_ftime: c_long = 35; +pub const SYS_sync: c_long = 36; +pub const SYS_kill: c_long = 37; +pub const SYS_rename: c_long = 38; +pub const SYS_mkdir: c_long = 39; +pub const SYS_rmdir: c_long = 40; +pub const SYS_dup: c_long = 41; +pub const SYS_pipe: c_long = 42; +pub const SYS_times: c_long = 43; +pub const SYS_prof: c_long = 44; +pub const SYS_brk: c_long = 45; +pub const SYS_setgid: c_long = 46; +pub const SYS_getgid: c_long = 47; +pub const SYS_signal: c_long = 48; +pub const SYS_geteuid: c_long = 49; +pub const SYS_getegid: c_long = 50; +pub const SYS_acct: c_long = 51; +pub const SYS_umount2: c_long = 52; +pub const SYS_lock: c_long = 53; +pub const SYS_ioctl: c_long = 54; +pub const SYS_fcntl: c_long = 55; +pub const SYS_mpx: c_long = 56; +pub const SYS_setpgid: c_long = 57; +pub const SYS_ulimit: c_long = 58; +pub const SYS_oldolduname: c_long = 59; +pub const SYS_umask: c_long = 60; +pub const SYS_chroot: c_long = 61; +pub const SYS_ustat: c_long = 62; +pub const SYS_dup2: c_long = 63; +pub const SYS_getppid: c_long = 64; +pub const SYS_getpgrp: c_long = 65; +pub const SYS_setsid: c_long = 66; +pub const SYS_sigaction: c_long = 67; +pub const SYS_sgetmask: c_long = 68; +pub const SYS_ssetmask: c_long = 69; +pub const SYS_setreuid: c_long = 70; +pub const SYS_setregid: c_long = 71; +pub const SYS_sigsuspend: c_long = 72; +pub const SYS_sigpending: c_long = 73; +pub const SYS_sethostname: c_long = 74; +pub const SYS_setrlimit: c_long = 75; +pub const SYS_getrlimit: c_long = 76; +pub const SYS_getrusage: c_long = 77; +pub const SYS_gettimeofday: c_long = 78; +pub const SYS_settimeofday: c_long = 79; +pub const SYS_getgroups: c_long = 80; +pub const SYS_setgroups: c_long = 81; +pub const SYS_select: c_long = 82; +pub const SYS_symlink: c_long = 83; +pub const SYS_oldlstat: c_long = 84; +pub const SYS_readlink: c_long = 85; +pub const SYS_uselib: c_long = 86; +pub const SYS_swapon: c_long = 87; +pub const SYS_reboot: c_long = 88; +pub const SYS_readdir: c_long = 89; +pub const SYS_mmap: c_long = 90; +pub const SYS_munmap: c_long = 91; +pub const SYS_truncate: c_long = 92; +pub const SYS_ftruncate: c_long = 93; +pub const SYS_fchmod: c_long = 94; +pub const SYS_fchown: c_long = 95; +pub const SYS_getpriority: c_long = 96; +pub const SYS_setpriority: c_long = 97; +pub const SYS_profil: c_long = 98; +pub const SYS_statfs: c_long = 99; +pub const SYS_fstatfs: c_long = 100; +pub const SYS_ioperm: c_long = 101; +pub const SYS_socketcall: c_long = 102; +pub const SYS_syslog: c_long = 103; +pub const SYS_setitimer: c_long = 104; +pub const SYS_getitimer: c_long = 105; +pub const SYS_stat: c_long = 106; +pub const SYS_lstat: c_long = 107; +pub const SYS_fstat: c_long = 108; +pub const SYS_olduname: c_long = 109; +pub const SYS_iopl: c_long = 110; +pub const SYS_vhangup: c_long = 111; +pub const SYS_idle: c_long = 112; +pub const SYS_vm86old: c_long = 113; +pub const SYS_wait4: c_long = 114; +pub const SYS_swapoff: c_long = 115; +pub const SYS_sysinfo: c_long = 116; +pub const SYS_ipc: c_long = 117; +pub const SYS_fsync: c_long = 118; +pub const SYS_sigreturn: c_long = 119; +pub const SYS_clone: c_long = 120; +pub const SYS_setdomainname: c_long = 121; +pub const SYS_uname: c_long = 122; +pub const SYS_modify_ldt: c_long = 123; +pub const SYS_adjtimex: c_long = 124; +pub const SYS_mprotect: c_long = 125; +pub const SYS_sigprocmask: c_long = 126; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_create_module: c_long = 127; +pub const SYS_init_module: c_long = 128; +pub const SYS_delete_module: c_long = 129; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_get_kernel_syms: c_long = 130; +pub const SYS_quotactl: c_long = 131; +pub const SYS_getpgid: c_long = 132; +pub const SYS_fchdir: c_long = 133; +pub const SYS_bdflush: c_long = 134; +pub const SYS_sysfs: c_long = 135; +pub const SYS_personality: c_long = 136; +pub const SYS_afs_syscall: c_long = 137; +pub const SYS_setfsuid: c_long = 138; +pub const SYS_setfsgid: c_long = 139; +pub const SYS__llseek: c_long = 140; +pub const SYS_getdents: c_long = 141; +pub const SYS__newselect: c_long = 142; +pub const SYS_flock: c_long = 143; +pub const SYS_msync: c_long = 144; +pub const SYS_readv: c_long = 145; +pub const SYS_writev: c_long = 146; +pub const SYS_getsid: c_long = 147; +pub const SYS_fdatasync: c_long = 148; +pub const SYS__sysctl: c_long = 149; +pub const SYS_mlock: c_long = 150; +pub const SYS_munlock: c_long = 151; +pub const SYS_mlockall: c_long = 152; +pub const SYS_munlockall: c_long = 153; +pub const SYS_sched_setparam: c_long = 154; +pub const SYS_sched_getparam: c_long = 155; +pub const SYS_sched_setscheduler: c_long = 156; +pub const SYS_sched_getscheduler: c_long = 157; +pub const SYS_sched_yield: c_long = 158; +pub const SYS_sched_get_priority_max: c_long = 159; +pub const SYS_sched_get_priority_min: c_long = 160; +pub const SYS_sched_rr_get_interval: c_long = 161; +pub const SYS_nanosleep: c_long = 162; +pub const SYS_mremap: c_long = 163; +pub const SYS_setresuid: c_long = 164; +pub const SYS_getresuid: c_long = 165; +pub const SYS_vm86: c_long = 166; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_query_module: c_long = 167; +pub const SYS_poll: c_long = 168; +pub const SYS_nfsservctl: c_long = 169; +pub const SYS_setresgid: c_long = 170; +pub const SYS_getresgid: c_long = 171; +pub const SYS_prctl: c_long = 172; +pub const SYS_rt_sigreturn: c_long = 173; +pub const SYS_rt_sigaction: c_long = 174; +pub const SYS_rt_sigprocmask: c_long = 175; +pub const SYS_rt_sigpending: c_long = 176; +pub const SYS_rt_sigtimedwait: c_long = 177; +pub const SYS_rt_sigqueueinfo: c_long = 178; +pub const SYS_rt_sigsuspend: c_long = 179; +pub const SYS_pread64: c_long = 180; +pub const SYS_pwrite64: c_long = 181; +pub const SYS_chown: c_long = 182; +pub const SYS_getcwd: c_long = 183; +pub const SYS_capget: c_long = 184; +pub const SYS_capset: c_long = 185; +pub const SYS_sigaltstack: c_long = 186; +pub const SYS_sendfile: c_long = 187; +pub const SYS_getpmsg: c_long = 188; +pub const SYS_putpmsg: c_long = 189; +pub const SYS_vfork: c_long = 190; +pub const SYS_ugetrlimit: c_long = 191; +pub const SYS_mmap2: c_long = 192; +pub const SYS_truncate64: c_long = 193; +pub const SYS_ftruncate64: c_long = 194; +pub const SYS_stat64: c_long = 195; +pub const SYS_lstat64: c_long = 196; +pub const SYS_fstat64: c_long = 197; +pub const SYS_lchown32: c_long = 198; +pub const SYS_getuid32: c_long = 199; +pub const SYS_getgid32: c_long = 200; +pub const SYS_geteuid32: c_long = 201; +pub const SYS_getegid32: c_long = 202; +pub const SYS_setreuid32: c_long = 203; +pub const SYS_setregid32: c_long = 204; +pub const SYS_getgroups32: c_long = 205; +pub const SYS_setgroups32: c_long = 206; +pub const SYS_fchown32: c_long = 207; +pub const SYS_setresuid32: c_long = 208; +pub const SYS_getresuid32: c_long = 209; +pub const SYS_setresgid32: c_long = 210; +pub const SYS_getresgid32: c_long = 211; +pub const SYS_chown32: c_long = 212; +pub const SYS_setuid32: c_long = 213; +pub const SYS_setgid32: c_long = 214; +pub const SYS_setfsuid32: c_long = 215; +pub const SYS_setfsgid32: c_long = 216; +pub const SYS_pivot_root: c_long = 217; +pub const SYS_mincore: c_long = 218; +pub const SYS_madvise: c_long = 219; +pub const SYS_getdents64: c_long = 220; +pub const SYS_fcntl64: c_long = 221; +pub const SYS_gettid: c_long = 224; +pub const SYS_readahead: c_long = 225; +pub const SYS_setxattr: c_long = 226; +pub const SYS_lsetxattr: c_long = 227; +pub const SYS_fsetxattr: c_long = 228; +pub const SYS_getxattr: c_long = 229; +pub const SYS_lgetxattr: c_long = 230; +pub const SYS_fgetxattr: c_long = 231; +pub const SYS_listxattr: c_long = 232; +pub const SYS_llistxattr: c_long = 233; +pub const SYS_flistxattr: c_long = 234; +pub const SYS_removexattr: c_long = 235; +pub const SYS_lremovexattr: c_long = 236; +pub const SYS_fremovexattr: c_long = 237; +pub const SYS_tkill: c_long = 238; +pub const SYS_sendfile64: c_long = 239; +pub const SYS_futex: c_long = 240; +pub const SYS_sched_setaffinity: c_long = 241; +pub const SYS_sched_getaffinity: c_long = 242; +pub const SYS_set_thread_area: c_long = 243; +pub const SYS_get_thread_area: c_long = 244; +pub const SYS_io_setup: c_long = 245; +pub const SYS_io_destroy: c_long = 246; +pub const SYS_io_getevents: c_long = 247; +pub const SYS_io_submit: c_long = 248; +pub const SYS_io_cancel: c_long = 249; +pub const SYS_fadvise64: c_long = 250; +pub const SYS_exit_group: c_long = 252; +pub const SYS_lookup_dcookie: c_long = 253; +pub const SYS_epoll_create: c_long = 254; +pub const SYS_epoll_ctl: c_long = 255; +pub const SYS_epoll_wait: c_long = 256; +pub const SYS_remap_file_pages: c_long = 257; +pub const SYS_set_tid_address: c_long = 258; +pub const SYS_timer_create: c_long = 259; +pub const SYS_timer_settime: c_long = 260; +pub const SYS_timer_gettime: c_long = 261; +pub const SYS_timer_getoverrun: c_long = 262; +pub const SYS_timer_delete: c_long = 263; +pub const SYS_clock_settime: c_long = 264; +pub const SYS_clock_gettime: c_long = 265; +pub const SYS_clock_getres: c_long = 266; +pub const SYS_clock_nanosleep: c_long = 267; +pub const SYS_statfs64: c_long = 268; +pub const SYS_fstatfs64: c_long = 269; +pub const SYS_tgkill: c_long = 270; +pub const SYS_utimes: c_long = 271; +pub const SYS_fadvise64_64: c_long = 272; +pub const SYS_vserver: c_long = 273; +pub const SYS_mbind: c_long = 274; +pub const SYS_get_mempolicy: c_long = 275; +pub const SYS_set_mempolicy: c_long = 276; +pub const SYS_mq_open: c_long = 277; +pub const SYS_mq_unlink: c_long = 278; +pub const SYS_mq_timedsend: c_long = 279; +pub const SYS_mq_timedreceive: c_long = 280; +pub const SYS_mq_notify: c_long = 281; +pub const SYS_mq_getsetattr: c_long = 282; +pub const SYS_kexec_load: c_long = 283; +pub const SYS_waitid: c_long = 284; +pub const SYS_add_key: c_long = 286; +pub const SYS_request_key: c_long = 287; +pub const SYS_keyctl: c_long = 288; +pub const SYS_ioprio_set: c_long = 289; +pub const SYS_ioprio_get: c_long = 290; +pub const SYS_inotify_init: c_long = 291; +pub const SYS_inotify_add_watch: c_long = 292; +pub const SYS_inotify_rm_watch: c_long = 293; +pub const SYS_migrate_pages: c_long = 294; +pub const SYS_openat: c_long = 295; +pub const SYS_mkdirat: c_long = 296; +pub const SYS_mknodat: c_long = 297; +pub const SYS_fchownat: c_long = 298; +pub const SYS_futimesat: c_long = 299; +pub const SYS_fstatat64: c_long = 300; +pub const SYS_unlinkat: c_long = 301; +pub const SYS_renameat: c_long = 302; +pub const SYS_linkat: c_long = 303; +pub const SYS_symlinkat: c_long = 304; +pub const SYS_readlinkat: c_long = 305; +pub const SYS_fchmodat: c_long = 306; +pub const SYS_faccessat: c_long = 307; +pub const SYS_pselect6: c_long = 308; +pub const SYS_ppoll: c_long = 309; +pub const SYS_unshare: c_long = 310; +pub const SYS_set_robust_list: c_long = 311; +pub const SYS_get_robust_list: c_long = 312; +pub const SYS_splice: c_long = 313; +pub const SYS_sync_file_range: c_long = 314; +pub const SYS_tee: c_long = 315; +pub const SYS_vmsplice: c_long = 316; +pub const SYS_move_pages: c_long = 317; +pub const SYS_getcpu: c_long = 318; +pub const SYS_epoll_pwait: c_long = 319; +pub const SYS_utimensat: c_long = 320; +pub const SYS_signalfd: c_long = 321; +pub const SYS_timerfd_create: c_long = 322; +pub const SYS_eventfd: c_long = 323; +pub const SYS_fallocate: c_long = 324; +pub const SYS_timerfd_settime: c_long = 325; +pub const SYS_timerfd_gettime: c_long = 326; +pub const SYS_signalfd4: c_long = 327; +pub const SYS_eventfd2: c_long = 328; +pub const SYS_epoll_create1: c_long = 329; +pub const SYS_dup3: c_long = 330; +pub const SYS_pipe2: c_long = 331; +pub const SYS_inotify_init1: c_long = 332; +pub const SYS_preadv: c_long = 333; +pub const SYS_pwritev: c_long = 334; +pub const SYS_rt_tgsigqueueinfo: c_long = 335; +pub const SYS_perf_event_open: c_long = 336; +pub const SYS_recvmmsg: c_long = 337; +pub const SYS_fanotify_init: c_long = 338; +pub const SYS_fanotify_mark: c_long = 339; +pub const SYS_prlimit64: c_long = 340; +pub const SYS_name_to_handle_at: c_long = 341; +pub const SYS_open_by_handle_at: c_long = 342; +pub const SYS_clock_adjtime: c_long = 343; +pub const SYS_syncfs: c_long = 344; +pub const SYS_sendmmsg: c_long = 345; +pub const SYS_setns: c_long = 346; +pub const SYS_process_vm_readv: c_long = 347; +pub const SYS_process_vm_writev: c_long = 348; +pub const SYS_kcmp: c_long = 349; +pub const SYS_finit_module: c_long = 350; +pub const SYS_sched_setattr: c_long = 351; +pub const SYS_sched_getattr: c_long = 352; +pub const SYS_renameat2: c_long = 353; +pub const SYS_seccomp: c_long = 354; +pub const SYS_getrandom: c_long = 355; +pub const SYS_memfd_create: c_long = 356; +pub const SYS_bpf: c_long = 357; +pub const SYS_execveat: c_long = 358; +pub const SYS_socket: c_long = 359; +pub const SYS_socketpair: c_long = 360; +pub const SYS_bind: c_long = 361; +pub const SYS_connect: c_long = 362; +pub const SYS_listen: c_long = 363; +pub const SYS_accept4: c_long = 364; +pub const SYS_getsockopt: c_long = 365; +pub const SYS_setsockopt: c_long = 366; +pub const SYS_getsockname: c_long = 367; +pub const SYS_getpeername: c_long = 368; +pub const SYS_sendto: c_long = 369; +pub const SYS_sendmsg: c_long = 370; +pub const SYS_recvfrom: c_long = 371; +pub const SYS_recvmsg: c_long = 372; +pub const SYS_shutdown: c_long = 373; +pub const SYS_userfaultfd: c_long = 374; +pub const SYS_membarrier: c_long = 375; +pub const SYS_mlock2: c_long = 376; +pub const SYS_copy_file_range: c_long = 377; +pub const SYS_preadv2: c_long = 378; +pub const SYS_pwritev2: c_long = 379; +pub const SYS_pkey_mprotect: c_long = 380; +pub const SYS_pkey_alloc: c_long = 381; +pub const SYS_pkey_free: c_long = 382; +pub const SYS_statx: c_long = 383; +pub const SYS_pidfd_send_signal: c_long = 424; +pub const SYS_io_uring_setup: c_long = 425; +pub const SYS_io_uring_enter: c_long = 426; +pub const SYS_io_uring_register: c_long = 427; +pub const SYS_open_tree: c_long = 428; +pub const SYS_move_mount: c_long = 429; +pub const SYS_fsopen: c_long = 430; +pub const SYS_fsconfig: c_long = 431; +pub const SYS_fsmount: c_long = 432; +pub const SYS_fspick: c_long = 433; +pub const SYS_pidfd_open: c_long = 434; +pub const SYS_clone3: c_long = 435; +pub const SYS_close_range: c_long = 436; +pub const SYS_openat2: c_long = 437; +pub const SYS_pidfd_getfd: c_long = 438; +pub const SYS_faccessat2: c_long = 439; +pub const SYS_process_madvise: c_long = 440; +pub const SYS_epoll_pwait2: c_long = 441; +pub const SYS_mount_setattr: c_long = 442; +pub const SYS_quotactl_fd: c_long = 443; +pub const SYS_landlock_create_ruleset: c_long = 444; +pub const SYS_landlock_add_rule: c_long = 445; +pub const SYS_landlock_restrict_self: c_long = 446; +pub const SYS_memfd_secret: c_long = 447; +pub const SYS_process_mrelease: c_long = 448; +pub const SYS_futex_waitv: c_long = 449; +pub const SYS_set_mempolicy_home_node: c_long = 450; +pub const SYS_fchmodat2: c_long = 452; + +// offsets in user_regs_structs, from sys/reg.h +pub const EBX: c_int = 0; +pub const ECX: c_int = 1; +pub const EDX: c_int = 2; +pub const ESI: c_int = 3; +pub const EDI: c_int = 4; +pub const EBP: c_int = 5; +pub const EAX: c_int = 6; +pub const DS: c_int = 7; +pub const ES: c_int = 8; +pub const FS: c_int = 9; +pub const GS: c_int = 10; +pub const ORIG_EAX: c_int = 11; +pub const EIP: c_int = 12; +pub const CS: c_int = 13; +pub const EFL: c_int = 14; +pub const UESP: c_int = 15; +pub const SS: c_int = 16; diff --git a/http/vendor/libc/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs new file mode 100644 index 0000000..82df29b --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs @@ -0,0 +1,689 @@ +use crate::off_t; +use crate::prelude::*; + +pub type __u64 = c_ulonglong; +pub type __s64 = c_longlong; +pub type wchar_t = u32; +pub type nlink_t = u32; +pub type blksize_t = c_int; + +pub type stat64 = stat; + +s! { + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + __pad0: Padding, + pub st_size: off_t, + pub st_blksize: crate::blksize_t, + __pad1: Padding, + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + __unused: Padding<[c_uint; 2]>, + } + + pub struct user_regs_struct { + pub regs: [c_ulonglong; 31], + pub sp: c_ulonglong, + pub pc: c_ulonglong, + pub pstate: c_ulonglong, + } + + pub struct ipc_perm { + #[cfg(musl_v1_2_3)] + pub __key: crate::key_t, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "This field is incorrectly named and will be changed + to __key in a future release." + )] + pub __ipc_perm_key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: crate::mode_t, + + #[cfg(musl_v1_2_3)] + pub __seq: c_int, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "The type of this field has changed from c_ushort to c_int, + we'll follow that change in the future release." + )] + pub __seq: c_ushort, + __unused1: Padding, + __unused2: Padding, + } + + pub struct ucontext_t { + pub uc_flags: c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: crate::stack_t, + pub uc_sigmask: crate::sigset_t, + pub uc_mcontext: mcontext_t, + } + + #[repr(align(16))] + pub struct mcontext_t { + pub fault_address: c_ulong, + pub regs: [c_ulong; 31], + pub sp: c_ulong, + pub pc: c_ulong, + pub pstate: c_ulong, + __reserved: Padding<[u64; 512]>, + } + + #[repr(align(8))] + pub struct clone_args { + pub flags: c_ulonglong, + pub pidfd: c_ulonglong, + pub child_tid: c_ulonglong, + pub parent_tid: c_ulonglong, + pub exit_signal: c_ulonglong, + pub stack: c_ulonglong, + pub stack_size: c_ulonglong, + pub tls: c_ulonglong, + pub set_tid: c_ulonglong, + pub set_tid_size: c_ulonglong, + pub cgroup: c_ulonglong, + } + + pub struct user_fpsimd_struct { + pub vregs: [u128; 32], + pub fpsr: u32, + pub fpcr: u32, + } +} + +s_no_extra_traits! { + #[repr(align(16))] + pub struct max_align_t { + priv_: [f32; 8], + } +} + +pub const O_APPEND: c_int = 1024; +pub const O_DIRECT: c_int = 0x10000; +pub const O_DIRECTORY: c_int = 0x4000; +pub const O_LARGEFILE: c_int = 0x20000; +pub const O_NOFOLLOW: c_int = 0x8000; +pub const O_CREAT: c_int = 64; +pub const O_EXCL: c_int = 128; +pub const O_NOCTTY: c_int = 256; +pub const O_NONBLOCK: c_int = 2048; +pub const O_SYNC: c_int = 1052672; +pub const O_RSYNC: c_int = 1052672; +pub const O_DSYNC: c_int = 4096; +pub const O_ASYNC: c_int = 0x2000; + +pub const ENAMETOOLONG: c_int = 36; +pub const ENOLCK: c_int = 37; +pub const ENOSYS: c_int = 38; +pub const ENOTEMPTY: c_int = 39; +pub const ELOOP: c_int = 40; +pub const ENOMSG: c_int = 42; +pub const EIDRM: c_int = 43; +pub const ECHRNG: c_int = 44; +pub const EL2NSYNC: c_int = 45; +pub const EL3HLT: c_int = 46; +pub const EL3RST: c_int = 47; +pub const ELNRNG: c_int = 48; +pub const EUNATCH: c_int = 49; +pub const ENOCSI: c_int = 50; +pub const EL2HLT: c_int = 51; +pub const EBADE: c_int = 52; +pub const EBADR: c_int = 53; +pub const EXFULL: c_int = 54; +pub const ENOANO: c_int = 55; +pub const EBADRQC: c_int = 56; +pub const EBADSLT: c_int = 57; +pub const EMULTIHOP: c_int = 72; +pub const EBADMSG: c_int = 74; +pub const EOVERFLOW: c_int = 75; +pub const ENOTUNIQ: c_int = 76; +pub const EBADFD: c_int = 77; +pub const EREMCHG: c_int = 78; +pub const ELIBACC: c_int = 79; +pub const ELIBBAD: c_int = 80; +pub const ELIBSCN: c_int = 81; +pub const ELIBMAX: c_int = 82; +pub const ELIBEXEC: c_int = 83; +pub const EILSEQ: c_int = 84; +pub const ERESTART: c_int = 85; +pub const ESTRPIPE: c_int = 86; +pub const EUSERS: c_int = 87; +pub const ENOTSOCK: c_int = 88; +pub const EDESTADDRREQ: c_int = 89; +pub const EMSGSIZE: c_int = 90; +pub const EPROTOTYPE: c_int = 91; +pub const ENOPROTOOPT: c_int = 92; +pub const EPROTONOSUPPORT: c_int = 93; +pub const ESOCKTNOSUPPORT: c_int = 94; +pub const EOPNOTSUPP: c_int = 95; +pub const ENOTSUP: c_int = EOPNOTSUPP; +pub const EPFNOSUPPORT: c_int = 96; +pub const EAFNOSUPPORT: c_int = 97; +pub const EADDRINUSE: c_int = 98; +pub const EADDRNOTAVAIL: c_int = 99; +pub const ENETDOWN: c_int = 100; +pub const ENETUNREACH: c_int = 101; +pub const ENETRESET: c_int = 102; +pub const ECONNABORTED: c_int = 103; +pub const ECONNRESET: c_int = 104; +pub const ENOBUFS: c_int = 105; +pub const EISCONN: c_int = 106; +pub const ENOTCONN: c_int = 107; +pub const ESHUTDOWN: c_int = 108; +pub const ETOOMANYREFS: c_int = 109; +pub const ETIMEDOUT: c_int = 110; +pub const ECONNREFUSED: c_int = 111; +pub const EHOSTDOWN: c_int = 112; +pub const EHOSTUNREACH: c_int = 113; +pub const EALREADY: c_int = 114; +pub const EINPROGRESS: c_int = 115; +pub const ESTALE: c_int = 116; +pub const EUCLEAN: c_int = 117; +pub const ENOTNAM: c_int = 118; +pub const ENAVAIL: c_int = 119; +pub const EISNAM: c_int = 120; +pub const EREMOTEIO: c_int = 121; +pub const EDQUOT: c_int = 122; +pub const ENOMEDIUM: c_int = 123; +pub const EMEDIUMTYPE: c_int = 124; +pub const ECANCELED: c_int = 125; +pub const ENOKEY: c_int = 126; +pub const EKEYEXPIRED: c_int = 127; +pub const EKEYREVOKED: c_int = 128; +pub const EKEYREJECTED: c_int = 129; +pub const EOWNERDEAD: c_int = 130; +pub const ENOTRECOVERABLE: c_int = 131; +pub const ERFKILL: c_int = 132; +pub const EHWPOISON: c_int = 133; + +// bits/hwcap.h +pub const HWCAP_FP: c_ulong = 1 << 0; +pub const HWCAP_ASIMD: c_ulong = 1 << 1; +pub const HWCAP_EVTSTRM: c_ulong = 1 << 2; +pub const HWCAP_AES: c_ulong = 1 << 3; +pub const HWCAP_PMULL: c_ulong = 1 << 4; +pub const HWCAP_SHA1: c_ulong = 1 << 5; +pub const HWCAP_SHA2: c_ulong = 1 << 6; +pub const HWCAP_CRC32: c_ulong = 1 << 7; +pub const HWCAP_ATOMICS: c_ulong = 1 << 8; +pub const HWCAP_FPHP: c_ulong = 1 << 9; +pub const HWCAP_ASIMDHP: c_ulong = 1 << 10; +pub const HWCAP_CPUID: c_ulong = 1 << 11; +pub const HWCAP_ASIMDRDM: c_ulong = 1 << 12; +pub const HWCAP_JSCVT: c_ulong = 1 << 13; +pub const HWCAP_FCMA: c_ulong = 1 << 14; +pub const HWCAP_LRCPC: c_ulong = 1 << 15; +pub const HWCAP_DCPOP: c_ulong = 1 << 16; +pub const HWCAP_SHA3: c_ulong = 1 << 17; +pub const HWCAP_SM3: c_ulong = 1 << 18; +pub const HWCAP_SM4: c_ulong = 1 << 19; +pub const HWCAP_ASIMDDP: c_ulong = 1 << 20; +pub const HWCAP_SHA512: c_ulong = 1 << 21; +pub const HWCAP_SVE: c_ulong = 1 << 22; +pub const HWCAP_ASIMDFHM: c_ulong = 1 << 23; +pub const HWCAP_DIT: c_ulong = 1 << 24; +pub const HWCAP_USCAT: c_ulong = 1 << 25; +pub const HWCAP_ILRCPC: c_ulong = 1 << 26; +pub const HWCAP_FLAGM: c_ulong = 1 << 27; +pub const HWCAP_SSBS: c_ulong = 1 << 28; +pub const HWCAP_SB: c_ulong = 1 << 29; +pub const HWCAP_PACA: c_ulong = 1 << 30; +pub const HWCAP_PACG: c_ulong = 1 << 31; + +pub const MAP_ANON: c_int = 0x0020; +pub const MAP_GROWSDOWN: c_int = 0x0100; +pub const MAP_DENYWRITE: c_int = 0x0800; +pub const MAP_EXECUTABLE: c_int = 0x01000; +pub const MAP_LOCKED: c_int = 0x02000; +pub const MAP_NORESERVE: c_int = 0x04000; +pub const MAP_POPULATE: c_int = 0x08000; +pub const MAP_NONBLOCK: c_int = 0x010000; +pub const MAP_STACK: c_int = 0x020000; +pub const MAP_HUGETLB: c_int = 0x040000; +pub const MAP_SYNC: c_int = 0x080000; + +pub const SA_ONSTACK: c_int = 0x08000000; +pub const SA_SIGINFO: c_int = 0x00000004; +pub const SA_NOCLDWAIT: c_int = 0x00000002; + +pub const SIGCHLD: c_int = 17; +pub const SIGBUS: c_int = 7; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGUSR1: c_int = 10; +pub const SIGUSR2: c_int = 12; +pub const SIGCONT: c_int = 18; +pub const SIGSTOP: c_int = 19; +pub const SIGTSTP: c_int = 20; +pub const SIGURG: c_int = 23; +pub const SIGIO: c_int = 29; +pub const SIGSYS: c_int = 31; +pub const SIGSTKFLT: c_int = 16; +pub const SIGPOLL: c_int = 29; +pub const SIGPWR: c_int = 30; +pub const SIG_SETMASK: c_int = 2; +pub const SIG_BLOCK: c_int = 0x000000; +pub const SIG_UNBLOCK: c_int = 0x01; + +pub const F_GETLK: c_int = 5; +pub const F_GETOWN: c_int = 9; +pub const F_SETLK: c_int = 6; +pub const F_SETLKW: c_int = 7; +pub const F_SETOWN: c_int = 8; + +pub const VEOF: usize = 4; + +pub const POLLWRNORM: c_short = 0x100; +pub const POLLWRBAND: c_short = 0x200; + +pub const MINSIGSTKSZ: size_t = 6144; +pub const SIGSTKSZ: size_t = 12288; + +pub const MADV_SOFT_OFFLINE: c_int = 101; +pub const SYS_io_setup: c_long = 0; +pub const SYS_io_destroy: c_long = 1; +pub const SYS_io_submit: c_long = 2; +pub const SYS_io_cancel: c_long = 3; +pub const SYS_io_getevents: c_long = 4; +pub const SYS_setxattr: c_long = 5; +pub const SYS_lsetxattr: c_long = 6; +pub const SYS_fsetxattr: c_long = 7; +pub const SYS_getxattr: c_long = 8; +pub const SYS_lgetxattr: c_long = 9; +pub const SYS_fgetxattr: c_long = 10; +pub const SYS_listxattr: c_long = 11; +pub const SYS_llistxattr: c_long = 12; +pub const SYS_flistxattr: c_long = 13; +pub const SYS_removexattr: c_long = 14; +pub const SYS_lremovexattr: c_long = 15; +pub const SYS_fremovexattr: c_long = 16; +pub const SYS_getcwd: c_long = 17; +pub const SYS_lookup_dcookie: c_long = 18; +pub const SYS_eventfd2: c_long = 19; +pub const SYS_epoll_create1: c_long = 20; +pub const SYS_epoll_ctl: c_long = 21; +pub const SYS_epoll_pwait: c_long = 22; +pub const SYS_dup: c_long = 23; +pub const SYS_dup3: c_long = 24; +pub const SYS_fcntl: c_long = 25; +pub const SYS_inotify_init1: c_long = 26; +pub const SYS_inotify_add_watch: c_long = 27; +pub const SYS_inotify_rm_watch: c_long = 28; +pub const SYS_ioctl: c_long = 29; +pub const SYS_ioprio_set: c_long = 30; +pub const SYS_ioprio_get: c_long = 31; +pub const SYS_flock: c_long = 32; +pub const SYS_mknodat: c_long = 33; +pub const SYS_mkdirat: c_long = 34; +pub const SYS_unlinkat: c_long = 35; +pub const SYS_symlinkat: c_long = 36; +pub const SYS_linkat: c_long = 37; +pub const SYS_renameat: c_long = 38; +pub const SYS_umount2: c_long = 39; +pub const SYS_mount: c_long = 40; +pub const SYS_pivot_root: c_long = 41; +pub const SYS_nfsservctl: c_long = 42; +pub const SYS_statfs: c_long = 43; +pub const SYS_fstatfs: c_long = 44; +pub const SYS_truncate: c_long = 45; +pub const SYS_ftruncate: c_long = 46; +pub const SYS_fallocate: c_long = 47; +pub const SYS_faccessat: c_long = 48; +pub const SYS_chdir: c_long = 49; +pub const SYS_fchdir: c_long = 50; +pub const SYS_chroot: c_long = 51; +pub const SYS_fchmod: c_long = 52; +pub const SYS_fchmodat: c_long = 53; +pub const SYS_fchownat: c_long = 54; +pub const SYS_fchown: c_long = 55; +pub const SYS_openat: c_long = 56; +pub const SYS_close: c_long = 57; +pub const SYS_vhangup: c_long = 58; +pub const SYS_pipe2: c_long = 59; +pub const SYS_quotactl: c_long = 60; +pub const SYS_getdents64: c_long = 61; +pub const SYS_lseek: c_long = 62; +pub const SYS_read: c_long = 63; +pub const SYS_write: c_long = 64; +pub const SYS_readv: c_long = 65; +pub const SYS_writev: c_long = 66; +pub const SYS_pread64: c_long = 67; +pub const SYS_pwrite64: c_long = 68; +pub const SYS_preadv: c_long = 69; +pub const SYS_pwritev: c_long = 70; +pub const SYS_pselect6: c_long = 72; +pub const SYS_ppoll: c_long = 73; +pub const SYS_signalfd4: c_long = 74; +pub const SYS_vmsplice: c_long = 75; +pub const SYS_splice: c_long = 76; +pub const SYS_tee: c_long = 77; +pub const SYS_readlinkat: c_long = 78; +pub const SYS_newfstatat: c_long = 79; +pub const SYS_fstat: c_long = 80; +pub const SYS_sync: c_long = 81; +pub const SYS_fsync: c_long = 82; +pub const SYS_fdatasync: c_long = 83; +pub const SYS_sync_file_range: c_long = 84; +pub const SYS_timerfd_create: c_long = 85; +pub const SYS_timerfd_settime: c_long = 86; +pub const SYS_timerfd_gettime: c_long = 87; +pub const SYS_utimensat: c_long = 88; +pub const SYS_acct: c_long = 89; +pub const SYS_capget: c_long = 90; +pub const SYS_capset: c_long = 91; +pub const SYS_personality: c_long = 92; +pub const SYS_exit: c_long = 93; +pub const SYS_exit_group: c_long = 94; +pub const SYS_waitid: c_long = 95; +pub const SYS_set_tid_address: c_long = 96; +pub const SYS_unshare: c_long = 97; +pub const SYS_futex: c_long = 98; +pub const SYS_set_robust_list: c_long = 99; +pub const SYS_get_robust_list: c_long = 100; +pub const SYS_nanosleep: c_long = 101; +pub const SYS_getitimer: c_long = 102; +pub const SYS_setitimer: c_long = 103; +pub const SYS_kexec_load: c_long = 104; +pub const SYS_init_module: c_long = 105; +pub const SYS_delete_module: c_long = 106; +pub const SYS_timer_create: c_long = 107; +pub const SYS_timer_gettime: c_long = 108; +pub const SYS_timer_getoverrun: c_long = 109; +pub const SYS_timer_settime: c_long = 110; +pub const SYS_timer_delete: c_long = 111; +pub const SYS_clock_settime: c_long = 112; +pub const SYS_clock_gettime: c_long = 113; +pub const SYS_clock_getres: c_long = 114; +pub const SYS_clock_nanosleep: c_long = 115; +pub const SYS_syslog: c_long = 116; +pub const SYS_ptrace: c_long = 117; +pub const SYS_sched_setparam: c_long = 118; +pub const SYS_sched_setscheduler: c_long = 119; +pub const SYS_sched_getscheduler: c_long = 120; +pub const SYS_sched_getparam: c_long = 121; +pub const SYS_sched_setaffinity: c_long = 122; +pub const SYS_sched_getaffinity: c_long = 123; +pub const SYS_sched_yield: c_long = 124; +pub const SYS_sched_get_priority_max: c_long = 125; +pub const SYS_sched_get_priority_min: c_long = 126; +pub const SYS_sched_rr_get_interval: c_long = 127; +pub const SYS_restart_syscall: c_long = 128; +pub const SYS_kill: c_long = 129; +pub const SYS_tkill: c_long = 130; +pub const SYS_tgkill: c_long = 131; +pub const SYS_sigaltstack: c_long = 132; +pub const SYS_rt_sigsuspend: c_long = 133; +pub const SYS_rt_sigaction: c_long = 134; +pub const SYS_rt_sigprocmask: c_long = 135; +pub const SYS_rt_sigpending: c_long = 136; +pub const SYS_rt_sigtimedwait: c_long = 137; +pub const SYS_rt_sigqueueinfo: c_long = 138; +pub const SYS_rt_sigreturn: c_long = 139; +pub const SYS_setpriority: c_long = 140; +pub const SYS_getpriority: c_long = 141; +pub const SYS_reboot: c_long = 142; +pub const SYS_setregid: c_long = 143; +pub const SYS_setgid: c_long = 144; +pub const SYS_setreuid: c_long = 145; +pub const SYS_setuid: c_long = 146; +pub const SYS_setresuid: c_long = 147; +pub const SYS_getresuid: c_long = 148; +pub const SYS_setresgid: c_long = 149; +pub const SYS_getresgid: c_long = 150; +pub const SYS_setfsuid: c_long = 151; +pub const SYS_setfsgid: c_long = 152; +pub const SYS_times: c_long = 153; +pub const SYS_setpgid: c_long = 154; +pub const SYS_getpgid: c_long = 155; +pub const SYS_getsid: c_long = 156; +pub const SYS_setsid: c_long = 157; +pub const SYS_getgroups: c_long = 158; +pub const SYS_setgroups: c_long = 159; +pub const SYS_uname: c_long = 160; +pub const SYS_sethostname: c_long = 161; +pub const SYS_setdomainname: c_long = 162; +pub const SYS_getrlimit: c_long = 163; +pub const SYS_setrlimit: c_long = 164; +pub const SYS_getrusage: c_long = 165; +pub const SYS_umask: c_long = 166; +pub const SYS_prctl: c_long = 167; +pub const SYS_getcpu: c_long = 168; +pub const SYS_gettimeofday: c_long = 169; +pub const SYS_settimeofday: c_long = 170; +pub const SYS_adjtimex: c_long = 171; +pub const SYS_getpid: c_long = 172; +pub const SYS_getppid: c_long = 173; +pub const SYS_getuid: c_long = 174; +pub const SYS_geteuid: c_long = 175; +pub const SYS_getgid: c_long = 176; +pub const SYS_getegid: c_long = 177; +pub const SYS_gettid: c_long = 178; +pub const SYS_sysinfo: c_long = 179; +pub const SYS_mq_open: c_long = 180; +pub const SYS_mq_unlink: c_long = 181; +pub const SYS_mq_timedsend: c_long = 182; +pub const SYS_mq_timedreceive: c_long = 183; +pub const SYS_mq_notify: c_long = 184; +pub const SYS_mq_getsetattr: c_long = 185; +pub const SYS_msgget: c_long = 186; +pub const SYS_msgctl: c_long = 187; +pub const SYS_msgrcv: c_long = 188; +pub const SYS_msgsnd: c_long = 189; +pub const SYS_semget: c_long = 190; +pub const SYS_semctl: c_long = 191; +pub const SYS_semtimedop: c_long = 192; +pub const SYS_semop: c_long = 193; +pub const SYS_shmget: c_long = 194; +pub const SYS_shmctl: c_long = 195; +pub const SYS_shmat: c_long = 196; +pub const SYS_shmdt: c_long = 197; +pub const SYS_socket: c_long = 198; +pub const SYS_socketpair: c_long = 199; +pub const SYS_bind: c_long = 200; +pub const SYS_listen: c_long = 201; +pub const SYS_accept: c_long = 202; +pub const SYS_connect: c_long = 203; +pub const SYS_getsockname: c_long = 204; +pub const SYS_getpeername: c_long = 205; +pub const SYS_sendto: c_long = 206; +pub const SYS_recvfrom: c_long = 207; +pub const SYS_setsockopt: c_long = 208; +pub const SYS_getsockopt: c_long = 209; +pub const SYS_shutdown: c_long = 210; +pub const SYS_sendmsg: c_long = 211; +pub const SYS_recvmsg: c_long = 212; +pub const SYS_readahead: c_long = 213; +pub const SYS_brk: c_long = 214; +pub const SYS_munmap: c_long = 215; +pub const SYS_mremap: c_long = 216; +pub const SYS_add_key: c_long = 217; +pub const SYS_request_key: c_long = 218; +pub const SYS_keyctl: c_long = 219; +pub const SYS_clone: c_long = 220; +pub const SYS_execve: c_long = 221; +pub const SYS_mmap: c_long = 222; +pub const SYS_swapon: c_long = 224; +pub const SYS_swapoff: c_long = 225; +pub const SYS_mprotect: c_long = 226; +pub const SYS_msync: c_long = 227; +pub const SYS_mlock: c_long = 228; +pub const SYS_munlock: c_long = 229; +pub const SYS_mlockall: c_long = 230; +pub const SYS_munlockall: c_long = 231; +pub const SYS_mincore: c_long = 232; +pub const SYS_madvise: c_long = 233; +pub const SYS_remap_file_pages: c_long = 234; +pub const SYS_mbind: c_long = 235; +pub const SYS_get_mempolicy: c_long = 236; +pub const SYS_set_mempolicy: c_long = 237; +pub const SYS_migrate_pages: c_long = 238; +pub const SYS_move_pages: c_long = 239; +pub const SYS_rt_tgsigqueueinfo: c_long = 240; +pub const SYS_perf_event_open: c_long = 241; +pub const SYS_accept4: c_long = 242; +pub const SYS_recvmmsg: c_long = 243; +pub const SYS_wait4: c_long = 260; +pub const SYS_prlimit64: c_long = 261; +pub const SYS_fanotify_init: c_long = 262; +pub const SYS_fanotify_mark: c_long = 263; +pub const SYS_name_to_handle_at: c_long = 264; +pub const SYS_open_by_handle_at: c_long = 265; +pub const SYS_clock_adjtime: c_long = 266; +pub const SYS_syncfs: c_long = 267; +pub const SYS_setns: c_long = 268; +pub const SYS_sendmmsg: c_long = 269; +pub const SYS_process_vm_readv: c_long = 270; +pub const SYS_process_vm_writev: c_long = 271; +pub const SYS_kcmp: c_long = 272; +pub const SYS_finit_module: c_long = 273; +pub const SYS_sched_setattr: c_long = 274; +pub const SYS_sched_getattr: c_long = 275; +pub const SYS_renameat2: c_long = 276; +pub const SYS_seccomp: c_long = 277; +pub const SYS_getrandom: c_long = 278; +pub const SYS_memfd_create: c_long = 279; +pub const SYS_bpf: c_long = 280; +pub const SYS_execveat: c_long = 281; +pub const SYS_userfaultfd: c_long = 282; +pub const SYS_membarrier: c_long = 283; +pub const SYS_mlock2: c_long = 284; +pub const SYS_copy_file_range: c_long = 285; +pub const SYS_preadv2: c_long = 286; +pub const SYS_pwritev2: c_long = 287; +pub const SYS_pkey_mprotect: c_long = 288; +pub const SYS_pkey_alloc: c_long = 289; +pub const SYS_pkey_free: c_long = 290; +pub const SYS_statx: c_long = 291; +pub const SYS_io_pgetevents: c_long = 292; +pub const SYS_rseq: c_long = 293; +pub const SYS_pidfd_send_signal: c_long = 424; +pub const SYS_io_uring_setup: c_long = 425; +pub const SYS_io_uring_enter: c_long = 426; +pub const SYS_io_uring_register: c_long = 427; +pub const SYS_open_tree: c_long = 428; +pub const SYS_move_mount: c_long = 429; +pub const SYS_fsopen: c_long = 430; +pub const SYS_fsconfig: c_long = 431; +pub const SYS_fsmount: c_long = 432; +pub const SYS_fspick: c_long = 433; +pub const SYS_pidfd_open: c_long = 434; +pub const SYS_clone3: c_long = 435; +pub const SYS_close_range: c_long = 436; +pub const SYS_openat2: c_long = 437; +pub const SYS_pidfd_getfd: c_long = 438; +pub const SYS_faccessat2: c_long = 439; +pub const SYS_process_madvise: c_long = 440; +pub const SYS_epoll_pwait2: c_long = 441; +pub const SYS_mount_setattr: c_long = 442; +pub const SYS_quotactl_fd: c_long = 443; +pub const SYS_landlock_create_ruleset: c_long = 444; +pub const SYS_landlock_add_rule: c_long = 445; +pub const SYS_landlock_restrict_self: c_long = 446; +pub const SYS_memfd_secret: c_long = 447; +pub const SYS_process_mrelease: c_long = 448; +pub const SYS_futex_waitv: c_long = 449; +pub const SYS_set_mempolicy_home_node: c_long = 450; +pub const SYS_mseal: c_long = 462; + +pub const MCL_CURRENT: c_int = 0x0001; +pub const MCL_FUTURE: c_int = 0x0002; +pub const MCL_ONFAULT: c_int = 0x0004; +pub const CBAUD: crate::tcflag_t = 0o0010017; +pub const TAB1: c_int = 0x00000800; +pub const TAB2: c_int = 0x00001000; +pub const TAB3: c_int = 0x00001800; +pub const CR1: c_int = 0x00000200; +pub const CR2: c_int = 0x00000400; +pub const CR3: c_int = 0x00000600; +pub const FF1: c_int = 0x00008000; +pub const BS1: c_int = 0x00002000; +pub const VT1: c_int = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: crate::tcflag_t = 0x00000400; +pub const IXOFF: crate::tcflag_t = 0x00001000; +pub const ONLCR: crate::tcflag_t = 0x4; +pub const CSIZE: crate::tcflag_t = 0x00000030; +pub const CS6: crate::tcflag_t = 0x00000010; +pub const CS7: crate::tcflag_t = 0x00000020; +pub const CS8: crate::tcflag_t = 0x00000030; +pub const CSTOPB: crate::tcflag_t = 0x00000040; +pub const CREAD: crate::tcflag_t = 0x00000080; +pub const PARENB: crate::tcflag_t = 0x00000100; +pub const PARODD: crate::tcflag_t = 0x00000200; +pub const HUPCL: crate::tcflag_t = 0x00000400; +pub const CLOCAL: crate::tcflag_t = 0x00000800; +pub const ECHOKE: crate::tcflag_t = 0x00000800; +pub const ECHOE: crate::tcflag_t = 0x00000010; +pub const ECHOK: crate::tcflag_t = 0x00000020; +pub const ECHONL: crate::tcflag_t = 0x00000040; +pub const ECHOPRT: crate::tcflag_t = 0x00000400; +pub const ECHOCTL: crate::tcflag_t = 0x00000200; +pub const ISIG: crate::tcflag_t = 0x00000001; +pub const ICANON: crate::tcflag_t = 0x00000002; +pub const PENDIN: crate::tcflag_t = 0x00004000; +pub const NOFLSH: crate::tcflag_t = 0x00000080; +pub const CIBAUD: crate::tcflag_t = 0o02003600000; +pub const CBAUDEX: crate::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: crate::tcflag_t = 0o000002; +pub const NLDLY: crate::tcflag_t = 0o000400; +pub const CRDLY: crate::tcflag_t = 0o003000; +pub const TABDLY: crate::tcflag_t = 0o014000; +pub const BSDLY: crate::tcflag_t = 0o020000; +pub const FFDLY: crate::tcflag_t = 0o100000; +pub const VTDLY: crate::tcflag_t = 0o040000; +pub const XTABS: crate::tcflag_t = 0o014000; +pub const B57600: crate::speed_t = 0o010001; +pub const B115200: crate::speed_t = 0o010002; +pub const B230400: crate::speed_t = 0o010003; +pub const B460800: crate::speed_t = 0o010004; +pub const B500000: crate::speed_t = 0o010005; +pub const B576000: crate::speed_t = 0o010006; +pub const B921600: crate::speed_t = 0o010007; +pub const B1000000: crate::speed_t = 0o010010; +pub const B1152000: crate::speed_t = 0o010011; +pub const B1500000: crate::speed_t = 0o010012; +pub const B2000000: crate::speed_t = 0o010013; +pub const B2500000: crate::speed_t = 0o010014; +pub const B3000000: crate::speed_t = 0o010015; +pub const B3500000: crate::speed_t = 0o010016; +pub const B4000000: crate::speed_t = 0o010017; + +pub const EDEADLK: c_int = 35; +pub const EDEADLOCK: c_int = EDEADLK; + +pub const EXTPROC: crate::tcflag_t = 0x00010000; +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: crate::tcflag_t = 0x00008000; +pub const TOSTOP: crate::tcflag_t = 0x00000100; +pub const FLUSHO: crate::tcflag_t = 0x00001000; diff --git a/http/vendor/libc/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs new file mode 100644 index 0000000..8e890be --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs @@ -0,0 +1,643 @@ +//! LoongArch-specific definitions for 64-bit linux-like values + +use crate::off_t; +use crate::prelude::*; + +pub type wchar_t = c_int; + +pub type nlink_t = c_uint; +pub type blksize_t = c_int; +pub type __u64 = c_ulonglong; +pub type __s64 = c_longlong; + +pub type stat64 = stat; + +s! { + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + __pad1: Padding, + pub st_size: off_t, + pub st_blksize: crate::blksize_t, + __pad2: Padding, + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + __unused: Padding<[c_int; 2usize]>, + } + + pub struct ipc_perm { + pub __key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: c_uint, + pub __seq: c_int, + __unused1: Padding, + __unused2: Padding, + } + + pub struct user_regs_struct { + pub regs: [u64; 32], + pub orig_a0: u64, + pub csr_era: u64, + pub csr_badv: u64, + pub reserved: [u64; 10], + } + + pub struct user_fp_struct { + pub fpr: [u64; 32], + pub fcc: u64, + pub fcsr: u32, + } + + pub struct ucontext_t { + pub uc_flags: c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: crate::stack_t, + pub uc_sigmask: crate::sigset_t, + pub uc_mcontext: mcontext_t, + } + + #[repr(align(16))] + pub struct mcontext_t { + pub __pc: c_ulong, + pub __gregs: [c_ulong; 32], + pub __flags: c_uint, + pub __extcontext: [c_ulong; 0], + } + + #[repr(align(8))] + pub struct clone_args { + pub flags: c_ulonglong, + pub pidfd: c_ulonglong, + pub child_tid: c_ulonglong, + pub parent_tid: c_ulonglong, + pub exit_signal: c_ulonglong, + pub stack: c_ulonglong, + pub stack_size: c_ulonglong, + pub tls: c_ulonglong, + pub set_tid: c_ulonglong, + pub set_tid_size: c_ulonglong, + pub cgroup: c_ulonglong, + } +} + +s_no_extra_traits! { + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 4], + } +} + +pub const SYS_io_setup: c_long = 0; +pub const SYS_io_destroy: c_long = 1; +pub const SYS_io_submit: c_long = 2; +pub const SYS_io_cancel: c_long = 3; +pub const SYS_io_getevents: c_long = 4; +pub const SYS_setxattr: c_long = 5; +pub const SYS_lsetxattr: c_long = 6; +pub const SYS_fsetxattr: c_long = 7; +pub const SYS_getxattr: c_long = 8; +pub const SYS_lgetxattr: c_long = 9; +pub const SYS_fgetxattr: c_long = 10; +pub const SYS_listxattr: c_long = 11; +pub const SYS_llistxattr: c_long = 12; +pub const SYS_flistxattr: c_long = 13; +pub const SYS_removexattr: c_long = 14; +pub const SYS_lremovexattr: c_long = 15; +pub const SYS_fremovexattr: c_long = 16; +pub const SYS_getcwd: c_long = 17; +pub const SYS_lookup_dcookie: c_long = 18; +pub const SYS_eventfd2: c_long = 19; +pub const SYS_epoll_create1: c_long = 20; +pub const SYS_epoll_ctl: c_long = 21; +pub const SYS_epoll_pwait: c_long = 22; +pub const SYS_dup: c_long = 23; +pub const SYS_dup3: c_long = 24; +pub const SYS_fcntl: c_long = 25; +pub const SYS_inotify_init1: c_long = 26; +pub const SYS_inotify_add_watch: c_long = 27; +pub const SYS_inotify_rm_watch: c_long = 28; +pub const SYS_ioctl: c_long = 29; +pub const SYS_ioprio_set: c_long = 30; +pub const SYS_ioprio_get: c_long = 31; +pub const SYS_flock: c_long = 32; +pub const SYS_mknodat: c_long = 33; +pub const SYS_mkdirat: c_long = 34; +pub const SYS_unlinkat: c_long = 35; +pub const SYS_symlinkat: c_long = 36; +pub const SYS_linkat: c_long = 37; +pub const SYS_umount2: c_long = 39; +pub const SYS_mount: c_long = 40; +pub const SYS_pivot_root: c_long = 41; +pub const SYS_nfsservctl: c_long = 42; +pub const SYS_statfs: c_long = 43; +pub const SYS_fstatfs: c_long = 44; +pub const SYS_truncate: c_long = 45; +pub const SYS_ftruncate: c_long = 46; +pub const SYS_fallocate: c_long = 47; +pub const SYS_faccessat: c_long = 48; +pub const SYS_chdir: c_long = 49; +pub const SYS_fchdir: c_long = 50; +pub const SYS_chroot: c_long = 51; +pub const SYS_fchmod: c_long = 52; +pub const SYS_fchmodat: c_long = 53; +pub const SYS_fchownat: c_long = 54; +pub const SYS_fchown: c_long = 55; +pub const SYS_openat: c_long = 56; +pub const SYS_close: c_long = 57; +pub const SYS_vhangup: c_long = 58; +pub const SYS_pipe2: c_long = 59; +pub const SYS_quotactl: c_long = 60; +pub const SYS_getdents64: c_long = 61; +pub const SYS_lseek: c_long = 62; +pub const SYS_read: c_long = 63; +pub const SYS_write: c_long = 64; +pub const SYS_readv: c_long = 65; +pub const SYS_writev: c_long = 66; +pub const SYS_pread64: c_long = 67; +pub const SYS_pwrite64: c_long = 68; +pub const SYS_preadv: c_long = 69; +pub const SYS_pwritev: c_long = 70; +pub const SYS_sendfile: c_long = 71; +pub const SYS_pselect6: c_long = 72; +pub const SYS_ppoll: c_long = 73; +pub const SYS_signalfd4: c_long = 74; +pub const SYS_vmsplice: c_long = 75; +pub const SYS_splice: c_long = 76; +pub const SYS_tee: c_long = 77; +pub const SYS_readlinkat: c_long = 78; +pub const SYS_sync: c_long = 81; +pub const SYS_fsync: c_long = 82; +pub const SYS_fdatasync: c_long = 83; +pub const SYS_sync_file_range: c_long = 84; +pub const SYS_timerfd_create: c_long = 85; +pub const SYS_timerfd_settime: c_long = 86; +pub const SYS_timerfd_gettime: c_long = 87; +pub const SYS_utimensat: c_long = 88; +pub const SYS_acct: c_long = 89; +pub const SYS_capget: c_long = 90; +pub const SYS_capset: c_long = 91; +pub const SYS_personality: c_long = 92; +pub const SYS_exit: c_long = 93; +pub const SYS_exit_group: c_long = 94; +pub const SYS_waitid: c_long = 95; +pub const SYS_set_tid_address: c_long = 96; +pub const SYS_unshare: c_long = 97; +pub const SYS_futex: c_long = 98; +pub const SYS_set_robust_list: c_long = 99; +pub const SYS_get_robust_list: c_long = 100; +pub const SYS_nanosleep: c_long = 101; +pub const SYS_getitimer: c_long = 102; +pub const SYS_setitimer: c_long = 103; +pub const SYS_kexec_load: c_long = 104; +pub const SYS_init_module: c_long = 105; +pub const SYS_delete_module: c_long = 106; +pub const SYS_timer_create: c_long = 107; +pub const SYS_timer_gettime: c_long = 108; +pub const SYS_timer_getoverrun: c_long = 109; +pub const SYS_timer_settime: c_long = 110; +pub const SYS_timer_delete: c_long = 111; +pub const SYS_clock_settime: c_long = 112; +pub const SYS_clock_gettime: c_long = 113; +pub const SYS_clock_getres: c_long = 114; +pub const SYS_clock_nanosleep: c_long = 115; +pub const SYS_syslog: c_long = 116; +pub const SYS_ptrace: c_long = 117; +pub const SYS_sched_setparam: c_long = 118; +pub const SYS_sched_setscheduler: c_long = 119; +pub const SYS_sched_getscheduler: c_long = 120; +pub const SYS_sched_getparam: c_long = 121; +pub const SYS_sched_setaffinity: c_long = 122; +pub const SYS_sched_getaffinity: c_long = 123; +pub const SYS_sched_yield: c_long = 124; +pub const SYS_sched_get_priority_max: c_long = 125; +pub const SYS_sched_get_priority_min: c_long = 126; +pub const SYS_sched_rr_get_interval: c_long = 127; +pub const SYS_restart_syscall: c_long = 128; +pub const SYS_kill: c_long = 129; +pub const SYS_tkill: c_long = 130; +pub const SYS_tgkill: c_long = 131; +pub const SYS_sigaltstack: c_long = 132; +pub const SYS_rt_sigsuspend: c_long = 133; +pub const SYS_rt_sigaction: c_long = 134; +pub const SYS_rt_sigprocmask: c_long = 135; +pub const SYS_rt_sigpending: c_long = 136; +pub const SYS_rt_sigtimedwait: c_long = 137; +pub const SYS_rt_sigqueueinfo: c_long = 138; +pub const SYS_rt_sigreturn: c_long = 139; +pub const SYS_setpriority: c_long = 140; +pub const SYS_getpriority: c_long = 141; +pub const SYS_reboot: c_long = 142; +pub const SYS_setregid: c_long = 143; +pub const SYS_setgid: c_long = 144; +pub const SYS_setreuid: c_long = 145; +pub const SYS_setuid: c_long = 146; +pub const SYS_setresuid: c_long = 147; +pub const SYS_getresuid: c_long = 148; +pub const SYS_setresgid: c_long = 149; +pub const SYS_getresgid: c_long = 150; +pub const SYS_setfsuid: c_long = 151; +pub const SYS_setfsgid: c_long = 152; +pub const SYS_times: c_long = 153; +pub const SYS_setpgid: c_long = 154; +pub const SYS_getpgid: c_long = 155; +pub const SYS_getsid: c_long = 156; +pub const SYS_setsid: c_long = 157; +pub const SYS_getgroups: c_long = 158; +pub const SYS_setgroups: c_long = 159; +pub const SYS_uname: c_long = 160; +pub const SYS_sethostname: c_long = 161; +pub const SYS_setdomainname: c_long = 162; +pub const SYS_getrusage: c_long = 165; +pub const SYS_umask: c_long = 166; +pub const SYS_prctl: c_long = 167; +pub const SYS_getcpu: c_long = 168; +pub const SYS_gettimeofday: c_long = 169; +pub const SYS_settimeofday: c_long = 170; +pub const SYS_adjtimex: c_long = 171; +pub const SYS_getpid: c_long = 172; +pub const SYS_getppid: c_long = 173; +pub const SYS_getuid: c_long = 174; +pub const SYS_geteuid: c_long = 175; +pub const SYS_getgid: c_long = 176; +pub const SYS_getegid: c_long = 177; +pub const SYS_gettid: c_long = 178; +pub const SYS_sysinfo: c_long = 179; +pub const SYS_mq_open: c_long = 180; +pub const SYS_mq_unlink: c_long = 181; +pub const SYS_mq_timedsend: c_long = 182; +pub const SYS_mq_timedreceive: c_long = 183; +pub const SYS_mq_notify: c_long = 184; +pub const SYS_mq_getsetattr: c_long = 185; +pub const SYS_msgget: c_long = 186; +pub const SYS_msgctl: c_long = 187; +pub const SYS_msgrcv: c_long = 188; +pub const SYS_msgsnd: c_long = 189; +pub const SYS_semget: c_long = 190; +pub const SYS_semctl: c_long = 191; +pub const SYS_semtimedop: c_long = 192; +pub const SYS_semop: c_long = 193; +pub const SYS_shmget: c_long = 194; +pub const SYS_shmctl: c_long = 195; +pub const SYS_shmat: c_long = 196; +pub const SYS_shmdt: c_long = 197; +pub const SYS_socket: c_long = 198; +pub const SYS_socketpair: c_long = 199; +pub const SYS_bind: c_long = 200; +pub const SYS_listen: c_long = 201; +pub const SYS_accept: c_long = 202; +pub const SYS_connect: c_long = 203; +pub const SYS_getsockname: c_long = 204; +pub const SYS_getpeername: c_long = 205; +pub const SYS_sendto: c_long = 206; +pub const SYS_recvfrom: c_long = 207; +pub const SYS_setsockopt: c_long = 208; +pub const SYS_getsockopt: c_long = 209; +pub const SYS_shutdown: c_long = 210; +pub const SYS_sendmsg: c_long = 211; +pub const SYS_recvmsg: c_long = 212; +pub const SYS_readahead: c_long = 213; +pub const SYS_brk: c_long = 214; +pub const SYS_munmap: c_long = 215; +pub const SYS_mremap: c_long = 216; +pub const SYS_add_key: c_long = 217; +pub const SYS_request_key: c_long = 218; +pub const SYS_keyctl: c_long = 219; +pub const SYS_clone: c_long = 220; +pub const SYS_execve: c_long = 221; +pub const SYS_mmap: c_long = 222; +pub const SYS_fadvise64: c_long = 223; +pub const SYS_swapon: c_long = 224; +pub const SYS_swapoff: c_long = 225; +pub const SYS_mprotect: c_long = 226; +pub const SYS_msync: c_long = 227; +pub const SYS_mlock: c_long = 228; +pub const SYS_munlock: c_long = 229; +pub const SYS_mlockall: c_long = 230; +pub const SYS_munlockall: c_long = 231; +pub const SYS_mincore: c_long = 232; +pub const SYS_madvise: c_long = 233; +pub const SYS_remap_file_pages: c_long = 234; +pub const SYS_mbind: c_long = 235; +pub const SYS_get_mempolicy: c_long = 236; +pub const SYS_set_mempolicy: c_long = 237; +pub const SYS_migrate_pages: c_long = 238; +pub const SYS_move_pages: c_long = 239; +pub const SYS_rt_tgsigqueueinfo: c_long = 240; +pub const SYS_perf_event_open: c_long = 241; +pub const SYS_accept4: c_long = 242; +pub const SYS_recvmmsg: c_long = 243; +pub const SYS_arch_specific_syscall: c_long = 244; +pub const SYS_wait4: c_long = 260; +pub const SYS_prlimit64: c_long = 261; +pub const SYS_fanotify_init: c_long = 262; +pub const SYS_fanotify_mark: c_long = 263; +pub const SYS_name_to_handle_at: c_long = 264; +pub const SYS_open_by_handle_at: c_long = 265; +pub const SYS_clock_adjtime: c_long = 266; +pub const SYS_syncfs: c_long = 267; +pub const SYS_setns: c_long = 268; +pub const SYS_sendmmsg: c_long = 269; +pub const SYS_process_vm_readv: c_long = 270; +pub const SYS_process_vm_writev: c_long = 271; +pub const SYS_kcmp: c_long = 272; +pub const SYS_finit_module: c_long = 273; +pub const SYS_sched_setattr: c_long = 274; +pub const SYS_sched_getattr: c_long = 275; +pub const SYS_renameat2: c_long = 276; +pub const SYS_seccomp: c_long = 277; +pub const SYS_getrandom: c_long = 278; +pub const SYS_memfd_create: c_long = 279; +pub const SYS_bpf: c_long = 280; +pub const SYS_execveat: c_long = 281; +pub const SYS_userfaultfd: c_long = 282; +pub const SYS_membarrier: c_long = 283; +pub const SYS_mlock2: c_long = 284; +pub const SYS_copy_file_range: c_long = 285; +pub const SYS_preadv2: c_long = 286; +pub const SYS_pwritev2: c_long = 287; +pub const SYS_pkey_mprotect: c_long = 288; +pub const SYS_pkey_alloc: c_long = 289; +pub const SYS_pkey_free: c_long = 290; +pub const SYS_statx: c_long = 291; +pub const SYS_io_pgetevents: c_long = 292; +pub const SYS_rseq: c_long = 293; +pub const SYS_kexec_file_load: c_long = 294; +pub const SYS_pidfd_send_signal: c_long = 424; +pub const SYS_io_uring_setup: c_long = 425; +pub const SYS_io_uring_enter: c_long = 426; +pub const SYS_io_uring_register: c_long = 427; +pub const SYS_open_tree: c_long = 428; +pub const SYS_move_mount: c_long = 429; +pub const SYS_fsopen: c_long = 430; +pub const SYS_fsconfig: c_long = 431; +pub const SYS_fsmount: c_long = 432; +pub const SYS_fspick: c_long = 433; +pub const SYS_pidfd_open: c_long = 434; +pub const SYS_clone3: c_long = 435; +pub const SYS_close_range: c_long = 436; +pub const SYS_openat2: c_long = 437; +pub const SYS_pidfd_getfd: c_long = 438; +pub const SYS_faccessat2: c_long = 439; +pub const SYS_process_madvise: c_long = 440; +pub const SYS_epoll_pwait2: c_long = 441; +pub const SYS_mount_setattr: c_long = 442; +pub const SYS_quotactl_fd: c_long = 443; +pub const SYS_landlock_create_ruleset: c_long = 444; +pub const SYS_landlock_add_rule: c_long = 445; +pub const SYS_landlock_restrict_self: c_long = 446; +pub const SYS_process_mrelease: c_long = 448; +pub const SYS_futex_waitv: c_long = 449; +pub const SYS_set_mempolicy_home_node: c_long = 450; +pub const SYS_cachestat: c_long = 451; +pub const SYS_fchmodat2: c_long = 452; +pub const SYS_map_shadow_stack: c_long = 453; +pub const SYS_futex_wake: c_long = 454; +pub const SYS_futex_wait: c_long = 455; +pub const SYS_futex_requeue: c_long = 456; + +pub const O_APPEND: c_int = 1024; +pub const O_DIRECT: c_int = 0x4000; +pub const O_DIRECTORY: c_int = 0x10000; +pub const O_LARGEFILE: c_int = 0o0100000; +pub const O_NOFOLLOW: c_int = 0x20000; +pub const O_CREAT: c_int = 64; +pub const O_EXCL: c_int = 128; +pub const O_NOCTTY: c_int = 256; +pub const O_NONBLOCK: c_int = 2048; +pub const O_SYNC: c_int = 1052672; +pub const O_RSYNC: c_int = 1052672; +pub const O_DSYNC: c_int = 4096; +pub const O_ASYNC: c_int = 0o20000; + +pub const SIGSTKSZ: size_t = 16384; +pub const MINSIGSTKSZ: size_t = 4096; + +pub const ENAMETOOLONG: c_int = 36; +pub const ENOLCK: c_int = 37; +pub const ENOSYS: c_int = 38; +pub const ENOTEMPTY: c_int = 39; +pub const ELOOP: c_int = 40; +pub const ENOMSG: c_int = 42; +pub const EIDRM: c_int = 43; +pub const ECHRNG: c_int = 44; +pub const EL2NSYNC: c_int = 45; +pub const EL3HLT: c_int = 46; +pub const EL3RST: c_int = 47; +pub const ELNRNG: c_int = 48; +pub const EUNATCH: c_int = 49; +pub const ENOCSI: c_int = 50; +pub const EL2HLT: c_int = 51; +pub const EBADE: c_int = 52; +pub const EBADR: c_int = 53; +pub const EXFULL: c_int = 54; +pub const ENOANO: c_int = 55; +pub const EBADRQC: c_int = 56; +pub const EBADSLT: c_int = 57; +pub const EMULTIHOP: c_int = 72; +pub const EOVERFLOW: c_int = 75; +pub const ENOTUNIQ: c_int = 76; +pub const EBADFD: c_int = 77; +pub const EBADMSG: c_int = 74; +pub const EREMCHG: c_int = 78; +pub const ELIBACC: c_int = 79; +pub const ELIBBAD: c_int = 80; +pub const ELIBSCN: c_int = 81; +pub const ELIBMAX: c_int = 82; +pub const ELIBEXEC: c_int = 83; +pub const EILSEQ: c_int = 84; +pub const ERESTART: c_int = 85; +pub const ESTRPIPE: c_int = 86; +pub const EUSERS: c_int = 87; +pub const ENOTSOCK: c_int = 88; +pub const EDESTADDRREQ: c_int = 89; +pub const EMSGSIZE: c_int = 90; +pub const EPROTOTYPE: c_int = 91; +pub const ENOPROTOOPT: c_int = 92; +pub const EPROTONOSUPPORT: c_int = 93; +pub const ESOCKTNOSUPPORT: c_int = 94; +pub const EOPNOTSUPP: c_int = 95; +pub const ENOTSUP: c_int = EOPNOTSUPP; +pub const EPFNOSUPPORT: c_int = 96; +pub const EAFNOSUPPORT: c_int = 97; +pub const EADDRINUSE: c_int = 98; +pub const EADDRNOTAVAIL: c_int = 99; +pub const ENETDOWN: c_int = 100; +pub const ENETUNREACH: c_int = 101; +pub const ENETRESET: c_int = 102; +pub const ECONNABORTED: c_int = 103; +pub const ECONNRESET: c_int = 104; +pub const ENOBUFS: c_int = 105; +pub const EISCONN: c_int = 106; +pub const ENOTCONN: c_int = 107; +pub const ESHUTDOWN: c_int = 108; +pub const ETOOMANYREFS: c_int = 109; +pub const ETIMEDOUT: c_int = 110; +pub const ECONNREFUSED: c_int = 111; +pub const EHOSTDOWN: c_int = 112; +pub const EHOSTUNREACH: c_int = 113; +pub const EALREADY: c_int = 114; +pub const EINPROGRESS: c_int = 115; +pub const ESTALE: c_int = 116; +pub const EUCLEAN: c_int = 117; +pub const ENOTNAM: c_int = 118; +pub const ENAVAIL: c_int = 119; +pub const EISNAM: c_int = 120; +pub const EREMOTEIO: c_int = 121; +pub const EDQUOT: c_int = 122; +pub const ENOMEDIUM: c_int = 123; +pub const EMEDIUMTYPE: c_int = 124; +pub const ECANCELED: c_int = 125; +pub const ENOKEY: c_int = 126; +pub const EKEYEXPIRED: c_int = 127; +pub const EKEYREVOKED: c_int = 128; +pub const EKEYREJECTED: c_int = 129; +pub const EOWNERDEAD: c_int = 130; +pub const ENOTRECOVERABLE: c_int = 131; +pub const EHWPOISON: c_int = 133; +pub const ERFKILL: c_int = 132; + +pub const MADV_SOFT_OFFLINE: c_int = 101; + +pub const SA_ONSTACK: c_int = 0x08000000; +pub const SA_SIGINFO: c_int = 0x00000004; +pub const SA_NOCLDWAIT: c_int = 0x00000002; + +pub const SIGCHLD: c_int = 17; +pub const SIGBUS: c_int = 7; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGUSR1: c_int = 10; +pub const SIGUSR2: c_int = 12; +pub const SIGCONT: c_int = 18; +pub const SIGSTOP: c_int = 19; +pub const SIGTSTP: c_int = 20; +pub const SIGURG: c_int = 23; +pub const SIGIO: c_int = 29; +pub const SIGSYS: c_int = 31; +pub const SIGSTKFLT: c_int = 16; +pub const SIGPOLL: c_int = 29; +pub const SIGPWR: c_int = 30; +pub const SIG_SETMASK: c_int = 2; +pub const SIG_BLOCK: c_int = 0; +pub const SIG_UNBLOCK: c_int = 1; + +pub const F_GETLK: c_int = 5; +pub const F_GETOWN: c_int = 9; +pub const F_SETLK: c_int = 6; +pub const F_SETLKW: c_int = 7; +pub const F_SETOWN: c_int = 8; + +pub const VEOF: usize = 4; + +pub const POLLWRNORM: c_short = 0x100; +pub const POLLWRBAND: c_short = 0x200; + +pub const MAP_ANON: c_int = 0x0020; +pub const MAP_GROWSDOWN: c_int = 0x0100; +pub const MAP_DENYWRITE: c_int = 0x0800; +pub const MAP_EXECUTABLE: c_int = 0x01000; +pub const MAP_LOCKED: c_int = 0x02000; +pub const MAP_NORESERVE: c_int = 0x04000; +pub const MAP_POPULATE: c_int = 0x08000; +pub const MAP_NONBLOCK: c_int = 0x010000; +pub const MAP_STACK: c_int = 0x020000; +pub const MAP_HUGETLB: c_int = 0x040000; +pub const MAP_SYNC: c_int = 0x080000; + +pub const MCL_CURRENT: c_int = 0x0001; +pub const MCL_FUTURE: c_int = 0x0002; +pub const MCL_ONFAULT: c_int = 0x0004; +pub const CBAUD: crate::tcflag_t = 0o0010017; +pub const TAB1: c_int = 0x00000800; +pub const TAB2: c_int = 0x00001000; +pub const TAB3: c_int = 0x00001800; +pub const CR1: c_int = 0x00000200; +pub const CR2: c_int = 0x00000400; +pub const CR3: c_int = 0x00000600; +pub const FF1: c_int = 0x00008000; +pub const BS1: c_int = 0x00002000; +pub const VT1: c_int = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: crate::tcflag_t = 0x00000400; +pub const IXOFF: crate::tcflag_t = 0x00001000; +pub const ONLCR: crate::tcflag_t = 0x4; +pub const CSIZE: crate::tcflag_t = 0x00000030; +pub const CS6: crate::tcflag_t = 0x00000010; +pub const CS7: crate::tcflag_t = 0x00000020; +pub const CS8: crate::tcflag_t = 0x00000030; +pub const CSTOPB: crate::tcflag_t = 0x00000040; +pub const CREAD: crate::tcflag_t = 0x00000080; +pub const PARENB: crate::tcflag_t = 0x00000100; +pub const PARODD: crate::tcflag_t = 0x00000200; +pub const HUPCL: crate::tcflag_t = 0x00000400; +pub const CLOCAL: crate::tcflag_t = 0x00000800; +pub const ECHOKE: crate::tcflag_t = 0x00000800; +pub const ECHOE: crate::tcflag_t = 0x00000010; +pub const ECHOK: crate::tcflag_t = 0x00000020; +pub const ECHONL: crate::tcflag_t = 0x00000040; +pub const ECHOPRT: crate::tcflag_t = 0x00000400; +pub const ECHOCTL: crate::tcflag_t = 0x00000200; +pub const ISIG: crate::tcflag_t = 0x00000001; +pub const ICANON: crate::tcflag_t = 0x00000002; +pub const PENDIN: crate::tcflag_t = 0x00004000; +pub const NOFLSH: crate::tcflag_t = 0x00000080; +pub const CIBAUD: crate::tcflag_t = 0o02003600000; +pub const CBAUDEX: crate::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: crate::tcflag_t = 0o000002; +pub const NLDLY: crate::tcflag_t = 0o000400; +pub const CRDLY: crate::tcflag_t = 0o003000; +pub const TABDLY: crate::tcflag_t = 0o014000; +pub const BSDLY: crate::tcflag_t = 0o020000; +pub const FFDLY: crate::tcflag_t = 0o100000; +pub const VTDLY: crate::tcflag_t = 0o040000; +pub const XTABS: crate::tcflag_t = 0o014000; +pub const B57600: crate::speed_t = 0o010001; +pub const B115200: crate::speed_t = 0o010002; +pub const B230400: crate::speed_t = 0o010003; +pub const B460800: crate::speed_t = 0o010004; +pub const B500000: crate::speed_t = 0o010005; +pub const B576000: crate::speed_t = 0o010006; +pub const B921600: crate::speed_t = 0o010007; +pub const B1000000: crate::speed_t = 0o010010; +pub const B1152000: crate::speed_t = 0o010011; +pub const B1500000: crate::speed_t = 0o010012; +pub const B2000000: crate::speed_t = 0o010013; +pub const B2500000: crate::speed_t = 0o010014; +pub const B3000000: crate::speed_t = 0o010015; +pub const B3500000: crate::speed_t = 0o010016; +pub const B4000000: crate::speed_t = 0o010017; + +pub const EDEADLK: c_int = 35; +pub const EDEADLOCK: c_int = EDEADLK; +pub const EXTPROC: crate::tcflag_t = 0x00010000; +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: crate::tcflag_t = 0x00008000; +pub const TOSTOP: crate::tcflag_t = 0x00000100; +pub const FLUSHO: crate::tcflag_t = 0x00001000; diff --git a/http/vendor/libc/src/unix/linux_like/linux/musl/b64/mips64.rs b/http/vendor/libc/src/unix/linux_like/linux/musl/b64/mips64.rs new file mode 100644 index 0000000..1fb8618 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/musl/b64/mips64.rs @@ -0,0 +1,683 @@ +use crate::off_t; +use crate::prelude::*; + +pub type wchar_t = i32; +pub type __u64 = c_ulong; +pub type __s64 = c_long; +pub type nlink_t = c_uint; +pub type blksize_t = i64; + +pub type stat64 = stat; + +s! { + pub struct stat { + pub st_dev: crate::dev_t, + __pad1: Padding<[c_int; 3]>, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + __pad2: Padding<[c_uint; 2]>, + pub st_size: off_t, + __pad3: Padding, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + pub st_blksize: crate::blksize_t, + __pad4: Padding, + pub st_blocks: crate::blkcnt_t, + __pad5: Padding<[c_int; 14]>, + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_size: size_t, + pub ss_flags: c_int, + } + + pub struct ipc_perm { + #[cfg(musl_v1_2_3)] + pub __key: crate::key_t, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "This field is incorrectly named and will be changed + to __key in a future release." + )] + pub __ipc_perm_key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: crate::mode_t, + pub __seq: c_int, + __pad1: Padding, + __unused1: Padding, + __unused2: Padding, + } + + pub struct statfs { + pub f_type: c_ulong, + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_fsid: crate::fsid_t, + pub f_namelen: c_ulong, + pub f_flags: c_ulong, + pub f_spare: [c_ulong; 5], + } + + pub struct statfs64 { + pub f_type: c_ulong, + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt64_t, + pub f_bfree: crate::fsblkcnt64_t, + pub f_files: crate::fsfilcnt64_t, + pub f_ffree: crate::fsfilcnt64_t, + pub f_bavail: crate::fsblkcnt64_t, + pub f_fsid: crate::fsid_t, + pub f_namelen: c_ulong, + pub f_flags: c_ulong, + pub f_spare: [c_ulong; 5], + } +} + +pub const SIGSTKSZ: size_t = 8192; +pub const MINSIGSTKSZ: size_t = 2048; + +pub const SYS_read: c_long = 5000 + 0; +pub const SYS_write: c_long = 5000 + 1; +pub const SYS_open: c_long = 5000 + 2; +pub const SYS_close: c_long = 5000 + 3; +pub const SYS_stat: c_long = 5000 + 4; +pub const SYS_fstat: c_long = 5000 + 5; +pub const SYS_lstat: c_long = 5000 + 6; +pub const SYS_poll: c_long = 5000 + 7; +pub const SYS_lseek: c_long = 5000 + 8; +pub const SYS_mmap: c_long = 5000 + 9; +pub const SYS_mprotect: c_long = 5000 + 10; +pub const SYS_munmap: c_long = 5000 + 11; +pub const SYS_brk: c_long = 5000 + 12; +pub const SYS_rt_sigaction: c_long = 5000 + 13; +pub const SYS_rt_sigprocmask: c_long = 5000 + 14; +pub const SYS_ioctl: c_long = 5000 + 15; +pub const SYS_pread64: c_long = 5000 + 16; +pub const SYS_pwrite64: c_long = 5000 + 17; +pub const SYS_readv: c_long = 5000 + 18; +pub const SYS_writev: c_long = 5000 + 19; +pub const SYS_access: c_long = 5000 + 20; +pub const SYS_pipe: c_long = 5000 + 21; +pub const SYS__newselect: c_long = 5000 + 22; +pub const SYS_sched_yield: c_long = 5000 + 23; +pub const SYS_mremap: c_long = 5000 + 24; +pub const SYS_msync: c_long = 5000 + 25; +pub const SYS_mincore: c_long = 5000 + 26; +pub const SYS_madvise: c_long = 5000 + 27; +pub const SYS_shmget: c_long = 5000 + 28; +pub const SYS_shmat: c_long = 5000 + 29; +pub const SYS_shmctl: c_long = 5000 + 30; +pub const SYS_dup: c_long = 5000 + 31; +pub const SYS_dup2: c_long = 5000 + 32; +pub const SYS_pause: c_long = 5000 + 33; +pub const SYS_nanosleep: c_long = 5000 + 34; +pub const SYS_getitimer: c_long = 5000 + 35; +pub const SYS_setitimer: c_long = 5000 + 36; +pub const SYS_alarm: c_long = 5000 + 37; +pub const SYS_getpid: c_long = 5000 + 38; +pub const SYS_sendfile: c_long = 5000 + 39; +pub const SYS_socket: c_long = 5000 + 40; +pub const SYS_connect: c_long = 5000 + 41; +pub const SYS_accept: c_long = 5000 + 42; +pub const SYS_sendto: c_long = 5000 + 43; +pub const SYS_recvfrom: c_long = 5000 + 44; +pub const SYS_sendmsg: c_long = 5000 + 45; +pub const SYS_recvmsg: c_long = 5000 + 46; +pub const SYS_shutdown: c_long = 5000 + 47; +pub const SYS_bind: c_long = 5000 + 48; +pub const SYS_listen: c_long = 5000 + 49; +pub const SYS_getsockname: c_long = 5000 + 50; +pub const SYS_getpeername: c_long = 5000 + 51; +pub const SYS_socketpair: c_long = 5000 + 52; +pub const SYS_setsockopt: c_long = 5000 + 53; +pub const SYS_getsockopt: c_long = 5000 + 54; +pub const SYS_clone: c_long = 5000 + 55; +pub const SYS_fork: c_long = 5000 + 56; +pub const SYS_execve: c_long = 5000 + 57; +pub const SYS_exit: c_long = 5000 + 58; +pub const SYS_wait4: c_long = 5000 + 59; +pub const SYS_kill: c_long = 5000 + 60; +pub const SYS_uname: c_long = 5000 + 61; +pub const SYS_semget: c_long = 5000 + 62; +pub const SYS_semop: c_long = 5000 + 63; +pub const SYS_semctl: c_long = 5000 + 64; +pub const SYS_shmdt: c_long = 5000 + 65; +pub const SYS_msgget: c_long = 5000 + 66; +pub const SYS_msgsnd: c_long = 5000 + 67; +pub const SYS_msgrcv: c_long = 5000 + 68; +pub const SYS_msgctl: c_long = 5000 + 69; +pub const SYS_fcntl: c_long = 5000 + 70; +pub const SYS_flock: c_long = 5000 + 71; +pub const SYS_fsync: c_long = 5000 + 72; +pub const SYS_fdatasync: c_long = 5000 + 73; +pub const SYS_truncate: c_long = 5000 + 74; +pub const SYS_ftruncate: c_long = 5000 + 75; +pub const SYS_getdents: c_long = 5000 + 76; +pub const SYS_getcwd: c_long = 5000 + 77; +pub const SYS_chdir: c_long = 5000 + 78; +pub const SYS_fchdir: c_long = 5000 + 79; +pub const SYS_rename: c_long = 5000 + 80; +pub const SYS_mkdir: c_long = 5000 + 81; +pub const SYS_rmdir: c_long = 5000 + 82; +pub const SYS_creat: c_long = 5000 + 83; +pub const SYS_link: c_long = 5000 + 84; +pub const SYS_unlink: c_long = 5000 + 85; +pub const SYS_symlink: c_long = 5000 + 86; +pub const SYS_readlink: c_long = 5000 + 87; +pub const SYS_chmod: c_long = 5000 + 88; +pub const SYS_fchmod: c_long = 5000 + 89; +pub const SYS_chown: c_long = 5000 + 90; +pub const SYS_fchown: c_long = 5000 + 91; +pub const SYS_lchown: c_long = 5000 + 92; +pub const SYS_umask: c_long = 5000 + 93; +pub const SYS_gettimeofday: c_long = 5000 + 94; +pub const SYS_getrlimit: c_long = 5000 + 95; +pub const SYS_getrusage: c_long = 5000 + 96; +pub const SYS_sysinfo: c_long = 5000 + 97; +pub const SYS_times: c_long = 5000 + 98; +pub const SYS_ptrace: c_long = 5000 + 99; +pub const SYS_getuid: c_long = 5000 + 100; +pub const SYS_syslog: c_long = 5000 + 101; +pub const SYS_getgid: c_long = 5000 + 102; +pub const SYS_setuid: c_long = 5000 + 103; +pub const SYS_setgid: c_long = 5000 + 104; +pub const SYS_geteuid: c_long = 5000 + 105; +pub const SYS_getegid: c_long = 5000 + 106; +pub const SYS_setpgid: c_long = 5000 + 107; +pub const SYS_getppid: c_long = 5000 + 108; +pub const SYS_getpgrp: c_long = 5000 + 109; +pub const SYS_setsid: c_long = 5000 + 110; +pub const SYS_setreuid: c_long = 5000 + 111; +pub const SYS_setregid: c_long = 5000 + 112; +pub const SYS_getgroups: c_long = 5000 + 113; +pub const SYS_setgroups: c_long = 5000 + 114; +pub const SYS_setresuid: c_long = 5000 + 115; +pub const SYS_getresuid: c_long = 5000 + 116; +pub const SYS_setresgid: c_long = 5000 + 117; +pub const SYS_getresgid: c_long = 5000 + 118; +pub const SYS_getpgid: c_long = 5000 + 119; +pub const SYS_setfsuid: c_long = 5000 + 120; +pub const SYS_setfsgid: c_long = 5000 + 121; +pub const SYS_getsid: c_long = 5000 + 122; +pub const SYS_capget: c_long = 5000 + 123; +pub const SYS_capset: c_long = 5000 + 124; +pub const SYS_rt_sigpending: c_long = 5000 + 125; +pub const SYS_rt_sigtimedwait: c_long = 5000 + 126; +pub const SYS_rt_sigqueueinfo: c_long = 5000 + 127; +pub const SYS_rt_sigsuspend: c_long = 5000 + 128; +pub const SYS_sigaltstack: c_long = 5000 + 129; +pub const SYS_utime: c_long = 5000 + 130; +pub const SYS_mknod: c_long = 5000 + 131; +pub const SYS_personality: c_long = 5000 + 132; +pub const SYS_ustat: c_long = 5000 + 133; +pub const SYS_statfs: c_long = 5000 + 134; +pub const SYS_fstatfs: c_long = 5000 + 135; +pub const SYS_sysfs: c_long = 5000 + 136; +pub const SYS_getpriority: c_long = 5000 + 137; +pub const SYS_setpriority: c_long = 5000 + 138; +pub const SYS_sched_setparam: c_long = 5000 + 139; +pub const SYS_sched_getparam: c_long = 5000 + 140; +pub const SYS_sched_setscheduler: c_long = 5000 + 141; +pub const SYS_sched_getscheduler: c_long = 5000 + 142; +pub const SYS_sched_get_priority_max: c_long = 5000 + 143; +pub const SYS_sched_get_priority_min: c_long = 5000 + 144; +pub const SYS_sched_rr_get_interval: c_long = 5000 + 145; +pub const SYS_mlock: c_long = 5000 + 146; +pub const SYS_munlock: c_long = 5000 + 147; +pub const SYS_mlockall: c_long = 5000 + 148; +pub const SYS_munlockall: c_long = 5000 + 149; +pub const SYS_vhangup: c_long = 5000 + 150; +pub const SYS_pivot_root: c_long = 5000 + 151; +pub const SYS__sysctl: c_long = 5000 + 152; +pub const SYS_prctl: c_long = 5000 + 153; +pub const SYS_adjtimex: c_long = 5000 + 154; +pub const SYS_setrlimit: c_long = 5000 + 155; +pub const SYS_chroot: c_long = 5000 + 156; +pub const SYS_sync: c_long = 5000 + 157; +pub const SYS_acct: c_long = 5000 + 158; +pub const SYS_settimeofday: c_long = 5000 + 159; +pub const SYS_mount: c_long = 5000 + 160; +pub const SYS_umount2: c_long = 5000 + 161; +pub const SYS_swapon: c_long = 5000 + 162; +pub const SYS_swapoff: c_long = 5000 + 163; +pub const SYS_reboot: c_long = 5000 + 164; +pub const SYS_sethostname: c_long = 5000 + 165; +pub const SYS_setdomainname: c_long = 5000 + 166; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_create_module: c_long = 5000 + 167; +pub const SYS_init_module: c_long = 5000 + 168; +pub const SYS_delete_module: c_long = 5000 + 169; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_get_kernel_syms: c_long = 5000 + 170; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_query_module: c_long = 5000 + 171; +pub const SYS_quotactl: c_long = 5000 + 172; +pub const SYS_nfsservctl: c_long = 5000 + 173; +pub const SYS_getpmsg: c_long = 5000 + 174; +pub const SYS_putpmsg: c_long = 5000 + 175; +pub const SYS_afs_syscall: c_long = 5000 + 176; +pub const SYS_gettid: c_long = 5000 + 178; +pub const SYS_readahead: c_long = 5000 + 179; +pub const SYS_setxattr: c_long = 5000 + 180; +pub const SYS_lsetxattr: c_long = 5000 + 181; +pub const SYS_fsetxattr: c_long = 5000 + 182; +pub const SYS_getxattr: c_long = 5000 + 183; +pub const SYS_lgetxattr: c_long = 5000 + 184; +pub const SYS_fgetxattr: c_long = 5000 + 185; +pub const SYS_listxattr: c_long = 5000 + 186; +pub const SYS_llistxattr: c_long = 5000 + 187; +pub const SYS_flistxattr: c_long = 5000 + 188; +pub const SYS_removexattr: c_long = 5000 + 189; +pub const SYS_lremovexattr: c_long = 5000 + 190; +pub const SYS_fremovexattr: c_long = 5000 + 191; +pub const SYS_tkill: c_long = 5000 + 192; +pub const SYS_futex: c_long = 5000 + 194; +pub const SYS_sched_setaffinity: c_long = 5000 + 195; +pub const SYS_sched_getaffinity: c_long = 5000 + 196; +pub const SYS_cacheflush: c_long = 5000 + 197; +pub const SYS_cachectl: c_long = 5000 + 198; +pub const SYS_sysmips: c_long = 5000 + 199; +pub const SYS_io_setup: c_long = 5000 + 200; +pub const SYS_io_destroy: c_long = 5000 + 201; +pub const SYS_io_getevents: c_long = 5000 + 202; +pub const SYS_io_submit: c_long = 5000 + 203; +pub const SYS_io_cancel: c_long = 5000 + 204; +pub const SYS_exit_group: c_long = 5000 + 205; +pub const SYS_lookup_dcookie: c_long = 5000 + 206; +pub const SYS_epoll_create: c_long = 5000 + 207; +pub const SYS_epoll_ctl: c_long = 5000 + 208; +pub const SYS_epoll_wait: c_long = 5000 + 209; +pub const SYS_remap_file_pages: c_long = 5000 + 210; +pub const SYS_rt_sigreturn: c_long = 5000 + 211; +pub const SYS_set_tid_address: c_long = 5000 + 212; +pub const SYS_restart_syscall: c_long = 5000 + 213; +pub const SYS_semtimedop: c_long = 5000 + 214; +pub const SYS_fadvise64: c_long = 5000 + 215; +pub const SYS_timer_create: c_long = 5000 + 216; +pub const SYS_timer_settime: c_long = 5000 + 217; +pub const SYS_timer_gettime: c_long = 5000 + 218; +pub const SYS_timer_getoverrun: c_long = 5000 + 219; +pub const SYS_timer_delete: c_long = 5000 + 220; +pub const SYS_clock_settime: c_long = 5000 + 221; +pub const SYS_clock_gettime: c_long = 5000 + 222; +pub const SYS_clock_getres: c_long = 5000 + 223; +pub const SYS_clock_nanosleep: c_long = 5000 + 224; +pub const SYS_tgkill: c_long = 5000 + 225; +pub const SYS_utimes: c_long = 5000 + 226; +pub const SYS_mbind: c_long = 5000 + 227; +pub const SYS_get_mempolicy: c_long = 5000 + 228; +pub const SYS_set_mempolicy: c_long = 5000 + 229; +pub const SYS_mq_open: c_long = 5000 + 230; +pub const SYS_mq_unlink: c_long = 5000 + 231; +pub const SYS_mq_timedsend: c_long = 5000 + 232; +pub const SYS_mq_timedreceive: c_long = 5000 + 233; +pub const SYS_mq_notify: c_long = 5000 + 234; +pub const SYS_mq_getsetattr: c_long = 5000 + 235; +pub const SYS_vserver: c_long = 5000 + 236; +pub const SYS_waitid: c_long = 5000 + 237; +/* pub const SYS_sys_setaltroot: c_long = 5000 + 238; */ +pub const SYS_add_key: c_long = 5000 + 239; +pub const SYS_request_key: c_long = 5000 + 240; +pub const SYS_keyctl: c_long = 5000 + 241; +pub const SYS_set_thread_area: c_long = 5000 + 242; +pub const SYS_inotify_init: c_long = 5000 + 243; +pub const SYS_inotify_add_watch: c_long = 5000 + 244; +pub const SYS_inotify_rm_watch: c_long = 5000 + 245; +pub const SYS_migrate_pages: c_long = 5000 + 246; +pub const SYS_openat: c_long = 5000 + 247; +pub const SYS_mkdirat: c_long = 5000 + 248; +pub const SYS_mknodat: c_long = 5000 + 249; +pub const SYS_fchownat: c_long = 5000 + 250; +pub const SYS_futimesat: c_long = 5000 + 251; +pub const SYS_newfstatat: c_long = 5000 + 252; +pub const SYS_unlinkat: c_long = 5000 + 253; +pub const SYS_renameat: c_long = 5000 + 254; +pub const SYS_linkat: c_long = 5000 + 255; +pub const SYS_symlinkat: c_long = 5000 + 256; +pub const SYS_readlinkat: c_long = 5000 + 257; +pub const SYS_fchmodat: c_long = 5000 + 258; +pub const SYS_faccessat: c_long = 5000 + 259; +pub const SYS_pselect6: c_long = 5000 + 260; +pub const SYS_ppoll: c_long = 5000 + 261; +pub const SYS_unshare: c_long = 5000 + 262; +pub const SYS_splice: c_long = 5000 + 263; +pub const SYS_sync_file_range: c_long = 5000 + 264; +pub const SYS_tee: c_long = 5000 + 265; +pub const SYS_vmsplice: c_long = 5000 + 266; +pub const SYS_move_pages: c_long = 5000 + 267; +pub const SYS_set_robust_list: c_long = 5000 + 268; +pub const SYS_get_robust_list: c_long = 5000 + 269; +pub const SYS_kexec_load: c_long = 5000 + 270; +pub const SYS_getcpu: c_long = 5000 + 271; +pub const SYS_epoll_pwait: c_long = 5000 + 272; +pub const SYS_ioprio_set: c_long = 5000 + 273; +pub const SYS_ioprio_get: c_long = 5000 + 274; +pub const SYS_utimensat: c_long = 5000 + 275; +pub const SYS_signalfd: c_long = 5000 + 276; +pub const SYS_timerfd: c_long = 5000 + 277; +pub const SYS_eventfd: c_long = 5000 + 278; +pub const SYS_fallocate: c_long = 5000 + 279; +pub const SYS_timerfd_create: c_long = 5000 + 280; +pub const SYS_timerfd_gettime: c_long = 5000 + 281; +pub const SYS_timerfd_settime: c_long = 5000 + 282; +pub const SYS_signalfd4: c_long = 5000 + 283; +pub const SYS_eventfd2: c_long = 5000 + 284; +pub const SYS_epoll_create1: c_long = 5000 + 285; +pub const SYS_dup3: c_long = 5000 + 286; +pub const SYS_pipe2: c_long = 5000 + 287; +pub const SYS_inotify_init1: c_long = 5000 + 288; +pub const SYS_preadv: c_long = 5000 + 289; +pub const SYS_pwritev: c_long = 5000 + 290; +pub const SYS_rt_tgsigqueueinfo: c_long = 5000 + 291; +pub const SYS_perf_event_open: c_long = 5000 + 292; +pub const SYS_accept4: c_long = 5000 + 293; +pub const SYS_recvmmsg: c_long = 5000 + 294; +pub const SYS_fanotify_init: c_long = 5000 + 295; +pub const SYS_fanotify_mark: c_long = 5000 + 296; +pub const SYS_prlimit64: c_long = 5000 + 297; +pub const SYS_name_to_handle_at: c_long = 5000 + 298; +pub const SYS_open_by_handle_at: c_long = 5000 + 299; +pub const SYS_clock_adjtime: c_long = 5000 + 300; +pub const SYS_syncfs: c_long = 5000 + 301; +pub const SYS_sendmmsg: c_long = 5000 + 302; +pub const SYS_setns: c_long = 5000 + 303; +pub const SYS_process_vm_readv: c_long = 5000 + 304; +pub const SYS_process_vm_writev: c_long = 5000 + 305; +pub const SYS_kcmp: c_long = 5000 + 306; +pub const SYS_finit_module: c_long = 5000 + 307; +pub const SYS_getdents64: c_long = 5000 + 308; +pub const SYS_sched_setattr: c_long = 5000 + 309; +pub const SYS_sched_getattr: c_long = 5000 + 310; +pub const SYS_renameat2: c_long = 5000 + 311; +pub const SYS_seccomp: c_long = 5000 + 312; +pub const SYS_getrandom: c_long = 5000 + 313; +pub const SYS_memfd_create: c_long = 5000 + 314; +pub const SYS_bpf: c_long = 5000 + 315; +pub const SYS_execveat: c_long = 5000 + 316; +pub const SYS_userfaultfd: c_long = 5000 + 317; +pub const SYS_membarrier: c_long = 5000 + 318; +pub const SYS_mlock2: c_long = 5000 + 319; +pub const SYS_copy_file_range: c_long = 5000 + 320; +pub const SYS_preadv2: c_long = 5000 + 321; +pub const SYS_pwritev2: c_long = 5000 + 322; +pub const SYS_pkey_mprotect: c_long = 5000 + 323; +pub const SYS_pkey_alloc: c_long = 5000 + 324; +pub const SYS_pkey_free: c_long = 5000 + 325; +pub const SYS_statx: c_long = 5000 + 326; +pub const SYS_pidfd_send_signal: c_long = 5000 + 424; +pub const SYS_io_uring_setup: c_long = 5000 + 425; +pub const SYS_io_uring_enter: c_long = 5000 + 426; +pub const SYS_io_uring_register: c_long = 5000 + 427; +pub const SYS_open_tree: c_long = 5000 + 428; +pub const SYS_move_mount: c_long = 5000 + 429; +pub const SYS_fsopen: c_long = 5000 + 430; +pub const SYS_fsconfig: c_long = 5000 + 431; +pub const SYS_fsmount: c_long = 5000 + 432; +pub const SYS_fspick: c_long = 5000 + 433; +pub const SYS_pidfd_open: c_long = 5000 + 434; +pub const SYS_clone3: c_long = 5000 + 435; +pub const SYS_close_range: c_long = 5000 + 436; +pub const SYS_openat2: c_long = 5000 + 437; +pub const SYS_pidfd_getfd: c_long = 5000 + 438; +pub const SYS_faccessat2: c_long = 5000 + 439; +pub const SYS_process_madvise: c_long = 5000 + 440; +pub const SYS_epoll_pwait2: c_long = 5000 + 441; +pub const SYS_mount_setattr: c_long = 5000 + 442; +pub const SYS_quotactl_fd: c_long = 5000 + 443; +pub const SYS_landlock_create_ruleset: c_long = 5000 + 444; +pub const SYS_landlock_add_rule: c_long = 5000 + 445; +pub const SYS_landlock_restrict_self: c_long = 5000 + 446; +pub const SYS_memfd_secret: c_long = 5000 + 447; +pub const SYS_process_mrelease: c_long = 5000 + 448; +pub const SYS_futex_waitv: c_long = 5000 + 449; +pub const SYS_set_mempolicy_home_node: c_long = 5000 + 450; + +pub const O_DIRECT: c_int = 0x8000; +pub const O_DIRECTORY: c_int = 0x10000; +pub const O_NOFOLLOW: c_int = 0x20000; + +pub const O_APPEND: c_int = 8; +pub const O_CREAT: c_int = 256; +pub const O_EXCL: c_int = 1024; +pub const O_NOCTTY: c_int = 2048; +pub const O_NONBLOCK: c_int = 128; +pub const O_SYNC: c_int = 0x4010; +pub const O_RSYNC: c_int = 0x4010; +pub const O_DSYNC: c_int = 0x10; +pub const O_ASYNC: c_int = 0x1000; +pub const O_LARGEFILE: c_int = 0x2000; + +pub const EDEADLK: c_int = 45; +pub const ENAMETOOLONG: c_int = 78; +pub const ENOLCK: c_int = 46; +pub const ENOSYS: c_int = 89; +pub const ENOTEMPTY: c_int = 93; +pub const ELOOP: c_int = 90; +pub const ENOMSG: c_int = 35; +pub const EIDRM: c_int = 36; +pub const ECHRNG: c_int = 37; +pub const EL2NSYNC: c_int = 38; +pub const EL3HLT: c_int = 39; +pub const EL3RST: c_int = 40; +pub const ELNRNG: c_int = 41; +pub const EUNATCH: c_int = 42; +pub const ENOCSI: c_int = 43; +pub const EL2HLT: c_int = 44; +pub const EBADE: c_int = 50; +pub const EBADR: c_int = 51; +pub const EXFULL: c_int = 52; +pub const ENOANO: c_int = 53; +pub const EBADRQC: c_int = 54; +pub const EBADSLT: c_int = 55; +pub const EDEADLOCK: c_int = 56; +pub const EMULTIHOP: c_int = 74; +pub const EOVERFLOW: c_int = 79; +pub const ENOTUNIQ: c_int = 80; +pub const EBADFD: c_int = 81; +pub const EBADMSG: c_int = 77; +pub const EREMCHG: c_int = 82; +pub const ELIBACC: c_int = 83; +pub const ELIBBAD: c_int = 84; +pub const ELIBSCN: c_int = 85; +pub const ELIBMAX: c_int = 86; +pub const ELIBEXEC: c_int = 87; +pub const EILSEQ: c_int = 88; +pub const ERESTART: c_int = 91; +pub const ESTRPIPE: c_int = 92; +pub const EUSERS: c_int = 94; +pub const ENOTSOCK: c_int = 95; +pub const EDESTADDRREQ: c_int = 96; +pub const EMSGSIZE: c_int = 97; +pub const EPROTOTYPE: c_int = 98; +pub const ENOPROTOOPT: c_int = 99; +pub const EPROTONOSUPPORT: c_int = 120; +pub const ESOCKTNOSUPPORT: c_int = 121; +pub const EOPNOTSUPP: c_int = 122; +pub const ENOTSUP: c_int = EOPNOTSUPP; +pub const EPFNOSUPPORT: c_int = 123; +pub const EAFNOSUPPORT: c_int = 124; +pub const EADDRINUSE: c_int = 125; +pub const EADDRNOTAVAIL: c_int = 126; +pub const ENETDOWN: c_int = 127; +pub const ENETUNREACH: c_int = 128; +pub const ENETRESET: c_int = 129; +pub const ECONNABORTED: c_int = 130; +pub const ECONNRESET: c_int = 131; +pub const ENOBUFS: c_int = 132; +pub const EISCONN: c_int = 133; +pub const ENOTCONN: c_int = 134; +pub const ESHUTDOWN: c_int = 143; +pub const ETOOMANYREFS: c_int = 144; +pub const ETIMEDOUT: c_int = 145; +pub const ECONNREFUSED: c_int = 146; +pub const EHOSTDOWN: c_int = 147; +pub const EHOSTUNREACH: c_int = 148; +pub const EALREADY: c_int = 149; +pub const EINPROGRESS: c_int = 150; +pub const ESTALE: c_int = 151; +pub const EUCLEAN: c_int = 135; +pub const ENOTNAM: c_int = 137; +pub const ENAVAIL: c_int = 138; +pub const EISNAM: c_int = 139; +pub const EREMOTEIO: c_int = 140; +pub const EDQUOT: c_int = 1133; +pub const ENOMEDIUM: c_int = 159; +pub const EMEDIUMTYPE: c_int = 160; +pub const ECANCELED: c_int = 158; +pub const ENOKEY: c_int = 161; +pub const EKEYEXPIRED: c_int = 162; +pub const EKEYREVOKED: c_int = 163; +pub const EKEYREJECTED: c_int = 164; +pub const EOWNERDEAD: c_int = 165; +pub const ENOTRECOVERABLE: c_int = 166; +pub const ERFKILL: c_int = 167; + +pub const MAP_ANON: c_int = 0x800; +pub const MAP_GROWSDOWN: c_int = 0x1000; +pub const MAP_DENYWRITE: c_int = 0x2000; +pub const MAP_EXECUTABLE: c_int = 0x4000; +pub const MAP_LOCKED: c_int = 0x8000; +pub const MAP_NORESERVE: c_int = 0x400; +pub const MAP_POPULATE: c_int = 0x10000; +pub const MAP_NONBLOCK: c_int = 0x20000; +pub const MAP_STACK: c_int = 0x40000; +pub const MAP_HUGETLB: c_int = 0x080000; + +pub const SA_ONSTACK: c_int = 0x08000000; +pub const SA_SIGINFO: c_int = 0x00000008; +pub const SA_NOCLDWAIT: c_int = 0x00010000; + +pub const SIGEMT: c_int = 7; +pub const SIGCHLD: c_int = 18; +pub const SIGBUS: c_int = 10; +pub const SIGTTIN: c_int = 26; +pub const SIGTTOU: c_int = 27; +pub const SIGXCPU: c_int = 30; +pub const SIGXFSZ: c_int = 31; +pub const SIGVTALRM: c_int = 28; +pub const SIGPROF: c_int = 29; +pub const SIGWINCH: c_int = 20; +pub const SIGUSR1: c_int = 16; +pub const SIGUSR2: c_int = 17; +pub const SIGCONT: c_int = 25; +pub const SIGSTOP: c_int = 23; +pub const SIGTSTP: c_int = 24; +pub const SIGURG: c_int = 21; +pub const SIGIO: c_int = 22; +pub const SIGSYS: c_int = 12; +pub const SIGPOLL: c_int = 22; +pub const SIGPWR: c_int = 19; +pub const SIG_SETMASK: c_int = 3; +pub const SIG_BLOCK: c_int = 0x1; +pub const SIG_UNBLOCK: c_int = 0x2; + +pub const POLLWRNORM: c_short = 0x004; +pub const POLLWRBAND: c_short = 0x100; + +pub const VEOF: usize = 16; +pub const VEOL: usize = 17; +pub const VEOL2: usize = 6; +pub const VMIN: usize = 4; +pub const IEXTEN: crate::tcflag_t = 0x00000100; +pub const TOSTOP: crate::tcflag_t = 0x00008000; +pub const FLUSHO: crate::tcflag_t = 0x00002000; +pub const EXTPROC: crate::tcflag_t = 0o200000; + +pub const F_GETLK: c_int = 14; +pub const F_GETOWN: c_int = 23; +pub const F_SETOWN: c_int = 24; +pub const F_SETLK: c_int = 6; +pub const F_SETLKW: c_int = 7; + +pub const MCL_CURRENT: c_int = 0x0001; +pub const MCL_FUTURE: c_int = 0x0002; +pub const MCL_ONFAULT: c_int = 0x0004; + +pub const CBAUD: crate::tcflag_t = 0o0010017; +pub const TAB1: crate::tcflag_t = 0x00000800; +pub const TAB2: crate::tcflag_t = 0x00001000; +pub const TAB3: crate::tcflag_t = 0x00001800; +pub const CR1: crate::tcflag_t = 0x00000200; +pub const CR2: crate::tcflag_t = 0x00000400; +pub const CR3: crate::tcflag_t = 0x00000600; +pub const FF1: crate::tcflag_t = 0x00008000; +pub const BS1: crate::tcflag_t = 0x00002000; +pub const VT1: crate::tcflag_t = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: crate::tcflag_t = 0x00000400; +pub const IXOFF: crate::tcflag_t = 0x00001000; +pub const ONLCR: crate::tcflag_t = 0x4; +pub const CSIZE: crate::tcflag_t = 0x00000030; +pub const CS6: crate::tcflag_t = 0x00000010; +pub const CS7: crate::tcflag_t = 0x00000020; +pub const CS8: crate::tcflag_t = 0x00000030; +pub const CSTOPB: crate::tcflag_t = 0x00000040; +pub const CREAD: crate::tcflag_t = 0x00000080; +pub const PARENB: crate::tcflag_t = 0x00000100; +pub const PARODD: crate::tcflag_t = 0x00000200; +pub const HUPCL: crate::tcflag_t = 0x00000400; +pub const CLOCAL: crate::tcflag_t = 0x00000800; +pub const ECHOKE: crate::tcflag_t = 0x00000800; +pub const ECHOE: crate::tcflag_t = 0x00000010; +pub const ECHOK: crate::tcflag_t = 0x00000020; +pub const ECHONL: crate::tcflag_t = 0x00000040; +pub const ECHOPRT: crate::tcflag_t = 0x00000400; +pub const ECHOCTL: crate::tcflag_t = 0x00000200; +pub const ISIG: crate::tcflag_t = 0x00000001; +pub const ICANON: crate::tcflag_t = 0x00000002; +pub const PENDIN: crate::tcflag_t = 0x00004000; +pub const NOFLSH: crate::tcflag_t = 0x00000080; +pub const CIBAUD: crate::tcflag_t = 0o02003600000; +pub const CBAUDEX: crate::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: crate::tcflag_t = 0o000002; +pub const NLDLY: crate::tcflag_t = 0o000400; +pub const CRDLY: crate::tcflag_t = 0o003000; +pub const TABDLY: crate::tcflag_t = 0o014000; +pub const BSDLY: crate::tcflag_t = 0o020000; +pub const FFDLY: crate::tcflag_t = 0o100000; +pub const VTDLY: crate::tcflag_t = 0o040000; +pub const XTABS: crate::tcflag_t = 0o014000; + +pub const B57600: crate::speed_t = 0o010001; +pub const B115200: crate::speed_t = 0o010002; +pub const B230400: crate::speed_t = 0o010003; +pub const B460800: crate::speed_t = 0o010004; +pub const B500000: crate::speed_t = 0o010005; +pub const B576000: crate::speed_t = 0o010006; +pub const B921600: crate::speed_t = 0o010007; +pub const B1000000: crate::speed_t = 0o010010; +pub const B1152000: crate::speed_t = 0o010011; +pub const B1500000: crate::speed_t = 0o010012; +pub const B2000000: crate::speed_t = 0o010013; +pub const B2500000: crate::speed_t = 0o010014; +pub const B3000000: crate::speed_t = 0o010015; +pub const B3500000: crate::speed_t = 0o010016; +pub const B4000000: crate::speed_t = 0o010017; + +pub const EHWPOISON: c_int = 168; diff --git a/http/vendor/libc/src/unix/linux_like/linux/musl/b64/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/musl/b64/mod.rs new file mode 100644 index 0000000..6365dbe --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/musl/b64/mod.rs @@ -0,0 +1,88 @@ +use crate::prelude::*; + +pub type regoff_t = c_long; + +s! { + // MIPS implementation is special, see the subfolder. + #[cfg(not(target_arch = "mips64"))] + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_flags: c_int, + pub ss_size: size_t, + } + + pub struct pthread_attr_t { + __size: [u64; 7], + } + + pub struct sigset_t { + __val: [c_ulong; 16], + } + + // PowerPC implementation is special, see the subfolder. + #[cfg(not(target_arch = "powerpc64"))] + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, + pub shm_atime: crate::time_t, + pub shm_dtime: crate::time_t, + pub shm_ctime: crate::time_t, + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: c_ulong, + __pad1: Padding, + __pad2: Padding, + } + + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + pub msg_stime: crate::time_t, + pub msg_rtime: crate::time_t, + pub msg_ctime: crate::time_t, + pub __msg_cbytes: c_ulong, + pub msg_qnum: crate::msgqnum_t, + pub msg_qbytes: crate::msglen_t, + pub msg_lspid: crate::pid_t, + pub msg_lrpid: crate::pid_t, + __pad1: Padding, + __pad2: Padding, + } + + pub struct sem_t { + __val: [c_int; 8], + } +} + +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; +pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; + +cfg_if! { + if #[cfg(target_arch = "aarch64")] { + mod aarch64; + pub use self::aarch64::*; + } else if #[cfg(target_arch = "mips64")] { + mod mips64; + pub use self::mips64::*; + } else if #[cfg(any(target_arch = "powerpc64"))] { + mod powerpc64; + pub use self::powerpc64::*; + } else if #[cfg(any(target_arch = "s390x"))] { + mod s390x; + pub use self::s390x::*; + } else if #[cfg(any(target_arch = "x86_64"))] { + mod x86_64; + pub use self::x86_64::*; + } else if #[cfg(any(target_arch = "riscv64"))] { + mod riscv64; + pub use self::riscv64::*; + } else if #[cfg(any(target_arch = "loongarch64"))] { + mod loongarch64; + pub use self::loongarch64::*; + } else if #[cfg(any(target_arch = "wasm32"))] { + mod wasm32; + pub use self::wasm32::*; + } else { + // Unknown target_arch + } +} diff --git a/http/vendor/libc/src/unix/linux_like/linux/musl/b64/powerpc64.rs b/http/vendor/libc/src/unix/linux_like/linux/musl/b64/powerpc64.rs new file mode 100644 index 0000000..4885ea2 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/musl/b64/powerpc64.rs @@ -0,0 +1,730 @@ +use crate::off_t; +use crate::prelude::*; + +pub type wchar_t = i32; +pub type __u64 = c_ulong; +pub type __s64 = c_long; +pub type nlink_t = u64; +pub type blksize_t = c_long; + +pub type stat64 = stat; + +s! { + pub struct termios { + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_cc: [crate::cc_t; crate::NCCS], + pub c_line: crate::cc_t, + pub __c_ispeed: crate::speed_t, + pub __c_ospeed: crate::speed_t, + } + + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_nlink: crate::nlink_t, + pub st_mode: crate::mode_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + __pad0: Padding, + pub st_rdev: crate::dev_t, + pub st_size: off_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + __unused: Padding<[c_long; 3]>, + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_atime: crate::time_t, + pub shm_dtime: crate::time_t, + pub shm_ctime: crate::time_t, + pub shm_segsz: size_t, + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: c_ulong, + __unused: Padding<[c_ulong; 2]>, + } + + pub struct ipc_perm { + #[cfg(musl_v1_2_3)] + pub __key: crate::key_t, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "This field is incorrectly named and will be changed + to __key in a future release." + )] + pub __ipc_perm_key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: crate::mode_t, + pub __seq: c_int, + __unused1: Padding, + __unused2: Padding, + } +} + +pub const MADV_SOFT_OFFLINE: c_int = 101; +#[deprecated( + since = "0.2.175", + note = "Linux does not define MAP_32BIT on any architectures \ + other than x86 and x86_64, this constant will be removed in the future" +)] +pub const MAP_32BIT: c_int = 0x0040; +pub const O_APPEND: c_int = 1024; +pub const O_DIRECT: c_int = 0x20000; +pub const O_DIRECTORY: c_int = 0x4000; +pub const O_LARGEFILE: c_int = 0x10000; +pub const O_NOFOLLOW: c_int = 0x8000; +pub const O_CREAT: c_int = 64; +pub const O_EXCL: c_int = 128; +pub const O_NOCTTY: c_int = 256; +pub const O_NONBLOCK: c_int = 2048; +pub const O_SYNC: c_int = 1052672; +pub const O_RSYNC: c_int = 1052672; +pub const O_DSYNC: c_int = 4096; +pub const O_ASYNC: c_int = 0x2000; + +pub const ENAMETOOLONG: c_int = 36; +pub const ENOLCK: c_int = 37; +pub const ENOSYS: c_int = 38; +pub const ENOTEMPTY: c_int = 39; +pub const ELOOP: c_int = 40; +pub const ENOMSG: c_int = 42; +pub const EIDRM: c_int = 43; +pub const ECHRNG: c_int = 44; +pub const EL2NSYNC: c_int = 45; +pub const EL3HLT: c_int = 46; +pub const EL3RST: c_int = 47; +pub const ELNRNG: c_int = 48; +pub const EUNATCH: c_int = 49; +pub const ENOCSI: c_int = 50; +pub const EL2HLT: c_int = 51; +pub const EBADE: c_int = 52; +pub const EBADR: c_int = 53; +pub const EXFULL: c_int = 54; +pub const ENOANO: c_int = 55; +pub const EBADRQC: c_int = 56; +pub const EBADSLT: c_int = 57; +pub const EMULTIHOP: c_int = 72; +pub const EBADMSG: c_int = 74; +pub const EOVERFLOW: c_int = 75; +pub const ENOTUNIQ: c_int = 76; +pub const EBADFD: c_int = 77; +pub const EREMCHG: c_int = 78; +pub const ELIBACC: c_int = 79; +pub const ELIBBAD: c_int = 80; +pub const ELIBSCN: c_int = 81; +pub const ELIBMAX: c_int = 82; +pub const ELIBEXEC: c_int = 83; +pub const EILSEQ: c_int = 84; +pub const ERESTART: c_int = 85; +pub const ESTRPIPE: c_int = 86; +pub const EUSERS: c_int = 87; +pub const ENOTSOCK: c_int = 88; +pub const EDESTADDRREQ: c_int = 89; +pub const EMSGSIZE: c_int = 90; +pub const EPROTOTYPE: c_int = 91; +pub const ENOPROTOOPT: c_int = 92; +pub const EPROTONOSUPPORT: c_int = 93; +pub const ESOCKTNOSUPPORT: c_int = 94; +pub const EOPNOTSUPP: c_int = 95; +pub const ENOTSUP: c_int = EOPNOTSUPP; +pub const EPFNOSUPPORT: c_int = 96; +pub const EAFNOSUPPORT: c_int = 97; +pub const EADDRINUSE: c_int = 98; +pub const EADDRNOTAVAIL: c_int = 99; +pub const ENETDOWN: c_int = 100; +pub const ENETUNREACH: c_int = 101; +pub const ENETRESET: c_int = 102; +pub const ECONNABORTED: c_int = 103; +pub const ECONNRESET: c_int = 104; +pub const ENOBUFS: c_int = 105; +pub const EISCONN: c_int = 106; +pub const ENOTCONN: c_int = 107; +pub const ESHUTDOWN: c_int = 108; +pub const ETOOMANYREFS: c_int = 109; +pub const ETIMEDOUT: c_int = 110; +pub const ECONNREFUSED: c_int = 111; +pub const EHOSTDOWN: c_int = 112; +pub const EHOSTUNREACH: c_int = 113; +pub const EALREADY: c_int = 114; +pub const EINPROGRESS: c_int = 115; +pub const ESTALE: c_int = 116; +pub const EUCLEAN: c_int = 117; +pub const ENOTNAM: c_int = 118; +pub const ENAVAIL: c_int = 119; +pub const EISNAM: c_int = 120; +pub const EREMOTEIO: c_int = 121; +pub const EDQUOT: c_int = 122; +pub const ENOMEDIUM: c_int = 123; +pub const EMEDIUMTYPE: c_int = 124; +pub const ECANCELED: c_int = 125; +pub const ENOKEY: c_int = 126; +pub const EKEYEXPIRED: c_int = 127; +pub const EKEYREVOKED: c_int = 128; +pub const EKEYREJECTED: c_int = 129; +pub const EOWNERDEAD: c_int = 130; +pub const ENOTRECOVERABLE: c_int = 131; +pub const ERFKILL: c_int = 132; +pub const EHWPOISON: c_int = 133; + +pub const MAP_ANON: c_int = 0x0020; +pub const MAP_GROWSDOWN: c_int = 0x0100; +pub const MAP_DENYWRITE: c_int = 0x0800; +pub const MAP_EXECUTABLE: c_int = 0x01000; +pub const MAP_LOCKED: c_int = 0x80; +pub const MAP_NORESERVE: c_int = 0x40; +pub const MAP_POPULATE: c_int = 0x08000; +pub const MAP_NONBLOCK: c_int = 0x010000; +pub const MAP_STACK: c_int = 0x020000; +pub const MAP_HUGETLB: c_int = 0x040000; +pub const MAP_SYNC: c_int = 0x080000; + +pub const PTRACE_SYSEMU: c_int = 0x1d; +pub const PTRACE_SYSEMU_SINGLESTEP: c_int = 0x1e; + +pub const SA_ONSTACK: c_int = 0x08000000; +pub const SA_SIGINFO: c_int = 0x00000004; +pub const SA_NOCLDWAIT: c_int = 0x00000002; + +pub const SIGCHLD: c_int = 17; +pub const SIGBUS: c_int = 7; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGUSR1: c_int = 10; +pub const SIGUSR2: c_int = 12; +pub const SIGCONT: c_int = 18; +pub const SIGSTOP: c_int = 19; +pub const SIGTSTP: c_int = 20; +pub const SIGURG: c_int = 23; +pub const SIGIO: c_int = 29; +pub const SIGSYS: c_int = 31; +pub const SIGSTKFLT: c_int = 16; +pub const SIGPOLL: c_int = 29; +pub const SIGPWR: c_int = 30; +pub const SIG_SETMASK: c_int = 2; +pub const SIG_BLOCK: c_int = 0x000000; +pub const SIG_UNBLOCK: c_int = 0x01; + +pub const F_GETLK: c_int = 5; +pub const F_GETOWN: c_int = 9; +pub const F_SETLK: c_int = 6; +pub const F_SETLKW: c_int = 7; +pub const F_SETOWN: c_int = 8; + +pub const VEOF: usize = 4; + +pub const POLLWRNORM: c_short = 0x100; +pub const POLLWRBAND: c_short = 0x200; + +pub const SIGSTKSZ: size_t = 10240; +pub const MINSIGSTKSZ: size_t = 4096; + +// Syscall table +pub const SYS_restart_syscall: c_long = 0; +pub const SYS_exit: c_long = 1; +pub const SYS_fork: c_long = 2; +pub const SYS_read: c_long = 3; +pub const SYS_write: c_long = 4; +pub const SYS_open: c_long = 5; +pub const SYS_close: c_long = 6; +pub const SYS_waitpid: c_long = 7; +pub const SYS_creat: c_long = 8; +pub const SYS_link: c_long = 9; +pub const SYS_unlink: c_long = 10; +pub const SYS_execve: c_long = 11; +pub const SYS_chdir: c_long = 12; +pub const SYS_time: c_long = 13; +pub const SYS_mknod: c_long = 14; +pub const SYS_chmod: c_long = 15; +pub const SYS_lchown: c_long = 16; +pub const SYS_break: c_long = 17; +pub const SYS_oldstat: c_long = 18; +pub const SYS_lseek: c_long = 19; +pub const SYS_getpid: c_long = 20; +pub const SYS_mount: c_long = 21; +pub const SYS_umount: c_long = 22; +pub const SYS_setuid: c_long = 23; +pub const SYS_getuid: c_long = 24; +pub const SYS_stime: c_long = 25; +pub const SYS_ptrace: c_long = 26; +pub const SYS_alarm: c_long = 27; +pub const SYS_oldfstat: c_long = 28; +pub const SYS_pause: c_long = 29; +pub const SYS_utime: c_long = 30; +pub const SYS_stty: c_long = 31; +pub const SYS_gtty: c_long = 32; +pub const SYS_access: c_long = 33; +pub const SYS_nice: c_long = 34; +pub const SYS_ftime: c_long = 35; +pub const SYS_sync: c_long = 36; +pub const SYS_kill: c_long = 37; +pub const SYS_rename: c_long = 38; +pub const SYS_mkdir: c_long = 39; +pub const SYS_rmdir: c_long = 40; +pub const SYS_dup: c_long = 41; +pub const SYS_pipe: c_long = 42; +pub const SYS_times: c_long = 43; +pub const SYS_prof: c_long = 44; +pub const SYS_brk: c_long = 45; +pub const SYS_setgid: c_long = 46; +pub const SYS_getgid: c_long = 47; +pub const SYS_signal: c_long = 48; +pub const SYS_geteuid: c_long = 49; +pub const SYS_getegid: c_long = 50; +pub const SYS_acct: c_long = 51; +pub const SYS_umount2: c_long = 52; +pub const SYS_lock: c_long = 53; +pub const SYS_ioctl: c_long = 54; +pub const SYS_fcntl: c_long = 55; +pub const SYS_mpx: c_long = 56; +pub const SYS_setpgid: c_long = 57; +pub const SYS_ulimit: c_long = 58; +pub const SYS_oldolduname: c_long = 59; +pub const SYS_umask: c_long = 60; +pub const SYS_chroot: c_long = 61; +pub const SYS_ustat: c_long = 62; +pub const SYS_dup2: c_long = 63; +pub const SYS_getppid: c_long = 64; +pub const SYS_getpgrp: c_long = 65; +pub const SYS_setsid: c_long = 66; +pub const SYS_sigaction: c_long = 67; +pub const SYS_sgetmask: c_long = 68; +pub const SYS_ssetmask: c_long = 69; +pub const SYS_setreuid: c_long = 70; +pub const SYS_setregid: c_long = 71; +pub const SYS_sigsuspend: c_long = 72; +pub const SYS_sigpending: c_long = 73; +pub const SYS_sethostname: c_long = 74; +pub const SYS_setrlimit: c_long = 75; +pub const SYS_getrlimit: c_long = 76; +pub const SYS_getrusage: c_long = 77; +pub const SYS_gettimeofday: c_long = 78; +pub const SYS_settimeofday: c_long = 79; +pub const SYS_getgroups: c_long = 80; +pub const SYS_setgroups: c_long = 81; +pub const SYS_select: c_long = 82; +pub const SYS_symlink: c_long = 83; +pub const SYS_oldlstat: c_long = 84; +pub const SYS_readlink: c_long = 85; +pub const SYS_uselib: c_long = 86; +pub const SYS_swapon: c_long = 87; +pub const SYS_reboot: c_long = 88; +pub const SYS_readdir: c_long = 89; +pub const SYS_mmap: c_long = 90; +pub const SYS_munmap: c_long = 91; +pub const SYS_truncate: c_long = 92; +pub const SYS_ftruncate: c_long = 93; +pub const SYS_fchmod: c_long = 94; +pub const SYS_fchown: c_long = 95; +pub const SYS_getpriority: c_long = 96; +pub const SYS_setpriority: c_long = 97; +pub const SYS_profil: c_long = 98; +pub const SYS_statfs: c_long = 99; +pub const SYS_fstatfs: c_long = 100; +pub const SYS_ioperm: c_long = 101; +pub const SYS_socketcall: c_long = 102; +pub const SYS_syslog: c_long = 103; +pub const SYS_setitimer: c_long = 104; +pub const SYS_getitimer: c_long = 105; +pub const SYS_stat: c_long = 106; +pub const SYS_lstat: c_long = 107; +pub const SYS_fstat: c_long = 108; +pub const SYS_olduname: c_long = 109; +pub const SYS_iopl: c_long = 110; +pub const SYS_vhangup: c_long = 111; +pub const SYS_idle: c_long = 112; +pub const SYS_vm86: c_long = 113; +pub const SYS_wait4: c_long = 114; +pub const SYS_swapoff: c_long = 115; +pub const SYS_sysinfo: c_long = 116; +pub const SYS_ipc: c_long = 117; +pub const SYS_fsync: c_long = 118; +pub const SYS_sigreturn: c_long = 119; +pub const SYS_clone: c_long = 120; +pub const SYS_setdomainname: c_long = 121; +pub const SYS_uname: c_long = 122; +pub const SYS_modify_ldt: c_long = 123; +pub const SYS_adjtimex: c_long = 124; +pub const SYS_mprotect: c_long = 125; +pub const SYS_sigprocmask: c_long = 126; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_create_module: c_long = 127; +pub const SYS_init_module: c_long = 128; +pub const SYS_delete_module: c_long = 129; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_get_kernel_syms: c_long = 130; +pub const SYS_quotactl: c_long = 131; +pub const SYS_getpgid: c_long = 132; +pub const SYS_fchdir: c_long = 133; +pub const SYS_bdflush: c_long = 134; +pub const SYS_sysfs: c_long = 135; +pub const SYS_personality: c_long = 136; +pub const SYS_afs_syscall: c_long = 137; /* Syscall for Andrew File System */ +pub const SYS_setfsuid: c_long = 138; +pub const SYS_setfsgid: c_long = 139; +pub const SYS__llseek: c_long = 140; +pub const SYS_getdents: c_long = 141; +pub const SYS__newselect: c_long = 142; +pub const SYS_flock: c_long = 143; +pub const SYS_msync: c_long = 144; +pub const SYS_readv: c_long = 145; +pub const SYS_writev: c_long = 146; +pub const SYS_getsid: c_long = 147; +pub const SYS_fdatasync: c_long = 148; +pub const SYS__sysctl: c_long = 149; +pub const SYS_mlock: c_long = 150; +pub const SYS_munlock: c_long = 151; +pub const SYS_mlockall: c_long = 152; +pub const SYS_munlockall: c_long = 153; +pub const SYS_sched_setparam: c_long = 154; +pub const SYS_sched_getparam: c_long = 155; +pub const SYS_sched_setscheduler: c_long = 156; +pub const SYS_sched_getscheduler: c_long = 157; +pub const SYS_sched_yield: c_long = 158; +pub const SYS_sched_get_priority_max: c_long = 159; +pub const SYS_sched_get_priority_min: c_long = 160; +pub const SYS_sched_rr_get_interval: c_long = 161; +pub const SYS_nanosleep: c_long = 162; +pub const SYS_mremap: c_long = 163; +pub const SYS_setresuid: c_long = 164; +pub const SYS_getresuid: c_long = 165; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_query_module: c_long = 166; +pub const SYS_poll: c_long = 167; +pub const SYS_nfsservctl: c_long = 168; +pub const SYS_setresgid: c_long = 169; +pub const SYS_getresgid: c_long = 170; +pub const SYS_prctl: c_long = 171; +pub const SYS_rt_sigreturn: c_long = 172; +pub const SYS_rt_sigaction: c_long = 173; +pub const SYS_rt_sigprocmask: c_long = 174; +pub const SYS_rt_sigpending: c_long = 175; +pub const SYS_rt_sigtimedwait: c_long = 176; +pub const SYS_rt_sigqueueinfo: c_long = 177; +pub const SYS_rt_sigsuspend: c_long = 178; +pub const SYS_pread64: c_long = 179; +pub const SYS_pwrite64: c_long = 180; +pub const SYS_chown: c_long = 181; +pub const SYS_getcwd: c_long = 182; +pub const SYS_capget: c_long = 183; +pub const SYS_capset: c_long = 184; +pub const SYS_sigaltstack: c_long = 185; +pub const SYS_sendfile: c_long = 186; +pub const SYS_getpmsg: c_long = 187; /* some people actually want streams */ +pub const SYS_putpmsg: c_long = 188; /* some people actually want streams */ +pub const SYS_vfork: c_long = 189; +pub const SYS_ugetrlimit: c_long = 190; /* SuS compliant getrlimit */ +pub const SYS_readahead: c_long = 191; +pub const SYS_pciconfig_read: c_long = 198; +pub const SYS_pciconfig_write: c_long = 199; +pub const SYS_pciconfig_iobase: c_long = 200; +pub const SYS_multiplexer: c_long = 201; +pub const SYS_getdents64: c_long = 202; +pub const SYS_pivot_root: c_long = 203; +pub const SYS_madvise: c_long = 205; +pub const SYS_mincore: c_long = 206; +pub const SYS_gettid: c_long = 207; +pub const SYS_tkill: c_long = 208; +pub const SYS_setxattr: c_long = 209; +pub const SYS_lsetxattr: c_long = 210; +pub const SYS_fsetxattr: c_long = 211; +pub const SYS_getxattr: c_long = 212; +pub const SYS_lgetxattr: c_long = 213; +pub const SYS_fgetxattr: c_long = 214; +pub const SYS_listxattr: c_long = 215; +pub const SYS_llistxattr: c_long = 216; +pub const SYS_flistxattr: c_long = 217; +pub const SYS_removexattr: c_long = 218; +pub const SYS_lremovexattr: c_long = 219; +pub const SYS_fremovexattr: c_long = 220; +pub const SYS_futex: c_long = 221; +pub const SYS_sched_setaffinity: c_long = 222; +pub const SYS_sched_getaffinity: c_long = 223; +pub const SYS_tuxcall: c_long = 225; +pub const SYS_io_setup: c_long = 227; +pub const SYS_io_destroy: c_long = 228; +pub const SYS_io_getevents: c_long = 229; +pub const SYS_io_submit: c_long = 230; +pub const SYS_io_cancel: c_long = 231; +pub const SYS_set_tid_address: c_long = 232; +pub const SYS_exit_group: c_long = 234; +pub const SYS_lookup_dcookie: c_long = 235; +pub const SYS_epoll_create: c_long = 236; +pub const SYS_epoll_ctl: c_long = 237; +pub const SYS_epoll_wait: c_long = 238; +pub const SYS_remap_file_pages: c_long = 239; +pub const SYS_timer_create: c_long = 240; +pub const SYS_timer_settime: c_long = 241; +pub const SYS_timer_gettime: c_long = 242; +pub const SYS_timer_getoverrun: c_long = 243; +pub const SYS_timer_delete: c_long = 244; +pub const SYS_clock_settime: c_long = 245; +pub const SYS_clock_gettime: c_long = 246; +pub const SYS_clock_getres: c_long = 247; +pub const SYS_clock_nanosleep: c_long = 248; +pub const SYS_swapcontext: c_long = 249; +pub const SYS_tgkill: c_long = 250; +pub const SYS_utimes: c_long = 251; +pub const SYS_statfs64: c_long = 252; +pub const SYS_fstatfs64: c_long = 253; +pub const SYS_rtas: c_long = 255; +pub const SYS_sys_debug_setcontext: c_long = 256; +pub const SYS_migrate_pages: c_long = 258; +pub const SYS_mbind: c_long = 259; +pub const SYS_get_mempolicy: c_long = 260; +pub const SYS_set_mempolicy: c_long = 261; +pub const SYS_mq_open: c_long = 262; +pub const SYS_mq_unlink: c_long = 263; +pub const SYS_mq_timedsend: c_long = 264; +pub const SYS_mq_timedreceive: c_long = 265; +pub const SYS_mq_notify: c_long = 266; +pub const SYS_mq_getsetattr: c_long = 267; +pub const SYS_kexec_load: c_long = 268; +pub const SYS_add_key: c_long = 269; +pub const SYS_request_key: c_long = 270; +pub const SYS_keyctl: c_long = 271; +pub const SYS_waitid: c_long = 272; +pub const SYS_ioprio_set: c_long = 273; +pub const SYS_ioprio_get: c_long = 274; +pub const SYS_inotify_init: c_long = 275; +pub const SYS_inotify_add_watch: c_long = 276; +pub const SYS_inotify_rm_watch: c_long = 277; +pub const SYS_spu_run: c_long = 278; +pub const SYS_spu_create: c_long = 279; +pub const SYS_pselect6: c_long = 280; +pub const SYS_ppoll: c_long = 281; +pub const SYS_unshare: c_long = 282; +pub const SYS_splice: c_long = 283; +pub const SYS_tee: c_long = 284; +pub const SYS_vmsplice: c_long = 285; +pub const SYS_openat: c_long = 286; +pub const SYS_mkdirat: c_long = 287; +pub const SYS_mknodat: c_long = 288; +pub const SYS_fchownat: c_long = 289; +pub const SYS_futimesat: c_long = 290; +pub const SYS_newfstatat: c_long = 291; +pub const SYS_unlinkat: c_long = 292; +pub const SYS_renameat: c_long = 293; +pub const SYS_linkat: c_long = 294; +pub const SYS_symlinkat: c_long = 295; +pub const SYS_readlinkat: c_long = 296; +pub const SYS_fchmodat: c_long = 297; +pub const SYS_faccessat: c_long = 298; +pub const SYS_get_robust_list: c_long = 299; +pub const SYS_set_robust_list: c_long = 300; +pub const SYS_move_pages: c_long = 301; +pub const SYS_getcpu: c_long = 302; +pub const SYS_epoll_pwait: c_long = 303; +pub const SYS_utimensat: c_long = 304; +pub const SYS_signalfd: c_long = 305; +pub const SYS_timerfd_create: c_long = 306; +pub const SYS_eventfd: c_long = 307; +pub const SYS_sync_file_range2: c_long = 308; +pub const SYS_fallocate: c_long = 309; +pub const SYS_subpage_prot: c_long = 310; +pub const SYS_timerfd_settime: c_long = 311; +pub const SYS_timerfd_gettime: c_long = 312; +pub const SYS_signalfd4: c_long = 313; +pub const SYS_eventfd2: c_long = 314; +pub const SYS_epoll_create1: c_long = 315; +pub const SYS_dup3: c_long = 316; +pub const SYS_pipe2: c_long = 317; +pub const SYS_inotify_init1: c_long = 318; +pub const SYS_perf_event_open: c_long = 319; +pub const SYS_preadv: c_long = 320; +pub const SYS_pwritev: c_long = 321; +pub const SYS_rt_tgsigqueueinfo: c_long = 322; +pub const SYS_fanotify_init: c_long = 323; +pub const SYS_fanotify_mark: c_long = 324; +pub const SYS_prlimit64: c_long = 325; +pub const SYS_socket: c_long = 326; +pub const SYS_bind: c_long = 327; +pub const SYS_connect: c_long = 328; +pub const SYS_listen: c_long = 329; +pub const SYS_accept: c_long = 330; +pub const SYS_getsockname: c_long = 331; +pub const SYS_getpeername: c_long = 332; +pub const SYS_socketpair: c_long = 333; +pub const SYS_send: c_long = 334; +pub const SYS_sendto: c_long = 335; +pub const SYS_recv: c_long = 336; +pub const SYS_recvfrom: c_long = 337; +pub const SYS_shutdown: c_long = 338; +pub const SYS_setsockopt: c_long = 339; +pub const SYS_getsockopt: c_long = 340; +pub const SYS_sendmsg: c_long = 341; +pub const SYS_recvmsg: c_long = 342; +pub const SYS_recvmmsg: c_long = 343; +pub const SYS_accept4: c_long = 344; +pub const SYS_name_to_handle_at: c_long = 345; +pub const SYS_open_by_handle_at: c_long = 346; +pub const SYS_clock_adjtime: c_long = 347; +pub const SYS_syncfs: c_long = 348; +pub const SYS_sendmmsg: c_long = 349; +pub const SYS_setns: c_long = 350; +pub const SYS_process_vm_readv: c_long = 351; +pub const SYS_process_vm_writev: c_long = 352; +pub const SYS_finit_module: c_long = 353; +pub const SYS_kcmp: c_long = 354; +pub const SYS_sched_setattr: c_long = 355; +pub const SYS_sched_getattr: c_long = 356; +pub const SYS_renameat2: c_long = 357; +pub const SYS_seccomp: c_long = 358; +pub const SYS_getrandom: c_long = 359; +pub const SYS_memfd_create: c_long = 360; +pub const SYS_bpf: c_long = 361; +pub const SYS_execveat: c_long = 362; +pub const SYS_switch_endian: c_long = 363; +pub const SYS_userfaultfd: c_long = 364; +pub const SYS_membarrier: c_long = 365; +pub const SYS_mlock2: c_long = 378; +pub const SYS_copy_file_range: c_long = 379; +pub const SYS_preadv2: c_long = 380; +pub const SYS_pwritev2: c_long = 381; +pub const SYS_kexec_file_load: c_long = 382; +pub const SYS_statx: c_long = 383; +pub const SYS_pkey_alloc: c_long = 384; +pub const SYS_pkey_free: c_long = 385; +pub const SYS_pkey_mprotect: c_long = 386; +pub const SYS_rseq: c_long = 387; +pub const SYS_io_pgetevents: c_long = 388; +pub const SYS_semtimedop: c_long = 392; +pub const SYS_semget: c_long = 393; +pub const SYS_semctl: c_long = 394; +pub const SYS_shmget: c_long = 395; +pub const SYS_shmctl: c_long = 396; +pub const SYS_shmat: c_long = 397; +pub const SYS_shmdt: c_long = 398; +pub const SYS_msgget: c_long = 399; +pub const SYS_msgsnd: c_long = 400; +pub const SYS_msgrcv: c_long = 401; +pub const SYS_msgctl: c_long = 402; +pub const SYS_pidfd_send_signal: c_long = 424; +pub const SYS_io_uring_setup: c_long = 425; +pub const SYS_io_uring_enter: c_long = 426; +pub const SYS_io_uring_register: c_long = 427; +pub const SYS_open_tree: c_long = 428; +pub const SYS_move_mount: c_long = 429; +pub const SYS_fsopen: c_long = 430; +pub const SYS_fsconfig: c_long = 431; +pub const SYS_fsmount: c_long = 432; +pub const SYS_fspick: c_long = 433; +pub const SYS_pidfd_open: c_long = 434; +pub const SYS_clone3: c_long = 435; +pub const SYS_close_range: c_long = 436; +pub const SYS_openat2: c_long = 437; +pub const SYS_pidfd_getfd: c_long = 438; +pub const SYS_faccessat2: c_long = 439; +pub const SYS_process_madvise: c_long = 440; +pub const SYS_epoll_pwait2: c_long = 441; +pub const SYS_mount_setattr: c_long = 442; +pub const SYS_quotactl_fd: c_long = 443; +pub const SYS_landlock_create_ruleset: c_long = 444; +pub const SYS_landlock_add_rule: c_long = 445; +pub const SYS_landlock_restrict_self: c_long = 446; +pub const SYS_memfd_secret: c_long = 447; +pub const SYS_process_mrelease: c_long = 448; +pub const SYS_futex_waitv: c_long = 449; +pub const SYS_set_mempolicy_home_node: c_long = 450; + +pub const EDEADLK: c_int = 35; +pub const EDEADLOCK: c_int = 58; + +pub const EXTPROC: crate::tcflag_t = 0x10000000; +pub const VEOL: usize = 6; +pub const VEOL2: usize = 8; +pub const VMIN: usize = 5; +pub const IEXTEN: crate::tcflag_t = 0x00000400; +pub const TOSTOP: crate::tcflag_t = 0x00400000; +pub const FLUSHO: crate::tcflag_t = 0x00800000; + +pub const MCL_CURRENT: c_int = 0x2000; +pub const MCL_FUTURE: c_int = 0x4000; +pub const MCL_ONFAULT: c_int = 0x8000; +pub const CBAUD: crate::tcflag_t = 0xff; +pub const TAB1: c_int = 0x400; +pub const TAB2: c_int = 0x800; +pub const TAB3: c_int = 0xc00; +pub const CR1: c_int = 0x1000; +pub const CR2: c_int = 0x2000; +pub const CR3: c_int = 0x3000; +pub const FF1: c_int = 0x4000; +pub const BS1: c_int = 0x8000; +pub const VT1: c_int = 0x10000; +pub const VWERASE: usize = 10; +pub const VREPRINT: usize = 11; +pub const VSUSP: usize = 12; +pub const VSTART: usize = 13; +pub const VSTOP: usize = 14; +pub const VDISCARD: usize = 16; +pub const VTIME: usize = 7; +pub const IXON: crate::tcflag_t = 0x00000200; +pub const IXOFF: crate::tcflag_t = 0x00000400; +pub const ONLCR: crate::tcflag_t = 0x2; +pub const CSIZE: crate::tcflag_t = 0x00000300; + +pub const CS6: crate::tcflag_t = 0x00000100; +pub const CS7: crate::tcflag_t = 0x00000200; +pub const CS8: crate::tcflag_t = 0x00000300; +pub const CSTOPB: crate::tcflag_t = 0x00000400; +pub const CREAD: crate::tcflag_t = 0x00000800; +pub const PARENB: crate::tcflag_t = 0x00001000; +pub const PARODD: crate::tcflag_t = 0x00002000; +pub const HUPCL: crate::tcflag_t = 0x00004000; +pub const CLOCAL: crate::tcflag_t = 0x00008000; +pub const ECHOKE: crate::tcflag_t = 0x00000001; +pub const ECHOE: crate::tcflag_t = 0x00000002; +pub const ECHOK: crate::tcflag_t = 0x00000004; +pub const ECHONL: crate::tcflag_t = 0x00000010; +pub const ECHOPRT: crate::tcflag_t = 0x00000020; +pub const ECHOCTL: crate::tcflag_t = 0x00000040; +pub const ISIG: crate::tcflag_t = 0x00000080; +pub const ICANON: crate::tcflag_t = 0x00000100; +pub const PENDIN: crate::tcflag_t = 0x20000000; +pub const NOFLSH: crate::tcflag_t = 0x80000000; + +pub const CIBAUD: crate::tcflag_t = 0o77600000; +pub const CBAUDEX: crate::tcflag_t = 0o0000020; +pub const VSWTC: usize = 9; +pub const OLCUC: crate::tcflag_t = 0o000004; +pub const NLDLY: crate::tcflag_t = 0o0001400; +pub const CRDLY: crate::tcflag_t = 0o0030000; +pub const TABDLY: crate::tcflag_t = 0o0006000; +pub const BSDLY: crate::tcflag_t = 0o0100000; +pub const FFDLY: crate::tcflag_t = 0o0040000; +pub const VTDLY: crate::tcflag_t = 0o0200000; +pub const XTABS: crate::tcflag_t = 0o00006000; + +pub const B57600: crate::speed_t = 0o00020; +pub const B115200: crate::speed_t = 0o00021; +pub const B230400: crate::speed_t = 0o00022; +pub const B460800: crate::speed_t = 0o00023; +pub const B500000: crate::speed_t = 0o00024; +pub const B576000: crate::speed_t = 0o00025; +pub const B921600: crate::speed_t = 0o00026; +pub const B1000000: crate::speed_t = 0o00027; +pub const B1152000: crate::speed_t = 0o00030; +pub const B1500000: crate::speed_t = 0o00031; +pub const B2000000: crate::speed_t = 0o00032; +pub const B2500000: crate::speed_t = 0o00033; +pub const B3000000: crate::speed_t = 0o00034; +pub const B3500000: crate::speed_t = 0o00035; +pub const B4000000: crate::speed_t = 0o00036; diff --git a/http/vendor/libc/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs new file mode 100644 index 0000000..bd395e4 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs @@ -0,0 +1,649 @@ +//! RISC-V-specific definitions for 64-bit linux-like values + +use crate::off_t; +use crate::prelude::*; + +pub type wchar_t = c_int; + +pub type nlink_t = c_uint; +pub type blksize_t = c_int; +pub type __u64 = c_ulonglong; +pub type __s64 = c_longlong; + +pub type stat64 = stat; + +s! { + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + __pad1: Padding, + pub st_size: off_t, + pub st_blksize: crate::blksize_t, + __pad2: Padding, + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + __unused: Padding<[c_int; 2usize]>, + } + + pub struct ipc_perm { + pub __key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: c_ushort, + __pad1: Padding, + pub __seq: c_ushort, + __pad2: Padding, + __unused1: Padding, + __unused2: Padding, + } + + #[repr(align(8))] + pub struct clone_args { + pub flags: c_ulonglong, + pub pidfd: c_ulonglong, + pub child_tid: c_ulonglong, + pub parent_tid: c_ulonglong, + pub exit_signal: c_ulonglong, + pub stack: c_ulonglong, + pub stack_size: c_ulonglong, + pub tls: c_ulonglong, + pub set_tid: c_ulonglong, + pub set_tid_size: c_ulonglong, + pub cgroup: c_ulonglong, + } +} + +s_no_extra_traits! { + pub struct ucontext_t { + pub __uc_flags: c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: crate::stack_t, + pub uc_sigmask: crate::sigset_t, + pub uc_mcontext: mcontext_t, + } + + #[repr(align(16))] + pub struct mcontext_t { + pub __gregs: [c_ulong; 32], + pub __fpregs: __riscv_mc_fp_state, + } + + pub union __riscv_mc_fp_state { + pub __f: __riscv_mc_f_ext_state, + pub __d: __riscv_mc_d_ext_state, + pub __q: __riscv_mc_q_ext_state, + } + + pub struct __riscv_mc_f_ext_state { + pub __f: [c_uint; 32], + pub __fcsr: c_uint, + } + + pub struct __riscv_mc_d_ext_state { + pub __f: [c_ulonglong; 32], + pub __fcsr: c_uint, + } + + #[repr(align(16))] + pub struct __riscv_mc_q_ext_state { + pub __f: [c_ulonglong; 64], + pub __fcsr: c_uint, + pub __glibc_reserved: [c_uint; 3], + } +} + +pub const SYS_read: c_long = 63; +pub const SYS_write: c_long = 64; +pub const SYS_close: c_long = 57; +pub const SYS_fstat: c_long = 80; +pub const SYS_lseek: c_long = 62; +pub const SYS_mmap: c_long = 222; +pub const SYS_mprotect: c_long = 226; +pub const SYS_munmap: c_long = 215; +pub const SYS_brk: c_long = 214; +pub const SYS_rt_sigaction: c_long = 134; +pub const SYS_rt_sigprocmask: c_long = 135; +pub const SYS_rt_sigreturn: c_long = 139; +pub const SYS_ioctl: c_long = 29; +pub const SYS_pread64: c_long = 67; +pub const SYS_pwrite64: c_long = 68; +pub const SYS_readv: c_long = 65; +pub const SYS_writev: c_long = 66; +pub const SYS_sched_yield: c_long = 124; +pub const SYS_mremap: c_long = 216; +pub const SYS_msync: c_long = 227; +pub const SYS_mincore: c_long = 232; +pub const SYS_madvise: c_long = 233; +pub const SYS_shmget: c_long = 194; +pub const SYS_shmat: c_long = 196; +pub const SYS_shmctl: c_long = 195; +pub const SYS_dup: c_long = 23; +pub const SYS_nanosleep: c_long = 101; +pub const SYS_getitimer: c_long = 102; +pub const SYS_setitimer: c_long = 103; +pub const SYS_getpid: c_long = 172; +pub const SYS_sendfile: c_long = 71; +pub const SYS_socket: c_long = 198; +pub const SYS_connect: c_long = 203; +pub const SYS_accept: c_long = 202; +pub const SYS_sendto: c_long = 206; +pub const SYS_recvfrom: c_long = 207; +pub const SYS_sendmsg: c_long = 211; +pub const SYS_recvmsg: c_long = 212; +pub const SYS_shutdown: c_long = 210; +pub const SYS_bind: c_long = 200; +pub const SYS_listen: c_long = 201; +pub const SYS_getsockname: c_long = 204; +pub const SYS_getpeername: c_long = 205; +pub const SYS_socketpair: c_long = 199; +pub const SYS_setsockopt: c_long = 208; +pub const SYS_getsockopt: c_long = 209; +pub const SYS_clone: c_long = 220; +pub const SYS_execve: c_long = 221; +pub const SYS_exit: c_long = 93; +pub const SYS_wait4: c_long = 260; +pub const SYS_kill: c_long = 129; +pub const SYS_uname: c_long = 160; +pub const SYS_semget: c_long = 190; +pub const SYS_semop: c_long = 193; +pub const SYS_semctl: c_long = 191; +pub const SYS_shmdt: c_long = 197; +pub const SYS_msgget: c_long = 186; +pub const SYS_msgsnd: c_long = 189; +pub const SYS_msgrcv: c_long = 188; +pub const SYS_msgctl: c_long = 187; +pub const SYS_fcntl: c_long = 25; +pub const SYS_flock: c_long = 32; +pub const SYS_fsync: c_long = 82; +pub const SYS_fdatasync: c_long = 83; +pub const SYS_truncate: c_long = 45; +pub const SYS_ftruncate: c_long = 46; +pub const SYS_getcwd: c_long = 17; +pub const SYS_chdir: c_long = 49; +pub const SYS_fchdir: c_long = 50; +pub const SYS_fchmod: c_long = 52; +pub const SYS_fchown: c_long = 55; +pub const SYS_umask: c_long = 166; +pub const SYS_gettimeofday: c_long = 169; +pub const SYS_getrlimit: c_long = 163; +pub const SYS_getrusage: c_long = 165; +pub const SYS_sysinfo: c_long = 179; +pub const SYS_times: c_long = 153; +pub const SYS_ptrace: c_long = 117; +pub const SYS_getuid: c_long = 174; +pub const SYS_syslog: c_long = 116; +pub const SYS_getgid: c_long = 176; +pub const SYS_setuid: c_long = 146; +pub const SYS_setgid: c_long = 144; +pub const SYS_geteuid: c_long = 175; +pub const SYS_getegid: c_long = 177; +pub const SYS_setpgid: c_long = 154; +pub const SYS_getppid: c_long = 173; +pub const SYS_setsid: c_long = 157; +pub const SYS_setreuid: c_long = 145; +pub const SYS_setregid: c_long = 143; +pub const SYS_getgroups: c_long = 158; +pub const SYS_setgroups: c_long = 159; +pub const SYS_setresuid: c_long = 147; +pub const SYS_getresuid: c_long = 148; +pub const SYS_setresgid: c_long = 149; +pub const SYS_getresgid: c_long = 150; +pub const SYS_getpgid: c_long = 155; +pub const SYS_setfsuid: c_long = 151; +pub const SYS_setfsgid: c_long = 152; +pub const SYS_getsid: c_long = 156; +pub const SYS_capget: c_long = 90; +pub const SYS_capset: c_long = 91; +pub const SYS_rt_sigpending: c_long = 136; +pub const SYS_rt_sigtimedwait: c_long = 137; +pub const SYS_rt_sigqueueinfo: c_long = 138; +pub const SYS_rt_sigsuspend: c_long = 133; +pub const SYS_sigaltstack: c_long = 132; +pub const SYS_personality: c_long = 92; +pub const SYS_statfs: c_long = 43; +pub const SYS_fstatfs: c_long = 44; +pub const SYS_getpriority: c_long = 141; +pub const SYS_setpriority: c_long = 140; +pub const SYS_sched_setparam: c_long = 118; +pub const SYS_sched_getparam: c_long = 121; +pub const SYS_sched_setscheduler: c_long = 119; +pub const SYS_sched_getscheduler: c_long = 120; +pub const SYS_sched_get_priority_max: c_long = 125; +pub const SYS_sched_get_priority_min: c_long = 126; +pub const SYS_sched_rr_get_interval: c_long = 127; +pub const SYS_mlock: c_long = 228; +pub const SYS_munlock: c_long = 229; +pub const SYS_mlockall: c_long = 230; +pub const SYS_munlockall: c_long = 231; +pub const SYS_vhangup: c_long = 58; +pub const SYS_pivot_root: c_long = 41; +pub const SYS_prctl: c_long = 167; +pub const SYS_adjtimex: c_long = 171; +pub const SYS_setrlimit: c_long = 164; +pub const SYS_chroot: c_long = 51; +pub const SYS_sync: c_long = 81; +pub const SYS_acct: c_long = 89; +pub const SYS_settimeofday: c_long = 170; +pub const SYS_mount: c_long = 40; +pub const SYS_umount2: c_long = 39; +pub const SYS_swapon: c_long = 224; +pub const SYS_swapoff: c_long = 225; +pub const SYS_reboot: c_long = 142; +pub const SYS_sethostname: c_long = 161; +pub const SYS_setdomainname: c_long = 162; +pub const SYS_init_module: c_long = 105; +pub const SYS_delete_module: c_long = 106; +pub const SYS_quotactl: c_long = 60; +pub const SYS_nfsservctl: c_long = 42; +pub const SYS_gettid: c_long = 178; +pub const SYS_readahead: c_long = 213; +pub const SYS_setxattr: c_long = 5; +pub const SYS_lsetxattr: c_long = 6; +pub const SYS_fsetxattr: c_long = 7; +pub const SYS_getxattr: c_long = 8; +pub const SYS_lgetxattr: c_long = 9; +pub const SYS_fgetxattr: c_long = 10; +pub const SYS_listxattr: c_long = 11; +pub const SYS_llistxattr: c_long = 12; +pub const SYS_flistxattr: c_long = 13; +pub const SYS_removexattr: c_long = 14; +pub const SYS_lremovexattr: c_long = 15; +pub const SYS_fremovexattr: c_long = 16; +pub const SYS_tkill: c_long = 130; +pub const SYS_futex: c_long = 98; +pub const SYS_sched_setaffinity: c_long = 122; +pub const SYS_sched_getaffinity: c_long = 123; +pub const SYS_io_setup: c_long = 0; +pub const SYS_io_destroy: c_long = 1; +pub const SYS_io_getevents: c_long = 4; +pub const SYS_io_submit: c_long = 2; +pub const SYS_io_cancel: c_long = 3; +pub const SYS_lookup_dcookie: c_long = 18; +pub const SYS_remap_file_pages: c_long = 234; +pub const SYS_getdents64: c_long = 61; +pub const SYS_set_tid_address: c_long = 96; +pub const SYS_restart_syscall: c_long = 128; +pub const SYS_semtimedop: c_long = 192; +pub const SYS_fadvise64: c_long = 223; +pub const SYS_timer_create: c_long = 107; +pub const SYS_timer_settime: c_long = 110; +pub const SYS_timer_gettime: c_long = 108; +pub const SYS_timer_getoverrun: c_long = 109; +pub const SYS_timer_delete: c_long = 111; +pub const SYS_clock_settime: c_long = 112; +pub const SYS_clock_gettime: c_long = 113; +pub const SYS_clock_getres: c_long = 114; +pub const SYS_clock_nanosleep: c_long = 115; +pub const SYS_exit_group: c_long = 94; +pub const SYS_epoll_ctl: c_long = 21; +pub const SYS_tgkill: c_long = 131; +pub const SYS_mbind: c_long = 235; +pub const SYS_set_mempolicy: c_long = 237; +pub const SYS_get_mempolicy: c_long = 236; +pub const SYS_mq_open: c_long = 180; +pub const SYS_mq_unlink: c_long = 181; +pub const SYS_mq_timedsend: c_long = 182; +pub const SYS_mq_timedreceive: c_long = 183; +pub const SYS_mq_notify: c_long = 184; +pub const SYS_mq_getsetattr: c_long = 185; +pub const SYS_kexec_load: c_long = 104; +pub const SYS_waitid: c_long = 95; +pub const SYS_add_key: c_long = 217; +pub const SYS_request_key: c_long = 218; +pub const SYS_keyctl: c_long = 219; +pub const SYS_ioprio_set: c_long = 30; +pub const SYS_ioprio_get: c_long = 31; +pub const SYS_inotify_add_watch: c_long = 27; +pub const SYS_inotify_rm_watch: c_long = 28; +pub const SYS_migrate_pages: c_long = 238; +pub const SYS_openat: c_long = 56; +pub const SYS_mkdirat: c_long = 34; +pub const SYS_mknodat: c_long = 33; +pub const SYS_fchownat: c_long = 54; +pub const SYS_newfstatat: c_long = 79; +pub const SYS_unlinkat: c_long = 35; +pub const SYS_linkat: c_long = 37; +pub const SYS_symlinkat: c_long = 36; +pub const SYS_readlinkat: c_long = 78; +pub const SYS_fchmodat: c_long = 53; +pub const SYS_faccessat: c_long = 48; +pub const SYS_pselect6: c_long = 72; +pub const SYS_ppoll: c_long = 73; +pub const SYS_unshare: c_long = 97; +pub const SYS_set_robust_list: c_long = 99; +pub const SYS_get_robust_list: c_long = 100; +pub const SYS_splice: c_long = 76; +pub const SYS_tee: c_long = 77; +pub const SYS_sync_file_range: c_long = 84; +pub const SYS_vmsplice: c_long = 75; +pub const SYS_move_pages: c_long = 239; +pub const SYS_utimensat: c_long = 88; +pub const SYS_epoll_pwait: c_long = 22; +pub const SYS_timerfd_create: c_long = 85; +pub const SYS_fallocate: c_long = 47; +pub const SYS_timerfd_settime: c_long = 86; +pub const SYS_timerfd_gettime: c_long = 87; +pub const SYS_accept4: c_long = 242; +pub const SYS_signalfd4: c_long = 74; +pub const SYS_eventfd2: c_long = 19; +pub const SYS_epoll_create1: c_long = 20; +pub const SYS_dup3: c_long = 24; +pub const SYS_pipe2: c_long = 59; +pub const SYS_inotify_init1: c_long = 26; +pub const SYS_preadv: c_long = 69; +pub const SYS_pwritev: c_long = 70; +pub const SYS_rt_tgsigqueueinfo: c_long = 240; +pub const SYS_perf_event_open: c_long = 241; +pub const SYS_recvmmsg: c_long = 243; +pub const SYS_fanotify_init: c_long = 262; +pub const SYS_fanotify_mark: c_long = 263; +pub const SYS_prlimit64: c_long = 261; +pub const SYS_name_to_handle_at: c_long = 264; +pub const SYS_open_by_handle_at: c_long = 265; +pub const SYS_clock_adjtime: c_long = 266; +pub const SYS_syncfs: c_long = 267; +pub const SYS_sendmmsg: c_long = 269; +pub const SYS_setns: c_long = 268; +pub const SYS_getcpu: c_long = 168; +pub const SYS_process_vm_readv: c_long = 270; +pub const SYS_process_vm_writev: c_long = 271; +pub const SYS_kcmp: c_long = 272; +pub const SYS_finit_module: c_long = 273; +pub const SYS_sched_setattr: c_long = 274; +pub const SYS_sched_getattr: c_long = 275; +pub const SYS_renameat2: c_long = 276; +pub const SYS_seccomp: c_long = 277; +pub const SYS_getrandom: c_long = 278; +pub const SYS_memfd_create: c_long = 279; +pub const SYS_bpf: c_long = 280; +pub const SYS_execveat: c_long = 281; +pub const SYS_userfaultfd: c_long = 282; +pub const SYS_membarrier: c_long = 283; +pub const SYS_mlock2: c_long = 284; +pub const SYS_copy_file_range: c_long = 285; +pub const SYS_preadv2: c_long = 286; +pub const SYS_pwritev2: c_long = 287; +pub const SYS_pkey_mprotect: c_long = 288; +pub const SYS_pkey_alloc: c_long = 289; +pub const SYS_pkey_free: c_long = 290; +pub const SYS_statx: c_long = 291; +pub const SYS_io_pgetevents: c_long = 292; +pub const SYS_rseq: c_long = 293; +pub const SYS_pidfd_send_signal: c_long = 424; +pub const SYS_io_uring_setup: c_long = 425; +pub const SYS_io_uring_enter: c_long = 426; +pub const SYS_io_uring_register: c_long = 427; +pub const SYS_open_tree: c_long = 428; +pub const SYS_move_mount: c_long = 429; +pub const SYS_fsopen: c_long = 430; +pub const SYS_fsconfig: c_long = 431; +pub const SYS_fsmount: c_long = 432; +pub const SYS_fspick: c_long = 433; +pub const SYS_pidfd_open: c_long = 434; +pub const SYS_clone3: c_long = 435; +pub const SYS_close_range: c_long = 436; +pub const SYS_openat2: c_long = 437; +pub const SYS_pidfd_getfd: c_long = 438; +pub const SYS_faccessat2: c_long = 439; +pub const SYS_process_madvise: c_long = 440; +pub const SYS_epoll_pwait2: c_long = 441; +pub const SYS_mount_setattr: c_long = 442; +pub const SYS_landlock_create_ruleset: c_long = 444; +pub const SYS_landlock_add_rule: c_long = 445; +pub const SYS_landlock_restrict_self: c_long = 446; + +pub const O_APPEND: c_int = 1024; +pub const O_DIRECT: c_int = 0x4000; +pub const O_DIRECTORY: c_int = 0x10000; +pub const O_LARGEFILE: c_int = 0o100000; +pub const O_NOFOLLOW: c_int = 0x20000; +pub const O_CREAT: c_int = 64; +pub const O_EXCL: c_int = 128; +pub const O_NOCTTY: c_int = 256; +pub const O_NONBLOCK: c_int = 2048; +pub const O_SYNC: c_int = 1052672; +pub const O_RSYNC: c_int = 1052672; +pub const O_DSYNC: c_int = 4096; +pub const O_ASYNC: c_int = 0x2000; + +pub const SIGSTKSZ: size_t = 8192; +pub const MINSIGSTKSZ: size_t = 2048; + +pub const ENAMETOOLONG: c_int = 36; +pub const ENOLCK: c_int = 37; +pub const ENOSYS: c_int = 38; +pub const ENOTEMPTY: c_int = 39; +pub const ELOOP: c_int = 40; +pub const ENOMSG: c_int = 42; +pub const EIDRM: c_int = 43; +pub const ECHRNG: c_int = 44; +pub const EL2NSYNC: c_int = 45; +pub const EL3HLT: c_int = 46; +pub const EL3RST: c_int = 47; +pub const ELNRNG: c_int = 48; +pub const EUNATCH: c_int = 49; +pub const ENOCSI: c_int = 50; +pub const EL2HLT: c_int = 51; +pub const EBADE: c_int = 52; +pub const EBADR: c_int = 53; +pub const EXFULL: c_int = 54; +pub const ENOANO: c_int = 55; +pub const EBADRQC: c_int = 56; +pub const EBADSLT: c_int = 57; +pub const EMULTIHOP: c_int = 72; +pub const EOVERFLOW: c_int = 75; +pub const ENOTUNIQ: c_int = 76; +pub const EBADFD: c_int = 77; +pub const EBADMSG: c_int = 74; +pub const EREMCHG: c_int = 78; +pub const ELIBACC: c_int = 79; +pub const ELIBBAD: c_int = 80; +pub const ELIBSCN: c_int = 81; +pub const ELIBMAX: c_int = 82; +pub const ELIBEXEC: c_int = 83; +pub const EILSEQ: c_int = 84; +pub const ERESTART: c_int = 85; +pub const ESTRPIPE: c_int = 86; +pub const EUSERS: c_int = 87; +pub const ENOTSOCK: c_int = 88; +pub const EDESTADDRREQ: c_int = 89; +pub const EMSGSIZE: c_int = 90; +pub const EPROTOTYPE: c_int = 91; +pub const ENOPROTOOPT: c_int = 92; +pub const EPROTONOSUPPORT: c_int = 93; +pub const ESOCKTNOSUPPORT: c_int = 94; +pub const EOPNOTSUPP: c_int = 95; +pub const ENOTSUP: c_int = EOPNOTSUPP; +pub const EPFNOSUPPORT: c_int = 96; +pub const EAFNOSUPPORT: c_int = 97; +pub const EADDRINUSE: c_int = 98; +pub const EADDRNOTAVAIL: c_int = 99; +pub const ENETDOWN: c_int = 100; +pub const ENETUNREACH: c_int = 101; +pub const ENETRESET: c_int = 102; +pub const ECONNABORTED: c_int = 103; +pub const ECONNRESET: c_int = 104; +pub const ENOBUFS: c_int = 105; +pub const EISCONN: c_int = 106; +pub const ENOTCONN: c_int = 107; +pub const ESHUTDOWN: c_int = 108; +pub const ETOOMANYREFS: c_int = 109; +pub const ETIMEDOUT: c_int = 110; +pub const ECONNREFUSED: c_int = 111; +pub const EHOSTDOWN: c_int = 112; +pub const EHOSTUNREACH: c_int = 113; +pub const EALREADY: c_int = 114; +pub const EINPROGRESS: c_int = 115; +pub const ESTALE: c_int = 116; +pub const EUCLEAN: c_int = 117; +pub const ENOTNAM: c_int = 118; +pub const ENAVAIL: c_int = 119; +pub const EISNAM: c_int = 120; +pub const EREMOTEIO: c_int = 121; +pub const EDQUOT: c_int = 122; +pub const ENOMEDIUM: c_int = 123; +pub const EMEDIUMTYPE: c_int = 124; +pub const ECANCELED: c_int = 125; +pub const ENOKEY: c_int = 126; +pub const EKEYEXPIRED: c_int = 127; +pub const EKEYREVOKED: c_int = 128; +pub const EKEYREJECTED: c_int = 129; +pub const EOWNERDEAD: c_int = 130; +pub const ENOTRECOVERABLE: c_int = 131; +pub const EHWPOISON: c_int = 133; +pub const ERFKILL: c_int = 132; + +pub const SA_ONSTACK: c_int = 0x08000000; +pub const SA_SIGINFO: c_int = 0x00000004; +pub const SA_NOCLDWAIT: c_int = 0x00000002; + +pub const SIGCHLD: c_int = 17; +pub const SIGBUS: c_int = 7; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGUSR1: c_int = 10; +pub const SIGUSR2: c_int = 12; +pub const SIGCONT: c_int = 18; +pub const SIGSTOP: c_int = 19; +pub const SIGTSTP: c_int = 20; +pub const SIGURG: c_int = 23; +pub const SIGIO: c_int = 29; +pub const SIGSYS: c_int = 31; +pub const SIGSTKFLT: c_int = 16; +pub const SIGPOLL: c_int = 29; +pub const SIGPWR: c_int = 30; +pub const SIG_SETMASK: c_int = 2; +pub const SIG_BLOCK: c_int = 0x000000; +pub const SIG_UNBLOCK: c_int = 0x01; + +pub const F_GETLK: c_int = 5; +pub const F_GETOWN: c_int = 9; +pub const F_SETLK: c_int = 6; +pub const F_SETLKW: c_int = 7; +pub const F_SETOWN: c_int = 8; + +pub const VEOF: usize = 4; + +pub const POLLWRNORM: c_short = 0x100; +pub const POLLWRBAND: c_short = 0x200; + +pub const MADV_SOFT_OFFLINE: c_int = 101; +pub const MAP_ANON: c_int = 0x0020; +pub const MAP_GROWSDOWN: c_int = 0x0100; +pub const MAP_DENYWRITE: c_int = 0x0800; +pub const MAP_EXECUTABLE: c_int = 0x01000; +pub const MAP_LOCKED: c_int = 0x02000; +pub const MAP_NORESERVE: c_int = 0x04000; +pub const MAP_POPULATE: c_int = 0x08000; +pub const MAP_NONBLOCK: c_int = 0x010000; +pub const MAP_STACK: c_int = 0x020000; +pub const MAP_HUGETLB: c_int = 0x040000; +pub const MAP_SYNC: c_int = 0x080000; + +pub const MCL_CURRENT: c_int = 0x0001; +pub const MCL_FUTURE: c_int = 0x0002; +pub const MCL_ONFAULT: c_int = 0x0004; +pub const CBAUD: crate::tcflag_t = 0o0010017; +pub const TAB1: c_int = 0x00000800; +pub const TAB2: c_int = 0x00001000; +pub const TAB3: c_int = 0x00001800; +pub const CR1: c_int = 0x00000200; +pub const CR2: c_int = 0x00000400; +pub const CR3: c_int = 0x00000600; +pub const FF1: c_int = 0x00008000; +pub const BS1: c_int = 0x00002000; +pub const VT1: c_int = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: crate::tcflag_t = 0x00000400; +pub const IXOFF: crate::tcflag_t = 0x00001000; +pub const ONLCR: crate::tcflag_t = 0x4; +pub const CSIZE: crate::tcflag_t = 0x00000030; +pub const CS6: crate::tcflag_t = 0x00000010; +pub const CS7: crate::tcflag_t = 0x00000020; +pub const CS8: crate::tcflag_t = 0x00000030; +pub const CSTOPB: crate::tcflag_t = 0x00000040; +pub const CREAD: crate::tcflag_t = 0x00000080; +pub const PARENB: crate::tcflag_t = 0x00000100; +pub const PARODD: crate::tcflag_t = 0x00000200; +pub const HUPCL: crate::tcflag_t = 0x00000400; +pub const CLOCAL: crate::tcflag_t = 0x00000800; +pub const ECHOKE: crate::tcflag_t = 0x00000800; +pub const ECHOE: crate::tcflag_t = 0x00000010; +pub const ECHOK: crate::tcflag_t = 0x00000020; +pub const ECHONL: crate::tcflag_t = 0x00000040; +pub const ECHOPRT: crate::tcflag_t = 0x00000400; +pub const ECHOCTL: crate::tcflag_t = 0x00000200; +pub const ISIG: crate::tcflag_t = 0x00000001; +pub const ICANON: crate::tcflag_t = 0x00000002; +pub const PENDIN: crate::tcflag_t = 0x00004000; +pub const NOFLSH: crate::tcflag_t = 0x00000080; +pub const CIBAUD: crate::tcflag_t = 0o02003600000; +pub const CBAUDEX: crate::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: crate::tcflag_t = 0o000002; +pub const NLDLY: crate::tcflag_t = 0o000400; +pub const CRDLY: crate::tcflag_t = 0o003000; +pub const TABDLY: crate::tcflag_t = 0o014000; +pub const BSDLY: crate::tcflag_t = 0o020000; +pub const FFDLY: crate::tcflag_t = 0o100000; +pub const VTDLY: crate::tcflag_t = 0o040000; +pub const XTABS: crate::tcflag_t = 0o014000; +pub const B57600: crate::speed_t = 0o010001; +pub const B115200: crate::speed_t = 0o010002; +pub const B230400: crate::speed_t = 0o010003; +pub const B460800: crate::speed_t = 0o010004; +pub const B500000: crate::speed_t = 0o010005; +pub const B576000: crate::speed_t = 0o010006; +pub const B921600: crate::speed_t = 0o010007; +pub const B1000000: crate::speed_t = 0o010010; +pub const B1152000: crate::speed_t = 0o010011; +pub const B1500000: crate::speed_t = 0o010012; +pub const B2000000: crate::speed_t = 0o010013; +pub const B2500000: crate::speed_t = 0o010014; +pub const B3000000: crate::speed_t = 0o010015; +pub const B3500000: crate::speed_t = 0o010016; +pub const B4000000: crate::speed_t = 0o010017; + +pub const EDEADLK: c_int = 35; +pub const EDEADLOCK: c_int = EDEADLK; +pub const EXTPROC: crate::tcflag_t = 0x00010000; +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: crate::tcflag_t = 0x00008000; +pub const TOSTOP: crate::tcflag_t = 0x00000100; +pub const FLUSHO: crate::tcflag_t = 0x00001000; + +pub const NGREG: usize = 32; +pub const REG_PC: usize = 0; +pub const REG_RA: usize = 1; +pub const REG_SP: usize = 2; +pub const REG_TP: usize = 4; +pub const REG_S0: usize = 8; +pub const REG_S1: usize = 9; +pub const REG_A0: usize = 10; +pub const REG_S2: usize = 18; +pub const REG_NARGS: usize = 8; diff --git a/http/vendor/libc/src/unix/linux_like/linux/musl/b64/s390x.rs b/http/vendor/libc/src/unix/linux_like/linux/musl/b64/s390x.rs new file mode 100644 index 0000000..0ee6c11 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/musl/b64/s390x.rs @@ -0,0 +1,734 @@ +use crate::off_t; +use crate::prelude::*; + +pub type blksize_t = i64; +pub type nlink_t = u64; +pub type wchar_t = i32; +pub type greg_t = u64; +pub type __u64 = u64; +pub type __s64 = i64; +pub type statfs64 = statfs; +pub type stat64 = stat; + +s! { + pub struct ipc_perm { + #[cfg(musl_v1_2_3)] + pub __key: crate::key_t, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "This field is incorrectly named and will be changed + to __key in a future release." + )] + pub __ipc_perm_key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: crate::mode_t, + pub __seq: c_int, + __pad1: Padding, + __pad2: Padding, + } + + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_nlink: crate::nlink_t, + pub st_mode: crate::mode_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + pub st_size: off_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + __unused: Padding<[c_long; 3]>, + } + + pub struct statfs { + pub f_type: c_uint, + pub f_bsize: c_uint, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_fsid: crate::fsid_t, + pub f_namelen: c_uint, + pub f_frsize: c_uint, + pub f_flags: c_uint, + pub f_spare: [c_uint; 4], + } + + pub struct __psw_t { + pub mask: c_ulong, + pub addr: c_ulong, + } + + pub struct fpregset_t { + pub fpc: c_uint, + pub fprs: [fpreg_t; 16], + } + + pub struct mcontext_t { + pub psw: __psw_t, + pub gregs: [c_ulong; 16], + pub aregs: [c_uint; 16], + pub fpregs: fpregset_t, + } + + pub struct ucontext_t { + pub uc_flags: c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: crate::stack_t, + pub uc_mcontext: mcontext_t, + pub uc_sigmask: crate::sigset_t, + } +} + +s_no_extra_traits! { + pub union fpreg_t { + pub d: c_double, + pub f: c_float, + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for fpreg_t { + fn eq(&self, _other: &fpreg_t) -> bool { + unimplemented!("traits") + } + } + + impl Eq for fpreg_t {} + + impl hash::Hash for fpreg_t { + fn hash(&self, _state: &mut H) { + unimplemented!("traits") + } + } + } +} + +pub const VEOF: usize = 4; + +pub const EUCLEAN: c_int = 117; +pub const ENOTNAM: c_int = 118; +pub const ENAVAIL: c_int = 119; +pub const EISNAM: c_int = 120; +pub const EREMOTEIO: c_int = 121; +pub const EADDRINUSE: c_int = 98; +pub const EADDRNOTAVAIL: c_int = 99; +pub const ECONNABORTED: c_int = 103; +pub const ECONNREFUSED: c_int = 111; +pub const ECONNRESET: c_int = 104; +pub const EDEADLK: c_int = 35; +pub const ENOSYS: c_int = 38; +pub const ENOTCONN: c_int = 107; +pub const ETIMEDOUT: c_int = 110; +pub const O_APPEND: c_int = 1024; +pub const O_CREAT: c_int = 64; +pub const O_EXCL: c_int = 128; +pub const O_LARGEFILE: c_int = 0x8000; +pub const O_NONBLOCK: c_int = 2048; +pub const SA_NOCLDWAIT: c_int = 2; +pub const SA_ONSTACK: c_int = 0x08000000; +pub const SA_SIGINFO: c_int = 4; +pub const SIGBUS: c_int = 7; +pub const SIGSTKSZ: size_t = 10240; +pub const MINSIGSTKSZ: size_t = 4096; +pub const SIG_SETMASK: c_int = 2; + +pub const O_NOCTTY: c_int = 256; +pub const O_SYNC: c_int = 1052672; +pub const O_RSYNC: c_int = 1052672; +pub const O_DSYNC: c_int = 4096; +pub const O_DIRECT: c_int = 0x4000; +pub const O_DIRECTORY: c_int = 0x10000; +pub const O_NOFOLLOW: c_int = 0x20000; + +pub const MADV_SOFT_OFFLINE: c_int = 101; +pub const MAP_GROWSDOWN: c_int = 0x0100; +pub const MAP_LOCKED: c_int = 0x02000; +pub const MAP_NORESERVE: c_int = 0x04000; +pub const MAP_ANON: c_int = 0x0020; +pub const MAP_DENYWRITE: c_int = 0x0800; +pub const MAP_EXECUTABLE: c_int = 0x01000; +pub const MAP_POPULATE: c_int = 0x08000; +pub const MAP_NONBLOCK: c_int = 0x010000; +pub const MAP_STACK: c_int = 0x020000; +pub const MAP_HUGETLB: c_int = 0x040000; +pub const MAP_SYNC: c_int = 0x080000; + +pub const PTRACE_SYSEMU: c_int = 31; +pub const PTRACE_SYSEMU_SINGLESTEP: c_int = 32; + +pub const EDEADLOCK: c_int = 35; +pub const ENAMETOOLONG: c_int = 36; +pub const ENOLCK: c_int = 37; +pub const ENOTEMPTY: c_int = 39; +pub const ELOOP: c_int = 40; +pub const ENOMSG: c_int = 42; +pub const EIDRM: c_int = 43; +pub const ECHRNG: c_int = 44; +pub const EL2NSYNC: c_int = 45; +pub const EL3HLT: c_int = 46; +pub const EL3RST: c_int = 47; +pub const ELNRNG: c_int = 48; +pub const EUNATCH: c_int = 49; +pub const ENOCSI: c_int = 50; +pub const EL2HLT: c_int = 51; +pub const EBADE: c_int = 52; +pub const EBADR: c_int = 53; +pub const EXFULL: c_int = 54; +pub const ENOANO: c_int = 55; +pub const EBADRQC: c_int = 56; +pub const EBADSLT: c_int = 57; +pub const EMULTIHOP: c_int = 72; +pub const EOVERFLOW: c_int = 75; +pub const ENOTUNIQ: c_int = 76; +pub const EBADFD: c_int = 77; +pub const EBADMSG: c_int = 74; +pub const EREMCHG: c_int = 78; +pub const ELIBACC: c_int = 79; +pub const ELIBBAD: c_int = 80; +pub const ELIBSCN: c_int = 81; +pub const ELIBMAX: c_int = 82; +pub const ELIBEXEC: c_int = 83; +pub const EILSEQ: c_int = 84; +pub const ERESTART: c_int = 85; +pub const ESTRPIPE: c_int = 86; +pub const EUSERS: c_int = 87; +pub const ENOTSOCK: c_int = 88; +pub const EDESTADDRREQ: c_int = 89; +pub const EMSGSIZE: c_int = 90; +pub const EPROTOTYPE: c_int = 91; +pub const ENOPROTOOPT: c_int = 92; +pub const EPROTONOSUPPORT: c_int = 93; +pub const ESOCKTNOSUPPORT: c_int = 94; +pub const EOPNOTSUPP: c_int = 95; +pub const ENOTSUP: c_int = EOPNOTSUPP; +pub const EPFNOSUPPORT: c_int = 96; +pub const EAFNOSUPPORT: c_int = 97; +pub const ENETDOWN: c_int = 100; +pub const ENETUNREACH: c_int = 101; +pub const ENETRESET: c_int = 102; +pub const ENOBUFS: c_int = 105; +pub const EISCONN: c_int = 106; +pub const ESHUTDOWN: c_int = 108; +pub const ETOOMANYREFS: c_int = 109; +pub const EHOSTDOWN: c_int = 112; +pub const EHOSTUNREACH: c_int = 113; +pub const EALREADY: c_int = 114; +pub const EINPROGRESS: c_int = 115; +pub const ESTALE: c_int = 116; +pub const EDQUOT: c_int = 122; +pub const ENOMEDIUM: c_int = 123; +pub const EMEDIUMTYPE: c_int = 124; +pub const ECANCELED: c_int = 125; +pub const ENOKEY: c_int = 126; +pub const EKEYEXPIRED: c_int = 127; +pub const EKEYREVOKED: c_int = 128; +pub const EKEYREJECTED: c_int = 129; +pub const EOWNERDEAD: c_int = 130; +pub const ENOTRECOVERABLE: c_int = 131; +pub const EHWPOISON: c_int = 133; +pub const ERFKILL: c_int = 132; + +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGCHLD: c_int = 17; +pub const SIGUSR1: c_int = 10; +pub const SIGUSR2: c_int = 12; +pub const SIGCONT: c_int = 18; +pub const SIGSTOP: c_int = 19; +pub const SIGTSTP: c_int = 20; +pub const SIGURG: c_int = 23; +pub const SIGIO: c_int = 29; +pub const SIGSYS: c_int = 31; +pub const SIGSTKFLT: c_int = 16; +pub const SIGPOLL: c_int = 29; +pub const SIGPWR: c_int = 30; +pub const SIG_BLOCK: c_int = 0x000000; +pub const SIG_UNBLOCK: c_int = 0x01; + +pub const O_ASYNC: c_int = 0x2000; + +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: crate::tcflag_t = 0x00008000; +pub const TOSTOP: crate::tcflag_t = 0x00000100; +pub const FLUSHO: crate::tcflag_t = 0x00001000; + +pub const EXTPROC: crate::tcflag_t = 0x00010000; + +pub const MCL_CURRENT: c_int = 0x0001; +pub const MCL_FUTURE: c_int = 0x0002; +pub const MCL_ONFAULT: c_int = 0x0004; + +pub const F_GETLK: c_int = 5; +pub const F_GETOWN: c_int = 9; +pub const F_SETOWN: c_int = 8; +pub const F_SETLK: c_int = 6; +pub const F_SETLKW: c_int = 7; + +pub const VTIME: usize = 5; +pub const VSWTC: usize = 7; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VSUSP: usize = 10; +pub const VREPRINT: usize = 12; +pub const VDISCARD: usize = 13; +pub const VWERASE: usize = 14; +pub const OLCUC: crate::tcflag_t = 0o000002; +pub const ONLCR: crate::tcflag_t = 0o000004; +pub const NLDLY: crate::tcflag_t = 0o000400; +pub const CRDLY: crate::tcflag_t = 0o003000; +pub const CR1: crate::tcflag_t = 0x00000200; +pub const CR2: crate::tcflag_t = 0x00000400; +pub const CR3: crate::tcflag_t = 0x00000600; +pub const TABDLY: crate::tcflag_t = 0o014000; +pub const TAB1: crate::tcflag_t = 0x00000800; +pub const TAB2: crate::tcflag_t = 0x00001000; +pub const TAB3: crate::tcflag_t = 0x00001800; +pub const BSDLY: crate::tcflag_t = 0o020000; +pub const BS1: crate::tcflag_t = 0x00002000; +pub const FFDLY: crate::tcflag_t = 0o100000; +pub const FF1: crate::tcflag_t = 0x00008000; +pub const VTDLY: crate::tcflag_t = 0o040000; +pub const VT1: crate::tcflag_t = 0x00004000; +pub const XTABS: crate::tcflag_t = 0o014000; + +pub const CBAUD: crate::speed_t = 0o010017; +pub const CSIZE: crate::tcflag_t = 0o000060; +pub const CS6: crate::tcflag_t = 0o000020; +pub const CS7: crate::tcflag_t = 0o000040; +pub const CS8: crate::tcflag_t = 0o000060; +pub const CSTOPB: crate::tcflag_t = 0o000100; +pub const CREAD: crate::tcflag_t = 0o000200; +pub const PARENB: crate::tcflag_t = 0o000400; +pub const PARODD: crate::tcflag_t = 0o001000; +pub const HUPCL: crate::tcflag_t = 0o002000; +pub const CLOCAL: crate::tcflag_t = 0o004000; +pub const CBAUDEX: crate::tcflag_t = 0o010000; +pub const B57600: crate::speed_t = 0o010001; +pub const B115200: crate::speed_t = 0o010002; +pub const B230400: crate::speed_t = 0o010003; +pub const B460800: crate::speed_t = 0o010004; +pub const B500000: crate::speed_t = 0o010005; +pub const B576000: crate::speed_t = 0o010006; +pub const B921600: crate::speed_t = 0o010007; +pub const B1000000: crate::speed_t = 0o010010; +pub const B1152000: crate::speed_t = 0o010011; +pub const B1500000: crate::speed_t = 0o010012; +pub const B2000000: crate::speed_t = 0o010013; +pub const B2500000: crate::speed_t = 0o010014; +pub const B3000000: crate::speed_t = 0o010015; +pub const B3500000: crate::speed_t = 0o010016; +pub const B4000000: crate::speed_t = 0o010017; +pub const CIBAUD: crate::tcflag_t = 0o02003600000; + +pub const ISIG: crate::tcflag_t = 0o000001; +pub const ICANON: crate::tcflag_t = 0o000002; +pub const ECHOE: crate::tcflag_t = 0o000020; +pub const ECHOK: crate::tcflag_t = 0o000040; +pub const ECHONL: crate::tcflag_t = 0o000100; +pub const NOFLSH: crate::tcflag_t = 0o000200; +pub const ECHOCTL: crate::tcflag_t = 0o001000; +pub const ECHOPRT: crate::tcflag_t = 0o002000; +pub const ECHOKE: crate::tcflag_t = 0o004000; +pub const PENDIN: crate::tcflag_t = 0o040000; + +pub const POLLWRNORM: c_short = 0x100; +pub const POLLWRBAND: c_short = 0x200; + +pub const IXON: crate::tcflag_t = 0o002000; +pub const IXOFF: crate::tcflag_t = 0o010000; + +pub const SYS_exit: c_long = 1; +pub const SYS_fork: c_long = 2; +pub const SYS_read: c_long = 3; +pub const SYS_write: c_long = 4; +pub const SYS_open: c_long = 5; +pub const SYS_close: c_long = 6; +pub const SYS_restart_syscall: c_long = 7; +pub const SYS_creat: c_long = 8; +pub const SYS_link: c_long = 9; +pub const SYS_unlink: c_long = 10; +pub const SYS_execve: c_long = 11; +pub const SYS_chdir: c_long = 12; +pub const SYS_mknod: c_long = 14; +pub const SYS_chmod: c_long = 15; +pub const SYS_lseek: c_long = 19; +pub const SYS_getpid: c_long = 20; +pub const SYS_mount: c_long = 21; +pub const SYS_umount: c_long = 22; +pub const SYS_ptrace: c_long = 26; +pub const SYS_alarm: c_long = 27; +pub const SYS_pause: c_long = 29; +pub const SYS_utime: c_long = 30; +pub const SYS_access: c_long = 33; +pub const SYS_nice: c_long = 34; +pub const SYS_sync: c_long = 36; +pub const SYS_kill: c_long = 37; +pub const SYS_rename: c_long = 38; +pub const SYS_mkdir: c_long = 39; +pub const SYS_rmdir: c_long = 40; +pub const SYS_dup: c_long = 41; +pub const SYS_pipe: c_long = 42; +pub const SYS_times: c_long = 43; +pub const SYS_brk: c_long = 45; +pub const SYS_signal: c_long = 48; +pub const SYS_acct: c_long = 51; +pub const SYS_umount2: c_long = 52; +pub const SYS_ioctl: c_long = 54; +pub const SYS_fcntl: c_long = 55; +pub const SYS_setpgid: c_long = 57; +pub const SYS_umask: c_long = 60; +pub const SYS_chroot: c_long = 61; +pub const SYS_ustat: c_long = 62; +pub const SYS_dup2: c_long = 63; +pub const SYS_getppid: c_long = 64; +pub const SYS_getpgrp: c_long = 65; +pub const SYS_setsid: c_long = 66; +pub const SYS_sigaction: c_long = 67; +pub const SYS_sigsuspend: c_long = 72; +pub const SYS_sigpending: c_long = 73; +pub const SYS_sethostname: c_long = 74; +pub const SYS_setrlimit: c_long = 75; +pub const SYS_getrusage: c_long = 77; +pub const SYS_gettimeofday: c_long = 78; +pub const SYS_settimeofday: c_long = 79; +pub const SYS_symlink: c_long = 83; +pub const SYS_readlink: c_long = 85; +pub const SYS_uselib: c_long = 86; +pub const SYS_swapon: c_long = 87; +pub const SYS_reboot: c_long = 88; +pub const SYS_readdir: c_long = 89; +pub const SYS_mmap: c_long = 90; +pub const SYS_munmap: c_long = 91; +pub const SYS_truncate: c_long = 92; +pub const SYS_ftruncate: c_long = 93; +pub const SYS_fchmod: c_long = 94; +pub const SYS_getpriority: c_long = 96; +pub const SYS_setpriority: c_long = 97; +pub const SYS_statfs: c_long = 99; +pub const SYS_fstatfs: c_long = 100; +pub const SYS_socketcall: c_long = 102; +pub const SYS_syslog: c_long = 103; +pub const SYS_setitimer: c_long = 104; +pub const SYS_getitimer: c_long = 105; +pub const SYS_stat: c_long = 106; +pub const SYS_lstat: c_long = 107; +pub const SYS_fstat: c_long = 108; +pub const SYS_lookup_dcookie: c_long = 110; +pub const SYS_vhangup: c_long = 111; +pub const SYS_idle: c_long = 112; +pub const SYS_wait4: c_long = 114; +pub const SYS_swapoff: c_long = 115; +pub const SYS_sysinfo: c_long = 116; +pub const SYS_ipc: c_long = 117; +pub const SYS_fsync: c_long = 118; +pub const SYS_sigreturn: c_long = 119; +pub const SYS_clone: c_long = 120; +pub const SYS_setdomainname: c_long = 121; +pub const SYS_uname: c_long = 122; +pub const SYS_adjtimex: c_long = 124; +pub const SYS_mprotect: c_long = 125; +pub const SYS_sigprocmask: c_long = 126; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_create_module: c_long = 127; +pub const SYS_init_module: c_long = 128; +pub const SYS_delete_module: c_long = 129; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_get_kernel_syms: c_long = 130; +pub const SYS_quotactl: c_long = 131; +pub const SYS_getpgid: c_long = 132; +pub const SYS_fchdir: c_long = 133; +pub const SYS_bdflush: c_long = 134; +pub const SYS_sysfs: c_long = 135; +pub const SYS_personality: c_long = 136; +pub const SYS_afs_syscall: c_long = 137; /* Syscall for Andrew File System */ +pub const SYS_getdents: c_long = 141; +pub const SYS_select: c_long = 142; +pub const SYS_flock: c_long = 143; +pub const SYS_msync: c_long = 144; +pub const SYS_readv: c_long = 145; +pub const SYS_writev: c_long = 146; +pub const SYS_getsid: c_long = 147; +pub const SYS_fdatasync: c_long = 148; +pub const SYS__sysctl: c_long = 149; +pub const SYS_mlock: c_long = 150; +pub const SYS_munlock: c_long = 151; +pub const SYS_mlockall: c_long = 152; +pub const SYS_munlockall: c_long = 153; +pub const SYS_sched_setparam: c_long = 154; +pub const SYS_sched_getparam: c_long = 155; +pub const SYS_sched_setscheduler: c_long = 156; +pub const SYS_sched_getscheduler: c_long = 157; +pub const SYS_sched_yield: c_long = 158; +pub const SYS_sched_get_priority_max: c_long = 159; +pub const SYS_sched_get_priority_min: c_long = 160; +pub const SYS_sched_rr_get_interval: c_long = 161; +pub const SYS_nanosleep: c_long = 162; +pub const SYS_mremap: c_long = 163; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_query_module: c_long = 167; +pub const SYS_poll: c_long = 168; +pub const SYS_nfsservctl: c_long = 169; +pub const SYS_prctl: c_long = 172; +pub const SYS_rt_sigreturn: c_long = 173; +pub const SYS_rt_sigaction: c_long = 174; +pub const SYS_rt_sigprocmask: c_long = 175; +pub const SYS_rt_sigpending: c_long = 176; +pub const SYS_rt_sigtimedwait: c_long = 177; +pub const SYS_rt_sigqueueinfo: c_long = 178; +pub const SYS_rt_sigsuspend: c_long = 179; +pub const SYS_pread64: c_long = 180; +pub const SYS_pwrite64: c_long = 181; +pub const SYS_getcwd: c_long = 183; +pub const SYS_capget: c_long = 184; +pub const SYS_capset: c_long = 185; +pub const SYS_sigaltstack: c_long = 186; +pub const SYS_sendfile: c_long = 187; +pub const SYS_getpmsg: c_long = 188; +pub const SYS_putpmsg: c_long = 189; +pub const SYS_vfork: c_long = 190; +pub const SYS_getrlimit: c_long = 191; +pub const SYS_lchown: c_long = 198; +pub const SYS_getuid: c_long = 199; +pub const SYS_getgid: c_long = 200; +pub const SYS_geteuid: c_long = 201; +pub const SYS_getegid: c_long = 202; +pub const SYS_setreuid: c_long = 203; +pub const SYS_setregid: c_long = 204; +pub const SYS_getgroups: c_long = 205; +pub const SYS_setgroups: c_long = 206; +pub const SYS_fchown: c_long = 207; +pub const SYS_setresuid: c_long = 208; +pub const SYS_getresuid: c_long = 209; +pub const SYS_setresgid: c_long = 210; +pub const SYS_getresgid: c_long = 211; +pub const SYS_chown: c_long = 212; +pub const SYS_setuid: c_long = 213; +pub const SYS_setgid: c_long = 214; +pub const SYS_setfsuid: c_long = 215; +pub const SYS_setfsgid: c_long = 216; +pub const SYS_pivot_root: c_long = 217; +pub const SYS_mincore: c_long = 218; +pub const SYS_madvise: c_long = 219; +pub const SYS_getdents64: c_long = 220; +pub const SYS_readahead: c_long = 222; +pub const SYS_setxattr: c_long = 224; +pub const SYS_lsetxattr: c_long = 225; +pub const SYS_fsetxattr: c_long = 226; +pub const SYS_getxattr: c_long = 227; +pub const SYS_lgetxattr: c_long = 228; +pub const SYS_fgetxattr: c_long = 229; +pub const SYS_listxattr: c_long = 230; +pub const SYS_llistxattr: c_long = 231; +pub const SYS_flistxattr: c_long = 232; +pub const SYS_removexattr: c_long = 233; +pub const SYS_lremovexattr: c_long = 234; +pub const SYS_fremovexattr: c_long = 235; +pub const SYS_gettid: c_long = 236; +pub const SYS_tkill: c_long = 237; +pub const SYS_futex: c_long = 238; +pub const SYS_sched_setaffinity: c_long = 239; +pub const SYS_sched_getaffinity: c_long = 240; +pub const SYS_tgkill: c_long = 241; +pub const SYS_io_setup: c_long = 243; +pub const SYS_io_destroy: c_long = 244; +pub const SYS_io_getevents: c_long = 245; +pub const SYS_io_submit: c_long = 246; +pub const SYS_io_cancel: c_long = 247; +pub const SYS_exit_group: c_long = 248; +pub const SYS_epoll_create: c_long = 249; +pub const SYS_epoll_ctl: c_long = 250; +pub const SYS_epoll_wait: c_long = 251; +pub const SYS_set_tid_address: c_long = 252; +pub const SYS_fadvise64: c_long = 253; +pub const SYS_timer_create: c_long = 254; +pub const SYS_timer_settime: c_long = 255; +pub const SYS_timer_gettime: c_long = 256; +pub const SYS_timer_getoverrun: c_long = 257; +pub const SYS_timer_delete: c_long = 258; +pub const SYS_clock_settime: c_long = 259; +pub const SYS_clock_gettime: c_long = 260; +pub const SYS_clock_getres: c_long = 261; +pub const SYS_clock_nanosleep: c_long = 262; +pub const SYS_statfs64: c_long = 265; +pub const SYS_fstatfs64: c_long = 266; +pub const SYS_remap_file_pages: c_long = 267; +pub const SYS_mbind: c_long = 268; +pub const SYS_get_mempolicy: c_long = 269; +pub const SYS_set_mempolicy: c_long = 270; +pub const SYS_mq_open: c_long = 271; +pub const SYS_mq_unlink: c_long = 272; +pub const SYS_mq_timedsend: c_long = 273; +pub const SYS_mq_timedreceive: c_long = 274; +pub const SYS_mq_notify: c_long = 275; +pub const SYS_mq_getsetattr: c_long = 276; +pub const SYS_kexec_load: c_long = 277; +pub const SYS_add_key: c_long = 278; +pub const SYS_request_key: c_long = 279; +pub const SYS_keyctl: c_long = 280; +pub const SYS_waitid: c_long = 281; +pub const SYS_ioprio_set: c_long = 282; +pub const SYS_ioprio_get: c_long = 283; +pub const SYS_inotify_init: c_long = 284; +pub const SYS_inotify_add_watch: c_long = 285; +pub const SYS_inotify_rm_watch: c_long = 286; +pub const SYS_migrate_pages: c_long = 287; +pub const SYS_openat: c_long = 288; +pub const SYS_mkdirat: c_long = 289; +pub const SYS_mknodat: c_long = 290; +pub const SYS_fchownat: c_long = 291; +pub const SYS_futimesat: c_long = 292; +pub const SYS_newfstatat: c_long = 293; +pub const SYS_unlinkat: c_long = 294; +pub const SYS_renameat: c_long = 295; +pub const SYS_linkat: c_long = 296; +pub const SYS_symlinkat: c_long = 297; +pub const SYS_readlinkat: c_long = 298; +pub const SYS_fchmodat: c_long = 299; +pub const SYS_faccessat: c_long = 300; +pub const SYS_pselect6: c_long = 301; +pub const SYS_ppoll: c_long = 302; +pub const SYS_unshare: c_long = 303; +pub const SYS_set_robust_list: c_long = 304; +pub const SYS_get_robust_list: c_long = 305; +pub const SYS_splice: c_long = 306; +pub const SYS_sync_file_range: c_long = 307; +pub const SYS_tee: c_long = 308; +pub const SYS_vmsplice: c_long = 309; +pub const SYS_move_pages: c_long = 310; +pub const SYS_getcpu: c_long = 311; +pub const SYS_epoll_pwait: c_long = 312; +pub const SYS_utimes: c_long = 313; +pub const SYS_fallocate: c_long = 314; +pub const SYS_utimensat: c_long = 315; +pub const SYS_signalfd: c_long = 316; +pub const SYS_timerfd: c_long = 317; +pub const SYS_eventfd: c_long = 318; +pub const SYS_timerfd_create: c_long = 319; +pub const SYS_timerfd_settime: c_long = 320; +pub const SYS_timerfd_gettime: c_long = 321; +pub const SYS_signalfd4: c_long = 322; +pub const SYS_eventfd2: c_long = 323; +pub const SYS_inotify_init1: c_long = 324; +pub const SYS_pipe2: c_long = 325; +pub const SYS_dup3: c_long = 326; +pub const SYS_epoll_create1: c_long = 327; +pub const SYS_preadv: c_long = 328; +pub const SYS_pwritev: c_long = 329; +pub const SYS_rt_tgsigqueueinfo: c_long = 330; +pub const SYS_perf_event_open: c_long = 331; +pub const SYS_fanotify_init: c_long = 332; +pub const SYS_fanotify_mark: c_long = 333; +pub const SYS_prlimit64: c_long = 334; +pub const SYS_name_to_handle_at: c_long = 335; +pub const SYS_open_by_handle_at: c_long = 336; +pub const SYS_clock_adjtime: c_long = 337; +pub const SYS_syncfs: c_long = 338; +pub const SYS_setns: c_long = 339; +pub const SYS_process_vm_readv: c_long = 340; +pub const SYS_process_vm_writev: c_long = 341; +pub const SYS_s390_runtime_instr: c_long = 342; +pub const SYS_kcmp: c_long = 343; +pub const SYS_finit_module: c_long = 344; +pub const SYS_sched_setattr: c_long = 345; +pub const SYS_sched_getattr: c_long = 346; +pub const SYS_renameat2: c_long = 347; +pub const SYS_seccomp: c_long = 348; +pub const SYS_getrandom: c_long = 349; +pub const SYS_memfd_create: c_long = 350; +pub const SYS_bpf: c_long = 351; +pub const SYS_s390_pci_mmio_write: c_long = 352; +pub const SYS_s390_pci_mmio_read: c_long = 353; +pub const SYS_execveat: c_long = 354; +pub const SYS_userfaultfd: c_long = 355; +pub const SYS_membarrier: c_long = 356; +pub const SYS_recvmmsg: c_long = 357; +pub const SYS_sendmmsg: c_long = 358; +pub const SYS_socket: c_long = 359; +pub const SYS_socketpair: c_long = 360; +pub const SYS_bind: c_long = 361; +pub const SYS_connect: c_long = 362; +pub const SYS_listen: c_long = 363; +pub const SYS_accept4: c_long = 364; +pub const SYS_getsockopt: c_long = 365; +pub const SYS_setsockopt: c_long = 366; +pub const SYS_getsockname: c_long = 367; +pub const SYS_getpeername: c_long = 368; +pub const SYS_sendto: c_long = 369; +pub const SYS_sendmsg: c_long = 370; +pub const SYS_recvfrom: c_long = 371; +pub const SYS_recvmsg: c_long = 372; +pub const SYS_shutdown: c_long = 373; +pub const SYS_mlock2: c_long = 374; +pub const SYS_copy_file_range: c_long = 375; +pub const SYS_preadv2: c_long = 376; +pub const SYS_pwritev2: c_long = 377; +pub const SYS_s390_guarded_storage: c_long = 378; +pub const SYS_statx: c_long = 379; +pub const SYS_s390_sthyi: c_long = 380; +pub const SYS_kexec_file_load: c_long = 381; +pub const SYS_io_pgetevents: c_long = 382; +pub const SYS_rseq: c_long = 383; +pub const SYS_pkey_mprotect: c_long = 384; +pub const SYS_pkey_alloc: c_long = 385; +pub const SYS_pkey_free: c_long = 386; +pub const SYS_semtimedop: c_long = 392; +pub const SYS_semget: c_long = 393; +pub const SYS_semctl: c_long = 394; +pub const SYS_shmget: c_long = 395; +pub const SYS_shmctl: c_long = 396; +pub const SYS_shmat: c_long = 397; +pub const SYS_shmdt: c_long = 398; +pub const SYS_msgget: c_long = 399; +pub const SYS_msgsnd: c_long = 400; +pub const SYS_msgrcv: c_long = 401; +pub const SYS_msgctl: c_long = 402; +pub const SYS_pidfd_send_signal: c_long = 424; +pub const SYS_io_uring_setup: c_long = 425; +pub const SYS_io_uring_enter: c_long = 426; +pub const SYS_io_uring_register: c_long = 427; +pub const SYS_open_tree: c_long = 428; +pub const SYS_move_mount: c_long = 429; +pub const SYS_fsopen: c_long = 430; +pub const SYS_fsconfig: c_long = 431; +pub const SYS_fsmount: c_long = 432; +pub const SYS_fspick: c_long = 433; +pub const SYS_pidfd_open: c_long = 434; +pub const SYS_clone3: c_long = 435; +pub const SYS_close_range: c_long = 436; +pub const SYS_openat2: c_long = 437; +pub const SYS_pidfd_getfd: c_long = 438; +pub const SYS_faccessat2: c_long = 439; +pub const SYS_process_madvise: c_long = 440; +pub const SYS_epoll_pwait2: c_long = 441; +pub const SYS_mount_setattr: c_long = 442; +pub const SYS_landlock_create_ruleset: c_long = 444; +pub const SYS_landlock_add_rule: c_long = 445; +pub const SYS_landlock_restrict_self: c_long = 446; +pub const SYS_memfd_secret: c_long = 447; +pub const SYS_process_mrelease: c_long = 448; +pub const SYS_futex_waitv: c_long = 449; +pub const SYS_set_mempolicy_home_node: c_long = 450; +pub const SYS_cachestat: c_long = 451; +pub const SYS_fchmodat2: c_long = 452; +pub const SYS_mseal: c_long = 462; diff --git a/http/vendor/libc/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs new file mode 100644 index 0000000..1a4d896 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/musl/b64/wasm32/mod.rs @@ -0,0 +1,666 @@ +//! Wasm32 definitions conforming to the WALI ABI. +//! The WALI ABI closely mirrors `x86_64` Linux and is thus implemented within the `b64` module as opposed to `b32` +use crate::off_t; +use crate::prelude::*; + +pub type wchar_t = i32; +pub type nlink_t = u64; +pub type blksize_t = c_long; +pub type __u64 = c_ulonglong; +pub type __s64 = c_longlong; + +pub type stat64 = stat; + +s! { + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_nlink: crate::nlink_t, + pub st_mode: crate::mode_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + __pad0: Padding, + pub st_rdev: crate::dev_t, + pub st_size: off_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + __unused: Padding<[c_long; 3]>, + } + + pub struct ipc_perm { + #[cfg(musl_v1_2_3)] + pub __key: crate::key_t, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "This field is incorrectly named and will be changed + to __key in a future release." + )] + pub __ipc_perm_key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: crate::mode_t, + pub __seq: c_int, + __unused1: Padding, + __unused2: Padding, + } +} + +// Syscall table +pub const SYS_read: c_long = 0; +pub const SYS_write: c_long = 1; +pub const SYS_open: c_long = 2; +pub const SYS_close: c_long = 3; +pub const SYS_stat: c_long = 4; +pub const SYS_fstat: c_long = 5; +pub const SYS_lstat: c_long = 6; +pub const SYS_poll: c_long = 7; +pub const SYS_lseek: c_long = 8; +pub const SYS_mmap: c_long = 9; +pub const SYS_mprotect: c_long = 10; +pub const SYS_munmap: c_long = 11; +pub const SYS_brk: c_long = 12; +pub const SYS_rt_sigaction: c_long = 13; +pub const SYS_rt_sigprocmask: c_long = 14; +pub const SYS_rt_sigreturn: c_long = 15; +pub const SYS_ioctl: c_long = 16; +pub const SYS_pread64: c_long = 17; +pub const SYS_pwrite64: c_long = 18; +pub const SYS_readv: c_long = 19; +pub const SYS_writev: c_long = 20; +pub const SYS_access: c_long = 21; +pub const SYS_pipe: c_long = 22; +pub const SYS_select: c_long = 23; +pub const SYS_sched_yield: c_long = 24; +pub const SYS_mremap: c_long = 25; +pub const SYS_msync: c_long = 26; +pub const SYS_mincore: c_long = 27; +pub const SYS_madvise: c_long = 28; +pub const SYS_shmget: c_long = 29; +pub const SYS_shmat: c_long = 30; +pub const SYS_shmctl: c_long = 31; +pub const SYS_dup: c_long = 32; +pub const SYS_dup2: c_long = 33; +pub const SYS_pause: c_long = 34; +pub const SYS_nanosleep: c_long = 35; +pub const SYS_getitimer: c_long = 36; +pub const SYS_alarm: c_long = 37; +pub const SYS_setitimer: c_long = 38; +pub const SYS_getpid: c_long = 39; +pub const SYS_sendfile: c_long = 40; +pub const SYS_socket: c_long = 41; +pub const SYS_connect: c_long = 42; +pub const SYS_accept: c_long = 43; +pub const SYS_sendto: c_long = 44; +pub const SYS_recvfrom: c_long = 45; +pub const SYS_sendmsg: c_long = 46; +pub const SYS_recvmsg: c_long = 47; +pub const SYS_shutdown: c_long = 48; +pub const SYS_bind: c_long = 49; +pub const SYS_listen: c_long = 50; +pub const SYS_getsockname: c_long = 51; +pub const SYS_getpeername: c_long = 52; +pub const SYS_socketpair: c_long = 53; +pub const SYS_setsockopt: c_long = 54; +pub const SYS_getsockopt: c_long = 55; +pub const SYS_clone: c_long = 56; +pub const SYS_fork: c_long = 57; +pub const SYS_vfork: c_long = 58; +pub const SYS_execve: c_long = 59; +pub const SYS_exit: c_long = 60; +pub const SYS_wait4: c_long = 61; +pub const SYS_kill: c_long = 62; +pub const SYS_uname: c_long = 63; +pub const SYS_semget: c_long = 64; +pub const SYS_semop: c_long = 65; +pub const SYS_semctl: c_long = 66; +pub const SYS_shmdt: c_long = 67; +pub const SYS_msgget: c_long = 68; +pub const SYS_msgsnd: c_long = 69; +pub const SYS_msgrcv: c_long = 70; +pub const SYS_msgctl: c_long = 71; +pub const SYS_fcntl: c_long = 72; +pub const SYS_flock: c_long = 73; +pub const SYS_fsync: c_long = 74; +pub const SYS_fdatasync: c_long = 75; +pub const SYS_truncate: c_long = 76; +pub const SYS_ftruncate: c_long = 77; +pub const SYS_getdents: c_long = 78; +pub const SYS_getcwd: c_long = 79; +pub const SYS_chdir: c_long = 80; +pub const SYS_fchdir: c_long = 81; +pub const SYS_rename: c_long = 82; +pub const SYS_mkdir: c_long = 83; +pub const SYS_rmdir: c_long = 84; +pub const SYS_creat: c_long = 85; +pub const SYS_link: c_long = 86; +pub const SYS_unlink: c_long = 87; +pub const SYS_symlink: c_long = 88; +pub const SYS_readlink: c_long = 89; +pub const SYS_chmod: c_long = 90; +pub const SYS_fchmod: c_long = 91; +pub const SYS_chown: c_long = 92; +pub const SYS_fchown: c_long = 93; +pub const SYS_lchown: c_long = 94; +pub const SYS_umask: c_long = 95; +pub const SYS_gettimeofday: c_long = 96; +pub const SYS_getrlimit: c_long = 97; +pub const SYS_getrusage: c_long = 98; +pub const SYS_sysinfo: c_long = 99; +pub const SYS_times: c_long = 100; +pub const SYS_ptrace: c_long = 101; +pub const SYS_getuid: c_long = 102; +pub const SYS_syslog: c_long = 103; +pub const SYS_getgid: c_long = 104; +pub const SYS_setuid: c_long = 105; +pub const SYS_setgid: c_long = 106; +pub const SYS_geteuid: c_long = 107; +pub const SYS_getegid: c_long = 108; +pub const SYS_setpgid: c_long = 109; +pub const SYS_getppid: c_long = 110; +pub const SYS_getpgrp: c_long = 111; +pub const SYS_setsid: c_long = 112; +pub const SYS_setreuid: c_long = 113; +pub const SYS_setregid: c_long = 114; +pub const SYS_getgroups: c_long = 115; +pub const SYS_setgroups: c_long = 116; +pub const SYS_setresuid: c_long = 117; +pub const SYS_getresuid: c_long = 118; +pub const SYS_setresgid: c_long = 119; +pub const SYS_getresgid: c_long = 120; +pub const SYS_getpgid: c_long = 121; +pub const SYS_setfsuid: c_long = 122; +pub const SYS_setfsgid: c_long = 123; +pub const SYS_getsid: c_long = 124; +pub const SYS_capget: c_long = 125; +pub const SYS_capset: c_long = 126; +pub const SYS_rt_sigpending: c_long = 127; +pub const SYS_rt_sigtimedwait: c_long = 128; +pub const SYS_rt_sigqueueinfo: c_long = 129; +pub const SYS_rt_sigsuspend: c_long = 130; +pub const SYS_sigaltstack: c_long = 131; +pub const SYS_utime: c_long = 132; +pub const SYS_mknod: c_long = 133; +pub const SYS_uselib: c_long = 134; +pub const SYS_personality: c_long = 135; +pub const SYS_ustat: c_long = 136; +pub const SYS_statfs: c_long = 137; +pub const SYS_fstatfs: c_long = 138; +pub const SYS_sysfs: c_long = 139; +pub const SYS_getpriority: c_long = 140; +pub const SYS_setpriority: c_long = 141; +pub const SYS_sched_setparam: c_long = 142; +pub const SYS_sched_getparam: c_long = 143; +pub const SYS_sched_setscheduler: c_long = 144; +pub const SYS_sched_getscheduler: c_long = 145; +pub const SYS_sched_get_priority_max: c_long = 146; +pub const SYS_sched_get_priority_min: c_long = 147; +pub const SYS_sched_rr_get_interval: c_long = 148; +pub const SYS_mlock: c_long = 149; +pub const SYS_munlock: c_long = 150; +pub const SYS_mlockall: c_long = 151; +pub const SYS_munlockall: c_long = 152; +pub const SYS_vhangup: c_long = 153; +pub const SYS_modify_ldt: c_long = 154; +pub const SYS_pivot_root: c_long = 155; +pub const SYS__sysctl: c_long = 156; +pub const SYS_prctl: c_long = 157; +pub const SYS_arch_prctl: c_long = 158; +pub const SYS_adjtimex: c_long = 159; +pub const SYS_setrlimit: c_long = 160; +pub const SYS_chroot: c_long = 161; +pub const SYS_sync: c_long = 162; +pub const SYS_acct: c_long = 163; +pub const SYS_settimeofday: c_long = 164; +pub const SYS_mount: c_long = 165; +pub const SYS_umount2: c_long = 166; +pub const SYS_swapon: c_long = 167; +pub const SYS_swapoff: c_long = 168; +pub const SYS_reboot: c_long = 169; +pub const SYS_sethostname: c_long = 170; +pub const SYS_setdomainname: c_long = 171; +pub const SYS_iopl: c_long = 172; +pub const SYS_ioperm: c_long = 173; +pub const SYS_create_module: c_long = 174; +pub const SYS_init_module: c_long = 175; +pub const SYS_delete_module: c_long = 176; +pub const SYS_get_kernel_syms: c_long = 177; +pub const SYS_query_module: c_long = 178; +pub const SYS_quotactl: c_long = 179; +pub const SYS_nfsservctl: c_long = 180; +pub const SYS_getpmsg: c_long = 181; +pub const SYS_putpmsg: c_long = 182; +pub const SYS_afs_syscall: c_long = 183; +pub const SYS_tuxcall: c_long = 184; +pub const SYS_security: c_long = 185; +pub const SYS_gettid: c_long = 186; +pub const SYS_readahead: c_long = 187; +pub const SYS_setxattr: c_long = 188; +pub const SYS_lsetxattr: c_long = 189; +pub const SYS_fsetxattr: c_long = 190; +pub const SYS_getxattr: c_long = 191; +pub const SYS_lgetxattr: c_long = 192; +pub const SYS_fgetxattr: c_long = 193; +pub const SYS_listxattr: c_long = 194; +pub const SYS_llistxattr: c_long = 195; +pub const SYS_flistxattr: c_long = 196; +pub const SYS_removexattr: c_long = 197; +pub const SYS_lremovexattr: c_long = 198; +pub const SYS_fremovexattr: c_long = 199; +pub const SYS_tkill: c_long = 200; +pub const SYS_time: c_long = 201; +pub const SYS_futex: c_long = 202; +pub const SYS_sched_setaffinity: c_long = 203; +pub const SYS_sched_getaffinity: c_long = 204; +pub const SYS_set_thread_area: c_long = 205; +pub const SYS_io_setup: c_long = 206; +pub const SYS_io_destroy: c_long = 207; +pub const SYS_io_getevents: c_long = 208; +pub const SYS_io_submit: c_long = 209; +pub const SYS_io_cancel: c_long = 210; +pub const SYS_get_thread_area: c_long = 211; +pub const SYS_lookup_dcookie: c_long = 212; +pub const SYS_epoll_create: c_long = 213; +pub const SYS_epoll_ctl_old: c_long = 214; +pub const SYS_epoll_wait_old: c_long = 215; +pub const SYS_remap_file_pages: c_long = 216; +pub const SYS_getdents64: c_long = 217; +pub const SYS_set_tid_address: c_long = 218; +pub const SYS_restart_syscall: c_long = 219; +pub const SYS_semtimedop: c_long = 220; +pub const SYS_fadvise64: c_long = 221; +pub const SYS_timer_create: c_long = 222; +pub const SYS_timer_settime: c_long = 223; +pub const SYS_timer_gettime: c_long = 224; +pub const SYS_timer_getoverrun: c_long = 225; +pub const SYS_timer_delete: c_long = 226; +pub const SYS_clock_settime: c_long = 227; +pub const SYS_clock_gettime: c_long = 228; +pub const SYS_clock_getres: c_long = 229; +pub const SYS_clock_nanosleep: c_long = 230; +pub const SYS_exit_group: c_long = 231; +pub const SYS_epoll_wait: c_long = 232; +pub const SYS_epoll_ctl: c_long = 233; +pub const SYS_tgkill: c_long = 234; +pub const SYS_utimes: c_long = 235; +pub const SYS_vserver: c_long = 236; +pub const SYS_mbind: c_long = 237; +pub const SYS_set_mempolicy: c_long = 238; +pub const SYS_get_mempolicy: c_long = 239; +pub const SYS_mq_open: c_long = 240; +pub const SYS_mq_unlink: c_long = 241; +pub const SYS_mq_timedsend: c_long = 242; +pub const SYS_mq_timedreceive: c_long = 243; +pub const SYS_mq_notify: c_long = 244; +pub const SYS_mq_getsetattr: c_long = 245; +pub const SYS_kexec_load: c_long = 246; +pub const SYS_waitid: c_long = 247; +pub const SYS_add_key: c_long = 248; +pub const SYS_request_key: c_long = 249; +pub const SYS_keyctl: c_long = 250; +pub const SYS_ioprio_set: c_long = 251; +pub const SYS_ioprio_get: c_long = 252; +pub const SYS_inotify_init: c_long = 253; +pub const SYS_inotify_add_watch: c_long = 254; +pub const SYS_inotify_rm_watch: c_long = 255; +pub const SYS_migrate_pages: c_long = 256; +pub const SYS_openat: c_long = 257; +pub const SYS_mkdirat: c_long = 258; +pub const SYS_mknodat: c_long = 259; +pub const SYS_fchownat: c_long = 260; +pub const SYS_futimesat: c_long = 261; +pub const SYS_newfstatat: c_long = 262; +pub const SYS_unlinkat: c_long = 263; +pub const SYS_renameat: c_long = 264; +pub const SYS_linkat: c_long = 265; +pub const SYS_symlinkat: c_long = 266; +pub const SYS_readlinkat: c_long = 267; +pub const SYS_fchmodat: c_long = 268; +pub const SYS_faccessat: c_long = 269; +pub const SYS_pselect6: c_long = 270; +pub const SYS_ppoll: c_long = 271; +pub const SYS_unshare: c_long = 272; +pub const SYS_set_robust_list: c_long = 273; +pub const SYS_get_robust_list: c_long = 274; +pub const SYS_splice: c_long = 275; +pub const SYS_tee: c_long = 276; +pub const SYS_sync_file_range: c_long = 277; +pub const SYS_vmsplice: c_long = 278; +pub const SYS_move_pages: c_long = 279; +pub const SYS_utimensat: c_long = 280; +pub const SYS_epoll_pwait: c_long = 281; +pub const SYS_signalfd: c_long = 282; +pub const SYS_timerfd_create: c_long = 283; +pub const SYS_eventfd: c_long = 284; +pub const SYS_fallocate: c_long = 285; +pub const SYS_timerfd_settime: c_long = 286; +pub const SYS_timerfd_gettime: c_long = 287; +pub const SYS_accept4: c_long = 288; +pub const SYS_signalfd4: c_long = 289; +pub const SYS_eventfd2: c_long = 290; +pub const SYS_epoll_create1: c_long = 291; +pub const SYS_dup3: c_long = 292; +pub const SYS_pipe2: c_long = 293; +pub const SYS_inotify_init1: c_long = 294; +pub const SYS_preadv: c_long = 295; +pub const SYS_pwritev: c_long = 296; +pub const SYS_rt_tgsigqueueinfo: c_long = 297; +pub const SYS_perf_event_open: c_long = 298; +pub const SYS_recvmmsg: c_long = 299; +pub const SYS_fanotify_init: c_long = 300; +pub const SYS_fanotify_mark: c_long = 301; +pub const SYS_prlimit64: c_long = 302; +pub const SYS_name_to_handle_at: c_long = 303; +pub const SYS_open_by_handle_at: c_long = 304; +pub const SYS_clock_adjtime: c_long = 305; +pub const SYS_syncfs: c_long = 306; +pub const SYS_sendmmsg: c_long = 307; +pub const SYS_setns: c_long = 308; +pub const SYS_getcpu: c_long = 309; +pub const SYS_process_vm_readv: c_long = 310; +pub const SYS_process_vm_writev: c_long = 311; +pub const SYS_kcmp: c_long = 312; +pub const SYS_finit_module: c_long = 313; +pub const SYS_sched_setattr: c_long = 314; +pub const SYS_sched_getattr: c_long = 315; +pub const SYS_renameat2: c_long = 316; +pub const SYS_seccomp: c_long = 317; +pub const SYS_getrandom: c_long = 318; +pub const SYS_memfd_create: c_long = 319; +pub const SYS_kexec_file_load: c_long = 320; +pub const SYS_bpf: c_long = 321; +pub const SYS_execveat: c_long = 322; +pub const SYS_userfaultfd: c_long = 323; +pub const SYS_membarrier: c_long = 324; +pub const SYS_mlock2: c_long = 325; +pub const SYS_copy_file_range: c_long = 326; +pub const SYS_preadv2: c_long = 327; +pub const SYS_pwritev2: c_long = 328; +pub const SYS_pkey_mprotect: c_long = 329; +pub const SYS_pkey_alloc: c_long = 330; +pub const SYS_pkey_free: c_long = 331; +pub const SYS_statx: c_long = 332; +pub const SYS_io_pgetevents: c_long = 333; +pub const SYS_rseq: c_long = 334; +pub const SYS_pidfd_send_signal: c_long = 424; +pub const SYS_io_uring_setup: c_long = 425; +pub const SYS_io_uring_enter: c_long = 426; +pub const SYS_io_uring_register: c_long = 427; +pub const SYS_open_tree: c_long = 428; +pub const SYS_move_mount: c_long = 429; +pub const SYS_fsopen: c_long = 430; +pub const SYS_fsconfig: c_long = 431; +pub const SYS_fsmount: c_long = 432; +pub const SYS_fspick: c_long = 433; +pub const SYS_pidfd_open: c_long = 434; +pub const SYS_clone3: c_long = 435; +pub const SYS_close_range: c_long = 436; +pub const SYS_openat2: c_long = 437; +pub const SYS_pidfd_getfd: c_long = 438; +pub const SYS_faccessat2: c_long = 439; +pub const SYS_process_madvise: c_long = 440; +pub const SYS_epoll_pwait2: c_long = 441; +pub const SYS_mount_setattr: c_long = 442; +pub const SYS_quotactl_fd: c_long = 443; +pub const SYS_landlock_create_ruleset: c_long = 444; +pub const SYS_landlock_add_rule: c_long = 445; +pub const SYS_landlock_restrict_self: c_long = 446; +pub const SYS_memfd_secret: c_long = 447; +pub const SYS_process_mrelease: c_long = 448; +pub const SYS_futex_waitv: c_long = 449; +pub const SYS_set_mempolicy_home_node: c_long = 450; + +// Syscall aliases for WALI +pub const SYS_fadvise: c_long = SYS_fadvise64; + +pub const MADV_SOFT_OFFLINE: c_int = 101; +pub const O_APPEND: c_int = 1024; +pub const O_DIRECT: c_int = 0x4000; +pub const O_DIRECTORY: c_int = 0x10000; +pub const O_LARGEFILE: c_int = 0; +pub const O_NOFOLLOW: c_int = 0x20000; +pub const O_CREAT: c_int = 64; +pub const O_EXCL: c_int = 128; +pub const O_NOCTTY: c_int = 256; +pub const O_NONBLOCK: c_int = 2048; +pub const O_SYNC: c_int = 1052672; +pub const O_RSYNC: c_int = 1052672; +pub const O_DSYNC: c_int = 4096; +pub const O_ASYNC: c_int = 0x2000; + +pub const PTRACE_SYSEMU: c_int = 31; +pub const PTRACE_SYSEMU_SINGLESTEP: c_int = 32; + +pub const SIGSTKSZ: size_t = 8192; +pub const MINSIGSTKSZ: size_t = 2048; + +pub const ENAMETOOLONG: c_int = 36; +pub const ENOLCK: c_int = 37; +pub const ENOSYS: c_int = 38; +pub const ENOTEMPTY: c_int = 39; +pub const ELOOP: c_int = 40; +pub const ENOMSG: c_int = 42; +pub const EIDRM: c_int = 43; +pub const ECHRNG: c_int = 44; +pub const EL2NSYNC: c_int = 45; +pub const EL3HLT: c_int = 46; +pub const EL3RST: c_int = 47; +pub const ELNRNG: c_int = 48; +pub const EUNATCH: c_int = 49; +pub const ENOCSI: c_int = 50; +pub const EL2HLT: c_int = 51; +pub const EBADE: c_int = 52; +pub const EBADR: c_int = 53; +pub const EXFULL: c_int = 54; +pub const ENOANO: c_int = 55; +pub const EBADRQC: c_int = 56; +pub const EBADSLT: c_int = 57; +pub const EMULTIHOP: c_int = 72; +pub const EBADMSG: c_int = 74; +pub const EOVERFLOW: c_int = 75; +pub const ENOTUNIQ: c_int = 76; +pub const EBADFD: c_int = 77; +pub const EREMCHG: c_int = 78; +pub const ELIBACC: c_int = 79; +pub const ELIBBAD: c_int = 80; +pub const ELIBSCN: c_int = 81; +pub const ELIBMAX: c_int = 82; +pub const ELIBEXEC: c_int = 83; +pub const EILSEQ: c_int = 84; +pub const ERESTART: c_int = 85; +pub const ESTRPIPE: c_int = 86; +pub const EUSERS: c_int = 87; +pub const ENOTSOCK: c_int = 88; +pub const EDESTADDRREQ: c_int = 89; +pub const EMSGSIZE: c_int = 90; +pub const EPROTOTYPE: c_int = 91; +pub const ENOPROTOOPT: c_int = 92; +pub const EPROTONOSUPPORT: c_int = 93; +pub const ESOCKTNOSUPPORT: c_int = 94; +pub const EOPNOTSUPP: c_int = 95; +pub const ENOTSUP: c_int = EOPNOTSUPP; +pub const EPFNOSUPPORT: c_int = 96; +pub const EAFNOSUPPORT: c_int = 97; +pub const EADDRINUSE: c_int = 98; +pub const EADDRNOTAVAIL: c_int = 99; +pub const ENETDOWN: c_int = 100; +pub const ENETUNREACH: c_int = 101; +pub const ENETRESET: c_int = 102; +pub const ECONNABORTED: c_int = 103; +pub const ECONNRESET: c_int = 104; +pub const ENOBUFS: c_int = 105; +pub const EISCONN: c_int = 106; +pub const ENOTCONN: c_int = 107; +pub const ESHUTDOWN: c_int = 108; +pub const ETOOMANYREFS: c_int = 109; +pub const ETIMEDOUT: c_int = 110; +pub const ECONNREFUSED: c_int = 111; +pub const EHOSTDOWN: c_int = 112; +pub const EHOSTUNREACH: c_int = 113; +pub const EALREADY: c_int = 114; +pub const EINPROGRESS: c_int = 115; +pub const ESTALE: c_int = 116; +pub const EUCLEAN: c_int = 117; +pub const ENOTNAM: c_int = 118; +pub const ENAVAIL: c_int = 119; +pub const EISNAM: c_int = 120; +pub const EREMOTEIO: c_int = 121; +pub const EDQUOT: c_int = 122; +pub const ENOMEDIUM: c_int = 123; +pub const EMEDIUMTYPE: c_int = 124; +pub const ECANCELED: c_int = 125; +pub const ENOKEY: c_int = 126; +pub const EKEYEXPIRED: c_int = 127; +pub const EKEYREVOKED: c_int = 128; +pub const EKEYREJECTED: c_int = 129; +pub const EOWNERDEAD: c_int = 130; +pub const ENOTRECOVERABLE: c_int = 131; +pub const ERFKILL: c_int = 132; +pub const EHWPOISON: c_int = 133; + +pub const SA_ONSTACK: c_int = 0x08000000; +pub const SA_SIGINFO: c_int = 0x00000004; +pub const SA_NOCLDWAIT: c_int = 0x00000002; + +pub const SIGCHLD: c_int = 17; +pub const SIGBUS: c_int = 7; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGUSR1: c_int = 10; +pub const SIGUSR2: c_int = 12; +pub const SIGCONT: c_int = 18; +pub const SIGSTOP: c_int = 19; +pub const SIGTSTP: c_int = 20; +pub const SIGURG: c_int = 23; +pub const SIGIO: c_int = 29; +pub const SIGSYS: c_int = 31; +pub const SIGSTKFLT: c_int = 16; +pub const SIGPOLL: c_int = 29; +pub const SIGPWR: c_int = 30; +pub const SIG_SETMASK: c_int = 2; +pub const SIG_BLOCK: c_int = 0x000000; +pub const SIG_UNBLOCK: c_int = 0x01; + +pub const F_GETLK: c_int = 5; +pub const F_GETOWN: c_int = 9; +pub const F_SETLK: c_int = 6; +pub const F_SETLKW: c_int = 7; +pub const F_SETOWN: c_int = 8; + +pub const VEOF: usize = 4; + +pub const POLLWRNORM: c_short = 0x100; +pub const POLLWRBAND: c_short = 0x200; + +pub const MAP_ANON: c_int = 0x0020; +pub const MAP_GROWSDOWN: c_int = 0x0100; +pub const MAP_DENYWRITE: c_int = 0x0800; +pub const MAP_EXECUTABLE: c_int = 0x01000; +pub const MAP_LOCKED: c_int = 0x02000; +pub const MAP_NORESERVE: c_int = 0x04000; +pub const MAP_POPULATE: c_int = 0x08000; +pub const MAP_NONBLOCK: c_int = 0x010000; +pub const MAP_STACK: c_int = 0x020000; +pub const MAP_HUGETLB: c_int = 0x040000; +pub const MAP_SYNC: c_int = 0x080000; + +pub const MCL_CURRENT: c_int = 0x0001; +pub const MCL_FUTURE: c_int = 0x0002; +pub const MCL_ONFAULT: c_int = 0x0004; +pub const CBAUD: crate::tcflag_t = 0o0010017; +pub const TAB1: c_int = 0x00000800; +pub const TAB2: c_int = 0x00001000; +pub const TAB3: c_int = 0x00001800; +pub const CR1: c_int = 0x00000200; +pub const CR2: c_int = 0x00000400; +pub const CR3: c_int = 0x00000600; +pub const FF1: c_int = 0x00008000; +pub const BS1: c_int = 0x00002000; +pub const VT1: c_int = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: crate::tcflag_t = 0x00000400; +pub const IXOFF: crate::tcflag_t = 0x00001000; +pub const ONLCR: crate::tcflag_t = 0x4; +pub const CSIZE: crate::tcflag_t = 0x00000030; +pub const CS6: crate::tcflag_t = 0x00000010; +pub const CS7: crate::tcflag_t = 0x00000020; +pub const CS8: crate::tcflag_t = 0x00000030; +pub const CSTOPB: crate::tcflag_t = 0x00000040; +pub const CREAD: crate::tcflag_t = 0x00000080; +pub const PARENB: crate::tcflag_t = 0x00000100; +pub const PARODD: crate::tcflag_t = 0x00000200; +pub const HUPCL: crate::tcflag_t = 0x00000400; +pub const CLOCAL: crate::tcflag_t = 0x00000800; +pub const ECHOKE: crate::tcflag_t = 0x00000800; +pub const ECHOE: crate::tcflag_t = 0x00000010; +pub const ECHOK: crate::tcflag_t = 0x00000020; +pub const ECHONL: crate::tcflag_t = 0x00000040; +pub const ECHOPRT: crate::tcflag_t = 0x00000400; +pub const ECHOCTL: crate::tcflag_t = 0x00000200; +pub const ISIG: crate::tcflag_t = 0x00000001; +pub const ICANON: crate::tcflag_t = 0x00000002; +pub const PENDIN: crate::tcflag_t = 0x00004000; +pub const NOFLSH: crate::tcflag_t = 0x00000080; +pub const CIBAUD: crate::tcflag_t = 0o02003600000; +pub const CBAUDEX: crate::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: crate::tcflag_t = 0o000002; +pub const NLDLY: crate::tcflag_t = 0o000400; +pub const CRDLY: crate::tcflag_t = 0o003000; +pub const TABDLY: crate::tcflag_t = 0o014000; +pub const BSDLY: crate::tcflag_t = 0o020000; +pub const FFDLY: crate::tcflag_t = 0o100000; +pub const VTDLY: crate::tcflag_t = 0o040000; +pub const XTABS: crate::tcflag_t = 0o014000; +pub const B57600: crate::speed_t = 0o010001; +pub const B115200: crate::speed_t = 0o010002; +pub const B230400: crate::speed_t = 0o010003; +pub const B460800: crate::speed_t = 0o010004; +pub const B500000: crate::speed_t = 0o010005; +pub const B576000: crate::speed_t = 0o010006; +pub const B921600: crate::speed_t = 0o010007; +pub const B1000000: crate::speed_t = 0o010010; +pub const B1152000: crate::speed_t = 0o010011; +pub const B1500000: crate::speed_t = 0o010012; +pub const B2000000: crate::speed_t = 0o010013; +pub const B2500000: crate::speed_t = 0o010014; +pub const B3000000: crate::speed_t = 0o010015; +pub const B3500000: crate::speed_t = 0o010016; +pub const B4000000: crate::speed_t = 0o010017; + +pub const EDEADLK: c_int = 35; +pub const EDEADLOCK: c_int = EDEADLK; + +pub const EXTPROC: crate::tcflag_t = 0x00010000; +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: crate::tcflag_t = 0x00008000; +pub const TOSTOP: crate::tcflag_t = 0x00000100; +pub const FLUSHO: crate::tcflag_t = 0x00001000; + +cfg_if! { + if #[cfg(all(target_family = "wasm", target_env = "musl"))] { + mod wali; + pub use self::wali::*; + } +} diff --git a/http/vendor/libc/src/unix/linux_like/linux/musl/b64/wasm32/wali.rs b/http/vendor/libc/src/unix/linux_like/linux/musl/b64/wasm32/wali.rs new file mode 100644 index 0000000..f347e8a --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/musl/b64/wasm32/wali.rs @@ -0,0 +1,441 @@ +//! WebAssembly Linux Interface syscall specification + +use crate::prelude::*; + +// --- Autogenerated from WALI/scripts/autogen.py --- +#[link(wasm_import_module = "wali")] +extern "C" { + /* 0 */ + #[link_name = "SYS_read"] + pub fn __syscall_SYS_read(a1: i32, a2: i32, a3: u32) -> c_long; + /* 1 */ + #[link_name = "SYS_write"] + pub fn __syscall_SYS_write(a1: i32, a2: i32, a3: u32) -> c_long; + /* 2 */ + #[link_name = "SYS_open"] + pub fn __syscall_SYS_open(a1: i32, a2: i32, a3: i32) -> c_long; + /* 3 */ + #[link_name = "SYS_close"] + pub fn __syscall_SYS_close(a1: i32) -> c_long; + /* 4 */ + #[link_name = "SYS_stat"] + pub fn __syscall_SYS_stat(a1: i32, a2: i32) -> c_long; + /* 5 */ + #[link_name = "SYS_fstat"] + pub fn __syscall_SYS_fstat(a1: i32, a2: i32) -> c_long; + /* 6 */ + #[link_name = "SYS_lstat"] + pub fn __syscall_SYS_lstat(a1: i32, a2: i32) -> c_long; + /* 7 */ + #[link_name = "SYS_poll"] + pub fn __syscall_SYS_poll(a1: i32, a2: u32, a3: i32) -> c_long; + /* 8 */ + #[link_name = "SYS_lseek"] + pub fn __syscall_SYS_lseek(a1: i32, a2: i64, a3: i32) -> c_long; + /* 9 */ + #[link_name = "SYS_mmap"] + pub fn __syscall_SYS_mmap(a1: i32, a2: u32, a3: i32, a4: i32, a5: i32, a6: i64) -> c_long; + /* 10 */ + #[link_name = "SYS_mprotect"] + pub fn __syscall_SYS_mprotect(a1: i32, a2: u32, a3: i32) -> c_long; + /* 11 */ + #[link_name = "SYS_munmap"] + pub fn __syscall_SYS_munmap(a1: i32, a2: u32) -> c_long; + /* 12 */ + #[link_name = "SYS_brk"] + pub fn __syscall_SYS_brk(a1: i32) -> c_long; + /* 13 */ + #[link_name = "SYS_rt_sigaction"] + pub fn __syscall_SYS_rt_sigaction(a1: i32, a2: i32, a3: i32, a4: u32) -> c_long; + /* 14 */ + #[link_name = "SYS_rt_sigprocmask"] + pub fn __syscall_SYS_rt_sigprocmask(a1: i32, a2: i32, a3: i32, a4: u32) -> c_long; + /* 15 */ + #[link_name = "SYS_rt_sigreturn"] + pub fn __syscall_SYS_rt_sigreturn(a1: i64) -> c_long; + /* 16 */ + #[link_name = "SYS_ioctl"] + pub fn __syscall_SYS_ioctl(a1: i32, a2: i32, a3: i32) -> c_long; + /* 17 */ + #[link_name = "SYS_pread64"] + pub fn __syscall_SYS_pread64(a1: i32, a2: i32, a3: u32, a4: i64) -> c_long; + /* 18 */ + #[link_name = "SYS_pwrite64"] + pub fn __syscall_SYS_pwrite64(a1: i32, a2: i32, a3: u32, a4: i64) -> c_long; + /* 19 */ + #[link_name = "SYS_readv"] + pub fn __syscall_SYS_readv(a1: i32, a2: i32, a3: i32) -> c_long; + /* 20 */ + #[link_name = "SYS_writev"] + pub fn __syscall_SYS_writev(a1: i32, a2: i32, a3: i32) -> c_long; + /* 21 */ + #[link_name = "SYS_access"] + pub fn __syscall_SYS_access(a1: i32, a2: i32) -> c_long; + /* 22 */ + #[link_name = "SYS_pipe"] + pub fn __syscall_SYS_pipe(a1: i32) -> c_long; + /* 23 */ + #[link_name = "SYS_select"] + pub fn __syscall_SYS_select(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> c_long; + /* 24 */ + #[link_name = "SYS_sched_yield"] + pub fn __syscall_SYS_sched_yield() -> c_long; + /* 25 */ + #[link_name = "SYS_mremap"] + pub fn __syscall_SYS_mremap(a1: i32, a2: u32, a3: u32, a4: i32, a5: i32) -> c_long; + /* 26 */ + #[link_name = "SYS_msync"] + pub fn __syscall_SYS_msync(a1: i32, a2: u32, a3: i32) -> c_long; + /* 28 */ + #[link_name = "SYS_madvise"] + pub fn __syscall_SYS_madvise(a1: i32, a2: u32, a3: i32) -> c_long; + /* 32 */ + #[link_name = "SYS_dup"] + pub fn __syscall_SYS_dup(a1: i32) -> c_long; + /* 33 */ + #[link_name = "SYS_dup2"] + pub fn __syscall_SYS_dup2(a1: i32, a2: i32) -> c_long; + /* 35 */ + #[link_name = "SYS_nanosleep"] + pub fn __syscall_SYS_nanosleep(a1: i32, a2: i32) -> c_long; + /* 37 */ + #[link_name = "SYS_alarm"] + pub fn __syscall_SYS_alarm(a1: i32) -> c_long; + /* 38 */ + #[link_name = "SYS_setitimer"] + pub fn __syscall_SYS_setitimer(a1: i32, a2: i32, a3: i32) -> c_long; + /* 39 */ + #[link_name = "SYS_getpid"] + pub fn __syscall_SYS_getpid() -> c_long; + /* 41 */ + #[link_name = "SYS_socket"] + pub fn __syscall_SYS_socket(a1: i32, a2: i32, a3: i32) -> c_long; + /* 42 */ + #[link_name = "SYS_connect"] + pub fn __syscall_SYS_connect(a1: i32, a2: i32, a3: u32) -> c_long; + /* 43 */ + #[link_name = "SYS_accept"] + pub fn __syscall_SYS_accept(a1: i32, a2: i32, a3: i32) -> c_long; + /* 44 */ + #[link_name = "SYS_sendto"] + pub fn __syscall_SYS_sendto(a1: i32, a2: i32, a3: u32, a4: i32, a5: i32, a6: u32) -> c_long; + /* 45 */ + #[link_name = "SYS_recvfrom"] + pub fn __syscall_SYS_recvfrom(a1: i32, a2: i32, a3: u32, a4: i32, a5: i32, a6: i32) -> c_long; + /* 46 */ + #[link_name = "SYS_sendmsg"] + pub fn __syscall_SYS_sendmsg(a1: i32, a2: i32, a3: i32) -> c_long; + /* 47 */ + #[link_name = "SYS_recvmsg"] + pub fn __syscall_SYS_recvmsg(a1: i32, a2: i32, a3: i32) -> c_long; + /* 48 */ + #[link_name = "SYS_shutdown"] + pub fn __syscall_SYS_shutdown(a1: i32, a2: i32) -> c_long; + /* 49 */ + #[link_name = "SYS_bind"] + pub fn __syscall_SYS_bind(a1: i32, a2: i32, a3: u32) -> c_long; + /* 50 */ + #[link_name = "SYS_listen"] + pub fn __syscall_SYS_listen(a1: i32, a2: i32) -> c_long; + /* 51 */ + #[link_name = "SYS_getsockname"] + pub fn __syscall_SYS_getsockname(a1: i32, a2: i32, a3: i32) -> c_long; + /* 52 */ + #[link_name = "SYS_getpeername"] + pub fn __syscall_SYS_getpeername(a1: i32, a2: i32, a3: i32) -> c_long; + /* 53 */ + #[link_name = "SYS_socketpair"] + pub fn __syscall_SYS_socketpair(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; + /* 54 */ + #[link_name = "SYS_setsockopt"] + pub fn __syscall_SYS_setsockopt(a1: i32, a2: i32, a3: i32, a4: i32, a5: u32) -> c_long; + /* 55 */ + #[link_name = "SYS_getsockopt"] + pub fn __syscall_SYS_getsockopt(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> c_long; + /* 57 */ + #[link_name = "SYS_fork"] + pub fn __syscall_SYS_fork() -> c_long; + /* 59 */ + #[link_name = "SYS_execve"] + pub fn __syscall_SYS_execve(a1: i32, a2: i32, a3: i32) -> c_long; + /* 60 */ + #[link_name = "SYS_exit"] + pub fn __syscall_SYS_exit(a1: i32) -> c_long; + /* 61 */ + #[link_name = "SYS_wait4"] + pub fn __syscall_SYS_wait4(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; + /* 62 */ + #[link_name = "SYS_kill"] + pub fn __syscall_SYS_kill(a1: i32, a2: i32) -> c_long; + /* 63 */ + #[link_name = "SYS_uname"] + pub fn __syscall_SYS_uname(a1: i32) -> c_long; + /* 72 */ + #[link_name = "SYS_fcntl"] + pub fn __syscall_SYS_fcntl(a1: i32, a2: i32, a3: i32) -> c_long; + /* 73 */ + #[link_name = "SYS_flock"] + pub fn __syscall_SYS_flock(a1: i32, a2: i32) -> c_long; + /* 74 */ + #[link_name = "SYS_fsync"] + pub fn __syscall_SYS_fsync(a1: i32) -> c_long; + /* 75 */ + #[link_name = "SYS_fdatasync"] + pub fn __syscall_SYS_fdatasync(a1: i32) -> c_long; + /* 77 */ + #[link_name = "SYS_ftruncate"] + pub fn __syscall_SYS_ftruncate(a1: i32, a2: i64) -> c_long; + /* 78 */ + #[link_name = "SYS_getdents"] + pub fn __syscall_SYS_getdents(a1: i32, a2: i32, a3: i32) -> c_long; + /* 79 */ + #[link_name = "SYS_getcwd"] + pub fn __syscall_SYS_getcwd(a1: i32, a2: u32) -> c_long; + /* 80 */ + #[link_name = "SYS_chdir"] + pub fn __syscall_SYS_chdir(a1: i32) -> c_long; + /* 81 */ + #[link_name = "SYS_fchdir"] + pub fn __syscall_SYS_fchdir(a1: i32) -> c_long; + /* 82 */ + #[link_name = "SYS_rename"] + pub fn __syscall_SYS_rename(a1: i32, a2: i32) -> c_long; + /* 83 */ + #[link_name = "SYS_mkdir"] + pub fn __syscall_SYS_mkdir(a1: i32, a2: i32) -> c_long; + /* 84 */ + #[link_name = "SYS_rmdir"] + pub fn __syscall_SYS_rmdir(a1: i32) -> c_long; + /* 86 */ + #[link_name = "SYS_link"] + pub fn __syscall_SYS_link(a1: i32, a2: i32) -> c_long; + /* 87 */ + #[link_name = "SYS_unlink"] + pub fn __syscall_SYS_unlink(a1: i32) -> c_long; + /* 88 */ + #[link_name = "SYS_symlink"] + pub fn __syscall_SYS_symlink(a1: i32, a2: i32) -> c_long; + /* 89 */ + #[link_name = "SYS_readlink"] + pub fn __syscall_SYS_readlink(a1: i32, a2: i32, a3: u32) -> c_long; + /* 90 */ + #[link_name = "SYS_chmod"] + pub fn __syscall_SYS_chmod(a1: i32, a2: i32) -> c_long; + /* 91 */ + #[link_name = "SYS_fchmod"] + pub fn __syscall_SYS_fchmod(a1: i32, a2: i32) -> c_long; + /* 92 */ + #[link_name = "SYS_chown"] + pub fn __syscall_SYS_chown(a1: i32, a2: i32, a3: i32) -> c_long; + /* 93 */ + #[link_name = "SYS_fchown"] + pub fn __syscall_SYS_fchown(a1: i32, a2: i32, a3: i32) -> c_long; + /* 95 */ + #[link_name = "SYS_umask"] + pub fn __syscall_SYS_umask(a1: i32) -> c_long; + /* 97 */ + #[link_name = "SYS_getrlimit"] + pub fn __syscall_SYS_getrlimit(a1: i32, a2: i32) -> c_long; + /* 98 */ + #[link_name = "SYS_getrusage"] + pub fn __syscall_SYS_getrusage(a1: i32, a2: i32) -> c_long; + /* 99 */ + #[link_name = "SYS_sysinfo"] + pub fn __syscall_SYS_sysinfo(a1: i32) -> c_long; + /* 102 */ + #[link_name = "SYS_getuid"] + pub fn __syscall_SYS_getuid() -> c_long; + /* 104 */ + #[link_name = "SYS_getgid"] + pub fn __syscall_SYS_getgid() -> c_long; + /* 105 */ + #[link_name = "SYS_setuid"] + pub fn __syscall_SYS_setuid(a1: i32) -> c_long; + /* 106 */ + #[link_name = "SYS_setgid"] + pub fn __syscall_SYS_setgid(a1: i32) -> c_long; + /* 107 */ + #[link_name = "SYS_geteuid"] + pub fn __syscall_SYS_geteuid() -> c_long; + /* 108 */ + #[link_name = "SYS_getegid"] + pub fn __syscall_SYS_getegid() -> c_long; + /* 109 */ + #[link_name = "SYS_setpgid"] + pub fn __syscall_SYS_setpgid(a1: i32, a2: i32) -> c_long; + /* 110 */ + #[link_name = "SYS_getppid"] + pub fn __syscall_SYS_getppid() -> c_long; + /* 112 */ + #[link_name = "SYS_setsid"] + pub fn __syscall_SYS_setsid() -> c_long; + /* 113 */ + #[link_name = "SYS_setreuid"] + pub fn __syscall_SYS_setreuid(a1: i32, a2: i32) -> c_long; + /* 114 */ + #[link_name = "SYS_setregid"] + pub fn __syscall_SYS_setregid(a1: i32, a2: i32) -> c_long; + /* 115 */ + #[link_name = "SYS_getgroups"] + pub fn __syscall_SYS_getgroups(a1: u32, a2: i32) -> c_long; + /* 116 */ + #[link_name = "SYS_setgroups"] + pub fn __syscall_SYS_setgroups(a1: u32, a2: i32) -> c_long; + /* 117 */ + #[link_name = "SYS_setresuid"] + pub fn __syscall_SYS_setresuid(a1: i32, a2: i32, a3: i32) -> c_long; + /* 119 */ + #[link_name = "SYS_setresgid"] + pub fn __syscall_SYS_setresgid(a1: i32, a2: i32, a3: i32) -> c_long; + /* 121 */ + #[link_name = "SYS_getpgid"] + pub fn __syscall_SYS_getpgid(a1: i32) -> c_long; + /* 124 */ + #[link_name = "SYS_getsid"] + pub fn __syscall_SYS_getsid(a1: i32) -> c_long; + /* 127 */ + #[link_name = "SYS_rt_sigpending"] + pub fn __syscall_SYS_rt_sigpending(a1: i32, a2: u32) -> c_long; + /* 130 */ + #[link_name = "SYS_rt_sigsuspend"] + pub fn __syscall_SYS_rt_sigsuspend(a1: i32, a2: u32) -> c_long; + /* 131 */ + #[link_name = "SYS_sigaltstack"] + pub fn __syscall_SYS_sigaltstack(a1: i32, a2: i32) -> c_long; + /* 132 */ + #[link_name = "SYS_utime"] + pub fn __syscall_SYS_utime(a1: i32, a2: i32) -> c_long; + /* 137 */ + #[link_name = "SYS_statfs"] + pub fn __syscall_SYS_statfs(a1: i32, a2: i32) -> c_long; + /* 138 */ + #[link_name = "SYS_fstatfs"] + pub fn __syscall_SYS_fstatfs(a1: i32, a2: i32) -> c_long; + /* 157 */ + #[link_name = "SYS_prctl"] + pub fn __syscall_SYS_prctl(a1: i32, a2: u64, a3: u64, a4: u64, a5: u64) -> c_long; + /* 160 */ + #[link_name = "SYS_setrlimit"] + pub fn __syscall_SYS_setrlimit(a1: i32, a2: i32) -> c_long; + /* 161 */ + #[link_name = "SYS_chroot"] + pub fn __syscall_SYS_chroot(a1: i32) -> c_long; + /* 186 */ + #[link_name = "SYS_gettid"] + pub fn __syscall_SYS_gettid() -> c_long; + /* 200 */ + #[link_name = "SYS_tkill"] + pub fn __syscall_SYS_tkill(a1: i32, a2: i32) -> c_long; + /* 202 */ + #[link_name = "SYS_futex"] + pub fn __syscall_SYS_futex(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32, a6: i32) -> c_long; + /* 204 */ + #[link_name = "SYS_sched_getaffinity"] + pub fn __syscall_SYS_sched_getaffinity(a1: i32, a2: u32, a3: i32) -> c_long; + /* 217 */ + #[link_name = "SYS_getdents64"] + pub fn __syscall_SYS_getdents64(a1: i32, a2: i32, a3: i32) -> c_long; + /* 218 */ + #[link_name = "SYS_set_tid_address"] + pub fn __syscall_SYS_set_tid_address(a1: i32) -> c_long; + /* 221 */ + #[link_name = "SYS_fadvise"] + pub fn __syscall_SYS_fadvise(a1: i32, a2: i64, a3: i64, a4: i32) -> c_long; + /* 228 */ + #[link_name = "SYS_clock_gettime"] + pub fn __syscall_SYS_clock_gettime(a1: i32, a2: i32) -> c_long; + /* 229 */ + #[link_name = "SYS_clock_getres"] + pub fn __syscall_SYS_clock_getres(a1: i32, a2: i32) -> c_long; + /* 230 */ + #[link_name = "SYS_clock_nanosleep"] + pub fn __syscall_SYS_clock_nanosleep(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; + /* 231 */ + #[link_name = "SYS_exit_group"] + pub fn __syscall_SYS_exit_group(a1: i32) -> c_long; + /* 233 */ + #[link_name = "SYS_epoll_ctl"] + pub fn __syscall_SYS_epoll_ctl(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; + /* 257 */ + #[link_name = "SYS_openat"] + pub fn __syscall_SYS_openat(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; + /* 258 */ + #[link_name = "SYS_mkdirat"] + pub fn __syscall_SYS_mkdirat(a1: i32, a2: i32, a3: i32) -> c_long; + /* 260 */ + #[link_name = "SYS_fchownat"] + pub fn __syscall_SYS_fchownat(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> c_long; + /* 262 */ + #[link_name = "SYS_fstatat"] + pub fn __syscall_SYS_fstatat(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; + /* 263 */ + #[link_name = "SYS_unlinkat"] + pub fn __syscall_SYS_unlinkat(a1: i32, a2: i32, a3: i32) -> c_long; + /* 265 */ + #[link_name = "SYS_linkat"] + pub fn __syscall_SYS_linkat(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> c_long; + /* 266 */ + #[link_name = "SYS_symlinkat"] + pub fn __syscall_SYS_symlinkat(a1: i32, a2: i32, a3: i32) -> c_long; + /* 267 */ + #[link_name = "SYS_readlinkat"] + pub fn __syscall_SYS_readlinkat(a1: i32, a2: i32, a3: i32, a4: u32) -> c_long; + /* 268 */ + #[link_name = "SYS_fchmodat"] + pub fn __syscall_SYS_fchmodat(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; + /* 269 */ + #[link_name = "SYS_faccessat"] + pub fn __syscall_SYS_faccessat(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; + /* 270 */ + #[link_name = "SYS_pselect6"] + pub fn __syscall_SYS_pselect6(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32, a6: i32) -> c_long; + /* 271 */ + #[link_name = "SYS_ppoll"] + pub fn __syscall_SYS_ppoll(a1: i32, a2: u32, a3: i32, a4: i32, a5: u32) -> c_long; + /* 280 */ + #[link_name = "SYS_utimensat"] + pub fn __syscall_SYS_utimensat(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; + /* 281 */ + #[link_name = "SYS_epoll_pwait"] + pub fn __syscall_SYS_epoll_pwait( + a1: i32, + a2: i32, + a3: i32, + a4: i32, + a5: i32, + a6: u32, + ) -> c_long; + /* 284 */ + #[link_name = "SYS_eventfd"] + pub fn __syscall_SYS_eventfd(a1: i32) -> c_long; + /* 288 */ + #[link_name = "SYS_accept4"] + pub fn __syscall_SYS_accept4(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; + /* 290 */ + #[link_name = "SYS_eventfd2"] + pub fn __syscall_SYS_eventfd2(a1: i32, a2: i32) -> c_long; + /* 291 */ + #[link_name = "SYS_epoll_create1"] + pub fn __syscall_SYS_epoll_create1(a1: i32) -> c_long; + /* 292 */ + #[link_name = "SYS_dup3"] + pub fn __syscall_SYS_dup3(a1: i32, a2: i32, a3: i32) -> c_long; + /* 293 */ + #[link_name = "SYS_pipe2"] + pub fn __syscall_SYS_pipe2(a1: i32, a2: i32) -> c_long; + /* 302 */ + #[link_name = "SYS_prlimit64"] + pub fn __syscall_SYS_prlimit64(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; + /* 316 */ + #[link_name = "SYS_renameat2"] + pub fn __syscall_SYS_renameat2(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> c_long; + /* 318 */ + #[link_name = "SYS_getrandom"] + pub fn __syscall_SYS_getrandom(a1: i32, a2: u32, a3: i32) -> c_long; + /* 332 */ + #[link_name = "SYS_statx"] + pub fn __syscall_SYS_statx(a1: i32, a2: i32, a3: i32, a4: i32, a5: i32) -> c_long; + /* 439 */ + #[link_name = "SYS_faccessat2"] + pub fn __syscall_SYS_faccessat2(a1: i32, a2: i32, a3: i32, a4: i32) -> c_long; +} diff --git a/http/vendor/libc/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs new file mode 100644 index 0000000..39daf54 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs @@ -0,0 +1,833 @@ +use crate::off_t; +use crate::prelude::*; + +pub type wchar_t = i32; +pub type nlink_t = u64; +pub type blksize_t = c_long; +pub type __u64 = c_ulonglong; +pub type __s64 = c_longlong; +pub type greg_t = i64; + +pub type stat64 = stat; + +s! { + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_nlink: crate::nlink_t, + pub st_mode: crate::mode_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + __pad0: Padding, + pub st_rdev: crate::dev_t, + pub st_size: off_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + #[cfg(all(musl32_time64, target_pointer_width = "32"))] + pub st_atime_nsec: i64, + #[cfg(not(all(musl32_time64, target_pointer_width = "32")))] + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + #[cfg(all(musl32_time64, target_pointer_width = "32"))] + pub st_mtime_nsec: i64, + #[cfg(not(all(musl32_time64, target_pointer_width = "32")))] + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + #[cfg(all(musl32_time64, target_pointer_width = "32"))] + pub st_ctime_nsec: i64, + #[cfg(not(all(musl32_time64, target_pointer_width = "32")))] + pub st_ctime_nsec: c_long, + __unused: Padding<[c_long; 3]>, + } + + pub struct user_regs_struct { + pub r15: c_ulong, + pub r14: c_ulong, + pub r13: c_ulong, + pub r12: c_ulong, + pub rbp: c_ulong, + pub rbx: c_ulong, + pub r11: c_ulong, + pub r10: c_ulong, + pub r9: c_ulong, + pub r8: c_ulong, + pub rax: c_ulong, + pub rcx: c_ulong, + pub rdx: c_ulong, + pub rsi: c_ulong, + pub rdi: c_ulong, + pub orig_rax: c_ulong, + pub rip: c_ulong, + pub cs: c_ulong, + pub eflags: c_ulong, + pub rsp: c_ulong, + pub ss: c_ulong, + pub fs_base: c_ulong, + pub gs_base: c_ulong, + pub ds: c_ulong, + pub es: c_ulong, + pub fs: c_ulong, + pub gs: c_ulong, + } + + pub struct user { + pub regs: user_regs_struct, + pub u_fpvalid: c_int, + pub i387: user_fpregs_struct, + pub u_tsize: c_ulong, + pub u_dsize: c_ulong, + pub u_ssize: c_ulong, + pub start_code: c_ulong, + pub start_stack: c_ulong, + pub signal: c_long, + __reserved: Padding, + #[cfg(target_pointer_width = "32")] + __pad1: Padding, + pub u_ar0: *mut user_regs_struct, + #[cfg(target_pointer_width = "32")] + __pad2: Padding, + pub u_fpstate: *mut user_fpregs_struct, + pub magic: c_ulong, + pub u_comm: [c_char; 32], + pub u_debugreg: [c_ulong; 8], + } + + // GitHub repo: ifduyue/musl/ + // commit: b4b1e10364c8737a632be61582e05a8d3acf5690 + // file: arch/x86_64/bits/signal.h#L80-L84 + pub struct mcontext_t { + pub gregs: [greg_t; 23], + __private: [u64; 9], + } + + pub struct ipc_perm { + #[cfg(musl_v1_2_3)] + pub __key: crate::key_t, + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "This field is incorrectly named and will be changed + to __key in a future release." + )] + pub __ipc_perm_key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: crate::mode_t, + pub __seq: c_int, + __unused1: Padding, + __unused2: Padding, + } + + #[repr(align(8))] + pub struct clone_args { + pub flags: c_ulonglong, + pub pidfd: c_ulonglong, + pub child_tid: c_ulonglong, + pub parent_tid: c_ulonglong, + pub exit_signal: c_ulonglong, + pub stack: c_ulonglong, + pub stack_size: c_ulonglong, + pub tls: c_ulonglong, + pub set_tid: c_ulonglong, + pub set_tid_size: c_ulonglong, + pub cgroup: c_ulonglong, + } + + pub struct user_fpregs_struct { + pub cwd: c_ushort, + pub swd: c_ushort, + pub ftw: c_ushort, + pub fop: c_ushort, + pub rip: c_ulong, + pub rdp: c_ulong, + pub mxcsr: c_uint, + pub mxcr_mask: c_uint, + pub st_space: [c_uint; 32], + pub xmm_space: [c_uint; 64], + padding: Padding<[c_uint; 24]>, + } + + pub struct ucontext_t { + pub uc_flags: c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: crate::stack_t, + pub uc_mcontext: mcontext_t, + pub uc_sigmask: crate::sigset_t, + __private: [u8; 512], + } +} + +s_no_extra_traits! { + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 4], + } +} + +// Syscall table + +pub const SYS_read: c_long = 0; +pub const SYS_write: c_long = 1; +pub const SYS_open: c_long = 2; +pub const SYS_close: c_long = 3; +pub const SYS_stat: c_long = 4; +pub const SYS_fstat: c_long = 5; +pub const SYS_lstat: c_long = 6; +pub const SYS_poll: c_long = 7; +pub const SYS_lseek: c_long = 8; +pub const SYS_mmap: c_long = 9; +pub const SYS_mprotect: c_long = 10; +pub const SYS_munmap: c_long = 11; +pub const SYS_brk: c_long = 12; +pub const SYS_rt_sigaction: c_long = 13; +pub const SYS_rt_sigprocmask: c_long = 14; +pub const SYS_rt_sigreturn: c_long = 15; +pub const SYS_ioctl: c_long = 16; +pub const SYS_pread64: c_long = 17; +pub const SYS_pwrite64: c_long = 18; +pub const SYS_readv: c_long = 19; +pub const SYS_writev: c_long = 20; +pub const SYS_access: c_long = 21; +pub const SYS_pipe: c_long = 22; +pub const SYS_select: c_long = 23; +pub const SYS_sched_yield: c_long = 24; +pub const SYS_mremap: c_long = 25; +pub const SYS_msync: c_long = 26; +pub const SYS_mincore: c_long = 27; +pub const SYS_madvise: c_long = 28; +pub const SYS_shmget: c_long = 29; +pub const SYS_shmat: c_long = 30; +pub const SYS_shmctl: c_long = 31; +pub const SYS_dup: c_long = 32; +pub const SYS_dup2: c_long = 33; +pub const SYS_pause: c_long = 34; +pub const SYS_nanosleep: c_long = 35; +pub const SYS_getitimer: c_long = 36; +pub const SYS_alarm: c_long = 37; +pub const SYS_setitimer: c_long = 38; +pub const SYS_getpid: c_long = 39; +pub const SYS_sendfile: c_long = 40; +pub const SYS_socket: c_long = 41; +pub const SYS_connect: c_long = 42; +pub const SYS_accept: c_long = 43; +pub const SYS_sendto: c_long = 44; +pub const SYS_recvfrom: c_long = 45; +pub const SYS_sendmsg: c_long = 46; +pub const SYS_recvmsg: c_long = 47; +pub const SYS_shutdown: c_long = 48; +pub const SYS_bind: c_long = 49; +pub const SYS_listen: c_long = 50; +pub const SYS_getsockname: c_long = 51; +pub const SYS_getpeername: c_long = 52; +pub const SYS_socketpair: c_long = 53; +pub const SYS_setsockopt: c_long = 54; +pub const SYS_getsockopt: c_long = 55; +pub const SYS_clone: c_long = 56; +pub const SYS_fork: c_long = 57; +pub const SYS_vfork: c_long = 58; +pub const SYS_execve: c_long = 59; +pub const SYS_exit: c_long = 60; +pub const SYS_wait4: c_long = 61; +pub const SYS_kill: c_long = 62; +pub const SYS_uname: c_long = 63; +pub const SYS_semget: c_long = 64; +pub const SYS_semop: c_long = 65; +pub const SYS_semctl: c_long = 66; +pub const SYS_shmdt: c_long = 67; +pub const SYS_msgget: c_long = 68; +pub const SYS_msgsnd: c_long = 69; +pub const SYS_msgrcv: c_long = 70; +pub const SYS_msgctl: c_long = 71; +pub const SYS_fcntl: c_long = 72; +pub const SYS_flock: c_long = 73; +pub const SYS_fsync: c_long = 74; +pub const SYS_fdatasync: c_long = 75; +pub const SYS_truncate: c_long = 76; +pub const SYS_ftruncate: c_long = 77; +pub const SYS_getdents: c_long = 78; +pub const SYS_getcwd: c_long = 79; +pub const SYS_chdir: c_long = 80; +pub const SYS_fchdir: c_long = 81; +pub const SYS_rename: c_long = 82; +pub const SYS_mkdir: c_long = 83; +pub const SYS_rmdir: c_long = 84; +pub const SYS_creat: c_long = 85; +pub const SYS_link: c_long = 86; +pub const SYS_unlink: c_long = 87; +pub const SYS_symlink: c_long = 88; +pub const SYS_readlink: c_long = 89; +pub const SYS_chmod: c_long = 90; +pub const SYS_fchmod: c_long = 91; +pub const SYS_chown: c_long = 92; +pub const SYS_fchown: c_long = 93; +pub const SYS_lchown: c_long = 94; +pub const SYS_umask: c_long = 95; +pub const SYS_gettimeofday: c_long = 96; +pub const SYS_getrlimit: c_long = 97; +pub const SYS_getrusage: c_long = 98; +pub const SYS_sysinfo: c_long = 99; +pub const SYS_times: c_long = 100; +pub const SYS_ptrace: c_long = 101; +pub const SYS_getuid: c_long = 102; +pub const SYS_syslog: c_long = 103; +pub const SYS_getgid: c_long = 104; +pub const SYS_setuid: c_long = 105; +pub const SYS_setgid: c_long = 106; +pub const SYS_geteuid: c_long = 107; +pub const SYS_getegid: c_long = 108; +pub const SYS_setpgid: c_long = 109; +pub const SYS_getppid: c_long = 110; +pub const SYS_getpgrp: c_long = 111; +pub const SYS_setsid: c_long = 112; +pub const SYS_setreuid: c_long = 113; +pub const SYS_setregid: c_long = 114; +pub const SYS_getgroups: c_long = 115; +pub const SYS_setgroups: c_long = 116; +pub const SYS_setresuid: c_long = 117; +pub const SYS_getresuid: c_long = 118; +pub const SYS_setresgid: c_long = 119; +pub const SYS_getresgid: c_long = 120; +pub const SYS_getpgid: c_long = 121; +pub const SYS_setfsuid: c_long = 122; +pub const SYS_setfsgid: c_long = 123; +pub const SYS_getsid: c_long = 124; +pub const SYS_capget: c_long = 125; +pub const SYS_capset: c_long = 126; +pub const SYS_rt_sigpending: c_long = 127; +pub const SYS_rt_sigtimedwait: c_long = 128; +pub const SYS_rt_sigqueueinfo: c_long = 129; +pub const SYS_rt_sigsuspend: c_long = 130; +pub const SYS_sigaltstack: c_long = 131; +pub const SYS_utime: c_long = 132; +pub const SYS_mknod: c_long = 133; +pub const SYS_uselib: c_long = 134; +pub const SYS_personality: c_long = 135; +pub const SYS_ustat: c_long = 136; +pub const SYS_statfs: c_long = 137; +pub const SYS_fstatfs: c_long = 138; +pub const SYS_sysfs: c_long = 139; +pub const SYS_getpriority: c_long = 140; +pub const SYS_setpriority: c_long = 141; +pub const SYS_sched_setparam: c_long = 142; +pub const SYS_sched_getparam: c_long = 143; +pub const SYS_sched_setscheduler: c_long = 144; +pub const SYS_sched_getscheduler: c_long = 145; +pub const SYS_sched_get_priority_max: c_long = 146; +pub const SYS_sched_get_priority_min: c_long = 147; +pub const SYS_sched_rr_get_interval: c_long = 148; +pub const SYS_mlock: c_long = 149; +pub const SYS_munlock: c_long = 150; +pub const SYS_mlockall: c_long = 151; +pub const SYS_munlockall: c_long = 152; +pub const SYS_vhangup: c_long = 153; +pub const SYS_modify_ldt: c_long = 154; +pub const SYS_pivot_root: c_long = 155; +pub const SYS__sysctl: c_long = 156; +pub const SYS_prctl: c_long = 157; +pub const SYS_arch_prctl: c_long = 158; +pub const SYS_adjtimex: c_long = 159; +pub const SYS_setrlimit: c_long = 160; +pub const SYS_chroot: c_long = 161; +pub const SYS_sync: c_long = 162; +pub const SYS_acct: c_long = 163; +pub const SYS_settimeofday: c_long = 164; +pub const SYS_mount: c_long = 165; +pub const SYS_umount2: c_long = 166; +pub const SYS_swapon: c_long = 167; +pub const SYS_swapoff: c_long = 168; +pub const SYS_reboot: c_long = 169; +pub const SYS_sethostname: c_long = 170; +pub const SYS_setdomainname: c_long = 171; +pub const SYS_iopl: c_long = 172; +pub const SYS_ioperm: c_long = 173; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_create_module: c_long = 174; +pub const SYS_init_module: c_long = 175; +pub const SYS_delete_module: c_long = 176; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_get_kernel_syms: c_long = 177; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_query_module: c_long = 178; +pub const SYS_quotactl: c_long = 179; +pub const SYS_nfsservctl: c_long = 180; +pub const SYS_getpmsg: c_long = 181; +pub const SYS_putpmsg: c_long = 182; +pub const SYS_afs_syscall: c_long = 183; +pub const SYS_tuxcall: c_long = 184; +pub const SYS_security: c_long = 185; +pub const SYS_gettid: c_long = 186; +pub const SYS_readahead: c_long = 187; +pub const SYS_setxattr: c_long = 188; +pub const SYS_lsetxattr: c_long = 189; +pub const SYS_fsetxattr: c_long = 190; +pub const SYS_getxattr: c_long = 191; +pub const SYS_lgetxattr: c_long = 192; +pub const SYS_fgetxattr: c_long = 193; +pub const SYS_listxattr: c_long = 194; +pub const SYS_llistxattr: c_long = 195; +pub const SYS_flistxattr: c_long = 196; +pub const SYS_removexattr: c_long = 197; +pub const SYS_lremovexattr: c_long = 198; +pub const SYS_fremovexattr: c_long = 199; +pub const SYS_tkill: c_long = 200; +pub const SYS_time: c_long = 201; +pub const SYS_futex: c_long = 202; +pub const SYS_sched_setaffinity: c_long = 203; +pub const SYS_sched_getaffinity: c_long = 204; +pub const SYS_set_thread_area: c_long = 205; +pub const SYS_io_setup: c_long = 206; +pub const SYS_io_destroy: c_long = 207; +pub const SYS_io_getevents: c_long = 208; +pub const SYS_io_submit: c_long = 209; +pub const SYS_io_cancel: c_long = 210; +pub const SYS_get_thread_area: c_long = 211; +pub const SYS_lookup_dcookie: c_long = 212; +pub const SYS_epoll_create: c_long = 213; +pub const SYS_epoll_ctl_old: c_long = 214; +pub const SYS_epoll_wait_old: c_long = 215; +pub const SYS_remap_file_pages: c_long = 216; +pub const SYS_getdents64: c_long = 217; +pub const SYS_set_tid_address: c_long = 218; +pub const SYS_restart_syscall: c_long = 219; +pub const SYS_semtimedop: c_long = 220; +pub const SYS_fadvise64: c_long = 221; +pub const SYS_timer_create: c_long = 222; +pub const SYS_timer_settime: c_long = 223; +pub const SYS_timer_gettime: c_long = 224; +pub const SYS_timer_getoverrun: c_long = 225; +pub const SYS_timer_delete: c_long = 226; +pub const SYS_clock_settime: c_long = 227; +pub const SYS_clock_gettime: c_long = 228; +pub const SYS_clock_getres: c_long = 229; +pub const SYS_clock_nanosleep: c_long = 230; +pub const SYS_exit_group: c_long = 231; +pub const SYS_epoll_wait: c_long = 232; +pub const SYS_epoll_ctl: c_long = 233; +pub const SYS_tgkill: c_long = 234; +pub const SYS_utimes: c_long = 235; +pub const SYS_vserver: c_long = 236; +pub const SYS_mbind: c_long = 237; +pub const SYS_set_mempolicy: c_long = 238; +pub const SYS_get_mempolicy: c_long = 239; +pub const SYS_mq_open: c_long = 240; +pub const SYS_mq_unlink: c_long = 241; +pub const SYS_mq_timedsend: c_long = 242; +pub const SYS_mq_timedreceive: c_long = 243; +pub const SYS_mq_notify: c_long = 244; +pub const SYS_mq_getsetattr: c_long = 245; +pub const SYS_kexec_load: c_long = 246; +pub const SYS_waitid: c_long = 247; +pub const SYS_add_key: c_long = 248; +pub const SYS_request_key: c_long = 249; +pub const SYS_keyctl: c_long = 250; +pub const SYS_ioprio_set: c_long = 251; +pub const SYS_ioprio_get: c_long = 252; +pub const SYS_inotify_init: c_long = 253; +pub const SYS_inotify_add_watch: c_long = 254; +pub const SYS_inotify_rm_watch: c_long = 255; +pub const SYS_migrate_pages: c_long = 256; +pub const SYS_openat: c_long = 257; +pub const SYS_mkdirat: c_long = 258; +pub const SYS_mknodat: c_long = 259; +pub const SYS_fchownat: c_long = 260; +pub const SYS_futimesat: c_long = 261; +pub const SYS_newfstatat: c_long = 262; +pub const SYS_unlinkat: c_long = 263; +pub const SYS_renameat: c_long = 264; +pub const SYS_linkat: c_long = 265; +pub const SYS_symlinkat: c_long = 266; +pub const SYS_readlinkat: c_long = 267; +pub const SYS_fchmodat: c_long = 268; +pub const SYS_faccessat: c_long = 269; +pub const SYS_pselect6: c_long = 270; +pub const SYS_ppoll: c_long = 271; +pub const SYS_unshare: c_long = 272; +pub const SYS_set_robust_list: c_long = 273; +pub const SYS_get_robust_list: c_long = 274; +pub const SYS_splice: c_long = 275; +pub const SYS_tee: c_long = 276; +pub const SYS_sync_file_range: c_long = 277; +pub const SYS_vmsplice: c_long = 278; +pub const SYS_move_pages: c_long = 279; +pub const SYS_utimensat: c_long = 280; +pub const SYS_epoll_pwait: c_long = 281; +pub const SYS_signalfd: c_long = 282; +pub const SYS_timerfd_create: c_long = 283; +pub const SYS_eventfd: c_long = 284; +pub const SYS_fallocate: c_long = 285; +pub const SYS_timerfd_settime: c_long = 286; +pub const SYS_timerfd_gettime: c_long = 287; +pub const SYS_accept4: c_long = 288; +pub const SYS_signalfd4: c_long = 289; +pub const SYS_eventfd2: c_long = 290; +pub const SYS_epoll_create1: c_long = 291; +pub const SYS_dup3: c_long = 292; +pub const SYS_pipe2: c_long = 293; +pub const SYS_inotify_init1: c_long = 294; +pub const SYS_preadv: c_long = 295; +pub const SYS_pwritev: c_long = 296; +pub const SYS_rt_tgsigqueueinfo: c_long = 297; +pub const SYS_perf_event_open: c_long = 298; +pub const SYS_recvmmsg: c_long = 299; +pub const SYS_fanotify_init: c_long = 300; +pub const SYS_fanotify_mark: c_long = 301; +pub const SYS_prlimit64: c_long = 302; +pub const SYS_name_to_handle_at: c_long = 303; +pub const SYS_open_by_handle_at: c_long = 304; +pub const SYS_clock_adjtime: c_long = 305; +pub const SYS_syncfs: c_long = 306; +pub const SYS_sendmmsg: c_long = 307; +pub const SYS_setns: c_long = 308; +pub const SYS_getcpu: c_long = 309; +pub const SYS_process_vm_readv: c_long = 310; +pub const SYS_process_vm_writev: c_long = 311; +pub const SYS_kcmp: c_long = 312; +pub const SYS_finit_module: c_long = 313; +pub const SYS_sched_setattr: c_long = 314; +pub const SYS_sched_getattr: c_long = 315; +pub const SYS_renameat2: c_long = 316; +pub const SYS_seccomp: c_long = 317; +pub const SYS_getrandom: c_long = 318; +pub const SYS_memfd_create: c_long = 319; +pub const SYS_kexec_file_load: c_long = 320; +pub const SYS_bpf: c_long = 321; +pub const SYS_execveat: c_long = 322; +pub const SYS_userfaultfd: c_long = 323; +pub const SYS_membarrier: c_long = 324; +pub const SYS_mlock2: c_long = 325; +pub const SYS_copy_file_range: c_long = 326; +pub const SYS_preadv2: c_long = 327; +pub const SYS_pwritev2: c_long = 328; +pub const SYS_pkey_mprotect: c_long = 329; +pub const SYS_pkey_alloc: c_long = 330; +pub const SYS_pkey_free: c_long = 331; +pub const SYS_statx: c_long = 332; +pub const SYS_io_pgetevents: c_long = 333; +pub const SYS_rseq: c_long = 334; +pub const SYS_pidfd_send_signal: c_long = 424; +pub const SYS_io_uring_setup: c_long = 425; +pub const SYS_io_uring_enter: c_long = 426; +pub const SYS_io_uring_register: c_long = 427; +pub const SYS_open_tree: c_long = 428; +pub const SYS_move_mount: c_long = 429; +pub const SYS_fsopen: c_long = 430; +pub const SYS_fsconfig: c_long = 431; +pub const SYS_fsmount: c_long = 432; +pub const SYS_fspick: c_long = 433; +pub const SYS_pidfd_open: c_long = 434; +pub const SYS_clone3: c_long = 435; +pub const SYS_close_range: c_long = 436; +pub const SYS_openat2: c_long = 437; +pub const SYS_pidfd_getfd: c_long = 438; +pub const SYS_faccessat2: c_long = 439; +pub const SYS_process_madvise: c_long = 440; +pub const SYS_epoll_pwait2: c_long = 441; +pub const SYS_mount_setattr: c_long = 442; +pub const SYS_quotactl_fd: c_long = 443; +pub const SYS_landlock_create_ruleset: c_long = 444; +pub const SYS_landlock_add_rule: c_long = 445; +pub const SYS_landlock_restrict_self: c_long = 446; +pub const SYS_memfd_secret: c_long = 447; +pub const SYS_process_mrelease: c_long = 448; +pub const SYS_futex_waitv: c_long = 449; +pub const SYS_set_mempolicy_home_node: c_long = 450; +pub const SYS_fchmodat2: c_long = 452; +pub const SYS_mseal: c_long = 462; + +// offsets in user_regs_structs, from sys/reg.h +pub const R15: c_int = 0; +pub const R14: c_int = 1; +pub const R13: c_int = 2; +pub const R12: c_int = 3; +pub const RBP: c_int = 4; +pub const RBX: c_int = 5; +pub const R11: c_int = 6; +pub const R10: c_int = 7; +pub const R9: c_int = 8; +pub const R8: c_int = 9; +pub const RAX: c_int = 10; +pub const RCX: c_int = 11; +pub const RDX: c_int = 12; +pub const RSI: c_int = 13; +pub const RDI: c_int = 14; +pub const ORIG_RAX: c_int = 15; +pub const RIP: c_int = 16; +pub const CS: c_int = 17; +pub const EFLAGS: c_int = 18; +pub const RSP: c_int = 19; +pub const SS: c_int = 20; +pub const FS_BASE: c_int = 21; +pub const GS_BASE: c_int = 22; +pub const DS: c_int = 23; +pub const ES: c_int = 24; +pub const FS: c_int = 25; +pub const GS: c_int = 26; + +// offsets in mcontext_t.gregs from bits/signal.h +// GitHub repo: ifduyue/musl/ +// commit: b4b1e10364c8737a632be61582e05a8d3acf5690 +// file: arch/x86_64/bits/signal.h#L9-L56 +pub const REG_R8: c_int = 0; +pub const REG_R9: c_int = 1; +pub const REG_R10: c_int = 2; +pub const REG_R11: c_int = 3; +pub const REG_R12: c_int = 4; +pub const REG_R13: c_int = 5; +pub const REG_R14: c_int = 6; +pub const REG_R15: c_int = 7; +pub const REG_RDI: c_int = 8; +pub const REG_RSI: c_int = 9; +pub const REG_RBP: c_int = 10; +pub const REG_RBX: c_int = 11; +pub const REG_RDX: c_int = 12; +pub const REG_RAX: c_int = 13; +pub const REG_RCX: c_int = 14; +pub const REG_RSP: c_int = 15; +pub const REG_RIP: c_int = 16; +pub const REG_EFL: c_int = 17; +pub const REG_CSGSFS: c_int = 18; +pub const REG_ERR: c_int = 19; +pub const REG_TRAPNO: c_int = 20; +pub const REG_OLDMASK: c_int = 21; +pub const REG_CR2: c_int = 22; + +pub const MADV_SOFT_OFFLINE: c_int = 101; +pub const MAP_32BIT: c_int = 0x0040; +pub const O_APPEND: c_int = 1024; +pub const O_DIRECT: c_int = 0x4000; +pub const O_DIRECTORY: c_int = 0x10000; +pub const O_LARGEFILE: c_int = 0o0100000; +pub const O_NOFOLLOW: c_int = 0x20000; +pub const O_CREAT: c_int = 64; +pub const O_EXCL: c_int = 128; +pub const O_NOCTTY: c_int = 256; +pub const O_NONBLOCK: c_int = 2048; +pub const O_SYNC: c_int = 1052672; +pub const O_RSYNC: c_int = 1052672; +pub const O_DSYNC: c_int = 4096; +pub const O_ASYNC: c_int = 0x2000; + +pub const PTRACE_SYSEMU: c_int = 31; +pub const PTRACE_SYSEMU_SINGLESTEP: c_int = 32; + +pub const SIGSTKSZ: size_t = 8192; +pub const MINSIGSTKSZ: size_t = 2048; + +pub const ENAMETOOLONG: c_int = 36; +pub const ENOLCK: c_int = 37; +pub const ENOSYS: c_int = 38; +pub const ENOTEMPTY: c_int = 39; +pub const ELOOP: c_int = 40; +pub const ENOMSG: c_int = 42; +pub const EIDRM: c_int = 43; +pub const ECHRNG: c_int = 44; +pub const EL2NSYNC: c_int = 45; +pub const EL3HLT: c_int = 46; +pub const EL3RST: c_int = 47; +pub const ELNRNG: c_int = 48; +pub const EUNATCH: c_int = 49; +pub const ENOCSI: c_int = 50; +pub const EL2HLT: c_int = 51; +pub const EBADE: c_int = 52; +pub const EBADR: c_int = 53; +pub const EXFULL: c_int = 54; +pub const ENOANO: c_int = 55; +pub const EBADRQC: c_int = 56; +pub const EBADSLT: c_int = 57; +pub const EMULTIHOP: c_int = 72; +pub const EBADMSG: c_int = 74; +pub const EOVERFLOW: c_int = 75; +pub const ENOTUNIQ: c_int = 76; +pub const EBADFD: c_int = 77; +pub const EREMCHG: c_int = 78; +pub const ELIBACC: c_int = 79; +pub const ELIBBAD: c_int = 80; +pub const ELIBSCN: c_int = 81; +pub const ELIBMAX: c_int = 82; +pub const ELIBEXEC: c_int = 83; +pub const EILSEQ: c_int = 84; +pub const ERESTART: c_int = 85; +pub const ESTRPIPE: c_int = 86; +pub const EUSERS: c_int = 87; +pub const ENOTSOCK: c_int = 88; +pub const EDESTADDRREQ: c_int = 89; +pub const EMSGSIZE: c_int = 90; +pub const EPROTOTYPE: c_int = 91; +pub const ENOPROTOOPT: c_int = 92; +pub const EPROTONOSUPPORT: c_int = 93; +pub const ESOCKTNOSUPPORT: c_int = 94; +pub const EOPNOTSUPP: c_int = 95; +pub const ENOTSUP: c_int = EOPNOTSUPP; +pub const EPFNOSUPPORT: c_int = 96; +pub const EAFNOSUPPORT: c_int = 97; +pub const EADDRINUSE: c_int = 98; +pub const EADDRNOTAVAIL: c_int = 99; +pub const ENETDOWN: c_int = 100; +pub const ENETUNREACH: c_int = 101; +pub const ENETRESET: c_int = 102; +pub const ECONNABORTED: c_int = 103; +pub const ECONNRESET: c_int = 104; +pub const ENOBUFS: c_int = 105; +pub const EISCONN: c_int = 106; +pub const ENOTCONN: c_int = 107; +pub const ESHUTDOWN: c_int = 108; +pub const ETOOMANYREFS: c_int = 109; +pub const ETIMEDOUT: c_int = 110; +pub const ECONNREFUSED: c_int = 111; +pub const EHOSTDOWN: c_int = 112; +pub const EHOSTUNREACH: c_int = 113; +pub const EALREADY: c_int = 114; +pub const EINPROGRESS: c_int = 115; +pub const ESTALE: c_int = 116; +pub const EUCLEAN: c_int = 117; +pub const ENOTNAM: c_int = 118; +pub const ENAVAIL: c_int = 119; +pub const EISNAM: c_int = 120; +pub const EREMOTEIO: c_int = 121; +pub const EDQUOT: c_int = 122; +pub const ENOMEDIUM: c_int = 123; +pub const EMEDIUMTYPE: c_int = 124; +pub const ECANCELED: c_int = 125; +pub const ENOKEY: c_int = 126; +pub const EKEYEXPIRED: c_int = 127; +pub const EKEYREVOKED: c_int = 128; +pub const EKEYREJECTED: c_int = 129; +pub const EOWNERDEAD: c_int = 130; +pub const ENOTRECOVERABLE: c_int = 131; +pub const ERFKILL: c_int = 132; +pub const EHWPOISON: c_int = 133; + +pub const SA_ONSTACK: c_int = 0x08000000; +pub const SA_SIGINFO: c_int = 0x00000004; +pub const SA_NOCLDWAIT: c_int = 0x00000002; + +pub const SIGCHLD: c_int = 17; +pub const SIGBUS: c_int = 7; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGUSR1: c_int = 10; +pub const SIGUSR2: c_int = 12; +pub const SIGCONT: c_int = 18; +pub const SIGSTOP: c_int = 19; +pub const SIGTSTP: c_int = 20; +pub const SIGURG: c_int = 23; +pub const SIGIO: c_int = 29; +pub const SIGSYS: c_int = 31; +pub const SIGSTKFLT: c_int = 16; +pub const SIGPOLL: c_int = 29; +pub const SIGPWR: c_int = 30; +pub const SIG_SETMASK: c_int = 2; +pub const SIG_BLOCK: c_int = 0x000000; +pub const SIG_UNBLOCK: c_int = 0x01; + +pub const F_GETLK: c_int = 5; +pub const F_GETOWN: c_int = 9; +pub const F_SETLK: c_int = 6; +pub const F_SETLKW: c_int = 7; +pub const F_SETOWN: c_int = 8; + +pub const VEOF: usize = 4; + +pub const POLLWRNORM: c_short = 0x100; +pub const POLLWRBAND: c_short = 0x200; + +pub const MAP_ANON: c_int = 0x0020; +pub const MAP_GROWSDOWN: c_int = 0x0100; +pub const MAP_DENYWRITE: c_int = 0x0800; +pub const MAP_EXECUTABLE: c_int = 0x01000; +pub const MAP_LOCKED: c_int = 0x02000; +pub const MAP_NORESERVE: c_int = 0x04000; +pub const MAP_POPULATE: c_int = 0x08000; +pub const MAP_NONBLOCK: c_int = 0x010000; +pub const MAP_STACK: c_int = 0x020000; +pub const MAP_HUGETLB: c_int = 0x040000; +pub const MAP_SYNC: c_int = 0x080000; + +pub const MCL_CURRENT: c_int = 0x0001; +pub const MCL_FUTURE: c_int = 0x0002; +pub const MCL_ONFAULT: c_int = 0x0004; +pub const CBAUD: crate::tcflag_t = 0o0010017; +pub const TAB1: c_int = 0x00000800; +pub const TAB2: c_int = 0x00001000; +pub const TAB3: c_int = 0x00001800; +pub const CR1: c_int = 0x00000200; +pub const CR2: c_int = 0x00000400; +pub const CR3: c_int = 0x00000600; +pub const FF1: c_int = 0x00008000; +pub const BS1: c_int = 0x00002000; +pub const VT1: c_int = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: crate::tcflag_t = 0x00000400; +pub const IXOFF: crate::tcflag_t = 0x00001000; +pub const ONLCR: crate::tcflag_t = 0x4; +pub const CSIZE: crate::tcflag_t = 0x00000030; +pub const CS6: crate::tcflag_t = 0x00000010; +pub const CS7: crate::tcflag_t = 0x00000020; +pub const CS8: crate::tcflag_t = 0x00000030; +pub const CSTOPB: crate::tcflag_t = 0x00000040; +pub const CREAD: crate::tcflag_t = 0x00000080; +pub const PARENB: crate::tcflag_t = 0x00000100; +pub const PARODD: crate::tcflag_t = 0x00000200; +pub const HUPCL: crate::tcflag_t = 0x00000400; +pub const CLOCAL: crate::tcflag_t = 0x00000800; +pub const ECHOKE: crate::tcflag_t = 0x00000800; +pub const ECHOE: crate::tcflag_t = 0x00000010; +pub const ECHOK: crate::tcflag_t = 0x00000020; +pub const ECHONL: crate::tcflag_t = 0x00000040; +pub const ECHOPRT: crate::tcflag_t = 0x00000400; +pub const ECHOCTL: crate::tcflag_t = 0x00000200; +pub const ISIG: crate::tcflag_t = 0x00000001; +pub const ICANON: crate::tcflag_t = 0x00000002; +pub const PENDIN: crate::tcflag_t = 0x00004000; +pub const NOFLSH: crate::tcflag_t = 0x00000080; +pub const CIBAUD: crate::tcflag_t = 0o02003600000; +pub const CBAUDEX: crate::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: crate::tcflag_t = 0o000002; +pub const NLDLY: crate::tcflag_t = 0o000400; +pub const CRDLY: crate::tcflag_t = 0o003000; +pub const TABDLY: crate::tcflag_t = 0o014000; +pub const BSDLY: crate::tcflag_t = 0o020000; +pub const FFDLY: crate::tcflag_t = 0o100000; +pub const VTDLY: crate::tcflag_t = 0o040000; +pub const XTABS: crate::tcflag_t = 0o014000; +pub const B57600: crate::speed_t = 0o010001; +pub const B115200: crate::speed_t = 0o010002; +pub const B230400: crate::speed_t = 0o010003; +pub const B460800: crate::speed_t = 0o010004; +pub const B500000: crate::speed_t = 0o010005; +pub const B576000: crate::speed_t = 0o010006; +pub const B921600: crate::speed_t = 0o010007; +pub const B1000000: crate::speed_t = 0o010010; +pub const B1152000: crate::speed_t = 0o010011; +pub const B1500000: crate::speed_t = 0o010012; +pub const B2000000: crate::speed_t = 0o010013; +pub const B2500000: crate::speed_t = 0o010014; +pub const B3000000: crate::speed_t = 0o010015; +pub const B3500000: crate::speed_t = 0o010016; +pub const B4000000: crate::speed_t = 0o010017; + +pub const EDEADLK: c_int = 35; +pub const EDEADLOCK: c_int = EDEADLK; + +pub const EXTPROC: crate::tcflag_t = 0x00010000; +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: crate::tcflag_t = 0x00008000; +pub const TOSTOP: crate::tcflag_t = 0x00000100; +pub const FLUSHO: crate::tcflag_t = 0x00001000; diff --git a/http/vendor/libc/src/unix/linux_like/linux/musl/lfs64.rs b/http/vendor/libc/src/unix/linux_like/linux/musl/lfs64.rs new file mode 100644 index 0000000..4d595fc --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/musl/lfs64.rs @@ -0,0 +1,242 @@ +use crate::off64_t; +use crate::prelude::*; + +#[inline] +pub unsafe extern "C" fn creat64(path: *const c_char, mode: crate::mode_t) -> c_int { + crate::creat(path, mode) +} + +#[inline] +pub unsafe extern "C" fn fallocate64( + fd: c_int, + mode: c_int, + offset: off64_t, + len: off64_t, +) -> c_int { + crate::fallocate(fd, mode, offset, len) +} + +#[inline] +pub unsafe extern "C" fn fgetpos64(stream: *mut crate::FILE, pos: *mut crate::fpos64_t) -> c_int { + crate::fgetpos(stream, pos as *mut _) +} + +#[inline] +pub unsafe extern "C" fn fopen64(pathname: *const c_char, mode: *const c_char) -> *mut crate::FILE { + crate::fopen(pathname, mode) +} + +#[inline] +pub unsafe extern "C" fn freopen64( + pathname: *const c_char, + mode: *const c_char, + stream: *mut crate::FILE, +) -> *mut crate::FILE { + crate::freopen(pathname, mode, stream) +} + +#[inline] +pub unsafe extern "C" fn fseeko64( + stream: *mut crate::FILE, + offset: off64_t, + whence: c_int, +) -> c_int { + crate::fseeko(stream, offset, whence) +} + +#[inline] +pub unsafe extern "C" fn fsetpos64(stream: *mut crate::FILE, pos: *const crate::fpos64_t) -> c_int { + crate::fsetpos(stream, pos as *mut _) +} + +#[inline] +pub unsafe extern "C" fn fstat64(fildes: c_int, buf: *mut crate::stat64) -> c_int { + crate::fstat(fildes, buf as *mut _) +} + +#[inline] +pub unsafe extern "C" fn fstatat64( + fd: c_int, + path: *const c_char, + buf: *mut crate::stat64, + flag: c_int, +) -> c_int { + crate::fstatat(fd, path, buf as *mut _, flag) +} + +#[inline] +pub unsafe extern "C" fn fstatfs64(fd: c_int, buf: *mut crate::statfs64) -> c_int { + crate::fstatfs(fd, buf as *mut _) +} + +#[inline] +pub unsafe extern "C" fn fstatvfs64(fd: c_int, buf: *mut crate::statvfs64) -> c_int { + crate::fstatvfs(fd, buf as *mut _) +} + +#[inline] +pub unsafe extern "C" fn ftello64(stream: *mut crate::FILE) -> off64_t { + crate::ftello(stream) +} + +#[inline] +pub unsafe extern "C" fn ftruncate64(fd: c_int, length: off64_t) -> c_int { + crate::ftruncate(fd, length) +} + +#[inline] +pub unsafe extern "C" fn getrlimit64(resource: c_int, rlim: *mut crate::rlimit64) -> c_int { + crate::getrlimit(resource, rlim as *mut _) +} + +#[inline] +pub unsafe extern "C" fn lseek64(fd: c_int, offset: off64_t, whence: c_int) -> off64_t { + crate::lseek(fd, offset, whence) +} + +#[inline] +pub unsafe extern "C" fn lstat64(path: *const c_char, buf: *mut crate::stat64) -> c_int { + crate::lstat(path, buf as *mut _) +} + +#[inline] +pub unsafe extern "C" fn mmap64( + addr: *mut c_void, + length: size_t, + prot: c_int, + flags: c_int, + fd: c_int, + offset: off64_t, +) -> *mut c_void { + crate::mmap(addr, length, prot, flags, fd, offset) +} + +// These functions are variadic in the C ABI since the `mode` argument is "optional". Variadic +// `extern "C"` functions are unstable in Rust so we cannot write a shim function for these +// entrypoints. See https://github.com/rust-lang/rust/issues/44930. +// +// These aliases are mostly fine though, neither function takes a LFS64-namespaced type as an +// argument, nor do their names clash with any declared types. +pub use crate::{ + open as open64, + openat as openat64, +}; + +#[inline] +pub unsafe extern "C" fn posix_fadvise64( + fd: c_int, + offset: off64_t, + len: off64_t, + advice: c_int, +) -> c_int { + crate::posix_fadvise(fd, offset, len, advice) +} + +#[inline] +pub unsafe extern "C" fn posix_fallocate64(fd: c_int, offset: off64_t, len: off64_t) -> c_int { + crate::posix_fallocate(fd, offset, len) +} + +#[inline] +pub unsafe extern "C" fn pread64( + fd: c_int, + buf: *mut c_void, + count: size_t, + offset: off64_t, +) -> ssize_t { + crate::pread(fd, buf, count, offset) +} + +#[inline] +pub unsafe extern "C" fn preadv64( + fd: c_int, + iov: *const crate::iovec, + iovcnt: c_int, + offset: off64_t, +) -> ssize_t { + crate::preadv(fd, iov, iovcnt, offset) +} + +#[inline] +pub unsafe extern "C" fn prlimit64( + pid: crate::pid_t, + resource: c_int, + new_limit: *const crate::rlimit64, + old_limit: *mut crate::rlimit64, +) -> c_int { + crate::prlimit(pid, resource, new_limit as *mut _, old_limit as *mut _) +} + +#[inline] +pub unsafe extern "C" fn pwrite64( + fd: c_int, + buf: *const c_void, + count: size_t, + offset: off64_t, +) -> ssize_t { + crate::pwrite(fd, buf, count, offset) +} + +#[inline] +pub unsafe extern "C" fn pwritev64( + fd: c_int, + iov: *const crate::iovec, + iovcnt: c_int, + offset: off64_t, +) -> ssize_t { + crate::pwritev(fd, iov, iovcnt, offset) +} + +#[inline] +pub unsafe extern "C" fn readdir64(dirp: *mut crate::DIR) -> *mut crate::dirent64 { + crate::readdir(dirp) as *mut _ +} + +#[inline] +pub unsafe extern "C" fn readdir64_r( + dirp: *mut crate::DIR, + entry: *mut crate::dirent64, + result: *mut *mut crate::dirent64, +) -> c_int { + crate::readdir_r(dirp, entry as *mut _, result as *mut _) +} + +#[inline] +pub unsafe extern "C" fn sendfile64( + out_fd: c_int, + in_fd: c_int, + offset: *mut off64_t, + count: size_t, +) -> ssize_t { + crate::sendfile(out_fd, in_fd, offset, count) +} + +#[inline] +pub unsafe extern "C" fn setrlimit64(resource: c_int, rlim: *const crate::rlimit64) -> c_int { + crate::setrlimit(resource, rlim as *mut _) +} + +#[inline] +pub unsafe extern "C" fn stat64(pathname: *const c_char, statbuf: *mut crate::stat64) -> c_int { + crate::stat(pathname, statbuf as *mut _) +} + +#[inline] +pub unsafe extern "C" fn statfs64(pathname: *const c_char, buf: *mut crate::statfs64) -> c_int { + crate::statfs(pathname, buf as *mut _) +} + +#[inline] +pub unsafe extern "C" fn statvfs64(path: *const c_char, buf: *mut crate::statvfs64) -> c_int { + crate::statvfs(path, buf as *mut _) +} + +#[inline] +pub unsafe extern "C" fn tmpfile64() -> *mut crate::FILE { + crate::tmpfile() +} + +#[inline] +pub unsafe extern "C" fn truncate64(path: *const c_char, length: off64_t) -> c_int { + crate::truncate(path, length) +} diff --git a/http/vendor/libc/src/unix/linux_like/linux/musl/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/musl/mod.rs new file mode 100644 index 0000000..9d3009c --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/musl/mod.rs @@ -0,0 +1,914 @@ +use crate::off64_t; +use crate::prelude::*; + +pub type pthread_t = *mut c_void; +pub type clock_t = c_long; +#[cfg(musl32_time64)] +pub type time_t = i64; +#[cfg(not(musl32_time64))] +#[cfg_attr( + not(feature = "rustc-dep-of-std"), + deprecated( + since = "0.2.80", + note = "This type is changed to 64-bit in musl 1.2.0, \ + we'll follow that change in the future release. \ + See #1848 for more info." + ) +)] +pub type time_t = c_long; +#[cfg(musl32_time64)] +pub type suseconds_t = i64; +#[cfg(not(musl32_time64))] +#[cfg_attr( + not(feature = "rustc-dep-of-std"), + deprecated( + since = "0.2.80", + note = "This type is changed to 64-bit in musl 1.2.0, \ + we'll follow that change in the future release. \ + See #1848 for more info." + ) +)] +pub type suseconds_t = c_long; +pub type ino_t = u64; +pub type off_t = i64; +pub type blkcnt_t = i64; + +pub type shmatt_t = c_ulong; +pub type msgqnum_t = c_ulong; +pub type msglen_t = c_ulong; +pub type fsblkcnt_t = c_ulonglong; +pub type fsblkcnt64_t = c_ulonglong; +pub type fsfilcnt_t = c_ulonglong; +pub type fsfilcnt64_t = c_ulonglong; +pub type rlim_t = c_ulonglong; + +cfg_if! { + if #[cfg(doc)] { + // Used in `linux::arch` to define ioctl constants. + pub(crate) type Ioctl = c_int; + } else { + #[doc(hidden)] + pub type Ioctl = c_int; + } +} + +impl siginfo_t { + pub unsafe fn si_addr(&self) -> *mut c_void { + #[repr(C)] + struct siginfo_sigfault { + _si_signo: c_int, + _si_errno: c_int, + _si_code: c_int, + si_addr: *mut c_void, + } + (*(self as *const siginfo_t as *const siginfo_sigfault)).si_addr + } + + pub unsafe fn si_value(&self) -> crate::sigval { + #[repr(C)] + struct siginfo_si_value { + _si_signo: c_int, + _si_errno: c_int, + _si_code: c_int, + _si_timerid: c_int, + _si_overrun: c_int, + si_value: crate::sigval, + } + (*(self as *const siginfo_t as *const siginfo_si_value)).si_value + } +} + +s_no_extra_traits! { + // Internal, for casts to access union fields + struct sifields_sigchld { + si_pid: crate::pid_t, + si_uid: crate::uid_t, + si_status: c_int, + si_utime: c_long, + si_stime: c_long, + } + + // Internal, for casts to access union fields + union sifields { + _align_pointer: *mut c_void, + sigchld: sifields_sigchld, + } + + // Internal, for casts to access union fields. Note that some variants + // of sifields start with a pointer, which makes the alignment of + // sifields vary on 32-bit and 64-bit architectures. + struct siginfo_f { + _siginfo_base: [c_int; 3], + sifields: sifields, + } +} + +impl siginfo_t { + unsafe fn sifields(&self) -> &sifields { + &(*(self as *const siginfo_t as *const siginfo_f)).sifields + } + + pub unsafe fn si_pid(&self) -> crate::pid_t { + self.sifields().sigchld.si_pid + } + + pub unsafe fn si_uid(&self) -> crate::uid_t { + self.sifields().sigchld.si_uid + } + + pub unsafe fn si_status(&self) -> c_int { + self.sifields().sigchld.si_status + } + + pub unsafe fn si_utime(&self) -> c_long { + self.sifields().sigchld.si_utime + } + + pub unsafe fn si_stime(&self) -> c_long { + self.sifields().sigchld.si_stime + } +} + +s! { + pub struct aiocb { + pub aio_fildes: c_int, + pub aio_lio_opcode: c_int, + pub aio_reqprio: c_int, + pub aio_buf: *mut c_void, + pub aio_nbytes: size_t, + pub aio_sigevent: crate::sigevent, + __td: *mut c_void, + __lock: [c_int; 2], + __err: c_int, + __ret: ssize_t, + pub aio_offset: off_t, + __next: *mut c_void, + __prev: *mut c_void, + __dummy4: [c_char; 32 - 2 * size_of::<*const ()>()], + } + + #[repr(align(8))] + pub struct fanotify_event_metadata { + pub event_len: c_uint, + pub vers: c_uchar, + pub reserved: c_uchar, + pub metadata_len: c_ushort, + pub mask: c_ulonglong, + pub fd: c_int, + pub pid: c_int, + } + + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigaction { + pub sa_sigaction: crate::sighandler_t, + pub sa_mask: crate::sigset_t, + pub sa_flags: c_int, + pub sa_restorer: Option, + } + + // `mips*` targets swap the `s_errno` and `s_code` fields otherwise this struct is + // target-agnostic (see https://www.openwall.com/lists/musl/2016/01/27/1/2) + // + // FIXME(union): C implementation uses unions + pub struct siginfo_t { + pub si_signo: c_int, + #[cfg(not(any(target_arch = "mips", target_arch = "mips64")))] + pub si_errno: c_int, + pub si_code: c_int, + #[cfg(any(target_arch = "mips", target_arch = "mips64"))] + pub si_errno: c_int, + #[doc(hidden)] + #[deprecated( + since = "0.2.54", + note = "Please leave a comment on https://github.com/rust-lang/libc/pull/1316 \ + if you're using this field" + )] + pub _pad: [c_int; 29], + _align: [usize; 0], + } + + pub struct statvfs { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_favail: crate::fsfilcnt_t, + #[cfg(target_endian = "little")] + pub f_fsid: c_ulong, + #[cfg(target_pointer_width = "32")] + __pad: Padding, + #[cfg(target_endian = "big")] + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_reserved: Padding<[c_int; 6]>, + } + + pub struct statvfs64 { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt64_t, + pub f_bfree: crate::fsblkcnt64_t, + pub f_bavail: crate::fsblkcnt64_t, + pub f_files: crate::fsfilcnt64_t, + pub f_ffree: crate::fsfilcnt64_t, + pub f_favail: crate::fsfilcnt64_t, + #[cfg(target_endian = "little")] + pub f_fsid: c_ulong, + #[cfg(target_pointer_width = "32")] + __pad: Padding, + #[cfg(target_endian = "big")] + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_reserved: Padding<[c_int; 6]>, + } + + // PowerPC implementations are special, see the subfolders + #[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))] + pub struct termios { + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_line: crate::cc_t, + pub c_cc: [crate::cc_t; crate::NCCS], + pub __c_ispeed: crate::speed_t, + pub __c_ospeed: crate::speed_t, + } + + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off_t, + pub l_len: off_t, + pub l_pid: crate::pid_t, + } + + pub struct flock64 { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off64_t, + pub l_len: off64_t, + pub l_pid: crate::pid_t, + } + + pub struct regex_t { + __re_nsub: size_t, + __opaque: *mut c_void, + __padding: Padding<[*mut c_void; 4usize]>, + __nsub2: size_t, + __padding2: Padding, + } + + pub struct rtentry { + pub rt_pad1: c_ulong, + pub rt_dst: crate::sockaddr, + pub rt_gateway: crate::sockaddr, + pub rt_genmask: crate::sockaddr, + pub rt_flags: c_ushort, + pub rt_pad2: c_short, + pub rt_pad3: c_ulong, + pub rt_tos: c_uchar, + pub rt_class: c_uchar, + #[cfg(target_pointer_width = "64")] + pub rt_pad4: [c_short; 3usize], + #[cfg(not(target_pointer_width = "64"))] + pub rt_pad4: [c_short; 1usize], + pub rt_metric: c_short, + pub rt_dev: *mut c_char, + pub rt_mtu: c_ulong, + pub rt_window: c_ulong, + pub rt_irtt: c_ushort, + } + + pub struct __exit_status { + pub e_termination: c_short, + pub e_exit: c_short, + } + + pub struct Elf64_Chdr { + pub ch_type: crate::Elf64_Word, + pub ch_reserved: crate::Elf64_Word, + pub ch_size: crate::Elf64_Xword, + pub ch_addralign: crate::Elf64_Xword, + } + + pub struct Elf32_Chdr { + pub ch_type: crate::Elf32_Word, + pub ch_size: crate::Elf32_Word, + pub ch_addralign: crate::Elf32_Word, + } + + pub struct timex { + pub modes: c_uint, + pub offset: c_long, + pub freq: c_long, + pub maxerror: c_long, + pub esterror: c_long, + pub status: c_int, + pub constant: c_long, + pub precision: c_long, + pub tolerance: c_long, + pub time: crate::timeval, + pub tick: c_long, + pub ppsfreq: c_long, + pub jitter: c_long, + pub shift: c_int, + pub stabil: c_long, + pub jitcnt: c_long, + pub calcnt: c_long, + pub errcnt: c_long, + pub stbcnt: c_long, + pub tai: c_int, + pub __padding: [c_int; 11], + } + + pub struct ntptimeval { + pub time: crate::timeval, + pub maxerror: c_long, + pub esterror: c_long, + } + + // netinet/tcp.h + + pub struct tcp_info { + pub tcpi_state: u8, + pub tcpi_ca_state: u8, + pub tcpi_retransmits: u8, + pub tcpi_probes: u8, + pub tcpi_backoff: u8, + pub tcpi_options: u8, + /// This contains the bitfields `tcpi_snd_wscale` and `tcpi_rcv_wscale`. + /// Each is 4 bits. + pub tcpi_snd_rcv_wscale: u8, + /// This contains the bitfields `tcpi_delivery_rate_app_limited` (1 bit) and + /// `tcpi_fastopen_client_fail` (2 bits). + pub tcpi_delivery_fastopen_bitfields: u8, + pub tcpi_rto: u32, + pub tcpi_ato: u32, + pub tcpi_snd_mss: u32, + pub tcpi_rcv_mss: u32, + pub tcpi_unacked: u32, + pub tcpi_sacked: u32, + pub tcpi_lost: u32, + pub tcpi_retrans: u32, + pub tcpi_fackets: u32, + pub tcpi_last_data_sent: u32, + pub tcpi_last_ack_sent: u32, + pub tcpi_last_data_recv: u32, + pub tcpi_last_ack_recv: u32, + pub tcpi_pmtu: u32, + pub tcpi_rcv_ssthresh: u32, + pub tcpi_rtt: u32, + pub tcpi_rttvar: u32, + pub tcpi_snd_ssthresh: u32, + pub tcpi_snd_cwnd: u32, + pub tcpi_advmss: u32, + pub tcpi_reordering: u32, + pub tcpi_rcv_rtt: u32, + pub tcpi_rcv_space: u32, + pub tcpi_total_retrans: u32, + pub tcpi_pacing_rate: u64, + pub tcpi_max_pacing_rate: u64, + pub tcpi_bytes_acked: u64, + pub tcpi_bytes_received: u64, + pub tcpi_segs_out: u32, + pub tcpi_segs_in: u32, + pub tcpi_notsent_bytes: u32, + pub tcpi_min_rtt: u32, + pub tcpi_data_segs_in: u32, + pub tcpi_data_segs_out: u32, + pub tcpi_delivery_rate: u64, + pub tcpi_busy_time: u64, + pub tcpi_rwnd_limited: u64, + pub tcpi_sndbuf_limited: u64, + pub tcpi_delivered: u32, + pub tcpi_delivered_ce: u32, + pub tcpi_bytes_sent: u64, + pub tcpi_bytes_retrans: u64, + pub tcpi_dsack_dups: u32, + pub tcpi_reord_seen: u32, + pub tcpi_rcv_ooopack: u32, + pub tcpi_snd_wnd: u32, + } + + // MIPS/s390x implementation is special (see arch folders) + #[cfg(not(any(target_arch = "mips", target_arch = "mips64", target_arch = "s390x")))] + pub struct statfs { + pub f_type: c_ulong, + pub f_bsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_fsid: crate::fsid_t, + pub f_namelen: c_ulong, + pub f_frsize: c_ulong, + pub f_flags: c_ulong, + pub f_spare: [c_ulong; 4], + } + + // MIPS/s390x implementation is special (see arch folders) + #[cfg(not(any(target_arch = "mips", target_arch = "mips64", target_arch = "s390x")))] + pub struct statfs64 { + pub f_type: c_ulong, + pub f_bsize: c_ulong, + pub f_blocks: crate::fsblkcnt64_t, + pub f_bfree: crate::fsblkcnt64_t, + pub f_bavail: crate::fsblkcnt64_t, + pub f_files: crate::fsfilcnt64_t, + pub f_ffree: crate::fsfilcnt64_t, + pub f_fsid: crate::fsid_t, + pub f_namelen: c_ulong, + pub f_frsize: c_ulong, + pub f_flags: c_ulong, + pub f_spare: [c_ulong; 4], + } + + pub struct sysinfo { + pub uptime: c_ulong, + pub loads: [c_ulong; 3], + pub totalram: c_ulong, + pub freeram: c_ulong, + pub sharedram: c_ulong, + pub bufferram: c_ulong, + pub totalswap: c_ulong, + pub freeswap: c_ulong, + pub procs: c_ushort, + pub pad: c_ushort, + pub totalhigh: c_ulong, + pub freehigh: c_ulong, + pub mem_unit: c_uint, + pub __reserved: [c_char; 256], + } + + pub struct utmpx { + pub ut_type: c_short, + __ut_pad1: Padding, + pub ut_pid: crate::pid_t, + pub ut_line: [c_char; 32], + pub ut_id: [c_char; 4], + pub ut_user: [c_char; 32], + pub ut_host: [c_char; 256], + pub ut_exit: __exit_status, + + #[cfg(not(musl_v1_2_3))] + #[deprecated( + since = "0.2.173", + note = "The ABI of this field has changed from c_long to c_int with padding, \ + we'll follow that change in the future release. See #4443 for more info." + )] + pub ut_session: c_long, + + #[cfg(musl_v1_2_3)] + #[cfg(not(target_endian = "little"))] + __ut_pad2: Padding, + + #[cfg(musl_v1_2_3)] + pub ut_session: c_int, + + #[cfg(musl_v1_2_3)] + #[cfg(target_endian = "little")] + __ut_pad2: Padding, + + pub ut_tv: crate::timeval, + pub ut_addr_v6: [c_uint; 4], + __unused: Padding<[c_char; 20]>, + } +} + +// include/sys/mman.h +/* + * Huge page size encoding when MAP_HUGETLB is specified, and a huge page + * size other than the default is desired. See hugetlb_encode.h. + * All known huge page size encodings are provided here. It is the + * responsibility of the application to know which sizes are supported on + * the running system. See mmap(2) man page for details. + */ +pub const MAP_HUGE_SHIFT: c_int = 26; +pub const MAP_HUGE_MASK: c_int = 0x3f; + +pub const MAP_HUGE_64KB: c_int = 16 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_512KB: c_int = 19 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_1MB: c_int = 20 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_2MB: c_int = 21 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_8MB: c_int = 23 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_16MB: c_int = 24 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_32MB: c_int = 25 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_256MB: c_int = 28 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_512MB: c_int = 29 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_1GB: c_int = 30 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_2GB: c_int = 31 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_16GB: c_int = 34 << MAP_HUGE_SHIFT; + +pub const MS_RMT_MASK: c_ulong = 0x02800051; + +// include/utmpx.h +pub const EMPTY: c_short = 0; +pub const RUN_LVL: c_short = 1; +pub const BOOT_TIME: c_short = 2; +pub const NEW_TIME: c_short = 3; +pub const OLD_TIME: c_short = 4; +pub const INIT_PROCESS: c_short = 5; +pub const LOGIN_PROCESS: c_short = 6; +pub const USER_PROCESS: c_short = 7; +pub const DEAD_PROCESS: c_short = 8; +pub const ACCOUNTING: c_short = 9; + +pub const SFD_CLOEXEC: c_int = 0x080000; + +#[cfg(not(any(target_arch = "powerpc", target_arch = "powerpc64")))] +pub const NCCS: usize = 32; +#[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))] +pub const NCCS: usize = 19; + +pub const O_TRUNC: c_int = 512; +pub const O_NOATIME: c_int = 0o1000000; +pub const O_CLOEXEC: c_int = 0x80000; +pub const O_TMPFILE: c_int = 0o20000000 | O_DIRECTORY; + +pub const EBFONT: c_int = 59; +pub const ENOSTR: c_int = 60; +pub const ENODATA: c_int = 61; +pub const ETIME: c_int = 62; +pub const ENOSR: c_int = 63; +pub const ENONET: c_int = 64; +pub const ENOPKG: c_int = 65; +pub const EREMOTE: c_int = 66; +pub const ENOLINK: c_int = 67; +pub const EADV: c_int = 68; +pub const ESRMNT: c_int = 69; +pub const ECOMM: c_int = 70; +pub const EPROTO: c_int = 71; +pub const EDOTDOT: c_int = 73; + +pub const F_OFD_GETLK: c_int = 36; +pub const F_OFD_SETLK: c_int = 37; +pub const F_OFD_SETLKW: c_int = 38; + +pub const F_RDLCK: c_int = 0; +pub const F_WRLCK: c_int = 1; +pub const F_UNLCK: c_int = 2; + +pub const SA_NODEFER: c_int = 0x40000000; +pub const SA_RESETHAND: c_int = 0x80000000; +pub const SA_RESTART: c_int = 0x10000000; +pub const SA_NOCLDSTOP: c_int = 0x00000001; + +pub const EPOLL_CLOEXEC: c_int = 0x80000; + +pub const EFD_CLOEXEC: c_int = 0x80000; + +pub const BUFSIZ: c_uint = 1024; +pub const TMP_MAX: c_uint = 10000; +pub const FOPEN_MAX: c_uint = 1000; +pub const FILENAME_MAX: c_uint = 4096; +pub const O_PATH: c_int = 0o10000000; +pub const O_EXEC: c_int = 0o10000000; +pub const O_SEARCH: c_int = 0o10000000; +pub const O_ACCMODE: c_int = 0o10000003; +pub const O_NDELAY: c_int = O_NONBLOCK; +pub const NI_MAXHOST: crate::socklen_t = 255; +pub const PTHREAD_STACK_MIN: size_t = 2048; + +pub const MAP_ANONYMOUS: c_int = MAP_ANON; + +pub const SOCK_SEQPACKET: c_int = 5; +pub const SOCK_DCCP: c_int = 6; +pub const SOCK_NONBLOCK: c_int = O_NONBLOCK; +#[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")] +pub const SOCK_PACKET: c_int = 10; + +pub const SOMAXCONN: c_int = 128; + +#[deprecated(since = "0.2.55", note = "Use SIGSYS instead")] +pub const SIGUNUSED: c_int = crate::SIGSYS; + +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; +pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; + +// Value was changed in 1.2.4 +pub const CPU_SETSIZE: c_int = if cfg!(musl_v1_2_3) { 1024 } else { 128 }; + +pub const PTRACE_TRACEME: c_int = 0; +pub const PTRACE_PEEKTEXT: c_int = 1; +pub const PTRACE_PEEKDATA: c_int = 2; +pub const PTRACE_PEEKUSER: c_int = 3; +pub const PTRACE_POKETEXT: c_int = 4; +pub const PTRACE_POKEDATA: c_int = 5; +pub const PTRACE_POKEUSER: c_int = 6; +pub const PTRACE_CONT: c_int = 7; +pub const PTRACE_KILL: c_int = 8; +pub const PTRACE_SINGLESTEP: c_int = 9; +pub const PTRACE_GETREGS: c_int = 12; +pub const PTRACE_SETREGS: c_int = 13; +pub const PTRACE_GETFPREGS: c_int = 14; +pub const PTRACE_SETFPREGS: c_int = 15; +pub const PTRACE_ATTACH: c_int = 16; +pub const PTRACE_DETACH: c_int = 17; +pub const PTRACE_GETFPXREGS: c_int = 18; +pub const PTRACE_SETFPXREGS: c_int = 19; +pub const PTRACE_SYSCALL: c_int = 24; +pub const PTRACE_SETOPTIONS: c_int = 0x4200; +pub const PTRACE_GETEVENTMSG: c_int = 0x4201; +pub const PTRACE_GETSIGINFO: c_int = 0x4202; +pub const PTRACE_SETSIGINFO: c_int = 0x4203; +pub const PTRACE_GETREGSET: c_int = 0x4204; +pub const PTRACE_SETREGSET: c_int = 0x4205; +pub const PTRACE_SEIZE: c_int = 0x4206; +pub const PTRACE_INTERRUPT: c_int = 0x4207; +pub const PTRACE_LISTEN: c_int = 0x4208; +pub const PTRACE_PEEKSIGINFO: c_int = 0x4209; +pub const PTRACE_GETSIGMASK: c_uint = 0x420a; +pub const PTRACE_SETSIGMASK: c_uint = 0x420b; + +pub const AF_IB: c_int = 27; +pub const AF_MPLS: c_int = 28; +pub const AF_NFC: c_int = 39; +pub const AF_VSOCK: c_int = 40; +pub const AF_XDP: c_int = 44; +pub const PF_IB: c_int = AF_IB; +pub const PF_MPLS: c_int = AF_MPLS; +pub const PF_NFC: c_int = AF_NFC; +pub const PF_VSOCK: c_int = AF_VSOCK; +pub const PF_XDP: c_int = AF_XDP; + +pub const EFD_NONBLOCK: c_int = crate::O_NONBLOCK; + +pub const SFD_NONBLOCK: c_int = crate::O_NONBLOCK; + +pub const TCSANOW: c_int = 0; +pub const TCSADRAIN: c_int = 1; +pub const TCSAFLUSH: c_int = 2; + +pub const RTLD_GLOBAL: c_int = 0x100; +pub const RTLD_NOLOAD: c_int = 0x4; + +pub const CLOCK_SGI_CYCLE: crate::clockid_t = 10; + +pub const B0: crate::speed_t = 0o000000; +pub const B50: crate::speed_t = 0o000001; +pub const B75: crate::speed_t = 0o000002; +pub const B110: crate::speed_t = 0o000003; +pub const B134: crate::speed_t = 0o000004; +pub const B150: crate::speed_t = 0o000005; +pub const B200: crate::speed_t = 0o000006; +pub const B300: crate::speed_t = 0o000007; +pub const B600: crate::speed_t = 0o000010; +pub const B1200: crate::speed_t = 0o000011; +pub const B1800: crate::speed_t = 0o000012; +pub const B2400: crate::speed_t = 0o000013; +pub const B4800: crate::speed_t = 0o000014; +pub const B9600: crate::speed_t = 0o000015; +pub const B19200: crate::speed_t = 0o000016; +pub const B38400: crate::speed_t = 0o000017; +pub const EXTA: crate::speed_t = B19200; +pub const EXTB: crate::speed_t = B38400; + +pub const REG_OK: c_int = 0; + +pub const PRIO_PROCESS: c_int = 0; +pub const PRIO_PGRP: c_int = 1; +pub const PRIO_USER: c_int = 2; + +pub const ADJ_OFFSET: c_uint = 0x0001; +pub const ADJ_FREQUENCY: c_uint = 0x0002; +pub const ADJ_MAXERROR: c_uint = 0x0004; +pub const ADJ_ESTERROR: c_uint = 0x0008; +pub const ADJ_STATUS: c_uint = 0x0010; +pub const ADJ_TIMECONST: c_uint = 0x0020; +pub const ADJ_TAI: c_uint = 0x0080; +pub const ADJ_SETOFFSET: c_uint = 0x0100; +pub const ADJ_MICRO: c_uint = 0x1000; +pub const ADJ_NANO: c_uint = 0x2000; +pub const ADJ_TICK: c_uint = 0x4000; +pub const ADJ_OFFSET_SINGLESHOT: c_uint = 0x8001; +pub const ADJ_OFFSET_SS_READ: c_uint = 0xa001; +pub const MOD_OFFSET: c_uint = ADJ_OFFSET; +pub const MOD_FREQUENCY: c_uint = ADJ_FREQUENCY; +pub const MOD_MAXERROR: c_uint = ADJ_MAXERROR; +pub const MOD_ESTERROR: c_uint = ADJ_ESTERROR; +pub const MOD_STATUS: c_uint = ADJ_STATUS; +pub const MOD_TIMECONST: c_uint = ADJ_TIMECONST; +pub const MOD_CLKB: c_uint = ADJ_TICK; +pub const MOD_CLKA: c_uint = ADJ_OFFSET_SINGLESHOT; +pub const MOD_TAI: c_uint = ADJ_TAI; +pub const MOD_MICRO: c_uint = ADJ_MICRO; +pub const MOD_NANO: c_uint = ADJ_NANO; +pub const STA_PLL: c_int = 0x0001; +pub const STA_PPSFREQ: c_int = 0x0002; +pub const STA_PPSTIME: c_int = 0x0004; +pub const STA_FLL: c_int = 0x0008; +pub const STA_INS: c_int = 0x0010; +pub const STA_DEL: c_int = 0x0020; +pub const STA_UNSYNC: c_int = 0x0040; +pub const STA_FREQHOLD: c_int = 0x0080; +pub const STA_PPSSIGNAL: c_int = 0x0100; +pub const STA_PPSJITTER: c_int = 0x0200; +pub const STA_PPSWANDER: c_int = 0x0400; +pub const STA_PPSERROR: c_int = 0x0800; +pub const STA_CLOCKERR: c_int = 0x1000; +pub const STA_NANO: c_int = 0x2000; +pub const STA_MODE: c_int = 0x4000; +pub const STA_CLK: c_int = 0x8000; +pub const STA_RONLY: c_int = STA_PPSSIGNAL + | STA_PPSJITTER + | STA_PPSWANDER + | STA_PPSERROR + | STA_CLOCKERR + | STA_NANO + | STA_MODE + | STA_CLK; + +pub const TIME_OK: c_int = 0; +pub const TIME_INS: c_int = 1; +pub const TIME_DEL: c_int = 2; +pub const TIME_OOP: c_int = 3; +pub const TIME_WAIT: c_int = 4; +pub const TIME_ERROR: c_int = 5; +pub const TIME_BAD: c_int = TIME_ERROR; +pub const MAXTC: c_long = 6; + +pub const _CS_V6_ENV: c_int = 1148; +pub const _CS_V7_ENV: c_int = 1149; + +pub const CLONE_NEWTIME: c_int = 0x80; + +pub const UT_HOSTSIZE: usize = 256; +pub const UT_LINESIZE: usize = 32; +pub const UT_NAMESIZE: usize = 32; + +cfg_if! { + if #[cfg(target_arch = "s390x")] { + pub const POSIX_FADV_DONTNEED: c_int = 6; + pub const POSIX_FADV_NOREUSE: c_int = 7; + } else { + pub const POSIX_FADV_DONTNEED: c_int = 4; + pub const POSIX_FADV_NOREUSE: c_int = 5; + } +} + +extern "C" { + pub fn getrlimit(resource: c_int, rlim: *mut crate::rlimit) -> c_int; + pub fn setrlimit(resource: c_int, rlim: *const crate::rlimit) -> c_int; + pub fn prlimit( + pid: crate::pid_t, + resource: c_int, + new_limit: *const crate::rlimit, + old_limit: *mut crate::rlimit, + ) -> c_int; + #[cfg_attr(musl_redir_time64, link_name = "__gettimeofday_time64")] + pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut c_void) -> c_int; + pub fn ptrace(request: c_int, ...) -> c_long; + pub fn getpriority(which: c_int, who: crate::id_t) -> c_int; + pub fn setpriority(which: c_int, who: crate::id_t, prio: c_int) -> c_int; + // Musl targets need the `mask` argument of `fanotify_mark` be specified + // `c_ulonglong` instead of `u64` or there will be a type mismatch between + // `long long unsigned int` and the expected `uint64_t`. + pub fn fanotify_mark( + fd: c_int, + flags: c_uint, + mask: c_ulonglong, + dirfd: c_int, + path: *const c_char, + ) -> c_int; + pub fn preadv2( + fd: c_int, + iov: *const crate::iovec, + iovcnt: c_int, + offset: off_t, + flags: c_int, + ) -> ssize_t; + pub fn pwritev2( + fd: c_int, + iov: *const crate::iovec, + iovcnt: c_int, + offset: off_t, + flags: c_int, + ) -> ssize_t; + pub fn getauxval(type_: c_ulong) -> c_ulong; + + // Added in `musl` 1.1.20 + pub fn explicit_bzero(s: *mut c_void, len: size_t); + // Added in `musl` 1.2.2 + pub fn reallocarray(ptr: *mut c_void, nmemb: size_t, size: size_t) -> *mut c_void; + + #[cfg_attr(musl_redir_time64, link_name = "__adjtimex_time64")] + pub fn adjtimex(buf: *mut crate::timex) -> c_int; + #[cfg_attr(musl_redir_time64, link_name = "__clock_adjtime64")] + pub fn clock_adjtime(clk_id: crate::clockid_t, buf: *mut crate::timex) -> c_int; + + pub fn ctermid(s: *mut c_char) -> *mut c_char; + + pub fn memfd_create(name: *const c_char, flags: c_uint) -> c_int; + pub fn mlock2(addr: *const c_void, len: size_t, flags: c_uint) -> c_int; + pub fn malloc_usable_size(ptr: *mut c_void) -> size_t; + + pub fn euidaccess(pathname: *const c_char, mode: c_int) -> c_int; + pub fn eaccess(pathname: *const c_char, mode: c_int) -> c_int; + + pub fn asctime_r(tm: *const crate::tm, buf: *mut c_char) -> *mut c_char; + + pub fn dirname(path: *mut c_char) -> *mut c_char; + pub fn basename(path: *mut c_char) -> *mut c_char; + + // Added in `musl` 1.1.20 + pub fn getrandom(buf: *mut c_void, buflen: size_t, flags: c_uint) -> ssize_t; + + // Added in `musl` 1.1.24 + pub fn posix_spawn_file_actions_addchdir_np( + actions: *mut crate::posix_spawn_file_actions_t, + path: *const c_char, + ) -> c_int; + // Added in `musl` 1.1.24 + pub fn posix_spawn_file_actions_addfchdir_np( + actions: *mut crate::posix_spawn_file_actions_t, + fd: c_int, + ) -> c_int; + + #[deprecated( + since = "0.2.172", + note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html" + )] + pub fn getutxent() -> *mut utmpx; + #[deprecated( + since = "0.2.172", + note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html" + )] + pub fn getutxid(ut: *const utmpx) -> *mut utmpx; + #[deprecated( + since = "0.2.172", + note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html" + )] + pub fn getutxline(ut: *const utmpx) -> *mut utmpx; + #[deprecated( + since = "0.2.172", + note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html" + )] + pub fn pututxline(ut: *const utmpx) -> *mut utmpx; + #[deprecated( + since = "0.2.172", + note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html" + )] + pub fn setutxent(); + #[deprecated( + since = "0.2.172", + note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html" + )] + pub fn endutxent(); + #[deprecated( + since = "0.2.172", + note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html" + )] + pub fn utmpxname(file: *const c_char) -> c_int; + pub fn pthread_tryjoin_np(thread: crate::pthread_t, retval: *mut *mut c_void) -> c_int; + #[cfg_attr( + all(musl_redir_time64, target_pointer_width = "32"), + link_name = "__pthread_timedjoin_np_time64" + )] + pub fn pthread_timedjoin_np( + thread: crate::pthread_t, + retval: *mut *mut c_void, + abstime: *const crate::timespec, + ) -> c_int; +} + +// Alias to 64 to mimic glibc's LFS64 support +mod lfs64; +pub use self::lfs64::*; + +cfg_if! { + if #[cfg(any( + target_arch = "x86_64", + target_arch = "aarch64", + target_arch = "mips64", + target_arch = "powerpc64", + target_arch = "s390x", + target_arch = "riscv64", + target_arch = "loongarch64", + // musl-linux ABI for wasm32 follows b64 convention + target_arch = "wasm32", + ))] { + mod b64; + pub use self::b64::*; + } else if #[cfg(any( + target_arch = "x86", + target_arch = "mips", + target_arch = "powerpc", + target_arch = "hexagon", + target_arch = "riscv32", + target_arch = "arm" + ))] { + mod b32; + pub use self::b32::*; + } else { + } +} diff --git a/http/vendor/libc/src/unix/linux_like/linux/uclibc/arm/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/uclibc/arm/mod.rs new file mode 100644 index 0000000..26dd49b --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/uclibc/arm/mod.rs @@ -0,0 +1,925 @@ +use crate::off64_t; +use crate::prelude::*; + +pub type wchar_t = c_uint; +pub type time_t = c_long; + +pub type clock_t = c_long; +pub type fsblkcnt_t = c_ulong; +pub type fsfilcnt_t = c_ulong; +pub type ino_t = c_ulong; +pub type off_t = c_long; +pub type pthread_t = c_ulong; +pub type suseconds_t = c_long; + +pub type nlink_t = c_uint; +pub type blksize_t = c_long; +pub type blkcnt_t = c_long; + +pub type fsblkcnt64_t = u64; +pub type fsfilcnt64_t = u64; +pub type __u64 = c_ulonglong; +pub type __s64 = c_longlong; + +s! { + pub struct cmsghdr { + pub cmsg_len: size_t, + pub cmsg_level: c_int, + pub cmsg_type: c_int, + } + + pub struct msghdr { + pub msg_name: *mut c_void, + pub msg_namelen: crate::socklen_t, + pub msg_iov: *mut crate::iovec, + pub msg_iovlen: c_int, + pub msg_control: *mut c_void, + pub msg_controllen: crate::socklen_t, + pub msg_flags: c_int, + } + + pub struct pthread_attr_t { + __size: [c_long; 9], + } + + pub struct stat { + pub st_dev: c_ulonglong, + __pad1: Padding, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: c_ulonglong, + __pad2: Padding, + pub st_size: off_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + __unused4: Padding, + __unused5: Padding, + } + + pub struct stat64 { + pub st_dev: c_ulonglong, + pub __pad1: c_uint, + pub __st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: c_ulonglong, + pub __pad2: c_uint, + pub st_size: off64_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt64_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + pub st_ino: crate::ino64_t, + } + + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off_t, + pub l_len: off_t, + pub l_pid: crate::pid_t, + } + + pub struct sysinfo { + pub uptime: c_long, + pub loads: [c_ulong; 3], + pub totalram: c_ulong, + pub freeram: c_ulong, + pub sharedram: c_ulong, + pub bufferram: c_ulong, + pub totalswap: c_ulong, + pub freeswap: c_ulong, + pub procs: c_ushort, + pub pad: c_ushort, + pub totalhigh: c_ulong, + pub freehigh: c_ulong, + pub mem_unit: c_uint, + pub _f: [c_char; 8], + } + + pub struct statfs { + pub f_type: c_int, + pub f_bsize: c_int, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + + pub f_fsid: crate::fsid_t, + pub f_namelen: c_int, + pub f_frsize: c_int, + pub f_flags: c_int, + pub f_spare: [c_int; 4], + } + + pub struct statfs64 { + pub f_type: c_int, + pub f_bsize: c_int, + pub f_blocks: crate::fsblkcnt64_t, + pub f_bfree: crate::fsblkcnt64_t, + pub f_bavail: crate::fsblkcnt64_t, + pub f_files: crate::fsfilcnt64_t, + pub f_ffree: crate::fsfilcnt64_t, + pub f_fsid: crate::fsid_t, + pub f_namelen: c_int, + pub f_frsize: c_int, + pub f_flags: c_int, + pub f_spare: [c_int; 4], + } + + pub struct statvfs64 { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: c_ulong, + __f_unused: Padding, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: [c_int; 6], + } + + pub struct sigset_t { + __val: [c_ulong; 2], + } + + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigaction { + pub sa_sigaction: crate::sighandler_t, + pub sa_flags: c_ulong, + pub sa_restorer: Option, + pub sa_mask: sigset_t, + } + + pub struct termios { + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_line: crate::cc_t, + pub c_cc: [crate::cc_t; crate::NCCS], + pub c_ispeed: crate::speed_t, + pub c_ospeed: crate::speed_t, + } + + pub struct siginfo_t { + pub si_signo: c_int, + pub si_errno: c_int, + pub si_code: c_int, + pub _pad: [c_int; 29], + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_flags: c_int, + pub ss_size: size_t, + } + + pub struct ipc_perm { + pub __key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: c_ushort, + __pad1: Padding, + pub __seq: c_ushort, + __pad2: Padding, + __unused1: Padding, + __unused2: Padding, + } + + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + pub msg_stime: crate::time_t, + __unused1: Padding, + pub msg_rtime: crate::time_t, + __unused2: Padding, + pub msg_ctime: crate::time_t, + __unused3: Padding, + pub __msg_cbytes: c_ulong, + pub msg_qnum: crate::msgqnum_t, + pub msg_qbytes: crate::msglen_t, + pub msg_lspid: crate::pid_t, + pub msg_lrpid: crate::pid_t, + __unused4: Padding, + __unused5: Padding, + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, + pub shm_atime: crate::time_t, + __unused1: Padding, + pub shm_dtime: crate::time_t, + __unused2: Padding, + pub shm_ctime: crate::time_t, + __unused3: Padding, + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: crate::shmatt_t, + __unused4: Padding, + __unused5: Padding, + } + + // FIXME(1.0) this is actually a union + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + pub struct sem_t { + #[cfg(target_pointer_width = "32")] + __size: [c_char; 16], + #[cfg(target_pointer_width = "64")] + __size: [c_char; 32], + } +} + +pub const O_CLOEXEC: c_int = 0o2000000; +pub const __SIZEOF_PTHREAD_ATTR_T: usize = 36; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_COND_COMPAT_T: usize = 12; +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; +pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; +pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 20; +pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; +pub const NCCS: usize = 32; + +// I wasn't able to find those constants +// in uclibc build environment for armv7 +pub const MAP_HUGETLB: c_int = 0x040000; // from linux/other/mod.rs + +// autogenerated constants with hand tuned types +pub const B0: crate::speed_t = 0; +pub const B1000000: crate::speed_t = 0x1008; +pub const B110: crate::speed_t = 0x3; +pub const B115200: crate::speed_t = 0x1002; +pub const B1152000: crate::speed_t = 0x1009; +pub const B1200: crate::speed_t = 0x9; +pub const B134: crate::speed_t = 0x4; +pub const B150: crate::speed_t = 0x5; +pub const B1500000: crate::speed_t = 0x100a; +pub const B1800: crate::speed_t = 0xa; +pub const B19200: crate::speed_t = 0xe; +pub const B200: crate::speed_t = 0x6; +pub const B2000000: crate::speed_t = 0x100b; +pub const B230400: crate::speed_t = 0x1003; +pub const B2400: crate::speed_t = 0xb; +pub const B2500000: crate::speed_t = 0x100c; +pub const B300: crate::speed_t = 0x7; +pub const B3000000: crate::speed_t = 0x100d; +pub const B3500000: crate::speed_t = 0x100e; +pub const B38400: crate::speed_t = 0xf; +pub const B4000000: crate::speed_t = 0x100f; +pub const B460800: crate::speed_t = 0x1004; +pub const B4800: crate::speed_t = 0xc; +pub const B50: crate::speed_t = 0x1; +pub const B500000: crate::speed_t = 0x1005; +pub const B57600: crate::speed_t = 0x1001; +pub const B576000: crate::speed_t = 0x1006; +pub const B600: crate::speed_t = 0x8; +pub const B75: crate::speed_t = 0x2; +pub const B921600: crate::speed_t = 0x1007; +pub const B9600: crate::speed_t = 0xd; +pub const BS1: c_int = 0x2000; +pub const BSDLY: c_int = 0x2000; +pub const CBAUD: crate::tcflag_t = 0x100f; +pub const CBAUDEX: crate::tcflag_t = 0x1000; +pub const CIBAUD: crate::tcflag_t = 0x100f0000; +pub const CLOCAL: crate::tcflag_t = 0x800; +pub const CPU_SETSIZE: c_int = 0x400; +pub const CR1: c_int = 0x200; +pub const CR2: c_int = 0x400; +pub const CR3: c_int = 0x600; +pub const CRDLY: c_int = 0x600; +pub const CREAD: crate::tcflag_t = 0x80; +pub const CS6: crate::tcflag_t = 0x10; +pub const CS7: crate::tcflag_t = 0x20; +pub const CS8: crate::tcflag_t = 0x30; +pub const CSIZE: crate::tcflag_t = 0x30; +pub const CSTOPB: crate::tcflag_t = 0x40; +pub const EADDRINUSE: c_int = 0x62; +pub const EADDRNOTAVAIL: c_int = 0x63; +pub const EADV: c_int = 0x44; +pub const EAFNOSUPPORT: c_int = 0x61; +pub const EALREADY: c_int = 0x72; +pub const EBADE: c_int = 0x34; +pub const EBADFD: c_int = 0x4d; +pub const EBADMSG: c_int = 0x4a; +pub const EBADR: c_int = 0x35; +pub const EBADRQC: c_int = 0x38; +pub const EBADSLT: c_int = 0x39; +pub const EBFONT: c_int = 0x3b; +pub const ECANCELED: c_int = 0x7d; +pub const ECHOCTL: crate::tcflag_t = 0x200; +pub const ECHOE: crate::tcflag_t = 0x10; +pub const ECHOK: crate::tcflag_t = 0x20; +pub const ECHOKE: crate::tcflag_t = 0x800; +pub const ECHONL: crate::tcflag_t = 0x40; +pub const ECHOPRT: crate::tcflag_t = 0x400; +pub const ECHRNG: c_int = 0x2c; +pub const ECOMM: c_int = 0x46; +pub const ECONNABORTED: c_int = 0x67; +pub const ECONNREFUSED: c_int = 0x6f; +pub const ECONNRESET: c_int = 0x68; +pub const EDEADLK: c_int = 0x23; +pub const EDESTADDRREQ: c_int = 0x59; +pub const EDOTDOT: c_int = 0x49; +pub const EDQUOT: c_int = 0x7a; +pub const EFD_CLOEXEC: c_int = 0x80000; +pub const EFD_NONBLOCK: c_int = 0x800; +pub const EHOSTDOWN: c_int = 0x70; +pub const EHOSTUNREACH: c_int = 0x71; +pub const EHWPOISON: c_int = 0x85; +pub const EIDRM: c_int = 0x2b; +pub const EILSEQ: c_int = 0x54; +pub const EINPROGRESS: c_int = 0x73; +pub const EISCONN: c_int = 0x6a; +pub const EISNAM: c_int = 0x78; +pub const EKEYEXPIRED: c_int = 0x7f; +pub const EKEYREJECTED: c_int = 0x81; +pub const EKEYREVOKED: c_int = 0x80; +pub const EL2HLT: c_int = 0x33; +pub const EL2NSYNC: c_int = 0x2d; +pub const EL3HLT: c_int = 0x2e; +pub const EL3RST: c_int = 0x2f; +pub const ELIBACC: c_int = 0x4f; +pub const ELIBBAD: c_int = 0x50; +pub const ELIBEXEC: c_int = 0x53; +pub const ELIBMAX: c_int = 0x52; +pub const ELIBSCN: c_int = 0x51; +pub const ELNRNG: c_int = 0x30; +pub const ELOOP: c_int = 0x28; +pub const EMEDIUMTYPE: c_int = 0x7c; +pub const EMSGSIZE: c_int = 0x5a; +pub const EMULTIHOP: c_int = 0x48; +pub const ENAMETOOLONG: c_int = 0x24; +pub const ENAVAIL: c_int = 0x77; +pub const ENETDOWN: c_int = 0x64; +pub const ENETRESET: c_int = 0x66; +pub const ENETUNREACH: c_int = 0x65; +pub const ENOANO: c_int = 0x37; +pub const ENOBUFS: c_int = 0x69; +pub const ENOCSI: c_int = 0x32; +pub const ENODATA: c_int = 0x3d; +pub const ENOKEY: c_int = 0x7e; +pub const ENOLCK: c_int = 0x25; +pub const ENOLINK: c_int = 0x43; +pub const ENOMEDIUM: c_int = 0x7b; +pub const ENOMSG: c_int = 0x2a; +pub const ENONET: c_int = 0x40; +pub const ENOPKG: c_int = 0x41; +pub const ENOPROTOOPT: c_int = 0x5c; +pub const ENOSR: c_int = 0x3f; +pub const ENOSTR: c_int = 0x3c; +pub const ENOSYS: c_int = 0x26; +pub const ENOTCONN: c_int = 0x6b; +pub const ENOTEMPTY: c_int = 0x27; +pub const ENOTNAM: c_int = 0x76; +pub const ENOTRECOVERABLE: c_int = 0x83; +pub const ENOTSOCK: c_int = 0x58; +pub const ENOTUNIQ: c_int = 0x4c; +pub const EOPNOTSUPP: c_int = 0x5f; +pub const EOVERFLOW: c_int = 0x4b; +pub const EOWNERDEAD: c_int = 0x82; +pub const EPFNOSUPPORT: c_int = 0x60; +pub const EPOLL_CLOEXEC: c_int = 0x80000; +pub const EPROTO: c_int = 0x47; +pub const EPROTONOSUPPORT: c_int = 0x5d; +pub const EPROTOTYPE: c_int = 0x5b; +pub const EREMCHG: c_int = 0x4e; +pub const EREMOTE: c_int = 0x42; +pub const EREMOTEIO: c_int = 0x79; +pub const ERESTART: c_int = 0x55; +pub const ERFKILL: c_int = 0x84; +pub const ESHUTDOWN: c_int = 0x6c; +pub const ESOCKTNOSUPPORT: c_int = 0x5e; +pub const ESRMNT: c_int = 0x45; +pub const ESTALE: c_int = 0x74; +pub const ESTRPIPE: c_int = 0x56; +pub const ETIME: c_int = 0x3e; +pub const ETIMEDOUT: c_int = 0x6e; +pub const ETOOMANYREFS: c_int = 0x6d; +pub const EUCLEAN: c_int = 0x75; +pub const EUNATCH: c_int = 0x31; +pub const EUSERS: c_int = 0x57; +pub const EXFULL: c_int = 0x36; +pub const FF1: c_int = 0x8000; +pub const FFDLY: c_int = 0x8000; +pub const FLUSHO: crate::tcflag_t = 0x1000; +pub const F_GETLK: c_int = 0x5; +pub const F_SETLK: c_int = 0x6; +pub const F_SETLKW: c_int = 0x7; +pub const HUPCL: crate::tcflag_t = 0x400; +pub const ICANON: crate::tcflag_t = 0x2; +pub const IEXTEN: crate::tcflag_t = 0x8000; +pub const ISIG: crate::tcflag_t = 0x1; +pub const IXOFF: crate::tcflag_t = 0x1000; +pub const IXON: crate::tcflag_t = 0x400; +pub const MAP_ANON: c_int = 0x20; +pub const MAP_ANONYMOUS: c_int = 0x20; +pub const MAP_DENYWRITE: c_int = 0x800; +pub const MAP_EXECUTABLE: c_int = 0x1000; +pub const MAP_GROWSDOWN: c_int = 0x100; +pub const MAP_LOCKED: c_int = 0x2000; +pub const MAP_NONBLOCK: c_int = 0x10000; +pub const MAP_NORESERVE: c_int = 0x4000; +pub const MAP_POPULATE: c_int = 0x8000; +pub const MAP_STACK: c_int = 0x20000; +pub const NLDLY: crate::tcflag_t = 0x100; +pub const NOFLSH: crate::tcflag_t = 0x80; +pub const OLCUC: crate::tcflag_t = 0x2; +pub const ONLCR: crate::tcflag_t = 0x4; +pub const O_ACCMODE: c_int = 0x3; +pub const O_APPEND: c_int = 0x400; +pub const O_ASYNC: c_int = 0o20000; +pub const O_CREAT: c_int = 0x40; +pub const O_DIRECT: c_int = 0x10000; +pub const O_DIRECTORY: c_int = 0x4000; +pub const O_DSYNC: c_int = O_SYNC; +pub const O_EXCL: c_int = 0x80; +pub const O_FSYNC: c_int = O_SYNC; +pub const O_LARGEFILE: c_int = 0o400000; +pub const O_NDELAY: c_int = O_NONBLOCK; +pub const O_NOATIME: c_int = 0o1000000; +pub const O_NOCTTY: c_int = 0x100; +pub const O_NOFOLLOW: c_int = 0x8000; +pub const O_NONBLOCK: c_int = 0x800; +pub const O_PATH: c_int = 0o10000000; +pub const O_RSYNC: c_int = O_SYNC; +pub const O_SYNC: c_int = 0o10000; +pub const O_TRUNC: c_int = 0x200; +pub const PARENB: crate::tcflag_t = 0x100; +pub const PARODD: crate::tcflag_t = 0x200; +pub const PENDIN: crate::tcflag_t = 0x4000; +pub const POLLWRBAND: c_short = 0x200; +pub const POLLWRNORM: c_short = 0x100; +pub const PTHREAD_STACK_MIN: size_t = 16384; +pub const RTLD_GLOBAL: c_int = 0x00100; + +// These are typed unsigned to match sigaction +pub const SA_NOCLDSTOP: c_ulong = 0x1; +pub const SA_NOCLDWAIT: c_ulong = 0x2; +pub const SA_SIGINFO: c_ulong = 0x4; +pub const SA_NODEFER: c_ulong = 0x40000000; +pub const SA_ONSTACK: c_ulong = 0x8000000; +pub const SA_RESETHAND: c_ulong = 0x80000000; +pub const SA_RESTART: c_ulong = 0x10000000; + +pub const SFD_CLOEXEC: c_int = 0x80000; +pub const SFD_NONBLOCK: c_int = 0x800; +pub const SIGBUS: c_int = 0x7; +pub const SIGCHLD: c_int = 0x11; +pub const SIGCONT: c_int = 0x12; +pub const SIGIO: c_int = 0x1d; +pub const SIGPROF: c_int = 0x1b; +pub const SIGPWR: c_int = 0x1e; +pub const SIGSTKFLT: c_int = 0x10; +pub const SIGSTKSZ: size_t = 8192; +pub const SIGSTOP: c_int = 0x13; +pub const SIGSYS: c_int = 0x1f; +pub const SIGTSTP: c_int = 0x14; +pub const SIGTTIN: c_int = 0x15; +pub const SIGTTOU: c_int = 0x16; +pub const SIGURG: c_int = 0x17; +pub const SIGUSR1: c_int = 0xa; +pub const SIGUSR2: c_int = 0xc; +pub const SIGVTALRM: c_int = 0x1a; +pub const SIGWINCH: c_int = 0x1c; +pub const SIGXCPU: c_int = 0x18; +pub const SIGXFSZ: c_int = 0x19; +pub const SIG_BLOCK: c_int = 0; +pub const SIG_SETMASK: c_int = 0x2; +pub const SIG_UNBLOCK: c_int = 0x1; +pub const SOCK_DGRAM: c_int = 0x2; +pub const SOCK_NONBLOCK: c_int = 0o0004000; +pub const SOCK_SEQPACKET: c_int = 0x5; +pub const SOCK_STREAM: c_int = 0x1; + +pub const TAB1: c_int = 0x800; +pub const TAB2: c_int = 0x1000; +pub const TAB3: c_int = 0x1800; +pub const TABDLY: c_int = 0x1800; +pub const TCSADRAIN: c_int = 0x1; +pub const TCSAFLUSH: c_int = 0x2; +pub const TCSANOW: c_int = 0; +pub const TOSTOP: crate::tcflag_t = 0x100; +pub const VDISCARD: usize = 0xd; +pub const VEOF: usize = 0x4; +pub const VEOL: usize = 0xb; +pub const VEOL2: usize = 0x10; +pub const VMIN: usize = 0x6; +pub const VREPRINT: usize = 0xc; +pub const VSTART: usize = 0x8; +pub const VSTOP: usize = 0x9; +pub const VSUSP: usize = 0xa; +pub const VSWTC: usize = 0x7; +pub const VT1: c_int = 0x4000; +pub const VTDLY: c_int = 0x4000; +pub const VTIME: usize = 0x5; +pub const VWERASE: usize = 0xe; +pub const XTABS: crate::tcflag_t = 0x1800; + +pub const MADV_SOFT_OFFLINE: c_int = 101; + +// Syscall table is copied from src/unix/notbsd/linux/musl/b32/arm.rs +pub const SYS_restart_syscall: c_long = 0; +pub const SYS_exit: c_long = 1; +pub const SYS_fork: c_long = 2; +pub const SYS_read: c_long = 3; +pub const SYS_write: c_long = 4; +pub const SYS_open: c_long = 5; +pub const SYS_close: c_long = 6; +pub const SYS_creat: c_long = 8; +pub const SYS_link: c_long = 9; +pub const SYS_unlink: c_long = 10; +pub const SYS_execve: c_long = 11; +pub const SYS_chdir: c_long = 12; +pub const SYS_mknod: c_long = 14; +pub const SYS_chmod: c_long = 15; +pub const SYS_lchown: c_long = 16; +pub const SYS_lseek: c_long = 19; +pub const SYS_getpid: c_long = 20; +pub const SYS_mount: c_long = 21; +pub const SYS_setuid: c_long = 23; +pub const SYS_getuid: c_long = 24; +pub const SYS_ptrace: c_long = 26; +pub const SYS_pause: c_long = 29; +pub const SYS_access: c_long = 33; +pub const SYS_nice: c_long = 34; +pub const SYS_sync: c_long = 36; +pub const SYS_kill: c_long = 37; +pub const SYS_rename: c_long = 38; +pub const SYS_mkdir: c_long = 39; +pub const SYS_rmdir: c_long = 40; +pub const SYS_dup: c_long = 41; +pub const SYS_pipe: c_long = 42; +pub const SYS_times: c_long = 43; +pub const SYS_brk: c_long = 45; +pub const SYS_setgid: c_long = 46; +pub const SYS_getgid: c_long = 47; +pub const SYS_geteuid: c_long = 49; +pub const SYS_getegid: c_long = 50; +pub const SYS_acct: c_long = 51; +pub const SYS_umount2: c_long = 52; +pub const SYS_ioctl: c_long = 54; +pub const SYS_fcntl: c_long = 55; +pub const SYS_setpgid: c_long = 57; +pub const SYS_umask: c_long = 60; +pub const SYS_chroot: c_long = 61; +pub const SYS_ustat: c_long = 62; +pub const SYS_dup2: c_long = 63; +pub const SYS_getppid: c_long = 64; +pub const SYS_getpgrp: c_long = 65; +pub const SYS_setsid: c_long = 66; +pub const SYS_sigaction: c_long = 67; +pub const SYS_setreuid: c_long = 70; +pub const SYS_setregid: c_long = 71; +pub const SYS_sigsuspend: c_long = 72; +pub const SYS_sigpending: c_long = 73; +pub const SYS_sethostname: c_long = 74; +pub const SYS_setrlimit: c_long = 75; +pub const SYS_getrusage: c_long = 77; +pub const SYS_gettimeofday: c_long = 78; +pub const SYS_settimeofday: c_long = 79; +pub const SYS_getgroups: c_long = 80; +pub const SYS_setgroups: c_long = 81; +pub const SYS_symlink: c_long = 83; +pub const SYS_readlink: c_long = 85; +pub const SYS_uselib: c_long = 86; +pub const SYS_swapon: c_long = 87; +pub const SYS_reboot: c_long = 88; +pub const SYS_munmap: c_long = 91; +pub const SYS_truncate: c_long = 92; +pub const SYS_ftruncate: c_long = 93; +pub const SYS_fchmod: c_long = 94; +pub const SYS_fchown: c_long = 95; +pub const SYS_getpriority: c_long = 96; +pub const SYS_setpriority: c_long = 97; +pub const SYS_statfs: c_long = 99; +pub const SYS_fstatfs: c_long = 100; +pub const SYS_syslog: c_long = 103; +pub const SYS_setitimer: c_long = 104; +pub const SYS_getitimer: c_long = 105; +pub const SYS_stat: c_long = 106; +pub const SYS_lstat: c_long = 107; +pub const SYS_fstat: c_long = 108; +pub const SYS_vhangup: c_long = 111; +pub const SYS_wait4: c_long = 114; +pub const SYS_swapoff: c_long = 115; +pub const SYS_sysinfo: c_long = 116; +pub const SYS_fsync: c_long = 118; +pub const SYS_sigreturn: c_long = 119; +pub const SYS_clone: c_long = 120; +pub const SYS_setdomainname: c_long = 121; +pub const SYS_uname: c_long = 122; +pub const SYS_adjtimex: c_long = 124; +pub const SYS_mprotect: c_long = 125; +pub const SYS_sigprocmask: c_long = 126; +pub const SYS_init_module: c_long = 128; +pub const SYS_delete_module: c_long = 129; +pub const SYS_quotactl: c_long = 131; +pub const SYS_getpgid: c_long = 132; +pub const SYS_fchdir: c_long = 133; +pub const SYS_bdflush: c_long = 134; +pub const SYS_sysfs: c_long = 135; +pub const SYS_personality: c_long = 136; +pub const SYS_setfsuid: c_long = 138; +pub const SYS_setfsgid: c_long = 139; +pub const SYS__llseek: c_long = 140; +pub const SYS_getdents: c_long = 141; +pub const SYS__newselect: c_long = 142; +pub const SYS_flock: c_long = 143; +pub const SYS_msync: c_long = 144; +pub const SYS_readv: c_long = 145; +pub const SYS_writev: c_long = 146; +pub const SYS_getsid: c_long = 147; +pub const SYS_fdatasync: c_long = 148; +pub const SYS__sysctl: c_long = 149; +pub const SYS_mlock: c_long = 150; +pub const SYS_munlock: c_long = 151; +pub const SYS_mlockall: c_long = 152; +pub const SYS_munlockall: c_long = 153; +pub const SYS_sched_setparam: c_long = 154; +pub const SYS_sched_getparam: c_long = 155; +pub const SYS_sched_setscheduler: c_long = 156; +pub const SYS_sched_getscheduler: c_long = 157; +pub const SYS_sched_yield: c_long = 158; +pub const SYS_sched_get_priority_max: c_long = 159; +pub const SYS_sched_get_priority_min: c_long = 160; +pub const SYS_sched_rr_get_interval: c_long = 161; +pub const SYS_nanosleep: c_long = 162; +pub const SYS_mremap: c_long = 163; +pub const SYS_setresuid: c_long = 164; +pub const SYS_getresuid: c_long = 165; +pub const SYS_poll: c_long = 168; +pub const SYS_nfsservctl: c_long = 169; +pub const SYS_setresgid: c_long = 170; +pub const SYS_getresgid: c_long = 171; +pub const SYS_prctl: c_long = 172; +pub const SYS_rt_sigreturn: c_long = 173; +pub const SYS_rt_sigaction: c_long = 174; +pub const SYS_rt_sigprocmask: c_long = 175; +pub const SYS_rt_sigpending: c_long = 176; +pub const SYS_rt_sigtimedwait: c_long = 177; +pub const SYS_rt_sigqueueinfo: c_long = 178; +pub const SYS_rt_sigsuspend: c_long = 179; +pub const SYS_pread64: c_long = 180; +pub const SYS_pwrite64: c_long = 181; +pub const SYS_chown: c_long = 182; +pub const SYS_getcwd: c_long = 183; +pub const SYS_capget: c_long = 184; +pub const SYS_capset: c_long = 185; +pub const SYS_sigaltstack: c_long = 186; +pub const SYS_sendfile: c_long = 187; +pub const SYS_vfork: c_long = 190; +pub const SYS_ugetrlimit: c_long = 191; +pub const SYS_mmap2: c_long = 192; +pub const SYS_truncate64: c_long = 193; +pub const SYS_ftruncate64: c_long = 194; +pub const SYS_stat64: c_long = 195; +pub const SYS_lstat64: c_long = 196; +pub const SYS_fstat64: c_long = 197; +pub const SYS_lchown32: c_long = 198; +pub const SYS_getuid32: c_long = 199; +pub const SYS_getgid32: c_long = 200; +pub const SYS_geteuid32: c_long = 201; +pub const SYS_getegid32: c_long = 202; +pub const SYS_setreuid32: c_long = 203; +pub const SYS_setregid32: c_long = 204; +pub const SYS_getgroups32: c_long = 205; +pub const SYS_setgroups32: c_long = 206; +pub const SYS_fchown32: c_long = 207; +pub const SYS_setresuid32: c_long = 208; +pub const SYS_getresuid32: c_long = 209; +pub const SYS_setresgid32: c_long = 210; +pub const SYS_getresgid32: c_long = 211; +pub const SYS_chown32: c_long = 212; +pub const SYS_setuid32: c_long = 213; +pub const SYS_setgid32: c_long = 214; +pub const SYS_setfsuid32: c_long = 215; +pub const SYS_setfsgid32: c_long = 216; +pub const SYS_getdents64: c_long = 217; +pub const SYS_pivot_root: c_long = 218; +pub const SYS_mincore: c_long = 219; +pub const SYS_madvise: c_long = 220; +pub const SYS_fcntl64: c_long = 221; +pub const SYS_gettid: c_long = 224; +pub const SYS_readahead: c_long = 225; +pub const SYS_setxattr: c_long = 226; +pub const SYS_lsetxattr: c_long = 227; +pub const SYS_fsetxattr: c_long = 228; +pub const SYS_getxattr: c_long = 229; +pub const SYS_lgetxattr: c_long = 230; +pub const SYS_fgetxattr: c_long = 231; +pub const SYS_listxattr: c_long = 232; +pub const SYS_llistxattr: c_long = 233; +pub const SYS_flistxattr: c_long = 234; +pub const SYS_removexattr: c_long = 235; +pub const SYS_lremovexattr: c_long = 236; +pub const SYS_fremovexattr: c_long = 237; +pub const SYS_tkill: c_long = 238; +pub const SYS_sendfile64: c_long = 239; +pub const SYS_futex: c_long = 240; +pub const SYS_sched_setaffinity: c_long = 241; +pub const SYS_sched_getaffinity: c_long = 242; +pub const SYS_io_setup: c_long = 243; +pub const SYS_io_destroy: c_long = 244; +pub const SYS_io_getevents: c_long = 245; +pub const SYS_io_submit: c_long = 246; +pub const SYS_io_cancel: c_long = 247; +pub const SYS_exit_group: c_long = 248; +pub const SYS_lookup_dcookie: c_long = 249; +pub const SYS_epoll_create: c_long = 250; +pub const SYS_epoll_ctl: c_long = 251; +pub const SYS_epoll_wait: c_long = 252; +pub const SYS_remap_file_pages: c_long = 253; +pub const SYS_set_tid_address: c_long = 256; +pub const SYS_timer_create: c_long = 257; +pub const SYS_timer_settime: c_long = 258; +pub const SYS_timer_gettime: c_long = 259; +pub const SYS_timer_getoverrun: c_long = 260; +pub const SYS_timer_delete: c_long = 261; +pub const SYS_clock_settime: c_long = 262; +pub const SYS_clock_gettime: c_long = 263; +pub const SYS_clock_getres: c_long = 264; +pub const SYS_clock_nanosleep: c_long = 265; +pub const SYS_statfs64: c_long = 266; +pub const SYS_fstatfs64: c_long = 267; +pub const SYS_tgkill: c_long = 268; +pub const SYS_utimes: c_long = 269; +pub const SYS_pciconfig_iobase: c_long = 271; +pub const SYS_pciconfig_read: c_long = 272; +pub const SYS_pciconfig_write: c_long = 273; +pub const SYS_mq_open: c_long = 274; +pub const SYS_mq_unlink: c_long = 275; +pub const SYS_mq_timedsend: c_long = 276; +pub const SYS_mq_timedreceive: c_long = 277; +pub const SYS_mq_notify: c_long = 278; +pub const SYS_mq_getsetattr: c_long = 279; +pub const SYS_waitid: c_long = 280; +pub const SYS_socket: c_long = 281; +pub const SYS_bind: c_long = 282; +pub const SYS_connect: c_long = 283; +pub const SYS_listen: c_long = 284; +pub const SYS_accept: c_long = 285; +pub const SYS_getsockname: c_long = 286; +pub const SYS_getpeername: c_long = 287; +pub const SYS_socketpair: c_long = 288; +pub const SYS_send: c_long = 289; +pub const SYS_sendto: c_long = 290; +pub const SYS_recv: c_long = 291; +pub const SYS_recvfrom: c_long = 292; +pub const SYS_shutdown: c_long = 293; +pub const SYS_setsockopt: c_long = 294; +pub const SYS_getsockopt: c_long = 295; +pub const SYS_sendmsg: c_long = 296; +pub const SYS_recvmsg: c_long = 297; +pub const SYS_semop: c_long = 298; +pub const SYS_semget: c_long = 299; +pub const SYS_semctl: c_long = 300; +pub const SYS_msgsnd: c_long = 301; +pub const SYS_msgrcv: c_long = 302; +pub const SYS_msgget: c_long = 303; +pub const SYS_msgctl: c_long = 304; +pub const SYS_shmat: c_long = 305; +pub const SYS_shmdt: c_long = 306; +pub const SYS_shmget: c_long = 307; +pub const SYS_shmctl: c_long = 308; +pub const SYS_add_key: c_long = 309; +pub const SYS_request_key: c_long = 310; +pub const SYS_keyctl: c_long = 311; +pub const SYS_semtimedop: c_long = 312; +pub const SYS_vserver: c_long = 313; +pub const SYS_ioprio_set: c_long = 314; +pub const SYS_ioprio_get: c_long = 315; +pub const SYS_inotify_init: c_long = 316; +pub const SYS_inotify_add_watch: c_long = 317; +pub const SYS_inotify_rm_watch: c_long = 318; +pub const SYS_mbind: c_long = 319; +pub const SYS_get_mempolicy: c_long = 320; +pub const SYS_set_mempolicy: c_long = 321; +pub const SYS_openat: c_long = 322; +pub const SYS_mkdirat: c_long = 323; +pub const SYS_mknodat: c_long = 324; +pub const SYS_fchownat: c_long = 325; +pub const SYS_futimesat: c_long = 326; +pub const SYS_fstatat64: c_long = 327; +pub const SYS_unlinkat: c_long = 328; +pub const SYS_renameat: c_long = 329; +pub const SYS_linkat: c_long = 330; +pub const SYS_symlinkat: c_long = 331; +pub const SYS_readlinkat: c_long = 332; +pub const SYS_fchmodat: c_long = 333; +pub const SYS_faccessat: c_long = 334; +pub const SYS_pselect6: c_long = 335; +pub const SYS_ppoll: c_long = 336; +pub const SYS_unshare: c_long = 337; +pub const SYS_set_robust_list: c_long = 338; +pub const SYS_get_robust_list: c_long = 339; +pub const SYS_splice: c_long = 340; +pub const SYS_tee: c_long = 342; +pub const SYS_vmsplice: c_long = 343; +pub const SYS_move_pages: c_long = 344; +pub const SYS_getcpu: c_long = 345; +pub const SYS_epoll_pwait: c_long = 346; +pub const SYS_kexec_load: c_long = 347; +pub const SYS_utimensat: c_long = 348; +pub const SYS_signalfd: c_long = 349; +pub const SYS_timerfd_create: c_long = 350; +pub const SYS_eventfd: c_long = 351; +pub const SYS_fallocate: c_long = 352; +pub const SYS_timerfd_settime: c_long = 353; +pub const SYS_timerfd_gettime: c_long = 354; +pub const SYS_signalfd4: c_long = 355; +pub const SYS_eventfd2: c_long = 356; +pub const SYS_epoll_create1: c_long = 357; +pub const SYS_dup3: c_long = 358; +pub const SYS_pipe2: c_long = 359; +pub const SYS_inotify_init1: c_long = 360; +pub const SYS_preadv: c_long = 361; +pub const SYS_pwritev: c_long = 362; +pub const SYS_rt_tgsigqueueinfo: c_long = 363; +pub const SYS_perf_event_open: c_long = 364; +pub const SYS_recvmmsg: c_long = 365; +pub const SYS_accept4: c_long = 366; +pub const SYS_fanotify_init: c_long = 367; +pub const SYS_fanotify_mark: c_long = 368; +pub const SYS_prlimit64: c_long = 369; +pub const SYS_name_to_handle_at: c_long = 370; +pub const SYS_open_by_handle_at: c_long = 371; +pub const SYS_clock_adjtime: c_long = 372; +pub const SYS_syncfs: c_long = 373; +pub const SYS_sendmmsg: c_long = 374; +pub const SYS_setns: c_long = 375; +pub const SYS_process_vm_readv: c_long = 376; +pub const SYS_process_vm_writev: c_long = 377; +pub const SYS_kcmp: c_long = 378; +pub const SYS_finit_module: c_long = 379; +pub const SYS_sched_setattr: c_long = 380; +pub const SYS_sched_getattr: c_long = 381; +pub const SYS_renameat2: c_long = 382; +pub const SYS_seccomp: c_long = 383; +pub const SYS_getrandom: c_long = 384; +pub const SYS_memfd_create: c_long = 385; +pub const SYS_bpf: c_long = 386; +pub const SYS_execveat: c_long = 387; +pub const SYS_userfaultfd: c_long = 388; +pub const SYS_membarrier: c_long = 389; +pub const SYS_mlock2: c_long = 390; +pub const SYS_copy_file_range: c_long = 391; +pub const SYS_preadv2: c_long = 392; +pub const SYS_pwritev2: c_long = 393; +pub const SYS_pkey_mprotect: c_long = 394; +pub const SYS_pkey_alloc: c_long = 395; +pub const SYS_pkey_free: c_long = 396; +// FIXME(linux): should be a `c_long` too, but a bug slipped in. +pub const SYS_statx: c_int = 397; +pub const SYS_pidfd_send_signal: c_long = 424; +pub const SYS_io_uring_setup: c_long = 425; +pub const SYS_io_uring_enter: c_long = 426; +pub const SYS_io_uring_register: c_long = 427; +pub const SYS_open_tree: c_long = 428; +pub const SYS_move_mount: c_long = 429; +pub const SYS_fsopen: c_long = 430; +pub const SYS_fsconfig: c_long = 431; +pub const SYS_fsmount: c_long = 432; +pub const SYS_fspick: c_long = 433; +pub const SYS_pidfd_open: c_long = 434; +pub const SYS_clone3: c_long = 435; +pub const SYS_close_range: c_long = 436; +pub const SYS_openat2: c_long = 437; +pub const SYS_pidfd_getfd: c_long = 438; +pub const SYS_faccessat2: c_long = 439; +pub const SYS_process_madvise: c_long = 440; +pub const SYS_epoll_pwait2: c_long = 441; +pub const SYS_mount_setattr: c_long = 442; +pub const SYS_quotactl_fd: c_long = 443; +pub const SYS_landlock_create_ruleset: c_long = 444; +pub const SYS_landlock_add_rule: c_long = 445; +pub const SYS_landlock_restrict_self: c_long = 446; +pub const SYS_memfd_secret: c_long = 447; +pub const SYS_process_mrelease: c_long = 448; +pub const SYS_futex_waitv: c_long = 449; +pub const SYS_set_mempolicy_home_node: c_long = 450; diff --git a/http/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs new file mode 100644 index 0000000..93ed7ab --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs @@ -0,0 +1,695 @@ +use crate::off64_t; +use crate::prelude::*; + +pub type clock_t = i32; +pub type time_t = i32; +pub type suseconds_t = i32; +pub type wchar_t = i32; +pub type off_t = i32; +pub type ino_t = u32; +pub type blkcnt_t = i32; +pub type blksize_t = i32; +pub type nlink_t = u32; +pub type fsblkcnt_t = c_ulong; +pub type fsfilcnt_t = c_ulong; +pub type __u64 = c_ulonglong; +pub type __s64 = c_longlong; +pub type fsblkcnt64_t = u64; +pub type fsfilcnt64_t = u64; + +s! { + pub struct stat { + pub st_dev: crate::dev_t, + st_pad1: Padding<[c_long; 2]>, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + pub st_pad2: [c_long; 1], + pub st_size: off_t, + st_pad3: Padding, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + st_pad5: Padding<[c_long; 14]>, + } + + pub struct stat64 { + pub st_dev: crate::dev_t, + st_pad1: Padding<[c_long; 2]>, + pub st_ino: crate::ino64_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + st_pad2: Padding<[c_long; 2]>, + pub st_size: off64_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + pub st_blksize: crate::blksize_t, + st_pad3: Padding, + pub st_blocks: crate::blkcnt64_t, + st_pad5: Padding<[c_long; 14]>, + } + + pub struct statvfs64 { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt64_t, + pub f_bfree: crate::fsblkcnt64_t, + pub f_bavail: crate::fsblkcnt64_t, + pub f_files: crate::fsfilcnt64_t, + pub f_ffree: crate::fsfilcnt64_t, + pub f_favail: crate::fsfilcnt64_t, + pub f_fsid: c_ulong, + pub __f_unused: c_int, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + pub __f_spare: [c_int; 6], + } + + pub struct pthread_attr_t { + __size: [u32; 9], + } + + pub struct sigaction { + pub sa_flags: c_uint, + pub sa_sigaction: crate::sighandler_t, + pub sa_mask: sigset_t, + _restorer: *mut c_void, + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_size: size_t, + pub ss_flags: c_int, + } + + pub struct sigset_t { + __val: [c_ulong; 4], + } + + pub struct siginfo_t { + pub si_signo: c_int, + pub si_code: c_int, + pub si_errno: c_int, + pub _pad: [c_int; 29], + } + + pub struct glob64_t { + pub gl_pathc: size_t, + pub gl_pathv: *mut *mut c_char, + pub gl_offs: size_t, + pub gl_flags: c_int, + + __unused1: Padding<*mut c_void>, + __unused2: Padding<*mut c_void>, + __unused3: Padding<*mut c_void>, + __unused4: Padding<*mut c_void>, + __unused5: Padding<*mut c_void>, + } + + pub struct ipc_perm { + pub __key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: c_uint, + pub __seq: c_ushort, + __pad1: Padding, + __unused1: Padding, + __unused2: Padding, + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, + pub shm_atime: crate::time_t, + pub shm_dtime: crate::time_t, + pub shm_ctime: crate::time_t, + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: crate::shmatt_t, + __unused4: Padding, + __unused5: Padding, + } + + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + #[cfg(target_endian = "big")] + __glibc_reserved1: Padding, + pub msg_stime: crate::time_t, + #[cfg(target_endian = "little")] + __glibc_reserved1: Padding, + #[cfg(target_endian = "big")] + __glibc_reserved2: Padding, + pub msg_rtime: crate::time_t, + #[cfg(target_endian = "little")] + __glibc_reserved2: Padding, + #[cfg(target_endian = "big")] + __glibc_reserved3: Padding, + pub msg_ctime: crate::time_t, + #[cfg(target_endian = "little")] + __glibc_reserved3: Padding, + pub __msg_cbytes: c_ulong, + pub msg_qnum: crate::msgqnum_t, + pub msg_qbytes: crate::msglen_t, + pub msg_lspid: crate::pid_t, + pub msg_lrpid: crate::pid_t, + __glibc_reserved4: Padding, + __glibc_reserved5: Padding, + } + + pub struct statfs { + pub f_type: c_long, + pub f_bsize: c_long, + pub f_frsize: c_long, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_files: crate::fsblkcnt_t, + pub f_ffree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_fsid: crate::fsid_t, + + pub f_namelen: c_long, + f_spare: [c_long; 6], + } + + pub struct statfs64 { + pub f_type: c_long, + pub f_bsize: c_long, + pub f_frsize: c_long, + pub f_blocks: crate::fsblkcnt64_t, + pub f_bfree: crate::fsblkcnt64_t, + pub f_files: crate::fsblkcnt64_t, + pub f_ffree: crate::fsblkcnt64_t, + pub f_bavail: crate::fsblkcnt64_t, + pub f_fsid: crate::fsid_t, + pub f_namelen: c_long, + pub f_flags: c_long, + pub f_spare: [c_long; 5], + } + + pub struct msghdr { + pub msg_name: *mut c_void, + pub msg_namelen: crate::socklen_t, + pub msg_iov: *mut crate::iovec, + pub msg_iovlen: c_int, + pub msg_control: *mut c_void, + pub msg_controllen: size_t, + pub msg_flags: c_int, + } + + pub struct cmsghdr { + pub cmsg_len: size_t, + pub cmsg_level: c_int, + pub cmsg_type: c_int, + } + + pub struct termios { + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_line: crate::cc_t, + pub c_cc: [crate::cc_t; crate::NCCS], + } + + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off_t, + pub l_len: off_t, + pub l_sysid: c_long, + pub l_pid: crate::pid_t, + pad: Padding<[c_long; 4]>, + } + + pub struct sysinfo { + pub uptime: c_long, + pub loads: [c_ulong; 3], + pub totalram: c_ulong, + pub freeram: c_ulong, + pub sharedram: c_ulong, + pub bufferram: c_ulong, + pub totalswap: c_ulong, + pub freeswap: c_ulong, + pub procs: c_ushort, + pub pad: c_ushort, + pub totalhigh: c_ulong, + pub freehigh: c_ulong, + pub mem_unit: c_uint, + pub _f: [c_char; 8], + } + + // FIXME(1.0): this is actually a union + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + pub struct sem_t { + #[cfg(target_pointer_width = "32")] + __size: [c_char; 16], + #[cfg(target_pointer_width = "64")] + __size: [c_char; 32], + } +} + +pub const __SIZEOF_PTHREAD_ATTR_T: usize = 36; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; +pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; +pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 20; +pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; + +pub const SYS_syscall: c_long = 4000 + 0; +pub const SYS_exit: c_long = 4000 + 1; +pub const SYS_fork: c_long = 4000 + 2; +pub const SYS_read: c_long = 4000 + 3; +pub const SYS_write: c_long = 4000 + 4; +pub const SYS_open: c_long = 4000 + 5; +pub const SYS_close: c_long = 4000 + 6; +pub const SYS_waitpid: c_long = 4000 + 7; +pub const SYS_creat: c_long = 4000 + 8; +pub const SYS_link: c_long = 4000 + 9; +pub const SYS_unlink: c_long = 4000 + 10; +pub const SYS_execve: c_long = 4000 + 11; +pub const SYS_chdir: c_long = 4000 + 12; +pub const SYS_time: c_long = 4000 + 13; +pub const SYS_mknod: c_long = 4000 + 14; +pub const SYS_chmod: c_long = 4000 + 15; +pub const SYS_lchown: c_long = 4000 + 16; +pub const SYS_break: c_long = 4000 + 17; +pub const SYS_lseek: c_long = 4000 + 19; +pub const SYS_getpid: c_long = 4000 + 20; +pub const SYS_mount: c_long = 4000 + 21; +pub const SYS_umount: c_long = 4000 + 22; +pub const SYS_setuid: c_long = 4000 + 23; +pub const SYS_getuid: c_long = 4000 + 24; +pub const SYS_stime: c_long = 4000 + 25; +pub const SYS_ptrace: c_long = 4000 + 26; +pub const SYS_alarm: c_long = 4000 + 27; +pub const SYS_pause: c_long = 4000 + 29; +pub const SYS_utime: c_long = 4000 + 30; +pub const SYS_stty: c_long = 4000 + 31; +pub const SYS_gtty: c_long = 4000 + 32; +pub const SYS_access: c_long = 4000 + 33; +pub const SYS_nice: c_long = 4000 + 34; +pub const SYS_ftime: c_long = 4000 + 35; +pub const SYS_sync: c_long = 4000 + 36; +pub const SYS_kill: c_long = 4000 + 37; +pub const SYS_rename: c_long = 4000 + 38; +pub const SYS_mkdir: c_long = 4000 + 39; +pub const SYS_rmdir: c_long = 4000 + 40; +pub const SYS_dup: c_long = 4000 + 41; +pub const SYS_pipe: c_long = 4000 + 42; +pub const SYS_times: c_long = 4000 + 43; +pub const SYS_prof: c_long = 4000 + 44; +pub const SYS_brk: c_long = 4000 + 45; +pub const SYS_setgid: c_long = 4000 + 46; +pub const SYS_getgid: c_long = 4000 + 47; +pub const SYS_signal: c_long = 4000 + 48; +pub const SYS_geteuid: c_long = 4000 + 49; +pub const SYS_getegid: c_long = 4000 + 50; +pub const SYS_acct: c_long = 4000 + 51; +pub const SYS_umount2: c_long = 4000 + 52; +pub const SYS_lock: c_long = 4000 + 53; +pub const SYS_ioctl: c_long = 4000 + 54; +pub const SYS_fcntl: c_long = 4000 + 55; +pub const SYS_mpx: c_long = 4000 + 56; +pub const SYS_setpgid: c_long = 4000 + 57; +pub const SYS_ulimit: c_long = 4000 + 58; +pub const SYS_umask: c_long = 4000 + 60; +pub const SYS_chroot: c_long = 4000 + 61; +pub const SYS_ustat: c_long = 4000 + 62; +pub const SYS_dup2: c_long = 4000 + 63; +pub const SYS_getppid: c_long = 4000 + 64; +pub const SYS_getpgrp: c_long = 4000 + 65; +pub const SYS_setsid: c_long = 4000 + 66; +pub const SYS_sigaction: c_long = 4000 + 67; +pub const SYS_sgetmask: c_long = 4000 + 68; +pub const SYS_ssetmask: c_long = 4000 + 69; +pub const SYS_setreuid: c_long = 4000 + 70; +pub const SYS_setregid: c_long = 4000 + 71; +pub const SYS_sigsuspend: c_long = 4000 + 72; +pub const SYS_sigpending: c_long = 4000 + 73; +pub const SYS_sethostname: c_long = 4000 + 74; +pub const SYS_setrlimit: c_long = 4000 + 75; +pub const SYS_getrlimit: c_long = 4000 + 76; +pub const SYS_getrusage: c_long = 4000 + 77; +pub const SYS_gettimeofday: c_long = 4000 + 78; +pub const SYS_settimeofday: c_long = 4000 + 79; +pub const SYS_getgroups: c_long = 4000 + 80; +pub const SYS_setgroups: c_long = 4000 + 81; +pub const SYS_symlink: c_long = 4000 + 83; +pub const SYS_readlink: c_long = 4000 + 85; +pub const SYS_uselib: c_long = 4000 + 86; +pub const SYS_swapon: c_long = 4000 + 87; +pub const SYS_reboot: c_long = 4000 + 88; +pub const SYS_readdir: c_long = 4000 + 89; +pub const SYS_mmap: c_long = 4000 + 90; +pub const SYS_munmap: c_long = 4000 + 91; +pub const SYS_truncate: c_long = 4000 + 92; +pub const SYS_ftruncate: c_long = 4000 + 93; +pub const SYS_fchmod: c_long = 4000 + 94; +pub const SYS_fchown: c_long = 4000 + 95; +pub const SYS_getpriority: c_long = 4000 + 96; +pub const SYS_setpriority: c_long = 4000 + 97; +pub const SYS_profil: c_long = 4000 + 98; +pub const SYS_statfs: c_long = 4000 + 99; +pub const SYS_fstatfs: c_long = 4000 + 100; +pub const SYS_ioperm: c_long = 4000 + 101; +pub const SYS_socketcall: c_long = 4000 + 102; +pub const SYS_syslog: c_long = 4000 + 103; +pub const SYS_setitimer: c_long = 4000 + 104; +pub const SYS_getitimer: c_long = 4000 + 105; +pub const SYS_stat: c_long = 4000 + 106; +pub const SYS_lstat: c_long = 4000 + 107; +pub const SYS_fstat: c_long = 4000 + 108; +pub const SYS_iopl: c_long = 4000 + 110; +pub const SYS_vhangup: c_long = 4000 + 111; +pub const SYS_idle: c_long = 4000 + 112; +pub const SYS_vm86: c_long = 4000 + 113; +pub const SYS_wait4: c_long = 4000 + 114; +pub const SYS_swapoff: c_long = 4000 + 115; +pub const SYS_sysinfo: c_long = 4000 + 116; +pub const SYS_ipc: c_long = 4000 + 117; +pub const SYS_fsync: c_long = 4000 + 118; +pub const SYS_sigreturn: c_long = 4000 + 119; +pub const SYS_clone: c_long = 4000 + 120; +pub const SYS_setdomainname: c_long = 4000 + 121; +pub const SYS_uname: c_long = 4000 + 122; +pub const SYS_modify_ldt: c_long = 4000 + 123; +pub const SYS_adjtimex: c_long = 4000 + 124; +pub const SYS_mprotect: c_long = 4000 + 125; +pub const SYS_sigprocmask: c_long = 4000 + 126; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_create_module: c_long = 4000 + 127; +pub const SYS_init_module: c_long = 4000 + 128; +pub const SYS_delete_module: c_long = 4000 + 129; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_get_kernel_syms: c_long = 4000 + 130; +pub const SYS_quotactl: c_long = 4000 + 131; +pub const SYS_getpgid: c_long = 4000 + 132; +pub const SYS_fchdir: c_long = 4000 + 133; +pub const SYS_bdflush: c_long = 4000 + 134; +pub const SYS_sysfs: c_long = 4000 + 135; +pub const SYS_personality: c_long = 4000 + 136; +pub const SYS_afs_syscall: c_long = 4000 + 137; +pub const SYS_setfsuid: c_long = 4000 + 138; +pub const SYS_setfsgid: c_long = 4000 + 139; +pub const SYS__llseek: c_long = 4000 + 140; +pub const SYS_getdents: c_long = 4000 + 141; +pub const SYS__newselect: c_long = 4000 + 142; +pub const SYS_flock: c_long = 4000 + 143; +pub const SYS_msync: c_long = 4000 + 144; +pub const SYS_readv: c_long = 4000 + 145; +pub const SYS_writev: c_long = 4000 + 146; +pub const SYS_cacheflush: c_long = 4000 + 147; +pub const SYS_cachectl: c_long = 4000 + 148; +pub const SYS_sysmips: c_long = 4000 + 149; +pub const SYS_getsid: c_long = 4000 + 151; +pub const SYS_fdatasync: c_long = 4000 + 152; +pub const SYS__sysctl: c_long = 4000 + 153; +pub const SYS_mlock: c_long = 4000 + 154; +pub const SYS_munlock: c_long = 4000 + 155; +pub const SYS_mlockall: c_long = 4000 + 156; +pub const SYS_munlockall: c_long = 4000 + 157; +pub const SYS_sched_setparam: c_long = 4000 + 158; +pub const SYS_sched_getparam: c_long = 4000 + 159; +pub const SYS_sched_setscheduler: c_long = 4000 + 160; +pub const SYS_sched_getscheduler: c_long = 4000 + 161; +pub const SYS_sched_yield: c_long = 4000 + 162; +pub const SYS_sched_get_priority_max: c_long = 4000 + 163; +pub const SYS_sched_get_priority_min: c_long = 4000 + 164; +pub const SYS_sched_rr_get_interval: c_long = 4000 + 165; +pub const SYS_nanosleep: c_long = 4000 + 166; +pub const SYS_mremap: c_long = 4000 + 167; +pub const SYS_accept: c_long = 4000 + 168; +pub const SYS_bind: c_long = 4000 + 169; +pub const SYS_connect: c_long = 4000 + 170; +pub const SYS_getpeername: c_long = 4000 + 171; +pub const SYS_getsockname: c_long = 4000 + 172; +pub const SYS_getsockopt: c_long = 4000 + 173; +pub const SYS_listen: c_long = 4000 + 174; +pub const SYS_recv: c_long = 4000 + 175; +pub const SYS_recvfrom: c_long = 4000 + 176; +pub const SYS_recvmsg: c_long = 4000 + 177; +pub const SYS_send: c_long = 4000 + 178; +pub const SYS_sendmsg: c_long = 4000 + 179; +pub const SYS_sendto: c_long = 4000 + 180; +pub const SYS_setsockopt: c_long = 4000 + 181; +pub const SYS_shutdown: c_long = 4000 + 182; +pub const SYS_socket: c_long = 4000 + 183; +pub const SYS_socketpair: c_long = 4000 + 184; +pub const SYS_setresuid: c_long = 4000 + 185; +pub const SYS_getresuid: c_long = 4000 + 186; +#[deprecated(since = "0.2.70", note = "Functional up to 2.6 kernel")] +pub const SYS_query_module: c_long = 4000 + 187; +pub const SYS_poll: c_long = 4000 + 188; +pub const SYS_nfsservctl: c_long = 4000 + 189; +pub const SYS_setresgid: c_long = 4000 + 190; +pub const SYS_getresgid: c_long = 4000 + 191; +pub const SYS_prctl: c_long = 4000 + 192; +pub const SYS_rt_sigreturn: c_long = 4000 + 193; +pub const SYS_rt_sigaction: c_long = 4000 + 194; +pub const SYS_rt_sigprocmask: c_long = 4000 + 195; +pub const SYS_rt_sigpending: c_long = 4000 + 196; +pub const SYS_rt_sigtimedwait: c_long = 4000 + 197; +pub const SYS_rt_sigqueueinfo: c_long = 4000 + 198; +pub const SYS_rt_sigsuspend: c_long = 4000 + 199; +pub const SYS_pread64: c_long = 4000 + 200; +pub const SYS_pwrite64: c_long = 4000 + 201; +pub const SYS_chown: c_long = 4000 + 202; +pub const SYS_getcwd: c_long = 4000 + 203; +pub const SYS_capget: c_long = 4000 + 204; +pub const SYS_capset: c_long = 4000 + 205; +pub const SYS_sigaltstack: c_long = 4000 + 206; +pub const SYS_sendfile: c_long = 4000 + 207; +pub const SYS_getpmsg: c_long = 4000 + 208; +pub const SYS_putpmsg: c_long = 4000 + 209; +pub const SYS_mmap2: c_long = 4000 + 210; +pub const SYS_truncate64: c_long = 4000 + 211; +pub const SYS_ftruncate64: c_long = 4000 + 212; +pub const SYS_stat64: c_long = 4000 + 213; +pub const SYS_lstat64: c_long = 4000 + 214; +pub const SYS_fstat64: c_long = 4000 + 215; +pub const SYS_pivot_root: c_long = 4000 + 216; +pub const SYS_mincore: c_long = 4000 + 217; +pub const SYS_madvise: c_long = 4000 + 218; +pub const SYS_getdents64: c_long = 4000 + 219; +pub const SYS_fcntl64: c_long = 4000 + 220; +pub const SYS_gettid: c_long = 4000 + 222; +pub const SYS_readahead: c_long = 4000 + 223; +pub const SYS_setxattr: c_long = 4000 + 224; +pub const SYS_lsetxattr: c_long = 4000 + 225; +pub const SYS_fsetxattr: c_long = 4000 + 226; +pub const SYS_getxattr: c_long = 4000 + 227; +pub const SYS_lgetxattr: c_long = 4000 + 228; +pub const SYS_fgetxattr: c_long = 4000 + 229; +pub const SYS_listxattr: c_long = 4000 + 230; +pub const SYS_llistxattr: c_long = 4000 + 231; +pub const SYS_flistxattr: c_long = 4000 + 232; +pub const SYS_removexattr: c_long = 4000 + 233; +pub const SYS_lremovexattr: c_long = 4000 + 234; +pub const SYS_fremovexattr: c_long = 4000 + 235; +pub const SYS_tkill: c_long = 4000 + 236; +pub const SYS_sendfile64: c_long = 4000 + 237; +pub const SYS_futex: c_long = 4000 + 238; +pub const SYS_sched_setaffinity: c_long = 4000 + 239; +pub const SYS_sched_getaffinity: c_long = 4000 + 240; +pub const SYS_io_setup: c_long = 4000 + 241; +pub const SYS_io_destroy: c_long = 4000 + 242; +pub const SYS_io_getevents: c_long = 4000 + 243; +pub const SYS_io_submit: c_long = 4000 + 244; +pub const SYS_io_cancel: c_long = 4000 + 245; +pub const SYS_exit_group: c_long = 4000 + 246; +pub const SYS_lookup_dcookie: c_long = 4000 + 247; +pub const SYS_epoll_create: c_long = 4000 + 248; +pub const SYS_epoll_ctl: c_long = 4000 + 249; +pub const SYS_epoll_wait: c_long = 4000 + 250; +pub const SYS_remap_file_pages: c_long = 4000 + 251; +pub const SYS_set_tid_address: c_long = 4000 + 252; +pub const SYS_restart_syscall: c_long = 4000 + 253; +pub const SYS_fadvise64: c_long = 4000 + 254; +pub const SYS_statfs64: c_long = 4000 + 255; +pub const SYS_fstatfs64: c_long = 4000 + 256; +pub const SYS_timer_create: c_long = 4000 + 257; +pub const SYS_timer_settime: c_long = 4000 + 258; +pub const SYS_timer_gettime: c_long = 4000 + 259; +pub const SYS_timer_getoverrun: c_long = 4000 + 260; +pub const SYS_timer_delete: c_long = 4000 + 261; +pub const SYS_clock_settime: c_long = 4000 + 262; +pub const SYS_clock_gettime: c_long = 4000 + 263; +pub const SYS_clock_getres: c_long = 4000 + 264; +pub const SYS_clock_nanosleep: c_long = 4000 + 265; +pub const SYS_tgkill: c_long = 4000 + 266; +pub const SYS_utimes: c_long = 4000 + 267; +pub const SYS_mbind: c_long = 4000 + 268; +pub const SYS_get_mempolicy: c_long = 4000 + 269; +pub const SYS_set_mempolicy: c_long = 4000 + 270; +pub const SYS_mq_open: c_long = 4000 + 271; +pub const SYS_mq_unlink: c_long = 4000 + 272; +pub const SYS_mq_timedsend: c_long = 4000 + 273; +pub const SYS_mq_timedreceive: c_long = 4000 + 274; +pub const SYS_mq_notify: c_long = 4000 + 275; +pub const SYS_mq_getsetattr: c_long = 4000 + 276; +pub const SYS_vserver: c_long = 4000 + 277; +pub const SYS_waitid: c_long = 4000 + 278; +/* pub const SYS_sys_setaltroot: c_long = 4000 + 279; */ +pub const SYS_add_key: c_long = 4000 + 280; +pub const SYS_request_key: c_long = 4000 + 281; +pub const SYS_keyctl: c_long = 4000 + 282; +pub const SYS_set_thread_area: c_long = 4000 + 283; +pub const SYS_inotify_init: c_long = 4000 + 284; +pub const SYS_inotify_add_watch: c_long = 4000 + 285; +pub const SYS_inotify_rm_watch: c_long = 4000 + 286; +pub const SYS_migrate_pages: c_long = 4000 + 287; +pub const SYS_openat: c_long = 4000 + 288; +pub const SYS_mkdirat: c_long = 4000 + 289; +pub const SYS_mknodat: c_long = 4000 + 290; +pub const SYS_fchownat: c_long = 4000 + 291; +pub const SYS_futimesat: c_long = 4000 + 292; +pub const SYS_fstatat64: c_long = 4000 + 293; +pub const SYS_unlinkat: c_long = 4000 + 294; +pub const SYS_renameat: c_long = 4000 + 295; +pub const SYS_linkat: c_long = 4000 + 296; +pub const SYS_symlinkat: c_long = 4000 + 297; +pub const SYS_readlinkat: c_long = 4000 + 298; +pub const SYS_fchmodat: c_long = 4000 + 299; +pub const SYS_faccessat: c_long = 4000 + 300; +pub const SYS_pselect6: c_long = 4000 + 301; +pub const SYS_ppoll: c_long = 4000 + 302; +pub const SYS_unshare: c_long = 4000 + 303; +pub const SYS_splice: c_long = 4000 + 304; +pub const SYS_sync_file_range: c_long = 4000 + 305; +pub const SYS_tee: c_long = 4000 + 306; +pub const SYS_vmsplice: c_long = 4000 + 307; +pub const SYS_move_pages: c_long = 4000 + 308; +pub const SYS_set_robust_list: c_long = 4000 + 309; +pub const SYS_get_robust_list: c_long = 4000 + 310; +pub const SYS_kexec_load: c_long = 4000 + 311; +pub const SYS_getcpu: c_long = 4000 + 312; +pub const SYS_epoll_pwait: c_long = 4000 + 313; +pub const SYS_ioprio_set: c_long = 4000 + 314; +pub const SYS_ioprio_get: c_long = 4000 + 315; +pub const SYS_utimensat: c_long = 4000 + 316; +pub const SYS_signalfd: c_long = 4000 + 317; +pub const SYS_timerfd: c_long = 4000 + 318; +pub const SYS_eventfd: c_long = 4000 + 319; +pub const SYS_fallocate: c_long = 4000 + 320; +pub const SYS_timerfd_create: c_long = 4000 + 321; +pub const SYS_timerfd_gettime: c_long = 4000 + 322; +pub const SYS_timerfd_settime: c_long = 4000 + 323; +pub const SYS_signalfd4: c_long = 4000 + 324; +pub const SYS_eventfd2: c_long = 4000 + 325; +pub const SYS_epoll_create1: c_long = 4000 + 326; +pub const SYS_dup3: c_long = 4000 + 327; +pub const SYS_pipe2: c_long = 4000 + 328; +pub const SYS_inotify_init1: c_long = 4000 + 329; +pub const SYS_preadv: c_long = 4000 + 330; +pub const SYS_pwritev: c_long = 4000 + 331; +pub const SYS_rt_tgsigqueueinfo: c_long = 4000 + 332; +pub const SYS_perf_event_open: c_long = 4000 + 333; +pub const SYS_accept4: c_long = 4000 + 334; +pub const SYS_recvmmsg: c_long = 4000 + 335; +pub const SYS_fanotify_init: c_long = 4000 + 336; +pub const SYS_fanotify_mark: c_long = 4000 + 337; +pub const SYS_prlimit64: c_long = 4000 + 338; +pub const SYS_name_to_handle_at: c_long = 4000 + 339; +pub const SYS_open_by_handle_at: c_long = 4000 + 340; +pub const SYS_clock_adjtime: c_long = 4000 + 341; +pub const SYS_syncfs: c_long = 4000 + 342; +pub const SYS_sendmmsg: c_long = 4000 + 343; +pub const SYS_setns: c_long = 4000 + 344; +pub const SYS_process_vm_readv: c_long = 4000 + 345; +pub const SYS_process_vm_writev: c_long = 4000 + 346; +pub const SYS_kcmp: c_long = 4000 + 347; +pub const SYS_finit_module: c_long = 4000 + 348; +pub const SYS_sched_setattr: c_long = 4000 + 349; +pub const SYS_sched_getattr: c_long = 4000 + 350; +pub const SYS_renameat2: c_long = 4000 + 351; +pub const SYS_seccomp: c_long = 4000 + 352; +pub const SYS_getrandom: c_long = 4000 + 353; +pub const SYS_memfd_create: c_long = 4000 + 354; +pub const SYS_bpf: c_long = 4000 + 355; +pub const SYS_execveat: c_long = 4000 + 356; +pub const SYS_userfaultfd: c_long = 4000 + 357; +pub const SYS_membarrier: c_long = 4000 + 358; +pub const SYS_mlock2: c_long = 4000 + 359; +pub const SYS_copy_file_range: c_long = 4000 + 360; +pub const SYS_preadv2: c_long = 4000 + 361; +pub const SYS_pwritev2: c_long = 4000 + 362; +pub const SYS_pkey_mprotect: c_long = 4000 + 363; +pub const SYS_pkey_alloc: c_long = 4000 + 364; +pub const SYS_pkey_free: c_long = 4000 + 365; +pub const SYS_statx: c_long = 4000 + 366; +pub const SYS_pidfd_send_signal: c_long = 4000 + 424; +pub const SYS_io_uring_setup: c_long = 4000 + 425; +pub const SYS_io_uring_enter: c_long = 4000 + 426; +pub const SYS_io_uring_register: c_long = 4000 + 427; +pub const SYS_open_tree: c_long = 4000 + 428; +pub const SYS_move_mount: c_long = 4000 + 429; +pub const SYS_fsopen: c_long = 4000 + 430; +pub const SYS_fsconfig: c_long = 4000 + 431; +pub const SYS_fsmount: c_long = 4000 + 432; +pub const SYS_fspick: c_long = 4000 + 433; +pub const SYS_pidfd_open: c_long = 4000 + 434; +pub const SYS_clone3: c_long = 4000 + 435; +pub const SYS_close_range: c_long = 4000 + 436; +pub const SYS_openat2: c_long = 4000 + 437; +pub const SYS_pidfd_getfd: c_long = 4000 + 438; +pub const SYS_faccessat2: c_long = 4000 + 439; +pub const SYS_process_madvise: c_long = 4000 + 440; +pub const SYS_epoll_pwait2: c_long = 4000 + 441; +pub const SYS_mount_setattr: c_long = 4000 + 442; +pub const SYS_quotactl_fd: c_long = 4000 + 443; +pub const SYS_landlock_create_ruleset: c_long = 4000 + 444; +pub const SYS_landlock_add_rule: c_long = 4000 + 445; +pub const SYS_landlock_restrict_self: c_long = 4000 + 446; +pub const SYS_memfd_secret: c_long = 4000 + 447; +pub const SYS_process_mrelease: c_long = 4000 + 448; +pub const SYS_futex_waitv: c_long = 4000 + 449; +pub const SYS_set_mempolicy_home_node: c_long = 4000 + 450; + +#[link(name = "util")] +extern "C" { + pub fn sysctl( + name: *mut c_int, + namelen: c_int, + oldp: *mut c_void, + oldlenp: *mut size_t, + newp: *mut c_void, + newlen: size_t, + ) -> c_int; + pub fn glob64( + pattern: *const c_char, + flags: c_int, + errfunc: Option c_int>, + pglob: *mut glob64_t, + ) -> c_int; + pub fn globfree64(pglob: *mut glob64_t); + pub fn pthread_attr_getaffinity_np( + attr: *const crate::pthread_attr_t, + cpusetsize: size_t, + cpuset: *mut crate::cpu_set_t, + ) -> c_int; + pub fn pthread_attr_setaffinity_np( + attr: *mut crate::pthread_attr_t, + cpusetsize: size_t, + cpuset: *const crate::cpu_set_t, + ) -> c_int; +} diff --git a/http/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs new file mode 100644 index 0000000..4495181 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs @@ -0,0 +1,204 @@ +use crate::off64_t; +use crate::prelude::*; + +pub type blkcnt_t = i64; +pub type blksize_t = i64; +pub type fsblkcnt_t = c_ulong; +pub type fsfilcnt_t = c_ulong; +pub type ino_t = u64; +pub type nlink_t = u64; +pub type off_t = i64; +pub type suseconds_t = i64; +pub type time_t = i64; +pub type wchar_t = i32; + +s! { + pub struct stat { + pub st_dev: c_ulong, + st_pad1: Padding<[c_long; 2]>, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: c_ulong, + st_pad2: Padding<[c_ulong; 1]>, + pub st_size: off_t, + st_pad3: Padding, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + pub st_blksize: crate::blksize_t, + st_pad4: Padding, + pub st_blocks: crate::blkcnt_t, + st_pad5: Padding<[c_long; 7]>, + } + + pub struct stat64 { + pub st_dev: c_ulong, + st_pad1: Padding<[c_long; 2]>, + pub st_ino: crate::ino64_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: c_ulong, + st_pad2: Padding<[c_long; 2]>, + pub st_size: off64_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + pub st_blksize: crate::blksize_t, + st_pad3: Padding, + pub st_blocks: crate::blkcnt64_t, + st_pad5: Padding<[c_long; 7]>, + } + + pub struct pthread_attr_t { + __size: [c_ulong; 7], + } + + pub struct sigaction { + pub sa_flags: c_int, + pub sa_sigaction: crate::sighandler_t, + pub sa_mask: sigset_t, + _restorer: *mut c_void, + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_size: size_t, + pub ss_flags: c_int, + } + + pub struct sigset_t { + __size: [c_ulong; 16], + } + + pub struct siginfo_t { + pub si_signo: c_int, + pub si_code: c_int, + pub si_errno: c_int, + _pad: Padding, + _pad2: Padding<[c_long; 14]>, + } + + pub struct ipc_perm { + pub __key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: c_uint, + pub __seq: c_ushort, + __pad1: Padding, + __unused1: Padding, + __unused2: Padding, + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, + pub shm_atime: crate::time_t, + pub shm_dtime: crate::time_t, + pub shm_ctime: crate::time_t, + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: crate::shmatt_t, + __unused4: Padding, + __unused5: Padding, + } + + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + pub msg_stime: crate::time_t, + pub msg_rtime: crate::time_t, + pub msg_ctime: crate::time_t, + pub __msg_cbytes: c_ulong, + pub msg_qnum: crate::msgqnum_t, + pub msg_qbytes: crate::msglen_t, + pub msg_lspid: crate::pid_t, + pub msg_lrpid: crate::pid_t, + __glibc_reserved4: Padding, + __glibc_reserved5: Padding, + } + + pub struct statfs { + pub f_type: c_long, + pub f_bsize: c_long, + pub f_frsize: c_long, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_files: crate::fsblkcnt_t, + pub f_ffree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_fsid: crate::fsid_t, + + pub f_namelen: c_long, + f_spare: [c_long; 6], + } + + pub struct msghdr { + pub msg_name: *mut c_void, + pub msg_namelen: crate::socklen_t, + pub msg_iov: *mut crate::iovec, + pub msg_iovlen: size_t, + pub msg_control: *mut c_void, + pub msg_controllen: size_t, + pub msg_flags: c_int, + } + + pub struct cmsghdr { + pub cmsg_len: size_t, + pub cmsg_level: c_int, + pub cmsg_type: c_int, + } + + pub struct termios { + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_line: crate::cc_t, + pub c_cc: [crate::cc_t; crate::NCCS], + } + + pub struct sysinfo { + pub uptime: c_long, + pub loads: [c_ulong; 3], + pub totalram: c_ulong, + pub freeram: c_ulong, + pub sharedram: c_ulong, + pub bufferram: c_ulong, + pub totalswap: c_ulong, + pub freeswap: c_ulong, + pub procs: c_ushort, + pub pad: c_ushort, + pub totalhigh: c_ulong, + pub freehigh: c_ulong, + pub mem_unit: c_uint, + pub _f: [c_char; 0], + } + + // FIXME(1.0): this is actually a union + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + pub struct sem_t { + __size: [c_char; 32], + } +} + +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; +pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; + +pub const SYS_gettid: c_long = 5178; // Valid for n64 diff --git a/http/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mod.rs new file mode 100644 index 0000000..8d17aa8 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mod.rs @@ -0,0 +1,312 @@ +use crate::prelude::*; + +pub type pthread_t = c_ulong; + +pub const SFD_CLOEXEC: c_int = 0x080000; + +pub const NCCS: usize = 32; + +pub const O_TRUNC: c_int = 512; + +pub const O_CLOEXEC: c_int = 0x80000; + +pub const EBFONT: c_int = 59; +pub const ENOSTR: c_int = 60; +pub const ENODATA: c_int = 61; +pub const ETIME: c_int = 62; +pub const ENOSR: c_int = 63; +pub const ENONET: c_int = 64; +pub const ENOPKG: c_int = 65; +pub const EREMOTE: c_int = 66; +pub const ENOLINK: c_int = 67; +pub const EADV: c_int = 68; +pub const ESRMNT: c_int = 69; +pub const ECOMM: c_int = 70; +pub const EPROTO: c_int = 71; +pub const EDOTDOT: c_int = 73; + +pub const SA_NODEFER: c_uint = 0x40000000; +pub const SA_RESETHAND: c_uint = 0x80000000; +pub const SA_RESTART: c_uint = 0x10000000; +pub const SA_NOCLDSTOP: c_uint = 0x00000001; + +pub const EPOLL_CLOEXEC: c_int = 0x80000; + +pub const EFD_CLOEXEC: c_int = 0x80000; + +pub const TMP_MAX: c_uint = 238328; +pub const _SC_2_C_VERSION: c_int = 96; +pub const O_ACCMODE: c_int = 3; +pub const O_DIRECT: c_int = 0x8000; +pub const O_DIRECTORY: c_int = 0x10000; +pub const O_NOFOLLOW: c_int = 0x20000; +pub const O_NOATIME: c_int = 0x40000; +pub const O_PATH: c_int = 0o010000000; + +pub const O_APPEND: c_int = 8; +pub const O_CREAT: c_int = 256; +pub const O_EXCL: c_int = 1024; +pub const O_NOCTTY: c_int = 2048; +pub const O_NONBLOCK: c_int = 128; +pub const O_SYNC: c_int = 0x10; +pub const O_RSYNC: c_int = 0x10; +pub const O_DSYNC: c_int = 0x10; +pub const O_FSYNC: c_int = 0x10; +pub const O_ASYNC: c_int = 0x1000; +pub const O_LARGEFILE: c_int = 0x2000; +pub const O_NDELAY: c_int = 0x80; + +pub const SOCK_NONBLOCK: c_int = 128; + +pub const EDEADLK: c_int = 45; +pub const ENAMETOOLONG: c_int = 78; +pub const ENOLCK: c_int = 46; +pub const ENOSYS: c_int = 89; +pub const ENOTEMPTY: c_int = 93; +pub const ELOOP: c_int = 90; +pub const ENOMSG: c_int = 35; +pub const EIDRM: c_int = 36; +pub const ECHRNG: c_int = 37; +pub const EL2NSYNC: c_int = 38; +pub const EL3HLT: c_int = 39; +pub const EL3RST: c_int = 40; +pub const ELNRNG: c_int = 41; +pub const EUNATCH: c_int = 42; +pub const ENOCSI: c_int = 43; +pub const EL2HLT: c_int = 44; +pub const EBADE: c_int = 50; +pub const EBADR: c_int = 51; +pub const EXFULL: c_int = 52; +pub const FFDLY: c_int = 0o0100000; +pub const ENOANO: c_int = 53; +pub const EBADRQC: c_int = 54; +pub const EBADSLT: c_int = 55; +pub const EMULTIHOP: c_int = 74; +pub const EOVERFLOW: c_int = 79; +pub const ENOTUNIQ: c_int = 80; +pub const EBADFD: c_int = 81; +pub const EBADMSG: c_int = 77; +pub const EREMCHG: c_int = 82; +pub const ELIBACC: c_int = 83; +pub const ELIBBAD: c_int = 84; +pub const ELIBSCN: c_int = 85; +pub const ELIBMAX: c_int = 86; +pub const ELIBEXEC: c_int = 87; +pub const EILSEQ: c_int = 88; +pub const ERESTART: c_int = 91; +pub const ESTRPIPE: c_int = 92; +pub const EUSERS: c_int = 94; +pub const ENOTSOCK: c_int = 95; +pub const EDESTADDRREQ: c_int = 96; +pub const EMSGSIZE: c_int = 97; +pub const EPROTOTYPE: c_int = 98; +pub const ENOPROTOOPT: c_int = 99; +pub const EPROTONOSUPPORT: c_int = 120; +pub const ESOCKTNOSUPPORT: c_int = 121; +pub const EOPNOTSUPP: c_int = 122; +pub const EPFNOSUPPORT: c_int = 123; +pub const EAFNOSUPPORT: c_int = 124; +pub const EADDRINUSE: c_int = 125; +pub const EADDRNOTAVAIL: c_int = 126; +pub const ENETDOWN: c_int = 127; +pub const ENETUNREACH: c_int = 128; +pub const ENETRESET: c_int = 129; +pub const ECONNABORTED: c_int = 130; +pub const ECONNRESET: c_int = 131; +pub const ENOBUFS: c_int = 132; +pub const EISCONN: c_int = 133; +pub const ENOTCONN: c_int = 134; +pub const ESHUTDOWN: c_int = 143; +pub const ETOOMANYREFS: c_int = 144; +pub const ETIMEDOUT: c_int = 145; +pub const ECONNREFUSED: c_int = 146; +pub const EHOSTDOWN: c_int = 147; +pub const EHOSTUNREACH: c_int = 148; +pub const EALREADY: c_int = 149; +pub const EINPROGRESS: c_int = 150; +pub const ESTALE: c_int = 151; +pub const EUCLEAN: c_int = 135; +pub const ENOTNAM: c_int = 137; +pub const ENAVAIL: c_int = 138; +pub const EISNAM: c_int = 139; +pub const EREMOTEIO: c_int = 140; +pub const EDQUOT: c_int = 1133; +pub const ENOMEDIUM: c_int = 159; +pub const EMEDIUMTYPE: c_int = 160; +pub const ECANCELED: c_int = 158; +pub const ENOKEY: c_int = 161; +pub const EKEYEXPIRED: c_int = 162; +pub const EKEYREVOKED: c_int = 163; +pub const EKEYREJECTED: c_int = 164; +pub const EOWNERDEAD: c_int = 165; +pub const ENOTRECOVERABLE: c_int = 166; +pub const ERFKILL: c_int = 167; + +pub const MAP_NORESERVE: c_int = 0x400; +pub const MAP_ANON: c_int = 0x800; +pub const MAP_ANONYMOUS: c_int = 0x800; +pub const MAP_GROWSDOWN: c_int = 0x1000; +pub const MAP_DENYWRITE: c_int = 0x2000; +pub const MAP_EXECUTABLE: c_int = 0x4000; +pub const MAP_LOCKED: c_int = 0x8000; +pub const MAP_POPULATE: c_int = 0x10000; +pub const MAP_NONBLOCK: c_int = 0x20000; +pub const MAP_STACK: c_int = 0x40000; + +pub const NLDLY: crate::tcflag_t = 0o0000400; + +pub const SOCK_STREAM: c_int = 2; +pub const SOCK_DGRAM: c_int = 1; +pub const SOCK_SEQPACKET: c_int = 5; + +pub const SA_ONSTACK: c_uint = 0x08000000; +pub const SA_SIGINFO: c_uint = 0x00000008; +pub const SA_NOCLDWAIT: c_int = 0x00010000; + +pub const SIGEMT: c_int = 7; +pub const SIGCHLD: c_int = 18; +pub const SIGBUS: c_int = 10; +pub const SIGTTIN: c_int = 26; +pub const SIGTTOU: c_int = 27; +pub const SIGXCPU: c_int = 30; +pub const SIGXFSZ: c_int = 31; +pub const SIGVTALRM: c_int = 28; +pub const SIGPROF: c_int = 29; +pub const SIGWINCH: c_int = 20; +pub const SIGUSR1: c_int = 16; +pub const SIGUSR2: c_int = 17; +pub const SIGCONT: c_int = 25; +pub const SIGSTOP: c_int = 23; +pub const SIGTSTP: c_int = 24; +pub const SIGURG: c_int = 21; +pub const SIGIO: c_int = 22; +pub const SIGSYS: c_int = 12; +pub const SIGPWR: c_int = 19; +pub const SIG_SETMASK: c_int = 3; +pub const SIG_BLOCK: c_int = 0x1; +pub const SIG_UNBLOCK: c_int = 0x2; + +pub const POLLWRNORM: c_short = 0x004; +pub const POLLWRBAND: c_short = 0x100; + +pub const PTHREAD_STACK_MIN: size_t = 16384; + +pub const VEOF: usize = 16; +pub const VEOL: usize = 17; +pub const VEOL2: usize = 6; +pub const VMIN: usize = 4; +pub const IEXTEN: crate::tcflag_t = 0x00000100; +pub const TOSTOP: crate::tcflag_t = 0x00008000; +pub const FLUSHO: crate::tcflag_t = 0x00002000; +pub const TCSANOW: c_int = 0x540e; +pub const TCSADRAIN: c_int = 0x540f; +pub const TCSAFLUSH: c_int = 0x5410; + +pub const CPU_SETSIZE: c_int = 0x400; + +pub const EFD_NONBLOCK: c_int = 0x80; + +pub const F_GETLK: c_int = 14; +pub const F_SETLK: c_int = 6; +pub const F_SETLKW: c_int = 7; + +pub const SFD_NONBLOCK: c_int = 0x80; + +pub const RTLD_GLOBAL: c_int = 0x4; + +pub const SIGSTKSZ: size_t = 8192; +pub const CBAUD: crate::tcflag_t = 0o0010017; +pub const CBAUDEX: crate::tcflag_t = 0o0010000; +pub const CIBAUD: crate::tcflag_t = 0o002003600000; +pub const TAB1: crate::tcflag_t = 0x00000800; +pub const TAB2: crate::tcflag_t = 0x00001000; +pub const TAB3: crate::tcflag_t = 0x00001800; +pub const TABDLY: crate::tcflag_t = 0o0014000; +pub const CR1: crate::tcflag_t = 0x00000200; +pub const CR2: crate::tcflag_t = 0x00000400; +pub const CR3: crate::tcflag_t = 0x00000600; +pub const FF1: crate::tcflag_t = 0x00008000; +pub const BS1: crate::tcflag_t = 0x00002000; +pub const BSDLY: crate::tcflag_t = 0o0020000; +pub const VT1: crate::tcflag_t = 0x00004000; +pub const VWERASE: usize = 14; +pub const XTABS: crate::tcflag_t = 0o0014000; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSWTC: usize = 7; +pub const VTDLY: c_int = 0o0040000; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: crate::tcflag_t = 0x00000400; +pub const IXOFF: crate::tcflag_t = 0x00001000; +pub const OLCUC: crate::tcflag_t = 0o0000002; +pub const ONLCR: crate::tcflag_t = 0x4; +pub const CSIZE: crate::tcflag_t = 0x00000030; +pub const CS6: crate::tcflag_t = 0x00000010; +pub const CS7: crate::tcflag_t = 0x00000020; +pub const CS8: crate::tcflag_t = 0x00000030; +pub const CSTOPB: crate::tcflag_t = 0x00000040; +pub const CRDLY: c_int = 0o0003000; +pub const CREAD: crate::tcflag_t = 0x00000080; +pub const PARENB: crate::tcflag_t = 0x00000100; +pub const PARODD: crate::tcflag_t = 0x00000200; +pub const HUPCL: crate::tcflag_t = 0x00000400; +pub const CLOCAL: crate::tcflag_t = 0x00000800; +pub const ECHOKE: crate::tcflag_t = 0x00000800; +pub const ECHOE: crate::tcflag_t = 0x00000010; +pub const ECHOK: crate::tcflag_t = 0x00000020; +pub const ECHONL: crate::tcflag_t = 0x00000040; +pub const ECHOPRT: crate::tcflag_t = 0x00000400; +pub const ECHOCTL: crate::tcflag_t = 0x00000200; +pub const ISIG: crate::tcflag_t = 0x00000001; +pub const ICANON: crate::tcflag_t = 0x00000002; +pub const PENDIN: crate::tcflag_t = 0x00004000; +pub const NOFLSH: crate::tcflag_t = 0x00000080; + +pub const MAP_HUGETLB: c_int = 0x80000; + +pub const B0: crate::speed_t = 0o000000; +pub const B50: crate::speed_t = 0o000001; +pub const B75: crate::speed_t = 0o000002; +pub const B110: crate::speed_t = 0o000003; +pub const B134: crate::speed_t = 0o000004; +pub const B150: crate::speed_t = 0o000005; +pub const B200: crate::speed_t = 0o000006; +pub const B300: crate::speed_t = 0o000007; +pub const B600: crate::speed_t = 0o000010; +pub const B1200: crate::speed_t = 0o000011; +pub const B1800: crate::speed_t = 0o000012; +pub const B2400: crate::speed_t = 0o000013; +pub const B4800: crate::speed_t = 0o000014; +pub const B9600: crate::speed_t = 0o000015; +pub const B19200: crate::speed_t = 0o000016; +pub const B38400: crate::speed_t = 0o000017; +pub const B57600: crate::speed_t = 0o010001; +pub const B115200: crate::speed_t = 0o010002; +pub const B230400: crate::speed_t = 0o010003; +pub const B460800: crate::speed_t = 0o010004; +pub const B500000: crate::speed_t = 0o010005; +pub const B576000: crate::speed_t = 0o010006; +pub const B921600: crate::speed_t = 0o010007; +pub const B1000000: crate::speed_t = 0o010010; +pub const B1152000: crate::speed_t = 0o010011; +pub const B1500000: crate::speed_t = 0o010012; +pub const B2000000: crate::speed_t = 0o010013; +pub const B2500000: crate::speed_t = 0o010014; +pub const B3000000: crate::speed_t = 0o010015; +pub const B3500000: crate::speed_t = 0o010016; +pub const B4000000: crate::speed_t = 0o010017; + +cfg_if! { + if #[cfg(target_arch = "mips")] { + mod mips32; + pub use self::mips32::*; + } else if #[cfg(target_arch = "mips64")] { + mod mips64; + pub use self::mips64::*; + } else { + // Unknown target_arch + } +} diff --git a/http/vendor/libc/src/unix/linux_like/linux/uclibc/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/uclibc/mod.rs new file mode 100644 index 0000000..f70e0c4 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/uclibc/mod.rs @@ -0,0 +1,509 @@ +// FIXME(ulibc): this module has definitions that are redundant with the parent +#![allow(dead_code)] + +use crate::off64_t; +use crate::prelude::*; + +pub type shmatt_t = c_ulong; +pub type msgqnum_t = c_ulong; +pub type msglen_t = c_ulong; +pub type regoff_t = c_int; +pub type rlim_t = c_ulong; +pub type __rlimit_resource_t = c_ulong; +pub type __priority_which_t = c_uint; + +cfg_if! { + if #[cfg(doc)] { + // Used in `linux::arch` to define ioctl constants. + pub(crate) type Ioctl = c_ulong; + } else { + #[doc(hidden)] + pub type Ioctl = c_ulong; + } +} + +s! { + pub struct statvfs { + // Different than GNU! + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_favail: crate::fsfilcnt_t, + #[cfg(target_endian = "little")] + pub f_fsid: c_ulong, + #[cfg(target_pointer_width = "32")] + __f_unused: Padding, + #[cfg(target_endian = "big")] + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: [c_int; 6], + } + + pub struct regex_t { + __buffer: *mut c_void, + __allocated: size_t, + __used: size_t, + __syntax: c_ulong, + __fastmap: *mut c_char, + __translate: *mut c_char, + __re_nsub: size_t, + __bitfield: u8, + } + + pub struct rtentry { + pub rt_pad1: c_ulong, + pub rt_dst: crate::sockaddr, + pub rt_gateway: crate::sockaddr, + pub rt_genmask: crate::sockaddr, + pub rt_flags: c_ushort, + pub rt_pad2: c_short, + pub rt_pad3: c_ulong, + pub rt_tos: c_uchar, + pub rt_class: c_uchar, + #[cfg(target_pointer_width = "64")] + pub rt_pad4: [c_short; 3usize], + #[cfg(not(target_pointer_width = "64"))] + pub rt_pad4: c_short, + pub rt_metric: c_short, + pub rt_dev: *mut c_char, + pub rt_mtu: c_ulong, + pub rt_window: c_ulong, + pub rt_irtt: c_ushort, + } + + pub struct __exit_status { + pub e_termination: c_short, + pub e_exit: c_short, + } + + pub struct ptrace_peeksiginfo_args { + pub off: crate::__u64, + pub flags: crate::__u32, + pub nr: crate::__s32, + } + + #[cfg_attr( + any( + target_pointer_width = "32", + target_arch = "x86_64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "s390x", + target_arch = "sparc64" + ), + repr(align(4)) + )] + #[cfg_attr( + not(any( + target_pointer_width = "32", + target_arch = "x86_64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "s390x", + target_arch = "sparc64" + )), + repr(align(8)) + )] + pub struct pthread_mutexattr_t { + size: [u8; crate::__SIZEOF_PTHREAD_MUTEXATTR_T], + } + + #[repr(align(4))] + pub struct pthread_condattr_t { + size: [u8; crate::__SIZEOF_PTHREAD_CONDATTR_T], + } + + pub struct tcp_info { + pub tcpi_state: u8, + pub tcpi_ca_state: u8, + pub tcpi_retransmits: u8, + pub tcpi_probes: u8, + pub tcpi_backoff: u8, + pub tcpi_options: u8, + /// This contains the bitfields `tcpi_snd_wscale` and `tcpi_rcv_wscale`. + /// Each is 4 bits. + pub tcpi_snd_rcv_wscale: u8, + pub tcpi_rto: u32, + pub tcpi_ato: u32, + pub tcpi_snd_mss: u32, + pub tcpi_rcv_mss: u32, + pub tcpi_unacked: u32, + pub tcpi_sacked: u32, + pub tcpi_lost: u32, + pub tcpi_retrans: u32, + pub tcpi_fackets: u32, + pub tcpi_last_data_sent: u32, + pub tcpi_last_ack_sent: u32, + pub tcpi_last_data_recv: u32, + pub tcpi_last_ack_recv: u32, + pub tcpi_pmtu: u32, + pub tcpi_rcv_ssthresh: u32, + pub tcpi_rtt: u32, + pub tcpi_rttvar: u32, + pub tcpi_snd_ssthresh: u32, + pub tcpi_snd_cwnd: u32, + pub tcpi_advmss: u32, + pub tcpi_reordering: u32, + pub tcpi_rcv_rtt: u32, + pub tcpi_rcv_space: u32, + pub tcpi_total_retrans: u32, + } +} + +impl siginfo_t { + pub unsafe fn si_addr(&self) -> *mut c_void { + #[repr(C)] + struct siginfo_sigfault { + _si_signo: c_int, + _si_errno: c_int, + _si_code: c_int, + si_addr: *mut c_void, + } + (*(self as *const siginfo_t as *const siginfo_sigfault)).si_addr + } + + pub unsafe fn si_value(&self) -> crate::sigval { + #[repr(C)] + struct siginfo_si_value { + _si_signo: c_int, + _si_errno: c_int, + _si_code: c_int, + _si_timerid: c_int, + _si_overrun: c_int, + si_value: crate::sigval, + } + (*(self as *const siginfo_t as *const siginfo_si_value)).si_value + } +} + +s_no_extra_traits! { + // Internal, for casts to access union fields + struct sifields_sigchld { + si_pid: crate::pid_t, + si_uid: crate::uid_t, + si_status: c_int, + si_utime: c_long, + si_stime: c_long, + } + + // Internal, for casts to access union fields + union sifields { + _align_pointer: *mut c_void, + sigchld: sifields_sigchld, + } + + // Internal, for casts to access union fields. Note that some variants + // of sifields start with a pointer, which makes the alignment of + // sifields vary on 32-bit and 64-bit architectures. + struct siginfo_f { + _siginfo_base: [c_int; 3], + sifields: sifields, + } +} + +impl siginfo_t { + unsafe fn sifields(&self) -> &sifields { + &(*(self as *const siginfo_t as *const siginfo_f)).sifields + } + + pub unsafe fn si_pid(&self) -> crate::pid_t { + self.sifields().sigchld.si_pid + } + + pub unsafe fn si_uid(&self) -> crate::uid_t { + self.sifields().sigchld.si_uid + } + + pub unsafe fn si_status(&self) -> c_int { + self.sifields().sigchld.si_status + } + + pub unsafe fn si_utime(&self) -> c_long { + self.sifields().sigchld.si_utime + } + + pub unsafe fn si_stime(&self) -> c_long { + self.sifields().sigchld.si_stime + } +} + +pub const MCL_CURRENT: c_int = 0x0001; +pub const MCL_FUTURE: c_int = 0x0002; +pub const MCL_ONFAULT: c_int = 0x0004; + +pub const SIGEV_THREAD_ID: c_int = 4; + +pub const AF_VSOCK: c_int = 40; + +// Most `*_SUPER_MAGIC` constants are defined at the `linux_like` level; the +// following are only available on newer Linux versions than the versions +// currently used in CI in some configurations, so we define them here. +pub const BINDERFS_SUPER_MAGIC: c_long = 0x6c6f6f70; +pub const XFS_SUPER_MAGIC: c_long = 0x58465342; + +pub const PTRACE_TRACEME: c_int = 0; +pub const PTRACE_PEEKTEXT: c_int = 1; +pub const PTRACE_PEEKDATA: c_int = 2; +pub const PTRACE_PEEKUSER: c_int = 3; +pub const PTRACE_POKETEXT: c_int = 4; +pub const PTRACE_POKEDATA: c_int = 5; +pub const PTRACE_POKEUSER: c_int = 6; +pub const PTRACE_CONT: c_int = 7; +pub const PTRACE_KILL: c_int = 8; +pub const PTRACE_SINGLESTEP: c_int = 9; +pub const PTRACE_GETREGS: c_int = 12; +pub const PTRACE_SETREGS: c_int = 13; +pub const PTRACE_GETFPREGS: c_int = 14; +pub const PTRACE_SETFPREGS: c_int = 15; +pub const PTRACE_ATTACH: c_int = 16; +pub const PTRACE_DETACH: c_int = 17; +pub const PTRACE_GETFPXREGS: c_int = 18; +pub const PTRACE_SETFPXREGS: c_int = 19; +pub const PTRACE_SYSCALL: c_int = 24; +pub const PTRACE_SETOPTIONS: c_int = 0x4200; +pub const PTRACE_GETEVENTMSG: c_int = 0x4201; +pub const PTRACE_GETSIGINFO: c_int = 0x4202; +pub const PTRACE_SETSIGINFO: c_int = 0x4203; +pub const PTRACE_GETREGSET: c_int = 0x4204; +pub const PTRACE_SETREGSET: c_int = 0x4205; +pub const PTRACE_SEIZE: c_int = 0x4206; +pub const PTRACE_INTERRUPT: c_int = 0x4207; +pub const PTRACE_LISTEN: c_int = 0x4208; + +pub const POSIX_FADV_DONTNEED: c_int = 4; +pub const POSIX_FADV_NOREUSE: c_int = 5; + +// These are different than GNU! +pub const LC_CTYPE: c_int = 0; +pub const LC_NUMERIC: c_int = 1; +pub const LC_TIME: c_int = 3; +pub const LC_COLLATE: c_int = 4; +pub const LC_MONETARY: c_int = 2; +pub const LC_MESSAGES: c_int = 5; +pub const LC_ALL: c_int = 6; +// end different section + +// MS_ flags for mount(2) +pub const MS_RMT_MASK: c_ulong = + crate::MS_RDONLY | crate::MS_SYNCHRONOUS | crate::MS_MANDLOCK | crate::MS_I_VERSION; + +pub const ENOTSUP: c_int = EOPNOTSUPP; + +pub const IPV6_JOIN_GROUP: c_int = 20; +pub const IPV6_LEAVE_GROUP: c_int = 21; + +// These are different from GNU +pub const ABDAY_1: crate::nl_item = 0x300; +pub const ABDAY_2: crate::nl_item = 0x301; +pub const ABDAY_3: crate::nl_item = 0x302; +pub const ABDAY_4: crate::nl_item = 0x303; +pub const ABDAY_5: crate::nl_item = 0x304; +pub const ABDAY_6: crate::nl_item = 0x305; +pub const ABDAY_7: crate::nl_item = 0x306; +pub const DAY_1: crate::nl_item = 0x307; +pub const DAY_2: crate::nl_item = 0x308; +pub const DAY_3: crate::nl_item = 0x309; +pub const DAY_4: crate::nl_item = 0x30A; +pub const DAY_5: crate::nl_item = 0x30B; +pub const DAY_6: crate::nl_item = 0x30C; +pub const DAY_7: crate::nl_item = 0x30D; +pub const ABMON_1: crate::nl_item = 0x30E; +pub const ABMON_2: crate::nl_item = 0x30F; +pub const ABMON_3: crate::nl_item = 0x310; +pub const ABMON_4: crate::nl_item = 0x311; +pub const ABMON_5: crate::nl_item = 0x312; +pub const ABMON_6: crate::nl_item = 0x313; +pub const ABMON_7: crate::nl_item = 0x314; +pub const ABMON_8: crate::nl_item = 0x315; +pub const ABMON_9: crate::nl_item = 0x316; +pub const ABMON_10: crate::nl_item = 0x317; +pub const ABMON_11: crate::nl_item = 0x318; +pub const ABMON_12: crate::nl_item = 0x319; +pub const MON_1: crate::nl_item = 0x31A; +pub const MON_2: crate::nl_item = 0x31B; +pub const MON_3: crate::nl_item = 0x31C; +pub const MON_4: crate::nl_item = 0x31D; +pub const MON_5: crate::nl_item = 0x31E; +pub const MON_6: crate::nl_item = 0x31F; +pub const MON_7: crate::nl_item = 0x320; +pub const MON_8: crate::nl_item = 0x321; +pub const MON_9: crate::nl_item = 0x322; +pub const MON_10: crate::nl_item = 0x323; +pub const MON_11: crate::nl_item = 0x324; +pub const MON_12: crate::nl_item = 0x325; +pub const AM_STR: crate::nl_item = 0x326; +pub const PM_STR: crate::nl_item = 0x327; +pub const D_T_FMT: crate::nl_item = 0x328; +pub const D_FMT: crate::nl_item = 0x329; +pub const T_FMT: crate::nl_item = 0x32A; +pub const T_FMT_AMPM: crate::nl_item = 0x32B; +pub const ERA: crate::nl_item = 0x32C; +pub const ERA_D_FMT: crate::nl_item = 0x32E; +pub const ALT_DIGITS: crate::nl_item = 0x32F; +pub const ERA_D_T_FMT: crate::nl_item = 0x330; +pub const ERA_T_FMT: crate::nl_item = 0x331; +pub const CODESET: crate::nl_item = 10; +pub const CRNCYSTR: crate::nl_item = 0x215; +pub const RADIXCHAR: crate::nl_item = 0x100; +pub const THOUSEP: crate::nl_item = 0x101; +pub const NOEXPR: crate::nl_item = 0x501; +pub const YESSTR: crate::nl_item = 0x502; +pub const NOSTR: crate::nl_item = 0x503; + +// Different than Gnu. +pub const FILENAME_MAX: c_uint = 4095; + +pub const PRIO_PROCESS: c_int = 0; +pub const PRIO_PGRP: c_int = 1; +pub const PRIO_USER: c_int = 2; + +pub const SOMAXCONN: c_int = 128; + +pub const ST_RELATIME: c_ulong = 4096; + +pub const AF_NFC: c_int = PF_NFC; +pub const BUFSIZ: c_int = 4096; +pub const EDEADLOCK: c_int = EDEADLK; +pub const EXTA: c_uint = B19200; +pub const EXTB: c_uint = B38400; +pub const EXTPROC: crate::tcflag_t = 0o200000; +pub const FOPEN_MAX: c_int = 16; +pub const F_GETOWN: c_int = 9; +pub const F_OFD_GETLK: c_int = 36; +pub const F_OFD_SETLK: c_int = 37; +pub const F_OFD_SETLKW: c_int = 38; +pub const F_RDLCK: c_int = 0; +pub const F_SETOWN: c_int = 8; +pub const F_UNLCK: c_int = 2; +pub const F_WRLCK: c_int = 1; +pub const IPV6_MULTICAST_ALL: c_int = 29; +pub const IPV6_ROUTER_ALERT_ISOLATE: c_int = 30; +pub const MAP_HUGE_SHIFT: c_int = 26; +pub const MAP_HUGE_MASK: c_int = 0x3f; +pub const MAP_HUGE_64KB: c_int = 16 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_512KB: c_int = 19 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_1MB: c_int = 20 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_2MB: c_int = 21 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_8MB: c_int = 23 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_16MB: c_int = 24 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_32MB: c_int = 25 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_256MB: c_int = 28 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_512MB: c_int = 29 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_1GB: c_int = 30 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_2GB: c_int = 31 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_16GB: c_int = 34 << MAP_HUGE_SHIFT; +pub const MINSIGSTKSZ: c_int = 2048; +pub const MSG_COPY: c_int = 0o40000; +pub const NI_MAXHOST: crate::socklen_t = 1025; +pub const O_TMPFILE: c_int = 0o20000000 | O_DIRECTORY; +pub const PACKET_MR_UNICAST: c_int = 3; +pub const PF_NFC: c_int = 39; +pub const PF_VSOCK: c_int = 40; +pub const PTRACE_EVENT_STOP: c_int = 128; +pub const PTRACE_GETSIGMASK: c_uint = 0x420a; +pub const PTRACE_PEEKSIGINFO: c_int = 0x4209; +pub const PTRACE_SETSIGMASK: c_uint = 0x420b; +pub const RTLD_NOLOAD: c_int = 0x00004; +pub const RUSAGE_THREAD: c_int = 1; +pub const SHM_EXEC: c_int = 0o100000; +pub const SIGPOLL: c_int = SIGIO; +pub const SOCK_DCCP: c_int = 6; +#[deprecated(since = "0.2.70", note = "AF_PACKET must be used instead")] +pub const SOCK_PACKET: c_int = 10; +pub const TCP_COOKIE_TRANSACTIONS: c_int = 15; +pub const UDP_GRO: c_int = 104; +pub const UDP_SEGMENT: c_int = 103; +pub const YESEXPR: c_int = ((5) << 8) | (0); + +extern "C" { + pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut crate::timezone) -> c_int; + + pub fn pthread_rwlockattr_getkind_np( + attr: *const crate::pthread_rwlockattr_t, + val: *mut c_int, + ) -> c_int; + pub fn pthread_rwlockattr_setkind_np( + attr: *mut crate::pthread_rwlockattr_t, + val: c_int, + ) -> c_int; + + pub fn ptrace(request: c_uint, ...) -> c_long; + + pub fn sendmmsg( + sockfd: c_int, + msgvec: *mut crate::mmsghdr, + vlen: c_uint, + flags: c_int, + ) -> c_int; + pub fn recvmmsg( + sockfd: c_int, + msgvec: *mut crate::mmsghdr, + vlen: c_uint, + flags: c_int, + timeout: *mut crate::timespec, + ) -> c_int; + + pub fn openpty( + amaster: *mut c_int, + aslave: *mut c_int, + name: *mut c_char, + termp: *mut termios, + winp: *mut crate::winsize, + ) -> c_int; + pub fn forkpty( + amaster: *mut c_int, + name: *mut c_char, + termp: *mut termios, + winp: *mut crate::winsize, + ) -> crate::pid_t; + + pub fn getnameinfo( + sa: *const crate::sockaddr, + salen: crate::socklen_t, + host: *mut c_char, + hostlen: crate::socklen_t, + serv: *mut c_char, + servlen: crate::socklen_t, + flags: c_int, + ) -> c_int; + + pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off64_t) -> ssize_t; + pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off64_t) -> ssize_t; + + pub fn sethostid(hostid: c_long) -> c_int; + pub fn fanotify_mark( + fd: c_int, + flags: c_uint, + mask: u64, + dirfd: c_int, + path: *const c_char, + ) -> c_int; + pub fn getrlimit64(resource: crate::__rlimit_resource_t, rlim: *mut crate::rlimit64) -> c_int; + pub fn setrlimit64(resource: crate::__rlimit_resource_t, rlim: *const crate::rlimit64) + -> c_int; + pub fn getrlimit(resource: crate::__rlimit_resource_t, rlim: *mut crate::rlimit) -> c_int; + pub fn setrlimit(resource: crate::__rlimit_resource_t, rlim: *const crate::rlimit) -> c_int; + pub fn getpriority(which: crate::__priority_which_t, who: crate::id_t) -> c_int; + pub fn setpriority(which: crate::__priority_which_t, who: crate::id_t, prio: c_int) -> c_int; + pub fn getauxval(type_: c_ulong) -> c_ulong; +} + +cfg_if! { + if #[cfg(any(target_arch = "mips", target_arch = "mips64"))] { + mod mips; + pub use self::mips::*; + } else if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } else if #[cfg(target_arch = "arm")] { + mod arm; + pub use self::arm::*; + } else { + pub use unsupported_target; + } +} diff --git a/http/vendor/libc/src/unix/linux_like/linux/uclibc/x86_64/mod.rs b/http/vendor/libc/src/unix/linux_like/linux/uclibc/x86_64/mod.rs new file mode 100644 index 0000000..30e6772 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux/uclibc/x86_64/mod.rs @@ -0,0 +1,346 @@ +//! Definitions for uclibc on 64bit systems + +use crate::off64_t; +use crate::prelude::*; + +pub type blkcnt_t = i64; +pub type blksize_t = i64; +pub type clock_t = i64; +pub type fsblkcnt_t = c_ulong; +pub type fsfilcnt_t = c_ulong; +pub type fsword_t = c_long; +pub type ino_t = c_ulong; +pub type nlink_t = c_uint; +pub type off_t = c_long; +// [uClibc docs] Note stat64 has the same shape as stat for x86-64. +pub type stat64 = stat; +pub type suseconds_t = c_long; +pub type time_t = c_int; +pub type wchar_t = c_int; +pub type pthread_t = c_ulong; + +pub type fsblkcnt64_t = u64; +pub type fsfilcnt64_t = u64; +pub type __u64 = c_ulong; +pub type __s64 = c_long; + +s! { + pub struct ipc_perm { + pub __key: crate::key_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: c_ushort, // read / write + __pad1: Padding, + pub __seq: c_ushort, + __pad2: Padding, + __unused1: Padding, + __unused2: Padding, + } + + pub struct pthread_attr_t { + __detachstate: c_int, + __schedpolicy: c_int, + __schedparam: __sched_param, + __inheritsched: c_int, + __scope: c_int, + __guardsize: size_t, + __stackaddr_set: c_int, + __stackaddr: *mut c_void, // better don't use it + __stacksize: size_t, + } + + pub struct __sched_param { + __sched_priority: c_int, + } + + pub struct siginfo_t { + si_signo: c_int, // signal number + si_errno: c_int, // if not zero: error value of signal, see errno.h + si_code: c_int, // signal code + pub _pad: [c_int; 28], // unported union + _align: [usize; 0], + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, // segment size in bytes + pub shm_atime: crate::time_t, // time of last shmat() + pub shm_dtime: crate::time_t, + pub shm_ctime: crate::time_t, + pub shm_cpid: crate::pid_t, + pub shm_lpid: crate::pid_t, + pub shm_nattch: crate::shmatt_t, + __unused1: Padding, + __unused2: Padding, + } + + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + pub msg_stime: crate::time_t, + pub msg_rtime: crate::time_t, + pub msg_ctime: crate::time_t, + pub __msg_cbytes: c_ulong, + pub msg_qnum: crate::msgqnum_t, + pub msg_qbytes: crate::msglen_t, + pub msg_lspid: crate::pid_t, + pub msg_lrpid: crate::pid_t, + __ignored1: c_ulong, + __ignored2: c_ulong, + } + + pub struct sockaddr { + pub sa_family: crate::sa_family_t, + pub sa_data: [c_char; 14], + } + + pub struct sockaddr_in { + pub sin_family: crate::sa_family_t, + pub sin_port: crate::in_port_t, + pub sin_addr: crate::in_addr, + pub sin_zero: [u8; 8], + } + + pub struct sockaddr_in6 { + pub sin6_family: crate::sa_family_t, + pub sin6_port: crate::in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: crate::in6_addr, + pub sin6_scope_id: u32, + } + + /* ------------------------------------------------------------ + * definitions below are *unverified* and might **break** the software + */ + + // pub struct in_addr { + // pub s_addr: in_addr_t, + // } + // + // pub struct in6_addr { + // pub s6_addr: [u8; 16], + // } + + pub struct stat { + pub st_dev: c_ulong, + pub st_ino: crate::ino_t, + // According to uclibc/libc/sysdeps/linux/x86_64/bits/stat.h, order of + // nlink and mode are swapped on 64 bit systems. + pub st_nlink: crate::nlink_t, + pub st_mode: crate::mode_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: c_ulong, // dev_t + pub st_size: off_t, // file size + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_ulong, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_ulong, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_ulong, + st_pad4: Padding<[c_long; 3]>, + } + + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigaction { + pub sa_handler: crate::sighandler_t, + pub sa_flags: c_ulong, + pub sa_restorer: Option, + pub sa_mask: crate::sigset_t, + } + + pub struct stack_t { + // FIXME(ulibc) + pub ss_sp: *mut c_void, + pub ss_flags: c_int, + pub ss_size: size_t, + } + + pub struct statfs { + // FIXME(ulibc) + pub f_type: fsword_t, + pub f_bsize: fsword_t, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_fsid: crate::fsid_t, + pub f_namelen: fsword_t, + pub f_frsize: fsword_t, + f_spare: [fsword_t; 5], + } + + pub struct statfs64 { + pub f_type: c_int, + pub f_bsize: c_int, + pub f_blocks: crate::fsblkcnt64_t, + pub f_bfree: crate::fsblkcnt64_t, + pub f_bavail: crate::fsblkcnt64_t, + pub f_files: crate::fsfilcnt64_t, + pub f_ffree: crate::fsfilcnt64_t, + pub f_fsid: crate::fsid_t, + pub f_namelen: c_int, + pub f_frsize: c_int, + pub f_flags: c_int, + pub f_spare: [c_int; 4], + } + + pub struct statvfs64 { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: u64, + pub f_files: u64, + pub f_ffree: u64, + pub f_favail: u64, + pub f_fsid: c_ulong, + __f_unused: Padding, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + __f_spare: [c_int; 6], + } + + pub struct msghdr { + // FIXME(ulibc) + pub msg_name: *mut c_void, + pub msg_namelen: crate::socklen_t, + pub msg_iov: *mut crate::iovec, + pub msg_iovlen: size_t, + pub msg_control: *mut c_void, + pub msg_controllen: size_t, + pub msg_flags: c_int, + } + + pub struct termios { + // FIXME(ulibc) + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_line: crate::cc_t, + pub c_cc: [crate::cc_t; crate::NCCS], + } + + pub struct sigset_t { + // FIXME(ulibc) + __val: [c_ulong; 16], + } + + pub struct sysinfo { + // FIXME(ulibc) + pub uptime: c_long, + pub loads: [c_ulong; 3], + pub totalram: c_ulong, + pub freeram: c_ulong, + pub sharedram: c_ulong, + pub bufferram: c_ulong, + pub totalswap: c_ulong, + pub freeswap: c_ulong, + pub procs: c_ushort, + pub pad: c_ushort, + pub totalhigh: c_ulong, + pub freehigh: c_ulong, + pub mem_unit: c_uint, + pub _f: [c_char; 0], + } + + pub struct glob_t { + // FIXME(ulibc) + pub gl_pathc: size_t, + pub gl_pathv: *mut *mut c_char, + pub gl_offs: size_t, + pub gl_flags: c_int, + __unused1: Padding<*mut c_void>, + __unused2: Padding<*mut c_void>, + __unused3: Padding<*mut c_void>, + __unused4: Padding<*mut c_void>, + __unused5: Padding<*mut c_void>, + } + + pub struct cpu_set_t { + // FIXME(ulibc) + #[cfg(target_pointer_width = "32")] + bits: [u32; 32], + #[cfg(target_pointer_width = "64")] + bits: [u64; 16], + } + + pub struct fsid_t { + // FIXME(ulibc) + __val: [c_int; 2], + } + + // FIXME(1.0): this is actually a union + pub struct sem_t { + #[cfg(target_pointer_width = "32")] + __size: [c_char; 16], + #[cfg(target_pointer_width = "64")] + __size: [c_char; 32], + __align: [c_long; 0], + } + + pub struct cmsghdr { + pub cmsg_len: size_t, + pub cmsg_level: c_int, + pub cmsg_type: c_int, + } +} + +s_no_extra_traits! { + pub struct dirent { + pub d_ino: crate::ino64_t, + pub d_off: off64_t, + pub d_reclen: u16, + pub d_type: u8, + pub d_name: [c_char; 256], + } +} + +// constants +pub const ENAMETOOLONG: c_int = 36; // File name too long +pub const ENOTEMPTY: c_int = 39; // Directory not empty +pub const ELOOP: c_int = 40; // Too many symbolic links encountered +pub const EADDRINUSE: c_int = 98; // Address already in use +pub const EADDRNOTAVAIL: c_int = 99; // Cannot assign requested address +pub const ENETDOWN: c_int = 100; // Network is down +pub const ENETUNREACH: c_int = 101; // Network is unreachable +pub const ECONNABORTED: c_int = 103; // Software caused connection abort +pub const ECONNREFUSED: c_int = 111; // Connection refused +pub const ECONNRESET: c_int = 104; // Connection reset by peer +pub const EDEADLK: c_int = 35; // Resource deadlock would occur +pub const ENOSYS: c_int = 38; // Function not implemented +pub const ENOTCONN: c_int = 107; // Transport endpoint is not connected +pub const ETIMEDOUT: c_int = 110; // connection timed out +pub const ESTALE: c_int = 116; // Stale file handle +pub const EHOSTUNREACH: c_int = 113; // No route to host +pub const EDQUOT: c_int = 122; // Quota exceeded +pub const EOPNOTSUPP: c_int = 0x5f; +pub const ENODATA: c_int = 0x3d; +pub const O_APPEND: c_int = 0o2000; +pub const O_ACCMODE: c_int = 0o003; +pub const O_CLOEXEC: c_int = 0x80000; +pub const O_CREAT: c_int = 0100; +pub const O_DIRECTORY: c_int = 0o200000; +pub const O_EXCL: c_int = 0o200; +pub const O_NOFOLLOW: c_int = 0x20000; +pub const O_NONBLOCK: c_int = 0o4000; +pub const O_TRUNC: c_int = 0o1000; +pub const NCCS: usize = 32; +pub const SIG_SETMASK: c_int = 2; // Set the set of blocked signals +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; +pub const SOCK_DGRAM: c_int = 2; // connectionless, unreliable datagrams +pub const SOCK_STREAM: c_int = 1; // …/common/bits/socket_type.h +pub const __SIZEOF_PTHREAD_COND_T: usize = 48; +pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; +pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; +pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; +pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; +pub const PTHREAD_STACK_MIN: usize = 16384; diff --git a/http/vendor/libc/src/unix/linux_like/linux_l4re_shared.rs b/http/vendor/libc/src/unix/linux_like/linux_l4re_shared.rs new file mode 100644 index 0000000..cf76b39 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/linux_l4re_shared.rs @@ -0,0 +1,1997 @@ +use crate::prelude::*; + +pub type Elf32_Half = u16; +pub type Elf32_Word = u32; +pub type Elf32_Off = u32; +pub type Elf32_Addr = u32; +pub type Elf32_Xword = u64; +pub type Elf32_Sword = i32; + +pub type Elf64_Half = u16; +pub type Elf64_Word = u32; +pub type Elf64_Off = u64; +pub type Elf64_Addr = u64; +pub type Elf64_Xword = u64; +pub type Elf64_Sxword = i64; +pub type Elf64_Sword = i32; + +pub type Elf32_Section = u16; +pub type Elf64_Section = u16; + +pub type Elf32_Relr = Elf32_Word; +pub type Elf64_Relr = Elf32_Xword; +pub type Elf32_Rel = __c_anonymous_elf32_rel; +pub type Elf64_Rel = __c_anonymous_elf64_rel; + +cfg_if! { + if #[cfg(not(target_arch = "sparc64"))] { + pub type Elf32_Rela = __c_anonymous_elf32_rela; + pub type Elf64_Rela = __c_anonymous_elf64_rela; + } +} + +pub type iconv_t = *mut c_void; + +cfg_if! { + if #[cfg(not(target_env = "gnu"))] { + extern_ty! { + pub enum fpos64_t {} // FIXME(linux): fill this out with a struct + } + } +} + +s! { + pub struct glob_t { + pub gl_pathc: size_t, + pub gl_pathv: *mut *mut c_char, + pub gl_offs: size_t, + pub gl_flags: c_int, + + __unused1: Padding<*mut c_void>, + __unused2: Padding<*mut c_void>, + __unused3: Padding<*mut c_void>, + __unused4: Padding<*mut c_void>, + __unused5: Padding<*mut c_void>, + } + + pub struct passwd { + pub pw_name: *mut c_char, + pub pw_passwd: *mut c_char, + pub pw_uid: crate::uid_t, + pub pw_gid: crate::gid_t, + pub pw_gecos: *mut c_char, + pub pw_dir: *mut c_char, + pub pw_shell: *mut c_char, + } + + pub struct spwd { + pub sp_namp: *mut c_char, + pub sp_pwdp: *mut c_char, + pub sp_lstchg: c_long, + pub sp_min: c_long, + pub sp_max: c_long, + pub sp_warn: c_long, + pub sp_inact: c_long, + pub sp_expire: c_long, + pub sp_flag: c_ulong, + } + + pub struct itimerspec { + pub it_interval: crate::timespec, + pub it_value: crate::timespec, + } + + pub struct fsid_t { + __val: [c_int; 2], + } + + pub struct packet_mreq { + pub mr_ifindex: c_int, + pub mr_type: c_ushort, + pub mr_alen: c_ushort, + pub mr_address: [c_uchar; 8], + } + + pub struct cpu_set_t { + #[cfg(all(target_pointer_width = "32", not(target_arch = "x86_64")))] + bits: [u32; 32], + #[cfg(not(all(target_pointer_width = "32", not(target_arch = "x86_64"))))] + bits: [u64; 16], + } + + pub struct sembuf { + pub sem_num: c_ushort, + pub sem_op: c_short, + pub sem_flg: c_short, + } + + pub struct dl_phdr_info { + #[cfg(target_pointer_width = "64")] + pub dlpi_addr: Elf64_Addr, + #[cfg(target_pointer_width = "32")] + pub dlpi_addr: Elf32_Addr, + + pub dlpi_name: *const c_char, + + #[cfg(target_pointer_width = "64")] + pub dlpi_phdr: *const Elf64_Phdr, + #[cfg(target_pointer_width = "32")] + pub dlpi_phdr: *const Elf32_Phdr, + + #[cfg(target_pointer_width = "64")] + pub dlpi_phnum: Elf64_Half, + #[cfg(target_pointer_width = "32")] + pub dlpi_phnum: Elf32_Half, + + // As of uClibc 1.0.36, the following fields are + // gated behind a "#if 0" block which always evaluates + // to false. So I'm just removing these, and if uClibc changes + // the #if block in the future to include the following fields, these + // will probably need including here. tsidea, skrap + // QNX (NTO) platform does not define these fields + #[cfg(not(any(target_env = "uclibc", target_os = "nto")))] + pub dlpi_adds: c_ulonglong, + #[cfg(not(any(target_env = "uclibc", target_os = "nto")))] + pub dlpi_subs: c_ulonglong, + #[cfg(not(any(target_env = "uclibc", target_os = "nto")))] + pub dlpi_tls_modid: size_t, + #[cfg(not(any(target_env = "uclibc", target_os = "nto")))] + pub dlpi_tls_data: *mut c_void, + } + + pub struct Elf32_Ehdr { + pub e_ident: [c_uchar; 16], + pub e_type: Elf32_Half, + pub e_machine: Elf32_Half, + pub e_version: Elf32_Word, + pub e_entry: Elf32_Addr, + pub e_phoff: Elf32_Off, + pub e_shoff: Elf32_Off, + pub e_flags: Elf32_Word, + pub e_ehsize: Elf32_Half, + pub e_phentsize: Elf32_Half, + pub e_phnum: Elf32_Half, + pub e_shentsize: Elf32_Half, + pub e_shnum: Elf32_Half, + pub e_shstrndx: Elf32_Half, + } + + pub struct Elf64_Ehdr { + pub e_ident: [c_uchar; 16], + pub e_type: Elf64_Half, + pub e_machine: Elf64_Half, + pub e_version: Elf64_Word, + pub e_entry: Elf64_Addr, + pub e_phoff: Elf64_Off, + pub e_shoff: Elf64_Off, + pub e_flags: Elf64_Word, + pub e_ehsize: Elf64_Half, + pub e_phentsize: Elf64_Half, + pub e_phnum: Elf64_Half, + pub e_shentsize: Elf64_Half, + pub e_shnum: Elf64_Half, + pub e_shstrndx: Elf64_Half, + } + + pub struct Elf32_Sym { + pub st_name: Elf32_Word, + pub st_value: Elf32_Addr, + pub st_size: Elf32_Word, + pub st_info: c_uchar, + pub st_other: c_uchar, + pub st_shndx: Elf32_Section, + } + + pub struct Elf64_Sym { + pub st_name: Elf64_Word, + pub st_info: c_uchar, + pub st_other: c_uchar, + pub st_shndx: Elf64_Section, + pub st_value: Elf64_Addr, + pub st_size: Elf64_Xword, + } + + pub struct Elf32_Phdr { + pub p_type: Elf32_Word, + pub p_offset: Elf32_Off, + pub p_vaddr: Elf32_Addr, + pub p_paddr: Elf32_Addr, + pub p_filesz: Elf32_Word, + pub p_memsz: Elf32_Word, + pub p_flags: Elf32_Word, + pub p_align: Elf32_Word, + } + + pub struct Elf64_Phdr { + pub p_type: Elf64_Word, + pub p_flags: Elf64_Word, + pub p_offset: Elf64_Off, + pub p_vaddr: Elf64_Addr, + pub p_paddr: Elf64_Addr, + pub p_filesz: Elf64_Xword, + pub p_memsz: Elf64_Xword, + pub p_align: Elf64_Xword, + } + + pub struct Elf32_Shdr { + pub sh_name: Elf32_Word, + pub sh_type: Elf32_Word, + pub sh_flags: Elf32_Word, + pub sh_addr: Elf32_Addr, + pub sh_offset: Elf32_Off, + pub sh_size: Elf32_Word, + pub sh_link: Elf32_Word, + pub sh_info: Elf32_Word, + pub sh_addralign: Elf32_Word, + pub sh_entsize: Elf32_Word, + } + + pub struct Elf64_Shdr { + pub sh_name: Elf64_Word, + pub sh_type: Elf64_Word, + pub sh_flags: Elf64_Xword, + pub sh_addr: Elf64_Addr, + pub sh_offset: Elf64_Off, + pub sh_size: Elf64_Xword, + pub sh_link: Elf64_Word, + pub sh_info: Elf64_Word, + pub sh_addralign: Elf64_Xword, + pub sh_entsize: Elf64_Xword, + } + + pub struct __c_anonymous_elf32_rel { + pub r_offset: Elf32_Addr, + pub r_info: Elf32_Word, + } + + pub struct __c_anonymous_elf64_rel { + pub r_offset: Elf64_Addr, + pub r_info: Elf64_Xword, + } + + pub struct ucred { + pub pid: crate::pid_t, + pub uid: crate::uid_t, + pub gid: crate::gid_t, + } + + pub struct mntent { + pub mnt_fsname: *mut c_char, + pub mnt_dir: *mut c_char, + pub mnt_type: *mut c_char, + pub mnt_opts: *mut c_char, + pub mnt_freq: c_int, + pub mnt_passno: c_int, + } + + pub struct in6_pktinfo { + pub ipi6_addr: crate::in6_addr, + pub ipi6_ifindex: c_uint, + } + + pub struct arpd_request { + pub req: c_ushort, + pub ip: u32, + pub dev: c_ulong, + pub stamp: c_ulong, + pub updated: c_ulong, + pub ha: [c_uchar; crate::MAX_ADDR_LEN], + } + + pub struct regmatch_t { + pub rm_so: crate::regoff_t, + pub rm_eo: crate::regoff_t, + } + + pub struct option { + pub name: *const c_char, + pub has_arg: c_int, + pub flag: *mut c_int, + pub val: c_int, + } + + pub struct rlimit64 { + pub rlim_cur: crate::rlim64_t, + pub rlim_max: crate::rlim64_t, + } + + pub struct __c_anonymous_ifru_map { + pub mem_start: c_ulong, + pub mem_end: c_ulong, + pub base_addr: c_ushort, + pub irq: c_uchar, + pub dma: c_uchar, + pub port: c_uchar, + } + + pub struct dirent { + pub d_ino: crate::ino_t, + pub d_off: crate::off_t, + pub d_reclen: c_ushort, + pub d_type: c_uchar, + pub d_name: [c_char; 256], + } + + pub struct dirent64 { + pub d_ino: crate::ino64_t, + pub d_off: crate::off64_t, + pub d_reclen: c_ushort, + pub d_type: c_uchar, + pub d_name: [c_char; 256], + } +} + +cfg_if! { + if #[cfg(not(target_arch = "sparc64"))] { + s! { + pub struct __c_anonymous_elf32_rela { + pub r_offset: crate::Elf32_Addr, + pub r_info: crate::Elf32_Word, + pub r_addend: crate::Elf32_Sword, + } + + pub struct __c_anonymous_elf64_rela { + pub r_offset: crate::Elf64_Addr, + pub r_info: crate::Elf64_Xword, + pub r_addend: crate::Elf64_Sxword, + } + } + } +} + +s_no_extra_traits! { + pub union __c_anonymous_ifr_ifru { + pub ifru_addr: crate::sockaddr, + pub ifru_dstaddr: crate::sockaddr, + pub ifru_broadaddr: crate::sockaddr, + pub ifru_netmask: crate::sockaddr, + pub ifru_hwaddr: crate::sockaddr, + pub ifru_flags: c_short, + pub ifru_ifindex: c_int, + pub ifru_metric: c_int, + pub ifru_mtu: c_int, + pub ifru_map: __c_anonymous_ifru_map, + pub ifru_slave: [c_char; crate::IFNAMSIZ], + pub ifru_newname: [c_char; crate::IFNAMSIZ], + pub ifru_data: *mut c_char, + } + + pub struct ifreq { + /// interface name, e.g. "en0" + pub ifr_name: [c_char; crate::IFNAMSIZ], + pub ifr_ifru: __c_anonymous_ifr_ifru, + } + + pub union __c_anonymous_ifc_ifcu { + pub ifcu_buf: *mut c_char, + pub ifcu_req: *mut crate::ifreq, + } + + /// Structure used in SIOCGIFCONF request. Used to retrieve interface configuration for + /// machine (useful for programs which must know all networks accessible). + pub struct ifconf { + /// Size of buffer + pub ifc_len: c_int, + pub ifc_ifcu: __c_anonymous_ifc_ifcu, + } +} + +cfg_if! { + if #[cfg(not(target_env = "uclibc"))] { + const DATE_BASE: crate::nl_item = 0x20000; + } else { + const DATE_BASE: crate::nl_item = 768; + } +} + +pub const ABDAY_1: crate::nl_item = DATE_BASE; +pub const ABDAY_2: crate::nl_item = DATE_BASE + 0x1; +pub const ABDAY_3: crate::nl_item = DATE_BASE + 0x2; +pub const ABDAY_4: crate::nl_item = DATE_BASE + 0x3; +pub const ABDAY_5: crate::nl_item = DATE_BASE + 0x4; +pub const ABDAY_6: crate::nl_item = DATE_BASE + 0x5; +pub const ABDAY_7: crate::nl_item = DATE_BASE + 0x6; + +pub const DAY_1: crate::nl_item = DATE_BASE + 0x7; +pub const DAY_2: crate::nl_item = DATE_BASE + 0x8; +pub const DAY_3: crate::nl_item = DATE_BASE + 0x9; +pub const DAY_4: crate::nl_item = DATE_BASE + 0xA; +pub const DAY_5: crate::nl_item = DATE_BASE + 0xB; +pub const DAY_6: crate::nl_item = DATE_BASE + 0xC; +pub const DAY_7: crate::nl_item = DATE_BASE + 0xD; + +pub const ABMON_1: crate::nl_item = DATE_BASE + 0xE; +pub const ABMON_2: crate::nl_item = DATE_BASE + 0xF; +pub const ABMON_3: crate::nl_item = DATE_BASE + 0x10; +pub const ABMON_4: crate::nl_item = DATE_BASE + 0x11; +pub const ABMON_5: crate::nl_item = DATE_BASE + 0x12; +pub const ABMON_6: crate::nl_item = DATE_BASE + 0x13; +pub const ABMON_7: crate::nl_item = DATE_BASE + 0x14; +pub const ABMON_8: crate::nl_item = DATE_BASE + 0x15; +pub const ABMON_9: crate::nl_item = DATE_BASE + 0x16; +pub const ABMON_10: crate::nl_item = DATE_BASE + 0x17; +pub const ABMON_11: crate::nl_item = DATE_BASE + 0x18; +pub const ABMON_12: crate::nl_item = DATE_BASE + 0x19; + +pub const MON_1: crate::nl_item = DATE_BASE + 0x1A; +pub const MON_2: crate::nl_item = DATE_BASE + 0x1B; +pub const MON_3: crate::nl_item = DATE_BASE + 0x1C; +pub const MON_4: crate::nl_item = DATE_BASE + 0x1D; +pub const MON_5: crate::nl_item = DATE_BASE + 0x1E; +pub const MON_6: crate::nl_item = DATE_BASE + 0x1F; +pub const MON_7: crate::nl_item = DATE_BASE + 0x20; +pub const MON_8: crate::nl_item = DATE_BASE + 0x21; +pub const MON_9: crate::nl_item = DATE_BASE + 0x22; +pub const MON_10: crate::nl_item = DATE_BASE + 0x23; +pub const MON_11: crate::nl_item = DATE_BASE + 0x24; +pub const MON_12: crate::nl_item = DATE_BASE + 0x25; + +pub const AM_STR: crate::nl_item = DATE_BASE + 0x26; +pub const PM_STR: crate::nl_item = DATE_BASE + 0x27; + +pub const D_T_FMT: crate::nl_item = DATE_BASE + 0x28; +pub const D_FMT: crate::nl_item = DATE_BASE + 0x29; +pub const T_FMT: crate::nl_item = DATE_BASE + 0x2A; +pub const T_FMT_AMPM: crate::nl_item = DATE_BASE + 0x2B; + +pub const ERA: crate::nl_item = DATE_BASE + 0x2C; +pub const ERA_D_FMT: crate::nl_item = DATE_BASE + 0x2E; +pub const ALT_DIGITS: crate::nl_item = DATE_BASE + 0x2F; +pub const ERA_D_T_FMT: crate::nl_item = DATE_BASE + 0x30; +pub const ERA_T_FMT: crate::nl_item = DATE_BASE + 0x31; + +cfg_if! { + if #[cfg(any( + target_env = "gnu", + target_env = "musl", + target_env = "ohos" + ))] { + pub const CODESET: crate::nl_item = 14; + pub const CRNCYSTR: crate::nl_item = 0x4000F; + pub const RADIXCHAR: crate::nl_item = 0x10000; + pub const THOUSEP: crate::nl_item = 0x10001; + pub const YESEXPR: crate::nl_item = 0x50000; + pub const NOEXPR: crate::nl_item = 0x50001; + pub const YESSTR: crate::nl_item = 0x50002; + pub const NOSTR: crate::nl_item = 0x50003; + } else if #[cfg(target_env = "uclibc")] { + pub const CODESET: crate::nl_item = 10; + pub const CRNCYSTR: crate::nl_item = 0x215; + pub const RADIXCHAR: crate::nl_item = 0x100; + pub const THOUSEP: crate::nl_item = 0x101; + pub const YESEXPR: crate::nl_item = 0x500; + pub const NOEXPR: crate::nl_item = 0x501; + pub const YESSTR: crate::nl_item = 0x502; + pub const NOSTR: crate::nl_item = 0x503; + } +} + +pub const RUSAGE_CHILDREN: c_int = -1; + +pub const L_tmpnam: c_uint = 20; +pub const _PC_LINK_MAX: c_int = 0; +pub const _PC_MAX_CANON: c_int = 1; +pub const _PC_MAX_INPUT: c_int = 2; +pub const _PC_NAME_MAX: c_int = 3; +pub const _PC_PATH_MAX: c_int = 4; +pub const _PC_PIPE_BUF: c_int = 5; +pub const _PC_CHOWN_RESTRICTED: c_int = 6; +pub const _PC_NO_TRUNC: c_int = 7; +pub const _PC_VDISABLE: c_int = 8; +pub const _PC_SYNC_IO: c_int = 9; +pub const _PC_ASYNC_IO: c_int = 10; +pub const _PC_PRIO_IO: c_int = 11; +pub const _PC_SOCK_MAXBUF: c_int = 12; +pub const _PC_FILESIZEBITS: c_int = 13; +pub const _PC_REC_INCR_XFER_SIZE: c_int = 14; +pub const _PC_REC_MAX_XFER_SIZE: c_int = 15; +pub const _PC_REC_MIN_XFER_SIZE: c_int = 16; +pub const _PC_REC_XFER_ALIGN: c_int = 17; +pub const _PC_ALLOC_SIZE_MIN: c_int = 18; +pub const _PC_SYMLINK_MAX: c_int = 19; +pub const _PC_2_SYMLINKS: c_int = 20; + +pub const _SC_ARG_MAX: c_int = 0; +pub const _SC_CHILD_MAX: c_int = 1; +pub const _SC_CLK_TCK: c_int = 2; +pub const _SC_NGROUPS_MAX: c_int = 3; +pub const _SC_OPEN_MAX: c_int = 4; +pub const _SC_STREAM_MAX: c_int = 5; +pub const _SC_TZNAME_MAX: c_int = 6; +pub const _SC_JOB_CONTROL: c_int = 7; +pub const _SC_SAVED_IDS: c_int = 8; +pub const _SC_REALTIME_SIGNALS: c_int = 9; +pub const _SC_PRIORITY_SCHEDULING: c_int = 10; +pub const _SC_TIMERS: c_int = 11; +pub const _SC_ASYNCHRONOUS_IO: c_int = 12; +pub const _SC_PRIORITIZED_IO: c_int = 13; +pub const _SC_SYNCHRONIZED_IO: c_int = 14; +pub const _SC_FSYNC: c_int = 15; +pub const _SC_MAPPED_FILES: c_int = 16; +pub const _SC_MEMLOCK: c_int = 17; +pub const _SC_MEMLOCK_RANGE: c_int = 18; +pub const _SC_MEMORY_PROTECTION: c_int = 19; +pub const _SC_MESSAGE_PASSING: c_int = 20; +pub const _SC_SEMAPHORES: c_int = 21; +pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 22; +pub const _SC_AIO_LISTIO_MAX: c_int = 23; +pub const _SC_AIO_MAX: c_int = 24; +pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 25; +pub const _SC_DELAYTIMER_MAX: c_int = 26; +pub const _SC_MQ_OPEN_MAX: c_int = 27; +pub const _SC_MQ_PRIO_MAX: c_int = 28; +pub const _SC_VERSION: c_int = 29; +pub const _SC_PAGESIZE: c_int = 30; +pub const _SC_PAGE_SIZE: c_int = _SC_PAGESIZE; +pub const _SC_RTSIG_MAX: c_int = 31; +pub const _SC_SEM_NSEMS_MAX: c_int = 32; +pub const _SC_SEM_VALUE_MAX: c_int = 33; +pub const _SC_SIGQUEUE_MAX: c_int = 34; +pub const _SC_TIMER_MAX: c_int = 35; +pub const _SC_BC_BASE_MAX: c_int = 36; +pub const _SC_BC_DIM_MAX: c_int = 37; +pub const _SC_BC_SCALE_MAX: c_int = 38; +pub const _SC_BC_STRING_MAX: c_int = 39; +pub const _SC_COLL_WEIGHTS_MAX: c_int = 40; +pub const _SC_EXPR_NEST_MAX: c_int = 42; +pub const _SC_LINE_MAX: c_int = 43; +pub const _SC_RE_DUP_MAX: c_int = 44; +pub const _SC_2_VERSION: c_int = 46; +pub const _SC_2_C_BIND: c_int = 47; +pub const _SC_2_C_DEV: c_int = 48; +pub const _SC_2_FORT_DEV: c_int = 49; +pub const _SC_2_FORT_RUN: c_int = 50; +pub const _SC_2_SW_DEV: c_int = 51; +pub const _SC_2_LOCALEDEF: c_int = 52; +pub const _SC_UIO_MAXIOV: c_int = 60; +pub const _SC_IOV_MAX: c_int = 60; +pub const _SC_THREADS: c_int = 67; +pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 68; +pub const _SC_GETGR_R_SIZE_MAX: c_int = 69; +pub const _SC_GETPW_R_SIZE_MAX: c_int = 70; +pub const _SC_LOGIN_NAME_MAX: c_int = 71; +pub const _SC_TTY_NAME_MAX: c_int = 72; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 73; +pub const _SC_THREAD_KEYS_MAX: c_int = 74; +pub const _SC_THREAD_STACK_MIN: c_int = 75; +pub const _SC_THREAD_THREADS_MAX: c_int = 76; +pub const _SC_THREAD_ATTR_STACKADDR: c_int = 77; +pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 78; +pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 79; +pub const _SC_THREAD_PRIO_INHERIT: c_int = 80; +pub const _SC_THREAD_PRIO_PROTECT: c_int = 81; +pub const _SC_THREAD_PROCESS_SHARED: c_int = 82; +pub const _SC_NPROCESSORS_CONF: c_int = 83; +pub const _SC_NPROCESSORS_ONLN: c_int = 84; +pub const _SC_PHYS_PAGES: c_int = 85; +pub const _SC_AVPHYS_PAGES: c_int = 86; +pub const _SC_ATEXIT_MAX: c_int = 87; +pub const _SC_PASS_MAX: c_int = 88; +pub const _SC_XOPEN_VERSION: c_int = 89; +pub const _SC_XOPEN_XCU_VERSION: c_int = 90; +pub const _SC_XOPEN_UNIX: c_int = 91; +pub const _SC_XOPEN_CRYPT: c_int = 92; +pub const _SC_XOPEN_ENH_I18N: c_int = 93; +pub const _SC_XOPEN_SHM: c_int = 94; +pub const _SC_2_CHAR_TERM: c_int = 95; +pub const _SC_2_UPE: c_int = 97; +pub const _SC_XOPEN_XPG2: c_int = 98; +pub const _SC_XOPEN_XPG3: c_int = 99; +pub const _SC_XOPEN_XPG4: c_int = 100; +pub const _SC_NZERO: c_int = 109; +pub const _SC_XBS5_ILP32_OFF32: c_int = 125; +pub const _SC_XBS5_ILP32_OFFBIG: c_int = 126; +pub const _SC_XBS5_LP64_OFF64: c_int = 127; +pub const _SC_XBS5_LPBIG_OFFBIG: c_int = 128; +pub const _SC_XOPEN_LEGACY: c_int = 129; +pub const _SC_XOPEN_REALTIME: c_int = 130; +pub const _SC_XOPEN_REALTIME_THREADS: c_int = 131; +pub const _SC_ADVISORY_INFO: c_int = 132; +pub const _SC_BARRIERS: c_int = 133; +pub const _SC_CLOCK_SELECTION: c_int = 137; +pub const _SC_CPUTIME: c_int = 138; +pub const _SC_THREAD_CPUTIME: c_int = 139; +pub const _SC_MONOTONIC_CLOCK: c_int = 149; +pub const _SC_READER_WRITER_LOCKS: c_int = 153; +pub const _SC_SPIN_LOCKS: c_int = 154; +pub const _SC_REGEXP: c_int = 155; +pub const _SC_SHELL: c_int = 157; +pub const _SC_SPAWN: c_int = 159; +pub const _SC_SPORADIC_SERVER: c_int = 160; +pub const _SC_THREAD_SPORADIC_SERVER: c_int = 161; +pub const _SC_TIMEOUTS: c_int = 164; +pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 165; +pub const _SC_2_PBS: c_int = 168; +pub const _SC_2_PBS_ACCOUNTING: c_int = 169; +pub const _SC_2_PBS_LOCATE: c_int = 170; +pub const _SC_2_PBS_MESSAGE: c_int = 171; +pub const _SC_2_PBS_TRACK: c_int = 172; +pub const _SC_SYMLOOP_MAX: c_int = 173; +pub const _SC_STREAMS: c_int = 174; +pub const _SC_2_PBS_CHECKPOINT: c_int = 175; +pub const _SC_V6_ILP32_OFF32: c_int = 176; +pub const _SC_V6_ILP32_OFFBIG: c_int = 177; +pub const _SC_V6_LP64_OFF64: c_int = 178; +pub const _SC_V6_LPBIG_OFFBIG: c_int = 179; +pub const _SC_HOST_NAME_MAX: c_int = 180; +pub const _SC_TRACE: c_int = 181; +pub const _SC_TRACE_EVENT_FILTER: c_int = 182; +pub const _SC_TRACE_INHERIT: c_int = 183; +pub const _SC_TRACE_LOG: c_int = 184; +pub const _SC_IPV6: c_int = 235; +pub const _SC_RAW_SOCKETS: c_int = 236; +pub const _SC_V7_ILP32_OFF32: c_int = 237; +pub const _SC_V7_ILP32_OFFBIG: c_int = 238; +pub const _SC_V7_LP64_OFF64: c_int = 239; +pub const _SC_V7_LPBIG_OFFBIG: c_int = 240; +pub const _SC_SS_REPL_MAX: c_int = 241; +pub const _SC_TRACE_EVENT_NAME_MAX: c_int = 242; +pub const _SC_TRACE_NAME_MAX: c_int = 243; +pub const _SC_TRACE_SYS_MAX: c_int = 244; +pub const _SC_TRACE_USER_EVENT_MAX: c_int = 245; +pub const _SC_XOPEN_STREAMS: c_int = 246; +pub const _SC_THREAD_ROBUST_PRIO_INHERIT: c_int = 247; +pub const _SC_THREAD_ROBUST_PRIO_PROTECT: c_int = 248; + +pub const _CS_PATH: c_int = 0; +pub const _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS: c_int = 1; +pub const _CS_POSIX_V5_WIDTH_RESTRICTED_ENVS: c_int = 4; +pub const _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS: c_int = 5; +pub const _CS_POSIX_V6_ILP32_OFF32_CFLAGS: c_int = 1116; +pub const _CS_POSIX_V6_ILP32_OFF32_LDFLAGS: c_int = 1117; +pub const _CS_POSIX_V6_ILP32_OFF32_LIBS: c_int = 1118; +pub const _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS: c_int = 1119; +pub const _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS: c_int = 1120; +pub const _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS: c_int = 1121; +pub const _CS_POSIX_V6_ILP32_OFFBIG_LIBS: c_int = 1122; +pub const _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS: c_int = 1123; +pub const _CS_POSIX_V6_LP64_OFF64_CFLAGS: c_int = 1124; +pub const _CS_POSIX_V6_LP64_OFF64_LDFLAGS: c_int = 1125; +pub const _CS_POSIX_V6_LP64_OFF64_LIBS: c_int = 1126; +pub const _CS_POSIX_V6_LP64_OFF64_LINTFLAGS: c_int = 1127; +pub const _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS: c_int = 1128; +pub const _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS: c_int = 1129; +pub const _CS_POSIX_V6_LPBIG_OFFBIG_LIBS: c_int = 1130; +pub const _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS: c_int = 1131; +pub const _CS_POSIX_V7_ILP32_OFF32_CFLAGS: c_int = 1132; +pub const _CS_POSIX_V7_ILP32_OFF32_LDFLAGS: c_int = 1133; +pub const _CS_POSIX_V7_ILP32_OFF32_LIBS: c_int = 1134; +pub const _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS: c_int = 1135; +pub const _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS: c_int = 1136; +pub const _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS: c_int = 1137; +pub const _CS_POSIX_V7_ILP32_OFFBIG_LIBS: c_int = 1138; +pub const _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS: c_int = 1139; +pub const _CS_POSIX_V7_LP64_OFF64_CFLAGS: c_int = 1140; +pub const _CS_POSIX_V7_LP64_OFF64_LDFLAGS: c_int = 1141; +pub const _CS_POSIX_V7_LP64_OFF64_LIBS: c_int = 1142; +pub const _CS_POSIX_V7_LP64_OFF64_LINTFLAGS: c_int = 1143; +pub const _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS: c_int = 1144; +pub const _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS: c_int = 1145; +pub const _CS_POSIX_V7_LPBIG_OFFBIG_LIBS: c_int = 1146; +pub const _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS: c_int = 1147; + +pub const RLIM_SAVED_MAX: crate::rlim_t = crate::RLIM_INFINITY; +pub const RLIM_SAVED_CUR: crate::rlim_t = crate::RLIM_INFINITY; + +// elf.h - Fields in the e_ident array. +pub const EI_NIDENT: usize = 16; + +pub const EI_MAG0: usize = 0; +pub const ELFMAG0: u8 = 0x7f; +pub const EI_MAG1: usize = 1; +pub const ELFMAG1: u8 = b'E'; +pub const EI_MAG2: usize = 2; +pub const ELFMAG2: u8 = b'L'; +pub const EI_MAG3: usize = 3; +pub const ELFMAG3: u8 = b'F'; +pub const SELFMAG: usize = 4; + +pub const EI_CLASS: usize = 4; +pub const ELFCLASSNONE: u8 = 0; +pub const ELFCLASS32: u8 = 1; +pub const ELFCLASS64: u8 = 2; +pub const ELFCLASSNUM: usize = 3; + +pub const EI_DATA: usize = 5; +pub const ELFDATANONE: u8 = 0; +pub const ELFDATA2LSB: u8 = 1; +pub const ELFDATA2MSB: u8 = 2; +pub const ELFDATANUM: usize = 3; + +pub const EI_VERSION: usize = 6; + +pub const EI_OSABI: usize = 7; +pub const ELFOSABI_NONE: u8 = 0; +pub const ELFOSABI_SYSV: u8 = 0; +pub const ELFOSABI_HPUX: u8 = 1; +pub const ELFOSABI_NETBSD: u8 = 2; +pub const ELFOSABI_GNU: u8 = 3; +pub const ELFOSABI_LINUX: u8 = ELFOSABI_GNU; +pub const ELFOSABI_SOLARIS: u8 = 6; +pub const ELFOSABI_AIX: u8 = 7; +pub const ELFOSABI_IRIX: u8 = 8; +pub const ELFOSABI_FREEBSD: u8 = 9; +pub const ELFOSABI_TRU64: u8 = 10; +pub const ELFOSABI_MODESTO: u8 = 11; +pub const ELFOSABI_OPENBSD: u8 = 12; +pub const ELFOSABI_ARM: u8 = 97; +pub const ELFOSABI_STANDALONE: u8 = 255; + +pub const EI_ABIVERSION: usize = 8; + +pub const EI_PAD: usize = 9; + +// elf.h - Legal values for e_type (object file type). +pub const ET_NONE: u16 = 0; +pub const ET_REL: u16 = 1; +pub const ET_EXEC: u16 = 2; +pub const ET_DYN: u16 = 3; +pub const ET_CORE: u16 = 4; +pub const ET_NUM: u16 = 5; +pub const ET_LOOS: u16 = 0xfe00; +pub const ET_HIOS: u16 = 0xfeff; +pub const ET_LOPROC: u16 = 0xff00; +pub const ET_HIPROC: u16 = 0xffff; + +// elf.h - Legal values for e_machine (architecture). +pub const EM_NONE: u16 = 0; +pub const EM_M32: u16 = 1; +pub const EM_SPARC: u16 = 2; +pub const EM_386: u16 = 3; +pub const EM_68K: u16 = 4; +pub const EM_88K: u16 = 5; +pub const EM_860: u16 = 7; +pub const EM_MIPS: u16 = 8; +pub const EM_S370: u16 = 9; +pub const EM_MIPS_RS3_LE: u16 = 10; +pub const EM_PARISC: u16 = 15; +pub const EM_VPP500: u16 = 17; +pub const EM_SPARC32PLUS: u16 = 18; +pub const EM_960: u16 = 19; +pub const EM_PPC: u16 = 20; +pub const EM_PPC64: u16 = 21; +pub const EM_S390: u16 = 22; +pub const EM_V800: u16 = 36; +pub const EM_FR20: u16 = 37; +pub const EM_RH32: u16 = 38; +pub const EM_RCE: u16 = 39; +pub const EM_ARM: u16 = 40; +pub const EM_FAKE_ALPHA: u16 = 41; +pub const EM_SH: u16 = 42; +pub const EM_SPARCV9: u16 = 43; +pub const EM_TRICORE: u16 = 44; +pub const EM_ARC: u16 = 45; +pub const EM_H8_300: u16 = 46; +pub const EM_H8_300H: u16 = 47; +pub const EM_H8S: u16 = 48; +pub const EM_H8_500: u16 = 49; +pub const EM_IA_64: u16 = 50; +pub const EM_MIPS_X: u16 = 51; +pub const EM_COLDFIRE: u16 = 52; +pub const EM_68HC12: u16 = 53; +pub const EM_MMA: u16 = 54; +pub const EM_PCP: u16 = 55; +pub const EM_NCPU: u16 = 56; +pub const EM_NDR1: u16 = 57; +pub const EM_STARCORE: u16 = 58; +pub const EM_ME16: u16 = 59; +pub const EM_ST100: u16 = 60; +pub const EM_TINYJ: u16 = 61; +pub const EM_X86_64: u16 = 62; +pub const EM_PDSP: u16 = 63; +pub const EM_FX66: u16 = 66; +pub const EM_ST9PLUS: u16 = 67; +pub const EM_ST7: u16 = 68; +pub const EM_68HC16: u16 = 69; +pub const EM_68HC11: u16 = 70; +pub const EM_68HC08: u16 = 71; +pub const EM_68HC05: u16 = 72; +pub const EM_SVX: u16 = 73; +pub const EM_ST19: u16 = 74; +pub const EM_VAX: u16 = 75; +pub const EM_CRIS: u16 = 76; +pub const EM_JAVELIN: u16 = 77; +pub const EM_FIREPATH: u16 = 78; +pub const EM_ZSP: u16 = 79; +pub const EM_MMIX: u16 = 80; +pub const EM_HUANY: u16 = 81; +pub const EM_PRISM: u16 = 82; +pub const EM_AVR: u16 = 83; +pub const EM_FR30: u16 = 84; +pub const EM_D10V: u16 = 85; +pub const EM_D30V: u16 = 86; +pub const EM_V850: u16 = 87; +pub const EM_M32R: u16 = 88; +pub const EM_MN10300: u16 = 89; +pub const EM_MN10200: u16 = 90; +pub const EM_PJ: u16 = 91; +#[cfg(not(target_env = "uclibc"))] +pub const EM_OPENRISC: u16 = 92; +#[cfg(target_env = "uclibc")] +pub const EM_OR1K: u16 = 92; +#[cfg(not(target_env = "uclibc"))] +pub const EM_ARC_A5: u16 = 93; +pub const EM_XTENSA: u16 = 94; +pub const EM_AARCH64: u16 = 183; +pub const EM_TILEPRO: u16 = 188; +pub const EM_TILEGX: u16 = 191; +pub const EM_RISCV: u16 = 243; +pub const EM_ALPHA: u16 = 0x9026; + +// elf.h - Legal values for e_version (version). +pub const EV_NONE: u32 = 0; +pub const EV_CURRENT: u32 = 1; +pub const EV_NUM: u32 = 2; + +// elf.h - Legal values for p_type (segment type). +pub const PT_NULL: u32 = 0; +pub const PT_LOAD: u32 = 1; +pub const PT_DYNAMIC: u32 = 2; +pub const PT_INTERP: u32 = 3; +pub const PT_NOTE: u32 = 4; +pub const PT_SHLIB: u32 = 5; +pub const PT_PHDR: u32 = 6; +pub const PT_TLS: u32 = 7; +pub const PT_NUM: u32 = 8; +pub const PT_LOOS: u32 = 0x60000000; +pub const PT_GNU_EH_FRAME: u32 = 0x6474e550; +pub const PT_GNU_STACK: u32 = 0x6474e551; +pub const PT_GNU_RELRO: u32 = 0x6474e552; +pub const PT_LOSUNW: u32 = 0x6ffffffa; +pub const PT_SUNWBSS: u32 = 0x6ffffffa; +pub const PT_SUNWSTACK: u32 = 0x6ffffffb; +pub const PT_HISUNW: u32 = 0x6fffffff; +pub const PT_HIOS: u32 = 0x6fffffff; +pub const PT_LOPROC: u32 = 0x70000000; +pub const PT_HIPROC: u32 = 0x7fffffff; + +// Legal values for p_flags (segment flags). +pub const PF_X: u32 = 1 << 0; +pub const PF_W: u32 = 1 << 1; +pub const PF_R: u32 = 1 << 2; +pub const PF_MASKOS: u32 = 0x0ff00000; +pub const PF_MASKPROC: u32 = 0xf0000000; + +// elf.h - Legal values for a_type (entry type). +pub const AT_NULL: c_ulong = 0; +pub const AT_IGNORE: c_ulong = 1; +pub const AT_EXECFD: c_ulong = 2; +pub const AT_PHDR: c_ulong = 3; +pub const AT_PHENT: c_ulong = 4; +pub const AT_PHNUM: c_ulong = 5; +pub const AT_PAGESZ: c_ulong = 6; +pub const AT_BASE: c_ulong = 7; +pub const AT_FLAGS: c_ulong = 8; +pub const AT_ENTRY: c_ulong = 9; +pub const AT_NOTELF: c_ulong = 10; +pub const AT_UID: c_ulong = 11; +pub const AT_EUID: c_ulong = 12; +pub const AT_GID: c_ulong = 13; +pub const AT_EGID: c_ulong = 14; +pub const AT_PLATFORM: c_ulong = 15; +pub const AT_HWCAP: c_ulong = 16; +pub const AT_CLKTCK: c_ulong = 17; + +pub const AT_SECURE: c_ulong = 23; +pub const AT_BASE_PLATFORM: c_ulong = 24; +pub const AT_RANDOM: c_ulong = 25; +pub const AT_HWCAP2: c_ulong = 26; + +pub const AT_HWCAP3: c_ulong = 29; +pub const AT_HWCAP4: c_ulong = 30; +pub const AT_EXECFN: c_ulong = 31; + +// defined in arch//include/uapi/asm/auxvec.h but has the same value +// wherever it is defined. +pub const AT_SYSINFO_EHDR: c_ulong = 33; +#[cfg(not(target_env = "uclibc"))] +pub const AT_MINSIGSTKSZ: c_ulong = 51; + +pub const GLOB_ERR: c_int = 1 << 0; +pub const GLOB_MARK: c_int = 1 << 1; +pub const GLOB_NOSORT: c_int = 1 << 2; +pub const GLOB_DOOFFS: c_int = 1 << 3; +pub const GLOB_NOCHECK: c_int = 1 << 4; +pub const GLOB_APPEND: c_int = 1 << 5; +pub const GLOB_NOESCAPE: c_int = 1 << 6; + +pub const GLOB_NOSPACE: c_int = 1; +pub const GLOB_ABORTED: c_int = 2; +pub const GLOB_NOMATCH: c_int = 3; + +pub const POSIX_MADV_NORMAL: c_int = 0; +pub const POSIX_MADV_RANDOM: c_int = 1; +pub const POSIX_MADV_SEQUENTIAL: c_int = 2; +pub const POSIX_MADV_WILLNEED: c_int = 3; +pub const POSIX_MADV_DONTNEED: c_int = 4; + +pub const S_IEXEC: crate::mode_t = 0o0100; +pub const S_IWRITE: crate::mode_t = 0o0200; +pub const S_IREAD: crate::mode_t = 0o0400; + +pub const F_LOCK: c_int = 1; +pub const F_TEST: c_int = 3; +pub const F_TLOCK: c_int = 2; +pub const F_ULOCK: c_int = 0; + +pub const ST_RDONLY: c_ulong = 1; +pub const ST_NOSUID: c_ulong = 2; +pub const ST_NODEV: c_ulong = 4; +pub const ST_NOEXEC: c_ulong = 8; +pub const ST_SYNCHRONOUS: c_ulong = 16; +pub const ST_MANDLOCK: c_ulong = 64; +pub const ST_WRITE: c_ulong = 128; +pub const ST_APPEND: c_ulong = 256; +pub const ST_IMMUTABLE: c_ulong = 512; +pub const ST_NOATIME: c_ulong = 1024; +pub const ST_NODIRATIME: c_ulong = 2048; + +pub const RTLD_NEXT: *mut c_void = -1i64 as *mut c_void; +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); +pub const RTLD_NODELETE: c_int = 0x1000; +pub const RTLD_NOW: c_int = 0x2; + +pub const AT_EACCESS: c_int = 0x200; + +pub const PTHREAD_BARRIER_SERIAL_THREAD: c_int = -1; +pub const PTHREAD_ONCE_INIT: crate::pthread_once_t = 0; +pub const PTHREAD_MUTEX_NORMAL: c_int = 0; +pub const PTHREAD_MUTEX_RECURSIVE: c_int = 1; +pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 2; +pub const PTHREAD_MUTEX_DEFAULT: c_int = PTHREAD_MUTEX_NORMAL; +#[cfg(not(target_env = "uclibc"))] +pub const PTHREAD_MUTEX_STALLED: c_int = 0; +#[cfg(not(target_env = "uclibc"))] +pub const PTHREAD_MUTEX_ROBUST: c_int = 1; +#[cfg(not(target_env = "uclibc"))] +pub const PTHREAD_PRIO_NONE: c_int = 0; +#[cfg(not(target_env = "uclibc"))] +pub const PTHREAD_PRIO_INHERIT: c_int = 1; +#[cfg(not(target_env = "uclibc"))] +pub const PTHREAD_PRIO_PROTECT: c_int = 2; +pub const PTHREAD_PROCESS_PRIVATE: c_int = 0; +pub const PTHREAD_PROCESS_SHARED: c_int = 1; +pub const PTHREAD_INHERIT_SCHED: c_int = 0; +pub const PTHREAD_EXPLICIT_SCHED: c_int = 1; +#[cfg(not(all(target_os = "l4re", target_env = "uclibc")))] +pub const __SIZEOF_PTHREAD_COND_T: usize = 48; + +// netinet/in.h +// NOTE: These are in addition to the constants defined in src/unix/mod.rs + +#[deprecated( + since = "0.2.80", + note = "This value was increased in the newer kernel \ + and we'll change this following upstream in the future release. \ + See #1896 for more info." +)] +pub const IPPROTO_MAX: c_int = 256; + +// System V IPC +pub const IPC_PRIVATE: crate::key_t = 0; + +pub const IPC_CREAT: c_int = 0o1000; +pub const IPC_EXCL: c_int = 0o2000; +pub const IPC_NOWAIT: c_int = 0o4000; + +pub const IPC_RMID: c_int = 0; +pub const IPC_SET: c_int = 1; +pub const IPC_STAT: c_int = if cfg!(musl_redir_time64) { 0x102 } else { 2 }; +pub const IPC_INFO: c_int = 3; + +pub const SHM_R: c_int = 0o400; +pub const SHM_W: c_int = 0o200; + +pub const SHM_RDONLY: c_int = 0o10000; +pub const SHM_RND: c_int = 0o20000; +pub const SHM_REMAP: c_int = 0o40000; +pub const SHM_LOCK: c_int = 11; +pub const SHM_UNLOCK: c_int = 12; +pub const SHM_HUGETLB: c_int = 0o4000; +#[cfg(not(all(target_env = "uclibc", target_arch = "mips")))] +pub const SHM_NORESERVE: c_int = 0o10000; + +pub const LOG_NFACILITIES: c_int = 24; + +pub const SEM_FAILED: *mut crate::sem_t = ptr::null_mut(); + +pub const AI_PASSIVE: c_int = 0x0001; +pub const AI_CANONNAME: c_int = 0x0002; +pub const AI_NUMERICHOST: c_int = 0x0004; +pub const AI_V4MAPPED: c_int = 0x0008; +pub const AI_ALL: c_int = 0x0010; +pub const AI_ADDRCONFIG: c_int = 0x0020; + +pub const AI_NUMERICSERV: c_int = 0x0400; + +pub const EAI_BADFLAGS: c_int = -1; +pub const EAI_NONAME: c_int = -2; +pub const EAI_AGAIN: c_int = -3; +pub const EAI_FAIL: c_int = -4; +pub const EAI_NODATA: c_int = -5; +pub const EAI_FAMILY: c_int = -6; +pub const EAI_SOCKTYPE: c_int = -7; +pub const EAI_SERVICE: c_int = -8; +pub const EAI_MEMORY: c_int = -10; +pub const EAI_SYSTEM: c_int = -11; +pub const EAI_OVERFLOW: c_int = -12; + +pub const NI_NUMERICHOST: c_int = 1; +pub const NI_NUMERICSERV: c_int = 2; +pub const NI_NOFQDN: c_int = 4; +pub const NI_NAMEREQD: c_int = 8; +pub const NI_DGRAM: c_int = 16; +#[cfg(not(target_env = "uclibc"))] +pub const NI_IDN: c_int = 32; + +cfg_if! { + if #[cfg(not(target_env = "uclibc"))] { + pub const AIO_CANCELED: c_int = 0; + pub const AIO_NOTCANCELED: c_int = 1; + pub const AIO_ALLDONE: c_int = 2; + pub const LIO_READ: c_int = 0; + pub const LIO_WRITE: c_int = 1; + pub const LIO_NOP: c_int = 2; + pub const LIO_WAIT: c_int = 0; + pub const LIO_NOWAIT: c_int = 1; + pub const RUSAGE_THREAD: c_int = 1; + pub const MSG_COPY: c_int = 0o40000; + pub const SHM_EXEC: c_int = 0o100000; + pub const IPV6_MULTICAST_ALL: c_int = 29; + pub const IPV6_ROUTER_ALERT_ISOLATE: c_int = 30; + pub const PACKET_MR_UNICAST: c_int = 3; + pub const PTRACE_EVENT_STOP: c_int = 128; + pub const UDP_SEGMENT: c_int = 103; + pub const UDP_GRO: c_int = 104; + } +} + +pub const PR_SET_PDEATHSIG: c_int = 1; +pub const PR_GET_PDEATHSIG: c_int = 2; + +pub const PR_GET_DUMPABLE: c_int = 3; +pub const PR_SET_DUMPABLE: c_int = 4; + +pub const PR_GET_UNALIGN: c_int = 5; +pub const PR_SET_UNALIGN: c_int = 6; +pub const PR_UNALIGN_NOPRINT: c_int = 1; +pub const PR_UNALIGN_SIGBUS: c_int = 2; + +pub const PR_GET_KEEPCAPS: c_int = 7; +pub const PR_SET_KEEPCAPS: c_int = 8; + +pub const PR_GET_FPEMU: c_int = 9; +pub const PR_SET_FPEMU: c_int = 10; +pub const PR_FPEMU_NOPRINT: c_int = 1; +pub const PR_FPEMU_SIGFPE: c_int = 2; + +pub const PR_GET_FPEXC: c_int = 11; +pub const PR_SET_FPEXC: c_int = 12; +pub const PR_FP_EXC_SW_ENABLE: c_int = 0x80; +pub const PR_FP_EXC_DIV: c_int = 0x010000; +pub const PR_FP_EXC_OVF: c_int = 0x020000; +pub const PR_FP_EXC_UND: c_int = 0x040000; +pub const PR_FP_EXC_RES: c_int = 0x080000; +pub const PR_FP_EXC_INV: c_int = 0x100000; +pub const PR_FP_EXC_DISABLED: c_int = 0; +pub const PR_FP_EXC_NONRECOV: c_int = 1; +pub const PR_FP_EXC_ASYNC: c_int = 2; +pub const PR_FP_EXC_PRECISE: c_int = 3; + +pub const PR_GET_TIMING: c_int = 13; +pub const PR_SET_TIMING: c_int = 14; +pub const PR_TIMING_STATISTICAL: c_int = 0; +pub const PR_TIMING_TIMESTAMP: c_int = 1; + +pub const PR_SET_NAME: c_int = 15; +pub const PR_GET_NAME: c_int = 16; + +pub const PR_GET_ENDIAN: c_int = 19; +pub const PR_SET_ENDIAN: c_int = 20; +pub const PR_ENDIAN_BIG: c_int = 0; +pub const PR_ENDIAN_LITTLE: c_int = 1; +pub const PR_ENDIAN_PPC_LITTLE: c_int = 2; + +pub const PR_GET_SECCOMP: c_int = 21; +pub const PR_SET_SECCOMP: c_int = 22; + +pub const PR_CAPBSET_READ: c_int = 23; +pub const PR_CAPBSET_DROP: c_int = 24; + +pub const PR_GET_TSC: c_int = 25; +pub const PR_SET_TSC: c_int = 26; +pub const PR_TSC_ENABLE: c_int = 1; +pub const PR_TSC_SIGSEGV: c_int = 2; + +pub const PR_GET_SECUREBITS: c_int = 27; +pub const PR_SET_SECUREBITS: c_int = 28; + +pub const PR_SET_TIMERSLACK: c_int = 29; +pub const PR_GET_TIMERSLACK: c_int = 30; + +pub const PR_TASK_PERF_EVENTS_DISABLE: c_int = 31; +pub const PR_TASK_PERF_EVENTS_ENABLE: c_int = 32; + +pub const PR_MCE_KILL: c_int = 33; +pub const PR_MCE_KILL_CLEAR: c_int = 0; +pub const PR_MCE_KILL_SET: c_int = 1; + +pub const PR_MCE_KILL_LATE: c_int = 0; +pub const PR_MCE_KILL_EARLY: c_int = 1; +pub const PR_MCE_KILL_DEFAULT: c_int = 2; + +pub const PR_MCE_KILL_GET: c_int = 34; + +pub const PR_SET_MM: c_int = 35; +pub const PR_SET_MM_START_CODE: c_int = 1; +pub const PR_SET_MM_END_CODE: c_int = 2; +pub const PR_SET_MM_START_DATA: c_int = 3; +pub const PR_SET_MM_END_DATA: c_int = 4; +pub const PR_SET_MM_START_STACK: c_int = 5; +pub const PR_SET_MM_START_BRK: c_int = 6; +pub const PR_SET_MM_BRK: c_int = 7; +pub const PR_SET_MM_ARG_START: c_int = 8; +pub const PR_SET_MM_ARG_END: c_int = 9; +pub const PR_SET_MM_ENV_START: c_int = 10; +pub const PR_SET_MM_ENV_END: c_int = 11; +pub const PR_SET_MM_AUXV: c_int = 12; +pub const PR_SET_MM_EXE_FILE: c_int = 13; +pub const PR_SET_MM_MAP: c_int = 14; +pub const PR_SET_MM_MAP_SIZE: c_int = 15; + +pub const PR_SET_PTRACER: c_int = 0x59616d61; +pub const PR_SET_PTRACER_ANY: c_ulong = 0xffffffffffffffff; + +pub const PR_SET_CHILD_SUBREAPER: c_int = 36; +pub const PR_GET_CHILD_SUBREAPER: c_int = 37; + +pub const PR_SET_NO_NEW_PRIVS: c_int = 38; +pub const PR_GET_NO_NEW_PRIVS: c_int = 39; + +pub const PR_GET_TID_ADDRESS: c_int = 40; + +pub const PR_SET_THP_DISABLE: c_int = 41; +pub const PR_GET_THP_DISABLE: c_int = 42; + +pub const PR_MPX_ENABLE_MANAGEMENT: c_int = 43; +pub const PR_MPX_DISABLE_MANAGEMENT: c_int = 44; + +pub const PR_SET_FP_MODE: c_int = 45; +pub const PR_GET_FP_MODE: c_int = 46; +pub const PR_FP_MODE_FR: c_int = 1 << 0; +pub const PR_FP_MODE_FRE: c_int = 1 << 1; + +pub const PR_CAP_AMBIENT: c_int = 47; +pub const PR_CAP_AMBIENT_IS_SET: c_int = 1; +pub const PR_CAP_AMBIENT_RAISE: c_int = 2; +pub const PR_CAP_AMBIENT_LOWER: c_int = 3; +pub const PR_CAP_AMBIENT_CLEAR_ALL: c_int = 4; + +pub const PR_SET_VMA: c_int = 0x53564d41; +pub const PR_SET_VMA_ANON_NAME: c_int = 0; + +pub const PR_SCHED_CORE: c_int = 62; +pub const PR_SCHED_CORE_GET: c_int = 0; +pub const PR_SCHED_CORE_CREATE: c_int = 1; +pub const PR_SCHED_CORE_SHARE_TO: c_int = 2; +pub const PR_SCHED_CORE_SHARE_FROM: c_int = 3; +pub const PR_SCHED_CORE_MAX: c_int = 4; +pub const PR_SCHED_CORE_SCOPE_THREAD: c_int = 0; +pub const PR_SCHED_CORE_SCOPE_THREAD_GROUP: c_int = 1; +pub const PR_SCHED_CORE_SCOPE_PROCESS_GROUP: c_int = 2; + +pub const ITIMER_REAL: c_int = 0; +pub const ITIMER_VIRTUAL: c_int = 1; +pub const ITIMER_PROF: c_int = 2; + +pub const _POSIX_VDISABLE: crate::cc_t = 0; + +pub const IPV6_RTHDR_LOOSE: c_int = 0; +pub const IPV6_RTHDR_STRICT: c_int = 1; + +pub const IUTF8: crate::tcflag_t = 0x00004000; +#[cfg(not(all(target_env = "uclibc", target_arch = "mips")))] +pub const CMSPAR: crate::tcflag_t = 0o10000000000; + +pub const MFD_CLOEXEC: c_uint = 0x0001; +pub const MFD_ALLOW_SEALING: c_uint = 0x0002; +pub const MFD_HUGETLB: c_uint = 0x0004; +cfg_if! { + if #[cfg(not(target_env = "uclibc"))] { + pub const MFD_NOEXEC_SEAL: c_uint = 0x0008; + pub const MFD_EXEC: c_uint = 0x0010; + pub const MFD_HUGE_64KB: c_uint = 0x40000000; + pub const MFD_HUGE_512KB: c_uint = 0x4c000000; + pub const MFD_HUGE_1MB: c_uint = 0x50000000; + pub const MFD_HUGE_2MB: c_uint = 0x54000000; + pub const MFD_HUGE_8MB: c_uint = 0x5c000000; + pub const MFD_HUGE_16MB: c_uint = 0x60000000; + pub const MFD_HUGE_32MB: c_uint = 0x64000000; + pub const MFD_HUGE_256MB: c_uint = 0x70000000; + pub const MFD_HUGE_512MB: c_uint = 0x74000000; + pub const MFD_HUGE_1GB: c_uint = 0x78000000; + pub const MFD_HUGE_2GB: c_uint = 0x7c000000; + pub const MFD_HUGE_16GB: c_uint = 0x88000000; + pub const MFD_HUGE_MASK: c_uint = 63; + pub const MFD_HUGE_SHIFT: c_uint = 26; + } +} + +// linux/if_packet.h +pub const PACKET_HOST: c_uchar = 0; +pub const PACKET_BROADCAST: c_uchar = 1; +pub const PACKET_MULTICAST: c_uchar = 2; +pub const PACKET_OTHERHOST: c_uchar = 3; +pub const PACKET_OUTGOING: c_uchar = 4; +pub const PACKET_LOOPBACK: c_uchar = 5; +#[cfg(not(target_os = "l4re"))] +pub const PACKET_USER: c_uchar = 6; +#[cfg(not(target_os = "l4re"))] +pub const PACKET_KERNEL: c_uchar = 7; + +pub const PACKET_ADD_MEMBERSHIP: c_int = 1; +pub const PACKET_DROP_MEMBERSHIP: c_int = 2; +pub const PACKET_RECV_OUTPUT: c_int = 3; +pub const PACKET_RX_RING: c_int = 5; +pub const PACKET_STATISTICS: c_int = 6; +cfg_if! { + if #[cfg(not(target_os = "l4re"))] { + pub const PACKET_COPY_THRESH: c_int = 7; + pub const PACKET_AUXDATA: c_int = 8; + pub const PACKET_ORIGDEV: c_int = 9; + pub const PACKET_VERSION: c_int = 10; + pub const PACKET_HDRLEN: c_int = 11; + pub const PACKET_RESERVE: c_int = 12; + pub const PACKET_TX_RING: c_int = 13; + pub const PACKET_LOSS: c_int = 14; + pub const PACKET_VNET_HDR: c_int = 15; + pub const PACKET_TX_TIMESTAMP: c_int = 16; + pub const PACKET_TIMESTAMP: c_int = 17; + } +} + +pub const PACKET_MR_MULTICAST: c_int = 0; +pub const PACKET_MR_PROMISC: c_int = 1; +pub const PACKET_MR_ALLMULTI: c_int = 2; + +pub const SIOCADDRT: c_ulong = 0x0000890B; +pub const SIOCDELRT: c_ulong = 0x0000890C; +pub const SIOCGIFNAME: c_ulong = 0x00008910; +pub const SIOCSIFLINK: c_ulong = 0x00008911; +pub const SIOCGIFCONF: c_ulong = 0x00008912; +pub const SIOCGIFFLAGS: c_ulong = 0x00008913; +pub const SIOCSIFFLAGS: c_ulong = 0x00008914; +pub const SIOCGIFADDR: c_ulong = 0x00008915; +pub const SIOCSIFADDR: c_ulong = 0x00008916; +pub const SIOCGIFDSTADDR: c_ulong = 0x00008917; +pub const SIOCSIFDSTADDR: c_ulong = 0x00008918; +pub const SIOCGIFBRDADDR: c_ulong = 0x00008919; +pub const SIOCSIFBRDADDR: c_ulong = 0x0000891A; +pub const SIOCGIFNETMASK: c_ulong = 0x0000891B; +pub const SIOCSIFNETMASK: c_ulong = 0x0000891C; +pub const SIOCGIFMETRIC: c_ulong = 0x0000891D; +pub const SIOCSIFMETRIC: c_ulong = 0x0000891E; +pub const SIOCGIFMEM: c_ulong = 0x0000891F; +pub const SIOCSIFMEM: c_ulong = 0x00008920; +pub const SIOCGIFMTU: c_ulong = 0x00008921; +pub const SIOCSIFMTU: c_ulong = 0x00008922; +pub const SIOCSIFNAME: c_ulong = 0x00008923; +pub const SIOCSIFHWADDR: c_ulong = 0x00008924; +pub const SIOCGIFENCAP: c_ulong = 0x00008925; +pub const SIOCSIFENCAP: c_ulong = 0x00008926; +pub const SIOCGIFHWADDR: c_ulong = 0x00008927; +pub const SIOCGIFSLAVE: c_ulong = 0x00008929; +pub const SIOCSIFSLAVE: c_ulong = 0x00008930; +pub const SIOCADDMULTI: c_ulong = 0x00008931; +pub const SIOCDELMULTI: c_ulong = 0x00008932; +pub const SIOCGIFINDEX: c_ulong = 0x00008933; +pub const SIOGIFINDEX: c_ulong = SIOCGIFINDEX; +pub const SIOCSIFPFLAGS: c_ulong = 0x00008934; +pub const SIOCGIFPFLAGS: c_ulong = 0x00008935; +pub const SIOCDIFADDR: c_ulong = 0x00008936; +pub const SIOCSIFHWBROADCAST: c_ulong = 0x00008937; +pub const SIOCGIFCOUNT: c_ulong = 0x00008938; +pub const SIOCGIFBR: c_ulong = 0x00008940; +pub const SIOCSIFBR: c_ulong = 0x00008941; +pub const SIOCGIFTXQLEN: c_ulong = 0x00008942; +pub const SIOCSIFTXQLEN: c_ulong = 0x00008943; +cfg_if! { + if #[cfg(not(target_os = "l4re"))] { + pub const SIOCETHTOOL: c_ulong = 0x00008946; + pub const SIOCGMIIPHY: c_ulong = 0x00008947; + pub const SIOCGMIIREG: c_ulong = 0x00008948; + pub const SIOCSMIIREG: c_ulong = 0x00008949; + pub const SIOCWANDEV: c_ulong = 0x0000894A; + pub const SIOCOUTQNSD: c_ulong = 0x0000894B; + pub const SIOCGSKNS: c_ulong = 0x0000894C; + } +} +pub const SIOCDARP: c_ulong = 0x00008953; +pub const SIOCGARP: c_ulong = 0x00008954; +pub const SIOCSARP: c_ulong = 0x00008955; +pub const SIOCDRARP: c_ulong = 0x00008960; +pub const SIOCGRARP: c_ulong = 0x00008961; +pub const SIOCSRARP: c_ulong = 0x00008962; +pub const SIOCGIFMAP: c_ulong = 0x00008970; +pub const SIOCSIFMAP: c_ulong = 0x00008971; + +pub const IPTOS_TOS_MASK: u8 = 0x1E; +pub const IPTOS_PREC_MASK: u8 = 0xE0; + +pub const IPTOS_ECN_NOT_ECT: u8 = 0x00; + +pub const RTF_UP: c_ushort = 0x0001; +pub const RTF_GATEWAY: c_ushort = 0x0002; + +pub const RTF_HOST: c_ushort = 0x0004; +pub const RTF_REINSTATE: c_ushort = 0x0008; +pub const RTF_DYNAMIC: c_ushort = 0x0010; +pub const RTF_MODIFIED: c_ushort = 0x0020; +pub const RTF_MTU: c_ushort = 0x0040; +pub const RTF_MSS: c_ushort = RTF_MTU; +pub const RTF_WINDOW: c_ushort = 0x0080; +pub const RTF_IRTT: c_ushort = 0x0100; +pub const RTF_REJECT: c_ushort = 0x0200; +pub const RTF_STATIC: c_ushort = 0x0400; +pub const RTF_XRESOLVE: c_ushort = 0x0800; +pub const RTF_NOFORWARD: c_ushort = 0x1000; +pub const RTF_THROW: c_ushort = 0x2000; +pub const RTF_NOPMTUDISC: c_ushort = 0x4000; + +pub const RTF_DEFAULT: u32 = 0x00010000; +pub const RTF_ALLONLINK: u32 = 0x00020000; +pub const RTF_ADDRCONF: u32 = 0x00040000; +pub const RTF_LINKRT: u32 = 0x00100000; +pub const RTF_NONEXTHOP: u32 = 0x00200000; +pub const RTF_CACHE: u32 = 0x01000000; +pub const RTF_FLOW: u32 = 0x02000000; +pub const RTF_POLICY: u32 = 0x04000000; + +pub const RTCF_VALVE: u32 = 0x00200000; +pub const RTCF_MASQ: u32 = 0x00400000; +pub const RTCF_NAT: u32 = 0x00800000; +pub const RTCF_DOREDIRECT: u32 = 0x01000000; +pub const RTCF_LOG: u32 = 0x02000000; +pub const RTCF_DIRECTSRC: u32 = 0x04000000; + +pub const RTF_LOCAL: u32 = 0x80000000; +pub const RTF_INTERFACE: u32 = 0x40000000; +pub const RTF_MULTICAST: u32 = 0x20000000; +pub const RTF_BROADCAST: u32 = 0x10000000; +pub const RTF_NAT: u32 = 0x08000000; +pub const RTF_ADDRCLASSMASK: u32 = 0xF8000000; + +pub const RT_CLASS_UNSPEC: u8 = 0; +pub const RT_CLASS_DEFAULT: u8 = 253; +pub const RT_CLASS_MAIN: u8 = 254; +pub const RT_CLASS_LOCAL: u8 = 255; +pub const RT_CLASS_MAX: u8 = 255; + +pub const MAX_ADDR_LEN: usize = 7; +pub const ARPD_UPDATE: c_ushort = 0x01; +pub const ARPD_LOOKUP: c_ushort = 0x02; +pub const ARPD_FLUSH: c_ushort = 0x03; +pub const ATF_MAGIC: c_int = 0x80; + +// include/uapi/linux/udp.h +pub const UDP_CORK: c_int = 1; +pub const UDP_ENCAP: c_int = 100; +pub const UDP_NO_CHECK6_TX: c_int = 101; +pub const UDP_NO_CHECK6_RX: c_int = 102; + +// include/uapi/asm-generic/mman-common.h +pub const MAP_FIXED_NOREPLACE: c_int = 0x100000; +pub const MLOCK_ONFAULT: c_uint = 0x01; + +pub const REG_EXTENDED: c_int = 1; +pub const REG_ICASE: c_int = 2; +pub const REG_NEWLINE: c_int = 4; +pub const REG_NOSUB: c_int = 8; + +pub const REG_NOTBOL: c_int = 1; +pub const REG_NOTEOL: c_int = 2; + +pub const REG_ENOSYS: c_int = -1; +pub const REG_NOMATCH: c_int = 1; +pub const REG_BADPAT: c_int = 2; +pub const REG_ECOLLATE: c_int = 3; +pub const REG_ECTYPE: c_int = 4; +pub const REG_EESCAPE: c_int = 5; +pub const REG_ESUBREG: c_int = 6; +pub const REG_EBRACK: c_int = 7; +pub const REG_EPAREN: c_int = 8; +pub const REG_EBRACE: c_int = 9; +pub const REG_BADBR: c_int = 10; +pub const REG_ERANGE: c_int = 11; +pub const REG_ESPACE: c_int = 12; +pub const REG_BADRPT: c_int = 13; + +// errno.h +pub const EPERM: c_int = 1; +pub const ENOENT: c_int = 2; +pub const ESRCH: c_int = 3; +pub const EINTR: c_int = 4; +pub const EIO: c_int = 5; +pub const ENXIO: c_int = 6; +pub const E2BIG: c_int = 7; +pub const ENOEXEC: c_int = 8; +pub const EBADF: c_int = 9; +pub const ECHILD: c_int = 10; +pub const EAGAIN: c_int = 11; +pub const ENOMEM: c_int = 12; +pub const EACCES: c_int = 13; +pub const EFAULT: c_int = 14; +pub const ENOTBLK: c_int = 15; +pub const EBUSY: c_int = 16; +pub const EEXIST: c_int = 17; +pub const EXDEV: c_int = 18; +pub const ENODEV: c_int = 19; +pub const ENOTDIR: c_int = 20; +pub const EISDIR: c_int = 21; +pub const EINVAL: c_int = 22; +pub const ENFILE: c_int = 23; +pub const EMFILE: c_int = 24; +pub const ENOTTY: c_int = 25; +pub const ETXTBSY: c_int = 26; +pub const EFBIG: c_int = 27; +pub const ENOSPC: c_int = 28; +pub const ESPIPE: c_int = 29; +pub const EROFS: c_int = 30; +pub const EMLINK: c_int = 31; +pub const EPIPE: c_int = 32; +pub const EDOM: c_int = 33; +pub const ERANGE: c_int = 34; +pub const EWOULDBLOCK: c_int = EAGAIN; + +pub const CSIGNAL: c_int = 0x000000ff; + +#[cfg(not(target_os = "l4re"))] +pub const SCHED_NORMAL: c_int = 0; +pub const SCHED_OTHER: c_int = 0; +pub const SCHED_FIFO: c_int = 1; +pub const SCHED_RR: c_int = 2; +pub const SCHED_BATCH: c_int = 3; +pub const SCHED_IDLE: c_int = 5; +pub const SCHED_DEADLINE: c_int = 6; + +pub const SCHED_RESET_ON_FORK: c_int = 0x40000000; + +// elf.h +pub const NT_PRSTATUS: c_int = 1; +#[cfg(not(target_os = "l4re"))] +pub const NT_PRFPREG: c_int = 2; +pub const NT_FPREGSET: c_int = 2; +pub const NT_PRPSINFO: c_int = 3; +#[cfg(not(target_os = "l4re"))] +pub const NT_PRXREG: c_int = 4; +pub const NT_TASKSTRUCT: c_int = 4; +pub const NT_PLATFORM: c_int = 5; +pub const NT_AUXV: c_int = 6; +pub const NT_GWINDOWS: c_int = 7; +pub const NT_ASRS: c_int = 8; +pub const NT_PSTATUS: c_int = 10; +pub const NT_PSINFO: c_int = 13; +pub const NT_PRCRED: c_int = 14; +pub const NT_UTSNAME: c_int = 15; +pub const NT_LWPSTATUS: c_int = 16; +pub const NT_LWPSINFO: c_int = 17; +pub const NT_PRFPXREG: c_int = 20; + +pub const MS_NOUSER: c_ulong = 0xffffffff80000000; + +f! { + pub fn CMSG_NXTHDR( + mhdr: *const crate::msghdr, + cmsg: *const crate::cmsghdr, + ) -> *mut crate::cmsghdr { + if ((*cmsg).cmsg_len as usize) < size_of::() { + return core::ptr::null_mut::(); + } + + // FIXME(msrv): `.wrapping_byte_add()` stabilized in 1.75 + let next_cmsg = cmsg + .cast::() + .wrapping_add(super::CMSG_ALIGN((*cmsg).cmsg_len as usize)) + .cast::(); + + // In case the addition wrapped. `next_addr > max_addr` + // would otherwise not work as intended. + if (next_cmsg as usize) < (cmsg as usize) { + return core::ptr::null_mut(); + } + + let mut max_addr = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; + + if cfg!(any(target_env = "musl", target_env = "ohos")) { + // musl and some of its descendants do `>= max_addr` + // comparisons in the if statement below. + // https://www.openwall.com/lists/musl/2025/12/27/1 + max_addr -= 1; + } + + if next_cmsg as usize + size_of::() > max_addr { + core::ptr::null_mut::() + } else { + next_cmsg as *mut crate::cmsghdr + } + } + + pub fn CPU_ALLOC_SIZE(count: c_int) -> size_t { + let _dummy: cpu_set_t = mem::zeroed(); + let size_in_bits = 8 * size_of_val(&_dummy.bits[0]); + ((count as size_t + size_in_bits - 1) / 8) as size_t + } + + pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { + for slot in &mut cpuset.bits { + *slot = 0; + } + } + + pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc + let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); + cpuset.bits[idx] |= 1 << offset; + } + + pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc + let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); + cpuset.bits[idx] &= !(1 << offset); + } + + pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { + let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); + let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); + 0 != (cpuset.bits[idx] & (1 << offset)) + } + + pub fn CPU_COUNT_S(size: usize, cpuset: &cpu_set_t) -> c_int { + let mut s: u32 = 0; + let size_of_mask = size_of_val(&cpuset.bits[0]); + for i in &cpuset.bits[..(size / size_of_mask)] { + s += i.count_ones(); + } + s as c_int + } + + pub fn CPU_COUNT(cpuset: &cpu_set_t) -> c_int { + CPU_COUNT_S(size_of::(), cpuset) + } + + pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool { + set1.bits == set2.bits + } + + pub fn IPTOS_TOS(tos: u8) -> u8 { + tos & IPTOS_TOS_MASK + } + + pub fn IPTOS_PREC(tos: u8) -> u8 { + tos & IPTOS_PREC_MASK + } + + pub fn RT_TOS(tos: u8) -> u8 { + tos & crate::IPTOS_TOS_MASK + } + + pub fn RT_ADDRCLASS(flags: u32) -> u32 { + flags >> 23 + } + + pub fn RT_LOCALADDR(flags: u32) -> bool { + (flags & RTF_ADDRCLASSMASK) == (RTF_LOCAL | RTF_INTERFACE) + } + + pub fn ELF32_R_SYM(val: Elf32_Word) -> Elf32_Word { + val >> 8 + } + + pub fn ELF32_R_TYPE(val: Elf32_Word) -> Elf32_Word { + val & 0xff + } + + pub fn ELF32_R_INFO(sym: Elf32_Word, t: Elf32_Word) -> Elf32_Word { + sym << (8 + t) & 0xff + } + + pub fn ELF64_R_SYM(val: Elf64_Xword) -> Elf64_Xword { + val >> 32 + } + + pub fn ELF64_R_TYPE(val: Elf64_Xword) -> Elf64_Xword { + val & 0xffffffff + } + + pub fn ELF64_R_INFO(sym: Elf64_Xword, t: Elf64_Xword) -> Elf64_Xword { + sym << (32 + t) + } +} + +safe_f! { + pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { + let major = major as crate::dev_t; + let minor = minor as crate::dev_t; + let mut dev = 0; + dev |= (major & 0x00000fff) << 8; + dev |= (major & 0xfffff000) << 32; + dev |= (minor & 0x000000ff) << 0; + dev |= (minor & 0xffffff00) << 12; + dev + } + + pub const fn major(dev: crate::dev_t) -> c_uint { + let mut major = 0; + major |= (dev & 0x00000000000fff00) >> 8; + major |= (dev & 0xfffff00000000000) >> 32; + major as c_uint + } + + pub const fn minor(dev: crate::dev_t) -> c_uint { + let mut minor = 0; + minor |= (dev & 0x00000000000000ff) >> 0; + minor |= (dev & 0x00000ffffff00000) >> 12; + minor as c_uint + } +} + +cfg_if! { + if #[cfg(all( + any(target_env = "gnu", target_env = "musl", target_env = "ohos"), + any(target_arch = "x86_64", target_arch = "x86") + ))] { + extern "C" { + pub fn iopl(level: c_int) -> c_int; + pub fn ioperm(from: c_ulong, num: c_ulong, turn_on: c_int) -> c_int; + } + } +} + +cfg_if! { + if #[cfg(all(not(target_env = "uclibc"), not(target_env = "ohos")))] { + extern "C" { + #[cfg_attr(gnu_file_offset_bits64, link_name = "aio_read64")] + pub fn aio_read(aiocbp: *mut crate::aiocb) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "aio_write64")] + pub fn aio_write(aiocbp: *mut crate::aiocb) -> c_int; + pub fn aio_fsync(op: c_int, aiocbp: *mut crate::aiocb) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "aio_error64")] + pub fn aio_error(aiocbp: *const crate::aiocb) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "aio_return64")] + pub fn aio_return(aiocbp: *mut crate::aiocb) -> ssize_t; + #[cfg_attr( + any(musl_redir_time64, gnu_time_bits64), + link_name = "__aio_suspend_time64" + )] + pub fn aio_suspend( + aiocb_list: *const *const crate::aiocb, + nitems: c_int, + timeout: *const crate::timespec, + ) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "aio_cancel64")] + pub fn aio_cancel(fd: c_int, aiocbp: *mut crate::aiocb) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "lio_listio64")] + pub fn lio_listio( + mode: c_int, + aiocb_list: *const *mut crate::aiocb, + nitems: c_int, + sevp: *mut crate::sigevent, + ) -> c_int; + } + } +} + +cfg_if! { + if #[cfg(not(target_env = "uclibc"))] { + extern "C" { + #[cfg_attr(gnu_file_offset_bits64, link_name = "pwritev64")] + pub fn pwritev( + fd: c_int, + iov: *const crate::iovec, + iovcnt: c_int, + offset: crate::off_t, + ) -> ssize_t; + #[cfg_attr(gnu_file_offset_bits64, link_name = "preadv64")] + pub fn preadv( + fd: c_int, + iov: *const crate::iovec, + iovcnt: c_int, + offset: crate::off_t, + ) -> ssize_t; + pub fn getnameinfo( + sa: *const crate::sockaddr, + salen: crate::socklen_t, + host: *mut c_char, + hostlen: crate::socklen_t, + serv: *mut c_char, + servlen: crate::socklen_t, + flags: c_int, + ) -> c_int; + pub fn getloadavg(loadavg: *mut c_double, nelem: c_int) -> c_int; + pub fn process_vm_readv( + pid: crate::pid_t, + local_iov: *const crate::iovec, + liovcnt: c_ulong, + remote_iov: *const crate::iovec, + riovcnt: c_ulong, + flags: c_ulong, + ) -> isize; + pub fn process_vm_writev( + pid: crate::pid_t, + local_iov: *const crate::iovec, + liovcnt: c_ulong, + remote_iov: *const crate::iovec, + riovcnt: c_ulong, + flags: c_ulong, + ) -> isize; + #[cfg_attr(gnu_time_bits64, link_name = "__futimes64")] + #[cfg_attr(musl_redir_time64, link_name = "__futimes_time64")] + pub fn futimes(fd: c_int, times: *const crate::timeval) -> c_int; + } + } +} + +extern "C" { + #[cfg_attr( + not(any(target_env = "musl", target_env = "ohos")), + link_name = "__xpg_strerror_r" + )] + pub fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int; + + pub fn abs(i: c_int) -> c_int; + pub fn labs(i: c_long) -> c_long; + pub fn rand() -> c_int; + pub fn srand(seed: c_uint); + + pub fn drand48() -> c_double; + pub fn erand48(xseed: *mut c_ushort) -> c_double; + pub fn lrand48() -> c_long; + pub fn nrand48(xseed: *mut c_ushort) -> c_long; + pub fn jrand48(xseed: *mut c_ushort) -> c_long; + pub fn srand48(seed: c_long); + + pub fn setpwent(); + pub fn endpwent(); + pub fn getpwent() -> *mut passwd; + pub fn setgrent(); + pub fn endgrent(); + pub fn getgrent() -> *mut crate::group; + #[cfg(not(target_os = "l4re"))] + pub fn setspent(); + #[cfg(not(target_os = "l4re"))] + pub fn endspent(); + #[cfg(not(target_os = "l4re"))] + pub fn getspent() -> *mut spwd; + + pub fn getspnam(name: *const c_char) -> *mut spwd; + + // System V IPC + pub fn shmget(key: crate::key_t, size: size_t, shmflg: c_int) -> c_int; + pub fn shmat(shmid: c_int, shmaddr: *const c_void, shmflg: c_int) -> *mut c_void; + pub fn shmdt(shmaddr: *const c_void) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__shmctl64")] + pub fn shmctl(shmid: c_int, cmd: c_int, buf: *mut crate::shmid_ds) -> c_int; + + pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; + pub fn __errno_location() -> *mut c_int; + + // Not available now on Android + pub fn mremap( + addr: *mut c_void, + len: size_t, + new_len: size_t, + flags: c_int, + ... + ) -> *mut c_void; + + #[cfg_attr(gnu_time_bits64, link_name = "__glob64_time64")] + #[cfg_attr( + all(not(gnu_time_bits64), gnu_file_offset_bits64), + link_name = "glob64" + )] + pub fn glob( + pattern: *const c_char, + flags: c_int, + errfunc: Option c_int>, + pglob: *mut crate::glob_t, + ) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__globfree64_time64")] + #[cfg_attr( + all(not(gnu_time_bits64), gnu_file_offset_bits64), + link_name = "globfree64" + )] + pub fn globfree(pglob: *mut crate::glob_t); + + pub fn seekdir(dirp: *mut crate::DIR, loc: c_long); + + pub fn telldir(dirp: *mut crate::DIR) -> c_long; + pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; + + pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int; + pub fn recvfrom( + socket: c_int, + buf: *mut c_void, + len: size_t, + flags: c_int, + addr: *mut crate::sockaddr, + addrlen: *mut crate::socklen_t, + ) -> ssize_t; + + pub fn nl_langinfo(item: crate::nl_item) -> *mut c_char; + pub fn nl_langinfo_l(item: crate::nl_item, locale: crate::locale_t) -> *mut c_char; + + pub fn sched_getaffinity( + pid: crate::pid_t, + cpusetsize: size_t, + cpuset: *mut cpu_set_t, + ) -> c_int; + pub fn sched_get_priority_max(policy: c_int) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__settimeofday64")] + #[cfg_attr(musl_redir_time64, link_name = "__settimeofday_time64")] + pub fn settimeofday(tv: *const crate::timeval, tz: *const crate::timezone) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__sem_timedwait64")] + #[cfg_attr(musl_redir_time64, link_name = "__sem_timedwait_time64")] + pub fn sem_timedwait(sem: *mut crate::sem_t, abstime: *const crate::timespec) -> c_int; + pub fn sem_getvalue(sem: *mut crate::sem_t, sval: *mut c_int) -> c_int; + pub fn mount( + src: *const c_char, + target: *const c_char, + fstype: *const c_char, + flags: c_ulong, + data: *const c_void, + ) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__prctl_time64")] + pub fn prctl(option: c_int, ...) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__ppoll64")] + #[cfg_attr(musl_redir_time64, link_name = "__ppoll_time64")] + pub fn ppoll( + fds: *mut crate::pollfd, + nfds: crate::nfds_t, + timeout: *const crate::timespec, + sigmask: *const crate::sigset_t, + ) -> c_int; + pub fn sethostname(name: *const c_char, len: size_t) -> c_int; + pub fn sched_get_priority_min(policy: c_int) -> c_int; + pub fn sysinfo(info: *mut crate::sysinfo) -> c_int; + pub fn sigsuspend(mask: *const crate::sigset_t) -> c_int; + pub fn getgrgid_r( + gid: crate::gid_t, + grp: *mut crate::group, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::group, + ) -> c_int; + pub fn sem_close(sem: *mut crate::sem_t) -> c_int; + pub fn getgrnam_r( + name: *const c_char, + grp: *mut crate::group, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::group, + ) -> c_int; + pub fn initgroups(user: *const c_char, group: crate::gid_t) -> c_int; + pub fn sem_open(name: *const c_char, oflag: c_int, ...) -> *mut crate::sem_t; + pub fn getgrnam(name: *const c_char) -> *mut crate::group; + pub fn sem_unlink(name: *const c_char) -> c_int; + pub fn daemon(nochdir: c_int, noclose: c_int) -> c_int; + pub fn sigwait(set: *const crate::sigset_t, sig: *mut c_int) -> c_int; + pub fn getgrgid(gid: crate::gid_t) -> *mut crate::group; + pub fn popen(command: *const c_char, mode: *const c_char) -> *mut crate::FILE; + pub fn faccessat(dirfd: c_int, pathname: *const c_char, mode: c_int, flags: c_int) -> c_int; + pub fn dl_iterate_phdr( + callback: Option< + unsafe extern "C" fn( + info: *mut crate::dl_phdr_info, + size: size_t, + data: *mut c_void, + ) -> c_int, + >, + data: *mut c_void, + ) -> c_int; + + pub fn setmntent(filename: *const c_char, ty: *const c_char) -> *mut crate::FILE; + pub fn getmntent(stream: *mut crate::FILE) -> *mut crate::mntent; + pub fn addmntent(stream: *mut crate::FILE, mnt: *const crate::mntent) -> c_int; + pub fn endmntent(streamp: *mut crate::FILE) -> c_int; + pub fn hasmntopt(mnt: *const crate::mntent, opt: *const c_char) -> *mut c_char; + + pub fn regcomp(preg: *mut crate::regex_t, pattern: *const c_char, cflags: c_int) -> c_int; + + pub fn regexec( + preg: *const crate::regex_t, + input: *const c_char, + nmatch: size_t, + pmatch: *mut regmatch_t, + eflags: c_int, + ) -> c_int; + + pub fn regerror( + errcode: c_int, + preg: *const crate::regex_t, + errbuf: *mut c_char, + errbuf_size: size_t, + ) -> size_t; + + pub fn regfree(preg: *mut crate::regex_t); + + pub fn iconv_open(tocode: *const c_char, fromcode: *const c_char) -> iconv_t; + pub fn iconv( + cd: iconv_t, + inbuf: *mut *mut c_char, + inbytesleft: *mut size_t, + outbuf: *mut *mut c_char, + outbytesleft: *mut size_t, + ) -> size_t; + pub fn iconv_close(cd: iconv_t) -> c_int; + + pub fn gettid() -> crate::pid_t; + + pub fn timer_create( + clockid: crate::clockid_t, + sevp: *mut crate::sigevent, + timerid: *mut crate::timer_t, + ) -> c_int; + pub fn timer_delete(timerid: crate::timer_t) -> c_int; + #[cfg(not(target_os = "l4re"))] + pub fn timer_getoverrun(timerid: crate::timer_t) -> c_int; + #[cfg_attr( + any(gnu_time_bits64, musl_redir_time64), + link_name = "__timer_gettime64" + )] + pub fn timer_gettime(timerid: crate::timer_t, curr_value: *mut crate::itimerspec) -> c_int; + #[cfg_attr( + any(gnu_time_bits64, musl_redir_time64), + link_name = "__timer_settime64" + )] + pub fn timer_settime( + timerid: crate::timer_t, + flags: c_int, + new_value: *const crate::itimerspec, + old_value: *mut crate::itimerspec, + ) -> c_int; + + pub fn memmem( + haystack: *const c_void, + haystacklen: size_t, + needle: *const c_void, + needlelen: size_t, + ) -> *mut c_void; + pub fn sched_getcpu() -> c_int; + + pub fn getopt_long( + argc: c_int, + argv: *const *mut c_char, + optstring: *const c_char, + longopts: *const option, + longindex: *mut c_int, + ) -> c_int; + + #[cfg(not(target_env = "uclibc"))] + pub fn copy_file_range( + fd_in: c_int, + off_in: *mut crate::off64_t, + fd_out: c_int, + off_out: *mut crate::off64_t, + len: size_t, + flags: c_uint, + ) -> ssize_t; +} + +cfg_if! { + if #[cfg(not(any(target_env = "musl", target_env = "ohos")))] { + extern "C" { + pub fn freopen64( + filename: *const c_char, + mode: *const c_char, + file: *mut crate::FILE, + ) -> *mut crate::FILE; + pub fn fseeko64( + stream: *mut crate::FILE, + offset: crate::off64_t, + whence: c_int, + ) -> c_int; + pub fn fsetpos64(stream: *mut crate::FILE, ptr: *const crate::fpos64_t) -> c_int; + pub fn ftello64(stream: *mut crate::FILE) -> crate::off64_t; + } + } +} diff --git a/http/vendor/libc/src/unix/linux_like/mod.rs b/http/vendor/libc/src/unix/linux_like/mod.rs new file mode 100644 index 0000000..59e16a0 --- /dev/null +++ b/http/vendor/libc/src/unix/linux_like/mod.rs @@ -0,0 +1,2211 @@ +use crate::prelude::*; + +pub type sa_family_t = u16; +pub type speed_t = c_uint; +pub type tcflag_t = c_uint; +pub type clockid_t = c_int; +pub type timer_t = *mut c_void; +pub type useconds_t = u32; +pub type key_t = c_int; +pub type id_t = c_uint; + +extern_ty! { + pub enum timezone {} +} + +s! { + pub struct in_addr { + pub s_addr: crate::in_addr_t, + } + + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct ip_mreqn { + pub imr_multiaddr: in_addr, + pub imr_address: in_addr, + pub imr_ifindex: c_int, + } + + pub struct ip_mreq_source { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + pub imr_sourceaddr: in_addr, + } + + pub struct sockaddr { + pub sa_family: sa_family_t, + pub sa_data: [c_char; 14], + } + + pub struct sockaddr_in { + pub sin_family: sa_family_t, + pub sin_port: crate::in_port_t, + pub sin_addr: crate::in_addr, + pub sin_zero: [u8; 8], + } + + pub struct sockaddr_in6 { + pub sin6_family: sa_family_t, + pub sin6_port: crate::in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: crate::in6_addr, + pub sin6_scope_id: u32, + } + + // The order of the `ai_addr` field in this struct is crucial + // for converting between the Rust and C types. + pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: socklen_t, + + #[cfg(not(target_os = "android"))] + pub ai_addr: *mut crate::sockaddr, + + pub ai_canonname: *mut c_char, + + #[cfg(target_os = "android")] + pub ai_addr: *mut crate::sockaddr, + + pub ai_next: *mut addrinfo, + } + + pub struct sockaddr_ll { + pub sll_family: c_ushort, + pub sll_protocol: c_ushort, + pub sll_ifindex: c_int, + pub sll_hatype: c_ushort, + pub sll_pkttype: c_uchar, + pub sll_halen: c_uchar, + pub sll_addr: [c_uchar; 8], + } + + pub struct fd_set { + fds_bits: [c_ulong; FD_SETSIZE as usize / ULONG_SIZE], + } + + pub struct tm { + pub tm_sec: c_int, + pub tm_min: c_int, + pub tm_hour: c_int, + pub tm_mday: c_int, + pub tm_mon: c_int, + pub tm_year: c_int, + pub tm_wday: c_int, + pub tm_yday: c_int, + pub tm_isdst: c_int, + pub tm_gmtoff: c_long, + pub tm_zone: *const c_char, + } + + #[cfg(not(any(target_env = "musl", target_os = "emscripten", target_env = "ohos")))] + pub struct sched_param { + pub sched_priority: c_int, + } + + pub struct Dl_info { + pub dli_fname: *const c_char, + pub dli_fbase: *mut c_void, + pub dli_sname: *const c_char, + pub dli_saddr: *mut c_void, + } + + pub struct lconv { + pub decimal_point: *mut c_char, + pub thousands_sep: *mut c_char, + pub grouping: *mut c_char, + pub int_curr_symbol: *mut c_char, + pub currency_symbol: *mut c_char, + pub mon_decimal_point: *mut c_char, + pub mon_thousands_sep: *mut c_char, + pub mon_grouping: *mut c_char, + pub positive_sign: *mut c_char, + pub negative_sign: *mut c_char, + pub int_frac_digits: c_char, + pub frac_digits: c_char, + pub p_cs_precedes: c_char, + pub p_sep_by_space: c_char, + pub n_cs_precedes: c_char, + pub n_sep_by_space: c_char, + pub p_sign_posn: c_char, + pub n_sign_posn: c_char, + pub int_p_cs_precedes: c_char, + pub int_p_sep_by_space: c_char, + pub int_n_cs_precedes: c_char, + pub int_n_sep_by_space: c_char, + pub int_p_sign_posn: c_char, + pub int_n_sign_posn: c_char, + } + + pub struct in_pktinfo { + pub ipi_ifindex: c_int, + pub ipi_spec_dst: crate::in_addr, + pub ipi_addr: crate::in_addr, + } + + pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut c_char, + pub ifa_flags: c_uint, + pub ifa_addr: *mut crate::sockaddr, + pub ifa_netmask: *mut crate::sockaddr, + pub ifa_ifu: *mut crate::sockaddr, // FIXME(union) This should be a union + pub ifa_data: *mut c_void, + } + + pub struct in6_rtmsg { + rtmsg_dst: crate::in6_addr, + rtmsg_src: crate::in6_addr, + rtmsg_gateway: crate::in6_addr, + rtmsg_type: u32, + rtmsg_dst_len: u16, + rtmsg_src_len: u16, + rtmsg_metric: u32, + rtmsg_info: c_ulong, + rtmsg_flags: u32, + rtmsg_ifindex: c_int, + } + + pub struct arpreq { + pub arp_pa: crate::sockaddr, + pub arp_ha: crate::sockaddr, + pub arp_flags: c_int, + pub arp_netmask: crate::sockaddr, + pub arp_dev: [c_char; 16], + } + + pub struct arpreq_old { + pub arp_pa: crate::sockaddr, + pub arp_ha: crate::sockaddr, + pub arp_flags: c_int, + pub arp_netmask: crate::sockaddr, + } + + pub struct arphdr { + pub ar_hrd: u16, + pub ar_pro: u16, + pub ar_hln: u8, + pub ar_pln: u8, + pub ar_op: u16, + } + + pub struct mmsghdr { + pub msg_hdr: crate::msghdr, + pub msg_len: c_uint, + } + + pub struct sockaddr_un { + pub sun_family: sa_family_t, + pub sun_path: [c_char; 108], + } + + pub struct sockaddr_storage { + pub ss_family: sa_family_t, + #[cfg(target_pointer_width = "32")] + __ss_pad2: Padding<[u8; 128 - 2 - 4]>, + #[cfg(target_pointer_width = "64")] + __ss_pad2: Padding<[u8; 128 - 2 - 8]>, + __ss_align: size_t, + } + + pub struct utsname { + pub sysname: [c_char; 65], + pub nodename: [c_char; 65], + pub release: [c_char; 65], + pub version: [c_char; 65], + pub machine: [c_char; 65], + pub domainname: [c_char; 65], + } + + pub struct if_nameindex { + pub if_index: c_uint, + pub if_name: *mut c_char, + } +} + +cfg_if! { + if #[cfg(not(any(target_os = "emscripten", target_os = "l4re")))] { + s! { + pub struct file_clone_range { + pub src_fd: crate::__s64, + pub src_offset: crate::__u64, + pub src_length: crate::__u64, + pub dest_offset: crate::__u64, + } + + // linux/filter.h + pub struct sock_filter { + pub code: __u16, + pub jt: __u8, + pub jf: __u8, + pub k: __u32, + } + + pub struct sock_fprog { + pub len: c_ushort, + pub filter: *mut sock_filter, + } + } + } +} + +cfg_if! { + if #[cfg(any( + target_env = "gnu", + target_os = "android", + all(target_env = "musl", musl_v1_2_3) + ))] { + s! { + pub struct statx { + pub stx_mask: crate::__u32, + pub stx_blksize: crate::__u32, + pub stx_attributes: crate::__u64, + pub stx_nlink: crate::__u32, + pub stx_uid: crate::__u32, + pub stx_gid: crate::__u32, + pub stx_mode: crate::__u16, + __statx_pad1: Padding<[crate::__u16; 1]>, + pub stx_ino: crate::__u64, + pub stx_size: crate::__u64, + pub stx_blocks: crate::__u64, + pub stx_attributes_mask: crate::__u64, + pub stx_atime: statx_timestamp, + pub stx_btime: statx_timestamp, + pub stx_ctime: statx_timestamp, + pub stx_mtime: statx_timestamp, + pub stx_rdev_major: crate::__u32, + pub stx_rdev_minor: crate::__u32, + pub stx_dev_major: crate::__u32, + pub stx_dev_minor: crate::__u32, + pub stx_mnt_id: crate::__u64, + pub stx_dio_mem_align: crate::__u32, + pub stx_dio_offset_align: crate::__u32, + __statx_pad3: Padding<[crate::__u64; 12]>, + } + + pub struct statx_timestamp { + pub tv_sec: crate::__s64, + pub tv_nsec: crate::__u32, + __statx_timestamp_pad1: Padding<[crate::__s32; 1]>, + } + } + } +} + +s_no_extra_traits! { + #[cfg_attr( + any(target_arch = "x86_64", all(target_arch = "x86", target_env = "gnu")), + repr(packed) + )] + pub struct epoll_event { + pub events: u32, + pub u64: u64, + } + + pub struct sigevent { + pub sigev_value: crate::sigval, + pub sigev_signo: c_int, + pub sigev_notify: c_int, + // Actually a union. We only expose sigev_notify_thread_id because it's + // the most useful member + pub sigev_notify_thread_id: c_int, + #[cfg(target_pointer_width = "64")] + __unused1: Padding<[c_int; 11]>, + #[cfg(target_pointer_width = "32")] + __unused1: Padding<[c_int; 12]>, + } +} + +cfg_if! { + if #[cfg(all(feature = "extra_traits", not(target_os = "l4re")))] { + impl PartialEq for epoll_event { + fn eq(&self, other: &epoll_event) -> bool { + self.events == other.events && self.u64 == other.u64 + } + } + impl Eq for epoll_event {} + impl hash::Hash for epoll_event { + fn hash(&self, state: &mut H) { + let events = self.events; + let u64 = self.u64; + events.hash(state); + u64.hash(state); + } + } + + impl PartialEq for sigevent { + fn eq(&self, other: &sigevent) -> bool { + self.sigev_value == other.sigev_value + && self.sigev_signo == other.sigev_signo + && self.sigev_notify == other.sigev_notify + && self.sigev_notify_thread_id == other.sigev_notify_thread_id + } + } + impl Eq for sigevent {} + impl hash::Hash for sigevent { + fn hash(&self, state: &mut H) { + self.sigev_value.hash(state); + self.sigev_signo.hash(state); + self.sigev_notify.hash(state); + self.sigev_notify_thread_id.hash(state); + } + } + } +} + +// intentionally not public, only used for fd_set +cfg_if! { + if #[cfg(target_pointer_width = "32")] { + const ULONG_SIZE: usize = 32; + } else if #[cfg(target_pointer_width = "64")] { + const ULONG_SIZE: usize = 64; + } else { + // Unknown target_pointer_width + } +} + +pub const EXIT_FAILURE: c_int = 1; +pub const EXIT_SUCCESS: c_int = 0; +pub const RAND_MAX: c_int = 2147483647; +pub const EOF: c_int = -1; +pub const SEEK_SET: c_int = 0; +pub const SEEK_CUR: c_int = 1; +pub const SEEK_END: c_int = 2; +pub const _IOFBF: c_int = 0; +pub const _IONBF: c_int = 2; +pub const _IOLBF: c_int = 1; + +pub const F_DUPFD: c_int = 0; +pub const F_GETFD: c_int = 1; +pub const F_SETFD: c_int = 2; +pub const F_GETFL: c_int = 3; +pub const F_SETFL: c_int = 4; + +// Linux-specific fcntls +pub const F_SETLEASE: c_int = 1024; +pub const F_GETLEASE: c_int = 1025; +pub const F_NOTIFY: c_int = 1026; +pub const F_CANCELLK: c_int = 1029; +pub const F_DUPFD_CLOEXEC: c_int = 1030; +pub const F_SETPIPE_SZ: c_int = 1031; +pub const F_GETPIPE_SZ: c_int = 1032; +pub const F_ADD_SEALS: c_int = 1033; +pub const F_GET_SEALS: c_int = 1034; + +pub const F_SEAL_SEAL: c_int = 0x0001; +pub const F_SEAL_SHRINK: c_int = 0x0002; +pub const F_SEAL_GROW: c_int = 0x0004; +pub const F_SEAL_WRITE: c_int = 0x0008; + +// FIXME(#235): Include file sealing fcntls once we have a way to verify them. + +pub const SIGTRAP: c_int = 5; + +pub const PTHREAD_CREATE_JOINABLE: c_int = 0; +pub const PTHREAD_CREATE_DETACHED: c_int = 1; + +pub const CLOCK_REALTIME: crate::clockid_t = 0; +pub const CLOCK_MONOTONIC: crate::clockid_t = 1; +pub const CLOCK_PROCESS_CPUTIME_ID: crate::clockid_t = 2; +pub const CLOCK_THREAD_CPUTIME_ID: crate::clockid_t = 3; +pub const CLOCK_MONOTONIC_RAW: crate::clockid_t = 4; +pub const CLOCK_REALTIME_COARSE: crate::clockid_t = 5; +pub const CLOCK_MONOTONIC_COARSE: crate::clockid_t = 6; +pub const CLOCK_BOOTTIME: crate::clockid_t = 7; +pub const CLOCK_REALTIME_ALARM: crate::clockid_t = 8; +pub const CLOCK_BOOTTIME_ALARM: crate::clockid_t = 9; +pub const CLOCK_TAI: crate::clockid_t = 11; +pub const TIMER_ABSTIME: c_int = 1; + +pub const RUSAGE_SELF: c_int = 0; + +pub const O_RDONLY: c_int = 0; +pub const O_WRONLY: c_int = 1; +pub const O_RDWR: c_int = 2; + +pub const SOCK_CLOEXEC: c_int = O_CLOEXEC; + +pub const S_IFIFO: mode_t = 0o1_0000; +pub const S_IFCHR: mode_t = 0o2_0000; +pub const S_IFBLK: mode_t = 0o6_0000; +pub const S_IFDIR: mode_t = 0o4_0000; +pub const S_IFREG: mode_t = 0o10_0000; +pub const S_IFLNK: mode_t = 0o12_0000; +pub const S_IFSOCK: mode_t = 0o14_0000; +pub const S_IFMT: mode_t = 0o17_0000; +pub const S_IRWXU: mode_t = 0o0700; +pub const S_IXUSR: mode_t = 0o0100; +pub const S_IWUSR: mode_t = 0o0200; +pub const S_IRUSR: mode_t = 0o0400; +pub const S_IRWXG: mode_t = 0o0070; +pub const S_IXGRP: mode_t = 0o0010; +pub const S_IWGRP: mode_t = 0o0020; +pub const S_IRGRP: mode_t = 0o0040; +pub const S_IRWXO: mode_t = 0o0007; +pub const S_IXOTH: mode_t = 0o0001; +pub const S_IWOTH: mode_t = 0o0002; +pub const S_IROTH: mode_t = 0o0004; +pub const F_OK: c_int = 0; +pub const R_OK: c_int = 4; +pub const W_OK: c_int = 2; +pub const X_OK: c_int = 1; +pub const SIGHUP: c_int = 1; +pub const SIGINT: c_int = 2; +pub const SIGQUIT: c_int = 3; +pub const SIGILL: c_int = 4; +pub const SIGABRT: c_int = 6; +pub const SIGFPE: c_int = 8; +pub const SIGKILL: c_int = 9; +pub const SIGSEGV: c_int = 11; +pub const SIGPIPE: c_int = 13; +pub const SIGALRM: c_int = 14; +pub const SIGTERM: c_int = 15; + +pub const PROT_NONE: c_int = 0; +pub const PROT_READ: c_int = 1; +pub const PROT_WRITE: c_int = 2; +pub const PROT_EXEC: c_int = 4; + +#[cfg(not(target_os = "l4re"))] +pub const XATTR_CREATE: c_int = 0x1; +#[cfg(not(target_os = "l4re"))] +pub const XATTR_REPLACE: c_int = 0x2; + +cfg_if! { + if #[cfg(target_os = "android")] { + pub const RLIM64_INFINITY: c_ulonglong = !0; + } else { + pub const RLIM64_INFINITY: crate::rlim64_t = !0; + } +} + +cfg_if! { + if #[cfg(target_env = "ohos")] { + pub const LC_CTYPE: c_int = 0; + pub const LC_NUMERIC: c_int = 1; + pub const LC_TIME: c_int = 2; + pub const LC_COLLATE: c_int = 3; + pub const LC_MONETARY: c_int = 4; + pub const LC_MESSAGES: c_int = 5; + pub const LC_PAPER: c_int = 6; + pub const LC_NAME: c_int = 7; + pub const LC_ADDRESS: c_int = 8; + pub const LC_TELEPHONE: c_int = 9; + pub const LC_MEASUREMENT: c_int = 10; + pub const LC_IDENTIFICATION: c_int = 11; + pub const LC_ALL: c_int = 12; + } else if #[cfg(not(target_env = "uclibc"))] { + pub const LC_CTYPE: c_int = 0; + pub const LC_NUMERIC: c_int = 1; + pub const LC_TIME: c_int = 2; + pub const LC_COLLATE: c_int = 3; + pub const LC_MONETARY: c_int = 4; + pub const LC_MESSAGES: c_int = 5; + pub const LC_ALL: c_int = 6; + } +} + +pub const LC_CTYPE_MASK: c_int = 1 << LC_CTYPE; +pub const LC_NUMERIC_MASK: c_int = 1 << LC_NUMERIC; +pub const LC_TIME_MASK: c_int = 1 << LC_TIME; +pub const LC_COLLATE_MASK: c_int = 1 << LC_COLLATE; +pub const LC_MONETARY_MASK: c_int = 1 << LC_MONETARY; +pub const LC_MESSAGES_MASK: c_int = 1 << LC_MESSAGES; +// LC_ALL_MASK defined per platform + +pub const MAP_FILE: c_int = 0x0000; +pub const MAP_SHARED: c_int = 0x0001; +pub const MAP_PRIVATE: c_int = 0x0002; +pub const MAP_FIXED: c_int = 0x0010; + +pub const MAP_FAILED: *mut c_void = !0 as *mut c_void; + +// MS_ flags for msync(2) +pub const MS_ASYNC: c_int = 0x0001; +pub const MS_INVALIDATE: c_int = 0x0002; +pub const MS_SYNC: c_int = 0x0004; + +// MS_ flags for mount(2) +pub const MS_RDONLY: c_ulong = 0x01; +pub const MS_NOSUID: c_ulong = 0x02; +pub const MS_NODEV: c_ulong = 0x04; +pub const MS_NOEXEC: c_ulong = 0x08; +pub const MS_SYNCHRONOUS: c_ulong = 0x10; +pub const MS_REMOUNT: c_ulong = 0x20; +pub const MS_MANDLOCK: c_ulong = 0x40; +pub const MS_DIRSYNC: c_ulong = 0x80; +pub const MS_NOSYMFOLLOW: c_ulong = 0x100; +pub const MS_NOATIME: c_ulong = 0x0400; +pub const MS_NODIRATIME: c_ulong = 0x0800; +pub const MS_BIND: c_ulong = 0x1000; +pub const MS_MOVE: c_ulong = 0x2000; +pub const MS_REC: c_ulong = 0x4000; +pub const MS_SILENT: c_ulong = 0x8000; +pub const MS_POSIXACL: c_ulong = 0x010000; +pub const MS_UNBINDABLE: c_ulong = 0x020000; +pub const MS_PRIVATE: c_ulong = 0x040000; +pub const MS_SLAVE: c_ulong = 0x080000; +pub const MS_SHARED: c_ulong = 0x100000; +pub const MS_RELATIME: c_ulong = 0x200000; +pub const MS_KERNMOUNT: c_ulong = 0x400000; +pub const MS_I_VERSION: c_ulong = 0x800000; +pub const MS_STRICTATIME: c_ulong = 0x1000000; +pub const MS_LAZYTIME: c_ulong = 0x2000000; +pub const MS_ACTIVE: c_ulong = 0x40000000; +pub const MS_MGC_VAL: c_ulong = 0xc0ed0000; +pub const MS_MGC_MSK: c_ulong = 0xffff0000; + +pub const SCM_RIGHTS: c_int = 0x01; +pub const SCM_CREDENTIALS: c_int = 0x02; + +pub const PROT_GROWSDOWN: c_int = 0x1000000; +pub const PROT_GROWSUP: c_int = 0x2000000; + +pub const MAP_TYPE: c_int = 0x000f; + +pub const MADV_NORMAL: c_int = 0; +pub const MADV_RANDOM: c_int = 1; +pub const MADV_SEQUENTIAL: c_int = 2; +pub const MADV_WILLNEED: c_int = 3; +pub const MADV_DONTNEED: c_int = 4; +pub const MADV_FREE: c_int = 8; +pub const MADV_REMOVE: c_int = 9; +pub const MADV_DONTFORK: c_int = 10; +pub const MADV_DOFORK: c_int = 11; +pub const MADV_MERGEABLE: c_int = 12; +pub const MADV_UNMERGEABLE: c_int = 13; +pub const MADV_HUGEPAGE: c_int = 14; +pub const MADV_NOHUGEPAGE: c_int = 15; +pub const MADV_DONTDUMP: c_int = 16; +pub const MADV_DODUMP: c_int = 17; +pub const MADV_WIPEONFORK: c_int = 18; +pub const MADV_KEEPONFORK: c_int = 19; +#[cfg(not(target_os = "l4re"))] +pub const MADV_COLD: c_int = 20; +#[cfg(not(target_os = "l4re"))] +pub const MADV_PAGEOUT: c_int = 21; +pub const MADV_HWPOISON: c_int = 100; +cfg_if! { + if #[cfg(not(any(target_os = "emscripten", target_os = "l4re")))] { + pub const MADV_POPULATE_READ: c_int = 22; + pub const MADV_POPULATE_WRITE: c_int = 23; + pub const MADV_DONTNEED_LOCKED: c_int = 24; + } +} + +pub const IFF_UP: c_int = 0x1; +pub const IFF_BROADCAST: c_int = 0x2; +pub const IFF_DEBUG: c_int = 0x4; +pub const IFF_LOOPBACK: c_int = 0x8; +pub const IFF_POINTOPOINT: c_int = 0x10; +pub const IFF_NOTRAILERS: c_int = 0x20; +pub const IFF_RUNNING: c_int = 0x40; +pub const IFF_NOARP: c_int = 0x80; +pub const IFF_PROMISC: c_int = 0x100; +pub const IFF_ALLMULTI: c_int = 0x200; +pub const IFF_MASTER: c_int = 0x400; +pub const IFF_SLAVE: c_int = 0x800; +pub const IFF_MULTICAST: c_int = 0x1000; +pub const IFF_PORTSEL: c_int = 0x2000; +pub const IFF_AUTOMEDIA: c_int = 0x4000; +pub const IFF_DYNAMIC: c_int = 0x8000; + +pub const SOL_IP: c_int = 0; +pub const SOL_TCP: c_int = 6; +pub const SOL_UDP: c_int = 17; +pub const SOL_IPV6: c_int = 41; +pub const SOL_ICMPV6: c_int = 58; +pub const SOL_RAW: c_int = 255; +pub const SOL_DECNET: c_int = 261; +pub const SOL_X25: c_int = 262; +pub const SOL_PACKET: c_int = 263; +pub const SOL_ATM: c_int = 264; +pub const SOL_AAL: c_int = 265; +pub const SOL_IRDA: c_int = 266; +pub const SOL_NETBEUI: c_int = 267; +pub const SOL_LLC: c_int = 268; +pub const SOL_DCCP: c_int = 269; +pub const SOL_NETLINK: c_int = 270; +pub const SOL_TIPC: c_int = 271; +pub const SOL_BLUETOOTH: c_int = 274; +pub const SOL_ALG: c_int = 279; + +pub const AF_UNSPEC: c_int = 0; +pub const AF_UNIX: c_int = 1; +pub const AF_LOCAL: c_int = 1; +pub const AF_INET: c_int = 2; +pub const AF_AX25: c_int = 3; +pub const AF_IPX: c_int = 4; +pub const AF_APPLETALK: c_int = 5; +pub const AF_NETROM: c_int = 6; +pub const AF_BRIDGE: c_int = 7; +pub const AF_ATMPVC: c_int = 8; +pub const AF_X25: c_int = 9; +pub const AF_INET6: c_int = 10; +pub const AF_ROSE: c_int = 11; +pub const AF_DECnet: c_int = 12; +pub const AF_NETBEUI: c_int = 13; +pub const AF_SECURITY: c_int = 14; +pub const AF_KEY: c_int = 15; +pub const AF_NETLINK: c_int = 16; +pub const AF_ROUTE: c_int = AF_NETLINK; +pub const AF_PACKET: c_int = 17; +pub const AF_ASH: c_int = 18; +pub const AF_ECONET: c_int = 19; +pub const AF_ATMSVC: c_int = 20; +pub const AF_RDS: c_int = 21; +pub const AF_SNA: c_int = 22; +pub const AF_IRDA: c_int = 23; +pub const AF_PPPOX: c_int = 24; +pub const AF_WANPIPE: c_int = 25; +pub const AF_LLC: c_int = 26; +pub const AF_CAN: c_int = 29; +pub const AF_TIPC: c_int = 30; +pub const AF_BLUETOOTH: c_int = 31; +pub const AF_IUCV: c_int = 32; +pub const AF_RXRPC: c_int = 33; +pub const AF_ISDN: c_int = 34; +pub const AF_PHONET: c_int = 35; +pub const AF_IEEE802154: c_int = 36; +pub const AF_CAIF: c_int = 37; +pub const AF_ALG: c_int = 38; + +pub const PF_UNSPEC: c_int = AF_UNSPEC; +pub const PF_UNIX: c_int = AF_UNIX; +pub const PF_LOCAL: c_int = AF_LOCAL; +pub const PF_INET: c_int = AF_INET; +pub const PF_AX25: c_int = AF_AX25; +pub const PF_IPX: c_int = AF_IPX; +pub const PF_APPLETALK: c_int = AF_APPLETALK; +pub const PF_NETROM: c_int = AF_NETROM; +pub const PF_BRIDGE: c_int = AF_BRIDGE; +pub const PF_ATMPVC: c_int = AF_ATMPVC; +pub const PF_X25: c_int = AF_X25; +pub const PF_INET6: c_int = AF_INET6; +pub const PF_ROSE: c_int = AF_ROSE; +pub const PF_DECnet: c_int = AF_DECnet; +pub const PF_NETBEUI: c_int = AF_NETBEUI; +pub const PF_SECURITY: c_int = AF_SECURITY; +pub const PF_KEY: c_int = AF_KEY; +pub const PF_NETLINK: c_int = AF_NETLINK; +pub const PF_ROUTE: c_int = AF_ROUTE; +pub const PF_PACKET: c_int = AF_PACKET; +pub const PF_ASH: c_int = AF_ASH; +pub const PF_ECONET: c_int = AF_ECONET; +pub const PF_ATMSVC: c_int = AF_ATMSVC; +pub const PF_RDS: c_int = AF_RDS; +pub const PF_SNA: c_int = AF_SNA; +pub const PF_IRDA: c_int = AF_IRDA; +pub const PF_PPPOX: c_int = AF_PPPOX; +pub const PF_WANPIPE: c_int = AF_WANPIPE; +pub const PF_LLC: c_int = AF_LLC; +pub const PF_CAN: c_int = AF_CAN; +pub const PF_TIPC: c_int = AF_TIPC; +pub const PF_BLUETOOTH: c_int = AF_BLUETOOTH; +pub const PF_IUCV: c_int = AF_IUCV; +pub const PF_RXRPC: c_int = AF_RXRPC; +pub const PF_ISDN: c_int = AF_ISDN; +pub const PF_PHONET: c_int = AF_PHONET; +pub const PF_IEEE802154: c_int = AF_IEEE802154; +pub const PF_CAIF: c_int = AF_CAIF; +pub const PF_ALG: c_int = AF_ALG; + +pub const MSG_OOB: c_int = 1; +pub const MSG_PEEK: c_int = 2; +pub const MSG_DONTROUTE: c_int = 4; +pub const MSG_CTRUNC: c_int = 8; +pub const MSG_TRUNC: c_int = 0x20; +pub const MSG_DONTWAIT: c_int = 0x40; +pub const MSG_EOR: c_int = 0x80; +pub const MSG_WAITALL: c_int = 0x100; +pub const MSG_FIN: c_int = 0x200; +pub const MSG_SYN: c_int = 0x400; +pub const MSG_CONFIRM: c_int = 0x800; +pub const MSG_RST: c_int = 0x1000; +pub const MSG_ERRQUEUE: c_int = 0x2000; +pub const MSG_NOSIGNAL: c_int = 0x4000; +pub const MSG_MORE: c_int = 0x8000; +pub const MSG_WAITFORONE: c_int = 0x10000; +pub const MSG_FASTOPEN: c_int = 0x20000000; +pub const MSG_CMSG_CLOEXEC: c_int = 0x40000000; + +pub const SCM_TIMESTAMP: c_int = SO_TIMESTAMP; + +pub const SOCK_RAW: c_int = 3; +pub const SOCK_RDM: c_int = 4; +pub const IP_TOS: c_int = 1; +pub const IP_TTL: c_int = 2; +pub const IP_HDRINCL: c_int = 3; +pub const IP_OPTIONS: c_int = 4; +pub const IP_ROUTER_ALERT: c_int = 5; +pub const IP_RECVOPTS: c_int = 6; +pub const IP_RETOPTS: c_int = 7; +pub const IP_PKTINFO: c_int = 8; +pub const IP_PKTOPTIONS: c_int = 9; +pub const IP_MTU_DISCOVER: c_int = 10; +pub const IP_RECVERR: c_int = 11; +pub const IP_RECVTTL: c_int = 12; +pub const IP_RECVTOS: c_int = 13; +pub const IP_MTU: c_int = 14; +pub const IP_FREEBIND: c_int = 15; +pub const IP_IPSEC_POLICY: c_int = 16; +pub const IP_XFRM_POLICY: c_int = 17; +pub const IP_PASSSEC: c_int = 18; +pub const IP_TRANSPARENT: c_int = 19; +pub const IP_ORIGDSTADDR: c_int = 20; +pub const IP_RECVORIGDSTADDR: c_int = IP_ORIGDSTADDR; +pub const IP_MINTTL: c_int = 21; +#[cfg(not(target_env = "uclibc"))] +pub const IP_NODEFRAG: c_int = 22; +#[cfg(not(target_env = "uclibc"))] +pub const IP_CHECKSUM: c_int = 23; +#[cfg(not(target_env = "uclibc"))] +pub const IP_BIND_ADDRESS_NO_PORT: c_int = 24; +pub const IP_MULTICAST_IF: c_int = 32; +pub const IP_MULTICAST_TTL: c_int = 33; +pub const IP_MULTICAST_LOOP: c_int = 34; +pub const IP_ADD_MEMBERSHIP: c_int = 35; +pub const IP_DROP_MEMBERSHIP: c_int = 36; +pub const IP_UNBLOCK_SOURCE: c_int = 37; +pub const IP_BLOCK_SOURCE: c_int = 38; +pub const IP_ADD_SOURCE_MEMBERSHIP: c_int = 39; +pub const IP_DROP_SOURCE_MEMBERSHIP: c_int = 40; +pub const IP_MSFILTER: c_int = 41; +pub const IP_MULTICAST_ALL: c_int = 49; +pub const IP_UNICAST_IF: c_int = 50; + +pub const IP_DEFAULT_MULTICAST_TTL: c_int = 1; +pub const IP_DEFAULT_MULTICAST_LOOP: c_int = 1; + +pub const IP_PMTUDISC_DONT: c_int = 0; +pub const IP_PMTUDISC_WANT: c_int = 1; +pub const IP_PMTUDISC_DO: c_int = 2; +pub const IP_PMTUDISC_PROBE: c_int = 3; +#[cfg(not(target_env = "uclibc"))] +pub const IP_PMTUDISC_INTERFACE: c_int = 4; +#[cfg(not(target_env = "uclibc"))] +pub const IP_PMTUDISC_OMIT: c_int = 5; + +// IPPROTO_IP defined in src/unix/mod.rs +/// Hop-by-hop option header +pub const IPPROTO_HOPOPTS: c_int = 0; +// IPPROTO_ICMP defined in src/unix/mod.rs +/// group mgmt protocol +pub const IPPROTO_IGMP: c_int = 2; +/// for compatibility +pub const IPPROTO_IPIP: c_int = 4; +// IPPROTO_TCP defined in src/unix/mod.rs +/// exterior gateway protocol +pub const IPPROTO_EGP: c_int = 8; +/// pup +pub const IPPROTO_PUP: c_int = 12; +// IPPROTO_UDP defined in src/unix/mod.rs +/// xns idp +pub const IPPROTO_IDP: c_int = 22; +/// tp-4 w/ class negotiation +pub const IPPROTO_TP: c_int = 29; +/// DCCP +pub const IPPROTO_DCCP: c_int = 33; +// IPPROTO_IPV6 defined in src/unix/mod.rs +/// IP6 routing header +pub const IPPROTO_ROUTING: c_int = 43; +/// IP6 fragmentation header +pub const IPPROTO_FRAGMENT: c_int = 44; +/// resource reservation +pub const IPPROTO_RSVP: c_int = 46; +/// General Routing Encap. +pub const IPPROTO_GRE: c_int = 47; +/// IP6 Encap Sec. Payload +pub const IPPROTO_ESP: c_int = 50; +/// IP6 Auth Header +pub const IPPROTO_AH: c_int = 51; +// IPPROTO_ICMPV6 defined in src/unix/mod.rs +/// IP6 no next header +pub const IPPROTO_NONE: c_int = 59; +/// IP6 destination option +pub const IPPROTO_DSTOPTS: c_int = 60; +pub const IPPROTO_MTP: c_int = 92; +/// encapsulation header +pub const IPPROTO_ENCAP: c_int = 98; +/// Protocol indep. multicast +pub const IPPROTO_PIM: c_int = 103; +/// IP Payload Comp. Protocol +pub const IPPROTO_COMP: c_int = 108; +/// SCTP +pub const IPPROTO_SCTP: c_int = 132; +pub const IPPROTO_MH: c_int = 135; +pub const IPPROTO_UDPLITE: c_int = 136; +/// raw IP packet +pub const IPPROTO_RAW: c_int = 255; +pub const IPPROTO_BEETPH: c_int = 94; +pub const IPPROTO_MPLS: c_int = 137; +/// Multipath TCP +#[cfg(not(target_os = "l4re"))] +pub const IPPROTO_MPTCP: c_int = 262; +/// Ethernet-within-IPv6 encapsulation. +#[cfg(not(target_os = "l4re"))] +pub const IPPROTO_ETHERNET: c_int = 143; + +pub const MCAST_EXCLUDE: c_int = 0; +pub const MCAST_INCLUDE: c_int = 1; +pub const MCAST_JOIN_GROUP: c_int = 42; +pub const MCAST_BLOCK_SOURCE: c_int = 43; +pub const MCAST_UNBLOCK_SOURCE: c_int = 44; +pub const MCAST_LEAVE_GROUP: c_int = 45; +pub const MCAST_JOIN_SOURCE_GROUP: c_int = 46; +pub const MCAST_LEAVE_SOURCE_GROUP: c_int = 47; +pub const MCAST_MSFILTER: c_int = 48; + +pub const IPV6_ADDRFORM: c_int = 1; +pub const IPV6_2292PKTINFO: c_int = 2; +pub const IPV6_2292HOPOPTS: c_int = 3; +pub const IPV6_2292DSTOPTS: c_int = 4; +pub const IPV6_2292RTHDR: c_int = 5; +pub const IPV6_2292PKTOPTIONS: c_int = 6; +pub const IPV6_CHECKSUM: c_int = 7; +pub const IPV6_2292HOPLIMIT: c_int = 8; +pub const IPV6_NEXTHOP: c_int = 9; +pub const IPV6_AUTHHDR: c_int = 10; +pub const IPV6_UNICAST_HOPS: c_int = 16; +pub const IPV6_MULTICAST_IF: c_int = 17; +pub const IPV6_MULTICAST_HOPS: c_int = 18; +pub const IPV6_MULTICAST_LOOP: c_int = 19; +pub const IPV6_ADD_MEMBERSHIP: c_int = 20; +pub const IPV6_DROP_MEMBERSHIP: c_int = 21; +pub const IPV6_ROUTER_ALERT: c_int = 22; +pub const IPV6_MTU_DISCOVER: c_int = 23; +pub const IPV6_MTU: c_int = 24; +pub const IPV6_RECVERR: c_int = 25; +pub const IPV6_V6ONLY: c_int = 26; +pub const IPV6_JOIN_ANYCAST: c_int = 27; +pub const IPV6_LEAVE_ANYCAST: c_int = 28; +pub const IPV6_IPSEC_POLICY: c_int = 34; +pub const IPV6_XFRM_POLICY: c_int = 35; +pub const IPV6_HDRINCL: c_int = 36; +pub const IPV6_RECVPKTINFO: c_int = 49; +pub const IPV6_PKTINFO: c_int = 50; +pub const IPV6_RECVHOPLIMIT: c_int = 51; +pub const IPV6_HOPLIMIT: c_int = 52; +pub const IPV6_RECVHOPOPTS: c_int = 53; +pub const IPV6_HOPOPTS: c_int = 54; +pub const IPV6_RTHDRDSTOPTS: c_int = 55; +pub const IPV6_RECVRTHDR: c_int = 56; +pub const IPV6_RTHDR: c_int = 57; +pub const IPV6_RECVDSTOPTS: c_int = 58; +pub const IPV6_DSTOPTS: c_int = 59; +#[cfg(not(target_env = "uclibc"))] +pub const IPV6_RECVPATHMTU: c_int = 60; +#[cfg(not(target_env = "uclibc"))] +pub const IPV6_PATHMTU: c_int = 61; +#[cfg(not(target_env = "uclibc"))] +pub const IPV6_DONTFRAG: c_int = 62; +pub const IPV6_RECVTCLASS: c_int = 66; +pub const IPV6_TCLASS: c_int = 67; +cfg_if! { + if #[cfg(not(target_env = "uclibc"))] { + pub const IPV6_AUTOFLOWLABEL: c_int = 70; + pub const IPV6_ADDR_PREFERENCES: c_int = 72; + pub const IPV6_MINHOPCOUNT: c_int = 73; + pub const IPV6_ORIGDSTADDR: c_int = 74; + pub const IPV6_RECVORIGDSTADDR: c_int = IPV6_ORIGDSTADDR; + pub const IPV6_TRANSPARENT: c_int = 75; + pub const IPV6_UNICAST_IF: c_int = 76; + pub const IPV6_PREFER_SRC_TMP: c_int = 0x0001; + pub const IPV6_PREFER_SRC_PUBLIC: c_int = 0x0002; + pub const IPV6_PREFER_SRC_PUBTMP_DEFAULT: c_int = 0x0100; + pub const IPV6_PREFER_SRC_COA: c_int = 0x0004; + pub const IPV6_PREFER_SRC_HOME: c_int = 0x0400; + pub const IPV6_PREFER_SRC_CGA: c_int = 0x0008; + pub const IPV6_PREFER_SRC_NONCGA: c_int = 0x0800; + } +} + +pub const IPV6_PMTUDISC_DONT: c_int = 0; +pub const IPV6_PMTUDISC_WANT: c_int = 1; +pub const IPV6_PMTUDISC_DO: c_int = 2; +pub const IPV6_PMTUDISC_PROBE: c_int = 3; +pub const IPV6_PMTUDISC_INTERFACE: c_int = 4; +pub const IPV6_PMTUDISC_OMIT: c_int = 5; + +pub const TCP_NODELAY: c_int = 1; +pub const TCP_MAXSEG: c_int = 2; +pub const TCP_CORK: c_int = 3; +pub const TCP_KEEPIDLE: c_int = 4; +pub const TCP_KEEPINTVL: c_int = 5; +pub const TCP_KEEPCNT: c_int = 6; +pub const TCP_SYNCNT: c_int = 7; +pub const TCP_LINGER2: c_int = 8; +pub const TCP_DEFER_ACCEPT: c_int = 9; +pub const TCP_WINDOW_CLAMP: c_int = 10; +pub const TCP_INFO: c_int = 11; +pub const TCP_QUICKACK: c_int = 12; +pub const TCP_CONGESTION: c_int = 13; +pub const TCP_MD5SIG: c_int = 14; +cfg_if! { + if #[cfg(all( + target_os = "linux", + any(target_env = "gnu", target_env = "musl", target_env = "ohos") + ))] { + // WARN: deprecated + pub const TCP_COOKIE_TRANSACTIONS: c_int = 15; + } +} +pub const TCP_THIN_LINEAR_TIMEOUTS: c_int = 16; +pub const TCP_THIN_DUPACK: c_int = 17; +pub const TCP_USER_TIMEOUT: c_int = 18; +pub const TCP_REPAIR: c_int = 19; +pub const TCP_REPAIR_QUEUE: c_int = 20; +pub const TCP_QUEUE_SEQ: c_int = 21; +pub const TCP_REPAIR_OPTIONS: c_int = 22; +pub const TCP_FASTOPEN: c_int = 23; +pub const TCP_TIMESTAMP: c_int = 24; +pub const TCP_NOTSENT_LOWAT: c_int = 25; +pub const TCP_CC_INFO: c_int = 26; +pub const TCP_SAVE_SYN: c_int = 27; +pub const TCP_SAVED_SYN: c_int = 28; +cfg_if! { + if #[cfg(not(target_os = "emscripten"))] { + // NOTE: emscripten doesn't support these options yet. + + pub const TCP_REPAIR_WINDOW: c_int = 29; + pub const TCP_FASTOPEN_CONNECT: c_int = 30; + pub const TCP_ULP: c_int = 31; + pub const TCP_MD5SIG_EXT: c_int = 32; + pub const TCP_FASTOPEN_KEY: c_int = 33; + pub const TCP_FASTOPEN_NO_COOKIE: c_int = 34; + pub const TCP_ZEROCOPY_RECEIVE: c_int = 35; + pub const TCP_INQ: c_int = 36; + pub const TCP_CM_INQ: c_int = TCP_INQ; + // NOTE: Some CI images doesn't have this option yet. + // pub const TCP_TX_DELAY: c_int = 37; + pub const TCP_MD5SIG_MAXKEYLEN: usize = 80; + } +} + +pub const SO_DEBUG: c_int = 1; + +pub const SHUT_RD: c_int = 0; +pub const SHUT_WR: c_int = 1; +pub const SHUT_RDWR: c_int = 2; + +pub const LOCK_SH: c_int = 1; +pub const LOCK_EX: c_int = 2; +pub const LOCK_NB: c_int = 4; +pub const LOCK_UN: c_int = 8; + +pub const SS_ONSTACK: c_int = 1; +pub const SS_DISABLE: c_int = 2; + +pub const NAME_MAX: c_int = 255; +pub const PATH_MAX: c_int = 4096; + +pub const UIO_MAXIOV: c_int = 1024; + +pub const FD_SETSIZE: usize = 1024; + +pub const EPOLLIN: c_int = 0x1; +pub const EPOLLPRI: c_int = 0x2; +pub const EPOLLOUT: c_int = 0x4; +pub const EPOLLERR: c_int = 0x8; +pub const EPOLLHUP: c_int = 0x10; +pub const EPOLLRDNORM: c_int = 0x40; +pub const EPOLLRDBAND: c_int = 0x80; +pub const EPOLLWRNORM: c_int = 0x100; +pub const EPOLLWRBAND: c_int = 0x200; +pub const EPOLLMSG: c_int = 0x400; +pub const EPOLLRDHUP: c_int = 0x2000; +pub const EPOLLEXCLUSIVE: c_int = 0x10000000; +pub const EPOLLWAKEUP: c_int = 0x20000000; +pub const EPOLLONESHOT: c_int = 0x40000000; +pub const EPOLLET: c_int = 0x80000000; + +pub const EPOLL_CTL_ADD: c_int = 1; +pub const EPOLL_CTL_MOD: c_int = 3; +pub const EPOLL_CTL_DEL: c_int = 2; + +pub const MNT_FORCE: c_int = 0x1; +pub const MNT_DETACH: c_int = 0x2; +pub const MNT_EXPIRE: c_int = 0x4; +pub const UMOUNT_NOFOLLOW: c_int = 0x8; + +cfg_if! { + if #[cfg(not(target_os = "l4re"))] { + pub const Q_GETFMT: c_int = 0x800004; + pub const Q_GETINFO: c_int = 0x800005; + pub const Q_SETINFO: c_int = 0x800006; + pub const QIF_BLIMITS: u32 = 1; + pub const QIF_SPACE: u32 = 2; + pub const QIF_ILIMITS: u32 = 4; + pub const QIF_INODES: u32 = 8; + pub const QIF_BTIME: u32 = 16; + pub const QIF_ITIME: u32 = 32; + pub const QIF_LIMITS: u32 = 5; + pub const QIF_USAGE: u32 = 10; + pub const QIF_TIMES: u32 = 48; + pub const QIF_ALL: u32 = 63; + + pub const Q_SYNC: c_int = 0x800001; + pub const Q_QUOTAON: c_int = 0x800002; + pub const Q_QUOTAOFF: c_int = 0x800003; + pub const Q_GETQUOTA: c_int = 0x800007; + pub const Q_SETQUOTA: c_int = 0x800008; + } +} + +pub const TCIOFF: c_int = 2; +pub const TCION: c_int = 3; +pub const TCOOFF: c_int = 0; +pub const TCOON: c_int = 1; +pub const TCIFLUSH: c_int = 0; +pub const TCOFLUSH: c_int = 1; +pub const TCIOFLUSH: c_int = 2; +pub const NL0: crate::tcflag_t = 0x00000000; +pub const NL1: crate::tcflag_t = 0x00000100; +pub const TAB0: crate::tcflag_t = 0x00000000; +pub const CR0: crate::tcflag_t = 0x00000000; +pub const FF0: crate::tcflag_t = 0x00000000; +pub const BS0: crate::tcflag_t = 0x00000000; +pub const VT0: crate::tcflag_t = 0x00000000; +pub const VERASE: usize = 2; +pub const VKILL: usize = 3; +pub const VINTR: usize = 0; +pub const VQUIT: usize = 1; +pub const VLNEXT: usize = 15; +pub const IGNBRK: crate::tcflag_t = 0x00000001; +pub const BRKINT: crate::tcflag_t = 0x00000002; +pub const IGNPAR: crate::tcflag_t = 0x00000004; +pub const PARMRK: crate::tcflag_t = 0x00000008; +pub const INPCK: crate::tcflag_t = 0x00000010; +pub const ISTRIP: crate::tcflag_t = 0x00000020; +pub const INLCR: crate::tcflag_t = 0x00000040; +pub const IGNCR: crate::tcflag_t = 0x00000080; +pub const ICRNL: crate::tcflag_t = 0x00000100; +pub const IXANY: crate::tcflag_t = 0x00000800; +pub const IMAXBEL: crate::tcflag_t = 0x00002000; +pub const OPOST: crate::tcflag_t = 0x1; +pub const CS5: crate::tcflag_t = 0x00000000; +pub const CRTSCTS: crate::tcflag_t = 0x80000000; +pub const ECHO: crate::tcflag_t = 0x00000008; +pub const OCRNL: crate::tcflag_t = 0o000010; +pub const ONOCR: crate::tcflag_t = 0o000020; +pub const ONLRET: crate::tcflag_t = 0o000040; +pub const OFILL: crate::tcflag_t = 0o000100; +pub const OFDEL: crate::tcflag_t = 0o000200; + +pub const CLONE_VM: c_int = 0x100; +pub const CLONE_FS: c_int = 0x200; +pub const CLONE_FILES: c_int = 0x400; +pub const CLONE_SIGHAND: c_int = 0x800; +pub const CLONE_PTRACE: c_int = 0x2000; +pub const CLONE_VFORK: c_int = 0x4000; +pub const CLONE_PARENT: c_int = 0x8000; +pub const CLONE_THREAD: c_int = 0x10000; +pub const CLONE_NEWNS: c_int = 0x20000; +pub const CLONE_SYSVSEM: c_int = 0x40000; +pub const CLONE_SETTLS: c_int = 0x80000; +pub const CLONE_PARENT_SETTID: c_int = 0x100000; +pub const CLONE_CHILD_CLEARTID: c_int = 0x200000; +pub const CLONE_DETACHED: c_int = 0x400000; +pub const CLONE_UNTRACED: c_int = 0x800000; +pub const CLONE_CHILD_SETTID: c_int = 0x01000000; +#[cfg(not(target_os = "l4re"))] +pub const CLONE_NEWCGROUP: c_int = 0x02000000; +pub const CLONE_NEWUTS: c_int = 0x04000000; +pub const CLONE_NEWIPC: c_int = 0x08000000; +pub const CLONE_NEWUSER: c_int = 0x10000000; +pub const CLONE_NEWPID: c_int = 0x20000000; +pub const CLONE_NEWNET: c_int = 0x40000000; +pub const CLONE_IO: c_int = 0x80000000; + +pub const WNOHANG: c_int = 0x00000001; +pub const WUNTRACED: c_int = 0x00000002; +pub const WSTOPPED: c_int = WUNTRACED; +pub const WEXITED: c_int = 0x00000004; +pub const WCONTINUED: c_int = 0x00000008; +pub const WNOWAIT: c_int = 0x01000000; + +cfg_if! { + if #[cfg(not(target_os = "l4re"))] { + // Options for personality(2). + pub const ADDR_NO_RANDOMIZE: c_int = 0x0040000; + pub const MMAP_PAGE_ZERO: c_int = 0x0100000; + pub const ADDR_COMPAT_LAYOUT: c_int = 0x0200000; + pub const READ_IMPLIES_EXEC: c_int = 0x0400000; + pub const ADDR_LIMIT_32BIT: c_int = 0x0800000; + pub const SHORT_INODE: c_int = 0x1000000; + pub const WHOLE_SECONDS: c_int = 0x2000000; + pub const STICKY_TIMEOUTS: c_int = 0x4000000; + pub const ADDR_LIMIT_3GB: c_int = 0x8000000; + + // Options set using PTRACE_SETOPTIONS. + pub const PTRACE_O_TRACESYSGOOD: c_int = 0x00000001; + pub const PTRACE_O_TRACEFORK: c_int = 0x00000002; + pub const PTRACE_O_TRACEVFORK: c_int = 0x00000004; + pub const PTRACE_O_TRACECLONE: c_int = 0x00000008; + pub const PTRACE_O_TRACEEXEC: c_int = 0x00000010; + pub const PTRACE_O_TRACEVFORKDONE: c_int = 0x00000020; + pub const PTRACE_O_TRACEEXIT: c_int = 0x00000040; + pub const PTRACE_O_TRACESECCOMP: c_int = 0x00000080; + pub const PTRACE_O_SUSPEND_SECCOMP: c_int = 0x00200000; + pub const PTRACE_O_EXITKILL: c_int = 0x00100000; + pub const PTRACE_O_MASK: c_int = 0x003000ff; + + // Wait extended result codes for the above trace options. + pub const PTRACE_EVENT_FORK: c_int = 1; + pub const PTRACE_EVENT_VFORK: c_int = 2; + pub const PTRACE_EVENT_CLONE: c_int = 3; + pub const PTRACE_EVENT_EXEC: c_int = 4; + pub const PTRACE_EVENT_VFORK_DONE: c_int = 5; + pub const PTRACE_EVENT_EXIT: c_int = 6; + pub const PTRACE_EVENT_SECCOMP: c_int = 7; + } +} + +pub const __WNOTHREAD: c_int = 0x20000000; +pub const __WALL: c_int = 0x40000000; +pub const __WCLONE: c_int = 0x80000000; + +cfg_if! { + if #[cfg(not(target_env = "uclibc"))] { + pub const SPLICE_F_MOVE: c_uint = 0x01; + pub const SPLICE_F_NONBLOCK: c_uint = 0x02; + pub const SPLICE_F_MORE: c_uint = 0x04; + pub const SPLICE_F_GIFT: c_uint = 0x08; + } +} + +pub const RTLD_LOCAL: c_int = 0; +pub const RTLD_LAZY: c_int = 1; + +pub const POSIX_FADV_NORMAL: c_int = 0; +pub const POSIX_FADV_RANDOM: c_int = 1; +pub const POSIX_FADV_SEQUENTIAL: c_int = 2; +pub const POSIX_FADV_WILLNEED: c_int = 3; + +pub const AT_FDCWD: c_int = -100; +pub const AT_SYMLINK_NOFOLLOW: c_int = 0x100; +pub const AT_REMOVEDIR: c_int = 0x200; +pub const AT_SYMLINK_FOLLOW: c_int = 0x400; +pub const AT_NO_AUTOMOUNT: c_int = 0x800; +pub const AT_EMPTY_PATH: c_int = 0x1000; +pub const AT_RECURSIVE: c_int = 0x8000; + +pub const LOG_CRON: c_int = 9 << 3; +pub const LOG_AUTHPRIV: c_int = 10 << 3; +pub const LOG_FTP: c_int = 11 << 3; +pub const LOG_PERROR: c_int = 0x20; + +#[cfg(not(target_os = "l4re"))] +pub const PIPE_BUF: usize = 4096; + +pub const SI_LOAD_SHIFT: c_uint = 16; + +// si_code values +pub const SI_USER: c_int = 0; +pub const SI_KERNEL: c_int = 0x80; +pub const SI_QUEUE: c_int = -1; +cfg_if! { + if #[cfg(not(any( + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "mips64" + )))] { + pub const SI_TIMER: c_int = -2; + pub const SI_MESGQ: c_int = -3; + pub const SI_ASYNCIO: c_int = -4; + } else { + pub const SI_TIMER: c_int = -3; + pub const SI_MESGQ: c_int = -4; + pub const SI_ASYNCIO: c_int = -2; + } +} +pub const SI_SIGIO: c_int = -5; +pub const SI_TKILL: c_int = -6; +pub const SI_ASYNCNL: c_int = -60; + +// si_code values for SIGBUS signal +pub const BUS_ADRALN: c_int = 1; +pub const BUS_ADRERR: c_int = 2; +pub const BUS_OBJERR: c_int = 3; +// Linux-specific si_code values for SIGBUS signal +#[cfg(not(target_os = "l4re"))] +pub const BUS_MCEERR_AR: c_int = 4; +#[cfg(not(target_os = "l4re"))] +pub const BUS_MCEERR_AO: c_int = 5; + +// si_code values for SIGTRAP +pub const TRAP_BRKPT: c_int = 1; +pub const TRAP_TRACE: c_int = 2; +#[cfg(not(target_os = "l4re"))] +pub const TRAP_BRANCH: c_int = 3; +#[cfg(not(target_os = "l4re"))] +pub const TRAP_HWBKPT: c_int = 4; +#[cfg(not(target_os = "l4re"))] +pub const TRAP_UNK: c_int = 5; + +// si_code values for SIGCHLD signal +pub const CLD_EXITED: c_int = 1; +pub const CLD_KILLED: c_int = 2; +pub const CLD_DUMPED: c_int = 3; +pub const CLD_TRAPPED: c_int = 4; +pub const CLD_STOPPED: c_int = 5; +pub const CLD_CONTINUED: c_int = 6; + +pub const SIGEV_SIGNAL: c_int = 0; +pub const SIGEV_NONE: c_int = 1; +pub const SIGEV_THREAD: c_int = 2; + +pub const P_ALL: idtype_t = 0; +pub const P_PID: idtype_t = 1; +pub const P_PGID: idtype_t = 2; +cfg_if! { + if #[cfg(not(target_os = "emscripten"))] { + pub const P_PIDFD: idtype_t = 3; + } +} + +pub const UTIME_OMIT: c_long = 1073741822; +pub const UTIME_NOW: c_long = 1073741823; + +pub const POLLIN: c_short = 0x1; +pub const POLLPRI: c_short = 0x2; +pub const POLLOUT: c_short = 0x4; +pub const POLLERR: c_short = 0x8; +pub const POLLHUP: c_short = 0x10; +pub const POLLNVAL: c_short = 0x20; +pub const POLLRDNORM: c_short = 0x040; +pub const POLLRDBAND: c_short = 0x080; +#[cfg(not(any(target_arch = "sparc", target_arch = "sparc64")))] +pub const POLLRDHUP: c_short = 0x2000; +#[cfg(any(target_arch = "sparc", target_arch = "sparc64"))] +pub const POLLRDHUP: c_short = 0x800; + +pub const IPTOS_LOWDELAY: u8 = 0x10; +pub const IPTOS_THROUGHPUT: u8 = 0x08; +pub const IPTOS_RELIABILITY: u8 = 0x04; +pub const IPTOS_MINCOST: u8 = 0x02; + +pub const IPTOS_PREC_NETCONTROL: u8 = 0xe0; +pub const IPTOS_PREC_INTERNETCONTROL: u8 = 0xc0; +pub const IPTOS_PREC_CRITIC_ECP: u8 = 0xa0; +pub const IPTOS_PREC_FLASHOVERRIDE: u8 = 0x80; +pub const IPTOS_PREC_FLASH: u8 = 0x60; +pub const IPTOS_PREC_IMMEDIATE: u8 = 0x40; +pub const IPTOS_PREC_PRIORITY: u8 = 0x20; +pub const IPTOS_PREC_ROUTINE: u8 = 0x00; + +pub const IPTOS_ECN_MASK: u8 = 0x03; +pub const IPTOS_ECN_ECT1: u8 = 0x01; +pub const IPTOS_ECN_ECT0: u8 = 0x02; +pub const IPTOS_ECN_CE: u8 = 0x03; + +pub const IPOPT_COPY: u8 = 0x80; +pub const IPOPT_CLASS_MASK: u8 = 0x60; +pub const IPOPT_NUMBER_MASK: u8 = 0x1f; + +pub const IPOPT_CONTROL: u8 = 0x00; +pub const IPOPT_RESERVED1: u8 = 0x20; +pub const IPOPT_MEASUREMENT: u8 = 0x40; +pub const IPOPT_RESERVED2: u8 = 0x60; +pub const IPOPT_END: u8 = 0 | IPOPT_CONTROL; +pub const IPOPT_NOOP: u8 = 1 | IPOPT_CONTROL; +pub const IPOPT_SEC: u8 = 2 | IPOPT_CONTROL | IPOPT_COPY; +pub const IPOPT_LSRR: u8 = 3 | IPOPT_CONTROL | IPOPT_COPY; +pub const IPOPT_TIMESTAMP: u8 = 4 | IPOPT_MEASUREMENT; +pub const IPOPT_RR: u8 = 7 | IPOPT_CONTROL; +pub const IPOPT_SID: u8 = 8 | IPOPT_CONTROL | IPOPT_COPY; +pub const IPOPT_SSRR: u8 = 9 | IPOPT_CONTROL | IPOPT_COPY; +pub const IPOPT_RA: u8 = 20 | IPOPT_CONTROL | IPOPT_COPY; +pub const IPVERSION: u8 = 4; +pub const MAXTTL: u8 = 255; +pub const IPDEFTTL: u8 = 64; +pub const IPOPT_OPTVAL: u8 = 0; +pub const IPOPT_OLEN: u8 = 1; +pub const IPOPT_OFFSET: u8 = 2; +pub const IPOPT_MINOFF: u8 = 4; +pub const MAX_IPOPTLEN: u8 = 40; +pub const IPOPT_NOP: u8 = IPOPT_NOOP; +pub const IPOPT_EOL: u8 = IPOPT_END; +pub const IPOPT_TS: u8 = IPOPT_TIMESTAMP; +pub const IPOPT_TS_TSONLY: u8 = 0; +pub const IPOPT_TS_TSANDADDR: u8 = 1; +pub const IPOPT_TS_PRESPEC: u8 = 3; + +pub const ARPOP_RREQUEST: u16 = 3; +pub const ARPOP_RREPLY: u16 = 4; +pub const ARPOP_InREQUEST: u16 = 8; +pub const ARPOP_InREPLY: u16 = 9; +pub const ARPOP_NAK: u16 = 10; + +pub const ATF_NETMASK: c_int = 0x20; +pub const ATF_DONTPUB: c_int = 0x40; + +pub const ARPHRD_NETROM: u16 = 0; +pub const ARPHRD_ETHER: u16 = 1; +pub const ARPHRD_EETHER: u16 = 2; +pub const ARPHRD_AX25: u16 = 3; +pub const ARPHRD_PRONET: u16 = 4; +pub const ARPHRD_CHAOS: u16 = 5; +pub const ARPHRD_IEEE802: u16 = 6; +pub const ARPHRD_ARCNET: u16 = 7; +pub const ARPHRD_APPLETLK: u16 = 8; +pub const ARPHRD_DLCI: u16 = 15; +pub const ARPHRD_ATM: u16 = 19; +pub const ARPHRD_METRICOM: u16 = 23; +pub const ARPHRD_IEEE1394: u16 = 24; +pub const ARPHRD_EUI64: u16 = 27; +pub const ARPHRD_INFINIBAND: u16 = 32; + +pub const ARPHRD_SLIP: u16 = 256; +pub const ARPHRD_CSLIP: u16 = 257; +pub const ARPHRD_SLIP6: u16 = 258; +pub const ARPHRD_CSLIP6: u16 = 259; +pub const ARPHRD_RSRVD: u16 = 260; +pub const ARPHRD_ADAPT: u16 = 264; +pub const ARPHRD_ROSE: u16 = 270; +pub const ARPHRD_X25: u16 = 271; +pub const ARPHRD_HWX25: u16 = 272; +pub const ARPHRD_CAN: u16 = 280; +pub const ARPHRD_PPP: u16 = 512; +pub const ARPHRD_CISCO: u16 = 513; +pub const ARPHRD_HDLC: u16 = ARPHRD_CISCO; +pub const ARPHRD_LAPB: u16 = 516; +pub const ARPHRD_DDCMP: u16 = 517; +pub const ARPHRD_RAWHDLC: u16 = 518; + +pub const ARPHRD_TUNNEL: u16 = 768; +pub const ARPHRD_TUNNEL6: u16 = 769; +pub const ARPHRD_FRAD: u16 = 770; +pub const ARPHRD_SKIP: u16 = 771; +pub const ARPHRD_LOOPBACK: u16 = 772; +pub const ARPHRD_LOCALTLK: u16 = 773; +pub const ARPHRD_FDDI: u16 = 774; +pub const ARPHRD_BIF: u16 = 775; +pub const ARPHRD_SIT: u16 = 776; +pub const ARPHRD_IPDDP: u16 = 777; +pub const ARPHRD_IPGRE: u16 = 778; +pub const ARPHRD_PIMREG: u16 = 779; +pub const ARPHRD_HIPPI: u16 = 780; +pub const ARPHRD_ASH: u16 = 781; +pub const ARPHRD_ECONET: u16 = 782; +pub const ARPHRD_IRDA: u16 = 783; +pub const ARPHRD_FCPP: u16 = 784; +pub const ARPHRD_FCAL: u16 = 785; +pub const ARPHRD_FCPL: u16 = 786; +pub const ARPHRD_FCFABRIC: u16 = 787; +pub const ARPHRD_IEEE802_TR: u16 = 800; +pub const ARPHRD_IEEE80211: u16 = 801; +pub const ARPHRD_IEEE80211_PRISM: u16 = 802; +pub const ARPHRD_IEEE80211_RADIOTAP: u16 = 803; +pub const ARPHRD_IEEE802154: u16 = 804; + +pub const ARPHRD_VOID: u16 = 0xFFFF; +pub const ARPHRD_NONE: u16 = 0xFFFE; + +cfg_if! { + if #[cfg(not(any(target_os = "emscripten", target_os = "l4re")))] { + // linux/if_tun.h + /* TUNSETIFF ifr flags */ + pub const IFF_TUN: c_int = 0x0001; + pub const IFF_TAP: c_int = 0x0002; + pub const IFF_NAPI: c_int = 0x0010; + pub const IFF_NAPI_FRAGS: c_int = 0x0020; + // Used in TUNSETIFF to bring up tun/tap without carrier + pub const IFF_NO_CARRIER: c_int = 0x0040; + pub const IFF_NO_PI: c_int = 0x1000; + // Read queue size + pub const TUN_READQ_SIZE: c_short = 500; + // TUN device type flags: deprecated. Use IFF_TUN/IFF_TAP instead. + pub const TUN_TUN_DEV: c_short = crate::IFF_TUN as c_short; + pub const TUN_TAP_DEV: c_short = crate::IFF_TAP as c_short; + pub const TUN_TYPE_MASK: c_short = 0x000f; + // This flag has no real effect + pub const IFF_ONE_QUEUE: c_int = 0x2000; + pub const IFF_VNET_HDR: c_int = 0x4000; + pub const IFF_TUN_EXCL: c_int = 0x8000; + pub const IFF_MULTI_QUEUE: c_int = 0x0100; + pub const IFF_ATTACH_QUEUE: c_int = 0x0200; + pub const IFF_DETACH_QUEUE: c_int = 0x0400; + // read-only flag + pub const IFF_PERSIST: c_int = 0x0800; + pub const IFF_NOFILTER: c_int = 0x1000; + // Socket options + pub const TUN_TX_TIMESTAMP: c_int = 1; + // Features for GSO (TUNSETOFFLOAD) + pub const TUN_F_CSUM: c_uint = 0x01; + pub const TUN_F_TSO4: c_uint = 0x02; + pub const TUN_F_TSO6: c_uint = 0x04; + pub const TUN_F_TSO_ECN: c_uint = 0x08; + pub const TUN_F_UFO: c_uint = 0x10; + pub const TUN_F_USO4: c_uint = 0x20; + pub const TUN_F_USO6: c_uint = 0x40; + // Protocol info prepended to the packets (when IFF_NO_PI is not set) + pub const TUN_PKT_STRIP: c_int = 0x0001; + // Accept all multicast packets + pub const TUN_FLT_ALLMULTI: c_int = 0x0001; + // Ioctl operation codes + const T_TYPE: u32 = b'T' as u32; + pub const TUNSETNOCSUM: Ioctl = _IOW::(T_TYPE, 200); + pub const TUNSETDEBUG: Ioctl = _IOW::(T_TYPE, 201); + pub const TUNSETIFF: Ioctl = _IOW::(T_TYPE, 202); + pub const TUNSETPERSIST: Ioctl = _IOW::(T_TYPE, 203); + pub const TUNSETOWNER: Ioctl = _IOW::(T_TYPE, 204); + pub const TUNSETLINK: Ioctl = _IOW::(T_TYPE, 205); + pub const TUNSETGROUP: Ioctl = _IOW::(T_TYPE, 206); + pub const TUNGETFEATURES: Ioctl = _IOR::(T_TYPE, 207); + pub const TUNSETOFFLOAD: Ioctl = _IOW::(T_TYPE, 208); + pub const TUNSETTXFILTER: Ioctl = _IOW::(T_TYPE, 209); + pub const TUNGETIFF: Ioctl = _IOR::(T_TYPE, 210); + pub const TUNGETSNDBUF: Ioctl = _IOR::(T_TYPE, 211); + pub const TUNSETSNDBUF: Ioctl = _IOW::(T_TYPE, 212); + pub const TUNATTACHFILTER: Ioctl = _IOW::(T_TYPE, 213); + pub const TUNDETACHFILTER: Ioctl = _IOW::(T_TYPE, 214); + pub const TUNGETVNETHDRSZ: Ioctl = _IOR::(T_TYPE, 215); + pub const TUNSETVNETHDRSZ: Ioctl = _IOW::(T_TYPE, 216); + pub const TUNSETQUEUE: Ioctl = _IOW::(T_TYPE, 217); + pub const TUNSETIFINDEX: Ioctl = _IOW::(T_TYPE, 218); + pub const TUNGETFILTER: Ioctl = _IOR::(T_TYPE, 219); + pub const TUNSETVNETLE: Ioctl = _IOW::(T_TYPE, 220); + pub const TUNGETVNETLE: Ioctl = _IOR::(T_TYPE, 221); + pub const TUNSETVNETBE: Ioctl = _IOW::(T_TYPE, 222); + pub const TUNGETVNETBE: Ioctl = _IOR::(T_TYPE, 223); + pub const TUNSETSTEERINGEBPF: Ioctl = _IOR::(T_TYPE, 224); + pub const TUNSETFILTEREBPF: Ioctl = _IOR::(T_TYPE, 225); + pub const TUNSETCARRIER: Ioctl = _IOW::(T_TYPE, 226); + pub const TUNGETDEVNETNS: Ioctl = _IO(T_TYPE, 227); + + // linux/fs.h + pub const FS_IOC_GETFLAGS: Ioctl = _IOR::('f' as u32, 1); + pub const FS_IOC_SETFLAGS: Ioctl = _IOW::('f' as u32, 2); + pub const FS_IOC_GETVERSION: Ioctl = _IOR::('v' as u32, 1); + pub const FS_IOC_SETVERSION: Ioctl = _IOW::('v' as u32, 2); + pub const FS_IOC32_GETFLAGS: Ioctl = _IOR::('f' as u32, 1); + pub const FS_IOC32_SETFLAGS: Ioctl = _IOW::('f' as u32, 2); + pub const FS_IOC32_GETVERSION: Ioctl = _IOR::('v' as u32, 1); + pub const FS_IOC32_SETVERSION: Ioctl = _IOW::('v' as u32, 2); + + pub const FICLONE: Ioctl = _IOW::(0x94, 9); + pub const FICLONERANGE: Ioctl = _IOW::(0x94, 13); + } +} + +cfg_if! { + if #[cfg(any(target_os = "emscripten", target_os = "l4re"))] { + // Emscripten does not define any `*_SUPER_MAGIC` constants. + } else if #[cfg(not(target_arch = "s390x"))] { + pub const ADFS_SUPER_MAGIC: c_long = 0x0000adf5; + pub const AFFS_SUPER_MAGIC: c_long = 0x0000adff; + pub const AFS_SUPER_MAGIC: c_long = 0x5346414f; + pub const AUTOFS_SUPER_MAGIC: c_long = 0x0187; + pub const BPF_FS_MAGIC: c_long = 0xcafe4a11; + pub const BTRFS_SUPER_MAGIC: c_long = 0x9123683e; + pub const CGROUP2_SUPER_MAGIC: c_long = 0x63677270; + pub const CGROUP_SUPER_MAGIC: c_long = 0x27e0eb; + pub const CODA_SUPER_MAGIC: c_long = 0x73757245; + pub const CRAMFS_MAGIC: c_long = 0x28cd3d45; + pub const DEBUGFS_MAGIC: c_long = 0x64626720; + pub const DEVPTS_SUPER_MAGIC: c_long = 0x1cd1; + pub const ECRYPTFS_SUPER_MAGIC: c_long = 0xf15f; + pub const EFS_SUPER_MAGIC: c_long = 0x00414a53; + pub const EXT2_SUPER_MAGIC: c_long = 0x0000ef53; + pub const EXT3_SUPER_MAGIC: c_long = 0x0000ef53; + pub const EXT4_SUPER_MAGIC: c_long = 0x0000ef53; + pub const F2FS_SUPER_MAGIC: c_long = 0xf2f52010; + pub const FUSE_SUPER_MAGIC: c_long = 0x65735546; + pub const FUTEXFS_SUPER_MAGIC: c_long = 0xbad1dea; + pub const HOSTFS_SUPER_MAGIC: c_long = 0x00c0ffee; + pub const HPFS_SUPER_MAGIC: c_long = 0xf995e849; + pub const HUGETLBFS_MAGIC: c_long = 0x958458f6; + pub const ISOFS_SUPER_MAGIC: c_long = 0x00009660; + pub const JFFS2_SUPER_MAGIC: c_long = 0x000072b6; + pub const MINIX2_SUPER_MAGIC2: c_long = 0x00002478; + pub const MINIX2_SUPER_MAGIC: c_long = 0x00002468; + pub const MINIX3_SUPER_MAGIC: c_long = 0x4d5a; + pub const MINIX_SUPER_MAGIC2: c_long = 0x0000138f; + pub const MINIX_SUPER_MAGIC: c_long = 0x0000137f; + pub const MSDOS_SUPER_MAGIC: c_long = 0x00004d44; + pub const NCP_SUPER_MAGIC: c_long = 0x0000564c; + pub const NFS_SUPER_MAGIC: c_long = 0x00006969; + pub const NILFS_SUPER_MAGIC: c_long = 0x3434; + pub const OCFS2_SUPER_MAGIC: c_long = 0x7461636f; + pub const OPENPROM_SUPER_MAGIC: c_long = 0x00009fa1; + pub const OVERLAYFS_SUPER_MAGIC: c_long = 0x794c7630; + pub const PROC_SUPER_MAGIC: c_long = 0x00009fa0; + pub const QNX4_SUPER_MAGIC: c_long = 0x0000002f; + pub const QNX6_SUPER_MAGIC: c_long = 0x68191122; + pub const RDTGROUP_SUPER_MAGIC: c_long = 0x7655821; + pub const REISERFS_SUPER_MAGIC: c_long = 0x52654973; + pub const SECURITYFS_MAGIC: c_long = 0x73636673; + pub const SELINUX_MAGIC: c_long = 0xf97cff8c; + pub const SMACK_MAGIC: c_long = 0x43415d53; + pub const SMB_SUPER_MAGIC: c_long = 0x0000517b; + pub const SYSFS_MAGIC: c_long = 0x62656572; + pub const TMPFS_MAGIC: c_long = 0x01021994; + pub const TRACEFS_MAGIC: c_long = 0x74726163; + pub const UDF_SUPER_MAGIC: c_long = 0x15013346; + pub const USBDEVICE_SUPER_MAGIC: c_long = 0x00009fa2; + pub const XENFS_SUPER_MAGIC: c_long = 0xabba1974; + pub const NSFS_MAGIC: c_long = 0x6e736673; + } else if #[cfg(target_arch = "s390x")] { + pub const ADFS_SUPER_MAGIC: c_uint = 0x0000adf5; + pub const AFFS_SUPER_MAGIC: c_uint = 0x0000adff; + pub const AFS_SUPER_MAGIC: c_uint = 0x5346414f; + pub const AUTOFS_SUPER_MAGIC: c_uint = 0x0187; + pub const BPF_FS_MAGIC: c_uint = 0xcafe4a11; + pub const BTRFS_SUPER_MAGIC: c_uint = 0x9123683e; + pub const CGROUP2_SUPER_MAGIC: c_uint = 0x63677270; + pub const CGROUP_SUPER_MAGIC: c_uint = 0x27e0eb; + pub const CODA_SUPER_MAGIC: c_uint = 0x73757245; + pub const CRAMFS_MAGIC: c_uint = 0x28cd3d45; + pub const DEBUGFS_MAGIC: c_uint = 0x64626720; + pub const DEVPTS_SUPER_MAGIC: c_uint = 0x1cd1; + pub const ECRYPTFS_SUPER_MAGIC: c_uint = 0xf15f; + pub const EFS_SUPER_MAGIC: c_uint = 0x00414a53; + pub const EXT2_SUPER_MAGIC: c_uint = 0x0000ef53; + pub const EXT3_SUPER_MAGIC: c_uint = 0x0000ef53; + pub const EXT4_SUPER_MAGIC: c_uint = 0x0000ef53; + pub const F2FS_SUPER_MAGIC: c_uint = 0xf2f52010; + pub const FUSE_SUPER_MAGIC: c_uint = 0x65735546; + pub const FUTEXFS_SUPER_MAGIC: c_uint = 0xbad1dea; + pub const HOSTFS_SUPER_MAGIC: c_uint = 0x00c0ffee; + pub const HPFS_SUPER_MAGIC: c_uint = 0xf995e849; + pub const HUGETLBFS_MAGIC: c_uint = 0x958458f6; + pub const ISOFS_SUPER_MAGIC: c_uint = 0x00009660; + pub const JFFS2_SUPER_MAGIC: c_uint = 0x000072b6; + pub const MINIX2_SUPER_MAGIC2: c_uint = 0x00002478; + pub const MINIX2_SUPER_MAGIC: c_uint = 0x00002468; + pub const MINIX3_SUPER_MAGIC: c_uint = 0x4d5a; + pub const MINIX_SUPER_MAGIC2: c_uint = 0x0000138f; + pub const MINIX_SUPER_MAGIC: c_uint = 0x0000137f; + pub const MSDOS_SUPER_MAGIC: c_uint = 0x00004d44; + pub const NCP_SUPER_MAGIC: c_uint = 0x0000564c; + pub const NFS_SUPER_MAGIC: c_uint = 0x00006969; + pub const NILFS_SUPER_MAGIC: c_uint = 0x3434; + pub const OCFS2_SUPER_MAGIC: c_uint = 0x7461636f; + pub const OPENPROM_SUPER_MAGIC: c_uint = 0x00009fa1; + pub const OVERLAYFS_SUPER_MAGIC: c_uint = 0x794c7630; + pub const PROC_SUPER_MAGIC: c_uint = 0x00009fa0; + pub const QNX4_SUPER_MAGIC: c_uint = 0x0000002f; + pub const QNX6_SUPER_MAGIC: c_uint = 0x68191122; + pub const RDTGROUP_SUPER_MAGIC: c_uint = 0x7655821; + pub const REISERFS_SUPER_MAGIC: c_uint = 0x52654973; + pub const SECURITYFS_MAGIC: c_uint = 0x73636673; + pub const SELINUX_MAGIC: c_uint = 0xf97cff8c; + pub const SMACK_MAGIC: c_uint = 0x43415d53; + pub const SMB_SUPER_MAGIC: c_uint = 0x0000517b; + pub const SYSFS_MAGIC: c_uint = 0x62656572; + pub const TMPFS_MAGIC: c_uint = 0x01021994; + pub const TRACEFS_MAGIC: c_uint = 0x74726163; + pub const UDF_SUPER_MAGIC: c_uint = 0x15013346; + pub const USBDEVICE_SUPER_MAGIC: c_uint = 0x00009fa2; + pub const XENFS_SUPER_MAGIC: c_uint = 0xabba1974; + pub const NSFS_MAGIC: c_uint = 0x6e736673; + } +} + +cfg_if! { + if #[cfg(any( + target_env = "gnu", + target_os = "android", + all(target_env = "musl", musl_v1_2_3), + target_os = "l4re" + ))] { + pub const AT_STATX_SYNC_TYPE: c_int = 0x6000; + pub const AT_STATX_SYNC_AS_STAT: c_int = 0x0000; + pub const AT_STATX_FORCE_SYNC: c_int = 0x2000; + pub const AT_STATX_DONT_SYNC: c_int = 0x4000; + pub const STATX_TYPE: c_uint = 0x0001; + pub const STATX_MODE: c_uint = 0x0002; + pub const STATX_NLINK: c_uint = 0x0004; + pub const STATX_UID: c_uint = 0x0008; + pub const STATX_GID: c_uint = 0x0010; + pub const STATX_ATIME: c_uint = 0x0020; + pub const STATX_MTIME: c_uint = 0x0040; + pub const STATX_CTIME: c_uint = 0x0080; + pub const STATX_INO: c_uint = 0x0100; + pub const STATX_SIZE: c_uint = 0x0200; + pub const STATX_BLOCKS: c_uint = 0x0400; + pub const STATX_BASIC_STATS: c_uint = 0x07ff; + pub const STATX_BTIME: c_uint = 0x0800; + pub const STATX_ALL: c_uint = 0x0fff; + pub const STATX_MNT_ID: c_uint = 0x1000; + pub const STATX_DIOALIGN: c_uint = 0x2000; + pub const STATX__RESERVED: c_int = 0x80000000; + pub const STATX_ATTR_COMPRESSED: c_int = 0x0004; + pub const STATX_ATTR_IMMUTABLE: c_int = 0x0010; + pub const STATX_ATTR_APPEND: c_int = 0x0020; + pub const STATX_ATTR_NODUMP: c_int = 0x0040; + pub const STATX_ATTR_ENCRYPTED: c_int = 0x0800; + pub const STATX_ATTR_AUTOMOUNT: c_int = 0x1000; + pub const STATX_ATTR_MOUNT_ROOT: c_int = 0x2000; + pub const STATX_ATTR_VERITY: c_int = 0x100000; + pub const STATX_ATTR_DAX: c_int = 0x200000; + } +} + +// https://github.com/search?q=repo%3Atorvalds%2Flinux+%22%23define+_IOC_NONE%22&type=code +cfg_if! { + if #[cfg(not(target_os = "emscripten"))] { + const _IOC_NRBITS: u32 = 8; + const _IOC_TYPEBITS: u32 = 8; + + cfg_if! { + if #[cfg(any( + any(target_arch = "powerpc", target_arch = "powerpc64"), + any(target_arch = "sparc", target_arch = "sparc64"), + any(target_arch = "mips", target_arch = "mips64"), + ))] { + // https://github.com/torvalds/linux/blob/b311c1b497e51a628aa89e7cb954481e5f9dced2/arch/powerpc/include/uapi/asm/ioctl.h + // https://github.com/torvalds/linux/blob/b311c1b497e51a628aa89e7cb954481e5f9dced2/arch/sparc/include/uapi/asm/ioctl.h + // https://github.com/torvalds/linux/blob/b311c1b497e51a628aa89e7cb954481e5f9dced2/arch/mips/include/uapi/asm/ioctl.h + + const _IOC_SIZEBITS: u32 = 13; + const _IOC_DIRBITS: u32 = 3; + + const _IOC_NONE: u32 = 1; + const _IOC_READ: u32 = 2; + const _IOC_WRITE: u32 = 4; + } else { + // https://github.com/torvalds/linux/blob/b311c1b497e51a628aa89e7cb954481e5f9dced2/include/uapi/asm-generic/ioctl.h + + const _IOC_SIZEBITS: u32 = 14; + const _IOC_DIRBITS: u32 = 2; + + const _IOC_NONE: u32 = 0; + const _IOC_WRITE: u32 = 1; + const _IOC_READ: u32 = 2; + } + } + const _IOC_NRMASK: u32 = (1 << _IOC_NRBITS) - 1; + const _IOC_TYPEMASK: u32 = (1 << _IOC_TYPEBITS) - 1; + const _IOC_SIZEMASK: u32 = (1 << _IOC_SIZEBITS) - 1; + const _IOC_DIRMASK: u32 = (1 << _IOC_DIRBITS) - 1; + + const _IOC_NRSHIFT: u32 = 0; + const _IOC_TYPESHIFT: u32 = _IOC_NRSHIFT + _IOC_NRBITS; + const _IOC_SIZESHIFT: u32 = _IOC_TYPESHIFT + _IOC_TYPEBITS; + const _IOC_DIRSHIFT: u32 = _IOC_SIZESHIFT + _IOC_SIZEBITS; + + // adapted from https://github.com/torvalds/linux/blob/8a696a29c6905594e4abf78eaafcb62165ac61f1/rust/kernel/ioctl.rs + + /// Build an ioctl number, analogous to the C macro of the same name. + const fn _IOC(dir: u32, ty: u32, nr: u32, size: usize) -> Ioctl { + core::debug_assert!(dir <= _IOC_DIRMASK); + core::debug_assert!(ty <= _IOC_TYPEMASK); + core::debug_assert!(nr <= _IOC_NRMASK); + core::debug_assert!(size <= (_IOC_SIZEMASK as usize)); + + ((dir << _IOC_DIRSHIFT) + | (ty << _IOC_TYPESHIFT) + | (nr << _IOC_NRSHIFT) + | ((size as u32) << _IOC_SIZESHIFT)) as Ioctl + } + + /// Build an ioctl number for an argumentless ioctl. + pub const fn _IO(ty: u32, nr: u32) -> Ioctl { + _IOC(_IOC_NONE, ty, nr, 0) + } + + /// Build an ioctl number for an read-only ioctl. + pub const fn _IOR(ty: u32, nr: u32) -> Ioctl { + _IOC(_IOC_READ, ty, nr, size_of::()) + } + + /// Build an ioctl number for an write-only ioctl. + pub const fn _IOW(ty: u32, nr: u32) -> Ioctl { + _IOC(_IOC_WRITE, ty, nr, size_of::()) + } + + /// Build an ioctl number for a read-write ioctl. + pub const fn _IOWR(ty: u32, nr: u32) -> Ioctl { + _IOC(_IOC_READ | _IOC_WRITE, ty, nr, size_of::()) + } + + extern "C" { + #[cfg_attr(gnu_time_bits64, link_name = "__ioctl_time64")] + pub fn ioctl(fd: c_int, request: Ioctl, ...) -> c_int; + } + } +} + +const fn CMSG_ALIGN(len: usize) -> usize { + (len + size_of::() - 1) & !(size_of::() - 1) +} + +f! { + pub fn CMSG_FIRSTHDR(mhdr: *const crate::msghdr) -> *mut crate::cmsghdr { + if (*mhdr).msg_controllen as usize >= size_of::() { + (*mhdr).msg_control.cast::() + } else { + core::ptr::null_mut::() + } + } + + pub fn CMSG_DATA(cmsg: *const crate::cmsghdr) -> *mut c_uchar { + cmsg.offset(1) as *mut c_uchar + } + + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { + (CMSG_ALIGN(length as usize) + CMSG_ALIGN(size_of::())) as c_uint + } + + pub const fn CMSG_LEN(length: c_uint) -> c_uint { + CMSG_ALIGN(size_of::()) as c_uint + length + } + + pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { + let fd = fd as usize; + let size = size_of_val(&(*set).fds_bits[0]) * 8; + (*set).fds_bits[fd / size] &= !(1 << (fd % size)); + return; + } + + pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { + let fd = fd as usize; + let size = size_of_val(&(*set).fds_bits[0]) * 8; + return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0; + } + + pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { + let fd = fd as usize; + let size = size_of_val(&(*set).fds_bits[0]) * 8; + (*set).fds_bits[fd / size] |= 1 << (fd % size); + return; + } + + pub fn FD_ZERO(set: *mut fd_set) -> () { + for slot in &mut (*set).fds_bits { + *slot = 0; + } + } +} + +safe_f! { + pub fn SIGRTMAX() -> c_int { + unsafe { __libc_current_sigrtmax() } + } + + pub fn SIGRTMIN() -> c_int { + unsafe { __libc_current_sigrtmin() } + } + + pub const fn WIFSTOPPED(status: c_int) -> bool { + (status & 0xff) == 0x7f + } + + pub const fn WSTOPSIG(status: c_int) -> c_int { + (status >> 8) & 0xff + } + + pub const fn WIFCONTINUED(status: c_int) -> bool { + status == 0xffff + } + + pub const fn WIFSIGNALED(status: c_int) -> bool { + ((status & 0x7f) + 1) as i8 >= 2 + } + + pub const fn WTERMSIG(status: c_int) -> c_int { + status & 0x7f + } + + pub const fn WIFEXITED(status: c_int) -> bool { + (status & 0x7f) == 0 + } + + pub const fn WEXITSTATUS(status: c_int) -> c_int { + (status >> 8) & 0xff + } + + pub const fn WCOREDUMP(status: c_int) -> bool { + (status & 0x80) != 0 + } + + pub const fn W_EXITCODE(ret: c_int, sig: c_int) -> c_int { + (ret << 8) | sig + } + + pub const fn W_STOPCODE(sig: c_int) -> c_int { + (sig << 8) | 0x7f + } + + pub const fn QCMD(cmd: c_int, type_: c_int) -> c_int { + (cmd << 8) | (type_ & 0x00ff) + } + + pub const fn IPOPT_COPIED(o: u8) -> u8 { + o & IPOPT_COPY + } + + pub const fn IPOPT_CLASS(o: u8) -> u8 { + o & IPOPT_CLASS_MASK + } + + pub const fn IPOPT_NUMBER(o: u8) -> u8 { + o & IPOPT_NUMBER_MASK + } + + pub const fn IPTOS_ECN(x: u8) -> u8 { + x & crate::IPTOS_ECN_MASK + } + + #[allow(ellipsis_inclusive_range_patterns)] + pub const fn KERNEL_VERSION(a: u32, b: u32, c: u32) -> u32 { + ((a << 16) + (b << 8)) + if c > 255 { 255 } else { c } + } +} + +extern "C" { + #[doc(hidden)] + pub fn __libc_current_sigrtmax() -> c_int; + #[doc(hidden)] + pub fn __libc_current_sigrtmin() -> c_int; + + pub fn sem_destroy(sem: *mut sem_t) -> c_int; + pub fn sem_init(sem: *mut sem_t, pshared: c_int, value: c_uint) -> c_int; + pub fn fdatasync(fd: c_int) -> c_int; + #[cfg(not(target_os = "l4re"))] + pub fn mincore(addr: *mut c_void, len: size_t, vec: *mut c_uchar) -> c_int; + + #[cfg_attr(gnu_time_bits64, link_name = "__clock_getres64")] + #[cfg_attr(musl_redir_time64, link_name = "__clock_getres_time64")] + pub fn clock_getres(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; + #[cfg_attr( + any(gnu_time_bits64, musl_redir_time64), + link_name = "__clock_gettime64" + )] + pub fn clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; + #[cfg_attr( + any(gnu_time_bits64, musl_redir_time64), + link_name = "__clock_settime64" + )] + pub fn clock_settime(clk_id: crate::clockid_t, tp: *const crate::timespec) -> c_int; + #[cfg(not(target_os = "l4re"))] + pub fn clock_getcpuclockid(pid: crate::pid_t, clk_id: *mut crate::clockid_t) -> c_int; + + #[cfg_attr(gnu_time_bits64, link_name = "__getitimer64")] + #[cfg_attr(musl_redir_time64, link_name = "__getitimer_time64")] + pub fn getitimer(which: c_int, curr_value: *mut crate::itimerval) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__setitimer64")] + #[cfg_attr(musl_redir_time64, link_name = "__setitimer_time64")] + pub fn setitimer( + which: c_int, + new_value: *const crate::itimerval, + old_value: *mut crate::itimerval, + ) -> c_int; + + pub fn dirfd(dirp: *mut crate::DIR) -> c_int; + + pub fn memalign(align: size_t, size: size_t) -> *mut c_void; + pub fn setgroups(ngroups: size_t, ptr: *const crate::gid_t) -> c_int; + #[cfg(not(target_os = "l4re"))] + pub fn pipe2(fds: *mut c_int, flags: c_int) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "statfs64")] + pub fn statfs(path: *const c_char, buf: *mut statfs) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "fstatfs64")] + pub fn fstatfs(fd: c_int, buf: *mut statfs) -> c_int; + pub fn memrchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; + #[cfg_attr(gnu_file_offset_bits64, link_name = "posix_fadvise64")] + pub fn posix_fadvise(fd: c_int, offset: off_t, len: off_t, advise: c_int) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__futimens64")] + #[cfg_attr(musl_redir_time64, link_name = "__futimens_time64")] + #[cfg(not(target_os = "l4re"))] + pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__utimensat64")] + #[cfg_attr(musl_redir_time64, link_name = "__utimensat_time64")] + pub fn utimensat( + dirfd: c_int, + path: *const c_char, + times: *const crate::timespec, + flag: c_int, + ) -> c_int; + #[cfg(not(target_os = "l4re"))] + pub fn duplocale(base: crate::locale_t) -> crate::locale_t; + pub fn freelocale(loc: crate::locale_t); + pub fn newlocale(mask: c_int, locale: *const c_char, base: crate::locale_t) -> crate::locale_t; + pub fn uselocale(loc: crate::locale_t) -> crate::locale_t; + #[cfg(not(target_os = "l4re"))] + pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; + + #[cfg(not(target_os = "l4re"))] + pub fn ptsname_r(fd: c_int, buf: *mut c_char, buflen: size_t) -> c_int; + pub fn clearenv() -> c_int; + #[cfg(not(target_os = "l4re"))] + pub fn waitid( + idtype: idtype_t, + id: id_t, + infop: *mut crate::siginfo_t, + options: c_int, + ) -> c_int; + #[cfg(not(target_os = "l4re"))] + pub fn getresuid( + ruid: *mut crate::uid_t, + euid: *mut crate::uid_t, + suid: *mut crate::uid_t, + ) -> c_int; + #[cfg(not(target_os = "l4re"))] + pub fn getresgid( + rgid: *mut crate::gid_t, + egid: *mut crate::gid_t, + sgid: *mut crate::gid_t, + ) -> c_int; + #[cfg(not(target_os = "l4re"))] + pub fn acct(filename: *const c_char) -> c_int; + #[cfg(not(target_os = "l4re"))] + pub fn brk(addr: *mut c_void) -> c_int; + #[cfg(not(target_os = "l4re"))] + pub fn sbrk(increment: intptr_t) -> *mut c_void; + #[deprecated( + since = "0.2.66", + note = "causes memory corruption, see rust-lang/libc#1596" + )] + pub fn vfork() -> crate::pid_t; + #[cfg(not(target_os = "l4re"))] + pub fn setresgid(rgid: crate::gid_t, egid: crate::gid_t, sgid: crate::gid_t) -> c_int; + #[cfg(not(target_os = "l4re"))] + pub fn setresuid(ruid: crate::uid_t, euid: crate::uid_t, suid: crate::uid_t) -> c_int; + #[cfg_attr(any(gnu_time_bits64, musl_redir_time64), link_name = "__wait4_time64")] + #[cfg(not(target_os = "l4re"))] + pub fn wait4( + pid: crate::pid_t, + status: *mut c_int, + options: c_int, + rusage: *mut crate::rusage, + ) -> crate::pid_t; + #[cfg(not(target_os = "l4re"))] + pub fn login_tty(fd: c_int) -> c_int; + + // DIFF(main): changed to `*const *mut` in e77f551de9 + #[cfg(not(target_os = "l4re"))] + pub fn execvpe( + file: *const c_char, + argv: *const *const c_char, + envp: *const *const c_char, + ) -> c_int; + #[cfg(not(target_os = "l4re"))] + pub fn fexecve(fd: c_int, argv: *const *const c_char, envp: *const *const c_char) -> c_int; + #[cfg(not(target_os = "l4re"))] + pub fn getifaddrs(ifap: *mut *mut crate::ifaddrs) -> c_int; + #[cfg(not(target_os = "l4re"))] + pub fn freeifaddrs(ifa: *mut crate::ifaddrs); + pub fn bind( + socket: c_int, + address: *const crate::sockaddr, + address_len: crate::socklen_t, + ) -> c_int; + + pub fn writev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; + pub fn readv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; + + #[cfg_attr(gnu_time_bits64, link_name = "__sendmsg64")] + pub fn sendmsg(fd: c_int, msg: *const crate::msghdr, flags: c_int) -> ssize_t; + #[cfg_attr(gnu_time_bits64, link_name = "__recvmsg64")] + pub fn recvmsg(fd: c_int, msg: *mut crate::msghdr, flags: c_int) -> ssize_t; + pub fn uname(buf: *mut crate::utsname) -> c_int; + + pub fn strchrnul(s: *const c_char, c: c_int) -> *mut c_char; + + pub fn strftime( + s: *mut c_char, + max: size_t, + format: *const c_char, + tm: *const crate::tm, + ) -> size_t; + pub fn strftime_l( + s: *mut c_char, + max: size_t, + format: *const c_char, + tm: *const crate::tm, + locale: crate::locale_t, + ) -> size_t; + pub fn strptime(s: *const c_char, format: *const c_char, tm: *mut crate::tm) -> *mut c_char; + + #[cfg_attr(gnu_file_offset_bits64, link_name = "mkostemp64")] + pub fn mkostemp(template: *mut c_char, flags: c_int) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "mkostemps64")] + #[cfg(not(target_os = "l4re"))] + pub fn mkostemps(template: *mut c_char, suffixlen: c_int, flags: c_int) -> c_int; + + #[cfg(not(target_os = "l4re"))] + pub fn getdomainname(name: *mut c_char, len: size_t) -> c_int; + #[cfg(not(target_os = "l4re"))] + pub fn setdomainname(name: *const c_char, len: size_t) -> c_int; + + pub fn if_nameindex() -> *mut if_nameindex; + pub fn if_freenameindex(ptr: *mut if_nameindex); + + pub fn getpwnam_r( + name: *const c_char, + pwd: *mut passwd, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut passwd, + ) -> c_int; + pub fn getpwuid_r( + uid: crate::uid_t, + pwd: *mut passwd, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut passwd, + ) -> c_int; +} + +// LFS64 extensions +// +// * musl and Emscripten has 64-bit versions only so aliases the LFS64 symbols to the standard ones +// * ulibc doesn't have preadv64/pwritev64 +cfg_if! { + if #[cfg(not(any( + target_env = "musl", + target_env = "ohos", + target_os = "emscripten", + )))] { + extern "C" { + pub fn fstatfs64(fd: c_int, buf: *mut statfs64) -> c_int; + pub fn statvfs64(path: *const c_char, buf: *mut statvfs64) -> c_int; + pub fn fstatvfs64(fd: c_int, buf: *mut statvfs64) -> c_int; + pub fn statfs64(path: *const c_char, buf: *mut statfs64) -> c_int; + pub fn creat64(path: *const c_char, mode: mode_t) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__fstat64_time64")] + pub fn fstat64(fildes: c_int, buf: *mut stat64) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__fstatat64_time64")] + #[cfg(not(target_os = "l4re"))] + pub fn fstatat64( + dirfd: c_int, + pathname: *const c_char, + buf: *mut stat64, + flags: c_int, + ) -> c_int; + pub fn ftruncate64(fd: c_int, length: off64_t) -> c_int; + pub fn lseek64(fd: c_int, offset: off64_t, whence: c_int) -> off64_t; + #[cfg_attr(gnu_time_bits64, link_name = "__lstat64_time64")] + #[cfg(not(target_os = "l4re"))] + pub fn lstat64(path: *const c_char, buf: *mut stat64) -> c_int; + pub fn mmap64( + addr: *mut c_void, + len: size_t, + prot: c_int, + flags: c_int, + fd: c_int, + offset: off64_t, + ) -> *mut c_void; + pub fn open64(path: *const c_char, oflag: c_int, ...) -> c_int; + pub fn openat64(fd: c_int, path: *const c_char, oflag: c_int, ...) -> c_int; + pub fn posix_fadvise64( + fd: c_int, + offset: off64_t, + len: off64_t, + advise: c_int, + ) -> c_int; + pub fn pread64(fd: c_int, buf: *mut c_void, count: size_t, offset: off64_t) -> ssize_t; + pub fn pwrite64( + fd: c_int, + buf: *const c_void, + count: size_t, + offset: off64_t, + ) -> ssize_t; + pub fn readdir64(dirp: *mut crate::DIR) -> *mut crate::dirent64; + pub fn readdir64_r( + dirp: *mut crate::DIR, + entry: *mut crate::dirent64, + result: *mut *mut crate::dirent64, + ) -> c_int; + #[cfg_attr(gnu_time_bits64, link_name = "__stat64_time64")] + #[cfg(not(target_os = "l4re"))] + pub fn stat64(path: *const c_char, buf: *mut stat64) -> c_int; + pub fn truncate64(path: *const c_char, length: off64_t) -> c_int; + } + } +} + +cfg_if! { + if #[cfg(not(any( + target_env = "uclibc", + target_env = "musl", + target_env = "ohos", + target_os = "emscripten", + )))] { + extern "C" { + pub fn preadv64( + fd: c_int, + iov: *const crate::iovec, + iovcnt: c_int, + offset: off64_t, + ) -> ssize_t; + pub fn pwritev64( + fd: c_int, + iov: *const crate::iovec, + iovcnt: c_int, + offset: off64_t, + ) -> ssize_t; + } + } +} + +cfg_if! { + if #[cfg(not(target_env = "uclibc"))] { + extern "C" { + // uclibc has separate non-const version of this function + pub fn forkpty( + amaster: *mut c_int, + name: *mut c_char, + termp: *const termios, + winp: *const crate::winsize, + ) -> crate::pid_t; + // uclibc has separate non-const version of this function + pub fn openpty( + amaster: *mut c_int, + aslave: *mut c_int, + name: *mut c_char, + termp: *const termios, + winp: *const crate::winsize, + ) -> c_int; + } + } +} + +// The statx syscall, available on some libcs. +cfg_if! { + if #[cfg(any( + target_env = "gnu", + target_os = "android", + all(target_env = "musl", musl_v1_2_3) + ))] { + extern "C" { + pub fn statx( + dirfd: c_int, + pathname: *const c_char, + flags: c_int, + mask: c_uint, + statxbuf: *mut statx, + ) -> c_int; + } + } +} + +cfg_if! { + if #[cfg(target_os = "emscripten")] { + mod emscripten; + pub use self::emscripten::*; + } else if #[cfg(target_os = "linux")] { + mod linux; + pub use self::linux::*; + mod linux_l4re_shared; + pub use self::linux_l4re_shared::*; + } else if #[cfg(target_os = "l4re")] { + mod l4re; + pub use self::l4re::*; + mod linux_l4re_shared; + pub use self::linux_l4re_shared::*; + } else if #[cfg(target_os = "android")] { + mod android; + pub use self::android::*; + } else { + // Unknown target_os + } +} diff --git a/http/vendor/libc/src/unix/mod.rs b/http/vendor/libc/src/unix/mod.rs new file mode 100644 index 0000000..207c36b --- /dev/null +++ b/http/vendor/libc/src/unix/mod.rs @@ -0,0 +1,2500 @@ +//! Definitions found commonly among almost all Unix derivatives +//! +//! More functions and definitions can be found in the more specific modules +//! according to the platform in question. + +use crate::prelude::*; + +pub type intmax_t = i64; +pub type uintmax_t = u64; + +pub type size_t = usize; +pub type ptrdiff_t = isize; +pub type intptr_t = isize; +pub type uintptr_t = usize; +pub type ssize_t = isize; + +pub type pid_t = i32; +pub type in_addr_t = u32; +pub type in_port_t = u16; +pub type sighandler_t = size_t; +pub type cc_t = c_uchar; + +cfg_if! { + if #[cfg(any( + target_os = "espidf", + target_os = "horizon", + target_os = "vita" + ))] { + pub type uid_t = c_ushort; + pub type gid_t = c_ushort; + } else if #[cfg(target_os = "nto")] { + pub type uid_t = i32; + pub type gid_t = i32; + } else { + pub type uid_t = u32; + pub type gid_t = u32; + } +} + +extern_ty! { + pub enum DIR {} +} + +#[cfg(not(target_os = "nuttx"))] +pub type locale_t = *mut c_void; + +s! { + pub struct group { + pub gr_name: *mut c_char, + pub gr_passwd: *mut c_char, + pub gr_gid: crate::gid_t, + pub gr_mem: *mut *mut c_char, + } + + pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } + + #[derive(Default)] + pub struct timeval { + pub tv_sec: time_t, + #[cfg(not(gnu_time_bits64))] + pub tv_usec: crate::suseconds_t, + // For 64 bit time on 32 bit linux glibc, suseconds_t is still + // a 32 bit type. Use __suseconds64_t instead + #[cfg(gnu_time_bits64)] + pub tv_usec: __suseconds64_t, + } + + // linux x32 compatibility + // See https://sourceware.org/bugzilla/show_bug.cgi?id=16437 + #[derive(Default)] + #[cfg(not(target_env = "gnu"))] + pub struct timespec { + pub tv_sec: time_t, + #[cfg(all(musl32_time64, target_endian = "big"))] + __pad0: Padding, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + pub tv_nsec: i64, + #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] + pub tv_nsec: c_long, + #[cfg(all(musl32_time64, target_endian = "little"))] + __pad0: Padding, + } + + pub struct rlimit { + pub rlim_cur: rlim_t, + pub rlim_max: rlim_t, + } + + pub struct rusage { + pub ru_utime: timeval, + pub ru_stime: timeval, + pub ru_maxrss: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad1: Padding, + pub ru_ixrss: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad2: Padding, + pub ru_idrss: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad3: Padding, + pub ru_isrss: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad4: Padding, + pub ru_minflt: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad5: Padding, + pub ru_majflt: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad6: Padding, + pub ru_nswap: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad7: Padding, + pub ru_inblock: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad8: Padding, + pub ru_oublock: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad9: Padding, + pub ru_msgsnd: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad10: Padding, + pub ru_msgrcv: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad11: Padding, + pub ru_nsignals: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad12: Padding, + pub ru_nvcsw: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad13: Padding, + pub ru_nivcsw: c_long, + #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] + __pad14: Padding, + + #[cfg(any(target_env = "musl", target_env = "ohos", target_os = "emscripten"))] + __reserved: Padding<[c_long; 16]>, + } + + #[cfg(not(target_os = "nuttx"))] + pub struct ipv6_mreq { + pub ipv6mr_multiaddr: in6_addr, + #[cfg(target_os = "android")] + pub ipv6mr_interface: c_int, + #[cfg(not(target_os = "android"))] + pub ipv6mr_interface: c_uint, + } + + #[cfg(all(not(target_os = "cygwin"), not(target_os = "horizon")))] + pub struct hostent { + pub h_name: *mut c_char, + pub h_aliases: *mut *mut c_char, + pub h_addrtype: c_int, + pub h_length: c_int, + pub h_addr_list: *mut *mut c_char, + } + + pub struct iovec { + pub iov_base: *mut c_void, + pub iov_len: size_t, + } + + #[cfg(not(target_os = "horizon"))] + pub struct pollfd { + pub fd: c_int, + pub events: c_short, + pub revents: c_short, + } + + pub struct winsize { + pub ws_row: c_ushort, + pub ws_col: c_ushort, + pub ws_xpixel: c_ushort, + pub ws_ypixel: c_ushort, + } + + #[cfg(not(target_os = "cygwin"))] + pub struct linger { + pub l_onoff: c_int, + pub l_linger: c_int, + } + + pub struct sigval { + // Actually a union of an int and a void* + pub sival_ptr: *mut c_void, + } + + // + pub struct itimerval { + pub it_interval: crate::timeval, + pub it_value: crate::timeval, + } + + // + pub struct tms { + pub tms_utime: crate::clock_t, + pub tms_stime: crate::clock_t, + pub tms_cutime: crate::clock_t, + pub tms_cstime: crate::clock_t, + } + + pub struct servent { + pub s_name: *mut c_char, + pub s_aliases: *mut *mut c_char, + #[cfg(target_os = "cygwin")] + pub s_port: c_short, + #[cfg(not(target_os = "cygwin"))] + pub s_port: c_int, + pub s_proto: *mut c_char, + } + + pub struct protoent { + pub p_name: *mut c_char, + pub p_aliases: *mut *mut c_char, + #[cfg(not(target_os = "cygwin"))] + pub p_proto: c_int, + #[cfg(target_os = "cygwin")] + pub p_proto: c_short, + } + + #[repr(align(4))] + pub struct in6_addr { + pub s6_addr: [u8; 16], + } +} + +pub const INT_MIN: c_int = -2147483648; +pub const INT_MAX: c_int = 2147483647; + +pub const SIG_DFL: sighandler_t = 0 as sighandler_t; +pub const SIG_IGN: sighandler_t = 1 as sighandler_t; +pub const SIG_ERR: sighandler_t = !0 as sighandler_t; + +cfg_if! { + if #[cfg(all( + not(target_os = "nto"), + not(target_os = "aix"), + not(target_os = "espidf") + ))] { + pub const DT_UNKNOWN: u8 = 0; + pub const DT_FIFO: u8 = 1; + pub const DT_CHR: u8 = 2; + pub const DT_DIR: u8 = 4; + pub const DT_BLK: u8 = 6; + pub const DT_REG: u8 = 8; + pub const DT_LNK: u8 = 10; + pub const DT_SOCK: u8 = 12; + } +} +cfg_if! { + if #[cfg(not(target_os = "redox"))] { + pub const FD_CLOEXEC: c_int = 0x1; + } +} + +cfg_if! { + if #[cfg(not(any(target_os = "nto", target_os = "l4re")))] { + pub const USRQUOTA: c_int = 0; + pub const GRPQUOTA: c_int = 1; + } +} +pub const SIGIOT: c_int = 6; + +pub const S_ISUID: mode_t = 0o4000; +pub const S_ISGID: mode_t = 0o2000; +pub const S_ISVTX: mode_t = 0o1000; + +cfg_if! { + if #[cfg(not(any( + target_os = "haiku", + target_os = "illumos", + target_os = "solaris", + target_os = "cygwin" + )))] { + pub const IF_NAMESIZE: size_t = 16; + pub const IFNAMSIZ: size_t = IF_NAMESIZE; + } +} + +pub const LOG_EMERG: c_int = 0; +pub const LOG_ALERT: c_int = 1; +pub const LOG_CRIT: c_int = 2; +pub const LOG_ERR: c_int = 3; +pub const LOG_WARNING: c_int = 4; +pub const LOG_NOTICE: c_int = 5; +pub const LOG_INFO: c_int = 6; +pub const LOG_DEBUG: c_int = 7; + +pub const LOG_KERN: c_int = 0; +pub const LOG_USER: c_int = 1 << 3; +pub const LOG_MAIL: c_int = 2 << 3; +pub const LOG_DAEMON: c_int = 3 << 3; +pub const LOG_AUTH: c_int = 4 << 3; +pub const LOG_SYSLOG: c_int = 5 << 3; +pub const LOG_LPR: c_int = 6 << 3; +pub const LOG_NEWS: c_int = 7 << 3; +pub const LOG_UUCP: c_int = 8 << 3; +pub const LOG_LOCAL0: c_int = 16 << 3; +pub const LOG_LOCAL1: c_int = 17 << 3; +pub const LOG_LOCAL2: c_int = 18 << 3; +pub const LOG_LOCAL3: c_int = 19 << 3; +pub const LOG_LOCAL4: c_int = 20 << 3; +pub const LOG_LOCAL5: c_int = 21 << 3; +pub const LOG_LOCAL6: c_int = 22 << 3; +pub const LOG_LOCAL7: c_int = 23 << 3; + +cfg_if! { + if #[cfg(not(target_os = "haiku"))] { + pub const LOG_PID: c_int = 0x01; + pub const LOG_CONS: c_int = 0x02; + pub const LOG_ODELAY: c_int = 0x04; + pub const LOG_NDELAY: c_int = 0x08; + pub const LOG_NOWAIT: c_int = 0x10; + } +} +pub const LOG_PRIMASK: c_int = 7; +pub const LOG_FACMASK: c_int = 0x3f8; + +cfg_if! { + if #[cfg(not(target_os = "nto"))] { + pub const PRIO_MIN: c_int = -20; + pub const PRIO_MAX: c_int = 20; + } +} +pub const IPPROTO_ICMP: c_int = 1; +pub const IPPROTO_ICMPV6: c_int = 58; +pub const IPPROTO_TCP: c_int = 6; +pub const IPPROTO_UDP: c_int = 17; +pub const IPPROTO_IP: c_int = 0; +pub const IPPROTO_IPV6: c_int = 41; + +pub const INADDR_LOOPBACK: in_addr_t = 2130706433; +pub const INADDR_ANY: in_addr_t = 0; +pub const INADDR_BROADCAST: in_addr_t = 4294967295; +pub const INADDR_NONE: in_addr_t = 4294967295; + +pub const IN6ADDR_LOOPBACK_INIT: in6_addr = in6_addr { + s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], +}; + +pub const IN6ADDR_ANY_INIT: in6_addr = in6_addr { + s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], +}; + +pub const ARPOP_REQUEST: u16 = 1; +pub const ARPOP_REPLY: u16 = 2; + +pub const ATF_COM: c_int = 0x02; +pub const ATF_PERM: c_int = 0x04; +pub const ATF_PUBL: c_int = 0x08; +pub const ATF_USETRAILERS: c_int = 0x10; + +cfg_if! { + if #[cfg(any(target_os = "nto", target_os = "aix"))] { + pub const FNM_PERIOD: c_int = 1 << 1; + } else { + pub const FNM_PERIOD: c_int = 1 << 2; + } +} +pub const FNM_NOMATCH: c_int = 1; + +cfg_if! { + if #[cfg(any( + target_os = "illumos", + target_os = "solaris", + target_os = "netbsd" + ))] { + pub const FNM_CASEFOLD: c_int = 1 << 3; + } else if #[cfg(not(target_os = "aix"))] { + pub const FNM_CASEFOLD: c_int = 1 << 4; + } +} + +cfg_if! { + if #[cfg(any( + target_os = "macos", + target_os = "freebsd", + target_os = "android", + target_os = "openbsd", + target_os = "cygwin", + target_os = "netbsd", + ))] { + pub const FNM_PATHNAME: c_int = 1 << 1; + } else { + pub const FNM_PATHNAME: c_int = 1 << 0; + } +} + +cfg_if! { + if #[cfg(any( + target_os = "macos", + target_os = "freebsd", + target_os = "android", + target_os = "openbsd", + target_os = "netbsd", + target_os = "cygwin", + ))] { + pub const FNM_NOESCAPE: c_int = 1 << 0; + } else if #[cfg(target_os = "nto")] { + pub const FNM_NOESCAPE: c_int = 1 << 2; + } else if #[cfg(target_os = "aix")] { + pub const FNM_NOESCAPE: c_int = 1 << 3; + } else { + pub const FNM_NOESCAPE: c_int = 1 << 1; + } +} + +extern "C" { + pub static in6addr_loopback: in6_addr; + pub static in6addr_any: in6_addr; +} + +cfg_if! { + if #[cfg(any( + target_os = "l4re", + target_os = "espidf", + target_os = "nuttx" + ))] { + // required libraries are linked externally for these platforms: + // * L4Re + // * ESP-IDF + // * NuttX + } else if #[cfg(feature = "std")] { + // cargo build, don't pull in anything extra as the std dep + // already pulls in all libs. + } else if #[cfg(all( + any( + all( + target_os = "linux", + any(target_env = "gnu", target_env = "uclibc") + ), + target_os = "cygwin" + ), + feature = "rustc-dep-of-std" + ))] { + #[link( + name = "util", + kind = "static", + modifiers = "-bundle", + cfg(target_feature = "crt-static") + )] + #[link( + name = "rt", + kind = "static", + modifiers = "-bundle", + cfg(target_feature = "crt-static") + )] + #[link( + name = "pthread", + kind = "static", + modifiers = "-bundle", + cfg(target_feature = "crt-static") + )] + #[link( + name = "m", + kind = "static", + modifiers = "-bundle", + cfg(target_feature = "crt-static") + )] + #[link( + name = "dl", + kind = "static", + modifiers = "-bundle", + cfg(target_feature = "crt-static") + )] + #[link( + name = "c", + kind = "static", + modifiers = "-bundle", + cfg(target_feature = "crt-static") + )] + #[link( + name = "gcc_eh", + kind = "static", + modifiers = "-bundle", + cfg(target_feature = "crt-static") + )] + #[link( + name = "gcc", + kind = "static", + modifiers = "-bundle", + cfg(target_feature = "crt-static") + )] + #[link( + name = "c", + kind = "static", + modifiers = "-bundle", + cfg(target_feature = "crt-static") + )] + #[link(name = "util", cfg(not(target_feature = "crt-static")))] + #[link(name = "rt", cfg(not(target_feature = "crt-static")))] + #[link(name = "pthread", cfg(not(target_feature = "crt-static")))] + #[link(name = "m", cfg(not(target_feature = "crt-static")))] + #[link(name = "dl", cfg(not(target_feature = "crt-static")))] + #[link(name = "c", cfg(not(target_feature = "crt-static")))] + extern "C" {} + } else if #[cfg(any(target_env = "musl", target_env = "ohos"))] { + #[cfg_attr( + feature = "rustc-dep-of-std", + link( + name = "c", + kind = "static", + modifiers = "-bundle", + cfg(target_feature = "crt-static") + ) + )] + #[cfg_attr( + feature = "rustc-dep-of-std", + link(name = "c", cfg(not(target_feature = "crt-static"))) + )] + extern "C" {} + } else if #[cfg(target_os = "emscripten")] { + // Don't pass -lc to Emscripten, it breaks. See: + // https://github.com/emscripten-core/emscripten/issues/22758 + } else if #[cfg(all(target_os = "android", feature = "rustc-dep-of-std"))] { + #[link( + name = "c", + kind = "static", + modifiers = "-bundle", + cfg(target_feature = "crt-static") + )] + #[link( + name = "m", + kind = "static", + modifiers = "-bundle", + cfg(target_feature = "crt-static") + )] + #[link(name = "m", cfg(not(target_feature = "crt-static")))] + #[link(name = "c", cfg(not(target_feature = "crt-static")))] + extern "C" {} + } else if #[cfg(any( + target_os = "macos", + target_os = "ios", + target_os = "tvos", + target_os = "watchos", + target_os = "visionos", + target_os = "android", + target_os = "openbsd", + target_os = "nto", + ))] { + #[link(name = "c")] + #[link(name = "m")] + extern "C" {} + } else if #[cfg(target_os = "haiku")] { + #[link(name = "root")] + #[link(name = "network")] + extern "C" {} + } else if #[cfg(target_env = "newlib")] { + #[link(name = "c")] + #[link(name = "m")] + extern "C" {} + } else if #[cfg(target_env = "illumos")] { + #[link(name = "c")] + #[link(name = "m")] + extern "C" {} + } else if #[cfg(target_os = "redox")] { + #[cfg_attr( + feature = "rustc-dep-of-std", + link( + name = "c", + kind = "static", + modifiers = "-bundle", + cfg(target_feature = "crt-static") + ) + )] + #[cfg_attr( + feature = "rustc-dep-of-std", + link(name = "c", cfg(not(target_feature = "crt-static"))) + )] + extern "C" {} + } else if #[cfg(target_os = "aix")] { + #[link(name = "c")] + #[link(name = "m")] + #[link(name = "bsd")] + #[link(name = "pthread")] + extern "C" {} + } else { + #[link(name = "c")] + #[link(name = "m")] + #[link(name = "rt")] + #[link(name = "pthread")] + extern "C" {} + } +} + +cfg_if! { + if #[cfg(not(all(target_os = "linux", target_env = "gnu")))] { + extern_ty! { + pub enum fpos_t {} // FIXME(unix): fill this out with a struct + } + } +} + +extern_ty! { + pub enum FILE {} +} + +extern "C" { + pub fn isalnum(c: c_int) -> c_int; + pub fn isalpha(c: c_int) -> c_int; + pub fn iscntrl(c: c_int) -> c_int; + pub fn isdigit(c: c_int) -> c_int; + pub fn isgraph(c: c_int) -> c_int; + pub fn islower(c: c_int) -> c_int; + pub fn isprint(c: c_int) -> c_int; + pub fn ispunct(c: c_int) -> c_int; + pub fn isspace(c: c_int) -> c_int; + pub fn isupper(c: c_int) -> c_int; + pub fn isxdigit(c: c_int) -> c_int; + pub fn isblank(c: c_int) -> c_int; + pub fn tolower(c: c_int) -> c_int; + pub fn toupper(c: c_int) -> c_int; + pub fn qsort( + base: *mut c_void, + num: size_t, + size: size_t, + compar: Option c_int>, + ); + pub fn bsearch( + key: *const c_void, + base: *const c_void, + num: size_t, + size: size_t, + compar: Option c_int>, + ) -> *mut c_void; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "fopen$UNIX2003" + )] + #[cfg_attr(gnu_file_offset_bits64, link_name = "fopen64")] + pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "freopen$UNIX2003" + )] + #[cfg_attr(gnu_file_offset_bits64, link_name = "freopen64")] + pub fn freopen(filename: *const c_char, mode: *const c_char, file: *mut FILE) -> *mut FILE; + + pub fn fflush(file: *mut FILE) -> c_int; + pub fn fclose(file: *mut FILE) -> c_int; + pub fn remove(filename: *const c_char) -> c_int; + pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "tmpfile64")] + pub fn tmpfile() -> *mut FILE; + pub fn setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int, size: size_t) -> c_int; + pub fn setbuf(stream: *mut FILE, buf: *mut c_char); + pub fn getchar() -> c_int; + pub fn putchar(c: c_int) -> c_int; + pub fn fgetc(stream: *mut FILE) -> c_int; + pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char; + pub fn fputc(c: c_int, stream: *mut FILE) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "fputs$UNIX2003" + )] + pub fn fputs(s: *const c_char, stream: *mut FILE) -> c_int; + pub fn puts(s: *const c_char) -> c_int; + pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int; + pub fn fread(ptr: *mut c_void, size: size_t, nobj: size_t, stream: *mut FILE) -> size_t; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "fwrite$UNIX2003" + )] + pub fn fwrite(ptr: *const c_void, size: size_t, nobj: size_t, stream: *mut FILE) -> size_t; + pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int; + pub fn ftell(stream: *mut FILE) -> c_long; + pub fn rewind(stream: *mut FILE); + #[cfg_attr(target_os = "netbsd", link_name = "__fgetpos50")] + #[cfg_attr(gnu_file_offset_bits64, link_name = "fgetpos64")] + pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__fsetpos50")] + #[cfg_attr(gnu_file_offset_bits64, link_name = "fsetpos64")] + pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int; + pub fn feof(stream: *mut FILE) -> c_int; + pub fn ferror(stream: *mut FILE) -> c_int; + pub fn clearerr(stream: *mut FILE); + pub fn perror(s: *const c_char); + pub fn atof(s: *const c_char) -> c_double; + pub fn atoi(s: *const c_char) -> c_int; + pub fn atol(s: *const c_char) -> c_long; + pub fn atoll(s: *const c_char) -> c_longlong; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "strtod$UNIX2003" + )] + pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double; + pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float; + pub fn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long; + pub fn strtoll(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_longlong; + pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong; + pub fn strtoull(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulonglong; + #[cfg_attr(target_os = "aix", link_name = "vec_calloc")] + pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; + #[cfg_attr(target_os = "aix", link_name = "vec_malloc")] + pub fn malloc(size: size_t) -> *mut c_void; + pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; + pub fn free(p: *mut c_void); + pub fn abort() -> !; + pub fn exit(status: c_int) -> !; + pub fn _exit(status: c_int) -> !; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "system$UNIX2003" + )] + pub fn system(s: *const c_char) -> c_int; + pub fn getenv(s: *const c_char) -> *mut c_char; + + pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char; + pub fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char; + pub fn stpcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char; + pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char; + pub fn strncat(s: *mut c_char, ct: *const c_char, n: size_t) -> *mut c_char; + pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int; + pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strdup(cs: *const c_char) -> *mut c_char; + pub fn strndup(cs: *const c_char, n: size_t) -> *mut c_char; + pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strcasecmp(s1: *const c_char, s2: *const c_char) -> c_int; + pub fn strncasecmp(s1: *const c_char, s2: *const c_char, n: size_t) -> c_int; + pub fn strlen(cs: *const c_char) -> size_t; + pub fn strnlen(cs: *const c_char, maxlen: size_t) -> size_t; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "strerror$UNIX2003" + )] + pub fn strerror(n: c_int) -> *mut c_char; + pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char; + pub fn strtok_r(s: *mut c_char, t: *const c_char, p: *mut *mut c_char) -> *mut c_char; + pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t; + pub fn strsignal(sig: c_int) -> *mut c_char; + pub fn wcslen(buf: *const wchar_t) -> size_t; + pub fn wcstombs(dest: *mut c_char, src: *const wchar_t, n: size_t) -> size_t; + + pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; + pub fn wmemchr(cx: *const wchar_t, c: wchar_t, n: size_t) -> *mut wchar_t; + pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int; + pub fn memcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; + pub fn memmove(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; + pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void; + pub fn memccpy(dest: *mut c_void, src: *const c_void, c: c_int, n: size_t) -> *mut c_void; +} + +extern "C" { + #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam50")] + pub fn getpwnam(name: *const c_char) -> *mut passwd; + #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid50")] + pub fn getpwuid(uid: crate::uid_t) -> *mut passwd; + + pub fn fprintf(stream: *mut crate::FILE, format: *const c_char, ...) -> c_int; + pub fn printf(format: *const c_char, ...) -> c_int; + pub fn snprintf(s: *mut c_char, n: size_t, format: *const c_char, ...) -> c_int; + pub fn sprintf(s: *mut c_char, format: *const c_char, ...) -> c_int; + #[cfg_attr( + all(target_os = "linux", not(target_env = "uclibc")), + link_name = "__isoc99_fscanf" + )] + pub fn fscanf(stream: *mut crate::FILE, format: *const c_char, ...) -> c_int; + #[cfg_attr( + all(target_os = "linux", not(target_env = "uclibc")), + link_name = "__isoc99_scanf" + )] + pub fn scanf(format: *const c_char, ...) -> c_int; + #[cfg_attr( + all(target_os = "linux", not(target_env = "uclibc")), + link_name = "__isoc99_sscanf" + )] + pub fn sscanf(s: *const c_char, format: *const c_char, ...) -> c_int; + pub fn getchar_unlocked() -> c_int; + pub fn putchar_unlocked(c: c_int) -> c_int; + + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] + #[cfg_attr(target_os = "netbsd", link_name = "__socket30")] + #[cfg_attr(target_os = "illumos", link_name = "__xnet_socket")] + #[cfg_attr(target_os = "solaris", link_name = "__xnet7_socket")] + #[cfg_attr(target_os = "espidf", link_name = "lwip_socket")] + pub fn socket(domain: c_int, ty: c_int, protocol: c_int) -> c_int; + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "connect$UNIX2003" + )] + #[cfg_attr( + any(target_os = "illumos", target_os = "solaris"), + link_name = "__xnet_connect" + )] + #[cfg_attr(target_os = "espidf", link_name = "lwip_connect")] + pub fn connect(socket: c_int, address: *const sockaddr, len: socklen_t) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "listen$UNIX2003" + )] + #[cfg_attr(target_os = "espidf", link_name = "lwip_listen")] + pub fn listen(socket: c_int, backlog: c_int) -> c_int; + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "accept$UNIX2003" + )] + #[cfg_attr(target_os = "espidf", link_name = "lwip_accept")] + #[cfg_attr(target_os = "aix", link_name = "naccept")] + pub fn accept(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t) -> c_int; + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "getpeername$UNIX2003" + )] + #[cfg_attr(target_os = "espidf", link_name = "lwip_getpeername")] + #[cfg_attr(target_os = "aix", link_name = "ngetpeername")] + pub fn getpeername(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t) + -> c_int; + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "getsockname$UNIX2003" + )] + #[cfg_attr(target_os = "espidf", link_name = "lwip_getsockname")] + #[cfg_attr(target_os = "aix", link_name = "ngetsockname")] + pub fn getsockname(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t) + -> c_int; + #[cfg_attr(target_os = "espidf", link_name = "lwip_setsockopt")] + #[cfg_attr(gnu_time_bits64, link_name = "__setsockopt64")] + pub fn setsockopt( + socket: c_int, + level: c_int, + name: c_int, + value: *const c_void, + option_len: socklen_t, + ) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "socketpair$UNIX2003" + )] + #[cfg_attr( + any(target_os = "illumos", target_os = "solaris"), + link_name = "__xnet_socketpair" + )] + pub fn socketpair( + domain: c_int, + type_: c_int, + protocol: c_int, + socket_vector: *mut c_int, + ) -> c_int; + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "sendto$UNIX2003" + )] + #[cfg_attr( + any(target_os = "illumos", target_os = "solaris"), + link_name = "__xnet_sendto" + )] + #[cfg_attr(target_os = "espidf", link_name = "lwip_sendto")] + pub fn sendto( + socket: c_int, + buf: *const c_void, + len: size_t, + flags: c_int, + addr: *const sockaddr, + addrlen: socklen_t, + ) -> ssize_t; + #[cfg_attr(target_os = "espidf", link_name = "lwip_shutdown")] + pub fn shutdown(socket: c_int, how: c_int) -> c_int; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "chmod$UNIX2003" + )] + pub fn chmod(path: *const c_char, mode: mode_t) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "fchmod$UNIX2003" + )] + pub fn fchmod(fd: c_int, mode: mode_t) -> c_int; + + #[cfg_attr( + all(target_os = "macos", not(target_arch = "aarch64")), + link_name = "fstat$INODE64" + )] + #[cfg_attr(target_os = "netbsd", link_name = "__fstat50")] + #[cfg_attr( + all(target_os = "freebsd", any(freebsd11, freebsd10)), + link_name = "fstat@FBSD_1.0" + )] + #[cfg_attr(gnu_time_bits64, link_name = "__fstat64_time64")] + #[cfg_attr( + all(not(gnu_time_bits64), gnu_file_offset_bits64), + link_name = "fstat64" + )] + #[cfg_attr(musl_redir_time64, link_name = "__fstat_time64")] + pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int; + + pub fn mkdir(path: *const c_char, mode: mode_t) -> c_int; + + #[cfg_attr( + all(target_os = "macos", not(target_arch = "aarch64")), + link_name = "stat$INODE64" + )] + #[cfg_attr(target_os = "netbsd", link_name = "__stat50")] + #[cfg_attr( + all(target_os = "freebsd", any(freebsd11, freebsd10)), + link_name = "stat@FBSD_1.0" + )] + #[cfg_attr(gnu_time_bits64, link_name = "__stat64_time64")] + #[cfg_attr( + all(not(gnu_time_bits64), gnu_file_offset_bits64), + link_name = "stat64" + )] + #[cfg_attr(musl_redir_time64, link_name = "__stat_time64")] + pub fn stat(path: *const c_char, buf: *mut stat) -> c_int; + + pub fn pclose(stream: *mut crate::FILE) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "fdopen$UNIX2003" + )] + pub fn fdopen(fd: c_int, mode: *const c_char) -> *mut crate::FILE; + pub fn fileno(stream: *mut crate::FILE) -> c_int; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "open$UNIX2003" + )] + #[cfg_attr(gnu_file_offset_bits64, link_name = "open64")] + pub fn open(path: *const c_char, oflag: c_int, ...) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "creat$UNIX2003" + )] + #[cfg_attr(gnu_file_offset_bits64, link_name = "creat64")] + pub fn creat(path: *const c_char, mode: mode_t) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "fcntl$UNIX2003" + )] + #[cfg_attr(gnu_time_bits64, link_name = "__fcntl_time64")] + #[cfg_attr( + all(not(gnu_time_bits64), gnu_file_offset_bits64), + link_name = "__fcntl_time64" + )] + pub fn fcntl(fd: c_int, cmd: c_int, ...) -> c_int; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86_64"), + link_name = "opendir$INODE64" + )] + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "opendir$INODE64$UNIX2003" + )] + #[cfg_attr(target_os = "netbsd", link_name = "__opendir30")] + pub fn opendir(dirname: *const c_char) -> *mut crate::DIR; + + #[cfg_attr( + all(target_os = "macos", not(target_arch = "aarch64")), + link_name = "readdir$INODE64" + )] + #[cfg_attr(target_os = "netbsd", link_name = "__readdir30")] + #[cfg_attr( + all(target_os = "freebsd", any(freebsd11, freebsd10)), + link_name = "readdir@FBSD_1.0" + )] + #[cfg_attr(gnu_file_offset_bits64, link_name = "readdir64")] + pub fn readdir(dirp: *mut crate::DIR) -> *mut crate::dirent; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "closedir$UNIX2003" + )] + pub fn closedir(dirp: *mut crate::DIR) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86_64"), + link_name = "rewinddir$INODE64" + )] + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "rewinddir$INODE64$UNIX2003" + )] + pub fn rewinddir(dirp: *mut crate::DIR); + + pub fn fchmodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, flags: c_int) -> c_int; + pub fn fchown(fd: c_int, owner: crate::uid_t, group: crate::gid_t) -> c_int; + #[cfg(not(target_os = "l4re"))] + pub fn fchownat( + dirfd: c_int, + pathname: *const c_char, + owner: crate::uid_t, + group: crate::gid_t, + flags: c_int, + ) -> c_int; + #[cfg_attr( + all(target_os = "macos", not(target_arch = "aarch64")), + link_name = "fstatat$INODE64" + )] + #[cfg_attr( + all(target_os = "freebsd", any(freebsd11, freebsd10)), + link_name = "fstatat@FBSD_1.1" + )] + #[cfg_attr(gnu_time_bits64, link_name = "__fstatat64_time64")] + #[cfg_attr( + all(not(gnu_time_bits64), gnu_file_offset_bits64), + link_name = "fstatat64" + )] + #[cfg(not(target_os = "l4re"))] + #[cfg_attr(musl_redir_time64, link_name = "__fstatat_time64")] + pub fn fstatat(dirfd: c_int, pathname: *const c_char, buf: *mut stat, flags: c_int) -> c_int; + #[cfg(not(target_os = "l4re"))] + pub fn linkat( + olddirfd: c_int, + oldpath: *const c_char, + newdirfd: c_int, + newpath: *const c_char, + flags: c_int, + ) -> c_int; + #[cfg(not(target_os = "l4re"))] + pub fn renameat( + olddirfd: c_int, + oldpath: *const c_char, + newdirfd: c_int, + newpath: *const c_char, + ) -> c_int; + #[cfg(not(target_os = "l4re"))] + pub fn symlinkat(target: *const c_char, newdirfd: c_int, linkpath: *const c_char) -> c_int; + #[cfg(not(target_os = "l4re"))] + pub fn unlinkat(dirfd: c_int, pathname: *const c_char, flags: c_int) -> c_int; + + pub fn access(path: *const c_char, amode: c_int) -> c_int; + pub fn alarm(seconds: c_uint) -> c_uint; + pub fn chdir(dir: *const c_char) -> c_int; + pub fn fchdir(dirfd: c_int) -> c_int; + pub fn chown(path: *const c_char, uid: uid_t, gid: gid_t) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "lchown$UNIX2003" + )] + pub fn lchown(path: *const c_char, uid: uid_t, gid: gid_t) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "close$NOCANCEL$UNIX2003" + )] + #[cfg_attr( + all(target_os = "macos", target_arch = "x86_64"), + link_name = "close$NOCANCEL" + )] + pub fn close(fd: c_int) -> c_int; + pub fn dup(fd: c_int) -> c_int; + pub fn dup2(src: c_int, dst: c_int) -> c_int; + + pub fn execl(path: *const c_char, arg0: *const c_char, ...) -> c_int; + pub fn execle(path: *const c_char, arg0: *const c_char, ...) -> c_int; + pub fn execlp(file: *const c_char, arg0: *const c_char, ...) -> c_int; + + // DIFF(main): changed to `*const *mut` in e77f551de9 + pub fn execv(prog: *const c_char, argv: *const *const c_char) -> c_int; + pub fn execve( + prog: *const c_char, + argv: *const *const c_char, + envp: *const *const c_char, + ) -> c_int; + pub fn execvp(c: *const c_char, argv: *const *const c_char) -> c_int; + + pub fn fork() -> pid_t; + pub fn fpathconf(filedes: c_int, name: c_int) -> c_long; + pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char; + pub fn getegid() -> gid_t; + pub fn geteuid() -> uid_t; + pub fn getgid() -> gid_t; + pub fn getgroups(ngroups_max: c_int, groups: *mut gid_t) -> c_int; + #[cfg_attr(target_os = "illumos", link_name = "getloginx")] + pub fn getlogin() -> *mut c_char; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "getopt$UNIX2003" + )] + pub fn getopt(argc: c_int, argv: *const *mut c_char, optstr: *const c_char) -> c_int; + pub fn getpgid(pid: pid_t) -> pid_t; + pub fn getpgrp() -> pid_t; + pub fn getpid() -> pid_t; + pub fn getppid() -> pid_t; + pub fn getuid() -> uid_t; + pub fn isatty(fd: c_int) -> c_int; + #[cfg_attr(target_os = "solaris", link_name = "__link_xpg4")] + pub fn link(src: *const c_char, dst: *const c_char) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "lseek64")] + pub fn lseek(fd: c_int, offset: off_t, whence: c_int) -> off_t; + pub fn pathconf(path: *const c_char, name: c_int) -> c_long; + pub fn pipe(fds: *mut c_int) -> c_int; + pub fn posix_memalign(memptr: *mut *mut c_void, align: size_t, size: size_t) -> c_int; + pub fn aligned_alloc(alignment: size_t, size: size_t) -> *mut c_void; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "read$UNIX2003" + )] + pub fn read(fd: c_int, buf: *mut c_void, count: size_t) -> ssize_t; + pub fn rmdir(path: *const c_char) -> c_int; + pub fn seteuid(uid: uid_t) -> c_int; + pub fn setegid(gid: gid_t) -> c_int; + pub fn setgid(gid: gid_t) -> c_int; + pub fn setpgid(pid: pid_t, pgid: pid_t) -> c_int; + pub fn setsid() -> pid_t; + pub fn setuid(uid: uid_t) -> c_int; + pub fn setreuid(ruid: uid_t, euid: uid_t) -> c_int; + pub fn setregid(rgid: gid_t, egid: gid_t) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "sleep$UNIX2003" + )] + pub fn sleep(secs: c_uint) -> c_uint; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "nanosleep$UNIX2003" + )] + #[cfg_attr(target_os = "netbsd", link_name = "__nanosleep50")] + #[cfg_attr(gnu_time_bits64, link_name = "__nanosleep64")] + #[cfg_attr(musl_redir_time64, link_name = "__nanosleep_time64")] + pub fn nanosleep(rqtp: *const timespec, rmtp: *mut timespec) -> c_int; + pub fn tcgetpgrp(fd: c_int) -> pid_t; + pub fn tcsetpgrp(fd: c_int, pgrp: crate::pid_t) -> c_int; + pub fn ttyname(fd: c_int) -> *mut c_char; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "ttyname_r$UNIX2003" + )] + #[cfg_attr( + any(target_os = "illumos", target_os = "solaris"), + link_name = "__posix_ttyname_r" + )] + pub fn ttyname_r(fd: c_int, buf: *mut c_char, buflen: size_t) -> c_int; + pub fn unlink(c: *const c_char) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "wait$UNIX2003" + )] + pub fn wait(status: *mut c_int) -> pid_t; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "waitpid$UNIX2003" + )] + pub fn waitpid(pid: pid_t, status: *mut c_int, options: c_int) -> pid_t; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "write$UNIX2003" + )] + pub fn write(fd: c_int, buf: *const c_void, count: size_t) -> ssize_t; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pread$UNIX2003" + )] + #[cfg_attr(gnu_file_offset_bits64, link_name = "pread64")] + pub fn pread(fd: c_int, buf: *mut c_void, count: size_t, offset: off_t) -> ssize_t; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pwrite$UNIX2003" + )] + #[cfg_attr(gnu_file_offset_bits64, link_name = "pwrite64")] + pub fn pwrite(fd: c_int, buf: *const c_void, count: size_t, offset: off_t) -> ssize_t; + pub fn umask(mask: mode_t) -> mode_t; + + #[cfg_attr(target_os = "netbsd", link_name = "__utime50")] + #[cfg_attr(any(gnu_time_bits64, musl_redir_time64), link_name = "__utime64")] + pub fn utime(file: *const c_char, buf: *const utimbuf) -> c_int; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "kill$UNIX2003" + )] + pub fn kill(pid: pid_t, sig: c_int) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "killpg$UNIX2003" + )] + pub fn killpg(pgrp: pid_t, sig: c_int) -> c_int; + + pub fn mlock(addr: *const c_void, len: size_t) -> c_int; + pub fn munlock(addr: *const c_void, len: size_t) -> c_int; + pub fn mlockall(flags: c_int) -> c_int; + pub fn munlockall() -> c_int; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "mmap$UNIX2003" + )] + #[cfg_attr(gnu_file_offset_bits64, link_name = "mmap64")] + pub fn mmap( + addr: *mut c_void, + len: size_t, + prot: c_int, + flags: c_int, + fd: c_int, + offset: off_t, + ) -> *mut c_void; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "munmap$UNIX2003" + )] + pub fn munmap(addr: *mut c_void, len: size_t) -> c_int; + + pub fn if_nametoindex(ifname: *const c_char) -> c_uint; + pub fn if_indextoname(ifindex: c_uint, ifname: *mut c_char) -> *mut c_char; + + #[cfg_attr( + all(target_os = "macos", not(target_arch = "aarch64")), + link_name = "lstat$INODE64" + )] + #[cfg_attr(target_os = "netbsd", link_name = "__lstat50")] + #[cfg_attr( + all(target_os = "freebsd", any(freebsd11, freebsd10)), + link_name = "lstat@FBSD_1.0" + )] + #[cfg_attr(gnu_time_bits64, link_name = "__lstat64_time64")] + #[cfg_attr( + all(not(gnu_time_bits64), gnu_file_offset_bits64), + link_name = "lstat64" + )] + #[cfg_attr(musl_redir_time64, link_name = "__lstat_time64")] + pub fn lstat(path: *const c_char, buf: *mut stat) -> c_int; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "fsync$UNIX2003" + )] + pub fn fsync(fd: c_int) -> c_int; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "setenv$UNIX2003" + )] + pub fn setenv(name: *const c_char, val: *const c_char, overwrite: c_int) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "unsetenv$UNIX2003" + )] + #[cfg_attr(target_os = "netbsd", link_name = "__unsetenv13")] + pub fn unsetenv(name: *const c_char) -> c_int; + + pub fn symlink(path1: *const c_char, path2: *const c_char) -> c_int; + + #[cfg_attr(gnu_file_offset_bits64, link_name = "truncate64")] + pub fn truncate(path: *const c_char, length: off_t) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "ftruncate64")] + pub fn ftruncate(fd: c_int, length: off_t) -> c_int; + + pub fn signal(signum: c_int, handler: sighandler_t) -> sighandler_t; + + #[cfg_attr(target_os = "netbsd", link_name = "__getrusage50")] + #[cfg_attr(gnu_time_bits64, link_name = "__getrusage64")] + #[cfg_attr(musl_redir_time64, link_name = "__getrusage_time64")] + pub fn getrusage(resource: c_int, usage: *mut rusage) -> c_int; + + #[cfg_attr( + any( + target_os = "macos", + target_os = "ios", + target_os = "tvos", + target_os = "watchos", + target_os = "visionos" + ), + link_name = "realpath$DARWIN_EXTSN" + )] + pub fn realpath(pathname: *const c_char, resolved: *mut c_char) -> *mut c_char; + + #[cfg_attr(target_os = "netbsd", link_name = "__times13")] + pub fn times(buf: *mut crate::tms) -> crate::clock_t; + + pub fn pthread_self() -> crate::pthread_t; + pub fn pthread_equal(t1: crate::pthread_t, t2: crate::pthread_t) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_join$UNIX2003" + )] + pub fn pthread_join(native: crate::pthread_t, value: *mut *mut c_void) -> c_int; + pub fn pthread_exit(value: *mut c_void) -> !; + pub fn pthread_attr_init(attr: *mut crate::pthread_attr_t) -> c_int; + pub fn pthread_attr_destroy(attr: *mut crate::pthread_attr_t) -> c_int; + pub fn pthread_attr_getstacksize( + attr: *const crate::pthread_attr_t, + stacksize: *mut size_t, + ) -> c_int; + pub fn pthread_attr_setstacksize(attr: *mut crate::pthread_attr_t, stack_size: size_t) + -> c_int; + pub fn pthread_attr_setdetachstate(attr: *mut crate::pthread_attr_t, state: c_int) -> c_int; + pub fn pthread_detach(thread: crate::pthread_t) -> c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__libc_thr_yield")] + pub fn sched_yield() -> c_int; + pub fn pthread_key_create( + key: *mut crate::pthread_key_t, + dtor: Option, + ) -> c_int; + pub fn pthread_key_delete(key: crate::pthread_key_t) -> c_int; + pub fn pthread_getspecific(key: crate::pthread_key_t) -> *mut c_void; + pub fn pthread_setspecific(key: crate::pthread_key_t, value: *const c_void) -> c_int; + pub fn pthread_mutex_init( + lock: *mut crate::pthread_mutex_t, + attr: *const crate::pthread_mutexattr_t, + ) -> c_int; + pub fn pthread_mutex_destroy(lock: *mut crate::pthread_mutex_t) -> c_int; + pub fn pthread_mutex_lock(lock: *mut crate::pthread_mutex_t) -> c_int; + pub fn pthread_mutex_trylock(lock: *mut crate::pthread_mutex_t) -> c_int; + pub fn pthread_mutex_unlock(lock: *mut crate::pthread_mutex_t) -> c_int; + + pub fn pthread_mutexattr_init(attr: *mut crate::pthread_mutexattr_t) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_mutexattr_destroy$UNIX2003" + )] + pub fn pthread_mutexattr_destroy(attr: *mut crate::pthread_mutexattr_t) -> c_int; + pub fn pthread_mutexattr_settype(attr: *mut crate::pthread_mutexattr_t, _type: c_int) -> c_int; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_cond_init$UNIX2003" + )] + pub fn pthread_cond_init( + cond: *mut crate::pthread_cond_t, + attr: *const crate::pthread_condattr_t, + ) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_cond_wait$UNIX2003" + )] + pub fn pthread_cond_wait( + cond: *mut crate::pthread_cond_t, + lock: *mut crate::pthread_mutex_t, + ) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_cond_timedwait$UNIX2003" + )] + #[cfg_attr(gnu_time_bits64, link_name = "__pthread_cond_timedwait64")] + #[cfg_attr(musl_redir_time64, link_name = "__pthread_cond_timedwait_time64")] + pub fn pthread_cond_timedwait( + cond: *mut crate::pthread_cond_t, + lock: *mut crate::pthread_mutex_t, + abstime: *const crate::timespec, + ) -> c_int; + pub fn pthread_cond_signal(cond: *mut crate::pthread_cond_t) -> c_int; + pub fn pthread_cond_broadcast(cond: *mut crate::pthread_cond_t) -> c_int; + pub fn pthread_cond_destroy(cond: *mut crate::pthread_cond_t) -> c_int; + pub fn pthread_condattr_init(attr: *mut crate::pthread_condattr_t) -> c_int; + pub fn pthread_condattr_destroy(attr: *mut crate::pthread_condattr_t) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_rwlock_init$UNIX2003" + )] + pub fn pthread_rwlock_init( + lock: *mut crate::pthread_rwlock_t, + attr: *const crate::pthread_rwlockattr_t, + ) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_rwlock_destroy$UNIX2003" + )] + pub fn pthread_rwlock_destroy(lock: *mut crate::pthread_rwlock_t) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_rwlock_rdlock$UNIX2003" + )] + pub fn pthread_rwlock_rdlock(lock: *mut crate::pthread_rwlock_t) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_rwlock_tryrdlock$UNIX2003" + )] + pub fn pthread_rwlock_tryrdlock(lock: *mut crate::pthread_rwlock_t) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_rwlock_wrlock$UNIX2003" + )] + pub fn pthread_rwlock_wrlock(lock: *mut crate::pthread_rwlock_t) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_rwlock_trywrlock$UNIX2003" + )] + pub fn pthread_rwlock_trywrlock(lock: *mut crate::pthread_rwlock_t) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pthread_rwlock_unlock$UNIX2003" + )] + pub fn pthread_rwlock_unlock(lock: *mut crate::pthread_rwlock_t) -> c_int; + pub fn pthread_rwlockattr_init(attr: *mut crate::pthread_rwlockattr_t) -> c_int; + pub fn pthread_rwlockattr_destroy(attr: *mut crate::pthread_rwlockattr_t) -> c_int; + + #[cfg_attr( + any(target_os = "illumos", target_os = "solaris"), + link_name = "__xnet_getsockopt" + )] + #[cfg_attr(target_os = "espidf", link_name = "lwip_getsockopt")] + #[cfg_attr(gnu_time_bits64, link_name = "__getsockopt64")] + pub fn getsockopt( + sockfd: c_int, + level: c_int, + optname: c_int, + optval: *mut c_void, + optlen: *mut crate::socklen_t, + ) -> c_int; + pub fn raise(signum: c_int) -> c_int; + + #[cfg_attr(target_os = "netbsd", link_name = "__utimes50")] + #[cfg_attr(gnu_time_bits64, link_name = "__utimes64")] + #[cfg_attr(musl_redir_time64, link_name = "__utimes_time64")] + pub fn utimes(filename: *const c_char, times: *const crate::timeval) -> c_int; + pub fn dlopen(filename: *const c_char, flag: c_int) -> *mut c_void; + pub fn dlerror() -> *mut c_char; + #[cfg_attr(musl_redir_time64, link_name = "__dlsym_time64")] + pub fn dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void; + pub fn dlclose(handle: *mut c_void) -> c_int; + + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] + #[cfg_attr( + any(target_os = "illumos", target_os = "solaris"), + link_name = "__xnet_getaddrinfo" + )] + #[cfg_attr(target_os = "espidf", link_name = "lwip_getaddrinfo")] + pub fn getaddrinfo( + node: *const c_char, + service: *const c_char, + hints: *const addrinfo, + res: *mut *mut addrinfo, + ) -> c_int; + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] + #[cfg_attr(target_os = "espidf", link_name = "lwip_freeaddrinfo")] + pub fn freeaddrinfo(res: *mut addrinfo); + pub fn hstrerror(errcode: c_int) -> *const c_char; + pub fn gai_strerror(errcode: c_int) -> *const c_char; + #[cfg_attr( + any( + all( + target_os = "linux", + not(any(target_env = "musl", target_env = "ohos")) + ), + target_os = "freebsd", + target_os = "cygwin", + target_os = "dragonfly", + target_os = "haiku" + ), + link_name = "__res_init" + )] + #[cfg_attr( + any( + target_os = "macos", + target_os = "ios", + target_os = "tvos", + target_os = "watchos", + target_os = "visionos" + ), + link_name = "res_9_init" + )] + #[cfg_attr(target_os = "aix", link_name = "_res_init")] + #[cfg(not(target_os = "l4re"))] + pub fn res_init() -> c_int; + + #[cfg_attr(target_os = "netbsd", link_name = "__gmtime_r50")] + #[cfg_attr(gnu_time_bits64, link_name = "__gmtime64_r")] + #[cfg_attr(not(musl32_time64), allow(deprecated))] + #[cfg_attr(musl_redir_time64, link_name = "__gmtime64_r")] + pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm; + #[cfg_attr(target_os = "netbsd", link_name = "__localtime_r50")] + #[cfg_attr(gnu_time_bits64, link_name = "__localtime64_r")] + #[cfg_attr(not(musl32_time64), allow(deprecated))] + #[cfg_attr(musl_redir_time64, link_name = "__localtime64_r")] + pub fn localtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "mktime$UNIX2003" + )] + #[cfg_attr(target_os = "netbsd", link_name = "__mktime50")] + #[cfg_attr(any(gnu_time_bits64, musl_redir_time64), link_name = "__mktime64")] + #[cfg_attr(not(musl32_time64), allow(deprecated))] + pub fn mktime(tm: *mut tm) -> time_t; + #[cfg_attr(target_os = "netbsd", link_name = "__time50")] + #[cfg_attr(any(gnu_time_bits64, musl_redir_time64), link_name = "__time64")] + #[cfg_attr(not(musl32_time64), allow(deprecated))] + pub fn time(time: *mut time_t) -> time_t; + #[cfg_attr(target_os = "netbsd", link_name = "__gmtime50")] + #[cfg_attr(any(gnu_time_bits64, musl_redir_time64), link_name = "__gmtime64")] + #[cfg_attr(not(musl32_time64), allow(deprecated))] + pub fn gmtime(time_p: *const time_t) -> *mut tm; + #[cfg_attr(target_os = "netbsd", link_name = "__locatime50")] + #[cfg_attr(any(gnu_time_bits64, musl_redir_time64), link_name = "__localtime64")] + #[cfg_attr(not(musl32_time64), allow(deprecated))] + pub fn localtime(time_p: *const time_t) -> *mut tm; + #[cfg_attr(target_os = "netbsd", link_name = "__difftime50")] + #[cfg_attr(any(gnu_time_bits64, musl_redir_time64), link_name = "__difftime64")] + #[cfg_attr(not(musl32_time64), allow(deprecated))] + pub fn difftime(time1: time_t, time0: time_t) -> c_double; + #[cfg(not(target_os = "aix"))] + #[cfg_attr(target_os = "netbsd", link_name = "__timegm50")] + #[cfg_attr(gnu_time_bits64, link_name = "__timegm64")] + #[cfg_attr(not(musl32_time64), allow(deprecated))] + #[cfg_attr(musl_redir_time64, link_name = "__timegm_time64")] + pub fn timegm(tm: *mut crate::tm) -> time_t; + + #[cfg_attr(target_os = "netbsd", link_name = "__mknod50")] + #[cfg_attr( + all(target_os = "freebsd", any(freebsd11, freebsd10)), + link_name = "mknod@FBSD_1.0" + )] + pub fn mknod(pathname: *const c_char, mode: mode_t, dev: crate::dev_t) -> c_int; + #[cfg(not(target_os = "espidf"))] + pub fn gethostname(name: *mut c_char, len: size_t) -> c_int; + pub fn endservent(); + pub fn getservbyname(name: *const c_char, proto: *const c_char) -> *mut servent; + pub fn getservbyport(port: c_int, proto: *const c_char) -> *mut servent; + pub fn getservent() -> *mut servent; + pub fn setservent(stayopen: c_int); + pub fn getprotobyname(name: *const c_char) -> *mut protoent; + pub fn getprotobynumber(proto: c_int) -> *mut protoent; + pub fn chroot(name: *const c_char) -> c_int; + #[cfg(target_os = "cygwin")] + pub fn usleep(secs: useconds_t) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "usleep$UNIX2003" + )] + #[cfg(not(target_os = "cygwin"))] + pub fn usleep(secs: c_uint) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "send$UNIX2003" + )] + #[cfg_attr(target_os = "espidf", link_name = "lwip_send")] + pub fn send(socket: c_int, buf: *const c_void, len: size_t, flags: c_int) -> ssize_t; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "recv$UNIX2003" + )] + #[cfg_attr(target_os = "espidf", link_name = "lwip_recv")] + pub fn recv(socket: c_int, buf: *mut c_void, len: size_t, flags: c_int) -> ssize_t; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "putenv$UNIX2003" + )] + #[cfg_attr(target_os = "netbsd", link_name = "__putenv50")] + pub fn putenv(string: *mut c_char) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "poll$UNIX2003" + )] + pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: c_int) -> c_int; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86_64"), + link_name = "select$1050" + )] + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "select$UNIX2003" + )] + #[cfg_attr(target_os = "netbsd", link_name = "__select50")] + #[cfg_attr(target_os = "aix", link_name = "__fd_select")] + #[cfg_attr(gnu_time_bits64, link_name = "__select64")] + #[cfg_attr(musl_redir_time64, link_name = "__select_time64")] + pub fn select( + nfds: c_int, + readfds: *mut fd_set, + writefds: *mut fd_set, + errorfds: *mut fd_set, + timeout: *mut timeval, + ) -> c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__setlocale50")] + pub fn setlocale(category: c_int, locale: *const c_char) -> *mut c_char; + pub fn localeconv() -> *mut lconv; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "sem_wait$UNIX2003" + )] + pub fn sem_wait(sem: *mut sem_t) -> c_int; + pub fn sem_trywait(sem: *mut sem_t) -> c_int; + pub fn sem_post(sem: *mut sem_t) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "statvfs64")] + pub fn statvfs(path: *const c_char, buf: *mut crate::statvfs) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "fstatvfs64")] + pub fn fstatvfs(fd: c_int, buf: *mut crate::statvfs) -> c_int; + + #[cfg_attr(target_os = "netbsd", link_name = "__sigemptyset14")] + pub fn sigemptyset(set: *mut sigset_t) -> c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__sigaddset14")] + pub fn sigaddset(set: *mut sigset_t, signum: c_int) -> c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__sigfillset14")] + pub fn sigfillset(set: *mut sigset_t) -> c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__sigdelset14")] + pub fn sigdelset(set: *mut sigset_t, signum: c_int) -> c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__sigismember14")] + pub fn sigismember(set: *const sigset_t, signum: c_int) -> c_int; + + #[cfg_attr(target_os = "netbsd", link_name = "__sigprocmask14")] + pub fn sigprocmask(how: c_int, set: *const sigset_t, oldset: *mut sigset_t) -> c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__sigpending14")] + pub fn sigpending(set: *mut sigset_t) -> c_int; + + #[cfg_attr(target_os = "solaris", link_name = "__sysconf_xpg7")] + pub fn sysconf(name: c_int) -> c_long; + + pub fn mkfifo(path: *const c_char, mode: mode_t) -> c_int; + + #[cfg_attr(gnu_file_offset_bits64, link_name = "fseeko64")] + pub fn fseeko(stream: *mut crate::FILE, offset: off_t, whence: c_int) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "ftello64")] + pub fn ftello(stream: *mut crate::FILE) -> off_t; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "tcdrain$UNIX2003" + )] + pub fn tcdrain(fd: c_int) -> c_int; + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "arm"), + link_name = "cfgetispeed@GLIBC_2.4" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "csky"), + link_name = "cfgetispeed@GLIBC_2.29" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "m68k"), + link_name = "cfgetispeed@GLIBC_2.0" + )] + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + any(target_arch = "mips", target_arch = "mips32r6") + ), + link_name = "cfgetispeed@GLIBC_2.0" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "powerpc"), + link_name = "cfgetispeed@GLIBC_2.0" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "riscv32"), + link_name = "cfgetispeed@GLIBC_2.33" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "sparc"), + link_name = "cfgetispeed@GLIBC_2.0" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "x86"), + link_name = "cfgetispeed@GLIBC_2.0" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "aarch64"), + link_name = "cfgetispeed@GLIBC_2.17" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "loongarch64"), + link_name = "cfgetispeed@GLIBC_2.36" + )] + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + any(target_arch = "mips64", target_arch = "mips64r6") + ), + link_name = "cfgetispeed@GLIBC_2.0" + )] + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + target_arch = "powerpc64", + target_endian = "big" + ), + link_name = "cfgetispeed@GLIBC_2.3" + )] + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + target_arch = "powerpc64", + target_endian = "little" + ), + link_name = "cfgetispeed@GLIBC_2.17" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "riscv64"), + link_name = "cfgetispeed@GLIBC_2.27" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "s390x"), + link_name = "cfgetispeed@GLIBC_2.2" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "sparc64"), + link_name = "cfgetispeed@GLIBC_2.2" + )] + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + target_arch = "x86_64", + target_pointer_width = "64" + ), + link_name = "cfgetispeed@GLIBC_2.2.5" + )] + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + target_arch = "x86_64", + target_pointer_width = "32" + ), + link_name = "cfgetispeed@GLIBC_2.16" + )] + pub fn cfgetispeed(termios: *const crate::termios) -> crate::speed_t; + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "arm"), + link_name = "cfgetospeed@GLIBC_2.4" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "csky"), + link_name = "cfgetospeed@GLIBC_2.29" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "m68k"), + link_name = "cfgetospeed@GLIBC_2.0" + )] + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + any(target_arch = "mips", target_arch = "mips32r6") + ), + link_name = "cfgetospeed@GLIBC_2.0" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "powerpc"), + link_name = "cfgetospeed@GLIBC_2.0" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "riscv32"), + link_name = "cfgetospeed@GLIBC_2.33" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "sparc"), + link_name = "cfgetospeed@GLIBC_2.0" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "x86"), + link_name = "cfgetospeed@GLIBC_2.0" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "aarch64"), + link_name = "cfgetospeed@GLIBC_2.17" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "loongarch64"), + link_name = "cfgetospeed@GLIBC_2.36" + )] + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + any(target_arch = "mips64", target_arch = "mips64r6") + ), + link_name = "cfgetospeed@GLIBC_2.0" + )] + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + target_arch = "powerpc64", + target_endian = "big" + ), + link_name = "cfgetospeed@GLIBC_2.3" + )] + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + target_arch = "powerpc64", + target_endian = "little" + ), + link_name = "cfgetospeed@GLIBC_2.17" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "riscv64"), + link_name = "cfgetospeed@GLIBC_2.27" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "s390x"), + link_name = "cfgetospeed@GLIBC_2.2" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "sparc64"), + link_name = "cfgetospeed@GLIBC_2.2" + )] + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + target_arch = "x86_64", + target_pointer_width = "64" + ), + link_name = "cfgetospeed@GLIBC_2.2.5" + )] + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + target_arch = "x86_64", + target_pointer_width = "32" + ), + link_name = "cfgetospeed@GLIBC_2.16" + )] + pub fn cfgetospeed(termios: *const crate::termios) -> crate::speed_t; + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "arm"), + link_name = "cfsetispeed@GLIBC_2.4" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "csky"), + link_name = "cfsetispeed@GLIBC_2.29" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "m68k"), + link_name = "cfsetispeed@GLIBC_2.0" + )] + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + any(target_arch = "mips", target_arch = "mips32r6") + ), + link_name = "cfsetispeed@GLIBC_2.0" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "powerpc"), + link_name = "cfsetispeed@GLIBC_2.0" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "riscv32"), + link_name = "cfsetispeed@GLIBC_2.33" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "sparc"), + link_name = "cfsetispeed@GLIBC_2.0" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "x86"), + link_name = "cfsetispeed@GLIBC_2.0" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "aarch64"), + link_name = "cfsetispeed@GLIBC_2.17" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "loongarch64"), + link_name = "cfsetispeed@GLIBC_2.36" + )] + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + any(target_arch = "mips64", target_arch = "mips64r6") + ), + link_name = "cfsetispeed@GLIBC_2.0" + )] + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + target_arch = "powerpc64", + target_endian = "big" + ), + link_name = "cfsetispeed@GLIBC_2.3" + )] + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + target_arch = "powerpc64", + target_endian = "little" + ), + link_name = "cfsetispeed@GLIBC_2.17" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "riscv64"), + link_name = "cfsetispeed@GLIBC_2.27" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "s390x"), + link_name = "cfsetispeed@GLIBC_2.2" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "sparc64"), + link_name = "cfsetispeed@GLIBC_2.2" + )] + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + target_arch = "x86_64", + target_pointer_width = "64" + ), + link_name = "cfsetispeed@GLIBC_2.2.5" + )] + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + target_arch = "x86_64", + target_pointer_width = "32" + ), + link_name = "cfsetispeed@GLIBC_2.16" + )] + pub fn cfsetispeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int; + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "arm"), + link_name = "cfsetospeed@GLIBC_2.4" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "csky"), + link_name = "cfsetospeed@GLIBC_2.29" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "m68k"), + link_name = "cfsetospeed@GLIBC_2.0" + )] + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + any(target_arch = "mips", target_arch = "mips32r6") + ), + link_name = "cfsetospeed@GLIBC_2.0" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "powerpc"), + link_name = "cfsetospeed@GLIBC_2.0" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "riscv32"), + link_name = "cfsetospeed@GLIBC_2.33" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "sparc"), + link_name = "cfsetospeed@GLIBC_2.0" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "x86"), + link_name = "cfsetospeed@GLIBC_2.0" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "aarch64"), + link_name = "cfsetospeed@GLIBC_2.17" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "loongarch64"), + link_name = "cfsetospeed@GLIBC_2.36" + )] + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + any(target_arch = "mips64", target_arch = "mips64r6") + ), + link_name = "cfsetospeed@GLIBC_2.0" + )] + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + target_arch = "powerpc64", + target_endian = "big" + ), + link_name = "cfsetospeed@GLIBC_2.3" + )] + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + target_arch = "powerpc64", + target_endian = "little" + ), + link_name = "cfsetospeed@GLIBC_2.17" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "riscv64"), + link_name = "cfsetospeed@GLIBC_2.27" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "s390x"), + link_name = "cfsetospeed@GLIBC_2.2" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "sparc64"), + link_name = "cfsetospeed@GLIBC_2.2" + )] + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + target_arch = "x86_64", + target_pointer_width = "64" + ), + link_name = "cfsetospeed@GLIBC_2.2.5" + )] + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + target_arch = "x86_64", + target_pointer_width = "32" + ), + link_name = "cfsetospeed@GLIBC_2.16" + )] + pub fn cfsetospeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int; + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + any( + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "mips64", + target_arch = "mips64r6", + target_arch = "sparc" + ), + ), + link_name = "tcgetattr@GLIBC_2.0" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "sparc64"), + link_name = "tcgetattr@GLIBC_2.2" + )] + pub fn tcgetattr(fd: c_int, termios: *mut crate::termios) -> c_int; + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + any( + target_arch = "mips", + target_arch = "mips32r6", + target_arch = "mips64", + target_arch = "mips64r6", + target_arch = "sparc" + ), + ), + link_name = "tcsetattr@GLIBC_2.0" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "sparc64"), + link_name = "tcsetattr@GLIBC_2.2" + )] + pub fn tcsetattr(fd: c_int, optional_actions: c_int, termios: *const crate::termios) -> c_int; + pub fn tcflow(fd: c_int, action: c_int) -> c_int; + pub fn tcflush(fd: c_int, action: c_int) -> c_int; + pub fn tcgetsid(fd: c_int) -> crate::pid_t; + pub fn tcsendbreak(fd: c_int, duration: c_int) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "mkstemp64")] + pub fn mkstemp(template: *mut c_char) -> c_int; + pub fn mkdtemp(template: *mut c_char) -> *mut c_char; + + pub fn tmpnam(ptr: *mut c_char) -> *mut c_char; + + pub fn openlog(ident: *const c_char, logopt: c_int, facility: c_int); + pub fn closelog(); + pub fn setlogmask(maskpri: c_int) -> c_int; + #[cfg_attr(target_os = "macos", link_name = "syslog$DARWIN_EXTSN")] + pub fn syslog(priority: c_int, message: *const c_char, ...); + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "nice$UNIX2003" + )] + pub fn nice(incr: c_int) -> c_int; + + #[cfg(not(target_os = "l4re"))] + pub fn grantpt(fd: c_int) -> c_int; + #[cfg(not(target_os = "l4re"))] + pub fn posix_openpt(flags: c_int) -> c_int; + #[cfg(not(target_os = "l4re"))] + pub fn ptsname(fd: c_int) -> *mut c_char; + #[cfg(not(target_os = "l4re"))] + pub fn unlockpt(fd: c_int) -> c_int; + + #[cfg(not(target_os = "aix"))] + pub fn strcasestr(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn getline(lineptr: *mut *mut c_char, n: *mut size_t, stream: *mut FILE) -> ssize_t; + + #[cfg_attr(gnu_file_offset_bits64, link_name = "lockf64")] + pub fn lockf(fd: c_int, cmd: c_int, len: off_t) -> c_int; + +} + +safe_f! { + // It seems htonl, etc are macros on macOS. So we have to reimplement them. So let's + // reimplement them for all UNIX platforms + pub const fn htonl(hostlong: u32) -> u32 { + u32::to_be(hostlong) + } + pub const fn htons(hostshort: u16) -> u16 { + u16::to_be(hostshort) + } + pub const fn ntohl(netlong: u32) -> u32 { + u32::from_be(netlong) + } + pub const fn ntohs(netshort: u16) -> u16 { + u16::from_be(netshort) + } +} + +cfg_if! { + if #[cfg(not(any( + target_os = "emscripten", + target_os = "android", + target_os = "haiku", + target_os = "nto", + target_os = "solaris", + target_os = "cygwin", + target_os = "aix", + target_os = "l4re", + )))] { + extern "C" { + #[cfg_attr(target_os = "netbsd", link_name = "__adjtime50")] + #[cfg_attr(any(gnu_time_bits64, musl_redir_time64), link_name = "__adjtime64")] + pub fn adjtime(delta: *const timeval, olddelta: *mut timeval) -> c_int; + } + } else if #[cfg(target_os = "solaris")] { + extern "C" { + pub fn adjtime(delta: *mut timeval, olddelta: *mut timeval) -> c_int; + } + } +} + +cfg_if! { + if #[cfg(not(any( + target_os = "emscripten", + target_os = "android", + target_os = "nto" + )))] { + extern "C" { + pub fn stpncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char; + } + } +} + +cfg_if! { + if #[cfg(not(any( + target_os = "dragonfly", + target_os = "emscripten", + target_os = "hurd", + target_os = "macos", + target_os = "openbsd", + target_os = "l4re", + )))] { + extern "C" { + pub fn sigqueue(pid: pid_t, sig: c_int, value: crate::sigval) -> c_int; + } + } +} + +cfg_if! { + if #[cfg(not(target_os = "android"))] { + extern "C" { + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "confstr$UNIX2003" + )] + #[cfg_attr(target_os = "solaris", link_name = "__confstr_xpg7")] + pub fn confstr(name: c_int, buf: *mut c_char, len: size_t) -> size_t; + } + } +} + +cfg_if! { + if #[cfg(not(target_os = "aix"))] { + extern "C" { + pub fn dladdr(addr: *const c_void, info: *mut Dl_info) -> c_int; + } + } +} + +cfg_if! { + if #[cfg(not(target_os = "solaris"))] { + extern "C" { + pub fn flock(fd: c_int, operation: c_int) -> c_int; + } + } +} + +cfg_if! { + if #[cfg(not(any(target_env = "uclibc", target_os = "nto")))] { + extern "C" { + pub fn open_wmemstream(ptr: *mut *mut wchar_t, sizeloc: *mut size_t) -> *mut FILE; + } + } +} + +cfg_if! { + if #[cfg(not(target_os = "redox"))] { + extern "C" { + pub fn getsid(pid: pid_t) -> pid_t; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pause$UNIX2003" + )] + pub fn pause() -> c_int; + + #[cfg(not(target_os = "l4re"))] + pub fn mkdirat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; + #[cfg_attr(gnu_file_offset_bits64, link_name = "openat64")] + pub fn openat(dirfd: c_int, pathname: *const c_char, flags: c_int, ...) -> c_int; + + #[cfg_attr( + all(target_os = "macos", target_arch = "x86_64"), + link_name = "fdopendir$INODE64" + )] + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "fdopendir$INODE64$UNIX2003" + )] + pub fn fdopendir(fd: c_int) -> *mut crate::DIR; + + #[cfg_attr( + all(target_os = "macos", not(target_arch = "aarch64")), + link_name = "readdir_r$INODE64" + )] + #[cfg_attr(target_os = "netbsd", link_name = "__readdir_r30")] + #[cfg_attr( + all(target_os = "freebsd", any(freebsd11, freebsd10)), + link_name = "readdir_r@FBSD_1.0" + )] + #[cfg_attr( + all(target_os = "freebsd", not(any(freebsd11, freebsd10))), + link_name = "readdir_r@FBSD_1.5" + )] + #[allow(non_autolinks)] // FIXME(docs): `<>` breaks line length limit. + /// The 64-bit libc on Solaris and illumos only has readdir_r. If a + /// 32-bit Solaris or illumos target is ever created, it should use + /// __posix_readdir_r. See libc(3LIB) on Solaris or illumos: + /// https://illumos.org/man/3lib/libc + /// https://docs.oracle.com/cd/E36784_01/html/E36873/libc-3lib.html + /// https://www.unix.com/man-page/opensolaris/3LIB/libc/ + #[cfg_attr(gnu_file_offset_bits64, link_name = "readdir64_r")] + pub fn readdir_r( + dirp: *mut crate::DIR, + entry: *mut crate::dirent, + result: *mut *mut crate::dirent, + ) -> c_int; + } + } +} + +cfg_if! { + if #[cfg(target_os = "nto")] { + extern "C" { + pub fn readlinkat( + dirfd: c_int, + pathname: *const c_char, + buf: *mut c_char, + bufsiz: size_t, + ) -> c_int; + pub fn readlink(path: *const c_char, buf: *mut c_char, bufsz: size_t) -> c_int; + pub fn pselect( + nfds: c_int, + readfds: *mut fd_set, + writefds: *mut fd_set, + errorfds: *mut fd_set, + timeout: *mut timespec, + sigmask: *const sigset_t, + ) -> c_int; + pub fn sigaction(signum: c_int, act: *const sigaction, oldact: *mut sigaction) + -> c_int; + } + } else { + extern "C" { + #[cfg(not(target_os = "l4re"))] + pub fn readlinkat( + dirfd: c_int, + pathname: *const c_char, + buf: *mut c_char, + bufsiz: size_t, + ) -> ssize_t; + #[cfg(not(target_os = "l4re"))] + pub fn fmemopen(buf: *mut c_void, size: size_t, mode: *const c_char) -> *mut FILE; + #[cfg(not(target_os = "l4re"))] + pub fn open_memstream(ptr: *mut *mut c_char, sizeloc: *mut size_t) -> *mut FILE; + pub fn atexit(cb: extern "C" fn()) -> c_int; + #[cfg_attr(target_os = "netbsd", link_name = "__sigaction14")] + pub fn sigaction(signum: c_int, act: *const sigaction, oldact: *mut sigaction) + -> c_int; + pub fn readlink(path: *const c_char, buf: *mut c_char, bufsz: size_t) -> ssize_t; + #[cfg_attr( + all(target_os = "macos", target_arch = "x86_64"), + link_name = "pselect$1050" + )] + #[cfg_attr( + all(target_os = "macos", target_arch = "x86"), + link_name = "pselect$UNIX2003" + )] + #[cfg_attr(target_os = "netbsd", link_name = "__pselect50")] + #[cfg_attr(gnu_time_bits64, link_name = "__pselect64")] + #[cfg_attr(musl_redir_time64, link_name = "__pselect_time64")] + pub fn pselect( + nfds: c_int, + readfds: *mut fd_set, + writefds: *mut fd_set, + errorfds: *mut fd_set, + timeout: *const timespec, + sigmask: *const sigset_t, + ) -> c_int; + } + } +} + +cfg_if! { + if #[cfg(any(target_os = "aix", target_os = "nto"))] { + extern "C" { + pub fn cfmakeraw(termios: *mut crate::termios) -> c_int; + } + } else if #[cfg(not(any(target_os = "solaris", target_os = "illumos",)))] { + extern "C" { + pub fn cfmakeraw(termios: *mut crate::termios); + } + } +} + +cfg_if! { + if #[cfg(any( + target_os = "aix", + all(target_os = "nto", target_env = "nto80") + ))] { + extern "C" { + pub fn cfsetspeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int; + } + } else if #[cfg(not(any( + target_os = "solaris", + target_os = "illumos", + target_os = "nto" + )))] { + extern "C" { + #[cfg(not(target_os = "l4re"))] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "arm"), + link_name = "cfsetspeed@GLIBC_2.4" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "csky"), + link_name = "cfsetspeed@GLIBC_2.29" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "m68k"), + link_name = "cfsetspeed@GLIBC_2.0" + )] + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + any(target_arch = "mips", target_arch = "mips32r6") + ), + link_name = "cfsetspeed@GLIBC_2.0" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "powerpc"), + link_name = "cfsetspeed@GLIBC_2.0" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "riscv32"), + link_name = "cfsetspeed@GLIBC_2.33" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "sparc"), + link_name = "cfsetspeed@GLIBC_2.0" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "x86"), + link_name = "cfsetspeed@GLIBC_2.0" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "aarch64"), + link_name = "cfsetspeed@GLIBC_2.17" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "loongarch64"), + link_name = "cfsetspeed@GLIBC_2.36" + )] + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + any(target_arch = "mips64", target_arch = "mips64r6") + ), + link_name = "cfsetspeed@GLIBC_2.0" + )] + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + target_arch = "powerpc64", + target_endian = "big" + ), + link_name = "cfsetspeed@GLIBC_2.3" + )] + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + target_arch = "powerpc64", + target_endian = "little" + ), + link_name = "cfsetspeed@GLIBC_2.17" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "riscv64"), + link_name = "cfsetspeed@GLIBC_2.27" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "s390x"), + link_name = "cfsetspeed@GLIBC_2.2" + )] + #[cfg_attr( + all(target_os = "linux", target_env = "gnu", target_arch = "sparc64"), + link_name = "cfsetspeed@GLIBC_2.2" + )] + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + target_arch = "x86_64", + target_pointer_width = "64" + ), + link_name = "cfsetspeed@GLIBC_2.2.5" + )] + #[cfg_attr( + all( + target_os = "linux", + target_env = "gnu", + target_arch = "x86_64", + target_pointer_width = "32" + ), + link_name = "cfsetspeed@GLIBC_2.16" + )] + pub fn cfsetspeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int; + } + } +} + +extern "C" { + pub fn fnmatch(pattern: *const c_char, name: *const c_char, flags: c_int) -> c_int; +} + +cfg_if! { + if #[cfg(target_env = "newlib")] { + mod newlib; + pub use self::newlib::*; + } else if #[cfg(any( + target_os = "linux", + target_os = "l4re", + target_os = "android", + target_os = "emscripten" + ))] { + mod linux_like; + pub use self::linux_like::*; + } else if #[cfg(any( + target_os = "macos", + target_os = "ios", + target_os = "tvos", + target_os = "watchos", + target_os = "visionos", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "openbsd", + target_os = "netbsd" + ))] { + mod bsd; + pub use self::bsd::*; + } else if #[cfg(any(target_os = "solaris", target_os = "illumos"))] { + mod solarish; + pub use self::solarish::*; + } else if #[cfg(target_os = "haiku")] { + mod haiku; + pub use self::haiku::*; + } else if #[cfg(target_os = "redox")] { + mod redox; + pub use self::redox::*; + } else if #[cfg(target_os = "cygwin")] { + mod cygwin; + pub use self::cygwin::*; + } else if #[cfg(target_os = "nto")] { + mod nto; + pub use self::nto::*; + } else if #[cfg(target_os = "aix")] { + mod aix; + pub use self::aix::*; + } else if #[cfg(target_os = "hurd")] { + mod hurd; + pub use self::hurd::*; + } else if #[cfg(target_os = "nuttx")] { + mod nuttx; + pub use self::nuttx::*; + } else { + // Unknown target_os + } +} diff --git a/http/vendor/libc/src/unix/newlib/aarch64/mod.rs b/http/vendor/libc/src/unix/newlib/aarch64/mod.rs new file mode 100644 index 0000000..56c268f --- /dev/null +++ b/http/vendor/libc/src/unix/newlib/aarch64/mod.rs @@ -0,0 +1,56 @@ +use crate::prelude::*; + +pub type clock_t = c_long; +pub type wchar_t = u32; + +s! { + pub struct sockaddr { + pub sa_len: u8, + pub sa_family: crate::sa_family_t, + pub sa_data: [c_char; 14], + } + + pub struct sockaddr_in6 { + pub sin6_len: u8, + pub sin6_family: crate::sa_family_t, + pub sin6_port: crate::in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: crate::in6_addr, + pub sin6_scope_id: u32, + } + + pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: crate::sa_family_t, + pub sin_port: crate::in_port_t, + pub sin_addr: crate::in_addr, + pub sin_zero: [c_char; 8], + } +} + +pub const AF_INET6: c_int = 23; + +pub const FIONBIO: c_ulong = 1; + +pub const POLLIN: c_short = 0x1; +pub const POLLPRI: c_short = 0x2; +pub const POLLOUT: c_short = 0x4; +pub const POLLERR: c_short = 0x8; +pub const POLLHUP: c_short = 0x10; +pub const POLLNVAL: c_short = 0x20; + +pub const SOL_SOCKET: c_int = 65535; + +pub const MSG_OOB: c_int = 1; +pub const MSG_PEEK: c_int = 2; +pub const MSG_DONTWAIT: c_int = 4; +pub const MSG_DONTROUTE: c_int = 0; +pub const MSG_WAITALL: c_int = 0; +pub const MSG_MORE: c_int = 0; +pub const MSG_NOSIGNAL: c_int = 0; + +pub use crate::unix::newlib::generic::{ + dirent, + sigset_t, + stat, +}; diff --git a/http/vendor/libc/src/unix/newlib/arm/mod.rs b/http/vendor/libc/src/unix/newlib/arm/mod.rs new file mode 100644 index 0000000..9b5978f --- /dev/null +++ b/http/vendor/libc/src/unix/newlib/arm/mod.rs @@ -0,0 +1,58 @@ +use crate::prelude::*; + +pub type clock_t = c_long; +pub type wchar_t = u32; + +s! { + pub struct sockaddr { + pub sa_family: crate::sa_family_t, + pub sa_data: [c_char; 14], + } + + pub struct sockaddr_in6 { + pub sin6_family: crate::sa_family_t, + pub sin6_port: crate::in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: crate::in6_addr, + pub sin6_scope_id: u32, + } + + pub struct sockaddr_in { + pub sin_family: crate::sa_family_t, + pub sin_port: crate::in_port_t, + pub sin_addr: crate::in_addr, + pub sin_zero: [u8; 8], + } + + pub struct sockaddr_storage { + pub ss_family: crate::sa_family_t, + __ss_padding: Padding<[u8; 26]>, + } +} + +pub const AF_INET6: c_int = 23; + +pub const FIONBIO: c_ulong = 1; + +pub const POLLIN: c_short = 0x1; +pub const POLLPRI: c_short = 0x2; +pub const POLLHUP: c_short = 0x4; +pub const POLLERR: c_short = 0x8; +pub const POLLOUT: c_short = 0x10; +pub const POLLNVAL: c_short = 0x20; + +pub const SOL_SOCKET: c_int = 65535; + +pub const MSG_OOB: c_int = 1; +pub const MSG_PEEK: c_int = 2; +pub const MSG_DONTWAIT: c_int = 4; +pub const MSG_DONTROUTE: c_int = 0; +pub const MSG_WAITALL: c_int = 0; +pub const MSG_MORE: c_int = 0; +pub const MSG_NOSIGNAL: c_int = 0; + +pub use crate::unix::newlib::generic::{ + dirent, + sigset_t, + stat, +}; diff --git a/http/vendor/libc/src/unix/newlib/espidf/mod.rs b/http/vendor/libc/src/unix/newlib/espidf/mod.rs new file mode 100644 index 0000000..b791bbe --- /dev/null +++ b/http/vendor/libc/src/unix/newlib/espidf/mod.rs @@ -0,0 +1,137 @@ +use crate::prelude::*; + +pub type clock_t = c_ulong; +pub type wchar_t = u32; + +s! { + pub struct cmsghdr { + pub cmsg_len: crate::socklen_t, + pub cmsg_level: c_int, + pub cmsg_type: c_int, + } + + pub struct msghdr { + pub msg_name: *mut c_void, + pub msg_namelen: crate::socklen_t, + pub msg_iov: *mut crate::iovec, + pub msg_iovlen: c_int, + pub msg_control: *mut c_void, + pub msg_controllen: crate::socklen_t, + pub msg_flags: c_int, + } + + pub struct sockaddr_un { + pub sun_family: crate::sa_family_t, + pub sun_path: [c_char; 108], + } + + pub struct sockaddr { + pub sa_len: u8, + pub sa_family: crate::sa_family_t, + pub sa_data: [c_char; 14], + } + + pub struct sockaddr_in6 { + pub sin6_len: u8, + pub sin6_family: crate::sa_family_t, + pub sin6_port: crate::in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: crate::in6_addr, + pub sin6_scope_id: u32, + } + + pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: crate::sa_family_t, + pub sin_port: crate::in_port_t, + pub sin_addr: crate::in_addr, + pub sin_zero: [c_char; 8], + } + + pub struct sockaddr_storage { + pub s2_len: u8, + pub ss_family: crate::sa_family_t, + pub s2_data1: [c_char; 2], + pub s2_data2: [u32; 3], + pub s2_data3: [u32; 3], + } +} + +pub const AF_UNIX: c_int = 1; +pub const AF_INET6: c_int = 10; + +pub const FIONBIO: c_ulong = 2147772030; + +pub const POLLIN: c_short = 1 << 0; +pub const POLLRDNORM: c_short = 1 << 1; +pub const POLLRDBAND: c_short = 1 << 2; +pub const POLLPRI: c_short = POLLRDBAND; +pub const POLLOUT: c_short = 1 << 3; +pub const POLLWRNORM: c_short = POLLOUT; +pub const POLLWRBAND: c_short = 1 << 4; +pub const POLLERR: c_short = 1 << 5; +pub const POLLHUP: c_short = 1 << 6; + +pub const SOL_SOCKET: c_int = 0xfff; + +pub const MSG_OOB: c_int = 0x04; +pub const MSG_PEEK: c_int = 0x01; +pub const MSG_DONTWAIT: c_int = 0x08; +pub const MSG_DONTROUTE: c_int = 0x4; +pub const MSG_WAITALL: c_int = 0x02; +pub const MSG_MORE: c_int = 0x10; +pub const MSG_NOSIGNAL: c_int = 0x20; +pub const MSG_TRUNC: c_int = 0x04; +pub const MSG_CTRUNC: c_int = 0x08; +pub const MSG_EOR: c_int = 0x08; + +pub const PTHREAD_STACK_MIN: size_t = 768; + +pub const SIGABRT: c_int = 6; +pub const SIGFPE: c_int = 8; +pub const SIGILL: c_int = 4; +pub const SIGINT: c_int = 2; +pub const SIGSEGV: c_int = 11; +pub const SIGTERM: c_int = 15; +pub const SIGHUP: c_int = 1; +pub const SIGQUIT: c_int = 3; +pub const NSIG: size_t = 32; + +pub const SOMAXCONN: c_int = 128; + +pub const DT_UNKNOWN: u8 = 0; +pub const DT_REG: u8 = 1; +pub const DT_DIR: u8 = 2; +// Not used by esp-idf, but still defined in headers. +pub const DT_CHR: u8 = 4; +pub const DT_BLK: u8 = 6; +pub const DT_FIFO: u8 = 8; +pub const DT_LNK: u8 = 10; +pub const DT_SOCK: u8 = 12; +pub const DT_WHT: u8 = 14; + +extern "C" { + pub fn pthread_create( + native: *mut crate::pthread_t, + attr: *const crate::pthread_attr_t, + f: extern "C" fn(_: *mut c_void) -> *mut c_void, + value: *mut c_void, + ) -> c_int; + + pub fn getrandom(buf: *mut c_void, buflen: size_t, flags: c_uint) -> ssize_t; + + pub fn gethostname(name: *mut c_char, namelen: ssize_t); + + #[link_name = "lwip_sendmsg"] + pub fn sendmsg(s: c_int, msg: *const crate::msghdr, flags: c_int) -> ssize_t; + #[link_name = "lwip_recvmsg"] + pub fn recvmsg(s: c_int, msg: *mut crate::msghdr, flags: c_int) -> ssize_t; + + pub fn eventfd(initval: c_uint, flags: c_int) -> c_int; +} + +pub use crate::unix::newlib::generic::{ + dirent, + sigset_t, + stat, +}; diff --git a/http/vendor/libc/src/unix/newlib/generic.rs b/http/vendor/libc/src/unix/newlib/generic.rs new file mode 100644 index 0000000..303de80 --- /dev/null +++ b/http/vendor/libc/src/unix/newlib/generic.rs @@ -0,0 +1,39 @@ +//! Common types used by most newlib platforms + +#[allow(unused_imports)] // needed for platforms that don't use the prelude here +use crate::prelude::*; + +s! { + #[cfg(all(not(target_os = "vita"), not(target_os = "horizon")))] + pub struct sigset_t { + __val: u32, + } + + #[cfg(all(not(target_os = "vita"), not(target_os = "horizon")))] + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + pub st_size: crate::off_t, + pub st_atime: crate::time_t, + pub st_spare1: c_long, + pub st_mtime: crate::time_t, + pub st_spare2: c_long, + pub st_ctime: crate::time_t, + pub st_spare3: c_long, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + pub st_spare4: [c_long; 2usize], + } + + #[cfg(not(target_os = "vita"))] + pub struct dirent { + pub d_ino: crate::ino_t, + pub d_type: c_uchar, + pub d_name: [c_char; 256usize], + } +} diff --git a/http/vendor/libc/src/unix/newlib/horizon/mod.rs b/http/vendor/libc/src/unix/newlib/horizon/mod.rs new file mode 100644 index 0000000..e94a0bb --- /dev/null +++ b/http/vendor/libc/src/unix/newlib/horizon/mod.rs @@ -0,0 +1,281 @@ +//! ARMv6K Nintendo 3DS C Newlib definitions + +use crate::off_t; +use crate::prelude::*; + +pub type wchar_t = c_uint; + +pub type u_register_t = c_uint; +pub type u_char = c_uchar; +pub type u_short = c_ushort; +pub type u_int = c_uint; +pub type u_long = c_ulong; +pub type ushort = c_ushort; +pub type uint = c_uint; +pub type ulong = c_ulong; +pub type clock_t = c_ulong; +pub type daddr_t = c_long; +pub type caddr_t = *mut c_char; +pub type sbintime_t = c_longlong; +pub type sigset_t = c_ulong; + +s! { + pub struct hostent { + pub h_name: *mut c_char, + pub h_aliases: *mut *mut c_char, + pub h_addrtype: u16, + pub h_length: u16, + pub h_addr_list: *mut *mut c_char, + } + + pub struct pollfd { + pub fd: c_int, + pub events: c_int, + pub revents: c_int, + } + + pub struct sockaddr { + pub sa_family: crate::sa_family_t, + pub sa_data: [c_char; 26usize], + } + + pub struct sockaddr_storage { + pub ss_family: crate::sa_family_t, + __ss_padding: Padding<[c_char; 26usize]>, + } + + pub struct sockaddr_in { + pub sin_family: crate::sa_family_t, + pub sin_port: crate::in_port_t, + pub sin_addr: crate::in_addr, + pub sin_zero: [c_char; 8], + } + + pub struct sockaddr_in6 { + pub sin6_family: crate::sa_family_t, + pub sin6_port: crate::in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: crate::in6_addr, + pub sin6_scope_id: u32, + } + + pub struct sockaddr_un { + pub sun_len: c_uchar, + pub sun_family: crate::sa_family_t, + pub sun_path: [c_char; 104usize], + } + + pub struct sched_param { + pub sched_priority: c_int, + } + + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + pub st_size: off_t, + pub st_atim: crate::timespec, + pub st_mtim: crate::timespec, + pub st_ctim: crate::timespec, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + pub st_spare4: [c_long; 2usize], + } +} + +pub const SIGEV_NONE: c_int = 1; +pub const SIGEV_SIGNAL: c_int = 2; +pub const SIGEV_THREAD: c_int = 3; +pub const SA_NOCLDSTOP: c_int = 1; +pub const MINSIGSTKSZ: c_int = 2048; +pub const SIGSTKSZ: c_int = 8192; +pub const SS_ONSTACK: c_int = 1; +pub const SS_DISABLE: c_int = 2; +pub const SIG_SETMASK: c_int = 0; +pub const SIG_BLOCK: c_int = 1; +pub const SIG_UNBLOCK: c_int = 2; +pub const SIGHUP: c_int = 1; +pub const SIGINT: c_int = 2; +pub const SIGQUIT: c_int = 3; +pub const SIGILL: c_int = 4; +pub const SIGTRAP: c_int = 5; +pub const SIGABRT: c_int = 6; +pub const SIGEMT: c_int = 7; +pub const SIGFPE: c_int = 8; +pub const SIGKILL: c_int = 9; +pub const SIGBUS: c_int = 10; +pub const SIGSEGV: c_int = 11; +pub const SIGSYS: c_int = 12; +pub const SIGPIPE: c_int = 13; +pub const SIGALRM: c_int = 14; +pub const SIGTERM: c_int = 15; +pub const SIGURG: c_int = 16; +pub const SIGSTOP: c_int = 17; +pub const SIGTSTP: c_int = 18; +pub const SIGCONT: c_int = 19; +pub const SIGCHLD: c_int = 20; +pub const SIGCLD: c_int = 20; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGIO: c_int = 23; +pub const SIGPOLL: c_int = 23; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGLOST: c_int = 29; +pub const SIGUSR1: c_int = 30; +pub const SIGUSR2: c_int = 31; +pub const NSIG: c_int = 32; +pub const CLOCK_ENABLED: c_uint = 1; +pub const CLOCK_DISABLED: c_uint = 0; +pub const CLOCK_ALLOWED: c_uint = 1; +pub const CLOCK_DISALLOWED: c_uint = 0; +pub const TIMER_ABSTIME: c_uint = 4; +pub const SOL_SOCKET: c_int = 65535; +pub const MSG_OOB: c_int = 1; +pub const MSG_PEEK: c_int = 2; +pub const MSG_DONTWAIT: c_int = 4; +pub const MSG_DONTROUTE: c_int = 0; +pub const MSG_WAITALL: c_int = 0; +pub const MSG_MORE: c_int = 0; +pub const MSG_NOSIGNAL: c_int = 0; +pub const SOL_CONFIG: c_uint = 65534; + +pub const PTHREAD_STACK_MIN: size_t = 4096; +pub const WNOHANG: c_int = 1; + +pub const POLLIN: c_int = 0x0001; +pub const POLLPRI: c_int = 0x0002; +pub const POLLOUT: c_int = 0x0004; +pub const POLLRDNORM: c_int = 0x0040; +pub const POLLWRNORM: c_int = POLLOUT; +pub const POLLRDBAND: c_int = 0x0080; +pub const POLLWRBAND: c_int = 0x0100; +pub const POLLERR: c_int = 0x0008; +pub const POLLHUP: c_int = 0x0010; +pub const POLLNVAL: c_int = 0x0020; + +pub const EAI_AGAIN: c_int = 2; +pub const EAI_BADFLAGS: c_int = 3; +pub const EAI_FAIL: c_int = 4; +pub const EAI_SERVICE: c_int = 9; +pub const EAI_SYSTEM: c_int = 11; +pub const EAI_BADHINTS: c_int = 12; +pub const EAI_PROTOCOL: c_int = 13; +pub const EAI_OVERFLOW: c_int = 14; +pub const EAI_MAX: c_int = 15; + +pub const AF_UNIX: c_int = 1; +pub const AF_INET6: c_int = 23; + +pub const FIONBIO: c_ulong = 1; + +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); + +// For pthread get/setschedparam +pub const SCHED_FIFO: c_int = 1; +pub const SCHED_RR: c_int = 2; + +// For getrandom() +pub const GRND_NONBLOCK: c_uint = 0x1; +pub const GRND_RANDOM: c_uint = 0x2; + +// Horizon OS works doesn't or can't hold any of this information +safe_f! { + pub const fn WIFSTOPPED(_status: c_int) -> bool { + false + } + + pub const fn WSTOPSIG(_status: c_int) -> c_int { + 0 + } + + pub const fn WIFCONTINUED(_status: c_int) -> bool { + true + } + + pub const fn WIFSIGNALED(_status: c_int) -> bool { + false + } + + pub const fn WTERMSIG(_status: c_int) -> c_int { + 0 + } + + pub const fn WIFEXITED(_status: c_int) -> bool { + true + } + + pub const fn WEXITSTATUS(_status: c_int) -> c_int { + 0 + } + + pub const fn WCOREDUMP(_status: c_int) -> bool { + false + } +} + +extern "C" { + pub fn pthread_create( + native: *mut crate::pthread_t, + attr: *const crate::pthread_attr_t, + f: extern "C" fn(_: *mut c_void) -> *mut c_void, + value: *mut c_void, + ) -> c_int; + + pub fn pthread_attr_getschedparam( + attr: *const crate::pthread_attr_t, + param: *mut sched_param, + ) -> c_int; + + pub fn pthread_attr_setschedparam( + attr: *mut crate::pthread_attr_t, + param: *const sched_param, + ) -> c_int; + + pub fn pthread_attr_getprocessorid_np( + attr: *const crate::pthread_attr_t, + processor_id: *mut c_int, + ) -> c_int; + + pub fn pthread_attr_setprocessorid_np( + attr: *mut crate::pthread_attr_t, + processor_id: c_int, + ) -> c_int; + + pub fn pthread_getschedparam( + native: crate::pthread_t, + policy: *mut c_int, + param: *mut crate::sched_param, + ) -> c_int; + + pub fn pthread_setschedparam( + native: crate::pthread_t, + policy: c_int, + param: *const crate::sched_param, + ) -> c_int; + + pub fn pthread_condattr_getclock( + attr: *const crate::pthread_condattr_t, + clock_id: *mut crate::clockid_t, + ) -> c_int; + + pub fn pthread_condattr_setclock( + attr: *mut crate::pthread_condattr_t, + clock_id: crate::clockid_t, + ) -> c_int; + + pub fn pthread_getprocessorid_np() -> c_int; + + pub fn getrandom(buf: *mut c_void, buflen: size_t, flags: c_uint) -> ssize_t; + + pub fn gethostid() -> c_long; +} + +pub use crate::unix::newlib::generic::dirent; diff --git a/http/vendor/libc/src/unix/newlib/mod.rs b/http/vendor/libc/src/unix/newlib/mod.rs new file mode 100644 index 0000000..9e7df16 --- /dev/null +++ b/http/vendor/libc/src/unix/newlib/mod.rs @@ -0,0 +1,977 @@ +use crate::prelude::*; + +pub type blkcnt_t = i32; +pub type blksize_t = i32; + +pub type clockid_t = c_ulong; + +cfg_if! { + if #[cfg(any(target_os = "espidf"))] { + pub type dev_t = c_short; + pub type ino_t = c_ushort; + pub type off_t = c_long; + } else if #[cfg(any(target_os = "vita"))] { + pub type dev_t = c_short; + pub type ino_t = c_ushort; + pub type off_t = c_int; + } else { + pub type dev_t = u32; + pub type ino_t = u32; + pub type off_t = i64; + } +} + +pub type fsblkcnt_t = u64; +pub type fsfilcnt_t = u32; +pub type id_t = u32; +pub type key_t = c_int; +pub type loff_t = c_longlong; +pub type mode_t = c_uint; +pub type nfds_t = u32; +pub type nlink_t = c_ushort; +pub type pthread_t = c_ulong; +pub type pthread_key_t = c_uint; +pub type rlim_t = u32; + +cfg_if! { + if #[cfg(target_os = "horizon")] { + pub type sa_family_t = u16; + } else { + pub type sa_family_t = u8; + } +} + +pub type socklen_t = u32; +pub type speed_t = u32; +pub type suseconds_t = i32; +cfg_if! { + if #[cfg(target_os = "espidf")] { + pub type tcflag_t = u16; + } else { + pub type tcflag_t = c_uint; + } +} +pub type useconds_t = u32; + +cfg_if! { + if #[cfg(any( + target_os = "horizon", + all(target_os = "espidf", not(espidf_time32)) + ))] { + pub type time_t = c_longlong; + } else { + pub type time_t = i32; + } +} + +s! { + // The order of the `ai_addr` field in this struct is crucial + // for converting between the Rust and C types. + pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: socklen_t, + + #[cfg(target_os = "espidf")] + pub ai_addr: *mut sockaddr, + + pub ai_canonname: *mut c_char, + + #[cfg(not(any( + target_os = "espidf", + all(target_arch = "powerpc", target_vendor = "nintendo") + )))] + pub ai_addr: *mut sockaddr, + + pub ai_next: *mut addrinfo, + } + + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct in_addr { + pub s_addr: crate::in_addr_t, + } + + pub struct lconv { + pub decimal_point: *mut c_char, + pub thousands_sep: *mut c_char, + pub grouping: *mut c_char, + pub int_curr_symbol: *mut c_char, + pub currency_symbol: *mut c_char, + pub mon_decimal_point: *mut c_char, + pub mon_thousands_sep: *mut c_char, + pub mon_grouping: *mut c_char, + pub positive_sign: *mut c_char, + pub negative_sign: *mut c_char, + pub int_frac_digits: c_char, + pub frac_digits: c_char, + pub p_cs_precedes: c_char, + pub p_sep_by_space: c_char, + pub n_cs_precedes: c_char, + pub n_sep_by_space: c_char, + pub p_sign_posn: c_char, + pub n_sign_posn: c_char, + pub int_n_cs_precedes: c_char, + pub int_n_sep_by_space: c_char, + pub int_n_sign_posn: c_char, + pub int_p_cs_precedes: c_char, + pub int_p_sep_by_space: c_char, + pub int_p_sign_posn: c_char, + } + + pub struct tm { + pub tm_sec: c_int, + pub tm_min: c_int, + pub tm_hour: c_int, + pub tm_mday: c_int, + pub tm_mon: c_int, + pub tm_year: c_int, + pub tm_wday: c_int, + pub tm_yday: c_int, + pub tm_isdst: c_int, + } + + pub struct statvfs { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: fsblkcnt_t, + pub f_bfree: fsblkcnt_t, + pub f_bavail: fsblkcnt_t, + pub f_files: fsfilcnt_t, + pub f_ffree: fsfilcnt_t, + pub f_favail: fsfilcnt_t, + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + } + + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigaction { + pub sa_handler: extern "C" fn(arg1: c_int), + pub sa_mask: sigset_t, + pub sa_flags: c_int, + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_flags: c_int, + pub ss_size: usize, + } + + pub struct fd_set { + // Unverified + fds_bits: [c_ulong; FD_SETSIZE as usize / ULONG_SIZE], + } + + pub struct passwd { + // Unverified + pub pw_name: *mut c_char, + pub pw_passwd: *mut c_char, + pub pw_uid: crate::uid_t, + pub pw_gid: crate::gid_t, + pub pw_gecos: *mut c_char, + pub pw_dir: *mut c_char, + pub pw_shell: *mut c_char, + } + + pub struct termios { + // Unverified + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_line: crate::cc_t, + pub c_cc: [crate::cc_t; crate::NCCS], + #[cfg(target_os = "espidf")] + pub c_ispeed: u32, + #[cfg(target_os = "espidf")] + pub c_ospeed: u32, + } + + pub struct sem_t { + // Unverified + __size: [c_char; 16], + } + + pub struct Dl_info { + // Unverified + pub dli_fname: *const c_char, + pub dli_fbase: *mut c_void, + pub dli_sname: *const c_char, + pub dli_saddr: *mut c_void, + } + + pub struct utsname { + // Unverified + pub sysname: [c_char; 65], + pub nodename: [c_char; 65], + pub release: [c_char; 65], + pub version: [c_char; 65], + pub machine: [c_char; 65], + pub domainname: [c_char; 65], + } + + pub struct cpu_set_t { + // Unverified + bits: [u32; 32], + } + + pub struct pthread_attr_t { + // Unverified + #[cfg(not(target_os = "espidf"))] + __size: [u8; __SIZEOF_PTHREAD_ATTR_T], + #[cfg(target_os = "espidf")] + pub is_initialized: i32, + #[cfg(target_os = "espidf")] + pub stackaddr: *mut c_void, + #[cfg(target_os = "espidf")] + pub stacksize: i32, + #[cfg(target_os = "espidf")] + pub contentionscope: i32, + #[cfg(target_os = "espidf")] + pub inheritsched: i32, + #[cfg(target_os = "espidf")] + pub schedpolicy: i32, + #[cfg(target_os = "espidf")] + pub schedparam: i32, + #[cfg(target_os = "espidf")] + pub detachstate: i32, + } + + pub struct pthread_rwlockattr_t { + // Unverified + __size: [u8; __SIZEOF_PTHREAD_RWLOCKATTR_T], + } + + #[cfg_attr( + all( + target_pointer_width = "32", + any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc") + ), + repr(align(4)) + )] + #[cfg_attr( + any( + target_pointer_width = "64", + not(any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc")) + ), + repr(align(8)) + )] + pub struct pthread_mutex_t { + // Unverified + size: [u8; crate::__SIZEOF_PTHREAD_MUTEX_T], + } + + #[cfg_attr( + all( + target_pointer_width = "32", + any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc") + ), + repr(align(4)) + )] + #[cfg_attr( + any( + target_pointer_width = "64", + not(any(target_arch = "mips", target_arch = "arm", target_arch = "powerpc")) + ), + repr(align(8)) + )] + pub struct pthread_rwlock_t { + // Unverified + size: [u8; crate::__SIZEOF_PTHREAD_RWLOCK_T], + } + + #[cfg_attr( + any( + target_pointer_width = "32", + target_arch = "x86_64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "s390x", + target_arch = "sparc64" + ), + repr(align(4)) + )] + #[cfg_attr( + not(any( + target_pointer_width = "32", + target_arch = "x86_64", + target_arch = "powerpc64", + target_arch = "mips64", + target_arch = "s390x", + target_arch = "sparc64" + )), + repr(align(8)) + )] + pub struct pthread_mutexattr_t { + // Unverified + size: [u8; crate::__SIZEOF_PTHREAD_MUTEXATTR_T], + } + + #[repr(align(8))] + pub struct pthread_cond_t { + // Unverified + size: [u8; crate::__SIZEOF_PTHREAD_COND_T], + } + + #[repr(align(4))] + pub struct pthread_condattr_t { + // Unverified + size: [u8; crate::__SIZEOF_PTHREAD_CONDATTR_T], + } +} + +// unverified constants +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + size: [__PTHREAD_INITIALIZER_BYTE; __SIZEOF_PTHREAD_MUTEX_T], +}; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + size: [__PTHREAD_INITIALIZER_BYTE; __SIZEOF_PTHREAD_COND_T], +}; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + size: [__PTHREAD_INITIALIZER_BYTE; __SIZEOF_PTHREAD_RWLOCK_T], +}; + +cfg_if! { + if #[cfg(target_os = "espidf")] { + pub const NCCS: usize = 11; + } else { + pub const NCCS: usize = 32; + } +} + +cfg_if! { + if #[cfg(target_os = "espidf")] { + const __PTHREAD_INITIALIZER_BYTE: u8 = 0xff; + pub const __SIZEOF_PTHREAD_ATTR_T: usize = 32; + pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 4; + pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 12; + pub const __SIZEOF_PTHREAD_COND_T: usize = 4; + pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 8; + pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 4; + pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 12; + pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; + } else if #[cfg(target_os = "vita")] { + const __PTHREAD_INITIALIZER_BYTE: u8 = 0xff; + pub const __SIZEOF_PTHREAD_ATTR_T: usize = 4; + pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 4; + pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; + pub const __SIZEOF_PTHREAD_COND_T: usize = 4; + pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; + pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 4; + pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 4; + pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 4; + } else if #[cfg(target_os = "rtems")] { + const __PTHREAD_INITIALIZER_BYTE: u8 = 0x00; + pub const __SIZEOF_PTHREAD_ATTR_T: usize = 96; + pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 64; + pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 24; + pub const __SIZEOF_PTHREAD_COND_T: usize = 28; + pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 24; + pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; + pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; + pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; + } else { + const __PTHREAD_INITIALIZER_BYTE: u8 = 0; + pub const __SIZEOF_PTHREAD_ATTR_T: usize = 56; + pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; + pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; + pub const __SIZEOF_PTHREAD_COND_T: usize = 48; + pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; + pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; + pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; + pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; + } +} + +pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; +pub const __PTHREAD_MUTEX_HAVE_PREV: usize = 1; +pub const __PTHREAD_RWLOCK_INT_FLAGS_SHARED: usize = 1; +pub const PTHREAD_MUTEX_NORMAL: c_int = 0; +pub const PTHREAD_MUTEX_RECURSIVE: c_int = 1; +pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 2; + +cfg_if! { + if #[cfg(any(target_os = "horizon", target_os = "espidf"))] { + pub const FD_SETSIZE: usize = 64; + } else if #[cfg(target_os = "vita")] { + pub const FD_SETSIZE: usize = 256; + } else { + pub const FD_SETSIZE: usize = 1024; + } +} +// intentionally not public, only used for fd_set +const ULONG_SIZE: usize = 32; + +// Other constants +pub const EPERM: c_int = 1; +pub const ENOENT: c_int = 2; +pub const ESRCH: c_int = 3; +pub const EINTR: c_int = 4; +pub const EIO: c_int = 5; +pub const ENXIO: c_int = 6; +pub const E2BIG: c_int = 7; +pub const ENOEXEC: c_int = 8; +pub const EBADF: c_int = 9; +pub const ECHILD: c_int = 10; +pub const EAGAIN: c_int = 11; +pub const ENOMEM: c_int = 12; +pub const EACCES: c_int = 13; +pub const EFAULT: c_int = 14; +pub const EBUSY: c_int = 16; +pub const EEXIST: c_int = 17; +pub const EXDEV: c_int = 18; +pub const ENODEV: c_int = 19; +pub const ENOTDIR: c_int = 20; +pub const EISDIR: c_int = 21; +pub const EINVAL: c_int = 22; +pub const ENFILE: c_int = 23; +pub const EMFILE: c_int = 24; +pub const ENOTTY: c_int = 25; +pub const ETXTBSY: c_int = 26; +pub const EFBIG: c_int = 27; +pub const ENOSPC: c_int = 28; +pub const ESPIPE: c_int = 29; +pub const EROFS: c_int = 30; +pub const EMLINK: c_int = 31; +pub const EPIPE: c_int = 32; +pub const EDOM: c_int = 33; +pub const ERANGE: c_int = 34; +pub const ENOMSG: c_int = 35; +pub const EIDRM: c_int = 36; +pub const EDEADLK: c_int = 45; +pub const ENOLCK: c_int = 46; +pub const ENOSTR: c_int = 60; +pub const ENODATA: c_int = 61; +pub const ETIME: c_int = 62; +pub const ENOSR: c_int = 63; +pub const ENOLINK: c_int = 67; +pub const EPROTO: c_int = 71; +pub const EMULTIHOP: c_int = 74; +pub const EBADMSG: c_int = 77; +pub const EFTYPE: c_int = 79; +pub const ENOSYS: c_int = 88; +pub const ENOTEMPTY: c_int = 90; +pub const ENAMETOOLONG: c_int = 91; +pub const ELOOP: c_int = 92; +pub const EOPNOTSUPP: c_int = 95; +pub const EPFNOSUPPORT: c_int = 96; +pub const ECONNRESET: c_int = 104; +pub const ENOBUFS: c_int = 105; +pub const EAFNOSUPPORT: c_int = 106; +pub const EPROTOTYPE: c_int = 107; +pub const ENOTSOCK: c_int = 108; +pub const ENOPROTOOPT: c_int = 109; +pub const ECONNREFUSED: c_int = 111; +pub const EADDRINUSE: c_int = 112; +pub const ECONNABORTED: c_int = 113; +pub const ENETUNREACH: c_int = 114; +pub const ENETDOWN: c_int = 115; +pub const ETIMEDOUT: c_int = 116; +pub const EHOSTDOWN: c_int = 117; +pub const EHOSTUNREACH: c_int = 118; +pub const EINPROGRESS: c_int = 119; +pub const EALREADY: c_int = 120; +pub const EDESTADDRREQ: c_int = 121; +pub const EMSGSIZE: c_int = 122; +pub const EPROTONOSUPPORT: c_int = 123; +pub const EADDRNOTAVAIL: c_int = 125; +pub const ENETRESET: c_int = 126; +pub const EISCONN: c_int = 127; +pub const ENOTCONN: c_int = 128; +pub const ETOOMANYREFS: c_int = 129; +pub const EDQUOT: c_int = 132; +pub const ESTALE: c_int = 133; +pub const ENOTSUP: c_int = 134; +pub const EILSEQ: c_int = 138; +pub const EOVERFLOW: c_int = 139; +pub const ECANCELED: c_int = 140; +pub const ENOTRECOVERABLE: c_int = 141; +pub const EOWNERDEAD: c_int = 142; +pub const EWOULDBLOCK: c_int = 11; + +pub const F_DUPFD: c_int = 0; +pub const F_GETFD: c_int = 1; +pub const F_SETFD: c_int = 2; +pub const F_GETFL: c_int = 3; +pub const F_SETFL: c_int = 4; +pub const F_GETOWN: c_int = 5; +pub const F_SETOWN: c_int = 6; +pub const F_GETLK: c_int = 7; +pub const F_SETLK: c_int = 8; +pub const F_SETLKW: c_int = 9; +pub const F_RGETLK: c_int = 10; +pub const F_RSETLK: c_int = 11; +pub const F_CNVT: c_int = 12; +pub const F_RSETLKW: c_int = 13; +pub const F_DUPFD_CLOEXEC: c_int = 14; + +pub const O_RDONLY: c_int = 0; +pub const O_WRONLY: c_int = 1; +pub const O_RDWR: c_int = 2; +cfg_if! { + if #[cfg(espidf_picolibc)] { + pub const O_APPEND: c_int = 1024; + pub const O_CREAT: c_int = 64; + pub const O_TRUNC: c_int = 512; + } else { + pub const O_APPEND: c_int = 8; + pub const O_CREAT: c_int = 512; + pub const O_TRUNC: c_int = 1024; + } +} +pub const O_EXCL: c_int = 2048; +pub const O_SYNC: c_int = 8192; +pub const O_NONBLOCK: c_int = 16384; + +pub const O_ACCMODE: c_int = 3; +cfg_if! { + if #[cfg(target_os = "espidf")] { + pub const O_CLOEXEC: c_int = 0x40000; + } else { + pub const O_CLOEXEC: c_int = 0x80000; + } +} + +pub const RTLD_LAZY: c_int = 0x1; + +pub const SEEK_SET: c_int = 0; +pub const SEEK_CUR: c_int = 1; +pub const SEEK_END: c_int = 2; + +pub const FIOCLEX: c_ulong = 0x20006601; +pub const FIONCLEX: c_ulong = 0x20006602; + +pub const S_BLKSIZE: mode_t = 1024; +pub const S_IREAD: mode_t = 0o0400; +pub const S_IWRITE: mode_t = 0o0200; +pub const S_IEXEC: mode_t = 0o0100; +pub const S_ENFMT: mode_t = 0o2000; +pub const S_IFMT: mode_t = 0o17_0000; +pub const S_IFDIR: mode_t = 0o4_0000; +pub const S_IFCHR: mode_t = 0o2_0000; +pub const S_IFBLK: mode_t = 0o6_0000; +pub const S_IFREG: mode_t = 0o10_0000; +pub const S_IFLNK: mode_t = 0o12_0000; +pub const S_IFSOCK: mode_t = 0o14_0000; +pub const S_IFIFO: mode_t = 0o1_0000; +pub const S_IRUSR: mode_t = 0o0400; +pub const S_IWUSR: mode_t = 0o0200; +pub const S_IXUSR: mode_t = 0o0100; +pub const S_IRGRP: mode_t = 0o0040; +pub const S_IWGRP: mode_t = 0o0020; +pub const S_IXGRP: mode_t = 0o0010; +pub const S_IROTH: mode_t = 0o0004; +pub const S_IWOTH: mode_t = 0o0002; +pub const S_IXOTH: mode_t = 0o0001; + +pub const SOL_TCP: c_int = 6; + +pub const PF_UNSPEC: c_int = 0; +pub const PF_INET: c_int = 2; +cfg_if! { + if #[cfg(target_os = "espidf")] { + pub const PF_INET6: c_int = 10; + } else { + pub const PF_INET6: c_int = 23; + } +} + +pub const AF_UNSPEC: c_int = 0; +pub const AF_INET: c_int = 2; + +pub const CLOCK_REALTIME: crate::clockid_t = 1; +pub const CLOCK_MONOTONIC: crate::clockid_t = 4; +pub const CLOCK_BOOTTIME: crate::clockid_t = 4; + +pub const SOCK_STREAM: c_int = 1; +pub const SOCK_DGRAM: c_int = 2; + +pub const SHUT_RD: c_int = 0; +pub const SHUT_WR: c_int = 1; +pub const SHUT_RDWR: c_int = 2; + +pub const SO_BINTIME: c_int = 0x2000; +pub const SO_NO_OFFLOAD: c_int = 0x4000; +pub const SO_NO_DDP: c_int = 0x8000; +pub const SO_REUSEPORT_LB: c_int = 0x10000; +pub const SO_LABEL: c_int = 0x1009; +pub const SO_PEERLABEL: c_int = 0x1010; +pub const SO_LISTENQLIMIT: c_int = 0x1011; +pub const SO_LISTENQLEN: c_int = 0x1012; +pub const SO_LISTENINCQLEN: c_int = 0x1013; +pub const SO_SETFIB: c_int = 0x1014; +pub const SO_USER_COOKIE: c_int = 0x1015; +pub const SO_PROTOCOL: c_int = 0x1016; +pub const SO_PROTOTYPE: c_int = SO_PROTOCOL; +pub const SO_VENDOR: c_int = 0x80000000; +pub const SO_DEBUG: c_int = 0x01; +pub const SO_ACCEPTCONN: c_int = 0x0002; +pub const SO_REUSEADDR: c_int = 0x0004; +pub const SO_KEEPALIVE: c_int = 0x0008; +pub const SO_DONTROUTE: c_int = 0x0010; +pub const SO_BROADCAST: c_int = 0x0020; +pub const SO_USELOOPBACK: c_int = 0x0040; +pub const SO_LINGER: c_int = 0x0080; +pub const SO_OOBINLINE: c_int = 0x0100; +pub const SO_REUSEPORT: c_int = 0x0200; +pub const SO_TIMESTAMP: c_int = 0x0400; +pub const SO_NOSIGPIPE: c_int = 0x0800; +pub const SO_ACCEPTFILTER: c_int = 0x1000; +pub const SO_SNDBUF: c_int = 0x1001; +pub const SO_RCVBUF: c_int = 0x1002; +pub const SO_SNDLOWAT: c_int = 0x1003; +pub const SO_RCVLOWAT: c_int = 0x1004; +pub const SO_SNDTIMEO: c_int = 0x1005; +pub const SO_RCVTIMEO: c_int = 0x1006; +cfg_if! { + if #[cfg(target_os = "horizon")] { + pub const SO_ERROR: c_int = 0x1009; + } else { + pub const SO_ERROR: c_int = 0x1007; + } +} +pub const SO_TYPE: c_int = 0x1008; + +pub const SOCK_CLOEXEC: c_int = O_CLOEXEC; + +pub const INET_ADDRSTRLEN: c_int = 16; + +// https://github.com/bminor/newlib/blob/HEAD/newlib/libc/sys/linux/include/net/if.h#L121 +pub const IFF_UP: c_int = 0x1; // interface is up +pub const IFF_BROADCAST: c_int = 0x2; // broadcast address valid +pub const IFF_DEBUG: c_int = 0x4; // turn on debugging +pub const IFF_LOOPBACK: c_int = 0x8; // is a loopback net +pub const IFF_POINTOPOINT: c_int = 0x10; // interface is point-to-point link +pub const IFF_NOTRAILERS: c_int = 0x20; // avoid use of trailers +pub const IFF_RUNNING: c_int = 0x40; // resources allocated +pub const IFF_NOARP: c_int = 0x80; // no address resolution protocol +pub const IFF_PROMISC: c_int = 0x100; // receive all packets +pub const IFF_ALLMULTI: c_int = 0x200; // receive all multicast packets +pub const IFF_OACTIVE: c_int = 0x400; // transmission in progress +pub const IFF_SIMPLEX: c_int = 0x800; // can't hear own transmissions +pub const IFF_LINK0: c_int = 0x1000; // per link layer defined bit +pub const IFF_LINK1: c_int = 0x2000; // per link layer defined bit +pub const IFF_LINK2: c_int = 0x4000; // per link layer defined bit +pub const IFF_ALTPHYS: c_int = IFF_LINK2; // use alternate physical connection +pub const IFF_MULTICAST: c_int = 0x8000; // supports multicast + +cfg_if! { + if #[cfg(target_os = "vita")] { + pub const TCP_NODELAY: c_int = 1; + pub const TCP_MAXSEG: c_int = 2; + } else if #[cfg(target_os = "espidf")] { + pub const TCP_NODELAY: c_int = 1; + pub const TCP_MAXSEG: c_int = 8194; + } else { + pub const TCP_NODELAY: c_int = 8193; + pub const TCP_MAXSEG: c_int = 8194; + } +} + +pub const TCP_NOPUSH: c_int = 4; +pub const TCP_NOOPT: c_int = 8; +cfg_if! { + if #[cfg(target_os = "espidf")] { + pub const TCP_KEEPIDLE: c_int = 3; + pub const TCP_KEEPINTVL: c_int = 4; + pub const TCP_KEEPCNT: c_int = 5; + } else { + pub const TCP_KEEPIDLE: c_int = 256; + pub const TCP_KEEPINTVL: c_int = 512; + pub const TCP_KEEPCNT: c_int = 1024; + } +} + +cfg_if! { + if #[cfg(target_os = "horizon")] { + pub const IP_TOS: c_int = 7; + } else if #[cfg(target_os = "espidf")] { + pub const IP_TOS: c_int = 1; + } else { + pub const IP_TOS: c_int = 3; + } +} +cfg_if! { + if #[cfg(target_os = "vita")] { + pub const IP_TTL: c_int = 4; + } else if #[cfg(target_os = "espidf")] { + pub const IP_TTL: c_int = 2; + } else { + pub const IP_TTL: c_int = 8; + } +} + +cfg_if! { + if #[cfg(target_os = "espidf")] { + pub const IP_MULTICAST_IF: c_int = 6; + pub const IP_MULTICAST_TTL: c_int = 5; + pub const IP_MULTICAST_LOOP: c_int = 7; + } else { + pub const IP_MULTICAST_IF: c_int = 9; + pub const IP_MULTICAST_TTL: c_int = 10; + pub const IP_MULTICAST_LOOP: c_int = 11; + } +} + +cfg_if! { + if #[cfg(target_os = "vita")] { + pub const IP_ADD_MEMBERSHIP: c_int = 12; + pub const IP_DROP_MEMBERSHIP: c_int = 13; + } else if #[cfg(target_os = "espidf")] { + pub const IP_ADD_MEMBERSHIP: c_int = 3; + pub const IP_DROP_MEMBERSHIP: c_int = 4; + } else { + pub const IP_ADD_MEMBERSHIP: c_int = 11; + pub const IP_DROP_MEMBERSHIP: c_int = 12; + } +} +pub const IPV6_UNICAST_HOPS: c_int = 4; +cfg_if! { + if #[cfg(target_os = "espidf")] { + pub const IPV6_MULTICAST_IF: c_int = 768; + pub const IPV6_MULTICAST_HOPS: c_int = 769; + pub const IPV6_MULTICAST_LOOP: c_int = 770; + } else { + pub const IPV6_MULTICAST_IF: c_int = 9; + pub const IPV6_MULTICAST_HOPS: c_int = 10; + pub const IPV6_MULTICAST_LOOP: c_int = 11; + } +} +pub const IPV6_V6ONLY: c_int = 27; +pub const IPV6_JOIN_GROUP: c_int = 12; +pub const IPV6_LEAVE_GROUP: c_int = 13; +pub const IPV6_ADD_MEMBERSHIP: c_int = 12; +pub const IPV6_DROP_MEMBERSHIP: c_int = 13; + +cfg_if! { + if #[cfg(target_os = "espidf")] { + pub const HOST_NOT_FOUND: c_int = 210; + pub const NO_DATA: c_int = 211; + pub const NO_RECOVERY: c_int = 212; + pub const TRY_AGAIN: c_int = 213; + } else { + pub const HOST_NOT_FOUND: c_int = 1; + pub const NO_DATA: c_int = 2; + pub const NO_RECOVERY: c_int = 3; + pub const TRY_AGAIN: c_int = 4; + } +} +pub const NO_ADDRESS: c_int = 2; + +pub const AI_PASSIVE: c_int = 1; +pub const AI_CANONNAME: c_int = 2; +pub const AI_NUMERICHOST: c_int = 4; +cfg_if! { + if #[cfg(target_os = "espidf")] { + pub const AI_NUMERICSERV: c_int = 8; + pub const AI_ADDRCONFIG: c_int = 64; + } else { + pub const AI_NUMERICSERV: c_int = 0; + pub const AI_ADDRCONFIG: c_int = 0; + } +} + +pub const NI_MAXHOST: c_int = 1025; +pub const NI_MAXSERV: c_int = 32; +pub const NI_NOFQDN: c_int = 1; +pub const NI_NUMERICHOST: c_int = 2; +pub const NI_NAMEREQD: c_int = 4; +cfg_if! { + if #[cfg(target_os = "espidf")] { + pub const NI_NUMERICSERV: c_int = 8; + pub const NI_DGRAM: c_int = 16; + } else { + pub const NI_NUMERICSERV: c_int = 0; + pub const NI_DGRAM: c_int = 0; + } +} + +cfg_if! { + // Defined in vita/mod.rs for "vita" + if #[cfg(target_os = "espidf")] { + pub const EAI_FAMILY: c_int = 204; + pub const EAI_MEMORY: c_int = 203; + pub const EAI_NONAME: c_int = 200; + pub const EAI_SOCKTYPE: c_int = 10; + } else if #[cfg(not(target_os = "vita"))] { + pub const EAI_FAMILY: c_int = -303; + pub const EAI_MEMORY: c_int = -304; + pub const EAI_NONAME: c_int = -305; + pub const EAI_SOCKTYPE: c_int = -307; + } +} + +pub const EXIT_SUCCESS: c_int = 0; +pub const EXIT_FAILURE: c_int = 1; + +pub const PRIO_PROCESS: c_int = 0; +pub const PRIO_PGRP: c_int = 1; +pub const PRIO_USER: c_int = 2; + +f! { + pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { + let bits = size_of_val(&(*set).fds_bits[0]) * 8; + let fd = fd as usize; + (*set).fds_bits[fd / bits] &= !(1 << (fd % bits)); + return; + } + + pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { + let bits = size_of_val(&(*set).fds_bits[0]) * 8; + let fd = fd as usize; + return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0; + } + + pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { + let bits = size_of_val(&(*set).fds_bits[0]) * 8; + let fd = fd as usize; + (*set).fds_bits[fd / bits] |= 1 << (fd % bits); + return; + } + + pub fn FD_ZERO(set: *mut fd_set) -> () { + for slot in (*set).fds_bits.iter_mut() { + *slot = 0; + } + } +} + +extern "C" { + pub fn getrlimit(resource: c_int, rlim: *mut crate::rlimit) -> c_int; + pub fn setrlimit(resource: c_int, rlim: *const crate::rlimit) -> c_int; + + #[cfg_attr(target_os = "linux", link_name = "__xpg_strerror_r")] + pub fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int; + + pub fn sem_destroy(sem: *mut sem_t) -> c_int; + pub fn sem_init(sem: *mut sem_t, pshared: c_int, value: c_uint) -> c_int; + + pub fn abs(i: c_int) -> c_int; + pub fn labs(i: c_long) -> c_long; + pub fn rand() -> c_int; + pub fn srand(seed: c_uint); + + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] + #[cfg_attr(target_os = "espidf", link_name = "lwip_bind")] + pub fn bind(fd: c_int, addr: *const sockaddr, len: socklen_t) -> c_int; + pub fn clock_settime(clock_id: crate::clockid_t, tp: *const crate::timespec) -> c_int; + pub fn clock_gettime(clock_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; + pub fn clock_getres(clock_id: crate::clockid_t, res: *mut crate::timespec) -> c_int; + #[cfg_attr(target_os = "espidf", link_name = "lwip_close")] + pub fn closesocket(sockfd: c_int) -> c_int; + pub fn ioctl(fd: c_int, request: c_ulong, ...) -> c_int; + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] + #[cfg_attr(target_os = "espidf", link_name = "lwip_recvfrom")] + pub fn recvfrom( + fd: c_int, + buf: *mut c_void, + n: usize, + flags: c_int, + addr: *mut sockaddr, + addr_len: *mut socklen_t, + ) -> isize; + #[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))] + pub fn getnameinfo( + sa: *const sockaddr, + salen: socklen_t, + host: *mut c_char, + hostlen: socklen_t, + serv: *mut c_char, + servlen: socklen_t, + flags: c_int, + ) -> c_int; + pub fn memalign(align: size_t, size: size_t) -> *mut c_void; + + // DIFF(main): changed to `*const *mut` in e77f551de9 + pub fn fexecve(fd: c_int, argv: *const *const c_char, envp: *const *const c_char) -> c_int; + + pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut c_void) -> c_int; + pub fn getgrgid_r( + gid: crate::gid_t, + grp: *mut crate::group, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::group, + ) -> c_int; + pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> c_int; + pub fn sem_close(sem: *mut sem_t) -> c_int; + pub fn getdtablesize() -> c_int; + pub fn getgrnam_r( + name: *const c_char, + grp: *mut crate::group, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::group, + ) -> c_int; + pub fn pthread_sigmask(how: c_int, set: *const sigset_t, oldset: *mut sigset_t) -> c_int; + pub fn sem_open(name: *const c_char, oflag: c_int, ...) -> *mut sem_t; + pub fn getgrnam(name: *const c_char) -> *mut crate::group; + pub fn pthread_kill(thread: crate::pthread_t, sig: c_int) -> c_int; + pub fn sem_unlink(name: *const c_char) -> c_int; + pub fn daemon(nochdir: c_int, noclose: c_int) -> c_int; + pub fn getpwnam_r( + name: *const c_char, + pwd: *mut passwd, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut passwd, + ) -> c_int; + pub fn getpwuid_r( + uid: crate::uid_t, + pwd: *mut passwd, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut passwd, + ) -> c_int; + pub fn sigwait(set: *const sigset_t, sig: *mut c_int) -> c_int; + pub fn pthread_atfork( + prepare: Option, + parent: Option, + child: Option, + ) -> c_int; + pub fn getgrgid(gid: crate::gid_t) -> *mut crate::group; + pub fn popen(command: *const c_char, mode: *const c_char) -> *mut crate::FILE; + pub fn uname(buf: *mut crate::utsname) -> c_int; +} + +mod generic; + +cfg_if! { + if #[cfg(target_os = "espidf")] { + mod espidf; + pub use self::espidf::*; + } else if #[cfg(target_os = "horizon")] { + mod horizon; + pub use self::horizon::*; + } else if #[cfg(target_os = "vita")] { + mod vita; + pub use self::vita::*; + } else if #[cfg(target_arch = "arm")] { + mod arm; + pub use self::arm::*; + } else if #[cfg(target_arch = "aarch64")] { + mod aarch64; + pub use self::aarch64::*; + } else if #[cfg(target_arch = "powerpc")] { + mod powerpc; + pub use self::powerpc::*; + } else { + // Only tested on ARM so far. Other platforms might have different + // definitions for types and constants. + pub use target_arch_not_implemented; + } +} + +cfg_if! { + if #[cfg(target_os = "rtems")] { + mod rtems; + pub use self::rtems::*; + } +} diff --git a/http/vendor/libc/src/unix/newlib/powerpc/mod.rs b/http/vendor/libc/src/unix/newlib/powerpc/mod.rs new file mode 100644 index 0000000..f51a1b2 --- /dev/null +++ b/http/vendor/libc/src/unix/newlib/powerpc/mod.rs @@ -0,0 +1,18 @@ +use crate::prelude::*; + +pub type clock_t = c_ulong; +pub type wchar_t = c_int; + +pub use crate::unix::newlib::generic::{ + dirent, + sigset_t, + stat, +}; + +// the newlib shipped with devkitPPC does not support the following components: +// - sockaddr +// - AF_INET6 +// - FIONBIO +// - POLL* +// - SOL_SOCKET +// - MSG_* diff --git a/http/vendor/libc/src/unix/newlib/rtems/mod.rs b/http/vendor/libc/src/unix/newlib/rtems/mod.rs new file mode 100644 index 0000000..ec4534e --- /dev/null +++ b/http/vendor/libc/src/unix/newlib/rtems/mod.rs @@ -0,0 +1,144 @@ +// defined in architecture specific module + +use crate::prelude::*; + +s! { + pub struct sockaddr_un { + pub sun_family: crate::sa_family_t, + pub sun_path: [c_char; 108usize], + } +} + +pub const AF_UNIX: c_int = 1; + +pub const RTLD_DEFAULT: *mut c_void = -2isize as *mut c_void; + +pub const UTIME_OMIT: c_long = -1; +pub const AT_FDCWD: c_int = -2; + +pub const O_DIRECTORY: c_int = 0x200000; +pub const O_NOFOLLOW: c_int = 0x100000; + +pub const AT_EACCESS: c_int = 1; +pub const AT_SYMLINK_NOFOLLOW: c_int = 2; +pub const AT_SYMLINK_FOLLOW: c_int = 4; +pub const AT_REMOVEDIR: c_int = 8; + +// signal.h +pub const SIG_BLOCK: c_int = 1; +pub const SIG_UNBLOCK: c_int = 2; +pub const SIG_SETMASK: c_int = 0; +pub const SIGHUP: c_int = 1; +pub const SIGINT: c_int = 2; +pub const SIGQUIT: c_int = 3; +pub const SIGILL: c_int = 4; +pub const SIGTRAP: c_int = 5; +pub const SIGABRT: c_int = 6; +pub const SIGEMT: c_int = 7; +pub const SIGFPE: c_int = 8; +pub const SIGKILL: c_int = 9; +pub const SIGBUS: c_int = 10; +pub const SIGSEGV: c_int = 11; +pub const SIGSYS: c_int = 12; +pub const SIGPIPE: c_int = 13; +pub const SIGALRM: c_int = 14; +pub const SIGTERM: c_int = 15; +pub const SIGURG: c_int = 16; +pub const SIGSTOP: c_int = 17; +pub const SIGTSTP: c_int = 18; +pub const SIGCONT: c_int = 19; +pub const SIGCHLD: c_int = 20; +pub const SIGCLD: c_int = 20; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGIO: c_int = 23; +pub const SIGWINCH: c_int = 24; +pub const SIGUSR1: c_int = 25; +pub const SIGUSR2: c_int = 26; +pub const SIGRTMIN: c_int = 27; +pub const SIGRTMAX: c_int = 31; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; + +pub const SA_NOCLDSTOP: c_ulong = 0x00000001; +pub const SA_SIGINFO: c_ulong = 0x00000002; +pub const SA_ONSTACK: c_ulong = 0x00000004; + +pub const EAI_AGAIN: c_int = 2; +pub const EAI_BADFLAGS: c_int = 3; +pub const EAI_FAIL: c_int = 4; +pub const EAI_SERVICE: c_int = 9; +pub const EAI_SYSTEM: c_int = 11; +pub const EAI_OVERFLOW: c_int = 14; + +pub const PTHREAD_STACK_MIN: size_t = 0; + +// sys/wait.h +pub const WNOHANG: c_int = 1; +pub const WUNTRACED: c_int = 2; + +// sys/socket.h +pub const SOMAXCONN: c_int = 128; + +safe_f! { + pub const fn WIFSTOPPED(status: c_int) -> bool { + (status & 0xff) == 0x7f + } + + pub const fn WSTOPSIG(status: c_int) -> c_int { + // (status >> 8) & 0xff + WEXITSTATUS(status) + } + + pub const fn WIFSIGNALED(status: c_int) -> bool { + ((status & 0x7f) > 0) && ((status & 0x7f) < 0x7f) + } + + pub const fn WTERMSIG(status: c_int) -> c_int { + status & 0x7f + } + + pub const fn WIFEXITED(status: c_int) -> bool { + (status & 0xff) == 0 + } + + pub const fn WEXITSTATUS(status: c_int) -> c_int { + (status >> 8) & 0xff + } + + // RTEMS doesn't have native WIFCONTINUED. + pub const fn WIFCONTINUED(_status: c_int) -> bool { + true + } + + // RTEMS doesn't have native WCOREDUMP. + pub const fn WCOREDUMP(_status: c_int) -> bool { + false + } +} + +extern "C" { + pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int; + pub fn writev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; + pub fn readv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; + + pub fn pthread_create( + native: *mut crate::pthread_t, + attr: *const crate::pthread_attr_t, + f: extern "C" fn(_: *mut c_void) -> *mut c_void, + value: *mut c_void, + ) -> c_int; + + pub fn pthread_condattr_setclock( + attr: *mut crate::pthread_condattr_t, + clock_id: crate::clockid_t, + ) -> c_int; + + pub fn getentropy(buf: *mut c_void, buflen: size_t) -> c_int; + + pub fn arc4random_buf(buf: *mut core::ffi::c_void, nbytes: size_t); + + pub fn setgroups(ngroups: c_int, grouplist: *const crate::gid_t) -> c_int; +} diff --git a/http/vendor/libc/src/unix/newlib/vita/mod.rs b/http/vendor/libc/src/unix/newlib/vita/mod.rs new file mode 100644 index 0000000..95abf90 --- /dev/null +++ b/http/vendor/libc/src/unix/newlib/vita/mod.rs @@ -0,0 +1,233 @@ +use crate::off_t; +use crate::prelude::*; + +pub type clock_t = c_long; + +pub type wchar_t = u32; + +pub type sigset_t = c_ulong; + +s! { + pub struct msghdr { + pub msg_name: *mut c_void, + pub msg_namelen: crate::socklen_t, + pub msg_iov: *mut crate::iovec, + pub msg_iovlen: c_int, + pub msg_control: *mut c_void, + pub msg_controllen: crate::socklen_t, + pub msg_flags: c_int, + } + + pub struct sockaddr { + pub sa_len: u8, + pub sa_family: crate::sa_family_t, + pub sa_data: [c_char; 14], + } + + pub struct sockaddr_in6 { + pub sin6_len: u8, + pub sin6_family: crate::sa_family_t, + pub sin6_port: crate::in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: crate::in6_addr, + pub sin6_vport: crate::in_port_t, + pub sin6_scope_id: u32, + } + + pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: crate::sa_family_t, + pub sin_port: crate::in_port_t, + pub sin_addr: crate::in_addr, + pub sin_vport: crate::in_port_t, + pub sin_zero: [u8; 6], + } + + pub struct sockaddr_un { + pub ss_len: u8, + pub sun_family: crate::sa_family_t, + pub sun_path: [c_char; 108usize], + } + + pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: crate::sa_family_t, + __ss_pad1: Padding<[u8; 2]>, + __ss_align: i64, + __ss_pad2: Padding<[u8; 116]>, + } + + pub struct sched_param { + pub sched_priority: c_int, + } + + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_mode: crate::mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + pub st_size: off_t, + pub st_atime: crate::time_t, + pub st_mtime: crate::time_t, + pub st_ctime: crate::time_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + pub st_spare4: [c_long; 2usize], + } + + #[repr(align(8))] + pub struct dirent { + __offset: [u8; 88], + pub d_name: [c_char; 256usize], + __pad: Padding<[u8; 8]>, + } +} + +pub const AF_UNIX: c_int = 1; +pub const AF_INET6: c_int = 24; + +pub const SOCK_RAW: c_int = 3; +pub const SOCK_RDM: c_int = 4; +pub const SOCK_SEQPACKET: c_int = 5; + +pub const SOMAXCONN: c_int = 128; + +pub const FIONBIO: c_ulong = 1; + +pub const POLLIN: c_short = 0x0001; +pub const POLLPRI: c_short = POLLIN; +pub const POLLOUT: c_short = 0x0004; +pub const POLLRDNORM: c_short = POLLIN; +pub const POLLRDBAND: c_short = POLLIN; +pub const POLLWRNORM: c_short = POLLOUT; +pub const POLLWRBAND: c_short = POLLOUT; +pub const POLLERR: c_short = 0x0008; +pub const POLLHUP: c_short = 0x0010; +pub const POLLNVAL: c_short = 0x0020; + +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); + +pub const SOL_SOCKET: c_int = 0xffff; +pub const SO_NONBLOCK: c_int = 0x1100; + +pub const MSG_OOB: c_int = 0x1; +pub const MSG_PEEK: c_int = 0x2; +pub const MSG_DONTROUTE: c_int = 0x4; +pub const MSG_EOR: c_int = 0x8; +pub const MSG_TRUNC: c_int = 0x10; +pub const MSG_CTRUNC: c_int = 0x20; +pub const MSG_WAITALL: c_int = 0x40; +pub const MSG_DONTWAIT: c_int = 0x80; +pub const MSG_BCAST: c_int = 0x100; +pub const MSG_MCAST: c_int = 0x200; + +pub const UTIME_OMIT: c_long = -1; +pub const AT_FDCWD: c_int = -2; + +pub const O_DIRECTORY: c_int = 0x200000; +pub const O_NOFOLLOW: c_int = 0x100000; + +pub const AT_EACCESS: c_int = 1; +pub const AT_SYMLINK_NOFOLLOW: c_int = 2; +pub const AT_SYMLINK_FOLLOW: c_int = 4; +pub const AT_REMOVEDIR: c_int = 8; + +pub const SIGHUP: c_int = 1; +pub const SIGINT: c_int = 2; +pub const SIGQUIT: c_int = 3; +pub const SIGILL: c_int = 4; +pub const SIGTRAP: c_int = 5; +pub const SIGABRT: c_int = 6; +pub const SIGEMT: c_int = 7; +pub const SIGFPE: c_int = 8; +pub const SIGKILL: c_int = 9; +pub const SIGBUS: c_int = 10; +pub const SIGSEGV: c_int = 11; +pub const SIGSYS: c_int = 12; +pub const SIGPIPE: c_int = 13; +pub const SIGALRM: c_int = 14; +pub const SIGTERM: c_int = 15; + +pub const EAI_BADFLAGS: c_int = -1; +pub const EAI_NONAME: c_int = -2; +pub const EAI_AGAIN: c_int = -3; +pub const EAI_FAIL: c_int = -4; +pub const EAI_NODATA: c_int = -5; +pub const EAI_FAMILY: c_int = -6; +pub const EAI_SOCKTYPE: c_int = -7; +pub const EAI_SERVICE: c_int = -8; +pub const EAI_ADDRFAMILY: c_int = -9; +pub const EAI_MEMORY: c_int = -10; +pub const EAI_SYSTEM: c_int = -11; +pub const EAI_OVERFLOW: c_int = -12; + +pub const PTHREAD_STACK_MIN: size_t = 32 * 1024; + +pub const IP_HDRINCL: c_int = 2; + +extern "C" { + pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int; + pub fn writev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; + pub fn readv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; + + pub fn sendmsg(s: c_int, msg: *const crate::msghdr, flags: c_int) -> ssize_t; + pub fn recvmsg(s: c_int, msg: *mut crate::msghdr, flags: c_int) -> ssize_t; + + pub fn pthread_create( + native: *mut crate::pthread_t, + attr: *const crate::pthread_attr_t, + f: extern "C" fn(_: *mut c_void) -> *mut c_void, + value: *mut c_void, + ) -> c_int; + + pub fn pthread_attr_getschedparam( + attr: *const crate::pthread_attr_t, + param: *mut sched_param, + ) -> c_int; + + pub fn pthread_attr_setschedparam( + attr: *mut crate::pthread_attr_t, + param: *const sched_param, + ) -> c_int; + + pub fn pthread_attr_getprocessorid_np( + attr: *const crate::pthread_attr_t, + processor_id: *mut c_int, + ) -> c_int; + + pub fn pthread_attr_setprocessorid_np( + attr: *mut crate::pthread_attr_t, + processor_id: c_int, + ) -> c_int; + + pub fn pthread_getschedparam( + native: crate::pthread_t, + policy: *mut c_int, + param: *mut crate::sched_param, + ) -> c_int; + + pub fn pthread_setschedparam( + native: crate::pthread_t, + policy: c_int, + param: *const crate::sched_param, + ) -> c_int; + + pub fn pthread_condattr_getclock( + attr: *const crate::pthread_condattr_t, + clock_id: *mut crate::clockid_t, + ) -> c_int; + + pub fn pthread_condattr_setclock( + attr: *mut crate::pthread_condattr_t, + clock_id: crate::clockid_t, + ) -> c_int; + + pub fn pthread_getprocessorid_np() -> c_int; + + pub fn getentropy(buf: *mut c_void, buflen: size_t) -> c_int; + + pub fn pipe2(fds: *mut c_int, flags: c_int) -> c_int; +} diff --git a/http/vendor/libc/src/unix/nto/aarch64.rs b/http/vendor/libc/src/unix/nto/aarch64.rs new file mode 100644 index 0000000..559ab6e --- /dev/null +++ b/http/vendor/libc/src/unix/nto/aarch64.rs @@ -0,0 +1,35 @@ +use crate::prelude::*; + +pub type wchar_t = u32; +pub type time_t = i64; + +s! { + pub struct aarch64_qreg_t { + pub qlo: u64, + pub qhi: u64, + } + + pub struct aarch64_fpu_registers { + pub reg: [crate::aarch64_qreg_t; 32], + pub fpsr: u32, + pub fpcr: u32, + } + + pub struct aarch64_cpu_registers { + pub gpr: [u64; 32], + pub elr: u64, + pub pstate: u64, + } + + #[repr(align(16))] + pub struct mcontext_t { + pub cpu: crate::aarch64_cpu_registers, + pub fpu: crate::aarch64_fpu_registers, + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_size: size_t, + pub ss_flags: c_int, + } +} diff --git a/http/vendor/libc/src/unix/nto/mod.rs b/http/vendor/libc/src/unix/nto/mod.rs new file mode 100644 index 0000000..022fb0b --- /dev/null +++ b/http/vendor/libc/src/unix/nto/mod.rs @@ -0,0 +1,3216 @@ +use crate::prelude::*; + +pub type clock_t = u32; + +pub type sa_family_t = u8; +pub type speed_t = c_uint; +pub type tcflag_t = c_uint; +pub type clockid_t = c_int; +pub type timer_t = c_int; +pub type key_t = c_uint; +pub type id_t = c_int; + +pub type useconds_t = u32; +pub type dev_t = u32; +pub type socklen_t = u32; +pub type mode_t = u32; +pub type rlim64_t = u64; +pub type mqd_t = c_int; +pub type nfds_t = c_uint; +pub type idtype_t = c_uint; +pub type errno_t = c_int; +pub type rsize_t = c_ulong; + +pub type Elf32_Half = u16; +pub type Elf32_Word = u32; +pub type Elf32_Off = u32; +pub type Elf32_Addr = u32; +pub type Elf32_Lword = u64; +pub type Elf32_Sword = i32; + +pub type Elf64_Half = u16; +pub type Elf64_Word = u32; +pub type Elf64_Off = u64; +pub type Elf64_Addr = u64; +pub type Elf64_Xword = u64; +pub type Elf64_Sxword = i64; +pub type Elf64_Lword = u64; +pub type Elf64_Sword = i32; + +pub type Elf32_Section = u16; +pub type Elf64_Section = u16; + +pub type _Time32t = u32; + +pub type pthread_t = c_int; +pub type regoff_t = ssize_t; + +pub type nlink_t = u32; +pub type blksize_t = u32; +pub type suseconds_t = i32; + +pub type ino_t = u64; +pub type off_t = i64; +pub type blkcnt_t = u64; +pub type msgqnum_t = u64; +pub type msglen_t = u64; +pub type fsblkcnt_t = u64; +pub type fsfilcnt_t = u64; +pub type rlim_t = u64; +pub type posix_spawn_file_actions_t = *mut c_void; +pub type posix_spawnattr_t = crate::uintptr_t; + +pub type pthread_mutex_t = crate::sync_t; +pub type pthread_mutexattr_t = crate::_sync_attr; +pub type pthread_cond_t = crate::sync_t; +pub type pthread_condattr_t = crate::_sync_attr; +pub type pthread_rwlockattr_t = crate::_sync_attr; +pub type pthread_key_t = c_int; +pub type pthread_spinlock_t = sync_t; +pub type pthread_barrierattr_t = _sync_attr; +pub type sem_t = sync_t; + +pub type nl_item = c_int; + +extern_ty! { + pub enum timezone {} +} + +s! { + pub struct dirent_extra { + pub d_datalen: u16, + pub d_type: u16, + d_reserved: Padding, + } + + pub struct stat { + pub st_ino: crate::ino_t, + pub st_size: off_t, + pub st_dev: crate::dev_t, + pub st_rdev: crate::dev_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub __old_st_mtime: crate::_Time32t, + pub __old_st_atime: crate::_Time32t, + pub __old_st_ctime: crate::_Time32t, + pub st_mode: mode_t, + pub st_nlink: crate::nlink_t, + pub st_blocksize: crate::blksize_t, + pub st_nblocks: i32, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + pub st_mtim: crate::timespec, + pub st_atim: crate::timespec, + pub st_ctim: crate::timespec, + } + + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + #[cfg_attr(any(target_env = "nto71", target_env = "nto70"), repr(packed))] + pub struct in_addr { + pub s_addr: crate::in_addr_t, + } + + pub struct sockaddr { + pub sa_len: u8, + pub sa_family: sa_family_t, + pub sa_data: [c_char; 14], + } + + #[cfg(not(target_env = "nto71_iosock"))] + pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: sa_family_t, + pub sin_port: crate::in_port_t, + pub sin_addr: crate::in_addr, + pub sin_zero: [i8; 8], + } + + #[cfg(target_env = "nto71_iosock")] + pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: sa_family_t, + pub sin_port: crate::in_port_t, + pub sin_addr: crate::in_addr, + pub sin_zero: [c_char; 8], + } + + pub struct sockaddr_in6 { + pub sin6_len: u8, + pub sin6_family: sa_family_t, + pub sin6_port: crate::in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: crate::in6_addr, + pub sin6_scope_id: u32, + } + + // The order of the `ai_addr` field in this struct is crucial + // for converting between the Rust and C types. + pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: socklen_t, + pub ai_canonname: *mut c_char, + pub ai_addr: *mut crate::sockaddr, + pub ai_next: *mut addrinfo, + } + + pub struct fd_set { + fds_bits: [c_uint; 2 * FD_SETSIZE as usize / ULONG_SIZE], + } + + pub struct tm { + pub tm_sec: c_int, + pub tm_min: c_int, + pub tm_hour: c_int, + pub tm_mday: c_int, + pub tm_mon: c_int, + pub tm_year: c_int, + pub tm_wday: c_int, + pub tm_yday: c_int, + pub tm_isdst: c_int, + pub tm_gmtoff: c_long, + pub tm_zone: *const c_char, + } + + #[repr(align(8))] + pub struct sched_param { + pub sched_priority: c_int, + pub sched_curpriority: c_int, + reserved: Padding<[c_int; 10]>, + } + + #[repr(align(8))] + pub struct __sched_param { + pub __sched_priority: c_int, + pub __sched_curpriority: c_int, + reserved: Padding<[c_int; 10]>, + } + + pub struct Dl_info { + pub dli_fname: *const c_char, + pub dli_fbase: *mut c_void, + pub dli_sname: *const c_char, + pub dli_saddr: *mut c_void, + } + + pub struct lconv { + pub currency_symbol: *mut c_char, + pub int_curr_symbol: *mut c_char, + pub mon_decimal_point: *mut c_char, + pub mon_grouping: *mut c_char, + pub mon_thousands_sep: *mut c_char, + pub negative_sign: *mut c_char, + pub positive_sign: *mut c_char, + pub frac_digits: c_char, + pub int_frac_digits: c_char, + pub n_cs_precedes: c_char, + pub n_sep_by_space: c_char, + pub n_sign_posn: c_char, + pub p_cs_precedes: c_char, + pub p_sep_by_space: c_char, + pub p_sign_posn: c_char, + + pub int_n_cs_precedes: c_char, + pub int_n_sep_by_space: c_char, + pub int_n_sign_posn: c_char, + pub int_p_cs_precedes: c_char, + pub int_p_sep_by_space: c_char, + pub int_p_sign_posn: c_char, + + pub decimal_point: *mut c_char, + pub grouping: *mut c_char, + pub thousands_sep: *mut c_char, + + pub _Frac_grouping: *mut c_char, + pub _Frac_sep: *mut c_char, + pub _False: *mut c_char, + pub _True: *mut c_char, + + pub _No: *mut c_char, + pub _Yes: *mut c_char, + pub _Nostr: *mut c_char, + pub _Yesstr: *mut c_char, + _Reserved: Padding<[*mut c_char; 8]>, + } + + // Does not exist in io-sock + #[cfg(not(target_env = "nto71_iosock"))] + pub struct in_pktinfo { + pub ipi_addr: crate::in_addr, + pub ipi_ifindex: c_uint, + } + + pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut c_char, + pub ifa_flags: c_uint, + pub ifa_addr: *mut crate::sockaddr, + pub ifa_netmask: *mut crate::sockaddr, + pub ifa_dstaddr: *mut crate::sockaddr, + pub ifa_data: *mut c_void, + } + + pub struct arpreq { + pub arp_pa: crate::sockaddr, + pub arp_ha: crate::sockaddr, + pub arp_flags: c_int, + } + + #[cfg_attr(any(target_env = "nto71", target_env = "nto70"), repr(packed))] + pub struct arphdr { + pub ar_hrd: u16, + pub ar_pro: u16, + pub ar_hln: u8, + pub ar_pln: u8, + pub ar_op: u16, + } + + #[cfg(not(target_env = "nto71_iosock"))] + pub struct mmsghdr { + pub msg_hdr: crate::msghdr, + pub msg_len: c_uint, + } + + #[cfg(target_env = "nto71_iosock")] + pub struct mmsghdr { + pub msg_hdr: crate::msghdr, + pub msg_len: ssize_t, + } + + #[repr(align(8))] + pub struct siginfo_t { + pub si_signo: c_int, + pub si_code: c_int, + pub si_errno: c_int, + __data: [u8; 36], // union + } + + pub struct sigaction { + pub sa_sigaction: crate::sighandler_t, + pub sa_flags: c_int, + pub sa_mask: crate::sigset_t, + } + + pub struct _sync { + _union: c_uint, + __owner: c_uint, + } + pub struct rlimit64 { + pub rlim_cur: rlim64_t, + pub rlim_max: rlim64_t, + } + + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct glob_t { + pub gl_pathc: size_t, + pub gl_matchc: c_int, + pub gl_pathv: *mut *mut c_char, + pub gl_offs: size_t, + pub gl_flags: c_int, + pub gl_errfunc: extern "C" fn(*const c_char, c_int) -> c_int, + + __unused1: Padding<*mut c_void>, + __unused2: Padding<*mut c_void>, + __unused3: Padding<*mut c_void>, + __unused4: Padding<*mut c_void>, + __unused5: Padding<*mut c_void>, + } + + pub struct passwd { + pub pw_name: *mut c_char, + pub pw_passwd: *mut c_char, + pub pw_uid: crate::uid_t, + pub pw_gid: crate::gid_t, + pub pw_age: *mut c_char, + pub pw_comment: *mut c_char, + pub pw_gecos: *mut c_char, + pub pw_dir: *mut c_char, + pub pw_shell: *mut c_char, + } + + pub struct if_nameindex { + pub if_index: c_uint, + pub if_name: *mut c_char, + } + + pub struct sembuf { + pub sem_num: c_ushort, + pub sem_op: c_short, + pub sem_flg: c_short, + } + + pub struct Elf32_Ehdr { + pub e_ident: [c_uchar; 16], + pub e_type: Elf32_Half, + pub e_machine: Elf32_Half, + pub e_version: Elf32_Word, + pub e_entry: Elf32_Addr, + pub e_phoff: Elf32_Off, + pub e_shoff: Elf32_Off, + pub e_flags: Elf32_Word, + pub e_ehsize: Elf32_Half, + pub e_phentsize: Elf32_Half, + pub e_phnum: Elf32_Half, + pub e_shentsize: Elf32_Half, + pub e_shnum: Elf32_Half, + pub e_shstrndx: Elf32_Half, + } + + pub struct Elf64_Ehdr { + pub e_ident: [c_uchar; 16], + pub e_type: Elf64_Half, + pub e_machine: Elf64_Half, + pub e_version: Elf64_Word, + pub e_entry: Elf64_Addr, + pub e_phoff: Elf64_Off, + pub e_shoff: Elf64_Off, + pub e_flags: Elf64_Word, + pub e_ehsize: Elf64_Half, + pub e_phentsize: Elf64_Half, + pub e_phnum: Elf64_Half, + pub e_shentsize: Elf64_Half, + pub e_shnum: Elf64_Half, + pub e_shstrndx: Elf64_Half, + } + + pub struct Elf32_Sym { + pub st_name: Elf32_Word, + pub st_value: Elf32_Addr, + pub st_size: Elf32_Word, + pub st_info: c_uchar, + pub st_other: c_uchar, + pub st_shndx: Elf32_Section, + } + + pub struct Elf64_Sym { + pub st_name: Elf64_Word, + pub st_info: c_uchar, + pub st_other: c_uchar, + pub st_shndx: Elf64_Section, + pub st_value: Elf64_Addr, + pub st_size: Elf64_Xword, + } + + pub struct Elf32_Phdr { + pub p_type: Elf32_Word, + pub p_offset: Elf32_Off, + pub p_vaddr: Elf32_Addr, + pub p_paddr: Elf32_Addr, + pub p_filesz: Elf32_Word, + pub p_memsz: Elf32_Word, + pub p_flags: Elf32_Word, + pub p_align: Elf32_Word, + } + + pub struct Elf64_Phdr { + pub p_type: Elf64_Word, + pub p_flags: Elf64_Word, + pub p_offset: Elf64_Off, + pub p_vaddr: Elf64_Addr, + pub p_paddr: Elf64_Addr, + pub p_filesz: Elf64_Xword, + pub p_memsz: Elf64_Xword, + pub p_align: Elf64_Xword, + } + + pub struct Elf32_Shdr { + pub sh_name: Elf32_Word, + pub sh_type: Elf32_Word, + pub sh_flags: Elf32_Word, + pub sh_addr: Elf32_Addr, + pub sh_offset: Elf32_Off, + pub sh_size: Elf32_Word, + pub sh_link: Elf32_Word, + pub sh_info: Elf32_Word, + pub sh_addralign: Elf32_Word, + pub sh_entsize: Elf32_Word, + } + + pub struct Elf64_Shdr { + pub sh_name: Elf64_Word, + pub sh_type: Elf64_Word, + pub sh_flags: Elf64_Xword, + pub sh_addr: Elf64_Addr, + pub sh_offset: Elf64_Off, + pub sh_size: Elf64_Xword, + pub sh_link: Elf64_Word, + pub sh_info: Elf64_Word, + pub sh_addralign: Elf64_Xword, + pub sh_entsize: Elf64_Xword, + } + + pub struct in6_pktinfo { + pub ipi6_addr: crate::in6_addr, + pub ipi6_ifindex: c_uint, + } + + pub struct inotify_event { + pub wd: c_int, + pub mask: u32, + pub cookie: u32, + pub len: u32, + } + + pub struct regmatch_t { + pub rm_so: regoff_t, + pub rm_eo: regoff_t, + } + + pub struct msghdr { + pub msg_name: *mut c_void, + pub msg_namelen: crate::socklen_t, + pub msg_iov: *mut crate::iovec, + pub msg_iovlen: c_int, + pub msg_control: *mut c_void, + pub msg_controllen: crate::socklen_t, + pub msg_flags: c_int, + } + + pub struct cmsghdr { + pub cmsg_len: crate::socklen_t, + pub cmsg_level: c_int, + pub cmsg_type: c_int, + } + + pub struct termios { + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_cc: [crate::cc_t; crate::NCCS], + __reserved: Padding<[c_uint; 3]>, + pub c_ispeed: crate::speed_t, + pub c_ospeed: crate::speed_t, + } + + pub struct mallinfo { + pub arena: c_int, + pub ordblks: c_int, + pub smblks: c_int, + pub hblks: c_int, + pub hblkhd: c_int, + pub usmblks: c_int, + pub fsmblks: c_int, + pub uordblks: c_int, + pub fordblks: c_int, + pub keepcost: c_int, + } + + pub struct flock { + pub l_type: i16, + pub l_whence: i16, + pub l_zero1: i32, + pub l_start: off_t, + pub l_len: off_t, + pub l_pid: crate::pid_t, + pub l_sysid: u32, + } + + pub struct statvfs { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_favail: crate::fsfilcnt_t, + pub f_fsid: c_ulong, + pub f_basetype: [c_char; 16], + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + f_filler: [c_uint; 21], + } + + pub struct aiocb { + pub aio_fildes: c_int, + pub aio_reqprio: c_int, + pub aio_offset: off_t, + pub aio_buf: *mut c_void, + pub aio_nbytes: size_t, + pub aio_sigevent: crate::sigevent, + pub aio_lio_opcode: c_int, + pub _aio_lio_state: *mut c_void, + _aio_pad: Padding<[c_int; 3]>, + pub _aio_next: *mut crate::aiocb, + pub _aio_flag: c_uint, + pub _aio_iotype: c_uint, + pub _aio_result: ssize_t, + pub _aio_error: c_uint, + pub _aio_suspend: *mut c_void, + pub _aio_plist: *mut c_void, + pub _aio_policy: c_int, + pub _aio_param: crate::__sched_param, + } + + pub struct pthread_attr_t { + __data1: c_long, + __data2: [u8; 96], + } + + pub struct ipc_perm { + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: mode_t, + pub seq: c_uint, + pub key: crate::key_t, + _reserved: Padding<[c_int; 4]>, + } + + pub struct regex_t { + re_magic: c_int, + re_nsub: size_t, + re_endp: *const c_char, + re_g: *mut c_void, + } + + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct _thread_attr { + pub __flags: c_int, + pub __stacksize: size_t, + pub __stackaddr: *mut c_void, + pub __exitfunc: Option, + pub __policy: c_int, + pub __param: crate::__sched_param, + pub __guardsize: c_uint, + pub __prealloc: c_uint, + __spare: [c_int; 2], + } + + pub struct _sync_attr { + pub __protocol: c_int, + pub __flags: c_int, + pub __prioceiling: c_int, + pub __clockid: c_int, + pub __count: c_int, + __reserved: Padding<[c_int; 3]>, + } + + pub struct sockcred { + pub sc_uid: crate::uid_t, + pub sc_euid: crate::uid_t, + pub sc_gid: crate::gid_t, + pub sc_egid: crate::gid_t, + pub sc_ngroups: c_int, + pub sc_groups: [crate::gid_t; 1], + } + + pub struct bpf_program { + pub bf_len: c_uint, + pub bf_insns: *mut crate::bpf_insn, + } + + #[cfg(not(target_env = "nto71_iosock"))] + pub struct bpf_stat { + pub bs_recv: u64, + pub bs_drop: u64, + pub bs_capt: u64, + bs_padding: Padding<[u64; 13]>, + } + + #[cfg(target_env = "nto71_iosock")] + pub struct bpf_stat { + pub bs_recv: c_uint, + pub bs_drop: c_uint, + } + + pub struct bpf_version { + pub bv_major: c_ushort, + pub bv_minor: c_ushort, + } + + pub struct bpf_hdr { + pub bh_tstamp: crate::timeval, + pub bh_caplen: u32, + pub bh_datalen: u32, + pub bh_hdrlen: u16, + } + + pub struct bpf_insn { + pub code: u16, + pub jt: c_uchar, + pub jf: c_uchar, + pub k: u32, + } + + pub struct bpf_dltlist { + pub bfl_len: c_uint, + pub bfl_list: *mut c_uint, + } + + // Does not exist in io-sock + #[cfg(not(target_env = "nto71_iosock"))] + pub struct unpcbid { + pub unp_pid: crate::pid_t, + pub unp_euid: crate::uid_t, + pub unp_egid: crate::gid_t, + } + + pub struct dl_phdr_info { + pub dlpi_addr: crate::Elf64_Addr, + pub dlpi_name: *const c_char, + pub dlpi_phdr: *const crate::Elf64_Phdr, + pub dlpi_phnum: crate::Elf64_Half, + } + + #[repr(align(8))] + pub struct ucontext_t { + pub uc_link: *mut ucontext_t, + pub uc_sigmask: crate::sigset_t, + pub uc_stack: stack_t, + pub uc_mcontext: mcontext_t, + } + pub struct sockaddr_un { + pub sun_len: u8, + pub sun_family: sa_family_t, + pub sun_path: [c_char; 104], + } + + pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: sa_family_t, + __ss_pad1: Padding<[c_char; 6]>, + __ss_align: i64, + __ss_pad2: Padding<[c_char; 112]>, + } + + pub struct utsname { + pub sysname: [c_char; _SYSNAME_SIZE], + pub nodename: [c_char; _SYSNAME_SIZE], + pub release: [c_char; _SYSNAME_SIZE], + pub version: [c_char; _SYSNAME_SIZE], + pub machine: [c_char; _SYSNAME_SIZE], + } + + pub struct sigevent { + pub sigev_notify: c_int, + __padding1: Padding, + pub sigev_signo: c_int, // union + __padding2: Padding, + pub sigev_value: crate::sigval, + __sigev_un2: usize, // union + } + pub struct dirent { + pub d_ino: crate::ino_t, + pub d_offset: off_t, + pub d_reclen: c_short, + pub d_namelen: c_short, + pub d_name: [c_char; 1], // flex array + } + + pub struct sigset_t { + __val: [u32; 2], + } + + pub struct mq_attr { + pub mq_maxmsg: c_long, + pub mq_msgsize: c_long, + pub mq_flags: c_long, + pub mq_curmsgs: c_long, + pub mq_sendwait: c_long, + pub mq_recvwait: c_long, + } + + #[cfg(not(target_env = "nto71_iosock"))] + pub struct sockaddr_dl { + pub sdl_len: c_uchar, + pub sdl_family: crate::sa_family_t, + pub sdl_index: u16, + pub sdl_type: c_uchar, + pub sdl_nlen: c_uchar, + pub sdl_alen: c_uchar, + pub sdl_slen: c_uchar, + pub sdl_data: [c_char; 12], + } + + #[cfg(target_env = "nto71_iosock")] + pub struct sockaddr_dl { + pub sdl_len: c_uchar, + pub sdl_family: c_uchar, + pub sdl_index: c_ushort, + pub sdl_type: c_uchar, + pub sdl_nlen: c_uchar, + pub sdl_alen: c_uchar, + pub sdl_slen: c_uchar, + pub sdl_data: [c_char; 46], + } +} + +s_no_extra_traits! { + pub struct msg { + pub msg_next: *mut crate::msg, + pub msg_type: c_long, + pub msg_ts: c_ushort, + pub msg_spot: c_short, + _pad: Padding<[u8; 4]>, + } + + pub struct msqid_ds { + pub msg_perm: crate::ipc_perm, + pub msg_first: *mut crate::msg, + pub msg_last: *mut crate::msg, + pub msg_cbytes: crate::msglen_t, + pub msg_qnum: crate::msgqnum_t, + pub msg_qbytes: crate::msglen_t, + pub msg_lspid: crate::pid_t, + pub msg_lrpid: crate::pid_t, + pub msg_stime: crate::time_t, + msg_pad1: Padding, + pub msg_rtime: crate::time_t, + msg_pad2: Padding, + pub msg_ctime: crate::time_t, + msg_pad3: Padding, + msg_pad4: Padding<[c_long; 4]>, + } + + pub struct sync_t { + __u: c_uint, // union + pub __owner: c_uint, + } + + #[repr(align(4))] + pub struct pthread_barrier_t { + // union + __pad: Padding<[u8; 28]>, // union + } + + pub struct pthread_rwlock_t { + pub __active: c_int, + pub __blockedwriters: c_int, + pub __blockedreaders: c_int, + pub __heavy: c_int, + pub __lock: crate::pthread_mutex_t, // union + pub __rcond: crate::pthread_cond_t, // union + pub __wcond: crate::pthread_cond_t, // union + pub __owner: c_uint, + pub __spare: c_uint, + } + + // There is no canonical definition of c_longdouble in Rust. For both AArch64 and x86_64, + // however, the size and alignment properties are that of the gcc __int128 which corresponds (at + // least on rustc 1.78+ with LLVM 18, see + // https://blog.rust-lang.org/2024/03/30/i128-layout-update/) to i128. Use this instead until we + // get native f128 support. + // + // The definition was taken from the definition of the _Maxalignt struct in the QNX SDK. + // However, on QNX7, there is a different definition of std::max_align_t (the C++ version of + // this type). In practice, this doesn't make a difference for the _alignment_ properties of the + // type - however, it changes the size, so using in in any other form than the zero-sized array + // form would be bogus and it would potentially change the size of the data type. On QNX8, this + // got fixed and both C and C++ are using the same definition. + pub struct max_align_t { + _ll: crate::c_longlong, + _ld: i128, + } +} + +pub const _SYSNAME_SIZE: usize = 256 + 1; +pub const RLIM_INFINITY: crate::rlim_t = 0xfffffffffffffffd; +pub const O_LARGEFILE: c_int = 0o0100000; + +// intentionally not public, only used for fd_set +cfg_if! { + if #[cfg(target_pointer_width = "32")] { + const ULONG_SIZE: usize = 32; + } else if #[cfg(target_pointer_width = "64")] { + const ULONG_SIZE: usize = 64; + } else { + // Unknown target_pointer_width + } +} + +pub const EXIT_FAILURE: c_int = 1; +pub const EXIT_SUCCESS: c_int = 0; +pub const RAND_MAX: c_int = 32767; +pub const EOF: c_int = -1; +pub const SEEK_SET: c_int = 0; +pub const SEEK_CUR: c_int = 1; +pub const SEEK_END: c_int = 2; +pub const _IOFBF: c_int = 0; +pub const _IONBF: c_int = 2; +pub const _IOLBF: c_int = 1; + +pub const F_DUPFD: c_int = 0; +pub const F_GETFD: c_int = 1; +pub const F_SETFD: c_int = 2; +pub const F_GETFL: c_int = 3; +pub const F_SETFL: c_int = 4; + +pub const F_DUPFD_CLOEXEC: c_int = 5; + +pub const SIGTRAP: c_int = 5; + +pub const CLOCK_REALTIME: crate::clockid_t = 0; +pub const CLOCK_MONOTONIC: crate::clockid_t = 2; +pub const CLOCK_PROCESS_CPUTIME_ID: crate::clockid_t = 3; +pub const CLOCK_THREAD_CPUTIME_ID: crate::clockid_t = 4; +pub const TIMER_ABSTIME: c_uint = 0x80000000; + +pub const RUSAGE_SELF: c_int = 0; + +pub const F_OK: c_int = 0; +pub const X_OK: c_int = 1; +pub const W_OK: c_int = 2; +pub const R_OK: c_int = 4; + +pub const SIGHUP: c_int = 1; +pub const SIGINT: c_int = 2; +pub const SIGQUIT: c_int = 3; +pub const SIGILL: c_int = 4; +pub const SIGABRT: c_int = 6; +pub const SIGFPE: c_int = 8; +pub const SIGKILL: c_int = 9; +pub const SIGSEGV: c_int = 11; +pub const SIGPIPE: c_int = 13; +pub const SIGALRM: c_int = 14; +pub const SIGTERM: c_int = 15; + +pub const PROT_NONE: c_int = 0x00000000; +pub const PROT_READ: c_int = 0x00000100; +pub const PROT_WRITE: c_int = 0x00000200; +pub const PROT_EXEC: c_int = 0x00000400; + +pub const MAP_FILE: c_int = 0; +pub const MAP_SHARED: c_int = 1; +pub const MAP_PRIVATE: c_int = 2; +pub const MAP_FIXED: c_int = 0x10; + +pub const MAP_FAILED: *mut c_void = !0 as *mut c_void; + +pub const MS_ASYNC: c_int = 1; +pub const MS_INVALIDATE: c_int = 4; +pub const MS_SYNC: c_int = 2; + +pub const SCM_RIGHTS: c_int = 0x01; +pub const SCM_TIMESTAMP: c_int = 0x02; + +// QNX Network Stack Versioning: +// +// The `if` block targets the legacy `io-pkt` stack. +// - target_env = "nto70": QNX 7.0 +// - target_env = "nto71": Standard QNX 7.1 (default legacy stack) +// +// The `else` block targets the modern `io-sock` stack. +// - target_env = "nto71_iosock": QNX 7.1 with the optional new stack +// - target_env = "nto80": QNX 8.0 +cfg_if! { + if #[cfg(any(target_env = "nto70", target_env = "nto71"))] { + pub const SCM_CREDS: c_int = 0x04; + pub const IFF_NOTRAILERS: c_int = 0x00000020; + pub const AF_INET6: c_int = 24; + pub const AF_BLUETOOTH: c_int = 31; + pub const pseudo_AF_KEY: c_int = 29; + pub const MSG_NOSIGNAL: c_int = 0x0800; + pub const MSG_WAITFORONE: c_int = 0x2000; + pub const IP_IPSEC_POLICY_COMPAT: c_int = 22; + pub const IP_PKTINFO: c_int = 25; + pub const IPPROTO_DIVERT: c_int = 259; + pub const IPV6_IPSEC_POLICY_COMPAT: c_int = 28; + pub const TCP_KEEPALIVE: c_int = 0x04; + pub const ARPHRD_ARCNET: u16 = 7; + pub const SO_BINDTODEVICE: c_int = 0x0800; + pub const EAI_NODATA: c_int = 7; + pub const IPTOS_ECN_NOT_ECT: u8 = 0x00; + pub const RTF_BROADCAST: u32 = 0x80000; + pub const UDP_ENCAP: c_int = 100; + pub const HW_IOSTATS: c_int = 9; + pub const HW_MACHINE_ARCH: c_int = 10; + pub const HW_ALIGNBYTES: c_int = 11; + pub const HW_CNMAGIC: c_int = 12; + pub const HW_PHYSMEM64: c_int = 13; + pub const HW_USERMEM64: c_int = 14; + pub const HW_IOSTATNAMES: c_int = 15; + pub const HW_MAXID: c_int = 15; + pub const CTL_UNSPEC: c_int = 0; + pub const CTL_QNX: c_int = 9; + pub const CTL_PROC: c_int = 10; + pub const CTL_VENDOR: c_int = 11; + pub const CTL_EMUL: c_int = 12; + pub const CTL_SECURITY: c_int = 13; + pub const CTL_MAXID: c_int = 14; + pub const AF_ARP: c_int = 28; + pub const AF_IEEE80211: c_int = 32; + pub const AF_NATM: c_int = 27; + pub const AF_NS: c_int = 6; + pub const BIOCGDLTLIST: c_int = -1072676233; + pub const BIOCGETIF: c_int = 1083196011; + pub const BIOCGSEESENT: c_int = 1074020984; + pub const BIOCGSTATS: c_int = 1082147439; + pub const BIOCSDLT: c_int = -2147204490; + pub const BIOCSETIF: c_int = -2138029460; + pub const BIOCSSEESENT: c_int = -2147204487; + pub const FIONSPACE: c_int = 1074030200; + pub const FIONWRITE: c_int = 1074030201; + pub const IFF_ACCEPTRTADV: c_int = 0x40000000; + pub const IFF_IP6FORWARDING: c_int = 0x20000000; + pub const IFF_SHIM: c_int = 0x80000000; + pub const KERN_ARND: c_int = 81; + pub const KERN_IOV_MAX: c_int = 38; + pub const KERN_LOGSIGEXIT: c_int = 46; + pub const KERN_MAXID: c_int = 83; + pub const KERN_PROC_ARGS: c_int = 48; + pub const KERN_PROC_ENV: c_int = 3; + pub const KERN_PROC_GID: c_int = 7; + pub const KERN_PROC_RGID: c_int = 8; + pub const LOCAL_CONNWAIT: c_int = 0x0002; + pub const LOCAL_CREDS: c_int = 0x0001; + pub const LOCAL_PEEREID: c_int = 0x0003; + pub const MSG_NOTIFICATION: c_int = 0x0400; + pub const NET_RT_IFLIST: c_int = 4; + pub const NI_NUMERICSCOPE: c_int = 0x00000040; + pub const PF_ARP: c_int = 28; + pub const PF_NATM: c_int = 27; + pub const pseudo_AF_HDRCMPLT: c_int = 30; + pub const SIOCGIFADDR: c_int = -1064277727; + pub const SO_FIB: c_int = 0x100a; + pub const SO_TXPRIO: c_int = 0x100b; + pub const SO_SETFIB: c_int = 0x100a; + pub const SO_VLANPRIO: c_int = 0x100c; + pub const USER_ATEXIT_MAX: c_int = 21; + pub const USER_MAXID: c_int = 22; + pub const SO_OVERFLOWED: c_int = 0x1009; + } else { + pub const SCM_CREDS: c_int = 0x03; + pub const AF_INET6: c_int = 28; + pub const AF_BLUETOOTH: c_int = 36; + pub const pseudo_AF_KEY: c_int = 27; + pub const MSG_NOSIGNAL: c_int = 0x20000; + pub const MSG_WAITFORONE: c_int = 0x00080000; + pub const IPPROTO_DIVERT: c_int = 258; + pub const RTF_BROADCAST: u32 = 0x400000; + pub const UDP_ENCAP: c_int = 1; + pub const HW_MACHINE_ARCH: c_int = 11; + pub const AF_ARP: c_int = 35; + pub const AF_IEEE80211: c_int = 37; + pub const AF_NATM: c_int = 29; + pub const BIOCGDLTLIST: c_ulong = 0xffffffffc0104279; + pub const BIOCGETIF: c_int = 0x4020426b; + pub const BIOCGSEESENT: c_int = 0x40044276; + pub const BIOCGSTATS: c_int = 0x4008426f; + pub const BIOCSDLT: c_int = 0x80044278; + pub const BIOCSETIF: c_int = 0x8020426c; + pub const BIOCSSEESENT: c_int = 0x80044277; + pub const KERN_ARND: c_int = 37; + pub const KERN_IOV_MAX: c_int = 35; + pub const KERN_LOGSIGEXIT: c_int = 34; + pub const KERN_PROC_ARGS: c_int = 7; + pub const KERN_PROC_ENV: c_int = 35; + pub const KERN_PROC_GID: c_int = 11; + pub const KERN_PROC_RGID: c_int = 10; + pub const LOCAL_CONNWAIT: c_int = 4; + pub const LOCAL_CREDS: c_int = 2; + pub const MSG_NOTIFICATION: c_int = 0x00002000; + pub const NET_RT_IFLIST: c_int = 3; + pub const NI_NUMERICSCOPE: c_int = 0x00000020; + pub const PF_ARP: c_int = AF_ARP; + pub const PF_NATM: c_int = AF_NATM; + pub const pseudo_AF_HDRCMPLT: c_int = 31; + pub const SIOCGIFADDR: c_int = 0xc0206921; + pub const SO_SETFIB: c_int = 0x1014; + } +} + +pub const MAP_TYPE: c_int = 0x3; + +pub const IFF_UP: c_int = 0x00000001; +pub const IFF_BROADCAST: c_int = 0x00000002; +pub const IFF_DEBUG: c_int = 0x00000004; +pub const IFF_LOOPBACK: c_int = 0x00000008; +pub const IFF_POINTOPOINT: c_int = 0x00000010; +pub const IFF_RUNNING: c_int = 0x00000040; +pub const IFF_NOARP: c_int = 0x00000080; +pub const IFF_PROMISC: c_int = 0x00000100; +pub const IFF_ALLMULTI: c_int = 0x00000200; +pub const IFF_MULTICAST: c_int = 0x00008000; + +pub const AF_UNSPEC: c_int = 0; +pub const AF_UNIX: c_int = AF_LOCAL; +pub const AF_LOCAL: c_int = 1; +pub const AF_INET: c_int = 2; +pub const AF_IPX: c_int = 23; +pub const AF_APPLETALK: c_int = 16; +pub const AF_ROUTE: c_int = 17; +pub const AF_SNA: c_int = 11; + +pub const AF_ISDN: c_int = 26; + +pub const PF_UNSPEC: c_int = AF_UNSPEC; +pub const PF_UNIX: c_int = PF_LOCAL; +pub const PF_LOCAL: c_int = AF_LOCAL; +pub const PF_INET: c_int = AF_INET; +pub const PF_IPX: c_int = AF_IPX; +pub const PF_APPLETALK: c_int = AF_APPLETALK; +pub const PF_INET6: c_int = AF_INET6; +pub const PF_KEY: c_int = pseudo_AF_KEY; +pub const PF_ROUTE: c_int = AF_ROUTE; +pub const PF_SNA: c_int = AF_SNA; + +pub const PF_BLUETOOTH: c_int = AF_BLUETOOTH; +pub const PF_ISDN: c_int = AF_ISDN; + +pub const SOMAXCONN: c_int = 128; + +pub const MSG_OOB: c_int = 0x0001; +pub const MSG_PEEK: c_int = 0x0002; +pub const MSG_DONTROUTE: c_int = 0x0004; +pub const MSG_CTRUNC: c_int = 0x0020; +pub const MSG_TRUNC: c_int = 0x0010; +pub const MSG_DONTWAIT: c_int = 0x0080; +pub const MSG_EOR: c_int = 0x0008; +pub const MSG_WAITALL: c_int = 0x0040; + +pub const IP_TOS: c_int = 3; +pub const IP_TTL: c_int = 4; +pub const IP_HDRINCL: c_int = 2; +pub const IP_OPTIONS: c_int = 1; +pub const IP_RECVOPTS: c_int = 5; +pub const IP_RETOPTS: c_int = 8; +pub const IP_MULTICAST_IF: c_int = 9; +pub const IP_MULTICAST_TTL: c_int = 10; +pub const IP_MULTICAST_LOOP: c_int = 11; +pub const IP_ADD_MEMBERSHIP: c_int = 12; +pub const IP_DROP_MEMBERSHIP: c_int = 13; +pub const IP_DEFAULT_MULTICAST_TTL: c_int = 1; +pub const IP_DEFAULT_MULTICAST_LOOP: c_int = 1; + +pub const IPPROTO_HOPOPTS: c_int = 0; +pub const IPPROTO_IGMP: c_int = 2; +pub const IPPROTO_IPIP: c_int = 4; +pub const IPPROTO_EGP: c_int = 8; +pub const IPPROTO_PUP: c_int = 12; +pub const IPPROTO_IDP: c_int = 22; +pub const IPPROTO_TP: c_int = 29; +pub const IPPROTO_ROUTING: c_int = 43; +pub const IPPROTO_FRAGMENT: c_int = 44; +pub const IPPROTO_RSVP: c_int = 46; +pub const IPPROTO_GRE: c_int = 47; +pub const IPPROTO_ESP: c_int = 50; +pub const IPPROTO_AH: c_int = 51; +pub const IPPROTO_NONE: c_int = 59; +pub const IPPROTO_DSTOPTS: c_int = 60; +pub const IPPROTO_ENCAP: c_int = 98; +pub const IPPROTO_PIM: c_int = 103; +pub const IPPROTO_SCTP: c_int = 132; +pub const IPPROTO_RAW: c_int = 255; +pub const IPPROTO_MAX: c_int = 256; +pub const IPPROTO_CARP: c_int = 112; +pub const IPPROTO_DONE: c_int = 257; +pub const IPPROTO_EON: c_int = 80; +pub const IPPROTO_ETHERIP: c_int = 97; +pub const IPPROTO_GGP: c_int = 3; +pub const IPPROTO_IPCOMP: c_int = 108; +pub const IPPROTO_MOBILE: c_int = 55; + +pub const IPV6_RTHDR_LOOSE: c_int = 0; +pub const IPV6_RTHDR_STRICT: c_int = 1; +pub const IPV6_UNICAST_HOPS: c_int = 4; +pub const IPV6_MULTICAST_IF: c_int = 9; +pub const IPV6_MULTICAST_HOPS: c_int = 10; +pub const IPV6_MULTICAST_LOOP: c_int = 11; +pub const IPV6_JOIN_GROUP: c_int = 12; +pub const IPV6_LEAVE_GROUP: c_int = 13; +pub const IPV6_CHECKSUM: c_int = 26; +pub const IPV6_V6ONLY: c_int = 27; +pub const IPV6_RTHDRDSTOPTS: c_int = 35; +pub const IPV6_RECVPKTINFO: c_int = 36; +pub const IPV6_RECVHOPLIMIT: c_int = 37; +pub const IPV6_RECVRTHDR: c_int = 38; +pub const IPV6_RECVHOPOPTS: c_int = 39; +pub const IPV6_RECVDSTOPTS: c_int = 40; +pub const IPV6_RECVPATHMTU: c_int = 43; +pub const IPV6_PATHMTU: c_int = 44; +pub const IPV6_PKTINFO: c_int = 46; +pub const IPV6_HOPLIMIT: c_int = 47; +pub const IPV6_NEXTHOP: c_int = 48; +pub const IPV6_HOPOPTS: c_int = 49; +pub const IPV6_DSTOPTS: c_int = 50; +pub const IPV6_RECVTCLASS: c_int = 57; +pub const IPV6_TCLASS: c_int = 61; +pub const IPV6_DONTFRAG: c_int = 62; + +pub const TCP_NODELAY: c_int = 0x01; +pub const TCP_MAXSEG: c_int = 0x02; +pub const TCP_MD5SIG: c_int = 0x10; + +pub const SHUT_RD: c_int = 0; +pub const SHUT_WR: c_int = 1; +pub const SHUT_RDWR: c_int = 2; + +pub const LOCK_SH: c_int = 0x1; +pub const LOCK_EX: c_int = 0x2; +pub const LOCK_NB: c_int = 0x4; +pub const LOCK_UN: c_int = 0x8; + +pub const SS_ONSTACK: c_int = 1; +pub const SS_DISABLE: c_int = 2; + +pub const PATH_MAX: c_int = 1024; + +pub const UIO_MAXIOV: c_int = 1024; + +pub const FD_SETSIZE: usize = 256; + +pub const TCIOFF: c_int = 0x0002; +pub const TCION: c_int = 0x0003; +pub const TCOOFF: c_int = 0x0000; +pub const TCOON: c_int = 0x0001; +pub const TCIFLUSH: c_int = 0; +pub const TCOFLUSH: c_int = 1; +pub const TCIOFLUSH: c_int = 2; +pub const NL0: crate::tcflag_t = 0x000; +pub const NL1: crate::tcflag_t = 0x100; +pub const TAB0: crate::tcflag_t = 0x0000; +pub const CR0: crate::tcflag_t = 0x000; +pub const FF0: crate::tcflag_t = 0x0000; +pub const BS0: crate::tcflag_t = 0x0000; +pub const VT0: crate::tcflag_t = 0x0000; +pub const VERASE: usize = 2; +pub const VKILL: usize = 3; +pub const VINTR: usize = 0; +pub const VQUIT: usize = 1; +pub const VLNEXT: usize = 15; +pub const IGNBRK: crate::tcflag_t = 0x00000001; +pub const BRKINT: crate::tcflag_t = 0x00000002; +pub const IGNPAR: crate::tcflag_t = 0x00000004; +pub const PARMRK: crate::tcflag_t = 0x00000008; +pub const INPCK: crate::tcflag_t = 0x00000010; +pub const ISTRIP: crate::tcflag_t = 0x00000020; +pub const INLCR: crate::tcflag_t = 0x00000040; +pub const IGNCR: crate::tcflag_t = 0x00000080; +pub const ICRNL: crate::tcflag_t = 0x00000100; +pub const IXANY: crate::tcflag_t = 0x00000800; +pub const IMAXBEL: crate::tcflag_t = 0x00002000; +pub const OPOST: crate::tcflag_t = 0x00000001; +pub const CS5: crate::tcflag_t = 0x00; +pub const ECHO: crate::tcflag_t = 0x00000008; +pub const OCRNL: crate::tcflag_t = 0x00000008; +pub const ONOCR: crate::tcflag_t = 0x00000010; +pub const ONLRET: crate::tcflag_t = 0x00000020; +pub const OFILL: crate::tcflag_t = 0x00000040; +pub const OFDEL: crate::tcflag_t = 0x00000080; + +pub const WNOHANG: c_int = 0x0040; +pub const WUNTRACED: c_int = 0x0004; +pub const WSTOPPED: c_int = WUNTRACED; +pub const WEXITED: c_int = 0x0001; +pub const WCONTINUED: c_int = 0x0008; +pub const WNOWAIT: c_int = 0x0080; +pub const WTRAPPED: c_int = 0x0002; + +pub const RTLD_LOCAL: c_int = 0x0200; +pub const RTLD_LAZY: c_int = 0x0001; + +pub const POSIX_FADV_NORMAL: c_int = 0; +pub const POSIX_FADV_RANDOM: c_int = 2; +pub const POSIX_FADV_SEQUENTIAL: c_int = 1; +pub const POSIX_FADV_WILLNEED: c_int = 3; + +pub const AT_FDCWD: c_int = -100; +pub const AT_EACCESS: c_int = 0x0001; +pub const AT_SYMLINK_NOFOLLOW: c_int = 0x0002; +pub const AT_SYMLINK_FOLLOW: c_int = 0x0004; +pub const AT_REMOVEDIR: c_int = 0x0008; + +pub const LOG_CRON: c_int = 9 << 3; +pub const LOG_AUTHPRIV: c_int = 10 << 3; +pub const LOG_FTP: c_int = 11 << 3; +pub const LOG_PERROR: c_int = 0x20; + +pub const PIPE_BUF: usize = 5120; + +pub const CLD_EXITED: c_int = 1; +pub const CLD_KILLED: c_int = 2; +pub const CLD_DUMPED: c_int = 3; +pub const CLD_TRAPPED: c_int = 4; +pub const CLD_STOPPED: c_int = 5; +pub const CLD_CONTINUED: c_int = 6; + +pub const UTIME_OMIT: c_long = 0x40000002; +pub const UTIME_NOW: c_long = 0x40000001; + +pub const POLLIN: c_short = POLLRDNORM | POLLRDBAND; +pub const POLLPRI: c_short = 0x0008; +pub const POLLOUT: c_short = 0x0002; +pub const POLLERR: c_short = 0x0020; +pub const POLLHUP: c_short = 0x0040; +pub const POLLNVAL: c_short = 0x1000; +pub const POLLRDNORM: c_short = 0x0001; +pub const POLLRDBAND: c_short = 0x0004; + +pub const IPTOS_LOWDELAY: u8 = 0x10; +pub const IPTOS_THROUGHPUT: u8 = 0x08; +pub const IPTOS_RELIABILITY: u8 = 0x04; +pub const IPTOS_MINCOST: u8 = 0x02; + +pub const IPTOS_PREC_NETCONTROL: u8 = 0xe0; +pub const IPTOS_PREC_INTERNETCONTROL: u8 = 0xc0; +pub const IPTOS_PREC_CRITIC_ECP: u8 = 0xa0; +pub const IPTOS_PREC_FLASHOVERRIDE: u8 = 0x80; +pub const IPTOS_PREC_FLASH: u8 = 0x60; +pub const IPTOS_PREC_IMMEDIATE: u8 = 0x40; +pub const IPTOS_PREC_PRIORITY: u8 = 0x20; +pub const IPTOS_PREC_ROUTINE: u8 = 0x00; + +pub const IPTOS_ECN_MASK: u8 = 0x03; +pub const IPTOS_ECN_ECT1: u8 = 0x01; +pub const IPTOS_ECN_ECT0: u8 = 0x02; +pub const IPTOS_ECN_CE: u8 = 0x03; + +pub const IPOPT_CONTROL: u8 = 0x00; +pub const IPOPT_RESERVED1: u8 = 0x20; +pub const IPOPT_RESERVED2: u8 = 0x60; +pub const IPOPT_LSRR: u8 = 131; +pub const IPOPT_RR: u8 = 7; +pub const IPOPT_SSRR: u8 = 137; +pub const IPDEFTTL: u8 = 64; +pub const IPOPT_OPTVAL: u8 = 0; +pub const IPOPT_OLEN: u8 = 1; +pub const IPOPT_OFFSET: u8 = 2; +pub const IPOPT_MINOFF: u8 = 4; +pub const IPOPT_NOP: u8 = 1; +pub const IPOPT_EOL: u8 = 0; +pub const IPOPT_TS: u8 = 68; +pub const IPOPT_TS_TSONLY: u8 = 0; +pub const IPOPT_TS_TSANDADDR: u8 = 1; +pub const IPOPT_TS_PRESPEC: u8 = 3; + +pub const MAX_IPOPTLEN: u8 = 40; +pub const IPVERSION: u8 = 4; +pub const MAXTTL: u8 = 255; + +pub const ARPHRD_ETHER: u16 = 1; +pub const ARPHRD_IEEE802: u16 = 6; +pub const ARPHRD_IEEE1394: u16 = 24; + +pub const SOL_SOCKET: c_int = 0xffff; + +pub const SO_DEBUG: c_int = 0x0001; +pub const SO_REUSEADDR: c_int = 0x0004; +pub const SO_TYPE: c_int = 0x1008; +pub const SO_ERROR: c_int = 0x1007; +pub const SO_DONTROUTE: c_int = 0x0010; +pub const SO_BROADCAST: c_int = 0x0020; +pub const SO_SNDBUF: c_int = 0x1001; +pub const SO_RCVBUF: c_int = 0x1002; +pub const SO_KEEPALIVE: c_int = 0x0008; +pub const SO_OOBINLINE: c_int = 0x0100; +pub const SO_LINGER: c_int = 0x0080; +pub const SO_REUSEPORT: c_int = 0x0200; +pub const SO_RCVLOWAT: c_int = 0x1004; +pub const SO_SNDLOWAT: c_int = 0x1003; +pub const SO_RCVTIMEO: c_int = 0x1006; +pub const SO_SNDTIMEO: c_int = 0x1005; +pub const SO_TIMESTAMP: c_int = 0x0400; +pub const SO_ACCEPTCONN: c_int = 0x0002; + +pub const TIOCM_LE: c_int = 0x0100; +pub const TIOCM_DTR: c_int = 0x0001; +pub const TIOCM_RTS: c_int = 0x0002; +pub const TIOCM_ST: c_int = 0x0200; +pub const TIOCM_SR: c_int = 0x0400; +pub const TIOCM_CTS: c_int = 0x1000; +pub const TIOCM_CAR: c_int = TIOCM_CD; +pub const TIOCM_CD: c_int = 0x8000; +pub const TIOCM_RNG: c_int = TIOCM_RI; +pub const TIOCM_RI: c_int = 0x4000; +pub const TIOCM_DSR: c_int = 0x2000; + +pub const SCHED_OTHER: c_int = 3; +pub const SCHED_FIFO: c_int = 1; +pub const SCHED_RR: c_int = 2; + +pub const IPC_PRIVATE: crate::key_t = 0; + +pub const IPC_CREAT: c_int = 0o001000; +pub const IPC_EXCL: c_int = 0o002000; +pub const IPC_NOWAIT: c_int = 0o004000; + +pub const IPC_RMID: c_int = 0; +pub const IPC_SET: c_int = 1; +pub const IPC_STAT: c_int = 2; + +pub const MSG_NOERROR: c_int = 0o010000; + +pub const LOG_NFACILITIES: c_int = 24; + +pub const SEM_FAILED: *mut crate::sem_t = 0xFFFFFFFFFFFFFFFF as *mut sem_t; + +pub const AI_PASSIVE: c_int = 0x00000001; +pub const AI_CANONNAME: c_int = 0x00000002; +pub const AI_NUMERICHOST: c_int = 0x00000004; + +pub const AI_NUMERICSERV: c_int = 0x00000008; + +pub const EAI_BADFLAGS: c_int = 3; +pub const EAI_NONAME: c_int = 8; +pub const EAI_AGAIN: c_int = 2; +pub const EAI_FAIL: c_int = 4; +pub const EAI_FAMILY: c_int = 5; +pub const EAI_SOCKTYPE: c_int = 10; +pub const EAI_SERVICE: c_int = 9; +pub const EAI_MEMORY: c_int = 6; +pub const EAI_SYSTEM: c_int = 11; +pub const EAI_OVERFLOW: c_int = 14; + +pub const NI_NUMERICHOST: c_int = 0x00000002; +pub const NI_NUMERICSERV: c_int = 0x00000008; +pub const NI_NOFQDN: c_int = 0x00000001; +pub const NI_NAMEREQD: c_int = 0x00000004; +pub const NI_DGRAM: c_int = 0x00000010; + +pub const AIO_CANCELED: c_int = 0; +pub const AIO_NOTCANCELED: c_int = 2; +pub const AIO_ALLDONE: c_int = 1; +pub const LIO_READ: c_int = 1; +pub const LIO_WRITE: c_int = 2; +pub const LIO_NOP: c_int = 0; +pub const LIO_WAIT: c_int = 1; +pub const LIO_NOWAIT: c_int = 0; + +pub const ITIMER_REAL: c_int = 0; +pub const ITIMER_VIRTUAL: c_int = 1; +pub const ITIMER_PROF: c_int = 2; + +// DIFF(main): changed to `c_short` in f62eb023ab +pub const POSIX_SPAWN_RESETIDS: c_int = 0x00000010; +pub const POSIX_SPAWN_SETPGROUP: c_int = 0x00000001; +pub const POSIX_SPAWN_SETSIGDEF: c_int = 0x00000004; +pub const POSIX_SPAWN_SETSIGMASK: c_int = 0x00000002; +pub const POSIX_SPAWN_SETSCHEDPARAM: c_int = 0x00000400; +pub const POSIX_SPAWN_SETSCHEDULER: c_int = 0x00000040; + +pub const RTF_UP: c_ushort = 0x0001; +pub const RTF_GATEWAY: c_ushort = 0x0002; + +pub const RTF_HOST: c_ushort = 0x0004; +pub const RTF_DYNAMIC: c_ushort = 0x0010; +pub const RTF_MODIFIED: c_ushort = 0x0020; +pub const RTF_REJECT: c_ushort = 0x0008; +pub const RTF_STATIC: c_ushort = 0x0800; +pub const RTF_XRESOLVE: c_ushort = 0x0200; +pub const RTM_NEWADDR: u16 = 0xc; +pub const RTM_DELADDR: u16 = 0xd; +pub const RTA_DST: c_ushort = 0x1; +pub const RTA_GATEWAY: c_ushort = 0x2; + +pub const IN_ACCESS: u32 = 0x00000001; +pub const IN_MODIFY: u32 = 0x00000002; +pub const IN_ATTRIB: u32 = 0x00000004; +pub const IN_CLOSE_WRITE: u32 = 0x00000008; +pub const IN_CLOSE_NOWRITE: u32 = 0x00000010; +pub const IN_CLOSE: u32 = IN_CLOSE_WRITE | IN_CLOSE_NOWRITE; +pub const IN_OPEN: u32 = 0x00000020; +pub const IN_MOVED_FROM: u32 = 0x00000040; +pub const IN_MOVED_TO: u32 = 0x00000080; +pub const IN_MOVE: u32 = IN_MOVED_FROM | IN_MOVED_TO; +pub const IN_CREATE: u32 = 0x00000100; +pub const IN_DELETE: u32 = 0x00000200; +pub const IN_DELETE_SELF: u32 = 0x00000400; +pub const IN_MOVE_SELF: u32 = 0x00000800; +pub const IN_UNMOUNT: u32 = 0x00002000; +pub const IN_Q_OVERFLOW: u32 = 0x00004000; +pub const IN_IGNORED: u32 = 0x00008000; +pub const IN_ONLYDIR: u32 = 0x01000000; +pub const IN_DONT_FOLLOW: u32 = 0x02000000; + +pub const IN_ISDIR: u32 = 0x40000000; +pub const IN_ONESHOT: u32 = 0x80000000; + +pub const REG_EXTENDED: c_int = 0o0001; +pub const REG_ICASE: c_int = 0o0002; +pub const REG_NEWLINE: c_int = 0o0010; +pub const REG_NOSUB: c_int = 0o0004; + +pub const REG_NOTBOL: c_int = 0o00001; +pub const REG_NOTEOL: c_int = 0o00002; + +pub const REG_ENOSYS: c_int = 17; +pub const REG_NOMATCH: c_int = 1; +pub const REG_BADPAT: c_int = 2; +pub const REG_ECOLLATE: c_int = 3; +pub const REG_ECTYPE: c_int = 4; +pub const REG_EESCAPE: c_int = 5; +pub const REG_ESUBREG: c_int = 6; +pub const REG_EBRACK: c_int = 7; +pub const REG_EPAREN: c_int = 8; +pub const REG_EBRACE: c_int = 9; +pub const REG_BADBR: c_int = 10; +pub const REG_ERANGE: c_int = 11; +pub const REG_ESPACE: c_int = 12; +pub const REG_BADRPT: c_int = 13; + +// errno.h +pub const EOK: c_int = 0; +pub const EWOULDBLOCK: c_int = EAGAIN; +pub const EPERM: c_int = 1; +pub const ENOENT: c_int = 2; +pub const ESRCH: c_int = 3; +pub const EINTR: c_int = 4; +pub const EIO: c_int = 5; +pub const ENXIO: c_int = 6; +pub const E2BIG: c_int = 7; +pub const ENOEXEC: c_int = 8; +pub const EBADF: c_int = 9; +pub const ECHILD: c_int = 10; +pub const EAGAIN: c_int = 11; +pub const ENOMEM: c_int = 12; +pub const EACCES: c_int = 13; +pub const EFAULT: c_int = 14; +pub const ENOTBLK: c_int = 15; +pub const EBUSY: c_int = 16; +pub const EEXIST: c_int = 17; +pub const EXDEV: c_int = 18; +pub const ENODEV: c_int = 19; +pub const ENOTDIR: c_int = 20; +pub const EISDIR: c_int = 21; +pub const EINVAL: c_int = 22; +pub const ENFILE: c_int = 23; +pub const EMFILE: c_int = 24; +pub const ENOTTY: c_int = 25; +pub const ETXTBSY: c_int = 26; +pub const EFBIG: c_int = 27; +pub const ENOSPC: c_int = 28; +pub const ESPIPE: c_int = 29; +pub const EROFS: c_int = 30; +pub const EMLINK: c_int = 31; +pub const EPIPE: c_int = 32; +pub const EDOM: c_int = 33; +pub const ERANGE: c_int = 34; +pub const ENOMSG: c_int = 35; +pub const EIDRM: c_int = 36; +pub const ECHRNG: c_int = 37; +pub const EL2NSYNC: c_int = 38; +pub const EL3HLT: c_int = 39; +pub const EL3RST: c_int = 40; +pub const ELNRNG: c_int = 41; +pub const EUNATCH: c_int = 42; +pub const ENOCSI: c_int = 43; +pub const EL2HLT: c_int = 44; +pub const EDEADLK: c_int = 45; +pub const ENOLCK: c_int = 46; +pub const ECANCELED: c_int = 47; +pub const EDQUOT: c_int = 49; +pub const EBADE: c_int = 50; +pub const EBADR: c_int = 51; +pub const EXFULL: c_int = 52; +pub const ENOANO: c_int = 53; +pub const EBADRQC: c_int = 54; +pub const EBADSLT: c_int = 55; +pub const EDEADLOCK: c_int = 56; +pub const EBFONT: c_int = 57; +pub const EOWNERDEAD: c_int = 58; +pub const ENOSTR: c_int = 60; +pub const ENODATA: c_int = 61; +pub const ETIME: c_int = 62; +pub const ENOSR: c_int = 63; +pub const ENONET: c_int = 64; +pub const ENOPKG: c_int = 65; +pub const EREMOTE: c_int = 66; +pub const ENOLINK: c_int = 67; +pub const EADV: c_int = 68; +pub const ESRMNT: c_int = 69; +pub const ECOMM: c_int = 70; +pub const EPROTO: c_int = 71; +pub const EMULTIHOP: c_int = 74; +pub const EBADMSG: c_int = 77; +pub const ENAMETOOLONG: c_int = 78; +pub const EOVERFLOW: c_int = 79; +pub const ENOTUNIQ: c_int = 80; +pub const EBADFD: c_int = 81; +pub const EREMCHG: c_int = 82; +pub const ELIBACC: c_int = 83; +pub const ELIBBAD: c_int = 84; +pub const ELIBSCN: c_int = 85; +pub const ELIBMAX: c_int = 86; +pub const ELIBEXEC: c_int = 87; +pub const EILSEQ: c_int = 88; +pub const ENOSYS: c_int = 89; +pub const ELOOP: c_int = 90; +pub const ERESTART: c_int = 91; +pub const ESTRPIPE: c_int = 92; +pub const ENOTEMPTY: c_int = 93; +pub const EUSERS: c_int = 94; +pub const ENOTRECOVERABLE: c_int = 95; +pub const EOPNOTSUPP: c_int = 103; +pub const EFPOS: c_int = 110; +pub const ESTALE: c_int = 122; +pub const EINPROGRESS: c_int = 236; +pub const EALREADY: c_int = 237; +pub const ENOTSOCK: c_int = 238; +pub const EDESTADDRREQ: c_int = 239; +pub const EMSGSIZE: c_int = 240; +pub const EPROTOTYPE: c_int = 241; +pub const ENOPROTOOPT: c_int = 242; +pub const EPROTONOSUPPORT: c_int = 243; +pub const ESOCKTNOSUPPORT: c_int = 244; +pub const EPFNOSUPPORT: c_int = 246; +pub const EAFNOSUPPORT: c_int = 247; +pub const EADDRINUSE: c_int = 248; +pub const EADDRNOTAVAIL: c_int = 249; +pub const ENETDOWN: c_int = 250; +pub const ENETUNREACH: c_int = 251; +pub const ENETRESET: c_int = 252; +pub const ECONNABORTED: c_int = 253; +pub const ECONNRESET: c_int = 254; +pub const ENOBUFS: c_int = 255; +pub const EISCONN: c_int = 256; +pub const ENOTCONN: c_int = 257; +pub const ESHUTDOWN: c_int = 258; +pub const ETOOMANYREFS: c_int = 259; +pub const ETIMEDOUT: c_int = 260; +pub const ECONNREFUSED: c_int = 261; +pub const EHOSTDOWN: c_int = 264; +pub const EHOSTUNREACH: c_int = 265; +pub const EBADRPC: c_int = 272; +pub const ERPCMISMATCH: c_int = 273; +pub const EPROGUNAVAIL: c_int = 274; +pub const EPROGMISMATCH: c_int = 275; +pub const EPROCUNAVAIL: c_int = 276; +pub const ENOREMOTE: c_int = 300; +pub const ENONDP: c_int = 301; +pub const EBADFSYS: c_int = 302; +pub const EMORE: c_int = 309; +pub const ECTRLTERM: c_int = 310; +pub const ENOLIC: c_int = 311; +pub const ESRVRFAULT: c_int = 312; +pub const EENDIAN: c_int = 313; +pub const ESECTYPEINVAL: c_int = 314; + +pub const RUSAGE_CHILDREN: c_int = -1; +pub const L_tmpnam: c_uint = 255; + +pub const _PC_LINK_MAX: c_int = 1; +pub const _PC_MAX_CANON: c_int = 2; +pub const _PC_MAX_INPUT: c_int = 3; +pub const _PC_NAME_MAX: c_int = 4; +pub const _PC_PATH_MAX: c_int = 5; +pub const _PC_PIPE_BUF: c_int = 6; +pub const _PC_CHOWN_RESTRICTED: c_int = 9; +pub const _PC_NO_TRUNC: c_int = 7; +pub const _PC_VDISABLE: c_int = 8; +pub const _PC_SYNC_IO: c_int = 14; +pub const _PC_ASYNC_IO: c_int = 12; +pub const _PC_PRIO_IO: c_int = 13; +pub const _PC_SOCK_MAXBUF: c_int = 15; +pub const _PC_FILESIZEBITS: c_int = 16; +pub const _PC_REC_INCR_XFER_SIZE: c_int = 22; +pub const _PC_REC_MAX_XFER_SIZE: c_int = 23; +pub const _PC_REC_MIN_XFER_SIZE: c_int = 24; +pub const _PC_REC_XFER_ALIGN: c_int = 25; +pub const _PC_ALLOC_SIZE_MIN: c_int = 21; +pub const _PC_SYMLINK_MAX: c_int = 17; +pub const _PC_2_SYMLINKS: c_int = 20; + +pub const _SC_PAGE_SIZE: c_int = _SC_PAGESIZE; +pub const _SC_ARG_MAX: c_int = 1; +pub const _SC_CHILD_MAX: c_int = 2; +pub const _SC_CLK_TCK: c_int = 3; +pub const _SC_NGROUPS_MAX: c_int = 4; +pub const _SC_OPEN_MAX: c_int = 5; +pub const _SC_JOB_CONTROL: c_int = 6; +pub const _SC_SAVED_IDS: c_int = 7; +pub const _SC_VERSION: c_int = 8; +pub const _SC_PASS_MAX: c_int = 9; +pub const _SC_PAGESIZE: c_int = 11; +pub const _SC_XOPEN_VERSION: c_int = 12; +pub const _SC_STREAM_MAX: c_int = 13; +pub const _SC_TZNAME_MAX: c_int = 14; +pub const _SC_AIO_LISTIO_MAX: c_int = 15; +pub const _SC_AIO_MAX: c_int = 16; +pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 17; +pub const _SC_DELAYTIMER_MAX: c_int = 18; +pub const _SC_MQ_OPEN_MAX: c_int = 19; +pub const _SC_MQ_PRIO_MAX: c_int = 20; +pub const _SC_RTSIG_MAX: c_int = 21; +pub const _SC_SEM_NSEMS_MAX: c_int = 22; +pub const _SC_SEM_VALUE_MAX: c_int = 23; +pub const _SC_SIGQUEUE_MAX: c_int = 24; +pub const _SC_TIMER_MAX: c_int = 25; +pub const _SC_ASYNCHRONOUS_IO: c_int = 26; +pub const _SC_FSYNC: c_int = 27; +pub const _SC_MAPPED_FILES: c_int = 28; +pub const _SC_MEMLOCK: c_int = 29; +pub const _SC_MEMLOCK_RANGE: c_int = 30; +pub const _SC_MEMORY_PROTECTION: c_int = 31; +pub const _SC_MESSAGE_PASSING: c_int = 32; +pub const _SC_PRIORITIZED_IO: c_int = 33; +pub const _SC_PRIORITY_SCHEDULING: c_int = 34; +pub const _SC_REALTIME_SIGNALS: c_int = 35; +pub const _SC_SEMAPHORES: c_int = 36; +pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 37; +pub const _SC_SYNCHRONIZED_IO: c_int = 38; +pub const _SC_TIMERS: c_int = 39; +pub const _SC_GETGR_R_SIZE_MAX: c_int = 40; +pub const _SC_GETPW_R_SIZE_MAX: c_int = 41; +pub const _SC_LOGIN_NAME_MAX: c_int = 42; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 43; +pub const _SC_THREAD_KEYS_MAX: c_int = 44; +pub const _SC_THREAD_STACK_MIN: c_int = 45; +pub const _SC_THREAD_THREADS_MAX: c_int = 46; +pub const _SC_TTY_NAME_MAX: c_int = 47; +pub const _SC_THREADS: c_int = 48; +pub const _SC_THREAD_ATTR_STACKADDR: c_int = 49; +pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 50; +pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 51; +pub const _SC_THREAD_PRIO_INHERIT: c_int = 52; +pub const _SC_THREAD_PRIO_PROTECT: c_int = 53; +pub const _SC_THREAD_PROCESS_SHARED: c_int = 54; +pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 55; +pub const _SC_2_CHAR_TERM: c_int = 56; +pub const _SC_2_C_BIND: c_int = 57; +pub const _SC_2_C_DEV: c_int = 58; +pub const _SC_2_C_VERSION: c_int = 59; +pub const _SC_2_FORT_DEV: c_int = 60; +pub const _SC_2_FORT_RUN: c_int = 61; +pub const _SC_2_LOCALEDEF: c_int = 62; +pub const _SC_2_SW_DEV: c_int = 63; +pub const _SC_2_UPE: c_int = 64; +pub const _SC_2_VERSION: c_int = 65; +pub const _SC_ATEXIT_MAX: c_int = 66; +pub const _SC_AVPHYS_PAGES: c_int = 67; +pub const _SC_BC_BASE_MAX: c_int = 68; +pub const _SC_BC_DIM_MAX: c_int = 69; +pub const _SC_BC_SCALE_MAX: c_int = 70; +pub const _SC_BC_STRING_MAX: c_int = 71; +pub const _SC_CHARCLASS_NAME_MAX: c_int = 72; +pub const _SC_CHAR_BIT: c_int = 73; +pub const _SC_CHAR_MAX: c_int = 74; +pub const _SC_CHAR_MIN: c_int = 75; +pub const _SC_COLL_WEIGHTS_MAX: c_int = 76; +pub const _SC_EQUIV_CLASS_MAX: c_int = 77; +pub const _SC_EXPR_NEST_MAX: c_int = 78; +pub const _SC_INT_MAX: c_int = 79; +pub const _SC_INT_MIN: c_int = 80; +pub const _SC_LINE_MAX: c_int = 81; +pub const _SC_LONG_BIT: c_int = 82; +pub const _SC_MB_LEN_MAX: c_int = 83; +pub const _SC_NL_ARGMAX: c_int = 84; +pub const _SC_NL_LANGMAX: c_int = 85; +pub const _SC_NL_MSGMAX: c_int = 86; +pub const _SC_NL_NMAX: c_int = 87; +pub const _SC_NL_SETMAX: c_int = 88; +pub const _SC_NL_TEXTMAX: c_int = 89; +pub const _SC_NPROCESSORS_CONF: c_int = 90; +pub const _SC_NPROCESSORS_ONLN: c_int = 91; +pub const _SC_NZERO: c_int = 92; +pub const _SC_PHYS_PAGES: c_int = 93; +pub const _SC_PII: c_int = 94; +pub const _SC_PII_INTERNET: c_int = 95; +pub const _SC_PII_INTERNET_DGRAM: c_int = 96; +pub const _SC_PII_INTERNET_STREAM: c_int = 97; +pub const _SC_PII_OSI: c_int = 98; +pub const _SC_PII_OSI_CLTS: c_int = 99; +pub const _SC_PII_OSI_COTS: c_int = 100; +pub const _SC_PII_OSI_M: c_int = 101; +pub const _SC_PII_SOCKET: c_int = 102; +pub const _SC_PII_XTI: c_int = 103; +pub const _SC_POLL: c_int = 104; +pub const _SC_RE_DUP_MAX: c_int = 105; +pub const _SC_SCHAR_MAX: c_int = 106; +pub const _SC_SCHAR_MIN: c_int = 107; +pub const _SC_SELECT: c_int = 108; +pub const _SC_SHRT_MAX: c_int = 109; +pub const _SC_SHRT_MIN: c_int = 110; +pub const _SC_SSIZE_MAX: c_int = 111; +pub const _SC_T_IOV_MAX: c_int = 112; +pub const _SC_UCHAR_MAX: c_int = 113; +pub const _SC_UINT_MAX: c_int = 114; +pub const _SC_UIO_MAXIOV: c_int = 115; +pub const _SC_ULONG_MAX: c_int = 116; +pub const _SC_USHRT_MAX: c_int = 117; +pub const _SC_WORD_BIT: c_int = 118; +pub const _SC_XOPEN_CRYPT: c_int = 119; +pub const _SC_XOPEN_ENH_I18N: c_int = 120; +pub const _SC_XOPEN_SHM: c_int = 121; +pub const _SC_XOPEN_UNIX: c_int = 122; +pub const _SC_XOPEN_XCU_VERSION: c_int = 123; +pub const _SC_XOPEN_XPG2: c_int = 124; +pub const _SC_XOPEN_XPG3: c_int = 125; +pub const _SC_XOPEN_XPG4: c_int = 126; +pub const _SC_XBS5_ILP32_OFF32: c_int = 127; +pub const _SC_XBS5_ILP32_OFFBIG: c_int = 128; +pub const _SC_XBS5_LP64_OFF64: c_int = 129; +pub const _SC_XBS5_LPBIG_OFFBIG: c_int = 130; +pub const _SC_ADVISORY_INFO: c_int = 131; +pub const _SC_CPUTIME: c_int = 132; +pub const _SC_SPAWN: c_int = 133; +pub const _SC_SPORADIC_SERVER: c_int = 134; +pub const _SC_THREAD_CPUTIME: c_int = 135; +pub const _SC_THREAD_SPORADIC_SERVER: c_int = 136; +pub const _SC_TIMEOUTS: c_int = 137; +pub const _SC_BARRIERS: c_int = 138; +pub const _SC_CLOCK_SELECTION: c_int = 139; +pub const _SC_MONOTONIC_CLOCK: c_int = 140; +pub const _SC_READER_WRITER_LOCKS: c_int = 141; +pub const _SC_SPIN_LOCKS: c_int = 142; +pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 143; +pub const _SC_TRACE_EVENT_FILTER: c_int = 144; +pub const _SC_TRACE: c_int = 145; +pub const _SC_TRACE_INHERIT: c_int = 146; +pub const _SC_TRACE_LOG: c_int = 147; +pub const _SC_2_PBS: c_int = 148; +pub const _SC_2_PBS_ACCOUNTING: c_int = 149; +pub const _SC_2_PBS_CHECKPOINT: c_int = 150; +pub const _SC_2_PBS_LOCATE: c_int = 151; +pub const _SC_2_PBS_MESSAGE: c_int = 152; +pub const _SC_2_PBS_TRACK: c_int = 153; +pub const _SC_HOST_NAME_MAX: c_int = 154; +pub const _SC_IOV_MAX: c_int = 155; +pub const _SC_IPV6: c_int = 156; +pub const _SC_RAW_SOCKETS: c_int = 157; +pub const _SC_REGEXP: c_int = 158; +pub const _SC_SHELL: c_int = 159; +pub const _SC_SS_REPL_MAX: c_int = 160; +pub const _SC_SYMLOOP_MAX: c_int = 161; +pub const _SC_TRACE_EVENT_NAME_MAX: c_int = 162; +pub const _SC_TRACE_NAME_MAX: c_int = 163; +pub const _SC_TRACE_SYS_MAX: c_int = 164; +pub const _SC_TRACE_USER_EVENT_MAX: c_int = 165; +pub const _SC_V6_ILP32_OFF32: c_int = 166; +pub const _SC_V6_ILP32_OFFBIG: c_int = 167; +pub const _SC_V6_LP64_OFF64: c_int = 168; +pub const _SC_V6_LPBIG_OFFBIG: c_int = 169; +pub const _SC_XOPEN_REALTIME: c_int = 170; +pub const _SC_XOPEN_REALTIME_THREADS: c_int = 171; +pub const _SC_XOPEN_LEGACY: c_int = 172; +pub const _SC_XOPEN_STREAMS: c_int = 173; +pub const _SC_V7_ILP32_OFF32: c_int = 176; +pub const _SC_V7_ILP32_OFFBIG: c_int = 177; +pub const _SC_V7_LP64_OFF64: c_int = 178; +pub const _SC_V7_LPBIG_OFFBIG: c_int = 179; + +pub const GLOB_ERR: c_int = 0x0001; +pub const GLOB_MARK: c_int = 0x0002; +pub const GLOB_NOSORT: c_int = 0x0004; +pub const GLOB_DOOFFS: c_int = 0x0008; +pub const GLOB_NOCHECK: c_int = 0x0010; +pub const GLOB_APPEND: c_int = 0x0020; +pub const GLOB_NOESCAPE: c_int = 0x0040; + +pub const GLOB_NOSPACE: c_int = 1; +pub const GLOB_ABORTED: c_int = 2; +pub const GLOB_NOMATCH: c_int = 3; + +pub const S_IEXEC: mode_t = crate::S_IXUSR; +pub const S_IWRITE: mode_t = crate::S_IWUSR; +pub const S_IREAD: mode_t = crate::S_IRUSR; + +pub const S_IFIFO: mode_t = 0o1_0000; +pub const S_IFCHR: mode_t = 0o2_0000; +pub const S_IFDIR: mode_t = 0o4_0000; +pub const S_IFBLK: mode_t = 0o6_0000; +pub const S_IFREG: mode_t = 0o10_0000; +pub const S_IFLNK: mode_t = 0o12_0000; +pub const S_IFSOCK: mode_t = 0o14_0000; +pub const S_IFMT: mode_t = 0o17_0000; + +pub const S_IXOTH: mode_t = 0o0001; +pub const S_IWOTH: mode_t = 0o0002; +pub const S_IROTH: mode_t = 0o0004; +pub const S_IRWXO: mode_t = 0o0007; +pub const S_IXGRP: mode_t = 0o0010; +pub const S_IWGRP: mode_t = 0o0020; +pub const S_IRGRP: mode_t = 0o0040; +pub const S_IRWXG: mode_t = 0o0070; +pub const S_IXUSR: mode_t = 0o0100; +pub const S_IWUSR: mode_t = 0o0200; +pub const S_IRUSR: mode_t = 0o0400; +pub const S_IRWXU: mode_t = 0o0700; + +pub const F_LOCK: c_int = 1; +pub const F_TEST: c_int = 3; +pub const F_TLOCK: c_int = 2; +pub const F_ULOCK: c_int = 0; + +pub const ST_RDONLY: c_ulong = 0x01; +pub const ST_NOSUID: c_ulong = 0x04; +pub const ST_NOEXEC: c_ulong = 0x02; +pub const ST_NOATIME: c_ulong = 0x20; + +pub const RTLD_NEXT: *mut c_void = -3i64 as *mut c_void; +pub const RTLD_DEFAULT: *mut c_void = -2i64 as *mut c_void; +pub const RTLD_NODELETE: c_int = 0x1000; +pub const RTLD_NOW: c_int = 0x0002; + +pub const EMPTY: c_short = 0; +pub const RUN_LVL: c_short = 1; +pub const BOOT_TIME: c_short = 2; +pub const NEW_TIME: c_short = 4; +pub const OLD_TIME: c_short = 3; +pub const INIT_PROCESS: c_short = 5; +pub const LOGIN_PROCESS: c_short = 6; +pub const USER_PROCESS: c_short = 7; +pub const DEAD_PROCESS: c_short = 8; +pub const ACCOUNTING: c_short = 9; + +pub const ENOTSUP: c_int = 48; + +pub const BUFSIZ: c_uint = 1024; +pub const TMP_MAX: c_uint = 26 * 26 * 26; +pub const FOPEN_MAX: c_uint = 16; +pub const FILENAME_MAX: c_uint = 255; + +pub const NI_MAXHOST: crate::socklen_t = 1025; +pub const M_KEEP: c_int = 4; +pub const REG_STARTEND: c_int = 0o00004; +pub const VEOF: usize = 4; + +pub const RTLD_GLOBAL: c_int = 0x0100; +pub const RTLD_NOLOAD: c_int = 0x0004; + +pub const O_RDONLY: c_int = 0o000000; +pub const O_WRONLY: c_int = 0o000001; +pub const O_RDWR: c_int = 0o000002; + +pub const O_EXEC: c_int = 0o00003; +pub const O_ASYNC: c_int = 0o0200000; +pub const O_NDELAY: c_int = O_NONBLOCK; +pub const O_TRUNC: c_int = 0o001000; +pub const O_CLOEXEC: c_int = 0o020000; +pub const O_DIRECTORY: c_int = 0o4000000; +pub const O_ACCMODE: c_int = 0o000007; +pub const O_APPEND: c_int = 0o000010; +pub const O_CREAT: c_int = 0o000400; +pub const O_EXCL: c_int = 0o002000; +pub const O_NOCTTY: c_int = 0o004000; +pub const O_NONBLOCK: c_int = 0o000200; +pub const O_SYNC: c_int = 0o000040; +pub const O_RSYNC: c_int = 0o000100; +pub const O_DSYNC: c_int = 0o000020; +pub const O_NOFOLLOW: c_int = 0o010000; + +pub const POSIX_FADV_DONTNEED: c_int = 4; +pub const POSIX_FADV_NOREUSE: c_int = 5; + +pub const SOCK_SEQPACKET: c_int = 5; +pub const SOCK_STREAM: c_int = 1; +pub const SOCK_DGRAM: c_int = 2; +pub const SOCK_RAW: c_int = 3; +pub const SOCK_RDM: c_int = 4; +pub const SOCK_CLOEXEC: c_int = 0x10000000; + +pub const SA_SIGINFO: c_int = 0x0002; +pub const SA_NOCLDWAIT: c_int = 0x0020; +pub const SA_NODEFER: c_int = 0x0010; +pub const SA_RESETHAND: c_int = 0x0004; +pub const SA_NOCLDSTOP: c_int = 0x0001; + +pub const SIGTTIN: c_int = 26; +pub const SIGTTOU: c_int = 27; +pub const SIGXCPU: c_int = 30; +pub const SIGXFSZ: c_int = 31; +pub const SIGVTALRM: c_int = 28; +pub const SIGPROF: c_int = 29; +pub const SIGWINCH: c_int = 20; +pub const SIGCHLD: c_int = 18; +pub const SIGBUS: c_int = 10; +pub const SIGUSR1: c_int = 16; +pub const SIGUSR2: c_int = 17; +pub const SIGCONT: c_int = 25; +pub const SIGSTOP: c_int = 23; +pub const SIGTSTP: c_int = 24; +pub const SIGURG: c_int = 21; +pub const SIGIO: c_int = SIGPOLL; +pub const SIGSYS: c_int = 12; +pub const SIGPOLL: c_int = 22; +pub const SIGPWR: c_int = 19; +pub const SIG_SETMASK: c_int = 2; +pub const SIG_BLOCK: c_int = 0; +pub const SIG_UNBLOCK: c_int = 1; + +pub const POLLWRNORM: c_short = crate::POLLOUT; +pub const POLLWRBAND: c_short = 0x0010; + +pub const F_SETLK: c_int = 106; +pub const F_SETLKW: c_int = 107; +pub const F_ALLOCSP: c_int = 110; +pub const F_FREESP: c_int = 111; +pub const F_GETLK: c_int = 114; + +pub const F_RDLCK: c_int = 1; +pub const F_WRLCK: c_int = 2; +pub const F_UNLCK: c_int = 3; + +pub const NCCS: usize = 40; + +pub const MAP_ANON: c_int = MAP_ANONYMOUS; +pub const MAP_ANONYMOUS: c_int = 0x00080000; + +pub const MCL_CURRENT: c_int = 0x000000001; +pub const MCL_FUTURE: c_int = 0x000000002; + +pub const _TIO_CBAUD: crate::tcflag_t = 15; +pub const CBAUD: crate::tcflag_t = _TIO_CBAUD; +pub const TAB1: crate::tcflag_t = 0x0800; +pub const TAB2: crate::tcflag_t = 0x1000; +pub const TAB3: crate::tcflag_t = 0x1800; +pub const CR1: crate::tcflag_t = 0x200; +pub const CR2: crate::tcflag_t = 0x400; +pub const CR3: crate::tcflag_t = 0x600; +pub const FF1: crate::tcflag_t = 0x8000; +pub const BS1: crate::tcflag_t = 0x2000; +pub const VT1: crate::tcflag_t = 0x4000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 17; +pub const IXON: crate::tcflag_t = 0x00000400; +pub const IXOFF: crate::tcflag_t = 0x00001000; +pub const ONLCR: crate::tcflag_t = 0x00000004; +pub const CSIZE: crate::tcflag_t = 0x00000030; +pub const CS6: crate::tcflag_t = 0x10; +pub const CS7: crate::tcflag_t = 0x20; +pub const CS8: crate::tcflag_t = 0x30; +pub const CSTOPB: crate::tcflag_t = 0x00000040; +pub const CREAD: crate::tcflag_t = 0x00000080; +pub const PARENB: crate::tcflag_t = 0x00000100; +pub const PARODD: crate::tcflag_t = 0x00000200; +pub const HUPCL: crate::tcflag_t = 0x00000400; +pub const CLOCAL: crate::tcflag_t = 0x00000800; +pub const ECHOKE: crate::tcflag_t = 0x00000800; +pub const ECHOE: crate::tcflag_t = 0x00000010; +pub const ECHOK: crate::tcflag_t = 0x00000020; +pub const ECHONL: crate::tcflag_t = 0x00000040; +pub const ECHOCTL: crate::tcflag_t = 0x00000200; +pub const ISIG: crate::tcflag_t = 0x00000001; +pub const ICANON: crate::tcflag_t = 0x00000002; +pub const NOFLSH: crate::tcflag_t = 0x00000080; +pub const OLCUC: crate::tcflag_t = 0x00000002; +pub const NLDLY: crate::tcflag_t = 0x00000100; +pub const CRDLY: crate::tcflag_t = 0x00000600; +pub const TABDLY: crate::tcflag_t = 0x00001800; +pub const BSDLY: crate::tcflag_t = 0x00002000; +pub const FFDLY: crate::tcflag_t = 0x00008000; +pub const VTDLY: crate::tcflag_t = 0x00004000; +pub const XTABS: crate::tcflag_t = 0x1800; + +pub const B0: crate::speed_t = 0; +pub const B50: crate::speed_t = 1; +pub const B75: crate::speed_t = 2; +pub const B110: crate::speed_t = 3; +pub const B134: crate::speed_t = 4; +pub const B150: crate::speed_t = 5; +pub const B200: crate::speed_t = 6; +pub const B300: crate::speed_t = 7; +pub const B600: crate::speed_t = 8; +pub const B1200: crate::speed_t = 9; +pub const B1800: crate::speed_t = 10; +pub const B2400: crate::speed_t = 11; +pub const B4800: crate::speed_t = 12; +pub const B9600: crate::speed_t = 13; +pub const B19200: crate::speed_t = 14; +pub const B38400: crate::speed_t = 15; +pub const EXTA: crate::speed_t = 14; +pub const EXTB: crate::speed_t = 15; +pub const B57600: crate::speed_t = 57600; +pub const B115200: crate::speed_t = 115200; + +pub const VEOL: usize = 5; +pub const VEOL2: usize = 6; +pub const VMIN: usize = 16; +pub const IEXTEN: crate::tcflag_t = 0x00008000; +pub const TOSTOP: crate::tcflag_t = 0x00000100; + +pub const TCSANOW: c_int = 0x0001; +pub const TCSADRAIN: c_int = 0x0002; +pub const TCSAFLUSH: c_int = 0x0004; + +pub const HW_MACHINE: c_int = 1; +pub const HW_MODEL: c_int = 2; +pub const HW_NCPU: c_int = 3; +pub const HW_BYTEORDER: c_int = 4; +pub const HW_PHYSMEM: c_int = 5; +pub const HW_USERMEM: c_int = 6; +pub const HW_PAGESIZE: c_int = 7; +pub const HW_DISKNAMES: c_int = 8; +pub const CTL_KERN: c_int = 1; +pub const CTL_VM: c_int = 2; +pub const CTL_VFS: c_int = 3; +pub const CTL_NET: c_int = 4; +pub const CTL_DEBUG: c_int = 5; +pub const CTL_HW: c_int = 6; +pub const CTL_MACHDEP: c_int = 7; +pub const CTL_USER: c_int = 8; + +pub const DAY_1: crate::nl_item = 8; +pub const DAY_2: crate::nl_item = 9; +pub const DAY_3: crate::nl_item = 10; +pub const DAY_4: crate::nl_item = 11; +pub const DAY_5: crate::nl_item = 12; +pub const DAY_6: crate::nl_item = 13; +pub const DAY_7: crate::nl_item = 14; + +pub const MON_1: crate::nl_item = 22; +pub const MON_2: crate::nl_item = 23; +pub const MON_3: crate::nl_item = 24; +pub const MON_4: crate::nl_item = 25; +pub const MON_5: crate::nl_item = 26; +pub const MON_6: crate::nl_item = 27; +pub const MON_7: crate::nl_item = 28; +pub const MON_8: crate::nl_item = 29; +pub const MON_9: crate::nl_item = 30; +pub const MON_10: crate::nl_item = 31; +pub const MON_11: crate::nl_item = 32; +pub const MON_12: crate::nl_item = 33; + +pub const ABDAY_1: crate::nl_item = 15; +pub const ABDAY_2: crate::nl_item = 16; +pub const ABDAY_3: crate::nl_item = 17; +pub const ABDAY_4: crate::nl_item = 18; +pub const ABDAY_5: crate::nl_item = 19; +pub const ABDAY_6: crate::nl_item = 20; +pub const ABDAY_7: crate::nl_item = 21; + +pub const ABMON_1: crate::nl_item = 34; +pub const ABMON_2: crate::nl_item = 35; +pub const ABMON_3: crate::nl_item = 36; +pub const ABMON_4: crate::nl_item = 37; +pub const ABMON_5: crate::nl_item = 38; +pub const ABMON_6: crate::nl_item = 39; +pub const ABMON_7: crate::nl_item = 40; +pub const ABMON_8: crate::nl_item = 41; +pub const ABMON_9: crate::nl_item = 42; +pub const ABMON_10: crate::nl_item = 43; +pub const ABMON_11: crate::nl_item = 44; +pub const ABMON_12: crate::nl_item = 45; + +pub const AF_CCITT: c_int = 10; +pub const AF_CHAOS: c_int = 5; +pub const AF_CNT: c_int = 21; +pub const AF_COIP: c_int = 20; +pub const AF_DATAKIT: c_int = 9; +pub const AF_DECnet: c_int = 12; +pub const AF_DLI: c_int = 13; +pub const AF_E164: c_int = 26; +pub const AF_ECMA: c_int = 8; +pub const AF_HYLINK: c_int = 15; +pub const AF_IMPLINK: c_int = 3; +pub const AF_ISO: c_int = 7; +pub const AF_LAT: c_int = 14; +pub const AF_LINK: c_int = 18; +pub const AF_OSI: c_int = 7; +pub const AF_PUP: c_int = 4; +pub const ALT_DIGITS: crate::nl_item = 50; +pub const AM_STR: crate::nl_item = 6; +pub const B76800: crate::speed_t = 76800; + +pub const BIOCFLUSH: c_int = 17000; +pub const BIOCGBLEN: c_int = 1074020966; +pub const BIOCGDLT: c_int = 1074020970; +pub const BIOCGHDRCMPLT: c_int = 1074020980; +pub const BIOCGRTIMEOUT: c_int = 1074807406; +pub const BIOCIMMEDIATE: c_int = -2147204496; +pub const BIOCPROMISC: c_int = 17001; +pub const BIOCSBLEN: c_int = -1073462682; +pub const BIOCSETF: c_int = -2146418073; +pub const BIOCSHDRCMPLT: c_int = -2147204491; +pub const BIOCSRTIMEOUT: c_int = -2146418067; +pub const BIOCVERSION: c_int = 1074020977; + +pub const BPF_ALIGNMENT: usize = size_of::(); +pub const CHAR_BIT: usize = 8; +pub const CODESET: crate::nl_item = 1; +pub const CRNCYSTR: crate::nl_item = 55; + +pub const D_FLAG_FILTER: c_int = 0x00000001; +pub const D_FLAG_STAT: c_int = 0x00000002; +pub const D_FLAG_STAT_FORM_MASK: c_int = 0x000000f0; +pub const D_FLAG_STAT_FORM_T32_2001: c_int = 0x00000010; +pub const D_FLAG_STAT_FORM_T32_2008: c_int = 0x00000020; +pub const D_FLAG_STAT_FORM_T64_2008: c_int = 0x00000030; +pub const D_FLAG_STAT_FORM_UNSET: c_int = 0x00000000; + +pub const D_FMT: crate::nl_item = 3; +pub const D_GETFLAG: c_int = 1; +pub const D_SETFLAG: c_int = 2; +pub const D_T_FMT: crate::nl_item = 2; +pub const ERA: crate::nl_item = 46; +pub const ERA_D_FMT: crate::nl_item = 47; +pub const ERA_D_T_FMT: crate::nl_item = 48; +pub const ERA_T_FMT: crate::nl_item = 49; +pub const RADIXCHAR: crate::nl_item = 51; +pub const THOUSEP: crate::nl_item = 52; +pub const YESEXPR: crate::nl_item = 53; +pub const NOEXPR: crate::nl_item = 54; +pub const F_GETOWN: c_int = 35; + +pub const FIONBIO: c_int = -2147195266; +pub const FIOASYNC: c_int = -2147195267; +pub const FIOCLEX: c_int = 26113; +pub const FIOGETOWN: c_int = 1074030203; +pub const FIONCLEX: c_int = 26114; +pub const FIONREAD: c_int = 1074030207; +pub const FIOSETOWN: c_int = -2147195268; + +pub const F_SETOWN: c_int = 36; +pub const IFF_LINK0: c_int = 0x00001000; +pub const IFF_LINK1: c_int = 0x00002000; +pub const IFF_LINK2: c_int = 0x00004000; +pub const IFF_OACTIVE: c_int = 0x00000400; +pub const IFF_SIMPLEX: c_int = 0x00000800; +pub const IHFLOW: tcflag_t = 0x00000001; +pub const IIDLE: tcflag_t = 0x00000008; +pub const IP_RECVDSTADDR: c_int = 7; +pub const IP_RECVIF: c_int = 20; +pub const IPTOS_ECN_NOTECT: u8 = 0x00; +pub const IUCLC: tcflag_t = 0x00000200; +pub const IUTF8: tcflag_t = 0x0004000; + +pub const KERN_ARGMAX: c_int = 8; +pub const KERN_BOOTTIME: c_int = 21; +pub const KERN_CLOCKRATE: c_int = 12; +pub const KERN_FILE: c_int = 15; +pub const KERN_HOSTID: c_int = 11; +pub const KERN_HOSTNAME: c_int = 10; +pub const KERN_JOB_CONTROL: c_int = 19; +pub const KERN_MAXFILES: c_int = 7; +pub const KERN_MAXPROC: c_int = 6; +pub const KERN_MAXVNODES: c_int = 5; +pub const KERN_NGROUPS: c_int = 18; +pub const KERN_OSRELEASE: c_int = 2; +pub const KERN_OSREV: c_int = 3; +pub const KERN_OSTYPE: c_int = 1; +pub const KERN_POSIX1: c_int = 17; +pub const KERN_PROC: c_int = 14; +pub const KERN_PROC_ALL: c_int = 0; +pub const KERN_PROC_PGRP: c_int = 2; +pub const KERN_PROC_PID: c_int = 1; +pub const KERN_PROC_RUID: c_int = 6; +pub const KERN_PROC_SESSION: c_int = 3; +pub const KERN_PROC_TTY: c_int = 4; +pub const KERN_PROC_UID: c_int = 5; +pub const KERN_PROF: c_int = 16; +pub const KERN_SAVED_IDS: c_int = 20; +pub const KERN_SECURELVL: c_int = 9; +pub const KERN_VERSION: c_int = 4; +pub const KERN_VNODE: c_int = 13; + +pub const LC_ALL: c_int = 63; +pub const LC_COLLATE: c_int = 1; +pub const LC_CTYPE: c_int = 2; +pub const LC_MESSAGES: c_int = 32; +pub const LC_MONETARY: c_int = 4; +pub const LC_NUMERIC: c_int = 8; +pub const LC_TIME: c_int = 16; + +pub const MAP_STACK: c_int = 0x00001000; +pub const MNT_NOEXEC: c_int = 0x02; +pub const MNT_NOSUID: c_int = 0x04; +pub const MNT_RDONLY: c_int = 0x01; + +pub const NET_RT_DUMP: c_int = 1; +pub const NET_RT_FLAGS: c_int = 2; +pub const OHFLOW: tcflag_t = 0x00000002; +pub const P_ALL: idtype_t = 0; +pub const PARSTK: tcflag_t = 0x00000004; +pub const PF_CCITT: c_int = 10; +pub const PF_CHAOS: c_int = 5; +pub const PF_CNT: c_int = 21; +pub const PF_COIP: c_int = 20; +pub const PF_DATAKIT: c_int = 9; +pub const PF_DECnet: c_int = 12; +pub const PF_DLI: c_int = 13; +pub const PF_ECMA: c_int = 8; +pub const PF_HYLINK: c_int = 15; +pub const PF_IMPLINK: c_int = 3; +pub const PF_ISO: c_int = 7; +pub const PF_LAT: c_int = 14; +pub const PF_LINK: c_int = 18; +pub const PF_OSI: c_int = 7; +pub const PF_PIP: c_int = 25; +pub const PF_PUP: c_int = 4; +pub const PF_RTIP: c_int = 22; +pub const PF_XTP: c_int = 19; +pub const PM_STR: crate::nl_item = 7; +pub const POSIX_MADV_DONTNEED: c_int = 4; +pub const POSIX_MADV_NORMAL: c_int = 0; +pub const POSIX_MADV_RANDOM: c_int = 2; +pub const POSIX_MADV_SEQUENTIAL: c_int = 1; +pub const POSIX_MADV_WILLNEED: c_int = 3; +pub const _POSIX_VDISABLE: c_int = 0; +pub const P_PGID: idtype_t = 2; +pub const P_PID: idtype_t = 1; +pub const PRIO_PGRP: c_int = 1; +pub const PRIO_PROCESS: c_int = 0; +pub const PRIO_USER: c_int = 2; +pub const pseudo_AF_PIP: c_int = 25; +pub const pseudo_AF_RTIP: c_int = 22; +pub const pseudo_AF_XTP: c_int = 19; +pub const REG_ASSERT: c_int = 15; +pub const REG_ATOI: c_int = 255; +pub const REG_BACKR: c_int = 0x400; +pub const REG_BASIC: c_int = 0x00; +pub const REG_DUMP: c_int = 0x80; +pub const REG_EMPTY: c_int = 14; +pub const REG_INVARG: c_int = 16; +pub const REG_ITOA: c_int = 0o400; +pub const REG_LARGE: c_int = 0x200; +pub const REG_NOSPEC: c_int = 0x10; +pub const REG_OK: c_int = 0; +pub const REG_PEND: c_int = 0x20; +pub const REG_TRACE: c_int = 0x100; + +pub const RLIMIT_AS: c_int = 6; +pub const RLIMIT_CORE: c_int = 4; +pub const RLIMIT_CPU: c_int = 0; +pub const RLIMIT_DATA: c_int = 2; +pub const RLIMIT_FSIZE: c_int = 1; +pub const RLIMIT_MEMLOCK: c_int = 7; +pub const RLIMIT_NOFILE: c_int = 5; +pub const RLIMIT_NPROC: c_int = 8; +pub const RLIMIT_RSS: c_int = 6; +pub const RLIMIT_STACK: c_int = 3; +pub const RLIMIT_VMEM: c_int = 6; +#[deprecated(since = "0.2.64", note = "Not stable across OS versions")] +pub const RLIM_NLIMITS: c_int = 14; + +pub const SCHED_ADJTOHEAD: c_int = 5; +pub const SCHED_ADJTOTAIL: c_int = 6; +pub const SCHED_MAXPOLICY: c_int = 7; +pub const SCHED_SETPRIO: c_int = 7; +pub const SCHED_SPORADIC: c_int = 4; + +pub const SHM_ANON: *mut c_char = -1isize as *mut c_char; +pub const SIGCLD: c_int = SIGCHLD; +pub const SIGDEADLK: c_int = 7; +pub const SIGEMT: c_int = 7; +pub const SIGEV_NONE: c_int = 0; +pub const SIGEV_SIGNAL: c_int = 129; +pub const SIGEV_THREAD: c_int = 135; +pub const SO_USELOOPBACK: c_int = 0x0040; +pub const _SS_ALIGNSIZE: usize = size_of::(); +pub const _SS_MAXSIZE: usize = 128; +pub const _SS_PAD1SIZE: usize = _SS_ALIGNSIZE - 2; +pub const _SS_PAD2SIZE: usize = _SS_MAXSIZE - 2 - _SS_PAD1SIZE - _SS_ALIGNSIZE; +pub const TC_CPOSIX: tcflag_t = CLOCAL | CREAD | CSIZE | CSTOPB | HUPCL | PARENB | PARODD; +pub const TCGETS: c_int = 0x404c540d; +pub const TC_IPOSIX: tcflag_t = + BRKINT | ICRNL | IGNBRK | IGNPAR | INLCR | INPCK | ISTRIP | IXOFF | IXON | PARMRK; +pub const TC_LPOSIX: tcflag_t = + ECHO | ECHOE | ECHOK | ECHONL | ICANON | IEXTEN | ISIG | NOFLSH | TOSTOP; +pub const TC_OPOSIX: tcflag_t = OPOST; +pub const T_FMT_AMPM: crate::nl_item = 5; + +pub const TIOCCBRK: c_int = 29818; +pub const TIOCCDTR: c_int = 29816; +pub const TIOCDRAIN: c_int = 29790; +pub const TIOCEXCL: c_int = 29709; +pub const TIOCFLUSH: c_int = -2147191792; +pub const TIOCGETA: c_int = 1078752275; +pub const TIOCGPGRP: c_int = 1074033783; +pub const TIOCGWINSZ: c_int = 1074295912; +pub const TIOCMBIC: c_int = -2147191701; +pub const TIOCMBIS: c_int = -2147191700; +pub const TIOCMGET: c_int = 1074033770; +pub const TIOCMSET: c_int = -2147191699; +pub const TIOCNOTTY: c_int = 29809; +pub const TIOCNXCL: c_int = 29710; +pub const TIOCOUTQ: c_int = 1074033779; +pub const TIOCPKT: c_int = -2147191696; +pub const TIOCPKT_DATA: c_int = 0x00; +pub const TIOCPKT_DOSTOP: c_int = 0x20; +pub const TIOCPKT_FLUSHREAD: c_int = 0x01; +pub const TIOCPKT_FLUSHWRITE: c_int = 0x02; +pub const TIOCPKT_IOCTL: c_int = 0x40; +pub const TIOCPKT_NOSTOP: c_int = 0x10; +pub const TIOCPKT_START: c_int = 0x08; +pub const TIOCPKT_STOP: c_int = 0x04; +pub const TIOCSBRK: c_int = 29819; +pub const TIOCSCTTY: c_int = 29793; +pub const TIOCSDTR: c_int = 29817; +pub const TIOCSETA: c_int = -2142473196; +pub const TIOCSETAF: c_int = -2142473194; +pub const TIOCSETAW: c_int = -2142473195; +pub const TIOCSPGRP: c_int = -2147191690; +pub const TIOCSTART: c_int = 29806; +pub const TIOCSTI: c_int = -2147388302; +pub const TIOCSTOP: c_int = 29807; +pub const TIOCSWINSZ: c_int = -2146929561; + +pub const USER_CS_PATH: c_int = 1; +pub const USER_BC_BASE_MAX: c_int = 2; +pub const USER_BC_DIM_MAX: c_int = 3; +pub const USER_BC_SCALE_MAX: c_int = 4; +pub const USER_BC_STRING_MAX: c_int = 5; +pub const USER_COLL_WEIGHTS_MAX: c_int = 6; +pub const USER_EXPR_NEST_MAX: c_int = 7; +pub const USER_LINE_MAX: c_int = 8; +pub const USER_RE_DUP_MAX: c_int = 9; +pub const USER_POSIX2_VERSION: c_int = 10; +pub const USER_POSIX2_C_BIND: c_int = 11; +pub const USER_POSIX2_C_DEV: c_int = 12; +pub const USER_POSIX2_CHAR_TERM: c_int = 13; +pub const USER_POSIX2_FORT_DEV: c_int = 14; +pub const USER_POSIX2_FORT_RUN: c_int = 15; +pub const USER_POSIX2_LOCALEDEF: c_int = 16; +pub const USER_POSIX2_SW_DEV: c_int = 17; +pub const USER_POSIX2_UPE: c_int = 18; +pub const USER_STREAM_MAX: c_int = 19; +pub const USER_TZNAME_MAX: c_int = 20; + +pub const VDOWN: usize = 31; +pub const VINS: usize = 32; +pub const VDEL: usize = 33; +pub const VRUB: usize = 34; +pub const VCAN: usize = 35; +pub const VHOME: usize = 36; +pub const VEND: usize = 37; +pub const VSPARE3: usize = 38; +pub const VSPARE4: usize = 39; +pub const VSWTCH: usize = 7; +pub const VDSUSP: usize = 11; +pub const VFWD: usize = 18; +pub const VLOGIN: usize = 19; +pub const VPREFIX: usize = 20; +pub const VSUFFIX: usize = 24; +pub const VLEFT: usize = 28; +pub const VRIGHT: usize = 29; +pub const VUP: usize = 30; +pub const XCASE: tcflag_t = 0x00000004; + +pub const PTHREAD_BARRIER_SERIAL_THREAD: c_int = -1; +pub const PTHREAD_CREATE_JOINABLE: c_int = 0x00; +pub const PTHREAD_CREATE_DETACHED: c_int = 0x01; + +pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 1; +pub const PTHREAD_MUTEX_RECURSIVE: c_int = 2; +pub const PTHREAD_MUTEX_NORMAL: c_int = 3; +pub const PTHREAD_STACK_MIN: size_t = 256; +pub const PTHREAD_MUTEX_DEFAULT: c_int = 0; +pub const PTHREAD_MUTEX_STALLED: c_int = 0x00; +pub const PTHREAD_MUTEX_ROBUST: c_int = 0x10; +pub const PTHREAD_PROCESS_PRIVATE: c_int = 0x00; +pub const PTHREAD_PROCESS_SHARED: c_int = 0x01; + +pub const PTHREAD_KEYS_MAX: usize = 128; + +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + __u: 0x80000000, + __owner: 0xffffffff, +}; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + __u: CLOCK_REALTIME as u32, + __owner: 0xfffffffb, +}; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + __active: 0, + __blockedwriters: 0, + __blockedreaders: 0, + __heavy: 0, + __lock: PTHREAD_MUTEX_INITIALIZER, + __rcond: PTHREAD_COND_INITIALIZER, + __wcond: PTHREAD_COND_INITIALIZER, + __owner: -2i32 as c_uint, + __spare: 0, +}; + +const fn _CMSG_ALIGN(len: usize) -> usize { + len + size_of::() - 1 & !(size_of::() - 1) +} + +const fn _ALIGN(p: usize, b: usize) -> usize { + (p + b - 1) & !(b - 1) +} + +f! { + pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { + if (*mhdr).msg_controllen as usize >= size_of::() { + (*mhdr).msg_control as *mut cmsghdr + } else { + core::ptr::null_mut::() + } + } + + pub fn CMSG_NXTHDR(mhdr: *const crate::msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { + let msg = _CMSG_ALIGN((*cmsg).cmsg_len as usize); + let next = cmsg as usize + msg + _CMSG_ALIGN(size_of::()); + if next > (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize { + core::ptr::null_mut::() + } else { + (cmsg as usize + msg) as *mut cmsghdr + } + } + + pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { + (cmsg as *mut c_uchar).offset(_CMSG_ALIGN(size_of::()) as isize) + } + + pub const fn CMSG_LEN(length: c_uint) -> c_uint { + _CMSG_ALIGN(size_of::()) as c_uint + length + } + + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { + (_CMSG_ALIGN(size_of::()) + _CMSG_ALIGN(length as usize)) as c_uint + } + + pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { + let fd = fd as usize; + let size = size_of_val(&(*set).fds_bits[0]) * 8; + (*set).fds_bits[fd / size] &= !(1 << (fd % size)); + return; + } + + pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { + let fd = fd as usize; + let size = size_of_val(&(*set).fds_bits[0]) * 8; + return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0; + } + + pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { + let fd = fd as usize; + let size = size_of_val(&(*set).fds_bits[0]) * 8; + (*set).fds_bits[fd / size] |= 1 << (fd % size); + return; + } + + pub fn FD_ZERO(set: *mut fd_set) -> () { + for slot in (*set).fds_bits.iter_mut() { + *slot = 0; + } + } + + pub fn _DEXTRA_FIRST(_d: *const dirent) -> *mut crate::dirent_extra { + let _f = &((*(_d)).d_name) as *const _; + let _s = _d as usize; + + _ALIGN(_s + _f as usize - _s + (*_d).d_namelen as usize + 1, 8) as *mut crate::dirent_extra + } + + pub fn _DEXTRA_VALID(_x: *const crate::dirent_extra, _d: *const dirent) -> bool { + let sz = _x as usize - _d as usize + size_of::(); + let rsz = (*_d).d_reclen as usize; + + if sz > rsz || sz + (*_x).d_datalen as usize > rsz { + false + } else { + true + } + } + + pub fn _DEXTRA_NEXT(_x: *const crate::dirent_extra) -> *mut crate::dirent_extra { + _ALIGN( + _x as usize + size_of::() + (*_x).d_datalen as usize, + 8, + ) as *mut crate::dirent_extra + } + + pub fn SOCKCREDSIZE(ngrps: usize) -> usize { + let ngrps = if ngrps > 0 { ngrps - 1 } else { 0 }; + size_of::() + size_of::() * ngrps + } +} + +safe_f! { + pub const fn WIFSTOPPED(status: c_int) -> bool { + (status & 0xff) == 0x7f + } + + pub const fn WSTOPSIG(status: c_int) -> c_int { + (status >> 8) & 0xff + } + + pub const fn WIFCONTINUED(status: c_int) -> bool { + status == 0xffff + } + + pub const fn WIFSIGNALED(status: c_int) -> bool { + ((status & 0x7f) + 1) as i8 >= 2 + } + + pub const fn WTERMSIG(status: c_int) -> c_int { + status & 0x7f + } + + pub const fn WIFEXITED(status: c_int) -> bool { + (status & 0x7f) == 0 + } + + pub const fn WEXITSTATUS(status: c_int) -> c_int { + (status >> 8) & 0xff + } + + pub const fn WCOREDUMP(status: c_int) -> bool { + (status & 0x80) != 0 + } + + pub const fn IPTOS_ECN(x: u8) -> u8 { + x & crate::IPTOS_ECN_MASK + } + + pub const fn makedev(major: c_uint, minor: c_uint) -> crate::dev_t { + ((major << 10) | (minor)) as crate::dev_t + } + + pub const fn major(dev: crate::dev_t) -> c_uint { + ((dev as c_uint) >> 10) & 0x3f + } + + pub const fn minor(dev: crate::dev_t) -> c_uint { + (dev as c_uint) & 0x3ff + } +} + +cfg_if! { + if #[cfg(not(target_env = "nto71_iosock"))] { + extern "C" { + pub fn sendmmsg( + sockfd: c_int, + msgvec: *mut crate::mmsghdr, + vlen: c_uint, + flags: c_uint, + ) -> c_int; + pub fn recvmmsg( + sockfd: c_int, + msgvec: *mut crate::mmsghdr, + vlen: c_uint, + flags: c_uint, + timeout: *mut crate::timespec, + ) -> c_int; + } + } else { + extern "C" { + pub fn sendmmsg( + sockfd: c_int, + msgvec: *mut crate::mmsghdr, + vlen: size_t, + flags: c_int, + ) -> ssize_t; + pub fn recvmmsg( + sockfd: c_int, + msgvec: *mut crate::mmsghdr, + vlen: size_t, + flags: c_int, + timeout: *const crate::timespec, + ) -> ssize_t; + } + } +} + +// Network related functions are provided by libsocket and regex +// functions are provided by libregex. +// In QNX <=7.0, libregex functions were included in libc itself. +#[link(name = "socket")] +#[cfg_attr(not(target_env = "nto70"), link(name = "regex"))] +extern "C" { + pub fn sem_destroy(sem: *mut sem_t) -> c_int; + pub fn sem_init(sem: *mut sem_t, pshared: c_int, value: c_uint) -> c_int; + pub fn fdatasync(fd: c_int) -> c_int; + pub fn getpriority(which: c_int, who: crate::id_t) -> c_int; + pub fn setpriority(which: c_int, who: crate::id_t, prio: c_int) -> c_int; + pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; + pub fn mknodat(__fd: c_int, pathname: *const c_char, mode: mode_t, dev: crate::dev_t) -> c_int; + + pub fn clock_getres(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; + pub fn clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; + pub fn clock_settime(clk_id: crate::clockid_t, tp: *const crate::timespec) -> c_int; + pub fn clock_getcpuclockid(pid: crate::pid_t, clk_id: *mut crate::clockid_t) -> c_int; + + pub fn pthread_attr_getstack( + attr: *const crate::pthread_attr_t, + stackaddr: *mut *mut c_void, + stacksize: *mut size_t, + ) -> c_int; + pub fn memalign(align: size_t, size: size_t) -> *mut c_void; + pub fn setgroups(ngroups: c_int, ptr: *const crate::gid_t) -> c_int; + + pub fn posix_fadvise(fd: c_int, offset: off_t, len: off_t, advise: c_int) -> c_int; + pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int; + pub fn nl_langinfo(item: crate::nl_item) -> *mut c_char; + + pub fn utimensat( + dirfd: c_int, + path: *const c_char, + times: *const crate::timespec, + flag: c_int, + ) -> c_int; + + pub fn pthread_condattr_getclock( + attr: *const pthread_condattr_t, + clock_id: *mut clockid_t, + ) -> c_int; + pub fn pthread_condattr_setclock( + attr: *mut pthread_condattr_t, + clock_id: crate::clockid_t, + ) -> c_int; + pub fn pthread_condattr_setpshared(attr: *mut pthread_condattr_t, pshared: c_int) -> c_int; + pub fn pthread_mutexattr_setpshared(attr: *mut pthread_mutexattr_t, pshared: c_int) -> c_int; + pub fn pthread_rwlockattr_getpshared( + attr: *const pthread_rwlockattr_t, + val: *mut c_int, + ) -> c_int; + pub fn pthread_rwlockattr_setpshared(attr: *mut pthread_rwlockattr_t, val: c_int) -> c_int; + pub fn ptsname_r(fd: c_int, buf: *mut c_char, buflen: size_t) -> *mut c_char; + pub fn clearenv() -> c_int; + pub fn waitid( + idtype: idtype_t, + id: id_t, + infop: *mut crate::siginfo_t, + options: c_int, + ) -> c_int; + pub fn wait4( + pid: crate::pid_t, + status: *mut c_int, + options: c_int, + rusage: *mut crate::rusage, + ) -> crate::pid_t; + + // DIFF(main): changed to `*const *mut` in e77f551de9 + pub fn execvpe( + file: *const c_char, + argv: *const *const c_char, + envp: *const *const c_char, + ) -> c_int; + + pub fn getifaddrs(ifap: *mut *mut crate::ifaddrs) -> c_int; + pub fn freeifaddrs(ifa: *mut crate::ifaddrs); + pub fn bind( + socket: c_int, + address: *const crate::sockaddr, + address_len: crate::socklen_t, + ) -> c_int; + + pub fn writev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; + pub fn readv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; + + pub fn sendmsg(fd: c_int, msg: *const crate::msghdr, flags: c_int) -> ssize_t; + pub fn recvmsg(fd: c_int, msg: *mut crate::msghdr, flags: c_int) -> ssize_t; + pub fn openpty( + amaster: *mut c_int, + aslave: *mut c_int, + name: *mut c_char, + termp: *mut termios, + winp: *mut crate::winsize, + ) -> c_int; + pub fn forkpty( + amaster: *mut c_int, + name: *mut c_char, + termp: *mut termios, + winp: *mut crate::winsize, + ) -> crate::pid_t; + pub fn login_tty(fd: c_int) -> c_int; + + pub fn uname(buf: *mut crate::utsname) -> c_int; + + pub fn getpeereid(socket: c_int, euid: *mut crate::uid_t, egid: *mut crate::gid_t) -> c_int; + + pub fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int; + + pub fn abs(i: c_int) -> c_int; + pub fn labs(i: c_long) -> c_long; + pub fn rand() -> c_int; + pub fn srand(seed: c_uint); + + pub fn setpwent(); + pub fn endpwent(); + pub fn getpwent() -> *mut passwd; + pub fn setgrent(); + pub fn endgrent(); + pub fn getgrent() -> *mut crate::group; + pub fn setspent(); + pub fn endspent(); + + pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int; + + pub fn ftok(pathname: *const c_char, proj_id: c_int) -> crate::key_t; + pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; + + pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int; + pub fn mkostemp(template: *mut c_char, flags: c_int) -> c_int; + pub fn mkostemps(template: *mut c_char, suffixlen: c_int, flags: c_int) -> c_int; + pub fn sigtimedwait( + set: *const sigset_t, + info: *mut siginfo_t, + timeout: *const crate::timespec, + ) -> c_int; + pub fn sigwaitinfo(set: *const sigset_t, info: *mut siginfo_t) -> c_int; + pub fn pthread_setschedprio(native: crate::pthread_t, priority: c_int) -> c_int; + + pub fn if_nameindex() -> *mut if_nameindex; + pub fn if_freenameindex(ptr: *mut if_nameindex); + + pub fn glob( + pattern: *const c_char, + flags: c_int, + errfunc: Option c_int>, + pglob: *mut crate::glob_t, + ) -> c_int; + pub fn globfree(pglob: *mut crate::glob_t); + + pub fn posix_madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; + + pub fn shm_unlink(name: *const c_char) -> c_int; + + pub fn seekdir(dirp: *mut crate::DIR, loc: c_long); + + pub fn telldir(dirp: *mut crate::DIR) -> c_long; + + pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int; + + pub fn recvfrom( + socket: c_int, + buf: *mut c_void, + len: size_t, + flags: c_int, + addr: *mut crate::sockaddr, + addrlen: *mut crate::socklen_t, + ) -> ssize_t; + pub fn mkstemps(template: *mut c_char, suffixlen: c_int) -> c_int; + + pub fn getdomainname(name: *mut c_char, len: size_t) -> c_int; + pub fn setdomainname(name: *const c_char, len: size_t) -> c_int; + pub fn sync(); + pub fn pthread_getschedparam( + native: crate::pthread_t, + policy: *mut c_int, + param: *mut crate::sched_param, + ) -> c_int; + pub fn umount(target: *const c_char, flags: c_int) -> c_int; + pub fn sched_get_priority_max(policy: c_int) -> c_int; + pub fn settimeofday(tv: *const crate::timeval, tz: *const c_void) -> c_int; + pub fn sched_rr_get_interval(pid: crate::pid_t, tp: *mut crate::timespec) -> c_int; + pub fn sem_timedwait(sem: *mut sem_t, abstime: *const crate::timespec) -> c_int; + pub fn sem_getvalue(sem: *mut sem_t, sval: *mut c_int) -> c_int; + pub fn sched_setparam(pid: crate::pid_t, param: *const crate::sched_param) -> c_int; + pub fn mount( + special_device: *const c_char, + mount_directory: *const c_char, + flags: c_int, + mount_type: *const c_char, + mount_data: *const c_void, + mount_datalen: c_int, + ) -> c_int; + pub fn sched_getparam(pid: crate::pid_t, param: *mut crate::sched_param) -> c_int; + pub fn pthread_mutex_consistent(mutex: *mut pthread_mutex_t) -> c_int; + pub fn pthread_mutex_timedlock( + lock: *mut pthread_mutex_t, + abstime: *const crate::timespec, + ) -> c_int; + pub fn pthread_spin_init(lock: *mut crate::pthread_spinlock_t, pshared: c_int) -> c_int; + pub fn pthread_spin_destroy(lock: *mut crate::pthread_spinlock_t) -> c_int; + pub fn pthread_spin_lock(lock: *mut crate::pthread_spinlock_t) -> c_int; + pub fn pthread_spin_trylock(lock: *mut crate::pthread_spinlock_t) -> c_int; + pub fn pthread_spin_unlock(lock: *mut crate::pthread_spinlock_t) -> c_int; + pub fn pthread_barrierattr_init(__attr: *mut crate::pthread_barrierattr_t) -> c_int; + pub fn pthread_barrierattr_destroy(__attr: *mut crate::pthread_barrierattr_t) -> c_int; + pub fn pthread_barrierattr_getpshared( + __attr: *const crate::pthread_barrierattr_t, + __pshared: *mut c_int, + ) -> c_int; + pub fn pthread_barrierattr_setpshared( + __attr: *mut crate::pthread_barrierattr_t, + __pshared: c_int, + ) -> c_int; + pub fn pthread_barrier_init( + __barrier: *mut crate::pthread_barrier_t, + __attr: *const crate::pthread_barrierattr_t, + __count: c_uint, + ) -> c_int; + pub fn pthread_barrier_destroy(__barrier: *mut crate::pthread_barrier_t) -> c_int; + pub fn pthread_barrier_wait(__barrier: *mut crate::pthread_barrier_t) -> c_int; + + pub fn sched_getscheduler(pid: crate::pid_t) -> c_int; + pub fn clock_nanosleep( + clk_id: crate::clockid_t, + flags: c_int, + rqtp: *const crate::timespec, + rmtp: *mut crate::timespec, + ) -> c_int; + pub fn pthread_attr_getguardsize( + attr: *const crate::pthread_attr_t, + guardsize: *mut size_t, + ) -> c_int; + pub fn pthread_attr_setguardsize(attr: *mut crate::pthread_attr_t, guardsize: size_t) -> c_int; + pub fn sethostname(name: *const c_char, len: size_t) -> c_int; + pub fn sched_get_priority_min(policy: c_int) -> c_int; + pub fn pthread_condattr_getpshared( + attr: *const pthread_condattr_t, + pshared: *mut c_int, + ) -> c_int; + pub fn pthread_setschedparam( + native: crate::pthread_t, + policy: c_int, + param: *const crate::sched_param, + ) -> c_int; + pub fn sched_setscheduler( + pid: crate::pid_t, + policy: c_int, + param: *const crate::sched_param, + ) -> c_int; + pub fn sigsuspend(mask: *const crate::sigset_t) -> c_int; + pub fn getgrgid_r( + gid: crate::gid_t, + grp: *mut crate::group, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::group, + ) -> c_int; + pub fn sem_close(sem: *mut sem_t) -> c_int; + pub fn getdtablesize() -> c_int; + pub fn getgrnam_r( + name: *const c_char, + grp: *mut crate::group, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::group, + ) -> c_int; + pub fn initgroups(user: *const c_char, group: crate::gid_t) -> c_int; + pub fn pthread_sigmask(how: c_int, set: *const sigset_t, oldset: *mut sigset_t) -> c_int; + pub fn sem_open(name: *const c_char, oflag: c_int, ...) -> *mut sem_t; + pub fn getgrnam(name: *const c_char) -> *mut crate::group; + pub fn pthread_cancel(thread: crate::pthread_t) -> c_int; + pub fn pthread_kill(thread: crate::pthread_t, sig: c_int) -> c_int; + pub fn sem_unlink(name: *const c_char) -> c_int; + pub fn daemon(nochdir: c_int, noclose: c_int) -> c_int; + pub fn getpwnam_r( + name: *const c_char, + pwd: *mut passwd, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut passwd, + ) -> c_int; + pub fn getpwuid_r( + uid: crate::uid_t, + pwd: *mut passwd, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut passwd, + ) -> c_int; + pub fn sigwait(set: *const sigset_t, sig: *mut c_int) -> c_int; + pub fn pthread_atfork( + prepare: Option, + parent: Option, + child: Option, + ) -> c_int; + pub fn getgrgid(gid: crate::gid_t) -> *mut crate::group; + pub fn getgrouplist( + user: *const c_char, + group: crate::gid_t, + groups: *mut crate::gid_t, + ngroups: *mut c_int, + ) -> c_int; + pub fn pthread_mutexattr_getpshared( + attr: *const pthread_mutexattr_t, + pshared: *mut c_int, + ) -> c_int; + pub fn pthread_mutexattr_getrobust( + attr: *const pthread_mutexattr_t, + robustness: *mut c_int, + ) -> c_int; + pub fn pthread_mutexattr_setrobust(attr: *mut pthread_mutexattr_t, robustness: c_int) -> c_int; + pub fn pthread_create( + native: *mut crate::pthread_t, + attr: *const crate::pthread_attr_t, + f: extern "C" fn(*mut c_void) -> *mut c_void, + value: *mut c_void, + ) -> c_int; + pub fn getitimer(which: c_int, curr_value: *mut crate::itimerval) -> c_int; + pub fn setitimer( + which: c_int, + value: *const crate::itimerval, + ovalue: *mut crate::itimerval, + ) -> c_int; + pub fn posix_spawn( + pid: *mut crate::pid_t, + path: *const c_char, + file_actions: *const crate::posix_spawn_file_actions_t, + attrp: *const crate::posix_spawnattr_t, + argv: *const *mut c_char, + envp: *const *mut c_char, + ) -> c_int; + pub fn posix_spawnp( + pid: *mut crate::pid_t, + file: *const c_char, + file_actions: *const crate::posix_spawn_file_actions_t, + attrp: *const crate::posix_spawnattr_t, + argv: *const *mut c_char, + envp: *const *mut c_char, + ) -> c_int; + pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> c_int; + pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> c_int; + pub fn posix_spawnattr_getsigdefault( + attr: *const posix_spawnattr_t, + default: *mut crate::sigset_t, + ) -> c_int; + pub fn posix_spawnattr_setsigdefault( + attr: *mut posix_spawnattr_t, + default: *const crate::sigset_t, + ) -> c_int; + pub fn posix_spawnattr_getsigmask( + attr: *const posix_spawnattr_t, + default: *mut crate::sigset_t, + ) -> c_int; + pub fn posix_spawnattr_setsigmask( + attr: *mut posix_spawnattr_t, + default: *const crate::sigset_t, + ) -> c_int; + pub fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t, flags: *mut c_short) -> c_int; + pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t, flags: c_short) -> c_int; + pub fn posix_spawnattr_getpgroup( + attr: *const posix_spawnattr_t, + flags: *mut crate::pid_t, + ) -> c_int; + pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, flags: crate::pid_t) -> c_int; + pub fn posix_spawnattr_getschedpolicy( + attr: *const posix_spawnattr_t, + flags: *mut c_int, + ) -> c_int; + pub fn posix_spawnattr_setschedpolicy(attr: *mut posix_spawnattr_t, flags: c_int) -> c_int; + pub fn posix_spawnattr_getschedparam( + attr: *const posix_spawnattr_t, + param: *mut crate::sched_param, + ) -> c_int; + pub fn posix_spawnattr_setschedparam( + attr: *mut posix_spawnattr_t, + param: *const crate::sched_param, + ) -> c_int; + + pub fn posix_spawn_file_actions_init(actions: *mut posix_spawn_file_actions_t) -> c_int; + pub fn posix_spawn_file_actions_destroy(actions: *mut posix_spawn_file_actions_t) -> c_int; + pub fn posix_spawn_file_actions_addopen( + actions: *mut posix_spawn_file_actions_t, + fd: c_int, + path: *const c_char, + oflag: c_int, + mode: mode_t, + ) -> c_int; + pub fn posix_spawn_file_actions_addclose( + actions: *mut posix_spawn_file_actions_t, + fd: c_int, + ) -> c_int; + pub fn posix_spawn_file_actions_adddup2( + actions: *mut posix_spawn_file_actions_t, + fd: c_int, + newfd: c_int, + ) -> c_int; + pub fn popen(command: *const c_char, mode: *const c_char) -> *mut crate::FILE; + pub fn faccessat(dirfd: c_int, pathname: *const c_char, mode: c_int, flags: c_int) -> c_int; + pub fn inotify_rm_watch(fd: c_int, wd: c_int) -> c_int; + pub fn inotify_init() -> c_int; + pub fn inotify_add_watch(fd: c_int, path: *const c_char, mask: u32) -> c_int; + + pub fn gettid() -> crate::pid_t; + + pub fn pthread_getcpuclockid(thread: crate::pthread_t, clk_id: *mut crate::clockid_t) -> c_int; + + pub fn getnameinfo( + sa: *const crate::sockaddr, + salen: crate::socklen_t, + host: *mut c_char, + hostlen: crate::socklen_t, + serv: *mut c_char, + servlen: crate::socklen_t, + flags: c_int, + ) -> c_int; + + pub fn mallopt(param: c_int, value: i64) -> c_int; + pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut c_void) -> c_int; + + pub fn ctermid(s: *mut c_char) -> *mut c_char; + pub fn ioctl(fd: c_int, request: c_int, ...) -> c_int; + + pub fn mallinfo() -> crate::mallinfo; + pub fn getpwent_r( + pwd: *mut crate::passwd, + buf: *mut c_char, + __bufsize: c_int, + __result: *mut *mut crate::passwd, + ) -> c_int; + pub fn pthread_getname_np(thread: crate::pthread_t, name: *mut c_char, len: c_int) -> c_int; + pub fn pthread_setname_np(thread: crate::pthread_t, name: *const c_char) -> c_int; + + pub fn sysctl( + _: *const c_int, + _: c_uint, + _: *mut c_void, + _: *mut size_t, + _: *const c_void, + _: size_t, + ) -> c_int; + + pub fn getrlimit(resource: c_int, rlim: *mut crate::rlimit) -> c_int; + pub fn setrlimit(resource: c_int, rlp: *const crate::rlimit) -> c_int; + + pub fn lio_listio( + __mode: c_int, + __list: *const *mut aiocb, + __nent: c_int, + __sig: *mut sigevent, + ) -> c_int; + + pub fn dl_iterate_phdr( + callback: Option< + unsafe extern "C" fn( + // The original .h file declares this as *const, but for consistency with other platforms, + // changing this to *mut to make it easier to use. + // Maybe in v0.3 all platforms should use this as a *const. + info: *mut dl_phdr_info, + size: size_t, + data: *mut c_void, + ) -> c_int, + >, + data: *mut c_void, + ) -> c_int; + + pub fn memset_s(s: *mut c_void, smax: size_t, c: c_int, n: size_t) -> c_int; + + pub fn regcomp(__preg: *mut crate::regex_t, __pattern: *const c_char, __cflags: c_int) + -> c_int; + pub fn regexec( + __preg: *const crate::regex_t, + __str: *const c_char, + __nmatch: size_t, + __pmatch: *mut crate::regmatch_t, + __eflags: c_int, + ) -> c_int; + pub fn regerror( + __errcode: c_int, + __preg: *const crate::regex_t, + __errbuf: *mut c_char, + __errbuf_size: size_t, + ) -> size_t; + pub fn regfree(__preg: *mut crate::regex_t); + pub fn dirfd(__dirp: *mut crate::DIR) -> c_int; + pub fn dircntl(dir: *mut crate::DIR, cmd: c_int, ...) -> c_int; + + pub fn aio_cancel(__fd: c_int, __aiocbp: *mut crate::aiocb) -> c_int; + pub fn aio_error(__aiocbp: *const crate::aiocb) -> c_int; + pub fn aio_fsync(__operation: c_int, __aiocbp: *mut crate::aiocb) -> c_int; + pub fn aio_read(__aiocbp: *mut crate::aiocb) -> c_int; + pub fn aio_return(__aiocpb: *mut crate::aiocb) -> ssize_t; + pub fn aio_suspend( + __list: *const *const crate::aiocb, + __nent: c_int, + __timeout: *const crate::timespec, + ) -> c_int; + pub fn aio_write(__aiocpb: *mut crate::aiocb) -> c_int; + + pub fn mq_close(__mqdes: crate::mqd_t) -> c_int; + pub fn mq_getattr(__mqdes: crate::mqd_t, __mqstat: *mut crate::mq_attr) -> c_int; + pub fn mq_notify(__mqdes: crate::mqd_t, __notification: *const crate::sigevent) -> c_int; + pub fn mq_open(__name: *const c_char, __oflag: c_int, ...) -> crate::mqd_t; + pub fn mq_receive( + __mqdes: crate::mqd_t, + __msg_ptr: *mut c_char, + __msg_len: size_t, + __msg_prio: *mut c_uint, + ) -> ssize_t; + pub fn mq_send( + __mqdes: crate::mqd_t, + __msg_ptr: *const c_char, + __msg_len: size_t, + __msg_prio: c_uint, + ) -> c_int; + pub fn mq_setattr( + __mqdes: crate::mqd_t, + __mqstat: *const mq_attr, + __omqstat: *mut mq_attr, + ) -> c_int; + pub fn mq_timedreceive( + __mqdes: crate::mqd_t, + __msg_ptr: *mut c_char, + __msg_len: size_t, + __msg_prio: *mut c_uint, + __abs_timeout: *const crate::timespec, + ) -> ssize_t; + pub fn mq_timedsend( + __mqdes: crate::mqd_t, + __msg_ptr: *const c_char, + __msg_len: size_t, + __msg_prio: c_uint, + __abs_timeout: *const crate::timespec, + ) -> c_int; + pub fn mq_unlink(__name: *const c_char) -> c_int; + pub fn __get_errno_ptr() -> *mut c_int; + + // System page, see https://www.qnx.com/developers/docs/7.1#com.qnx.doc.neutrino.building/topic/syspage/syspage_about.html + pub static mut _syspage_ptr: *mut syspage_entry; + + // Function on the stack after a call to pthread_create(). This is used + // as a sentinel to work around an infitnite loop in the unwinding code. + pub fn __my_thread_exit(value_ptr: *mut *const c_void); +} + +// Models the implementation in stdlib.h. Ctest will fail if trying to use the +// default symbol from libc +pub unsafe fn atexit(cb: extern "C" fn()) -> c_int { + extern "C" { + static __dso_handle: *mut c_void; + pub fn __cxa_atexit(cb: extern "C" fn(), __arg: *mut c_void, __dso: *mut c_void) -> c_int; + } + __cxa_atexit(cb, 0 as *mut c_void, __dso_handle) +} + +impl siginfo_t { + pub unsafe fn si_addr(&self) -> *mut c_void { + #[repr(C)] + struct siginfo_si_addr { + _pad: Padding<[u8; 32]>, + si_addr: *mut c_void, + } + (*(self as *const siginfo_t as *const siginfo_si_addr)).si_addr + } + + pub unsafe fn si_value(&self) -> crate::sigval { + #[repr(C)] + struct siginfo_si_value { + _pad: Padding<[u8; 32]>, + si_value: crate::sigval, + } + (*(self as *const siginfo_t as *const siginfo_si_value)).si_value + } + + pub unsafe fn si_pid(&self) -> crate::pid_t { + #[repr(C)] + struct siginfo_si_pid { + _pad: Padding<[u8; 16]>, + si_pid: crate::pid_t, + } + (*(self as *const siginfo_t as *const siginfo_si_pid)).si_pid + } + + pub unsafe fn si_uid(&self) -> crate::uid_t { + #[repr(C)] + struct siginfo_si_uid { + _pad: Padding<[u8; 24]>, + si_uid: crate::uid_t, + } + (*(self as *const siginfo_t as *const siginfo_si_uid)).si_uid + } + + pub unsafe fn si_status(&self) -> c_int { + #[repr(C)] + struct siginfo_si_status { + _pad: Padding<[u8; 28]>, + si_status: c_int, + } + (*(self as *const siginfo_t as *const siginfo_si_status)).si_status + } +} + +cfg_if! { + if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } else if #[cfg(target_arch = "aarch64")] { + mod aarch64; + pub use self::aarch64::*; + } else { + panic!("Unsupported arch"); + } +} + +mod neutrino; +pub use self::neutrino::*; diff --git a/http/vendor/libc/src/unix/nto/neutrino.rs b/http/vendor/libc/src/unix/nto/neutrino.rs new file mode 100644 index 0000000..4c3fca1 --- /dev/null +++ b/http/vendor/libc/src/unix/nto/neutrino.rs @@ -0,0 +1,1270 @@ +use crate::prelude::*; + +pub type nto_job_t = crate::sync_t; + +s! { + pub struct syspage_entry_info { + pub entry_off: u16, + pub entry_size: u16, + } + pub struct syspage_array_info { + entry_off: u16, + entry_size: u16, + element_size: u16, + } + + pub struct intrspin { + pub value: c_uint, // volatile + } + + pub struct iov_t { + pub iov_base: *mut c_void, // union + pub iov_len: size_t, + } + + pub struct _itimer { + pub nsec: u64, + pub interval_nsec: u64, + } + + pub struct _msg_info64 { + pub nd: u32, + pub srcnd: u32, + pub pid: crate::pid_t, + pub tid: i32, + pub chid: i32, + pub scoid: i32, + pub coid: i32, + pub priority: i16, + pub flags: i16, + pub msglen: isize, + pub srcmsglen: isize, + pub dstmsglen: isize, + pub type_id: u32, + reserved: Padding, + } + + pub struct _cred_info { + pub ruid: crate::uid_t, + pub euid: crate::uid_t, + pub suid: crate::uid_t, + pub rgid: crate::gid_t, + pub egid: crate::gid_t, + pub sgid: crate::gid_t, + pub ngroups: u32, + pub grouplist: [crate::gid_t; 8], + } + + pub struct _client_info { + pub nd: u32, + pub pid: crate::pid_t, + pub sid: crate::pid_t, + pub flags: u32, + pub cred: crate::_cred_info, + } + + pub struct _client_able { + pub ability: u32, + pub flags: u32, + pub range_lo: u64, + pub range_hi: u64, + } + + pub struct nto_channel_config { + pub event: crate::sigevent, + pub num_pulses: c_uint, + pub rearm_threshold: c_uint, + pub options: c_uint, + reserved: Padding<[c_uint; 3]>, + } + + // TODO: The following structures are defined in a header file which doesn't + // appear as part of the default headers found in a standard installation + // of Neutrino 7.1 SDP. Commented out for now. + //pub struct _asyncmsg_put_header { + // pub err: c_int, + // pub iov: *mut crate::iov_t, + // pub parts: c_int, + // pub handle: c_uint, + // pub cb: Option< + // unsafe extern "C" fn( + // err: c_int, + // buf: *mut c_void, + // handle: c_uint, + // ) -> c_int>, + // pub put_hdr_flags: c_uint, + //} + + //pub struct _asyncmsg_connection_attr { + // pub call_back: Option< + // unsafe extern "C" fn( + // err: c_int, + // buff: *mut c_void, + // handle: c_uint, + // ) -> c_int>, + // pub buffer_size: size_t, + // pub max_num_buffer: c_uint, + // pub trigger_num_msg: c_uint, + // pub trigger_time: crate::_itimer, + // reserve: Padding, + //} + + //pub struct _asyncmsg_connection_descriptor { + // pub flags: c_uint, + // pub sendq_size: c_uint, + // pub sendq_head: c_uint, + // pub sendq_tail: c_uint, + // pub sendq_free: c_uint, + // pub err: c_int, + // pub ev: crate::sigevent, + // pub num_curmsg: c_uint, + // pub ttimer: crate::timer_t, + // pub block_con: crate::pthread_cond_t, + // pub mu: crate::pthread_mutex_t, + // reserved: Padding, + // pub attr: crate::_asyncmsg_connection_attr, + // reserves: Padding<[c_uint; 3]>, + // pub sendq: [crate::_asyncmsg_put_header; 1], // flexarray + //} + + pub struct __c_anonymous_struct_ev { + pub event: crate::sigevent, + pub coid: c_int, + } + + pub struct _channel_connect_attr { + // union + pub ev: crate::__c_anonymous_struct_ev, + } + + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct _sighandler_info { + pub siginfo: crate::siginfo_t, + pub handler: Option, + pub context: *mut c_void, + } + + pub struct __c_anonymous_struct_time { + pub length: c_uint, + pub scale: c_uint, + } + + pub struct _idle_hook { + pub hook_size: c_uint, + pub cmd: c_uint, + pub mode: c_uint, + pub latency: c_uint, + pub next_fire: u64, + pub curr_time: u64, + pub tod_adjust: u64, + pub resp: c_uint, + pub time: __c_anonymous_struct_time, + pub trigger: crate::sigevent, + pub intrs: *mut c_uint, + pub block_stack_size: c_uint, + } + + pub struct _clockadjust { + pub tick_count: u32, + pub tick_nsec_inc: i32, + } + + pub struct qtime_entry { + pub cycles_per_sec: u64, + pub nsec_tod_adjust: u64, // volatile + pub nsec: u64, // volatile + pub nsec_inc: u32, + pub boot_time: u32, + pub adjust: _clockadjust, + pub timer_rate: u32, + pub timer_scale: i32, + pub timer_load: u32, + pub intr: i32, + pub epoch: u32, + pub flags: u32, + pub rr_interval_mul: u32, + pub timer_load_hi: u32, + pub nsec_stable: u64, // volatile + pub timer_load_max: u64, + pub timer_prog_time: u32, + spare: [u32; 7], + } + + pub struct _sched_info { + pub priority_min: c_int, + pub priority_max: c_int, + pub interval: u64, + pub priority_priv: c_int, + reserved: Padding<[c_int; 11]>, + } + + pub struct _timer_info { + pub itime: crate::_itimer, + pub otime: crate::_itimer, + pub flags: u32, + pub tid: i32, + pub notify: i32, + pub clockid: crate::clockid_t, + pub overruns: u32, + pub event: crate::sigevent, // union + } + + pub struct _clockperiod { + pub nsec: u32, + pub fract: i32, + } +} + +s_no_extra_traits! { + #[repr(align(8))] + pub struct syspage_entry { + pub size: u16, + pub total_size: u16, + pub type_: u16, + pub num_cpu: u16, + pub system_private: syspage_entry_info, + pub old_asinfo: syspage_entry_info, + pub __mangle_name_to_cause_compilation_errs_meminfo: syspage_entry_info, + pub hwinfo: syspage_entry_info, + pub old_cpuinfo: syspage_entry_info, + pub old_cacheattr: syspage_entry_info, + pub qtime: syspage_entry_info, + pub callout: syspage_entry_info, + pub callin: syspage_entry_info, + pub typed_strings: syspage_entry_info, + pub strings: syspage_entry_info, + pub old_intrinfo: syspage_entry_info, + pub smp: syspage_entry_info, + pub pminfo: syspage_entry_info, + pub old_mdriver: syspage_entry_info, + spare0: [u32; 1], + __reserved: Padding<[u8; 160]>, // anonymous union with architecture dependent structs + pub new_asinfo: syspage_array_info, + pub new_cpuinfo: syspage_array_info, + pub new_cacheattr: syspage_array_info, + pub new_intrinfo: syspage_array_info, + pub new_mdriver: syspage_array_info, + } +} + +pub const SYSMGR_PID: u32 = 1; +pub const SYSMGR_CHID: u32 = 1; +pub const SYSMGR_COID: u32 = _NTO_SIDE_CHANNEL; +pub const SYSMGR_HANDLE: u32 = 0; + +pub const STATE_DEAD: c_int = 0x00; +pub const STATE_RUNNING: c_int = 0x01; +pub const STATE_READY: c_int = 0x02; +pub const STATE_STOPPED: c_int = 0x03; +pub const STATE_SEND: c_int = 0x04; +pub const STATE_RECEIVE: c_int = 0x05; +pub const STATE_REPLY: c_int = 0x06; +pub const STATE_STACK: c_int = 0x07; +pub const STATE_WAITTHREAD: c_int = 0x08; +pub const STATE_WAITPAGE: c_int = 0x09; +pub const STATE_SIGSUSPEND: c_int = 0x0a; +pub const STATE_SIGWAITINFO: c_int = 0x0b; +pub const STATE_NANOSLEEP: c_int = 0x0c; +pub const STATE_MUTEX: c_int = 0x0d; +pub const STATE_CONDVAR: c_int = 0x0e; +pub const STATE_JOIN: c_int = 0x0f; +pub const STATE_INTR: c_int = 0x10; +pub const STATE_SEM: c_int = 0x11; +pub const STATE_WAITCTX: c_int = 0x12; +pub const STATE_NET_SEND: c_int = 0x13; +pub const STATE_NET_REPLY: c_int = 0x14; +pub const STATE_MAX: c_int = 0x18; + +pub const _NTO_TIMEOUT_RECEIVE: i32 = 1 << STATE_RECEIVE; +pub const _NTO_TIMEOUT_SEND: i32 = 1 << STATE_SEND; +pub const _NTO_TIMEOUT_REPLY: i32 = 1 << STATE_REPLY; +pub const _NTO_TIMEOUT_SIGSUSPEND: i32 = 1 << STATE_SIGSUSPEND; +pub const _NTO_TIMEOUT_SIGWAITINFO: i32 = 1 << STATE_SIGWAITINFO; +pub const _NTO_TIMEOUT_NANOSLEEP: i32 = 1 << STATE_NANOSLEEP; +pub const _NTO_TIMEOUT_MUTEX: i32 = 1 << STATE_MUTEX; +pub const _NTO_TIMEOUT_CONDVAR: i32 = 1 << STATE_CONDVAR; +pub const _NTO_TIMEOUT_JOIN: i32 = 1 << STATE_JOIN; +pub const _NTO_TIMEOUT_INTR: i32 = 1 << STATE_INTR; +pub const _NTO_TIMEOUT_SEM: i32 = 1 << STATE_SEM; + +pub const _NTO_MI_ENDIAN_BIG: u32 = 1; +pub const _NTO_MI_ENDIAN_DIFF: u32 = 2; +pub const _NTO_MI_UNBLOCK_REQ: u32 = 256; +pub const _NTO_MI_NET_CRED_DIRTY: u32 = 512; +pub const _NTO_MI_CONSTRAINED: u32 = 1024; +pub const _NTO_MI_CHROOT: u32 = 2048; +pub const _NTO_MI_BITS_64: u32 = 4096; +pub const _NTO_MI_BITS_DIFF: u32 = 8192; +pub const _NTO_MI_SANDBOX: u32 = 16384; + +pub const _NTO_CI_ENDIAN_BIG: u32 = 1; +pub const _NTO_CI_BKGND_PGRP: u32 = 4; +pub const _NTO_CI_ORPHAN_PGRP: u32 = 8; +pub const _NTO_CI_STOPPED: u32 = 128; +pub const _NTO_CI_UNABLE: u32 = 256; +pub const _NTO_CI_TYPE_ID: u32 = 512; +pub const _NTO_CI_CHROOT: u32 = 2048; +pub const _NTO_CI_BITS_64: u32 = 4096; +pub const _NTO_CI_SANDBOX: u32 = 16384; +pub const _NTO_CI_LOADER: u32 = 32768; +pub const _NTO_CI_FULL_GROUPS: u32 = 2147483648; + +pub const _NTO_TI_ACTIVE: u32 = 1; +pub const _NTO_TI_ABSOLUTE: u32 = 2; +pub const _NTO_TI_EXPIRED: u32 = 4; +pub const _NTO_TI_TOD_BASED: u32 = 8; +pub const _NTO_TI_TARGET_PROCESS: u32 = 16; +pub const _NTO_TI_REPORT_TOLERANCE: u32 = 32; +pub const _NTO_TI_PRECISE: u32 = 64; +pub const _NTO_TI_TOLERANT: u32 = 128; +pub const _NTO_TI_WAKEUP: u32 = 256; +pub const _NTO_TI_PROCESS_TOLERANT: u32 = 512; +pub const _NTO_TI_HIGH_RESOLUTION: u32 = 1024; + +pub const _PULSE_TYPE: u32 = 0; +pub const _PULSE_SUBTYPE: u32 = 0; +pub const _PULSE_CODE_UNBLOCK: i32 = -32; +pub const _PULSE_CODE_DISCONNECT: i32 = -33; +pub const _PULSE_CODE_THREADDEATH: i32 = -34; +pub const _PULSE_CODE_COIDDEATH: i32 = -35; +pub const _PULSE_CODE_NET_ACK: i32 = -36; +pub const _PULSE_CODE_NET_UNBLOCK: i32 = -37; +pub const _PULSE_CODE_NET_DETACH: i32 = -38; +pub const _PULSE_CODE_RESTART: i32 = -39; +pub const _PULSE_CODE_NORESTART: i32 = -40; +pub const _PULSE_CODE_UNBLOCK_RESTART: i32 = -41; +pub const _PULSE_CODE_UNBLOCK_TIMER: i32 = -42; +pub const _PULSE_CODE_MINAVAIL: u32 = 0; +pub const _PULSE_CODE_MAXAVAIL: u32 = 127; + +pub const _NTO_HARD_FLAGS_END: u32 = 1; + +pub const _NTO_PULSE_IF_UNIQUE: u32 = 4096; +pub const _NTO_PULSE_REPLACE: u32 = 8192; + +pub const _NTO_PF_NOCLDSTOP: u32 = 1; +pub const _NTO_PF_LOADING: u32 = 2; +pub const _NTO_PF_TERMING: u32 = 4; +pub const _NTO_PF_ZOMBIE: u32 = 8; +pub const _NTO_PF_NOZOMBIE: u32 = 16; +pub const _NTO_PF_FORKED: u32 = 32; +pub const _NTO_PF_ORPHAN_PGRP: u32 = 64; +pub const _NTO_PF_STOPPED: u32 = 128; +pub const _NTO_PF_DEBUG_STOPPED: u32 = 256; +pub const _NTO_PF_BKGND_PGRP: u32 = 512; +pub const _NTO_PF_NOISYNC: u32 = 1024; +pub const _NTO_PF_CONTINUED: u32 = 2048; +pub const _NTO_PF_CHECK_INTR: u32 = 4096; +pub const _NTO_PF_COREDUMP: u32 = 8192; +pub const _NTO_PF_RING0: u32 = 32768; +pub const _NTO_PF_SLEADER: u32 = 65536; +pub const _NTO_PF_WAITINFO: u32 = 131072; +pub const _NTO_PF_DESTROYALL: u32 = 524288; +pub const _NTO_PF_NOCOREDUMP: u32 = 1048576; +pub const _NTO_PF_WAITDONE: u32 = 4194304; +pub const _NTO_PF_TERM_WAITING: u32 = 8388608; +pub const _NTO_PF_ASLR: u32 = 16777216; +pub const _NTO_PF_EXECED: u32 = 33554432; +pub const _NTO_PF_APP_STOPPED: u32 = 67108864; +pub const _NTO_PF_64BIT: u32 = 134217728; +pub const _NTO_PF_NET: u32 = 268435456; +pub const _NTO_PF_NOLAZYSTACK: u32 = 536870912; +pub const _NTO_PF_NOEXEC_STACK: u32 = 1073741824; +pub const _NTO_PF_LOADER_PERMS: u32 = 2147483648; + +pub const _NTO_TF_INTR_PENDING: u32 = 65536; +pub const _NTO_TF_DETACHED: u32 = 131072; +pub const _NTO_TF_SHR_MUTEX: u32 = 262144; +pub const _NTO_TF_SHR_MUTEX_EUID: u32 = 524288; +pub const _NTO_TF_THREADS_HOLD: u32 = 1048576; +pub const _NTO_TF_UNBLOCK_REQ: u32 = 4194304; +pub const _NTO_TF_ALIGN_FAULT: u32 = 16777216; +pub const _NTO_TF_SSTEP: u32 = 33554432; +pub const _NTO_TF_ALLOCED_STACK: u32 = 67108864; +pub const _NTO_TF_NOMULTISIG: u32 = 134217728; +pub const _NTO_TF_LOW_LATENCY: u32 = 268435456; +pub const _NTO_TF_IOPRIV: u32 = 2147483648; + +pub const _NTO_TCTL_IO_PRIV: u32 = 1; +pub const _NTO_TCTL_THREADS_HOLD: u32 = 2; +pub const _NTO_TCTL_THREADS_CONT: u32 = 3; +pub const _NTO_TCTL_RUNMASK: u32 = 4; +pub const _NTO_TCTL_ALIGN_FAULT: u32 = 5; +pub const _NTO_TCTL_RUNMASK_GET_AND_SET: u32 = 6; +pub const _NTO_TCTL_PERFCOUNT: u32 = 7; +pub const _NTO_TCTL_ONE_THREAD_HOLD: u32 = 8; +pub const _NTO_TCTL_ONE_THREAD_CONT: u32 = 9; +pub const _NTO_TCTL_RUNMASK_GET_AND_SET_INHERIT: u32 = 10; +pub const _NTO_TCTL_NAME: u32 = 11; +pub const _NTO_TCTL_RCM_GET_AND_SET: u32 = 12; +pub const _NTO_TCTL_SHR_MUTEX: u32 = 13; +pub const _NTO_TCTL_IO: u32 = 14; +pub const _NTO_TCTL_NET_KIF_GET_AND_SET: u32 = 15; +pub const _NTO_TCTL_LOW_LATENCY: u32 = 16; +pub const _NTO_TCTL_ADD_EXIT_EVENT: u32 = 17; +pub const _NTO_TCTL_DEL_EXIT_EVENT: u32 = 18; +pub const _NTO_TCTL_IO_LEVEL: u32 = 19; +pub const _NTO_TCTL_RESERVED: u32 = 2147483648; +pub const _NTO_TCTL_IO_LEVEL_INHERIT: u32 = 1073741824; +pub const _NTO_IO_LEVEL_NONE: u32 = 1; +pub const _NTO_IO_LEVEL_1: u32 = 2; +pub const _NTO_IO_LEVEL_2: u32 = 3; + +pub const _NTO_THREAD_NAME_MAX: u32 = 100; + +pub const _NTO_CHF_FIXED_PRIORITY: u32 = 1; +pub const _NTO_CHF_UNBLOCK: u32 = 2; +pub const _NTO_CHF_THREAD_DEATH: u32 = 4; +pub const _NTO_CHF_DISCONNECT: u32 = 8; +pub const _NTO_CHF_NET_MSG: u32 = 16; +pub const _NTO_CHF_SENDER_LEN: u32 = 32; +pub const _NTO_CHF_COID_DISCONNECT: u32 = 64; +pub const _NTO_CHF_REPLY_LEN: u32 = 128; +pub const _NTO_CHF_PULSE_POOL: u32 = 256; +pub const _NTO_CHF_ASYNC_NONBLOCK: u32 = 512; +pub const _NTO_CHF_ASYNC: u32 = 1024; +pub const _NTO_CHF_GLOBAL: u32 = 2048; +pub const _NTO_CHF_PRIVATE: u32 = 4096; +pub const _NTO_CHF_MSG_PAUSING: u32 = 8192; +pub const _NTO_CHF_INHERIT_RUNMASK: u32 = 16384; +pub const _NTO_CHF_UNBLOCK_TIMER: u32 = 32768; + +pub const _NTO_CHO_CUSTOM_EVENT: u32 = 1; + +pub const _NTO_COF_CLOEXEC: u32 = 1; +pub const _NTO_COF_DEAD: u32 = 2; +pub const _NTO_COF_NOSHARE: u32 = 64; +pub const _NTO_COF_NETCON: u32 = 128; +pub const _NTO_COF_NONBLOCK: u32 = 256; +pub const _NTO_COF_ASYNC: u32 = 512; +pub const _NTO_COF_GLOBAL: u32 = 1024; +pub const _NTO_COF_NOEVENT: u32 = 2048; +pub const _NTO_COF_INSECURE: u32 = 4096; +pub const _NTO_COF_REG_EVENTS: u32 = 8192; +pub const _NTO_COF_UNREG_EVENTS: u32 = 16384; +pub const _NTO_COF_MASK: u32 = 65535; + +pub const _NTO_SIDE_CHANNEL: u32 = 1073741824; + +pub const _NTO_CONNECTION_SCOID: u32 = 65536; +pub const _NTO_GLOBAL_CHANNEL: u32 = 1073741824; + +pub const _NTO_TIMEOUT_MASK: u32 = (1 << STATE_MAX) - 1; +pub const _NTO_TIMEOUT_ACTIVE: u32 = 1 << STATE_MAX; +pub const _NTO_TIMEOUT_IMMEDIATE: u32 = 1 << (STATE_MAX + 1); + +pub const _NTO_IC_LATENCY: u32 = 0; + +pub const _NTO_INTR_FLAGS_END: u32 = 1; +pub const _NTO_INTR_FLAGS_NO_UNMASK: u32 = 2; +pub const _NTO_INTR_FLAGS_PROCESS: u32 = 4; +pub const _NTO_INTR_FLAGS_TRK_MSK: u32 = 8; +pub const _NTO_INTR_FLAGS_ARRAY: u32 = 16; +pub const _NTO_INTR_FLAGS_EXCLUSIVE: u32 = 32; +pub const _NTO_INTR_FLAGS_FPU: u32 = 64; + +pub const _NTO_INTR_CLASS_EXTERNAL: u32 = 0; +pub const _NTO_INTR_CLASS_SYNTHETIC: u32 = 2147418112; + +pub const _NTO_INTR_SPARE: u32 = 2147483647; + +pub const _NTO_HOOK_IDLE: u32 = 2147418113; +pub const _NTO_HOOK_OVERDRIVE: u32 = 2147418114; +pub const _NTO_HOOK_LAST: u32 = 2147418114; +pub const _NTO_HOOK_IDLE2_FLAG: u32 = 32768; + +pub const _NTO_IH_CMD_SLEEP_SETUP: u32 = 1; +pub const _NTO_IH_CMD_SLEEP_BLOCK: u32 = 2; +pub const _NTO_IH_CMD_SLEEP_WAKEUP: u32 = 4; +pub const _NTO_IH_CMD_SLEEP_ONLINE: u32 = 8; +pub const _NTO_IH_RESP_NEEDS_BLOCK: u32 = 1; +pub const _NTO_IH_RESP_NEEDS_WAKEUP: u32 = 2; +pub const _NTO_IH_RESP_NEEDS_ONLINE: u32 = 4; +pub const _NTO_IH_RESP_SYNC_TIME: u32 = 16; +pub const _NTO_IH_RESP_SYNC_TLB: u32 = 32; +pub const _NTO_IH_RESP_SUGGEST_OFFLINE: u32 = 256; +pub const _NTO_IH_RESP_SLEEP_MODE_REACHED: u32 = 512; +pub const _NTO_IH_RESP_DELIVER_INTRS: u32 = 1024; + +pub const _NTO_READIOV_SEND: u32 = 0; +pub const _NTO_READIOV_REPLY: u32 = 1; + +pub const _NTO_KEYDATA_VTID: u32 = 2147483648; + +pub const _NTO_KEYDATA_PATHSIGN: u32 = 32768; +pub const _NTO_KEYDATA_OP_MASK: u32 = 255; +pub const _NTO_KEYDATA_VERIFY: u32 = 0; +pub const _NTO_KEYDATA_CALCULATE: u32 = 1; +pub const _NTO_KEYDATA_CALCULATE_REUSE: u32 = 2; +pub const _NTO_KEYDATA_PATHSIGN_VERIFY: u32 = 32768; +pub const _NTO_KEYDATA_PATHSIGN_CALCULATE: u32 = 32769; +pub const _NTO_KEYDATA_PATHSIGN_CALCULATE_REUSE: u32 = 32770; + +pub const _NTO_SCTL_SETPRIOCEILING: u32 = 1; +pub const _NTO_SCTL_GETPRIOCEILING: u32 = 2; +pub const _NTO_SCTL_SETEVENT: u32 = 3; +pub const _NTO_SCTL_MUTEX_WAKEUP: u32 = 4; +pub const _NTO_SCTL_MUTEX_CONSISTENT: u32 = 5; +pub const _NTO_SCTL_SEM_VALUE: u32 = 6; + +pub const _NTO_CLIENTINFO_GETGROUPS: u32 = 1; +pub const _NTO_CLIENTINFO_GETTYPEID: u32 = 2; + +extern "C" { + pub fn ChannelCreate(__flags: c_uint) -> c_int; + pub fn ChannelCreate_r(__flags: c_uint) -> c_int; + pub fn ChannelCreatePulsePool(__flags: c_uint, __config: *const nto_channel_config) -> c_int; + pub fn ChannelCreateExt( + __flags: c_uint, + __mode: crate::mode_t, + __bufsize: usize, + __maxnumbuf: c_uint, + __ev: *const crate::sigevent, + __cred: *mut _cred_info, + ) -> c_int; + pub fn ChannelDestroy(__chid: c_int) -> c_int; + pub fn ChannelDestroy_r(__chid: c_int) -> c_int; + pub fn ConnectAttach( + __nd: u32, + __pid: crate::pid_t, + __chid: c_int, + __index: c_uint, + __flags: c_int, + ) -> c_int; + pub fn ConnectAttach_r( + __nd: u32, + __pid: crate::pid_t, + __chid: c_int, + __index: c_uint, + __flags: c_int, + ) -> c_int; + + // TODO: The following function uses a structure defined in a header file + // which doesn't appear as part of the default headers found in a + // standard installation of Neutrino 7.1 SDP. Commented out for now. + //pub fn ConnectAttachExt( + // __nd: u32, + // __pid: crate::pid_t, + // __chid: c_int, + // __index: c_uint, + // __flags: c_int, + // __cd: *mut _asyncmsg_connection_descriptor, + //) -> c_int; + pub fn ConnectDetach(__coid: c_int) -> c_int; + pub fn ConnectDetach_r(__coid: c_int) -> c_int; + pub fn ConnectServerInfo(__pid: crate::pid_t, __coid: c_int, __info: *mut _msg_info64) + -> c_int; + pub fn ConnectServerInfo_r( + __pid: crate::pid_t, + __coid: c_int, + __info: *mut _msg_info64, + ) -> c_int; + pub fn ConnectClientInfoExtraArgs( + __scoid: c_int, + __info_pp: *mut _client_info, + __ngroups: c_int, + __abilities: *mut _client_able, + __nable: c_int, + __type_id: *mut c_uint, + ) -> c_int; + pub fn ConnectClientInfoExtraArgs_r( + __scoid: c_int, + __info_pp: *mut _client_info, + __ngroups: c_int, + __abilities: *mut _client_able, + __nable: c_int, + __type_id: *mut c_uint, + ) -> c_int; + pub fn ConnectClientInfo(__scoid: c_int, __info: *mut _client_info, __ngroups: c_int) -> c_int; + pub fn ConnectClientInfo_r( + __scoid: c_int, + __info: *mut _client_info, + __ngroups: c_int, + ) -> c_int; + pub fn ConnectClientInfoExt( + __scoid: c_int, + __info_pp: *mut *mut _client_info, + flags: c_int, + ) -> c_int; + pub fn ClientInfoExtFree(__info_pp: *mut *mut _client_info) -> c_int; + pub fn ConnectClientInfoAble( + __scoid: c_int, + __info_pp: *mut *mut _client_info, + flags: c_int, + abilities: *mut _client_able, + nable: c_int, + ) -> c_int; + pub fn ConnectFlags( + __pid: crate::pid_t, + __coid: c_int, + __mask: c_uint, + __bits: c_uint, + ) -> c_int; + pub fn ConnectFlags_r( + __pid: crate::pid_t, + __coid: c_int, + __mask: c_uint, + __bits: c_uint, + ) -> c_int; + pub fn ChannelConnectAttr( + __id: c_uint, + __old_attr: *mut _channel_connect_attr, + __new_attr: *mut _channel_connect_attr, + __flags: c_uint, + ) -> c_int; + pub fn MsgSend( + __coid: c_int, + __smsg: *const c_void, + __sbytes: usize, + __rmsg: *mut c_void, + __rbytes: usize, + ) -> c_long; + pub fn MsgSend_r( + __coid: c_int, + __smsg: *const c_void, + __sbytes: usize, + __rmsg: *mut c_void, + __rbytes: usize, + ) -> c_long; + pub fn MsgSendnc( + __coid: c_int, + __smsg: *const c_void, + __sbytes: usize, + __rmsg: *mut c_void, + __rbytes: usize, + ) -> c_long; + pub fn MsgSendnc_r( + __coid: c_int, + __smsg: *const c_void, + __sbytes: usize, + __rmsg: *mut c_void, + __rbytes: usize, + ) -> c_long; + pub fn MsgSendsv( + __coid: c_int, + __smsg: *const c_void, + __sbytes: usize, + __riov: *const crate::iovec, + __rparts: usize, + ) -> c_long; + pub fn MsgSendsv_r( + __coid: c_int, + __smsg: *const c_void, + __sbytes: usize, + __riov: *const crate::iovec, + __rparts: usize, + ) -> c_long; + pub fn MsgSendsvnc( + __coid: c_int, + __smsg: *const c_void, + __sbytes: usize, + __riov: *const crate::iovec, + __rparts: usize, + ) -> c_long; + pub fn MsgSendsvnc_r( + __coid: c_int, + __smsg: *const c_void, + __sbytes: usize, + __riov: *const crate::iovec, + __rparts: usize, + ) -> c_long; + pub fn MsgSendvs( + __coid: c_int, + __siov: *const crate::iovec, + __sparts: usize, + __rmsg: *mut c_void, + __rbytes: usize, + ) -> c_long; + pub fn MsgSendvs_r( + __coid: c_int, + __siov: *const crate::iovec, + __sparts: usize, + __rmsg: *mut c_void, + __rbytes: usize, + ) -> c_long; + pub fn MsgSendvsnc( + __coid: c_int, + __siov: *const crate::iovec, + __sparts: usize, + __rmsg: *mut c_void, + __rbytes: usize, + ) -> c_long; + pub fn MsgSendvsnc_r( + __coid: c_int, + __siov: *const crate::iovec, + __sparts: usize, + __rmsg: *mut c_void, + __rbytes: usize, + ) -> c_long; + pub fn MsgSendv( + __coid: c_int, + __siov: *const crate::iovec, + __sparts: usize, + __riov: *const crate::iovec, + __rparts: usize, + ) -> c_long; + pub fn MsgSendv_r( + __coid: c_int, + __siov: *const crate::iovec, + __sparts: usize, + __riov: *const crate::iovec, + __rparts: usize, + ) -> c_long; + pub fn MsgSendvnc( + __coid: c_int, + __siov: *const crate::iovec, + __sparts: usize, + __riov: *const crate::iovec, + __rparts: usize, + ) -> c_long; + pub fn MsgSendvnc_r( + __coid: c_int, + __siov: *const crate::iovec, + __sparts: usize, + __riov: *const crate::iovec, + __rparts: usize, + ) -> c_long; + pub fn MsgReceive( + __chid: c_int, + __msg: *mut c_void, + __bytes: usize, + __info: *mut _msg_info64, + ) -> c_int; + pub fn MsgReceive_r( + __chid: c_int, + __msg: *mut c_void, + __bytes: usize, + __info: *mut _msg_info64, + ) -> c_int; + pub fn MsgReceivev( + __chid: c_int, + __iov: *const crate::iovec, + __parts: usize, + __info: *mut _msg_info64, + ) -> c_int; + pub fn MsgReceivev_r( + __chid: c_int, + __iov: *const crate::iovec, + __parts: usize, + __info: *mut _msg_info64, + ) -> c_int; + pub fn MsgReceivePulse( + __chid: c_int, + __pulse: *mut c_void, + __bytes: usize, + __info: *mut _msg_info64, + ) -> c_int; + pub fn MsgReceivePulse_r( + __chid: c_int, + __pulse: *mut c_void, + __bytes: usize, + __info: *mut _msg_info64, + ) -> c_int; + pub fn MsgReceivePulsev( + __chid: c_int, + __iov: *const crate::iovec, + __parts: usize, + __info: *mut _msg_info64, + ) -> c_int; + pub fn MsgReceivePulsev_r( + __chid: c_int, + __iov: *const crate::iovec, + __parts: usize, + __info: *mut _msg_info64, + ) -> c_int; + pub fn MsgReply( + __rcvid: c_int, + __status: c_long, + __msg: *const c_void, + __bytes: usize, + ) -> c_int; + pub fn MsgReply_r( + __rcvid: c_int, + __status: c_long, + __msg: *const c_void, + __bytes: usize, + ) -> c_int; + pub fn MsgReplyv( + __rcvid: c_int, + __status: c_long, + __iov: *const crate::iovec, + __parts: usize, + ) -> c_int; + pub fn MsgReplyv_r( + __rcvid: c_int, + __status: c_long, + __iov: *const crate::iovec, + __parts: usize, + ) -> c_int; + pub fn MsgReadiov( + __rcvid: c_int, + __iov: *const crate::iovec, + __parts: usize, + __offset: usize, + __flags: c_int, + ) -> isize; + pub fn MsgReadiov_r( + __rcvid: c_int, + __iov: *const crate::iovec, + __parts: usize, + __offset: usize, + __flags: c_int, + ) -> isize; + pub fn MsgRead(__rcvid: c_int, __msg: *mut c_void, __bytes: usize, __offset: usize) -> isize; + pub fn MsgRead_r(__rcvid: c_int, __msg: *mut c_void, __bytes: usize, __offset: usize) -> isize; + pub fn MsgReadv( + __rcvid: c_int, + __iov: *const crate::iovec, + __parts: usize, + __offset: usize, + ) -> isize; + pub fn MsgReadv_r( + __rcvid: c_int, + __iov: *const crate::iovec, + __parts: usize, + __offset: usize, + ) -> isize; + pub fn MsgWrite(__rcvid: c_int, __msg: *const c_void, __bytes: usize, __offset: usize) + -> isize; + pub fn MsgWrite_r( + __rcvid: c_int, + __msg: *const c_void, + __bytes: usize, + __offset: usize, + ) -> isize; + pub fn MsgWritev( + __rcvid: c_int, + __iov: *const crate::iovec, + __parts: usize, + __offset: usize, + ) -> isize; + pub fn MsgWritev_r( + __rcvid: c_int, + __iov: *const crate::iovec, + __parts: usize, + __offset: usize, + ) -> isize; + pub fn MsgSendPulse(__coid: c_int, __priority: c_int, __code: c_int, __value: c_int) -> c_int; + pub fn MsgSendPulse_r(__coid: c_int, __priority: c_int, __code: c_int, __value: c_int) + -> c_int; + pub fn MsgSendPulsePtr( + __coid: c_int, + __priority: c_int, + __code: c_int, + __value: *mut c_void, + ) -> c_int; + pub fn MsgSendPulsePtr_r( + __coid: c_int, + __priority: c_int, + __code: c_int, + __value: *mut c_void, + ) -> c_int; + pub fn MsgDeliverEvent(__rcvid: c_int, __event: *const crate::sigevent) -> c_int; + pub fn MsgDeliverEvent_r(__rcvid: c_int, __event: *const crate::sigevent) -> c_int; + pub fn MsgVerifyEvent(__rcvid: c_int, __event: *const crate::sigevent) -> c_int; + pub fn MsgVerifyEvent_r(__rcvid: c_int, __event: *const crate::sigevent) -> c_int; + pub fn MsgRegisterEvent(__event: *mut crate::sigevent, __coid: c_int) -> c_int; + pub fn MsgRegisterEvent_r(__event: *mut crate::sigevent, __coid: c_int) -> c_int; + pub fn MsgUnregisterEvent(__event: *const crate::sigevent) -> c_int; + pub fn MsgUnregisterEvent_r(__event: *const crate::sigevent) -> c_int; + pub fn MsgInfo(__rcvid: c_int, __info: *mut _msg_info64) -> c_int; + pub fn MsgInfo_r(__rcvid: c_int, __info: *mut _msg_info64) -> c_int; + pub fn MsgKeyData( + __rcvid: c_int, + __oper: c_int, + __key: u32, + __newkey: *mut u32, + __iov: *const crate::iovec, + __parts: c_int, + ) -> c_int; + pub fn MsgKeyData_r( + __rcvid: c_int, + __oper: c_int, + __key: u32, + __newkey: *mut u32, + __iov: *const crate::iovec, + __parts: c_int, + ) -> c_int; + pub fn MsgError(__rcvid: c_int, __err: c_int) -> c_int; + pub fn MsgError_r(__rcvid: c_int, __err: c_int) -> c_int; + pub fn MsgCurrent(__rcvid: c_int) -> c_int; + pub fn MsgCurrent_r(__rcvid: c_int) -> c_int; + pub fn MsgSendAsyncGbl( + __coid: c_int, + __smsg: *const c_void, + __sbytes: usize, + __msg_prio: c_uint, + ) -> c_int; + pub fn MsgSendAsync(__coid: c_int) -> c_int; + pub fn MsgReceiveAsyncGbl( + __chid: c_int, + __rmsg: *mut c_void, + __rbytes: usize, + __info: *mut _msg_info64, + __coid: c_int, + ) -> c_int; + pub fn MsgReceiveAsync(__chid: c_int, __iov: *const crate::iovec, __parts: c_uint) -> c_int; + pub fn MsgPause(__rcvid: c_int, __cookie: c_uint) -> c_int; + pub fn MsgPause_r(__rcvid: c_int, __cookie: c_uint) -> c_int; + + pub fn SignalKill( + __nd: u32, + __pid: crate::pid_t, + __tid: c_int, + __signo: c_int, + __code: c_int, + __value: c_int, + ) -> c_int; + pub fn SignalKill_r( + __nd: u32, + __pid: crate::pid_t, + __tid: c_int, + __signo: c_int, + __code: c_int, + __value: c_int, + ) -> c_int; + pub fn SignalKillSigval( + __nd: u32, + __pid: crate::pid_t, + __tid: c_int, + __signo: c_int, + __code: c_int, + __value: *const crate::sigval, + ) -> c_int; + pub fn SignalKillSigval_r( + __nd: u32, + __pid: crate::pid_t, + __tid: c_int, + __signo: c_int, + __code: c_int, + __value: *const crate::sigval, + ) -> c_int; + pub fn SignalReturn(__info: *mut _sighandler_info) -> c_int; + pub fn SignalFault(__sigcode: c_uint, __regs: *mut c_void, __refaddr: usize) -> c_int; + pub fn SignalAction( + __pid: crate::pid_t, + __sigstub: unsafe extern "C" fn(), + __signo: c_int, + __act: *const crate::sigaction, + __oact: *mut crate::sigaction, + ) -> c_int; + pub fn SignalAction_r( + __pid: crate::pid_t, + __sigstub: unsafe extern "C" fn(), + __signo: c_int, + __act: *const crate::sigaction, + __oact: *mut crate::sigaction, + ) -> c_int; + pub fn SignalProcmask( + __pid: crate::pid_t, + __tid: c_int, + __how: c_int, + __set: *const crate::sigset_t, + __oldset: *mut crate::sigset_t, + ) -> c_int; + pub fn SignalProcmask_r( + __pid: crate::pid_t, + __tid: c_int, + __how: c_int, + __set: *const crate::sigset_t, + __oldset: *mut crate::sigset_t, + ) -> c_int; + pub fn SignalSuspend(__set: *const crate::sigset_t) -> c_int; + pub fn SignalSuspend_r(__set: *const crate::sigset_t) -> c_int; + pub fn SignalWaitinfo(__set: *const crate::sigset_t, __info: *mut crate::siginfo_t) -> c_int; + pub fn SignalWaitinfo_r(__set: *const crate::sigset_t, __info: *mut crate::siginfo_t) -> c_int; + pub fn SignalWaitinfoMask( + __set: *const crate::sigset_t, + __info: *mut crate::siginfo_t, + __mask: *const crate::sigset_t, + ) -> c_int; + pub fn SignalWaitinfoMask_r( + __set: *const crate::sigset_t, + __info: *mut crate::siginfo_t, + __mask: *const crate::sigset_t, + ) -> c_int; + pub fn ThreadCreate( + __pid: crate::pid_t, + __func: unsafe extern "C" fn(__arg: *mut c_void) -> *mut c_void, + __arg: *mut c_void, + __attr: *const crate::_thread_attr, + ) -> c_int; + pub fn ThreadCreate_r( + __pid: crate::pid_t, + __func: unsafe extern "C" fn(__arg: *mut c_void) -> *mut c_void, + __arg: *mut c_void, + __attr: *const crate::_thread_attr, + ) -> c_int; + + pub fn ThreadDestroy(__tid: c_int, __priority: c_int, __status: *mut c_void) -> c_int; + pub fn ThreadDestroy_r(__tid: c_int, __priority: c_int, __status: *mut c_void) -> c_int; + pub fn ThreadDetach(__tid: c_int) -> c_int; + pub fn ThreadDetach_r(__tid: c_int) -> c_int; + pub fn ThreadJoin(__tid: c_int, __status: *mut *mut c_void) -> c_int; + pub fn ThreadJoin_r(__tid: c_int, __status: *mut *mut c_void) -> c_int; + pub fn ThreadCancel(__tid: c_int, __canstub: unsafe extern "C" fn()) -> c_int; + pub fn ThreadCancel_r(__tid: c_int, __canstub: unsafe extern "C" fn()) -> c_int; + pub fn ThreadCtl(__cmd: c_int, __data: *mut c_void) -> c_int; + pub fn ThreadCtl_r(__cmd: c_int, __data: *mut c_void) -> c_int; + pub fn ThreadCtlExt( + __pid: crate::pid_t, + __tid: c_int, + __cmd: c_int, + __data: *mut c_void, + ) -> c_int; + pub fn ThreadCtlExt_r( + __pid: crate::pid_t, + __tid: c_int, + __cmd: c_int, + __data: *mut c_void, + ) -> c_int; + + pub fn InterruptHookTrace( + __handler: Option *const crate::sigevent>, + __flags: c_uint, + ) -> c_int; + pub fn InterruptHookIdle( + __handler: Option, + __flags: c_uint, + ) -> c_int; + pub fn InterruptHookIdle2( + __handler: Option< + unsafe extern "C" fn(arg1: c_uint, arg2: *mut syspage_entry, arg3: *mut _idle_hook), + >, + __flags: c_uint, + ) -> c_int; + pub fn InterruptHookOverdriveEvent(__event: *const crate::sigevent, __flags: c_uint) -> c_int; + pub fn InterruptAttachEvent( + __intr: c_int, + __event: *const crate::sigevent, + __flags: c_uint, + ) -> c_int; + pub fn InterruptAttachEvent_r( + __intr: c_int, + __event: *const crate::sigevent, + __flags: c_uint, + ) -> c_int; + pub fn InterruptAttach( + __intr: c_int, + __handler: Option< + unsafe extern "C" fn(__area: *mut c_void, __id: c_int) -> *const crate::sigevent, + >, + __area: *const c_void, + __size: c_int, + __flags: c_uint, + ) -> c_int; + pub fn InterruptAttach_r( + __intr: c_int, + __handler: Option< + unsafe extern "C" fn(__area: *mut c_void, __id: c_int) -> *const crate::sigevent, + >, + __area: *const c_void, + __size: c_int, + __flags: c_uint, + ) -> c_int; + pub fn InterruptAttachArray( + __intr: c_int, + __handler: Option< + unsafe extern "C" fn(__area: *mut c_void, __id: c_int) -> *const *const crate::sigevent, + >, + __area: *const c_void, + __size: c_int, + __flags: c_uint, + ) -> c_int; + pub fn InterruptAttachArray_r( + __intr: c_int, + __handler: Option< + unsafe extern "C" fn(__area: *mut c_void, __id: c_int) -> *const *const crate::sigevent, + >, + __area: *const c_void, + __size: c_int, + __flags: c_uint, + ) -> c_int; + pub fn InterruptDetach(__id: c_int) -> c_int; + pub fn InterruptDetach_r(__id: c_int) -> c_int; + pub fn InterruptWait(__flags: c_int, __timeout: *const u64) -> c_int; + pub fn InterruptWait_r(__flags: c_int, __timeout: *const u64) -> c_int; + pub fn InterruptCharacteristic( + __type: c_int, + __id: c_int, + __new: *mut c_uint, + __old: *mut c_uint, + ) -> c_int; + pub fn InterruptCharacteristic_r( + __type: c_int, + __id: c_int, + __new: *mut c_uint, + __old: *mut c_uint, + ) -> c_int; + + pub fn SchedGet(__pid: crate::pid_t, __tid: c_int, __param: *mut crate::sched_param) -> c_int; + pub fn SchedGet_r(__pid: crate::pid_t, __tid: c_int, __param: *mut crate::sched_param) + -> c_int; + pub fn SchedGetCpuNum() -> c_uint; + pub fn SchedSet( + __pid: crate::pid_t, + __tid: c_int, + __algorithm: c_int, + __param: *const crate::sched_param, + ) -> c_int; + pub fn SchedSet_r( + __pid: crate::pid_t, + __tid: c_int, + __algorithm: c_int, + __param: *const crate::sched_param, + ) -> c_int; + pub fn SchedInfo( + __pid: crate::pid_t, + __algorithm: c_int, + __info: *mut crate::_sched_info, + ) -> c_int; + pub fn SchedInfo_r( + __pid: crate::pid_t, + __algorithm: c_int, + __info: *mut crate::_sched_info, + ) -> c_int; + pub fn SchedYield() -> c_int; + pub fn SchedYield_r() -> c_int; + pub fn SchedCtl(__cmd: c_int, __data: *mut c_void, __length: usize) -> c_int; + pub fn SchedCtl_r(__cmd: c_int, __data: *mut c_void, __length: usize) -> c_int; + pub fn SchedJobCreate(__job: *mut nto_job_t) -> c_int; + pub fn SchedJobCreate_r(__job: *mut nto_job_t) -> c_int; + pub fn SchedJobDestroy(__job: *mut nto_job_t) -> c_int; + pub fn SchedJobDestroy_r(__job: *mut nto_job_t) -> c_int; + pub fn SchedWaypoint( + __job: *mut nto_job_t, + __new: *const i64, + __max: *const i64, + __old: *mut i64, + ) -> c_int; + pub fn SchedWaypoint_r( + __job: *mut nto_job_t, + __new: *const i64, + __max: *const i64, + __old: *mut i64, + ) -> c_int; + + pub fn TimerCreate(__id: crate::clockid_t, __notify: *const crate::sigevent) -> c_int; + pub fn TimerCreate_r(__id: crate::clockid_t, __notify: *const crate::sigevent) -> c_int; + pub fn TimerDestroy(__id: crate::timer_t) -> c_int; + pub fn TimerDestroy_r(__id: crate::timer_t) -> c_int; + pub fn TimerSettime( + __id: crate::timer_t, + __flags: c_int, + __itime: *const crate::_itimer, + __oitime: *mut crate::_itimer, + ) -> c_int; + pub fn TimerSettime_r( + __id: crate::timer_t, + __flags: c_int, + __itime: *const crate::_itimer, + __oitime: *mut crate::_itimer, + ) -> c_int; + pub fn TimerInfo( + __pid: crate::pid_t, + __id: crate::timer_t, + __flags: c_int, + __info: *mut crate::_timer_info, + ) -> c_int; + pub fn TimerInfo_r( + __pid: crate::pid_t, + __id: crate::timer_t, + __flags: c_int, + __info: *mut crate::_timer_info, + ) -> c_int; + pub fn TimerAlarm( + __id: crate::clockid_t, + __itime: *const crate::_itimer, + __otime: *mut crate::_itimer, + ) -> c_int; + pub fn TimerAlarm_r( + __id: crate::clockid_t, + __itime: *const crate::_itimer, + __otime: *mut crate::_itimer, + ) -> c_int; + pub fn TimerTimeout( + __id: crate::clockid_t, + __flags: c_int, + __notify: *const crate::sigevent, + __ntime: *const u64, + __otime: *mut u64, + ) -> c_int; + pub fn TimerTimeout_r( + __id: crate::clockid_t, + __flags: c_int, + __notify: *const crate::sigevent, + __ntime: *const u64, + __otime: *mut u64, + ) -> c_int; + + pub fn SyncTypeCreate( + __type: c_uint, + __sync: *mut crate::sync_t, + __attr: *const crate::_sync_attr, + ) -> c_int; + pub fn SyncTypeCreate_r( + __type: c_uint, + __sync: *mut crate::sync_t, + __attr: *const crate::_sync_attr, + ) -> c_int; + pub fn SyncDestroy(__sync: *mut crate::sync_t) -> c_int; + pub fn SyncDestroy_r(__sync: *mut crate::sync_t) -> c_int; + pub fn SyncCtl(__cmd: c_int, __sync: *mut crate::sync_t, __data: *mut c_void) -> c_int; + pub fn SyncCtl_r(__cmd: c_int, __sync: *mut crate::sync_t, __data: *mut c_void) -> c_int; + pub fn SyncMutexEvent(__sync: *mut crate::sync_t, event: *const crate::sigevent) -> c_int; + pub fn SyncMutexEvent_r(__sync: *mut crate::sync_t, event: *const crate::sigevent) -> c_int; + pub fn SyncMutexLock(__sync: *mut crate::sync_t) -> c_int; + pub fn SyncMutexLock_r(__sync: *mut crate::sync_t) -> c_int; + pub fn SyncMutexUnlock(__sync: *mut crate::sync_t) -> c_int; + pub fn SyncMutexUnlock_r(__sync: *mut crate::sync_t) -> c_int; + pub fn SyncMutexRevive(__sync: *mut crate::sync_t) -> c_int; + pub fn SyncMutexRevive_r(__sync: *mut crate::sync_t) -> c_int; + pub fn SyncCondvarWait(__sync: *mut crate::sync_t, __mutex: *mut crate::sync_t) -> c_int; + pub fn SyncCondvarWait_r(__sync: *mut crate::sync_t, __mutex: *mut crate::sync_t) -> c_int; + pub fn SyncCondvarSignal(__sync: *mut crate::sync_t, __all: c_int) -> c_int; + pub fn SyncCondvarSignal_r(__sync: *mut crate::sync_t, __all: c_int) -> c_int; + pub fn SyncSemPost(__sync: *mut crate::sync_t) -> c_int; + pub fn SyncSemPost_r(__sync: *mut crate::sync_t) -> c_int; + pub fn SyncSemWait(__sync: *mut crate::sync_t, __tryto: c_int) -> c_int; + pub fn SyncSemWait_r(__sync: *mut crate::sync_t, __tryto: c_int) -> c_int; + + pub fn ClockTime(__id: crate::clockid_t, _new: *const u64, __old: *mut u64) -> c_int; + pub fn ClockTime_r(__id: crate::clockid_t, _new: *const u64, __old: *mut u64) -> c_int; + pub fn ClockAdjust( + __id: crate::clockid_t, + _new: *const crate::_clockadjust, + __old: *mut crate::_clockadjust, + ) -> c_int; + pub fn ClockAdjust_r( + __id: crate::clockid_t, + _new: *const crate::_clockadjust, + __old: *mut crate::_clockadjust, + ) -> c_int; + pub fn ClockPeriod( + __id: crate::clockid_t, + _new: *const crate::_clockperiod, + __old: *mut crate::_clockperiod, + __reserved: c_int, + ) -> c_int; + pub fn ClockPeriod_r( + __id: crate::clockid_t, + _new: *const crate::_clockperiod, + __old: *mut crate::_clockperiod, + __reserved: c_int, + ) -> c_int; + pub fn ClockId(__pid: crate::pid_t, __tid: c_int) -> c_int; + pub fn ClockId_r(__pid: crate::pid_t, __tid: c_int) -> c_int; + + // + //TODO: The following commented out functions are implemented in assembly. + // We can implmement them either via a C stub or rust's inline assembly. + // + //pub fn InterruptEnable(); + //pub fn InterruptDisable(); + pub fn InterruptMask(__intr: c_int, __id: c_int) -> c_int; + pub fn InterruptUnmask(__intr: c_int, __id: c_int) -> c_int; + //pub fn InterruptLock(__spin: *mut intrspin); + //pub fn InterruptUnlock(__spin: *mut intrspin); + //pub fn InterruptStatus() -> c_uint; +} diff --git a/http/vendor/libc/src/unix/nto/x86_64.rs b/http/vendor/libc/src/unix/nto/x86_64.rs new file mode 100644 index 0000000..b8e0b22 --- /dev/null +++ b/http/vendor/libc/src/unix/nto/x86_64.rs @@ -0,0 +1,111 @@ +use crate::prelude::*; + +pub type wchar_t = u32; +pub type time_t = i64; + +s! { + #[repr(align(8))] + pub struct x86_64_cpu_registers { + pub rdi: u64, + pub rsi: u64, + pub rdx: u64, + pub r10: u64, + pub r8: u64, + pub r9: u64, + pub rax: u64, + pub rbx: u64, + pub rbp: u64, + pub rcx: u64, + pub r11: u64, + pub r12: u64, + pub r13: u64, + pub r14: u64, + pub r15: u64, + pub rip: u64, + pub cs: u32, + rsvd1: Padding, + pub rflags: u64, + pub rsp: u64, + pub ss: u32, + rsvd2: Padding, + } + + #[repr(align(8))] + pub struct mcontext_t { + pub cpu: x86_64_cpu_registers, + pub fpu: x86_64_fpu_registers, + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_size: size_t, + pub ss_flags: c_int, + } + + pub struct fsave_area_64 { + pub fpu_control_word: u32, + pub fpu_status_word: u32, + pub fpu_tag_word: u32, + pub fpu_ip: u32, + pub fpu_cs: u32, + pub fpu_op: u32, + pub fpu_ds: u32, + pub st_regs: [u8; 80], + } + + pub struct fxsave_area_64 { + pub fpu_control_word: u16, + pub fpu_status_word: u16, + pub fpu_tag_word: u16, + pub fpu_operand: u16, + pub fpu_rip: u64, + pub fpu_rdp: u64, + pub mxcsr: u32, + pub mxcsr_mask: u32, + pub st_regs: [u8; 128], + pub xmm_regs: [u8; 128], + reserved2: Padding<[u8; 224]>, + } + + pub struct fpu_extention_savearea_64 { + pub other: [u8; 512], + pub xstate_bv: u64, + pub xstate_undef: [u64; 7], + pub xstate_info: [u8; 224], + } +} + +s_no_extra_traits! { + pub union x86_64_fpu_registers { + pub fsave_area: fsave_area_64, + pub fxsave_area: fxsave_area_64, + pub xsave_area: fpu_extention_savearea_64, + pub data: [u8; 1024], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl Eq for x86_64_fpu_registers {} + + impl PartialEq for x86_64_fpu_registers { + fn eq(&self, other: &x86_64_fpu_registers) -> bool { + unsafe { + self.fsave_area == other.fsave_area + || self.fxsave_area == other.fxsave_area + || self.xsave_area == other.xsave_area + } + } + } + + impl hash::Hash for x86_64_fpu_registers { + fn hash(&self, state: &mut H) { + unsafe { + self.fsave_area.hash(state); + self.fxsave_area.hash(state); + self.xsave_area.hash(state); + } + } + } + } +} diff --git a/http/vendor/libc/src/unix/nuttx/mod.rs b/http/vendor/libc/src/unix/nuttx/mod.rs new file mode 100644 index 0000000..150dc43 --- /dev/null +++ b/http/vendor/libc/src/unix/nuttx/mod.rs @@ -0,0 +1,594 @@ +use crate::prelude::*; +use crate::{ + in6_addr, + in_addr_t, + timespec, + DIR, +}; + +pub type nlink_t = u16; +pub type ino_t = u16; +pub type blkcnt_t = u64; +pub type blksize_t = i16; +pub type cc_t = u8; +pub type clock_t = i64; +pub type dev_t = i32; +pub type fsblkcnt_t = u64; +pub type locale_t = *mut i8; +pub type mode_t = u32; +pub type nfds_t = u32; +pub type off_t = i64; +pub type pthread_key_t = i32; +pub type pthread_mutexattr_t = u8; +pub type pthread_rwlockattr_t = i32; +pub type pthread_t = i32; +pub type rlim_t = i64; +pub type sa_family_t = u16; +pub type socklen_t = u32; +pub type speed_t = usize; +pub type suseconds_t = i32; +pub type tcflag_t = u32; +pub type clockid_t = i32; +pub type time_t = i64; +pub type wchar_t = i32; + +s! { + pub struct stat { + pub st_dev: dev_t, + pub st_ino: ino_t, + pub st_mode: mode_t, + pub st_nlink: nlink_t, + pub st_uid: u32, + pub st_gid: u32, + pub st_rdev: dev_t, + pub st_size: off_t, + pub st_atim: timespec, + pub st_mtim: timespec, + pub st_ctim: timespec, + pub st_blksize: blksize_t, + pub st_blocks: i64, + __reserved: Padding<[usize; __DEFAULT_RESERVED_SIZE__]>, + } + + pub struct sockaddr { + pub sa_family: sa_family_t, + pub sa_data: [u8; 14], + } + + pub struct passwd { + pub pw_name: *const c_char, + pub pw_passwd: *const c_char, + pub pw_uid: u32, + pub pw_gid: u32, + pub pw_gecos: *const c_char, + pub pw_dir: *const c_char, + pub pw_shell: *const c_char, + __reserved: Padding<[usize; __DEFAULT_RESERVED_SIZE__]>, + } + + pub struct sem_t { + __val: [usize; __SEM_SIZE__], + } + + pub struct pthread_attr_t { + __val: [usize; __PTHREAD_ATTR_SIZE__], + } + + pub struct pthread_mutex_t { + __val: [usize; __PTHREAD_MUTEX_SIZE__], + } + + pub struct pthread_cond_t { + __val: [usize; __PTHREAD_COND_SIZE__], + } + + pub struct pthread_condattr_t { + __val: [usize; __PTHREAD_CONDATTR_SIZE__], + } + + pub struct Dl_info { + pub dli_fname: *const c_char, + pub dli_fbase: *mut c_void, + pub dli_sname: *const c_char, + pub dli_saddr: *mut c_void, + } + + pub struct lconv { + pub decimal_point: *const c_char, + pub thousands_sep: *const c_char, + pub grouping: *const c_char, + pub int_curr_symbol: *const c_char, + pub currency_symbol: *const c_char, + pub mon_decimal_point: *const c_char, + pub mon_thousands_sep: *const c_char, + pub mon_grouping: *const c_char, + pub positive_sign: *const c_char, + pub negative_sign: *const c_char, + pub int_frac_digits: i8, + pub frac_digits: i8, + pub p_cs_precedes: i8, + pub p_sep_by_space: i8, + pub n_cs_precedes: i8, + pub n_sep_by_space: i8, + pub p_sign_posn: i8, + pub n_sign_posn: i8, + pub int_n_cs_precedes: i8, + pub int_n_sep_by_space: i8, + pub int_n_sign_posn: i8, + pub int_p_cs_precedes: i8, + pub int_p_sep_by_space: i8, + pub int_p_sign_posn: i8, + __reserved: Padding<[usize; __DEFAULT_RESERVED_SIZE__]>, + } + + pub struct tm { + pub tm_sec: i32, + pub tm_min: i32, + pub tm_hour: i32, + pub tm_mday: i32, + pub tm_mon: i32, + pub tm_year: i32, + pub tm_wday: i32, + pub tm_yday: i32, + pub tm_isdst: i32, + pub tm_gmtoff: isize, + pub tm_zone: *const c_char, + __reserved: Padding<[usize; __DEFAULT_RESERVED_SIZE__]>, + } + + pub struct addrinfo { + pub ai_flags: i32, + pub ai_family: i32, + pub ai_socktype: i32, + pub ai_protocol: i32, + pub ai_addrlen: socklen_t, + pub ai_addr: *mut sockaddr, + pub ai_canonname: *mut c_char, + pub ai_next: *mut addrinfo, + __reserved: Padding<[usize; __DEFAULT_RESERVED_SIZE__]>, + } + + pub struct pthread_rwlock_t { + __val: [usize; __PTHREAD_RWLOCK_SIZE__], + } + + pub struct statvfs { + pub f_bsize: usize, + pub f_frsize: usize, + pub f_blocks: fsblkcnt_t, + pub f_bfree: fsblkcnt_t, + pub f_bavail: fsblkcnt_t, + pub f_files: fsblkcnt_t, + pub f_ffree: fsblkcnt_t, + pub f_favail: fsblkcnt_t, + pub f_fsid: usize, + pub f_flag: usize, + pub f_namemax: usize, + __reserved: Padding<[usize; __DEFAULT_RESERVED_SIZE__]>, + } + + pub struct dirent { + pub d_type: u8, + pub d_name: [c_char; __NAME_MAX__ + 1], + } + + pub struct fd_set { + __val: [u32; __FDSET_SIZE__], + } + + pub struct sigset_t { + __val: [u32; __SIGSET_SIZE__], + } + + pub struct sigaction { + pub sa_handler: usize, + pub sa_mask: sigset_t, + pub sa_flags: i32, + pub sa_user: usize, + __reserved: Padding<[usize; __DEFAULT_RESERVED_SIZE__]>, + } + + pub struct termios { + pub c_iflag: tcflag_t, + pub c_oflag: tcflag_t, + pub c_cflag: tcflag_t, + pub c_lflag: tcflag_t, + pub c_cc: [cc_t; 12], + pub c_speed: speed_t, + __reserved: Padding<[usize; __DEFAULT_RESERVED_SIZE__]>, + } + + pub struct in_addr { + pub s_addr: in_addr_t, + } + + pub struct sockaddr_in { + pub sin_family: sa_family_t, + pub sin_port: crate::in_port_t, + pub sin_addr: crate::in_addr, + pub sin_zero: [u8; 8], + } + + pub struct sockaddr_in6 { + pub sin6_family: sa_family_t, + pub sin6_port: crate::in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: crate::in6_addr, + pub sin6_scope_id: u32, + } + + pub struct sockaddr_un { + pub sun_family: sa_family_t, + pub sun_path: [c_char; 108], + } + + pub struct sockaddr_storage { + pub ss_family: sa_family_t, + ss_data: [u32; __SOCKADDR_STORAGE_SIZE__], + } + + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct ipv6_mreq { + pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_interface: u32, + } +} + +// Reserved two pointer size for reserved area for some structures. +// This ensures that the size of these structures is large enough +// if more fields are added in the NuttX side. +// +// These structures are that defined by POSIX but only necessary fields are included, +// for example, struct passwd, https://pubs.opengroup.org/onlinepubs/009695399/basedefs/pwd.h.html, +// POSIX only defines following fields in struct passwd: +// char *pw_name User's login name. +// char *pw_passwd Encrypted password. +// uid_t pw_uid Numerical user ID. +// gid_t pw_gid Numerical group ID. +// char *pw_dir Initial working directory. +// char *pw_shell Program to use as shell. +// Other fields can be different depending on the implementation. + +const __DEFAULT_RESERVED_SIZE__: usize = 2; + +const __SOCKADDR_STORAGE_SIZE__: usize = 36; +const __PTHREAD_ATTR_SIZE__: usize = 5; +const __PTHREAD_MUTEX_SIZE__: usize = 9; +const __PTHREAD_COND_SIZE__: usize = 7; +const __PTHREAD_CONDATTR_SIZE__: usize = 5; +const __PTHREAD_RWLOCK_SIZE__: usize = 17; +const __SEM_SIZE__: usize = 6; +const __NAME_MAX__: usize = 64; +const __FDSET_SIZE__: usize = 10; +const __SIGSET_SIZE__: usize = 8; + +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + __val: [0; __PTHREAD_COND_SIZE__], +}; +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + __val: [0; __PTHREAD_MUTEX_SIZE__], +}; + +// dlfcn.h +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); + +// stdlib.h +pub const EXIT_SUCCESS: i32 = 0; +pub const EXIT_FAILURE: i32 = 1; + +// time.h +pub const CLOCK_REALTIME: i32 = 0; +pub const CLOCK_MONOTONIC: i32 = 1; + +// errno.h +pub const EPERM: i32 = 1; +pub const ENOENT: i32 = 2; +pub const ESRCH: i32 = 3; +pub const EINTR: i32 = 4; +pub const EIO: i32 = 5; +pub const ENXIO: i32 = 6; +pub const E2BIG: i32 = 7; +pub const ENOEXEC: i32 = 8; +pub const EBADF: i32 = 9; +pub const ECHILD: i32 = 10; +pub const EAGAIN: i32 = 11; +pub const ENOMEM: i32 = 12; +pub const EACCES: i32 = 13; +pub const EFAULT: i32 = 14; +pub const ENOTBLK: i32 = 15; +pub const EBUSY: i32 = 16; +pub const EEXIST: i32 = 17; +pub const EXDEV: i32 = 18; +pub const ENODEV: i32 = 19; +pub const ENOTDIR: i32 = 20; +pub const EISDIR: i32 = 21; +pub const EINVAL: i32 = 22; +pub const ENFILE: i32 = 23; +pub const EMFILE: i32 = 24; +pub const ENOTTY: i32 = 25; +pub const ETXTBSY: i32 = 26; +pub const EFBIG: i32 = 27; +pub const ENOSPC: i32 = 28; +pub const ESPIPE: i32 = 29; +pub const EROFS: i32 = 30; +pub const EMLINK: i32 = 31; +pub const EPIPE: i32 = 32; +pub const EDOM: i32 = 33; +pub const ERANGE: i32 = 34; +pub const EDEADLK: i32 = 35; +pub const ENAMETOOLONG: i32 = 36; +pub const ENOLCK: i32 = 37; +pub const ENOSYS: i32 = 38; +pub const ENOTEMPTY: i32 = 39; +pub const ELOOP: i32 = 40; +pub const EWOULDBLOCK: i32 = EAGAIN; +pub const ENOMSG: i32 = 42; +pub const EIDRM: i32 = 43; +pub const ECHRNG: i32 = 44; +pub const EL2NSYNC: i32 = 45; +pub const EL3HLT: i32 = 46; +pub const EL3RST: i32 = 47; +pub const ELNRNG: i32 = 48; +pub const EUNATCH: i32 = 49; +pub const ENOCSI: i32 = 50; +pub const EL2HLT: i32 = 51; +pub const EBADE: i32 = 52; +pub const EBADR: i32 = 53; +pub const EXFULL: i32 = 54; +pub const ENOANO: i32 = 55; +pub const EBADRQC: i32 = 56; +pub const EBADSLT: i32 = 57; +pub const EDEADLOCK: i32 = EDEADLK; +pub const EBFONT: i32 = 59; +pub const ENOSTR: i32 = 60; +pub const ENODATA: i32 = 61; +pub const ETIME: i32 = 62; +pub const ENOSR: i32 = 63; +pub const ENONET: i32 = 64; +pub const ENOPKG: i32 = 65; +pub const EREMOTE: i32 = 66; +pub const ENOLINK: i32 = 67; +pub const EADV: i32 = 68; +pub const ESRMNT: i32 = 69; +pub const ECOMM: i32 = 70; +pub const EPROTO: i32 = 71; +pub const EMULTIHOP: i32 = 72; +pub const EDOTDOT: i32 = 73; +pub const EBADMSG: i32 = 74; +pub const EOVERFLOW: i32 = 75; +pub const ENOTUNIQ: i32 = 76; +pub const EBADFD: i32 = 77; +pub const EREMCHG: i32 = 78; +pub const ELIBACC: i32 = 79; +pub const ELIBBAD: i32 = 80; +pub const ELIBSCN: i32 = 81; +pub const ELIBMAX: i32 = 82; +pub const ELIBEXEC: i32 = 83; +pub const EILSEQ: i32 = 84; +pub const ERESTART: i32 = 85; +pub const ESTRPIPE: i32 = 86; +pub const EUSERS: i32 = 87; +pub const ENOTSOCK: i32 = 88; +pub const EDESTADDRREQ: i32 = 89; +pub const EMSGSIZE: i32 = 90; +pub const EPROTOTYPE: i32 = 91; +pub const ENOPROTOOPT: i32 = 92; +pub const EPROTONOSUPPORT: i32 = 93; +pub const ESOCKTNOSUPPORT: i32 = 94; +pub const EOPNOTSUPP: i32 = 95; +pub const EPFNOSUPPORT: i32 = 96; +pub const EAFNOSUPPORT: i32 = 97; +pub const EADDRINUSE: i32 = 98; +pub const EADDRNOTAVAIL: i32 = 99; +pub const ENETDOWN: i32 = 100; +pub const ENETUNREACH: i32 = 101; +pub const ENETRESET: i32 = 102; +pub const ECONNABORTED: i32 = 103; +pub const ECONNRESET: i32 = 104; +pub const ENOBUFS: i32 = 105; +pub const EISCONN: i32 = 106; +pub const ENOTCONN: i32 = 107; +pub const ESHUTDOWN: i32 = 108; +pub const ETOOMANYREFS: i32 = 109; +pub const ETIMEDOUT: i32 = 110; +pub const ECONNREFUSED: i32 = 111; +pub const EHOSTDOWN: i32 = 112; +pub const EHOSTUNREACH: i32 = 113; +pub const EALREADY: i32 = 114; +pub const EINPROGRESS: i32 = 115; +pub const ESTALE: i32 = 116; +pub const EUCLEAN: i32 = 117; +pub const ENOTNAM: i32 = 118; +pub const ENAVAIL: i32 = 119; +pub const EISNAM: i32 = 120; +pub const EREMOTEIO: i32 = 121; +pub const EDQUOT: i32 = 122; +pub const ENOMEDIUM: i32 = 123; +pub const EMEDIUMTYPE: i32 = 124; +pub const ECANCELED: i32 = 125; +pub const ENOKEY: i32 = 126; +pub const EKEYEXPIRED: i32 = 127; +pub const EKEYREVOKED: i32 = 128; +pub const EKEYREJECTED: i32 = 129; +pub const EOWNERDEAD: i32 = 130; +pub const ENOTRECOVERABLE: i32 = 131; +pub const ERFKILL: i32 = 132; +pub const EHWPOISON: i32 = 133; +pub const ELBIN: i32 = 134; +pub const EFTYPE: i32 = 135; +pub const ENMFILE: i32 = 136; +pub const EPROCLIM: i32 = 137; +pub const ENOTSUP: i32 = 138; +pub const ENOSHARE: i32 = 139; +pub const ECASECLASH: i32 = 140; + +// fcntl.h +pub const FIOCLEX: i32 = 0x30b; +pub const F_SETFL: i32 = 0x9; +pub const F_DUPFD_CLOEXEC: i32 = 0x12; +pub const F_GETFD: i32 = 0x1; +pub const F_GETFL: i32 = 0x2; +pub const O_RDONLY: i32 = 0x1; +pub const O_WRONLY: i32 = 0x2; +pub const O_RDWR: i32 = 0x3; +pub const O_CREAT: i32 = 0x4; +pub const O_EXCL: i32 = 0x8; +pub const O_NOCTTY: i32 = 0x0; +pub const O_TRUNC: i32 = 0x20; +pub const O_APPEND: i32 = 0x10; +pub const O_NONBLOCK: i32 = 0x40; +pub const O_DSYNC: i32 = 0x80; +pub const O_DIRECT: i32 = 0x200; +pub const O_LARGEFILE: i32 = 0x2000; +pub const O_DIRECTORY: i32 = 0x800; +pub const O_NOFOLLOW: i32 = 0x1000; +pub const O_NOATIME: i32 = 0x40000; +pub const O_CLOEXEC: i32 = 0x400; +pub const O_ACCMODE: i32 = 0x0003; +pub const AT_FDCWD: i32 = -100; +pub const AT_REMOVEDIR: i32 = 0x200; + +// sys/types.h +pub const SEEK_SET: i32 = 0; +pub const SEEK_CUR: i32 = 1; +pub const SEEK_END: i32 = 2; + +// sys/stat.h +pub const S_IFDIR: u32 = 0x4000; +pub const S_IFLNK: u32 = 0xA000; +pub const S_IFREG: u32 = 0x8000; +pub const S_IFMT: u32 = 0xF000; +pub const S_IFIFO: u32 = 0x1000; +pub const S_IFSOCK: u32 = 0xc000; +pub const S_IFBLK: u32 = 0x6000; +pub const S_IFCHR: u32 = 0x2000; +pub const S_IRUSR: u32 = 0x100; +pub const S_IWUSR: u32 = 0x80; +pub const S_IXUSR: u32 = 0x40; +pub const S_IRGRP: u32 = 0x20; +pub const S_IWGRP: u32 = 0x10; +pub const S_IXGRP: u32 = 0x8; +pub const S_IROTH: u32 = 0x004; +pub const S_IWOTH: u32 = 0x002; +pub const S_IXOTH: u32 = 0x001; + +// sys/poll.h +pub const POLLIN: i16 = 0x01; +pub const POLLOUT: i16 = 0x04; +pub const POLLHUP: i16 = 0x10; +pub const POLLERR: i16 = 0x08; +pub const POLLNVAL: i16 = 0x20; + +// sys/socket.h +pub const AF_UNIX: i32 = 1; +pub const SOCK_DGRAM: i32 = 2; +pub const SOCK_STREAM: i32 = 1; +pub const AF_INET: i32 = 2; +pub const AF_INET6: i32 = 10; +pub const MSG_PEEK: i32 = 0x02; +pub const SOL_SOCKET: i32 = 1; +pub const SHUT_WR: i32 = 2; +pub const SHUT_RD: i32 = 1; +pub const SHUT_RDWR: i32 = 3; +pub const SO_ERROR: i32 = 4; +pub const SO_REUSEADDR: i32 = 11; +pub const SOMAXCONN: i32 = 8; +pub const SO_LINGER: i32 = 6; +pub const SO_RCVTIMEO: i32 = 0xa; +pub const SO_SNDTIMEO: i32 = 0xe; +pub const SO_BROADCAST: i32 = 1; + +// netinet/tcp.h +pub const TCP_NODELAY: i32 = 0x10; + +// nuttx/fs/ioctl.h +pub const FIONBIO: i32 = 0x30a; + +// unistd.h +pub const _SC_PAGESIZE: i32 = 0x36; +pub const _SC_THREAD_STACK_MIN: i32 = 0x58; +pub const _SC_GETPW_R_SIZE_MAX: i32 = 0x25; +pub const _SC_HOST_NAME_MAX: i32 = 0x26; + +// signal.h +pub const SIGHUP: c_int = 1; +pub const SIGINT: c_int = 2; +pub const SIGQUIT: c_int = 3; +pub const SIGILL: c_int = 4; +pub const SIGTRAP: c_int = 5; +pub const SIGABRT: c_int = 6; +pub const SIGBUS: c_int = 7; +pub const SIGFPE: c_int = 8; +pub const SIGKILL: c_int = 9; +pub const SIGUSR1: c_int = 10; +pub const SIGSEGV: c_int = 11; +pub const SIGUSR2: c_int = 12; +pub const SIGPIPE: c_int = 13; +pub const SIGALRM: c_int = 14; +pub const SIGTERM: c_int = 15; +pub const SIGSTKFLT: c_int = 16; +pub const SIGCHLD: c_int = 17; +pub const SIGCONT: c_int = 18; +pub const SIGSTOP: c_int = 19; +pub const SIGTSTP: c_int = 20; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGURG: c_int = 23; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGIO: c_int = 29; +pub const SIGPOLL: c_int = SIGIO; +pub const SIGPWR: c_int = 30; +pub const SIGSYS: c_int = 31; + +// pthread.h +pub const PTHREAD_MUTEX_NORMAL: i32 = 0; + +// netinet/in.h +pub const IP_TTL: i32 = 0x1e; +pub const IPV6_V6ONLY: i32 = 0x17; +pub const IPV6_JOIN_GROUP: i32 = 0x11; +pub const IPV6_LEAVE_GROUP: i32 = 0x12; +pub const IP_MULTICAST_LOOP: i32 = 0x13; +pub const IPV6_MULTICAST_LOOP: i32 = 0x15; +pub const IP_MULTICAST_TTL: i32 = 0x12; +pub const IP_ADD_MEMBERSHIP: i32 = 0x14; +pub const IP_DROP_MEMBERSHIP: i32 = 0x15; + +extern "C" { + pub fn __errno() -> *mut c_int; + pub fn bind(sockfd: i32, addr: *const sockaddr, addrlen: socklen_t) -> i32; + pub fn ioctl(fd: i32, request: i32, ...) -> i32; + pub fn dirfd(dirp: *mut DIR) -> i32; + pub fn recvfrom( + sockfd: i32, + buf: *mut c_void, + len: usize, + flags: i32, + src_addr: *mut sockaddr, + addrlen: *mut socklen_t, + ) -> i32; + + pub fn pthread_create( + thread: *mut pthread_t, + attr: *const pthread_attr_t, + start_routine: extern "C" fn(*mut c_void) -> *mut c_void, + arg: *mut c_void, + ) -> i32; + + pub fn clock_gettime(clockid: clockid_t, tp: *mut timespec) -> i32; + pub fn futimens(fd: i32, times: *const timespec) -> i32; + pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t, clock_id: clockid_t) -> i32; + pub fn pthread_setname_np(thread: pthread_t, name: *const c_char) -> i32; + pub fn pthread_getname_np(thread: pthread_t, name: *mut c_char, len: usize) -> i32; + pub fn getrandom(buf: *mut c_void, buflen: usize, flags: u32) -> isize; + pub fn arc4random() -> u32; + pub fn arc4random_buf(bytes: *mut c_void, nbytes: usize); +} diff --git a/http/vendor/libc/src/unix/redox/mod.rs b/http/vendor/libc/src/unix/redox/mod.rs new file mode 100644 index 0000000..691fe5c --- /dev/null +++ b/http/vendor/libc/src/unix/redox/mod.rs @@ -0,0 +1,1433 @@ +use crate::prelude::*; + +pub type wchar_t = i32; + +pub type blkcnt_t = c_longlong; +pub type blksize_t = c_long; +pub type clock_t = c_long; +pub type clockid_t = c_int; +pub type dev_t = c_ulonglong; +pub type fsblkcnt_t = c_ulong; +pub type fsfilcnt_t = c_ulong; +pub type ino_t = c_ulonglong; +pub type mode_t = c_int; +pub type nfds_t = c_ulong; +pub type nlink_t = c_ulong; +pub type off_t = c_longlong; +pub type pthread_t = *mut c_void; +// Must be usize due to library/std/sys_common/thread_local.rs, +// should technically be *mut c_void +pub type pthread_key_t = usize; +pub type rlim_t = c_ulonglong; +pub type sa_family_t = u16; +pub type sem_t = *mut c_void; +pub type sigset_t = c_ulonglong; +pub type socklen_t = u32; +pub type speed_t = u32; +pub type suseconds_t = c_int; +pub type tcflag_t = u32; +pub type time_t = c_longlong; +pub type id_t = c_uint; +pub type uid_t = c_int; +pub type gid_t = c_int; + +extern_ty! { + pub enum timezone {} +} + +s! { + #[repr(C)] + pub struct utsname { + pub sysname: [c_char; UTSLENGTH], + pub nodename: [c_char; UTSLENGTH], + pub release: [c_char; UTSLENGTH], + pub version: [c_char; UTSLENGTH], + pub machine: [c_char; UTSLENGTH], + pub domainname: [c_char; UTSLENGTH], + } + + pub struct dirent { + pub d_ino: crate::ino_t, + pub d_off: off_t, + pub d_reclen: c_ushort, + pub d_type: c_uchar, + pub d_name: [c_char; 256], + } + + pub struct sockaddr_un { + pub sun_family: crate::sa_family_t, + pub sun_path: [c_char; 108], + } + + pub struct sockaddr_storage { + pub ss_family: crate::sa_family_t, + __ss_padding: Padding<[u8; 128 - size_of::() - size_of::()]>, + __ss_align: c_ulong, + } + + pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: size_t, + pub ai_canonname: *mut c_char, + pub ai_addr: *mut crate::sockaddr, + pub ai_next: *mut crate::addrinfo, + } + + pub struct Dl_info { + pub dli_fname: *const c_char, + pub dli_fbase: *mut c_void, + pub dli_sname: *const c_char, + pub dli_saddr: *mut c_void, + } + + pub struct epoll_event { + pub events: u32, + pub u64: u64, + pub _pad: u64, + } + + pub struct fd_set { + fds_bits: [c_ulong; crate::FD_SETSIZE as usize / ULONG_SIZE], + } + + pub struct in_addr { + pub s_addr: crate::in_addr_t, + } + + pub struct ip_mreq { + pub imr_multiaddr: crate::in_addr, + pub imr_interface: crate::in_addr, + } + + pub struct lconv { + pub currency_symbol: *const c_char, + pub decimal_point: *const c_char, + pub frac_digits: c_char, + pub grouping: *const c_char, + pub int_curr_symbol: *const c_char, + pub int_frac_digits: c_char, + pub mon_decimal_point: *const c_char, + pub mon_grouping: *const c_char, + pub mon_thousands_sep: *const c_char, + pub negative_sign: *const c_char, + pub n_cs_precedes: c_char, + pub n_sep_by_space: c_char, + pub n_sign_posn: c_char, + pub positive_sign: *const c_char, + pub p_cs_precedes: c_char, + pub p_sep_by_space: c_char, + pub p_sign_posn: c_char, + pub thousands_sep: *const c_char, + } + + pub struct msghdr { + pub msg_name: *mut c_void, + pub msg_namelen: crate::socklen_t, + pub msg_iov: *mut crate::iovec, + pub msg_iovlen: size_t, + pub msg_control: *mut c_void, + pub msg_controllen: size_t, + pub msg_flags: c_int, + } + + pub struct cmsghdr { + pub cmsg_len: size_t, + pub cmsg_level: c_int, + pub cmsg_type: c_int, + } + + pub struct passwd { + pub pw_name: *mut c_char, + pub pw_passwd: *mut c_char, + pub pw_uid: crate::uid_t, + pub pw_gid: crate::gid_t, + pub pw_gecos: *mut c_char, + pub pw_dir: *mut c_char, + pub pw_shell: *mut c_char, + } + + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] + pub struct sigaction { + pub sa_sigaction: crate::sighandler_t, + pub sa_flags: c_int, + pub sa_restorer: Option, + pub sa_mask: crate::sigset_t, + } + + pub struct siginfo_t { + pub si_signo: c_int, + pub si_errno: c_int, + pub si_code: c_int, + _pad: Padding<[c_int; 29]>, + _align: [usize; 0], + } + + pub struct sockaddr { + pub sa_family: crate::sa_family_t, + pub sa_data: [c_char; 14], + } + + pub struct sockaddr_in { + pub sin_family: crate::sa_family_t, + pub sin_port: crate::in_port_t, + pub sin_addr: crate::in_addr, + pub sin_zero: [c_char; 8], + } + + pub struct sockaddr_in6 { + pub sin6_family: crate::sa_family_t, + pub sin6_port: crate::in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: crate::in6_addr, + pub sin6_scope_id: u32, + } + + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_nlink: crate::nlink_t, + pub st_mode: mode_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + pub st_size: off_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + _pad: Padding<[c_char; 24]>, + } + + pub struct statvfs { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_favail: crate::fsfilcnt_t, + pub f_fsid: c_ulong, + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + } + + pub struct termios { + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_line: crate::cc_t, + pub c_cc: [crate::cc_t; crate::NCCS], + pub c_ispeed: crate::speed_t, + pub c_ospeed: crate::speed_t, + } + + pub struct tm { + pub tm_sec: c_int, + pub tm_min: c_int, + pub tm_hour: c_int, + pub tm_mday: c_int, + pub tm_mon: c_int, + pub tm_year: c_int, + pub tm_wday: c_int, + pub tm_yday: c_int, + pub tm_isdst: c_int, + pub tm_gmtoff: c_long, + pub tm_zone: *const c_char, + } + + pub struct ucred { + pub pid: crate::pid_t, + pub uid: uid_t, + pub gid: gid_t, + } + + #[cfg_attr(target_pointer_width = "32", repr(C, align(4)))] + #[cfg_attr(target_pointer_width = "64", repr(C, align(8)))] + pub struct pthread_attr_t { + bytes: [u8; _PTHREAD_ATTR_SIZE], + } + #[repr(C)] + #[repr(align(4))] + pub struct pthread_barrier_t { + bytes: [u8; _PTHREAD_BARRIER_SIZE], + } + #[repr(C)] + #[repr(align(4))] + pub struct pthread_barrierattr_t { + bytes: [u8; _PTHREAD_BARRIERATTR_SIZE], + } + #[repr(C)] + #[repr(align(4))] + pub struct pthread_mutex_t { + bytes: [u8; _PTHREAD_MUTEX_SIZE], + } + #[repr(C)] + #[repr(align(4))] + pub struct pthread_rwlock_t { + bytes: [u8; _PTHREAD_RWLOCK_SIZE], + } + #[repr(C)] + #[repr(align(4))] + pub struct pthread_mutexattr_t { + bytes: [u8; _PTHREAD_MUTEXATTR_SIZE], + } + #[repr(C)] + #[repr(align(1))] + pub struct pthread_rwlockattr_t { + bytes: [u8; _PTHREAD_RWLOCKATTR_SIZE], + } + #[repr(C)] + #[repr(align(4))] + pub struct pthread_cond_t { + bytes: [u8; _PTHREAD_COND_SIZE], + } + #[repr(C)] + #[repr(align(4))] + pub struct pthread_condattr_t { + bytes: [u8; _PTHREAD_CONDATTR_SIZE], + } + #[repr(C)] + #[repr(align(4))] + pub struct pthread_once_t { + bytes: [u8; _PTHREAD_ONCE_SIZE], + } + #[repr(C)] + #[repr(align(4))] + pub struct pthread_spinlock_t { + bytes: [u8; _PTHREAD_SPINLOCK_SIZE], + } +} +const _PTHREAD_ATTR_SIZE: usize = 32; +const _PTHREAD_RWLOCKATTR_SIZE: usize = 1; +const _PTHREAD_RWLOCK_SIZE: usize = 4; +const _PTHREAD_BARRIER_SIZE: usize = 24; +const _PTHREAD_BARRIERATTR_SIZE: usize = 4; +const _PTHREAD_CONDATTR_SIZE: usize = 8; +const _PTHREAD_COND_SIZE: usize = 8; +const _PTHREAD_MUTEX_SIZE: usize = 12; +const _PTHREAD_MUTEXATTR_SIZE: usize = 20; +const _PTHREAD_ONCE_SIZE: usize = 4; +const _PTHREAD_SPINLOCK_SIZE: usize = 4; + +pub const UTSLENGTH: usize = 65; + +// intentionally not public, only used for fd_set +cfg_if! { + if #[cfg(target_pointer_width = "32")] { + const ULONG_SIZE: usize = 32; + } else if #[cfg(target_pointer_width = "64")] { + const ULONG_SIZE: usize = 64; + } else { + // Unknown target_pointer_width + } +} + +// limits.h +pub const PATH_MAX: c_int = 4096; + +// fcntl.h +pub const F_GETLK: c_int = 5; +pub const F_SETLK: c_int = 6; +pub const F_SETLKW: c_int = 7; +pub const F_ULOCK: c_int = 0; +pub const F_LOCK: c_int = 1; +pub const F_TLOCK: c_int = 2; +pub const F_TEST: c_int = 3; + +pub const AT_FDCWD: c_int = -100; + +// FIXME(redox): relibc { +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); +// } + +// dlfcn.h +pub const RTLD_LAZY: c_int = 0x0001; +pub const RTLD_NOW: c_int = 0x0002; +pub const RTLD_NOLOAD: c_int = 0x0004; +pub const RTLD_GLOBAL: c_int = 0x0100; +pub const RTLD_LOCAL: c_int = 0x0000; + +// errno.h +pub const EPERM: c_int = 1; /* Operation not permitted */ +pub const ENOENT: c_int = 2; /* No such file or directory */ +pub const ESRCH: c_int = 3; /* No such process */ +pub const EINTR: c_int = 4; /* Interrupted system call */ +pub const EIO: c_int = 5; /* I/O error */ +pub const ENXIO: c_int = 6; /* No such device or address */ +pub const E2BIG: c_int = 7; /* Argument list too long */ +pub const ENOEXEC: c_int = 8; /* Exec format error */ +pub const EBADF: c_int = 9; /* Bad file number */ +pub const ECHILD: c_int = 10; /* No child processes */ +pub const EAGAIN: c_int = 11; /* Try again */ +pub const ENOMEM: c_int = 12; /* Out of memory */ +pub const EACCES: c_int = 13; /* Permission denied */ +pub const EFAULT: c_int = 14; /* Bad address */ +pub const ENOTBLK: c_int = 15; /* Block device required */ +pub const EBUSY: c_int = 16; /* Device or resource busy */ +pub const EEXIST: c_int = 17; /* File exists */ +pub const EXDEV: c_int = 18; /* Cross-device link */ +pub const ENODEV: c_int = 19; /* No such device */ +pub const ENOTDIR: c_int = 20; /* Not a directory */ +pub const EISDIR: c_int = 21; /* Is a directory */ +pub const EINVAL: c_int = 22; /* Invalid argument */ +pub const ENFILE: c_int = 23; /* File table overflow */ +pub const EMFILE: c_int = 24; /* Too many open files */ +pub const ENOTTY: c_int = 25; /* Not a typewriter */ +pub const ETXTBSY: c_int = 26; /* Text file busy */ +pub const EFBIG: c_int = 27; /* File too large */ +pub const ENOSPC: c_int = 28; /* No space left on device */ +pub const ESPIPE: c_int = 29; /* Illegal seek */ +pub const EROFS: c_int = 30; /* Read-only file system */ +pub const EMLINK: c_int = 31; /* Too many links */ +pub const EPIPE: c_int = 32; /* Broken pipe */ +pub const EDOM: c_int = 33; /* Math argument out of domain of func */ +pub const ERANGE: c_int = 34; /* Math result not representable */ +pub const EDEADLK: c_int = 35; /* Resource deadlock would occur */ +pub const ENAMETOOLONG: c_int = 36; /* File name too long */ +pub const ENOLCK: c_int = 37; /* No record locks available */ +pub const ENOSYS: c_int = 38; /* Function not implemented */ +pub const ENOTEMPTY: c_int = 39; /* Directory not empty */ +pub const ELOOP: c_int = 40; /* Too many symbolic links encountered */ +pub const EWOULDBLOCK: c_int = 41; /* Operation would block */ +pub const ENOMSG: c_int = 42; /* No message of desired type */ +pub const EIDRM: c_int = 43; /* Identifier removed */ +pub const ECHRNG: c_int = 44; /* Channel number out of range */ +pub const EL2NSYNC: c_int = 45; /* Level 2 not synchronized */ +pub const EL3HLT: c_int = 46; /* Level 3 halted */ +pub const EL3RST: c_int = 47; /* Level 3 reset */ +pub const ELNRNG: c_int = 48; /* Link number out of range */ +pub const EUNATCH: c_int = 49; /* Protocol driver not attached */ +pub const ENOCSI: c_int = 50; /* No CSI structure available */ +pub const EL2HLT: c_int = 51; /* Level 2 halted */ +pub const EBADE: c_int = 52; /* Invalid exchange */ +pub const EBADR: c_int = 53; /* Invalid request descriptor */ +pub const EXFULL: c_int = 54; /* Exchange full */ +pub const ENOANO: c_int = 55; /* No anode */ +pub const EBADRQC: c_int = 56; /* Invalid request code */ +pub const EBADSLT: c_int = 57; /* Invalid slot */ +pub const EDEADLOCK: c_int = 58; /* Resource deadlock would occur */ +pub const EBFONT: c_int = 59; /* Bad font file format */ +pub const ENOSTR: c_int = 60; /* Device not a stream */ +pub const ENODATA: c_int = 61; /* No data available */ +pub const ETIME: c_int = 62; /* Timer expired */ +pub const ENOSR: c_int = 63; /* Out of streams resources */ +pub const ENONET: c_int = 64; /* Machine is not on the network */ +pub const ENOPKG: c_int = 65; /* Package not installed */ +pub const EREMOTE: c_int = 66; /* Object is remote */ +pub const ENOLINK: c_int = 67; /* Link has been severed */ +pub const EADV: c_int = 68; /* Advertise error */ +pub const ESRMNT: c_int = 69; /* Srmount error */ +pub const ECOMM: c_int = 70; /* Communication error on send */ +pub const EPROTO: c_int = 71; /* Protocol error */ +pub const EMULTIHOP: c_int = 72; /* Multihop attempted */ +pub const EDOTDOT: c_int = 73; /* RFS specific error */ +pub const EBADMSG: c_int = 74; /* Not a data message */ +pub const EOVERFLOW: c_int = 75; /* Value too large for defined data type */ +pub const ENOTUNIQ: c_int = 76; /* Name not unique on network */ +pub const EBADFD: c_int = 77; /* File descriptor in bad state */ +pub const EREMCHG: c_int = 78; /* Remote address changed */ +pub const ELIBACC: c_int = 79; /* Can not access a needed shared library */ +pub const ELIBBAD: c_int = 80; /* Accessing a corrupted shared library */ +pub const ELIBSCN: c_int = 81; /* .lib section in a.out corrupted */ +/* Attempting to link in too many shared libraries */ +pub const ELIBMAX: c_int = 82; +pub const ELIBEXEC: c_int = 83; /* Cannot exec a shared library directly */ +pub const EILSEQ: c_int = 84; /* Illegal byte sequence */ +/* Interrupted system call should be restarted */ +pub const ERESTART: c_int = 85; +pub const ESTRPIPE: c_int = 86; /* Streams pipe error */ +pub const EUSERS: c_int = 87; /* Too many users */ +pub const ENOTSOCK: c_int = 88; /* Socket operation on non-socket */ +pub const EDESTADDRREQ: c_int = 89; /* Destination address required */ +pub const EMSGSIZE: c_int = 90; /* Message too long */ +pub const EPROTOTYPE: c_int = 91; /* Protocol wrong type for socket */ +pub const ENOPROTOOPT: c_int = 92; /* Protocol not available */ +pub const EPROTONOSUPPORT: c_int = 93; /* Protocol not supported */ +pub const ESOCKTNOSUPPORT: c_int = 94; /* Socket type not supported */ +/* Operation not supported on transport endpoint */ +pub const EOPNOTSUPP: c_int = 95; +pub const ENOTSUP: c_int = EOPNOTSUPP; +pub const EPFNOSUPPORT: c_int = 96; /* Protocol family not supported */ +/* Address family not supported by protocol */ +pub const EAFNOSUPPORT: c_int = 97; +pub const EADDRINUSE: c_int = 98; /* Address already in use */ +pub const EADDRNOTAVAIL: c_int = 99; /* Cannot assign requested address */ +pub const ENETDOWN: c_int = 100; /* Network is down */ +pub const ENETUNREACH: c_int = 101; /* Network is unreachable */ +/* Network dropped connection because of reset */ +pub const ENETRESET: c_int = 102; +pub const ECONNABORTED: c_int = 103; /* Software caused connection abort */ +pub const ECONNRESET: c_int = 104; /* Connection reset by peer */ +pub const ENOBUFS: c_int = 105; /* No buffer space available */ +pub const EISCONN: c_int = 106; /* Transport endpoint is already connected */ +pub const ENOTCONN: c_int = 107; /* Transport endpoint is not connected */ +/* Cannot send after transport endpoint shutdown */ +pub const ESHUTDOWN: c_int = 108; +pub const ETOOMANYREFS: c_int = 109; /* Too many references: cannot splice */ +pub const ETIMEDOUT: c_int = 110; /* Connection timed out */ +pub const ECONNREFUSED: c_int = 111; /* Connection refused */ +pub const EHOSTDOWN: c_int = 112; /* Host is down */ +pub const EHOSTUNREACH: c_int = 113; /* No route to host */ +pub const EALREADY: c_int = 114; /* Operation already in progress */ +pub const EINPROGRESS: c_int = 115; /* Operation now in progress */ +pub const ESTALE: c_int = 116; /* Stale NFS file handle */ +pub const EUCLEAN: c_int = 117; /* Structure needs cleaning */ +pub const ENOTNAM: c_int = 118; /* Not a XENIX named type file */ +pub const ENAVAIL: c_int = 119; /* No XENIX semaphores available */ +pub const EISNAM: c_int = 120; /* Is a named type file */ +pub const EREMOTEIO: c_int = 121; /* Remote I/O error */ +pub const EDQUOT: c_int = 122; /* Quota exceeded */ +pub const ENOMEDIUM: c_int = 123; /* No medium found */ +pub const EMEDIUMTYPE: c_int = 124; /* Wrong medium type */ +pub const ECANCELED: c_int = 125; /* Operation Canceled */ +pub const ENOKEY: c_int = 126; /* Required key not available */ +pub const EKEYEXPIRED: c_int = 127; /* Key has expired */ +pub const EKEYREVOKED: c_int = 128; /* Key has been revoked */ +pub const EKEYREJECTED: c_int = 129; /* Key was rejected by service */ +pub const EOWNERDEAD: c_int = 130; /* Owner died */ +pub const ENOTRECOVERABLE: c_int = 131; /* State not recoverable */ + +// fcntl.h +pub const F_DUPFD: c_int = 0; +pub const F_GETFD: c_int = 1; +pub const F_SETFD: c_int = 2; +pub const F_GETFL: c_int = 3; +pub const F_SETFL: c_int = 4; +pub const F_DUPFD_CLOEXEC: c_int = 1030; +pub const FD_CLOEXEC: c_int = 0x0100_0000; +pub const O_RDONLY: c_int = 0x0001_0000; +pub const O_WRONLY: c_int = 0x0002_0000; +pub const O_RDWR: c_int = 0x0003_0000; +pub const O_ACCMODE: c_int = 0x0003_0000; +pub const O_NONBLOCK: c_int = 0x0004_0000; +pub const O_NDELAY: c_int = O_NONBLOCK; +pub const O_APPEND: c_int = 0x0008_0000; +pub const O_SHLOCK: c_int = 0x0010_0000; +pub const O_EXLOCK: c_int = 0x0020_0000; +pub const O_ASYNC: c_int = 0x0040_0000; +pub const O_FSYNC: c_int = 0x0080_0000; +pub const O_CLOEXEC: c_int = 0x0100_0000; +pub const O_CREAT: c_int = 0x0200_0000; +pub const O_TRUNC: c_int = 0x0400_0000; +pub const O_EXCL: c_int = 0x0800_0000; +pub const O_DIRECTORY: c_int = 0x1000_0000; +pub const O_PATH: c_int = 0x2000_0000; +pub const O_SYMLINK: c_int = 0x4000_0000; +// Negative to allow it to be used as int +// FIXME(redox): Fix negative values missing from includes +pub const O_NOFOLLOW: c_int = -0x8000_0000; +pub const O_NOCTTY: c_int = 0x00000200; + +// locale.h +pub const LC_COLLATE: c_int = 0; +pub const LC_CTYPE: c_int = 1; +pub const LC_MESSAGES: c_int = 2; +pub const LC_MONETARY: c_int = 3; +pub const LC_NUMERIC: c_int = 4; +pub const LC_TIME: c_int = 5; +pub const LC_ALL: c_int = 6; + +// netdb.h +pub const AI_PASSIVE: c_int = 0x0001; +pub const AI_CANONNAME: c_int = 0x0002; +pub const AI_NUMERICHOST: c_int = 0x0004; +pub const AI_V4MAPPED: c_int = 0x0008; +pub const AI_ALL: c_int = 0x0010; +pub const AI_ADDRCONFIG: c_int = 0x0020; +pub const AI_NUMERICSERV: c_int = 0x0400; +pub const EAI_BADFLAGS: c_int = -1; +pub const EAI_NONAME: c_int = -2; +pub const EAI_AGAIN: c_int = -3; +pub const EAI_FAIL: c_int = -4; +pub const EAI_NODATA: c_int = -5; +pub const EAI_FAMILY: c_int = -6; +pub const EAI_SOCKTYPE: c_int = -7; +pub const EAI_SERVICE: c_int = -8; +pub const EAI_ADDRFAMILY: c_int = -9; +pub const EAI_MEMORY: c_int = -10; +pub const EAI_SYSTEM: c_int = -11; +pub const EAI_OVERFLOW: c_int = -12; +pub const NI_MAXHOST: c_int = 1025; +pub const NI_MAXSERV: c_int = 32; +pub const NI_NUMERICHOST: c_int = 0x0001; +pub const NI_NUMERICSERV: c_int = 0x0002; +pub const NI_NOFQDN: c_int = 0x0004; +pub const NI_NAMEREQD: c_int = 0x0008; +pub const NI_DGRAM: c_int = 0x0010; + +// netinet/in.h +// FIXME(redox): relibc { +pub const IP_TTL: c_int = 2; +pub const IPV6_UNICAST_HOPS: c_int = 16; +pub const IPV6_MULTICAST_IF: c_int = 17; +pub const IPV6_MULTICAST_HOPS: c_int = 18; +pub const IPV6_MULTICAST_LOOP: c_int = 19; +pub const IPV6_ADD_MEMBERSHIP: c_int = 20; +pub const IPV6_JOIN_GROUP: c_int = 20; +pub const IPV6_DROP_MEMBERSHIP: c_int = 21; +pub const IPV6_LEAVE_GROUP: c_int = 21; +pub const IPV6_V6ONLY: c_int = 26; +pub const IP_MULTICAST_IF: c_int = 32; +pub const IP_MULTICAST_TTL: c_int = 33; +pub const IP_MULTICAST_LOOP: c_int = 34; +pub const IP_ADD_MEMBERSHIP: c_int = 35; +pub const IP_DROP_MEMBERSHIP: c_int = 36; +pub const IP_TOS: c_int = 1; +pub const IP_RECVTOS: c_int = 13; +pub const IPPROTO_IGMP: c_int = 2; +pub const IPPROTO_PUP: c_int = 12; +pub const IPPROTO_IDP: c_int = 22; +pub const IPPROTO_RAW: c_int = 255; +pub const IPPROTO_MAX: c_int = 255; +// } + +// netinet/tcp.h +pub const TCP_NODELAY: c_int = 1; +pub const TCP_MAXSEG: c_int = 2; +pub const TCP_KEEPIDLE: c_int = 4; +pub const TCP_KEEPINTVL: c_int = 5; +pub const TCP_KEEPCNT: c_int = 6; + +// poll.h +pub const POLLIN: c_short = 0x001; +pub const POLLPRI: c_short = 0x002; +pub const POLLOUT: c_short = 0x004; +pub const POLLERR: c_short = 0x008; +pub const POLLHUP: c_short = 0x010; +pub const POLLNVAL: c_short = 0x020; +pub const POLLRDNORM: c_short = 0x040; +pub const POLLRDBAND: c_short = 0x080; +pub const POLLWRNORM: c_short = 0x100; +pub const POLLWRBAND: c_short = 0x200; + +// pthread.h +pub const PTHREAD_MUTEX_DEFAULT: c_int = 0; +pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 1; +pub const PTHREAD_MUTEX_NORMAL: c_int = 2; +pub const PTHREAD_MUTEX_RECURSIVE: c_int = 3; + +pub const PTHREAD_MUTEX_ROBUST: c_int = 0; +pub const PTHREAD_MUTEX_STALLED: c_int = 1; + +pub const PTHREAD_MUTEX_INITIALIZER: crate::pthread_mutex_t = crate::pthread_mutex_t { + bytes: [0; _PTHREAD_MUTEX_SIZE], +}; +pub const PTHREAD_COND_INITIALIZER: crate::pthread_cond_t = crate::pthread_cond_t { + bytes: [0; _PTHREAD_COND_SIZE], +}; +pub const PTHREAD_RWLOCK_INITIALIZER: crate::pthread_rwlock_t = crate::pthread_rwlock_t { + bytes: [0; _PTHREAD_RWLOCK_SIZE], +}; +pub const PTHREAD_STACK_MIN: size_t = 4096; + +// signal.h +pub const SIG_BLOCK: c_int = 0; +pub const SIG_UNBLOCK: c_int = 1; +pub const SIG_SETMASK: c_int = 2; +pub const SIGHUP: c_int = 1; +pub const SIGINT: c_int = 2; +pub const SIGQUIT: c_int = 3; +pub const SIGILL: c_int = 4; +pub const SIGTRAP: c_int = 5; +pub const SIGABRT: c_int = 6; +pub const SIGBUS: c_int = 7; +pub const SIGFPE: c_int = 8; +pub const SIGKILL: c_int = 9; +pub const SIGUSR1: c_int = 10; +pub const SIGSEGV: c_int = 11; +pub const SIGUSR2: c_int = 12; +pub const SIGPIPE: c_int = 13; +pub const SIGALRM: c_int = 14; +pub const SIGTERM: c_int = 15; +pub const SIGSTKFLT: c_int = 16; +pub const SIGCHLD: c_int = 17; +pub const SIGCONT: c_int = 18; +pub const SIGSTOP: c_int = 19; +pub const SIGTSTP: c_int = 20; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGURG: c_int = 23; +pub const SIGXCPU: c_int = 24; +pub const SIGXFSZ: c_int = 25; +pub const SIGVTALRM: c_int = 26; +pub const SIGPROF: c_int = 27; +pub const SIGWINCH: c_int = 28; +pub const SIGIO: c_int = 29; +pub const SIGPWR: c_int = 30; +pub const SIGSYS: c_int = 31; +pub const NSIG: c_int = 32; + +pub const SA_NOCLDWAIT: c_int = 0x0000_0002; +pub const SA_RESTORER: c_int = 0x0000_0004; // FIXME(redox): remove after relibc removes it +pub const SA_SIGINFO: c_int = 0x0200_0000; +pub const SA_ONSTACK: c_int = 0x0400_0000; +pub const SA_RESTART: c_int = 0x0800_0000; +pub const SA_NODEFER: c_int = 0x1000_0000; +pub const SA_RESETHAND: c_int = 0x2000_0000; +pub const SA_NOCLDSTOP: c_int = 0x4000_0000; + +// sys/file.h +pub const LOCK_SH: c_int = 1; +pub const LOCK_EX: c_int = 2; +pub const LOCK_NB: c_int = 4; +pub const LOCK_UN: c_int = 8; + +// sys/epoll.h +pub const EPOLL_CLOEXEC: c_int = 0x0100_0000; +pub const EPOLL_CTL_ADD: c_int = 1; +pub const EPOLL_CTL_DEL: c_int = 2; +pub const EPOLL_CTL_MOD: c_int = 3; +pub const EPOLLIN: c_int = 0x001; +pub const EPOLLPRI: c_int = 0x002; +pub const EPOLLOUT: c_int = 0x004; +pub const EPOLLERR: c_int = 0x008; +pub const EPOLLHUP: c_int = 0x010; +pub const EPOLLNVAL: c_int = 0x020; +pub const EPOLLRDNORM: c_int = 0x040; +pub const EPOLLRDBAND: c_int = 0x080; +pub const EPOLLWRNORM: c_int = 0x100; +pub const EPOLLWRBAND: c_int = 0x200; +pub const EPOLLMSG: c_int = 0x400; +pub const EPOLLRDHUP: c_int = 0x2000; +pub const EPOLLEXCLUSIVE: c_int = 1 << 28; +pub const EPOLLWAKEUP: c_int = 1 << 29; +pub const EPOLLONESHOT: c_int = 1 << 30; +pub const EPOLLET: c_int = 1 << 31; + +// sys/stat.h +pub const S_IFMT: c_int = 0o17_0000; +pub const S_IFDIR: c_int = 0o4_0000; +pub const S_IFCHR: c_int = 0o2_0000; +pub const S_IFBLK: c_int = 0o6_0000; +pub const S_IFREG: c_int = 0o10_0000; +pub const S_IFIFO: c_int = 0o1_0000; +pub const S_IFLNK: c_int = 0o12_0000; +pub const S_IFSOCK: c_int = 0o14_0000; +pub const S_IRWXU: c_int = 0o0700; +pub const S_IRUSR: c_int = 0o0400; +pub const S_IWUSR: c_int = 0o0200; +pub const S_IXUSR: c_int = 0o0100; +pub const S_IRWXG: c_int = 0o0070; +pub const S_IRGRP: c_int = 0o0040; +pub const S_IWGRP: c_int = 0o0020; +pub const S_IXGRP: c_int = 0o0010; +pub const S_IRWXO: c_int = 0o0007; +pub const S_IROTH: c_int = 0o0004; +pub const S_IWOTH: c_int = 0o0002; +pub const S_IXOTH: c_int = 0o0001; + +// stdlib.h +pub const EXIT_SUCCESS: c_int = 0; +pub const EXIT_FAILURE: c_int = 1; + +// sys/ioctl.h +// FIXME(redox): relibc { +pub const FIONREAD: c_ulong = 0x541B; +pub const FIONBIO: c_ulong = 0x5421; +pub const FIOCLEX: c_ulong = 0x5451; +// } +pub const TCGETS: c_ulong = 0x5401; +pub const TCSETS: c_ulong = 0x5402; +pub const TCFLSH: c_ulong = 0x540B; +pub const TIOCSCTTY: c_ulong = 0x540E; +pub const TIOCGPGRP: c_ulong = 0x540F; +pub const TIOCSPGRP: c_ulong = 0x5410; +pub const TIOCGWINSZ: c_ulong = 0x5413; +pub const TIOCSWINSZ: c_ulong = 0x5414; + +// sys/mman.h +pub const PROT_NONE: c_int = 0x0000; +pub const PROT_READ: c_int = 0x0004; +pub const PROT_WRITE: c_int = 0x0002; +pub const PROT_EXEC: c_int = 0x0001; + +pub const MADV_NORMAL: c_int = 0; +pub const MADV_RANDOM: c_int = 1; +pub const MADV_SEQUENTIAL: c_int = 2; +pub const MADV_WILLNEED: c_int = 3; +pub const MADV_DONTNEED: c_int = 4; + +pub const MAP_SHARED: c_int = 0x0001; +pub const MAP_PRIVATE: c_int = 0x0002; +pub const MAP_ANON: c_int = 0x0020; +pub const MAP_ANONYMOUS: c_int = MAP_ANON; +pub const MAP_FIXED: c_int = 0x0004; +pub const MAP_FAILED: *mut c_void = !0 as _; + +pub const MS_ASYNC: c_int = 0x0001; +pub const MS_INVALIDATE: c_int = 0x0002; +pub const MS_SYNC: c_int = 0x0004; + +// sys/resource.h +pub const RLIM_INFINITY: rlim_t = !0; +pub const RLIM_SAVED_CUR: rlim_t = RLIM_INFINITY; +pub const RLIM_SAVED_MAX: rlim_t = RLIM_INFINITY; +pub const RLIMIT_CPU: c_int = 0; +pub const RLIMIT_FSIZE: c_int = 1; +pub const RLIMIT_DATA: c_int = 2; +pub const RLIMIT_STACK: c_int = 3; +pub const RLIMIT_CORE: c_int = 4; +pub const RLIMIT_RSS: c_int = 5; +pub const RLIMIT_NPROC: c_int = 6; +pub const RLIMIT_NOFILE: c_int = 7; +pub const RLIMIT_MEMLOCK: c_int = 8; +pub const RLIMIT_AS: c_int = 9; +pub const RLIMIT_LOCKS: c_int = 10; +pub const RLIMIT_SIGPENDING: c_int = 11; +pub const RLIMIT_MSGQUEUE: c_int = 12; +pub const RLIMIT_NICE: c_int = 13; +pub const RLIMIT_RTPRIO: c_int = 14; +pub const RLIMIT_NLIMITS: c_int = 15; + +pub const RUSAGE_SELF: c_int = 0; +pub const RUSAGE_CHILDREN: c_int = -1; +pub const RUSAGE_BOTH: c_int = -2; +pub const RUSAGE_THREAD: c_int = 1; + +// sys/select.h +pub const FD_SETSIZE: usize = 1024; + +// sys/socket.h +pub const AF_INET: c_int = 2; +pub const AF_INET6: c_int = 10; +pub const AF_UNIX: c_int = 1; +pub const AF_UNSPEC: c_int = 0; +pub const PF_INET: c_int = 2; +pub const PF_INET6: c_int = 10; +pub const PF_UNIX: c_int = 1; +pub const PF_UNSPEC: c_int = 0; +pub const MSG_CTRUNC: c_int = 8; +pub const MSG_DONTROUTE: c_int = 4; +pub const MSG_EOR: c_int = 128; +pub const MSG_OOB: c_int = 1; +pub const MSG_PEEK: c_int = 2; +pub const MSG_TRUNC: c_int = 32; +pub const MSG_DONTWAIT: c_int = 64; +pub const MSG_WAITALL: c_int = 256; +pub const SCM_RIGHTS: c_int = 1; +pub const SHUT_RD: c_int = 0; +pub const SHUT_WR: c_int = 1; +pub const SHUT_RDWR: c_int = 2; +pub const SO_DEBUG: c_int = 1; +pub const SO_REUSEADDR: c_int = 2; +pub const SO_TYPE: c_int = 3; +pub const SO_ERROR: c_int = 4; +pub const SO_DONTROUTE: c_int = 5; +pub const SO_BROADCAST: c_int = 6; +pub const SO_SNDBUF: c_int = 7; +pub const SO_RCVBUF: c_int = 8; +pub const SO_KEEPALIVE: c_int = 9; +pub const SO_OOBINLINE: c_int = 10; +pub const SO_NO_CHECK: c_int = 11; +pub const SO_PRIORITY: c_int = 12; +pub const SO_LINGER: c_int = 13; +pub const SO_BSDCOMPAT: c_int = 14; +pub const SO_REUSEPORT: c_int = 15; +pub const SO_PASSCRED: c_int = 16; +pub const SO_PEERCRED: c_int = 17; +pub const SO_RCVLOWAT: c_int = 18; +pub const SO_SNDLOWAT: c_int = 19; +pub const SO_RCVTIMEO: c_int = 20; +pub const SO_SNDTIMEO: c_int = 21; +pub const SO_ACCEPTCONN: c_int = 30; +pub const SO_PEERSEC: c_int = 31; +pub const SO_SNDBUFFORCE: c_int = 32; +pub const SO_RCVBUFFORCE: c_int = 33; +pub const SO_PROTOCOL: c_int = 38; +pub const SO_DOMAIN: c_int = 39; +pub const SOCK_STREAM: c_int = 1; +pub const SOCK_DGRAM: c_int = 2; +pub const SOCK_RAW: c_int = 3; +pub const SOCK_NONBLOCK: c_int = 0o4_000; +pub const SOCK_CLOEXEC: c_int = 0o2_000_000; +pub const SOCK_SEQPACKET: c_int = 5; +pub const SOL_SOCKET: c_int = 1; +pub const SOMAXCONN: c_int = 128; + +// sys/termios.h +pub const VEOF: usize = 0; +pub const VEOL: usize = 1; +pub const VEOL2: usize = 2; +pub const VERASE: usize = 3; +pub const VWERASE: usize = 4; +pub const VKILL: usize = 5; +pub const VREPRINT: usize = 6; +pub const VSWTC: usize = 7; +pub const VINTR: usize = 8; +pub const VQUIT: usize = 9; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 12; +pub const VSTOP: usize = 13; +pub const VLNEXT: usize = 14; +pub const VDISCARD: usize = 15; +pub const VMIN: usize = 16; +pub const VTIME: usize = 17; +pub const NCCS: usize = 32; + +pub const IGNBRK: crate::tcflag_t = 0o000_001; +pub const BRKINT: crate::tcflag_t = 0o000_002; +pub const IGNPAR: crate::tcflag_t = 0o000_004; +pub const PARMRK: crate::tcflag_t = 0o000_010; +pub const INPCK: crate::tcflag_t = 0o000_020; +pub const ISTRIP: crate::tcflag_t = 0o000_040; +pub const INLCR: crate::tcflag_t = 0o000_100; +pub const IGNCR: crate::tcflag_t = 0o000_200; +pub const ICRNL: crate::tcflag_t = 0o000_400; +pub const IXON: crate::tcflag_t = 0o001_000; +pub const IXOFF: crate::tcflag_t = 0o002_000; + +pub const OPOST: crate::tcflag_t = 0o000_001; +pub const ONLCR: crate::tcflag_t = 0o000_002; +pub const OLCUC: crate::tcflag_t = 0o000_004; +pub const OCRNL: crate::tcflag_t = 0o000_010; +pub const ONOCR: crate::tcflag_t = 0o000_020; +pub const ONLRET: crate::tcflag_t = 0o000_040; +pub const OFILL: crate::tcflag_t = 0o0000_100; +pub const OFDEL: crate::tcflag_t = 0o0000_200; + +pub const B0: speed_t = 0o000_000; +pub const B50: speed_t = 0o000_001; +pub const B75: speed_t = 0o000_002; +pub const B110: speed_t = 0o000_003; +pub const B134: speed_t = 0o000_004; +pub const B150: speed_t = 0o000_005; +pub const B200: speed_t = 0o000_006; +pub const B300: speed_t = 0o000_007; +pub const B600: speed_t = 0o000_010; +pub const B1200: speed_t = 0o000_011; +pub const B1800: speed_t = 0o000_012; +pub const B2400: speed_t = 0o000_013; +pub const B4800: speed_t = 0o000_014; +pub const B9600: speed_t = 0o000_015; +pub const B19200: speed_t = 0o000_016; +pub const B38400: speed_t = 0o000_017; + +pub const B57600: speed_t = 0o0_020; +pub const B115200: speed_t = 0o0_021; +pub const B230400: speed_t = 0o0_022; +pub const B460800: speed_t = 0o0_023; +pub const B500000: speed_t = 0o0_024; +pub const B576000: speed_t = 0o0_025; +pub const B921600: speed_t = 0o0_026; +pub const B1000000: speed_t = 0o0_027; +pub const B1152000: speed_t = 0o0_030; +pub const B1500000: speed_t = 0o0_031; +pub const B2000000: speed_t = 0o0_032; +pub const B2500000: speed_t = 0o0_033; +pub const B3000000: speed_t = 0o0_034; +pub const B3500000: speed_t = 0o0_035; +pub const B4000000: speed_t = 0o0_036; + +pub const CSIZE: crate::tcflag_t = 0o001_400; +pub const CS5: crate::tcflag_t = 0o000_000; +pub const CS6: crate::tcflag_t = 0o000_400; +pub const CS7: crate::tcflag_t = 0o001_000; +pub const CS8: crate::tcflag_t = 0o001_400; + +pub const CSTOPB: crate::tcflag_t = 0o002_000; +pub const CREAD: crate::tcflag_t = 0o004_000; +pub const PARENB: crate::tcflag_t = 0o010_000; +pub const PARODD: crate::tcflag_t = 0o020_000; +pub const HUPCL: crate::tcflag_t = 0o040_000; + +pub const CLOCAL: crate::tcflag_t = 0o0100000; + +pub const ISIG: crate::tcflag_t = 0x0000_0080; +pub const ICANON: crate::tcflag_t = 0x0000_0100; +pub const ECHO: crate::tcflag_t = 0x0000_0008; +pub const ECHOE: crate::tcflag_t = 0x0000_0002; +pub const ECHOK: crate::tcflag_t = 0x0000_0004; +pub const ECHONL: crate::tcflag_t = 0x0000_0010; +pub const NOFLSH: crate::tcflag_t = 0x8000_0000; +pub const TOSTOP: crate::tcflag_t = 0x0040_0000; +pub const IEXTEN: crate::tcflag_t = 0x0000_0400; + +pub const TCOOFF: c_int = 0; +pub const TCOON: c_int = 1; +pub const TCIOFF: c_int = 2; +pub const TCION: c_int = 3; + +pub const TCIFLUSH: c_int = 0; +pub const TCOFLUSH: c_int = 1; +pub const TCIOFLUSH: c_int = 2; + +pub const TCSANOW: c_int = 0; +pub const TCSADRAIN: c_int = 1; +pub const TCSAFLUSH: c_int = 2; + +pub const _POSIX_VDISABLE: crate::cc_t = 0; + +// sys/wait.h +pub const WNOHANG: c_int = 1; +pub const WUNTRACED: c_int = 2; + +pub const WSTOPPED: c_int = 2; +pub const WEXITED: c_int = 4; +pub const WCONTINUED: c_int = 8; +pub const WNOWAIT: c_int = 0x0100_0000; + +pub const __WNOTHREAD: c_int = 0x2000_0000; +pub const __WALL: c_int = 0x4000_0000; +#[allow(overflowing_literals)] +pub const __WCLONE: c_int = 0x8000_0000; + +// time.h +pub const CLOCK_REALTIME: c_int = 1; +pub const CLOCK_MONOTONIC: c_int = 4; +pub const CLOCK_PROCESS_CPUTIME_ID: crate::clockid_t = 2; +pub const CLOCKS_PER_SEC: crate::clock_t = 1_000_000; + +// unistd.h +// POSIX.1 { +pub const _SC_ARG_MAX: c_int = 0; +pub const _SC_CHILD_MAX: c_int = 1; +pub const _SC_CLK_TCK: c_int = 2; +pub const _SC_NGROUPS_MAX: c_int = 3; +pub const _SC_OPEN_MAX: c_int = 4; +pub const _SC_STREAM_MAX: c_int = 5; +pub const _SC_TZNAME_MAX: c_int = 6; +// ... +pub const _SC_VERSION: c_int = 29; +pub const _SC_PAGESIZE: c_int = 30; +pub const _SC_PAGE_SIZE: c_int = 30; +// ... +pub const _SC_RE_DUP_MAX: c_int = 44; + +pub const _SC_NPROCESSORS_CONF: c_int = 57; +pub const _SC_NPROCESSORS_ONLN: c_int = 58; + +// ... +pub const _SC_GETGR_R_SIZE_MAX: c_int = 69; +pub const _SC_GETPW_R_SIZE_MAX: c_int = 70; +pub const _SC_LOGIN_NAME_MAX: c_int = 71; +pub const _SC_TTY_NAME_MAX: c_int = 72; +// ... +pub const _SC_SYMLOOP_MAX: c_int = 173; +// ... +pub const _SC_HOST_NAME_MAX: c_int = 180; +// ... +pub const _SC_SIGQUEUE_MAX: c_int = 190; +pub const _SC_REALTIME_SIGNALS: c_int = 191; +// } POSIX.1 + +// confstr +pub const _CS_PATH: c_int = 0; +pub const _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS: c_int = 1; +pub const _CS_POSIX_V5_WIDTH_RESTRICTED_ENVS: c_int = 4; +pub const _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS: c_int = 5; +pub const _CS_POSIX_V6_ILP32_OFF32_CFLAGS: c_int = 1116; +pub const _CS_POSIX_V6_ILP32_OFF32_LDFLAGS: c_int = 1117; +pub const _CS_POSIX_V6_ILP32_OFF32_LIBS: c_int = 1118; +pub const _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS: c_int = 1119; +pub const _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS: c_int = 1120; +pub const _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS: c_int = 1121; +pub const _CS_POSIX_V6_ILP32_OFFBIG_LIBS: c_int = 1122; +pub const _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS: c_int = 1123; +pub const _CS_POSIX_V6_LP64_OFF64_CFLAGS: c_int = 1124; +pub const _CS_POSIX_V6_LP64_OFF64_LDFLAGS: c_int = 1125; +pub const _CS_POSIX_V6_LP64_OFF64_LIBS: c_int = 1126; +pub const _CS_POSIX_V6_LP64_OFF64_LINTFLAGS: c_int = 1127; +pub const _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS: c_int = 1128; +pub const _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS: c_int = 1129; +pub const _CS_POSIX_V6_LPBIG_OFFBIG_LIBS: c_int = 1130; +pub const _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS: c_int = 1131; +pub const _CS_POSIX_V7_ILP32_OFF32_CFLAGS: c_int = 1132; +pub const _CS_POSIX_V7_ILP32_OFF32_LDFLAGS: c_int = 1133; +pub const _CS_POSIX_V7_ILP32_OFF32_LIBS: c_int = 1134; +pub const _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS: c_int = 1135; +pub const _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS: c_int = 1136; +pub const _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS: c_int = 1137; +pub const _CS_POSIX_V7_ILP32_OFFBIG_LIBS: c_int = 1138; +pub const _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS: c_int = 1139; +pub const _CS_POSIX_V7_LP64_OFF64_CFLAGS: c_int = 1140; +pub const _CS_POSIX_V7_LP64_OFF64_LDFLAGS: c_int = 1141; +pub const _CS_POSIX_V7_LP64_OFF64_LIBS: c_int = 1142; +pub const _CS_POSIX_V7_LP64_OFF64_LINTFLAGS: c_int = 1143; +pub const _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS: c_int = 1144; +pub const _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS: c_int = 1145; +pub const _CS_POSIX_V7_LPBIG_OFFBIG_LIBS: c_int = 1146; +pub const _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS: c_int = 1147; + +pub const F_OK: c_int = 0; +pub const R_OK: c_int = 4; +pub const W_OK: c_int = 2; +pub const X_OK: c_int = 1; + +// stdio.h +pub const BUFSIZ: c_uint = 1024; +pub const _IOFBF: c_int = 0; +pub const _IOLBF: c_int = 1; +pub const _IONBF: c_int = 2; +pub const SEEK_SET: c_int = 0; +pub const SEEK_CUR: c_int = 1; +pub const SEEK_END: c_int = 2; + +pub const _PC_LINK_MAX: c_int = 0; +pub const _PC_MAX_CANON: c_int = 1; +pub const _PC_MAX_INPUT: c_int = 2; +pub const _PC_NAME_MAX: c_int = 3; +pub const _PC_PATH_MAX: c_int = 4; +pub const _PC_PIPE_BUF: c_int = 5; +pub const _PC_CHOWN_RESTRICTED: c_int = 6; +pub const _PC_NO_TRUNC: c_int = 7; +pub const _PC_VDISABLE: c_int = 8; +pub const _PC_SYNC_IO: c_int = 9; +pub const _PC_ASYNC_IO: c_int = 10; +pub const _PC_PRIO_IO: c_int = 11; +pub const _PC_SOCK_MAXBUF: c_int = 12; +pub const _PC_FILESIZEBITS: c_int = 13; +pub const _PC_REC_INCR_XFER_SIZE: c_int = 14; +pub const _PC_REC_MAX_XFER_SIZE: c_int = 15; +pub const _PC_REC_MIN_XFER_SIZE: c_int = 16; +pub const _PC_REC_XFER_ALIGN: c_int = 17; +pub const _PC_ALLOC_SIZE_MIN: c_int = 18; +pub const _PC_SYMLINK_MAX: c_int = 19; +pub const _PC_2_SYMLINKS: c_int = 20; + +pub const PRIO_PROCESS: c_int = 0; +pub const PRIO_PGRP: c_int = 1; +pub const PRIO_USER: c_int = 2; + +pub const RENAME_NOREPLACE: c_uint = 1; + +f! { + //sys/socket.h + pub const fn CMSG_ALIGN(len: size_t) -> size_t { + (len + size_of::() - 1) & !(size_of::() - 1) + } + pub const fn CMSG_LEN(length: c_uint) -> c_uint { + (CMSG_ALIGN(size_of::()) + length as usize) as c_uint + } + pub const fn CMSG_SPACE(len: c_uint) -> c_uint { + (CMSG_ALIGN(len as size_t) + CMSG_ALIGN(size_of::())) as c_uint + } + + // wait.h + pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { + let fd = fd as usize; + let size = size_of_val(&(*set).fds_bits[0]) * 8; + (*set).fds_bits[fd / size] &= !(1 << (fd % size)); + return; + } + + pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { + let fd = fd as usize; + let size = size_of_val(&(*set).fds_bits[0]) * 8; + return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0; + } + + pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { + let fd = fd as usize; + let size = size_of_val(&(*set).fds_bits[0]) * 8; + (*set).fds_bits[fd / size] |= 1 << (fd % size); + return; + } + + pub fn FD_ZERO(set: *mut fd_set) -> () { + for slot in (*set).fds_bits.iter_mut() { + *slot = 0; + } + } +} + +safe_f! { + pub const fn WIFSTOPPED(status: c_int) -> bool { + (status & 0xff) == 0x7f + } + + pub const fn WSTOPSIG(status: c_int) -> c_int { + (status >> 8) & 0xff + } + + pub const fn WIFCONTINUED(status: c_int) -> bool { + status == 0xffff + } + + pub const fn WIFSIGNALED(status: c_int) -> bool { + ((status & 0x7f) + 1) as i8 >= 2 + } + + pub const fn WTERMSIG(status: c_int) -> c_int { + status & 0x7f + } + + pub const fn WIFEXITED(status: c_int) -> bool { + (status & 0x7f) == 0 + } + + pub const fn WEXITSTATUS(status: c_int) -> c_int { + (status >> 8) & 0xff + } + + pub const fn WCOREDUMP(status: c_int) -> bool { + (status & 0x80) != 0 + } + + pub const fn makedev(major: c_uint, minor: c_uint) -> dev_t { + let major = major as dev_t; + let minor = minor as dev_t; + let mut dev = 0; + dev |= (major & 0x00000fff) << 8; + dev |= (major & 0xfffff000) << 32; + dev |= (minor & 0x000000ff) << 0; + dev |= (minor & 0xffffff00) << 12; + dev + } + + pub const fn major(dev: dev_t) -> c_uint { + let mut major = 0; + major |= (dev & 0x00000000000fff00) >> 8; + major |= (dev & 0xfffff00000000000) >> 32; + major as c_uint + } + + pub const fn minor(dev: dev_t) -> c_uint { + let mut minor = 0; + minor |= (dev & 0x00000000000000ff) >> 0; + minor |= (dev & 0x00000ffffff00000) >> 12; + minor as c_uint + } +} + +extern "C" { + // errno.h + pub fn __errno_location() -> *mut c_int; + pub fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int; + + // dirent.h + pub fn dirfd(dirp: *mut crate::DIR) -> c_int; + + // unistd.h + pub fn pipe2(fds: *mut c_int, flags: c_int) -> c_int; + pub fn getdtablesize() -> c_int; + pub fn getresgid( + rgid: *mut crate::gid_t, + egid: *mut crate::gid_t, + sgid: *mut crate::gid_t, + ) -> c_int; + pub fn getresuid( + ruid: *mut crate::uid_t, + euid: *mut crate::uid_t, + suid: *mut crate::uid_t, + ) -> c_int; + pub fn setresgid(rgid: crate::gid_t, egid: crate::gid_t, sgid: crate::gid_t) -> c_int; + pub fn setresuid(ruid: crate::uid_t, euid: crate::uid_t, suid: crate::uid_t) -> c_int; + + // grp.h + pub fn getgrent() -> *mut crate::group; + pub fn setgrent(); + pub fn endgrent(); + pub fn getgrgid(gid: crate::gid_t) -> *mut crate::group; + pub fn getgrgid_r( + gid: crate::gid_t, + grp: *mut crate::group, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::group, + ) -> c_int; + pub fn getgrnam(name: *const c_char) -> *mut crate::group; + pub fn getgrnam_r( + name: *const c_char, + grp: *mut crate::group, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::group, + ) -> c_int; + pub fn getgrouplist( + user: *const c_char, + group: crate::gid_t, + groups: *mut crate::gid_t, + ngroups: *mut c_int, + ) -> c_int; + + // malloc.h + pub fn memalign(align: size_t, size: size_t) -> *mut c_void; + + // netdb.h + pub fn getnameinfo( + addr: *const crate::sockaddr, + addrlen: crate::socklen_t, + host: *mut c_char, + hostlen: crate::socklen_t, + serv: *mut c_char, + servlen: crate::socklen_t, + flags: c_int, + ) -> c_int; + + // pthread.h + pub fn pthread_atfork( + prepare: Option, + parent: Option, + child: Option, + ) -> c_int; + pub fn pthread_create( + tid: *mut crate::pthread_t, + attr: *const crate::pthread_attr_t, + start: extern "C" fn(*mut c_void) -> *mut c_void, + arg: *mut c_void, + ) -> c_int; + pub fn pthread_condattr_setclock( + attr: *mut pthread_condattr_t, + clock_id: crate::clockid_t, + ) -> c_int; + + //pty.h + pub fn openpty( + amaster: *mut c_int, + aslave: *mut c_int, + name: *mut c_char, + termp: *const termios, + winp: *const crate::winsize, + ) -> c_int; + + // pwd.h + pub fn getpwent() -> *mut passwd; + pub fn setpwent(); + pub fn endpwent(); + pub fn getpwnam_r( + name: *const c_char, + pwd: *mut passwd, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut passwd, + ) -> c_int; + pub fn getpwuid_r( + uid: crate::uid_t, + pwd: *mut passwd, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut passwd, + ) -> c_int; + + // semaphore.h + pub fn sem_destroy(sem: *mut sem_t) -> c_int; + pub fn sem_init(sem: *mut sem_t, pshared: c_int, value: c_uint) -> c_int; + pub fn sem_clockwait( + sem: *mut sem_t, + clock_id: clockid_t, + abstime: *const crate::timespec, + ) -> c_int; + pub fn sem_timedwait(sem: *mut sem_t, abstime: *const crate::timespec) -> c_int; + pub fn sem_getvalue(sem: *mut sem_t, sval: *mut c_int) -> c_int; + + // signal.h + pub fn pthread_sigmask( + how: c_int, + set: *const crate::sigset_t, + oldset: *mut crate::sigset_t, + ) -> c_int; + pub fn pthread_cancel(thread: crate::pthread_t) -> c_int; + pub fn pthread_kill(thread: crate::pthread_t, sig: c_int) -> c_int; + pub fn sigtimedwait( + set: *const sigset_t, + sig: *mut siginfo_t, + timeout: *const crate::timespec, + ) -> c_int; + pub fn sigwait(set: *const sigset_t, sig: *mut c_int) -> c_int; + + // stdlib.h + pub fn getsubopt( + optionp: *mut *mut c_char, + tokens: *const *mut c_char, + valuep: *mut *mut c_char, + ) -> c_int; + pub fn mkostemp(template: *mut c_char, flags: c_int) -> c_int; + pub fn mkostemps(template: *mut c_char, suffixlen: c_int, flags: c_int) -> c_int; + pub fn reallocarray(ptr: *mut c_void, nmemb: size_t, size: size_t) -> *mut c_void; + + // stdio.h + pub fn renameat2( + olddirfd: c_int, + oldpath: *const c_char, + newdirfd: c_int, + newpath: *const c_char, + flags: c_uint, + ) -> c_int; + + // string.h + pub fn explicit_bzero(p: *mut c_void, len: size_t); + pub fn strlcat(dst: *mut c_char, src: *const c_char, siz: size_t) -> size_t; + pub fn strlcpy(dst: *mut c_char, src: *const c_char, siz: size_t) -> size_t; + + // sys/epoll.h + pub fn epoll_create(size: c_int) -> c_int; + pub fn epoll_create1(flags: c_int) -> c_int; + pub fn epoll_wait( + epfd: c_int, + events: *mut crate::epoll_event, + maxevents: c_int, + timeout: c_int, + ) -> c_int; + pub fn epoll_ctl(epfd: c_int, op: c_int, fd: c_int, event: *mut crate::epoll_event) -> c_int; + + // sys/ioctl.h + pub fn ioctl(fd: c_int, request: c_ulong, ...) -> c_int; + + // sys/mman.h + pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; + pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int; + pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; + pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int; + pub fn shm_unlink(name: *const c_char) -> c_int; + + // sys/resource.h + pub fn getpriority(which: c_int, who: crate::id_t) -> c_int; + pub fn setpriority(which: c_int, who: crate::id_t, prio: c_int) -> c_int; + pub fn getrlimit(resource: c_int, rlim: *mut crate::rlimit) -> c_int; + pub fn setrlimit(resource: c_int, rlim: *const crate::rlimit) -> c_int; + + // sys/socket.h + pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar; + pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr; + pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr; + pub fn bind( + socket: c_int, + address: *const crate::sockaddr, + address_len: crate::socklen_t, + ) -> c_int; + pub fn recvfrom( + socket: c_int, + buf: *mut c_void, + len: size_t, + flags: c_int, + addr: *mut crate::sockaddr, + addrlen: *mut crate::socklen_t, + ) -> ssize_t; + pub fn recvmsg(socket: c_int, msg: *mut msghdr, flags: c_int) -> ssize_t; + pub fn sendmsg(socket: c_int, msg: *const msghdr, flags: c_int) -> ssize_t; + + // sys/stat.h + pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int; + + // sys/uio.h + pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t; + pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t; + pub fn readv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; + pub fn writev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; + + // sys/utsname.h + pub fn uname(utsname: *mut utsname) -> c_int; + + // time.h + pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut crate::timezone) -> c_int; + pub fn clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; + pub fn strftime( + s: *mut c_char, + max: size_t, + format: *const c_char, + tm: *const crate::tm, + ) -> size_t; + + // utmp.h + pub fn login_tty(fd: c_int) -> c_int; +} diff --git a/http/vendor/libc/src/unix/solarish/compat.rs b/http/vendor/libc/src/unix/solarish/compat.rs new file mode 100644 index 0000000..6876a9d --- /dev/null +++ b/http/vendor/libc/src/unix/solarish/compat.rs @@ -0,0 +1,222 @@ +// Common functions that are unfortunately missing on illumos and +// Solaris, but often needed by other crates. +use core::cmp::min; + +use crate::unix::solarish::*; +use crate::{ + c_char, + c_int, + size_t, +}; + +pub unsafe fn cfmakeraw(termios: *mut crate::termios) { + (*termios).c_iflag &= + !(IMAXBEL | IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON); + (*termios).c_oflag &= !OPOST; + (*termios).c_lflag &= !(ECHO | ECHONL | ICANON | ISIG | IEXTEN); + (*termios).c_cflag &= !(CSIZE | PARENB); + (*termios).c_cflag |= CS8; + + // By default, most software expects a pending read to block until at + // least one byte becomes available. As per termio(7I), this requires + // setting the MIN and TIME parameters appropriately. + // + // As a somewhat unfortunate artefact of history, the MIN and TIME slots + // in the control character array overlap with the EOF and EOL slots used + // for canonical mode processing. Because the EOF character needs to be + // the ASCII EOT value (aka Control-D), it has the byte value 4. When + // switching to raw mode, this is interpreted as a MIN value of 4; i.e., + // reads will block until at least four bytes have been input. + // + // Other platforms with a distinct MIN slot like Linux and FreeBSD appear + // to default to a MIN value of 1, so we'll force that value here: + (*termios).c_cc[VMIN] = 1; + (*termios).c_cc[VTIME] = 0; +} + +pub unsafe fn cfsetspeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int { + // Neither of these functions on illumos or Solaris actually ever + // return an error + crate::cfsetispeed(termios, speed); + crate::cfsetospeed(termios, speed); + 0 +} + +#[cfg(target_os = "illumos")] +unsafe fn bail(fdm: c_int, fds: c_int) -> c_int { + let e = *___errno(); + if fds >= 0 { + crate::close(fds); + } + if fdm >= 0 { + crate::close(fdm); + } + *___errno() = e; + -1 +} + +#[cfg(target_os = "illumos")] +pub unsafe fn openpty( + amain: *mut c_int, + asubord: *mut c_int, + name: *mut c_char, + termp: *const termios, + winp: *const crate::winsize, +) -> c_int { + const PTEM: &[u8] = b"ptem\0"; + const LDTERM: &[u8] = b"ldterm\0"; + + // Open the main pseudo-terminal device, making sure not to set it as the + // controlling terminal for this process: + let fdm = crate::posix_openpt(O_RDWR | O_NOCTTY); + if fdm < 0 { + return -1; + } + + // Set permissions and ownership on the subordinate device and unlock it: + if crate::grantpt(fdm) < 0 || crate::unlockpt(fdm) < 0 { + return bail(fdm, -1); + } + + // Get the path name of the subordinate device: + let subordpath = crate::ptsname(fdm); + if subordpath.is_null() { + return bail(fdm, -1); + } + + // Open the subordinate device without setting it as the controlling + // terminal for this process: + let fds = crate::open(subordpath, O_RDWR | O_NOCTTY); + if fds < 0 { + return bail(fdm, -1); + } + + // Check if the STREAMS modules are already pushed: + let setup = crate::ioctl(fds, I_FIND, LDTERM.as_ptr()); + if setup < 0 { + return bail(fdm, fds); + } else if setup == 0 { + // The line discipline is not present, so push the appropriate STREAMS + // modules for the subordinate device: + if crate::ioctl(fds, I_PUSH, PTEM.as_ptr()) < 0 + || crate::ioctl(fds, I_PUSH, LDTERM.as_ptr()) < 0 + { + return bail(fdm, fds); + } + } + + // If provided, set the terminal parameters: + if !termp.is_null() && crate::tcsetattr(fds, TCSAFLUSH, termp) != 0 { + return bail(fdm, fds); + } + + // If provided, set the window size: + if !winp.is_null() && crate::ioctl(fds, TIOCSWINSZ, winp) < 0 { + return bail(fdm, fds); + } + + // If the caller wants the name of the subordinate device, copy it out. + // + // Note that this is a terrible interface: there appears to be no standard + // upper bound on the copy length for this pointer. Nobody should pass + // anything but NULL here, preferring instead to use ptsname(3C) directly. + if !name.is_null() { + crate::strcpy(name, subordpath); + } + + *amain = fdm; + *asubord = fds; + 0 +} + +#[cfg(target_os = "illumos")] +pub unsafe fn forkpty( + amain: *mut c_int, + name: *mut c_char, + termp: *const termios, + winp: *const crate::winsize, +) -> crate::pid_t { + let mut fds = -1; + + if openpty(amain, &mut fds, name, termp, winp) != 0 { + return -1; + } + + let pid = crate::fork(); + if pid < 0 { + return bail(*amain, fds); + } else if pid > 0 { + // In the parent process, we close the subordinate device and return the + // process ID of the new child: + crate::close(fds); + return pid; + } + + // The rest of this function executes in the child process. + + // Close the main side of the pseudo-terminal pair: + crate::close(*amain); + + // Use TIOCSCTTY to set the subordinate device as our controlling + // terminal. This will fail (with ENOTTY) if we are not the leader in + // our own session, so we call setsid() first. Finally, arrange for + // the pseudo-terminal to occupy the standard I/O descriptors. + if crate::setsid() < 0 + || crate::ioctl(fds, TIOCSCTTY, 0) < 0 + || crate::dup2(fds, 0) < 0 + || crate::dup2(fds, 1) < 0 + || crate::dup2(fds, 2) < 0 + { + // At this stage there are no particularly good ways to handle failure. + // Exit as abruptly as possible, using _exit() to avoid messing with any + // state still shared with the parent process. + crate::_exit(EXIT_FAILURE); + } + // Close the inherited descriptor, taking care to avoid closing the standard + // descriptors by mistake: + if fds > 2 { + crate::close(fds); + } + + 0 +} + +pub unsafe fn getpwent_r( + pwd: *mut passwd, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut passwd, +) -> c_int { + let old_errno = *crate::___errno(); + *crate::___errno() = 0; + *result = native_getpwent_r(pwd, buf, min(buflen, c_int::MAX as size_t) as c_int); + + let ret = if (*result).is_null() { + *crate::___errno() + } else { + 0 + }; + *crate::___errno() = old_errno; + + ret +} + +pub unsafe fn getgrent_r( + grp: *mut crate::group, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::group, +) -> c_int { + let old_errno = *crate::___errno(); + *crate::___errno() = 0; + *result = native_getgrent_r(grp, buf, min(buflen, c_int::MAX as size_t) as c_int); + + let ret = if (*result).is_null() { + *crate::___errno() + } else { + 0 + }; + *crate::___errno() = old_errno; + + ret +} diff --git a/http/vendor/libc/src/unix/solarish/illumos.rs b/http/vendor/libc/src/unix/solarish/illumos.rs new file mode 100644 index 0000000..50e6302 --- /dev/null +++ b/http/vendor/libc/src/unix/solarish/illumos.rs @@ -0,0 +1,292 @@ +use crate::prelude::*; +use crate::{ + exit_status, + off_t, + NET_MAC_AWARE, + NET_MAC_AWARE_INHERIT, + PRIV_AWARE_RESET, + PRIV_DEBUG, + PRIV_PFEXEC, + PRIV_XPOLICY, +}; + +pub type lgrp_rsrc_t = c_int; +pub type lgrp_affinity_t = c_int; + +s! { + pub struct aiocb { + pub aio_fildes: c_int, + pub aio_buf: *mut c_void, + pub aio_nbytes: size_t, + pub aio_offset: off_t, + pub aio_reqprio: c_int, + pub aio_sigevent: crate::sigevent, + pub aio_lio_opcode: c_int, + pub aio_resultp: crate::aio_result_t, + pub aio_state: c_int, + pub aio__pad: [c_int; 1], + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, + pub shm_amp: *mut c_void, + pub shm_lkcnt: c_ushort, + pub shm_lpid: crate::pid_t, + pub shm_cpid: crate::pid_t, + pub shm_nattch: crate::shmatt_t, + pub shm_cnattch: c_ulong, + pub shm_atime: crate::time_t, + pub shm_dtime: crate::time_t, + pub shm_ctime: crate::time_t, + pub shm_pad4: [i64; 4], + } + + pub struct fil_info { + pub fi_flags: c_int, + pub fi_pos: c_int, + pub fi_name: [c_char; crate::FILNAME_MAX as usize], + } + + #[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), repr(packed(4)))] + pub struct epoll_event { + pub events: u32, + pub u64: u64, + } + + pub struct utmpx { + pub ut_user: [c_char; _UTX_USERSIZE], + pub ut_id: [c_char; _UTX_IDSIZE], + pub ut_line: [c_char; _UTX_LINESIZE], + pub ut_pid: crate::pid_t, + pub ut_type: c_short, + pub ut_exit: exit_status, + pub ut_tv: crate::timeval, + pub ut_session: c_int, + pub ut_pad: [c_int; _UTX_PADSIZE], + pub ut_syslen: c_short, + pub ut_host: [c_char; _UTX_HOSTSIZE], + } +} + +pub const _UTX_USERSIZE: usize = 32; +pub const _UTX_LINESIZE: usize = 32; +pub const _UTX_PADSIZE: usize = 5; +pub const _UTX_IDSIZE: usize = 4; +pub const _UTX_HOSTSIZE: usize = 257; + +pub const AF_LOCAL: c_int = 1; // AF_UNIX +pub const AF_FILE: c_int = 1; // AF_UNIX + +pub const EFD_SEMAPHORE: c_int = 0x1; +pub const EFD_NONBLOCK: c_int = 0x800; +pub const EFD_CLOEXEC: c_int = 0x80000; + +pub const POLLRDHUP: c_short = 0x4000; + +pub const TCP_KEEPIDLE: c_int = 34; +pub const TCP_KEEPCNT: c_int = 35; +pub const TCP_KEEPINTVL: c_int = 36; +pub const TCP_CONGESTION: c_int = 37; + +// These constants are correct for 64-bit programs or 32-bit programs that are +// not using large-file mode. If Rust ever supports anything other than 64-bit +// compilation on illumos, this may require adjustment: +pub const F_OFD_GETLK: c_int = 47; +pub const F_OFD_SETLK: c_int = 48; +pub const F_OFD_SETLKW: c_int = 49; +pub const F_FLOCK: c_int = 53; +pub const F_FLOCKW: c_int = 54; + +pub const F_DUPFD_CLOEXEC: c_int = 37; +pub const F_DUPFD_CLOFORK: c_int = 58; +pub const F_DUP2FD_CLOEXEC: c_int = 36; +pub const F_DUP2FD_CLOFORK: c_int = 57; +pub const F_DUP3FD: c_int = 59; + +pub const FD_CLOFORK: c_int = 2; + +pub const FIL_ATTACH: c_int = 0x1; +pub const FIL_DETACH: c_int = 0x2; +pub const FIL_LIST: c_int = 0x3; +pub const FILNAME_MAX: c_int = 32; +pub const FILF_PROG: c_int = 0x1; +pub const FILF_AUTO: c_int = 0x2; +pub const FILF_BYPASS: c_int = 0x4; +pub const SOL_FILTER: c_int = 0xfffc; + +pub const MADV_PURGE: c_int = 9; + +pub const POSIX_FADV_NORMAL: c_int = 0; +pub const POSIX_FADV_RANDOM: c_int = 1; +pub const POSIX_FADV_SEQUENTIAL: c_int = 2; +pub const POSIX_FADV_WILLNEED: c_int = 3; +pub const POSIX_FADV_DONTNEED: c_int = 4; +pub const POSIX_FADV_NOREUSE: c_int = 5; + +pub const POSIX_SPAWN_SETSID: c_short = 0x40; + +pub const SIGINFO: c_int = 41; + +pub const O_DIRECT: c_int = 0x2000000; +pub const O_CLOFORK: c_int = 0x4000000; + +pub const MSG_CMSG_CLOEXEC: c_int = 0x1000; +pub const MSG_CMSG_CLOFORK: c_int = 0x2000; + +pub const PBIND_HARD: crate::processorid_t = -3; +pub const PBIND_SOFT: crate::processorid_t = -4; + +pub const PS_SYSTEM: c_int = 1; + +pub const MAP_FILE: c_int = 0; + +pub const MAP_32BIT: c_int = 0x80; + +pub const AF_NCA: c_int = 28; + +pub const PF_NCA: c_int = AF_NCA; + +pub const LOCK_SH: c_int = 1; +pub const LOCK_EX: c_int = 2; +pub const LOCK_NB: c_int = 4; +pub const LOCK_UN: c_int = 8; + +pub const _PC_LAST: c_int = 101; + +pub const _CS_PATH: c_int = 65; + +pub const VSTATUS: usize = 16; +pub const VERASE2: usize = 17; + +pub const EPOLLIN: c_int = 0x1; +pub const EPOLLPRI: c_int = 0x2; +pub const EPOLLOUT: c_int = 0x4; +pub const EPOLLRDNORM: c_int = 0x40; +pub const EPOLLRDBAND: c_int = 0x80; +pub const EPOLLWRNORM: c_int = 0x100; +pub const EPOLLWRBAND: c_int = 0x200; +pub const EPOLLMSG: c_int = 0x400; +pub const EPOLLERR: c_int = 0x8; +pub const EPOLLHUP: c_int = 0x10; +pub const EPOLLET: c_int = 0x80000000; +pub const EPOLLRDHUP: c_int = 0x2000; +pub const EPOLLONESHOT: c_int = 0x40000000; +pub const EPOLLWAKEUP: c_int = 0x20000000; +pub const EPOLLEXCLUSIVE: c_int = 0x10000000; +pub const EPOLL_CLOEXEC: c_int = 0x80000; +pub const EPOLL_CTL_ADD: c_int = 1; +pub const EPOLL_CTL_MOD: c_int = 3; +pub const EPOLL_CTL_DEL: c_int = 2; + +pub const PRIV_USER: c_uint = PRIV_DEBUG + | NET_MAC_AWARE + | NET_MAC_AWARE_INHERIT + | PRIV_XPOLICY + | PRIV_AWARE_RESET + | PRIV_PFEXEC; + +pub const LGRP_RSRC_COUNT: crate::lgrp_rsrc_t = 2; +pub const LGRP_RSRC_CPU: crate::lgrp_rsrc_t = 0; +pub const LGRP_RSRC_MEM: crate::lgrp_rsrc_t = 1; + +pub const P_DISABLED: c_int = 0x008; + +pub const AT_SUN_HWCAP2: c_uint = 2023; +pub const AT_SUN_FPTYPE: c_uint = 2027; + +pub const B1000000: crate::speed_t = 24; +pub const B1152000: crate::speed_t = 25; +pub const B1500000: crate::speed_t = 26; +pub const B2000000: crate::speed_t = 27; +pub const B2500000: crate::speed_t = 28; +pub const B3000000: crate::speed_t = 29; +pub const B3500000: crate::speed_t = 30; +pub const B4000000: crate::speed_t = 31; + +// sys/systeminfo.h +pub const SI_ADDRESS_WIDTH: c_int = 520; + +// sys/timerfd.h +pub const TFD_CLOEXEC: i32 = 0o2000000; +pub const TFD_NONBLOCK: i32 = 0o4000; +pub const TFD_TIMER_ABSTIME: i32 = 1 << 0; +pub const TFD_TIMER_CANCEL_ON_SET: i32 = 1 << 1; + +extern "C" { + pub fn eventfd(initval: c_uint, flags: c_int) -> c_int; + + pub fn epoll_pwait( + epfd: c_int, + events: *mut crate::epoll_event, + maxevents: c_int, + timeout: c_int, + sigmask: *const crate::sigset_t, + ) -> c_int; + pub fn epoll_create(size: c_int) -> c_int; + pub fn epoll_create1(flags: c_int) -> c_int; + pub fn epoll_wait( + epfd: c_int, + events: *mut crate::epoll_event, + maxevents: c_int, + timeout: c_int, + ) -> c_int; + pub fn epoll_ctl(epfd: c_int, op: c_int, fd: c_int, event: *mut crate::epoll_event) -> c_int; + + pub fn mincore(addr: crate::caddr_t, len: size_t, vec: *mut c_char) -> c_int; + + pub fn pset_bind_lwp( + pset: crate::psetid_t, + id: crate::id_t, + pid: crate::pid_t, + opset: *mut crate::psetid_t, + ) -> c_int; + pub fn pset_getloadavg(pset: crate::psetid_t, load: *mut c_double, num: c_int) -> c_int; + + pub fn pthread_attr_get_np(thread: crate::pthread_t, attr: *mut crate::pthread_attr_t) + -> c_int; + pub fn pthread_attr_getstackaddr( + attr: *const crate::pthread_attr_t, + stackaddr: *mut *mut c_void, + ) -> c_int; + pub fn pthread_attr_setstack( + attr: *mut crate::pthread_attr_t, + stackaddr: *mut c_void, + stacksize: size_t, + ) -> c_int; + pub fn pthread_attr_setstackaddr( + attr: *mut crate::pthread_attr_t, + stackaddr: *mut c_void, + ) -> c_int; + + pub fn posix_fadvise(fd: c_int, offset: off_t, len: off_t, advice: c_int) -> c_int; + pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t; + pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t; + pub fn getpagesizes2(pagesize: *mut size_t, nelem: c_int) -> c_int; + + pub fn posix_spawn_file_actions_addfchdir_np( + file_actions: *mut crate::posix_spawn_file_actions_t, + fd: c_int, + ) -> c_int; + + pub fn ptsname_r(fildes: c_int, name: *mut c_char, namelen: size_t) -> c_int; + + pub fn syncfs(fd: c_int) -> c_int; + + pub fn strcasecmp_l(s1: *const c_char, s2: *const c_char, loc: crate::locale_t) -> c_int; + pub fn strncasecmp_l( + s1: *const c_char, + s2: *const c_char, + n: size_t, + loc: crate::locale_t, + ) -> c_int; + + pub fn timerfd_create(clockid: c_int, flags: c_int) -> c_int; + pub fn timerfd_gettime(fd: c_int, curr_value: *mut crate::itimerspec) -> c_int; + pub fn timerfd_settime( + fd: c_int, + flags: c_int, + new_value: *const crate::itimerspec, + old_value: *mut crate::itimerspec, + ) -> c_int; +} diff --git a/http/vendor/libc/src/unix/solarish/mod.rs b/http/vendor/libc/src/unix/solarish/mod.rs new file mode 100644 index 0000000..494ecdb --- /dev/null +++ b/http/vendor/libc/src/unix/solarish/mod.rs @@ -0,0 +1,3049 @@ +use crate::prelude::*; + +pub type caddr_t = *mut c_char; + +pub type clockid_t = c_int; +pub type blkcnt_t = c_long; +pub type clock_t = c_long; +pub type daddr_t = c_long; +pub type dev_t = c_ulong; +pub type fsblkcnt_t = c_ulong; +pub type fsfilcnt_t = c_ulong; +pub type ino_t = c_ulong; +pub type key_t = c_int; +pub type major_t = c_uint; +pub type minor_t = c_uint; +pub type mode_t = c_uint; +pub type nlink_t = c_uint; +pub type rlim_t = c_ulong; +pub type speed_t = c_uint; +pub type tcflag_t = c_uint; +pub type time_t = c_long; +pub type timer_t = c_int; +pub type wchar_t = c_int; +pub type nfds_t = c_ulong; +pub type projid_t = c_int; +pub type zoneid_t = c_int; +pub type psetid_t = c_int; +pub type processorid_t = c_int; +pub type chipid_t = c_int; +pub type ctid_t = crate::id_t; + +pub type suseconds_t = c_long; +pub type off_t = c_long; +pub type useconds_t = c_uint; +pub type socklen_t = c_uint; +pub type sa_family_t = u16; +pub type pthread_t = c_uint; +pub type pthread_key_t = c_uint; +pub type thread_t = c_uint; +pub type blksize_t = c_int; +pub type nl_item = c_int; +pub type mqd_t = *mut c_void; +pub type id_t = c_int; +pub type idtype_t = c_uint; +pub type shmatt_t = c_ulong; + +pub type lgrp_id_t = crate::id_t; +pub type lgrp_mem_size_t = c_longlong; +pub type lgrp_cookie_t = crate::uintptr_t; +pub type lgrp_content_t = c_uint; +pub type lgrp_lat_between_t = c_uint; +pub type lgrp_mem_size_flag_t = c_uint; +pub type lgrp_view_t = c_uint; + +pub type posix_spawnattr_t = *mut c_void; +pub type posix_spawn_file_actions_t = *mut c_void; + +extern_ty! { + pub enum timezone {} + pub enum ucred_t {} +} + +s! { + pub struct in_addr { + pub s_addr: crate::in_addr_t, + } + + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct ip_mreq_source { + pub imr_multiaddr: in_addr, + pub imr_sourceaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct ipc_perm { + pub uid: crate::uid_t, + pub gid: crate::gid_t, + pub cuid: crate::uid_t, + pub cgid: crate::gid_t, + pub mode: mode_t, + pub seq: c_uint, + pub key: crate::key_t, + } + + pub struct sockaddr { + pub sa_family: sa_family_t, + pub sa_data: [c_char; 14], + } + + pub struct sockaddr_in { + pub sin_family: sa_family_t, + pub sin_port: crate::in_port_t, + pub sin_addr: crate::in_addr, + pub sin_zero: [c_char; 8], + } + + pub struct sockaddr_in6 { + pub sin6_family: sa_family_t, + pub sin6_port: crate::in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: crate::in6_addr, + pub sin6_scope_id: u32, + pub __sin6_src_id: u32, + } + + pub struct in_pktinfo { + pub ipi_ifindex: c_uint, + pub ipi_spec_dst: crate::in_addr, + pub ipi_addr: crate::in_addr, + } + + pub struct in6_pktinfo { + pub ipi6_addr: crate::in6_addr, + pub ipi6_ifindex: c_uint, + } + + pub struct passwd { + pub pw_name: *mut c_char, + pub pw_passwd: *mut c_char, + pub pw_uid: crate::uid_t, + pub pw_gid: crate::gid_t, + pub pw_age: *mut c_char, + pub pw_comment: *mut c_char, + pub pw_gecos: *mut c_char, + pub pw_dir: *mut c_char, + pub pw_shell: *mut c_char, + } + + pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut c_char, + pub ifa_flags: u64, + pub ifa_addr: *mut crate::sockaddr, + pub ifa_netmask: *mut crate::sockaddr, + pub ifa_dstaddr: *mut crate::sockaddr, + pub ifa_data: *mut c_void, + } + + pub struct itimerspec { + pub it_interval: crate::timespec, + pub it_value: crate::timespec, + } + + pub struct tm { + pub tm_sec: c_int, + pub tm_min: c_int, + pub tm_hour: c_int, + pub tm_mday: c_int, + pub tm_mon: c_int, + pub tm_year: c_int, + pub tm_wday: c_int, + pub tm_yday: c_int, + pub tm_isdst: c_int, + } + + pub struct msghdr { + pub msg_name: *mut c_void, + pub msg_namelen: crate::socklen_t, + pub msg_iov: *mut crate::iovec, + pub msg_iovlen: c_int, + pub msg_control: *mut c_void, + pub msg_controllen: crate::socklen_t, + pub msg_flags: c_int, + } + + pub struct cmsghdr { + pub cmsg_len: crate::socklen_t, + pub cmsg_level: c_int, + pub cmsg_type: c_int, + } + + pub struct pthread_attr_t { + __pthread_attrp: *mut c_void, + } + + pub struct pthread_mutex_t { + __pthread_mutex_flag1: u16, + __pthread_mutex_flag2: u8, + __pthread_mutex_ceiling: u8, + __pthread_mutex_type: u16, + __pthread_mutex_magic: u16, + __pthread_mutex_lock: u64, + __pthread_mutex_data: u64, + } + + pub struct pthread_mutexattr_t { + __pthread_mutexattrp: *mut c_void, + } + + pub struct pthread_cond_t { + __pthread_cond_flag: [u8; 4], + __pthread_cond_type: u16, + __pthread_cond_magic: u16, + __pthread_cond_data: u64, + } + + pub struct pthread_condattr_t { + __pthread_condattrp: *mut c_void, + } + + pub struct pthread_rwlock_t { + __pthread_rwlock_readers: i32, + __pthread_rwlock_type: u16, + __pthread_rwlock_magic: u16, + __pthread_rwlock_mutex: crate::pthread_mutex_t, + __pthread_rwlock_readercv: crate::pthread_cond_t, + __pthread_rwlock_writercv: crate::pthread_cond_t, + } + + pub struct pthread_rwlockattr_t { + __pthread_rwlockattrp: *mut c_void, + } + + pub struct dirent { + pub d_ino: crate::ino_t, + pub d_off: off_t, + pub d_reclen: u16, + pub d_name: [c_char; 3], + } + + pub struct glob_t { + pub gl_pathc: size_t, + pub gl_pathv: *mut *mut c_char, + pub gl_offs: size_t, + __unused1: Padding<*mut c_void>, + __unused2: Padding, + #[cfg(target_os = "illumos")] + __unused3: Padding, + #[cfg(target_os = "illumos")] + __unused4: Padding, + #[cfg(target_os = "illumos")] + __unused5: Padding<*mut c_void>, + #[cfg(target_os = "illumos")] + __unused6: Padding<*mut c_void>, + #[cfg(target_os = "illumos")] + __unused7: Padding<*mut c_void>, + #[cfg(target_os = "illumos")] + __unused8: Padding<*mut c_void>, + #[cfg(target_os = "illumos")] + __unused9: Padding<*mut c_void>, + #[cfg(target_os = "illumos")] + __unused10: Padding<*mut c_void>, + } + + pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + #[cfg(target_arch = "sparc64")] + __sparcv9_pad: Padding, + pub ai_addrlen: crate::socklen_t, + pub ai_canonname: *mut c_char, + pub ai_addr: *mut crate::sockaddr, + pub ai_next: *mut addrinfo, + } + + pub struct sigset_t { + bits: [u32; 4], + } + + pub struct sigaction { + pub sa_flags: c_int, + pub sa_sigaction: crate::sighandler_t, + pub sa_mask: sigset_t, + } + + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_size: size_t, + pub ss_flags: c_int, + } + + pub struct statvfs { + pub f_bsize: c_ulong, + pub f_frsize: c_ulong, + pub f_blocks: crate::fsblkcnt_t, + pub f_bfree: crate::fsblkcnt_t, + pub f_bavail: crate::fsblkcnt_t, + pub f_files: crate::fsfilcnt_t, + pub f_ffree: crate::fsfilcnt_t, + pub f_favail: crate::fsfilcnt_t, + pub f_fsid: c_ulong, + pub f_basetype: [c_char; 16], + pub f_flag: c_ulong, + pub f_namemax: c_ulong, + pub f_fstr: [c_char; 32], + } + + pub struct sendfilevec_t { + pub sfv_fd: c_int, + pub sfv_flag: c_uint, + pub sfv_off: off_t, + pub sfv_len: size_t, + } + + pub struct sched_param { + pub sched_priority: c_int, + sched_pad: Padding<[c_int; 8]>, + } + + pub struct Dl_info { + pub dli_fname: *const c_char, + pub dli_fbase: *mut c_void, + pub dli_sname: *const c_char, + pub dli_saddr: *mut c_void, + } + + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_mode: mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + pub st_size: off_t, + pub st_atime: crate::time_t, + pub st_atime_nsec: c_long, + pub st_mtime: crate::time_t, + pub st_mtime_nsec: c_long, + pub st_ctime: crate::time_t, + pub st_ctime_nsec: c_long, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + pub st_fstype: [c_char; _ST_FSTYPSZ as usize], + } + + pub struct termios { + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_cc: [crate::cc_t; crate::NCCS], + } + + pub struct lconv { + pub decimal_point: *mut c_char, + pub thousands_sep: *mut c_char, + pub grouping: *mut c_char, + pub int_curr_symbol: *mut c_char, + pub currency_symbol: *mut c_char, + pub mon_decimal_point: *mut c_char, + pub mon_thousands_sep: *mut c_char, + pub mon_grouping: *mut c_char, + pub positive_sign: *mut c_char, + pub negative_sign: *mut c_char, + pub int_frac_digits: c_char, + pub frac_digits: c_char, + pub p_cs_precedes: c_char, + pub p_sep_by_space: c_char, + pub n_cs_precedes: c_char, + pub n_sep_by_space: c_char, + pub p_sign_posn: c_char, + pub n_sign_posn: c_char, + pub int_p_cs_precedes: c_char, + pub int_p_sep_by_space: c_char, + pub int_n_cs_precedes: c_char, + pub int_n_sep_by_space: c_char, + pub int_p_sign_posn: c_char, + pub int_n_sign_posn: c_char, + } + + pub struct sem_t { + pub sem_count: u32, + pub sem_type: u16, + pub sem_magic: u16, + pub sem_pad1: [u64; 3], + pub sem_pad2: [u64; 2], + } + + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: off_t, + pub l_len: off_t, + pub l_sysid: c_int, + pub l_pid: crate::pid_t, + pub l_pad: [c_long; 4], + } + + pub struct if_nameindex { + pub if_index: c_uint, + pub if_name: *mut c_char, + } + + pub struct mq_attr { + pub mq_flags: c_long, + pub mq_maxmsg: c_long, + pub mq_msgsize: c_long, + pub mq_curmsgs: c_long, + _pad: Padding<[c_int; 12]>, + } + + pub struct port_event { + pub portev_events: c_int, + pub portev_source: c_ushort, + pub portev_pad: c_ushort, + pub portev_object: crate::uintptr_t, + pub portev_user: *mut c_void, + } + + pub struct port_notify { + pub portnfy_port: c_int, + pub portnfy_user: *mut c_void, + } + + pub struct aio_result_t { + pub aio_return: ssize_t, + pub aio_errno: c_int, + } + + pub struct exit_status { + e_termination: c_short, + e_exit: c_short, + } + + pub struct utmp { + pub ut_user: [c_char; 8], + pub ut_id: [c_char; 4], + pub ut_line: [c_char; 12], + pub ut_pid: c_short, + pub ut_type: c_short, + pub ut_exit: exit_status, + pub ut_time: crate::time_t, + } + + pub struct timex { + pub modes: u32, + pub offset: i32, + pub freq: i32, + pub maxerror: i32, + pub esterror: i32, + pub status: i32, + pub constant: i32, + pub precision: i32, + pub tolerance: i32, + pub ppsfreq: i32, + pub jitter: i32, + pub shift: i32, + pub stabil: i32, + pub jitcnt: i32, + pub calcnt: i32, + pub errcnt: i32, + pub stbcnt: i32, + } + + pub struct ntptimeval { + pub time: crate::timeval, + pub maxerror: i32, + pub esterror: i32, + } + + pub struct mmapobj_result_t { + pub mr_addr: crate::caddr_t, + pub mr_msize: size_t, + pub mr_fsize: size_t, + pub mr_offset: size_t, + pub mr_prot: c_uint, + pub mr_flags: c_uint, + } + + pub struct lgrp_affinity_args_t { + pub idtype: crate::idtype_t, + pub id: crate::id_t, + pub lgrp: crate::lgrp_id_t, + pub aff: crate::lgrp_affinity_t, + } + + pub struct processor_info_t { + pub pi_state: c_int, + pub pi_processor_type: [c_char; PI_TYPELEN as usize], + pub pi_fputypes: [c_char; PI_FPUTYPE as usize], + pub pi_clock: c_int, + } + + pub struct option { + pub name: *const c_char, + pub has_arg: c_int, + pub flag: *mut c_int, + pub val: c_int, + } + + pub struct sockaddr_un { + pub sun_family: sa_family_t, + pub sun_path: [c_char; 108], + } + + pub struct utsname { + pub sysname: [c_char; 257], + pub nodename: [c_char; 257], + pub release: [c_char; 257], + pub version: [c_char; 257], + pub machine: [c_char; 257], + } + + pub struct fd_set { + #[cfg(target_pointer_width = "64")] + fds_bits: [i64; FD_SETSIZE as usize / 64], + #[cfg(target_pointer_width = "32")] + fds_bits: [i32; FD_SETSIZE as usize / 32], + } + + pub struct sockaddr_storage { + pub ss_family: crate::sa_family_t, + __ss_pad1: Padding<[u8; 6]>, + __ss_align: i64, + __ss_pad2: Padding<[u8; 240]>, + } + + pub struct sockaddr_dl { + pub sdl_family: c_ushort, + pub sdl_index: c_ushort, + pub sdl_type: c_uchar, + pub sdl_nlen: c_uchar, + pub sdl_alen: c_uchar, + pub sdl_slen: c_uchar, + pub sdl_data: [c_char; 244], + } + + pub struct sigevent { + pub sigev_notify: c_int, + pub sigev_signo: c_int, + pub sigev_value: crate::sigval, + pub ss_sp: *mut c_void, + pub sigev_notify_attributes: *const crate::pthread_attr_t, + __sigev_pad2: Padding, + } +} + +s_no_extra_traits! { + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + pub struct siginfo_t { + pub si_signo: c_int, + pub si_code: c_int, + pub si_errno: c_int, + #[cfg(target_pointer_width = "64")] + pub si_pad: c_int, + + __data_pad: [c_int; SIGINFO_DATA_SIZE], + } + + #[repr(align(16))] + pub union pad128_t { + // pub _q in this structure would be a "long double", of 16 bytes + pub _l: [i32; 4], + } + + #[repr(align(16))] + pub union upad128_t { + // pub _q in this structure would be a "long double", of 16 bytes + pub _l: [u32; 4], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl siginfo_t { + /// The siginfo_t will have differing contents based on the delivered signal. Based on + /// `si_signo`, this determines how many of the `c_int` pad fields contain valid data + /// exposed by the C unions. + /// + /// It is not yet exhausitive for the OS-defined types, and defaults to assuming the + /// entire data pad area is "valid" for otherwise unrecognized signal numbers. + fn data_field_count(&self) -> usize { + match self.si_signo { + SIGSEGV | SIGBUS | SIGILL | SIGTRAP | SIGFPE => { + size_of::() / size_of::() + } + SIGCLD => size_of::() / size_of::(), + SIGHUP + | SIGINT + | SIGQUIT + | SIGABRT + | SIGSYS + | SIGPIPE + | SIGALRM + | SIGTERM + | crate::SIGUSR1 + | crate::SIGUSR2 + | SIGPWR + | SIGWINCH + | SIGURG => size_of::() / size_of::(), + _ => SIGINFO_DATA_SIZE, + } + } + } + impl PartialEq for siginfo_t { + fn eq(&self, other: &siginfo_t) -> bool { + if self.si_signo == other.si_signo + && self.si_code == other.si_code + && self.si_errno == other.si_errno + { + // FIXME(solarish): The `si_pad` field in the 64-bit version of the struct is ignored + // (for now) when doing comparisons. + + let field_count = self.data_field_count(); + self.__data_pad[..field_count] + .iter() + .zip(other.__data_pad[..field_count].iter()) + .all(|(a, b)| a == b) + } else { + false + } + } + } + impl Eq for siginfo_t {} + impl hash::Hash for siginfo_t { + fn hash(&self, state: &mut H) { + self.si_signo.hash(state); + self.si_code.hash(state); + self.si_errno.hash(state); + + // FIXME(solarish): The `si_pad` field in the 64-bit version of the struct is ignored + // (for now) when doing hashing. + + let field_count = self.data_field_count(); + self.__data_pad[..field_count].hash(state) + } + } + + impl PartialEq for pad128_t { + fn eq(&self, other: &pad128_t) -> bool { + unsafe { + // FIXME(solarish): self._q == other._q || + self._l == other._l + } + } + } + impl Eq for pad128_t {} + impl hash::Hash for pad128_t { + fn hash(&self, state: &mut H) { + unsafe { + // FIXME(solarish): state.write_i64(self._q as i64); + self._l.hash(state); + } + } + } + impl PartialEq for upad128_t { + fn eq(&self, other: &upad128_t) -> bool { + unsafe { + // FIXME(solarish): self._q == other._q || + self._l == other._l + } + } + } + impl Eq for upad128_t {} + impl hash::Hash for upad128_t { + fn hash(&self, state: &mut H) { + unsafe { + // FIXME(solarish): state.write_i64(self._q as i64); + self._l.hash(state); + } + } + } + } +} + +cfg_if! { + if #[cfg(target_pointer_width = "64")] { + const SIGINFO_DATA_SIZE: usize = 60; + } else { + const SIGINFO_DATA_SIZE: usize = 29; + } +} + +s_no_extra_traits! { + struct siginfo_fault { + addr: *mut c_void, + trapno: c_int, + pc: *mut crate::caddr_t, + } + + struct siginfo_cldval { + utime: crate::clock_t, + status: c_int, + stime: crate::clock_t, + } + + struct siginfo_killval { + uid: crate::uid_t, + value: crate::sigval, + // Pad out to match the SIGCLD value size + _pad: Padding<*mut c_void>, + } + + struct siginfo_sigcld { + pid: crate::pid_t, + val: siginfo_cldval, + ctid: crate::ctid_t, + zoneid: crate::zoneid_t, + } + + struct siginfo_kill { + pid: crate::pid_t, + val: siginfo_killval, + ctid: crate::ctid_t, + zoneid: crate::zoneid_t, + } +} + +impl siginfo_t { + unsafe fn sidata(&self) -> T { + *((&self.__data_pad) as *const c_int as *const T) + } + pub unsafe fn si_addr(&self) -> *mut c_void { + let sifault: siginfo_fault = self.sidata(); + sifault.addr + } + pub unsafe fn si_uid(&self) -> crate::uid_t { + let kill: siginfo_kill = self.sidata(); + kill.val.uid + } + pub unsafe fn si_value(&self) -> crate::sigval { + let kill: siginfo_kill = self.sidata(); + kill.val.value + } + pub unsafe fn si_pid(&self) -> crate::pid_t { + let sigcld: siginfo_sigcld = self.sidata(); + sigcld.pid + } + pub unsafe fn si_status(&self) -> c_int { + let sigcld: siginfo_sigcld = self.sidata(); + sigcld.val.status + } + pub unsafe fn si_utime(&self) -> c_long { + let sigcld: siginfo_sigcld = self.sidata(); + sigcld.val.utime + } + pub unsafe fn si_stime(&self) -> c_long { + let sigcld: siginfo_sigcld = self.sidata(); + sigcld.val.stime + } +} + +pub const LC_CTYPE: c_int = 0; +pub const LC_NUMERIC: c_int = 1; +pub const LC_TIME: c_int = 2; +pub const LC_COLLATE: c_int = 3; +pub const LC_MONETARY: c_int = 4; +pub const LC_MESSAGES: c_int = 5; +pub const LC_ALL: c_int = 6; +pub const LC_CTYPE_MASK: c_int = 1 << LC_CTYPE; +pub const LC_NUMERIC_MASK: c_int = 1 << LC_NUMERIC; +pub const LC_TIME_MASK: c_int = 1 << LC_TIME; +pub const LC_COLLATE_MASK: c_int = 1 << LC_COLLATE; +pub const LC_MONETARY_MASK: c_int = 1 << LC_MONETARY; +pub const LC_MESSAGES_MASK: c_int = 1 << LC_MESSAGES; +pub const LC_ALL_MASK: c_int = LC_CTYPE_MASK + | LC_NUMERIC_MASK + | LC_TIME_MASK + | LC_COLLATE_MASK + | LC_MONETARY_MASK + | LC_MESSAGES_MASK; + +pub const DAY_1: crate::nl_item = 1; +pub const DAY_2: crate::nl_item = 2; +pub const DAY_3: crate::nl_item = 3; +pub const DAY_4: crate::nl_item = 4; +pub const DAY_5: crate::nl_item = 5; +pub const DAY_6: crate::nl_item = 6; +pub const DAY_7: crate::nl_item = 7; + +pub const ABDAY_1: crate::nl_item = 8; +pub const ABDAY_2: crate::nl_item = 9; +pub const ABDAY_3: crate::nl_item = 10; +pub const ABDAY_4: crate::nl_item = 11; +pub const ABDAY_5: crate::nl_item = 12; +pub const ABDAY_6: crate::nl_item = 13; +pub const ABDAY_7: crate::nl_item = 14; + +pub const MON_1: crate::nl_item = 15; +pub const MON_2: crate::nl_item = 16; +pub const MON_3: crate::nl_item = 17; +pub const MON_4: crate::nl_item = 18; +pub const MON_5: crate::nl_item = 19; +pub const MON_6: crate::nl_item = 20; +pub const MON_7: crate::nl_item = 21; +pub const MON_8: crate::nl_item = 22; +pub const MON_9: crate::nl_item = 23; +pub const MON_10: crate::nl_item = 24; +pub const MON_11: crate::nl_item = 25; +pub const MON_12: crate::nl_item = 26; + +pub const ABMON_1: crate::nl_item = 27; +pub const ABMON_2: crate::nl_item = 28; +pub const ABMON_3: crate::nl_item = 29; +pub const ABMON_4: crate::nl_item = 30; +pub const ABMON_5: crate::nl_item = 31; +pub const ABMON_6: crate::nl_item = 32; +pub const ABMON_7: crate::nl_item = 33; +pub const ABMON_8: crate::nl_item = 34; +pub const ABMON_9: crate::nl_item = 35; +pub const ABMON_10: crate::nl_item = 36; +pub const ABMON_11: crate::nl_item = 37; +pub const ABMON_12: crate::nl_item = 38; + +pub const RADIXCHAR: crate::nl_item = 39; +pub const THOUSEP: crate::nl_item = 40; +pub const YESSTR: crate::nl_item = 41; +pub const NOSTR: crate::nl_item = 42; +pub const CRNCYSTR: crate::nl_item = 43; + +pub const D_T_FMT: crate::nl_item = 44; +pub const D_FMT: crate::nl_item = 45; +pub const T_FMT: crate::nl_item = 46; +pub const AM_STR: crate::nl_item = 47; +pub const PM_STR: crate::nl_item = 48; + +pub const CODESET: crate::nl_item = 49; +pub const T_FMT_AMPM: crate::nl_item = 50; +pub const ERA: crate::nl_item = 51; +pub const ERA_D_FMT: crate::nl_item = 52; +pub const ERA_D_T_FMT: crate::nl_item = 53; +pub const ERA_T_FMT: crate::nl_item = 54; +pub const ALT_DIGITS: crate::nl_item = 55; +pub const YESEXPR: crate::nl_item = 56; +pub const NOEXPR: crate::nl_item = 57; +pub const _DATE_FMT: crate::nl_item = 58; +pub const MAXSTRMSG: crate::nl_item = 58; + +pub const PATH_MAX: c_int = 1024; + +pub const SA_ONSTACK: c_int = 0x00000001; +pub const SA_RESETHAND: c_int = 0x00000002; +pub const SA_RESTART: c_int = 0x00000004; +pub const SA_SIGINFO: c_int = 0x00000008; +pub const SA_NODEFER: c_int = 0x00000010; +pub const SA_NOCLDWAIT: c_int = 0x00010000; +pub const SA_NOCLDSTOP: c_int = 0x00020000; + +pub const SS_ONSTACK: c_int = 1; +pub const SS_DISABLE: c_int = 2; + +pub const FIOCLEX: c_int = 0x20006601; +pub const FIONCLEX: c_int = 0x20006602; +pub const FIONREAD: c_int = 0x4004667f; +pub const FIONBIO: c_int = 0x8004667e; +pub const FIOASYNC: c_int = 0x8004667d; +pub const FIOSETOWN: c_int = 0x8004667c; +pub const FIOGETOWN: c_int = 0x4004667b; + +pub const SIGCHLD: c_int = 18; +pub const SIGCLD: c_int = SIGCHLD; +pub const SIGBUS: c_int = 10; +pub const SIG_BLOCK: c_int = 1; +pub const SIG_UNBLOCK: c_int = 2; +pub const SIG_SETMASK: c_int = 3; + +pub const AIO_CANCELED: c_int = 0; +pub const AIO_ALLDONE: c_int = 1; +pub const AIO_NOTCANCELED: c_int = 2; +pub const LIO_NOP: c_int = 0; +pub const LIO_READ: c_int = 1; +pub const LIO_WRITE: c_int = 2; +pub const LIO_NOWAIT: c_int = 0; +pub const LIO_WAIT: c_int = 1; + +pub const SIGEV_NONE: c_int = 1; +pub const SIGEV_SIGNAL: c_int = 2; +pub const SIGEV_THREAD: c_int = 3; +pub const SIGEV_PORT: c_int = 4; + +pub const CLD_EXITED: c_int = 1; +pub const CLD_KILLED: c_int = 2; +pub const CLD_DUMPED: c_int = 3; +pub const CLD_TRAPPED: c_int = 4; +pub const CLD_STOPPED: c_int = 5; +pub const CLD_CONTINUED: c_int = 6; + +pub const IP_RECVDSTADDR: c_int = 0x7; +pub const IP_PKTINFO: c_int = 0x1a; +pub const IP_DONTFRAG: c_int = 0x1b; +pub const IP_SEC_OPT: c_int = 0x22; + +pub const IPV6_UNICAST_HOPS: c_int = 0x5; +pub const IPV6_MULTICAST_IF: c_int = 0x6; +pub const IPV6_MULTICAST_HOPS: c_int = 0x7; +pub const IPV6_MULTICAST_LOOP: c_int = 0x8; +pub const IPV6_PKTINFO: c_int = 0xb; +pub const IPV6_RECVPKTINFO: c_int = 0x12; +pub const IPV6_RECVTCLASS: c_int = 0x19; +pub const IPV6_DONTFRAG: c_int = 0x21; +pub const IPV6_SEC_OPT: c_int = 0x22; +pub const IPV6_TCLASS: c_int = 0x26; +pub const IPV6_V6ONLY: c_int = 0x27; +pub const IPV6_BOUND_IF: c_int = 0x41; + +cfg_if! { + if #[cfg(target_pointer_width = "64")] { + pub const FD_SETSIZE: usize = 65536; + } else { + pub const FD_SETSIZE: usize = 1024; + } +} + +pub const ST_RDONLY: c_ulong = 1; +pub const ST_NOSUID: c_ulong = 2; + +pub const NI_MAXHOST: crate::socklen_t = 1025; +pub const NI_MAXSERV: crate::socklen_t = 32; + +pub const EXIT_FAILURE: c_int = 1; +pub const EXIT_SUCCESS: c_int = 0; +pub const RAND_MAX: c_int = 32767; +pub const EOF: c_int = -1; +pub const SEEK_SET: c_int = 0; +pub const SEEK_CUR: c_int = 1; +pub const SEEK_END: c_int = 2; +pub const SEEK_DATA: c_int = 3; +pub const SEEK_HOLE: c_int = 4; +pub const _IOFBF: c_int = 0; +pub const _IONBF: c_int = 4; +pub const _IOLBF: c_int = 64; +pub const BUFSIZ: c_uint = 1024; +pub const FOPEN_MAX: c_uint = 20; +pub const FILENAME_MAX: c_uint = 1024; +pub const L_tmpnam: c_uint = 25; +pub const TMP_MAX: c_uint = 17576; +pub const PIPE_BUF: c_int = 5120; + +pub const GRND_NONBLOCK: c_uint = 0x0001; +pub const GRND_RANDOM: c_uint = 0x0002; + +pub const O_RDONLY: c_int = 0; +pub const O_WRONLY: c_int = 1; +pub const O_RDWR: c_int = 2; +pub const O_NDELAY: c_int = 0x04; +pub const O_APPEND: c_int = 8; +pub const O_DSYNC: c_int = 0x40; +pub const O_RSYNC: c_int = 0x8000; +pub const O_CREAT: c_int = 256; +pub const O_EXCL: c_int = 1024; +pub const O_NOCTTY: c_int = 2048; +pub const O_TRUNC: c_int = 512; +pub const O_NOFOLLOW: c_int = 0x20000; +pub const O_SEARCH: c_int = 0x200000; +pub const O_EXEC: c_int = 0x400000; +pub const O_CLOEXEC: c_int = 0x800000; +pub const O_ACCMODE: c_int = 0x600003; +pub const O_XATTR: c_int = 0x4000; +pub const O_DIRECTORY: c_int = 0x1000000; +pub const S_IFIFO: mode_t = 0o1_0000; +pub const S_IFCHR: mode_t = 0o2_0000; +pub const S_IFBLK: mode_t = 0o6_0000; +pub const S_IFDIR: mode_t = 0o4_0000; +pub const S_IFREG: mode_t = 0o10_0000; +pub const S_IFLNK: mode_t = 0o12_0000; +pub const S_IFSOCK: mode_t = 0o14_0000; +pub const S_IFMT: mode_t = 0o17_0000; +pub const S_IEXEC: mode_t = 0o0100; +pub const S_IWRITE: mode_t = 0o0200; +pub const S_IREAD: mode_t = 0o0400; +pub const S_IRWXU: mode_t = 0o0700; +pub const S_IXUSR: mode_t = 0o0100; +pub const S_IWUSR: mode_t = 0o0200; +pub const S_IRUSR: mode_t = 0o0400; +pub const S_IRWXG: mode_t = 0o0070; +pub const S_IXGRP: mode_t = 0o0010; +pub const S_IWGRP: mode_t = 0o0020; +pub const S_IRGRP: mode_t = 0o0040; +pub const S_IRWXO: mode_t = 0o0007; +pub const S_IXOTH: mode_t = 0o0001; +pub const S_IWOTH: mode_t = 0o0002; +pub const S_IROTH: mode_t = 0o0004; +pub const F_OK: c_int = 0; +pub const R_OK: c_int = 4; +pub const W_OK: c_int = 2; +pub const X_OK: c_int = 1; +pub const F_LOCK: c_int = 1; +pub const F_TEST: c_int = 3; +pub const F_TLOCK: c_int = 2; +pub const F_ULOCK: c_int = 0; +pub const F_SETLK: c_int = 6; +pub const F_SETLKW: c_int = 7; +pub const F_GETLK: c_int = 14; +pub const F_ALLOCSP: c_int = 10; +pub const F_FREESP: c_int = 11; +pub const F_BLOCKS: c_int = 18; +pub const F_BLKSIZE: c_int = 19; +pub const F_SHARE: c_int = 40; +pub const F_UNSHARE: c_int = 41; +pub const F_ISSTREAM: c_int = 13; +pub const F_PRIV: c_int = 15; +pub const F_NPRIV: c_int = 16; +pub const F_QUOTACTL: c_int = 17; +pub const F_GETOWN: c_int = 23; +pub const F_SETOWN: c_int = 24; +pub const F_REVOKE: c_int = 25; +pub const F_HASREMOTELOCKS: c_int = 26; +pub const SIGHUP: c_int = 1; +pub const SIGINT: c_int = 2; +pub const SIGQUIT: c_int = 3; +pub const SIGILL: c_int = 4; +pub const SIGABRT: c_int = 6; +pub const SIGEMT: c_int = 7; +pub const SIGFPE: c_int = 8; +pub const SIGKILL: c_int = 9; +pub const SIGSEGV: c_int = 11; +pub const SIGSYS: c_int = 12; +pub const SIGPIPE: c_int = 13; +pub const SIGALRM: c_int = 14; +pub const SIGTERM: c_int = 15; +pub const SIGUSR1: c_int = 16; +pub const SIGUSR2: c_int = 17; +pub const SIGPWR: c_int = 19; +pub const SIGWINCH: c_int = 20; +pub const SIGURG: c_int = 21; +pub const SIGPOLL: c_int = 22; +pub const SIGIO: c_int = SIGPOLL; +pub const SIGSTOP: c_int = 23; +pub const SIGTSTP: c_int = 24; +pub const SIGCONT: c_int = 25; +pub const SIGTTIN: c_int = 26; +pub const SIGTTOU: c_int = 27; +pub const SIGVTALRM: c_int = 28; +pub const SIGPROF: c_int = 29; +pub const SIGXCPU: c_int = 30; +pub const SIGXFSZ: c_int = 31; + +pub const WNOHANG: c_int = 0x40; +pub const WUNTRACED: c_int = 0x04; + +pub const WEXITED: c_int = 0x01; +pub const WTRAPPED: c_int = 0x02; +pub const WSTOPPED: c_int = WUNTRACED; +pub const WCONTINUED: c_int = 0x08; +pub const WNOWAIT: c_int = 0x80; + +pub const AT_FDCWD: c_int = 0xffd19553; +pub const AT_SYMLINK_NOFOLLOW: c_int = 0x1000; +pub const AT_SYMLINK_FOLLOW: c_int = 0x2000; +pub const AT_REMOVEDIR: c_int = 0x1; +pub const _AT_TRIGGER: c_int = 0x2; +pub const AT_EACCESS: c_int = 0x4; + +pub const P_PID: idtype_t = 0; +pub const P_PPID: idtype_t = 1; +pub const P_PGID: idtype_t = 2; +pub const P_SID: idtype_t = 3; +pub const P_CID: idtype_t = 4; +pub const P_UID: idtype_t = 5; +pub const P_GID: idtype_t = 6; +pub const P_ALL: idtype_t = 7; +pub const P_LWPID: idtype_t = 8; +pub const P_TASKID: idtype_t = 9; +pub const P_PROJID: idtype_t = 10; +pub const P_POOLID: idtype_t = 11; +pub const P_ZONEID: idtype_t = 12; +pub const P_CTID: idtype_t = 13; +pub const P_CPUID: idtype_t = 14; +pub const P_PSETID: idtype_t = 15; + +pub const PBIND_NONE: crate::processorid_t = -1; +pub const PBIND_QUERY: crate::processorid_t = -2; + +pub const PS_NONE: c_int = -1; +pub const PS_QUERY: c_int = -2; +pub const PS_MYID: c_int = -3; +pub const PS_SOFT: c_int = -4; +pub const PS_HARD: c_int = -5; +pub const PS_QUERY_TYPE: c_int = -6; +pub const PS_PRIVATE: c_int = 2; + +pub const UTIME_OMIT: c_long = -2; +pub const UTIME_NOW: c_long = -1; + +pub const PROT_NONE: c_int = 0; +pub const PROT_READ: c_int = 1; +pub const PROT_WRITE: c_int = 2; +pub const PROT_EXEC: c_int = 4; + +pub const MAP_SHARED: c_int = 0x0001; +pub const MAP_PRIVATE: c_int = 0x0002; +pub const MAP_FIXED: c_int = 0x0010; +pub const MAP_NORESERVE: c_int = 0x40; +pub const MAP_ANON: c_int = 0x0100; +pub const MAP_ANONYMOUS: c_int = 0x0100; +pub const MAP_RENAME: c_int = 0x20; +pub const MAP_ALIGN: c_int = 0x200; +pub const MAP_TEXT: c_int = 0x400; +pub const MAP_INITDATA: c_int = 0x800; +pub const MAP_FAILED: *mut c_void = !0 as *mut c_void; + +pub const MCL_CURRENT: c_int = 0x0001; +pub const MCL_FUTURE: c_int = 0x0002; + +pub const MS_SYNC: c_int = 0x0004; +pub const MS_ASYNC: c_int = 0x0001; +pub const MS_INVALIDATE: c_int = 0x0002; + +pub const MMOBJ_PADDING: c_uint = 0x10000; +pub const MMOBJ_INTERPRET: c_uint = 0x20000; +pub const MR_PADDING: c_uint = 0x1; +pub const MR_HDR_ELF: c_uint = 0x2; + +pub const EPERM: c_int = 1; +pub const ENOENT: c_int = 2; +pub const ESRCH: c_int = 3; +pub const EINTR: c_int = 4; +pub const EIO: c_int = 5; +pub const ENXIO: c_int = 6; +pub const E2BIG: c_int = 7; +pub const ENOEXEC: c_int = 8; +pub const EBADF: c_int = 9; +pub const ECHILD: c_int = 10; +pub const EAGAIN: c_int = 11; +pub const ENOMEM: c_int = 12; +pub const EACCES: c_int = 13; +pub const EFAULT: c_int = 14; +pub const ENOTBLK: c_int = 15; +pub const EBUSY: c_int = 16; +pub const EEXIST: c_int = 17; +pub const EXDEV: c_int = 18; +pub const ENODEV: c_int = 19; +pub const ENOTDIR: c_int = 20; +pub const EISDIR: c_int = 21; +pub const EINVAL: c_int = 22; +pub const ENFILE: c_int = 23; +pub const EMFILE: c_int = 24; +pub const ENOTTY: c_int = 25; +pub const ETXTBSY: c_int = 26; +pub const EFBIG: c_int = 27; +pub const ENOSPC: c_int = 28; +pub const ESPIPE: c_int = 29; +pub const EROFS: c_int = 30; +pub const EMLINK: c_int = 31; +pub const EPIPE: c_int = 32; +pub const EDOM: c_int = 33; +pub const ERANGE: c_int = 34; +pub const ENOMSG: c_int = 35; +pub const EIDRM: c_int = 36; +pub const ECHRNG: c_int = 37; +pub const EL2NSYNC: c_int = 38; +pub const EL3HLT: c_int = 39; +pub const EL3RST: c_int = 40; +pub const ELNRNG: c_int = 41; +pub const EUNATCH: c_int = 42; +pub const ENOCSI: c_int = 43; +pub const EL2HLT: c_int = 44; +pub const EDEADLK: c_int = 45; +pub const ENOLCK: c_int = 46; +pub const ECANCELED: c_int = 47; +pub const ENOTSUP: c_int = 48; +pub const EDQUOT: c_int = 49; +pub const EBADE: c_int = 50; +pub const EBADR: c_int = 51; +pub const EXFULL: c_int = 52; +pub const ENOANO: c_int = 53; +pub const EBADRQC: c_int = 54; +pub const EBADSLT: c_int = 55; +pub const EDEADLOCK: c_int = 56; +pub const EBFONT: c_int = 57; +pub const EOWNERDEAD: c_int = 58; +pub const ENOTRECOVERABLE: c_int = 59; +pub const ENOSTR: c_int = 60; +pub const ENODATA: c_int = 61; +pub const ETIME: c_int = 62; +pub const ENOSR: c_int = 63; +pub const ENONET: c_int = 64; +pub const ENOPKG: c_int = 65; +pub const EREMOTE: c_int = 66; +pub const ENOLINK: c_int = 67; +pub const EADV: c_int = 68; +pub const ESRMNT: c_int = 69; +pub const ECOMM: c_int = 70; +pub const EPROTO: c_int = 71; +pub const ELOCKUNMAPPED: c_int = 72; +pub const ENOTACTIVE: c_int = 73; +pub const EMULTIHOP: c_int = 74; +pub const EADI: c_int = 75; +pub const EBADMSG: c_int = 77; +pub const ENAMETOOLONG: c_int = 78; +pub const EOVERFLOW: c_int = 79; +pub const ENOTUNIQ: c_int = 80; +pub const EBADFD: c_int = 81; +pub const EREMCHG: c_int = 82; +pub const ELIBACC: c_int = 83; +pub const ELIBBAD: c_int = 84; +pub const ELIBSCN: c_int = 85; +pub const ELIBMAX: c_int = 86; +pub const ELIBEXEC: c_int = 87; +pub const EILSEQ: c_int = 88; +pub const ENOSYS: c_int = 89; +pub const ELOOP: c_int = 90; +pub const ERESTART: c_int = 91; +pub const ESTRPIPE: c_int = 92; +pub const ENOTEMPTY: c_int = 93; +pub const EUSERS: c_int = 94; +pub const ENOTSOCK: c_int = 95; +pub const EDESTADDRREQ: c_int = 96; +pub const EMSGSIZE: c_int = 97; +pub const EPROTOTYPE: c_int = 98; +pub const ENOPROTOOPT: c_int = 99; +pub const EPROTONOSUPPORT: c_int = 120; +pub const ESOCKTNOSUPPORT: c_int = 121; +pub const EOPNOTSUPP: c_int = 122; +pub const EPFNOSUPPORT: c_int = 123; +pub const EAFNOSUPPORT: c_int = 124; +pub const EADDRINUSE: c_int = 125; +pub const EADDRNOTAVAIL: c_int = 126; +pub const ENETDOWN: c_int = 127; +pub const ENETUNREACH: c_int = 128; +pub const ENETRESET: c_int = 129; +pub const ECONNABORTED: c_int = 130; +pub const ECONNRESET: c_int = 131; +pub const ENOBUFS: c_int = 132; +pub const EISCONN: c_int = 133; +pub const ENOTCONN: c_int = 134; +pub const ESHUTDOWN: c_int = 143; +pub const ETOOMANYREFS: c_int = 144; +pub const ETIMEDOUT: c_int = 145; +pub const ECONNREFUSED: c_int = 146; +pub const EHOSTDOWN: c_int = 147; +pub const EHOSTUNREACH: c_int = 148; +pub const EWOULDBLOCK: c_int = EAGAIN; +pub const EALREADY: c_int = 149; +pub const EINPROGRESS: c_int = 150; +pub const ESTALE: c_int = 151; + +pub const EAI_AGAIN: c_int = 2; +pub const EAI_BADFLAGS: c_int = 3; +pub const EAI_FAIL: c_int = 4; +pub const EAI_FAMILY: c_int = 5; +pub const EAI_MEMORY: c_int = 6; +pub const EAI_NODATA: c_int = 7; +pub const EAI_NONAME: c_int = 8; +pub const EAI_SERVICE: c_int = 9; +pub const EAI_SOCKTYPE: c_int = 10; +pub const EAI_SYSTEM: c_int = 11; +pub const EAI_OVERFLOW: c_int = 12; + +pub const NI_NOFQDN: c_uint = 0x0001; +pub const NI_NUMERICHOST: c_uint = 0x0002; +pub const NI_NAMEREQD: c_uint = 0x0004; +pub const NI_NUMERICSERV: c_uint = 0x0008; +pub const NI_DGRAM: c_uint = 0x0010; +pub const NI_WITHSCOPEID: c_uint = 0x0020; +pub const NI_NUMERICSCOPE: c_uint = 0x0040; + +pub const F_DUPFD: c_int = 0; +pub const F_DUP2FD: c_int = 9; +pub const F_GETFD: c_int = 1; +pub const F_SETFD: c_int = 2; +pub const F_GETFL: c_int = 3; +pub const F_SETFL: c_int = 4; +pub const F_GETXFL: c_int = 45; + +pub const SIGTRAP: c_int = 5; + +pub const GLOB_APPEND: c_int = 32; +pub const GLOB_DOOFFS: c_int = 16; +pub const GLOB_ERR: c_int = 1; +pub const GLOB_MARK: c_int = 2; +pub const GLOB_NOCHECK: c_int = 8; +pub const GLOB_NOSORT: c_int = 4; +pub const GLOB_NOESCAPE: c_int = 64; + +pub const GLOB_NOSPACE: c_int = -2; +pub const GLOB_ABORTED: c_int = -1; +pub const GLOB_NOMATCH: c_int = -3; + +pub const POLLIN: c_short = 0x1; +pub const POLLPRI: c_short = 0x2; +pub const POLLOUT: c_short = 0x4; +pub const POLLERR: c_short = 0x8; +pub const POLLHUP: c_short = 0x10; +pub const POLLNVAL: c_short = 0x20; +pub const POLLNORM: c_short = 0x0040; +pub const POLLRDNORM: c_short = 0x0040; +pub const POLLWRNORM: c_short = 0x4; /* POLLOUT */ +pub const POLLRDBAND: c_short = 0x0080; +pub const POLLWRBAND: c_short = 0x0100; + +pub const POSIX_MADV_NORMAL: c_int = 0; +pub const POSIX_MADV_RANDOM: c_int = 1; +pub const POSIX_MADV_SEQUENTIAL: c_int = 2; +pub const POSIX_MADV_WILLNEED: c_int = 3; +pub const POSIX_MADV_DONTNEED: c_int = 4; + +pub const POSIX_SPAWN_RESETIDS: c_short = 0x1; +pub const POSIX_SPAWN_SETPGROUP: c_short = 0x2; +pub const POSIX_SPAWN_SETSIGDEF: c_short = 0x4; +pub const POSIX_SPAWN_SETSIGMASK: c_short = 0x8; +pub const POSIX_SPAWN_SETSCHEDPARAM: c_short = 0x10; +pub const POSIX_SPAWN_SETSCHEDULER: c_short = 0x20; +pub const POSIX_SPAWN_SETSIGIGN_NP: c_short = 0x800; +pub const POSIX_SPAWN_NOSIGCHLD_NP: c_short = 0x1000; +pub const POSIX_SPAWN_WAITPID_NP: c_short = 0x2000; +pub const POSIX_SPAWN_NOEXECERR_NP: c_short = 0x4000; + +pub const PTHREAD_CREATE_JOINABLE: c_int = 0; +pub const PTHREAD_CREATE_DETACHED: c_int = 0x40; +pub const PTHREAD_PROCESS_SHARED: c_int = 1; +pub const PTHREAD_PROCESS_PRIVATE: c_ushort = 0; +pub const PTHREAD_STACK_MIN: size_t = 4096; + +pub const SIGSTKSZ: size_t = 8192; + +// https://illumos.org/man/3c/clock_gettime +// https://github.com/illumos/illumos-gate/ +// blob/HEAD/usr/src/lib/libc/amd64/sys/__clock_gettime.s +// clock_gettime(3c) doesn't seem to accept anything other than CLOCK_REALTIME +// or __CLOCK_REALTIME0 +// +// https://github.com/illumos/illumos-gate/ +// blob/HEAD/usr/src/uts/common/sys/time_impl.h +// Confusing! CLOCK_HIGHRES==CLOCK_MONOTONIC==4 +// __CLOCK_REALTIME0==0 is an obsoleted version of CLOCK_REALTIME==3 +pub const CLOCK_REALTIME: crate::clockid_t = 3; +pub const CLOCK_MONOTONIC: crate::clockid_t = 4; +pub const TIMER_RELTIME: c_int = 0; +pub const TIMER_ABSTIME: c_int = 1; + +pub const RLIMIT_CPU: c_int = 0; +pub const RLIMIT_FSIZE: c_int = 1; +pub const RLIMIT_DATA: c_int = 2; +pub const RLIMIT_STACK: c_int = 3; +pub const RLIMIT_CORE: c_int = 4; +pub const RLIMIT_NOFILE: c_int = 5; +pub const RLIMIT_VMEM: c_int = 6; +pub const RLIMIT_AS: c_int = RLIMIT_VMEM; + +#[deprecated(since = "0.2.64", note = "Not stable across OS versions")] +pub const RLIM_NLIMITS: rlim_t = 7; +pub const RLIM_INFINITY: rlim_t = 0xfffffffffffffffd; + +pub const RUSAGE_SELF: c_int = 0; +pub const RUSAGE_CHILDREN: c_int = -1; + +pub const MADV_NORMAL: c_int = 0; +pub const MADV_RANDOM: c_int = 1; +pub const MADV_SEQUENTIAL: c_int = 2; +pub const MADV_WILLNEED: c_int = 3; +pub const MADV_DONTNEED: c_int = 4; +pub const MADV_FREE: c_int = 5; +pub const MADV_ACCESS_DEFAULT: c_int = 6; +pub const MADV_ACCESS_LWP: c_int = 7; +pub const MADV_ACCESS_MANY: c_int = 8; + +pub const AF_UNSPEC: c_int = 0; +pub const AF_UNIX: c_int = 1; +pub const AF_INET: c_int = 2; +pub const AF_IMPLINK: c_int = 3; +pub const AF_PUP: c_int = 4; +pub const AF_CHAOS: c_int = 5; +pub const AF_NS: c_int = 6; +pub const AF_NBS: c_int = 7; +pub const AF_ECMA: c_int = 8; +pub const AF_DATAKIT: c_int = 9; +pub const AF_CCITT: c_int = 10; +pub const AF_SNA: c_int = 11; +pub const AF_DECnet: c_int = 12; +pub const AF_DLI: c_int = 13; +pub const AF_LAT: c_int = 14; +pub const AF_HYLINK: c_int = 15; +pub const AF_APPLETALK: c_int = 16; +pub const AF_NIT: c_int = 17; +pub const AF_802: c_int = 18; +pub const AF_OSI: c_int = 19; +pub const AF_X25: c_int = 20; +pub const AF_OSINET: c_int = 21; +pub const AF_GOSIP: c_int = 22; +pub const AF_IPX: c_int = 23; +pub const AF_ROUTE: c_int = 24; +pub const AF_LINK: c_int = 25; +pub const AF_INET6: c_int = 26; +pub const AF_KEY: c_int = 27; +pub const AF_POLICY: c_int = 29; +pub const AF_INET_OFFLOAD: c_int = 30; +pub const AF_TRILL: c_int = 31; +pub const AF_PACKET: c_int = 32; + +pub const PF_UNSPEC: c_int = AF_UNSPEC; +pub const PF_UNIX: c_int = AF_UNIX; +pub const PF_LOCAL: c_int = PF_UNIX; +pub const PF_FILE: c_int = PF_UNIX; +pub const PF_INET: c_int = AF_INET; +pub const PF_IMPLINK: c_int = AF_IMPLINK; +pub const PF_PUP: c_int = AF_PUP; +pub const PF_CHAOS: c_int = AF_CHAOS; +pub const PF_NS: c_int = AF_NS; +pub const PF_NBS: c_int = AF_NBS; +pub const PF_ECMA: c_int = AF_ECMA; +pub const PF_DATAKIT: c_int = AF_DATAKIT; +pub const PF_CCITT: c_int = AF_CCITT; +pub const PF_SNA: c_int = AF_SNA; +pub const PF_DECnet: c_int = AF_DECnet; +pub const PF_DLI: c_int = AF_DLI; +pub const PF_LAT: c_int = AF_LAT; +pub const PF_HYLINK: c_int = AF_HYLINK; +pub const PF_APPLETALK: c_int = AF_APPLETALK; +pub const PF_NIT: c_int = AF_NIT; +pub const PF_802: c_int = AF_802; +pub const PF_OSI: c_int = AF_OSI; +pub const PF_X25: c_int = AF_X25; +pub const PF_OSINET: c_int = AF_OSINET; +pub const PF_GOSIP: c_int = AF_GOSIP; +pub const PF_IPX: c_int = AF_IPX; +pub const PF_ROUTE: c_int = AF_ROUTE; +pub const PF_LINK: c_int = AF_LINK; +pub const PF_INET6: c_int = AF_INET6; +pub const PF_KEY: c_int = AF_KEY; +pub const PF_POLICY: c_int = AF_POLICY; +pub const PF_INET_OFFLOAD: c_int = AF_INET_OFFLOAD; +pub const PF_TRILL: c_int = AF_TRILL; +pub const PF_PACKET: c_int = AF_PACKET; + +pub const SOCK_DGRAM: c_int = 1; +pub const SOCK_STREAM: c_int = 2; +pub const SOCK_RAW: c_int = 4; +pub const SOCK_RDM: c_int = 5; +pub const SOCK_SEQPACKET: c_int = 6; +pub const IP_MULTICAST_IF: c_int = 16; +pub const IP_MULTICAST_TTL: c_int = 17; +pub const IP_MULTICAST_LOOP: c_int = 18; +pub const IP_HDRINCL: c_int = 2; +pub const IP_TOS: c_int = 3; +pub const IP_TTL: c_int = 4; +pub const IP_ADD_MEMBERSHIP: c_int = 19; +pub const IP_DROP_MEMBERSHIP: c_int = 20; +pub const IPV6_JOIN_GROUP: c_int = 9; +pub const IPV6_LEAVE_GROUP: c_int = 10; +pub const IP_ADD_SOURCE_MEMBERSHIP: c_int = 23; +pub const IP_DROP_SOURCE_MEMBERSHIP: c_int = 24; +pub const IP_BLOCK_SOURCE: c_int = 21; +pub const IP_UNBLOCK_SOURCE: c_int = 22; +pub const IP_BOUND_IF: c_int = 0x41; + +// These TCP socket options are common between illumos and Solaris, while higher +// numbers have generally diverged: +pub const TCP_NODELAY: c_int = 0x1; +pub const TCP_MAXSEG: c_int = 0x2; +pub const TCP_KEEPALIVE: c_int = 0x8; +pub const TCP_NOTIFY_THRESHOLD: c_int = 0x10; +pub const TCP_ABORT_THRESHOLD: c_int = 0x11; +pub const TCP_CONN_NOTIFY_THRESHOLD: c_int = 0x12; +pub const TCP_CONN_ABORT_THRESHOLD: c_int = 0x13; +pub const TCP_RECVDSTADDR: c_int = 0x14; +pub const TCP_INIT_CWND: c_int = 0x15; +pub const TCP_KEEPALIVE_THRESHOLD: c_int = 0x16; +pub const TCP_KEEPALIVE_ABORT_THRESHOLD: c_int = 0x17; +pub const TCP_CORK: c_int = 0x18; +pub const TCP_RTO_INITIAL: c_int = 0x19; +pub const TCP_RTO_MIN: c_int = 0x1a; +pub const TCP_RTO_MAX: c_int = 0x1b; +pub const TCP_LINGER2: c_int = 0x1c; + +pub const UDP_NAT_T_ENDPOINT: c_int = 0x0103; + +pub const SOMAXCONN: c_int = 128; + +pub const SOL_SOCKET: c_int = 0xffff; +pub const SO_DEBUG: c_int = 0x01; +pub const SO_ACCEPTCONN: c_int = 0x0002; +pub const SO_REUSEADDR: c_int = 0x0004; +pub const SO_KEEPALIVE: c_int = 0x0008; +pub const SO_DONTROUTE: c_int = 0x0010; +pub const SO_BROADCAST: c_int = 0x0020; +pub const SO_USELOOPBACK: c_int = 0x0040; +pub const SO_LINGER: c_int = 0x0080; +pub const SO_OOBINLINE: c_int = 0x0100; +pub const SO_SNDBUF: c_int = 0x1001; +pub const SO_RCVBUF: c_int = 0x1002; +pub const SO_SNDLOWAT: c_int = 0x1003; +pub const SO_RCVLOWAT: c_int = 0x1004; +pub const SO_SNDTIMEO: c_int = 0x1005; +pub const SO_RCVTIMEO: c_int = 0x1006; +pub const SO_ERROR: c_int = 0x1007; +pub const SO_TYPE: c_int = 0x1008; +pub const SO_PROTOTYPE: c_int = 0x1009; +pub const SO_DOMAIN: c_int = 0x100c; +pub const SO_TIMESTAMP: c_int = 0x1013; +pub const SO_EXCLBIND: c_int = 0x1015; + +pub const SCM_RIGHTS: c_int = 0x1010; +pub const SCM_UCRED: c_int = 0x1012; +pub const SCM_TIMESTAMP: c_int = SO_TIMESTAMP; + +pub const MSG_OOB: c_int = 0x1; +pub const MSG_PEEK: c_int = 0x2; +pub const MSG_DONTROUTE: c_int = 0x4; +pub const MSG_EOR: c_int = 0x8; +pub const MSG_CTRUNC: c_int = 0x10; +pub const MSG_TRUNC: c_int = 0x20; +pub const MSG_WAITALL: c_int = 0x40; +pub const MSG_DONTWAIT: c_int = 0x80; +pub const MSG_NOTIFICATION: c_int = 0x100; +pub const MSG_NOSIGNAL: c_int = 0x200; +pub const MSG_DUPCTRL: c_int = 0x800; +pub const MSG_XPG4_2: c_int = 0x8000; +pub const MSG_MAXIOVLEN: c_int = 16; + +pub const IF_NAMESIZE: size_t = 32; +pub const IFNAMSIZ: size_t = 16; + +// https://docs.oracle.com/cd/E23824_01/html/821-1475/if-7p.html +pub const IFF_UP: c_int = 0x0000000001; // Address is up +pub const IFF_BROADCAST: c_int = 0x0000000002; // Broadcast address valid +pub const IFF_DEBUG: c_int = 0x0000000004; // Turn on debugging +pub const IFF_LOOPBACK: c_int = 0x0000000008; // Loopback net +pub const IFF_POINTOPOINT: c_int = 0x0000000010; // Interface is p-to-p +pub const IFF_NOTRAILERS: c_int = 0x0000000020; // Avoid use of trailers +pub const IFF_RUNNING: c_int = 0x0000000040; // Resources allocated +pub const IFF_NOARP: c_int = 0x0000000080; // No address res. protocol +pub const IFF_PROMISC: c_int = 0x0000000100; // Receive all packets +pub const IFF_ALLMULTI: c_int = 0x0000000200; // Receive all multicast pkts +pub const IFF_INTELLIGENT: c_int = 0x0000000400; // Protocol code on board +pub const IFF_MULTICAST: c_int = 0x0000000800; // Supports multicast + +// Multicast using broadcst. add. +pub const IFF_MULTI_BCAST: c_int = 0x0000001000; +pub const IFF_UNNUMBERED: c_int = 0x0000002000; // Non-unique address +pub const IFF_DHCPRUNNING: c_int = 0x0000004000; // DHCP controls interface +pub const IFF_PRIVATE: c_int = 0x0000008000; // Do not advertise +pub const IFF_NOXMIT: c_int = 0x0000010000; // Do not transmit pkts + +// No address - just on-link subnet +pub const IFF_NOLOCAL: c_int = 0x0000020000; +pub const IFF_DEPRECATED: c_int = 0x0000040000; // Address is deprecated +pub const IFF_ADDRCONF: c_int = 0x0000080000; // Addr. from stateless addrconf +pub const IFF_ROUTER: c_int = 0x0000100000; // Router on interface +pub const IFF_NONUD: c_int = 0x0000200000; // No NUD on interface +pub const IFF_ANYCAST: c_int = 0x0000400000; // Anycast address +pub const IFF_NORTEXCH: c_int = 0x0000800000; // Don't xchange rout. info +pub const IFF_IPV4: c_int = 0x0001000000; // IPv4 interface +pub const IFF_IPV6: c_int = 0x0002000000; // IPv6 interface +pub const IFF_NOFAILOVER: c_int = 0x0008000000; // in.mpathd test address +pub const IFF_FAILED: c_int = 0x0010000000; // Interface has failed +pub const IFF_STANDBY: c_int = 0x0020000000; // Interface is a hot-spare +pub const IFF_INACTIVE: c_int = 0x0040000000; // Functioning but not used +pub const IFF_OFFLINE: c_int = 0x0080000000; // Interface is offline + // If CoS marking is supported +pub const IFF_COS_ENABLED: c_longlong = 0x0200000000; +pub const IFF_PREFERRED: c_longlong = 0x0400000000; // Prefer as source addr. +pub const IFF_TEMPORARY: c_longlong = 0x0800000000; // RFC3041 +pub const IFF_FIXEDMTU: c_longlong = 0x1000000000; // MTU set with SIOCSLIFMTU +pub const IFF_VIRTUAL: c_longlong = 0x2000000000; // Cannot send/receive pkts +pub const IFF_DUPLICATE: c_longlong = 0x4000000000; // Local address in use +pub const IFF_IPMP: c_longlong = 0x8000000000; // IPMP IP interface + +// sys/ipc.h: +pub const IPC_ALLOC: c_int = 0x8000; +pub const IPC_CREAT: c_int = 0x200; +pub const IPC_EXCL: c_int = 0x400; +pub const IPC_NOWAIT: c_int = 0x800; +pub const IPC_PRIVATE: key_t = 0; +pub const IPC_RMID: c_int = 10; +pub const IPC_SET: c_int = 11; +pub const IPC_SEAT: c_int = 12; + +// sys/shm.h +pub const SHM_R: c_int = 0o400; +pub const SHM_W: c_int = 0o200; +pub const SHM_RDONLY: c_int = 0o10000; +pub const SHM_RND: c_int = 0o20000; +pub const SHM_SHARE_MMU: c_int = 0o40000; +pub const SHM_PAGEABLE: c_int = 0o100000; + +pub const SHUT_RD: c_int = 0; +pub const SHUT_WR: c_int = 1; +pub const SHUT_RDWR: c_int = 2; + +pub const F_RDLCK: c_short = 1; +pub const F_WRLCK: c_short = 2; +pub const F_UNLCK: c_short = 3; + +pub const O_SYNC: c_int = 16; +pub const O_NONBLOCK: c_int = 128; + +pub const IPPROTO_RAW: c_int = 255; + +pub const _PC_LINK_MAX: c_int = 1; +pub const _PC_MAX_CANON: c_int = 2; +pub const _PC_MAX_INPUT: c_int = 3; +pub const _PC_NAME_MAX: c_int = 4; +pub const _PC_PATH_MAX: c_int = 5; +pub const _PC_PIPE_BUF: c_int = 6; +pub const _PC_NO_TRUNC: c_int = 7; +pub const _PC_VDISABLE: c_int = 8; +pub const _PC_CHOWN_RESTRICTED: c_int = 9; +pub const _PC_ASYNC_IO: c_int = 10; +pub const _PC_PRIO_IO: c_int = 11; +pub const _PC_SYNC_IO: c_int = 12; +pub const _PC_ALLOC_SIZE_MIN: c_int = 13; +pub const _PC_REC_INCR_XFER_SIZE: c_int = 14; +pub const _PC_REC_MAX_XFER_SIZE: c_int = 15; +pub const _PC_REC_MIN_XFER_SIZE: c_int = 16; +pub const _PC_REC_XFER_ALIGN: c_int = 17; +pub const _PC_SYMLINK_MAX: c_int = 18; +pub const _PC_2_SYMLINKS: c_int = 19; +pub const _PC_ACL_ENABLED: c_int = 20; +pub const _PC_MIN_HOLE_SIZE: c_int = 21; +pub const _PC_CASE_BEHAVIOR: c_int = 22; +pub const _PC_SATTR_ENABLED: c_int = 23; +pub const _PC_SATTR_EXISTS: c_int = 24; +pub const _PC_ACCESS_FILTERING: c_int = 25; +pub const _PC_TIMESTAMP_RESOLUTION: c_int = 26; +pub const _PC_FILESIZEBITS: c_int = 67; +pub const _PC_XATTR_ENABLED: c_int = 100; +pub const _PC_XATTR_EXISTS: c_int = 101; + +pub const _POSIX_VDISABLE: crate::cc_t = 0; + +pub const _SC_ARG_MAX: c_int = 1; +pub const _SC_CHILD_MAX: c_int = 2; +pub const _SC_CLK_TCK: c_int = 3; +pub const _SC_NGROUPS_MAX: c_int = 4; +pub const _SC_OPEN_MAX: c_int = 5; +pub const _SC_JOB_CONTROL: c_int = 6; +pub const _SC_SAVED_IDS: c_int = 7; +pub const _SC_VERSION: c_int = 8; +pub const _SC_PASS_MAX: c_int = 9; +pub const _SC_LOGNAME_MAX: c_int = 10; +pub const _SC_PAGESIZE: c_int = 11; +pub const _SC_PAGE_SIZE: c_int = _SC_PAGESIZE; +pub const _SC_XOPEN_VERSION: c_int = 12; +pub const _SC_NPROCESSORS_CONF: c_int = 14; +pub const _SC_NPROCESSORS_ONLN: c_int = 15; +pub const _SC_STREAM_MAX: c_int = 16; +pub const _SC_TZNAME_MAX: c_int = 17; +pub const _SC_AIO_LISTIO_MAX: c_int = 18; +pub const _SC_AIO_MAX: c_int = 19; +pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 20; +pub const _SC_ASYNCHRONOUS_IO: c_int = 21; +pub const _SC_DELAYTIMER_MAX: c_int = 22; +pub const _SC_FSYNC: c_int = 23; +pub const _SC_MAPPED_FILES: c_int = 24; +pub const _SC_MEMLOCK: c_int = 25; +pub const _SC_MEMLOCK_RANGE: c_int = 26; +pub const _SC_MEMORY_PROTECTION: c_int = 27; +pub const _SC_MESSAGE_PASSING: c_int = 28; +pub const _SC_MQ_OPEN_MAX: c_int = 29; +pub const _SC_MQ_PRIO_MAX: c_int = 30; +pub const _SC_PRIORITIZED_IO: c_int = 31; +pub const _SC_PRIORITY_SCHEDULING: c_int = 32; +pub const _SC_REALTIME_SIGNALS: c_int = 33; +pub const _SC_RTSIG_MAX: c_int = 34; +pub const _SC_SEMAPHORES: c_int = 35; +pub const _SC_SEM_NSEMS_MAX: c_int = 36; +pub const _SC_SEM_VALUE_MAX: c_int = 37; +pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 38; +pub const _SC_SIGQUEUE_MAX: c_int = 39; +pub const _SC_SIGRT_MIN: c_int = 40; +pub const _SC_SIGRT_MAX: c_int = 41; +pub const _SC_SYNCHRONIZED_IO: c_int = 42; +pub const _SC_TIMERS: c_int = 43; +pub const _SC_TIMER_MAX: c_int = 44; +pub const _SC_2_C_BIND: c_int = 45; +pub const _SC_2_C_DEV: c_int = 46; +pub const _SC_2_C_VERSION: c_int = 47; +pub const _SC_2_FORT_DEV: c_int = 48; +pub const _SC_2_FORT_RUN: c_int = 49; +pub const _SC_2_LOCALEDEF: c_int = 50; +pub const _SC_2_SW_DEV: c_int = 51; +pub const _SC_2_UPE: c_int = 52; +pub const _SC_2_VERSION: c_int = 53; +pub const _SC_BC_BASE_MAX: c_int = 54; +pub const _SC_BC_DIM_MAX: c_int = 55; +pub const _SC_BC_SCALE_MAX: c_int = 56; +pub const _SC_BC_STRING_MAX: c_int = 57; +pub const _SC_COLL_WEIGHTS_MAX: c_int = 58; +pub const _SC_EXPR_NEST_MAX: c_int = 59; +pub const _SC_LINE_MAX: c_int = 60; +pub const _SC_RE_DUP_MAX: c_int = 61; +pub const _SC_XOPEN_CRYPT: c_int = 62; +pub const _SC_XOPEN_ENH_I18N: c_int = 63; +pub const _SC_XOPEN_SHM: c_int = 64; +pub const _SC_2_CHAR_TERM: c_int = 66; +pub const _SC_XOPEN_XCU_VERSION: c_int = 67; +pub const _SC_ATEXIT_MAX: c_int = 76; +pub const _SC_IOV_MAX: c_int = 77; +pub const _SC_XOPEN_UNIX: c_int = 78; +pub const _SC_T_IOV_MAX: c_int = 79; +pub const _SC_PHYS_PAGES: c_int = 500; +pub const _SC_AVPHYS_PAGES: c_int = 501; +pub const _SC_COHER_BLKSZ: c_int = 503; +pub const _SC_SPLIT_CACHE: c_int = 504; +pub const _SC_ICACHE_SZ: c_int = 505; +pub const _SC_DCACHE_SZ: c_int = 506; +pub const _SC_ICACHE_LINESZ: c_int = 507; +pub const _SC_DCACHE_LINESZ: c_int = 508; +pub const _SC_ICACHE_BLKSZ: c_int = 509; +pub const _SC_DCACHE_BLKSZ: c_int = 510; +pub const _SC_DCACHE_TBLKSZ: c_int = 511; +pub const _SC_ICACHE_ASSOC: c_int = 512; +pub const _SC_DCACHE_ASSOC: c_int = 513; +pub const _SC_MAXPID: c_int = 514; +pub const _SC_STACK_PROT: c_int = 515; +pub const _SC_NPROCESSORS_MAX: c_int = 516; +pub const _SC_CPUID_MAX: c_int = 517; +pub const _SC_EPHID_MAX: c_int = 518; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 568; +pub const _SC_GETGR_R_SIZE_MAX: c_int = 569; +pub const _SC_GETPW_R_SIZE_MAX: c_int = 570; +pub const _SC_LOGIN_NAME_MAX: c_int = 571; +pub const _SC_THREAD_KEYS_MAX: c_int = 572; +pub const _SC_THREAD_STACK_MIN: c_int = 573; +pub const _SC_THREAD_THREADS_MAX: c_int = 574; +pub const _SC_TTY_NAME_MAX: c_int = 575; +pub const _SC_THREADS: c_int = 576; +pub const _SC_THREAD_ATTR_STACKADDR: c_int = 577; +pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 578; +pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 579; +pub const _SC_THREAD_PRIO_INHERIT: c_int = 580; +pub const _SC_THREAD_PRIO_PROTECT: c_int = 581; +pub const _SC_THREAD_PROCESS_SHARED: c_int = 582; +pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 583; +pub const _SC_XOPEN_LEGACY: c_int = 717; +pub const _SC_XOPEN_REALTIME: c_int = 718; +pub const _SC_XOPEN_REALTIME_THREADS: c_int = 719; +pub const _SC_XBS5_ILP32_OFF32: c_int = 720; +pub const _SC_XBS5_ILP32_OFFBIG: c_int = 721; +pub const _SC_XBS5_LP64_OFF64: c_int = 722; +pub const _SC_XBS5_LPBIG_OFFBIG: c_int = 723; +pub const _SC_2_PBS: c_int = 724; +pub const _SC_2_PBS_ACCOUNTING: c_int = 725; +pub const _SC_2_PBS_CHECKPOINT: c_int = 726; +pub const _SC_2_PBS_LOCATE: c_int = 728; +pub const _SC_2_PBS_MESSAGE: c_int = 729; +pub const _SC_2_PBS_TRACK: c_int = 730; +pub const _SC_ADVISORY_INFO: c_int = 731; +pub const _SC_BARRIERS: c_int = 732; +pub const _SC_CLOCK_SELECTION: c_int = 733; +pub const _SC_CPUTIME: c_int = 734; +pub const _SC_HOST_NAME_MAX: c_int = 735; +pub const _SC_MONOTONIC_CLOCK: c_int = 736; +pub const _SC_READER_WRITER_LOCKS: c_int = 737; +pub const _SC_REGEXP: c_int = 738; +pub const _SC_SHELL: c_int = 739; +pub const _SC_SPAWN: c_int = 740; +pub const _SC_SPIN_LOCKS: c_int = 741; +pub const _SC_SPORADIC_SERVER: c_int = 742; +pub const _SC_SS_REPL_MAX: c_int = 743; +pub const _SC_SYMLOOP_MAX: c_int = 744; +pub const _SC_THREAD_CPUTIME: c_int = 745; +pub const _SC_THREAD_SPORADIC_SERVER: c_int = 746; +pub const _SC_TIMEOUTS: c_int = 747; +pub const _SC_TRACE: c_int = 748; +pub const _SC_TRACE_EVENT_FILTER: c_int = 749; +pub const _SC_TRACE_EVENT_NAME_MAX: c_int = 750; +pub const _SC_TRACE_INHERIT: c_int = 751; +pub const _SC_TRACE_LOG: c_int = 752; +pub const _SC_TRACE_NAME_MAX: c_int = 753; +pub const _SC_TRACE_SYS_MAX: c_int = 754; +pub const _SC_TRACE_USER_EVENT_MAX: c_int = 755; +pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 756; +pub const _SC_V6_ILP32_OFF32: c_int = 757; +pub const _SC_V6_ILP32_OFFBIG: c_int = 758; +pub const _SC_V6_LP64_OFF64: c_int = 759; +pub const _SC_V6_LPBIG_OFFBIG: c_int = 760; +pub const _SC_XOPEN_STREAMS: c_int = 761; +pub const _SC_IPV6: c_int = 762; +pub const _SC_RAW_SOCKETS: c_int = 763; + +pub const _ST_FSTYPSZ: c_int = 16; + +pub const _MUTEX_MAGIC: u16 = 0x4d58; // MX +pub const _COND_MAGIC: u16 = 0x4356; // CV +pub const _RWL_MAGIC: u16 = 0x5257; // RW + +pub const NCCS: usize = 19; + +pub const LOG_CRON: c_int = 15 << 3; + +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + __pthread_mutex_flag1: 0, + __pthread_mutex_flag2: 0, + __pthread_mutex_ceiling: 0, + __pthread_mutex_type: PTHREAD_PROCESS_PRIVATE, + __pthread_mutex_magic: _MUTEX_MAGIC, + __pthread_mutex_lock: 0, + __pthread_mutex_data: 0, +}; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + __pthread_cond_flag: [0; 4], + __pthread_cond_type: PTHREAD_PROCESS_PRIVATE, + __pthread_cond_magic: _COND_MAGIC, + __pthread_cond_data: 0, +}; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + __pthread_rwlock_readers: 0, + __pthread_rwlock_type: PTHREAD_PROCESS_PRIVATE, + __pthread_rwlock_magic: _RWL_MAGIC, + __pthread_rwlock_mutex: PTHREAD_MUTEX_INITIALIZER, + __pthread_rwlock_readercv: PTHREAD_COND_INITIALIZER, + __pthread_rwlock_writercv: PTHREAD_COND_INITIALIZER, +}; +pub const PTHREAD_MUTEX_NORMAL: c_int = 0; +pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 2; +pub const PTHREAD_MUTEX_RECURSIVE: c_int = 4; +pub const PTHREAD_MUTEX_DEFAULT: c_int = crate::PTHREAD_MUTEX_NORMAL; + +pub const RTLD_NEXT: *mut c_void = -1isize as *mut c_void; +pub const RTLD_DEFAULT: *mut c_void = -2isize as *mut c_void; +pub const RTLD_SELF: *mut c_void = -3isize as *mut c_void; +pub const RTLD_PROBE: *mut c_void = -4isize as *mut c_void; + +pub const RTLD_LAZY: c_int = 0x1; +pub const RTLD_NOW: c_int = 0x2; +pub const RTLD_NOLOAD: c_int = 0x4; +pub const RTLD_GLOBAL: c_int = 0x100; +pub const RTLD_LOCAL: c_int = 0x0; +pub const RTLD_PARENT: c_int = 0x200; +pub const RTLD_GROUP: c_int = 0x400; +pub const RTLD_WORLD: c_int = 0x800; +pub const RTLD_NODELETE: c_int = 0x1000; +pub const RTLD_FIRST: c_int = 0x2000; +pub const RTLD_CONFGEN: c_int = 0x10000; + +pub const PORT_SOURCE_AIO: c_int = 1; +pub const PORT_SOURCE_TIMER: c_int = 2; +pub const PORT_SOURCE_USER: c_int = 3; +pub const PORT_SOURCE_FD: c_int = 4; +pub const PORT_SOURCE_ALERT: c_int = 5; +pub const PORT_SOURCE_MQ: c_int = 6; +pub const PORT_SOURCE_FILE: c_int = 7; + +pub const NONROOT_USR: c_short = 2; + +pub const EMPTY: c_short = 0; +pub const RUN_LVL: c_short = 1; +pub const BOOT_TIME: c_short = 2; +pub const OLD_TIME: c_short = 3; +pub const NEW_TIME: c_short = 4; +pub const INIT_PROCESS: c_short = 5; +pub const LOGIN_PROCESS: c_short = 6; +pub const USER_PROCESS: c_short = 7; +pub const DEAD_PROCESS: c_short = 8; +pub const ACCOUNTING: c_short = 9; +pub const DOWN_TIME: c_short = 10; + +const _TIOC: c_int = ('T' as i32) << 8; +const tIOC: c_int = ('t' as i32) << 8; +pub const TCGETA: c_int = _TIOC | 1; +pub const TCSETA: c_int = _TIOC | 2; +pub const TCSETAW: c_int = _TIOC | 3; +pub const TCSETAF: c_int = _TIOC | 4; +pub const TCSBRK: c_int = _TIOC | 5; +pub const TCXONC: c_int = _TIOC | 6; +pub const TCFLSH: c_int = _TIOC | 7; +pub const TCDSET: c_int = _TIOC | 32; +pub const TCGETS: c_int = _TIOC | 13; +pub const TCSETS: c_int = _TIOC | 14; +pub const TCSANOW: c_int = _TIOC | 14; +pub const TCSETSW: c_int = _TIOC | 15; +pub const TCSADRAIN: c_int = _TIOC | 15; +pub const TCSETSF: c_int = _TIOC | 16; +pub const TCSAFLUSH: c_int = _TIOC | 16; +pub const TCIFLUSH: c_int = 0; +pub const TCOFLUSH: c_int = 1; +pub const TCIOFLUSH: c_int = 2; +pub const TCOOFF: c_int = 0; +pub const TCOON: c_int = 1; +pub const TCIOFF: c_int = 2; +pub const TCION: c_int = 3; +pub const TIOC: c_int = _TIOC; +pub const TIOCKBON: c_int = _TIOC | 8; +pub const TIOCKBOF: c_int = _TIOC | 9; +pub const TIOCGWINSZ: c_int = _TIOC | 104; +pub const TIOCSWINSZ: c_int = _TIOC | 103; +pub const TIOCGSOFTCAR: c_int = _TIOC | 105; +pub const TIOCSSOFTCAR: c_int = _TIOC | 106; +pub const TIOCGPPS: c_int = _TIOC | 125; +pub const TIOCSPPS: c_int = _TIOC | 126; +pub const TIOCGPPSEV: c_int = _TIOC | 127; +pub const TIOCGETD: c_int = tIOC | 0; +pub const TIOCSETD: c_int = tIOC | 1; +pub const TIOCHPCL: c_int = tIOC | 2; +pub const TIOCGETP: c_int = tIOC | 8; +pub const TIOCSETP: c_int = tIOC | 9; +pub const TIOCSETN: c_int = tIOC | 10; +pub const TIOCEXCL: c_int = tIOC | 13; +pub const TIOCNXCL: c_int = tIOC | 14; +pub const TIOCFLUSH: c_int = tIOC | 16; +pub const TIOCSETC: c_int = tIOC | 17; +pub const TIOCGETC: c_int = tIOC | 18; +pub const TIOCLBIS: c_int = tIOC | 127; +pub const TIOCLBIC: c_int = tIOC | 126; +pub const TIOCLSET: c_int = tIOC | 125; +pub const TIOCLGET: c_int = tIOC | 124; +pub const TIOCSBRK: c_int = tIOC | 123; +pub const TIOCCBRK: c_int = tIOC | 122; +pub const TIOCSDTR: c_int = tIOC | 121; +pub const TIOCCDTR: c_int = tIOC | 120; +pub const TIOCSLTC: c_int = tIOC | 117; +pub const TIOCGLTC: c_int = tIOC | 116; +pub const TIOCOUTQ: c_int = tIOC | 115; +pub const TIOCNOTTY: c_int = tIOC | 113; +pub const TIOCSCTTY: c_int = tIOC | 132; +pub const TIOCSTOP: c_int = tIOC | 111; +pub const TIOCSTART: c_int = tIOC | 110; +pub const TIOCSILOOP: c_int = tIOC | 109; +pub const TIOCCILOOP: c_int = tIOC | 108; +pub const TIOCGPGRP: c_int = tIOC | 20; +pub const TIOCSPGRP: c_int = tIOC | 21; +pub const TIOCGSID: c_int = tIOC | 22; +pub const TIOCSTI: c_int = tIOC | 23; +pub const TIOCMSET: c_int = tIOC | 26; +pub const TIOCMBIS: c_int = tIOC | 27; +pub const TIOCMBIC: c_int = tIOC | 28; +pub const TIOCMGET: c_int = tIOC | 29; +pub const TIOCREMOTE: c_int = tIOC | 30; +pub const TIOCSIGNAL: c_int = tIOC | 31; + +pub const TIOCM_LE: c_int = 0o0001; +pub const TIOCM_DTR: c_int = 0o0002; +pub const TIOCM_RTS: c_int = 0o0004; +pub const TIOCM_ST: c_int = 0o0010; +pub const TIOCM_SR: c_int = 0o0020; +pub const TIOCM_CTS: c_int = 0o0040; +pub const TIOCM_CAR: c_int = 0o0100; +pub const TIOCM_CD: c_int = TIOCM_CAR; +pub const TIOCM_RNG: c_int = 0o0200; +pub const TIOCM_RI: c_int = TIOCM_RNG; +pub const TIOCM_DSR: c_int = 0o0400; + +/* termios */ +pub const B0: speed_t = 0; +pub const B50: speed_t = 1; +pub const B75: speed_t = 2; +pub const B110: speed_t = 3; +pub const B134: speed_t = 4; +pub const B150: speed_t = 5; +pub const B200: speed_t = 6; +pub const B300: speed_t = 7; +pub const B600: speed_t = 8; +pub const B1200: speed_t = 9; +pub const B1800: speed_t = 10; +pub const B2400: speed_t = 11; +pub const B4800: speed_t = 12; +pub const B9600: speed_t = 13; +pub const B19200: speed_t = 14; +pub const B38400: speed_t = 15; +pub const B57600: speed_t = 16; +pub const B76800: speed_t = 17; +pub const B115200: speed_t = 18; +pub const B153600: speed_t = 19; +pub const B230400: speed_t = 20; +pub const B307200: speed_t = 21; +pub const B460800: speed_t = 22; +pub const B921600: speed_t = 23; +pub const CSTART: crate::tcflag_t = 0o21; +pub const CSTOP: crate::tcflag_t = 0o23; +pub const CSWTCH: crate::tcflag_t = 0o32; +pub const CBAUD: crate::tcflag_t = 0o17; +pub const CIBAUD: crate::tcflag_t = 0o3600000; +pub const CBAUDEXT: crate::tcflag_t = 0o10000000; +pub const CIBAUDEXT: crate::tcflag_t = 0o20000000; +pub const CSIZE: crate::tcflag_t = 0o000060; +pub const CS5: crate::tcflag_t = 0; +pub const CS6: crate::tcflag_t = 0o000020; +pub const CS7: crate::tcflag_t = 0o000040; +pub const CS8: crate::tcflag_t = 0o000060; +pub const CSTOPB: crate::tcflag_t = 0o000100; +pub const ECHO: crate::tcflag_t = 0o000010; +pub const ECHOE: crate::tcflag_t = 0o000020; +pub const ECHOK: crate::tcflag_t = 0o000040; +pub const ECHONL: crate::tcflag_t = 0o000100; +pub const ECHOCTL: crate::tcflag_t = 0o001000; +pub const ECHOPRT: crate::tcflag_t = 0o002000; +pub const ECHOKE: crate::tcflag_t = 0o004000; +pub const EXTPROC: crate::tcflag_t = 0o200000; +pub const IGNBRK: crate::tcflag_t = 0o000001; +pub const BRKINT: crate::tcflag_t = 0o000002; +pub const IGNPAR: crate::tcflag_t = 0o000004; +pub const PARMRK: crate::tcflag_t = 0o000010; +pub const INPCK: crate::tcflag_t = 0o000020; +pub const ISTRIP: crate::tcflag_t = 0o000040; +pub const INLCR: crate::tcflag_t = 0o000100; +pub const IGNCR: crate::tcflag_t = 0o000200; +pub const ICRNL: crate::tcflag_t = 0o000400; +pub const IUCLC: crate::tcflag_t = 0o001000; +pub const IXON: crate::tcflag_t = 0o002000; +pub const IXOFF: crate::tcflag_t = 0o010000; +pub const IXANY: crate::tcflag_t = 0o004000; +pub const IMAXBEL: crate::tcflag_t = 0o020000; +pub const DOSMODE: crate::tcflag_t = 0o100000; +pub const OPOST: crate::tcflag_t = 0o000001; +pub const OLCUC: crate::tcflag_t = 0o000002; +pub const ONLCR: crate::tcflag_t = 0o000004; +pub const OCRNL: crate::tcflag_t = 0o000010; +pub const ONOCR: crate::tcflag_t = 0o000020; +pub const ONLRET: crate::tcflag_t = 0o000040; +pub const OFILL: crate::tcflag_t = 0o0000100; +pub const OFDEL: crate::tcflag_t = 0o0000200; +pub const CREAD: crate::tcflag_t = 0o000200; +pub const PARENB: crate::tcflag_t = 0o000400; +pub const PARODD: crate::tcflag_t = 0o001000; +pub const HUPCL: crate::tcflag_t = 0o002000; +pub const CLOCAL: crate::tcflag_t = 0o004000; +pub const CRTSXOFF: crate::tcflag_t = 0o10000000000; +pub const CRTSCTS: crate::tcflag_t = 0o20000000000; +pub const ISIG: crate::tcflag_t = 0o000001; +pub const ICANON: crate::tcflag_t = 0o000002; +pub const IEXTEN: crate::tcflag_t = 0o100000; +pub const TOSTOP: crate::tcflag_t = 0o000400; +pub const FLUSHO: crate::tcflag_t = 0o020000; +pub const PENDIN: crate::tcflag_t = 0o040000; +pub const NOFLSH: crate::tcflag_t = 0o000200; +pub const VINTR: usize = 0; +pub const VQUIT: usize = 1; +pub const VERASE: usize = 2; +pub const VKILL: usize = 3; +pub const VEOF: usize = 4; +pub const VEOL: usize = 5; +pub const VEOL2: usize = 6; +pub const VMIN: usize = 4; +pub const VTIME: usize = 5; +pub const VSWTCH: usize = 7; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VSUSP: usize = 10; +pub const VDSUSP: usize = 11; +pub const VREPRINT: usize = 12; +pub const VDISCARD: usize = 13; +pub const VWERASE: usize = 14; +pub const VLNEXT: usize = 15; + +// +const STR: c_int = (b'S' as c_int) << 8; +pub const I_NREAD: c_int = STR | 0o1; +pub const I_PUSH: c_int = STR | 0o2; +pub const I_POP: c_int = STR | 0o3; +pub const I_LOOK: c_int = STR | 0o4; +pub const I_FLUSH: c_int = STR | 0o5; +pub const I_SRDOPT: c_int = STR | 0o6; +pub const I_GRDOPT: c_int = STR | 0o7; +pub const I_STR: c_int = STR | 0o10; +pub const I_SETSIG: c_int = STR | 0o11; +pub const I_GETSIG: c_int = STR | 0o12; +pub const I_FIND: c_int = STR | 0o13; +pub const I_LINK: c_int = STR | 0o14; +pub const I_UNLINK: c_int = STR | 0o15; +pub const I_PEEK: c_int = STR | 0o17; +pub const I_FDINSERT: c_int = STR | 0o20; +pub const I_SENDFD: c_int = STR | 0o21; +pub const I_RECVFD: c_int = STR | 0o16; +pub const I_SWROPT: c_int = STR | 0o23; +pub const I_GWROPT: c_int = STR | 0o24; +pub const I_LIST: c_int = STR | 0o25; +pub const I_PLINK: c_int = STR | 0o26; +pub const I_PUNLINK: c_int = STR | 0o27; +pub const I_ANCHOR: c_int = STR | 0o30; +pub const I_FLUSHBAND: c_int = STR | 0o34; +pub const I_CKBAND: c_int = STR | 0o35; +pub const I_GETBAND: c_int = STR | 0o36; +pub const I_ATMARK: c_int = STR | 0o37; +pub const I_SETCLTIME: c_int = STR | 0o40; +pub const I_GETCLTIME: c_int = STR | 0o41; +pub const I_CANPUT: c_int = STR | 0o42; +pub const I_SERROPT: c_int = STR | 0o43; +pub const I_GERROPT: c_int = STR | 0o44; +pub const I_ESETSIG: c_int = STR | 0o45; +pub const I_EGETSIG: c_int = STR | 0o46; +pub const __I_PUSH_NOCTTY: c_int = STR | 0o47; + +// 3SOCKET flags +pub const SOCK_CLOEXEC: c_int = 0x080000; +pub const SOCK_NONBLOCK: c_int = 0x100000; +pub const SOCK_NDELAY: c_int = 0x200000; + +// +pub const SCALE_KG: c_int = 1 << 6; +pub const SCALE_KF: c_int = 1 << 16; +pub const SCALE_KH: c_int = 1 << 2; +pub const MAXTC: c_int = 1 << 6; +pub const SCALE_PHASE: c_int = 1 << 22; +pub const SCALE_USEC: c_int = 1 << 16; +pub const SCALE_UPDATE: c_int = SCALE_KG * MAXTC; +pub const FINEUSEC: c_int = 1 << 22; +pub const MAXPHASE: c_int = 512000; +pub const MAXFREQ: c_int = 512 * SCALE_USEC; +pub const MAXTIME: c_int = 200 << PPS_AVG; +pub const MINSEC: c_int = 16; +pub const MAXSEC: c_int = 1200; +pub const PPS_AVG: c_int = 2; +pub const PPS_SHIFT: c_int = 2; +pub const PPS_SHIFTMAX: c_int = 8; +pub const PPS_VALID: c_int = 120; +pub const MAXGLITCH: c_int = 30; +pub const MOD_OFFSET: u32 = 0x0001; +pub const MOD_FREQUENCY: u32 = 0x0002; +pub const MOD_MAXERROR: u32 = 0x0004; +pub const MOD_ESTERROR: u32 = 0x0008; +pub const MOD_STATUS: u32 = 0x0010; +pub const MOD_TIMECONST: u32 = 0x0020; +pub const MOD_CLKB: u32 = 0x4000; +pub const MOD_CLKA: u32 = 0x8000; +pub const STA_PLL: u32 = 0x0001; +pub const STA_PPSFREQ: i32 = 0x0002; +pub const STA_PPSTIME: i32 = 0x0004; +pub const STA_FLL: i32 = 0x0008; +pub const STA_INS: i32 = 0x0010; +pub const STA_DEL: i32 = 0x0020; +pub const STA_UNSYNC: i32 = 0x0040; +pub const STA_FREQHOLD: i32 = 0x0080; +pub const STA_PPSSIGNAL: i32 = 0x0100; +pub const STA_PPSJITTER: i32 = 0x0200; +pub const STA_PPSWANDER: i32 = 0x0400; +pub const STA_PPSERROR: i32 = 0x0800; +pub const STA_CLOCKERR: i32 = 0x1000; +pub const STA_RONLY: i32 = + STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | STA_PPSERROR | STA_CLOCKERR; +pub const TIME_OK: i32 = 0; +pub const TIME_INS: i32 = 1; +pub const TIME_DEL: i32 = 2; +pub const TIME_OOP: i32 = 3; +pub const TIME_WAIT: i32 = 4; +pub const TIME_ERROR: i32 = 5; + +pub const PRIO_PROCESS: c_int = 0; +pub const PRIO_PGRP: c_int = 1; +pub const PRIO_USER: c_int = 2; + +pub const SCHED_OTHER: c_int = 0; +pub const SCHED_FIFO: c_int = 1; +pub const SCHED_RR: c_int = 2; +pub const SCHED_SYS: c_int = 3; +pub const SCHED_IA: c_int = 4; +pub const SCHED_FSS: c_int = 5; +pub const SCHED_FX: c_int = 6; + +// sys/priv.h +pub const PRIV_DEBUG: c_uint = 0x0001; +pub const PRIV_AWARE: c_uint = 0x0002; +pub const PRIV_AWARE_INHERIT: c_uint = 0x0004; +pub const __PROC_PROTECT: c_uint = 0x0008; +pub const NET_MAC_AWARE: c_uint = 0x0010; +pub const NET_MAC_AWARE_INHERIT: c_uint = 0x0020; +pub const PRIV_AWARE_RESET: c_uint = 0x0040; +pub const PRIV_XPOLICY: c_uint = 0x0080; +pub const PRIV_PFEXEC: c_uint = 0x0100; + +// sys/systeminfo.h +pub const SI_SYSNAME: c_int = 1; +pub const SI_HOSTNAME: c_int = 2; +pub const SI_RELEASE: c_int = 3; +pub const SI_VERSION: c_int = 4; +pub const SI_MACHINE: c_int = 5; +pub const SI_ARCHITECTURE: c_int = 6; +pub const SI_HW_SERIAL: c_int = 7; +pub const SI_HW_PROVIDER: c_int = 8; +pub const SI_SET_HOSTNAME: c_int = 258; +pub const SI_SET_SRPC_DOMAIN: c_int = 265; +pub const SI_PLATFORM: c_int = 513; +pub const SI_ISALIST: c_int = 514; +pub const SI_DHCP_CACHE: c_int = 515; +pub const SI_ARCHITECTURE_32: c_int = 516; +pub const SI_ARCHITECTURE_64: c_int = 517; +pub const SI_ARCHITECTURE_K: c_int = 518; +pub const SI_ARCHITECTURE_NATIVE: c_int = 519; + +// sys/lgrp_user.h +pub const LGRP_COOKIE_NONE: crate::lgrp_cookie_t = 0; +pub const LGRP_AFF_NONE: crate::lgrp_affinity_t = 0x0; +pub const LGRP_AFF_WEAK: crate::lgrp_affinity_t = 0x10; +pub const LGRP_AFF_STRONG: crate::lgrp_affinity_t = 0x100; +pub const LGRP_CONTENT_ALL: crate::lgrp_content_t = 0; +pub const LGRP_CONTENT_HIERARCHY: crate::lgrp_content_t = LGRP_CONTENT_ALL; +pub const LGRP_CONTENT_DIRECT: crate::lgrp_content_t = 1; +pub const LGRP_LAT_CPU_TO_MEM: crate::lgrp_lat_between_t = 0; +pub const LGRP_MEM_SZ_FREE: crate::lgrp_mem_size_flag_t = 0; +pub const LGRP_MEM_SZ_INSTALLED: crate::lgrp_mem_size_flag_t = 1; +pub const LGRP_VIEW_CALLER: crate::lgrp_view_t = 0; +pub const LGRP_VIEW_OS: crate::lgrp_view_t = 1; + +// sys/processor.h + +pub const P_OFFLINE: c_int = 0x001; +pub const P_ONLINE: c_int = 0x002; +pub const P_STATUS: c_int = 0x003; +pub const P_FAULTED: c_int = 0x004; +pub const P_POWEROFF: c_int = 0x005; +pub const P_NOINTR: c_int = 0x006; +pub const P_SPARE: c_int = 0x007; +pub const P_FORCED: c_int = 0x10000000; +pub const PI_TYPELEN: c_int = 16; +pub const PI_FPUTYPE: c_int = 32; + +// sys/auxv.h +pub const AT_SUN_HWCAP: c_uint = 2009; + +// As per sys/socket.h, header alignment must be 8 bytes on SPARC +// and 4 bytes everywhere else: +#[cfg(target_arch = "sparc64")] +const _CMSG_HDR_ALIGNMENT: usize = 8; +#[cfg(not(target_arch = "sparc64"))] +const _CMSG_HDR_ALIGNMENT: usize = 4; + +const _CMSG_DATA_ALIGNMENT: usize = size_of::(); + +const NEWDEV: c_int = 1; + +// sys/sendfile.h +pub const SFV_FD_SELF: c_int = -2; + +const fn _CMSG_HDR_ALIGN(p: usize) -> usize { + (p + _CMSG_HDR_ALIGNMENT - 1) & !(_CMSG_HDR_ALIGNMENT - 1) +} + +const fn _CMSG_DATA_ALIGN(p: usize) -> usize { + (p + _CMSG_DATA_ALIGNMENT - 1) & !(_CMSG_DATA_ALIGNMENT - 1) +} + +f! { + pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { + _CMSG_DATA_ALIGN(cmsg.offset(1) as usize) as *mut c_uchar + } + + pub const fn CMSG_LEN(length: c_uint) -> c_uint { + _CMSG_DATA_ALIGN(size_of::()) as c_uint + length + } + + pub fn CMSG_FIRSTHDR(mhdr: *const crate::msghdr) -> *mut cmsghdr { + if ((*mhdr).msg_controllen as usize) < size_of::() { + core::ptr::null_mut::() + } else { + (*mhdr).msg_control as *mut cmsghdr + } + } + + pub fn CMSG_NXTHDR(mhdr: *const crate::msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { + if cmsg.is_null() { + return crate::CMSG_FIRSTHDR(mhdr); + } + let next = + _CMSG_HDR_ALIGN(cmsg as usize + (*cmsg).cmsg_len as usize + size_of::()); + let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; + if next > max { + core::ptr::null_mut::() + } else { + _CMSG_HDR_ALIGN(cmsg as usize + (*cmsg).cmsg_len as usize) as *mut cmsghdr + } + } + + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { + _CMSG_HDR_ALIGN(size_of::() as usize + length as usize) as c_uint + } + + pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { + let bits = size_of_val(&(*set).fds_bits[0]) * 8; + let fd = fd as usize; + (*set).fds_bits[fd / bits] &= !(1 << (fd % bits)); + return; + } + + pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { + let bits = size_of_val(&(*set).fds_bits[0]) * 8; + let fd = fd as usize; + return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0; + } + + pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { + let bits = size_of_val(&(*set).fds_bits[0]) * 8; + let fd = fd as usize; + (*set).fds_bits[fd / bits] |= 1 << (fd % bits); + return; + } + + pub fn FD_ZERO(set: *mut fd_set) -> () { + for slot in (*set).fds_bits.iter_mut() { + *slot = 0; + } + } +} + +safe_f! { + pub fn SIGRTMAX() -> c_int { + unsafe { crate::sysconf(_SC_SIGRT_MAX) as c_int } + } + + pub fn SIGRTMIN() -> c_int { + unsafe { crate::sysconf(_SC_SIGRT_MIN) as c_int } + } + + pub const fn WIFEXITED(status: c_int) -> bool { + (status & 0xFF) == 0 + } + + pub const fn WEXITSTATUS(status: c_int) -> c_int { + (status >> 8) & 0xFF + } + + pub const fn WTERMSIG(status: c_int) -> c_int { + status & 0x7F + } + + pub const fn WIFCONTINUED(status: c_int) -> bool { + (status & 0xffff) == 0xffff + } + + pub const fn WSTOPSIG(status: c_int) -> c_int { + (status & 0xff00) >> 8 + } + + pub const fn WIFSIGNALED(status: c_int) -> bool { + ((status & 0xff) > 0) && (status & 0xff00 == 0) + } + + pub const fn WIFSTOPPED(status: c_int) -> bool { + ((status & 0xff) == 0x7f) && ((status & 0xff00) != 0) + } + + pub const fn WCOREDUMP(status: c_int) -> bool { + (status & 0x80) != 0 + } + + pub const fn MR_GET_TYPE(flags: c_uint) -> c_uint { + flags & 0x0000ffff + } +} + +extern "C" { + pub fn getrlimit(resource: c_int, rlim: *mut crate::rlimit) -> c_int; + pub fn setrlimit(resource: c_int, rlim: *const crate::rlimit) -> c_int; + + pub fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int; + + pub fn sem_destroy(sem: *mut sem_t) -> c_int; + pub fn sem_init(sem: *mut sem_t, pshared: c_int, value: c_uint) -> c_int; + + pub fn abs(i: c_int) -> c_int; + pub fn acct(filename: *const c_char) -> c_int; + pub fn dirfd(dirp: *mut crate::DIR) -> c_int; + pub fn labs(i: c_long) -> c_long; + pub fn rand() -> c_int; + pub fn srand(seed: c_uint); + pub fn getentropy(buf: *mut c_void, buflen: size_t) -> c_int; + pub fn getrandom(bbuf: *mut c_void, buflen: size_t, flags: c_uint) -> ssize_t; + + pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut c_void) -> c_int; + pub fn settimeofday(tp: *const crate::timeval, tz: *const c_void) -> c_int; + pub fn getifaddrs(ifap: *mut *mut crate::ifaddrs) -> c_int; + pub fn freeifaddrs(ifa: *mut crate::ifaddrs); + + pub fn stack_getbounds(sp: *mut crate::stack_t) -> c_int; + pub fn getgrouplist( + name: *const c_char, + basegid: crate::gid_t, + groups: *mut crate::gid_t, + ngroups: *mut c_int, + ) -> c_int; + pub fn initgroups(name: *const c_char, basegid: crate::gid_t) -> c_int; + pub fn setgroups(ngroups: c_int, ptr: *const crate::gid_t) -> c_int; + pub fn ioctl(fildes: c_int, request: c_int, ...) -> c_int; + pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; + pub fn ___errno() -> *mut c_int; + pub fn clock_getres(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; + pub fn clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; + pub fn clock_nanosleep( + clk_id: crate::clockid_t, + flags: c_int, + rqtp: *const crate::timespec, + rmtp: *mut crate::timespec, + ) -> c_int; + pub fn clock_settime(clk_id: crate::clockid_t, tp: *const crate::timespec) -> c_int; + pub fn getnameinfo( + sa: *const crate::sockaddr, + salen: crate::socklen_t, + host: *mut c_char, + hostlen: crate::socklen_t, + serv: *mut c_char, + servlen: crate::socklen_t, + flags: c_int, + ) -> c_int; + pub fn setpwent(); + pub fn endpwent(); + pub fn getpwent() -> *mut passwd; + pub fn fdatasync(fd: c_int) -> c_int; + pub fn nl_langinfo_l(item: crate::nl_item, locale: crate::locale_t) -> *mut c_char; + pub fn duplocale(base: crate::locale_t) -> crate::locale_t; + pub fn freelocale(loc: crate::locale_t); + pub fn newlocale(mask: c_int, locale: *const c_char, base: crate::locale_t) -> crate::locale_t; + pub fn uselocale(loc: crate::locale_t) -> crate::locale_t; + pub fn getprogname() -> *const c_char; + pub fn setprogname(name: *const c_char); + pub fn getloadavg(loadavg: *mut c_double, nelem: c_int) -> c_int; + pub fn getpriority(which: c_int, who: c_int) -> c_int; + pub fn setpriority(which: c_int, who: c_int, prio: c_int) -> c_int; + + pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; + pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; + pub fn sethostname(name: *const c_char, len: c_int) -> c_int; + pub fn if_nameindex() -> *mut if_nameindex; + pub fn if_freenameindex(ptr: *mut if_nameindex); + pub fn pthread_create( + native: *mut crate::pthread_t, + attr: *const crate::pthread_attr_t, + f: extern "C" fn(*mut c_void) -> *mut c_void, + value: *mut c_void, + ) -> c_int; + pub fn pthread_attr_getstack( + attr: *const crate::pthread_attr_t, + stackaddr: *mut *mut c_void, + stacksize: *mut size_t, + ) -> c_int; + pub fn pthread_condattr_getclock( + attr: *const pthread_condattr_t, + clock_id: *mut clockid_t, + ) -> c_int; + pub fn pthread_condattr_setclock( + attr: *mut pthread_condattr_t, + clock_id: crate::clockid_t, + ) -> c_int; + pub fn sem_timedwait(sem: *mut sem_t, abstime: *const crate::timespec) -> c_int; + pub fn sem_getvalue(sem: *mut sem_t, sval: *mut c_int) -> c_int; + pub fn pthread_mutex_timedlock( + lock: *mut pthread_mutex_t, + abstime: *const crate::timespec, + ) -> c_int; + pub fn pthread_getname_np(tid: crate::pthread_t, name: *mut c_char, len: size_t) -> c_int; + pub fn pthread_setname_np(tid: crate::pthread_t, name: *const c_char) -> c_int; + pub fn waitid( + idtype: idtype_t, + id: id_t, + infop: *mut crate::siginfo_t, + options: c_int, + ) -> c_int; + + #[cfg_attr(target_os = "illumos", link_name = "_glob_ext")] + pub fn glob( + pattern: *const c_char, + flags: c_int, + errfunc: Option c_int>, + pglob: *mut crate::glob_t, + ) -> c_int; + + #[cfg_attr(target_os = "illumos", link_name = "_globfree_ext")] + pub fn globfree(pglob: *mut crate::glob_t); + + pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int; + pub fn posix_madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; + + pub fn posix_spawn( + pid: *mut crate::pid_t, + path: *const c_char, + file_actions: *const posix_spawn_file_actions_t, + attrp: *const posix_spawnattr_t, + argv: *const *mut c_char, + envp: *const *mut c_char, + ) -> c_int; + pub fn posix_spawnp( + pid: *mut crate::pid_t, + file: *const c_char, + file_actions: *const posix_spawn_file_actions_t, + attrp: *const posix_spawnattr_t, + argv: *const *mut c_char, + envp: *const *mut c_char, + ) -> c_int; + + pub fn posix_spawn_file_actions_init(file_actions: *mut posix_spawn_file_actions_t) -> c_int; + pub fn posix_spawn_file_actions_destroy(file_actions: *mut posix_spawn_file_actions_t) + -> c_int; + pub fn posix_spawn_file_actions_addopen( + file_actions: *mut posix_spawn_file_actions_t, + fildes: c_int, + path: *const c_char, + oflag: c_int, + mode: mode_t, + ) -> c_int; + pub fn posix_spawn_file_actions_addclose( + file_actions: *mut posix_spawn_file_actions_t, + fildes: c_int, + ) -> c_int; + pub fn posix_spawn_file_actions_adddup2( + file_actions: *mut posix_spawn_file_actions_t, + fildes: c_int, + newfildes: c_int, + ) -> c_int; + pub fn posix_spawn_file_actions_addclosefrom_np( + file_actions: *mut posix_spawn_file_actions_t, + lowfiledes: c_int, + ) -> c_int; + pub fn posix_spawn_file_actions_addchdir( + file_actions: *mut posix_spawn_file_actions_t, + path: *const c_char, + ) -> c_int; + pub fn posix_spawn_file_actions_addchdir_np( + file_actions: *mut posix_spawn_file_actions_t, + path: *const c_char, + ) -> c_int; + pub fn posix_spawn_file_actions_addfchdir( + file_actions: *mut posix_spawn_file_actions_t, + fd: c_int, + ) -> c_int; + + pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> c_int; + pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> c_int; + pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t, flags: c_short) -> c_int; + pub fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t, flags: *mut c_short) -> c_int; + pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, pgroup: crate::pid_t) -> c_int; + pub fn posix_spawnattr_getpgroup( + attr: *const posix_spawnattr_t, + _pgroup: *mut crate::pid_t, + ) -> c_int; + pub fn posix_spawnattr_setschedparam( + attr: *mut posix_spawnattr_t, + param: *const crate::sched_param, + ) -> c_int; + pub fn posix_spawnattr_getschedparam( + attr: *const posix_spawnattr_t, + param: *mut crate::sched_param, + ) -> c_int; + pub fn posix_spawnattr_setschedpolicy(attr: *mut posix_spawnattr_t, policy: c_int) -> c_int; + pub fn posix_spawnattr_getschedpolicy( + attr: *const posix_spawnattr_t, + _policy: *mut c_int, + ) -> c_int; + pub fn posix_spawnattr_setsigdefault( + attr: *mut posix_spawnattr_t, + sigdefault: *const sigset_t, + ) -> c_int; + pub fn posix_spawnattr_getsigdefault( + attr: *const posix_spawnattr_t, + sigdefault: *mut sigset_t, + ) -> c_int; + pub fn posix_spawnattr_setsigignore_np( + attr: *mut posix_spawnattr_t, + sigignore: *const sigset_t, + ) -> c_int; + pub fn posix_spawnattr_getsigignore_np( + attr: *const posix_spawnattr_t, + sigignore: *mut sigset_t, + ) -> c_int; + pub fn posix_spawnattr_setsigmask( + attr: *mut posix_spawnattr_t, + sigmask: *const sigset_t, + ) -> c_int; + pub fn posix_spawnattr_getsigmask( + attr: *const posix_spawnattr_t, + sigmask: *mut sigset_t, + ) -> c_int; + + pub fn shmat(shmid: c_int, shmaddr: *const c_void, shmflg: c_int) -> *mut c_void; + + pub fn shmctl(shmid: c_int, cmd: c_int, buf: *mut crate::shmid_ds) -> c_int; + + pub fn shmdt(shmaddr: *const c_void) -> c_int; + + pub fn shmget(key: key_t, size: size_t, shmflg: c_int) -> c_int; + + pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int; + pub fn shm_unlink(name: *const c_char) -> c_int; + + pub fn seekdir(dirp: *mut crate::DIR, loc: c_long); + + pub fn telldir(dirp: *mut crate::DIR) -> c_long; + pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; + + pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int; + + pub fn memalign(align: size_t, size: size_t) -> *mut c_void; + + pub fn recvfrom( + socket: c_int, + buf: *mut c_void, + len: size_t, + flags: c_int, + addr: *mut crate::sockaddr, + addrlen: *mut crate::socklen_t, + ) -> ssize_t; + pub fn mkstemps(template: *mut c_char, suffixlen: c_int) -> c_int; + pub fn futimesat(fd: c_int, path: *const c_char, times: *const crate::timeval) -> c_int; + pub fn futimens(dirfd: c_int, times: *const crate::timespec) -> c_int; + pub fn utimensat( + dirfd: c_int, + path: *const c_char, + times: *const crate::timespec, + flag: c_int, + ) -> c_int; + pub fn nl_langinfo(item: crate::nl_item) -> *mut c_char; + + #[link_name = "__xnet_bind"] + pub fn bind( + socket: c_int, + address: *const crate::sockaddr, + address_len: crate::socklen_t, + ) -> c_int; + + pub fn writev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; + pub fn readv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; + + #[link_name = "__xnet_sendmsg"] + pub fn sendmsg(fd: c_int, msg: *const crate::msghdr, flags: c_int) -> ssize_t; + #[link_name = "__xnet_recvmsg"] + pub fn recvmsg(fd: c_int, msg: *mut crate::msghdr, flags: c_int) -> ssize_t; + pub fn accept4( + fd: c_int, + address: *mut sockaddr, + address_len: *mut socklen_t, + flags: c_int, + ) -> c_int; + + pub fn mq_open(name: *const c_char, oflag: c_int, ...) -> crate::mqd_t; + pub fn mq_close(mqd: crate::mqd_t) -> c_int; + pub fn mq_unlink(name: *const c_char) -> c_int; + pub fn mq_receive( + mqd: crate::mqd_t, + msg_ptr: *mut c_char, + msg_len: size_t, + msg_prio: *mut c_uint, + ) -> ssize_t; + pub fn mq_timedreceive( + mqd: crate::mqd_t, + msg_ptr: *mut c_char, + msg_len: size_t, + msg_prio: *mut c_uint, + abs_timeout: *const crate::timespec, + ) -> ssize_t; + pub fn mq_send( + mqd: crate::mqd_t, + msg_ptr: *const c_char, + msg_len: size_t, + msg_prio: c_uint, + ) -> c_int; + pub fn mq_timedsend( + mqd: crate::mqd_t, + msg_ptr: *const c_char, + msg_len: size_t, + msg_prio: c_uint, + abs_timeout: *const crate::timespec, + ) -> c_int; + pub fn mq_getattr(mqd: crate::mqd_t, attr: *mut crate::mq_attr) -> c_int; + pub fn mq_setattr( + mqd: crate::mqd_t, + newattr: *const crate::mq_attr, + oldattr: *mut crate::mq_attr, + ) -> c_int; + pub fn port_create() -> c_int; + pub fn port_associate( + port: c_int, + source: c_int, + object: crate::uintptr_t, + events: c_int, + user: *mut c_void, + ) -> c_int; + pub fn port_dissociate(port: c_int, source: c_int, object: crate::uintptr_t) -> c_int; + pub fn port_get(port: c_int, pe: *mut port_event, timeout: *mut crate::timespec) -> c_int; + pub fn port_getn( + port: c_int, + pe_list: *mut port_event, + max: c_uint, + nget: *mut c_uint, + timeout: *mut crate::timespec, + ) -> c_int; + pub fn port_send(port: c_int, events: c_int, user: *mut c_void) -> c_int; + pub fn port_sendn( + port_list: *mut c_int, + error_list: *mut c_int, + nent: c_uint, + events: c_int, + user: *mut c_void, + ) -> c_int; + #[cfg_attr( + any(target_os = "solaris", target_os = "illumos"), + link_name = "__posix_getgrgid_r" + )] + pub fn getgrgid_r( + gid: crate::gid_t, + grp: *mut crate::group, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::group, + ) -> c_int; + pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> c_int; + pub fn sigsuspend(mask: *const crate::sigset_t) -> c_int; + pub fn sem_close(sem: *mut sem_t) -> c_int; + pub fn getdtablesize() -> c_int; + + #[cfg_attr( + any(target_os = "solaris", target_os = "illumos"), + link_name = "__posix_getgrnam_r" + )] + pub fn getgrnam_r( + name: *const c_char, + grp: *mut crate::group, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut crate::group, + ) -> c_int; + pub fn thr_self() -> crate::thread_t; + pub fn pthread_sigmask(how: c_int, set: *const sigset_t, oldset: *mut sigset_t) -> c_int; + pub fn sem_open(name: *const c_char, oflag: c_int, ...) -> *mut sem_t; + pub fn getgrnam(name: *const c_char) -> *mut crate::group; + #[cfg_attr(target_os = "solaris", link_name = "__pthread_kill_xpg7")] + pub fn pthread_kill(thread: crate::pthread_t, sig: c_int) -> c_int; + pub fn sched_get_priority_min(policy: c_int) -> c_int; + pub fn sched_get_priority_max(policy: c_int) -> c_int; + pub fn sched_getparam(pid: crate::pid_t, param: *mut sched_param) -> c_int; + pub fn sched_setparam(pid: crate::pid_t, param: *const sched_param) -> c_int; + pub fn sched_getscheduler(pid: crate::pid_t) -> c_int; + pub fn sched_setscheduler( + pid: crate::pid_t, + policy: c_int, + param: *const crate::sched_param, + ) -> c_int; + pub fn sem_unlink(name: *const c_char) -> c_int; + pub fn daemon(nochdir: c_int, noclose: c_int) -> c_int; + #[cfg_attr( + any(target_os = "solaris", target_os = "illumos"), + link_name = "__posix_getpwnam_r" + )] + pub fn getpwnam_r( + name: *const c_char, + pwd: *mut passwd, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut passwd, + ) -> c_int; + #[cfg_attr( + any(target_os = "solaris", target_os = "illumos"), + link_name = "__posix_getpwuid_r" + )] + pub fn getpwuid_r( + uid: crate::uid_t, + pwd: *mut passwd, + buf: *mut c_char, + buflen: size_t, + result: *mut *mut passwd, + ) -> c_int; + #[cfg_attr( + any(target_os = "solaris", target_os = "illumos"), + link_name = "getpwent_r" + )] + fn native_getpwent_r(pwd: *mut passwd, buf: *mut c_char, buflen: c_int) -> *mut passwd; + #[cfg_attr( + any(target_os = "solaris", target_os = "illumos"), + link_name = "getgrent_r" + )] + fn native_getgrent_r( + grp: *mut crate::group, + buf: *mut c_char, + buflen: c_int, + ) -> *mut crate::group; + #[cfg_attr( + any(target_os = "solaris", target_os = "illumos"), + link_name = "__posix_sigwait" + )] + pub fn sigwait(set: *const sigset_t, sig: *mut c_int) -> c_int; + pub fn pthread_atfork( + prepare: Option, + parent: Option, + child: Option, + ) -> c_int; + pub fn getgrgid(gid: crate::gid_t) -> *mut crate::group; + pub fn setgrent(); + pub fn endgrent(); + pub fn getgrent() -> *mut crate::group; + pub fn popen(command: *const c_char, mode: *const c_char) -> *mut crate::FILE; + + pub fn dup3(src: c_int, dst: c_int, flags: c_int) -> c_int; + pub fn uname(buf: *mut crate::utsname) -> c_int; + pub fn pipe2(fds: *mut c_int, flags: c_int) -> c_int; + + pub fn makeutx(ux: *const utmpx) -> *mut utmpx; + pub fn modutx(ux: *const utmpx) -> *mut utmpx; + pub fn updwtmpx(file: *const c_char, ut: *mut utmpx); + pub fn utmpxname(file: *const c_char) -> c_int; + pub fn getutxent() -> *mut utmpx; + pub fn getutxid(ut: *const utmpx) -> *mut utmpx; + pub fn getutxline(ut: *const utmpx) -> *mut utmpx; + pub fn pututxline(ut: *const utmpx) -> *mut utmpx; + pub fn setutxent(); + pub fn endutxent(); + + pub fn endutent(); + pub fn getutent() -> *mut utmp; + pub fn getutid(u: *const utmp) -> *mut utmp; + pub fn getutline(u: *const utmp) -> *mut utmp; + pub fn pututline(u: *const utmp) -> *mut utmp; + pub fn setutent(); + pub fn utmpname(file: *const c_char) -> c_int; + + pub fn getutmp(ux: *const utmpx, u: *mut utmp); + pub fn getutmpx(u: *const utmp, ux: *mut utmpx); + pub fn updwtmp(file: *const c_char, u: *mut utmp); + + pub fn ntp_adjtime(buf: *mut timex) -> c_int; + pub fn ntp_gettime(buf: *mut ntptimeval) -> c_int; + + pub fn timer_create(clock_id: clockid_t, evp: *mut sigevent, timerid: *mut timer_t) -> c_int; + pub fn timer_delete(timerid: timer_t) -> c_int; + pub fn timer_getoverrun(timerid: timer_t) -> c_int; + pub fn timer_gettime(timerid: timer_t, value: *mut itimerspec) -> c_int; + pub fn timer_settime( + timerid: timer_t, + flags: c_int, + value: *const itimerspec, + ovalue: *mut itimerspec, + ) -> c_int; + + pub fn ucred_get(pid: crate::pid_t) -> *mut ucred_t; + pub fn getpeerucred(fd: c_int, ucred: *mut *mut ucred_t) -> c_int; + + pub fn ucred_free(ucred: *mut ucred_t); + + pub fn ucred_geteuid(ucred: *const ucred_t) -> crate::uid_t; + pub fn ucred_getruid(ucred: *const ucred_t) -> crate::uid_t; + pub fn ucred_getsuid(ucred: *const ucred_t) -> crate::uid_t; + pub fn ucred_getegid(ucred: *const ucred_t) -> crate::gid_t; + pub fn ucred_getrgid(ucred: *const ucred_t) -> crate::gid_t; + pub fn ucred_getsgid(ucred: *const ucred_t) -> crate::gid_t; + pub fn ucred_getgroups(ucred: *const ucred_t, groups: *mut *const crate::gid_t) -> c_int; + pub fn ucred_getpid(ucred: *const ucred_t) -> crate::pid_t; + pub fn ucred_getprojid(ucred: *const ucred_t) -> projid_t; + pub fn ucred_getzoneid(ucred: *const ucred_t) -> zoneid_t; + pub fn ucred_getpflags(ucred: *const ucred_t, flags: c_uint) -> c_uint; + + pub fn ucred_size() -> size_t; + + pub fn pset_create(newpset: *mut crate::psetid_t) -> c_int; + pub fn pset_destroy(pset: crate::psetid_t) -> c_int; + pub fn pset_assign( + pset: crate::psetid_t, + cpu: crate::processorid_t, + opset: *mut psetid_t, + ) -> c_int; + pub fn pset_info( + pset: crate::psetid_t, + tpe: *mut c_int, + numcpus: *mut c_uint, + cpulist: *mut processorid_t, + ) -> c_int; + pub fn pset_bind( + pset: crate::psetid_t, + idtype: crate::idtype_t, + id: crate::id_t, + opset: *mut psetid_t, + ) -> c_int; + pub fn pset_list(pset: *mut psetid_t, numpsets: *mut c_uint) -> c_int; + pub fn pset_setattr(pset: psetid_t, attr: c_uint) -> c_int; + pub fn pset_getattr(pset: psetid_t, attr: *mut c_uint) -> c_int; + pub fn processor_bind( + idtype: crate::idtype_t, + id: crate::id_t, + new_binding: crate::processorid_t, + old_binding: *mut processorid_t, + ) -> c_int; + pub fn p_online(processorid: crate::processorid_t, flag: c_int) -> c_int; + pub fn processor_info(processorid: crate::processorid_t, infop: *mut processor_info_t) + -> c_int; + + pub fn getexecname() -> *const c_char; + + pub fn gethostid() -> c_long; + + pub fn getpflags(flags: c_uint) -> c_uint; + pub fn setpflags(flags: c_uint, value: c_uint) -> c_int; + + pub fn sysinfo(command: c_int, buf: *mut c_char, count: c_long) -> c_int; + + pub fn faccessat(fd: c_int, path: *const c_char, amode: c_int, flag: c_int) -> c_int; + + // #include + #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + pub fn dl_iterate_phdr( + callback: Option< + unsafe extern "C" fn(info: *mut dl_phdr_info, size: usize, data: *mut c_void) -> c_int, + >, + data: *mut c_void, + ) -> c_int; + pub fn getpagesize() -> c_int; + pub fn getpagesizes(pagesize: *mut size_t, nelem: c_int) -> c_int; + pub fn mmapobj( + fd: c_int, + flags: c_uint, + storage: *mut mmapobj_result_t, + elements: *mut c_uint, + arg: *mut c_void, + ) -> c_int; + pub fn meminfo( + inaddr: *const u64, + addr_count: c_int, + info_req: *const c_uint, + info_count: c_int, + outdata: *mut u64, + validity: *mut c_uint, + ) -> c_int; + + pub fn strsep(string: *mut *mut c_char, delim: *const c_char) -> *mut c_char; + + pub fn getisax(array: *mut u32, n: c_uint) -> c_uint; + + pub fn backtrace(buffer: *mut *mut c_void, size: c_int) -> c_int; + pub fn backtrace_symbols(buffer: *const *mut c_void, size: c_int) -> *mut *mut c_char; + pub fn backtrace_symbols_fd(buffer: *const *mut c_void, size: c_int, fd: c_int); + + pub fn getopt_long( + argc: c_int, + argv: *const *mut c_char, + optstring: *const c_char, + longopts: *const option, + longindex: *mut c_int, + ) -> c_int; + + pub fn sync(); + + pub fn aio_cancel(fd: c_int, aiocbp: *mut aiocb) -> c_int; + pub fn aio_error(aiocbp: *const aiocb) -> c_int; + pub fn aio_fsync(op: c_int, aiocbp: *mut aiocb) -> c_int; + pub fn aio_read(aiocbp: *mut aiocb) -> c_int; + pub fn aio_return(aiocbp: *mut aiocb) -> ssize_t; + pub fn aio_suspend( + aiocb_list: *const *const aiocb, + nitems: c_int, + timeout: *const crate::timespec, + ) -> c_int; + pub fn aio_waitn( + aiocb_list: *mut *mut aiocb, + nent: c_uint, + nwait: *mut c_uint, + timeout: *const crate::timespec, + ) -> c_int; + pub fn aio_write(aiocbp: *mut aiocb) -> c_int; + pub fn lio_listio( + mode: c_int, + aiocb_list: *const *mut aiocb, + nitems: c_int, + sevp: *mut sigevent, + ) -> c_int; + + pub fn __major(version: c_int, devnum: crate::dev_t) -> crate::major_t; + pub fn __minor(version: c_int, devnum: crate::dev_t) -> crate::minor_t; + pub fn __makedev( + version: c_int, + majdev: crate::major_t, + mindev: crate::minor_t, + ) -> crate::dev_t; + + pub fn arc4random() -> u32; + pub fn arc4random_buf(buf: *mut c_void, nbytes: size_t); + pub fn arc4random_uniform(upper_bound: u32) -> u32; + + pub fn secure_getenv(name: *const c_char) -> *mut c_char; + + #[cfg_attr(target_os = "solaris", link_name = "__strftime_xpg7")] + pub fn strftime( + s: *mut c_char, + maxsize: size_t, + format: *const c_char, + timeptr: *const crate::tm, + ) -> size_t; + pub fn strftime_l( + s: *mut c_char, + maxsize: size_t, + format: *const c_char, + timeptr: *const crate::tm, + loc: crate::locale_t, + ) -> size_t; +} + +#[link(name = "sendfile")] +extern "C" { + pub fn sendfile(out_fd: c_int, in_fd: c_int, off: *mut off_t, len: size_t) -> ssize_t; + pub fn sendfilev( + fildes: c_int, + vec: *const sendfilevec_t, + sfvcnt: c_int, + xferred: *mut size_t, + ) -> ssize_t; +} + +#[link(name = "lgrp")] +extern "C" { + pub fn lgrp_init(view: lgrp_view_t) -> lgrp_cookie_t; + pub fn lgrp_fini(cookie: lgrp_cookie_t) -> c_int; + pub fn lgrp_affinity_get( + idtype: crate::idtype_t, + id: crate::id_t, + lgrp: crate::lgrp_id_t, + ) -> crate::lgrp_affinity_t; + pub fn lgrp_affinity_set( + idtype: crate::idtype_t, + id: crate::id_t, + lgrp: crate::lgrp_id_t, + aff: lgrp_affinity_t, + ) -> c_int; + pub fn lgrp_cpus( + cookie: crate::lgrp_cookie_t, + lgrp: crate::lgrp_id_t, + cpuids: *mut crate::processorid_t, + count: c_uint, + content: crate::lgrp_content_t, + ) -> c_int; + pub fn lgrp_mem_size( + cookie: crate::lgrp_cookie_t, + lgrp: crate::lgrp_id_t, + tpe: crate::lgrp_mem_size_flag_t, + content: crate::lgrp_content_t, + ) -> crate::lgrp_mem_size_t; + pub fn lgrp_nlgrps(cookie: crate::lgrp_cookie_t) -> c_int; + pub fn lgrp_view(cookie: crate::lgrp_cookie_t) -> crate::lgrp_view_t; + pub fn lgrp_home(idtype: crate::idtype_t, id: crate::id_t) -> crate::lgrp_id_t; + pub fn lgrp_version(version: c_int) -> c_int; + pub fn lgrp_resources( + cookie: crate::lgrp_cookie_t, + lgrp: crate::lgrp_id_t, + lgrps: *mut crate::lgrp_id_t, + count: c_uint, + tpe: crate::lgrp_rsrc_t, + ) -> c_int; + pub fn lgrp_root(cookie: crate::lgrp_cookie_t) -> crate::lgrp_id_t; +} + +pub unsafe fn major(device: crate::dev_t) -> crate::major_t { + __major(NEWDEV, device) +} + +pub unsafe fn minor(device: crate::dev_t) -> crate::minor_t { + __minor(NEWDEV, device) +} + +pub unsafe fn makedev(maj: crate::major_t, min: crate::minor_t) -> crate::dev_t { + __makedev(NEWDEV, maj, min) +} + +mod compat; +pub use self::compat::*; + +cfg_if! { + if #[cfg(target_os = "illumos")] { + mod illumos; + pub use self::illumos::*; + } else if #[cfg(target_os = "solaris")] { + mod solaris; + pub use self::solaris::*; + } else { + // Unknown target_os + } +} + +cfg_if! { + if #[cfg(target_arch = "x86_64")] { + mod x86_64; + mod x86_common; + pub use self::x86_64::*; + pub use self::x86_common::*; + } else if #[cfg(target_arch = "x86")] { + mod x86; + mod x86_common; + pub use self::x86::*; + pub use self::x86_common::*; + } +} diff --git a/http/vendor/libc/src/unix/solarish/solaris.rs b/http/vendor/libc/src/unix/solarish/solaris.rs new file mode 100644 index 0000000..2b9ace5 --- /dev/null +++ b/http/vendor/libc/src/unix/solarish/solaris.rs @@ -0,0 +1,204 @@ +use crate::prelude::*; +use crate::{ + exit_status, + off_t, + termios, + NET_MAC_AWARE, + NET_MAC_AWARE_INHERIT, + PRIV_AWARE_RESET, + PRIV_DEBUG, + PRIV_PFEXEC, + PRIV_XPOLICY, +}; + +pub type door_attr_t = c_uint; +pub type door_id_t = c_ulonglong; +pub type lgrp_affinity_t = c_uint; + +e! { + #[repr(u32)] + pub enum lgrp_rsrc_t { + LGRP_RSRC_CPU = 0, + LGRP_RSRC_MEM = 1, + LGRP_RSRC_TYPES = 2, + } +} + +s! { + pub struct aiocb { + pub aio_fildes: c_int, + pub aio_buf: *mut c_void, + pub aio_nbytes: size_t, + pub aio_offset: off_t, + pub aio_reqprio: c_int, + pub aio_sigevent: crate::sigevent, + pub aio_lio_opcode: c_int, + pub aio_resultp: crate::aio_result_t, + pub aio_state: c_char, + pub aio_returned: c_char, + pub aio__pad1: [c_char; 2], + pub aio_flags: c_int, + } + + pub struct shmid_ds { + pub shm_perm: crate::ipc_perm, + pub shm_segsz: size_t, + pub shm_flags: crate::uintptr_t, + pub shm_lkcnt: c_ushort, + pub shm_lpid: crate::pid_t, + pub shm_cpid: crate::pid_t, + pub shm_nattch: crate::shmatt_t, + pub shm_cnattch: c_ulong, + pub shm_atime: crate::time_t, + pub shm_dtime: crate::time_t, + pub shm_ctime: crate::time_t, + pub shm_amp: *mut c_void, + pub shm_gransize: u64, + pub shm_allocated: u64, + pub shm_pad4: [i64; 1], + } + + pub struct xrs_t { + pub xrs_id: c_ulong, + pub xrs_ptr: *mut c_char, + } + + pub struct utmpx { + pub ut_user: [c_char; _UTMP_USER_LEN], + pub ut_id: [c_char; _UTMP_ID_LEN], + pub ut_line: [c_char; _UTMP_LINE_LEN], + pub ut_pid: crate::pid_t, + pub ut_type: c_short, + pub ut_exit: exit_status, + pub ut_tv: crate::timeval, + pub ut_session: c_int, + pub pad: [c_int; 5], + pub ut_syslen: c_short, + pub ut_host: [c_char; 257], + } +} + +s_no_extra_traits! { + #[repr(packed)] + pub struct door_desc_t__d_data__d_desc { + pub d_descriptor: c_int, + pub d_id: crate::door_id_t, + } + + pub union door_desc_t__d_data { + pub d_desc: door_desc_t__d_data__d_desc, + d_resv: [c_int; 5], /* Check out /usr/include/sys/door.h */ + } + + pub struct door_desc_t { + pub d_attributes: door_attr_t, + pub d_data: door_desc_t__d_data, + } + + pub struct door_arg_t { + pub data_ptr: *const c_char, + pub data_size: size_t, + pub desc_ptr: *const door_desc_t, + pub dec_num: c_uint, + pub rbuf: *const c_char, + pub rsize: size_t, + } +} + +// FIXME(solaris): O_DIRECT and SIGINFO are NOT available on Solaris. +// But in past they were defined here and thus other crates expected them. +// Latest version v0.29.0 of Nix crate still expects this. Since last +// version of Nix crate is almost one year ago let's define these two +// temporarily before new Nix version is released. +pub const O_DIRECT: c_int = 0x2000000; +pub const SIGINFO: c_int = 41; + +pub const _UTMP_USER_LEN: usize = 32; +pub const _UTMP_LINE_LEN: usize = 32; +pub const _UTMP_ID_LEN: usize = 4; + +pub const PORT_SOURCE_POSTWAIT: c_int = 8; +pub const PORT_SOURCE_SIGNAL: c_int = 9; + +pub const AF_LOCAL: c_int = 1; // AF_UNIX +pub const AF_FILE: c_int = 1; // AF_UNIX + +pub const TCP_KEEPIDLE: c_int = 0x1d; +pub const TCP_KEEPINTVL: c_int = 0x1e; +pub const TCP_KEEPCNT: c_int = 0x1f; + +pub const F_DUPFD_CLOEXEC: c_int = 47; +pub const F_DUPFD_CLOFORK: c_int = 49; +pub const F_DUP2FD_CLOEXEC: c_int = 48; +pub const F_DUP2FD_CLOFORK: c_int = 50; + +pub const _PC_LAST: c_int = 102; + +pub const PRIV_PROC_SENSITIVE: c_uint = 0x0008; +pub const PRIV_PFEXEC_AUTH: c_uint = 0x0200; +pub const PRIV_PROC_TPD: c_uint = 0x0400; +pub const PRIV_TPD_UNSAFE: c_uint = 0x0800; +pub const PRIV_PROC_TPD_RESET: c_uint = 0x1000; +pub const PRIV_TPD_KILLABLE: c_uint = 0x2000; + +pub const POSIX_SPAWN_SETSID: c_short = 0x400; + +pub const PRIV_USER: c_uint = PRIV_DEBUG + | PRIV_PROC_SENSITIVE + | NET_MAC_AWARE + | NET_MAC_AWARE_INHERIT + | PRIV_XPOLICY + | PRIV_AWARE_RESET + | PRIV_PFEXEC + | PRIV_PFEXEC_AUTH + | PRIV_PROC_TPD + | PRIV_TPD_UNSAFE + | PRIV_TPD_KILLABLE + | PRIV_PROC_TPD_RESET; + +extern "C" { + // DIFF(main): changed to `*const *mut` in e77f551de9 + pub fn fexecve(fd: c_int, argv: *const *const c_char, envp: *const *const c_char) -> c_int; + + pub fn mincore(addr: *mut c_void, len: size_t, vec: *mut c_char) -> c_int; + + pub fn door_call(d: c_int, params: *mut door_arg_t) -> c_int; + pub fn door_return( + data_ptr: *mut c_char, + data_size: size_t, + desc_ptr: *mut door_desc_t, + num_desc: c_uint, + ) -> c_int; + pub fn door_create( + server_procedure: extern "C" fn( + cookie: *mut c_void, + argp: *mut c_char, + arg_size: size_t, + dp: *mut door_desc_t, + n_desc: c_uint, + ), + cookie: *mut c_void, + attributes: door_attr_t, + ) -> c_int; + + pub fn fattach(fildes: c_int, path: *const c_char) -> c_int; + + pub fn pthread_getattr_np(thread: crate::pthread_t, attr: *mut crate::pthread_attr_t) -> c_int; + + pub fn euidaccess(path: *const c_char, amode: c_int) -> c_int; + + pub fn openpty( + amain: *mut c_int, + asubord: *mut c_int, + name: *mut c_char, + termp: *mut termios, + winp: *mut crate::winsize, + ) -> c_int; + + pub fn forkpty( + amain: *mut c_int, + name: *mut c_char, + termp: *mut termios, + winp: *mut crate::winsize, + ) -> crate::pid_t; +} diff --git a/http/vendor/libc/src/unix/solarish/x86.rs b/http/vendor/libc/src/unix/solarish/x86.rs new file mode 100644 index 0000000..a37ed3d --- /dev/null +++ b/http/vendor/libc/src/unix/solarish/x86.rs @@ -0,0 +1,31 @@ +use crate::prelude::*; + +pub type Elf32_Addr = c_ulong; +pub type Elf32_Half = c_ushort; +pub type Elf32_Off = c_ulong; +pub type Elf32_Sword = c_long; +pub type Elf32_Word = c_ulong; +pub type Elf32_Lword = c_ulonglong; +pub type Elf32_Phdr = __c_anonymous_Elf32_Phdr; + +s! { + pub struct __c_anonymous_Elf32_Phdr { + pub p_type: Elf32_Word, + pub p_offset: Elf32_Off, + pub p_vaddr: Elf32_Addr, + pub p_paddr: Elf32_Addr, + pub p_filesz: Elf32_Word, + pub p_memsz: Elf32_Word, + pub p_flags: Elf32_Word, + pub p_align: Elf32_Word, + } + + pub struct dl_phdr_info { + pub dlpi_addr: Elf32_Addr, + pub dlpi_name: *const c_char, + pub dlpi_phdr: *const Elf32_Phdr, + pub dlpi_phnum: Elf32_Half, + pub dlpi_adds: c_ulonglong, + pub dlpi_subs: c_ulonglong, + } +} diff --git a/http/vendor/libc/src/unix/solarish/x86_64.rs b/http/vendor/libc/src/unix/solarish/x86_64.rs new file mode 100644 index 0000000..a4c4806 --- /dev/null +++ b/http/vendor/libc/src/unix/solarish/x86_64.rs @@ -0,0 +1,154 @@ +use crate::prelude::*; + +cfg_if! { + if #[cfg(target_os = "solaris")] { + use crate::unix::solarish::solaris; + } +} + +pub type greg_t = c_long; + +pub type Elf64_Addr = c_ulong; +pub type Elf64_Half = c_ushort; +pub type Elf64_Off = c_ulong; +pub type Elf64_Sword = c_int; +pub type Elf64_Sxword = c_long; +pub type Elf64_Word = c_uint; +pub type Elf64_Xword = c_ulong; +pub type Elf64_Lword = c_ulong; +pub type Elf64_Phdr = __c_anonymous_Elf64_Phdr; + +s! { + pub struct __c_anonymous_fpchip_state { + pub cw: u16, + pub sw: u16, + pub fctw: u8, + pub __fx_rsvd: u8, + pub fop: u16, + pub rip: u64, + pub rdp: u64, + pub mxcsr: u32, + pub mxcsr_mask: u32, + pub st: [crate::upad128_t; 8], + pub xmm: [crate::upad128_t; 16], + pub __fx_ign: [crate::upad128_t; 6], + pub status: u32, + pub xstatus: u32, + } + + pub struct __c_anonymous_Elf64_Phdr { + pub p_type: crate::Elf64_Word, + pub p_flags: crate::Elf64_Word, + pub p_offset: crate::Elf64_Off, + pub p_vaddr: crate::Elf64_Addr, + pub p_paddr: crate::Elf64_Addr, + pub p_filesz: crate::Elf64_Xword, + pub p_memsz: crate::Elf64_Xword, + pub p_align: crate::Elf64_Xword, + } + + pub struct dl_phdr_info { + pub dlpi_addr: crate::Elf64_Addr, + pub dlpi_name: *const c_char, + pub dlpi_phdr: *const crate::Elf64_Phdr, + pub dlpi_phnum: crate::Elf64_Half, + pub dlpi_adds: c_ulonglong, + pub dlpi_subs: c_ulonglong, + #[cfg(target_os = "solaris")] + pub dlpi_tls_modid: c_ulong, + #[cfg(target_os = "solaris")] + pub dlpi_tls_data: *mut c_void, + } + + pub struct fpregset_t { + pub fp_reg_set: __c_anonymous_fp_reg_set, + } + + pub struct mcontext_t { + pub gregs: [crate::greg_t; 28], + pub fpregs: fpregset_t, + } + + pub struct ucontext_t { + pub uc_flags: c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_sigmask: crate::sigset_t, + pub uc_stack: crate::stack_t, + pub uc_mcontext: mcontext_t, + #[cfg(target_os = "illumos")] + pub uc_brand_data: [*mut c_void; 3], + #[cfg(target_os = "illumos")] + pub uc_xsave: c_long, + #[cfg(target_os = "illumos")] + pub uc_filler: c_long, + #[cfg(target_os = "solaris")] + pub uc_xrs: solaris::xrs_t, + #[cfg(target_os = "solaris")] + pub uc_lwpid: c_uint, + #[cfg(target_os = "solaris")] + pub uc_filler: [c_long; 2], + } +} + +s_no_extra_traits! { + pub union __c_anonymous_fp_reg_set { + pub fpchip_state: __c_anonymous_fpchip_state, + pub f_fpregs: [[u32; 13]; 10], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for __c_anonymous_fp_reg_set { + fn eq(&self, other: &__c_anonymous_fp_reg_set) -> bool { + unsafe { + self.fpchip_state == other.fpchip_state + || self + .f_fpregs + .iter() + .zip(other.f_fpregs.iter()) + .all(|(a, b)| a == b) + } + } + } + impl Eq for __c_anonymous_fp_reg_set {} + impl hash::Hash for __c_anonymous_fp_reg_set { + fn hash(&self, state: &mut H) { + unsafe { + self.f_fpregs.hash(state); + } + } + } + } +} + +// sys/regset.h + +pub const REG_GSBASE: c_int = 27; +pub const REG_FSBASE: c_int = 26; +pub const REG_DS: c_int = 25; +pub const REG_ES: c_int = 24; +pub const REG_GS: c_int = 23; +pub const REG_FS: c_int = 22; +pub const REG_SS: c_int = 21; +pub const REG_RSP: c_int = 20; +pub const REG_RFL: c_int = 19; +pub const REG_CS: c_int = 18; +pub const REG_RIP: c_int = 17; +pub const REG_ERR: c_int = 16; +pub const REG_TRAPNO: c_int = 15; +pub const REG_RAX: c_int = 14; +pub const REG_RCX: c_int = 13; +pub const REG_RDX: c_int = 12; +pub const REG_RBX: c_int = 11; +pub const REG_RBP: c_int = 10; +pub const REG_RSI: c_int = 9; +pub const REG_RDI: c_int = 8; +pub const REG_R8: c_int = 7; +pub const REG_R9: c_int = 6; +pub const REG_R10: c_int = 5; +pub const REG_R11: c_int = 4; +pub const REG_R12: c_int = 3; +pub const REG_R13: c_int = 2; +pub const REG_R14: c_int = 1; +pub const REG_R15: c_int = 0; diff --git a/http/vendor/libc/src/unix/solarish/x86_common.rs b/http/vendor/libc/src/unix/solarish/x86_common.rs new file mode 100644 index 0000000..e72a22a --- /dev/null +++ b/http/vendor/libc/src/unix/solarish/x86_common.rs @@ -0,0 +1,69 @@ +// AT_SUN_HWCAP +pub const AV_386_FPU: u32 = 0x00001; +pub const AV_386_TSC: u32 = 0x00002; +pub const AV_386_CX8: u32 = 0x00004; +pub const AV_386_SEP: u32 = 0x00008; +pub const AV_386_AMD_SYSC: u32 = 0x00010; +pub const AV_386_CMOV: u32 = 0x00020; +pub const AV_386_MMX: u32 = 0x00040; +pub const AV_386_AMD_MMX: u32 = 0x00080; +pub const AV_386_AMD_3DNow: u32 = 0x00100; +pub const AV_386_AMD_3DNowx: u32 = 0x00200; +pub const AV_386_FXSR: u32 = 0x00400; +pub const AV_386_SSE: u32 = 0x00800; +pub const AV_386_SSE2: u32 = 0x01000; +pub const AV_386_CX16: u32 = 0x10000; +pub const AV_386_AHF: u32 = 0x20000; +pub const AV_386_TSCP: u32 = 0x40000; +pub const AV_386_AMD_SSE4A: u32 = 0x80000; +pub const AV_386_POPCNT: u32 = 0x100000; +pub const AV_386_AMD_LZCNT: u32 = 0x200000; +pub const AV_386_SSSE3: u32 = 0x400000; +pub const AV_386_SSE4_1: u32 = 0x800000; +pub const AV_386_SSE4_2: u32 = 0x1000000; +pub const AV_386_MOVBE: u32 = 0x2000000; +pub const AV_386_AES: u32 = 0x4000000; +pub const AV_386_PCLMULQDQ: u32 = 0x8000000; +pub const AV_386_XSAVE: u32 = 0x10000000; +pub const AV_386_AVX: u32 = 0x20000000; +cfg_if! { + if #[cfg(target_os = "illumos")] { + pub const AV_386_VMX: u32 = 0x40000000; + pub const AV_386_AMD_SVM: u32 = 0x80000000; + // AT_SUN_HWCAP2 + pub const AV_386_2_F16C: u32 = 0x00000001; + pub const AV_386_2_RDRAND: u32 = 0x00000002; + pub const AV_386_2_BMI1: u32 = 0x00000004; + pub const AV_386_2_BMI2: u32 = 0x00000008; + pub const AV_386_2_FMA: u32 = 0x00000010; + pub const AV_386_2_AVX2: u32 = 0x00000020; + pub const AV_386_2_ADX: u32 = 0x00000040; + pub const AV_386_2_RDSEED: u32 = 0x00000080; + pub const AV_386_2_AVX512F: u32 = 0x00000100; + pub const AV_386_2_AVX512DQ: u32 = 0x00000200; + pub const AV_386_2_AVX512IFMA: u32 = 0x00000400; + pub const AV_386_2_AVX512PF: u32 = 0x00000800; + pub const AV_386_2_AVX512ER: u32 = 0x00001000; + pub const AV_386_2_AVX512CD: u32 = 0x00002000; + pub const AV_386_2_AVX512BW: u32 = 0x00004000; + pub const AV_386_2_AVX512VL: u32 = 0x00008000; + pub const AV_386_2_AVX512VBMI: u32 = 0x00010000; + pub const AV_386_2_AVX512VPOPCDQ: u32 = 0x00020000; + pub const AV_386_2_AVX512_4NNIW: u32 = 0x00040000; + pub const AV_386_2_AVX512_4FMAPS: u32 = 0x00080000; + pub const AV_386_2_SHA: u32 = 0x00100000; + pub const AV_386_2_FSGSBASE: u32 = 0x00200000; + pub const AV_386_2_CLFLUSHOPT: u32 = 0x00400000; + pub const AV_386_2_CLWB: u32 = 0x00800000; + pub const AV_386_2_MONITORX: u32 = 0x01000000; + pub const AV_386_2_CLZERO: u32 = 0x02000000; + pub const AV_386_2_AVX512_VNNI: u32 = 0x04000000; + pub const AV_386_2_VPCLMULQDQ: u32 = 0x08000000; + pub const AV_386_2_VAES: u32 = 0x10000000; + // AT_SUN_FPTYPE + pub const AT_386_FPINFO_NONE: u32 = 0; + pub const AT_386_FPINFO_FXSAVE: u32 = 1; + pub const AT_386_FPINFO_XSAVE: u32 = 2; + pub const AT_386_FPINFO_XSAVE_AMD: u32 = 3; + } +} diff --git a/http/vendor/libc/src/vxworks/aarch64.rs b/http/vendor/libc/src/vxworks/aarch64.rs new file mode 100644 index 0000000..376783c --- /dev/null +++ b/http/vendor/libc/src/vxworks/aarch64.rs @@ -0,0 +1 @@ +pub type wchar_t = u32; diff --git a/http/vendor/libc/src/vxworks/arm.rs b/http/vendor/libc/src/vxworks/arm.rs new file mode 100644 index 0000000..376783c --- /dev/null +++ b/http/vendor/libc/src/vxworks/arm.rs @@ -0,0 +1 @@ +pub type wchar_t = u32; diff --git a/http/vendor/libc/src/vxworks/mod.rs b/http/vendor/libc/src/vxworks/mod.rs new file mode 100644 index 0000000..bc4d536 --- /dev/null +++ b/http/vendor/libc/src/vxworks/mod.rs @@ -0,0 +1,2477 @@ +//! Interface to VxWorks C library + +use core::ptr::null_mut; + +use crate::prelude::*; + +extern_ty! { + pub enum DIR {} +} + +pub type intmax_t = i64; +pub type uintmax_t = u64; + +pub type uintptr_t = usize; +pub type intptr_t = isize; +pub type ptrdiff_t = isize; +pub type size_t = crate::uintptr_t; +pub type ssize_t = intptr_t; +pub type speed_t = c_uint; +pub type tcflag_t = c_uint; +pub type clock_t = c_long; +pub type cc_t = c_uchar; + +pub type pid_t = c_int; +pub type in_addr_t = u32; +pub type sighandler_t = size_t; +pub type cpuset_t = u32; + +pub type blkcnt_t = c_long; +pub type blksize_t = c_long; +pub type ino_t = c_ulong; + +pub type rlim_t = c_ulong; +pub type suseconds_t = c_long; +pub type time_t = c_longlong; + +pub type errno_t = c_int; + +pub type useconds_t = c_ulong; + +pub type socklen_t = c_uint; + +pub type pthread_t = c_ulong; + +pub type clockid_t = c_int; + +//defined for the structs +pub type dev_t = c_ulong; +pub type mode_t = c_int; +pub type nlink_t = c_ulong; +pub type uid_t = c_ushort; +pub type gid_t = c_ushort; +pub type sigset_t = c_ulonglong; +pub type key_t = c_long; + +pub type nfds_t = c_uint; +pub type stat64 = crate::stat; + +pub type pthread_key_t = c_ulong; + +// From b_off_t.h +pub type off_t = c_longlong; +pub type off64_t = off_t; + +// From b_BOOL.h +pub type BOOL = c_int; + +// From vxWind.h .. +pub type _Vx_OBJ_HANDLE = c_int; +pub type _Vx_TASK_ID = crate::_Vx_OBJ_HANDLE; +pub type _Vx_MSG_Q_ID = crate::_Vx_OBJ_HANDLE; +pub type _Vx_SEM_ID_KERNEL = crate::_Vx_OBJ_HANDLE; +pub type _Vx_RTP_ID = crate::_Vx_OBJ_HANDLE; +pub type _Vx_SD_ID = crate::_Vx_OBJ_HANDLE; +pub type _Vx_CONDVAR_ID = crate::_Vx_OBJ_HANDLE; +pub type _Vx_SEM_ID = *mut crate::_Vx_semaphore; +pub type OBJ_HANDLE = crate::_Vx_OBJ_HANDLE; +pub type TASK_ID = crate::OBJ_HANDLE; +pub type MSG_Q_ID = crate::OBJ_HANDLE; +pub type SEM_ID_KERNEL = crate::OBJ_HANDLE; +pub type RTP_ID = crate::OBJ_HANDLE; +pub type SD_ID = crate::OBJ_HANDLE; +pub type CONDVAR_ID = crate::OBJ_HANDLE; +pub type STATUS = crate::OBJ_HANDLE; + +// From vxTypes.h +pub type _Vx_usr_arg_t = isize; +pub type _Vx_exit_code_t = isize; +pub type _Vx_ticks_t = c_uint; +pub type _Vx_ticks64_t = c_ulonglong; + +pub type sa_family_t = c_uchar; + +// mqueue.h +pub type mqd_t = c_int; + +extern_ty! { + pub enum _Vx_semaphore {} +} + +impl siginfo_t { + pub unsafe fn si_addr(&self) -> *mut c_void { + self.si_addr + } + + pub unsafe fn si_value(&self) -> crate::sigval { + self.si_value + } + + pub unsafe fn si_pid(&self) -> crate::pid_t { + self.si_pid + } + + pub unsafe fn si_uid(&self) -> crate::uid_t { + self.si_uid + } + + pub unsafe fn si_status(&self) -> c_int { + self.si_status + } +} + +s! { + // b_pthread_condattr_t.h + pub struct pthread_condattr_t { + pub condAttrStatus: c_int, + pub condAttrPshared: c_int, + pub condAttrClockId: crate::clockid_t, + } + + // b_pthread_cond_t.h + pub struct pthread_cond_t { + pub condSemId: crate::_Vx_SEM_ID, + pub condValid: c_int, + pub condInitted: c_int, + pub condRefCount: c_int, + pub condMutex: *mut crate::pthread_mutex_t, + pub condAttr: crate::pthread_condattr_t, + pub condSemName: [c_char; _PTHREAD_SHARED_SEM_NAME_MAX], + } + + // b_pthread_rwlockattr_t.h + pub struct pthread_rwlockattr_t { + pub rwlockAttrStatus: c_int, + pub rwlockAttrPshared: c_int, + pub rwlockAttrMaxReaders: c_uint, + pub rwlockAttrConformOpt: c_uint, + } + + // b_pthread_rwlock_t.h + pub struct pthread_rwlock_t { + pub rwlockSemId: crate::_Vx_SEM_ID, + pub rwlockReadersRefCount: c_uint, + pub rwlockValid: c_int, + pub rwlockInitted: c_int, + pub rwlockAttr: crate::pthread_rwlockattr_t, + pub rwlockSemName: [c_char; _PTHREAD_SHARED_SEM_NAME_MAX], + } + + // b_struct_timeval.h + #[derive(Default)] + pub struct timeval { + pub tv_sec: crate::time_t, + pub tv_usec: crate::suseconds_t, + } + + // socket.h + pub struct linger { + pub l_onoff: c_int, + pub l_linger: c_int, + } + + pub struct sockaddr { + pub sa_len: c_uchar, + pub sa_family: sa_family_t, + pub sa_data: [c_char; 14], + } + + pub struct iovec { + pub iov_base: *mut c_void, + pub iov_len: size_t, + } + + pub struct msghdr { + pub msg_name: *mut c_void, + pub msg_namelen: socklen_t, + pub msg_iov: *mut iovec, + pub msg_iovlen: c_int, + pub msg_control: *mut c_void, + pub msg_controllen: socklen_t, + pub msg_flags: c_int, + } + + pub struct cmsghdr { + pub cmsg_len: socklen_t, + pub cmsg_level: c_int, + pub cmsg_type: c_int, + } + + // poll.h + pub struct pollfd { + pub fd: c_int, + pub events: c_short, + pub revents: c_short, + } + + // resource.h + pub struct rlimit { + pub rlim_cur: crate::rlim_t, + pub rlim_max: crate::rlim_t, + } + + // stat.h + pub struct stat { + pub st_dev: crate::dev_t, + pub st_ino: crate::ino_t, + pub st_mode: mode_t, + pub st_nlink: crate::nlink_t, + pub st_uid: crate::uid_t, + pub st_gid: crate::gid_t, + pub st_rdev: crate::dev_t, + pub st_size: off_t, + #[cfg(not(vxworks_lt_25_09))] + pub st_atim: timespec, + #[cfg(vxworks_lt_25_09)] + pub st_atime: crate::time_t, + #[cfg(not(vxworks_lt_25_09))] + pub st_mtim: timespec, + #[cfg(vxworks_lt_25_09)] + pub st_mtime: crate::time_t, + #[cfg(not(vxworks_lt_25_09))] + pub st_ctim: timespec, + #[cfg(vxworks_lt_25_09)] + pub st_ctime: crate::time_t, + pub st_blksize: crate::blksize_t, + pub st_blocks: crate::blkcnt_t, + pub st_attrib: c_uchar, + st_reserved1: Padding, + st_reserved2: Padding, + st_reserved3: Padding, + st_reserved4: Padding, + } + + pub struct fsid_t { + val: [c_long; 2], + } + + pub struct statfs { + pub f_type: c_long, + pub f_bsize: c_long, + pub f_blocks: c_long, + pub f_bfree: c_long, + pub f_bavail: c_long, + pub f_files: c_long, + pub f_ffree: c_long, + pub f_fsid: crate::fsid_t, + f_spare: Padding<[c_long; 7]>, + } + + //b_struct__Timespec.h + pub struct _Timespec { + pub tv_sec: crate::time_t, + pub tv_nsec: c_long, + } + + // b_struct__Sched_param.h + pub struct sched_param { + pub sched_priority: c_int, /* scheduling priority */ + pub sched_ss_low_priority: c_int, /* low scheduling priority */ + pub sched_ss_repl_period: crate::timespec, /* replenishment period */ + pub sched_ss_init_budget: crate::timespec, /* initial budget */ + pub sched_ss_max_repl: c_int, /* max pending replenishment */ + } + + // b_struct__Sched_param.h + pub struct _Sched_param { + pub sched_priority: c_int, /* scheduling priority */ + pub sched_ss_low_priority: c_int, /* low scheduling priority */ + pub sched_ss_repl_period: crate::_Timespec, /* replenishment period */ + pub sched_ss_init_budget: crate::_Timespec, /* initial budget */ + pub sched_ss_max_repl: c_int, /* max pending replenishment */ + } + + // b_pthread_attr_t.h + pub struct pthread_attr_t { + pub threadAttrStatus: c_int, + pub threadAttrStacksize: size_t, + pub threadAttrStackaddr: *mut c_void, + pub threadAttrGuardsize: size_t, + pub threadAttrDetachstate: c_int, + pub threadAttrContentionscope: c_int, + pub threadAttrInheritsched: c_int, + pub threadAttrSchedpolicy: c_int, + pub threadAttrName: *mut c_char, + pub threadAttrOptions: c_int, + pub threadAttrSchedparam: crate::_Sched_param, + } + + // signal.h + + pub struct sigaction { + #[cfg(vxworks_lt_25_09)] + pub sa_u: crate::sa_u_t, + #[cfg(not(vxworks_lt_25_09))] + pub sa_sigaction: crate::sighandler_t, + pub sa_mask: crate::sigset_t, + pub sa_flags: c_int, + } + + // b_stack_t.h + pub struct stack_t { + pub ss_sp: *mut c_void, + pub ss_size: size_t, + pub ss_flags: c_int, + } + + // signal.h + pub struct siginfo_t { + pub si_signo: c_int, + pub si_code: c_int, + pub si_value: crate::sigval, + pub si_errno: c_int, + pub si_status: c_int, + pub si_addr: *mut c_void, + pub si_uid: crate::uid_t, + pub si_pid: crate::pid_t, + } + + // pthread.h (krnl) + // b_pthread_mutexattr_t.h (usr) + pub struct pthread_mutexattr_t { + mutexAttrStatus: c_int, + mutexAttrPshared: c_int, + mutexAttrProtocol: c_int, + mutexAttrPrioceiling: c_int, + mutexAttrType: c_int, + } + + // pthread.h (krnl) + // b_pthread_mutex_t.h (usr) + pub struct pthread_mutex_t { + pub mutexSemId: crate::_Vx_SEM_ID, /*_Vx_SEM_ID ..*/ + pub mutexValid: c_int, + pub mutexInitted: c_int, + pub mutexCondRefCount: c_int, + pub mutexSavPriority: c_int, + pub mutexAttr: crate::pthread_mutexattr_t, + pub mutexSemName: [c_char; _PTHREAD_SHARED_SEM_NAME_MAX], + } + + // b_struct_timespec.h + #[derive(Default)] + pub struct timespec { + pub tv_sec: crate::time_t, + pub tv_nsec: c_long, + } + + // time.h + pub struct tm { + pub tm_sec: c_int, + pub tm_min: c_int, + pub tm_hour: c_int, + pub tm_mday: c_int, + pub tm_mon: c_int, + pub tm_year: c_int, + pub tm_wday: c_int, + pub tm_yday: c_int, + pub tm_isdst: c_int, + } + + // sys/times.h + pub struct tms { + pub tms_utime: crate::clock_t, + pub tms_stime: crate::clock_t, + pub tms_cutime: crate::clock_t, + pub tms_cstime: crate::clock_t, + } + + // utime.h + pub struct utimbuf { + pub actime: time_t, + pub modtime: time_t, + } + + // in.h + pub struct in_addr { + pub s_addr: in_addr_t, + } + + // in.h + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + // in6.h + #[repr(align(4))] + pub struct in6_addr { + pub s6_addr: [u8; 16], + } + + // in6.h + pub struct ipv6_mreq { + pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_interface: c_uint, + } + + // netdb.h + pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: size_t, + pub ai_canonname: *mut c_char, + pub ai_addr: *mut crate::sockaddr, + pub ai_next: *mut crate::addrinfo, + } + + // netdb.h + pub struct servent { + pub s_name: *mut c_char, + pub s_aliases: *mut *mut c_char, + pub s_port: c_int, + pub s_proto: *mut c_char, + } + + // netdb.h + pub struct protoent { + pub p_name: *mut c_char, + pub p_aliases: *mut *mut c_char, + pub p_proto: c_int, + } + + // netdb.h + pub struct hostent { + pub h_name: *mut c_char, + pub h_aliases: *mut *mut c_char, + pub h_addrtype: c_int, + pub h_length: c_int, + pub h_addr_list: *mut *mut c_char, + } + + // in.h + pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: u8, + pub sin_port: u16, + pub sin_addr: crate::in_addr, + pub sin_zero: [c_char; 8], + } + + // in6.h + pub struct sockaddr_in6 { + pub sin6_len: u8, + pub sin6_family: u8, + pub sin6_port: u16, + pub sin6_flowinfo: u32, + pub sin6_addr: crate::in6_addr, + pub sin6_scope_id: u32, + } + + pub struct Dl_info { + pub dli_fname: *const c_char, + pub dli_fbase: *mut c_void, + pub dli_sname: *const c_char, + pub dli_saddr: *mut c_void, + } + + pub struct mq_attr { + pub mq_maxmsg: c_long, + pub mq_msgsize: c_long, + pub mq_flags: c_long, + pub mq_curmsgs: c_long, + } + + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: c_longlong, + pub l_len: c_longlong, + pub l_pid: c_long, + } + + pub struct winsize { + pub ws_row: c_ushort, + pub ws_col: c_ushort, + pub ws_xpixel: c_ushort, + pub ws_ypixel: c_ushort, + } + + pub struct termios { + pub c_iflag: crate::tcflag_t, + pub c_oflag: crate::tcflag_t, + pub c_cflag: crate::tcflag_t, + pub c_lflag: crate::tcflag_t, + pub c_cc: [crate::cc_t; crate::NCCS], + pub c_ispeed: crate::speed_t, + pub c_ospeed: crate::speed_t, + } + + pub struct rusage { + pub ru_utime: timeval, + pub ru_stime: timeval, + pub ru_maxrss: c_long, + pub ru_ixrss: c_long, + pub ru_idrss: c_long, + pub ru_isrss: c_long, + pub ru_minflt: c_long, + pub ru_majflt: c_long, + pub ru_nswap: c_long, + pub ru_inblock: c_long, + pub ru_oublock: c_long, + pub ru_msgsnd: c_long, + pub ru_msgrcv: c_long, + pub ru_nsignals: c_long, + pub ru_nvcsw: c_long, + pub ru_nivcsw: c_long, + } + + pub struct lconv { + pub currency_symbol: *mut c_char, + pub int_curr_symbol: *mut c_char, + pub mon_decimal_point: *mut c_char, + pub mon_grouping: *mut c_char, + pub mon_thousands_sep: *mut c_char, + pub negative_sign: *mut c_char, + pub positive_sign: *mut c_char, + pub frac_digits: c_char, + pub n_cs_precedes: c_char, + pub n_sep_by_space: c_char, + pub n_sign_posn: c_char, + pub p_cs_precedes: c_char, + pub p_sep_by_space: c_char, + pub p_sign_posn: c_char, + pub int_frac_digits: c_char, + pub int_n_cs_precedes: c_char, + pub int_n_sep_by_space: c_char, + pub int_n_sign_posn: c_char, + pub int_p_cs_precedes: c_char, + pub int_p_sep_by_space: c_char, + pub int_p_sign_posn: c_char, + pub decimal_point: *mut c_char, + pub grouping: *mut c_char, + pub thousands_sep: *mut c_char, + pub _Frac_grouping: *mut c_char, + pub _Frac_sep: *mut c_char, + pub _False: *mut c_char, + pub _True: *mut c_char, + + pub _No: *mut c_char, + pub _Yes: *mut c_char, + } + + // grp.h + pub struct group { + pub gr_name: *mut c_char, + pub gr_passwd: *mut c_char, + pub gr_gid: c_int, + pub gr_mem: *mut *mut c_char, + } + + pub struct utsname { + pub sysname: [c_char; 80], + pub nodename: [c_char; 256], + pub release: [c_char; 80], + pub version: [c_char; 256], + pub machine: [c_char; 256], + pub endian: [c_char; 80], + pub kernelversion: [c_char; 80], + pub releaseversion: [c_char; 80], + pub processor: [c_char; 80], + pub bsprevision: [c_char; 80], + pub builddate: [c_char; 80], + } +} + +s_no_extra_traits! { + // dirent.h + pub struct dirent { + pub d_ino: crate::ino_t, + pub d_name: [c_char; _PARM_NAME_MAX as usize + 1], + pub d_type: c_uchar, + } + + pub struct sockaddr_un { + pub sun_len: u8, + pub sun_family: sa_family_t, + pub sun_path: [c_char; 104], + } + + // rtpLibCommon.h + pub struct RTP_DESC { + pub status: c_int, + pub options: u32, + pub entrAddr: *mut c_void, + pub initTaskId: crate::TASK_ID, + pub parentId: crate::RTP_ID, + pub pathName: [c_char; VX_RTP_NAME_LENGTH as usize + 1], + pub taskCnt: c_int, + pub textStart: *mut c_void, + pub textEnd: *mut c_void, + } + // socket.h + pub struct sockaddr_storage { + pub ss_len: c_uchar, + pub ss_family: crate::sa_family_t, + __ss_pad1: Padding<[c_char; _SS_PAD1SIZE]>, + __ss_align: i32, + __ss_pad2: Padding<[c_char; _SS_PAD2SIZE]>, + } + + pub union sa_u_t { + pub sa_handler: Option !>, + pub sa_sigaction: + Option !>, + } + + pub union sigval { + pub sival_int: c_int, + pub sival_ptr: *mut c_void, + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for sa_u_t { + fn eq(&self, other: &sa_u_t) -> bool { + unsafe { + let h1 = match self.sa_handler { + Some(handler) => handler as usize, + None => 0 as usize, + }; + let h2 = match other.sa_handler { + Some(handler) => handler as usize, + None => 0 as usize, + }; + h1 == h2 + } + } + } + impl Eq for sa_u_t {} + impl hash::Hash for sa_u_t { + fn hash(&self, state: &mut H) { + unsafe { + let h = match self.sa_handler { + Some(handler) => handler as usize, + None => 0 as usize, + }; + h.hash(state) + } + } + } + + impl PartialEq for sigval { + fn eq(&self, other: &sigval) -> bool { + unsafe { self.sival_ptr as usize == other.sival_ptr as usize } + } + } + impl Eq for sigval {} + impl hash::Hash for sigval { + fn hash(&self, state: &mut H) { + unsafe { (self.sival_ptr as usize).hash(state) }; + } + } + } +} + +pub const EXIT_SUCCESS: c_int = 0; +pub const EXIT_FAILURE: c_int = 1; + +pub const EAI_SERVICE: c_int = 9; +pub const EAI_SOCKTYPE: c_int = 10; +pub const EAI_SYSTEM: c_int = 11; + +pub const INT_MAX: c_int = 0x7fffffff; +pub const INT_MIN: c_int = -INT_MAX - 1; + +// FIXME(vxworks): This is not defined in vxWorks, but we have to define it here +// to make the building pass for getrandom and std +pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); + +//Clock Lib Stuff +pub const CLOCK_REALTIME: c_int = 0x0; +pub const CLOCK_MONOTONIC: c_int = 0x1; +pub const CLOCK_PROCESS_CPUTIME_ID: c_int = 0x2; +pub const CLOCK_THREAD_CPUTIME_ID: c_int = 0x3; +pub const TIMER_ABSTIME: c_int = 0x1; +pub const TIMER_RELTIME: c_int = 0x0; + +// PTHREAD STUFF +pub const PTHREAD_INITIALIZED_OBJ: c_int = 0xF70990EF; +pub const PTHREAD_DESTROYED_OBJ: c_int = -1; +pub const PTHREAD_VALID_OBJ: c_int = 0xEC542A37; +pub const PTHREAD_INVALID_OBJ: c_int = -1; +pub const PTHREAD_UNUSED_YET_OBJ: c_int = -1; + +pub const PTHREAD_PRIO_NONE: c_int = 0; +pub const PTHREAD_PRIO_INHERIT: c_int = 1; +pub const PTHREAD_PRIO_PROTECT: c_int = 2; + +pub const PTHREAD_MUTEX_NORMAL: c_int = 0; +pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 1; +pub const PTHREAD_MUTEX_RECURSIVE: c_int = 2; +pub const PTHREAD_MUTEX_DEFAULT: c_int = PTHREAD_MUTEX_NORMAL; +pub const PTHREAD_STACK_MIN: usize = 4096; +pub const _PTHREAD_SHARED_SEM_NAME_MAX: usize = 30; + +//sched.h +pub const SCHED_FIFO: c_int = 0x01; +pub const SCHED_RR: c_int = 0x02; +pub const SCHED_OTHER: c_int = 0x04; +pub const SCHED_SPORADIC: c_int = 0x08; +pub const PRIO_PROCESS: c_uint = 0; +pub const SCHED_FIFO_HIGH_PRI: c_int = 255; +pub const SCHED_FIFO_LOW_PRI: c_int = 0; +pub const SCHED_RR_HIGH_PRI: c_int = 255; +pub const SCHED_RR_LOW_PRI: c_int = 0; +pub const SCHED_SPORADIC_HIGH_PRI: c_int = 255; +pub const SCHED_SPORADIC_LOW_PRI: c_int = 0; + +// ERRNO STUFF +pub const ERROR: c_int = -1; +pub const OK: c_int = 0; +pub const EPERM: c_int = 1; /* Not owner */ +pub const ENOENT: c_int = 2; /* No such file or directory */ +pub const ESRCH: c_int = 3; /* No such process */ +pub const EINTR: c_int = 4; /* Interrupted system call */ +pub const EIO: c_int = 5; /* I/O error */ +pub const ENXIO: c_int = 6; /* No such device or address */ +pub const E2BIG: c_int = 7; /* Arg list too long */ +pub const ENOEXEC: c_int = 8; /* Exec format error */ +pub const EBADF: c_int = 9; /* Bad file number */ +pub const ECHILD: c_int = 10; /* No children */ +pub const EAGAIN: c_int = 11; /* No more processes */ +pub const ENOMEM: c_int = 12; /* Not enough core */ +pub const EACCES: c_int = 13; /* Permission denied */ +pub const EFAULT: c_int = 14; +pub const ENOTEMPTY: c_int = 15; +pub const EBUSY: c_int = 16; +pub const EEXIST: c_int = 17; +pub const EXDEV: c_int = 18; +pub const ENODEV: c_int = 19; +pub const ENOTDIR: c_int = 20; +pub const EISDIR: c_int = 21; +pub const EINVAL: c_int = 22; +pub const ENFILE: c_int = 23; +pub const EMFILE: c_int = 24; +pub const ENOTTY: c_int = 25; +pub const ENAMETOOLONG: c_int = 26; +pub const EFBIG: c_int = 27; +pub const ENOSPC: c_int = 28; +pub const ESPIPE: c_int = 29; +pub const EROFS: c_int = 30; +pub const EMLINK: c_int = 31; +pub const EPIPE: c_int = 32; +pub const EDEADLK: c_int = 33; +pub const ENOLCK: c_int = 34; +pub const ENOTSUP: c_int = 35; +pub const EMSGSIZE: c_int = 36; +pub const EDOM: c_int = 37; +pub const ERANGE: c_int = 38; +pub const EDOOM: c_int = 39; +pub const EDESTADDRREQ: c_int = 40; +pub const EPROTOTYPE: c_int = 41; +pub const ENOPROTOOPT: c_int = 42; +pub const EPROTONOSUPPORT: c_int = 43; +pub const ESOCKTNOSUPPORT: c_int = 44; +pub const EOPNOTSUPP: c_int = 45; +pub const EPFNOSUPPORT: c_int = 46; +pub const EAFNOSUPPORT: c_int = 47; +pub const EADDRINUSE: c_int = 48; +pub const EADDRNOTAVAIL: c_int = 49; +pub const ENOTSOCK: c_int = 50; +pub const ENETUNREACH: c_int = 51; +pub const ENETRESET: c_int = 52; +pub const ECONNABORTED: c_int = 53; +pub const ECONNRESET: c_int = 54; +pub const ENOBUFS: c_int = 55; +pub const EISCONN: c_int = 56; +pub const ENOTCONN: c_int = 57; +pub const ESHUTDOWN: c_int = 58; +pub const ETOOMANYREFS: c_int = 59; +pub const ETIMEDOUT: c_int = 60; +pub const ECONNREFUSED: c_int = 61; +pub const ENETDOWN: c_int = 62; +pub const ETXTBSY: c_int = 63; +pub const ELOOP: c_int = 64; +pub const EHOSTUNREACH: c_int = 65; +pub const ENOTBLK: c_int = 66; +pub const EHOSTDOWN: c_int = 67; +pub const EINPROGRESS: c_int = 68; +pub const EALREADY: c_int = 69; +pub const EWOULDBLOCK: c_int = 70; +pub const ENOSYS: c_int = 71; +pub const ECANCELED: c_int = 72; +pub const ENOSR: c_int = 74; +pub const ENOSTR: c_int = 75; +pub const EPROTO: c_int = 76; +pub const EBADMSG: c_int = 77; +pub const ENODATA: c_int = 78; +pub const ETIME: c_int = 79; +pub const ENOMSG: c_int = 80; +pub const EFPOS: c_int = 81; +pub const EILSEQ: c_int = 82; +pub const EDQUOT: c_int = 83; +pub const EIDRM: c_int = 84; +pub const EOVERFLOW: c_int = 85; +pub const EMULTIHOP: c_int = 86; +pub const ENOLINK: c_int = 87; +pub const ESTALE: c_int = 88; +pub const EOWNERDEAD: c_int = 89; +pub const ENOTRECOVERABLE: c_int = 90; + +// NFS errnos: Refer to pkgs_v2/storage/fs/nfs/h/nfs/nfsCommon.h +const M_nfsStat: c_int = 48 << 16; +enum nfsstat { + NFSERR_REMOTE = 71, + NFSERR_WFLUSH = 99, + NFSERR_BADHANDLE = 10001, + NFSERR_NOT_SYNC = 10002, + NFSERR_BAD_COOKIE = 10003, + NFSERR_TOOSMALL = 10005, + NFSERR_BADTYPE = 10007, + NFSERR_JUKEBOX = 10008, +} + +pub const S_nfsLib_NFS_OK: c_int = OK; +pub const S_nfsLib_NFSERR_PERM: c_int = EPERM; +pub const S_nfsLib_NFSERR_NOENT: c_int = ENOENT; +pub const S_nfsLib_NFSERR_IO: c_int = EIO; +pub const S_nfsLib_NFSERR_NXIO: c_int = ENXIO; +pub const S_nfsLib_NFSERR_ACCESS: c_int = EACCES; +pub const S_nfsLib_NFSERR_EXIST: c_int = EEXIST; +pub const S_nfsLib_NFSERR_ENODEV: c_int = ENODEV; +pub const S_nfsLib_NFSERR_NOTDIR: c_int = ENOTDIR; +pub const S_nfsLib_NFSERR_ISDIR: c_int = EISDIR; +pub const S_nfsLib_NFSERR_INVAL: c_int = EINVAL; +pub const S_nfsLib_NFSERR_FBIG: c_int = EFBIG; +pub const S_nfsLib_NFSERR_NOSPC: c_int = ENOSPC; +pub const S_nfsLib_NFSERR_ROFS: c_int = EROFS; +pub const S_nfsLib_NFSERR_NAMETOOLONG: c_int = ENAMETOOLONG; +pub const S_nfsLib_NFSERR_NOTEMPTY: c_int = ENOTEMPTY; +pub const S_nfsLib_NFSERR_DQUOT: c_int = EDQUOT; +pub const S_nfsLib_NFSERR_STALE: c_int = ESTALE; +pub const S_nfsLib_NFSERR_WFLUSH: c_int = M_nfsStat | nfsstat::NFSERR_WFLUSH as c_int; +pub const S_nfsLib_NFSERR_REMOTE: c_int = M_nfsStat | nfsstat::NFSERR_REMOTE as c_int; +pub const S_nfsLib_NFSERR_BADHANDLE: c_int = M_nfsStat | nfsstat::NFSERR_BADHANDLE as c_int; +pub const S_nfsLib_NFSERR_NOT_SYNC: c_int = M_nfsStat | nfsstat::NFSERR_NOT_SYNC as c_int; +pub const S_nfsLib_NFSERR_BAD_COOKIE: c_int = M_nfsStat | nfsstat::NFSERR_BAD_COOKIE as c_int; +pub const S_nfsLib_NFSERR_NOTSUPP: c_int = EOPNOTSUPP; +pub const S_nfsLib_NFSERR_TOOSMALL: c_int = M_nfsStat | nfsstat::NFSERR_TOOSMALL as c_int; +pub const S_nfsLib_NFSERR_SERVERFAULT: c_int = EIO; +pub const S_nfsLib_NFSERR_BADTYPE: c_int = M_nfsStat | nfsstat::NFSERR_BADTYPE as c_int; +pub const S_nfsLib_NFSERR_JUKEBOX: c_int = M_nfsStat | nfsstat::NFSERR_JUKEBOX as c_int; + +// internal offset values for below constants +const taskErrorBase: c_int = 0x00030000; +const semErrorBase: c_int = 0x00160000; +const objErrorBase: c_int = 0x003d0000; + +// taskLibCommon.h +pub const S_taskLib_NAME_NOT_FOUND: c_int = taskErrorBase + 0x0065; +pub const S_taskLib_TASK_HOOK_TABLE_FULL: c_int = taskErrorBase + 0x0066; +pub const S_taskLib_TASK_HOOK_NOT_FOUND: c_int = taskErrorBase + 0x0067; +pub const S_taskLib_ILLEGAL_PRIORITY: c_int = taskErrorBase + 0x006D; + +// FIXME(vxworks): could also be useful for TASK_DESC type +pub const VX_TASK_NAME_LENGTH: c_int = 31; +pub const VX_TASK_RENAME_LENGTH: c_int = 16; + +pub const TCIFLUSH: c_int = 0; + +pub const VINTR: usize = 0; +pub const VQUIT: usize = 1; +pub const VERASE: usize = 2; +pub const VKILL: usize = 3; +pub const VEOF: usize = 4; +pub const VMIN: usize = 16; +pub const VTIME: usize = 17; + +// semLibCommon.h +pub const S_semLib_INVALID_STATE: c_int = semErrorBase + 0x0065; +pub const S_semLib_INVALID_OPTION: c_int = semErrorBase + 0x0066; +pub const S_semLib_INVALID_QUEUE_TYPE: c_int = semErrorBase + 0x0067; +pub const S_semLib_INVALID_OPERATION: c_int = semErrorBase + 0x0068; + +// objLibCommon.h +pub const S_objLib_OBJ_ID_ERROR: c_int = objErrorBase + 0x0001; +pub const S_objLib_OBJ_UNAVAILABLE: c_int = objErrorBase + 0x0002; +pub const S_objLib_OBJ_DELETED: c_int = objErrorBase + 0x0003; +pub const S_objLib_OBJ_TIMEOUT: c_int = objErrorBase + 0x0004; +pub const S_objLib_OBJ_NO_METHOD: c_int = objErrorBase + 0x0005; + +// netinet/in.h +pub const IPPROTO_IP: c_int = 0; +pub const IPPROTO_ICMP: c_int = 1; +pub const IPPROTO_TCP: c_int = 6; +pub const IPPROTO_IPV6: c_int = 41; +pub const IPPROTO_ICMPV6: c_int = 58; + +pub const INADDR_ANY: in_addr_t = 0; +pub const INADDR_LOOPBACK: in_addr_t = 2130706433; +pub const INADDR_BROADCAST: in_addr_t = 4294967295; +pub const INADDR_NONE: in_addr_t = 4294967295; + +// netinet6/in6.h +pub const IN6ADDR_LOOPBACK_INIT: in6_addr = in6_addr { + s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], +}; +pub const IN6ADDR_ANY_INIT: in6_addr = in6_addr { + s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], +}; + +// udp.h +pub const IPPROTO_UDP: c_int = 17; + +pub const IP_TTL: c_int = 4; +pub const IP_MULTICAST_IF: c_int = 9; +pub const IP_MULTICAST_TTL: c_int = 10; +pub const IP_MULTICAST_LOOP: c_int = 11; +pub const IP_ADD_MEMBERSHIP: c_int = 12; +pub const IP_DROP_MEMBERSHIP: c_int = 13; + +// netdb.h +pub const NI_MAXHOST: c_int = 1025; + +// in6.h +pub const IPV6_V6ONLY: c_int = 1; +pub const IPV6_UNICAST_HOPS: c_int = 4; +pub const IPV6_MULTICAST_IF: c_int = 9; +pub const IPV6_MULTICAST_HOPS: c_int = 10; +pub const IPV6_MULTICAST_LOOP: c_int = 11; +pub const IPV6_ADD_MEMBERSHIP: c_int = 12; +pub const IPV6_DROP_MEMBERSHIP: c_int = 13; + +// STAT Stuff +pub const S_IFMT: c_int = 0o17_0000; +pub const S_IFIFO: c_int = 0o1_0000; +pub const S_IFCHR: c_int = 0o2_0000; +pub const S_IFDIR: c_int = 0o4_0000; +pub const S_IFBLK: c_int = 0o6_0000; +pub const S_IFREG: c_int = 0o10_0000; +pub const S_IFLNK: c_int = 0o12_0000; +pub const S_IFSHM: c_int = 0o13_0000; +pub const S_IFSOCK: c_int = 0o14_0000; +pub const S_ISUID: c_int = 0o4000; +pub const S_ISGID: c_int = 0o2000; +pub const S_ISTXT: c_int = 0o1000; +pub const S_ISVTX: c_int = 0o1000; +pub const S_IRUSR: c_int = 0o0400; +pub const S_IWUSR: c_int = 0o0200; +pub const S_IXUSR: c_int = 0o0100; +pub const S_IRWXU: c_int = 0o0700; +pub const S_IRGRP: c_int = 0o0040; +pub const S_IWGRP: c_int = 0o0020; +pub const S_IXGRP: c_int = 0o0010; +pub const S_IRWXG: c_int = 0o0070; +pub const S_IROTH: c_int = 0o0004; +pub const S_IWOTH: c_int = 0o0002; +pub const S_IXOTH: c_int = 0o0001; +pub const S_IRWXO: c_int = 0o0007; + +pub const UTIME_OMIT: c_long = 0x3ffffffe; +pub const UTIME_NOW: c_long = 0x3fffffff; + +// socket.h +pub const SOL_SOCKET: c_int = 0xffff; +pub const SOMAXCONN: c_int = 128; + +pub const SO_DEBUG: c_int = 0x0001; +pub const SO_REUSEADDR: c_int = 0x0004; +pub const SO_KEEPALIVE: c_int = 0x0008; +pub const SO_DONTROUTE: c_int = 0x0010; +pub const SO_RCVLOWAT: c_int = 0x0012; +pub const SO_SNDLOWAT: c_int = 0x0013; +pub const SO_SNDTIMEO: c_int = 0x1005; +pub const SO_ACCEPTCONN: c_int = 0x001e; +pub const SO_BROADCAST: c_int = 0x0020; +pub const SO_USELOOPBACK: c_int = 0x0040; +pub const SO_LINGER: c_int = 0x0080; +pub const SO_REUSEPORT: c_int = 0x0200; + +pub const SO_VLAN: c_int = 0x8000; + +pub const SO_SNDBUF: c_int = 0x1001; +pub const SO_RCVBUF: c_int = 0x1002; +pub const SO_RCVTIMEO: c_int = 0x1006; +pub const SO_ERROR: c_int = 0x1007; +pub const SO_TYPE: c_int = 0x1008; +pub const SO_BINDTODEVICE: c_int = 0x1010; +pub const SO_OOBINLINE: c_int = 0x1011; +pub const SO_CONNTIMEO: c_int = 0x100a; + +pub const SOCK_STREAM: c_int = 1; +pub const SOCK_DGRAM: c_int = 2; +pub const SOCK_RAW: c_int = 3; +pub const SOCK_RDM: c_int = 4; +pub const SOCK_SEQPACKET: c_int = 5; +pub const SOCK_PACKET: c_int = 10; + +pub const _SS_MAXSIZE: usize = 128; +pub const _SS_ALIGNSIZE: usize = size_of::(); +pub const _SS_PAD1SIZE: usize = + _SS_ALIGNSIZE - size_of::() - size_of::(); +pub const _SS_PAD2SIZE: usize = _SS_MAXSIZE + - size_of::() + - size_of::() + - _SS_PAD1SIZE + - _SS_ALIGNSIZE; + +pub const MSG_OOB: c_int = 0x0001; +pub const MSG_PEEK: c_int = 0x0002; +pub const MSG_DONTROUTE: c_int = 0x0004; +pub const MSG_EOR: c_int = 0x0008; +pub const MSG_TRUNC: c_int = 0x0010; +pub const MSG_CTRUNC: c_int = 0x0020; +pub const MSG_WAITALL: c_int = 0x0040; +pub const MSG_DONTWAIT: c_int = 0x0080; +pub const MSG_EOF: c_int = 0x0100; +pub const MSG_EXP: c_int = 0x0200; +pub const MSG_MBUF: c_int = 0x0400; +pub const MSG_NOTIFICATION: c_int = 0x0800; +pub const MSG_COMPAT: c_int = 0x8000; + +pub const AF_UNSPEC: c_int = 0; +pub const AF_LOCAL: c_int = 1; +pub const PF_LOCAL: c_int = AF_LOCAL; +pub const PF_UNIX: c_int = PF_LOCAL; +pub const PF_UNSPEC: c_int = AF_UNSPEC; +pub const AF_UNIX: c_int = AF_LOCAL; +pub const AF_INET: c_int = 2; +pub const PF_INET: c_int = AF_INET; +pub const AF_NETLINK: c_int = 16; +pub const AF_ROUTE: c_int = 17; +pub const AF_LINK: c_int = 18; +pub const AF_PACKET: c_int = 19; +pub const pseudo_AF_KEY: c_int = 27; +pub const AF_KEY: c_int = pseudo_AF_KEY; +pub const AF_INET6: c_int = 28; +pub const PF_INET6: c_int = AF_INET6; +pub const AF_SOCKDEV: c_int = 31; +pub const AF_TIPC: c_int = 33; +pub const AF_MIPC: c_int = 34; +pub const AF_MIPC_SAFE: c_int = 35; +pub const AF_MAX: c_int = 39; + +// termios.h +pub const B0: crate::speed_t = 0; +pub const B50: crate::speed_t = 50; +pub const B75: crate::speed_t = 75; +pub const B110: crate::speed_t = 110; +pub const B134: crate::speed_t = 134; +pub const B150: crate::speed_t = 150; +pub const B200: crate::speed_t = 200; +pub const B300: crate::speed_t = 300; +pub const B600: crate::speed_t = 600; +pub const B1200: crate::speed_t = 1200; +pub const B1800: crate::speed_t = 1800; +pub const B2400: crate::speed_t = 2400; +pub const B4800: crate::speed_t = 4800; +pub const B9600: crate::speed_t = 9600; +pub const B19200: crate::speed_t = 19200; +pub const B38400: crate::speed_t = 38400; +pub const B57600: crate::speed_t = 57600; +pub const B115200: crate::speed_t = 115200; +pub const B230400: crate::speed_t = 230400; + +pub const IGNBRK: crate::tcflag_t = 0x00000001; +pub const BRKINT: crate::tcflag_t = 0x00000002; +pub const IGNCR: crate::tcflag_t = 0x00000200; +pub const IGNPAR: crate::tcflag_t = 0x00000000; +pub const INPCK: crate::tcflag_t = 0x00000020; +pub const ISTRIP: crate::tcflag_t = 0x00000040; +pub const INLCR: crate::tcflag_t = 0x00000100; +pub const ISIG: crate::tcflag_t = 0x00000001; +pub const IXOFF: crate::tcflag_t = 0x00010000; +pub const IXON: crate::tcflag_t = 0x00002000; +pub const PARMRK: crate::tcflag_t = 0x00000000; +pub const NOFLSH: crate::tcflag_t = 0x00000000; +pub const NCCS: usize = 20; + +pub const OPOST: crate::tcflag_t = 0x00000001; +pub const ONLCR: crate::tcflag_t = 0x00000004; +pub const ECHO: crate::tcflag_t = 0x00000010; +pub const OCRNL: crate::tcflag_t = 0x00000010; +pub const ECHOE: crate::tcflag_t = 0x00000020; +pub const ECHOK: crate::tcflag_t = 0x00000040; +pub const ECHONL: crate::tcflag_t = 0x00000100; + +// net/if.h +pub const IFNAMSIZ: size_t = 16; +pub const IF_NAMESIZE: size_t = IFNAMSIZ; + +// sioLibCommon.h +pub const CLOCAL: crate::tcflag_t = 0x1; +pub const CREAD: crate::tcflag_t = 0x2; +pub const CS5: crate::tcflag_t = 0x0; +pub const CS6: crate::tcflag_t = 0x4; +pub const CS7: crate::tcflag_t = 0x8; +pub const CS8: crate::tcflag_t = 0xc; +pub const CSTOPB: crate::tcflag_t = 0x20; +pub const CSIZE: crate::tcflag_t = 0xc; + +pub const PARODD: crate::tcflag_t = 0x80; +pub const PARENB: crate::tcflag_t = 0x40; + +pub const DT_FIFO: c_uchar = 1; +pub const DT_CHR: c_uchar = 2; +pub const DT_DIR: c_uchar = 4; +pub const DT_BLK: c_uchar = 6; +pub const DT_REG: c_uchar = 8; +pub const DT_LNK: c_uchar = 10; +pub const DT_SOCK: c_uchar = 12; + +pub const FNM_NOMATCH: c_int = 1; +pub const FNM_NOESCAPE: c_int = 1; +pub const FNM_PATHNAME: c_int = 2; +pub const FNM_PERIOD: c_int = 4; +pub const FNM_CASEFOLD: c_int = 16; + +pub const F_OK: c_int = 0; +pub const X_OK: c_int = 1; +pub const W_OK: c_int = 2; + +pub const _PC_CHOWN_RESTRICTED: c_int = 4; +pub const _PC_LINK_MAX: c_int = 6; +pub const _PC_MAX_CANON: c_int = 7; +pub const _PC_MAX_INPUT: c_int = 8; +pub const _PC_NAME_MAX: c_int = 9; +pub const _PC_NO_TRUNC: c_int = 10; +pub const _PC_PATH_MAX: c_int = 11; +pub const _PC_PIPE_BUF: c_int = 12; +pub const _PC_VDISABLE: c_int = 20; + +pub const HUPCL: crate::tcflag_t = 0x10; + +pub const SHUT_RD: c_int = 0; +pub const SHUT_WR: c_int = 1; +pub const SHUT_RDWR: c_int = 2; + +pub const ICANON: crate::tcflag_t = 0x00000002; +pub const ICRNL: crate::tcflag_t = 0x00000400; +pub const IEXTEN: crate::tcflag_t = 0x00000000; + +pub const TCP_NODELAY: c_int = 1; +pub const TCP_MAXSEG: c_int = 2; +pub const TCP_NOPUSH: c_int = 3; +pub const TCP_KEEPIDLE: c_int = 4; +pub const TCP_KEEPINTVL: c_int = 5; +pub const TCP_KEEPCNT: c_int = 6; + +pub const TCSANOW: c_int = 0; +pub const TCSADRAIN: c_int = 1; +pub const TCSAFLUSH: c_int = 2; + +// ioLib.h +pub const FIONREAD: c_int = 0x40040001; +pub const FIOFLUSH: c_int = 2; +pub const FIOOPTIONS: c_int = 3; +pub const FIOBAUDRATE: c_int = 4; +pub const FIODISKFORMAT: c_int = 5; +pub const FIODISKINIT: c_int = 6; +pub const FIOSEEK: c_int = 7; +pub const FIOWHERE: c_int = 8; +pub const FIODIRENTRY: c_int = 9; +pub const FIORENAME: c_int = 10; +pub const FIOREADYCHANGE: c_int = 11; +pub const FIODISKCHANGE: c_int = 13; +pub const FIOCANCEL: c_int = 14; +pub const FIOSQUEEZE: c_int = 15; +pub const FIOGETNAME: c_int = 18; +pub const FIONBIO: c_int = 0x90040010; + +// limits.h +pub const PATH_MAX: c_int = _PARM_PATH_MAX; +pub const _POSIX_PATH_MAX: c_int = 256; + +// Some poll stuff +pub const POLLIN: c_short = 0x0001; +pub const POLLPRI: c_short = 0x0002; +pub const POLLOUT: c_short = 0x0004; +pub const POLLRDNORM: c_short = 0x0040; +pub const POLLWRNORM: c_short = POLLOUT; +pub const POLLRDBAND: c_short = 0x0080; +pub const POLLWRBAND: c_short = 0x0100; +pub const POLLERR: c_short = 0x0008; +pub const POLLHUP: c_short = 0x0010; +pub const POLLNVAL: c_short = 0x0020; + +// fnctlcom.h +pub const FD_CLOEXEC: c_int = 1; +pub const F_DUPFD: c_int = 0; +pub const F_GETFD: c_int = 1; +pub const F_SETFD: c_int = 2; +pub const F_GETFL: c_int = 3; +pub const F_SETFL: c_int = 4; +pub const F_GETOWN: c_int = 5; +pub const F_SETOWN: c_int = 6; +pub const F_GETLK: c_int = 7; +pub const F_SETLK: c_int = 8; +pub const F_SETLKW: c_int = 9; +pub const F_DUPFD_CLOEXEC: c_int = 14; +pub const F_RDLCK: c_int = 1; +pub const F_WRLCK: c_int = 2; +pub const F_UNLCK: c_int = 3; + +pub const LOG_EMERG: c_int = 0; +pub const LOG_ALERT: c_int = 1; +pub const LOG_CRIT: c_int = 2; +pub const LOG_ERR: c_int = 3; +pub const LOG_WARNING: c_int = 4; +pub const LOG_NOTICE: c_int = 5; +pub const LOG_INFO: c_int = 6; +pub const LOG_DEBUG: c_int = 7; + +pub const LOG_KERN: c_int = 0 << 3; +pub const LOG_USER: c_int = 1 << 3; +pub const LOG_MAIL: c_int = 2 << 3; +pub const LOG_DAEMON: c_int = 3 << 3; +pub const LOG_AUTH: c_int = 4 << 3; +pub const LOG_SYSLOG: c_int = 5 << 3; +pub const LOG_LPR: c_int = 6 << 3; +pub const LOG_NEWS: c_int = 7 << 3; +pub const LOG_UUCP: c_int = 8 << 3; +pub const LOG_LOCAL0: c_int = 16 << 3; +pub const LOG_LOCAL1: c_int = 17 << 3; +pub const LOG_LOCAL2: c_int = 18 << 3; +pub const LOG_LOCAL3: c_int = 19 << 3; +pub const LOG_LOCAL4: c_int = 20 << 3; +pub const LOG_LOCAL5: c_int = 21 << 3; +pub const LOG_LOCAL6: c_int = 22 << 3; +pub const LOG_LOCAL7: c_int = 23 << 3; + +pub const LOG_PID: c_int = 0x01; +pub const LOG_CONS: c_int = 0x02; +pub const LOG_ODELAY: c_int = 0x04; +pub const LOG_NDELAY: c_int = 0x08; +pub const LOG_NOWAIT: c_int = 0x10; + +pub const LOG_PRIMASK: c_int = 0x7; +pub const LOG_FACMASK: c_int = 0x3f8; + +// dlfcn.h +pub const RTLD_LOCAL: c_int = 0; +pub const RTLD_LAZY: c_int = 1; +pub const RTLD_NOW: c_int = 2; +pub const RTLD_GLOBAL: c_int = 256; + +// signal.h +pub const SIG_DFL: sighandler_t = 0 as sighandler_t; +pub const SIG_IGN: sighandler_t = 1 as sighandler_t; +pub const SIG_ERR: sighandler_t = -1 as isize as sighandler_t; + +pub const SIGHUP: c_int = 1; +pub const SIGINT: c_int = 2; +pub const SIGQUIT: c_int = 3; +pub const SIGILL: c_int = 4; +pub const SIGTRAP: c_int = 5; +pub const SIGABRT: c_int = 6; +pub const SIGEMT: c_int = 7; +pub const SIGFPE: c_int = 8; +pub const SIGKILL: c_int = 9; +pub const SIGBUS: c_int = 10; +pub const SIGSEGV: c_int = 11; +pub const SIGFMT: c_int = 12; +pub const SIGPIPE: c_int = 13; +pub const SIGALRM: c_int = 14; +pub const SIGTERM: c_int = 15; +pub const SIGCNCL: c_int = 16; +pub const SIGSTOP: c_int = 17; +pub const SIGTSTP: c_int = 18; +pub const SIGCONT: c_int = 19; +pub const SIGCHLD: c_int = 20; +pub const SIGTTIN: c_int = 21; +pub const SIGTTOU: c_int = 22; +pub const SIGUSR1: c_int = 30; +pub const SIGUSR2: c_int = 31; +pub const SIGPOLL: c_int = 32; +pub const SIGPROF: c_int = 33; +pub const SIGSYS: c_int = 34; +pub const SIGURG: c_int = 35; +pub const SIGVTALRM: c_int = 36; +pub const SIGXCPU: c_int = 37; +pub const SIGXFSZ: c_int = 38; +pub const SIGRTMIN: c_int = 48; + +pub const SIGIO: c_int = SIGRTMIN; +pub const SIGWINCH: c_int = SIGRTMIN + 5; +pub const SIGLOST: c_int = SIGRTMIN + 6; + +pub const SIG_BLOCK: c_int = 1; +pub const SIG_UNBLOCK: c_int = 2; +pub const SIG_SETMASK: c_int = 3; + +pub const SA_NOCLDSTOP: c_int = 0x0001; +pub const SA_SIGINFO: c_int = 0x0002; +pub const SA_ONSTACK: c_int = 0x0004; +pub const SA_INTERRUPT: c_int = 0x0008; +pub const SA_RESETHAND: c_int = 0x0010; +pub const SA_RESTART: c_int = 0x0020; +pub const SA_NODEFER: c_int = 0x0040; +pub const SA_NOCLDWAIT: c_int = 0x0080; + +pub const SI_SYNC: c_int = 0; +pub const SI_USER: c_int = -1; +pub const SI_QUEUE: c_int = -2; +pub const SI_TIMER: c_int = -3; +pub const SI_ASYNCIO: c_int = -4; +pub const SI_MESGQ: c_int = -5; +pub const SI_CHILD: c_int = -6; +pub const SI_KILL: c_int = SI_USER; + +pub const AT_FDCWD: c_int = -100; +pub const AT_SYMLINK_NOFOLLOW: c_int = 0x100; +pub const AT_REMOVEDIR: c_int = 0x200; +pub const AT_SYMLINK_FOLLOW: c_int = 0x400; + +// vxParams.h definitions +pub const _PARM_NAME_MAX: c_int = 255; +pub const _PARM_PATH_MAX: c_int = 1024; + +// WAIT STUFF +pub const WNOHANG: c_int = 0x01; +pub const WUNTRACED: c_int = 0x02; +pub const WCONTINUED: c_int = 0x04; + +const PTHREAD_MUTEXATTR_INITIALIZER: pthread_mutexattr_t = pthread_mutexattr_t { + mutexAttrStatus: PTHREAD_INITIALIZED_OBJ, + mutexAttrProtocol: PTHREAD_PRIO_NONE, + mutexAttrPrioceiling: 0, + mutexAttrType: PTHREAD_MUTEX_DEFAULT, + mutexAttrPshared: 1, +}; +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + mutexSemId: null_mut(), + mutexValid: PTHREAD_VALID_OBJ, + mutexInitted: PTHREAD_UNUSED_YET_OBJ, + mutexCondRefCount: 0, + mutexSavPriority: -1, + mutexAttr: PTHREAD_MUTEXATTR_INITIALIZER, + mutexSemName: [0; _PTHREAD_SHARED_SEM_NAME_MAX], +}; + +const PTHREAD_CONDATTR_INITIALIZER: pthread_condattr_t = pthread_condattr_t { + condAttrStatus: 0xf70990ef, + condAttrPshared: 1, + condAttrClockId: CLOCK_REALTIME, +}; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + condSemId: null_mut(), + condValid: PTHREAD_VALID_OBJ, + condInitted: PTHREAD_UNUSED_YET_OBJ, + condRefCount: 0, + condMutex: null_mut(), + condAttr: PTHREAD_CONDATTR_INITIALIZER, + condSemName: [0; _PTHREAD_SHARED_SEM_NAME_MAX], +}; + +const PTHREAD_RWLOCKATTR_INITIALIZER: pthread_rwlockattr_t = pthread_rwlockattr_t { + rwlockAttrStatus: PTHREAD_INITIALIZED_OBJ, + rwlockAttrPshared: 1, + rwlockAttrMaxReaders: 0, + rwlockAttrConformOpt: 1, +}; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + rwlockSemId: null_mut(), + rwlockReadersRefCount: 0, + rwlockValid: PTHREAD_VALID_OBJ, + rwlockInitted: PTHREAD_UNUSED_YET_OBJ, + rwlockAttr: PTHREAD_RWLOCKATTR_INITIALIZER, + rwlockSemName: [0; _PTHREAD_SHARED_SEM_NAME_MAX], +}; + +pub const SEEK_SET: c_int = 0; +pub const SEEK_CUR: c_int = 1; +pub const SEEK_END: c_int = 2; + +// rtpLibCommon.h +pub const VX_RTP_NAME_LENGTH: c_int = 255; +pub const RTP_ID_ERROR: crate::RTP_ID = -1; + +// h/public/unistd.h +// h/public/unistd.h +pub const R_OK: c_int = 4; +pub const _SC_ARG_MAX: c_int = 4; // Via unistd.h +pub const _SC_CHILD_MAX: c_int = 12; +pub const _SC_CLK_TCK: c_int = 13; +pub const _SC_GETPW_R_SIZE_MAX: c_int = 21; +pub const _SC_HOST_NAME_MAX: c_int = 22; +pub const _SC_NGROUPS_MAX: c_int = 36; +pub const _SC_OPEN_MAX: c_int = 37; +pub const _SC_PAGE_SIZE: c_int = 38; +pub const _SC_PAGESIZE: c_int = 39; +pub const _SC_STREAM_MAX: c_int = 59; +pub const _SC_SYMLOOP_MAX: c_int = 60; +pub const _SC_TTY_NAME_MAX: c_int = 87; +pub const _SC_TZNAME_MAX: c_int = 89; +pub const _SC_VERSION: c_int = 94; +pub const O_ACCMODE: c_int = 3; +pub const O_CLOEXEC: c_int = 0x100000; // fcntlcom +pub const O_EXCL: c_int = 0x0800; +pub const O_CREAT: c_int = 0x0200; +pub const O_SYNC: c_int = 0x2000; +pub const O_ASYNC: c_int = 0x0040; +pub const O_DSYNC: c_int = 0x10000; +pub const O_TRUNC: c_int = 0x0400; +pub const O_APPEND: c_int = 0x0008; +pub const O_RDWR: c_int = 0x0002; +pub const O_WRONLY: c_int = 0x0001; +pub const O_RDONLY: c_int = 0; +pub const O_NONBLOCK: c_int = 0x4000; + +// mman.h +pub const PROT_NONE: c_int = 0x0000; +pub const PROT_READ: c_int = 0x0001; +pub const PROT_WRITE: c_int = 0x0002; +pub const PROT_EXEC: c_int = 0x0004; + +pub const MAP_SHARED: c_int = 0x0001; +pub const MAP_PRIVATE: c_int = 0x0002; +pub const MAP_ANON: c_int = 0x0004; +pub const MAP_ANONYMOUS: c_int = MAP_ANON; +pub const MAP_FIXED: c_int = 0x0010; +pub const MAP_CONTIG: c_int = 0x0020; + +pub const MS_SYNC: c_int = 0x0001; +pub const MS_ASYNC: c_int = 0x0002; +pub const MS_INVALIDATE: c_int = 0x0004; + +pub const MAP_FAILED: *mut c_void = !0 as *mut c_void; + +// sys/ttycom.h +pub const TIOCGWINSZ: c_int = 0x1740087468; +pub const TIOCSWINSZ: c_int = -0x7ff78b99; + +extern_ty! { + pub enum FILE {} + pub enum fpos_t {} // FIXME(vxworks): fill this out with a struct +} + +f! { + pub const fn CMSG_ALIGN(len: usize) -> usize { + len + size_of::() - 1 & !(size_of::() - 1) + } + + pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr { + let next = cmsg as usize + + CMSG_ALIGN((*cmsg).cmsg_len as usize) + + CMSG_ALIGN(size_of::()); + let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; + if next <= max { + (cmsg as usize + CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr + } else { + core::ptr::null_mut::() + } + } + + pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr { + if (*mhdr).msg_controllen as usize > 0 { + (*mhdr).msg_control as *mut cmsghdr + } else { + core::ptr::null_mut::() + } + } + + pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { + (cmsg as *mut c_uchar).offset(CMSG_ALIGN(size_of::()) as isize) + } + + pub const fn CMSG_SPACE(length: c_uint) -> c_uint { + (CMSG_ALIGN(length as usize) + CMSG_ALIGN(size_of::())) as c_uint + } + + pub const fn CMSG_LEN(length: c_uint) -> c_uint { + CMSG_ALIGN(size_of::()) as c_uint + length + } +} + +extern "C" { + pub fn isalnum(c: c_int) -> c_int; + pub fn isalpha(c: c_int) -> c_int; + pub fn iscntrl(c: c_int) -> c_int; + pub fn isdigit(c: c_int) -> c_int; + pub fn isgraph(c: c_int) -> c_int; + pub fn islower(c: c_int) -> c_int; + pub fn isprint(c: c_int) -> c_int; + pub fn ispunct(c: c_int) -> c_int; + pub fn isspace(c: c_int) -> c_int; + pub fn isupper(c: c_int) -> c_int; + pub fn isxdigit(c: c_int) -> c_int; + pub fn isblank(c: c_int) -> c_int; + pub fn tolower(c: c_int) -> c_int; + pub fn toupper(c: c_int) -> c_int; + pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE; + pub fn freopen(filename: *const c_char, mode: *const c_char, file: *mut FILE) -> *mut FILE; + pub fn fflush(file: *mut FILE) -> c_int; + pub fn fclose(file: *mut FILE) -> c_int; + pub fn remove(filename: *const c_char) -> c_int; + pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int; + pub fn tmpfile() -> *mut FILE; + pub fn setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int, size: size_t) -> c_int; + pub fn setbuf(stream: *mut FILE, buf: *mut c_char); + pub fn getchar() -> c_int; + pub fn putchar(c: c_int) -> c_int; + pub fn fgetc(stream: *mut FILE) -> c_int; + pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char; + pub fn fputc(c: c_int, stream: *mut FILE) -> c_int; + pub fn fputs(s: *const c_char, stream: *mut FILE) -> c_int; + pub fn puts(s: *const c_char) -> c_int; + pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int; + pub fn fread(ptr: *mut c_void, size: size_t, nobj: size_t, stream: *mut FILE) -> size_t; + pub fn fwrite(ptr: *const c_void, size: size_t, nobj: size_t, stream: *mut FILE) -> size_t; + pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int; + pub fn ftell(stream: *mut FILE) -> c_long; + pub fn rewind(stream: *mut FILE); + pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int; + pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int; + pub fn feof(stream: *mut FILE) -> c_int; + pub fn ferror(stream: *mut FILE) -> c_int; + pub fn perror(s: *const c_char); + pub fn atof(s: *const c_char) -> c_double; + pub fn atoi(s: *const c_char) -> c_int; + pub fn atol(s: *const c_char) -> c_long; + pub fn atoll(s: *const c_char) -> c_longlong; + pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double; + pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float; + pub fn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long; + pub fn strtoll(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_longlong; + pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong; + pub fn strtoull(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulonglong; + pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; + pub fn malloc(size: size_t) -> *mut c_void; + pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; + pub fn free(p: *mut c_void); + pub fn abort() -> !; + pub fn exit(status: c_int) -> !; + pub fn atexit(cb: extern "C" fn()) -> c_int; + pub fn system(s: *const c_char) -> c_int; + pub fn getenv(s: *const c_char) -> *mut c_char; + + pub fn cfgetospeed(termios: *const crate::termios) -> crate::speed_t; + pub fn cfmakeraw(termios: *mut crate::termios) -> c_int; + pub fn cfsetispeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int; + pub fn cfsetospeed(termios: *mut crate::termios, speed: crate::speed_t) -> c_int; + pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char; + pub fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char; + pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char; + pub fn strncat(s: *mut c_char, ct: *const c_char, n: size_t) -> *mut c_char; + pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int; + pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strdup(cs: *const c_char) -> *mut c_char; + pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strcasecmp(s1: *const c_char, s2: *const c_char) -> c_int; + pub fn strncasecmp(s1: *const c_char, s2: *const c_char, n: size_t) -> c_int; + pub fn strlen(cs: *const c_char) -> size_t; + pub fn strnlen(cs: *const c_char, n: size_t) -> size_t; + pub fn strerror(n: c_int) -> *mut c_char; + pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char; + pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t; + pub fn wcslen(buf: *const wchar_t) -> size_t; + pub fn wcstombs(dest: *mut c_char, src: *const wchar_t, n: size_t) -> size_t; + + pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; + pub fn wmemchr(cx: *const wchar_t, c: wchar_t, n: size_t) -> *mut wchar_t; + pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int; + pub fn memcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; + pub fn memccpy(dest: *mut c_void, src: *const c_void, c: c_int, n: size_t) -> *mut c_void; + pub fn memmove(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; + pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void; + + pub fn aligned_alloc(alignment: size_t, size: size_t) -> *mut c_void; + pub fn uname(buf: *mut crate::utsname) -> c_int; + pub fn times(buf: *mut crate::tms) -> crate::clock_t; + pub fn tcflush(fd: c_int, action: c_int) -> c_int; + pub fn pclose(stream: *mut crate::FILE) -> c_int; + pub fn mkdtemp(template: *mut c_char) -> *mut c_char; + + pub fn linkat( + olddirfd: c_int, + oldpath: *const c_char, + newdirfd: c_int, + newpath: *const c_char, + flags: c_int, + ) -> c_int; + + pub fn mkdirat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; + + pub fn readlinkat( + dirfd: c_int, + pathname: *const c_char, + buf: *mut c_char, + bufsiz: size_t, + ) -> ssize_t; + + pub fn unlinkat(dirfd: c_int, pathname: *const c_char, flags: c_int) -> c_int; + + // netdb.h + pub fn getprotobyname(name: *const c_char) -> *mut protoent; + pub fn getprotobynumber(proto: c_int) -> *mut protoent; + pub fn getservbyname(name: *const c_char, proto: *const c_char) -> *mut servent; + + pub fn fchownat( + dirfd: c_int, + pathname: *const c_char, + owner: crate::uid_t, + group: crate::gid_t, + flags: c_int, + ) -> c_int; +} + +extern "C" { + pub fn fprintf(stream: *mut crate::FILE, format: *const c_char, ...) -> c_int; + pub fn printf(format: *const c_char, ...) -> c_int; + pub fn snprintf(s: *mut c_char, n: size_t, format: *const c_char, ...) -> c_int; + pub fn sprintf(s: *mut c_char, format: *const c_char, ...) -> c_int; + pub fn fscanf(stream: *mut crate::FILE, format: *const c_char, ...) -> c_int; + pub fn scanf(format: *const c_char, ...) -> c_int; + pub fn sscanf(s: *const c_char, format: *const c_char, ...) -> c_int; + pub fn getchar_unlocked() -> c_int; + pub fn putchar_unlocked(c: c_int) -> c_int; + pub fn stat(path: *const c_char, buf: *mut stat) -> c_int; + pub fn fdopen(fd: c_int, mode: *const c_char) -> *mut crate::FILE; + pub fn fileno(stream: *mut crate::FILE) -> c_int; + pub fn creat(path: *const c_char, mode: mode_t) -> c_int; + pub fn rewinddir(dirp: *mut crate::DIR); + pub fn fchown(fd: c_int, owner: crate::uid_t, group: crate::gid_t) -> c_int; + pub fn access(path: *const c_char, amode: c_int) -> c_int; + pub fn alarm(seconds: c_uint) -> c_uint; + pub fn fchdir(dirfd: c_int) -> c_int; + pub fn chown(path: *const c_char, uid: uid_t, gid: gid_t) -> c_int; + pub fn fpathconf(filedes: c_int, name: c_int) -> c_long; + pub fn getegid() -> gid_t; + pub fn geteuid() -> uid_t; + pub fn getgroups(ngroups_max: c_int, groups: *mut gid_t) -> c_int; + pub fn getlogin() -> *mut c_char; + pub fn getopt(argc: c_int, argv: *const *mut c_char, optstr: *const c_char) -> c_int; + pub fn pathconf(path: *const c_char, name: c_int) -> c_long; + pub fn pause() -> c_int; + pub fn seteuid(uid: uid_t) -> c_int; + pub fn setegid(gid: gid_t) -> c_int; + pub fn statfs(path: *const c_char, buf: *mut statfs) -> c_int; + pub fn sleep(secs: c_uint) -> c_uint; + pub fn ttyname(fd: c_int) -> *mut c_char; + pub fn wait(status: *mut c_int) -> pid_t; + pub fn umask(mask: mode_t) -> mode_t; + pub fn mlock(addr: *const c_void, len: size_t) -> c_int; + pub fn mlockall(flags: c_int) -> c_int; + pub fn munlock(addr: *const c_void, len: size_t) -> c_int; + pub fn munlockall() -> c_int; + + pub fn mmap( + addr: *mut c_void, + len: size_t, + prot: c_int, + flags: c_int, + fd: c_int, + offset: off_t, + ) -> *mut c_void; + pub fn munmap(addr: *mut c_void, len: size_t) -> c_int; + + pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; + pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int; + + pub fn truncate(path: *const c_char, length: off_t) -> c_int; + pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int; + pub fn shm_unlink(name: *const c_char) -> c_int; + + pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut c_void) -> c_int; + pub fn pthread_exit(value: *mut c_void) -> !; + pub fn pthread_attr_setdetachstate(attr: *mut crate::pthread_attr_t, state: c_int) -> c_int; + pub fn pthread_equal(t1: crate::pthread_t, t2: crate::pthread_t) -> c_int; + + pub fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int; + + pub fn sigaddset(set: *mut sigset_t, signum: c_int) -> c_int; + + pub fn sigaction(signum: c_int, act: *const sigaction, oldact: *mut sigaction) -> c_int; + + pub fn utimes(filename: *const c_char, times: *const crate::timeval) -> c_int; + + pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int; + + pub fn utimensat( + dirfd: c_int, + path: *const c_char, + times: *const crate::timespec, + flag: c_int, + ) -> c_int; + + #[link_name = "_rtld_dlopen"] + pub fn dlopen(filename: *const c_char, flag: c_int) -> *mut c_void; + + #[link_name = "_rtld_dlerror"] + pub fn dlerror() -> *mut c_char; + + #[link_name = "_rtld_dlsym"] + pub fn dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void; + + #[link_name = "_rtld_dlclose"] + pub fn dlclose(handle: *mut c_void) -> c_int; + + #[link_name = "_rtld_dladdr"] + pub fn dladdr(addr: *mut c_void, info: *mut Dl_info) -> c_int; + + // time.h + pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm; + pub fn localtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm; + pub fn mktime(tm: *mut tm) -> time_t; + pub fn time(time: *mut time_t) -> time_t; + pub fn gmtime(time_p: *const time_t) -> *mut tm; + pub fn localtime(time_p: *const time_t) -> *mut tm; + pub fn timegm(tm: *mut tm) -> time_t; + pub fn difftime(time1: time_t, time0: time_t) -> c_double; + pub fn gethostname(name: *mut c_char, len: size_t) -> c_int; + pub fn usleep(secs: crate::useconds_t) -> c_int; + pub fn putenv(string: *mut c_char) -> c_int; + pub fn setlocale(category: c_int, locale: *const c_char) -> *mut c_char; + pub fn localeconv() -> *mut lconv; + + pub fn sigprocmask(how: c_int, set: *const sigset_t, oldset: *mut sigset_t) -> c_int; + pub fn sigpending(set: *mut sigset_t) -> c_int; + + pub fn mkfifo(path: *const c_char, mode: mode_t) -> c_int; + + pub fn fseeko(stream: *mut crate::FILE, offset: off_t, whence: c_int) -> c_int; + pub fn ftello(stream: *mut crate::FILE) -> off_t; + pub fn mkstemp(template: *mut c_char) -> c_int; + + pub fn tmpnam(ptr: *mut c_char) -> *mut c_char; + + pub fn openlog(ident: *const c_char, logopt: c_int, facility: c_int); + pub fn closelog(); + pub fn setlogmask(maskpri: c_int) -> c_int; + pub fn syslog(priority: c_int, message: *const c_char, ...); + pub fn getline(lineptr: *mut *mut c_char, n: *mut size_t, stream: *mut FILE) -> ssize_t; + pub fn tcsetattr(fd: c_int, optional_actions: c_int, termios: *const crate::termios) -> c_int; + pub fn tcgetattr(fd: c_int, termios: *mut crate::termios) -> c_int; + pub fn tcsendbreak(fd: c_int, duration: c_int) -> c_int; + pub fn confstr(name: c_int, buf: *mut c_char, len: size_t) -> size_t; + pub fn fnmatch(pattern: *const c_char, name: *const c_char, flags: c_int) -> c_int; + + pub fn symlinkat(target: *const c_char, newdirfd: c_int, linkpath: *const c_char) -> c_int; + + // sys/stat.h + pub fn fchmodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, flags: c_int) -> c_int; + + // utime.h + pub fn utime(file: *const c_char, buf: *const utimbuf) -> c_int; +} + +extern "C" { + // stdlib.h + pub fn memalign(block_size: size_t, size_arg: size_t) -> *mut c_void; + + // ioLib.h + pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char; + + // ioLib.h + pub fn chdir(attr: *const c_char) -> c_int; + + // pthread.h + pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> c_int; + + // pthread.h + pub fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> c_int; + + // pthread.h + pub fn pthread_mutexattr_settype(pAttr: *mut crate::pthread_mutexattr_t, pType: c_int) + -> c_int; + + // pthread.h + pub fn pthread_mutex_init( + mutex: *mut pthread_mutex_t, + attr: *const pthread_mutexattr_t, + ) -> c_int; + + // pthread.h + pub fn pthread_mutex_destroy(mutex: *mut pthread_mutex_t) -> c_int; + + // pthread.h + pub fn pthread_mutex_lock(mutex: *mut pthread_mutex_t) -> c_int; + + // pthread.h + pub fn pthread_mutex_trylock(mutex: *mut pthread_mutex_t) -> c_int; + + // pthread.h + pub fn pthread_mutex_timedlock(attr: *mut pthread_mutex_t, spec: *const timespec) -> c_int; + + // pthread.h + pub fn pthread_mutex_unlock(mutex: *mut pthread_mutex_t) -> c_int; + + // pthread.h + pub fn pthread_attr_setname(pAttr: *mut crate::pthread_attr_t, name: *mut c_char) -> c_int; + + // pthread.h + pub fn pthread_attr_setstacksize(attr: *mut crate::pthread_attr_t, stacksize: size_t) -> c_int; + + // pthread.h + pub fn pthread_attr_getstacksize( + attr: *const crate::pthread_attr_t, + size: *mut size_t, + ) -> c_int; + + // pthread.h + pub fn pthread_attr_init(attr: *mut crate::pthread_attr_t) -> c_int; + + // pthread.h + pub fn pthread_create( + pThread: *mut crate::pthread_t, + pAttr: *const crate::pthread_attr_t, + start_routine: extern "C" fn(*mut c_void) -> *mut c_void, + value: *mut c_void, + ) -> c_int; + + //pthread.h + pub fn pthread_setschedparam( + native: crate::pthread_t, + policy: c_int, + param: *const crate::sched_param, + ) -> c_int; + + //pthread.h + pub fn pthread_getschedparam( + native: crate::pthread_t, + policy: *mut c_int, + param: *mut crate::sched_param, + ) -> c_int; + + //pthread.h + pub fn pthread_attr_setinheritsched( + attr: *mut crate::pthread_attr_t, + inheritsched: c_int, + ) -> c_int; + + //pthread.h + pub fn pthread_attr_setschedpolicy(attr: *mut crate::pthread_attr_t, policy: c_int) -> c_int; + + // pthread.h + pub fn pthread_attr_destroy(thread: *mut crate::pthread_attr_t) -> c_int; + + // pthread.h + pub fn pthread_detach(thread: crate::pthread_t) -> c_int; + + // int pthread_atfork (void (*)(void), void (*)(void), void (*)(void)); + pub fn pthread_atfork( + prepare: Option, + parent: Option, + child: Option, + ) -> c_int; + + // stat.h + pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int; + + // sys/statfs.h + pub fn fstatfs(fd: c_int, buf: *mut statfs) -> c_int; + + // stat.h + pub fn lstat(path: *const c_char, buf: *mut stat) -> c_int; + + // unistd.h + pub fn ftruncate(fd: c_int, length: off_t) -> c_int; + + // dirent.h + pub fn readdir_r( + pDir: *mut crate::DIR, + entry: *mut crate::dirent, + result: *mut *mut crate::dirent, + ) -> c_int; + + // dirent.h + pub fn readdir(pDir: *mut crate::DIR) -> *mut crate::dirent; + + // dirent.h + pub fn fdopendir(fd: c_int) -> *mut crate::DIR; + + // dirent.h + pub fn dirfd(dirp: *mut crate::DIR) -> c_int; + + // fcntl.h or + // ioLib.h + pub fn open(path: *const c_char, oflag: c_int, ...) -> c_int; + + // fcntl.h + pub fn openat(dirfd: c_int, pathname: *const c_char, flags: c_int, ...) -> c_int; + + // poll.h + pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: c_int) -> c_int; + + // pthread.h + pub fn pthread_condattr_init(attr: *mut crate::pthread_condattr_t) -> c_int; + + // pthread.h + pub fn pthread_condattr_destroy(attr: *mut crate::pthread_condattr_t) -> c_int; + + // pthread.h + pub fn pthread_condattr_getclock( + pAttr: *const crate::pthread_condattr_t, + pClockId: *mut crate::clockid_t, + ) -> c_int; + + // pthread.h + pub fn pthread_condattr_setclock( + pAttr: *mut crate::pthread_condattr_t, + clockId: crate::clockid_t, + ) -> c_int; + + // pthread.h + pub fn pthread_cond_init( + cond: *mut crate::pthread_cond_t, + attr: *const crate::pthread_condattr_t, + ) -> c_int; + + // pthread.h + pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> c_int; + + // pthread.h + pub fn pthread_cond_signal(cond: *mut crate::pthread_cond_t) -> c_int; + + // pthread.h + pub fn pthread_cond_broadcast(cond: *mut crate::pthread_cond_t) -> c_int; + + // pthread.h + pub fn pthread_cond_wait( + cond: *mut crate::pthread_cond_t, + mutex: *mut crate::pthread_mutex_t, + ) -> c_int; + + // pthread.h + pub fn pthread_rwlockattr_init(attr: *mut crate::pthread_rwlockattr_t) -> c_int; + + // pthread.h + pub fn pthread_rwlockattr_destroy(attr: *mut crate::pthread_rwlockattr_t) -> c_int; + + // pthread.h + pub fn pthread_rwlockattr_setmaxreaders( + attr: *mut crate::pthread_rwlockattr_t, + attr2: c_uint, + ) -> c_int; + + // pthread.h + pub fn pthread_rwlock_init( + attr: *mut crate::pthread_rwlock_t, + host: *const crate::pthread_rwlockattr_t, + ) -> c_int; + + // pthread.h + pub fn pthread_rwlock_destroy(attr: *mut crate::pthread_rwlock_t) -> c_int; + + // pthread.h + pub fn pthread_rwlock_rdlock(attr: *mut crate::pthread_rwlock_t) -> c_int; + + // pthread.h + pub fn pthread_rwlock_tryrdlock(attr: *mut crate::pthread_rwlock_t) -> c_int; + + // pthread.h + pub fn pthread_rwlock_timedrdlock( + attr: *mut crate::pthread_rwlock_t, + host: *const crate::timespec, + ) -> c_int; + + // pthread.h + pub fn pthread_rwlock_wrlock(attr: *mut crate::pthread_rwlock_t) -> c_int; + + // pthread.h + pub fn pthread_rwlock_trywrlock(attr: *mut crate::pthread_rwlock_t) -> c_int; + + // pthread.h + pub fn pthread_rwlock_timedwrlock( + attr: *mut crate::pthread_rwlock_t, + host: *const crate::timespec, + ) -> c_int; + + // pthread.h + pub fn pthread_rwlock_unlock(attr: *mut crate::pthread_rwlock_t) -> c_int; + + // pthread.h + pub fn pthread_key_create( + key: *mut crate::pthread_key_t, + dtor: Option, + ) -> c_int; + + // pthread.h + pub fn pthread_key_delete(key: crate::pthread_key_t) -> c_int; + + // pthread.h + pub fn pthread_setspecific(key: crate::pthread_key_t, value: *const c_void) -> c_int; + + // pthread.h + pub fn pthread_getspecific(key: crate::pthread_key_t) -> *mut c_void; + + // pthread.h + pub fn pthread_cond_timedwait( + cond: *mut crate::pthread_cond_t, + mutex: *mut crate::pthread_mutex_t, + abstime: *const crate::timespec, + ) -> c_int; + + // pthread.h + pub fn pthread_attr_getname(attr: *mut crate::pthread_attr_t, name: *mut *mut c_char) -> c_int; + + // pthread.h + pub fn pthread_join(thread: crate::pthread_t, status: *mut *mut c_void) -> c_int; + + // pthread.h + pub fn pthread_self() -> crate::pthread_t; + + // clockLib.h + pub fn clock_gettime(clock_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; + + // clockLib.h + pub fn clock_settime(clock_id: crate::clockid_t, tp: *const crate::timespec) -> c_int; + + // clockLib.h + pub fn clock_getres(clock_id: crate::clockid_t, res: *mut crate::timespec) -> c_int; + + // clockLib.h + pub fn clock_nanosleep( + clock_id: crate::clockid_t, + flags: c_int, + rqtp: *const crate::timespec, + rmtp: *mut crate::timespec, + ) -> c_int; + + // timerLib.h + pub fn nanosleep(rqtp: *const crate::timespec, rmtp: *mut crate::timespec) -> c_int; + + // socket.h + pub fn accept(s: c_int, addr: *mut crate::sockaddr, addrlen: *mut crate::socklen_t) -> c_int; + + // socket.h + pub fn bind(fd: c_int, addr: *const sockaddr, len: socklen_t) -> c_int; + + // socket.h + pub fn connect(s: c_int, name: *const crate::sockaddr, namelen: crate::socklen_t) -> c_int; + + // socket.h + pub fn getpeername( + s: c_int, + name: *mut crate::sockaddr, + namelen: *mut crate::socklen_t, + ) -> c_int; + + // socket.h + pub fn getsockname(socket: c_int, address: *mut sockaddr, address_len: *mut socklen_t) + -> c_int; + + // socket.h + pub fn getsockopt( + sockfd: c_int, + level: c_int, + optname: c_int, + optval: *mut c_void, + optlen: *mut crate::socklen_t, + ) -> c_int; + + // socket.h + pub fn listen(socket: c_int, backlog: c_int) -> c_int; + + // socket.h + pub fn recv(s: c_int, buf: *mut c_void, bufLen: size_t, flags: c_int) -> ssize_t; + + // socket.h + pub fn recvfrom( + s: c_int, + buf: *mut c_void, + bufLen: size_t, + flags: c_int, + from: *mut crate::sockaddr, + pFromLen: *mut crate::socklen_t, + ) -> ssize_t; + + pub fn recvmsg(socket: c_int, mp: *mut crate::msghdr, flags: c_int) -> ssize_t; + + // socket.h + pub fn send(socket: c_int, buf: *const c_void, len: size_t, flags: c_int) -> ssize_t; + + pub fn sendmsg(socket: c_int, mp: *const crate::msghdr, flags: c_int) -> ssize_t; + + // socket.h + pub fn sendto( + socket: c_int, + buf: *const c_void, + len: size_t, + flags: c_int, + addr: *const sockaddr, + addrlen: socklen_t, + ) -> ssize_t; + + // socket.h + pub fn setsockopt( + socket: c_int, + level: c_int, + name: c_int, + value: *const c_void, + option_len: socklen_t, + ) -> c_int; + + // socket.h + pub fn shutdown(s: c_int, how: c_int) -> c_int; + + // socket.h + pub fn socket(domain: c_int, _type: c_int, protocol: c_int) -> c_int; + + // icotl.h + pub fn ioctl(fd: c_int, request: c_int, ...) -> c_int; + + // fcntl.h + pub fn fcntl(fd: c_int, cmd: c_int, ...) -> c_int; + + // ntp_rfc2553.h for kernel + // netdb.h for user + pub fn gai_strerror(errcode: c_int) -> *mut c_char; + + // ioLib.h or + // unistd.h + pub fn close(fd: c_int) -> c_int; + + // ioLib.h or + // unistd.h + pub fn read(fd: c_int, buf: *mut c_void, count: size_t) -> ssize_t; + + // ioLib.h or + // unistd.h + pub fn write(fd: c_int, buf: *const c_void, count: size_t) -> ssize_t; + + // ioLib.h or + // unistd.h + pub fn isatty(fd: c_int) -> c_int; + + // ioLib.h or + // unistd.h + pub fn dup(src: c_int) -> c_int; + + // ioLib.h or + // unistd.h + pub fn dup2(src: c_int, dst: c_int) -> c_int; + + // ioLib.h or + // unistd.h + pub fn pipe(fds: *mut c_int) -> c_int; + + // ioLib.h or + // unistd.h + pub fn unlink(pathname: *const c_char) -> c_int; + + // unistd.h and + // ioLib.h + pub fn lseek(fd: c_int, offset: off_t, whence: c_int) -> off_t; + + // netdb.h + pub fn getaddrinfo( + node: *const c_char, + service: *const c_char, + hints: *const addrinfo, + res: *mut *mut addrinfo, + ) -> c_int; + + // netdb.h + pub fn freeaddrinfo(res: *mut addrinfo); + + // signal.h + pub fn signal(signum: c_int, handler: sighandler_t) -> sighandler_t; + + // unistd.h + pub fn getpid() -> pid_t; + + // unistd.h + pub fn getppid() -> pid_t; + + // unistd.h + pub fn setpgid(pid: pid_t, pgid: pid_t) -> pid_t; + + // wait.h + pub fn waitpid(pid: pid_t, status: *mut c_int, options: c_int) -> pid_t; + + // unistd.h + pub fn sysconf(attr: c_int) -> c_long; + + // stdlib.h + pub fn setenv( + // setenv.c + envVarName: *const c_char, + envVarValue: *const c_char, + overwrite: c_int, + ) -> c_int; + + // stdlib.h + pub fn unsetenv( + // setenv.c + envVarName: *const c_char, + ) -> c_int; + + // stdlib.h + pub fn realpath(fileName: *const c_char, resolvedName: *mut c_char) -> *mut c_char; + + // unistd.h + pub fn link(src: *const c_char, dst: *const c_char) -> c_int; + + // unistd.h + pub fn readlink(path: *const c_char, buf: *mut c_char, bufsize: size_t) -> ssize_t; + + // unistd.h + pub fn symlink(path1: *const c_char, path2: *const c_char) -> c_int; + + // dirent.h + pub fn opendir(name: *const c_char) -> *mut crate::DIR; + + // unistd.h + pub fn rmdir(path: *const c_char) -> c_int; + + // stat.h + pub fn mkdir(dirName: *const c_char, mode: mode_t) -> c_int; + + // stat.h + pub fn chmod(path: *const c_char, mode: mode_t) -> c_int; + + // stat.h + pub fn fchmod(attr1: c_int, attr2: mode_t) -> c_int; + + // unistd.h + pub fn fsync(fd: c_int) -> c_int; + + // unistd.h + pub fn fdatasync(fd: c_int) -> c_int; + + // dirent.h + pub fn closedir(ptr: *mut crate::DIR) -> c_int; + + //sched.h + pub fn sched_get_priority_max(policy: c_int) -> c_int; + + //sched.h + pub fn sched_get_priority_min(policy: c_int) -> c_int; + + //sched.h + pub fn sched_setparam(pid: crate::pid_t, param: *const crate::sched_param) -> c_int; + + //sched.h + pub fn sched_getparam(pid: crate::pid_t, param: *mut crate::sched_param) -> c_int; + + //sched.h + pub fn sched_setscheduler( + pid: crate::pid_t, + policy: c_int, + param: *const crate::sched_param, + ) -> c_int; + + //sched.h + pub fn sched_getscheduler(pid: crate::pid_t) -> c_int; + + //sched.h + pub fn sched_rr_get_interval(pid: crate::pid_t, tp: *mut crate::timespec) -> c_int; + + // sched.h + pub fn sched_yield() -> c_int; + + // errnoLib.h + pub fn errnoSet(err: c_int) -> c_int; + + // errnoLib.h + pub fn errnoGet() -> c_int; + + // unistd.h + pub fn _exit(status: c_int) -> !; + + // unistd.h + pub fn setgid(gid: crate::gid_t) -> c_int; + + // unistd.h + pub fn getgid() -> crate::gid_t; + + // unistd.h + pub fn setuid(uid: crate::uid_t) -> c_int; + + // unistd.h + pub fn getuid() -> crate::uid_t; + + // signal.h + pub fn sigemptyset(__set: *mut sigset_t) -> c_int; + pub fn sigfillset(set: *mut sigset_t) -> c_int; + pub fn sigdelset(set: *mut sigset_t, signum: c_int) -> c_int; + pub fn sigismember(set: *const sigset_t, signum: c_int) -> c_int; + + // pthread.h for kernel + // signal.h for user + pub fn pthread_sigmask(__how: c_int, __set: *const sigset_t, __oset: *mut sigset_t) -> c_int; + + // signal.h for user + pub fn kill(__pid: pid_t, __signo: c_int) -> c_int; + + // signal.h for user + pub fn sigqueue(__pid: pid_t, __signo: c_int, __value: crate::sigval) -> c_int; + + // signal.h for user + pub fn _sigqueue( + rtpId: crate::RTP_ID, + signo: c_int, + pValue: *const crate::sigval, + sigCode: c_int, + ) -> c_int; + + // signal.h + pub fn taskKill(taskId: crate::TASK_ID, signo: c_int) -> c_int; + + // signal.h + pub fn raise(__signo: c_int) -> c_int; + + // taskLibCommon.h + pub fn taskIdSelf() -> crate::TASK_ID; + pub fn taskDelay(ticks: crate::_Vx_ticks_t) -> c_int; + + // taskLib.h + pub fn taskNameSet(task_id: crate::TASK_ID, task_name: *mut c_char) -> c_int; + pub fn taskNameGet(task_id: crate::TASK_ID, buf_name: *mut c_char, bufsize: size_t) -> c_int; + + // rtpLibCommon.h + pub fn rtpInfoGet(rtpId: crate::RTP_ID, rtpStruct: *mut crate::RTP_DESC) -> c_int; + pub fn rtpSpawn( + pubrtpFileName: *const c_char, + argv: *mut *const c_char, + envp: *mut *const c_char, + priority: c_int, + uStackSize: size_t, + options: c_int, + taskOptions: c_int, + ) -> RTP_ID; + + // ioLib.h + pub fn _realpath(fileName: *const c_char, resolvedName: *mut c_char) -> *mut c_char; + + // pathLib.h + pub fn _pathIsAbsolute(filepath: *const c_char, pNameTail: *mut *const c_char) -> BOOL; + + pub fn writev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; + pub fn readv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; + + // randomNumGen.h + pub fn randBytes(buf: *mut c_uchar, length: c_int) -> c_int; + pub fn randABytes(buf: *mut c_uchar, length: c_int) -> c_int; + pub fn randUBytes(buf: *mut c_uchar, length: c_int) -> c_int; + pub fn randSecure() -> c_int; + + // mqueue.h + pub fn mq_open(name: *const c_char, oflag: c_int, ...) -> crate::mqd_t; + pub fn mq_close(mqd: crate::mqd_t) -> c_int; + pub fn mq_unlink(name: *const c_char) -> c_int; + pub fn mq_receive( + mqd: crate::mqd_t, + msg_ptr: *mut c_char, + msg_len: size_t, + msg_prio: *mut c_uint, + ) -> ssize_t; + pub fn mq_timedreceive( + mqd: crate::mqd_t, + msg_ptr: *mut c_char, + msg_len: size_t, + msg_prio: *mut c_uint, + abs_timeout: *const crate::timespec, + ) -> ssize_t; + pub fn mq_send( + mqd: crate::mqd_t, + msg_ptr: *const c_char, + msg_len: size_t, + msg_prio: c_uint, + ) -> c_int; + pub fn mq_timedsend( + mqd: crate::mqd_t, + msg_ptr: *const c_char, + msg_len: size_t, + msg_prio: c_uint, + abs_timeout: *const crate::timespec, + ) -> c_int; + pub fn mq_getattr(mqd: crate::mqd_t, attr: *mut crate::mq_attr) -> c_int; + pub fn mq_setattr( + mqd: crate::mqd_t, + newattr: *const crate::mq_attr, + oldattr: *mut crate::mq_attr, + ) -> c_int; + + // vxCpuLib.h + pub fn vxCpuEnabledGet() -> crate::cpuset_t; // Get set of running CPU's in the system + pub fn vxCpuConfiguredGet() -> crate::cpuset_t; // Get set of Configured CPU's in the system +} + +//Dummy functions, these don't really exist in VxWorks. + +// wait.h macros +safe_f! { + pub const fn WIFEXITED(status: c_int) -> bool { + (status & 0xFF00) == 0 + } + pub const fn WIFSIGNALED(status: c_int) -> bool { + (status & 0xFF00) != 0 + } + pub const fn WIFSTOPPED(status: c_int) -> bool { + (status & 0xFF0000) != 0 + } + pub const fn WEXITSTATUS(status: c_int) -> c_int { + status & 0xFF + } + pub const fn WIFCONTINUED(status: c_int) -> c_int { + (status >> 24) & 0xFF + } + pub const fn WTERMSIG(status: c_int) -> c_int { + (status >> 8) & 0xFF + } + pub const fn WSTOPSIG(status: c_int) -> c_int { + (status >> 16) & 0xFF + } +} + +pub fn pread(_fd: c_int, _buf: *mut c_void, _count: size_t, _offset: off64_t) -> ssize_t { + -1 +} + +pub fn pwrite(_fd: c_int, _buf: *const c_void, _count: size_t, _offset: off64_t) -> ssize_t { + -1 +} +pub fn posix_memalign(memptr: *mut *mut c_void, align: size_t, size: size_t) -> c_int { + // check to see if align is a power of 2 and if align is a multiple + // of sizeof(void *) + if (align & align - 1 != 0) || (align as usize % size_of::() != 0) { + return crate::EINVAL; + } + + unsafe { + // posix_memalign should not set errno + let e = crate::errnoGet(); + + let temp = memalign(align, size); + crate::errnoSet(e as c_int); + + if temp.is_null() { + crate::ENOMEM + } else { + *memptr = temp; + 0 + } + } +} + +cfg_if! { + if #[cfg(target_arch = "aarch64")] { + mod aarch64; + pub use self::aarch64::*; + } else if #[cfg(target_arch = "arm")] { + mod arm; + pub use self::arm::*; + } else if #[cfg(target_arch = "x86")] { + mod x86; + pub use self::x86::*; + } else if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } else if #[cfg(target_arch = "powerpc")] { + mod powerpc; + pub use self::powerpc::*; + } else if #[cfg(target_arch = "powerpc64")] { + mod powerpc64; + pub use self::powerpc64::*; + } else if #[cfg(target_arch = "riscv32")] { + mod riscv32; + pub use self::riscv32::*; + } else if #[cfg(target_arch = "riscv64")] { + mod riscv64; + pub use self::riscv64::*; + } else { + // Unknown target_arch + } +} diff --git a/http/vendor/libc/src/vxworks/powerpc.rs b/http/vendor/libc/src/vxworks/powerpc.rs new file mode 100644 index 0000000..376783c --- /dev/null +++ b/http/vendor/libc/src/vxworks/powerpc.rs @@ -0,0 +1 @@ +pub type wchar_t = u32; diff --git a/http/vendor/libc/src/vxworks/powerpc64.rs b/http/vendor/libc/src/vxworks/powerpc64.rs new file mode 100644 index 0000000..376783c --- /dev/null +++ b/http/vendor/libc/src/vxworks/powerpc64.rs @@ -0,0 +1 @@ +pub type wchar_t = u32; diff --git a/http/vendor/libc/src/vxworks/riscv32.rs b/http/vendor/libc/src/vxworks/riscv32.rs new file mode 100644 index 0000000..f562626 --- /dev/null +++ b/http/vendor/libc/src/vxworks/riscv32.rs @@ -0,0 +1 @@ +pub type wchar_t = i32; diff --git a/http/vendor/libc/src/vxworks/riscv64.rs b/http/vendor/libc/src/vxworks/riscv64.rs new file mode 100644 index 0000000..f562626 --- /dev/null +++ b/http/vendor/libc/src/vxworks/riscv64.rs @@ -0,0 +1 @@ +pub type wchar_t = i32; diff --git a/http/vendor/libc/src/vxworks/x86.rs b/http/vendor/libc/src/vxworks/x86.rs new file mode 100644 index 0000000..f562626 --- /dev/null +++ b/http/vendor/libc/src/vxworks/x86.rs @@ -0,0 +1 @@ +pub type wchar_t = i32; diff --git a/http/vendor/libc/src/vxworks/x86_64.rs b/http/vendor/libc/src/vxworks/x86_64.rs new file mode 100644 index 0000000..f562626 --- /dev/null +++ b/http/vendor/libc/src/vxworks/x86_64.rs @@ -0,0 +1 @@ +pub type wchar_t = i32; diff --git a/http/vendor/libc/src/wasi/mod.rs b/http/vendor/libc/src/wasi/mod.rs new file mode 100644 index 0000000..e580df5 --- /dev/null +++ b/http/vendor/libc/src/wasi/mod.rs @@ -0,0 +1,1098 @@ +//! [wasi-libc](https://github.com/WebAssembly/wasi-libc) definitions. +//! +//! `wasi-libc` project provides multiple libraries including emulated features, but we list only +//! basic features with `libc.a` here. + +use core::iter::Iterator; + +use crate::prelude::*; + +pub type intmax_t = i64; +pub type uintmax_t = u64; +pub type size_t = usize; +pub type ssize_t = isize; +pub type ptrdiff_t = isize; +pub type intptr_t = isize; +pub type uintptr_t = usize; +pub type off_t = i64; +pub type pid_t = i32; +pub type clock_t = c_longlong; +pub type time_t = c_longlong; +pub type ino_t = u64; +pub type sigset_t = c_uchar; +pub type suseconds_t = c_longlong; +pub type mode_t = u32; +pub type dev_t = u64; +pub type uid_t = u32; +pub type gid_t = u32; +pub type nlink_t = u64; +pub type blksize_t = c_long; +pub type blkcnt_t = i64; +pub type nfds_t = c_ulong; +pub type wchar_t = i32; +pub type nl_item = c_int; +pub type __wasi_rights_t = u64; +pub type locale_t = *mut __locale_struct; +pub type pthread_t = *mut c_void; +pub type pthread_once_t = c_int; +pub type pthread_key_t = c_uint; +pub type pthread_spinlock_t = c_int; + +s_no_extra_traits! { + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 4], + } +} + +#[allow(missing_copy_implementations)] +#[derive(Debug)] +pub enum FILE {} +#[allow(missing_copy_implementations)] +#[derive(Debug)] +pub enum DIR {} +#[allow(missing_copy_implementations)] +#[derive(Debug)] +pub enum __locale_struct {} + +s_paren! { + // in wasi-libc clockid_t is const struct __clockid* (where __clockid is an opaque struct), + // but that's an implementation detail that we don't want to have to deal with + #[repr(transparent)] + #[allow(dead_code)] + pub struct clockid_t(*const u8); +} + +unsafe impl Send for clockid_t {} +unsafe impl Sync for clockid_t {} + +s! { + #[repr(align(8))] + pub struct fpos_t { + data: [u8; 16], + } + + pub struct tm { + pub tm_sec: c_int, + pub tm_min: c_int, + pub tm_hour: c_int, + pub tm_mday: c_int, + pub tm_mon: c_int, + pub tm_year: c_int, + pub tm_wday: c_int, + pub tm_yday: c_int, + pub tm_isdst: c_int, + pub __tm_gmtoff: c_int, + pub __tm_zone: *const c_char, + pub __tm_nsec: c_int, + } + + #[derive(Default)] + pub struct timeval { + pub tv_sec: time_t, + pub tv_usec: suseconds_t, + } + + #[derive(Default)] + pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, + } + + pub struct tms { + pub tms_utime: clock_t, + pub tms_stime: clock_t, + pub tms_cutime: clock_t, + pub tms_cstime: clock_t, + } + + pub struct itimerspec { + pub it_interval: timespec, + pub it_value: timespec, + } + + pub struct iovec { + pub iov_base: *mut c_void, + pub iov_len: size_t, + } + + pub struct lconv { + pub decimal_point: *mut c_char, + pub thousands_sep: *mut c_char, + pub grouping: *mut c_char, + pub int_curr_symbol: *mut c_char, + pub currency_symbol: *mut c_char, + pub mon_decimal_point: *mut c_char, + pub mon_thousands_sep: *mut c_char, + pub mon_grouping: *mut c_char, + pub positive_sign: *mut c_char, + pub negative_sign: *mut c_char, + pub int_frac_digits: c_char, + pub frac_digits: c_char, + pub p_cs_precedes: c_char, + pub p_sep_by_space: c_char, + pub n_cs_precedes: c_char, + pub n_sep_by_space: c_char, + pub p_sign_posn: c_char, + pub n_sign_posn: c_char, + pub int_p_cs_precedes: c_char, + pub int_p_sep_by_space: c_char, + pub int_n_cs_precedes: c_char, + pub int_n_sep_by_space: c_char, + pub int_p_sign_posn: c_char, + pub int_n_sign_posn: c_char, + } + + pub struct pollfd { + pub fd: c_int, + pub events: c_short, + pub revents: c_short, + } + + pub struct rusage { + pub ru_utime: timeval, + pub ru_stime: timeval, + } + + pub struct stat { + pub st_dev: dev_t, + pub st_ino: ino_t, + pub st_nlink: nlink_t, + pub st_mode: mode_t, + pub st_uid: uid_t, + pub st_gid: gid_t, + __pad0: Padding, + pub st_rdev: dev_t, + pub st_size: off_t, + pub st_blksize: blksize_t, + pub st_blocks: blkcnt_t, + pub st_atim: timespec, + pub st_mtim: timespec, + pub st_ctim: timespec, + __reserved: Padding<[c_longlong; 3]>, + } + + pub struct fd_set { + __nfds: usize, + __fds: [c_int; FD_SETSIZE as usize], + } + + pub struct pthread_attr_t { + size: [c_long; 9], + } + + pub struct pthread_mutexattr_t { + __attr: c_uint, + } + + pub struct pthread_condattr_t { + __attr: c_uint, + } + + pub struct pthread_barrierattr_t { + __attr: c_uint, + } + + pub struct pthread_rwlockattr_t { + __attr: [c_uint; 2], + } + + pub struct pthread_cond_t { + size: [*mut c_void; 12], + } + + pub struct pthread_mutex_t { + size: [*mut c_void; 6], + } + + pub struct pthread_rwlock_t { + size: [*mut c_void; 8], + } + + pub struct pthread_barrier_t { + size: [*mut c_void; 5], + } +} + +// Declare dirent outside of s! so that it doesn't implement Copy, Eq, Hash, +// etc., since it contains a flexible array member with a dynamic size. +#[repr(C)] +#[allow(missing_copy_implementations)] +#[derive(Debug)] +pub struct dirent { + pub d_ino: ino_t, + pub d_type: c_uchar, + /// d_name is declared in WASI libc as a flexible array member, which + /// can't be directly expressed in Rust. As an imperfect workaround, + /// declare it as a zero-length array instead. + pub d_name: [c_char; 0], +} + +pub const EXIT_SUCCESS: c_int = 0; +pub const EXIT_FAILURE: c_int = 1; +pub const STDIN_FILENO: c_int = 0; +pub const STDOUT_FILENO: c_int = 1; +pub const STDERR_FILENO: c_int = 2; +pub const SEEK_SET: c_int = 0; +pub const SEEK_CUR: c_int = 1; +pub const SEEK_END: c_int = 2; +pub const _IOFBF: c_int = 0; +pub const _IONBF: c_int = 2; +pub const _IOLBF: c_int = 1; +pub const F_GETFD: c_int = 1; +pub const F_SETFD: c_int = 2; +pub const F_GETFL: c_int = 3; +pub const F_SETFL: c_int = 4; +pub const FD_CLOEXEC: c_int = 1; +pub const FD_SETSIZE: size_t = 1024; +pub const O_APPEND: c_int = 0x0001; +pub const O_DSYNC: c_int = 0x0002; +pub const O_NONBLOCK: c_int = 0x0004; +pub const O_RSYNC: c_int = 0x0008; +pub const O_SYNC: c_int = 0x0010; +pub const O_CREAT: c_int = 0x0001 << 12; +pub const O_DIRECTORY: c_int = 0x0002 << 12; +pub const O_EXCL: c_int = 0x0004 << 12; +pub const O_TRUNC: c_int = 0x0008 << 12; +pub const O_NOFOLLOW: c_int = 0x01000000; +pub const O_EXEC: c_int = 0x02000000; +pub const O_RDONLY: c_int = 0x04000000; +pub const O_SEARCH: c_int = 0x08000000; +pub const O_WRONLY: c_int = 0x10000000; +pub const O_CLOEXEC: c_int = 0x0; +pub const O_RDWR: c_int = O_WRONLY | O_RDONLY; +pub const O_ACCMODE: c_int = O_EXEC | O_RDWR | O_SEARCH; +pub const O_NOCTTY: c_int = 0x0; +pub const POSIX_FADV_DONTNEED: c_int = 4; +pub const POSIX_FADV_NOREUSE: c_int = 5; +pub const POSIX_FADV_NORMAL: c_int = 0; +pub const POSIX_FADV_RANDOM: c_int = 2; +pub const POSIX_FADV_SEQUENTIAL: c_int = 1; +pub const POSIX_FADV_WILLNEED: c_int = 3; +pub const AT_FDCWD: c_int = -2; +pub const AT_EACCESS: c_int = 0x0; +pub const AT_SYMLINK_NOFOLLOW: c_int = 0x1; +pub const AT_SYMLINK_FOLLOW: c_int = 0x2; +pub const AT_REMOVEDIR: c_int = 0x4; +pub const UTIME_OMIT: c_long = 0xfffffffe; +pub const UTIME_NOW: c_long = 0xffffffff; +pub const S_IFIFO: mode_t = 0o1_0000; +pub const S_IFCHR: mode_t = 0o2_0000; +pub const S_IFBLK: mode_t = 0o6_0000; +pub const S_IFDIR: mode_t = 0o4_0000; +pub const S_IFREG: mode_t = 0o10_0000; +pub const S_IFLNK: mode_t = 0o12_0000; +pub const S_IFSOCK: mode_t = 0o14_0000; +pub const S_IFMT: mode_t = 0o17_0000; +pub const S_IRWXO: mode_t = 0o0007; +pub const S_IXOTH: mode_t = 0o0001; +pub const S_IWOTH: mode_t = 0o0002; +pub const S_IROTH: mode_t = 0o0004; +pub const S_IRWXG: mode_t = 0o0070; +pub const S_IXGRP: mode_t = 0o0010; +pub const S_IWGRP: mode_t = 0o0020; +pub const S_IRGRP: mode_t = 0o0040; +pub const S_IRWXU: mode_t = 0o0700; +pub const S_IXUSR: mode_t = 0o0100; +pub const S_IWUSR: mode_t = 0o0200; +pub const S_IRUSR: mode_t = 0o0400; +pub const S_ISVTX: mode_t = 0o1000; +pub const S_ISGID: mode_t = 0o2000; +pub const S_ISUID: mode_t = 0o4000; +pub const DT_UNKNOWN: u8 = 0; +pub const DT_BLK: u8 = 1; +pub const DT_CHR: u8 = 2; +pub const DT_DIR: u8 = 3; +pub const DT_REG: u8 = 4; +pub const DT_FIFO: u8 = 6; +pub const DT_LNK: u8 = 7; +pub const DT_SOCK: u8 = 20; +pub const FIONREAD: c_int = 1; +pub const FIONBIO: c_int = 2; +pub const F_OK: c_int = 0; +pub const R_OK: c_int = 4; +pub const W_OK: c_int = 2; +pub const X_OK: c_int = 1; +pub const POLLIN: c_short = 0x1; +pub const POLLOUT: c_short = 0x2; +pub const POLLERR: c_short = 0x1000; +pub const POLLHUP: c_short = 0x2000; +pub const POLLNVAL: c_short = 0x4000; +pub const POLLRDNORM: c_short = 0x1; +pub const POLLWRNORM: c_short = 0x2; + +pub const E2BIG: c_int = 1; +pub const EACCES: c_int = 2; +pub const EADDRINUSE: c_int = 3; +pub const EADDRNOTAVAIL: c_int = 4; +pub const EAFNOSUPPORT: c_int = 5; +pub const EAGAIN: c_int = 6; +pub const EALREADY: c_int = 7; +pub const EBADF: c_int = 8; +pub const EBADMSG: c_int = 9; +pub const EBUSY: c_int = 10; +pub const ECANCELED: c_int = 11; +pub const ECHILD: c_int = 12; +pub const ECONNABORTED: c_int = 13; +pub const ECONNREFUSED: c_int = 14; +pub const ECONNRESET: c_int = 15; +pub const EDEADLK: c_int = 16; +pub const EDESTADDRREQ: c_int = 17; +pub const EDOM: c_int = 18; +pub const EDQUOT: c_int = 19; +pub const EEXIST: c_int = 20; +pub const EFAULT: c_int = 21; +pub const EFBIG: c_int = 22; +pub const EHOSTUNREACH: c_int = 23; +pub const EIDRM: c_int = 24; +pub const EILSEQ: c_int = 25; +pub const EINPROGRESS: c_int = 26; +pub const EINTR: c_int = 27; +pub const EINVAL: c_int = 28; +pub const EIO: c_int = 29; +pub const EISCONN: c_int = 30; +pub const EISDIR: c_int = 31; +pub const ELOOP: c_int = 32; +pub const EMFILE: c_int = 33; +pub const EMLINK: c_int = 34; +pub const EMSGSIZE: c_int = 35; +pub const EMULTIHOP: c_int = 36; +pub const ENAMETOOLONG: c_int = 37; +pub const ENETDOWN: c_int = 38; +pub const ENETRESET: c_int = 39; +pub const ENETUNREACH: c_int = 40; +pub const ENFILE: c_int = 41; +pub const ENOBUFS: c_int = 42; +pub const ENODEV: c_int = 43; +pub const ENOENT: c_int = 44; +pub const ENOEXEC: c_int = 45; +pub const ENOLCK: c_int = 46; +pub const ENOLINK: c_int = 47; +pub const ENOMEM: c_int = 48; +pub const ENOMSG: c_int = 49; +pub const ENOPROTOOPT: c_int = 50; +pub const ENOSPC: c_int = 51; +pub const ENOSYS: c_int = 52; +pub const ENOTCONN: c_int = 53; +pub const ENOTDIR: c_int = 54; +pub const ENOTEMPTY: c_int = 55; +pub const ENOTRECOVERABLE: c_int = 56; +pub const ENOTSOCK: c_int = 57; +pub const ENOTSUP: c_int = 58; +pub const ENOTTY: c_int = 59; +pub const ENXIO: c_int = 60; +pub const EOVERFLOW: c_int = 61; +pub const EOWNERDEAD: c_int = 62; +pub const EPERM: c_int = 63; +pub const EPIPE: c_int = 64; +pub const EPROTO: c_int = 65; +pub const EPROTONOSUPPORT: c_int = 66; +pub const EPROTOTYPE: c_int = 67; +pub const ERANGE: c_int = 68; +pub const EROFS: c_int = 69; +pub const ESPIPE: c_int = 70; +pub const ESRCH: c_int = 71; +pub const ESTALE: c_int = 72; +pub const ETIMEDOUT: c_int = 73; +pub const ETXTBSY: c_int = 74; +pub const EXDEV: c_int = 75; +pub const ENOTCAPABLE: c_int = 76; +pub const EOPNOTSUPP: c_int = ENOTSUP; +pub const EWOULDBLOCK: c_int = EAGAIN; + +pub const _SC_ARG_MAX: c_int = 0; +pub const _SC_CHILD_MAX: c_int = 1; +pub const _SC_CLK_TCK: c_int = 2; +pub const _SC_NGROUPS_MAX: c_int = 3; +pub const _SC_OPEN_MAX: c_int = 4; +pub const _SC_STREAM_MAX: c_int = 5; +pub const _SC_TZNAME_MAX: c_int = 6; +pub const _SC_JOB_CONTROL: c_int = 7; +pub const _SC_SAVED_IDS: c_int = 8; +pub const _SC_REALTIME_SIGNALS: c_int = 9; +pub const _SC_PRIORITY_SCHEDULING: c_int = 10; +pub const _SC_TIMERS: c_int = 11; +pub const _SC_ASYNCHRONOUS_IO: c_int = 12; +pub const _SC_PRIORITIZED_IO: c_int = 13; +pub const _SC_SYNCHRONIZED_IO: c_int = 14; +pub const _SC_FSYNC: c_int = 15; +pub const _SC_MAPPED_FILES: c_int = 16; +pub const _SC_MEMLOCK: c_int = 17; +pub const _SC_MEMLOCK_RANGE: c_int = 18; +pub const _SC_MEMORY_PROTECTION: c_int = 19; +pub const _SC_MESSAGE_PASSING: c_int = 20; +pub const _SC_SEMAPHORES: c_int = 21; +pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 22; +pub const _SC_AIO_LISTIO_MAX: c_int = 23; +pub const _SC_AIO_MAX: c_int = 24; +pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 25; +pub const _SC_DELAYTIMER_MAX: c_int = 26; +pub const _SC_MQ_OPEN_MAX: c_int = 27; +pub const _SC_MQ_PRIO_MAX: c_int = 28; +pub const _SC_VERSION: c_int = 29; +pub const _SC_PAGESIZE: c_int = 30; +pub const _SC_PAGE_SIZE: c_int = _SC_PAGESIZE; +pub const _SC_RTSIG_MAX: c_int = 31; +pub const _SC_SEM_NSEMS_MAX: c_int = 32; +pub const _SC_SEM_VALUE_MAX: c_int = 33; +pub const _SC_SIGQUEUE_MAX: c_int = 34; +pub const _SC_TIMER_MAX: c_int = 35; +pub const _SC_BC_BASE_MAX: c_int = 36; +pub const _SC_BC_DIM_MAX: c_int = 37; +pub const _SC_BC_SCALE_MAX: c_int = 38; +pub const _SC_BC_STRING_MAX: c_int = 39; +pub const _SC_COLL_WEIGHTS_MAX: c_int = 40; +pub const _SC_EXPR_NEST_MAX: c_int = 42; +pub const _SC_LINE_MAX: c_int = 43; +pub const _SC_RE_DUP_MAX: c_int = 44; +pub const _SC_2_VERSION: c_int = 46; +pub const _SC_2_C_BIND: c_int = 47; +pub const _SC_2_C_DEV: c_int = 48; +pub const _SC_2_FORT_DEV: c_int = 49; +pub const _SC_2_FORT_RUN: c_int = 50; +pub const _SC_2_SW_DEV: c_int = 51; +pub const _SC_2_LOCALEDEF: c_int = 52; +pub const _SC_UIO_MAXIOV: c_int = 60; +pub const _SC_IOV_MAX: c_int = 60; +pub const _SC_THREADS: c_int = 67; +pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 68; +pub const _SC_GETGR_R_SIZE_MAX: c_int = 69; +pub const _SC_GETPW_R_SIZE_MAX: c_int = 70; +pub const _SC_LOGIN_NAME_MAX: c_int = 71; +pub const _SC_TTY_NAME_MAX: c_int = 72; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 73; +pub const _SC_THREAD_KEYS_MAX: c_int = 74; +pub const _SC_THREAD_STACK_MIN: c_int = 75; +pub const _SC_THREAD_THREADS_MAX: c_int = 76; +pub const _SC_THREAD_ATTR_STACKADDR: c_int = 77; +pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 78; +pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 79; +pub const _SC_THREAD_PRIO_INHERIT: c_int = 80; +pub const _SC_THREAD_PRIO_PROTECT: c_int = 81; +pub const _SC_THREAD_PROCESS_SHARED: c_int = 82; +pub const _SC_NPROCESSORS_CONF: c_int = 83; +pub const _SC_NPROCESSORS_ONLN: c_int = 84; +pub const _SC_PHYS_PAGES: c_int = 85; +pub const _SC_AVPHYS_PAGES: c_int = 86; +pub const _SC_ATEXIT_MAX: c_int = 87; +pub const _SC_PASS_MAX: c_int = 88; +pub const _SC_XOPEN_VERSION: c_int = 89; +pub const _SC_XOPEN_XCU_VERSION: c_int = 90; +pub const _SC_XOPEN_UNIX: c_int = 91; +pub const _SC_XOPEN_CRYPT: c_int = 92; +pub const _SC_XOPEN_ENH_I18N: c_int = 93; +pub const _SC_XOPEN_SHM: c_int = 94; +pub const _SC_2_CHAR_TERM: c_int = 95; +pub const _SC_2_UPE: c_int = 97; +pub const _SC_XOPEN_XPG2: c_int = 98; +pub const _SC_XOPEN_XPG3: c_int = 99; +pub const _SC_XOPEN_XPG4: c_int = 100; +pub const _SC_NZERO: c_int = 109; +pub const _SC_XBS5_ILP32_OFF32: c_int = 125; +pub const _SC_XBS5_ILP32_OFFBIG: c_int = 126; +pub const _SC_XBS5_LP64_OFF64: c_int = 127; +pub const _SC_XBS5_LPBIG_OFFBIG: c_int = 128; +pub const _SC_XOPEN_LEGACY: c_int = 129; +pub const _SC_XOPEN_REALTIME: c_int = 130; +pub const _SC_XOPEN_REALTIME_THREADS: c_int = 131; +pub const _SC_ADVISORY_INFO: c_int = 132; +pub const _SC_BARRIERS: c_int = 133; +pub const _SC_CLOCK_SELECTION: c_int = 137; +pub const _SC_CPUTIME: c_int = 138; +pub const _SC_THREAD_CPUTIME: c_int = 139; +pub const _SC_MONOTONIC_CLOCK: c_int = 149; +pub const _SC_READER_WRITER_LOCKS: c_int = 153; +pub const _SC_SPIN_LOCKS: c_int = 154; +pub const _SC_REGEXP: c_int = 155; +pub const _SC_SHELL: c_int = 157; +pub const _SC_SPAWN: c_int = 159; +pub const _SC_SPORADIC_SERVER: c_int = 160; +pub const _SC_THREAD_SPORADIC_SERVER: c_int = 161; +pub const _SC_TIMEOUTS: c_int = 164; +pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 165; +pub const _SC_2_PBS: c_int = 168; +pub const _SC_2_PBS_ACCOUNTING: c_int = 169; +pub const _SC_2_PBS_LOCATE: c_int = 170; +pub const _SC_2_PBS_MESSAGE: c_int = 171; +pub const _SC_2_PBS_TRACK: c_int = 172; +pub const _SC_SYMLOOP_MAX: c_int = 173; +pub const _SC_STREAMS: c_int = 174; +pub const _SC_2_PBS_CHECKPOINT: c_int = 175; +pub const _SC_V6_ILP32_OFF32: c_int = 176; +pub const _SC_V6_ILP32_OFFBIG: c_int = 177; +pub const _SC_V6_LP64_OFF64: c_int = 178; +pub const _SC_V6_LPBIG_OFFBIG: c_int = 179; +pub const _SC_HOST_NAME_MAX: c_int = 180; +pub const _SC_TRACE: c_int = 181; +pub const _SC_TRACE_EVENT_FILTER: c_int = 182; +pub const _SC_TRACE_INHERIT: c_int = 183; +pub const _SC_TRACE_LOG: c_int = 184; +pub const _SC_IPV6: c_int = 235; +pub const _SC_RAW_SOCKETS: c_int = 236; +pub const _SC_V7_ILP32_OFF32: c_int = 237; +pub const _SC_V7_ILP32_OFFBIG: c_int = 238; +pub const _SC_V7_LP64_OFF64: c_int = 239; +pub const _SC_V7_LPBIG_OFFBIG: c_int = 240; +pub const _SC_SS_REPL_MAX: c_int = 241; +pub const _SC_TRACE_EVENT_NAME_MAX: c_int = 242; +pub const _SC_TRACE_NAME_MAX: c_int = 243; +pub const _SC_TRACE_SYS_MAX: c_int = 244; +pub const _SC_TRACE_USER_EVENT_MAX: c_int = 245; +pub const _SC_XOPEN_STREAMS: c_int = 246; +pub const _SC_THREAD_ROBUST_PRIO_INHERIT: c_int = 247; +pub const _SC_THREAD_ROBUST_PRIO_PROTECT: c_int = 248; +pub const _SC_MINSIGSTKSZ: c_int = 249; +pub const _SC_SIGSTKSZ: c_int = 250; + +// FIXME(msrv): `addr_of!(EXTERN_STATIC)` is now safe; remove `unsafe` when MSRV >= 1.82 +#[allow(unused_unsafe)] +pub static CLOCK_MONOTONIC: clockid_t = unsafe { clockid_t(core::ptr::addr_of!(_CLOCK_MONOTONIC)) }; +#[allow(unused_unsafe)] +pub static CLOCK_REALTIME: clockid_t = unsafe { clockid_t(core::ptr::addr_of!(_CLOCK_REALTIME)) }; + +pub const ABDAY_1: crate::nl_item = 0x20000; +pub const ABDAY_2: crate::nl_item = 0x20001; +pub const ABDAY_3: crate::nl_item = 0x20002; +pub const ABDAY_4: crate::nl_item = 0x20003; +pub const ABDAY_5: crate::nl_item = 0x20004; +pub const ABDAY_6: crate::nl_item = 0x20005; +pub const ABDAY_7: crate::nl_item = 0x20006; + +pub const DAY_1: crate::nl_item = 0x20007; +pub const DAY_2: crate::nl_item = 0x20008; +pub const DAY_3: crate::nl_item = 0x20009; +pub const DAY_4: crate::nl_item = 0x2000A; +pub const DAY_5: crate::nl_item = 0x2000B; +pub const DAY_6: crate::nl_item = 0x2000C; +pub const DAY_7: crate::nl_item = 0x2000D; + +pub const ABMON_1: crate::nl_item = 0x2000E; +pub const ABMON_2: crate::nl_item = 0x2000F; +pub const ABMON_3: crate::nl_item = 0x20010; +pub const ABMON_4: crate::nl_item = 0x20011; +pub const ABMON_5: crate::nl_item = 0x20012; +pub const ABMON_6: crate::nl_item = 0x20013; +pub const ABMON_7: crate::nl_item = 0x20014; +pub const ABMON_8: crate::nl_item = 0x20015; +pub const ABMON_9: crate::nl_item = 0x20016; +pub const ABMON_10: crate::nl_item = 0x20017; +pub const ABMON_11: crate::nl_item = 0x20018; +pub const ABMON_12: crate::nl_item = 0x20019; + +pub const MON_1: crate::nl_item = 0x2001A; +pub const MON_2: crate::nl_item = 0x2001B; +pub const MON_3: crate::nl_item = 0x2001C; +pub const MON_4: crate::nl_item = 0x2001D; +pub const MON_5: crate::nl_item = 0x2001E; +pub const MON_6: crate::nl_item = 0x2001F; +pub const MON_7: crate::nl_item = 0x20020; +pub const MON_8: crate::nl_item = 0x20021; +pub const MON_9: crate::nl_item = 0x20022; +pub const MON_10: crate::nl_item = 0x20023; +pub const MON_11: crate::nl_item = 0x20024; +pub const MON_12: crate::nl_item = 0x20025; + +pub const AM_STR: crate::nl_item = 0x20026; +pub const PM_STR: crate::nl_item = 0x20027; + +pub const D_T_FMT: crate::nl_item = 0x20028; +pub const D_FMT: crate::nl_item = 0x20029; +pub const T_FMT: crate::nl_item = 0x2002A; +pub const T_FMT_AMPM: crate::nl_item = 0x2002B; + +pub const ERA: crate::nl_item = 0x2002C; +pub const ERA_D_FMT: crate::nl_item = 0x2002E; +pub const ALT_DIGITS: crate::nl_item = 0x2002F; +pub const ERA_D_T_FMT: crate::nl_item = 0x20030; +pub const ERA_T_FMT: crate::nl_item = 0x20031; + +pub const CODESET: crate::nl_item = 14; +pub const CRNCYSTR: crate::nl_item = 0x4000F; +pub const RADIXCHAR: crate::nl_item = 0x10000; +pub const THOUSEP: crate::nl_item = 0x10001; +pub const YESEXPR: crate::nl_item = 0x50000; +pub const NOEXPR: crate::nl_item = 0x50001; +pub const YESSTR: crate::nl_item = 0x50002; +pub const NOSTR: crate::nl_item = 0x50003; + +pub const PTHREAD_STACK_MIN: usize = 2048; +pub const TIMER_ABSTIME: c_int = 1; + +f! { + pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { + let set = &*set; + let n = set.__nfds; + return set.__fds[..n].iter().any(|p| *p == fd); + } + + pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { + let set = &mut *set; + let n = set.__nfds; + if !set.__fds[..n].iter().any(|p| *p == fd) { + set.__nfds = n + 1; + set.__fds[n] = fd; + } + } + + pub fn FD_ZERO(set: *mut fd_set) -> () { + (*set).__nfds = 0; + return; + } +} + +#[cfg_attr( + feature = "rustc-dep-of-std", + link( + name = "c", + kind = "static", + modifiers = "-bundle", + cfg(target_feature = "crt-static") + ) +)] +#[cfg_attr( + feature = "rustc-dep-of-std", + link(name = "c", cfg(not(target_feature = "crt-static"))) +)] +extern "C" { + pub fn _Exit(code: c_int) -> !; + pub fn _exit(code: c_int) -> !; + pub fn abort() -> !; + pub fn aligned_alloc(a: size_t, b: size_t) -> *mut c_void; + pub fn calloc(amt: size_t, amt2: size_t) -> *mut c_void; + pub fn exit(code: c_int) -> !; + pub fn free(ptr: *mut c_void); + pub fn getenv(s: *const c_char) -> *mut c_char; + pub fn malloc(amt: size_t) -> *mut c_void; + pub fn malloc_usable_size(ptr: *mut c_void) -> size_t; + pub fn sbrk(increment: intptr_t) -> *mut c_void; + pub fn rand() -> c_int; + pub fn read(fd: c_int, ptr: *mut c_void, size: size_t) -> ssize_t; + pub fn realloc(ptr: *mut c_void, amt: size_t) -> *mut c_void; + pub fn setenv(k: *const c_char, v: *const c_char, a: c_int) -> c_int; + pub fn unsetenv(k: *const c_char) -> c_int; + pub fn clearenv() -> c_int; + pub fn write(fd: c_int, ptr: *const c_void, size: size_t) -> ssize_t; + pub static mut environ: *mut *mut c_char; + pub fn fopen(a: *const c_char, b: *const c_char) -> *mut FILE; + pub fn freopen(a: *const c_char, b: *const c_char, f: *mut FILE) -> *mut FILE; + pub fn fclose(f: *mut FILE) -> c_int; + pub fn remove(a: *const c_char) -> c_int; + pub fn rename(a: *const c_char, b: *const c_char) -> c_int; + pub fn feof(f: *mut FILE) -> c_int; + pub fn ferror(f: *mut FILE) -> c_int; + pub fn fflush(f: *mut FILE) -> c_int; + pub fn clearerr(f: *mut FILE); + pub fn fseek(f: *mut FILE, b: c_long, c: c_int) -> c_int; + pub fn ftell(f: *mut FILE) -> c_long; + pub fn rewind(f: *mut FILE); + pub fn fgetpos(f: *mut FILE, pos: *mut fpos_t) -> c_int; + pub fn fsetpos(f: *mut FILE, pos: *const fpos_t) -> c_int; + pub fn fread(buf: *mut c_void, a: size_t, b: size_t, f: *mut FILE) -> size_t; + pub fn fwrite(buf: *const c_void, a: size_t, b: size_t, f: *mut FILE) -> size_t; + pub fn fgetc(f: *mut FILE) -> c_int; + pub fn getc(f: *mut FILE) -> c_int; + pub fn getchar() -> c_int; + pub fn ungetc(a: c_int, f: *mut FILE) -> c_int; + pub fn fputc(a: c_int, f: *mut FILE) -> c_int; + pub fn putc(a: c_int, f: *mut FILE) -> c_int; + pub fn putchar(a: c_int) -> c_int; + pub fn fputs(a: *const c_char, f: *mut FILE) -> c_int; + pub fn puts(a: *const c_char) -> c_int; + pub fn perror(a: *const c_char); + pub fn srand(a: c_uint); + pub fn atexit(a: extern "C" fn()) -> c_int; + pub fn at_quick_exit(a: extern "C" fn()) -> c_int; + pub fn quick_exit(a: c_int) -> !; + pub fn posix_memalign(a: *mut *mut c_void, b: size_t, c: size_t) -> c_int; + pub fn rand_r(a: *mut c_uint) -> c_int; + pub fn random() -> c_long; + pub fn srandom(a: c_uint); + pub fn putenv(a: *mut c_char) -> c_int; + pub fn clock() -> clock_t; + pub fn time(a: *mut time_t) -> time_t; + pub fn difftime(a: time_t, b: time_t) -> c_double; + pub fn mktime(a: *mut tm) -> time_t; + pub fn strftime(a: *mut c_char, b: size_t, c: *const c_char, d: *const tm) -> size_t; + pub fn gmtime(a: *const time_t) -> *mut tm; + pub fn gmtime_r(a: *const time_t, b: *mut tm) -> *mut tm; + pub fn localtime(a: *const time_t) -> *mut tm; + pub fn localtime_r(a: *const time_t, b: *mut tm) -> *mut tm; + pub fn asctime_r(a: *const tm, b: *mut c_char) -> *mut c_char; + pub fn ctime_r(a: *const time_t, b: *mut c_char) -> *mut c_char; + + static _CLOCK_MONOTONIC: u8; + static _CLOCK_REALTIME: u8; + pub fn nanosleep(a: *const timespec, b: *mut timespec) -> c_int; + pub fn clock_getres(a: clockid_t, b: *mut timespec) -> c_int; + pub fn clock_gettime(a: clockid_t, b: *mut timespec) -> c_int; + pub fn clock_nanosleep(a: clockid_t, a2: c_int, b: *const timespec, c: *mut timespec) -> c_int; + + pub fn isalnum(c: c_int) -> c_int; + pub fn isalpha(c: c_int) -> c_int; + pub fn iscntrl(c: c_int) -> c_int; + pub fn isdigit(c: c_int) -> c_int; + pub fn isgraph(c: c_int) -> c_int; + pub fn islower(c: c_int) -> c_int; + pub fn isprint(c: c_int) -> c_int; + pub fn ispunct(c: c_int) -> c_int; + pub fn isspace(c: c_int) -> c_int; + pub fn isupper(c: c_int) -> c_int; + pub fn isxdigit(c: c_int) -> c_int; + pub fn isblank(c: c_int) -> c_int; + pub fn tolower(c: c_int) -> c_int; + pub fn toupper(c: c_int) -> c_int; + pub fn setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int, size: size_t) -> c_int; + pub fn setbuf(stream: *mut FILE, buf: *mut c_char); + pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char; + pub fn atof(s: *const c_char) -> c_double; + pub fn atoi(s: *const c_char) -> c_int; + pub fn atol(s: *const c_char) -> c_long; + pub fn atoll(s: *const c_char) -> c_longlong; + pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double; + pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float; + pub fn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long; + pub fn strtoll(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_longlong; + pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong; + pub fn strtoull(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulonglong; + + pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char; + pub fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char; + pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char; + pub fn strncat(s: *mut c_char, ct: *const c_char, n: size_t) -> *mut c_char; + pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int; + pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strdup(cs: *const c_char) -> *mut c_char; + pub fn strndup(cs: *const c_char, n: size_t) -> *mut c_char; + pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strcasecmp(s1: *const c_char, s2: *const c_char) -> c_int; + pub fn strncasecmp(s1: *const c_char, s2: *const c_char, n: size_t) -> c_int; + pub fn strlen(cs: *const c_char) -> size_t; + pub fn strnlen(cs: *const c_char, maxlen: size_t) -> size_t; + pub fn strerror(n: c_int) -> *mut c_char; + pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char; + pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t; + + pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; + pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int; + pub fn memcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; + pub fn memmove(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; + pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void; + + pub fn fprintf(stream: *mut crate::FILE, format: *const c_char, ...) -> c_int; + pub fn printf(format: *const c_char, ...) -> c_int; + pub fn snprintf(s: *mut c_char, n: size_t, format: *const c_char, ...) -> c_int; + pub fn sprintf(s: *mut c_char, format: *const c_char, ...) -> c_int; + pub fn fscanf(stream: *mut crate::FILE, format: *const c_char, ...) -> c_int; + pub fn scanf(format: *const c_char, ...) -> c_int; + pub fn sscanf(s: *const c_char, format: *const c_char, ...) -> c_int; + pub fn getchar_unlocked() -> c_int; + pub fn putchar_unlocked(c: c_int) -> c_int; + + pub fn shutdown(socket: c_int, how: c_int) -> c_int; + pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int; + pub fn mkdir(path: *const c_char, mode: mode_t) -> c_int; + pub fn stat(path: *const c_char, buf: *mut stat) -> c_int; + pub fn fdopen(fd: c_int, mode: *const c_char) -> *mut crate::FILE; + pub fn fileno(stream: *mut crate::FILE) -> c_int; + pub fn open(path: *const c_char, oflag: c_int, ...) -> c_int; + pub fn creat(path: *const c_char, mode: mode_t) -> c_int; + pub fn fcntl(fd: c_int, cmd: c_int, ...) -> c_int; + pub fn opendir(dirname: *const c_char) -> *mut crate::DIR; + pub fn fdopendir(fd: c_int) -> *mut crate::DIR; + pub fn readdir(dirp: *mut crate::DIR) -> *mut crate::dirent; + pub fn closedir(dirp: *mut crate::DIR) -> c_int; + pub fn rewinddir(dirp: *mut crate::DIR); + pub fn dirfd(dirp: *mut crate::DIR) -> c_int; + pub fn seekdir(dirp: *mut crate::DIR, loc: c_long); + pub fn telldir(dirp: *mut crate::DIR) -> c_long; + + pub fn openat(dirfd: c_int, pathname: *const c_char, flags: c_int, ...) -> c_int; + pub fn fstatat(dirfd: c_int, pathname: *const c_char, buf: *mut stat, flags: c_int) -> c_int; + pub fn linkat( + olddirfd: c_int, + oldpath: *const c_char, + newdirfd: c_int, + newpath: *const c_char, + flags: c_int, + ) -> c_int; + pub fn mkdirat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; + pub fn readlinkat( + dirfd: c_int, + pathname: *const c_char, + buf: *mut c_char, + bufsiz: size_t, + ) -> ssize_t; + pub fn renameat( + olddirfd: c_int, + oldpath: *const c_char, + newdirfd: c_int, + newpath: *const c_char, + ) -> c_int; + pub fn symlinkat(target: *const c_char, newdirfd: c_int, linkpath: *const c_char) -> c_int; + pub fn unlinkat(dirfd: c_int, pathname: *const c_char, flags: c_int) -> c_int; + + pub fn access(path: *const c_char, amode: c_int) -> c_int; + pub fn close(fd: c_int) -> c_int; + pub fn fpathconf(filedes: c_int, name: c_int) -> c_long; + pub fn getopt(argc: c_int, argv: *const *mut c_char, optstr: *const c_char) -> c_int; + pub fn isatty(fd: c_int) -> c_int; + pub fn link(src: *const c_char, dst: *const c_char) -> c_int; + pub fn lseek(fd: c_int, offset: off_t, whence: c_int) -> off_t; + pub fn pathconf(path: *const c_char, name: c_int) -> c_long; + pub fn rmdir(path: *const c_char) -> c_int; + pub fn sleep(secs: c_uint) -> c_uint; + pub fn unlink(c: *const c_char) -> c_int; + pub fn pread(fd: c_int, buf: *mut c_void, count: size_t, offset: off_t) -> ssize_t; + pub fn pwrite(fd: c_int, buf: *const c_void, count: size_t, offset: off_t) -> ssize_t; + + pub fn lstat(path: *const c_char, buf: *mut stat) -> c_int; + + pub fn fsync(fd: c_int) -> c_int; + pub fn fdatasync(fd: c_int) -> c_int; + + pub fn symlink(path1: *const c_char, path2: *const c_char) -> c_int; + + pub fn truncate(path: *const c_char, length: off_t) -> c_int; + pub fn ftruncate(fd: c_int, length: off_t) -> c_int; + + pub fn getrusage(resource: c_int, usage: *mut rusage) -> c_int; + + pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut c_void) -> c_int; + pub fn times(buf: *mut crate::tms) -> crate::clock_t; + + pub fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int; + + pub fn usleep(secs: c_uint) -> c_int; + pub fn send(socket: c_int, buf: *const c_void, len: size_t, flags: c_int) -> ssize_t; + pub fn recv(socket: c_int, buf: *mut c_void, len: size_t, flags: c_int) -> ssize_t; + pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: c_int) -> c_int; + pub fn setlocale(category: c_int, locale: *const c_char) -> *mut c_char; + pub fn localeconv() -> *mut lconv; + + pub fn readlink(path: *const c_char, buf: *mut c_char, bufsz: size_t) -> ssize_t; + + pub fn timegm(tm: *mut crate::tm) -> time_t; + + pub fn sysconf(name: c_int) -> c_long; + + pub fn ioctl(fd: c_int, request: c_int, ...) -> c_int; + + pub fn fseeko(stream: *mut crate::FILE, offset: off_t, whence: c_int) -> c_int; + pub fn ftello(stream: *mut crate::FILE) -> off_t; + pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int; + + pub fn strcasestr(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn getline(lineptr: *mut *mut c_char, n: *mut size_t, stream: *mut FILE) -> ssize_t; + + pub fn faccessat(dirfd: c_int, pathname: *const c_char, mode: c_int, flags: c_int) -> c_int; + pub fn writev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; + pub fn readv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; + pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t; + pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t; + pub fn posix_fadvise(fd: c_int, offset: off_t, len: off_t, advise: c_int) -> c_int; + pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int; + pub fn utimensat( + dirfd: c_int, + path: *const c_char, + times: *const crate::timespec, + flag: c_int, + ) -> c_int; + pub fn getentropy(buf: *mut c_void, buflen: size_t) -> c_int; + pub fn memrchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; + pub fn abs(i: c_int) -> c_int; + pub fn labs(i: c_long) -> c_long; + pub fn duplocale(base: crate::locale_t) -> crate::locale_t; + pub fn freelocale(loc: crate::locale_t); + pub fn newlocale(mask: c_int, locale: *const c_char, base: crate::locale_t) -> crate::locale_t; + pub fn uselocale(loc: crate::locale_t) -> crate::locale_t; + pub fn sched_yield() -> c_int; + pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char; + pub fn chdir(dir: *const c_char) -> c_int; + + pub fn nl_langinfo(item: crate::nl_item) -> *mut c_char; + pub fn nl_langinfo_l(item: crate::nl_item, loc: crate::locale_t) -> *mut c_char; + + pub fn select( + nfds: c_int, + readfds: *mut fd_set, + writefds: *mut fd_set, + errorfds: *mut fd_set, + timeout: *const timeval, + ) -> c_int; + + #[cfg(target_env = "p1")] + pub fn __wasilibc_register_preopened_fd(fd: c_int, path: *const c_char) -> c_int; + pub fn __wasilibc_fd_renumber(fd: c_int, newfd: c_int) -> c_int; + pub fn __wasilibc_unlinkat(fd: c_int, path: *const c_char) -> c_int; + pub fn __wasilibc_rmdirat(fd: c_int, path: *const c_char) -> c_int; + pub fn __wasilibc_find_relpath( + path: *const c_char, + abs_prefix: *mut *const c_char, + relative_path: *mut *mut c_char, + relative_path_len: usize, + ) -> c_int; + pub fn __wasilibc_tell(fd: c_int) -> off_t; + pub fn __wasilibc_nocwd___wasilibc_unlinkat(dirfd: c_int, path: *const c_char) -> c_int; + pub fn __wasilibc_nocwd___wasilibc_rmdirat(dirfd: c_int, path: *const c_char) -> c_int; + pub fn __wasilibc_nocwd_linkat( + olddirfd: c_int, + oldpath: *const c_char, + newdirfd: c_int, + newpath: *const c_char, + flags: c_int, + ) -> c_int; + pub fn __wasilibc_nocwd_symlinkat( + target: *const c_char, + dirfd: c_int, + path: *const c_char, + ) -> c_int; + pub fn __wasilibc_nocwd_readlinkat( + dirfd: c_int, + path: *const c_char, + buf: *mut c_char, + bufsize: usize, + ) -> isize; + pub fn __wasilibc_nocwd_faccessat( + dirfd: c_int, + path: *const c_char, + mode: c_int, + flags: c_int, + ) -> c_int; + pub fn __wasilibc_nocwd_renameat( + olddirfd: c_int, + oldpath: *const c_char, + newdirfd: c_int, + newpath: *const c_char, + ) -> c_int; + pub fn __wasilibc_nocwd_openat_nomode(dirfd: c_int, path: *const c_char, flags: c_int) + -> c_int; + pub fn __wasilibc_nocwd_fstatat( + dirfd: c_int, + path: *const c_char, + buf: *mut stat, + flags: c_int, + ) -> c_int; + pub fn __wasilibc_nocwd_mkdirat_nomode(dirfd: c_int, path: *const c_char) -> c_int; + pub fn __wasilibc_nocwd_utimensat( + dirfd: c_int, + path: *const c_char, + times: *const crate::timespec, + flags: c_int, + ) -> c_int; + pub fn __wasilibc_nocwd_opendirat(dirfd: c_int, path: *const c_char) -> *mut crate::DIR; + pub fn __wasilibc_access(pathname: *const c_char, mode: c_int, flags: c_int) -> c_int; + pub fn __wasilibc_stat(pathname: *const c_char, buf: *mut stat, flags: c_int) -> c_int; + pub fn __wasilibc_utimens( + pathname: *const c_char, + times: *const crate::timespec, + flags: c_int, + ) -> c_int; + pub fn __wasilibc_link(oldpath: *const c_char, newpath: *const c_char, flags: c_int) -> c_int; + pub fn __wasilibc_link_oldat( + olddirfd: c_int, + oldpath: *const c_char, + newpath: *const c_char, + flags: c_int, + ) -> c_int; + pub fn __wasilibc_link_newat( + oldpath: *const c_char, + newdirfd: c_int, + newpath: *const c_char, + flags: c_int, + ) -> c_int; + pub fn __wasilibc_rename_oldat( + olddirfd: c_int, + oldpath: *const c_char, + newpath: *const c_char, + ) -> c_int; + pub fn __wasilibc_rename_newat( + oldpath: *const c_char, + newdirfd: c_int, + newpath: *const c_char, + ) -> c_int; + + pub fn arc4random() -> u32; + pub fn arc4random_buf(a: *mut c_void, b: size_t); + pub fn arc4random_uniform(a: u32) -> u32; + + pub fn __errno_location() -> *mut c_int; + + pub fn chmod(path: *const c_char, mode: mode_t) -> c_int; + pub fn fchmod(fd: c_int, mode: mode_t) -> c_int; + pub fn realpath(pathname: *const c_char, resolved: *mut c_char) -> *mut c_char; + + pub fn pthread_self() -> pthread_t; + pub fn pthread_create( + native: *mut pthread_t, + attr: *const pthread_attr_t, + f: extern "C" fn(*mut c_void) -> *mut c_void, + value: *mut c_void, + ) -> c_int; + pub fn pthread_equal(t1: pthread_t, t2: pthread_t) -> c_int; + pub fn pthread_join(native: pthread_t, value: *mut *mut c_void) -> c_int; + pub fn pthread_attr_init(attr: *mut pthread_attr_t) -> c_int; + pub fn pthread_attr_destroy(attr: *mut pthread_attr_t) -> c_int; + pub fn pthread_attr_getstacksize(attr: *const pthread_attr_t, stacksize: *mut size_t) -> c_int; + pub fn pthread_attr_setstacksize(attr: *mut pthread_attr_t, stack_size: size_t) -> c_int; + pub fn pthread_attr_setdetachstate(attr: *mut pthread_attr_t, state: c_int) -> c_int; + pub fn pthread_detach(thread: pthread_t) -> c_int; + + pub fn pthread_key_create( + key: *mut pthread_key_t, + dtor: Option, + ) -> c_int; + pub fn pthread_key_delete(key: pthread_key_t) -> c_int; + pub fn pthread_getspecific(key: pthread_key_t) -> *mut c_void; + pub fn pthread_setspecific(key: pthread_key_t, value: *const c_void) -> c_int; + pub fn pthread_mutex_init( + lock: *mut pthread_mutex_t, + attr: *const pthread_mutexattr_t, + ) -> c_int; + pub fn pthread_mutex_destroy(lock: *mut pthread_mutex_t) -> c_int; + pub fn pthread_mutex_lock(lock: *mut pthread_mutex_t) -> c_int; + pub fn pthread_mutex_trylock(lock: *mut pthread_mutex_t) -> c_int; + pub fn pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> c_int; + + pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> c_int; + pub fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> c_int; + pub fn pthread_mutexattr_settype(attr: *mut pthread_mutexattr_t, _type: c_int) -> c_int; + + pub fn pthread_cond_init(cond: *mut pthread_cond_t, attr: *const pthread_condattr_t) -> c_int; + pub fn pthread_cond_wait(cond: *mut pthread_cond_t, lock: *mut pthread_mutex_t) -> c_int; + pub fn pthread_cond_timedwait( + cond: *mut pthread_cond_t, + lock: *mut pthread_mutex_t, + abstime: *const timespec, + ) -> c_int; + pub fn pthread_cond_signal(cond: *mut pthread_cond_t) -> c_int; + pub fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> c_int; + pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> c_int; + pub fn pthread_condattr_init(attr: *mut pthread_condattr_t) -> c_int; + pub fn pthread_condattr_destroy(attr: *mut pthread_condattr_t) -> c_int; + + pub fn pthread_rwlock_init( + lock: *mut pthread_rwlock_t, + attr: *const pthread_rwlockattr_t, + ) -> c_int; + pub fn pthread_rwlock_destroy(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_rdlock(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_tryrdlock(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_wrlock(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_trywrlock(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlock_unlock(lock: *mut pthread_rwlock_t) -> c_int; + pub fn pthread_rwlockattr_init(attr: *mut pthread_rwlockattr_t) -> c_int; + pub fn pthread_rwlockattr_destroy(attr: *mut pthread_rwlockattr_t) -> c_int; +} + +cfg_if! { + if #[cfg(not(target_env = "p1"))] { + mod p2; + pub use self::p2::*; + } +} diff --git a/http/vendor/libc/src/wasi/p2.rs b/http/vendor/libc/src/wasi/p2.rs new file mode 100644 index 0000000..7332a77 --- /dev/null +++ b/http/vendor/libc/src/wasi/p2.rs @@ -0,0 +1,188 @@ +use crate::prelude::*; + +pub type sa_family_t = c_ushort; +pub type in_port_t = c_ushort; +pub type in_addr_t = c_uint; + +pub type socklen_t = c_uint; + +s! { + #[repr(align(16))] + pub struct sockaddr { + pub sa_family: sa_family_t, + pub sa_data: [c_char; 0], + } + + pub struct in_addr { + pub s_addr: in_addr_t, + } + + #[repr(align(16))] + pub struct sockaddr_in { + pub sin_family: sa_family_t, + pub sin_port: in_port_t, + pub sin_addr: in_addr, + } + + #[repr(align(4))] + pub struct in6_addr { + pub s6_addr: [c_uchar; 16], + } + + #[repr(align(16))] + pub struct sockaddr_in6 { + pub sin6_family: sa_family_t, + pub sin6_port: in_port_t, + pub sin6_flowinfo: c_uint, + pub sin6_addr: in6_addr, + pub sin6_scope_id: c_uint, + } + + #[repr(align(16))] + pub struct sockaddr_storage { + pub ss_family: sa_family_t, + pub __ss_data: [c_char; 32], + } + + pub struct addrinfo { + pub ai_flags: c_int, + pub ai_family: c_int, + pub ai_socktype: c_int, + pub ai_protocol: c_int, + pub ai_addrlen: socklen_t, + pub ai_addr: *mut sockaddr, + pub ai_canonname: *mut c_char, + pub ai_next: *mut addrinfo, + } + + pub struct ip_mreq { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, + } + + pub struct ipv6_mreq { + pub ipv6mr_multiaddr: in6_addr, + pub ipv6mr_interface: c_uint, + } + + pub struct linger { + pub l_onoff: c_int, + pub l_linger: c_int, + } +} + +pub const SHUT_RD: c_int = 1 << 0; +pub const SHUT_WR: c_int = 1 << 1; +pub const SHUT_RDWR: c_int = SHUT_RD | SHUT_WR; + +pub const MSG_NOSIGNAL: c_int = 0x4000; +pub const MSG_PEEK: c_int = 0x0002; + +pub const SO_REUSEADDR: c_int = 2; +pub const SO_TYPE: c_int = 3; +pub const SO_ERROR: c_int = 4; +pub const SO_BROADCAST: c_int = 6; +pub const SO_SNDBUF: c_int = 7; +pub const SO_RCVBUF: c_int = 8; +pub const SO_KEEPALIVE: c_int = 9; +pub const SO_LINGER: c_int = 13; +pub const SO_ACCEPTCONN: c_int = 30; +pub const SO_PROTOCOL: c_int = 38; +pub const SO_DOMAIN: c_int = 39; +pub const SO_RCVTIMEO: c_int = 66; +pub const SO_SNDTIMEO: c_int = 67; + +pub const SOCK_DGRAM: c_int = 5; +pub const SOCK_STREAM: c_int = 6; +pub const SOCK_NONBLOCK: c_int = 0x00004000; + +pub const SOL_SOCKET: c_int = 0x7fffffff; + +pub const AF_UNSPEC: c_int = 0; +pub const AF_INET: c_int = 1; +pub const AF_INET6: c_int = 2; + +pub const IPPROTO_IP: c_int = 0; +pub const IPPROTO_TCP: c_int = 6; +pub const IPPROTO_UDP: c_int = 17; +pub const IPPROTO_IPV6: c_int = 41; + +pub const IP_TTL: c_int = 2; +pub const IP_MULTICAST_TTL: c_int = 33; +pub const IP_MULTICAST_LOOP: c_int = 34; +pub const IP_ADD_MEMBERSHIP: c_int = 35; +pub const IP_DROP_MEMBERSHIP: c_int = 36; + +pub const IPV6_UNICAST_HOPS: c_int = 16; +pub const IPV6_MULTICAST_LOOP: c_int = 19; +pub const IPV6_JOIN_GROUP: c_int = 20; +pub const IPV6_LEAVE_GROUP: c_int = 21; +pub const IPV6_V6ONLY: c_int = 26; + +pub const IPV6_ADD_MEMBERSHIP: c_int = IPV6_JOIN_GROUP; +pub const IPV6_DROP_MEMBERSHIP: c_int = IPV6_LEAVE_GROUP; + +pub const TCP_NODELAY: c_int = 1; +pub const TCP_KEEPIDLE: c_int = 4; +pub const TCP_KEEPINTVL: c_int = 5; +pub const TCP_KEEPCNT: c_int = 6; + +pub const EAI_SYSTEM: c_int = -11; + +extern "C" { + pub fn socket(domain: c_int, type_: c_int, protocol: c_int) -> c_int; + pub fn connect(fd: c_int, name: *const sockaddr, addrlen: socklen_t) -> c_int; + pub fn bind(socket: c_int, addr: *const sockaddr, addrlen: socklen_t) -> c_int; + pub fn listen(socket: c_int, backlog: c_int) -> c_int; + pub fn accept(socket: c_int, addr: *mut sockaddr, addrlen: *mut socklen_t) -> c_int; + pub fn accept4( + socket: c_int, + addr: *mut sockaddr, + addrlen: *mut socklen_t, + flags: c_int, + ) -> c_int; + + pub fn getsockname(socket: c_int, addr: *mut sockaddr, addrlen: *mut socklen_t) -> c_int; + pub fn getpeername(socket: c_int, addr: *mut sockaddr, addrlen: *mut socklen_t) -> c_int; + + pub fn sendto( + socket: c_int, + buffer: *const c_void, + length: size_t, + flags: c_int, + addr: *const sockaddr, + addrlen: socklen_t, + ) -> ssize_t; + pub fn recvfrom( + socket: c_int, + buffer: *mut c_void, + length: size_t, + flags: c_int, + addr: *mut sockaddr, + addrlen: *mut socklen_t, + ) -> ssize_t; + + pub fn getsockopt( + sockfd: c_int, + level: c_int, + optname: c_int, + optval: *mut c_void, + optlen: *mut socklen_t, + ) -> c_int; + pub fn setsockopt( + sockfd: c_int, + level: c_int, + optname: c_int, + optval: *const c_void, + optlen: socklen_t, + ) -> c_int; + + pub fn getaddrinfo( + host: *const c_char, + serv: *const c_char, + hint: *const addrinfo, + res: *mut *mut addrinfo, + ) -> c_int; + pub fn freeaddrinfo(p: *mut addrinfo); + pub fn gai_strerror(ecode: c_int) -> *const c_char; +} diff --git a/http/vendor/libc/src/windows/gnu/mod.rs b/http/vendor/libc/src/windows/gnu/mod.rs new file mode 100644 index 0000000..6dfa852 --- /dev/null +++ b/http/vendor/libc/src/windows/gnu/mod.rs @@ -0,0 +1,35 @@ +use crate::prelude::*; + +// The below configuration for machines with 32-bit word size aligns with the +// declaration in the `mingw-w64` headers. +cfg_if! { + if #[cfg(target_pointer_width = "64")] { + s_no_extra_traits! { + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 4], + } + } + } else if #[cfg(target_pointer_width = "32")] { + s_no_extra_traits! { + #[repr(align(8))] + pub struct max_align_t { + priv_: [i64; 3], + } + } + } +} + +// stdio file descriptor numbers +pub const STDIN_FILENO: c_int = 0; +pub const STDOUT_FILENO: c_int = 1; +pub const STDERR_FILENO: c_int = 2; + +extern "C" { + pub fn strcasecmp(s1: *const c_char, s2: *const c_char) -> c_int; + pub fn strncasecmp(s1: *const c_char, s2: *const c_char, n: size_t) -> c_int; + + // NOTE: For MSVC target, `wmemchr` is only a inline function in `` + // header file. We cannot find a way to link to that symbol from Rust. + pub fn wmemchr(cx: *const crate::wchar_t, c: crate::wchar_t, n: size_t) -> *mut crate::wchar_t; +} diff --git a/http/vendor/libc/src/windows/mod.rs b/http/vendor/libc/src/windows/mod.rs new file mode 100644 index 0000000..612c0ee --- /dev/null +++ b/http/vendor/libc/src/windows/mod.rs @@ -0,0 +1,612 @@ +//! Windows CRT definitions + +use crate::prelude::*; + +pub type intmax_t = i64; +pub type uintmax_t = u64; + +pub type size_t = usize; +pub type ptrdiff_t = isize; +pub type intptr_t = isize; +pub type uintptr_t = usize; +pub type ssize_t = isize; +pub type sighandler_t = usize; + +pub type wchar_t = u16; + +pub type clock_t = i32; + +pub type errno_t = c_int; + +cfg_if! { + if #[cfg(all(target_arch = "x86", target_env = "gnu"))] { + pub type time_t = i32; + } else { + pub type time_t = i64; + } +} + +pub type off_t = i32; +pub type dev_t = u32; +pub type ino_t = u16; + +extern_ty! { + pub enum timezone {} +} + +pub type time64_t = i64; + +pub type SOCKET = crate::uintptr_t; + +s! { + // note this is the struct called stat64 in Windows. Not stat, nor stati64. + pub struct stat { + pub st_dev: dev_t, + pub st_ino: ino_t, + pub st_mode: u16, + pub st_nlink: c_short, + pub st_uid: c_short, + pub st_gid: c_short, + pub st_rdev: dev_t, + pub st_size: i64, + pub st_atime: time64_t, + pub st_mtime: time64_t, + pub st_ctime: time64_t, + } + + // note that this is called utimbuf64 in Windows + pub struct utimbuf { + pub actime: time64_t, + pub modtime: time64_t, + } + + pub struct tm { + pub tm_sec: c_int, + pub tm_min: c_int, + pub tm_hour: c_int, + pub tm_mday: c_int, + pub tm_mon: c_int, + pub tm_year: c_int, + pub tm_wday: c_int, + pub tm_yday: c_int, + pub tm_isdst: c_int, + } + + #[derive(Default)] + pub struct timeval { + pub tv_sec: c_long, + pub tv_usec: c_long, + } + + #[derive(Default)] + pub struct timespec { + pub tv_sec: time_t, + pub tv_nsec: c_long, + } + + pub struct sockaddr { + pub sa_family: c_ushort, + pub sa_data: [c_char; 14], + } +} + +pub const INT_MIN: c_int = -2147483648; +pub const INT_MAX: c_int = 2147483647; + +pub const EXIT_FAILURE: c_int = 1; +pub const EXIT_SUCCESS: c_int = 0; +pub const RAND_MAX: c_int = 32767; +pub const EOF: c_int = -1; +pub const SEEK_SET: c_int = 0; +pub const SEEK_CUR: c_int = 1; +pub const SEEK_END: c_int = 2; +pub const _IOFBF: c_int = 0; +pub const _IONBF: c_int = 4; +pub const _IOLBF: c_int = 64; +pub const BUFSIZ: c_uint = 512; +pub const FOPEN_MAX: c_uint = 20; +pub const FILENAME_MAX: c_uint = 260; + +// fcntl.h +pub const O_RDONLY: c_int = 0x0000; +pub const O_WRONLY: c_int = 0x0001; +pub const O_RDWR: c_int = 0x0002; +pub const O_APPEND: c_int = 0x0008; +pub const O_CREAT: c_int = 0x0100; +pub const O_TRUNC: c_int = 0x0200; +pub const O_EXCL: c_int = 0x0400; +pub const O_TEXT: c_int = 0x4000; +pub const O_BINARY: c_int = 0x8000; +pub const _O_WTEXT: c_int = 0x10000; +pub const _O_U16TEXT: c_int = 0x20000; +pub const _O_U8TEXT: c_int = 0x40000; +pub const O_RAW: c_int = O_BINARY; +pub const O_NOINHERIT: c_int = 0x0080; +pub const O_TEMPORARY: c_int = 0x0040; +pub const _O_SHORT_LIVED: c_int = 0x1000; +pub const _O_OBTAIN_DIR: c_int = 0x2000; +pub const O_SEQUENTIAL: c_int = 0x0020; +pub const O_RANDOM: c_int = 0x0010; + +pub const S_IFCHR: c_int = 0o2_0000; +pub const S_IFDIR: c_int = 0o4_0000; +pub const S_IFREG: c_int = 0o10_0000; +pub const S_IFMT: c_int = 0o17_0000; +pub const S_IEXEC: c_int = 0o0100; +pub const S_IWRITE: c_int = 0o0200; +pub const S_IREAD: c_int = 0o0400; + +pub const LC_ALL: c_int = 0; +pub const LC_COLLATE: c_int = 1; +pub const LC_CTYPE: c_int = 2; +pub const LC_MONETARY: c_int = 3; +pub const LC_NUMERIC: c_int = 4; +pub const LC_TIME: c_int = 5; + +pub const EPERM: c_int = 1; +pub const ENOENT: c_int = 2; +pub const ESRCH: c_int = 3; +pub const EINTR: c_int = 4; +pub const EIO: c_int = 5; +pub const ENXIO: c_int = 6; +pub const E2BIG: c_int = 7; +pub const ENOEXEC: c_int = 8; +pub const EBADF: c_int = 9; +pub const ECHILD: c_int = 10; +pub const EAGAIN: c_int = 11; +pub const ENOMEM: c_int = 12; +pub const EACCES: c_int = 13; +pub const EFAULT: c_int = 14; +pub const EBUSY: c_int = 16; +pub const EEXIST: c_int = 17; +pub const EXDEV: c_int = 18; +pub const ENODEV: c_int = 19; +pub const ENOTDIR: c_int = 20; +pub const EISDIR: c_int = 21; +pub const EINVAL: c_int = 22; +pub const ENFILE: c_int = 23; +pub const EMFILE: c_int = 24; +pub const ENOTTY: c_int = 25; +pub const EFBIG: c_int = 27; +pub const ENOSPC: c_int = 28; +pub const ESPIPE: c_int = 29; +pub const EROFS: c_int = 30; +pub const EMLINK: c_int = 31; +pub const EPIPE: c_int = 32; +pub const EDOM: c_int = 33; +pub const ERANGE: c_int = 34; +pub const EDEADLK: c_int = 36; +pub const EDEADLOCK: c_int = 36; +pub const ENAMETOOLONG: c_int = 38; +pub const ENOLCK: c_int = 39; +pub const ENOSYS: c_int = 40; +pub const ENOTEMPTY: c_int = 41; +pub const EILSEQ: c_int = 42; +pub const STRUNCATE: c_int = 80; + +// POSIX Supplement (from errno.h) +pub const EADDRINUSE: c_int = 100; +pub const EADDRNOTAVAIL: c_int = 101; +pub const EAFNOSUPPORT: c_int = 102; +pub const EALREADY: c_int = 103; +pub const EBADMSG: c_int = 104; +pub const ECANCELED: c_int = 105; +pub const ECONNABORTED: c_int = 106; +pub const ECONNREFUSED: c_int = 107; +pub const ECONNRESET: c_int = 108; +pub const EDESTADDRREQ: c_int = 109; +pub const EHOSTUNREACH: c_int = 110; +pub const EIDRM: c_int = 111; +pub const EINPROGRESS: c_int = 112; +pub const EISCONN: c_int = 113; +pub const ELOOP: c_int = 114; +pub const EMSGSIZE: c_int = 115; +pub const ENETDOWN: c_int = 116; +pub const ENETRESET: c_int = 117; +pub const ENETUNREACH: c_int = 118; +pub const ENOBUFS: c_int = 119; +pub const ENODATA: c_int = 120; +pub const ENOLINK: c_int = 121; +pub const ENOMSG: c_int = 122; +pub const ENOPROTOOPT: c_int = 123; +pub const ENOSR: c_int = 124; +pub const ENOSTR: c_int = 125; +pub const ENOTCONN: c_int = 126; +pub const ENOTRECOVERABLE: c_int = 127; +pub const ENOTSOCK: c_int = 128; +pub const ENOTSUP: c_int = 129; +pub const EOPNOTSUPP: c_int = 130; +pub const EOVERFLOW: c_int = 132; +pub const EOWNERDEAD: c_int = 133; +pub const EPROTO: c_int = 134; +pub const EPROTONOSUPPORT: c_int = 135; +pub const EPROTOTYPE: c_int = 136; +pub const ETIME: c_int = 137; +pub const ETIMEDOUT: c_int = 138; +pub const ETXTBSY: c_int = 139; +pub const EWOULDBLOCK: c_int = 140; + +// signal codes +pub const SIGINT: c_int = 2; +pub const SIGILL: c_int = 4; +pub const SIGFPE: c_int = 8; +pub const SIGSEGV: c_int = 11; +pub const SIGTERM: c_int = 15; +pub const SIGABRT: c_int = 22; +pub const NSIG: c_int = 23; + +pub const SIG_ERR: c_int = -1; +pub const SIG_DFL: crate::sighandler_t = 0; +pub const SIG_IGN: crate::sighandler_t = 1; +pub const SIG_GET: crate::sighandler_t = 2; +pub const SIG_SGE: crate::sighandler_t = 3; +pub const SIG_ACK: crate::sighandler_t = 4; + +pub const L_tmpnam: c_uint = 260; +pub const TMP_MAX: c_uint = 0x7fff_ffff; + +// DIFF(main): removed in 458c58f409 +// FIXME(msrv): done by `std` starting in 1.79.0 +// inline comment below appeases style checker +#[cfg(all(target_env = "msvc", feature = "rustc-dep-of-std"))] // " if " +#[link(name = "msvcrt", cfg(not(target_feature = "crt-static")))] +#[link(name = "libcmt", cfg(target_feature = "crt-static"))] +extern "C" {} + +extern_ty! { + pub enum FILE {} + pub enum fpos_t {} // FIXME(windows): fill this out with a struct +} + +// Special handling for all print and scan type functions because of https://github.com/rust-lang/libc/issues/2860 +cfg_if! { + if #[cfg(not(feature = "rustc-dep-of-std"))] { + #[cfg_attr( + all(windows, target_env = "msvc"), + link(name = "legacy_stdio_definitions") + )] + extern "C" { + pub fn printf(format: *const c_char, ...) -> c_int; + pub fn fprintf(stream: *mut FILE, format: *const c_char, ...) -> c_int; + pub fn snprintf( + buffer: *mut c_char, + count: size_t, + format: *const c_char, + ... + ) -> c_int; + pub fn sprintf(buffer: *mut c_char, format: *const c_char, ...) -> c_int; + + pub fn scanf(format: *const c_char, ...) -> c_int; + pub fn sscanf(buffer: *const c_char, format: *const c_char, ...) -> c_int; + pub fn fscanf(stream: *mut FILE, format: *const c_char, ...) -> c_int; + } + } +} + +extern "C" { + pub fn isalnum(c: c_int) -> c_int; + pub fn isalpha(c: c_int) -> c_int; + pub fn iscntrl(c: c_int) -> c_int; + pub fn isdigit(c: c_int) -> c_int; + pub fn isgraph(c: c_int) -> c_int; + pub fn islower(c: c_int) -> c_int; + pub fn isprint(c: c_int) -> c_int; + pub fn ispunct(c: c_int) -> c_int; + pub fn isspace(c: c_int) -> c_int; + pub fn isupper(c: c_int) -> c_int; + pub fn isxdigit(c: c_int) -> c_int; + pub fn isblank(c: c_int) -> c_int; + pub fn tolower(c: c_int) -> c_int; + pub fn toupper(c: c_int) -> c_int; + pub fn qsort( + base: *mut c_void, + num: size_t, + size: size_t, + compar: Option c_int>, + ); + pub fn qsort_s( + base: *mut c_void, + num: size_t, + size: size_t, + compar: Option c_int>, + arg: *mut c_void, + ); + pub fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE; + pub fn freopen(filename: *const c_char, mode: *const c_char, file: *mut FILE) -> *mut FILE; + pub fn fflush(file: *mut FILE) -> c_int; + pub fn fclose(file: *mut FILE) -> c_int; + pub fn remove(filename: *const c_char) -> c_int; + pub fn rename(oldname: *const c_char, newname: *const c_char) -> c_int; + pub fn tmpfile() -> *mut FILE; + pub fn setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int, size: size_t) -> c_int; + pub fn setbuf(stream: *mut FILE, buf: *mut c_char); + pub fn getchar() -> c_int; + pub fn putchar(c: c_int) -> c_int; + pub fn fgetc(stream: *mut FILE) -> c_int; + pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char; + pub fn fputc(c: c_int, stream: *mut FILE) -> c_int; + pub fn fputs(s: *const c_char, stream: *mut FILE) -> c_int; + pub fn puts(s: *const c_char) -> c_int; + pub fn ungetc(c: c_int, stream: *mut FILE) -> c_int; + pub fn fread(ptr: *mut c_void, size: size_t, nobj: size_t, stream: *mut FILE) -> size_t; + pub fn fwrite(ptr: *const c_void, size: size_t, nobj: size_t, stream: *mut FILE) -> size_t; + pub fn fseek(stream: *mut FILE, offset: c_long, whence: c_int) -> c_int; + pub fn ftell(stream: *mut FILE) -> c_long; + pub fn rewind(stream: *mut FILE); + pub fn fgetpos(stream: *mut FILE, ptr: *mut fpos_t) -> c_int; + pub fn fsetpos(stream: *mut FILE, ptr: *const fpos_t) -> c_int; + pub fn feof(stream: *mut FILE) -> c_int; + pub fn ferror(stream: *mut FILE) -> c_int; + pub fn perror(s: *const c_char); + pub fn atof(s: *const c_char) -> c_double; + pub fn atoi(s: *const c_char) -> c_int; + pub fn atol(s: *const c_char) -> c_long; + pub fn atoll(s: *const c_char) -> c_longlong; + pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double; + pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float; + pub fn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long; + pub fn strtoll(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_longlong; + pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong; + pub fn strtoull(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulonglong; + pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; + pub fn malloc(size: size_t) -> *mut c_void; + pub fn _msize(p: *mut c_void) -> size_t; + pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; + pub fn free(p: *mut c_void); + pub fn abort() -> !; + pub fn exit(status: c_int) -> !; + pub fn _exit(status: c_int) -> !; + pub fn atexit(cb: extern "C" fn()) -> c_int; + pub fn system(s: *const c_char) -> c_int; + pub fn getenv(s: *const c_char) -> *mut c_char; + + pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char; + pub fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char; + pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char; + pub fn strncat(s: *mut c_char, ct: *const c_char, n: size_t) -> *mut c_char; + pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int; + pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int; + pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char; + pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t; + pub fn strdup(cs: *const c_char) -> *mut c_char; + pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char; + pub fn strlen(cs: *const c_char) -> size_t; + pub fn strnlen(cs: *const c_char, maxlen: size_t) -> size_t; + pub fn strerror(n: c_int) -> *mut c_char; + pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char; + pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t; + pub fn wcslen(buf: *const wchar_t) -> size_t; + pub fn wcsnlen(str: *const wchar_t, numberOfElements: size_t) -> size_t; + pub fn wcstombs(dest: *mut c_char, src: *const wchar_t, n: size_t) -> size_t; + + pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; + pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int; + pub fn memcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; + pub fn memmove(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; + pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void; + + pub fn abs(i: c_int) -> c_int; + pub fn labs(i: c_long) -> c_long; + pub fn rand() -> c_int; + pub fn srand(seed: c_uint); + + pub fn signal(signum: c_int, handler: sighandler_t) -> sighandler_t; + pub fn raise(signum: c_int) -> c_int; + + pub fn clock() -> clock_t; + pub fn ctime(sourceTime: *const time_t) -> *mut c_char; + pub fn difftime(timeEnd: time_t, timeStart: time_t) -> c_double; + #[link_name = "_gmtime64_s"] + pub fn gmtime_s(destTime: *mut tm, srcTime: *const time_t) -> c_int; + #[link_name = "_get_daylight"] + pub fn get_daylight(hours: *mut c_int) -> errno_t; + #[link_name = "_get_dstbias"] + pub fn get_dstbias(seconds: *mut c_long) -> errno_t; + #[link_name = "_get_timezone"] + pub fn get_timezone(seconds: *mut c_long) -> errno_t; + #[link_name = "_get_tzname"] + pub fn get_tzname( + p_return_value: *mut size_t, + time_zone_name: *mut c_char, + size_in_bytes: size_t, + index: c_int, + ) -> errno_t; + #[link_name = "_localtime64_s"] + pub fn localtime_s(tmDest: *mut tm, sourceTime: *const time_t) -> crate::errno_t; + #[link_name = "_time64"] + pub fn time(destTime: *mut time_t) -> time_t; + #[link_name = "_tzset"] + pub fn tzset(); + #[link_name = "_chmod"] + pub fn chmod(path: *const c_char, mode: c_int) -> c_int; + #[link_name = "_wchmod"] + pub fn wchmod(path: *const wchar_t, mode: c_int) -> c_int; + #[link_name = "_mkdir"] + pub fn mkdir(path: *const c_char) -> c_int; + #[link_name = "_wrmdir"] + pub fn wrmdir(path: *const wchar_t) -> c_int; + #[link_name = "_fstat64"] + pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int; + #[link_name = "_stat64"] + pub fn stat(path: *const c_char, buf: *mut stat) -> c_int; + #[link_name = "_wstat64"] + pub fn wstat(path: *const wchar_t, buf: *mut stat) -> c_int; + #[link_name = "_wutime64"] + pub fn wutime(file: *const wchar_t, buf: *mut utimbuf) -> c_int; + #[link_name = "_popen"] + pub fn popen(command: *const c_char, mode: *const c_char) -> *mut crate::FILE; + #[link_name = "_pclose"] + pub fn pclose(stream: *mut crate::FILE) -> c_int; + #[link_name = "_fdopen"] + pub fn fdopen(fd: c_int, mode: *const c_char) -> *mut crate::FILE; + #[link_name = "_fileno"] + pub fn fileno(stream: *mut crate::FILE) -> c_int; + #[link_name = "_open"] + pub fn open(path: *const c_char, oflag: c_int, ...) -> c_int; + #[link_name = "_wopen"] + pub fn wopen(path: *const wchar_t, oflag: c_int, ...) -> c_int; + #[link_name = "_creat"] + pub fn creat(path: *const c_char, mode: c_int) -> c_int; + #[link_name = "_access"] + pub fn access(path: *const c_char, amode: c_int) -> c_int; + #[link_name = "_chdir"] + pub fn chdir(dir: *const c_char) -> c_int; + #[link_name = "_close"] + pub fn close(fd: c_int) -> c_int; + #[link_name = "_dup"] + pub fn dup(fd: c_int) -> c_int; + #[link_name = "_dup2"] + pub fn dup2(src: c_int, dst: c_int) -> c_int; + #[link_name = "_execl"] + pub fn execl(path: *const c_char, arg0: *const c_char, ...) -> intptr_t; + #[link_name = "_wexecl"] + pub fn wexecl(path: *const wchar_t, arg0: *const wchar_t, ...) -> intptr_t; + #[link_name = "_execle"] + pub fn execle(path: *const c_char, arg0: *const c_char, ...) -> intptr_t; + #[link_name = "_wexecle"] + pub fn wexecle(path: *const wchar_t, arg0: *const wchar_t, ...) -> intptr_t; + #[link_name = "_execlp"] + pub fn execlp(path: *const c_char, arg0: *const c_char, ...) -> intptr_t; + #[link_name = "_wexeclp"] + pub fn wexeclp(path: *const wchar_t, arg0: *const wchar_t, ...) -> intptr_t; + #[link_name = "_execlpe"] + pub fn execlpe(path: *const c_char, arg0: *const c_char, ...) -> intptr_t; + #[link_name = "_wexeclpe"] + pub fn wexeclpe(path: *const wchar_t, arg0: *const wchar_t, ...) -> intptr_t; + #[link_name = "_execv"] + // DIFF(main): changed to `intptr_t` in e77f551de9 + pub fn execv(prog: *const c_char, argv: *const *const c_char) -> intptr_t; + #[link_name = "_execve"] + pub fn execve( + prog: *const c_char, + argv: *const *const c_char, + envp: *const *const c_char, + ) -> c_int; + #[link_name = "_execvp"] + pub fn execvp(c: *const c_char, argv: *const *const c_char) -> c_int; + #[link_name = "_execvpe"] + pub fn execvpe( + c: *const c_char, + argv: *const *const c_char, + envp: *const *const c_char, + ) -> c_int; + + #[link_name = "_wexecv"] + pub fn wexecv(prog: *const wchar_t, argv: *const *const wchar_t) -> intptr_t; + #[link_name = "_wexecve"] + pub fn wexecve( + prog: *const wchar_t, + argv: *const *const wchar_t, + envp: *const *const wchar_t, + ) -> intptr_t; + #[link_name = "_wexecvp"] + pub fn wexecvp(c: *const wchar_t, argv: *const *const wchar_t) -> intptr_t; + #[link_name = "_wexecvpe"] + pub fn wexecvpe( + c: *const wchar_t, + argv: *const *const wchar_t, + envp: *const *const wchar_t, + ) -> intptr_t; + #[link_name = "_getcwd"] + pub fn getcwd(buf: *mut c_char, size: c_int) -> *mut c_char; + #[link_name = "_getpid"] + pub fn getpid() -> c_int; + #[link_name = "_isatty"] + pub fn isatty(fd: c_int) -> c_int; + #[link_name = "_lseek"] + pub fn lseek(fd: c_int, offset: c_long, origin: c_int) -> c_long; + #[link_name = "_lseeki64"] + pub fn lseek64(fd: c_int, offset: c_longlong, origin: c_int) -> c_longlong; + #[link_name = "_pipe"] + pub fn pipe(fds: *mut c_int, psize: c_uint, textmode: c_int) -> c_int; + #[link_name = "_read"] + pub fn read(fd: c_int, buf: *mut c_void, count: c_uint) -> c_int; + #[link_name = "_rmdir"] + pub fn rmdir(path: *const c_char) -> c_int; + #[link_name = "_unlink"] + pub fn unlink(c: *const c_char) -> c_int; + #[link_name = "_write"] + pub fn write(fd: c_int, buf: *const c_void, count: c_uint) -> c_int; + #[link_name = "_commit"] + pub fn commit(fd: c_int) -> c_int; + #[link_name = "_get_osfhandle"] + pub fn get_osfhandle(fd: c_int) -> intptr_t; + #[link_name = "_open_osfhandle"] + pub fn open_osfhandle(osfhandle: intptr_t, flags: c_int) -> c_int; + pub fn setlocale(category: c_int, locale: *const c_char) -> *mut c_char; + #[link_name = "_wsetlocale"] + pub fn wsetlocale(category: c_int, locale: *const wchar_t) -> *mut wchar_t; + #[link_name = "_aligned_malloc"] + pub fn aligned_malloc(size: size_t, alignment: size_t) -> *mut c_void; + #[link_name = "_aligned_free"] + pub fn aligned_free(ptr: *mut c_void); + #[link_name = "_aligned_realloc"] + pub fn aligned_realloc(memblock: *mut c_void, size: size_t, alignment: size_t) -> *mut c_void; + #[link_name = "_putenv"] + pub fn putenv(envstring: *const c_char) -> c_int; + #[link_name = "_wputenv"] + pub fn wputenv(envstring: *const crate::wchar_t) -> c_int; + #[link_name = "_putenv_s"] + pub fn putenv_s(envstring: *const c_char, value_string: *const c_char) -> crate::errno_t; + #[link_name = "_wputenv_s"] + pub fn wputenv_s( + envstring: *const crate::wchar_t, + value_string: *const crate::wchar_t, + ) -> crate::errno_t; +} + +extern "system" { + pub fn listen(s: SOCKET, backlog: c_int) -> c_int; + pub fn accept(s: SOCKET, addr: *mut crate::sockaddr, addrlen: *mut c_int) -> SOCKET; + pub fn bind(s: SOCKET, name: *const crate::sockaddr, namelen: c_int) -> c_int; + pub fn connect(s: SOCKET, name: *const crate::sockaddr, namelen: c_int) -> c_int; + pub fn getpeername(s: SOCKET, name: *mut crate::sockaddr, nameln: *mut c_int) -> c_int; + pub fn getsockname(s: SOCKET, name: *mut crate::sockaddr, nameln: *mut c_int) -> c_int; + pub fn getsockopt( + s: SOCKET, + level: c_int, + optname: c_int, + optval: *mut c_char, + optlen: *mut c_int, + ) -> c_int; + pub fn recvfrom( + s: SOCKET, + buf: *mut c_char, + len: c_int, + flags: c_int, + from: *mut crate::sockaddr, + fromlen: *mut c_int, + ) -> c_int; + pub fn sendto( + s: SOCKET, + buf: *const c_char, + len: c_int, + flags: c_int, + to: *const crate::sockaddr, + tolen: c_int, + ) -> c_int; + pub fn setsockopt( + s: SOCKET, + level: c_int, + optname: c_int, + optval: *const c_char, + optlen: c_int, + ) -> c_int; + pub fn socket(af: c_int, socket_type: c_int, protocol: c_int) -> SOCKET; +} + +cfg_if! { + if #[cfg(all(target_env = "gnu"))] { + mod gnu; + pub use self::gnu::*; + } else if #[cfg(all(target_env = "msvc"))] { + mod msvc; + pub use self::msvc::*; + } else { + // Unknown target_env + } +} diff --git a/http/vendor/libc/src/windows/msvc/mod.rs b/http/vendor/libc/src/windows/msvc/mod.rs new file mode 100644 index 0000000..967df8c --- /dev/null +++ b/http/vendor/libc/src/windows/msvc/mod.rs @@ -0,0 +1,14 @@ +use crate::prelude::*; + +// POSIX Supplement (from errno.h) +// This particular error code is only currently available in msvc toolchain +pub const EOTHER: c_int = 131; + +extern "C" { + #[link_name = "_stricmp"] + pub fn stricmp(s1: *const c_char, s2: *const c_char) -> c_int; + #[link_name = "_strnicmp"] + pub fn strnicmp(s1: *const c_char, s2: *const c_char, n: size_t) -> c_int; + #[link_name = "_memccpy"] + pub fn memccpy(dest: *mut c_void, src: *const c_void, c: c_int, count: size_t) -> *mut c_void; +} diff --git a/http/vendor/libc/src/xous.rs b/http/vendor/libc/src/xous.rs new file mode 100644 index 0000000..2415fd4 --- /dev/null +++ b/http/vendor/libc/src/xous.rs @@ -0,0 +1,18 @@ +//! Xous C type definitions + +use crate::prelude::*; + +pub type intmax_t = i64; +pub type uintmax_t = u64; + +pub type size_t = usize; +pub type ptrdiff_t = isize; +pub type intptr_t = isize; +pub type uintptr_t = usize; +pub type ssize_t = isize; + +pub type off_t = i64; +pub type wchar_t = u32; + +pub const INT_MIN: c_int = -2147483648; +pub const INT_MAX: c_int = 2147483647; diff --git a/http/vendor/libc/tests/const_fn.rs b/http/vendor/libc/tests/const_fn.rs new file mode 100644 index 0000000..d9b41b8 --- /dev/null +++ b/http/vendor/libc/tests/const_fn.rs @@ -0,0 +1,3 @@ +#[cfg(target_os = "linux")] +const _FOO: libc::c_uint = unsafe { libc::CMSG_SPACE(1) }; +//^ if CMSG_SPACE is not const, this will fail to compile diff --git a/http/vendor/once_cell/.cargo-checksum.json b/http/vendor/once_cell/.cargo-checksum.json new file mode 100644 index 0000000..7639992 --- /dev/null +++ b/http/vendor/once_cell/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{".cargo_vcs_info.json":"abe28464063d16bc9b0ebaad2b1682fc1a8052b0968bb4277f6b265844822c67",".github/workflows/ci.yaml":"b1c9b12babf51fcaa7de2adc737c91e882da240cf847becf380141cec320cf2d","CHANGELOG.md":"c104a8ec44b9087539185006e8187a8412883b902318e0a0a807a23ac756a070","Cargo.lock":"25438daaf9e812ea9c506823a9030c708b38e0a664039c91f4d16b05d0444dd4","Cargo.toml":"87e5b7ee438abdef12e46386e86370f54ad70cabdcf949556b9ef012a9da9587","Cargo.toml.orig":"cce5bf836e33ad0e9adfb6e900d432371af2ca3861da45b719a0fce716ea810f","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"2331182c8b5a6971fd0d04a0ca711d5839e93b3de6b2003108940a8c93850aaf","bors.toml":"ebd69f714a49dceb8fd10ebadfea6e2767be4732fdef49eddf6239151b4bc78c","examples/bench.rs":"1597a52529f75d6c5ad0b86759a775b1d723dfa810e2016317283b13594219da","examples/bench_acquire.rs":"9f4912ca262194cb55e893c33739c85c2f4868d07905b9dd3238552b6ce8a6e4","examples/lazy_static.rs":"8bca1b264da21eceb1ccaf30477fc941bc71bedd030f1c6982ed3a7804abfb4f","examples/reentrant_init_deadlocks.rs":"ff84929de27a848e5b155549caa96db5db5f030afca975f8ba3f3da640083001","examples/regex.rs":"4a2e0fb093c7f5bbe0fff8689fc0c670c5334344a1bfda376f5faa98a05d459f","examples/test_synchronization.rs":"88abd5c16275bb2f2d77eaecf369d97681404a77b8edd0021f24bfd377c46be3","src/imp_cs.rs":"9eb73c340931f642664a8ee7a823af318c1118fab87b1aa63489e10a73c30945","src/imp_pl.rs":"9337fcbbfb80606de9f785f5e0f2d5ba513d7fd13918f90504bb24189831f877","src/imp_std.rs":"1c130f83be5c1360dfd379911f97797c1e4c730b845f465c8c2630467ca317d2","src/lib.rs":"9868277311543bf4a22463d41948af6e810feb40fdd7844d47893eeab1780215","src/race.rs":"4751464e8ccedb102097962a68d736de6f9434f78aa7761a1a03efd4a360c6c3","tests/it/main.rs":"e6e9987e053af84b9d76052602995b1e777efb5bc06cd5f49009e6f03b18626c","tests/it/race.rs":"5e299887123a852cb33692e27d88d59d2a007252675b60722d5e3ce5ca93dc19","tests/it/race_once_box.rs":"0cb5b3852f92002445ccc481de11642b22b9137f3a09db566cb484ab8eb32325","tests/it/sync_lazy.rs":"a36c5d66340b3d6d20aad331a499858a2125dfdfd624c5bf3b4b06a0b157c75c","tests/it/sync_once_cell.rs":"e6e539ce06966f656b24cc692603cf39241690fa58339d2775ecccda274b3769","tests/it/unsync_lazy.rs":"51a1ffd411770d1e32399ec23feb5f61be362bbed34e100eb7509f8496224e1a","tests/it/unsync_once_cell.rs":"82b72936d7bd4090db25cfc543c01ef3206d6917ac56f09d17d4110a65deb30a"},"package":"9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"} \ No newline at end of file diff --git a/http/vendor/once_cell/.cargo_vcs_info.json b/http/vendor/once_cell/.cargo_vcs_info.json new file mode 100644 index 0000000..2a60bf8 --- /dev/null +++ b/http/vendor/once_cell/.cargo_vcs_info.json @@ -0,0 +1,6 @@ +{ + "git": { + "sha1": "80fe900b21f6d76c1a2ed74d3343e8a3a88c46d0" + }, + "path_in_vcs": "" +} \ No newline at end of file diff --git a/http/vendor/once_cell/.github/workflows/ci.yaml b/http/vendor/once_cell/.github/workflows/ci.yaml new file mode 100644 index 0000000..6a998a8 --- /dev/null +++ b/http/vendor/once_cell/.github/workflows/ci.yaml @@ -0,0 +1,28 @@ +name: CI +on: + pull_request: + push: + branches: ["master", "staging", "trying"] + +env: + CARGO_INCREMENTAL: 0 + CARGO_NET_RETRY: 10 + CI: 1 + RUST_BACKTRACE: short + RUSTFLAGS: -D warnings + RUSTUP_MAX_RETRIES: 10 + +jobs: + test: + name: Rust + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 # fetch tags for publish + - uses: Swatinem/rust-cache@359a70e43a0bb8a13953b04a90f76428b4959bb6 + - run: cargo run -p xtask -- ci + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }} + MIRIFLAGS: -Zmiri-strict-provenance diff --git a/http/vendor/once_cell/CHANGELOG.md b/http/vendor/once_cell/CHANGELOG.md new file mode 100644 index 0000000..ac9797a --- /dev/null +++ b/http/vendor/once_cell/CHANGELOG.md @@ -0,0 +1,263 @@ +# Changelog + +## 1.21.4 + +- Fix unsoundness in `OnceCell::wait` under `--features=parking_lot`, [#295](https://github.com/matklad/once_cell/pull/295). + + If thread A calls `wait`, while thread B calls `get_or_try_init(f)`, and, furthermore, `f` panics, + the `wait` incorrectly returns and thread A observes uninitialized memory. + + Kudos to [@meng-xu-cs](https://github.com/meng-xu-cs) for a nice find! + +## 1.21.3 + +- Outline more initialization in `race`: [#284](https://github.com/matklad/once_cell/pull/284), + [#285](https://github.com/matklad/once_cell/pull/285). + +## 1.21.2 +- Relax success ordering from AcqRel to Release in `race`: [#278](https://github.com/matklad/once_cell/pull/278). + +## 1.21.1 +- Reduce MSRV to 1.65: [#277](https://github.com/matklad/once_cell/pull/277). + +## 1.21.0 + +- Outline initialization in `race`: [#273](https://github.com/matklad/once_cell/pull/273). +- Add `OnceNonZereUsize::get_unchecked`: [#274](https://github.com/matklad/once_cell/pull/274). +- Add `OnceBox::clone` and `OnceBox::with_value`: [#275](https://github.com/matklad/once_cell/pull/275). +- Increase MSRV to 1.70 + +## 1.20.2 + +- Remove `portable_atomic` from Cargo.lock if it is not, in fact, used: [#267](https://github.com/matklad/once_cell/pull/267) + This is a work-around for this cargo bug: https://github.com/rust-lang/cargo/issues/10801. + +## 1.20.1 + +- Allow using `race` module using just `portable_atomic`, without `critical_section` and provide + better error messages on targets without atomic CAS instruction, + [#265](https://github.com/matklad/once_cell/pull/265). + +## 1.19.0 + +- Use `portable-atomic` instead of `atomic-polyfill`, [#251](https://github.com/matklad/once_cell/pull/251). + +## 1.18.0 + +- `MSRV` is updated to 1.60.0 to take advantage of `dep:` syntax for cargo features, + removing "implementation details" from publicly visible surface. + +## 1.17.2 + +- Avoid unnecessary synchronization in `Lazy::{force,deref}_mut()`, [#231](https://github.com/matklad/once_cell/pull/231). + +## 1.17.1 + +- Make `OnceRef` implementation compliant with [strict provenance](https://github.com/rust-lang/rust/issues/95228). + +## 1.17.0 + +- Add `race::OnceRef` for storing a `&'a T`. + +## 1.16.0 + +- Add `no_std` implementation based on `critical-section`, + [#195](https://github.com/matklad/once_cell/pull/195). +- Deprecate `atomic-polyfill` feature (use the new `critical-section` instead) + +## 1.15.0 + +- Increase minimal supported Rust version to 1.56.0. +- Implement `UnwindSafe` even if the `std` feature is disabled. + +## 1.14.0 + +- Add extension to `unsync` and `sync` `Lazy` mut API: + - `force_mut` + - `get_mut` + + +## 1.13.1 + +- Make implementation compliant with [strict provenance](https://github.com/rust-lang/rust/issues/95228). +- Upgrade `atomic-polyfill` to `1.0` + +## 1.13.0 + +- Add `Lazy::get`, similar to `OnceCell::get`. + +## 1.12.1 + +- Remove incorrect `debug_assert`. + +## 1.12.0 + +- Add `OnceCell::wait`, a blocking variant of `get`. + +## 1.11.0 + +- Add `OnceCell::with_value` to create initialized `OnceCell` in `const` context. +- Improve `Clone` implementation for `OnceCell`. +- Rewrite `parking_lot` version on top of `parking_lot_core`, for even smaller cells! + +## 1.10.0 + +- upgrade `parking_lot` to `0.12.0` (note that this bumps MSRV with `parking_lot` feature enabled to `1.49.0`). + +## 1.9.0 + +- Added an `atomic-polyfill` optional dependency to compile `race` on platforms without atomics + +## 1.8.0 + +- Add `try_insert` API -- a version of `set` that returns a reference. + +## 1.7.2 + +- Improve code size when using parking_lot feature. + +## 1.7.1 + +- Fix `race::OnceBox` to also impl `Default` even if `T` doesn't impl `Default`. + +## 1.7.0 + +- Hide the `race` module behind (default) `race` feature. + Turns out that adding `race` by default was a breaking change on some platforms without atomics. + In this release, we make the module opt-out. + Technically, this is a breaking change for those who use `race` with `no_default_features`. + Given that the `race` module itself only several days old, the breakage is deemed acceptable. + +## 1.6.0 + +- Add `Lazy::into_value` +- Stabilize `once_cell::race` module for "first one wins" no_std-compatible initialization flavor. +- Migrate from deprecated `compare_and_swap` to `compare_exchange`. + +## 1.5.2 + +- `OnceBox` API uses `Box`. + This a breaking change to unstable API. + +## 1.5.1 + +- MSRV is increased to `1.36.0`. +- document `once_cell::race` module. +- introduce `alloc` feature for `OnceBox`. +- fix `OnceBox::set`. + +## 1.5.0 + +- add new `once_cell::race` module for "first one wins" no_std-compatible initialization flavor. + The API is provisional, subject to change and is gated by the `unstable` cargo feature. + +## 1.4.1 + +- upgrade `parking_lot` to `0.11.0` +- make `sync::OnceCell` pass https://doc.rust-lang.org/nomicon/dropck.html#an-escape-hatch[dropck] with `parking_lot` feature enabled. + This fixes a (minor) semver-incompatible changed introduced in `1.4.0` + +## 1.4.0 + +- upgrade `parking_lot` to `0.10` (note that this bumps MSRV with `parking_lot` feature enabled to `1.36.0`). +- add `OnceCell::take`. +- upgrade crossbeam utils (private dependency) to `0.7`. + +## 1.3.1 + +- remove unnecessary `F: fmt::Debug` bound from `impl fmt::Debug for Lazy`. + +## 1.3.0 + +- `Lazy` now implements `DerefMut`. +- update implementation according to the latest changes in `std`. + +## 1.2.0 + +- add `sync::OnceCell::get_unchecked`. + +## 1.1.0 + +- implement `Default` for `Lazy`: it creates an empty `Lazy` which is initialized with `T::default` on first access. +- add `OnceCell::get_mut`. + +## 1.0.2 + +- actually add `#![no_std]` attribute if std feature is not enabled. + +## 1.0.1 + +- fix unsoundness in `Lazy` if the initializing function panics. Thanks [@xfix](https://github.com/xfix)! +- implement `RefUnwindSafe` for `Lazy`. +- share more code between `std` and `parking_lot` implementations. +- add F.A.Q section to the docs. + +## 1.0.0 + +- remove `parking_lot` from the list of default features. +- add `std` default feature. Without `std`, only `unsync` module is supported. +- implement `Eq` for `OnceCell`. +- fix wrong `Sync` bound on `sync::Lazy`. +- run the whole test suite with miri. + +## 0.2.7 + +- New implementation of `sync::OnceCell` if `parking_lot` feature is disabled. + It now employs a hand-rolled variant of `std::sync::Once`. +- `sync::OnceCell::get_or_try_init` works without `parking_lot` as well! +- document the effects of `parking_lot` feature: same performance but smaller types. + +## 0.2.6 + +- Updated `Lazy`'s `Deref` impl to requires only `FnOnce` instead of `Fn` + +## 0.2.5 + +- `Lazy` requires only `FnOnce` instead of `Fn` + +## 0.2.4 + +- nicer `fmt::Debug` implementation + +## 0.2.3 + +- update `parking_lot` to `0.9.0` +- fix stacked borrows violation in `unsync::OnceCell::get` +- implement `Clone` for `sync::OnceCell where T: Clone` + +## 0.2.2 + +- add `OnceCell::into_inner` which consumes a cell and returns an option + +## 0.2.1 + +- implement `sync::OnceCell::get_or_try_init` if `parking_lot` feature is enabled +- switch internal `unsafe` implementation of `sync::OnceCell` from `Once` to `Mutex` +- `sync::OnceCell::get_or_init` is twice as fast if cell is already initialized +- implement `std::panic::RefUnwindSafe` and `std::panic::UnwindSafe` for `OnceCell` +- better document behavior around panics + +## 0.2.0 + +- MSRV is now 1.31.1 +- `Lazy::new` and `OnceCell::new` are now const-fns +- `unsync_lazy` and `sync_lazy` macros are removed + +## 0.1.8 + +- update crossbeam-utils to 0.6 +- enable bors-ng + +## 0.1.7 + +- cells implement `PartialEq` and `From` +- MSRV is down to 1.24.1 +- update `parking_lot` to `0.7.1` + +## 0.1.6 + +- `unsync::OnceCell` is `Clone` if `T` is `Clone`. + +## 0.1.5 + +- No changelog until this point :( diff --git a/http/vendor/once_cell/Cargo.lock b/http/vendor/once_cell/Cargo.lock new file mode 100644 index 0000000..5c074d8 --- /dev/null +++ b/http/vendor/once_cell/Cargo.lock @@ -0,0 +1,179 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "critical-section" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f64009896348fc5af4222e9cf7d7d82a95a256c634ebcf61c53e4ea461422242" + +[[package]] +name = "libc" +version = "0.2.158" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "once_cell" +version = "1.21.4" +dependencies = [ + "critical-section", + "parking_lot_core", + "portable-atomic", + "regex", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets", +] + +[[package]] +name = "portable-atomic" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" + +[[package]] +name = "redox_syscall" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0884ad60e090bf1345b93da0a5de8923c93884cd03f40dfcfddd3b4bee661853" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/http/vendor/once_cell/Cargo.toml b/http/vendor/once_cell/Cargo.toml new file mode 100644 index 0000000..cbc2491 --- /dev/null +++ b/http/vendor/once_cell/Cargo.toml @@ -0,0 +1,119 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies. +# +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. + +[package] +edition = "2021" +rust-version = "1.65" +name = "once_cell" +version = "1.21.4" +authors = ["Aleksey Kladov "] +build = false +exclude = [ + "*.png", + "*.svg", + "/Cargo.lock.msrv", + "rustfmt.toml", +] +autolib = false +autobins = false +autoexamples = false +autotests = false +autobenches = false +description = "Single assignment cells and lazy values." +documentation = "https://docs.rs/once_cell" +readme = "README.md" +keywords = [ + "lazy", + "static", +] +categories = [ + "rust-patterns", + "memory-management", +] +license = "MIT OR Apache-2.0" +repository = "https://github.com/matklad/once_cell" + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--generate-link-to-definition"] + +[features] +alloc = ["race"] +atomic-polyfill = ["critical-section"] +critical-section = [ + "dep:critical-section", + "portable-atomic", +] +default = ["std"] +parking_lot = ["dep:parking_lot_core"] +portable-atomic = ["dep:portable-atomic"] +race = [] +std = ["alloc"] +unstable = [] + +[lib] +name = "once_cell" +path = "src/lib.rs" + +[[example]] +name = "bench" +path = "examples/bench.rs" +required-features = ["std"] + +[[example]] +name = "bench_acquire" +path = "examples/bench_acquire.rs" +required-features = ["std"] + +[[example]] +name = "lazy_static" +path = "examples/lazy_static.rs" +required-features = ["std"] + +[[example]] +name = "reentrant_init_deadlocks" +path = "examples/reentrant_init_deadlocks.rs" +required-features = ["std"] + +[[example]] +name = "regex" +path = "examples/regex.rs" +required-features = ["std"] + +[[example]] +name = "test_synchronization" +path = "examples/test_synchronization.rs" +required-features = ["std"] + +[[test]] +name = "it" +path = "tests/it/main.rs" + +[dependencies.critical-section] +version = "1.1.3" +optional = true + +[dependencies.parking_lot_core] +version = "0.9.10" +optional = true +default-features = false + +[dependencies.portable-atomic] +version = "1.8" +optional = true +default-features = false + +[dev-dependencies.critical-section] +version = "1.1.3" +features = ["std"] + +[dev-dependencies.regex] +version = "1.10.6" diff --git a/http/vendor/once_cell/Cargo.toml.orig b/http/vendor/once_cell/Cargo.toml.orig new file mode 100644 index 0000000..69fffdd --- /dev/null +++ b/http/vendor/once_cell/Cargo.toml.orig @@ -0,0 +1,92 @@ +[package] +name = "once_cell" +version = "1.21.4" +authors = ["Aleksey Kladov "] +license = "MIT OR Apache-2.0" +edition = "2021" +rust-version = "1.65" + +description = "Single assignment cells and lazy values." +readme = "README.md" +documentation = "https://docs.rs/once_cell" + +repository = "https://github.com/matklad/once_cell" +keywords = ["lazy", "static"] +categories = ["rust-patterns", "memory-management"] + +exclude = ["*.png", "*.svg", "/Cargo.lock.msrv", "rustfmt.toml"] + +[workspace] +members = ["xtask"] + +[dependencies] +parking_lot_core = { version = "0.9.10", optional = true, default-features = false } +portable-atomic = { version = "1.8", optional = true, default-features = false } +critical-section = { version = "1.1.3", optional = true } + +[dev-dependencies] +regex = "1.10.6" +critical-section = { version = "1.1.3", features = ["std"] } + +[features] +default = ["std"] + +# Enables `once_cell::sync` module. +std = ["alloc"] + +# Enables `once_cell::race::OnceBox` type. +alloc = ["race"] + +# Enables `once_cell::race` module. +race = [] + +# Uses parking_lot to implement once_cell::sync::OnceCell. +# This makes no speed difference, but makes each OnceCell +# up to 16 bytes smaller, depending on the size of the T. +parking_lot = ["dep:parking_lot_core"] + +# Uses `portable-atomic` to implement `race` module. in +# `#![no_std]` mode. Please read `portable-atomic` docs carefully +# before enabling this feature. +portable-atomic = ["dep:portable-atomic"] + +# Uses `critical-section` to implement `sync` module. in +# `#![no_std]` mode. Please read `critical-section` docs carefully +# before enabling this feature. +# `portable-atomic` feature is enabled for backwards compatibility. +critical-section = ["dep:critical-section", "portable-atomic"] + +# Enables semver-exempt APIs of this crate. +# At the moment, this feature is unused. +unstable = [] + +# Only for backwards compatibility. +atomic-polyfill = ["critical-section"] + +[[example]] +name = "bench" +required-features = ["std"] + +[[example]] +name = "bench_acquire" +required-features = ["std"] + +[[example]] +name = "lazy_static" +required-features = ["std"] + +[[example]] +name = "reentrant_init_deadlocks" +required-features = ["std"] + +[[example]] +name = "regex" +required-features = ["std"] + +[[example]] +name = "test_synchronization" +required-features = ["std"] + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--generate-link-to-definition"] diff --git a/http/vendor/once_cell/LICENSE-APACHE b/http/vendor/once_cell/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/http/vendor/once_cell/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/http/vendor/once_cell/LICENSE-MIT b/http/vendor/once_cell/LICENSE-MIT new file mode 100644 index 0000000..31aa793 --- /dev/null +++ b/http/vendor/once_cell/LICENSE-MIT @@ -0,0 +1,23 @@ +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/http/vendor/once_cell/README.md b/http/vendor/once_cell/README.md new file mode 100644 index 0000000..2ac9b53 --- /dev/null +++ b/http/vendor/once_cell/README.md @@ -0,0 +1,57 @@ +

once_cell

+ + +[![Build Status](https://github.com/matklad/once_cell/actions/workflows/ci.yaml/badge.svg)](https://github.com/matklad/once_cell/actions) +[![Crates.io](https://img.shields.io/crates/v/once_cell.svg)](https://crates.io/crates/once_cell) +[![API reference](https://docs.rs/once_cell/badge.svg)](https://docs.rs/once_cell/) + +# Overview + +`once_cell` provides two new cell-like types, `unsync::OnceCell` and `sync::OnceCell`. `OnceCell` +might store arbitrary non-`Copy` types, can be assigned to at most once and provide direct access +to the stored contents. In a nutshell, API looks *roughly* like this: + +```rust +impl OnceCell { + fn new() -> OnceCell { ... } + fn set(&self, value: T) -> Result<(), T> { ... } + fn get(&self) -> Option<&T> { ... } +} +``` + +Note that, like with `RefCell` and `Mutex`, the `set` method requires only a shared reference. +Because of the single assignment restriction `get` can return an `&T` instead of `Ref` +or `MutexGuard`. + +`once_cell` also has a `Lazy` type, build on top of `OnceCell` which provides the same API as +the `lazy_static!` macro, but without using any macros: + +```rust +use std::{sync::Mutex, collections::HashMap}; +use once_cell::sync::Lazy; + +static GLOBAL_DATA: Lazy>> = Lazy::new(|| { + let mut m = HashMap::new(); + m.insert(13, "Spica".to_string()); + m.insert(74, "Hoyten".to_string()); + Mutex::new(m) +}); + +fn main() { + println!("{:?}", GLOBAL_DATA.lock().unwrap()); +} +``` + +More patterns and use-cases are in the [docs](https://docs.rs/once_cell/)! + +# Related crates + +* [double-checked-cell](https://github.com/niklasf/double-checked-cell) +* [lazy-init](https://crates.io/crates/lazy-init) +* [lazycell](https://crates.io/crates/lazycell) +* [mitochondria](https://crates.io/crates/mitochondria) +* [lazy_static](https://crates.io/crates/lazy_static) +* [async_once_cell](https://crates.io/crates/async_once_cell) +* [generic_once_cell](https://crates.io/crates/generic_once_cell) (bring your own mutex) + +Parts of `once_cell` API are included into `std` [as of Rust 1.70.0](https://github.com/rust-lang/rust/pull/105587). diff --git a/http/vendor/once_cell/bors.toml b/http/vendor/once_cell/bors.toml new file mode 100644 index 0000000..b92b99a --- /dev/null +++ b/http/vendor/once_cell/bors.toml @@ -0,0 +1,2 @@ +status = [ "Rust" ] +delete_merged_branches = true diff --git a/http/vendor/once_cell/examples/bench.rs b/http/vendor/once_cell/examples/bench.rs new file mode 100644 index 0000000..e680125 --- /dev/null +++ b/http/vendor/once_cell/examples/bench.rs @@ -0,0 +1,28 @@ +use std::mem::size_of; + +use once_cell::sync::OnceCell; + +const N_THREADS: usize = 32; +const N_ROUNDS: usize = 100_000_000; + +static CELL: OnceCell = OnceCell::new(); + +fn main() { + let start = std::time::Instant::now(); + let threads = + (0..N_THREADS).map(|i| std::thread::spawn(move || thread_main(i))).collect::>(); + for thread in threads { + thread.join().unwrap(); + } + println!("{:?}", start.elapsed()); + println!("size_of::>() = {:?}", size_of::>()); + println!("size_of::>() = {:?}", size_of::>()); + println!("size_of::>() = {:?}", size_of::>()); +} + +fn thread_main(i: usize) { + for _ in 0..N_ROUNDS { + let &value = CELL.get_or_init(|| i); + assert!(value < N_THREADS) + } +} diff --git a/http/vendor/once_cell/examples/bench_acquire.rs b/http/vendor/once_cell/examples/bench_acquire.rs new file mode 100644 index 0000000..1518047 --- /dev/null +++ b/http/vendor/once_cell/examples/bench_acquire.rs @@ -0,0 +1,39 @@ +//! Benchmark the overhead that the synchronization of `OnceCell::get` causes. +//! We do some other operations that write to memory to get an imprecise but somewhat realistic +//! measurement. + +use once_cell::sync::OnceCell; +use std::sync::atomic::{AtomicUsize, Ordering}; + +const N_THREADS: usize = 16; +const N_ROUNDS: usize = 1_000_000; + +static CELL: OnceCell = OnceCell::new(); +static OTHER: AtomicUsize = AtomicUsize::new(0); + +fn main() { + let start = std::time::Instant::now(); + let threads = + (0..N_THREADS).map(|i| std::thread::spawn(move || thread_main(i))).collect::>(); + for thread in threads { + thread.join().unwrap(); + } + println!("{:?}", start.elapsed()); + println!("{:?}", OTHER.load(Ordering::Relaxed)); +} + +#[inline(never)] +fn thread_main(i: usize) { + // The operations we do here don't really matter, as long as we do multiple writes, and + // everything is messy enough to prevent the compiler from optimizing the loop away. + let mut data = [i; 128]; + let mut accum = 0usize; + for _ in 0..N_ROUNDS { + let _value = CELL.get_or_init(|| i + 1); + let k = OTHER.fetch_add(data[accum & 0x7F] as usize, Ordering::Relaxed); + for j in data.iter_mut() { + *j = (*j).wrapping_add(accum); + accum = accum.wrapping_add(k); + } + } +} diff --git a/http/vendor/once_cell/examples/lazy_static.rs b/http/vendor/once_cell/examples/lazy_static.rs new file mode 100644 index 0000000..3cdb19f --- /dev/null +++ b/http/vendor/once_cell/examples/lazy_static.rs @@ -0,0 +1,36 @@ +extern crate once_cell; + +use once_cell::sync::{Lazy, OnceCell}; +use std::collections::HashMap; + +static HASHMAP: Lazy> = Lazy::new(|| { + let mut m = HashMap::new(); + m.insert(0, "foo"); + m.insert(1, "bar"); + m.insert(2, "baz"); + m +}); + +// Same, but completely without macros +fn hashmap() -> &'static HashMap { + static INSTANCE: OnceCell> = OnceCell::new(); + INSTANCE.get_or_init(|| { + let mut m = HashMap::new(); + m.insert(0, "foo"); + m.insert(1, "bar"); + m.insert(2, "baz"); + m + }) +} + +fn main() { + // First access to `HASHMAP` initializes it + println!("The entry for `0` is \"{}\".", HASHMAP.get(&0).unwrap()); + + // Any further access to `HASHMAP` just returns the computed value + println!("The entry for `1` is \"{}\".", HASHMAP.get(&1).unwrap()); + + // The same works for function-style: + assert_eq!(hashmap().get(&0), Some(&"foo")); + assert_eq!(hashmap().get(&1), Some(&"bar")); +} diff --git a/http/vendor/once_cell/examples/reentrant_init_deadlocks.rs b/http/vendor/once_cell/examples/reentrant_init_deadlocks.rs new file mode 100644 index 0000000..af4b5b7 --- /dev/null +++ b/http/vendor/once_cell/examples/reentrant_init_deadlocks.rs @@ -0,0 +1,14 @@ +fn main() { + let cell = once_cell::sync::OnceCell::::new(); + cell.get_or_init(|| { + cell.get_or_init(|| 1); + 2 + }); +} + +/// Dummy test to make it seem hang when compiled as `--test` +/// See https://github.com/matklad/once_cell/issues/79 +#[test] +fn dummy_test() { + std::thread::sleep(std::time::Duration::from_secs(4)); +} diff --git a/http/vendor/once_cell/examples/regex.rs b/http/vendor/once_cell/examples/regex.rs new file mode 100644 index 0000000..4c4c2ea --- /dev/null +++ b/http/vendor/once_cell/examples/regex.rs @@ -0,0 +1,49 @@ +use std::{str::FromStr, time::Instant}; + +use regex::Regex; + +macro_rules! regex { + ($re:literal $(,)?) => {{ + static RE: once_cell::sync::OnceCell = once_cell::sync::OnceCell::new(); + RE.get_or_init(|| regex::Regex::new($re).unwrap()) + }}; +} + +fn slow() { + let s = r##"13.28.24.13 - - [10/Mar/2016:19:29:25 +0100] "GET /etc/lib/pChart2/examples/index.php?Action=View&Script=../../../../cnf/db.php HTTP/1.1" 404 151 "-" "HTTP_Request2/2.2.1 (http://pear.php.net/package/http_request2) PHP/5.3.16""##; + + let mut total = 0; + for _ in 0..1000 { + let re = Regex::new( + r##"^(\S+) (\S+) (\S+) \[([^]]+)\] "([^"]*)" (\d+) (\d+) "([^"]*)" "([^"]*)"$"##, + ) + .unwrap(); + let size = usize::from_str(re.captures(s).unwrap().get(7).unwrap().as_str()).unwrap(); + total += size; + } + println!("{}", total); +} + +fn fast() { + let s = r##"13.28.24.13 - - [10/Mar/2016:19:29:25 +0100] "GET /etc/lib/pChart2/examples/index.php?Action=View&Script=../../../../cnf/db.php HTTP/1.1" 404 151 "-" "HTTP_Request2/2.2.1 (http://pear.php.net/package/http_request2) PHP/5.3.16""##; + + let mut total = 0; + for _ in 0..1000 { + let re: &Regex = regex!( + r##"^(\S+) (\S+) (\S+) \[([^]]+)\] "([^"]*)" (\d+) (\d+) "([^"]*)" "([^"]*)"$"##, + ); + let size = usize::from_str(re.captures(s).unwrap().get(7).unwrap().as_str()).unwrap(); + total += size; + } + println!("{}", total); +} + +fn main() { + let t = Instant::now(); + slow(); + println!("slow: {:?}", t.elapsed()); + + let t = Instant::now(); + fast(); + println!("fast: {:?}", t.elapsed()); +} diff --git a/http/vendor/once_cell/examples/test_synchronization.rs b/http/vendor/once_cell/examples/test_synchronization.rs new file mode 100644 index 0000000..0d54f98 --- /dev/null +++ b/http/vendor/once_cell/examples/test_synchronization.rs @@ -0,0 +1,38 @@ +//! Test if the OnceCell properly synchronizes. +//! Needs to be run in release mode. +//! +//! We create a `Vec` with `N_ROUNDS` of `OnceCell`s. All threads will walk the `Vec`, and race to +//! be the first one to initialize a cell. +//! Every thread adds the results of the cells it sees to an accumulator, which is compared at the +//! end. +//! All threads should end up with the same result. + +use once_cell::sync::OnceCell; + +const N_THREADS: usize = 32; +const N_ROUNDS: usize = 1_000_000; + +static CELLS: OnceCell>> = OnceCell::new(); +static RESULT: OnceCell = OnceCell::new(); + +fn main() { + let start = std::time::Instant::now(); + CELLS.get_or_init(|| vec![OnceCell::new(); N_ROUNDS]); + let threads = + (0..N_THREADS).map(|i| std::thread::spawn(move || thread_main(i))).collect::>(); + for thread in threads { + thread.join().unwrap(); + } + println!("{:?}", start.elapsed()); + println!("No races detected"); +} + +fn thread_main(i: usize) { + let cells = CELLS.get().unwrap(); + let mut accum = 0; + for cell in cells.iter() { + let &value = cell.get_or_init(|| i); + accum += value; + } + assert_eq!(RESULT.get_or_init(|| accum), &accum); +} diff --git a/http/vendor/once_cell/src/imp_cs.rs b/http/vendor/once_cell/src/imp_cs.rs new file mode 100644 index 0000000..6b8d53d --- /dev/null +++ b/http/vendor/once_cell/src/imp_cs.rs @@ -0,0 +1,78 @@ +use core::panic::{RefUnwindSafe, UnwindSafe}; + +use critical_section::{CriticalSection, Mutex}; +use portable_atomic::{AtomicBool, Ordering}; + +use crate::unsync; + +pub(crate) struct OnceCell { + initialized: AtomicBool, + // Use `unsync::OnceCell` internally since `Mutex` does not provide + // interior mutability and to be able to re-use `get_or_try_init`. + value: Mutex>, +} + +// Why do we need `T: Send`? +// Thread A creates a `OnceCell` and shares it with +// scoped thread B, which fills the cell, which is +// then destroyed by A. That is, destructor observes +// a sent value. +unsafe impl Sync for OnceCell {} +unsafe impl Send for OnceCell {} + +impl RefUnwindSafe for OnceCell {} +impl UnwindSafe for OnceCell {} + +impl OnceCell { + pub(crate) const fn new() -> OnceCell { + OnceCell { initialized: AtomicBool::new(false), value: Mutex::new(unsync::OnceCell::new()) } + } + + pub(crate) const fn with_value(value: T) -> OnceCell { + OnceCell { + initialized: AtomicBool::new(true), + value: Mutex::new(unsync::OnceCell::with_value(value)), + } + } + + #[inline] + pub(crate) fn is_initialized(&self) -> bool { + self.initialized.load(Ordering::Acquire) + } + + #[cold] + pub(crate) fn initialize(&self, f: F) -> Result<(), E> + where + F: FnOnce() -> Result, + { + critical_section::with(|cs| { + let cell = self.value.borrow(cs); + cell.get_or_try_init(f).map(|_| { + self.initialized.store(true, Ordering::Release); + }) + }) + } + + /// Get the reference to the underlying value, without checking if the cell + /// is initialized. + /// + /// # Safety + /// + /// Caller must ensure that the cell is in initialized state, and that + /// the contents are acquired by (synchronized to) this thread. + pub(crate) unsafe fn get_unchecked(&self) -> &T { + debug_assert!(self.is_initialized()); + // SAFETY: The caller ensures that the value is initialized and access synchronized. + self.value.borrow(CriticalSection::new()).get().unwrap_unchecked() + } + + #[inline] + pub(crate) fn get_mut(&mut self) -> Option<&mut T> { + self.value.get_mut().get_mut() + } + + #[inline] + pub(crate) fn into_inner(self) -> Option { + self.value.into_inner().into_inner() + } +} diff --git a/http/vendor/once_cell/src/imp_pl.rs b/http/vendor/once_cell/src/imp_pl.rs new file mode 100644 index 0000000..93bfced --- /dev/null +++ b/http/vendor/once_cell/src/imp_pl.rs @@ -0,0 +1,176 @@ +use std::{ + cell::UnsafeCell, + panic::{RefUnwindSafe, UnwindSafe}, + sync::atomic::{AtomicU8, Ordering}, +}; + +pub(crate) struct OnceCell { + state: AtomicU8, + value: UnsafeCell>, +} + +const INCOMPLETE: u8 = 0x0; +const RUNNING: u8 = 0x1; +const COMPLETE: u8 = 0x2; + +// Why do we need `T: Send`? +// Thread A creates a `OnceCell` and shares it with +// scoped thread B, which fills the cell, which is +// then destroyed by A. That is, destructor observes +// a sent value. +unsafe impl Sync for OnceCell {} +unsafe impl Send for OnceCell {} + +impl RefUnwindSafe for OnceCell {} +impl UnwindSafe for OnceCell {} + +impl OnceCell { + pub(crate) const fn new() -> OnceCell { + OnceCell { state: AtomicU8::new(INCOMPLETE), value: UnsafeCell::new(None) } + } + + pub(crate) const fn with_value(value: T) -> OnceCell { + OnceCell { state: AtomicU8::new(COMPLETE), value: UnsafeCell::new(Some(value)) } + } + + /// Safety: synchronizes with store to value via Release/Acquire. + #[inline] + pub(crate) fn is_initialized(&self) -> bool { + self.state.load(Ordering::Acquire) == COMPLETE + } + + /// Safety: synchronizes with store to value via `is_initialized` or mutex + /// lock/unlock, writes value only once because of the mutex. + #[cold] + pub(crate) fn initialize(&self, f: F) -> Result<(), E> + where + F: FnOnce() -> Result, + { + let mut f = Some(f); + let mut res: Result<(), E> = Ok(()); + let slot: *mut Option = self.value.get(); + initialize_inner(&self.state, &mut || { + // We are calling user-supplied function and need to be careful. + // - if it returns Err, we unlock mutex and return without touching anything + // - if it panics, we unlock mutex and propagate panic without touching anything + // - if it calls `set` or `get_or_try_init` re-entrantly, we get a deadlock on + // mutex, which is important for safety. We *could* detect this and panic, + // but that is more complicated + // - finally, if it returns Ok, we store the value and store the flag with + // `Release`, which synchronizes with `Acquire`s. + let f = unsafe { f.take().unwrap_unchecked() }; + match f() { + Ok(value) => unsafe { + // Safe b/c we have a unique access and no panic may happen + // until the cell is marked as initialized. + debug_assert!((*slot).is_none()); + *slot = Some(value); + true + }, + Err(err) => { + res = Err(err); + false + } + } + }); + res + } + + #[cold] + pub(crate) fn wait(&self) { + let key = &self.state as *const _ as usize; + unsafe { + while self.state.load(Ordering::Acquire) != COMPLETE { + parking_lot_core::park( + key, + || self.state.load(Ordering::Acquire) != COMPLETE, + || (), + |_, _| (), + parking_lot_core::DEFAULT_PARK_TOKEN, + None, + ); + } + } + } + + /// Get the reference to the underlying value, without checking if the cell + /// is initialized. + /// + /// # Safety + /// + /// Caller must ensure that the cell is in initialized state, and that + /// the contents are acquired by (synchronized to) this thread. + pub(crate) unsafe fn get_unchecked(&self) -> &T { + debug_assert!(self.is_initialized()); + let slot = &*self.value.get(); + slot.as_ref().unwrap_unchecked() + } + + /// Gets the mutable reference to the underlying value. + /// Returns `None` if the cell is empty. + pub(crate) fn get_mut(&mut self) -> Option<&mut T> { + // Safe b/c we have an exclusive access + let slot: &mut Option = unsafe { &mut *self.value.get() }; + slot.as_mut() + } + + /// Consumes this `OnceCell`, returning the wrapped value. + /// Returns `None` if the cell was empty. + pub(crate) fn into_inner(self) -> Option { + self.value.into_inner() + } +} + +struct Guard<'a> { + state: &'a AtomicU8, + new_state: u8, +} + +impl<'a> Drop for Guard<'a> { + fn drop(&mut self) { + self.state.store(self.new_state, Ordering::Release); + unsafe { + let key = self.state as *const AtomicU8 as usize; + parking_lot_core::unpark_all(key, parking_lot_core::DEFAULT_UNPARK_TOKEN); + } + } +} + +// Note: this is intentionally monomorphic +#[inline(never)] +fn initialize_inner(state: &AtomicU8, init: &mut dyn FnMut() -> bool) { + loop { + let exchange = + state.compare_exchange_weak(INCOMPLETE, RUNNING, Ordering::Acquire, Ordering::Acquire); + match exchange { + Ok(_) => { + let mut guard = Guard { state, new_state: INCOMPLETE }; + if init() { + guard.new_state = COMPLETE; + } + return; + } + Err(COMPLETE) => return, + Err(RUNNING) => unsafe { + let key = state as *const AtomicU8 as usize; + parking_lot_core::park( + key, + || state.load(Ordering::Relaxed) == RUNNING, + || (), + |_, _| (), + parking_lot_core::DEFAULT_PARK_TOKEN, + None, + ); + }, + Err(INCOMPLETE) => (), + Err(_) => debug_assert!(false), + } + } +} + +#[test] +fn test_size() { + use std::mem::size_of; + + assert_eq!(size_of::>(), 1 * size_of::() + size_of::()); +} diff --git a/http/vendor/once_cell/src/imp_std.rs b/http/vendor/once_cell/src/imp_std.rs new file mode 100644 index 0000000..3b9e6d2 --- /dev/null +++ b/http/vendor/once_cell/src/imp_std.rs @@ -0,0 +1,415 @@ +// There's a lot of scary concurrent code in this module, but it is copied from +// `std::sync::Once` with two changes: +// * no poisoning +// * init function can fail + +use std::{ + cell::{Cell, UnsafeCell}, + panic::{RefUnwindSafe, UnwindSafe}, + sync::atomic::{AtomicBool, AtomicPtr, Ordering}, + thread::{self, Thread}, +}; + +#[derive(Debug)] +pub(crate) struct OnceCell { + // This `queue` field is the core of the implementation. It encodes two + // pieces of information: + // + // * The current state of the cell (`INCOMPLETE`, `RUNNING`, `COMPLETE`) + // * Linked list of threads waiting for the current cell. + // + // State is encoded in two low bits. Only `INCOMPLETE` and `RUNNING` states + // allow waiters. + queue: AtomicPtr, + value: UnsafeCell>, +} + +// Why do we need `T: Send`? +// Thread A creates a `OnceCell` and shares it with +// scoped thread B, which fills the cell, which is +// then destroyed by A. That is, destructor observes +// a sent value. +unsafe impl Sync for OnceCell {} +unsafe impl Send for OnceCell {} + +impl RefUnwindSafe for OnceCell {} +impl UnwindSafe for OnceCell {} + +impl OnceCell { + pub(crate) const fn new() -> OnceCell { + OnceCell { queue: AtomicPtr::new(INCOMPLETE_PTR), value: UnsafeCell::new(None) } + } + + pub(crate) const fn with_value(value: T) -> OnceCell { + OnceCell { queue: AtomicPtr::new(COMPLETE_PTR), value: UnsafeCell::new(Some(value)) } + } + + /// Safety: synchronizes with store to value via Release/(Acquire|SeqCst). + #[inline] + pub(crate) fn is_initialized(&self) -> bool { + // An `Acquire` load is enough because that makes all the initialization + // operations visible to us, and, this being a fast path, weaker + // ordering helps with performance. This `Acquire` synchronizes with + // `SeqCst` operations on the slow path. + self.queue.load(Ordering::Acquire) == COMPLETE_PTR + } + + /// Safety: synchronizes with store to value via SeqCst read from state, + /// writes value only once because we never get to INCOMPLETE state after a + /// successful write. + #[cold] + pub(crate) fn initialize(&self, f: F) -> Result<(), E> + where + F: FnOnce() -> Result, + { + let mut f = Some(f); + let mut res: Result<(), E> = Ok(()); + let slot: *mut Option = self.value.get(); + initialize_or_wait( + &self.queue, + Some(&mut || { + let f = unsafe { f.take().unwrap_unchecked() }; + match f() { + Ok(value) => { + unsafe { *slot = Some(value) }; + true + } + Err(err) => { + res = Err(err); + false + } + } + }), + ); + res + } + + #[cold] + pub(crate) fn wait(&self) { + initialize_or_wait(&self.queue, None); + } + + /// Get the reference to the underlying value, without checking if the cell + /// is initialized. + /// + /// # Safety + /// + /// Caller must ensure that the cell is in initialized state, and that + /// the contents are acquired by (synchronized to) this thread. + pub(crate) unsafe fn get_unchecked(&self) -> &T { + debug_assert!(self.is_initialized()); + let slot = &*self.value.get(); + slot.as_ref().unwrap_unchecked() + } + + /// Gets the mutable reference to the underlying value. + /// Returns `None` if the cell is empty. + pub(crate) fn get_mut(&mut self) -> Option<&mut T> { + // Safe b/c we have a unique access. + unsafe { &mut *self.value.get() }.as_mut() + } + + /// Consumes this `OnceCell`, returning the wrapped value. + /// Returns `None` if the cell was empty. + #[inline] + pub(crate) fn into_inner(self) -> Option { + // Because `into_inner` takes `self` by value, the compiler statically + // verifies that it is not currently borrowed. + // So, it is safe to move out `Option`. + self.value.into_inner() + } +} + +// Three states that a OnceCell can be in, encoded into the lower bits of `queue` in +// the OnceCell structure. +const INCOMPLETE: usize = 0x0; +const RUNNING: usize = 0x1; +const COMPLETE: usize = 0x2; +const INCOMPLETE_PTR: *mut Waiter = INCOMPLETE as *mut Waiter; +const COMPLETE_PTR: *mut Waiter = COMPLETE as *mut Waiter; + +// Mask to learn about the state. All other bits are the queue of waiters if +// this is in the RUNNING state. +const STATE_MASK: usize = 0x3; + +/// Representation of a node in the linked list of waiters in the RUNNING state. +/// A waiters is stored on the stack of the waiting threads. +#[repr(align(4))] // Ensure the two lower bits are free to use as state bits. +struct Waiter { + thread: Cell>, + signaled: AtomicBool, + next: *mut Waiter, +} + +/// Drains and notifies the queue of waiters on drop. +struct Guard<'a> { + queue: &'a AtomicPtr, + new_queue: *mut Waiter, +} + +impl Drop for Guard<'_> { + fn drop(&mut self) { + let queue = self.queue.swap(self.new_queue, Ordering::AcqRel); + + let state = strict::addr(queue) & STATE_MASK; + assert_eq!(state, RUNNING); + + unsafe { + let mut waiter = strict::map_addr(queue, |q| q & !STATE_MASK); + while !waiter.is_null() { + let next = (*waiter).next; + let thread = (*waiter).thread.take().unwrap(); + (*waiter).signaled.store(true, Ordering::Release); + waiter = next; + thread.unpark(); + } + } + } +} + +// Corresponds to `std::sync::Once::call_inner`. +// +// Originally copied from std, but since modified to remove poisoning and to +// support wait. +// +// Note: this is intentionally monomorphic +#[inline(never)] +fn initialize_or_wait(queue: &AtomicPtr, mut init: Option<&mut dyn FnMut() -> bool>) { + let mut curr_queue = queue.load(Ordering::Acquire); + + loop { + let curr_state = strict::addr(curr_queue) & STATE_MASK; + match (curr_state, &mut init) { + (COMPLETE, _) => return, + (INCOMPLETE, Some(init)) => { + let exchange = queue.compare_exchange( + curr_queue, + strict::map_addr(curr_queue, |q| (q & !STATE_MASK) | RUNNING), + Ordering::Acquire, + Ordering::Acquire, + ); + if let Err(new_queue) = exchange { + curr_queue = new_queue; + continue; + } + let mut guard = Guard { queue, new_queue: INCOMPLETE_PTR }; + if init() { + guard.new_queue = COMPLETE_PTR; + } + return; + } + (INCOMPLETE, None) | (RUNNING, _) => { + wait(queue, curr_queue); + curr_queue = queue.load(Ordering::Acquire); + } + _ => debug_assert!(false), + } + } +} + +fn wait(queue: &AtomicPtr, mut curr_queue: *mut Waiter) { + let curr_state = strict::addr(curr_queue) & STATE_MASK; + loop { + let node = Waiter { + thread: Cell::new(Some(thread::current())), + signaled: AtomicBool::new(false), + next: strict::map_addr(curr_queue, |q| q & !STATE_MASK), + }; + let me = &node as *const Waiter as *mut Waiter; + + let exchange = queue.compare_exchange( + curr_queue, + strict::map_addr(me, |q| q | curr_state), + Ordering::Release, + Ordering::Relaxed, + ); + if let Err(new_queue) = exchange { + if strict::addr(new_queue) & STATE_MASK != curr_state { + return; + } + curr_queue = new_queue; + continue; + } + + while !node.signaled.load(Ordering::Acquire) { + thread::park(); + } + break; + } +} + +// Polyfill of strict provenance from https://crates.io/crates/sptr. +// +// Use free-standing function rather than a trait to keep things simple and +// avoid any potential conflicts with future stabile std API. +mod strict { + #[must_use] + #[inline] + pub(crate) fn addr(ptr: *mut T) -> usize + where + T: Sized, + { + // FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic. + // SAFETY: Pointer-to-integer transmutes are valid (if you are okay with losing the + // provenance). + unsafe { core::mem::transmute(ptr) } + } + + #[must_use] + #[inline] + pub(crate) fn with_addr(ptr: *mut T, addr: usize) -> *mut T + where + T: Sized, + { + // FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic. + // + // In the mean-time, this operation is defined to be "as if" it was + // a wrapping_offset, so we can emulate it as such. This should properly + // restore pointer provenance even under today's compiler. + let self_addr = self::addr(ptr) as isize; + let dest_addr = addr as isize; + let offset = dest_addr.wrapping_sub(self_addr); + + // This is the canonical desugarring of this operation, + // but `pointer::cast` was only stabilized in 1.38. + // self.cast::().wrapping_offset(offset).cast::() + (ptr as *mut u8).wrapping_offset(offset) as *mut T + } + + #[must_use] + #[inline] + pub(crate) fn map_addr(ptr: *mut T, f: impl FnOnce(usize) -> usize) -> *mut T + where + T: Sized, + { + self::with_addr(ptr, f(addr(ptr))) + } +} + +// These test are snatched from std as well. +#[cfg(test)] +mod tests { + use std::panic; + use std::{sync::mpsc::channel, thread}; + + use super::OnceCell; + + impl OnceCell { + fn init(&self, f: impl FnOnce() -> T) { + enum Void {} + let _ = self.initialize(|| Ok::(f())); + } + } + + #[test] + fn smoke_once() { + static O: OnceCell<()> = OnceCell::new(); + let mut a = 0; + O.init(|| a += 1); + assert_eq!(a, 1); + O.init(|| a += 1); + assert_eq!(a, 1); + } + + #[test] + fn stampede_once() { + static O: OnceCell<()> = OnceCell::new(); + static mut RUN: bool = false; + + let (tx, rx) = channel(); + for _ in 0..10 { + let tx = tx.clone(); + thread::spawn(move || { + for _ in 0..4 { + thread::yield_now() + } + unsafe { + O.init(|| { + assert!(!RUN); + RUN = true; + }); + assert!(RUN); + } + tx.send(()).unwrap(); + }); + } + + unsafe { + O.init(|| { + assert!(!RUN); + RUN = true; + }); + assert!(RUN); + } + + for _ in 0..10 { + rx.recv().unwrap(); + } + } + + #[test] + fn poison_bad() { + static O: OnceCell<()> = OnceCell::new(); + + // poison the once + let t = panic::catch_unwind(|| { + O.init(|| panic!()); + }); + assert!(t.is_err()); + + // we can subvert poisoning, however + let mut called = false; + O.init(|| { + called = true; + }); + assert!(called); + + // once any success happens, we stop propagating the poison + O.init(|| {}); + } + + #[test] + fn wait_for_force_to_finish() { + static O: OnceCell<()> = OnceCell::new(); + + // poison the once + let t = panic::catch_unwind(|| { + O.init(|| panic!()); + }); + assert!(t.is_err()); + + // make sure someone's waiting inside the once via a force + let (tx1, rx1) = channel(); + let (tx2, rx2) = channel(); + let t1 = thread::spawn(move || { + O.init(|| { + tx1.send(()).unwrap(); + rx2.recv().unwrap(); + }); + }); + + rx1.recv().unwrap(); + + // put another waiter on the once + let t2 = thread::spawn(|| { + let mut called = false; + O.init(|| { + called = true; + }); + assert!(!called); + }); + + tx2.send(()).unwrap(); + + assert!(t1.join().is_ok()); + assert!(t2.join().is_ok()); + } + + #[test] + #[cfg(target_pointer_width = "64")] + fn test_size() { + use std::mem::size_of; + + assert_eq!(size_of::>(), 4 * size_of::()); + } +} diff --git a/http/vendor/once_cell/src/lib.rs b/http/vendor/once_cell/src/lib.rs new file mode 100644 index 0000000..0ccab15 --- /dev/null +++ b/http/vendor/once_cell/src/lib.rs @@ -0,0 +1,1422 @@ +//! # Overview +//! +//! `once_cell` provides two new cell-like types, [`unsync::OnceCell`] and +//! [`sync::OnceCell`]. A `OnceCell` might store arbitrary non-`Copy` types, can +//! be assigned to at most once and provides direct access to the stored +//! contents. The core API looks *roughly* like this (and there's much more +//! inside, read on!): +//! +//! ```rust,ignore +//! impl OnceCell { +//! const fn new() -> OnceCell { ... } +//! fn set(&self, value: T) -> Result<(), T> { ... } +//! fn get(&self) -> Option<&T> { ... } +//! } +//! ``` +//! +//! Note that, like with [`RefCell`] and [`Mutex`], the `set` method requires +//! only a shared reference. Because of the single assignment restriction `get` +//! can return a `&T` instead of `Ref` or `MutexGuard`. +//! +//! The `sync` flavor is thread-safe (that is, implements the [`Sync`] trait), +//! while the `unsync` one is not. +//! +//! [`unsync::OnceCell`]: unsync/struct.OnceCell.html +//! [`sync::OnceCell`]: sync/struct.OnceCell.html +//! [`RefCell`]: https://doc.rust-lang.org/std/cell/struct.RefCell.html +//! [`Mutex`]: https://doc.rust-lang.org/std/sync/struct.Mutex.html +//! [`Sync`]: https://doc.rust-lang.org/std/marker/trait.Sync.html +//! +//! # Recipes +//! +//! `OnceCell` might be useful for a variety of patterns. +//! +//! ## Safe Initialization of Global Data +//! +//! ```rust +//! # #[cfg(any(feature = "std", feature = "critical-section"))] { +//! use std::{env, io}; +//! +//! use once_cell::sync::OnceCell; +//! +//! #[derive(Debug)] +//! pub struct Logger { +//! // ... +//! } +//! static INSTANCE: OnceCell = OnceCell::new(); +//! +//! impl Logger { +//! pub fn global() -> &'static Logger { +//! INSTANCE.get().expect("logger is not initialized") +//! } +//! +//! fn from_cli(args: env::Args) -> Result { +//! // ... +//! # Ok(Logger {}) +//! } +//! } +//! +//! fn main() { +//! let logger = Logger::from_cli(env::args()).unwrap(); +//! INSTANCE.set(logger).unwrap(); +//! // use `Logger::global()` from now on +//! } +//! # } +//! ``` +//! +//! ## Lazy Initialized Global Data +//! +//! This is essentially the `lazy_static!` macro, but without a macro. +//! +//! ```rust +//! # #[cfg(any(feature = "std", feature = "critical-section"))] { +//! use std::{sync::Mutex, collections::HashMap}; +//! +//! use once_cell::sync::OnceCell; +//! +//! fn global_data() -> &'static Mutex> { +//! static INSTANCE: OnceCell>> = OnceCell::new(); +//! INSTANCE.get_or_init(|| { +//! let mut m = HashMap::new(); +//! m.insert(13, "Spica".to_string()); +//! m.insert(74, "Hoyten".to_string()); +//! Mutex::new(m) +//! }) +//! } +//! # } +//! ``` +//! +//! There are also the [`sync::Lazy`] and [`unsync::Lazy`] convenience types to +//! streamline this pattern: +//! +//! ```rust +//! # #[cfg(any(feature = "std", feature = "critical-section"))] { +//! use std::{sync::Mutex, collections::HashMap}; +//! use once_cell::sync::Lazy; +//! +//! static GLOBAL_DATA: Lazy>> = Lazy::new(|| { +//! let mut m = HashMap::new(); +//! m.insert(13, "Spica".to_string()); +//! m.insert(74, "Hoyten".to_string()); +//! Mutex::new(m) +//! }); +//! +//! fn main() { +//! println!("{:?}", GLOBAL_DATA.lock().unwrap()); +//! } +//! # } +//! ``` +//! +//! Note that the variable that holds `Lazy` is declared as `static`, *not* +//! `const`. This is important: using `const` instead compiles, but works wrong. +//! +//! [`sync::Lazy`]: sync/struct.Lazy.html +//! [`unsync::Lazy`]: unsync/struct.Lazy.html +//! +//! ## General purpose lazy evaluation +//! +//! Unlike `lazy_static!`, `Lazy` works with local variables. +//! +//! ```rust +//! use once_cell::unsync::Lazy; +//! +//! fn main() { +//! let ctx = vec![1, 2, 3]; +//! let thunk = Lazy::new(|| { +//! ctx.iter().sum::() +//! }); +//! assert_eq!(*thunk, 6); +//! } +//! ``` +//! +//! If you need a lazy field in a struct, you probably should use `OnceCell` +//! directly, because that will allow you to access `self` during +//! initialization. +//! +//! ```rust +//! use std::{fs, path::PathBuf}; +//! +//! use once_cell::unsync::OnceCell; +//! +//! struct Ctx { +//! config_path: PathBuf, +//! config: OnceCell, +//! } +//! +//! impl Ctx { +//! pub fn get_config(&self) -> Result<&str, std::io::Error> { +//! let cfg = self.config.get_or_try_init(|| { +//! fs::read_to_string(&self.config_path) +//! })?; +//! Ok(cfg.as_str()) +//! } +//! } +//! ``` +//! +//! ## Lazily Compiled Regex +//! +//! This is a `regex!` macro which takes a string literal and returns an +//! *expression* that evaluates to a `&'static Regex`: +//! +//! ``` +//! macro_rules! regex { +//! ($re:literal $(,)?) => {{ +//! static RE: once_cell::sync::OnceCell = once_cell::sync::OnceCell::new(); +//! RE.get_or_init(|| regex::Regex::new($re).unwrap()) +//! }}; +//! } +//! ``` +//! +//! This macro can be useful to avoid the "compile regex on every loop +//! iteration" problem. +//! +//! ## Runtime `include_bytes!` +//! +//! The `include_bytes` macro is useful to include test resources, but it slows +//! down test compilation a lot. An alternative is to load the resources at +//! runtime: +//! +//! ``` +//! # #[cfg(any(feature = "std", feature = "critical-section"))] { +//! use std::path::Path; +//! +//! use once_cell::sync::OnceCell; +//! +//! pub struct TestResource { +//! path: &'static str, +//! cell: OnceCell>, +//! } +//! +//! impl TestResource { +//! pub const fn new(path: &'static str) -> TestResource { +//! TestResource { path, cell: OnceCell::new() } +//! } +//! pub fn bytes(&self) -> &[u8] { +//! self.cell.get_or_init(|| { +//! let dir = std::env::var("CARGO_MANIFEST_DIR").unwrap(); +//! let path = Path::new(dir.as_str()).join(self.path); +//! std::fs::read(&path).unwrap_or_else(|_err| { +//! panic!("failed to load test resource: {}", path.display()) +//! }) +//! }).as_slice() +//! } +//! } +//! +//! static TEST_IMAGE: TestResource = TestResource::new("test_data/lena.png"); +//! +//! #[test] +//! fn test_sobel_filter() { +//! let rgb: &[u8] = TEST_IMAGE.bytes(); +//! // ... +//! # drop(rgb); +//! } +//! # } +//! ``` +//! +//! ## `lateinit` +//! +//! `LateInit` type for delayed initialization. It is reminiscent of Kotlin's +//! `lateinit` keyword and allows construction of cyclic data structures: +//! +//! +//! ``` +//! # #[cfg(any(feature = "std", feature = "critical-section"))] { +//! use once_cell::sync::OnceCell; +//! +//! pub struct LateInit { cell: OnceCell } +//! +//! impl LateInit { +//! pub fn init(&self, value: T) { +//! assert!(self.cell.set(value).is_ok()) +//! } +//! } +//! +//! impl Default for LateInit { +//! fn default() -> Self { LateInit { cell: OnceCell::default() } } +//! } +//! +//! impl std::ops::Deref for LateInit { +//! type Target = T; +//! fn deref(&self) -> &T { +//! self.cell.get().unwrap() +//! } +//! } +//! +//! #[derive(Default)] +//! struct A<'a> { +//! b: LateInit<&'a B<'a>>, +//! } +//! +//! #[derive(Default)] +//! struct B<'a> { +//! a: LateInit<&'a A<'a>> +//! } +//! +//! +//! fn build_cycle() { +//! let a = A::default(); +//! let b = B::default(); +//! a.b.init(&b); +//! b.a.init(&a); +//! +//! let _a = &a.b.a.b.a; +//! } +//! # } +//! ``` +//! +//! # Comparison with std +//! +//! |`!Sync` types | Access Mode | Drawbacks | +//! |----------------------|------------------------|-----------------------------------------------| +//! |`Cell` | `T` | requires `T: Copy` for `get` | +//! |`RefCell` | `RefMut` / `Ref` | may panic at runtime | +//! |`unsync::OnceCell` | `&T` | assignable only once | +//! +//! |`Sync` types | Access Mode | Drawbacks | +//! |----------------------|------------------------|-----------------------------------------------| +//! |`AtomicT` | `T` | works only with certain `Copy` types | +//! |`Mutex` | `MutexGuard` | may deadlock at runtime, may block the thread | +//! |`sync::OnceCell` | `&T` | assignable only once, may block the thread | +//! +//! Technically, calling `get_or_init` will also cause a panic or a deadlock if +//! it recursively calls itself. However, because the assignment can happen only +//! once, such cases should be more rare than equivalents with `RefCell` and +//! `Mutex`. +//! +//! # Minimum Supported `rustc` Version +//! +//! If only the `std`, `alloc`, or `race` features are enabled, MSRV will be +//! updated conservatively, supporting at least latest 8 versions of the compiler. +//! When using other features, like `parking_lot`, MSRV might be updated more +//! frequently, up to the latest stable. In both cases, increasing MSRV is *not* +//! considered a semver-breaking change and requires only a minor version bump. +//! +//! # Implementation details +//! +//! The implementation is based on the +//! [`lazy_static`](https://github.com/rust-lang-nursery/lazy-static.rs/) and +//! [`lazy_cell`](https://github.com/indiv0/lazycell/) crates and +//! [`std::sync::Once`]. In some sense, `once_cell` just streamlines and unifies +//! those APIs. +//! +//! To implement a sync flavor of `OnceCell`, this crates uses either a custom +//! re-implementation of `std::sync::Once` or `parking_lot::Mutex`. This is +//! controlled by the `parking_lot` feature (disabled by default). Performance +//! is the same for both cases, but the `parking_lot` based `OnceCell` is +//! smaller by up to 16 bytes. +//! +//! This crate uses `unsafe`. +//! +//! [`std::sync::Once`]: https://doc.rust-lang.org/std/sync/struct.Once.html +//! +//! # F.A.Q. +//! +//! **Should I use the sync or unsync flavor?** +//! +//! Because Rust compiler checks thread safety for you, it's impossible to +//! accidentally use `unsync` where `sync` is required. So, use `unsync` in +//! single-threaded code and `sync` in multi-threaded. It's easy to switch +//! between the two if code becomes multi-threaded later. +//! +//! At the moment, `unsync` has an additional benefit that reentrant +//! initialization causes a panic, which might be easier to debug than a +//! deadlock. +//! +//! **Does this crate support async?** +//! +//! No, but you can use +//! [`async_once_cell`](https://crates.io/crates/async_once_cell) instead. +//! +//! **Does this crate support `no_std`?** +//! +//! Yes, but with caveats. `OnceCell` is a synchronization primitive which +//! _semantically_ relies on blocking. `OnceCell` guarantees that at most one +//! `f` will be called to compute the value. If two threads of execution call +//! `get_or_init` concurrently, one of them has to wait. +//! +//! Waiting fundamentally requires OS support. Execution environment needs to +//! understand who waits on whom to prevent deadlocks due to priority inversion. +//! You _could_ make code to compile by blindly using pure spinlocks, but the +//! runtime behavior would be subtly wrong. +//! +//! Given these constraints, `once_cell` provides the following options: +//! +//! - The `race` module provides similar, but distinct synchronization primitive +//! which is compatible with `no_std`. With `race`, the `f` function can be +//! called multiple times by different threads, but only one thread will win +//! to install the value. +//! - `critical-section` feature (with a `-`, not `_`) uses `critical_section` +//! to implement blocking. +//! +//! **Can I bring my own mutex?** +//! +//! There is [generic_once_cell](https://crates.io/crates/generic_once_cell) to +//! allow just that. +//! +//! **Should I use `std::cell::OnceCell`, `once_cell`, or `lazy_static`?** +//! +//! If you can use `std` version (your MSRV is at least 1.70, and you don't need +//! extra features `once_cell` provides), use `std`. Otherwise, use `once_cell`. +//! Don't use `lazy_static`. +//! +//! # Related crates +//! +//! * Most of this crate's functionality is available in `std` starting with +//! Rust 1.70. See `std::cell::OnceCell` and `std::sync::OnceLock`. +//! * [double-checked-cell](https://github.com/niklasf/double-checked-cell) +//! * [lazy-init](https://crates.io/crates/lazy-init) +//! * [lazycell](https://crates.io/crates/lazycell) +//! * [mitochondria](https://crates.io/crates/mitochondria) +//! * [lazy_static](https://crates.io/crates/lazy_static) +//! * [async_once_cell](https://crates.io/crates/async_once_cell) +//! * [generic_once_cell](https://crates.io/crates/generic_once_cell) (bring +//! your own mutex) + +#![cfg_attr(not(feature = "std"), no_std)] + +#[cfg(feature = "alloc")] +extern crate alloc; + +#[cfg(all(feature = "critical-section", not(feature = "std")))] +#[path = "imp_cs.rs"] +mod imp; + +#[cfg(all(feature = "std", feature = "parking_lot"))] +#[path = "imp_pl.rs"] +mod imp; + +#[cfg(all(feature = "std", not(feature = "parking_lot")))] +#[path = "imp_std.rs"] +mod imp; + +/// Single-threaded version of `OnceCell`. +pub mod unsync { + use core::{ + cell::{Cell, UnsafeCell}, + fmt, mem, + ops::{Deref, DerefMut}, + panic::{RefUnwindSafe, UnwindSafe}, + }; + + /// A cell which can be written to only once. It is not thread safe. + /// + /// Unlike [`std::cell::RefCell`], a `OnceCell` provides simple `&` + /// references to the contents. + /// + /// [`std::cell::RefCell`]: https://doc.rust-lang.org/std/cell/struct.RefCell.html + /// + /// # Example + /// ``` + /// use once_cell::unsync::OnceCell; + /// + /// let cell = OnceCell::new(); + /// assert!(cell.get().is_none()); + /// + /// let value: &String = cell.get_or_init(|| { + /// "Hello, World!".to_string() + /// }); + /// assert_eq!(value, "Hello, World!"); + /// assert!(cell.get().is_some()); + /// ``` + pub struct OnceCell { + // Invariant: written to at most once. + inner: UnsafeCell>, + } + + // Similarly to a `Sync` bound on `sync::OnceCell`, we can use + // `&unsync::OnceCell` to sneak a `T` through `catch_unwind`, + // by initializing the cell in closure and extracting the value in the + // `Drop`. + impl RefUnwindSafe for OnceCell {} + impl UnwindSafe for OnceCell {} + + impl Default for OnceCell { + fn default() -> Self { + Self::new() + } + } + + impl fmt::Debug for OnceCell { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self.get() { + Some(v) => f.debug_tuple("OnceCell").field(v).finish(), + None => f.write_str("OnceCell(Uninit)"), + } + } + } + + impl Clone for OnceCell { + fn clone(&self) -> OnceCell { + match self.get() { + Some(value) => OnceCell::with_value(value.clone()), + None => OnceCell::new(), + } + } + + fn clone_from(&mut self, source: &Self) { + match (self.get_mut(), source.get()) { + (Some(this), Some(source)) => this.clone_from(source), + _ => *self = source.clone(), + } + } + } + + impl PartialEq for OnceCell { + fn eq(&self, other: &Self) -> bool { + self.get() == other.get() + } + } + + impl Eq for OnceCell {} + + impl From for OnceCell { + fn from(value: T) -> Self { + OnceCell::with_value(value) + } + } + + impl OnceCell { + /// Creates a new empty cell. + pub const fn new() -> OnceCell { + OnceCell { inner: UnsafeCell::new(None) } + } + + /// Creates a new initialized cell. + pub const fn with_value(value: T) -> OnceCell { + OnceCell { inner: UnsafeCell::new(Some(value)) } + } + + /// Gets a reference to the underlying value. + /// + /// Returns `None` if the cell is empty. + #[inline] + pub fn get(&self) -> Option<&T> { + // Safe due to `inner`'s invariant of being written to at most once. + // Had multiple writes to `inner` been allowed, a reference to the + // value we return now would become dangling by a write of a + // different value later. + unsafe { &*self.inner.get() }.as_ref() + } + + /// Gets a mutable reference to the underlying value. + /// + /// Returns `None` if the cell is empty. + /// + /// This method is allowed to violate the invariant of writing to a `OnceCell` + /// at most once because it requires `&mut` access to `self`. As with all + /// interior mutability, `&mut` access permits arbitrary modification: + /// + /// ``` + /// use once_cell::unsync::OnceCell; + /// + /// let mut cell: OnceCell = OnceCell::new(); + /// cell.set(92).unwrap(); + /// *cell.get_mut().unwrap() = 93; + /// assert_eq!(cell.get(), Some(&93)); + /// ``` + #[inline] + pub fn get_mut(&mut self) -> Option<&mut T> { + // Safe because we have unique access + unsafe { &mut *self.inner.get() }.as_mut() + } + + /// Sets the contents of this cell to `value`. + /// + /// Returns `Ok(())` if the cell was empty and `Err(value)` if it was + /// full. + /// + /// # Example + /// ``` + /// use once_cell::unsync::OnceCell; + /// + /// let cell = OnceCell::new(); + /// assert!(cell.get().is_none()); + /// + /// assert_eq!(cell.set(92), Ok(())); + /// assert_eq!(cell.set(62), Err(62)); + /// + /// assert!(cell.get().is_some()); + /// ``` + pub fn set(&self, value: T) -> Result<(), T> { + match self.try_insert(value) { + Ok(_) => Ok(()), + Err((_, value)) => Err(value), + } + } + + /// Like [`set`](Self::set), but also returns a reference to the final cell value. + /// + /// # Example + /// ``` + /// use once_cell::unsync::OnceCell; + /// + /// let cell = OnceCell::new(); + /// assert!(cell.get().is_none()); + /// + /// assert_eq!(cell.try_insert(92), Ok(&92)); + /// assert_eq!(cell.try_insert(62), Err((&92, 62))); + /// + /// assert!(cell.get().is_some()); + /// ``` + pub fn try_insert(&self, value: T) -> Result<&T, (&T, T)> { + if let Some(old) = self.get() { + return Err((old, value)); + } + + let slot = unsafe { &mut *self.inner.get() }; + // This is the only place where we set the slot, no races + // due to reentrancy/concurrency are possible, and we've + // checked that slot is currently `None`, so this write + // maintains the `inner`'s invariant. + *slot = Some(value); + Ok(unsafe { slot.as_ref().unwrap_unchecked() }) + } + + /// Gets the contents of the cell, initializing it with `f` + /// if the cell was empty. + /// + /// # Panics + /// + /// If `f` panics, the panic is propagated to the caller, and the cell + /// remains uninitialized. + /// + /// It is an error to reentrantly initialize the cell from `f`. Doing + /// so results in a panic. + /// + /// # Example + /// ``` + /// use once_cell::unsync::OnceCell; + /// + /// let cell = OnceCell::new(); + /// let value = cell.get_or_init(|| 92); + /// assert_eq!(value, &92); + /// let value = cell.get_or_init(|| unreachable!()); + /// assert_eq!(value, &92); + /// ``` + pub fn get_or_init(&self, f: F) -> &T + where + F: FnOnce() -> T, + { + enum Void {} + match self.get_or_try_init(|| Ok::(f())) { + Ok(val) => val, + Err(void) => match void {}, + } + } + + /// Gets the contents of the cell, initializing it with `f` if + /// the cell was empty. If the cell was empty and `f` failed, an + /// error is returned. + /// + /// # Panics + /// + /// If `f` panics, the panic is propagated to the caller, and the cell + /// remains uninitialized. + /// + /// It is an error to reentrantly initialize the cell from `f`. Doing + /// so results in a panic. + /// + /// # Example + /// ``` + /// use once_cell::unsync::OnceCell; + /// + /// let cell = OnceCell::new(); + /// assert_eq!(cell.get_or_try_init(|| Err(())), Err(())); + /// assert!(cell.get().is_none()); + /// let value = cell.get_or_try_init(|| -> Result { + /// Ok(92) + /// }); + /// assert_eq!(value, Ok(&92)); + /// assert_eq!(cell.get(), Some(&92)) + /// ``` + pub fn get_or_try_init(&self, f: F) -> Result<&T, E> + where + F: FnOnce() -> Result, + { + if let Some(val) = self.get() { + return Ok(val); + } + let val = f()?; + // Note that *some* forms of reentrant initialization might lead to + // UB (see `reentrant_init` test). I believe that just removing this + // `assert`, while keeping `set/get` would be sound, but it seems + // better to panic, rather than to silently use an old value. + assert!(self.set(val).is_ok(), "reentrant init"); + Ok(unsafe { self.get().unwrap_unchecked() }) + } + + /// Takes the value out of this `OnceCell`, moving it back to an uninitialized state. + /// + /// Has no effect and returns `None` if the `OnceCell` hasn't been initialized. + /// + /// # Examples + /// + /// ``` + /// use once_cell::unsync::OnceCell; + /// + /// let mut cell: OnceCell = OnceCell::new(); + /// assert_eq!(cell.take(), None); + /// + /// let mut cell = OnceCell::new(); + /// cell.set("hello".to_string()).unwrap(); + /// assert_eq!(cell.take(), Some("hello".to_string())); + /// assert_eq!(cell.get(), None); + /// ``` + /// + /// This method is allowed to violate the invariant of writing to a `OnceCell` + /// at most once because it requires `&mut` access to `self`. As with all + /// interior mutability, `&mut` access permits arbitrary modification: + /// + /// ``` + /// use once_cell::unsync::OnceCell; + /// + /// let mut cell: OnceCell = OnceCell::new(); + /// cell.set(92).unwrap(); + /// cell = OnceCell::new(); + /// ``` + pub fn take(&mut self) -> Option { + mem::take(self).into_inner() + } + + /// Consumes the `OnceCell`, returning the wrapped value. + /// + /// Returns `None` if the cell was empty. + /// + /// # Examples + /// + /// ``` + /// use once_cell::unsync::OnceCell; + /// + /// let cell: OnceCell = OnceCell::new(); + /// assert_eq!(cell.into_inner(), None); + /// + /// let cell = OnceCell::new(); + /// cell.set("hello".to_string()).unwrap(); + /// assert_eq!(cell.into_inner(), Some("hello".to_string())); + /// ``` + pub fn into_inner(self) -> Option { + // Because `into_inner` takes `self` by value, the compiler statically verifies + // that it is not currently borrowed. So it is safe to move out `Option`. + self.inner.into_inner() + } + } + + /// A value which is initialized on the first access. + /// + /// # Example + /// ``` + /// use once_cell::unsync::Lazy; + /// + /// let lazy: Lazy = Lazy::new(|| { + /// println!("initializing"); + /// 92 + /// }); + /// println!("ready"); + /// println!("{}", *lazy); + /// println!("{}", *lazy); + /// + /// // Prints: + /// // ready + /// // initializing + /// // 92 + /// // 92 + /// ``` + pub struct Lazy T> { + cell: OnceCell, + init: Cell>, + } + + impl RefUnwindSafe for Lazy where OnceCell: RefUnwindSafe {} + + impl fmt::Debug for Lazy { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Lazy").field("cell", &self.cell).field("init", &"..").finish() + } + } + + impl Lazy { + /// Creates a new lazy value with the given initializing function. + /// + /// # Example + /// ``` + /// # fn main() { + /// use once_cell::unsync::Lazy; + /// + /// let hello = "Hello, World!".to_string(); + /// + /// let lazy = Lazy::new(|| hello.to_uppercase()); + /// + /// assert_eq!(&*lazy, "HELLO, WORLD!"); + /// # } + /// ``` + pub const fn new(init: F) -> Lazy { + Lazy { cell: OnceCell::new(), init: Cell::new(Some(init)) } + } + + /// Consumes this `Lazy` returning the stored value. + /// + /// Returns `Ok(value)` if `Lazy` is initialized and `Err(f)` otherwise. + pub fn into_value(this: Lazy) -> Result { + let cell = this.cell; + let init = this.init; + cell.into_inner().ok_or_else(|| { + init.take().unwrap_or_else(|| panic!("Lazy instance has previously been poisoned")) + }) + } + } + + impl T> Lazy { + /// Forces the evaluation of this lazy value and returns a reference to + /// the result. + /// + /// This is equivalent to the `Deref` impl, but is explicit. + /// + /// # Example + /// ``` + /// use once_cell::unsync::Lazy; + /// + /// let lazy = Lazy::new(|| 92); + /// + /// assert_eq!(Lazy::force(&lazy), &92); + /// assert_eq!(&*lazy, &92); + /// ``` + pub fn force(this: &Lazy) -> &T { + this.cell.get_or_init(|| match this.init.take() { + Some(f) => f(), + None => panic!("Lazy instance has previously been poisoned"), + }) + } + + /// Forces the evaluation of this lazy value and returns a mutable reference to + /// the result. + /// + /// This is equivalent to the `DerefMut` impl, but is explicit. + /// + /// # Example + /// ``` + /// use once_cell::unsync::Lazy; + /// + /// let mut lazy = Lazy::new(|| 92); + /// + /// assert_eq!(Lazy::force_mut(&mut lazy), &92); + /// assert_eq!(*lazy, 92); + /// ``` + pub fn force_mut(this: &mut Lazy) -> &mut T { + if this.cell.get_mut().is_none() { + let value = match this.init.get_mut().take() { + Some(f) => f(), + None => panic!("Lazy instance has previously been poisoned"), + }; + this.cell = OnceCell::with_value(value); + } + this.cell.get_mut().unwrap_or_else(|| unreachable!()) + } + + /// Gets the reference to the result of this lazy value if + /// it was initialized, otherwise returns `None`. + /// + /// # Example + /// ``` + /// use once_cell::unsync::Lazy; + /// + /// let lazy = Lazy::new(|| 92); + /// + /// assert_eq!(Lazy::get(&lazy), None); + /// assert_eq!(&*lazy, &92); + /// assert_eq!(Lazy::get(&lazy), Some(&92)); + /// ``` + pub fn get(this: &Lazy) -> Option<&T> { + this.cell.get() + } + + /// Gets the mutable reference to the result of this lazy value if + /// it was initialized, otherwise returns `None`. + /// + /// # Example + /// ``` + /// use once_cell::unsync::Lazy; + /// + /// let mut lazy = Lazy::new(|| 92); + /// + /// assert_eq!(Lazy::get_mut(&mut lazy), None); + /// assert_eq!(*lazy, 92); + /// assert_eq!(Lazy::get_mut(&mut lazy), Some(&mut 92)); + /// ``` + pub fn get_mut(this: &mut Lazy) -> Option<&mut T> { + this.cell.get_mut() + } + } + + impl T> Deref for Lazy { + type Target = T; + fn deref(&self) -> &T { + Lazy::force(self) + } + } + + impl T> DerefMut for Lazy { + fn deref_mut(&mut self) -> &mut T { + Lazy::force_mut(self) + } + } + + impl Default for Lazy { + /// Creates a new lazy value using `Default` as the initializing function. + fn default() -> Lazy { + Lazy::new(T::default) + } + } +} + +/// Thread-safe, blocking version of `OnceCell`. +#[cfg(any(feature = "std", feature = "critical-section"))] +pub mod sync { + use core::{ + cell::Cell, + fmt, mem, + ops::{Deref, DerefMut}, + panic::RefUnwindSafe, + }; + + use super::imp::OnceCell as Imp; + + /// A thread-safe cell which can be written to only once. + /// + /// `OnceCell` provides `&` references to the contents without RAII guards. + /// + /// Reading a non-`None` value out of `OnceCell` establishes a + /// happens-before relationship with a corresponding write. For example, if + /// thread A initializes the cell with `get_or_init(f)`, and thread B + /// subsequently reads the result of this call, B also observes all the side + /// effects of `f`. + /// + /// # Example + /// ``` + /// use once_cell::sync::OnceCell; + /// + /// static CELL: OnceCell = OnceCell::new(); + /// assert!(CELL.get().is_none()); + /// + /// std::thread::spawn(|| { + /// let value: &String = CELL.get_or_init(|| { + /// "Hello, World!".to_string() + /// }); + /// assert_eq!(value, "Hello, World!"); + /// }).join().unwrap(); + /// + /// let value: Option<&String> = CELL.get(); + /// assert!(value.is_some()); + /// assert_eq!(value.unwrap().as_str(), "Hello, World!"); + /// ``` + pub struct OnceCell(Imp); + + impl Default for OnceCell { + fn default() -> OnceCell { + OnceCell::new() + } + } + + impl fmt::Debug for OnceCell { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self.get() { + Some(v) => f.debug_tuple("OnceCell").field(v).finish(), + None => f.write_str("OnceCell(Uninit)"), + } + } + } + + impl Clone for OnceCell { + fn clone(&self) -> OnceCell { + match self.get() { + Some(value) => Self::with_value(value.clone()), + None => Self::new(), + } + } + + fn clone_from(&mut self, source: &Self) { + match (self.get_mut(), source.get()) { + (Some(this), Some(source)) => this.clone_from(source), + _ => *self = source.clone(), + } + } + } + + impl From for OnceCell { + fn from(value: T) -> Self { + Self::with_value(value) + } + } + + impl PartialEq for OnceCell { + fn eq(&self, other: &OnceCell) -> bool { + self.get() == other.get() + } + } + + impl Eq for OnceCell {} + + impl OnceCell { + /// Creates a new empty cell. + pub const fn new() -> OnceCell { + OnceCell(Imp::new()) + } + + /// Creates a new initialized cell. + pub const fn with_value(value: T) -> OnceCell { + OnceCell(Imp::with_value(value)) + } + + /// Gets the reference to the underlying value. + /// + /// Returns `None` if the cell is empty, or being initialized. This + /// method never blocks. + pub fn get(&self) -> Option<&T> { + if self.0.is_initialized() { + // Safe b/c value is initialized. + Some(unsafe { self.get_unchecked() }) + } else { + None + } + } + + /// Gets the reference to the underlying value, blocking the current + /// thread until it is set. + /// + /// ``` + /// use once_cell::sync::OnceCell; + /// + /// let mut cell = std::sync::Arc::new(OnceCell::new()); + /// let t = std::thread::spawn({ + /// let cell = std::sync::Arc::clone(&cell); + /// move || cell.set(92).unwrap() + /// }); + /// + /// // Returns immediately, but might return None. + /// let _value_or_none = cell.get(); + /// + /// // Will return 92, but might block until the other thread does `.set`. + /// let value: &u32 = cell.wait(); + /// assert_eq!(*value, 92); + /// t.join().unwrap(); + /// ``` + #[cfg(feature = "std")] + pub fn wait(&self) -> &T { + if !self.0.is_initialized() { + self.0.wait() + } + debug_assert!(self.0.is_initialized()); + // Safe b/c of the wait call above and the fact that we didn't + // relinquish our borrow. + unsafe { self.get_unchecked() } + } + + /// Gets the mutable reference to the underlying value. + /// + /// Returns `None` if the cell is empty. + /// + /// This method is allowed to violate the invariant of writing to a `OnceCell` + /// at most once because it requires `&mut` access to `self`. As with all + /// interior mutability, `&mut` access permits arbitrary modification: + /// + /// ``` + /// use once_cell::sync::OnceCell; + /// + /// let mut cell: OnceCell = OnceCell::new(); + /// cell.set(92).unwrap(); + /// cell = OnceCell::new(); + /// ``` + #[inline] + pub fn get_mut(&mut self) -> Option<&mut T> { + self.0.get_mut() + } + + /// Get the reference to the underlying value, without checking if the + /// cell is initialized. + /// + /// # Safety + /// + /// Caller must ensure that the cell is in initialized state, and that + /// the contents are acquired by (synchronized to) this thread. + #[inline] + pub unsafe fn get_unchecked(&self) -> &T { + self.0.get_unchecked() + } + + /// Sets the contents of this cell to `value`. + /// + /// Returns `Ok(())` if the cell was empty and `Err(value)` if it was + /// full. + /// + /// # Example + /// + /// ``` + /// use once_cell::sync::OnceCell; + /// + /// static CELL: OnceCell = OnceCell::new(); + /// + /// fn main() { + /// assert!(CELL.get().is_none()); + /// + /// std::thread::spawn(|| { + /// assert_eq!(CELL.set(92), Ok(())); + /// }).join().unwrap(); + /// + /// assert_eq!(CELL.set(62), Err(62)); + /// assert_eq!(CELL.get(), Some(&92)); + /// } + /// ``` + pub fn set(&self, value: T) -> Result<(), T> { + match self.try_insert(value) { + Ok(_) => Ok(()), + Err((_, value)) => Err(value), + } + } + + /// Like [`set`](Self::set), but also returns a reference to the final cell value. + /// + /// # Example + /// + /// ``` + /// use once_cell::sync::OnceCell; + /// + /// let cell = OnceCell::new(); + /// assert!(cell.get().is_none()); + /// + /// assert_eq!(cell.try_insert(92), Ok(&92)); + /// assert_eq!(cell.try_insert(62), Err((&92, 62))); + /// + /// assert!(cell.get().is_some()); + /// ``` + pub fn try_insert(&self, value: T) -> Result<&T, (&T, T)> { + let mut value = Some(value); + let res = self.get_or_init(|| unsafe { value.take().unwrap_unchecked() }); + match value { + None => Ok(res), + Some(value) => Err((res, value)), + } + } + + /// Gets the contents of the cell, initializing it with `f` if the cell + /// was empty. + /// + /// Many threads may call `get_or_init` concurrently with different + /// initializing functions, but it is guaranteed that only one function + /// will be executed. + /// + /// # Panics + /// + /// If `f` panics, the panic is propagated to the caller, and the cell + /// remains uninitialized. + /// + /// It is an error to reentrantly initialize the cell from `f`. The + /// exact outcome is unspecified. Current implementation deadlocks, but + /// this may be changed to a panic in the future. + /// + /// # Example + /// ``` + /// use once_cell::sync::OnceCell; + /// + /// let cell = OnceCell::new(); + /// let value = cell.get_or_init(|| 92); + /// assert_eq!(value, &92); + /// let value = cell.get_or_init(|| unreachable!()); + /// assert_eq!(value, &92); + /// ``` + pub fn get_or_init(&self, f: F) -> &T + where + F: FnOnce() -> T, + { + enum Void {} + match self.get_or_try_init(|| Ok::(f())) { + Ok(val) => val, + Err(void) => match void {}, + } + } + + /// Gets the contents of the cell, initializing it with `f` if + /// the cell was empty. If the cell was empty and `f` failed, an + /// error is returned. + /// + /// # Panics + /// + /// If `f` panics, the panic is propagated to the caller, and + /// the cell remains uninitialized. + /// + /// It is an error to reentrantly initialize the cell from `f`. + /// The exact outcome is unspecified. Current implementation + /// deadlocks, but this may be changed to a panic in the future. + /// + /// # Example + /// ``` + /// use once_cell::sync::OnceCell; + /// + /// let cell = OnceCell::new(); + /// assert_eq!(cell.get_or_try_init(|| Err(())), Err(())); + /// assert!(cell.get().is_none()); + /// let value = cell.get_or_try_init(|| -> Result { + /// Ok(92) + /// }); + /// assert_eq!(value, Ok(&92)); + /// assert_eq!(cell.get(), Some(&92)) + /// ``` + pub fn get_or_try_init(&self, f: F) -> Result<&T, E> + where + F: FnOnce() -> Result, + { + // Fast path check + if let Some(value) = self.get() { + return Ok(value); + } + + self.0.initialize(f)?; + + // Safe b/c value is initialized. + debug_assert!(self.0.is_initialized()); + Ok(unsafe { self.get_unchecked() }) + } + + /// Takes the value out of this `OnceCell`, moving it back to an uninitialized state. + /// + /// Has no effect and returns `None` if the `OnceCell` hasn't been initialized. + /// + /// # Examples + /// + /// ``` + /// use once_cell::sync::OnceCell; + /// + /// let mut cell: OnceCell = OnceCell::new(); + /// assert_eq!(cell.take(), None); + /// + /// let mut cell = OnceCell::new(); + /// cell.set("hello".to_string()).unwrap(); + /// assert_eq!(cell.take(), Some("hello".to_string())); + /// assert_eq!(cell.get(), None); + /// ``` + /// + /// This method is allowed to violate the invariant of writing to a `OnceCell` + /// at most once because it requires `&mut` access to `self`. As with all + /// interior mutability, `&mut` access permits arbitrary modification: + /// + /// ``` + /// use once_cell::sync::OnceCell; + /// + /// let mut cell: OnceCell = OnceCell::new(); + /// cell.set(92).unwrap(); + /// cell = OnceCell::new(); + /// ``` + pub fn take(&mut self) -> Option { + mem::take(self).into_inner() + } + + /// Consumes the `OnceCell`, returning the wrapped value. Returns + /// `None` if the cell was empty. + /// + /// # Examples + /// + /// ``` + /// use once_cell::sync::OnceCell; + /// + /// let cell: OnceCell = OnceCell::new(); + /// assert_eq!(cell.into_inner(), None); + /// + /// let cell = OnceCell::new(); + /// cell.set("hello".to_string()).unwrap(); + /// assert_eq!(cell.into_inner(), Some("hello".to_string())); + /// ``` + #[inline] + pub fn into_inner(self) -> Option { + self.0.into_inner() + } + } + + /// A value which is initialized on the first access. + /// + /// This type is thread-safe and can be used in statics. + /// + /// # Example + /// + /// ``` + /// use std::collections::HashMap; + /// + /// use once_cell::sync::Lazy; + /// + /// static HASHMAP: Lazy> = Lazy::new(|| { + /// println!("initializing"); + /// let mut m = HashMap::new(); + /// m.insert(13, "Spica".to_string()); + /// m.insert(74, "Hoyten".to_string()); + /// m + /// }); + /// + /// fn main() { + /// println!("ready"); + /// std::thread::spawn(|| { + /// println!("{:?}", HASHMAP.get(&13)); + /// }).join().unwrap(); + /// println!("{:?}", HASHMAP.get(&74)); + /// + /// // Prints: + /// // ready + /// // initializing + /// // Some("Spica") + /// // Some("Hoyten") + /// } + /// ``` + pub struct Lazy T> { + cell: OnceCell, + init: Cell>, + } + + impl fmt::Debug for Lazy { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.debug_struct("Lazy").field("cell", &self.cell).field("init", &"..").finish() + } + } + + // We never create a `&F` from a `&Lazy` so it is fine to not impl + // `Sync` for `F`. We do create a `&mut Option` in `force`, but this is + // properly synchronized, so it only happens once so it also does not + // contribute to this impl. + unsafe impl Sync for Lazy where OnceCell: Sync {} + // auto-derived `Send` impl is OK. + + impl RefUnwindSafe for Lazy where OnceCell: RefUnwindSafe {} + + impl Lazy { + /// Creates a new lazy value with the given initializing + /// function. + pub const fn new(f: F) -> Lazy { + Lazy { cell: OnceCell::new(), init: Cell::new(Some(f)) } + } + + /// Consumes this `Lazy` returning the stored value. + /// + /// Returns `Ok(value)` if `Lazy` is initialized and `Err(f)` otherwise. + pub fn into_value(this: Lazy) -> Result { + let cell = this.cell; + let init = this.init; + cell.into_inner().ok_or_else(|| { + init.take().unwrap_or_else(|| panic!("Lazy instance has previously been poisoned")) + }) + } + } + + impl T> Lazy { + /// Forces the evaluation of this lazy value and + /// returns a reference to the result. This is equivalent + /// to the `Deref` impl, but is explicit. + /// + /// # Example + /// ``` + /// use once_cell::sync::Lazy; + /// + /// let lazy = Lazy::new(|| 92); + /// + /// assert_eq!(Lazy::force(&lazy), &92); + /// assert_eq!(&*lazy, &92); + /// ``` + pub fn force(this: &Lazy) -> &T { + this.cell.get_or_init(|| match this.init.take() { + Some(f) => f(), + None => panic!("Lazy instance has previously been poisoned"), + }) + } + + /// Forces the evaluation of this lazy value and + /// returns a mutable reference to the result. This is equivalent + /// to the `Deref` impl, but is explicit. + /// + /// # Example + /// ``` + /// use once_cell::sync::Lazy; + /// + /// let mut lazy = Lazy::new(|| 92); + /// + /// assert_eq!(Lazy::force_mut(&mut lazy), &mut 92); + /// ``` + pub fn force_mut(this: &mut Lazy) -> &mut T { + if this.cell.get_mut().is_none() { + let value = match this.init.get_mut().take() { + Some(f) => f(), + None => panic!("Lazy instance has previously been poisoned"), + }; + this.cell = OnceCell::with_value(value); + } + this.cell.get_mut().unwrap_or_else(|| unreachable!()) + } + + /// Gets the reference to the result of this lazy value if + /// it was initialized, otherwise returns `None`. + /// + /// # Example + /// ``` + /// use once_cell::sync::Lazy; + /// + /// let lazy = Lazy::new(|| 92); + /// + /// assert_eq!(Lazy::get(&lazy), None); + /// assert_eq!(&*lazy, &92); + /// assert_eq!(Lazy::get(&lazy), Some(&92)); + /// ``` + pub fn get(this: &Lazy) -> Option<&T> { + this.cell.get() + } + + /// Gets the reference to the result of this lazy value if + /// it was initialized, otherwise returns `None`. + /// + /// # Example + /// ``` + /// use once_cell::sync::Lazy; + /// + /// let mut lazy = Lazy::new(|| 92); + /// + /// assert_eq!(Lazy::get_mut(&mut lazy), None); + /// assert_eq!(&*lazy, &92); + /// assert_eq!(Lazy::get_mut(&mut lazy), Some(&mut 92)); + /// ``` + pub fn get_mut(this: &mut Lazy) -> Option<&mut T> { + this.cell.get_mut() + } + } + + impl T> Deref for Lazy { + type Target = T; + fn deref(&self) -> &T { + Lazy::force(self) + } + } + + impl T> DerefMut for Lazy { + fn deref_mut(&mut self) -> &mut T { + Lazy::force_mut(self) + } + } + + impl Default for Lazy { + /// Creates a new lazy value using `Default` as the initializing function. + fn default() -> Lazy { + Lazy::new(T::default) + } + } + + /// ```compile_fail + /// struct S(*mut ()); + /// unsafe impl Sync for S {} + /// + /// fn share(_: &T) {} + /// share(&once_cell::sync::OnceCell::::new()); + /// ``` + /// + /// ```compile_fail + /// struct S(*mut ()); + /// unsafe impl Sync for S {} + /// + /// fn share(_: &T) {} + /// share(&once_cell::sync::Lazy::::new(|| unimplemented!())); + /// ``` + fn _dummy() {} +} + +#[cfg(feature = "race")] +pub mod race; diff --git a/http/vendor/once_cell/src/race.rs b/http/vendor/once_cell/src/race.rs new file mode 100644 index 0000000..852a804 --- /dev/null +++ b/http/vendor/once_cell/src/race.rs @@ -0,0 +1,498 @@ +//! Thread-safe, non-blocking, "first one wins" flavor of `OnceCell`. +//! +//! If two threads race to initialize a type from the `race` module, they +//! don't block, execute initialization function together, but only one of +//! them stores the result. +//! +//! This module does not require `std` feature. +//! +//! # Atomic orderings +//! +//! All types in this module use `Acquire` and `Release` +//! [atomic orderings](Ordering) for all their operations. While this is not +//! strictly necessary for types other than `OnceBox`, it is useful for users as +//! it allows them to be certain that after `get` or `get_or_init` returns on +//! one thread, any side-effects caused by the setter thread prior to them +//! calling `set` or `get_or_init` will be made visible to that thread; without +//! it, it's possible for it to appear as if they haven't happened yet from the +//! getter thread's perspective. This is an acceptable tradeoff to make since +//! `Acquire` and `Release` have very little performance overhead on most +//! architectures versus `Relaxed`. + +// The "atomic orderings" section of the documentation above promises +// "happens-before" semantics. This drives the choice of orderings in the uses +// of `compare_exchange` below. On success, the value was zero/null, so there +// was nothing to acquire (there is never any `Ordering::Release` store of 0). +// On failure, the value was nonzero, so it was initialized previously (perhaps +// on another thread) using `Ordering::Release`, so we must use +// `Ordering::Acquire` to ensure that store "happens-before" this load. + +#[cfg(not(feature = "portable-atomic"))] +use core::sync::atomic; +#[cfg(feature = "portable-atomic")] +use portable_atomic as atomic; + +use atomic::{AtomicPtr, AtomicUsize, Ordering}; +use core::cell::UnsafeCell; +use core::marker::PhantomData; +use core::num::NonZeroUsize; +use core::ptr; + +/// A thread-safe cell which can be written to only once. +#[derive(Default, Debug)] +pub struct OnceNonZeroUsize { + inner: AtomicUsize, +} + +impl OnceNonZeroUsize { + /// Creates a new empty cell. + #[inline] + pub const fn new() -> Self { + Self { inner: AtomicUsize::new(0) } + } + + /// Gets the underlying value. + #[inline] + pub fn get(&self) -> Option { + let val = self.inner.load(Ordering::Acquire); + NonZeroUsize::new(val) + } + + /// Get the reference to the underlying value, without checking if the cell + /// is initialized. + /// + /// # Safety + /// + /// Caller must ensure that the cell is in initialized state, and that + /// the contents are acquired by (synchronized to) this thread. + pub unsafe fn get_unchecked(&self) -> NonZeroUsize { + #[inline(always)] + fn as_const_ptr(r: &AtomicUsize) -> *const usize { + use core::mem::align_of; + + let p: *const AtomicUsize = r; + // SAFETY: "This type has the same size and bit validity as + // the underlying integer type, usize. However, the alignment of + // this type is always equal to its size, even on targets where + // usize has a lesser alignment." + const _ALIGNMENT_COMPATIBLE: () = + assert!(align_of::() % align_of::() == 0); + p.cast::() + } + + // TODO(MSRV-1.70): Use `AtomicUsize::as_ptr().cast_const()` + // See https://github.com/rust-lang/rust/issues/138246. + let p = as_const_ptr(&self.inner); + + // SAFETY: The caller is responsible for ensuring that the value + // was initialized and that the contents have been acquired by + // this thread. Assuming that, we can assume there will be no + // conflicting writes to the value since the value will never + // change once initialized. This relies on the statement in + // https://doc.rust-lang.org/1.83.0/core/sync/atomic/ that "(A + // `compare_exchange` or `compare_exchange_weak` that does not + // succeed is not considered a write." + let val = unsafe { p.read() }; + + // SAFETY: The caller is responsible for ensuring the value is + // initialized and thus not zero. + unsafe { NonZeroUsize::new_unchecked(val) } + } + + /// Sets the contents of this cell to `value`. + /// + /// Returns `Ok(())` if the cell was empty and `Err(())` if it was + /// full. + #[inline] + pub fn set(&self, value: NonZeroUsize) -> Result<(), ()> { + match self.compare_exchange(value) { + Ok(_) => Ok(()), + Err(_) => Err(()), + } + } + + /// Gets the contents of the cell, initializing it with `f` if the cell was + /// empty. + /// + /// If several threads concurrently run `get_or_init`, more than one `f` can + /// be called. However, all threads will return the same value, produced by + /// some `f`. + pub fn get_or_init(&self, f: F) -> NonZeroUsize + where + F: FnOnce() -> NonZeroUsize, + { + enum Void {} + match self.get_or_try_init(|| Ok::(f())) { + Ok(val) => val, + Err(void) => match void {}, + } + } + + /// Gets the contents of the cell, initializing it with `f` if + /// the cell was empty. If the cell was empty and `f` failed, an + /// error is returned. + /// + /// If several threads concurrently run `get_or_init`, more than one `f` can + /// be called. However, all threads will return the same value, produced by + /// some `f`. + pub fn get_or_try_init(&self, f: F) -> Result + where + F: FnOnce() -> Result, + { + match self.get() { + Some(it) => Ok(it), + None => self.init(f), + } + } + + #[cold] + #[inline(never)] + fn init(&self, f: impl FnOnce() -> Result) -> Result { + let nz = f()?; + let mut val = nz.get(); + if let Err(old) = self.compare_exchange(nz) { + val = old; + } + Ok(unsafe { NonZeroUsize::new_unchecked(val) }) + } + + #[inline(always)] + fn compare_exchange(&self, val: NonZeroUsize) -> Result { + self.inner.compare_exchange(0, val.get(), Ordering::Release, Ordering::Acquire) + } +} + +/// A thread-safe cell which can be written to only once. +#[derive(Default, Debug)] +pub struct OnceBool { + inner: OnceNonZeroUsize, +} + +impl OnceBool { + /// Creates a new empty cell. + #[inline] + pub const fn new() -> Self { + Self { inner: OnceNonZeroUsize::new() } + } + + /// Gets the underlying value. + #[inline] + pub fn get(&self) -> Option { + self.inner.get().map(Self::from_usize) + } + + /// Sets the contents of this cell to `value`. + /// + /// Returns `Ok(())` if the cell was empty and `Err(())` if it was + /// full. + #[inline] + pub fn set(&self, value: bool) -> Result<(), ()> { + self.inner.set(Self::to_usize(value)) + } + + /// Gets the contents of the cell, initializing it with `f` if the cell was + /// empty. + /// + /// If several threads concurrently run `get_or_init`, more than one `f` can + /// be called. However, all threads will return the same value, produced by + /// some `f`. + pub fn get_or_init(&self, f: F) -> bool + where + F: FnOnce() -> bool, + { + Self::from_usize(self.inner.get_or_init(|| Self::to_usize(f()))) + } + + /// Gets the contents of the cell, initializing it with `f` if + /// the cell was empty. If the cell was empty and `f` failed, an + /// error is returned. + /// + /// If several threads concurrently run `get_or_init`, more than one `f` can + /// be called. However, all threads will return the same value, produced by + /// some `f`. + pub fn get_or_try_init(&self, f: F) -> Result + where + F: FnOnce() -> Result, + { + self.inner.get_or_try_init(|| f().map(Self::to_usize)).map(Self::from_usize) + } + + #[inline] + fn from_usize(value: NonZeroUsize) -> bool { + value.get() == 1 + } + + #[inline] + fn to_usize(value: bool) -> NonZeroUsize { + unsafe { NonZeroUsize::new_unchecked(if value { 1 } else { 2 }) } + } +} + +/// A thread-safe cell which can be written to only once. +pub struct OnceRef<'a, T> { + inner: AtomicPtr, + ghost: PhantomData>, +} + +// TODO: Replace UnsafeCell with SyncUnsafeCell once stabilized +unsafe impl<'a, T: Sync> Sync for OnceRef<'a, T> {} + +impl<'a, T> core::fmt::Debug for OnceRef<'a, T> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "OnceRef({:?})", self.inner) + } +} + +impl<'a, T> Default for OnceRef<'a, T> { + fn default() -> Self { + Self::new() + } +} + +impl<'a, T> OnceRef<'a, T> { + /// Creates a new empty cell. + pub const fn new() -> Self { + Self { inner: AtomicPtr::new(ptr::null_mut()), ghost: PhantomData } + } + + /// Gets a reference to the underlying value. + pub fn get(&self) -> Option<&'a T> { + let ptr = self.inner.load(Ordering::Acquire); + unsafe { ptr.as_ref() } + } + + /// Sets the contents of this cell to `value`. + /// + /// Returns `Ok(())` if the cell was empty and `Err(value)` if it was + /// full. + pub fn set(&self, value: &'a T) -> Result<(), ()> { + match self.compare_exchange(value) { + Ok(_) => Ok(()), + Err(_) => Err(()), + } + } + + /// Gets the contents of the cell, initializing it with `f` if the cell was + /// empty. + /// + /// If several threads concurrently run `get_or_init`, more than one `f` can + /// be called. However, all threads will return the same value, produced by + /// some `f`. + pub fn get_or_init(&self, f: F) -> &'a T + where + F: FnOnce() -> &'a T, + { + enum Void {} + match self.get_or_try_init(|| Ok::<&'a T, Void>(f())) { + Ok(val) => val, + Err(void) => match void {}, + } + } + + /// Gets the contents of the cell, initializing it with `f` if + /// the cell was empty. If the cell was empty and `f` failed, an + /// error is returned. + /// + /// If several threads concurrently run `get_or_init`, more than one `f` can + /// be called. However, all threads will return the same value, produced by + /// some `f`. + pub fn get_or_try_init(&self, f: F) -> Result<&'a T, E> + where + F: FnOnce() -> Result<&'a T, E>, + { + match self.get() { + Some(val) => Ok(val), + None => self.init(f), + } + } + + #[cold] + #[inline(never)] + fn init(&self, f: impl FnOnce() -> Result<&'a T, E>) -> Result<&'a T, E> { + let mut value: &'a T = f()?; + if let Err(old) = self.compare_exchange(value) { + value = unsafe { &*old }; + } + Ok(value) + } + + #[inline(always)] + fn compare_exchange(&self, value: &'a T) -> Result<(), *const T> { + self.inner + .compare_exchange( + ptr::null_mut(), + <*const T>::cast_mut(value), + Ordering::Release, + Ordering::Acquire, + ) + .map(|_: *mut T| ()) + .map_err(<*mut T>::cast_const) + } + + /// ```compile_fail + /// use once_cell::race::OnceRef; + /// + /// let mut l = OnceRef::new(); + /// + /// { + /// let y = 2; + /// let mut r = OnceRef::new(); + /// r.set(&y).unwrap(); + /// core::mem::swap(&mut l, &mut r); + /// } + /// + /// // l now contains a dangling reference to y + /// eprintln!("uaf: {}", l.get().unwrap()); + /// ``` + fn _dummy() {} +} + +#[cfg(feature = "alloc")] +pub use self::once_box::OnceBox; + +#[cfg(feature = "alloc")] +mod once_box { + use super::atomic::{AtomicPtr, Ordering}; + use core::{marker::PhantomData, ptr}; + + use alloc::boxed::Box; + + /// A thread-safe cell which can be written to only once. + pub struct OnceBox { + inner: AtomicPtr, + ghost: PhantomData>>, + } + + impl core::fmt::Debug for OnceBox { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "OnceBox({:?})", self.inner.load(Ordering::Relaxed)) + } + } + + impl Default for OnceBox { + fn default() -> Self { + Self::new() + } + } + + impl Drop for OnceBox { + fn drop(&mut self) { + let ptr = *self.inner.get_mut(); + if !ptr.is_null() { + drop(unsafe { Box::from_raw(ptr) }) + } + } + } + + impl OnceBox { + /// Creates a new empty cell. + pub const fn new() -> Self { + Self { inner: AtomicPtr::new(ptr::null_mut()), ghost: PhantomData } + } + + /// Creates a new cell with the given value. + pub fn with_value(value: Box) -> Self { + Self { inner: AtomicPtr::new(Box::into_raw(value)), ghost: PhantomData } + } + + /// Gets a reference to the underlying value. + pub fn get(&self) -> Option<&T> { + let ptr = self.inner.load(Ordering::Acquire); + if ptr.is_null() { + return None; + } + Some(unsafe { &*ptr }) + } + + /// Sets the contents of this cell to `value`. + /// + /// Returns `Ok(())` if the cell was empty and `Err(value)` if it was + /// full. + pub fn set(&self, value: Box) -> Result<(), Box> { + let ptr = Box::into_raw(value); + let exchange = self.inner.compare_exchange( + ptr::null_mut(), + ptr, + Ordering::Release, + Ordering::Acquire, + ); + if exchange.is_err() { + let value = unsafe { Box::from_raw(ptr) }; + return Err(value); + } + Ok(()) + } + + /// Gets the contents of the cell, initializing it with `f` if the cell was + /// empty. + /// + /// If several threads concurrently run `get_or_init`, more than one `f` can + /// be called. However, all threads will return the same value, produced by + /// some `f`. + pub fn get_or_init(&self, f: F) -> &T + where + F: FnOnce() -> Box, + { + enum Void {} + match self.get_or_try_init(|| Ok::, Void>(f())) { + Ok(val) => val, + Err(void) => match void {}, + } + } + + /// Gets the contents of the cell, initializing it with `f` if + /// the cell was empty. If the cell was empty and `f` failed, an + /// error is returned. + /// + /// If several threads concurrently run `get_or_init`, more than one `f` can + /// be called. However, all threads will return the same value, produced by + /// some `f`. + pub fn get_or_try_init(&self, f: F) -> Result<&T, E> + where + F: FnOnce() -> Result, E>, + { + match self.get() { + Some(val) => Ok(val), + None => self.init(f) + } + } + + #[cold] + #[inline(never)] + fn init(&self, f: impl FnOnce() -> Result, E>) -> Result<&T, E> { + let val = f()?; + let mut ptr = Box::into_raw(val); + let exchange = self.inner.compare_exchange( + ptr::null_mut(), + ptr, + Ordering::Release, + Ordering::Acquire, + ); + if let Err(old) = exchange { + drop(unsafe { Box::from_raw(ptr) }); + ptr = old; + } + Ok(unsafe { &*ptr }) + } + } + + unsafe impl Sync for OnceBox {} + + impl Clone for OnceBox { + fn clone(&self) -> Self { + match self.get() { + Some(value) => OnceBox::with_value(Box::new(value.clone())), + None => OnceBox::new(), + } + } + } + + /// ```compile_fail + /// struct S(*mut ()); + /// unsafe impl Sync for S {} + /// + /// fn share(_: &T) {} + /// share(&once_cell::race::OnceBox::::new()); + /// ``` + fn _dummy() {} +} diff --git a/http/vendor/once_cell/tests/it/main.rs b/http/vendor/once_cell/tests/it/main.rs new file mode 100644 index 0000000..b8e56cc --- /dev/null +++ b/http/vendor/once_cell/tests/it/main.rs @@ -0,0 +1,12 @@ +mod unsync_once_cell; +#[cfg(any(feature = "std", feature = "critical-section"))] +mod sync_once_cell; + +mod unsync_lazy; +#[cfg(any(feature = "std", feature = "critical-section"))] +mod sync_lazy; + +#[cfg(feature = "race")] +mod race; +#[cfg(all(feature = "race", feature = "alloc"))] +mod race_once_box; diff --git a/http/vendor/once_cell/tests/it/race.rs b/http/vendor/once_cell/tests/it/race.rs new file mode 100644 index 0000000..8716f70 --- /dev/null +++ b/http/vendor/once_cell/tests/it/race.rs @@ -0,0 +1,191 @@ +#[cfg(feature = "std")] +use std::sync::Barrier; +use std::{ + num::NonZeroUsize, + sync::atomic::{AtomicUsize, Ordering::SeqCst}, + thread::scope, +}; + +use once_cell::race::{OnceBool, OnceNonZeroUsize, OnceRef}; + +#[test] +fn once_non_zero_usize_smoke_test() { + let cnt = AtomicUsize::new(0); + let cell = OnceNonZeroUsize::new(); + let val = NonZeroUsize::new(92).unwrap(); + scope(|s| { + s.spawn(|| { + assert_eq!( + cell.get_or_init(|| { + cnt.fetch_add(1, SeqCst); + val + }), + val + ); + assert_eq!(cnt.load(SeqCst), 1); + + assert_eq!( + cell.get_or_init(|| { + cnt.fetch_add(1, SeqCst); + val + }), + val + ); + assert_eq!(cnt.load(SeqCst), 1); + }); + }); + assert_eq!(cell.get(), Some(val)); + assert_eq!(cnt.load(SeqCst), 1); +} + +#[test] +fn once_non_zero_usize_set() { + let val1 = NonZeroUsize::new(92).unwrap(); + let val2 = NonZeroUsize::new(62).unwrap(); + + let cell = OnceNonZeroUsize::new(); + + assert!(cell.set(val1).is_ok()); + assert_eq!(cell.get(), Some(val1)); + + assert!(cell.set(val2).is_err()); + assert_eq!(cell.get(), Some(val1)); +} + +#[cfg(feature = "std")] +#[test] +fn once_non_zero_usize_first_wins() { + let val1 = NonZeroUsize::new(92).unwrap(); + let val2 = NonZeroUsize::new(62).unwrap(); + + let cell = OnceNonZeroUsize::new(); + + let b1 = Barrier::new(2); + let b2 = Barrier::new(2); + let b3 = Barrier::new(2); + scope(|s| { + s.spawn(|| { + let r1 = cell.get_or_init(|| { + b1.wait(); + b2.wait(); + val1 + }); + assert_eq!(r1, val1); + b3.wait(); + }); + b1.wait(); + s.spawn(|| { + let r2 = cell.get_or_init(|| { + b2.wait(); + b3.wait(); + val2 + }); + assert_eq!(r2, val1); + }); + }); + + assert_eq!(cell.get(), Some(val1)); +} + +#[test] +fn once_bool_smoke_test() { + let cnt = AtomicUsize::new(0); + let cell = OnceBool::new(); + scope(|s| { + s.spawn(|| { + assert_eq!( + cell.get_or_init(|| { + cnt.fetch_add(1, SeqCst); + false + }), + false + ); + assert_eq!(cnt.load(SeqCst), 1); + + assert_eq!( + cell.get_or_init(|| { + cnt.fetch_add(1, SeqCst); + false + }), + false + ); + assert_eq!(cnt.load(SeqCst), 1); + }); + }); + assert_eq!(cell.get(), Some(false)); + assert_eq!(cnt.load(SeqCst), 1); +} + +#[test] +fn once_bool_set() { + let cell = OnceBool::new(); + + assert!(cell.set(false).is_ok()); + assert_eq!(cell.get(), Some(false)); + + assert!(cell.set(true).is_err()); + assert_eq!(cell.get(), Some(false)); +} + +#[test] +fn once_bool_get_or_try_init() { + let cell = OnceBool::new(); + + let result1: Result = cell.get_or_try_init(|| Ok(true)); + let result2: Result = cell.get_or_try_init(|| Ok(false)); + assert_eq!(result1, Ok(true)); + assert_eq!(result2, Ok(true)); + + let cell = OnceBool::new(); + + let result3: Result = cell.get_or_try_init(|| Err(())); + assert_eq!(result3, Err(())); +} + +#[test] +fn once_ref_smoke_test() { + let cnt: AtomicUsize = AtomicUsize::new(0); + let cell: OnceRef<'_, &str> = OnceRef::new(); + scope(|s| { + s.spawn(|| { + assert_eq!( + cell.get_or_init(|| { + cnt.fetch_add(1, SeqCst); + &"false" + }), + &"false" + ); + assert_eq!(cnt.load(SeqCst), 1); + + assert_eq!( + cell.get_or_init(|| { + cnt.fetch_add(1, SeqCst); + &"false" + }), + &"false" + ); + assert_eq!(cnt.load(SeqCst), 1); + }); + }); + assert_eq!(cell.get(), Some(&"false")); + assert_eq!(cnt.load(SeqCst), 1); +} + +#[test] +fn once_ref_set() { + let cell: OnceRef<'_, &str> = OnceRef::new(); + + assert!(cell.set(&"false").is_ok()); + assert_eq!(cell.get(), Some(&"false")); + + assert!(cell.set(&"true").is_err()); + assert_eq!(cell.get(), Some(&"false")); +} + +#[test] +fn get_unchecked() { + let cell = OnceNonZeroUsize::new(); + cell.set(NonZeroUsize::new(92).unwrap()).unwrap(); + let value = unsafe { cell.get_unchecked() }; + assert_eq!(value, NonZeroUsize::new(92).unwrap()); +} diff --git a/http/vendor/once_cell/tests/it/race_once_box.rs b/http/vendor/once_cell/tests/it/race_once_box.rs new file mode 100644 index 0000000..e9ff2c1 --- /dev/null +++ b/http/vendor/once_cell/tests/it/race_once_box.rs @@ -0,0 +1,162 @@ +#[cfg(feature = "std")] +use std::sync::Barrier; +use std::sync::{ + atomic::{AtomicUsize, Ordering::SeqCst}, + Arc, +}; + +use once_cell::race::OnceBox; + +#[derive(Default)] +struct Heap { + total: Arc, +} + +#[derive(Debug)] +struct Pebble { + val: T, + total: Arc, +} + +impl Drop for Pebble { + fn drop(&mut self) { + self.total.fetch_sub(1, SeqCst); + } +} + +impl Heap { + fn total(&self) -> usize { + self.total.load(SeqCst) + } + fn new_pebble(&self, val: T) -> Pebble { + self.total.fetch_add(1, SeqCst); + Pebble { val, total: Arc::clone(&self.total) } + } +} + +#[cfg(feature = "std")] +#[test] +fn once_box_smoke_test() { + use std::thread::scope; + + let heap = Heap::default(); + let global_cnt = AtomicUsize::new(0); + let cell = OnceBox::new(); + let b = Barrier::new(128); + scope(|s| { + for _ in 0..128 { + s.spawn(|| { + let local_cnt = AtomicUsize::new(0); + cell.get_or_init(|| { + global_cnt.fetch_add(1, SeqCst); + local_cnt.fetch_add(1, SeqCst); + b.wait(); + Box::new(heap.new_pebble(())) + }); + assert_eq!(local_cnt.load(SeqCst), 1); + + cell.get_or_init(|| { + global_cnt.fetch_add(1, SeqCst); + local_cnt.fetch_add(1, SeqCst); + Box::new(heap.new_pebble(())) + }); + assert_eq!(local_cnt.load(SeqCst), 1); + }); + } + }); + assert!(cell.get().is_some()); + assert!(global_cnt.load(SeqCst) > 10); + + assert_eq!(heap.total(), 1); + drop(cell); + assert_eq!(heap.total(), 0); +} + +#[test] +fn once_box_set() { + let heap = Heap::default(); + let cell = OnceBox::new(); + assert!(cell.get().is_none()); + + assert!(cell.set(Box::new(heap.new_pebble("hello"))).is_ok()); + assert_eq!(cell.get().unwrap().val, "hello"); + assert_eq!(heap.total(), 1); + + assert!(cell.set(Box::new(heap.new_pebble("world"))).is_err()); + assert_eq!(cell.get().unwrap().val, "hello"); + assert_eq!(heap.total(), 1); + + drop(cell); + assert_eq!(heap.total(), 0); +} + +#[cfg(feature = "std")] +#[test] +fn once_box_first_wins() { + use std::thread::scope; + + let cell = OnceBox::new(); + let val1 = 92; + let val2 = 62; + + let b1 = Barrier::new(2); + let b2 = Barrier::new(2); + let b3 = Barrier::new(2); + scope(|s| { + s.spawn(|| { + let r1 = cell.get_or_init(|| { + b1.wait(); + b2.wait(); + Box::new(val1) + }); + assert_eq!(*r1, val1); + b3.wait(); + }); + b1.wait(); + s.spawn(|| { + let r2 = cell.get_or_init(|| { + b2.wait(); + b3.wait(); + Box::new(val2) + }); + assert_eq!(*r2, val1); + }); + }); + + assert_eq!(cell.get(), Some(&val1)); +} + +#[test] +fn once_box_reentrant() { + let cell = OnceBox::new(); + let res = cell.get_or_init(|| { + cell.get_or_init(|| Box::new("hello".to_string())); + Box::new("world".to_string()) + }); + assert_eq!(res, "hello"); +} + +#[test] +fn once_box_default() { + struct Foo; + + let cell: OnceBox = Default::default(); + assert!(cell.get().is_none()); +} + +#[test] +fn onece_box_with_value() { + let cell = OnceBox::with_value(Box::new(92)); + assert_eq!(cell.get(), Some(&92)); +} + +#[test] +fn onece_box_clone() { + let cell1 = OnceBox::new(); + let cell2 = cell1.clone(); + cell1.set(Box::new(92)).unwrap(); + let cell3 = cell1.clone(); + assert_eq!(cell1.get(), Some(&92)); + assert_eq!(cell2.get(), None); + assert_eq!(cell3.get(), Some(&92)); +} diff --git a/http/vendor/once_cell/tests/it/sync_lazy.rs b/http/vendor/once_cell/tests/it/sync_lazy.rs new file mode 100644 index 0000000..44d70fa --- /dev/null +++ b/http/vendor/once_cell/tests/it/sync_lazy.rs @@ -0,0 +1,176 @@ +use std::{ + cell::Cell, + sync::atomic::{AtomicUsize, Ordering::SeqCst}, + thread::scope, +}; + +use once_cell::sync::{Lazy, OnceCell}; + +#[test] +fn lazy_new() { + let called = AtomicUsize::new(0); + let x = Lazy::new(|| { + called.fetch_add(1, SeqCst); + 92 + }); + + assert_eq!(called.load(SeqCst), 0); + + scope(|s| { + s.spawn(|| { + let y = *x - 30; + assert_eq!(y, 62); + assert_eq!(called.load(SeqCst), 1); + }); + }); + + let y = *x - 30; + assert_eq!(y, 62); + assert_eq!(called.load(SeqCst), 1); +} + +#[test] +fn lazy_deref_mut() { + let called = AtomicUsize::new(0); + let mut x = Lazy::new(|| { + called.fetch_add(1, SeqCst); + 92 + }); + + assert_eq!(called.load(SeqCst), 0); + + let y = *x - 30; + assert_eq!(y, 62); + assert_eq!(called.load(SeqCst), 1); + + *x /= 2; + assert_eq!(*x, 46); + assert_eq!(called.load(SeqCst), 1); +} + +#[test] +fn lazy_force_mut() { + let called = Cell::new(0); + let mut x = Lazy::new(|| { + called.set(called.get() + 1); + 92 + }); + assert_eq!(called.get(), 0); + let v = Lazy::force_mut(&mut x); + assert_eq!(called.get(), 1); + + *v /= 2; + assert_eq!(*x, 46); + assert_eq!(called.get(), 1); +} + +#[test] +fn lazy_get_mut() { + let called = Cell::new(0); + let mut x: Lazy = Lazy::new(|| { + called.set(called.get() + 1); + 92 + }); + + assert_eq!(called.get(), 0); + assert_eq!(*x, 92); + + let mut_ref: &mut u32 = Lazy::get_mut(&mut x).unwrap(); + assert_eq!(called.get(), 1); + + *mut_ref /= 2; + assert_eq!(*x, 46); + assert_eq!(called.get(), 1); +} + +#[test] +fn lazy_default() { + static CALLED: AtomicUsize = AtomicUsize::new(0); + + struct Foo(u8); + impl Default for Foo { + fn default() -> Self { + CALLED.fetch_add(1, SeqCst); + Foo(42) + } + } + + let lazy: Lazy> = <_>::default(); + + assert_eq!(CALLED.load(SeqCst), 0); + + assert_eq!(lazy.lock().unwrap().0, 42); + assert_eq!(CALLED.load(SeqCst), 1); + + lazy.lock().unwrap().0 = 21; + + assert_eq!(lazy.lock().unwrap().0, 21); + assert_eq!(CALLED.load(SeqCst), 1); +} + +#[test] +fn static_lazy() { + static XS: Lazy> = Lazy::new(|| { + let mut xs = Vec::new(); + xs.push(1); + xs.push(2); + xs.push(3); + xs + }); + scope(|s| { + s.spawn(|| { + assert_eq!(&*XS, &vec![1, 2, 3]); + }); + }); + assert_eq!(&*XS, &vec![1, 2, 3]); +} + +#[test] +fn static_lazy_via_fn() { + fn xs() -> &'static Vec { + static XS: OnceCell> = OnceCell::new(); + XS.get_or_init(|| { + let mut xs = Vec::new(); + xs.push(1); + xs.push(2); + xs.push(3); + xs + }) + } + assert_eq!(xs(), &vec![1, 2, 3]); +} + +#[test] +fn lazy_into_value() { + let l: Lazy = Lazy::new(|| panic!()); + assert!(matches!(Lazy::into_value(l), Err(_))); + let l = Lazy::new(|| -> i32 { 92 }); + Lazy::force(&l); + assert!(matches!(Lazy::into_value(l), Ok(92))); +} + +#[test] +fn lazy_poisoning() { + let x: Lazy = Lazy::new(|| panic!("kaboom")); + for _ in 0..2 { + let res = std::panic::catch_unwind(|| x.len()); + assert!(res.is_err()); + } +} + +#[test] +// https://github.com/rust-lang/rust/issues/34761#issuecomment-256320669 +fn arrrrrrrrrrrrrrrrrrrrrr() { + let lazy: Lazy<&String, _>; + { + let s = String::new(); + lazy = Lazy::new(|| &s); + _ = *lazy; + } +} + +#[test] +fn lazy_is_sync_send() { + fn assert_traits() {} + assert_traits::>(); +} diff --git a/http/vendor/once_cell/tests/it/sync_once_cell.rs b/http/vendor/once_cell/tests/it/sync_once_cell.rs new file mode 100644 index 0000000..18382d8 --- /dev/null +++ b/http/vendor/once_cell/tests/it/sync_once_cell.rs @@ -0,0 +1,328 @@ +use std::{ + sync::atomic::{AtomicUsize, Ordering::SeqCst}, + thread::scope, +}; + +#[cfg(feature = "std")] +use std::sync::Barrier; + +#[cfg(not(feature = "std"))] +use core::cell::Cell; + +use once_cell::sync::{Lazy, OnceCell}; + +#[test] +fn once_cell() { + let c = OnceCell::new(); + assert!(c.get().is_none()); + scope(|s| { + s.spawn(|| { + c.get_or_init(|| 92); + assert_eq!(c.get(), Some(&92)); + }); + }); + c.get_or_init(|| panic!("Kabom!")); + assert_eq!(c.get(), Some(&92)); +} + +#[test] +fn once_cell_with_value() { + static CELL: OnceCell = OnceCell::with_value(12); + assert_eq!(CELL.get(), Some(&12)); +} + +#[test] +fn once_cell_get_mut() { + let mut c = OnceCell::new(); + assert!(c.get_mut().is_none()); + c.set(90).unwrap(); + *c.get_mut().unwrap() += 2; + assert_eq!(c.get_mut(), Some(&mut 92)); +} + +#[test] +fn once_cell_get_unchecked() { + let c = OnceCell::new(); + c.set(92).unwrap(); + unsafe { + assert_eq!(c.get_unchecked(), &92); + } +} + +#[test] +fn once_cell_drop() { + static DROP_CNT: AtomicUsize = AtomicUsize::new(0); + struct Dropper; + impl Drop for Dropper { + fn drop(&mut self) { + DROP_CNT.fetch_add(1, SeqCst); + } + } + + let x = OnceCell::new(); + scope(|s| { + s.spawn(|| { + x.get_or_init(|| Dropper); + assert_eq!(DROP_CNT.load(SeqCst), 0); + drop(x); + }); + }); + assert_eq!(DROP_CNT.load(SeqCst), 1); +} + +#[test] +fn once_cell_drop_empty() { + let x = OnceCell::::new(); + drop(x); +} + +#[test] +fn clone() { + let s = OnceCell::new(); + let c = s.clone(); + assert!(c.get().is_none()); + + s.set("hello".to_string()).unwrap(); + let c = s.clone(); + assert_eq!(c.get().map(String::as_str), Some("hello")); +} + +#[test] +fn get_or_try_init() { + let cell: OnceCell = OnceCell::new(); + assert!(cell.get().is_none()); + + let res = std::panic::catch_unwind(|| cell.get_or_try_init(|| -> Result<_, ()> { panic!() })); + assert!(res.is_err()); + assert!(cell.get().is_none()); + + assert_eq!(cell.get_or_try_init(|| Err(())), Err(())); + + assert_eq!(cell.get_or_try_init(|| Ok::<_, ()>("hello".to_string())), Ok(&"hello".to_string())); + assert_eq!(cell.get(), Some(&"hello".to_string())); +} + +#[cfg(feature = "std")] +#[test] +fn wait() { + let cell: OnceCell = OnceCell::new(); + scope(|s| { + s.spawn(|| cell.set("hello".to_string())); + let greeting = cell.wait(); + assert_eq!(greeting, "hello") + }); +} + +#[cfg(feature = "std")] +#[test] +fn wait_panic() { + let cell: OnceCell = OnceCell::new(); + scope(|s| { + let h1 = s.spawn(|| { + cell.get_or_try_init(|| -> Result { panic!() }).unwrap(); + }); + let h2 = s.spawn(|| { + assert!(h1.join().is_err()); + cell.get_or_try_init(|| -> Result { Ok("hello".to_string()) }).unwrap(); + }); + + let greeting = cell.wait(); + assert_eq!(greeting, "hello"); + assert!(h2.join().is_ok()); + }); +} + +#[cfg(feature = "std")] +#[test] +fn get_or_init_stress() { + let n_threads = if cfg!(miri) { 30 } else { 1_000 }; + let n_cells = if cfg!(miri) { 30 } else { 1_000 }; + let cells: Vec<_> = std::iter::repeat_with(|| (Barrier::new(n_threads), OnceCell::new())) + .take(n_cells) + .collect(); + scope(|s| { + for t in 0..n_threads { + let cells = &cells; + s.spawn(move || { + for (i, (b, s)) in cells.iter().enumerate() { + b.wait(); + let j = if t % 2 == 0 { s.wait() } else { s.get_or_init(|| i) }; + assert_eq!(*j, i); + } + }); + } + }); +} + +#[test] +fn from_impl() { + assert_eq!(OnceCell::from("value").get(), Some(&"value")); + assert_ne!(OnceCell::from("foo").get(), Some(&"bar")); +} + +#[test] +fn partialeq_impl() { + assert!(OnceCell::from("value") == OnceCell::from("value")); + assert!(OnceCell::from("foo") != OnceCell::from("bar")); + + assert!(OnceCell::::new() == OnceCell::new()); + assert!(OnceCell::::new() != OnceCell::from("value".to_owned())); +} + +#[test] +fn into_inner() { + let cell: OnceCell = OnceCell::new(); + assert_eq!(cell.into_inner(), None); + let cell = OnceCell::new(); + cell.set("hello".to_string()).unwrap(); + assert_eq!(cell.into_inner(), Some("hello".to_string())); +} + +#[test] +fn debug_impl() { + let cell = OnceCell::new(); + assert_eq!(format!("{:#?}", cell), "OnceCell(Uninit)"); + cell.set(vec!["hello", "world"]).unwrap(); + assert_eq!( + format!("{:#?}", cell), + r#"OnceCell( + [ + "hello", + "world", + ], +)"# + ); +} + +#[test] +#[cfg_attr(miri, ignore)] // miri doesn't support processes +#[cfg(feature = "std")] +fn reentrant_init() { + let examples_dir = { + let mut exe = std::env::current_exe().unwrap(); + exe.pop(); + exe.pop(); + exe.push("examples"); + exe + }; + let bin = examples_dir + .join("reentrant_init_deadlocks") + .with_extension(std::env::consts::EXE_EXTENSION); + let mut guard = Guard { child: std::process::Command::new(bin).spawn().unwrap() }; + std::thread::sleep(std::time::Duration::from_secs(2)); + let status = guard.child.try_wait().unwrap(); + assert!(status.is_none()); + + struct Guard { + child: std::process::Child, + } + + impl Drop for Guard { + fn drop(&mut self) { + let _ = self.child.kill(); + } + } +} + +#[cfg(not(feature = "std"))] +#[test] +#[should_panic(expected = "reentrant init")] +fn reentrant_init() { + let x: OnceCell> = OnceCell::new(); + let dangling_ref: Cell> = Cell::new(None); + x.get_or_init(|| { + let r = x.get_or_init(|| Box::new(92)); + dangling_ref.set(Some(r)); + Box::new(62) + }); + eprintln!("use after free: {:?}", dangling_ref.get().unwrap()); +} + +#[test] +fn eval_once_macro() { + macro_rules! eval_once { + (|| -> $ty:ty { + $($body:tt)* + }) => {{ + static ONCE_CELL: OnceCell<$ty> = OnceCell::new(); + fn init() -> $ty { + $($body)* + } + ONCE_CELL.get_or_init(init) + }}; + } + + let fib: &'static Vec = eval_once! { + || -> Vec { + let mut res = vec![1, 1]; + for i in 0..10 { + let next = res[i] + res[i + 1]; + res.push(next); + } + res + } + }; + assert_eq!(fib[5], 8) +} + +#[test] +fn once_cell_does_not_leak_partially_constructed_boxes() { + let n_tries = if cfg!(miri) { 10 } else { 100 }; + let n_readers = 10; + let n_writers = 3; + const MSG: &str = "Hello, World"; + + for _ in 0..n_tries { + let cell: OnceCell = OnceCell::new(); + scope(|scope| { + for _ in 0..n_readers { + scope.spawn(|| loop { + if let Some(msg) = cell.get() { + assert_eq!(msg, MSG); + break; + } + }); + } + for _ in 0..n_writers { + let _ = scope.spawn(|| cell.set(MSG.to_owned())); + } + }); + } +} + +#[cfg(feature = "std")] +#[test] +fn get_does_not_block() { + let cell = OnceCell::new(); + let barrier = Barrier::new(2); + scope(|scope| { + scope.spawn(|| { + cell.get_or_init(|| { + barrier.wait(); + barrier.wait(); + "hello".to_string() + }); + }); + barrier.wait(); + assert_eq!(cell.get(), None); + barrier.wait(); + }); + assert_eq!(cell.get(), Some(&"hello".to_string())); +} + +#[test] +// https://github.com/rust-lang/rust/issues/34761#issuecomment-256320669 +fn arrrrrrrrrrrrrrrrrrrrrr() { + let cell = OnceCell::new(); + { + let s = String::new(); + cell.set(&s).unwrap(); + } +} + +#[test] +fn once_cell_is_sync_send() { + fn assert_traits() {} + assert_traits::>(); + assert_traits::>(); +} diff --git a/http/vendor/once_cell/tests/it/unsync_lazy.rs b/http/vendor/once_cell/tests/it/unsync_lazy.rs new file mode 100644 index 0000000..0c308ca --- /dev/null +++ b/http/vendor/once_cell/tests/it/unsync_lazy.rs @@ -0,0 +1,134 @@ +use core::{ + cell::Cell, + sync::atomic::{AtomicUsize, Ordering::SeqCst}, +}; + +use once_cell::unsync::Lazy; + +#[test] +fn lazy_new() { + let called = Cell::new(0); + let x = Lazy::new(|| { + called.set(called.get() + 1); + 92 + }); + + assert_eq!(called.get(), 0); + + let y = *x - 30; + assert_eq!(y, 62); + assert_eq!(called.get(), 1); + + let y = *x - 30; + assert_eq!(y, 62); + assert_eq!(called.get(), 1); +} + +#[test] +fn lazy_deref_mut() { + let called = Cell::new(0); + let mut x = Lazy::new(|| { + called.set(called.get() + 1); + 92 + }); + + assert_eq!(called.get(), 0); + + let y = *x - 30; + assert_eq!(y, 62); + assert_eq!(called.get(), 1); + + *x /= 2; + assert_eq!(*x, 46); + assert_eq!(called.get(), 1); +} + +#[test] +fn lazy_force_mut() { + let called = Cell::new(0); + let mut x = Lazy::new(|| { + called.set(called.get() + 1); + 92 + }); + assert_eq!(called.get(), 0); + let v = Lazy::force_mut(&mut x); + assert_eq!(called.get(), 1); + + *v /= 2; + assert_eq!(*x, 46); + assert_eq!(called.get(), 1); +} + +#[test] +fn lazy_get_mut() { + let called = Cell::new(0); + let mut x: Lazy = Lazy::new(|| { + called.set(called.get() + 1); + 92 + }); + + assert_eq!(called.get(), 0); + assert_eq!(*x, 92); + + let mut_ref: &mut u32 = Lazy::get_mut(&mut x).unwrap(); + assert_eq!(called.get(), 1); + + *mut_ref /= 2; + assert_eq!(*x, 46); + assert_eq!(called.get(), 1); +} + +#[test] +fn lazy_default() { + static CALLED: AtomicUsize = AtomicUsize::new(0); + + struct Foo(u8); + impl Default for Foo { + fn default() -> Self { + CALLED.fetch_add(1, SeqCst); + Foo(42) + } + } + + let lazy: Lazy> = <_>::default(); + + assert_eq!(CALLED.load(SeqCst), 0); + + assert_eq!(lazy.lock().unwrap().0, 42); + assert_eq!(CALLED.load(SeqCst), 1); + + lazy.lock().unwrap().0 = 21; + + assert_eq!(lazy.lock().unwrap().0, 21); + assert_eq!(CALLED.load(SeqCst), 1); +} + +#[test] +fn lazy_into_value() { + let l: Lazy = Lazy::new(|| panic!()); + assert!(matches!(Lazy::into_value(l), Err(_))); + let l = Lazy::new(|| -> i32 { 92 }); + Lazy::force(&l); + assert!(matches!(Lazy::into_value(l), Ok(92))); +} + +#[test] +#[cfg(feature = "std")] +fn lazy_poisoning() { + let x: Lazy = Lazy::new(|| panic!("kaboom")); + for _ in 0..2 { + let res = std::panic::catch_unwind(|| x.len()); + assert!(res.is_err()); + } +} + +#[test] +// https://github.com/rust-lang/rust/issues/34761#issuecomment-256320669 +fn arrrrrrrrrrrrrrrrrrrrrr() { + let lazy: Lazy<&String, _>; + { + let s = String::new(); + lazy = Lazy::new(|| &s); + _ = *lazy; + } +} diff --git a/http/vendor/once_cell/tests/it/unsync_once_cell.rs b/http/vendor/once_cell/tests/it/unsync_once_cell.rs new file mode 100644 index 0000000..124cc3e --- /dev/null +++ b/http/vendor/once_cell/tests/it/unsync_once_cell.rs @@ -0,0 +1,154 @@ +use core::{ + cell::Cell, + sync::atomic::{AtomicUsize, Ordering::SeqCst}, +}; + +use once_cell::unsync::OnceCell; + +#[test] +fn once_cell() { + let c = OnceCell::new(); + assert!(c.get().is_none()); + c.get_or_init(|| 92); + assert_eq!(c.get(), Some(&92)); + + c.get_or_init(|| panic!("Kabom!")); + assert_eq!(c.get(), Some(&92)); +} + +#[test] +fn once_cell_with_value() { + const CELL: OnceCell = OnceCell::with_value(12); + let cell = CELL; + assert_eq!(cell.get(), Some(&12)); +} + +#[test] +fn once_cell_get_mut() { + let mut c = OnceCell::new(); + assert!(c.get_mut().is_none()); + c.set(90).unwrap(); + *c.get_mut().unwrap() += 2; + assert_eq!(c.get_mut(), Some(&mut 92)); +} + +#[test] +fn once_cell_drop() { + static DROP_CNT: AtomicUsize = AtomicUsize::new(0); + struct Dropper; + impl Drop for Dropper { + fn drop(&mut self) { + DROP_CNT.fetch_add(1, SeqCst); + } + } + + let x = OnceCell::new(); + x.get_or_init(|| Dropper); + assert_eq!(DROP_CNT.load(SeqCst), 0); + drop(x); + assert_eq!(DROP_CNT.load(SeqCst), 1); +} + +#[test] +fn once_cell_drop_empty() { + let x = OnceCell::::new(); + drop(x); +} + +#[test] +fn clone() { + let s = OnceCell::new(); + let c = s.clone(); + assert!(c.get().is_none()); + + s.set("hello".to_string()).unwrap(); + let c = s.clone(); + assert_eq!(c.get().map(String::as_str), Some("hello")); +} + +#[test] +fn get_or_try_init() { + let cell: OnceCell = OnceCell::new(); + assert!(cell.get().is_none()); + + let res = std::panic::catch_unwind(|| cell.get_or_try_init(|| -> Result<_, ()> { panic!() })); + assert!(res.is_err()); + assert!(cell.get().is_none()); + + assert_eq!(cell.get_or_try_init(|| Err(())), Err(())); + + assert_eq!(cell.get_or_try_init(|| Ok::<_, ()>("hello".to_string())), Ok(&"hello".to_string())); + assert_eq!(cell.get(), Some(&"hello".to_string())); +} + +#[test] +fn from_impl() { + assert_eq!(OnceCell::from("value").get(), Some(&"value")); + assert_ne!(OnceCell::from("foo").get(), Some(&"bar")); +} + +#[test] +fn partialeq_impl() { + assert!(OnceCell::from("value") == OnceCell::from("value")); + assert!(OnceCell::from("foo") != OnceCell::from("bar")); + + assert!(OnceCell::::new() == OnceCell::new()); + assert!(OnceCell::::new() != OnceCell::from("value".to_owned())); +} + +#[test] +fn into_inner() { + let cell: OnceCell = OnceCell::new(); + assert_eq!(cell.into_inner(), None); + let cell = OnceCell::new(); + cell.set("hello".to_string()).unwrap(); + assert_eq!(cell.into_inner(), Some("hello".to_string())); +} + +#[test] +fn debug_impl() { + let cell = OnceCell::new(); + assert_eq!(format!("{:#?}", cell), "OnceCell(Uninit)"); + cell.set(vec!["hello", "world"]).unwrap(); + assert_eq!( + format!("{:#?}", cell), + r#"OnceCell( + [ + "hello", + "world", + ], +)"# + ); +} + +#[test] +#[should_panic(expected = "reentrant init")] +fn reentrant_init() { + let x: OnceCell> = OnceCell::new(); + let dangling_ref: Cell> = Cell::new(None); + x.get_or_init(|| { + let r = x.get_or_init(|| Box::new(92)); + dangling_ref.set(Some(r)); + Box::new(62) + }); + eprintln!("use after free: {:?}", dangling_ref.get().unwrap()); +} + +#[test] +fn aliasing_in_get() { + let x = OnceCell::new(); + x.set(42).unwrap(); + let at_x = x.get().unwrap(); // --- (shared) borrow of inner `Option` --+ + let _ = x.set(27); // <-- temporary (unique) borrow of inner `Option` | + println!("{}", at_x); // <------- up until here ---------------------------+ +} + +#[test] +// https://github.com/rust-lang/rust/issues/34761#issuecomment-256320669 +fn arrrrrrrrrrrrrrrrrrrrrr() { + let cell = OnceCell::new(); + { + let s = String::new(); + cell.set(&s).unwrap(); + } +} diff --git a/http/vendor/ring/.cargo-checksum.json b/http/vendor/ring/.cargo-checksum.json new file mode 100644 index 0000000..5a999a2 --- /dev/null +++ b/http/vendor/ring/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{".cargo_vcs_info.json":"814e1ce7f5a67f2e37d5f9a9e566defa89961b32cce17d1b4da028673929b5b8","Cargo.lock":"04cb4d37c89afc375a41b990813dd1bc2f89dd6ffb4509f02894245160ac2d23","Cargo.toml":"b81a19b27cc744410b056eb1d1195ecd41e25a163acadfca3c6457e96b797d3f","Cargo.toml.orig":"4c58550e0f323c33bff699c2c00ee7320f2e078b68e9eafc9b269f65784873de","LICENSE":"b3d734001a94efff3579978d953391aa7115f877657d25eb54037a43875d078a","LICENSE-BoringSSL":"005fc765ddc5115da796cca915baa9557abae13ff35e0a47c47affc56f6c414d","LICENSE-other-bits":"f025ccfb7dfb6bdfedc75ca0f67acc69e6fb4998143d834f7c2f38a29989680f","README.md":"4c291847f83f138b087d2c7a4474cbdc6298ed9f04d32b65d3e222c7d10a2188","build.rs":"9d1928ffb1d8e15766c1c1b9ead73e4b81a21703dd25f7c27b87842a2e6e9cee","crypto/chacha/asm/chacha-armv4.pl":"25100401cfe20d6f39cf71a3f3ffe54b5a2d2b93828f84a104c0599d1c30c9c4","crypto/chacha/asm/chacha-armv8.pl":"05fe6547dab17296cb7e0b8b9253a860a39c7c931569ab22cd420e0083505fe6","crypto/chacha/asm/chacha-x86.pl":"c3b133032416211ffddd63485636ada3ee9783d2a41deb39da59f6cb09b9feab","crypto/chacha/asm/chacha-x86_64.pl":"24e536daad8464a6daea17de527b02f9c3ebe1f09356dd5e48cfdfa04abb955a","crypto/cipher/asm/chacha20_poly1305_armv8.pl":"a7f58ba7d3dd189fe2f1acde2357d62fce89f311509c7a058ead468cd6796de4","crypto/cipher/asm/chacha20_poly1305_x86_64.pl":"48f2a06a297d3575a760d01e219b0b8d8f8733c1e7b6d2aa6e7949cc12c1a9ae","crypto/constant_time_test.c":"bf5812781fb3fdd1e46ddc92124a74d821e77130af2593b22b196762e78607b9","crypto/cpu_intel.c":"7d2d2cd105344fa6e2142111597c733866c6cbb5718680947a13f53cb437ae61","crypto/crypto.c":"59df0a94f3edcb1655f1eb4d9f6dc99129efb252eb521edc4e5b1d862ebe63f4","crypto/curve25519/asm/x25519-asm-arm.S":"1791bcd4b8e8df8a8f0fe4f89de9e182fcf93551a9de3e557f85252d5ae77d17","crypto/curve25519/curve25519.c":"92f82432d2a75e3b82f3d9b697be12af42e737809126b81635a64307d6f08a63","crypto/curve25519/curve25519_64_adx.c":"1447697854e4e9863d4a76e1bf57b15965eda8b357af44b13cd11e53e33ee34d","crypto/curve25519/curve25519_tables.h":"cf93296bd07d68da2ee398d1ea0a51cfefddf72ab03cbb41d3bbb7894d651f6d","crypto/curve25519/internal.h":"c69c60db0bd994ed8b3a0693202e13eeda85c28ee0a09b6ff954a85b67e00dd9","crypto/fipsmodule/aes/aes_nohw.c":"a78fb13eaf6704c6ab4109efc77dc14cabcefd7c8c78cd983e4daad97bbce42b","crypto/fipsmodule/aes/asm/aes-gcm-avx2-x86_64.pl":"981415091853018d18144f6b3f3459e5ecf5cddd962d2706f1c7391a48fa6722","crypto/fipsmodule/aes/asm/aesni-gcm-x86_64.pl":"e85c2ddf728eb6253562f24d2db6fb305ed7808110f18949cdcd597e6c52c532","crypto/fipsmodule/aes/asm/aesni-x86.pl":"c08d6b755f541256190730274fde1d8634165760856bf05d1a0300f7f1313e91","crypto/fipsmodule/aes/asm/aesni-x86_64.pl":"74e331f10e9e97ae998a1929cacd7f6653b4826158a9269a82d5780ccfad72c8","crypto/fipsmodule/aes/asm/aesv8-armx.pl":"989b4086b368c8df4085dc433d020e463a9c24716e59b473fdbcc751d8357e21","crypto/fipsmodule/aes/asm/aesv8-gcm-armv8.pl":"e2f7e1a1147f711255e974f5942be63139da27db8da0706b0e7bfe23e4ef4c48","crypto/fipsmodule/aes/asm/bsaes-armv7.pl":"b262de8ca1d88c83de3319a926c637ae51781d530b710904bafd3ad360f52929","crypto/fipsmodule/aes/asm/ghash-armv4.pl":"d1a0f8100031e2c6babc97eacc8b05cb076952a2d63d07487ceebbb8ce176e18","crypto/fipsmodule/aes/asm/ghash-neon-armv8.pl":"6530524ab8c968cfc2867355cda5021da30ebd256e229e52b8936419a1f968d5","crypto/fipsmodule/aes/asm/ghash-x86.pl":"4487fc642997d6741981381da74f7e72cbf9297682e5b7ada9bb57cc1101f786","crypto/fipsmodule/aes/asm/ghash-x86_64.pl":"889157ff342fae29cec2e84f5d767e8c2e39910626a113ede4ffb526cd757f04","crypto/fipsmodule/aes/asm/ghashv8-armx.pl":"081ec51966fee94ee0bd5710e82a581c5b131deec40347d79587a6db9ae8c6a8","crypto/fipsmodule/aes/asm/vpaes-armv7.pl":"0cccfba4deebf93ae317c4e14c2986ec8abac58e4a8557924248eebaa975139e","crypto/fipsmodule/aes/asm/vpaes-armv8.pl":"7c0e738f4166f38f39bb709ca0bde1a3cec009708646c7c94971dce28b3fa9c9","crypto/fipsmodule/aes/asm/vpaes-x86.pl":"ef5252558dc5b23b7550800f53ab3d7c508f2a4fe71c717c5b35b05a971ec3d6","crypto/fipsmodule/aes/asm/vpaes-x86_64.pl":"b54f198a0faac2cc144f98a6c14019fe6d58d897124c7d69aebb2535a0102de9","crypto/fipsmodule/bn/asm/armv4-mont.pl":"2cb2a0a84c4281a9dda17945b94e76b5a9656dc2df6d8c2c1e62be7ff59e3b12","crypto/fipsmodule/bn/asm/armv8-mont.pl":"8993f64606360cbc1b688a1ec3ffd7011464ea78823a126df10e29bd94adaf13","crypto/fipsmodule/bn/asm/x86-mont.pl":"3a7085a9c8de3d7fd684de75d397e1aa4b74ca0386e9bc4d353626e06b6be3ab","crypto/fipsmodule/bn/asm/x86_64-mont.pl":"14cd1cb9fa1dd08473afa943e90ce98a43fbb4a9323d3101871f6724fb6b27ac","crypto/fipsmodule/bn/asm/x86_64-mont5.pl":"c0529d1a7faefd26c065601d5cfdc081c314c04294fd2c69589696681edf867c","crypto/fipsmodule/bn/internal.h":"224b9025f19fa747e91a70e4118a3669cb995d72838a34bceef3050dd7c8137d","crypto/fipsmodule/bn/montgomery.c":"dabd7d93bb368b9841bccb8ceae2bf9a358e31a183a610afdffbeff360e44f94","crypto/fipsmodule/bn/montgomery_inv.c":"d70a47e5db6c01d1df334dcf2bada013c93836e10d922ca0f0611c638b55d359","crypto/fipsmodule/ec/asm/p256-armv8-asm.pl":"029ce13a55ccf289f3cb58271ab6e1602f4b68ec244c3cbe739cc0858944ad50","crypto/fipsmodule/ec/asm/p256-x86_64-asm.pl":"454c278064dbae0f718bb2e415efee97e31a38958776623574632961b24e34ca","crypto/fipsmodule/ec/ecp_nistz.c":"d5d2359807cea970cdbd059935322890a5535c39b8abf633d4324656392d527d","crypto/fipsmodule/ec/ecp_nistz.h":"ba6982c928bbbc3c71e9ef2a7bd0e1f4ca3436bf3d178e0c5727fbcd49dfea61","crypto/fipsmodule/ec/ecp_nistz384.h":"7aeb84e1d64b1018d8e0c89b97ae1e603f31f9cd4786104ce5932f4d425bb1d7","crypto/fipsmodule/ec/ecp_nistz384.inl":"0229835ebc9bdfe9268c53cf3e5d346831a9b2f66377a320d92407f2293b5412","crypto/fipsmodule/ec/gfp_p256.c":"d7bbcc9c22d1885a465b41c6fbb4b4f7e5f22eed9566da6c8a52dfe2bfce1bf5","crypto/fipsmodule/ec/gfp_p384.c":"9a134536f0ac03d8f1e0bed849501a7a1b77754bb9cb2361d20e1acb26c5b757","crypto/fipsmodule/ec/p256-nistz-table.h":"eae4169efa9021ca93cf265be4de56bf1cb77e19c2957573e363c99a166953aa","crypto/fipsmodule/ec/p256-nistz.c":"033e609fc9709c20f4b46c54760a1386a439b95585759bbd7ebaa3024a051133","crypto/fipsmodule/ec/p256-nistz.h":"41d88cdd8f66e7ded5113290790e915c07c263c0e778078c7c76311d441b1513","crypto/fipsmodule/ec/p256.c":"359181086054d3ac46ab1ef7f736f3716c5dce2f6f2170ec9861cbf8f83c9ae3","crypto/fipsmodule/ec/p256_shared.h":"1a69c500d344254a43afa37c2a6887f30d07d7d21ffe3a13988894171c98df48","crypto/fipsmodule/ec/p256_table.h":"08da299899fe944c293a9675cd463d8223c9ab858786384221bc191284c5c4c0","crypto/fipsmodule/ec/util.h":"4e46df71bfa9759447e8833accdf924e0c005770e419239c7227d4c89ce64e10","crypto/fipsmodule/ecdsa/ecdsa_verify_tests.txt":"a607b74542c3833ab907e74e341c988ed16ee1e4b02c4323887e82c881a6b990","crypto/fipsmodule/sha/asm/sha256-armv4.pl":"1a9cc7c77921fb44912bf6e946d002a59a66ead474d0dc8b2bc581492dd941c5","crypto/fipsmodule/sha/asm/sha512-armv4.pl":"d900f16d6ecc4187a5a5ee35f1e7cf932ca5fe934ddeb4e0e55a8a05ff8393b7","crypto/fipsmodule/sha/asm/sha512-armv8.pl":"3db10ef65179656aa709cdab607ca3c5a2f5244d33071984385eb5990f7b404e","crypto/fipsmodule/sha/asm/sha512-x86_64.pl":"ab4c2e2cd6425b26d7df080bf363e938242016bfc929e523aa3318c6d352a098","crypto/internal.h":"c98b20d935dc38ecb83056c66006c5d633f01b30332428c20c1ebb84cb0c3d47","crypto/limbs/limbs.c":"f99051c9960ee135cc2ff9ef6c5798d97874b98d388ecef7df79c1067dd68cd6","crypto/limbs/limbs.h":"6800be804ae1272ed9733aa555de6a877874c4dff2f89ab3379dad44a3671078","crypto/limbs/limbs.inl":"5e09906440993389c1e54fecd0987a2140b05a96b59a628b5b2bcf6871028d76","crypto/mem.c":"5a4c1090e7e7309815c1d7f73e7ca8412761b1b8bb556cf471ce7c7e26a18503","crypto/perlasm/arm-xlate.pl":"18c99bd9639d132b091bd360af7a1cfc57148b46cabcc7d20224c68a35d432bf","crypto/perlasm/x86_64-xlate.pl":"783d46f1a12d150a60d51b44e3c1141b19ff65268f8d85e9bb4a44cdf32b9caa","crypto/perlasm/x86asm.pl":"99a3123e5135486546b36cf32c8e91f3635451cb9d926acdc6ac4d82aa652ed5","crypto/perlasm/x86gas.pl":"48bd5fb1f764137fe58dac82e86b8876bc9bdfd041ff53b5706ba2ad46bf6d80","crypto/perlasm/x86nasm.pl":"15383baac0a53850322e304b8f2ff9f210bed8c0d080ae938d329d71ed93d71e","crypto/poly1305/poly1305.c":"ef9031a370c97e16e7784eb70a982bf718734058ed960fd4c76f08385f03f2f7","crypto/poly1305/poly1305_arm.c":"2b2fc2e6c7b989d4d73626d4f15006b896b3eb16d08a131415b92b8a1c2c8b99","crypto/poly1305/poly1305_arm_asm.S":"87ad5d9ab8d23054d132d6881c878f2042fd8376a4af386d44ffc641ffd19010","include/ring-core/aes.h":"73c97c5517e11606ff8d4e9569fcce33e528665e27bbc1a04049879dc0f0092f","include/ring-core/asm_base.h":"23fab9f85899946ce27387cb60bc4dd6a90190b8284a9596a5bf3f045008d41e","include/ring-core/base.h":"c333f88dc2d0963a09e73ed7f9afe958ef88e3e6c6d19162fabc4f25a153eb78","include/ring-core/check.h":"22d393968de36256b2df48f9c8e5e2573e03cc362501c9060099d1d3338ad4f6","include/ring-core/mem.h":"31798b2fd5303aeda1429e70089655bd678894c5dff3c0d8e449ae0ea38b35f2","include/ring-core/target.h":"fedcf0f505a0ec0e50a5b2b7d2338bd52c2672d49739e902a1e662fe7a5fc586","include/ring-core/type_check.h":"00bc2c11882f30d975a23b2a9a94ceba72b3bcd1453fd6a9698b2575fe1dd0df","pregenerated/aes-gcm-avx2-x86_64-elf.S":"7d5475c2199ddd6f71daf14fb667f1f1c371372bd0878af8820abfd9461c920d","pregenerated/aes-gcm-avx2-x86_64-macosx.S":"9677df6b91e16301bfd125d4b78b6da23f11607ca96837bf5671f6d6c2dc6257","pregenerated/aes-gcm-avx2-x86_64-nasm.asm":"4453341dc4ebf944538c0535a9124879adf4e7446ef86632ce87f906b97f6de9","pregenerated/aes-gcm-avx2-x86_64-nasm.o":"78b04a1cdf412d3f288e743df2d8a1d42b4d61ba1c62ccf31642614de2b46ae4","pregenerated/aesni-gcm-x86_64-elf.S":"65d6fe52c6b4e33b8d1143b23618c416a311aa484088a46c2d3974e005c8a09f","pregenerated/aesni-gcm-x86_64-macosx.S":"c5ec0ccb1e60d2dcd34ba494980c2619e4ca3fff137883b0dd5853b2c1ac2c9f","pregenerated/aesni-gcm-x86_64-nasm.asm":"f7a21b4ad3617f3d74c3ab1e1a07d8a62b6c12f8edb6e273c6e2a2b0d22a36fc","pregenerated/aesni-gcm-x86_64-nasm.o":"b0567127aa4fad7752ddaa5efc35ce3ebd5fc00a9dd5a6cfe851b30d917839b5","pregenerated/aesni-x86-elf.S":"58df78619ef2462208093815fdf73051c416135d026231717d18e6ea48d19538","pregenerated/aesni-x86-win32n.asm":"615e2fece54528c7de38e4c53e4241a266c90eacc59a0f5928e84361a044bdd5","pregenerated/aesni-x86-win32n.o":"7aac096c17b19a3db102c18b985083f4cc36426469e128ec1773d3da3fce3c83","pregenerated/aesni-x86_64-elf.S":"f14c999c418f5a578fdc83425a1766129995b97f5cff91fbaa12bc00e84628c4","pregenerated/aesni-x86_64-macosx.S":"e401adb1b54894597507b994ae66534aff32669dbcf7faf00598e8dd58556d1f","pregenerated/aesni-x86_64-nasm.asm":"f683c54d4ed37a2706638457de020d0f03804978063f88ffc92c6d546243acd4","pregenerated/aesni-x86_64-nasm.o":"7a0f5946072b1bd43712460f83f32c693d5998eff88c95a18d73101bf86ae598","pregenerated/aesv8-armx-ios64.S":"b462dd29d15a481b2f382748624ebc124d8a3ca5de160ae21929e6a90404decc","pregenerated/aesv8-armx-linux64.S":"18fbfacc8dafeb3912664495998aa29b66f39775410d2a44e4b3afea2cdfa927","pregenerated/aesv8-armx-win64.S":"4bdec48b8329cbaba41c09ded8c68b7b322712fae01dcd43b6c6446ea1fa5467","pregenerated/aesv8-gcm-armv8-ios64.S":"d6ab780020e2b93c5e7ac038605737797190e8a05648e7c2fa85488cb38f897f","pregenerated/aesv8-gcm-armv8-linux64.S":"b631f75b43bfa664cc97dd89aa43b7b407619d496ed2593bb3075d405fb7b6c8","pregenerated/aesv8-gcm-armv8-win64.S":"8867f3c50364f4d934e5af06fe59a35039f07b872ac8853f853ac8510372da0e","pregenerated/armv4-mont-linux32.S":"e1ce8a9b63ba7b151520c8bfddf66dd5228341461ccb98391decf1eabd96e1f0","pregenerated/armv8-mont-ios64.S":"22e4b20e068d0e3fb8556b590fa7a86791c22a53f15f04207df8378d94d4c462","pregenerated/armv8-mont-linux64.S":"29109868c3b129375d0c2990fe021b9b65d1bbc40c35ab354892365dc3f23d4f","pregenerated/armv8-mont-win64.S":"33922f8ffe9236f9a4b84286bf851fdccd2bb04814f001cc96351e6ce82385bc","pregenerated/bsaes-armv7-linux32.S":"57b3c3d8d1b1948d026374b807d1dbe696a79b70caae6c293118954b6c494440","pregenerated/chacha-armv4-linux32.S":"c33cf27203c1b5a2e3bc4a4c5bf0d8fbdc958ec1c87207c85f9e28a6cb854a38","pregenerated/chacha-armv8-ios64.S":"5f8068c0e4d383118acef097d3808eff801ac85b431951547019ac9c8d74c12a","pregenerated/chacha-armv8-linux64.S":"e9fbe874ecaa8b43801cf42fd1e0e7b2b61b663c96a705006c409e5d2be396df","pregenerated/chacha-armv8-win64.S":"b6e724e3b4bc45318237258b13b8085ba2c0efc5855a40e5ca61b145f4114c5c","pregenerated/chacha-x86-elf.S":"80d184325177c46fca62348387cacaf7635c4254488c085bdf0f9091acc6a833","pregenerated/chacha-x86-win32n.asm":"5f6963f04507c5442c0d97cdcaf5ceedffafaedb9ab5d8726595952d95564c10","pregenerated/chacha-x86-win32n.o":"f7fdc6f43052e625da062085c792136c9813bbfe2f6118fed9da84101fb8c69e","pregenerated/chacha-x86_64-elf.S":"ccd1e5c64199878115080ac979ec290fa009dde767e490b6e0e9cedefaf3a0f0","pregenerated/chacha-x86_64-macosx.S":"2f0a24cb24aa2767634624547893018c0f580f51136874c0dc0781fca65a41fa","pregenerated/chacha-x86_64-nasm.asm":"b8a6e8e4c1b0341798b33b5d57c58e2e40a703d2f0e668bd845c07453e94adea","pregenerated/chacha-x86_64-nasm.o":"8bda22cae2f0d116ad54ca30395a4d19db9702f800cc97f7f6c9dbe0e36f03e5","pregenerated/chacha20_poly1305_armv8-ios64.S":"dc2e632365d720aa93608b6252aa2c1fd58fdadeba4729ff806f66ef2f4a1988","pregenerated/chacha20_poly1305_armv8-linux64.S":"bdd44452f0ed0ec803de9823a24e301a09567798cf3e00fc1bf139ae6575c032","pregenerated/chacha20_poly1305_armv8-win64.S":"170e30b85bb6a3fdf43f4be90b9c99348dadfb225a5ee51638730e8bd332d70b","pregenerated/chacha20_poly1305_x86_64-elf.S":"286c6eb57b9744a59e252db0e5c1ccbe39a7cd7c30e93c4c349b3c0321f48430","pregenerated/chacha20_poly1305_x86_64-macosx.S":"899e2e5592eae9b9a8d0e90f24d9899cff1eeb3864cad9b6025bf722515afeb9","pregenerated/chacha20_poly1305_x86_64-nasm.asm":"ccfef09bfc0c7cf84892fe0a1f1aacd459bf41b0a865d9803ee0666da71e158d","pregenerated/chacha20_poly1305_x86_64-nasm.o":"19d76b32b14bb5c91391f52dffd80e32a9c3e8f33295353cbdec00971aee73c8","pregenerated/ghash-armv4-linux32.S":"b264af5255234b650038d29eacecafad533ebd242b76d9abb86231ebaa9cd3d2","pregenerated/ghash-neon-armv8-ios64.S":"078a6ffb111f3376bd47cec2abdea46180b0c8676ee33e0d9dabd912b6ea65c0","pregenerated/ghash-neon-armv8-linux64.S":"8119a57c4c9820c43fc8cd48cb61f1b75888e10faed8346fc2c318bacce76898","pregenerated/ghash-neon-armv8-win64.S":"f2c51e94f8a1f5225b3c74341ec416735d6f5882eaa140b615e96e35ed3b2fe3","pregenerated/ghash-x86-elf.S":"bd563cbd50a11500f9f8cebaf187b686c7b04647f63e3f753ea25c70f46c49f0","pregenerated/ghash-x86-win32n.asm":"9b2ce35d865e9bf298fcf829dc2b2d33be108c8ce76b4a34a5487ee1617cd224","pregenerated/ghash-x86-win32n.o":"4e08a503d2c99d5e6f15173b17cb82d09f8394b45f3fc26f4003576c348f49b2","pregenerated/ghash-x86_64-elf.S":"66192b018e799f09f1cf9891861ed9e2372fd7c5f03d61f711ff81ea1edbb7a5","pregenerated/ghash-x86_64-macosx.S":"bc73d577f1d67d493f56a27b9ac7f1e232a07840c60fc0d6e68f54004cf6e728","pregenerated/ghash-x86_64-nasm.asm":"53525fedf1ace9a9a55cbba1d4ca6f1904a07cdf961aa27dc0e93052efb80df9","pregenerated/ghash-x86_64-nasm.o":"297a912601488fa8453ab538119f7be27212a02024c7ca6fc5a37575e4c276a3","pregenerated/ghashv8-armx-ios64.S":"4a62e1fbe80f7696aaa97846fde81b50d82dc3e71f5ac856b356bcd0c935e1af","pregenerated/ghashv8-armx-linux64.S":"add33225aced1b6f8e36582075cdafacc5cbd6461dfe23f5c3ff5a6486cf2c90","pregenerated/ghashv8-armx-win64.S":"3f411d95b37ca8e3e0cf30b200a5cf34964ecf2076a633d7aebf402ddbb13abf","pregenerated/p256-armv8-asm-ios64.S":"3a5f857a50f9be57b24d549cc083d1473693a02cd640216537b75bc0d0249f59","pregenerated/p256-armv8-asm-linux64.S":"48a08da50c5177aaf315c4d36ccb41715563459df3e32bb02c26b41e680b58dc","pregenerated/p256-armv8-asm-win64.S":"d910168308ee483c0cf66c6ade406760b18d9f6da31deca47bad1b14aed92ae1","pregenerated/p256-x86_64-asm-elf.S":"1656e4586e175db597e44d0683cec5817688668ede069a7e5361f56518b240ef","pregenerated/p256-x86_64-asm-macosx.S":"ecc7a409cf390dc5509d1305bdb47b4f82eccfdb1b58ab8e1f78a144a89405c3","pregenerated/p256-x86_64-asm-nasm.asm":"18ab0d3071fa289cadbc9aaf78867989f87c181b97d3783a038fd23078e87ce7","pregenerated/p256-x86_64-asm-nasm.o":"89bff078176c99f3fe22292d08b0be2c16434c37a7a059ebcbf7901bc37ddd3b","pregenerated/ring_core_generated/prefix_symbols.h":"7b9595d8bf93565ff8f756ec2e87c3066c1758a2af5bc16069bd64356b7a6359","pregenerated/ring_core_generated/prefix_symbols_asm.h":"208692521d54d5c6b9cb58fde17bcd6ae7e5eafa36062724d89230aaf3419457","pregenerated/ring_core_generated/prefix_symbols_nasm.inc":"84a0eb1337553d688b6224796e026fcd8a7135991e8f6d1f3f55404c07b19f29","pregenerated/sha256-armv4-linux32.S":"f57a53c03f8e42fea4828faca1ae8b57ed6752ff5201818ec257b0f71c686a7b","pregenerated/sha256-armv8-ios64.S":"4ab185c41aa8eea6cd4740a2a9c3bee51e6db6e24d8fa1e3aaf4124d5be5ce8a","pregenerated/sha256-armv8-linux64.S":"8d4c258e050e3b6ffa203e274f8402fd90b479dc40420283d9ada069a2fdb8f3","pregenerated/sha256-armv8-win64.S":"d8fee56141fac6c74319964a2e5c0f14f1c302baa87cf35ffe055790e29c3531","pregenerated/sha256-x86_64-elf.S":"25d2341ad14f7e0093638f37290b81d76fd460924a3c90c29294e4731d7cbe2f","pregenerated/sha256-x86_64-macosx.S":"2139751d1e13198849be3c127afe289e0131a4288b31532c9b85b84070c43b35","pregenerated/sha256-x86_64-nasm.asm":"aa6f5275addc1438ba7279132369e42e06c8e180b04283c7dff1ce26943a15f9","pregenerated/sha256-x86_64-nasm.o":"da82affac410c37d36ca92b9639b09198331d2e3bb5ed24a3312b1ea428ed913","pregenerated/sha512-armv4-linux32.S":"40a1bfec7807fd68863be1ae352da5de8228b073ba2e2915b5385aff82e44bc4","pregenerated/sha512-armv8-ios64.S":"ca8680a5d43bb77fcaa01b67dd18f54f9e41bb41fc93158f52555b5328177e60","pregenerated/sha512-armv8-linux64.S":"22708c3d7089cea4bca00c884f7d2a3cdae1a8620182d3d3fe61990d01a8b420","pregenerated/sha512-armv8-win64.S":"def3d9ff61f39ed437fa31df2a1656198463af73f108106507dbf2ea2a962c06","pregenerated/sha512-x86_64-elf.S":"e889d6bc0db5869c1359f0bed84d91614b2d3330988bbc0ebcff72808d260323","pregenerated/sha512-x86_64-macosx.S":"8ee8ec092ea57468502c5258984af591a1282d3798b57167eabcd7ccda0533bb","pregenerated/sha512-x86_64-nasm.asm":"0fd51c71f669d6d2a494ae51367186861ad792cc7d65c7483df8f36f32bdfdc3","pregenerated/sha512-x86_64-nasm.o":"8c86c34b61f998ca12715d2c0bcf0c08c23151eb5b16bb8d3c9eaa176f9a94db","pregenerated/vpaes-armv7-linux32.S":"a3af46145ebddac13fe162036cc0f0fd3deb6987e6490696246b30225dc11465","pregenerated/vpaes-armv8-ios64.S":"0c412df12f904ed43c4b24757a5f7eda8e9b00e0907cdba39827f5732b98b601","pregenerated/vpaes-armv8-linux64.S":"209b2cdebf5e089464b94ab7ab1be400554c6d4fc35b29780b9804cc471a78bb","pregenerated/vpaes-armv8-win64.S":"be78de61a0ef56199bc06854fdb66aa10e56f8fc20fe2bd161370dd664540f44","pregenerated/vpaes-x86-elf.S":"6d94acc7d3d5f01487013b41de7aa41253fb99b9e361f3e87d98ff817a7fc149","pregenerated/vpaes-x86-win32n.asm":"013818ac89c025d22b0751936305b45b80134e52751d56d07067372e84140dd9","pregenerated/vpaes-x86-win32n.o":"ef8114349f6eeab746ece2b5b36ca3f524ed3f0db69aa41e830460c372e21309","pregenerated/vpaes-x86_64-elf.S":"60454d53ea8327b7c108d2aab34b7ebf7ebf45e0a29dae35de71269a66c413a4","pregenerated/vpaes-x86_64-macosx.S":"516501b87fd20f431adc84711fd5016dd6354a6f6fe148eb4289fbd54cdab69c","pregenerated/vpaes-x86_64-nasm.asm":"3b7c31515b6710df4aa0d9309bb34e5fcbe41c4f0957981657aba35757ee03ad","pregenerated/vpaes-x86_64-nasm.o":"c818c028e4b9c9504b67be3979f5eaa35dd39aa7c26549352d77ce26f8967bde","pregenerated/x86-mont-elf.S":"7f9a6d5b6bfe4e31bff5a35962317c477362988175f22bc00fdf17e74e090e81","pregenerated/x86-mont-win32n.asm":"87b0feb4b72f335b264769a427f8e0aaa0e2d916567111d9cf921a070fa83a69","pregenerated/x86-mont-win32n.o":"ec05c30686f1fb3dc152d08bc93e0cebe04255e85e78c19d4915f4227f655916","pregenerated/x86_64-mont-elf.S":"d1165cecfff9a1149b52d2d8b2c7d694410eff60b0b79924c7d0d8fbfd74e87c","pregenerated/x86_64-mont-macosx.S":"515b34f31c9ad708bfb713a135708d92f15ed1d70d0444e3a57e50d875d2903b","pregenerated/x86_64-mont-nasm.asm":"950359c7e69862945127907885736b81e0809474b08482c7306ed5b3991ab321","pregenerated/x86_64-mont-nasm.o":"4bad2df173975ec987f2e932e4239bc7de02be4cc8b22f7e343d066bfae59787","pregenerated/x86_64-mont5-elf.S":"ec65bcb5ee82195f865987311cee6d67364606596fe9a29fa70989ad93f2c6c1","pregenerated/x86_64-mont5-macosx.S":"4c5cf549b0e85190377f53dcdd06bcc8efa70652111e9c7f6c41084c7cdb63e0","pregenerated/x86_64-mont5-nasm.asm":"1bf17c38bbb5e7ffa4e72a80d2fcf84c0c9ecf5bb7756c516d4aa3f8fc96b408","pregenerated/x86_64-mont5-nasm.o":"704a8637afb3536feaa3c9318d0be653e7f266c38e027e7a29ed7f3096b90103","src/aead.rs":"3ab890b8f5b1cfb0ac103af11294cbfd0937b8da3984067f5510b96807447f34","src/aead/aes.rs":"e5bf1a294dd56a76c35e8abc04e2247120faba621a069f75481265c87e23e659","src/aead/aes/bs.rs":"d49208534364fe2709fe93e89b61b41c24b0ef9d8608913eb9eaa5645287fc2a","src/aead/aes/fallback.rs":"076bee7436fb45d7fbe253eddad9f2ce3f8fde1a9f61488b45896b6b44c46e27","src/aead/aes/ffi.rs":"0564eb9dcc404785966f564a4c543284ceabc5f13da16048dd277b6eeb907940","src/aead/aes/hw.rs":"17cae15c3312f4b2744427ce79faadc7bf49bbd6815431a44d613a7e5db378eb","src/aead/aes/vp.rs":"13f0dac67774f6d6ddfe566e501781205be1ce93f33c58a14cc31ee19305743d","src/aead/aes_gcm.rs":"c2465f43aec314e1058acde919ffe19243701c8faf5577c54642921c31238753","src/aead/aes_gcm/aarch64.rs":"d184e191ba37c54c2a40b3777a967b978dbb1c18f5463e9a9408d492cbf7d509","src/aead/aes_gcm/aeshwclmulmovbe.rs":"6e97098b85def1877305106ad8258ce59c621894e1aeb91be57b8657b0701a27","src/aead/aes_gcm/vaesclmulavx2.rs":"a23a07aaaa9a24a56f6025f52f41f46903e230b32338494f7b516458b2708bc5","src/aead/algorithm.rs":"13c846f8a3ef11282e459fa4753d1dbdf5d4956ee7d152b71dfb8b3997c47284","src/aead/chacha.rs":"bbb8f137622eda811404cd97fb6358c570c583ec21dc4b5406b2d56a23bd7aca","src/aead/chacha/fallback.rs":"79c47ffa53a1450ef79cc311998998fb2d1785658ded656e85ef58a3621fc68a","src/aead/chacha/ffi.rs":"c54cbbe8ec3844354c5e72098d469936b35976afcd20a30c91c34c2851f32810","src/aead/chacha20_poly1305/integrated.rs":"ba73dc41cac0f2cbe240512b352c8b099de5ba2dd4bc94e4207042e67f691343","src/aead/chacha20_poly1305/mod.rs":"0c5a86b632fd04d77a85bfa5765a2c95aaeb6ceb83fff2723ae6d721213eae75","src/aead/chacha20_poly1305_openssh.rs":"e42352357c56b4503f4f9ca413755aab409c8fb8b2855557217022ed8073e71e","src/aead/gcm.rs":"0dc7633c5c3ef3c820ab7de0f97e31807b3153edc61ddc2c3922650158635c67","src/aead/gcm/clmul.rs":"3df31a8108c577e40c60ba0c4981bb97f70b78b79ceb0432bbe86ed7a292bea2","src/aead/gcm/clmulavxmovbe.rs":"6c5463930685c75092fa243d95a9a65e5b8da324fc494da514c58d727d266c9f","src/aead/gcm/fallback.rs":"610754d15ee05925f4f606aba5c7bca88408e7fb2fce3ec9cfb27f7191be5870","src/aead/gcm/ffi.rs":"a7cae8a54fc481cd56aee9bff6152e4173514c71aeea21aac2d8c9913a9ece56","src/aead/gcm/neon.rs":"b7d494799be27667f9ff278d1a00da7f918a79c23fce64c8116f5d15dcb38bea","src/aead/gcm/vclmulavx2.rs":"f8c79a602e597f4e81f248144d8598a37d1fbdb7ed460451ac3a47f9837dd8bc","src/aead/less_safe_key.rs":"466cc41a383dccc09ff37e9ca8bf212061563077a9b418f8f9a31ac30e5c8a58","src/aead/nonce.rs":"0d69b0932b2c58b9c3eb26ac9f19ac32ae78dbd6bd1715212fc0913288c6cfa5","src/aead/opening_key.rs":"e10478d923954b412c0b35ae12b4822c8b6369f7dd638593e04d48cca5d4031c","src/aead/overlapping/array.rs":"84f60b35b871fbb9a9276ad2485e935176404ef0cb5af03a641bad6613e8e8f9","src/aead/overlapping/base.rs":"1e7c185eb70e68809803206afe896f208064d5e8f40d5332fe756d81efc03bdd","src/aead/overlapping/mod.rs":"834affb61a8d930b5d05924330239bf783ab65170b8158f88c8fe30e680f712b","src/aead/overlapping/partial_block.rs":"b0f51b1dbc12a69080b8c6fbe145be558e7c9b54260d0b652b0bb344f1c22960","src/aead/poly1305.rs":"a4384e740d49b36c568a604d56082db6476715c31154c538d4e8388032e84cc8","src/aead/poly1305/ffi_arm_neon.rs":"66b81d9ce04b938b1ca0fe53d6afb97e36afe99f0331db231f4566ed0824b7da","src/aead/poly1305/ffi_fallback.rs":"85d27d274e05e48fd9136f0435b9b72957514f1dd724b3640176b8f4464fd155","src/aead/poly1305_test.txt":"3ce56f041cf95692d817dfaeee443dccd5df8ace7607e7a331b3fa102c9a8163","src/aead/quic.rs":"4d693d37accfa65ff234c36a0539ffa20fbff836898849579c9e21d12cc2023f","src/aead/sealing_key.rs":"021498d2a033dd68f296f59096485747dd40321d0f63a2e58f5f74c8756e3349","src/aead/shift.rs":"1b4c9fda2a6f4d3e195e5617b9a2505fccb503b39ed61e47abaf2023ce3b6a98","src/aead/unbound_key.rs":"e9f60b4c3e2016149b1efec757f81901f9a52388840884791b8b4d14bab1522f","src/agreement.rs":"722149657fb2a751eae72e0db7365ce2a106625a19a696e8db016ae319eafa30","src/arithmetic.rs":"a7b23bf9fdf3b5694801881e820355f0228c18f73ade007fe3f2b7464882e1cc","src/arithmetic/bigint.rs":"93be01c470baee8d0406df36e1bb7ce70b859c9054516a55386f803c72fee316","src/arithmetic/bigint/boxed_limbs.rs":"050b0452e9160b79234ab7b0a59db4f15c616c26f75fc44a69fab3fce72bbfb9","src/arithmetic/bigint/modulus.rs":"8431d0a7d33f1eb15b1bff304d4ded9e5f3c73fa0903ef388e910e51e1f57083","src/arithmetic/bigint/modulusvalue.rs":"95bc2e449275f9dc28e9e89c16445eb9c31755ce3e78c246aa7c74f78668c73a","src/arithmetic/bigint/private_exponent.rs":"c6ad25a3fe83d2413b569390ee1ceda2f354f2fce9f5ae21c2f691f6da565573","src/arithmetic/constant.rs":"9b735f14c1a58140288c44473e181b2b3014d0d39c6dcd3953744386e9cdc951","src/arithmetic/ffi.rs":"0e77868394524318d11b59e28e9390aae9c95e5a24f09367b98839bb832376d5","src/arithmetic/inout.rs":"c471a61a77e8b207c2a7f3ff1477327690a1cbcc978eccf9b009e39dc0c28d4c","src/arithmetic/limbs/aarch64/mod.rs":"2c1631c98c8ff5a32973327f5ab1122ee5692088c529bc893de281113a088adb","src/arithmetic/limbs/aarch64/mont.rs":"7794ab95ddf21006727e2261cd4fe4f360df57086b8f62216635e2de811775a6","src/arithmetic/limbs/mod.rs":"2613bdbadb258d99633a16a66218d42ec4527e0ed98c58e3f16b91dfb3e9e1c0","src/arithmetic/limbs/x86_64/mod.rs":"d371541e71a20753361ddafc0c52efe955ddccd2b726d6e3462887a31e7d9ccd","src/arithmetic/limbs/x86_64/mont.rs":"71a42222db9aff7c753fa96eb66668773bf48ab06f1696acd3abdc4147525810","src/arithmetic/limbs512/mod.rs":"0caed62cd744cf1a33ddd3ea42f601e95379426cdb2de31efedf3fa7cac37cf1","src/arithmetic/limbs512/storage.rs":"6130083783569f7f087418fb27f93a0fbb34c8800a25cdfd311c43be35d42eb8","src/arithmetic/montgomery.rs":"4b3b356e5dd6f516e4d0eac4f209ad8abc4bea9933e1fe26048f0212f2610fd9","src/arithmetic/n0.rs":"209b3cb860fcf5ee59ce3bd9796e0c1efd05b46fda5dab4930ccf892d5234472","src/bb/boolmask.rs":"5b02c78773d4c9d0a949432f6a13350863aefd8fe764c664be1d62789a93b67c","src/bb/leaky.rs":"16d0723b8fbbb70da312ec9471649de09892892300c428448da90ee8c15c2fd3","src/bb/mod.rs":"79370617c7ffc0158e90eba996c0611ed24ad267e745374db5b99027c97f8263","src/bb/word.rs":"0da05611f144df5e4c37b37a909a6e354e3d0ae1ecacd26b294076f16abb85ca","src/bits.rs":"2bd6a89e52b540822355f324bfa920ef41e017edbb0098c7779a4ca142078361","src/bssl.rs":"b7f0532a4c26e4c212bc59e892f83477999308cca2148231170d4d20411d0a10","src/c.rs":"53e0fbbab6aeb49aeb848ca5a7bdae438aa2b5c3417011ae7df8afb0d6c90285","src/cpu.rs":"d1f255f89aca5261b09af2e3f94a7f808496f0b9698e3f3ef3576d36db82c880","src/cpu/arm.rs":"77749329270ea6451dee43d2c3711826e46c6d7f5b23b8f5095150af4da5e283","src/cpu/arm/darwin.rs":"1dfb1d97999bcfd0c9b3d862078188299e1e27345393c93ddbe340919ebfc128","src/cpu/arm/fuchsia.rs":"7f06891c32e42072951daf15af1c7d05fddd0f3b060de2ee7bf7570a653201cb","src/cpu/arm/linux.rs":"e8b703978790d4a5a3049c537be75054faba192a484751e148a31acb1c809794","src/cpu/arm/windows.rs":"954bec8fe64436cc2af8a907479ce4e7577c315e7ca3a881b7d8024169041917","src/cpu/intel.rs":"ac4d6e8e73888780f491b012d986e9f092d502b758b6ba737145d9bc326e176f","src/data/alg-rsa-encryption.der":"7bc023427767a2f2e156f8ae030d06d19f862e326b952116649b423c3ff7110e","src/debug.rs":"9d0b5cdf0fbf2f18fa5a42c8916e30f93cf9881e5a1a0b8eb1b676e35dbafbe0","src/deprecated_constant_time.rs":"440c891a53710f32659e05bf9b68fb81674aca8fabed6cd590a7a03782161255","src/deprecated_test.rs":"fb892117eac31c8cb535f2384221049241d1071b52392eda8ee0c225140e3dc8","src/digest.rs":"61c7d3e3c96acb835a95f502b025b6e338df959b59953ceb6c4e4ffe0d665ed4","src/digest/dynstate.rs":"bed9e30f725afe88f5b92cfba4f803fffb01d167043e2600f0bbfc29589e688a","src/digest/sha1.rs":"9b5218444ee1268be006b853bc5994d8221c52243a3a2ffedbd37c60f6540290","src/digest/sha2/fallback.rs":"08a591d4d9cf1f8d39f92d5e5b180877dae8a7f023c8852f60c04c3c925526b7","src/digest/sha2/ffi.rs":"9e9213806c6cc6d045ad86289c052e5a6f16fa95ced01cc97613d15374c99264","src/digest/sha2/mod.rs":"a00f81158f7fcb1c5e46503512eaecc32f9c67b6a6f60235c0a906756d1d0fd8","src/digest/sha2/sha2_32.rs":"b1b889257ac23508d68addfc628e929f70139b6418cfdbee63a18930061db7a9","src/digest/sha2/sha2_64.rs":"c58467a3aea41c3f3a71069bbc5094e8785ba6730af049304d9f268983ed04f9","src/ec.rs":"f42524befe800fd42bdaa39db02b140862155ead1f12b8bf98a909f438064d29","src/ec/curve25519.rs":"01b7f21eb84b2bf3e21f20f0dca2a5def2e28bf8cd13b995630fa6667c53694b","src/ec/curve25519/ed25519.rs":"7283a6f5f6a7a69f3a3e3e862ab81b9da49a9a03c3607a167500f3f9ab698a14","src/ec/curve25519/ed25519/ed25519_pkcs8_v2_template.der":"b209940853a4d88930cf2a12d18dd6823de256cd30303676ba1be07475cc83b8","src/ec/curve25519/ed25519/signing.rs":"5f5504a259544e214baff8501ffaec3bb3c84d8ca50a9b56f61c86432860ab9b","src/ec/curve25519/ed25519/verification.rs":"bf62e085396b5ff7145e119438d6ee95156532c9fc3ad79006639dfded21c363","src/ec/curve25519/ops.rs":"2335c1bee550a554f89d2b678016faaf56b612131f1ab96f3c5f976053cf4c42","src/ec/curve25519/scalar.rs":"4f85537a03be7aab683a6d88f21dc9730301a487f73ab7c21c539db0fd7b36ef","src/ec/curve25519/x25519.rs":"c4f96494f8b13be029b11999d6492d7722098f931de98e28dad258d6a9f8c217","src/ec/keys.rs":"f62856f32e5f11984cf47836cf553b75479cc91dcdbd5b4feba83669c24477f4","src/ec/suite_b.rs":"87f1363af0c7bf5c4bf27887c91ff5f1f0a4fe8023ecca19ca860c0df5467e9d","src/ec/suite_b/curve.rs":"6706a1eedf5e5f3fb2ab48adf13c469fa8dd2910ff093114d979ddc63b8ee7d3","src/ec/suite_b/ecdh.rs":"7ec7a0ce7273a7f1e6d1f19a5e380c0a796d147282257d615f208d8bf881e3fd","src/ec/suite_b/ecdsa.rs":"013e0d2d2a21eb437253b03a1f6a1a4ba8c45eb1c2ea1396696bdd04a8ed2932","src/ec/suite_b/ecdsa/digest_scalar.rs":"52b29823ab57d95be812c8a9e66fb484206db968dc41171d3ea9c16edd8bb42d","src/ec/suite_b/ecdsa/ecPublicKey_p256_pkcs8_v1_template.der":"5a2207da0199ebe3e2a80e15e7692b21f215f855ed3bd2c51f466c7969e11990","src/ec/suite_b/ecdsa/ecPublicKey_p384_pkcs8_v1_template.der":"5ec14cd6aac17cec849382ee5e2077497f98ce435d7aee2116cd092bf84f5556","src/ec/suite_b/ecdsa/signing.rs":"aa8cdb16f345b978d99cc49110ac912243e14f141eb9ac39db893001428b4973","src/ec/suite_b/ecdsa/verification.rs":"5fe68bb7544ec714a297eb6d988593261a0e09e2f25d9e39dd048b7de7b786b5","src/ec/suite_b/ops.rs":"94eea4550debdcf3d4f5e81d30c1f9611d1f6b8c95fa4a4f847238a23a19c7a0","src/ec/suite_b/ops/elem.rs":"2c3eabcb0e757365ed8a6f10609999f593d71511e2e45cb3fbaa158d210deea8","src/ec/suite_b/ops/p256.rs":"6d330c184991e37620befe4e1026e079dfa5adf1124fd3860a37c2b9c724bd3c","src/ec/suite_b/ops/p384.rs":"d7a6199cd7f628f367876b98f5d7cbfad7bde3b76848a88a8b0973e710a8dc4a","src/ec/suite_b/private_key.rs":"433f500061f0c84b7da8d2b3bb68e0d3e0f3b4edf816602d86004cf731024166","src/ec/suite_b/public_key.rs":"06cc0d9b29327a1811d4e426059da091204028e32a8555d61de5a1504daf815b","src/error/input_too_long.rs":"92e017287e098cee62a85154be89616cfcb9a345c2725ec707291ca6908154e4","src/error/into_unspecified.rs":"11e186cc07b445d008b539216235e29e433e2a319b228c772c7d2fb19c67c488","src/error/key_rejected.rs":"3ca151a8c5e41b5b5927e0b0f82333e0809959ac0394f35890cbddf067bec696","src/error/mod.rs":"98a500cd5cdd70ee02a226e94b42ba25ead9d87adbd80d1104bedb2c58eb1ccd","src/error/unspecified.rs":"73a08184a94348fec1f98711698f3213160d1375dc6885a00d7d803386d663df","src/hkdf.rs":"99814b71f98ed72647aef37de1a4d548748dbf53656b72cee4603d8ea25ce6b2","src/hmac.rs":"f5b8b24f38aad01e6e2fd780c4671e42cc1f6bd7f4391581c61e84830739419b","src/io.rs":"b1b5060b07ca97130a752d3fb7e4a3fb7231bec3526e656c87fe8c028190ffd4","src/io/der.rs":"6c331a036ed26d908cef501c1c407750f931653e8cf3b16246d3181e2ea9ac05","src/io/der_writer.rs":"6d6b566436cfc40acfb00f752916514023bc489da9be3466d7e1fd1233946529","src/io/positive.rs":"7e34bbce3101acc22b5ece974fc787df344fbefa1c9df9ba6fc8d865c89bf9e4","src/io/writer.rs":"be71e57228f8881cc88cae3d2f616dc864d6e730c8a435ec3e59a1e4e7272457","src/lib.rs":"4ae5eb75aecf1b7b7aaa4a9f37a45c9f7fd803fc4423025eaf788902581cd1f4","src/limb.rs":"a7542a645f31c0887f46b99a31b71da5c82e448b5671cfb19fe8264a955b08b8","src/pbkdf2.rs":"bb6696fc0a42ea6154b8a8d15fc51a6132d00dc1347e81cec2c44ecd64cc5f6f","src/pkcs8.rs":"0719fd0997971e6b8685dcf6c4d13e19ab78ea6a270f3c7ac7243c550530c561","src/polyfill.rs":"5b997cc66f4cf98fe1e9b5cc20209cfc93bb17ac76b206e021287ee94dd7e726","src/polyfill/array_flat_map.rs":"cb1c69113132e84b7a59a999ccbed2815d9a8ea8173eccbb07c709265beb1da2","src/polyfill/array_split_map.rs":"2c2fd0d1a5cac384c58a1ed06c6f33032decbeb5da5da1428e2853522b4e2da0","src/polyfill/cold_error.rs":"fa99fb2207f02a6354be4d0729dc111a0dfe1882c9fc602e83206a8e796e478f","src/polyfill/cstr.rs":"884d91799403cd5a3894109b89313c86b11f9a7f621faca1327b047760280123","src/polyfill/leading_zeros_skipped.rs":"4a505dc28cad0b5718fe0f2a74b8f79de1bc78cc49c2bf1f65b8e7e3eaad7489","src/polyfill/notsend.rs":"cd2fe976858de450b255afb63e95620d023828b60d1d57619be3c58e188551bc","src/polyfill/once_cell/LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","src/polyfill/once_cell/LICENSE-MIT":"6ee2ed6c77710de911761acd5fc1ad1da00f476beb1a7ef27e78c2d1858deafc","src/polyfill/once_cell/race.rs":"486c98b50b9db775178faaf6a80748ea06805f93987aabd79c6a453c775fbc10","src/polyfill/ptr.rs":"f968c293be424b923cba2b82a8ad415d441a732fcef177a0114e3d2a949df52d","src/polyfill/slice.rs":"491810bd2e2e3e933db93d24bc8ae78b381a3d6931ecb783173cfb34edc14edd","src/polyfill/slice/as_chunks.rs":"1954d6ce641789745228ed1a78016e4d3aac879f09221232aa68398f280fea40","src/polyfill/slice/as_chunks_mut.rs":"4d07ad9b0d5ea18771435bbe20ab9c07a03c7dec9ec550eb16e4b96afd257780","src/polyfill/sliceutil.rs":"ee91dae6c2c1a8af1165d4e9ec429bc59b5d1688d0473f12c1bbe89d72a6880d","src/polyfill/test.rs":"38312699139268c9fc35f7d5ead73b118a79a471f6575da4b8a59efbf84eead7","src/polyfill/unwrap_const.rs":"658081fd2d7cf6f6d3b6a75c61fd56b0d61508d1b26ce403f7b10e1ac68cdcbe","src/prefixed.rs":"affcb8d80b9548f3f1d6a93d9460732dfb701627dda6274de7a8d07274bb02dc","src/rand.rs":"fb8708fe62706fe7f7c7aad5f7df9f65ca19def5fabac9616375e9f1e532f4b8","src/rsa.rs":"fe62407793ae487d663404dfe5642a7d4e8bc86db4ae70538781d35ea5626cf0","src/rsa/keypair.rs":"b241467ef86cb3b050ea5b7f86f8fd3ac65cafcadeac09b021b8dd213636dfd5","src/rsa/keypair_components.rs":"b3ce592439de54153b89c80e86165e8405f86c710e283d456b8cd5da5ad6ac65","src/rsa/padding.rs":"86d79319fb7b10ef477a59faa9bb984adf9aaaa3379197f5ec2cc62c623a595c","src/rsa/padding/pkcs1.rs":"6e2e7d808c09f680f7c64d51ef0bacf6cdaa47173a74e7efa9a67b6d978a35d6","src/rsa/padding/pss.rs":"8e662863f6fc1249fcaecdb9114d9fabfb4d1604a4ee9a8783a818b11c6528af","src/rsa/public_exponent.rs":"e49a90b89b806322329a6fff85fee5c81c4ff7ee3b1e896ece0db0be9a35a2f8","src/rsa/public_key.rs":"94a6509d394468984d7ae6d1fe3847267b646659177effe63fbbd12635df3302","src/rsa/public_key_components.rs":"18b9aa8cb25282b71b4380ebe8d4ebe5f269049703b1d8cb085a03ec64530740","src/rsa/public_modulus.rs":"6b26971c63a5bd3762e52775d769098d915e2116f091a9b6347a0bd3e8a90a9d","src/rsa/signature_rsa_example_private_key.der":"5344d57f719a98c4464aed1d1c2fa569f0a9de8621c6fdec7d28923a0e1c662c","src/rsa/signature_rsa_example_public_key.der":"28b0a357936485bd2a7776321cccfe17c2347f2bb75751ddf9dfc6429cacb6f1","src/rsa/verification.rs":"13ee4085cea16f434ef1b4e2b1bf623ef3095cef3a0edf2b3c99329bd7301b28","src/signature.rs":"1bb8408e6dfe2da73847016cd1b78bc8352e85a80e7bb55d5edb54e8178d1a13","src/tests/bits_tests.rs":"aa497cc7b103190d4d47466f0f43baf8e86bf28885cd0add0e6a94575b4628bd","src/tests/mod.rs":"2c5791daa813a98bf2aa54bef5263738356784a8db0923550bf29e7b07e71ca1","src/testutil.rs":"b971d1cfe1a3966d3715e565c355ca6b13c3269f862474136cf5b41157972eea","tests/aead_tests.rs":"e7b8e716b46b7951671c4376d1dd7693415060c66584e39940ef73899bd1bcde","tests/agreement_tests.rs":"a84b6dc536f153e75d12e0c52ed303fef80fbb9a62aedacca4f49a92c36a4779","tests/constant_time_tests.rs":"3e83d78368187120f39d857179cb6766374a38e5f6c93c74367373512b9a6682","tests/digest_tests.rs":"68d1acab03e0ecc7fae9334518192a43778715dee850c15e3915b5efb2b4abe4","tests/ecdsa_test_private_key_p256.p8":"d56f99994233d749d03315f5cb9797fad81d3e25f962d2cd543d4dfe7cdd1389","tests/ecdsa_test_public_key_p256.der":"93c930878dc29d802b151bf492a2f00672b2240b740002a650ccb706664d10c9","tests/ecdsa_test_public_key_p256_debug.txt":"ccce94ab37a5e5286f0e5f1934bdeb39539e8f72bc7ccd0a1f666c9a1abc0bdb","tests/ecdsa_tests.rs":"b9c0803f76e6728610d6a81aa587c48cc554d509b46440ef13ec053577b5c654","tests/ed25519_test_private_key.bin":"644d50ab64864c20a12b3c4656d46b4a48f69ef7c47ecdc8415cd28316b22ef5","tests/ed25519_test_private_key.p8":"8a5217b181c3096224275c3fedcfc938e54aee073114314cbc1a9cedfacce3b8","tests/ed25519_test_public_key.bin":"21fe31dfa154a261626bf854046fd2271b7bed4b6abe45aa58877ef47f9721b9","tests/ed25519_test_public_key.der":"119e5ed7b8533bdf24897f07fe4dd57671a64f8d10534ba128c9bb016af86484","tests/ed25519_tests.rs":"53786031eff672e7cf0e392f7114e4d217ecb0091a40c1da265e01ccc5be2d85","tests/error_tests.rs":"2af7ccf5b9e7a72720453376c97c2308145ca12f657dffec7030a4fc21fef9d9","tests/hkdf_tests.rs":"877a614d2d771c21ded679afc56c599b40bf97b34aecbbd7245fb1b893c35a6d","tests/hmac_tests.rs":"62a726139d1a9d366ce131ba11b3c53e24e95c6f783f1c48038acd2759b29e7a","tests/pbkdf2_tests.rs":"752fc51008ea34f2d6fb7e2e50aa1aaca72e7c4cf5238c96a0834ebdf2fbfae7","tests/quic_tests.rs":"6dfee0d9d8453918410685271e2b2df175d18cf234b29254db8132cad6654440","tests/rand_tests.rs":"666846d3c2b7c678b2848fd36609c3f3c60bd8bb03a78107e7a5ec781042ff63","tests/rsa_test_private_key_2048.p8":"a0d95a0b133b4c217bc11322b67d62eb13537b8a9f66e20b5c9b5ac31af21859","tests/rsa_test_public_key_2048.der":"7180acb59312d3544c3b36975ae6c4c55f59035ce4de487852cf6c99b33868cd","tests/rsa_test_public_key_2048_debug.txt":"dc471e4ca8c1ef4b57d2ce79c9b9ba25ab9e262ed63a24d2b65cb2d2f3797ffd","tests/rsa_test_public_modulus.bin":"a564c096055103ddd882641e3cb22c849b202a8a1bd646001451bb52b9ec7fd3","tests/rsa_tests.rs":"b01ce5b39d53e460771063372b4bc1ae107755fab348dd40b762a127b377f1be","tests/signature_tests.rs":"eb62f44403dc635889a9ed4c96d546abac7903a7235082abde45bb1dd2906273","third_party/fiat/LICENSE":"9eacbcb81be660840c714a560a9d65ba07913db98dd4baf969f78dd499fdd60f","third_party/fiat/asm/fiat_curve25519_adx_mul.S":"98dc96d4d48c8c8c533cb81456e5e543e1f54cc3523de8dda991da599a9fc6ec","third_party/fiat/asm/fiat_curve25519_adx_square.S":"1303960a7bc3af812f039a708a852daf36d5b5f1c1d177f4ddff5d7da22323d1","third_party/fiat/curve25519_32.h":"7a0cf7a38603186c95a90e5b3a0faa6175b9217f1a06ea1e4040dee6153da68f","third_party/fiat/curve25519_64.h":"667579239122a91d03f3add822c8b81a08df30212fa5ff86b5de9a77f134096f","third_party/fiat/curve25519_64_adx.h":"a337e02d9838e43ae89bb402382f7349d82aa72ee883527a2ea5abbcb07e7768","third_party/fiat/curve25519_64_msvc.h":"d65f92642124d6f0e45950845aed6194fb299e0c69a95109744c5a5d29d133dc","third_party/fiat/p256_32.h":"0078a1d7723f9707a35488e14fad497514b482df3af368ef908bd79dbbf5dd83","third_party/fiat/p256_64.h":"c5f54bc513da6de13cfec3334ed095786a46ca25352a5e038437095157c4aa03","third_party/fiat/p256_64_msvc.h":"5a36a2b959c2b68ac7f197f472bee55d58f7ec58dda6c226f565d6bd721dbeda"},"package":"a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7"} \ No newline at end of file diff --git a/http/vendor/ring/.cargo_vcs_info.json b/http/vendor/ring/.cargo_vcs_info.json new file mode 100644 index 0000000..9361bf9 --- /dev/null +++ b/http/vendor/ring/.cargo_vcs_info.json @@ -0,0 +1,7 @@ +{ + "git": { + "sha1": "2723abbca9e83347d82b056d5b239c6604f786df", + "dirty": true + }, + "path_in_vcs": "" +} \ No newline at end of file diff --git a/http/vendor/ring/Cargo.lock b/http/vendor/ring/Cargo.lock new file mode 100644 index 0000000..7ca88ee --- /dev/null +++ b/http/vendor/ring/Cargo.lock @@ -0,0 +1,361 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "bumpalo" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c59e7af012c713f529e7a3ee57ce9b31ddd858d4b512923602f74608b009631" + +[[package]] +name = "cc" +version = "1.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7777341816418c02e033934a09f20dc0ccaf65a5201ef8a450ae0105a573fda" +dependencies = [ + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "js-sys" +version = "0.3.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a865e038f7f6ed956f788f0d7d60c541fff74c7bd74272c5d4cf15c63743e705" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "libc" +version = "0.2.169" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" + +[[package]] +name = "log" +version = "0.4.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" + +[[package]] +name = "minicov" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f27fe9f1cc3c22e1687f9446c2083c4c5fc7f0bcf1c7a86bdbded14985895b4b" +dependencies = [ + "cc", + "walkdir", +] + +[[package]] +name = "once_cell" +version = "1.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e" + +[[package]] +name = "proc-macro2" +version = "1.0.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "ring" +version = "0.17.14" +dependencies = [ + "cc", + "cfg-if", + "getrandom", + "libc", + "untrusted", + "wasm-bindgen-test", + "windows-sys 0.52.0", +] + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "syn" +version = "2.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.97" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d15e63b4482863c109d70a7b8706c1e364eb6ea449b201a76c5b89cedcec2d5c" +dependencies = [ + "cfg-if", + "once_cell", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.97" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d36ef12e3aaca16ddd3f67922bc63e48e953f126de60bd33ccc0101ef9998cd" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dfaf8f50e5f293737ee323940c7d8b08a66a95a419223d9f41610ca08b0833d" +dependencies = [ + "cfg-if", + "js-sys", + "once_cell", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.97" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "705440e08b42d3e4b36de7d66c944be628d579796b8090bfa3471478a2260051" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.97" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98c9ae5a76e46f4deecd0f0255cc223cfa18dc9b261213b8aa0c7b36f61b3f1d" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.97" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ee99da9c5ba11bd675621338ef6fa52296b76b83305e9b6e5c77d4c286d6d49" + +[[package]] +name = "wasm-bindgen-test" +version = "0.3.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d919bb60ebcecb9160afee6c71b43a58a4f0517a2de0054cd050d02cec08201" +dependencies = [ + "js-sys", + "minicov", + "once_cell", + "scoped-tls", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-bindgen-test-macro", +] + +[[package]] +name = "wasm-bindgen-test-macro" +version = "0.3.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "222ebde6ea87fbfa6bdd2e9f1fd8a91d60aee5db68792632176c4e16a74fc7d8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "web-sys" +version = "0.3.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a98bc3c33f0fe7e59ad7cd041b89034fa82a7c2d4365ca538dda6cdaf513863c" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "winapi-util" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +dependencies = [ + "windows-sys 0.59.0", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/http/vendor/ring/Cargo.toml b/http/vendor/ring/Cargo.toml new file mode 100644 index 0000000..f445e18 --- /dev/null +++ b/http/vendor/ring/Cargo.toml @@ -0,0 +1,294 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies. +# +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. + +[package] +edition = "2021" +rust-version = "1.66.0" +name = "ring" +version = "0.17.14" +build = "build.rs" +links = "ring_core_0_17_14_" +include = [ + "LICENSE", + "LICENSE-other-bits", + "LICENSE-BoringSSL", + "src/polyfill/once_cell/LICENSE-APACHE", + "src/polyfill/once_cell/LICENSE-MIT", + "Cargo.toml", + "pregenerated/*", + "benches/*.rs", + "build.rs", + "crypto/chacha/asm/chacha-armv4.pl", + "crypto/chacha/asm/chacha-armv8.pl", + "crypto/chacha/asm/chacha-x86.pl", + "crypto/chacha/asm/chacha-x86_64.pl", + "crypto/constant_time_test.c", + "crypto/cpu_intel.c", + "crypto/crypto.c", + "crypto/curve25519/asm/x25519-asm-arm.S", + "crypto/curve25519/curve25519.c", + "crypto/curve25519/curve25519_64_adx.c", + "crypto/curve25519/curve25519_tables.h", + "crypto/curve25519/internal.h", + "crypto/fipsmodule/aes/aes_nohw.c", + "crypto/fipsmodule/aes/asm/aes-gcm-avx2-x86_64.pl", + "crypto/fipsmodule/aes/asm/aesni-x86.pl", + "crypto/fipsmodule/aes/asm/aesni-gcm-x86_64.pl", + "crypto/fipsmodule/aes/asm/aesni-x86_64.pl", + "crypto/fipsmodule/aes/asm/aesv8-armx.pl", + "crypto/fipsmodule/aes/asm/aesv8-gcm-armv8.pl", + "crypto/fipsmodule/aes/asm/ghash-armv4.pl", + "crypto/fipsmodule/aes/asm/ghash-neon-armv8.pl", + "crypto/fipsmodule/aes/asm/ghash-x86.pl", + "crypto/fipsmodule/aes/asm/ghash-x86_64.pl", + "crypto/fipsmodule/aes/asm/ghashv8-armx.pl", + "crypto/fipsmodule/aes/asm/bsaes-armv7.pl", + "crypto/fipsmodule/aes/asm/bsaes-x86_64.pl", + "crypto/fipsmodule/aes/asm/vsaes-armv7.pl", + "crypto/fipsmodule/aes/asm/vpaes-armv7.pl", + "crypto/fipsmodule/aes/asm/vpaes-armv8.pl", + "crypto/fipsmodule/aes/asm/vpaes-x86.pl", + "crypto/fipsmodule/aes/asm/vpaes-x86_64.pl", + "crypto/fipsmodule/bn/asm/armv4-mont.pl", + "crypto/fipsmodule/bn/asm/armv8-mont.pl", + "crypto/fipsmodule/bn/asm/x86-mont.pl", + "crypto/fipsmodule/bn/asm/x86_64-mont.pl", + "crypto/fipsmodule/bn/asm/x86_64-mont5.pl", + "crypto/fipsmodule/bn/internal.h", + "crypto/fipsmodule/bn/montgomery.c", + "crypto/fipsmodule/bn/montgomery_inv.c", + "crypto/fipsmodule/ec/asm/p256-armv8-asm.pl", + "crypto/fipsmodule/ec/asm/p256-x86_64-asm.pl", + "crypto/fipsmodule/ec/ecp_nistz.c", + "crypto/fipsmodule/ec/ecp_nistz.h", + "crypto/fipsmodule/ec/ecp_nistz384.h", + "crypto/fipsmodule/ec/ecp_nistz384.inl", + "crypto/fipsmodule/ec/gfp_p256.c", + "crypto/fipsmodule/ec/gfp_p384.c", + "crypto/fipsmodule/ec/p256.c", + "crypto/fipsmodule/ec/p256-nistz-table.h", + "crypto/fipsmodule/ec/p256-nistz.c", + "crypto/fipsmodule/ec/p256-nistz.h", + "crypto/fipsmodule/ec/p256_shared.h", + "crypto/fipsmodule/ec/p256_table.h", + "crypto/fipsmodule/ec/util.h", + "crypto/fipsmodule/ecdsa/ecdsa_verify_tests.txt", + "crypto/fipsmodule/sha/asm/sha256-armv4.pl", + "crypto/fipsmodule/sha/asm/sha512-armv4.pl", + "crypto/fipsmodule/sha/asm/sha512-armv8.pl", + "crypto/fipsmodule/sha/asm/sha512-x86_64.pl", + "crypto/internal.h", + "crypto/limbs/limbs.c", + "crypto/limbs/limbs.h", + "crypto/limbs/limbs.inl", + "crypto/mem.c", + "crypto/perlasm/arm-xlate.pl", + "crypto/perlasm/x86asm.pl", + "crypto/perlasm/x86gas.pl", + "crypto/perlasm/x86nasm.pl", + "crypto/perlasm/x86_64-xlate.pl", + "crypto/poly1305/poly1305.c", + "crypto/poly1305/poly1305_arm.c", + "crypto/poly1305/poly1305_arm_asm.S", + "crypto/cipher/asm/chacha20_poly1305_armv8.pl", + "crypto/cipher/asm/chacha20_poly1305_x86_64.pl", + "examples/**/*.rs", + "include/ring-core/aes.h", + "include/ring-core/asm_base.h", + "include/ring-core/base.h", + "include/ring-core/check.h", + "include/ring-core/mem.h", + "include/ring-core/target.h", + "include/ring-core/type_check.h", + "src/**/*.rs", + "src/aead/poly1305_test.txt", + "src/data/alg-rsa-encryption.der", + "src/ec/curve25519/ed25519/ed25519_pkcs8_v2_template.der", + "src/ec/suite_b/ecdsa/ecPublicKey_p256_pkcs8_v1_template.der", + "src/ec/suite_b/ecdsa/ecPublicKey_p384_pkcs8_v1_template.der", + "src/rsa/signature_rsa_example_private_key.der", + "src/rsa/signature_rsa_example_public_key.der", + "tests/**/*.rs", + "tests/ecdsa_test_private_key_p256.p8", + "tests/ecdsa_test_public_key_p256.der", + "tests/ecdsa_test_public_key_p256_debug.txt", + "tests/ed25519_test_private_key.bin", + "tests/ed25519_test_private_key.p8", + "tests/ed25519_test_public_key.bin", + "tests/ed25519_test_public_key.der", + "tests/rsa_test_private_key_2048.p8", + "tests/rsa_test_public_key_2048.der", + "tests/rsa_test_public_key_2048_debug.txt", + "tests/rsa_test_public_modulus.bin", + "third_party/fiat/asm/fiat_curve25519_adx_mul.S", + "third_party/fiat/asm/fiat_curve25519_adx_square.S", + "third_party/fiat/curve25519_32.h", + "third_party/fiat/curve25519_64.h", + "third_party/fiat/curve25519_64_adx.h", + "third_party/fiat/curve25519_64_msvc.h", + "third_party/fiat/p256_32.h", + "third_party/fiat/p256_64.h", + "third_party/fiat/p256_64_msvc.h", + "third_party/fiat/LICENSE", +] +autolib = false +autobins = false +autoexamples = false +autotests = false +autobenches = false +description = "An experiment." +readme = "README.md" +keywords = [ + "crypto", + "cryptography", + "rand", + "ECC", + "RSA", +] +categories = [ + "cryptography", + "no-std", +] +license = "Apache-2.0 AND ISC" +repository = "https://github.com/briansmith/ring" + +[package.metadata.docs.rs] +all-features = true + +[features] +alloc = [] +default = [ + "alloc", + "dev_urandom_fallback", +] +dev_urandom_fallback = [] +less-safe-getrandom-custom-or-rdrand = [] +less-safe-getrandom-espidf = [] +slow_tests = [] +std = ["alloc"] +test_logging = [] +unstable-testing-arm-no-hw = [] +unstable-testing-arm-no-neon = [] +wasm32_unknown_unknown_js = ["getrandom/js"] + +[lib] +name = "ring" +path = "src/lib.rs" + +[[test]] +name = "aead_tests" +path = "tests/aead_tests.rs" + +[[test]] +name = "agreement_tests" +path = "tests/agreement_tests.rs" + +[[test]] +name = "constant_time_tests" +path = "tests/constant_time_tests.rs" + +[[test]] +name = "digest_tests" +path = "tests/digest_tests.rs" + +[[test]] +name = "ecdsa_tests" +path = "tests/ecdsa_tests.rs" + +[[test]] +name = "ed25519_tests" +path = "tests/ed25519_tests.rs" + +[[test]] +name = "error_tests" +path = "tests/error_tests.rs" + +[[test]] +name = "hkdf_tests" +path = "tests/hkdf_tests.rs" + +[[test]] +name = "hmac_tests" +path = "tests/hmac_tests.rs" + +[[test]] +name = "pbkdf2_tests" +path = "tests/pbkdf2_tests.rs" + +[[test]] +name = "quic_tests" +path = "tests/quic_tests.rs" + +[[test]] +name = "rand_tests" +path = "tests/rand_tests.rs" + +[[test]] +name = "rsa_tests" +path = "tests/rsa_tests.rs" + +[[test]] +name = "signature_tests" +path = "tests/signature_tests.rs" + +[dependencies.cfg-if] +version = "1.0.0" +default-features = false + +[dependencies.getrandom] +version = "0.2.10" + +[dependencies.untrusted] +version = "0.9" + +[build-dependencies.cc] +version = "1.2.8" +default-features = false + +[target.'cfg(all(all(target_arch = "aarch64", target_endian = "little"), target_os = "windows"))'.dependencies.windows-sys] +version = "0.52" +features = [ + "Win32_Foundation", + "Win32_System_Threading", +] + +[target.'cfg(all(all(target_arch = "aarch64", target_endian = "little"), target_vendor = "apple", any(target_os = "ios", target_os = "macos", target_os = "tvos", target_os = "visionos", target_os = "watchos")))'.dependencies.libc] +version = "0.2.155" +default-features = false + +[target.'cfg(all(any(all(target_arch = "aarch64", target_endian = "little"), all(target_arch = "arm", target_endian = "little")), any(target_os = "android", target_os = "linux")))'.dependencies.libc] +version = "0.2.148" +default-features = false + +[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dev-dependencies.wasm-bindgen-test] +version = "0.3.37" +features = ["std"] +default-features = false + +[target.'cfg(any(unix, windows, target_os = "wasi"))'.dev-dependencies.libc] +version = "0.2.148" +default-features = false + +[profile.bench] +opt-level = 3 +lto = true +codegen-units = 1 +debug = 0 +debug-assertions = false +rpath = false + +[profile.release] +opt-level = 3 +lto = true +codegen-units = 1 +debug = 0 +debug-assertions = false +rpath = false diff --git a/http/vendor/ring/Cargo.toml.orig b/http/vendor/ring/Cargo.toml.orig new file mode 100644 index 0000000..8f8da17 --- /dev/null +++ b/http/vendor/ring/Cargo.toml.orig @@ -0,0 +1,226 @@ +[package] +build = "build.rs" +categories = ["cryptography", "no-std"] +description = "An experiment." +edition = "2021" +keywords = ["crypto", "cryptography", "rand", "ECC", "RSA"] +license = "Apache-2.0 AND ISC" +name = "ring" +repository = "https://github.com/briansmith/ring" + +# Keep in sync with .github/workflows/ci.yml ("MSRV") and see the MSRV note +# in cpu/arm.rs. +# 1.66 is required on x86/x86_64 for https://github.com/rust-lang/rust/pull/101861. +rust-version = "1.66.0" + +# Keep in sync with `links` below. +version = "0.17.14" + +# Keep in sync with `version` above. +# +# build.rs verifies that this equals "ring_core_{major}_{minor}_{patch}_{pre}" +# as keeping this in sync with the symbol prefixing is crucial for ensuring +# the safety of multiple versions of *ring* being used in a program. +links = "ring_core_0_17_14_" + +include = [ + "LICENSE", + "LICENSE-other-bits", + "LICENSE-BoringSSL", + "src/polyfill/once_cell/LICENSE-APACHE", + "src/polyfill/once_cell/LICENSE-MIT", + + "Cargo.toml", + + "pregenerated/*", + + "benches/*.rs", + "build.rs", + + "crypto/chacha/asm/chacha-armv4.pl", + "crypto/chacha/asm/chacha-armv8.pl", + "crypto/chacha/asm/chacha-x86.pl", + "crypto/chacha/asm/chacha-x86_64.pl", + "crypto/constant_time_test.c", + "crypto/cpu_intel.c", + "crypto/crypto.c", + "crypto/curve25519/asm/x25519-asm-arm.S", + "crypto/curve25519/curve25519.c", + "crypto/curve25519/curve25519_64_adx.c", + "crypto/curve25519/curve25519_tables.h", + "crypto/curve25519/internal.h", + "crypto/fipsmodule/aes/aes_nohw.c", + "crypto/fipsmodule/aes/asm/aes-gcm-avx2-x86_64.pl", + "crypto/fipsmodule/aes/asm/aesni-x86.pl", + "crypto/fipsmodule/aes/asm/aesni-gcm-x86_64.pl", + "crypto/fipsmodule/aes/asm/aesni-x86_64.pl", + "crypto/fipsmodule/aes/asm/aesv8-armx.pl", + "crypto/fipsmodule/aes/asm/aesv8-gcm-armv8.pl", + "crypto/fipsmodule/aes/asm/ghash-armv4.pl", + "crypto/fipsmodule/aes/asm/ghash-neon-armv8.pl", + "crypto/fipsmodule/aes/asm/ghash-x86.pl", + "crypto/fipsmodule/aes/asm/ghash-x86_64.pl", + "crypto/fipsmodule/aes/asm/ghashv8-armx.pl", + "crypto/fipsmodule/aes/asm/bsaes-armv7.pl", + "crypto/fipsmodule/aes/asm/bsaes-x86_64.pl", + "crypto/fipsmodule/aes/asm/vsaes-armv7.pl", + "crypto/fipsmodule/aes/asm/vpaes-armv7.pl", + "crypto/fipsmodule/aes/asm/vpaes-armv8.pl", + "crypto/fipsmodule/aes/asm/vpaes-x86.pl", + "crypto/fipsmodule/aes/asm/vpaes-x86_64.pl", + "crypto/fipsmodule/bn/asm/armv4-mont.pl", + "crypto/fipsmodule/bn/asm/armv8-mont.pl", + "crypto/fipsmodule/bn/asm/x86-mont.pl", + "crypto/fipsmodule/bn/asm/x86_64-mont.pl", + "crypto/fipsmodule/bn/asm/x86_64-mont5.pl", + "crypto/fipsmodule/bn/internal.h", + "crypto/fipsmodule/bn/montgomery.c", + "crypto/fipsmodule/bn/montgomery_inv.c", + "crypto/fipsmodule/ec/asm/p256-armv8-asm.pl", + "crypto/fipsmodule/ec/asm/p256-x86_64-asm.pl", + "crypto/fipsmodule/ec/ecp_nistz.c", + "crypto/fipsmodule/ec/ecp_nistz.h", + "crypto/fipsmodule/ec/ecp_nistz384.h", + "crypto/fipsmodule/ec/ecp_nistz384.inl", + "crypto/fipsmodule/ec/gfp_p256.c", + "crypto/fipsmodule/ec/gfp_p384.c", + "crypto/fipsmodule/ec/p256.c", + "crypto/fipsmodule/ec/p256-nistz-table.h", + "crypto/fipsmodule/ec/p256-nistz.c", + "crypto/fipsmodule/ec/p256-nistz.h", + "crypto/fipsmodule/ec/p256_shared.h", + "crypto/fipsmodule/ec/p256_table.h", + "crypto/fipsmodule/ec/util.h", + "crypto/fipsmodule/ecdsa/ecdsa_verify_tests.txt", + "crypto/fipsmodule/sha/asm/sha256-armv4.pl", + "crypto/fipsmodule/sha/asm/sha512-armv4.pl", + "crypto/fipsmodule/sha/asm/sha512-armv8.pl", + "crypto/fipsmodule/sha/asm/sha512-x86_64.pl", + "crypto/internal.h", + "crypto/limbs/limbs.c", + "crypto/limbs/limbs.h", + "crypto/limbs/limbs.inl", + "crypto/mem.c", + "crypto/perlasm/arm-xlate.pl", + "crypto/perlasm/x86asm.pl", + "crypto/perlasm/x86gas.pl", + "crypto/perlasm/x86nasm.pl", + "crypto/perlasm/x86_64-xlate.pl", + "crypto/poly1305/poly1305.c", + "crypto/poly1305/poly1305_arm.c", + "crypto/poly1305/poly1305_arm_asm.S", + "crypto/cipher/asm/chacha20_poly1305_armv8.pl", + "crypto/cipher/asm/chacha20_poly1305_x86_64.pl", + "examples/**/*.rs", + "include/ring-core/aes.h", + "include/ring-core/asm_base.h", + "include/ring-core/base.h", + "include/ring-core/check.h", + "include/ring-core/mem.h", + "include/ring-core/target.h", + "include/ring-core/type_check.h", + "src/**/*.rs", + "src/aead/poly1305_test.txt", + "src/data/alg-rsa-encryption.der", + "src/ec/curve25519/ed25519/ed25519_pkcs8_v2_template.der", + "src/ec/suite_b/ecdsa/ecPublicKey_p256_pkcs8_v1_template.der", + "src/ec/suite_b/ecdsa/ecPublicKey_p384_pkcs8_v1_template.der", + "src/rsa/signature_rsa_example_private_key.der", + "src/rsa/signature_rsa_example_public_key.der", + "tests/**/*.rs", + "tests/ecdsa_test_private_key_p256.p8", + "tests/ecdsa_test_public_key_p256.der", + "tests/ecdsa_test_public_key_p256_debug.txt", + "tests/ed25519_test_private_key.bin", + "tests/ed25519_test_private_key.p8", + "tests/ed25519_test_public_key.bin", + "tests/ed25519_test_public_key.der", + "tests/rsa_test_private_key_2048.p8", + "tests/rsa_test_public_key_2048.der", + "tests/rsa_test_public_key_2048_debug.txt", + "tests/rsa_test_public_modulus.bin", + "third_party/fiat/asm/fiat_curve25519_adx_mul.S", + "third_party/fiat/asm/fiat_curve25519_adx_square.S", + "third_party/fiat/curve25519_32.h", + "third_party/fiat/curve25519_64.h", + "third_party/fiat/curve25519_64_adx.h", + "third_party/fiat/curve25519_64_msvc.h", + "third_party/fiat/p256_32.h", + "third_party/fiat/p256_64.h", + "third_party/fiat/p256_64_msvc.h", + "third_party/fiat/LICENSE", +] + +[package.metadata.docs.rs] +all-features = true + +[lib] +name = "ring" + +[dependencies] +cfg-if = { version = "1.0.0", default-features = false } +getrandom = { version = "0.2.10" } +untrusted = { version = "0.9" } + +[target.'cfg(all(any(all(target_arch = "aarch64", target_endian = "little"), all(target_arch = "arm", target_endian = "little")), any(target_os = "android", target_os = "linux")))'.dependencies] +libc = { version = "0.2.148", default-features = false } + +[target.'cfg(all(all(target_arch = "aarch64", target_endian = "little"), target_vendor = "apple", any(target_os = "ios", target_os = "macos", target_os = "tvos", target_os = "visionos", target_os = "watchos")))'.dependencies] +libc = { version = "0.2.155", default-features = false } + +[target.'cfg(all(all(target_arch = "aarch64", target_endian = "little"), target_os = "windows"))'.dependencies] +windows-sys = { version = "0.52", features = ["Win32_Foundation", "Win32_System_Threading"] } + +[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dev-dependencies] +wasm-bindgen-test = { version = "0.3.37", default-features = false, features = ["std"] } + +[target.'cfg(any(unix, windows, target_os = "wasi"))'.dev-dependencies] +libc = { version = "0.2.148", default-features = false } + +[build-dependencies] +cc = { version = "1.2.8", default-features = false } + +[features] +# These features are documented in the top-level module's documentation. +default = ["alloc", "dev_urandom_fallback"] +alloc = [] +dev_urandom_fallback = [] +less-safe-getrandom-custom-or-rdrand = [] +less-safe-getrandom-espidf = [] +slow_tests = [] +std = ["alloc"] +unstable-testing-arm-no-hw = [] +unstable-testing-arm-no-neon = [] +test_logging = [] +wasm32_unknown_unknown_js = ["getrandom/js"] + +# XXX: debug = false because of https://github.com/rust-lang/rust/issues/34122 + +[profile.bench] +opt-level = 3 +debug = false +rpath = false +lto = true +debug-assertions = false +codegen-units = 1 + +[profile.release] +opt-level = 3 +debug = false +rpath = false +lto = true +debug-assertions = false +codegen-units = 1 + +[workspace] +members = [ + # intentionally not a default member so that `cargo test` doesn't cause criterion.rs and all its + # dependencies to get built. + "bench", + + "cavp", +] +default-members = [ + ".", + "cavp" +] diff --git a/http/vendor/ring/LICENSE b/http/vendor/ring/LICENSE new file mode 100644 index 0000000..2dac4d9 --- /dev/null +++ b/http/vendor/ring/LICENSE @@ -0,0 +1,9 @@ +*ring* uses an "ISC" license, like BoringSSL used to use, for new code +files. See LICENSE-other-bits for the text of that license. + +See LICENSE-BoringSSL for code that was sourced from BoringSSL under the +Apache 2.0 license. Some code that was sourced from BoringSSL under the ISC +license. In each case, the license info is at the top of the file. + +See src/polyfill/once_cell/LICENSE-APACHE and src/polyfill/once_cell/LICENSE-MIT +for the license to code that was sourced from the once_cell project. diff --git a/http/vendor/ring/LICENSE-BoringSSL b/http/vendor/ring/LICENSE-BoringSSL new file mode 100644 index 0000000..a0f82a1 --- /dev/null +++ b/http/vendor/ring/LICENSE-BoringSSL @@ -0,0 +1,272 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + +Licenses for support code +------------------------- + +Parts of the TLS test suite are under the Go license. This code is not included +in BoringSSL (i.e. libcrypto and libssl) when compiled, however, so +distributing code linked against BoringSSL does not trigger this license: + +Copyright (c) 2009 The Go Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +BoringSSL uses the Chromium test infrastructure to run a continuous build, +trybots etc. The scripts which manage this, and the script for generating build +metadata, are under the Chromium license. Distributing code linked against +BoringSSL does not trigger this license. + +Copyright 2015 The Chromium Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/http/vendor/ring/LICENSE-other-bits b/http/vendor/ring/LICENSE-other-bits new file mode 100644 index 0000000..bccf030 --- /dev/null +++ b/http/vendor/ring/LICENSE-other-bits @@ -0,0 +1,13 @@ +Copyright 2015-2025 Brian Smith. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/http/vendor/ring/README.md b/http/vendor/ring/README.md new file mode 100644 index 0000000..7ae6f61 --- /dev/null +++ b/http/vendor/ring/README.md @@ -0,0 +1,54 @@ +THE SOFTWARE IS PROVIDED "AS IS" AND BRIAN SMITH AND THE AUTHORS DISCLAIM +ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL BRIAN SMITH OR THE AUTHORS +BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY +DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN +AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + + +Most of the C and assembly language code in *ring* comes from BoringSSL. +BoringSSL is a fork of OpenSSL. This quote from the BoringSSL README.md +discouraging you from using it applies to this project: + +> BoringSSL is a fork of OpenSSL that is designed to meet Google's needs. +> +> Although BoringSSL is an open source project, it is not intended for general +> use, as OpenSSL is. We don't recommend that third parties depend upon it. + +This project was originally shared on GitHub in 2015 as an experiment. It was +put on crates.io shortly to help other people with their experiments. It is an +experiment. + + +Side Channels +------------- + +See [SIDE-CHANNELS.md](SIDE-CHANNELS.md) for important information regarding +the limitations of the side channel mitigations in this project. + + +Toolchains & Targets +-------------------- + +Be especially weary about using toolchains (C compilers, etc.) or targets +that aren't supported by other projects, especially BoringSSL. The further you +are from using the same version of Clang that Chrome uses, the more weary you +should be. + + +Bug Reporting +------------- + +For security vulnerabilities, see https://github.com/briansmith/ring/security/policy. + +Please report bugs that aren't security vulnerabilities either as pull requests or as issues in +[the issue tracker](https://github.com/briansmith/ring/issues). + + + +Release Notes +------------- +It is recommended that you review every commit in this project. Some +particularly noteworthy changes are noted in the [RELEASES.md](RELEASES.md). We could use some +help in making this better. diff --git a/http/vendor/ring/build.rs b/http/vendor/ring/build.rs new file mode 100644 index 0000000..9843ad8 --- /dev/null +++ b/http/vendor/ring/build.rs @@ -0,0 +1,1044 @@ +// Copyright 2015-2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! Build the non-Rust components. + +// It seems like it would be a good idea to use `log!` for logging, but it +// isn't worth having the external dependencies (one for the `log` crate, and +// another for the concrete logging implementation). Instead we use `eprintln!` +// to log everything to stderr. + +use std::{ + ffi::{OsStr, OsString}, + fs::{self, DirEntry}, + io::Write, + path::{Path, PathBuf}, + process::{Command, Stdio}, +}; + +mod env { + use std::ffi::OsString; + + /// Read an environment variable and tell Cargo that we depend on it. + /// + /// The name is static since we intend to only read a static set of environment + /// variables. + pub fn var_os(name: &'static str) -> Option { + println!("cargo:rerun-if-env-changed={}", name); + std::env::var_os(name) + } + + pub fn var(name: &'static str) -> Option { + var_os(name).and_then(|value| value.into_string().ok()) + } +} + +const X86: &str = "x86"; +const X86_64: &str = "x86_64"; +const AARCH64: &str = "aarch64"; +const ARM: &str = "arm"; +const WASM32: &str = "wasm32"; + +#[rustfmt::skip] +const RING_SRCS: &[(&[&str], &str)] = &[ + (&[], "crypto/curve25519/curve25519.c"), + (&[], "crypto/fipsmodule/aes/aes_nohw.c"), + (&[], "crypto/fipsmodule/bn/montgomery.c"), + (&[], "crypto/fipsmodule/bn/montgomery_inv.c"), + (&[], "crypto/fipsmodule/ec/ecp_nistz.c"), + (&[], "crypto/fipsmodule/ec/gfp_p256.c"), + (&[], "crypto/fipsmodule/ec/gfp_p384.c"), + (&[], "crypto/fipsmodule/ec/p256.c"), + (&[], "crypto/limbs/limbs.c"), + (&[], "crypto/mem.c"), + (&[], "crypto/poly1305/poly1305.c"), + + (&[ARM, X86_64, X86], "crypto/crypto.c"), + + (&[X86_64, X86], "crypto/cpu_intel.c"), + + (&[X86], "crypto/fipsmodule/aes/asm/aesni-x86.pl"), + (&[X86], "crypto/fipsmodule/aes/asm/ghash-x86.pl"), + (&[X86], "crypto/fipsmodule/aes/asm/vpaes-x86.pl"), + (&[X86], "crypto/fipsmodule/bn/asm/x86-mont.pl"), + (&[X86], "crypto/chacha/asm/chacha-x86.pl"), + + (&[X86_64], "crypto/chacha/asm/chacha-x86_64.pl"), + (&[X86_64], "crypto/curve25519/curve25519_64_adx.c"), + (&[X86_64], "crypto/fipsmodule/aes/asm/aes-gcm-avx2-x86_64.pl"), + (&[X86_64], "crypto/fipsmodule/aes/asm/aesni-gcm-x86_64.pl"), + (&[X86_64], "crypto/fipsmodule/aes/asm/aesni-x86_64.pl"), + (&[X86_64], "crypto/fipsmodule/aes/asm/ghash-x86_64.pl"), + (&[X86_64], "crypto/fipsmodule/aes/asm/vpaes-x86_64.pl"), + (&[X86_64], "crypto/fipsmodule/bn/asm/x86_64-mont.pl"), + (&[X86_64], "crypto/fipsmodule/bn/asm/x86_64-mont5.pl"), + (&[X86_64], "crypto/fipsmodule/ec/asm/p256-x86_64-asm.pl"), + (&[X86_64], SHA512_X86_64), + (&[X86_64], "crypto/cipher/asm/chacha20_poly1305_x86_64.pl"), + (&[X86_64], "third_party/fiat/asm/fiat_curve25519_adx_mul.S"), + (&[X86_64], "third_party/fiat/asm/fiat_curve25519_adx_square.S"), + + (&[AARCH64, X86_64], "crypto/fipsmodule/ec/p256-nistz.c"), + + (&[ARM], "crypto/fipsmodule/aes/asm/bsaes-armv7.pl"), + (&[ARM], "crypto/fipsmodule/aes/asm/ghash-armv4.pl"), + (&[ARM], "crypto/fipsmodule/aes/asm/vpaes-armv7.pl"), + (&[ARM], "crypto/fipsmodule/bn/asm/armv4-mont.pl"), + (&[ARM], "crypto/chacha/asm/chacha-armv4.pl"), + (&[ARM], "crypto/curve25519/asm/x25519-asm-arm.S"), + (&[ARM], "crypto/poly1305/poly1305_arm.c"), + (&[ARM], "crypto/poly1305/poly1305_arm_asm.S"), + (&[ARM], "crypto/fipsmodule/sha/asm/sha256-armv4.pl"), + (&[ARM], "crypto/fipsmodule/sha/asm/sha512-armv4.pl"), + + (&[AARCH64], "crypto/chacha/asm/chacha-armv8.pl"), + (&[AARCH64], "crypto/cipher/asm/chacha20_poly1305_armv8.pl"), + (&[AARCH64], "crypto/fipsmodule/aes/asm/aesv8-armx.pl"), + (&[AARCH64], "crypto/fipsmodule/aes/asm/aesv8-gcm-armv8.pl"), + (&[AARCH64], "crypto/fipsmodule/aes/asm/ghash-neon-armv8.pl"), + (&[AARCH64], "crypto/fipsmodule/aes/asm/ghashv8-armx.pl"), + (&[AARCH64], "crypto/fipsmodule/aes/asm/vpaes-armv8.pl"), + (&[AARCH64], "crypto/fipsmodule/bn/asm/armv8-mont.pl"), + (&[AARCH64], "crypto/fipsmodule/ec/asm/p256-armv8-asm.pl"), + (&[AARCH64], SHA512_ARMV8), +]; + +const SHA256_X86_64: &str = "crypto/fipsmodule/sha/asm/sha256-x86_64.pl"; +const SHA512_X86_64: &str = "crypto/fipsmodule/sha/asm/sha512-x86_64.pl"; + +const SHA256_ARMV8: &str = "crypto/fipsmodule/sha/asm/sha256-armv8.pl"; +const SHA512_ARMV8: &str = "crypto/fipsmodule/sha/asm/sha512-armv8.pl"; + +const RING_TEST_SRCS: &[&str] = &[("crypto/constant_time_test.c")]; + +const PREGENERATED: &str = "pregenerated"; + +fn cpp_flags(compiler: &cc::Tool) -> &'static [&'static str] { + if !compiler.is_like_msvc() { + static NON_MSVC_FLAGS: &[&str] = &[ + "-fvisibility=hidden", + "-std=c1x", // GCC 4.6 requires "c1x" instead of "c11" + "-Wall", + "-Wbad-function-cast", + "-Wcast-align", + "-Wcast-qual", + "-Wconversion", + "-Wmissing-field-initializers", + "-Wmissing-include-dirs", + "-Wnested-externs", + "-Wredundant-decls", + "-Wshadow", + "-Wsign-compare", + "-Wsign-conversion", + "-Wstrict-prototypes", + "-Wundef", + "-Wuninitialized", + ]; + NON_MSVC_FLAGS + } else { + static MSVC_FLAGS: &[&str] = &[ + "/Gy", // Enable function-level linking. + "/Zc:wchar_t", + "/Zc:forScope", + "/Zc:inline", + // Warnings. + "/Wall", + "/wd4127", // C4127: conditional expression is constant + "/wd4464", // C4464: relative include path contains '..' + "/wd4514", // C4514: : unreferenced inline function has be + "/wd4710", // C4710: function not inlined + "/wd4711", // C4711: function 'function' selected for inline expansion + "/wd4820", // C4820: : bytes padding added after + "/wd5045", /* C5045: Compiler will insert Spectre mitigation for memory load if + * /Qspectre switch specified */ + ]; + MSVC_FLAGS + } +} + +// None means "any OS" or "any target". The first match in sequence order is +// taken. +const ASM_TARGETS: &[AsmTarget] = &[ + AsmTarget { + oss: LINUX_ABI, + arch: AARCH64, + perlasm_format: "linux64", + }, + AsmTarget { + oss: LINUX_ABI, + arch: ARM, + perlasm_format: "linux32", + }, + AsmTarget { + oss: LINUX_ABI, + arch: X86, + perlasm_format: "elf", + }, + AsmTarget { + oss: LINUX_ABI, + arch: X86_64, + perlasm_format: "elf", + }, + AsmTarget { + oss: &["horizon"], + arch: ARM, + perlasm_format: "linux32", + }, + AsmTarget { + oss: APPLE_ABI, + arch: AARCH64, + perlasm_format: "ios64", + }, + AsmTarget { + oss: APPLE_ABI, + arch: X86_64, + perlasm_format: "macosx", + }, + AsmTarget { + oss: &[WINDOWS], + arch: X86, + perlasm_format: WIN32N, + }, + AsmTarget { + oss: &[WINDOWS], + arch: X86_64, + perlasm_format: NASM, + }, + AsmTarget { + oss: &[WINDOWS], + arch: AARCH64, + perlasm_format: "win64", + }, +]; + +struct AsmTarget { + /// Operating systems. + oss: &'static [&'static str], + + /// Architectures. + arch: &'static str, + + /// The PerlAsm format name. + perlasm_format: &'static str, +} + +impl AsmTarget { + fn use_nasm(&self) -> bool { + [WIN32N, NASM].contains(&self.perlasm_format) + } +} + +/// Operating systems that have the same ABI as Linux on every architecture +/// mentioned in `ASM_TARGETS`. +const LINUX_ABI: &[&str] = &[ + "android", + "dragonfly", + "freebsd", + "fuchsia", + "haiku", + "hurd", + "illumos", + "netbsd", + "openbsd", + "linux", + "redox", + "solaris", +]; + +const WIN32N: &str = "win32n"; +const NASM: &str = "nasm"; + +/// Operating systems that have the same ABI as macOS on every architecture +/// mentioned in `ASM_TARGETS`. +const APPLE_ABI: &[&str] = &["ios", "macos", "tvos", "visionos", "watchos"]; + +const WINDOWS: &str = "windows"; + +fn main() { + // Avoid assuming the working directory is the same is the $CARGO_MANIFEST_DIR so that toolchains + // which may assume other working directories can still build this code. + let c_root_dir = PathBuf::from( + env::var_os("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR should always be set"), + ); + + // Keep in sync with `core_name_and_version!` in prefixed.rs. + let core_name_and_version = [ + &env::var("CARGO_PKG_NAME").unwrap(), + "core", + &env::var("CARGO_PKG_VERSION_MAJOR").unwrap(), + &env::var("CARGO_PKG_VERSION_MINOR").unwrap(), + &env::var("CARGO_PKG_VERSION_PATCH").unwrap(), + &env::var("CARGO_PKG_VERSION_PRE").unwrap(), // Often empty + ] + .join("_"); + // Ensure `links` in Cargo.toml is consistent with the version. + assert_eq!( + &env::var("CARGO_MANIFEST_LINKS").unwrap(), + &core_name_and_version + ); + + const RING_PREGENERATE_ASM: &str = "RING_PREGENERATE_ASM"; + match env::var_os(RING_PREGENERATE_ASM).as_deref() { + Some(s) if s == "1" => { + pregenerate_asm_main(&c_root_dir, &core_name_and_version); + } + None => ring_build_rs_main(&c_root_dir, &core_name_and_version), + _ => { + panic!("${} has an invalid value", RING_PREGENERATE_ASM); + } + } +} + +fn ring_build_rs_main(c_root_dir: &Path, core_name_and_version: &str) { + let out_dir = env::var_os("OUT_DIR").unwrap(); + let out_dir = PathBuf::from(out_dir); + + let arch = env::var("CARGO_CFG_TARGET_ARCH").unwrap(); + let os = env::var("CARGO_CFG_TARGET_OS").unwrap(); + let env = env::var("CARGO_CFG_TARGET_ENV").unwrap(); + let endian = env::var("CARGO_CFG_TARGET_ENDIAN").unwrap(); + let is_little_endian = endian == "little"; + + let is_git = fs::metadata(c_root_dir.join(".git")).is_ok(); + + // Published builds are always built in release mode. + let is_debug = is_git && env::var("DEBUG").unwrap() != "false"; + + // During local development, force warnings in non-Rust code to be treated + // as errors. Since warnings are highly compiler-dependent and compilers + // don't maintain backward compatibility w.r.t. which warnings they issue, + // don't do this for packaged builds. + let force_warnings_into_errors = is_git; + + let target = Target { + arch, + os, + env, + is_debug, + force_warnings_into_errors, + }; + + let asm_target = if is_little_endian { + ASM_TARGETS.iter().find(|asm_target| { + asm_target.arch == target.arch && asm_target.oss.contains(&target.os.as_ref()) + }) + } else { + None + }; + + // If `.git` exists then assume this is the "local hacking" case where + // we want to make it easy to build *ring* using `cargo build`/`cargo test` + // without a prerequisite `package` step, at the cost of needing additional + // tools like `Perl` and/or `nasm`. + // + // If `.git` doesn't exist then assume that this is a packaged build where + // we want to optimize for minimizing the build tools required: No Perl, + // no nasm, etc. + let generated_dir = if !is_git { + c_root_dir.join(PREGENERATED) + } else { + generate_sources_and_preassemble( + &out_dir, + asm_target.into_iter(), + c_root_dir, + core_name_and_version, + ); + out_dir.clone() + }; + + build_c_code( + asm_target, + &target, + &generated_dir, + c_root_dir, + &out_dir, + core_name_and_version, + ); + emit_rerun_if_changed() +} + +fn pregenerate_asm_main(c_root_dir: &Path, core_name_and_version: &str) { + let pregenerated = c_root_dir.join(PREGENERATED); + fs::create_dir(&pregenerated).unwrap(); + generate_sources_and_preassemble( + &pregenerated, + ASM_TARGETS.iter(), + c_root_dir, + core_name_and_version, + ); +} + +fn generate_sources_and_preassemble<'a>( + out_dir: &Path, + asm_targets: impl Iterator, + c_root_dir: &Path, + core_name_and_version: &str, +) { + generate_prefix_symbols_headers(out_dir, core_name_and_version).unwrap(); + + let perl_exe = get_perl_exe(); + + for asm_target in asm_targets { + let perlasm_src_dsts = perlasm_src_dsts(out_dir, asm_target); + perlasm(&perl_exe, &perlasm_src_dsts, asm_target, c_root_dir); + + if asm_target.use_nasm() { + // Package pregenerated object files in addition to pregenerated + // assembly language source files, so that the user doesn't need + // to install the assembler. + let srcs = asm_srcs(perlasm_src_dsts); + for src in srcs { + nasm(&src, asm_target.arch, out_dir, out_dir, c_root_dir); + } + } + } +} + +struct Target { + arch: String, + os: String, + env: String, + + /// Is this a debug build? This affects whether assertions might be enabled + /// in the C code. For packaged builds, this should always be `false`. + is_debug: bool, + + /// true: Force warnings to be treated as errors. + /// false: Use the default behavior (perhaps determined by `$CFLAGS`, etc.) + force_warnings_into_errors: bool, +} + +fn build_c_code( + asm_target: Option<&AsmTarget>, + target: &Target, + generated_dir: &Path, + c_root_dir: &Path, + out_dir: &Path, + core_name_and_version: &str, +) { + let (asm_srcs, obj_srcs) = if let Some(asm_target) = asm_target { + let perlasm_src_dsts = perlasm_src_dsts(generated_dir, asm_target); + + let asm_srcs = asm_srcs(perlasm_src_dsts); + + if asm_target.use_nasm() { + // Nasm was already used to generate the object files, so use them instead of + // assembling. + let obj_srcs = asm_srcs + .iter() + .map(|src| obj_path(generated_dir, src.as_path())) + .collect::>(); + (vec![], obj_srcs) + } else { + (asm_srcs, vec![]) + } + } else { + (vec![], vec![]) + }; + + let core_srcs = sources_for_arch(&target.arch) + .into_iter() + .filter(|p| !is_perlasm(p)) + .filter(|p| { + if let Some(extension) = p.extension() { + // We don't (and can't) use any .S on Windows since MSVC and NASM can't assemble + // them. + if extension == "S" + && (target.arch == X86_64 || target.arch == X86) + && target.os == WINDOWS + { + return false; + } + } + true + }) + .collect::>(); + + let test_srcs = RING_TEST_SRCS.iter().map(PathBuf::from).collect::>(); + + let libs = [ + ( + core_name_and_version, + &core_srcs[..], + &asm_srcs[..], + &obj_srcs[..], + ), + ( + &(String::from(core_name_and_version) + "_test"), + &test_srcs[..], + &[], + &[], + ), + ]; + + // XXX: Ideally, ring-test would only be built for `cargo test`, but Cargo + // can't do that yet. + libs.iter() + .for_each(|&(lib_name, srcs, asm_srcs, obj_srcs)| { + let srcs = srcs.iter().chain(asm_srcs); + build_library( + target, + c_root_dir, + out_dir, + lib_name, + srcs, + generated_dir, + obj_srcs, + ) + }); + + println!( + "cargo:rustc-link-search=native={}", + out_dir.to_str().expect("Invalid path") + ); +} + +fn new_build(target: &Target, c_root_dir: &Path, include_dir: &Path) -> cc::Build { + let mut b = cc::Build::new(); + configure_cc(&mut b, target, c_root_dir, include_dir); + b +} + +fn build_library<'a>( + target: &Target, + c_root_dir: &Path, + out_dir: &Path, + lib_name: &str, + srcs: impl Iterator, + include_dir: &Path, + preassembled_objs: &[PathBuf], +) { + let mut c = new_build(target, c_root_dir, include_dir); + + // Compile all the (dirty) source files into object files. + srcs.for_each(|src| { + c.file(c_root_dir.join(src)); + }); + + preassembled_objs.iter().for_each(|obj| { + c.object(obj); + }); + + // Rebuild the library if necessary. + let lib_path = PathBuf::from(out_dir).join(format!("lib{}.a", lib_name)); + + // Handled below. + let _ = c.cargo_metadata(false); + + c.compile( + lib_path + .file_name() + .and_then(|f| f.to_str()) + .expect("No filename"), + ); + + // Link the library. This works even when the library doesn't need to be + // rebuilt. + println!("cargo:rustc-link-lib=static={}", lib_name); +} + +fn obj_path(out_dir: &Path, src: &Path) -> PathBuf { + let mut out_path = out_dir.join(src.file_name().unwrap()); + // To eliminate unnecessary conditional logic, use ".o" as the extension, + // even when the compiler (e.g. MSVC) would normally use something else + // (e.g. ".obj"). cc-rs seems to do the same. + assert!(out_path.set_extension("o")); + out_path +} + +fn configure_cc(c: &mut cc::Build, target: &Target, c_root_dir: &Path, include_dir: &Path) { + let compiler = c.get_compiler(); + // FIXME: On Windows AArch64 we currently must use Clang to compile C code + let compiler = if target.os == WINDOWS && target.arch == AARCH64 && !compiler.is_like_clang() { + let _ = c.compiler("clang"); + c.get_compiler() + } else { + compiler + }; + + let _ = c.include(c_root_dir.join("include")); + let _ = c.include(include_dir); + for f in cpp_flags(&compiler) { + let _ = c.flag(f); + } + + if APPLE_ABI.contains(&target.os.as_str()) { + // ``-gfull`` is required for Darwin's |-dead_strip|. + let _ = c.flag("-gfull"); + } else if !compiler.is_like_msvc() { + let _ = c.flag("-g3"); + }; + + if !target.is_debug { + let _ = c.define("NDEBUG", None); + } + + if target.arch == X86 { + let is_msvc_not_clang_cl = compiler.is_like_msvc() && !compiler.is_like_clang_cl(); + if !is_msvc_not_clang_cl { + let _ = c.flag("-msse2"); + } + } + + // Allow cross-compiling without a target sysroot for these targets. + if (target.arch == WASM32) + || (target.os == "linux" && target.env == "musl" && target.arch != X86_64) + { + // TODO: Expand this to non-clang compilers in 0.17.0 if practical. + if compiler.is_like_clang() { + let _ = c.flag("-nostdlibinc"); + let _ = c.define("RING_CORE_NOSTDLIBINC", "1"); + } + } + + if target.force_warnings_into_errors { + c.warnings_into_errors(true); + } +} + +fn nasm(file: &Path, arch: &str, include_dir: &Path, out_dir: &Path, c_root_dir: &Path) { + let out_file = obj_path(out_dir, file); + let oformat = match arch { + x if x == X86_64 => "win64", + x if x == X86 => "win32", + _ => panic!("unsupported arch: {}", arch), + }; + + // Nasm requires that the path end in a path separator. + let mut include_dir = include_dir.as_os_str().to_os_string(); + include_dir.push(OsString::from(String::from(std::path::MAIN_SEPARATOR))); + + let mut c = Command::new("./target/tools/windows/nasm/nasm"); + let _ = c + .arg("-o") + .arg(out_file.to_str().expect("Invalid path")) + .arg("-f") + .arg(oformat) + .arg("-i") + .arg("include/") + .arg("-i") + .arg(include_dir) + .arg("-Xgnu") + .arg("-gcv8") + .arg(c_root_dir.join(file)); + run_command(c); +} + +fn run_command_with_args(command_name: &Path, args: &[OsString]) { + let mut cmd = Command::new(command_name); + let _ = cmd.args(args); + run_command(cmd) +} + +fn run_command(mut cmd: Command) { + eprintln!("running {:?}", cmd); + cmd.stderr(Stdio::inherit()); + let status = cmd.status().unwrap_or_else(|e| { + panic!("failed to execute [{:?}]: {}", cmd, e); + }); + if !status.success() { + panic!("execution failed"); + } +} + +fn sources_for_arch(arch: &str) -> Vec { + RING_SRCS + .iter() + .filter(|&&(archs, _)| archs.is_empty() || archs.contains(&arch)) + .map(|&(_, p)| PathBuf::from(p)) + .collect::>() +} + +fn perlasm_src_dsts(out_dir: &Path, asm_target: &AsmTarget) -> Vec<(PathBuf, PathBuf)> { + let srcs = sources_for_arch(asm_target.arch); + let mut src_dsts = srcs + .iter() + .filter(|p| is_perlasm(p)) + .map(|src| (src.clone(), asm_path(out_dir, src, asm_target))) + .collect::>(); + + // Some PerlAsm source files need to be run multiple times with different + // output paths. + { + // Appease the borrow checker. + let mut maybe_synthesize = |concrete, synthesized| { + let concrete_path = PathBuf::from(concrete); + if srcs.contains(&concrete_path) { + let synthesized_path = PathBuf::from(synthesized); + src_dsts.push(( + concrete_path, + asm_path(out_dir, &synthesized_path, asm_target), + )) + } + }; + maybe_synthesize(SHA512_X86_64, SHA256_X86_64); + maybe_synthesize(SHA512_ARMV8, SHA256_ARMV8); + } + + src_dsts +} + +fn asm_srcs(perlasm_src_dsts: Vec<(PathBuf, PathBuf)>) -> Vec { + perlasm_src_dsts + .into_iter() + .map(|(_src, dst)| dst) + .collect::>() +} + +fn is_perlasm(path: &Path) -> bool { + path.extension().unwrap().to_str().unwrap() == "pl" +} + +fn asm_path(out_dir: &Path, src: &Path, asm_target: &AsmTarget) -> PathBuf { + let src_stem = src.file_stem().expect("source file without basename"); + + let dst_stem = src_stem.to_str().unwrap(); + let dst_filename = format!("{}-{}", dst_stem, asm_target.perlasm_format); + let extension = if asm_target.use_nasm() { "asm" } else { "S" }; + out_dir.join(dst_filename).with_extension(extension) +} + +fn perlasm( + perl_exe: &Path, + src_dst: &[(PathBuf, PathBuf)], + asm_target: &AsmTarget, + c_root_dir: &Path, +) { + for (src, dst) in src_dst { + let mut args = vec![ + join_components_with_forward_slashes(&c_root_dir.join(src)), + asm_target.perlasm_format.into(), + ]; + if asm_target.arch == X86 { + args.push("-fPIC".into()); + } + // Work around PerlAsm issue for ARM and AAarch64 targets by replacing + // back slashes with forward slashes. + args.push(join_components_with_forward_slashes(dst)); + run_command_with_args(perl_exe, &args); + } +} + +fn join_components_with_forward_slashes(path: &Path) -> OsString { + let parts = path.components().map(|c| c.as_os_str()).collect::>(); + parts.join(OsStr::new("/")) +} + +fn get_perl_exe() -> PathBuf { + get_command("PERL_EXECUTABLE", "perl") +} + +fn get_command(var: &'static str, default: &str) -> PathBuf { + PathBuf::from(env::var_os(var).unwrap_or_else(|| default.into())) +} + +// TODO: We should emit `cargo:rerun-if-changed-env` for the various +// environment variables that affect the build. +fn emit_rerun_if_changed() { + for path in &["crypto", "include", "third_party/fiat"] { + walk_dir(&PathBuf::from(path), &|entry| { + let path = entry.path(); + match path.extension().and_then(|ext| ext.to_str()) { + Some("c") | Some("S") | Some("h") | Some("inl") | Some("pl") | None => { + println!("cargo:rerun-if-changed={}", path.to_str().unwrap()); + } + _ => { + // Ignore other types of files. + } + } + }) + } +} + +fn walk_dir(dir: &Path, cb: &impl Fn(&DirEntry)) { + if dir.is_dir() { + for entry in fs::read_dir(dir).unwrap() { + let entry = entry.unwrap(); + let path = entry.path(); + if path.is_dir() { + walk_dir(&path, cb); + } else { + cb(&entry); + } + } + } +} + +/// Creates the necessary header files for symbol renaming. +/// +/// For simplicity, both non-Nasm- and Nasm- style headers are always +/// generated, even though local non-packaged builds need only one of them. +fn generate_prefix_symbols_headers( + out_dir: &Path, + core_name_and_version: &str, +) -> Result<(), std::io::Error> { + let prefix = &(String::from(core_name_and_version) + "_"); + + generate_prefix_symbols_header(out_dir, "prefix_symbols.h", '#', None, prefix)?; + + generate_prefix_symbols_header( + out_dir, + "prefix_symbols_asm.h", + '#', + Some("#if defined(__APPLE__)"), + prefix, + )?; + + generate_prefix_symbols_header( + out_dir, + "prefix_symbols_nasm.inc", + '%', + Some("%ifidn __OUTPUT_FORMAT__,win32"), + prefix, + )?; + + Ok(()) +} + +fn generate_prefix_symbols_header( + out_dir: &Path, + filename: &str, + pp: char, + prefix_condition: Option<&str>, + prefix: &str, +) -> Result<(), std::io::Error> { + let dir = out_dir.join("ring_core_generated"); + fs::create_dir_all(&dir)?; + + let path = dir.join(filename); + let mut file = fs::File::create(path)?; + + let filename_ident = filename.replace('.', "_").to_uppercase(); + writeln!( + file, + r#" +{pp}ifndef ring_core_generated_{filename_ident} +{pp}define ring_core_generated_{filename_ident} +"#, + pp = pp, + filename_ident = filename_ident + )?; + + if let Some(prefix_condition) = prefix_condition { + writeln!(file, "{}", prefix_condition)?; + writeln!(file, "{}", prefix_all_symbols(pp, "_", prefix))?; + writeln!(file, "{pp}else", pp = pp)?; + }; + writeln!(file, "{}", prefix_all_symbols(pp, "", prefix))?; + if prefix_condition.is_some() { + writeln!(file, "{pp}endif", pp = pp)? + } + + writeln!(file, "{pp}endif", pp = pp)?; + + Ok(()) +} + +fn prefix_all_symbols(pp: char, prefix_prefix: &str, prefix: &str) -> String { + // Rename some nistz256 assembly functions to match the names of their + // polyfills. + static SYMBOLS_TO_RENAME: &[(&str, &str)] = &[ + ("ecp_nistz256_point_double", "p256_point_double"), + ("ecp_nistz256_point_add", "p256_point_add"), + ("ecp_nistz256_point_add_affine", "p256_point_add_affine"), + ("ecp_nistz256_ord_mul_mont", "p256_scalar_mul_mont"), + ("ecp_nistz256_ord_sqr_mont", "p256_scalar_sqr_rep_mont"), + ("ecp_nistz256_mul_mont", "p256_mul_mont"), + ("ecp_nistz256_sqr_mont", "p256_sqr_mont"), + ]; + + static SYMBOLS_TO_PREFIX: &[&str] = &[ + "adx_bmi2_available", + "avx2_available", + "CRYPTO_memcmp", + "CRYPTO_poly1305_finish", + "CRYPTO_poly1305_finish_neon", + "CRYPTO_poly1305_init", + "CRYPTO_poly1305_init_neon", + "CRYPTO_poly1305_update", + "CRYPTO_poly1305_update_neon", + "ChaCha20_ctr32", + "ChaCha20_ctr32_avx2", + "ChaCha20_ctr32_neon", + "ChaCha20_ctr32_nohw", + "ChaCha20_ctr32_ssse3", + "ChaCha20_ctr32_ssse3_4x", + "LIMB_is_zero", + "LIMBS_add_mod", + "LIMBS_are_zero", + "LIMBS_equal", + "LIMBS_less_than", + "LIMBS_reduce_once", + "LIMBS_select_512_32", + "LIMBS_shl_mod", + "LIMBS_sub_mod", + "LIMBS_window5_split_window", + "LIMBS_window5_unsplit_window", + "LIMB_shr", + "OPENSSL_cpuid_setup", + "aes_gcm_dec_kernel", + "aes_gcm_dec_update_vaes_avx2", + "aes_gcm_enc_kernel", + "aes_gcm_enc_update_vaes_avx2", + "aes_hw_ctr32_encrypt_blocks", + "aes_hw_set_encrypt_key", + "aes_hw_set_encrypt_key_alt", + "aes_hw_set_encrypt_key_base", + "aes_nohw_ctr32_encrypt_blocks", + "aes_nohw_encrypt", + "aes_nohw_set_encrypt_key", + "aesni_gcm_decrypt", + "aesni_gcm_encrypt", + "bn_from_montgomery_in_place", + "bn_gather5", + "bn_mul_mont", + "bn_mul_mont_nohw", + "bn_mul4x_mont", + "bn_mulx4x_mont", + "bn_mul8x_mont_neon", + "bn_mul4x_mont_gather5", + "bn_mulx4x_mont_gather5", + "bn_neg_inv_mod_r_u64", + "bn_power5_nohw", + "bn_powerx5", + "bn_scatter5", + "bn_sqr8x_internal", + "bn_sqr8x_mont", + "bn_sqrx8x_internal", + "bsaes_ctr32_encrypt_blocks", + "bssl_constant_time_test_conditional_memcpy", + "bssl_constant_time_test_conditional_memxor", + "bssl_constant_time_test_main", + "chacha20_poly1305_open", + "chacha20_poly1305_open_avx2", + "chacha20_poly1305_open_sse41", + "chacha20_poly1305_seal", + "chacha20_poly1305_seal_avx2", + "chacha20_poly1305_seal_sse41", + "ecp_nistz256_mul_mont_adx", + "ecp_nistz256_mul_mont_nohw", + "ecp_nistz256_ord_mul_mont_adx", + "ecp_nistz256_ord_mul_mont_nohw", + "ecp_nistz256_ord_sqr_mont_adx", + "ecp_nistz256_ord_sqr_mont_nohw", + "ecp_nistz256_point_add_adx", + "ecp_nistz256_point_add_nohw", + "ecp_nistz256_point_add_affine_adx", + "ecp_nistz256_point_add_affine_nohw", + "ecp_nistz256_point_double_adx", + "ecp_nistz256_point_double_nohw", + "ecp_nistz256_select_w5_avx2", + "ecp_nistz256_select_w5_nohw", + "ecp_nistz256_select_w7_avx2", + "ecp_nistz256_select_w7_nohw", + "ecp_nistz256_sqr_mont_adx", + "ecp_nistz256_sqr_mont_nohw", + "fiat_curve25519_adx_mul", + "fiat_curve25519_adx_square", + "gcm_ghash_avx", + "gcm_ghash_clmul", + "gcm_ghash_neon", + "gcm_ghash_vpclmulqdq_avx2_1", + "gcm_gmult_clmul", + "gcm_gmult_neon", + "gcm_init_avx", + "gcm_init_clmul", + "gcm_init_neon", + "gcm_init_vpclmulqdq_avx2", + "k25519Precomp", + "limbs_mul_add_limb", + "little_endian_bytes_from_scalar", + "ecp_nistz256_neg", + "ecp_nistz256_select_w5", + "ecp_nistz256_select_w7", + "neon_available", + "p256_mul_mont", + "p256_point_add", + "p256_point_add_affine", + "p256_point_double", + "p256_point_mul", + "p256_point_mul_base", + "p256_point_mul_base_vartime", + "p256_scalar_mul_mont", + "p256_scalar_sqr_rep_mont", + "p256_sqr_mont", + "p384_elem_div_by_2", + "p384_elem_mul_mont", + "p384_elem_neg", + "p384_elem_sub", + "p384_point_add", + "p384_point_double", + "p384_point_mul", + "p384_scalar_mul_mont", + "openssl_poly1305_neon2_addmulmod", + "openssl_poly1305_neon2_blocks", + "sha256_block_data_order", + "sha256_block_data_order_avx", + "sha256_block_data_order_ssse3", + "sha256_block_data_order_hw", + "sha256_block_data_order_neon", + "sha256_block_data_order_nohw", + "sha512_block_data_order", + "sha512_block_data_order_avx", + "sha512_block_data_order_hw", + "sha512_block_data_order_neon", + "sha512_block_data_order_nohw", + "vpaes_ctr32_encrypt_blocks", + "vpaes_encrypt", + "vpaes_encrypt_key_to_bsaes", + "vpaes_set_encrypt_key", + "x25519_NEON", + "x25519_fe_invert", + "x25519_fe_isnegative", + "x25519_fe_mul_ttt", + "x25519_fe_neg", + "x25519_fe_tobytes", + "x25519_ge_double_scalarmult_vartime", + "x25519_ge_frombytes_vartime", + "x25519_ge_scalarmult_base", + "x25519_ge_scalarmult_base_adx", + "x25519_public_from_private_generic_masked", + "x25519_sc_mask", + "x25519_sc_muladd", + "x25519_sc_reduce", + "x25519_scalar_mult_adx", + "x25519_scalar_mult_generic_masked", + ]; + + let mut out = String::new(); + + for (old, new) in SYMBOLS_TO_RENAME { + let line = format!( + "{pp}define {prefix_prefix}{old} {prefix_prefix}{new}\n", + pp = pp, + prefix_prefix = prefix_prefix, + old = old, + new = new + ); + out += &line; + } + + for symbol in SYMBOLS_TO_PREFIX { + let line = format!( + "{pp}define {prefix_prefix}{symbol} {prefix_prefix}{prefix}{symbol}\n", + pp = pp, + prefix_prefix = prefix_prefix, + prefix = prefix, + symbol = symbol + ); + out += &line; + } + + out +} diff --git a/http/vendor/ring/crypto/chacha/asm/chacha-armv4.pl b/http/vendor/ring/crypto/chacha/asm/chacha-armv4.pl new file mode 100644 index 0000000..700da12 --- /dev/null +++ b/http/vendor/ring/crypto/chacha/asm/chacha-armv4.pl @@ -0,0 +1,1137 @@ +#! /usr/bin/env perl +# Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# ==================================================================== +# Written by Andy Polyakov for the OpenSSL +# project. +# ==================================================================== +# +# December 2014 +# +# ChaCha20 for ARMv4. +# +# Performance in cycles per byte out of large buffer. +# +# IALU/gcc-4.4 1xNEON 3xNEON+1xIALU +# +# Cortex-A5 19.3(*)/+95% 21.8 14.1 +# Cortex-A8 10.5(*)/+160% 13.9 6.35 +# Cortex-A9 12.9(**)/+110% 14.3 6.50 +# Cortex-A15 11.0/+40% 16.0 5.00 +# Snapdragon S4 11.5/+125% 13.6 4.90 +# +# (*) most "favourable" result for aligned data on little-endian +# processor, result for misaligned data is 10-15% lower; +# (**) this result is a trade-off: it can be improved by 20%, +# but then Snapdragon S4 and Cortex-A8 results get +# 20-25% worse; + +$flavour = shift; +if ($flavour=~/\w[\w\-]*\.\w+$/) { $output=$flavour; undef $flavour; } +else { while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {} } + +if ($flavour && $flavour ne "void") { + $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; + ( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or + ( $xlate="${dir}../../perlasm/arm-xlate.pl" and -f $xlate) or + die "can't locate arm-xlate.pl"; + + open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""; + *STDOUT=*OUT; +} else { + open OUT,">$output"; + *STDOUT=*OUT; +} + +sub AUTOLOAD() # thunk [simplified] x86-style perlasm +{ my $opcode = $AUTOLOAD; $opcode =~ s/.*:://; $opcode =~ s/_/\./; + my $arg = pop; + $arg = "#$arg" if ($arg*1 eq $arg); + $code .= "\t$opcode\t".join(',',@_,$arg)."\n"; +} + +my @x=map("r$_",(0..7,"x","x","x","x",12,"x",14,"x")); +my @t=map("r$_",(8..11)); + +sub ROUND { +my ($a0,$b0,$c0,$d0)=@_; +my ($a1,$b1,$c1,$d1)=map(($_&~3)+(($_+1)&3),($a0,$b0,$c0,$d0)); +my ($a2,$b2,$c2,$d2)=map(($_&~3)+(($_+1)&3),($a1,$b1,$c1,$d1)); +my ($a3,$b3,$c3,$d3)=map(($_&~3)+(($_+1)&3),($a2,$b2,$c2,$d2)); +my $odd = $d0&1; +my ($xc,$xc_) = (@t[0..1]); +my ($xd,$xd_) = $odd ? (@t[2],@x[$d1]) : (@x[$d0],@t[2]); +my @ret; + + # Consider order in which variables are addressed by their + # index: + # + # a b c d + # + # 0 4 8 12 < even round + # 1 5 9 13 + # 2 6 10 14 + # 3 7 11 15 + # 0 5 10 15 < odd round + # 1 6 11 12 + # 2 7 8 13 + # 3 4 9 14 + # + # 'a', 'b' are permanently allocated in registers, @x[0..7], + # while 'c's and pair of 'd's are maintained in memory. If + # you observe 'c' column, you'll notice that pair of 'c's is + # invariant between rounds. This means that we have to reload + # them once per round, in the middle. This is why you'll see + # bunch of 'c' stores and loads in the middle, but none in + # the beginning or end. If you observe 'd' column, you'll + # notice that 15 and 13 are reused in next pair of rounds. + # This is why these two are chosen for offloading to memory, + # to make loads count more. + push @ret,( + "&add (@x[$a0],@x[$a0],@x[$b0])", + "&mov ($xd,$xd,'ror#16')", + "&add (@x[$a1],@x[$a1],@x[$b1])", + "&mov ($xd_,$xd_,'ror#16')", + "&eor ($xd,$xd,@x[$a0],'ror#16')", + "&eor ($xd_,$xd_,@x[$a1],'ror#16')", + + "&add ($xc,$xc,$xd)", + "&mov (@x[$b0],@x[$b0],'ror#20')", + "&add ($xc_,$xc_,$xd_)", + "&mov (@x[$b1],@x[$b1],'ror#20')", + "&eor (@x[$b0],@x[$b0],$xc,'ror#20')", + "&eor (@x[$b1],@x[$b1],$xc_,'ror#20')", + + "&add (@x[$a0],@x[$a0],@x[$b0])", + "&mov ($xd,$xd,'ror#24')", + "&add (@x[$a1],@x[$a1],@x[$b1])", + "&mov ($xd_,$xd_,'ror#24')", + "&eor ($xd,$xd,@x[$a0],'ror#24')", + "&eor ($xd_,$xd_,@x[$a1],'ror#24')", + + "&add ($xc,$xc,$xd)", + "&mov (@x[$b0],@x[$b0],'ror#25')" ); + push @ret,( + "&str ($xd,'[sp,#4*(16+$d0)]')", + "&ldr ($xd,'[sp,#4*(16+$d2)]')" ) if ($odd); + push @ret,( + "&add ($xc_,$xc_,$xd_)", + "&mov (@x[$b1],@x[$b1],'ror#25')" ); + push @ret,( + "&str ($xd_,'[sp,#4*(16+$d1)]')", + "&ldr ($xd_,'[sp,#4*(16+$d3)]')" ) if (!$odd); + push @ret,( + "&eor (@x[$b0],@x[$b0],$xc,'ror#25')", + "&eor (@x[$b1],@x[$b1],$xc_,'ror#25')" ); + + $xd=@x[$d2] if (!$odd); + $xd_=@x[$d3] if ($odd); + push @ret,( + "&str ($xc,'[sp,#4*(16+$c0)]')", + "&ldr ($xc,'[sp,#4*(16+$c2)]')", + "&add (@x[$a2],@x[$a2],@x[$b2])", + "&mov ($xd,$xd,'ror#16')", + "&str ($xc_,'[sp,#4*(16+$c1)]')", + "&ldr ($xc_,'[sp,#4*(16+$c3)]')", + "&add (@x[$a3],@x[$a3],@x[$b3])", + "&mov ($xd_,$xd_,'ror#16')", + "&eor ($xd,$xd,@x[$a2],'ror#16')", + "&eor ($xd_,$xd_,@x[$a3],'ror#16')", + + "&add ($xc,$xc,$xd)", + "&mov (@x[$b2],@x[$b2],'ror#20')", + "&add ($xc_,$xc_,$xd_)", + "&mov (@x[$b3],@x[$b3],'ror#20')", + "&eor (@x[$b2],@x[$b2],$xc,'ror#20')", + "&eor (@x[$b3],@x[$b3],$xc_,'ror#20')", + + "&add (@x[$a2],@x[$a2],@x[$b2])", + "&mov ($xd,$xd,'ror#24')", + "&add (@x[$a3],@x[$a3],@x[$b3])", + "&mov ($xd_,$xd_,'ror#24')", + "&eor ($xd,$xd,@x[$a2],'ror#24')", + "&eor ($xd_,$xd_,@x[$a3],'ror#24')", + + "&add ($xc,$xc,$xd)", + "&mov (@x[$b2],@x[$b2],'ror#25')", + "&add ($xc_,$xc_,$xd_)", + "&mov (@x[$b3],@x[$b3],'ror#25')", + "&eor (@x[$b2],@x[$b2],$xc,'ror#25')", + "&eor (@x[$b3],@x[$b3],$xc_,'ror#25')" ); + + @ret; +} + +$code.=<<___; +@ Silence ARMv8 deprecated IT instruction warnings. This file is used by both +@ ARMv7 and ARMv8 processors and does not use ARMv8 instructions. +.arch armv7-a + +.text +#if defined(__thumb2__) || defined(__clang__) +.syntax unified +#endif +#if defined(__thumb2__) +.thumb +#else +.code 32 +#endif + +#if defined(__thumb2__) || defined(__clang__) +#define ldrhsb ldrbhs +#endif + +.align 5 +.Lsigma: +.long 0x61707865,0x3320646e,0x79622d32,0x6b206574 @ endian-neutral +.Lone: +.long 1,0,0,0 + +.globl ChaCha20_ctr32_nohw +.type ChaCha20_ctr32_nohw,%function +.align 5 +ChaCha20_ctr32_nohw: + ldr r12,[sp,#0] @ pull pointer to counter and nonce + stmdb sp!,{r0-r2,r4-r11,lr} + adr r14,.Lsigma + ldmia r12,{r4-r7} @ load counter and nonce + sub sp,sp,#4*(16) @ off-load area + stmdb sp!,{r4-r7} @ copy counter and nonce + ldmia r3,{r4-r11} @ load key + ldmia r14,{r0-r3} @ load sigma + stmdb sp!,{r4-r11} @ copy key + stmdb sp!,{r0-r3} @ copy sigma + str r10,[sp,#4*(16+10)] @ off-load "@x[10]" + str r11,[sp,#4*(16+11)] @ off-load "@x[11]" + b .Loop_outer_enter + +.align 4 +.Loop_outer: + ldmia sp,{r0-r9} @ load key material + str @t[3],[sp,#4*(32+2)] @ save len + str r12, [sp,#4*(32+1)] @ save inp + str r14, [sp,#4*(32+0)] @ save out +.Loop_outer_enter: + ldr @t[3], [sp,#4*(15)] + ldr @x[12],[sp,#4*(12)] @ modulo-scheduled load + ldr @t[2], [sp,#4*(13)] + ldr @x[14],[sp,#4*(14)] + str @t[3], [sp,#4*(16+15)] + mov @t[3],#10 + b .Loop + +.align 4 +.Loop: + subs @t[3],@t[3],#1 +___ + foreach (&ROUND(0, 4, 8,12)) { eval; } + foreach (&ROUND(0, 5,10,15)) { eval; } +$code.=<<___; + bne .Loop + + ldr @t[3],[sp,#4*(32+2)] @ load len + + str @t[0], [sp,#4*(16+8)] @ modulo-scheduled store + str @t[1], [sp,#4*(16+9)] + str @x[12],[sp,#4*(16+12)] + str @t[2], [sp,#4*(16+13)] + str @x[14],[sp,#4*(16+14)] + + @ at this point we have first half of 512-bit result in + @ @x[0-7] and second half at sp+4*(16+8) + + cmp @t[3],#64 @ done yet? +#ifdef __thumb2__ + itete lo +#endif + addlo r12,sp,#4*(0) @ shortcut or ... + ldrhs r12,[sp,#4*(32+1)] @ ... load inp + addlo r14,sp,#4*(0) @ shortcut or ... + ldrhs r14,[sp,#4*(32+0)] @ ... load out + + ldr @t[0],[sp,#4*(0)] @ load key material + ldr @t[1],[sp,#4*(1)] + +#if __ARM_ARCH>=6 || !defined(__ARMEB__) +# if __ARM_ARCH<7 + orr @t[2],r12,r14 + tst @t[2],#3 @ are input and output aligned? + ldr @t[2],[sp,#4*(2)] + bne .Lunaligned + cmp @t[3],#64 @ restore flags +# else + ldr @t[2],[sp,#4*(2)] +# endif + ldr @t[3],[sp,#4*(3)] + + add @x[0],@x[0],@t[0] @ accumulate key material + add @x[1],@x[1],@t[1] +# ifdef __thumb2__ + itt hs +# endif + ldrhs @t[0],[r12],#16 @ load input + ldrhs @t[1],[r12,#-12] + + add @x[2],@x[2],@t[2] + add @x[3],@x[3],@t[3] +# ifdef __thumb2__ + itt hs +# endif + ldrhs @t[2],[r12,#-8] + ldrhs @t[3],[r12,#-4] +# if __ARM_ARCH>=6 && defined(__ARMEB__) + rev @x[0],@x[0] + rev @x[1],@x[1] + rev @x[2],@x[2] + rev @x[3],@x[3] +# endif +# ifdef __thumb2__ + itt hs +# endif + eorhs @x[0],@x[0],@t[0] @ xor with input + eorhs @x[1],@x[1],@t[1] + add @t[0],sp,#4*(4) + str @x[0],[r14],#16 @ store output +# ifdef __thumb2__ + itt hs +# endif + eorhs @x[2],@x[2],@t[2] + eorhs @x[3],@x[3],@t[3] + ldmia @t[0],{@t[0]-@t[3]} @ load key material + str @x[1],[r14,#-12] + str @x[2],[r14,#-8] + str @x[3],[r14,#-4] + + add @x[4],@x[4],@t[0] @ accumulate key material + add @x[5],@x[5],@t[1] +# ifdef __thumb2__ + itt hs +# endif + ldrhs @t[0],[r12],#16 @ load input + ldrhs @t[1],[r12,#-12] + add @x[6],@x[6],@t[2] + add @x[7],@x[7],@t[3] +# ifdef __thumb2__ + itt hs +# endif + ldrhs @t[2],[r12,#-8] + ldrhs @t[3],[r12,#-4] +# if __ARM_ARCH>=6 && defined(__ARMEB__) + rev @x[4],@x[4] + rev @x[5],@x[5] + rev @x[6],@x[6] + rev @x[7],@x[7] +# endif +# ifdef __thumb2__ + itt hs +# endif + eorhs @x[4],@x[4],@t[0] + eorhs @x[5],@x[5],@t[1] + add @t[0],sp,#4*(8) + str @x[4],[r14],#16 @ store output +# ifdef __thumb2__ + itt hs +# endif + eorhs @x[6],@x[6],@t[2] + eorhs @x[7],@x[7],@t[3] + str @x[5],[r14,#-12] + ldmia @t[0],{@t[0]-@t[3]} @ load key material + str @x[6],[r14,#-8] + add @x[0],sp,#4*(16+8) + str @x[7],[r14,#-4] + + ldmia @x[0],{@x[0]-@x[7]} @ load second half + + add @x[0],@x[0],@t[0] @ accumulate key material + add @x[1],@x[1],@t[1] +# ifdef __thumb2__ + itt hs +# endif + ldrhs @t[0],[r12],#16 @ load input + ldrhs @t[1],[r12,#-12] +# ifdef __thumb2__ + itt hi +# endif + strhi @t[2],[sp,#4*(16+10)] @ copy "@x[10]" while at it + strhi @t[3],[sp,#4*(16+11)] @ copy "@x[11]" while at it + add @x[2],@x[2],@t[2] + add @x[3],@x[3],@t[3] +# ifdef __thumb2__ + itt hs +# endif + ldrhs @t[2],[r12,#-8] + ldrhs @t[3],[r12,#-4] +# if __ARM_ARCH>=6 && defined(__ARMEB__) + rev @x[0],@x[0] + rev @x[1],@x[1] + rev @x[2],@x[2] + rev @x[3],@x[3] +# endif +# ifdef __thumb2__ + itt hs +# endif + eorhs @x[0],@x[0],@t[0] + eorhs @x[1],@x[1],@t[1] + add @t[0],sp,#4*(12) + str @x[0],[r14],#16 @ store output +# ifdef __thumb2__ + itt hs +# endif + eorhs @x[2],@x[2],@t[2] + eorhs @x[3],@x[3],@t[3] + str @x[1],[r14,#-12] + ldmia @t[0],{@t[0]-@t[3]} @ load key material + str @x[2],[r14,#-8] + str @x[3],[r14,#-4] + + add @x[4],@x[4],@t[0] @ accumulate key material + add @x[5],@x[5],@t[1] +# ifdef __thumb2__ + itt hi +# endif + addhi @t[0],@t[0],#1 @ next counter value + strhi @t[0],[sp,#4*(12)] @ save next counter value +# ifdef __thumb2__ + itt hs +# endif + ldrhs @t[0],[r12],#16 @ load input + ldrhs @t[1],[r12,#-12] + add @x[6],@x[6],@t[2] + add @x[7],@x[7],@t[3] +# ifdef __thumb2__ + itt hs +# endif + ldrhs @t[2],[r12,#-8] + ldrhs @t[3],[r12,#-4] +# if __ARM_ARCH>=6 && defined(__ARMEB__) + rev @x[4],@x[4] + rev @x[5],@x[5] + rev @x[6],@x[6] + rev @x[7],@x[7] +# endif +# ifdef __thumb2__ + itt hs +# endif + eorhs @x[4],@x[4],@t[0] + eorhs @x[5],@x[5],@t[1] +# ifdef __thumb2__ + it ne +# endif + ldrne @t[0],[sp,#4*(32+2)] @ re-load len +# ifdef __thumb2__ + itt hs +# endif + eorhs @x[6],@x[6],@t[2] + eorhs @x[7],@x[7],@t[3] + str @x[4],[r14],#16 @ store output + str @x[5],[r14,#-12] +# ifdef __thumb2__ + it hs +# endif + subhs @t[3],@t[0],#64 @ len-=64 + str @x[6],[r14,#-8] + str @x[7],[r14,#-4] + bhi .Loop_outer + + beq .Ldone +# if __ARM_ARCH<7 + b .Ltail + +.align 4 +.Lunaligned: @ unaligned endian-neutral path + cmp @t[3],#64 @ restore flags +# endif +#endif +#if __ARM_ARCH<7 + ldr @t[3],[sp,#4*(3)] +___ +for ($i=0;$i<16;$i+=4) { +my $j=$i&0x7; + +$code.=<<___ if ($i==4); + add @x[0],sp,#4*(16+8) +___ +$code.=<<___ if ($i==8); + ldmia @x[0],{@x[0]-@x[7]} @ load second half +# ifdef __thumb2__ + itt hi +# endif + strhi @t[2],[sp,#4*(16+10)] @ copy "@x[10]" + strhi @t[3],[sp,#4*(16+11)] @ copy "@x[11]" +___ +$code.=<<___; + add @x[$j+0],@x[$j+0],@t[0] @ accumulate key material +___ +$code.=<<___ if ($i==12); +# ifdef __thumb2__ + itt hi +# endif + addhi @t[0],@t[0],#1 @ next counter value + strhi @t[0],[sp,#4*(12)] @ save next counter value +___ +$code.=<<___; + add @x[$j+1],@x[$j+1],@t[1] + add @x[$j+2],@x[$j+2],@t[2] +# ifdef __thumb2__ + itete lo +# endif + eorlo @t[0],@t[0],@t[0] @ zero or ... + ldrhsb @t[0],[r12],#16 @ ... load input + eorlo @t[1],@t[1],@t[1] + ldrhsb @t[1],[r12,#-12] + + add @x[$j+3],@x[$j+3],@t[3] +# ifdef __thumb2__ + itete lo +# endif + eorlo @t[2],@t[2],@t[2] + ldrhsb @t[2],[r12,#-8] + eorlo @t[3],@t[3],@t[3] + ldrhsb @t[3],[r12,#-4] + + eor @x[$j+0],@t[0],@x[$j+0] @ xor with input (or zero) + eor @x[$j+1],@t[1],@x[$j+1] +# ifdef __thumb2__ + itt hs +# endif + ldrhsb @t[0],[r12,#-15] @ load more input + ldrhsb @t[1],[r12,#-11] + eor @x[$j+2],@t[2],@x[$j+2] + strb @x[$j+0],[r14],#16 @ store output + eor @x[$j+3],@t[3],@x[$j+3] +# ifdef __thumb2__ + itt hs +# endif + ldrhsb @t[2],[r12,#-7] + ldrhsb @t[3],[r12,#-3] + strb @x[$j+1],[r14,#-12] + eor @x[$j+0],@t[0],@x[$j+0],lsr#8 + strb @x[$j+2],[r14,#-8] + eor @x[$j+1],@t[1],@x[$j+1],lsr#8 +# ifdef __thumb2__ + itt hs +# endif + ldrhsb @t[0],[r12,#-14] @ load more input + ldrhsb @t[1],[r12,#-10] + strb @x[$j+3],[r14,#-4] + eor @x[$j+2],@t[2],@x[$j+2],lsr#8 + strb @x[$j+0],[r14,#-15] + eor @x[$j+3],@t[3],@x[$j+3],lsr#8 +# ifdef __thumb2__ + itt hs +# endif + ldrhsb @t[2],[r12,#-6] + ldrhsb @t[3],[r12,#-2] + strb @x[$j+1],[r14,#-11] + eor @x[$j+0],@t[0],@x[$j+0],lsr#8 + strb @x[$j+2],[r14,#-7] + eor @x[$j+1],@t[1],@x[$j+1],lsr#8 +# ifdef __thumb2__ + itt hs +# endif + ldrhsb @t[0],[r12,#-13] @ load more input + ldrhsb @t[1],[r12,#-9] + strb @x[$j+3],[r14,#-3] + eor @x[$j+2],@t[2],@x[$j+2],lsr#8 + strb @x[$j+0],[r14,#-14] + eor @x[$j+3],@t[3],@x[$j+3],lsr#8 +# ifdef __thumb2__ + itt hs +# endif + ldrhsb @t[2],[r12,#-5] + ldrhsb @t[3],[r12,#-1] + strb @x[$j+1],[r14,#-10] + strb @x[$j+2],[r14,#-6] + eor @x[$j+0],@t[0],@x[$j+0],lsr#8 + strb @x[$j+3],[r14,#-2] + eor @x[$j+1],@t[1],@x[$j+1],lsr#8 + strb @x[$j+0],[r14,#-13] + eor @x[$j+2],@t[2],@x[$j+2],lsr#8 + strb @x[$j+1],[r14,#-9] + eor @x[$j+3],@t[3],@x[$j+3],lsr#8 + strb @x[$j+2],[r14,#-5] + strb @x[$j+3],[r14,#-1] +___ +$code.=<<___ if ($i<12); + add @t[0],sp,#4*(4+$i) + ldmia @t[0],{@t[0]-@t[3]} @ load key material +___ +} +$code.=<<___; +# ifdef __thumb2__ + it ne +# endif + ldrne @t[0],[sp,#4*(32+2)] @ re-load len +# ifdef __thumb2__ + it hs +# endif + subhs @t[3],@t[0],#64 @ len-=64 + bhi .Loop_outer + + beq .Ldone +#endif + +.Ltail: + ldr r12,[sp,#4*(32+1)] @ load inp + add @t[1],sp,#4*(0) + ldr r14,[sp,#4*(32+0)] @ load out + +.Loop_tail: + ldrb @t[2],[@t[1]],#1 @ read buffer on stack + ldrb @t[3],[r12],#1 @ read input + subs @t[0],@t[0],#1 + eor @t[3],@t[3],@t[2] + strb @t[3],[r14],#1 @ store output + bne .Loop_tail + +.Ldone: + add sp,sp,#4*(32+3) + ldmia sp!,{r4-r11,pc} +.size ChaCha20_ctr32_nohw,.-ChaCha20_ctr32_nohw +___ + +{{{ +my ($a0,$b0,$c0,$d0,$a1,$b1,$c1,$d1,$a2,$b2,$c2,$d2,$t0,$t1,$t2,$t3) = + map("q$_",(0..15)); + +sub NEONROUND { +my $odd = pop; +my ($a,$b,$c,$d,$t)=@_; + + ( + "&vadd_i32 ($a,$a,$b)", + "&veor ($d,$d,$a)", + "&vrev32_16 ($d,$d)", # vrot ($d,16) + + "&vadd_i32 ($c,$c,$d)", + "&veor ($t,$b,$c)", + "&vshr_u32 ($b,$t,20)", + "&vsli_32 ($b,$t,12)", + + "&vadd_i32 ($a,$a,$b)", + "&veor ($t,$d,$a)", + "&vshr_u32 ($d,$t,24)", + "&vsli_32 ($d,$t,8)", + + "&vadd_i32 ($c,$c,$d)", + "&veor ($t,$b,$c)", + "&vshr_u32 ($b,$t,25)", + "&vsli_32 ($b,$t,7)", + + "&vext_8 ($c,$c,$c,8)", + "&vext_8 ($b,$b,$b,$odd?12:4)", + "&vext_8 ($d,$d,$d,$odd?4:12)" + ); +} + +$code.=<<___; +#if __ARM_MAX_ARCH__>=7 +.arch armv7-a +.fpu neon + +.globl ChaCha20_ctr32_neon +.type ChaCha20_ctr32_neon,%function +.align 5 +ChaCha20_ctr32_neon: + ldr r12,[sp,#0] @ pull pointer to counter and nonce + stmdb sp!,{r0-r2,r4-r11,lr} + adr r14,.Lsigma + vstmdb sp!,{d8-d15} @ ABI spec says so + stmdb sp!,{r0-r3} + + vld1.32 {$b0-$c0},[r3] @ load key + ldmia r3,{r4-r11} @ load key + + sub sp,sp,#4*(16+16) + vld1.32 {$d0},[r12] @ load counter and nonce + add r12,sp,#4*8 + ldmia r14,{r0-r3} @ load sigma + vld1.32 {$a0},[r14]! @ load sigma + vld1.32 {$t0},[r14] @ one + vst1.32 {$c0-$d0},[r12] @ copy 1/2key|counter|nonce + vst1.32 {$a0-$b0},[sp] @ copy sigma|1/2key + + str r10,[sp,#4*(16+10)] @ off-load "@x[10]" + str r11,[sp,#4*(16+11)] @ off-load "@x[11]" + vshl.i32 $t1#lo,$t0#lo,#1 @ two + vstr $t0#lo,[sp,#4*(16+0)] + vshl.i32 $t2#lo,$t0#lo,#2 @ four + vstr $t1#lo,[sp,#4*(16+2)] + vmov $a1,$a0 + vstr $t2#lo,[sp,#4*(16+4)] + vmov $a2,$a0 + vmov $b1,$b0 + vmov $b2,$b0 + b .Loop_neon_enter + +.align 4 +.Loop_neon_outer: + ldmia sp,{r0-r9} @ load key material + cmp @t[3],#64*2 @ if len<=64*2 + bls .Lbreak_neon @ switch to integer-only + vmov $a1,$a0 + str @t[3],[sp,#4*(32+2)] @ save len + vmov $a2,$a0 + str r12, [sp,#4*(32+1)] @ save inp + vmov $b1,$b0 + str r14, [sp,#4*(32+0)] @ save out + vmov $b2,$b0 +.Loop_neon_enter: + ldr @t[3], [sp,#4*(15)] + vadd.i32 $d1,$d0,$t0 @ counter+1 + ldr @x[12],[sp,#4*(12)] @ modulo-scheduled load + vmov $c1,$c0 + ldr @t[2], [sp,#4*(13)] + vmov $c2,$c0 + ldr @x[14],[sp,#4*(14)] + vadd.i32 $d2,$d1,$t0 @ counter+2 + str @t[3], [sp,#4*(16+15)] + mov @t[3],#10 + add @x[12],@x[12],#3 @ counter+3 + b .Loop_neon + +.align 4 +.Loop_neon: + subs @t[3],@t[3],#1 +___ + my @thread0=&NEONROUND($a0,$b0,$c0,$d0,$t0,0); + my @thread1=&NEONROUND($a1,$b1,$c1,$d1,$t1,0); + my @thread2=&NEONROUND($a2,$b2,$c2,$d2,$t2,0); + my @thread3=&ROUND(0,4,8,12); + + foreach (@thread0) { + eval; eval(shift(@thread3)); + eval(shift(@thread1)); eval(shift(@thread3)); + eval(shift(@thread2)); eval(shift(@thread3)); + } + + @thread0=&NEONROUND($a0,$b0,$c0,$d0,$t0,1); + @thread1=&NEONROUND($a1,$b1,$c1,$d1,$t1,1); + @thread2=&NEONROUND($a2,$b2,$c2,$d2,$t2,1); + @thread3=&ROUND(0,5,10,15); + + foreach (@thread0) { + eval; eval(shift(@thread3)); + eval(shift(@thread1)); eval(shift(@thread3)); + eval(shift(@thread2)); eval(shift(@thread3)); + } +$code.=<<___; + bne .Loop_neon + + add @t[3],sp,#32 + vld1.32 {$t0-$t1},[sp] @ load key material + vld1.32 {$t2-$t3},[@t[3]] + + ldr @t[3],[sp,#4*(32+2)] @ load len + + str @t[0], [sp,#4*(16+8)] @ modulo-scheduled store + str @t[1], [sp,#4*(16+9)] + str @x[12],[sp,#4*(16+12)] + str @t[2], [sp,#4*(16+13)] + str @x[14],[sp,#4*(16+14)] + + @ at this point we have first half of 512-bit result in + @ @x[0-7] and second half at sp+4*(16+8) + + ldr r12,[sp,#4*(32+1)] @ load inp + ldr r14,[sp,#4*(32+0)] @ load out + + vadd.i32 $a0,$a0,$t0 @ accumulate key material + vadd.i32 $a1,$a1,$t0 + vadd.i32 $a2,$a2,$t0 + vldr $t0#lo,[sp,#4*(16+0)] @ one + + vadd.i32 $b0,$b0,$t1 + vadd.i32 $b1,$b1,$t1 + vadd.i32 $b2,$b2,$t1 + vldr $t1#lo,[sp,#4*(16+2)] @ two + + vadd.i32 $c0,$c0,$t2 + vadd.i32 $c1,$c1,$t2 + vadd.i32 $c2,$c2,$t2 + vadd.i32 $d1#lo,$d1#lo,$t0#lo @ counter+1 + vadd.i32 $d2#lo,$d2#lo,$t1#lo @ counter+2 + + vadd.i32 $d0,$d0,$t3 + vadd.i32 $d1,$d1,$t3 + vadd.i32 $d2,$d2,$t3 + + cmp @t[3],#64*4 + blo .Ltail_neon + + vld1.8 {$t0-$t1},[r12]! @ load input + mov @t[3],sp + vld1.8 {$t2-$t3},[r12]! + veor $a0,$a0,$t0 @ xor with input + veor $b0,$b0,$t1 + vld1.8 {$t0-$t1},[r12]! + veor $c0,$c0,$t2 + veor $d0,$d0,$t3 + vld1.8 {$t2-$t3},[r12]! + + veor $a1,$a1,$t0 + vst1.8 {$a0-$b0},[r14]! @ store output + veor $b1,$b1,$t1 + vld1.8 {$t0-$t1},[r12]! + veor $c1,$c1,$t2 + vst1.8 {$c0-$d0},[r14]! + veor $d1,$d1,$t3 + vld1.8 {$t2-$t3},[r12]! + + veor $a2,$a2,$t0 + vld1.32 {$a0-$b0},[@t[3]]! @ load for next iteration + veor $t0#hi,$t0#hi,$t0#hi + vldr $t0#lo,[sp,#4*(16+4)] @ four + veor $b2,$b2,$t1 + vld1.32 {$c0-$d0},[@t[3]] + veor $c2,$c2,$t2 + vst1.8 {$a1-$b1},[r14]! + veor $d2,$d2,$t3 + vst1.8 {$c1-$d1},[r14]! + + vadd.i32 $d0#lo,$d0#lo,$t0#lo @ next counter value + vldr $t0#lo,[sp,#4*(16+0)] @ one + + ldmia sp,{@t[0]-@t[3]} @ load key material + add @x[0],@x[0],@t[0] @ accumulate key material + ldr @t[0],[r12],#16 @ load input + vst1.8 {$a2-$b2},[r14]! + add @x[1],@x[1],@t[1] + ldr @t[1],[r12,#-12] + vst1.8 {$c2-$d2},[r14]! + add @x[2],@x[2],@t[2] + ldr @t[2],[r12,#-8] + add @x[3],@x[3],@t[3] + ldr @t[3],[r12,#-4] +# ifdef __ARMEB__ + rev @x[0],@x[0] + rev @x[1],@x[1] + rev @x[2],@x[2] + rev @x[3],@x[3] +# endif + eor @x[0],@x[0],@t[0] @ xor with input + add @t[0],sp,#4*(4) + eor @x[1],@x[1],@t[1] + str @x[0],[r14],#16 @ store output + eor @x[2],@x[2],@t[2] + str @x[1],[r14,#-12] + eor @x[3],@x[3],@t[3] + ldmia @t[0],{@t[0]-@t[3]} @ load key material + str @x[2],[r14,#-8] + str @x[3],[r14,#-4] + + add @x[4],@x[4],@t[0] @ accumulate key material + ldr @t[0],[r12],#16 @ load input + add @x[5],@x[5],@t[1] + ldr @t[1],[r12,#-12] + add @x[6],@x[6],@t[2] + ldr @t[2],[r12,#-8] + add @x[7],@x[7],@t[3] + ldr @t[3],[r12,#-4] +# ifdef __ARMEB__ + rev @x[4],@x[4] + rev @x[5],@x[5] + rev @x[6],@x[6] + rev @x[7],@x[7] +# endif + eor @x[4],@x[4],@t[0] + add @t[0],sp,#4*(8) + eor @x[5],@x[5],@t[1] + str @x[4],[r14],#16 @ store output + eor @x[6],@x[6],@t[2] + str @x[5],[r14,#-12] + eor @x[7],@x[7],@t[3] + ldmia @t[0],{@t[0]-@t[3]} @ load key material + str @x[6],[r14,#-8] + add @x[0],sp,#4*(16+8) + str @x[7],[r14,#-4] + + ldmia @x[0],{@x[0]-@x[7]} @ load second half + + add @x[0],@x[0],@t[0] @ accumulate key material + ldr @t[0],[r12],#16 @ load input + add @x[1],@x[1],@t[1] + ldr @t[1],[r12,#-12] +# ifdef __thumb2__ + it hi +# endif + strhi @t[2],[sp,#4*(16+10)] @ copy "@x[10]" while at it + add @x[2],@x[2],@t[2] + ldr @t[2],[r12,#-8] +# ifdef __thumb2__ + it hi +# endif + strhi @t[3],[sp,#4*(16+11)] @ copy "@x[11]" while at it + add @x[3],@x[3],@t[3] + ldr @t[3],[r12,#-4] +# ifdef __ARMEB__ + rev @x[0],@x[0] + rev @x[1],@x[1] + rev @x[2],@x[2] + rev @x[3],@x[3] +# endif + eor @x[0],@x[0],@t[0] + add @t[0],sp,#4*(12) + eor @x[1],@x[1],@t[1] + str @x[0],[r14],#16 @ store output + eor @x[2],@x[2],@t[2] + str @x[1],[r14,#-12] + eor @x[3],@x[3],@t[3] + ldmia @t[0],{@t[0]-@t[3]} @ load key material + str @x[2],[r14,#-8] + str @x[3],[r14,#-4] + + add @x[4],@x[4],@t[0] @ accumulate key material + add @t[0],@t[0],#4 @ next counter value + add @x[5],@x[5],@t[1] + str @t[0],[sp,#4*(12)] @ save next counter value + ldr @t[0],[r12],#16 @ load input + add @x[6],@x[6],@t[2] + add @x[4],@x[4],#3 @ counter+3 + ldr @t[1],[r12,#-12] + add @x[7],@x[7],@t[3] + ldr @t[2],[r12,#-8] + ldr @t[3],[r12,#-4] +# ifdef __ARMEB__ + rev @x[4],@x[4] + rev @x[5],@x[5] + rev @x[6],@x[6] + rev @x[7],@x[7] +# endif + eor @x[4],@x[4],@t[0] +# ifdef __thumb2__ + it hi +# endif + ldrhi @t[0],[sp,#4*(32+2)] @ re-load len + eor @x[5],@x[5],@t[1] + eor @x[6],@x[6],@t[2] + str @x[4],[r14],#16 @ store output + eor @x[7],@x[7],@t[3] + str @x[5],[r14,#-12] + sub @t[3],@t[0],#64*4 @ len-=64*4 + str @x[6],[r14,#-8] + str @x[7],[r14,#-4] + bhi .Loop_neon_outer + + b .Ldone_neon + +.align 4 +.Lbreak_neon: + @ harmonize NEON and integer-only stack frames: load data + @ from NEON frame, but save to integer-only one; distance + @ between the two is 4*(32+4+16-32)=4*(20). + + str @t[3], [sp,#4*(20+32+2)] @ save len + add @t[3],sp,#4*(32+4) + str r12, [sp,#4*(20+32+1)] @ save inp + str r14, [sp,#4*(20+32+0)] @ save out + + ldr @x[12],[sp,#4*(16+10)] + ldr @x[14],[sp,#4*(16+11)] + vldmia @t[3],{d8-d15} @ fulfill ABI requirement + str @x[12],[sp,#4*(20+16+10)] @ copy "@x[10]" + str @x[14],[sp,#4*(20+16+11)] @ copy "@x[11]" + + ldr @t[3], [sp,#4*(15)] + ldr @x[12],[sp,#4*(12)] @ modulo-scheduled load + ldr @t[2], [sp,#4*(13)] + ldr @x[14],[sp,#4*(14)] + str @t[3], [sp,#4*(20+16+15)] + add @t[3],sp,#4*(20) + vst1.32 {$a0-$b0},[@t[3]]! @ copy key + add sp,sp,#4*(20) @ switch frame + vst1.32 {$c0-$d0},[@t[3]] + mov @t[3],#10 + b .Loop @ go integer-only + +.align 4 +.Ltail_neon: + cmp @t[3],#64*3 + bhs .L192_or_more_neon + cmp @t[3],#64*2 + bhs .L128_or_more_neon + cmp @t[3],#64*1 + bhs .L64_or_more_neon + + add @t[0],sp,#4*(8) + vst1.8 {$a0-$b0},[sp] + add @t[2],sp,#4*(0) + vst1.8 {$c0-$d0},[@t[0]] + b .Loop_tail_neon + +.align 4 +.L64_or_more_neon: + vld1.8 {$t0-$t1},[r12]! + vld1.8 {$t2-$t3},[r12]! + veor $a0,$a0,$t0 + veor $b0,$b0,$t1 + veor $c0,$c0,$t2 + veor $d0,$d0,$t3 + vst1.8 {$a0-$b0},[r14]! + vst1.8 {$c0-$d0},[r14]! + + beq .Ldone_neon + + add @t[0],sp,#4*(8) + vst1.8 {$a1-$b1},[sp] + add @t[2],sp,#4*(0) + vst1.8 {$c1-$d1},[@t[0]] + sub @t[3],@t[3],#64*1 @ len-=64*1 + b .Loop_tail_neon + +.align 4 +.L128_or_more_neon: + vld1.8 {$t0-$t1},[r12]! + vld1.8 {$t2-$t3},[r12]! + veor $a0,$a0,$t0 + veor $b0,$b0,$t1 + vld1.8 {$t0-$t1},[r12]! + veor $c0,$c0,$t2 + veor $d0,$d0,$t3 + vld1.8 {$t2-$t3},[r12]! + + veor $a1,$a1,$t0 + veor $b1,$b1,$t1 + vst1.8 {$a0-$b0},[r14]! + veor $c1,$c1,$t2 + vst1.8 {$c0-$d0},[r14]! + veor $d1,$d1,$t3 + vst1.8 {$a1-$b1},[r14]! + vst1.8 {$c1-$d1},[r14]! + + beq .Ldone_neon + + add @t[0],sp,#4*(8) + vst1.8 {$a2-$b2},[sp] + add @t[2],sp,#4*(0) + vst1.8 {$c2-$d2},[@t[0]] + sub @t[3],@t[3],#64*2 @ len-=64*2 + b .Loop_tail_neon + +.align 4 +.L192_or_more_neon: + vld1.8 {$t0-$t1},[r12]! + vld1.8 {$t2-$t3},[r12]! + veor $a0,$a0,$t0 + veor $b0,$b0,$t1 + vld1.8 {$t0-$t1},[r12]! + veor $c0,$c0,$t2 + veor $d0,$d0,$t3 + vld1.8 {$t2-$t3},[r12]! + + veor $a1,$a1,$t0 + veor $b1,$b1,$t1 + vld1.8 {$t0-$t1},[r12]! + veor $c1,$c1,$t2 + vst1.8 {$a0-$b0},[r14]! + veor $d1,$d1,$t3 + vld1.8 {$t2-$t3},[r12]! + + veor $a2,$a2,$t0 + vst1.8 {$c0-$d0},[r14]! + veor $b2,$b2,$t1 + vst1.8 {$a1-$b1},[r14]! + veor $c2,$c2,$t2 + vst1.8 {$c1-$d1},[r14]! + veor $d2,$d2,$t3 + vst1.8 {$a2-$b2},[r14]! + vst1.8 {$c2-$d2},[r14]! + + beq .Ldone_neon + + ldmia sp,{@t[0]-@t[3]} @ load key material + add @x[0],@x[0],@t[0] @ accumulate key material + add @t[0],sp,#4*(4) + add @x[1],@x[1],@t[1] + add @x[2],@x[2],@t[2] + add @x[3],@x[3],@t[3] + ldmia @t[0],{@t[0]-@t[3]} @ load key material + + add @x[4],@x[4],@t[0] @ accumulate key material + add @t[0],sp,#4*(8) + add @x[5],@x[5],@t[1] + add @x[6],@x[6],@t[2] + add @x[7],@x[7],@t[3] + ldmia @t[0],{@t[0]-@t[3]} @ load key material +# ifdef __ARMEB__ + rev @x[0],@x[0] + rev @x[1],@x[1] + rev @x[2],@x[2] + rev @x[3],@x[3] + rev @x[4],@x[4] + rev @x[5],@x[5] + rev @x[6],@x[6] + rev @x[7],@x[7] +# endif + stmia sp,{@x[0]-@x[7]} + add @x[0],sp,#4*(16+8) + + ldmia @x[0],{@x[0]-@x[7]} @ load second half + + add @x[0],@x[0],@t[0] @ accumulate key material + add @t[0],sp,#4*(12) + add @x[1],@x[1],@t[1] + add @x[2],@x[2],@t[2] + add @x[3],@x[3],@t[3] + ldmia @t[0],{@t[0]-@t[3]} @ load key material + + add @x[4],@x[4],@t[0] @ accumulate key material + add @t[0],sp,#4*(8) + add @x[5],@x[5],@t[1] + add @x[4],@x[4],#3 @ counter+3 + add @x[6],@x[6],@t[2] + add @x[7],@x[7],@t[3] + ldr @t[3],[sp,#4*(32+2)] @ re-load len +# ifdef __ARMEB__ + rev @x[0],@x[0] + rev @x[1],@x[1] + rev @x[2],@x[2] + rev @x[3],@x[3] + rev @x[4],@x[4] + rev @x[5],@x[5] + rev @x[6],@x[6] + rev @x[7],@x[7] +# endif + stmia @t[0],{@x[0]-@x[7]} + add @t[2],sp,#4*(0) + sub @t[3],@t[3],#64*3 @ len-=64*3 + +.Loop_tail_neon: + ldrb @t[0],[@t[2]],#1 @ read buffer on stack + ldrb @t[1],[r12],#1 @ read input + subs @t[3],@t[3],#1 + eor @t[0],@t[0],@t[1] + strb @t[0],[r14],#1 @ store output + bne .Loop_tail_neon + +.Ldone_neon: + add sp,sp,#4*(32+4) + vldmia sp,{d8-d15} + add sp,sp,#4*(16+3) + ldmia sp!,{r4-r11,pc} +.size ChaCha20_ctr32_neon,.-ChaCha20_ctr32_neon +#endif +___ +}}} + +foreach (split("\n",$code)) { + s/\`([^\`]*)\`/eval $1/geo; + + s/\bq([0-9]+)#(lo|hi)/sprintf "d%d",2*$1+($2 eq "hi")/geo; + + print $_,"\n"; +} +close STDOUT or die "error closing STDOUT: $!"; diff --git a/http/vendor/ring/crypto/chacha/asm/chacha-armv8.pl b/http/vendor/ring/crypto/chacha/asm/chacha-armv8.pl new file mode 100644 index 0000000..8f2fe30 --- /dev/null +++ b/http/vendor/ring/crypto/chacha/asm/chacha-armv8.pl @@ -0,0 +1,1130 @@ +#! /usr/bin/env perl +# Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# ==================================================================== +# Written by Andy Polyakov for the OpenSSL +# project. +# ==================================================================== +# +# June 2015 +# +# ChaCha20 for ARMv8. +# +# Performance in cycles per byte out of large buffer. +# +# IALU/gcc-4.9 3xNEON+1xIALU 6xNEON+2xIALU +# +# Apple A7 5.50/+49% 3.33 1.70 +# Cortex-A53 8.40/+80% 4.72 4.72(*) +# Cortex-A57 8.06/+43% 4.90 4.43(**) +# Denver 4.50/+82% 2.63 2.67(*) +# X-Gene 9.50/+46% 8.82 8.89(*) +# Mongoose 8.00/+44% 3.64 3.25 +# Kryo 8.17/+50% 4.83 4.65 +# +# (*) it's expected that doubling interleave factor doesn't help +# all processors, only those with higher NEON latency and +# higher instruction issue rate; +# (**) expected improvement was actually higher; + +$flavour=shift; +$output=shift; + +$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; +( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or +( $xlate="${dir}../../perlasm/arm-xlate.pl" and -f $xlate) or +die "can't locate arm-xlate.pl"; + +open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""; +*STDOUT=*OUT; + +sub AUTOLOAD() # thunk [simplified] x86-style perlasm +{ my $opcode = $AUTOLOAD; $opcode =~ s/.*:://; $opcode =~ s/_/\./; + my $arg = pop; + $arg = "#$arg" if ($arg*1 eq $arg); + $code .= "\t$opcode\t".join(',',@_,$arg)."\n"; +} + +my ($out,$inp,$len,$key,$ctr) = map("x$_",(0..4)); + +my @x=map("x$_",(5..17,19..21)); +my @d=map("x$_",(22..28,30)); + +sub ROUND { +my ($a0,$b0,$c0,$d0)=@_; +my ($a1,$b1,$c1,$d1)=map(($_&~3)+(($_+1)&3),($a0,$b0,$c0,$d0)); +my ($a2,$b2,$c2,$d2)=map(($_&~3)+(($_+1)&3),($a1,$b1,$c1,$d1)); +my ($a3,$b3,$c3,$d3)=map(($_&~3)+(($_+1)&3),($a2,$b2,$c2,$d2)); + + ( + "&add_32 (@x[$a0],@x[$a0],@x[$b0])", + "&add_32 (@x[$a1],@x[$a1],@x[$b1])", + "&add_32 (@x[$a2],@x[$a2],@x[$b2])", + "&add_32 (@x[$a3],@x[$a3],@x[$b3])", + "&eor_32 (@x[$d0],@x[$d0],@x[$a0])", + "&eor_32 (@x[$d1],@x[$d1],@x[$a1])", + "&eor_32 (@x[$d2],@x[$d2],@x[$a2])", + "&eor_32 (@x[$d3],@x[$d3],@x[$a3])", + "&ror_32 (@x[$d0],@x[$d0],16)", + "&ror_32 (@x[$d1],@x[$d1],16)", + "&ror_32 (@x[$d2],@x[$d2],16)", + "&ror_32 (@x[$d3],@x[$d3],16)", + + "&add_32 (@x[$c0],@x[$c0],@x[$d0])", + "&add_32 (@x[$c1],@x[$c1],@x[$d1])", + "&add_32 (@x[$c2],@x[$c2],@x[$d2])", + "&add_32 (@x[$c3],@x[$c3],@x[$d3])", + "&eor_32 (@x[$b0],@x[$b0],@x[$c0])", + "&eor_32 (@x[$b1],@x[$b1],@x[$c1])", + "&eor_32 (@x[$b2],@x[$b2],@x[$c2])", + "&eor_32 (@x[$b3],@x[$b3],@x[$c3])", + "&ror_32 (@x[$b0],@x[$b0],20)", + "&ror_32 (@x[$b1],@x[$b1],20)", + "&ror_32 (@x[$b2],@x[$b2],20)", + "&ror_32 (@x[$b3],@x[$b3],20)", + + "&add_32 (@x[$a0],@x[$a0],@x[$b0])", + "&add_32 (@x[$a1],@x[$a1],@x[$b1])", + "&add_32 (@x[$a2],@x[$a2],@x[$b2])", + "&add_32 (@x[$a3],@x[$a3],@x[$b3])", + "&eor_32 (@x[$d0],@x[$d0],@x[$a0])", + "&eor_32 (@x[$d1],@x[$d1],@x[$a1])", + "&eor_32 (@x[$d2],@x[$d2],@x[$a2])", + "&eor_32 (@x[$d3],@x[$d3],@x[$a3])", + "&ror_32 (@x[$d0],@x[$d0],24)", + "&ror_32 (@x[$d1],@x[$d1],24)", + "&ror_32 (@x[$d2],@x[$d2],24)", + "&ror_32 (@x[$d3],@x[$d3],24)", + + "&add_32 (@x[$c0],@x[$c0],@x[$d0])", + "&add_32 (@x[$c1],@x[$c1],@x[$d1])", + "&add_32 (@x[$c2],@x[$c2],@x[$d2])", + "&add_32 (@x[$c3],@x[$c3],@x[$d3])", + "&eor_32 (@x[$b0],@x[$b0],@x[$c0])", + "&eor_32 (@x[$b1],@x[$b1],@x[$c1])", + "&eor_32 (@x[$b2],@x[$b2],@x[$c2])", + "&eor_32 (@x[$b3],@x[$b3],@x[$c3])", + "&ror_32 (@x[$b0],@x[$b0],25)", + "&ror_32 (@x[$b1],@x[$b1],25)", + "&ror_32 (@x[$b2],@x[$b2],25)", + "&ror_32 (@x[$b3],@x[$b3],25)" + ); +} + +$code.=<<___; +.section .rodata + +.align 5 +.Lsigma: +.quad 0x3320646e61707865,0x6b20657479622d32 // endian-neutral +.Lone: +.long 1,0,0,0 +.asciz "ChaCha20 for ARMv8, CRYPTOGAMS by " + +.text + +.globl ChaCha20_ctr32_nohw +.type ChaCha20_ctr32_nohw,%function +.align 5 +ChaCha20_ctr32_nohw: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-96]! + add x29,sp,#0 + + adrp @x[0],:pg_hi21:.Lsigma + add @x[0],@x[0],:lo12:.Lsigma + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + stp x27,x28,[sp,#80] + sub sp,sp,#64 + + ldp @d[0],@d[1],[@x[0]] // load sigma + ldp @d[2],@d[3],[$key] // load key + ldp @d[4],@d[5],[$key,#16] + ldp @d[6],@d[7],[$ctr] // load counter +#ifdef __AARCH64EB__ + ror @d[2],@d[2],#32 + ror @d[3],@d[3],#32 + ror @d[4],@d[4],#32 + ror @d[5],@d[5],#32 + ror @d[6],@d[6],#32 + ror @d[7],@d[7],#32 +#endif + +.Loop_outer: + mov.32 @x[0],@d[0] // unpack key block + lsr @x[1],@d[0],#32 + mov.32 @x[2],@d[1] + lsr @x[3],@d[1],#32 + mov.32 @x[4],@d[2] + lsr @x[5],@d[2],#32 + mov.32 @x[6],@d[3] + lsr @x[7],@d[3],#32 + mov.32 @x[8],@d[4] + lsr @x[9],@d[4],#32 + mov.32 @x[10],@d[5] + lsr @x[11],@d[5],#32 + mov.32 @x[12],@d[6] + lsr @x[13],@d[6],#32 + mov.32 @x[14],@d[7] + lsr @x[15],@d[7],#32 + + mov $ctr,#10 + subs $len,$len,#64 +.Loop: + sub $ctr,$ctr,#1 +___ + foreach (&ROUND(0, 4, 8,12)) { eval; } + foreach (&ROUND(0, 5,10,15)) { eval; } +$code.=<<___; + cbnz $ctr,.Loop + + add.32 @x[0],@x[0],@d[0] // accumulate key block + add @x[1],@x[1],@d[0],lsr#32 + add.32 @x[2],@x[2],@d[1] + add @x[3],@x[3],@d[1],lsr#32 + add.32 @x[4],@x[4],@d[2] + add @x[5],@x[5],@d[2],lsr#32 + add.32 @x[6],@x[6],@d[3] + add @x[7],@x[7],@d[3],lsr#32 + add.32 @x[8],@x[8],@d[4] + add @x[9],@x[9],@d[4],lsr#32 + add.32 @x[10],@x[10],@d[5] + add @x[11],@x[11],@d[5],lsr#32 + add.32 @x[12],@x[12],@d[6] + add @x[13],@x[13],@d[6],lsr#32 + add.32 @x[14],@x[14],@d[7] + add @x[15],@x[15],@d[7],lsr#32 + + b.lo .Ltail + + add @x[0],@x[0],@x[1],lsl#32 // pack + add @x[2],@x[2],@x[3],lsl#32 + ldp @x[1],@x[3],[$inp,#0] // load input + add @x[4],@x[4],@x[5],lsl#32 + add @x[6],@x[6],@x[7],lsl#32 + ldp @x[5],@x[7],[$inp,#16] + add @x[8],@x[8],@x[9],lsl#32 + add @x[10],@x[10],@x[11],lsl#32 + ldp @x[9],@x[11],[$inp,#32] + add @x[12],@x[12],@x[13],lsl#32 + add @x[14],@x[14],@x[15],lsl#32 + ldp @x[13],@x[15],[$inp,#48] + add $inp,$inp,#64 +#ifdef __AARCH64EB__ + rev @x[0],@x[0] + rev @x[2],@x[2] + rev @x[4],@x[4] + rev @x[6],@x[6] + rev @x[8],@x[8] + rev @x[10],@x[10] + rev @x[12],@x[12] + rev @x[14],@x[14] +#endif + eor @x[0],@x[0],@x[1] + eor @x[2],@x[2],@x[3] + eor @x[4],@x[4],@x[5] + eor @x[6],@x[6],@x[7] + eor @x[8],@x[8],@x[9] + eor @x[10],@x[10],@x[11] + eor @x[12],@x[12],@x[13] + eor @x[14],@x[14],@x[15] + + stp @x[0],@x[2],[$out,#0] // store output + add @d[6],@d[6],#1 // increment counter + stp @x[4],@x[6],[$out,#16] + stp @x[8],@x[10],[$out,#32] + stp @x[12],@x[14],[$out,#48] + add $out,$out,#64 + + b.hi .Loop_outer + + ldp x19,x20,[x29,#16] + add sp,sp,#64 + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldp x29,x30,[sp],#96 + AARCH64_VALIDATE_LINK_REGISTER + ret + +.align 4 +.Ltail: + add $len,$len,#64 +.Less_than_64: + sub $out,$out,#1 + add $inp,$inp,$len + add $out,$out,$len + add $ctr,sp,$len + neg $len,$len + + add @x[0],@x[0],@x[1],lsl#32 // pack + add @x[2],@x[2],@x[3],lsl#32 + add @x[4],@x[4],@x[5],lsl#32 + add @x[6],@x[6],@x[7],lsl#32 + add @x[8],@x[8],@x[9],lsl#32 + add @x[10],@x[10],@x[11],lsl#32 + add @x[12],@x[12],@x[13],lsl#32 + add @x[14],@x[14],@x[15],lsl#32 +#ifdef __AARCH64EB__ + rev @x[0],@x[0] + rev @x[2],@x[2] + rev @x[4],@x[4] + rev @x[6],@x[6] + rev @x[8],@x[8] + rev @x[10],@x[10] + rev @x[12],@x[12] + rev @x[14],@x[14] +#endif + stp @x[0],@x[2],[sp,#0] + stp @x[4],@x[6],[sp,#16] + stp @x[8],@x[10],[sp,#32] + stp @x[12],@x[14],[sp,#48] + +.Loop_tail: + ldrb w10,[$inp,$len] + ldrb w11,[$ctr,$len] + add $len,$len,#1 + eor w10,w10,w11 + strb w10,[$out,$len] + cbnz $len,.Loop_tail + + stp xzr,xzr,[sp,#0] + stp xzr,xzr,[sp,#16] + stp xzr,xzr,[sp,#32] + stp xzr,xzr,[sp,#48] + + ldp x19,x20,[x29,#16] + add sp,sp,#64 + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldp x29,x30,[sp],#96 + AARCH64_VALIDATE_LINK_REGISTER + ret +.size ChaCha20_ctr32_nohw,.-ChaCha20_ctr32_nohw +___ + +{{{ +my ($A0,$B0,$C0,$D0,$A1,$B1,$C1,$D1,$A2,$B2,$C2,$D2,$T0,$T1,$T2,$T3) = + map("v$_.4s",(0..7,16..23)); +my (@K)=map("v$_.4s",(24..30)); +my $ONE="v31.4s"; + +sub NEONROUND { +my $odd = pop; +my ($a,$b,$c,$d,$t)=@_; + + ( + "&add ('$a','$a','$b')", + "&eor ('$d','$d','$a')", + "&rev32_16 ('$d','$d')", # vrot ($d,16) + + "&add ('$c','$c','$d')", + "&eor ('$t','$b','$c')", + "&ushr ('$b','$t',20)", + "&sli ('$b','$t',12)", + + "&add ('$a','$a','$b')", + "&eor ('$t','$d','$a')", + "&ushr ('$d','$t',24)", + "&sli ('$d','$t',8)", + + "&add ('$c','$c','$d')", + "&eor ('$t','$b','$c')", + "&ushr ('$b','$t',25)", + "&sli ('$b','$t',7)", + + "&ext ('$c','$c','$c',8)", + "&ext ('$d','$d','$d',$odd?4:12)", + "&ext ('$b','$b','$b',$odd?12:4)" + ); +} + +$code.=<<___; + +.globl ChaCha20_ctr32_neon +.type ChaCha20_ctr32_neon,%function +.align 5 +ChaCha20_ctr32_neon: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-96]! + add x29,sp,#0 + + adrp @x[0],:pg_hi21:.Lsigma + add @x[0],@x[0],:lo12:.Lsigma + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + stp x27,x28,[sp,#80] + cmp $len,#512 + b.hs .L512_or_more_neon + + sub sp,sp,#64 + + ldp @d[0],@d[1],[@x[0]] // load sigma + ld1 {@K[0]},[@x[0]],#16 + ldp @d[2],@d[3],[$key] // load key + ldp @d[4],@d[5],[$key,#16] + ld1 {@K[1],@K[2]},[$key] + ldp @d[6],@d[7],[$ctr] // load counter + ld1 {@K[3]},[$ctr] + ld1 {$ONE},[@x[0]] +#ifdef __AARCH64EB__ + rev64 @K[0],@K[0] + ror @d[2],@d[2],#32 + ror @d[3],@d[3],#32 + ror @d[4],@d[4],#32 + ror @d[5],@d[5],#32 + ror @d[6],@d[6],#32 + ror @d[7],@d[7],#32 +#endif + add @K[3],@K[3],$ONE // += 1 + add @K[4],@K[3],$ONE + add @K[5],@K[4],$ONE + shl $ONE,$ONE,#2 // 1 -> 4 + +.Loop_outer_neon: + mov.32 @x[0],@d[0] // unpack key block + lsr @x[1],@d[0],#32 + mov $A0,@K[0] + mov.32 @x[2],@d[1] + lsr @x[3],@d[1],#32 + mov $A1,@K[0] + mov.32 @x[4],@d[2] + lsr @x[5],@d[2],#32 + mov $A2,@K[0] + mov.32 @x[6],@d[3] + mov $B0,@K[1] + lsr @x[7],@d[3],#32 + mov $B1,@K[1] + mov.32 @x[8],@d[4] + mov $B2,@K[1] + lsr @x[9],@d[4],#32 + mov $D0,@K[3] + mov.32 @x[10],@d[5] + mov $D1,@K[4] + lsr @x[11],@d[5],#32 + mov $D2,@K[5] + mov.32 @x[12],@d[6] + mov $C0,@K[2] + lsr @x[13],@d[6],#32 + mov $C1,@K[2] + mov.32 @x[14],@d[7] + mov $C2,@K[2] + lsr @x[15],@d[7],#32 + + mov $ctr,#10 + subs $len,$len,#256 +.Loop_neon: + sub $ctr,$ctr,#1 +___ + my @thread0=&NEONROUND($A0,$B0,$C0,$D0,$T0,0); + my @thread1=&NEONROUND($A1,$B1,$C1,$D1,$T1,0); + my @thread2=&NEONROUND($A2,$B2,$C2,$D2,$T2,0); + my @thread3=&ROUND(0,4,8,12); + + foreach (@thread0) { + eval; eval(shift(@thread3)); + eval(shift(@thread1)); eval(shift(@thread3)); + eval(shift(@thread2)); eval(shift(@thread3)); + } + + @thread0=&NEONROUND($A0,$B0,$C0,$D0,$T0,1); + @thread1=&NEONROUND($A1,$B1,$C1,$D1,$T1,1); + @thread2=&NEONROUND($A2,$B2,$C2,$D2,$T2,1); + @thread3=&ROUND(0,5,10,15); + + foreach (@thread0) { + eval; eval(shift(@thread3)); + eval(shift(@thread1)); eval(shift(@thread3)); + eval(shift(@thread2)); eval(shift(@thread3)); + } +$code.=<<___; + cbnz $ctr,.Loop_neon + + add.32 @x[0],@x[0],@d[0] // accumulate key block + add $A0,$A0,@K[0] + add @x[1],@x[1],@d[0],lsr#32 + add $A1,$A1,@K[0] + add.32 @x[2],@x[2],@d[1] + add $A2,$A2,@K[0] + add @x[3],@x[3],@d[1],lsr#32 + add $C0,$C0,@K[2] + add.32 @x[4],@x[4],@d[2] + add $C1,$C1,@K[2] + add @x[5],@x[5],@d[2],lsr#32 + add $C2,$C2,@K[2] + add.32 @x[6],@x[6],@d[3] + add $D0,$D0,@K[3] + add @x[7],@x[7],@d[3],lsr#32 + add.32 @x[8],@x[8],@d[4] + add $D1,$D1,@K[4] + add @x[9],@x[9],@d[4],lsr#32 + add.32 @x[10],@x[10],@d[5] + add $D2,$D2,@K[5] + add @x[11],@x[11],@d[5],lsr#32 + add.32 @x[12],@x[12],@d[6] + add $B0,$B0,@K[1] + add @x[13],@x[13],@d[6],lsr#32 + add.32 @x[14],@x[14],@d[7] + add $B1,$B1,@K[1] + add @x[15],@x[15],@d[7],lsr#32 + add $B2,$B2,@K[1] + + b.lo .Ltail_neon + + add @x[0],@x[0],@x[1],lsl#32 // pack + add @x[2],@x[2],@x[3],lsl#32 + ldp @x[1],@x[3],[$inp,#0] // load input + add @x[4],@x[4],@x[5],lsl#32 + add @x[6],@x[6],@x[7],lsl#32 + ldp @x[5],@x[7],[$inp,#16] + add @x[8],@x[8],@x[9],lsl#32 + add @x[10],@x[10],@x[11],lsl#32 + ldp @x[9],@x[11],[$inp,#32] + add @x[12],@x[12],@x[13],lsl#32 + add @x[14],@x[14],@x[15],lsl#32 + ldp @x[13],@x[15],[$inp,#48] + add $inp,$inp,#64 +#ifdef __AARCH64EB__ + rev @x[0],@x[0] + rev @x[2],@x[2] + rev @x[4],@x[4] + rev @x[6],@x[6] + rev @x[8],@x[8] + rev @x[10],@x[10] + rev @x[12],@x[12] + rev @x[14],@x[14] +#endif + ld1.8 {$T0-$T3},[$inp],#64 + eor @x[0],@x[0],@x[1] + eor @x[2],@x[2],@x[3] + eor @x[4],@x[4],@x[5] + eor @x[6],@x[6],@x[7] + eor @x[8],@x[8],@x[9] + eor $A0,$A0,$T0 + eor @x[10],@x[10],@x[11] + eor $B0,$B0,$T1 + eor @x[12],@x[12],@x[13] + eor $C0,$C0,$T2 + eor @x[14],@x[14],@x[15] + eor $D0,$D0,$T3 + ld1.8 {$T0-$T3},[$inp],#64 + + stp @x[0],@x[2],[$out,#0] // store output + add @d[6],@d[6],#4 // increment counter + stp @x[4],@x[6],[$out,#16] + add @K[3],@K[3],$ONE // += 4 + stp @x[8],@x[10],[$out,#32] + add @K[4],@K[4],$ONE + stp @x[12],@x[14],[$out,#48] + add @K[5],@K[5],$ONE + add $out,$out,#64 + + st1.8 {$A0-$D0},[$out],#64 + ld1.8 {$A0-$D0},[$inp],#64 + + eor $A1,$A1,$T0 + eor $B1,$B1,$T1 + eor $C1,$C1,$T2 + eor $D1,$D1,$T3 + st1.8 {$A1-$D1},[$out],#64 + + eor $A2,$A2,$A0 + eor $B2,$B2,$B0 + eor $C2,$C2,$C0 + eor $D2,$D2,$D0 + st1.8 {$A2-$D2},[$out],#64 + + b.hi .Loop_outer_neon + + ldp x19,x20,[x29,#16] + add sp,sp,#64 + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldp x29,x30,[sp],#96 + AARCH64_VALIDATE_LINK_REGISTER + ret + +.Ltail_neon: + add $len,$len,#256 + cmp $len,#64 + b.lo .Less_than_64 + + add @x[0],@x[0],@x[1],lsl#32 // pack + add @x[2],@x[2],@x[3],lsl#32 + ldp @x[1],@x[3],[$inp,#0] // load input + add @x[4],@x[4],@x[5],lsl#32 + add @x[6],@x[6],@x[7],lsl#32 + ldp @x[5],@x[7],[$inp,#16] + add @x[8],@x[8],@x[9],lsl#32 + add @x[10],@x[10],@x[11],lsl#32 + ldp @x[9],@x[11],[$inp,#32] + add @x[12],@x[12],@x[13],lsl#32 + add @x[14],@x[14],@x[15],lsl#32 + ldp @x[13],@x[15],[$inp,#48] + add $inp,$inp,#64 +#ifdef __AARCH64EB__ + rev @x[0],@x[0] + rev @x[2],@x[2] + rev @x[4],@x[4] + rev @x[6],@x[6] + rev @x[8],@x[8] + rev @x[10],@x[10] + rev @x[12],@x[12] + rev @x[14],@x[14] +#endif + eor @x[0],@x[0],@x[1] + eor @x[2],@x[2],@x[3] + eor @x[4],@x[4],@x[5] + eor @x[6],@x[6],@x[7] + eor @x[8],@x[8],@x[9] + eor @x[10],@x[10],@x[11] + eor @x[12],@x[12],@x[13] + eor @x[14],@x[14],@x[15] + + stp @x[0],@x[2],[$out,#0] // store output + add @d[6],@d[6],#4 // increment counter + stp @x[4],@x[6],[$out,#16] + stp @x[8],@x[10],[$out,#32] + stp @x[12],@x[14],[$out,#48] + add $out,$out,#64 + b.eq .Ldone_neon + sub $len,$len,#64 + cmp $len,#64 + b.lo .Less_than_128 + + ld1.8 {$T0-$T3},[$inp],#64 + eor $A0,$A0,$T0 + eor $B0,$B0,$T1 + eor $C0,$C0,$T2 + eor $D0,$D0,$T3 + st1.8 {$A0-$D0},[$out],#64 + b.eq .Ldone_neon + sub $len,$len,#64 + cmp $len,#64 + b.lo .Less_than_192 + + ld1.8 {$T0-$T3},[$inp],#64 + eor $A1,$A1,$T0 + eor $B1,$B1,$T1 + eor $C1,$C1,$T2 + eor $D1,$D1,$T3 + st1.8 {$A1-$D1},[$out],#64 + b.eq .Ldone_neon + sub $len,$len,#64 + + st1.8 {$A2-$D2},[sp] + b .Last_neon + +.Less_than_128: + st1.8 {$A0-$D0},[sp] + b .Last_neon +.Less_than_192: + st1.8 {$A1-$D1},[sp] + b .Last_neon + +.align 4 +.Last_neon: + sub $out,$out,#1 + add $inp,$inp,$len + add $out,$out,$len + add $ctr,sp,$len + neg $len,$len + +.Loop_tail_neon: + ldrb w10,[$inp,$len] + ldrb w11,[$ctr,$len] + add $len,$len,#1 + eor w10,w10,w11 + strb w10,[$out,$len] + cbnz $len,.Loop_tail_neon + + stp xzr,xzr,[sp,#0] + stp xzr,xzr,[sp,#16] + stp xzr,xzr,[sp,#32] + stp xzr,xzr,[sp,#48] + +.Ldone_neon: + ldp x19,x20,[x29,#16] + add sp,sp,#64 + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldp x29,x30,[sp],#96 + AARCH64_VALIDATE_LINK_REGISTER + ret +.size ChaCha20_ctr32_neon,.-ChaCha20_ctr32_neon +___ +{ +my ($T0,$T1,$T2,$T3,$T4,$T5)=@K; +my ($A0,$B0,$C0,$D0,$A1,$B1,$C1,$D1,$A2,$B2,$C2,$D2, + $A3,$B3,$C3,$D3,$A4,$B4,$C4,$D4,$A5,$B5,$C5,$D5) = map("v$_.4s",(0..23)); + +$code.=<<___; +.type ChaCha20_512_neon,%function +.align 5 +ChaCha20_512_neon: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-96]! + add x29,sp,#0 + + adrp @x[0],:pg_hi21:.Lsigma + add @x[0],@x[0],:lo12:.Lsigma + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + stp x27,x28,[sp,#80] + +.L512_or_more_neon: + sub sp,sp,#128+64 + + ldp @d[0],@d[1],[@x[0]] // load sigma + ld1 {@K[0]},[@x[0]],#16 + ldp @d[2],@d[3],[$key] // load key + ldp @d[4],@d[5],[$key,#16] + ld1 {@K[1],@K[2]},[$key] + ldp @d[6],@d[7],[$ctr] // load counter + ld1 {@K[3]},[$ctr] + ld1 {$ONE},[@x[0]] +#ifdef __AARCH64EB__ + rev64 @K[0],@K[0] + ror @d[2],@d[2],#32 + ror @d[3],@d[3],#32 + ror @d[4],@d[4],#32 + ror @d[5],@d[5],#32 + ror @d[6],@d[6],#32 + ror @d[7],@d[7],#32 +#endif + add @K[3],@K[3],$ONE // += 1 + stp @K[0],@K[1],[sp,#0] // off-load key block, invariant part + add @K[3],@K[3],$ONE // not typo + str @K[2],[sp,#32] + add @K[4],@K[3],$ONE + add @K[5],@K[4],$ONE + add @K[6],@K[5],$ONE + shl $ONE,$ONE,#2 // 1 -> 4 + + stp d8,d9,[sp,#128+0] // meet ABI requirements + stp d10,d11,[sp,#128+16] + stp d12,d13,[sp,#128+32] + stp d14,d15,[sp,#128+48] + + sub $len,$len,#512 // not typo + +.Loop_outer_512_neon: + mov $A0,@K[0] + mov $A1,@K[0] + mov $A2,@K[0] + mov $A3,@K[0] + mov $A4,@K[0] + mov $A5,@K[0] + mov $B0,@K[1] + mov.32 @x[0],@d[0] // unpack key block + mov $B1,@K[1] + lsr @x[1],@d[0],#32 + mov $B2,@K[1] + mov.32 @x[2],@d[1] + mov $B3,@K[1] + lsr @x[3],@d[1],#32 + mov $B4,@K[1] + mov.32 @x[4],@d[2] + mov $B5,@K[1] + lsr @x[5],@d[2],#32 + mov $D0,@K[3] + mov.32 @x[6],@d[3] + mov $D1,@K[4] + lsr @x[7],@d[3],#32 + mov $D2,@K[5] + mov.32 @x[8],@d[4] + mov $D3,@K[6] + lsr @x[9],@d[4],#32 + mov $C0,@K[2] + mov.32 @x[10],@d[5] + mov $C1,@K[2] + lsr @x[11],@d[5],#32 + add $D4,$D0,$ONE // +4 + mov.32 @x[12],@d[6] + add $D5,$D1,$ONE // +4 + lsr @x[13],@d[6],#32 + mov $C2,@K[2] + mov.32 @x[14],@d[7] + mov $C3,@K[2] + lsr @x[15],@d[7],#32 + mov $C4,@K[2] + stp @K[3],@K[4],[sp,#48] // off-load key block, variable part + mov $C5,@K[2] + str @K[5],[sp,#80] + + mov $ctr,#5 + subs $len,$len,#512 +.Loop_upper_neon: + sub $ctr,$ctr,#1 +___ + my @thread0=&NEONROUND($A0,$B0,$C0,$D0,$T0,0); + my @thread1=&NEONROUND($A1,$B1,$C1,$D1,$T1,0); + my @thread2=&NEONROUND($A2,$B2,$C2,$D2,$T2,0); + my @thread3=&NEONROUND($A3,$B3,$C3,$D3,$T3,0); + my @thread4=&NEONROUND($A4,$B4,$C4,$D4,$T4,0); + my @thread5=&NEONROUND($A5,$B5,$C5,$D5,$T5,0); + my @thread67=(&ROUND(0,4,8,12),&ROUND(0,5,10,15)); + my $diff = ($#thread0+1)*6 - $#thread67 - 1; + my $i = 0; + + foreach (@thread0) { + eval; eval(shift(@thread67)); + eval(shift(@thread1)); eval(shift(@thread67)); + eval(shift(@thread2)); eval(shift(@thread67)); + eval(shift(@thread3)); eval(shift(@thread67)); + eval(shift(@thread4)); eval(shift(@thread67)); + eval(shift(@thread5)); eval(shift(@thread67)); + } + + @thread0=&NEONROUND($A0,$B0,$C0,$D0,$T0,1); + @thread1=&NEONROUND($A1,$B1,$C1,$D1,$T1,1); + @thread2=&NEONROUND($A2,$B2,$C2,$D2,$T2,1); + @thread3=&NEONROUND($A3,$B3,$C3,$D3,$T3,1); + @thread4=&NEONROUND($A4,$B4,$C4,$D4,$T4,1); + @thread5=&NEONROUND($A5,$B5,$C5,$D5,$T5,1); + @thread67=(&ROUND(0,4,8,12),&ROUND(0,5,10,15)); + + foreach (@thread0) { + eval; eval(shift(@thread67)); + eval(shift(@thread1)); eval(shift(@thread67)); + eval(shift(@thread2)); eval(shift(@thread67)); + eval(shift(@thread3)); eval(shift(@thread67)); + eval(shift(@thread4)); eval(shift(@thread67)); + eval(shift(@thread5)); eval(shift(@thread67)); + } +$code.=<<___; + cbnz $ctr,.Loop_upper_neon + + add.32 @x[0],@x[0],@d[0] // accumulate key block + add @x[1],@x[1],@d[0],lsr#32 + add.32 @x[2],@x[2],@d[1] + add @x[3],@x[3],@d[1],lsr#32 + add.32 @x[4],@x[4],@d[2] + add @x[5],@x[5],@d[2],lsr#32 + add.32 @x[6],@x[6],@d[3] + add @x[7],@x[7],@d[3],lsr#32 + add.32 @x[8],@x[8],@d[4] + add @x[9],@x[9],@d[4],lsr#32 + add.32 @x[10],@x[10],@d[5] + add @x[11],@x[11],@d[5],lsr#32 + add.32 @x[12],@x[12],@d[6] + add @x[13],@x[13],@d[6],lsr#32 + add.32 @x[14],@x[14],@d[7] + add @x[15],@x[15],@d[7],lsr#32 + + add @x[0],@x[0],@x[1],lsl#32 // pack + add @x[2],@x[2],@x[3],lsl#32 + ldp @x[1],@x[3],[$inp,#0] // load input + add @x[4],@x[4],@x[5],lsl#32 + add @x[6],@x[6],@x[7],lsl#32 + ldp @x[5],@x[7],[$inp,#16] + add @x[8],@x[8],@x[9],lsl#32 + add @x[10],@x[10],@x[11],lsl#32 + ldp @x[9],@x[11],[$inp,#32] + add @x[12],@x[12],@x[13],lsl#32 + add @x[14],@x[14],@x[15],lsl#32 + ldp @x[13],@x[15],[$inp,#48] + add $inp,$inp,#64 +#ifdef __AARCH64EB__ + rev @x[0],@x[0] + rev @x[2],@x[2] + rev @x[4],@x[4] + rev @x[6],@x[6] + rev @x[8],@x[8] + rev @x[10],@x[10] + rev @x[12],@x[12] + rev @x[14],@x[14] +#endif + eor @x[0],@x[0],@x[1] + eor @x[2],@x[2],@x[3] + eor @x[4],@x[4],@x[5] + eor @x[6],@x[6],@x[7] + eor @x[8],@x[8],@x[9] + eor @x[10],@x[10],@x[11] + eor @x[12],@x[12],@x[13] + eor @x[14],@x[14],@x[15] + + stp @x[0],@x[2],[$out,#0] // store output + add @d[6],@d[6],#1 // increment counter + mov.32 @x[0],@d[0] // unpack key block + lsr @x[1],@d[0],#32 + stp @x[4],@x[6],[$out,#16] + mov.32 @x[2],@d[1] + lsr @x[3],@d[1],#32 + stp @x[8],@x[10],[$out,#32] + mov.32 @x[4],@d[2] + lsr @x[5],@d[2],#32 + stp @x[12],@x[14],[$out,#48] + add $out,$out,#64 + mov.32 @x[6],@d[3] + lsr @x[7],@d[3],#32 + mov.32 @x[8],@d[4] + lsr @x[9],@d[4],#32 + mov.32 @x[10],@d[5] + lsr @x[11],@d[5],#32 + mov.32 @x[12],@d[6] + lsr @x[13],@d[6],#32 + mov.32 @x[14],@d[7] + lsr @x[15],@d[7],#32 + + mov $ctr,#5 +.Loop_lower_neon: + sub $ctr,$ctr,#1 +___ + @thread0=&NEONROUND($A0,$B0,$C0,$D0,$T0,0); + @thread1=&NEONROUND($A1,$B1,$C1,$D1,$T1,0); + @thread2=&NEONROUND($A2,$B2,$C2,$D2,$T2,0); + @thread3=&NEONROUND($A3,$B3,$C3,$D3,$T3,0); + @thread4=&NEONROUND($A4,$B4,$C4,$D4,$T4,0); + @thread5=&NEONROUND($A5,$B5,$C5,$D5,$T5,0); + @thread67=(&ROUND(0,4,8,12),&ROUND(0,5,10,15)); + + foreach (@thread0) { + eval; eval(shift(@thread67)); + eval(shift(@thread1)); eval(shift(@thread67)); + eval(shift(@thread2)); eval(shift(@thread67)); + eval(shift(@thread3)); eval(shift(@thread67)); + eval(shift(@thread4)); eval(shift(@thread67)); + eval(shift(@thread5)); eval(shift(@thread67)); + } + + @thread0=&NEONROUND($A0,$B0,$C0,$D0,$T0,1); + @thread1=&NEONROUND($A1,$B1,$C1,$D1,$T1,1); + @thread2=&NEONROUND($A2,$B2,$C2,$D2,$T2,1); + @thread3=&NEONROUND($A3,$B3,$C3,$D3,$T3,1); + @thread4=&NEONROUND($A4,$B4,$C4,$D4,$T4,1); + @thread5=&NEONROUND($A5,$B5,$C5,$D5,$T5,1); + @thread67=(&ROUND(0,4,8,12),&ROUND(0,5,10,15)); + + foreach (@thread0) { + eval; eval(shift(@thread67)); + eval(shift(@thread1)); eval(shift(@thread67)); + eval(shift(@thread2)); eval(shift(@thread67)); + eval(shift(@thread3)); eval(shift(@thread67)); + eval(shift(@thread4)); eval(shift(@thread67)); + eval(shift(@thread5)); eval(shift(@thread67)); + } +$code.=<<___; + cbnz $ctr,.Loop_lower_neon + + add.32 @x[0],@x[0],@d[0] // accumulate key block + ldp @K[0],@K[1],[sp,#0] + add @x[1],@x[1],@d[0],lsr#32 + ldp @K[2],@K[3],[sp,#32] + add.32 @x[2],@x[2],@d[1] + ldp @K[4],@K[5],[sp,#64] + add @x[3],@x[3],@d[1],lsr#32 + add $A0,$A0,@K[0] + add.32 @x[4],@x[4],@d[2] + add $A1,$A1,@K[0] + add @x[5],@x[5],@d[2],lsr#32 + add $A2,$A2,@K[0] + add.32 @x[6],@x[6],@d[3] + add $A3,$A3,@K[0] + add @x[7],@x[7],@d[3],lsr#32 + add $A4,$A4,@K[0] + add.32 @x[8],@x[8],@d[4] + add $A5,$A5,@K[0] + add @x[9],@x[9],@d[4],lsr#32 + add $C0,$C0,@K[2] + add.32 @x[10],@x[10],@d[5] + add $C1,$C1,@K[2] + add @x[11],@x[11],@d[5],lsr#32 + add $C2,$C2,@K[2] + add.32 @x[12],@x[12],@d[6] + add $C3,$C3,@K[2] + add @x[13],@x[13],@d[6],lsr#32 + add $C4,$C4,@K[2] + add.32 @x[14],@x[14],@d[7] + add $C5,$C5,@K[2] + add @x[15],@x[15],@d[7],lsr#32 + add $D4,$D4,$ONE // +4 + add @x[0],@x[0],@x[1],lsl#32 // pack + add $D5,$D5,$ONE // +4 + add @x[2],@x[2],@x[3],lsl#32 + add $D0,$D0,@K[3] + ldp @x[1],@x[3],[$inp,#0] // load input + add $D1,$D1,@K[4] + add @x[4],@x[4],@x[5],lsl#32 + add $D2,$D2,@K[5] + add @x[6],@x[6],@x[7],lsl#32 + add $D3,$D3,@K[6] + ldp @x[5],@x[7],[$inp,#16] + add $D4,$D4,@K[3] + add @x[8],@x[8],@x[9],lsl#32 + add $D5,$D5,@K[4] + add @x[10],@x[10],@x[11],lsl#32 + add $B0,$B0,@K[1] + ldp @x[9],@x[11],[$inp,#32] + add $B1,$B1,@K[1] + add @x[12],@x[12],@x[13],lsl#32 + add $B2,$B2,@K[1] + add @x[14],@x[14],@x[15],lsl#32 + add $B3,$B3,@K[1] + ldp @x[13],@x[15],[$inp,#48] + add $B4,$B4,@K[1] + add $inp,$inp,#64 + add $B5,$B5,@K[1] + +#ifdef __AARCH64EB__ + rev @x[0],@x[0] + rev @x[2],@x[2] + rev @x[4],@x[4] + rev @x[6],@x[6] + rev @x[8],@x[8] + rev @x[10],@x[10] + rev @x[12],@x[12] + rev @x[14],@x[14] +#endif + ld1.8 {$T0-$T3},[$inp],#64 + eor @x[0],@x[0],@x[1] + eor @x[2],@x[2],@x[3] + eor @x[4],@x[4],@x[5] + eor @x[6],@x[6],@x[7] + eor @x[8],@x[8],@x[9] + eor $A0,$A0,$T0 + eor @x[10],@x[10],@x[11] + eor $B0,$B0,$T1 + eor @x[12],@x[12],@x[13] + eor $C0,$C0,$T2 + eor @x[14],@x[14],@x[15] + eor $D0,$D0,$T3 + ld1.8 {$T0-$T3},[$inp],#64 + + stp @x[0],@x[2],[$out,#0] // store output + add @d[6],@d[6],#7 // increment counter + stp @x[4],@x[6],[$out,#16] + stp @x[8],@x[10],[$out,#32] + stp @x[12],@x[14],[$out,#48] + add $out,$out,#64 + st1.8 {$A0-$D0},[$out],#64 + + ld1.8 {$A0-$D0},[$inp],#64 + eor $A1,$A1,$T0 + eor $B1,$B1,$T1 + eor $C1,$C1,$T2 + eor $D1,$D1,$T3 + st1.8 {$A1-$D1},[$out],#64 + + ld1.8 {$A1-$D1},[$inp],#64 + eor $A2,$A2,$A0 + ldp @K[0],@K[1],[sp,#0] + eor $B2,$B2,$B0 + ldp @K[2],@K[3],[sp,#32] + eor $C2,$C2,$C0 + eor $D2,$D2,$D0 + st1.8 {$A2-$D2},[$out],#64 + + ld1.8 {$A2-$D2},[$inp],#64 + eor $A3,$A3,$A1 + eor $B3,$B3,$B1 + eor $C3,$C3,$C1 + eor $D3,$D3,$D1 + st1.8 {$A3-$D3},[$out],#64 + + ld1.8 {$A3-$D3},[$inp],#64 + eor $A4,$A4,$A2 + eor $B4,$B4,$B2 + eor $C4,$C4,$C2 + eor $D4,$D4,$D2 + st1.8 {$A4-$D4},[$out],#64 + + shl $A0,$ONE,#1 // 4 -> 8 + eor $A5,$A5,$A3 + eor $B5,$B5,$B3 + eor $C5,$C5,$C3 + eor $D5,$D5,$D3 + st1.8 {$A5-$D5},[$out],#64 + + add @K[3],@K[3],$A0 // += 8 + add @K[4],@K[4],$A0 + add @K[5],@K[5],$A0 + add @K[6],@K[6],$A0 + + b.hs .Loop_outer_512_neon + + adds $len,$len,#512 + ushr $A0,$ONE,#2 // 4 -> 1 + + ldp d8,d9,[sp,#128+0] // meet ABI requirements + ldp d10,d11,[sp,#128+16] + ldp d12,d13,[sp,#128+32] + ldp d14,d15,[sp,#128+48] + + stp @K[0],$ONE,[sp,#0] // wipe off-load area + stp @K[0],$ONE,[sp,#32] + stp @K[0],$ONE,[sp,#64] + + b.eq .Ldone_512_neon + + cmp $len,#192 + sub @K[3],@K[3],$A0 // -= 1 + sub @K[4],@K[4],$A0 + sub @K[5],@K[5],$A0 + add sp,sp,#128 + b.hs .Loop_outer_neon + + eor @K[1],@K[1],@K[1] + eor @K[2],@K[2],@K[2] + eor @K[3],@K[3],@K[3] + eor @K[4],@K[4],@K[4] + eor @K[5],@K[5],@K[5] + eor @K[6],@K[6],@K[6] + b .Loop_outer + +.Ldone_512_neon: + ldp x19,x20,[x29,#16] + add sp,sp,#128+64 + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldp x29,x30,[sp],#96 + AARCH64_VALIDATE_LINK_REGISTER + ret +.size ChaCha20_512_neon,.-ChaCha20_512_neon +___ +} +}}} + +foreach (split("\n",$code)) { + s/\`([^\`]*)\`/eval $1/geo; + + (s/\b([a-z]+)\.32\b/$1/ and (s/x([0-9]+)/w$1/g or 1)) or + (m/\b(eor|ext|mov)\b/ and (s/\.4s/\.16b/g or 1)) or + (s/\b((?:ld|st)1)\.8\b/$1/ and (s/\.4s/\.16b/g or 1)) or + (m/\b(ld|st)[rp]\b/ and (s/v([0-9]+)\.4s/q$1/g or 1)) or + (s/\brev32\.16\b/rev32/ and (s/\.4s/\.8h/g or 1)); + + #s/\bq([0-9]+)#(lo|hi)/sprintf "d%d",2*$1+($2 eq "hi")/geo; + + print $_,"\n"; +} +close STDOUT or die "error closing STDOUT: $!"; # flush diff --git a/http/vendor/ring/crypto/chacha/asm/chacha-x86.pl b/http/vendor/ring/crypto/chacha/asm/chacha-x86.pl new file mode 100644 index 0000000..06f8ad9 --- /dev/null +++ b/http/vendor/ring/crypto/chacha/asm/chacha-x86.pl @@ -0,0 +1,480 @@ +#! /usr/bin/env perl +# Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# ==================================================================== +# Written by Andy Polyakov for the OpenSSL +# project. +# ==================================================================== +# +# January 2015 +# +# ChaCha20 for x86. +# +# Performance in cycles per byte out of large buffer. +# +# 1xIALU/gcc 4xSSSE3 +# Pentium 17.5/+80% +# PIII 14.2/+60% +# P4 18.6/+84% +# Core2 9.56/+89% 4.83 +# Westmere 9.50/+45% 3.35 +# Sandy Bridge 10.5/+47% 3.20 +# Haswell 8.15/+50% 2.83 +# Skylake 7.53/+22% 2.75 +# Silvermont 17.4/+36% 8.35 +# Goldmont 13.4/+40% 4.36 +# Sledgehammer 10.2/+54% +# Bulldozer 13.4/+50% 4.38(*) +# +# (*) Bulldozer actually executes 4xXOP code path that delivers 3.55; +# +# Modified from upstream OpenSSL to remove the XOP code. + +$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; +push(@INC,"${dir}","${dir}../../perlasm"); +require "x86asm.pl"; + +$output=pop; +open STDOUT,">$output"; + +&asm_init($ARGV[0]); + +$xmm=$ymm=1; +$gasver=999; # enable everything + +$a="eax"; +($b,$b_)=("ebx","ebp"); +($c,$c_)=("ecx","esi"); +($d,$d_)=("edx","edi"); + +&static_label("ssse3_data"); +&static_label("pic_point"); + +if ($xmm) { +my ($xa,$xa_,$xb,$xb_,$xc,$xc_,$xd,$xd_)=map("xmm$_",(0..7)); +my ($out,$inp,$len)=("edi","esi","ecx"); + +sub QUARTERROUND_SSSE3 { +my ($ai,$bi,$ci,$di,$i)=@_; +my ($an,$bn,$cn,$dn)=map(($_&~3)+(($_+1)&3),($ai,$bi,$ci,$di)); # next +my ($ap,$bp,$cp,$dp)=map(($_&~3)+(($_-1)&3),($ai,$bi,$ci,$di)); # previous + + # a b c d + # + # 0 4 8 12 < even round + # 1 5 9 13 + # 2 6 10 14 + # 3 7 11 15 + # 0 5 10 15 < odd round + # 1 6 11 12 + # 2 7 8 13 + # 3 4 9 14 + + if ($i==0) { + my $j=4; + ($ap,$bp,$cp,$dp)=map(($_&~3)+(($_-$j--)&3),($ap,$bp,$cp,$dp)); + } elsif ($i==3) { + my $j=0; + ($an,$bn,$cn,$dn)=map(($_&~3)+(($_+$j++)&3),($an,$bn,$cn,$dn)); + } elsif ($i==4) { + my $j=4; + ($ap,$bp,$cp,$dp)=map(($_&~3)+(($_+$j--)&3),($ap,$bp,$cp,$dp)); + } elsif ($i==7) { + my $j=0; + ($an,$bn,$cn,$dn)=map(($_&~3)+(($_-$j++)&3),($an,$bn,$cn,$dn)); + } + + #&paddd ($xa,$xb); # see elsewhere + #&pxor ($xd,$xa); # see elsewhere + &movdqa(&QWP(16*$cp-128,"ebx"),$xc_) if ($ai>0 && $ai<3); + &pshufb ($xd,&QWP(0,"eax")); # rot16 + &movdqa(&QWP(16*$bp-128,"ebx"),$xb_) if ($i!=0); + &paddd ($xc,$xd); + &movdqa($xc_,&QWP(16*$cn-128,"ebx")) if ($ai>0 && $ai<3); + &pxor ($xb,$xc); + &movdqa($xb_,&QWP(16*$bn-128,"ebx")) if ($i<7); + &movdqa ($xa_,$xb); # borrow as temporary + &pslld ($xb,12); + &psrld ($xa_,20); + &por ($xb,$xa_); + &movdqa($xa_,&QWP(16*$an-128,"ebx")); + &paddd ($xa,$xb); + &movdqa($xd_,&QWP(16*$dn-128,"ebx")) if ($di!=$dn); + &pxor ($xd,$xa); + &movdqa (&QWP(16*$ai-128,"ebx"),$xa); + &pshufb ($xd,&QWP(16,"eax")); # rot8 + &paddd ($xc,$xd); + &movdqa (&QWP(16*$di-128,"ebx"),$xd) if ($di!=$dn); + &movdqa ($xd_,$xd) if ($di==$dn); + &pxor ($xb,$xc); + &paddd ($xa_,$xb_) if ($i<7); # elsewhere + &movdqa ($xa,$xb); # borrow as temporary + &pslld ($xb,7); + &psrld ($xa,25); + &pxor ($xd_,$xa_) if ($i<7); # elsewhere + &por ($xb,$xa); + + ($xa,$xa_)=($xa_,$xa); + ($xb,$xb_)=($xb_,$xb); + ($xc,$xc_)=($xc_,$xc); + ($xd,$xd_)=($xd_,$xd); +} + +&function_begin("ChaCha20_ctr32_ssse3"); + &call (&label("pic_point")); +&set_label("pic_point"); + &blindpop("eax"); + + &mov ($out,&wparam(0)); + &mov ($inp,&wparam(1)); + &mov ($len,&wparam(2)); + &mov ("edx",&wparam(3)); # key + &mov ("ebx",&wparam(4)); # counter and nonce + + &mov ("ebp","esp"); + &stack_push (131); + &and ("esp",-64); + &mov (&DWP(512,"esp"),"ebp"); + + &lea ("eax",&DWP(&label("ssse3_data")."-". + &label("pic_point"),"eax")); + &movdqu ("xmm3",&QWP(0,"ebx")); # counter and nonce + +if (defined($gasver) && $gasver>=2.17) { # even though we encode + # pshufb manually, we + # handle only register + # operands, while this + # segment uses memory + # operand... + &cmp ($len,64*4); + &jb (&label("1x")); + + &mov (&DWP(512+4,"esp"),"edx"); # offload pointers + &mov (&DWP(512+8,"esp"),"ebx"); + &sub ($len,64*4); # bias len + &lea ("ebp",&DWP(256+128,"esp")); # size optimization + + &movdqu ("xmm7",&QWP(0,"edx")); # key + &pshufd ("xmm0","xmm3",0x00); + &pshufd ("xmm1","xmm3",0x55); + &pshufd ("xmm2","xmm3",0xaa); + &pshufd ("xmm3","xmm3",0xff); + &paddd ("xmm0",&QWP(16*3,"eax")); # fix counters + &pshufd ("xmm4","xmm7",0x00); + &pshufd ("xmm5","xmm7",0x55); + &psubd ("xmm0",&QWP(16*4,"eax")); + &pshufd ("xmm6","xmm7",0xaa); + &pshufd ("xmm7","xmm7",0xff); + &movdqa (&QWP(16*12-128,"ebp"),"xmm0"); + &movdqa (&QWP(16*13-128,"ebp"),"xmm1"); + &movdqa (&QWP(16*14-128,"ebp"),"xmm2"); + &movdqa (&QWP(16*15-128,"ebp"),"xmm3"); + &movdqu ("xmm3",&QWP(16,"edx")); # key + &movdqa (&QWP(16*4-128,"ebp"),"xmm4"); + &movdqa (&QWP(16*5-128,"ebp"),"xmm5"); + &movdqa (&QWP(16*6-128,"ebp"),"xmm6"); + &movdqa (&QWP(16*7-128,"ebp"),"xmm7"); + &movdqa ("xmm7",&QWP(16*2,"eax")); # sigma + &lea ("ebx",&DWP(128,"esp")); # size optimization + + &pshufd ("xmm0","xmm3",0x00); + &pshufd ("xmm1","xmm3",0x55); + &pshufd ("xmm2","xmm3",0xaa); + &pshufd ("xmm3","xmm3",0xff); + &pshufd ("xmm4","xmm7",0x00); + &pshufd ("xmm5","xmm7",0x55); + &pshufd ("xmm6","xmm7",0xaa); + &pshufd ("xmm7","xmm7",0xff); + &movdqa (&QWP(16*8-128,"ebp"),"xmm0"); + &movdqa (&QWP(16*9-128,"ebp"),"xmm1"); + &movdqa (&QWP(16*10-128,"ebp"),"xmm2"); + &movdqa (&QWP(16*11-128,"ebp"),"xmm3"); + &movdqa (&QWP(16*0-128,"ebp"),"xmm4"); + &movdqa (&QWP(16*1-128,"ebp"),"xmm5"); + &movdqa (&QWP(16*2-128,"ebp"),"xmm6"); + &movdqa (&QWP(16*3-128,"ebp"),"xmm7"); + + &lea ($inp,&DWP(128,$inp)); # size optimization + &lea ($out,&DWP(128,$out)); # size optimization + &jmp (&label("outer_loop")); + +&set_label("outer_loop",16); + #&movdqa ("xmm0",&QWP(16*0-128,"ebp")); # copy key material + &movdqa ("xmm1",&QWP(16*1-128,"ebp")); + &movdqa ("xmm2",&QWP(16*2-128,"ebp")); + &movdqa ("xmm3",&QWP(16*3-128,"ebp")); + #&movdqa ("xmm4",&QWP(16*4-128,"ebp")); + &movdqa ("xmm5",&QWP(16*5-128,"ebp")); + &movdqa ("xmm6",&QWP(16*6-128,"ebp")); + &movdqa ("xmm7",&QWP(16*7-128,"ebp")); + #&movdqa (&QWP(16*0-128,"ebx"),"xmm0"); + &movdqa (&QWP(16*1-128,"ebx"),"xmm1"); + &movdqa (&QWP(16*2-128,"ebx"),"xmm2"); + &movdqa (&QWP(16*3-128,"ebx"),"xmm3"); + #&movdqa (&QWP(16*4-128,"ebx"),"xmm4"); + &movdqa (&QWP(16*5-128,"ebx"),"xmm5"); + &movdqa (&QWP(16*6-128,"ebx"),"xmm6"); + &movdqa (&QWP(16*7-128,"ebx"),"xmm7"); + #&movdqa ("xmm0",&QWP(16*8-128,"ebp")); + #&movdqa ("xmm1",&QWP(16*9-128,"ebp")); + &movdqa ("xmm2",&QWP(16*10-128,"ebp")); + &movdqa ("xmm3",&QWP(16*11-128,"ebp")); + &movdqa ("xmm4",&QWP(16*12-128,"ebp")); + &movdqa ("xmm5",&QWP(16*13-128,"ebp")); + &movdqa ("xmm6",&QWP(16*14-128,"ebp")); + &movdqa ("xmm7",&QWP(16*15-128,"ebp")); + &paddd ("xmm4",&QWP(16*4,"eax")); # counter value + #&movdqa (&QWP(16*8-128,"ebx"),"xmm0"); + #&movdqa (&QWP(16*9-128,"ebx"),"xmm1"); + &movdqa (&QWP(16*10-128,"ebx"),"xmm2"); + &movdqa (&QWP(16*11-128,"ebx"),"xmm3"); + &movdqa (&QWP(16*12-128,"ebx"),"xmm4"); + &movdqa (&QWP(16*13-128,"ebx"),"xmm5"); + &movdqa (&QWP(16*14-128,"ebx"),"xmm6"); + &movdqa (&QWP(16*15-128,"ebx"),"xmm7"); + &movdqa (&QWP(16*12-128,"ebp"),"xmm4"); # save counter value + + &movdqa ($xa, &QWP(16*0-128,"ebp")); + &movdqa ($xd, "xmm4"); + &movdqa ($xb_,&QWP(16*4-128,"ebp")); + &movdqa ($xc, &QWP(16*8-128,"ebp")); + &movdqa ($xc_,&QWP(16*9-128,"ebp")); + + &mov ("edx",10); # loop counter + &nop (); + +&set_label("loop",16); + &paddd ($xa,$xb_); # elsewhere + &movdqa ($xb,$xb_); + &pxor ($xd,$xa); # elsewhere + &QUARTERROUND_SSSE3(0, 4, 8, 12, 0); + &QUARTERROUND_SSSE3(1, 5, 9, 13, 1); + &QUARTERROUND_SSSE3(2, 6,10, 14, 2); + &QUARTERROUND_SSSE3(3, 7,11, 15, 3); + &QUARTERROUND_SSSE3(0, 5,10, 15, 4); + &QUARTERROUND_SSSE3(1, 6,11, 12, 5); + &QUARTERROUND_SSSE3(2, 7, 8, 13, 6); + &QUARTERROUND_SSSE3(3, 4, 9, 14, 7); + &dec ("edx"); + &jnz (&label("loop")); + + &movdqa (&QWP(16*4-128,"ebx"),$xb_); + &movdqa (&QWP(16*8-128,"ebx"),$xc); + &movdqa (&QWP(16*9-128,"ebx"),$xc_); + &movdqa (&QWP(16*12-128,"ebx"),$xd); + &movdqa (&QWP(16*14-128,"ebx"),$xd_); + + my ($xa0,$xa1,$xa2,$xa3,$xt0,$xt1,$xt2,$xt3)=map("xmm$_",(0..7)); + + #&movdqa ($xa0,&QWP(16*0-128,"ebx")); # it's there + &movdqa ($xa1,&QWP(16*1-128,"ebx")); + &movdqa ($xa2,&QWP(16*2-128,"ebx")); + &movdqa ($xa3,&QWP(16*3-128,"ebx")); + + for($i=0;$i<256;$i+=64) { + &paddd ($xa0,&QWP($i+16*0-128,"ebp")); # accumulate key material + &paddd ($xa1,&QWP($i+16*1-128,"ebp")); + &paddd ($xa2,&QWP($i+16*2-128,"ebp")); + &paddd ($xa3,&QWP($i+16*3-128,"ebp")); + + &movdqa ($xt2,$xa0); # "de-interlace" data + &punpckldq ($xa0,$xa1); + &movdqa ($xt3,$xa2); + &punpckldq ($xa2,$xa3); + &punpckhdq ($xt2,$xa1); + &punpckhdq ($xt3,$xa3); + &movdqa ($xa1,$xa0); + &punpcklqdq ($xa0,$xa2); # "a0" + &movdqa ($xa3,$xt2); + &punpcklqdq ($xt2,$xt3); # "a2" + &punpckhqdq ($xa1,$xa2); # "a1" + &punpckhqdq ($xa3,$xt3); # "a3" + + #($xa2,$xt2)=($xt2,$xa2); + + &movdqu ($xt0,&QWP(64*0-128,$inp)); # load input + &movdqu ($xt1,&QWP(64*1-128,$inp)); + &movdqu ($xa2,&QWP(64*2-128,$inp)); + &movdqu ($xt3,&QWP(64*3-128,$inp)); + &lea ($inp,&QWP($i<192?16:(64*4-16*3),$inp)); + &pxor ($xt0,$xa0); + &movdqa ($xa0,&QWP($i+16*4-128,"ebx")) if ($i<192); + &pxor ($xt1,$xa1); + &movdqa ($xa1,&QWP($i+16*5-128,"ebx")) if ($i<192); + &pxor ($xt2,$xa2); + &movdqa ($xa2,&QWP($i+16*6-128,"ebx")) if ($i<192); + &pxor ($xt3,$xa3); + &movdqa ($xa3,&QWP($i+16*7-128,"ebx")) if ($i<192); + &movdqu (&QWP(64*0-128,$out),$xt0); # store output + &movdqu (&QWP(64*1-128,$out),$xt1); + &movdqu (&QWP(64*2-128,$out),$xt2); + &movdqu (&QWP(64*3-128,$out),$xt3); + &lea ($out,&QWP($i<192?16:(64*4-16*3),$out)); + } + &sub ($len,64*4); + &jnc (&label("outer_loop")); + + &add ($len,64*4); + &jz (&label("done")); + + &mov ("ebx",&DWP(512+8,"esp")); # restore pointers + &lea ($inp,&DWP(-128,$inp)); + &mov ("edx",&DWP(512+4,"esp")); + &lea ($out,&DWP(-128,$out)); + + &movd ("xmm2",&DWP(16*12-128,"ebp")); # counter value + &movdqu ("xmm3",&QWP(0,"ebx")); + &paddd ("xmm2",&QWP(16*6,"eax")); # +four + &pand ("xmm3",&QWP(16*7,"eax")); + &por ("xmm3","xmm2"); # counter value +} +{ +my ($a,$b,$c,$d,$t,$t1,$rot16,$rot24)=map("xmm$_",(0..7)); + +sub SSSE3ROUND { # critical path is 20 "SIMD ticks" per round + &paddd ($a,$b); + &pxor ($d,$a); + &pshufb ($d,$rot16); + + &paddd ($c,$d); + &pxor ($b,$c); + &movdqa ($t,$b); + &psrld ($b,20); + &pslld ($t,12); + &por ($b,$t); + + &paddd ($a,$b); + &pxor ($d,$a); + &pshufb ($d,$rot24); + + &paddd ($c,$d); + &pxor ($b,$c); + &movdqa ($t,$b); + &psrld ($b,25); + &pslld ($t,7); + &por ($b,$t); +} + +&set_label("1x"); + &movdqa ($a,&QWP(16*2,"eax")); # sigma + &movdqu ($b,&QWP(0,"edx")); + &movdqu ($c,&QWP(16,"edx")); + #&movdqu ($d,&QWP(0,"ebx")); # already loaded + &movdqa ($rot16,&QWP(0,"eax")); + &movdqa ($rot24,&QWP(16,"eax")); + &mov (&DWP(16*3,"esp"),"ebp"); + + &movdqa (&QWP(16*0,"esp"),$a); + &movdqa (&QWP(16*1,"esp"),$b); + &movdqa (&QWP(16*2,"esp"),$c); + &movdqa (&QWP(16*3,"esp"),$d); + &mov ("edx",10); + &jmp (&label("loop1x")); + +&set_label("outer1x",16); + &movdqa ($d,&QWP(16*5,"eax")); # one + &movdqa ($a,&QWP(16*0,"esp")); + &movdqa ($b,&QWP(16*1,"esp")); + &movdqa ($c,&QWP(16*2,"esp")); + &paddd ($d,&QWP(16*3,"esp")); + &mov ("edx",10); + &movdqa (&QWP(16*3,"esp"),$d); + &jmp (&label("loop1x")); + +&set_label("loop1x",16); + &SSSE3ROUND(); + &pshufd ($c,$c,0b01001110); + &pshufd ($b,$b,0b00111001); + &pshufd ($d,$d,0b10010011); + &nop (); + + &SSSE3ROUND(); + &pshufd ($c,$c,0b01001110); + &pshufd ($b,$b,0b10010011); + &pshufd ($d,$d,0b00111001); + + &dec ("edx"); + &jnz (&label("loop1x")); + + &paddd ($a,&QWP(16*0,"esp")); + &paddd ($b,&QWP(16*1,"esp")); + &paddd ($c,&QWP(16*2,"esp")); + &paddd ($d,&QWP(16*3,"esp")); + + &cmp ($len,64); + &jb (&label("tail")); + + &movdqu ($t,&QWP(16*0,$inp)); + &movdqu ($t1,&QWP(16*1,$inp)); + &pxor ($a,$t); # xor with input + &movdqu ($t,&QWP(16*2,$inp)); + &pxor ($b,$t1); + &movdqu ($t1,&QWP(16*3,$inp)); + &pxor ($c,$t); + &pxor ($d,$t1); + &lea ($inp,&DWP(16*4,$inp)); # inp+=64 + + &movdqu (&QWP(16*0,$out),$a); # write output + &movdqu (&QWP(16*1,$out),$b); + &movdqu (&QWP(16*2,$out),$c); + &movdqu (&QWP(16*3,$out),$d); + &lea ($out,&DWP(16*4,$out)); # inp+=64 + + &sub ($len,64); + &jnz (&label("outer1x")); + + &jmp (&label("done")); + +&set_label("tail"); + &movdqa (&QWP(16*0,"esp"),$a); + &movdqa (&QWP(16*1,"esp"),$b); + &movdqa (&QWP(16*2,"esp"),$c); + &movdqa (&QWP(16*3,"esp"),$d); + + &xor ("eax","eax"); + &xor ("edx","edx"); + &xor ("ebp","ebp"); + +&set_label("tail_loop"); + &movb ("al",&BP(0,"esp","ebp")); + &movb ("dl",&BP(0,$inp,"ebp")); + &lea ("ebp",&DWP(1,"ebp")); + &xor ("al","dl"); + &movb (&BP(-1,$out,"ebp"),"al"); + &dec ($len); + &jnz (&label("tail_loop")); +} +&set_label("done"); + &mov ("esp",&DWP(512,"esp")); +&function_end("ChaCha20_ctr32_ssse3"); + +&align (64); +&set_label("ssse3_data"); +&data_byte(0x2,0x3,0x0,0x1, 0x6,0x7,0x4,0x5, 0xa,0xb,0x8,0x9, 0xe,0xf,0xc,0xd); +&data_byte(0x3,0x0,0x1,0x2, 0x7,0x4,0x5,0x6, 0xb,0x8,0x9,0xa, 0xf,0xc,0xd,0xe); +&data_word(0x61707865,0x3320646e,0x79622d32,0x6b206574); +&data_word(0,1,2,3); +&data_word(4,4,4,4); +&data_word(1,0,0,0); +&data_word(4,0,0,0); +&data_word(0,-1,-1,-1); +&align (64); +} +&asciz ("ChaCha20 for x86, CRYPTOGAMS by "); + +&asm_finish(); + +close STDOUT or die "error closing STDOUT: $!"; diff --git a/http/vendor/ring/crypto/chacha/asm/chacha-x86_64.pl b/http/vendor/ring/crypto/chacha/asm/chacha-x86_64.pl new file mode 100644 index 0000000..002f369 --- /dev/null +++ b/http/vendor/ring/crypto/chacha/asm/chacha-x86_64.pl @@ -0,0 +1,1854 @@ +#! /usr/bin/env perl +# Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# ==================================================================== +# Written by Andy Polyakov for the OpenSSL +# project. +# ==================================================================== +# +# November 2014 +# +# ChaCha20 for x86_64. +# +# December 2016 +# +# Add AVX512F code path. +# +# Performance in cycles per byte out of large buffer. +# +# IALU/gcc 4.8(i) 1xSSSE3/SSE2 4xSSSE3 NxAVX(v) +# +# P4 9.48/+99% -/22.7(ii) - +# Core2 7.83/+55% 7.90/8.08 4.35 +# Westmere 7.19/+50% 5.60/6.70 3.00 +# Sandy Bridge 8.31/+42% 5.45/6.76 2.72 +# Ivy Bridge 6.71/+46% 5.40/6.49 2.41 +# Haswell 5.92/+43% 5.20/6.45 2.42 1.23 +# Skylake[-X] 5.87/+39% 4.70/- 2.31 1.19[0.57] +# Silvermont 12.0/+33% 7.75/7.40 7.03(iii) +# Knights L 11.7/- - 9.60(iii) 0.80 +# Goldmont 10.6/+17% 5.10/- 3.28 +# Sledgehammer 7.28/+52% -/14.2(ii) - +# Bulldozer 9.66/+28% 9.85/11.1 3.06(iv) +# Ryzen 5.96/+50% 5.19/- 2.40 2.09 +# VIA Nano 10.5/+46% 6.72/8.60 6.05 +# +# (i) compared to older gcc 3.x one can observe >2x improvement on +# most platforms; +# (ii) as it can be seen, SSE2 performance is too low on legacy +# processors; NxSSE2 results are naturally better, but not +# impressively better than IALU ones, which is why you won't +# find SSE2 code below; +# (iii) this is not optimal result for Atom because of MSROM +# limitations, SSE2 can do better, but gain is considered too +# low to justify the [maintenance] effort; +# (iv) Bulldozer actually executes 4xXOP code path that delivers 2.20; +# +# Modified from upstream OpenSSL to remove the XOP code. + +$flavour = shift; +$output = shift; +if ($flavour =~ /\./) { $output = $flavour; undef $flavour; } + +$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/); + +$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; +( $xlate="${dir}x86_64-xlate.pl" and -f $xlate ) or +( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or +die "can't locate x86_64-xlate.pl"; + +$avx = 2; + +open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""; +*STDOUT=*OUT; + +# input parameter block +($out,$inp,$len,$key,$counter)=("%rdi","%rsi","%rdx","%rcx","%r8"); + +$code.=<<___; +.text + +.section .rodata +.align 64 +.Lzero: +.long 0,0,0,0 +.Lone: +.long 1,0,0,0 +.Linc: +.long 0,1,2,3 +.Lfour: +.long 4,4,4,4 +.Lincy: +.long 0,2,4,6,1,3,5,7 +.Leight: +.long 8,8,8,8,8,8,8,8 +.Lrot16: +.byte 0x2,0x3,0x0,0x1, 0x6,0x7,0x4,0x5, 0xa,0xb,0x8,0x9, 0xe,0xf,0xc,0xd +.Lrot24: +.byte 0x3,0x0,0x1,0x2, 0x7,0x4,0x5,0x6, 0xb,0x8,0x9,0xa, 0xf,0xc,0xd,0xe +.Lsigma: +.asciz "expand 32-byte k" +.align 64 +.Lzeroz: +.long 0,0,0,0, 1,0,0,0, 2,0,0,0, 3,0,0,0 +.Lfourz: +.long 4,0,0,0, 4,0,0,0, 4,0,0,0, 4,0,0,0 +.Lincz: +.long 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 +.Lsixteen: +.long 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16 +.asciz "ChaCha20 for x86_64, CRYPTOGAMS by " +.text +___ + +sub AUTOLOAD() # thunk [simplified] 32-bit style perlasm +{ my $opcode = $AUTOLOAD; $opcode =~ s/.*:://; + my $arg = pop; + $arg = "\$$arg" if ($arg*1 eq $arg); + $code .= "\t$opcode\t".join(',',$arg,reverse @_)."\n"; +} + +@x=("%eax","%ebx","%ecx","%edx",map("%r${_}d",(8..11)), + "%nox","%nox","%nox","%nox",map("%r${_}d",(12..15))); +@t=("%esi","%edi"); + +sub ROUND { # critical path is 24 cycles per round +my ($a0,$b0,$c0,$d0)=@_; +my ($a1,$b1,$c1,$d1)=map(($_&~3)+(($_+1)&3),($a0,$b0,$c0,$d0)); +my ($a2,$b2,$c2,$d2)=map(($_&~3)+(($_+1)&3),($a1,$b1,$c1,$d1)); +my ($a3,$b3,$c3,$d3)=map(($_&~3)+(($_+1)&3),($a2,$b2,$c2,$d2)); +my ($xc,$xc_)=map("\"$_\"",@t); +my @x=map("\"$_\"",@x); + + # Consider order in which variables are addressed by their + # index: + # + # a b c d + # + # 0 4 8 12 < even round + # 1 5 9 13 + # 2 6 10 14 + # 3 7 11 15 + # 0 5 10 15 < odd round + # 1 6 11 12 + # 2 7 8 13 + # 3 4 9 14 + # + # 'a', 'b' and 'd's are permanently allocated in registers, + # @x[0..7,12..15], while 'c's are maintained in memory. If + # you observe 'c' column, you'll notice that pair of 'c's is + # invariant between rounds. This means that we have to reload + # them once per round, in the middle. This is why you'll see + # bunch of 'c' stores and loads in the middle, but none in + # the beginning or end. + + # Normally instructions would be interleaved to favour in-order + # execution. Generally out-of-order cores manage it gracefully, + # but not this time for some reason. As in-order execution + # cores are dying breed, old Atom is the only one around, + # instructions are left uninterleaved. Besides, Atom is better + # off executing 1xSSSE3 code anyway... + + ( + "&add (@x[$a0],@x[$b0])", # Q1 + "&xor (@x[$d0],@x[$a0])", + "&rol (@x[$d0],16)", + "&add (@x[$a1],@x[$b1])", # Q2 + "&xor (@x[$d1],@x[$a1])", + "&rol (@x[$d1],16)", + + "&add ($xc,@x[$d0])", + "&xor (@x[$b0],$xc)", + "&rol (@x[$b0],12)", + "&add ($xc_,@x[$d1])", + "&xor (@x[$b1],$xc_)", + "&rol (@x[$b1],12)", + + "&add (@x[$a0],@x[$b0])", + "&xor (@x[$d0],@x[$a0])", + "&rol (@x[$d0],8)", + "&add (@x[$a1],@x[$b1])", + "&xor (@x[$d1],@x[$a1])", + "&rol (@x[$d1],8)", + + "&add ($xc,@x[$d0])", + "&xor (@x[$b0],$xc)", + "&rol (@x[$b0],7)", + "&add ($xc_,@x[$d1])", + "&xor (@x[$b1],$xc_)", + "&rol (@x[$b1],7)", + + "&mov (\"4*$c0(%rsp)\",$xc)", # reload pair of 'c's + "&mov (\"4*$c1(%rsp)\",$xc_)", + "&mov ($xc,\"4*$c2(%rsp)\")", + "&mov ($xc_,\"4*$c3(%rsp)\")", + + "&add (@x[$a2],@x[$b2])", # Q3 + "&xor (@x[$d2],@x[$a2])", + "&rol (@x[$d2],16)", + "&add (@x[$a3],@x[$b3])", # Q4 + "&xor (@x[$d3],@x[$a3])", + "&rol (@x[$d3],16)", + + "&add ($xc,@x[$d2])", + "&xor (@x[$b2],$xc)", + "&rol (@x[$b2],12)", + "&add ($xc_,@x[$d3])", + "&xor (@x[$b3],$xc_)", + "&rol (@x[$b3],12)", + + "&add (@x[$a2],@x[$b2])", + "&xor (@x[$d2],@x[$a2])", + "&rol (@x[$d2],8)", + "&add (@x[$a3],@x[$b3])", + "&xor (@x[$d3],@x[$a3])", + "&rol (@x[$d3],8)", + + "&add ($xc,@x[$d2])", + "&xor (@x[$b2],$xc)", + "&rol (@x[$b2],7)", + "&add ($xc_,@x[$d3])", + "&xor (@x[$b3],$xc_)", + "&rol (@x[$b3],7)" + ); +} + +######################################################################## +# Generic code path that handles all lengths on pre-SSSE3 processors. +$code.=<<___; +.globl ChaCha20_ctr32_nohw +.type ChaCha20_ctr32_nohw,\@function,5 +.align 64 +ChaCha20_ctr32_nohw: +.cfi_startproc + _CET_ENDBR + push %rbx +.cfi_push rbx + push %rbp +.cfi_push rbp + push %r12 +.cfi_push r12 + push %r13 +.cfi_push r13 + push %r14 +.cfi_push r14 + push %r15 +.cfi_push r15 + sub \$64+24,%rsp +.cfi_adjust_cfa_offset `64+24` +.Lctr32_body: + + #movdqa .Lsigma(%rip),%xmm0 + movdqu ($key),%xmm1 + movdqu 16($key),%xmm2 + movdqu ($counter),%xmm3 + movdqa .Lone(%rip),%xmm4 + + #movdqa %xmm0,4*0(%rsp) # key[0] + movdqa %xmm1,4*4(%rsp) # key[1] + movdqa %xmm2,4*8(%rsp) # key[2] + movdqa %xmm3,4*12(%rsp) # key[3] + mov $len,%rbp # reassign $len + jmp .Loop_outer + +.align 32 +.Loop_outer: + mov \$0x61707865,@x[0] # 'expa' + mov \$0x3320646e,@x[1] # 'nd 3' + mov \$0x79622d32,@x[2] # '2-by' + mov \$0x6b206574,@x[3] # 'te k' + mov 4*4(%rsp),@x[4] + mov 4*5(%rsp),@x[5] + mov 4*6(%rsp),@x[6] + mov 4*7(%rsp),@x[7] + movd %xmm3,@x[12] + mov 4*13(%rsp),@x[13] + mov 4*14(%rsp),@x[14] + mov 4*15(%rsp),@x[15] + + mov %rbp,64+0(%rsp) # save len + mov \$10,%ebp + mov $inp,64+8(%rsp) # save inp + movq %xmm2,%rsi # "@x[8]" + mov $out,64+16(%rsp) # save out + mov %rsi,%rdi + shr \$32,%rdi # "@x[9]" + jmp .Loop + +.align 32 +.Loop: +___ + foreach (&ROUND (0, 4, 8,12)) { eval; } + foreach (&ROUND (0, 5,10,15)) { eval; } + &dec ("%ebp"); + &jnz (".Loop"); + +$code.=<<___; + mov @t[1],4*9(%rsp) # modulo-scheduled + mov @t[0],4*8(%rsp) + mov 64(%rsp),%rbp # load len + movdqa %xmm2,%xmm1 + mov 64+8(%rsp),$inp # load inp + paddd %xmm4,%xmm3 # increment counter + mov 64+16(%rsp),$out # load out + + add \$0x61707865,@x[0] # 'expa' + add \$0x3320646e,@x[1] # 'nd 3' + add \$0x79622d32,@x[2] # '2-by' + add \$0x6b206574,@x[3] # 'te k' + add 4*4(%rsp),@x[4] + add 4*5(%rsp),@x[5] + add 4*6(%rsp),@x[6] + add 4*7(%rsp),@x[7] + add 4*12(%rsp),@x[12] + add 4*13(%rsp),@x[13] + add 4*14(%rsp),@x[14] + add 4*15(%rsp),@x[15] + paddd 4*8(%rsp),%xmm1 + + cmp \$64,%rbp + jb .Ltail + + xor 4*0($inp),@x[0] # xor with input + xor 4*1($inp),@x[1] + xor 4*2($inp),@x[2] + xor 4*3($inp),@x[3] + xor 4*4($inp),@x[4] + xor 4*5($inp),@x[5] + xor 4*6($inp),@x[6] + xor 4*7($inp),@x[7] + movdqu 4*8($inp),%xmm0 + xor 4*12($inp),@x[12] + xor 4*13($inp),@x[13] + xor 4*14($inp),@x[14] + xor 4*15($inp),@x[15] + lea 4*16($inp),$inp # inp+=64 + pxor %xmm1,%xmm0 + + movdqa %xmm2,4*8(%rsp) + movd %xmm3,4*12(%rsp) + + mov @x[0],4*0($out) # write output + mov @x[1],4*1($out) + mov @x[2],4*2($out) + mov @x[3],4*3($out) + mov @x[4],4*4($out) + mov @x[5],4*5($out) + mov @x[6],4*6($out) + mov @x[7],4*7($out) + movdqu %xmm0,4*8($out) + mov @x[12],4*12($out) + mov @x[13],4*13($out) + mov @x[14],4*14($out) + mov @x[15],4*15($out) + lea 4*16($out),$out # out+=64 + + sub \$64,%rbp + jnz .Loop_outer + + jmp .Ldone + +.align 16 +.Ltail: + mov @x[0],4*0(%rsp) + mov @x[1],4*1(%rsp) + xor %rbx,%rbx + mov @x[2],4*2(%rsp) + mov @x[3],4*3(%rsp) + mov @x[4],4*4(%rsp) + mov @x[5],4*5(%rsp) + mov @x[6],4*6(%rsp) + mov @x[7],4*7(%rsp) + movdqa %xmm1,4*8(%rsp) + mov @x[12],4*12(%rsp) + mov @x[13],4*13(%rsp) + mov @x[14],4*14(%rsp) + mov @x[15],4*15(%rsp) + +.Loop_tail: + movzb ($inp,%rbx),%eax + movzb (%rsp,%rbx),%edx + lea 1(%rbx),%rbx + xor %edx,%eax + mov %al,-1($out,%rbx) + dec %rbp + jnz .Loop_tail + +.Ldone: + lea 64+24+48(%rsp),%rsi + mov -48(%rsi),%r15 +.cfi_restore r15 + mov -40(%rsi),%r14 +.cfi_restore r14 + mov -32(%rsi),%r13 +.cfi_restore r13 + mov -24(%rsi),%r12 +.cfi_restore r12 + mov -16(%rsi),%rbp +.cfi_restore rbp + mov -8(%rsi),%rbx +.cfi_restore rbx + lea (%rsi),%rsp +.cfi_adjust_cfa_offset `-64-24-48` +.Lno_data: + ret +.cfi_endproc +.size ChaCha20_ctr32_nohw,.-ChaCha20_ctr32_nohw +___ + +######################################################################## +# SSSE3 code path that handles longer messages. +{ +# assign variables to favor Atom front-end +my ($xd0,$xd1,$xd2,$xd3, $xt0,$xt1,$xt2,$xt3, + $xa0,$xa1,$xa2,$xa3, $xb0,$xb1,$xb2,$xb3)=map("%xmm$_",(0..15)); +my @xx=($xa0,$xa1,$xa2,$xa3, $xb0,$xb1,$xb2,$xb3, + "%nox","%nox","%nox","%nox", $xd0,$xd1,$xd2,$xd3); + +sub SSSE3_lane_ROUND { +my ($a0,$b0,$c0,$d0)=@_; +my ($a1,$b1,$c1,$d1)=map(($_&~3)+(($_+1)&3),($a0,$b0,$c0,$d0)); +my ($a2,$b2,$c2,$d2)=map(($_&~3)+(($_+1)&3),($a1,$b1,$c1,$d1)); +my ($a3,$b3,$c3,$d3)=map(($_&~3)+(($_+1)&3),($a2,$b2,$c2,$d2)); +my ($xc,$xc_,$t0,$t1)=map("\"$_\"",$xt0,$xt1,$xt2,$xt3); +my @x=map("\"$_\"",@xx); + + # Consider order in which variables are addressed by their + # index: + # + # a b c d + # + # 0 4 8 12 < even round + # 1 5 9 13 + # 2 6 10 14 + # 3 7 11 15 + # 0 5 10 15 < odd round + # 1 6 11 12 + # 2 7 8 13 + # 3 4 9 14 + # + # 'a', 'b' and 'd's are permanently allocated in registers, + # @x[0..7,12..15], while 'c's are maintained in memory. If + # you observe 'c' column, you'll notice that pair of 'c's is + # invariant between rounds. This means that we have to reload + # them once per round, in the middle. This is why you'll see + # bunch of 'c' stores and loads in the middle, but none in + # the beginning or end. + + ( + "&paddd (@x[$a0],@x[$b0])", # Q1 + "&paddd (@x[$a1],@x[$b1])", # Q2 + "&pxor (@x[$d0],@x[$a0])", + "&pxor (@x[$d1],@x[$a1])", + "&pshufb (@x[$d0],$t1)", + "&pshufb (@x[$d1],$t1)", + + "&paddd ($xc,@x[$d0])", + "&paddd ($xc_,@x[$d1])", + "&pxor (@x[$b0],$xc)", + "&pxor (@x[$b1],$xc_)", + "&movdqa ($t0,@x[$b0])", + "&pslld (@x[$b0],12)", + "&psrld ($t0,20)", + "&movdqa ($t1,@x[$b1])", + "&pslld (@x[$b1],12)", + "&por (@x[$b0],$t0)", + "&psrld ($t1,20)", + "&movdqa ($t0,'(%r11)')", # .Lrot24(%rip) + "&por (@x[$b1],$t1)", + + "&paddd (@x[$a0],@x[$b0])", + "&paddd (@x[$a1],@x[$b1])", + "&pxor (@x[$d0],@x[$a0])", + "&pxor (@x[$d1],@x[$a1])", + "&pshufb (@x[$d0],$t0)", + "&pshufb (@x[$d1],$t0)", + + "&paddd ($xc,@x[$d0])", + "&paddd ($xc_,@x[$d1])", + "&pxor (@x[$b0],$xc)", + "&pxor (@x[$b1],$xc_)", + "&movdqa ($t1,@x[$b0])", + "&pslld (@x[$b0],7)", + "&psrld ($t1,25)", + "&movdqa ($t0,@x[$b1])", + "&pslld (@x[$b1],7)", + "&por (@x[$b0],$t1)", + "&psrld ($t0,25)", + "&movdqa ($t1,'(%r10)')", # .Lrot16(%rip) + "&por (@x[$b1],$t0)", + + "&movdqa (\"`16*($c0-8)`(%rsp)\",$xc)", # reload pair of 'c's + "&movdqa (\"`16*($c1-8)`(%rsp)\",$xc_)", + "&movdqa ($xc,\"`16*($c2-8)`(%rsp)\")", + "&movdqa ($xc_,\"`16*($c3-8)`(%rsp)\")", + + "&paddd (@x[$a2],@x[$b2])", # Q3 + "&paddd (@x[$a3],@x[$b3])", # Q4 + "&pxor (@x[$d2],@x[$a2])", + "&pxor (@x[$d3],@x[$a3])", + "&pshufb (@x[$d2],$t1)", + "&pshufb (@x[$d3],$t1)", + + "&paddd ($xc,@x[$d2])", + "&paddd ($xc_,@x[$d3])", + "&pxor (@x[$b2],$xc)", + "&pxor (@x[$b3],$xc_)", + "&movdqa ($t0,@x[$b2])", + "&pslld (@x[$b2],12)", + "&psrld ($t0,20)", + "&movdqa ($t1,@x[$b3])", + "&pslld (@x[$b3],12)", + "&por (@x[$b2],$t0)", + "&psrld ($t1,20)", + "&movdqa ($t0,'(%r11)')", # .Lrot24(%rip) + "&por (@x[$b3],$t1)", + + "&paddd (@x[$a2],@x[$b2])", + "&paddd (@x[$a3],@x[$b3])", + "&pxor (@x[$d2],@x[$a2])", + "&pxor (@x[$d3],@x[$a3])", + "&pshufb (@x[$d2],$t0)", + "&pshufb (@x[$d3],$t0)", + + "&paddd ($xc,@x[$d2])", + "&paddd ($xc_,@x[$d3])", + "&pxor (@x[$b2],$xc)", + "&pxor (@x[$b3],$xc_)", + "&movdqa ($t1,@x[$b2])", + "&pslld (@x[$b2],7)", + "&psrld ($t1,25)", + "&movdqa ($t0,@x[$b3])", + "&pslld (@x[$b3],7)", + "&por (@x[$b2],$t1)", + "&psrld ($t0,25)", + "&movdqa ($t1,'(%r10)')", # .Lrot16(%rip) + "&por (@x[$b3],$t0)" + ); +} + +my $xframe = $win64 ? 0xa8 : 8; + +$code.=<<___; +.globl ChaCha20_ctr32_ssse3_4x +.type ChaCha20_ctr32_ssse3_4x,\@function,5 +.align 32 +ChaCha20_ctr32_ssse3_4x: +.cfi_startproc + _CET_ENDBR + mov %rsp,%r9 # frame pointer +.cfi_def_cfa_register r9 +___ +$code.=<<___; + sub \$0x140+$xframe,%rsp +___ + ################ stack layout + # +0x00 SIMD equivalent of @x[8-12] + # ... + # +0x40 constant copy of key[0-2] smashed by lanes + # ... + # +0x100 SIMD counters (with nonce smashed by lanes) + # ... + # +0x140 +$code.=<<___ if ($win64); + movaps %xmm6,-0xa8(%r9) + movaps %xmm7,-0x98(%r9) + movaps %xmm8,-0x88(%r9) + movaps %xmm9,-0x78(%r9) + movaps %xmm10,-0x68(%r9) + movaps %xmm11,-0x58(%r9) + movaps %xmm12,-0x48(%r9) + movaps %xmm13,-0x38(%r9) + movaps %xmm14,-0x28(%r9) + movaps %xmm15,-0x18(%r9) +.L4x_body: +___ +$code.=<<___; + movdqa .Lsigma(%rip),$xa3 # key[0] + movdqu ($key),$xb3 # key[1] + movdqu 16($key),$xt3 # key[2] + movdqu ($counter),$xd3 # key[3] + lea 0x100(%rsp),%rcx # size optimization + lea .Lrot16(%rip),%r10 + lea .Lrot24(%rip),%r11 + + pshufd \$0x00,$xa3,$xa0 # smash key by lanes... + pshufd \$0x55,$xa3,$xa1 + movdqa $xa0,0x40(%rsp) # ... and offload + pshufd \$0xaa,$xa3,$xa2 + movdqa $xa1,0x50(%rsp) + pshufd \$0xff,$xa3,$xa3 + movdqa $xa2,0x60(%rsp) + movdqa $xa3,0x70(%rsp) + + pshufd \$0x00,$xb3,$xb0 + pshufd \$0x55,$xb3,$xb1 + movdqa $xb0,0x80-0x100(%rcx) + pshufd \$0xaa,$xb3,$xb2 + movdqa $xb1,0x90-0x100(%rcx) + pshufd \$0xff,$xb3,$xb3 + movdqa $xb2,0xa0-0x100(%rcx) + movdqa $xb3,0xb0-0x100(%rcx) + + pshufd \$0x00,$xt3,$xt0 # "$xc0" + pshufd \$0x55,$xt3,$xt1 # "$xc1" + movdqa $xt0,0xc0-0x100(%rcx) + pshufd \$0xaa,$xt3,$xt2 # "$xc2" + movdqa $xt1,0xd0-0x100(%rcx) + pshufd \$0xff,$xt3,$xt3 # "$xc3" + movdqa $xt2,0xe0-0x100(%rcx) + movdqa $xt3,0xf0-0x100(%rcx) + + pshufd \$0x00,$xd3,$xd0 + pshufd \$0x55,$xd3,$xd1 + paddd .Linc(%rip),$xd0 # don't save counters yet + pshufd \$0xaa,$xd3,$xd2 + movdqa $xd1,0x110-0x100(%rcx) + pshufd \$0xff,$xd3,$xd3 + movdqa $xd2,0x120-0x100(%rcx) + movdqa $xd3,0x130-0x100(%rcx) + + jmp .Loop_enter4x + +.align 32 +.Loop_outer4x: + movdqa 0x40(%rsp),$xa0 # re-load smashed key + movdqa 0x50(%rsp),$xa1 + movdqa 0x60(%rsp),$xa2 + movdqa 0x70(%rsp),$xa3 + movdqa 0x80-0x100(%rcx),$xb0 + movdqa 0x90-0x100(%rcx),$xb1 + movdqa 0xa0-0x100(%rcx),$xb2 + movdqa 0xb0-0x100(%rcx),$xb3 + movdqa 0xc0-0x100(%rcx),$xt0 # "$xc0" + movdqa 0xd0-0x100(%rcx),$xt1 # "$xc1" + movdqa 0xe0-0x100(%rcx),$xt2 # "$xc2" + movdqa 0xf0-0x100(%rcx),$xt3 # "$xc3" + movdqa 0x100-0x100(%rcx),$xd0 + movdqa 0x110-0x100(%rcx),$xd1 + movdqa 0x120-0x100(%rcx),$xd2 + movdqa 0x130-0x100(%rcx),$xd3 + paddd .Lfour(%rip),$xd0 # next SIMD counters + +.Loop_enter4x: + movdqa $xt2,0x20(%rsp) # SIMD equivalent of "@x[10]" + movdqa $xt3,0x30(%rsp) # SIMD equivalent of "@x[11]" + movdqa (%r10),$xt3 # .Lrot16(%rip) + mov \$10,%eax + movdqa $xd0,0x100-0x100(%rcx) # save SIMD counters + jmp .Loop4x + +.align 32 +.Loop4x: +___ + foreach (&SSSE3_lane_ROUND(0, 4, 8,12)) { eval; } + foreach (&SSSE3_lane_ROUND(0, 5,10,15)) { eval; } +$code.=<<___; + dec %eax + jnz .Loop4x + + paddd 0x40(%rsp),$xa0 # accumulate key material + paddd 0x50(%rsp),$xa1 + paddd 0x60(%rsp),$xa2 + paddd 0x70(%rsp),$xa3 + + movdqa $xa0,$xt2 # "de-interlace" data + punpckldq $xa1,$xa0 + movdqa $xa2,$xt3 + punpckldq $xa3,$xa2 + punpckhdq $xa1,$xt2 + punpckhdq $xa3,$xt3 + movdqa $xa0,$xa1 + punpcklqdq $xa2,$xa0 # "a0" + movdqa $xt2,$xa3 + punpcklqdq $xt3,$xt2 # "a2" + punpckhqdq $xa2,$xa1 # "a1" + punpckhqdq $xt3,$xa3 # "a3" +___ + ($xa2,$xt2)=($xt2,$xa2); +$code.=<<___; + paddd 0x80-0x100(%rcx),$xb0 + paddd 0x90-0x100(%rcx),$xb1 + paddd 0xa0-0x100(%rcx),$xb2 + paddd 0xb0-0x100(%rcx),$xb3 + + movdqa $xa0,0x00(%rsp) # offload $xaN + movdqa $xa1,0x10(%rsp) + movdqa 0x20(%rsp),$xa0 # "xc2" + movdqa 0x30(%rsp),$xa1 # "xc3" + + movdqa $xb0,$xt2 + punpckldq $xb1,$xb0 + movdqa $xb2,$xt3 + punpckldq $xb3,$xb2 + punpckhdq $xb1,$xt2 + punpckhdq $xb3,$xt3 + movdqa $xb0,$xb1 + punpcklqdq $xb2,$xb0 # "b0" + movdqa $xt2,$xb3 + punpcklqdq $xt3,$xt2 # "b2" + punpckhqdq $xb2,$xb1 # "b1" + punpckhqdq $xt3,$xb3 # "b3" +___ + ($xb2,$xt2)=($xt2,$xb2); + my ($xc0,$xc1,$xc2,$xc3)=($xt0,$xt1,$xa0,$xa1); +$code.=<<___; + paddd 0xc0-0x100(%rcx),$xc0 + paddd 0xd0-0x100(%rcx),$xc1 + paddd 0xe0-0x100(%rcx),$xc2 + paddd 0xf0-0x100(%rcx),$xc3 + + movdqa $xa2,0x20(%rsp) # keep offloading $xaN + movdqa $xa3,0x30(%rsp) + + movdqa $xc0,$xt2 + punpckldq $xc1,$xc0 + movdqa $xc2,$xt3 + punpckldq $xc3,$xc2 + punpckhdq $xc1,$xt2 + punpckhdq $xc3,$xt3 + movdqa $xc0,$xc1 + punpcklqdq $xc2,$xc0 # "c0" + movdqa $xt2,$xc3 + punpcklqdq $xt3,$xt2 # "c2" + punpckhqdq $xc2,$xc1 # "c1" + punpckhqdq $xt3,$xc3 # "c3" +___ + ($xc2,$xt2)=($xt2,$xc2); + ($xt0,$xt1)=($xa2,$xa3); # use $xaN as temporary +$code.=<<___; + paddd 0x100-0x100(%rcx),$xd0 + paddd 0x110-0x100(%rcx),$xd1 + paddd 0x120-0x100(%rcx),$xd2 + paddd 0x130-0x100(%rcx),$xd3 + + movdqa $xd0,$xt2 + punpckldq $xd1,$xd0 + movdqa $xd2,$xt3 + punpckldq $xd3,$xd2 + punpckhdq $xd1,$xt2 + punpckhdq $xd3,$xt3 + movdqa $xd0,$xd1 + punpcklqdq $xd2,$xd0 # "d0" + movdqa $xt2,$xd3 + punpcklqdq $xt3,$xt2 # "d2" + punpckhqdq $xd2,$xd1 # "d1" + punpckhqdq $xt3,$xd3 # "d3" +___ + ($xd2,$xt2)=($xt2,$xd2); +$code.=<<___; + cmp \$64*4,$len + jb .Ltail4x + + movdqu 0x00($inp),$xt0 # xor with input + movdqu 0x10($inp),$xt1 + movdqu 0x20($inp),$xt2 + movdqu 0x30($inp),$xt3 + pxor 0x00(%rsp),$xt0 # $xaN is offloaded, remember? + pxor $xb0,$xt1 + pxor $xc0,$xt2 + pxor $xd0,$xt3 + + movdqu $xt0,0x00($out) + movdqu 0x40($inp),$xt0 + movdqu $xt1,0x10($out) + movdqu 0x50($inp),$xt1 + movdqu $xt2,0x20($out) + movdqu 0x60($inp),$xt2 + movdqu $xt3,0x30($out) + movdqu 0x70($inp),$xt3 + lea 0x80($inp),$inp # size optimization + pxor 0x10(%rsp),$xt0 + pxor $xb1,$xt1 + pxor $xc1,$xt2 + pxor $xd1,$xt3 + + movdqu $xt0,0x40($out) + movdqu 0x00($inp),$xt0 + movdqu $xt1,0x50($out) + movdqu 0x10($inp),$xt1 + movdqu $xt2,0x60($out) + movdqu 0x20($inp),$xt2 + movdqu $xt3,0x70($out) + lea 0x80($out),$out # size optimization + movdqu 0x30($inp),$xt3 + pxor 0x20(%rsp),$xt0 + pxor $xb2,$xt1 + pxor $xc2,$xt2 + pxor $xd2,$xt3 + + movdqu $xt0,0x00($out) + movdqu 0x40($inp),$xt0 + movdqu $xt1,0x10($out) + movdqu 0x50($inp),$xt1 + movdqu $xt2,0x20($out) + movdqu 0x60($inp),$xt2 + movdqu $xt3,0x30($out) + movdqu 0x70($inp),$xt3 + lea 0x80($inp),$inp # inp+=64*4 + pxor 0x30(%rsp),$xt0 + pxor $xb3,$xt1 + pxor $xc3,$xt2 + pxor $xd3,$xt3 + movdqu $xt0,0x40($out) + movdqu $xt1,0x50($out) + movdqu $xt2,0x60($out) + movdqu $xt3,0x70($out) + lea 0x80($out),$out # out+=64*4 + + sub \$64*4,$len + jnz .Loop_outer4x + + jmp .Ldone4x + +.Ltail4x: + cmp \$192,$len + jae .L192_or_more4x + cmp \$128,$len + jae .L128_or_more4x + cmp \$64,$len + jae .L64_or_more4x + + #movdqa 0x00(%rsp),$xt0 # $xaN is offloaded, remember? + xor %r10,%r10 + #movdqa $xt0,0x00(%rsp) + movdqa $xb0,0x10(%rsp) + movdqa $xc0,0x20(%rsp) + movdqa $xd0,0x30(%rsp) + jmp .Loop_tail4x + +.align 32 +.L64_or_more4x: + movdqu 0x00($inp),$xt0 # xor with input + movdqu 0x10($inp),$xt1 + movdqu 0x20($inp),$xt2 + movdqu 0x30($inp),$xt3 + pxor 0x00(%rsp),$xt0 # $xaxN is offloaded, remember? + pxor $xb0,$xt1 + pxor $xc0,$xt2 + pxor $xd0,$xt3 + movdqu $xt0,0x00($out) + movdqu $xt1,0x10($out) + movdqu $xt2,0x20($out) + movdqu $xt3,0x30($out) + je .Ldone4x + + movdqa 0x10(%rsp),$xt0 # $xaN is offloaded, remember? + lea 0x40($inp),$inp # inp+=64*1 + xor %r10,%r10 + movdqa $xt0,0x00(%rsp) + movdqa $xb1,0x10(%rsp) + lea 0x40($out),$out # out+=64*1 + movdqa $xc1,0x20(%rsp) + sub \$64,$len # len-=64*1 + movdqa $xd1,0x30(%rsp) + jmp .Loop_tail4x + +.align 32 +.L128_or_more4x: + movdqu 0x00($inp),$xt0 # xor with input + movdqu 0x10($inp),$xt1 + movdqu 0x20($inp),$xt2 + movdqu 0x30($inp),$xt3 + pxor 0x00(%rsp),$xt0 # $xaN is offloaded, remember? + pxor $xb0,$xt1 + pxor $xc0,$xt2 + pxor $xd0,$xt3 + + movdqu $xt0,0x00($out) + movdqu 0x40($inp),$xt0 + movdqu $xt1,0x10($out) + movdqu 0x50($inp),$xt1 + movdqu $xt2,0x20($out) + movdqu 0x60($inp),$xt2 + movdqu $xt3,0x30($out) + movdqu 0x70($inp),$xt3 + pxor 0x10(%rsp),$xt0 + pxor $xb1,$xt1 + pxor $xc1,$xt2 + pxor $xd1,$xt3 + movdqu $xt0,0x40($out) + movdqu $xt1,0x50($out) + movdqu $xt2,0x60($out) + movdqu $xt3,0x70($out) + je .Ldone4x + + movdqa 0x20(%rsp),$xt0 # $xaN is offloaded, remember? + lea 0x80($inp),$inp # inp+=64*2 + xor %r10,%r10 + movdqa $xt0,0x00(%rsp) + movdqa $xb2,0x10(%rsp) + lea 0x80($out),$out # out+=64*2 + movdqa $xc2,0x20(%rsp) + sub \$128,$len # len-=64*2 + movdqa $xd2,0x30(%rsp) + jmp .Loop_tail4x + +.align 32 +.L192_or_more4x: + movdqu 0x00($inp),$xt0 # xor with input + movdqu 0x10($inp),$xt1 + movdqu 0x20($inp),$xt2 + movdqu 0x30($inp),$xt3 + pxor 0x00(%rsp),$xt0 # $xaN is offloaded, remember? + pxor $xb0,$xt1 + pxor $xc0,$xt2 + pxor $xd0,$xt3 + + movdqu $xt0,0x00($out) + movdqu 0x40($inp),$xt0 + movdqu $xt1,0x10($out) + movdqu 0x50($inp),$xt1 + movdqu $xt2,0x20($out) + movdqu 0x60($inp),$xt2 + movdqu $xt3,0x30($out) + movdqu 0x70($inp),$xt3 + lea 0x80($inp),$inp # size optimization + pxor 0x10(%rsp),$xt0 + pxor $xb1,$xt1 + pxor $xc1,$xt2 + pxor $xd1,$xt3 + + movdqu $xt0,0x40($out) + movdqu 0x00($inp),$xt0 + movdqu $xt1,0x50($out) + movdqu 0x10($inp),$xt1 + movdqu $xt2,0x60($out) + movdqu 0x20($inp),$xt2 + movdqu $xt3,0x70($out) + lea 0x80($out),$out # size optimization + movdqu 0x30($inp),$xt3 + pxor 0x20(%rsp),$xt0 + pxor $xb2,$xt1 + pxor $xc2,$xt2 + pxor $xd2,$xt3 + movdqu $xt0,0x00($out) + movdqu $xt1,0x10($out) + movdqu $xt2,0x20($out) + movdqu $xt3,0x30($out) + je .Ldone4x + + movdqa 0x30(%rsp),$xt0 # $xaN is offloaded, remember? + lea 0x40($inp),$inp # inp+=64*3 + xor %r10,%r10 + movdqa $xt0,0x00(%rsp) + movdqa $xb3,0x10(%rsp) + lea 0x40($out),$out # out+=64*3 + movdqa $xc3,0x20(%rsp) + sub \$192,$len # len-=64*3 + movdqa $xd3,0x30(%rsp) + +.Loop_tail4x: + movzb ($inp,%r10),%eax + movzb (%rsp,%r10),%ecx + lea 1(%r10),%r10 + xor %ecx,%eax + mov %al,-1($out,%r10) + dec $len + jnz .Loop_tail4x + +.Ldone4x: +___ +$code.=<<___ if ($win64); + movaps -0xa8(%r9),%xmm6 + movaps -0x98(%r9),%xmm7 + movaps -0x88(%r9),%xmm8 + movaps -0x78(%r9),%xmm9 + movaps -0x68(%r9),%xmm10 + movaps -0x58(%r9),%xmm11 + movaps -0x48(%r9),%xmm12 + movaps -0x38(%r9),%xmm13 + movaps -0x28(%r9),%xmm14 + movaps -0x18(%r9),%xmm15 +___ +$code.=<<___; + lea (%r9),%rsp +.cfi_def_cfa_register rsp +.L4x_epilogue: + ret +.cfi_endproc +.size ChaCha20_ctr32_ssse3_4x,.-ChaCha20_ctr32_ssse3_4x +___ +} + +######################################################################## +# AVX2 code path +if ($avx>1) { +my ($xb0,$xb1,$xb2,$xb3, $xd0,$xd1,$xd2,$xd3, + $xa0,$xa1,$xa2,$xa3, $xt0,$xt1,$xt2,$xt3)=map("%ymm$_",(0..15)); +my @xx=($xa0,$xa1,$xa2,$xa3, $xb0,$xb1,$xb2,$xb3, + "%nox","%nox","%nox","%nox", $xd0,$xd1,$xd2,$xd3); + +sub AVX2_lane_ROUND { +my ($a0,$b0,$c0,$d0)=@_; +my ($a1,$b1,$c1,$d1)=map(($_&~3)+(($_+1)&3),($a0,$b0,$c0,$d0)); +my ($a2,$b2,$c2,$d2)=map(($_&~3)+(($_+1)&3),($a1,$b1,$c1,$d1)); +my ($a3,$b3,$c3,$d3)=map(($_&~3)+(($_+1)&3),($a2,$b2,$c2,$d2)); +my ($xc,$xc_,$t0,$t1)=map("\"$_\"",$xt0,$xt1,$xt2,$xt3); +my @x=map("\"$_\"",@xx); + + # Consider order in which variables are addressed by their + # index: + # + # a b c d + # + # 0 4 8 12 < even round + # 1 5 9 13 + # 2 6 10 14 + # 3 7 11 15 + # 0 5 10 15 < odd round + # 1 6 11 12 + # 2 7 8 13 + # 3 4 9 14 + # + # 'a', 'b' and 'd's are permanently allocated in registers, + # @x[0..7,12..15], while 'c's are maintained in memory. If + # you observe 'c' column, you'll notice that pair of 'c's is + # invariant between rounds. This means that we have to reload + # them once per round, in the middle. This is why you'll see + # bunch of 'c' stores and loads in the middle, but none in + # the beginning or end. + + ( + "&vpaddd (@x[$a0],@x[$a0],@x[$b0])", # Q1 + "&vpxor (@x[$d0],@x[$a0],@x[$d0])", + "&vpshufb (@x[$d0],@x[$d0],$t1)", + "&vpaddd (@x[$a1],@x[$a1],@x[$b1])", # Q2 + "&vpxor (@x[$d1],@x[$a1],@x[$d1])", + "&vpshufb (@x[$d1],@x[$d1],$t1)", + + "&vpaddd ($xc,$xc,@x[$d0])", + "&vpxor (@x[$b0],$xc,@x[$b0])", + "&vpslld ($t0,@x[$b0],12)", + "&vpsrld (@x[$b0],@x[$b0],20)", + "&vpor (@x[$b0],$t0,@x[$b0])", + "&vbroadcasti128($t0,'(%r11)')", # .Lrot24(%rip) + "&vpaddd ($xc_,$xc_,@x[$d1])", + "&vpxor (@x[$b1],$xc_,@x[$b1])", + "&vpslld ($t1,@x[$b1],12)", + "&vpsrld (@x[$b1],@x[$b1],20)", + "&vpor (@x[$b1],$t1,@x[$b1])", + + "&vpaddd (@x[$a0],@x[$a0],@x[$b0])", + "&vpxor (@x[$d0],@x[$a0],@x[$d0])", + "&vpshufb (@x[$d0],@x[$d0],$t0)", + "&vpaddd (@x[$a1],@x[$a1],@x[$b1])", + "&vpxor (@x[$d1],@x[$a1],@x[$d1])", + "&vpshufb (@x[$d1],@x[$d1],$t0)", + + "&vpaddd ($xc,$xc,@x[$d0])", + "&vpxor (@x[$b0],$xc,@x[$b0])", + "&vpslld ($t1,@x[$b0],7)", + "&vpsrld (@x[$b0],@x[$b0],25)", + "&vpor (@x[$b0],$t1,@x[$b0])", + "&vbroadcasti128($t1,'(%r10)')", # .Lrot16(%rip) + "&vpaddd ($xc_,$xc_,@x[$d1])", + "&vpxor (@x[$b1],$xc_,@x[$b1])", + "&vpslld ($t0,@x[$b1],7)", + "&vpsrld (@x[$b1],@x[$b1],25)", + "&vpor (@x[$b1],$t0,@x[$b1])", + + "&vmovdqa (\"`32*($c0-8)`(%rsp)\",$xc)", # reload pair of 'c's + "&vmovdqa (\"`32*($c1-8)`(%rsp)\",$xc_)", + "&vmovdqa ($xc,\"`32*($c2-8)`(%rsp)\")", + "&vmovdqa ($xc_,\"`32*($c3-8)`(%rsp)\")", + + "&vpaddd (@x[$a2],@x[$a2],@x[$b2])", # Q3 + "&vpxor (@x[$d2],@x[$a2],@x[$d2])", + "&vpshufb (@x[$d2],@x[$d2],$t1)", + "&vpaddd (@x[$a3],@x[$a3],@x[$b3])", # Q4 + "&vpxor (@x[$d3],@x[$a3],@x[$d3])", + "&vpshufb (@x[$d3],@x[$d3],$t1)", + + "&vpaddd ($xc,$xc,@x[$d2])", + "&vpxor (@x[$b2],$xc,@x[$b2])", + "&vpslld ($t0,@x[$b2],12)", + "&vpsrld (@x[$b2],@x[$b2],20)", + "&vpor (@x[$b2],$t0,@x[$b2])", + "&vbroadcasti128($t0,'(%r11)')", # .Lrot24(%rip) + "&vpaddd ($xc_,$xc_,@x[$d3])", + "&vpxor (@x[$b3],$xc_,@x[$b3])", + "&vpslld ($t1,@x[$b3],12)", + "&vpsrld (@x[$b3],@x[$b3],20)", + "&vpor (@x[$b3],$t1,@x[$b3])", + + "&vpaddd (@x[$a2],@x[$a2],@x[$b2])", + "&vpxor (@x[$d2],@x[$a2],@x[$d2])", + "&vpshufb (@x[$d2],@x[$d2],$t0)", + "&vpaddd (@x[$a3],@x[$a3],@x[$b3])", + "&vpxor (@x[$d3],@x[$a3],@x[$d3])", + "&vpshufb (@x[$d3],@x[$d3],$t0)", + + "&vpaddd ($xc,$xc,@x[$d2])", + "&vpxor (@x[$b2],$xc,@x[$b2])", + "&vpslld ($t1,@x[$b2],7)", + "&vpsrld (@x[$b2],@x[$b2],25)", + "&vpor (@x[$b2],$t1,@x[$b2])", + "&vbroadcasti128($t1,'(%r10)')", # .Lrot16(%rip) + "&vpaddd ($xc_,$xc_,@x[$d3])", + "&vpxor (@x[$b3],$xc_,@x[$b3])", + "&vpslld ($t0,@x[$b3],7)", + "&vpsrld (@x[$b3],@x[$b3],25)", + "&vpor (@x[$b3],$t0,@x[$b3])" + ); +} + +my $xframe = $win64 ? 0xa8 : 8; + +$code.=<<___; +.globl ChaCha20_ctr32_avx2 +.type ChaCha20_ctr32_avx2,\@function,5 +.align 32 +ChaCha20_ctr32_avx2: +.cfi_startproc + _CET_ENDBR + mov %rsp,%r9 # frame register +.cfi_def_cfa_register r9 + sub \$0x280+$xframe,%rsp + and \$-32,%rsp +___ +$code.=<<___ if ($win64); + movaps %xmm6,-0xa8(%r9) + movaps %xmm7,-0x98(%r9) + movaps %xmm8,-0x88(%r9) + movaps %xmm9,-0x78(%r9) + movaps %xmm10,-0x68(%r9) + movaps %xmm11,-0x58(%r9) + movaps %xmm12,-0x48(%r9) + movaps %xmm13,-0x38(%r9) + movaps %xmm14,-0x28(%r9) + movaps %xmm15,-0x18(%r9) +.L8x_body: +___ +$code.=<<___; + vzeroupper + + ################ stack layout + # +0x00 SIMD equivalent of @x[8-12] + # ... + # +0x80 constant copy of key[0-2] smashed by lanes + # ... + # +0x200 SIMD counters (with nonce smashed by lanes) + # ... + # +0x280 + + vbroadcasti128 .Lsigma(%rip),$xa3 # key[0] + vbroadcasti128 ($key),$xb3 # key[1] + vbroadcasti128 16($key),$xt3 # key[2] + vbroadcasti128 ($counter),$xd3 # key[3] + lea 0x100(%rsp),%rcx # size optimization + lea 0x200(%rsp),%rax # size optimization + lea .Lrot16(%rip),%r10 + lea .Lrot24(%rip),%r11 + + vpshufd \$0x00,$xa3,$xa0 # smash key by lanes... + vpshufd \$0x55,$xa3,$xa1 + vmovdqa $xa0,0x80-0x100(%rcx) # ... and offload + vpshufd \$0xaa,$xa3,$xa2 + vmovdqa $xa1,0xa0-0x100(%rcx) + vpshufd \$0xff,$xa3,$xa3 + vmovdqa $xa2,0xc0-0x100(%rcx) + vmovdqa $xa3,0xe0-0x100(%rcx) + + vpshufd \$0x00,$xb3,$xb0 + vpshufd \$0x55,$xb3,$xb1 + vmovdqa $xb0,0x100-0x100(%rcx) + vpshufd \$0xaa,$xb3,$xb2 + vmovdqa $xb1,0x120-0x100(%rcx) + vpshufd \$0xff,$xb3,$xb3 + vmovdqa $xb2,0x140-0x100(%rcx) + vmovdqa $xb3,0x160-0x100(%rcx) + + vpshufd \$0x00,$xt3,$xt0 # "xc0" + vpshufd \$0x55,$xt3,$xt1 # "xc1" + vmovdqa $xt0,0x180-0x200(%rax) + vpshufd \$0xaa,$xt3,$xt2 # "xc2" + vmovdqa $xt1,0x1a0-0x200(%rax) + vpshufd \$0xff,$xt3,$xt3 # "xc3" + vmovdqa $xt2,0x1c0-0x200(%rax) + vmovdqa $xt3,0x1e0-0x200(%rax) + + vpshufd \$0x00,$xd3,$xd0 + vpshufd \$0x55,$xd3,$xd1 + vpaddd .Lincy(%rip),$xd0,$xd0 # don't save counters yet + vpshufd \$0xaa,$xd3,$xd2 + vmovdqa $xd1,0x220-0x200(%rax) + vpshufd \$0xff,$xd3,$xd3 + vmovdqa $xd2,0x240-0x200(%rax) + vmovdqa $xd3,0x260-0x200(%rax) + + jmp .Loop_enter8x + +.align 32 +.Loop_outer8x: + vmovdqa 0x80-0x100(%rcx),$xa0 # re-load smashed key + vmovdqa 0xa0-0x100(%rcx),$xa1 + vmovdqa 0xc0-0x100(%rcx),$xa2 + vmovdqa 0xe0-0x100(%rcx),$xa3 + vmovdqa 0x100-0x100(%rcx),$xb0 + vmovdqa 0x120-0x100(%rcx),$xb1 + vmovdqa 0x140-0x100(%rcx),$xb2 + vmovdqa 0x160-0x100(%rcx),$xb3 + vmovdqa 0x180-0x200(%rax),$xt0 # "xc0" + vmovdqa 0x1a0-0x200(%rax),$xt1 # "xc1" + vmovdqa 0x1c0-0x200(%rax),$xt2 # "xc2" + vmovdqa 0x1e0-0x200(%rax),$xt3 # "xc3" + vmovdqa 0x200-0x200(%rax),$xd0 + vmovdqa 0x220-0x200(%rax),$xd1 + vmovdqa 0x240-0x200(%rax),$xd2 + vmovdqa 0x260-0x200(%rax),$xd3 + vpaddd .Leight(%rip),$xd0,$xd0 # next SIMD counters + +.Loop_enter8x: + vmovdqa $xt2,0x40(%rsp) # SIMD equivalent of "@x[10]" + vmovdqa $xt3,0x60(%rsp) # SIMD equivalent of "@x[11]" + vbroadcasti128 (%r10),$xt3 + vmovdqa $xd0,0x200-0x200(%rax) # save SIMD counters + mov \$10,%eax + jmp .Loop8x + +.align 32 +.Loop8x: +___ + foreach (&AVX2_lane_ROUND(0, 4, 8,12)) { eval; } + foreach (&AVX2_lane_ROUND(0, 5,10,15)) { eval; } +$code.=<<___; + dec %eax + jnz .Loop8x + + lea 0x200(%rsp),%rax # size optimization + vpaddd 0x80-0x100(%rcx),$xa0,$xa0 # accumulate key + vpaddd 0xa0-0x100(%rcx),$xa1,$xa1 + vpaddd 0xc0-0x100(%rcx),$xa2,$xa2 + vpaddd 0xe0-0x100(%rcx),$xa3,$xa3 + + vpunpckldq $xa1,$xa0,$xt2 # "de-interlace" data + vpunpckldq $xa3,$xa2,$xt3 + vpunpckhdq $xa1,$xa0,$xa0 + vpunpckhdq $xa3,$xa2,$xa2 + vpunpcklqdq $xt3,$xt2,$xa1 # "a0" + vpunpckhqdq $xt3,$xt2,$xt2 # "a1" + vpunpcklqdq $xa2,$xa0,$xa3 # "a2" + vpunpckhqdq $xa2,$xa0,$xa0 # "a3" +___ + ($xa0,$xa1,$xa2,$xa3,$xt2)=($xa1,$xt2,$xa3,$xa0,$xa2); +$code.=<<___; + vpaddd 0x100-0x100(%rcx),$xb0,$xb0 + vpaddd 0x120-0x100(%rcx),$xb1,$xb1 + vpaddd 0x140-0x100(%rcx),$xb2,$xb2 + vpaddd 0x160-0x100(%rcx),$xb3,$xb3 + + vpunpckldq $xb1,$xb0,$xt2 + vpunpckldq $xb3,$xb2,$xt3 + vpunpckhdq $xb1,$xb0,$xb0 + vpunpckhdq $xb3,$xb2,$xb2 + vpunpcklqdq $xt3,$xt2,$xb1 # "b0" + vpunpckhqdq $xt3,$xt2,$xt2 # "b1" + vpunpcklqdq $xb2,$xb0,$xb3 # "b2" + vpunpckhqdq $xb2,$xb0,$xb0 # "b3" +___ + ($xb0,$xb1,$xb2,$xb3,$xt2)=($xb1,$xt2,$xb3,$xb0,$xb2); +$code.=<<___; + vperm2i128 \$0x20,$xb0,$xa0,$xt3 # "de-interlace" further + vperm2i128 \$0x31,$xb0,$xa0,$xb0 + vperm2i128 \$0x20,$xb1,$xa1,$xa0 + vperm2i128 \$0x31,$xb1,$xa1,$xb1 + vperm2i128 \$0x20,$xb2,$xa2,$xa1 + vperm2i128 \$0x31,$xb2,$xa2,$xb2 + vperm2i128 \$0x20,$xb3,$xa3,$xa2 + vperm2i128 \$0x31,$xb3,$xa3,$xb3 +___ + ($xa0,$xa1,$xa2,$xa3,$xt3)=($xt3,$xa0,$xa1,$xa2,$xa3); + my ($xc0,$xc1,$xc2,$xc3)=($xt0,$xt1,$xa0,$xa1); +$code.=<<___; + vmovdqa $xa0,0x00(%rsp) # offload $xaN + vmovdqa $xa1,0x20(%rsp) + vmovdqa 0x40(%rsp),$xc2 # $xa0 + vmovdqa 0x60(%rsp),$xc3 # $xa1 + + vpaddd 0x180-0x200(%rax),$xc0,$xc0 + vpaddd 0x1a0-0x200(%rax),$xc1,$xc1 + vpaddd 0x1c0-0x200(%rax),$xc2,$xc2 + vpaddd 0x1e0-0x200(%rax),$xc3,$xc3 + + vpunpckldq $xc1,$xc0,$xt2 + vpunpckldq $xc3,$xc2,$xt3 + vpunpckhdq $xc1,$xc0,$xc0 + vpunpckhdq $xc3,$xc2,$xc2 + vpunpcklqdq $xt3,$xt2,$xc1 # "c0" + vpunpckhqdq $xt3,$xt2,$xt2 # "c1" + vpunpcklqdq $xc2,$xc0,$xc3 # "c2" + vpunpckhqdq $xc2,$xc0,$xc0 # "c3" +___ + ($xc0,$xc1,$xc2,$xc3,$xt2)=($xc1,$xt2,$xc3,$xc0,$xc2); +$code.=<<___; + vpaddd 0x200-0x200(%rax),$xd0,$xd0 + vpaddd 0x220-0x200(%rax),$xd1,$xd1 + vpaddd 0x240-0x200(%rax),$xd2,$xd2 + vpaddd 0x260-0x200(%rax),$xd3,$xd3 + + vpunpckldq $xd1,$xd0,$xt2 + vpunpckldq $xd3,$xd2,$xt3 + vpunpckhdq $xd1,$xd0,$xd0 + vpunpckhdq $xd3,$xd2,$xd2 + vpunpcklqdq $xt3,$xt2,$xd1 # "d0" + vpunpckhqdq $xt3,$xt2,$xt2 # "d1" + vpunpcklqdq $xd2,$xd0,$xd3 # "d2" + vpunpckhqdq $xd2,$xd0,$xd0 # "d3" +___ + ($xd0,$xd1,$xd2,$xd3,$xt2)=($xd1,$xt2,$xd3,$xd0,$xd2); +$code.=<<___; + vperm2i128 \$0x20,$xd0,$xc0,$xt3 # "de-interlace" further + vperm2i128 \$0x31,$xd0,$xc0,$xd0 + vperm2i128 \$0x20,$xd1,$xc1,$xc0 + vperm2i128 \$0x31,$xd1,$xc1,$xd1 + vperm2i128 \$0x20,$xd2,$xc2,$xc1 + vperm2i128 \$0x31,$xd2,$xc2,$xd2 + vperm2i128 \$0x20,$xd3,$xc3,$xc2 + vperm2i128 \$0x31,$xd3,$xc3,$xd3 +___ + ($xc0,$xc1,$xc2,$xc3,$xt3)=($xt3,$xc0,$xc1,$xc2,$xc3); + ($xb0,$xb1,$xb2,$xb3,$xc0,$xc1,$xc2,$xc3)= + ($xc0,$xc1,$xc2,$xc3,$xb0,$xb1,$xb2,$xb3); + ($xa0,$xa1)=($xt2,$xt3); +$code.=<<___; + vmovdqa 0x00(%rsp),$xa0 # $xaN was offloaded, remember? + vmovdqa 0x20(%rsp),$xa1 + + cmp \$64*8,$len + jb .Ltail8x + + vpxor 0x00($inp),$xa0,$xa0 # xor with input + vpxor 0x20($inp),$xb0,$xb0 + vpxor 0x40($inp),$xc0,$xc0 + vpxor 0x60($inp),$xd0,$xd0 + lea 0x80($inp),$inp # size optimization + vmovdqu $xa0,0x00($out) + vmovdqu $xb0,0x20($out) + vmovdqu $xc0,0x40($out) + vmovdqu $xd0,0x60($out) + lea 0x80($out),$out # size optimization + + vpxor 0x00($inp),$xa1,$xa1 + vpxor 0x20($inp),$xb1,$xb1 + vpxor 0x40($inp),$xc1,$xc1 + vpxor 0x60($inp),$xd1,$xd1 + lea 0x80($inp),$inp # size optimization + vmovdqu $xa1,0x00($out) + vmovdqu $xb1,0x20($out) + vmovdqu $xc1,0x40($out) + vmovdqu $xd1,0x60($out) + lea 0x80($out),$out # size optimization + + vpxor 0x00($inp),$xa2,$xa2 + vpxor 0x20($inp),$xb2,$xb2 + vpxor 0x40($inp),$xc2,$xc2 + vpxor 0x60($inp),$xd2,$xd2 + lea 0x80($inp),$inp # size optimization + vmovdqu $xa2,0x00($out) + vmovdqu $xb2,0x20($out) + vmovdqu $xc2,0x40($out) + vmovdqu $xd2,0x60($out) + lea 0x80($out),$out # size optimization + + vpxor 0x00($inp),$xa3,$xa3 + vpxor 0x20($inp),$xb3,$xb3 + vpxor 0x40($inp),$xc3,$xc3 + vpxor 0x60($inp),$xd3,$xd3 + lea 0x80($inp),$inp # size optimization + vmovdqu $xa3,0x00($out) + vmovdqu $xb3,0x20($out) + vmovdqu $xc3,0x40($out) + vmovdqu $xd3,0x60($out) + lea 0x80($out),$out # size optimization + + sub \$64*8,$len + jnz .Loop_outer8x + + jmp .Ldone8x + +.Ltail8x: + cmp \$448,$len + jae .L448_or_more8x + cmp \$384,$len + jae .L384_or_more8x + cmp \$320,$len + jae .L320_or_more8x + cmp \$256,$len + jae .L256_or_more8x + cmp \$192,$len + jae .L192_or_more8x + cmp \$128,$len + jae .L128_or_more8x + cmp \$64,$len + jae .L64_or_more8x + + xor %r10,%r10 + vmovdqa $xa0,0x00(%rsp) + vmovdqa $xb0,0x20(%rsp) + jmp .Loop_tail8x + +.align 32 +.L64_or_more8x: + vpxor 0x00($inp),$xa0,$xa0 # xor with input + vpxor 0x20($inp),$xb0,$xb0 + vmovdqu $xa0,0x00($out) + vmovdqu $xb0,0x20($out) + je .Ldone8x + + lea 0x40($inp),$inp # inp+=64*1 + xor %r10,%r10 + vmovdqa $xc0,0x00(%rsp) + lea 0x40($out),$out # out+=64*1 + sub \$64,$len # len-=64*1 + vmovdqa $xd0,0x20(%rsp) + jmp .Loop_tail8x + +.align 32 +.L128_or_more8x: + vpxor 0x00($inp),$xa0,$xa0 # xor with input + vpxor 0x20($inp),$xb0,$xb0 + vpxor 0x40($inp),$xc0,$xc0 + vpxor 0x60($inp),$xd0,$xd0 + vmovdqu $xa0,0x00($out) + vmovdqu $xb0,0x20($out) + vmovdqu $xc0,0x40($out) + vmovdqu $xd0,0x60($out) + je .Ldone8x + + lea 0x80($inp),$inp # inp+=64*2 + xor %r10,%r10 + vmovdqa $xa1,0x00(%rsp) + lea 0x80($out),$out # out+=64*2 + sub \$128,$len # len-=64*2 + vmovdqa $xb1,0x20(%rsp) + jmp .Loop_tail8x + +.align 32 +.L192_or_more8x: + vpxor 0x00($inp),$xa0,$xa0 # xor with input + vpxor 0x20($inp),$xb0,$xb0 + vpxor 0x40($inp),$xc0,$xc0 + vpxor 0x60($inp),$xd0,$xd0 + vpxor 0x80($inp),$xa1,$xa1 + vpxor 0xa0($inp),$xb1,$xb1 + vmovdqu $xa0,0x00($out) + vmovdqu $xb0,0x20($out) + vmovdqu $xc0,0x40($out) + vmovdqu $xd0,0x60($out) + vmovdqu $xa1,0x80($out) + vmovdqu $xb1,0xa0($out) + je .Ldone8x + + lea 0xc0($inp),$inp # inp+=64*3 + xor %r10,%r10 + vmovdqa $xc1,0x00(%rsp) + lea 0xc0($out),$out # out+=64*3 + sub \$192,$len # len-=64*3 + vmovdqa $xd1,0x20(%rsp) + jmp .Loop_tail8x + +.align 32 +.L256_or_more8x: + vpxor 0x00($inp),$xa0,$xa0 # xor with input + vpxor 0x20($inp),$xb0,$xb0 + vpxor 0x40($inp),$xc0,$xc0 + vpxor 0x60($inp),$xd0,$xd0 + vpxor 0x80($inp),$xa1,$xa1 + vpxor 0xa0($inp),$xb1,$xb1 + vpxor 0xc0($inp),$xc1,$xc1 + vpxor 0xe0($inp),$xd1,$xd1 + vmovdqu $xa0,0x00($out) + vmovdqu $xb0,0x20($out) + vmovdqu $xc0,0x40($out) + vmovdqu $xd0,0x60($out) + vmovdqu $xa1,0x80($out) + vmovdqu $xb1,0xa0($out) + vmovdqu $xc1,0xc0($out) + vmovdqu $xd1,0xe0($out) + je .Ldone8x + + lea 0x100($inp),$inp # inp+=64*4 + xor %r10,%r10 + vmovdqa $xa2,0x00(%rsp) + lea 0x100($out),$out # out+=64*4 + sub \$256,$len # len-=64*4 + vmovdqa $xb2,0x20(%rsp) + jmp .Loop_tail8x + +.align 32 +.L320_or_more8x: + vpxor 0x00($inp),$xa0,$xa0 # xor with input + vpxor 0x20($inp),$xb0,$xb0 + vpxor 0x40($inp),$xc0,$xc0 + vpxor 0x60($inp),$xd0,$xd0 + vpxor 0x80($inp),$xa1,$xa1 + vpxor 0xa0($inp),$xb1,$xb1 + vpxor 0xc0($inp),$xc1,$xc1 + vpxor 0xe0($inp),$xd1,$xd1 + vpxor 0x100($inp),$xa2,$xa2 + vpxor 0x120($inp),$xb2,$xb2 + vmovdqu $xa0,0x00($out) + vmovdqu $xb0,0x20($out) + vmovdqu $xc0,0x40($out) + vmovdqu $xd0,0x60($out) + vmovdqu $xa1,0x80($out) + vmovdqu $xb1,0xa0($out) + vmovdqu $xc1,0xc0($out) + vmovdqu $xd1,0xe0($out) + vmovdqu $xa2,0x100($out) + vmovdqu $xb2,0x120($out) + je .Ldone8x + + lea 0x140($inp),$inp # inp+=64*5 + xor %r10,%r10 + vmovdqa $xc2,0x00(%rsp) + lea 0x140($out),$out # out+=64*5 + sub \$320,$len # len-=64*5 + vmovdqa $xd2,0x20(%rsp) + jmp .Loop_tail8x + +.align 32 +.L384_or_more8x: + vpxor 0x00($inp),$xa0,$xa0 # xor with input + vpxor 0x20($inp),$xb0,$xb0 + vpxor 0x40($inp),$xc0,$xc0 + vpxor 0x60($inp),$xd0,$xd0 + vpxor 0x80($inp),$xa1,$xa1 + vpxor 0xa0($inp),$xb1,$xb1 + vpxor 0xc0($inp),$xc1,$xc1 + vpxor 0xe0($inp),$xd1,$xd1 + vpxor 0x100($inp),$xa2,$xa2 + vpxor 0x120($inp),$xb2,$xb2 + vpxor 0x140($inp),$xc2,$xc2 + vpxor 0x160($inp),$xd2,$xd2 + vmovdqu $xa0,0x00($out) + vmovdqu $xb0,0x20($out) + vmovdqu $xc0,0x40($out) + vmovdqu $xd0,0x60($out) + vmovdqu $xa1,0x80($out) + vmovdqu $xb1,0xa0($out) + vmovdqu $xc1,0xc0($out) + vmovdqu $xd1,0xe0($out) + vmovdqu $xa2,0x100($out) + vmovdqu $xb2,0x120($out) + vmovdqu $xc2,0x140($out) + vmovdqu $xd2,0x160($out) + je .Ldone8x + + lea 0x180($inp),$inp # inp+=64*6 + xor %r10,%r10 + vmovdqa $xa3,0x00(%rsp) + lea 0x180($out),$out # out+=64*6 + sub \$384,$len # len-=64*6 + vmovdqa $xb3,0x20(%rsp) + jmp .Loop_tail8x + +.align 32 +.L448_or_more8x: + vpxor 0x00($inp),$xa0,$xa0 # xor with input + vpxor 0x20($inp),$xb0,$xb0 + vpxor 0x40($inp),$xc0,$xc0 + vpxor 0x60($inp),$xd0,$xd0 + vpxor 0x80($inp),$xa1,$xa1 + vpxor 0xa0($inp),$xb1,$xb1 + vpxor 0xc0($inp),$xc1,$xc1 + vpxor 0xe0($inp),$xd1,$xd1 + vpxor 0x100($inp),$xa2,$xa2 + vpxor 0x120($inp),$xb2,$xb2 + vpxor 0x140($inp),$xc2,$xc2 + vpxor 0x160($inp),$xd2,$xd2 + vpxor 0x180($inp),$xa3,$xa3 + vpxor 0x1a0($inp),$xb3,$xb3 + vmovdqu $xa0,0x00($out) + vmovdqu $xb0,0x20($out) + vmovdqu $xc0,0x40($out) + vmovdqu $xd0,0x60($out) + vmovdqu $xa1,0x80($out) + vmovdqu $xb1,0xa0($out) + vmovdqu $xc1,0xc0($out) + vmovdqu $xd1,0xe0($out) + vmovdqu $xa2,0x100($out) + vmovdqu $xb2,0x120($out) + vmovdqu $xc2,0x140($out) + vmovdqu $xd2,0x160($out) + vmovdqu $xa3,0x180($out) + vmovdqu $xb3,0x1a0($out) + je .Ldone8x + + lea 0x1c0($inp),$inp # inp+=64*7 + xor %r10,%r10 + vmovdqa $xc3,0x00(%rsp) + lea 0x1c0($out),$out # out+=64*7 + sub \$448,$len # len-=64*7 + vmovdqa $xd3,0x20(%rsp) + +.Loop_tail8x: + movzb ($inp,%r10),%eax + movzb (%rsp,%r10),%ecx + lea 1(%r10),%r10 + xor %ecx,%eax + mov %al,-1($out,%r10) + dec $len + jnz .Loop_tail8x + +.Ldone8x: + vzeroall +___ +$code.=<<___ if ($win64); + movaps -0xa8(%r9),%xmm6 + movaps -0x98(%r9),%xmm7 + movaps -0x88(%r9),%xmm8 + movaps -0x78(%r9),%xmm9 + movaps -0x68(%r9),%xmm10 + movaps -0x58(%r9),%xmm11 + movaps -0x48(%r9),%xmm12 + movaps -0x38(%r9),%xmm13 + movaps -0x28(%r9),%xmm14 + movaps -0x18(%r9),%xmm15 +___ +$code.=<<___; + lea (%r9),%rsp +.cfi_def_cfa_register rsp +.L8x_epilogue: + ret +.cfi_endproc +.size ChaCha20_ctr32_avx2,.-ChaCha20_ctr32_avx2 +___ +} + +######################################################################## +# AVX512 code paths were removed + +# EXCEPTION_DISPOSITION handler (EXCEPTION_RECORD *rec,ULONG64 frame, +# CONTEXT *context,DISPATCHER_CONTEXT *disp) +if ($win64) { +$rec="%rcx"; +$frame="%rdx"; +$context="%r8"; +$disp="%r9"; + +$code.=<<___; +.extern __imp_RtlVirtualUnwind +.type se_handler,\@abi-omnipotent +.align 16 +se_handler: + push %rsi + push %rdi + push %rbx + push %rbp + push %r12 + push %r13 + push %r14 + push %r15 + pushfq + sub \$64,%rsp + + mov 120($context),%rax # pull context->Rax + mov 248($context),%rbx # pull context->Rip + + mov 8($disp),%rsi # disp->ImageBase + mov 56($disp),%r11 # disp->HandlerData + + lea .Lctr32_body(%rip),%r10 + cmp %r10,%rbx # context->Rip<.Lprologue + jb .Lcommon_seh_tail + + mov 152($context),%rax # pull context->Rsp + + lea .Lno_data(%rip),%r10 # epilogue label + cmp %r10,%rbx # context->Rip>=.Lepilogue + jae .Lcommon_seh_tail + + lea 64+24+48(%rax),%rax + + mov -8(%rax),%rbx + mov -16(%rax),%rbp + mov -24(%rax),%r12 + mov -32(%rax),%r13 + mov -40(%rax),%r14 + mov -48(%rax),%r15 + mov %rbx,144($context) # restore context->Rbx + mov %rbp,160($context) # restore context->Rbp + mov %r12,216($context) # restore context->R12 + mov %r13,224($context) # restore context->R13 + mov %r14,232($context) # restore context->R14 + mov %r15,240($context) # restore context->R14 + +.Lcommon_seh_tail: + mov 8(%rax),%rdi + mov 16(%rax),%rsi + mov %rax,152($context) # restore context->Rsp + mov %rsi,168($context) # restore context->Rsi + mov %rdi,176($context) # restore context->Rdi + + mov 40($disp),%rdi # disp->ContextRecord + mov $context,%rsi # context + mov \$154,%ecx # sizeof(CONTEXT) + .long 0xa548f3fc # cld; rep movsq + + mov $disp,%rsi + xor %rcx,%rcx # arg1, UNW_FLAG_NHANDLER + mov 8(%rsi),%rdx # arg2, disp->ImageBase + mov 0(%rsi),%r8 # arg3, disp->ControlPc + mov 16(%rsi),%r9 # arg4, disp->FunctionEntry + mov 40(%rsi),%r10 # disp->ContextRecord + lea 56(%rsi),%r11 # &disp->HandlerData + lea 24(%rsi),%r12 # &disp->EstablisherFrame + mov %r10,32(%rsp) # arg5 + mov %r11,40(%rsp) # arg6 + mov %r12,48(%rsp) # arg7 + mov %rcx,56(%rsp) # arg8, (NULL) + call *__imp_RtlVirtualUnwind(%rip) + + mov \$1,%eax # ExceptionContinueSearch + add \$64,%rsp + popfq + pop %r15 + pop %r14 + pop %r13 + pop %r12 + pop %rbp + pop %rbx + pop %rdi + pop %rsi + ret +.size se_handler,.-se_handler + +.type ssse3_handler,\@abi-omnipotent +.align 16 +ssse3_handler: + push %rsi + push %rdi + push %rbx + push %rbp + push %r12 + push %r13 + push %r14 + push %r15 + pushfq + sub \$64,%rsp + + mov 120($context),%rax # pull context->Rax + mov 248($context),%rbx # pull context->Rip + + mov 8($disp),%rsi # disp->ImageBase + mov 56($disp),%r11 # disp->HandlerData + + mov 0(%r11),%r10d # HandlerData[0] + lea (%rsi,%r10),%r10 # prologue label + cmp %r10,%rbx # context->RipR9 + + mov 4(%r11),%r10d # HandlerData[1] + lea (%rsi,%r10),%r10 # epilogue label + cmp %r10,%rbx # context->Rip>=epilogue label + jae .Lcommon_seh_tail + + lea -0x28(%rax),%rsi + lea 512($context),%rdi # &context.Xmm6 + mov \$4,%ecx + .long 0xa548f3fc # cld; rep movsq + + jmp .Lcommon_seh_tail +.size ssse3_handler,.-ssse3_handler + +.type full_handler,\@abi-omnipotent +.align 16 +full_handler: + push %rsi + push %rdi + push %rbx + push %rbp + push %r12 + push %r13 + push %r14 + push %r15 + pushfq + sub \$64,%rsp + + mov 120($context),%rax # pull context->Rax + mov 248($context),%rbx # pull context->Rip + + mov 8($disp),%rsi # disp->ImageBase + mov 56($disp),%r11 # disp->HandlerData + + mov 0(%r11),%r10d # HandlerData[0] + lea (%rsi,%r10),%r10 # prologue label + cmp %r10,%rbx # context->RipR9 + + mov 4(%r11),%r10d # HandlerData[1] + lea (%rsi,%r10),%r10 # epilogue label + cmp %r10,%rbx # context->Rip>=epilogue label + jae .Lcommon_seh_tail + + lea -0xa8(%rax),%rsi + lea 512($context),%rdi # &context.Xmm6 + mov \$20,%ecx + .long 0xa548f3fc # cld; rep movsq + + jmp .Lcommon_seh_tail +.size full_handler,.-full_handler + +.section .pdata +.align 4 + .rva .LSEH_begin_ChaCha20_ctr32_nohw + .rva .LSEH_end_ChaCha20_ctr32_nohw + .rva .LSEH_info_ChaCha20_ctr32_nohw + + .rva .LSEH_begin_ChaCha20_ctr32_ssse3_4x + .rva .LSEH_end_ChaCha20_ctr32_ssse3_4x + .rva .LSEH_info_ChaCha20_ctr32_ssse3_4x +___ +$code.=<<___ if ($avx>1); + .rva .LSEH_begin_ChaCha20_ctr32_avx2 + .rva .LSEH_end_ChaCha20_ctr32_avx2 + .rva .LSEH_info_ChaCha20_ctr32_avx2 +___ +$code.=<<___; +.section .xdata +.align 8 +.LSEH_info_ChaCha20_ctr32_nohw: + .byte 9,0,0,0 + .rva se_handler + +.LSEH_info_ChaCha20_ctr32_ssse3_4x: + .byte 9,0,0,0 + .rva full_handler + .rva .L4x_body,.L4x_epilogue +___ +$code.=<<___ if ($avx>1); +.LSEH_info_ChaCha20_ctr32_avx2: + .byte 9,0,0,0 + .rva full_handler + .rva .L8x_body,.L8x_epilogue # HandlerData[] +___ +} + +foreach (split("\n",$code)) { + s/\`([^\`]*)\`/eval $1/ge; + + s/%x#%[yz]/%x/g; # "down-shift" + + print $_,"\n"; +} + +close STDOUT or die "error closing STDOUT: $!"; diff --git a/http/vendor/ring/crypto/cipher/asm/chacha20_poly1305_armv8.pl b/http/vendor/ring/crypto/cipher/asm/chacha20_poly1305_armv8.pl new file mode 100644 index 0000000..06a35e0 --- /dev/null +++ b/http/vendor/ring/crypto/cipher/asm/chacha20_poly1305_armv8.pl @@ -0,0 +1,1643 @@ +#!/usr/bin/env perl + +# Copyright (c) 2020, CloudFlare Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +############################################################################## +# # +# Author: Vlad Krasnov # +# # +############################################################################## + +$flavour = shift; +while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {} + +$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; +( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or +( $xlate="${dir}../../perlasm/arm-xlate.pl" and -f $xlate) or +die "can't locate arm-xlate.pl"; + +open OUT,"| \"$^X\" $xlate $flavour $output"; +*STDOUT=*OUT; + +my ($oup,$inp,$inl,$adp,$adl,$keyp,$itr1,$itr2) = ("x0","x1","x2","x3","x4","x5","x6","x7"); +my ($acc0,$acc1,$acc2) = map("x$_",(8..10)); +my ($t0,$t1,$t2,$t3) = map("x$_",(11..14)); +my ($one, $r0, $r1) = ("x15","x16","x17"); +my ($t0w) = $t0 =~ s/x/w/r; + +my ($A0,$A1,$A2,$A3,$A4,$B0,$B1,$B2,$B3,$B4,$C0,$C1,$C2,$C3,$C4,$D0,$D1,$D2,$D3,$D4) = map("v$_",(0..19)); +my ($T0,$T1,$T2,$T3) = map("v$_",(20..23)); + +my $CONSTS = "v24"; +my $INC = "v25"; +my $ROL8 = "v26"; +my $CLAMP = "v27"; + +my ($B_STORE, $C_STORE, $D_STORE) = map("v$_",(28..30)); + +my $S_STORE = $CLAMP; +my $LEN_STORE = "v31"; + +sub chacha_qr { +my ($a,$b,$c,$d,$t,$dir)=@_; +my ($shift_b,$shift_d) = $dir =~ /left/ ? ("#4","#12") : ("#12","#4"); +$code.=<<___; + add $a.4s, $a.4s, $b.4s + eor $d.16b, $d.16b, $a.16b + rev32 $d.8h, $d.8h + + add $c.4s, $c.4s, $d.4s + eor $b.16b, $b.16b, $c.16b + ushr $t.4s, $b.4s, #20 + sli $t.4s, $b.4s, #12 +___ + ($t,$b) = ($b,$t); +$code.=<<___; + add $a.4s, $a.4s, $b.4s + eor $d.16b, $d.16b, $a.16b + tbl $d.16b, {$d.16b}, $ROL8.16b + + add $c.4s, $c.4s, $d.4s + eor $b.16b, $b.16b, $c.16b + ushr $t.4s, $b.4s, #25 + sli $t.4s, $b.4s, #7 +___ + ($t,$b) = ($b,$t); +$code.=<<___; + ext $b.16b, $b.16b, $b.16b, $shift_b + ext $c.16b, $c.16b, $c.16b, #8 + ext $d.16b, $d.16b, $d.16b, $shift_d +___ +} + +sub poly_add { +my ($src)=@_; +$code.="ldp $t0, $t1, [$src], 16 + adds $acc0, $acc0, $t0 + adcs $acc1, $acc1, $t1 + adc $acc2, $acc2, $one\n"; +} + +sub poly_add_vec { +my ($src)=@_; +$code.="mov $t0, $src.d[0] + mov $t1, $src.d[1] + adds $acc0, $acc0, $t0 + adcs $acc1, $acc1, $t1 + adc $acc2, $acc2, $one\n"; +} + +sub poly_stage1 { +$code.="mul $t0, $acc0, $r0 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh $t1, $acc0, $r0 + mul $t2, $acc1, $r0 + umulh $t3, $acc1, $r0 + adds $t1, $t1, $t2 + mul $t2, $acc2, $r0 + adc $t2, $t2, $t3\n"; +} + +sub poly_stage2 { +$code.="mul $t3, $acc0, $r1 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh $acc0, $acc0, $r1 + adds $t1, $t1, $t3 + mul $t3, $acc1, $r1 + umulh $acc1, $acc1, $r1 + adcs $t3, $t3, $acc0 + mul $acc2, $acc2, $r1 + adc $acc2, $acc2, $acc1 + adds $t2, $t2, $t3 + adc $t3, $acc2, xzr\n"; +} + +# At the beginning of the reduce stage t = [t3:t2:t1:t0] is a product of +# r = [r1:r0] and acc = [acc2:acc1:acc0] +# r is 124 bits at most (due to clamping) and acc is 131 bits at most +# (acc2 is at most 4 before the addition and can be at most 6 when we add in +# the next block) therefore t is at most 255 bits big, and t3 is 63 bits. +sub poly_reduce_stage { +$code.="and $acc2, $t2, #3 // At this point acc2 is 2 bits at most (value of 3) + and $acc0, $t2, #-4 + extr $t2, $t3, $t2, #2 + adds $acc0, $acc0, $t0 + lsr $t0, $t3, #2 + adc $acc1, $t3, $t0 // No carry out since t0 is 61 bits and t3 is 63 bits + adds $acc0, $acc0, $t2 + adcs $acc1, $acc1, $t1 + adc $acc2, $acc2, xzr // At this point acc2 has the value of 4 at most \n"; +} + +sub poly_mul { + &poly_stage1(); + &poly_stage2(); + &poly_reduce_stage(); +} + +sub chacha_qr_x3 { +my ($dir)=@_; +my ($shift_b,$shift_d) = $dir =~ /left/ ? ("#4","#12") : ("#12","#4"); +$code.=<<___; + add $A0.4s, $A0.4s, $B0.4s + add $A1.4s, $A1.4s, $B1.4s + add $A2.4s, $A2.4s, $B2.4s + eor $D0.16b, $D0.16b, $A0.16b + eor $D1.16b, $D1.16b, $A1.16b + eor $D2.16b, $D2.16b, $A2.16b + rev32 $D0.8h, $D0.8h + rev32 $D1.8h, $D1.8h + rev32 $D2.8h, $D2.8h + + add $C0.4s, $C0.4s, $D0.4s + add $C1.4s, $C1.4s, $D1.4s + add $C2.4s, $C2.4s, $D2.4s + eor $B0.16b, $B0.16b, $C0.16b + eor $B1.16b, $B1.16b, $C1.16b + eor $B2.16b, $B2.16b, $C2.16b + ushr $T0.4s, $B0.4s, #20 + sli $T0.4s, $B0.4s, #12 + ushr $B0.4s, $B1.4s, #20 + sli $B0.4s, $B1.4s, #12 + ushr $B1.4s, $B2.4s, #20 + sli $B1.4s, $B2.4s, #12 + + add $A0.4s, $A0.4s, $T0.4s + add $A1.4s, $A1.4s, $B0.4s + add $A2.4s, $A2.4s, $B1.4s + eor $D0.16b, $D0.16b, $A0.16b + eor $D1.16b, $D1.16b, $A1.16b + eor $D2.16b, $D2.16b, $A2.16b + tbl $D0.16b, {$D0.16b}, $ROL8.16b + tbl $D1.16b, {$D1.16b}, $ROL8.16b + tbl $D2.16b, {$D2.16b}, $ROL8.16b + + add $C0.4s, $C0.4s, $D0.4s + add $C1.4s, $C1.4s, $D1.4s + add $C2.4s, $C2.4s, $D2.4s + eor $T0.16b, $T0.16b, $C0.16b + eor $B0.16b, $B0.16b, $C1.16b + eor $B1.16b, $B1.16b, $C2.16b + ushr $B2.4s, $B1.4s, #25 + sli $B2.4s, $B1.4s, #7 + ushr $B1.4s, $B0.4s, #25 + sli $B1.4s, $B0.4s, #7 + ushr $B0.4s, $T0.4s, #25 + sli $B0.4s, $T0.4s, #7 + + ext $B0.16b, $B0.16b, $B0.16b, $shift_b + ext $B1.16b, $B1.16b, $B1.16b, $shift_b + ext $B2.16b, $B2.16b, $B2.16b, $shift_b + + ext $C0.16b, $C0.16b, $C0.16b, #8 + ext $C1.16b, $C1.16b, $C1.16b, #8 + ext $C2.16b, $C2.16b, $C2.16b, #8 + + ext $D0.16b, $D0.16b, $D0.16b, $shift_d + ext $D1.16b, $D1.16b, $D1.16b, $shift_d + ext $D2.16b, $D2.16b, $D2.16b, $shift_d +___ +} + +# When preparing 5 ChaCha20 blocks in parallel, we operate on 4 blocks vertically as introduced by Andrew Moon +# the fifth block is done horizontally +sub chacha_qr_x5 { +my ($dir)=@_; +my ($a0,$a1,$a2,$a3) = $dir =~ /left/ ? ($A0,$A1,$A2,$A3) : ($A0,$A1,$A2,$A3); +my ($b0,$b1,$b2,$b3) = $dir =~ /left/ ? ($B0,$B1,$B2,$B3) : ($B1,$B2,$B3,$B0); +my ($c0,$c1,$c2,$c3) = $dir =~ /left/ ? ($C0,$C1,$C2,$C3) : ($C2,$C3,$C0,$C1); +my ($d0,$d1,$d2,$d3) = $dir =~ /left/ ? ($D0,$D1,$D2,$D3) : ($D3,$D0,$D1,$D2); +my ($shift_b,$shift_d) = $dir =~ /left/ ? ("#4","#12") : ("#12","#4"); +$code.=<<___; + add $a0.4s, $a0.4s, $b0.4s + add $a1.4s, $a1.4s, $b1.4s + add $a2.4s, $a2.4s, $b2.4s + add $a3.4s, $a3.4s, $b3.4s + add $A4.4s, $A4.4s, $B4.4s + + eor $d0.16b, $d0.16b, $a0.16b + eor $d1.16b, $d1.16b, $a1.16b + eor $d2.16b, $d2.16b, $a2.16b + eor $d3.16b, $d3.16b, $a3.16b + eor $D4.16b, $D4.16b, $A4.16b + + rev32 $d0.8h, $d0.8h + rev32 $d1.8h, $d1.8h + rev32 $d2.8h, $d2.8h + rev32 $d3.8h, $d3.8h + rev32 $D4.8h, $D4.8h + + add $c0.4s, $c0.4s, $d0.4s + add $c1.4s, $c1.4s, $d1.4s + add $c2.4s, $c2.4s, $d2.4s + add $c3.4s, $c3.4s, $d3.4s + add $C4.4s, $C4.4s, $D4.4s + + eor $b0.16b, $b0.16b, $c0.16b + eor $b1.16b, $b1.16b, $c1.16b + eor $b2.16b, $b2.16b, $c2.16b + eor $b3.16b, $b3.16b, $c3.16b + eor $B4.16b, $B4.16b, $C4.16b + + ushr $T0.4s, $b0.4s, #20 + sli $T0.4s, $b0.4s, #12 + ushr $b0.4s, $b1.4s, #20 + sli $b0.4s, $b1.4s, #12 + ushr $b1.4s, $b2.4s, #20 + sli $b1.4s, $b2.4s, #12 + ushr $b2.4s, $b3.4s, #20 + sli $b2.4s, $b3.4s, #12 + ushr $b3.4s, $B4.4s, #20 + sli $b3.4s, $B4.4s, #12 + + add $a0.4s, $a0.4s, $T0.4s + add $a1.4s, $a1.4s, $b0.4s + add $a2.4s, $a2.4s, $b1.4s + add $a3.4s, $a3.4s, $b2.4s + add $A4.4s, $A4.4s, $b3.4s + + eor $d0.16b, $d0.16b, $a0.16b + eor $d1.16b, $d1.16b, $a1.16b + eor $d2.16b, $d2.16b, $a2.16b + eor $d3.16b, $d3.16b, $a3.16b + eor $D4.16b, $D4.16b, $A4.16b + + tbl $d0.16b, {$d0.16b}, $ROL8.16b + tbl $d1.16b, {$d1.16b}, $ROL8.16b + tbl $d2.16b, {$d2.16b}, $ROL8.16b + tbl $d3.16b, {$d3.16b}, $ROL8.16b + tbl $D4.16b, {$D4.16b}, $ROL8.16b + + add $c0.4s, $c0.4s, $d0.4s + add $c1.4s, $c1.4s, $d1.4s + add $c2.4s, $c2.4s, $d2.4s + add $c3.4s, $c3.4s, $d3.4s + add $C4.4s, $C4.4s, $D4.4s + + eor $T0.16b, $T0.16b, $c0.16b + eor $b0.16b, $b0.16b, $c1.16b + eor $b1.16b, $b1.16b, $c2.16b + eor $b2.16b, $b2.16b, $c3.16b + eor $b3.16b, $b3.16b, $C4.16b + + ushr $B4.4s, $b3.4s, #25 + sli $B4.4s, $b3.4s, #7 + ushr $b3.4s, $b2.4s, #25 + sli $b3.4s, $b2.4s, #7 + ushr $b2.4s, $b1.4s, #25 + sli $b2.4s, $b1.4s, #7 + ushr $b1.4s, $b0.4s, #25 + sli $b1.4s, $b0.4s, #7 + ushr $b0.4s, $T0.4s, #25 + sli $b0.4s, $T0.4s, #7 + + ext $B4.16b, $B4.16b, $B4.16b, $shift_b + ext $C4.16b, $C4.16b, $C4.16b, #8 + ext $D4.16b, $D4.16b, $D4.16b, $shift_d +___ +} + +{ +$code.=<<___; +.section .rodata + +.align 7 +.Lchacha20_consts: +.byte 'e','x','p','a','n','d',' ','3','2','-','b','y','t','e',' ','k' +.Linc: +.long 1,2,3,4 +.Lrol8: +.byte 3,0,1,2, 7,4,5,6, 11,8,9,10, 15,12,13,14 +.Lclamp: +.quad 0x0FFFFFFC0FFFFFFF, 0x0FFFFFFC0FFFFFFC + +.text + +.type .Lpoly_hash_ad_internal,%function +.align 6 +.Lpoly_hash_ad_internal: + .cfi_startproc + cbnz $adl, .Lpoly_hash_intro + ret + +.Lpoly_hash_intro: + cmp $adl, #16 + b.lt .Lpoly_hash_ad_tail +___ + &poly_add($adp); + &poly_mul(); +$code.=<<___; + sub $adl, $adl, #16 + b .Lpoly_hash_ad_internal + +.Lpoly_hash_ad_tail: + cbz $adl, .Lpoly_hash_ad_ret + + eor $T0.16b, $T0.16b, $T0.16b // Use T0 to load the AAD + sub $adl, $adl, #1 + +.Lpoly_hash_tail_16_compose: + ext $T0.16b, $T0.16b, $T0.16b, #15 + ldrb $t0w, [$adp, $adl] + mov $T0.b[0], $t0w + subs $adl, $adl, #1 + b.ge .Lpoly_hash_tail_16_compose +___ + &poly_add_vec($T0); + &poly_mul(); +$code.=<<___; + +.Lpoly_hash_ad_ret: + ret + .cfi_endproc +.size .Lpoly_hash_ad_internal, .-.Lpoly_hash_ad_internal + +///////////////////////////////// +// +// void chacha20_poly1305_seal(uint8_t *pt, uint8_t *ct, size_t len_in, uint8_t *ad, size_t len_ad, union open_data *seal_data); +// +.globl chacha20_poly1305_seal +.type chacha20_poly1305_seal,%function +.align 6 +chacha20_poly1305_seal: + AARCH64_SIGN_LINK_REGISTER +.cfi_startproc + stp x29, x30, [sp, #-80]! +.cfi_def_cfa_offset 80 +.cfi_offset w30, -72 +.cfi_offset w29, -80 + mov x29, sp + // We probably could do .cfi_def_cfa w29, 80 at this point, but since + // we don't actually use the frame pointer like that, it's probably not + // worth bothering. + stp d8, d9, [sp, #16] + stp d10, d11, [sp, #32] + stp d12, d13, [sp, #48] + stp d14, d15, [sp, #64] +.cfi_offset b15, -8 +.cfi_offset b14, -16 +.cfi_offset b13, -24 +.cfi_offset b12, -32 +.cfi_offset b11, -40 +.cfi_offset b10, -48 +.cfi_offset b9, -56 +.cfi_offset b8, -64 + + adrp $t0, :pg_hi21:.Lchacha20_consts + add $t0, $t0, :lo12:.Lchacha20_consts + + ld1 {$CONSTS.16b - $CLAMP.16b}, [$t0] // Load the CONSTS, INC, ROL8 and CLAMP values + ld1 {$B_STORE.16b - $D_STORE.16b}, [$keyp] + + mov $one, #1 // Prepare the Poly1305 state + mov $acc0, #0 + mov $acc1, #0 + mov $acc2, #0 + + ldr $t1, [$keyp, #56] // The total cipher text length includes extra_in_len + add $t1, $t1, $inl + mov $LEN_STORE.d[0], $adl // Store the input and aad lengths + mov $LEN_STORE.d[1], $t1 + + cmp $inl, #128 + b.le .Lseal_128 // Optimization for smaller buffers + + // Initially we prepare 5 ChaCha20 blocks. Four to encrypt up to 4 blocks (256 bytes) of plaintext, + // and one for the Poly1305 R and S keys. The first four blocks (A0-A3..D0-D3) are computed vertically, + // the fifth block (A4-D4) horizontally. + ld4r {$A0.4s-$A3.4s}, [$t0] + mov $A4.16b, $CONSTS.16b + + ld4r {$B0.4s-$B3.4s}, [$keyp], #16 + mov $B4.16b, $B_STORE.16b + + ld4r {$C0.4s-$C3.4s}, [$keyp], #16 + mov $C4.16b, $C_STORE.16b + + ld4r {$D0.4s-$D3.4s}, [$keyp] + add $D0.4s, $D0.4s, $INC.4s + mov $D4.16b, $D_STORE.16b + + sub $keyp, $keyp, #32 + + mov $itr1, #10 + +.align 5 +.Lseal_init_rounds: +___ + &chacha_qr_x5("left"); + &chacha_qr_x5("right"); +$code.=<<___; + subs $itr1, $itr1, #1 + b.hi .Lseal_init_rounds + + add $D0.4s, $D0.4s, $INC.4s + mov $t0, #4 + dup $T0.4s, $t0w + add $INC.4s, $INC.4s, $T0.4s + + zip1 $T0.4s, $A0.4s, $A1.4s + zip2 $T1.4s, $A0.4s, $A1.4s + zip1 $T2.4s, $A2.4s, $A3.4s + zip2 $T3.4s, $A2.4s, $A3.4s + + zip1 $A0.2d, $T0.2d, $T2.2d + zip2 $A1.2d, $T0.2d, $T2.2d + zip1 $A2.2d, $T1.2d, $T3.2d + zip2 $A3.2d, $T1.2d, $T3.2d + + zip1 $T0.4s, $B0.4s, $B1.4s + zip2 $T1.4s, $B0.4s, $B1.4s + zip1 $T2.4s, $B2.4s, $B3.4s + zip2 $T3.4s, $B2.4s, $B3.4s + + zip1 $B0.2d, $T0.2d, $T2.2d + zip2 $B1.2d, $T0.2d, $T2.2d + zip1 $B2.2d, $T1.2d, $T3.2d + zip2 $B3.2d, $T1.2d, $T3.2d + + zip1 $T0.4s, $C0.4s, $C1.4s + zip2 $T1.4s, $C0.4s, $C1.4s + zip1 $T2.4s, $C2.4s, $C3.4s + zip2 $T3.4s, $C2.4s, $C3.4s + + zip1 $C0.2d, $T0.2d, $T2.2d + zip2 $C1.2d, $T0.2d, $T2.2d + zip1 $C2.2d, $T1.2d, $T3.2d + zip2 $C3.2d, $T1.2d, $T3.2d + + zip1 $T0.4s, $D0.4s, $D1.4s + zip2 $T1.4s, $D0.4s, $D1.4s + zip1 $T2.4s, $D2.4s, $D3.4s + zip2 $T3.4s, $D2.4s, $D3.4s + + zip1 $D0.2d, $T0.2d, $T2.2d + zip2 $D1.2d, $T0.2d, $T2.2d + zip1 $D2.2d, $T1.2d, $T3.2d + zip2 $D3.2d, $T1.2d, $T3.2d + + add $A4.4s, $A4.4s, $CONSTS.4s + add $B4.4s, $B4.4s, $B_STORE.4s + and $A4.16b, $A4.16b, $CLAMP.16b + + add $A0.4s, $A0.4s, $CONSTS.4s + add $B0.4s, $B0.4s, $B_STORE.4s + add $C0.4s, $C0.4s, $C_STORE.4s + add $D0.4s, $D0.4s, $D_STORE.4s + + add $A1.4s, $A1.4s, $CONSTS.4s + add $B1.4s, $B1.4s, $B_STORE.4s + add $C1.4s, $C1.4s, $C_STORE.4s + add $D1.4s, $D1.4s, $D_STORE.4s + + add $A2.4s, $A2.4s, $CONSTS.4s + add $B2.4s, $B2.4s, $B_STORE.4s + add $C2.4s, $C2.4s, $C_STORE.4s + add $D2.4s, $D2.4s, $D_STORE.4s + + add $A3.4s, $A3.4s, $CONSTS.4s + add $B3.4s, $B3.4s, $B_STORE.4s + add $C3.4s, $C3.4s, $C_STORE.4s + add $D3.4s, $D3.4s, $D_STORE.4s + + mov $r0, $A4.d[0] // Move the R key to GPRs + mov $r1, $A4.d[1] + mov $S_STORE.16b, $B4.16b // Store the S key + + bl .Lpoly_hash_ad_internal + + mov $adp, $oup + cmp $inl, #256 + b.le .Lseal_tail + + ld1 {$T0.16b - $T3.16b}, [$inp], #64 + eor $T0.16b, $T0.16b, $A0.16b + eor $T1.16b, $T1.16b, $B0.16b + eor $T2.16b, $T2.16b, $C0.16b + eor $T3.16b, $T3.16b, $D0.16b + st1 {$T0.16b - $T3.16b}, [$oup], #64 + + ld1 {$T0.16b - $T3.16b}, [$inp], #64 + eor $T0.16b, $T0.16b, $A1.16b + eor $T1.16b, $T1.16b, $B1.16b + eor $T2.16b, $T2.16b, $C1.16b + eor $T3.16b, $T3.16b, $D1.16b + st1 {$T0.16b - $T3.16b}, [$oup], #64 + + ld1 {$T0.16b - $T3.16b}, [$inp], #64 + eor $T0.16b, $T0.16b, $A2.16b + eor $T1.16b, $T1.16b, $B2.16b + eor $T2.16b, $T2.16b, $C2.16b + eor $T3.16b, $T3.16b, $D2.16b + st1 {$T0.16b - $T3.16b}, [$oup], #64 + + ld1 {$T0.16b - $T3.16b}, [$inp], #64 + eor $T0.16b, $T0.16b, $A3.16b + eor $T1.16b, $T1.16b, $B3.16b + eor $T2.16b, $T2.16b, $C3.16b + eor $T3.16b, $T3.16b, $D3.16b + st1 {$T0.16b - $T3.16b}, [$oup], #64 + + sub $inl, $inl, #256 + + mov $itr1, #4 // In the first run of the loop we need to hash 256 bytes, therefore we hash one block for the first 4 rounds + mov $itr2, #6 // and two blocks for the remaining 6, for a total of (1 * 4 + 2 * 6) * 16 = 256 + +.Lseal_main_loop: + adrp $t0, :pg_hi21:.Lchacha20_consts + add $t0, $t0, :lo12:.Lchacha20_consts + + ld4r {$A0.4s-$A3.4s}, [$t0] + mov $A4.16b, $CONSTS.16b + + ld4r {$B0.4s-$B3.4s}, [$keyp], #16 + mov $B4.16b, $B_STORE.16b + + ld4r {$C0.4s-$C3.4s}, [$keyp], #16 + mov $C4.16b, $C_STORE.16b + + ld4r {$D0.4s-$D3.4s}, [$keyp] + add $D0.4s, $D0.4s, $INC.4s + mov $D4.16b, $D_STORE.16b + + eor $T0.16b, $T0.16b, $T0.16b //zero + not $T1.16b, $T0.16b // -1 + sub $T1.4s, $INC.4s, $T1.4s // Add +1 + ext $T0.16b, $T1.16b, $T0.16b, #12 // Get the last element (counter) + add $D4.4s, $D4.4s, $T0.4s + + sub $keyp, $keyp, #32 +.align 5 +.Lseal_main_loop_rounds: +___ + &chacha_qr_x5("left"); + &poly_add($adp); + &poly_mul(); + &chacha_qr_x5("right"); +$code.=<<___; + subs $itr1, $itr1, #1 + b.ge .Lseal_main_loop_rounds +___ + &poly_add($adp); + &poly_mul(); +$code.=<<___; + subs $itr2, $itr2, #1 + b.gt .Lseal_main_loop_rounds + + eor $T0.16b, $T0.16b, $T0.16b //zero + not $T1.16b, $T0.16b // -1 + sub $T1.4s, $INC.4s, $T1.4s // Add +1 + ext $T0.16b, $T1.16b, $T0.16b, #12 // Get the last element (counter) + add $D4.4s, $D4.4s, $T0.4s + + add $D0.4s, $D0.4s, $INC.4s + mov $t0, #5 + dup $T0.4s, $t0w + add $INC.4s, $INC.4s, $T0.4s + + zip1 $T0.4s, $A0.4s, $A1.4s + zip2 $T1.4s, $A0.4s, $A1.4s + zip1 $T2.4s, $A2.4s, $A3.4s + zip2 $T3.4s, $A2.4s, $A3.4s + + zip1 $A0.2d, $T0.2d, $T2.2d + zip2 $A1.2d, $T0.2d, $T2.2d + zip1 $A2.2d, $T1.2d, $T3.2d + zip2 $A3.2d, $T1.2d, $T3.2d + + zip1 $T0.4s, $B0.4s, $B1.4s + zip2 $T1.4s, $B0.4s, $B1.4s + zip1 $T2.4s, $B2.4s, $B3.4s + zip2 $T3.4s, $B2.4s, $B3.4s + + zip1 $B0.2d, $T0.2d, $T2.2d + zip2 $B1.2d, $T0.2d, $T2.2d + zip1 $B2.2d, $T1.2d, $T3.2d + zip2 $B3.2d, $T1.2d, $T3.2d + + zip1 $T0.4s, $C0.4s, $C1.4s + zip2 $T1.4s, $C0.4s, $C1.4s + zip1 $T2.4s, $C2.4s, $C3.4s + zip2 $T3.4s, $C2.4s, $C3.4s + + zip1 $C0.2d, $T0.2d, $T2.2d + zip2 $C1.2d, $T0.2d, $T2.2d + zip1 $C2.2d, $T1.2d, $T3.2d + zip2 $C3.2d, $T1.2d, $T3.2d + + zip1 $T0.4s, $D0.4s, $D1.4s + zip2 $T1.4s, $D0.4s, $D1.4s + zip1 $T2.4s, $D2.4s, $D3.4s + zip2 $T3.4s, $D2.4s, $D3.4s + + zip1 $D0.2d, $T0.2d, $T2.2d + zip2 $D1.2d, $T0.2d, $T2.2d + zip1 $D2.2d, $T1.2d, $T3.2d + zip2 $D3.2d, $T1.2d, $T3.2d + + add $A0.4s, $A0.4s, $CONSTS.4s + add $B0.4s, $B0.4s, $B_STORE.4s + add $C0.4s, $C0.4s, $C_STORE.4s + add $D0.4s, $D0.4s, $D_STORE.4s + + add $A1.4s, $A1.4s, $CONSTS.4s + add $B1.4s, $B1.4s, $B_STORE.4s + add $C1.4s, $C1.4s, $C_STORE.4s + add $D1.4s, $D1.4s, $D_STORE.4s + + add $A2.4s, $A2.4s, $CONSTS.4s + add $B2.4s, $B2.4s, $B_STORE.4s + add $C2.4s, $C2.4s, $C_STORE.4s + add $D2.4s, $D2.4s, $D_STORE.4s + + add $A3.4s, $A3.4s, $CONSTS.4s + add $B3.4s, $B3.4s, $B_STORE.4s + add $C3.4s, $C3.4s, $C_STORE.4s + add $D3.4s, $D3.4s, $D_STORE.4s + + add $A4.4s, $A4.4s, $CONSTS.4s + add $B4.4s, $B4.4s, $B_STORE.4s + add $C4.4s, $C4.4s, $C_STORE.4s + add $D4.4s, $D4.4s, $D_STORE.4s + + cmp $inl, #320 + b.le .Lseal_tail + + ld1 {$T0.16b - $T3.16b}, [$inp], #64 + eor $T0.16b, $T0.16b, $A0.16b + eor $T1.16b, $T1.16b, $B0.16b + eor $T2.16b, $T2.16b, $C0.16b + eor $T3.16b, $T3.16b, $D0.16b + st1 {$T0.16b - $T3.16b}, [$oup], #64 + + ld1 {$T0.16b - $T3.16b}, [$inp], #64 + eor $T0.16b, $T0.16b, $A1.16b + eor $T1.16b, $T1.16b, $B1.16b + eor $T2.16b, $T2.16b, $C1.16b + eor $T3.16b, $T3.16b, $D1.16b + st1 {$T0.16b - $T3.16b}, [$oup], #64 + + ld1 {$T0.16b - $T3.16b}, [$inp], #64 + eor $T0.16b, $T0.16b, $A2.16b + eor $T1.16b, $T1.16b, $B2.16b + eor $T2.16b, $T2.16b, $C2.16b + eor $T3.16b, $T3.16b, $D2.16b + st1 {$T0.16b - $T3.16b}, [$oup], #64 + + ld1 {$T0.16b - $T3.16b}, [$inp], #64 + eor $T0.16b, $T0.16b, $A3.16b + eor $T1.16b, $T1.16b, $B3.16b + eor $T2.16b, $T2.16b, $C3.16b + eor $T3.16b, $T3.16b, $D3.16b + st1 {$T0.16b - $T3.16b}, [$oup], #64 + + ld1 {$T0.16b - $T3.16b}, [$inp], #64 + eor $T0.16b, $T0.16b, $A4.16b + eor $T1.16b, $T1.16b, $B4.16b + eor $T2.16b, $T2.16b, $C4.16b + eor $T3.16b, $T3.16b, $D4.16b + st1 {$T0.16b - $T3.16b}, [$oup], #64 + + sub $inl, $inl, #320 + + mov $itr1, #0 + mov $itr2, #10 // For the remainder of the loop we always hash and encrypt 320 bytes per iteration + + b .Lseal_main_loop + +.Lseal_tail: + // This part of the function handles the storage and authentication of the last [0,320) bytes + // We assume A0-A4 ... D0-D4 hold at least inl (320 max) bytes of the stream data. + cmp $inl, #64 + b.lt .Lseal_tail_64 + + // Store and authenticate 64B blocks per iteration + ld1 {$T0.16b - $T3.16b}, [$inp], #64 + + eor $T0.16b, $T0.16b, $A0.16b + eor $T1.16b, $T1.16b, $B0.16b + eor $T2.16b, $T2.16b, $C0.16b + eor $T3.16b, $T3.16b, $D0.16b +___ + &poly_add_vec($T0); + &poly_mul(); + &poly_add_vec($T1); + &poly_mul(); + &poly_add_vec($T2); + &poly_mul(); + &poly_add_vec($T3); + &poly_mul(); +$code.=<<___; + st1 {$T0.16b - $T3.16b}, [$oup], #64 + sub $inl, $inl, #64 + + // Shift the state left by 64 bytes for the next iteration of the loop + mov $A0.16b, $A1.16b + mov $B0.16b, $B1.16b + mov $C0.16b, $C1.16b + mov $D0.16b, $D1.16b + + mov $A1.16b, $A2.16b + mov $B1.16b, $B2.16b + mov $C1.16b, $C2.16b + mov $D1.16b, $D2.16b + + mov $A2.16b, $A3.16b + mov $B2.16b, $B3.16b + mov $C2.16b, $C3.16b + mov $D2.16b, $D3.16b + + mov $A3.16b, $A4.16b + mov $B3.16b, $B4.16b + mov $C3.16b, $C4.16b + mov $D3.16b, $D4.16b + + b .Lseal_tail + +.Lseal_tail_64: + ldp $adp, $adl, [$keyp, #48] // extra_in_len and extra_in_ptr + + // Here we handle the last [0,64) bytes of plaintext + cmp $inl, #16 + b.lt .Lseal_tail_16 + // Each iteration encrypt and authenticate a 16B block + ld1 {$T0.16b}, [$inp], #16 + eor $T0.16b, $T0.16b, $A0.16b +___ + &poly_add_vec($T0); + &poly_mul(); +$code.=<<___; + st1 {$T0.16b}, [$oup], #16 + + sub $inl, $inl, #16 + + // Shift the state left by 16 bytes for the next iteration of the loop + mov $A0.16b, $B0.16b + mov $B0.16b, $C0.16b + mov $C0.16b, $D0.16b + + b .Lseal_tail_64 + +.Lseal_tail_16: + // Here we handle the last [0,16) bytes of ciphertext that require a padded block + cbz $inl, .Lseal_hash_extra + + eor $T0.16b, $T0.16b, $T0.16b // Use T0 to load the plaintext/extra in + eor $T1.16b, $T1.16b, $T1.16b // Use T1 to generate an AND mask that will only mask the ciphertext bytes + not $T2.16b, $T0.16b + + mov $itr1, $inl + add $inp, $inp, $inl + + cbz $adl, .Lseal_tail_16_compose // No extra data to pad with, zero padding + + mov $itr2, #16 // We need to load some extra_in first for padding + sub $itr2, $itr2, $inl + cmp $adl, $itr2 + csel $itr2, $adl, $itr2, lt // Load the minimum of extra_in_len and the amount needed to fill the register + mov $t1, $itr2 + add $adp, $adp, $itr2 + sub $adl, $adl, $itr2 + +.Lseal_tail16_compose_extra_in: + ext $T0.16b, $T0.16b, $T0.16b, #15 + ldrb $t0w, [$adp, #-1]! + mov $T0.b[0], $t0w + subs $itr2, $itr2, #1 + b.gt .Lseal_tail16_compose_extra_in + + add $adp, $adp, $t1 + +.Lseal_tail_16_compose: + ext $T0.16b, $T0.16b, $T0.16b, #15 + ldrb $t0w, [$inp, #-1]! + mov $T0.b[0], $t0w + ext $T1.16b, $T2.16b, $T1.16b, #15 + subs $inl, $inl, #1 + b.gt .Lseal_tail_16_compose + + and $A0.16b, $A0.16b, $T1.16b + eor $T0.16b, $T0.16b, $A0.16b + mov $T1.16b, $T0.16b + +.Lseal_tail_16_store: + umov $t0w, $T0.b[0] + strb $t0w, [$oup], #1 + ext $T0.16b, $T0.16b, $T0.16b, #1 + subs $itr1, $itr1, #1 + b.gt .Lseal_tail_16_store + + // Hash in the final ct block concatenated with extra_in +___ + &poly_add_vec($T1); + &poly_mul(); +$code.=<<___; + +.Lseal_hash_extra: + cbz $adl, .Lseal_finalize + +.Lseal_hash_extra_loop: + cmp $adl, #16 + b.lt .Lseal_hash_extra_tail + ld1 {$T0.16b}, [$adp], #16 +___ + &poly_add_vec($T0); + &poly_mul(); +$code.=<<___; + sub $adl, $adl, #16 + b .Lseal_hash_extra_loop + +.Lseal_hash_extra_tail: + cbz $adl, .Lseal_finalize + eor $T0.16b, $T0.16b, $T0.16b // Use T0 to load the remaining extra ciphertext + add $adp, $adp, $adl + +.Lseal_hash_extra_load: + ext $T0.16b, $T0.16b, $T0.16b, #15 + ldrb $t0w, [$adp, #-1]! + mov $T0.b[0], $t0w + subs $adl, $adl, #1 + b.gt .Lseal_hash_extra_load + + // Hash in the final padded extra_in blcok +___ + &poly_add_vec($T0); + &poly_mul(); +$code.=<<___; + +.Lseal_finalize: +___ + &poly_add_vec($LEN_STORE); + &poly_mul(); +$code.=<<___; + // Final reduction step + sub $t1, xzr, $one + orr $t2, xzr, #3 + subs $t0, $acc0, #-5 + sbcs $t1, $acc1, $t1 + sbcs $t2, $acc2, $t2 + csel $acc0, $t0, $acc0, cs + csel $acc1, $t1, $acc1, cs + csel $acc2, $t2, $acc2, cs +___ + &poly_add_vec($S_STORE); +$code.=<<___; + + stp $acc0, $acc1, [$keyp] + + ldp d8, d9, [sp, #16] + ldp d10, d11, [sp, #32] + ldp d12, d13, [sp, #48] + ldp d14, d15, [sp, #64] +.cfi_restore b15 +.cfi_restore b14 +.cfi_restore b13 +.cfi_restore b12 +.cfi_restore b11 +.cfi_restore b10 +.cfi_restore b9 +.cfi_restore b8 + ldp x29, x30, [sp], 80 +.cfi_restore w29 +.cfi_restore w30 +.cfi_def_cfa_offset 0 + AARCH64_VALIDATE_LINK_REGISTER + ret + +.Lseal_128: + // On some architectures preparing 5 blocks for small buffers is wasteful + eor $INC.16b, $INC.16b, $INC.16b + mov $t0, #1 + mov $INC.s[0], $t0w + mov $A0.16b, $CONSTS.16b + mov $A1.16b, $CONSTS.16b + mov $A2.16b, $CONSTS.16b + mov $B0.16b, $B_STORE.16b + mov $B1.16b, $B_STORE.16b + mov $B2.16b, $B_STORE.16b + mov $C0.16b, $C_STORE.16b + mov $C1.16b, $C_STORE.16b + mov $C2.16b, $C_STORE.16b + mov $D2.16b, $D_STORE.16b + add $D0.4s, $D2.4s, $INC.4s + add $D1.4s, $D0.4s, $INC.4s + + mov $itr1, #10 + +.Lseal_128_rounds: +___ + &chacha_qr_x3("left"); + &chacha_qr_x3("right"); +$code.=<<___; + subs $itr1, $itr1, #1 + b.hi .Lseal_128_rounds + + add $A0.4s, $A0.4s, $CONSTS.4s + add $A1.4s, $A1.4s, $CONSTS.4s + add $A2.4s, $A2.4s, $CONSTS.4s + + add $B0.4s, $B0.4s, $B_STORE.4s + add $B1.4s, $B1.4s, $B_STORE.4s + add $B2.4s, $B2.4s, $B_STORE.4s + + // Only the first 32 bytes of the third block (counter = 0) are needed, + // so skip updating $C2 and $D2. + add $C0.4s, $C0.4s, $C_STORE.4s + add $C1.4s, $C1.4s, $C_STORE.4s + + add $D_STORE.4s, $D_STORE.4s, $INC.4s + add $D0.4s, $D0.4s, $D_STORE.4s + add $D_STORE.4s, $D_STORE.4s, $INC.4s + add $D1.4s, $D1.4s, $D_STORE.4s + + and $A2.16b, $A2.16b, $CLAMP.16b + mov $r0, $A2.d[0] // Move the R key to GPRs + mov $r1, $A2.d[1] + mov $S_STORE.16b, $B2.16b // Store the S key + + bl .Lpoly_hash_ad_internal + b .Lseal_tail +.cfi_endproc +.size chacha20_poly1305_seal,.-chacha20_poly1305_seal + +///////////////////////////////// +// +// void chacha20_poly1305_open(uint8_t *pt, uint8_t *ct, size_t len_in, uint8_t *ad, size_t len_ad, union open_data *aead_data); +// +.globl chacha20_poly1305_open +.type chacha20_poly1305_open,%function +.align 6 +chacha20_poly1305_open: + AARCH64_SIGN_LINK_REGISTER +.cfi_startproc + stp x29, x30, [sp, #-80]! +.cfi_def_cfa_offset 80 +.cfi_offset w30, -72 +.cfi_offset w29, -80 + mov x29, sp + // We probably could do .cfi_def_cfa w29, 80 at this point, but since + // we don't actually use the frame pointer like that, it's probably not + // worth bothering. + stp d8, d9, [sp, #16] + stp d10, d11, [sp, #32] + stp d12, d13, [sp, #48] + stp d14, d15, [sp, #64] +.cfi_offset b15, -8 +.cfi_offset b14, -16 +.cfi_offset b13, -24 +.cfi_offset b12, -32 +.cfi_offset b11, -40 +.cfi_offset b10, -48 +.cfi_offset b9, -56 +.cfi_offset b8, -64 + + adrp $t0, :pg_hi21:.Lchacha20_consts + add $t0, $t0, :lo12:.Lchacha20_consts + + ld1 {$CONSTS.16b - $CLAMP.16b}, [$t0] // Load the CONSTS, INC, ROL8 and CLAMP values + ld1 {$B_STORE.16b - $D_STORE.16b}, [$keyp] + + mov $one, #1 // Prepare the Poly1305 state + mov $acc0, #0 + mov $acc1, #0 + mov $acc2, #0 + + mov $LEN_STORE.d[0], $adl // Store the input and aad lengths + mov $LEN_STORE.d[1], $inl + + cmp $inl, #128 + b.le .Lopen_128 // Optimization for smaller buffers + + // Initially we prepare a single ChaCha20 block for the Poly1305 R and S keys + mov $A0.16b, $CONSTS.16b + mov $B0.16b, $B_STORE.16b + mov $C0.16b, $C_STORE.16b + mov $D0.16b, $D_STORE.16b + + mov $itr1, #10 + +.align 5 +.Lopen_init_rounds: +___ + &chacha_qr($A0, $B0, $C0, $D0, $T0, "left"); + &chacha_qr($A0, $B0, $C0, $D0, $T0, "right"); +$code.=<<___; + subs $itr1, $itr1, #1 + b.hi .Lopen_init_rounds + + add $A0.4s, $A0.4s, $CONSTS.4s + add $B0.4s, $B0.4s, $B_STORE.4s + + and $A0.16b, $A0.16b, $CLAMP.16b + mov $r0, $A0.d[0] // Move the R key to GPRs + mov $r1, $A0.d[1] + mov $S_STORE.16b, $B0.16b // Store the S key + + bl .Lpoly_hash_ad_internal + +.Lopen_ad_done: + mov $adp, $inp + +// Each iteration of the loop hash 320 bytes, and prepare stream for 320 bytes +.Lopen_main_loop: + + cmp $inl, #192 + b.lt .Lopen_tail + + adrp $t0, :pg_hi21:.Lchacha20_consts + add $t0, $t0, :lo12:.Lchacha20_consts + + ld4r {$A0.4s-$A3.4s}, [$t0] + mov $A4.16b, $CONSTS.16b + + ld4r {$B0.4s-$B3.4s}, [$keyp], #16 + mov $B4.16b, $B_STORE.16b + + ld4r {$C0.4s-$C3.4s}, [$keyp], #16 + mov $C4.16b, $C_STORE.16b + + ld4r {$D0.4s-$D3.4s}, [$keyp] + sub $keyp, $keyp, #32 + add $D0.4s, $D0.4s, $INC.4s + mov $D4.16b, $D_STORE.16b + + eor $T0.16b, $T0.16b, $T0.16b //zero + not $T1.16b, $T0.16b // -1 + sub $T1.4s, $INC.4s, $T1.4s // Add +1 + ext $T0.16b, $T1.16b, $T0.16b, #12 // Get the last element (counter) + add $D4.4s, $D4.4s, $T0.4s + + lsr $adl, $inl, #4 // How many whole blocks we have to hash, will always be at least 12 + sub $adl, $adl, #10 + + mov $itr2, #10 + subs $itr1, $itr2, $adl + subs $itr1, $itr2, $adl // itr1 can be negative if we have more than 320 bytes to hash + csel $itr2, $itr2, $adl, le // if itr1 is zero or less, itr2 should be 10 to indicate all 10 rounds are full + + cbz $itr2, .Lopen_main_loop_rounds_short + +.align 5 +.Lopen_main_loop_rounds: +___ + &poly_add($adp); + &poly_mul(); +$code.=<<___; +.Lopen_main_loop_rounds_short: +___ + &chacha_qr_x5("left"); + &poly_add($adp); + &poly_mul(); + &chacha_qr_x5("right"); +$code.=<<___; + subs $itr2, $itr2, #1 + b.gt .Lopen_main_loop_rounds + subs $itr1, $itr1, #1 + b.ge .Lopen_main_loop_rounds_short +___ +$code.=<<___; + + eor $T0.16b, $T0.16b, $T0.16b //zero + not $T1.16b, $T0.16b // -1 + sub $T1.4s, $INC.4s, $T1.4s // Add +1 + ext $T0.16b, $T1.16b, $T0.16b, #12 // Get the last element (counter) + add $D4.4s, $D4.4s, $T0.4s + + add $D0.4s, $D0.4s, $INC.4s + mov $t0, #5 + dup $T0.4s, $t0w + add $INC.4s, $INC.4s, $T0.4s + + zip1 $T0.4s, $A0.4s, $A1.4s + zip2 $T1.4s, $A0.4s, $A1.4s + zip1 $T2.4s, $A2.4s, $A3.4s + zip2 $T3.4s, $A2.4s, $A3.4s + + zip1 $A0.2d, $T0.2d, $T2.2d + zip2 $A1.2d, $T0.2d, $T2.2d + zip1 $A2.2d, $T1.2d, $T3.2d + zip2 $A3.2d, $T1.2d, $T3.2d + + zip1 $T0.4s, $B0.4s, $B1.4s + zip2 $T1.4s, $B0.4s, $B1.4s + zip1 $T2.4s, $B2.4s, $B3.4s + zip2 $T3.4s, $B2.4s, $B3.4s + + zip1 $B0.2d, $T0.2d, $T2.2d + zip2 $B1.2d, $T0.2d, $T2.2d + zip1 $B2.2d, $T1.2d, $T3.2d + zip2 $B3.2d, $T1.2d, $T3.2d + + zip1 $T0.4s, $C0.4s, $C1.4s + zip2 $T1.4s, $C0.4s, $C1.4s + zip1 $T2.4s, $C2.4s, $C3.4s + zip2 $T3.4s, $C2.4s, $C3.4s + + zip1 $C0.2d, $T0.2d, $T2.2d + zip2 $C1.2d, $T0.2d, $T2.2d + zip1 $C2.2d, $T1.2d, $T3.2d + zip2 $C3.2d, $T1.2d, $T3.2d + + zip1 $T0.4s, $D0.4s, $D1.4s + zip2 $T1.4s, $D0.4s, $D1.4s + zip1 $T2.4s, $D2.4s, $D3.4s + zip2 $T3.4s, $D2.4s, $D3.4s + + zip1 $D0.2d, $T0.2d, $T2.2d + zip2 $D1.2d, $T0.2d, $T2.2d + zip1 $D2.2d, $T1.2d, $T3.2d + zip2 $D3.2d, $T1.2d, $T3.2d + + add $A0.4s, $A0.4s, $CONSTS.4s + add $B0.4s, $B0.4s, $B_STORE.4s + add $C0.4s, $C0.4s, $C_STORE.4s + add $D0.4s, $D0.4s, $D_STORE.4s + + add $A1.4s, $A1.4s, $CONSTS.4s + add $B1.4s, $B1.4s, $B_STORE.4s + add $C1.4s, $C1.4s, $C_STORE.4s + add $D1.4s, $D1.4s, $D_STORE.4s + + add $A2.4s, $A2.4s, $CONSTS.4s + add $B2.4s, $B2.4s, $B_STORE.4s + add $C2.4s, $C2.4s, $C_STORE.4s + add $D2.4s, $D2.4s, $D_STORE.4s + + add $A3.4s, $A3.4s, $CONSTS.4s + add $B3.4s, $B3.4s, $B_STORE.4s + add $C3.4s, $C3.4s, $C_STORE.4s + add $D3.4s, $D3.4s, $D_STORE.4s + + add $A4.4s, $A4.4s, $CONSTS.4s + add $B4.4s, $B4.4s, $B_STORE.4s + add $C4.4s, $C4.4s, $C_STORE.4s + add $D4.4s, $D4.4s, $D_STORE.4s + + // We can always safely store 192 bytes + ld1 {$T0.16b - $T3.16b}, [$inp], #64 + eor $T0.16b, $T0.16b, $A0.16b + eor $T1.16b, $T1.16b, $B0.16b + eor $T2.16b, $T2.16b, $C0.16b + eor $T3.16b, $T3.16b, $D0.16b + st1 {$T0.16b - $T3.16b}, [$oup], #64 + + ld1 {$T0.16b - $T3.16b}, [$inp], #64 + eor $T0.16b, $T0.16b, $A1.16b + eor $T1.16b, $T1.16b, $B1.16b + eor $T2.16b, $T2.16b, $C1.16b + eor $T3.16b, $T3.16b, $D1.16b + st1 {$T0.16b - $T3.16b}, [$oup], #64 + + ld1 {$T0.16b - $T3.16b}, [$inp], #64 + eor $T0.16b, $T0.16b, $A2.16b + eor $T1.16b, $T1.16b, $B2.16b + eor $T2.16b, $T2.16b, $C2.16b + eor $T3.16b, $T3.16b, $D2.16b + st1 {$T0.16b - $T3.16b}, [$oup], #64 + + sub $inl, $inl, #192 + + mov $A0.16b, $A3.16b + mov $B0.16b, $B3.16b + mov $C0.16b, $C3.16b + mov $D0.16b, $D3.16b + + cmp $inl, #64 + b.lt .Lopen_tail_64_store + + ld1 {$T0.16b - $T3.16b}, [$inp], #64 + eor $T0.16b, $T0.16b, $A3.16b + eor $T1.16b, $T1.16b, $B3.16b + eor $T2.16b, $T2.16b, $C3.16b + eor $T3.16b, $T3.16b, $D3.16b + st1 {$T0.16b - $T3.16b}, [$oup], #64 + + sub $inl, $inl, #64 + + mov $A0.16b, $A4.16b + mov $B0.16b, $B4.16b + mov $C0.16b, $C4.16b + mov $D0.16b, $D4.16b + + cmp $inl, #64 + b.lt .Lopen_tail_64_store + + ld1 {$T0.16b - $T3.16b}, [$inp], #64 + eor $T0.16b, $T0.16b, $A4.16b + eor $T1.16b, $T1.16b, $B4.16b + eor $T2.16b, $T2.16b, $C4.16b + eor $T3.16b, $T3.16b, $D4.16b + st1 {$T0.16b - $T3.16b}, [$oup], #64 + + sub $inl, $inl, #64 + b .Lopen_main_loop + +.Lopen_tail: + + cbz $inl, .Lopen_finalize + + lsr $adl, $inl, #4 // How many whole blocks we have to hash + + cmp $inl, #64 + b.le .Lopen_tail_64 + cmp $inl, #128 + b.le .Lopen_tail_128 + +.Lopen_tail_192: + // We need three more blocks + mov $A0.16b, $CONSTS.16b + mov $A1.16b, $CONSTS.16b + mov $A2.16b, $CONSTS.16b + mov $B0.16b, $B_STORE.16b + mov $B1.16b, $B_STORE.16b + mov $B2.16b, $B_STORE.16b + mov $C0.16b, $C_STORE.16b + mov $C1.16b, $C_STORE.16b + mov $C2.16b, $C_STORE.16b + mov $D0.16b, $D_STORE.16b + mov $D1.16b, $D_STORE.16b + mov $D2.16b, $D_STORE.16b + eor $T3.16b, $T3.16b, $T3.16b + eor $T1.16b, $T1.16b, $T1.16b + ins $T3.s[0], $INC.s[0] + ins $T1.d[0], $one + + add $T2.4s, $T3.4s, $T1.4s + add $T1.4s, $T2.4s, $T1.4s + + add $D0.4s, $D0.4s, $T1.4s + add $D1.4s, $D1.4s, $T3.4s + add $D2.4s, $D2.4s, $T2.4s + + mov $itr2, #10 + subs $itr1, $itr2, $adl // itr1 can be negative if we have more than 160 bytes to hash + csel $itr2, $itr2, $adl, le // if itr1 is zero or less, itr2 should be 10 to indicate all 10 rounds are hashing + sub $adl, $adl, $itr2 + + cbz $itr2, .Lopen_tail_192_rounds_no_hash + +.Lopen_tail_192_rounds: +___ + &poly_add($adp); + &poly_mul(); +$code.=<<___; +.Lopen_tail_192_rounds_no_hash: +___ + &chacha_qr_x3("left"); + &chacha_qr_x3("right"); +$code.=<<___; + subs $itr2, $itr2, #1 + b.gt .Lopen_tail_192_rounds + subs $itr1, $itr1, #1 + b.ge .Lopen_tail_192_rounds_no_hash + + // We hashed 160 bytes at most, may still have 32 bytes left +.Lopen_tail_192_hash: + cbz $adl, .Lopen_tail_192_hash_done +___ + &poly_add($adp); + &poly_mul(); +$code.=<<___; + sub $adl, $adl, #1 + b .Lopen_tail_192_hash + +.Lopen_tail_192_hash_done: + + add $A0.4s, $A0.4s, $CONSTS.4s + add $A1.4s, $A1.4s, $CONSTS.4s + add $A2.4s, $A2.4s, $CONSTS.4s + add $B0.4s, $B0.4s, $B_STORE.4s + add $B1.4s, $B1.4s, $B_STORE.4s + add $B2.4s, $B2.4s, $B_STORE.4s + add $C0.4s, $C0.4s, $C_STORE.4s + add $C1.4s, $C1.4s, $C_STORE.4s + add $C2.4s, $C2.4s, $C_STORE.4s + add $D0.4s, $D0.4s, $D_STORE.4s + add $D1.4s, $D1.4s, $D_STORE.4s + add $D2.4s, $D2.4s, $D_STORE.4s + + add $D0.4s, $D0.4s, $T1.4s + add $D1.4s, $D1.4s, $T3.4s + add $D2.4s, $D2.4s, $T2.4s + + ld1 {$T0.16b - $T3.16b}, [$inp], #64 + + eor $T0.16b, $T0.16b, $A1.16b + eor $T1.16b, $T1.16b, $B1.16b + eor $T2.16b, $T2.16b, $C1.16b + eor $T3.16b, $T3.16b, $D1.16b + + st1 {$T0.16b - $T3.16b}, [$oup], #64 + + ld1 {$T0.16b - $T3.16b}, [$inp], #64 + + eor $T0.16b, $T0.16b, $A2.16b + eor $T1.16b, $T1.16b, $B2.16b + eor $T2.16b, $T2.16b, $C2.16b + eor $T3.16b, $T3.16b, $D2.16b + + st1 {$T0.16b - $T3.16b}, [$oup], #64 + + sub $inl, $inl, #128 + b .Lopen_tail_64_store + +.Lopen_tail_128: + // We need two more blocks + mov $A0.16b, $CONSTS.16b + mov $A1.16b, $CONSTS.16b + mov $B0.16b, $B_STORE.16b + mov $B1.16b, $B_STORE.16b + mov $C0.16b, $C_STORE.16b + mov $C1.16b, $C_STORE.16b + mov $D0.16b, $D_STORE.16b + mov $D1.16b, $D_STORE.16b + eor $T3.16b, $T3.16b, $T3.16b + eor $T2.16b, $T2.16b, $T2.16b + ins $T3.s[0], $INC.s[0] + ins $T2.d[0], $one + add $T2.4s, $T2.4s, $T3.4s + + add $D0.4s, $D0.4s, $T2.4s + add $D1.4s, $D1.4s, $T3.4s + + mov $itr1, #10 + sub $itr1, $itr1, $adl + +.Lopen_tail_128_rounds: +___ + &chacha_qr($A0, $B0, $C0, $D0, $T0, "left"); + &chacha_qr($A1, $B1, $C1, $D1, $T0, "left"); + &chacha_qr($A0, $B0, $C0, $D0, $T0, "right"); + &chacha_qr($A1, $B1, $C1, $D1, $T0, "right"); +$code.=<<___; + subs $itr1, $itr1, #1 + b.gt .Lopen_tail_128_rounds + cbz $adl, .Lopen_tail_128_rounds_done + subs $adl, $adl, #1 +___ + &poly_add($adp); + &poly_mul(); +$code.=<<___; + b .Lopen_tail_128_rounds + +.Lopen_tail_128_rounds_done: + add $A0.4s, $A0.4s, $CONSTS.4s + add $A1.4s, $A1.4s, $CONSTS.4s + add $B0.4s, $B0.4s, $B_STORE.4s + add $B1.4s, $B1.4s, $B_STORE.4s + add $C0.4s, $C0.4s, $C_STORE.4s + add $C1.4s, $C1.4s, $C_STORE.4s + add $D0.4s, $D0.4s, $D_STORE.4s + add $D1.4s, $D1.4s, $D_STORE.4s + add $D0.4s, $D0.4s, $T2.4s + add $D1.4s, $D1.4s, $T3.4s + + ld1 {$T0.16b - $T3.16b}, [$inp], #64 + + eor $T0.16b, $T0.16b, $A1.16b + eor $T1.16b, $T1.16b, $B1.16b + eor $T2.16b, $T2.16b, $C1.16b + eor $T3.16b, $T3.16b, $D1.16b + + st1 {$T0.16b - $T3.16b}, [$oup], #64 + sub $inl, $inl, #64 + + b .Lopen_tail_64_store + +.Lopen_tail_64: + // We just need a single block + mov $A0.16b, $CONSTS.16b + mov $B0.16b, $B_STORE.16b + mov $C0.16b, $C_STORE.16b + mov $D0.16b, $D_STORE.16b + eor $T3.16b, $T3.16b, $T3.16b + ins $T3.s[0], $INC.s[0] + add $D0.4s, $D0.4s, $T3.4s + + mov $itr1, #10 + sub $itr1, $itr1, $adl + +.Lopen_tail_64_rounds: +___ + &chacha_qr($A0, $B0, $C0, $D0, $T0, "left"); + &chacha_qr($A0, $B0, $C0, $D0, $T0, "right"); +$code.=<<___; + subs $itr1, $itr1, #1 + b.gt .Lopen_tail_64_rounds + cbz $adl, .Lopen_tail_64_rounds_done + subs $adl, $adl, #1 +___ + &poly_add($adp); + &poly_mul(); +$code.=<<___; + b .Lopen_tail_64_rounds + +.Lopen_tail_64_rounds_done: + add $A0.4s, $A0.4s, $CONSTS.4s + add $B0.4s, $B0.4s, $B_STORE.4s + add $C0.4s, $C0.4s, $C_STORE.4s + add $D0.4s, $D0.4s, $D_STORE.4s + add $D0.4s, $D0.4s, $T3.4s + +.Lopen_tail_64_store: + cmp $inl, #16 + b.lt .Lopen_tail_16 + + ld1 {$T0.16b}, [$inp], #16 + eor $T0.16b, $T0.16b, $A0.16b + st1 {$T0.16b}, [$oup], #16 + mov $A0.16b, $B0.16b + mov $B0.16b, $C0.16b + mov $C0.16b, $D0.16b + sub $inl, $inl, #16 + b .Lopen_tail_64_store + +.Lopen_tail_16: + // Here we handle the last [0,16) bytes that require a padded block + cbz $inl, .Lopen_finalize + + eor $T0.16b, $T0.16b, $T0.16b // Use T0 to load the ciphertext + eor $T1.16b, $T1.16b, $T1.16b // Use T1 to generate an AND mask + not $T2.16b, $T0.16b + + add $itr2, $inp, $inl + mov $itr1, $inl + +.Lopen_tail_16_compose: + ext $T0.16b, $T0.16b, $T0.16b, #15 + ldrb $t0w, [$itr2, #-1]! + mov $T0.b[0], $t0w + ext $T1.16b, $T2.16b, $T1.16b, #15 + subs $inl, $inl, #1 + b.gt .Lopen_tail_16_compose + + and $T0.16b, $T0.16b, $T1.16b + // Hash in the final padded block +___ + &poly_add_vec($T0); + &poly_mul(); +$code.=<<___; + eor $T0.16b, $T0.16b, $A0.16b + +.Lopen_tail_16_store: + umov $t0w, $T0.b[0] + strb $t0w, [$oup], #1 + ext $T0.16b, $T0.16b, $T0.16b, #1 + subs $itr1, $itr1, #1 + b.gt .Lopen_tail_16_store + +.Lopen_finalize: +___ + &poly_add_vec($LEN_STORE); + &poly_mul(); +$code.=<<___; + // Final reduction step + sub $t1, xzr, $one + orr $t2, xzr, #3 + subs $t0, $acc0, #-5 + sbcs $t1, $acc1, $t1 + sbcs $t2, $acc2, $t2 + csel $acc0, $t0, $acc0, cs + csel $acc1, $t1, $acc1, cs + csel $acc2, $t2, $acc2, cs +___ + &poly_add_vec($S_STORE); +$code.=<<___; + + stp $acc0, $acc1, [$keyp] + + ldp d8, d9, [sp, #16] + ldp d10, d11, [sp, #32] + ldp d12, d13, [sp, #48] + ldp d14, d15, [sp, #64] +.cfi_restore b15 +.cfi_restore b14 +.cfi_restore b13 +.cfi_restore b12 +.cfi_restore b11 +.cfi_restore b10 +.cfi_restore b9 +.cfi_restore b8 + ldp x29, x30, [sp], 80 +.cfi_restore w29 +.cfi_restore w30 +.cfi_def_cfa_offset 0 + AARCH64_VALIDATE_LINK_REGISTER + ret + +.Lopen_128: + // On some architectures preparing 5 blocks for small buffers is wasteful + eor $INC.16b, $INC.16b, $INC.16b + mov $t0, #1 + mov $INC.s[0], $t0w + mov $A0.16b, $CONSTS.16b + mov $A1.16b, $CONSTS.16b + mov $A2.16b, $CONSTS.16b + mov $B0.16b, $B_STORE.16b + mov $B1.16b, $B_STORE.16b + mov $B2.16b, $B_STORE.16b + mov $C0.16b, $C_STORE.16b + mov $C1.16b, $C_STORE.16b + mov $C2.16b, $C_STORE.16b + mov $D2.16b, $D_STORE.16b + add $D0.4s, $D2.4s, $INC.4s + add $D1.4s, $D0.4s, $INC.4s + + mov $itr1, #10 + +.Lopen_128_rounds: +___ + &chacha_qr_x3("left"); + &chacha_qr_x3("right"); +$code.=<<___; + subs $itr1, $itr1, #1 + b.hi .Lopen_128_rounds + + add $A0.4s, $A0.4s, $CONSTS.4s + add $A1.4s, $A1.4s, $CONSTS.4s + add $A2.4s, $A2.4s, $CONSTS.4s + + add $B0.4s, $B0.4s, $B_STORE.4s + add $B1.4s, $B1.4s, $B_STORE.4s + add $B2.4s, $B2.4s, $B_STORE.4s + + add $C0.4s, $C0.4s, $C_STORE.4s + add $C1.4s, $C1.4s, $C_STORE.4s + + add $D_STORE.4s, $D_STORE.4s, $INC.4s + add $D0.4s, $D0.4s, $D_STORE.4s + add $D_STORE.4s, $D_STORE.4s, $INC.4s + add $D1.4s, $D1.4s, $D_STORE.4s + + and $A2.16b, $A2.16b, $CLAMP.16b + mov $r0, $A2.d[0] // Move the R key to GPRs + mov $r1, $A2.d[1] + mov $S_STORE.16b, $B2.16b // Store the S key + + bl .Lpoly_hash_ad_internal + +.Lopen_128_store: + cmp $inl, #64 + b.lt .Lopen_128_store_64 + + ld1 {$T0.16b - $T3.16b}, [$inp], #64 + +___ + &poly_add_vec($T0); + &poly_mul(); + &poly_add_vec($T1); + &poly_mul(); + &poly_add_vec($T2); + &poly_mul(); + &poly_add_vec($T3); + &poly_mul(); +$code.=<<___; + + eor $T0.16b, $T0.16b, $A0.16b + eor $T1.16b, $T1.16b, $B0.16b + eor $T2.16b, $T2.16b, $C0.16b + eor $T3.16b, $T3.16b, $D0.16b + + st1 {$T0.16b - $T3.16b}, [$oup], #64 + + sub $inl, $inl, #64 + + mov $A0.16b, $A1.16b + mov $B0.16b, $B1.16b + mov $C0.16b, $C1.16b + mov $D0.16b, $D1.16b + +.Lopen_128_store_64: + + lsr $adl, $inl, #4 + mov $adp, $inp + +.Lopen_128_hash_64: + cbz $adl, .Lopen_tail_64_store +___ + &poly_add($adp); + &poly_mul(); +$code.=<<___; + sub $adl, $adl, #1 + b .Lopen_128_hash_64 +.cfi_endproc +.size chacha20_poly1305_open,.-chacha20_poly1305_open +___ +} + +foreach (split("\n",$code)) { + s/\`([^\`]*)\`/eval $1/ge; + + print $_,"\n"; +} +close STDOUT or die "error closing STDOUT"; diff --git a/http/vendor/ring/crypto/cipher/asm/chacha20_poly1305_x86_64.pl b/http/vendor/ring/crypto/cipher/asm/chacha20_poly1305_x86_64.pl new file mode 100644 index 0000000..1abc178 --- /dev/null +++ b/http/vendor/ring/crypto/cipher/asm/chacha20_poly1305_x86_64.pl @@ -0,0 +1,2609 @@ +#!/usr/bin/env perl + +# Copyright (c) 2015, CloudFlare Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +############################################################################## +# # +# Author: Vlad Krasnov # +# # +############################################################################## + +$flavour = shift; +$output = shift; +if ($flavour =~ /\./) { $output = $flavour; undef $flavour; } + +$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/); + +$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; +( $xlate="${dir}x86_64-xlate.pl" and -f $xlate ) or +( $xlate="${dir}../../perlasm/x86_64-xlate.pl" and -f $xlate) or +die "can't locate x86_64-xlate.pl"; + +open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""; +*STDOUT=*OUT; + +$avx = 2; + +$code.=<<___; +.section .rodata +.align 64 +chacha20_poly1305_constants: +.Lchacha20_consts: +.byte 'e','x','p','a','n','d',' ','3','2','-','b','y','t','e',' ','k' +.byte 'e','x','p','a','n','d',' ','3','2','-','b','y','t','e',' ','k' +.Lrol8: +.byte 3,0,1,2, 7,4,5,6, 11,8,9,10, 15,12,13,14 +.byte 3,0,1,2, 7,4,5,6, 11,8,9,10, 15,12,13,14 +.Lrol16: +.byte 2,3,0,1, 6,7,4,5, 10,11,8,9, 14,15,12,13 +.byte 2,3,0,1, 6,7,4,5, 10,11,8,9, 14,15,12,13 +.Lavx2_init: +.long 0,0,0,0 +.Lsse_inc: +.long 1,0,0,0 +.Lavx2_inc: +.long 2,0,0,0,2,0,0,0 +.Lclamp: +.quad 0x0FFFFFFC0FFFFFFF, 0x0FFFFFFC0FFFFFFC +.quad 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF +.align 16 +.Land_masks: +.byte 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff +.text +___ + +my ($oup,$inp,$inl,$adp,$keyp,$itr1,$itr2,$adl)=("%rdi","%rsi","%rbx","%rcx","%r9","%rcx","%r8","%r8"); +my ($acc0,$acc1,$acc2)=map("%r$_",(10..12)); +my ($t0,$t1,$t2,$t3)=("%r13","%r14","%r15","%r9"); +my ($A0,$A1,$A2,$A3,$B0,$B1,$B2,$B3,$C0,$C1,$C2,$C3,$D0,$D1,$D2,$D3)=map("%xmm$_",(0..15)); +my ($T0,$T1,$T2,$T3)=($A3,$B3,$C3,$D3); +my $xmm_storage = 0; +if ($win64) { + $xmm_storage = 10*16; +} +my $xmm_store="0*16(%rbp)"; +my $r_store="$xmm_storage+0*16(%rbp)"; +my $s_store="$xmm_storage+1*16(%rbp)"; +my $len_store="$xmm_storage+2*16(%rbp)"; +my $state1_store="$xmm_storage+3*16(%rbp)"; +my $state2_store="$xmm_storage+4*16(%rbp)"; +my $tmp_store="$xmm_storage+5*16(%rbp)"; +my $ctr0_store="$xmm_storage+6*16(%rbp)"; +my $ctr1_store="$xmm_storage+7*16(%rbp)"; +my $ctr2_store="$xmm_storage+8*16(%rbp)"; +my $ctr3_store="$xmm_storage+9*16(%rbp)"; + +sub chacha_qr { +my ($a,$b,$c,$d,$t,$dir)=@_; +$code.="movdqa $t, $tmp_store\n" if ($dir =~ /store/); +$code.="paddd $b, $a + pxor $a, $d + pshufb .Lrol16(%rip), $d + paddd $d, $c + pxor $c, $b + movdqa $b, $t + pslld \$12, $t + psrld \$20, $b + pxor $t, $b + paddd $b, $a + pxor $a, $d + pshufb .Lrol8(%rip), $d + paddd $d, $c + pxor $c, $b + movdqa $b, $t + pslld \$7, $t + psrld \$25, $b + pxor $t, $b\n"; +$code.="palignr \$4, $b, $b + palignr \$8, $c, $c + palignr \$12, $d, $d\n" if ($dir =~ /left/); +$code.="palignr \$12, $b, $b + palignr \$8, $c, $c + palignr \$4, $d, $d\n" if ($dir =~ /right/); +$code.="movdqa $tmp_store, $t\n" if ($dir =~ /load/); +} + +sub poly_add { +my ($src)=@_; +$code.="add 0+$src, $acc0 + adc 8+$src, $acc1 + adc \$1, $acc2\n"; +} + +sub poly_stage1 { +$code.="mov 0+$r_store, %rax + mov %rax, $t2 + mul $acc0 + mov %rax, $t0 + mov %rdx, $t1 + mov 0+$r_store, %rax + mul $acc1 + imulq $acc2, $t2 + add %rax, $t1 + adc %rdx, $t2\n"; +} + +sub poly_stage2 { +$code.="mov 8+$r_store, %rax + mov %rax, $t3 + mul $acc0 + add %rax, $t1 + adc \$0, %rdx + mov %rdx, $acc0 + mov 8+$r_store, %rax + mul $acc1 + add %rax, $t2 + adc \$0, %rdx\n"; +} + +sub poly_stage3 { +$code.="imulq $acc2, $t3 + add $acc0, $t2 + adc %rdx, $t3\n"; +} + +# At the beginning of the reduce stage t = [t3:t2:t1:t0] is a product of +# r = [r1:r0] and acc = [acc2:acc1:acc0] +# r is 124 bits at most (due to clamping) and acc is 131 bits at most +# (acc2 is at most 4 before the addition and can be at most 6 when we add in +# the next block) therefore t is at most 255 bits big, and t3 is 63 bits. +sub poly_reduce_stage { +$code.="mov $t0, $acc0 + mov $t1, $acc1 + mov $t2, $acc2 + and \$3, $acc2 # At this point acc2 is 2 bits at most (value of 3) + mov $t2, $t0 + and \$-4, $t0 + mov $t3, $t1 + shrd \$2, $t3, $t2 + shr \$2, $t3 + add $t0, $t2 + adc $t1, $t3 # No carry out since t3 is 61 bits and t1 is 63 bits + add $t2, $acc0 + adc $t3, $acc1 + adc \$0, $acc2\n"; # At this point acc2 has the value of 4 at most +} + +sub poly_mul { + &poly_stage1(); + &poly_stage2(); + &poly_stage3(); + &poly_reduce_stage(); +} + +sub prep_state { +my ($n)=@_; +$code.="movdqa .Lchacha20_consts(%rip), $A0 + movdqa $state1_store, $B0 + movdqa $state2_store, $C0\n"; +$code.="movdqa $A0, $A1 + movdqa $B0, $B1 + movdqa $C0, $C1\n" if ($n ge 2); +$code.="movdqa $A0, $A2 + movdqa $B0, $B2 + movdqa $C0, $C2\n" if ($n ge 3); +$code.="movdqa $A0, $A3 + movdqa $B0, $B3 + movdqa $C0, $C3\n" if ($n ge 4); +$code.="movdqa $ctr0_store, $D0 + paddd .Lsse_inc(%rip), $D0 + movdqa $D0, $ctr0_store\n" if ($n eq 1); +$code.="movdqa $ctr0_store, $D1 + paddd .Lsse_inc(%rip), $D1 + movdqa $D1, $D0 + paddd .Lsse_inc(%rip), $D0 + movdqa $D0, $ctr0_store + movdqa $D1, $ctr1_store\n" if ($n eq 2); +$code.="movdqa $ctr0_store, $D2 + paddd .Lsse_inc(%rip), $D2 + movdqa $D2, $D1 + paddd .Lsse_inc(%rip), $D1 + movdqa $D1, $D0 + paddd .Lsse_inc(%rip), $D0 + movdqa $D0, $ctr0_store + movdqa $D1, $ctr1_store + movdqa $D2, $ctr2_store\n" if ($n eq 3); +$code.="movdqa $ctr0_store, $D3 + paddd .Lsse_inc(%rip), $D3 + movdqa $D3, $D2 + paddd .Lsse_inc(%rip), $D2 + movdqa $D2, $D1 + paddd .Lsse_inc(%rip), $D1 + movdqa $D1, $D0 + paddd .Lsse_inc(%rip), $D0 + movdqa $D0, $ctr0_store + movdqa $D1, $ctr1_store + movdqa $D2, $ctr2_store + movdqa $D3, $ctr3_store\n" if ($n eq 4); +} + +sub finalize_state { +my ($n)=@_; +$code.="paddd .Lchacha20_consts(%rip), $A3 + paddd $state1_store, $B3 + paddd $state2_store, $C3 + paddd $ctr3_store, $D3\n" if ($n eq 4); +$code.="paddd .Lchacha20_consts(%rip), $A2 + paddd $state1_store, $B2 + paddd $state2_store, $C2 + paddd $ctr2_store, $D2\n" if ($n ge 3); +$code.="paddd .Lchacha20_consts(%rip), $A1 + paddd $state1_store, $B1 + paddd $state2_store, $C1 + paddd $ctr1_store, $D1\n" if ($n ge 2); +$code.="paddd .Lchacha20_consts(%rip), $A0 + paddd $state1_store, $B0 + paddd $state2_store, $C0 + paddd $ctr0_store, $D0\n"; +} + +sub xor_stream { +my ($A, $B, $C, $D, $offset)=@_; +$code.="movdqu 0*16 + $offset($inp), $A3 + movdqu 1*16 + $offset($inp), $B3 + movdqu 2*16 + $offset($inp), $C3 + movdqu 3*16 + $offset($inp), $D3 + pxor $A3, $A + pxor $B3, $B + pxor $C3, $C + pxor $D, $D3 + movdqu $A, 0*16 + $offset($oup) + movdqu $B, 1*16 + $offset($oup) + movdqu $C, 2*16 + $offset($oup) + movdqu $D3, 3*16 + $offset($oup)\n"; +} + +sub xor_stream_using_temp { +my ($A, $B, $C, $D, $offset, $temp)=@_; +$code.="movdqa $temp, $tmp_store + movdqu 0*16 + $offset($inp), $temp + pxor $A, $temp + movdqu $temp, 0*16 + $offset($oup) + movdqu 1*16 + $offset($inp), $temp + pxor $B, $temp + movdqu $temp, 1*16 + $offset($oup) + movdqu 2*16 + $offset($inp), $temp + pxor $C, $temp + movdqu $temp, 2*16 + $offset($oup) + movdqu 3*16 + $offset($inp), $temp + pxor $D, $temp + movdqu $temp, 3*16 + $offset($oup)\n"; +} + +sub gen_chacha_round { +my ($rot1, $rot2, $shift)=@_; +my $round=""; +$round.="movdqa $C0, $tmp_store\n" if ($rot1 eq 20); +$round.="movdqa $rot2, $C0 + paddd $B3, $A3 + paddd $B2, $A2 + paddd $B1, $A1 + paddd $B0, $A0 + pxor $A3, $D3 + pxor $A2, $D2 + pxor $A1, $D1 + pxor $A0, $D0 + pshufb $C0, $D3 + pshufb $C0, $D2 + pshufb $C0, $D1 + pshufb $C0, $D0 + movdqa $tmp_store, $C0 + paddd $D3, $C3 + paddd $D2, $C2 + paddd $D1, $C1 + paddd $D0, $C0 + pxor $C3, $B3 + pxor $C2, $B2 + pxor $C1, $B1 + pxor $C0, $B0 + movdqa $C0, $tmp_store + movdqa $B3, $C0 + psrld \$$rot1, $C0 + pslld \$32-$rot1, $B3 + pxor $C0, $B3 + movdqa $B2, $C0 + psrld \$$rot1, $C0 + pslld \$32-$rot1, $B2 + pxor $C0, $B2 + movdqa $B1, $C0 + psrld \$$rot1, $C0 + pslld \$32-$rot1, $B1 + pxor $C0, $B1 + movdqa $B0, $C0 + psrld \$$rot1, $C0 + pslld \$32-$rot1, $B0 + pxor $C0, $B0\n"; +($s1,$s2,$s3)=(4,8,12) if ($shift =~ /left/); +($s1,$s2,$s3)=(12,8,4) if ($shift =~ /right/); +$round.="movdqa $tmp_store, $C0 + palignr \$$s1, $B3, $B3 + palignr \$$s2, $C3, $C3 + palignr \$$s3, $D3, $D3 + palignr \$$s1, $B2, $B2 + palignr \$$s2, $C2, $C2 + palignr \$$s3, $D2, $D2 + palignr \$$s1, $B1, $B1 + palignr \$$s2, $C1, $C1 + palignr \$$s3, $D1, $D1 + palignr \$$s1, $B0, $B0 + palignr \$$s2, $C0, $C0 + palignr \$$s3, $D0, $D0\n" +if (($shift =~ /left/) || ($shift =~ /right/)); +return $round; +}; + +$chacha_body = &gen_chacha_round(20, ".Lrol16(%rip)") . + &gen_chacha_round(25, ".Lrol8(%rip)", "left") . + &gen_chacha_round(20, ".Lrol16(%rip)") . + &gen_chacha_round(25, ".Lrol8(%rip)", "right"); + +my @loop_body = split /\n/, $chacha_body; + +sub emit_body { +my ($n)=@_; + for (my $i=0; $i < $n; $i++) { + $code=$code.shift(@loop_body)."\n"; + }; +} + +{ +################################################################################ +# void poly_hash_ad_internal(); +$code.=" +.type poly_hash_ad_internal,\@abi-omnipotent +.align 64 +poly_hash_ad_internal: +.cfi_startproc +.cfi_def_cfa rsp, 8 + xor $acc0, $acc0 + xor $acc1, $acc1 + xor $acc2, $acc2 + cmp \$13, $itr2 + jne .Lhash_ad_loop +.Lpoly_fast_tls_ad: + # Special treatment for the TLS case of 13 bytes + mov ($adp), $acc0 + mov 5($adp), $acc1 + shr \$24, $acc1 + mov \$1, $acc2\n"; + &poly_mul(); $code.=" + ret +.Lhash_ad_loop: + # Hash in 16 byte chunk + cmp \$16, $itr2 + jb .Lhash_ad_tail\n"; + &poly_add("0($adp)"); + &poly_mul(); $code.=" + lea 1*16($adp), $adp + sub \$16, $itr2 + jmp .Lhash_ad_loop +.Lhash_ad_tail: + cmp \$0, $itr2 + je .Lhash_ad_done + # Hash last < 16 byte tail + xor $t0, $t0 + xor $t1, $t1 + xor $t2, $t2 + add $itr2, $adp +.Lhash_ad_tail_loop: + shld \$8, $t0, $t1 + shl \$8, $t0 + movzxb -1($adp), $t2 + xor $t2, $t0 + dec $adp + dec $itr2 + jne .Lhash_ad_tail_loop + + add $t0, $acc0 + adc $t1, $acc1 + adc \$1, $acc2\n"; + &poly_mul(); $code.=" + # Finished AD +.Lhash_ad_done: + ret +.cfi_endproc +.size poly_hash_ad_internal, .-poly_hash_ad_internal\n"; +} + +{ +################################################################################ +# void chacha20_poly1305_open(uint8_t *out_plaintext, const uint8_t *ciphertext, +# size_t plaintext_len, const uint8_t *ad, +# size_t ad_len, +# union chacha20_poly1305_open_data *aead_data) +# +$code.=" +.globl chacha20_poly1305_open_sse41 +.type chacha20_poly1305_open_sse41,\@function,6 +.align 64 +chacha20_poly1305_open_sse41: +.cfi_startproc + _CET_ENDBR + push %rbp +.cfi_push %rbp + push %rbx +.cfi_push %rbx + push %r12 +.cfi_push %r12 + push %r13 +.cfi_push %r13 + push %r14 +.cfi_push %r14 + push %r15 +.cfi_push %r15 + # We write the calculated authenticator back to keyp at the end, so save + # the pointer on the stack too. + push $keyp +.cfi_push $keyp + sub \$288 + $xmm_storage + 32, %rsp +.cfi_adjust_cfa_offset 288 + 32 + + lea 32(%rsp), %rbp + and \$-32, %rbp\n"; +$code.=" + movaps %xmm6,16*0+$xmm_store + movaps %xmm7,16*1+$xmm_store + movaps %xmm8,16*2+$xmm_store + movaps %xmm9,16*3+$xmm_store + movaps %xmm10,16*4+$xmm_store + movaps %xmm11,16*5+$xmm_store + movaps %xmm12,16*6+$xmm_store + movaps %xmm13,16*7+$xmm_store + movaps %xmm14,16*8+$xmm_store + movaps %xmm15,16*9+$xmm_store\n" if ($win64); +$code.=" + mov %rdx, $inl + mov $adl, 0+$len_store + mov $inl, 8+$len_store + + cmp \$128, $inl + jbe .Lopen_sse_128 + # For long buffers, prepare the poly key first + movdqa .Lchacha20_consts(%rip), $A0 + movdqu 0*16($keyp), $B0 + movdqu 1*16($keyp), $C0 + movdqu 2*16($keyp), $D0 + + movdqa $D0, $T1 + # Store on stack, to free keyp + movdqa $B0, $state1_store + movdqa $C0, $state2_store + movdqa $D0, $ctr0_store + mov \$10, $acc0 +.Lopen_sse_init_rounds:\n"; + &chacha_qr($A0,$B0,$C0,$D0,$T0,"left"); + &chacha_qr($A0,$B0,$C0,$D0,$T0,"right"); $code.=" + dec $acc0 + jne .Lopen_sse_init_rounds + # A0|B0 hold the Poly1305 32-byte key, C0,D0 can be discarded + paddd .Lchacha20_consts(%rip), $A0 + paddd $state1_store, $B0 + # Clamp and store the key + pand .Lclamp(%rip), $A0 + movdqa $A0, $r_store + movdqa $B0, $s_store + # Hash + mov $adl, $itr2 + call poly_hash_ad_internal +.Lopen_sse_main_loop: + cmp \$16*16, $inl + jb .Lopen_sse_tail + # Load state, increment counter blocks\n"; + &prep_state(4); $code.=" + # There are 10 ChaCha20 iterations of 2QR each, so for 6 iterations we + # hash 2 blocks, and for the remaining 4 only 1 block - for a total of 16 + mov \$4, $itr1 + mov $inp, $itr2 +.Lopen_sse_main_loop_rounds:\n"; + &emit_body(20); + &poly_add("0($itr2)"); $code.=" + lea 2*8($itr2), $itr2\n"; + &emit_body(20); + &poly_stage1(); + &emit_body(20); + &poly_stage2(); + &emit_body(20); + &poly_stage3(); + &emit_body(20); + &poly_reduce_stage(); + foreach $l (@loop_body) {$code.=$l."\n";} + @loop_body = split /\n/, $chacha_body; $code.=" + dec $itr1 + jge .Lopen_sse_main_loop_rounds\n"; + &poly_add("0($itr2)"); + &poly_mul(); $code.=" + lea 2*8($itr2), $itr2 + cmp \$-6, $itr1 + jg .Lopen_sse_main_loop_rounds\n"; + &finalize_state(4); + &xor_stream_using_temp($A3, $B3, $C3, $D3, "0*16", $D0); + &xor_stream($A2, $B2, $C2, $D2, "4*16"); + &xor_stream($A1, $B1, $C1, $D1, "8*16"); + &xor_stream($A0, $B0, $C0, $tmp_store, "12*16"); $code.=" + lea 16*16($inp), $inp + lea 16*16($oup), $oup + sub \$16*16, $inl + jmp .Lopen_sse_main_loop +.Lopen_sse_tail: + # Handle the various tail sizes efficiently + test $inl, $inl + jz .Lopen_sse_finalize + cmp \$12*16, $inl + ja .Lopen_sse_tail_256 + cmp \$8*16, $inl + ja .Lopen_sse_tail_192 + cmp \$4*16, $inl + ja .Lopen_sse_tail_128\n"; +############################################################################### + # At most 64 bytes are left + &prep_state(1); $code.=" + xor $itr2, $itr2 + mov $inl, $itr1 + cmp \$16, $itr1 + jb .Lopen_sse_tail_64_rounds +.Lopen_sse_tail_64_rounds_and_x1hash: \n"; + &poly_add("0($inp,$itr2)"); + &poly_mul(); $code.=" + sub \$16, $itr1 +.Lopen_sse_tail_64_rounds: + add \$16, $itr2\n"; + &chacha_qr($A0,$B0,$C0,$D0,$T0,"left"); + &chacha_qr($A0,$B0,$C0,$D0,$T0,"right"); $code.=" + cmp \$16, $itr1 + jae .Lopen_sse_tail_64_rounds_and_x1hash + cmp \$10*16, $itr2 + jne .Lopen_sse_tail_64_rounds\n"; + &finalize_state(1); $code.=" + jmp .Lopen_sse_tail_64_dec_loop +############################################################################### +.Lopen_sse_tail_128:\n"; + # 65 - 128 bytes are left + &prep_state(2); $code.=" + mov $inl, $itr1 + and \$-16, $itr1 + xor $itr2, $itr2 +.Lopen_sse_tail_128_rounds_and_x1hash: \n"; + &poly_add("0($inp,$itr2)"); + &poly_mul(); $code.=" +.Lopen_sse_tail_128_rounds: + add \$16, $itr2\n"; + &chacha_qr($A0,$B0,$C0,$D0,$T0,"left"); + &chacha_qr($A1,$B1,$C1,$D1,$T0,"left"); + &chacha_qr($A0,$B0,$C0,$D0,$T0,"right"); + &chacha_qr($A1,$B1,$C1,$D1,$T0,"right");$code.=" + cmp $itr1, $itr2 + jb .Lopen_sse_tail_128_rounds_and_x1hash + cmp \$10*16, $itr2 + jne .Lopen_sse_tail_128_rounds\n"; + &finalize_state(2); + &xor_stream($A1, $B1, $C1, $D1, "0*16"); $code.=" + sub \$4*16, $inl + lea 4*16($inp), $inp + lea 4*16($oup), $oup + jmp .Lopen_sse_tail_64_dec_loop +############################################################################### +.Lopen_sse_tail_192:\n"; + # 129 - 192 bytes are left + &prep_state(3); $code.=" + mov $inl, $itr1 + mov \$10*16, $itr2 + cmp \$10*16, $itr1 + cmovg $itr2, $itr1 + and \$-16, $itr1 + xor $itr2, $itr2 +.Lopen_sse_tail_192_rounds_and_x1hash: \n"; + &poly_add("0($inp,$itr2)"); + &poly_mul(); $code.=" +.Lopen_sse_tail_192_rounds: + add \$16, $itr2\n"; + &chacha_qr($A0,$B0,$C0,$D0,$T0,"left"); + &chacha_qr($A1,$B1,$C1,$D1,$T0,"left"); + &chacha_qr($A2,$B2,$C2,$D2,$T0,"left"); + &chacha_qr($A0,$B0,$C0,$D0,$T0,"right"); + &chacha_qr($A1,$B1,$C1,$D1,$T0,"right"); + &chacha_qr($A2,$B2,$C2,$D2,$T0,"right"); $code.=" + cmp $itr1, $itr2 + jb .Lopen_sse_tail_192_rounds_and_x1hash + cmp \$10*16, $itr2 + jne .Lopen_sse_tail_192_rounds + cmp \$11*16, $inl + jb .Lopen_sse_tail_192_finish\n"; + &poly_add("10*16($inp)"); + &poly_mul(); $code.=" + cmp \$12*16, $inl + jb .Lopen_sse_tail_192_finish\n"; + &poly_add("11*16($inp)"); + &poly_mul(); $code.=" +.Lopen_sse_tail_192_finish: \n"; + &finalize_state(3); + &xor_stream($A2, $B2, $C2, $D2, "0*16"); + &xor_stream($A1, $B1, $C1, $D1, "4*16"); $code.=" + sub \$8*16, $inl + lea 8*16($inp), $inp + lea 8*16($oup), $oup + jmp .Lopen_sse_tail_64_dec_loop +############################################################################### +.Lopen_sse_tail_256:\n"; + # 193 - 255 bytes are left + &prep_state(4); $code.=" + xor $itr2, $itr2 +.Lopen_sse_tail_256_rounds_and_x1hash: \n"; + &poly_add("0($inp,$itr2)"); + &chacha_qr($A0,$B0,$C0,$D0,$C3,"store_left"); + &chacha_qr($A1,$B1,$C1,$D1,$C3,"left"); + &chacha_qr($A2,$B2,$C2,$D2,$C3,"left_load"); + &poly_stage1(); + &chacha_qr($A3,$B3,$C3,$D3,$C1,"store_left_load"); + &poly_stage2(); + &chacha_qr($A0,$B0,$C0,$D0,$C3,"store_right"); + &chacha_qr($A1,$B1,$C1,$D1,$C3,"right"); + &poly_stage3(); + &chacha_qr($A2,$B2,$C2,$D2,$C3,"right_load"); + &poly_reduce_stage(); + &chacha_qr($A3,$B3,$C3,$D3,$C1,"store_right_load"); $code.=" + add \$16, $itr2 + cmp \$10*16, $itr2 + jb .Lopen_sse_tail_256_rounds_and_x1hash + + mov $inl, $itr1 + and \$-16, $itr1 +.Lopen_sse_tail_256_hash: \n"; + &poly_add("0($inp,$itr2)"); + &poly_mul(); $code.=" + add \$16, $itr2 + cmp $itr1, $itr2 + jb .Lopen_sse_tail_256_hash\n"; + &finalize_state(4); + &xor_stream_using_temp($A3, $B3, $C3, $D3, "0*16", $D0); + &xor_stream($A2, $B2, $C2, $D2, "4*16"); + &xor_stream($A1, $B1, $C1, $D1, "8*16"); $code.=" + movdqa $tmp_store, $D0 + sub \$12*16, $inl + lea 12*16($inp), $inp + lea 12*16($oup), $oup +############################################################################### + # Decrypt the remaining data, 16B at a time, using existing stream +.Lopen_sse_tail_64_dec_loop: + cmp \$16, $inl + jb .Lopen_sse_tail_16_init + sub \$16, $inl + movdqu ($inp), $T0 + pxor $T0, $A0 + movdqu $A0, ($oup) + lea 16($inp), $inp + lea 16($oup), $oup + movdqa $B0, $A0 + movdqa $C0, $B0 + movdqa $D0, $C0 + jmp .Lopen_sse_tail_64_dec_loop +.Lopen_sse_tail_16_init: + movdqa $A0, $A1 + + # Decrypt up to 16 bytes at the end. +.Lopen_sse_tail_16: + test $inl, $inl + jz .Lopen_sse_finalize + + # Read the final bytes into $T0. They need to be read in reverse order so + # that they end up in the correct order in $T0. + pxor $T0, $T0 + lea -1($inp,$inl), $inp + movq $inl, $itr2 +.Lopen_sse_tail_16_compose: + pslldq \$1, $T0 + pinsrb \$0, ($inp), $T0 + sub \$1, $inp + sub \$1, $itr2 + jnz .Lopen_sse_tail_16_compose + + movq $T0, $t0 + pextrq \$1, $T0, $t1 + # The final bytes of keystream are in $A1. + pxor $A1, $T0 + + # Copy the plaintext bytes out. +.Lopen_sse_tail_16_extract: + pextrb \$0, $T0, ($oup) + psrldq \$1, $T0 + add \$1, $oup + sub \$1, $inl + jne .Lopen_sse_tail_16_extract + + add $t0, $acc0 + adc $t1, $acc1 + adc \$1, $acc2\n"; + &poly_mul(); $code.=" + +.Lopen_sse_finalize:\n"; + &poly_add($len_store); + &poly_mul(); $code.=" + # Final reduce + mov $acc0, $t0 + mov $acc1, $t1 + mov $acc2, $t2 + sub \$-5, $acc0 + sbb \$-1, $acc1 + sbb \$3, $acc2 + cmovc $t0, $acc0 + cmovc $t1, $acc1 + cmovc $t2, $acc2 + # Add in s part of the key + add 0+$s_store, $acc0 + adc 8+$s_store, $acc1\n"; + +$code.=" + movaps 16*0+$xmm_store, %xmm6 + movaps 16*1+$xmm_store, %xmm7 + movaps 16*2+$xmm_store, %xmm8 + movaps 16*3+$xmm_store, %xmm9 + movaps 16*4+$xmm_store, %xmm10 + movaps 16*5+$xmm_store, %xmm11 + movaps 16*6+$xmm_store, %xmm12 + movaps 16*7+$xmm_store, %xmm13 + movaps 16*8+$xmm_store, %xmm14 + movaps 16*9+$xmm_store, %xmm15\n" if ($win64); +$code.=" +.cfi_remember_state + add \$288 + $xmm_storage + 32, %rsp +.cfi_adjust_cfa_offset -(288 + 32) + # The tag replaces the key on return + pop $keyp +.cfi_pop $keyp + mov $acc0, ($keyp) + mov $acc1, 8($keyp) + pop %r15 +.cfi_pop %r15 + pop %r14 +.cfi_pop %r14 + pop %r13 +.cfi_pop %r13 + pop %r12 +.cfi_pop %r12 + pop %rbx +.cfi_pop %rbx + pop %rbp +.cfi_pop %rbp + ret +############################################################################### +.Lopen_sse_128: +.cfi_restore_state + movdqu .Lchacha20_consts(%rip), $A0\nmovdqa $A0, $A1\nmovdqa $A0, $A2 + movdqu 0*16($keyp), $B0\nmovdqa $B0, $B1\nmovdqa $B0, $B2 + movdqu 1*16($keyp), $C0\nmovdqa $C0, $C1\nmovdqa $C0, $C2 + movdqu 2*16($keyp), $D0 + movdqa $D0, $D1\npaddd .Lsse_inc(%rip), $D1 + movdqa $D1, $D2\npaddd .Lsse_inc(%rip), $D2 + movdqa $B0, $T1\nmovdqa $C0, $T2\nmovdqa $D1, $T3 + mov \$10, $acc0 + +.Lopen_sse_128_rounds: \n"; + &chacha_qr($A0,$B0,$C0,$D0,$T0,"left"); + &chacha_qr($A1,$B1,$C1,$D1,$T0,"left"); + &chacha_qr($A2,$B2,$C2,$D2,$T0,"left"); + &chacha_qr($A0,$B0,$C0,$D0,$T0,"right"); + &chacha_qr($A1,$B1,$C1,$D1,$T0,"right"); + &chacha_qr($A2,$B2,$C2,$D2,$T0,"right"); $code.=" + dec $acc0 + jnz .Lopen_sse_128_rounds + paddd .Lchacha20_consts(%rip), $A0 + paddd .Lchacha20_consts(%rip), $A1 + paddd .Lchacha20_consts(%rip), $A2 + paddd $T1, $B0\npaddd $T1, $B1\npaddd $T1, $B2 + paddd $T2, $C1\npaddd $T2, $C2 + paddd $T3, $D1 + paddd .Lsse_inc(%rip), $T3 + paddd $T3, $D2 + # Clamp and store the key + pand .Lclamp(%rip), $A0 + movdqa $A0, $r_store + movdqa $B0, $s_store + # Hash + mov $adl, $itr2 + call poly_hash_ad_internal +.Lopen_sse_128_xor_hash: + cmp \$16, $inl + jb .Lopen_sse_tail_16 + sub \$16, $inl\n"; + # Load for hashing + &poly_add("0*8($inp)"); $code.=" + # Load for decryption + movdqu 0*16($inp), $T0 + pxor $T0, $A1 + movdqu $A1, 0*16($oup) + lea 1*16($inp), $inp + lea 1*16($oup), $oup\n"; + &poly_mul(); $code.=" + # Shift the stream left + movdqa $B1, $A1 + movdqa $C1, $B1 + movdqa $D1, $C1 + movdqa $A2, $D1 + movdqa $B2, $A2 + movdqa $C2, $B2 + movdqa $D2, $C2 + jmp .Lopen_sse_128_xor_hash +.size chacha20_poly1305_open_sse41, .-chacha20_poly1305_open_sse41 +.cfi_endproc + +################################################################################ +################################################################################ +# void chacha20_poly1305_seal(uint8_t *out_ciphertext, const uint8_t *plaintext, +# size_t plaintext_len, const uint8_t *ad, +# size_t ad_len, +# union chacha20_poly1305_seal_data *data); +.globl chacha20_poly1305_seal_sse41 +.type chacha20_poly1305_seal_sse41,\@function,6 +.align 64 +chacha20_poly1305_seal_sse41: +.cfi_startproc + _CET_ENDBR + push %rbp +.cfi_push %rbp + push %rbx +.cfi_push %rbx + push %r12 +.cfi_push %r12 + push %r13 +.cfi_push %r13 + push %r14 +.cfi_push %r14 + push %r15 +.cfi_push %r15 +# We write the calculated authenticator back to keyp at the end, so save +# the pointer on the stack too. + push $keyp +.cfi_push $keyp + sub \$288 + $xmm_storage + 32, %rsp +.cfi_adjust_cfa_offset 288 + 32 + lea 32(%rsp), %rbp + and \$-32, %rbp\n"; +$code.=" + movaps %xmm6,16*0+$xmm_store + movaps %xmm7,16*1+$xmm_store + movaps %xmm8,16*2+$xmm_store + movaps %xmm9,16*3+$xmm_store + movaps %xmm10,16*4+$xmm_store + movaps %xmm11,16*5+$xmm_store + movaps %xmm12,16*6+$xmm_store + movaps %xmm13,16*7+$xmm_store + movaps %xmm14,16*8+$xmm_store + movaps %xmm15,16*9+$xmm_store\n" if ($win64); +$code.=" + mov 56($keyp), $inl # extra_in_len + addq %rdx, $inl + mov $adl, 0+$len_store + mov $inl, 8+$len_store + mov %rdx, $inl + + cmp \$128, $inl + jbe .Lseal_sse_128 + # For longer buffers, prepare the poly key + some stream + movdqa .Lchacha20_consts(%rip), $A0 + movdqu 0*16($keyp), $B0 + movdqu 1*16($keyp), $C0 + movdqu 2*16($keyp), $D0 + + movdqa $A0, $A1 + movdqa $A0, $A2 + movdqa $A0, $A3 + movdqa $B0, $B1 + movdqa $B0, $B2 + movdqa $B0, $B3 + movdqa $C0, $C1 + movdqa $C0, $C2 + movdqa $C0, $C3 + movdqa $D0, $D3 + paddd .Lsse_inc(%rip), $D0 + movdqa $D0, $D2 + paddd .Lsse_inc(%rip), $D0 + movdqa $D0, $D1 + paddd .Lsse_inc(%rip), $D0 + # Store on stack + movdqa $B0, $state1_store + movdqa $C0, $state2_store + movdqa $D0, $ctr0_store + movdqa $D1, $ctr1_store + movdqa $D2, $ctr2_store + movdqa $D3, $ctr3_store + mov \$10, $acc0 +.Lseal_sse_init_rounds: \n"; + foreach $l (@loop_body) {$code.=$l."\n";} + @loop_body = split /\n/, $chacha_body; $code.=" + dec $acc0 + jnz .Lseal_sse_init_rounds\n"; + &finalize_state(4); $code.=" + # Clamp and store the key + pand .Lclamp(%rip), $A3 + movdqa $A3, $r_store + movdqa $B3, $s_store + # Hash + mov $adl, $itr2 + call poly_hash_ad_internal\n"; + &xor_stream($A2,$B2,$C2,$D2,"0*16"); + &xor_stream($A1,$B1,$C1,$D1,"4*16"); $code.=" + cmp \$12*16, $inl + ja .Lseal_sse_main_init + mov \$8*16, $itr1 + sub \$8*16, $inl + lea 8*16($inp), $inp + jmp .Lseal_sse_128_tail_hash +.Lseal_sse_main_init:\n"; + &xor_stream($A0, $B0, $C0, $D0, "8*16"); $code.=" + mov \$12*16, $itr1 + sub \$12*16, $inl + lea 12*16($inp), $inp + mov \$2, $itr1 + mov \$8, $itr2 + cmp \$4*16, $inl + jbe .Lseal_sse_tail_64 + cmp \$8*16, $inl + jbe .Lseal_sse_tail_128 + cmp \$12*16, $inl + jbe .Lseal_sse_tail_192 + +.Lseal_sse_main_loop: \n"; + # The main loop + &prep_state(4); $code.=" +.align 32 +.Lseal_sse_main_rounds: \n"; + &emit_body(20); + &poly_add("0($oup)"); + &emit_body(20); + &poly_stage1(); + &emit_body(20); + &poly_stage2(); + &emit_body(20); + &poly_stage3(); + &emit_body(20); + &poly_reduce_stage(); + foreach $l (@loop_body) {$code.=$l."\n";} + @loop_body = split /\n/, $chacha_body; $code.=" + lea 16($oup), $oup + dec $itr2 + jge .Lseal_sse_main_rounds\n"; + &poly_add("0*8($oup)"); + &poly_mul(); $code.=" + lea 16($oup), $oup + dec $itr1 + jg .Lseal_sse_main_rounds\n"; + + &finalize_state(4);$code.=" + movdqa $D2, $tmp_store\n"; + &xor_stream_using_temp($A3,$B3,$C3,$D3,0*16,$D2); $code.=" + movdqa $tmp_store, $D2\n"; + &xor_stream($A2,$B2,$C2,$D2, 4*16); + &xor_stream($A1,$B1,$C1,$D1, 8*16); $code.=" + cmp \$16*16, $inl + ja .Lseal_sse_main_loop_xor + + mov \$12*16, $itr1 + sub \$12*16, $inl + lea 12*16($inp), $inp + jmp .Lseal_sse_128_tail_hash +.Lseal_sse_main_loop_xor: \n"; + &xor_stream($A0,$B0,$C0,$D0,"12*16"); $code.=" + lea 16*16($inp), $inp + sub \$16*16, $inl + mov \$6, $itr1 + mov \$4, $itr2 + cmp \$12*16, $inl + jg .Lseal_sse_main_loop + mov $inl, $itr1 + test $inl, $inl + je .Lseal_sse_128_tail_hash + mov \$6, $itr1 + cmp \$8*16, $inl + ja .Lseal_sse_tail_192 + cmp \$4*16, $inl + ja .Lseal_sse_tail_128 +############################################################################### +.Lseal_sse_tail_64: \n"; + &prep_state(1); $code.=" +.Lseal_sse_tail_64_rounds_and_x2hash: \n"; + &poly_add("0($oup)"); + &poly_mul(); $code.=" + lea 16($oup), $oup +.Lseal_sse_tail_64_rounds_and_x1hash: \n"; + &chacha_qr($A0,$B0,$C0,$D0,$T0,"left"); + &chacha_qr($A0,$B0,$C0,$D0,$T0,"right"); + &poly_add("0($oup)"); + &poly_mul(); $code.=" + lea 16($oup), $oup + dec $itr1 + jg .Lseal_sse_tail_64_rounds_and_x2hash + dec $itr2 + jge .Lseal_sse_tail_64_rounds_and_x1hash\n"; + &finalize_state(1); $code.=" + jmp .Lseal_sse_128_tail_xor +############################################################################### +.Lseal_sse_tail_128:\n"; + &prep_state(2); $code.=" +.Lseal_sse_tail_128_rounds_and_x2hash: \n"; + &poly_add("0($oup)"); + &poly_mul(); $code.=" + lea 16($oup), $oup +.Lseal_sse_tail_128_rounds_and_x1hash: \n"; + &chacha_qr($A0,$B0,$C0,$D0,$T0,"left"); + &chacha_qr($A1,$B1,$C1,$D1,$T0,"left"); + &poly_add("0($oup)"); + &poly_mul(); + &chacha_qr($A0,$B0,$C0,$D0,$T0,"right"); + &chacha_qr($A1,$B1,$C1,$D1,$T0,"right"); $code.=" + lea 16($oup), $oup + dec $itr1 + jg .Lseal_sse_tail_128_rounds_and_x2hash + dec $itr2 + jge .Lseal_sse_tail_128_rounds_and_x1hash\n"; + &finalize_state(2); + &xor_stream($A1,$B1,$C1,$D1,0*16); $code.=" + mov \$4*16, $itr1 + sub \$4*16, $inl + lea 4*16($inp), $inp + jmp .Lseal_sse_128_tail_hash +############################################################################### +.Lseal_sse_tail_192:\n"; + &prep_state(3); $code.=" +.Lseal_sse_tail_192_rounds_and_x2hash: \n"; + &poly_add("0($oup)"); + &poly_mul(); $code.=" + lea 16($oup), $oup +.Lseal_sse_tail_192_rounds_and_x1hash: \n"; + &chacha_qr($A0,$B0,$C0,$D0,$T0,"left"); + &chacha_qr($A1,$B1,$C1,$D1,$T0,"left"); + &chacha_qr($A2,$B2,$C2,$D2,$T0,"left"); + &poly_add("0($oup)"); + &poly_mul(); + &chacha_qr($A0,$B0,$C0,$D0,$T0,"right"); + &chacha_qr($A1,$B1,$C1,$D1,$T0,"right"); + &chacha_qr($A2,$B2,$C2,$D2,$T0,"right"); $code.=" + lea 16($oup), $oup + dec $itr1 + jg .Lseal_sse_tail_192_rounds_and_x2hash + dec $itr2 + jge .Lseal_sse_tail_192_rounds_and_x1hash\n"; + &finalize_state(3); + &xor_stream($A2,$B2,$C2,$D2,0*16); + &xor_stream($A1,$B1,$C1,$D1,4*16); $code.=" + mov \$8*16, $itr1 + sub \$8*16, $inl + lea 8*16($inp), $inp +############################################################################### +.Lseal_sse_128_tail_hash: + cmp \$16, $itr1 + jb .Lseal_sse_128_tail_xor\n"; + &poly_add("0($oup)"); + &poly_mul(); $code.=" + sub \$16, $itr1 + lea 16($oup), $oup + jmp .Lseal_sse_128_tail_hash + +.Lseal_sse_128_tail_xor: + cmp \$16, $inl + jb .Lseal_sse_tail_16 + sub \$16, $inl + # Load for decryption + movdqu 0*16($inp), $T0 + pxor $T0, $A0 + movdqu $A0, 0*16($oup) + # Then hash + add 0*8($oup), $acc0 + adc 1*8($oup), $acc1 + adc \$1, $acc2 + lea 1*16($inp), $inp + lea 1*16($oup), $oup\n"; + &poly_mul(); $code.=" + # Shift the stream left + movdqa $B0, $A0 + movdqa $C0, $B0 + movdqa $D0, $C0 + movdqa $A1, $D0 + movdqa $B1, $A1 + movdqa $C1, $B1 + movdqa $D1, $C1 + jmp .Lseal_sse_128_tail_xor + +.Lseal_sse_tail_16: + test $inl, $inl + jz .Lprocess_blocks_of_extra_in + # We can only load the PT one byte at a time to avoid buffer overread + mov $inl, $itr2 + mov $inl, $itr1 + lea -1($inp,$inl), $inp + pxor $T3, $T3 +.Lseal_sse_tail_16_compose: + pslldq \$1, $T3 + pinsrb \$0, ($inp), $T3 + lea -1($inp), $inp + dec $itr1 + jne .Lseal_sse_tail_16_compose + + # XOR the keystream with the plaintext. + pxor $A0, $T3 + + # Write ciphertext out, byte-by-byte. + movq $inl, $itr1 + movdqu $T3, $A0 +.Lseal_sse_tail_16_extract: + pextrb \$0, $A0, ($oup) + psrldq \$1, $A0 + add \$1, $oup + sub \$1, $itr1 + jnz .Lseal_sse_tail_16_extract + + # $T3 contains the final (partial, non-empty) block of ciphertext which + # needs to be fed into the Poly1305 state. The right-most $inl bytes of it + # are valid. We need to fill it with extra_in bytes until full, or until we + # run out of bytes. + # + # $keyp points to the tag output, which is actually a struct with the + # extra_in pointer and length at offset 48. + movq 288 + $xmm_storage + 32(%rsp), $keyp + movq 56($keyp), $t1 # extra_in_len + movq 48($keyp), $t0 # extra_in + test $t1, $t1 + jz .Lprocess_partial_block # Common case: no bytes of extra_in + + movq \$16, $t2 + subq $inl, $t2 # 16-$inl is the number of bytes that fit into $T3. + cmpq $t2, $t1 # if extra_in_len < 16-$inl, only copy extra_in_len + # (note that AT&T syntax reverses the arguments) + jge .Lload_extra_in + movq $t1, $t2 + +.Lload_extra_in: + # $t2 contains the number of bytes of extra_in (pointed to by $t0) to load + # into $T3. They are loaded in reverse order. + leaq -1($t0,$t2), $inp + # Update extra_in and extra_in_len to reflect the bytes that are about to + # be read. + addq $t2, $t0 + subq $t2, $t1 + movq $t0, 48($keyp) + movq $t1, 56($keyp) + + # Update $itr2, which is used to select the mask later on, to reflect the + # extra bytes about to be added. + addq $t2, $itr2 + + # Load $t2 bytes of extra_in into $T2. + pxor $T2, $T2 +.Lload_extra_load_loop: + pslldq \$1, $T2 + pinsrb \$0, ($inp), $T2 + lea -1($inp), $inp + sub \$1, $t2 + jnz .Lload_extra_load_loop + + # Shift $T2 up the length of the remainder from the main encryption. Sadly, + # the shift for an XMM register has to be a constant, thus we loop to do + # this. + movq $inl, $t2 + +.Lload_extra_shift_loop: + pslldq \$1, $T2 + sub \$1, $t2 + jnz .Lload_extra_shift_loop + + # Mask $T3 (the remainder from the main encryption) so that superfluous + # bytes are zero. This means that the non-zero bytes in $T2 and $T3 are + # disjoint and so we can merge them with an OR. + lea .Land_masks(%rip), $t2 + shl \$4, $inl + pand -16($t2,$inl), $T3 + + # Merge $T2 into $T3, forming the remainder block. + por $T2, $T3 + + # The block of ciphertext + extra_in is ready to be included in the + # Poly1305 state. + movq $T3, $t0 + pextrq \$1, $T3, $t1 + add $t0, $acc0 + adc $t1, $acc1 + adc \$1, $acc2\n"; + &poly_mul(); $code.=" + +.Lprocess_blocks_of_extra_in: + # There may be additional bytes of extra_in to process. + movq 288+32+$xmm_storage (%rsp), $keyp + movq 48($keyp), $inp # extra_in + movq 56($keyp), $itr2 # extra_in_len + movq $itr2, $itr1 + shr \$4, $itr2 # number of blocks + +.Lprocess_extra_hash_loop: + jz process_extra_in_trailer\n"; + &poly_add("0($inp)"); + &poly_mul(); $code.=" + leaq 16($inp), $inp + subq \$1, $itr2 + jmp .Lprocess_extra_hash_loop +process_extra_in_trailer: + andq \$15, $itr1 # remaining num bytes (<16) of extra_in + movq $itr1, $inl + jz .Ldo_length_block + leaq -1($inp,$itr1), $inp + +.Lprocess_extra_in_trailer_load: + pslldq \$1, $T3 + pinsrb \$0, ($inp), $T3 + lea -1($inp), $inp + sub \$1, $itr1 + jnz .Lprocess_extra_in_trailer_load + +.Lprocess_partial_block: + # $T3 contains $inl bytes of data to be fed into Poly1305. $inl != 0 + lea .Land_masks(%rip), $t2 + shl \$4, $inl + pand -16($t2,$inl), $T3 + movq $T3, $t0 + pextrq \$1, $T3, $t1 + add $t0, $acc0 + adc $t1, $acc1 + adc \$1, $acc2\n"; + &poly_mul(); $code.=" + +.Ldo_length_block:\n"; + &poly_add($len_store); + &poly_mul(); $code.=" + # Final reduce + mov $acc0, $t0 + mov $acc1, $t1 + mov $acc2, $t2 + sub \$-5, $acc0 + sbb \$-1, $acc1 + sbb \$3, $acc2 + cmovc $t0, $acc0 + cmovc $t1, $acc1 + cmovc $t2, $acc2 + # Add in s part of the key + add 0+$s_store, $acc0 + adc 8+$s_store, $acc1\n"; + +$code.=" + movaps 16*0+$xmm_store, %xmm6 + movaps 16*1+$xmm_store, %xmm7 + movaps 16*2+$xmm_store, %xmm8 + movaps 16*3+$xmm_store, %xmm9 + movaps 16*4+$xmm_store, %xmm10 + movaps 16*5+$xmm_store, %xmm11 + movaps 16*6+$xmm_store, %xmm12 + movaps 16*7+$xmm_store, %xmm13 + movaps 16*8+$xmm_store, %xmm14 + movaps 16*9+$xmm_store, %xmm15\n" if ($win64); +$code.=" +.cfi_remember_state + add \$288 + $xmm_storage + 32, %rsp +.cfi_adjust_cfa_offset -(288 + 32) + # The tag replaces the key on return + pop $keyp +.cfi_pop $keyp + mov $acc0, ($keyp) + mov $acc1, 8($keyp) + pop %r15 +.cfi_pop %r15 + pop %r14 +.cfi_pop %r14 + pop %r13 +.cfi_pop %r13 + pop %r12 +.cfi_pop %r12 + pop %rbx +.cfi_pop %rbx + pop %rbp +.cfi_pop %rbp + ret +################################################################################ +.Lseal_sse_128: +.cfi_restore_state + movdqu .Lchacha20_consts(%rip), $A0\nmovdqa $A0, $A1\nmovdqa $A0, $A2 + movdqu 0*16($keyp), $B0\nmovdqa $B0, $B1\nmovdqa $B0, $B2 + movdqu 1*16($keyp), $C0\nmovdqa $C0, $C1\nmovdqa $C0, $C2 + movdqu 2*16($keyp), $D2 + movdqa $D2, $D0\npaddd .Lsse_inc(%rip), $D0 + movdqa $D0, $D1\npaddd .Lsse_inc(%rip), $D1 + movdqa $B0, $T1\nmovdqa $C0, $T2\nmovdqa $D0, $T3 + mov \$10, $acc0 + +.Lseal_sse_128_rounds:\n"; + &chacha_qr($A0,$B0,$C0,$D0,$T0,"left"); + &chacha_qr($A1,$B1,$C1,$D1,$T0,"left"); + &chacha_qr($A2,$B2,$C2,$D2,$T0,"left"); + &chacha_qr($A0,$B0,$C0,$D0,$T0,"right"); + &chacha_qr($A1,$B1,$C1,$D1,$T0,"right"); + &chacha_qr($A2,$B2,$C2,$D2,$T0,"right"); $code.=" + dec $acc0 + jnz .Lseal_sse_128_rounds + paddd .Lchacha20_consts(%rip), $A0 + paddd .Lchacha20_consts(%rip), $A1 + paddd .Lchacha20_consts(%rip), $A2 + paddd $T1, $B0\npaddd $T1, $B1\npaddd $T1, $B2 + paddd $T2, $C0\npaddd $T2, $C1 + paddd $T3, $D0 + paddd .Lsse_inc(%rip), $T3 + paddd $T3, $D1 + # Clamp and store the key + pand .Lclamp(%rip), $A2 + movdqa $A2, $r_store + movdqa $B2, $s_store + # Hash + mov %r8, $itr2 + call poly_hash_ad_internal + jmp .Lseal_sse_128_tail_xor +.size chacha20_poly1305_seal_sse41, .-chacha20_poly1305_seal_sse41 +.cfi_endproc\n"; +} + +if ($avx>1) { + +($A0,$A1,$A2,$A3,$B0,$B1,$B2,$B3,$C0,$C1,$C2,$C3,$D0,$D1,$D2,$D3)=map("%ymm$_",(0..15)); +my ($A0x,$A1x,$A2x,$A3x,$B0x,$B1x,$B2x,$B3x,$C0x,$C1x,$C2x,$C3x,$D0x,$D1x,$D2x,$D3x)=map("%xmm$_",(0..15)); +($T0,$T1,$T2,$T3)=($A3,$B3,$C3,$D3); +$state1_store="$xmm_storage+2*32(%rbp)"; +$state2_store="$xmm_storage+3*32(%rbp)"; +$tmp_store="$xmm_storage+4*32(%rbp)"; +$ctr0_store="$xmm_storage+5*32(%rbp)"; +$ctr1_store="$xmm_storage+6*32(%rbp)"; +$ctr2_store="$xmm_storage+7*32(%rbp)"; +$ctr3_store="$xmm_storage+8*32(%rbp)"; + +sub chacha_qr_avx2 { +my ($a,$b,$c,$d,$t,$dir)=@_; +$code.=<<___ if ($dir =~ /store/); + vmovdqa $t, $tmp_store +___ +$code.=<<___; + vpaddd $b, $a, $a + vpxor $a, $d, $d + vpshufb .Lrol16(%rip), $d, $d + vpaddd $d, $c, $c + vpxor $c, $b, $b + vpsrld \$20, $b, $t + vpslld \$12, $b, $b + vpxor $t, $b, $b + vpaddd $b, $a, $a + vpxor $a, $d, $d + vpshufb .Lrol8(%rip), $d, $d + vpaddd $d, $c, $c + vpxor $c, $b, $b + vpslld \$7, $b, $t + vpsrld \$25, $b, $b + vpxor $t, $b, $b +___ +$code.=<<___ if ($dir =~ /left/); + vpalignr \$12, $d, $d, $d + vpalignr \$8, $c, $c, $c + vpalignr \$4, $b, $b, $b +___ +$code.=<<___ if ($dir =~ /right/); + vpalignr \$4, $d, $d, $d + vpalignr \$8, $c, $c, $c + vpalignr \$12, $b, $b, $b +___ +$code.=<<___ if ($dir =~ /load/); + vmovdqa $tmp_store, $t +___ +} + +sub prep_state_avx2 { +my ($n)=@_; +$code.=<<___; + vmovdqa .Lchacha20_consts(%rip), $A0 + vmovdqa $state1_store, $B0 + vmovdqa $state2_store, $C0 +___ +$code.=<<___ if ($n ge 2); + vmovdqa $A0, $A1 + vmovdqa $B0, $B1 + vmovdqa $C0, $C1 +___ +$code.=<<___ if ($n ge 3); + vmovdqa $A0, $A2 + vmovdqa $B0, $B2 + vmovdqa $C0, $C2 +___ +$code.=<<___ if ($n ge 4); + vmovdqa $A0, $A3 + vmovdqa $B0, $B3 + vmovdqa $C0, $C3 +___ +$code.=<<___ if ($n eq 1); + vmovdqa .Lavx2_inc(%rip), $D0 + vpaddd $ctr0_store, $D0, $D0 + vmovdqa $D0, $ctr0_store +___ +$code.=<<___ if ($n eq 2); + vmovdqa .Lavx2_inc(%rip), $D0 + vpaddd $ctr0_store, $D0, $D1 + vpaddd $D1, $D0, $D0 + vmovdqa $D0, $ctr0_store + vmovdqa $D1, $ctr1_store +___ +$code.=<<___ if ($n eq 3); + vmovdqa .Lavx2_inc(%rip), $D0 + vpaddd $ctr0_store, $D0, $D2 + vpaddd $D2, $D0, $D1 + vpaddd $D1, $D0, $D0 + vmovdqa $D0, $ctr0_store + vmovdqa $D1, $ctr1_store + vmovdqa $D2, $ctr2_store +___ +$code.=<<___ if ($n eq 4); + vmovdqa .Lavx2_inc(%rip), $D0 + vpaddd $ctr0_store, $D0, $D3 + vpaddd $D3, $D0, $D2 + vpaddd $D2, $D0, $D1 + vpaddd $D1, $D0, $D0 + vmovdqa $D3, $ctr3_store + vmovdqa $D2, $ctr2_store + vmovdqa $D1, $ctr1_store + vmovdqa $D0, $ctr0_store +___ +} + +sub finalize_state_avx2 { +my ($n)=@_; +$code.=<<___ if ($n eq 4); + vpaddd .Lchacha20_consts(%rip), $A3, $A3 + vpaddd $state1_store, $B3, $B3 + vpaddd $state2_store, $C3, $C3 + vpaddd $ctr3_store, $D3, $D3 +___ +$code.=<<___ if ($n ge 3); + vpaddd .Lchacha20_consts(%rip), $A2, $A2 + vpaddd $state1_store, $B2, $B2 + vpaddd $state2_store, $C2, $C2 + vpaddd $ctr2_store, $D2, $D2 +___ +$code.=<<___ if ($n ge 2); + vpaddd .Lchacha20_consts(%rip), $A1, $A1 + vpaddd $state1_store, $B1, $B1 + vpaddd $state2_store, $C1, $C1 + vpaddd $ctr1_store, $D1, $D1 +___ +$code.=<<___; + vpaddd .Lchacha20_consts(%rip), $A0, $A0 + vpaddd $state1_store, $B0, $B0 + vpaddd $state2_store, $C0, $C0 + vpaddd $ctr0_store, $D0, $D0 +___ +} + +sub xor_stream_avx2 { +my ($A, $B, $C, $D, $offset, $hlp)=@_; +$code.=<<___; + vperm2i128 \$0x02, $A, $B, $hlp + vperm2i128 \$0x13, $A, $B, $B + vperm2i128 \$0x02, $C, $D, $A + vperm2i128 \$0x13, $C, $D, $C + vpxor 0*32+$offset($inp), $hlp, $hlp + vpxor 1*32+$offset($inp), $A, $A + vpxor 2*32+$offset($inp), $B, $B + vpxor 3*32+$offset($inp), $C, $C + vmovdqu $hlp, 0*32+$offset($oup) + vmovdqu $A, 1*32+$offset($oup) + vmovdqu $B, 2*32+$offset($oup) + vmovdqu $C, 3*32+$offset($oup) +___ +} + +sub finish_stream_avx2 { +my ($A, $B, $C, $D, $hlp)=@_; +$code.=<<___; + vperm2i128 \$0x13, $A, $B, $hlp + vperm2i128 \$0x02, $A, $B, $A + vperm2i128 \$0x02, $C, $D, $B + vperm2i128 \$0x13, $C, $D, $D + vmovdqa $hlp, $C +___ +} + +sub poly_stage1_mulx { +$code.=<<___; + mov 0+$r_store, %rdx + mov %rdx, $t2 + mulx $acc0, $t0, $t1 + mulx $acc1, %rax, %rdx + imulq $acc2, $t2 + add %rax, $t1 + adc %rdx, $t2 +___ +} + +sub poly_stage2_mulx { +$code.=<<___; + mov 8+$r_store, %rdx + mulx $acc0, $acc0, %rax + add $acc0, $t1 + mulx $acc1, $acc1, $t3 + adc $acc1, $t2 + adc \$0, $t3 + imulq $acc2, %rdx +___ +} + +sub poly_stage3_mulx { +$code.=<<___; + add %rax, $t2 + adc %rdx, $t3 +___ +} + +sub poly_mul_mulx { + &poly_stage1_mulx(); + &poly_stage2_mulx(); + &poly_stage3_mulx(); + &poly_reduce_stage(); +} + +sub gen_chacha_round_avx2 { +my ($rot1, $rot2, $shift)=@_; +my $round=""; +$round=$round ."vmovdqa $C0, $tmp_store\n" if ($rot1 eq 20); +$round=$round ."vmovdqa $rot2, $C0 + vpaddd $B3, $A3, $A3 + vpaddd $B2, $A2, $A2 + vpaddd $B1, $A1, $A1 + vpaddd $B0, $A0, $A0 + vpxor $A3, $D3, $D3 + vpxor $A2, $D2, $D2 + vpxor $A1, $D1, $D1 + vpxor $A0, $D0, $D0 + vpshufb $C0, $D3, $D3 + vpshufb $C0, $D2, $D2 + vpshufb $C0, $D1, $D1 + vpshufb $C0, $D0, $D0 + vpaddd $D3, $C3, $C3 + vpaddd $D2, $C2, $C2 + vpaddd $D1, $C1, $C1 + vpaddd $tmp_store, $D0, $C0 + vpxor $C3, $B3, $B3 + vpxor $C2, $B2, $B2 + vpxor $C1, $B1, $B1 + vpxor $C0, $B0, $B0 + vmovdqa $C0, $tmp_store + vpsrld \$$rot1, $B3, $C0 + vpslld \$32-$rot1, $B3, $B3 + vpxor $C0, $B3, $B3 + vpsrld \$$rot1, $B2, $C0 + vpslld \$32-$rot1, $B2, $B2 + vpxor $C0, $B2, $B2 + vpsrld \$$rot1, $B1, $C0 + vpslld \$32-$rot1, $B1, $B1 + vpxor $C0, $B1, $B1 + vpsrld \$$rot1, $B0, $C0 + vpslld \$32-$rot1, $B0, $B0 + vpxor $C0, $B0, $B0\n"; +($s1,$s2,$s3)=(4,8,12) if ($shift =~ /left/); +($s1,$s2,$s3)=(12,8,4) if ($shift =~ /right/); +$round=$round ."vmovdqa $tmp_store, $C0 + vpalignr \$$s1, $B3, $B3, $B3 + vpalignr \$$s2, $C3, $C3, $C3 + vpalignr \$$s3, $D3, $D3, $D3 + vpalignr \$$s1, $B2, $B2, $B2 + vpalignr \$$s2, $C2, $C2, $C2 + vpalignr \$$s3, $D2, $D2, $D2 + vpalignr \$$s1, $B1, $B1, $B1 + vpalignr \$$s2, $C1, $C1, $C1 + vpalignr \$$s3, $D1, $D1, $D1 + vpalignr \$$s1, $B0, $B0, $B0 + vpalignr \$$s2, $C0, $C0, $C0 + vpalignr \$$s3, $D0, $D0, $D0\n" +if (($shift =~ /left/) || ($shift =~ /right/)); +return $round; +}; + +$chacha_body = &gen_chacha_round_avx2(20, ".Lrol16(%rip)") . + &gen_chacha_round_avx2(25, ".Lrol8(%rip)", "left") . + &gen_chacha_round_avx2(20, ".Lrol16(%rip)") . + &gen_chacha_round_avx2(25, ".Lrol8(%rip)", "right"); + +@loop_body = split /\n/, $chacha_body; + +$code.=" +############################################################################### +.globl chacha20_poly1305_open_avx2 +.type chacha20_poly1305_open_avx2,\@function,6 +.align 64 +chacha20_poly1305_open_avx2: +.cfi_startproc + _CET_ENDBR + push %rbp +.cfi_push %rbp + push %rbx +.cfi_push %rbx + push %r12 +.cfi_push %r12 + push %r13 +.cfi_push %r13 + push %r14 +.cfi_push %r14 + push %r15 +.cfi_push %r15 + # We write the calculated authenticator back to keyp at the end, so save + # the pointer on the stack too. + push $keyp +.cfi_push $keyp + sub \$288 + $xmm_storage + 32, %rsp +.cfi_adjust_cfa_offset 288 + 32 + + lea 32(%rsp), %rbp + and \$-32, %rbp\n"; +$code.=" + movaps %xmm6,16*0+$xmm_store + movaps %xmm7,16*1+$xmm_store + movaps %xmm8,16*2+$xmm_store + movaps %xmm9,16*3+$xmm_store + movaps %xmm10,16*4+$xmm_store + movaps %xmm11,16*5+$xmm_store + movaps %xmm12,16*6+$xmm_store + movaps %xmm13,16*7+$xmm_store + movaps %xmm14,16*8+$xmm_store + movaps %xmm15,16*9+$xmm_store\n" if ($win64); +$code.=" + mov %rdx, $inl + mov $adl, 0+$len_store + mov $inl, 8+$len_store + + vzeroupper + vmovdqa .Lchacha20_consts(%rip), $A0 + vbroadcasti128 0*16($keyp), $B0 + vbroadcasti128 1*16($keyp), $C0 + vbroadcasti128 2*16($keyp), $D0 + vpaddd .Lavx2_init(%rip), $D0, $D0 + cmp \$6*32, $inl + jbe .Lopen_avx2_192 + cmp \$10*32, $inl + jbe .Lopen_avx2_320 + + vmovdqa $B0, $state1_store + vmovdqa $C0, $state2_store + vmovdqa $D0, $ctr0_store + mov \$10, $acc0 +.Lopen_avx2_init_rounds: \n"; + &chacha_qr_avx2($A0,$B0,$C0,$D0,$T0,"left"); + &chacha_qr_avx2($A0,$B0,$C0,$D0,$T0,"right"); $code.=" + dec $acc0 + jne .Lopen_avx2_init_rounds + vpaddd .Lchacha20_consts(%rip), $A0, $A0 + vpaddd $state1_store, $B0, $B0 + vpaddd $state2_store, $C0, $C0 + vpaddd $ctr0_store, $D0, $D0 + + vperm2i128 \$0x02, $A0, $B0, $T0 + # Clamp and store key + vpand .Lclamp(%rip), $T0, $T0 + vmovdqa $T0, $r_store + # Stream for the first 64 bytes + vperm2i128 \$0x13, $A0, $B0, $A0 + vperm2i128 \$0x13, $C0, $D0, $B0 + # Hash AD + first 64 bytes + mov $adl, $itr2 + call poly_hash_ad_internal + # Hash first 64 bytes + xor $itr1, $itr1 +.Lopen_avx2_init_hash: \n"; + &poly_add("0($inp,$itr1)"); + &poly_mul(); $code.=" + add \$16, $itr1 + cmp \$2*32, $itr1 + jne .Lopen_avx2_init_hash + # Decrypt first 64 bytes + vpxor 0*32($inp), $A0, $A0 + vpxor 1*32($inp), $B0, $B0 + # Store first 64 bytes of decrypted data + vmovdqu $A0, 0*32($oup) + vmovdqu $B0, 1*32($oup) + lea 2*32($inp), $inp + lea 2*32($oup), $oup + sub \$2*32, $inl +.Lopen_avx2_main_loop: + # Hash and decrypt 512 bytes each iteration + cmp \$16*32, $inl + jb .Lopen_avx2_main_loop_done\n"; + &prep_state_avx2(4); $code.=" + xor $itr1, $itr1 +.Lopen_avx2_main_loop_rounds: \n"; + &poly_add("0*8($inp,$itr1)"); + &emit_body(10); + &poly_stage1_mulx(); + &emit_body(9); + &poly_stage2_mulx(); + &emit_body(12); + &poly_stage3_mulx(); + &emit_body(10); + &poly_reduce_stage(); + &emit_body(9); + &poly_add("2*8($inp,$itr1)"); + &emit_body(8); + &poly_stage1_mulx(); + &emit_body(18); + &poly_stage2_mulx(); + &emit_body(18); + &poly_stage3_mulx(); + &emit_body(9); + &poly_reduce_stage(); + &emit_body(8); + &poly_add("4*8($inp,$itr1)"); $code.=" + lea 6*8($itr1), $itr1\n"; + &emit_body(18); + &poly_stage1_mulx(); + &emit_body(8); + &poly_stage2_mulx(); + &emit_body(8); + &poly_stage3_mulx(); + &emit_body(18); + &poly_reduce_stage(); + foreach $l (@loop_body) {$code.=$l."\n";} + @loop_body = split /\n/, $chacha_body; $code.=" + cmp \$10*6*8, $itr1 + jne .Lopen_avx2_main_loop_rounds\n"; + &finalize_state_avx2(4); $code.=" + vmovdqa $A0, $tmp_store\n"; + &poly_add("10*6*8($inp)"); + &xor_stream_avx2($A3, $B3, $C3, $D3, 0*32, $A0); $code.=" + vmovdqa $tmp_store, $A0\n"; + &poly_mul(); + &xor_stream_avx2($A2, $B2, $C2, $D2, 4*32, $A3); + &poly_add("10*6*8+2*8($inp)"); + &xor_stream_avx2($A1, $B1, $C1, $D1, 8*32, $A3); + &poly_mul(); + &xor_stream_avx2($A0, $B0, $C0, $D0, 12*32, $A3); $code.=" + lea 16*32($inp), $inp + lea 16*32($oup), $oup + sub \$16*32, $inl + jmp .Lopen_avx2_main_loop +.Lopen_avx2_main_loop_done: + test $inl, $inl + vzeroupper + je .Lopen_sse_finalize + + cmp \$12*32, $inl + ja .Lopen_avx2_tail_512 + cmp \$8*32, $inl + ja .Lopen_avx2_tail_384 + cmp \$4*32, $inl + ja .Lopen_avx2_tail_256\n"; +############################################################################### + # 1-128 bytes left + &prep_state_avx2(1); $code.=" + xor $itr2, $itr2 + mov $inl, $itr1 + and \$-16, $itr1 + test $itr1, $itr1 + je .Lopen_avx2_tail_128_rounds # Have nothing to hash +.Lopen_avx2_tail_128_rounds_and_x1hash: \n"; + &poly_add("0*8($inp,$itr2)"); + &poly_mul(); $code.=" +.Lopen_avx2_tail_128_rounds: + add \$16, $itr2\n"; + &chacha_qr_avx2($A0,$B0,$C0,$D0,$T0,"left"); + &chacha_qr_avx2($A0,$B0,$C0,$D0,$T0,"right"); $code.=" + cmp $itr1, $itr2 + jb .Lopen_avx2_tail_128_rounds_and_x1hash + cmp \$160, $itr2 + jne .Lopen_avx2_tail_128_rounds\n"; + &finalize_state_avx2(1); + &finish_stream_avx2($A0,$B0,$C0,$D0,$T0); $code.=" + jmp .Lopen_avx2_tail_128_xor +############################################################################### +.Lopen_avx2_tail_256: \n"; + # 129-256 bytes left + &prep_state_avx2(2); $code.=" + mov $inl, $tmp_store + mov $inl, $itr1 + sub \$4*32, $itr1 + shr \$4, $itr1 + mov \$10, $itr2 + cmp \$10, $itr1 + cmovg $itr2, $itr1 + mov $inp, $inl + xor $itr2, $itr2 +.Lopen_avx2_tail_256_rounds_and_x1hash: \n"; + &poly_add("0*8($inl)"); + &poly_mul_mulx(); $code.=" + lea 16($inl), $inl +.Lopen_avx2_tail_256_rounds: \n"; + &chacha_qr_avx2($A0,$B0,$C0,$D0,$T0,"left"); + &chacha_qr_avx2($A1,$B1,$C1,$D1,$T0,"left"); $code.=" + inc $itr2\n"; + &chacha_qr_avx2($A0,$B0,$C0,$D0,$T0,"right"); + &chacha_qr_avx2($A1,$B1,$C1,$D1,$T0,"right"); + &chacha_qr_avx2($A2,$B2,$C2,$D2,$T0,"right"); $code.=" + cmp $itr1, $itr2 + jb .Lopen_avx2_tail_256_rounds_and_x1hash + cmp \$10, $itr2 + jne .Lopen_avx2_tail_256_rounds + mov $inl, $itr2 + sub $inp, $inl + mov $inl, $itr1 + mov $tmp_store, $inl +.Lopen_avx2_tail_256_hash: + add \$16, $itr1 + cmp $inl, $itr1 + jg .Lopen_avx2_tail_256_done\n"; + &poly_add("0*8($itr2)"); + &poly_mul_mulx(); $code.=" + lea 16($itr2), $itr2 + jmp .Lopen_avx2_tail_256_hash +.Lopen_avx2_tail_256_done: \n"; + &finalize_state_avx2(2); + &xor_stream_avx2($A1, $B1, $C1, $D1, 0*32, $T0); + &finish_stream_avx2($A0, $B0, $C0, $D0, $T0); $code.=" + lea 4*32($inp), $inp + lea 4*32($oup), $oup + sub \$4*32, $inl + jmp .Lopen_avx2_tail_128_xor +############################################################################### +.Lopen_avx2_tail_384: \n"; + # 257-383 bytes left + &prep_state_avx2(3); $code.=" + mov $inl, $tmp_store + mov $inl, $itr1 + sub \$8*32, $itr1 + shr \$4, $itr1 + add \$6, $itr1 + mov \$10, $itr2 + cmp \$10, $itr1 + cmovg $itr2, $itr1 + mov $inp, $inl + xor $itr2, $itr2 +.Lopen_avx2_tail_384_rounds_and_x2hash: \n"; + &poly_add("0*8($inl)"); + &poly_mul_mulx(); $code.=" + lea 16($inl), $inl +.Lopen_avx2_tail_384_rounds_and_x1hash: \n"; + &chacha_qr_avx2($A2,$B2,$C2,$D2,$T0,"left"); + &chacha_qr_avx2($A1,$B1,$C1,$D1,$T0,"left"); + &chacha_qr_avx2($A0,$B0,$C0,$D0,$T0,"left"); + &poly_add("0*8($inl)"); + &poly_mul(); $code.=" + lea 16($inl), $inl + inc $itr2\n"; + &chacha_qr_avx2($A2,$B2,$C2,$D2,$T0,"right"); + &chacha_qr_avx2($A1,$B1,$C1,$D1,$T0,"right"); + &chacha_qr_avx2($A0,$B0,$C0,$D0,$T0,"right"); $code.=" + cmp $itr1, $itr2 + jb .Lopen_avx2_tail_384_rounds_and_x2hash + cmp \$10, $itr2 + jne .Lopen_avx2_tail_384_rounds_and_x1hash + mov $inl, $itr2 + sub $inp, $inl + mov $inl, $itr1 + mov $tmp_store, $inl +.Lopen_avx2_384_tail_hash: + add \$16, $itr1 + cmp $inl, $itr1 + jg .Lopen_avx2_384_tail_done\n"; + &poly_add("0*8($itr2)"); + &poly_mul_mulx(); $code.=" + lea 16($itr2), $itr2 + jmp .Lopen_avx2_384_tail_hash +.Lopen_avx2_384_tail_done: \n"; + &finalize_state_avx2(3); + &xor_stream_avx2($A2, $B2, $C2, $D2, 0*32, $T0); + &xor_stream_avx2($A1, $B1, $C1, $D1, 4*32, $T0); + &finish_stream_avx2($A0, $B0, $C0, $D0, $T0); $code.=" + lea 8*32($inp), $inp + lea 8*32($oup), $oup + sub \$8*32, $inl + jmp .Lopen_avx2_tail_128_xor +############################################################################### +.Lopen_avx2_tail_512: \n"; + # 384-512 bytes left + &prep_state_avx2(4); $code.=" + xor $itr1, $itr1 + mov $inp, $itr2 +.Lopen_avx2_tail_512_rounds_and_x2hash: \n"; + &poly_add("0*8($itr2)"); + &poly_mul(); $code.=" + lea 2*8($itr2), $itr2 +.Lopen_avx2_tail_512_rounds_and_x1hash: \n"; + &emit_body(37); + &poly_add("0*8($itr2)"); + &poly_mul_mulx(); + &emit_body(48); + &poly_add("2*8($itr2)"); + &poly_mul_mulx(); $code.=" + lea 4*8($itr2), $itr2\n"; + foreach $l (@loop_body) {$code.=$l."\n";} + @loop_body = split /\n/, $chacha_body; $code.=" + inc $itr1 + cmp \$4, $itr1 + jl .Lopen_avx2_tail_512_rounds_and_x2hash + cmp \$10, $itr1 + jne .Lopen_avx2_tail_512_rounds_and_x1hash + mov $inl, $itr1 + sub \$12*32, $itr1 + and \$-16, $itr1 +.Lopen_avx2_tail_512_hash: + test $itr1, $itr1 + je .Lopen_avx2_tail_512_done\n"; + &poly_add("0*8($itr2)"); + &poly_mul_mulx(); $code.=" + lea 2*8($itr2), $itr2 + sub \$2*8, $itr1 + jmp .Lopen_avx2_tail_512_hash +.Lopen_avx2_tail_512_done: \n"; + &finalize_state_avx2(4); $code.=" + vmovdqa $A0, $tmp_store\n"; + &xor_stream_avx2($A3, $B3, $C3, $D3, 0*32, $A0); $code.=" + vmovdqa $tmp_store, $A0\n"; + &xor_stream_avx2($A2, $B2, $C2, $D2, 4*32, $A3); + &xor_stream_avx2($A1, $B1, $C1, $D1, 8*32, $A3); + &finish_stream_avx2($A0, $B0, $C0, $D0, $A3); $code.=" + lea 12*32($inp), $inp + lea 12*32($oup), $oup + sub \$12*32, $inl +.Lopen_avx2_tail_128_xor: + cmp \$32, $inl + jb .Lopen_avx2_tail_32_xor + sub \$32, $inl + vpxor ($inp), $A0, $A0 + vmovdqu $A0, ($oup) + lea 1*32($inp), $inp + lea 1*32($oup), $oup + vmovdqa $B0, $A0 + vmovdqa $C0, $B0 + vmovdqa $D0, $C0 + jmp .Lopen_avx2_tail_128_xor +.Lopen_avx2_tail_32_xor: + cmp \$16, $inl + vmovdqa $A0x, $A1x + jb .Lopen_avx2_exit + sub \$16, $inl + #load for decryption + vpxor ($inp), $A0x, $A1x + vmovdqu $A1x, ($oup) + lea 1*16($inp), $inp + lea 1*16($oup), $oup + vperm2i128 \$0x11, $A0, $A0, $A0 + vmovdqa $A0x, $A1x +.Lopen_avx2_exit: + vzeroupper + jmp .Lopen_sse_tail_16 +############################################################################### +.Lopen_avx2_192: + vmovdqa $A0, $A1 + vmovdqa $A0, $A2 + vmovdqa $B0, $B1 + vmovdqa $B0, $B2 + vmovdqa $C0, $C1 + vmovdqa $C0, $C2 + vpaddd .Lavx2_inc(%rip), $D0, $D1 + vmovdqa $D0, $T2 + vmovdqa $D1, $T3 + mov \$10, $acc0 +.Lopen_avx2_192_rounds: \n"; + &chacha_qr_avx2($A0,$B0,$C0,$D0,$T0,"left"); + &chacha_qr_avx2($A1,$B1,$C1,$D1,$T0,"left"); + &chacha_qr_avx2($A0,$B0,$C0,$D0,$T0,"right"); + &chacha_qr_avx2($A1,$B1,$C1,$D1,$T0,"right"); $code.=" + dec $acc0 + jne .Lopen_avx2_192_rounds + vpaddd $A2, $A0, $A0 + vpaddd $A2, $A1, $A1 + vpaddd $B2, $B0, $B0 + vpaddd $B2, $B1, $B1 + vpaddd $C2, $C0, $C0 + vpaddd $C2, $C1, $C1 + vpaddd $T2, $D0, $D0 + vpaddd $T3, $D1, $D1 + vperm2i128 \$0x02, $A0, $B0, $T0 + # Clamp and store the key + vpand .Lclamp(%rip), $T0, $T0 + vmovdqa $T0, $r_store + # Stream for up to 192 bytes + vperm2i128 \$0x13, $A0, $B0, $A0 + vperm2i128 \$0x13, $C0, $D0, $B0 + vperm2i128 \$0x02, $A1, $B1, $C0 + vperm2i128 \$0x02, $C1, $D1, $D0 + vperm2i128 \$0x13, $A1, $B1, $A1 + vperm2i128 \$0x13, $C1, $D1, $B1 +.Lopen_avx2_short: + mov $adl, $itr2 + call poly_hash_ad_internal +.Lopen_avx2_short_hash_and_xor_loop: + cmp \$32, $inl + jb .Lopen_avx2_short_tail_32 + sub \$32, $inl\n"; + # Load + hash + &poly_add("0*8($inp)"); + &poly_mul(); + &poly_add("2*8($inp)"); + &poly_mul(); $code.=" + # Load + decrypt + vpxor ($inp), $A0, $A0 + vmovdqu $A0, ($oup) + lea 1*32($inp), $inp + lea 1*32($oup), $oup + # Shift stream + vmovdqa $B0, $A0 + vmovdqa $C0, $B0 + vmovdqa $D0, $C0 + vmovdqa $A1, $D0 + vmovdqa $B1, $A1 + vmovdqa $C1, $B1 + vmovdqa $D1, $C1 + vmovdqa $A2, $D1 + vmovdqa $B2, $A2 + jmp .Lopen_avx2_short_hash_and_xor_loop +.Lopen_avx2_short_tail_32: + cmp \$16, $inl + vmovdqa $A0x, $A1x + jb .Lopen_avx2_short_tail_32_exit + sub \$16, $inl\n"; + &poly_add("0*8($inp)"); + &poly_mul(); $code.=" + vpxor ($inp), $A0x, $A3x + vmovdqu $A3x, ($oup) + lea 1*16($inp), $inp + lea 1*16($oup), $oup + vextracti128 \$1, $A0, $A1x +.Lopen_avx2_short_tail_32_exit: + vzeroupper + jmp .Lopen_sse_tail_16 +############################################################################### +.Lopen_avx2_320: + vmovdqa $A0, $A1 + vmovdqa $A0, $A2 + vmovdqa $B0, $B1 + vmovdqa $B0, $B2 + vmovdqa $C0, $C1 + vmovdqa $C0, $C2 + vpaddd .Lavx2_inc(%rip), $D0, $D1 + vpaddd .Lavx2_inc(%rip), $D1, $D2 + vmovdqa $B0, $T1 + vmovdqa $C0, $T2 + vmovdqa $D0, $ctr0_store + vmovdqa $D1, $ctr1_store + vmovdqa $D2, $ctr2_store + mov \$10, $acc0 +.Lopen_avx2_320_rounds: \n"; + &chacha_qr_avx2($A0,$B0,$C0,$D0,$T0,"left"); + &chacha_qr_avx2($A1,$B1,$C1,$D1,$T0,"left"); + &chacha_qr_avx2($A2,$B2,$C2,$D2,$T0,"left"); + &chacha_qr_avx2($A0,$B0,$C0,$D0,$T0,"right"); + &chacha_qr_avx2($A1,$B1,$C1,$D1,$T0,"right"); + &chacha_qr_avx2($A2,$B2,$C2,$D2,$T0,"right"); $code.=" + dec $acc0 + jne .Lopen_avx2_320_rounds + vpaddd .Lchacha20_consts(%rip), $A0, $A0 + vpaddd .Lchacha20_consts(%rip), $A1, $A1 + vpaddd .Lchacha20_consts(%rip), $A2, $A2 + vpaddd $T1, $B0, $B0 + vpaddd $T1, $B1, $B1 + vpaddd $T1, $B2, $B2 + vpaddd $T2, $C0, $C0 + vpaddd $T2, $C1, $C1 + vpaddd $T2, $C2, $C2 + vpaddd $ctr0_store, $D0, $D0 + vpaddd $ctr1_store, $D1, $D1 + vpaddd $ctr2_store, $D2, $D2 + vperm2i128 \$0x02, $A0, $B0, $T0 + # Clamp and store the key + vpand .Lclamp(%rip), $T0, $T0 + vmovdqa $T0, $r_store + # Stream for up to 320 bytes + vperm2i128 \$0x13, $A0, $B0, $A0 + vperm2i128 \$0x13, $C0, $D0, $B0 + vperm2i128 \$0x02, $A1, $B1, $C0 + vperm2i128 \$0x02, $C1, $D1, $D0 + vperm2i128 \$0x13, $A1, $B1, $A1 + vperm2i128 \$0x13, $C1, $D1, $B1 + vperm2i128 \$0x02, $A2, $B2, $C1 + vperm2i128 \$0x02, $C2, $D2, $D1 + vperm2i128 \$0x13, $A2, $B2, $A2 + vperm2i128 \$0x13, $C2, $D2, $B2 + jmp .Lopen_avx2_short +.size chacha20_poly1305_open_avx2, .-chacha20_poly1305_open_avx2 +.cfi_endproc +############################################################################### +############################################################################### +.globl chacha20_poly1305_seal_avx2 +.type chacha20_poly1305_seal_avx2,\@function,6 +.align 64 +chacha20_poly1305_seal_avx2: +.cfi_startproc + _CET_ENDBR + push %rbp +.cfi_push %rbp + push %rbx +.cfi_push %rbx + push %r12 +.cfi_push %r12 + push %r13 +.cfi_push %r13 + push %r14 +.cfi_push %r14 + push %r15 +.cfi_push %r15 +# We write the calculated authenticator back to keyp at the end, so save +# the pointer on the stack too. + push $keyp +.cfi_push $keyp + sub \$288 + $xmm_storage + 32, %rsp +.cfi_adjust_cfa_offset 288 + 32 + lea 32(%rsp), %rbp + and \$-32, %rbp\n"; +$code.=" + movaps %xmm6,16*0+$xmm_store + movaps %xmm7,16*1+$xmm_store + movaps %xmm8,16*2+$xmm_store + movaps %xmm9,16*3+$xmm_store + movaps %xmm10,16*4+$xmm_store + movaps %xmm11,16*5+$xmm_store + movaps %xmm12,16*6+$xmm_store + movaps %xmm13,16*7+$xmm_store + movaps %xmm14,16*8+$xmm_store + movaps %xmm15,16*9+$xmm_store\n" if ($win64); +$code.=" + mov 56($keyp), $inl # extra_in_len + addq %rdx, $inl + mov $adl, 0+$len_store + mov $inl, 8+$len_store + mov %rdx, $inl + + vzeroupper + vmovdqa .Lchacha20_consts(%rip), $A0 + vbroadcasti128 0*16($keyp), $B0 + vbroadcasti128 1*16($keyp), $C0 + vbroadcasti128 2*16($keyp), $D0 + vpaddd .Lavx2_init(%rip), $D0, $D0 + cmp \$6*32, $inl + jbe .Lseal_avx2_192 + cmp \$10*32, $inl + jbe .Lseal_avx2_320 + vmovdqa $A0, $A1 + vmovdqa $A0, $A2 + vmovdqa $A0, $A3 + vmovdqa $B0, $B1 + vmovdqa $B0, $B2 + vmovdqa $B0, $B3 + vmovdqa $B0, $state1_store + vmovdqa $C0, $C1 + vmovdqa $C0, $C2 + vmovdqa $C0, $C3 + vmovdqa $C0, $state2_store + vmovdqa $D0, $D3 + vpaddd .Lavx2_inc(%rip), $D3, $D2 + vpaddd .Lavx2_inc(%rip), $D2, $D1 + vpaddd .Lavx2_inc(%rip), $D1, $D0 + vmovdqa $D0, $ctr0_store + vmovdqa $D1, $ctr1_store + vmovdqa $D2, $ctr2_store + vmovdqa $D3, $ctr3_store + mov \$10, $acc0 +.Lseal_avx2_init_rounds: \n"; + foreach $l (@loop_body) {$code.=$l."\n";} + @loop_body = split /\n/, $chacha_body; $code.=" + dec $acc0 + jnz .Lseal_avx2_init_rounds\n"; + &finalize_state_avx2(4); $code.=" + vperm2i128 \$0x13, $C3, $D3, $C3 + vperm2i128 \$0x02, $A3, $B3, $D3 + vperm2i128 \$0x13, $A3, $B3, $A3 + vpand .Lclamp(%rip), $D3, $D3 + vmovdqa $D3, $r_store + mov $adl, $itr2 + call poly_hash_ad_internal + # Safely store 320 bytes (otherwise would handle with optimized call) + vpxor 0*32($inp), $A3, $A3 + vpxor 1*32($inp), $C3, $C3 + vmovdqu $A3, 0*32($oup) + vmovdqu $C3, 1*32($oup)\n"; + &xor_stream_avx2($A2,$B2,$C2,$D2,2*32,$T3); + &xor_stream_avx2($A1,$B1,$C1,$D1,6*32,$T3); + &finish_stream_avx2($A0,$B0,$C0,$D0,$T3); $code.=" + lea 10*32($inp), $inp + sub \$10*32, $inl + mov \$10*32, $itr1 + cmp \$4*32, $inl + jbe .Lseal_avx2_short_hash_remainder + vpxor 0*32($inp), $A0, $A0 + vpxor 1*32($inp), $B0, $B0 + vpxor 2*32($inp), $C0, $C0 + vpxor 3*32($inp), $D0, $D0 + vmovdqu $A0, 10*32($oup) + vmovdqu $B0, 11*32($oup) + vmovdqu $C0, 12*32($oup) + vmovdqu $D0, 13*32($oup) + lea 4*32($inp), $inp + sub \$4*32, $inl + mov \$8, $itr1 + mov \$2, $itr2 + cmp \$4*32, $inl + jbe .Lseal_avx2_tail_128 + cmp \$8*32, $inl + jbe .Lseal_avx2_tail_256 + cmp \$12*32, $inl + jbe .Lseal_avx2_tail_384 + cmp \$16*32, $inl + jbe .Lseal_avx2_tail_512\n"; + # We have 448 bytes to hash, but main loop hashes 512 bytes at a time - perform some rounds, before the main loop + &prep_state_avx2(4); + foreach $l (@loop_body) {$code.=$l."\n";} + @loop_body = split /\n/, $chacha_body; + &emit_body(41); + @loop_body = split /\n/, $chacha_body; $code.=" + sub \$16, $oup + mov \$9, $itr1 + jmp .Lseal_avx2_main_loop_rounds_entry +.align 32 +.Lseal_avx2_main_loop: \n"; + &prep_state_avx2(4); $code.=" + mov \$10, $itr1 +.align 32 +.Lseal_avx2_main_loop_rounds: \n"; + &poly_add("0*8($oup)"); + &emit_body(10); + &poly_stage1_mulx(); + &emit_body(9); + &poly_stage2_mulx(); + &emit_body(12); + &poly_stage3_mulx(); + &emit_body(10); + &poly_reduce_stage(); $code.=" +.Lseal_avx2_main_loop_rounds_entry: \n"; + &emit_body(9); + &poly_add("2*8($oup)"); + &emit_body(8); + &poly_stage1_mulx(); + &emit_body(18); + &poly_stage2_mulx(); + &emit_body(18); + &poly_stage3_mulx(); + &emit_body(9); + &poly_reduce_stage(); + &emit_body(8); + &poly_add("4*8($oup)"); $code.=" + lea 6*8($oup), $oup\n"; + &emit_body(18); + &poly_stage1_mulx(); + &emit_body(8); + &poly_stage2_mulx(); + &emit_body(8); + &poly_stage3_mulx(); + &emit_body(18); + &poly_reduce_stage(); + foreach $l (@loop_body) {$code.=$l."\n";} + @loop_body = split /\n/, $chacha_body; $code.=" + dec $itr1 + jne .Lseal_avx2_main_loop_rounds\n"; + &finalize_state_avx2(4); $code.=" + vmovdqa $A0, $tmp_store\n"; + &poly_add("0*8($oup)"); + &poly_mul_mulx(); + &poly_add("2*8($oup)"); + &poly_mul_mulx(); $code.=" + lea 4*8($oup), $oup\n"; + &xor_stream_avx2($A3, $B3, $C3, $D3, 0*32, $A0); $code.=" + vmovdqa $tmp_store, $A0\n"; + &xor_stream_avx2($A2, $B2, $C2, $D2, 4*32, $A3); + &xor_stream_avx2($A1, $B1, $C1, $D1, 8*32, $A3); + &xor_stream_avx2($A0, $B0, $C0, $D0, 12*32, $A3); $code.=" + lea 16*32($inp), $inp + sub \$16*32, $inl + cmp \$16*32, $inl + jg .Lseal_avx2_main_loop +\n"; + &poly_add("0*8($oup)"); + &poly_mul_mulx(); + &poly_add("2*8($oup)"); + &poly_mul_mulx(); $code.=" + lea 4*8($oup), $oup + mov \$10, $itr1 + xor $itr2, $itr2 + + cmp \$12*32, $inl + ja .Lseal_avx2_tail_512 + cmp \$8*32, $inl + ja .Lseal_avx2_tail_384 + cmp \$4*32, $inl + ja .Lseal_avx2_tail_256 +############################################################################### +.Lseal_avx2_tail_128:\n"; + &prep_state_avx2(1); $code.=" +.Lseal_avx2_tail_128_rounds_and_3xhash: \n"; + &poly_add("0($oup)"); + &poly_mul_mulx(); $code.=" + lea 2*8($oup), $oup +.Lseal_avx2_tail_128_rounds_and_2xhash: \n"; + &chacha_qr_avx2($A0,$B0,$C0,$D0,$T0,"left"); + &poly_add("0*8($oup)"); + &poly_mul_mulx(); + &chacha_qr_avx2($A0,$B0,$C0,$D0,$T0,"right"); + &poly_add("2*8($oup)"); + &poly_mul_mulx(); $code.=" + lea 4*8($oup), $oup + dec $itr1 + jg .Lseal_avx2_tail_128_rounds_and_3xhash + dec $itr2 + jge .Lseal_avx2_tail_128_rounds_and_2xhash\n"; + &finalize_state_avx2(1); + &finish_stream_avx2($A0,$B0,$C0,$D0,$T0); $code.=" + jmp .Lseal_avx2_short_loop +############################################################################### +.Lseal_avx2_tail_256:\n"; + &prep_state_avx2(2); $code.=" +.Lseal_avx2_tail_256_rounds_and_3xhash: \n"; + &poly_add("0($oup)"); + &poly_mul(); $code.=" + lea 2*8($oup), $oup +.Lseal_avx2_tail_256_rounds_and_2xhash: \n"; + &chacha_qr_avx2($A0,$B0,$C0,$D0,$T0,"left"); + &chacha_qr_avx2($A1,$B1,$C1,$D1,$T0,"left"); + &poly_add("0*8($oup)"); + &poly_mul(); + &chacha_qr_avx2($A0,$B0,$C0,$D0,$T0,"right"); + &chacha_qr_avx2($A1,$B1,$C1,$D1,$T0,"right"); + &poly_add("2*8($oup)"); + &poly_mul(); $code.=" + lea 4*8($oup), $oup + dec $itr1 + jg .Lseal_avx2_tail_256_rounds_and_3xhash + dec $itr2 + jge .Lseal_avx2_tail_256_rounds_and_2xhash\n"; + &finalize_state_avx2(2); + &xor_stream_avx2($A1,$B1,$C1,$D1,0*32,$T0); + &finish_stream_avx2($A0,$B0,$C0,$D0,$T0); $code.=" + mov \$4*32, $itr1 + lea 4*32($inp), $inp + sub \$4*32, $inl + jmp .Lseal_avx2_short_hash_remainder +############################################################################### +.Lseal_avx2_tail_384:\n"; + &prep_state_avx2(3); $code.=" +.Lseal_avx2_tail_384_rounds_and_3xhash: \n"; + &poly_add("0($oup)"); + &poly_mul(); $code.=" + lea 2*8($oup), $oup +.Lseal_avx2_tail_384_rounds_and_2xhash: \n"; + &chacha_qr_avx2($A0,$B0,$C0,$D0,$T0,"left"); + &chacha_qr_avx2($A1,$B1,$C1,$D1,$T0,"left"); + &poly_add("0*8($oup)"); + &poly_mul(); + &chacha_qr_avx2($A2,$B2,$C2,$D2,$T0,"left"); + &chacha_qr_avx2($A0,$B0,$C0,$D0,$T0,"right"); + &poly_add("2*8($oup)"); + &poly_mul(); + &chacha_qr_avx2($A1,$B1,$C1,$D1,$T0,"right"); + &chacha_qr_avx2($A2,$B2,$C2,$D2,$T0,"right"); $code.=" + lea 4*8($oup), $oup + dec $itr1 + jg .Lseal_avx2_tail_384_rounds_and_3xhash + dec $itr2 + jge .Lseal_avx2_tail_384_rounds_and_2xhash\n"; + &finalize_state_avx2(3); + &xor_stream_avx2($A2,$B2,$C2,$D2,0*32,$T0); + &xor_stream_avx2($A1,$B1,$C1,$D1,4*32,$T0); + &finish_stream_avx2($A0,$B0,$C0,$D0,$T0); $code.=" + mov \$8*32, $itr1 + lea 8*32($inp), $inp + sub \$8*32, $inl + jmp .Lseal_avx2_short_hash_remainder +############################################################################### +.Lseal_avx2_tail_512:\n"; + &prep_state_avx2(4); $code.=" +.Lseal_avx2_tail_512_rounds_and_3xhash: \n"; + &poly_add("0($oup)"); + &poly_mul_mulx(); $code.=" + lea 2*8($oup), $oup +.Lseal_avx2_tail_512_rounds_and_2xhash: \n"; + &emit_body(20); + &poly_add("0*8($oup)"); + &emit_body(20); + &poly_stage1_mulx(); + &emit_body(20); + &poly_stage2_mulx(); + &emit_body(20); + &poly_stage3_mulx(); + &emit_body(20); + &poly_reduce_stage(); + &emit_body(20); + &poly_add("2*8($oup)"); + &emit_body(20); + &poly_stage1_mulx(); + &emit_body(20); + &poly_stage2_mulx(); + &emit_body(20); + &poly_stage3_mulx(); + &emit_body(20); + &poly_reduce_stage(); + foreach $l (@loop_body) {$code.=$l."\n";} + @loop_body = split /\n/, $chacha_body; $code.=" + lea 4*8($oup), $oup + dec $itr1 + jg .Lseal_avx2_tail_512_rounds_and_3xhash + dec $itr2 + jge .Lseal_avx2_tail_512_rounds_and_2xhash\n"; + &finalize_state_avx2(4); $code.=" + vmovdqa $A0, $tmp_store\n"; + &xor_stream_avx2($A3, $B3, $C3, $D3, 0*32, $A0); $code.=" + vmovdqa $tmp_store, $A0\n"; + &xor_stream_avx2($A2, $B2, $C2, $D2, 4*32, $A3); + &xor_stream_avx2($A1, $B1, $C1, $D1, 8*32, $A3); + &finish_stream_avx2($A0,$B0,$C0,$D0,$T0); $code.=" + mov \$12*32, $itr1 + lea 12*32($inp), $inp + sub \$12*32, $inl + jmp .Lseal_avx2_short_hash_remainder +################################################################################ +.Lseal_avx2_320: + vmovdqa $A0, $A1 + vmovdqa $A0, $A2 + vmovdqa $B0, $B1 + vmovdqa $B0, $B2 + vmovdqa $C0, $C1 + vmovdqa $C0, $C2 + vpaddd .Lavx2_inc(%rip), $D0, $D1 + vpaddd .Lavx2_inc(%rip), $D1, $D2 + vmovdqa $B0, $T1 + vmovdqa $C0, $T2 + vmovdqa $D0, $ctr0_store + vmovdqa $D1, $ctr1_store + vmovdqa $D2, $ctr2_store + mov \$10, $acc0 +.Lseal_avx2_320_rounds: \n"; + &chacha_qr_avx2($A0,$B0,$C0,$D0,$T0,"left"); + &chacha_qr_avx2($A1,$B1,$C1,$D1,$T0,"left"); + &chacha_qr_avx2($A2,$B2,$C2,$D2,$T0,"left"); + &chacha_qr_avx2($A0,$B0,$C0,$D0,$T0,"right"); + &chacha_qr_avx2($A1,$B1,$C1,$D1,$T0,"right"); + &chacha_qr_avx2($A2,$B2,$C2,$D2,$T0,"right"); $code.=" + dec $acc0 + jne .Lseal_avx2_320_rounds + vpaddd .Lchacha20_consts(%rip), $A0, $A0 + vpaddd .Lchacha20_consts(%rip), $A1, $A1 + vpaddd .Lchacha20_consts(%rip), $A2, $A2 + vpaddd $T1, $B0, $B0 + vpaddd $T1, $B1, $B1 + vpaddd $T1, $B2, $B2 + vpaddd $T2, $C0, $C0 + vpaddd $T2, $C1, $C1 + vpaddd $T2, $C2, $C2 + vpaddd $ctr0_store, $D0, $D0 + vpaddd $ctr1_store, $D1, $D1 + vpaddd $ctr2_store, $D2, $D2 + vperm2i128 \$0x02, $A0, $B0, $T0 + # Clamp and store the key + vpand .Lclamp(%rip), $T0, $T0 + vmovdqa $T0, $r_store + # Stream for up to 320 bytes + vperm2i128 \$0x13, $A0, $B0, $A0 + vperm2i128 \$0x13, $C0, $D0, $B0 + vperm2i128 \$0x02, $A1, $B1, $C0 + vperm2i128 \$0x02, $C1, $D1, $D0 + vperm2i128 \$0x13, $A1, $B1, $A1 + vperm2i128 \$0x13, $C1, $D1, $B1 + vperm2i128 \$0x02, $A2, $B2, $C1 + vperm2i128 \$0x02, $C2, $D2, $D1 + vperm2i128 \$0x13, $A2, $B2, $A2 + vperm2i128 \$0x13, $C2, $D2, $B2 + jmp .Lseal_avx2_short +################################################################################ +.Lseal_avx2_192: + vmovdqa $A0, $A1 + vmovdqa $A0, $A2 + vmovdqa $B0, $B1 + vmovdqa $B0, $B2 + vmovdqa $C0, $C1 + vmovdqa $C0, $C2 + vpaddd .Lavx2_inc(%rip), $D0, $D1 + vmovdqa $D0, $T2 + vmovdqa $D1, $T3 + mov \$10, $acc0 +.Lseal_avx2_192_rounds: \n"; + &chacha_qr_avx2($A0,$B0,$C0,$D0,$T0,"left"); + &chacha_qr_avx2($A1,$B1,$C1,$D1,$T0,"left"); + &chacha_qr_avx2($A0,$B0,$C0,$D0,$T0,"right"); + &chacha_qr_avx2($A1,$B1,$C1,$D1,$T0,"right"); $code.=" + dec $acc0 + jne .Lseal_avx2_192_rounds + vpaddd $A2, $A0, $A0 + vpaddd $A2, $A1, $A1 + vpaddd $B2, $B0, $B0 + vpaddd $B2, $B1, $B1 + vpaddd $C2, $C0, $C0 + vpaddd $C2, $C1, $C1 + vpaddd $T2, $D0, $D0 + vpaddd $T3, $D1, $D1 + vperm2i128 \$0x02, $A0, $B0, $T0 + # Clamp and store the key + vpand .Lclamp(%rip), $T0, $T0 + vmovdqa $T0, $r_store + # Stream for up to 192 bytes + vperm2i128 \$0x13, $A0, $B0, $A0 + vperm2i128 \$0x13, $C0, $D0, $B0 + vperm2i128 \$0x02, $A1, $B1, $C0 + vperm2i128 \$0x02, $C1, $D1, $D0 + vperm2i128 \$0x13, $A1, $B1, $A1 + vperm2i128 \$0x13, $C1, $D1, $B1 +.Lseal_avx2_short: + mov $adl, $itr2 + call poly_hash_ad_internal + xor $itr1, $itr1 +.Lseal_avx2_short_hash_remainder: + cmp \$16, $itr1 + jb .Lseal_avx2_short_loop\n"; + &poly_add("0($oup)"); + &poly_mul(); $code.=" + sub \$16, $itr1 + add \$16, $oup + jmp .Lseal_avx2_short_hash_remainder +.Lseal_avx2_short_loop: + cmp \$32, $inl + jb .Lseal_avx2_short_tail + sub \$32, $inl + # Encrypt + vpxor ($inp), $A0, $A0 + vmovdqu $A0, ($oup) + lea 1*32($inp), $inp + # Load + hash\n"; + &poly_add("0*8($oup)"); + &poly_mul(); + &poly_add("2*8($oup)"); + &poly_mul(); $code.=" + lea 1*32($oup), $oup + # Shift stream + vmovdqa $B0, $A0 + vmovdqa $C0, $B0 + vmovdqa $D0, $C0 + vmovdqa $A1, $D0 + vmovdqa $B1, $A1 + vmovdqa $C1, $B1 + vmovdqa $D1, $C1 + vmovdqa $A2, $D1 + vmovdqa $B2, $A2 + jmp .Lseal_avx2_short_loop +.Lseal_avx2_short_tail: + cmp \$16, $inl + jb .Lseal_avx2_exit + sub \$16, $inl + vpxor ($inp), $A0x, $A3x + vmovdqu $A3x, ($oup) + lea 1*16($inp), $inp\n"; + &poly_add("0*8($oup)"); + &poly_mul(); $code.=" + lea 1*16($oup), $oup + vextracti128 \$1, $A0, $A0x +.Lseal_avx2_exit: + vzeroupper + jmp .Lseal_sse_tail_16 +.cfi_endproc +.size chacha20_poly1305_seal_avx2, .-chacha20_poly1305_seal_avx2 +"; +} + +$code =~ s/\`([^\`]*)\`/eval $1/gem; + +print $code; + +close STDOUT or die "error closing STDOUT: $!"; diff --git a/http/vendor/ring/crypto/constant_time_test.c b/http/vendor/ring/crypto/constant_time_test.c new file mode 100644 index 0000000..ed079f6 --- /dev/null +++ b/http/vendor/ring/crypto/constant_time_test.c @@ -0,0 +1,110 @@ +// Copyright 2014-2016 The OpenSSL Project Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "internal.h" + +int bssl_constant_time_test_main(void); + +static int test_binary_op_w(crypto_word_t (*op)(crypto_word_t a, crypto_word_t b), + crypto_word_t a, crypto_word_t b, int is_true) { + crypto_word_t c = op(a, b); + if (is_true && c != CONSTTIME_TRUE_W) { + return 1; + } else if (!is_true && c != CONSTTIME_FALSE_W) { + return 1; + } + return 0; +} + +static int test_is_zero_w(crypto_word_t a) { + crypto_word_t c = constant_time_is_zero_w(a); + if (a == 0 && c != CONSTTIME_TRUE_W) { + return 1; + } else if (a != 0 && c != CONSTTIME_FALSE_W) { + return 1; + } + + c = constant_time_is_nonzero_w(a); + if (a == 0 && c != CONSTTIME_FALSE_W) { + return 1; + } else if (a != 0 && c != CONSTTIME_TRUE_W) { + return 1; + } + + return 0; +} + +static int test_select_w(crypto_word_t a, crypto_word_t b) { + crypto_word_t selected = constant_time_select_w(CONSTTIME_TRUE_W, a, b); + if (selected != a) { + return 1; + } + selected = constant_time_select_w(CONSTTIME_FALSE_W, a, b); + if (selected != b) { + return 1; + } + return 0; +} + +static crypto_word_t test_values_w[] = { + 0, + 1, + 1024, + 12345, + 32000, +#if defined(OPENSSL_64_BIT) + 0xffffffff / 2 - 1, + 0xffffffff / 2, + 0xffffffff / 2 + 1, + 0xffffffff - 1, + 0xffffffff, +#endif + SIZE_MAX / 2 - 1, + SIZE_MAX / 2, + SIZE_MAX / 2 + 1, + SIZE_MAX - 1, + SIZE_MAX +}; + +int bssl_constant_time_test_main(void) { + int num_failed = 0; + + for (size_t i = 0; + i < sizeof(test_values_w) / sizeof(test_values_w[0]); ++i) { + crypto_word_t a = test_values_w[i]; + num_failed += test_is_zero_w(a); + for (size_t j = 0; + j < sizeof(test_values_w) / sizeof(test_values_w[0]); ++j) { + crypto_word_t b = test_values_w[j]; + num_failed += test_binary_op_w(&constant_time_eq_w, a, b, a == b); + num_failed += test_binary_op_w(&constant_time_eq_w, b, a, b == a); + num_failed += test_select_w(a, b); + } + } + + return num_failed == 0; +} + +// Exposes `constant_time_conditional_memcpy` to Rust for tests only. +void bssl_constant_time_test_conditional_memcpy(uint8_t dst[256], const uint8_t src[256], + crypto_word_t b) { + constant_time_conditional_memcpy(dst, src, 256, b); + } + +// Exposes `constant_time_conditional_memxor` to Rust for tests only. +void bssl_constant_time_test_conditional_memxor(uint8_t dst[256], + const uint8_t src[256], + crypto_word_t b) { + constant_time_conditional_memxor(dst, src, 256, b); +} diff --git a/http/vendor/ring/crypto/cpu_intel.c b/http/vendor/ring/crypto/cpu_intel.c new file mode 100644 index 0000000..6e792b6 --- /dev/null +++ b/http/vendor/ring/crypto/cpu_intel.c @@ -0,0 +1,198 @@ +// Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + + +#if !defined(OPENSSL_NO_ASM) && (defined(OPENSSL_X86) || defined(OPENSSL_X86_64)) + +#if defined(_MSC_VER) && !defined(__clang__) +#pragma warning(push, 3) +#include +#include +#pragma warning(pop) +#endif + +#include "internal.h" + + +// OPENSSL_cpuid runs the cpuid instruction. |leaf| is passed in as EAX and ECX +// is set to zero. It writes EAX, EBX, ECX, and EDX to |*out_eax| through +// |*out_edx|. +static void OPENSSL_cpuid(uint32_t *out_eax, uint32_t *out_ebx, + uint32_t *out_ecx, uint32_t *out_edx, uint32_t leaf) { +#if defined(_MSC_VER) && !defined(__clang__) + int tmp[4]; + __cpuid(tmp, (int)leaf); + *out_eax = (uint32_t)tmp[0]; + *out_ebx = (uint32_t)tmp[1]; + *out_ecx = (uint32_t)tmp[2]; + *out_edx = (uint32_t)tmp[3]; +#elif defined(__pic__) && defined(OPENSSL_32_BIT) + // Inline assembly may not clobber the PIC register. For 32-bit, this is EBX. + // See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47602. + __asm__ volatile ( + "xor %%ecx, %%ecx\n" + "mov %%ebx, %%edi\n" + "cpuid\n" + "xchg %%edi, %%ebx\n" + : "=a"(*out_eax), "=D"(*out_ebx), "=c"(*out_ecx), "=d"(*out_edx) + : "a"(leaf) + ); +#else + __asm__ volatile ( + "xor %%ecx, %%ecx\n" + "cpuid\n" + : "=a"(*out_eax), "=b"(*out_ebx), "=c"(*out_ecx), "=d"(*out_edx) + : "a"(leaf) + ); +#endif +} + +// OPENSSL_xgetbv returns the value of an Intel Extended Control Register (XCR). +// Currently only XCR0 is defined by Intel so |xcr| should always be zero. +// +// See https://software.intel.com/en-us/articles/how-to-detect-new-instruction-support-in-the-4th-generation-intel-core-processor-family +static uint64_t OPENSSL_xgetbv(uint32_t xcr) { +#if defined(_MSC_VER) && !defined(__clang__) + return (uint64_t)_xgetbv(xcr); +#else + uint32_t eax, edx; + __asm__ volatile ("xgetbv" : "=a"(eax), "=d"(edx) : "c"(xcr)); + return (((uint64_t)edx) << 32) | eax; +#endif +} + +void OPENSSL_cpuid_setup(uint32_t OPENSSL_ia32cap_P[4]) { + // Determine the vendor and maximum input value. + uint32_t eax, ebx, ecx, edx; + OPENSSL_cpuid(&eax, &ebx, &ecx, &edx, 0); + + uint32_t num_ids = eax; + + int is_intel = ebx == 0x756e6547 /* Genu */ && + edx == 0x49656e69 /* ineI */ && + ecx == 0x6c65746e /* ntel */; + + uint32_t extended_features[2] = {0}; + if (num_ids >= 7) { + OPENSSL_cpuid(&eax, &ebx, &ecx, &edx, 7); + extended_features[0] = ebx; + extended_features[1] = ecx; + } + + OPENSSL_cpuid(&eax, &ebx, &ecx, &edx, 1); + + const uint32_t base_family = (eax >> 8) & 15; + const uint32_t base_model = (eax >> 4) & 15; + + uint32_t family = base_family; + uint32_t model = base_model; + if (base_family == 15) { + const uint32_t ext_family = (eax >> 20) & 255; + family += ext_family; + } + if (base_family == 6 || base_family == 15) { + const uint32_t ext_model = (eax >> 16) & 15; + model |= ext_model << 4; + } + + // Reserved bit #30 is repurposed to signal an Intel CPU. + if (is_intel) { + edx |= (1u << 30); + } else { + edx &= ~(1u << 30); + } + + uint64_t xcr0 = 0; + if (ecx & (1u << 27)) { + // XCR0 may only be queried if the OSXSAVE bit is set. + xcr0 = OPENSSL_xgetbv(0); + } + // See Intel manual, volume 1, section 14.3. + if ((xcr0 & 6) != 6) { + // YMM registers cannot be used. + ecx &= ~(1u << 28); // AVX + ecx &= ~(1u << 12); // FMA + ecx &= ~(1u << 11); // AMD XOP + extended_features[0] &= ~(1u << 5); // AVX2 + extended_features[1] &= ~(1u << 9); // VAES + extended_features[1] &= ~(1u << 10); // VPCLMULQDQ + } + // See Intel manual, volume 1, sections 15.2 ("Detection of AVX-512 Foundation + // Instructions") through 15.4 ("Detection of Intel AVX-512 Instruction Groups + // Operating at 256 and 128-bit Vector Lengths"). + if ((xcr0 & 0xe6) != 0xe6) { + // Without XCR0.111xx11x, no AVX512 feature can be used. This includes ZMM + // registers, masking, SIMD registers 16-31 (even if accessed as YMM or + // XMM), and EVEX-coded instructions (even on YMM or XMM). Even if only + // XCR0.ZMM_Hi256 is missing, it isn't valid to use AVX512 features on + // shorter vectors, since AVX512 ties everything to the availability of + // 512-bit vectors. See the above-mentioned sections of the Intel manual, + // which say that *all* these XCR0 bits must be checked even when just using + // 128-bit or 256-bit vectors, and also volume 2a section 2.7.11 ("#UD + // Equations for EVEX") which says that all EVEX-coded instructions raise an + // undefined-instruction exception if any of these XCR0 bits is zero. + // + // AVX10 fixes this by reorganizing the features that used to be part of + // "AVX512" and allowing them to be used independently of 512-bit support. + // TODO: add AVX10 detection. + extended_features[0] &= ~(1u << 16); // AVX512F + extended_features[0] &= ~(1u << 17); // AVX512DQ + extended_features[0] &= ~(1u << 21); // AVX512IFMA + extended_features[0] &= ~(1u << 26); // AVX512PF + extended_features[0] &= ~(1u << 27); // AVX512ER + extended_features[0] &= ~(1u << 28); // AVX512CD + extended_features[0] &= ~(1u << 30); // AVX512BW + extended_features[0] &= ~(1u << 31); // AVX512VL + extended_features[1] &= ~(1u << 1); // AVX512VBMI + extended_features[1] &= ~(1u << 6); // AVX512VBMI2 + extended_features[1] &= ~(1u << 11); // AVX512VNNI + extended_features[1] &= ~(1u << 12); // AVX512BITALG + extended_features[1] &= ~(1u << 14); // AVX512VPOPCNTDQ + } + + // Repurpose the bit for the removed MPX feature to indicate when using zmm + // registers should be avoided even when they are supported. (When set, AVX512 + // features can still be used, but only using ymm or xmm registers.) Skylake + // suffered from severe downclocking when zmm registers were used, which + // affected unrelated code running on the system, making zmm registers not too + // useful outside of benchmarks. The situation improved significantly by Ice + // Lake, but a small amount of downclocking remained. (See + // https://lore.kernel.org/linux-crypto/e8ce1146-3952-6977-1d0e-a22758e58914@intel.com/) + // We take a conservative approach of not allowing zmm registers until after + // Ice Lake and Tiger Lake, i.e. until Sapphire Rapids on the server side. + // + // AMD CPUs, which support AVX512 starting with Zen 4, have not been reported + // to have any downclocking problem when zmm registers are used. + if (is_intel && family == 6 && + (model == 85 || // Skylake, Cascade Lake, Cooper Lake (server) + model == 106 || // Ice Lake (server) + model == 108 || // Ice Lake (micro server) + model == 125 || // Ice Lake (client) + model == 126 || // Ice Lake (mobile) + model == 140 || // Tiger Lake (mobile) + model == 141)) { // Tiger Lake (client) + extended_features[0] |= 1u << 14; + } else { + extended_features[0] &= ~(1u << 14); + } + + OPENSSL_ia32cap_P[0] = edx; + OPENSSL_ia32cap_P[1] = ecx; + OPENSSL_ia32cap_P[2] = extended_features[0]; + OPENSSL_ia32cap_P[3] = extended_features[1]; +} + +#endif // !OPENSSL_NO_ASM && (OPENSSL_X86 || OPENSSL_X86_64) diff --git a/http/vendor/ring/crypto/crypto.c b/http/vendor/ring/crypto/crypto.c new file mode 100644 index 0000000..153f97f --- /dev/null +++ b/http/vendor/ring/crypto/crypto.c @@ -0,0 +1,34 @@ +// Copyright 2014 The BoringSSL Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +// Our assembly does not use the GOT to reference symbols, which means +// references to visible symbols will often require a TEXTREL. This is +// undesirable, so all assembly-referenced symbols should be hidden. CPU +// capabilities are the only such symbols defined in C. Explicitly hide them, +// rather than rely on being built with -fvisibility=hidden. +#if defined(OPENSSL_WINDOWS) +#define HIDDEN +#else +#define HIDDEN __attribute__((visibility("hidden"))) +#endif + +#if defined(OPENSSL_X86_64) +// These are declared as `AtomicU32` on the Rust side. +HIDDEN uint32_t avx2_available = 0; +HIDDEN uint32_t adx_bmi2_available = 0; +#elif defined(OPENSSL_ARM) +HIDDEN uint32_t neon_available = 0; +#endif diff --git a/http/vendor/ring/crypto/curve25519/asm/x25519-asm-arm.S b/http/vendor/ring/crypto/curve25519/asm/x25519-asm-arm.S new file mode 100644 index 0000000..c085734 --- /dev/null +++ b/http/vendor/ring/crypto/curve25519/asm/x25519-asm-arm.S @@ -0,0 +1,2124 @@ +// Copyright 2015 The BoringSSL Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/* This file is taken from crypto_scalarmult/curve25519/neon2/scalarmult.s in + * SUPERCOP 20141124 (http://bench.cr.yp.to/supercop.html). That code is public + * domain licensed but the standard Apache 2.0 license is included above to keep + * licensing simple. */ + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_ARM) && defined(__ELF__) + +.fpu neon +.text +.align 4 + +.global x25519_NEON +.hidden x25519_NEON +.type x25519_NEON, %function +x25519_NEON: +vpush {q4,q5,q6,q7} +mov r12,sp +sub sp,sp,#736 +and sp,sp,#0xffffffe0 +strd r4,[sp,#0] +strd r6,[sp,#8] +strd r8,[sp,#16] +strd r10,[sp,#24] +str r12,[sp,#480] +str r14,[sp,#484] +mov r0,r0 +mov r1,r1 +mov r2,r2 +add r3,sp,#32 +ldr r4,=0 +ldr r5,=254 +vmov.i32 q0,#1 +vshr.u64 q1,q0,#7 +vshr.u64 q0,q0,#8 +vmov.i32 d4,#19 +vmov.i32 d5,#38 +add r6,sp,#512 +vst1.8 {d2-d3},[r6,: 128] +add r6,sp,#528 +vst1.8 {d0-d1},[r6,: 128] +add r6,sp,#544 +vst1.8 {d4-d5},[r6,: 128] +add r6,r3,#0 +vmov.i32 q2,#0 +vst1.8 {d4-d5},[r6,: 128]! +vst1.8 {d4-d5},[r6,: 128]! +vst1.8 d4,[r6,: 64] +add r6,r3,#0 +ldr r7,=960 +sub r7,r7,#2 +neg r7,r7 +sub r7,r7,r7,LSL #7 +str r7,[r6] +add r6,sp,#704 +vld1.8 {d4-d5},[r1]! +vld1.8 {d6-d7},[r1] +vst1.8 {d4-d5},[r6,: 128]! +vst1.8 {d6-d7},[r6,: 128] +sub r1,r6,#16 +ldrb r6,[r1] +and r6,r6,#248 +strb r6,[r1] +ldrb r6,[r1,#31] +and r6,r6,#127 +orr r6,r6,#64 +strb r6,[r1,#31] +vmov.i64 q2,#0xffffffff +vshr.u64 q3,q2,#7 +vshr.u64 q2,q2,#6 +vld1.8 {d8},[r2] +vld1.8 {d10},[r2] +add r2,r2,#6 +vld1.8 {d12},[r2] +vld1.8 {d14},[r2] +add r2,r2,#6 +vld1.8 {d16},[r2] +add r2,r2,#4 +vld1.8 {d18},[r2] +vld1.8 {d20},[r2] +add r2,r2,#6 +vld1.8 {d22},[r2] +add r2,r2,#2 +vld1.8 {d24},[r2] +vld1.8 {d26},[r2] +vshr.u64 q5,q5,#26 +vshr.u64 q6,q6,#3 +vshr.u64 q7,q7,#29 +vshr.u64 q8,q8,#6 +vshr.u64 q10,q10,#25 +vshr.u64 q11,q11,#3 +vshr.u64 q12,q12,#12 +vshr.u64 q13,q13,#38 +vand q4,q4,q2 +vand q6,q6,q2 +vand q8,q8,q2 +vand q10,q10,q2 +vand q2,q12,q2 +vand q5,q5,q3 +vand q7,q7,q3 +vand q9,q9,q3 +vand q11,q11,q3 +vand q3,q13,q3 +add r2,r3,#48 +vadd.i64 q12,q4,q1 +vadd.i64 q13,q10,q1 +vshr.s64 q12,q12,#26 +vshr.s64 q13,q13,#26 +vadd.i64 q5,q5,q12 +vshl.i64 q12,q12,#26 +vadd.i64 q14,q5,q0 +vadd.i64 q11,q11,q13 +vshl.i64 q13,q13,#26 +vadd.i64 q15,q11,q0 +vsub.i64 q4,q4,q12 +vshr.s64 q12,q14,#25 +vsub.i64 q10,q10,q13 +vshr.s64 q13,q15,#25 +vadd.i64 q6,q6,q12 +vshl.i64 q12,q12,#25 +vadd.i64 q14,q6,q1 +vadd.i64 q2,q2,q13 +vsub.i64 q5,q5,q12 +vshr.s64 q12,q14,#26 +vshl.i64 q13,q13,#25 +vadd.i64 q14,q2,q1 +vadd.i64 q7,q7,q12 +vshl.i64 q12,q12,#26 +vadd.i64 q15,q7,q0 +vsub.i64 q11,q11,q13 +vshr.s64 q13,q14,#26 +vsub.i64 q6,q6,q12 +vshr.s64 q12,q15,#25 +vadd.i64 q3,q3,q13 +vshl.i64 q13,q13,#26 +vadd.i64 q14,q3,q0 +vadd.i64 q8,q8,q12 +vshl.i64 q12,q12,#25 +vadd.i64 q15,q8,q1 +add r2,r2,#8 +vsub.i64 q2,q2,q13 +vshr.s64 q13,q14,#25 +vsub.i64 q7,q7,q12 +vshr.s64 q12,q15,#26 +vadd.i64 q14,q13,q13 +vadd.i64 q9,q9,q12 +vtrn.32 d12,d14 +vshl.i64 q12,q12,#26 +vtrn.32 d13,d15 +vadd.i64 q0,q9,q0 +vadd.i64 q4,q4,q14 +vst1.8 d12,[r2,: 64]! +vshl.i64 q6,q13,#4 +vsub.i64 q7,q8,q12 +vshr.s64 q0,q0,#25 +vadd.i64 q4,q4,q6 +vadd.i64 q6,q10,q0 +vshl.i64 q0,q0,#25 +vadd.i64 q8,q6,q1 +vadd.i64 q4,q4,q13 +vshl.i64 q10,q13,#25 +vadd.i64 q1,q4,q1 +vsub.i64 q0,q9,q0 +vshr.s64 q8,q8,#26 +vsub.i64 q3,q3,q10 +vtrn.32 d14,d0 +vshr.s64 q1,q1,#26 +vtrn.32 d15,d1 +vadd.i64 q0,q11,q8 +vst1.8 d14,[r2,: 64] +vshl.i64 q7,q8,#26 +vadd.i64 q5,q5,q1 +vtrn.32 d4,d6 +vshl.i64 q1,q1,#26 +vtrn.32 d5,d7 +vsub.i64 q3,q6,q7 +add r2,r2,#16 +vsub.i64 q1,q4,q1 +vst1.8 d4,[r2,: 64] +vtrn.32 d6,d0 +vtrn.32 d7,d1 +sub r2,r2,#8 +vtrn.32 d2,d10 +vtrn.32 d3,d11 +vst1.8 d6,[r2,: 64] +sub r2,r2,#24 +vst1.8 d2,[r2,: 64] +add r2,r3,#96 +vmov.i32 q0,#0 +vmov.i64 d2,#0xff +vmov.i64 d3,#0 +vshr.u32 q1,q1,#7 +vst1.8 {d2-d3},[r2,: 128]! +vst1.8 {d0-d1},[r2,: 128]! +vst1.8 d0,[r2,: 64] +add r2,r3,#144 +vmov.i32 q0,#0 +vst1.8 {d0-d1},[r2,: 128]! +vst1.8 {d0-d1},[r2,: 128]! +vst1.8 d0,[r2,: 64] +add r2,r3,#240 +vmov.i32 q0,#0 +vmov.i64 d2,#0xff +vmov.i64 d3,#0 +vshr.u32 q1,q1,#7 +vst1.8 {d2-d3},[r2,: 128]! +vst1.8 {d0-d1},[r2,: 128]! +vst1.8 d0,[r2,: 64] +add r2,r3,#48 +add r6,r3,#192 +vld1.8 {d0-d1},[r2,: 128]! +vld1.8 {d2-d3},[r2,: 128]! +vld1.8 {d4},[r2,: 64] +vst1.8 {d0-d1},[r6,: 128]! +vst1.8 {d2-d3},[r6,: 128]! +vst1.8 d4,[r6,: 64] +._mainloop: +mov r2,r5,LSR #3 +and r6,r5,#7 +ldrb r2,[r1,r2] +mov r2,r2,LSR r6 +and r2,r2,#1 +str r5,[sp,#488] +eor r4,r4,r2 +str r2,[sp,#492] +neg r2,r4 +add r4,r3,#96 +add r5,r3,#192 +add r6,r3,#144 +vld1.8 {d8-d9},[r4,: 128]! +add r7,r3,#240 +vld1.8 {d10-d11},[r5,: 128]! +veor q6,q4,q5 +vld1.8 {d14-d15},[r6,: 128]! +vdup.i32 q8,r2 +vld1.8 {d18-d19},[r7,: 128]! +veor q10,q7,q9 +vld1.8 {d22-d23},[r4,: 128]! +vand q6,q6,q8 +vld1.8 {d24-d25},[r5,: 128]! +vand q10,q10,q8 +vld1.8 {d26-d27},[r6,: 128]! +veor q4,q4,q6 +vld1.8 {d28-d29},[r7,: 128]! +veor q5,q5,q6 +vld1.8 {d0},[r4,: 64] +veor q6,q7,q10 +vld1.8 {d2},[r5,: 64] +veor q7,q9,q10 +vld1.8 {d4},[r6,: 64] +veor q9,q11,q12 +vld1.8 {d6},[r7,: 64] +veor q10,q0,q1 +sub r2,r4,#32 +vand q9,q9,q8 +sub r4,r5,#32 +vand q10,q10,q8 +sub r5,r6,#32 +veor q11,q11,q9 +sub r6,r7,#32 +veor q0,q0,q10 +veor q9,q12,q9 +veor q1,q1,q10 +veor q10,q13,q14 +veor q12,q2,q3 +vand q10,q10,q8 +vand q8,q12,q8 +veor q12,q13,q10 +veor q2,q2,q8 +veor q10,q14,q10 +veor q3,q3,q8 +vadd.i32 q8,q4,q6 +vsub.i32 q4,q4,q6 +vst1.8 {d16-d17},[r2,: 128]! +vadd.i32 q6,q11,q12 +vst1.8 {d8-d9},[r5,: 128]! +vsub.i32 q4,q11,q12 +vst1.8 {d12-d13},[r2,: 128]! +vadd.i32 q6,q0,q2 +vst1.8 {d8-d9},[r5,: 128]! +vsub.i32 q0,q0,q2 +vst1.8 d12,[r2,: 64] +vadd.i32 q2,q5,q7 +vst1.8 d0,[r5,: 64] +vsub.i32 q0,q5,q7 +vst1.8 {d4-d5},[r4,: 128]! +vadd.i32 q2,q9,q10 +vst1.8 {d0-d1},[r6,: 128]! +vsub.i32 q0,q9,q10 +vst1.8 {d4-d5},[r4,: 128]! +vadd.i32 q2,q1,q3 +vst1.8 {d0-d1},[r6,: 128]! +vsub.i32 q0,q1,q3 +vst1.8 d4,[r4,: 64] +vst1.8 d0,[r6,: 64] +add r2,sp,#544 +add r4,r3,#96 +add r5,r3,#144 +vld1.8 {d0-d1},[r2,: 128] +vld1.8 {d2-d3},[r4,: 128]! +vld1.8 {d4-d5},[r5,: 128]! +vzip.i32 q1,q2 +vld1.8 {d6-d7},[r4,: 128]! +vld1.8 {d8-d9},[r5,: 128]! +vshl.i32 q5,q1,#1 +vzip.i32 q3,q4 +vshl.i32 q6,q2,#1 +vld1.8 {d14},[r4,: 64] +vshl.i32 q8,q3,#1 +vld1.8 {d15},[r5,: 64] +vshl.i32 q9,q4,#1 +vmul.i32 d21,d7,d1 +vtrn.32 d14,d15 +vmul.i32 q11,q4,q0 +vmul.i32 q0,q7,q0 +vmull.s32 q12,d2,d2 +vmlal.s32 q12,d11,d1 +vmlal.s32 q12,d12,d0 +vmlal.s32 q12,d13,d23 +vmlal.s32 q12,d16,d22 +vmlal.s32 q12,d7,d21 +vmull.s32 q10,d2,d11 +vmlal.s32 q10,d4,d1 +vmlal.s32 q10,d13,d0 +vmlal.s32 q10,d6,d23 +vmlal.s32 q10,d17,d22 +vmull.s32 q13,d10,d4 +vmlal.s32 q13,d11,d3 +vmlal.s32 q13,d13,d1 +vmlal.s32 q13,d16,d0 +vmlal.s32 q13,d17,d23 +vmlal.s32 q13,d8,d22 +vmull.s32 q1,d10,d5 +vmlal.s32 q1,d11,d4 +vmlal.s32 q1,d6,d1 +vmlal.s32 q1,d17,d0 +vmlal.s32 q1,d8,d23 +vmull.s32 q14,d10,d6 +vmlal.s32 q14,d11,d13 +vmlal.s32 q14,d4,d4 +vmlal.s32 q14,d17,d1 +vmlal.s32 q14,d18,d0 +vmlal.s32 q14,d9,d23 +vmull.s32 q11,d10,d7 +vmlal.s32 q11,d11,d6 +vmlal.s32 q11,d12,d5 +vmlal.s32 q11,d8,d1 +vmlal.s32 q11,d19,d0 +vmull.s32 q15,d10,d8 +vmlal.s32 q15,d11,d17 +vmlal.s32 q15,d12,d6 +vmlal.s32 q15,d13,d5 +vmlal.s32 q15,d19,d1 +vmlal.s32 q15,d14,d0 +vmull.s32 q2,d10,d9 +vmlal.s32 q2,d11,d8 +vmlal.s32 q2,d12,d7 +vmlal.s32 q2,d13,d6 +vmlal.s32 q2,d14,d1 +vmull.s32 q0,d15,d1 +vmlal.s32 q0,d10,d14 +vmlal.s32 q0,d11,d19 +vmlal.s32 q0,d12,d8 +vmlal.s32 q0,d13,d17 +vmlal.s32 q0,d6,d6 +add r2,sp,#512 +vld1.8 {d18-d19},[r2,: 128] +vmull.s32 q3,d16,d7 +vmlal.s32 q3,d10,d15 +vmlal.s32 q3,d11,d14 +vmlal.s32 q3,d12,d9 +vmlal.s32 q3,d13,d8 +add r2,sp,#528 +vld1.8 {d8-d9},[r2,: 128] +vadd.i64 q5,q12,q9 +vadd.i64 q6,q15,q9 +vshr.s64 q5,q5,#26 +vshr.s64 q6,q6,#26 +vadd.i64 q7,q10,q5 +vshl.i64 q5,q5,#26 +vadd.i64 q8,q7,q4 +vadd.i64 q2,q2,q6 +vshl.i64 q6,q6,#26 +vadd.i64 q10,q2,q4 +vsub.i64 q5,q12,q5 +vshr.s64 q8,q8,#25 +vsub.i64 q6,q15,q6 +vshr.s64 q10,q10,#25 +vadd.i64 q12,q13,q8 +vshl.i64 q8,q8,#25 +vadd.i64 q13,q12,q9 +vadd.i64 q0,q0,q10 +vsub.i64 q7,q7,q8 +vshr.s64 q8,q13,#26 +vshl.i64 q10,q10,#25 +vadd.i64 q13,q0,q9 +vadd.i64 q1,q1,q8 +vshl.i64 q8,q8,#26 +vadd.i64 q15,q1,q4 +vsub.i64 q2,q2,q10 +vshr.s64 q10,q13,#26 +vsub.i64 q8,q12,q8 +vshr.s64 q12,q15,#25 +vadd.i64 q3,q3,q10 +vshl.i64 q10,q10,#26 +vadd.i64 q13,q3,q4 +vadd.i64 q14,q14,q12 +add r2,r3,#288 +vshl.i64 q12,q12,#25 +add r4,r3,#336 +vadd.i64 q15,q14,q9 +add r2,r2,#8 +vsub.i64 q0,q0,q10 +add r4,r4,#8 +vshr.s64 q10,q13,#25 +vsub.i64 q1,q1,q12 +vshr.s64 q12,q15,#26 +vadd.i64 q13,q10,q10 +vadd.i64 q11,q11,q12 +vtrn.32 d16,d2 +vshl.i64 q12,q12,#26 +vtrn.32 d17,d3 +vadd.i64 q1,q11,q4 +vadd.i64 q4,q5,q13 +vst1.8 d16,[r2,: 64]! +vshl.i64 q5,q10,#4 +vst1.8 d17,[r4,: 64]! +vsub.i64 q8,q14,q12 +vshr.s64 q1,q1,#25 +vadd.i64 q4,q4,q5 +vadd.i64 q5,q6,q1 +vshl.i64 q1,q1,#25 +vadd.i64 q6,q5,q9 +vadd.i64 q4,q4,q10 +vshl.i64 q10,q10,#25 +vadd.i64 q9,q4,q9 +vsub.i64 q1,q11,q1 +vshr.s64 q6,q6,#26 +vsub.i64 q3,q3,q10 +vtrn.32 d16,d2 +vshr.s64 q9,q9,#26 +vtrn.32 d17,d3 +vadd.i64 q1,q2,q6 +vst1.8 d16,[r2,: 64] +vshl.i64 q2,q6,#26 +vst1.8 d17,[r4,: 64] +vadd.i64 q6,q7,q9 +vtrn.32 d0,d6 +vshl.i64 q7,q9,#26 +vtrn.32 d1,d7 +vsub.i64 q2,q5,q2 +add r2,r2,#16 +vsub.i64 q3,q4,q7 +vst1.8 d0,[r2,: 64] +add r4,r4,#16 +vst1.8 d1,[r4,: 64] +vtrn.32 d4,d2 +vtrn.32 d5,d3 +sub r2,r2,#8 +sub r4,r4,#8 +vtrn.32 d6,d12 +vtrn.32 d7,d13 +vst1.8 d4,[r2,: 64] +vst1.8 d5,[r4,: 64] +sub r2,r2,#24 +sub r4,r4,#24 +vst1.8 d6,[r2,: 64] +vst1.8 d7,[r4,: 64] +add r2,r3,#240 +add r4,r3,#96 +vld1.8 {d0-d1},[r4,: 128]! +vld1.8 {d2-d3},[r4,: 128]! +vld1.8 {d4},[r4,: 64] +add r4,r3,#144 +vld1.8 {d6-d7},[r4,: 128]! +vtrn.32 q0,q3 +vld1.8 {d8-d9},[r4,: 128]! +vshl.i32 q5,q0,#4 +vtrn.32 q1,q4 +vshl.i32 q6,q3,#4 +vadd.i32 q5,q5,q0 +vadd.i32 q6,q6,q3 +vshl.i32 q7,q1,#4 +vld1.8 {d5},[r4,: 64] +vshl.i32 q8,q4,#4 +vtrn.32 d4,d5 +vadd.i32 q7,q7,q1 +vadd.i32 q8,q8,q4 +vld1.8 {d18-d19},[r2,: 128]! +vshl.i32 q10,q2,#4 +vld1.8 {d22-d23},[r2,: 128]! +vadd.i32 q10,q10,q2 +vld1.8 {d24},[r2,: 64] +vadd.i32 q5,q5,q0 +add r2,r3,#192 +vld1.8 {d26-d27},[r2,: 128]! +vadd.i32 q6,q6,q3 +vld1.8 {d28-d29},[r2,: 128]! +vadd.i32 q8,q8,q4 +vld1.8 {d25},[r2,: 64] +vadd.i32 q10,q10,q2 +vtrn.32 q9,q13 +vadd.i32 q7,q7,q1 +vadd.i32 q5,q5,q0 +vtrn.32 q11,q14 +vadd.i32 q6,q6,q3 +add r2,sp,#560 +vadd.i32 q10,q10,q2 +vtrn.32 d24,d25 +vst1.8 {d12-d13},[r2,: 128] +vshl.i32 q6,q13,#1 +add r2,sp,#576 +vst1.8 {d20-d21},[r2,: 128] +vshl.i32 q10,q14,#1 +add r2,sp,#592 +vst1.8 {d12-d13},[r2,: 128] +vshl.i32 q15,q12,#1 +vadd.i32 q8,q8,q4 +vext.32 d10,d31,d30,#0 +vadd.i32 q7,q7,q1 +add r2,sp,#608 +vst1.8 {d16-d17},[r2,: 128] +vmull.s32 q8,d18,d5 +vmlal.s32 q8,d26,d4 +vmlal.s32 q8,d19,d9 +vmlal.s32 q8,d27,d3 +vmlal.s32 q8,d22,d8 +vmlal.s32 q8,d28,d2 +vmlal.s32 q8,d23,d7 +vmlal.s32 q8,d29,d1 +vmlal.s32 q8,d24,d6 +vmlal.s32 q8,d25,d0 +add r2,sp,#624 +vst1.8 {d14-d15},[r2,: 128] +vmull.s32 q2,d18,d4 +vmlal.s32 q2,d12,d9 +vmlal.s32 q2,d13,d8 +vmlal.s32 q2,d19,d3 +vmlal.s32 q2,d22,d2 +vmlal.s32 q2,d23,d1 +vmlal.s32 q2,d24,d0 +add r2,sp,#640 +vst1.8 {d20-d21},[r2,: 128] +vmull.s32 q7,d18,d9 +vmlal.s32 q7,d26,d3 +vmlal.s32 q7,d19,d8 +vmlal.s32 q7,d27,d2 +vmlal.s32 q7,d22,d7 +vmlal.s32 q7,d28,d1 +vmlal.s32 q7,d23,d6 +vmlal.s32 q7,d29,d0 +add r2,sp,#656 +vst1.8 {d10-d11},[r2,: 128] +vmull.s32 q5,d18,d3 +vmlal.s32 q5,d19,d2 +vmlal.s32 q5,d22,d1 +vmlal.s32 q5,d23,d0 +vmlal.s32 q5,d12,d8 +add r2,sp,#672 +vst1.8 {d16-d17},[r2,: 128] +vmull.s32 q4,d18,d8 +vmlal.s32 q4,d26,d2 +vmlal.s32 q4,d19,d7 +vmlal.s32 q4,d27,d1 +vmlal.s32 q4,d22,d6 +vmlal.s32 q4,d28,d0 +vmull.s32 q8,d18,d7 +vmlal.s32 q8,d26,d1 +vmlal.s32 q8,d19,d6 +vmlal.s32 q8,d27,d0 +add r2,sp,#576 +vld1.8 {d20-d21},[r2,: 128] +vmlal.s32 q7,d24,d21 +vmlal.s32 q7,d25,d20 +vmlal.s32 q4,d23,d21 +vmlal.s32 q4,d29,d20 +vmlal.s32 q8,d22,d21 +vmlal.s32 q8,d28,d20 +vmlal.s32 q5,d24,d20 +add r2,sp,#576 +vst1.8 {d14-d15},[r2,: 128] +vmull.s32 q7,d18,d6 +vmlal.s32 q7,d26,d0 +add r2,sp,#656 +vld1.8 {d30-d31},[r2,: 128] +vmlal.s32 q2,d30,d21 +vmlal.s32 q7,d19,d21 +vmlal.s32 q7,d27,d20 +add r2,sp,#624 +vld1.8 {d26-d27},[r2,: 128] +vmlal.s32 q4,d25,d27 +vmlal.s32 q8,d29,d27 +vmlal.s32 q8,d25,d26 +vmlal.s32 q7,d28,d27 +vmlal.s32 q7,d29,d26 +add r2,sp,#608 +vld1.8 {d28-d29},[r2,: 128] +vmlal.s32 q4,d24,d29 +vmlal.s32 q8,d23,d29 +vmlal.s32 q8,d24,d28 +vmlal.s32 q7,d22,d29 +vmlal.s32 q7,d23,d28 +add r2,sp,#608 +vst1.8 {d8-d9},[r2,: 128] +add r2,sp,#560 +vld1.8 {d8-d9},[r2,: 128] +vmlal.s32 q7,d24,d9 +vmlal.s32 q7,d25,d31 +vmull.s32 q1,d18,d2 +vmlal.s32 q1,d19,d1 +vmlal.s32 q1,d22,d0 +vmlal.s32 q1,d24,d27 +vmlal.s32 q1,d23,d20 +vmlal.s32 q1,d12,d7 +vmlal.s32 q1,d13,d6 +vmull.s32 q6,d18,d1 +vmlal.s32 q6,d19,d0 +vmlal.s32 q6,d23,d27 +vmlal.s32 q6,d22,d20 +vmlal.s32 q6,d24,d26 +vmull.s32 q0,d18,d0 +vmlal.s32 q0,d22,d27 +vmlal.s32 q0,d23,d26 +vmlal.s32 q0,d24,d31 +vmlal.s32 q0,d19,d20 +add r2,sp,#640 +vld1.8 {d18-d19},[r2,: 128] +vmlal.s32 q2,d18,d7 +vmlal.s32 q2,d19,d6 +vmlal.s32 q5,d18,d6 +vmlal.s32 q5,d19,d21 +vmlal.s32 q1,d18,d21 +vmlal.s32 q1,d19,d29 +vmlal.s32 q0,d18,d28 +vmlal.s32 q0,d19,d9 +vmlal.s32 q6,d18,d29 +vmlal.s32 q6,d19,d28 +add r2,sp,#592 +vld1.8 {d18-d19},[r2,: 128] +add r2,sp,#512 +vld1.8 {d22-d23},[r2,: 128] +vmlal.s32 q5,d19,d7 +vmlal.s32 q0,d18,d21 +vmlal.s32 q0,d19,d29 +vmlal.s32 q6,d18,d6 +add r2,sp,#528 +vld1.8 {d6-d7},[r2,: 128] +vmlal.s32 q6,d19,d21 +add r2,sp,#576 +vld1.8 {d18-d19},[r2,: 128] +vmlal.s32 q0,d30,d8 +add r2,sp,#672 +vld1.8 {d20-d21},[r2,: 128] +vmlal.s32 q5,d30,d29 +add r2,sp,#608 +vld1.8 {d24-d25},[r2,: 128] +vmlal.s32 q1,d30,d28 +vadd.i64 q13,q0,q11 +vadd.i64 q14,q5,q11 +vmlal.s32 q6,d30,d9 +vshr.s64 q4,q13,#26 +vshr.s64 q13,q14,#26 +vadd.i64 q7,q7,q4 +vshl.i64 q4,q4,#26 +vadd.i64 q14,q7,q3 +vadd.i64 q9,q9,q13 +vshl.i64 q13,q13,#26 +vadd.i64 q15,q9,q3 +vsub.i64 q0,q0,q4 +vshr.s64 q4,q14,#25 +vsub.i64 q5,q5,q13 +vshr.s64 q13,q15,#25 +vadd.i64 q6,q6,q4 +vshl.i64 q4,q4,#25 +vadd.i64 q14,q6,q11 +vadd.i64 q2,q2,q13 +vsub.i64 q4,q7,q4 +vshr.s64 q7,q14,#26 +vshl.i64 q13,q13,#25 +vadd.i64 q14,q2,q11 +vadd.i64 q8,q8,q7 +vshl.i64 q7,q7,#26 +vadd.i64 q15,q8,q3 +vsub.i64 q9,q9,q13 +vshr.s64 q13,q14,#26 +vsub.i64 q6,q6,q7 +vshr.s64 q7,q15,#25 +vadd.i64 q10,q10,q13 +vshl.i64 q13,q13,#26 +vadd.i64 q14,q10,q3 +vadd.i64 q1,q1,q7 +add r2,r3,#144 +vshl.i64 q7,q7,#25 +add r4,r3,#96 +vadd.i64 q15,q1,q11 +add r2,r2,#8 +vsub.i64 q2,q2,q13 +add r4,r4,#8 +vshr.s64 q13,q14,#25 +vsub.i64 q7,q8,q7 +vshr.s64 q8,q15,#26 +vadd.i64 q14,q13,q13 +vadd.i64 q12,q12,q8 +vtrn.32 d12,d14 +vshl.i64 q8,q8,#26 +vtrn.32 d13,d15 +vadd.i64 q3,q12,q3 +vadd.i64 q0,q0,q14 +vst1.8 d12,[r2,: 64]! +vshl.i64 q7,q13,#4 +vst1.8 d13,[r4,: 64]! +vsub.i64 q1,q1,q8 +vshr.s64 q3,q3,#25 +vadd.i64 q0,q0,q7 +vadd.i64 q5,q5,q3 +vshl.i64 q3,q3,#25 +vadd.i64 q6,q5,q11 +vadd.i64 q0,q0,q13 +vshl.i64 q7,q13,#25 +vadd.i64 q8,q0,q11 +vsub.i64 q3,q12,q3 +vshr.s64 q6,q6,#26 +vsub.i64 q7,q10,q7 +vtrn.32 d2,d6 +vshr.s64 q8,q8,#26 +vtrn.32 d3,d7 +vadd.i64 q3,q9,q6 +vst1.8 d2,[r2,: 64] +vshl.i64 q6,q6,#26 +vst1.8 d3,[r4,: 64] +vadd.i64 q1,q4,q8 +vtrn.32 d4,d14 +vshl.i64 q4,q8,#26 +vtrn.32 d5,d15 +vsub.i64 q5,q5,q6 +add r2,r2,#16 +vsub.i64 q0,q0,q4 +vst1.8 d4,[r2,: 64] +add r4,r4,#16 +vst1.8 d5,[r4,: 64] +vtrn.32 d10,d6 +vtrn.32 d11,d7 +sub r2,r2,#8 +sub r4,r4,#8 +vtrn.32 d0,d2 +vtrn.32 d1,d3 +vst1.8 d10,[r2,: 64] +vst1.8 d11,[r4,: 64] +sub r2,r2,#24 +sub r4,r4,#24 +vst1.8 d0,[r2,: 64] +vst1.8 d1,[r4,: 64] +add r2,r3,#288 +add r4,r3,#336 +vld1.8 {d0-d1},[r2,: 128]! +vld1.8 {d2-d3},[r4,: 128]! +vsub.i32 q0,q0,q1 +vld1.8 {d2-d3},[r2,: 128]! +vld1.8 {d4-d5},[r4,: 128]! +vsub.i32 q1,q1,q2 +add r5,r3,#240 +vld1.8 {d4},[r2,: 64] +vld1.8 {d6},[r4,: 64] +vsub.i32 q2,q2,q3 +vst1.8 {d0-d1},[r5,: 128]! +vst1.8 {d2-d3},[r5,: 128]! +vst1.8 d4,[r5,: 64] +add r2,r3,#144 +add r4,r3,#96 +add r5,r3,#144 +add r6,r3,#192 +vld1.8 {d0-d1},[r2,: 128]! +vld1.8 {d2-d3},[r4,: 128]! +vsub.i32 q2,q0,q1 +vadd.i32 q0,q0,q1 +vld1.8 {d2-d3},[r2,: 128]! +vld1.8 {d6-d7},[r4,: 128]! +vsub.i32 q4,q1,q3 +vadd.i32 q1,q1,q3 +vld1.8 {d6},[r2,: 64] +vld1.8 {d10},[r4,: 64] +vsub.i32 q6,q3,q5 +vadd.i32 q3,q3,q5 +vst1.8 {d4-d5},[r5,: 128]! +vst1.8 {d0-d1},[r6,: 128]! +vst1.8 {d8-d9},[r5,: 128]! +vst1.8 {d2-d3},[r6,: 128]! +vst1.8 d12,[r5,: 64] +vst1.8 d6,[r6,: 64] +add r2,r3,#0 +add r4,r3,#240 +vld1.8 {d0-d1},[r4,: 128]! +vld1.8 {d2-d3},[r4,: 128]! +vld1.8 {d4},[r4,: 64] +add r4,r3,#336 +vld1.8 {d6-d7},[r4,: 128]! +vtrn.32 q0,q3 +vld1.8 {d8-d9},[r4,: 128]! +vshl.i32 q5,q0,#4 +vtrn.32 q1,q4 +vshl.i32 q6,q3,#4 +vadd.i32 q5,q5,q0 +vadd.i32 q6,q6,q3 +vshl.i32 q7,q1,#4 +vld1.8 {d5},[r4,: 64] +vshl.i32 q8,q4,#4 +vtrn.32 d4,d5 +vadd.i32 q7,q7,q1 +vadd.i32 q8,q8,q4 +vld1.8 {d18-d19},[r2,: 128]! +vshl.i32 q10,q2,#4 +vld1.8 {d22-d23},[r2,: 128]! +vadd.i32 q10,q10,q2 +vld1.8 {d24},[r2,: 64] +vadd.i32 q5,q5,q0 +add r2,r3,#288 +vld1.8 {d26-d27},[r2,: 128]! +vadd.i32 q6,q6,q3 +vld1.8 {d28-d29},[r2,: 128]! +vadd.i32 q8,q8,q4 +vld1.8 {d25},[r2,: 64] +vadd.i32 q10,q10,q2 +vtrn.32 q9,q13 +vadd.i32 q7,q7,q1 +vadd.i32 q5,q5,q0 +vtrn.32 q11,q14 +vadd.i32 q6,q6,q3 +add r2,sp,#560 +vadd.i32 q10,q10,q2 +vtrn.32 d24,d25 +vst1.8 {d12-d13},[r2,: 128] +vshl.i32 q6,q13,#1 +add r2,sp,#576 +vst1.8 {d20-d21},[r2,: 128] +vshl.i32 q10,q14,#1 +add r2,sp,#592 +vst1.8 {d12-d13},[r2,: 128] +vshl.i32 q15,q12,#1 +vadd.i32 q8,q8,q4 +vext.32 d10,d31,d30,#0 +vadd.i32 q7,q7,q1 +add r2,sp,#608 +vst1.8 {d16-d17},[r2,: 128] +vmull.s32 q8,d18,d5 +vmlal.s32 q8,d26,d4 +vmlal.s32 q8,d19,d9 +vmlal.s32 q8,d27,d3 +vmlal.s32 q8,d22,d8 +vmlal.s32 q8,d28,d2 +vmlal.s32 q8,d23,d7 +vmlal.s32 q8,d29,d1 +vmlal.s32 q8,d24,d6 +vmlal.s32 q8,d25,d0 +add r2,sp,#624 +vst1.8 {d14-d15},[r2,: 128] +vmull.s32 q2,d18,d4 +vmlal.s32 q2,d12,d9 +vmlal.s32 q2,d13,d8 +vmlal.s32 q2,d19,d3 +vmlal.s32 q2,d22,d2 +vmlal.s32 q2,d23,d1 +vmlal.s32 q2,d24,d0 +add r2,sp,#640 +vst1.8 {d20-d21},[r2,: 128] +vmull.s32 q7,d18,d9 +vmlal.s32 q7,d26,d3 +vmlal.s32 q7,d19,d8 +vmlal.s32 q7,d27,d2 +vmlal.s32 q7,d22,d7 +vmlal.s32 q7,d28,d1 +vmlal.s32 q7,d23,d6 +vmlal.s32 q7,d29,d0 +add r2,sp,#656 +vst1.8 {d10-d11},[r2,: 128] +vmull.s32 q5,d18,d3 +vmlal.s32 q5,d19,d2 +vmlal.s32 q5,d22,d1 +vmlal.s32 q5,d23,d0 +vmlal.s32 q5,d12,d8 +add r2,sp,#672 +vst1.8 {d16-d17},[r2,: 128] +vmull.s32 q4,d18,d8 +vmlal.s32 q4,d26,d2 +vmlal.s32 q4,d19,d7 +vmlal.s32 q4,d27,d1 +vmlal.s32 q4,d22,d6 +vmlal.s32 q4,d28,d0 +vmull.s32 q8,d18,d7 +vmlal.s32 q8,d26,d1 +vmlal.s32 q8,d19,d6 +vmlal.s32 q8,d27,d0 +add r2,sp,#576 +vld1.8 {d20-d21},[r2,: 128] +vmlal.s32 q7,d24,d21 +vmlal.s32 q7,d25,d20 +vmlal.s32 q4,d23,d21 +vmlal.s32 q4,d29,d20 +vmlal.s32 q8,d22,d21 +vmlal.s32 q8,d28,d20 +vmlal.s32 q5,d24,d20 +add r2,sp,#576 +vst1.8 {d14-d15},[r2,: 128] +vmull.s32 q7,d18,d6 +vmlal.s32 q7,d26,d0 +add r2,sp,#656 +vld1.8 {d30-d31},[r2,: 128] +vmlal.s32 q2,d30,d21 +vmlal.s32 q7,d19,d21 +vmlal.s32 q7,d27,d20 +add r2,sp,#624 +vld1.8 {d26-d27},[r2,: 128] +vmlal.s32 q4,d25,d27 +vmlal.s32 q8,d29,d27 +vmlal.s32 q8,d25,d26 +vmlal.s32 q7,d28,d27 +vmlal.s32 q7,d29,d26 +add r2,sp,#608 +vld1.8 {d28-d29},[r2,: 128] +vmlal.s32 q4,d24,d29 +vmlal.s32 q8,d23,d29 +vmlal.s32 q8,d24,d28 +vmlal.s32 q7,d22,d29 +vmlal.s32 q7,d23,d28 +add r2,sp,#608 +vst1.8 {d8-d9},[r2,: 128] +add r2,sp,#560 +vld1.8 {d8-d9},[r2,: 128] +vmlal.s32 q7,d24,d9 +vmlal.s32 q7,d25,d31 +vmull.s32 q1,d18,d2 +vmlal.s32 q1,d19,d1 +vmlal.s32 q1,d22,d0 +vmlal.s32 q1,d24,d27 +vmlal.s32 q1,d23,d20 +vmlal.s32 q1,d12,d7 +vmlal.s32 q1,d13,d6 +vmull.s32 q6,d18,d1 +vmlal.s32 q6,d19,d0 +vmlal.s32 q6,d23,d27 +vmlal.s32 q6,d22,d20 +vmlal.s32 q6,d24,d26 +vmull.s32 q0,d18,d0 +vmlal.s32 q0,d22,d27 +vmlal.s32 q0,d23,d26 +vmlal.s32 q0,d24,d31 +vmlal.s32 q0,d19,d20 +add r2,sp,#640 +vld1.8 {d18-d19},[r2,: 128] +vmlal.s32 q2,d18,d7 +vmlal.s32 q2,d19,d6 +vmlal.s32 q5,d18,d6 +vmlal.s32 q5,d19,d21 +vmlal.s32 q1,d18,d21 +vmlal.s32 q1,d19,d29 +vmlal.s32 q0,d18,d28 +vmlal.s32 q0,d19,d9 +vmlal.s32 q6,d18,d29 +vmlal.s32 q6,d19,d28 +add r2,sp,#592 +vld1.8 {d18-d19},[r2,: 128] +add r2,sp,#512 +vld1.8 {d22-d23},[r2,: 128] +vmlal.s32 q5,d19,d7 +vmlal.s32 q0,d18,d21 +vmlal.s32 q0,d19,d29 +vmlal.s32 q6,d18,d6 +add r2,sp,#528 +vld1.8 {d6-d7},[r2,: 128] +vmlal.s32 q6,d19,d21 +add r2,sp,#576 +vld1.8 {d18-d19},[r2,: 128] +vmlal.s32 q0,d30,d8 +add r2,sp,#672 +vld1.8 {d20-d21},[r2,: 128] +vmlal.s32 q5,d30,d29 +add r2,sp,#608 +vld1.8 {d24-d25},[r2,: 128] +vmlal.s32 q1,d30,d28 +vadd.i64 q13,q0,q11 +vadd.i64 q14,q5,q11 +vmlal.s32 q6,d30,d9 +vshr.s64 q4,q13,#26 +vshr.s64 q13,q14,#26 +vadd.i64 q7,q7,q4 +vshl.i64 q4,q4,#26 +vadd.i64 q14,q7,q3 +vadd.i64 q9,q9,q13 +vshl.i64 q13,q13,#26 +vadd.i64 q15,q9,q3 +vsub.i64 q0,q0,q4 +vshr.s64 q4,q14,#25 +vsub.i64 q5,q5,q13 +vshr.s64 q13,q15,#25 +vadd.i64 q6,q6,q4 +vshl.i64 q4,q4,#25 +vadd.i64 q14,q6,q11 +vadd.i64 q2,q2,q13 +vsub.i64 q4,q7,q4 +vshr.s64 q7,q14,#26 +vshl.i64 q13,q13,#25 +vadd.i64 q14,q2,q11 +vadd.i64 q8,q8,q7 +vshl.i64 q7,q7,#26 +vadd.i64 q15,q8,q3 +vsub.i64 q9,q9,q13 +vshr.s64 q13,q14,#26 +vsub.i64 q6,q6,q7 +vshr.s64 q7,q15,#25 +vadd.i64 q10,q10,q13 +vshl.i64 q13,q13,#26 +vadd.i64 q14,q10,q3 +vadd.i64 q1,q1,q7 +add r2,r3,#288 +vshl.i64 q7,q7,#25 +add r4,r3,#96 +vadd.i64 q15,q1,q11 +add r2,r2,#8 +vsub.i64 q2,q2,q13 +add r4,r4,#8 +vshr.s64 q13,q14,#25 +vsub.i64 q7,q8,q7 +vshr.s64 q8,q15,#26 +vadd.i64 q14,q13,q13 +vadd.i64 q12,q12,q8 +vtrn.32 d12,d14 +vshl.i64 q8,q8,#26 +vtrn.32 d13,d15 +vadd.i64 q3,q12,q3 +vadd.i64 q0,q0,q14 +vst1.8 d12,[r2,: 64]! +vshl.i64 q7,q13,#4 +vst1.8 d13,[r4,: 64]! +vsub.i64 q1,q1,q8 +vshr.s64 q3,q3,#25 +vadd.i64 q0,q0,q7 +vadd.i64 q5,q5,q3 +vshl.i64 q3,q3,#25 +vadd.i64 q6,q5,q11 +vadd.i64 q0,q0,q13 +vshl.i64 q7,q13,#25 +vadd.i64 q8,q0,q11 +vsub.i64 q3,q12,q3 +vshr.s64 q6,q6,#26 +vsub.i64 q7,q10,q7 +vtrn.32 d2,d6 +vshr.s64 q8,q8,#26 +vtrn.32 d3,d7 +vadd.i64 q3,q9,q6 +vst1.8 d2,[r2,: 64] +vshl.i64 q6,q6,#26 +vst1.8 d3,[r4,: 64] +vadd.i64 q1,q4,q8 +vtrn.32 d4,d14 +vshl.i64 q4,q8,#26 +vtrn.32 d5,d15 +vsub.i64 q5,q5,q6 +add r2,r2,#16 +vsub.i64 q0,q0,q4 +vst1.8 d4,[r2,: 64] +add r4,r4,#16 +vst1.8 d5,[r4,: 64] +vtrn.32 d10,d6 +vtrn.32 d11,d7 +sub r2,r2,#8 +sub r4,r4,#8 +vtrn.32 d0,d2 +vtrn.32 d1,d3 +vst1.8 d10,[r2,: 64] +vst1.8 d11,[r4,: 64] +sub r2,r2,#24 +sub r4,r4,#24 +vst1.8 d0,[r2,: 64] +vst1.8 d1,[r4,: 64] +add r2,sp,#544 +add r4,r3,#144 +add r5,r3,#192 +vld1.8 {d0-d1},[r2,: 128] +vld1.8 {d2-d3},[r4,: 128]! +vld1.8 {d4-d5},[r5,: 128]! +vzip.i32 q1,q2 +vld1.8 {d6-d7},[r4,: 128]! +vld1.8 {d8-d9},[r5,: 128]! +vshl.i32 q5,q1,#1 +vzip.i32 q3,q4 +vshl.i32 q6,q2,#1 +vld1.8 {d14},[r4,: 64] +vshl.i32 q8,q3,#1 +vld1.8 {d15},[r5,: 64] +vshl.i32 q9,q4,#1 +vmul.i32 d21,d7,d1 +vtrn.32 d14,d15 +vmul.i32 q11,q4,q0 +vmul.i32 q0,q7,q0 +vmull.s32 q12,d2,d2 +vmlal.s32 q12,d11,d1 +vmlal.s32 q12,d12,d0 +vmlal.s32 q12,d13,d23 +vmlal.s32 q12,d16,d22 +vmlal.s32 q12,d7,d21 +vmull.s32 q10,d2,d11 +vmlal.s32 q10,d4,d1 +vmlal.s32 q10,d13,d0 +vmlal.s32 q10,d6,d23 +vmlal.s32 q10,d17,d22 +vmull.s32 q13,d10,d4 +vmlal.s32 q13,d11,d3 +vmlal.s32 q13,d13,d1 +vmlal.s32 q13,d16,d0 +vmlal.s32 q13,d17,d23 +vmlal.s32 q13,d8,d22 +vmull.s32 q1,d10,d5 +vmlal.s32 q1,d11,d4 +vmlal.s32 q1,d6,d1 +vmlal.s32 q1,d17,d0 +vmlal.s32 q1,d8,d23 +vmull.s32 q14,d10,d6 +vmlal.s32 q14,d11,d13 +vmlal.s32 q14,d4,d4 +vmlal.s32 q14,d17,d1 +vmlal.s32 q14,d18,d0 +vmlal.s32 q14,d9,d23 +vmull.s32 q11,d10,d7 +vmlal.s32 q11,d11,d6 +vmlal.s32 q11,d12,d5 +vmlal.s32 q11,d8,d1 +vmlal.s32 q11,d19,d0 +vmull.s32 q15,d10,d8 +vmlal.s32 q15,d11,d17 +vmlal.s32 q15,d12,d6 +vmlal.s32 q15,d13,d5 +vmlal.s32 q15,d19,d1 +vmlal.s32 q15,d14,d0 +vmull.s32 q2,d10,d9 +vmlal.s32 q2,d11,d8 +vmlal.s32 q2,d12,d7 +vmlal.s32 q2,d13,d6 +vmlal.s32 q2,d14,d1 +vmull.s32 q0,d15,d1 +vmlal.s32 q0,d10,d14 +vmlal.s32 q0,d11,d19 +vmlal.s32 q0,d12,d8 +vmlal.s32 q0,d13,d17 +vmlal.s32 q0,d6,d6 +add r2,sp,#512 +vld1.8 {d18-d19},[r2,: 128] +vmull.s32 q3,d16,d7 +vmlal.s32 q3,d10,d15 +vmlal.s32 q3,d11,d14 +vmlal.s32 q3,d12,d9 +vmlal.s32 q3,d13,d8 +add r2,sp,#528 +vld1.8 {d8-d9},[r2,: 128] +vadd.i64 q5,q12,q9 +vadd.i64 q6,q15,q9 +vshr.s64 q5,q5,#26 +vshr.s64 q6,q6,#26 +vadd.i64 q7,q10,q5 +vshl.i64 q5,q5,#26 +vadd.i64 q8,q7,q4 +vadd.i64 q2,q2,q6 +vshl.i64 q6,q6,#26 +vadd.i64 q10,q2,q4 +vsub.i64 q5,q12,q5 +vshr.s64 q8,q8,#25 +vsub.i64 q6,q15,q6 +vshr.s64 q10,q10,#25 +vadd.i64 q12,q13,q8 +vshl.i64 q8,q8,#25 +vadd.i64 q13,q12,q9 +vadd.i64 q0,q0,q10 +vsub.i64 q7,q7,q8 +vshr.s64 q8,q13,#26 +vshl.i64 q10,q10,#25 +vadd.i64 q13,q0,q9 +vadd.i64 q1,q1,q8 +vshl.i64 q8,q8,#26 +vadd.i64 q15,q1,q4 +vsub.i64 q2,q2,q10 +vshr.s64 q10,q13,#26 +vsub.i64 q8,q12,q8 +vshr.s64 q12,q15,#25 +vadd.i64 q3,q3,q10 +vshl.i64 q10,q10,#26 +vadd.i64 q13,q3,q4 +vadd.i64 q14,q14,q12 +add r2,r3,#144 +vshl.i64 q12,q12,#25 +add r4,r3,#192 +vadd.i64 q15,q14,q9 +add r2,r2,#8 +vsub.i64 q0,q0,q10 +add r4,r4,#8 +vshr.s64 q10,q13,#25 +vsub.i64 q1,q1,q12 +vshr.s64 q12,q15,#26 +vadd.i64 q13,q10,q10 +vadd.i64 q11,q11,q12 +vtrn.32 d16,d2 +vshl.i64 q12,q12,#26 +vtrn.32 d17,d3 +vadd.i64 q1,q11,q4 +vadd.i64 q4,q5,q13 +vst1.8 d16,[r2,: 64]! +vshl.i64 q5,q10,#4 +vst1.8 d17,[r4,: 64]! +vsub.i64 q8,q14,q12 +vshr.s64 q1,q1,#25 +vadd.i64 q4,q4,q5 +vadd.i64 q5,q6,q1 +vshl.i64 q1,q1,#25 +vadd.i64 q6,q5,q9 +vadd.i64 q4,q4,q10 +vshl.i64 q10,q10,#25 +vadd.i64 q9,q4,q9 +vsub.i64 q1,q11,q1 +vshr.s64 q6,q6,#26 +vsub.i64 q3,q3,q10 +vtrn.32 d16,d2 +vshr.s64 q9,q9,#26 +vtrn.32 d17,d3 +vadd.i64 q1,q2,q6 +vst1.8 d16,[r2,: 64] +vshl.i64 q2,q6,#26 +vst1.8 d17,[r4,: 64] +vadd.i64 q6,q7,q9 +vtrn.32 d0,d6 +vshl.i64 q7,q9,#26 +vtrn.32 d1,d7 +vsub.i64 q2,q5,q2 +add r2,r2,#16 +vsub.i64 q3,q4,q7 +vst1.8 d0,[r2,: 64] +add r4,r4,#16 +vst1.8 d1,[r4,: 64] +vtrn.32 d4,d2 +vtrn.32 d5,d3 +sub r2,r2,#8 +sub r4,r4,#8 +vtrn.32 d6,d12 +vtrn.32 d7,d13 +vst1.8 d4,[r2,: 64] +vst1.8 d5,[r4,: 64] +sub r2,r2,#24 +sub r4,r4,#24 +vst1.8 d6,[r2,: 64] +vst1.8 d7,[r4,: 64] +add r2,r3,#336 +add r4,r3,#288 +vld1.8 {d0-d1},[r2,: 128]! +vld1.8 {d2-d3},[r4,: 128]! +vadd.i32 q0,q0,q1 +vld1.8 {d2-d3},[r2,: 128]! +vld1.8 {d4-d5},[r4,: 128]! +vadd.i32 q1,q1,q2 +add r5,r3,#288 +vld1.8 {d4},[r2,: 64] +vld1.8 {d6},[r4,: 64] +vadd.i32 q2,q2,q3 +vst1.8 {d0-d1},[r5,: 128]! +vst1.8 {d2-d3},[r5,: 128]! +vst1.8 d4,[r5,: 64] +add r2,r3,#48 +add r4,r3,#144 +vld1.8 {d0-d1},[r4,: 128]! +vld1.8 {d2-d3},[r4,: 128]! +vld1.8 {d4},[r4,: 64] +add r4,r3,#288 +vld1.8 {d6-d7},[r4,: 128]! +vtrn.32 q0,q3 +vld1.8 {d8-d9},[r4,: 128]! +vshl.i32 q5,q0,#4 +vtrn.32 q1,q4 +vshl.i32 q6,q3,#4 +vadd.i32 q5,q5,q0 +vadd.i32 q6,q6,q3 +vshl.i32 q7,q1,#4 +vld1.8 {d5},[r4,: 64] +vshl.i32 q8,q4,#4 +vtrn.32 d4,d5 +vadd.i32 q7,q7,q1 +vadd.i32 q8,q8,q4 +vld1.8 {d18-d19},[r2,: 128]! +vshl.i32 q10,q2,#4 +vld1.8 {d22-d23},[r2,: 128]! +vadd.i32 q10,q10,q2 +vld1.8 {d24},[r2,: 64] +vadd.i32 q5,q5,q0 +add r2,r3,#240 +vld1.8 {d26-d27},[r2,: 128]! +vadd.i32 q6,q6,q3 +vld1.8 {d28-d29},[r2,: 128]! +vadd.i32 q8,q8,q4 +vld1.8 {d25},[r2,: 64] +vadd.i32 q10,q10,q2 +vtrn.32 q9,q13 +vadd.i32 q7,q7,q1 +vadd.i32 q5,q5,q0 +vtrn.32 q11,q14 +vadd.i32 q6,q6,q3 +add r2,sp,#560 +vadd.i32 q10,q10,q2 +vtrn.32 d24,d25 +vst1.8 {d12-d13},[r2,: 128] +vshl.i32 q6,q13,#1 +add r2,sp,#576 +vst1.8 {d20-d21},[r2,: 128] +vshl.i32 q10,q14,#1 +add r2,sp,#592 +vst1.8 {d12-d13},[r2,: 128] +vshl.i32 q15,q12,#1 +vadd.i32 q8,q8,q4 +vext.32 d10,d31,d30,#0 +vadd.i32 q7,q7,q1 +add r2,sp,#608 +vst1.8 {d16-d17},[r2,: 128] +vmull.s32 q8,d18,d5 +vmlal.s32 q8,d26,d4 +vmlal.s32 q8,d19,d9 +vmlal.s32 q8,d27,d3 +vmlal.s32 q8,d22,d8 +vmlal.s32 q8,d28,d2 +vmlal.s32 q8,d23,d7 +vmlal.s32 q8,d29,d1 +vmlal.s32 q8,d24,d6 +vmlal.s32 q8,d25,d0 +add r2,sp,#624 +vst1.8 {d14-d15},[r2,: 128] +vmull.s32 q2,d18,d4 +vmlal.s32 q2,d12,d9 +vmlal.s32 q2,d13,d8 +vmlal.s32 q2,d19,d3 +vmlal.s32 q2,d22,d2 +vmlal.s32 q2,d23,d1 +vmlal.s32 q2,d24,d0 +add r2,sp,#640 +vst1.8 {d20-d21},[r2,: 128] +vmull.s32 q7,d18,d9 +vmlal.s32 q7,d26,d3 +vmlal.s32 q7,d19,d8 +vmlal.s32 q7,d27,d2 +vmlal.s32 q7,d22,d7 +vmlal.s32 q7,d28,d1 +vmlal.s32 q7,d23,d6 +vmlal.s32 q7,d29,d0 +add r2,sp,#656 +vst1.8 {d10-d11},[r2,: 128] +vmull.s32 q5,d18,d3 +vmlal.s32 q5,d19,d2 +vmlal.s32 q5,d22,d1 +vmlal.s32 q5,d23,d0 +vmlal.s32 q5,d12,d8 +add r2,sp,#672 +vst1.8 {d16-d17},[r2,: 128] +vmull.s32 q4,d18,d8 +vmlal.s32 q4,d26,d2 +vmlal.s32 q4,d19,d7 +vmlal.s32 q4,d27,d1 +vmlal.s32 q4,d22,d6 +vmlal.s32 q4,d28,d0 +vmull.s32 q8,d18,d7 +vmlal.s32 q8,d26,d1 +vmlal.s32 q8,d19,d6 +vmlal.s32 q8,d27,d0 +add r2,sp,#576 +vld1.8 {d20-d21},[r2,: 128] +vmlal.s32 q7,d24,d21 +vmlal.s32 q7,d25,d20 +vmlal.s32 q4,d23,d21 +vmlal.s32 q4,d29,d20 +vmlal.s32 q8,d22,d21 +vmlal.s32 q8,d28,d20 +vmlal.s32 q5,d24,d20 +add r2,sp,#576 +vst1.8 {d14-d15},[r2,: 128] +vmull.s32 q7,d18,d6 +vmlal.s32 q7,d26,d0 +add r2,sp,#656 +vld1.8 {d30-d31},[r2,: 128] +vmlal.s32 q2,d30,d21 +vmlal.s32 q7,d19,d21 +vmlal.s32 q7,d27,d20 +add r2,sp,#624 +vld1.8 {d26-d27},[r2,: 128] +vmlal.s32 q4,d25,d27 +vmlal.s32 q8,d29,d27 +vmlal.s32 q8,d25,d26 +vmlal.s32 q7,d28,d27 +vmlal.s32 q7,d29,d26 +add r2,sp,#608 +vld1.8 {d28-d29},[r2,: 128] +vmlal.s32 q4,d24,d29 +vmlal.s32 q8,d23,d29 +vmlal.s32 q8,d24,d28 +vmlal.s32 q7,d22,d29 +vmlal.s32 q7,d23,d28 +add r2,sp,#608 +vst1.8 {d8-d9},[r2,: 128] +add r2,sp,#560 +vld1.8 {d8-d9},[r2,: 128] +vmlal.s32 q7,d24,d9 +vmlal.s32 q7,d25,d31 +vmull.s32 q1,d18,d2 +vmlal.s32 q1,d19,d1 +vmlal.s32 q1,d22,d0 +vmlal.s32 q1,d24,d27 +vmlal.s32 q1,d23,d20 +vmlal.s32 q1,d12,d7 +vmlal.s32 q1,d13,d6 +vmull.s32 q6,d18,d1 +vmlal.s32 q6,d19,d0 +vmlal.s32 q6,d23,d27 +vmlal.s32 q6,d22,d20 +vmlal.s32 q6,d24,d26 +vmull.s32 q0,d18,d0 +vmlal.s32 q0,d22,d27 +vmlal.s32 q0,d23,d26 +vmlal.s32 q0,d24,d31 +vmlal.s32 q0,d19,d20 +add r2,sp,#640 +vld1.8 {d18-d19},[r2,: 128] +vmlal.s32 q2,d18,d7 +vmlal.s32 q2,d19,d6 +vmlal.s32 q5,d18,d6 +vmlal.s32 q5,d19,d21 +vmlal.s32 q1,d18,d21 +vmlal.s32 q1,d19,d29 +vmlal.s32 q0,d18,d28 +vmlal.s32 q0,d19,d9 +vmlal.s32 q6,d18,d29 +vmlal.s32 q6,d19,d28 +add r2,sp,#592 +vld1.8 {d18-d19},[r2,: 128] +add r2,sp,#512 +vld1.8 {d22-d23},[r2,: 128] +vmlal.s32 q5,d19,d7 +vmlal.s32 q0,d18,d21 +vmlal.s32 q0,d19,d29 +vmlal.s32 q6,d18,d6 +add r2,sp,#528 +vld1.8 {d6-d7},[r2,: 128] +vmlal.s32 q6,d19,d21 +add r2,sp,#576 +vld1.8 {d18-d19},[r2,: 128] +vmlal.s32 q0,d30,d8 +add r2,sp,#672 +vld1.8 {d20-d21},[r2,: 128] +vmlal.s32 q5,d30,d29 +add r2,sp,#608 +vld1.8 {d24-d25},[r2,: 128] +vmlal.s32 q1,d30,d28 +vadd.i64 q13,q0,q11 +vadd.i64 q14,q5,q11 +vmlal.s32 q6,d30,d9 +vshr.s64 q4,q13,#26 +vshr.s64 q13,q14,#26 +vadd.i64 q7,q7,q4 +vshl.i64 q4,q4,#26 +vadd.i64 q14,q7,q3 +vadd.i64 q9,q9,q13 +vshl.i64 q13,q13,#26 +vadd.i64 q15,q9,q3 +vsub.i64 q0,q0,q4 +vshr.s64 q4,q14,#25 +vsub.i64 q5,q5,q13 +vshr.s64 q13,q15,#25 +vadd.i64 q6,q6,q4 +vshl.i64 q4,q4,#25 +vadd.i64 q14,q6,q11 +vadd.i64 q2,q2,q13 +vsub.i64 q4,q7,q4 +vshr.s64 q7,q14,#26 +vshl.i64 q13,q13,#25 +vadd.i64 q14,q2,q11 +vadd.i64 q8,q8,q7 +vshl.i64 q7,q7,#26 +vadd.i64 q15,q8,q3 +vsub.i64 q9,q9,q13 +vshr.s64 q13,q14,#26 +vsub.i64 q6,q6,q7 +vshr.s64 q7,q15,#25 +vadd.i64 q10,q10,q13 +vshl.i64 q13,q13,#26 +vadd.i64 q14,q10,q3 +vadd.i64 q1,q1,q7 +add r2,r3,#240 +vshl.i64 q7,q7,#25 +add r4,r3,#144 +vadd.i64 q15,q1,q11 +add r2,r2,#8 +vsub.i64 q2,q2,q13 +add r4,r4,#8 +vshr.s64 q13,q14,#25 +vsub.i64 q7,q8,q7 +vshr.s64 q8,q15,#26 +vadd.i64 q14,q13,q13 +vadd.i64 q12,q12,q8 +vtrn.32 d12,d14 +vshl.i64 q8,q8,#26 +vtrn.32 d13,d15 +vadd.i64 q3,q12,q3 +vadd.i64 q0,q0,q14 +vst1.8 d12,[r2,: 64]! +vshl.i64 q7,q13,#4 +vst1.8 d13,[r4,: 64]! +vsub.i64 q1,q1,q8 +vshr.s64 q3,q3,#25 +vadd.i64 q0,q0,q7 +vadd.i64 q5,q5,q3 +vshl.i64 q3,q3,#25 +vadd.i64 q6,q5,q11 +vadd.i64 q0,q0,q13 +vshl.i64 q7,q13,#25 +vadd.i64 q8,q0,q11 +vsub.i64 q3,q12,q3 +vshr.s64 q6,q6,#26 +vsub.i64 q7,q10,q7 +vtrn.32 d2,d6 +vshr.s64 q8,q8,#26 +vtrn.32 d3,d7 +vadd.i64 q3,q9,q6 +vst1.8 d2,[r2,: 64] +vshl.i64 q6,q6,#26 +vst1.8 d3,[r4,: 64] +vadd.i64 q1,q4,q8 +vtrn.32 d4,d14 +vshl.i64 q4,q8,#26 +vtrn.32 d5,d15 +vsub.i64 q5,q5,q6 +add r2,r2,#16 +vsub.i64 q0,q0,q4 +vst1.8 d4,[r2,: 64] +add r4,r4,#16 +vst1.8 d5,[r4,: 64] +vtrn.32 d10,d6 +vtrn.32 d11,d7 +sub r2,r2,#8 +sub r4,r4,#8 +vtrn.32 d0,d2 +vtrn.32 d1,d3 +vst1.8 d10,[r2,: 64] +vst1.8 d11,[r4,: 64] +sub r2,r2,#24 +sub r4,r4,#24 +vst1.8 d0,[r2,: 64] +vst1.8 d1,[r4,: 64] +ldr r2,[sp,#488] +ldr r4,[sp,#492] +subs r5,r2,#1 +bge ._mainloop +add r1,r3,#144 +add r2,r3,#336 +vld1.8 {d0-d1},[r1,: 128]! +vld1.8 {d2-d3},[r1,: 128]! +vld1.8 {d4},[r1,: 64] +vst1.8 {d0-d1},[r2,: 128]! +vst1.8 {d2-d3},[r2,: 128]! +vst1.8 d4,[r2,: 64] +ldr r1,=0 +._invertloop: +add r2,r3,#144 +ldr r4,=0 +ldr r5,=2 +cmp r1,#1 +ldreq r5,=1 +addeq r2,r3,#336 +addeq r4,r3,#48 +cmp r1,#2 +ldreq r5,=1 +addeq r2,r3,#48 +cmp r1,#3 +ldreq r5,=5 +addeq r4,r3,#336 +cmp r1,#4 +ldreq r5,=10 +cmp r1,#5 +ldreq r5,=20 +cmp r1,#6 +ldreq r5,=10 +addeq r2,r3,#336 +addeq r4,r3,#336 +cmp r1,#7 +ldreq r5,=50 +cmp r1,#8 +ldreq r5,=100 +cmp r1,#9 +ldreq r5,=50 +addeq r2,r3,#336 +cmp r1,#10 +ldreq r5,=5 +addeq r2,r3,#48 +cmp r1,#11 +ldreq r5,=0 +addeq r2,r3,#96 +add r6,r3,#144 +add r7,r3,#288 +vld1.8 {d0-d1},[r6,: 128]! +vld1.8 {d2-d3},[r6,: 128]! +vld1.8 {d4},[r6,: 64] +vst1.8 {d0-d1},[r7,: 128]! +vst1.8 {d2-d3},[r7,: 128]! +vst1.8 d4,[r7,: 64] +cmp r5,#0 +beq ._skipsquaringloop +._squaringloop: +add r6,r3,#288 +add r7,r3,#288 +add r8,r3,#288 +vmov.i32 q0,#19 +vmov.i32 q1,#0 +vmov.i32 q2,#1 +vzip.i32 q1,q2 +vld1.8 {d4-d5},[r7,: 128]! +vld1.8 {d6-d7},[r7,: 128]! +vld1.8 {d9},[r7,: 64] +vld1.8 {d10-d11},[r6,: 128]! +add r7,sp,#416 +vld1.8 {d12-d13},[r6,: 128]! +vmul.i32 q7,q2,q0 +vld1.8 {d8},[r6,: 64] +vext.32 d17,d11,d10,#1 +vmul.i32 q9,q3,q0 +vext.32 d16,d10,d8,#1 +vshl.u32 q10,q5,q1 +vext.32 d22,d14,d4,#1 +vext.32 d24,d18,d6,#1 +vshl.u32 q13,q6,q1 +vshl.u32 d28,d8,d2 +vrev64.i32 d22,d22 +vmul.i32 d1,d9,d1 +vrev64.i32 d24,d24 +vext.32 d29,d8,d13,#1 +vext.32 d0,d1,d9,#1 +vrev64.i32 d0,d0 +vext.32 d2,d9,d1,#1 +vext.32 d23,d15,d5,#1 +vmull.s32 q4,d20,d4 +vrev64.i32 d23,d23 +vmlal.s32 q4,d21,d1 +vrev64.i32 d2,d2 +vmlal.s32 q4,d26,d19 +vext.32 d3,d5,d15,#1 +vmlal.s32 q4,d27,d18 +vrev64.i32 d3,d3 +vmlal.s32 q4,d28,d15 +vext.32 d14,d12,d11,#1 +vmull.s32 q5,d16,d23 +vext.32 d15,d13,d12,#1 +vmlal.s32 q5,d17,d4 +vst1.8 d8,[r7,: 64]! +vmlal.s32 q5,d14,d1 +vext.32 d12,d9,d8,#0 +vmlal.s32 q5,d15,d19 +vmov.i64 d13,#0 +vmlal.s32 q5,d29,d18 +vext.32 d25,d19,d7,#1 +vmlal.s32 q6,d20,d5 +vrev64.i32 d25,d25 +vmlal.s32 q6,d21,d4 +vst1.8 d11,[r7,: 64]! +vmlal.s32 q6,d26,d1 +vext.32 d9,d10,d10,#0 +vmlal.s32 q6,d27,d19 +vmov.i64 d8,#0 +vmlal.s32 q6,d28,d18 +vmlal.s32 q4,d16,d24 +vmlal.s32 q4,d17,d5 +vmlal.s32 q4,d14,d4 +vst1.8 d12,[r7,: 64]! +vmlal.s32 q4,d15,d1 +vext.32 d10,d13,d12,#0 +vmlal.s32 q4,d29,d19 +vmov.i64 d11,#0 +vmlal.s32 q5,d20,d6 +vmlal.s32 q5,d21,d5 +vmlal.s32 q5,d26,d4 +vext.32 d13,d8,d8,#0 +vmlal.s32 q5,d27,d1 +vmov.i64 d12,#0 +vmlal.s32 q5,d28,d19 +vst1.8 d9,[r7,: 64]! +vmlal.s32 q6,d16,d25 +vmlal.s32 q6,d17,d6 +vst1.8 d10,[r7,: 64] +vmlal.s32 q6,d14,d5 +vext.32 d8,d11,d10,#0 +vmlal.s32 q6,d15,d4 +vmov.i64 d9,#0 +vmlal.s32 q6,d29,d1 +vmlal.s32 q4,d20,d7 +vmlal.s32 q4,d21,d6 +vmlal.s32 q4,d26,d5 +vext.32 d11,d12,d12,#0 +vmlal.s32 q4,d27,d4 +vmov.i64 d10,#0 +vmlal.s32 q4,d28,d1 +vmlal.s32 q5,d16,d0 +sub r6,r7,#32 +vmlal.s32 q5,d17,d7 +vmlal.s32 q5,d14,d6 +vext.32 d30,d9,d8,#0 +vmlal.s32 q5,d15,d5 +vld1.8 {d31},[r6,: 64]! +vmlal.s32 q5,d29,d4 +vmlal.s32 q15,d20,d0 +vext.32 d0,d6,d18,#1 +vmlal.s32 q15,d21,d25 +vrev64.i32 d0,d0 +vmlal.s32 q15,d26,d24 +vext.32 d1,d7,d19,#1 +vext.32 d7,d10,d10,#0 +vmlal.s32 q15,d27,d23 +vrev64.i32 d1,d1 +vld1.8 {d6},[r6,: 64] +vmlal.s32 q15,d28,d22 +vmlal.s32 q3,d16,d4 +add r6,r6,#24 +vmlal.s32 q3,d17,d2 +vext.32 d4,d31,d30,#0 +vmov d17,d11 +vmlal.s32 q3,d14,d1 +vext.32 d11,d13,d13,#0 +vext.32 d13,d30,d30,#0 +vmlal.s32 q3,d15,d0 +vext.32 d1,d8,d8,#0 +vmlal.s32 q3,d29,d3 +vld1.8 {d5},[r6,: 64] +sub r6,r6,#16 +vext.32 d10,d6,d6,#0 +vmov.i32 q1,#0xffffffff +vshl.i64 q4,q1,#25 +add r7,sp,#512 +vld1.8 {d14-d15},[r7,: 128] +vadd.i64 q9,q2,q7 +vshl.i64 q1,q1,#26 +vshr.s64 q10,q9,#26 +vld1.8 {d0},[r6,: 64]! +vadd.i64 q5,q5,q10 +vand q9,q9,q1 +vld1.8 {d16},[r6,: 64]! +add r6,sp,#528 +vld1.8 {d20-d21},[r6,: 128] +vadd.i64 q11,q5,q10 +vsub.i64 q2,q2,q9 +vshr.s64 q9,q11,#25 +vext.32 d12,d5,d4,#0 +vand q11,q11,q4 +vadd.i64 q0,q0,q9 +vmov d19,d7 +vadd.i64 q3,q0,q7 +vsub.i64 q5,q5,q11 +vshr.s64 q11,q3,#26 +vext.32 d18,d11,d10,#0 +vand q3,q3,q1 +vadd.i64 q8,q8,q11 +vadd.i64 q11,q8,q10 +vsub.i64 q0,q0,q3 +vshr.s64 q3,q11,#25 +vand q11,q11,q4 +vadd.i64 q3,q6,q3 +vadd.i64 q6,q3,q7 +vsub.i64 q8,q8,q11 +vshr.s64 q11,q6,#26 +vand q6,q6,q1 +vadd.i64 q9,q9,q11 +vadd.i64 d25,d19,d21 +vsub.i64 q3,q3,q6 +vshr.s64 d23,d25,#25 +vand q4,q12,q4 +vadd.i64 d21,d23,d23 +vshl.i64 d25,d23,#4 +vadd.i64 d21,d21,d23 +vadd.i64 d25,d25,d21 +vadd.i64 d4,d4,d25 +vzip.i32 q0,q8 +vadd.i64 d12,d4,d14 +add r6,r8,#8 +vst1.8 d0,[r6,: 64] +vsub.i64 d19,d19,d9 +add r6,r6,#16 +vst1.8 d16,[r6,: 64] +vshr.s64 d22,d12,#26 +vand q0,q6,q1 +vadd.i64 d10,d10,d22 +vzip.i32 q3,q9 +vsub.i64 d4,d4,d0 +sub r6,r6,#8 +vst1.8 d6,[r6,: 64] +add r6,r6,#16 +vst1.8 d18,[r6,: 64] +vzip.i32 q2,q5 +sub r6,r6,#32 +vst1.8 d4,[r6,: 64] +subs r5,r5,#1 +bhi ._squaringloop +._skipsquaringloop: +mov r2,r2 +add r5,r3,#288 +add r6,r3,#144 +vmov.i32 q0,#19 +vmov.i32 q1,#0 +vmov.i32 q2,#1 +vzip.i32 q1,q2 +vld1.8 {d4-d5},[r5,: 128]! +vld1.8 {d6-d7},[r5,: 128]! +vld1.8 {d9},[r5,: 64] +vld1.8 {d10-d11},[r2,: 128]! +add r5,sp,#416 +vld1.8 {d12-d13},[r2,: 128]! +vmul.i32 q7,q2,q0 +vld1.8 {d8},[r2,: 64] +vext.32 d17,d11,d10,#1 +vmul.i32 q9,q3,q0 +vext.32 d16,d10,d8,#1 +vshl.u32 q10,q5,q1 +vext.32 d22,d14,d4,#1 +vext.32 d24,d18,d6,#1 +vshl.u32 q13,q6,q1 +vshl.u32 d28,d8,d2 +vrev64.i32 d22,d22 +vmul.i32 d1,d9,d1 +vrev64.i32 d24,d24 +vext.32 d29,d8,d13,#1 +vext.32 d0,d1,d9,#1 +vrev64.i32 d0,d0 +vext.32 d2,d9,d1,#1 +vext.32 d23,d15,d5,#1 +vmull.s32 q4,d20,d4 +vrev64.i32 d23,d23 +vmlal.s32 q4,d21,d1 +vrev64.i32 d2,d2 +vmlal.s32 q4,d26,d19 +vext.32 d3,d5,d15,#1 +vmlal.s32 q4,d27,d18 +vrev64.i32 d3,d3 +vmlal.s32 q4,d28,d15 +vext.32 d14,d12,d11,#1 +vmull.s32 q5,d16,d23 +vext.32 d15,d13,d12,#1 +vmlal.s32 q5,d17,d4 +vst1.8 d8,[r5,: 64]! +vmlal.s32 q5,d14,d1 +vext.32 d12,d9,d8,#0 +vmlal.s32 q5,d15,d19 +vmov.i64 d13,#0 +vmlal.s32 q5,d29,d18 +vext.32 d25,d19,d7,#1 +vmlal.s32 q6,d20,d5 +vrev64.i32 d25,d25 +vmlal.s32 q6,d21,d4 +vst1.8 d11,[r5,: 64]! +vmlal.s32 q6,d26,d1 +vext.32 d9,d10,d10,#0 +vmlal.s32 q6,d27,d19 +vmov.i64 d8,#0 +vmlal.s32 q6,d28,d18 +vmlal.s32 q4,d16,d24 +vmlal.s32 q4,d17,d5 +vmlal.s32 q4,d14,d4 +vst1.8 d12,[r5,: 64]! +vmlal.s32 q4,d15,d1 +vext.32 d10,d13,d12,#0 +vmlal.s32 q4,d29,d19 +vmov.i64 d11,#0 +vmlal.s32 q5,d20,d6 +vmlal.s32 q5,d21,d5 +vmlal.s32 q5,d26,d4 +vext.32 d13,d8,d8,#0 +vmlal.s32 q5,d27,d1 +vmov.i64 d12,#0 +vmlal.s32 q5,d28,d19 +vst1.8 d9,[r5,: 64]! +vmlal.s32 q6,d16,d25 +vmlal.s32 q6,d17,d6 +vst1.8 d10,[r5,: 64] +vmlal.s32 q6,d14,d5 +vext.32 d8,d11,d10,#0 +vmlal.s32 q6,d15,d4 +vmov.i64 d9,#0 +vmlal.s32 q6,d29,d1 +vmlal.s32 q4,d20,d7 +vmlal.s32 q4,d21,d6 +vmlal.s32 q4,d26,d5 +vext.32 d11,d12,d12,#0 +vmlal.s32 q4,d27,d4 +vmov.i64 d10,#0 +vmlal.s32 q4,d28,d1 +vmlal.s32 q5,d16,d0 +sub r2,r5,#32 +vmlal.s32 q5,d17,d7 +vmlal.s32 q5,d14,d6 +vext.32 d30,d9,d8,#0 +vmlal.s32 q5,d15,d5 +vld1.8 {d31},[r2,: 64]! +vmlal.s32 q5,d29,d4 +vmlal.s32 q15,d20,d0 +vext.32 d0,d6,d18,#1 +vmlal.s32 q15,d21,d25 +vrev64.i32 d0,d0 +vmlal.s32 q15,d26,d24 +vext.32 d1,d7,d19,#1 +vext.32 d7,d10,d10,#0 +vmlal.s32 q15,d27,d23 +vrev64.i32 d1,d1 +vld1.8 {d6},[r2,: 64] +vmlal.s32 q15,d28,d22 +vmlal.s32 q3,d16,d4 +add r2,r2,#24 +vmlal.s32 q3,d17,d2 +vext.32 d4,d31,d30,#0 +vmov d17,d11 +vmlal.s32 q3,d14,d1 +vext.32 d11,d13,d13,#0 +vext.32 d13,d30,d30,#0 +vmlal.s32 q3,d15,d0 +vext.32 d1,d8,d8,#0 +vmlal.s32 q3,d29,d3 +vld1.8 {d5},[r2,: 64] +sub r2,r2,#16 +vext.32 d10,d6,d6,#0 +vmov.i32 q1,#0xffffffff +vshl.i64 q4,q1,#25 +add r5,sp,#512 +vld1.8 {d14-d15},[r5,: 128] +vadd.i64 q9,q2,q7 +vshl.i64 q1,q1,#26 +vshr.s64 q10,q9,#26 +vld1.8 {d0},[r2,: 64]! +vadd.i64 q5,q5,q10 +vand q9,q9,q1 +vld1.8 {d16},[r2,: 64]! +add r2,sp,#528 +vld1.8 {d20-d21},[r2,: 128] +vadd.i64 q11,q5,q10 +vsub.i64 q2,q2,q9 +vshr.s64 q9,q11,#25 +vext.32 d12,d5,d4,#0 +vand q11,q11,q4 +vadd.i64 q0,q0,q9 +vmov d19,d7 +vadd.i64 q3,q0,q7 +vsub.i64 q5,q5,q11 +vshr.s64 q11,q3,#26 +vext.32 d18,d11,d10,#0 +vand q3,q3,q1 +vadd.i64 q8,q8,q11 +vadd.i64 q11,q8,q10 +vsub.i64 q0,q0,q3 +vshr.s64 q3,q11,#25 +vand q11,q11,q4 +vadd.i64 q3,q6,q3 +vadd.i64 q6,q3,q7 +vsub.i64 q8,q8,q11 +vshr.s64 q11,q6,#26 +vand q6,q6,q1 +vadd.i64 q9,q9,q11 +vadd.i64 d25,d19,d21 +vsub.i64 q3,q3,q6 +vshr.s64 d23,d25,#25 +vand q4,q12,q4 +vadd.i64 d21,d23,d23 +vshl.i64 d25,d23,#4 +vadd.i64 d21,d21,d23 +vadd.i64 d25,d25,d21 +vadd.i64 d4,d4,d25 +vzip.i32 q0,q8 +vadd.i64 d12,d4,d14 +add r2,r6,#8 +vst1.8 d0,[r2,: 64] +vsub.i64 d19,d19,d9 +add r2,r2,#16 +vst1.8 d16,[r2,: 64] +vshr.s64 d22,d12,#26 +vand q0,q6,q1 +vadd.i64 d10,d10,d22 +vzip.i32 q3,q9 +vsub.i64 d4,d4,d0 +sub r2,r2,#8 +vst1.8 d6,[r2,: 64] +add r2,r2,#16 +vst1.8 d18,[r2,: 64] +vzip.i32 q2,q5 +sub r2,r2,#32 +vst1.8 d4,[r2,: 64] +cmp r4,#0 +beq ._skippostcopy +add r2,r3,#144 +mov r4,r4 +vld1.8 {d0-d1},[r2,: 128]! +vld1.8 {d2-d3},[r2,: 128]! +vld1.8 {d4},[r2,: 64] +vst1.8 {d0-d1},[r4,: 128]! +vst1.8 {d2-d3},[r4,: 128]! +vst1.8 d4,[r4,: 64] +._skippostcopy: +cmp r1,#1 +bne ._skipfinalcopy +add r2,r3,#288 +add r4,r3,#144 +vld1.8 {d0-d1},[r2,: 128]! +vld1.8 {d2-d3},[r2,: 128]! +vld1.8 {d4},[r2,: 64] +vst1.8 {d0-d1},[r4,: 128]! +vst1.8 {d2-d3},[r4,: 128]! +vst1.8 d4,[r4,: 64] +._skipfinalcopy: +add r1,r1,#1 +cmp r1,#12 +blo ._invertloop +add r1,r3,#144 +ldr r2,[r1],#4 +ldr r3,[r1],#4 +ldr r4,[r1],#4 +ldr r5,[r1],#4 +ldr r6,[r1],#4 +ldr r7,[r1],#4 +ldr r8,[r1],#4 +ldr r9,[r1],#4 +ldr r10,[r1],#4 +ldr r1,[r1] +add r11,r1,r1,LSL #4 +add r11,r11,r1,LSL #1 +add r11,r11,#16777216 +mov r11,r11,ASR #25 +add r11,r11,r2 +mov r11,r11,ASR #26 +add r11,r11,r3 +mov r11,r11,ASR #25 +add r11,r11,r4 +mov r11,r11,ASR #26 +add r11,r11,r5 +mov r11,r11,ASR #25 +add r11,r11,r6 +mov r11,r11,ASR #26 +add r11,r11,r7 +mov r11,r11,ASR #25 +add r11,r11,r8 +mov r11,r11,ASR #26 +add r11,r11,r9 +mov r11,r11,ASR #25 +add r11,r11,r10 +mov r11,r11,ASR #26 +add r11,r11,r1 +mov r11,r11,ASR #25 +add r2,r2,r11 +add r2,r2,r11,LSL #1 +add r2,r2,r11,LSL #4 +mov r11,r2,ASR #26 +add r3,r3,r11 +sub r2,r2,r11,LSL #26 +mov r11,r3,ASR #25 +add r4,r4,r11 +sub r3,r3,r11,LSL #25 +mov r11,r4,ASR #26 +add r5,r5,r11 +sub r4,r4,r11,LSL #26 +mov r11,r5,ASR #25 +add r6,r6,r11 +sub r5,r5,r11,LSL #25 +mov r11,r6,ASR #26 +add r7,r7,r11 +sub r6,r6,r11,LSL #26 +mov r11,r7,ASR #25 +add r8,r8,r11 +sub r7,r7,r11,LSL #25 +mov r11,r8,ASR #26 +add r9,r9,r11 +sub r8,r8,r11,LSL #26 +mov r11,r9,ASR #25 +add r10,r10,r11 +sub r9,r9,r11,LSL #25 +mov r11,r10,ASR #26 +add r1,r1,r11 +sub r10,r10,r11,LSL #26 +mov r11,r1,ASR #25 +sub r1,r1,r11,LSL #25 +add r2,r2,r3,LSL #26 +mov r3,r3,LSR #6 +add r3,r3,r4,LSL #19 +mov r4,r4,LSR #13 +add r4,r4,r5,LSL #13 +mov r5,r5,LSR #19 +add r5,r5,r6,LSL #6 +add r6,r7,r8,LSL #25 +mov r7,r8,LSR #7 +add r7,r7,r9,LSL #19 +mov r8,r9,LSR #13 +add r8,r8,r10,LSL #12 +mov r9,r10,LSR #20 +add r1,r9,r1,LSL #6 +str r2,[r0],#4 +str r3,[r0],#4 +str r4,[r0],#4 +str r5,[r0],#4 +str r6,[r0],#4 +str r7,[r0],#4 +str r8,[r0],#4 +str r1,[r0] +ldrd r4,[sp,#0] +ldrd r6,[sp,#8] +ldrd r8,[sp,#16] +ldrd r10,[sp,#24] +ldr r12,[sp,#480] +ldr r14,[sp,#484] +ldr r0,=0 +mov sp,r12 +vpop {q4,q5,q6,q7} +bx lr + +#endif /* !OPENSSL_NO_ASM && OPENSSL_ARM && __ELF__ */ diff --git a/http/vendor/ring/crypto/curve25519/curve25519.c b/http/vendor/ring/crypto/curve25519/curve25519.c new file mode 100644 index 0000000..99d7d7f --- /dev/null +++ b/http/vendor/ring/crypto/curve25519/curve25519.c @@ -0,0 +1,1924 @@ +// Copyright 2020 The BoringSSL Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Some of this code is taken from the ref10 version of Ed25519 in SUPERCOP +// 20141124 (http://bench.cr.yp.to/supercop.html). That code is released as +// public domain. Other parts have been replaced to call into code generated by +// Fiat (https://github.com/mit-plv/fiat-crypto) in //third_party/fiat. +// +// The field functions are shared by Ed25519 and X25519 where possible. + +#include + +#include "internal.h" +#include "../internal.h" + +#if defined(_MSC_VER) && !defined(__clang__) +// '=': conversion from 'int64_t' to 'int32_t', possible loss of data +#pragma warning(disable: 4242) +// '=': conversion from 'int32_t' to 'uint8_t', possible loss of data +#pragma warning(disable: 4244) +#endif + +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic ignored "-Winline" +#endif + +// Various pre-computed constants. +#include "./curve25519_tables.h" + +#if defined(BORINGSSL_HAS_UINT128) +#if defined(__GNUC__) +#pragma GCC diagnostic ignored "-Wpedantic" +#endif +#include "../../third_party/fiat/curve25519_64.h" +#elif defined(OPENSSL_64_BIT) +#include "../../third_party/fiat/curve25519_64_msvc.h" +#else +#include "../../third_party/fiat/curve25519_32.h" +#endif + + +// Low-level intrinsic operations + +static uint64_t load_3(const uint8_t *in) { + uint64_t result; + result = (uint64_t)in[0]; + result |= ((uint64_t)in[1]) << 8; + result |= ((uint64_t)in[2]) << 16; + return result; +} + +static uint64_t load_4(const uint8_t *in) { + uint64_t result; + result = (uint64_t)in[0]; + result |= ((uint64_t)in[1]) << 8; + result |= ((uint64_t)in[2]) << 16; + result |= ((uint64_t)in[3]) << 24; + return result; +} + + +// Field operations. + +#if defined(OPENSSL_64_BIT) + +// assert_fe asserts that |f| satisfies bounds: +// +// [[0x0 ~> 0x8cccccccccccc], +// [0x0 ~> 0x8cccccccccccc], +// [0x0 ~> 0x8cccccccccccc], +// [0x0 ~> 0x8cccccccccccc], +// [0x0 ~> 0x8cccccccccccc]] +// +// See comments in curve25519_64.h for which functions use these bounds for +// inputs or outputs. +#define assert_fe(f) \ + do { \ + for (unsigned _assert_fe_i = 0; _assert_fe_i < 5; _assert_fe_i++) { \ + declassify_assert(f[_assert_fe_i] <= UINT64_C(0x8cccccccccccc)); \ + } \ + } while (0) + +// assert_fe_loose asserts that |f| satisfies bounds: +// +// [[0x0 ~> 0x1a666666666664], +// [0x0 ~> 0x1a666666666664], +// [0x0 ~> 0x1a666666666664], +// [0x0 ~> 0x1a666666666664], +// [0x0 ~> 0x1a666666666664]] +// +// See comments in curve25519_64.h for which functions use these bounds for +// inputs or outputs. +#define assert_fe_loose(f) \ + do { \ + for (unsigned _assert_fe_i = 0; _assert_fe_i < 5; _assert_fe_i++) { \ + declassify_assert(f[_assert_fe_i] <= UINT64_C(0x1a666666666664)); \ + } \ + } while (0) + +#else + +// assert_fe asserts that |f| satisfies bounds: +// +// [[0x0 ~> 0x4666666], [0x0 ~> 0x2333333], +// [0x0 ~> 0x4666666], [0x0 ~> 0x2333333], +// [0x0 ~> 0x4666666], [0x0 ~> 0x2333333], +// [0x0 ~> 0x4666666], [0x0 ~> 0x2333333], +// [0x0 ~> 0x4666666], [0x0 ~> 0x2333333]] +// +// See comments in curve25519_32.h for which functions use these bounds for +// inputs or outputs. +#define assert_fe(f) \ + do { \ + for (unsigned _assert_fe_i = 0; _assert_fe_i < 10; _assert_fe_i++) { \ + declassify_assert(f[_assert_fe_i] <= \ + ((_assert_fe_i & 1) ? 0x2333333u : 0x4666666u)); \ + } \ + } while (0) + +// assert_fe_loose asserts that |f| satisfies bounds: +// +// [[0x0 ~> 0xd333332], [0x0 ~> 0x6999999], +// [0x0 ~> 0xd333332], [0x0 ~> 0x6999999], +// [0x0 ~> 0xd333332], [0x0 ~> 0x6999999], +// [0x0 ~> 0xd333332], [0x0 ~> 0x6999999], +// [0x0 ~> 0xd333332], [0x0 ~> 0x6999999]] +// +// See comments in curve25519_32.h for which functions use these bounds for +// inputs or outputs. +#define assert_fe_loose(f) \ + do { \ + for (unsigned _assert_fe_i = 0; _assert_fe_i < 10; _assert_fe_i++) { \ + declassify_assert(f[_assert_fe_i] <= \ + ((_assert_fe_i & 1) ? 0x6999999u : 0xd333332u)); \ + } \ + } while (0) + +#endif // OPENSSL_64_BIT + +OPENSSL_STATIC_ASSERT(sizeof(fe) == sizeof(fe_limb_t) * FE_NUM_LIMBS, + "fe_limb_t[FE_NUM_LIMBS] is inconsistent with fe"); + +static void fe_frombytes_strict(fe *h, const uint8_t s[32]) { + // |fiat_25519_from_bytes| requires the top-most bit be clear. + declassify_assert((s[31] & 0x80) == 0); + fiat_25519_from_bytes(h->v, s); + assert_fe(h->v); +} + +static void fe_frombytes(fe *h, const uint8_t s[32]) { + uint8_t s_copy[32]; + OPENSSL_memcpy(s_copy, s, 32); + s_copy[31] &= 0x7f; + fe_frombytes_strict(h, s_copy); +} + +static void fe_tobytes(uint8_t s[32], const fe *f) { + assert_fe(f->v); + fiat_25519_to_bytes(s, f->v); +} + +// h = 0 +static void fe_0(fe *h) { + OPENSSL_memset(h, 0, sizeof(fe)); +} + +#if defined(OPENSSL_SMALL) + +static void fe_loose_0(fe_loose *h) { + OPENSSL_memset(h, 0, sizeof(fe_loose)); +} + +#endif + +// h = 1 +static void fe_1(fe *h) { + OPENSSL_memset(h, 0, sizeof(fe)); + h->v[0] = 1; +} + +#if defined(OPENSSL_SMALL) + +static void fe_loose_1(fe_loose *h) { + OPENSSL_memset(h, 0, sizeof(fe_loose)); + h->v[0] = 1; +} + +#endif + +// h = f + g +// Can overlap h with f or g. +static void fe_add(fe_loose *h, const fe *f, const fe *g) { + assert_fe(f->v); + assert_fe(g->v); + fiat_25519_add(h->v, f->v, g->v); + assert_fe_loose(h->v); +} + +// h = f - g +// Can overlap h with f or g. +static void fe_sub(fe_loose *h, const fe *f, const fe *g) { + assert_fe(f->v); + assert_fe(g->v); + fiat_25519_sub(h->v, f->v, g->v); + assert_fe_loose(h->v); +} + +static void fe_carry(fe *h, const fe_loose* f) { + assert_fe_loose(f->v); + fiat_25519_carry(h->v, f->v); + assert_fe(h->v); +} + +static void fe_mul_impl(fe_limb_t out[FE_NUM_LIMBS], + const fe_limb_t in1[FE_NUM_LIMBS], + const fe_limb_t in2[FE_NUM_LIMBS]) { + assert_fe_loose(in1); + assert_fe_loose(in2); + fiat_25519_carry_mul(out, in1, in2); + assert_fe(out); +} + +static void fe_mul_ltt(fe_loose *h, const fe *f, const fe *g) { + fe_mul_impl(h->v, f->v, g->v); +} + +#if defined(OPENSSL_SMALL) +static void fe_mul_llt(fe_loose *h, const fe_loose *f, const fe *g) { + fe_mul_impl(h->v, f->v, g->v); +} +#endif + +static void fe_mul_ttt(fe *h, const fe *f, const fe *g) { + fe_mul_impl(h->v, f->v, g->v); +} + +static void fe_mul_tlt(fe *h, const fe_loose *f, const fe *g) { + fe_mul_impl(h->v, f->v, g->v); +} + +static void fe_mul_ttl(fe *h, const fe *f, const fe_loose *g) { + fe_mul_impl(h->v, f->v, g->v); +} + +static void fe_mul_tll(fe *h, const fe_loose *f, const fe_loose *g) { + fe_mul_impl(h->v, f->v, g->v); +} + +static void fe_sq_tl(fe *h, const fe_loose *f) { + assert_fe_loose(f->v); + fiat_25519_carry_square(h->v, f->v); + assert_fe(h->v); +} + +static void fe_sq_tt(fe *h, const fe *f) { + assert_fe_loose(f->v); + fiat_25519_carry_square(h->v, f->v); + assert_fe(h->v); +} + +// Replace (f,g) with (g,f) if b == 1; +// replace (f,g) with (f,g) if b == 0. +// +// Preconditions: b in {0,1}. +static void fe_cswap(fe *f, fe *g, fe_limb_t b) { + b = 0-b; + for (unsigned i = 0; i < FE_NUM_LIMBS; i++) { + fe_limb_t x = f->v[i] ^ g->v[i]; + x &= b; + f->v[i] ^= x; + g->v[i] ^= x; + } +} + +static void fe_mul121666(fe *h, const fe_loose *f) { + assert_fe_loose(f->v); + fiat_25519_carry_scmul_121666(h->v, f->v); + assert_fe(h->v); +} + +// h = -f +static void fe_neg(fe_loose *h, const fe *f) { + assert_fe(f->v); + fiat_25519_opp(h->v, f->v); + assert_fe_loose(h->v); +} + +// Replace (f,g) with (g,g) if b == 1; +// replace (f,g) with (f,g) if b == 0. +// +// Preconditions: b in {0,1}. +static void fe_cmov(fe_loose *f, const fe_loose *g, fe_limb_t b) { + // TODO(davidben): Switch to fiat's calling convention, or ask fiat to emit a + // different one. + + b = 0-b; + for (unsigned i = 0; i < FE_NUM_LIMBS; i++) { + fe_limb_t x = f->v[i] ^ g->v[i]; + x &= b; + f->v[i] ^= x; + } +} + +// h = f +static void fe_copy(fe *h, const fe *f) { + fe_limbs_copy(h->v, f->v); +} + +static void fe_copy_lt(fe_loose *h, const fe *f) { + OPENSSL_STATIC_ASSERT(sizeof(fe_loose) == sizeof(fe), "fe and fe_loose mismatch"); + fe_limbs_copy(h->v, f->v); +} + +static void fe_loose_invert(fe *out, const fe_loose *z) { + fe t0; + fe t1; + fe t2; + fe t3; + int i; + + fe_sq_tl(&t0, z); + fe_sq_tt(&t1, &t0); + for (i = 1; i < 2; ++i) { + fe_sq_tt(&t1, &t1); + } + fe_mul_tlt(&t1, z, &t1); + fe_mul_ttt(&t0, &t0, &t1); + fe_sq_tt(&t2, &t0); + fe_mul_ttt(&t1, &t1, &t2); + fe_sq_tt(&t2, &t1); + for (i = 1; i < 5; ++i) { + fe_sq_tt(&t2, &t2); + } + fe_mul_ttt(&t1, &t2, &t1); + fe_sq_tt(&t2, &t1); + for (i = 1; i < 10; ++i) { + fe_sq_tt(&t2, &t2); + } + fe_mul_ttt(&t2, &t2, &t1); + fe_sq_tt(&t3, &t2); + for (i = 1; i < 20; ++i) { + fe_sq_tt(&t3, &t3); + } + fe_mul_ttt(&t2, &t3, &t2); + fe_sq_tt(&t2, &t2); + for (i = 1; i < 10; ++i) { + fe_sq_tt(&t2, &t2); + } + fe_mul_ttt(&t1, &t2, &t1); + fe_sq_tt(&t2, &t1); + for (i = 1; i < 50; ++i) { + fe_sq_tt(&t2, &t2); + } + fe_mul_ttt(&t2, &t2, &t1); + fe_sq_tt(&t3, &t2); + for (i = 1; i < 100; ++i) { + fe_sq_tt(&t3, &t3); + } + fe_mul_ttt(&t2, &t3, &t2); + fe_sq_tt(&t2, &t2); + for (i = 1; i < 50; ++i) { + fe_sq_tt(&t2, &t2); + } + fe_mul_ttt(&t1, &t2, &t1); + fe_sq_tt(&t1, &t1); + for (i = 1; i < 5; ++i) { + fe_sq_tt(&t1, &t1); + } + fe_mul_ttt(out, &t1, &t0); +} + +static void fe_invert(fe *out, const fe *z) { + fe_loose l; + fe_copy_lt(&l, z); + fe_loose_invert(out, &l); +} + +// return 0 if f == 0 +// return 1 if f != 0 +static int fe_isnonzero(const fe_loose *f) { + fe tight; + fe_carry(&tight, f); + uint8_t s[32]; + fe_tobytes(s, &tight); + + static const uint8_t zero[32] = {0}; + return CRYPTO_memcmp(s, zero, sizeof(zero)) != 0; +} + +// return 1 if f is in {1,3,5,...,q-2} +// return 0 if f is in {0,2,4,...,q-1} +static int fe_isnegative(const fe *f) { + uint8_t s[32]; + fe_tobytes(s, f); + return s[0] & 1; +} + +static void fe_sq2_tt(fe *h, const fe *f) { + // h = f^2 + fe_sq_tt(h, f); + + // h = h + h + fe_loose tmp; + fe_add(&tmp, h, h); + fe_carry(h, &tmp); +} + +static void fe_pow22523(fe *out, const fe *z) { + fe t0; + fe t1; + fe t2; + int i; + + fe_sq_tt(&t0, z); + fe_sq_tt(&t1, &t0); + for (i = 1; i < 2; ++i) { + fe_sq_tt(&t1, &t1); + } + fe_mul_ttt(&t1, z, &t1); + fe_mul_ttt(&t0, &t0, &t1); + fe_sq_tt(&t0, &t0); + fe_mul_ttt(&t0, &t1, &t0); + fe_sq_tt(&t1, &t0); + for (i = 1; i < 5; ++i) { + fe_sq_tt(&t1, &t1); + } + fe_mul_ttt(&t0, &t1, &t0); + fe_sq_tt(&t1, &t0); + for (i = 1; i < 10; ++i) { + fe_sq_tt(&t1, &t1); + } + fe_mul_ttt(&t1, &t1, &t0); + fe_sq_tt(&t2, &t1); + for (i = 1; i < 20; ++i) { + fe_sq_tt(&t2, &t2); + } + fe_mul_ttt(&t1, &t2, &t1); + fe_sq_tt(&t1, &t1); + for (i = 1; i < 10; ++i) { + fe_sq_tt(&t1, &t1); + } + fe_mul_ttt(&t0, &t1, &t0); + fe_sq_tt(&t1, &t0); + for (i = 1; i < 50; ++i) { + fe_sq_tt(&t1, &t1); + } + fe_mul_ttt(&t1, &t1, &t0); + fe_sq_tt(&t2, &t1); + for (i = 1; i < 100; ++i) { + fe_sq_tt(&t2, &t2); + } + fe_mul_ttt(&t1, &t2, &t1); + fe_sq_tt(&t1, &t1); + for (i = 1; i < 50; ++i) { + fe_sq_tt(&t1, &t1); + } + fe_mul_ttt(&t0, &t1, &t0); + fe_sq_tt(&t0, &t0); + for (i = 1; i < 2; ++i) { + fe_sq_tt(&t0, &t0); + } + fe_mul_ttt(out, &t0, z); +} + + +// Group operations. + +int x25519_ge_frombytes_vartime(ge_p3 *h, const uint8_t s[32]) { + fe u; + fe_loose v; + fe w; + fe vxx; + fe_loose check; + + fe_frombytes(&h->Y, s); + fe_1(&h->Z); + fe_sq_tt(&w, &h->Y); + fe_mul_ttt(&vxx, &w, &d); + fe_sub(&v, &w, &h->Z); // u = y^2-1 + fe_carry(&u, &v); + fe_add(&v, &vxx, &h->Z); // v = dy^2+1 + + fe_mul_ttl(&w, &u, &v); // w = u*v + fe_pow22523(&h->X, &w); // x = w^((q-5)/8) + fe_mul_ttt(&h->X, &h->X, &u); // x = u*w^((q-5)/8) + + fe_sq_tt(&vxx, &h->X); + fe_mul_ttl(&vxx, &vxx, &v); + fe_sub(&check, &vxx, &u); + if (fe_isnonzero(&check)) { + fe_add(&check, &vxx, &u); + if (fe_isnonzero(&check)) { + return 0; + } + fe_mul_ttt(&h->X, &h->X, &sqrtm1); + } + + if (fe_isnegative(&h->X) != (s[31] >> 7)) { + fe_loose t; + fe_neg(&t, &h->X); + fe_carry(&h->X, &t); + } + + fe_mul_ttt(&h->T, &h->X, &h->Y); + return 1; +} + +static void ge_p2_0(ge_p2 *h) { + fe_0(&h->X); + fe_1(&h->Y); + fe_1(&h->Z); +} + +static void ge_p3_0(ge_p3 *h) { + fe_0(&h->X); + fe_1(&h->Y); + fe_1(&h->Z); + fe_0(&h->T); +} + +#if defined(OPENSSL_SMALL) + +static void ge_precomp_0(ge_precomp *h) { + fe_loose_1(&h->yplusx); + fe_loose_1(&h->yminusx); + fe_loose_0(&h->xy2d); +} + +#endif + +// r = p +static void ge_p3_to_p2(ge_p2 *r, const ge_p3 *p) { + fe_copy(&r->X, &p->X); + fe_copy(&r->Y, &p->Y); + fe_copy(&r->Z, &p->Z); +} + +// r = p +static void x25519_ge_p3_to_cached(ge_cached *r, const ge_p3 *p) { + fe_add(&r->YplusX, &p->Y, &p->X); + fe_sub(&r->YminusX, &p->Y, &p->X); + fe_copy_lt(&r->Z, &p->Z); + fe_mul_ltt(&r->T2d, &p->T, &d2); +} + +// r = p +static void x25519_ge_p1p1_to_p2(ge_p2 *r, const ge_p1p1 *p) { + fe_mul_tll(&r->X, &p->X, &p->T); + fe_mul_tll(&r->Y, &p->Y, &p->Z); + fe_mul_tll(&r->Z, &p->Z, &p->T); +} + +// r = p +static void x25519_ge_p1p1_to_p3(ge_p3 *r, const ge_p1p1 *p) { + fe_mul_tll(&r->X, &p->X, &p->T); + fe_mul_tll(&r->Y, &p->Y, &p->Z); + fe_mul_tll(&r->Z, &p->Z, &p->T); + fe_mul_tll(&r->T, &p->X, &p->Y); +} + +// r = 2 * p +static void ge_p2_dbl(ge_p1p1 *r, const ge_p2 *p) { + fe trX, trZ, trT; + fe t0; + + fe_sq_tt(&trX, &p->X); + fe_sq_tt(&trZ, &p->Y); + fe_sq2_tt(&trT, &p->Z); + fe_add(&r->Y, &p->X, &p->Y); + fe_sq_tl(&t0, &r->Y); + + fe_add(&r->Y, &trZ, &trX); + fe_sub(&r->Z, &trZ, &trX); + fe_carry(&trZ, &r->Y); + fe_sub(&r->X, &t0, &trZ); + fe_carry(&trZ, &r->Z); + fe_sub(&r->T, &trT, &trZ); +} + +// r = 2 * p +static void ge_p3_dbl(ge_p1p1 *r, const ge_p3 *p) { + ge_p2 q; + ge_p3_to_p2(&q, p); + ge_p2_dbl(r, &q); +} + +// r = p + q +static void ge_madd(ge_p1p1 *r, const ge_p3 *p, const ge_precomp *q) { + fe trY, trZ, trT; + + fe_add(&r->X, &p->Y, &p->X); + fe_sub(&r->Y, &p->Y, &p->X); + fe_mul_tll(&trZ, &r->X, &q->yplusx); + fe_mul_tll(&trY, &r->Y, &q->yminusx); + fe_mul_tlt(&trT, &q->xy2d, &p->T); + fe_add(&r->T, &p->Z, &p->Z); + fe_sub(&r->X, &trZ, &trY); + fe_add(&r->Y, &trZ, &trY); + fe_carry(&trZ, &r->T); + fe_add(&r->Z, &trZ, &trT); + fe_sub(&r->T, &trZ, &trT); +} + +// r = p - q +static void ge_msub(ge_p1p1 *r, const ge_p3 *p, const ge_precomp *q) { + fe trY, trZ, trT; + + fe_add(&r->X, &p->Y, &p->X); + fe_sub(&r->Y, &p->Y, &p->X); + fe_mul_tll(&trZ, &r->X, &q->yminusx); + fe_mul_tll(&trY, &r->Y, &q->yplusx); + fe_mul_tlt(&trT, &q->xy2d, &p->T); + fe_add(&r->T, &p->Z, &p->Z); + fe_sub(&r->X, &trZ, &trY); + fe_add(&r->Y, &trZ, &trY); + fe_carry(&trZ, &r->T); + fe_sub(&r->Z, &trZ, &trT); + fe_add(&r->T, &trZ, &trT); +} + +// r = p + q +static void x25519_ge_add(ge_p1p1 *r, const ge_p3 *p, const ge_cached *q) { + fe trX, trY, trZ, trT; + + fe_add(&r->X, &p->Y, &p->X); + fe_sub(&r->Y, &p->Y, &p->X); + fe_mul_tll(&trZ, &r->X, &q->YplusX); + fe_mul_tll(&trY, &r->Y, &q->YminusX); + fe_mul_tlt(&trT, &q->T2d, &p->T); + fe_mul_ttl(&trX, &p->Z, &q->Z); + fe_add(&r->T, &trX, &trX); + fe_sub(&r->X, &trZ, &trY); + fe_add(&r->Y, &trZ, &trY); + fe_carry(&trZ, &r->T); + fe_add(&r->Z, &trZ, &trT); + fe_sub(&r->T, &trZ, &trT); +} + +// r = p - q +static void x25519_ge_sub(ge_p1p1 *r, const ge_p3 *p, const ge_cached *q) { + fe trX, trY, trZ, trT; + + fe_add(&r->X, &p->Y, &p->X); + fe_sub(&r->Y, &p->Y, &p->X); + fe_mul_tll(&trZ, &r->X, &q->YminusX); + fe_mul_tll(&trY, &r->Y, &q->YplusX); + fe_mul_tlt(&trT, &q->T2d, &p->T); + fe_mul_ttl(&trX, &p->Z, &q->Z); + fe_add(&r->T, &trX, &trX); + fe_sub(&r->X, &trZ, &trY); + fe_add(&r->Y, &trZ, &trY); + fe_carry(&trZ, &r->T); + fe_sub(&r->Z, &trZ, &trT); + fe_add(&r->T, &trZ, &trT); +} + +static void cmov(ge_precomp *t, const ge_precomp *u, uint8_t b) { + fe_cmov(&t->yplusx, &u->yplusx, b); + fe_cmov(&t->yminusx, &u->yminusx, b); + fe_cmov(&t->xy2d, &u->xy2d, b); +} + +#if defined(OPENSSL_SMALL) + +static void x25519_ge_scalarmult_small_precomp( + ge_p3 *h, const uint8_t a[32], const uint8_t precomp_table[15 * 2 * 32]) { + // precomp_table is first expanded into matching |ge_precomp| + // elements. + ge_precomp multiples[15]; + + unsigned i; + for (i = 0; i < 15; i++) { + // The precomputed table is assumed to already clear the top bit, so + // |fe_frombytes_strict| may be used directly. + const uint8_t *bytes = &precomp_table[i*(2 * 32)]; + fe x, y; + fe_frombytes_strict(&x, bytes); + fe_frombytes_strict(&y, bytes + 32); + + ge_precomp *out = &multiples[i]; + fe_add(&out->yplusx, &y, &x); + fe_sub(&out->yminusx, &y, &x); + fe_mul_ltt(&out->xy2d, &x, &y); + fe_mul_llt(&out->xy2d, &out->xy2d, &d2); + } + + // See the comment above |k25519SmallPrecomp| about the structure of the + // precomputed elements. This loop does 64 additions and 64 doublings to + // calculate the result. + ge_p3_0(h); + + for (i = 63; i < 64; i--) { + unsigned j; + signed char index = 0; + + for (j = 0; j < 4; j++) { + const uint8_t bit = 1 & (a[(8 * j) + (i / 8)] >> (i & 7)); + index |= (bit << j); + } + + ge_precomp e; + ge_precomp_0(&e); + + for (j = 1; j < 16; j++) { + cmov(&e, &multiples[j-1], 1&constant_time_eq_w(index, j)); + } + + ge_cached cached; + ge_p1p1 r; + x25519_ge_p3_to_cached(&cached, h); + x25519_ge_add(&r, h, &cached); + x25519_ge_p1p1_to_p3(h, &r); + + ge_madd(&r, h, &e); + x25519_ge_p1p1_to_p3(h, &r); + } +} + +void x25519_ge_scalarmult_base(ge_p3 *h, const uint8_t a[32], int use_adx) { + (void)use_adx; + x25519_ge_scalarmult_small_precomp(h, a, k25519SmallPrecomp); +} + +#else + +static void table_select(ge_precomp *t, const int pos, const signed char b) { + uint8_t bnegative = constant_time_msb_w(b); + uint8_t babs = b - ((bnegative & b) << 1); + + uint8_t t_bytes[3][32] = { + {constant_time_is_zero_w(b) & 1}, {constant_time_is_zero_w(b) & 1}, {0}}; +#if defined(__clang__) // materialize for vectorization, 6% speedup + __asm__("" : "+m" (t_bytes) : /*no inputs*/); +#endif + OPENSSL_STATIC_ASSERT(sizeof(t_bytes) == sizeof(k25519Precomp[pos][0]), ""); + for (int i = 0; i < 8; i++) { + constant_time_conditional_memxor(t_bytes, k25519Precomp[pos][i], + sizeof(t_bytes), + constant_time_eq_w(babs, 1 + i)); + } + + fe yplusx, yminusx, xy2d; + fe_frombytes_strict(&yplusx, t_bytes[0]); + fe_frombytes_strict(&yminusx, t_bytes[1]); + fe_frombytes_strict(&xy2d, t_bytes[2]); + + fe_copy_lt(&t->yplusx, &yplusx); + fe_copy_lt(&t->yminusx, &yminusx); + fe_copy_lt(&t->xy2d, &xy2d); + + ge_precomp minust; + fe_copy_lt(&minust.yplusx, &yminusx); + fe_copy_lt(&minust.yminusx, &yplusx); + fe_neg(&minust.xy2d, &xy2d); + cmov(t, &minust, bnegative>>7); +} + +// h = a * B +// where a = a[0]+256*a[1]+...+256^31 a[31] +// B is the Ed25519 base point (x,4/5) with x positive. +// +// Preconditions: +// a[31] <= 127 +void x25519_ge_scalarmult_base(ge_p3 *h, const uint8_t a[32], int use_adx) { +#if defined(BORINGSSL_FE25519_ADX) + if (use_adx) { + uint8_t t[4][32]; + x25519_ge_scalarmult_base_adx(t, a); + fiat_25519_from_bytes(h->X.v, t[0]); + fiat_25519_from_bytes(h->Y.v, t[1]); + fiat_25519_from_bytes(h->Z.v, t[2]); + fiat_25519_from_bytes(h->T.v, t[3]); + return; + } +#else + (void)use_adx; +#endif + signed char e[64]; + signed char carry; + ge_p1p1 r; + ge_p2 s; + ge_precomp t; + int i; + + for (i = 0; i < 32; ++i) { + e[2 * i + 0] = (a[i] >> 0) & 15; + e[2 * i + 1] = (a[i] >> 4) & 15; + } + // each e[i] is between 0 and 15 + // e[63] is between 0 and 7 + + carry = 0; + for (i = 0; i < 63; ++i) { + e[i] += carry; + carry = e[i] + 8; + carry >>= 4; + e[i] -= carry << 4; + } + e[63] += carry; + // each e[i] is between -8 and 8 + + ge_p3_0(h); + for (i = 1; i < 64; i += 2) { + table_select(&t, i / 2, e[i]); + ge_madd(&r, h, &t); + x25519_ge_p1p1_to_p3(h, &r); + } + + ge_p3_dbl(&r, h); + x25519_ge_p1p1_to_p2(&s, &r); + ge_p2_dbl(&r, &s); + x25519_ge_p1p1_to_p2(&s, &r); + ge_p2_dbl(&r, &s); + x25519_ge_p1p1_to_p2(&s, &r); + ge_p2_dbl(&r, &s); + x25519_ge_p1p1_to_p3(h, &r); + + for (i = 0; i < 64; i += 2) { + table_select(&t, i / 2, e[i]); + ge_madd(&r, h, &t); + x25519_ge_p1p1_to_p3(h, &r); + } +} + +#endif + +static void slide(signed char *r, const uint8_t *a) { + int i; + int b; + int k; + + for (i = 0; i < 256; ++i) { + r[i] = 1 & (a[i >> 3] >> (i & 7)); + } + + for (i = 0; i < 256; ++i) { + if (r[i]) { + for (b = 1; b <= 6 && i + b < 256; ++b) { + if (r[i + b]) { + if (r[i] + (r[i + b] << b) <= 15) { + r[i] += r[i + b] << b; + r[i + b] = 0; + } else if (r[i] - (r[i + b] << b) >= -15) { + r[i] -= r[i + b] << b; + for (k = i + b; k < 256; ++k) { + if (!r[k]) { + r[k] = 1; + break; + } + r[k] = 0; + } + } else { + break; + } + } + } + } + } +} + +// r = a * A + b * B +// where a = a[0]+256*a[1]+...+256^31 a[31]. +// and b = b[0]+256*b[1]+...+256^31 b[31]. +// B is the Ed25519 base point (x,4/5) with x positive. +static void ge_double_scalarmult_vartime(ge_p2 *r, const uint8_t *a, + const ge_p3 *A, const uint8_t *b) { + signed char aslide[256]; + signed char bslide[256]; + ge_cached Ai[8]; // A,3A,5A,7A,9A,11A,13A,15A + ge_p1p1 t; + ge_p3 u; + ge_p3 A2; + int i; + + slide(aslide, a); + slide(bslide, b); + + x25519_ge_p3_to_cached(&Ai[0], A); + ge_p3_dbl(&t, A); + x25519_ge_p1p1_to_p3(&A2, &t); + x25519_ge_add(&t, &A2, &Ai[0]); + x25519_ge_p1p1_to_p3(&u, &t); + x25519_ge_p3_to_cached(&Ai[1], &u); + x25519_ge_add(&t, &A2, &Ai[1]); + x25519_ge_p1p1_to_p3(&u, &t); + x25519_ge_p3_to_cached(&Ai[2], &u); + x25519_ge_add(&t, &A2, &Ai[2]); + x25519_ge_p1p1_to_p3(&u, &t); + x25519_ge_p3_to_cached(&Ai[3], &u); + x25519_ge_add(&t, &A2, &Ai[3]); + x25519_ge_p1p1_to_p3(&u, &t); + x25519_ge_p3_to_cached(&Ai[4], &u); + x25519_ge_add(&t, &A2, &Ai[4]); + x25519_ge_p1p1_to_p3(&u, &t); + x25519_ge_p3_to_cached(&Ai[5], &u); + x25519_ge_add(&t, &A2, &Ai[5]); + x25519_ge_p1p1_to_p3(&u, &t); + x25519_ge_p3_to_cached(&Ai[6], &u); + x25519_ge_add(&t, &A2, &Ai[6]); + x25519_ge_p1p1_to_p3(&u, &t); + x25519_ge_p3_to_cached(&Ai[7], &u); + + ge_p2_0(r); + + for (i = 255; i >= 0; --i) { + if (aslide[i] || bslide[i]) { + break; + } + } + + for (; i >= 0; --i) { + ge_p2_dbl(&t, r); + + if (aslide[i] > 0) { + x25519_ge_p1p1_to_p3(&u, &t); + x25519_ge_add(&t, &u, &Ai[aslide[i] / 2]); + } else if (aslide[i] < 0) { + x25519_ge_p1p1_to_p3(&u, &t); + x25519_ge_sub(&t, &u, &Ai[(-aslide[i]) / 2]); + } + + if (bslide[i] > 0) { + x25519_ge_p1p1_to_p3(&u, &t); + ge_madd(&t, &u, &Bi[bslide[i] / 2]); + } else if (bslide[i] < 0) { + x25519_ge_p1p1_to_p3(&u, &t); + ge_msub(&t, &u, &Bi[(-bslide[i]) / 2]); + } + + x25519_ge_p1p1_to_p2(r, &t); + } +} + +// int64_lshift21 returns |a << 21| but is defined when shifting bits into the +// sign bit. This works around a language flaw in C. +static inline int64_t int64_lshift21(int64_t a) { + return (int64_t)((uint64_t)a << 21); +} + +// The set of scalars is \Z/l +// where l = 2^252 + 27742317777372353535851937790883648493. + +// Input: +// s[0]+256*s[1]+...+256^63*s[63] = s +// +// Output: +// s[0]+256*s[1]+...+256^31*s[31] = s mod l +// where l = 2^252 + 27742317777372353535851937790883648493. +// Overwrites s in place. +void x25519_sc_reduce(uint8_t s[64]) { + int64_t s0 = 2097151 & load_3(s); + int64_t s1 = 2097151 & (load_4(s + 2) >> 5); + int64_t s2 = 2097151 & (load_3(s + 5) >> 2); + int64_t s3 = 2097151 & (load_4(s + 7) >> 7); + int64_t s4 = 2097151 & (load_4(s + 10) >> 4); + int64_t s5 = 2097151 & (load_3(s + 13) >> 1); + int64_t s6 = 2097151 & (load_4(s + 15) >> 6); + int64_t s7 = 2097151 & (load_3(s + 18) >> 3); + int64_t s8 = 2097151 & load_3(s + 21); + int64_t s9 = 2097151 & (load_4(s + 23) >> 5); + int64_t s10 = 2097151 & (load_3(s + 26) >> 2); + int64_t s11 = 2097151 & (load_4(s + 28) >> 7); + int64_t s12 = 2097151 & (load_4(s + 31) >> 4); + int64_t s13 = 2097151 & (load_3(s + 34) >> 1); + int64_t s14 = 2097151 & (load_4(s + 36) >> 6); + int64_t s15 = 2097151 & (load_3(s + 39) >> 3); + int64_t s16 = 2097151 & load_3(s + 42); + int64_t s17 = 2097151 & (load_4(s + 44) >> 5); + int64_t s18 = 2097151 & (load_3(s + 47) >> 2); + int64_t s19 = 2097151 & (load_4(s + 49) >> 7); + int64_t s20 = 2097151 & (load_4(s + 52) >> 4); + int64_t s21 = 2097151 & (load_3(s + 55) >> 1); + int64_t s22 = 2097151 & (load_4(s + 57) >> 6); + int64_t s23 = (load_4(s + 60) >> 3); + int64_t carry0; + int64_t carry1; + int64_t carry2; + int64_t carry3; + int64_t carry4; + int64_t carry5; + int64_t carry6; + int64_t carry7; + int64_t carry8; + int64_t carry9; + int64_t carry10; + int64_t carry11; + int64_t carry12; + int64_t carry13; + int64_t carry14; + int64_t carry15; + int64_t carry16; + + s11 += s23 * 666643; + s12 += s23 * 470296; + s13 += s23 * 654183; + s14 -= s23 * 997805; + s15 += s23 * 136657; + s16 -= s23 * 683901; + s23 = 0; + + s10 += s22 * 666643; + s11 += s22 * 470296; + s12 += s22 * 654183; + s13 -= s22 * 997805; + s14 += s22 * 136657; + s15 -= s22 * 683901; + s22 = 0; + + s9 += s21 * 666643; + s10 += s21 * 470296; + s11 += s21 * 654183; + s12 -= s21 * 997805; + s13 += s21 * 136657; + s14 -= s21 * 683901; + s21 = 0; + + s8 += s20 * 666643; + s9 += s20 * 470296; + s10 += s20 * 654183; + s11 -= s20 * 997805; + s12 += s20 * 136657; + s13 -= s20 * 683901; + s20 = 0; + + s7 += s19 * 666643; + s8 += s19 * 470296; + s9 += s19 * 654183; + s10 -= s19 * 997805; + s11 += s19 * 136657; + s12 -= s19 * 683901; + s19 = 0; + + s6 += s18 * 666643; + s7 += s18 * 470296; + s8 += s18 * 654183; + s9 -= s18 * 997805; + s10 += s18 * 136657; + s11 -= s18 * 683901; + s18 = 0; + + carry6 = (s6 + (1 << 20)) >> 21; + s7 += carry6; + s6 -= int64_lshift21(carry6); + carry8 = (s8 + (1 << 20)) >> 21; + s9 += carry8; + s8 -= int64_lshift21(carry8); + carry10 = (s10 + (1 << 20)) >> 21; + s11 += carry10; + s10 -= int64_lshift21(carry10); + carry12 = (s12 + (1 << 20)) >> 21; + s13 += carry12; + s12 -= int64_lshift21(carry12); + carry14 = (s14 + (1 << 20)) >> 21; + s15 += carry14; + s14 -= int64_lshift21(carry14); + carry16 = (s16 + (1 << 20)) >> 21; + s17 += carry16; + s16 -= int64_lshift21(carry16); + + carry7 = (s7 + (1 << 20)) >> 21; + s8 += carry7; + s7 -= int64_lshift21(carry7); + carry9 = (s9 + (1 << 20)) >> 21; + s10 += carry9; + s9 -= int64_lshift21(carry9); + carry11 = (s11 + (1 << 20)) >> 21; + s12 += carry11; + s11 -= int64_lshift21(carry11); + carry13 = (s13 + (1 << 20)) >> 21; + s14 += carry13; + s13 -= int64_lshift21(carry13); + carry15 = (s15 + (1 << 20)) >> 21; + s16 += carry15; + s15 -= int64_lshift21(carry15); + + s5 += s17 * 666643; + s6 += s17 * 470296; + s7 += s17 * 654183; + s8 -= s17 * 997805; + s9 += s17 * 136657; + s10 -= s17 * 683901; + s17 = 0; + + s4 += s16 * 666643; + s5 += s16 * 470296; + s6 += s16 * 654183; + s7 -= s16 * 997805; + s8 += s16 * 136657; + s9 -= s16 * 683901; + s16 = 0; + + s3 += s15 * 666643; + s4 += s15 * 470296; + s5 += s15 * 654183; + s6 -= s15 * 997805; + s7 += s15 * 136657; + s8 -= s15 * 683901; + s15 = 0; + + s2 += s14 * 666643; + s3 += s14 * 470296; + s4 += s14 * 654183; + s5 -= s14 * 997805; + s6 += s14 * 136657; + s7 -= s14 * 683901; + s14 = 0; + + s1 += s13 * 666643; + s2 += s13 * 470296; + s3 += s13 * 654183; + s4 -= s13 * 997805; + s5 += s13 * 136657; + s6 -= s13 * 683901; + s13 = 0; + + s0 += s12 * 666643; + s1 += s12 * 470296; + s2 += s12 * 654183; + s3 -= s12 * 997805; + s4 += s12 * 136657; + s5 -= s12 * 683901; + s12 = 0; + + carry0 = (s0 + (1 << 20)) >> 21; + s1 += carry0; + s0 -= int64_lshift21(carry0); + carry2 = (s2 + (1 << 20)) >> 21; + s3 += carry2; + s2 -= int64_lshift21(carry2); + carry4 = (s4 + (1 << 20)) >> 21; + s5 += carry4; + s4 -= int64_lshift21(carry4); + carry6 = (s6 + (1 << 20)) >> 21; + s7 += carry6; + s6 -= int64_lshift21(carry6); + carry8 = (s8 + (1 << 20)) >> 21; + s9 += carry8; + s8 -= int64_lshift21(carry8); + carry10 = (s10 + (1 << 20)) >> 21; + s11 += carry10; + s10 -= int64_lshift21(carry10); + + carry1 = (s1 + (1 << 20)) >> 21; + s2 += carry1; + s1 -= int64_lshift21(carry1); + carry3 = (s3 + (1 << 20)) >> 21; + s4 += carry3; + s3 -= int64_lshift21(carry3); + carry5 = (s5 + (1 << 20)) >> 21; + s6 += carry5; + s5 -= int64_lshift21(carry5); + carry7 = (s7 + (1 << 20)) >> 21; + s8 += carry7; + s7 -= int64_lshift21(carry7); + carry9 = (s9 + (1 << 20)) >> 21; + s10 += carry9; + s9 -= int64_lshift21(carry9); + carry11 = (s11 + (1 << 20)) >> 21; + s12 += carry11; + s11 -= int64_lshift21(carry11); + + s0 += s12 * 666643; + s1 += s12 * 470296; + s2 += s12 * 654183; + s3 -= s12 * 997805; + s4 += s12 * 136657; + s5 -= s12 * 683901; + s12 = 0; + + carry0 = s0 >> 21; + s1 += carry0; + s0 -= int64_lshift21(carry0); + carry1 = s1 >> 21; + s2 += carry1; + s1 -= int64_lshift21(carry1); + carry2 = s2 >> 21; + s3 += carry2; + s2 -= int64_lshift21(carry2); + carry3 = s3 >> 21; + s4 += carry3; + s3 -= int64_lshift21(carry3); + carry4 = s4 >> 21; + s5 += carry4; + s4 -= int64_lshift21(carry4); + carry5 = s5 >> 21; + s6 += carry5; + s5 -= int64_lshift21(carry5); + carry6 = s6 >> 21; + s7 += carry6; + s6 -= int64_lshift21(carry6); + carry7 = s7 >> 21; + s8 += carry7; + s7 -= int64_lshift21(carry7); + carry8 = s8 >> 21; + s9 += carry8; + s8 -= int64_lshift21(carry8); + carry9 = s9 >> 21; + s10 += carry9; + s9 -= int64_lshift21(carry9); + carry10 = s10 >> 21; + s11 += carry10; + s10 -= int64_lshift21(carry10); + carry11 = s11 >> 21; + s12 += carry11; + s11 -= int64_lshift21(carry11); + + s0 += s12 * 666643; + s1 += s12 * 470296; + s2 += s12 * 654183; + s3 -= s12 * 997805; + s4 += s12 * 136657; + s5 -= s12 * 683901; + s12 = 0; + + carry0 = s0 >> 21; + s1 += carry0; + s0 -= int64_lshift21(carry0); + carry1 = s1 >> 21; + s2 += carry1; + s1 -= int64_lshift21(carry1); + carry2 = s2 >> 21; + s3 += carry2; + s2 -= int64_lshift21(carry2); + carry3 = s3 >> 21; + s4 += carry3; + s3 -= int64_lshift21(carry3); + carry4 = s4 >> 21; + s5 += carry4; + s4 -= int64_lshift21(carry4); + carry5 = s5 >> 21; + s6 += carry5; + s5 -= int64_lshift21(carry5); + carry6 = s6 >> 21; + s7 += carry6; + s6 -= int64_lshift21(carry6); + carry7 = s7 >> 21; + s8 += carry7; + s7 -= int64_lshift21(carry7); + carry8 = s8 >> 21; + s9 += carry8; + s8 -= int64_lshift21(carry8); + carry9 = s9 >> 21; + s10 += carry9; + s9 -= int64_lshift21(carry9); + carry10 = s10 >> 21; + s11 += carry10; + s10 -= int64_lshift21(carry10); + + s[0] = s0 >> 0; + s[1] = s0 >> 8; + s[2] = (s0 >> 16) | (s1 << 5); + s[3] = s1 >> 3; + s[4] = s1 >> 11; + s[5] = (s1 >> 19) | (s2 << 2); + s[6] = s2 >> 6; + s[7] = (s2 >> 14) | (s3 << 7); + s[8] = s3 >> 1; + s[9] = s3 >> 9; + s[10] = (s3 >> 17) | (s4 << 4); + s[11] = s4 >> 4; + s[12] = s4 >> 12; + s[13] = (s4 >> 20) | (s5 << 1); + s[14] = s5 >> 7; + s[15] = (s5 >> 15) | (s6 << 6); + s[16] = s6 >> 2; + s[17] = s6 >> 10; + s[18] = (s6 >> 18) | (s7 << 3); + s[19] = s7 >> 5; + s[20] = s7 >> 13; + s[21] = s8 >> 0; + s[22] = s8 >> 8; + s[23] = (s8 >> 16) | (s9 << 5); + s[24] = s9 >> 3; + s[25] = s9 >> 11; + s[26] = (s9 >> 19) | (s10 << 2); + s[27] = s10 >> 6; + s[28] = (s10 >> 14) | (s11 << 7); + s[29] = s11 >> 1; + s[30] = s11 >> 9; + s[31] = s11 >> 17; +} + +// Input: +// a[0]+256*a[1]+...+256^31*a[31] = a +// b[0]+256*b[1]+...+256^31*b[31] = b +// c[0]+256*c[1]+...+256^31*c[31] = c +// +// Output: +// s[0]+256*s[1]+...+256^31*s[31] = (ab+c) mod l +// where l = 2^252 + 27742317777372353535851937790883648493. +static void sc_muladd(uint8_t *s, const uint8_t *a, const uint8_t *b, + const uint8_t *c) { + int64_t a0 = 2097151 & load_3(a); + int64_t a1 = 2097151 & (load_4(a + 2) >> 5); + int64_t a2 = 2097151 & (load_3(a + 5) >> 2); + int64_t a3 = 2097151 & (load_4(a + 7) >> 7); + int64_t a4 = 2097151 & (load_4(a + 10) >> 4); + int64_t a5 = 2097151 & (load_3(a + 13) >> 1); + int64_t a6 = 2097151 & (load_4(a + 15) >> 6); + int64_t a7 = 2097151 & (load_3(a + 18) >> 3); + int64_t a8 = 2097151 & load_3(a + 21); + int64_t a9 = 2097151 & (load_4(a + 23) >> 5); + int64_t a10 = 2097151 & (load_3(a + 26) >> 2); + int64_t a11 = (load_4(a + 28) >> 7); + int64_t b0 = 2097151 & load_3(b); + int64_t b1 = 2097151 & (load_4(b + 2) >> 5); + int64_t b2 = 2097151 & (load_3(b + 5) >> 2); + int64_t b3 = 2097151 & (load_4(b + 7) >> 7); + int64_t b4 = 2097151 & (load_4(b + 10) >> 4); + int64_t b5 = 2097151 & (load_3(b + 13) >> 1); + int64_t b6 = 2097151 & (load_4(b + 15) >> 6); + int64_t b7 = 2097151 & (load_3(b + 18) >> 3); + int64_t b8 = 2097151 & load_3(b + 21); + int64_t b9 = 2097151 & (load_4(b + 23) >> 5); + int64_t b10 = 2097151 & (load_3(b + 26) >> 2); + int64_t b11 = (load_4(b + 28) >> 7); + int64_t c0 = 2097151 & load_3(c); + int64_t c1 = 2097151 & (load_4(c + 2) >> 5); + int64_t c2 = 2097151 & (load_3(c + 5) >> 2); + int64_t c3 = 2097151 & (load_4(c + 7) >> 7); + int64_t c4 = 2097151 & (load_4(c + 10) >> 4); + int64_t c5 = 2097151 & (load_3(c + 13) >> 1); + int64_t c6 = 2097151 & (load_4(c + 15) >> 6); + int64_t c7 = 2097151 & (load_3(c + 18) >> 3); + int64_t c8 = 2097151 & load_3(c + 21); + int64_t c9 = 2097151 & (load_4(c + 23) >> 5); + int64_t c10 = 2097151 & (load_3(c + 26) >> 2); + int64_t c11 = (load_4(c + 28) >> 7); + int64_t s0; + int64_t s1; + int64_t s2; + int64_t s3; + int64_t s4; + int64_t s5; + int64_t s6; + int64_t s7; + int64_t s8; + int64_t s9; + int64_t s10; + int64_t s11; + int64_t s12; + int64_t s13; + int64_t s14; + int64_t s15; + int64_t s16; + int64_t s17; + int64_t s18; + int64_t s19; + int64_t s20; + int64_t s21; + int64_t s22; + int64_t s23; + int64_t carry0; + int64_t carry1; + int64_t carry2; + int64_t carry3; + int64_t carry4; + int64_t carry5; + int64_t carry6; + int64_t carry7; + int64_t carry8; + int64_t carry9; + int64_t carry10; + int64_t carry11; + int64_t carry12; + int64_t carry13; + int64_t carry14; + int64_t carry15; + int64_t carry16; + int64_t carry17; + int64_t carry18; + int64_t carry19; + int64_t carry20; + int64_t carry21; + int64_t carry22; + + s0 = c0 + a0 * b0; + s1 = c1 + a0 * b1 + a1 * b0; + s2 = c2 + a0 * b2 + a1 * b1 + a2 * b0; + s3 = c3 + a0 * b3 + a1 * b2 + a2 * b1 + a3 * b0; + s4 = c4 + a0 * b4 + a1 * b3 + a2 * b2 + a3 * b1 + a4 * b0; + s5 = c5 + a0 * b5 + a1 * b4 + a2 * b3 + a3 * b2 + a4 * b1 + a5 * b0; + s6 = c6 + a0 * b6 + a1 * b5 + a2 * b4 + a3 * b3 + a4 * b2 + a5 * b1 + a6 * b0; + s7 = c7 + a0 * b7 + a1 * b6 + a2 * b5 + a3 * b4 + a4 * b3 + a5 * b2 + + a6 * b1 + a7 * b0; + s8 = c8 + a0 * b8 + a1 * b7 + a2 * b6 + a3 * b5 + a4 * b4 + a5 * b3 + + a6 * b2 + a7 * b1 + a8 * b0; + s9 = c9 + a0 * b9 + a1 * b8 + a2 * b7 + a3 * b6 + a4 * b5 + a5 * b4 + + a6 * b3 + a7 * b2 + a8 * b1 + a9 * b0; + s10 = c10 + a0 * b10 + a1 * b9 + a2 * b8 + a3 * b7 + a4 * b6 + a5 * b5 + + a6 * b4 + a7 * b3 + a8 * b2 + a9 * b1 + a10 * b0; + s11 = c11 + a0 * b11 + a1 * b10 + a2 * b9 + a3 * b8 + a4 * b7 + a5 * b6 + + a6 * b5 + a7 * b4 + a8 * b3 + a9 * b2 + a10 * b1 + a11 * b0; + s12 = a1 * b11 + a2 * b10 + a3 * b9 + a4 * b8 + a5 * b7 + a6 * b6 + a7 * b5 + + a8 * b4 + a9 * b3 + a10 * b2 + a11 * b1; + s13 = a2 * b11 + a3 * b10 + a4 * b9 + a5 * b8 + a6 * b7 + a7 * b6 + a8 * b5 + + a9 * b4 + a10 * b3 + a11 * b2; + s14 = a3 * b11 + a4 * b10 + a5 * b9 + a6 * b8 + a7 * b7 + a8 * b6 + a9 * b5 + + a10 * b4 + a11 * b3; + s15 = a4 * b11 + a5 * b10 + a6 * b9 + a7 * b8 + a8 * b7 + a9 * b6 + a10 * b5 + + a11 * b4; + s16 = a5 * b11 + a6 * b10 + a7 * b9 + a8 * b8 + a9 * b7 + a10 * b6 + a11 * b5; + s17 = a6 * b11 + a7 * b10 + a8 * b9 + a9 * b8 + a10 * b7 + a11 * b6; + s18 = a7 * b11 + a8 * b10 + a9 * b9 + a10 * b8 + a11 * b7; + s19 = a8 * b11 + a9 * b10 + a10 * b9 + a11 * b8; + s20 = a9 * b11 + a10 * b10 + a11 * b9; + s21 = a10 * b11 + a11 * b10; + s22 = a11 * b11; + s23 = 0; + + carry0 = (s0 + (1 << 20)) >> 21; + s1 += carry0; + s0 -= int64_lshift21(carry0); + carry2 = (s2 + (1 << 20)) >> 21; + s3 += carry2; + s2 -= int64_lshift21(carry2); + carry4 = (s4 + (1 << 20)) >> 21; + s5 += carry4; + s4 -= int64_lshift21(carry4); + carry6 = (s6 + (1 << 20)) >> 21; + s7 += carry6; + s6 -= int64_lshift21(carry6); + carry8 = (s8 + (1 << 20)) >> 21; + s9 += carry8; + s8 -= int64_lshift21(carry8); + carry10 = (s10 + (1 << 20)) >> 21; + s11 += carry10; + s10 -= int64_lshift21(carry10); + carry12 = (s12 + (1 << 20)) >> 21; + s13 += carry12; + s12 -= int64_lshift21(carry12); + carry14 = (s14 + (1 << 20)) >> 21; + s15 += carry14; + s14 -= int64_lshift21(carry14); + carry16 = (s16 + (1 << 20)) >> 21; + s17 += carry16; + s16 -= int64_lshift21(carry16); + carry18 = (s18 + (1 << 20)) >> 21; + s19 += carry18; + s18 -= int64_lshift21(carry18); + carry20 = (s20 + (1 << 20)) >> 21; + s21 += carry20; + s20 -= int64_lshift21(carry20); + carry22 = (s22 + (1 << 20)) >> 21; + s23 += carry22; + s22 -= int64_lshift21(carry22); + + carry1 = (s1 + (1 << 20)) >> 21; + s2 += carry1; + s1 -= int64_lshift21(carry1); + carry3 = (s3 + (1 << 20)) >> 21; + s4 += carry3; + s3 -= int64_lshift21(carry3); + carry5 = (s5 + (1 << 20)) >> 21; + s6 += carry5; + s5 -= int64_lshift21(carry5); + carry7 = (s7 + (1 << 20)) >> 21; + s8 += carry7; + s7 -= int64_lshift21(carry7); + carry9 = (s9 + (1 << 20)) >> 21; + s10 += carry9; + s9 -= int64_lshift21(carry9); + carry11 = (s11 + (1 << 20)) >> 21; + s12 += carry11; + s11 -= int64_lshift21(carry11); + carry13 = (s13 + (1 << 20)) >> 21; + s14 += carry13; + s13 -= int64_lshift21(carry13); + carry15 = (s15 + (1 << 20)) >> 21; + s16 += carry15; + s15 -= int64_lshift21(carry15); + carry17 = (s17 + (1 << 20)) >> 21; + s18 += carry17; + s17 -= int64_lshift21(carry17); + carry19 = (s19 + (1 << 20)) >> 21; + s20 += carry19; + s19 -= int64_lshift21(carry19); + carry21 = (s21 + (1 << 20)) >> 21; + s22 += carry21; + s21 -= int64_lshift21(carry21); + + s11 += s23 * 666643; + s12 += s23 * 470296; + s13 += s23 * 654183; + s14 -= s23 * 997805; + s15 += s23 * 136657; + s16 -= s23 * 683901; + s23 = 0; + + s10 += s22 * 666643; + s11 += s22 * 470296; + s12 += s22 * 654183; + s13 -= s22 * 997805; + s14 += s22 * 136657; + s15 -= s22 * 683901; + s22 = 0; + + s9 += s21 * 666643; + s10 += s21 * 470296; + s11 += s21 * 654183; + s12 -= s21 * 997805; + s13 += s21 * 136657; + s14 -= s21 * 683901; + s21 = 0; + + s8 += s20 * 666643; + s9 += s20 * 470296; + s10 += s20 * 654183; + s11 -= s20 * 997805; + s12 += s20 * 136657; + s13 -= s20 * 683901; + s20 = 0; + + s7 += s19 * 666643; + s8 += s19 * 470296; + s9 += s19 * 654183; + s10 -= s19 * 997805; + s11 += s19 * 136657; + s12 -= s19 * 683901; + s19 = 0; + + s6 += s18 * 666643; + s7 += s18 * 470296; + s8 += s18 * 654183; + s9 -= s18 * 997805; + s10 += s18 * 136657; + s11 -= s18 * 683901; + s18 = 0; + + carry6 = (s6 + (1 << 20)) >> 21; + s7 += carry6; + s6 -= int64_lshift21(carry6); + carry8 = (s8 + (1 << 20)) >> 21; + s9 += carry8; + s8 -= int64_lshift21(carry8); + carry10 = (s10 + (1 << 20)) >> 21; + s11 += carry10; + s10 -= int64_lshift21(carry10); + carry12 = (s12 + (1 << 20)) >> 21; + s13 += carry12; + s12 -= int64_lshift21(carry12); + carry14 = (s14 + (1 << 20)) >> 21; + s15 += carry14; + s14 -= int64_lshift21(carry14); + carry16 = (s16 + (1 << 20)) >> 21; + s17 += carry16; + s16 -= int64_lshift21(carry16); + + carry7 = (s7 + (1 << 20)) >> 21; + s8 += carry7; + s7 -= int64_lshift21(carry7); + carry9 = (s9 + (1 << 20)) >> 21; + s10 += carry9; + s9 -= int64_lshift21(carry9); + carry11 = (s11 + (1 << 20)) >> 21; + s12 += carry11; + s11 -= int64_lshift21(carry11); + carry13 = (s13 + (1 << 20)) >> 21; + s14 += carry13; + s13 -= int64_lshift21(carry13); + carry15 = (s15 + (1 << 20)) >> 21; + s16 += carry15; + s15 -= int64_lshift21(carry15); + + s5 += s17 * 666643; + s6 += s17 * 470296; + s7 += s17 * 654183; + s8 -= s17 * 997805; + s9 += s17 * 136657; + s10 -= s17 * 683901; + s17 = 0; + + s4 += s16 * 666643; + s5 += s16 * 470296; + s6 += s16 * 654183; + s7 -= s16 * 997805; + s8 += s16 * 136657; + s9 -= s16 * 683901; + s16 = 0; + + s3 += s15 * 666643; + s4 += s15 * 470296; + s5 += s15 * 654183; + s6 -= s15 * 997805; + s7 += s15 * 136657; + s8 -= s15 * 683901; + s15 = 0; + + s2 += s14 * 666643; + s3 += s14 * 470296; + s4 += s14 * 654183; + s5 -= s14 * 997805; + s6 += s14 * 136657; + s7 -= s14 * 683901; + s14 = 0; + + s1 += s13 * 666643; + s2 += s13 * 470296; + s3 += s13 * 654183; + s4 -= s13 * 997805; + s5 += s13 * 136657; + s6 -= s13 * 683901; + s13 = 0; + + s0 += s12 * 666643; + s1 += s12 * 470296; + s2 += s12 * 654183; + s3 -= s12 * 997805; + s4 += s12 * 136657; + s5 -= s12 * 683901; + s12 = 0; + + carry0 = (s0 + (1 << 20)) >> 21; + s1 += carry0; + s0 -= int64_lshift21(carry0); + carry2 = (s2 + (1 << 20)) >> 21; + s3 += carry2; + s2 -= int64_lshift21(carry2); + carry4 = (s4 + (1 << 20)) >> 21; + s5 += carry4; + s4 -= int64_lshift21(carry4); + carry6 = (s6 + (1 << 20)) >> 21; + s7 += carry6; + s6 -= int64_lshift21(carry6); + carry8 = (s8 + (1 << 20)) >> 21; + s9 += carry8; + s8 -= int64_lshift21(carry8); + carry10 = (s10 + (1 << 20)) >> 21; + s11 += carry10; + s10 -= int64_lshift21(carry10); + + carry1 = (s1 + (1 << 20)) >> 21; + s2 += carry1; + s1 -= int64_lshift21(carry1); + carry3 = (s3 + (1 << 20)) >> 21; + s4 += carry3; + s3 -= int64_lshift21(carry3); + carry5 = (s5 + (1 << 20)) >> 21; + s6 += carry5; + s5 -= int64_lshift21(carry5); + carry7 = (s7 + (1 << 20)) >> 21; + s8 += carry7; + s7 -= int64_lshift21(carry7); + carry9 = (s9 + (1 << 20)) >> 21; + s10 += carry9; + s9 -= int64_lshift21(carry9); + carry11 = (s11 + (1 << 20)) >> 21; + s12 += carry11; + s11 -= int64_lshift21(carry11); + + s0 += s12 * 666643; + s1 += s12 * 470296; + s2 += s12 * 654183; + s3 -= s12 * 997805; + s4 += s12 * 136657; + s5 -= s12 * 683901; + s12 = 0; + + carry0 = s0 >> 21; + s1 += carry0; + s0 -= int64_lshift21(carry0); + carry1 = s1 >> 21; + s2 += carry1; + s1 -= int64_lshift21(carry1); + carry2 = s2 >> 21; + s3 += carry2; + s2 -= int64_lshift21(carry2); + carry3 = s3 >> 21; + s4 += carry3; + s3 -= int64_lshift21(carry3); + carry4 = s4 >> 21; + s5 += carry4; + s4 -= int64_lshift21(carry4); + carry5 = s5 >> 21; + s6 += carry5; + s5 -= int64_lshift21(carry5); + carry6 = s6 >> 21; + s7 += carry6; + s6 -= int64_lshift21(carry6); + carry7 = s7 >> 21; + s8 += carry7; + s7 -= int64_lshift21(carry7); + carry8 = s8 >> 21; + s9 += carry8; + s8 -= int64_lshift21(carry8); + carry9 = s9 >> 21; + s10 += carry9; + s9 -= int64_lshift21(carry9); + carry10 = s10 >> 21; + s11 += carry10; + s10 -= int64_lshift21(carry10); + carry11 = s11 >> 21; + s12 += carry11; + s11 -= int64_lshift21(carry11); + + s0 += s12 * 666643; + s1 += s12 * 470296; + s2 += s12 * 654183; + s3 -= s12 * 997805; + s4 += s12 * 136657; + s5 -= s12 * 683901; + s12 = 0; + + carry0 = s0 >> 21; + s1 += carry0; + s0 -= int64_lshift21(carry0); + carry1 = s1 >> 21; + s2 += carry1; + s1 -= int64_lshift21(carry1); + carry2 = s2 >> 21; + s3 += carry2; + s2 -= int64_lshift21(carry2); + carry3 = s3 >> 21; + s4 += carry3; + s3 -= int64_lshift21(carry3); + carry4 = s4 >> 21; + s5 += carry4; + s4 -= int64_lshift21(carry4); + carry5 = s5 >> 21; + s6 += carry5; + s5 -= int64_lshift21(carry5); + carry6 = s6 >> 21; + s7 += carry6; + s6 -= int64_lshift21(carry6); + carry7 = s7 >> 21; + s8 += carry7; + s7 -= int64_lshift21(carry7); + carry8 = s8 >> 21; + s9 += carry8; + s8 -= int64_lshift21(carry8); + carry9 = s9 >> 21; + s10 += carry9; + s9 -= int64_lshift21(carry9); + carry10 = s10 >> 21; + s11 += carry10; + s10 -= int64_lshift21(carry10); + + s[0] = s0 >> 0; + s[1] = s0 >> 8; + s[2] = (s0 >> 16) | (s1 << 5); + s[3] = s1 >> 3; + s[4] = s1 >> 11; + s[5] = (s1 >> 19) | (s2 << 2); + s[6] = s2 >> 6; + s[7] = (s2 >> 14) | (s3 << 7); + s[8] = s3 >> 1; + s[9] = s3 >> 9; + s[10] = (s3 >> 17) | (s4 << 4); + s[11] = s4 >> 4; + s[12] = s4 >> 12; + s[13] = (s4 >> 20) | (s5 << 1); + s[14] = s5 >> 7; + s[15] = (s5 >> 15) | (s6 << 6); + s[16] = s6 >> 2; + s[17] = s6 >> 10; + s[18] = (s6 >> 18) | (s7 << 3); + s[19] = s7 >> 5; + s[20] = s7 >> 13; + s[21] = s8 >> 0; + s[22] = s8 >> 8; + s[23] = (s8 >> 16) | (s9 << 5); + s[24] = s9 >> 3; + s[25] = s9 >> 11; + s[26] = (s9 >> 19) | (s10 << 2); + s[27] = s10 >> 6; + s[28] = (s10 >> 14) | (s11 << 7); + s[29] = s11 >> 1; + s[30] = s11 >> 9; + s[31] = s11 >> 17; +} + + +void x25519_scalar_mult_generic_masked(uint8_t out[32], + const uint8_t scalar_masked[32], + const uint8_t point[32]) { + fe x1, x2, z2, x3, z3, tmp0, tmp1; + fe_loose x2l, z2l, x3l, tmp0l, tmp1l; + + uint8_t e[32]; + OPENSSL_memcpy(e, scalar_masked, 32); + // The following implementation was transcribed to Coq and proven to + // correspond to unary scalar multiplication in affine coordinates given that + // x1 != 0 is the x coordinate of some point on the curve. It was also checked + // in Coq that doing a ladderstep with x1 = x3 = 0 gives z2' = z3' = 0, and z2 + // = z3 = 0 gives z2' = z3' = 0. The statement was quantified over the + // underlying field, so it applies to Curve25519 itself and the quadratic + // twist of Curve25519. It was not proven in Coq that prime-field arithmetic + // correctly simulates extension-field arithmetic on prime-field values. + // The decoding of the byte array representation of e was not considered. + // Specification of Montgomery curves in affine coordinates: + // + // Proof that these form a group that is isomorphic to a Weierstrass curve: + // + // Coq transcription and correctness proof of the loop (where scalarbits=255): + // + // + // preconditions: 0 <= e < 2^255 (not necessarily e < order), fe_invert(0) = 0 + fe_frombytes(&x1, point); + fe_1(&x2); + fe_0(&z2); + fe_copy(&x3, &x1); + fe_1(&z3); + + unsigned swap = 0; + int pos; + for (pos = 254; pos >= 0; --pos) { + // loop invariant as of right before the test, for the case where x1 != 0: + // pos >= -1; if z2 = 0 then x2 is nonzero; if z3 = 0 then x3 is nonzero + // let r := e >> (pos+1) in the following equalities of projective points: + // to_xz (r*P) === if swap then (x3, z3) else (x2, z2) + // to_xz ((r+1)*P) === if swap then (x2, z2) else (x3, z3) + // x1 is the nonzero x coordinate of the nonzero point (r*P-(r+1)*P) + unsigned b = 1 & (e[pos / 8] >> (pos & 7)); + swap ^= b; + fe_cswap(&x2, &x3, swap); + fe_cswap(&z2, &z3, swap); + swap = b; + // Coq transcription of ladderstep formula (called from transcribed loop): + // + // + // x1 != 0 + // x1 = 0 + fe_sub(&tmp0l, &x3, &z3); + fe_sub(&tmp1l, &x2, &z2); + fe_add(&x2l, &x2, &z2); + fe_add(&z2l, &x3, &z3); + fe_mul_tll(&z3, &tmp0l, &x2l); + fe_mul_tll(&z2, &z2l, &tmp1l); + fe_sq_tl(&tmp0, &tmp1l); + fe_sq_tl(&tmp1, &x2l); + fe_add(&x3l, &z3, &z2); + fe_sub(&z2l, &z3, &z2); + fe_mul_ttt(&x2, &tmp1, &tmp0); + fe_sub(&tmp1l, &tmp1, &tmp0); + fe_sq_tl(&z2, &z2l); + fe_mul121666(&z3, &tmp1l); + fe_sq_tl(&x3, &x3l); + fe_add(&tmp0l, &tmp0, &z3); + fe_mul_ttt(&z3, &x1, &z2); + fe_mul_tll(&z2, &tmp1l, &tmp0l); + } + // here pos=-1, so r=e, so to_xz (e*P) === if swap then (x3, z3) else (x2, z2) + fe_cswap(&x2, &x3, swap); + fe_cswap(&z2, &z3, swap); + + fe_invert(&z2, &z2); + fe_mul_ttt(&x2, &x2, &z2); + fe_tobytes(out, &x2); +} + +void x25519_public_from_private_generic_masked(uint8_t out_public_value[32], + const uint8_t private_key_masked[32], + int use_adx) { + uint8_t e[32]; + OPENSSL_memcpy(e, private_key_masked, 32); + + ge_p3 A; + x25519_ge_scalarmult_base(&A, e, use_adx); + + // We only need the u-coordinate of the curve25519 point. The map is + // u=(y+1)/(1-y). Since y=Y/Z, this gives u=(Z+Y)/(Z-Y). + fe_loose zplusy, zminusy; + fe zminusy_inv; + fe_add(&zplusy, &A.Z, &A.Y); + fe_sub(&zminusy, &A.Z, &A.Y); + fe_loose_invert(&zminusy_inv, &zminusy); + fe_mul_tlt(&zminusy_inv, &zplusy, &zminusy_inv); + fe_tobytes(out_public_value, &zminusy_inv); + CONSTTIME_DECLASSIFY(out_public_value, 32); +} + +void x25519_fe_invert(fe *out, const fe *z) { + fe_invert(out, z); +} + +uint8_t x25519_fe_isnegative(const fe *f) { + return (uint8_t)fe_isnegative(f); +} + +void x25519_fe_mul_ttt(fe *h, const fe *f, const fe *g) { + fe_mul_ttt(h, f, g); +} + +void x25519_fe_neg(fe *f) { + fe_loose t; + fe_neg(&t, f); + fe_carry(f, &t); +} + +void x25519_fe_tobytes(uint8_t s[32], const fe *h) { + fe_tobytes(s, h); +} + +void x25519_ge_double_scalarmult_vartime(ge_p2 *r, const uint8_t *a, + const ge_p3 *A, const uint8_t *b) { + ge_double_scalarmult_vartime(r, a, A, b); +} + +void x25519_sc_mask(uint8_t a[32]) { + a[0] &= 248; + a[31] &= 127; + a[31] |= 64; +} + +void x25519_sc_muladd(uint8_t *s, const uint8_t *a, const uint8_t *b, + const uint8_t *c) { + sc_muladd(s, a, b, c); +} diff --git a/http/vendor/ring/crypto/curve25519/curve25519_64_adx.c b/http/vendor/ring/crypto/curve25519/curve25519_64_adx.c new file mode 100644 index 0000000..88964a9 --- /dev/null +++ b/http/vendor/ring/crypto/curve25519/curve25519_64_adx.c @@ -0,0 +1,23 @@ +// Copyright 2023 The BoringSSL Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "internal.h" +#if defined(BORINGSSL_FE25519_ADX) + +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wpedantic" +#pragma GCC diagnostic ignored "-Wsign-conversion" + +#include "../../third_party/fiat/curve25519_64_adx.h" +#endif diff --git a/http/vendor/ring/crypto/curve25519/curve25519_tables.h b/http/vendor/ring/crypto/curve25519/curve25519_tables.h new file mode 100644 index 0000000..72caa33 --- /dev/null +++ b/http/vendor/ring/crypto/curve25519/curve25519_tables.h @@ -0,0 +1,3264 @@ +// Copyright 2020 The BoringSSL Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This file is generated from +// ./make_curve25519_tables.py > curve25519_tables.h + + +static const fe d = {{ +#if defined(OPENSSL_64_BIT) + 929955233495203, 466365720129213, 1662059464998953, 2033849074728123, + 1442794654840575 +#else + 56195235, 13857412, 51736253, 6949390, 114729, 24766616, 60832955, 30306712, + 48412415, 21499315 +#endif +}}; + +static const fe sqrtm1 = {{ +#if defined(OPENSSL_64_BIT) + 1718705420411056, 234908883556509, 2233514472574048, 2117202627021982, + 765476049583133 +#else + 34513072, 25610706, 9377949, 3500415, 12389472, 33281959, 41962654, + 31548777, 326685, 11406482 +#endif +}}; + +static const fe d2 = {{ +#if defined(OPENSSL_64_BIT) + 1859910466990425, 932731440258426, 1072319116312658, 1815898335770999, + 633789495995903 +#else + 45281625, 27714825, 36363642, 13898781, 229458, 15978800, 54557047, + 27058993, 29715967, 9444199 +#endif +}}; + +#if defined(OPENSSL_SMALL) + +// This block of code replaces the standard base-point table with a much smaller +// one. The standard table is 30,720 bytes while this one is just 960. +// +// This table contains 15 pairs of group elements, (x, y), where each field +// element is serialised with |fe_tobytes|. If |i| is the index of the group +// element then consider i+1 as a four-bit number: (i₀, i₁, i₂, i₃) (where i₀ +// is the most significant bit). The value of the group element is then: +// (i₀×2^192 + i₁×2^128 + i₂×2^64 + i₃)G, where G is the generator. +static const uint8_t k25519SmallPrecomp[15 * 2 * 32] = { + 0x1a, 0xd5, 0x25, 0x8f, 0x60, 0x2d, 0x56, 0xc9, 0xb2, 0xa7, 0x25, 0x95, + 0x60, 0xc7, 0x2c, 0x69, 0x5c, 0xdc, 0xd6, 0xfd, 0x31, 0xe2, 0xa4, 0xc0, + 0xfe, 0x53, 0x6e, 0xcd, 0xd3, 0x36, 0x69, 0x21, 0x58, 0x66, 0x66, 0x66, + 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, + 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, + 0x66, 0x66, 0x66, 0x66, 0x02, 0xa2, 0xed, 0xf4, 0x8f, 0x6b, 0x0b, 0x3e, + 0xeb, 0x35, 0x1a, 0xd5, 0x7e, 0xdb, 0x78, 0x00, 0x96, 0x8a, 0xa0, 0xb4, + 0xcf, 0x60, 0x4b, 0xd4, 0xd5, 0xf9, 0x2d, 0xbf, 0x88, 0xbd, 0x22, 0x62, + 0x13, 0x53, 0xe4, 0x82, 0x57, 0xfa, 0x1e, 0x8f, 0x06, 0x2b, 0x90, 0xba, + 0x08, 0xb6, 0x10, 0x54, 0x4f, 0x7c, 0x1b, 0x26, 0xed, 0xda, 0x6b, 0xdd, + 0x25, 0xd0, 0x4e, 0xea, 0x42, 0xbb, 0x25, 0x03, 0xa2, 0xfb, 0xcc, 0x61, + 0x67, 0x06, 0x70, 0x1a, 0xc4, 0x78, 0x3a, 0xff, 0x32, 0x62, 0xdd, 0x2c, + 0xab, 0x50, 0x19, 0x3b, 0xf2, 0x9b, 0x7d, 0xb8, 0xfd, 0x4f, 0x29, 0x9c, + 0xa7, 0x91, 0xba, 0x0e, 0x46, 0x5e, 0x51, 0xfe, 0x1d, 0xbf, 0xe5, 0xe5, + 0x9b, 0x95, 0x0d, 0x67, 0xf8, 0xd1, 0xb5, 0x5a, 0xa1, 0x93, 0x2c, 0xc3, + 0xde, 0x0e, 0x97, 0x85, 0x2d, 0x7f, 0xea, 0xab, 0x3e, 0x47, 0x30, 0x18, + 0x24, 0xe8, 0xb7, 0x60, 0xae, 0x47, 0x80, 0xfc, 0xe5, 0x23, 0xe7, 0xc2, + 0xc9, 0x85, 0xe6, 0x98, 0xa0, 0x29, 0x4e, 0xe1, 0x84, 0x39, 0x2d, 0x95, + 0x2c, 0xf3, 0x45, 0x3c, 0xff, 0xaf, 0x27, 0x4c, 0x6b, 0xa6, 0xf5, 0x4b, + 0x11, 0xbd, 0xba, 0x5b, 0x9e, 0xc4, 0xa4, 0x51, 0x1e, 0xbe, 0xd0, 0x90, + 0x3a, 0x9c, 0xc2, 0x26, 0xb6, 0x1e, 0xf1, 0x95, 0x7d, 0xc8, 0x6d, 0x52, + 0xe6, 0x99, 0x2c, 0x5f, 0x9a, 0x96, 0x0c, 0x68, 0x29, 0xfd, 0xe2, 0xfb, + 0xe6, 0xbc, 0xec, 0x31, 0x08, 0xec, 0xe6, 0xb0, 0x53, 0x60, 0xc3, 0x8c, + 0xbe, 0xc1, 0xb3, 0x8a, 0x8f, 0xe4, 0x88, 0x2b, 0x55, 0xe5, 0x64, 0x6e, + 0x9b, 0xd0, 0xaf, 0x7b, 0x64, 0x2a, 0x35, 0x25, 0x10, 0x52, 0xc5, 0x9e, + 0x58, 0x11, 0x39, 0x36, 0x45, 0x51, 0xb8, 0x39, 0x93, 0xfc, 0x9d, 0x6a, + 0xbe, 0x58, 0xcb, 0xa4, 0x0f, 0x51, 0x3c, 0x38, 0x05, 0xca, 0xab, 0x43, + 0x63, 0x0e, 0xf3, 0x8b, 0x41, 0xa6, 0xf8, 0x9b, 0x53, 0x70, 0x80, 0x53, + 0x86, 0x5e, 0x8f, 0xe3, 0xc3, 0x0d, 0x18, 0xc8, 0x4b, 0x34, 0x1f, 0xd8, + 0x1d, 0xbc, 0xf2, 0x6d, 0x34, 0x3a, 0xbe, 0xdf, 0xd9, 0xf6, 0xf3, 0x89, + 0xa1, 0xe1, 0x94, 0x9f, 0x5d, 0x4c, 0x5d, 0xe9, 0xa1, 0x49, 0x92, 0xef, + 0x0e, 0x53, 0x81, 0x89, 0x58, 0x87, 0xa6, 0x37, 0xf1, 0xdd, 0x62, 0x60, + 0x63, 0x5a, 0x9d, 0x1b, 0x8c, 0xc6, 0x7d, 0x52, 0xea, 0x70, 0x09, 0x6a, + 0xe1, 0x32, 0xf3, 0x73, 0x21, 0x1f, 0x07, 0x7b, 0x7c, 0x9b, 0x49, 0xd8, + 0xc0, 0xf3, 0x25, 0x72, 0x6f, 0x9d, 0xed, 0x31, 0x67, 0x36, 0x36, 0x54, + 0x40, 0x92, 0x71, 0xe6, 0x11, 0x28, 0x11, 0xad, 0x93, 0x32, 0x85, 0x7b, + 0x3e, 0xb7, 0x3b, 0x49, 0x13, 0x1c, 0x07, 0xb0, 0x2e, 0x93, 0xaa, 0xfd, + 0xfd, 0x28, 0x47, 0x3d, 0x8d, 0xd2, 0xda, 0xc7, 0x44, 0xd6, 0x7a, 0xdb, + 0x26, 0x7d, 0x1d, 0xb8, 0xe1, 0xde, 0x9d, 0x7a, 0x7d, 0x17, 0x7e, 0x1c, + 0x37, 0x04, 0x8d, 0x2d, 0x7c, 0x5e, 0x18, 0x38, 0x1e, 0xaf, 0xc7, 0x1b, + 0x33, 0x48, 0x31, 0x00, 0x59, 0xf6, 0xf2, 0xca, 0x0f, 0x27, 0x1b, 0x63, + 0x12, 0x7e, 0x02, 0x1d, 0x49, 0xc0, 0x5d, 0x79, 0x87, 0xef, 0x5e, 0x7a, + 0x2f, 0x1f, 0x66, 0x55, 0xd8, 0x09, 0xd9, 0x61, 0x38, 0x68, 0xb0, 0x07, + 0xa3, 0xfc, 0xcc, 0x85, 0x10, 0x7f, 0x4c, 0x65, 0x65, 0xb3, 0xfa, 0xfa, + 0xa5, 0x53, 0x6f, 0xdb, 0x74, 0x4c, 0x56, 0x46, 0x03, 0xe2, 0xd5, 0x7a, + 0x29, 0x1c, 0xc6, 0x02, 0xbc, 0x59, 0xf2, 0x04, 0x75, 0x63, 0xc0, 0x84, + 0x2f, 0x60, 0x1c, 0x67, 0x76, 0xfd, 0x63, 0x86, 0xf3, 0xfa, 0xbf, 0xdc, + 0xd2, 0x2d, 0x90, 0x91, 0xbd, 0x33, 0xa9, 0xe5, 0x66, 0x0c, 0xda, 0x42, + 0x27, 0xca, 0xf4, 0x66, 0xc2, 0xec, 0x92, 0x14, 0x57, 0x06, 0x63, 0xd0, + 0x4d, 0x15, 0x06, 0xeb, 0x69, 0x58, 0x4f, 0x77, 0xc5, 0x8b, 0xc7, 0xf0, + 0x8e, 0xed, 0x64, 0xa0, 0xb3, 0x3c, 0x66, 0x71, 0xc6, 0x2d, 0xda, 0x0a, + 0x0d, 0xfe, 0x70, 0x27, 0x64, 0xf8, 0x27, 0xfa, 0xf6, 0x5f, 0x30, 0xa5, + 0x0d, 0x6c, 0xda, 0xf2, 0x62, 0x5e, 0x78, 0x47, 0xd3, 0x66, 0x00, 0x1c, + 0xfd, 0x56, 0x1f, 0x5d, 0x3f, 0x6f, 0xf4, 0x4c, 0xd8, 0xfd, 0x0e, 0x27, + 0xc9, 0x5c, 0x2b, 0xbc, 0xc0, 0xa4, 0xe7, 0x23, 0x29, 0x02, 0x9f, 0x31, + 0xd6, 0xe9, 0xd7, 0x96, 0xf4, 0xe0, 0x5e, 0x0b, 0x0e, 0x13, 0xee, 0x3c, + 0x09, 0xed, 0xf2, 0x3d, 0x76, 0x91, 0xc3, 0xa4, 0x97, 0xae, 0xd4, 0x87, + 0xd0, 0x5d, 0xf6, 0x18, 0x47, 0x1f, 0x1d, 0x67, 0xf2, 0xcf, 0x63, 0xa0, + 0x91, 0x27, 0xf8, 0x93, 0x45, 0x75, 0x23, 0x3f, 0xd1, 0xf1, 0xad, 0x23, + 0xdd, 0x64, 0x93, 0x96, 0x41, 0x70, 0x7f, 0xf7, 0xf5, 0xa9, 0x89, 0xa2, + 0x34, 0xb0, 0x8d, 0x1b, 0xae, 0x19, 0x15, 0x49, 0x58, 0x23, 0x6d, 0x87, + 0x15, 0x4f, 0x81, 0x76, 0xfb, 0x23, 0xb5, 0xea, 0xcf, 0xac, 0x54, 0x8d, + 0x4e, 0x42, 0x2f, 0xeb, 0x0f, 0x63, 0xdb, 0x68, 0x37, 0xa8, 0xcf, 0x8b, + 0xab, 0xf5, 0xa4, 0x6e, 0x96, 0x2a, 0xb2, 0xd6, 0xbe, 0x9e, 0xbd, 0x0d, + 0xb4, 0x42, 0xa9, 0xcf, 0x01, 0x83, 0x8a, 0x17, 0x47, 0x76, 0xc4, 0xc6, + 0x83, 0x04, 0x95, 0x0b, 0xfc, 0x11, 0xc9, 0x62, 0xb8, 0x0c, 0x76, 0x84, + 0xd9, 0xb9, 0x37, 0xfa, 0xfc, 0x7c, 0xc2, 0x6d, 0x58, 0x3e, 0xb3, 0x04, + 0xbb, 0x8c, 0x8f, 0x48, 0xbc, 0x91, 0x27, 0xcc, 0xf9, 0xb7, 0x22, 0x19, + 0x83, 0x2e, 0x09, 0xb5, 0x72, 0xd9, 0x54, 0x1c, 0x4d, 0xa1, 0xea, 0x0b, + 0xf1, 0xc6, 0x08, 0x72, 0x46, 0x87, 0x7a, 0x6e, 0x80, 0x56, 0x0a, 0x8a, + 0xc0, 0xdd, 0x11, 0x6b, 0xd6, 0xdd, 0x47, 0xdf, 0x10, 0xd9, 0xd8, 0xea, + 0x7c, 0xb0, 0x8f, 0x03, 0x00, 0x2e, 0xc1, 0x8f, 0x44, 0xa8, 0xd3, 0x30, + 0x06, 0x89, 0xa2, 0xf9, 0x34, 0xad, 0xdc, 0x03, 0x85, 0xed, 0x51, 0xa7, + 0x82, 0x9c, 0xe7, 0x5d, 0x52, 0x93, 0x0c, 0x32, 0x9a, 0x5b, 0xe1, 0xaa, + 0xca, 0xb8, 0x02, 0x6d, 0x3a, 0xd4, 0xb1, 0x3a, 0xf0, 0x5f, 0xbe, 0xb5, + 0x0d, 0x10, 0x6b, 0x38, 0x32, 0xac, 0x76, 0x80, 0xbd, 0xca, 0x94, 0x71, + 0x7a, 0xf2, 0xc9, 0x35, 0x2a, 0xde, 0x9f, 0x42, 0x49, 0x18, 0x01, 0xab, + 0xbc, 0xef, 0x7c, 0x64, 0x3f, 0x58, 0x3d, 0x92, 0x59, 0xdb, 0x13, 0xdb, + 0x58, 0x6e, 0x0a, 0xe0, 0xb7, 0x91, 0x4a, 0x08, 0x20, 0xd6, 0x2e, 0x3c, + 0x45, 0xc9, 0x8b, 0x17, 0x79, 0xe7, 0xc7, 0x90, 0x99, 0x3a, 0x18, 0x25, +}; + +#else + +// k25519Precomp[i][j] = (j+1)*256^i*B +const uint8_t k25519Precomp[32][8][3][32] = { + { + { + {0x85, 0x3b, 0x8c, 0xf5, 0xc6, 0x93, 0xbc, 0x2f, 0x19, 0xe, 0x8c, + 0xfb, 0xc6, 0x2d, 0x93, 0xcf, 0xc2, 0x42, 0x3d, 0x64, 0x98, 0x48, + 0xb, 0x27, 0x65, 0xba, 0xd4, 0x33, 0x3a, 0x9d, 0xcf, 0x7}, + {0x3e, 0x91, 0x40, 0xd7, 0x5, 0x39, 0x10, 0x9d, 0xb3, 0xbe, 0x40, + 0xd1, 0x5, 0x9f, 0x39, 0xfd, 0x9, 0x8a, 0x8f, 0x68, 0x34, 0x84, + 0xc1, 0xa5, 0x67, 0x12, 0xf8, 0x98, 0x92, 0x2f, 0xfd, 0x44}, + {0x68, 0xaa, 0x7a, 0x87, 0x5, 0x12, 0xc9, 0xab, 0x9e, 0xc4, 0xaa, + 0xcc, 0x23, 0xe8, 0xd9, 0x26, 0x8c, 0x59, 0x43, 0xdd, 0xcb, 0x7d, + 0x1b, 0x5a, 0xa8, 0x65, 0xc, 0x9f, 0x68, 0x7b, 0x11, 0x6f}, + }, + { + {0xd7, 0x71, 0x3c, 0x93, 0xfc, 0xe7, 0x24, 0x92, 0xb5, 0xf5, 0xf, + 0x7a, 0x96, 0x9d, 0x46, 0x9f, 0x2, 0x7, 0xd6, 0xe1, 0x65, 0x9a, + 0xa6, 0x5a, 0x2e, 0x2e, 0x7d, 0xa8, 0x3f, 0x6, 0xc, 0x59}, + {0xa8, 0xd5, 0xb4, 0x42, 0x60, 0xa5, 0x99, 0x8a, 0xf6, 0xac, 0x60, + 0x4e, 0xc, 0x81, 0x2b, 0x8f, 0xaa, 0x37, 0x6e, 0xb1, 0x6b, 0x23, + 0x9e, 0xe0, 0x55, 0x25, 0xc9, 0x69, 0xa6, 0x95, 0xb5, 0x6b}, + {0x5f, 0x7a, 0x9b, 0xa5, 0xb3, 0xa8, 0xfa, 0x43, 0x78, 0xcf, 0x9a, + 0x5d, 0xdd, 0x6b, 0xc1, 0x36, 0x31, 0x6a, 0x3d, 0xb, 0x84, 0xa0, + 0xf, 0x50, 0x73, 0xb, 0xa5, 0x3e, 0xb1, 0xf5, 0x1a, 0x70}, + }, + { + {0x30, 0x97, 0xee, 0x4c, 0xa8, 0xb0, 0x25, 0xaf, 0x8a, 0x4b, 0x86, + 0xe8, 0x30, 0x84, 0x5a, 0x2, 0x32, 0x67, 0x1, 0x9f, 0x2, 0x50, + 0x1b, 0xc1, 0xf4, 0xf8, 0x80, 0x9a, 0x1b, 0x4e, 0x16, 0x7a}, + {0x65, 0xd2, 0xfc, 0xa4, 0xe8, 0x1f, 0x61, 0x56, 0x7d, 0xba, 0xc1, + 0xe5, 0xfd, 0x53, 0xd3, 0x3b, 0xbd, 0xd6, 0x4b, 0x21, 0x1a, 0xf3, + 0x31, 0x81, 0x62, 0xda, 0x5b, 0x55, 0x87, 0x15, 0xb9, 0x2a}, + {0x89, 0xd8, 0xd0, 0xd, 0x3f, 0x93, 0xae, 0x14, 0x62, 0xda, 0x35, + 0x1c, 0x22, 0x23, 0x94, 0x58, 0x4c, 0xdb, 0xf2, 0x8c, 0x45, 0xe5, + 0x70, 0xd1, 0xc6, 0xb4, 0xb9, 0x12, 0xaf, 0x26, 0x28, 0x5a}, + }, + { + {0x9f, 0x9, 0xfc, 0x8e, 0xb9, 0x51, 0x73, 0x28, 0x38, 0x25, 0xfd, + 0x7d, 0xf4, 0xc6, 0x65, 0x67, 0x65, 0x92, 0xa, 0xfb, 0x3d, 0x8d, + 0x34, 0xca, 0x27, 0x87, 0xe5, 0x21, 0x3, 0x91, 0xe, 0x68}, + {0xbf, 0x18, 0x68, 0x5, 0xa, 0x5, 0xfe, 0x95, 0xa9, 0xfa, 0x60, + 0x56, 0x71, 0x89, 0x7e, 0x32, 0x73, 0x50, 0xa0, 0x6, 0xcd, 0xe3, + 0xe8, 0xc3, 0x9a, 0xa4, 0x45, 0x74, 0x4c, 0x3f, 0x93, 0x27}, + {0x9, 0xff, 0x76, 0xc4, 0xe9, 0xfb, 0x13, 0x5a, 0x72, 0xc1, 0x5c, + 0x7b, 0x45, 0x39, 0x9e, 0x6e, 0x94, 0x44, 0x2b, 0x10, 0xf9, 0xdc, + 0xdb, 0x5d, 0x2b, 0x3e, 0x55, 0x63, 0xbf, 0xc, 0x9d, 0x7f}, + }, + { + {0x33, 0xbb, 0xa5, 0x8, 0x44, 0xbc, 0x12, 0xa2, 0x2, 0xed, 0x5e, + 0xc7, 0xc3, 0x48, 0x50, 0x8d, 0x44, 0xec, 0xbf, 0x5a, 0xc, 0xeb, + 0x1b, 0xdd, 0xeb, 0x6, 0xe2, 0x46, 0xf1, 0xcc, 0x45, 0x29}, + {0xba, 0xd6, 0x47, 0xa4, 0xc3, 0x82, 0x91, 0x7f, 0xb7, 0x29, 0x27, + 0x4b, 0xd1, 0x14, 0x0, 0xd5, 0x87, 0xa0, 0x64, 0xb8, 0x1c, 0xf1, + 0x3c, 0xe3, 0xf3, 0x55, 0x1b, 0xeb, 0x73, 0x7e, 0x4a, 0x15}, + {0x85, 0x82, 0x2a, 0x81, 0xf1, 0xdb, 0xbb, 0xbc, 0xfc, 0xd1, 0xbd, + 0xd0, 0x7, 0x8, 0xe, 0x27, 0x2d, 0xa7, 0xbd, 0x1b, 0xb, 0x67, + 0x1b, 0xb4, 0x9a, 0xb6, 0x3b, 0x6b, 0x69, 0xbe, 0xaa, 0x43}, + }, + { + {0x31, 0x71, 0x15, 0x77, 0xeb, 0xee, 0xc, 0x3a, 0x88, 0xaf, 0xc8, + 0x0, 0x89, 0x15, 0x27, 0x9b, 0x36, 0xa7, 0x59, 0xda, 0x68, 0xb6, + 0x65, 0x80, 0xbd, 0x38, 0xcc, 0xa2, 0xb6, 0x7b, 0xe5, 0x51}, + {0xa4, 0x8c, 0x7d, 0x7b, 0xb6, 0x6, 0x98, 0x49, 0x39, 0x27, 0xd2, + 0x27, 0x84, 0xe2, 0x5b, 0x57, 0xb9, 0x53, 0x45, 0x20, 0xe7, 0x5c, + 0x8, 0xbb, 0x84, 0x78, 0x41, 0xae, 0x41, 0x4c, 0xb6, 0x38}, + {0x71, 0x4b, 0xea, 0x2, 0x67, 0x32, 0xac, 0x85, 0x1, 0xbb, 0xa1, + 0x41, 0x3, 0xe0, 0x70, 0xbe, 0x44, 0xc1, 0x3b, 0x8, 0x4b, 0xa2, + 0xe4, 0x53, 0xe3, 0x61, 0xd, 0x9f, 0x1a, 0xe9, 0xb8, 0x10}, + }, + { + {0xbf, 0xa3, 0x4e, 0x94, 0xd0, 0x5c, 0x1a, 0x6b, 0xd2, 0xc0, 0x9d, + 0xb3, 0x3a, 0x35, 0x70, 0x74, 0x49, 0x2e, 0x54, 0x28, 0x82, 0x52, + 0xb2, 0x71, 0x7e, 0x92, 0x3c, 0x28, 0x69, 0xea, 0x1b, 0x46}, + {0xb1, 0x21, 0x32, 0xaa, 0x9a, 0x2c, 0x6f, 0xba, 0xa7, 0x23, 0xba, + 0x3b, 0x53, 0x21, 0xa0, 0x6c, 0x3a, 0x2c, 0x19, 0x92, 0x4f, 0x76, + 0xea, 0x9d, 0xe0, 0x17, 0x53, 0x2e, 0x5d, 0xdd, 0x6e, 0x1d}, + {0xa2, 0xb3, 0xb8, 0x1, 0xc8, 0x6d, 0x83, 0xf1, 0x9a, 0xa4, 0x3e, + 0x5, 0x47, 0x5f, 0x3, 0xb3, 0xf3, 0xad, 0x77, 0x58, 0xba, 0x41, + 0x9c, 0x52, 0xa7, 0x90, 0xf, 0x6a, 0x1c, 0xbb, 0x9f, 0x7a}, + }, + { + {0x8f, 0x3e, 0xdd, 0x4, 0x66, 0x59, 0xb7, 0x59, 0x2c, 0x70, 0x88, + 0xe2, 0x77, 0x3, 0xb3, 0x6c, 0x23, 0xc3, 0xd9, 0x5e, 0x66, 0x9c, + 0x33, 0xb1, 0x2f, 0xe5, 0xbc, 0x61, 0x60, 0xe7, 0x15, 0x9}, + {0xd9, 0x34, 0x92, 0xf3, 0xed, 0x5d, 0xa7, 0xe2, 0xf9, 0x58, 0xb5, + 0xe1, 0x80, 0x76, 0x3d, 0x96, 0xfb, 0x23, 0x3c, 0x6e, 0xac, 0x41, + 0x27, 0x2c, 0xc3, 0x1, 0xe, 0x32, 0xa1, 0x24, 0x90, 0x3a}, + {0x1a, 0x91, 0xa2, 0xc9, 0xd9, 0xf5, 0xc1, 0xe7, 0xd7, 0xa7, 0xcc, + 0x8b, 0x78, 0x71, 0xa3, 0xb8, 0x32, 0x2a, 0xb6, 0xe, 0x19, 0x12, + 0x64, 0x63, 0x95, 0x4e, 0xcc, 0x2e, 0x5c, 0x7c, 0x90, 0x26}, + }, + }, + { + { + {0x1d, 0x9c, 0x2f, 0x63, 0xe, 0xdd, 0xcc, 0x2e, 0x15, 0x31, 0x89, + 0x76, 0x96, 0xb6, 0xd0, 0x51, 0x58, 0x7a, 0x63, 0xa8, 0x6b, 0xb7, + 0xdf, 0x52, 0x39, 0xef, 0xe, 0xa0, 0x49, 0x7d, 0xd3, 0x6d}, + {0x5e, 0x51, 0xaa, 0x49, 0x54, 0x63, 0x5b, 0xed, 0x3a, 0x82, 0xc6, + 0xb, 0x9f, 0xc4, 0x65, 0xa8, 0xc4, 0xd1, 0x42, 0x5b, 0xe9, 0x1f, + 0xc, 0x85, 0xb9, 0x15, 0xd3, 0x3, 0x6f, 0x6d, 0xd7, 0x30}, + {0xc7, 0xe4, 0x6, 0x21, 0x17, 0x44, 0x44, 0x6c, 0x69, 0x7f, 0x8d, + 0x92, 0x80, 0xd6, 0x53, 0xfb, 0x26, 0x3f, 0x4d, 0x69, 0xa4, 0x9e, + 0x73, 0xb4, 0xb0, 0x4b, 0x86, 0x2e, 0x11, 0x97, 0xc6, 0x10}, + }, + { + {0x5, 0xc8, 0x58, 0x83, 0xa0, 0x2a, 0xa6, 0xc, 0x47, 0x42, 0x20, + 0x7a, 0xe3, 0x4a, 0x3d, 0x6a, 0xdc, 0xed, 0x11, 0x3b, 0xa6, 0xd3, + 0x64, 0x74, 0xef, 0x6, 0x8, 0x55, 0xaf, 0x9b, 0xbf, 0x3}, + {0xde, 0x5f, 0xbe, 0x7d, 0x27, 0xc4, 0x93, 0x64, 0xa2, 0x7e, 0xad, + 0x19, 0xad, 0x4f, 0x5d, 0x26, 0x90, 0x45, 0x30, 0x46, 0xc8, 0xdf, + 0x0, 0xe, 0x9, 0xfe, 0x66, 0xed, 0xab, 0x1c, 0xe6, 0x25}, + {0x4, 0x66, 0x58, 0xcc, 0x28, 0xe1, 0x13, 0x3f, 0x7e, 0x74, 0x59, + 0xb4, 0xec, 0x73, 0x58, 0x6f, 0xf5, 0x68, 0x12, 0xcc, 0xed, 0x3d, + 0xb6, 0xa0, 0x2c, 0xe2, 0x86, 0x45, 0x63, 0x78, 0x6d, 0x56}, + }, + { + {0xd0, 0x2f, 0x5a, 0xc6, 0x85, 0x42, 0x5, 0xa1, 0xc3, 0x67, 0x16, + 0xf3, 0x2a, 0x11, 0x64, 0x6c, 0x58, 0xee, 0x1a, 0x73, 0x40, 0xe2, + 0xa, 0x68, 0x2a, 0xb2, 0x93, 0x47, 0xf3, 0xa5, 0xfb, 0x14}, + {0x34, 0x8, 0xc1, 0x9c, 0x9f, 0xa4, 0x37, 0x16, 0x51, 0xc4, 0x9b, + 0xa8, 0xd5, 0x56, 0x8e, 0xbc, 0xdb, 0xd2, 0x7f, 0x7f, 0xf, 0xec, + 0xb5, 0x1c, 0xd9, 0x35, 0xcc, 0x5e, 0xca, 0x5b, 0x97, 0x33}, + {0xd4, 0xf7, 0x85, 0x69, 0x16, 0x46, 0xd7, 0x3c, 0x57, 0x0, 0xc8, + 0xc9, 0x84, 0x5e, 0x3e, 0x59, 0x1e, 0x13, 0x61, 0x7b, 0xb6, 0xf2, + 0xc3, 0x2f, 0x6c, 0x52, 0xfc, 0x83, 0xea, 0x9c, 0x82, 0x14}, + }, + { + {0xb8, 0xec, 0x71, 0x4e, 0x2f, 0xb, 0xe7, 0x21, 0xe3, 0x77, 0xa4, + 0x40, 0xb9, 0xdd, 0x56, 0xe6, 0x80, 0x4f, 0x1d, 0xce, 0xce, 0x56, + 0x65, 0xbf, 0x7e, 0x7b, 0x5d, 0x53, 0xc4, 0x3b, 0xfc, 0x5}, + {0xc2, 0x95, 0xdd, 0x97, 0x84, 0x7b, 0x43, 0xff, 0xa7, 0xb5, 0x4e, + 0xaa, 0x30, 0x4e, 0x74, 0x6c, 0x8b, 0xe8, 0x85, 0x3c, 0x61, 0x5d, + 0xc, 0x9e, 0x73, 0x81, 0x75, 0x5f, 0x1e, 0xc7, 0xd9, 0x2f}, + {0xdd, 0xde, 0xaf, 0x52, 0xae, 0xb3, 0xb8, 0x24, 0xcf, 0x30, 0x3b, + 0xed, 0x8c, 0x63, 0x95, 0x34, 0x95, 0x81, 0xbe, 0xa9, 0x83, 0xbc, + 0xa4, 0x33, 0x4, 0x1f, 0x65, 0x5c, 0x47, 0x67, 0x37, 0x37}, + }, + { + {0x90, 0x65, 0x24, 0x14, 0xcb, 0x95, 0x40, 0x63, 0x35, 0x55, 0xc1, + 0x16, 0x40, 0x14, 0x12, 0xef, 0x60, 0xbc, 0x10, 0x89, 0xc, 0x14, + 0x38, 0x9e, 0x8c, 0x7c, 0x90, 0x30, 0x57, 0x90, 0xf5, 0x6b}, + {0xd9, 0xad, 0xd1, 0x40, 0xfd, 0x99, 0xba, 0x2f, 0x27, 0xd0, 0xf4, + 0x96, 0x6f, 0x16, 0x7, 0xb3, 0xae, 0x3b, 0xf0, 0x15, 0x52, 0xf0, + 0x63, 0x43, 0x99, 0xf9, 0x18, 0x3b, 0x6c, 0xa5, 0xbe, 0x1f}, + {0x8a, 0x5b, 0x41, 0xe1, 0xf1, 0x78, 0xa7, 0xf, 0x7e, 0xa7, 0xc3, + 0xba, 0xf7, 0x9f, 0x40, 0x6, 0x50, 0x9a, 0xa2, 0x9a, 0xb8, 0xd7, + 0x52, 0x6f, 0x56, 0x5a, 0x63, 0x7a, 0xf6, 0x1c, 0x52, 0x2}, + }, + { + {0xe4, 0x5e, 0x2f, 0x77, 0x20, 0x67, 0x14, 0xb1, 0xce, 0x9a, 0x7, + 0x96, 0xb1, 0x94, 0xf8, 0xe8, 0x4a, 0x82, 0xac, 0x0, 0x4d, 0x22, + 0xf8, 0x4a, 0xc4, 0x6c, 0xcd, 0xf7, 0xd9, 0x53, 0x17, 0x0}, + {0x94, 0x52, 0x9d, 0xa, 0xb, 0xee, 0x3f, 0x51, 0x66, 0x5a, 0xdf, + 0xf, 0x5c, 0xe7, 0x98, 0x8f, 0xce, 0x7, 0xe1, 0xbf, 0x88, 0x86, + 0x61, 0xd4, 0xed, 0x2c, 0x38, 0x71, 0x7e, 0xa, 0xa0, 0x3f}, + {0x34, 0xdb, 0x3d, 0x96, 0x2d, 0x23, 0x69, 0x3c, 0x58, 0x38, 0x97, + 0xb4, 0xda, 0x87, 0xde, 0x1d, 0x85, 0xf2, 0x91, 0xa0, 0xf9, 0xd1, + 0xd7, 0xaa, 0xb6, 0xed, 0x48, 0xa0, 0x2f, 0xfe, 0xb5, 0x12}, + }, + { + {0x92, 0x1e, 0x6f, 0xad, 0x26, 0x7c, 0x2b, 0xdf, 0x13, 0x89, 0x4b, + 0x50, 0x23, 0xd3, 0x66, 0x4b, 0xc3, 0x8b, 0x1c, 0x75, 0xc0, 0x9d, + 0x40, 0x8c, 0xb8, 0xc7, 0x96, 0x7, 0xc2, 0x93, 0x7e, 0x6f}, + {0x4d, 0xe3, 0xfc, 0x96, 0xc4, 0xfb, 0xf0, 0x71, 0xed, 0x5b, 0xf3, + 0xad, 0x6b, 0x82, 0xb9, 0x73, 0x61, 0xc5, 0x28, 0xff, 0x61, 0x72, + 0x4, 0xd2, 0x6f, 0x20, 0xb1, 0x6f, 0xf9, 0x76, 0x9b, 0x74}, + {0x5, 0xae, 0xa6, 0xae, 0x4, 0xf6, 0x5a, 0x1f, 0x99, 0x9c, 0xe4, + 0xbe, 0xf1, 0x51, 0x23, 0xc1, 0x66, 0x6b, 0xff, 0xee, 0xb5, 0x8, + 0xa8, 0x61, 0x51, 0x21, 0xe0, 0x1, 0xf, 0xc1, 0xce, 0xf}, + }, + { + {0x45, 0x4e, 0x24, 0xc4, 0x9d, 0xd2, 0xf2, 0x3d, 0xa, 0xde, 0xd8, + 0x93, 0x74, 0xe, 0x2, 0x2b, 0x4d, 0x21, 0xc, 0x82, 0x7e, 0x6, + 0xc8, 0x6c, 0xa, 0xb9, 0xea, 0x6f, 0x16, 0x79, 0x37, 0x41}, + {0x44, 0x1e, 0xfe, 0x49, 0xa6, 0x58, 0x4d, 0x64, 0x7e, 0x77, 0xad, + 0x31, 0xa2, 0xae, 0xfc, 0x21, 0xd2, 0xd0, 0x7f, 0x88, 0x5a, 0x1c, + 0x44, 0x2, 0xf3, 0x11, 0xc5, 0x83, 0x71, 0xaa, 0x1, 0x49}, + {0xf0, 0xf8, 0x1a, 0x8c, 0x54, 0xb7, 0xb1, 0x8, 0xb4, 0x99, 0x62, + 0x24, 0x7c, 0x7a, 0xf, 0xce, 0x39, 0xd9, 0x6, 0x1e, 0xf9, 0xb0, + 0x60, 0xf7, 0x13, 0x12, 0x6d, 0x72, 0x7b, 0x88, 0xbb, 0x41}, + }, + }, + { + { + {0xae, 0x91, 0x66, 0x7c, 0x59, 0x4c, 0x23, 0x7e, 0xc8, 0xb4, 0x85, + 0xa, 0x3d, 0x9d, 0x88, 0x64, 0xe7, 0xfa, 0x4a, 0x35, 0xc, 0xc9, + 0xe2, 0xda, 0x1d, 0x9e, 0x6a, 0xc, 0x7, 0x1e, 0x87, 0xa}, + {0xbe, 0x46, 0x43, 0x74, 0x44, 0x7d, 0xe8, 0x40, 0x25, 0x2b, 0xb5, + 0x15, 0xd4, 0xda, 0x48, 0x1d, 0x3e, 0x60, 0x3b, 0xa1, 0x18, 0x8a, + 0x3a, 0x7c, 0xf7, 0xbd, 0xcd, 0x2f, 0xc1, 0x28, 0xb7, 0x4e}, + {0x89, 0x89, 0xbc, 0x4b, 0x99, 0xb5, 0x1, 0x33, 0x60, 0x42, 0xdd, + 0x5b, 0x3a, 0xae, 0x6b, 0x73, 0x3c, 0x9e, 0xd5, 0x19, 0xe2, 0xad, + 0x61, 0xd, 0x64, 0xd4, 0x85, 0x26, 0xf, 0x30, 0xe7, 0x3e}, + }, + { + {0x18, 0x75, 0x1e, 0x84, 0x47, 0x79, 0xfa, 0x43, 0xd7, 0x46, 0x9c, + 0x63, 0x59, 0xfa, 0xc6, 0xe5, 0x74, 0x2b, 0x5, 0xe3, 0x1d, 0x5e, + 0x6, 0xa1, 0x30, 0x90, 0xb8, 0xcf, 0xa2, 0xc6, 0x47, 0x7d}, + {0xb7, 0xd6, 0x7d, 0x9e, 0xe4, 0x55, 0xd2, 0xf5, 0xac, 0x1e, 0xb, + 0x61, 0x5c, 0x11, 0x16, 0x80, 0xca, 0x87, 0xe1, 0x92, 0x5d, 0x97, + 0x99, 0x3c, 0xc2, 0x25, 0x91, 0x97, 0x62, 0x57, 0x81, 0x13}, + {0xe0, 0xd6, 0xf0, 0x8e, 0x14, 0xd0, 0xda, 0x3f, 0x3c, 0x6f, 0x54, + 0x91, 0x9a, 0x74, 0x3e, 0x9d, 0x57, 0x81, 0xbb, 0x26, 0x10, 0x62, + 0xec, 0x71, 0x80, 0xec, 0xc9, 0x34, 0x8d, 0xf5, 0x8c, 0x14}, + }, + { + {0x6d, 0x75, 0xe4, 0x9a, 0x7d, 0x2f, 0x57, 0xe2, 0x7f, 0x48, 0xf3, + 0x88, 0xbb, 0x45, 0xc3, 0x56, 0x8d, 0xa8, 0x60, 0x69, 0x6d, 0xb, + 0xd1, 0x9f, 0xb9, 0xa1, 0xae, 0x4e, 0xad, 0xeb, 0x8f, 0x27}, + {0x27, 0xf0, 0x34, 0x79, 0xf6, 0x92, 0xa4, 0x46, 0xa9, 0xa, 0x84, + 0xf6, 0xbe, 0x84, 0x99, 0x46, 0x54, 0x18, 0x61, 0x89, 0x2a, 0xbc, + 0xa1, 0x5c, 0xd4, 0xbb, 0x5d, 0xbd, 0x1e, 0xfa, 0xf2, 0x3f}, + {0x66, 0x39, 0x93, 0x8c, 0x1f, 0x68, 0xaa, 0xb1, 0x98, 0xc, 0x29, + 0x20, 0x9c, 0x94, 0x21, 0x8c, 0x52, 0x3c, 0x9d, 0x21, 0x91, 0x52, + 0x11, 0x39, 0x7b, 0x67, 0x9c, 0xfe, 0x2, 0xdd, 0x4, 0x41}, + }, + { + {0xb8, 0x6a, 0x9, 0xdb, 0x6, 0x4e, 0x21, 0x81, 0x35, 0x4f, 0xe4, + 0xc, 0xc9, 0xb6, 0xa8, 0x21, 0xf5, 0x2a, 0x9e, 0x40, 0x2a, 0xc1, + 0x24, 0x65, 0x81, 0xa4, 0xfc, 0x8e, 0xa4, 0xb5, 0x65, 0x1}, + {0x2a, 0x42, 0x24, 0x11, 0x5e, 0xbf, 0xb2, 0x72, 0xb5, 0x3a, 0xa3, + 0x98, 0x33, 0xc, 0xfa, 0xa1, 0x66, 0xb6, 0x52, 0xfa, 0x1, 0x61, + 0xcb, 0x94, 0xd5, 0x53, 0xaf, 0xaf, 0x0, 0x3b, 0x86, 0x2c}, + {0x76, 0x6a, 0x84, 0xa0, 0x74, 0xa4, 0x90, 0xf1, 0xc0, 0x7c, 0x2f, + 0xcd, 0x84, 0xf9, 0xef, 0x12, 0x8f, 0x2b, 0xaa, 0x58, 0x6, 0x29, + 0x5e, 0x69, 0xb8, 0xc8, 0xfe, 0xbf, 0xd9, 0x67, 0x1b, 0x59}, + }, + { + {0x5d, 0xb5, 0x18, 0x9f, 0x71, 0xb3, 0xb9, 0x99, 0x1e, 0x64, 0x8c, + 0xa1, 0xfa, 0xe5, 0x65, 0xe4, 0xed, 0x5, 0x9f, 0xc2, 0x36, 0x11, + 0x8, 0x61, 0x8b, 0x12, 0x30, 0x70, 0x86, 0x4f, 0x9b, 0x48}, + {0xfa, 0x9b, 0xb4, 0x80, 0x1c, 0xd, 0x2f, 0x31, 0x8a, 0xec, 0xf3, + 0xab, 0x5e, 0x51, 0x79, 0x59, 0x88, 0x1c, 0xf0, 0x9e, 0xc0, 0x33, + 0x70, 0x72, 0xcb, 0x7b, 0x8f, 0xca, 0xc7, 0x2e, 0xe0, 0x3d}, + {0xef, 0x92, 0xeb, 0x3a, 0x2d, 0x10, 0x32, 0xd2, 0x61, 0xa8, 0x16, + 0x61, 0xb4, 0x53, 0x62, 0xe1, 0x24, 0xaa, 0xb, 0x19, 0xe7, 0xab, + 0x7e, 0x3d, 0xbf, 0xbe, 0x6c, 0x49, 0xba, 0xfb, 0xf5, 0x49}, + }, + { + {0x2e, 0x57, 0x9c, 0x1e, 0x8c, 0x62, 0x5d, 0x15, 0x41, 0x47, 0x88, + 0xc5, 0xac, 0x86, 0x4d, 0x8a, 0xeb, 0x63, 0x57, 0x51, 0xf6, 0x52, + 0xa3, 0x91, 0x5b, 0x51, 0x67, 0x88, 0xc2, 0xa6, 0xa1, 0x6}, + {0xd4, 0xcf, 0x5b, 0x8a, 0x10, 0x9a, 0x94, 0x30, 0xeb, 0x73, 0x64, + 0xbc, 0x70, 0xdd, 0x40, 0xdc, 0x1c, 0xd, 0x7c, 0x30, 0xc1, 0x94, + 0xc2, 0x92, 0x74, 0x6e, 0xfa, 0xcb, 0x6d, 0xa8, 0x4, 0x56}, + {0xb6, 0x64, 0x17, 0x7c, 0xd4, 0xd1, 0x88, 0x72, 0x51, 0x8b, 0x41, + 0xe0, 0x40, 0x11, 0x54, 0x72, 0xd1, 0xf6, 0xac, 0x18, 0x60, 0x1a, + 0x3, 0x9f, 0xc6, 0x42, 0x27, 0xfe, 0x89, 0x9e, 0x98, 0x20}, + }, + { + {0x2e, 0xec, 0xea, 0x85, 0x8b, 0x27, 0x74, 0x16, 0xdf, 0x2b, 0xcb, + 0x7a, 0x7, 0xdc, 0x21, 0x56, 0x5a, 0xf4, 0xcb, 0x61, 0x16, 0x4c, + 0xa, 0x64, 0xd3, 0x95, 0x5, 0xf7, 0x50, 0x99, 0xb, 0x73}, + {0x7f, 0xcc, 0x2d, 0x3a, 0xfd, 0x77, 0x97, 0x49, 0x92, 0xd8, 0x4f, + 0xa5, 0x2c, 0x7c, 0x85, 0x32, 0xa0, 0xe3, 0x7, 0xd2, 0x64, 0xd8, + 0x79, 0xa2, 0x29, 0x7e, 0xa6, 0xc, 0x1d, 0xed, 0x3, 0x4}, + {0x52, 0xc5, 0x4e, 0x87, 0x35, 0x2d, 0x4b, 0xc9, 0x8d, 0x6f, 0x24, + 0x98, 0xcf, 0xc8, 0xe6, 0xc5, 0xce, 0x35, 0xc0, 0x16, 0xfa, 0x46, + 0xcb, 0xf7, 0xcc, 0x3d, 0x30, 0x8, 0x43, 0x45, 0xd7, 0x5b}, + }, + { + {0x2a, 0x79, 0xe7, 0x15, 0x21, 0x93, 0xc4, 0x85, 0xc9, 0xdd, 0xcd, + 0xbd, 0xa2, 0x89, 0x4c, 0xc6, 0x62, 0xd7, 0xa3, 0xad, 0xa8, 0x3d, + 0x1e, 0x9d, 0x2c, 0xf8, 0x67, 0x30, 0x12, 0xdb, 0xb7, 0x5b}, + {0xc2, 0x4c, 0xb2, 0x28, 0x95, 0xd1, 0x9a, 0x7f, 0x81, 0xc1, 0x35, + 0x63, 0x65, 0x54, 0x6b, 0x7f, 0x36, 0x72, 0xc0, 0x4f, 0x6e, 0xb6, + 0xb8, 0x66, 0x83, 0xad, 0x80, 0x73, 0x0, 0x78, 0x3a, 0x13}, + {0xbe, 0x62, 0xca, 0xc6, 0x67, 0xf4, 0x61, 0x9, 0xee, 0x52, 0x19, + 0x21, 0xd6, 0x21, 0xec, 0x4, 0x70, 0x47, 0xd5, 0x9b, 0x77, 0x60, + 0x23, 0x18, 0xd2, 0xe0, 0xf0, 0x58, 0x6d, 0xca, 0xd, 0x74}, + }, + }, + { + { + {0x3c, 0x43, 0x78, 0x4, 0x57, 0x8c, 0x1a, 0x23, 0x9d, 0x43, 0x81, + 0xc2, 0xe, 0x27, 0xb5, 0xb7, 0x9f, 0x7, 0xd9, 0xe3, 0xea, 0x99, + 0xaa, 0xdb, 0xd9, 0x3, 0x2b, 0x6c, 0x25, 0xf5, 0x3, 0x2c}, + {0x4e, 0xce, 0xcf, 0x52, 0x7, 0xee, 0x48, 0xdf, 0xb7, 0x8, 0xec, + 0x6, 0xf3, 0xfa, 0xff, 0xc3, 0xc4, 0x59, 0x54, 0xb9, 0x2a, 0xb, + 0x71, 0x5, 0x8d, 0xa3, 0x3e, 0x96, 0xfa, 0x25, 0x1d, 0x16}, + {0x7d, 0xa4, 0x53, 0x7b, 0x75, 0x18, 0xf, 0x79, 0x79, 0x58, 0xc, + 0xcf, 0x30, 0x1, 0x7b, 0x30, 0xf9, 0xf7, 0x7e, 0x25, 0x77, 0x3d, + 0x90, 0x31, 0xaf, 0xbb, 0x96, 0xbd, 0xbd, 0x68, 0x94, 0x69}, + }, + { + {0x48, 0x19, 0xa9, 0x6a, 0xe6, 0x3d, 0xdd, 0xd8, 0xcc, 0xd2, 0xc0, + 0x2f, 0xc2, 0x64, 0x50, 0x48, 0x2f, 0xea, 0xfd, 0x34, 0x66, 0x24, + 0x48, 0x9b, 0x3a, 0x2e, 0x4a, 0x6c, 0x4e, 0x1c, 0x3e, 0x29}, + {0xcf, 0xfe, 0xda, 0xf4, 0x46, 0x2f, 0x1f, 0xbd, 0xf7, 0xd6, 0x7f, + 0xa4, 0x14, 0x1, 0xef, 0x7c, 0x7f, 0xb3, 0x47, 0x4a, 0xda, 0xfd, + 0x1f, 0xd3, 0x85, 0x57, 0x90, 0x73, 0xa4, 0x19, 0x52, 0x52}, + {0xe1, 0x12, 0x51, 0x92, 0x4b, 0x13, 0x6e, 0x37, 0xa0, 0x5d, 0xa1, + 0xdc, 0xb5, 0x78, 0x37, 0x70, 0x11, 0x31, 0x1c, 0x46, 0xaf, 0x89, + 0x45, 0xb0, 0x23, 0x28, 0x3, 0x7f, 0x44, 0x5c, 0x60, 0x5b}, + }, + { + {0x4c, 0xf0, 0xe7, 0xf0, 0xc6, 0xfe, 0xe9, 0x3b, 0x62, 0x49, 0xe3, + 0x75, 0x9e, 0x57, 0x6a, 0x86, 0x1a, 0xe6, 0x1d, 0x1e, 0x16, 0xef, + 0x42, 0x55, 0xd5, 0xbd, 0x5a, 0xcc, 0xf4, 0xfe, 0x12, 0x2f}, + {0x89, 0x7c, 0xc4, 0x20, 0x59, 0x80, 0x65, 0xb9, 0xcc, 0x8f, 0x3b, + 0x92, 0xc, 0x10, 0xf0, 0xe7, 0x77, 0xef, 0xe2, 0x2, 0x65, 0x25, + 0x1, 0x0, 0xee, 0xb3, 0xae, 0xa8, 0xce, 0x6d, 0xa7, 0x24}, + {0x40, 0xc7, 0xc0, 0xdf, 0xb2, 0x22, 0x45, 0xa, 0x7, 0xa4, 0xc9, + 0x40, 0x7f, 0x6e, 0xd0, 0x10, 0x68, 0xf6, 0xcf, 0x78, 0x41, 0x14, + 0xcf, 0xc6, 0x90, 0x37, 0xa4, 0x18, 0x25, 0x7b, 0x60, 0x5e}, + }, + { + {0x14, 0xcf, 0x96, 0xa5, 0x1c, 0x43, 0x2c, 0xa0, 0x0, 0xe4, 0xd3, + 0xae, 0x40, 0x2d, 0xc4, 0xe3, 0xdb, 0x26, 0xf, 0x2e, 0x80, 0x26, + 0x45, 0xd2, 0x68, 0x70, 0x45, 0x9e, 0x13, 0x33, 0x1f, 0x20}, + {0x18, 0x18, 0xdf, 0x6c, 0x8f, 0x1d, 0xb3, 0x58, 0xa2, 0x58, 0x62, + 0xc3, 0x4f, 0xa7, 0xcf, 0x35, 0x6e, 0x1d, 0xe6, 0x66, 0x4f, 0xff, + 0xb3, 0xe1, 0xf7, 0xd5, 0xcd, 0x6c, 0xab, 0xac, 0x67, 0x50}, + {0x51, 0x9d, 0x3, 0x8, 0x6b, 0x7f, 0x52, 0xfd, 0x6, 0x0, 0x7c, + 0x1, 0x64, 0x49, 0xb1, 0x18, 0xa8, 0xa4, 0x25, 0x2e, 0xb0, 0xe, + 0x22, 0xd5, 0x75, 0x3, 0x46, 0x62, 0x88, 0xba, 0x7c, 0x39}, + }, + { + {0xe7, 0x79, 0x13, 0xc8, 0xfb, 0xc3, 0x15, 0x78, 0xf1, 0x2a, 0xe1, + 0xdd, 0x20, 0x94, 0x61, 0xa6, 0xd5, 0xfd, 0xa8, 0x85, 0xf8, 0xc0, + 0xa9, 0xff, 0x52, 0xc2, 0xe1, 0xc1, 0x22, 0x40, 0x1b, 0x77}, + {0xb2, 0x59, 0x59, 0xf0, 0x93, 0x30, 0xc1, 0x30, 0x76, 0x79, 0xa9, + 0xe9, 0x8d, 0xa1, 0x3a, 0xe2, 0x26, 0x5e, 0x1d, 0x72, 0x91, 0xd4, + 0x2f, 0x22, 0x3a, 0x6c, 0x6e, 0x76, 0x20, 0xd3, 0x39, 0x23}, + {0xa7, 0x2f, 0x3a, 0x51, 0x86, 0xd9, 0x7d, 0xd8, 0x8, 0xcf, 0xd4, + 0xf9, 0x71, 0x9b, 0xac, 0xf5, 0xb3, 0x83, 0xa2, 0x1e, 0x1b, 0xc3, + 0x6b, 0xd0, 0x76, 0x1a, 0x97, 0x19, 0x92, 0x18, 0x1a, 0x33}, + }, + { + {0xaf, 0x72, 0x75, 0x9d, 0x3a, 0x2f, 0x51, 0x26, 0x9e, 0x4a, 0x7, + 0x68, 0x88, 0xe2, 0xcb, 0x5b, 0xc4, 0xf7, 0x80, 0x11, 0xc1, 0xc1, + 0xed, 0x84, 0x7b, 0xa6, 0x49, 0xf6, 0x9f, 0x61, 0xc9, 0x1a}, + {0xc6, 0x80, 0x4f, 0xfb, 0x45, 0x6f, 0x16, 0xf5, 0xcf, 0x75, 0xc7, + 0x61, 0xde, 0xc7, 0x36, 0x9c, 0x1c, 0xd9, 0x41, 0x90, 0x1b, 0xe8, + 0xd4, 0xe3, 0x21, 0xfe, 0xbd, 0x83, 0x6b, 0x7c, 0x16, 0x31}, + {0x68, 0x10, 0x4b, 0x52, 0x42, 0x38, 0x2b, 0xf2, 0x87, 0xe9, 0x9c, + 0xee, 0x3b, 0x34, 0x68, 0x50, 0xc8, 0x50, 0x62, 0x4a, 0x84, 0x71, + 0x9d, 0xfc, 0x11, 0xb1, 0x8, 0x1f, 0x34, 0x36, 0x24, 0x61}, + }, + { + {0x38, 0x26, 0x2d, 0x1a, 0xe3, 0x49, 0x63, 0x8b, 0x35, 0xfd, 0xd3, + 0x9b, 0x0, 0xb7, 0xdf, 0x9d, 0xa4, 0x6b, 0xa0, 0xa3, 0xb8, 0xf1, + 0x8b, 0x7f, 0x45, 0x4, 0xd9, 0x78, 0x31, 0xaa, 0x22, 0x15}, + {0x8d, 0x89, 0x4e, 0x87, 0xdb, 0x41, 0x9d, 0xd9, 0x20, 0xdc, 0x7, + 0x6c, 0xf1, 0xa5, 0xfe, 0x9, 0xbc, 0x9b, 0xf, 0xd0, 0x67, 0x2c, + 0x3d, 0x79, 0x40, 0xff, 0x5e, 0x9e, 0x30, 0xe2, 0xeb, 0x46}, + {0x38, 0x49, 0x61, 0x69, 0x53, 0x2f, 0x38, 0x2c, 0x10, 0x6d, 0x2d, + 0xb7, 0x9a, 0x40, 0xfe, 0xda, 0x27, 0xf2, 0x46, 0xb6, 0x91, 0x33, + 0xc8, 0xe8, 0x6c, 0x30, 0x24, 0x5, 0xf5, 0x70, 0xfe, 0x45}, + }, + { + {0x91, 0x14, 0x95, 0xc8, 0x20, 0x49, 0xf2, 0x62, 0xa2, 0xc, 0x63, + 0x3f, 0xc8, 0x7, 0xf0, 0x5, 0xb8, 0xd4, 0xc9, 0xf5, 0xd2, 0x45, + 0xbb, 0x6f, 0x45, 0x22, 0x7a, 0xb5, 0x6d, 0x9f, 0x61, 0x16}, + {0x8c, 0xb, 0xc, 0x96, 0xa6, 0x75, 0x48, 0xda, 0x20, 0x2f, 0xe, + 0xef, 0x76, 0xd0, 0x68, 0x5b, 0xd4, 0x8f, 0xb, 0x3d, 0xcf, 0x51, + 0xfb, 0x7, 0xd4, 0x92, 0xe3, 0xa0, 0x23, 0x16, 0x8d, 0x42}, + {0xfd, 0x8, 0xa3, 0x1, 0x44, 0x4a, 0x4f, 0x8, 0xac, 0xca, 0xa5, + 0x76, 0xc3, 0x19, 0x22, 0xa8, 0x7d, 0xbc, 0xd1, 0x43, 0x46, 0xde, + 0xb8, 0xde, 0xc6, 0x38, 0xbd, 0x60, 0x2d, 0x59, 0x81, 0x1d}, + }, + }, + { + { + {0xe8, 0xc5, 0x85, 0x7b, 0x9f, 0xb6, 0x65, 0x87, 0xb2, 0xba, 0x68, + 0xd1, 0x8b, 0x67, 0xf0, 0x6f, 0x9b, 0xf, 0x33, 0x1d, 0x7c, 0xe7, + 0x70, 0x3a, 0x7c, 0x8e, 0xaf, 0xb0, 0x51, 0x6d, 0x5f, 0x3a}, + {0x5f, 0xac, 0xd, 0xa6, 0x56, 0x87, 0x36, 0x61, 0x57, 0xdc, 0xab, + 0xeb, 0x6a, 0x2f, 0xe0, 0x17, 0x7d, 0xf, 0xce, 0x4c, 0x2d, 0x3f, + 0x19, 0x7f, 0xf0, 0xdc, 0xec, 0x89, 0x77, 0x4a, 0x23, 0x20}, + {0x52, 0xb2, 0x78, 0x71, 0xb6, 0xd, 0xd2, 0x76, 0x60, 0xd1, 0x1e, + 0xd5, 0xf9, 0x34, 0x1c, 0x7, 0x70, 0x11, 0xe4, 0xb3, 0x20, 0x4a, + 0x2a, 0xf6, 0x66, 0xe3, 0xff, 0x3c, 0x35, 0x82, 0xd6, 0x7c}, + }, + { + {0xf3, 0xf4, 0xac, 0x68, 0x60, 0xcd, 0x65, 0xa6, 0xd3, 0xe3, 0xd7, + 0x3c, 0x18, 0x2d, 0xd9, 0x42, 0xd9, 0x25, 0x60, 0x33, 0x9d, 0x38, + 0x59, 0x57, 0xff, 0xd8, 0x2c, 0x2b, 0x3b, 0x25, 0xf0, 0x3e}, + {0xb6, 0xfa, 0x87, 0xd8, 0x5b, 0xa4, 0xe1, 0xb, 0x6e, 0x3b, 0x40, + 0xba, 0x32, 0x6a, 0x84, 0x2a, 0x0, 0x60, 0x6e, 0xe9, 0x12, 0x10, + 0x92, 0xd9, 0x43, 0x9, 0xdc, 0x3b, 0x86, 0xc8, 0x38, 0x28}, + {0x30, 0x50, 0x46, 0x4a, 0xcf, 0xb0, 0x6b, 0xd1, 0xab, 0x77, 0xc5, + 0x15, 0x41, 0x6b, 0x49, 0xfa, 0x9d, 0x41, 0xab, 0xf4, 0x8a, 0xae, + 0xcf, 0x82, 0x12, 0x28, 0xa8, 0x6, 0xa6, 0xb8, 0xdc, 0x21}, + }, + { + {0xba, 0x31, 0x77, 0xbe, 0xfa, 0x0, 0x8d, 0x9a, 0x89, 0x18, 0x9e, + 0x62, 0x7e, 0x60, 0x3, 0x82, 0x7f, 0xd9, 0xf3, 0x43, 0x37, 0x2, + 0xcc, 0xb2, 0x8b, 0x67, 0x6f, 0x6c, 0xbf, 0xd, 0x84, 0x5d}, + {0xc8, 0x9f, 0x9d, 0x8c, 0x46, 0x4, 0x60, 0x5c, 0xcb, 0xa3, 0x2a, + 0xd4, 0x6e, 0x9, 0x40, 0x25, 0x9c, 0x2f, 0xee, 0x12, 0x4c, 0x4d, + 0x5b, 0x12, 0xab, 0x1d, 0xa3, 0x94, 0x81, 0xd0, 0xc3, 0xb}, + {0x8b, 0xe1, 0x9f, 0x30, 0xd, 0x38, 0x6e, 0x70, 0xc7, 0x65, 0xe1, + 0xb9, 0xa6, 0x2d, 0xb0, 0x6e, 0xab, 0x20, 0xae, 0x7d, 0x99, 0xba, + 0xbb, 0x57, 0xdd, 0x96, 0xc1, 0x2a, 0x23, 0x76, 0x42, 0x3a}, + }, + { + {0xcb, 0x7e, 0x44, 0xdb, 0x72, 0xc1, 0xf8, 0x3b, 0xbd, 0x2d, 0x28, + 0xc6, 0x1f, 0xc4, 0xcf, 0x5f, 0xfe, 0x15, 0xaa, 0x75, 0xc0, 0xff, + 0xac, 0x80, 0xf9, 0xa9, 0xe1, 0x24, 0xe8, 0xc9, 0x70, 0x7}, + {0xfa, 0x84, 0x70, 0x8a, 0x2c, 0x43, 0x42, 0x4b, 0x45, 0xe5, 0xb9, + 0xdf, 0xe3, 0x19, 0x8a, 0x89, 0x5d, 0xe4, 0x58, 0x9c, 0x21, 0x0, + 0x9f, 0xbe, 0xd1, 0xeb, 0x6d, 0xa1, 0xce, 0x77, 0xf1, 0x1f}, + {0xfd, 0xb5, 0xb5, 0x45, 0x9a, 0xd9, 0x61, 0xcf, 0x24, 0x79, 0x3a, + 0x1b, 0xe9, 0x84, 0x9, 0x86, 0x89, 0x3e, 0x3e, 0x30, 0x19, 0x9, + 0x30, 0xe7, 0x1e, 0xb, 0x50, 0x41, 0xfd, 0x64, 0xf2, 0x39}, + }, + { + {0xe1, 0x7b, 0x9, 0xfe, 0xab, 0x4a, 0x9b, 0xd1, 0x29, 0x19, 0xe0, + 0xdf, 0xe1, 0xfc, 0x6d, 0xa4, 0xff, 0xf1, 0xa6, 0x2c, 0x94, 0x8, + 0xc9, 0xc3, 0x4e, 0xf1, 0x35, 0x2c, 0x27, 0x21, 0xc6, 0x65}, + {0x9c, 0xe2, 0xe7, 0xdb, 0x17, 0x34, 0xad, 0xa7, 0x9c, 0x13, 0x9c, + 0x2b, 0x6a, 0x37, 0x94, 0xbd, 0xa9, 0x7b, 0x59, 0x93, 0x8e, 0x1b, + 0xe9, 0xa0, 0x40, 0x98, 0x88, 0x68, 0x34, 0xd7, 0x12, 0x17}, + {0xdd, 0x93, 0x31, 0xce, 0xf8, 0x89, 0x2b, 0xe7, 0xbb, 0xc0, 0x25, + 0xa1, 0x56, 0x33, 0x10, 0x4d, 0x83, 0xfe, 0x1c, 0x2e, 0x3d, 0xa9, + 0x19, 0x4, 0x72, 0xe2, 0x9c, 0xb1, 0xa, 0x80, 0xf9, 0x22}, + }, + { + {0xac, 0xfd, 0x6e, 0x9a, 0xdd, 0x9f, 0x2, 0x42, 0x41, 0x49, 0xa5, + 0x34, 0xbe, 0xce, 0x12, 0xb9, 0x7b, 0xf3, 0xbd, 0x87, 0xb9, 0x64, + 0xf, 0x64, 0xb4, 0xca, 0x98, 0x85, 0xd3, 0xa4, 0x71, 0x41}, + {0xcb, 0xf8, 0x9e, 0x3e, 0x8a, 0x36, 0x5a, 0x60, 0x15, 0x47, 0x50, + 0xa5, 0x22, 0xc0, 0xe9, 0xe3, 0x8f, 0x24, 0x24, 0x5f, 0xb0, 0x48, + 0x3d, 0x55, 0xe5, 0x26, 0x76, 0x64, 0xcd, 0x16, 0xf4, 0x13}, + {0x8c, 0x4c, 0xc9, 0x99, 0xaa, 0x58, 0x27, 0xfa, 0x7, 0xb8, 0x0, + 0xb0, 0x6f, 0x6f, 0x0, 0x23, 0x92, 0x53, 0xda, 0xad, 0xdd, 0x91, + 0xd2, 0xfb, 0xab, 0xd1, 0x4b, 0x57, 0xfa, 0x14, 0x82, 0x50}, + }, + { + {0xd6, 0x3, 0xd0, 0x53, 0xbb, 0x15, 0x1a, 0x46, 0x65, 0xc9, 0xf3, + 0xbc, 0x88, 0x28, 0x10, 0xb2, 0x5a, 0x3a, 0x68, 0x6c, 0x75, 0x76, + 0xc5, 0x27, 0x47, 0xb4, 0x6c, 0xc8, 0xa4, 0x58, 0x77, 0x3a}, + {0x4b, 0xfe, 0xd6, 0x3e, 0x15, 0x69, 0x2, 0xc2, 0xc4, 0x77, 0x1d, + 0x51, 0x39, 0x67, 0x5a, 0xa6, 0x94, 0xaf, 0x14, 0x2c, 0x46, 0x26, + 0xde, 0xcb, 0x4b, 0xa7, 0xab, 0x6f, 0xec, 0x60, 0xf9, 0x22}, + {0x76, 0x50, 0xae, 0x93, 0xf6, 0x11, 0x81, 0x54, 0xa6, 0x54, 0xfd, + 0x1d, 0xdf, 0x21, 0xae, 0x1d, 0x65, 0x5e, 0x11, 0xf3, 0x90, 0x8c, + 0x24, 0x12, 0x94, 0xf4, 0xe7, 0x8d, 0x5f, 0xd1, 0x9f, 0x5d}, + }, + { + {0x1e, 0x52, 0xd7, 0xee, 0x2a, 0x4d, 0x24, 0x3f, 0x15, 0x96, 0x2e, + 0x43, 0x28, 0x90, 0x3a, 0x8e, 0xd4, 0x16, 0x9c, 0x2e, 0x77, 0xba, + 0x64, 0xe1, 0xd8, 0x98, 0xeb, 0x47, 0xfa, 0x87, 0xc1, 0x3b}, + {0x7f, 0x72, 0x63, 0x6d, 0xd3, 0x8, 0x14, 0x3, 0x33, 0xb5, 0xc7, + 0xd7, 0xef, 0x9a, 0x37, 0x6a, 0x4b, 0xe2, 0xae, 0xcc, 0xc5, 0x8f, + 0xe1, 0xa9, 0xd3, 0xbe, 0x8f, 0x4f, 0x91, 0x35, 0x2f, 0x33}, + {0xc, 0xc2, 0x86, 0xea, 0x15, 0x1, 0x47, 0x6d, 0x25, 0xd1, 0x46, + 0x6c, 0xcb, 0xb7, 0x8a, 0x99, 0x88, 0x1, 0x66, 0x3a, 0xb5, 0x32, + 0x78, 0xd7, 0x3, 0xba, 0x6f, 0x90, 0xce, 0x81, 0xd, 0x45}, + }, + }, + { + { + {0x3f, 0x74, 0xae, 0x1c, 0x96, 0xd8, 0x74, 0xd0, 0xed, 0x63, 0x1c, + 0xee, 0xf5, 0x18, 0x6d, 0xf8, 0x29, 0xed, 0xf4, 0xe7, 0x5b, 0xc5, + 0xbd, 0x97, 0x8, 0xb1, 0x3a, 0x66, 0x79, 0xd2, 0xba, 0x4c}, + {0x75, 0x52, 0x20, 0xa6, 0xa1, 0xb6, 0x7b, 0x6e, 0x83, 0x8e, 0x3c, + 0x41, 0xd7, 0x21, 0x4f, 0xaa, 0xb2, 0x5c, 0x8f, 0xe8, 0x55, 0xd1, + 0x56, 0x6f, 0xe1, 0x5b, 0x34, 0xa6, 0x4b, 0x5d, 0xe2, 0x2d}, + {0xcd, 0x1f, 0xd7, 0xa0, 0x24, 0x90, 0xd1, 0x80, 0xf8, 0x8a, 0x28, + 0xfb, 0xa, 0xc2, 0x25, 0xc5, 0x19, 0x64, 0x3a, 0x5f, 0x4b, 0x97, + 0xa3, 0xb1, 0x33, 0x72, 0x0, 0xe2, 0xef, 0xbc, 0x7f, 0x7d}, + }, + { + {0x94, 0x90, 0xc2, 0xf3, 0xc5, 0x5d, 0x7c, 0xcd, 0xab, 0x5, 0x91, + 0x2a, 0x9a, 0xa2, 0x81, 0xc7, 0x58, 0x30, 0x1c, 0x42, 0x36, 0x1d, + 0xc6, 0x80, 0xd7, 0xd4, 0xd8, 0xdc, 0x96, 0xd1, 0x9c, 0x4f}, + {0x1, 0x28, 0x6b, 0x26, 0x6a, 0x1e, 0xef, 0xfa, 0x16, 0x9f, 0x73, + 0xd5, 0xc4, 0x68, 0x6c, 0x86, 0x2c, 0x76, 0x3, 0x1b, 0xbc, 0x2f, + 0x8a, 0xf6, 0x8d, 0x5a, 0xb7, 0x87, 0x5e, 0x43, 0x75, 0x59}, + {0x68, 0x37, 0x7b, 0x6a, 0xd8, 0x97, 0x92, 0x19, 0x63, 0x7a, 0xd1, + 0x1a, 0x24, 0x58, 0xd0, 0xd0, 0x17, 0xc, 0x1c, 0x5c, 0xad, 0x9c, + 0x2, 0xba, 0x7, 0x3, 0x7a, 0x38, 0x84, 0xd0, 0xcd, 0x7c}, + }, + { + {0x93, 0xcc, 0x60, 0x67, 0x18, 0x84, 0xc, 0x9b, 0x99, 0x2a, 0xb3, + 0x1a, 0x7a, 0x0, 0xae, 0xcd, 0x18, 0xda, 0xb, 0x62, 0x86, 0xec, + 0x8d, 0xa8, 0x44, 0xca, 0x90, 0x81, 0x84, 0xca, 0x93, 0x35}, + {0x17, 0x4, 0x26, 0x6d, 0x2c, 0x42, 0xa6, 0xdc, 0xbd, 0x40, 0x82, + 0x94, 0x50, 0x3d, 0x15, 0xae, 0x77, 0xc6, 0x68, 0xfb, 0xb4, 0xc1, + 0xc0, 0xa9, 0x53, 0xcf, 0xd0, 0x61, 0xed, 0xd0, 0x8b, 0x42}, + {0xa7, 0x9a, 0x84, 0x5e, 0x9a, 0x18, 0x13, 0x92, 0xcd, 0xfa, 0xd8, + 0x65, 0x35, 0xc3, 0xd8, 0xd4, 0xd1, 0xbb, 0xfd, 0x53, 0x5b, 0x54, + 0x52, 0x8c, 0xe6, 0x63, 0x2d, 0xda, 0x8, 0x83, 0x39, 0x27}, + }, + { + {0x53, 0x24, 0x70, 0xa, 0x4c, 0xe, 0xa1, 0xb9, 0xde, 0x1b, 0x7d, + 0xd5, 0x66, 0x58, 0xa2, 0xf, 0xf7, 0xda, 0x27, 0xcd, 0xb5, 0xd9, + 0xb9, 0xff, 0xfd, 0x33, 0x2c, 0x49, 0x45, 0x29, 0x2c, 0x57}, + {0x13, 0xd4, 0x5e, 0x43, 0x28, 0x8d, 0xc3, 0x42, 0xc9, 0xcc, 0x78, + 0x32, 0x60, 0xf3, 0x50, 0xbd, 0xef, 0x3, 0xda, 0x79, 0x1a, 0xab, + 0x7, 0xbb, 0x55, 0x33, 0x8c, 0xbe, 0xae, 0x97, 0x95, 0x26}, + {0xbe, 0x30, 0xcd, 0xd6, 0x45, 0xc7, 0x7f, 0xc7, 0xfb, 0xae, 0xba, + 0xe3, 0xd3, 0xe8, 0xdf, 0xe4, 0xc, 0xda, 0x5d, 0xaa, 0x30, 0x88, + 0x2c, 0xa2, 0x80, 0xca, 0x5b, 0xc0, 0x98, 0x54, 0x98, 0x7f}, + }, + { + {0x63, 0x63, 0xbf, 0xf, 0x52, 0x15, 0x56, 0xd3, 0xa6, 0xfb, 0x4d, + 0xcf, 0x45, 0x5a, 0x4, 0x8, 0xc2, 0xa0, 0x3f, 0x87, 0xbc, 0x4f, + 0xc2, 0xee, 0xe7, 0x12, 0x9b, 0xd6, 0x3c, 0x65, 0xf2, 0x30}, + {0x17, 0xe1, 0xb, 0x9f, 0x88, 0xce, 0x49, 0x38, 0x88, 0xa2, 0x54, + 0x7b, 0x1b, 0xad, 0x5, 0x80, 0x1c, 0x92, 0xfc, 0x23, 0x9f, 0xc3, + 0xa3, 0x3d, 0x4, 0xf3, 0x31, 0xa, 0x47, 0xec, 0xc2, 0x76}, + {0x85, 0xc, 0xc1, 0xaa, 0x38, 0xc9, 0x8, 0x8a, 0xcb, 0x6b, 0x27, + 0xdb, 0x60, 0x9b, 0x17, 0x46, 0x70, 0xac, 0x6f, 0xe, 0x1e, 0xc0, + 0x20, 0xa9, 0xda, 0x73, 0x64, 0x59, 0xf1, 0x73, 0x12, 0x2f}, + }, + { + {0xc0, 0xb, 0xa7, 0x55, 0xd7, 0x8b, 0x48, 0x30, 0xe7, 0x42, 0xd4, + 0xf1, 0xa4, 0xb5, 0xd6, 0x6, 0x62, 0x61, 0x59, 0xbc, 0x9e, 0xa6, + 0xd1, 0xea, 0x84, 0xf7, 0xc5, 0xed, 0x97, 0x19, 0xac, 0x38}, + {0x11, 0x1e, 0xe0, 0x8a, 0x7c, 0xfc, 0x39, 0x47, 0x9f, 0xab, 0x6a, + 0x4a, 0x90, 0x74, 0x52, 0xfd, 0x2e, 0x8f, 0x72, 0x87, 0x82, 0x8a, + 0xd9, 0x41, 0xf2, 0x69, 0x5b, 0xd8, 0x2a, 0x57, 0x9e, 0x5d}, + {0x3b, 0xb1, 0x51, 0xa7, 0x17, 0xb5, 0x66, 0x6, 0x8c, 0x85, 0x9b, + 0x7e, 0x86, 0x6, 0x7d, 0x74, 0x49, 0xde, 0x4d, 0x45, 0x11, 0xc0, + 0xac, 0xac, 0x9c, 0xe6, 0xe9, 0xbf, 0x9c, 0xcd, 0xdf, 0x22}, + }, + { + {0xa1, 0xe0, 0x3b, 0x10, 0xb4, 0x59, 0xec, 0x56, 0x69, 0xf9, 0x59, + 0xd2, 0xec, 0xba, 0xe3, 0x2e, 0x32, 0xcd, 0xf5, 0x13, 0x94, 0xb2, + 0x7c, 0x79, 0x72, 0xe4, 0xcd, 0x24, 0x78, 0x87, 0xe9, 0xf}, + {0xd9, 0xc, 0xd, 0xc3, 0xe0, 0xd2, 0xdb, 0x8d, 0x33, 0x43, 0xbb, + 0xac, 0x5f, 0x66, 0x8e, 0xad, 0x1f, 0x96, 0x2a, 0x32, 0x8c, 0x25, + 0x6b, 0x8f, 0xc7, 0xc1, 0x48, 0x54, 0xc0, 0x16, 0x29, 0x6b}, + {0x3b, 0x91, 0xba, 0xa, 0xd1, 0x34, 0xdb, 0x7e, 0xe, 0xac, 0x6d, + 0x2e, 0x82, 0xcd, 0xa3, 0x4e, 0x15, 0xf8, 0x78, 0x65, 0xff, 0x3d, + 0x8, 0x66, 0x17, 0xa, 0xf0, 0x7f, 0x30, 0x3f, 0x30, 0x4c}, + }, + { + {0x0, 0x45, 0xd9, 0xd, 0x58, 0x3, 0xfc, 0x29, 0x93, 0xec, 0xbb, + 0x6f, 0xa4, 0x7a, 0xd2, 0xec, 0xf8, 0xa7, 0xe2, 0xc2, 0x5f, 0x15, + 0xa, 0x13, 0xd5, 0xa1, 0x6, 0xb7, 0x1a, 0x15, 0x6b, 0x41}, + {0x85, 0x8c, 0xb2, 0x17, 0xd6, 0x3b, 0xa, 0xd3, 0xea, 0x3b, 0x77, + 0x39, 0xb7, 0x77, 0xd3, 0xc5, 0xbf, 0x5c, 0x6a, 0x1e, 0x8c, 0xe7, + 0xc6, 0xc6, 0xc4, 0xb7, 0x2a, 0x8b, 0xf7, 0xb8, 0x61, 0xd}, + {0xb0, 0x36, 0xc1, 0xe9, 0xef, 0xd7, 0xa8, 0x56, 0x20, 0x4b, 0xe4, + 0x58, 0xcd, 0xe5, 0x7, 0xbd, 0xab, 0xe0, 0x57, 0x1b, 0xda, 0x2f, + 0xe6, 0xaf, 0xd2, 0xe8, 0x77, 0x42, 0xf7, 0x2a, 0x1a, 0x19}, + }, + }, + { + { + {0xfb, 0xe, 0x46, 0x4f, 0x43, 0x2b, 0xe6, 0x9f, 0xd6, 0x7, 0x36, + 0xa6, 0xd4, 0x3, 0xd3, 0xde, 0x24, 0xda, 0xa0, 0xb7, 0xe, 0x21, + 0x52, 0xf0, 0x93, 0x5b, 0x54, 0x0, 0xbe, 0x7d, 0x7e, 0x23}, + {0x31, 0x14, 0x3c, 0xc5, 0x4b, 0xf7, 0x16, 0xce, 0xde, 0xed, 0x72, + 0x20, 0xce, 0x25, 0x97, 0x2b, 0xe7, 0x3e, 0xb2, 0xb5, 0x6f, 0xc3, + 0xb9, 0xb8, 0x8, 0xc9, 0x5c, 0xb, 0x45, 0xe, 0x2e, 0x7e}, + {0x30, 0xb4, 0x1, 0x67, 0xed, 0x75, 0x35, 0x1, 0x10, 0xfd, 0xb, + 0x9f, 0xe6, 0x94, 0x10, 0x23, 0x22, 0x7f, 0xe4, 0x83, 0x15, 0xf, + 0x32, 0x75, 0xe3, 0x55, 0x11, 0xb1, 0x99, 0xa6, 0xaf, 0x71}, + }, + { + {0xd6, 0x50, 0x3b, 0x47, 0x1c, 0x3c, 0x42, 0xea, 0x10, 0xef, 0x38, + 0x3b, 0x1f, 0x7a, 0xe8, 0x51, 0x95, 0xbe, 0xc9, 0xb2, 0x5f, 0xbf, + 0x84, 0x9b, 0x1c, 0x9a, 0xf8, 0x78, 0xbc, 0x1f, 0x73, 0x0}, + {0x1d, 0xb6, 0x53, 0x39, 0x9b, 0x6f, 0xce, 0x65, 0xe6, 0x41, 0xa1, + 0xaf, 0xea, 0x39, 0x58, 0xc6, 0xfe, 0x59, 0xf7, 0xa9, 0xfd, 0x5f, + 0x43, 0xf, 0x8e, 0xc2, 0xb1, 0xc2, 0xe9, 0x42, 0x11, 0x2}, + {0x80, 0x18, 0xf8, 0x48, 0x18, 0xc7, 0x30, 0xe4, 0x19, 0xc1, 0xce, + 0x5e, 0x22, 0xc, 0x96, 0xbf, 0xe3, 0x15, 0xba, 0x6b, 0x83, 0xe0, + 0xda, 0xb6, 0x8, 0x58, 0xe1, 0x47, 0x33, 0x6f, 0x4d, 0x4c}, + }, + { + {0x70, 0x19, 0x8f, 0x98, 0xfc, 0xdd, 0xc, 0x2f, 0x1b, 0xf5, 0xb9, + 0xb0, 0x27, 0x62, 0x91, 0x6b, 0xbe, 0x76, 0x91, 0x77, 0xc4, 0xb6, + 0xc7, 0x6e, 0xa8, 0x9f, 0x8f, 0xa8, 0x0, 0x95, 0xbf, 0x38}, + {0xc9, 0x1f, 0x7d, 0xc1, 0xcf, 0xec, 0xf7, 0x18, 0x14, 0x3c, 0x40, + 0x51, 0xa6, 0xf5, 0x75, 0x6c, 0xdf, 0xc, 0xee, 0xf7, 0x2b, 0x71, + 0xde, 0xdb, 0x22, 0x7a, 0xe4, 0xa7, 0xaa, 0xdd, 0x3f, 0x19}, + {0x6f, 0x87, 0xe8, 0x37, 0x3c, 0xc9, 0xd2, 0x1f, 0x2c, 0x46, 0xd1, + 0x18, 0x5a, 0x1e, 0xf6, 0xa2, 0x76, 0x12, 0x24, 0x39, 0x82, 0xf5, + 0x80, 0x50, 0x69, 0x49, 0xd, 0xbf, 0x9e, 0xb9, 0x6f, 0x6a}, + }, + { + {0xc6, 0x23, 0xe4, 0xb6, 0xb5, 0x22, 0xb1, 0xee, 0x8e, 0xff, 0x86, + 0xf2, 0x10, 0x70, 0x9d, 0x93, 0x8c, 0x5d, 0xcf, 0x1d, 0x83, 0x2a, + 0xa9, 0x90, 0x10, 0xeb, 0xc5, 0x42, 0x9f, 0xda, 0x6f, 0x13}, + {0xeb, 0x55, 0x8, 0x56, 0xbb, 0xc1, 0x46, 0x6a, 0x9d, 0xf0, 0x93, + 0xf8, 0x38, 0xbb, 0x16, 0x24, 0xc1, 0xac, 0x71, 0x8f, 0x37, 0x11, + 0x1d, 0xd7, 0xea, 0x96, 0x18, 0xa3, 0x14, 0x69, 0xf7, 0x75}, + {0xd1, 0xbd, 0x5, 0xa3, 0xb1, 0xdf, 0x4c, 0xf9, 0x8, 0x2c, 0xf8, + 0x9f, 0x9d, 0x4b, 0x36, 0xf, 0x8a, 0x58, 0xbb, 0xc3, 0xa5, 0xd8, + 0x87, 0x2a, 0xba, 0xdc, 0xe8, 0xb, 0x51, 0x83, 0x21, 0x2}, + }, + { + {0x7f, 0x7a, 0x30, 0x43, 0x1, 0x71, 0x5a, 0x9d, 0x5f, 0xa4, 0x7d, + 0xc4, 0x9e, 0xde, 0x63, 0xb0, 0xd3, 0x7a, 0x92, 0xbe, 0x52, 0xfe, + 0xbb, 0x22, 0x6c, 0x42, 0x40, 0xfd, 0x41, 0xc4, 0x87, 0x13}, + {0x14, 0x2d, 0xad, 0x5e, 0x38, 0x66, 0xf7, 0x4a, 0x30, 0x58, 0x7c, + 0xca, 0x80, 0xd8, 0x8e, 0xa0, 0x3d, 0x1e, 0x21, 0x10, 0xe6, 0xa6, + 0x13, 0xd, 0x3, 0x6c, 0x80, 0x7b, 0xe1, 0x1c, 0x7, 0x6a}, + {0xf8, 0x8a, 0x97, 0x87, 0xd1, 0xc3, 0xd3, 0xb5, 0x13, 0x44, 0xe, + 0x7f, 0x3d, 0x5a, 0x2b, 0x72, 0xa0, 0x7c, 0x47, 0xbb, 0x48, 0x48, + 0x7b, 0xd, 0x92, 0xdc, 0x1e, 0xaf, 0x6a, 0xb2, 0x71, 0x31}, + }, + { + {0xd1, 0x47, 0x8a, 0xb2, 0xd8, 0xb7, 0xd, 0xa6, 0xf1, 0xa4, 0x70, + 0x17, 0xd6, 0x14, 0xbf, 0xa6, 0x58, 0xbd, 0xdd, 0x53, 0x93, 0xf8, + 0xa1, 0xd4, 0xe9, 0x43, 0x42, 0x34, 0x63, 0x4a, 0x51, 0x6c}, + {0xa8, 0x4c, 0x56, 0x97, 0x90, 0x31, 0x2f, 0xa9, 0x19, 0xe1, 0x75, + 0x22, 0x4c, 0xb8, 0x7b, 0xff, 0x50, 0x51, 0x87, 0xa4, 0x37, 0xfe, + 0x55, 0x4f, 0x5a, 0x83, 0xf0, 0x3c, 0x87, 0xd4, 0x1f, 0x22}, + {0x41, 0x63, 0x15, 0x3a, 0x4f, 0x20, 0x22, 0x23, 0x2d, 0x3, 0xa, + 0xba, 0xe9, 0xe0, 0x73, 0xfb, 0xe, 0x3, 0xf, 0x41, 0x4c, 0xdd, + 0xe0, 0xfc, 0xaa, 0x4a, 0x92, 0xfb, 0x96, 0xa5, 0xda, 0x48}, + }, + { + {0x93, 0x97, 0x4c, 0xc8, 0x5d, 0x1d, 0xf6, 0x14, 0x6, 0x82, 0x41, + 0xef, 0xe3, 0xf9, 0x41, 0x99, 0xac, 0x77, 0x62, 0x34, 0x8f, 0xb8, + 0xf5, 0xcd, 0xa9, 0x79, 0x8a, 0xe, 0xfa, 0x37, 0xc8, 0x58}, + {0xc7, 0x9c, 0xa5, 0x5c, 0x66, 0x8e, 0xca, 0x6e, 0xa0, 0xac, 0x38, + 0x2e, 0x4b, 0x25, 0x47, 0xa8, 0xce, 0x17, 0x1e, 0xd2, 0x8, 0xc7, + 0xaf, 0x31, 0xf7, 0x4a, 0xd8, 0xca, 0xfc, 0xd6, 0x6d, 0x67}, + {0x58, 0x90, 0xfc, 0x96, 0x85, 0x68, 0xf9, 0xc, 0x1b, 0xa0, 0x56, + 0x7b, 0xf3, 0xbb, 0xdc, 0x1d, 0x6a, 0xd6, 0x35, 0x49, 0x7d, 0xe7, + 0xc2, 0xdc, 0xa, 0x7f, 0xa5, 0xc6, 0xf2, 0x73, 0x4f, 0x1c}, + }, + { + {0x84, 0x34, 0x7c, 0xfc, 0x6e, 0x70, 0x6e, 0xb3, 0x61, 0xcf, 0xc1, + 0xc3, 0xb4, 0xc9, 0xdf, 0x73, 0xe5, 0xc7, 0x1c, 0x78, 0xc9, 0x79, + 0x1d, 0xeb, 0x5c, 0x67, 0xaf, 0x7d, 0xdb, 0x9a, 0x45, 0x70}, + {0xbb, 0xa0, 0x5f, 0x30, 0xbd, 0x4f, 0x7a, 0xe, 0xad, 0x63, 0xc6, + 0x54, 0xe0, 0x4c, 0x9d, 0x82, 0x48, 0x38, 0xe3, 0x2f, 0x83, 0xc3, + 0x21, 0xf4, 0x42, 0x4c, 0xf6, 0x1b, 0xd, 0xc8, 0x5a, 0x79}, + {0xb3, 0x2b, 0xb4, 0x91, 0x49, 0xdb, 0x91, 0x1b, 0xca, 0xdc, 0x2, + 0x4b, 0x23, 0x96, 0x26, 0x57, 0xdc, 0x78, 0x8c, 0x1f, 0xe5, 0x9e, + 0xdf, 0x9f, 0xd3, 0x1f, 0xe2, 0x8c, 0x84, 0x62, 0xe1, 0x5f}, + }, + }, + { + { + {0x8, 0xb2, 0x7c, 0x5d, 0x2d, 0x85, 0x79, 0x28, 0xe7, 0xf2, 0x7d, + 0x68, 0x70, 0xdd, 0xde, 0xb8, 0x91, 0x78, 0x68, 0x21, 0xab, 0xff, + 0xb, 0xdc, 0x35, 0xaa, 0x7d, 0x67, 0x43, 0xc0, 0x44, 0x2b}, + {0x1a, 0x96, 0x94, 0xe1, 0x4f, 0x21, 0x59, 0x4e, 0x4f, 0xcd, 0x71, + 0xd, 0xc7, 0x7d, 0xbe, 0x49, 0x2d, 0xf2, 0x50, 0x3b, 0xd2, 0xcf, + 0x0, 0x93, 0x32, 0x72, 0x91, 0xfc, 0x46, 0xd4, 0x89, 0x47}, + {0x8e, 0xb7, 0x4e, 0x7, 0xab, 0x87, 0x1c, 0x1a, 0x67, 0xf4, 0xda, + 0x99, 0x8e, 0xd1, 0xc6, 0xfa, 0x67, 0x90, 0x4f, 0x48, 0xcd, 0xbb, + 0xac, 0x3e, 0xe4, 0xa4, 0xb9, 0x2b, 0xef, 0x2e, 0xc5, 0x60}, + }, + { + {0x11, 0x6d, 0xae, 0x7c, 0xc2, 0xc5, 0x2b, 0x70, 0xab, 0x8c, 0xa4, + 0x54, 0x9b, 0x69, 0xc7, 0x44, 0xb2, 0x2e, 0x49, 0xba, 0x56, 0x40, + 0xbc, 0xef, 0x6d, 0x67, 0xb6, 0xd9, 0x48, 0x72, 0xd7, 0x70}, + {0xf1, 0x8b, 0xfd, 0x3b, 0xbc, 0x89, 0x5d, 0xb, 0x1a, 0x55, 0xf3, + 0xc9, 0x37, 0x92, 0x6b, 0xb0, 0xf5, 0x28, 0x30, 0xd5, 0xb0, 0x16, + 0x4c, 0xe, 0xab, 0xca, 0xcf, 0x2c, 0x31, 0x9c, 0xbc, 0x10}, + {0x5b, 0xa0, 0xc2, 0x3e, 0x4b, 0xe8, 0x8a, 0xaa, 0xe0, 0x81, 0x17, + 0xed, 0xf4, 0x9e, 0x69, 0x98, 0xd1, 0x85, 0x8e, 0x70, 0xe4, 0x13, + 0x45, 0x79, 0x13, 0xf4, 0x76, 0xa9, 0xd3, 0x5b, 0x75, 0x63}, + }, + { + {0xb7, 0xac, 0xf1, 0x97, 0x18, 0x10, 0xc7, 0x3d, 0xd8, 0xbb, 0x65, + 0xc1, 0x5e, 0x7d, 0xda, 0x5d, 0xf, 0x2, 0xa1, 0xf, 0x9c, 0x5b, + 0x8e, 0x50, 0x56, 0x2a, 0xc5, 0x37, 0x17, 0x75, 0x63, 0x27}, + {0x53, 0x8, 0xd1, 0x2a, 0x3e, 0xa0, 0x5f, 0xb5, 0x69, 0x35, 0xe6, + 0x9e, 0x90, 0x75, 0x6f, 0x35, 0x90, 0xb8, 0x69, 0xbe, 0xfd, 0xf1, + 0xf9, 0x9f, 0x84, 0x6f, 0xc1, 0x8b, 0xc4, 0xc1, 0x8c, 0xd}, + {0xa9, 0x19, 0xb4, 0x6e, 0xd3, 0x2, 0x94, 0x2, 0xa5, 0x60, 0xb4, + 0x77, 0x7e, 0x4e, 0xb4, 0xf0, 0x56, 0x49, 0x3c, 0xd4, 0x30, 0x62, + 0xa8, 0xcf, 0xe7, 0x66, 0xd1, 0x7a, 0x8a, 0xdd, 0xc2, 0x70}, + }, + { + {0x13, 0x7e, 0xed, 0xb8, 0x7d, 0x96, 0xd4, 0x91, 0x7a, 0x81, 0x76, + 0xd7, 0xa, 0x2f, 0x25, 0x74, 0x64, 0x25, 0x85, 0xd, 0xe0, 0x82, + 0x9, 0xe4, 0xe5, 0x3c, 0xa5, 0x16, 0x38, 0x61, 0xb8, 0x32}, + {0xe, 0xec, 0x6f, 0x9f, 0x50, 0x94, 0x61, 0x65, 0x8d, 0x51, 0xc6, + 0x46, 0xa9, 0x7e, 0x2e, 0xee, 0x5c, 0x9b, 0xe0, 0x67, 0xf3, 0xc1, + 0x33, 0x97, 0x95, 0x84, 0x94, 0x63, 0x63, 0xac, 0xf, 0x2e}, + {0x64, 0xcd, 0x48, 0xe4, 0xbe, 0xf7, 0xe7, 0x79, 0xd0, 0x86, 0x78, + 0x8, 0x67, 0x3a, 0xc8, 0x6a, 0x2e, 0xdb, 0xe4, 0xa0, 0xd9, 0xd4, + 0x9f, 0xf8, 0x41, 0x4f, 0x5a, 0x73, 0x5c, 0x21, 0x79, 0x41}, + }, + { + {0x34, 0xcd, 0x6b, 0x28, 0xb9, 0x33, 0xae, 0xe4, 0xdc, 0xd6, 0x9d, + 0x55, 0xb6, 0x7e, 0xef, 0xb7, 0x1f, 0x8e, 0xd3, 0xb3, 0x1f, 0x14, + 0x8b, 0x27, 0x86, 0xc2, 0x41, 0x22, 0x66, 0x85, 0xfa, 0x31}, + {0x2a, 0xed, 0xdc, 0xd7, 0xe7, 0x94, 0x70, 0x8c, 0x70, 0x9c, 0xd3, + 0x47, 0xc3, 0x8a, 0xfb, 0x97, 0x2, 0xd9, 0x6, 0xa9, 0x33, 0xe0, + 0x3b, 0xe1, 0x76, 0x9d, 0xd9, 0xc, 0xa3, 0x44, 0x3, 0x70}, + {0xf4, 0x22, 0x36, 0x2e, 0x42, 0x6c, 0x82, 0xaf, 0x2d, 0x50, 0x33, + 0x98, 0x87, 0x29, 0x20, 0xc1, 0x23, 0x91, 0x38, 0x2b, 0xe1, 0xb7, + 0xc1, 0x9b, 0x89, 0x24, 0x95, 0xa9, 0x12, 0x23, 0xbb, 0x24}, + }, + { + {0x6b, 0x5c, 0xf8, 0xf5, 0x2a, 0xc, 0xf8, 0x41, 0x94, 0x67, 0xfa, + 0x4, 0xc3, 0x84, 0x72, 0x68, 0xad, 0x1b, 0xba, 0xa3, 0x99, 0xdf, + 0x45, 0x89, 0x16, 0x5d, 0xeb, 0xff, 0xf9, 0x2a, 0x1d, 0xd}, + {0xc3, 0x67, 0xde, 0x32, 0x17, 0xed, 0xa8, 0xb1, 0x48, 0x49, 0x1b, + 0x46, 0x18, 0x94, 0xb4, 0x3c, 0xd2, 0xbc, 0xcf, 0x76, 0x43, 0x43, + 0xbd, 0x8e, 0x8, 0x80, 0x18, 0x1e, 0x87, 0x3e, 0xee, 0xf}, + {0xdf, 0x1e, 0x62, 0x32, 0xa1, 0x8a, 0xda, 0xa9, 0x79, 0x65, 0x22, + 0x59, 0xa1, 0x22, 0xb8, 0x30, 0x93, 0xc1, 0x9a, 0xa7, 0x7b, 0x19, + 0x4, 0x40, 0x76, 0x1d, 0x53, 0x18, 0x97, 0xd7, 0xac, 0x16}, + }, + { + {0xad, 0xb6, 0x87, 0x78, 0xc5, 0xc6, 0x59, 0xc9, 0xba, 0xfe, 0x90, + 0x5f, 0xad, 0x9e, 0xe1, 0x94, 0x4, 0xf5, 0x42, 0xa3, 0x62, 0x4e, + 0xe2, 0x16, 0x0, 0x17, 0x16, 0x18, 0x4b, 0xd3, 0x4e, 0x16}, + {0x3d, 0x1d, 0x9b, 0x2d, 0xaf, 0x72, 0xdf, 0x72, 0x5a, 0x24, 0x32, + 0xa4, 0x36, 0x2a, 0x46, 0x63, 0x37, 0x96, 0xb3, 0x16, 0x79, 0xa0, + 0xce, 0x3e, 0x9, 0x23, 0x30, 0xb9, 0xf6, 0xe, 0x3e, 0x12}, + {0x9a, 0xe6, 0x2f, 0x19, 0x4c, 0xd9, 0x7e, 0x48, 0x13, 0x15, 0x91, + 0x3a, 0xea, 0x2c, 0xae, 0x61, 0x27, 0xde, 0xa4, 0xb9, 0xd3, 0xf6, + 0x7b, 0x87, 0xeb, 0xf3, 0x73, 0x10, 0xc6, 0xf, 0xda, 0x78}, + }, + { + {0x94, 0x3a, 0xc, 0x68, 0xf1, 0x80, 0x9f, 0xa2, 0xe6, 0xe7, 0xe9, + 0x1a, 0x15, 0x7e, 0xf7, 0x71, 0x73, 0x79, 0x1, 0x48, 0x58, 0xf1, + 0x0, 0x11, 0xdd, 0x8d, 0xb3, 0x16, 0xb3, 0xa4, 0x4a, 0x5}, + {0x6a, 0xc6, 0x2b, 0xe5, 0x28, 0x5d, 0xf1, 0x5b, 0x8e, 0x1a, 0xf0, + 0x70, 0x18, 0xe3, 0x47, 0x2c, 0xdd, 0x8b, 0xc2, 0x6, 0xbc, 0xaf, + 0x19, 0x24, 0x3a, 0x17, 0x6b, 0x25, 0xeb, 0xde, 0x25, 0x2d}, + {0xb8, 0x7c, 0x26, 0x19, 0x8d, 0x46, 0xc8, 0xdf, 0xaf, 0x4d, 0xe5, + 0x66, 0x9c, 0x78, 0x28, 0xb, 0x17, 0xec, 0x6e, 0x66, 0x2a, 0x1d, + 0xeb, 0x2a, 0x60, 0xa7, 0x7d, 0xab, 0xa6, 0x10, 0x46, 0x13}, + }, + }, + { + { + {0x15, 0xf5, 0xd1, 0x77, 0xe7, 0x65, 0x2a, 0xcd, 0xf1, 0x60, 0xaa, + 0x8f, 0x87, 0x91, 0x89, 0x54, 0xe5, 0x6, 0xbc, 0xda, 0xbc, 0x3b, + 0xb7, 0xb1, 0xfb, 0xc9, 0x7c, 0xa9, 0xcb, 0x78, 0x48, 0x65}, + {0xfe, 0xb0, 0xf6, 0x8d, 0xc7, 0x8e, 0x13, 0x51, 0x1b, 0xf5, 0x75, + 0xe5, 0x89, 0xda, 0x97, 0x53, 0xb9, 0xf1, 0x7a, 0x71, 0x1d, 0x7a, + 0x20, 0x9, 0x50, 0xd6, 0x20, 0x2b, 0xba, 0xfd, 0x2, 0x21}, + {0xa1, 0xe6, 0x5c, 0x5, 0x5, 0xe4, 0x9e, 0x96, 0x29, 0xad, 0x51, + 0x12, 0x68, 0xa7, 0xbc, 0x36, 0x15, 0xa4, 0x7d, 0xaa, 0x17, 0xf5, + 0x1a, 0x3a, 0xba, 0xb2, 0xec, 0x29, 0xdb, 0x25, 0xd7, 0xa}, + }, + { + {0x85, 0x6f, 0x5, 0x9b, 0xc, 0xbc, 0xc7, 0xfe, 0xd7, 0xff, 0xf5, + 0xe7, 0x68, 0x52, 0x7d, 0x53, 0xfa, 0xae, 0x12, 0x43, 0x62, 0xc6, + 0xaf, 0x77, 0xd9, 0x9f, 0x39, 0x2, 0x53, 0x5f, 0x67, 0x4f}, + {0x57, 0x24, 0x4e, 0x83, 0xb1, 0x67, 0x42, 0xdc, 0xc5, 0x1b, 0xce, + 0x70, 0xb5, 0x44, 0x75, 0xb6, 0xd7, 0x5e, 0xd1, 0xf7, 0xb, 0x7a, + 0xf0, 0x1a, 0x50, 0x36, 0xa0, 0x71, 0xfb, 0xcf, 0xef, 0x4a}, + {0x1e, 0x17, 0x15, 0x4, 0x36, 0x36, 0x2d, 0xc3, 0x3b, 0x48, 0x98, + 0x89, 0x11, 0xef, 0x2b, 0xcd, 0x10, 0x51, 0x94, 0xd0, 0xad, 0x6e, + 0xa, 0x87, 0x61, 0x65, 0xa8, 0xa2, 0x72, 0xbb, 0xcc, 0xb}, + }, + { + {0x96, 0x12, 0xfe, 0x50, 0x4c, 0x5e, 0x6d, 0x18, 0x7e, 0x9f, 0xe8, + 0xfe, 0x82, 0x7b, 0x39, 0xe0, 0xb0, 0x31, 0x70, 0x50, 0xc5, 0xf6, + 0xc7, 0x3b, 0xc2, 0x37, 0x8f, 0x10, 0x69, 0xfd, 0x78, 0x66}, + {0xc8, 0xa9, 0xb1, 0xea, 0x2f, 0x96, 0x5e, 0x18, 0xcd, 0x7d, 0x14, + 0x65, 0x35, 0xe6, 0xe7, 0x86, 0xf2, 0x6d, 0x5b, 0xbb, 0x31, 0xe0, + 0x92, 0xb0, 0x3e, 0xb7, 0xd6, 0x59, 0xab, 0xf0, 0x24, 0x40}, + {0xc2, 0x63, 0x68, 0x63, 0x31, 0xfa, 0x86, 0x15, 0xf2, 0x33, 0x2d, + 0x57, 0x48, 0x8c, 0xf6, 0x7, 0xfc, 0xae, 0x9e, 0x78, 0x9f, 0xcc, + 0x73, 0x4f, 0x1, 0x47, 0xad, 0x8e, 0x10, 0xe2, 0x42, 0x2d}, + }, + { + {0x93, 0x75, 0x53, 0xf, 0xd, 0x7b, 0x71, 0x21, 0x4c, 0x6, 0x1e, + 0x13, 0xb, 0x69, 0x4e, 0x91, 0x9f, 0xe0, 0x2a, 0x75, 0xae, 0x87, + 0xb6, 0x1b, 0x6e, 0x3c, 0x42, 0x9b, 0xa7, 0xf3, 0xb, 0x42}, + {0x9b, 0xd2, 0xdf, 0x94, 0x15, 0x13, 0xf5, 0x97, 0x6a, 0x4c, 0x3f, + 0x31, 0x5d, 0x98, 0x55, 0x61, 0x10, 0x50, 0x45, 0x8, 0x7, 0x3f, + 0xa1, 0xeb, 0x22, 0xd3, 0xd2, 0xb8, 0x8, 0x26, 0x6b, 0x67}, + {0x47, 0x2b, 0x5b, 0x1c, 0x65, 0xba, 0x38, 0x81, 0x80, 0x1b, 0x1b, + 0x31, 0xec, 0xb6, 0x71, 0x86, 0xb0, 0x35, 0x31, 0xbc, 0xb1, 0xc, + 0xff, 0x7b, 0xe0, 0xf1, 0xc, 0x9c, 0xfa, 0x2f, 0x5d, 0x74}, + }, + { + {0x6a, 0x4e, 0xd3, 0x21, 0x57, 0xdf, 0x36, 0x60, 0xd0, 0xb3, 0x7b, + 0x99, 0x27, 0x88, 0xdb, 0xb1, 0xfa, 0x6a, 0x75, 0xc8, 0xc3, 0x9, + 0xc2, 0xd3, 0x39, 0xc8, 0x1d, 0x4c, 0xe5, 0x5b, 0xe1, 0x6}, + {0xbd, 0xc8, 0xc9, 0x2b, 0x1e, 0x5a, 0x52, 0xbf, 0x81, 0x9d, 0x47, + 0x26, 0x8, 0x26, 0x5b, 0xea, 0xdb, 0x55, 0x1, 0xdf, 0xe, 0xc7, + 0x11, 0xd5, 0xd0, 0xf5, 0xc, 0x96, 0xeb, 0x3c, 0xe2, 0x1a}, + {0x4a, 0x99, 0x32, 0x19, 0x87, 0x5d, 0x72, 0x5b, 0xb0, 0xda, 0xb1, + 0xce, 0xb5, 0x1c, 0x35, 0x32, 0x5, 0xca, 0xb7, 0xda, 0x49, 0x15, + 0xc4, 0x7d, 0xf7, 0xc1, 0x8e, 0x27, 0x61, 0xd8, 0xde, 0x58}, + }, + { + {0xa8, 0xc9, 0xc2, 0xb6, 0xa8, 0x5b, 0xfb, 0x2d, 0x8c, 0x59, 0x2c, + 0xf5, 0x8e, 0xef, 0xee, 0x48, 0x73, 0x15, 0x2d, 0xf1, 0x7, 0x91, + 0x80, 0x33, 0xd8, 0x5b, 0x1d, 0x53, 0x6b, 0x69, 0xba, 0x8}, + {0x5c, 0xc5, 0x66, 0xf2, 0x93, 0x37, 0x17, 0xd8, 0x49, 0x4e, 0x45, + 0xcc, 0xc5, 0x76, 0xc9, 0xc8, 0xa8, 0xc3, 0x26, 0xbc, 0xf8, 0x82, + 0xe3, 0x5c, 0xf9, 0xf6, 0x85, 0x54, 0xe8, 0x9d, 0xf3, 0x2f}, + {0x7a, 0xc5, 0xef, 0xc3, 0xee, 0x3e, 0xed, 0x77, 0x11, 0x48, 0xff, + 0xd4, 0x17, 0x55, 0xe0, 0x4, 0xcb, 0x71, 0xa6, 0xf1, 0x3f, 0x7a, + 0x3d, 0xea, 0x54, 0xfe, 0x7c, 0x94, 0xb4, 0x33, 0x6, 0x12}, + }, + { + {0xa, 0x10, 0x12, 0x49, 0x47, 0x31, 0xbd, 0x82, 0x6, 0xbe, 0x6f, + 0x7e, 0x6d, 0x7b, 0x23, 0xde, 0xc6, 0x79, 0xea, 0x11, 0x19, 0x76, + 0x1e, 0xe1, 0xde, 0x3b, 0x39, 0xcb, 0xe3, 0x3b, 0x43, 0x7}, + {0x42, 0x0, 0x61, 0x91, 0x78, 0x98, 0x94, 0xb, 0xe8, 0xfa, 0xeb, + 0xec, 0x3c, 0xb1, 0xe7, 0x4e, 0xc0, 0xa4, 0xf0, 0x94, 0x95, 0x73, + 0xbe, 0x70, 0x85, 0x91, 0xd5, 0xb4, 0x99, 0xa, 0xd3, 0x35}, + {0xf4, 0x97, 0xe9, 0x5c, 0xc0, 0x44, 0x79, 0xff, 0xa3, 0x51, 0x5c, + 0xb0, 0xe4, 0x3d, 0x5d, 0x57, 0x7c, 0x84, 0x76, 0x5a, 0xfd, 0x81, + 0x33, 0x58, 0x9f, 0xda, 0xf6, 0x7a, 0xde, 0x3e, 0x87, 0x2d}, + }, + { + {0x81, 0xf9, 0x5d, 0x4e, 0xe1, 0x2, 0x62, 0xaa, 0xf5, 0xe1, 0x15, + 0x50, 0x17, 0x59, 0xd, 0xa2, 0x6c, 0x1d, 0xe2, 0xba, 0xd3, 0x75, + 0xa2, 0x18, 0x53, 0x2, 0x60, 0x1, 0x8a, 0x61, 0x43, 0x5}, + {0x9, 0x34, 0x37, 0x43, 0x64, 0x31, 0x7a, 0x15, 0xd9, 0x81, 0xaa, + 0xf4, 0xee, 0xb7, 0xb8, 0xfa, 0x6, 0x48, 0xa6, 0xf5, 0xe6, 0xfe, + 0x93, 0xb0, 0xb6, 0xa7, 0x7f, 0x70, 0x54, 0x36, 0x77, 0x2e}, + {0xc1, 0x23, 0x4c, 0x97, 0xf4, 0xbd, 0xea, 0xd, 0x93, 0x46, 0xce, + 0x9d, 0x25, 0xa, 0x6f, 0xaa, 0x2c, 0xba, 0x9a, 0xa2, 0xb8, 0x2c, + 0x20, 0x4, 0xd, 0x96, 0x7, 0x2d, 0x36, 0x43, 0x14, 0x4b}, + }, + }, + { + { + {0xcb, 0x9c, 0x52, 0x1c, 0xe9, 0x54, 0x7c, 0x96, 0xfb, 0x35, 0xc6, + 0x64, 0x92, 0x26, 0xf6, 0x30, 0x65, 0x19, 0x12, 0x78, 0xf4, 0xaf, + 0x47, 0x27, 0x5c, 0x6f, 0xf6, 0xea, 0x18, 0x84, 0x3, 0x17}, + {0x7a, 0x1f, 0x6e, 0xb6, 0xc7, 0xb7, 0xc4, 0xcc, 0x7e, 0x2f, 0xc, + 0xf5, 0x25, 0x7e, 0x15, 0x44, 0x1c, 0xaf, 0x3e, 0x71, 0xfc, 0x6d, + 0xf0, 0x3e, 0xf7, 0x63, 0xda, 0x52, 0x67, 0x44, 0x2f, 0x58}, + {0xe4, 0x4c, 0x32, 0x20, 0xd3, 0x7b, 0x31, 0xc6, 0xc4, 0x8b, 0x48, + 0xa4, 0xe8, 0x42, 0x10, 0xa8, 0x64, 0x13, 0x5a, 0x4e, 0x8b, 0xf1, + 0x1e, 0xb2, 0xc9, 0x8d, 0xa2, 0xcd, 0x4b, 0x1c, 0x2a, 0xc}, + }, + { + {0x45, 0x69, 0xbd, 0x69, 0x48, 0x81, 0xc4, 0xed, 0x22, 0x8d, 0x1c, + 0xbe, 0x7d, 0x90, 0x6d, 0xd, 0xab, 0xc5, 0x5c, 0xd5, 0x12, 0xd2, + 0x3b, 0xc6, 0x83, 0xdc, 0x14, 0xa3, 0x30, 0x9b, 0x6a, 0x5a}, + {0x47, 0x4, 0x1f, 0x6f, 0xd0, 0xc7, 0x4d, 0xd2, 0x59, 0xc0, 0x87, + 0xdb, 0x3e, 0x9e, 0x26, 0xb2, 0x8f, 0xd2, 0xb2, 0xfb, 0x72, 0x2, + 0x5b, 0xd1, 0x77, 0x48, 0xf6, 0xc6, 0xd1, 0x8b, 0x55, 0x7c}, + {0x3d, 0x46, 0x96, 0xd3, 0x24, 0x15, 0xec, 0xd0, 0xf0, 0x24, 0x5a, + 0xc3, 0x8a, 0x62, 0xbb, 0x12, 0xa4, 0x5f, 0xbc, 0x1c, 0x79, 0x3a, + 0xc, 0xa5, 0xc3, 0xaf, 0xfb, 0xa, 0xca, 0xa5, 0x4, 0x4}, + }, + { + {0xd1, 0x6f, 0x41, 0x2a, 0x1b, 0x9e, 0xbc, 0x62, 0x8b, 0x59, 0x50, + 0xe3, 0x28, 0xf7, 0xc6, 0xb5, 0x67, 0x69, 0x5d, 0x3d, 0xd8, 0x3f, + 0x34, 0x4, 0x98, 0xee, 0xf8, 0xe7, 0x16, 0x75, 0x52, 0x39}, + {0xd6, 0x43, 0xa7, 0xa, 0x7, 0x40, 0x1f, 0x8c, 0xe8, 0x5e, 0x26, + 0x5b, 0xcb, 0xd0, 0xba, 0xcc, 0xde, 0xd2, 0x8f, 0x66, 0x6b, 0x4, + 0x4b, 0x57, 0x33, 0x96, 0xdd, 0xca, 0xfd, 0x5b, 0x39, 0x46}, + {0x9c, 0x9a, 0x5d, 0x1a, 0x2d, 0xdb, 0x7f, 0x11, 0x2a, 0x5c, 0x0, + 0xd1, 0xbc, 0x45, 0x77, 0x9c, 0xea, 0x6f, 0xd5, 0x54, 0xf1, 0xbe, + 0xd4, 0xef, 0x16, 0xd0, 0x22, 0xe8, 0x29, 0x9a, 0x57, 0x76}, + }, + { + {0xf2, 0x34, 0xb4, 0x52, 0x13, 0xb5, 0x3c, 0x33, 0xe1, 0x80, 0xde, + 0x93, 0x49, 0x28, 0x32, 0xd8, 0xce, 0x35, 0xd, 0x75, 0x87, 0x28, + 0x51, 0xb5, 0xc1, 0x77, 0x27, 0x2a, 0xbb, 0x14, 0xc5, 0x2}, + {0x17, 0x2a, 0xc0, 0x49, 0x7e, 0x8e, 0xb6, 0x45, 0x7f, 0xa3, 0xa9, + 0xbc, 0xa2, 0x51, 0xcd, 0x23, 0x1b, 0x4c, 0x22, 0xec, 0x11, 0x5f, + 0xd6, 0x3e, 0xb1, 0xbd, 0x5, 0x9e, 0xdc, 0x84, 0xa3, 0x43}, + {0x45, 0xb6, 0xf1, 0x8b, 0xda, 0xd5, 0x4b, 0x68, 0x53, 0x4b, 0xb5, + 0xf6, 0x7e, 0xd3, 0x8b, 0xfb, 0x53, 0xd2, 0xb0, 0xa9, 0xd7, 0x16, + 0x39, 0x31, 0x59, 0x80, 0x54, 0x61, 0x9, 0x92, 0x60, 0x11}, + }, + { + {0xcd, 0x4d, 0x9b, 0x36, 0x16, 0x56, 0x38, 0x7a, 0x63, 0x35, 0x5c, + 0x65, 0xa7, 0x2c, 0xc0, 0x75, 0x21, 0x80, 0xf1, 0xd4, 0xf9, 0x1b, + 0xc2, 0x7d, 0x42, 0xe0, 0xe6, 0x91, 0x74, 0x7d, 0x63, 0x2f}, + {0xaa, 0xcf, 0xda, 0x29, 0x69, 0x16, 0x4d, 0xb4, 0x8f, 0x59, 0x13, + 0x84, 0x4c, 0x9f, 0x52, 0xda, 0x59, 0x55, 0x3d, 0x45, 0xca, 0x63, + 0xef, 0xe9, 0xb, 0x8e, 0x69, 0xc5, 0x5b, 0x12, 0x1e, 0x35}, + {0xbe, 0x7b, 0xf6, 0x1a, 0x46, 0x9b, 0xb4, 0xd4, 0x61, 0x89, 0xab, + 0xc8, 0x7a, 0x3, 0x3, 0xd6, 0xfb, 0x99, 0xa6, 0xf9, 0x9f, 0xe1, + 0xde, 0x71, 0x9a, 0x2a, 0xce, 0xe7, 0x6, 0x2d, 0x18, 0x7f}, + }, + { + {0x22, 0x75, 0x21, 0x8e, 0x72, 0x4b, 0x45, 0x9, 0xd8, 0xb8, 0x84, + 0xd4, 0xf4, 0xe8, 0x58, 0xaa, 0x3c, 0x90, 0x46, 0x7f, 0x4d, 0x25, + 0x58, 0xd3, 0x17, 0x52, 0x1c, 0x24, 0x43, 0xc0, 0xac, 0x44}, + {0xec, 0x68, 0x1, 0xab, 0x64, 0x8e, 0x7c, 0x7a, 0x43, 0xc5, 0xed, + 0x15, 0x55, 0x4a, 0x5a, 0xcb, 0xda, 0xe, 0xcd, 0x47, 0xd3, 0x19, + 0x55, 0x9, 0xb0, 0x93, 0x3e, 0x34, 0x8c, 0xac, 0xd4, 0x67}, + {0x77, 0x57, 0x7a, 0x4f, 0xbb, 0x6b, 0x7d, 0x1c, 0xe1, 0x13, 0x83, + 0x91, 0xd4, 0xfe, 0x35, 0x8b, 0x84, 0x46, 0x6b, 0xc9, 0xc6, 0xa1, + 0xdc, 0x4a, 0xbd, 0x71, 0xad, 0x12, 0x83, 0x1c, 0x6d, 0x55}, + }, + { + {0x21, 0xe8, 0x1b, 0xb1, 0x56, 0x67, 0xf0, 0x81, 0xdd, 0xf3, 0xa3, + 0x10, 0x23, 0xf8, 0xaf, 0xf, 0x5d, 0x46, 0x99, 0x6a, 0x55, 0xd0, + 0xb2, 0xf8, 0x5, 0x7f, 0x8c, 0xcc, 0x38, 0xbe, 0x7a, 0x9}, + {0x82, 0x39, 0x8d, 0xc, 0xe3, 0x40, 0xef, 0x17, 0x34, 0xfa, 0xa3, + 0x15, 0x3e, 0x7, 0xf7, 0x31, 0x6e, 0x64, 0x73, 0x7, 0xcb, 0xf3, + 0x21, 0x4f, 0xff, 0x4e, 0x82, 0x1d, 0x6d, 0x6c, 0x6c, 0x74}, + {0xa4, 0x2d, 0xa5, 0x7e, 0x87, 0xc9, 0x49, 0xc, 0x43, 0x1d, 0xdc, + 0x9b, 0x55, 0x69, 0x43, 0x4c, 0xd2, 0xeb, 0xcc, 0xf7, 0x9, 0x38, + 0x2c, 0x2, 0xbd, 0x84, 0xee, 0x4b, 0xa3, 0x14, 0x7e, 0x57}, + }, + { + {0x2b, 0xd7, 0x4d, 0xbd, 0xbe, 0xce, 0xfe, 0x94, 0x11, 0x22, 0xf, + 0x6, 0xda, 0x4f, 0x6a, 0xf4, 0xff, 0xd1, 0xc8, 0xc0, 0x77, 0x59, + 0x4a, 0x12, 0x95, 0x92, 0x0, 0xfb, 0xb8, 0x4, 0x53, 0x70}, + {0xa, 0x3b, 0xa7, 0x61, 0xac, 0x68, 0xe2, 0xf0, 0xf5, 0xa5, 0x91, + 0x37, 0x10, 0xfa, 0xfa, 0xf2, 0xe9, 0x0, 0x6d, 0x6b, 0x82, 0x3e, + 0xe1, 0xc1, 0x42, 0x8f, 0xd7, 0x6f, 0xe9, 0x7e, 0xfa, 0x60}, + {0xc6, 0x6e, 0x29, 0x4d, 0x35, 0x1d, 0x3d, 0xb6, 0xd8, 0x31, 0xad, + 0x5f, 0x3e, 0x5, 0xc3, 0xf3, 0xec, 0x42, 0xbd, 0xb4, 0x8c, 0x95, + 0xb, 0x67, 0xfd, 0x53, 0x63, 0xa1, 0xc, 0x8e, 0x39, 0x21}, + }, + }, + { + { + {0x1, 0x56, 0xb7, 0xb4, 0xf9, 0xaa, 0x98, 0x27, 0x72, 0xad, 0x8d, + 0x5c, 0x13, 0x72, 0xac, 0x5e, 0x23, 0xa0, 0xb7, 0x61, 0x61, 0xaa, + 0xce, 0xd2, 0x4e, 0x7d, 0x8f, 0xe9, 0x84, 0xb2, 0xbf, 0x1b}, + {0xf3, 0x33, 0x2b, 0x38, 0x8a, 0x5, 0xf5, 0x89, 0xb4, 0xc0, 0x48, + 0xad, 0xb, 0xba, 0xe2, 0x5a, 0x6e, 0xb3, 0x3d, 0xa5, 0x3, 0xb5, + 0x93, 0x8f, 0xe6, 0x32, 0xa2, 0x95, 0x9d, 0xed, 0xa3, 0x5a}, + {0x61, 0x65, 0xd9, 0xc7, 0xe9, 0x77, 0x67, 0x65, 0x36, 0x80, 0xc7, + 0x72, 0x54, 0x12, 0x2b, 0xcb, 0xee, 0x6e, 0x50, 0xd9, 0x99, 0x32, + 0x5, 0x65, 0xcc, 0x57, 0x89, 0x5e, 0x4e, 0xe1, 0x7, 0x4a}, + }, + { + {0x9b, 0xa4, 0x77, 0xc4, 0xcd, 0x58, 0xb, 0x24, 0x17, 0xf0, 0x47, + 0x64, 0xde, 0xda, 0x38, 0xfd, 0xad, 0x6a, 0xc8, 0xa7, 0x32, 0x8d, + 0x92, 0x19, 0x81, 0xa0, 0xaf, 0x84, 0xed, 0x7a, 0xaf, 0x50}, + {0x99, 0xf9, 0xd, 0x98, 0xcb, 0x12, 0xe4, 0x4e, 0x71, 0xc7, 0x6e, + 0x3c, 0x6f, 0xd7, 0x15, 0xa3, 0xfd, 0x77, 0x5c, 0x92, 0xde, 0xed, + 0xa5, 0xbb, 0x2, 0x34, 0x31, 0x1d, 0x39, 0xac, 0xb, 0x3f}, + {0xe5, 0x5b, 0xf6, 0x15, 0x1, 0xde, 0x4f, 0x6e, 0xb2, 0x9, 0x61, + 0x21, 0x21, 0x26, 0x98, 0x29, 0xd9, 0xd6, 0xad, 0xb, 0x81, 0x5, + 0x2, 0x78, 0x6, 0xd0, 0xeb, 0xba, 0x16, 0xa3, 0x21, 0x19}, + }, + { + {0x8b, 0xc1, 0xf3, 0xd9, 0x9a, 0xad, 0x5a, 0xd7, 0x9c, 0xc1, 0xb1, + 0x60, 0xef, 0xe, 0x6a, 0x56, 0xd9, 0xe, 0x5c, 0x25, 0xac, 0xb, + 0x9a, 0x3e, 0xf5, 0xc7, 0x62, 0xa0, 0xec, 0x9d, 0x4, 0x7b}, + {0xfc, 0x70, 0xb8, 0xdf, 0x7e, 0x2f, 0x42, 0x89, 0xbd, 0xb3, 0x76, + 0x4f, 0xeb, 0x6b, 0x29, 0x2c, 0xf7, 0x4d, 0xc2, 0x36, 0xd4, 0xf1, + 0x38, 0x7, 0xb0, 0xae, 0x73, 0xe2, 0x41, 0xdf, 0x58, 0x64}, + {0x83, 0x44, 0x44, 0x35, 0x7a, 0xe3, 0xcb, 0xdc, 0x93, 0xbe, 0xed, + 0xf, 0x33, 0x79, 0x88, 0x75, 0x87, 0xdd, 0xc5, 0x12, 0xc3, 0x4, + 0x60, 0x78, 0x64, 0xe, 0x95, 0xc2, 0xcb, 0xdc, 0x93, 0x60}, + }, + { + {0x4b, 0x3, 0x84, 0x60, 0xbe, 0xee, 0xde, 0x6b, 0x54, 0xb8, 0xf, + 0x78, 0xb6, 0xc2, 0x99, 0x31, 0x95, 0x6, 0x2d, 0xb6, 0xab, 0x76, + 0x33, 0x97, 0x90, 0x7d, 0x64, 0x8b, 0xc9, 0x80, 0x31, 0x6e}, + {0x6d, 0x70, 0xe0, 0x85, 0x85, 0x9a, 0xf3, 0x1f, 0x33, 0x39, 0xe7, + 0xb3, 0xd8, 0xa5, 0xd0, 0x36, 0x3b, 0x45, 0x8f, 0x71, 0xe1, 0xf2, + 0xb9, 0x43, 0x7c, 0xa9, 0x27, 0x48, 0x8, 0xea, 0xd1, 0x57}, + {0x71, 0xb0, 0x28, 0xa1, 0xe7, 0xb6, 0x7a, 0xee, 0xaa, 0x8b, 0xa8, + 0x93, 0x6d, 0x59, 0xc1, 0xa4, 0x30, 0x61, 0x21, 0xb2, 0x82, 0xde, + 0xb4, 0xf7, 0x18, 0xbd, 0x97, 0xdd, 0x9d, 0x99, 0x3e, 0x36}, + }, + { + {0xc6, 0xae, 0x4b, 0xe2, 0xdc, 0x48, 0x18, 0x2f, 0x60, 0xaf, 0xbc, + 0xba, 0x55, 0x72, 0x9b, 0x76, 0x31, 0xe9, 0xef, 0x3c, 0x6e, 0x3c, + 0xcb, 0x90, 0x55, 0xb3, 0xf9, 0xc6, 0x9b, 0x97, 0x1f, 0x23}, + {0xc4, 0x1f, 0xee, 0x35, 0xc1, 0x43, 0xa8, 0x96, 0xcf, 0xc8, 0xe4, + 0x8, 0x55, 0xb3, 0x6e, 0x97, 0x30, 0xd3, 0x8c, 0xb5, 0x1, 0x68, + 0x2f, 0xb4, 0x2b, 0x5, 0x3a, 0x69, 0x78, 0x9b, 0xee, 0x48}, + {0xc6, 0xf3, 0x2a, 0xcc, 0x4b, 0xde, 0x31, 0x5c, 0x1f, 0x8d, 0x20, + 0xfe, 0x30, 0xb0, 0x4b, 0xb0, 0x66, 0xb4, 0x4f, 0xc1, 0x9, 0x70, + 0x8d, 0xb7, 0x13, 0x24, 0x79, 0x8, 0x9b, 0xfa, 0x9b, 0x7}, + }, + { + {0x45, 0x42, 0xd5, 0xa2, 0x80, 0xed, 0xc9, 0xf3, 0x52, 0x39, 0xf6, + 0x77, 0x78, 0x8b, 0xa0, 0xa, 0x75, 0x54, 0x8, 0xd1, 0x63, 0xac, + 0x6d, 0xd7, 0x6b, 0x63, 0x70, 0x94, 0x15, 0xfb, 0xf4, 0x1e}, + {0xf4, 0xd, 0x30, 0xda, 0x51, 0x3a, 0x90, 0xe3, 0xb0, 0x5a, 0xa9, + 0x3d, 0x23, 0x64, 0x39, 0x84, 0x80, 0x64, 0x35, 0xb, 0x2d, 0xf1, + 0x3c, 0xed, 0x94, 0x71, 0x81, 0x84, 0xf6, 0x77, 0x8c, 0x3}, + {0xec, 0x7b, 0x16, 0x5b, 0xe6, 0x5e, 0x4e, 0x85, 0xc2, 0xcd, 0xd0, + 0x96, 0x42, 0xa, 0x59, 0x59, 0x99, 0x21, 0x10, 0x98, 0x34, 0xdf, + 0xb2, 0x72, 0x56, 0xff, 0xb, 0x4a, 0x2a, 0xe9, 0x5e, 0x57}, + }, + { + {0x1, 0xd8, 0xa4, 0xa, 0x45, 0xbc, 0x46, 0x5d, 0xd8, 0xb9, 0x33, + 0xa5, 0x27, 0x12, 0xaf, 0xc3, 0xc2, 0x6, 0x89, 0x2b, 0x26, 0x3b, + 0x9e, 0x38, 0x1b, 0x58, 0x2f, 0x38, 0x7e, 0x1e, 0xa, 0x20}, + {0xcf, 0x2f, 0x18, 0x8a, 0x90, 0x80, 0xc0, 0xd4, 0xbd, 0x9d, 0x48, + 0x99, 0xc2, 0x70, 0xe1, 0x30, 0xde, 0x33, 0xf7, 0x52, 0x57, 0xbd, + 0xba, 0x5, 0x0, 0xfd, 0xd3, 0x2c, 0x11, 0xe7, 0xd4, 0x43}, + {0xc5, 0x3a, 0xf9, 0xea, 0x67, 0xb9, 0x8d, 0x51, 0xc0, 0x52, 0x66, + 0x5, 0x9b, 0x98, 0xbc, 0x71, 0xf5, 0x97, 0x71, 0x56, 0xd9, 0x85, + 0x2b, 0xfe, 0x38, 0x4e, 0x1e, 0x65, 0x52, 0xca, 0xe, 0x5}, + }, + { + {0xea, 0x68, 0xe6, 0x60, 0x76, 0x39, 0xac, 0x97, 0x97, 0xb4, 0x3a, + 0x15, 0xfe, 0xbb, 0x19, 0x9b, 0x9f, 0xa7, 0xec, 0x34, 0xb5, 0x79, + 0xb1, 0x4c, 0x57, 0xae, 0x31, 0xa1, 0x9f, 0xc0, 0x51, 0x61}, + {0x9c, 0xc, 0x3f, 0x45, 0xde, 0x1a, 0x43, 0xc3, 0x9b, 0x3b, 0x70, + 0xff, 0x5e, 0x4, 0xf5, 0xe9, 0x3d, 0x7b, 0x84, 0xed, 0xc9, 0x7a, + 0xd9, 0xfc, 0xc6, 0xf4, 0x58, 0x1c, 0xc2, 0xe6, 0xe, 0x4b}, + {0x96, 0x5d, 0xf0, 0xfd, 0xd, 0x5c, 0xf5, 0x3a, 0x7a, 0xee, 0xb4, + 0x2a, 0xe0, 0x2e, 0x26, 0xdd, 0x9, 0x17, 0x17, 0x12, 0x87, 0xbb, + 0xb2, 0x11, 0xb, 0x3, 0xf, 0x80, 0xfa, 0x24, 0xef, 0x1f}, + }, + }, + { + { + {0x86, 0x6b, 0x97, 0x30, 0xf5, 0xaf, 0xd2, 0x22, 0x4, 0x46, 0xd2, + 0xc2, 0x6, 0xb8, 0x90, 0x8d, 0xe5, 0xba, 0xe5, 0x4d, 0x6c, 0x89, + 0xa1, 0xdc, 0x17, 0xc, 0x34, 0xc8, 0xe6, 0x5f, 0x0, 0x28}, + {0x96, 0x31, 0xa7, 0x1a, 0xfb, 0x53, 0xd6, 0x37, 0x18, 0x64, 0xd7, + 0x3f, 0x30, 0x95, 0x94, 0xf, 0xb2, 0x17, 0x3a, 0xfb, 0x9, 0xb, + 0x20, 0xad, 0x3e, 0x61, 0xc8, 0x2f, 0x29, 0x49, 0x4d, 0x54}, + {0x88, 0x86, 0x52, 0x34, 0x9f, 0xba, 0xef, 0x6a, 0xa1, 0x7d, 0x10, + 0x25, 0x94, 0xff, 0x1b, 0x5c, 0x36, 0x4b, 0xd9, 0x66, 0xcd, 0xbb, + 0x5b, 0xf7, 0xfa, 0x6d, 0x31, 0xf, 0x93, 0x72, 0xe4, 0x72}, + }, + { + {0x27, 0x76, 0x2a, 0xd3, 0x35, 0xf6, 0xf3, 0x7, 0xf0, 0x66, 0x65, + 0x5f, 0x86, 0x4d, 0xaa, 0x7a, 0x50, 0x44, 0xd0, 0x28, 0x97, 0xe7, + 0x85, 0x3c, 0x38, 0x64, 0xe0, 0xf, 0x0, 0x7f, 0xee, 0x1f}, + {0x4f, 0x8, 0x81, 0x97, 0x8c, 0x20, 0x95, 0x26, 0xe1, 0xe, 0x45, + 0x23, 0xb, 0x2a, 0x50, 0xb1, 0x2, 0xde, 0xef, 0x3, 0xa6, 0xae, + 0x9d, 0xfd, 0x4c, 0xa3, 0x33, 0x27, 0x8c, 0x2e, 0x9d, 0x5a}, + {0xe5, 0xf7, 0xdb, 0x3, 0xda, 0x5, 0x53, 0x76, 0xbd, 0xcd, 0x34, + 0x14, 0x49, 0xf2, 0xda, 0xa4, 0xec, 0x88, 0x4a, 0xd2, 0xcd, 0xd5, + 0x4a, 0x7b, 0x43, 0x5, 0x4, 0xee, 0x51, 0x40, 0xf9, 0x0}, + }, + { + {0x53, 0x97, 0xaf, 0x7, 0xbb, 0x93, 0xef, 0xd7, 0xa7, 0x66, 0xb7, + 0x3d, 0xcf, 0xd0, 0x3e, 0x58, 0xc5, 0x1e, 0xb, 0x6e, 0xbf, 0x98, + 0x69, 0xce, 0x52, 0x4, 0xd4, 0x5d, 0xd2, 0xff, 0xb7, 0x47}, + {0xb2, 0x30, 0xd3, 0xc3, 0x23, 0x6b, 0x35, 0x8d, 0x6, 0x1b, 0x47, + 0xb0, 0x9b, 0x8b, 0x1c, 0xf2, 0x3c, 0xb8, 0x42, 0x6e, 0x6c, 0x31, + 0x6c, 0xb3, 0xd, 0xb1, 0xea, 0x8b, 0x7e, 0x9c, 0xd7, 0x7}, + {0x12, 0xdd, 0x8, 0xbc, 0x9c, 0xfb, 0xfb, 0x87, 0x9b, 0xc2, 0xee, + 0xe1, 0x3a, 0x6b, 0x6, 0x8a, 0xbf, 0xc1, 0x1f, 0xdb, 0x2b, 0x24, + 0x57, 0xd, 0xb6, 0x4b, 0xa6, 0x5e, 0xa3, 0x20, 0x35, 0x1c}, + }, + { + {0x59, 0xc0, 0x6b, 0x21, 0x40, 0x6f, 0xa8, 0xcd, 0x7e, 0xd8, 0xbc, + 0x12, 0x1d, 0x23, 0xbb, 0x1f, 0x90, 0x9, 0xc7, 0x17, 0x9e, 0x6a, + 0x95, 0xb4, 0x55, 0x2e, 0xd1, 0x66, 0x3b, 0xc, 0x75, 0x38}, + {0x4a, 0xa3, 0xcb, 0xbc, 0xa6, 0x53, 0xd2, 0x80, 0x9b, 0x21, 0x38, + 0x38, 0xa1, 0xc3, 0x61, 0x3e, 0x96, 0xe3, 0x82, 0x98, 0x1, 0xb6, + 0xc3, 0x90, 0x6f, 0xe6, 0xe, 0x5d, 0x77, 0x5, 0x3d, 0x1c}, + {0x1a, 0xe5, 0x22, 0x94, 0x40, 0xf1, 0x2e, 0x69, 0x71, 0xf6, 0x5d, + 0x2b, 0x3c, 0xc7, 0xc0, 0xcb, 0x29, 0xe0, 0x4c, 0x74, 0xe7, 0x4f, + 0x1, 0x21, 0x7c, 0x48, 0x30, 0xd3, 0xc7, 0xe2, 0x21, 0x6}, + }, + { + {0xf3, 0xf0, 0xdb, 0xb0, 0x96, 0x17, 0xae, 0xb7, 0x96, 0xe1, 0x7c, + 0xe1, 0xb9, 0xaf, 0xdf, 0x54, 0xb4, 0xa3, 0xaa, 0xe9, 0x71, 0x30, + 0x92, 0x25, 0x9d, 0x2e, 0x0, 0xa1, 0x9c, 0x58, 0x8e, 0x5d}, + {0x8d, 0x83, 0x59, 0x82, 0xcc, 0x60, 0x98, 0xaf, 0xdc, 0x9a, 0x9f, + 0xc6, 0xc1, 0x48, 0xea, 0x90, 0x30, 0x1e, 0x58, 0x65, 0x37, 0x48, + 0x26, 0x65, 0xbc, 0xa5, 0xd3, 0x7b, 0x9, 0xd6, 0x7, 0x0}, + {0x4b, 0xa9, 0x42, 0x8, 0x95, 0x1d, 0xbf, 0xc0, 0x3e, 0x2e, 0x8f, + 0x58, 0x63, 0xc3, 0xd3, 0xb2, 0xef, 0xe2, 0x51, 0xbb, 0x38, 0x14, + 0x96, 0xa, 0x86, 0xbf, 0x1c, 0x3c, 0x78, 0xd7, 0x83, 0x15}, + }, + { + {0xc7, 0x28, 0x9d, 0xcc, 0x4, 0x47, 0x3, 0x90, 0x8f, 0xc5, 0x2c, + 0xf7, 0x9e, 0x67, 0x1b, 0x1d, 0x26, 0x87, 0x5b, 0xbe, 0x5f, 0x2b, + 0xe1, 0x16, 0xa, 0x58, 0xc5, 0x83, 0x4e, 0x6, 0x58, 0x49}, + {0xe1, 0x7a, 0xa2, 0x5d, 0xef, 0xa2, 0xee, 0xec, 0x74, 0x1, 0x67, + 0x55, 0x14, 0x3a, 0x7c, 0x59, 0x7a, 0x16, 0x9, 0x66, 0x12, 0x2a, + 0xa6, 0xc9, 0x70, 0x8f, 0xed, 0x81, 0x2e, 0x5f, 0x2a, 0x25}, + {0xd, 0xe8, 0x66, 0x50, 0x26, 0x94, 0x28, 0xd, 0x6b, 0x8c, 0x7c, + 0x30, 0x85, 0xf7, 0xc3, 0xfc, 0xfd, 0x12, 0x11, 0xc, 0x78, 0xda, + 0x53, 0x1b, 0x88, 0xb3, 0x43, 0xd8, 0xb, 0x17, 0x9c, 0x7}, + }, + { + {0x56, 0xd0, 0xd5, 0xc0, 0x50, 0xcd, 0xd6, 0xcd, 0x3b, 0x57, 0x3, + 0xbb, 0x6d, 0x68, 0xf7, 0x9a, 0x48, 0xef, 0xc3, 0xf3, 0x3f, 0x72, + 0xa6, 0x3c, 0xcc, 0x8a, 0x7b, 0x31, 0xd7, 0xc0, 0x68, 0x67}, + {0xff, 0x6f, 0xfa, 0x64, 0xe4, 0xec, 0x6, 0x5, 0x23, 0xe5, 0x5, + 0x62, 0x1e, 0x43, 0xe3, 0xbe, 0x42, 0xea, 0xb8, 0x51, 0x24, 0x42, + 0x79, 0x35, 0x0, 0xfb, 0xc9, 0x4a, 0xe3, 0x5, 0xec, 0x6d}, + {0xb3, 0xc1, 0x55, 0xf1, 0xe5, 0x25, 0xb6, 0x94, 0x91, 0x7b, 0x7b, + 0x99, 0xa7, 0xf3, 0x7b, 0x41, 0x0, 0x26, 0x6b, 0x6d, 0xdc, 0xbd, + 0x2c, 0xc2, 0xf4, 0x52, 0xcd, 0xdd, 0x14, 0x5e, 0x44, 0x51}, + }, + { + {0x55, 0xa4, 0xbe, 0x2b, 0xab, 0x47, 0x31, 0x89, 0x29, 0x91, 0x7, + 0x92, 0x4f, 0xa2, 0x53, 0x8c, 0xa7, 0xf7, 0x30, 0xbe, 0x48, 0xf9, + 0x49, 0x4b, 0x3d, 0xd4, 0x4f, 0x6e, 0x8, 0x90, 0xe9, 0x12}, + {0x51, 0x49, 0x14, 0x3b, 0x4b, 0x2b, 0x50, 0x57, 0xb3, 0xbc, 0x4b, + 0x44, 0x6b, 0xff, 0x67, 0x8e, 0xdb, 0x85, 0x63, 0x16, 0x27, 0x69, + 0xbd, 0xb8, 0xc8, 0x95, 0x92, 0xe3, 0x31, 0x6f, 0x18, 0x13}, + {0x2e, 0xbb, 0xdf, 0x7f, 0xb3, 0x96, 0xc, 0xf1, 0xf9, 0xea, 0x1c, + 0x12, 0x5e, 0x93, 0x9a, 0x9f, 0x3f, 0x98, 0x5b, 0x3a, 0xc4, 0x36, + 0x11, 0xdf, 0xaf, 0x99, 0x3e, 0x5d, 0xf0, 0xe3, 0xb2, 0x77}, + }, + }, + { + { + {0xa4, 0xb0, 0xdd, 0x12, 0x9c, 0x63, 0x98, 0xd5, 0x6b, 0x86, 0x24, + 0xc0, 0x30, 0x9f, 0xd1, 0xa5, 0x60, 0xe4, 0xfc, 0x58, 0x3, 0x2f, + 0x7c, 0xd1, 0x8a, 0x5e, 0x9, 0x2e, 0x15, 0x95, 0xa1, 0x7}, + {0xde, 0xc4, 0x2e, 0x9c, 0xc5, 0xa9, 0x6f, 0x29, 0xcb, 0xf3, 0x84, + 0x4f, 0xbf, 0x61, 0x8b, 0xbc, 0x8, 0xf9, 0xa8, 0x17, 0xd9, 0x6, + 0x77, 0x1c, 0x5d, 0x25, 0xd3, 0x7a, 0xfc, 0x95, 0xb7, 0x63}, + {0xc8, 0x5f, 0x9e, 0x38, 0x2, 0x8f, 0x36, 0xa8, 0x3b, 0xe4, 0x8d, + 0xcf, 0x2, 0x3b, 0x43, 0x90, 0x43, 0x26, 0x41, 0xc5, 0x5d, 0xfd, + 0xa1, 0xaf, 0x37, 0x1, 0x2f, 0x3, 0x3d, 0xe8, 0x8f, 0x3e}, + }, + { + {0x3c, 0xd1, 0xef, 0xe8, 0x8d, 0x4c, 0x70, 0x8, 0x31, 0x37, 0xe0, + 0x33, 0x8e, 0x1a, 0xc5, 0xdf, 0xe3, 0xcd, 0x60, 0x12, 0xa5, 0x5d, + 0x9d, 0xa5, 0x86, 0x8c, 0x25, 0xa6, 0x99, 0x8, 0xd6, 0x22}, + {0x94, 0xa2, 0x70, 0x5, 0xb9, 0x15, 0x8b, 0x2f, 0x49, 0x45, 0x8, + 0x67, 0x70, 0x42, 0xf2, 0x94, 0x84, 0xfd, 0xbb, 0x61, 0xe1, 0x5a, + 0x1c, 0xde, 0x7, 0x40, 0xac, 0x7f, 0x79, 0x3b, 0xba, 0x75}, + {0x96, 0xd1, 0xcd, 0x70, 0xc0, 0xdb, 0x39, 0x62, 0x9a, 0x8a, 0x7d, + 0x6c, 0x8b, 0x8a, 0xfe, 0x60, 0x60, 0x12, 0x40, 0xeb, 0xbc, 0x47, + 0x88, 0xb3, 0x5e, 0x9e, 0x77, 0x87, 0x7b, 0xd0, 0x4, 0x9}, + }, + { + {0xb9, 0x40, 0xf9, 0x48, 0x66, 0x2d, 0x32, 0xf4, 0x39, 0xc, 0x2d, + 0xbd, 0xc, 0x2f, 0x95, 0x6, 0x31, 0xf9, 0x81, 0xa0, 0xad, 0x97, + 0x76, 0x16, 0x6c, 0x2a, 0xf7, 0xba, 0xce, 0xaa, 0x40, 0x62}, + {0x9c, 0x91, 0xba, 0xdd, 0xd4, 0x1f, 0xce, 0xb4, 0xaa, 0x8d, 0x4c, + 0xc7, 0x3e, 0xdb, 0x31, 0xcf, 0x51, 0xcc, 0x86, 0xad, 0x63, 0xcc, + 0x63, 0x2c, 0x7, 0xde, 0x1d, 0xbc, 0x3f, 0x14, 0xe2, 0x43}, + {0xa0, 0x95, 0xa2, 0x5b, 0x9c, 0x74, 0x34, 0xf8, 0x5a, 0xd2, 0x37, + 0xca, 0x5b, 0x7c, 0x94, 0xd6, 0x6a, 0x31, 0xc9, 0xe7, 0xa7, 0x3b, + 0xf1, 0x66, 0xac, 0xc, 0xb4, 0x8d, 0x23, 0xaf, 0xbd, 0x56}, + }, + { + {0xb2, 0x3b, 0x9d, 0xc1, 0x6c, 0xd3, 0x10, 0x13, 0xb9, 0x86, 0x23, + 0x62, 0xb7, 0x6b, 0x2a, 0x6, 0x5c, 0x4f, 0xa1, 0xd7, 0x91, 0x85, + 0x9b, 0x7c, 0x54, 0x57, 0x1e, 0x7e, 0x50, 0x31, 0xaa, 0x3}, + {0xeb, 0x33, 0x35, 0xf5, 0xe3, 0xb9, 0x2a, 0x36, 0x40, 0x3d, 0xb9, + 0x6e, 0xd5, 0x68, 0x85, 0x33, 0x72, 0x55, 0x5a, 0x1d, 0x52, 0x14, + 0xe, 0x9e, 0x18, 0x13, 0x74, 0x83, 0x6d, 0xa8, 0x24, 0x1d}, + {0x1f, 0xce, 0xd4, 0xff, 0x48, 0x76, 0xec, 0xf4, 0x1c, 0x8c, 0xac, + 0x54, 0xf0, 0xea, 0x45, 0xe0, 0x7c, 0x35, 0x9, 0x1d, 0x82, 0x25, + 0xd2, 0x88, 0x59, 0x48, 0xeb, 0x9a, 0xdc, 0x61, 0xb2, 0x43}, + }, + { + {0x64, 0x13, 0x95, 0x6c, 0x8b, 0x3d, 0x51, 0x19, 0x7b, 0xf4, 0xb, + 0x0, 0x26, 0x71, 0xfe, 0x94, 0x67, 0x95, 0x4f, 0xd5, 0xdd, 0x10, + 0x8d, 0x2, 0x64, 0x9, 0x94, 0x42, 0xe2, 0xd5, 0xb4, 0x2}, + {0xbb, 0x79, 0xbb, 0x88, 0x19, 0x1e, 0x5b, 0xe5, 0x9d, 0x35, 0x7a, + 0xc1, 0x7d, 0xd0, 0x9e, 0xa0, 0x33, 0xea, 0x3d, 0x60, 0xe2, 0x2e, + 0x2c, 0xb0, 0xc2, 0x6b, 0x27, 0x5b, 0xcf, 0x55, 0x60, 0x32}, + {0xf2, 0x8d, 0xd1, 0x28, 0xcb, 0x55, 0xa1, 0xb4, 0x8, 0xe5, 0x6c, + 0x18, 0x46, 0x46, 0xcc, 0xea, 0x89, 0x43, 0x82, 0x6c, 0x93, 0xf4, + 0x9c, 0xc4, 0x10, 0x34, 0x5d, 0xae, 0x9, 0xc8, 0xa6, 0x27}, + }, + { + {0x54, 0x69, 0x3d, 0xc4, 0xa, 0x27, 0x2c, 0xcd, 0xb2, 0xca, 0x66, + 0x6a, 0x57, 0x3e, 0x4a, 0xdd, 0x6c, 0x3, 0xd7, 0x69, 0x24, 0x59, + 0xfa, 0x79, 0x99, 0x25, 0x8c, 0x3d, 0x60, 0x3, 0x15, 0x22}, + {0x88, 0xb1, 0xd, 0x1f, 0xcd, 0xeb, 0xa6, 0x8b, 0xe8, 0x5b, 0x5a, + 0x67, 0x3a, 0xd7, 0xd3, 0x37, 0x5a, 0x58, 0xf5, 0x15, 0xa3, 0xdf, + 0x2e, 0xf2, 0x7e, 0xa1, 0x60, 0xff, 0x74, 0x71, 0xb6, 0x2c}, + {0xd0, 0xe1, 0xb, 0x39, 0xf9, 0xcd, 0xee, 0x59, 0xf1, 0xe3, 0x8c, + 0x72, 0x44, 0x20, 0x42, 0xa9, 0xf4, 0xf0, 0x94, 0x7a, 0x66, 0x1c, + 0x89, 0x82, 0x36, 0xf4, 0x90, 0x38, 0xb7, 0xf4, 0x1d, 0x7b}, + }, + { + {0x8c, 0xf5, 0xf8, 0x7, 0x18, 0x22, 0x2e, 0x5f, 0xd4, 0x9, 0x94, + 0xd4, 0x9f, 0x5c, 0x55, 0xe3, 0x30, 0xa6, 0xb6, 0x1f, 0x8d, 0xa8, + 0xaa, 0xb2, 0x3d, 0xe0, 0x52, 0xd3, 0x45, 0x82, 0x69, 0x68}, + {0x24, 0xa2, 0xb2, 0xb3, 0xe0, 0xf2, 0x92, 0xe4, 0x60, 0x11, 0x55, + 0x2b, 0x6, 0x9e, 0x6c, 0x7c, 0xe, 0x7b, 0x7f, 0xd, 0xe2, 0x8f, + 0xeb, 0x15, 0x92, 0x59, 0xfc, 0x58, 0x26, 0xef, 0xfc, 0x61}, + {0x7a, 0x18, 0x18, 0x2a, 0x85, 0x5d, 0xb1, 0xdb, 0xd7, 0xac, 0xdd, + 0x86, 0xd3, 0xaa, 0xe4, 0xf3, 0x82, 0xc4, 0xf6, 0xf, 0x81, 0xe2, + 0xba, 0x44, 0xcf, 0x1, 0xaf, 0x3d, 0x47, 0x4c, 0xcf, 0x46}, + }, + { + {0x40, 0x81, 0x49, 0xf1, 0xa7, 0x6e, 0x3c, 0x21, 0x54, 0x48, 0x2b, + 0x39, 0xf8, 0x7e, 0x1e, 0x7c, 0xba, 0xce, 0x29, 0x56, 0x8c, 0xc3, + 0x88, 0x24, 0xbb, 0xc5, 0x8c, 0xd, 0xe5, 0xaa, 0x65, 0x10}, + {0xf9, 0xe5, 0xc4, 0x9e, 0xed, 0x25, 0x65, 0x42, 0x3, 0x33, 0x90, + 0x16, 0x1, 0xda, 0x5e, 0xe, 0xdc, 0xca, 0xe5, 0xcb, 0xf2, 0xa7, + 0xb1, 0x72, 0x40, 0x5f, 0xeb, 0x14, 0xcd, 0x7b, 0x38, 0x29}, + {0x57, 0xd, 0x20, 0xdf, 0x25, 0x45, 0x2c, 0x1c, 0x4a, 0x67, 0xca, + 0xbf, 0xd6, 0x2d, 0x3b, 0x5c, 0x30, 0x40, 0x83, 0xe1, 0xb1, 0xe7, + 0x7, 0xa, 0x16, 0xe7, 0x1c, 0x4f, 0xe6, 0x98, 0xa1, 0x69}, + }, + }, + { + { + {0xed, 0xca, 0xc5, 0xdc, 0x34, 0x44, 0x1, 0xe1, 0x33, 0xfb, 0x84, + 0x3c, 0x96, 0x5d, 0xed, 0x47, 0xe7, 0xa0, 0x86, 0xed, 0x76, 0x95, + 0x1, 0x70, 0xe4, 0xf9, 0x67, 0xd2, 0x7b, 0x69, 0xb2, 0x25}, + {0xbc, 0x78, 0x1a, 0xd9, 0xe0, 0xb2, 0x62, 0x90, 0x67, 0x96, 0x50, + 0xc8, 0x9c, 0x88, 0xc9, 0x47, 0xb8, 0x70, 0x50, 0x40, 0x66, 0x4a, + 0xf5, 0x9d, 0xbf, 0xa1, 0x93, 0x24, 0xa9, 0xe6, 0x69, 0x73}, + {0x64, 0x68, 0x98, 0x13, 0xfb, 0x3f, 0x67, 0x9d, 0xb8, 0xc7, 0x5d, + 0x41, 0xd9, 0xfb, 0xa5, 0x3c, 0x5e, 0x3b, 0x27, 0xdf, 0x3b, 0xcc, + 0x4e, 0xe0, 0xd2, 0x4c, 0x4e, 0xb5, 0x3d, 0x68, 0x20, 0x14}, + }, + { + {0xd0, 0x5a, 0xcc, 0xc1, 0x6f, 0xbb, 0xee, 0x34, 0x8b, 0xac, 0x46, + 0x96, 0xe9, 0xc, 0x1b, 0x6a, 0x53, 0xde, 0x6b, 0xa6, 0x49, 0xda, + 0xb0, 0xd3, 0xc1, 0x81, 0xd0, 0x61, 0x41, 0x3b, 0xe8, 0x31}, + {0x97, 0xd1, 0x9d, 0x24, 0x1e, 0xbd, 0x78, 0xb4, 0x2, 0xc1, 0x58, + 0x5e, 0x0, 0x35, 0xc, 0x62, 0x5c, 0xac, 0xba, 0xcc, 0x2f, 0xd3, + 0x2, 0xfb, 0x2d, 0xa7, 0x8, 0xf5, 0xeb, 0x3b, 0xb6, 0x60}, + {0x4f, 0x2b, 0x6, 0x9e, 0x12, 0xc7, 0xe8, 0x97, 0xd8, 0xa, 0x32, + 0x29, 0x4f, 0x8f, 0xe4, 0x49, 0x3f, 0x68, 0x18, 0x6f, 0x4b, 0xe1, + 0xec, 0x5b, 0x17, 0x3, 0x55, 0x2d, 0xb6, 0x1e, 0xcf, 0x55}, + }, + { + {0x52, 0x8c, 0xf5, 0x7d, 0xe3, 0xb5, 0x76, 0x30, 0x36, 0xcc, 0x99, + 0xe7, 0xdd, 0xb9, 0x3a, 0xd7, 0x20, 0xee, 0x13, 0x49, 0xe3, 0x1c, + 0x83, 0xbd, 0x33, 0x1, 0xba, 0x62, 0xaa, 0xfb, 0x56, 0x1a}, + {0x58, 0x3d, 0xc2, 0x65, 0x10, 0x10, 0x79, 0x58, 0x9c, 0x81, 0x94, + 0x50, 0x6d, 0x8, 0x9d, 0x8b, 0xa7, 0x5f, 0xc5, 0x12, 0xa9, 0x2f, + 0x40, 0xe2, 0xd4, 0x91, 0x8, 0x57, 0x64, 0x65, 0x9a, 0x66}, + {0xec, 0xc9, 0x9d, 0x5c, 0x50, 0x6b, 0x3e, 0x94, 0x1a, 0x37, 0x7c, + 0xa7, 0xbb, 0x57, 0x25, 0x30, 0x51, 0x76, 0x34, 0x41, 0x56, 0xae, + 0x73, 0x98, 0x5c, 0x8a, 0xc5, 0x99, 0x67, 0x83, 0xc4, 0x13}, + }, + { + {0x80, 0xd0, 0x8b, 0x5d, 0x6a, 0xfb, 0xdc, 0xc4, 0x42, 0x48, 0x1a, + 0x57, 0xec, 0xc4, 0xeb, 0xde, 0x65, 0x53, 0xe5, 0xb8, 0x83, 0xe8, + 0xb2, 0xd4, 0x27, 0xb8, 0xe5, 0xc8, 0x7d, 0xc8, 0xbd, 0x50}, + {0xb9, 0xe1, 0xb3, 0x5a, 0x46, 0x5d, 0x3a, 0x42, 0x61, 0x3f, 0xf1, + 0xc7, 0x87, 0xc1, 0x13, 0xfc, 0xb6, 0xb9, 0xb5, 0xec, 0x64, 0x36, + 0xf8, 0x19, 0x7, 0xb6, 0x37, 0xa6, 0x93, 0xc, 0xf8, 0x66}, + {0x11, 0xe1, 0xdf, 0x6e, 0x83, 0x37, 0x6d, 0x60, 0xd9, 0xab, 0x11, + 0xf0, 0x15, 0x3e, 0x35, 0x32, 0x96, 0x3b, 0xb7, 0x25, 0xc3, 0x3a, + 0xb0, 0x64, 0xae, 0xd5, 0x5f, 0x72, 0x44, 0x64, 0xd5, 0x1d}, + }, + { + {0x9a, 0xc8, 0xba, 0x8, 0x0, 0xe6, 0x97, 0xc2, 0xe0, 0xc3, 0xe1, + 0xea, 0x11, 0xea, 0x4c, 0x7d, 0x7c, 0x97, 0xe7, 0x9f, 0xe1, 0x8b, + 0xe3, 0xf3, 0xcd, 0x5, 0xa3, 0x63, 0xf, 0x45, 0x3a, 0x3a}, + {0x7d, 0x12, 0x62, 0x33, 0xf8, 0x7f, 0xa4, 0x8f, 0x15, 0x7c, 0xcd, + 0x71, 0xc4, 0x6a, 0x9f, 0xbc, 0x8b, 0xc, 0x22, 0x49, 0x43, 0x45, + 0x71, 0x6e, 0x2e, 0x73, 0x9f, 0x21, 0x12, 0x59, 0x64, 0xe}, + {0x27, 0x46, 0x39, 0xd8, 0x31, 0x2f, 0x8f, 0x7, 0x10, 0xa5, 0x94, + 0xde, 0x83, 0x31, 0x9d, 0x38, 0x80, 0x6f, 0x99, 0x17, 0x6d, 0x6c, + 0xe3, 0xd1, 0x7b, 0xa8, 0xa9, 0x93, 0x93, 0x8d, 0x8c, 0x31}, + }, + { + {0x98, 0xd3, 0x1d, 0xab, 0x29, 0x9e, 0x66, 0x5d, 0x3b, 0x9e, 0x2d, + 0x34, 0x58, 0x16, 0x92, 0xfc, 0xcd, 0x73, 0x59, 0xf3, 0xfd, 0x1d, + 0x85, 0x55, 0xf6, 0xa, 0x95, 0x25, 0xc3, 0x41, 0x9a, 0x50}, + {0x19, 0xfe, 0xff, 0x2a, 0x3, 0x5d, 0x74, 0xf2, 0x66, 0xdb, 0x24, + 0x7f, 0x49, 0x3c, 0x9f, 0xc, 0xef, 0x98, 0x85, 0xba, 0xe3, 0xd3, + 0x98, 0xbc, 0x14, 0x53, 0x1d, 0x9a, 0x67, 0x7c, 0x4c, 0x22}, + {0xe9, 0x25, 0xf9, 0xa6, 0xdc, 0x6e, 0xc0, 0xbd, 0x33, 0x1f, 0x1b, + 0x64, 0xf4, 0xf3, 0x3e, 0x79, 0x89, 0x3e, 0x83, 0x9d, 0x80, 0x12, + 0xec, 0x82, 0x89, 0x13, 0xa1, 0x28, 0x23, 0xf0, 0xbf, 0x5}, + }, + { + {0xe4, 0x12, 0xc5, 0xd, 0xdd, 0xa0, 0x81, 0x68, 0xfe, 0xfa, 0xa5, + 0x44, 0xc8, 0xd, 0xe7, 0x4f, 0x40, 0x52, 0x4a, 0x8f, 0x6b, 0x8e, + 0x74, 0x1f, 0xea, 0xa3, 0x1, 0xee, 0xcd, 0x77, 0x62, 0x57}, + {0xb, 0xe0, 0xca, 0x23, 0x70, 0x13, 0x32, 0x36, 0x59, 0xcf, 0xac, + 0xd1, 0xa, 0xcf, 0x4a, 0x54, 0x88, 0x1c, 0x1a, 0xd2, 0x49, 0x10, + 0x74, 0x96, 0xa7, 0x44, 0x2a, 0xfa, 0xc3, 0x8c, 0xb, 0x78}, + {0x5f, 0x30, 0x4f, 0x23, 0xbc, 0x8a, 0xf3, 0x1e, 0x8, 0xde, 0x5, + 0x14, 0xbd, 0x7f, 0x57, 0x9a, 0xd, 0x2a, 0xe6, 0x34, 0x14, 0xa5, + 0x82, 0x5e, 0xa1, 0xb7, 0x71, 0x62, 0x72, 0x18, 0xf4, 0x5f}, + }, + { + {0x40, 0x95, 0xb6, 0x13, 0xe8, 0x47, 0xdb, 0xe5, 0xe1, 0x10, 0x26, + 0x43, 0x3b, 0x2a, 0x5d, 0xf3, 0x76, 0x12, 0x78, 0x38, 0xe9, 0x26, + 0x1f, 0xac, 0x69, 0xcb, 0xa0, 0xa0, 0x8c, 0xdb, 0xd4, 0x29}, + {0x9d, 0xdb, 0x89, 0x17, 0xc, 0x8, 0x8e, 0x39, 0xf5, 0x78, 0xe7, + 0xf3, 0x25, 0x20, 0x60, 0xa7, 0x5d, 0x3, 0xbd, 0x6, 0x4c, 0x89, + 0x98, 0xfa, 0xbe, 0x66, 0xa9, 0x25, 0xdc, 0x3, 0x6a, 0x10}, + {0xd0, 0x53, 0x33, 0x33, 0xaf, 0xa, 0xad, 0xd9, 0xe5, 0x9, 0xd3, + 0xac, 0xa5, 0x9d, 0x66, 0x38, 0xf0, 0xf7, 0x88, 0xc8, 0x8a, 0x65, + 0x57, 0x3c, 0xfa, 0xbe, 0x2c, 0x5, 0x51, 0x8a, 0xb3, 0x4a}, + }, + }, + { + { + {0x9c, 0xc0, 0xdd, 0x5f, 0xef, 0xd1, 0xcf, 0xd6, 0xce, 0x5d, 0x57, + 0xf7, 0xfd, 0x3e, 0x2b, 0xe8, 0xc2, 0x34, 0x16, 0x20, 0x5d, 0x6b, + 0xd5, 0x25, 0x9b, 0x2b, 0xed, 0x4, 0xbb, 0xc6, 0x41, 0x30}, + {0x93, 0xd5, 0x68, 0x67, 0x25, 0x2b, 0x7c, 0xda, 0x13, 0xca, 0x22, + 0x44, 0x57, 0xc0, 0xc1, 0x98, 0x1d, 0xce, 0xa, 0xca, 0xd5, 0xb, + 0xa8, 0xf1, 0x90, 0xa6, 0x88, 0xc0, 0xad, 0xd1, 0xcd, 0x29}, + {0x48, 0xe1, 0x56, 0xd9, 0xf9, 0xf2, 0xf2, 0xf, 0x2e, 0x6b, 0x35, + 0x9f, 0x75, 0x97, 0xe7, 0xad, 0x5c, 0x2, 0x6c, 0x5f, 0xbb, 0x98, + 0x46, 0x1a, 0x7b, 0x9a, 0x4, 0x14, 0x68, 0xbd, 0x4b, 0x10}, + }, + { + {0x63, 0xf1, 0x7f, 0xd6, 0x5f, 0x9a, 0x5d, 0xa9, 0x81, 0x56, 0xc7, + 0x4c, 0x9d, 0xe6, 0x2b, 0xe9, 0x57, 0xf2, 0x20, 0xde, 0x4c, 0x2, + 0xf8, 0xb7, 0xf5, 0x2d, 0x7, 0xfb, 0x20, 0x2a, 0x4f, 0x20}, + {0x67, 0xed, 0xf1, 0x68, 0x31, 0xfd, 0xf0, 0x51, 0xc2, 0x3b, 0x6f, + 0xd8, 0xcd, 0x1d, 0x81, 0x2c, 0xde, 0xf2, 0xd2, 0x4, 0x43, 0x5c, + 0xdc, 0x44, 0x49, 0x71, 0x2a, 0x9, 0x57, 0xcc, 0xe8, 0x5b}, + {0x79, 0xb0, 0xeb, 0x30, 0x3d, 0x3b, 0x14, 0xc8, 0x30, 0x2e, 0x65, + 0xbd, 0x5a, 0x15, 0x89, 0x75, 0x31, 0x5c, 0x6d, 0x8f, 0x31, 0x3c, + 0x3c, 0x65, 0x1f, 0x16, 0x79, 0xc2, 0x17, 0xfb, 0x70, 0x25}, + }, + { + {0x5a, 0x24, 0xb8, 0xb, 0x55, 0xa9, 0x2e, 0x19, 0xd1, 0x50, 0x90, + 0x8f, 0xa8, 0xfb, 0xe6, 0xc8, 0x35, 0xc9, 0xa4, 0x88, 0x2d, 0xea, + 0x86, 0x79, 0x68, 0x86, 0x1, 0xde, 0x91, 0x5f, 0x1c, 0x24}, + {0x75, 0x15, 0xb6, 0x2c, 0x7f, 0x36, 0xfa, 0x3e, 0x6c, 0x2, 0xd6, + 0x1c, 0x76, 0x6f, 0xf9, 0xf5, 0x62, 0x25, 0xb5, 0x65, 0x2a, 0x14, + 0xc7, 0xe8, 0xcd, 0xa, 0x3, 0x53, 0xea, 0x65, 0xcb, 0x3d}, + {0xaa, 0x6c, 0xde, 0x40, 0x29, 0x17, 0xd8, 0x28, 0x3a, 0x73, 0xd9, + 0x22, 0xf0, 0x2c, 0xbf, 0x8f, 0xd1, 0x1, 0x5b, 0x23, 0xdd, 0xfc, + 0xd7, 0x16, 0xe5, 0xf0, 0xcd, 0x5f, 0xdd, 0xe, 0x42, 0x8}, + }, + { + {0xce, 0x10, 0xf4, 0x4, 0x4e, 0xc3, 0x58, 0x3, 0x85, 0x6, 0x6e, + 0x27, 0x5a, 0x5b, 0x13, 0xb6, 0x21, 0x15, 0xb9, 0xeb, 0xc7, 0x70, + 0x96, 0x5d, 0x9c, 0x88, 0xdb, 0x21, 0xf3, 0x54, 0xd6, 0x4}, + {0x4a, 0xfa, 0x62, 0x83, 0xab, 0x20, 0xff, 0xcd, 0x6e, 0x3e, 0x1a, + 0xe2, 0xd4, 0x18, 0xe1, 0x57, 0x2b, 0xe6, 0x39, 0xfc, 0x17, 0x96, + 0x17, 0xe3, 0xfd, 0x69, 0x17, 0xbc, 0xef, 0x53, 0x9a, 0xd}, + {0xd5, 0xb5, 0xbd, 0xdd, 0x16, 0xc1, 0x7d, 0x5e, 0x2d, 0xdd, 0xa5, + 0x8d, 0xb6, 0xde, 0x54, 0x29, 0x92, 0xa2, 0x34, 0x33, 0x17, 0x8, + 0xb6, 0x1c, 0xd7, 0x1a, 0x99, 0x18, 0x26, 0x4f, 0x7a, 0x4a}, + }, + { + {0x4b, 0x2a, 0x37, 0xaf, 0x91, 0xb2, 0xc3, 0x24, 0xf2, 0x47, 0x81, + 0x71, 0x70, 0x82, 0xda, 0x93, 0xf2, 0x9e, 0x89, 0x86, 0x64, 0x85, + 0x84, 0xdd, 0x33, 0xee, 0xe0, 0x23, 0x42, 0x31, 0x96, 0x4a}, + {0x95, 0x5f, 0xb1, 0x5f, 0x2, 0x18, 0xa7, 0xf4, 0x8f, 0x1b, 0x5c, + 0x6b, 0x34, 0x5f, 0xf6, 0x3d, 0x12, 0x11, 0xe0, 0x0, 0x85, 0xf0, + 0xfc, 0xcd, 0x48, 0x18, 0xd3, 0xdd, 0x4c, 0xc, 0xb5, 0x11}, + {0xd6, 0xff, 0xa4, 0x8, 0x44, 0x27, 0xe8, 0xa6, 0xd9, 0x76, 0x15, + 0x9c, 0x7e, 0x17, 0x8e, 0x73, 0xf2, 0xb3, 0x2, 0x3d, 0xb6, 0x48, + 0x33, 0x77, 0x51, 0xcc, 0x6b, 0xce, 0x4d, 0xce, 0x4b, 0x4f}, + }, + { + {0x6f, 0xb, 0x9d, 0xc4, 0x6e, 0x61, 0xe2, 0x30, 0x17, 0x23, 0xec, + 0xca, 0x8f, 0x71, 0x56, 0xe4, 0xa6, 0x4f, 0x6b, 0xf2, 0x9b, 0x40, + 0xeb, 0x48, 0x37, 0x5f, 0x59, 0x61, 0xe5, 0xce, 0x42, 0x30}, + {0x84, 0x25, 0x24, 0xe2, 0x5a, 0xce, 0x1f, 0xa7, 0x9e, 0x8a, 0xf5, + 0x92, 0x56, 0x72, 0xea, 0x26, 0xf4, 0x3c, 0xea, 0x1c, 0xd7, 0x9, + 0x1a, 0xd2, 0xe6, 0x1, 0x1c, 0xb7, 0x14, 0xdd, 0xfc, 0x73}, + {0x41, 0xac, 0x9b, 0x44, 0x79, 0x70, 0x7e, 0x42, 0xa, 0x31, 0xe2, + 0xbc, 0x6d, 0xe3, 0x5a, 0x85, 0x7c, 0x1a, 0x84, 0x5f, 0x21, 0x76, + 0xae, 0x4c, 0xd6, 0xe1, 0x9c, 0x9a, 0xc, 0x74, 0x9e, 0x38}, + }, + { + {0x28, 0xac, 0xe, 0x57, 0xf6, 0x78, 0xbd, 0xc9, 0xe1, 0x9c, 0x91, + 0x27, 0x32, 0xb, 0x5b, 0xe5, 0xed, 0x91, 0x9b, 0xa1, 0xab, 0x3e, + 0xfc, 0x65, 0x90, 0x36, 0x26, 0xd6, 0xe5, 0x25, 0xc4, 0x25}, + {0xce, 0xb9, 0xdc, 0x34, 0xae, 0xb3, 0xfc, 0x64, 0xad, 0xd0, 0x48, + 0xe3, 0x23, 0x3, 0x50, 0x97, 0x1b, 0x38, 0xc6, 0x62, 0x7d, 0xf0, + 0xb3, 0x45, 0x88, 0x67, 0x5a, 0x46, 0x79, 0x53, 0x54, 0x61}, + {0x6e, 0xde, 0xd7, 0xf1, 0xa6, 0x6, 0x3e, 0x3f, 0x8, 0x23, 0x6, + 0x8e, 0x27, 0x76, 0xf9, 0x3e, 0x77, 0x6c, 0x8a, 0x4e, 0x26, 0xf6, + 0x14, 0x8c, 0x59, 0x47, 0x48, 0x15, 0x89, 0xa0, 0x39, 0x65}, + }, + { + {0x19, 0x4a, 0xbb, 0x14, 0xd4, 0xdb, 0xc4, 0xdd, 0x8e, 0x4f, 0x42, + 0x98, 0x3c, 0xbc, 0xb2, 0x19, 0x69, 0x71, 0xca, 0x36, 0xd7, 0x9f, + 0xa8, 0x48, 0x90, 0xbd, 0x19, 0xf0, 0xe, 0x32, 0x65, 0xf}, + {0x73, 0xf7, 0xd2, 0xc3, 0x74, 0x1f, 0xd2, 0xe9, 0x45, 0x68, 0xc4, + 0x25, 0x41, 0x54, 0x50, 0xc1, 0x33, 0x9e, 0xb9, 0xf9, 0xe8, 0x5c, + 0x4e, 0x62, 0x6c, 0x18, 0xcd, 0xc5, 0xaa, 0xe4, 0xc5, 0x11}, + {0xc6, 0xe0, 0xfd, 0xca, 0xb1, 0xd1, 0x86, 0xd4, 0x81, 0x51, 0x3b, + 0x16, 0xe3, 0xe6, 0x3f, 0x4f, 0x9a, 0x93, 0xf2, 0xfa, 0xd, 0xaf, + 0xa8, 0x59, 0x2a, 0x7, 0x33, 0xec, 0xbd, 0xc7, 0xab, 0x4c}, + }, + }, + { + { + {0x89, 0xd2, 0x78, 0x3f, 0x8f, 0x78, 0x8f, 0xc0, 0x9f, 0x4d, 0x40, + 0xa1, 0x2c, 0xa7, 0x30, 0xfe, 0x9d, 0xcc, 0x65, 0xcf, 0xfc, 0x8b, + 0x77, 0xf2, 0x21, 0x20, 0xcb, 0x5a, 0x16, 0x98, 0xe4, 0x7e}, + {0x2e, 0xa, 0x9c, 0x8, 0x24, 0x96, 0x9e, 0x23, 0x38, 0x47, 0xfe, + 0x3a, 0xc0, 0xc4, 0x48, 0xc7, 0x2a, 0xa1, 0x4f, 0x76, 0x2a, 0xed, + 0xdb, 0x17, 0x82, 0x85, 0x1c, 0x32, 0xf0, 0x93, 0x9b, 0x63}, + {0xc3, 0xa1, 0x11, 0x91, 0xe3, 0x8, 0xd5, 0x7b, 0x89, 0x74, 0x90, + 0x80, 0xd4, 0x90, 0x2b, 0x2b, 0x19, 0xfd, 0x72, 0xae, 0xc2, 0xae, + 0xd2, 0xe7, 0xa6, 0x2, 0xb6, 0x85, 0x3c, 0x49, 0xdf, 0xe}, + }, + { + {0x13, 0x41, 0x76, 0x84, 0xd2, 0xc4, 0x67, 0x67, 0x35, 0xf8, 0xf5, + 0xf7, 0x3f, 0x40, 0x90, 0xa0, 0xde, 0xbe, 0xe6, 0xca, 0xfa, 0xcf, + 0x8f, 0x1c, 0x69, 0xa3, 0xdf, 0xd1, 0x54, 0xc, 0xc0, 0x4}, + {0x68, 0x5a, 0x9b, 0x59, 0x58, 0x81, 0xcc, 0xae, 0xe, 0xe2, 0xad, + 0xeb, 0xf, 0x4f, 0x57, 0xea, 0x7, 0x7f, 0xb6, 0x22, 0x74, 0x1d, + 0xe4, 0x4f, 0xb4, 0x4f, 0x9d, 0x1, 0xe3, 0x92, 0x3b, 0x40}, + {0xf8, 0x5c, 0x46, 0x8b, 0x81, 0x2f, 0xc2, 0x4d, 0xf8, 0xef, 0x80, + 0x14, 0x5a, 0xf3, 0xa0, 0x71, 0x57, 0xd6, 0xc7, 0x4, 0xad, 0xbf, + 0xe8, 0xae, 0xf4, 0x76, 0x61, 0xb2, 0x2a, 0xb1, 0x5b, 0x35}, + }, + { + {0x18, 0x73, 0x8c, 0x5a, 0xc7, 0xda, 0x1, 0xa3, 0x11, 0xaa, 0xce, + 0xb3, 0x9d, 0x3, 0x90, 0xed, 0x2d, 0x3f, 0xae, 0x3b, 0xbf, 0x7c, + 0x7, 0x6f, 0x8e, 0xad, 0x52, 0xe0, 0xf8, 0xea, 0x18, 0x75}, + {0xf4, 0xbb, 0x93, 0x74, 0xcc, 0x64, 0x1e, 0xa7, 0xc3, 0xb0, 0xa3, + 0xec, 0xd9, 0x84, 0xbd, 0xe5, 0x85, 0xe7, 0x5, 0xfa, 0xc, 0xc5, + 0x6b, 0xa, 0x12, 0xc3, 0x2e, 0x18, 0x32, 0x81, 0x9b, 0xf}, + {0x32, 0x6c, 0x7f, 0x1b, 0xc4, 0x59, 0x88, 0xa4, 0x98, 0x32, 0x38, + 0xf4, 0xbc, 0x60, 0x2d, 0xf, 0xd9, 0xd1, 0xb1, 0xc9, 0x29, 0xa9, + 0x15, 0x18, 0xc4, 0x55, 0x17, 0xbb, 0x1b, 0x87, 0xc3, 0x47}, + }, + { + {0xb0, 0x66, 0x50, 0xc8, 0x50, 0x5d, 0xe6, 0xfb, 0xb0, 0x99, 0xa2, + 0xb3, 0xb0, 0xc4, 0xec, 0x62, 0xe0, 0xe8, 0x1a, 0x44, 0xea, 0x54, + 0x37, 0xe5, 0x5f, 0x8d, 0xd4, 0xe8, 0x2c, 0xa0, 0xfe, 0x8}, + {0x48, 0x4f, 0xec, 0x71, 0x97, 0x53, 0x44, 0x51, 0x6e, 0x5d, 0x8c, + 0xc9, 0x7d, 0xb1, 0x5, 0xf8, 0x6b, 0xc6, 0xc3, 0x47, 0x1a, 0xc1, + 0x62, 0xf7, 0xdc, 0x99, 0x46, 0x76, 0x85, 0x9b, 0xb8, 0x0}, + {0xd0, 0xea, 0xde, 0x68, 0x76, 0xdd, 0x4d, 0x82, 0x23, 0x5d, 0x68, + 0x4b, 0x20, 0x45, 0x64, 0xc8, 0x65, 0xd6, 0x89, 0x5d, 0xcd, 0xcf, + 0x14, 0xb5, 0x37, 0xd5, 0x75, 0x4f, 0xa7, 0x29, 0x38, 0x47}, + }, + { + {0xc9, 0x2, 0x39, 0xad, 0x3a, 0x53, 0xd9, 0x23, 0x8f, 0x58, 0x3, + 0xef, 0xce, 0xdd, 0xc2, 0x64, 0xb4, 0x2f, 0xe1, 0xcf, 0x90, 0x73, + 0x25, 0x15, 0x90, 0xd3, 0xe4, 0x44, 0x4d, 0x8b, 0x66, 0x6c}, + {0x18, 0xc4, 0x79, 0x46, 0x75, 0xda, 0xd2, 0x82, 0xf0, 0x8d, 0x61, + 0xb2, 0xd8, 0xd7, 0x3b, 0xe6, 0xa, 0xeb, 0x47, 0xac, 0x24, 0xef, + 0x5e, 0x35, 0xb4, 0xc6, 0x33, 0x48, 0x4c, 0x68, 0x78, 0x20}, + {0xc, 0x82, 0x78, 0x7a, 0x21, 0xcf, 0x48, 0x3b, 0x97, 0x3e, 0x27, + 0x81, 0xb2, 0xa, 0x6a, 0xf7, 0x7b, 0xed, 0x8e, 0x8c, 0xa7, 0x65, + 0x6c, 0xa9, 0x3f, 0x43, 0x8a, 0x4f, 0x5, 0xa6, 0x11, 0x74}, + }, + { + {0xb4, 0x75, 0xb1, 0x18, 0x3d, 0xe5, 0x9a, 0x57, 0x2, 0xa1, 0x92, + 0xf3, 0x59, 0x31, 0x71, 0x68, 0xf5, 0x35, 0xef, 0x1e, 0xba, 0xec, + 0x55, 0x84, 0x8f, 0x39, 0x8c, 0x45, 0x72, 0xa8, 0xc9, 0x1e}, + {0x6d, 0xc8, 0x9d, 0xb9, 0x32, 0x9d, 0x65, 0x4d, 0x15, 0xf1, 0x3a, + 0x60, 0x75, 0xdc, 0x4c, 0x4, 0x88, 0xe4, 0xc2, 0xdc, 0x2c, 0x71, + 0x4c, 0xb3, 0xff, 0x34, 0x81, 0xfb, 0x74, 0x65, 0x13, 0x7c}, + {0x9b, 0x50, 0xa2, 0x0, 0xd4, 0xa4, 0xe6, 0xb8, 0xb4, 0x82, 0xc8, + 0xb, 0x2, 0xd7, 0x81, 0x9b, 0x61, 0x75, 0x95, 0xf1, 0x9b, 0xcc, + 0xe7, 0x57, 0x60, 0x64, 0xcd, 0xc7, 0xa5, 0x88, 0xdd, 0x3a}, + }, + { + {0x46, 0x30, 0x39, 0x59, 0xd4, 0x98, 0xc2, 0x85, 0xec, 0x59, 0xf6, + 0x5f, 0x98, 0x35, 0x7e, 0x8f, 0x3a, 0x6e, 0xf6, 0xf2, 0x2a, 0xa2, + 0x2c, 0x1d, 0x20, 0xa7, 0x6, 0xa4, 0x31, 0x11, 0xba, 0x61}, + {0xf2, 0xdc, 0x35, 0xb6, 0x70, 0x57, 0x89, 0xab, 0xbc, 0x1f, 0x6c, + 0xf6, 0x6c, 0xef, 0xdf, 0x2, 0x87, 0xd1, 0xb6, 0xbe, 0x68, 0x2, + 0x53, 0x85, 0x74, 0x9e, 0x87, 0xcc, 0xfc, 0x29, 0x99, 0x24}, + {0x29, 0x90, 0x95, 0x16, 0xf1, 0xa0, 0xd0, 0xa3, 0x89, 0xbd, 0x7e, + 0xba, 0x6c, 0x6b, 0x3b, 0x2, 0x7, 0x33, 0x78, 0x26, 0x3e, 0x5a, + 0xf1, 0x7b, 0xe7, 0xec, 0xd8, 0xbb, 0xc, 0x31, 0x20, 0x56}, + }, + { + {0xd6, 0x85, 0xe2, 0x77, 0xf4, 0xb5, 0x46, 0x66, 0x93, 0x61, 0x8f, + 0x6c, 0x67, 0xff, 0xe8, 0x40, 0xdd, 0x94, 0xb5, 0xab, 0x11, 0x73, + 0xec, 0xa6, 0x4d, 0xec, 0x8c, 0x65, 0xf3, 0x46, 0xc8, 0x7e}, + {0x43, 0xd6, 0x34, 0x49, 0x43, 0x93, 0x89, 0x52, 0xf5, 0x22, 0x12, + 0xa5, 0x6, 0xf8, 0xdb, 0xb9, 0x22, 0x1c, 0xf4, 0xc3, 0x8f, 0x87, + 0x6d, 0x8f, 0x30, 0x97, 0x9d, 0x4d, 0x2a, 0x6a, 0x67, 0x37}, + {0xc7, 0x2e, 0xa2, 0x1d, 0x3f, 0x8f, 0x5e, 0x9b, 0x13, 0xcd, 0x1, + 0x6c, 0x77, 0x1d, 0xf, 0x13, 0xb8, 0x9f, 0x98, 0xa2, 0xcf, 0x8f, + 0x4c, 0x21, 0xd5, 0x9d, 0x9b, 0x39, 0x23, 0xf7, 0xaa, 0x6d}, + }, + }, + { + { + {0xa2, 0x8e, 0xad, 0xac, 0xbf, 0x4, 0x3b, 0x58, 0x84, 0xe8, 0x8b, + 0x14, 0xe8, 0x43, 0xb7, 0x29, 0xdb, 0xc5, 0x10, 0x8, 0x3b, 0x58, + 0x1e, 0x2b, 0xaa, 0xbb, 0xb3, 0x8e, 0xe5, 0x49, 0x54, 0x2b}, + {0x47, 0xbe, 0x3d, 0xeb, 0x62, 0x75, 0x3a, 0x5f, 0xb8, 0xa0, 0xbd, + 0x8e, 0x54, 0x38, 0xea, 0xf7, 0x99, 0x72, 0x74, 0x45, 0x31, 0xe5, + 0xc3, 0x0, 0x51, 0xd5, 0x27, 0x16, 0xe7, 0xe9, 0x4, 0x13}, + {0xfe, 0x9c, 0xdc, 0x6a, 0xd2, 0x14, 0x98, 0x78, 0xb, 0xdd, 0x48, + 0x8b, 0x3f, 0xab, 0x1b, 0x3c, 0xa, 0xc6, 0x79, 0xf9, 0xff, 0xe1, + 0xf, 0xda, 0x93, 0xd6, 0x2d, 0x7c, 0x2d, 0xde, 0x68, 0x44}, + }, + { + {0xce, 0x7, 0x63, 0xf8, 0xc6, 0xd8, 0x9a, 0x4b, 0x28, 0xc, 0x5d, + 0x43, 0x31, 0x35, 0x11, 0x21, 0x2c, 0x77, 0x7a, 0x65, 0xc5, 0x66, + 0xa8, 0xd4, 0x52, 0x73, 0x24, 0x63, 0x7e, 0x42, 0xa6, 0x5d}, + {0x9e, 0x46, 0x19, 0x94, 0x5e, 0x35, 0xbb, 0x51, 0x54, 0xc7, 0xdd, + 0x23, 0x4c, 0xdc, 0xe6, 0x33, 0x62, 0x99, 0x7f, 0x44, 0xd6, 0xb6, + 0xa5, 0x93, 0x63, 0xbd, 0x44, 0xfb, 0x6f, 0x7c, 0xce, 0x6c}, + {0xca, 0x22, 0xac, 0xde, 0x88, 0xc6, 0x94, 0x1a, 0xf8, 0x1f, 0xae, + 0xbb, 0xf7, 0x6e, 0x6, 0xb9, 0xf, 0x58, 0x59, 0x8d, 0x38, 0x8c, + 0xad, 0x88, 0xa8, 0x2c, 0x9f, 0xe7, 0xbf, 0x9a, 0xf2, 0x58}, + }, + { + {0xf6, 0xcd, 0xe, 0x71, 0xbf, 0x64, 0x5a, 0x4b, 0x3c, 0x29, 0x2c, + 0x46, 0x38, 0xe5, 0x4c, 0xb1, 0xb9, 0x3a, 0xb, 0xd5, 0x56, 0xd0, + 0x43, 0x36, 0x70, 0x48, 0x5b, 0x18, 0x24, 0x37, 0xf9, 0x6a}, + {0x68, 0x3e, 0xe7, 0x8d, 0xab, 0xcf, 0xe, 0xe9, 0xa5, 0x76, 0x7e, + 0x37, 0x9f, 0x6f, 0x3, 0x54, 0x82, 0x59, 0x1, 0xbe, 0xb, 0x5b, + 0x49, 0xf0, 0x36, 0x1e, 0xf4, 0xa7, 0xc4, 0x29, 0x76, 0x57}, + {0x88, 0xa8, 0xc6, 0x9, 0x45, 0x2, 0x20, 0x32, 0x73, 0x89, 0x55, + 0x4b, 0x13, 0x36, 0xe0, 0xd2, 0x9f, 0x28, 0x33, 0x3c, 0x23, 0x36, + 0xe2, 0x83, 0x8f, 0xc1, 0xae, 0xc, 0xbb, 0x25, 0x1f, 0x70}, + }, + { + {0x13, 0xc1, 0xbe, 0x7c, 0xd9, 0xf6, 0x18, 0x9d, 0xe4, 0xdb, 0xbf, + 0x74, 0xe6, 0x6, 0x4a, 0x84, 0xd6, 0x60, 0x4e, 0xac, 0x22, 0xb5, + 0xf5, 0x20, 0x51, 0x5e, 0x95, 0x50, 0xc0, 0x5b, 0xa, 0x72}, + {0xed, 0x6c, 0x61, 0xe4, 0xf8, 0xb0, 0xa8, 0xc3, 0x7d, 0xa8, 0x25, + 0x9e, 0xe, 0x66, 0x0, 0xf7, 0x9c, 0xa5, 0xbc, 0xf4, 0x1f, 0x6, + 0xe3, 0x61, 0xe9, 0xb, 0xc4, 0xbd, 0xbf, 0x92, 0xc, 0x2e}, + {0x35, 0x5a, 0x80, 0x9b, 0x43, 0x9, 0x3f, 0xc, 0xfc, 0xab, 0x42, + 0x62, 0x37, 0x8b, 0x4e, 0xe8, 0x46, 0x93, 0x22, 0x5c, 0xf3, 0x17, + 0x14, 0x69, 0xec, 0xf0, 0x4e, 0x14, 0xbb, 0x9c, 0x9b, 0xe}, + }, + { + {0xee, 0xbe, 0xb1, 0x5d, 0xd5, 0x9b, 0xee, 0x8d, 0xb9, 0x3f, 0x72, + 0xa, 0x37, 0xab, 0xc3, 0xc9, 0x91, 0xd7, 0x68, 0x1c, 0xbf, 0xf1, + 0xa8, 0x44, 0xde, 0x3c, 0xfd, 0x1c, 0x19, 0x44, 0x6d, 0x36}, + {0xad, 0x20, 0x57, 0xfb, 0x8f, 0xd4, 0xba, 0xfb, 0xe, 0xd, 0xf9, + 0xdb, 0x6b, 0x91, 0x81, 0xee, 0xbf, 0x43, 0x55, 0x63, 0x52, 0x31, + 0x81, 0xd4, 0xd8, 0x7b, 0x33, 0x3f, 0xeb, 0x4, 0x11, 0x22}, + {0x14, 0x8c, 0xbc, 0xf2, 0x43, 0x17, 0x3c, 0x9e, 0x3b, 0x6c, 0x85, + 0xb5, 0xfc, 0x26, 0xda, 0x2e, 0x97, 0xfb, 0xa7, 0x68, 0xe, 0x2f, + 0xb8, 0xcc, 0x44, 0x32, 0x59, 0xbc, 0xe6, 0xa4, 0x67, 0x41}, + }, + { + {0xee, 0x8f, 0xce, 0xf8, 0x65, 0x26, 0xbe, 0xc2, 0x2c, 0xd6, 0x80, + 0xe8, 0x14, 0xff, 0x67, 0xe9, 0xee, 0x4e, 0x36, 0x2f, 0x7e, 0x6e, + 0x2e, 0xf1, 0xf6, 0xd2, 0x7e, 0xcb, 0x70, 0x33, 0xb3, 0x34}, + {0x0, 0x27, 0xf6, 0x76, 0x28, 0x9d, 0x3b, 0x64, 0xeb, 0x68, 0x76, + 0xe, 0x40, 0x9d, 0x1d, 0x5d, 0x84, 0x6, 0xfc, 0x21, 0x3, 0x43, + 0x4b, 0x1b, 0x6a, 0x24, 0x55, 0x22, 0x7e, 0xbb, 0x38, 0x79}, + {0xcc, 0xd6, 0x81, 0x86, 0xee, 0x91, 0xc5, 0xcd, 0x53, 0xa7, 0x85, + 0xed, 0x9c, 0x10, 0x2, 0xce, 0x83, 0x88, 0x80, 0x58, 0xc1, 0x85, + 0x74, 0xed, 0xe4, 0x65, 0xfe, 0x2d, 0x6e, 0xfc, 0x76, 0x11}, + }, + { + {0xb8, 0xe, 0x77, 0x49, 0x89, 0xe2, 0x90, 0xdb, 0xa3, 0x40, 0xf4, + 0xac, 0x2a, 0xcc, 0xfb, 0x98, 0x9b, 0x87, 0xd7, 0xde, 0xfe, 0x4f, + 0x35, 0x21, 0xb6, 0x6, 0x69, 0xf2, 0x54, 0x3e, 0x6a, 0x1f}, + {0x9b, 0x61, 0x9c, 0x5b, 0xd0, 0x6c, 0xaf, 0xb4, 0x80, 0x84, 0xa5, + 0xb2, 0xf4, 0xc9, 0xdf, 0x2d, 0xc4, 0x4d, 0xe9, 0xeb, 0x2, 0xa5, + 0x4f, 0x3d, 0x34, 0x5f, 0x7d, 0x67, 0x4c, 0x3a, 0xfc, 0x8}, + {0xea, 0x34, 0x7, 0xd3, 0x99, 0xc1, 0xa4, 0x60, 0xd6, 0x5c, 0x16, + 0x31, 0xb6, 0x85, 0xc0, 0x40, 0x95, 0x82, 0x59, 0xf7, 0x23, 0x3e, + 0x33, 0xe2, 0xd1, 0x0, 0xb9, 0x16, 0x1, 0xad, 0x2f, 0x4f}, + }, + { + {0x38, 0xb6, 0x3b, 0xb7, 0x1d, 0xd9, 0x2c, 0x96, 0x8, 0x9c, 0x12, + 0xfc, 0xaa, 0x77, 0x5, 0xe6, 0x89, 0x16, 0xb6, 0xf3, 0x39, 0x9b, + 0x61, 0x6f, 0x81, 0xee, 0x44, 0x29, 0x5f, 0x99, 0x51, 0x34}, + {0x54, 0x4e, 0xae, 0x94, 0x41, 0xb2, 0xbe, 0x44, 0x6c, 0xef, 0x57, + 0x18, 0x51, 0x1c, 0x54, 0x5f, 0x98, 0x4, 0x8d, 0x36, 0x2d, 0x6b, + 0x1e, 0xa6, 0xab, 0xf7, 0x2e, 0x97, 0xa4, 0x84, 0x54, 0x44}, + {0x7c, 0x7d, 0xea, 0x9f, 0xd0, 0xfc, 0x52, 0x91, 0xf6, 0x5c, 0x93, + 0xb0, 0x94, 0x6c, 0x81, 0x4a, 0x40, 0x5c, 0x28, 0x47, 0xaa, 0x9a, + 0x8e, 0x25, 0xb7, 0x93, 0x28, 0x4, 0xa6, 0x9c, 0xb8, 0x10}, + }, + }, + { + { + {0x6e, 0xf0, 0x45, 0x5a, 0xbe, 0x41, 0x39, 0x75, 0x65, 0x5f, 0x9c, + 0x6d, 0xed, 0xae, 0x7c, 0xd0, 0xb6, 0x51, 0xff, 0x72, 0x9c, 0x6b, + 0x77, 0x11, 0xa9, 0x4d, 0xd, 0xef, 0xd9, 0xd1, 0xd2, 0x17}, + {0x9c, 0x28, 0x18, 0x97, 0x49, 0x47, 0x59, 0x3d, 0x26, 0x3f, 0x53, + 0x24, 0xc5, 0xf8, 0xeb, 0x12, 0x15, 0xef, 0xc3, 0x14, 0xcb, 0xbf, + 0x62, 0x2, 0x8e, 0x51, 0xb7, 0x77, 0xd5, 0x78, 0xb8, 0x20}, + {0x6a, 0x3e, 0x3f, 0x7, 0x18, 0xaf, 0xf2, 0x27, 0x69, 0x10, 0x52, + 0xd7, 0x19, 0xe5, 0x3f, 0xfd, 0x22, 0x0, 0xa6, 0x3c, 0x2c, 0xb7, + 0xe3, 0x22, 0xa7, 0xc6, 0x65, 0xcc, 0x63, 0x4f, 0x21, 0x72}, + }, + { + {0xc9, 0x29, 0x3b, 0xf4, 0xb9, 0xb7, 0x9d, 0x1d, 0x75, 0x8f, 0x51, + 0x4f, 0x4a, 0x82, 0x5, 0xd6, 0xc4, 0x9d, 0x2f, 0x31, 0xbd, 0x72, + 0xc0, 0xf2, 0xb0, 0x45, 0x15, 0x5a, 0x85, 0xac, 0x24, 0x1f}, + {0x93, 0xa6, 0x7, 0x53, 0x40, 0x7f, 0xe3, 0xb4, 0x95, 0x67, 0x33, + 0x2f, 0xd7, 0x14, 0xa7, 0xab, 0x99, 0x10, 0x76, 0x73, 0xa7, 0xd0, + 0xfb, 0xd6, 0xc9, 0xcb, 0x71, 0x81, 0xc5, 0x48, 0xdf, 0x5f}, + {0xaa, 0x5, 0x95, 0x8e, 0x32, 0x8, 0xd6, 0x24, 0xee, 0x20, 0x14, + 0xc, 0xd1, 0xc1, 0x48, 0x47, 0xa2, 0x25, 0xfb, 0x6, 0x5c, 0xe4, + 0xff, 0xc7, 0xe6, 0x95, 0xe3, 0x2a, 0x9e, 0x73, 0xba, 0x0}, + }, + { + {0x26, 0xbb, 0x88, 0xea, 0xf5, 0x26, 0x44, 0xae, 0xfb, 0x3b, 0x97, + 0x84, 0xd9, 0x79, 0x6, 0x36, 0x50, 0x4e, 0x69, 0x26, 0xc, 0x3, + 0x9f, 0x5c, 0x26, 0xd2, 0x18, 0xd5, 0xe7, 0x7d, 0x29, 0x72}, + {0xd6, 0x90, 0x87, 0x5c, 0xde, 0x98, 0x2e, 0x59, 0xdf, 0xa2, 0xc2, + 0x45, 0xd3, 0xb7, 0xbf, 0xe5, 0x22, 0x99, 0xb4, 0xf9, 0x60, 0x3b, + 0x5a, 0x11, 0xf3, 0x78, 0xad, 0x67, 0x3e, 0x3a, 0x28, 0x3}, + {0x39, 0xb9, 0xc, 0xbe, 0xc7, 0x1d, 0x24, 0x48, 0x80, 0x30, 0x63, + 0x8b, 0x4d, 0x9b, 0xf1, 0x32, 0x8, 0x93, 0x28, 0x2, 0xd, 0xc9, + 0xdf, 0xd3, 0x45, 0x19, 0x27, 0x46, 0x68, 0x29, 0xe1, 0x5}, + }, + { + {0x50, 0x45, 0x2c, 0x24, 0xc8, 0xbb, 0xbf, 0xad, 0xd9, 0x81, 0x30, + 0xd0, 0xec, 0xc, 0xc8, 0xbc, 0x92, 0xdf, 0xc8, 0xf5, 0xa6, 0x66, + 0x35, 0x84, 0x4c, 0xce, 0x58, 0x82, 0xd3, 0x25, 0xcf, 0x78}, + {0x5a, 0x49, 0x9c, 0x2d, 0xb3, 0xee, 0x82, 0xba, 0x7c, 0xb9, 0x2b, + 0xf1, 0xfc, 0xc8, 0xef, 0xce, 0xe0, 0xd1, 0xb5, 0x93, 0xae, 0xab, + 0x2d, 0xb0, 0x9b, 0x8d, 0x69, 0x13, 0x9c, 0xc, 0xc0, 0x39}, + {0x68, 0x9d, 0x48, 0x31, 0x8e, 0x6b, 0xae, 0x15, 0x87, 0xf0, 0x2b, + 0x9c, 0xab, 0x1c, 0x85, 0xaa, 0x5, 0xfa, 0x4e, 0xf0, 0x97, 0x5a, + 0xa7, 0xc9, 0x32, 0xf8, 0x3f, 0x6b, 0x7, 0x52, 0x6b, 0x0}, + }, + { + {0x2d, 0x8, 0xce, 0xb9, 0x16, 0x7e, 0xcb, 0xf5, 0x29, 0xbc, 0x7a, + 0x41, 0x4c, 0xf1, 0x7, 0x34, 0xab, 0xa7, 0xf4, 0x2b, 0xce, 0x6b, + 0xb3, 0xd4, 0xce, 0x75, 0x9f, 0x1a, 0x56, 0xe9, 0xe2, 0x7d}, + {0x1c, 0x78, 0x95, 0x9d, 0xe1, 0xcf, 0xe0, 0x29, 0xe2, 0x10, 0x63, + 0x96, 0x18, 0xdf, 0x81, 0xb6, 0x39, 0x6b, 0x51, 0x70, 0xd3, 0x39, + 0xdf, 0x57, 0x22, 0x61, 0xc7, 0x3b, 0x44, 0xe3, 0x57, 0x4d}, + {0xcb, 0x5e, 0xa5, 0xb6, 0xf4, 0xd4, 0x70, 0xde, 0x99, 0xdb, 0x85, + 0x5d, 0x7f, 0x52, 0x1, 0x48, 0x81, 0x9a, 0xee, 0xd3, 0x40, 0xc4, + 0xc9, 0xdb, 0xed, 0x29, 0x60, 0x1a, 0xaf, 0x90, 0x2a, 0x6b}, + }, + { + {0xa, 0xd8, 0xb2, 0x5b, 0x24, 0xf3, 0xeb, 0x77, 0x9b, 0x7, 0xb9, + 0x2f, 0x47, 0x1b, 0x30, 0xd8, 0x33, 0x73, 0xee, 0x4c, 0xf2, 0xe6, + 0x47, 0xc6, 0x9, 0x21, 0x6c, 0x27, 0xc8, 0x12, 0x58, 0x46}, + {0x97, 0x1e, 0xe6, 0x9a, 0xfc, 0xf4, 0x23, 0x69, 0xd1, 0x5f, 0x3f, + 0xe0, 0x1d, 0x28, 0x35, 0x57, 0x2d, 0xd1, 0xed, 0xe6, 0x43, 0xae, + 0x64, 0xa7, 0x4a, 0x3e, 0x2d, 0xd1, 0xe9, 0xf4, 0xd8, 0x5f}, + {0xd9, 0x62, 0x10, 0x2a, 0xb2, 0xbe, 0x43, 0x4d, 0x16, 0xdc, 0x31, + 0x38, 0x75, 0xfb, 0x65, 0x70, 0xd7, 0x68, 0x29, 0xde, 0x7b, 0x4a, + 0xd, 0x18, 0x90, 0x67, 0xb1, 0x1c, 0x2b, 0x2c, 0xb3, 0x5}, + }, + { + {0x95, 0x81, 0xd5, 0x7a, 0x2c, 0xa4, 0xfc, 0xf7, 0xcc, 0xf3, 0x33, + 0x43, 0x6e, 0x28, 0x14, 0x32, 0x9d, 0x97, 0xb, 0x34, 0xd, 0x9d, + 0xc2, 0xb6, 0xe1, 0x7, 0x73, 0x56, 0x48, 0x1a, 0x77, 0x31}, + {0xfd, 0xa8, 0x4d, 0xd2, 0xcc, 0x5e, 0xc0, 0xc8, 0x83, 0xef, 0xdf, + 0x5, 0xac, 0x1a, 0xcf, 0xa1, 0x61, 0xcd, 0xf9, 0x7d, 0xf2, 0xef, + 0xbe, 0xdb, 0x99, 0x1e, 0x47, 0x7b, 0xa3, 0x56, 0x55, 0x3b}, + {0x82, 0xd4, 0x4d, 0xe1, 0x24, 0xc5, 0xb0, 0x32, 0xb6, 0xa4, 0x2b, + 0x1a, 0x54, 0x51, 0xb3, 0xed, 0xf3, 0x5a, 0x2b, 0x28, 0x48, 0x60, + 0xd1, 0xa3, 0xeb, 0x36, 0x73, 0x7a, 0xd2, 0x79, 0xc0, 0x4f}, + }, + { + {0xd, 0xc5, 0x86, 0xc, 0x44, 0x8b, 0x34, 0xdc, 0x51, 0xe6, 0x94, + 0xcc, 0xc9, 0xcb, 0x37, 0x13, 0xb9, 0x3c, 0x3e, 0x64, 0x4d, 0xf7, + 0x22, 0x64, 0x8, 0xcd, 0xe3, 0xba, 0xc2, 0x70, 0x11, 0x24}, + {0x7f, 0x2f, 0xbf, 0x89, 0xb0, 0x38, 0xc9, 0x51, 0xa7, 0xe9, 0xdf, + 0x2, 0x65, 0xbd, 0x97, 0x24, 0x53, 0xe4, 0x80, 0x78, 0x9c, 0xc0, + 0xff, 0xff, 0x92, 0x8e, 0xf9, 0xca, 0xce, 0x67, 0x45, 0x12}, + {0xb4, 0x73, 0xc4, 0xa, 0x86, 0xab, 0xf9, 0x3f, 0x35, 0xe4, 0x13, + 0x1, 0xee, 0x1d, 0x91, 0xf0, 0xaf, 0xc4, 0xc6, 0xeb, 0x60, 0x50, + 0xe7, 0x4a, 0xd, 0x0, 0x87, 0x6c, 0x96, 0x12, 0x86, 0x3f}, + }, + }, + { + { + {0x13, 0x8d, 0x4, 0x36, 0xfa, 0xfc, 0x18, 0x9c, 0xdd, 0x9d, 0x89, + 0x73, 0xb3, 0x9d, 0x15, 0x29, 0xaa, 0xd0, 0x92, 0x9f, 0xb, 0x35, + 0x9f, 0xdc, 0xd4, 0x19, 0x8a, 0x87, 0xee, 0x7e, 0xf5, 0x26}, + {0xde, 0xd, 0x2a, 0x78, 0xc9, 0xc, 0x9a, 0x55, 0x85, 0x83, 0x71, + 0xea, 0xb2, 0xcd, 0x1d, 0x55, 0x8c, 0x23, 0xef, 0x31, 0x5b, 0x86, + 0x62, 0x7f, 0x3d, 0x61, 0x73, 0x79, 0x76, 0xa7, 0x4a, 0x50}, + {0xb1, 0xef, 0x87, 0x56, 0xd5, 0x2c, 0xab, 0xc, 0x7b, 0xf1, 0x7a, + 0x24, 0x62, 0xd1, 0x80, 0x51, 0x67, 0x24, 0x5a, 0x4f, 0x34, 0x5a, + 0xc1, 0x85, 0x69, 0x30, 0xba, 0x9d, 0x3d, 0x94, 0x41, 0x40}, + }, + { + {0xdd, 0xaa, 0x6c, 0xa2, 0x43, 0x77, 0x21, 0x4b, 0xce, 0xb7, 0x8a, + 0x64, 0x24, 0xb4, 0xa6, 0x47, 0xe3, 0xc9, 0xfb, 0x3, 0x7a, 0x4f, + 0x1d, 0xcb, 0x19, 0xd0, 0x0, 0x98, 0x42, 0x31, 0xd9, 0x12}, + {0x96, 0xcc, 0xeb, 0x43, 0xba, 0xee, 0xc0, 0xc3, 0xaf, 0x9c, 0xea, + 0x26, 0x9c, 0x9c, 0x74, 0x8d, 0xc6, 0xcc, 0x77, 0x1c, 0xee, 0x95, + 0xfa, 0xd9, 0xf, 0x34, 0x84, 0x76, 0xd9, 0xa1, 0x20, 0x14}, + {0x4f, 0x59, 0x37, 0xd3, 0x99, 0x77, 0xc6, 0x0, 0x7b, 0xa4, 0x3a, + 0xb2, 0x40, 0x51, 0x3c, 0x5e, 0x95, 0xf3, 0x5f, 0xe3, 0x54, 0x28, + 0x18, 0x44, 0x12, 0xa0, 0x59, 0x43, 0x31, 0x92, 0x4f, 0x1b}, + }, + { + {0xb1, 0x66, 0x98, 0xa4, 0x30, 0x30, 0xcf, 0x33, 0x59, 0x48, 0x5f, + 0x21, 0xd2, 0x73, 0x1f, 0x25, 0xf6, 0xf4, 0xde, 0x51, 0x40, 0xaa, + 0x82, 0xab, 0xf6, 0x23, 0x9a, 0x6f, 0xd5, 0x91, 0xf1, 0x5f}, + {0x51, 0x9, 0x15, 0x89, 0x9d, 0x10, 0x5c, 0x3e, 0x6a, 0x69, 0xe9, + 0x2d, 0x91, 0xfa, 0xce, 0x39, 0x20, 0x30, 0x5f, 0x97, 0x3f, 0xe4, + 0xea, 0x20, 0xae, 0x2d, 0x13, 0x7f, 0x2a, 0x57, 0x9b, 0x23}, + {0x68, 0x90, 0x2d, 0xac, 0x33, 0xd4, 0x9e, 0x81, 0x23, 0x85, 0xc9, + 0x5f, 0x79, 0xab, 0x83, 0x28, 0x3d, 0xeb, 0x93, 0x55, 0x80, 0x72, + 0x45, 0xef, 0xcb, 0x36, 0x8f, 0x75, 0x6a, 0x52, 0xc, 0x2}, + }, + { + {0x89, 0xcc, 0x42, 0xf0, 0x59, 0xef, 0x31, 0xe9, 0xb6, 0x4b, 0x12, + 0x8e, 0x9d, 0x9c, 0x58, 0x2c, 0x97, 0x59, 0xc7, 0xae, 0x8a, 0xe1, + 0xc8, 0xad, 0xc, 0xc5, 0x2, 0x56, 0xa, 0xfe, 0x2c, 0x45}, + {0xbc, 0xdb, 0xd8, 0x9e, 0xf8, 0x34, 0x98, 0x77, 0x6c, 0xa4, 0x7c, + 0xdc, 0xf9, 0xaa, 0xf2, 0xc8, 0x74, 0xb0, 0xe1, 0xa3, 0xdc, 0x4c, + 0x52, 0xa9, 0x77, 0x38, 0x31, 0x15, 0x46, 0xcc, 0xaa, 0x2}, + {0xdf, 0x77, 0x78, 0x64, 0xa0, 0xf7, 0xa0, 0x86, 0x9f, 0x7c, 0x60, + 0xe, 0x27, 0x64, 0xc4, 0xbb, 0xc9, 0x11, 0xfb, 0xf1, 0x25, 0xea, + 0x17, 0xab, 0x7b, 0x87, 0x4b, 0x30, 0x7b, 0x7d, 0xfb, 0x4c}, + }, + { + {0x12, 0xef, 0x89, 0x97, 0xc2, 0x99, 0x86, 0xe2, 0xd, 0x19, 0x57, + 0xdf, 0x71, 0xcd, 0x6e, 0x2b, 0xd0, 0x70, 0xc9, 0xec, 0x57, 0xc8, + 0x43, 0xc3, 0xc5, 0x3a, 0x4d, 0x43, 0xbc, 0x4c, 0x1d, 0x5b}, + {0xfe, 0x75, 0x9b, 0xb8, 0x6c, 0x3d, 0xb4, 0x72, 0x80, 0xdc, 0x6a, + 0x9c, 0xd9, 0x94, 0xc6, 0x54, 0x9f, 0x4c, 0xe3, 0x3e, 0x37, 0xaa, + 0xc3, 0xb8, 0x64, 0x53, 0x7, 0x39, 0x2b, 0x62, 0xb4, 0x14}, + {0x26, 0x9f, 0xa, 0xcc, 0x15, 0x26, 0xfb, 0xb6, 0xe5, 0xcc, 0x8d, + 0xb8, 0x2b, 0xe, 0x4f, 0x3a, 0x5, 0xa7, 0x69, 0x33, 0x8b, 0x49, + 0x1, 0x13, 0xd1, 0x2d, 0x59, 0x58, 0x12, 0xf7, 0x98, 0x2f}, + }, + { + {0x1, 0xa7, 0x54, 0x4f, 0x44, 0xae, 0x12, 0x2e, 0xde, 0xd7, 0xcb, + 0xa9, 0xf0, 0x3e, 0xfe, 0xfc, 0xe0, 0x5d, 0x83, 0x75, 0xd, 0x89, + 0xbf, 0xce, 0x54, 0x45, 0x61, 0xe7, 0xe9, 0x62, 0x80, 0x1d}, + {0x56, 0x9e, 0xf, 0xb5, 0x4c, 0xa7, 0x94, 0xc, 0x20, 0x13, 0x8e, + 0x8e, 0xa9, 0xf4, 0x1f, 0x5b, 0x67, 0xf, 0x30, 0x82, 0x21, 0xcc, + 0x2a, 0x9a, 0xf9, 0xaa, 0x6, 0xd8, 0x49, 0xe2, 0x6a, 0x3a}, + {0x5a, 0x7c, 0x90, 0xa9, 0x85, 0xda, 0x7a, 0x65, 0x62, 0xf, 0xb9, + 0x91, 0xb5, 0xa8, 0xe, 0x1a, 0xe9, 0xb4, 0x34, 0xdf, 0xfb, 0x1d, + 0xe, 0x8d, 0xf3, 0x5f, 0xf2, 0xae, 0xe8, 0x8c, 0x8b, 0x29}, + }, + { + {0xde, 0x65, 0x21, 0xa, 0xea, 0x72, 0x7a, 0x83, 0xf6, 0x79, 0xcf, + 0xb, 0xb4, 0x7, 0xab, 0x3f, 0x70, 0xae, 0x38, 0x77, 0xc7, 0x36, + 0x16, 0x52, 0xdc, 0xd7, 0xa7, 0x3, 0x18, 0x27, 0xa6, 0x6b}, + {0xb2, 0xc, 0xf7, 0xef, 0x53, 0x79, 0x92, 0x2a, 0x76, 0x70, 0x15, + 0x79, 0x2a, 0xc9, 0x89, 0x4b, 0x6a, 0xcf, 0xa7, 0x30, 0x7a, 0x45, + 0x18, 0x94, 0x85, 0xe4, 0x5c, 0x4d, 0x40, 0xa8, 0xb8, 0x34}, + {0x35, 0x33, 0x69, 0x83, 0xb5, 0xec, 0x6e, 0xc2, 0xfd, 0xfe, 0xb5, + 0x63, 0xdf, 0x13, 0xa8, 0xd5, 0x73, 0x25, 0xb2, 0xa4, 0x9a, 0xaa, + 0x93, 0xa2, 0x6a, 0x1c, 0x5e, 0x46, 0xdd, 0x2b, 0xd6, 0x71}, + }, + { + {0xf5, 0x5e, 0xf7, 0xb1, 0xda, 0xb5, 0x2d, 0xcd, 0xf5, 0x65, 0xb0, + 0x16, 0xcf, 0x95, 0x7f, 0xd7, 0x85, 0xf0, 0x49, 0x3f, 0xea, 0x1f, + 0x57, 0x14, 0x3d, 0x2b, 0x2b, 0x26, 0x21, 0x36, 0x33, 0x1c}, + {0x80, 0xdf, 0x78, 0xd3, 0x28, 0xcc, 0x33, 0x65, 0xb4, 0xa4, 0xf, + 0xa, 0x79, 0x43, 0xdb, 0xf6, 0x5a, 0xda, 0x1, 0xf7, 0xf9, 0x5f, + 0x64, 0xe3, 0xa4, 0x2b, 0x17, 0xf3, 0x17, 0xf3, 0xd5, 0x74}, + {0x81, 0xca, 0xd9, 0x67, 0x54, 0xe5, 0x6f, 0xa8, 0x37, 0x8c, 0x29, + 0x2b, 0x75, 0x7c, 0x8b, 0x39, 0x3b, 0x62, 0xac, 0xe3, 0x92, 0x8, + 0x6d, 0xda, 0x8c, 0xd9, 0xe9, 0x47, 0x45, 0xcc, 0xeb, 0x4a}, + }, + }, + { + { + {0x10, 0xb6, 0x54, 0x73, 0x9e, 0x8d, 0x40, 0xb, 0x6e, 0x5b, 0xa8, + 0x5b, 0x53, 0x32, 0x6b, 0x80, 0x7, 0xa2, 0x58, 0x4a, 0x3, 0x3a, + 0xe6, 0xdb, 0x2c, 0xdf, 0xa1, 0xc9, 0xdd, 0xd9, 0x3b, 0x17}, + {0xc9, 0x1, 0x6d, 0x27, 0x1b, 0x7, 0xf0, 0x12, 0x70, 0x8c, 0xc4, + 0x86, 0xc5, 0xba, 0xb8, 0xe7, 0xa9, 0xfb, 0xd6, 0x71, 0x9b, 0x12, + 0x8, 0x53, 0x92, 0xb7, 0x3d, 0x5a, 0xf9, 0xfb, 0x88, 0x5d}, + {0xdf, 0x72, 0x58, 0xfe, 0x1e, 0xf, 0x50, 0x2b, 0xc1, 0x18, 0x39, + 0xd4, 0x2e, 0x58, 0xd6, 0x58, 0xe0, 0x3a, 0x67, 0xc9, 0x8e, 0x27, + 0xed, 0xe6, 0x19, 0xa3, 0x9e, 0xb1, 0x13, 0xcd, 0xe1, 0x6}, + }, + { + {0x53, 0x3, 0x5b, 0x9e, 0x62, 0xaf, 0x2b, 0x47, 0x47, 0x4, 0x8d, + 0x27, 0x90, 0xb, 0xaa, 0x3b, 0x27, 0xbf, 0x43, 0x96, 0x46, 0x5f, + 0x78, 0xc, 0x13, 0x7b, 0x83, 0x8d, 0x1a, 0x6a, 0x3a, 0x7f}, + {0x23, 0x6f, 0x16, 0x6f, 0x51, 0xad, 0xd0, 0x40, 0xbe, 0x6a, 0xab, + 0x1f, 0x93, 0x32, 0x8e, 0x11, 0x8e, 0x8, 0x4d, 0xa0, 0x14, 0x5e, + 0xe3, 0x3f, 0x66, 0x62, 0xe1, 0x26, 0x35, 0x60, 0x80, 0x30}, + {0xb, 0x80, 0x3d, 0x5d, 0x39, 0x44, 0xe6, 0xf7, 0xf6, 0xed, 0x1, + 0xc9, 0x55, 0xd5, 0xa8, 0x95, 0x39, 0x63, 0x2c, 0x59, 0x30, 0x78, + 0xcd, 0x68, 0x7e, 0x30, 0x51, 0x2e, 0xed, 0xfd, 0xd0, 0x30}, + }, + { + {0x50, 0x47, 0xb8, 0x68, 0x1e, 0x97, 0xb4, 0x9c, 0xcf, 0xbb, 0x64, + 0x66, 0x29, 0x72, 0x95, 0xa0, 0x2b, 0x41, 0xfa, 0x72, 0x26, 0xe7, + 0x8d, 0x5c, 0xd9, 0x89, 0xc5, 0x51, 0x43, 0x8, 0x15, 0x46}, + {0xb3, 0x33, 0x12, 0xf2, 0x1a, 0x4d, 0x59, 0xe0, 0x9c, 0x4d, 0xcc, + 0xf0, 0x8e, 0xe7, 0xdb, 0x1b, 0x77, 0x9a, 0x49, 0x8f, 0x7f, 0x18, + 0x65, 0x69, 0x68, 0x98, 0x9, 0x2c, 0x20, 0x14, 0x92, 0xa}, + {0x2e, 0xa0, 0xb9, 0xae, 0xc0, 0x19, 0x90, 0xbc, 0xae, 0x4c, 0x3, + 0x16, 0xd, 0x11, 0xc7, 0x55, 0xec, 0x32, 0x99, 0x65, 0x1, 0xf5, + 0x6d, 0xe, 0xfe, 0x5d, 0xca, 0x95, 0x28, 0xd, 0xca, 0x3b}, + }, + { + {0xbf, 0x1, 0xcc, 0x9e, 0xb6, 0x8e, 0x68, 0x9c, 0x6f, 0x89, 0x44, + 0xa6, 0xad, 0x83, 0xbc, 0xf0, 0xe2, 0x9f, 0x7a, 0x5f, 0x5f, 0x95, + 0x2d, 0xca, 0x41, 0x82, 0xf2, 0x8d, 0x3, 0xb4, 0xa8, 0x4e}, + {0xa4, 0x62, 0x5d, 0x3c, 0xbc, 0x31, 0xf0, 0x40, 0x60, 0x7a, 0xf0, + 0xcf, 0x3e, 0x8b, 0xfc, 0x19, 0x45, 0xb5, 0xf, 0x13, 0xa2, 0x3d, + 0x18, 0x98, 0xcd, 0x13, 0x8f, 0xae, 0xdd, 0xde, 0x31, 0x56}, + {0x2, 0xd2, 0xca, 0xf1, 0xa, 0x46, 0xed, 0x2a, 0x83, 0xee, 0x8c, + 0xa4, 0x5, 0x53, 0x30, 0x46, 0x5f, 0x1a, 0xf1, 0x49, 0x45, 0x77, + 0x21, 0x91, 0x63, 0xa4, 0x2c, 0x54, 0x30, 0x9, 0xce, 0x24}, + }, + { + {0x85, 0xb, 0xf3, 0xfd, 0x55, 0xa1, 0xcf, 0x3f, 0xa4, 0x2e, 0x37, + 0x36, 0x8e, 0x16, 0xf7, 0xd2, 0x44, 0xf8, 0x92, 0x64, 0xde, 0x64, + 0xe0, 0xb2, 0x80, 0x42, 0x4f, 0x32, 0xa7, 0x28, 0x99, 0x54}, + {0x6, 0xc1, 0x6, 0xfd, 0xf5, 0x90, 0xe8, 0x1f, 0xf2, 0x10, 0x88, + 0x5d, 0x35, 0x68, 0xc4, 0xb5, 0x3e, 0xaf, 0x8c, 0x6e, 0xfe, 0x8, + 0x78, 0x82, 0x4b, 0xd7, 0x6, 0x8a, 0xc2, 0xe3, 0xd4, 0x41}, + {0x2e, 0x1a, 0xee, 0x63, 0xa7, 0x32, 0x6e, 0xf2, 0xea, 0xfd, 0x5f, + 0xd2, 0xb7, 0xe4, 0x91, 0xae, 0x69, 0x4d, 0x7f, 0xd1, 0x3b, 0xd3, + 0x3b, 0xbc, 0x6a, 0xff, 0xdc, 0xc0, 0xde, 0x66, 0x1b, 0x49}, + }, + { + {0xa1, 0x64, 0xda, 0xd0, 0x8e, 0x4a, 0xf0, 0x75, 0x4b, 0x28, 0xe2, + 0x67, 0xaf, 0x2c, 0x22, 0xed, 0xa4, 0x7b, 0x7b, 0x1f, 0x79, 0xa3, + 0x34, 0x82, 0x67, 0x8b, 0x1, 0xb7, 0xb0, 0xb8, 0xf6, 0x4c}, + {0xa7, 0x32, 0xea, 0xc7, 0x3d, 0xb1, 0xf5, 0x98, 0x98, 0xdb, 0x16, + 0x7e, 0xcc, 0xf8, 0xd5, 0xe3, 0x47, 0xd9, 0xf8, 0xcb, 0x52, 0xbf, + 0xa, 0xac, 0xac, 0xe4, 0x5e, 0xc8, 0xd0, 0x38, 0xf3, 0x8}, + {0xbd, 0x73, 0x1a, 0x99, 0x21, 0xa8, 0x83, 0xc3, 0x7a, 0xc, 0x32, + 0xdf, 0x1, 0xbc, 0x27, 0xab, 0x63, 0x70, 0x77, 0x84, 0x1b, 0x33, + 0x3d, 0xc1, 0x99, 0x8a, 0x7, 0xeb, 0x82, 0x4a, 0xd, 0x53}, + }, + { + {0x9e, 0xbf, 0x9a, 0x6c, 0x45, 0x73, 0x69, 0x6d, 0x80, 0xa8, 0x0, + 0x49, 0xfc, 0xb2, 0x7f, 0x25, 0x50, 0xb8, 0xcf, 0xc8, 0x12, 0xf4, + 0xac, 0x2b, 0x5b, 0xbd, 0xbf, 0xc, 0xe0, 0xe7, 0xb3, 0xd}, + {0x25, 0x48, 0xf9, 0xe1, 0x30, 0x36, 0x4c, 0x0, 0x5a, 0x53, 0xab, + 0x8c, 0x26, 0x78, 0x2d, 0x7e, 0x8b, 0xff, 0x84, 0xcc, 0x23, 0x23, + 0x48, 0xc7, 0xb9, 0x70, 0x17, 0x10, 0x3f, 0x75, 0xea, 0x65}, + {0x63, 0x63, 0x9, 0xe2, 0x3e, 0xfc, 0x66, 0x3d, 0x6b, 0xcb, 0xb5, + 0x61, 0x7f, 0x2c, 0xd6, 0x81, 0x1a, 0x3b, 0x44, 0x13, 0x42, 0x4, + 0xbe, 0xf, 0xdb, 0xa1, 0xe1, 0x21, 0x19, 0xec, 0xa4, 0x2}, + }, + { + {0x5f, 0x79, 0xcf, 0xf1, 0x62, 0x61, 0xc8, 0xf5, 0xf2, 0x57, 0xee, + 0x26, 0x19, 0x86, 0x8c, 0x11, 0x78, 0x35, 0x6, 0x1c, 0x85, 0x24, + 0x21, 0x17, 0xcf, 0x7f, 0x6, 0xec, 0x5d, 0x2b, 0xd1, 0x36}, + {0xa2, 0xb8, 0x24, 0x3b, 0x9a, 0x25, 0xe6, 0x5c, 0xb8, 0xa0, 0xaf, + 0x45, 0xcc, 0x7a, 0x57, 0xb8, 0x37, 0x70, 0xa0, 0x8b, 0xe8, 0xe6, + 0xcb, 0xcc, 0xbf, 0x9, 0x78, 0x12, 0x51, 0x3c, 0x14, 0x3d}, + {0x57, 0x45, 0x15, 0x79, 0x91, 0x27, 0x6d, 0x12, 0xa, 0x3a, 0x78, + 0xfc, 0x5c, 0x8f, 0xe4, 0xd5, 0xac, 0x9b, 0x17, 0xdf, 0xe8, 0xb6, + 0xbd, 0x36, 0x59, 0x28, 0xa8, 0x5b, 0x88, 0x17, 0xf5, 0x2e}, + }, + }, + { + { + {0x51, 0x2f, 0x5b, 0x30, 0xfb, 0xbf, 0xee, 0x96, 0xb8, 0x96, 0x95, + 0x88, 0xad, 0x38, 0xf9, 0xd3, 0x25, 0xdd, 0xd5, 0x46, 0xc7, 0x2d, + 0xf5, 0xf0, 0x95, 0x0, 0x3a, 0xbb, 0x90, 0x82, 0x96, 0x57}, + {0xdc, 0xae, 0x58, 0x8c, 0x4e, 0x97, 0x37, 0x46, 0xa4, 0x41, 0xf0, + 0xab, 0xfb, 0x22, 0xef, 0xb9, 0x8a, 0x71, 0x80, 0xe9, 0x56, 0xd9, + 0x85, 0xe1, 0xa6, 0xa8, 0x43, 0xb1, 0xfa, 0x78, 0x1b, 0x2f}, + {0x1, 0xe1, 0x20, 0xa, 0x43, 0xb8, 0x1a, 0xf7, 0x47, 0xec, 0xf0, + 0x24, 0x8d, 0x65, 0x93, 0xf3, 0xd1, 0xee, 0xe2, 0x6e, 0xa8, 0x9, + 0x75, 0xcf, 0xe1, 0xa3, 0x2a, 0xdc, 0x35, 0x3e, 0xc4, 0x7d}, + }, + { + {0x18, 0x97, 0x3e, 0x27, 0x5c, 0x2a, 0x78, 0x5a, 0x94, 0xfd, 0x4e, + 0x5e, 0x99, 0xc6, 0x76, 0x35, 0x3e, 0x7d, 0x23, 0x1f, 0x5, 0xd8, + 0x2e, 0xf, 0x99, 0xa, 0xd5, 0x82, 0x1d, 0xb8, 0x4f, 0x4}, + {0xc3, 0xd9, 0x7d, 0x88, 0x65, 0x66, 0x96, 0x85, 0x55, 0x53, 0xb0, + 0x4b, 0x31, 0x9b, 0xf, 0xc9, 0xb1, 0x79, 0x20, 0xef, 0xf8, 0x8d, + 0xe0, 0xc6, 0x2f, 0xc1, 0x8c, 0x75, 0x16, 0x20, 0xf7, 0x7e}, + {0xd9, 0xe3, 0x7, 0xa9, 0xc5, 0x18, 0xdf, 0xc1, 0x59, 0x63, 0x4c, + 0xce, 0x1d, 0x37, 0xb3, 0x57, 0x49, 0xbb, 0x1, 0xb2, 0x34, 0x45, + 0x70, 0xca, 0x2e, 0xdd, 0x30, 0x9c, 0x3f, 0x82, 0x79, 0x7f}, + }, + { + {0xba, 0x87, 0xf5, 0x68, 0xf0, 0x1f, 0x9c, 0x6a, 0xde, 0xc8, 0x50, + 0x0, 0x4e, 0x89, 0x27, 0x8, 0xe7, 0x5b, 0xed, 0x7d, 0x55, 0x99, + 0xbf, 0x3c, 0xf0, 0xd6, 0x6, 0x1c, 0x43, 0xb0, 0xa9, 0x64}, + {0xe8, 0x13, 0xb5, 0xa3, 0x39, 0xd2, 0x34, 0x83, 0xd8, 0xa8, 0x1f, + 0xb9, 0xd4, 0x70, 0x36, 0xc1, 0x33, 0xbd, 0x90, 0xf5, 0x36, 0x41, + 0xb5, 0x12, 0xb4, 0xd9, 0x84, 0xd7, 0x73, 0x3, 0x4e, 0xa}, + {0x19, 0x29, 0x7d, 0x5b, 0xa1, 0xd6, 0xb3, 0x2e, 0x35, 0x82, 0x3a, + 0xd5, 0xa0, 0xf6, 0xb4, 0xb0, 0x47, 0x5d, 0xa4, 0x89, 0x43, 0xce, + 0x56, 0x71, 0x6c, 0x34, 0x18, 0xce, 0xa, 0x7d, 0x1a, 0x7}, + }, + { + {0x31, 0x44, 0xe1, 0x20, 0x52, 0x35, 0xc, 0xcc, 0x41, 0x51, 0xb1, + 0x9, 0x7, 0x95, 0x65, 0xd, 0x36, 0x5f, 0x9d, 0x20, 0x1b, 0x62, + 0xf5, 0x9a, 0xd3, 0x55, 0x77, 0x61, 0xf7, 0xbc, 0x69, 0x7c}, + {0xb, 0xba, 0x87, 0xc8, 0xaa, 0x2d, 0x7, 0xd3, 0xee, 0x62, 0xa5, + 0xbf, 0x5, 0x29, 0x26, 0x1, 0x8b, 0x76, 0xef, 0xc0, 0x2, 0x30, + 0x54, 0xcf, 0x9c, 0x7e, 0xea, 0x46, 0x71, 0xcc, 0x3b, 0x2c}, + {0x5f, 0x29, 0xe8, 0x4, 0xeb, 0xd7, 0xf0, 0x7, 0x7d, 0xf3, 0x50, + 0x2f, 0x25, 0x18, 0xdb, 0x10, 0xd7, 0x98, 0x17, 0x17, 0xa3, 0xa9, + 0x51, 0xe9, 0x1d, 0xa5, 0xac, 0x22, 0x73, 0x9a, 0x5a, 0x6f}, + }, + { + {0xbe, 0x44, 0xd9, 0xa3, 0xeb, 0xd4, 0x29, 0xe7, 0x9e, 0xaf, 0x78, + 0x80, 0x40, 0x9, 0x9e, 0x8d, 0x3, 0x9c, 0x86, 0x47, 0x7a, 0x56, + 0x25, 0x45, 0x24, 0x3b, 0x8d, 0xee, 0x80, 0x96, 0xab, 0x2}, + {0xc5, 0xc6, 0x41, 0x2f, 0xc, 0x0, 0xa1, 0x8b, 0x9b, 0xfb, 0xfe, + 0xc, 0xc1, 0x79, 0x9f, 0xc4, 0x9f, 0x1c, 0xc5, 0x3c, 0x70, 0x47, + 0xfa, 0x4e, 0xca, 0xaf, 0x47, 0xe1, 0xa2, 0x21, 0x4e, 0x49}, + {0x9a, 0xd, 0xe5, 0xdd, 0x85, 0x8a, 0xa4, 0xef, 0x49, 0xa2, 0xb9, + 0xf, 0x4e, 0x22, 0x9a, 0x21, 0xd9, 0xf6, 0x1e, 0xd9, 0x1d, 0x1f, + 0x9, 0xfa, 0x34, 0xbb, 0x46, 0xea, 0xcb, 0x76, 0x5d, 0x6b}, + }, + { + {0x22, 0x25, 0x78, 0x1e, 0x17, 0x41, 0xf9, 0xe0, 0xd3, 0x36, 0x69, + 0x3, 0x74, 0xae, 0xe6, 0xf1, 0x46, 0xc7, 0xfc, 0xd0, 0xa2, 0x3e, + 0x8b, 0x40, 0x3e, 0x31, 0xdd, 0x3, 0x9c, 0x86, 0xfb, 0x16}, + {0x94, 0xd9, 0xc, 0xec, 0x6c, 0x55, 0x57, 0x88, 0xba, 0x1d, 0xd0, + 0x5c, 0x6f, 0xdc, 0x72, 0x64, 0x77, 0xb4, 0x42, 0x8f, 0x14, 0x69, + 0x1, 0xaf, 0x54, 0x73, 0x27, 0x85, 0xf6, 0x33, 0xe3, 0xa}, + {0x62, 0x9, 0xb6, 0x33, 0x97, 0x19, 0x8e, 0x28, 0x33, 0xe1, 0xab, + 0xd8, 0xb4, 0x72, 0xfc, 0x24, 0x3e, 0xd0, 0x91, 0x9, 0xed, 0xf7, + 0x11, 0x48, 0x75, 0xd0, 0x70, 0x8f, 0x8b, 0xe3, 0x81, 0x3f}, + }, + { + {0x24, 0xc8, 0x17, 0x5f, 0x35, 0x7f, 0xdb, 0xa, 0xa4, 0x99, 0x42, + 0xd7, 0xc3, 0x23, 0xb9, 0x74, 0xf7, 0xea, 0xf8, 0xcb, 0x8b, 0x3e, + 0x7c, 0xd5, 0x3d, 0xdc, 0xde, 0x4c, 0xd3, 0xe2, 0xd3, 0xa}, + {0xfe, 0xaf, 0xd9, 0x7e, 0xcc, 0xf, 0x91, 0x7f, 0x4b, 0x87, 0x65, + 0x24, 0xa1, 0xb8, 0x5c, 0x54, 0x4, 0x47, 0xc, 0x4b, 0xd2, 0x7e, + 0x39, 0xa8, 0x93, 0x9, 0xf5, 0x4, 0xc1, 0xf, 0x51, 0x50}, + {0x9d, 0x24, 0x6e, 0x33, 0xc5, 0xf, 0xc, 0x6f, 0xd9, 0xcf, 0x31, + 0xc3, 0x19, 0xde, 0x5e, 0x74, 0x1c, 0xfe, 0xee, 0x9, 0x0, 0xfd, + 0xd6, 0xf2, 0xbe, 0x1e, 0xfa, 0xf0, 0x8b, 0x15, 0x7c, 0x12}, + }, + { + {0x74, 0xb9, 0x51, 0xae, 0xc4, 0x8f, 0xa2, 0xde, 0x96, 0xfe, 0x4d, + 0x74, 0xd3, 0x73, 0x99, 0x1d, 0xa8, 0x48, 0x38, 0x87, 0xb, 0x68, + 0x40, 0x62, 0x95, 0xdf, 0x67, 0xd1, 0x79, 0x24, 0xd8, 0x4e}, + {0xa2, 0x79, 0x98, 0x2e, 0x42, 0x7c, 0x19, 0xf6, 0x47, 0x36, 0xca, + 0x52, 0xd4, 0xdd, 0x4a, 0xa4, 0xcb, 0xac, 0x4e, 0x4b, 0xc1, 0x3f, + 0x41, 0x9b, 0x68, 0x4f, 0xef, 0x7, 0x7d, 0xf8, 0x4e, 0x35}, + {0x75, 0xd9, 0xc5, 0x60, 0x22, 0xb5, 0xe3, 0xfe, 0xb8, 0xb0, 0x41, + 0xeb, 0xfc, 0x2e, 0x35, 0x50, 0x3c, 0x65, 0xf6, 0xa9, 0x30, 0xac, + 0x8, 0x88, 0x6d, 0x23, 0x39, 0x5, 0xd2, 0x92, 0x2d, 0x30}, + }, + }, + { + { + {0x77, 0xf1, 0xe0, 0xe4, 0xb6, 0x6f, 0xbc, 0x2d, 0x93, 0x6a, 0xbd, + 0xa4, 0x29, 0xbf, 0xe1, 0x4, 0xe8, 0xf6, 0x7a, 0x78, 0xd4, 0x66, + 0x19, 0x5e, 0x60, 0xd0, 0x26, 0xb4, 0x5e, 0x5f, 0xdc, 0xe}, + {0x3d, 0x28, 0xa4, 0xbc, 0xa2, 0xc1, 0x13, 0x78, 0xd9, 0x3d, 0x86, + 0xa1, 0x91, 0xf0, 0x62, 0xed, 0x86, 0xfa, 0x68, 0xc2, 0xb8, 0xbc, + 0xc7, 0xae, 0x4c, 0xae, 0x1c, 0x6f, 0xb7, 0xd3, 0xe5, 0x10}, + {0x67, 0x8e, 0xda, 0x53, 0xd6, 0xbf, 0x53, 0x54, 0x41, 0xf6, 0xa9, + 0x24, 0xec, 0x1e, 0xdc, 0xe9, 0x23, 0x8a, 0x57, 0x3, 0x3b, 0x26, + 0x87, 0xbf, 0x72, 0xba, 0x1c, 0x36, 0x51, 0x6c, 0xb4, 0x45}, + }, + { + {0xe4, 0xe3, 0x7f, 0x8a, 0xdd, 0x4d, 0x9d, 0xce, 0x30, 0xe, 0x62, + 0x76, 0x56, 0x64, 0x13, 0xab, 0x58, 0x99, 0xe, 0xb3, 0x7b, 0x4f, + 0x59, 0x4b, 0xdf, 0x29, 0x12, 0x32, 0xef, 0xa, 0x1c, 0x5c}, + {0xa1, 0x7f, 0x4f, 0x31, 0xbf, 0x2a, 0x40, 0xa9, 0x50, 0xf4, 0x8c, + 0x8e, 0xdc, 0xf1, 0x57, 0xe2, 0x84, 0xbe, 0xa8, 0x23, 0x4b, 0xd5, + 0xbb, 0x1d, 0x3b, 0x71, 0xcb, 0x6d, 0xa3, 0xbf, 0x77, 0x21}, + {0x8f, 0xdb, 0x79, 0xfa, 0xbc, 0x1b, 0x8, 0x37, 0xb3, 0x59, 0x5f, + 0xc2, 0x1e, 0x81, 0x48, 0x60, 0x87, 0x24, 0x83, 0x9c, 0x65, 0x76, + 0x7a, 0x8, 0xbb, 0xb5, 0x8a, 0x7d, 0x38, 0x19, 0xe6, 0x4a}, + }, + { + {0x83, 0xfb, 0x5b, 0x98, 0x44, 0x7e, 0x11, 0x61, 0x36, 0x31, 0x96, + 0x71, 0x2a, 0x46, 0xe0, 0xfc, 0x4b, 0x90, 0x25, 0xd4, 0x48, 0x34, + 0xac, 0x83, 0x64, 0x3d, 0xa4, 0x5b, 0xbe, 0x5a, 0x68, 0x75}, + {0x2e, 0xa3, 0x44, 0x53, 0xaa, 0xf6, 0xdb, 0x8d, 0x78, 0x40, 0x1b, + 0xb4, 0xb4, 0xea, 0x88, 0x7d, 0x60, 0xd, 0x13, 0x4a, 0x97, 0xeb, + 0xb0, 0x5e, 0x3, 0x3e, 0xbf, 0x17, 0x1b, 0xd9, 0x0, 0x1a}, + {0xb2, 0xf2, 0x61, 0xeb, 0x33, 0x9, 0x96, 0x6e, 0x52, 0x49, 0xff, + 0xc9, 0xa8, 0xf, 0x3d, 0x54, 0x69, 0x65, 0xf6, 0x7a, 0x10, 0x75, + 0x72, 0xdf, 0xaa, 0xe6, 0xb0, 0x23, 0xb6, 0x29, 0x55, 0x13}, + }, + { + {0xfe, 0x83, 0x2e, 0xe2, 0xbc, 0x16, 0xc7, 0xf5, 0xc1, 0x85, 0x9, + 0xe8, 0x19, 0xeb, 0x2b, 0xb4, 0xae, 0x4a, 0x25, 0x14, 0x37, 0xa6, + 0x9d, 0xec, 0x13, 0xa6, 0x90, 0x15, 0x5, 0xea, 0x72, 0x59}, + {0x18, 0xd5, 0xd1, 0xad, 0xd7, 0xdb, 0xf0, 0x18, 0x11, 0x1f, 0xc1, + 0xcf, 0x88, 0x78, 0x9f, 0x97, 0x9b, 0x75, 0x14, 0x71, 0xf0, 0xe1, + 0x32, 0x87, 0x1, 0x3a, 0xca, 0x65, 0x1a, 0xb8, 0xb5, 0x79}, + {0x11, 0x78, 0x8f, 0xdc, 0x20, 0xac, 0xd4, 0xf, 0xa8, 0x4f, 0x4d, + 0xac, 0x94, 0xd2, 0x9a, 0x9a, 0x34, 0x4, 0x36, 0xb3, 0x64, 0x2d, + 0x1b, 0xc0, 0xdb, 0x3b, 0x5f, 0x90, 0x95, 0x9c, 0x7e, 0x4f}, + }, + { + {0xfe, 0x99, 0x52, 0x35, 0x3d, 0x44, 0xc8, 0x71, 0xd7, 0xea, 0xeb, + 0xdb, 0x1c, 0x3b, 0xcd, 0x8b, 0x66, 0x94, 0xa4, 0xf1, 0x9e, 0x49, + 0x92, 0x80, 0xc8, 0xad, 0x44, 0xa1, 0xc4, 0xee, 0x42, 0x19}, + {0x2e, 0x30, 0x81, 0x57, 0xbc, 0x4b, 0x67, 0x62, 0xf, 0xdc, 0xad, + 0x89, 0x39, 0xf, 0x52, 0xd8, 0xc6, 0xd9, 0xfb, 0x53, 0xae, 0x99, + 0x29, 0x8c, 0x4c, 0x8e, 0x63, 0x2e, 0xd9, 0x3a, 0x99, 0x31}, + {0x92, 0x49, 0x23, 0xae, 0x19, 0x53, 0xac, 0x7d, 0x92, 0x3e, 0xea, + 0xc, 0x91, 0x3d, 0x1b, 0x2c, 0x22, 0x11, 0x3c, 0x25, 0x94, 0xe4, + 0x3c, 0x55, 0x75, 0xca, 0xf9, 0x4e, 0x31, 0x65, 0xa, 0x2a}, + }, + { + {0x3a, 0x79, 0x1c, 0x3c, 0xcd, 0x1a, 0x36, 0xcf, 0x3b, 0xbc, 0x35, + 0x5a, 0xac, 0xbc, 0x9e, 0x2f, 0xab, 0xa6, 0xcd, 0xa8, 0xe9, 0x60, + 0xe8, 0x60, 0x13, 0x1a, 0xea, 0x6d, 0x9b, 0xc3, 0x5d, 0x5}, + {0xc2, 0x27, 0xf9, 0xf7, 0x7f, 0x93, 0xb7, 0x2d, 0x35, 0xa6, 0xd0, + 0x17, 0x6, 0x1f, 0x74, 0xdb, 0x76, 0xaf, 0x55, 0x11, 0xa2, 0xf3, + 0x82, 0x59, 0xed, 0x2d, 0x7c, 0x64, 0x18, 0xe2, 0xf6, 0x4c}, + {0xb6, 0x5b, 0x8d, 0xc2, 0x7c, 0x22, 0x19, 0xb1, 0xab, 0xff, 0x4d, + 0x77, 0xbc, 0x4e, 0xe2, 0x7, 0x89, 0x2c, 0xa3, 0xe4, 0xce, 0x78, + 0x3c, 0xa8, 0xb6, 0x24, 0xaa, 0x10, 0x77, 0x30, 0x1a, 0x12}, + }, + { + {0xc9, 0x83, 0x74, 0xc7, 0x3e, 0x71, 0x59, 0xd6, 0xaf, 0x96, 0x2b, + 0xb8, 0x77, 0xe0, 0xbf, 0x88, 0xd3, 0xbc, 0x97, 0x10, 0x23, 0x28, + 0x9e, 0x28, 0x9b, 0x3a, 0xed, 0x6c, 0x4a, 0xb9, 0x7b, 0x52}, + {0x97, 0x4a, 0x3, 0x9f, 0x5e, 0x5d, 0xdb, 0xe4, 0x2d, 0xbc, 0x34, + 0x30, 0x9, 0xfc, 0x53, 0xe1, 0xb1, 0xd3, 0x51, 0x95, 0x91, 0x46, + 0x5, 0x46, 0x2d, 0xe5, 0x40, 0x7a, 0x6c, 0xc7, 0x3f, 0x33}, + {0x2e, 0x48, 0x5b, 0x99, 0x2a, 0x99, 0x3d, 0x56, 0x1, 0x38, 0x38, + 0x6e, 0x7c, 0xd0, 0x5, 0x34, 0xe5, 0xd8, 0x64, 0x2f, 0xde, 0x35, + 0x50, 0x48, 0xf7, 0xa9, 0xa7, 0x20, 0x9b, 0x6, 0x89, 0x6b}, + }, + { + {0x77, 0xdb, 0xc7, 0xb5, 0x8c, 0xfa, 0x82, 0x40, 0x55, 0xc1, 0x34, + 0xc7, 0xf8, 0x86, 0x86, 0x6, 0x7e, 0xa5, 0xe7, 0xf6, 0xd9, 0xc8, + 0xe6, 0x29, 0xcf, 0x9b, 0x63, 0xa7, 0x8, 0xd3, 0x73, 0x4}, + {0xd, 0x22, 0x70, 0x62, 0x41, 0xa0, 0x2a, 0x81, 0x4e, 0x5b, 0x24, + 0xf9, 0xfa, 0x89, 0x5a, 0x99, 0x5, 0xef, 0x72, 0x50, 0xce, 0xc4, + 0xad, 0xff, 0x73, 0xeb, 0x73, 0xaa, 0x3, 0x21, 0xbc, 0x23}, + {0x5, 0x9e, 0x58, 0x3, 0x26, 0x79, 0xee, 0xca, 0x92, 0xc4, 0xdc, + 0x46, 0x12, 0x42, 0x4b, 0x2b, 0x4f, 0xa9, 0x1, 0xe6, 0x74, 0xef, + 0xa1, 0x2, 0x1a, 0x34, 0x4, 0xde, 0xbf, 0x73, 0x2f, 0x10}, + }, + }, + { + { + {0x9a, 0x1c, 0x51, 0xb5, 0xe0, 0xda, 0xb4, 0xa2, 0x6, 0xff, 0xff, + 0x2b, 0x29, 0x60, 0xc8, 0x7a, 0x34, 0x42, 0x50, 0xf5, 0x5d, 0x37, + 0x1f, 0x98, 0x2d, 0xa1, 0x4e, 0xda, 0x25, 0xd7, 0x6b, 0x3f}, + {0xc6, 0x45, 0x57, 0x7f, 0xab, 0xb9, 0x18, 0xeb, 0x90, 0xc6, 0x87, + 0x57, 0xee, 0x8a, 0x3a, 0x2, 0xa9, 0xaf, 0xf7, 0x2d, 0xda, 0x12, + 0x27, 0xb7, 0x3d, 0x1, 0x5c, 0xea, 0x25, 0x7d, 0x59, 0x36}, + {0xac, 0x58, 0x60, 0x10, 0x7b, 0x8d, 0x4d, 0x73, 0x5f, 0x90, 0xc6, + 0x6f, 0x9e, 0x57, 0x40, 0xd9, 0x2d, 0x93, 0x2, 0x92, 0xf9, 0xf8, + 0x66, 0x64, 0xd0, 0xd6, 0x60, 0xda, 0x19, 0xcc, 0x7e, 0x7b}, + }, + { + {0x9b, 0xfa, 0x7c, 0xa7, 0x51, 0x4a, 0xae, 0x6d, 0x50, 0x86, 0xa3, + 0xe7, 0x54, 0x36, 0x26, 0x82, 0xdb, 0x82, 0x2d, 0x8f, 0xcd, 0xff, + 0xbb, 0x9, 0xba, 0xca, 0xf5, 0x1b, 0x66, 0xdc, 0xbe, 0x3}, + {0xd, 0x69, 0x5c, 0x69, 0x3c, 0x37, 0xc2, 0x78, 0x6e, 0x90, 0x42, + 0x6, 0x66, 0x2e, 0x25, 0xdd, 0xd2, 0x2b, 0xe1, 0x4a, 0x44, 0x44, + 0x1d, 0x95, 0x56, 0x39, 0x74, 0x1, 0x76, 0xad, 0x35, 0x42}, + {0xf5, 0x75, 0x89, 0x7, 0xd, 0xcb, 0x58, 0x62, 0x98, 0xf2, 0x89, + 0x91, 0x54, 0x42, 0x29, 0x49, 0xe4, 0x6e, 0xe3, 0xe2, 0x23, 0xb4, + 0xca, 0xa0, 0xa1, 0x66, 0xf0, 0xcd, 0xb0, 0xe2, 0x7c, 0xe}, + }, + { + {0xf9, 0x70, 0x4b, 0xd9, 0xdf, 0xfe, 0xa6, 0xfe, 0x2d, 0xba, 0xfc, + 0xc1, 0x51, 0xc0, 0x30, 0xf1, 0x89, 0xab, 0x2f, 0x7f, 0x7e, 0xd4, + 0x82, 0x48, 0xb5, 0xee, 0xec, 0x8a, 0x13, 0x56, 0x52, 0x61}, + {0xa3, 0x85, 0x8c, 0xc4, 0x3a, 0x64, 0x94, 0xc4, 0xad, 0x39, 0x61, + 0x3c, 0xf4, 0x1d, 0x36, 0xfd, 0x48, 0x4d, 0xe9, 0x3a, 0xdd, 0x17, + 0xdb, 0x9, 0x4a, 0x67, 0xb4, 0x8f, 0x5d, 0xa, 0x6e, 0x66}, + {0xd, 0xcb, 0x70, 0x48, 0x4e, 0xf6, 0xbb, 0x2a, 0x6b, 0x8b, 0x45, + 0xaa, 0xf0, 0xbc, 0x65, 0xcd, 0x5d, 0x98, 0xe8, 0x75, 0xba, 0x4e, + 0xbe, 0x9a, 0xe4, 0xde, 0x14, 0xd5, 0x10, 0xc8, 0xb, 0x7f}, + }, + { + {0xa0, 0x13, 0x72, 0x73, 0xad, 0x9d, 0xac, 0x83, 0x98, 0x2e, 0xf7, + 0x2e, 0xba, 0xf8, 0xf6, 0x9f, 0x57, 0x69, 0xec, 0x43, 0xdd, 0x2e, + 0x1e, 0x31, 0x75, 0xab, 0xc5, 0xde, 0x7d, 0x90, 0x3a, 0x1d}, + {0x6f, 0x13, 0xf4, 0x26, 0xa4, 0x6b, 0x0, 0xb9, 0x35, 0x30, 0xe0, + 0x57, 0x9e, 0x36, 0x67, 0x8d, 0x28, 0x3c, 0x46, 0x4f, 0xd9, 0xdf, + 0xc8, 0xcb, 0xf5, 0xdb, 0xee, 0xf8, 0xbc, 0x8d, 0x1f, 0xd}, + {0xdc, 0x81, 0xd0, 0x3e, 0x31, 0x93, 0x16, 0xba, 0x80, 0x34, 0x1b, + 0x85, 0xad, 0x9f, 0x32, 0x29, 0xcb, 0x21, 0x3, 0x3, 0x3c, 0x1, + 0x28, 0x1, 0xe3, 0xfd, 0x1b, 0xa3, 0x44, 0x1b, 0x1, 0x0}, + }, + { + {0x5c, 0xa7, 0xa, 0x6a, 0x69, 0x1f, 0x56, 0x16, 0x6a, 0xbd, 0x52, + 0x58, 0x5c, 0x72, 0xbf, 0xc1, 0xad, 0x66, 0x79, 0x9a, 0x7f, 0xdd, + 0xa8, 0x11, 0x26, 0x10, 0x85, 0xd2, 0xa2, 0x88, 0xd9, 0x63}, + {0xc, 0x6c, 0xc6, 0x3f, 0x6c, 0xa0, 0xdf, 0x3f, 0xd2, 0xd, 0xd6, + 0x4d, 0x8e, 0xe3, 0x40, 0x5d, 0x71, 0x4d, 0x8e, 0x26, 0x38, 0x8b, + 0xe3, 0x7a, 0xe1, 0x57, 0x83, 0x6e, 0x91, 0x8d, 0xc4, 0x3a}, + {0x2e, 0x23, 0xbd, 0xaf, 0x53, 0x7, 0x12, 0x0, 0x83, 0xf6, 0xd8, + 0xfd, 0xb8, 0xce, 0x2b, 0xe9, 0x91, 0x2b, 0xe7, 0x84, 0xb3, 0x69, + 0x16, 0xf8, 0x66, 0xa0, 0x68, 0x23, 0x2b, 0xd5, 0xfa, 0x33}, + }, + { + {0xe8, 0xcf, 0x22, 0xc4, 0xd0, 0xc8, 0x2c, 0x8d, 0xcb, 0x3a, 0xa1, + 0x5, 0x7b, 0x4f, 0x2b, 0x7, 0x6f, 0xa5, 0xf6, 0xec, 0xe6, 0xb6, + 0xfe, 0xa3, 0xe2, 0x71, 0xa, 0xb9, 0xcc, 0x55, 0xc3, 0x3c}, + {0x16, 0x1e, 0xe4, 0xc5, 0xc6, 0x49, 0x6, 0x54, 0x35, 0x77, 0x3f, + 0x33, 0x30, 0x64, 0xf8, 0xa, 0x46, 0xe7, 0x5, 0xf3, 0xd2, 0xfc, + 0xac, 0xb2, 0xa7, 0xdc, 0x56, 0xa2, 0x29, 0xf4, 0xc0, 0x16}, + {0x31, 0x91, 0x3e, 0x90, 0x43, 0x94, 0xb6, 0xe9, 0xce, 0x37, 0x56, + 0x7a, 0xcb, 0x94, 0xa4, 0xb8, 0x44, 0x92, 0xba, 0xba, 0xa4, 0xd1, + 0x7c, 0xc8, 0x68, 0x75, 0xae, 0x6b, 0x42, 0xaf, 0x1e, 0x63}, + }, + { + {0xe8, 0xd, 0x70, 0xa3, 0xb9, 0x75, 0xd9, 0x47, 0x52, 0x5, 0xf8, + 0xe2, 0xfb, 0xc5, 0x80, 0x72, 0xe1, 0x5d, 0xe4, 0x32, 0x27, 0x8f, + 0x65, 0x53, 0xb5, 0x80, 0x5f, 0x66, 0x7f, 0x2c, 0x1f, 0x43}, + {0x9f, 0xfe, 0x66, 0xda, 0x10, 0x4, 0xe9, 0xb3, 0xa6, 0xe5, 0x16, + 0x6c, 0x52, 0x4b, 0xdd, 0x85, 0x83, 0xbf, 0xf9, 0x1e, 0x61, 0x97, + 0x3d, 0xbc, 0xb5, 0x19, 0xa9, 0x1e, 0x8b, 0x64, 0x99, 0x55}, + {0x19, 0x7b, 0x8f, 0x85, 0x44, 0x63, 0x2, 0xd6, 0x4a, 0x51, 0xea, + 0xa1, 0x2f, 0x35, 0xab, 0x14, 0xd7, 0xa9, 0x90, 0x20, 0x1a, 0x44, + 0x0, 0x89, 0x26, 0x3b, 0x25, 0x91, 0x5f, 0x71, 0x4, 0x7b}, + }, + { + {0xc6, 0xba, 0xe6, 0xc4, 0x80, 0xc2, 0x76, 0xb3, 0xb, 0x9b, 0x1d, + 0x6d, 0xdd, 0xd3, 0xe, 0x97, 0x44, 0xf9, 0xb, 0x45, 0x58, 0x95, + 0x9a, 0xb0, 0x23, 0xe2, 0xcd, 0x57, 0xfa, 0xac, 0xd0, 0x48}, + {0x43, 0xae, 0xf6, 0xac, 0x28, 0xbd, 0xed, 0x83, 0xb4, 0x7a, 0x5c, + 0x7d, 0x8b, 0x7c, 0x35, 0x86, 0x44, 0x2c, 0xeb, 0xb7, 0x69, 0x47, + 0x40, 0xc0, 0x3f, 0x58, 0xf6, 0xc2, 0xf5, 0x7b, 0xb3, 0x59}, + {0x71, 0xe6, 0xab, 0x7d, 0xe4, 0x26, 0xf, 0xb6, 0x37, 0x3a, 0x2f, + 0x62, 0x97, 0xa1, 0xd1, 0xf1, 0x94, 0x3, 0x96, 0xe9, 0x7e, 0xce, + 0x8, 0x42, 0xdb, 0x3b, 0x6d, 0x33, 0x91, 0x41, 0x23, 0x16}, + }, + }, + { + { + {0x40, 0x86, 0xf3, 0x1f, 0xd6, 0x9c, 0x49, 0xdd, 0xa0, 0x25, 0x36, + 0x6, 0xc3, 0x9b, 0xcd, 0x29, 0xc3, 0x3d, 0xd7, 0x3d, 0x2, 0xd8, + 0xe2, 0x51, 0x31, 0x92, 0x3b, 0x20, 0x7a, 0x70, 0x25, 0x4a}, + {0xf6, 0x7f, 0x26, 0xf6, 0xde, 0x99, 0xe4, 0xb9, 0x43, 0x8, 0x2c, + 0x74, 0x7b, 0xca, 0x72, 0x77, 0xb1, 0xf2, 0xa4, 0xe9, 0x3f, 0x15, + 0xa0, 0x23, 0x6, 0x50, 0xd0, 0xd5, 0xec, 0xdf, 0xdf, 0x2c}, + {0x6a, 0xed, 0xf6, 0x53, 0x8a, 0x66, 0xb7, 0x2a, 0xa1, 0x70, 0xd1, + 0x1d, 0x58, 0x42, 0x42, 0x30, 0x61, 0x1, 0xe2, 0x3a, 0x4c, 0x14, + 0x0, 0x40, 0xfc, 0x49, 0x8e, 0x24, 0x6d, 0x89, 0x21, 0x57}, + }, + { + {0x4e, 0xda, 0xd0, 0xa1, 0x91, 0x50, 0x5d, 0x28, 0x8, 0x3e, 0xfe, + 0xb5, 0xa7, 0x6f, 0xaa, 0x4b, 0xb3, 0x93, 0x93, 0xe1, 0x7c, 0x17, + 0xe5, 0x63, 0xfd, 0x30, 0xb0, 0xc4, 0xaf, 0x35, 0xc9, 0x3}, + {0xae, 0x1b, 0x18, 0xfd, 0x17, 0x55, 0x6e, 0xb, 0xb4, 0x63, 0xb9, + 0x2b, 0x9f, 0x62, 0x22, 0x90, 0x25, 0x46, 0x6, 0x32, 0xe9, 0xbc, + 0x9, 0x55, 0xda, 0x13, 0x3c, 0xf6, 0x74, 0xdd, 0x8e, 0x57}, + {0x3d, 0xc, 0x2b, 0x49, 0xc6, 0x76, 0x72, 0x99, 0xfc, 0x5, 0xe2, + 0xdf, 0xc4, 0xc2, 0xcc, 0x47, 0x3c, 0x3a, 0x62, 0xdd, 0x84, 0x9b, + 0xd2, 0xdc, 0xa2, 0xc7, 0x88, 0x2, 0x59, 0xab, 0xc2, 0x3e}, + }, + { + {0xcb, 0xd1, 0x32, 0xae, 0x9, 0x3a, 0x21, 0xa7, 0xd5, 0xc2, 0xf5, + 0x40, 0xdf, 0x87, 0x2b, 0xf, 0x29, 0xab, 0x1e, 0xe8, 0xc6, 0xa4, + 0xae, 0xb, 0x5e, 0xac, 0xdb, 0x6a, 0x6c, 0xf6, 0x1b, 0xe}, + {0xb9, 0x7b, 0xd8, 0xe4, 0x7b, 0xd2, 0xa0, 0xa1, 0xed, 0x1a, 0x39, + 0x61, 0xeb, 0x4d, 0x8b, 0xa9, 0x83, 0x9b, 0xcb, 0x73, 0xd0, 0xdd, + 0xa0, 0x99, 0xce, 0xca, 0xf, 0x20, 0x5a, 0xc2, 0xd5, 0x2d}, + {0x7e, 0x88, 0x2c, 0x79, 0xe9, 0xd5, 0xab, 0xe2, 0x5d, 0x6d, 0x92, + 0xcb, 0x18, 0x0, 0x2, 0x1a, 0x1e, 0x5f, 0xae, 0xba, 0xcd, 0x69, + 0xba, 0xbf, 0x5f, 0x8f, 0xe8, 0x5a, 0xb3, 0x48, 0x5, 0x73}, + }, + { + {0x34, 0xe3, 0xd6, 0xa1, 0x4b, 0x9, 0x5b, 0x80, 0x19, 0x3f, 0x35, + 0x9, 0x77, 0xf1, 0x3e, 0xbf, 0x2b, 0x70, 0x22, 0x6, 0xcb, 0x6, + 0x3f, 0x42, 0xdd, 0x45, 0x78, 0xd8, 0x77, 0x22, 0x5a, 0x58}, + {0xee, 0xb8, 0xa8, 0xcb, 0xa3, 0x51, 0x35, 0xc4, 0x16, 0x5f, 0x11, + 0xb2, 0x1d, 0x6f, 0xa2, 0x65, 0x50, 0x38, 0x8c, 0xab, 0x52, 0x4f, + 0xf, 0x76, 0xca, 0xb8, 0x1d, 0x41, 0x3b, 0x44, 0x43, 0x30}, + {0x62, 0x89, 0xd4, 0x33, 0x82, 0x5f, 0x8a, 0xa1, 0x7f, 0x25, 0x78, + 0xec, 0xb5, 0xc4, 0x98, 0x66, 0xff, 0x41, 0x3e, 0x37, 0xa5, 0x6f, + 0x8e, 0xa7, 0x1f, 0x98, 0xef, 0x50, 0x89, 0x27, 0x56, 0x76}, + }, + { + {0x9d, 0xcf, 0x86, 0xea, 0xa3, 0x73, 0x70, 0xe1, 0xdc, 0x5f, 0x15, + 0x7, 0xb7, 0xfb, 0x8c, 0x3a, 0x8e, 0x8a, 0x83, 0x31, 0xfc, 0xe7, + 0x53, 0x48, 0x16, 0xf6, 0x13, 0xb6, 0x84, 0xf4, 0xbb, 0x28}, + {0xc0, 0xc8, 0x1f, 0xd5, 0x59, 0xcf, 0xc3, 0x38, 0xf2, 0xb6, 0x6, + 0x5, 0xfd, 0xd2, 0xed, 0x9b, 0x8f, 0xe, 0x57, 0xab, 0x9f, 0x10, + 0xbf, 0x26, 0xa6, 0x46, 0xb8, 0xc1, 0xa8, 0x60, 0x41, 0x3f}, + {0x7c, 0x6c, 0x13, 0x6f, 0x5c, 0x2f, 0x61, 0xf2, 0xbe, 0x11, 0xdd, + 0xf6, 0x7, 0xd1, 0xea, 0xaf, 0x33, 0x6f, 0xde, 0x13, 0xd2, 0x9a, + 0x7e, 0x52, 0x5d, 0xf7, 0x88, 0x81, 0x35, 0xcb, 0x79, 0x1e}, + }, + { + {0x81, 0x81, 0xe0, 0xf5, 0xd8, 0x53, 0xe9, 0x77, 0xd9, 0xde, 0x9d, + 0x29, 0x44, 0xc, 0xa5, 0x84, 0xe5, 0x25, 0x45, 0x86, 0xc, 0x2d, + 0x6c, 0xdc, 0xf4, 0xf2, 0xd1, 0x39, 0x2d, 0xb5, 0x8a, 0x47}, + {0xf1, 0xe3, 0xf7, 0xee, 0xc3, 0x36, 0x34, 0x1, 0xf8, 0x10, 0x9e, + 0xfe, 0x7f, 0x6a, 0x8b, 0x82, 0xfc, 0xde, 0xf9, 0xbc, 0xe5, 0x8, + 0xf9, 0x7f, 0x31, 0x38, 0x3b, 0x3a, 0x1b, 0x95, 0xd7, 0x65}, + {0x59, 0xd1, 0x52, 0x92, 0xd3, 0xa4, 0xa6, 0x66, 0x7, 0xc8, 0x1a, + 0x87, 0xbc, 0xe1, 0xdd, 0xe5, 0x6f, 0xc9, 0xc1, 0xa6, 0x40, 0x6b, + 0x2c, 0xb8, 0x14, 0x22, 0x21, 0x1a, 0x41, 0x7a, 0xd8, 0x16}, + }, + { + {0x83, 0x5, 0x4e, 0xd5, 0xe2, 0xd5, 0xa4, 0xfb, 0xfa, 0x99, 0xbd, + 0x2e, 0xd7, 0xaf, 0x1f, 0xe2, 0x8f, 0x77, 0xe9, 0x6e, 0x73, 0xc2, + 0x7a, 0x49, 0xde, 0x6d, 0x5a, 0x7a, 0x57, 0xb, 0x99, 0x1f}, + {0x15, 0x62, 0x6, 0x42, 0x5a, 0x7e, 0xbd, 0xb3, 0xc1, 0x24, 0x5a, + 0xc, 0xcd, 0xe3, 0x9b, 0x87, 0xb7, 0x94, 0xf9, 0xd6, 0xb1, 0x5d, + 0xc0, 0x57, 0xa6, 0x8c, 0xf3, 0x65, 0x81, 0x7c, 0xf8, 0x28}, + {0xd6, 0xf7, 0xe8, 0x1b, 0xad, 0x4e, 0x34, 0xa3, 0x8f, 0x79, 0xea, + 0xac, 0xeb, 0x50, 0x1e, 0x7d, 0x52, 0xe0, 0xd, 0x52, 0x9e, 0x56, + 0xc6, 0x77, 0x3e, 0x6d, 0x4d, 0x53, 0xe1, 0x2f, 0x88, 0x45}, + }, + { + {0xe4, 0x6f, 0x3c, 0x94, 0x29, 0x99, 0xac, 0xd8, 0xa2, 0x92, 0x83, + 0xa3, 0x61, 0xf1, 0xf9, 0xb5, 0xf3, 0x9a, 0xc8, 0xbe, 0x13, 0xdb, + 0x99, 0x26, 0x74, 0xf0, 0x5, 0xe4, 0x3c, 0x84, 0xcf, 0x7d}, + {0xd6, 0x83, 0x79, 0x75, 0x5d, 0x34, 0x69, 0x66, 0xa6, 0x11, 0xaa, + 0x17, 0x11, 0xed, 0xb6, 0x62, 0x8f, 0x12, 0x5e, 0x98, 0x57, 0x18, + 0xdd, 0x7d, 0xdd, 0xf6, 0x26, 0xf6, 0xb8, 0xe5, 0x8f, 0x68}, + {0xc0, 0x32, 0x47, 0x4a, 0x48, 0xd6, 0x90, 0x6c, 0x99, 0x32, 0x56, + 0xca, 0xfd, 0x43, 0x21, 0xd5, 0xe1, 0xc6, 0x5d, 0x91, 0xc3, 0x28, + 0xbe, 0xb3, 0x1b, 0x19, 0x27, 0x73, 0x7e, 0x68, 0x39, 0x67}, + }, + }, + { + { + {0xc0, 0x1a, 0xc, 0xc8, 0x9d, 0xcc, 0x6d, 0xa6, 0x36, 0xa4, 0x38, + 0x1b, 0xf4, 0x5c, 0xa0, 0x97, 0xc6, 0xd7, 0xdb, 0x95, 0xbe, 0xf3, + 0xeb, 0xa7, 0xab, 0x7d, 0x7e, 0x8d, 0xf6, 0xb8, 0xa0, 0x7d}, + {0xa6, 0x75, 0x56, 0x38, 0x14, 0x20, 0x78, 0xef, 0xe8, 0xa9, 0xfd, + 0xaa, 0x30, 0x9f, 0x64, 0xa2, 0xcb, 0xa8, 0xdf, 0x5c, 0x50, 0xeb, + 0xd1, 0x4c, 0xb3, 0xc0, 0x4d, 0x1d, 0xba, 0x5a, 0x11, 0x46}, + {0x76, 0xda, 0xb5, 0xc3, 0x53, 0x19, 0xf, 0xd4, 0x9b, 0x9e, 0x11, + 0x21, 0x73, 0x6f, 0xac, 0x1d, 0x60, 0x59, 0xb2, 0xfe, 0x21, 0x60, + 0xcc, 0x3, 0x4b, 0x4b, 0x67, 0x83, 0x7e, 0x88, 0x5f, 0x5a}, + }, + { + {0xb9, 0x43, 0xa6, 0xa0, 0xd3, 0x28, 0x96, 0x9e, 0x64, 0x20, 0xc3, + 0xe6, 0x0, 0xcb, 0xc3, 0xb5, 0x32, 0xec, 0x2d, 0x7c, 0x89, 0x2, + 0x53, 0x9b, 0xc, 0xc7, 0xd1, 0xd5, 0xe2, 0x7a, 0xe3, 0x43}, + {0x11, 0x3d, 0xa1, 0x70, 0xcf, 0x1, 0x63, 0x8f, 0xc4, 0xd0, 0xd, + 0x35, 0x15, 0xb8, 0xce, 0xcf, 0x7e, 0xa4, 0xbc, 0xa4, 0xd4, 0x97, + 0x2, 0xf7, 0x34, 0x14, 0x4d, 0xe4, 0x56, 0xb6, 0x69, 0x36}, + {0x33, 0xe1, 0xa6, 0xed, 0x6, 0x3f, 0x7e, 0x38, 0xc0, 0x3a, 0xa1, + 0x99, 0x51, 0x1d, 0x30, 0x67, 0x11, 0x38, 0x26, 0x36, 0xf8, 0xd8, + 0x5a, 0xbd, 0xbe, 0xe9, 0xd5, 0x4f, 0xcd, 0xe6, 0x21, 0x6a}, + }, + { + {0xe3, 0xb2, 0x99, 0x66, 0x12, 0x29, 0x41, 0xef, 0x1, 0x13, 0x8d, + 0x70, 0x47, 0x8, 0xd3, 0x71, 0xbd, 0xb0, 0x82, 0x11, 0xd0, 0x32, + 0x54, 0x32, 0x36, 0x8b, 0x1e, 0x0, 0x7, 0x1b, 0x37, 0x45}, + {0x5f, 0xe6, 0x46, 0x30, 0xa, 0x17, 0xc6, 0xf1, 0x24, 0x35, 0xd2, + 0x0, 0x2a, 0x2a, 0x71, 0x58, 0x55, 0xb7, 0x82, 0x8c, 0x3c, 0xbd, + 0xdb, 0x69, 0x57, 0xff, 0x95, 0xa1, 0xf1, 0xf9, 0x6b, 0x58}, + {0xb, 0x79, 0xf8, 0x5e, 0x8d, 0x8, 0xdb, 0xa6, 0xe5, 0x37, 0x9, + 0x61, 0xdc, 0xf0, 0x78, 0x52, 0xb8, 0x6e, 0xa1, 0x61, 0xd2, 0x49, + 0x3, 0xac, 0x79, 0x21, 0xe5, 0x90, 0x37, 0xb0, 0xaf, 0xe}, + }, + { + {0x1d, 0xae, 0x75, 0xf, 0x5e, 0x80, 0x40, 0x51, 0x30, 0xcc, 0x62, + 0x26, 0xe3, 0xfb, 0x2, 0xec, 0x6d, 0x39, 0x92, 0xea, 0x1e, 0xdf, + 0xeb, 0x2c, 0xb3, 0x5b, 0x43, 0xc5, 0x44, 0x33, 0xae, 0x44}, + {0x2f, 0x4, 0x48, 0x37, 0xc1, 0x55, 0x5, 0x96, 0x11, 0xaa, 0xb, + 0x82, 0xe6, 0x41, 0x9a, 0x21, 0xc, 0x6d, 0x48, 0x73, 0x38, 0xf7, + 0x81, 0x1c, 0x61, 0xc6, 0x2, 0x5a, 0x67, 0xcc, 0x9a, 0x30}, + {0xee, 0x43, 0xa5, 0xbb, 0xb9, 0x89, 0xf2, 0x9c, 0x42, 0x71, 0xc9, + 0x5a, 0x9d, 0xe, 0x76, 0xf3, 0xaa, 0x60, 0x93, 0x4f, 0xc6, 0xe5, + 0x82, 0x1d, 0x8f, 0x67, 0x94, 0x7f, 0x1b, 0x22, 0xd5, 0x62}, + }, + { + {0x3c, 0x7a, 0xf7, 0x3a, 0x26, 0xd4, 0x85, 0x75, 0x4d, 0x14, 0xe9, + 0xfe, 0x11, 0x7b, 0xae, 0xdf, 0x3d, 0x19, 0xf7, 0x59, 0x80, 0x70, + 0x6, 0xa5, 0x37, 0x20, 0x92, 0x83, 0x53, 0x9a, 0xf2, 0x14}, + {0x6d, 0x93, 0xd0, 0x18, 0x9c, 0x29, 0x4c, 0x52, 0xc, 0x1a, 0xc, + 0x8a, 0x6c, 0xb5, 0x6b, 0xc8, 0x31, 0x86, 0x4a, 0xdb, 0x2e, 0x5, + 0x75, 0xa3, 0x62, 0x45, 0x75, 0xbc, 0xe4, 0xfd, 0xe, 0x5c}, + {0xf5, 0xd7, 0xb2, 0x25, 0xdc, 0x7e, 0x71, 0xdf, 0x40, 0x30, 0xb5, + 0x99, 0xdb, 0x70, 0xf9, 0x21, 0x62, 0x4c, 0xed, 0xc3, 0xb7, 0x34, + 0x92, 0xda, 0x3e, 0x9, 0xee, 0x7b, 0x5c, 0x36, 0x72, 0x5e}, + }, + { + {0x3e, 0xb3, 0x8, 0x2f, 0x6, 0x39, 0x93, 0x7d, 0xbe, 0x32, 0x9f, + 0xdf, 0xe5, 0x59, 0x96, 0x5b, 0xfd, 0xbd, 0x9e, 0x1f, 0xad, 0x3d, + 0xff, 0xac, 0xb7, 0x49, 0x73, 0xcb, 0x55, 0x5, 0xb2, 0x70}, + {0x7f, 0x21, 0x71, 0x45, 0x7, 0xfc, 0x5b, 0x57, 0x5b, 0xd9, 0x94, + 0x6, 0x5d, 0x67, 0x79, 0x37, 0x33, 0x1e, 0x19, 0xf4, 0xbb, 0x37, + 0xa, 0x9a, 0xbc, 0xea, 0xb4, 0x47, 0x4c, 0x10, 0xf1, 0x77}, + {0x4c, 0x2c, 0x11, 0x55, 0xc5, 0x13, 0x51, 0xbe, 0xcd, 0x1f, 0x88, + 0x9a, 0x3a, 0x42, 0x88, 0x66, 0x47, 0x3b, 0x50, 0x5e, 0x85, 0x77, + 0x66, 0x44, 0x4a, 0x40, 0x6, 0x4a, 0x8f, 0x39, 0x34, 0xe}, + }, + { + {0x28, 0x19, 0x4b, 0x3e, 0x9, 0xb, 0x93, 0x18, 0x40, 0xf6, 0xf3, + 0x73, 0xe, 0xe1, 0xe3, 0x7d, 0x6f, 0x5d, 0x39, 0x73, 0xda, 0x17, + 0x32, 0xf4, 0x3e, 0x9c, 0x37, 0xca, 0xd6, 0xde, 0x8a, 0x6f}, + {0xe8, 0xbd, 0xce, 0x3e, 0xd9, 0x22, 0x7d, 0xb6, 0x7, 0x2f, 0x82, + 0x27, 0x41, 0xe8, 0xb3, 0x9, 0x8d, 0x6d, 0x5b, 0xb0, 0x1f, 0xa6, + 0x3f, 0x74, 0x72, 0x23, 0x36, 0x8a, 0x36, 0x5, 0x54, 0x5e}, + {0x9a, 0xb2, 0xb7, 0xfd, 0x3d, 0x12, 0x40, 0xe3, 0x91, 0xb2, 0x1a, + 0xa2, 0xe1, 0x97, 0x7b, 0x48, 0x9e, 0x94, 0xe6, 0xfd, 0x2, 0x7d, + 0x96, 0xf9, 0x97, 0xde, 0xd3, 0xc8, 0x2e, 0xe7, 0xd, 0x78}, + }, + { + {0x72, 0x27, 0xf4, 0x0, 0xf3, 0xea, 0x1f, 0x67, 0xaa, 0x41, 0x8c, + 0x2a, 0x2a, 0xeb, 0x72, 0x8f, 0x92, 0x32, 0x37, 0x97, 0xd7, 0x7f, + 0xa1, 0x29, 0xa6, 0x87, 0xb5, 0x32, 0xad, 0xc6, 0xef, 0x1d}, + {0xbc, 0xe7, 0x9a, 0x8, 0x45, 0x85, 0xe2, 0xa, 0x6, 0x4d, 0x7f, + 0x1c, 0xcf, 0xde, 0x8d, 0x38, 0xb8, 0x11, 0x48, 0xa, 0x51, 0x15, + 0xac, 0x38, 0xe4, 0x8c, 0x92, 0x71, 0xf6, 0x8b, 0xb2, 0xe}, + {0xa7, 0x95, 0x51, 0xef, 0x1a, 0xbe, 0x5b, 0xaf, 0xed, 0x15, 0x7b, + 0x91, 0x77, 0x12, 0x8c, 0x14, 0x2e, 0xda, 0xe5, 0x7a, 0xfb, 0xf7, + 0x91, 0x29, 0x67, 0x28, 0xdd, 0xf8, 0x1b, 0x20, 0x7d, 0x46}, + }, + }, + { + { + {0xa9, 0xe7, 0x7a, 0x56, 0xbd, 0xf4, 0x1e, 0xbc, 0xbd, 0x98, 0x44, + 0xd6, 0xb2, 0x4c, 0x62, 0x3f, 0xc8, 0x4e, 0x1f, 0x2c, 0xd2, 0x64, + 0x10, 0xe4, 0x1, 0x40, 0x38, 0xba, 0xa5, 0xc5, 0xf9, 0x2e}, + {0xad, 0x4f, 0xef, 0x74, 0x9a, 0x91, 0xfe, 0x95, 0xa2, 0x8, 0xa3, + 0xf6, 0xec, 0x7b, 0x82, 0x3a, 0x1, 0x7b, 0xa4, 0x9, 0xd3, 0x1, + 0x4e, 0x96, 0x97, 0xc7, 0xa3, 0x5b, 0x4f, 0x3c, 0xc4, 0x71}, + {0xcd, 0x74, 0x9e, 0xfa, 0xf6, 0x6d, 0xfd, 0xb6, 0x7a, 0x26, 0xaf, + 0xe4, 0xbc, 0x78, 0x82, 0xf1, 0xe, 0x99, 0xef, 0xf1, 0xd0, 0xb3, + 0x55, 0x82, 0x93, 0xf2, 0xc5, 0x90, 0xa3, 0x8c, 0x75, 0x5a}, + }, + { + {0x94, 0xdc, 0x61, 0x1d, 0x8b, 0x91, 0xe0, 0x8c, 0x66, 0x30, 0x81, + 0x9a, 0x46, 0x36, 0xed, 0x8d, 0xd3, 0xaa, 0xe8, 0xaf, 0x29, 0xa8, + 0xe6, 0xd4, 0x3f, 0xd4, 0x39, 0xf6, 0x27, 0x80, 0x73, 0xa}, + {0x95, 0x24, 0x46, 0xd9, 0x10, 0x27, 0xb7, 0xa2, 0x3, 0x50, 0x7d, + 0xd5, 0xd2, 0xc6, 0xa8, 0x3a, 0xca, 0x87, 0xb4, 0xa0, 0xbf, 0x0, + 0xd4, 0xe3, 0xec, 0x72, 0xeb, 0xb3, 0x44, 0xe2, 0xba, 0x2d}, + {0xcc, 0xe1, 0xff, 0x57, 0x2f, 0x4a, 0xf, 0x98, 0x43, 0x98, 0x83, + 0xe1, 0xd, 0xd, 0x67, 0x0, 0xfd, 0x15, 0xfb, 0x49, 0x4a, 0x3f, + 0x5c, 0x10, 0x9c, 0xa6, 0x26, 0x51, 0x63, 0xca, 0x98, 0x26}, + }, + { + {0xe, 0xd9, 0x3d, 0x5e, 0x2f, 0x70, 0x3d, 0x2e, 0x86, 0x53, 0xd2, + 0xe4, 0x18, 0x9, 0x3f, 0x9e, 0x6a, 0xa9, 0x4d, 0x2, 0xf6, 0x3e, + 0x77, 0x5e, 0x32, 0x33, 0xfa, 0x4a, 0xc, 0x4b, 0x0, 0x3c}, + {0x78, 0xba, 0xb0, 0x32, 0x88, 0x31, 0x65, 0xe7, 0x8b, 0xff, 0x5c, + 0x92, 0xf7, 0x31, 0x18, 0x38, 0xcc, 0x1f, 0x29, 0xa0, 0x91, 0x1b, + 0xa8, 0x8, 0x7, 0xeb, 0xca, 0x49, 0xcc, 0x3d, 0xb4, 0x1f}, + {0x2b, 0xb8, 0xf4, 0x6, 0xac, 0x46, 0xa9, 0x9a, 0xf3, 0xc4, 0x6, + 0xa8, 0xa5, 0x84, 0xa2, 0x1c, 0x87, 0x47, 0xcd, 0xc6, 0x5f, 0x26, + 0xd3, 0x3e, 0x17, 0xd2, 0x1f, 0xcd, 0x1, 0xfd, 0x43, 0x6b}, + }, + { + {0xf3, 0xe, 0x76, 0x3e, 0x58, 0x42, 0xc7, 0xb5, 0x90, 0xb9, 0xa, + 0xee, 0xb9, 0x52, 0xdc, 0x75, 0x3f, 0x92, 0x2b, 0x7, 0xc2, 0x27, + 0x14, 0xbf, 0xf0, 0xd9, 0xf0, 0x6f, 0x2d, 0xb, 0x42, 0x73}, + {0x44, 0xc5, 0x97, 0x46, 0x4b, 0x5d, 0xa7, 0xc7, 0xbf, 0xff, 0xf, + 0xdf, 0x48, 0xf8, 0xfd, 0x15, 0x5a, 0x78, 0x46, 0xaa, 0xeb, 0xb9, + 0x68, 0x28, 0x14, 0xf7, 0x52, 0x5b, 0x10, 0xd7, 0x68, 0x5a}, + {0x6, 0x1e, 0x85, 0x9e, 0xcb, 0xf6, 0x2c, 0xaf, 0xc4, 0x38, 0x22, + 0xc6, 0x13, 0x39, 0x59, 0x8f, 0x73, 0xf3, 0xfb, 0x99, 0x96, 0xb8, + 0x8a, 0xda, 0x9e, 0xbc, 0x34, 0xea, 0x2f, 0x63, 0xb5, 0x3d}, + }, + { + {0xd5, 0x25, 0x98, 0x82, 0xb1, 0x90, 0x49, 0x2e, 0x91, 0x89, 0x9a, + 0x3e, 0x87, 0xeb, 0xea, 0xed, 0xf8, 0x4a, 0x70, 0x4c, 0x39, 0x3d, + 0xf0, 0xee, 0xe, 0x2b, 0xdf, 0x95, 0xa4, 0x7e, 0x19, 0x59}, + {0xd8, 0xd9, 0x5d, 0xf7, 0x2b, 0xee, 0x6e, 0xf4, 0xa5, 0x59, 0x67, + 0x39, 0xf6, 0xb1, 0x17, 0xd, 0x73, 0x72, 0x9e, 0x49, 0x31, 0xd1, + 0xf2, 0x1b, 0x13, 0x5f, 0xd7, 0x49, 0xdf, 0x1a, 0x32, 0x4}, + {0xae, 0x5a, 0xe5, 0xe4, 0x19, 0x60, 0xe1, 0x4, 0xe9, 0x92, 0x2f, + 0x7e, 0x7a, 0x43, 0x7b, 0xe7, 0xa4, 0x9a, 0x15, 0x6f, 0xc1, 0x2d, + 0xce, 0xc7, 0xc0, 0xc, 0xd7, 0xf4, 0xc1, 0xfd, 0xea, 0x45}, + }, + { + {0xed, 0xb1, 0xcc, 0xcf, 0x24, 0x46, 0xe, 0xb6, 0x95, 0x3, 0x5c, + 0xbd, 0x92, 0xc2, 0xdb, 0x59, 0xc9, 0x81, 0x4, 0xdc, 0x1d, 0x9d, + 0xa0, 0x31, 0x40, 0xd9, 0x56, 0x5d, 0xea, 0xce, 0x73, 0x3f}, + {0x2b, 0xd7, 0x45, 0x80, 0x85, 0x1, 0x84, 0x69, 0x51, 0x6, 0x2f, + 0xcf, 0xa2, 0xfa, 0x22, 0x4c, 0xc6, 0x2d, 0x22, 0x6b, 0x65, 0x36, + 0x1a, 0x94, 0xde, 0xda, 0x62, 0x3, 0xc8, 0xeb, 0x5e, 0x5a}, + {0xc6, 0x8d, 0x4e, 0xa, 0xd1, 0xbf, 0xa7, 0xb7, 0x39, 0xb3, 0xc9, + 0x44, 0x7e, 0x0, 0x57, 0xbe, 0xfa, 0xae, 0x57, 0x15, 0x7f, 0x20, + 0xc1, 0x60, 0xdb, 0x18, 0x62, 0x26, 0x91, 0x88, 0x5, 0x26}, + }, + { + {0x42, 0xe5, 0x76, 0xc6, 0x3c, 0x8e, 0x81, 0x4c, 0xad, 0xcc, 0xce, + 0x3, 0x93, 0x2c, 0x42, 0x5e, 0x8, 0x9f, 0x12, 0xb4, 0xca, 0xcc, + 0x7, 0xec, 0xb8, 0x43, 0x44, 0xb2, 0x10, 0xfa, 0xed, 0xd}, + {0x4, 0xff, 0x60, 0x83, 0xa6, 0x4, 0xf7, 0x59, 0xf4, 0xe6, 0x61, + 0x76, 0xde, 0x3f, 0xd9, 0xc3, 0x51, 0x35, 0x87, 0x12, 0x73, 0x2a, + 0x1b, 0x83, 0x57, 0x5d, 0x61, 0x4e, 0x2e, 0xc, 0xad, 0x54}, + {0x2a, 0x52, 0x2b, 0xb8, 0xd5, 0x67, 0x3b, 0xee, 0xeb, 0xc1, 0xa5, + 0x9f, 0x46, 0x63, 0xf1, 0x36, 0xd3, 0x9f, 0xc1, 0x6e, 0xf2, 0xd2, + 0xb4, 0xa5, 0x8, 0x94, 0x7a, 0xa7, 0xba, 0xb2, 0xec, 0x62}, + }, + { + {0x74, 0x28, 0xb6, 0xaf, 0x36, 0x28, 0x7, 0x92, 0xa5, 0x4, 0xe1, + 0x79, 0x85, 0x5e, 0xcd, 0x5f, 0x4a, 0xa1, 0x30, 0xc6, 0xad, 0x1, + 0xad, 0x5a, 0x98, 0x3f, 0x66, 0x75, 0x50, 0x3d, 0x91, 0x61}, + {0x3d, 0x2b, 0x15, 0x61, 0x52, 0x79, 0xed, 0xe5, 0xd1, 0xd7, 0xdd, + 0xe, 0x7d, 0x35, 0x62, 0x49, 0x71, 0x4c, 0x6b, 0xb9, 0xd0, 0xc8, + 0x82, 0x74, 0xbe, 0xd8, 0x66, 0xa9, 0x19, 0xf9, 0x59, 0x2e}, + {0xda, 0x31, 0x32, 0x1a, 0x36, 0x2d, 0xc6, 0xd, 0x70, 0x2, 0x20, + 0x94, 0x32, 0x58, 0x47, 0xfa, 0xce, 0x94, 0x95, 0x3f, 0x51, 0x1, + 0xd8, 0x2, 0x5c, 0x5d, 0xc0, 0x31, 0xa1, 0xc2, 0xdb, 0x3d}, + }, + }, + { + { + {0x14, 0xbb, 0x96, 0x27, 0xa2, 0x57, 0xaa, 0xf3, 0x21, 0xda, 0x7, + 0x9b, 0xb7, 0xba, 0x3a, 0x88, 0x1c, 0x39, 0xa0, 0x31, 0x18, 0xe2, + 0x4b, 0xe5, 0xf9, 0x5, 0x32, 0xd8, 0x38, 0xfb, 0xe7, 0x5e}, + {0x4b, 0xc5, 0x5e, 0xce, 0xf9, 0xf, 0xdc, 0x9a, 0xd, 0x13, 0x2f, + 0x8c, 0x6b, 0x2a, 0x9c, 0x3, 0x15, 0x95, 0xf8, 0xf0, 0xc7, 0x7, + 0x80, 0x2, 0x6b, 0xb3, 0x4, 0xac, 0x14, 0x83, 0x96, 0x78}, + {0x8e, 0x6a, 0x44, 0x41, 0xcb, 0xfd, 0x8d, 0x53, 0xf9, 0x37, 0x49, + 0x43, 0xa9, 0xfd, 0xac, 0xa5, 0x78, 0x8c, 0x3c, 0x26, 0x8d, 0x90, + 0xaf, 0x46, 0x9, 0xd, 0xca, 0x9b, 0x3c, 0x63, 0xd0, 0x61}, + }, + { + {0xdf, 0x73, 0xfc, 0xf8, 0xbc, 0x28, 0xa3, 0xad, 0xfc, 0x37, 0xf0, + 0xa6, 0x5d, 0x69, 0x84, 0xee, 0x9, 0xa9, 0xc2, 0x38, 0xdb, 0xb4, + 0x7f, 0x63, 0xdc, 0x7b, 0x6, 0xf8, 0x2d, 0xac, 0x23, 0x5b}, + {0x66, 0x25, 0xdb, 0xff, 0x35, 0x49, 0x74, 0x63, 0xbb, 0x68, 0xb, + 0x78, 0x89, 0x6b, 0xbd, 0xc5, 0x3, 0xec, 0x3e, 0x55, 0x80, 0x32, + 0x1b, 0x6f, 0xf5, 0xd7, 0xae, 0x47, 0xd8, 0x5f, 0x96, 0x6e}, + {0x7b, 0x52, 0x80, 0xee, 0x53, 0xb9, 0xd2, 0x9a, 0x8d, 0x6d, 0xde, + 0xfa, 0xaa, 0x19, 0x8f, 0xe8, 0xcf, 0x82, 0xe, 0x15, 0x4, 0x17, + 0x71, 0xe, 0xdc, 0xde, 0x95, 0xdd, 0xb9, 0xbb, 0xb9, 0x79}, + }, + { + {0x74, 0x73, 0x9f, 0x8e, 0xae, 0x7d, 0x99, 0xd1, 0x16, 0x8, 0xbb, + 0xcf, 0xf8, 0xa2, 0x32, 0xa0, 0xa, 0x5f, 0x44, 0x6d, 0x12, 0xba, + 0x6c, 0xcd, 0x34, 0xb8, 0xcc, 0xa, 0x46, 0x11, 0xa8, 0x1b}, + {0xc2, 0x26, 0x31, 0x6a, 0x40, 0x55, 0xb3, 0xeb, 0x93, 0xc3, 0xc8, + 0x68, 0xa8, 0x83, 0x63, 0xd2, 0x82, 0x7a, 0xb9, 0xe5, 0x29, 0x64, + 0xc, 0x6c, 0x47, 0x21, 0xfd, 0xc9, 0x58, 0xf1, 0x65, 0x50}, + {0x54, 0x99, 0x42, 0xc, 0xfb, 0x69, 0x81, 0x70, 0x67, 0xcf, 0x6e, + 0xd7, 0xac, 0x0, 0x46, 0xe1, 0xba, 0x45, 0xe6, 0x70, 0x8a, 0xb9, + 0xaa, 0x2e, 0xf2, 0xfa, 0xa4, 0x58, 0x9e, 0xf3, 0x81, 0x39}, + }, + { + {0xde, 0x6f, 0xe6, 0x6d, 0xa5, 0xdf, 0x45, 0xc8, 0x3a, 0x48, 0x40, + 0x2c, 0x0, 0xa5, 0x52, 0xe1, 0x32, 0xf6, 0xb4, 0xc7, 0x63, 0xe1, + 0xd2, 0xe9, 0x65, 0x1b, 0xbc, 0xdc, 0x2e, 0x45, 0xf4, 0x30}, + {0x93, 0xa, 0x23, 0x59, 0x75, 0x8a, 0xfb, 0x18, 0x5d, 0xf4, 0xe6, + 0x60, 0x69, 0x8f, 0x16, 0x1d, 0xb5, 0x3c, 0xa9, 0x14, 0x45, 0xa9, + 0x85, 0x3a, 0xfd, 0xd0, 0xac, 0x5, 0x37, 0x8, 0xdc, 0x38}, + {0x40, 0x97, 0x75, 0xc5, 0x82, 0x27, 0x6d, 0x85, 0xcc, 0xbe, 0x9c, + 0xf9, 0x69, 0x45, 0x13, 0xfa, 0x71, 0x4e, 0xea, 0xc0, 0x73, 0xfc, + 0x44, 0x88, 0x69, 0x24, 0x3f, 0x59, 0x1a, 0x9a, 0x2d, 0x63}, + }, + { + {0xa7, 0x84, 0xc, 0xed, 0x11, 0xfd, 0x9, 0xbf, 0x3a, 0x69, 0x9f, + 0xd, 0x81, 0x71, 0xf0, 0x63, 0x79, 0x87, 0xcf, 0x57, 0x2d, 0x8c, + 0x90, 0x21, 0xa2, 0x4b, 0xf6, 0x8a, 0xf2, 0x7d, 0x5a, 0x3a}, + {0xa6, 0xcb, 0x7, 0xb8, 0x15, 0x6b, 0xbb, 0xf6, 0xd7, 0xf0, 0x54, + 0xbc, 0xdf, 0xc7, 0x23, 0x18, 0xb, 0x67, 0x29, 0x6e, 0x3, 0x97, + 0x1d, 0xbb, 0x57, 0x4a, 0xed, 0x47, 0x88, 0xf4, 0x24, 0xb}, + {0xc7, 0xea, 0x1b, 0x51, 0xbe, 0xd4, 0xda, 0xdc, 0xf2, 0xcc, 0x26, + 0xed, 0x75, 0x80, 0x53, 0xa4, 0x65, 0x9a, 0x5f, 0x0, 0x9f, 0xff, + 0x9c, 0xe1, 0x63, 0x1f, 0x48, 0x75, 0x44, 0xf7, 0xfc, 0x34}, + }, + { + {0x98, 0xaa, 0xcf, 0x78, 0xab, 0x1d, 0xbb, 0xa5, 0xf2, 0x72, 0xb, + 0x19, 0x67, 0xa2, 0xed, 0x5c, 0x8e, 0x60, 0x92, 0xa, 0x11, 0xc9, + 0x9, 0x93, 0xb0, 0x74, 0xb3, 0x2f, 0x4, 0xa3, 0x19, 0x1}, + {0xca, 0x67, 0x97, 0x78, 0x4c, 0xe0, 0x97, 0xc1, 0x7d, 0x46, 0xd9, + 0x38, 0xcb, 0x4d, 0x71, 0xb8, 0xa8, 0x5f, 0xf9, 0x83, 0x82, 0x88, + 0xde, 0x55, 0xf7, 0x63, 0xfa, 0x4d, 0x16, 0xdc, 0x3b, 0x3d}, + {0x7d, 0x17, 0xc2, 0xe8, 0x9c, 0xd8, 0xa2, 0x67, 0xc1, 0xd0, 0x95, + 0x68, 0xf6, 0xa5, 0x9d, 0x66, 0xb0, 0xa2, 0x82, 0xb2, 0xe5, 0x98, + 0x65, 0xf5, 0x73, 0xa, 0xe2, 0xed, 0xf1, 0x88, 0xc0, 0x56}, + }, + { + {0x2, 0x8f, 0xf3, 0x24, 0xac, 0x5f, 0x1b, 0x58, 0xbd, 0xc, 0xe3, + 0xba, 0xfe, 0xe9, 0xb, 0xa9, 0xf0, 0x92, 0xcf, 0x8a, 0x2, 0x69, + 0x21, 0x9a, 0x8f, 0x3, 0x59, 0x83, 0xa4, 0x7e, 0x8b, 0x3}, + {0x17, 0x6e, 0xa8, 0x10, 0x11, 0x3d, 0x6d, 0x33, 0xfa, 0xb2, 0x75, + 0xb, 0x32, 0x88, 0xf3, 0xd7, 0x88, 0x29, 0x7, 0x25, 0x76, 0x33, + 0x15, 0xf9, 0x87, 0x8b, 0x10, 0x99, 0x6b, 0x4c, 0x67, 0x9}, + {0xf8, 0x6f, 0x31, 0x99, 0x21, 0xf8, 0x4e, 0x9f, 0x4f, 0x8d, 0xa7, + 0xea, 0x82, 0xd2, 0x49, 0x2f, 0x74, 0x31, 0xef, 0x5a, 0xab, 0xa5, + 0x71, 0x9, 0x65, 0xeb, 0x69, 0x59, 0x2, 0x31, 0x5e, 0x6e}, + }, + { + {0x22, 0x62, 0x6, 0x63, 0xe, 0xfb, 0x4, 0x33, 0x3f, 0xba, 0xac, + 0x87, 0x89, 0x6, 0x35, 0xfb, 0xa3, 0x61, 0x10, 0x8c, 0x77, 0x24, + 0x19, 0xbd, 0x20, 0x86, 0x83, 0xd1, 0x43, 0xad, 0x58, 0x30}, + {0xfb, 0x93, 0xe5, 0x87, 0xf5, 0x62, 0x6c, 0xb1, 0x71, 0x3e, 0x5d, + 0xca, 0xde, 0xed, 0x99, 0x49, 0x6d, 0x3e, 0xcc, 0x14, 0xe0, 0xc1, + 0x91, 0xb4, 0xa8, 0xdb, 0xa8, 0x89, 0x47, 0x11, 0xf5, 0x8}, + {0xd0, 0x63, 0x76, 0xe5, 0xfd, 0xf, 0x3c, 0x32, 0x10, 0xa6, 0x2e, + 0xa2, 0x38, 0xdf, 0xc3, 0x5, 0x9a, 0x4f, 0x99, 0xac, 0xbd, 0x8a, + 0xc7, 0xbd, 0x99, 0xdc, 0xe3, 0xef, 0xa4, 0x9f, 0x54, 0x26}, + }, + }, + { + { + {0x6e, 0x66, 0x3f, 0xaf, 0x49, 0x85, 0x46, 0xdb, 0xa5, 0xe, 0x4a, + 0xf1, 0x4, 0xcf, 0x7f, 0xd7, 0x47, 0xc, 0xba, 0xa4, 0xf7, 0x3f, + 0xf2, 0x3d, 0x85, 0x3c, 0xce, 0x32, 0xe1, 0xdf, 0x10, 0x3a}, + {0xd6, 0xf9, 0x6b, 0x1e, 0x46, 0x5a, 0x1d, 0x74, 0x81, 0xa5, 0x77, + 0x77, 0xfc, 0xb3, 0x5, 0x23, 0xd9, 0xd3, 0x74, 0x64, 0xa2, 0x74, + 0x55, 0xd4, 0xff, 0xe0, 0x1, 0x64, 0xdc, 0xe1, 0x26, 0x19}, + {0xa0, 0xce, 0x17, 0xea, 0x8a, 0x4e, 0x7f, 0xe0, 0xfd, 0xc1, 0x1f, + 0x3a, 0x46, 0x15, 0xd5, 0x2f, 0xf1, 0xc0, 0xf2, 0x31, 0xfd, 0x22, + 0x53, 0x17, 0x15, 0x5d, 0x1e, 0x86, 0x1d, 0xd0, 0xa1, 0x1f}, + }, + { + {0xab, 0x94, 0xdf, 0xd1, 0x0, 0xac, 0xdc, 0x38, 0xe9, 0xd, 0x8, + 0xd1, 0xdd, 0x2b, 0x71, 0x2e, 0x62, 0xe2, 0xd5, 0xfd, 0x3e, 0xe9, + 0x13, 0x7f, 0xe5, 0x1, 0x9a, 0xee, 0x18, 0xed, 0xfc, 0x73}, + {0x32, 0x98, 0x59, 0x7d, 0x94, 0x55, 0x80, 0xcc, 0x20, 0x55, 0xf1, + 0x37, 0xda, 0x56, 0x46, 0x1e, 0x20, 0x93, 0x5, 0x4e, 0x74, 0xf7, + 0xf6, 0x99, 0x33, 0xcf, 0x75, 0x6a, 0xbc, 0x63, 0x35, 0x77}, + {0xb3, 0x9c, 0x13, 0x63, 0x8, 0xe9, 0xb1, 0x6, 0xcd, 0x3e, 0xa0, + 0xc5, 0x67, 0xda, 0x93, 0xa4, 0x32, 0x89, 0x63, 0xad, 0xc8, 0xce, + 0x77, 0x8d, 0x44, 0x4f, 0x86, 0x1b, 0x70, 0x6b, 0x42, 0x1f}, + }, + { + {0x52, 0x25, 0xa1, 0x91, 0xc8, 0x35, 0x7e, 0xf1, 0x76, 0x9c, 0x5e, + 0x57, 0x53, 0x81, 0x6b, 0xb7, 0x3e, 0x72, 0x9b, 0xd, 0x6f, 0x40, + 0x83, 0xfa, 0x38, 0xe4, 0xa7, 0x3f, 0x1b, 0xbb, 0x76, 0xb}, + {0x1, 0x1c, 0x91, 0x41, 0x4c, 0x26, 0xc9, 0xef, 0x25, 0x2c, 0xa2, + 0x17, 0xb8, 0xb7, 0xa3, 0xf1, 0x47, 0x14, 0xf, 0xf3, 0x6b, 0xda, + 0x75, 0x58, 0x90, 0xb0, 0x31, 0x1d, 0x27, 0xf5, 0x1a, 0x4e}, + {0x9b, 0x93, 0x92, 0x7f, 0xf9, 0xc1, 0xb8, 0x8, 0x6e, 0xab, 0x44, + 0xd4, 0xcb, 0x71, 0x67, 0xbe, 0x17, 0x80, 0xbb, 0x99, 0x63, 0x64, + 0xe5, 0x22, 0x55, 0xa9, 0x72, 0xb7, 0x1e, 0xd6, 0x6d, 0x7b}, + }, + { + {0xc7, 0xd2, 0x1, 0xab, 0xf9, 0xab, 0x30, 0x57, 0x18, 0x3b, 0x14, + 0x40, 0xdc, 0x76, 0xfb, 0x16, 0x81, 0xb2, 0xcb, 0xa0, 0x65, 0xbe, + 0x6c, 0x86, 0xfe, 0x6a, 0xff, 0x9b, 0x65, 0x9b, 0xfa, 0x53}, + {0x92, 0x3d, 0xf3, 0x50, 0xe8, 0xc1, 0xad, 0xb7, 0xcf, 0xd5, 0x8c, + 0x60, 0x4f, 0xfa, 0x98, 0x79, 0xdb, 0x5b, 0xfc, 0x8d, 0xbd, 0x2d, + 0x96, 0xad, 0x4f, 0x2f, 0x1d, 0xaf, 0xce, 0x9b, 0x3e, 0x70}, + {0x55, 0x54, 0x88, 0x94, 0xe9, 0xc8, 0x14, 0x6c, 0xe5, 0xd4, 0xae, + 0x65, 0x66, 0x5d, 0x3a, 0x84, 0xf1, 0x5a, 0xd6, 0xbc, 0x3e, 0xb7, + 0x1b, 0x18, 0x50, 0x1f, 0xc6, 0xc4, 0xe5, 0x93, 0x8d, 0x39}, + }, + { + {0xf2, 0xe3, 0xe7, 0xd2, 0x60, 0x7c, 0x87, 0xc3, 0xb1, 0x8b, 0x82, + 0x30, 0xa0, 0xaa, 0x34, 0x3b, 0x38, 0xf1, 0x9e, 0x73, 0xe7, 0x26, + 0x3e, 0x28, 0x77, 0x5, 0xc3, 0x2, 0x90, 0x9c, 0x9c, 0x69}, + {0xf3, 0x48, 0xe2, 0x33, 0x67, 0xd1, 0x4b, 0x1c, 0x5f, 0xa, 0xbf, + 0x15, 0x87, 0x12, 0x9e, 0xbd, 0x76, 0x3, 0xb, 0xa1, 0xf0, 0x8c, + 0x3f, 0xd4, 0x13, 0x1b, 0x19, 0xdf, 0x5d, 0x9b, 0xb0, 0x53}, + {0xcc, 0xf1, 0x46, 0x59, 0x23, 0xa7, 0x6, 0xf3, 0x7d, 0xd9, 0xe5, + 0xcc, 0xb5, 0x18, 0x17, 0x92, 0x75, 0xe9, 0xb4, 0x81, 0x47, 0xd2, + 0xcd, 0x28, 0x7, 0xd9, 0xcd, 0x6f, 0xc, 0xf3, 0xca, 0x51}, + }, + { + {0xc7, 0x54, 0xac, 0x18, 0x9a, 0xf9, 0x7a, 0x73, 0xf, 0xb3, 0x1c, + 0xc5, 0xdc, 0x78, 0x33, 0x90, 0xc7, 0xc, 0xe1, 0x4c, 0x33, 0xbc, + 0x89, 0x2b, 0x9a, 0xe9, 0xf8, 0x89, 0xc1, 0x29, 0xae, 0x12}, + {0xa, 0xe0, 0x74, 0x76, 0x42, 0xa7, 0xb, 0xa6, 0xf3, 0x7b, 0x7a, + 0xa1, 0x70, 0x85, 0xe, 0x63, 0xcc, 0x24, 0x33, 0xcf, 0x3d, 0x56, + 0x58, 0x37, 0xaa, 0xfd, 0x83, 0x23, 0x29, 0xaa, 0x4, 0x55}, + {0xcf, 0x1, 0xd, 0x1f, 0xcb, 0xc0, 0x9e, 0xa9, 0xae, 0xf7, 0x34, + 0x3a, 0xcc, 0xef, 0xd1, 0xd, 0x22, 0x4e, 0x9c, 0xd0, 0x21, 0x75, + 0xca, 0x55, 0xea, 0xa5, 0xeb, 0x58, 0xe9, 0x4f, 0xd1, 0x5f}, + }, + { + {0x8e, 0xcb, 0x93, 0xbf, 0x5e, 0xfe, 0x42, 0x3c, 0x5f, 0x56, 0xd4, + 0x36, 0x51, 0xa8, 0xdf, 0xbe, 0xe8, 0x20, 0x42, 0x88, 0x9e, 0x85, + 0xf0, 0xe0, 0x28, 0xd1, 0x25, 0x7, 0x96, 0x3f, 0xd7, 0x7d}, + {0x2c, 0xab, 0x45, 0x28, 0xdf, 0x2d, 0xdc, 0xb5, 0x93, 0xe9, 0x7f, + 0xa, 0xb1, 0x91, 0x94, 0x6, 0x46, 0xe3, 0x2, 0x40, 0xd6, 0xf3, + 0xaa, 0x4d, 0xd1, 0x74, 0x64, 0x58, 0x6e, 0xf2, 0x3f, 0x9}, + {0x29, 0x98, 0x5, 0x68, 0xfe, 0x24, 0xd, 0xb1, 0xe5, 0x23, 0xaf, + 0xdb, 0x72, 0x6, 0x73, 0x75, 0x29, 0xac, 0x57, 0xb4, 0x3a, 0x25, + 0x67, 0x13, 0xa4, 0x70, 0xb4, 0x86, 0xbc, 0xbc, 0x59, 0x2f}, + }, + { + {0x1, 0xc3, 0x91, 0xb6, 0x60, 0xd5, 0x41, 0x70, 0x1e, 0xe7, 0xd7, + 0xad, 0x3f, 0x1b, 0x20, 0x85, 0x85, 0x55, 0x33, 0x11, 0x63, 0xe1, + 0xc2, 0x16, 0xb1, 0x28, 0x8, 0x1, 0x3d, 0x5e, 0xa5, 0x2a}, + {0x5f, 0x13, 0x17, 0x99, 0x42, 0x7d, 0x84, 0x83, 0xd7, 0x3, 0x7d, + 0x56, 0x1f, 0x91, 0x1b, 0xad, 0xd1, 0xaa, 0x77, 0xbe, 0xd9, 0x48, + 0x77, 0x7e, 0x4a, 0xaf, 0x51, 0x2e, 0x2e, 0xb4, 0x58, 0x54}, + {0x4f, 0x44, 0x7, 0xc, 0xe6, 0x92, 0x51, 0xed, 0x10, 0x1d, 0x42, + 0x74, 0x2d, 0x4e, 0xc5, 0x42, 0x64, 0xc8, 0xb5, 0xfd, 0x82, 0x4c, + 0x2b, 0x35, 0x64, 0x86, 0x76, 0x8a, 0x4a, 0x0, 0xe9, 0x13}, + }, + }, + { + { + {0x7f, 0x87, 0x3b, 0x19, 0xc9, 0x0, 0x2e, 0xbb, 0x6b, 0x50, 0xdc, + 0xe0, 0x90, 0xa8, 0xe3, 0xec, 0x9f, 0x64, 0xde, 0x36, 0xc0, 0xb7, + 0xf3, 0xec, 0x1a, 0x9e, 0xde, 0x98, 0x8, 0x4, 0x46, 0x5f}, + {0xdb, 0xce, 0x2f, 0x83, 0x45, 0x88, 0x9d, 0x73, 0x63, 0xf8, 0x6b, + 0xae, 0xc9, 0xd6, 0x38, 0xfa, 0xf7, 0xfe, 0x4f, 0xb7, 0xca, 0xd, + 0xbc, 0x32, 0x5e, 0xe4, 0xbc, 0x14, 0x88, 0x7e, 0x93, 0x73}, + {0x8d, 0xf4, 0x7b, 0x29, 0x16, 0x71, 0x3, 0xb9, 0x34, 0x68, 0xf0, + 0xd4, 0x22, 0x3b, 0xd1, 0xa9, 0xc6, 0xbd, 0x96, 0x46, 0x57, 0x15, + 0x97, 0xe1, 0x35, 0xe8, 0xd5, 0x91, 0xe8, 0xa4, 0xf8, 0x2c}, + }, + { + {0xa2, 0x6b, 0xd0, 0x17, 0x7e, 0x48, 0xb5, 0x2c, 0x6b, 0x19, 0x50, + 0x39, 0x1c, 0x38, 0xd2, 0x24, 0x30, 0x8a, 0x97, 0x85, 0x81, 0x9c, + 0x65, 0xd7, 0xf6, 0xa4, 0xd6, 0x91, 0x28, 0x7f, 0x6f, 0x7a}, + {0x67, 0xf, 0x11, 0x7, 0x87, 0xfd, 0x93, 0x6d, 0x49, 0xb5, 0x38, + 0x7c, 0xd3, 0x9, 0x4c, 0xdd, 0x86, 0x6a, 0x73, 0xc2, 0x4c, 0x6a, + 0xb1, 0x7c, 0x9, 0x2a, 0x25, 0x58, 0x6e, 0xbd, 0x49, 0x20}, + {0x49, 0xef, 0x9a, 0x6a, 0x8d, 0xfd, 0x9, 0x7d, 0xb, 0xb9, 0x3d, + 0x5b, 0xbe, 0x60, 0xee, 0xf0, 0xd4, 0xbf, 0x9e, 0x51, 0x2c, 0xb5, + 0x21, 0x4c, 0x1d, 0x94, 0x45, 0xc5, 0xdf, 0xaa, 0x11, 0x60}, + }, + { + {0x90, 0xf8, 0xcb, 0x2, 0xc8, 0xd0, 0xde, 0x63, 0xaa, 0x6a, 0xff, + 0xd, 0xca, 0x98, 0xd0, 0xfb, 0x99, 0xed, 0xb6, 0xb9, 0xfd, 0xa, + 0x4d, 0x62, 0x1e, 0xb, 0x34, 0x79, 0xb7, 0x18, 0xce, 0x69}, + {0x3c, 0xf8, 0x95, 0xcf, 0x6d, 0x92, 0x67, 0x5f, 0x71, 0x90, 0x28, + 0x71, 0x61, 0x85, 0x7e, 0x7c, 0x5b, 0x7a, 0x8f, 0x99, 0xf3, 0xe7, + 0xa1, 0xd6, 0xe0, 0xf9, 0x62, 0xb, 0x1b, 0xcc, 0xc5, 0x6f}, + {0xcb, 0x79, 0x98, 0xb2, 0x28, 0x55, 0xef, 0xd1, 0x92, 0x90, 0x7e, + 0xd4, 0x3c, 0xae, 0x1a, 0xdd, 0x52, 0x23, 0x9f, 0x18, 0x42, 0x4, + 0x7e, 0x12, 0xf1, 0x1, 0x71, 0xe5, 0x3a, 0x6b, 0x59, 0x15}, + }, + { + {0xca, 0x24, 0x51, 0x7e, 0x16, 0x31, 0xff, 0x9, 0xdf, 0x45, 0xc7, + 0xd9, 0x8b, 0x15, 0xe4, 0xb, 0xe5, 0x56, 0xf5, 0x7e, 0x22, 0x7d, + 0x2b, 0x29, 0x38, 0xd1, 0xb6, 0xaf, 0x41, 0xe2, 0xa4, 0x3a}, + {0xa2, 0x79, 0x91, 0x3f, 0xd2, 0x39, 0x27, 0x46, 0xcf, 0xdd, 0xd6, + 0x97, 0x31, 0x12, 0x83, 0xff, 0x8a, 0x14, 0xf2, 0x53, 0xb5, 0xde, + 0x7, 0x13, 0xda, 0x4d, 0x5f, 0x7b, 0x68, 0x37, 0x22, 0xd}, + {0xf5, 0x5, 0x33, 0x2a, 0xbf, 0x38, 0xc1, 0x2c, 0xc3, 0x26, 0xe9, + 0xa2, 0x8f, 0x3f, 0x58, 0x48, 0xeb, 0xd2, 0x49, 0x55, 0xa2, 0xb1, + 0x3a, 0x8, 0x6c, 0xa3, 0x87, 0x46, 0x6e, 0xaa, 0xfc, 0x32}, + }, + { + {0xdf, 0xcc, 0x87, 0x27, 0x73, 0xa4, 0x7, 0x32, 0xf8, 0xe3, 0x13, + 0xf2, 0x8, 0x19, 0xe3, 0x17, 0x4e, 0x96, 0xd, 0xf6, 0xd7, 0xec, + 0xb2, 0xd5, 0xe9, 0xb, 0x60, 0xc2, 0x36, 0x63, 0x6f, 0x74}, + {0xf5, 0x9a, 0x7d, 0xc5, 0x8d, 0x6e, 0xc5, 0x7b, 0xf2, 0xbd, 0xf0, + 0x9d, 0xed, 0xd2, 0xb, 0x3e, 0xa3, 0xe4, 0xef, 0x22, 0xde, 0x14, + 0xc0, 0xaa, 0x5c, 0x6a, 0xbd, 0xfe, 0xce, 0xe9, 0x27, 0x46}, + {0x1c, 0x97, 0x6c, 0xab, 0x45, 0xf3, 0x4a, 0x3f, 0x1f, 0x73, 0x43, + 0x99, 0x72, 0xeb, 0x88, 0xe2, 0x6d, 0x18, 0x44, 0x3, 0x8a, 0x6a, + 0x59, 0x33, 0x93, 0x62, 0xd6, 0x7e, 0x0, 0x17, 0x49, 0x7b}, + }, + { + {0xdd, 0xa2, 0x53, 0xdd, 0x28, 0x1b, 0x34, 0x54, 0x3f, 0xfc, 0x42, + 0xdf, 0x5b, 0x90, 0x17, 0xaa, 0xf4, 0xf8, 0xd2, 0x4d, 0xd9, 0x92, + 0xf5, 0xf, 0x7d, 0xd3, 0x8c, 0xe0, 0xf, 0x62, 0x3, 0x1d}, + {0x64, 0xb0, 0x84, 0xab, 0x5c, 0xfb, 0x85, 0x2d, 0x14, 0xbc, 0xf3, + 0x89, 0xd2, 0x10, 0x78, 0x49, 0xc, 0xce, 0x15, 0x7b, 0x44, 0xdc, + 0x6a, 0x47, 0x7b, 0xfd, 0x44, 0xf8, 0x76, 0xa3, 0x2b, 0x12}, + {0x54, 0xe5, 0xb4, 0xa2, 0xcd, 0x32, 0x2, 0xc2, 0x7f, 0x18, 0x5d, + 0x11, 0x42, 0xfd, 0xd0, 0x9e, 0xd9, 0x79, 0xd4, 0x7d, 0xbe, 0xb4, + 0xab, 0x2e, 0x4c, 0xec, 0x68, 0x2b, 0xf5, 0xb, 0xc7, 0x2}, + }, + { + {0xe1, 0x72, 0x8d, 0x45, 0xbf, 0x32, 0xe5, 0xac, 0xb5, 0x3c, 0xb7, + 0x7c, 0xe0, 0x68, 0xe7, 0x5b, 0xe7, 0xbd, 0x8b, 0xee, 0x94, 0x7d, + 0xcf, 0x56, 0x3, 0x3a, 0xb4, 0xfe, 0xe3, 0x97, 0x6, 0x6b}, + {0xbb, 0x2f, 0xb, 0x5d, 0x4b, 0xec, 0x87, 0xa2, 0xca, 0x82, 0x48, + 0x7, 0x90, 0x57, 0x5c, 0x41, 0x5c, 0x81, 0xd0, 0xc1, 0x1e, 0xa6, + 0x44, 0xe0, 0xe0, 0xf5, 0x9e, 0x40, 0xa, 0x4f, 0x33, 0x26}, + {0xc0, 0xa3, 0x62, 0xdf, 0x4a, 0xf0, 0xc8, 0xb6, 0x5d, 0xa4, 0x6d, + 0x7, 0xef, 0x0, 0xf0, 0x3e, 0xa9, 0xd2, 0xf0, 0x49, 0x58, 0xb9, + 0x9c, 0x9c, 0xae, 0x2f, 0x1b, 0x44, 0x43, 0x7f, 0xc3, 0x1c}, + }, + { + {0xb9, 0xae, 0xce, 0xc9, 0xf1, 0x56, 0x66, 0xd7, 0x6a, 0x65, 0xe5, + 0x18, 0xf8, 0x15, 0x5b, 0x1c, 0x34, 0x23, 0x4c, 0x84, 0x32, 0x28, + 0xe7, 0x26, 0x38, 0x68, 0x19, 0x2f, 0x77, 0x6f, 0x34, 0x3a}, + {0x4f, 0x32, 0xc7, 0x5c, 0x5a, 0x56, 0x8f, 0x50, 0x22, 0xa9, 0x6, + 0xe5, 0xc0, 0xc4, 0x61, 0xd0, 0x19, 0xac, 0x45, 0x5c, 0xdb, 0xab, + 0x18, 0xfb, 0x4a, 0x31, 0x80, 0x3, 0xc1, 0x9, 0x68, 0x6c}, + {0xc8, 0x6a, 0xda, 0xe2, 0x12, 0x51, 0xd5, 0xd2, 0xed, 0x51, 0xe8, + 0xb1, 0x31, 0x3, 0xbd, 0xe9, 0x62, 0x72, 0xc6, 0x8e, 0xdd, 0x46, + 0x7, 0x96, 0xd0, 0xc5, 0xf7, 0x6e, 0x9f, 0x1b, 0x91, 0x5}, + }, + }, + { + { + {0xef, 0xea, 0x2e, 0x51, 0xf3, 0xac, 0x49, 0x53, 0x49, 0xcb, 0xc1, + 0x1c, 0xd3, 0x41, 0xc1, 0x20, 0x8d, 0x68, 0x9a, 0xa9, 0x7, 0xc, + 0x18, 0x24, 0x17, 0x2d, 0x4b, 0xc6, 0xd1, 0xf9, 0x5e, 0x55}, + {0xbb, 0xe, 0xdf, 0xf5, 0x83, 0x99, 0x33, 0xc1, 0xac, 0x4c, 0x2c, + 0x51, 0x8f, 0x75, 0xf3, 0xc0, 0xe1, 0x98, 0xb3, 0xb, 0xa, 0x13, + 0xf1, 0x2c, 0x62, 0xc, 0x27, 0xaa, 0xf9, 0xec, 0x3c, 0x6b}, + {0x8, 0xbd, 0x73, 0x3b, 0xba, 0x70, 0xa7, 0x36, 0xc, 0xbf, 0xaf, + 0xa3, 0x8, 0xef, 0x4a, 0x62, 0xf2, 0x46, 0x9, 0xb4, 0x98, 0xff, + 0x37, 0x57, 0x9d, 0x74, 0x81, 0x33, 0xe1, 0x4d, 0x5f, 0x67}, + }, + { + {0x1d, 0xb3, 0xda, 0x3b, 0xd9, 0xf6, 0x2f, 0xa1, 0xfe, 0x2d, 0x65, + 0x9d, 0xf, 0xd8, 0x25, 0x7, 0x87, 0x94, 0xbe, 0x9a, 0xf3, 0x4f, + 0x9c, 0x1, 0x43, 0x3c, 0xcd, 0x82, 0xb8, 0x50, 0xf4, 0x60}, + {0xfc, 0x82, 0x17, 0x6b, 0x3, 0x52, 0x2c, 0xe, 0xb4, 0x83, 0xad, + 0x6c, 0x81, 0x6c, 0x81, 0x64, 0x3e, 0x7, 0x64, 0x69, 0xd9, 0xbd, + 0xdc, 0xd0, 0x20, 0xc5, 0x64, 0x1, 0xf7, 0x9d, 0xd9, 0x13}, + {0xca, 0xc0, 0xe5, 0x21, 0xc3, 0x5e, 0x4b, 0x1, 0xa2, 0xbf, 0x19, + 0xd7, 0xc9, 0x69, 0xcb, 0x4f, 0xa0, 0x23, 0x0, 0x75, 0x18, 0x1c, + 0x5f, 0x4e, 0x80, 0xac, 0xed, 0x55, 0x9e, 0xde, 0x6, 0x1c}, + }, + { + {0xaa, 0x69, 0x6d, 0xff, 0x40, 0x2b, 0xd5, 0xff, 0xbb, 0x49, 0x40, + 0xdc, 0x18, 0xb, 0x53, 0x34, 0x97, 0x98, 0x4d, 0xa3, 0x2f, 0x5c, + 0x4a, 0x5e, 0x2d, 0xba, 0x32, 0x7d, 0x8e, 0x6f, 0x9, 0x78}, + {0xe2, 0xc4, 0x3e, 0xa3, 0xd6, 0x7a, 0xf, 0x99, 0x8e, 0xe0, 0x2e, + 0xbe, 0x38, 0xf9, 0x8, 0x66, 0x15, 0x45, 0x28, 0x63, 0xc5, 0x43, + 0xa1, 0x9c, 0xd, 0xb6, 0x2d, 0xec, 0x1f, 0x8a, 0xf3, 0x4c}, + {0xe7, 0x5c, 0xfa, 0xd, 0x65, 0xaa, 0xaa, 0xa0, 0x8c, 0x47, 0xb5, + 0x48, 0x2a, 0x9e, 0xc4, 0xf9, 0x5b, 0x72, 0x3, 0x70, 0x7d, 0xcc, + 0x9, 0x4f, 0xbe, 0x1a, 0x9, 0x26, 0x3a, 0xad, 0x3c, 0x37}, + }, + { + {0xad, 0xbb, 0xdd, 0x89, 0xfb, 0xa8, 0xbe, 0xf1, 0xcb, 0xae, 0xae, + 0x61, 0xbc, 0x2c, 0xcb, 0x3b, 0x9d, 0x8d, 0x9b, 0x1f, 0xbb, 0xa7, + 0x58, 0x8f, 0x86, 0xa6, 0x12, 0x51, 0xda, 0x7e, 0x54, 0x21}, + {0x7c, 0xf5, 0xc9, 0x82, 0x4d, 0x63, 0x94, 0xb2, 0x36, 0x45, 0x93, + 0x24, 0xe1, 0xfd, 0xcb, 0x1f, 0x5a, 0xdb, 0x8c, 0x41, 0xb3, 0x4d, + 0x9c, 0x9e, 0xfc, 0x19, 0x44, 0x45, 0xd9, 0xf3, 0x40, 0x0}, + {0xd3, 0x86, 0x59, 0xfd, 0x39, 0xe9, 0xfd, 0xde, 0xc, 0x38, 0xa, + 0x51, 0x89, 0x2c, 0x27, 0xf4, 0xb9, 0x19, 0x31, 0xbb, 0x7, 0xa4, + 0x2b, 0xb7, 0xf4, 0x4d, 0x25, 0x4a, 0x33, 0xa, 0x55, 0x63}, + }, + { + {0x49, 0x7b, 0x54, 0x72, 0x45, 0x58, 0xba, 0x9b, 0xe0, 0x8, 0xc4, + 0xe2, 0xfa, 0xc6, 0x5, 0xf3, 0x8d, 0xf1, 0x34, 0xc7, 0x69, 0xfa, + 0xe8, 0x60, 0x7a, 0x76, 0x7d, 0xaa, 0xaf, 0x2b, 0xa9, 0x39}, + {0x37, 0xcf, 0x69, 0xb5, 0xed, 0xd6, 0x7, 0x65, 0xe1, 0x2e, 0xa5, + 0xc, 0xb0, 0x29, 0x84, 0x17, 0x5d, 0xd6, 0x6b, 0xeb, 0x90, 0x0, + 0x7c, 0xea, 0x51, 0x8f, 0xf7, 0xda, 0xc7, 0x62, 0xea, 0x3e}, + {0x4e, 0x27, 0x93, 0xe6, 0x13, 0xc7, 0x24, 0x9d, 0x75, 0xd3, 0xdb, + 0x68, 0x77, 0x85, 0x63, 0x5f, 0x9a, 0xb3, 0x8a, 0xeb, 0x60, 0x55, + 0x52, 0x70, 0xcd, 0xc4, 0xc9, 0x65, 0x6, 0x6a, 0x43, 0x68}, + }, + { + {0x7c, 0x10, 0x20, 0xe8, 0x17, 0xd3, 0x56, 0x1e, 0x65, 0xe9, 0xa, + 0x84, 0x44, 0x68, 0x26, 0xc5, 0x7a, 0xfc, 0xf, 0x32, 0xc6, 0xa1, + 0xe0, 0xc1, 0x72, 0x14, 0x61, 0x91, 0x9c, 0x66, 0x73, 0x53}, + {0x27, 0x3f, 0x2f, 0x20, 0xe8, 0x35, 0x2, 0xbc, 0xb0, 0x75, 0xf9, + 0x64, 0xe2, 0x0, 0x5c, 0xc7, 0x16, 0x24, 0x8c, 0xa3, 0xd5, 0xe9, + 0xa4, 0x91, 0xf9, 0x89, 0xb7, 0x8a, 0xf6, 0xe7, 0xb6, 0x17}, + {0x57, 0x52, 0xe, 0x9a, 0xab, 0x14, 0x28, 0x5d, 0xfc, 0xb3, 0xca, + 0xc9, 0x84, 0x20, 0x8f, 0x90, 0xca, 0x1e, 0x2d, 0x5b, 0x88, 0xf5, + 0xca, 0xaf, 0x11, 0x7d, 0xf8, 0x78, 0xa6, 0xb5, 0xb4, 0x1c}, + }, + { + {0xe7, 0x7, 0xa0, 0xa2, 0x62, 0xaa, 0x74, 0x6b, 0xb1, 0xc7, 0x71, + 0xf0, 0xb0, 0xe0, 0x11, 0xf3, 0x23, 0xe2, 0xb, 0x0, 0x38, 0xe4, + 0x7, 0x57, 0xac, 0x6e, 0xef, 0x82, 0x2d, 0xfd, 0xc0, 0x2d}, + {0x6c, 0xfc, 0x4a, 0x39, 0x6b, 0xc0, 0x64, 0xb6, 0xb1, 0x5f, 0xda, + 0x98, 0x24, 0xde, 0x88, 0xc, 0x34, 0xd8, 0xca, 0x4b, 0x16, 0x3, + 0x8d, 0x4f, 0xa2, 0x34, 0x74, 0xde, 0x78, 0xca, 0xb, 0x33}, + {0x4e, 0x74, 0x19, 0x11, 0x84, 0xff, 0x2e, 0x98, 0x24, 0x47, 0x7, + 0x2b, 0x96, 0x5e, 0x69, 0xf9, 0xfb, 0x53, 0xc9, 0xbf, 0x4f, 0xc1, + 0x8a, 0xc5, 0xf5, 0x1c, 0x9f, 0x36, 0x1b, 0xbe, 0x31, 0x3c}, + }, + { + {0x72, 0x42, 0xcb, 0xf9, 0x93, 0xbc, 0x68, 0xc1, 0x98, 0xdb, 0xce, + 0xc7, 0x1f, 0x71, 0xb8, 0xae, 0x7a, 0x8d, 0xac, 0x34, 0xaa, 0x52, + 0xe, 0x7f, 0xbb, 0x55, 0x7d, 0x7e, 0x9, 0xc1, 0xce, 0x41}, + {0xee, 0x8a, 0x94, 0x8, 0x4d, 0x86, 0xf4, 0xb0, 0x6f, 0x1c, 0xba, + 0x91, 0xee, 0x19, 0xdc, 0x7, 0x58, 0xa1, 0xac, 0xa6, 0xae, 0xcd, + 0x75, 0x79, 0xbb, 0xd4, 0x62, 0x42, 0x13, 0x61, 0xb, 0x33}, + {0x8a, 0x80, 0x6d, 0xa2, 0xd7, 0x19, 0x96, 0xf7, 0x6d, 0x15, 0x9e, + 0x1d, 0x9e, 0xd4, 0x1f, 0xbb, 0x27, 0xdf, 0xa1, 0xdb, 0x6c, 0xc3, + 0xd7, 0x73, 0x7d, 0x77, 0x28, 0x1f, 0xd9, 0x4c, 0xb4, 0x26}, + }, + }, + { + { + {0x83, 0x3, 0x73, 0x62, 0x93, 0xf2, 0xb7, 0xe1, 0x2c, 0x8a, 0xca, + 0xeb, 0xff, 0x79, 0x52, 0x4b, 0x14, 0x13, 0xd4, 0xbf, 0x8a, 0x77, + 0xfc, 0xda, 0xf, 0x61, 0x72, 0x9c, 0x14, 0x10, 0xeb, 0x7d}, + {0x75, 0x74, 0x38, 0x8f, 0x47, 0x48, 0xf0, 0x51, 0x3c, 0xcb, 0xbe, + 0x9c, 0xf4, 0xbc, 0x5d, 0xb2, 0x55, 0x20, 0x9f, 0xd9, 0x44, 0x12, + 0xab, 0x9a, 0xd6, 0xa5, 0x10, 0x1c, 0x6c, 0x9e, 0x70, 0x2c}, + {0x7a, 0xee, 0x66, 0x87, 0x6a, 0xaf, 0x62, 0xcb, 0xe, 0xcd, 0x53, + 0x55, 0x4, 0xec, 0xcb, 0x66, 0xb5, 0xe4, 0xb, 0xf, 0x38, 0x1, + 0x80, 0x58, 0xea, 0xe2, 0x2c, 0xf6, 0x9f, 0x8e, 0xe6, 0x8}, + }, + { + {0xf9, 0xf2, 0xb8, 0xa, 0xd5, 0x9, 0x2d, 0x2f, 0xdf, 0x23, 0x59, + 0xc5, 0x8d, 0x21, 0xb9, 0xac, 0xb9, 0x6c, 0x76, 0x73, 0x26, 0x34, + 0x8f, 0x4a, 0xf5, 0x19, 0xf7, 0x38, 0xd7, 0x3b, 0xb1, 0x4c}, + {0xad, 0x30, 0xc1, 0x4b, 0xa, 0x50, 0xad, 0x34, 0x9c, 0xd4, 0xb, + 0x3d, 0x49, 0xdb, 0x38, 0x8d, 0xbe, 0x89, 0xa, 0x50, 0x98, 0x3d, + 0x5c, 0xa2, 0x9, 0x3b, 0xba, 0xee, 0x87, 0x3f, 0x1f, 0x2f}, + {0x4a, 0xb6, 0x15, 0xe5, 0x75, 0x8c, 0x84, 0xf7, 0x38, 0x90, 0x4a, + 0xdb, 0xba, 0x1, 0x95, 0xa5, 0x50, 0x1b, 0x75, 0x3f, 0x3f, 0x31, + 0xd, 0xc2, 0xe8, 0x2e, 0xae, 0xc0, 0x53, 0xe3, 0xa1, 0x19}, + }, + { + {0xbd, 0xbd, 0x96, 0xd5, 0xcd, 0x72, 0x21, 0xb4, 0x40, 0xfc, 0xee, + 0x98, 0x43, 0x45, 0xe0, 0x93, 0xb5, 0x9, 0x41, 0xb4, 0x47, 0x53, + 0xb1, 0x9f, 0x34, 0xae, 0x66, 0x2, 0x99, 0xd3, 0x6b, 0x73}, + {0xc3, 0x5, 0xfa, 0xba, 0x60, 0x75, 0x1c, 0x7d, 0x61, 0x5e, 0xe5, + 0xc6, 0xa0, 0xa0, 0xe1, 0xb3, 0x73, 0x64, 0xd6, 0xc0, 0x18, 0x97, + 0x52, 0xe3, 0x86, 0x34, 0xc, 0xc2, 0x11, 0x6b, 0x54, 0x41}, + {0xb4, 0xb3, 0x34, 0x93, 0x50, 0x2d, 0x53, 0x85, 0x73, 0x65, 0x81, + 0x60, 0x4b, 0x11, 0xfd, 0x46, 0x75, 0x83, 0x5c, 0x42, 0x30, 0x5f, + 0x5f, 0xcc, 0x5c, 0xab, 0x7f, 0xb8, 0xa2, 0x95, 0x22, 0x41}, + }, + { + {0xc6, 0xea, 0x93, 0xe2, 0x61, 0x52, 0x65, 0x2e, 0xdb, 0xac, 0x33, + 0x21, 0x3, 0x92, 0x5a, 0x84, 0x6b, 0x99, 0x0, 0x79, 0xcb, 0x75, + 0x9, 0x46, 0x80, 0xdd, 0x5a, 0x19, 0x8d, 0xbb, 0x60, 0x7}, + {0xe9, 0xd6, 0x7e, 0xf5, 0x88, 0x9b, 0xc9, 0x19, 0x25, 0xc8, 0xf8, + 0x6d, 0x26, 0xcb, 0x93, 0x53, 0x73, 0xd2, 0xa, 0xb3, 0x13, 0x32, + 0xee, 0x5c, 0x34, 0x2e, 0x2d, 0xb5, 0xeb, 0x53, 0xe1, 0x14}, + {0x8a, 0x81, 0xe6, 0xcd, 0x17, 0x1a, 0x3e, 0x41, 0x84, 0xa0, 0x69, + 0xed, 0xa9, 0x6d, 0x15, 0x57, 0xb1, 0xcc, 0xca, 0x46, 0x8f, 0x26, + 0xbf, 0x2c, 0xf2, 0xc5, 0x3a, 0xc3, 0x9b, 0xbe, 0x34, 0x6b}, + }, + { + {0xd3, 0xf2, 0x71, 0x65, 0x65, 0x69, 0xfc, 0x11, 0x7a, 0x73, 0xe, + 0x53, 0x45, 0xe8, 0xc9, 0xc6, 0x35, 0x50, 0xfe, 0xd4, 0xa2, 0xe7, + 0x3a, 0xe3, 0xb, 0xd3, 0x6d, 0x2e, 0xb6, 0xc7, 0xb9, 0x1}, + {0xb2, 0xc0, 0x78, 0x3a, 0x64, 0x2f, 0xdf, 0xf3, 0x7c, 0x2, 0x2e, + 0xf2, 0x1e, 0x97, 0x3e, 0x4c, 0xa3, 0xb5, 0xc1, 0x49, 0x5e, 0x1c, + 0x7d, 0xec, 0x2d, 0xdd, 0x22, 0x9, 0x8f, 0xc1, 0x12, 0x20}, + {0x29, 0x9d, 0xc8, 0x5a, 0xe5, 0x55, 0xb, 0x88, 0x63, 0xa7, 0xa0, + 0x45, 0x1f, 0x24, 0x83, 0x14, 0x1f, 0x6c, 0xe7, 0xc2, 0xdf, 0xef, + 0x36, 0x3d, 0xe8, 0xad, 0x4b, 0x4e, 0x78, 0x5b, 0xaf, 0x8}, + }, + { + {0x4b, 0x2c, 0xcc, 0x89, 0xd2, 0x14, 0x73, 0xe2, 0x8d, 0x17, 0x87, + 0xa2, 0x11, 0xbd, 0xe4, 0x4b, 0xce, 0x64, 0x33, 0xfa, 0xd6, 0x28, + 0xd5, 0x18, 0x6e, 0x82, 0xd9, 0xaf, 0xd5, 0xc1, 0x23, 0x64}, + {0x33, 0x25, 0x1f, 0x88, 0xdc, 0x99, 0x34, 0x28, 0xb6, 0x23, 0x93, + 0x77, 0xda, 0x25, 0x5, 0x9d, 0xf4, 0x41, 0x34, 0x67, 0xfb, 0xdd, + 0x7a, 0x89, 0x8d, 0x16, 0x3a, 0x16, 0x71, 0x9d, 0xb7, 0x32}, + {0x6a, 0xb3, 0xfc, 0xed, 0xd9, 0xf8, 0x85, 0xcc, 0xf9, 0xe5, 0x46, + 0x37, 0x8f, 0xc2, 0xbc, 0x22, 0xcd, 0xd3, 0xe5, 0xf9, 0x38, 0xe3, + 0x9d, 0xe4, 0xcc, 0x2d, 0x3e, 0xc1, 0xfb, 0x5e, 0xa, 0x48}, + }, + { + {0x1f, 0x22, 0xce, 0x42, 0xe4, 0x4c, 0x61, 0xb6, 0x28, 0x39, 0x5, + 0x4c, 0xcc, 0x9d, 0x19, 0x6e, 0x3, 0xbe, 0x1c, 0xdc, 0xa4, 0xb4, + 0x3f, 0x66, 0x6, 0x8e, 0x1c, 0x69, 0x47, 0x1d, 0xb3, 0x24}, + {0x71, 0x20, 0x62, 0x1, 0xb, 0xe7, 0x51, 0xb, 0xc5, 0xaf, 0x1d, + 0x8b, 0xcf, 0x5, 0xb5, 0x6, 0xcd, 0xab, 0x5a, 0xef, 0x61, 0xb0, + 0x6b, 0x2c, 0x31, 0xbf, 0xb7, 0xc, 0x60, 0x27, 0xaa, 0x47}, + {0xc3, 0xf8, 0x15, 0xc0, 0xed, 0x1e, 0x54, 0x2a, 0x7c, 0x3f, 0x69, + 0x7c, 0x7e, 0xfe, 0xa4, 0x11, 0xd6, 0x78, 0xa2, 0x4e, 0x13, 0x66, + 0xaf, 0xf0, 0x94, 0xa0, 0xdd, 0x14, 0x5d, 0x58, 0x5b, 0x54}, + }, + { + {0xe1, 0x21, 0xb3, 0xe3, 0xd0, 0xe4, 0x4, 0x62, 0x95, 0x1e, 0xff, + 0x28, 0x7a, 0x63, 0xaa, 0x3b, 0x9e, 0xbd, 0x99, 0x5b, 0xfd, 0xcf, + 0xc, 0xb, 0x71, 0xd0, 0xc8, 0x64, 0x3e, 0xdc, 0x22, 0x4d}, + {0xf, 0x3a, 0xd4, 0xa0, 0x5e, 0x27, 0xbf, 0x67, 0xbe, 0xee, 0x9b, + 0x8, 0x34, 0x8e, 0xe6, 0xad, 0x2e, 0xe7, 0x79, 0xd4, 0x4c, 0x13, + 0x89, 0x42, 0x54, 0x54, 0xba, 0x32, 0xc3, 0xf9, 0x62, 0xf}, + {0x39, 0x5f, 0x3b, 0xd6, 0x89, 0x65, 0xb4, 0xfc, 0x61, 0xcf, 0xcb, + 0x57, 0x3f, 0x6a, 0xae, 0x5c, 0x5, 0xfa, 0x3a, 0x95, 0xd2, 0xc2, + 0xba, 0xfe, 0x36, 0x14, 0x37, 0x36, 0x1a, 0xa0, 0xf, 0x1c}, + }, + }, + { + { + {0x50, 0x6a, 0x93, 0x8c, 0xe, 0x2b, 0x8, 0x69, 0xb6, 0xc5, 0xda, + 0xc1, 0x35, 0xa0, 0xc9, 0xf9, 0x34, 0xb6, 0xdf, 0xc4, 0x54, 0x3e, + 0xb7, 0x6f, 0x40, 0xc1, 0x2b, 0x1d, 0x9b, 0x41, 0x5, 0x40}, + {0xff, 0x3d, 0x94, 0x22, 0xb6, 0x4, 0xc6, 0xd2, 0xa0, 0xb3, 0xcf, + 0x44, 0xce, 0xbe, 0x8c, 0xbc, 0x78, 0x86, 0x80, 0x97, 0xf3, 0x4f, + 0x25, 0x5d, 0xbf, 0xa6, 0x1c, 0x3b, 0x4f, 0x61, 0xa3, 0xf}, + {0xf0, 0x82, 0xbe, 0xb9, 0xbd, 0xfe, 0x3, 0xa0, 0x90, 0xac, 0x44, + 0x3a, 0xaf, 0xc1, 0x89, 0x20, 0x8e, 0xfa, 0x54, 0x19, 0x91, 0x9f, + 0x49, 0xf8, 0x42, 0xab, 0x40, 0xef, 0x8a, 0x21, 0xba, 0x1f}, + }, + { + {0x94, 0x1, 0x7b, 0x3e, 0x4, 0x57, 0x3e, 0x4f, 0x7f, 0xaf, 0xda, + 0x8, 0xee, 0x3e, 0x1d, 0xa8, 0xf1, 0xde, 0xdc, 0x99, 0xab, 0xc6, + 0x39, 0xc8, 0xd5, 0x61, 0x77, 0xff, 0x13, 0x5d, 0x53, 0x6c}, + {0x3e, 0xf5, 0xc8, 0xfa, 0x48, 0x94, 0x54, 0xab, 0x41, 0x37, 0xa6, + 0x7b, 0x9a, 0xe8, 0xf6, 0x81, 0x1, 0x5e, 0x2b, 0x6c, 0x7d, 0x6c, + 0xfd, 0x74, 0x42, 0x6e, 0xc8, 0xa8, 0xca, 0x3a, 0x2e, 0x39}, + {0xaf, 0x35, 0x8a, 0x3e, 0xe9, 0x34, 0xbd, 0x4c, 0x16, 0xe8, 0x87, + 0x58, 0x44, 0x81, 0x7, 0x2e, 0xab, 0xb0, 0x9a, 0xf2, 0x76, 0x9c, + 0x31, 0x19, 0x3b, 0xc1, 0xa, 0xd5, 0xe4, 0x7f, 0xe1, 0x25}, + }, + { + {0xa7, 0x21, 0xf1, 0x76, 0xf5, 0x7f, 0x5f, 0x91, 0xe3, 0x87, 0xcd, + 0x2f, 0x27, 0x32, 0x4a, 0xc3, 0x26, 0xe5, 0x1b, 0x4d, 0xde, 0x2f, + 0xba, 0xcc, 0x9b, 0x89, 0x69, 0x89, 0x8f, 0x82, 0xba, 0x6b}, + {0x76, 0xf6, 0x4, 0x1e, 0xd7, 0x9b, 0x28, 0xa, 0x95, 0xf, 0x42, + 0xd6, 0x52, 0x1c, 0x8e, 0x20, 0xab, 0x1f, 0x69, 0x34, 0xb0, 0xd8, + 0x86, 0x51, 0x51, 0xb3, 0x9f, 0x2a, 0x44, 0x51, 0x57, 0x25}, + {0x1, 0x39, 0xfe, 0x90, 0x66, 0xbc, 0xd1, 0xe2, 0xd5, 0x7a, 0x99, + 0xa0, 0x18, 0x4a, 0xb5, 0x4c, 0xd4, 0x60, 0x84, 0xaf, 0x14, 0x69, + 0x1d, 0x97, 0xe4, 0x7b, 0x6b, 0x7f, 0x4f, 0x50, 0x9d, 0x55}, + }, + { + {0xfd, 0x66, 0xd2, 0xf6, 0xe7, 0x91, 0x48, 0x9c, 0x1b, 0x78, 0x7, + 0x3, 0x9b, 0xa1, 0x44, 0x7, 0x3b, 0xe2, 0x61, 0x60, 0x1d, 0x8f, + 0x38, 0x88, 0xe, 0xd5, 0x4b, 0x35, 0xa3, 0xa6, 0x3e, 0x12}, + {0xd5, 0x54, 0xeb, 0xb3, 0x78, 0x83, 0x73, 0xa7, 0x7c, 0x3c, 0x55, + 0xa5, 0x66, 0xd3, 0x69, 0x1d, 0xba, 0x0, 0x28, 0xf9, 0x62, 0xcf, + 0x26, 0xa, 0x17, 0x32, 0x7e, 0x80, 0xd5, 0x12, 0xab, 0x1}, + {0x96, 0x2d, 0xe3, 0x41, 0x90, 0x18, 0x8d, 0x11, 0x48, 0x58, 0x31, + 0xd8, 0xc2, 0xe3, 0xed, 0xb9, 0xd9, 0x45, 0x32, 0xd8, 0x71, 0x42, + 0xab, 0x1e, 0x54, 0xa1, 0x18, 0xc9, 0xe2, 0x61, 0x39, 0x4a}, + }, + { + {0x1e, 0x3f, 0x23, 0xf3, 0x44, 0xd6, 0x27, 0x3, 0x16, 0xf0, 0xfc, + 0x34, 0xe, 0x26, 0x9a, 0x49, 0x79, 0xb9, 0xda, 0xf2, 0x16, 0xa7, + 0xb5, 0x83, 0x1f, 0x11, 0xd4, 0x9b, 0xad, 0xee, 0xac, 0x68}, + {0xa0, 0xbb, 0xe6, 0xf8, 0xe0, 0x3b, 0xdc, 0x71, 0xa, 0xe3, 0xff, + 0x7e, 0x34, 0xf8, 0xce, 0xd6, 0x6a, 0x47, 0x3a, 0xe1, 0x5f, 0x42, + 0x92, 0xa9, 0x63, 0xb7, 0x1d, 0xfb, 0xe3, 0xbc, 0xd6, 0x2c}, + {0x10, 0xc2, 0xd7, 0xf3, 0xe, 0xc9, 0xb4, 0x38, 0xc, 0x4, 0xad, + 0xb7, 0x24, 0x6e, 0x8e, 0x30, 0x23, 0x3e, 0xe7, 0xb7, 0xf1, 0xd9, + 0x60, 0x38, 0x97, 0xf5, 0x8, 0xb5, 0xd5, 0x60, 0x57, 0x59}, + }, + { + {0x90, 0x27, 0x2, 0xfd, 0xeb, 0xcb, 0x2a, 0x88, 0x60, 0x57, 0x11, + 0xc4, 0x5, 0x33, 0xaf, 0x89, 0xf4, 0x73, 0x34, 0x7d, 0xe3, 0x92, + 0xf4, 0x65, 0x2b, 0x5a, 0x51, 0x54, 0xdf, 0xc5, 0xb2, 0x2c}, + {0x97, 0x63, 0xaa, 0x4, 0xe1, 0xbf, 0x29, 0x61, 0xcb, 0xfc, 0xa7, + 0xa4, 0x8, 0x0, 0x96, 0x8f, 0x58, 0x94, 0x90, 0x7d, 0x89, 0xc0, + 0x8b, 0x3f, 0xa9, 0x91, 0xb2, 0xdc, 0x3e, 0xa4, 0x9f, 0x70}, + {0xca, 0x2a, 0xfd, 0x63, 0x8c, 0x5d, 0xa, 0xeb, 0xff, 0x4e, 0x69, + 0x2e, 0x66, 0xc1, 0x2b, 0xd2, 0x3a, 0xb0, 0xcb, 0xf8, 0x6e, 0xf3, + 0x23, 0x27, 0x1f, 0x13, 0xc8, 0xf0, 0xec, 0x29, 0xf0, 0x70}, + }, + { + {0xb9, 0xb0, 0x10, 0x5e, 0xaa, 0xaf, 0x6a, 0x2a, 0xa9, 0x1a, 0x4, + 0xef, 0x70, 0xa3, 0xf0, 0x78, 0x1f, 0xd6, 0x3a, 0xaa, 0x77, 0xfb, + 0x3e, 0x77, 0xe1, 0xd9, 0x4b, 0xa7, 0xa2, 0xa5, 0xec, 0x44}, + {0x33, 0x3e, 0xed, 0x2e, 0xb3, 0x7, 0x13, 0x46, 0xe7, 0x81, 0x55, + 0xa4, 0x33, 0x2f, 0x4, 0xae, 0x66, 0x3, 0x5f, 0x19, 0xd3, 0x49, + 0x44, 0xc9, 0x58, 0x48, 0x31, 0x6c, 0x8a, 0x5d, 0x7d, 0xb}, + {0x43, 0xd5, 0x95, 0x7b, 0x32, 0x48, 0xd4, 0x25, 0x1d, 0xf, 0x34, + 0xa3, 0x0, 0x83, 0xd3, 0x70, 0x2b, 0xc5, 0xe1, 0x60, 0x1c, 0x53, + 0x1c, 0xde, 0xe4, 0xe9, 0x7d, 0x2c, 0x51, 0x24, 0x22, 0x27}, + }, + { + {0xfc, 0x75, 0xa9, 0x42, 0x8a, 0xbb, 0x7b, 0xbf, 0x58, 0xa3, 0xad, + 0x96, 0x77, 0x39, 0x5c, 0x8c, 0x48, 0xaa, 0xed, 0xcd, 0x6f, 0xc7, + 0x7f, 0xe2, 0xa6, 0x20, 0xbc, 0xf6, 0xd7, 0x5f, 0x73, 0x19}, + {0x2e, 0x34, 0xc5, 0x49, 0xaf, 0x92, 0xbc, 0x1a, 0xd0, 0xfa, 0xe6, + 0xb2, 0x11, 0xd8, 0xee, 0xff, 0x29, 0x4e, 0xc8, 0xfc, 0x8d, 0x8c, + 0xa2, 0xef, 0x43, 0xc5, 0x4c, 0xa4, 0x18, 0xdf, 0xb5, 0x11}, + {0x66, 0x42, 0xc8, 0x42, 0xd0, 0x90, 0xab, 0xe3, 0x7e, 0x54, 0x19, + 0x7f, 0xf, 0x8e, 0x84, 0xeb, 0xb9, 0x97, 0xa4, 0x65, 0xd0, 0xa1, + 0x3, 0x25, 0x5f, 0x89, 0xdf, 0x91, 0x11, 0x91, 0xef, 0xf}, + }, + }, +}; + +#endif // OPENSSL_SMALL + +// Bi[i] = (2*i+1)*B +static const ge_precomp Bi[8] = { + { + {{ +#if defined(OPENSSL_64_BIT) + 1288382639258501, 245678601348599, 269427782077623, + 1462984067271730, 137412439391563 +#else + 25967493, 19198397, 29566455, 3660896, 54414519, 4014786, 27544626, + 21800161, 61029707, 2047604 +#endif + }}, + {{ +#if defined(OPENSSL_64_BIT) + 62697248952638, 204681361388450, 631292143396476, 338455783676468, + 1213667448819585 +#else + 54563134, 934261, 64385954, 3049989, 66381436, 9406985, 12720692, + 5043384, 19500929, 18085054 +#endif + }}, + {{ +#if defined(OPENSSL_64_BIT) + 301289933810280, 1259582250014073, 1422107436869536, + 796239922652654, 1953934009299142 +#else + 58370664, 4489569, 9688441, 18769238, 10184608, 21191052, 29287918, + 11864899, 42594502, 29115885 +#endif + }}, + }, + { + {{ +#if defined(OPENSSL_64_BIT) + 1601611775252272, 1720807796594148, 1132070835939856, + 1260455018889551, 2147779492816911 +#else + 15636272, 23865875, 24204772, 25642034, 616976, 16869170, 27787599, + 18782243, 28944399, 32004408 +#endif + }}, + {{ +#if defined(OPENSSL_64_BIT) + 316559037616741, 2177824224946892, 1459442586438991, + 1461528397712656, 751590696113597 +#else + 16568933, 4717097, 55552716, 32452109, 15682895, 21747389, 16354576, + 21778470, 7689661, 11199574 +#endif + }}, + {{ +#if defined(OPENSSL_64_BIT) + 1850748884277385, 1200145853858453, 1068094770532492, + 672251375690438, 1586055907191707 +#else + 30464137, 27578307, 55329429, 17883566, 23220364, 15915852, 7512774, + 10017326, 49359771, 23634074 +#endif + }}, + }, + { + {{ +#if defined(OPENSSL_64_BIT) + 769950342298419, 132954430919746, 844085933195555, 974092374476333, + 726076285546016 +#else + 10861363, 11473154, 27284546, 1981175, 37044515, 12577860, 32867885, + 14515107, 51670560, 10819379 +#endif + }}, + {{ +#if defined(OPENSSL_64_BIT) + 425251763115706, 608463272472562, 442562545713235, 837766094556764, + 374555092627893 +#else + 4708026, 6336745, 20377586, 9066809, 55836755, 6594695, 41455196, + 12483687, 54440373, 5581305 +#endif + }}, + {{ +#if defined(OPENSSL_64_BIT) + 1086255230780037, 274979815921559, 1960002765731872, + 929474102396301, 1190409889297339 +#else + 19563141, 16186464, 37722007, 4097518, 10237984, 29206317, 28542349, + 13850243, 43430843, 17738489 +#endif + }}, + }, + { + {{ +#if defined(OPENSSL_64_BIT) + 665000864555967, 2065379846933859, 370231110385876, 350988370788628, + 1233371373142985 +#else + 5153727, 9909285, 1723747, 30776558, 30523604, 5516873, 19480852, + 5230134, 43156425, 18378665 +#endif + }}, + {{ +#if defined(OPENSSL_64_BIT) + 2019367628972465, 676711900706637, 110710997811333, + 1108646842542025, 517791959672113 +#else + 36839857, 30090922, 7665485, 10083793, 28475525, 1649722, 20654025, + 16520125, 30598449, 7715701 +#endif + }}, + {{ +#if defined(OPENSSL_64_BIT) + 965130719900578, 247011430587952, 526356006571389, 91986625355052, + 2157223321444601 +#else + 28881826, 14381568, 9657904, 3680757, 46927229, 7843315, 35708204, + 1370707, 29794553, 32145132 +#endif + }}, + }, + { + {{ +#if defined(OPENSSL_64_BIT) + 1802695059465007, 1664899123557221, 593559490740857, + 2160434469266659, 927570450755031 +#else + 44589871, 26862249, 14201701, 24808930, 43598457, 8844725, 18474211, + 32192982, 54046167, 13821876 +#endif + }}, + {{ +#if defined(OPENSSL_64_BIT) + 1725674970513508, 1933645953859181, 1542344539275782, + 1767788773573747, 1297447965928905 +#else + 60653668, 25714560, 3374701, 28813570, 40010246, 22982724, 31655027, + 26342105, 18853321, 19333481 +#endif + }}, + {{ +#if defined(OPENSSL_64_BIT) + 1381809363726107, 1430341051343062, 2061843536018959, + 1551778050872521, 2036394857967624 +#else + 4566811, 20590564, 38133974, 21313742, 59506191, 30723862, 58594505, + 23123294, 2207752, 30344648 +#endif + }}, + }, + { + {{ +#if defined(OPENSSL_64_BIT) + 1970894096313054, 528066325833207, 1619374932191227, + 2207306624415883, 1169170329061080 +#else + 41954014, 29368610, 29681143, 7868801, 60254203, 24130566, 54671499, + 32891431, 35997400, 17421995 +#endif + }}, + {{ +#if defined(OPENSSL_64_BIT) + 2070390218572616, 1458919061857835, 624171843017421, + 1055332792707765, 433987520732508 +#else + 25576264, 30851218, 7349803, 21739588, 16472781, 9300885, 3844789, + 15725684, 171356, 6466918 +#endif + }}, + {{ +#if defined(OPENSSL_64_BIT) + 893653801273833, 1168026499324677, 1242553501121234, + 1306366254304474, 1086752658510815 +#else + 23103977, 13316479, 9739013, 17404951, 817874, 18515490, 8965338, + 19466374, 36393951, 16193876 +#endif + }}, + }, + { + {{ +#if defined(OPENSSL_64_BIT) + 213454002618221, 939771523987438, 1159882208056014, 317388369627517, + 621213314200687 +#else + 33587053, 3180712, 64714734, 14003686, 50205390, 17283591, 17238397, + 4729455, 49034351, 9256799 +#endif + }}, + {{ +#if defined(OPENSSL_64_BIT) + 1971678598905747, 338026507889165, 762398079972271, 655096486107477, + 42299032696322 +#else + 41926547, 29380300, 32336397, 5036987, 45872047, 11360616, 22616405, + 9761698, 47281666, 630304 +#endif + }}, + {{ +#if defined(OPENSSL_64_BIT) + 177130678690680, 1754759263300204, 1864311296286618, + 1180675631479880, 1292726903152791 +#else + 53388152, 2639452, 42871404, 26147950, 9494426, 27780403, 60554312, + 17593437, 64659607, 19263131 +#endif + }}, + }, + { + {{ +#if defined(OPENSSL_64_BIT) + 1913163449625248, 460779200291993, 2193883288642314, + 1008900146920800, 1721983679009502 +#else + 63957664, 28508356, 9282713, 6866145, 35201802, 32691408, 48168288, + 15033783, 25105118, 25659556 +#endif + }}, + {{ +#if defined(OPENSSL_64_BIT) + 1070401523076875, 1272492007800961, 1910153608563310, + 2075579521696771, 1191169788841221 +#else + 42782475, 15950225, 35307649, 18961608, 55446126, 28463506, 1573891, + 30928545, 2198789, 17749813 +#endif + }}, + {{ +#if defined(OPENSSL_64_BIT) + 692896803108118, 500174642072499, 2068223309439677, + 1162190621851337, 1426986007309901 +#else + 64009494, 10324966, 64867251, 7453182, 61661885, 30818928, 53296841, + 17317989, 34647629, 21263748 +#endif + }}, + }, +}; diff --git a/http/vendor/ring/crypto/curve25519/internal.h b/http/vendor/ring/crypto/curve25519/internal.h new file mode 100644 index 0000000..d15a1b4 --- /dev/null +++ b/http/vendor/ring/crypto/curve25519/internal.h @@ -0,0 +1,135 @@ +// Copyright 2020 The BoringSSL Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef OPENSSL_HEADER_CURVE25519_INTERNAL_H +#define OPENSSL_HEADER_CURVE25519_INTERNAL_H + +#include + +#include "../internal.h" + + +#if defined(OPENSSL_ARM) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_APPLE) +#define BORINGSSL_X25519_NEON + +// x25519_NEON is defined in asm/x25519-arm.S. +void x25519_NEON(uint8_t out[32], const uint8_t scalar[32], + const uint8_t point[32]); +#endif + +#if !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_SMALL) && \ + defined(__GNUC__) && defined(__x86_64__) && !defined(OPENSSL_WINDOWS) +#define BORINGSSL_FE25519_ADX + +// fiat_curve25519_adx_mul is defined in +// third_party/fiat/asm/fiat_curve25519_adx_mul.S +void __attribute__((sysv_abi)) +fiat_curve25519_adx_mul(uint64_t out[4], const uint64_t in1[4], + const uint64_t in2[4]); + +// fiat_curve25519_adx_square is defined in +// third_party/fiat/asm/fiat_curve25519_adx_square.S +void __attribute__((sysv_abi)) +fiat_curve25519_adx_square(uint64_t out[4], const uint64_t in[4]); + +// x25519_scalar_mult_adx is defined in third_party/fiat/curve25519_64_adx.h +void x25519_scalar_mult_adx(uint8_t out[32], const uint8_t scalar[32], + const uint8_t point[32]); +void x25519_ge_scalarmult_base_adx(uint8_t h[4][32], const uint8_t a[32]); +#endif + +#if defined(OPENSSL_64_BIT) +// An element t, +// entries t[0]...t[4], represents the integer t[0]+2^51 t[1]+2^102 t[2]+2^153 +// t[3]+2^204 t[4]. +// fe limbs are bounded by 1.125*2^51. +// fe_loose limbs are bounded by 3.375*2^51. +typedef uint64_t fe_limb_t; +#define FE_NUM_LIMBS 5 +#else +// An element t, +// entries t[0]...t[9], represents the integer t[0]+2^26 t[1]+2^51 t[2]+2^77 +// t[3]+2^102 t[4]+...+2^230 t[9]. +// fe limbs are bounded by 1.125*2^26,1.125*2^25,1.125*2^26,1.125*2^25,etc. +// fe_loose limbs are bounded by 3.375*2^26,3.375*2^25,3.375*2^26,3.375*2^25,etc. +typedef uint32_t fe_limb_t; +#define FE_NUM_LIMBS 10 +#endif + +// fe means field element. Here the field is \Z/(2^255-19). +// Multiplication and carrying produce fe from fe_loose. +// Keep in sync with `Elem` and `ELEM_LIMBS` in curve25519/ops.rs. +typedef struct fe { fe_limb_t v[FE_NUM_LIMBS]; } fe; + +// Addition and subtraction produce fe_loose from (fe, fe). +// Keep in sync with `Elem` and `ELEM_LIMBS` in curve25519/ops.rs. +typedef struct fe_loose { fe_limb_t v[FE_NUM_LIMBS]; } fe_loose; + +static inline void fe_limbs_copy(fe_limb_t r[], const fe_limb_t a[]) { + for (size_t i = 0; i < FE_NUM_LIMBS; ++i) { + r[i] = a[i]; + } +} + +// ge means group element. +// +// Here the group is the set of pairs (x,y) of field elements (see fe.h) +// satisfying -x^2 + y^2 = 1 + d x^2y^2 +// where d = -121665/121666. +// +// Representations: +// ge_p2 (projective): (X:Y:Z) satisfying x=X/Z, y=Y/Z +// ge_p3 (extended): (X:Y:Z:T) satisfying x=X/Z, y=Y/Z, XY=ZT +// ge_p1p1 (completed): ((X:Z),(Y:T)) satisfying x=X/Z, y=Y/T +// ge_precomp (Duif): (y+x,y-x,2dxy) + +// Keep in sync with `Point` in curve25519/ops.rs. +typedef struct { + fe X; + fe Y; + fe Z; +} ge_p2; + + +// Keep in sync with `ExtPoint` in curve25519/ops.rs. +typedef struct { + fe X; + fe Y; + fe Z; + fe T; +} ge_p3; + +typedef struct { + fe_loose X; + fe_loose Y; + fe_loose Z; + fe_loose T; +} ge_p1p1; + +typedef struct { + fe_loose yplusx; + fe_loose yminusx; + fe_loose xy2d; +} ge_precomp; + +typedef struct { + fe_loose YplusX; + fe_loose YminusX; + fe_loose Z; + fe_loose T2d; +} ge_cached; + +extern const uint8_t k25519Precomp[32][8][3][32]; + +#endif // OPENSSL_HEADER_CURVE25519_INTERNAL_H diff --git a/http/vendor/ring/crypto/fipsmodule/aes/aes_nohw.c b/http/vendor/ring/crypto/fipsmodule/aes/aes_nohw.c new file mode 100644 index 0000000..9530cbc --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/aes/aes_nohw.c @@ -0,0 +1,881 @@ +/* Copyright (c) 2019, Google Inc. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#include + +#include "../../internal.h" + +// This file contains a constant-time implementation of AES, bitsliced with +// 32-bit or 64-bit, operating on two-, four-, and eight-block +// batches, respectively. +// +// This implementation is based on the algorithms described in the following +// references: +// - https://bearssl.org/constanttime.html#aes +// - https://eprint.iacr.org/2009/129.pdf +// - https://eprint.iacr.org/2009/191.pdf + + +// Word operations. +// +// An aes_word_t is the word used for this AES implementation. Throughout this +// file, bits and bytes are ordered little-endian, though "left" and "right" +// shifts match the operations themselves, which makes them reversed in a +// little-endian, left-to-right reading. +// +// Eight |aes_word_t|s contain |AES_NOHW_BATCH_SIZE| blocks. The bits in an +// |aes_word_t| are divided into 16 consecutive groups of |AES_NOHW_BATCH_SIZE| +// bits each, each corresponding to a byte in an AES block in column-major +// order (AES's byte order). We refer to these as "logical bytes". Note, in the +// 32-bit and 64-bit implementations, they are smaller than a byte. (The +// contents of a logical byte will be described later.) +// +// MSVC does not support C bit operators on |__m128i|, so the wrapper functions +// |aes_nohw_and|, etc., should be used instead. Note |aes_nohw_shift_left| and +// |aes_nohw_shift_right| measure the shift in logical bytes. That is, the shift +// value ranges from 0 to 15 independent of |aes_word_t| and +// |AES_NOHW_BATCH_SIZE|. +// +// This ordering is different from https://eprint.iacr.org/2009/129.pdf, which +// uses row-major order. Matching the AES order was easier to reason about, and +// we do not have PSHUFB available to arbitrarily permute bytes. + +#if defined(OPENSSL_64_BIT) +typedef uint64_t aes_word_t; +#define AES_NOHW_WORD_SIZE 8 +#define AES_NOHW_BATCH_SIZE 4 +#define AES_NOHW_ROW0_MASK UINT64_C(0x000f000f000f000f) +#define AES_NOHW_ROW1_MASK UINT64_C(0x00f000f000f000f0) +#define AES_NOHW_ROW2_MASK UINT64_C(0x0f000f000f000f00) +#define AES_NOHW_ROW3_MASK UINT64_C(0xf000f000f000f000) +#else // !OPENSSL_64_BIT +typedef uint32_t aes_word_t; +#define AES_NOHW_WORD_SIZE 4 +#define AES_NOHW_BATCH_SIZE 2 +#define AES_NOHW_ROW0_MASK 0x03030303 +#define AES_NOHW_ROW1_MASK 0x0c0c0c0c +#define AES_NOHW_ROW2_MASK 0x30303030 +#define AES_NOHW_ROW3_MASK 0xc0c0c0c0 +#endif // OPENSSL_64_BIT + +static inline aes_word_t aes_nohw_and(aes_word_t a, aes_word_t b) { + return a & b; +} + +static inline aes_word_t aes_nohw_or(aes_word_t a, aes_word_t b) { + return a | b; +} + +static inline aes_word_t aes_nohw_xor(aes_word_t a, aes_word_t b) { + return a ^ b; +} + +static inline aes_word_t aes_nohw_not(aes_word_t a) { return ~a; } + +static inline aes_word_t aes_nohw_shift_left(aes_word_t a, aes_word_t i) { + return a << (i * AES_NOHW_BATCH_SIZE); +} + +static inline aes_word_t aes_nohw_shift_right(aes_word_t a, aes_word_t i) { + return a >> (i * AES_NOHW_BATCH_SIZE); +} + +OPENSSL_STATIC_ASSERT(AES_NOHW_BATCH_SIZE * 128 == 8 * 8 * sizeof(aes_word_t), + "batch size does not match word size"); +OPENSSL_STATIC_ASSERT(AES_NOHW_WORD_SIZE == sizeof(aes_word_t), + "AES_NOHW_WORD_SIZE is incorrect"); + + +// Block representations. +// +// This implementation uses three representations for AES blocks. First, the +// public API represents blocks as uint8_t[16] in the usual way. Second, most +// AES steps are evaluated in bitsliced form, stored in an |AES_NOHW_BATCH|. +// This stores |AES_NOHW_BATCH_SIZE| blocks in bitsliced order. For 64-bit words +// containing bitsliced blocks a, b, c, d, this would be as follows (vertical +// bars divide logical bytes): +// +// batch.w[0] = a0 b0 c0 d0 | a8 b8 c8 d8 | a16 b16 c16 d16 ... +// batch.w[1] = a1 b1 c1 d1 | a9 b9 c9 d9 | a17 b17 c17 d17 ... +// batch.w[2] = a2 b2 c2 d2 | a10 b10 c10 d10 | a18 b18 c18 d18 ... +// batch.w[3] = a3 b3 c3 d3 | a11 b11 c11 d11 | a19 b19 c19 d19 ... +// ... +// +// Finally, an individual block may be stored as an intermediate form in an +// aes_word_t[AES_NOHW_BLOCK_WORDS]. In this form, we permute the bits in each +// block, so that block[0]'s ith logical byte contains least-significant +// |AES_NOHW_BATCH_SIZE| bits of byte i, block[1] contains the next group of +// |AES_NOHW_BATCH_SIZE| bits, and so on. We refer to this transformation as +// "compacting" the block. Note this is no-op with 128-bit words because then +// |AES_NOHW_BLOCK_WORDS| is one and |AES_NOHW_BATCH_SIZE| is eight. For 64-bit +// words, one block would be stored in two words: +// +// block[0] = a0 a1 a2 a3 | a8 a9 a10 a11 | a16 a17 a18 a19 ... +// block[1] = a4 a5 a6 a7 | a12 a13 a14 a15 | a20 a21 a22 a23 ... +// +// Observe that the distances between corresponding bits in bitsliced and +// compact bit orders match. If we line up corresponding words of each block, +// the bitsliced and compact representations may be converted by tranposing bits +// in corresponding logical bytes. Continuing the 64-bit example: +// +// block_a[0] = a0 a1 a2 a3 | a8 a9 a10 a11 | a16 a17 a18 a19 ... +// block_b[0] = b0 b1 b2 b3 | b8 b9 b10 b11 | b16 b17 b18 b19 ... +// block_c[0] = c0 c1 c2 c3 | c8 c9 c10 c11 | c16 c17 c18 c19 ... +// block_d[0] = d0 d1 d2 d3 | d8 d9 d10 d11 | d16 d17 d18 d19 ... +// +// batch.w[0] = a0 b0 c0 d0 | a8 b8 c8 d8 | a16 b16 c16 d16 ... +// batch.w[1] = a1 b1 c1 d1 | a9 b9 c9 d9 | a17 b17 c17 d17 ... +// batch.w[2] = a2 b2 c2 d2 | a10 b10 c10 d10 | a18 b18 c18 d18 ... +// batch.w[3] = a3 b3 c3 d3 | a11 b11 c11 d11 | a19 b19 c19 d19 ... +// +// Note also that bitwise operations and (logical) byte permutations on an +// |aes_word_t| work equally for the bitsliced and compact words. +// +// We use the compact form in the |AES_KEY| representation to save work +// inflating round keys into |AES_NOHW_BATCH|. The compact form also exists +// temporarily while moving blocks in or out of an |AES_NOHW_BATCH|, immediately +// before or after |aes_nohw_transpose|. + +#define AES_NOHW_BLOCK_WORDS (16 / sizeof(aes_word_t)) + +// An AES_NOHW_BATCH stores |AES_NOHW_BATCH_SIZE| blocks. Unless otherwise +// specified, it is in bitsliced form. +typedef struct { + aes_word_t w[8]; +} AES_NOHW_BATCH; + +// An AES_NOHW_SCHEDULE is an expanded bitsliced AES key schedule. It is +// suitable for encryption or decryption. It is as large as |AES_NOHW_BATCH| +// |AES_KEY|s so it should not be used as a long-term key representation. +typedef struct { + // keys is an array of batches, one for each round key. Each batch stores + // |AES_NOHW_BATCH_SIZE| copies of the round key in bitsliced form. + AES_NOHW_BATCH keys[AES_MAXNR + 1]; +} AES_NOHW_SCHEDULE; + +// aes_nohw_batch_set sets the |i|th block of |batch| to |in|. |batch| is in +// compact form. +static inline void aes_nohw_batch_set(AES_NOHW_BATCH *batch, + const aes_word_t in[AES_NOHW_BLOCK_WORDS], + size_t i) { + // Note the words are interleaved. The order comes from |aes_nohw_transpose|. + // If |i| is zero and this is the 64-bit implementation, in[0] contains bits + // 0-3 and in[1] contains bits 4-7. We place in[0] at w[0] and in[1] at + // w[4] so that bits 0 and 4 are in the correct position. (In general, bits + // along diagonals of |AES_NOHW_BATCH_SIZE| by |AES_NOHW_BATCH_SIZE| squares + // will be correctly placed.) + dev_assert_secret(i < AES_NOHW_BATCH_SIZE); +#if defined(OPENSSL_64_BIT) + batch->w[i] = in[0]; + batch->w[i + 4] = in[1]; +#else + batch->w[i] = in[0]; + batch->w[i + 2] = in[1]; + batch->w[i + 4] = in[2]; + batch->w[i + 6] = in[3]; +#endif +} + +// aes_nohw_batch_get writes the |i|th block of |batch| to |out|. |batch| is in +// compact form. +static inline void aes_nohw_batch_get(const AES_NOHW_BATCH *batch, + aes_word_t out[AES_NOHW_BLOCK_WORDS], + size_t i) { + dev_assert_secret(i < AES_NOHW_BATCH_SIZE); +#if defined(OPENSSL_64_BIT) + out[0] = batch->w[i]; + out[1] = batch->w[i + 4]; +#else + out[0] = batch->w[i]; + out[1] = batch->w[i + 2]; + out[2] = batch->w[i + 4]; + out[3] = batch->w[i + 6]; +#endif +} + +// aes_nohw_delta_swap returns |a| with bits |a & mask| and +// |a & (mask << shift)| swapped. |mask| and |mask << shift| may not overlap. +static inline aes_word_t aes_nohw_delta_swap(aes_word_t a, aes_word_t mask, + aes_word_t shift) { + // See + // https://reflectionsonsecurity.wordpress.com/2014/05/11/efficient-bit-permutation-using-delta-swaps/ + aes_word_t b = (a ^ (a >> shift)) & mask; + return a ^ b ^ (b << shift); +} + +// In the 32-bit and 64-bit implementations, a block spans multiple words. +// |aes_nohw_compact_block| must permute bits across different words. First we +// implement |aes_nohw_compact_word| which performs a smaller version of the +// transformation which stays within a single word. +// +// These transformations are generalizations of the output of +// http://programming.sirrida.de/calcperm.php on smaller inputs. +#if defined(OPENSSL_64_BIT) +static inline uint64_t aes_nohw_compact_word(uint64_t a) { +#if defined(RING_BIG_ENDIAN) + a = CRYPTO_bswap8(a); +#endif + // Numbering the 64/2 = 16 4-bit chunks, least to most significant, we swap + // quartets of those chunks: + // 0 1 2 3 | 4 5 6 7 | 8 9 10 11 | 12 13 14 15 => + // 0 2 1 3 | 4 6 5 7 | 8 10 9 11 | 12 14 13 15 + a = aes_nohw_delta_swap(a, UINT64_C(0x00f000f000f000f0), 4); + // Swap quartets of 8-bit chunks (still numbering by 4-bit chunks): + // 0 2 1 3 | 4 6 5 7 | 8 10 9 11 | 12 14 13 15 => + // 0 2 4 6 | 1 3 5 7 | 8 10 12 14 | 9 11 13 15 + a = aes_nohw_delta_swap(a, UINT64_C(0x0000ff000000ff00), 8); + // Swap quartets of 16-bit chunks (still numbering by 4-bit chunks): + // 0 2 4 6 | 1 3 5 7 | 8 10 12 14 | 9 11 13 15 => + // 0 2 4 6 | 8 10 12 14 | 1 3 5 7 | 9 11 13 15 + a = aes_nohw_delta_swap(a, UINT64_C(0x00000000ffff0000), 16); + return a; +} + +static inline uint64_t aes_nohw_uncompact_word(uint64_t a) { + // Reverse the steps of |aes_nohw_uncompact_word|. + a = aes_nohw_delta_swap(a, UINT64_C(0x00000000ffff0000), 16); + a = aes_nohw_delta_swap(a, UINT64_C(0x0000ff000000ff00), 8); + a = aes_nohw_delta_swap(a, UINT64_C(0x00f000f000f000f0), 4); +#if defined(RING_BIG_ENDIAN) + a = CRYPTO_bswap8(a); +#endif + return a; +} +#else // !OPENSSL_64_BIT +static inline uint32_t aes_nohw_compact_word(uint32_t a) { +#if defined(RING_BIG_ENDIAN) + a = CRYPTO_bswap4(a); +#endif + // Numbering the 32/2 = 16 pairs of bits, least to most significant, we swap: + // 0 1 2 3 | 4 5 6 7 | 8 9 10 11 | 12 13 14 15 => + // 0 4 2 6 | 1 5 3 7 | 8 12 10 14 | 9 13 11 15 + // Note: 0x00cc = 0b0000_0000_1100_1100 + // 0x00cc << 6 = 0b0011_0011_0000_0000 + a = aes_nohw_delta_swap(a, 0x00cc00cc, 6); + // Now we swap groups of four bits (still numbering by pairs): + // 0 4 2 6 | 1 5 3 7 | 8 12 10 14 | 9 13 11 15 => + // 0 4 8 12 | 1 5 9 13 | 2 6 10 14 | 3 7 11 15 + // Note: 0x0000_f0f0 << 12 = 0x0f0f_0000 + a = aes_nohw_delta_swap(a, 0x0000f0f0, 12); + return a; +} + +static inline uint32_t aes_nohw_uncompact_word(uint32_t a) { + // Reverse the steps of |aes_nohw_uncompact_word|. + a = aes_nohw_delta_swap(a, 0x0000f0f0, 12); + a = aes_nohw_delta_swap(a, 0x00cc00cc, 6); +#if defined(RING_BIG_ENDIAN) + a = CRYPTO_bswap4(a); +#endif + return a; +} + +static inline uint32_t aes_nohw_word_from_bytes(uint8_t a0, uint8_t a1, + uint8_t a2, uint8_t a3) { + return (uint32_t)a0 | ((uint32_t)a1 << 8) | ((uint32_t)a2 << 16) | + ((uint32_t)a3 << 24); +} + +static inline uint8_t lo(uint32_t a) { + return (uint8_t)a; +} + +#endif // OPENSSL_64_BIT + +static inline void aes_nohw_compact_block(aes_word_t out[AES_NOHW_BLOCK_WORDS], + const uint8_t in[16]) { + OPENSSL_memcpy(out, in, 16); +#if defined(OPENSSL_64_BIT) + uint64_t a0 = aes_nohw_compact_word(out[0]); + uint64_t a1 = aes_nohw_compact_word(out[1]); + out[0] = (a0 & UINT64_C(0x00000000ffffffff)) | (a1 << 32); + out[1] = (a1 & UINT64_C(0xffffffff00000000)) | (a0 >> 32); +#else + uint32_t a0 = aes_nohw_compact_word(out[0]); + uint32_t a1 = aes_nohw_compact_word(out[1]); + uint32_t a2 = aes_nohw_compact_word(out[2]); + uint32_t a3 = aes_nohw_compact_word(out[3]); + // Note clang, when building for ARM Thumb2, will sometimes miscompile + // expressions such as (a0 & 0x0000ff00) << 8, particularly when building + // without optimizations. This bug was introduced in + // https://reviews.llvm.org/rL340261 and fixed in + // https://reviews.llvm.org/rL351310. The following is written to avoid this. + out[0] = aes_nohw_word_from_bytes(lo(a0), lo(a1), lo(a2), lo(a3)); + out[1] = aes_nohw_word_from_bytes(lo(a0 >> 8), lo(a1 >> 8), lo(a2 >> 8), lo(a3 >> 8)); + out[2] = aes_nohw_word_from_bytes(lo(a0 >> 16), lo(a1 >> 16), lo(a2 >> 16), lo(a3 >> 16)); + out[3] = aes_nohw_word_from_bytes(lo(a0 >> 24), lo(a1 >> 24), lo(a2 >> 24), lo(a3 >> 24)); +#endif +} + +static inline void aes_nohw_uncompact_block( + uint8_t out[16], const aes_word_t in[AES_NOHW_BLOCK_WORDS]) { +#if defined(OPENSSL_64_BIT) + uint64_t a0 = in[0]; + uint64_t a1 = in[1]; + uint64_t b0 = + aes_nohw_uncompact_word((a0 & UINT64_C(0x00000000ffffffff)) | (a1 << 32)); + uint64_t b1 = + aes_nohw_uncompact_word((a1 & UINT64_C(0xffffffff00000000)) | (a0 >> 32)); + OPENSSL_memcpy(out, &b0, 8); + OPENSSL_memcpy(out + 8, &b1, 8); +#else + uint32_t a0 = in[0]; + uint32_t a1 = in[1]; + uint32_t a2 = in[2]; + uint32_t a3 = in[3]; + // Note clang, when building for ARM Thumb2, will sometimes miscompile + // expressions such as (a0 & 0x0000ff00) << 8, particularly when building + // without optimizations. This bug was introduced in + // https://reviews.llvm.org/rL340261 and fixed in + // https://reviews.llvm.org/rL351310. The following is written to avoid this. + uint32_t b0 = aes_nohw_word_from_bytes(lo(a0), lo(a1), lo(a2), lo(a3)); + uint32_t b1 = aes_nohw_word_from_bytes(lo(a0 >> 8), lo(a1 >> 8), lo(a2 >> 8), lo(a3 >> 8)); + uint32_t b2 = + aes_nohw_word_from_bytes(lo(a0 >> 16), lo(a1 >> 16), lo(a2 >> 16), lo(a3 >> 16)); + uint32_t b3 = + aes_nohw_word_from_bytes(lo(a0 >> 24), lo(a1 >> 24), lo(a2 >> 24), lo(a3 >> 24)); + b0 = aes_nohw_uncompact_word(b0); + b1 = aes_nohw_uncompact_word(b1); + b2 = aes_nohw_uncompact_word(b2); + b3 = aes_nohw_uncompact_word(b3); + OPENSSL_memcpy(out, &b0, 4); + OPENSSL_memcpy(out + 4, &b1, 4); + OPENSSL_memcpy(out + 8, &b2, 4); + OPENSSL_memcpy(out + 12, &b3, 4); +#endif +} + +// aes_nohw_swap_bits is a variation on a delta swap. It swaps the bits in +// |*a & (mask << shift)| with the bits in |*b & mask|. |mask| and +// |mask << shift| must not overlap. |mask| is specified as a |uint32_t|, but it +// is repeated to the full width of |aes_word_t|. +static inline void aes_nohw_swap_bits(aes_word_t *a, aes_word_t *b, + uint32_t mask, aes_word_t shift) { +#if defined(OPENSSL_64_BIT) + aes_word_t mask_w = (((uint64_t)mask) << 32) | mask; +#else + aes_word_t mask_w = mask; +#endif + // This is a variation on a delta swap. + aes_word_t swap = ((*a >> shift) ^ *b) & mask_w; + *a ^= swap << shift; + *b ^= swap; +} + +// aes_nohw_transpose converts |batch| to and from bitsliced form. It divides +// the 8 × word_size bits into AES_NOHW_BATCH_SIZE × AES_NOHW_BATCH_SIZE squares +// and transposes each square. +static void aes_nohw_transpose(AES_NOHW_BATCH *batch) { + // Swap bits with index 0 and 1 mod 2 (0x55 = 0b01010101). + aes_nohw_swap_bits(&batch->w[0], &batch->w[1], 0x55555555, 1); + aes_nohw_swap_bits(&batch->w[2], &batch->w[3], 0x55555555, 1); + aes_nohw_swap_bits(&batch->w[4], &batch->w[5], 0x55555555, 1); + aes_nohw_swap_bits(&batch->w[6], &batch->w[7], 0x55555555, 1); + +#if AES_NOHW_BATCH_SIZE >= 4 + // Swap bits with index 0-1 and 2-3 mod 4 (0x33 = 0b00110011). + aes_nohw_swap_bits(&batch->w[0], &batch->w[2], 0x33333333, 2); + aes_nohw_swap_bits(&batch->w[1], &batch->w[3], 0x33333333, 2); + aes_nohw_swap_bits(&batch->w[4], &batch->w[6], 0x33333333, 2); + aes_nohw_swap_bits(&batch->w[5], &batch->w[7], 0x33333333, 2); +#endif + +#if AES_NOHW_BATCH_SIZE >= 8 + // Swap bits with index 0-3 and 4-7 mod 8 (0x0f = 0b00001111). + aes_nohw_swap_bits(&batch->w[0], &batch->w[4], 0x0f0f0f0f, 4); + aes_nohw_swap_bits(&batch->w[1], &batch->w[5], 0x0f0f0f0f, 4); + aes_nohw_swap_bits(&batch->w[2], &batch->w[6], 0x0f0f0f0f, 4); + aes_nohw_swap_bits(&batch->w[3], &batch->w[7], 0x0f0f0f0f, 4); +#endif +} + +// aes_nohw_to_batch initializes |out| with the |num_blocks| blocks from |in|. +// |num_blocks| must be at most |AES_NOHW_BATCH|. +static void aes_nohw_to_batch(AES_NOHW_BATCH *out, const uint8_t *in, + size_t num_blocks) { + // Don't leave unused blocks uninitialized. + OPENSSL_memset(out, 0, sizeof(AES_NOHW_BATCH)); + debug_assert_nonsecret(num_blocks <= AES_NOHW_BATCH_SIZE); + for (size_t i = 0; i < num_blocks; i++) { + aes_word_t block[AES_NOHW_BLOCK_WORDS]; + aes_nohw_compact_block(block, in + 16 * i); + aes_nohw_batch_set(out, block, i); + } + + aes_nohw_transpose(out); +} + +// aes_nohw_to_batch writes the first |num_blocks| blocks in |batch| to |out|. +// |num_blocks| must be at most |AES_NOHW_BATCH|. +static void aes_nohw_from_batch(uint8_t *out, size_t num_blocks, + const AES_NOHW_BATCH *batch) { + AES_NOHW_BATCH copy = *batch; + aes_nohw_transpose(©); + + debug_assert_nonsecret(num_blocks <= AES_NOHW_BATCH_SIZE); + for (size_t i = 0; i < num_blocks; i++) { + aes_word_t block[AES_NOHW_BLOCK_WORDS]; + aes_nohw_batch_get(©, block, i); + aes_nohw_uncompact_block(out + 16 * i, block); + } +} + + +// AES round steps. + +static void aes_nohw_add_round_key(AES_NOHW_BATCH *batch, + const AES_NOHW_BATCH *key) { + for (size_t i = 0; i < 8; i++) { + batch->w[i] = aes_nohw_xor(batch->w[i], key->w[i]); + } +} + +static void aes_nohw_sub_bytes(AES_NOHW_BATCH *batch) { + // See https://eprint.iacr.org/2009/191.pdf, Appendix C. + aes_word_t x0 = batch->w[7]; + aes_word_t x1 = batch->w[6]; + aes_word_t x2 = batch->w[5]; + aes_word_t x3 = batch->w[4]; + aes_word_t x4 = batch->w[3]; + aes_word_t x5 = batch->w[2]; + aes_word_t x6 = batch->w[1]; + aes_word_t x7 = batch->w[0]; + + // Figure 2, the top linear transformation. + aes_word_t y14 = aes_nohw_xor(x3, x5); + aes_word_t y13 = aes_nohw_xor(x0, x6); + aes_word_t y9 = aes_nohw_xor(x0, x3); + aes_word_t y8 = aes_nohw_xor(x0, x5); + aes_word_t t0 = aes_nohw_xor(x1, x2); + aes_word_t y1 = aes_nohw_xor(t0, x7); + aes_word_t y4 = aes_nohw_xor(y1, x3); + aes_word_t y12 = aes_nohw_xor(y13, y14); + aes_word_t y2 = aes_nohw_xor(y1, x0); + aes_word_t y5 = aes_nohw_xor(y1, x6); + aes_word_t y3 = aes_nohw_xor(y5, y8); + aes_word_t t1 = aes_nohw_xor(x4, y12); + aes_word_t y15 = aes_nohw_xor(t1, x5); + aes_word_t y20 = aes_nohw_xor(t1, x1); + aes_word_t y6 = aes_nohw_xor(y15, x7); + aes_word_t y10 = aes_nohw_xor(y15, t0); + aes_word_t y11 = aes_nohw_xor(y20, y9); + aes_word_t y7 = aes_nohw_xor(x7, y11); + aes_word_t y17 = aes_nohw_xor(y10, y11); + aes_word_t y19 = aes_nohw_xor(y10, y8); + aes_word_t y16 = aes_nohw_xor(t0, y11); + aes_word_t y21 = aes_nohw_xor(y13, y16); + aes_word_t y18 = aes_nohw_xor(x0, y16); + + // Figure 3, the middle non-linear section. + aes_word_t t2 = aes_nohw_and(y12, y15); + aes_word_t t3 = aes_nohw_and(y3, y6); + aes_word_t t4 = aes_nohw_xor(t3, t2); + aes_word_t t5 = aes_nohw_and(y4, x7); + aes_word_t t6 = aes_nohw_xor(t5, t2); + aes_word_t t7 = aes_nohw_and(y13, y16); + aes_word_t t8 = aes_nohw_and(y5, y1); + aes_word_t t9 = aes_nohw_xor(t8, t7); + aes_word_t t10 = aes_nohw_and(y2, y7); + aes_word_t t11 = aes_nohw_xor(t10, t7); + aes_word_t t12 = aes_nohw_and(y9, y11); + aes_word_t t13 = aes_nohw_and(y14, y17); + aes_word_t t14 = aes_nohw_xor(t13, t12); + aes_word_t t15 = aes_nohw_and(y8, y10); + aes_word_t t16 = aes_nohw_xor(t15, t12); + aes_word_t t17 = aes_nohw_xor(t4, t14); + aes_word_t t18 = aes_nohw_xor(t6, t16); + aes_word_t t19 = aes_nohw_xor(t9, t14); + aes_word_t t20 = aes_nohw_xor(t11, t16); + aes_word_t t21 = aes_nohw_xor(t17, y20); + aes_word_t t22 = aes_nohw_xor(t18, y19); + aes_word_t t23 = aes_nohw_xor(t19, y21); + aes_word_t t24 = aes_nohw_xor(t20, y18); + aes_word_t t25 = aes_nohw_xor(t21, t22); + aes_word_t t26 = aes_nohw_and(t21, t23); + aes_word_t t27 = aes_nohw_xor(t24, t26); + aes_word_t t28 = aes_nohw_and(t25, t27); + aes_word_t t29 = aes_nohw_xor(t28, t22); + aes_word_t t30 = aes_nohw_xor(t23, t24); + aes_word_t t31 = aes_nohw_xor(t22, t26); + aes_word_t t32 = aes_nohw_and(t31, t30); + aes_word_t t33 = aes_nohw_xor(t32, t24); + aes_word_t t34 = aes_nohw_xor(t23, t33); + aes_word_t t35 = aes_nohw_xor(t27, t33); + aes_word_t t36 = aes_nohw_and(t24, t35); + aes_word_t t37 = aes_nohw_xor(t36, t34); + aes_word_t t38 = aes_nohw_xor(t27, t36); + aes_word_t t39 = aes_nohw_and(t29, t38); + aes_word_t t40 = aes_nohw_xor(t25, t39); + aes_word_t t41 = aes_nohw_xor(t40, t37); + aes_word_t t42 = aes_nohw_xor(t29, t33); + aes_word_t t43 = aes_nohw_xor(t29, t40); + aes_word_t t44 = aes_nohw_xor(t33, t37); + aes_word_t t45 = aes_nohw_xor(t42, t41); + aes_word_t z0 = aes_nohw_and(t44, y15); + aes_word_t z1 = aes_nohw_and(t37, y6); + aes_word_t z2 = aes_nohw_and(t33, x7); + aes_word_t z3 = aes_nohw_and(t43, y16); + aes_word_t z4 = aes_nohw_and(t40, y1); + aes_word_t z5 = aes_nohw_and(t29, y7); + aes_word_t z6 = aes_nohw_and(t42, y11); + aes_word_t z7 = aes_nohw_and(t45, y17); + aes_word_t z8 = aes_nohw_and(t41, y10); + aes_word_t z9 = aes_nohw_and(t44, y12); + aes_word_t z10 = aes_nohw_and(t37, y3); + aes_word_t z11 = aes_nohw_and(t33, y4); + aes_word_t z12 = aes_nohw_and(t43, y13); + aes_word_t z13 = aes_nohw_and(t40, y5); + aes_word_t z14 = aes_nohw_and(t29, y2); + aes_word_t z15 = aes_nohw_and(t42, y9); + aes_word_t z16 = aes_nohw_and(t45, y14); + aes_word_t z17 = aes_nohw_and(t41, y8); + + // Figure 4, bottom linear transformation. + aes_word_t t46 = aes_nohw_xor(z15, z16); + aes_word_t t47 = aes_nohw_xor(z10, z11); + aes_word_t t48 = aes_nohw_xor(z5, z13); + aes_word_t t49 = aes_nohw_xor(z9, z10); + aes_word_t t50 = aes_nohw_xor(z2, z12); + aes_word_t t51 = aes_nohw_xor(z2, z5); + aes_word_t t52 = aes_nohw_xor(z7, z8); + aes_word_t t53 = aes_nohw_xor(z0, z3); + aes_word_t t54 = aes_nohw_xor(z6, z7); + aes_word_t t55 = aes_nohw_xor(z16, z17); + aes_word_t t56 = aes_nohw_xor(z12, t48); + aes_word_t t57 = aes_nohw_xor(t50, t53); + aes_word_t t58 = aes_nohw_xor(z4, t46); + aes_word_t t59 = aes_nohw_xor(z3, t54); + aes_word_t t60 = aes_nohw_xor(t46, t57); + aes_word_t t61 = aes_nohw_xor(z14, t57); + aes_word_t t62 = aes_nohw_xor(t52, t58); + aes_word_t t63 = aes_nohw_xor(t49, t58); + aes_word_t t64 = aes_nohw_xor(z4, t59); + aes_word_t t65 = aes_nohw_xor(t61, t62); + aes_word_t t66 = aes_nohw_xor(z1, t63); + aes_word_t s0 = aes_nohw_xor(t59, t63); + aes_word_t s6 = aes_nohw_xor(t56, aes_nohw_not(t62)); + aes_word_t s7 = aes_nohw_xor(t48, aes_nohw_not(t60)); + aes_word_t t67 = aes_nohw_xor(t64, t65); + aes_word_t s3 = aes_nohw_xor(t53, t66); + aes_word_t s4 = aes_nohw_xor(t51, t66); + aes_word_t s5 = aes_nohw_xor(t47, t65); + aes_word_t s1 = aes_nohw_xor(t64, aes_nohw_not(s3)); + aes_word_t s2 = aes_nohw_xor(t55, aes_nohw_not(t67)); + + batch->w[0] = s7; + batch->w[1] = s6; + batch->w[2] = s5; + batch->w[3] = s4; + batch->w[4] = s3; + batch->w[5] = s2; + batch->w[6] = s1; + batch->w[7] = s0; +} + +// aes_nohw_rotate_cols_right returns |v| with the columns in each row rotated +// to the right by |n|. This is a macro because |aes_nohw_shift_*| require +// constant shift counts in the SSE2 implementation. +#define aes_nohw_rotate_cols_right(/* aes_word_t */ v, /* const */ n) \ + (aes_nohw_or(aes_nohw_shift_right((v), (n)*4), \ + aes_nohw_shift_left((v), 16 - (n)*4))) + +static void aes_nohw_shift_rows(AES_NOHW_BATCH *batch) { + for (size_t i = 0; i < 8; i++) { + aes_word_t row0 = aes_nohw_and(batch->w[i], AES_NOHW_ROW0_MASK); + aes_word_t row1 = aes_nohw_and(batch->w[i], AES_NOHW_ROW1_MASK); + aes_word_t row2 = aes_nohw_and(batch->w[i], AES_NOHW_ROW2_MASK); + aes_word_t row3 = aes_nohw_and(batch->w[i], AES_NOHW_ROW3_MASK); + row1 = aes_nohw_rotate_cols_right(row1, 1); + row2 = aes_nohw_rotate_cols_right(row2, 2); + row3 = aes_nohw_rotate_cols_right(row3, 3); + batch->w[i] = aes_nohw_or(aes_nohw_or(row0, row1), aes_nohw_or(row2, row3)); + } +} + +// aes_nohw_rotate_rows_down returns |v| with the rows in each column rotated +// down by one. +static inline aes_word_t aes_nohw_rotate_rows_down(aes_word_t v) { +#if defined(OPENSSL_64_BIT) + return ((v >> 4) & UINT64_C(0x0fff0fff0fff0fff)) | + ((v << 12) & UINT64_C(0xf000f000f000f000)); +#else + return ((v >> 2) & 0x3f3f3f3f) | ((v << 6) & 0xc0c0c0c0); +#endif +} + +// aes_nohw_rotate_rows_twice returns |v| with the rows in each column rotated +// by two. +static inline aes_word_t aes_nohw_rotate_rows_twice(aes_word_t v) { +#if defined(OPENSSL_64_BIT) + return ((v >> 8) & UINT64_C(0x00ff00ff00ff00ff)) | + ((v << 8) & UINT64_C(0xff00ff00ff00ff00)); +#else + return ((v >> 4) & 0x0f0f0f0f) | ((v << 4) & 0xf0f0f0f0); +#endif +} + +static void aes_nohw_mix_columns(AES_NOHW_BATCH *batch) { + // See https://eprint.iacr.org/2009/129.pdf, section 4.4 and appendix A. + aes_word_t a0 = batch->w[0]; + aes_word_t a1 = batch->w[1]; + aes_word_t a2 = batch->w[2]; + aes_word_t a3 = batch->w[3]; + aes_word_t a4 = batch->w[4]; + aes_word_t a5 = batch->w[5]; + aes_word_t a6 = batch->w[6]; + aes_word_t a7 = batch->w[7]; + + aes_word_t r0 = aes_nohw_rotate_rows_down(a0); + aes_word_t a0_r0 = aes_nohw_xor(a0, r0); + aes_word_t r1 = aes_nohw_rotate_rows_down(a1); + aes_word_t a1_r1 = aes_nohw_xor(a1, r1); + aes_word_t r2 = aes_nohw_rotate_rows_down(a2); + aes_word_t a2_r2 = aes_nohw_xor(a2, r2); + aes_word_t r3 = aes_nohw_rotate_rows_down(a3); + aes_word_t a3_r3 = aes_nohw_xor(a3, r3); + aes_word_t r4 = aes_nohw_rotate_rows_down(a4); + aes_word_t a4_r4 = aes_nohw_xor(a4, r4); + aes_word_t r5 = aes_nohw_rotate_rows_down(a5); + aes_word_t a5_r5 = aes_nohw_xor(a5, r5); + aes_word_t r6 = aes_nohw_rotate_rows_down(a6); + aes_word_t a6_r6 = aes_nohw_xor(a6, r6); + aes_word_t r7 = aes_nohw_rotate_rows_down(a7); + aes_word_t a7_r7 = aes_nohw_xor(a7, r7); + + batch->w[0] = + aes_nohw_xor(aes_nohw_xor(a7_r7, r0), aes_nohw_rotate_rows_twice(a0_r0)); + batch->w[1] = + aes_nohw_xor(aes_nohw_xor(a0_r0, a7_r7), + aes_nohw_xor(r1, aes_nohw_rotate_rows_twice(a1_r1))); + batch->w[2] = + aes_nohw_xor(aes_nohw_xor(a1_r1, r2), aes_nohw_rotate_rows_twice(a2_r2)); + batch->w[3] = + aes_nohw_xor(aes_nohw_xor(a2_r2, a7_r7), + aes_nohw_xor(r3, aes_nohw_rotate_rows_twice(a3_r3))); + batch->w[4] = + aes_nohw_xor(aes_nohw_xor(a3_r3, a7_r7), + aes_nohw_xor(r4, aes_nohw_rotate_rows_twice(a4_r4))); + batch->w[5] = + aes_nohw_xor(aes_nohw_xor(a4_r4, r5), aes_nohw_rotate_rows_twice(a5_r5)); + batch->w[6] = + aes_nohw_xor(aes_nohw_xor(a5_r5, r6), aes_nohw_rotate_rows_twice(a6_r6)); + batch->w[7] = + aes_nohw_xor(aes_nohw_xor(a6_r6, r7), aes_nohw_rotate_rows_twice(a7_r7)); +} + +static void aes_nohw_encrypt_batch(const AES_NOHW_SCHEDULE *key, + size_t num_rounds, AES_NOHW_BATCH *batch) { + aes_nohw_add_round_key(batch, &key->keys[0]); + for (size_t i = 1; i < num_rounds; i++) { + aes_nohw_sub_bytes(batch); + aes_nohw_shift_rows(batch); + aes_nohw_mix_columns(batch); + aes_nohw_add_round_key(batch, &key->keys[i]); + } + aes_nohw_sub_bytes(batch); + aes_nohw_shift_rows(batch); + aes_nohw_add_round_key(batch, &key->keys[num_rounds]); +} + +// Key schedule. + +static void aes_nohw_expand_round_keys(AES_NOHW_SCHEDULE *out, + const AES_KEY *key) { + for (size_t i = 0; i <= key->rounds; i++) { + // Copy the round key into each block in the batch. + for (size_t j = 0; j < AES_NOHW_BATCH_SIZE; j++) { + aes_word_t tmp[AES_NOHW_BLOCK_WORDS]; + OPENSSL_memcpy(tmp, key->rd_key + 4 * i, 16); + aes_nohw_batch_set(&out->keys[i], tmp, j); + } + aes_nohw_transpose(&out->keys[i]); + } +} + +static const uint8_t aes_nohw_rcon[10] = {0x01, 0x02, 0x04, 0x08, 0x10, + 0x20, 0x40, 0x80, 0x1b, 0x36}; + +// aes_nohw_rcon_slice returns the |i|th group of |AES_NOHW_BATCH_SIZE| bits in +// |rcon|, stored in a |aes_word_t|. +static inline aes_word_t aes_nohw_rcon_slice(uint8_t rcon, size_t i) { + rcon = (rcon >> (i * AES_NOHW_BATCH_SIZE)) & ((1 << AES_NOHW_BATCH_SIZE) - 1); + return ((aes_word_t)rcon); +} + +static void aes_nohw_sub_block(aes_word_t out[AES_NOHW_BLOCK_WORDS], + const aes_word_t in[AES_NOHW_BLOCK_WORDS]) { + AES_NOHW_BATCH batch; + OPENSSL_memset(&batch, 0, sizeof(batch)); + aes_nohw_batch_set(&batch, in, 0); + aes_nohw_transpose(&batch); + aes_nohw_sub_bytes(&batch); + aes_nohw_transpose(&batch); + aes_nohw_batch_get(&batch, out, 0); +} + +static void aes_nohw_setup_key_128(AES_KEY *key, const uint8_t in[16]) { + key->rounds = 10; + + aes_word_t block[AES_NOHW_BLOCK_WORDS]; + aes_nohw_compact_block(block, in); + OPENSSL_memcpy(key->rd_key, block, 16); + + for (size_t i = 1; i <= 10; i++) { + aes_word_t sub[AES_NOHW_BLOCK_WORDS]; + aes_nohw_sub_block(sub, block); + uint8_t rcon = aes_nohw_rcon[i - 1]; + for (size_t j = 0; j < AES_NOHW_BLOCK_WORDS; j++) { + // Incorporate |rcon| and the transformed word into the first word. + block[j] = aes_nohw_xor(block[j], aes_nohw_rcon_slice(rcon, j)); + block[j] = aes_nohw_xor( + block[j], + aes_nohw_shift_right(aes_nohw_rotate_rows_down(sub[j]), 12)); + // Propagate to the remaining words. Note this is reordered from the usual + // formulation to avoid needing masks. + aes_word_t v = block[j]; + block[j] = aes_nohw_xor(block[j], aes_nohw_shift_left(v, 4)); + block[j] = aes_nohw_xor(block[j], aes_nohw_shift_left(v, 8)); + block[j] = aes_nohw_xor(block[j], aes_nohw_shift_left(v, 12)); + } + OPENSSL_memcpy(key->rd_key + 4 * i, block, 16); + } +} + +static void aes_nohw_setup_key_256(AES_KEY *key, const uint8_t in[32]) { + key->rounds = 14; + + // Each key schedule iteration produces two round keys. + aes_word_t block1[AES_NOHW_BLOCK_WORDS], block2[AES_NOHW_BLOCK_WORDS]; + aes_nohw_compact_block(block1, in); + OPENSSL_memcpy(key->rd_key, block1, 16); + + aes_nohw_compact_block(block2, in + 16); + OPENSSL_memcpy(key->rd_key + 4, block2, 16); + + for (size_t i = 2; i <= 14; i += 2) { + aes_word_t sub[AES_NOHW_BLOCK_WORDS]; + aes_nohw_sub_block(sub, block2); + uint8_t rcon = aes_nohw_rcon[i / 2 - 1]; + for (size_t j = 0; j < AES_NOHW_BLOCK_WORDS; j++) { + // Incorporate |rcon| and the transformed word into the first word. + block1[j] = aes_nohw_xor(block1[j], aes_nohw_rcon_slice(rcon, j)); + block1[j] = aes_nohw_xor( + block1[j], + aes_nohw_shift_right(aes_nohw_rotate_rows_down(sub[j]), 12)); + // Propagate to the remaining words. + aes_word_t v = block1[j]; + block1[j] = aes_nohw_xor(block1[j], aes_nohw_shift_left(v, 4)); + block1[j] = aes_nohw_xor(block1[j], aes_nohw_shift_left(v, 8)); + block1[j] = aes_nohw_xor(block1[j], aes_nohw_shift_left(v, 12)); + } + OPENSSL_memcpy(key->rd_key + 4 * i, block1, 16); + + if (i == 14) { + break; + } + + aes_nohw_sub_block(sub, block1); + for (size_t j = 0; j < AES_NOHW_BLOCK_WORDS; j++) { + // Incorporate the transformed word into the first word. + block2[j] = aes_nohw_xor(block2[j], aes_nohw_shift_right(sub[j], 12)); + // Propagate to the remaining words. + aes_word_t v = block2[j]; + block2[j] = aes_nohw_xor(block2[j], aes_nohw_shift_left(v, 4)); + block2[j] = aes_nohw_xor(block2[j], aes_nohw_shift_left(v, 8)); + block2[j] = aes_nohw_xor(block2[j], aes_nohw_shift_left(v, 12)); + } + OPENSSL_memcpy(key->rd_key + 4 * (i + 1), block2, 16); + } +} + + +// External API. + +int aes_nohw_set_encrypt_key(const uint8_t *key, unsigned bits, + AES_KEY *aeskey) { + switch (bits) { + case 128: + aes_nohw_setup_key_128(aeskey, key); + return 0; + case 256: + aes_nohw_setup_key_256(aeskey, key); + return 0; + } + return 1; +} + +void aes_nohw_encrypt(const uint8_t *in, uint8_t *out, const AES_KEY *key) { + AES_NOHW_SCHEDULE sched; + aes_nohw_expand_round_keys(&sched, key); + AES_NOHW_BATCH batch; + aes_nohw_to_batch(&batch, in, /*num_blocks=*/1); + aes_nohw_encrypt_batch(&sched, key->rounds, &batch); + aes_nohw_from_batch(out, /*num_blocks=*/1, &batch); +} + +static inline void aes_nohw_xor_block(uint8_t out[16], const uint8_t a[16], + const uint8_t b[16]) { + for (size_t i = 0; i < 16; i += sizeof(aes_word_t)) { + aes_word_t x, y; + OPENSSL_memcpy(&x, a + i, sizeof(aes_word_t)); + OPENSSL_memcpy(&y, b + i, sizeof(aes_word_t)); + x = aes_nohw_xor(x, y); + OPENSSL_memcpy(out + i, &x, sizeof(aes_word_t)); + } +} + +void aes_nohw_ctr32_encrypt_blocks(const uint8_t *in, uint8_t *out, + size_t blocks, const AES_KEY *key, + const uint8_t ivec[16]) { + if (blocks == 0) { + return; + } + + AES_NOHW_SCHEDULE sched; + aes_nohw_expand_round_keys(&sched, key); + + // Make |AES_NOHW_BATCH_SIZE| copies of |ivec|. + alignas(AES_NOHW_WORD_SIZE) uint8_t ivs[AES_NOHW_BATCH_SIZE * 16]; + alignas(AES_NOHW_WORD_SIZE) uint8_t enc_ivs[AES_NOHW_BATCH_SIZE * 16]; + for (size_t i = 0; i < AES_NOHW_BATCH_SIZE; i++) { + OPENSSL_memcpy(ivs + 16 * i, ivec, 16); + } + + uint32_t ctr = CRYPTO_load_u32_be(ivs + 12); + for (;;) { + // Update counters. + for (size_t i = 0; i < AES_NOHW_BATCH_SIZE; i++) { + CRYPTO_store_u32_be(ivs + 16 * i + 12, ctr + (uint32_t)i); + } + + size_t todo = blocks >= AES_NOHW_BATCH_SIZE ? AES_NOHW_BATCH_SIZE : blocks; + AES_NOHW_BATCH batch; + aes_nohw_to_batch(&batch, ivs, todo); + aes_nohw_encrypt_batch(&sched, key->rounds, &batch); + aes_nohw_from_batch(enc_ivs, todo, &batch); + + for (size_t i = 0; i < todo; i++) { + aes_nohw_xor_block(out + 16 * i, in + 16 * i, enc_ivs + 16 * i); + } + + blocks -= todo; + if (blocks == 0) { + break; + } + + in += 16 * AES_NOHW_BATCH_SIZE; + out += 16 * AES_NOHW_BATCH_SIZE; + ctr += AES_NOHW_BATCH_SIZE; + } +} diff --git a/http/vendor/ring/crypto/fipsmodule/aes/asm/aes-gcm-avx2-x86_64.pl b/http/vendor/ring/crypto/fipsmodule/aes/asm/aes-gcm-avx2-x86_64.pl new file mode 100644 index 0000000..f4c546a --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/aes/asm/aes-gcm-avx2-x86_64.pl @@ -0,0 +1,1038 @@ +#!/usr/bin/env perl +# Copyright 2024 The BoringSSL Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +#------------------------------------------------------------------------------ +# +# VAES and VPCLMULQDQ optimized AES-GCM for x86_64 (AVX2 version) +# +# This is similar to aes-gcm-avx10-x86_64.pl, but it uses AVX2 instead of AVX512 +# / AVX10. This means it can only use 16 vector registers instead of 32, the +# maximum vector length is 32 bytes, and some instructions such as vpternlogd +# and masked loads/stores are unavailable. However, it is able to run on CPUs +# that have VAES without AVX512 / AVX10, namely AMD Zen 3 (including "Milan" +# server processors) and some Intel client CPUs such as Alder Lake. +# +# This implementation also uses Karatsuba multiplication instead of schoolbook +# multiplication for GHASH in its main loop. This does not help much on Intel, +# but it improves performance by ~5% on AMD Zen 3 which is the main target for +# this implementation. Other factors weighing slightly in favor of Karatsuba +# multiplication in this implementation are the lower maximum vector length +# (which means there is space left in the Htable array to cache the halves of +# the key powers XOR'd together) and the unavailability of the vpternlogd +# instruction (which helped schoolbook a bit more than Karatsuba). + +use strict; + +my $flavour = shift; +my $output = shift; +if ( $flavour =~ /\./ ) { $output = $flavour; undef $flavour; } + +my $win64; +my @argregs; +if ( $flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/ ) { + $win64 = 1; + @argregs = ( "%rcx", "%rdx", "%r8", "%r9" ); +} +else { + $win64 = 0; + @argregs = ( "%rdi", "%rsi", "%rdx", "%rcx", "%r8", "%r9" ); +} + +$0 =~ m/(.*[\/\\])[^\/\\]+$/; +my $dir = $1; +my $xlate; +( $xlate = "${dir}x86_64-xlate.pl" and -f $xlate ) + or ( $xlate = "${dir}../../../perlasm/x86_64-xlate.pl" and -f $xlate ) + or die "can't locate x86_64-xlate.pl"; + +open OUT, "| \"$^X\" \"$xlate\" $flavour \"$output\""; +*STDOUT = *OUT; + +my $g_cur_func_name; +my $g_cur_func_uses_seh; +my @g_cur_func_saved_gpregs; +my @g_cur_func_saved_xmmregs; + +sub _begin_func { + my ( $funcname, $uses_seh ) = @_; + $g_cur_func_name = $funcname; + $g_cur_func_uses_seh = $uses_seh; + @g_cur_func_saved_gpregs = (); + @g_cur_func_saved_xmmregs = (); + return <<___; +.globl $funcname +.type $funcname,\@abi-omnipotent +.align 32 +$funcname: + .cfi_startproc + @{[ $uses_seh ? ".seh_startproc" : "" ]} + _CET_ENDBR +___ +} + +# Push a list of general purpose registers onto the stack. +sub _save_gpregs { + my @gpregs = @_; + my $code = ""; + die "_save_gpregs requires uses_seh" unless $g_cur_func_uses_seh; + die "_save_gpregs can only be called once per function" + if @g_cur_func_saved_gpregs; + die "Order must be _save_gpregs, then _save_xmmregs" + if @g_cur_func_saved_xmmregs; + @g_cur_func_saved_gpregs = @gpregs; + for my $reg (@gpregs) { + $code .= "push $reg\n"; + if ($win64) { + $code .= ".seh_pushreg $reg\n"; + } + else { + $code .= ".cfi_push $reg\n"; + } + } + return $code; +} + +# Push a list of xmm registers onto the stack if the target is Windows. +sub _save_xmmregs { + my @xmmregs = @_; + my $num_xmmregs = scalar @xmmregs; + my $code = ""; + die "_save_xmmregs requires uses_seh" unless $g_cur_func_uses_seh; + die "_save_xmmregs can only be called once per function" + if @g_cur_func_saved_xmmregs; + if ( $win64 and $num_xmmregs > 0 ) { + @g_cur_func_saved_xmmregs = @xmmregs; + my $is_misaligned = ( scalar @g_cur_func_saved_gpregs ) % 2 == 0; + my $alloc_size = 16 * $num_xmmregs + ( $is_misaligned ? 8 : 0 ); + $code .= "sub \$$alloc_size, %rsp\n"; + $code .= ".seh_stackalloc $alloc_size\n"; + for my $i ( 0 .. $num_xmmregs - 1 ) { + my $reg_num = $xmmregs[$i]; + my $pos = 16 * $i; + $code .= "movdqa %xmm$reg_num, $pos(%rsp)\n"; + $code .= ".seh_savexmm %xmm$reg_num, $pos\n"; + } + } + return $code; +} + +sub _end_func { + my $code = ""; + + # Restore any xmm registers that were saved earlier. + my $num_xmmregs = scalar @g_cur_func_saved_xmmregs; + if ( $win64 and $num_xmmregs > 0 ) { + my $need_alignment = ( scalar @g_cur_func_saved_gpregs ) % 2 == 0; + my $alloc_size = 16 * $num_xmmregs + ( $need_alignment ? 8 : 0 ); + for my $i ( 0 .. $num_xmmregs - 1 ) { + my $reg_num = $g_cur_func_saved_xmmregs[$i]; + my $pos = 16 * $i; + $code .= "movdqa $pos(%rsp), %xmm$reg_num\n"; + } + $code .= "add \$$alloc_size, %rsp\n"; + } + + # Restore any general purpose registers that were saved earlier. + for my $reg ( reverse @g_cur_func_saved_gpregs ) { + $code .= "pop $reg\n"; + if ( !$win64 ) { + $code .= ".cfi_pop $reg\n"; + } + } + + $code .= <<___; + ret + @{[ $g_cur_func_uses_seh ? ".seh_endproc" : "" ]} + .cfi_endproc + .size $g_cur_func_name, . - $g_cur_func_name +___ + return $code; +} + +my $code = <<___; +.section .rodata +.align 16 + + # A shuffle mask that reflects the bytes of 16-byte blocks +.Lbswap_mask: + .quad 0x08090a0b0c0d0e0f, 0x0001020304050607 + + # This is the GHASH reducing polynomial without its constant term, i.e. + # x^128 + x^7 + x^2 + x, represented using the backwards mapping + # between bits and polynomial coefficients. + # + # Alternatively, it can be interpreted as the naturally-ordered + # representation of the polynomial x^127 + x^126 + x^121 + 1, i.e. the + # "reversed" GHASH reducing polynomial without its x^128 term. +.Lgfpoly: + .quad 1, 0xc200000000000000 + + # Same as above, but with the (1 << 64) bit set. +.Lgfpoly_and_internal_carrybit: + .quad 1, 0xc200000000000001 + +.align 32 + # The below constants are used for incrementing the counter blocks. +.Lctr_pattern: + .quad 0, 0 + .quad 1, 0 +.Linc_2blocks: + .quad 2, 0 + .quad 2, 0 + +.text +___ + +# We use Htable[0..7] to store H^8 through H^1, and Htable[8..11] to store the +# 64-bit halves of the key powers XOR'd together (for Karatsuba multiplication) +# in the order 8,6,7,5,4,2,3,1. We do not use Htable[12..15]. +my $NUM_H_POWERS = 8; +my $OFFSETOFEND_H_POWERS = $NUM_H_POWERS * 16; +my $OFFSETOF_H_POWERS_XORED = $OFFSETOFEND_H_POWERS; + +# Offset to 'rounds' in AES_KEY struct +my $OFFSETOF_AES_ROUNDS = 240; + +# GHASH-multiply the 128-bit lanes of \a by the 128-bit lanes of \b and store +# the reduced products in \dst. Uses schoolbook multiplication. +sub _ghash_mul { + my ( $a, $b, $dst, $gfpoly, $t0, $t1, $t2 ) = @_; + return <<___; + vpclmulqdq \$0x00, $a, $b, $t0 # LO = a_L * b_L + vpclmulqdq \$0x01, $a, $b, $t1 # MI_0 = a_L * b_H + vpclmulqdq \$0x10, $a, $b, $t2 # MI_1 = a_H * b_L + vpxor $t2, $t1, $t1 # MI = MI_0 + MI_1 + vpclmulqdq \$0x01, $t0, $gfpoly, $t2 # LO_L*(x^63 + x^62 + x^57) + vpshufd \$0x4e, $t0, $t0 # Swap halves of LO + vpxor $t0, $t1, $t1 # Fold LO into MI (part 1) + vpxor $t2, $t1, $t1 # Fold LO into MI (part 2) + vpclmulqdq \$0x11, $a, $b, $dst # HI = a_H * b_H + vpclmulqdq \$0x01, $t1, $gfpoly, $t0 # MI_L*(x^63 + x^62 + x^57) + vpshufd \$0x4e, $t1, $t1 # Swap halves of MI + vpxor $t1, $dst, $dst # Fold MI into HI (part 1) + vpxor $t0, $dst, $dst # Fold MI into HI (part 2) +___ +} + +# void gcm_init_vpclmulqdq_avx2(u128 Htable[16], const uint64_t H[2]); +# +# Initialize |Htable| with powers of the GHASH subkey |H|. +# +# We use Htable[0..7] to store H^8 through H^1, and Htable[8..11] to store the +# 64-bit halves of the key powers XOR'd together (for Karatsuba multiplication) +# in the order 8,6,7,5,4,2,3,1. We do not use Htable[12..15]. +$code .= _begin_func "gcm_init_vpclmulqdq_avx2", 1; +{ + my ( $HTABLE, $H_PTR ) = @argregs[ 0 .. 1 ]; + my ( $TMP0, $TMP0_XMM ) = ( "%ymm0", "%xmm0" ); + my ( $TMP1, $TMP1_XMM ) = ( "%ymm1", "%xmm1" ); + my ( $TMP2, $TMP2_XMM ) = ( "%ymm2", "%xmm2" ); + my ( $H_CUR, $H_CUR_XMM ) = ( "%ymm3", "%xmm3" ); + my ( $H_CUR2, $H_CUR2_XMM ) = ( "%ymm4", "%xmm4" ); + my ( $H_INC, $H_INC_XMM ) = ( "%ymm5", "%xmm5" ); + my ( $GFPOLY, $GFPOLY_XMM ) = ( "%ymm6", "%xmm6" ); + + $code .= <<___; + @{[ _save_xmmregs (6) ]} + .seh_endprologue + + # Load the byte-reflected hash subkey. BoringSSL provides it in + # byte-reflected form except the two halves are in the wrong order. + vpshufd \$0x4e, ($H_PTR), $H_CUR_XMM + + # Finish preprocessing the byte-reflected hash subkey by multiplying it by + # x^-1 ("standard" interpretation of polynomial coefficients) or + # equivalently x^1 (natural interpretation). This gets the key into a + # format that avoids having to bit-reflect the data blocks later. + vpshufd \$0xd3, $H_CUR_XMM, $TMP0_XMM + vpsrad \$31, $TMP0_XMM, $TMP0_XMM + vpaddq $H_CUR_XMM, $H_CUR_XMM, $H_CUR_XMM + vpand .Lgfpoly_and_internal_carrybit(%rip), $TMP0_XMM, $TMP0_XMM + vpxor $TMP0_XMM, $H_CUR_XMM, $H_CUR_XMM + + vbroadcasti128 .Lgfpoly(%rip), $GFPOLY + + # Square H^1 to get H^2. + @{[ _ghash_mul $H_CUR_XMM, $H_CUR_XMM, $H_INC_XMM, $GFPOLY_XMM, + $TMP0_XMM, $TMP1_XMM, $TMP2_XMM ]} + + # Create H_CUR = [H^2, H^1] and H_INC = [H^2, H^2]. + vinserti128 \$1, $H_CUR_XMM, $H_INC, $H_CUR + vinserti128 \$1, $H_INC_XMM, $H_INC, $H_INC + + # Compute H_CUR2 = [H^4, H^3]. + @{[ _ghash_mul $H_INC, $H_CUR, $H_CUR2, $GFPOLY, $TMP0, $TMP1, $TMP2 ]} + + # Store [H^2, H^1] and [H^4, H^3]. + vmovdqu $H_CUR, 3*32($HTABLE) + vmovdqu $H_CUR2, 2*32($HTABLE) + + # For Karatsuba multiplication: compute and store the two 64-bit halves of + # each key power XOR'd together. Order is 4,2,3,1. + vpunpcklqdq $H_CUR, $H_CUR2, $TMP0 + vpunpckhqdq $H_CUR, $H_CUR2, $TMP1 + vpxor $TMP1, $TMP0, $TMP0 + vmovdqu $TMP0, $OFFSETOF_H_POWERS_XORED+32($HTABLE) + + # Compute and store H_CUR = [H^6, H^5] and H_CUR2 = [H^8, H^7]. + @{[ _ghash_mul $H_INC, $H_CUR2, $H_CUR, $GFPOLY, $TMP0, $TMP1, $TMP2 ]} + @{[ _ghash_mul $H_INC, $H_CUR, $H_CUR2, $GFPOLY, $TMP0, $TMP1, $TMP2 ]} + vmovdqu $H_CUR, 1*32($HTABLE) + vmovdqu $H_CUR2, 0*32($HTABLE) + + # Again, compute and store the two 64-bit halves of each key power XOR'd + # together. Order is 8,6,7,5. + vpunpcklqdq $H_CUR, $H_CUR2, $TMP0 + vpunpckhqdq $H_CUR, $H_CUR2, $TMP1 + vpxor $TMP1, $TMP0, $TMP0 + vmovdqu $TMP0, $OFFSETOF_H_POWERS_XORED($HTABLE) + + vzeroupper +___ +} +$code .= _end_func; + +# Do one step of the GHASH update of four vectors of data blocks. +# $i: the step to do, 0 through 9 +# $ghashdata_ptr: pointer to the data blocks (ciphertext or AAD) +# $htable: pointer to the Htable for the key +# $bswap_mask: mask for reflecting the bytes of blocks +# $h_pow[2-1]_xored: XOR'd key powers cached from Htable +# $tmp[0-2]: temporary registers. $tmp[1-2] must be preserved across steps. +# $lo, $mi: working state for this macro that must be preserved across steps +# $ghash_acc: the GHASH accumulator (input/output) +sub _ghash_step_4x { + my ( + $i, $ghashdata_ptr, $htable, $bswap_mask, + $h_pow2_xored, $h_pow1_xored, $tmp0, $tmp0_xmm, + $tmp1, $tmp2, $lo, $mi, + $ghash_acc, $ghash_acc_xmm + ) = @_; + my ( $hi, $hi_xmm ) = ( $ghash_acc, $ghash_acc_xmm ); # alias + if ( $i == 0 ) { + return <<___; + # First vector + vmovdqu 0*32($ghashdata_ptr), $tmp1 + vpshufb $bswap_mask, $tmp1, $tmp1 + vmovdqu 0*32($htable), $tmp2 + vpxor $ghash_acc, $tmp1, $tmp1 + vpclmulqdq \$0x00, $tmp2, $tmp1, $lo + vpclmulqdq \$0x11, $tmp2, $tmp1, $hi + vpunpckhqdq $tmp1, $tmp1, $tmp0 + vpxor $tmp1, $tmp0, $tmp0 + vpclmulqdq \$0x00, $h_pow2_xored, $tmp0, $mi +___ + } + elsif ( $i == 1 ) { + return <<___; +___ + } + elsif ( $i == 2 ) { + return <<___; + # Second vector + vmovdqu 1*32($ghashdata_ptr), $tmp1 + vpshufb $bswap_mask, $tmp1, $tmp1 + vmovdqu 1*32($htable), $tmp2 + vpclmulqdq \$0x00, $tmp2, $tmp1, $tmp0 + vpxor $tmp0, $lo, $lo + vpclmulqdq \$0x11, $tmp2, $tmp1, $tmp0 + vpxor $tmp0, $hi, $hi + vpunpckhqdq $tmp1, $tmp1, $tmp0 + vpxor $tmp1, $tmp0, $tmp0 + vpclmulqdq \$0x10, $h_pow2_xored, $tmp0, $tmp0 + vpxor $tmp0, $mi, $mi +___ + } + elsif ( $i == 3 ) { + return <<___; + # Third vector + vmovdqu 2*32($ghashdata_ptr), $tmp1 + vpshufb $bswap_mask, $tmp1, $tmp1 + vmovdqu 2*32($htable), $tmp2 +___ + } + elsif ( $i == 4 ) { + return <<___; + vpclmulqdq \$0x00, $tmp2, $tmp1, $tmp0 + vpxor $tmp0, $lo, $lo + vpclmulqdq \$0x11, $tmp2, $tmp1, $tmp0 + vpxor $tmp0, $hi, $hi +___ + } + elsif ( $i == 5 ) { + return <<___; + vpunpckhqdq $tmp1, $tmp1, $tmp0 + vpxor $tmp1, $tmp0, $tmp0 + vpclmulqdq \$0x00, $h_pow1_xored, $tmp0, $tmp0 + vpxor $tmp0, $mi, $mi + + # Fourth vector + vmovdqu 3*32($ghashdata_ptr), $tmp1 + vpshufb $bswap_mask, $tmp1, $tmp1 +___ + } + elsif ( $i == 6 ) { + return <<___; + vmovdqu 3*32($htable), $tmp2 + vpclmulqdq \$0x00, $tmp2, $tmp1, $tmp0 + vpxor $tmp0, $lo, $lo + vpclmulqdq \$0x11, $tmp2, $tmp1, $tmp0 + vpxor $tmp0, $hi, $hi + vpunpckhqdq $tmp1, $tmp1, $tmp0 + vpxor $tmp1, $tmp0, $tmp0 + vpclmulqdq \$0x10, $h_pow1_xored, $tmp0, $tmp0 + vpxor $tmp0, $mi, $mi +___ + } + elsif ( $i == 7 ) { + return <<___; + # Finalize 'mi' following Karatsuba multiplication. + vpxor $lo, $mi, $mi + vpxor $hi, $mi, $mi + + # Fold lo into mi. + vbroadcasti128 .Lgfpoly(%rip), $tmp2 + vpclmulqdq \$0x01, $lo, $tmp2, $tmp0 + vpshufd \$0x4e, $lo, $lo + vpxor $lo, $mi, $mi + vpxor $tmp0, $mi, $mi +___ + } + elsif ( $i == 8 ) { + return <<___; + # Fold mi into hi. + vpclmulqdq \$0x01, $mi, $tmp2, $tmp0 + vpshufd \$0x4e, $mi, $mi + vpxor $mi, $hi, $hi + vpxor $tmp0, $hi, $hi +___ + } + elsif ( $i == 9 ) { + return <<___; + vextracti128 \$1, $hi, $tmp0_xmm + vpxor $tmp0_xmm, $hi_xmm, $ghash_acc_xmm +___ + } +} + +sub _ghash_4x { + my $code = ""; + for my $i ( 0 .. 9 ) { + $code .= _ghash_step_4x $i, @_; + } + return $code; +} + +# void gcm_ghash_vpclmulqdq_avx2(uint8_t Xi[16], const u128 Htable[16], +# const uint8_t *in, size_t len); +# +# Using the key |Htable|, update the GHASH accumulator |Xi| with the data given +# by |in| and |len|. |len| must be exactly 16. +$code .= _begin_func "gcm_ghash_vpclmulqdq_avx2_1", 1; +{ + # Function arguments + my ( $GHASH_ACC_PTR, $HTABLE, $AAD, $AADLEN ) = @argregs[ 0 .. 3 ]; + + # Additional local variables + my ( $TMP0, $TMP0_XMM ) = ( "%ymm0", "%xmm0" ); + my ( $TMP1, $TMP1_XMM ) = ( "%ymm1", "%xmm1" ); + my ( $TMP2, $TMP2_XMM ) = ( "%ymm2", "%xmm2" ); + my ( $LO, $LO_XMM ) = ( "%ymm3", "%xmm3" ); + my ( $MI, $MI_XMM ) = ( "%ymm4", "%xmm4" ); + my ( $GHASH_ACC, $GHASH_ACC_XMM ) = ( "%ymm5", "%xmm5" ); + my ( $BSWAP_MASK, $BSWAP_MASK_XMM ) = ( "%ymm6", "%xmm6" ); + my ( $GFPOLY, $GFPOLY_XMM ) = ( "%ymm7", "%xmm7" ); + my $H_POW2_XORED = "%ymm8"; + my $H_POW1_XORED = "%ymm9"; + + $code .= <<___; + @{[ _save_xmmregs (6 .. 9) ]} + .seh_endprologue + + # Load the bswap_mask and gfpoly constants. Since AADLEN is usually small, + # usually only 128-bit vectors will be used. So as an optimization, don't + # broadcast these constants to both 128-bit lanes quite yet. + vmovdqu .Lbswap_mask(%rip), $BSWAP_MASK_XMM + vmovdqu .Lgfpoly(%rip), $GFPOLY_XMM + + # Load the GHASH accumulator. + vmovdqu ($GHASH_ACC_PTR), $GHASH_ACC_XMM + vpshufb $BSWAP_MASK_XMM, $GHASH_ACC_XMM, $GHASH_ACC_XMM + + + # Update GHASH with the remaining 16-byte block if any. +.Lghash_lastblock: + vmovdqu ($AAD), $TMP0_XMM + vpshufb $BSWAP_MASK_XMM, $TMP0_XMM, $TMP0_XMM + vpxor $TMP0_XMM, $GHASH_ACC_XMM, $GHASH_ACC_XMM + vmovdqu $OFFSETOFEND_H_POWERS-16($HTABLE), $TMP0_XMM + @{[ _ghash_mul $TMP0_XMM, $GHASH_ACC_XMM, $GHASH_ACC_XMM, $GFPOLY_XMM, + $TMP1_XMM, $TMP2_XMM, $LO_XMM ]} + +.Lghash_done: + # Store the updated GHASH accumulator back to memory. + vpshufb $BSWAP_MASK_XMM, $GHASH_ACC_XMM, $GHASH_ACC_XMM + vmovdqu $GHASH_ACC_XMM, ($GHASH_ACC_PTR) + + vzeroupper +___ +} +$code .= _end_func; + +sub _vaesenc_4x { + my ( $round_key, $aesdata0, $aesdata1, $aesdata2, $aesdata3 ) = @_; + return <<___; + vaesenc $round_key, $aesdata0, $aesdata0 + vaesenc $round_key, $aesdata1, $aesdata1 + vaesenc $round_key, $aesdata2, $aesdata2 + vaesenc $round_key, $aesdata3, $aesdata3 +___ +} + +sub _ctr_begin_4x { + my ( + $le_ctr, $bswap_mask, $rndkey0, $aesdata0, + $aesdata1, $aesdata2, $aesdata3, $tmp + ) = @_; + return <<___; + # Increment le_ctr four times to generate four vectors of little-endian + # counter blocks, swap each to big-endian, and store them in aesdata[0-3]. + vmovdqu .Linc_2blocks(%rip), $tmp + vpshufb $bswap_mask, $le_ctr, $aesdata0 + vpaddd $tmp, $le_ctr, $le_ctr + vpshufb $bswap_mask, $le_ctr, $aesdata1 + vpaddd $tmp, $le_ctr, $le_ctr + vpshufb $bswap_mask, $le_ctr, $aesdata2 + vpaddd $tmp, $le_ctr, $le_ctr + vpshufb $bswap_mask, $le_ctr, $aesdata3 + vpaddd $tmp, $le_ctr, $le_ctr + + # AES "round zero": XOR in the zero-th round key. + vpxor $rndkey0, $aesdata0, $aesdata0 + vpxor $rndkey0, $aesdata1, $aesdata1 + vpxor $rndkey0, $aesdata2, $aesdata2 + vpxor $rndkey0, $aesdata3, $aesdata3 +___ +} + +# Do the last AES round for four vectors of counter blocks, XOR four vectors of +# source data with the resulting keystream blocks, and write the result to the +# destination buffer. The implementation differs slightly as it takes advantage +# of the property vaesenclast(key, a) ^ b == vaesenclast(key ^ b, a) to reduce +# latency, but it has the same effect. +sub _aesenclast_and_xor_4x { + my ( + $src, $dst, $rndkeylast, $aesdata0, + $aesdata1, $aesdata2, $aesdata3, $t0, + $t1, $t2, $t3 + ) = @_; + return <<___; + vpxor 0*32($src), $rndkeylast, $t0 + vpxor 1*32($src), $rndkeylast, $t1 + vpxor 2*32($src), $rndkeylast, $t2 + vpxor 3*32($src), $rndkeylast, $t3 + vaesenclast $t0, $aesdata0, $aesdata0 + vaesenclast $t1, $aesdata1, $aesdata1 + vaesenclast $t2, $aesdata2, $aesdata2 + vaesenclast $t3, $aesdata3, $aesdata3 + vmovdqu $aesdata0, 0*32($dst) + vmovdqu $aesdata1, 1*32($dst) + vmovdqu $aesdata2, 2*32($dst) + vmovdqu $aesdata3, 3*32($dst) +___ +} + +my $g_update_macro_expansion_count = 0; + +# void aes_gcm_{enc,dec}_update_vaes_avx2(const uint8_t *in, uint8_t *out, +# size_t len, const AES_KEY *key, +# const uint8_t ivec[16], +# const u128 Htable[16], +# uint8_t Xi[16]); +# +# This macro generates a GCM encryption or decryption update function with the +# above prototype (with \enc selecting which one). The function computes the +# next portion of the CTR keystream, XOR's it with |len| bytes from |in|, and +# writes the resulting encrypted or decrypted data to |out|. It also updates +# the GHASH accumulator |Xi| using the next |len| ciphertext bytes. +# +# |len| must be a multiple of 16. The caller must do any buffering needed to +# ensure this. Both in-place and out-of-place en/decryption are supported. +# +# |ivec| must give the current counter in big-endian format. This function +# loads the counter from |ivec| and increments the loaded counter as needed, but +# it does *not* store the updated counter back to |ivec|. The caller must +# update |ivec| if any more data segments follow. Internally, only the low +# 32-bit word of the counter is incremented, following the GCM standard. +sub _aes_gcm_update { + my $local_label_suffix = "__func" . ++$g_update_macro_expansion_count; + my ($enc) = @_; + my $code = ""; + + # Function arguments + my ( $SRC, $DST, $DATALEN, $AESKEY, $BE_CTR_PTR, $HTABLE, $GHASH_ACC_PTR ) + = $win64 + ? ( @argregs[ 0 .. 3 ], "%rsi", "%rdi", "%r12" ) + : ( @argregs[ 0 .. 5 ], "%r12" ); + + # Additional local variables. + # %rax is used as a temporary register. BE_CTR_PTR is also available as a + # temporary register after the counter is loaded. + + # AES key length in bytes + my ( $AESKEYLEN, $AESKEYLEN64 ) = ( "%r10d", "%r10" ); + + # Pointer to the last AES round key for the chosen AES variant + my $RNDKEYLAST_PTR = "%r11"; + + # BSWAP_MASK is the shuffle mask for byte-reflecting 128-bit values + # using vpshufb, copied to all 128-bit lanes. + my ( $BSWAP_MASK, $BSWAP_MASK_XMM ) = ( "%ymm0", "%xmm0" ); + + # GHASH_ACC is the accumulator variable for GHASH. When fully reduced, + # only the lowest 128-bit lane can be nonzero. When not fully reduced, + # more than one lane may be used, and they need to be XOR'd together. + my ( $GHASH_ACC, $GHASH_ACC_XMM ) = ( "%ymm1", "%xmm1" ); + + # TMP[0-2] are temporary registers. + my ( $TMP0, $TMP0_XMM ) = ( "%ymm2", "%xmm2" ); + my ( $TMP1, $TMP1_XMM ) = ( "%ymm3", "%xmm3" ); + my ( $TMP2, $TMP2_XMM ) = ( "%ymm4", "%xmm4" ); + + # LO and MI are used to accumulate unreduced GHASH products. + my ( $LO, $LO_XMM ) = ( "%ymm5", "%xmm5" ); + my ( $MI, $MI_XMM ) = ( "%ymm6", "%xmm6" ); + + # Cached key powers from Htable + my ( $H_POW2_XORED, $H_POW2_XORED_XMM ) = ( "%ymm7", "%xmm7" ); + my ( $H_POW1_XORED, $H_POW1_XORED_XMM ) = ( "%ymm8", "%xmm8" ); + + # RNDKEY0 caches the zero-th round key, and RNDKEYLAST the last one. + my $RNDKEY0 = "%ymm9"; + my $RNDKEYLAST = "%ymm10"; + + # LE_CTR contains the next set of little-endian counter blocks. + my $LE_CTR = "%ymm11"; + + # AESDATA[0-3] hold the counter blocks that are being encrypted by AES. + my ( $AESDATA0, $AESDATA0_XMM ) = ( "%ymm12", "%xmm12" ); + my ( $AESDATA1, $AESDATA1_XMM ) = ( "%ymm13", "%xmm13" ); + my ( $AESDATA2, $AESDATA2_XMM ) = ( "%ymm14", "%xmm14" ); + my ( $AESDATA3, $AESDATA3_XMM ) = ( "%ymm15", "%xmm15" ); + my @AESDATA = ( $AESDATA0, $AESDATA1, $AESDATA2, $AESDATA3 ); + + my @ghash_4x_args = ( + $enc ? $DST : $SRC, $HTABLE, $BSWAP_MASK, $H_POW2_XORED, + $H_POW1_XORED, $TMP0, $TMP0_XMM, $TMP1, + $TMP2, $LO, $MI, $GHASH_ACC, + $GHASH_ACC_XMM + ); + + if ($win64) { + $code .= <<___; + @{[ _save_gpregs $BE_CTR_PTR, $HTABLE, $GHASH_ACC_PTR ]} + mov 64(%rsp), $BE_CTR_PTR # arg5 + mov 72(%rsp), $HTABLE # arg6 + mov 80(%rsp), $GHASH_ACC_PTR # arg7 + @{[ _save_xmmregs (6 .. 15) ]} + .seh_endprologue +___ + } + else { + $code .= <<___; + @{[ _save_gpregs $GHASH_ACC_PTR ]} + mov 16(%rsp), $GHASH_ACC_PTR # arg7 +___ + } + + if ($enc) { + $code .= <<___; +#ifdef BORINGSSL_DISPATCH_TEST + .extern BORINGSSL_function_hit + movb \$1,BORINGSSL_function_hit+8(%rip) +#endif +___ + } + $code .= <<___; + vbroadcasti128 .Lbswap_mask(%rip), $BSWAP_MASK + + # Load the GHASH accumulator and the starting counter. + # BoringSSL passes these values in big endian format. + vmovdqu ($GHASH_ACC_PTR), $GHASH_ACC_XMM + vpshufb $BSWAP_MASK_XMM, $GHASH_ACC_XMM, $GHASH_ACC_XMM + vbroadcasti128 ($BE_CTR_PTR), $LE_CTR + vpshufb $BSWAP_MASK, $LE_CTR, $LE_CTR + + # Load the AES key length in bytes. BoringSSL stores number of rounds + # minus 1, so convert using: AESKEYLEN = 4 * aeskey->rounds - 20. + movl $OFFSETOF_AES_ROUNDS($AESKEY), $AESKEYLEN + lea -20(,$AESKEYLEN,4), $AESKEYLEN + + # Make RNDKEYLAST_PTR point to the last AES round key. This is the + # round key with index 10, 12, or 14 for AES-128, AES-192, or AES-256 + # respectively. Then load the zero-th and last round keys. + lea 6*16($AESKEY,$AESKEYLEN64,4), $RNDKEYLAST_PTR + vbroadcasti128 ($AESKEY), $RNDKEY0 + vbroadcasti128 ($RNDKEYLAST_PTR), $RNDKEYLAST + + # Finish initializing LE_CTR by adding 1 to the second block. + vpaddd .Lctr_pattern(%rip), $LE_CTR, $LE_CTR + + # If there are at least 128 bytes of data, then continue into the loop that + # processes 128 bytes of data at a time. Otherwise skip it. + cmp \$127, $DATALEN + jbe .Lcrypt_loop_4x_done$local_label_suffix + + vmovdqu $OFFSETOF_H_POWERS_XORED($HTABLE), $H_POW2_XORED + vmovdqu $OFFSETOF_H_POWERS_XORED+32($HTABLE), $H_POW1_XORED +___ + + # Main loop: en/decrypt and hash 4 vectors (128 bytes) at a time. + + if ($enc) { + $code .= <<___; + # Encrypt the first 4 vectors of plaintext blocks. + @{[ _ctr_begin_4x $LE_CTR, $BSWAP_MASK, $RNDKEY0, @AESDATA, $TMP0 ]} + lea 16($AESKEY), %rax +.Lvaesenc_loop_first_4_vecs$local_label_suffix: + vbroadcasti128 (%rax), $TMP0 + @{[ _vaesenc_4x $TMP0, @AESDATA ]} + add \$16, %rax + cmp %rax, $RNDKEYLAST_PTR + jne .Lvaesenc_loop_first_4_vecs$local_label_suffix + @{[ _aesenclast_and_xor_4x $SRC, $DST, $RNDKEYLAST, @AESDATA, + $TMP0, $TMP1, $LO, $MI ]} + sub \$-128, $SRC # 128 is 4 bytes, -128 is 1 byte + add \$-128, $DATALEN + cmp \$127, $DATALEN + jbe .Lghash_last_ciphertext_4x$local_label_suffix +___ + } + + $code .= <<___; +.align 16 +.Lcrypt_loop_4x$local_label_suffix: + + # Start the AES encryption of the counter blocks. + @{[ _ctr_begin_4x $LE_CTR, $BSWAP_MASK, $RNDKEY0, @AESDATA, $TMP0 ]} + cmp \$24, $AESKEYLEN + jl .Laes128$local_label_suffix + je .Laes192$local_label_suffix + # AES-256 + vbroadcasti128 -13*16($RNDKEYLAST_PTR), $TMP0 + @{[ _vaesenc_4x $TMP0, @AESDATA ]} + vbroadcasti128 -12*16($RNDKEYLAST_PTR), $TMP0 + @{[ _vaesenc_4x $TMP0, @AESDATA ]} +.Laes192$local_label_suffix: + vbroadcasti128 -11*16($RNDKEYLAST_PTR), $TMP0 + @{[ _vaesenc_4x $TMP0, @AESDATA ]} + vbroadcasti128 -10*16($RNDKEYLAST_PTR), $TMP0 + @{[ _vaesenc_4x $TMP0, @AESDATA ]} +.Laes128$local_label_suffix: +___ + + # Prefetch the source data 512 bytes ahead into the L1 data cache, to + # improve performance when the hardware prefetcher is disabled. Assumes the + # L1 data cache line size is 64 bytes (de facto standard on x86_64). + $code .= "prefetcht0 512($SRC)\n"; + $code .= "prefetcht0 512+64($SRC)\n"; + + # Finish the AES encryption of the counter blocks in AESDATA[0-3], + # interleaved with the GHASH update of the ciphertext blocks. + for my $i ( reverse 1 .. 9 ) { + $code .= <<___; + @{[ _ghash_step_4x 9-$i, @ghash_4x_args ]} + vbroadcasti128 -$i*16($RNDKEYLAST_PTR), $TMP0 + @{[ _vaesenc_4x $TMP0, @AESDATA ]} +___ + } + $code .= <<___; + @{[ _ghash_step_4x 9, @ghash_4x_args ]} + + @{[ $enc ? "sub \$-128, $DST" : "" ]} # 128 is 4 bytes, -128 is 1 byte + @{[ _aesenclast_and_xor_4x $SRC, $DST, $RNDKEYLAST, @AESDATA, + $TMP0, $TMP1, $LO, $MI ]} + sub \$-128, $SRC + @{[ !$enc ? "sub \$-128, $DST" : "" ]} + add \$-128, $DATALEN + cmp \$127, $DATALEN + ja .Lcrypt_loop_4x$local_label_suffix +___ + + if ($enc) { + + # Update GHASH with the last set of ciphertext blocks. + $code .= <<___; +.Lghash_last_ciphertext_4x$local_label_suffix: + @{[ _ghash_4x @ghash_4x_args ]} + sub \$-128, $DST +___ + } + + my $POWERS_PTR = $BE_CTR_PTR; # BE_CTR_PTR is free to be reused. + my ( $HI, $HI_XMM ) = ( $H_POW2_XORED, $H_POW2_XORED_XMM ); # reuse + + $code .= <<___; +.Lcrypt_loop_4x_done$local_label_suffix: + # Check whether any data remains. + test $DATALEN, $DATALEN + jz .Ldone$local_label_suffix + + # DATALEN is in [16, 32, 48, 64, 80, 96, 112]. + + # Make POWERS_PTR point to the key powers [H^N, H^(N-1), ...] where N + # is the number of blocks that remain. + lea $OFFSETOFEND_H_POWERS($HTABLE), $POWERS_PTR + sub $DATALEN, $POWERS_PTR + + # Start collecting the unreduced GHASH intermediate value LO, MI, HI. + vpxor $LO_XMM, $LO_XMM, $LO_XMM + vpxor $MI_XMM, $MI_XMM, $MI_XMM + vpxor $HI_XMM, $HI_XMM, $HI_XMM + + cmp \$64, $DATALEN + jb .Llessthan64bytes$local_label_suffix + + # DATALEN is in [64, 80, 96, 112]. Encrypt two vectors of counter blocks. + vpshufb $BSWAP_MASK, $LE_CTR, $AESDATA0 + vpaddd .Linc_2blocks(%rip), $LE_CTR, $LE_CTR + vpshufb $BSWAP_MASK, $LE_CTR, $AESDATA1 + vpaddd .Linc_2blocks(%rip), $LE_CTR, $LE_CTR + vpxor $RNDKEY0, $AESDATA0, $AESDATA0 + vpxor $RNDKEY0, $AESDATA1, $AESDATA1 + lea 16($AESKEY), %rax +.Lvaesenc_loop_tail_1$local_label_suffix: + vbroadcasti128 (%rax), $TMP0 + vaesenc $TMP0, $AESDATA0, $AESDATA0 + vaesenc $TMP0, $AESDATA1, $AESDATA1 + add \$16, %rax + cmp %rax, $RNDKEYLAST_PTR + jne .Lvaesenc_loop_tail_1$local_label_suffix + vaesenclast $RNDKEYLAST, $AESDATA0, $AESDATA0 + vaesenclast $RNDKEYLAST, $AESDATA1, $AESDATA1 + + # XOR the data with the two vectors of keystream blocks. + vmovdqu 0($SRC), $TMP0 + vmovdqu 32($SRC), $TMP1 + vpxor $TMP0, $AESDATA0, $AESDATA0 + vpxor $TMP1, $AESDATA1, $AESDATA1 + vmovdqu $AESDATA0, 0($DST) + vmovdqu $AESDATA1, 32($DST) + + # Update GHASH with two vectors of ciphertext blocks, without reducing. + vpshufb $BSWAP_MASK, @{[ $enc ? $AESDATA0 : $TMP0 ]}, $AESDATA0 + vpshufb $BSWAP_MASK, @{[ $enc ? $AESDATA1 : $TMP1 ]}, $AESDATA1 + vpxor $GHASH_ACC, $AESDATA0, $AESDATA0 + vmovdqu ($POWERS_PTR), $TMP0 + vmovdqu 32($POWERS_PTR), $TMP1 + vpclmulqdq \$0x00, $TMP0, $AESDATA0, $LO + vpclmulqdq \$0x01, $TMP0, $AESDATA0, $MI + vpclmulqdq \$0x10, $TMP0, $AESDATA0, $TMP2 + vpxor $TMP2, $MI, $MI + vpclmulqdq \$0x11, $TMP0, $AESDATA0, $HI + vpclmulqdq \$0x00, $TMP1, $AESDATA1, $TMP2 + vpxor $TMP2, $LO, $LO + vpclmulqdq \$0x01, $TMP1, $AESDATA1, $TMP2 + vpxor $TMP2, $MI, $MI + vpclmulqdq \$0x10, $TMP1, $AESDATA1, $TMP2 + vpxor $TMP2, $MI, $MI + vpclmulqdq \$0x11, $TMP1, $AESDATA1, $TMP2 + vpxor $TMP2, $HI, $HI + + add \$64, $POWERS_PTR + add \$64, $SRC + add \$64, $DST + sub \$64, $DATALEN + jz .Lreduce$local_label_suffix + + vpxor $GHASH_ACC_XMM, $GHASH_ACC_XMM, $GHASH_ACC_XMM + + # DATALEN is in [16, 32, 48]. Encrypt two last vectors of counter blocks. +.Llessthan64bytes$local_label_suffix: + vpshufb $BSWAP_MASK, $LE_CTR, $AESDATA0 + vpaddd .Linc_2blocks(%rip), $LE_CTR, $LE_CTR + vpshufb $BSWAP_MASK, $LE_CTR, $AESDATA1 + vpxor $RNDKEY0, $AESDATA0, $AESDATA0 + vpxor $RNDKEY0, $AESDATA1, $AESDATA1 + lea 16($AESKEY), %rax +.Lvaesenc_loop_tail_2$local_label_suffix: + vbroadcasti128 (%rax), $TMP0 + vaesenc $TMP0, $AESDATA0, $AESDATA0 + vaesenc $TMP0, $AESDATA1, $AESDATA1 + add \$16, %rax + cmp %rax, $RNDKEYLAST_PTR + jne .Lvaesenc_loop_tail_2$local_label_suffix + vaesenclast $RNDKEYLAST, $AESDATA0, $AESDATA0 + vaesenclast $RNDKEYLAST, $AESDATA1, $AESDATA1 + + # XOR the remaining data with the keystream blocks, and update GHASH with + # the remaining ciphertext blocks without reducing. + + cmp \$32, $DATALEN + jb .Lxor_one_block$local_label_suffix + je .Lxor_two_blocks$local_label_suffix + +.Lxor_three_blocks$local_label_suffix: + vmovdqu 0($SRC), $TMP0 + vmovdqu 32($SRC), $TMP1_XMM + vpxor $TMP0, $AESDATA0, $AESDATA0 + vpxor $TMP1_XMM, $AESDATA1_XMM, $AESDATA1_XMM + vmovdqu $AESDATA0, 0($DST) + vmovdqu $AESDATA1_XMM, 32($DST) + + vpshufb $BSWAP_MASK, @{[ $enc ? $AESDATA0 : $TMP0 ]}, $AESDATA0 + vpshufb $BSWAP_MASK_XMM, @{[ $enc ? $AESDATA1_XMM : $TMP1_XMM ]}, $AESDATA1_XMM + vpxor $GHASH_ACC, $AESDATA0, $AESDATA0 + vmovdqu ($POWERS_PTR), $TMP0 + vmovdqu 32($POWERS_PTR), $TMP1_XMM + vpclmulqdq \$0x00, $TMP1_XMM, $AESDATA1_XMM, $TMP2_XMM + vpxor $TMP2, $LO, $LO + vpclmulqdq \$0x01, $TMP1_XMM, $AESDATA1_XMM, $TMP2_XMM + vpxor $TMP2, $MI, $MI + vpclmulqdq \$0x10, $TMP1_XMM, $AESDATA1_XMM, $TMP2_XMM + vpxor $TMP2, $MI, $MI + vpclmulqdq \$0x11, $TMP1_XMM, $AESDATA1_XMM, $TMP2_XMM + vpxor $TMP2, $HI, $HI + jmp .Lghash_mul_one_vec_unreduced$local_label_suffix + +.Lxor_two_blocks$local_label_suffix: + vmovdqu ($SRC), $TMP0 + vpxor $TMP0, $AESDATA0, $AESDATA0 + vmovdqu $AESDATA0, ($DST) + vpshufb $BSWAP_MASK, @{[ $enc ? $AESDATA0 : $TMP0 ]}, $AESDATA0 + vpxor $GHASH_ACC, $AESDATA0, $AESDATA0 + vmovdqu ($POWERS_PTR), $TMP0 + jmp .Lghash_mul_one_vec_unreduced$local_label_suffix + +.Lxor_one_block$local_label_suffix: + vmovdqu ($SRC), $TMP0_XMM + vpxor $TMP0_XMM, $AESDATA0_XMM, $AESDATA0_XMM + vmovdqu $AESDATA0_XMM, ($DST) + vpshufb $BSWAP_MASK_XMM, @{[ $enc ? $AESDATA0_XMM : $TMP0_XMM ]}, $AESDATA0_XMM + vpxor $GHASH_ACC_XMM, $AESDATA0_XMM, $AESDATA0_XMM + vmovdqu ($POWERS_PTR), $TMP0_XMM + +.Lghash_mul_one_vec_unreduced$local_label_suffix: + vpclmulqdq \$0x00, $TMP0, $AESDATA0, $TMP2 + vpxor $TMP2, $LO, $LO + vpclmulqdq \$0x01, $TMP0, $AESDATA0, $TMP2 + vpxor $TMP2, $MI, $MI + vpclmulqdq \$0x10, $TMP0, $AESDATA0, $TMP2 + vpxor $TMP2, $MI, $MI + vpclmulqdq \$0x11, $TMP0, $AESDATA0, $TMP2 + vpxor $TMP2, $HI, $HI + +.Lreduce$local_label_suffix: + # Finally, do the GHASH reduction. + vbroadcasti128 .Lgfpoly(%rip), $TMP0 + vpclmulqdq \$0x01, $LO, $TMP0, $TMP1 + vpshufd \$0x4e, $LO, $LO + vpxor $LO, $MI, $MI + vpxor $TMP1, $MI, $MI + vpclmulqdq \$0x01, $MI, $TMP0, $TMP1 + vpshufd \$0x4e, $MI, $MI + vpxor $MI, $HI, $HI + vpxor $TMP1, $HI, $HI + vextracti128 \$1, $HI, $GHASH_ACC_XMM + vpxor $HI_XMM, $GHASH_ACC_XMM, $GHASH_ACC_XMM + +.Ldone$local_label_suffix: + # Store the updated GHASH accumulator back to memory. + vpshufb $BSWAP_MASK_XMM, $GHASH_ACC_XMM, $GHASH_ACC_XMM + vmovdqu $GHASH_ACC_XMM, ($GHASH_ACC_PTR) + + vzeroupper +___ + return $code; +} + +$code .= _begin_func "aes_gcm_enc_update_vaes_avx2", 1; +$code .= _aes_gcm_update 1; +$code .= _end_func; + +$code .= _begin_func "aes_gcm_dec_update_vaes_avx2", 1; +$code .= _aes_gcm_update 0; +$code .= _end_func; + +sub filter_and_print { + # This function replaces AVX2 assembly instructions with their assembled forms, + # to allow the code to work on old versions of binutils (older than 2.30) that do + # not support these instructions. + my %asmMap = ( + 'vaesenc %ymm2, %ymm12, %ymm12' => '.byte 0xc4,0x62,0x1d,0xdc,0xe2', + 'vaesenc %ymm2, %ymm13, %ymm13' => '.byte 0xc4,0x62,0x15,0xdc,0xea', + 'vaesenc %ymm2, %ymm14, %ymm14' => '.byte 0xc4,0x62,0x0d,0xdc,0xf2', + 'vaesenc %ymm2, %ymm15, %ymm15' => '.byte 0xc4,0x62,0x05,0xdc,0xfa', + 'vaesenclast %ymm10, %ymm12, %ymm12' => '.byte 0xc4,0x42,0x1d,0xdd,0xe2', + 'vaesenclast %ymm10, %ymm13, %ymm13' => '.byte 0xc4,0x42,0x15,0xdd,0xea', + 'vaesenclast %ymm2, %ymm12, %ymm12' => '.byte 0xc4,0x62,0x1d,0xdd,0xe2', + 'vaesenclast %ymm3, %ymm13, %ymm13' => '.byte 0xc4,0x62,0x15,0xdd,0xeb', + 'vaesenclast %ymm5, %ymm14, %ymm14' => '.byte 0xc4,0x62,0x0d,0xdd,0xf5', + 'vaesenclast %ymm6, %ymm15, %ymm15' => '.byte 0xc4,0x62,0x05,0xdd,0xfe', + 'vpclmulqdq $0x00, %ymm2, %ymm12, %ymm4' => '.byte 0xc4,0xe3,0x1d,0x44,0xe2,0x00', + 'vpclmulqdq $0x00, %ymm2, %ymm12, %ymm5' => '.byte 0xc4,0xe3,0x1d,0x44,0xea,0x00', + 'vpclmulqdq $0x00, %ymm3, %ymm13, %ymm4' => '.byte 0xc4,0xe3,0x15,0x44,0xe3,0x00', + 'vpclmulqdq $0x00, %ymm4, %ymm3, %ymm2' => '.byte 0xc4,0xe3,0x65,0x44,0xd4,0x00', + 'vpclmulqdq $0x00, %ymm4, %ymm3, %ymm5' => '.byte 0xc4,0xe3,0x65,0x44,0xec,0x00', + 'vpclmulqdq $0x00, %ymm5, %ymm3, %ymm0' => '.byte 0xc4,0xe3,0x65,0x44,0xc5,0x00', + 'vpclmulqdq $0x00, %ymm5, %ymm4, %ymm0' => '.byte 0xc4,0xe3,0x5d,0x44,0xc5,0x00', + 'vpclmulqdq $0x00, %ymm7, %ymm2, %ymm6' => '.byte 0xc4,0xe3,0x6d,0x44,0xf7,0x00', + 'vpclmulqdq $0x00, %ymm8, %ymm2, %ymm2' => '.byte 0xc4,0xc3,0x6d,0x44,0xd0,0x00', + 'vpclmulqdq $0x01, %ymm0, %ymm6, %ymm2' => '.byte 0xc4,0xe3,0x4d,0x44,0xd0,0x01', + 'vpclmulqdq $0x01, %ymm1, %ymm6, %ymm0' => '.byte 0xc4,0xe3,0x4d,0x44,0xc1,0x01', + 'vpclmulqdq $0x01, %ymm2, %ymm12, %ymm4' => '.byte 0xc4,0xe3,0x1d,0x44,0xe2,0x01', + 'vpclmulqdq $0x01, %ymm2, %ymm12, %ymm6' => '.byte 0xc4,0xe3,0x1d,0x44,0xf2,0x01', + 'vpclmulqdq $0x01, %ymm3, %ymm13, %ymm4' => '.byte 0xc4,0xe3,0x15,0x44,0xe3,0x01', + 'vpclmulqdq $0x01, %ymm5, %ymm2, %ymm3' => '.byte 0xc4,0xe3,0x6d,0x44,0xdd,0x01', + 'vpclmulqdq $0x01, %ymm5, %ymm3, %ymm1' => '.byte 0xc4,0xe3,0x65,0x44,0xcd,0x01', + 'vpclmulqdq $0x01, %ymm5, %ymm4, %ymm1' => '.byte 0xc4,0xe3,0x5d,0x44,0xcd,0x01', + 'vpclmulqdq $0x01, %ymm5, %ymm4, %ymm2' => '.byte 0xc4,0xe3,0x5d,0x44,0xd5,0x01', + 'vpclmulqdq $0x01, %ymm6, %ymm2, %ymm3' => '.byte 0xc4,0xe3,0x6d,0x44,0xde,0x01', + 'vpclmulqdq $0x01, %ymm6, %ymm4, %ymm2' => '.byte 0xc4,0xe3,0x5d,0x44,0xd6,0x01', + 'vpclmulqdq $0x10, %ymm2, %ymm12, %ymm4' => '.byte 0xc4,0xe3,0x1d,0x44,0xe2,0x10', + 'vpclmulqdq $0x10, %ymm3, %ymm13, %ymm4' => '.byte 0xc4,0xe3,0x15,0x44,0xe3,0x10', + 'vpclmulqdq $0x10, %ymm5, %ymm3, %ymm2' => '.byte 0xc4,0xe3,0x65,0x44,0xd5,0x10', + 'vpclmulqdq $0x10, %ymm5, %ymm4, %ymm2' => '.byte 0xc4,0xe3,0x5d,0x44,0xd5,0x10', + 'vpclmulqdq $0x10, %ymm7, %ymm2, %ymm2' => '.byte 0xc4,0xe3,0x6d,0x44,0xd7,0x10', + 'vpclmulqdq $0x10, %ymm8, %ymm2, %ymm2' => '.byte 0xc4,0xc3,0x6d,0x44,0xd0,0x10', + 'vpclmulqdq $0x11, %ymm2, %ymm12, %ymm4' => '.byte 0xc4,0xe3,0x1d,0x44,0xe2,0x11', + 'vpclmulqdq $0x11, %ymm2, %ymm12, %ymm7' => '.byte 0xc4,0xe3,0x1d,0x44,0xfa,0x11', + 'vpclmulqdq $0x11, %ymm3, %ymm13, %ymm4' => '.byte 0xc4,0xe3,0x15,0x44,0xe3,0x11', + 'vpclmulqdq $0x11, %ymm4, %ymm3, %ymm1' => '.byte 0xc4,0xe3,0x65,0x44,0xcc,0x11', + 'vpclmulqdq $0x11, %ymm4, %ymm3, %ymm2' => '.byte 0xc4,0xe3,0x65,0x44,0xd4,0x11', + 'vpclmulqdq $0x11, %ymm5, %ymm3, %ymm4' => '.byte 0xc4,0xe3,0x65,0x44,0xe5,0x11', + 'vpclmulqdq $0x11, %ymm5, %ymm4, %ymm3' => '.byte 0xc4,0xe3,0x5d,0x44,0xdd,0x11', + ); + for my $line (split("\n",$code)) { + my $trimmed; + $trimmed = $line; + $trimmed =~ s/^\s+//; + $trimmed =~ s/\s+(#.*)?$//; + if (exists $asmMap{$trimmed}) { + $line = $asmMap{$trimmed}; + } else { + if($trimmed =~ /(vpclmulqdq|vaes).*%[yz]mm/) { + die ("found instruction not supported under old binutils, please update asmMap with the results of running\n" . + 'find target -name "*aes-gcm-avx2*.o" -exec python3 crypto/fipsmodule/aes/asm/make-avx-map-for-old-binutils.py \{\} \; | LC_ALL=C sort | uniq'); + } + } + print $line,"\n"; + } +} + +filter_and_print(); + +close STDOUT or die "error closing STDOUT: $!"; +exit 0; diff --git a/http/vendor/ring/crypto/fipsmodule/aes/asm/aesni-gcm-x86_64.pl b/http/vendor/ring/crypto/fipsmodule/aes/asm/aesni-gcm-x86_64.pl new file mode 100644 index 0000000..77c8bbe --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/aes/asm/aesni-gcm-x86_64.pl @@ -0,0 +1,1120 @@ +#! /usr/bin/env perl +# Copyright 2013-2016 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# ==================================================================== +# Written by Andy Polyakov for the OpenSSL +# project. +# ==================================================================== +# +# +# AES-NI-CTR+GHASH stitch. +# +# February 2013 +# +# OpenSSL GCM implementation is organized in such way that its +# performance is rather close to the sum of its streamed components, +# in the context parallelized AES-NI CTR and modulo-scheduled +# PCLMULQDQ-enabled GHASH. Unfortunately, as no stitch implementation +# was observed to perform significantly better than the sum of the +# components on contemporary CPUs, the effort was deemed impossible to +# justify. This module is based on combination of Intel submissions, +# [1] and [2], with MOVBE twist suggested by Ilya Albrekht and Max +# Locktyukhin of Intel Corp. who verified that it reduces shuffles +# pressure with notable relative improvement, achieving 1.0 cycle per +# byte processed with 128-bit key on Haswell processor, 0.74 - on +# Broadwell, 0.63 - on Skylake... [Mentioned results are raw profiled +# measurements for favourable packet size, one divisible by 96. +# Applications using the EVP interface will observe a few percent +# worse performance.] +# +# Knights Landing processes 1 byte in 1.25 cycles (measured with EVP). +# +# [1] http://rt.openssl.org/Ticket/Display.html?id=2900&user=guest&pass=guest +# [2] http://www.intel.com/content/dam/www/public/us/en/documents/software-support/enabling-high-performance-gcm.pdf + +$flavour = shift; +$output = shift; +if ($flavour =~ /\./) { $output = $flavour; undef $flavour; } + +$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/); + +$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; +( $xlate="${dir}x86_64-xlate.pl" and -f $xlate ) or +( $xlate="${dir}../../../perlasm/x86_64-xlate.pl" and -f $xlate) or +die "can't locate x86_64-xlate.pl"; + +# |$avx| in ghash-x86_64.pl must be set to at least 1; otherwise tags will +# be computed incorrectly. +# +# In upstream, this is controlled by shelling out to the compiler to check +# versions, but BoringSSL is intended to be used with pre-generated perlasm +# output, so this isn't useful anyway. +# +# The upstream code uses the condition |$avx>1| even though no AVX2 +# instructions are used, because it assumes MOVBE is supported by the assembler +# if and only if AVX2 is also supported by the assembler; see +# https://marc.info/?l=openssl-dev&m=146567589526984&w=2. +$avx = 2; + +open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""; +*STDOUT=*OUT; + +# See the comment above regarding why the condition is ($avx>1) when there are +# no AVX2 instructions being used. +if ($avx>1) {{{ + +# On Windows, only four parameters are passed in registers. The last two +# parameters will be manually loaded into %rdi and %rsi. +my ($inp, $out, $len, $key, $ivp, $Htable) = + $win64 ? ("%rcx", "%rdx", "%r8", "%r9", "%rdi", "%rsi") : + ("%rdi", "%rsi", "%rdx", "%rcx", "%r8", "%r9"); + +# The offset from %rbp to the Xip parameter. On Windows, all parameters have +# corresponding stack positions, not just ones passed on the stack. +# (0x40 = 6*8 + 0x10) +# +# Xip only needs to be accessed at the beginning and end of the function, and +# this function is short on registers, so we make it the last parameter for +# convenience. +my $Xip_offset = $win64 ? 0x40 : 0x10; + +($Ii,$T1,$T2,$Hkey, + $Z0,$Z1,$Z2,$Z3,$Xi) = map("%xmm$_",(0..8)); + +($inout0,$inout1,$inout2,$inout3,$inout4,$inout5,$rndkey) = map("%xmm$_",(9..15)); + +($counter,$rounds,$const,$in0,$end0)=("%ebx","%r10d","%r11","%r14","%r15"); + +$code=<<___; +.text + +.type _aesni_ctr32_ghash_6x,\@abi-omnipotent +.align 32 +_aesni_ctr32_ghash_6x: +.cfi_startproc + vmovdqu 0x20($const),$T2 # borrow $T2, .Lone_msb + sub \$6,$len + vpxor $Z0,$Z0,$Z0 # $Z0 = 0 + vmovdqu 0x00-0x80($key),$rndkey + vpaddb $T2,$T1,$inout1 + vpaddb $T2,$inout1,$inout2 + vpaddb $T2,$inout2,$inout3 + vpaddb $T2,$inout3,$inout4 + vpaddb $T2,$inout4,$inout5 + vpxor $rndkey,$T1,$inout0 + vmovdqu $Z0,16+8(%rsp) # "$Z3" = 0 + jmp .Loop6x + +.align 32 +.Loop6x: + add \$`6<<24`,$counter + jc .Lhandle_ctr32 # discard $inout[1-5]? + vmovdqu 0x00-0x20($Htable),$Hkey # $Hkey^1 + vpaddb $T2,$inout5,$T1 # next counter value + vpxor $rndkey,$inout1,$inout1 + vpxor $rndkey,$inout2,$inout2 + +.Lresume_ctr32: + vmovdqu $T1,($ivp) # save next counter value + vpclmulqdq \$0x10,$Hkey,$Z3,$Z1 + vpxor $rndkey,$inout3,$inout3 + vmovups 0x10-0x80($key),$T2 # borrow $T2 for $rndkey + vpclmulqdq \$0x01,$Hkey,$Z3,$Z2 + + # At this point, the current block of 96 (0x60) bytes has already been + # loaded into registers. Concurrently with processing it, we want to + # load the next 96 bytes of input for the next round. Obviously, we can + # only do this if there are at least 96 more bytes of input beyond the + # input we're currently processing, or else we'd read past the end of + # the input buffer. Here, we set |%r12| to 96 if there are at least 96 + # bytes of input beyond the 96 bytes we're already processing, and we + # set |%r12| to 0 otherwise. In the case where we set |%r12| to 96, + # we'll read in the next block so that it is in registers for the next + # loop iteration. In the case where we set |%r12| to 0, we'll re-read + # the current block and then ignore what we re-read. + # + # At this point, |$in0| points to the current (already read into + # registers) block, and |$end0| points to 2*96 bytes before the end of + # the input. Thus, |$in0| > |$end0| means that we do not have the next + # 96-byte block to read in, and |$in0| <= |$end0| means we do. + xor %r12,%r12 + cmp $in0,$end0 + + vaesenc $T2,$inout0,$inout0 + vmovdqu 0x30+8(%rsp),$Ii # I[4] + vpxor $rndkey,$inout4,$inout4 + vpclmulqdq \$0x00,$Hkey,$Z3,$T1 + vaesenc $T2,$inout1,$inout1 + vpxor $rndkey,$inout5,$inout5 + setnc %r12b + vpclmulqdq \$0x11,$Hkey,$Z3,$Z3 + vaesenc $T2,$inout2,$inout2 + vmovdqu 0x10-0x20($Htable),$Hkey # $Hkey^2 + neg %r12 + vaesenc $T2,$inout3,$inout3 + vpxor $Z1,$Z2,$Z2 + vpclmulqdq \$0x00,$Hkey,$Ii,$Z1 + vpxor $Z0,$Xi,$Xi # modulo-scheduled + vaesenc $T2,$inout4,$inout4 + vpxor $Z1,$T1,$Z0 + and \$0x60,%r12 + vmovups 0x20-0x80($key),$rndkey + vpclmulqdq \$0x10,$Hkey,$Ii,$T1 + vaesenc $T2,$inout5,$inout5 + + vpclmulqdq \$0x01,$Hkey,$Ii,$T2 + lea ($in0,%r12),$in0 + vaesenc $rndkey,$inout0,$inout0 + vpxor 16+8(%rsp),$Xi,$Xi # modulo-scheduled [vpxor $Z3,$Xi,$Xi] + vpclmulqdq \$0x11,$Hkey,$Ii,$Hkey + vmovdqu 0x40+8(%rsp),$Ii # I[3] + vaesenc $rndkey,$inout1,$inout1 + movbe 0x58($in0),%r13 + vaesenc $rndkey,$inout2,$inout2 + movbe 0x50($in0),%r12 + vaesenc $rndkey,$inout3,$inout3 + mov %r13,0x20+8(%rsp) + vaesenc $rndkey,$inout4,$inout4 + mov %r12,0x28+8(%rsp) + vmovdqu 0x30-0x20($Htable),$Z1 # borrow $Z1 for $Hkey^3 + vaesenc $rndkey,$inout5,$inout5 + + vmovups 0x30-0x80($key),$rndkey + vpxor $T1,$Z2,$Z2 + vpclmulqdq \$0x00,$Z1,$Ii,$T1 + vaesenc $rndkey,$inout0,$inout0 + vpxor $T2,$Z2,$Z2 + vpclmulqdq \$0x10,$Z1,$Ii,$T2 + vaesenc $rndkey,$inout1,$inout1 + vpxor $Hkey,$Z3,$Z3 + vpclmulqdq \$0x01,$Z1,$Ii,$Hkey + vaesenc $rndkey,$inout2,$inout2 + vpclmulqdq \$0x11,$Z1,$Ii,$Z1 + vmovdqu 0x50+8(%rsp),$Ii # I[2] + vaesenc $rndkey,$inout3,$inout3 + vaesenc $rndkey,$inout4,$inout4 + vpxor $T1,$Z0,$Z0 + vmovdqu 0x40-0x20($Htable),$T1 # borrow $T1 for $Hkey^4 + vaesenc $rndkey,$inout5,$inout5 + + vmovups 0x40-0x80($key),$rndkey + vpxor $T2,$Z2,$Z2 + vpclmulqdq \$0x00,$T1,$Ii,$T2 + vaesenc $rndkey,$inout0,$inout0 + vpxor $Hkey,$Z2,$Z2 + vpclmulqdq \$0x10,$T1,$Ii,$Hkey + vaesenc $rndkey,$inout1,$inout1 + movbe 0x48($in0),%r13 + vpxor $Z1,$Z3,$Z3 + vpclmulqdq \$0x01,$T1,$Ii,$Z1 + vaesenc $rndkey,$inout2,$inout2 + movbe 0x40($in0),%r12 + vpclmulqdq \$0x11,$T1,$Ii,$T1 + vmovdqu 0x60+8(%rsp),$Ii # I[1] + vaesenc $rndkey,$inout3,$inout3 + mov %r13,0x30+8(%rsp) + vaesenc $rndkey,$inout4,$inout4 + mov %r12,0x38+8(%rsp) + vpxor $T2,$Z0,$Z0 + vmovdqu 0x60-0x20($Htable),$T2 # borrow $T2 for $Hkey^5 + vaesenc $rndkey,$inout5,$inout5 + + vmovups 0x50-0x80($key),$rndkey + vpxor $Hkey,$Z2,$Z2 + vpclmulqdq \$0x00,$T2,$Ii,$Hkey + vaesenc $rndkey,$inout0,$inout0 + vpxor $Z1,$Z2,$Z2 + vpclmulqdq \$0x10,$T2,$Ii,$Z1 + vaesenc $rndkey,$inout1,$inout1 + movbe 0x38($in0),%r13 + vpxor $T1,$Z3,$Z3 + vpclmulqdq \$0x01,$T2,$Ii,$T1 + vpxor 0x70+8(%rsp),$Xi,$Xi # accumulate I[0] + vaesenc $rndkey,$inout2,$inout2 + movbe 0x30($in0),%r12 + vpclmulqdq \$0x11,$T2,$Ii,$T2 + vaesenc $rndkey,$inout3,$inout3 + mov %r13,0x40+8(%rsp) + vaesenc $rndkey,$inout4,$inout4 + mov %r12,0x48+8(%rsp) + vpxor $Hkey,$Z0,$Z0 + vmovdqu 0x70-0x20($Htable),$Hkey # $Hkey^6 + vaesenc $rndkey,$inout5,$inout5 + + vmovups 0x60-0x80($key),$rndkey + vpxor $Z1,$Z2,$Z2 + vpclmulqdq \$0x10,$Hkey,$Xi,$Z1 + vaesenc $rndkey,$inout0,$inout0 + vpxor $T1,$Z2,$Z2 + vpclmulqdq \$0x01,$Hkey,$Xi,$T1 + vaesenc $rndkey,$inout1,$inout1 + movbe 0x28($in0),%r13 + vpxor $T2,$Z3,$Z3 + vpclmulqdq \$0x00,$Hkey,$Xi,$T2 + vaesenc $rndkey,$inout2,$inout2 + movbe 0x20($in0),%r12 + vpclmulqdq \$0x11,$Hkey,$Xi,$Xi + vaesenc $rndkey,$inout3,$inout3 + mov %r13,0x50+8(%rsp) + vaesenc $rndkey,$inout4,$inout4 + mov %r12,0x58+8(%rsp) + vpxor $Z1,$Z2,$Z2 + vaesenc $rndkey,$inout5,$inout5 + vpxor $T1,$Z2,$Z2 + + vmovups 0x70-0x80($key),$rndkey + vpslldq \$8,$Z2,$Z1 + vpxor $T2,$Z0,$Z0 + vmovdqu 0x10($const),$Hkey # .Lpoly + + vaesenc $rndkey,$inout0,$inout0 + vpxor $Xi,$Z3,$Z3 + vaesenc $rndkey,$inout1,$inout1 + vpxor $Z1,$Z0,$Z0 + movbe 0x18($in0),%r13 + vaesenc $rndkey,$inout2,$inout2 + movbe 0x10($in0),%r12 + vpalignr \$8,$Z0,$Z0,$Ii # 1st phase + vpclmulqdq \$0x10,$Hkey,$Z0,$Z0 + mov %r13,0x60+8(%rsp) + vaesenc $rndkey,$inout3,$inout3 + mov %r12,0x68+8(%rsp) + vaesenc $rndkey,$inout4,$inout4 + vmovups 0x80-0x80($key),$T1 # borrow $T1 for $rndkey + vaesenc $rndkey,$inout5,$inout5 + + vaesenc $T1,$inout0,$inout0 + vmovups 0x90-0x80($key),$rndkey + vaesenc $T1,$inout1,$inout1 + vpsrldq \$8,$Z2,$Z2 + vaesenc $T1,$inout2,$inout2 + vpxor $Z2,$Z3,$Z3 + vaesenc $T1,$inout3,$inout3 + vpxor $Ii,$Z0,$Z0 + movbe 0x08($in0),%r13 + vaesenc $T1,$inout4,$inout4 + movbe 0x00($in0),%r12 + vaesenc $T1,$inout5,$inout5 + vmovups 0xa0-0x80($key),$T1 + cmp \$11,$rounds + jb .Lenc_tail # 128-bit key + + vaesenc $rndkey,$inout0,$inout0 + vaesenc $rndkey,$inout1,$inout1 + vaesenc $rndkey,$inout2,$inout2 + vaesenc $rndkey,$inout3,$inout3 + vaesenc $rndkey,$inout4,$inout4 + vaesenc $rndkey,$inout5,$inout5 + + vaesenc $T1,$inout0,$inout0 + vaesenc $T1,$inout1,$inout1 + vaesenc $T1,$inout2,$inout2 + vaesenc $T1,$inout3,$inout3 + vaesenc $T1,$inout4,$inout4 + vmovups 0xb0-0x80($key),$rndkey + vaesenc $T1,$inout5,$inout5 + vmovups 0xc0-0x80($key),$T1 + # 192-bit key support was removed. + + vaesenc $rndkey,$inout0,$inout0 + vaesenc $rndkey,$inout1,$inout1 + vaesenc $rndkey,$inout2,$inout2 + vaesenc $rndkey,$inout3,$inout3 + vaesenc $rndkey,$inout4,$inout4 + vaesenc $rndkey,$inout5,$inout5 + + vaesenc $T1,$inout0,$inout0 + vaesenc $T1,$inout1,$inout1 + vaesenc $T1,$inout2,$inout2 + vaesenc $T1,$inout3,$inout3 + vaesenc $T1,$inout4,$inout4 + vmovups 0xd0-0x80($key),$rndkey + vaesenc $T1,$inout5,$inout5 + vmovups 0xe0-0x80($key),$T1 + jmp .Lenc_tail # 256-bit key + +.align 32 +.Lhandle_ctr32: + vmovdqu ($const),$Ii # borrow $Ii for .Lbswap_mask + vpshufb $Ii,$T1,$Z2 # byte-swap counter + vmovdqu 0x30($const),$Z1 # borrow $Z1, .Ltwo_lsb + vpaddd 0x40($const),$Z2,$inout1 # .Lone_lsb + vpaddd $Z1,$Z2,$inout2 + vmovdqu 0x00-0x20($Htable),$Hkey # $Hkey^1 + vpaddd $Z1,$inout1,$inout3 + vpshufb $Ii,$inout1,$inout1 + vpaddd $Z1,$inout2,$inout4 + vpshufb $Ii,$inout2,$inout2 + vpxor $rndkey,$inout1,$inout1 + vpaddd $Z1,$inout3,$inout5 + vpshufb $Ii,$inout3,$inout3 + vpxor $rndkey,$inout2,$inout2 + vpaddd $Z1,$inout4,$T1 # byte-swapped next counter value + vpshufb $Ii,$inout4,$inout4 + vpshufb $Ii,$inout5,$inout5 + vpshufb $Ii,$T1,$T1 # next counter value + jmp .Lresume_ctr32 + +.align 32 +.Lenc_tail: + vaesenc $rndkey,$inout0,$inout0 + vmovdqu $Z3,16+8(%rsp) # postpone vpxor $Z3,$Xi,$Xi + vpalignr \$8,$Z0,$Z0,$Xi # 2nd phase + vaesenc $rndkey,$inout1,$inout1 + vpclmulqdq \$0x10,$Hkey,$Z0,$Z0 + vpxor 0x00($inp),$T1,$T2 + vaesenc $rndkey,$inout2,$inout2 + vpxor 0x10($inp),$T1,$Ii + vaesenc $rndkey,$inout3,$inout3 + vpxor 0x20($inp),$T1,$Z1 + vaesenc $rndkey,$inout4,$inout4 + vpxor 0x30($inp),$T1,$Z2 + vaesenc $rndkey,$inout5,$inout5 + vpxor 0x40($inp),$T1,$Z3 + vpxor 0x50($inp),$T1,$Hkey + vmovdqu ($ivp),$T1 # load next counter value + + vaesenclast $T2,$inout0,$inout0 + vmovdqu 0x20($const),$T2 # borrow $T2, .Lone_msb + vaesenclast $Ii,$inout1,$inout1 + vpaddb $T2,$T1,$Ii + mov %r13,0x70+8(%rsp) + lea 0x60($inp),$inp + # These two prefetches were added in BoringSSL. See change that added them. + prefetcht0 512($inp) # We use 96-byte block so prefetch 2 lines (128 bytes) + prefetcht0 576($inp) + vaesenclast $Z1,$inout2,$inout2 + vpaddb $T2,$Ii,$Z1 + mov %r12,0x78+8(%rsp) + lea 0x60($out),$out + vmovdqu 0x00-0x80($key),$rndkey + vaesenclast $Z2,$inout3,$inout3 + vpaddb $T2,$Z1,$Z2 + vaesenclast $Z3, $inout4,$inout4 + vpaddb $T2,$Z2,$Z3 + vaesenclast $Hkey,$inout5,$inout5 + vpaddb $T2,$Z3,$Hkey + + add \$0x60,%rax + sub \$0x6,$len + jc .L6x_done + + vmovups $inout0,-0x60($out) # save output + vpxor $rndkey,$T1,$inout0 + vmovups $inout1,-0x50($out) + vmovdqa $Ii,$inout1 # 0 latency + vmovups $inout2,-0x40($out) + vmovdqa $Z1,$inout2 # 0 latency + vmovups $inout3,-0x30($out) + vmovdqa $Z2,$inout3 # 0 latency + vmovups $inout4,-0x20($out) + vmovdqa $Z3,$inout4 # 0 latency + vmovups $inout5,-0x10($out) + vmovdqa $Hkey,$inout5 # 0 latency + vmovdqu 0x20+8(%rsp),$Z3 # I[5] + jmp .Loop6x + +.L6x_done: + vpxor 16+8(%rsp),$Xi,$Xi # modulo-scheduled + vpxor $Z0,$Xi,$Xi # modulo-scheduled + + ret +.cfi_endproc +.size _aesni_ctr32_ghash_6x,.-_aesni_ctr32_ghash_6x +___ +###################################################################### +# +# size_t aesni_gcm_[en|de]crypt(const void *inp, void *out, size_t len, +# const AES_KEY *key, unsigned char iv[16], const u128 Htbl[9], +# u128 *Xip); +$code.=<<___; +.globl aesni_gcm_decrypt +.type aesni_gcm_decrypt,\@abi-omnipotent +.align 32 +aesni_gcm_decrypt: +.cfi_startproc +.seh_startproc + _CET_ENDBR + xor %rax,%rax + + # We call |_aesni_ctr32_ghash_6x|, which requires at least 96 (0x60) + # bytes of input. + cmp \$0x60,$len # minimal accepted length + jb .Lgcm_dec_abort + + push %rbp +.cfi_push %rbp +.seh_pushreg %rbp + mov %rsp, %rbp # save stack pointer +.cfi_def_cfa_register %rbp + push %rbx +.cfi_push %rbx +.seh_pushreg %rbx + push %r12 +.cfi_push %r12 +.seh_pushreg %r12 + push %r13 +.cfi_push %r13 +.seh_pushreg %r13 + push %r14 +.cfi_push %r14 +.seh_pushreg %r14 + push %r15 +.cfi_push %r15 +.seh_pushreg %r15 +___ +if ($win64) { +$code.=<<___ + lea -0xa8(%rsp),%rsp # 8 extra bytes to align the stack +.seh_stackalloc 0xa8 +.seh_setframe %rbp, 0xa8+5*8 + # Load the last two parameters. These go into %rdi and %rsi, which are + # non-volatile on Windows, so stash them in the parameter stack area + # first. + mov %rdi, 0x10(%rbp) +.seh_savereg %rdi, 0xa8+5*8+0x10 + mov %rsi, 0x18(%rbp) +.seh_savereg %rsi, 0xa8+5*8+0x18 + mov 0x30(%rbp), $ivp + mov 0x38(%rbp), $Htable + # Save non-volatile XMM registers. + movaps %xmm6,-0xd0(%rbp) +.seh_savexmm %xmm6, 0xa8+5*8-0xd0 + movaps %xmm7,-0xc0(%rbp) +.seh_savexmm %xmm7, 0xa8+5*8-0xc0 + movaps %xmm8,-0xb0(%rbp) +.seh_savexmm %xmm8, 0xa8+5*8-0xb0 + movaps %xmm9,-0xa0(%rbp) +.seh_savexmm %xmm9, 0xa8+5*8-0xa0 + movaps %xmm10,-0x90(%rbp) +.seh_savexmm %xmm10, 0xa8+5*8-0x90 + movaps %xmm11,-0x80(%rbp) +.seh_savexmm %xmm11, 0xa8+5*8-0x80 + movaps %xmm12,-0x70(%rbp) +.seh_savexmm %xmm12, 0xa8+5*8-0x70 + movaps %xmm13,-0x60(%rbp) +.seh_savexmm %xmm13, 0xa8+5*8-0x60 + movaps %xmm14,-0x50(%rbp) +.seh_savexmm %xmm14, 0xa8+5*8-0x50 + movaps %xmm15,-0x40(%rbp) +.seh_savexmm %xmm15, 0xa8+5*8-0x40 +.seh_endprologue +___ +} +$code.=<<___; + vzeroupper + + mov $Xip_offset(%rbp), %r12 + vmovdqu ($ivp),$T1 # input counter value + add \$-128,%rsp + mov 12($ivp),$counter + lea .Lbswap_mask(%rip),$const + lea -0x80($key),$in0 # borrow $in0 + mov \$0xf80,$end0 # borrow $end0 + vmovdqu (%r12),$Xi # load Xi + and \$-128,%rsp # ensure stack alignment + vmovdqu ($const),$Ii # borrow $Ii for .Lbswap_mask + lea 0x80($key),$key # size optimization + lea 0x20($Htable),$Htable # size optimization + mov 0xf0-0x80($key),$rounds + vpshufb $Ii,$Xi,$Xi + + and $end0,$in0 + and %rsp,$end0 + sub $in0,$end0 + jc .Ldec_no_key_aliasing + cmp \$768,$end0 + jnc .Ldec_no_key_aliasing + sub $end0,%rsp # avoid aliasing with key +.Ldec_no_key_aliasing: + + vmovdqu 0x50($inp),$Z3 # I[5] + mov $inp,$in0 + vmovdqu 0x40($inp),$Z0 + + # |_aesni_ctr32_ghash_6x| requires |$end0| to point to 2*96 (0xc0) + # bytes before the end of the input. Note, in particular, that this is + # correct even if |$len| is not an even multiple of 96 or 16. XXX: This + # seems to require that |$inp| + |$len| >= 2*96 (0xc0); i.e. |$inp| must + # not be near the very beginning of the address space when |$len| < 2*96 + # (0xc0). + lea -0xc0($inp,$len),$end0 + + vmovdqu 0x30($inp),$Z1 + shr \$4,$len + xor %rax,%rax + vmovdqu 0x20($inp),$Z2 + vpshufb $Ii,$Z3,$Z3 # passed to _aesni_ctr32_ghash_6x + vmovdqu 0x10($inp),$T2 + vpshufb $Ii,$Z0,$Z0 + vmovdqu ($inp),$Hkey + vpshufb $Ii,$Z1,$Z1 + vmovdqu $Z0,0x30(%rsp) + vpshufb $Ii,$Z2,$Z2 + vmovdqu $Z1,0x40(%rsp) + vpshufb $Ii,$T2,$T2 + vmovdqu $Z2,0x50(%rsp) + vpshufb $Ii,$Hkey,$Hkey + vmovdqu $T2,0x60(%rsp) + vmovdqu $Hkey,0x70(%rsp) + + call _aesni_ctr32_ghash_6x + + mov $Xip_offset(%rbp), %r12 + vmovups $inout0,-0x60($out) # save output + vmovups $inout1,-0x50($out) + vmovups $inout2,-0x40($out) + vmovups $inout3,-0x30($out) + vmovups $inout4,-0x20($out) + vmovups $inout5,-0x10($out) + + vpshufb ($const),$Xi,$Xi # .Lbswap_mask + vmovdqu $Xi,(%r12) # output Xi + + vzeroupper +___ +$code.=<<___ if ($win64); + movaps -0xd0(%rbp),%xmm6 + movaps -0xc0(%rbp),%xmm7 + movaps -0xb0(%rbp),%xmm8 + movaps -0xa0(%rbp),%xmm9 + movaps -0x90(%rbp),%xmm10 + movaps -0x80(%rbp),%xmm11 + movaps -0x70(%rbp),%xmm12 + movaps -0x60(%rbp),%xmm13 + movaps -0x50(%rbp),%xmm14 + movaps -0x40(%rbp),%xmm15 + mov 0x10(%rbp),%rdi + mov 0x18(%rbp),%rsi +___ +$code.=<<___; + lea -0x28(%rbp), %rsp # restore %rsp to fixed allocation +.cfi_def_cfa %rsp, 0x38 + pop %r15 +.cfi_pop %r15 + pop %r14 +.cfi_pop %r14 + pop %r13 +.cfi_pop %r13 + pop %r12 +.cfi_pop %r12 + pop %rbx +.cfi_pop %rbx + pop %rbp +.cfi_pop %rbp +.Lgcm_dec_abort: + ret +.seh_endproc +.cfi_endproc +.size aesni_gcm_decrypt,.-aesni_gcm_decrypt +___ + +$code.=<<___; +.type _aesni_ctr32_6x,\@abi-omnipotent +.align 32 +_aesni_ctr32_6x: +.cfi_startproc + vmovdqu 0x00-0x80($key),$Z0 # borrow $Z0 for $rndkey + vmovdqu 0x20($const),$T2 # borrow $T2, .Lone_msb + lea -1($rounds),%r13 + vmovups 0x10-0x80($key),$rndkey + lea 0x20-0x80($key),%r12 + vpxor $Z0,$T1,$inout0 + add \$`6<<24`,$counter + jc .Lhandle_ctr32_2 + vpaddb $T2,$T1,$inout1 + vpaddb $T2,$inout1,$inout2 + vpxor $Z0,$inout1,$inout1 + vpaddb $T2,$inout2,$inout3 + vpxor $Z0,$inout2,$inout2 + vpaddb $T2,$inout3,$inout4 + vpxor $Z0,$inout3,$inout3 + vpaddb $T2,$inout4,$inout5 + vpxor $Z0,$inout4,$inout4 + vpaddb $T2,$inout5,$T1 + vpxor $Z0,$inout5,$inout5 + jmp .Loop_ctr32 + +.align 16 +.Loop_ctr32: + vaesenc $rndkey,$inout0,$inout0 + vaesenc $rndkey,$inout1,$inout1 + vaesenc $rndkey,$inout2,$inout2 + vaesenc $rndkey,$inout3,$inout3 + vaesenc $rndkey,$inout4,$inout4 + vaesenc $rndkey,$inout5,$inout5 + vmovups (%r12),$rndkey + lea 0x10(%r12),%r12 + dec %r13d + jnz .Loop_ctr32 + + vmovdqu (%r12),$Hkey # last round key + vaesenc $rndkey,$inout0,$inout0 + vpxor 0x00($inp),$Hkey,$Z0 + vaesenc $rndkey,$inout1,$inout1 + vpxor 0x10($inp),$Hkey,$Z1 + vaesenc $rndkey,$inout2,$inout2 + vpxor 0x20($inp),$Hkey,$Z2 + vaesenc $rndkey,$inout3,$inout3 + vpxor 0x30($inp),$Hkey,$Xi + vaesenc $rndkey,$inout4,$inout4 + vpxor 0x40($inp),$Hkey,$T2 + vaesenc $rndkey,$inout5,$inout5 + vpxor 0x50($inp),$Hkey,$Hkey + lea 0x60($inp),$inp + + vaesenclast $Z0,$inout0,$inout0 + vaesenclast $Z1,$inout1,$inout1 + vaesenclast $Z2,$inout2,$inout2 + vaesenclast $Xi,$inout3,$inout3 + vaesenclast $T2,$inout4,$inout4 + vaesenclast $Hkey,$inout5,$inout5 + vmovups $inout0,0x00($out) + vmovups $inout1,0x10($out) + vmovups $inout2,0x20($out) + vmovups $inout3,0x30($out) + vmovups $inout4,0x40($out) + vmovups $inout5,0x50($out) + lea 0x60($out),$out + + ret +.align 32 +.Lhandle_ctr32_2: + vpshufb $Ii,$T1,$Z2 # byte-swap counter + vmovdqu 0x30($const),$Z1 # borrow $Z1, .Ltwo_lsb + vpaddd 0x40($const),$Z2,$inout1 # .Lone_lsb + vpaddd $Z1,$Z2,$inout2 + vpaddd $Z1,$inout1,$inout3 + vpshufb $Ii,$inout1,$inout1 + vpaddd $Z1,$inout2,$inout4 + vpshufb $Ii,$inout2,$inout2 + vpxor $Z0,$inout1,$inout1 + vpaddd $Z1,$inout3,$inout5 + vpshufb $Ii,$inout3,$inout3 + vpxor $Z0,$inout2,$inout2 + vpaddd $Z1,$inout4,$T1 # byte-swapped next counter value + vpshufb $Ii,$inout4,$inout4 + vpxor $Z0,$inout3,$inout3 + vpshufb $Ii,$inout5,$inout5 + vpxor $Z0,$inout4,$inout4 + vpshufb $Ii,$T1,$T1 # next counter value + vpxor $Z0,$inout5,$inout5 + jmp .Loop_ctr32 +.cfi_endproc +.size _aesni_ctr32_6x,.-_aesni_ctr32_6x + +.globl aesni_gcm_encrypt +.type aesni_gcm_encrypt,\@abi-omnipotent +.align 32 +aesni_gcm_encrypt: +.cfi_startproc +.seh_startproc + _CET_ENDBR +#ifdef BORINGSSL_DISPATCH_TEST +.extern BORINGSSL_function_hit + movb \$1,BORINGSSL_function_hit+2(%rip) +#endif + xor %rax,%rax + + # We call |_aesni_ctr32_6x| twice, each call consuming 96 bytes of + # input. Then we call |_aesni_ctr32_ghash_6x|, which requires at + # least 96 more bytes of input. + cmp \$0x60*3,$len # minimal accepted length + jb .Lgcm_enc_abort + + push %rbp +.cfi_push %rbp +.seh_pushreg %rbp + mov %rsp, %rbp # save stack pointer +.cfi_def_cfa_register %rbp + push %rbx +.cfi_push %rbx +.seh_pushreg %rbx + push %r12 +.cfi_push %r12 +.seh_pushreg %r12 + push %r13 +.cfi_push %r13 +.seh_pushreg %r13 + push %r14 +.cfi_push %r14 +.seh_pushreg %r14 + push %r15 +.cfi_push %r15 +.seh_pushreg %r15 +___ +if ($win64) { +$code.=<<___ + lea -0xa8(%rsp),%rsp # 8 extra bytes to align the stack +.seh_stackalloc 0xa8 +.seh_setframe %rbp, 0xa8+5*8 + # Load the last two parameters. These go into %rdi and %rsi, which are + # non-volatile on Windows, so stash them in the parameter stack area + # first. + mov %rdi, 0x10(%rbp) +.seh_savereg %rdi, 0xa8+5*8+0x10 + mov %rsi, 0x18(%rbp) +.seh_savereg %rsi, 0xa8+5*8+0x18 + mov 0x30(%rbp), $ivp + mov 0x38(%rbp), $Htable + # Save non-volatile XMM registers. + movaps %xmm6,-0xd0(%rbp) +.seh_savexmm %xmm6, 0xa8+5*8-0xd0 + movaps %xmm7,-0xc0(%rbp) +.seh_savexmm %xmm7, 0xa8+5*8-0xc0 + movaps %xmm8,-0xb0(%rbp) +.seh_savexmm %xmm8, 0xa8+5*8-0xb0 + movaps %xmm9,-0xa0(%rbp) +.seh_savexmm %xmm9, 0xa8+5*8-0xa0 + movaps %xmm10,-0x90(%rbp) +.seh_savexmm %xmm10, 0xa8+5*8-0x90 + movaps %xmm11,-0x80(%rbp) +.seh_savexmm %xmm11, 0xa8+5*8-0x80 + movaps %xmm12,-0x70(%rbp) +.seh_savexmm %xmm12, 0xa8+5*8-0x70 + movaps %xmm13,-0x60(%rbp) +.seh_savexmm %xmm13, 0xa8+5*8-0x60 + movaps %xmm14,-0x50(%rbp) +.seh_savexmm %xmm14, 0xa8+5*8-0x50 + movaps %xmm15,-0x40(%rbp) +.seh_savexmm %xmm15, 0xa8+5*8-0x40 +.seh_endprologue +___ +} +$code.=<<___; + vzeroupper + + vmovdqu ($ivp),$T1 # input counter value + add \$-128,%rsp + mov 12($ivp),$counter + lea .Lbswap_mask(%rip),$const + lea -0x80($key),$in0 # borrow $in0 + mov \$0xf80,$end0 # borrow $end0 + lea 0x80($key),$key # size optimization + vmovdqu ($const),$Ii # borrow $Ii for .Lbswap_mask + and \$-128,%rsp # ensure stack alignment + mov 0xf0-0x80($key),$rounds + + and $end0,$in0 + and %rsp,$end0 + sub $in0,$end0 + jc .Lenc_no_key_aliasing + cmp \$768,$end0 + jnc .Lenc_no_key_aliasing + sub $end0,%rsp # avoid aliasing with key +.Lenc_no_key_aliasing: + + mov $out,$in0 + + # |_aesni_ctr32_ghash_6x| requires |$end0| to point to 2*96 (0xc0) + # bytes before the end of the input. Note, in particular, that this is + # correct even if |$len| is not an even multiple of 96 or 16. Unlike in + # the decryption case, there's no caveat that |$out| must not be near + # the very beginning of the address space, because we know that + # |$len| >= 3*96 from the check above, and so we know + # |$out| + |$len| >= 2*96 (0xc0). + lea -0xc0($out,$len),$end0 + + shr \$4,$len + + call _aesni_ctr32_6x + vpshufb $Ii,$inout0,$Xi # save bswapped output on stack + vpshufb $Ii,$inout1,$T2 + vmovdqu $Xi,0x70(%rsp) + vpshufb $Ii,$inout2,$Z0 + vmovdqu $T2,0x60(%rsp) + vpshufb $Ii,$inout3,$Z1 + vmovdqu $Z0,0x50(%rsp) + vpshufb $Ii,$inout4,$Z2 + vmovdqu $Z1,0x40(%rsp) + vpshufb $Ii,$inout5,$Z3 # passed to _aesni_ctr32_ghash_6x + vmovdqu $Z2,0x30(%rsp) + + call _aesni_ctr32_6x + + mov $Xip_offset(%rbp), %r12 + lea 0x20($Htable),$Htable # size optimization + vmovdqu (%r12),$Xi # load Xi + sub \$12,$len + mov \$0x60*2,%rax + vpshufb $Ii,$Xi,$Xi + + call _aesni_ctr32_ghash_6x + vmovdqu 0x20(%rsp),$Z3 # I[5] + vmovdqu ($const),$Ii # borrow $Ii for .Lbswap_mask + vmovdqu 0x00-0x20($Htable),$Hkey # $Hkey^1 + vpunpckhqdq $Z3,$Z3,$T1 + vmovdqu 0x20-0x20($Htable),$rndkey # borrow $rndkey for $HK + vmovups $inout0,-0x60($out) # save output + vpshufb $Ii,$inout0,$inout0 # but keep bswapped copy + vpxor $Z3,$T1,$T1 + vmovups $inout1,-0x50($out) + vpshufb $Ii,$inout1,$inout1 + vmovups $inout2,-0x40($out) + vpshufb $Ii,$inout2,$inout2 + vmovups $inout3,-0x30($out) + vpshufb $Ii,$inout3,$inout3 + vmovups $inout4,-0x20($out) + vpshufb $Ii,$inout4,$inout4 + vmovups $inout5,-0x10($out) + vpshufb $Ii,$inout5,$inout5 + vmovdqu $inout0,0x10(%rsp) # free $inout0 +___ +{ my ($HK,$T3)=($rndkey,$inout0); + +$code.=<<___; + vmovdqu 0x30(%rsp),$Z2 # I[4] + vmovdqu 0x10-0x20($Htable),$Ii # borrow $Ii for $Hkey^2 + vpunpckhqdq $Z2,$Z2,$T2 + vpclmulqdq \$0x00,$Hkey,$Z3,$Z1 + vpxor $Z2,$T2,$T2 + vpclmulqdq \$0x11,$Hkey,$Z3,$Z3 + vpclmulqdq \$0x00,$HK,$T1,$T1 + + vmovdqu 0x40(%rsp),$T3 # I[3] + vpclmulqdq \$0x00,$Ii,$Z2,$Z0 + vmovdqu 0x30-0x20($Htable),$Hkey # $Hkey^3 + vpxor $Z1,$Z0,$Z0 + vpunpckhqdq $T3,$T3,$Z1 + vpclmulqdq \$0x11,$Ii,$Z2,$Z2 + vpxor $T3,$Z1,$Z1 + vpxor $Z3,$Z2,$Z2 + vpclmulqdq \$0x10,$HK,$T2,$T2 + vmovdqu 0x50-0x20($Htable),$HK + vpxor $T1,$T2,$T2 + + vmovdqu 0x50(%rsp),$T1 # I[2] + vpclmulqdq \$0x00,$Hkey,$T3,$Z3 + vmovdqu 0x40-0x20($Htable),$Ii # borrow $Ii for $Hkey^4 + vpxor $Z0,$Z3,$Z3 + vpunpckhqdq $T1,$T1,$Z0 + vpclmulqdq \$0x11,$Hkey,$T3,$T3 + vpxor $T1,$Z0,$Z0 + vpxor $Z2,$T3,$T3 + vpclmulqdq \$0x00,$HK,$Z1,$Z1 + vpxor $T2,$Z1,$Z1 + + vmovdqu 0x60(%rsp),$T2 # I[1] + vpclmulqdq \$0x00,$Ii,$T1,$Z2 + vmovdqu 0x60-0x20($Htable),$Hkey # $Hkey^5 + vpxor $Z3,$Z2,$Z2 + vpunpckhqdq $T2,$T2,$Z3 + vpclmulqdq \$0x11,$Ii,$T1,$T1 + vpxor $T2,$Z3,$Z3 + vpxor $T3,$T1,$T1 + vpclmulqdq \$0x10,$HK,$Z0,$Z0 + vmovdqu 0x80-0x20($Htable),$HK + vpxor $Z1,$Z0,$Z0 + + vpxor 0x70(%rsp),$Xi,$Xi # accumulate I[0] + vpclmulqdq \$0x00,$Hkey,$T2,$Z1 + vmovdqu 0x70-0x20($Htable),$Ii # borrow $Ii for $Hkey^6 + vpunpckhqdq $Xi,$Xi,$T3 + vpxor $Z2,$Z1,$Z1 + vpclmulqdq \$0x11,$Hkey,$T2,$T2 + vpxor $Xi,$T3,$T3 + vpxor $T1,$T2,$T2 + vpclmulqdq \$0x00,$HK,$Z3,$Z3 + vpxor $Z0,$Z3,$Z0 + + vpclmulqdq \$0x00,$Ii,$Xi,$Z2 + vmovdqu 0x00-0x20($Htable),$Hkey # $Hkey^1 + vpunpckhqdq $inout5,$inout5,$T1 + vpclmulqdq \$0x11,$Ii,$Xi,$Xi + vpxor $inout5,$T1,$T1 + vpxor $Z1,$Z2,$Z1 + vpclmulqdq \$0x10,$HK,$T3,$T3 + vmovdqu 0x20-0x20($Htable),$HK + vpxor $T2,$Xi,$Z3 + vpxor $Z0,$T3,$Z2 + + vmovdqu 0x10-0x20($Htable),$Ii # borrow $Ii for $Hkey^2 + vpxor $Z1,$Z3,$T3 # aggregated Karatsuba post-processing + vpclmulqdq \$0x00,$Hkey,$inout5,$Z0 + vpxor $T3,$Z2,$Z2 + vpunpckhqdq $inout4,$inout4,$T2 + vpclmulqdq \$0x11,$Hkey,$inout5,$inout5 + vpxor $inout4,$T2,$T2 + vpslldq \$8,$Z2,$T3 + vpclmulqdq \$0x00,$HK,$T1,$T1 + vpxor $T3,$Z1,$Xi + vpsrldq \$8,$Z2,$Z2 + vpxor $Z2,$Z3,$Z3 + + vpclmulqdq \$0x00,$Ii,$inout4,$Z1 + vmovdqu 0x30-0x20($Htable),$Hkey # $Hkey^3 + vpxor $Z0,$Z1,$Z1 + vpunpckhqdq $inout3,$inout3,$T3 + vpclmulqdq \$0x11,$Ii,$inout4,$inout4 + vpxor $inout3,$T3,$T3 + vpxor $inout5,$inout4,$inout4 + vpalignr \$8,$Xi,$Xi,$inout5 # 1st phase + vpclmulqdq \$0x10,$HK,$T2,$T2 + vmovdqu 0x50-0x20($Htable),$HK + vpxor $T1,$T2,$T2 + + vpclmulqdq \$0x00,$Hkey,$inout3,$Z0 + vmovdqu 0x40-0x20($Htable),$Ii # borrow $Ii for $Hkey^4 + vpxor $Z1,$Z0,$Z0 + vpunpckhqdq $inout2,$inout2,$T1 + vpclmulqdq \$0x11,$Hkey,$inout3,$inout3 + vpxor $inout2,$T1,$T1 + vpxor $inout4,$inout3,$inout3 + vxorps 0x10(%rsp),$Z3,$Z3 # accumulate $inout0 + vpclmulqdq \$0x00,$HK,$T3,$T3 + vpxor $T2,$T3,$T3 + + vpclmulqdq \$0x10,0x10($const),$Xi,$Xi + vxorps $inout5,$Xi,$Xi + + vpclmulqdq \$0x00,$Ii,$inout2,$Z1 + vmovdqu 0x60-0x20($Htable),$Hkey # $Hkey^5 + vpxor $Z0,$Z1,$Z1 + vpunpckhqdq $inout1,$inout1,$T2 + vpclmulqdq \$0x11,$Ii,$inout2,$inout2 + vpxor $inout1,$T2,$T2 + vpalignr \$8,$Xi,$Xi,$inout5 # 2nd phase + vpxor $inout3,$inout2,$inout2 + vpclmulqdq \$0x10,$HK,$T1,$T1 + vmovdqu 0x80-0x20($Htable),$HK + vpxor $T3,$T1,$T1 + + vxorps $Z3,$inout5,$inout5 + vpclmulqdq \$0x10,0x10($const),$Xi,$Xi + vxorps $inout5,$Xi,$Xi + + vpclmulqdq \$0x00,$Hkey,$inout1,$Z0 + vmovdqu 0x70-0x20($Htable),$Ii # borrow $Ii for $Hkey^6 + vpxor $Z1,$Z0,$Z0 + vpunpckhqdq $Xi,$Xi,$T3 + vpclmulqdq \$0x11,$Hkey,$inout1,$inout1 + vpxor $Xi,$T3,$T3 + vpxor $inout2,$inout1,$inout1 + vpclmulqdq \$0x00,$HK,$T2,$T2 + vpxor $T1,$T2,$T2 + + vpclmulqdq \$0x00,$Ii,$Xi,$Z1 + vpclmulqdq \$0x11,$Ii,$Xi,$Z3 + vpxor $Z0,$Z1,$Z1 + vpclmulqdq \$0x10,$HK,$T3,$Z2 + vpxor $inout1,$Z3,$Z3 + vpxor $T2,$Z2,$Z2 + + vpxor $Z1,$Z3,$Z0 # aggregated Karatsuba post-processing + vpxor $Z0,$Z2,$Z2 + vpslldq \$8,$Z2,$T1 + vmovdqu 0x10($const),$Hkey # .Lpoly + vpsrldq \$8,$Z2,$Z2 + vpxor $T1,$Z1,$Xi + vpxor $Z2,$Z3,$Z3 + + vpalignr \$8,$Xi,$Xi,$T2 # 1st phase + vpclmulqdq \$0x10,$Hkey,$Xi,$Xi + vpxor $T2,$Xi,$Xi + + vpalignr \$8,$Xi,$Xi,$T2 # 2nd phase + vpclmulqdq \$0x10,$Hkey,$Xi,$Xi + vpxor $Z3,$T2,$T2 + vpxor $T2,$Xi,$Xi +___ +} +$code.=<<___; + mov $Xip_offset(%rbp), %r12 + vpshufb ($const),$Xi,$Xi # .Lbswap_mask + vmovdqu $Xi,(%r12) # output Xi + + vzeroupper +___ +$code.=<<___ if ($win64); + movaps -0xd0(%rbp),%xmm6 + movaps -0xc0(%rbp),%xmm7 + movaps -0xb0(%rbp),%xmm8 + movaps -0xa0(%rbp),%xmm9 + movaps -0x90(%rbp),%xmm10 + movaps -0x80(%rbp),%xmm11 + movaps -0x70(%rbp),%xmm12 + movaps -0x60(%rbp),%xmm13 + movaps -0x50(%rbp),%xmm14 + movaps -0x40(%rbp),%xmm15 + mov 0x10(%rbp),%rdi + mov 0x18(%rbp),%rsi +___ +$code.=<<___; + lea -0x28(%rbp), %rsp # restore %rsp to fixed allocation +.cfi_def_cfa %rsp, 0x38 + pop %r15 +.cfi_pop %r15 + pop %r14 +.cfi_pop %r14 + pop %r13 +.cfi_pop %r13 + pop %r12 +.cfi_pop %r12 + pop %rbx +.cfi_pop %rbx + pop %rbp +.cfi_pop %rbp +.Lgcm_enc_abort: + ret +.seh_endproc +.cfi_endproc +.size aesni_gcm_encrypt,.-aesni_gcm_encrypt +___ + +$code.=<<___; +.section .rodata +.align 64 +.Lbswap_mask: + .byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 +.Lpoly: + .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0xc2 +.Lone_msb: + .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 +.Ltwo_lsb: + .byte 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +.Lone_lsb: + .byte 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +.asciz "AES-NI GCM module for x86_64, CRYPTOGAMS by " +.align 64 +.text +___ +}}} else {{{ +$code=<<___; # assembler is too old +.text + +.globl aesni_gcm_encrypt +.type aesni_gcm_encrypt,\@abi-omnipotent +aesni_gcm_encrypt: + _CET_ENDBR + xor %eax,%eax + ret +.size aesni_gcm_encrypt,.-aesni_gcm_encrypt + +.globl aesni_gcm_decrypt +.type aesni_gcm_decrypt,\@abi-omnipotent +aesni_gcm_decrypt: + _CET_ENDBR + xor %eax,%eax + ret +.size aesni_gcm_decrypt,.-aesni_gcm_decrypt +___ +}}} + +$code =~ s/\`([^\`]*)\`/eval($1)/gem; + +print $code; + +close STDOUT or die "error closing STDOUT: $!"; diff --git a/http/vendor/ring/crypto/fipsmodule/aes/asm/aesni-x86.pl b/http/vendor/ring/crypto/fipsmodule/aes/asm/aesni-x86.pl new file mode 100644 index 0000000..8a7a156 --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/aes/asm/aesni-x86.pl @@ -0,0 +1,973 @@ +#! /usr/bin/env perl +# Copyright 2009-2016 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# ==================================================================== +# Written by Andy Polyakov for the OpenSSL +# project. +# ==================================================================== +# +# This module implements support for Intel AES-NI extension. In +# OpenSSL context it's used with Intel engine, but can also be used as +# drop-in replacement for crypto/aes/asm/aes-586.pl [see below for +# details]. +# +# Performance. +# +# To start with see corresponding paragraph in aesni-x86_64.pl... +# Instead of filling table similar to one found there I've chosen to +# summarize *comparison* results for raw ECB, CTR and CBC benchmarks. +# The simplified table below represents 32-bit performance relative +# to 64-bit one in every given point. Ratios vary for different +# encryption modes, therefore interval values. +# +# 16-byte 64-byte 256-byte 1-KB 8-KB +# 53-67% 67-84% 91-94% 95-98% 97-99.5% +# +# Lower ratios for smaller block sizes are perfectly understandable, +# because function call overhead is higher in 32-bit mode. Largest +# 8-KB block performance is virtually same: 32-bit code is less than +# 1% slower for ECB, CBC and CCM, and ~3% slower otherwise. + +# January 2011 +# +# See aesni-x86_64.pl for details. Unlike x86_64 version this module +# interleaves at most 6 aes[enc|dec] instructions, because there are +# not enough registers for 8x interleave [which should be optimal for +# Sandy Bridge]. Actually, performance results for 6x interleave +# factor presented in aesni-x86_64.pl (except for CTR) are for this +# module. + +# April 2011 +# +# Add aesni_xts_[en|de]crypt. Westmere spends 1.50 cycles processing +# one byte out of 8KB with 128-bit key, Sandy Bridge - 1.09. + +# November 2015 +# +# Add aesni_ocb_[en|de]crypt. [Removed in BoringSSL] + +###################################################################### +# Current large-block performance in cycles per byte processed with +# 128-bit key (less is better). +# +# CBC en-/decrypt CTR XTS ECB OCB +# Westmere 3.77/1.37 1.37 1.52 1.27 +# * Bridge 5.07/0.98 0.99 1.09 0.91 1.10 +# Haswell 4.44/0.80 0.97 1.03 0.72 0.76 +# Skylake 2.68/0.65 0.65 0.66 0.64 0.66 +# Silvermont 5.77/3.56 3.67 4.03 3.46 4.03 +# Goldmont 3.84/1.39 1.39 1.63 1.31 1.70 +# Bulldozer 5.80/0.98 1.05 1.24 0.93 1.23 + +$PREFIX="aes_hw"; # if $PREFIX is set to "AES", the script + # generates drop-in replacement for + # crypto/aes/asm/aes-586.pl:-) +$AESNI_PREFIX="aes_hw"; +$inline=1; # inline _aesni_[en|de]crypt + +$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; +push(@INC,"${dir}","${dir}../../../perlasm"); +require "x86asm.pl"; + +$output = pop; +open OUT,">$output"; +*STDOUT=*OUT; + +&asm_init($ARGV[0]); + +&preprocessor_ifdef("BORINGSSL_DISPATCH_TEST") +&external_label("BORINGSSL_function_hit"); +&preprocessor_endif(); +&static_label("key_const"); + +if ($PREFIX eq $AESNI_PREFIX) { $movekey=\&movups; } +else { $movekey=\&movups; } + +$len="eax"; +$rounds="ecx"; +$key="edx"; +$inp="esi"; +$out="edi"; +$rounds_="ebx"; # backup copy for $rounds +$key_="ebp"; # backup copy for $key + +$rndkey0="xmm0"; +$rndkey1="xmm1"; +$inout0="xmm2"; +$inout1="xmm3"; +$inout2="xmm4"; +$inout3="xmm5"; $in1="xmm5"; +$inout4="xmm6"; $in0="xmm6"; +$inout5="xmm7"; $ivec="xmm7"; + +# AESNI extension +sub aeskeygenassist +{ my($dst,$src,$imm)=@_; + if ("$dst:$src" =~ /xmm([0-7]):xmm([0-7])/) + { &data_byte(0x66,0x0f,0x3a,0xdf,0xc0|($1<<3)|$2,$imm); } +} +sub aescommon +{ my($opcodelet,$dst,$src)=@_; + if ("$dst:$src" =~ /xmm([0-7]):xmm([0-7])/) + { &data_byte(0x66,0x0f,0x38,$opcodelet,0xc0|($1<<3)|$2);} +} +sub aesimc { aescommon(0xdb,@_); } +sub aesenc { aescommon(0xdc,@_); } +sub aesenclast { aescommon(0xdd,@_); } + +# Inline version of internal aesni_[en|de]crypt1 +{ my $sn; +sub aesni_inline_generate1 +{ my ($p,$inout,$ivec)=@_; $inout=$inout0 if (!defined($inout)); + $sn++; + + &$movekey ($rndkey0,&QWP(0,$key)); + &$movekey ($rndkey1,&QWP(16,$key)); + &xorps ($ivec,$rndkey0) if (defined($ivec)); + &lea ($key,&DWP(32,$key)); + &xorps ($inout,$ivec) if (defined($ivec)); + &xorps ($inout,$rndkey0) if (!defined($ivec)); + &set_label("${p}1_loop_$sn"); + eval"&aes${p} ($inout,$rndkey1)"; + &dec ($rounds); + &$movekey ($rndkey1,&QWP(0,$key)); + &lea ($key,&DWP(16,$key)); + &jnz (&label("${p}1_loop_$sn")); + eval"&aes${p}last ($inout,$rndkey1)"; +}} + +sub aesni_generate1 # fully unrolled loop +{ my ($p,$inout)=@_; $inout=$inout0 if (!defined($inout)); + + &function_begin_B("_aesni_${p}rypt1"); + &movups ($rndkey0,&QWP(0,$key)); + &$movekey ($rndkey1,&QWP(0x10,$key)); + &xorps ($inout,$rndkey0); + &$movekey ($rndkey0,&QWP(0x20,$key)); + &lea ($key,&DWP(0x30,$key)); + &cmp ($rounds,11); + &jb (&label("${p}128")); + &lea ($key,&DWP(0x40,$key)); + # 192-bit key support was removed. + eval"&aes${p} ($inout,$rndkey1)"; + &$movekey ($rndkey1,&QWP(-0x40,$key)); + eval"&aes${p} ($inout,$rndkey0)"; + &$movekey ($rndkey0,&QWP(-0x30,$key)); + # 192-bit key support was removed. + eval"&aes${p} ($inout,$rndkey1)"; + &$movekey ($rndkey1,&QWP(-0x20,$key)); + eval"&aes${p} ($inout,$rndkey0)"; + &$movekey ($rndkey0,&QWP(-0x10,$key)); + &set_label("${p}128"); + eval"&aes${p} ($inout,$rndkey1)"; + &$movekey ($rndkey1,&QWP(0,$key)); + eval"&aes${p} ($inout,$rndkey0)"; + &$movekey ($rndkey0,&QWP(0x10,$key)); + eval"&aes${p} ($inout,$rndkey1)"; + &$movekey ($rndkey1,&QWP(0x20,$key)); + eval"&aes${p} ($inout,$rndkey0)"; + &$movekey ($rndkey0,&QWP(0x30,$key)); + eval"&aes${p} ($inout,$rndkey1)"; + &$movekey ($rndkey1,&QWP(0x40,$key)); + eval"&aes${p} ($inout,$rndkey0)"; + &$movekey ($rndkey0,&QWP(0x50,$key)); + eval"&aes${p} ($inout,$rndkey1)"; + &$movekey ($rndkey1,&QWP(0x60,$key)); + eval"&aes${p} ($inout,$rndkey0)"; + &$movekey ($rndkey0,&QWP(0x70,$key)); + eval"&aes${p} ($inout,$rndkey1)"; + eval"&aes${p}last ($inout,$rndkey0)"; + &ret(); + &function_end_B("_aesni_${p}rypt1"); +} + + +# _aesni_[en|de]cryptN are private interfaces, N denotes interleave +# factor. Why 3x subroutine were originally used in loops? Even though +# aes[enc|dec] latency was originally 6, it could be scheduled only +# every *2nd* cycle. Thus 3x interleave was the one providing optimal +# utilization, i.e. when subroutine's throughput is virtually same as +# of non-interleaved subroutine [for number of input blocks up to 3]. +# This is why it originally made no sense to implement 2x subroutine. +# But times change and it became appropriate to spend extra 192 bytes +# on 2x subroutine on Atom Silvermont account. For processors that +# can schedule aes[enc|dec] every cycle optimal interleave factor +# equals to corresponding instructions latency. 8x is optimal for +# * Bridge, but it's unfeasible to accommodate such implementation +# in XMM registers addressable in 32-bit mode and therefore maximum +# of 6x is used instead... + +sub aesni_generate2 +{ my $p=shift; + + &function_begin_B("_aesni_${p}rypt2"); + &$movekey ($rndkey0,&QWP(0,$key)); + &shl ($rounds,4); + &$movekey ($rndkey1,&QWP(16,$key)); + &xorps ($inout0,$rndkey0); + &pxor ($inout1,$rndkey0); + &$movekey ($rndkey0,&QWP(32,$key)); + &lea ($key,&DWP(32,$key,$rounds)); + &neg ($rounds); + &add ($rounds,16); + + &set_label("${p}2_loop"); + eval"&aes${p} ($inout0,$rndkey1)"; + eval"&aes${p} ($inout1,$rndkey1)"; + &$movekey ($rndkey1,&QWP(0,$key,$rounds)); + &add ($rounds,32); + eval"&aes${p} ($inout0,$rndkey0)"; + eval"&aes${p} ($inout1,$rndkey0)"; + &$movekey ($rndkey0,&QWP(-16,$key,$rounds)); + &jnz (&label("${p}2_loop")); + eval"&aes${p} ($inout0,$rndkey1)"; + eval"&aes${p} ($inout1,$rndkey1)"; + eval"&aes${p}last ($inout0,$rndkey0)"; + eval"&aes${p}last ($inout1,$rndkey0)"; + &ret(); + &function_end_B("_aesni_${p}rypt2"); +} + +sub aesni_generate3 +{ my $p=shift; + + &function_begin_B("_aesni_${p}rypt3"); + &$movekey ($rndkey0,&QWP(0,$key)); + &shl ($rounds,4); + &$movekey ($rndkey1,&QWP(16,$key)); + &xorps ($inout0,$rndkey0); + &pxor ($inout1,$rndkey0); + &pxor ($inout2,$rndkey0); + &$movekey ($rndkey0,&QWP(32,$key)); + &lea ($key,&DWP(32,$key,$rounds)); + &neg ($rounds); + &add ($rounds,16); + + &set_label("${p}3_loop"); + eval"&aes${p} ($inout0,$rndkey1)"; + eval"&aes${p} ($inout1,$rndkey1)"; + eval"&aes${p} ($inout2,$rndkey1)"; + &$movekey ($rndkey1,&QWP(0,$key,$rounds)); + &add ($rounds,32); + eval"&aes${p} ($inout0,$rndkey0)"; + eval"&aes${p} ($inout1,$rndkey0)"; + eval"&aes${p} ($inout2,$rndkey0)"; + &$movekey ($rndkey0,&QWP(-16,$key,$rounds)); + &jnz (&label("${p}3_loop")); + eval"&aes${p} ($inout0,$rndkey1)"; + eval"&aes${p} ($inout1,$rndkey1)"; + eval"&aes${p} ($inout2,$rndkey1)"; + eval"&aes${p}last ($inout0,$rndkey0)"; + eval"&aes${p}last ($inout1,$rndkey0)"; + eval"&aes${p}last ($inout2,$rndkey0)"; + &ret(); + &function_end_B("_aesni_${p}rypt3"); +} + +# 4x interleave is implemented to improve small block performance, +# most notably [and naturally] 4 block by ~30%. One can argue that one +# should have implemented 5x as well, but improvement would be <20%, +# so it's not worth it... +sub aesni_generate4 +{ my $p=shift; + + &function_begin_B("_aesni_${p}rypt4"); + &$movekey ($rndkey0,&QWP(0,$key)); + &$movekey ($rndkey1,&QWP(16,$key)); + &shl ($rounds,4); + &xorps ($inout0,$rndkey0); + &pxor ($inout1,$rndkey0); + &pxor ($inout2,$rndkey0); + &pxor ($inout3,$rndkey0); + &$movekey ($rndkey0,&QWP(32,$key)); + &lea ($key,&DWP(32,$key,$rounds)); + &neg ($rounds); + &data_byte (0x0f,0x1f,0x40,0x00); + &add ($rounds,16); + + &set_label("${p}4_loop"); + eval"&aes${p} ($inout0,$rndkey1)"; + eval"&aes${p} ($inout1,$rndkey1)"; + eval"&aes${p} ($inout2,$rndkey1)"; + eval"&aes${p} ($inout3,$rndkey1)"; + &$movekey ($rndkey1,&QWP(0,$key,$rounds)); + &add ($rounds,32); + eval"&aes${p} ($inout0,$rndkey0)"; + eval"&aes${p} ($inout1,$rndkey0)"; + eval"&aes${p} ($inout2,$rndkey0)"; + eval"&aes${p} ($inout3,$rndkey0)"; + &$movekey ($rndkey0,&QWP(-16,$key,$rounds)); + &jnz (&label("${p}4_loop")); + + eval"&aes${p} ($inout0,$rndkey1)"; + eval"&aes${p} ($inout1,$rndkey1)"; + eval"&aes${p} ($inout2,$rndkey1)"; + eval"&aes${p} ($inout3,$rndkey1)"; + eval"&aes${p}last ($inout0,$rndkey0)"; + eval"&aes${p}last ($inout1,$rndkey0)"; + eval"&aes${p}last ($inout2,$rndkey0)"; + eval"&aes${p}last ($inout3,$rndkey0)"; + &ret(); + &function_end_B("_aesni_${p}rypt4"); +} + +sub aesni_generate6 +{ my $p=shift; + + &function_begin_B("_aesni_${p}rypt6"); + &static_label("_aesni_${p}rypt6_enter"); + &$movekey ($rndkey0,&QWP(0,$key)); + &shl ($rounds,4); + &$movekey ($rndkey1,&QWP(16,$key)); + &xorps ($inout0,$rndkey0); + &pxor ($inout1,$rndkey0); # pxor does better here + &pxor ($inout2,$rndkey0); + eval"&aes${p} ($inout0,$rndkey1)"; + &pxor ($inout3,$rndkey0); + &pxor ($inout4,$rndkey0); + eval"&aes${p} ($inout1,$rndkey1)"; + &lea ($key,&DWP(32,$key,$rounds)); + &neg ($rounds); + eval"&aes${p} ($inout2,$rndkey1)"; + &pxor ($inout5,$rndkey0); + &$movekey ($rndkey0,&QWP(0,$key,$rounds)); + &add ($rounds,16); + &jmp (&label("_aesni_${p}rypt6_inner")); + + &set_label("${p}6_loop",16); + eval"&aes${p} ($inout0,$rndkey1)"; + eval"&aes${p} ($inout1,$rndkey1)"; + eval"&aes${p} ($inout2,$rndkey1)"; + &set_label("_aesni_${p}rypt6_inner"); + eval"&aes${p} ($inout3,$rndkey1)"; + eval"&aes${p} ($inout4,$rndkey1)"; + eval"&aes${p} ($inout5,$rndkey1)"; + &set_label("_aesni_${p}rypt6_enter"); + &$movekey ($rndkey1,&QWP(0,$key,$rounds)); + &add ($rounds,32); + eval"&aes${p} ($inout0,$rndkey0)"; + eval"&aes${p} ($inout1,$rndkey0)"; + eval"&aes${p} ($inout2,$rndkey0)"; + eval"&aes${p} ($inout3,$rndkey0)"; + eval"&aes${p} ($inout4,$rndkey0)"; + eval"&aes${p} ($inout5,$rndkey0)"; + &$movekey ($rndkey0,&QWP(-16,$key,$rounds)); + &jnz (&label("${p}6_loop")); + + eval"&aes${p} ($inout0,$rndkey1)"; + eval"&aes${p} ($inout1,$rndkey1)"; + eval"&aes${p} ($inout2,$rndkey1)"; + eval"&aes${p} ($inout3,$rndkey1)"; + eval"&aes${p} ($inout4,$rndkey1)"; + eval"&aes${p} ($inout5,$rndkey1)"; + eval"&aes${p}last ($inout0,$rndkey0)"; + eval"&aes${p}last ($inout1,$rndkey0)"; + eval"&aes${p}last ($inout2,$rndkey0)"; + eval"&aes${p}last ($inout3,$rndkey0)"; + eval"&aes${p}last ($inout4,$rndkey0)"; + eval"&aes${p}last ($inout5,$rndkey0)"; + &ret(); + &function_end_B("_aesni_${p}rypt6"); +} +&aesni_generate2("enc") if ($PREFIX eq $AESNI_PREFIX); +&aesni_generate3("enc") if ($PREFIX eq $AESNI_PREFIX); +&aesni_generate4("enc") if ($PREFIX eq $AESNI_PREFIX); +&aesni_generate6("enc") if ($PREFIX eq $AESNI_PREFIX); + +if ($PREFIX eq $AESNI_PREFIX) { + +###################################################################### +# void aes_hw_ctr32_encrypt_blocks (const void *in, void *out, +# size_t blocks, const AES_KEY *key, +# const char *ivec); +# +# Handles only complete blocks, operates on 32-bit counter and +# does not update *ivec! (see crypto/modes/ctr128.c for details) +# +# stack layout: +# 0 pshufb mask +# 16 vector addend: 0,6,6,6 +# 32 counter-less ivec +# 48 1st triplet of counter vector +# 64 2nd triplet of counter vector +# 80 saved %esp + +&function_begin("${PREFIX}_ctr32_encrypt_blocks"); + &record_function_hit(0); + + &mov ($inp,&wparam(0)); + &mov ($out,&wparam(1)); + &mov ($len,&wparam(2)); + &mov ($key,&wparam(3)); + &mov ($rounds_,&wparam(4)); + &mov ($key_,"esp"); + &sub ("esp",88); + &and ("esp",-16); # align stack + &mov (&DWP(80,"esp"),$key_); + + &cmp ($len,1); + &je (&label("ctr32_one_shortcut")); + + &movdqu ($inout5,&QWP(0,$rounds_)); # load ivec + + # compose byte-swap control mask for pshufb on stack + &mov (&DWP(0,"esp"),0x0c0d0e0f); + &mov (&DWP(4,"esp"),0x08090a0b); + &mov (&DWP(8,"esp"),0x04050607); + &mov (&DWP(12,"esp"),0x00010203); + + # compose counter increment vector on stack + &mov ($rounds,6); + &xor ($key_,$key_); + &mov (&DWP(16,"esp"),$rounds); + &mov (&DWP(20,"esp"),$rounds); + &mov (&DWP(24,"esp"),$rounds); + &mov (&DWP(28,"esp"),$key_); + + &pextrd ($rounds_,$inout5,3); # pull 32-bit counter + &pinsrd ($inout5,$key_,3); # wipe 32-bit counter + + &mov ($rounds,&DWP(240,$key)); # key->rounds + + # compose 2 vectors of 3x32-bit counters + &bswap ($rounds_); + &pxor ($rndkey0,$rndkey0); + &pxor ($rndkey1,$rndkey1); + &movdqa ($inout0,&QWP(0,"esp")); # load byte-swap mask + &pinsrd ($rndkey0,$rounds_,0); + &lea ($key_,&DWP(3,$rounds_)); + &pinsrd ($rndkey1,$key_,0); + &inc ($rounds_); + &pinsrd ($rndkey0,$rounds_,1); + &inc ($key_); + &pinsrd ($rndkey1,$key_,1); + &inc ($rounds_); + &pinsrd ($rndkey0,$rounds_,2); + &inc ($key_); + &pinsrd ($rndkey1,$key_,2); + &movdqa (&QWP(48,"esp"),$rndkey0); # save 1st triplet + &pshufb ($rndkey0,$inout0); # byte swap + &movdqu ($inout4,&QWP(0,$key)); # key[0] + &movdqa (&QWP(64,"esp"),$rndkey1); # save 2nd triplet + &pshufb ($rndkey1,$inout0); # byte swap + + &pshufd ($inout0,$rndkey0,3<<6); # place counter to upper dword + &pshufd ($inout1,$rndkey0,2<<6); + &cmp ($len,6); + &jb (&label("ctr32_tail")); + &pxor ($inout5,$inout4); # counter-less ivec^key[0] + &shl ($rounds,4); + &mov ($rounds_,16); + &movdqa (&QWP(32,"esp"),$inout5); # save counter-less ivec^key[0] + &mov ($key_,$key); # backup $key + &sub ($rounds_,$rounds); # backup twisted $rounds + &lea ($key,&DWP(32,$key,$rounds)); + &sub ($len,6); + &jmp (&label("ctr32_loop6")); + +&set_label("ctr32_loop6",16); + # inlining _aesni_encrypt6's prologue gives ~6% improvement... + &pshufd ($inout2,$rndkey0,1<<6); + &movdqa ($rndkey0,&QWP(32,"esp")); # pull counter-less ivec + &pshufd ($inout3,$rndkey1,3<<6); + &pxor ($inout0,$rndkey0); # merge counter-less ivec + &pshufd ($inout4,$rndkey1,2<<6); + &pxor ($inout1,$rndkey0); + &pshufd ($inout5,$rndkey1,1<<6); + &$movekey ($rndkey1,&QWP(16,$key_)); + &pxor ($inout2,$rndkey0); + &pxor ($inout3,$rndkey0); + &aesenc ($inout0,$rndkey1); + &pxor ($inout4,$rndkey0); + &pxor ($inout5,$rndkey0); + &aesenc ($inout1,$rndkey1); + &$movekey ($rndkey0,&QWP(32,$key_)); + &mov ($rounds,$rounds_); + &aesenc ($inout2,$rndkey1); + &aesenc ($inout3,$rndkey1); + &aesenc ($inout4,$rndkey1); + &aesenc ($inout5,$rndkey1); + + &call (&label("_aesni_encrypt6_enter")); + + &movups ($rndkey1,&QWP(0,$inp)); + &movups ($rndkey0,&QWP(0x10,$inp)); + &xorps ($inout0,$rndkey1); + &movups ($rndkey1,&QWP(0x20,$inp)); + &xorps ($inout1,$rndkey0); + &movups (&QWP(0,$out),$inout0); + &movdqa ($rndkey0,&QWP(16,"esp")); # load increment + &xorps ($inout2,$rndkey1); + &movdqa ($rndkey1,&QWP(64,"esp")); # load 2nd triplet + &movups (&QWP(0x10,$out),$inout1); + &movups (&QWP(0x20,$out),$inout2); + + &paddd ($rndkey1,$rndkey0); # 2nd triplet increment + &paddd ($rndkey0,&QWP(48,"esp")); # 1st triplet increment + &movdqa ($inout0,&QWP(0,"esp")); # load byte swap mask + + &movups ($inout1,&QWP(0x30,$inp)); + &movups ($inout2,&QWP(0x40,$inp)); + &xorps ($inout3,$inout1); + &movups ($inout1,&QWP(0x50,$inp)); + &lea ($inp,&DWP(0x60,$inp)); + &movdqa (&QWP(48,"esp"),$rndkey0); # save 1st triplet + &pshufb ($rndkey0,$inout0); # byte swap + &xorps ($inout4,$inout2); + &movups (&QWP(0x30,$out),$inout3); + &xorps ($inout5,$inout1); + &movdqa (&QWP(64,"esp"),$rndkey1); # save 2nd triplet + &pshufb ($rndkey1,$inout0); # byte swap + &movups (&QWP(0x40,$out),$inout4); + &pshufd ($inout0,$rndkey0,3<<6); + &movups (&QWP(0x50,$out),$inout5); + &lea ($out,&DWP(0x60,$out)); + + &pshufd ($inout1,$rndkey0,2<<6); + &sub ($len,6); + &jnc (&label("ctr32_loop6")); + + &add ($len,6); + &jz (&label("ctr32_ret")); + &movdqu ($inout5,&QWP(0,$key_)); + &mov ($key,$key_); + &pxor ($inout5,&QWP(32,"esp")); # restore count-less ivec + &mov ($rounds,&DWP(240,$key_)); # restore $rounds + +&set_label("ctr32_tail"); + &por ($inout0,$inout5); + &cmp ($len,2); + &jb (&label("ctr32_one")); + + &pshufd ($inout2,$rndkey0,1<<6); + &por ($inout1,$inout5); + &je (&label("ctr32_two")); + + &pshufd ($inout3,$rndkey1,3<<6); + &por ($inout2,$inout5); + &cmp ($len,4); + &jb (&label("ctr32_three")); + + &pshufd ($inout4,$rndkey1,2<<6); + &por ($inout3,$inout5); + &je (&label("ctr32_four")); + + &por ($inout4,$inout5); + &call ("_aesni_encrypt6"); + &movups ($rndkey1,&QWP(0,$inp)); + &movups ($rndkey0,&QWP(0x10,$inp)); + &xorps ($inout0,$rndkey1); + &movups ($rndkey1,&QWP(0x20,$inp)); + &xorps ($inout1,$rndkey0); + &movups ($rndkey0,&QWP(0x30,$inp)); + &xorps ($inout2,$rndkey1); + &movups ($rndkey1,&QWP(0x40,$inp)); + &xorps ($inout3,$rndkey0); + &movups (&QWP(0,$out),$inout0); + &xorps ($inout4,$rndkey1); + &movups (&QWP(0x10,$out),$inout1); + &movups (&QWP(0x20,$out),$inout2); + &movups (&QWP(0x30,$out),$inout3); + &movups (&QWP(0x40,$out),$inout4); + &jmp (&label("ctr32_ret")); + +&set_label("ctr32_one_shortcut",16); + &movups ($inout0,&QWP(0,$rounds_)); # load ivec + &mov ($rounds,&DWP(240,$key)); + +&set_label("ctr32_one"); + if ($inline) + { &aesni_inline_generate1("enc"); } + else + { &call ("_aesni_encrypt1"); } + &movups ($in0,&QWP(0,$inp)); + &xorps ($in0,$inout0); + &movups (&QWP(0,$out),$in0); + &jmp (&label("ctr32_ret")); + +&set_label("ctr32_two",16); + &call ("_aesni_encrypt2"); + &movups ($inout3,&QWP(0,$inp)); + &movups ($inout4,&QWP(0x10,$inp)); + &xorps ($inout0,$inout3); + &xorps ($inout1,$inout4); + &movups (&QWP(0,$out),$inout0); + &movups (&QWP(0x10,$out),$inout1); + &jmp (&label("ctr32_ret")); + +&set_label("ctr32_three",16); + &call ("_aesni_encrypt3"); + &movups ($inout3,&QWP(0,$inp)); + &movups ($inout4,&QWP(0x10,$inp)); + &xorps ($inout0,$inout3); + &movups ($inout5,&QWP(0x20,$inp)); + &xorps ($inout1,$inout4); + &movups (&QWP(0,$out),$inout0); + &xorps ($inout2,$inout5); + &movups (&QWP(0x10,$out),$inout1); + &movups (&QWP(0x20,$out),$inout2); + &jmp (&label("ctr32_ret")); + +&set_label("ctr32_four",16); + &call ("_aesni_encrypt4"); + &movups ($inout4,&QWP(0,$inp)); + &movups ($inout5,&QWP(0x10,$inp)); + &movups ($rndkey1,&QWP(0x20,$inp)); + &xorps ($inout0,$inout4); + &movups ($rndkey0,&QWP(0x30,$inp)); + &xorps ($inout1,$inout5); + &movups (&QWP(0,$out),$inout0); + &xorps ($inout2,$rndkey1); + &movups (&QWP(0x10,$out),$inout1); + &xorps ($inout3,$rndkey0); + &movups (&QWP(0x20,$out),$inout2); + &movups (&QWP(0x30,$out),$inout3); + +&set_label("ctr32_ret"); + &pxor ("xmm0","xmm0"); # clear register bank + &pxor ("xmm1","xmm1"); + &pxor ("xmm2","xmm2"); + &pxor ("xmm3","xmm3"); + &pxor ("xmm4","xmm4"); + &movdqa (&QWP(32,"esp"),"xmm0"); # clear stack + &pxor ("xmm5","xmm5"); + &movdqa (&QWP(48,"esp"),"xmm0"); + &pxor ("xmm6","xmm6"); + &movdqa (&QWP(64,"esp"),"xmm0"); + &pxor ("xmm7","xmm7"); + &mov ("esp",&DWP(80,"esp")); +&function_end("${PREFIX}_ctr32_encrypt_blocks"); +} + +###################################################################### +# Mechanical port from aesni-x86_64.pl. + +# int $PREFIX_set_encrypt_key_base (const unsigned char *userKey, int bits, +# AES_KEY *key) +&function_begin_B("${PREFIX}_set_encrypt_key_base"); + &record_function_hit(3); + + &mov ("eax",&wparam(0)); + &mov ($rounds,&wparam(1)); + &mov ($key,&wparam(2)); + &push ("ebx"); + + &call (&label("pic")); +&set_label("pic"); + &blindpop("ebx"); + &lea ("ebx",&DWP(&label("key_const")."-".&label("pic"),"ebx")); + + &movups ("xmm0",&QWP(0,"eax")); # pull first 128 bits of *userKey + &xorps ("xmm4","xmm4"); # low dword of xmm4 is assumed 0 + &lea ($key,&DWP(16,$key)); + &cmp ($rounds,256); + &je (&label("14rounds")); + # 192-bit key support was removed. + &cmp ($rounds,128); + &jne (&label("bad_keybits")); + +&set_label("10rounds",16); + &mov ($rounds,9); + &$movekey (&QWP(-16,$key),"xmm0"); # round 0 + &aeskeygenassist("xmm1","xmm0",0x01); # round 1 + &call (&label("key_128_cold")); + &aeskeygenassist("xmm1","xmm0",0x2); # round 2 + &call (&label("key_128")); + &aeskeygenassist("xmm1","xmm0",0x04); # round 3 + &call (&label("key_128")); + &aeskeygenassist("xmm1","xmm0",0x08); # round 4 + &call (&label("key_128")); + &aeskeygenassist("xmm1","xmm0",0x10); # round 5 + &call (&label("key_128")); + &aeskeygenassist("xmm1","xmm0",0x20); # round 6 + &call (&label("key_128")); + &aeskeygenassist("xmm1","xmm0",0x40); # round 7 + &call (&label("key_128")); + &aeskeygenassist("xmm1","xmm0",0x80); # round 8 + &call (&label("key_128")); + &aeskeygenassist("xmm1","xmm0",0x1b); # round 9 + &call (&label("key_128")); + &aeskeygenassist("xmm1","xmm0",0x36); # round 10 + &call (&label("key_128")); + &$movekey (&QWP(0,$key),"xmm0"); + &mov (&DWP(80,$key),$rounds); + + &jmp (&label("good_key")); + +&set_label("key_128",16); + &$movekey (&QWP(0,$key),"xmm0"); + &lea ($key,&DWP(16,$key)); +&set_label("key_128_cold"); + &shufps ("xmm4","xmm0",0b00010000); + &xorps ("xmm0","xmm4"); + &shufps ("xmm4","xmm0",0b10001100); + &xorps ("xmm0","xmm4"); + &shufps ("xmm1","xmm1",0b11111111); # critical path + &xorps ("xmm0","xmm1"); + &ret(); + +&set_label("14rounds",16); + &movups ("xmm2",&QWP(16,"eax")); # remaining half of *userKey + &lea ($key,&DWP(16,$key)); + + &mov ($rounds,13); + &$movekey (&QWP(-32,$key),"xmm0"); # round 0 + &$movekey (&QWP(-16,$key),"xmm2"); # round 1 + &aeskeygenassist("xmm1","xmm2",0x01); # round 2 + &call (&label("key_256a_cold")); + &aeskeygenassist("xmm1","xmm0",0x01); # round 3 + &call (&label("key_256b")); + &aeskeygenassist("xmm1","xmm2",0x02); # round 4 + &call (&label("key_256a")); + &aeskeygenassist("xmm1","xmm0",0x02); # round 5 + &call (&label("key_256b")); + &aeskeygenassist("xmm1","xmm2",0x04); # round 6 + &call (&label("key_256a")); + &aeskeygenassist("xmm1","xmm0",0x04); # round 7 + &call (&label("key_256b")); + &aeskeygenassist("xmm1","xmm2",0x08); # round 8 + &call (&label("key_256a")); + &aeskeygenassist("xmm1","xmm0",0x08); # round 9 + &call (&label("key_256b")); + &aeskeygenassist("xmm1","xmm2",0x10); # round 10 + &call (&label("key_256a")); + &aeskeygenassist("xmm1","xmm0",0x10); # round 11 + &call (&label("key_256b")); + &aeskeygenassist("xmm1","xmm2",0x20); # round 12 + &call (&label("key_256a")); + &aeskeygenassist("xmm1","xmm0",0x20); # round 13 + &call (&label("key_256b")); + &aeskeygenassist("xmm1","xmm2",0x40); # round 14 + &call (&label("key_256a")); + &$movekey (&QWP(0,$key),"xmm0"); + &mov (&DWP(16,$key),$rounds); + &xor ("eax","eax"); + + &jmp (&label("good_key")); + +&set_label("key_256a",16); + &$movekey (&QWP(0,$key),"xmm2"); + &lea ($key,&DWP(16,$key)); +&set_label("key_256a_cold"); + &shufps ("xmm4","xmm0",0b00010000); + &xorps ("xmm0","xmm4"); + &shufps ("xmm4","xmm0",0b10001100); + &xorps ("xmm0","xmm4"); + &shufps ("xmm1","xmm1",0b11111111); # critical path + &xorps ("xmm0","xmm1"); + &ret(); + +&set_label("key_256b",16); + &$movekey (&QWP(0,$key),"xmm0"); + &lea ($key,&DWP(16,$key)); + + &shufps ("xmm4","xmm2",0b00010000); + &xorps ("xmm2","xmm4"); + &shufps ("xmm4","xmm2",0b10001100); + &xorps ("xmm2","xmm4"); + &shufps ("xmm1","xmm1",0b10101010); # critical path + &xorps ("xmm2","xmm1"); + &ret(); + +&set_label("good_key"); + &pxor ("xmm0","xmm0"); + &pxor ("xmm1","xmm1"); + &pxor ("xmm2","xmm2"); + &pxor ("xmm3","xmm3"); + &pxor ("xmm4","xmm4"); + &pxor ("xmm5","xmm5"); + &xor ("eax","eax"); + &pop ("ebx"); + &ret (); + +&set_label("bad_keybits",4); + &pxor ("xmm0","xmm0"); + &mov ("eax",-2); + &pop ("ebx"); + &ret (); +&function_end_B("${PREFIX}_set_encrypt_key_base"); + +# int $PREFIX_set_encrypt_key_alt (const unsigned char *userKey, int bits, +# AES_KEY *key) +&function_begin_B("${PREFIX}_set_encrypt_key_alt"); + &record_function_hit(3); + + &mov ("eax",&wparam(0)); + &mov ($rounds,&wparam(1)); + &mov ($key,&wparam(2)); + &push ("ebx"); + + &call (&label("pic")); +&set_label("pic"); + &blindpop("ebx"); + &lea ("ebx",&DWP(&label("key_const")."-".&label("pic"),"ebx")); + + &movups ("xmm0",&QWP(0,"eax")); # pull first 128 bits of *userKey + &xorps ("xmm4","xmm4"); # low dword of xmm4 is assumed 0 + &lea ($key,&DWP(16,$key)); + &cmp ($rounds,256); + &je (&label("14rounds_alt")); + # 192-bit key support was removed. + &cmp ($rounds,128); + &jne (&label("bad_keybits")); + +&set_label("10rounds_alt",16); + &movdqa ("xmm5",&QWP(0x00,"ebx")); + &mov ($rounds,8); + &movdqa ("xmm4",&QWP(0x20,"ebx")); + &movdqa ("xmm2","xmm0"); + &movdqu (&QWP(-16,$key),"xmm0"); + +&set_label("loop_key128"); + &pshufb ("xmm0","xmm5"); + &aesenclast ("xmm0","xmm4"); + &pslld ("xmm4",1); + &lea ($key,&DWP(16,$key)); + + &movdqa ("xmm3","xmm2"); + &pslldq ("xmm2",4); + &pxor ("xmm3","xmm2"); + &pslldq ("xmm2",4); + &pxor ("xmm3","xmm2"); + &pslldq ("xmm2",4); + &pxor ("xmm2","xmm3"); + + &pxor ("xmm0","xmm2"); + &movdqu (&QWP(-16,$key),"xmm0"); + &movdqa ("xmm2","xmm0"); + + &dec ($rounds); + &jnz (&label("loop_key128")); + + &movdqa ("xmm4",&QWP(0x30,"ebx")); + + &pshufb ("xmm0","xmm5"); + &aesenclast ("xmm0","xmm4"); + &pslld ("xmm4",1); + + &movdqa ("xmm3","xmm2"); + &pslldq ("xmm2",4); + &pxor ("xmm3","xmm2"); + &pslldq ("xmm2",4); + &pxor ("xmm3","xmm2"); + &pslldq ("xmm2",4); + &pxor ("xmm2","xmm3"); + + &pxor ("xmm0","xmm2"); + &movdqu (&QWP(0,$key),"xmm0"); + + &movdqa ("xmm2","xmm0"); + &pshufb ("xmm0","xmm5"); + &aesenclast ("xmm0","xmm4"); + + &movdqa ("xmm3","xmm2"); + &pslldq ("xmm2",4); + &pxor ("xmm3","xmm2"); + &pslldq ("xmm2",4); + &pxor ("xmm3","xmm2"); + &pslldq ("xmm2",4); + &pxor ("xmm2","xmm3"); + + &pxor ("xmm0","xmm2"); + &movdqu (&QWP(16,$key),"xmm0"); + + &mov ($rounds,9); + &mov (&DWP(96,$key),$rounds); + + &jmp (&label("good_key")); + + # 192-bit key support was removed. + +&set_label("14rounds_alt",16); + &movups ("xmm2",&QWP(16,"eax")); # remaining half of *userKey + &lea ($key,&DWP(16,$key)); + &movdqa ("xmm5",&QWP(0x00,"ebx")); + &movdqa ("xmm4",&QWP(0x20,"ebx")); + &mov ($rounds,7); + &movdqu (&QWP(-32,$key),"xmm0"); + &movdqa ("xmm1","xmm2"); + &movdqu (&QWP(-16,$key),"xmm2"); + +&set_label("loop_key256"); + &pshufb ("xmm2","xmm5"); + &aesenclast ("xmm2","xmm4"); + + &movdqa ("xmm3","xmm0"); + &pslldq ("xmm0",4); + &pxor ("xmm3","xmm0"); + &pslldq ("xmm0",4); + &pxor ("xmm3","xmm0"); + &pslldq ("xmm0",4); + &pxor ("xmm0","xmm3"); + &pslld ("xmm4",1); + + &pxor ("xmm0","xmm2"); + &movdqu (&QWP(0,$key),"xmm0"); + + &dec ($rounds); + &jz (&label("done_key256")); + + &pshufd ("xmm2","xmm0",0xff); + &pxor ("xmm3","xmm3"); + &aesenclast ("xmm2","xmm3"); + + &movdqa ("xmm3","xmm1"); + &pslldq ("xmm1",4); + &pxor ("xmm3","xmm1"); + &pslldq ("xmm1",4); + &pxor ("xmm3","xmm1"); + &pslldq ("xmm1",4); + &pxor ("xmm1","xmm3"); + + &pxor ("xmm2","xmm1"); + &movdqu (&QWP(16,$key),"xmm2"); + &lea ($key,&DWP(32,$key)); + &movdqa ("xmm1","xmm2"); + &jmp (&label("loop_key256")); + +&set_label("done_key256"); + &mov ($rounds,13); + &mov (&DWP(16,$key),$rounds); + +&set_label("good_key"); + &pxor ("xmm0","xmm0"); + &pxor ("xmm1","xmm1"); + &pxor ("xmm2","xmm2"); + &pxor ("xmm3","xmm3"); + &pxor ("xmm4","xmm4"); + &pxor ("xmm5","xmm5"); + &xor ("eax","eax"); + &pop ("ebx"); + &ret (); + +&set_label("bad_keybits",4); + &pxor ("xmm0","xmm0"); + &mov ("eax",-2); + &pop ("ebx"); + &ret (); +&function_end_B("${PREFIX}_set_encrypt_key_alt"); + + +&set_label("key_const",64); +&data_word(0x0c0f0e0d,0x0c0f0e0d,0x0c0f0e0d,0x0c0f0e0d); +&data_word(0x04070605,0x04070605,0x04070605,0x04070605); +&data_word(1,1,1,1); +&data_word(0x1b,0x1b,0x1b,0x1b); +&asciz("AES for Intel AES-NI, CRYPTOGAMS by "); + +&asm_finish(); + +close STDOUT or die "error closing STDOUT: $!"; diff --git a/http/vendor/ring/crypto/fipsmodule/aes/asm/aesni-x86_64.pl b/http/vendor/ring/crypto/fipsmodule/aes/asm/aesni-x86_64.pl new file mode 100644 index 0000000..94fd3a9 --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/aes/asm/aesni-x86_64.pl @@ -0,0 +1,1600 @@ +#! /usr/bin/env perl +# Copyright 2009-2016 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# ==================================================================== +# Written by Andy Polyakov for the OpenSSL +# project. +# ==================================================================== +# +# This module implements support for Intel AES-NI extension. In +# OpenSSL context it's used with Intel engine, but can also be used as +# drop-in replacement for crypto/aes/asm/aes-x86_64.pl [see below for +# details]. +# +# Performance. +# +# Given aes(enc|dec) instructions' latency asymptotic performance for +# non-parallelizable modes such as CBC encrypt is 3.75 cycles per byte +# processed with 128-bit key. And given their throughput asymptotic +# performance for parallelizable modes is 1.25 cycles per byte. Being +# asymptotic limit it's not something you commonly achieve in reality, +# but how close does one get? Below are results collected for +# different modes and block sized. Pairs of numbers are for en-/ +# decryption. +# +# 16-byte 64-byte 256-byte 1-KB 8-KB +# ECB 4.25/4.25 1.38/1.38 1.28/1.28 1.26/1.26 1.26/1.26 +# CTR 5.42/5.42 1.92/1.92 1.44/1.44 1.28/1.28 1.26/1.26 +# CBC 4.38/4.43 4.15/1.43 4.07/1.32 4.07/1.29 4.06/1.28 +# CCM 5.66/9.42 4.42/5.41 4.16/4.40 4.09/4.15 4.06/4.07 +# OFB 5.42/5.42 4.64/4.64 4.44/4.44 4.39/4.39 4.38/4.38 +# CFB 5.73/5.85 5.56/5.62 5.48/5.56 5.47/5.55 5.47/5.55 +# +# ECB, CTR, CBC and CCM results are free from EVP overhead. This means +# that otherwise used 'openssl speed -evp aes-128-??? -engine aesni +# [-decrypt]' will exhibit 10-15% worse results for smaller blocks. +# The results were collected with specially crafted speed.c benchmark +# in order to compare them with results reported in "Intel Advanced +# Encryption Standard (AES) New Instruction Set" White Paper Revision +# 3.0 dated May 2010. All above results are consistently better. This +# module also provides better performance for block sizes smaller than +# 128 bytes in points *not* represented in the above table. +# +# Looking at the results for 8-KB buffer. +# +# CFB and OFB results are far from the limit, because implementation +# uses "generic" CRYPTO_[c|o]fb128_encrypt interfaces relying on +# single-block aesni_encrypt, which is not the most optimal way to go. +# CBC encrypt result is unexpectedly high and there is no documented +# explanation for it. Seemingly there is a small penalty for feeding +# the result back to AES unit the way it's done in CBC mode. There is +# nothing one can do and the result appears optimal. CCM result is +# identical to CBC, because CBC-MAC is essentially CBC encrypt without +# saving output. CCM CTR "stays invisible," because it's neatly +# interleaved wih CBC-MAC. This provides ~30% improvement over +# "straightforward" CCM implementation with CTR and CBC-MAC performed +# disjointly. Parallelizable modes practically achieve the theoretical +# limit. +# +# Looking at how results vary with buffer size. +# +# Curves are practically saturated at 1-KB buffer size. In most cases +# "256-byte" performance is >95%, and "64-byte" is ~90% of "8-KB" one. +# CTR curve doesn't follow this pattern and is "slowest" changing one +# with "256-byte" result being 87% of "8-KB." This is because overhead +# in CTR mode is most computationally intensive. Small-block CCM +# decrypt is slower than encrypt, because first CTR and last CBC-MAC +# iterations can't be interleaved. +# +# Results for 192- and 256-bit keys. +# +# EVP-free results were observed to scale perfectly with number of +# rounds for larger block sizes, i.e. 192-bit result being 10/12 times +# lower and 256-bit one - 10/14. Well, in CBC encrypt case differences +# are a tad smaller, because the above mentioned penalty biases all +# results by same constant value. In similar way function call +# overhead affects small-block performance, as well as OFB and CFB +# results. Differences are not large, most common coefficients are +# 10/11.7 and 10/13.4 (as opposite to 10/12.0 and 10/14.0), but one +# observe even 10/11.2 and 10/12.4 (CTR, OFB, CFB)... + +# January 2011 +# +# While Westmere processor features 6 cycles latency for aes[enc|dec] +# instructions, which can be scheduled every second cycle, Sandy +# Bridge spends 8 cycles per instruction, but it can schedule them +# every cycle. This means that code targeting Westmere would perform +# suboptimally on Sandy Bridge. Therefore this update. +# +# In addition, non-parallelizable CBC encrypt (as well as CCM) is +# optimized. Relative improvement might appear modest, 8% on Westmere, +# but in absolute terms it's 3.77 cycles per byte encrypted with +# 128-bit key on Westmere, and 5.07 - on Sandy Bridge. These numbers +# should be compared to asymptotic limits of 3.75 for Westmere and +# 5.00 for Sandy Bridge. Actually, the fact that they get this close +# to asymptotic limits is quite amazing. Indeed, the limit is +# calculated as latency times number of rounds, 10 for 128-bit key, +# and divided by 16, the number of bytes in block, or in other words +# it accounts *solely* for aesenc instructions. But there are extra +# instructions, and numbers so close to the asymptotic limits mean +# that it's as if it takes as little as *one* additional cycle to +# execute all of them. How is it possible? It is possible thanks to +# out-of-order execution logic, which manages to overlap post- +# processing of previous block, things like saving the output, with +# actual encryption of current block, as well as pre-processing of +# current block, things like fetching input and xor-ing it with +# 0-round element of the key schedule, with actual encryption of +# previous block. Keep this in mind... +# +# For parallelizable modes, such as ECB, CBC decrypt, CTR, higher +# performance is achieved by interleaving instructions working on +# independent blocks. In which case asymptotic limit for such modes +# can be obtained by dividing above mentioned numbers by AES +# instructions' interleave factor. Westmere can execute at most 3 +# instructions at a time, meaning that optimal interleave factor is 3, +# and that's where the "magic" number of 1.25 come from. "Optimal +# interleave factor" means that increase of interleave factor does +# not improve performance. The formula has proven to reflect reality +# pretty well on Westmere... Sandy Bridge on the other hand can +# execute up to 8 AES instructions at a time, so how does varying +# interleave factor affect the performance? Here is table for ECB +# (numbers are cycles per byte processed with 128-bit key): +# +# instruction interleave factor 3x 6x 8x +# theoretical asymptotic limit 1.67 0.83 0.625 +# measured performance for 8KB block 1.05 0.86 0.84 +# +# "as if" interleave factor 4.7x 5.8x 6.0x +# +# Further data for other parallelizable modes: +# +# CBC decrypt 1.16 0.93 0.74 +# CTR 1.14 0.91 0.74 +# +# Well, given 3x column it's probably inappropriate to call the limit +# asymptotic, if it can be surpassed, isn't it? What happens there? +# Rewind to CBC paragraph for the answer. Yes, out-of-order execution +# magic is responsible for this. Processor overlaps not only the +# additional instructions with AES ones, but even AES instructions +# processing adjacent triplets of independent blocks. In the 6x case +# additional instructions still claim disproportionally small amount +# of additional cycles, but in 8x case number of instructions must be +# a tad too high for out-of-order logic to cope with, and AES unit +# remains underutilized... As you can see 8x interleave is hardly +# justifiable, so there no need to feel bad that 32-bit aesni-x86.pl +# utilizes 6x interleave because of limited register bank capacity. +# +# Higher interleave factors do have negative impact on Westmere +# performance. While for ECB mode it's negligible ~1.5%, other +# parallelizables perform ~5% worse, which is outweighed by ~25% +# improvement on Sandy Bridge. To balance regression on Westmere +# CTR mode was implemented with 6x aesenc interleave factor. + +# April 2011 +# +# Add aesni_xts_[en|de]crypt. Westmere spends 1.25 cycles processing +# one byte out of 8KB with 128-bit key, Sandy Bridge - 0.90. Just like +# in CTR mode AES instruction interleave factor was chosen to be 6x. + +###################################################################### +# Current large-block performance in cycles per byte processed with +# 128-bit key (less is better). +# +# CBC en-/decrypt CTR XTS ECB OCB +# Westmere 3.77/1.25 1.25 1.25 1.26 +# * Bridge 5.07/0.74 0.75 0.90 0.85 0.98 +# Haswell 4.44/0.63 0.63 0.73 0.63 0.70 +# Skylake 2.62/0.63 0.63 0.63 0.63 +# Silvermont 5.75/3.54 3.56 4.12 3.87(*) 4.11 +# Knights L 2.54/0.77 0.78 0.85 - 1.50 +# Goldmont 3.82/1.26 1.26 1.29 1.29 1.50 +# Bulldozer 5.77/0.70 0.72 0.90 0.70 0.95 +# Ryzen 2.71/0.35 0.35 0.44 0.38 0.49 +# +# (*) Atom Silvermont ECB result is suboptimal because of penalties +# incurred by operations on %xmm8-15. As ECB is not considered +# critical, nothing was done to mitigate the problem. + +$PREFIX="aes_hw"; # if $PREFIX is set to "AES", the script + # generates drop-in replacement for + # crypto/aes/asm/aes-x86_64.pl:-) + +$flavour = shift; +$output = shift; +if ($flavour =~ /\./) { $output = $flavour; undef $flavour; } + +$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/); + +$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; +( $xlate="${dir}x86_64-xlate.pl" and -f $xlate ) or +( $xlate="${dir}../../../perlasm/x86_64-xlate.pl" and -f $xlate) or +die "can't locate x86_64-xlate.pl"; + +open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""; +*STDOUT=*OUT; + +$movkey = $PREFIX eq "aes_hw" ? "movups" : "movups"; +@_4args=$win64? ("%rcx","%rdx","%r8", "%r9") : # Win64 order + ("%rdi","%rsi","%rdx","%rcx"); # Unix order + +$code=".text\n"; + +$rounds="%eax"; # input to and changed by aesni_[en|de]cryptN !!! +# this is natural Unix argument order for public $PREFIX_[ecb|cbc]_encrypt ... +$inp="%rdi"; +$out="%rsi"; +$len="%rdx"; +$key="%rcx"; # input to and changed by aesni_[en|de]cryptN !!! +$ivp="%r8"; # cbc, ctr, ... + +$rnds_="%r10d"; # backup copy for $rounds +$key_="%r11"; # backup copy for $key + +# %xmm register layout +$rndkey0="%xmm0"; $rndkey1="%xmm1"; +$inout0="%xmm2"; $inout1="%xmm3"; +$inout2="%xmm4"; $inout3="%xmm5"; +$inout4="%xmm6"; $inout5="%xmm7"; +$inout6="%xmm8"; $inout7="%xmm9"; + +$in2="%xmm6"; $in1="%xmm7"; # used in CBC decrypt, CTR, ... +$in0="%xmm8"; $iv="%xmm9"; + +# Inline version of internal aesni_[en|de]crypt1. +# +# Why folded loop? Because aes[enc|dec] is slow enough to accommodate +# cycles which take care of loop variables... +{ my $sn; +sub aesni_generate1 { +my ($p,$key,$rounds,$inout,$ivec)=@_; $inout=$inout0 if (!defined($inout)); +++$sn; +$code.=<<___; + $movkey ($key),$rndkey0 + $movkey 16($key),$rndkey1 +___ +$code.=<<___ if (defined($ivec)); + xorps $rndkey0,$ivec + lea 32($key),$key + xorps $ivec,$inout +___ +$code.=<<___ if (!defined($ivec)); + lea 32($key),$key + xorps $rndkey0,$inout +___ +$code.=<<___; +.Loop_${p}1_$sn: + aes${p} $rndkey1,$inout + dec $rounds + $movkey ($key),$rndkey1 + lea 16($key),$key + jnz .Loop_${p}1_$sn # loop body is 16 bytes + aes${p}last $rndkey1,$inout +___ +}} + +# _aesni_[en|de]cryptN are private interfaces, N denotes interleave +# factor. Why 3x subroutine were originally used in loops? Even though +# aes[enc|dec] latency was originally 6, it could be scheduled only +# every *2nd* cycle. Thus 3x interleave was the one providing optimal +# utilization, i.e. when subroutine's throughput is virtually same as +# of non-interleaved subroutine [for number of input blocks up to 3]. +# This is why it originally made no sense to implement 2x subroutine. +# But times change and it became appropriate to spend extra 192 bytes +# on 2x subroutine on Atom Silvermont account. For processors that +# can schedule aes[enc|dec] every cycle optimal interleave factor +# equals to corresponding instructions latency. 8x is optimal for +# * Bridge and "super-optimal" for other Intel CPUs... + +sub aesni_generate2 { +my $dir=shift; +# As already mentioned it takes in $key and $rounds, which are *not* +# preserved. $inout[0-1] is cipher/clear text... +$code.=<<___; +.type _aesni_${dir}rypt2,\@abi-omnipotent +.align 16 +_aesni_${dir}rypt2: +.cfi_startproc + $movkey ($key),$rndkey0 + shl \$4,$rounds + $movkey 16($key),$rndkey1 + xorps $rndkey0,$inout0 + xorps $rndkey0,$inout1 + $movkey 32($key),$rndkey0 + lea 32($key,$rounds),$key + neg %rax # $rounds + add \$16,%rax + +.L${dir}_loop2: + aes${dir} $rndkey1,$inout0 + aes${dir} $rndkey1,$inout1 + $movkey ($key,%rax),$rndkey1 + add \$32,%rax + aes${dir} $rndkey0,$inout0 + aes${dir} $rndkey0,$inout1 + $movkey -16($key,%rax),$rndkey0 + jnz .L${dir}_loop2 + + aes${dir} $rndkey1,$inout0 + aes${dir} $rndkey1,$inout1 + aes${dir}last $rndkey0,$inout0 + aes${dir}last $rndkey0,$inout1 + ret +.cfi_endproc +.size _aesni_${dir}rypt2,.-_aesni_${dir}rypt2 +___ +} +sub aesni_generate3 { +my $dir=shift; +# As already mentioned it takes in $key and $rounds, which are *not* +# preserved. $inout[0-2] is cipher/clear text... +$code.=<<___; +.type _aesni_${dir}rypt3,\@abi-omnipotent +.align 16 +_aesni_${dir}rypt3: +.cfi_startproc + $movkey ($key),$rndkey0 + shl \$4,$rounds + $movkey 16($key),$rndkey1 + xorps $rndkey0,$inout0 + xorps $rndkey0,$inout1 + xorps $rndkey0,$inout2 + $movkey 32($key),$rndkey0 + lea 32($key,$rounds),$key + neg %rax # $rounds + add \$16,%rax + +.L${dir}_loop3: + aes${dir} $rndkey1,$inout0 + aes${dir} $rndkey1,$inout1 + aes${dir} $rndkey1,$inout2 + $movkey ($key,%rax),$rndkey1 + add \$32,%rax + aes${dir} $rndkey0,$inout0 + aes${dir} $rndkey0,$inout1 + aes${dir} $rndkey0,$inout2 + $movkey -16($key,%rax),$rndkey0 + jnz .L${dir}_loop3 + + aes${dir} $rndkey1,$inout0 + aes${dir} $rndkey1,$inout1 + aes${dir} $rndkey1,$inout2 + aes${dir}last $rndkey0,$inout0 + aes${dir}last $rndkey0,$inout1 + aes${dir}last $rndkey0,$inout2 + ret +.cfi_endproc +.size _aesni_${dir}rypt3,.-_aesni_${dir}rypt3 +___ +} +# 4x interleave is implemented to improve small block performance, +# most notably [and naturally] 4 block by ~30%. One can argue that one +# should have implemented 5x as well, but improvement would be <20%, +# so it's not worth it... +sub aesni_generate4 { +my $dir=shift; +# As already mentioned it takes in $key and $rounds, which are *not* +# preserved. $inout[0-3] is cipher/clear text... +$code.=<<___; +.type _aesni_${dir}rypt4,\@abi-omnipotent +.align 16 +_aesni_${dir}rypt4: +.cfi_startproc + $movkey ($key),$rndkey0 + shl \$4,$rounds + $movkey 16($key),$rndkey1 + xorps $rndkey0,$inout0 + xorps $rndkey0,$inout1 + xorps $rndkey0,$inout2 + xorps $rndkey0,$inout3 + $movkey 32($key),$rndkey0 + lea 32($key,$rounds),$key + neg %rax # $rounds + .byte 0x0f,0x1f,0x00 + add \$16,%rax + +.L${dir}_loop4: + aes${dir} $rndkey1,$inout0 + aes${dir} $rndkey1,$inout1 + aes${dir} $rndkey1,$inout2 + aes${dir} $rndkey1,$inout3 + $movkey ($key,%rax),$rndkey1 + add \$32,%rax + aes${dir} $rndkey0,$inout0 + aes${dir} $rndkey0,$inout1 + aes${dir} $rndkey0,$inout2 + aes${dir} $rndkey0,$inout3 + $movkey -16($key,%rax),$rndkey0 + jnz .L${dir}_loop4 + + aes${dir} $rndkey1,$inout0 + aes${dir} $rndkey1,$inout1 + aes${dir} $rndkey1,$inout2 + aes${dir} $rndkey1,$inout3 + aes${dir}last $rndkey0,$inout0 + aes${dir}last $rndkey0,$inout1 + aes${dir}last $rndkey0,$inout2 + aes${dir}last $rndkey0,$inout3 + ret +.cfi_endproc +.size _aesni_${dir}rypt4,.-_aesni_${dir}rypt4 +___ +} +sub aesni_generate6 { +my $dir=shift; +# As already mentioned it takes in $key and $rounds, which are *not* +# preserved. $inout[0-5] is cipher/clear text... +$code.=<<___; +.type _aesni_${dir}rypt6,\@abi-omnipotent +.align 16 +_aesni_${dir}rypt6: +.cfi_startproc + $movkey ($key),$rndkey0 + shl \$4,$rounds + $movkey 16($key),$rndkey1 + xorps $rndkey0,$inout0 + pxor $rndkey0,$inout1 + pxor $rndkey0,$inout2 + aes${dir} $rndkey1,$inout0 + lea 32($key,$rounds),$key + neg %rax # $rounds + aes${dir} $rndkey1,$inout1 + pxor $rndkey0,$inout3 + pxor $rndkey0,$inout4 + aes${dir} $rndkey1,$inout2 + pxor $rndkey0,$inout5 + $movkey ($key,%rax),$rndkey0 + add \$16,%rax + jmp .L${dir}_loop6_enter +.align 16 +.L${dir}_loop6: + aes${dir} $rndkey1,$inout0 + aes${dir} $rndkey1,$inout1 + aes${dir} $rndkey1,$inout2 +.L${dir}_loop6_enter: + aes${dir} $rndkey1,$inout3 + aes${dir} $rndkey1,$inout4 + aes${dir} $rndkey1,$inout5 + $movkey ($key,%rax),$rndkey1 + add \$32,%rax + aes${dir} $rndkey0,$inout0 + aes${dir} $rndkey0,$inout1 + aes${dir} $rndkey0,$inout2 + aes${dir} $rndkey0,$inout3 + aes${dir} $rndkey0,$inout4 + aes${dir} $rndkey0,$inout5 + $movkey -16($key,%rax),$rndkey0 + jnz .L${dir}_loop6 + + aes${dir} $rndkey1,$inout0 + aes${dir} $rndkey1,$inout1 + aes${dir} $rndkey1,$inout2 + aes${dir} $rndkey1,$inout3 + aes${dir} $rndkey1,$inout4 + aes${dir} $rndkey1,$inout5 + aes${dir}last $rndkey0,$inout0 + aes${dir}last $rndkey0,$inout1 + aes${dir}last $rndkey0,$inout2 + aes${dir}last $rndkey0,$inout3 + aes${dir}last $rndkey0,$inout4 + aes${dir}last $rndkey0,$inout5 + ret +.cfi_endproc +.size _aesni_${dir}rypt6,.-_aesni_${dir}rypt6 +___ +} +sub aesni_generate8 { +my $dir=shift; +# As already mentioned it takes in $key and $rounds, which are *not* +# preserved. $inout[0-7] is cipher/clear text... +$code.=<<___; +.type _aesni_${dir}rypt8,\@abi-omnipotent +.align 16 +_aesni_${dir}rypt8: +.cfi_startproc + $movkey ($key),$rndkey0 + shl \$4,$rounds + $movkey 16($key),$rndkey1 + xorps $rndkey0,$inout0 + xorps $rndkey0,$inout1 + pxor $rndkey0,$inout2 + pxor $rndkey0,$inout3 + pxor $rndkey0,$inout4 + lea 32($key,$rounds),$key + neg %rax # $rounds + aes${dir} $rndkey1,$inout0 + pxor $rndkey0,$inout5 + pxor $rndkey0,$inout6 + aes${dir} $rndkey1,$inout1 + pxor $rndkey0,$inout7 + $movkey ($key,%rax),$rndkey0 + add \$16,%rax + jmp .L${dir}_loop8_inner +.align 16 +.L${dir}_loop8: + aes${dir} $rndkey1,$inout0 + aes${dir} $rndkey1,$inout1 +.L${dir}_loop8_inner: + aes${dir} $rndkey1,$inout2 + aes${dir} $rndkey1,$inout3 + aes${dir} $rndkey1,$inout4 + aes${dir} $rndkey1,$inout5 + aes${dir} $rndkey1,$inout6 + aes${dir} $rndkey1,$inout7 +.L${dir}_loop8_enter: + $movkey ($key,%rax),$rndkey1 + add \$32,%rax + aes${dir} $rndkey0,$inout0 + aes${dir} $rndkey0,$inout1 + aes${dir} $rndkey0,$inout2 + aes${dir} $rndkey0,$inout3 + aes${dir} $rndkey0,$inout4 + aes${dir} $rndkey0,$inout5 + aes${dir} $rndkey0,$inout6 + aes${dir} $rndkey0,$inout7 + $movkey -16($key,%rax),$rndkey0 + jnz .L${dir}_loop8 + + aes${dir} $rndkey1,$inout0 + aes${dir} $rndkey1,$inout1 + aes${dir} $rndkey1,$inout2 + aes${dir} $rndkey1,$inout3 + aes${dir} $rndkey1,$inout4 + aes${dir} $rndkey1,$inout5 + aes${dir} $rndkey1,$inout6 + aes${dir} $rndkey1,$inout7 + aes${dir}last $rndkey0,$inout0 + aes${dir}last $rndkey0,$inout1 + aes${dir}last $rndkey0,$inout2 + aes${dir}last $rndkey0,$inout3 + aes${dir}last $rndkey0,$inout4 + aes${dir}last $rndkey0,$inout5 + aes${dir}last $rndkey0,$inout6 + aes${dir}last $rndkey0,$inout7 + ret +.cfi_endproc +.size _aesni_${dir}rypt8,.-_aesni_${dir}rypt8 +___ +} +&aesni_generate2("enc") if ($PREFIX eq "aes_hw"); +&aesni_generate3("enc") if ($PREFIX eq "aes_hw"); +&aesni_generate4("enc") if ($PREFIX eq "aes_hw"); +&aesni_generate6("enc") if ($PREFIX eq "aes_hw"); +&aesni_generate8("enc") if ($PREFIX eq "aes_hw"); + +if ($PREFIX eq "aes_hw") { +{ +###################################################################### +# void aesni_ctr32_encrypt_blocks (const void *in, void *out, +# size_t blocks, const AES_KEY *key, +# const char *ivec); +# +# Handles only complete blocks, operates on 32-bit counter and +# does not update *ivec! (see crypto/modes/ctr128.c for details) +# +# Overhaul based on suggestions from Shay Gueron and Vlad Krasnov, +# http://rt.openssl.org/Ticket/Display.html?id=3021&user=guest&pass=guest. +# Keywords are full unroll and modulo-schedule counter calculations +# with zero-round key xor. +{ +my ($in0,$in1,$in2,$in3,$in4,$in5)=map("%xmm$_",(10..15)); +my ($key0,$ctr)=("%ebp","${ivp}d"); +my $frame_size = 0x80 + ($win64?160:0); + +$code.=<<___; +.globl ${PREFIX}_ctr32_encrypt_blocks +.type ${PREFIX}_ctr32_encrypt_blocks,\@function,5 +.align 16 +${PREFIX}_ctr32_encrypt_blocks: +.cfi_startproc + _CET_ENDBR +#ifdef BORINGSSL_DISPATCH_TEST + movb \$1,BORINGSSL_function_hit(%rip) +#endif + cmp \$1,$len + jne .Lctr32_bulk + + # handle single block without allocating stack frame, + # useful when handling edges + movups ($ivp),$inout0 + movups ($inp),$inout1 + mov 240($key),%edx # key->rounds +___ + &aesni_generate1("enc",$key,"%edx"); +$code.=<<___; + pxor $rndkey0,$rndkey0 # clear register bank + pxor $rndkey1,$rndkey1 + xorps $inout1,$inout0 + pxor $inout1,$inout1 + movups $inout0,($out) + xorps $inout0,$inout0 + jmp .Lctr32_epilogue + +.align 16 +.Lctr32_bulk: + lea (%rsp),$key_ # use $key_ as frame pointer +.cfi_def_cfa_register $key_ + push %rbp +.cfi_push %rbp + sub \$$frame_size,%rsp + and \$-16,%rsp # Linux kernel stack can be incorrectly seeded +___ +$code.=<<___ if ($win64); + movaps %xmm6,-0xa8($key_) # offload everything + movaps %xmm7,-0x98($key_) + movaps %xmm8,-0x88($key_) + movaps %xmm9,-0x78($key_) + movaps %xmm10,-0x68($key_) + movaps %xmm11,-0x58($key_) + movaps %xmm12,-0x48($key_) + movaps %xmm13,-0x38($key_) + movaps %xmm14,-0x28($key_) + movaps %xmm15,-0x18($key_) +.Lctr32_body: +___ +$code.=<<___; + + # 8 16-byte words on top of stack are counter values + # xor-ed with zero-round key + + movdqu ($ivp),$inout0 + movdqu ($key),$rndkey0 + mov 12($ivp),$ctr # counter LSB + pxor $rndkey0,$inout0 + mov 12($key),$key0 # 0-round key LSB + movdqa $inout0,0x00(%rsp) # populate counter block + bswap $ctr + movdqa $inout0,$inout1 + movdqa $inout0,$inout2 + movdqa $inout0,$inout3 + movdqa $inout0,0x40(%rsp) + movdqa $inout0,0x50(%rsp) + movdqa $inout0,0x60(%rsp) + mov %rdx,%r10 # about to borrow %rdx + movdqa $inout0,0x70(%rsp) + + lea 1($ctr),%rax + lea 2($ctr),%rdx + bswap %eax + bswap %edx + xor $key0,%eax + xor $key0,%edx + pinsrd \$3,%eax,$inout1 + lea 3($ctr),%rax + movdqa $inout1,0x10(%rsp) + pinsrd \$3,%edx,$inout2 + bswap %eax + mov %r10,%rdx # restore %rdx + lea 4($ctr),%r10 + movdqa $inout2,0x20(%rsp) + xor $key0,%eax + bswap %r10d + pinsrd \$3,%eax,$inout3 + xor $key0,%r10d + movdqa $inout3,0x30(%rsp) + lea 5($ctr),%r9 + mov %r10d,0x40+12(%rsp) + bswap %r9d + lea 6($ctr),%r10 + mov 240($key),$rounds # key->rounds + xor $key0,%r9d + bswap %r10d + mov %r9d,0x50+12(%rsp) + xor $key0,%r10d + lea 7($ctr),%r9 + mov %r10d,0x60+12(%rsp) + bswap %r9d + xor $key0,%r9d + mov %r9d,0x70+12(%rsp) + + $movkey 0x10($key),$rndkey1 + + movdqa 0x40(%rsp),$inout4 + movdqa 0x50(%rsp),$inout5 + + cmp \$8,$len # $len is in blocks + jb .Lctr32_tail # short input if ($len<8) + + lea 0x80($key),$key # size optimization + sub \$8,$len # $len is biased by -8 + jmp .Lctr32_loop8 + +.align 32 +.Lctr32_loop8: + add \$8,$ctr # next counter value + movdqa 0x60(%rsp),$inout6 + aesenc $rndkey1,$inout0 + mov $ctr,%r9d + movdqa 0x70(%rsp),$inout7 + aesenc $rndkey1,$inout1 + bswap %r9d + $movkey 0x20-0x80($key),$rndkey0 + aesenc $rndkey1,$inout2 + xor $key0,%r9d + nop + aesenc $rndkey1,$inout3 + mov %r9d,0x00+12(%rsp) # store next counter value + lea 1($ctr),%r9 + aesenc $rndkey1,$inout4 + aesenc $rndkey1,$inout5 + aesenc $rndkey1,$inout6 + aesenc $rndkey1,$inout7 + $movkey 0x30-0x80($key),$rndkey1 +___ +for($i=2;$i<8;$i++) { +my $rndkeyx = ($i&1)?$rndkey1:$rndkey0; +$code.=<<___; + bswap %r9d + aesenc $rndkeyx,$inout0 + aesenc $rndkeyx,$inout1 + xor $key0,%r9d + .byte 0x66,0x90 + aesenc $rndkeyx,$inout2 + aesenc $rndkeyx,$inout3 + mov %r9d,`0x10*($i-1)`+12(%rsp) + lea $i($ctr),%r9 + aesenc $rndkeyx,$inout4 + aesenc $rndkeyx,$inout5 + aesenc $rndkeyx,$inout6 + aesenc $rndkeyx,$inout7 + $movkey `0x20+0x10*$i`-0x80($key),$rndkeyx +___ +} +$code.=<<___; + bswap %r9d + aesenc $rndkey0,$inout0 + aesenc $rndkey0,$inout1 + aesenc $rndkey0,$inout2 + xor $key0,%r9d + movdqu 0x00($inp),$in0 # start loading input + aesenc $rndkey0,$inout3 + mov %r9d,0x70+12(%rsp) + cmp \$11,$rounds + aesenc $rndkey0,$inout4 + aesenc $rndkey0,$inout5 + aesenc $rndkey0,$inout6 + aesenc $rndkey0,$inout7 + $movkey 0xa0-0x80($key),$rndkey0 + + jb .Lctr32_enc_done + + aesenc $rndkey1,$inout0 + aesenc $rndkey1,$inout1 + aesenc $rndkey1,$inout2 + aesenc $rndkey1,$inout3 + aesenc $rndkey1,$inout4 + aesenc $rndkey1,$inout5 + aesenc $rndkey1,$inout6 + aesenc $rndkey1,$inout7 + $movkey 0xb0-0x80($key),$rndkey1 + + aesenc $rndkey0,$inout0 + aesenc $rndkey0,$inout1 + aesenc $rndkey0,$inout2 + aesenc $rndkey0,$inout3 + aesenc $rndkey0,$inout4 + aesenc $rndkey0,$inout5 + aesenc $rndkey0,$inout6 + aesenc $rndkey0,$inout7 + $movkey 0xc0-0x80($key),$rndkey0 + # 192-bit key support was removed. + + aesenc $rndkey1,$inout0 + aesenc $rndkey1,$inout1 + aesenc $rndkey1,$inout2 + aesenc $rndkey1,$inout3 + aesenc $rndkey1,$inout4 + aesenc $rndkey1,$inout5 + aesenc $rndkey1,$inout6 + aesenc $rndkey1,$inout7 + $movkey 0xd0-0x80($key),$rndkey1 + + aesenc $rndkey0,$inout0 + aesenc $rndkey0,$inout1 + aesenc $rndkey0,$inout2 + aesenc $rndkey0,$inout3 + aesenc $rndkey0,$inout4 + aesenc $rndkey0,$inout5 + aesenc $rndkey0,$inout6 + aesenc $rndkey0,$inout7 + $movkey 0xe0-0x80($key),$rndkey0 + jmp .Lctr32_enc_done + +.align 16 +.Lctr32_enc_done: + movdqu 0x10($inp),$in1 + pxor $rndkey0,$in0 # input^=round[last] + movdqu 0x20($inp),$in2 + pxor $rndkey0,$in1 + movdqu 0x30($inp),$in3 + pxor $rndkey0,$in2 + movdqu 0x40($inp),$in4 + pxor $rndkey0,$in3 + movdqu 0x50($inp),$in5 + pxor $rndkey0,$in4 + prefetcht0 0x1c0($inp) # We process 128 bytes (8*16), so to prefetch 1 iteration + prefetcht0 0x200($inp) # We need to prefetch 2 64 byte lines + pxor $rndkey0,$in5 + aesenc $rndkey1,$inout0 + aesenc $rndkey1,$inout1 + aesenc $rndkey1,$inout2 + aesenc $rndkey1,$inout3 + aesenc $rndkey1,$inout4 + aesenc $rndkey1,$inout5 + aesenc $rndkey1,$inout6 + aesenc $rndkey1,$inout7 + movdqu 0x60($inp),$rndkey1 # borrow $rndkey1 for inp[6] + lea 0x80($inp),$inp # $inp+=8*16 + + aesenclast $in0,$inout0 # $inN is inp[N]^round[last] + pxor $rndkey0,$rndkey1 # borrowed $rndkey + movdqu 0x70-0x80($inp),$in0 + aesenclast $in1,$inout1 + pxor $rndkey0,$in0 + movdqa 0x00(%rsp),$in1 # load next counter block + aesenclast $in2,$inout2 + aesenclast $in3,$inout3 + movdqa 0x10(%rsp),$in2 + movdqa 0x20(%rsp),$in3 + aesenclast $in4,$inout4 + aesenclast $in5,$inout5 + movdqa 0x30(%rsp),$in4 + movdqa 0x40(%rsp),$in5 + aesenclast $rndkey1,$inout6 + movdqa 0x50(%rsp),$rndkey0 + $movkey 0x10-0x80($key),$rndkey1#real 1st-round key + aesenclast $in0,$inout7 + + movups $inout0,($out) # store 8 output blocks + movdqa $in1,$inout0 + movups $inout1,0x10($out) + movdqa $in2,$inout1 + movups $inout2,0x20($out) + movdqa $in3,$inout2 + movups $inout3,0x30($out) + movdqa $in4,$inout3 + movups $inout4,0x40($out) + movdqa $in5,$inout4 + movups $inout5,0x50($out) + movdqa $rndkey0,$inout5 + movups $inout6,0x60($out) + movups $inout7,0x70($out) + lea 0x80($out),$out # $out+=8*16 + + sub \$8,$len + jnc .Lctr32_loop8 # loop if $len-=8 didn't borrow + + add \$8,$len # restore real remaining $len + jz .Lctr32_done # done if ($len==0) + lea -0x80($key),$key + +.Lctr32_tail: + # note that at this point $inout0..5 are populated with + # counter values xor-ed with 0-round key + lea 16($key),$key + cmp \$4,$len + jb .Lctr32_loop3 + je .Lctr32_loop4 + + # if ($len>4) compute 7 E(counter) + shl \$4,$rounds + movdqa 0x60(%rsp),$inout6 + pxor $inout7,$inout7 + + $movkey 16($key),$rndkey0 + aesenc $rndkey1,$inout0 + aesenc $rndkey1,$inout1 + lea 32-16($key,$rounds),$key# prepare for .Lenc_loop8_enter + neg %rax + aesenc $rndkey1,$inout2 + add \$16,%rax # prepare for .Lenc_loop8_enter + movups ($inp),$in0 + aesenc $rndkey1,$inout3 + aesenc $rndkey1,$inout4 + movups 0x10($inp),$in1 # pre-load input + movups 0x20($inp),$in2 + aesenc $rndkey1,$inout5 + aesenc $rndkey1,$inout6 + + call .Lenc_loop8_enter + + movdqu 0x30($inp),$in3 + pxor $in0,$inout0 + movdqu 0x40($inp),$in0 + pxor $in1,$inout1 + movdqu $inout0,($out) # store output + pxor $in2,$inout2 + movdqu $inout1,0x10($out) + pxor $in3,$inout3 + movdqu $inout2,0x20($out) + pxor $in0,$inout4 + movdqu $inout3,0x30($out) + movdqu $inout4,0x40($out) + cmp \$6,$len + jb .Lctr32_done # $len was 5, stop store + + movups 0x50($inp),$in1 + xorps $in1,$inout5 + movups $inout5,0x50($out) + je .Lctr32_done # $len was 6, stop store + + movups 0x60($inp),$in2 + xorps $in2,$inout6 + movups $inout6,0x60($out) + jmp .Lctr32_done # $len was 7, stop store + +.align 32 +.Lctr32_loop4: + aesenc $rndkey1,$inout0 + lea 16($key),$key + dec $rounds + aesenc $rndkey1,$inout1 + aesenc $rndkey1,$inout2 + aesenc $rndkey1,$inout3 + $movkey ($key),$rndkey1 + jnz .Lctr32_loop4 + aesenclast $rndkey1,$inout0 + aesenclast $rndkey1,$inout1 + movups ($inp),$in0 # load input + movups 0x10($inp),$in1 + aesenclast $rndkey1,$inout2 + aesenclast $rndkey1,$inout3 + movups 0x20($inp),$in2 + movups 0x30($inp),$in3 + + xorps $in0,$inout0 + movups $inout0,($out) # store output + xorps $in1,$inout1 + movups $inout1,0x10($out) + pxor $in2,$inout2 + movdqu $inout2,0x20($out) + pxor $in3,$inout3 + movdqu $inout3,0x30($out) + jmp .Lctr32_done # $len was 4, stop store + +.align 32 +.Lctr32_loop3: + aesenc $rndkey1,$inout0 + lea 16($key),$key + dec $rounds + aesenc $rndkey1,$inout1 + aesenc $rndkey1,$inout2 + $movkey ($key),$rndkey1 + jnz .Lctr32_loop3 + aesenclast $rndkey1,$inout0 + aesenclast $rndkey1,$inout1 + aesenclast $rndkey1,$inout2 + + movups ($inp),$in0 # load input + xorps $in0,$inout0 + movups $inout0,($out) # store output + cmp \$2,$len + jb .Lctr32_done # $len was 1, stop store + + movups 0x10($inp),$in1 + xorps $in1,$inout1 + movups $inout1,0x10($out) + je .Lctr32_done # $len was 2, stop store + + movups 0x20($inp),$in2 + xorps $in2,$inout2 + movups $inout2,0x20($out) # $len was 3, stop store + +.Lctr32_done: + xorps %xmm0,%xmm0 # clear register bank + xor $key0,$key0 + pxor %xmm1,%xmm1 + pxor %xmm2,%xmm2 + pxor %xmm3,%xmm3 + pxor %xmm4,%xmm4 + pxor %xmm5,%xmm5 +___ +$code.=<<___ if (!$win64); + pxor %xmm6,%xmm6 + pxor %xmm7,%xmm7 + movaps %xmm0,0x00(%rsp) # clear stack + pxor %xmm8,%xmm8 + movaps %xmm0,0x10(%rsp) + pxor %xmm9,%xmm9 + movaps %xmm0,0x20(%rsp) + pxor %xmm10,%xmm10 + movaps %xmm0,0x30(%rsp) + pxor %xmm11,%xmm11 + movaps %xmm0,0x40(%rsp) + pxor %xmm12,%xmm12 + movaps %xmm0,0x50(%rsp) + pxor %xmm13,%xmm13 + movaps %xmm0,0x60(%rsp) + pxor %xmm14,%xmm14 + movaps %xmm0,0x70(%rsp) + pxor %xmm15,%xmm15 +___ +$code.=<<___ if ($win64); + movaps -0xa8($key_),%xmm6 + movaps %xmm0,-0xa8($key_) # clear stack + movaps -0x98($key_),%xmm7 + movaps %xmm0,-0x98($key_) + movaps -0x88($key_),%xmm8 + movaps %xmm0,-0x88($key_) + movaps -0x78($key_),%xmm9 + movaps %xmm0,-0x78($key_) + movaps -0x68($key_),%xmm10 + movaps %xmm0,-0x68($key_) + movaps -0x58($key_),%xmm11 + movaps %xmm0,-0x58($key_) + movaps -0x48($key_),%xmm12 + movaps %xmm0,-0x48($key_) + movaps -0x38($key_),%xmm13 + movaps %xmm0,-0x38($key_) + movaps -0x28($key_),%xmm14 + movaps %xmm0,-0x28($key_) + movaps -0x18($key_),%xmm15 + movaps %xmm0,-0x18($key_) + movaps %xmm0,0x00(%rsp) + movaps %xmm0,0x10(%rsp) + movaps %xmm0,0x20(%rsp) + movaps %xmm0,0x30(%rsp) + movaps %xmm0,0x40(%rsp) + movaps %xmm0,0x50(%rsp) + movaps %xmm0,0x60(%rsp) + movaps %xmm0,0x70(%rsp) +___ +$code.=<<___; + mov -8($key_),%rbp +.cfi_restore %rbp + lea ($key_),%rsp +.cfi_def_cfa_register %rsp +.Lctr32_epilogue: + ret +.cfi_endproc +.size ${PREFIX}_ctr32_encrypt_blocks,.-${PREFIX}_ctr32_encrypt_blocks +___ +} }} + +{ my ($inp,$bits,$key) = @_4args; + $bits =~ s/%r/%e/; +# This is based on submission from Intel by +# Huang Ying +# Vinodh Gopal +# Kahraman Akdemir +# +# Aggressively optimized in respect to aeskeygenassist's critical path +# and is contained in %xmm0-5 to meet Win64 ABI requirement. +# +# int ${PREFIX}_set_encrypt_key(const unsigned char *inp, +# int bits, AES_KEY * const key); +# +# input: $inp user-supplied key +# $bits $inp length in bits +# $key pointer to key schedule +# output: %eax 0 denoting success, -1 or -2 - failure (see C) +# $bits rounds-1 (used in aesni_set_decrypt_key) +# *$key key schedule +# $key pointer to key schedule (used in +# aesni_set_decrypt_key) +# +# Subroutine is frame-less, which means that only volatile registers +# are used. Note that it's declared "abi-omnipotent", which means that +# amount of volatile registers is smaller on Windows. +# +# There are two variants of this function, one which uses aeskeygenassist +# ("base") and one which uses aesenclast + pshufb ("alt"). See aes/internal.h +# for details. +$code.=<<___; +.globl ${PREFIX}_set_encrypt_key_base +.type ${PREFIX}_set_encrypt_key_base,\@abi-omnipotent +.align 16 +${PREFIX}_set_encrypt_key_base: +.cfi_startproc +.seh_startproc + _CET_ENDBR +#ifdef BORINGSSL_DISPATCH_TEST + movb \$1,BORINGSSL_function_hit+3(%rip) +#endif + sub \$8,%rsp +.cfi_adjust_cfa_offset 8 +.seh_stackalloc 8 +.seh_endprologue + movups ($inp),%xmm0 # pull first 128 bits of *userKey + xorps %xmm4,%xmm4 # low dword of xmm4 is assumed 0 + lea 16($key),%rax # %rax is used as modifiable copy of $key + cmp \$256,$bits + je .L14rounds + # 192-bit key support was removed. + + cmp \$128,$bits + jne .Lbad_keybits + +.L10rounds: + mov \$9,$bits # 10 rounds for 128-bit key + + $movkey %xmm0,($key) # round 0 + aeskeygenassist \$0x1,%xmm0,%xmm1 # round 1 + call .Lkey_expansion_128_cold + aeskeygenassist \$0x2,%xmm0,%xmm1 # round 2 + call .Lkey_expansion_128 + aeskeygenassist \$0x4,%xmm0,%xmm1 # round 3 + call .Lkey_expansion_128 + aeskeygenassist \$0x8,%xmm0,%xmm1 # round 4 + call .Lkey_expansion_128 + aeskeygenassist \$0x10,%xmm0,%xmm1 # round 5 + call .Lkey_expansion_128 + aeskeygenassist \$0x20,%xmm0,%xmm1 # round 6 + call .Lkey_expansion_128 + aeskeygenassist \$0x40,%xmm0,%xmm1 # round 7 + call .Lkey_expansion_128 + aeskeygenassist \$0x80,%xmm0,%xmm1 # round 8 + call .Lkey_expansion_128 + aeskeygenassist \$0x1b,%xmm0,%xmm1 # round 9 + call .Lkey_expansion_128 + aeskeygenassist \$0x36,%xmm0,%xmm1 # round 10 + call .Lkey_expansion_128 + $movkey %xmm0,(%rax) + mov $bits,80(%rax) # 240(%rdx) + xor %eax,%eax + jmp .Lenc_key_ret + + # 192-bit key support was removed. + +.align 16 +.L14rounds: + movups 16($inp),%xmm2 # remaining half of *userKey + mov \$13,$bits # 14 rounds for 256 + lea 16(%rax),%rax + + $movkey %xmm0,($key) # round 0 + $movkey %xmm2,16($key) # round 1 + aeskeygenassist \$0x1,%xmm2,%xmm1 # round 2 + call .Lkey_expansion_256a_cold + aeskeygenassist \$0x1,%xmm0,%xmm1 # round 3 + call .Lkey_expansion_256b + aeskeygenassist \$0x2,%xmm2,%xmm1 # round 4 + call .Lkey_expansion_256a + aeskeygenassist \$0x2,%xmm0,%xmm1 # round 5 + call .Lkey_expansion_256b + aeskeygenassist \$0x4,%xmm2,%xmm1 # round 6 + call .Lkey_expansion_256a + aeskeygenassist \$0x4,%xmm0,%xmm1 # round 7 + call .Lkey_expansion_256b + aeskeygenassist \$0x8,%xmm2,%xmm1 # round 8 + call .Lkey_expansion_256a + aeskeygenassist \$0x8,%xmm0,%xmm1 # round 9 + call .Lkey_expansion_256b + aeskeygenassist \$0x10,%xmm2,%xmm1 # round 10 + call .Lkey_expansion_256a + aeskeygenassist \$0x10,%xmm0,%xmm1 # round 11 + call .Lkey_expansion_256b + aeskeygenassist \$0x20,%xmm2,%xmm1 # round 12 + call .Lkey_expansion_256a + aeskeygenassist \$0x20,%xmm0,%xmm1 # round 13 + call .Lkey_expansion_256b + aeskeygenassist \$0x40,%xmm2,%xmm1 # round 14 + call .Lkey_expansion_256a + $movkey %xmm0,(%rax) + mov $bits,16(%rax) # 240(%rdx) + xor %rax,%rax + jmp .Lenc_key_ret + +.align 16 +.Lbad_keybits: + mov \$-2,%rax +.Lenc_key_ret: + pxor %xmm0,%xmm0 + pxor %xmm1,%xmm1 + pxor %xmm2,%xmm2 + pxor %xmm3,%xmm3 + pxor %xmm4,%xmm4 + pxor %xmm5,%xmm5 + add \$8,%rsp +.cfi_adjust_cfa_offset -8 + ret +.cfi_endproc +.seh_endproc + +.align 16 +.Lkey_expansion_128: +.cfi_startproc + $movkey %xmm0,(%rax) + lea 16(%rax),%rax +.Lkey_expansion_128_cold: + shufps \$0b00010000,%xmm0,%xmm4 + xorps %xmm4, %xmm0 + shufps \$0b10001100,%xmm0,%xmm4 + xorps %xmm4, %xmm0 + shufps \$0b11111111,%xmm1,%xmm1 # critical path + xorps %xmm1,%xmm0 + ret +.cfi_endproc + +.align 16 +.Lkey_expansion_256a: +.cfi_startproc + $movkey %xmm2,(%rax) + lea 16(%rax),%rax +.Lkey_expansion_256a_cold: + shufps \$0b00010000,%xmm0,%xmm4 + xorps %xmm4,%xmm0 + shufps \$0b10001100,%xmm0,%xmm4 + xorps %xmm4,%xmm0 + shufps \$0b11111111,%xmm1,%xmm1 # critical path + xorps %xmm1,%xmm0 + ret +.cfi_endproc + +.align 16 +.Lkey_expansion_256b: +.cfi_startproc + $movkey %xmm0,(%rax) + lea 16(%rax),%rax + + shufps \$0b00010000,%xmm2,%xmm4 + xorps %xmm4,%xmm2 + shufps \$0b10001100,%xmm2,%xmm4 + xorps %xmm4,%xmm2 + shufps \$0b10101010,%xmm1,%xmm1 # critical path + xorps %xmm1,%xmm2 + ret +.cfi_endproc +.size ${PREFIX}_set_encrypt_key_base,.-${PREFIX}_set_encrypt_key_base + +.globl ${PREFIX}_set_encrypt_key_alt +.type ${PREFIX}_set_encrypt_key_alt,\@abi-omnipotent +.align 16 +${PREFIX}_set_encrypt_key_alt: +.cfi_startproc +.seh_startproc + _CET_ENDBR +#ifdef BORINGSSL_DISPATCH_TEST + movb \$1,BORINGSSL_function_hit+3(%rip) +#endif + sub \$8,%rsp +.cfi_adjust_cfa_offset 8 +.seh_stackalloc 8 +.seh_endprologue + movups ($inp),%xmm0 # pull first 128 bits of *userKey + xorps %xmm4,%xmm4 # low dword of xmm4 is assumed 0 + lea 16($key),%rax # %rax is used as modifiable copy of $key + cmp \$256,$bits + je .L14rounds_alt + # 192-bit key support was removed. + cmp \$128,$bits + jne .Lbad_keybits_alt + + mov \$9,$bits # 10 rounds for 128-bit key + movdqa .Lkey_rotate(%rip),%xmm5 + mov \$8,%r10d + movdqa .Lkey_rcon1(%rip),%xmm4 + movdqa %xmm0,%xmm2 + movdqu %xmm0,($key) + jmp .Loop_key128 + +.align 16 +.Loop_key128: + pshufb %xmm5,%xmm0 + aesenclast %xmm4,%xmm0 + pslld \$1,%xmm4 + lea 16(%rax),%rax + + movdqa %xmm2,%xmm3 + pslldq \$4,%xmm2 + pxor %xmm2,%xmm3 + pslldq \$4,%xmm2 + pxor %xmm2,%xmm3 + pslldq \$4,%xmm2 + pxor %xmm3,%xmm2 + + pxor %xmm2,%xmm0 + movdqu %xmm0,-16(%rax) + movdqa %xmm0,%xmm2 + + dec %r10d + jnz .Loop_key128 + + movdqa .Lkey_rcon1b(%rip),%xmm4 + + pshufb %xmm5,%xmm0 + aesenclast %xmm4,%xmm0 + pslld \$1,%xmm4 + + movdqa %xmm2,%xmm3 + pslldq \$4,%xmm2 + pxor %xmm2,%xmm3 + pslldq \$4,%xmm2 + pxor %xmm2,%xmm3 + pslldq \$4,%xmm2 + pxor %xmm3,%xmm2 + + pxor %xmm2,%xmm0 + movdqu %xmm0,(%rax) + + movdqa %xmm0,%xmm2 + pshufb %xmm5,%xmm0 + aesenclast %xmm4,%xmm0 + + movdqa %xmm2,%xmm3 + pslldq \$4,%xmm2 + pxor %xmm2,%xmm3 + pslldq \$4,%xmm2 + pxor %xmm2,%xmm3 + pslldq \$4,%xmm2 + pxor %xmm3,%xmm2 + + pxor %xmm2,%xmm0 + movdqu %xmm0,16(%rax) + + mov $bits,96(%rax) # 240($key) + xor %eax,%eax + jmp .Lenc_key_ret_alt + + # 192-bit key support was removed. + +.align 16 +.L14rounds_alt: + movups 16($inp),%xmm2 # remaining half of *userKey + mov \$13,$bits # 14 rounds for 256 + lea 16(%rax),%rax + movdqa .Lkey_rotate(%rip),%xmm5 + movdqa .Lkey_rcon1(%rip),%xmm4 + mov \$7,%r10d + movdqu %xmm0,0($key) + movdqa %xmm2,%xmm1 + movdqu %xmm2,16($key) + jmp .Loop_key256 + +.align 16 +.Loop_key256: + pshufb %xmm5,%xmm2 + aesenclast %xmm4,%xmm2 + + movdqa %xmm0,%xmm3 + pslldq \$4,%xmm0 + pxor %xmm0,%xmm3 + pslldq \$4,%xmm0 + pxor %xmm0,%xmm3 + pslldq \$4,%xmm0 + pxor %xmm3,%xmm0 + pslld \$1,%xmm4 + + pxor %xmm2,%xmm0 + movdqu %xmm0,(%rax) + + dec %r10d + jz .Ldone_key256 + + pshufd \$0xff,%xmm0,%xmm2 + pxor %xmm3,%xmm3 + aesenclast %xmm3,%xmm2 + + movdqa %xmm1,%xmm3 + pslldq \$4,%xmm1 + pxor %xmm1,%xmm3 + pslldq \$4,%xmm1 + pxor %xmm1,%xmm3 + pslldq \$4,%xmm1 + pxor %xmm3,%xmm1 + + pxor %xmm1,%xmm2 + movdqu %xmm2,16(%rax) + lea 32(%rax),%rax + movdqa %xmm2,%xmm1 + + jmp .Loop_key256 + +.Ldone_key256: + mov $bits,16(%rax) # 240($key) + xor %eax,%eax + jmp .Lenc_key_ret_alt + +.align 16 +.Lbad_keybits_alt: + mov \$-2,%rax +.Lenc_key_ret_alt: + pxor %xmm0,%xmm0 + pxor %xmm1,%xmm1 + pxor %xmm2,%xmm2 + pxor %xmm3,%xmm3 + pxor %xmm4,%xmm4 + pxor %xmm5,%xmm5 + add \$8,%rsp +.cfi_adjust_cfa_offset -8 + ret +.cfi_endproc +.seh_endproc +.size ${PREFIX}_set_encrypt_key_alt,.-${PREFIX}_set_encrypt_key_alt +___ +} + +$code.=<<___; +.section .rodata +.align 64 +.Lbswap_mask: + .byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 +.Lincrement32: + .long 6,6,6,0 +.Lincrement64: + .long 1,0,0,0 +.Lincrement1: + .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 +.Lkey_rotate: + .long 0x0c0f0e0d,0x0c0f0e0d,0x0c0f0e0d,0x0c0f0e0d +.Lkey_rotate192: + .long 0x04070605,0x04070605,0x04070605,0x04070605 +.Lkey_rcon1: + .long 1,1,1,1 +.Lkey_rcon1b: + .long 0x1b,0x1b,0x1b,0x1b + +.asciz "AES for Intel AES-NI, CRYPTOGAMS by " +.align 64 +.text +___ + +# EXCEPTION_DISPOSITION handler (EXCEPTION_RECORD *rec,ULONG64 frame, +# CONTEXT *context,DISPATCHER_CONTEXT *disp) +if ($win64) { +$rec="%rcx"; +$frame="%rdx"; +$context="%r8"; +$disp="%r9"; + +$code.=<<___; +.extern __imp_RtlVirtualUnwind +___ +$code.=<<___ if ($PREFIX eq "aes_hw"); +.type ctr_xts_se_handler,\@abi-omnipotent +.align 16 +ctr_xts_se_handler: + push %rsi + push %rdi + push %rbx + push %rbp + push %r12 + push %r13 + push %r14 + push %r15 + pushfq + sub \$64,%rsp + + mov 120($context),%rax # pull context->Rax + mov 248($context),%rbx # pull context->Rip + + mov 8($disp),%rsi # disp->ImageBase + mov 56($disp),%r11 # disp->HandlerData + + mov 0(%r11),%r10d # HandlerData[0] + lea (%rsi,%r10),%r10 # prologue lable + cmp %r10,%rbx # context->RipRsp + + mov 4(%r11),%r10d # HandlerData[1] + lea (%rsi,%r10),%r10 # epilogue label + cmp %r10,%rbx # context->Rip>=epilogue label + jae .Lcommon_seh_tail + + mov 208($context),%rax # pull context->R11 + + lea -0xa8(%rax),%rsi # %xmm save area + lea 512($context),%rdi # & context.Xmm6 + mov \$20,%ecx # 10*sizeof(%xmm0)/sizeof(%rax) + .long 0xa548f3fc # cld; rep movsq + + mov -8(%rax),%rbp # restore saved %rbp + mov %rbp,160($context) # restore context->Rbp + + +.Lcommon_seh_tail: + mov 8(%rax),%rdi + mov 16(%rax),%rsi + mov %rax,152($context) # restore context->Rsp + mov %rsi,168($context) # restore context->Rsi + mov %rdi,176($context) # restore context->Rdi + + mov 40($disp),%rdi # disp->ContextRecord + mov $context,%rsi # context + mov \$154,%ecx # sizeof(CONTEXT) + .long 0xa548f3fc # cld; rep movsq + + mov $disp,%rsi + xor %rcx,%rcx # arg1, UNW_FLAG_NHANDLER + mov 8(%rsi),%rdx # arg2, disp->ImageBase + mov 0(%rsi),%r8 # arg3, disp->ControlPc + mov 16(%rsi),%r9 # arg4, disp->FunctionEntry + mov 40(%rsi),%r10 # disp->ContextRecord + lea 56(%rsi),%r11 # &disp->HandlerData + lea 24(%rsi),%r12 # &disp->EstablisherFrame + mov %r10,32(%rsp) # arg5 + mov %r11,40(%rsp) # arg6 + mov %r12,48(%rsp) # arg7 + mov %rcx,56(%rsp) # arg8, (NULL) + call *__imp_RtlVirtualUnwind(%rip) + + mov \$1,%eax # ExceptionContinueSearch + add \$64,%rsp + popfq + pop %r15 + pop %r14 + pop %r13 + pop %r12 + pop %rbp + pop %rbx + pop %rdi + pop %rsi + ret +.size ctr_xts_se_handler,.-ctr_xts_se_handler + +.section .pdata +.align 4 +___ +$code.=<<___ if ($PREFIX eq "aes_hw"); + .rva .LSEH_begin_${PREFIX}_ctr32_encrypt_blocks + .rva .LSEH_end_${PREFIX}_ctr32_encrypt_blocks + .rva .LSEH_info_ctr32 +___ +$code.=<<___; +.section .xdata +.align 8 +___ +$code.=<<___ if ($PREFIX eq "aes_hw"); +.LSEH_info_ctr32: + .byte 9,0,0,0 + .rva ctr_xts_se_handler + .rva .Lctr32_body,.Lctr32_epilogue # HandlerData[] +___ +} + +sub rex { + local *opcode=shift; + my ($dst,$src)=@_; + my $rex=0; + + $rex|=0x04 if($dst>=8); + $rex|=0x01 if($src>=8); + push @opcode,$rex|0x40 if($rex); +} + +sub aesni { + my $line=shift; + my @opcode=(0x66); + + if ($line=~/(aeskeygenassist)\s+\$([x0-9a-f]+),\s*%xmm([0-9]+),\s*%xmm([0-9]+)/) { + rex(\@opcode,$4,$3); + push @opcode,0x0f,0x3a,0xdf; + push @opcode,0xc0|($3&7)|(($4&7)<<3); # ModR/M + my $c=$2; + push @opcode,$c=~/^0/?oct($c):$c; + return ".byte\t".join(',',@opcode); + } + elsif ($line=~/(aes[a-z]+)\s+%xmm([0-9]+),\s*%xmm([0-9]+)/) { + my %opcodelet = ( + "aesimc" => 0xdb, + "aesenc" => 0xdc, "aesenclast" => 0xdd, + "aesdec" => 0xde, "aesdeclast" => 0xdf + ); + return undef if (!defined($opcodelet{$1})); + rex(\@opcode,$3,$2); + push @opcode,0x0f,0x38,$opcodelet{$1}; + push @opcode,0xc0|($2&7)|(($3&7)<<3); # ModR/M + return ".byte\t".join(',',@opcode); + } + elsif ($line=~/(aes[a-z]+)\s+([0x1-9a-fA-F]*)\(%rsp\),\s*%xmm([0-9]+)/) { + my %opcodelet = ( + "aesenc" => 0xdc, "aesenclast" => 0xdd, + "aesdec" => 0xde, "aesdeclast" => 0xdf + ); + return undef if (!defined($opcodelet{$1})); + my $off = $2; + push @opcode,0x44 if ($3>=8); + push @opcode,0x0f,0x38,$opcodelet{$1}; + push @opcode,0x44|(($3&7)<<3),0x24; # ModR/M + push @opcode,($off=~/^0/?oct($off):$off)&0xff; + return ".byte\t".join(',',@opcode); + } + return $line; +} + +sub movbe { + ".byte 0x0f,0x38,0xf1,0x44,0x24,".shift; +} + +$code =~ s/\`([^\`]*)\`/eval($1)/gem; +$code =~ s/\b(aes.*%xmm[0-9]+).*$/aesni($1)/gem; +#$code =~ s/\bmovbe\s+%eax/bswap %eax; mov %eax/gm; # debugging artefact +$code =~ s/\bmovbe\s+%eax,\s*([0-9]+)\(%rsp\)/movbe($1)/gem; + +print $code; + +close STDOUT or die "error closing STDOUT: $!"; diff --git a/http/vendor/ring/crypto/fipsmodule/aes/asm/aesv8-armx.pl b/http/vendor/ring/crypto/fipsmodule/aes/asm/aesv8-armx.pl new file mode 100644 index 0000000..5dfb4b1 --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/aes/asm/aesv8-armx.pl @@ -0,0 +1,587 @@ +#! /usr/bin/env perl +# Copyright 2014-2016 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# ==================================================================== +# Written by Andy Polyakov for the OpenSSL +# project. +# ==================================================================== +# +# This module implements support for ARMv8 AES instructions. The +# module is endian-agnostic in sense that it supports both big- and +# little-endian cases. As does it support both 32- and 64-bit modes +# of operation. Latter is achieved by limiting amount of utilized +# registers to 16, which implies additional NEON load and integer +# instructions. This has no effect on mighty Apple A7, where results +# are literally equal to the theoretical estimates based on AES +# instruction latencies and issue rates. On Cortex-A53, an in-order +# execution core, this costs up to 10-15%, which is partially +# compensated by implementing dedicated code path for 128-bit +# CBC encrypt case. On Cortex-A57 parallelizable mode performance +# seems to be limited by sheer amount of NEON instructions... +# +# Performance in cycles per byte processed with 128-bit key: +# +# CBC enc CBC dec CTR +# Apple A7 2.39 1.20 1.20 +# Cortex-A53 1.32 1.29 1.46 +# Cortex-A57(*) 1.95 0.85 0.93 +# Denver 1.96 0.86 0.80 +# Mongoose 1.33 1.20 1.20 +# +# (*) original 3.64/1.34/1.32 results were for r0p0 revision +# and are still same even for updated module; + +$flavour = shift; +$output = shift; + +$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; +( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or +( $xlate="${dir}../../../perlasm/arm-xlate.pl" and -f $xlate) or +die "can't locate arm-xlate.pl"; + +open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""; +*STDOUT=*OUT; + +$prefix="aes_hw"; + +$code=<<___; +#if __ARM_MAX_ARCH__>=7 +.text +___ +$code.=".arch armv8-a+crypto\n" if ($flavour =~ /64/); +$code.=<<___ if ($flavour !~ /64/); +.arch armv7-a // don't confuse not-so-latest binutils with argv8 :-) +.fpu neon +.code 32 +#undef __thumb2__ +___ + +# Assembler mnemonics are an eclectic mix of 32- and 64-bit syntax, +# NEON is mostly 32-bit mnemonics, integer - mostly 64. Goal is to +# maintain both 32- and 64-bit codes within single module and +# transliterate common code to either flavour with regex vodoo. +# +{{{ +my ($inp,$bits,$out,$ptr,$rounds)=("x0","w1","x2","x3","w12"); +my ($zero,$rcon,$mask,$in0,$in1,$tmp,$key)= + $flavour=~/64/? map("q$_",(0..6)) : map("q$_",(0..3,8..10)); + + +# On AArch64, put the data .rodata and use adrp + add for compatibility with +# execute-only memory. On AArch32, put it in .text and use adr. +$code.= ".section .rodata\n" if ($flavour =~ /64/); +$code.=<<___; +.align 5 +.Lrcon: +.long 0x01,0x01,0x01,0x01 +.long 0x0c0f0e0d,0x0c0f0e0d,0x0c0f0e0d,0x0c0f0e0d // rotate-n-splat +.long 0x1b,0x1b,0x1b,0x1b + +.text + +.globl ${prefix}_set_encrypt_key +.type ${prefix}_set_encrypt_key,%function +.align 5 +${prefix}_set_encrypt_key: +.Lenc_key: +___ +$code.=<<___ if ($flavour =~ /64/); + // Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later. + AARCH64_VALID_CALL_TARGET + stp x29,x30,[sp,#-16]! + add x29,sp,#0 +___ +$code.=<<___; + mov $ptr,#-2 + cmp $bits,#128 + b.lt .Lenc_key_abort + cmp $bits,#256 + b.gt .Lenc_key_abort + tst $bits,#0x3f + b.ne .Lenc_key_abort + +___ +$code.=<<___ if ($flavour =~ /64/); + adrp $ptr,:pg_hi21:.Lrcon + add $ptr,$ptr,:lo12:.Lrcon +___ +$code.=<<___ if ($flavour !~ /64/); + adr $ptr,.Lrcon +___ +$code.=<<___; + cmp $bits,#192 + + veor $zero,$zero,$zero + vld1.8 {$in0},[$inp],#16 + mov $bits,#8 // reuse $bits + vld1.32 {$rcon,$mask},[$ptr],#32 + + b.lt .Loop128 + // 192-bit key support was removed. + b .L256 + +.align 4 +.Loop128: + vtbl.8 $key,{$in0},$mask + vext.8 $tmp,$zero,$in0,#12 + vst1.32 {$in0},[$out],#16 + aese $key,$zero + subs $bits,$bits,#1 + + veor $in0,$in0,$tmp + vext.8 $tmp,$zero,$tmp,#12 + veor $in0,$in0,$tmp + vext.8 $tmp,$zero,$tmp,#12 + veor $key,$key,$rcon + veor $in0,$in0,$tmp + vshl.u8 $rcon,$rcon,#1 + veor $in0,$in0,$key + b.ne .Loop128 + + vld1.32 {$rcon},[$ptr] + + vtbl.8 $key,{$in0},$mask + vext.8 $tmp,$zero,$in0,#12 + vst1.32 {$in0},[$out],#16 + aese $key,$zero + + veor $in0,$in0,$tmp + vext.8 $tmp,$zero,$tmp,#12 + veor $in0,$in0,$tmp + vext.8 $tmp,$zero,$tmp,#12 + veor $key,$key,$rcon + veor $in0,$in0,$tmp + vshl.u8 $rcon,$rcon,#1 + veor $in0,$in0,$key + + vtbl.8 $key,{$in0},$mask + vext.8 $tmp,$zero,$in0,#12 + vst1.32 {$in0},[$out],#16 + aese $key,$zero + + veor $in0,$in0,$tmp + vext.8 $tmp,$zero,$tmp,#12 + veor $in0,$in0,$tmp + vext.8 $tmp,$zero,$tmp,#12 + veor $key,$key,$rcon + veor $in0,$in0,$tmp + veor $in0,$in0,$key + vst1.32 {$in0},[$out] + add $out,$out,#0x50 + + mov $rounds,#10 + b .Ldone + +// 192-bit key support was removed. + +.align 4 +.L256: + vld1.8 {$in1},[$inp] + mov $bits,#7 + mov $rounds,#14 + vst1.32 {$in0},[$out],#16 + +.Loop256: + vtbl.8 $key,{$in1},$mask + vext.8 $tmp,$zero,$in0,#12 + vst1.32 {$in1},[$out],#16 + aese $key,$zero + subs $bits,$bits,#1 + + veor $in0,$in0,$tmp + vext.8 $tmp,$zero,$tmp,#12 + veor $in0,$in0,$tmp + vext.8 $tmp,$zero,$tmp,#12 + veor $key,$key,$rcon + veor $in0,$in0,$tmp + vshl.u8 $rcon,$rcon,#1 + veor $in0,$in0,$key + vst1.32 {$in0},[$out],#16 + b.eq .Ldone + + vdup.32 $key,${in0}[3] // just splat + vext.8 $tmp,$zero,$in1,#12 + aese $key,$zero + + veor $in1,$in1,$tmp + vext.8 $tmp,$zero,$tmp,#12 + veor $in1,$in1,$tmp + vext.8 $tmp,$zero,$tmp,#12 + veor $in1,$in1,$tmp + + veor $in1,$in1,$key + b .Loop256 + +.Ldone: + str $rounds,[$out] + mov $ptr,#0 + +.Lenc_key_abort: + mov x0,$ptr // return value + `"ldr x29,[sp],#16" if ($flavour =~ /64/)` + ret +.size ${prefix}_set_encrypt_key,.-${prefix}_set_encrypt_key +___ +}}} +{{{ +my ($inp,$out,$len,$key,$ivp)=map("x$_",(0..4)); +my ($rounds,$cnt,$key_)=("w5","w6","x7"); +my ($ctr,$tctr0,$tctr1,$tctr2)=map("w$_",(8..10,12)); +my $step="x12"; # aliases with $tctr2 + +my ($dat0,$dat1,$in0,$in1,$tmp0,$tmp1,$ivec,$rndlast)=map("q$_",(0..7)); +my ($dat2,$in2,$tmp2)=map("q$_",(10,11,9)); + +my ($dat,$tmp)=($dat0,$tmp0); + +### q8-q15 preloaded key schedule + +$code.=<<___; +.globl ${prefix}_ctr32_encrypt_blocks +.type ${prefix}_ctr32_encrypt_blocks,%function +.align 5 +${prefix}_ctr32_encrypt_blocks: +___ +$code.=<<___ if ($flavour =~ /64/); + // Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later. + AARCH64_VALID_CALL_TARGET + stp x29,x30,[sp,#-16]! + add x29,sp,#0 +___ +$code.=<<___ if ($flavour !~ /64/); + mov ip,sp + stmdb sp!,{r4-r10,lr} + vstmdb sp!,{d8-d15} @ ABI specification says so + ldr r4, [ip] @ load remaining arg +___ +$code.=<<___; + ldr $rounds,[$key,#240] + + ldr $ctr, [$ivp, #12] + vld1.32 {$dat0},[$ivp] + + vld1.32 {q8-q9},[$key] // load key schedule... + sub $rounds,$rounds,#4 + mov $step,#16 + cmp $len,#2 + add $key_,$key,x5,lsl#4 // pointer to last 5 round keys + sub $rounds,$rounds,#2 + vld1.32 {q12-q13},[$key_],#32 + vld1.32 {q14-q15},[$key_],#32 + vld1.32 {$rndlast},[$key_] + add $key_,$key,#32 + mov $cnt,$rounds + cclr $step,lo + + // ARM Cortex-A57 and Cortex-A72 cores running in 32-bit mode are + // affected by silicon errata #1742098 [0] and #1655431 [1], + // respectively, where the second instruction of an aese/aesmc + // instruction pair may execute twice if an interrupt is taken right + // after the first instruction consumes an input register of which a + // single 32-bit lane has been updated the last time it was modified. + // + // This function uses a counter in one 32-bit lane. The vmov.32 lines + // could write to $dat1 and $dat2 directly, but that trips this bugs. + // We write to $ivec and copy to the final register as a workaround. + // + // [0] ARM-EPM-049219 v23 Cortex-A57 MPCore Software Developers Errata Notice + // [1] ARM-EPM-012079 v11.0 Cortex-A72 MPCore Software Developers Errata Notice +#ifndef __ARMEB__ + rev $ctr, $ctr +#endif + add $tctr1, $ctr, #1 + vorr $ivec,$dat0,$dat0 + rev $tctr1, $tctr1 + vmov.32 ${ivec}[3],$tctr1 + add $ctr, $ctr, #2 + vorr $dat1,$ivec,$ivec + b.ls .Lctr32_tail + rev $tctr2, $ctr + vmov.32 ${ivec}[3],$tctr2 + sub $len,$len,#3 // bias + vorr $dat2,$ivec,$ivec + b .Loop3x_ctr32 + +.align 4 +.Loop3x_ctr32: + aese $dat0,q8 + aesmc $dat0,$dat0 + aese $dat1,q8 + aesmc $dat1,$dat1 + aese $dat2,q8 + aesmc $dat2,$dat2 + vld1.32 {q8},[$key_],#16 + subs $cnt,$cnt,#2 + aese $dat0,q9 + aesmc $dat0,$dat0 + aese $dat1,q9 + aesmc $dat1,$dat1 + aese $dat2,q9 + aesmc $dat2,$dat2 + vld1.32 {q9},[$key_],#16 + b.gt .Loop3x_ctr32 + + aese $dat0,q8 + aesmc $tmp0,$dat0 + aese $dat1,q8 + aesmc $tmp1,$dat1 + vld1.8 {$in0},[$inp],#16 + add $tctr0,$ctr,#1 + aese $dat2,q8 + aesmc $dat2,$dat2 + vld1.8 {$in1},[$inp],#16 + rev $tctr0,$tctr0 + aese $tmp0,q9 + aesmc $tmp0,$tmp0 + aese $tmp1,q9 + aesmc $tmp1,$tmp1 + vld1.8 {$in2},[$inp],#16 + mov $key_,$key + aese $dat2,q9 + aesmc $tmp2,$dat2 + aese $tmp0,q12 + aesmc $tmp0,$tmp0 + aese $tmp1,q12 + aesmc $tmp1,$tmp1 + veor $in0,$in0,$rndlast + add $tctr1,$ctr,#2 + aese $tmp2,q12 + aesmc $tmp2,$tmp2 + veor $in1,$in1,$rndlast + add $ctr,$ctr,#3 + aese $tmp0,q13 + aesmc $tmp0,$tmp0 + aese $tmp1,q13 + aesmc $tmp1,$tmp1 + // Note the logic to update $dat0, $dat1, and $dat1 is written to work + // around a bug in ARM Cortex-A57 and Cortex-A72 cores running in + // 32-bit mode. See the comment above. + veor $in2,$in2,$rndlast + vmov.32 ${ivec}[3], $tctr0 + aese $tmp2,q13 + aesmc $tmp2,$tmp2 + vorr $dat0,$ivec,$ivec + rev $tctr1,$tctr1 + aese $tmp0,q14 + aesmc $tmp0,$tmp0 + vmov.32 ${ivec}[3], $tctr1 + rev $tctr2,$ctr + aese $tmp1,q14 + aesmc $tmp1,$tmp1 + vorr $dat1,$ivec,$ivec + vmov.32 ${ivec}[3], $tctr2 + aese $tmp2,q14 + aesmc $tmp2,$tmp2 + vorr $dat2,$ivec,$ivec + subs $len,$len,#3 + aese $tmp0,q15 + aese $tmp1,q15 + aese $tmp2,q15 + + veor $in0,$in0,$tmp0 + vld1.32 {q8},[$key_],#16 // re-pre-load rndkey[0] + vst1.8 {$in0},[$out],#16 + veor $in1,$in1,$tmp1 + mov $cnt,$rounds + vst1.8 {$in1},[$out],#16 + veor $in2,$in2,$tmp2 + vld1.32 {q9},[$key_],#16 // re-pre-load rndkey[1] + vst1.8 {$in2},[$out],#16 + b.hs .Loop3x_ctr32 + + adds $len,$len,#3 + b.eq .Lctr32_done + cmp $len,#1 + mov $step,#16 + cclr $step,eq + +.Lctr32_tail: + aese $dat0,q8 + aesmc $dat0,$dat0 + aese $dat1,q8 + aesmc $dat1,$dat1 + vld1.32 {q8},[$key_],#16 + subs $cnt,$cnt,#2 + aese $dat0,q9 + aesmc $dat0,$dat0 + aese $dat1,q9 + aesmc $dat1,$dat1 + vld1.32 {q9},[$key_],#16 + b.gt .Lctr32_tail + + aese $dat0,q8 + aesmc $dat0,$dat0 + aese $dat1,q8 + aesmc $dat1,$dat1 + aese $dat0,q9 + aesmc $dat0,$dat0 + aese $dat1,q9 + aesmc $dat1,$dat1 + vld1.8 {$in0},[$inp],$step + aese $dat0,q12 + aesmc $dat0,$dat0 + aese $dat1,q12 + aesmc $dat1,$dat1 + vld1.8 {$in1},[$inp] + aese $dat0,q13 + aesmc $dat0,$dat0 + aese $dat1,q13 + aesmc $dat1,$dat1 + veor $in0,$in0,$rndlast + aese $dat0,q14 + aesmc $dat0,$dat0 + aese $dat1,q14 + aesmc $dat1,$dat1 + veor $in1,$in1,$rndlast + aese $dat0,q15 + aese $dat1,q15 + + cmp $len,#1 + veor $in0,$in0,$dat0 + veor $in1,$in1,$dat1 + vst1.8 {$in0},[$out],#16 + b.eq .Lctr32_done + vst1.8 {$in1},[$out] + +.Lctr32_done: +___ +$code.=<<___ if ($flavour !~ /64/); + vldmia sp!,{d8-d15} + ldmia sp!,{r4-r10,pc} +___ +$code.=<<___ if ($flavour =~ /64/); + ldr x29,[sp],#16 + ret +___ +$code.=<<___; +.size ${prefix}_ctr32_encrypt_blocks,.-${prefix}_ctr32_encrypt_blocks +___ +}}} +$code.=<<___; +#endif +___ +######################################## +if ($flavour =~ /64/) { ######## 64-bit code + my %opcode = ( + "aesd" => 0x4e285800, "aese" => 0x4e284800, + "aesimc"=> 0x4e287800, "aesmc" => 0x4e286800 ); + + local *unaes = sub { + my ($mnemonic,$arg)=@_; + + $arg =~ m/[qv]([0-9]+)[^,]*,\s*[qv]([0-9]+)/o && + sprintf ".inst\t0x%08x\t//%s %s", + $opcode{$mnemonic}|$1|($2<<5), + $mnemonic,$arg; + }; + + foreach(split("\n",$code)) { + s/\`([^\`]*)\`/eval($1)/geo; + + s/\bq([0-9]+)\b/"v".($1<8?$1:$1+8).".16b"/geo; # old->new registers + s/@\s/\/\//o; # old->new style commentary + + #s/[v]?(aes\w+)\s+([qv].*)/unaes($1,$2)/geo or + s/cclr\s+([wx])([^,]+),\s*([a-z]+)/csel $1$2,$1zr,$1$2,$3/o or + s/mov\.([a-z]+)\s+([wx][0-9]+),\s*([wx][0-9]+)/csel $2,$3,$2,$1/o or + s/vmov\.i8/movi/o or # fix up legacy mnemonics + s/vext\.8/ext/o or + s/vrev32\.8/rev32/o or + s/vtst\.8/cmtst/o or + s/vshr/ushr/o or + s/^(\s+)v/$1/o or # strip off v prefix + s/\bbx\s+lr\b/ret/o; + + # fix up remaining legacy suffixes + s/\.[ui]?8//o; + m/\],#8/o and s/\.16b/\.8b/go; + s/\.[ui]?32//o and s/\.16b/\.4s/go; + s/\.[ui]?64//o and s/\.16b/\.2d/go; + s/\.[42]([sd])\[([0-3])\]/\.$1\[$2\]/o; + + # Switch preprocessor checks to aarch64 versions. + s/__ARME([BL])__/__AARCH64E$1__/go; + + print $_,"\n"; + } +} else { ######## 32-bit code + my %opcode = ( + "aesd" => 0xf3b00340, "aese" => 0xf3b00300, + "aesimc"=> 0xf3b003c0, "aesmc" => 0xf3b00380 ); + + local *unaes = sub { + my ($mnemonic,$arg)=@_; + + if ($arg =~ m/[qv]([0-9]+)[^,]*,\s*[qv]([0-9]+)/o) { + my $word = $opcode{$mnemonic}|(($1&7)<<13)|(($1&8)<<19) + |(($2&7)<<1) |(($2&8)<<2); + # since ARMv7 instructions are always encoded little-endian. + # correct solution is to use .inst directive, but older + # assemblers don't implement it:-( + sprintf ".byte\t0x%02x,0x%02x,0x%02x,0x%02x\t@ %s %s", + $word&0xff,($word>>8)&0xff, + ($word>>16)&0xff,($word>>24)&0xff, + $mnemonic,$arg; + } + }; + + sub unvtbl { + my $arg=shift; + + $arg =~ m/q([0-9]+),\s*\{q([0-9]+)\},\s*q([0-9]+)/o && + sprintf "vtbl.8 d%d,{q%d},d%d\n\t". + "vtbl.8 d%d,{q%d},d%d", 2*$1,$2,2*$3, 2*$1+1,$2,2*$3+1; + } + + sub unvdup32 { + my $arg=shift; + + $arg =~ m/q([0-9]+),\s*q([0-9]+)\[([0-3])\]/o && + sprintf "vdup.32 q%d,d%d[%d]",$1,2*$2+($3>>1),$3&1; + } + + sub unvmov32 { + my $arg=shift; + + $arg =~ m/q([0-9]+)\[([0-3])\],(.*)/o && + sprintf "vmov.32 d%d[%d],%s",2*$1+($2>>1),$2&1,$3; + } + + foreach(split("\n",$code)) { + s/\`([^\`]*)\`/eval($1)/geo; + + s/\b[wx]([0-9]+)\b/r$1/go; # new->old registers + s/\bv([0-9])\.[12468]+[bsd]\b/q$1/go; # new->old registers + s/\/\/\s?/@ /o; # new->old style commentary + + # fix up remaining new-style suffixes + s/\{q([0-9]+)\},\s*\[(.+)\],#8/sprintf "{d%d},[$2]!",2*$1/eo or + s/\],#[0-9]+/]!/o; + + s/[v]?(aes\w+)\s+([qv].*)/unaes($1,$2)/geo or + s/cclr\s+([^,]+),\s*([a-z]+)/mov$2 $1,#0/o or + s/vtbl\.8\s+(.*)/unvtbl($1)/geo or + s/vdup\.32\s+(.*)/unvdup32($1)/geo or + s/vmov\.32\s+(.*)/unvmov32($1)/geo or + s/^(\s+)b\./$1b/o or + s/^(\s+)mov\./$1mov/o or + s/^(\s+)ret/$1bx\tlr/o; + + print $_,"\n"; + } +} + +close STDOUT or die "error closing STDOUT: $!"; diff --git a/http/vendor/ring/crypto/fipsmodule/aes/asm/aesv8-gcm-armv8.pl b/http/vendor/ring/crypto/fipsmodule/aes/asm/aesv8-gcm-armv8.pl new file mode 100644 index 0000000..4f862a9 --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/aes/asm/aesv8-gcm-armv8.pl @@ -0,0 +1,1541 @@ +#! /usr/bin/env perl + +# Copyright (c) 2022, ARM Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#======================================================================== +# Written by Fangming Fang for the OpenSSL project, +# derived from https://github.com/ARM-software/AArch64cryptolib, original +# author Samuel Lee . +#======================================================================== +# +# Approach - assume we don't want to reload constants, so reserve ~half of +# vector register file for constants +# +# main loop to act on 4 16B blocks per iteration, and then do modulo of the +# accumulated intermediate hashes from the 4 blocks +# +# ____________________________________________________ +# | | +# | PRE | +# |____________________________________________________| +# | | | | +# | CTR block 4k+8 | AES block 4k+4 | GHASH block 4k+0 | +# |________________|________________|__________________| +# | | | | +# | CTR block 4k+9 | AES block 4k+5 | GHASH block 4k+1 | +# |________________|________________|__________________| +# | | | | +# | CTR block 4k+10| AES block 4k+6 | GHASH block 4k+2 | +# |________________|________________|__________________| +# | | | | +# | CTR block 4k+11| AES block 4k+7 | GHASH block 4k+3 | +# |________________|____(mostly)____|__________________| +# | | +# | MODULO | +# |____________________________________________________| +# +# PRE: Ensure previous generated intermediate hash is aligned and merged with +# result for GHASH 4k+0 +# +# EXT low_acc, low_acc, low_acc, #8 +# EOR res_curr (4k+0), res_curr (4k+0), low_acc +# +# CTR block: Increment and byte reverse counter in scalar registers and transfer +# to SIMD registers +# +# REV ctr32, rev_ctr32 +# ORR ctr64, constctr96_top32, ctr32, LSL #32 +# // Keeping this in scalar registers to free up space in SIMD RF +# INS ctr_next.d[0], constctr96_bottom64 +# INS ctr_next.d[1], ctr64X +# ADD rev_ctr32, #1 +# +# AES block: +# +# Do AES encryption/decryption on CTR block X and EOR it with input block X. +# Take 256 bytes key below for example. Doing small trick here of loading input +# in scalar registers, EORing with last key and then transferring Given we are +# very constrained in our ASIMD registers this is quite important +# +# Encrypt: +# LDR input_low, [ input_ptr ], #8 +# LDR input_high, [ input_ptr ], #8 +# EOR input_low, k14_low +# EOR input_high, k14_high +# INS res_curr.d[0], input_low +# INS res_curr.d[1], input_high +# AESE ctr_curr, k0; AESMC ctr_curr, ctr_curr +# AESE ctr_curr, k1; AESMC ctr_curr, ctr_curr +# AESE ctr_curr, k2; AESMC ctr_curr, ctr_curr +# AESE ctr_curr, k3; AESMC ctr_curr, ctr_curr +# AESE ctr_curr, k4; AESMC ctr_curr, ctr_curr +# AESE ctr_curr, k5; AESMC ctr_curr, ctr_curr +# AESE ctr_curr, k6; AESMC ctr_curr, ctr_curr +# AESE ctr_curr, k7; AESMC ctr_curr, ctr_curr +# AESE ctr_curr, k8; AESMC ctr_curr, ctr_curr +# AESE ctr_curr, k9; AESMC ctr_curr, ctr_curr +# AESE ctr_curr, k10; AESMC ctr_curr, ctr_curr +# AESE ctr_curr, k11; AESMC ctr_curr, ctr_curr +# AESE ctr_curr, k12; AESMC ctr_curr, ctr_curr +# AESE ctr_curr, k13 +# EOR res_curr, res_curr, ctr_curr +# ST1 { res_curr.16b }, [ output_ptr ], #16 +# +# Decrypt: +# AESE ctr_curr, k0; AESMC ctr_curr, ctr_curr +# AESE ctr_curr, k1; AESMC ctr_curr, ctr_curr +# AESE ctr_curr, k2; AESMC ctr_curr, ctr_curr +# AESE ctr_curr, k3; AESMC ctr_curr, ctr_curr +# AESE ctr_curr, k4; AESMC ctr_curr, ctr_curr +# AESE ctr_curr, k5; AESMC ctr_curr, ctr_curr +# AESE ctr_curr, k6; AESMC ctr_curr, ctr_curr +# AESE ctr_curr, k7; AESMC ctr_curr, ctr_curr +# AESE ctr_curr, k8; AESMC ctr_curr, ctr_curr +# AESE ctr_curr, k9; AESMC ctr_curr, ctr_curr +# AESE ctr_curr, k10; AESMC ctr_curr, ctr_curr +# AESE ctr_curr, k11; AESMC ctr_curr, ctr_curr +# AESE ctr_curr, k12; AESMC ctr_curr, ctr_curr +# AESE ctr_curr, k13 +# LDR res_curr, [ input_ptr ], #16 +# EOR res_curr, res_curr, ctr_curr +# MOV output_low, res_curr.d[0] +# MOV output_high, res_curr.d[1] +# EOR output_low, k14_low +# EOR output_high, k14_high +# STP output_low, output_high, [ output_ptr ], #16 +# +# GHASH block X: +# Do 128b karatsuba polynomial multiplication on block. We only have +# 64b->128b polynomial multipliers, naively that means we need to do 4 64b +# multiplies to generate a 128b. +# +# multiplication: +# Pmull(A,B) == (Pmull(Ah,Bh)<<128 | Pmull(Al,Bl)) ^ +# (Pmull(Ah,Bl) ^ Pmull(Al,Bh))<<64 +# +# The idea behind Karatsuba multiplication is that we can do just 3 64b +# multiplies: +# Pmull(A,B) == (Pmull(Ah,Bh)<<128 | Pmull(Al,Bl)) ^ +# (Pmull(Ah^Al,Bh^Bl) ^ Pmull(Ah,Bh) ^ +# Pmull(Al,Bl))<<64 +# +# There is some complication here because the bit order of GHASH's PMULL is +# reversed compared to elsewhere, so we are multiplying with "twisted" +# powers of H +# +# Note: We can PMULL directly into the acc_x in first GHASH of the loop +# +# Note: For scheduling big cores we want to split the processing to happen over +# two loop iterations - otherwise the critical path latency dominates the +# performance. +# +# This has a knock on effect on register pressure, so we have to be a bit +# more clever with our temporary registers than indicated here +# +# REV64 res_curr, res_curr +# INS t_m.d[0], res_curr.d[1] +# EOR t_m.8B, t_m.8B, res_curr.8B +# PMULL2 t_h, res_curr, HX +# PMULL t_l, res_curr, HX +# PMULL t_m, t_m, HX_k +# EOR acc_h, acc_h, t_h +# EOR acc_l, acc_l, t_l +# EOR acc_m, acc_m, t_m +# +# MODULO: take the partial accumulators (~representing sum of 256b +# multiplication results), from GHASH and do modulo reduction on them +# There is some complication here because the bit order of GHASH's +# PMULL is reversed compared to elsewhere, so we are doing modulo with +# a reversed constant +# +# EOR acc_m, acc_m, acc_h +# EOR acc_m, acc_m, acc_l // Finish off karatsuba processing +# PMULL t_mod, acc_h, mod_constant +# EXT acc_h, acc_h, acc_h, #8 +# EOR acc_m, acc_m, acc_h +# EOR acc_m, acc_m, t_mod +# PMULL acc_h, acc_m, mod_constant +# EXT acc_m, acc_m, acc_m, #8 +# EOR acc_l, acc_l, acc_h +# EOR acc_l, acc_l, acc_m +# +# This code was then modified to merge the AES-128-GCM, AES-192-GCM, and +# AES-256-GCM implementations into a single function to reduce size. We move the +# last two round keys into consistent registers across all sizes, as they're +# treated special. Then, after rounds 0 through 8, we added some branches to +# conditionally run rounds 9-10 (AES-192 + AES-256) and 11-12 (AES-256), before +# merging back into code which finishes up the last two rounds. +# +# There is a mostly decision to be made around how much parallel work goes +# before or after the conditional part. We attempted to preserve the original +# scheduling where possible, but it's possible other schedulings are more +# optimal with the current ordering. + +$flavour = shift; +$output = shift; + +$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; +( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or +( $xlate="${dir}../../../perlasm/arm-xlate.pl" and -f $xlate) or +die "can't locate arm-xlate.pl"; + +open OUT,"| \"$^X\" $xlate $flavour $output"; +*STDOUT=*OUT; + +$code=<<___; +#if __ARM_MAX_ARCH__ >= 8 + +.arch armv8-a+crypto +.text +___ + +$input_ptr="x0"; #argument block +$bit_length="x1"; +$output_ptr="x2"; +$current_tag="x3"; +$Htable="x6"; +$counter="x16"; +$cc="x8"; + +{ +my ($end_input_ptr,$main_end_input_ptr,$input_l0,$input_h0)=map("x$_",(4..7)); +my ($input_l1,$input_h1,$input_l2,$input_h2,$input_l3,$input_h3)=map("x$_",(19..24)); +my ($output_l1,$output_h1,$output_l2,$output_h2,$output_l3,$output_h3)=map("x$_",(19..24)); +my ($output_l0,$output_h0)=map("x$_",(6..7)); + +# rkN_l and rkN_h store the final round key, which is handled slightly +# differently because it is EORed through general-purpose registers. +my $ctr32w="w9"; +my ($ctr32x,$ctr96_b64x,$ctr96_t32x,$rctr32x,$rkN_l,$rkN_h,$len)=map("x$_",(9..15)); +my ($ctr96_t32w,$rctr32w)=map("w$_",(11..12)); + +my $rounds="x17"; +my $roundsw="w17"; + +my ($ctr0b,$ctr1b,$ctr2b,$ctr3b,$res0b,$res1b,$res2b,$res3b)=map("v$_.16b",(0..7)); +my ($ctr0,$ctr1,$ctr2,$ctr3,$res0,$res1,$res2,$res3)=map("v$_",(0..7)); +my ($ctr0d,$ctr1d,$ctr2d,$ctr3d,$res0d,$res1d,$res2d,$res3d)=map("d$_",(0..7)); +my ($res0q,$res1q,$res2q,$res3q)=map("q$_",(4..7)); + +my ($acc_hb,$acc_mb,$acc_lb)=map("v$_.16b",(9..11)); +my ($acc_h,$acc_m,$acc_l)=map("v$_",(9..11)); +my ($acc_hd,$acc_md,$acc_ld)=map("d$_",(9..11)); + +my ($h1,$h2,$h3,$h4,$h12k,$h34k)=map("v$_",(12..17)); +my ($h1q,$h2q,$h3q,$h4q)=map("q$_",(12..15)); +my ($h1b,$h2b,$h3b,$h4b)=map("v$_.16b",(12..15)); + +my $t0="v8"; +my $t0d="d8"; +my $t1="v4"; +my $t1d="d4"; +my $t2="v8"; +my $t2d="d8"; +my $t3="v4"; +my $t3d="d4"; +my $t4="v4"; +my $t4d="d4"; +my $t5="v5"; +my $t5d="d5"; +my $t6="v8"; +my $t6d="d8"; +my $t7="v5"; +my $t7d="d5"; +my $t8="v6"; +my $t8d="d6"; +my $t9="v4"; +my $t9d="d4"; + +my ($ctr_t0,$ctr_t1,$ctr_t2,$ctr_t3)=map("v$_",(4..7)); +my ($ctr_t0d,$ctr_t1d,$ctr_t2d,$ctr_t3d)=map("d$_",(4..7)); +my ($ctr_t0b,$ctr_t1b,$ctr_t2b,$ctr_t3b)=map("v$_.16b",(4..7)); + +my $mod_constantd="d8"; +my $mod_constant="v8"; +my $mod_t="v7"; + +# rkNm1 stores the second-to-last round key, which is handled slightly +# differently because it uses plain AESE instead of an AESE + AESMC macro-op. +my ($rk0,$rk1,$rk2,$rk3,$rk4,$rk5,$rk6,$rk7,$rk8,$rk9,$rk10,$rk11,$rk12,$rkNm1)=map("v$_.16b",(18..31)); +my ($rk0q,$rk1q,$rk2q,$rk3q,$rk4q,$rk5q,$rk6q,$rk7q,$rk8q,$rk9q,$rk10q,$rk11q,$rk12q,$rkNm1q)=map("q$_",(18..31)); +my $rk2q1="v20.1q"; +my $rk3q1="v21.1q"; +my $rk4v="v22"; +my $rk4d="d22"; + +################################################################################ +# size_t aes_gcm_enc_kernel(const uint8_t *in, +# size_t len_bits, +# uint8_t *out, +# u64 *Xi, +# uint8_t ivec[16], +# const void *key, +# const void *Htable); +# +$code.=<<___; +.global aes_gcm_enc_kernel +.type aes_gcm_enc_kernel,%function +.align 4 +aes_gcm_enc_kernel: + AARCH64_SIGN_LINK_REGISTER + stp x29, x30, [sp, #-128]! + mov x29, sp + stp x19, x20, [sp, #16] + mov $counter, x4 + mov $cc, x5 + stp x21, x22, [sp, #32] + stp x23, x24, [sp, #48] + stp d8, d9, [sp, #64] + stp d10, d11, [sp, #80] + stp d12, d13, [sp, #96] + stp d14, d15, [sp, #112] + ldr $roundsw, [$cc, #240] + add $input_l1, $cc, $rounds, lsl #4 // borrow input_l1 for last key + ldp $rkN_l, $rkN_h, [$input_l1] // load round N keys + ldr $rkNm1q, [$input_l1, #-16] // load round N-1 keys + add $end_input_ptr, $input_ptr, $bit_length, lsr #3 // end_input_ptr + lsr $main_end_input_ptr, $bit_length, #3 // byte_len + mov $len, $main_end_input_ptr + ldp $ctr96_b64x, $ctr96_t32x, [$counter] // ctr96_b64, ctr96_t32 + ld1 { $ctr0b}, [$counter] // special case vector load initial counter so we can start first AES block as quickly as possible + sub $main_end_input_ptr, $main_end_input_ptr, #1 // byte_len - 1 + ldr $rk0q, [$cc, #0] // load rk0 + and $main_end_input_ptr, $main_end_input_ptr, #0xffffffffffffffc0 // number of bytes to be processed in main loop (at least 1 byte must be handled by tail) + ldr $rk7q, [$cc, #112] // load rk7 + add $main_end_input_ptr, $main_end_input_ptr, $input_ptr + lsr $rctr32x, $ctr96_t32x, #32 + fmov $ctr2d, $ctr96_b64x // CTR block 2 + orr $ctr96_t32w, $ctr96_t32w, $ctr96_t32w + rev $rctr32w, $rctr32w // rev_ctr32 + fmov $ctr1d, $ctr96_b64x // CTR block 1 + aese $ctr0b, $rk0 \n aesmc $ctr0b, $ctr0b // AES block 0 - round 0 + add $rctr32w, $rctr32w, #1 // increment rev_ctr32 + rev $ctr32w, $rctr32w // CTR block 1 + fmov $ctr3d, $ctr96_b64x // CTR block 3 + orr $ctr32x, $ctr96_t32x, $ctr32x, lsl #32 // CTR block 1 + add $rctr32w, $rctr32w, #1 // CTR block 1 + ldr $rk1q, [$cc, #16] // load rk1 + fmov $ctr1.d[1], $ctr32x // CTR block 1 + rev $ctr32w, $rctr32w // CTR block 2 + add $rctr32w, $rctr32w, #1 // CTR block 2 + orr $ctr32x, $ctr96_t32x, $ctr32x, lsl #32 // CTR block 2 + ldr $rk2q, [$cc, #32] // load rk2 + fmov $ctr2.d[1], $ctr32x // CTR block 2 + rev $ctr32w, $rctr32w // CTR block 3 + aese $ctr0b, $rk1 \n aesmc $ctr0b, $ctr0b // AES block 0 - round 1 + orr $ctr32x, $ctr96_t32x, $ctr32x, lsl #32 // CTR block 3 + fmov $ctr3.d[1], $ctr32x // CTR block 3 + aese $ctr1b, $rk0 \n aesmc $ctr1b, $ctr1b // AES block 1 - round 0 + ldr $rk3q, [$cc, #48] // load rk3 + aese $ctr0b, $rk2 \n aesmc $ctr0b, $ctr0b // AES block 0 - round 2 + ldr $rk6q, [$cc, #96] // load rk6 + aese $ctr2b, $rk0 \n aesmc $ctr2b, $ctr2b // AES block 2 - round 0 + ldr $rk5q, [$cc, #80] // load rk5 + aese $ctr1b, $rk1 \n aesmc $ctr1b, $ctr1b // AES block 1 - round 1 + ldr $h3q, [$Htable, #48] // load h3l | h3h + ext $h3b, $h3b, $h3b, #8 + aese $ctr3b, $rk0 \n aesmc $ctr3b, $ctr3b // AES block 3 - round 0 + aese $ctr2b, $rk1 \n aesmc $ctr2b, $ctr2b // AES block 2 - round 1 + ldr $rk4q, [$cc, #64] // load rk4 + aese $ctr1b, $rk2 \n aesmc $ctr1b, $ctr1b // AES block 1 - round 2 + ldr $h2q, [$Htable, #32] // load h2l | h2h + ext $h2b, $h2b, $h2b, #8 + aese $ctr3b, $rk1 \n aesmc $ctr3b, $ctr3b // AES block 3 - round 1 + ldr $rk12q, [$cc, #192] // load rk12 + aese $ctr2b, $rk2 \n aesmc $ctr2b, $ctr2b // AES block 2 - round 2 + ldr $h4q, [$Htable, #80] // load h4l | h4h + ext $h4b, $h4b, $h4b, #8 + aese $ctr1b, $rk3 \n aesmc $ctr1b, $ctr1b // AES block 1 - round 3 + ldr $rk11q, [$cc, #176] // load rk11 + aese $ctr3b, $rk2 \n aesmc $ctr3b, $ctr3b // AES block 3 - round 2 + ldr $rk8q, [$cc, #128] // load rk8 + aese $ctr2b, $rk3 \n aesmc $ctr2b, $ctr2b // AES block 2 - round 3 + add $rctr32w, $rctr32w, #1 // CTR block 3 + aese $ctr0b, $rk3 \n aesmc $ctr0b, $ctr0b // AES block 0 - round 3 + aese $ctr3b, $rk3 \n aesmc $ctr3b, $ctr3b // AES block 3 - round 3 + ld1 { $acc_lb}, [$current_tag] + ext $acc_lb, $acc_lb, $acc_lb, #8 + rev64 $acc_lb, $acc_lb + aese $ctr2b, $rk4 \n aesmc $ctr2b, $ctr2b // AES block 2 - round 4 + aese $ctr0b, $rk4 \n aesmc $ctr0b, $ctr0b // AES block 0 - round 4 + aese $ctr1b, $rk4 \n aesmc $ctr1b, $ctr1b // AES block 1 - round 4 + aese $ctr3b, $rk4 \n aesmc $ctr3b, $ctr3b // AES block 3 - round 4 + cmp $rounds, #12 // setup flags for AES-128/192/256 check + aese $ctr0b, $rk5 \n aesmc $ctr0b, $ctr0b // AES block 0 - round 5 + aese $ctr1b, $rk5 \n aesmc $ctr1b, $ctr1b // AES block 1 - round 5 + aese $ctr3b, $rk5 \n aesmc $ctr3b, $ctr3b // AES block 3 - round 5 + aese $ctr2b, $rk5 \n aesmc $ctr2b, $ctr2b // AES block 2 - round 5 + aese $ctr1b, $rk6 \n aesmc $ctr1b, $ctr1b // AES block 1 - round 6 + trn2 $h34k.2d, $h3.2d, $h4.2d // h4l | h3l + aese $ctr3b, $rk6 \n aesmc $ctr3b, $ctr3b // AES block 3 - round 6 + ldr $rk9q, [$cc, #144] // load rk9 + aese $ctr0b, $rk6 \n aesmc $ctr0b, $ctr0b // AES block 0 - round 6 + ldr $h1q, [$Htable] // load h1l | h1h + ext $h1b, $h1b, $h1b, #8 + aese $ctr2b, $rk6 \n aesmc $ctr2b, $ctr2b // AES block 2 - round 6 + ldr $rk10q, [$cc, #160] // load rk10 + aese $ctr1b, $rk7 \n aesmc $ctr1b, $ctr1b // AES block 1 - round 7 + trn1 $acc_h.2d, $h3.2d, $h4.2d // h4h | h3h + aese $ctr0b, $rk7 \n aesmc $ctr0b, $ctr0b // AES block 0 - round 7 + aese $ctr2b, $rk7 \n aesmc $ctr2b, $ctr2b // AES block 2 - round 7 + aese $ctr3b, $rk7 \n aesmc $ctr3b, $ctr3b // AES block 3 - round 7 + trn2 $h12k.2d, $h1.2d, $h2.2d // h2l | h1l + aese $ctr1b, $rk8 \n aesmc $ctr1b, $ctr1b // AES block 1 - round 8 + aese $ctr2b, $rk8 \n aesmc $ctr2b, $ctr2b // AES block 2 - round 8 + aese $ctr3b, $rk8 \n aesmc $ctr3b, $ctr3b // AES block 3 - round 8 + aese $ctr0b, $rk8 \n aesmc $ctr0b, $ctr0b // AES block 0 - round 8 + b.lt .Lenc_finish_first_blocks // branch if AES-128 + + aese $ctr1b, $rk9 \n aesmc $ctr1b, $ctr1b // AES block 1 - round 9 + aese $ctr2b, $rk9 \n aesmc $ctr2b, $ctr2b // AES block 2 - round 9 + aese $ctr3b, $rk9 \n aesmc $ctr3b, $ctr3b // AES block 3 - round 9 + aese $ctr0b, $rk9 \n aesmc $ctr0b, $ctr0b // AES block 0 - round 9 + aese $ctr1b, $rk10 \n aesmc $ctr1b, $ctr1b // AES block 1 - round 10 + aese $ctr2b, $rk10 \n aesmc $ctr2b, $ctr2b // AES block 2 - round 10 + aese $ctr3b, $rk10 \n aesmc $ctr3b, $ctr3b // AES block 3 - round 10 + aese $ctr0b, $rk10 \n aesmc $ctr0b, $ctr0b // AES block 0 - round 10 + b.eq .Lenc_finish_first_blocks // branch if AES-192 + + aese $ctr1b, $rk11 \n aesmc $ctr1b, $ctr1b // AES block 1 - round 11 + aese $ctr2b, $rk11 \n aesmc $ctr2b, $ctr2b // AES block 2 - round 11 + aese $ctr0b, $rk11 \n aesmc $ctr0b, $ctr0b // AES block 0 - round 11 + aese $ctr3b, $rk11 \n aesmc $ctr3b, $ctr3b // AES block 3 - round 11 + aese $ctr1b, $rk12 \n aesmc $ctr1b, $ctr1b // AES block 1 - round 12 + aese $ctr2b, $rk12 \n aesmc $ctr2b, $ctr2b // AES block 2 - round 12 + aese $ctr0b, $rk12 \n aesmc $ctr0b, $ctr0b // AES block 0 - round 12 + aese $ctr3b, $rk12 \n aesmc $ctr3b, $ctr3b // AES block 3 - round 12 + +.Lenc_finish_first_blocks: + cmp $input_ptr, $main_end_input_ptr // check if we have <= 4 blocks + eor $h34k.16b, $h34k.16b, $acc_h.16b // h4k | h3k + aese $ctr2b, $rkNm1 // AES block 2 - round N-1 + trn1 $t0.2d, $h1.2d, $h2.2d // h2h | h1h + aese $ctr1b, $rkNm1 // AES block 1 - round N-1 + aese $ctr0b, $rkNm1 // AES block 0 - round N-1 + aese $ctr3b, $rkNm1 // AES block 3 - round N-1 + eor $h12k.16b, $h12k.16b, $t0.16b // h2k | h1k + b.ge .Lenc_tail // handle tail + + ldp $input_l1, $input_h1, [$input_ptr, #16] // AES block 1 - load plaintext + rev $ctr32w, $rctr32w // CTR block 4 + ldp $input_l0, $input_h0, [$input_ptr, #0] // AES block 0 - load plaintext + ldp $input_l3, $input_h3, [$input_ptr, #48] // AES block 3 - load plaintext + ldp $input_l2, $input_h2, [$input_ptr, #32] // AES block 2 - load plaintext + add $input_ptr, $input_ptr, #64 // AES input_ptr update + eor $input_l1, $input_l1, $rkN_l // AES block 1 - round N low + eor $input_h1, $input_h1, $rkN_h // AES block 1 - round N high + fmov $ctr_t1d, $input_l1 // AES block 1 - mov low + eor $input_l0, $input_l0, $rkN_l // AES block 0 - round N low + eor $input_h0, $input_h0, $rkN_h // AES block 0 - round N high + eor $input_h3, $input_h3, $rkN_h // AES block 3 - round N high + fmov $ctr_t0d, $input_l0 // AES block 0 - mov low + cmp $input_ptr, $main_end_input_ptr // check if we have <= 8 blocks + fmov $ctr_t0.d[1], $input_h0 // AES block 0 - mov high + eor $input_l3, $input_l3, $rkN_l // AES block 3 - round N low + eor $input_l2, $input_l2, $rkN_l // AES block 2 - round N low + fmov $ctr_t1.d[1], $input_h1 // AES block 1 - mov high + fmov $ctr_t2d, $input_l2 // AES block 2 - mov low + add $rctr32w, $rctr32w, #1 // CTR block 4 + orr $ctr32x, $ctr96_t32x, $ctr32x, lsl #32 // CTR block 4 + fmov $ctr_t3d, $input_l3 // AES block 3 - mov low + eor $input_h2, $input_h2, $rkN_h // AES block 2 - round N high + fmov $ctr_t2.d[1], $input_h2 // AES block 2 - mov high + eor $res0b, $ctr_t0b, $ctr0b // AES block 0 - result + fmov $ctr0d, $ctr96_b64x // CTR block 4 + fmov $ctr0.d[1], $ctr32x // CTR block 4 + rev $ctr32w, $rctr32w // CTR block 5 + add $rctr32w, $rctr32w, #1 // CTR block 5 + eor $res1b, $ctr_t1b, $ctr1b // AES block 1 - result + fmov $ctr1d, $ctr96_b64x // CTR block 5 + orr $ctr32x, $ctr96_t32x, $ctr32x, lsl #32 // CTR block 5 + fmov $ctr1.d[1], $ctr32x // CTR block 5 + rev $ctr32w, $rctr32w // CTR block 6 + st1 { $res0b}, [$output_ptr], #16 // AES block 0 - store result + fmov $ctr_t3.d[1], $input_h3 // AES block 3 - mov high + orr $ctr32x, $ctr96_t32x, $ctr32x, lsl #32 // CTR block 6 + eor $res2b, $ctr_t2b, $ctr2b // AES block 2 - result + st1 { $res1b}, [$output_ptr], #16 // AES block 1 - store result + add $rctr32w, $rctr32w, #1 // CTR block 6 + fmov $ctr2d, $ctr96_b64x // CTR block 6 + fmov $ctr2.d[1], $ctr32x // CTR block 6 + st1 { $res2b}, [$output_ptr], #16 // AES block 2 - store result + rev $ctr32w, $rctr32w // CTR block 7 + orr $ctr32x, $ctr96_t32x, $ctr32x, lsl #32 // CTR block 7 + eor $res3b, $ctr_t3b, $ctr3b // AES block 3 - result + st1 { $res3b}, [$output_ptr], #16 // AES block 3 - store result + b.ge .Lenc_prepretail // do prepretail + +.Lenc_main_loop: // main loop start + aese $ctr0b, $rk0 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 0 + rev64 $res0b, $res0b // GHASH block 4k (only t0 is free) + aese $ctr1b, $rk0 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 0 + fmov $ctr3d, $ctr96_b64x // CTR block 4k+3 + aese $ctr2b, $rk0 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 0 + ext $acc_lb, $acc_lb, $acc_lb, #8 // PRE 0 + aese $ctr0b, $rk1 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 1 + fmov $ctr3.d[1], $ctr32x // CTR block 4k+3 + aese $ctr1b, $rk1 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 1 + ldp $input_l3, $input_h3, [$input_ptr, #48] // AES block 4k+7 - load plaintext + aese $ctr2b, $rk1 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 1 + ldp $input_l2, $input_h2, [$input_ptr, #32] // AES block 4k+6 - load plaintext + aese $ctr0b, $rk2 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 2 + eor $res0b, $res0b, $acc_lb // PRE 1 + aese $ctr1b, $rk2 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 2 + aese $ctr3b, $rk0 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 0 + eor $input_l3, $input_l3, $rkN_l // AES block 4k+7 - round N low + aese $ctr0b, $rk3 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 3 + mov $acc_md, $h34k.d[1] // GHASH block 4k - mid + pmull2 $acc_h.1q, $res0.2d, $h4.2d // GHASH block 4k - high + eor $input_h2, $input_h2, $rkN_h // AES block 4k+6 - round N high + mov $t0d, $res0.d[1] // GHASH block 4k - mid + aese $ctr3b, $rk1 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 1 + rev64 $res1b, $res1b // GHASH block 4k+1 (t0 and t1 free) + aese $ctr0b, $rk4 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 4 + pmull $acc_l.1q, $res0.1d, $h4.1d // GHASH block 4k - low + eor $t0.8b, $t0.8b, $res0.8b // GHASH block 4k - mid + aese $ctr2b, $rk2 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 2 + aese $ctr0b, $rk5 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 5 + rev64 $res3b, $res3b // GHASH block 4k+3 (t0, t1, t2 and t3 free) + pmull2 $t1.1q, $res1.2d, $h3.2d // GHASH block 4k+1 - high + pmull $acc_m.1q, $t0.1d, $acc_m.1d // GHASH block 4k - mid + rev64 $res2b, $res2b // GHASH block 4k+2 (t0, t1, and t2 free) + pmull $t2.1q, $res1.1d, $h3.1d // GHASH block 4k+1 - low + eor $acc_hb, $acc_hb, $t1.16b // GHASH block 4k+1 - high + mov $t3d, $res1.d[1] // GHASH block 4k+1 - mid + aese $ctr1b, $rk3 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 3 + aese $ctr3b, $rk2 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 2 + eor $acc_lb, $acc_lb, $t2.16b // GHASH block 4k+1 - low + aese $ctr2b, $rk3 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 3 + aese $ctr1b, $rk4 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 4 + mov $t6d, $res2.d[1] // GHASH block 4k+2 - mid + aese $ctr3b, $rk3 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 3 + eor $t3.8b, $t3.8b, $res1.8b // GHASH block 4k+1 - mid + aese $ctr2b, $rk4 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 4 + aese $ctr0b, $rk6 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 6 + eor $t6.8b, $t6.8b, $res2.8b // GHASH block 4k+2 - mid + aese $ctr3b, $rk4 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 4 + pmull $t3.1q, $t3.1d, $h34k.1d // GHASH block 4k+1 - mid + aese $ctr0b, $rk7 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 7 + aese $ctr3b, $rk5 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 5 + ins $t6.d[1], $t6.d[0] // GHASH block 4k+2 - mid + aese $ctr1b, $rk5 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 5 + aese $ctr0b, $rk8 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 8 + aese $ctr2b, $rk5 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 5 + aese $ctr1b, $rk6 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 6 + eor $acc_mb, $acc_mb, $t3.16b // GHASH block 4k+1 - mid + pmull2 $t4.1q, $res2.2d, $h2.2d // GHASH block 4k+2 - high + pmull $t5.1q, $res2.1d, $h2.1d // GHASH block 4k+2 - low + aese $ctr1b, $rk7 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 7 + pmull $t8.1q, $res3.1d, $h1.1d // GHASH block 4k+3 - low + eor $acc_hb, $acc_hb, $t4.16b // GHASH block 4k+2 - high + aese $ctr3b, $rk6 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 6 + ldp $input_l1, $input_h1, [$input_ptr, #16] // AES block 4k+5 - load plaintext + aese $ctr1b, $rk8 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 8 + mov $t9d, $res3.d[1] // GHASH block 4k+3 - mid + aese $ctr2b, $rk6 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 6 + eor $acc_lb, $acc_lb, $t5.16b // GHASH block 4k+2 - low + pmull2 $t6.1q, $t6.2d, $h12k.2d // GHASH block 4k+2 - mid + pmull2 $t7.1q, $res3.2d, $h1.2d // GHASH block 4k+3 - high + eor $t9.8b, $t9.8b, $res3.8b // GHASH block 4k+3 - mid + aese $ctr2b, $rk7 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 7 + eor $input_l1, $input_l1, $rkN_l // AES block 4k+5 - round N low + aese $ctr2b, $rk8 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 8 + eor $acc_mb, $acc_mb, $t6.16b // GHASH block 4k+2 - mid + aese $ctr3b, $rk7 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 7 + eor $input_l2, $input_l2, $rkN_l // AES block 4k+6 - round N low + aese $ctr3b, $rk8 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 8 + movi $mod_constant.8b, #0xc2 + pmull $t9.1q, $t9.1d, $h12k.1d // GHASH block 4k+3 - mid + eor $acc_hb, $acc_hb, $t7.16b // GHASH block 4k+3 - high + cmp $rounds, #12 // setup flags for AES-128/192/256 check + fmov $ctr_t1d, $input_l1 // AES block 4k+5 - mov low + ldp $input_l0, $input_h0, [$input_ptr, #0] // AES block 4k+4 - load plaintext + b.lt .Lenc_main_loop_continue // branch if AES-128 + + aese $ctr1b, $rk9 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 9 + aese $ctr0b, $rk9 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 9 + aese $ctr2b, $rk9 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 9 + aese $ctr3b, $rk9 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 9 + aese $ctr0b, $rk10 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 10 + aese $ctr1b, $rk10 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 10 + aese $ctr2b, $rk10 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 10 + aese $ctr3b, $rk10 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 10 + b.eq .Lenc_main_loop_continue // branch if AES-192 + + aese $ctr0b, $rk11 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 11 + aese $ctr1b, $rk11 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 11 + aese $ctr2b, $rk11 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 11 + aese $ctr3b, $rk11 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 11 + aese $ctr1b, $rk12 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 12 + aese $ctr0b, $rk12 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 12 + aese $ctr2b, $rk12 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 12 + aese $ctr3b, $rk12 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 12 + +.Lenc_main_loop_continue: + shl $mod_constantd, $mod_constantd, #56 // mod_constant + eor $acc_lb, $acc_lb, $t8.16b // GHASH block 4k+3 - low + eor $acc_mb, $acc_mb, $t9.16b // GHASH block 4k+3 - mid + add $rctr32w, $rctr32w, #1 // CTR block 4k+3 + eor $t9.16b, $acc_lb, $acc_hb // MODULO - karatsuba tidy up + add $input_ptr, $input_ptr, #64 // AES input_ptr update + pmull $mod_t.1q, $acc_h.1d, $mod_constant.1d // MODULO - top 64b align with mid + rev $ctr32w, $rctr32w // CTR block 4k+8 + ext $acc_hb, $acc_hb, $acc_hb, #8 // MODULO - other top alignment + eor $input_l0, $input_l0, $rkN_l // AES block 4k+4 - round N low + eor $acc_mb, $acc_mb, $t9.16b // MODULO - karatsuba tidy up + eor $input_h0, $input_h0, $rkN_h // AES block 4k+4 - round N high + fmov $ctr_t0d, $input_l0 // AES block 4k+4 - mov low + orr $ctr32x, $ctr96_t32x, $ctr32x, lsl #32 // CTR block 4k+8 + eor $mod_t.16b, $acc_hb, $mod_t.16b // MODULO - fold into mid + eor $input_h1, $input_h1, $rkN_h // AES block 4k+5 - round N high + eor $input_h3, $input_h3, $rkN_h // AES block 4k+7 - round N high + add $rctr32w, $rctr32w, #1 // CTR block 4k+8 + aese $ctr0b, $rkNm1 // AES block 4k+4 - round N-1 + fmov $ctr_t0.d[1], $input_h0 // AES block 4k+4 - mov high + eor $acc_mb, $acc_mb, $mod_t.16b // MODULO - fold into mid + fmov $ctr_t3d, $input_l3 // AES block 4k+7 - mov low + aese $ctr1b, $rkNm1 // AES block 4k+5 - round N-1 + fmov $ctr_t1.d[1], $input_h1 // AES block 4k+5 - mov high + fmov $ctr_t2d, $input_l2 // AES block 4k+6 - mov low + cmp $input_ptr, $main_end_input_ptr // LOOP CONTROL + fmov $ctr_t2.d[1], $input_h2 // AES block 4k+6 - mov high + pmull $acc_h.1q, $acc_m.1d, $mod_constant.1d // MODULO - mid 64b align with low + eor $res0b, $ctr_t0b, $ctr0b // AES block 4k+4 - result + fmov $ctr0d, $ctr96_b64x // CTR block 4k+8 + fmov $ctr0.d[1], $ctr32x // CTR block 4k+8 + rev $ctr32w, $rctr32w // CTR block 4k+9 + add $rctr32w, $rctr32w, #1 // CTR block 4k+9 + eor $res1b, $ctr_t1b, $ctr1b // AES block 4k+5 - result + fmov $ctr1d, $ctr96_b64x // CTR block 4k+9 + orr $ctr32x, $ctr96_t32x, $ctr32x, lsl #32 // CTR block 4k+9 + fmov $ctr1.d[1], $ctr32x // CTR block 4k+9 + aese $ctr2b, $rkNm1 // AES block 4k+6 - round N-1 + rev $ctr32w, $rctr32w // CTR block 4k+10 + st1 { $res0b}, [$output_ptr], #16 // AES block 4k+4 - store result + orr $ctr32x, $ctr96_t32x, $ctr32x, lsl #32 // CTR block 4k+10 + eor $acc_lb, $acc_lb, $acc_hb // MODULO - fold into low + fmov $ctr_t3.d[1], $input_h3 // AES block 4k+7 - mov high + ext $acc_mb, $acc_mb, $acc_mb, #8 // MODULO - other mid alignment + st1 { $res1b}, [$output_ptr], #16 // AES block 4k+5 - store result + add $rctr32w, $rctr32w, #1 // CTR block 4k+10 + aese $ctr3b, $rkNm1 // AES block 4k+7 - round N-1 + eor $res2b, $ctr_t2b, $ctr2b // AES block 4k+6 - result + fmov $ctr2d, $ctr96_b64x // CTR block 4k+10 + st1 { $res2b}, [$output_ptr], #16 // AES block 4k+6 - store result + fmov $ctr2.d[1], $ctr32x // CTR block 4k+10 + rev $ctr32w, $rctr32w // CTR block 4k+11 + eor $acc_lb, $acc_lb, $acc_mb // MODULO - fold into low + orr $ctr32x, $ctr96_t32x, $ctr32x, lsl #32 // CTR block 4k+11 + eor $res3b, $ctr_t3b, $ctr3b // AES block 4k+7 - result + st1 { $res3b}, [$output_ptr], #16 // AES block 4k+7 - store result + b.lt .Lenc_main_loop + +.Lenc_prepretail: // PREPRETAIL + aese $ctr1b, $rk0 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 0 + rev64 $res2b, $res2b // GHASH block 4k+2 (t0, t1, and t2 free) + aese $ctr2b, $rk0 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 0 + fmov $ctr3d, $ctr96_b64x // CTR block 4k+3 + aese $ctr0b, $rk0 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 0 + rev64 $res0b, $res0b // GHASH block 4k (only t0 is free) + fmov $ctr3.d[1], $ctr32x // CTR block 4k+3 + ext $acc_lb, $acc_lb, $acc_lb, #8 // PRE 0 + aese $ctr2b, $rk1 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 1 + aese $ctr0b, $rk1 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 1 + eor $res0b, $res0b, $acc_lb // PRE 1 + rev64 $res1b, $res1b // GHASH block 4k+1 (t0 and t1 free) + aese $ctr2b, $rk2 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 2 + aese $ctr3b, $rk0 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 0 + mov $acc_md, $h34k.d[1] // GHASH block 4k - mid + aese $ctr1b, $rk1 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 1 + pmull $acc_l.1q, $res0.1d, $h4.1d // GHASH block 4k - low + mov $t0d, $res0.d[1] // GHASH block 4k - mid + pmull2 $acc_h.1q, $res0.2d, $h4.2d // GHASH block 4k - high + aese $ctr2b, $rk3 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 3 + aese $ctr1b, $rk2 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 2 + eor $t0.8b, $t0.8b, $res0.8b // GHASH block 4k - mid + aese $ctr0b, $rk2 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 2 + aese $ctr3b, $rk1 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 1 + aese $ctr1b, $rk3 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 3 + pmull $acc_m.1q, $t0.1d, $acc_m.1d // GHASH block 4k - mid + pmull2 $t1.1q, $res1.2d, $h3.2d // GHASH block 4k+1 - high + pmull $t2.1q, $res1.1d, $h3.1d // GHASH block 4k+1 - low + aese $ctr3b, $rk2 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 2 + eor $acc_hb, $acc_hb, $t1.16b // GHASH block 4k+1 - high + mov $t3d, $res1.d[1] // GHASH block 4k+1 - mid + aese $ctr0b, $rk3 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 3 + eor $acc_lb, $acc_lb, $t2.16b // GHASH block 4k+1 - low + aese $ctr3b, $rk3 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 3 + eor $t3.8b, $t3.8b, $res1.8b // GHASH block 4k+1 - mid + mov $t6d, $res2.d[1] // GHASH block 4k+2 - mid + aese $ctr0b, $rk4 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 4 + rev64 $res3b, $res3b // GHASH block 4k+3 (t0, t1, t2 and t3 free) + aese $ctr3b, $rk4 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 4 + pmull $t3.1q, $t3.1d, $h34k.1d // GHASH block 4k+1 - mid + eor $t6.8b, $t6.8b, $res2.8b // GHASH block 4k+2 - mid + add $rctr32w, $rctr32w, #1 // CTR block 4k+3 + pmull $t5.1q, $res2.1d, $h2.1d // GHASH block 4k+2 - low + aese $ctr3b, $rk5 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 5 + aese $ctr2b, $rk4 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 4 + eor $acc_mb, $acc_mb, $t3.16b // GHASH block 4k+1 - mid + pmull2 $t4.1q, $res2.2d, $h2.2d // GHASH block 4k+2 - high + eor $acc_lb, $acc_lb, $t5.16b // GHASH block 4k+2 - low + ins $t6.d[1], $t6.d[0] // GHASH block 4k+2 - mid + aese $ctr2b, $rk5 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 5 + eor $acc_hb, $acc_hb, $t4.16b // GHASH block 4k+2 - high + mov $t9d, $res3.d[1] // GHASH block 4k+3 - mid + aese $ctr1b, $rk4 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 4 + pmull2 $t6.1q, $t6.2d, $h12k.2d // GHASH block 4k+2 - mid + eor $t9.8b, $t9.8b, $res3.8b // GHASH block 4k+3 - mid + pmull2 $t7.1q, $res3.2d, $h1.2d // GHASH block 4k+3 - high + aese $ctr1b, $rk5 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 5 + pmull $t9.1q, $t9.1d, $h12k.1d // GHASH block 4k+3 - mid + eor $acc_mb, $acc_mb, $t6.16b // GHASH block 4k+2 - mid + aese $ctr0b, $rk5 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 5 + aese $ctr1b, $rk6 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 6 + aese $ctr2b, $rk6 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 6 + aese $ctr0b, $rk6 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 6 + movi $mod_constant.8b, #0xc2 + aese $ctr3b, $rk6 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 6 + aese $ctr1b, $rk7 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 7 + eor $acc_hb, $acc_hb, $t7.16b // GHASH block 4k+3 - high + aese $ctr0b, $rk7 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 7 + aese $ctr3b, $rk7 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 7 + shl $mod_constantd, $mod_constantd, #56 // mod_constant + aese $ctr1b, $rk8 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 8 + eor $acc_mb, $acc_mb, $t9.16b // GHASH block 4k+3 - mid + pmull $t8.1q, $res3.1d, $h1.1d // GHASH block 4k+3 - low + aese $ctr3b, $rk8 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 8 + cmp $rounds, #12 // setup flags for AES-128/192/256 check + aese $ctr0b, $rk8 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 8 + eor $acc_lb, $acc_lb, $t8.16b // GHASH block 4k+3 - low + aese $ctr2b, $rk7 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 7 + eor $acc_mb, $acc_mb, $acc_hb // karatsuba tidy up + aese $ctr2b, $rk8 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 8 + pmull $t1.1q, $acc_h.1d, $mod_constant.1d + ext $acc_hb, $acc_hb, $acc_hb, #8 + eor $acc_mb, $acc_mb, $acc_lb + b.lt .Lenc_finish_prepretail // branch if AES-128 + + aese $ctr1b, $rk9 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 9 + aese $ctr3b, $rk9 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 9 + aese $ctr0b, $rk9 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 9 + aese $ctr2b, $rk9 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 9 + aese $ctr3b, $rk10 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 10 + aese $ctr1b, $rk10 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 10 + aese $ctr0b, $rk10 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 10 + aese $ctr2b, $rk10 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 10 + b.eq .Lenc_finish_prepretail // branch if AES-192 + + aese $ctr1b, $rk11 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 11 + aese $ctr0b, $rk11 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 11 + aese $ctr3b, $rk11 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 11 + aese $ctr2b, $rk11 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 11 + aese $ctr1b, $rk12 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 12 + aese $ctr0b, $rk12 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 12 + aese $ctr3b, $rk12 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 12 + aese $ctr2b, $rk12 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 12 + +.Lenc_finish_prepretail: + eor $acc_mb, $acc_mb, $t1.16b + eor $acc_mb, $acc_mb, $acc_hb + pmull $t1.1q, $acc_m.1d, $mod_constant.1d + ext $acc_mb, $acc_mb, $acc_mb, #8 + aese $ctr1b, $rkNm1 // AES block 4k+5 - round N-1 + eor $acc_lb, $acc_lb, $t1.16b + aese $ctr3b, $rkNm1 // AES block 4k+7 - round N-1 + aese $ctr0b, $rkNm1 // AES block 4k+4 - round N-1 + aese $ctr2b, $rkNm1 // AES block 4k+6 - round N-1 + eor $acc_lb, $acc_lb, $acc_mb + +.Lenc_tail: // TAIL + ext $t0.16b, $acc_lb, $acc_lb, #8 // prepare final partial tag + sub $main_end_input_ptr, $end_input_ptr, $input_ptr // main_end_input_ptr is number of bytes left to process + ldp $input_l0, $input_h0, [$input_ptr], #16 // AES block 4k+4 - load plaintext + eor $input_l0, $input_l0, $rkN_l // AES block 4k+4 - round N low + eor $input_h0, $input_h0, $rkN_h // AES block 4k+4 - round N high + cmp $main_end_input_ptr, #48 + fmov $ctr_t0d, $input_l0 // AES block 4k+4 - mov low + fmov $ctr_t0.d[1], $input_h0 // AES block 4k+4 - mov high + eor $res1b, $ctr_t0b, $ctr0b // AES block 4k+4 - result + b.gt .Lenc_blocks_more_than_3 + cmp $main_end_input_ptr, #32 + mov $ctr3b, $ctr2b + movi $acc_l.8b, #0 + movi $acc_h.8b, #0 + sub $rctr32w, $rctr32w, #1 + mov $ctr2b, $ctr1b + movi $acc_m.8b, #0 + b.gt .Lenc_blocks_more_than_2 + mov $ctr3b, $ctr1b + sub $rctr32w, $rctr32w, #1 + cmp $main_end_input_ptr, #16 + b.gt .Lenc_blocks_more_than_1 + sub $rctr32w, $rctr32w, #1 + b .Lenc_blocks_less_than_1 +.Lenc_blocks_more_than_3: // blocks left > 3 + st1 { $res1b}, [$output_ptr], #16 // AES final-3 block - store result + ldp $input_l0, $input_h0, [$input_ptr], #16 // AES final-2 block - load input low & high + rev64 $res0b, $res1b // GHASH final-3 block + eor $input_l0, $input_l0, $rkN_l // AES final-2 block - round N low + eor $res0b, $res0b, $t0.16b // feed in partial tag + eor $input_h0, $input_h0, $rkN_h // AES final-2 block - round N high + mov $rk4d, $res0.d[1] // GHASH final-3 block - mid + fmov $res1d, $input_l0 // AES final-2 block - mov low + fmov $res1.d[1], $input_h0 // AES final-2 block - mov high + eor $rk4v.8b, $rk4v.8b, $res0.8b // GHASH final-3 block - mid + movi $t0.8b, #0 // suppress further partial tag feed in + mov $acc_md, $h34k.d[1] // GHASH final-3 block - mid + pmull $acc_l.1q, $res0.1d, $h4.1d // GHASH final-3 block - low + pmull2 $acc_h.1q, $res0.2d, $h4.2d // GHASH final-3 block - high + pmull $acc_m.1q, $rk4v.1d, $acc_m.1d // GHASH final-3 block - mid + eor $res1b, $res1b, $ctr1b // AES final-2 block - result +.Lenc_blocks_more_than_2: // blocks left > 2 + st1 { $res1b}, [$output_ptr], #16 // AES final-2 block - store result + ldp $input_l0, $input_h0, [$input_ptr], #16 // AES final-1 block - load input low & high + rev64 $res0b, $res1b // GHASH final-2 block + eor $input_l0, $input_l0, $rkN_l // AES final-1 block - round N low + eor $res0b, $res0b, $t0.16b // feed in partial tag + fmov $res1d, $input_l0 // AES final-1 block - mov low + eor $input_h0, $input_h0, $rkN_h // AES final-1 block - round N high + fmov $res1.d[1], $input_h0 // AES final-1 block - mov high + movi $t0.8b, #0 // suppress further partial tag feed in + pmull2 $rk2q1, $res0.2d, $h3.2d // GHASH final-2 block - high + mov $rk4d, $res0.d[1] // GHASH final-2 block - mid + pmull $rk3q1, $res0.1d, $h3.1d // GHASH final-2 block - low + eor $rk4v.8b, $rk4v.8b, $res0.8b // GHASH final-2 block - mid + eor $res1b, $res1b, $ctr2b // AES final-1 block - result + eor $acc_hb, $acc_hb, $rk2 // GHASH final-2 block - high + pmull $rk4v.1q, $rk4v.1d, $h34k.1d // GHASH final-2 block - mid + eor $acc_lb, $acc_lb, $rk3 // GHASH final-2 block - low + eor $acc_mb, $acc_mb, $rk4v.16b // GHASH final-2 block - mid +.Lenc_blocks_more_than_1: // blocks left > 1 + st1 { $res1b}, [$output_ptr], #16 // AES final-1 block - store result + rev64 $res0b, $res1b // GHASH final-1 block + ldp $input_l0, $input_h0, [$input_ptr], #16 // AES final block - load input low & high + eor $res0b, $res0b, $t0.16b // feed in partial tag + movi $t0.8b, #0 // suppress further partial tag feed in + eor $input_l0, $input_l0, $rkN_l // AES final block - round N low + mov $rk4d, $res0.d[1] // GHASH final-1 block - mid + pmull2 $rk2q1, $res0.2d, $h2.2d // GHASH final-1 block - high + eor $input_h0, $input_h0, $rkN_h // AES final block - round N high + eor $rk4v.8b, $rk4v.8b, $res0.8b // GHASH final-1 block - mid + eor $acc_hb, $acc_hb, $rk2 // GHASH final-1 block - high + ins $rk4v.d[1], $rk4v.d[0] // GHASH final-1 block - mid + fmov $res1d, $input_l0 // AES final block - mov low + fmov $res1.d[1], $input_h0 // AES final block - mov high + pmull2 $rk4v.1q, $rk4v.2d, $h12k.2d // GHASH final-1 block - mid + pmull $rk3q1, $res0.1d, $h2.1d // GHASH final-1 block - low + eor $res1b, $res1b, $ctr3b // AES final block - result + eor $acc_mb, $acc_mb, $rk4v.16b // GHASH final-1 block - mid + eor $acc_lb, $acc_lb, $rk3 // GHASH final-1 block - low +.Lenc_blocks_less_than_1: // blocks left <= 1 + and $bit_length, $bit_length, #127 // bit_length %= 128 + mvn $rkN_l, xzr // rkN_l = 0xffffffffffffffff + sub $bit_length, $bit_length, #128 // bit_length -= 128 + neg $bit_length, $bit_length // bit_length = 128 - #bits in input (in range [1,128]) + ld1 { $rk0}, [$output_ptr] // load existing bytes where the possibly partial last block is to be stored + mvn $rkN_h, xzr // rkN_h = 0xffffffffffffffff + and $bit_length, $bit_length, #127 // bit_length %= 128 + lsr $rkN_h, $rkN_h, $bit_length // rkN_h is mask for top 64b of last block + cmp $bit_length, #64 + csel $input_l0, $rkN_l, $rkN_h, lt + csel $input_h0, $rkN_h, xzr, lt + fmov $ctr0d, $input_l0 // ctr0b is mask for last block + fmov $ctr0.d[1], $input_h0 + and $res1b, $res1b, $ctr0b // possibly partial last block has zeroes in highest bits + rev64 $res0b, $res1b // GHASH final block + eor $res0b, $res0b, $t0.16b // feed in partial tag + bif $res1b, $rk0, $ctr0b // insert existing bytes in top end of result before storing + pmull2 $rk2q1, $res0.2d, $h1.2d // GHASH final block - high + mov $t0d, $res0.d[1] // GHASH final block - mid + rev $ctr32w, $rctr32w + pmull $rk3q1, $res0.1d, $h1.1d // GHASH final block - low + eor $acc_hb, $acc_hb, $rk2 // GHASH final block - high + eor $t0.8b, $t0.8b, $res0.8b // GHASH final block - mid + pmull $t0.1q, $t0.1d, $h12k.1d // GHASH final block - mid + eor $acc_lb, $acc_lb, $rk3 // GHASH final block - low + eor $acc_mb, $acc_mb, $t0.16b // GHASH final block - mid + movi $mod_constant.8b, #0xc2 + eor $t9.16b, $acc_lb, $acc_hb // MODULO - karatsuba tidy up + shl $mod_constantd, $mod_constantd, #56 // mod_constant + eor $acc_mb, $acc_mb, $t9.16b // MODULO - karatsuba tidy up + pmull $mod_t.1q, $acc_h.1d, $mod_constant.1d // MODULO - top 64b align with mid + ext $acc_hb, $acc_hb, $acc_hb, #8 // MODULO - other top alignment + eor $acc_mb, $acc_mb, $mod_t.16b // MODULO - fold into mid + eor $acc_mb, $acc_mb, $acc_hb // MODULO - fold into mid + pmull $acc_h.1q, $acc_m.1d, $mod_constant.1d // MODULO - mid 64b align with low + ext $acc_mb, $acc_mb, $acc_mb, #8 // MODULO - other mid alignment + str $ctr32w, [$counter, #12] // store the updated counter + st1 { $res1b}, [$output_ptr] // store all 16B + eor $acc_lb, $acc_lb, $acc_hb // MODULO - fold into low + eor $acc_lb, $acc_lb, $acc_mb // MODULO - fold into low + ext $acc_lb, $acc_lb, $acc_lb, #8 + rev64 $acc_lb, $acc_lb + mov x0, $len + st1 { $acc_l.16b }, [$current_tag] + ldp x19, x20, [sp, #16] + ldp x21, x22, [sp, #32] + ldp x23, x24, [sp, #48] + ldp d8, d9, [sp, #64] + ldp d10, d11, [sp, #80] + ldp d12, d13, [sp, #96] + ldp d14, d15, [sp, #112] + ldp x29, x30, [sp], #128 + AARCH64_VALIDATE_LINK_REGISTER + ret +.size aes_gcm_enc_kernel,.-aes_gcm_enc_kernel +___ + +{ +my $t8="v4"; +my $t8d="d4"; +my $t9="v6"; +my $t9d="d6"; +################################################################################ +# size_t aes_gcm_dec_kernel(const uint8_t *in, +# size_t len_bits, +# uint8_t *out, +# u64 *Xi, +# uint8_t ivec[16], +# const void *key); +# +$code.=<<___; +.global aes_gcm_dec_kernel +.type aes_gcm_dec_kernel,%function +.align 4 +aes_gcm_dec_kernel: + AARCH64_SIGN_LINK_REGISTER + stp x29, x30, [sp, #-128]! + mov x29, sp + stp x19, x20, [sp, #16] + mov $counter, x4 + mov $cc, x5 + stp x21, x22, [sp, #32] + stp x23, x24, [sp, #48] + stp d8, d9, [sp, #64] + stp d10, d11, [sp, #80] + stp d12, d13, [sp, #96] + stp d14, d15, [sp, #112] + ldr $roundsw, [$cc, #240] + add $input_l1, $cc, $rounds, lsl #4 // borrow input_l1 for last key + ldp $rkN_l, $rkN_h, [$input_l1] // load round N keys + ldr $rkNm1q, [$input_l1, #-16] // load round N-1 keys + lsr $main_end_input_ptr, $bit_length, #3 // byte_len + mov $len, $main_end_input_ptr + ldp $ctr96_b64x, $ctr96_t32x, [$counter] // ctr96_b64, ctr96_t32 + ldr $rk8q, [$cc, #128] // load rk8 + sub $main_end_input_ptr, $main_end_input_ptr, #1 // byte_len - 1 + ldr $rk7q, [$cc, #112] // load rk7 + and $main_end_input_ptr, $main_end_input_ptr, #0xffffffffffffffc0 // number of bytes to be processed in main loop (at least 1 byte must be handled by tail) + add $end_input_ptr, $input_ptr, $bit_length, lsr #3 // end_input_ptr + ldr $rk6q, [$cc, #96] // load rk6 + lsr $rctr32x, $ctr96_t32x, #32 + ldr $rk5q, [$cc, #80] // load rk5 + orr $ctr96_t32w, $ctr96_t32w, $ctr96_t32w + ldr $rk3q, [$cc, #48] // load rk3 + add $main_end_input_ptr, $main_end_input_ptr, $input_ptr + rev $rctr32w, $rctr32w // rev_ctr32 + add $rctr32w, $rctr32w, #1 // increment rev_ctr32 + fmov $ctr3d, $ctr96_b64x // CTR block 3 + rev $ctr32w, $rctr32w // CTR block 1 + add $rctr32w, $rctr32w, #1 // CTR block 1 + fmov $ctr1d, $ctr96_b64x // CTR block 1 + orr $ctr32x, $ctr96_t32x, $ctr32x, lsl #32 // CTR block 1 + ld1 { $ctr0b}, [$counter] // special case vector load initial counter so we can start first AES block as quickly as possible + fmov $ctr1.d[1], $ctr32x // CTR block 1 + rev $ctr32w, $rctr32w // CTR block 2 + add $rctr32w, $rctr32w, #1 // CTR block 2 + fmov $ctr2d, $ctr96_b64x // CTR block 2 + orr $ctr32x, $ctr96_t32x, $ctr32x, lsl #32 // CTR block 2 + fmov $ctr2.d[1], $ctr32x // CTR block 2 + rev $ctr32w, $rctr32w // CTR block 3 + orr $ctr32x, $ctr96_t32x, $ctr32x, lsl #32 // CTR block 3 + ldr $rk0q, [$cc, #0] // load rk0 + fmov $ctr3.d[1], $ctr32x // CTR block 3 + add $rctr32w, $rctr32w, #1 // CTR block 3 + ldr $rk4q, [$cc, #64] // load rk4 + ldr $rk1q, [$cc, #16] // load rk1 + aese $ctr0b, $rk0 \n aesmc $ctr0b, $ctr0b // AES block 0 - round 0 + ldr $h3q, [$Htable, #48] // load h3l | h3h + ext $h3b, $h3b, $h3b, #8 + aese $ctr3b, $rk0 \n aesmc $ctr3b, $ctr3b // AES block 3 - round 0 + ldr $h4q, [$Htable, #80] // load h4l | h4h + ext $h4b, $h4b, $h4b, #8 + aese $ctr1b, $rk0 \n aesmc $ctr1b, $ctr1b // AES block 1 - round 0 + ldr $h2q, [$Htable, #32] // load h2l | h2h + ext $h2b, $h2b, $h2b, #8 + aese $ctr2b, $rk0 \n aesmc $ctr2b, $ctr2b // AES block 2 - round 0 + ldr $rk2q, [$cc, #32] // load rk2 + aese $ctr0b, $rk1 \n aesmc $ctr0b, $ctr0b // AES block 0 - round 1 + aese $ctr1b, $rk1 \n aesmc $ctr1b, $ctr1b // AES block 1 - round 1 + ld1 { $acc_lb}, [$current_tag] + ext $acc_lb, $acc_lb, $acc_lb, #8 + rev64 $acc_lb, $acc_lb + aese $ctr2b, $rk1 \n aesmc $ctr2b, $ctr2b // AES block 2 - round 1 + ldr $rk9q, [$cc, #144] // load rk9 + aese $ctr3b, $rk1 \n aesmc $ctr3b, $ctr3b // AES block 3 - round 1 + ldr $rk12q, [$cc, #192] // load rk12 + aese $ctr0b, $rk2 \n aesmc $ctr0b, $ctr0b // AES block 0 - round 2 + ldr $h1q, [$Htable] // load h1l | h1h + ext $h1b, $h1b, $h1b, #8 + aese $ctr2b, $rk2 \n aesmc $ctr2b, $ctr2b // AES block 2 - round 2 + ldr $rk10q, [$cc, #160] // load rk10 + aese $ctr3b, $rk2 \n aesmc $ctr3b, $ctr3b // AES block 3 - round 2 + aese $ctr0b, $rk3 \n aesmc $ctr0b, $ctr0b // AES block 0 - round 3 + aese $ctr1b, $rk2 \n aesmc $ctr1b, $ctr1b // AES block 1 - round 2 + aese $ctr3b, $rk3 \n aesmc $ctr3b, $ctr3b // AES block 3 - round 3 + aese $ctr0b, $rk4 \n aesmc $ctr0b, $ctr0b // AES block 0 - round 4 + aese $ctr2b, $rk3 \n aesmc $ctr2b, $ctr2b // AES block 2 - round 3 + aese $ctr1b, $rk3 \n aesmc $ctr1b, $ctr1b // AES block 1 - round 3 + aese $ctr3b, $rk4 \n aesmc $ctr3b, $ctr3b // AES block 3 - round 4 + aese $ctr2b, $rk4 \n aesmc $ctr2b, $ctr2b // AES block 2 - round 4 + aese $ctr1b, $rk4 \n aesmc $ctr1b, $ctr1b // AES block 1 - round 4 + aese $ctr3b, $rk5 \n aesmc $ctr3b, $ctr3b // AES block 3 - round 5 + aese $ctr0b, $rk5 \n aesmc $ctr0b, $ctr0b // AES block 0 - round 5 + aese $ctr1b, $rk5 \n aesmc $ctr1b, $ctr1b // AES block 1 - round 5 + aese $ctr2b, $rk5 \n aesmc $ctr2b, $ctr2b // AES block 2 - round 5 + aese $ctr0b, $rk6 \n aesmc $ctr0b, $ctr0b // AES block 0 - round 6 + aese $ctr3b, $rk6 \n aesmc $ctr3b, $ctr3b // AES block 3 - round 6 + cmp $rounds, #12 // setup flags for AES-128/192/256 check + aese $ctr1b, $rk6 \n aesmc $ctr1b, $ctr1b // AES block 1 - round 6 + aese $ctr2b, $rk6 \n aesmc $ctr2b, $ctr2b // AES block 2 - round 6 + aese $ctr0b, $rk7 \n aesmc $ctr0b, $ctr0b // AES block 0 - round 7 + aese $ctr1b, $rk7 \n aesmc $ctr1b, $ctr1b // AES block 1 - round 7 + aese $ctr3b, $rk7 \n aesmc $ctr3b, $ctr3b // AES block 3 - round 7 + aese $ctr0b, $rk8 \n aesmc $ctr0b, $ctr0b // AES block 0 - round 8 + aese $ctr2b, $rk7 \n aesmc $ctr2b, $ctr2b // AES block 2 - round 7 + aese $ctr3b, $rk8 \n aesmc $ctr3b, $ctr3b // AES block 3 - round 8 + aese $ctr1b, $rk8 \n aesmc $ctr1b, $ctr1b // AES block 1 - round 8 + ldr $rk11q, [$cc, #176] // load rk11 + aese $ctr2b, $rk8 \n aesmc $ctr2b, $ctr2b // AES block 2 - round 8 + b.lt .Ldec_finish_first_blocks // branch if AES-128 + + aese $ctr0b, $rk9 \n aesmc $ctr0b, $ctr0b // AES block 0 - round 9 + aese $ctr1b, $rk9 \n aesmc $ctr1b, $ctr1b // AES block 1 - round 9 + aese $ctr3b, $rk9 \n aesmc $ctr3b, $ctr3b // AES block 3 - round 9 + aese $ctr2b, $rk9 \n aesmc $ctr2b, $ctr2b // AES block 2 - round 9 + aese $ctr0b, $rk10 \n aesmc $ctr0b, $ctr0b // AES block 0 - round 10 + aese $ctr1b, $rk10 \n aesmc $ctr1b, $ctr1b // AES block 1 - round 10 + aese $ctr3b, $rk10 \n aesmc $ctr3b, $ctr3b // AES block 3 - round 10 + aese $ctr2b, $rk10 \n aesmc $ctr2b, $ctr2b // AES block 2 - round 10 + b.eq .Ldec_finish_first_blocks // branch if AES-192 + + aese $ctr0b, $rk11 \n aesmc $ctr0b, $ctr0b // AES block 0 - round 11 + aese $ctr3b, $rk11 \n aesmc $ctr3b, $ctr3b // AES block 3 - round 11 + aese $ctr1b, $rk11 \n aesmc $ctr1b, $ctr1b // AES block 1 - round 11 + aese $ctr2b, $rk11 \n aesmc $ctr2b, $ctr2b // AES block 2 - round 11 + aese $ctr1b, $rk12 \n aesmc $ctr1b, $ctr1b // AES block 1 - round 12 + aese $ctr0b, $rk12 \n aesmc $ctr0b, $ctr0b // AES block 0 - round 12 + aese $ctr2b, $rk12 \n aesmc $ctr2b, $ctr2b // AES block 2 - round 12 + aese $ctr3b, $rk12 \n aesmc $ctr3b, $ctr3b // AES block 3 - round 12 + +.Ldec_finish_first_blocks: + cmp $input_ptr, $main_end_input_ptr // check if we have <= 4 blocks + trn1 $acc_h.2d, $h3.2d, $h4.2d // h4h | h3h + trn2 $h34k.2d, $h3.2d, $h4.2d // h4l | h3l + trn1 $t0.2d, $h1.2d, $h2.2d // h2h | h1h + trn2 $h12k.2d, $h1.2d, $h2.2d // h2l | h1l + eor $h34k.16b, $h34k.16b, $acc_h.16b // h4k | h3k + aese $ctr1b, $rkNm1 // AES block 1 - round N-1 + aese $ctr2b, $rkNm1 // AES block 2 - round N-1 + eor $h12k.16b, $h12k.16b, $t0.16b // h2k | h1k + aese $ctr3b, $rkNm1 // AES block 3 - round N-1 + aese $ctr0b, $rkNm1 // AES block 0 - round N-1 + b.ge .Ldec_tail // handle tail + + ldr $res0q, [$input_ptr, #0] // AES block 0 - load ciphertext + ldr $res1q, [$input_ptr, #16] // AES block 1 - load ciphertext + rev $ctr32w, $rctr32w // CTR block 4 + eor $ctr0b, $res0b, $ctr0b // AES block 0 - result + eor $ctr1b, $res1b, $ctr1b // AES block 1 - result + rev64 $res1b, $res1b // GHASH block 1 + ldr $res3q, [$input_ptr, #48] // AES block 3 - load ciphertext + mov $output_h0, $ctr0.d[1] // AES block 0 - mov high + mov $output_l0, $ctr0.d[0] // AES block 0 - mov low + rev64 $res0b, $res0b // GHASH block 0 + add $rctr32w, $rctr32w, #1 // CTR block 4 + fmov $ctr0d, $ctr96_b64x // CTR block 4 + orr $ctr32x, $ctr96_t32x, $ctr32x, lsl #32 // CTR block 4 + fmov $ctr0.d[1], $ctr32x // CTR block 4 + rev $ctr32w, $rctr32w // CTR block 5 + add $rctr32w, $rctr32w, #1 // CTR block 5 + mov $output_l1, $ctr1.d[0] // AES block 1 - mov low + orr $ctr32x, $ctr96_t32x, $ctr32x, lsl #32 // CTR block 5 + mov $output_h1, $ctr1.d[1] // AES block 1 - mov high + eor $output_h0, $output_h0, $rkN_h // AES block 0 - round N high + eor $output_l0, $output_l0, $rkN_l // AES block 0 - round N low + stp $output_l0, $output_h0, [$output_ptr], #16 // AES block 0 - store result + fmov $ctr1d, $ctr96_b64x // CTR block 5 + ldr $res2q, [$input_ptr, #32] // AES block 2 - load ciphertext + add $input_ptr, $input_ptr, #64 // AES input_ptr update + fmov $ctr1.d[1], $ctr32x // CTR block 5 + rev $ctr32w, $rctr32w // CTR block 6 + add $rctr32w, $rctr32w, #1 // CTR block 6 + eor $output_l1, $output_l1, $rkN_l // AES block 1 - round N low + orr $ctr32x, $ctr96_t32x, $ctr32x, lsl #32 // CTR block 6 + eor $output_h1, $output_h1, $rkN_h // AES block 1 - round N high + stp $output_l1, $output_h1, [$output_ptr], #16 // AES block 1 - store result + eor $ctr2b, $res2b, $ctr2b // AES block 2 - result + cmp $input_ptr, $main_end_input_ptr // check if we have <= 8 blocks + b.ge .Ldec_prepretail // do prepretail + +.Ldec_main_loop: // main loop start + mov $output_l2, $ctr2.d[0] // AES block 4k+2 - mov low + ext $acc_lb, $acc_lb, $acc_lb, #8 // PRE 0 + eor $ctr3b, $res3b, $ctr3b // AES block 4k+3 - result + aese $ctr0b, $rk0 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 0 + mov $output_h2, $ctr2.d[1] // AES block 4k+2 - mov high + aese $ctr1b, $rk0 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 0 + fmov $ctr2d, $ctr96_b64x // CTR block 4k+6 + fmov $ctr2.d[1], $ctr32x // CTR block 4k+6 + eor $res0b, $res0b, $acc_lb // PRE 1 + rev $ctr32w, $rctr32w // CTR block 4k+7 + aese $ctr0b, $rk1 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 1 + mov $output_h3, $ctr3.d[1] // AES block 4k+3 - mov high + aese $ctr1b, $rk1 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 1 + mov $output_l3, $ctr3.d[0] // AES block 4k+3 - mov low + pmull2 $acc_h.1q, $res0.2d, $h4.2d // GHASH block 4k - high + mov $t0d, $res0.d[1] // GHASH block 4k - mid + fmov $ctr3d, $ctr96_b64x // CTR block 4k+7 + aese $ctr0b, $rk2 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 2 + orr $ctr32x, $ctr96_t32x, $ctr32x, lsl #32 // CTR block 4k+7 + aese $ctr2b, $rk0 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 0 + fmov $ctr3.d[1], $ctr32x // CTR block 4k+7 + aese $ctr1b, $rk2 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 2 + eor $t0.8b, $t0.8b, $res0.8b // GHASH block 4k - mid + aese $ctr0b, $rk3 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 3 + eor $output_h2, $output_h2, $rkN_h // AES block 4k+2 - round N high + aese $ctr2b, $rk1 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 1 + mov $acc_md, $h34k.d[1] // GHASH block 4k - mid + aese $ctr1b, $rk3 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 3 + rev64 $res2b, $res2b // GHASH block 4k+2 + aese $ctr3b, $rk0 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 0 + eor $output_l2, $output_l2, $rkN_l // AES block 4k+2 - round N low + aese $ctr2b, $rk2 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 2 + stp $output_l2, $output_h2, [$output_ptr], #16 // AES block 4k+2 - store result + pmull $acc_l.1q, $res0.1d, $h4.1d // GHASH block 4k - low + pmull2 $t1.1q, $res1.2d, $h3.2d // GHASH block 4k+1 - high + aese $ctr2b, $rk3 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 3 + rev64 $res3b, $res3b // GHASH block 4k+3 + pmull $acc_m.1q, $t0.1d, $acc_m.1d // GHASH block 4k - mid + eor $output_l3, $output_l3, $rkN_l // AES block 4k+3 - round N low + pmull $t2.1q, $res1.1d, $h3.1d // GHASH block 4k+1 - low + eor $output_h3, $output_h3, $rkN_h // AES block 4k+3 - round N high + eor $acc_hb, $acc_hb, $t1.16b // GHASH block 4k+1 - high + aese $ctr2b, $rk4 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 4 + aese $ctr3b, $rk1 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 1 + mov $t3d, $res1.d[1] // GHASH block 4k+1 - mid + aese $ctr0b, $rk4 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 4 + eor $acc_lb, $acc_lb, $t2.16b // GHASH block 4k+1 - low + aese $ctr2b, $rk5 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 5 + add $rctr32w, $rctr32w, #1 // CTR block 4k+7 + aese $ctr3b, $rk2 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 2 + mov $t6d, $res2.d[1] // GHASH block 4k+2 - mid + aese $ctr1b, $rk4 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 4 + eor $t3.8b, $t3.8b, $res1.8b // GHASH block 4k+1 - mid + pmull $t5.1q, $res2.1d, $h2.1d // GHASH block 4k+2 - low + aese $ctr3b, $rk3 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 3 + eor $t6.8b, $t6.8b, $res2.8b // GHASH block 4k+2 - mid + aese $ctr1b, $rk5 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 5 + aese $ctr0b, $rk5 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 5 + eor $acc_lb, $acc_lb, $t5.16b // GHASH block 4k+2 - low + pmull $t3.1q, $t3.1d, $h34k.1d // GHASH block 4k+1 - mid + rev $ctr32w, $rctr32w // CTR block 4k+8 + aese $ctr1b, $rk6 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 6 + ins $t6.d[1], $t6.d[0] // GHASH block 4k+2 - mid + aese $ctr0b, $rk6 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 6 + add $rctr32w, $rctr32w, #1 // CTR block 4k+8 + aese $ctr3b, $rk4 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 4 + aese $ctr1b, $rk7 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 7 + eor $acc_mb, $acc_mb, $t3.16b // GHASH block 4k+1 - mid + aese $ctr0b, $rk7 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 7 + pmull2 $t4.1q, $res2.2d, $h2.2d // GHASH block 4k+2 - high + mov $t9d, $res3.d[1] // GHASH block 4k+3 - mid + aese $ctr3b, $rk5 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 5 + pmull2 $t6.1q, $t6.2d, $h12k.2d // GHASH block 4k+2 - mid + aese $ctr0b, $rk8 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 8 + eor $acc_hb, $acc_hb, $t4.16b // GHASH block 4k+2 - high + aese $ctr3b, $rk6 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 6 + pmull $t8.1q, $res3.1d, $h1.1d // GHASH block 4k+3 - low + orr $ctr32x, $ctr96_t32x, $ctr32x, lsl #32 // CTR block 4k+8 + eor $acc_mb, $acc_mb, $t6.16b // GHASH block 4k+2 - mid + pmull2 $t7.1q, $res3.2d, $h1.2d // GHASH block 4k+3 - high + cmp $rounds, #12 // setup flags for AES-128/192/256 check + eor $t9.8b, $t9.8b, $res3.8b // GHASH block 4k+3 - mid + aese $ctr1b, $rk8 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 8 + aese $ctr2b, $rk6 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 6 + eor $acc_hb, $acc_hb, $t7.16b // GHASH block 4k+3 - high + pmull $t9.1q, $t9.1d, $h12k.1d // GHASH block 4k+3 - mid + movi $mod_constant.8b, #0xc2 + aese $ctr2b, $rk7 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 7 + eor $acc_lb, $acc_lb, $t8.16b // GHASH block 4k+3 - low + aese $ctr3b, $rk7 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 7 + shl $mod_constantd, $mod_constantd, #56 // mod_constant + aese $ctr2b, $rk8 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 8 + eor $acc_mb, $acc_mb, $t9.16b // GHASH block 4k+3 - mid + aese $ctr3b, $rk8 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 8 + b.lt .Ldec_main_loop_continue // branch if AES-128 + + aese $ctr0b, $rk9 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 9 + aese $ctr2b, $rk9 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 9 + aese $ctr1b, $rk9 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 9 + aese $ctr3b, $rk9 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 9 + aese $ctr0b, $rk10 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 10 + aese $ctr1b, $rk10 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 10 + aese $ctr2b, $rk10 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 10 + aese $ctr3b, $rk10 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 10 + b.eq .Ldec_main_loop_continue // branch if AES-192 + + aese $ctr0b, $rk11 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 11 + aese $ctr1b, $rk11 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 11 + aese $ctr2b, $rk11 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 11 + aese $ctr3b, $rk11 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 11 + aese $ctr0b, $rk12 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 12 + aese $ctr1b, $rk12 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 12 + aese $ctr2b, $rk12 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 12 + aese $ctr3b, $rk12 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 12 + +.Ldec_main_loop_continue: + pmull $mod_t.1q, $acc_h.1d, $mod_constant.1d // MODULO - top 64b align with mid + eor $t9.16b, $acc_lb, $acc_hb // MODULO - karatsuba tidy up + ldr $res0q, [$input_ptr, #0] // AES block 4k+4 - load ciphertext + aese $ctr0b, $rkNm1 // AES block 4k+4 - round N-1 + ext $acc_hb, $acc_hb, $acc_hb, #8 // MODULO - other top alignment + eor $acc_mb, $acc_mb, $t9.16b // MODULO - karatsuba tidy up + ldr $res1q, [$input_ptr, #16] // AES block 4k+5 - load ciphertext + eor $ctr0b, $res0b, $ctr0b // AES block 4k+4 - result + stp $output_l3, $output_h3, [$output_ptr], #16 // AES block 4k+3 - store result + eor $acc_mb, $acc_mb, $mod_t.16b // MODULO - fold into mid + ldr $res3q, [$input_ptr, #48] // AES block 4k+7 - load ciphertext + ldr $res2q, [$input_ptr, #32] // AES block 4k+6 - load ciphertext + mov $output_h0, $ctr0.d[1] // AES block 4k+4 - mov high + eor $acc_mb, $acc_mb, $acc_hb // MODULO - fold into mid + aese $ctr1b, $rkNm1 // AES block 4k+5 - round N-1 + add $input_ptr, $input_ptr, #64 // AES input_ptr update + mov $output_l0, $ctr0.d[0] // AES block 4k+4 - mov low + fmov $ctr0d, $ctr96_b64x // CTR block 4k+8 + fmov $ctr0.d[1], $ctr32x // CTR block 4k+8 + pmull $mod_constant.1q, $acc_m.1d, $mod_constant.1d // MODULO - mid 64b align with low + eor $ctr1b, $res1b, $ctr1b // AES block 4k+5 - result + rev $ctr32w, $rctr32w // CTR block 4k+9 + aese $ctr2b, $rkNm1 // AES block 4k+6 - round N-1 + orr $ctr32x, $ctr96_t32x, $ctr32x, lsl #32 // CTR block 4k+9 + cmp $input_ptr, $main_end_input_ptr // LOOP CONTROL + add $rctr32w, $rctr32w, #1 // CTR block 4k+9 + eor $output_l0, $output_l0, $rkN_l // AES block 4k+4 - round N low + eor $output_h0, $output_h0, $rkN_h // AES block 4k+4 - round N high + mov $output_h1, $ctr1.d[1] // AES block 4k+5 - mov high + eor $ctr2b, $res2b, $ctr2b // AES block 4k+6 - result + eor $acc_lb, $acc_lb, $mod_constant.16b // MODULO - fold into low + mov $output_l1, $ctr1.d[0] // AES block 4k+5 - mov low + fmov $ctr1d, $ctr96_b64x // CTR block 4k+9 + ext $acc_mb, $acc_mb, $acc_mb, #8 // MODULO - other mid alignment + fmov $ctr1.d[1], $ctr32x // CTR block 4k+9 + rev $ctr32w, $rctr32w // CTR block 4k+10 + add $rctr32w, $rctr32w, #1 // CTR block 4k+10 + aese $ctr3b, $rkNm1 // AES block 4k+7 - round N-1 + orr $ctr32x, $ctr96_t32x, $ctr32x, lsl #32 // CTR block 4k+10 + rev64 $res1b, $res1b // GHASH block 4k+5 + eor $output_h1, $output_h1, $rkN_h // AES block 4k+5 - round N high + stp $output_l0, $output_h0, [$output_ptr], #16 // AES block 4k+4 - store result + eor $output_l1, $output_l1, $rkN_l // AES block 4k+5 - round N low + stp $output_l1, $output_h1, [$output_ptr], #16 // AES block 4k+5 - store result + rev64 $res0b, $res0b // GHASH block 4k+4 + eor $acc_lb, $acc_lb, $acc_mb // MODULO - fold into low + b.lt .Ldec_main_loop + +.Ldec_prepretail: // PREPRETAIL + ext $acc_lb, $acc_lb, $acc_lb, #8 // PRE 0 + mov $output_l2, $ctr2.d[0] // AES block 4k+2 - mov low + eor $ctr3b, $res3b, $ctr3b // AES block 4k+3 - result + aese $ctr0b, $rk0 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 0 + mov $output_h2, $ctr2.d[1] // AES block 4k+2 - mov high + aese $ctr1b, $rk0 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 0 + fmov $ctr2d, $ctr96_b64x // CTR block 4k+6 + fmov $ctr2.d[1], $ctr32x // CTR block 4k+6 + rev $ctr32w, $rctr32w // CTR block 4k+7 + eor $res0b, $res0b, $acc_lb // PRE 1 + rev64 $res2b, $res2b // GHASH block 4k+2 + orr $ctr32x, $ctr96_t32x, $ctr32x, lsl #32 // CTR block 4k+7 + mov $output_l3, $ctr3.d[0] // AES block 4k+3 - mov low + aese $ctr1b, $rk1 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 1 + mov $output_h3, $ctr3.d[1] // AES block 4k+3 - mov high + pmull $acc_l.1q, $res0.1d, $h4.1d // GHASH block 4k - low + mov $t0d, $res0.d[1] // GHASH block 4k - mid + fmov $ctr3d, $ctr96_b64x // CTR block 4k+7 + pmull2 $acc_h.1q, $res0.2d, $h4.2d // GHASH block 4k - high + fmov $ctr3.d[1], $ctr32x // CTR block 4k+7 + aese $ctr2b, $rk0 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 0 + mov $acc_md, $h34k.d[1] // GHASH block 4k - mid + aese $ctr0b, $rk1 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 1 + eor $t0.8b, $t0.8b, $res0.8b // GHASH block 4k - mid + pmull2 $t1.1q, $res1.2d, $h3.2d // GHASH block 4k+1 - high + aese $ctr2b, $rk1 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 1 + rev64 $res3b, $res3b // GHASH block 4k+3 + aese $ctr3b, $rk0 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 0 + pmull $acc_m.1q, $t0.1d, $acc_m.1d // GHASH block 4k - mid + eor $acc_hb, $acc_hb, $t1.16b // GHASH block 4k+1 - high + pmull $t2.1q, $res1.1d, $h3.1d // GHASH block 4k+1 - low + aese $ctr3b, $rk1 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 1 + mov $t3d, $res1.d[1] // GHASH block 4k+1 - mid + aese $ctr0b, $rk2 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 2 + aese $ctr1b, $rk2 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 2 + eor $acc_lb, $acc_lb, $t2.16b // GHASH block 4k+1 - low + aese $ctr2b, $rk2 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 2 + aese $ctr0b, $rk3 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 3 + mov $t6d, $res2.d[1] // GHASH block 4k+2 - mid + aese $ctr3b, $rk2 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 2 + eor $t3.8b, $t3.8b, $res1.8b // GHASH block 4k+1 - mid + pmull $t5.1q, $res2.1d, $h2.1d // GHASH block 4k+2 - low + aese $ctr0b, $rk4 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 4 + aese $ctr3b, $rk3 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 3 + eor $t6.8b, $t6.8b, $res2.8b // GHASH block 4k+2 - mid + pmull $t3.1q, $t3.1d, $h34k.1d // GHASH block 4k+1 - mid + aese $ctr0b, $rk5 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 5 + eor $acc_lb, $acc_lb, $t5.16b // GHASH block 4k+2 - low + aese $ctr3b, $rk4 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 4 + pmull2 $t7.1q, $res3.2d, $h1.2d // GHASH block 4k+3 - high + eor $acc_mb, $acc_mb, $t3.16b // GHASH block 4k+1 - mid + pmull2 $t4.1q, $res2.2d, $h2.2d // GHASH block 4k+2 - high + aese $ctr3b, $rk5 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 5 + ins $t6.d[1], $t6.d[0] // GHASH block 4k+2 - mid + aese $ctr2b, $rk3 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 3 + aese $ctr1b, $rk3 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 3 + eor $acc_hb, $acc_hb, $t4.16b // GHASH block 4k+2 - high + pmull $t8.1q, $res3.1d, $h1.1d // GHASH block 4k+3 - low + aese $ctr2b, $rk4 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 4 + mov $t9d, $res3.d[1] // GHASH block 4k+3 - mid + aese $ctr1b, $rk4 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 4 + pmull2 $t6.1q, $t6.2d, $h12k.2d // GHASH block 4k+2 - mid + aese $ctr2b, $rk5 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 5 + eor $t9.8b, $t9.8b, $res3.8b // GHASH block 4k+3 - mid + aese $ctr1b, $rk5 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 5 + aese $ctr3b, $rk6 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 6 + eor $acc_mb, $acc_mb, $t6.16b // GHASH block 4k+2 - mid + aese $ctr2b, $rk6 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 6 + aese $ctr0b, $rk6 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 6 + movi $mod_constant.8b, #0xc2 + aese $ctr1b, $rk6 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 6 + eor $acc_lb, $acc_lb, $t8.16b // GHASH block 4k+3 - low + pmull $t9.1q, $t9.1d, $h12k.1d // GHASH block 4k+3 - mid + aese $ctr3b, $rk7 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 7 + cmp $rounds, #12 // setup flags for AES-128/192/256 check + eor $acc_hb, $acc_hb, $t7.16b // GHASH block 4k+3 - high + aese $ctr1b, $rk7 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 7 + aese $ctr0b, $rk7 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 7 + eor $acc_mb, $acc_mb, $t9.16b // GHASH block 4k+3 - mid + aese $ctr3b, $rk8 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 8 + aese $ctr2b, $rk7 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 7 + eor $t9.16b, $acc_lb, $acc_hb // MODULO - karatsuba tidy up + aese $ctr1b, $rk8 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 8 + aese $ctr0b, $rk8 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 8 + shl $mod_constantd, $mod_constantd, #56 // mod_constant + aese $ctr2b, $rk8 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 8 + b.lt .Ldec_finish_prepretail // branch if AES-128 + + aese $ctr1b, $rk9 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 9 + aese $ctr2b, $rk9 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 9 + aese $ctr3b, $rk9 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 9 + aese $ctr0b, $rk9 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 9 + aese $ctr2b, $rk10 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 10 + aese $ctr3b, $rk10 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 10 + aese $ctr0b, $rk10 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 10 + aese $ctr1b, $rk10 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 10 + b.eq .Ldec_finish_prepretail // branch if AES-192 + + aese $ctr2b, $rk11 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 11 + aese $ctr0b, $rk11 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 11 + aese $ctr1b, $rk11 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 11 + aese $ctr2b, $rk12 \n aesmc $ctr2b, $ctr2b // AES block 4k+6 - round 12 + aese $ctr3b, $rk11 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 11 + aese $ctr1b, $rk12 \n aesmc $ctr1b, $ctr1b // AES block 4k+5 - round 12 + aese $ctr0b, $rk12 \n aesmc $ctr0b, $ctr0b // AES block 4k+4 - round 12 + aese $ctr3b, $rk12 \n aesmc $ctr3b, $ctr3b // AES block 4k+7 - round 12 + +.Ldec_finish_prepretail: + eor $acc_mb, $acc_mb, $t9.16b // MODULO - karatsuba tidy up + pmull $mod_t.1q, $acc_h.1d, $mod_constant.1d // MODULO - top 64b align with mid + ext $acc_hb, $acc_hb, $acc_hb, #8 // MODULO - other top alignment + eor $acc_mb, $acc_mb, $mod_t.16b // MODULO - fold into mid + eor $output_h2, $output_h2, $rkN_h // AES block 4k+2 - round N high + eor $output_l3, $output_l3, $rkN_l // AES block 4k+3 - round N low + eor $acc_mb, $acc_mb, $acc_hb // MODULO - fold into mid + add $rctr32w, $rctr32w, #1 // CTR block 4k+7 + eor $output_l2, $output_l2, $rkN_l // AES block 4k+2 - round N low + pmull $mod_constant.1q, $acc_m.1d, $mod_constant.1d // MODULO - mid 64b align with low + eor $output_h3, $output_h3, $rkN_h // AES block 4k+3 - round N high + stp $output_l2, $output_h2, [$output_ptr], #16 // AES block 4k+2 - store result + ext $acc_mb, $acc_mb, $acc_mb, #8 // MODULO - other mid alignment + stp $output_l3, $output_h3, [$output_ptr], #16 // AES block 4k+3 - store result + + eor $acc_lb, $acc_lb, $mod_constant.16b // MODULO - fold into low + aese $ctr1b, $rkNm1 // AES block 4k+5 - round N-1 + aese $ctr0b, $rkNm1 // AES block 4k+4 - round N-1 + aese $ctr3b, $rkNm1 // AES block 4k+7 - round N-1 + aese $ctr2b, $rkNm1 // AES block 4k+6 - round N-1 + eor $acc_lb, $acc_lb, $acc_mb // MODULO - fold into low + +.Ldec_tail: // TAIL + sub $main_end_input_ptr, $end_input_ptr, $input_ptr // main_end_input_ptr is number of bytes left to process + ld1 { $res1b}, [$input_ptr], #16 // AES block 4k+4 - load ciphertext + eor $ctr0b, $res1b, $ctr0b // AES block 4k+4 - result + mov $output_l0, $ctr0.d[0] // AES block 4k+4 - mov low + mov $output_h0, $ctr0.d[1] // AES block 4k+4 - mov high + ext $t0.16b, $acc_lb, $acc_lb, #8 // prepare final partial tag + cmp $main_end_input_ptr, #48 + eor $output_l0, $output_l0, $rkN_l // AES block 4k+4 - round N low + eor $output_h0, $output_h0, $rkN_h // AES block 4k+4 - round N high + b.gt .Ldec_blocks_more_than_3 + sub $rctr32w, $rctr32w, #1 + mov $ctr3b, $ctr2b + movi $acc_m.8b, #0 + movi $acc_l.8b, #0 + cmp $main_end_input_ptr, #32 + movi $acc_h.8b, #0 + mov $ctr2b, $ctr1b + b.gt .Ldec_blocks_more_than_2 + sub $rctr32w, $rctr32w, #1 + mov $ctr3b, $ctr1b + cmp $main_end_input_ptr, #16 + b.gt .Ldec_blocks_more_than_1 + sub $rctr32w, $rctr32w, #1 + b .Ldec_blocks_less_than_1 +.Ldec_blocks_more_than_3: // blocks left > 3 + rev64 $res0b, $res1b // GHASH final-3 block + ld1 { $res1b}, [$input_ptr], #16 // AES final-2 block - load ciphertext + stp $output_l0, $output_h0, [$output_ptr], #16 // AES final-3 block - store result + mov $acc_md, $h34k.d[1] // GHASH final-3 block - mid + eor $res0b, $res0b, $t0.16b // feed in partial tag + eor $ctr0b, $res1b, $ctr1b // AES final-2 block - result + mov $rk4d, $res0.d[1] // GHASH final-3 block - mid + mov $output_l0, $ctr0.d[0] // AES final-2 block - mov low + mov $output_h0, $ctr0.d[1] // AES final-2 block - mov high + eor $rk4v.8b, $rk4v.8b, $res0.8b // GHASH final-3 block - mid + movi $t0.8b, #0 // suppress further partial tag feed in + pmull2 $acc_h.1q, $res0.2d, $h4.2d // GHASH final-3 block - high + pmull $acc_m.1q, $rk4v.1d, $acc_m.1d // GHASH final-3 block - mid + eor $output_l0, $output_l0, $rkN_l // AES final-2 block - round N low + pmull $acc_l.1q, $res0.1d, $h4.1d // GHASH final-3 block - low + eor $output_h0, $output_h0, $rkN_h // AES final-2 block - round N high +.Ldec_blocks_more_than_2: // blocks left > 2 + rev64 $res0b, $res1b // GHASH final-2 block + ld1 { $res1b}, [$input_ptr], #16 // AES final-1 block - load ciphertext + eor $res0b, $res0b, $t0.16b // feed in partial tag + stp $output_l0, $output_h0, [$output_ptr], #16 // AES final-2 block - store result + eor $ctr0b, $res1b, $ctr2b // AES final-1 block - result + mov $rk4d, $res0.d[1] // GHASH final-2 block - mid + pmull $rk3q1, $res0.1d, $h3.1d // GHASH final-2 block - low + pmull2 $rk2q1, $res0.2d, $h3.2d // GHASH final-2 block - high + eor $rk4v.8b, $rk4v.8b, $res0.8b // GHASH final-2 block - mid + mov $output_l0, $ctr0.d[0] // AES final-1 block - mov low + mov $output_h0, $ctr0.d[1] // AES final-1 block - mov high + eor $acc_lb, $acc_lb, $rk3 // GHASH final-2 block - low + movi $t0.8b, #0 // suppress further partial tag feed in + pmull $rk4v.1q, $rk4v.1d, $h34k.1d // GHASH final-2 block - mid + eor $acc_hb, $acc_hb, $rk2 // GHASH final-2 block - high + eor $output_l0, $output_l0, $rkN_l // AES final-1 block - round N low + eor $acc_mb, $acc_mb, $rk4v.16b // GHASH final-2 block - mid + eor $output_h0, $output_h0, $rkN_h // AES final-1 block - round N high +.Ldec_blocks_more_than_1: // blocks left > 1 + stp $output_l0, $output_h0, [$output_ptr], #16 // AES final-1 block - store result + rev64 $res0b, $res1b // GHASH final-1 block + ld1 { $res1b}, [$input_ptr], #16 // AES final block - load ciphertext + eor $res0b, $res0b, $t0.16b // feed in partial tag + movi $t0.8b, #0 // suppress further partial tag feed in + mov $rk4d, $res0.d[1] // GHASH final-1 block - mid + eor $ctr0b, $res1b, $ctr3b // AES final block - result + pmull2 $rk2q1, $res0.2d, $h2.2d // GHASH final-1 block - high + eor $rk4v.8b, $rk4v.8b, $res0.8b // GHASH final-1 block - mid + pmull $rk3q1, $res0.1d, $h2.1d // GHASH final-1 block - low + mov $output_l0, $ctr0.d[0] // AES final block - mov low + ins $rk4v.d[1], $rk4v.d[0] // GHASH final-1 block - mid + mov $output_h0, $ctr0.d[1] // AES final block - mov high + pmull2 $rk4v.1q, $rk4v.2d, $h12k.2d // GHASH final-1 block - mid + eor $output_l0, $output_l0, $rkN_l // AES final block - round N low + eor $acc_lb, $acc_lb, $rk3 // GHASH final-1 block - low + eor $acc_hb, $acc_hb, $rk2 // GHASH final-1 block - high + eor $acc_mb, $acc_mb, $rk4v.16b // GHASH final-1 block - mid + eor $output_h0, $output_h0, $rkN_h // AES final block - round N high +.Ldec_blocks_less_than_1: // blocks left <= 1 + and $bit_length, $bit_length, #127 // bit_length %= 128 + mvn $rkN_h, xzr // rkN_h = 0xffffffffffffffff + sub $bit_length, $bit_length, #128 // bit_length -= 128 + mvn $rkN_l, xzr // rkN_l = 0xffffffffffffffff + ldp $end_input_ptr, $main_end_input_ptr, [$output_ptr] // load existing bytes we need to not overwrite + neg $bit_length, $bit_length // bit_length = 128 - #bits in input (in range [1,128]) + and $bit_length, $bit_length, #127 // bit_length %= 128 + lsr $rkN_h, $rkN_h, $bit_length // rkN_h is mask for top 64b of last block + cmp $bit_length, #64 + csel $ctr32x, $rkN_l, $rkN_h, lt + csel $ctr96_b64x, $rkN_h, xzr, lt + fmov $ctr0d, $ctr32x // ctr0b is mask for last block + and $output_l0, $output_l0, $ctr32x + mov $ctr0.d[1], $ctr96_b64x + bic $end_input_ptr, $end_input_ptr, $ctr32x // mask out low existing bytes + rev $ctr32w, $rctr32w + bic $main_end_input_ptr, $main_end_input_ptr, $ctr96_b64x // mask out high existing bytes + orr $output_l0, $output_l0, $end_input_ptr + and $output_h0, $output_h0, $ctr96_b64x + orr $output_h0, $output_h0, $main_end_input_ptr + and $res1b, $res1b, $ctr0b // possibly partial last block has zeroes in highest bits + rev64 $res0b, $res1b // GHASH final block + eor $res0b, $res0b, $t0.16b // feed in partial tag + pmull $rk3q1, $res0.1d, $h1.1d // GHASH final block - low + mov $t0d, $res0.d[1] // GHASH final block - mid + eor $t0.8b, $t0.8b, $res0.8b // GHASH final block - mid + pmull2 $rk2q1, $res0.2d, $h1.2d // GHASH final block - high + pmull $t0.1q, $t0.1d, $h12k.1d // GHASH final block - mid + eor $acc_hb, $acc_hb, $rk2 // GHASH final block - high + eor $acc_lb, $acc_lb, $rk3 // GHASH final block - low + eor $acc_mb, $acc_mb, $t0.16b // GHASH final block - mid + movi $mod_constant.8b, #0xc2 + eor $t9.16b, $acc_lb, $acc_hb // MODULO - karatsuba tidy up + shl $mod_constantd, $mod_constantd, #56 // mod_constant + eor $acc_mb, $acc_mb, $t9.16b // MODULO - karatsuba tidy up + pmull $mod_t.1q, $acc_h.1d, $mod_constant.1d // MODULO - top 64b align with mid + ext $acc_hb, $acc_hb, $acc_hb, #8 // MODULO - other top alignment + eor $acc_mb, $acc_mb, $mod_t.16b // MODULO - fold into mid + eor $acc_mb, $acc_mb, $acc_hb // MODULO - fold into mid + pmull $mod_constant.1q, $acc_m.1d, $mod_constant.1d // MODULO - mid 64b align with low + ext $acc_mb, $acc_mb, $acc_mb, #8 // MODULO - other mid alignment + eor $acc_lb, $acc_lb, $mod_constant.16b // MODULO - fold into low + stp $output_l0, $output_h0, [$output_ptr] + str $ctr32w, [$counter, #12] // store the updated counter + eor $acc_lb, $acc_lb, $acc_mb // MODULO - fold into low + ext $acc_lb, $acc_lb, $acc_lb, #8 + rev64 $acc_lb, $acc_lb + mov x0, $len + st1 { $acc_l.16b }, [$current_tag] + ldp x19, x20, [sp, #16] + ldp x21, x22, [sp, #32] + ldp x23, x24, [sp, #48] + ldp d8, d9, [sp, #64] + ldp d10, d11, [sp, #80] + ldp d12, d13, [sp, #96] + ldp d14, d15, [sp, #112] + ldp x29, x30, [sp], #128 + AARCH64_VALIDATE_LINK_REGISTER + ret +.size aes_gcm_dec_kernel,.-aes_gcm_dec_kernel +___ +} +} + +$code.=<<___; +#endif +___ + +print $code; +close STDOUT or die "error closing STDOUT: $!"; # enforce flush diff --git a/http/vendor/ring/crypto/fipsmodule/aes/asm/bsaes-armv7.pl b/http/vendor/ring/crypto/fipsmodule/aes/asm/bsaes-armv7.pl new file mode 100644 index 0000000..a7518f6 --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/aes/asm/bsaes-armv7.pl @@ -0,0 +1,1144 @@ +#! /usr/bin/env perl +# Copyright 2012-2016 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# ==================================================================== +# Written by Andy Polyakov for the OpenSSL +# project. +# +# Specific modes and adaptation for Linux kernel by Ard Biesheuvel +# of Linaro. +# ==================================================================== + +# Bit-sliced AES for ARM NEON +# +# February 2012. +# +# This implementation is direct adaptation of bsaes-x86_64 module for +# ARM NEON. Except that this module is endian-neutral [in sense that +# it can be compiled for either endianness] by courtesy of vld1.8's +# neutrality. Initial version doesn't implement interface to OpenSSL, +# only low-level primitives and unsupported entry points, just enough +# to collect performance results, which for Cortex-A8 core are: +# +# encrypt 19.5 cycles per byte processed with 128-bit key +# decrypt 22.1 cycles per byte processed with 128-bit key +# key conv. 440 cycles per 128-bit key/0.18 of 8x block +# +# Snapdragon S4 encrypts byte in 17.6 cycles and decrypts in 19.7, +# which is [much] worse than anticipated (for further details see +# http://www.openssl.org/~appro/Snapdragon-S4.html). +# +# Cortex-A15 manages in 14.2/16.1 cycles [when integer-only code +# manages in 20.0 cycles]. +# +# When comparing to x86_64 results keep in mind that NEON unit is +# [mostly] single-issue and thus can't [fully] benefit from +# instruction-level parallelism. And when comparing to aes-armv4 +# results keep in mind key schedule conversion overhead (see +# bsaes-x86_64.pl for further details)... +# +# + +# April-August 2013 +# Add CBC, CTR and XTS subroutines and adapt for kernel use; courtesy of Ard. + +$flavour = shift; +if ($flavour=~/\w[\w\-]*\.\w+$/) { $output=$flavour; undef $flavour; } +else { while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {} } + +if ($flavour && $flavour ne "void") { + $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; + ( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or + ( $xlate="${dir}../../../perlasm/arm-xlate.pl" and -f $xlate) or + die "can't locate arm-xlate.pl"; + + open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""; + *STDOUT=*OUT; +} else { + open OUT,">$output"; + *STDOUT=*OUT; +} + +my ($inp,$out,$len,$key)=("r0","r1","r2","r3"); +my @XMM=map("q$_",(0..15)); + +{ +my ($key,$rounds,$const)=("r4","r5","r6"); + +sub Dlo() { shift=~m|q([1]?[0-9])|?"d".($1*2):""; } +sub Dhi() { shift=~m|q([1]?[0-9])|?"d".($1*2+1):""; } + +sub Sbox { +# input in lsb > [b0, b1, b2, b3, b4, b5, b6, b7] < msb +# output in lsb > [b0, b1, b4, b6, b3, b7, b2, b5] < msb +my @b=@_[0..7]; +my @t=@_[8..11]; +my @s=@_[12..15]; + &InBasisChange (@b); + &Inv_GF256 (@b[6,5,0,3,7,1,4,2],@t,@s); + &OutBasisChange (@b[7,1,4,2,6,5,0,3]); +} + +sub InBasisChange { +# input in lsb > [b0, b1, b2, b3, b4, b5, b6, b7] < msb +# output in lsb > [b6, b5, b0, b3, b7, b1, b4, b2] < msb +my @b=@_[0..7]; +$code.=<<___; + veor @b[2], @b[2], @b[1] + veor @b[5], @b[5], @b[6] + veor @b[3], @b[3], @b[0] + veor @b[6], @b[6], @b[2] + veor @b[5], @b[5], @b[0] + + veor @b[6], @b[6], @b[3] + veor @b[3], @b[3], @b[7] + veor @b[7], @b[7], @b[5] + veor @b[3], @b[3], @b[4] + veor @b[4], @b[4], @b[5] + + veor @b[2], @b[2], @b[7] + veor @b[3], @b[3], @b[1] + veor @b[1], @b[1], @b[5] +___ +} + +sub OutBasisChange { +# input in lsb > [b0, b1, b2, b3, b4, b5, b6, b7] < msb +# output in lsb > [b6, b1, b2, b4, b7, b0, b3, b5] < msb +my @b=@_[0..7]; +$code.=<<___; + veor @b[0], @b[0], @b[6] + veor @b[1], @b[1], @b[4] + veor @b[4], @b[4], @b[6] + veor @b[2], @b[2], @b[0] + veor @b[6], @b[6], @b[1] + + veor @b[1], @b[1], @b[5] + veor @b[5], @b[5], @b[3] + veor @b[3], @b[3], @b[7] + veor @b[7], @b[7], @b[5] + veor @b[2], @b[2], @b[5] + + veor @b[4], @b[4], @b[7] +___ +} + +sub InvSbox { +# input in lsb > [b0, b1, b2, b3, b4, b5, b6, b7] < msb +# output in lsb > [b0, b1, b6, b4, b2, b7, b3, b5] < msb +my @b=@_[0..7]; +my @t=@_[8..11]; +my @s=@_[12..15]; + &InvInBasisChange (@b); + &Inv_GF256 (@b[5,1,2,6,3,7,0,4],@t,@s); + &InvOutBasisChange (@b[3,7,0,4,5,1,2,6]); +} + +sub InvInBasisChange { # OutBasisChange in reverse (with twist) +my @b=@_[5,1,2,6,3,7,0,4]; +$code.=<<___ + veor @b[1], @b[1], @b[7] + veor @b[4], @b[4], @b[7] + + veor @b[7], @b[7], @b[5] + veor @b[1], @b[1], @b[3] + veor @b[2], @b[2], @b[5] + veor @b[3], @b[3], @b[7] + + veor @b[6], @b[6], @b[1] + veor @b[2], @b[2], @b[0] + veor @b[5], @b[5], @b[3] + veor @b[4], @b[4], @b[6] + veor @b[0], @b[0], @b[6] + veor @b[1], @b[1], @b[4] +___ +} + +sub InvOutBasisChange { # InBasisChange in reverse +my @b=@_[2,5,7,3,6,1,0,4]; +$code.=<<___; + veor @b[1], @b[1], @b[5] + veor @b[2], @b[2], @b[7] + + veor @b[3], @b[3], @b[1] + veor @b[4], @b[4], @b[5] + veor @b[7], @b[7], @b[5] + veor @b[3], @b[3], @b[4] + veor @b[5], @b[5], @b[0] + veor @b[3], @b[3], @b[7] + veor @b[6], @b[6], @b[2] + veor @b[2], @b[2], @b[1] + veor @b[6], @b[6], @b[3] + + veor @b[3], @b[3], @b[0] + veor @b[5], @b[5], @b[6] +___ +} + +sub Mul_GF4 { +#;************************************************************* +#;* Mul_GF4: Input x0-x1,y0-y1 Output x0-x1 Temp t0 (8) * +#;************************************************************* +my ($x0,$x1,$y0,$y1,$t0,$t1)=@_; +$code.=<<___; + veor $t0, $y0, $y1 + vand $t0, $t0, $x0 + veor $x0, $x0, $x1 + vand $t1, $x1, $y0 + vand $x0, $x0, $y1 + veor $x1, $t1, $t0 + veor $x0, $x0, $t1 +___ +} + +sub Mul_GF4_N { # not used, see next subroutine +# multiply and scale by N +my ($x0,$x1,$y0,$y1,$t0)=@_; +$code.=<<___; + veor $t0, $y0, $y1 + vand $t0, $t0, $x0 + veor $x0, $x0, $x1 + vand $x1, $x1, $y0 + vand $x0, $x0, $y1 + veor $x1, $x1, $x0 + veor $x0, $x0, $t0 +___ +} + +sub Mul_GF4_N_GF4 { +# interleaved Mul_GF4_N and Mul_GF4 +my ($x0,$x1,$y0,$y1,$t0, + $x2,$x3,$y2,$y3,$t1)=@_; +$code.=<<___; + veor $t0, $y0, $y1 + veor $t1, $y2, $y3 + vand $t0, $t0, $x0 + vand $t1, $t1, $x2 + veor $x0, $x0, $x1 + veor $x2, $x2, $x3 + vand $x1, $x1, $y0 + vand $x3, $x3, $y2 + vand $x0, $x0, $y1 + vand $x2, $x2, $y3 + veor $x1, $x1, $x0 + veor $x2, $x2, $x3 + veor $x0, $x0, $t0 + veor $x3, $x3, $t1 +___ +} +sub Mul_GF16_2 { +my @x=@_[0..7]; +my @y=@_[8..11]; +my @t=@_[12..15]; +$code.=<<___; + veor @t[0], @x[0], @x[2] + veor @t[1], @x[1], @x[3] +___ + &Mul_GF4 (@x[0], @x[1], @y[0], @y[1], @t[2..3]); +$code.=<<___; + veor @y[0], @y[0], @y[2] + veor @y[1], @y[1], @y[3] +___ + Mul_GF4_N_GF4 (@t[0], @t[1], @y[0], @y[1], @t[3], + @x[2], @x[3], @y[2], @y[3], @t[2]); +$code.=<<___; + veor @x[0], @x[0], @t[0] + veor @x[2], @x[2], @t[0] + veor @x[1], @x[1], @t[1] + veor @x[3], @x[3], @t[1] + + veor @t[0], @x[4], @x[6] + veor @t[1], @x[5], @x[7] +___ + &Mul_GF4_N_GF4 (@t[0], @t[1], @y[0], @y[1], @t[3], + @x[6], @x[7], @y[2], @y[3], @t[2]); +$code.=<<___; + veor @y[0], @y[0], @y[2] + veor @y[1], @y[1], @y[3] +___ + &Mul_GF4 (@x[4], @x[5], @y[0], @y[1], @t[2..3]); +$code.=<<___; + veor @x[4], @x[4], @t[0] + veor @x[6], @x[6], @t[0] + veor @x[5], @x[5], @t[1] + veor @x[7], @x[7], @t[1] +___ +} +sub Inv_GF256 { +#;******************************************************************** +#;* Inv_GF256: Input x0-x7 Output x0-x7 Temp t0-t3,s0-s3 (144) * +#;******************************************************************** +my @x=@_[0..7]; +my @t=@_[8..11]; +my @s=@_[12..15]; +# direct optimizations from hardware +$code.=<<___; + veor @t[3], @x[4], @x[6] + veor @t[2], @x[5], @x[7] + veor @t[1], @x[1], @x[3] + veor @s[1], @x[7], @x[6] + vmov @t[0], @t[2] + veor @s[0], @x[0], @x[2] + + vorr @t[2], @t[2], @t[1] + veor @s[3], @t[3], @t[0] + vand @s[2], @t[3], @s[0] + vorr @t[3], @t[3], @s[0] + veor @s[0], @s[0], @t[1] + vand @t[0], @t[0], @t[1] + veor @t[1], @x[3], @x[2] + vand @s[3], @s[3], @s[0] + vand @s[1], @s[1], @t[1] + veor @t[1], @x[4], @x[5] + veor @s[0], @x[1], @x[0] + veor @t[3], @t[3], @s[1] + veor @t[2], @t[2], @s[1] + vand @s[1], @t[1], @s[0] + vorr @t[1], @t[1], @s[0] + veor @t[3], @t[3], @s[3] + veor @t[0], @t[0], @s[1] + veor @t[2], @t[2], @s[2] + veor @t[1], @t[1], @s[3] + veor @t[0], @t[0], @s[2] + vand @s[0], @x[7], @x[3] + veor @t[1], @t[1], @s[2] + vand @s[1], @x[6], @x[2] + vand @s[2], @x[5], @x[1] + vorr @s[3], @x[4], @x[0] + veor @t[3], @t[3], @s[0] + veor @t[1], @t[1], @s[2] + veor @t[0], @t[0], @s[3] + veor @t[2], @t[2], @s[1] + + @ Inv_GF16 \t0, \t1, \t2, \t3, \s0, \s1, \s2, \s3 + + @ new smaller inversion + + vand @s[2], @t[3], @t[1] + vmov @s[0], @t[0] + + veor @s[1], @t[2], @s[2] + veor @s[3], @t[0], @s[2] + veor @s[2], @t[0], @s[2] @ @s[2]=@s[3] + + vbsl @s[1], @t[1], @t[0] + vbsl @s[3], @t[3], @t[2] + veor @t[3], @t[3], @t[2] + + vbsl @s[0], @s[1], @s[2] + vbsl @t[0], @s[2], @s[1] + + vand @s[2], @s[0], @s[3] + veor @t[1], @t[1], @t[0] + + veor @s[2], @s[2], @t[3] +___ +# output in s3, s2, s1, t1 + +# Mul_GF16_2 \x0, \x1, \x2, \x3, \x4, \x5, \x6, \x7, \t2, \t3, \t0, \t1, \s0, \s1, \s2, \s3 + +# Mul_GF16_2 \x0, \x1, \x2, \x3, \x4, \x5, \x6, \x7, \s3, \s2, \s1, \t1, \s0, \t0, \t2, \t3 + &Mul_GF16_2(@x,@s[3,2,1],@t[1],@s[0],@t[0,2,3]); + +### output msb > [x3,x2,x1,x0,x7,x6,x5,x4] < lsb +} + +# AES linear components + +sub ShiftRows { +my @x=@_[0..7]; +my @t=@_[8..11]; +my $mask=pop; +$code.=<<___; + vldmia $key!, {@t[0]-@t[3]} + veor @t[0], @t[0], @x[0] + veor @t[1], @t[1], @x[1] + vtbl.8 `&Dlo(@x[0])`, {@t[0]}, `&Dlo($mask)` + vtbl.8 `&Dhi(@x[0])`, {@t[0]}, `&Dhi($mask)` + vldmia $key!, {@t[0]} + veor @t[2], @t[2], @x[2] + vtbl.8 `&Dlo(@x[1])`, {@t[1]}, `&Dlo($mask)` + vtbl.8 `&Dhi(@x[1])`, {@t[1]}, `&Dhi($mask)` + vldmia $key!, {@t[1]} + veor @t[3], @t[3], @x[3] + vtbl.8 `&Dlo(@x[2])`, {@t[2]}, `&Dlo($mask)` + vtbl.8 `&Dhi(@x[2])`, {@t[2]}, `&Dhi($mask)` + vldmia $key!, {@t[2]} + vtbl.8 `&Dlo(@x[3])`, {@t[3]}, `&Dlo($mask)` + vtbl.8 `&Dhi(@x[3])`, {@t[3]}, `&Dhi($mask)` + vldmia $key!, {@t[3]} + veor @t[0], @t[0], @x[4] + veor @t[1], @t[1], @x[5] + vtbl.8 `&Dlo(@x[4])`, {@t[0]}, `&Dlo($mask)` + vtbl.8 `&Dhi(@x[4])`, {@t[0]}, `&Dhi($mask)` + veor @t[2], @t[2], @x[6] + vtbl.8 `&Dlo(@x[5])`, {@t[1]}, `&Dlo($mask)` + vtbl.8 `&Dhi(@x[5])`, {@t[1]}, `&Dhi($mask)` + veor @t[3], @t[3], @x[7] + vtbl.8 `&Dlo(@x[6])`, {@t[2]}, `&Dlo($mask)` + vtbl.8 `&Dhi(@x[6])`, {@t[2]}, `&Dhi($mask)` + vtbl.8 `&Dlo(@x[7])`, {@t[3]}, `&Dlo($mask)` + vtbl.8 `&Dhi(@x[7])`, {@t[3]}, `&Dhi($mask)` +___ +} + +sub MixColumns { +# modified to emit output in order suitable for feeding back to aesenc[last] +my @x=@_[0..7]; +my @t=@_[8..15]; +my $inv=@_[16]; # optional +$code.=<<___; + vext.8 @t[0], @x[0], @x[0], #12 @ x0 <<< 32 + vext.8 @t[1], @x[1], @x[1], #12 + veor @x[0], @x[0], @t[0] @ x0 ^ (x0 <<< 32) + vext.8 @t[2], @x[2], @x[2], #12 + veor @x[1], @x[1], @t[1] + vext.8 @t[3], @x[3], @x[3], #12 + veor @x[2], @x[2], @t[2] + vext.8 @t[4], @x[4], @x[4], #12 + veor @x[3], @x[3], @t[3] + vext.8 @t[5], @x[5], @x[5], #12 + veor @x[4], @x[4], @t[4] + vext.8 @t[6], @x[6], @x[6], #12 + veor @x[5], @x[5], @t[5] + vext.8 @t[7], @x[7], @x[7], #12 + veor @x[6], @x[6], @t[6] + + veor @t[1], @t[1], @x[0] + veor @x[7], @x[7], @t[7] + vext.8 @x[0], @x[0], @x[0], #8 @ (x0 ^ (x0 <<< 32)) <<< 64) + veor @t[2], @t[2], @x[1] + veor @t[0], @t[0], @x[7] + veor @t[1], @t[1], @x[7] + vext.8 @x[1], @x[1], @x[1], #8 + veor @t[5], @t[5], @x[4] + veor @x[0], @x[0], @t[0] + veor @t[6], @t[6], @x[5] + veor @x[1], @x[1], @t[1] + vext.8 @t[0], @x[4], @x[4], #8 + veor @t[4], @t[4], @x[3] + vext.8 @t[1], @x[5], @x[5], #8 + veor @t[7], @t[7], @x[6] + vext.8 @x[4], @x[3], @x[3], #8 + veor @t[3], @t[3], @x[2] + vext.8 @x[5], @x[7], @x[7], #8 + veor @t[4], @t[4], @x[7] + vext.8 @x[3], @x[6], @x[6], #8 + veor @t[3], @t[3], @x[7] + vext.8 @x[6], @x[2], @x[2], #8 + veor @x[7], @t[1], @t[5] +___ +$code.=<<___ if (!$inv); + veor @x[2], @t[0], @t[4] + veor @x[4], @x[4], @t[3] + veor @x[5], @x[5], @t[7] + veor @x[3], @x[3], @t[6] + @ vmov @x[2], @t[0] + veor @x[6], @x[6], @t[2] + @ vmov @x[7], @t[1] +___ +$code.=<<___ if ($inv); + veor @t[3], @t[3], @x[4] + veor @x[5], @x[5], @t[7] + veor @x[2], @x[3], @t[6] + veor @x[3], @t[0], @t[4] + veor @x[4], @x[6], @t[2] + vmov @x[6], @t[3] + @ vmov @x[7], @t[1] +___ +} + +sub InvMixColumns_orig { +my @x=@_[0..7]; +my @t=@_[8..15]; + +$code.=<<___; + @ multiplication by 0x0e + vext.8 @t[7], @x[7], @x[7], #12 + vmov @t[2], @x[2] + veor @x[2], @x[2], @x[5] @ 2 5 + veor @x[7], @x[7], @x[5] @ 7 5 + vext.8 @t[0], @x[0], @x[0], #12 + vmov @t[5], @x[5] + veor @x[5], @x[5], @x[0] @ 5 0 [1] + veor @x[0], @x[0], @x[1] @ 0 1 + vext.8 @t[1], @x[1], @x[1], #12 + veor @x[1], @x[1], @x[2] @ 1 25 + veor @x[0], @x[0], @x[6] @ 01 6 [2] + vext.8 @t[3], @x[3], @x[3], #12 + veor @x[1], @x[1], @x[3] @ 125 3 [4] + veor @x[2], @x[2], @x[0] @ 25 016 [3] + veor @x[3], @x[3], @x[7] @ 3 75 + veor @x[7], @x[7], @x[6] @ 75 6 [0] + vext.8 @t[6], @x[6], @x[6], #12 + vmov @t[4], @x[4] + veor @x[6], @x[6], @x[4] @ 6 4 + veor @x[4], @x[4], @x[3] @ 4 375 [6] + veor @x[3], @x[3], @x[7] @ 375 756=36 + veor @x[6], @x[6], @t[5] @ 64 5 [7] + veor @x[3], @x[3], @t[2] @ 36 2 + vext.8 @t[5], @t[5], @t[5], #12 + veor @x[3], @x[3], @t[4] @ 362 4 [5] +___ + my @y = @x[7,5,0,2,1,3,4,6]; +$code.=<<___; + @ multiplication by 0x0b + veor @y[1], @y[1], @y[0] + veor @y[0], @y[0], @t[0] + vext.8 @t[2], @t[2], @t[2], #12 + veor @y[1], @y[1], @t[1] + veor @y[0], @y[0], @t[5] + vext.8 @t[4], @t[4], @t[4], #12 + veor @y[1], @y[1], @t[6] + veor @y[0], @y[0], @t[7] + veor @t[7], @t[7], @t[6] @ clobber t[7] + + veor @y[3], @y[3], @t[0] + veor @y[1], @y[1], @y[0] + vext.8 @t[0], @t[0], @t[0], #12 + veor @y[2], @y[2], @t[1] + veor @y[4], @y[4], @t[1] + vext.8 @t[1], @t[1], @t[1], #12 + veor @y[2], @y[2], @t[2] + veor @y[3], @y[3], @t[2] + veor @y[5], @y[5], @t[2] + veor @y[2], @y[2], @t[7] + vext.8 @t[2], @t[2], @t[2], #12 + veor @y[3], @y[3], @t[3] + veor @y[6], @y[6], @t[3] + veor @y[4], @y[4], @t[3] + veor @y[7], @y[7], @t[4] + vext.8 @t[3], @t[3], @t[3], #12 + veor @y[5], @y[5], @t[4] + veor @y[7], @y[7], @t[7] + veor @t[7], @t[7], @t[5] @ clobber t[7] even more + veor @y[3], @y[3], @t[5] + veor @y[4], @y[4], @t[4] + + veor @y[5], @y[5], @t[7] + vext.8 @t[4], @t[4], @t[4], #12 + veor @y[6], @y[6], @t[7] + veor @y[4], @y[4], @t[7] + + veor @t[7], @t[7], @t[5] + vext.8 @t[5], @t[5], @t[5], #12 + + @ multiplication by 0x0d + veor @y[4], @y[4], @y[7] + veor @t[7], @t[7], @t[6] @ restore t[7] + veor @y[7], @y[7], @t[4] + vext.8 @t[6], @t[6], @t[6], #12 + veor @y[2], @y[2], @t[0] + veor @y[7], @y[7], @t[5] + vext.8 @t[7], @t[7], @t[7], #12 + veor @y[2], @y[2], @t[2] + + veor @y[3], @y[3], @y[1] + veor @y[1], @y[1], @t[1] + veor @y[0], @y[0], @t[0] + veor @y[3], @y[3], @t[0] + veor @y[1], @y[1], @t[5] + veor @y[0], @y[0], @t[5] + vext.8 @t[0], @t[0], @t[0], #12 + veor @y[1], @y[1], @t[7] + veor @y[0], @y[0], @t[6] + veor @y[3], @y[3], @y[1] + veor @y[4], @y[4], @t[1] + vext.8 @t[1], @t[1], @t[1], #12 + + veor @y[7], @y[7], @t[7] + veor @y[4], @y[4], @t[2] + veor @y[5], @y[5], @t[2] + veor @y[2], @y[2], @t[6] + veor @t[6], @t[6], @t[3] @ clobber t[6] + vext.8 @t[2], @t[2], @t[2], #12 + veor @y[4], @y[4], @y[7] + veor @y[3], @y[3], @t[6] + + veor @y[6], @y[6], @t[6] + veor @y[5], @y[5], @t[5] + vext.8 @t[5], @t[5], @t[5], #12 + veor @y[6], @y[6], @t[4] + vext.8 @t[4], @t[4], @t[4], #12 + veor @y[5], @y[5], @t[6] + veor @y[6], @y[6], @t[7] + vext.8 @t[7], @t[7], @t[7], #12 + veor @t[6], @t[6], @t[3] @ restore t[6] + vext.8 @t[3], @t[3], @t[3], #12 + + @ multiplication by 0x09 + veor @y[4], @y[4], @y[1] + veor @t[1], @t[1], @y[1] @ t[1]=y[1] + veor @t[0], @t[0], @t[5] @ clobber t[0] + vext.8 @t[6], @t[6], @t[6], #12 + veor @t[1], @t[1], @t[5] + veor @y[3], @y[3], @t[0] + veor @t[0], @t[0], @y[0] @ t[0]=y[0] + veor @t[1], @t[1], @t[6] + veor @t[6], @t[6], @t[7] @ clobber t[6] + veor @y[4], @y[4], @t[1] + veor @y[7], @y[7], @t[4] + veor @y[6], @y[6], @t[3] + veor @y[5], @y[5], @t[2] + veor @t[4], @t[4], @y[4] @ t[4]=y[4] + veor @t[3], @t[3], @y[3] @ t[3]=y[3] + veor @t[5], @t[5], @y[5] @ t[5]=y[5] + veor @t[2], @t[2], @y[2] @ t[2]=y[2] + veor @t[3], @t[3], @t[7] + veor @XMM[5], @t[5], @t[6] + veor @XMM[6], @t[6], @y[6] @ t[6]=y[6] + veor @XMM[2], @t[2], @t[6] + veor @XMM[7], @t[7], @y[7] @ t[7]=y[7] + + vmov @XMM[0], @t[0] + vmov @XMM[1], @t[1] + @ vmov @XMM[2], @t[2] + vmov @XMM[3], @t[3] + vmov @XMM[4], @t[4] + @ vmov @XMM[5], @t[5] + @ vmov @XMM[6], @t[6] + @ vmov @XMM[7], @t[7] +___ +} + +sub InvMixColumns { +my @x=@_[0..7]; +my @t=@_[8..15]; + +# Thanks to Jussi Kivilinna for providing pointer to +# +# | 0e 0b 0d 09 | | 02 03 01 01 | | 05 00 04 00 | +# | 09 0e 0b 0d | = | 01 02 03 01 | x | 00 05 00 04 | +# | 0d 09 0e 0b | | 01 01 02 03 | | 04 00 05 00 | +# | 0b 0d 09 0e | | 03 01 01 02 | | 00 04 00 05 | + +$code.=<<___; + @ multiplication by 0x05-0x00-0x04-0x00 + vext.8 @t[0], @x[0], @x[0], #8 + vext.8 @t[6], @x[6], @x[6], #8 + vext.8 @t[7], @x[7], @x[7], #8 + veor @t[0], @t[0], @x[0] + vext.8 @t[1], @x[1], @x[1], #8 + veor @t[6], @t[6], @x[6] + vext.8 @t[2], @x[2], @x[2], #8 + veor @t[7], @t[7], @x[7] + vext.8 @t[3], @x[3], @x[3], #8 + veor @t[1], @t[1], @x[1] + vext.8 @t[4], @x[4], @x[4], #8 + veor @t[2], @t[2], @x[2] + vext.8 @t[5], @x[5], @x[5], #8 + veor @t[3], @t[3], @x[3] + veor @t[4], @t[4], @x[4] + veor @t[5], @t[5], @x[5] + + veor @x[0], @x[0], @t[6] + veor @x[1], @x[1], @t[6] + veor @x[2], @x[2], @t[0] + veor @x[4], @x[4], @t[2] + veor @x[3], @x[3], @t[1] + veor @x[1], @x[1], @t[7] + veor @x[2], @x[2], @t[7] + veor @x[4], @x[4], @t[6] + veor @x[5], @x[5], @t[3] + veor @x[3], @x[3], @t[6] + veor @x[6], @x[6], @t[4] + veor @x[4], @x[4], @t[7] + veor @x[5], @x[5], @t[7] + veor @x[7], @x[7], @t[5] +___ + &MixColumns (@x,@t,1); # flipped 2<->3 and 4<->6 +} + +sub swapmove { +my ($a,$b,$n,$mask,$t)=@_; +$code.=<<___; + vshr.u64 $t, $b, #$n + veor $t, $t, $a + vand $t, $t, $mask + veor $a, $a, $t + vshl.u64 $t, $t, #$n + veor $b, $b, $t +___ +} +sub swapmove2x { +my ($a0,$b0,$a1,$b1,$n,$mask,$t0,$t1)=@_; +$code.=<<___; + vshr.u64 $t0, $b0, #$n + vshr.u64 $t1, $b1, #$n + veor $t0, $t0, $a0 + veor $t1, $t1, $a1 + vand $t0, $t0, $mask + vand $t1, $t1, $mask + veor $a0, $a0, $t0 + vshl.u64 $t0, $t0, #$n + veor $a1, $a1, $t1 + vshl.u64 $t1, $t1, #$n + veor $b0, $b0, $t0 + veor $b1, $b1, $t1 +___ +} + +sub bitslice { +my @x=reverse(@_[0..7]); +my ($t0,$t1,$t2,$t3)=@_[8..11]; +$code.=<<___; + vmov.i8 $t0,#0x55 @ compose .LBS0 + vmov.i8 $t1,#0x33 @ compose .LBS1 +___ + &swapmove2x(@x[0,1,2,3],1,$t0,$t2,$t3); + &swapmove2x(@x[4,5,6,7],1,$t0,$t2,$t3); +$code.=<<___; + vmov.i8 $t0,#0x0f @ compose .LBS2 +___ + &swapmove2x(@x[0,2,1,3],2,$t1,$t2,$t3); + &swapmove2x(@x[4,6,5,7],2,$t1,$t2,$t3); + + &swapmove2x(@x[0,4,1,5],4,$t0,$t2,$t3); + &swapmove2x(@x[2,6,3,7],4,$t0,$t2,$t3); +} + +$code.=<<___; +#ifndef __KERNEL__ +# define VFP_ABI_PUSH vstmdb sp!,{d8-d15} +# define VFP_ABI_POP vldmia sp!,{d8-d15} +# define VFP_ABI_FRAME 0x40 +#else +# define VFP_ABI_PUSH +# define VFP_ABI_POP +# define VFP_ABI_FRAME 0 +# define BSAES_ASM_EXTENDED_KEY +# define __ARM_MAX_ARCH__ 7 +#endif + +#ifdef __thumb__ +# define adrl adr +#endif + +#if __ARM_MAX_ARCH__>=7 +.arch armv7-a +.fpu neon + +.text +.syntax unified @ ARMv7-capable assembler is expected to handle this +#if defined(__thumb2__) && !defined(__APPLE__) +.thumb +#else +.code 32 +# undef __thumb2__ +#endif + +.type _bsaes_const,%object +.align 6 +_bsaes_const: +.LM0ISR: @ InvShiftRows constants + .quad 0x0a0e0206070b0f03, 0x0004080c0d010509 +.LISR: + .quad 0x0504070602010003, 0x0f0e0d0c080b0a09 +.LISRM0: + .quad 0x01040b0e0205080f, 0x0306090c00070a0d +.LM0SR: @ ShiftRows constants + .quad 0x0a0e02060f03070b, 0x0004080c05090d01 +.LSR: + .quad 0x0504070600030201, 0x0f0e0d0c0a09080b +.LSRM0: + .quad 0x0304090e00050a0f, 0x01060b0c0207080d +.LM0: + .quad 0x02060a0e03070b0f, 0x0004080c0105090d +.LREVM0SR: + .quad 0x090d01050c000408, 0x03070b0f060a0e02 +.asciz "Bit-sliced AES for NEON, CRYPTOGAMS by " +.align 6 +.size _bsaes_const,.-_bsaes_const + +.type _bsaes_encrypt8,%function +.align 4 +_bsaes_encrypt8: + adr $const,. + vldmia $key!, {@XMM[9]} @ round 0 key +#if defined(__thumb2__) || defined(__APPLE__) + adr $const,.LM0SR +#else + sub $const,$const,#_bsaes_encrypt8-.LM0SR +#endif + + vldmia $const!, {@XMM[8]} @ .LM0SR +_bsaes_encrypt8_alt: + veor @XMM[10], @XMM[0], @XMM[9] @ xor with round0 key + veor @XMM[11], @XMM[1], @XMM[9] + vtbl.8 `&Dlo(@XMM[0])`, {@XMM[10]}, `&Dlo(@XMM[8])` + vtbl.8 `&Dhi(@XMM[0])`, {@XMM[10]}, `&Dhi(@XMM[8])` + veor @XMM[12], @XMM[2], @XMM[9] + vtbl.8 `&Dlo(@XMM[1])`, {@XMM[11]}, `&Dlo(@XMM[8])` + vtbl.8 `&Dhi(@XMM[1])`, {@XMM[11]}, `&Dhi(@XMM[8])` + veor @XMM[13], @XMM[3], @XMM[9] + vtbl.8 `&Dlo(@XMM[2])`, {@XMM[12]}, `&Dlo(@XMM[8])` + vtbl.8 `&Dhi(@XMM[2])`, {@XMM[12]}, `&Dhi(@XMM[8])` + veor @XMM[14], @XMM[4], @XMM[9] + vtbl.8 `&Dlo(@XMM[3])`, {@XMM[13]}, `&Dlo(@XMM[8])` + vtbl.8 `&Dhi(@XMM[3])`, {@XMM[13]}, `&Dhi(@XMM[8])` + veor @XMM[15], @XMM[5], @XMM[9] + vtbl.8 `&Dlo(@XMM[4])`, {@XMM[14]}, `&Dlo(@XMM[8])` + vtbl.8 `&Dhi(@XMM[4])`, {@XMM[14]}, `&Dhi(@XMM[8])` + veor @XMM[10], @XMM[6], @XMM[9] + vtbl.8 `&Dlo(@XMM[5])`, {@XMM[15]}, `&Dlo(@XMM[8])` + vtbl.8 `&Dhi(@XMM[5])`, {@XMM[15]}, `&Dhi(@XMM[8])` + veor @XMM[11], @XMM[7], @XMM[9] + vtbl.8 `&Dlo(@XMM[6])`, {@XMM[10]}, `&Dlo(@XMM[8])` + vtbl.8 `&Dhi(@XMM[6])`, {@XMM[10]}, `&Dhi(@XMM[8])` + vtbl.8 `&Dlo(@XMM[7])`, {@XMM[11]}, `&Dlo(@XMM[8])` + vtbl.8 `&Dhi(@XMM[7])`, {@XMM[11]}, `&Dhi(@XMM[8])` +_bsaes_encrypt8_bitslice: +___ + &bitslice (@XMM[0..7, 8..11]); +$code.=<<___; + sub $rounds,$rounds,#1 + b .Lenc_sbox +.align 4 +.Lenc_loop: +___ + &ShiftRows (@XMM[0..7, 8..12]); +$code.=".Lenc_sbox:\n"; + &Sbox (@XMM[0..7, 8..15]); +$code.=<<___; + subs $rounds,$rounds,#1 + bcc .Lenc_done +___ + &MixColumns (@XMM[0,1,4,6,3,7,2,5, 8..15]); +$code.=<<___; + vldmia $const, {@XMM[12]} @ .LSR + ite eq @ Thumb2 thing, samity check in ARM + addeq $const,$const,#0x10 + bne .Lenc_loop + vldmia $const, {@XMM[12]} @ .LSRM0 + b .Lenc_loop +.align 4 +.Lenc_done: +___ + # output in lsb > [t0, t1, t4, t6, t3, t7, t2, t5] < msb + &bitslice (@XMM[0,1,4,6,3,7,2,5, 8..11]); +$code.=<<___; + vldmia $key, {@XMM[8]} @ last round key + veor @XMM[4], @XMM[4], @XMM[8] + veor @XMM[6], @XMM[6], @XMM[8] + veor @XMM[3], @XMM[3], @XMM[8] + veor @XMM[7], @XMM[7], @XMM[8] + veor @XMM[2], @XMM[2], @XMM[8] + veor @XMM[5], @XMM[5], @XMM[8] + veor @XMM[0], @XMM[0], @XMM[8] + veor @XMM[1], @XMM[1], @XMM[8] + bx lr +.size _bsaes_encrypt8,.-_bsaes_encrypt8 +___ +} +{ +my ($out,$inp,$rounds,$const)=("r12","r4","r5","r6"); + +sub bitslice_key { +my @x=reverse(@_[0..7]); +my ($bs0,$bs1,$bs2,$t2,$t3)=@_[8..12]; + + &swapmove (@x[0,1],1,$bs0,$t2,$t3); +$code.=<<___; + @ &swapmove(@x[2,3],1,$t0,$t2,$t3); + vmov @x[2], @x[0] + vmov @x[3], @x[1] +___ + #&swapmove2x(@x[4,5,6,7],1,$t0,$t2,$t3); + + &swapmove2x (@x[0,2,1,3],2,$bs1,$t2,$t3); +$code.=<<___; + @ &swapmove2x(@x[4,6,5,7],2,$t1,$t2,$t3); + vmov @x[4], @x[0] + vmov @x[6], @x[2] + vmov @x[5], @x[1] + vmov @x[7], @x[3] +___ + &swapmove2x (@x[0,4,1,5],4,$bs2,$t2,$t3); + &swapmove2x (@x[2,6,3,7],4,$bs2,$t2,$t3); +} + +$code.=<<___; +.type _bsaes_key_convert,%function +.align 4 +_bsaes_key_convert: + adr $const,. + vld1.8 {@XMM[7]}, [$inp]! @ load round 0 key +#if defined(__thumb2__) || defined(__APPLE__) + adr $const,.LM0 +#else + sub $const,$const,#_bsaes_key_convert-.LM0 +#endif + vld1.8 {@XMM[15]}, [$inp]! @ load round 1 key + + vmov.i8 @XMM[8], #0x01 @ bit masks + vmov.i8 @XMM[9], #0x02 + vmov.i8 @XMM[10], #0x04 + vmov.i8 @XMM[11], #0x08 + vmov.i8 @XMM[12], #0x10 + vmov.i8 @XMM[13], #0x20 + vldmia $const, {@XMM[14]} @ .LM0 + +#ifdef __ARMEL__ + vrev32.8 @XMM[7], @XMM[7] + vrev32.8 @XMM[15], @XMM[15] +#endif + sub $rounds,$rounds,#1 + vstmia $out!, {@XMM[7]} @ save round 0 key + b .Lkey_loop + +.align 4 +.Lkey_loop: + vtbl.8 `&Dlo(@XMM[7])`,{@XMM[15]},`&Dlo(@XMM[14])` + vtbl.8 `&Dhi(@XMM[7])`,{@XMM[15]},`&Dhi(@XMM[14])` + vmov.i8 @XMM[6], #0x40 + vmov.i8 @XMM[15], #0x80 + + vtst.8 @XMM[0], @XMM[7], @XMM[8] + vtst.8 @XMM[1], @XMM[7], @XMM[9] + vtst.8 @XMM[2], @XMM[7], @XMM[10] + vtst.8 @XMM[3], @XMM[7], @XMM[11] + vtst.8 @XMM[4], @XMM[7], @XMM[12] + vtst.8 @XMM[5], @XMM[7], @XMM[13] + vtst.8 @XMM[6], @XMM[7], @XMM[6] + vtst.8 @XMM[7], @XMM[7], @XMM[15] + vld1.8 {@XMM[15]}, [$inp]! @ load next round key + vmvn @XMM[0], @XMM[0] @ "pnot" + vmvn @XMM[1], @XMM[1] + vmvn @XMM[5], @XMM[5] + vmvn @XMM[6], @XMM[6] +#ifdef __ARMEL__ + vrev32.8 @XMM[15], @XMM[15] +#endif + subs $rounds,$rounds,#1 + vstmia $out!,{@XMM[0]-@XMM[7]} @ write bit-sliced round key + bne .Lkey_loop + + vmov.i8 @XMM[7],#0x63 @ compose .L63 + @ don't save last round key + bx lr +.size _bsaes_key_convert,.-_bsaes_key_convert +___ +} + +{ +my ($inp,$out,$len,$key, $ctr,$fp,$rounds)=(map("r$_",(0..3,8..10))); +my $const = "r6"; # shared with _bsaes_encrypt8_alt +my $keysched = "sp"; + +$code.=<<___; +.global bsaes_ctr32_encrypt_blocks +.type bsaes_ctr32_encrypt_blocks,%function +.align 5 +bsaes_ctr32_encrypt_blocks: + @ In OpenSSL, short inputs fall back to aes_nohw_* here. We patch this + @ out to retain a constant-time implementation. + mov ip, sp + stmdb sp!, {r4-r10, lr} + VFP_ABI_PUSH + ldr $ctr, [ip] @ ctr is 1st arg on the stack + sub sp, sp, #0x10 @ scratch space to carry over the ctr + mov $fp, sp @ save sp + + ldr $rounds, [$key, #240] @ get # of rounds +#ifndef BSAES_ASM_EXTENDED_KEY + @ allocate the key schedule on the stack + sub r12, sp, $rounds, lsl#7 @ 128 bytes per inner round key + add r12, #`128-32` @ size of bit-sliced key schedule + + @ populate the key schedule + mov r4, $key @ pass key + mov r5, $rounds @ pass # of rounds + mov sp, r12 @ sp is $keysched + bl _bsaes_key_convert + veor @XMM[7],@XMM[7],@XMM[15] @ fix up last round key + vstmia r12, {@XMM[7]} @ save last round key + + vld1.8 {@XMM[0]}, [$ctr] @ load counter +#ifdef __APPLE__ + mov $ctr, #:lower16:(.LREVM0SR-.LM0) + add $ctr, $const, $ctr +#else + add $ctr, $const, #.LREVM0SR-.LM0 @ borrow $ctr +#endif + vldmia $keysched, {@XMM[4]} @ load round0 key +#else + ldr r12, [$key, #244] + eors r12, #1 + beq 0f + + @ populate the key schedule + str r12, [$key, #244] + mov r4, $key @ pass key + mov r5, $rounds @ pass # of rounds + add r12, $key, #248 @ pass key schedule + bl _bsaes_key_convert + veor @XMM[7],@XMM[7],@XMM[15] @ fix up last round key + vstmia r12, {@XMM[7]} @ save last round key + +.align 2 +0: add r12, $key, #248 + vld1.8 {@XMM[0]}, [$ctr] @ load counter + adrl $ctr, .LREVM0SR @ borrow $ctr + vldmia r12, {@XMM[4]} @ load round0 key + sub sp, #0x10 @ place for adjusted round0 key +#endif + + vmov.i32 @XMM[8],#1 @ compose 1<<96 + veor @XMM[9],@XMM[9],@XMM[9] + vrev32.8 @XMM[0],@XMM[0] + vext.8 @XMM[8],@XMM[9],@XMM[8],#4 + vrev32.8 @XMM[4],@XMM[4] + vadd.u32 @XMM[9],@XMM[8],@XMM[8] @ compose 2<<96 + vstmia $keysched, {@XMM[4]} @ save adjusted round0 key + b .Lctr_enc_loop + +.align 4 +.Lctr_enc_loop: + vadd.u32 @XMM[10], @XMM[8], @XMM[9] @ compose 3<<96 + vadd.u32 @XMM[1], @XMM[0], @XMM[8] @ +1 + vadd.u32 @XMM[2], @XMM[0], @XMM[9] @ +2 + vadd.u32 @XMM[3], @XMM[0], @XMM[10] @ +3 + vadd.u32 @XMM[4], @XMM[1], @XMM[10] + vadd.u32 @XMM[5], @XMM[2], @XMM[10] + vadd.u32 @XMM[6], @XMM[3], @XMM[10] + vadd.u32 @XMM[7], @XMM[4], @XMM[10] + vadd.u32 @XMM[10], @XMM[5], @XMM[10] @ next counter + + @ Borrow prologue from _bsaes_encrypt8 to use the opportunity + @ to flip byte order in 32-bit counter + + vldmia $keysched, {@XMM[9]} @ load round0 key +#ifndef BSAES_ASM_EXTENDED_KEY + add r4, $keysched, #0x10 @ pass next round key +#else + add r4, $key, #`248+16` +#endif + vldmia $ctr, {@XMM[8]} @ .LREVM0SR + mov r5, $rounds @ pass rounds + vstmia $fp, {@XMM[10]} @ save next counter +#ifdef __APPLE__ + mov $const, #:lower16:(.LREVM0SR-.LSR) + sub $const, $ctr, $const +#else + sub $const, $ctr, #.LREVM0SR-.LSR @ pass constants +#endif + + bl _bsaes_encrypt8_alt + + subs $len, $len, #8 + blo .Lctr_enc_loop_done + + vld1.8 {@XMM[8]-@XMM[9]}, [$inp]! @ load input + vld1.8 {@XMM[10]-@XMM[11]}, [$inp]! + veor @XMM[0], @XMM[8] + veor @XMM[1], @XMM[9] + vld1.8 {@XMM[12]-@XMM[13]}, [$inp]! + veor @XMM[4], @XMM[10] + veor @XMM[6], @XMM[11] + vld1.8 {@XMM[14]-@XMM[15]}, [$inp]! + veor @XMM[3], @XMM[12] + vst1.8 {@XMM[0]-@XMM[1]}, [$out]! @ write output + veor @XMM[7], @XMM[13] + veor @XMM[2], @XMM[14] + vst1.8 {@XMM[4]}, [$out]! + veor @XMM[5], @XMM[15] + vst1.8 {@XMM[6]}, [$out]! + vmov.i32 @XMM[8], #1 @ compose 1<<96 + vst1.8 {@XMM[3]}, [$out]! + veor @XMM[9], @XMM[9], @XMM[9] + vst1.8 {@XMM[7]}, [$out]! + vext.8 @XMM[8], @XMM[9], @XMM[8], #4 + vst1.8 {@XMM[2]}, [$out]! + vadd.u32 @XMM[9],@XMM[8],@XMM[8] @ compose 2<<96 + vst1.8 {@XMM[5]}, [$out]! + vldmia $fp, {@XMM[0]} @ load counter + + bne .Lctr_enc_loop + b .Lctr_enc_done + +.align 4 +.Lctr_enc_loop_done: + add $len, $len, #8 + vld1.8 {@XMM[8]}, [$inp]! @ load input + veor @XMM[0], @XMM[8] + vst1.8 {@XMM[0]}, [$out]! @ write output + cmp $len, #2 + blo .Lctr_enc_done + vld1.8 {@XMM[9]}, [$inp]! + veor @XMM[1], @XMM[9] + vst1.8 {@XMM[1]}, [$out]! + beq .Lctr_enc_done + vld1.8 {@XMM[10]}, [$inp]! + veor @XMM[4], @XMM[10] + vst1.8 {@XMM[4]}, [$out]! + cmp $len, #4 + blo .Lctr_enc_done + vld1.8 {@XMM[11]}, [$inp]! + veor @XMM[6], @XMM[11] + vst1.8 {@XMM[6]}, [$out]! + beq .Lctr_enc_done + vld1.8 {@XMM[12]}, [$inp]! + veor @XMM[3], @XMM[12] + vst1.8 {@XMM[3]}, [$out]! + cmp $len, #6 + blo .Lctr_enc_done + vld1.8 {@XMM[13]}, [$inp]! + veor @XMM[7], @XMM[13] + vst1.8 {@XMM[7]}, [$out]! + beq .Lctr_enc_done + vld1.8 {@XMM[14]}, [$inp] + veor @XMM[2], @XMM[14] + vst1.8 {@XMM[2]}, [$out]! + +.Lctr_enc_done: + vmov.i32 q0, #0 + vmov.i32 q1, #0 +#ifndef BSAES_ASM_EXTENDED_KEY +.Lctr_enc_bzero: @ wipe key schedule [if any] + vstmia $keysched!, {q0-q1} + cmp $keysched, $fp + bne .Lctr_enc_bzero +#else + vstmia $keysched, {q0-q1} +#endif + + mov sp, $fp + add sp, #0x10 @ add sp,$fp,#0x10 is no good for thumb + VFP_ABI_POP + ldmia sp!, {r4-r10, pc} @ return + + @ OpenSSL contains aes_nohw_* fallback code here. We patch this + @ out to retain a constant-time implementation. +.size bsaes_ctr32_encrypt_blocks,.-bsaes_ctr32_encrypt_blocks +___ +} +$code.=<<___; +#endif +___ + +$code =~ s/\`([^\`]*)\`/eval($1)/gem; + +open SELF,$0; +while() { + next if (/^#!/); + last if (!s/^#/@/ and !/^$/); + print; +} +close SELF; + +print $code; + +close STDOUT or die "error closing STDOUT: $!"; diff --git a/http/vendor/ring/crypto/fipsmodule/aes/asm/ghash-armv4.pl b/http/vendor/ring/crypto/fipsmodule/aes/asm/ghash-armv4.pl new file mode 100644 index 0000000..c16ed37 --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/aes/asm/ghash-armv4.pl @@ -0,0 +1,303 @@ +#! /usr/bin/env perl +# Copyright 2010-2018 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# ==================================================================== +# Written by Andy Polyakov for the OpenSSL +# project. +# ==================================================================== +# +# April 2010 +# +# The module implements "4-bit" GCM GHASH function and underlying +# single multiplication operation in GF(2^128). "4-bit" means that it +# uses 256 bytes per-key table [+32 bytes shared table]. There is no +# experimental performance data available yet. The only approximation +# that can be made at this point is based on code size. Inner loop is +# 32 instructions long and on single-issue core should execute in <40 +# cycles. Having verified that gcc 3.4 didn't unroll corresponding +# loop, this assembler loop body was found to be ~3x smaller than +# compiler-generated one... +# +# July 2010 +# +# Rescheduling for dual-issue pipeline resulted in 8.5% improvement on +# Cortex A8 core and ~25 cycles per processed byte (which was observed +# to be ~3 times faster than gcc-generated code:-) +# +# February 2011 +# +# Profiler-assisted and platform-specific optimization resulted in 7% +# improvement on Cortex A8 core and ~23.5 cycles per byte. +# +# March 2011 +# +# Add NEON implementation featuring polynomial multiplication, i.e. no +# lookup tables involved. On Cortex A8 it was measured to process one +# byte in 15 cycles or 55% faster than integer-only code. +# +# April 2014 +# +# Switch to multiplication algorithm suggested in paper referred +# below and combine it with reduction algorithm from x86 module. +# Performance improvement over previous version varies from 65% on +# Snapdragon S4 to 110% on Cortex A9. In absolute terms Cortex A8 +# processes one byte in 8.45 cycles, A9 - in 10.2, A15 - in 7.63, +# Snapdragon S4 - in 9.33. +# +# Câmara, D.; Gouvêa, C. P. L.; López, J. & Dahab, R.: Fast Software +# Polynomial Multiplication on ARM Processors using the NEON Engine. +# +# http://conradoplg.cryptoland.net/files/2010/12/mocrysen13.pdf + +# ==================================================================== +# Note about "528B" variant. In ARM case it makes lesser sense to +# implement it for following reasons: +# +# - performance improvement won't be anywhere near 50%, because 128- +# bit shift operation is neatly fused with 128-bit xor here, and +# "538B" variant would eliminate only 4-5 instructions out of 32 +# in the inner loop (meaning that estimated improvement is ~15%); +# - ARM-based systems are often embedded ones and extra memory +# consumption might be unappreciated (for so little improvement); +# +# Byte order [in]dependence. ========================================= +# +# Caller is expected to maintain specific *dword* order in Htable, +# namely with *least* significant dword of 128-bit value at *lower* +# address. This differs completely from C code and has everything to +# do with ldm instruction and order in which dwords are "consumed" by +# algorithm. *Byte* order within these dwords in turn is whatever +# *native* byte order on current platform. See gcm128.c for working +# example... + +# This file was patched in BoringSSL to remove the variable-time 4-bit +# implementation. + +$flavour = shift; +if ($flavour=~/\w[\w\-]*\.\w+$/) { $output=$flavour; undef $flavour; } +else { while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {} } + +if ($flavour && $flavour ne "void") { + $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; + ( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or + ( $xlate="${dir}../../../perlasm/arm-xlate.pl" and -f $xlate) or + die "can't locate arm-xlate.pl"; + + open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""; + *STDOUT=*OUT; +} else { + open OUT,">$output"; + *STDOUT=*OUT; +} + +$Xi="r0"; # argument block +$Htbl="r1"; +$inp="r2"; +$len="r3"; + +$code=<<___; +@ Silence ARMv8 deprecated IT instruction warnings. This file is used by both +@ ARMv7 and ARMv8 processors and does not use ARMv8 instructions. (ARMv8 PMULL +@ instructions are in aesv8-armx.pl.) +.arch armv7-a + +.text +#if defined(__thumb2__) || defined(__clang__) +.syntax unified +#define ldrplb ldrbpl +#define ldrneb ldrbne +#endif +#if defined(__thumb2__) +.thumb +#else +.code 32 +#endif +___ +{ +my ($Xl,$Xm,$Xh,$IN)=map("q$_",(0..3)); +my ($t0,$t1,$t2,$t3)=map("q$_",(8..12)); +my ($Hlo,$Hhi,$Hhl,$k48,$k32,$k16)=map("d$_",(26..31)); + +sub clmul64x64 { +my ($r,$a,$b)=@_; +$code.=<<___; + vext.8 $t0#lo, $a, $a, #1 @ A1 + vmull.p8 $t0, $t0#lo, $b @ F = A1*B + vext.8 $r#lo, $b, $b, #1 @ B1 + vmull.p8 $r, $a, $r#lo @ E = A*B1 + vext.8 $t1#lo, $a, $a, #2 @ A2 + vmull.p8 $t1, $t1#lo, $b @ H = A2*B + vext.8 $t3#lo, $b, $b, #2 @ B2 + vmull.p8 $t3, $a, $t3#lo @ G = A*B2 + vext.8 $t2#lo, $a, $a, #3 @ A3 + veor $t0, $t0, $r @ L = E + F + vmull.p8 $t2, $t2#lo, $b @ J = A3*B + vext.8 $r#lo, $b, $b, #3 @ B3 + veor $t1, $t1, $t3 @ M = G + H + vmull.p8 $r, $a, $r#lo @ I = A*B3 + veor $t0#lo, $t0#lo, $t0#hi @ t0 = (L) (P0 + P1) << 8 + vand $t0#hi, $t0#hi, $k48 + vext.8 $t3#lo, $b, $b, #4 @ B4 + veor $t1#lo, $t1#lo, $t1#hi @ t1 = (M) (P2 + P3) << 16 + vand $t1#hi, $t1#hi, $k32 + vmull.p8 $t3, $a, $t3#lo @ K = A*B4 + veor $t2, $t2, $r @ N = I + J + veor $t0#lo, $t0#lo, $t0#hi + veor $t1#lo, $t1#lo, $t1#hi + veor $t2#lo, $t2#lo, $t2#hi @ t2 = (N) (P4 + P5) << 24 + vand $t2#hi, $t2#hi, $k16 + vext.8 $t0, $t0, $t0, #15 + veor $t3#lo, $t3#lo, $t3#hi @ t3 = (K) (P6 + P7) << 32 + vmov.i64 $t3#hi, #0 + vext.8 $t1, $t1, $t1, #14 + veor $t2#lo, $t2#lo, $t2#hi + vmull.p8 $r, $a, $b @ D = A*B + vext.8 $t3, $t3, $t3, #12 + vext.8 $t2, $t2, $t2, #13 + veor $t0, $t0, $t1 + veor $t2, $t2, $t3 + veor $r, $r, $t0 + veor $r, $r, $t2 +___ +} + +$code.=<<___; +#if __ARM_MAX_ARCH__>=7 +.arch armv7-a +.fpu neon + +.global gcm_init_neon +.type gcm_init_neon,%function +.align 4 +gcm_init_neon: + vld1.64 $IN#hi,[r1]! @ load H + vmov.i8 $t0,#0xe1 + vld1.64 $IN#lo,[r1] + vshl.i64 $t0#hi,#57 + vshr.u64 $t0#lo,#63 @ t0=0xc2....01 + vdup.8 $t1,$IN#hi[7] + vshr.u64 $Hlo,$IN#lo,#63 + vshr.s8 $t1,#7 @ broadcast carry bit + vshl.i64 $IN,$IN,#1 + vand $t0,$t0,$t1 + vorr $IN#hi,$Hlo @ H<<<=1 + veor $IN,$IN,$t0 @ twisted H + vstmia r0,{$IN} + + ret @ bx lr +.size gcm_init_neon,.-gcm_init_neon + +.global gcm_gmult_neon +.type gcm_gmult_neon,%function +.align 4 +gcm_gmult_neon: + vld1.64 $IN#hi,[$Xi]! @ load Xi + vld1.64 $IN#lo,[$Xi]! + vmov.i64 $k48,#0x0000ffffffffffff + vldmia $Htbl,{$Hlo-$Hhi} @ load twisted H + vmov.i64 $k32,#0x00000000ffffffff +#ifdef __ARMEL__ + vrev64.8 $IN,$IN +#endif + vmov.i64 $k16,#0x000000000000ffff + veor $Hhl,$Hlo,$Hhi @ Karatsuba pre-processing + mov $len,#16 + b .Lgmult_neon +.size gcm_gmult_neon,.-gcm_gmult_neon + +.global gcm_ghash_neon +.type gcm_ghash_neon,%function +.align 4 +gcm_ghash_neon: + vld1.64 $Xl#hi,[$Xi]! @ load Xi + vld1.64 $Xl#lo,[$Xi]! + vmov.i64 $k48,#0x0000ffffffffffff + vldmia $Htbl,{$Hlo-$Hhi} @ load twisted H + vmov.i64 $k32,#0x00000000ffffffff +#ifdef __ARMEL__ + vrev64.8 $Xl,$Xl +#endif + vmov.i64 $k16,#0x000000000000ffff + veor $Hhl,$Hlo,$Hhi @ Karatsuba pre-processing + +.Loop_neon: + vld1.64 $IN#hi,[$inp]! @ load inp + vld1.64 $IN#lo,[$inp]! +#ifdef __ARMEL__ + vrev64.8 $IN,$IN +#endif + veor $IN,$Xl @ inp^=Xi +.Lgmult_neon: +___ + &clmul64x64 ($Xl,$Hlo,"$IN#lo"); # H.lo·Xi.lo +$code.=<<___; + veor $IN#lo,$IN#lo,$IN#hi @ Karatsuba pre-processing +___ + &clmul64x64 ($Xm,$Hhl,"$IN#lo"); # (H.lo+H.hi)·(Xi.lo+Xi.hi) + &clmul64x64 ($Xh,$Hhi,"$IN#hi"); # H.hi·Xi.hi +$code.=<<___; + veor $Xm,$Xm,$Xl @ Karatsuba post-processing + veor $Xm,$Xm,$Xh + veor $Xl#hi,$Xl#hi,$Xm#lo + veor $Xh#lo,$Xh#lo,$Xm#hi @ Xh|Xl - 256-bit result + + @ equivalent of reduction_avx from ghash-x86_64.pl + vshl.i64 $t1,$Xl,#57 @ 1st phase + vshl.i64 $t2,$Xl,#62 + veor $t2,$t2,$t1 @ + vshl.i64 $t1,$Xl,#63 + veor $t2, $t2, $t1 @ + veor $Xl#hi,$Xl#hi,$t2#lo @ + veor $Xh#lo,$Xh#lo,$t2#hi + + vshr.u64 $t2,$Xl,#1 @ 2nd phase + veor $Xh,$Xh,$Xl + veor $Xl,$Xl,$t2 @ + vshr.u64 $t2,$t2,#6 + vshr.u64 $Xl,$Xl,#1 @ + veor $Xl,$Xl,$Xh @ + veor $Xl,$Xl,$t2 @ + + subs $len,#16 + bne .Loop_neon + +#ifdef __ARMEL__ + vrev64.8 $Xl,$Xl +#endif + sub $Xi,#16 + vst1.64 $Xl#hi,[$Xi]! @ write out Xi + vst1.64 $Xl#lo,[$Xi] + + ret @ bx lr +.size gcm_ghash_neon,.-gcm_ghash_neon +#endif +___ +} +$code.=<<___; +.asciz "GHASH for ARMv4/NEON, CRYPTOGAMS by " +.align 2 +___ + +foreach (split("\n",$code)) { + s/\`([^\`]*)\`/eval $1/geo; + + s/\bq([0-9]+)#(lo|hi)/sprintf "d%d",2*$1+($2 eq "hi")/geo or + s/\bret\b/bx lr/go or + s/\bbx\s+lr\b/.word\t0xe12fff1e/go; # make it possible to compile with -march=armv4 + + print $_,"\n"; +} +close STDOUT or die "error closing STDOUT: $!"; # enforce flush diff --git a/http/vendor/ring/crypto/fipsmodule/aes/asm/ghash-neon-armv8.pl b/http/vendor/ring/crypto/fipsmodule/aes/asm/ghash-neon-armv8.pl new file mode 100644 index 0000000..b4ae1db --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/aes/asm/ghash-neon-armv8.pl @@ -0,0 +1,297 @@ +#! /usr/bin/env perl +# Copyright 2010-2016 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# ==================================================================== +# Written by Andy Polyakov for the OpenSSL +# project. +# ==================================================================== + +# This file was adapted to AArch64 from the 32-bit version in ghash-armv4.pl. It +# implements the multiplication algorithm described in: +# +# Câmara, D.; Gouvêa, C. P. L.; López, J. & Dahab, R.: Fast Software +# Polynomial Multiplication on ARM Processors using the NEON Engine. +# +# http://conradoplg.cryptoland.net/files/2010/12/mocrysen13.pdf +# +# The main distinction to keep in mind between 32-bit NEON and AArch64 SIMD is +# AArch64 cannot compute over the upper halves of SIMD registers. In 32-bit +# NEON, the low and high halves of the 128-bit register q0 are accessible as +# 64-bit registers d0 and d1, respectively. In AArch64, dN is the lower half of +# vN. Where the 32-bit version would use the upper half, this file must keep +# halves in separate registers. +# +# The other distinction is in syntax. 32-bit NEON embeds lane information in the +# instruction name, while AArch64 uses suffixes on the registers. For instance, +# left-shifting 64-bit lanes of a SIMD register in 32-bit would be written: +# +# vshl.i64 q0, q0, #1 +# +# in 64-bit, it would be written: +# +# shl v0.2d, v0.2d, #1 +# +# See Programmer's Guide for ARMv8-A, section 7 for details. +# http://infocenter.arm.com/help/topic/com.arm.doc.den0024a/DEN0024A_v8_architecture_PG.pdf +# +# Finally, note the 8-bit and 64-bit polynomial multipliers in AArch64 differ +# only by suffix. pmull vR.8h, vA.8b, vB.8b multiplies eight 8-bit polynomials +# and is always available. pmull vR.1q, vA.1d, vB.1d multiplies a 64-bit +# polynomial and is conditioned on the PMULL extension. This file emulates the +# latter with the former. + +use strict; + +my $flavour = shift; +my $output; +if ($flavour=~/\w[\w\-]*\.\w+$/) { $output=$flavour; undef $flavour; } +else { while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {} } + +if ($flavour && $flavour ne "void") { + $0 =~ m/(.*[\/\\])[^\/\\]+$/; + my $dir = $1; + my $xlate; + ( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or + ( $xlate="${dir}../../../perlasm/arm-xlate.pl" and -f $xlate) or + die "can't locate arm-xlate.pl"; + + open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""; + *STDOUT=*OUT; +} else { + open OUT,">$output"; + *STDOUT=*OUT; +} + +my ($Xi, $Htbl, $inp, $len) = map("x$_", (0..3)); # argument block +my ($Xl, $Xm, $Xh, $INlo, $INhi) = map("v$_", (0..4)); +my ($Hlo, $Hhi, $Hhl) = map("v$_", (5..7)); +# d8-d15 are callee-saved, so avoid v8-v15. AArch64 SIMD has plenty of registers +# to spare. +my ($t0, $t1, $t2, $t3) = map("v$_", (16..19)); +my ($t0l_t1l, $t0h_t1h, $t2l_t3l, $t2h_t3h) = map("v$_", (20..23)); +my ($k48_k32, $k16_k0) = map("v$_", (24..25)); + +my $code = ""; + +# clmul64x64 emits code which emulates pmull $r.1q, $a.1d, $b.1d. $r, $a, and $b +# must be distinct from $t* and $k*. $t* are clobbered by the emitted code. +sub clmul64x64 { +my ($r, $a, $b) = @_; +$code .= <<___; + ext $t0.8b, $a.8b, $a.8b, #1 // A1 + pmull $t0.8h, $t0.8b, $b.8b // F = A1*B + ext $r.8b, $b.8b, $b.8b, #1 // B1 + pmull $r.8h, $a.8b, $r.8b // E = A*B1 + ext $t1.8b, $a.8b, $a.8b, #2 // A2 + pmull $t1.8h, $t1.8b, $b.8b // H = A2*B + ext $t3.8b, $b.8b, $b.8b, #2 // B2 + pmull $t3.8h, $a.8b, $t3.8b // G = A*B2 + ext $t2.8b, $a.8b, $a.8b, #3 // A3 + eor $t0.16b, $t0.16b, $r.16b // L = E + F + pmull $t2.8h, $t2.8b, $b.8b // J = A3*B + ext $r.8b, $b.8b, $b.8b, #3 // B3 + eor $t1.16b, $t1.16b, $t3.16b // M = G + H + pmull $r.8h, $a.8b, $r.8b // I = A*B3 + + // Here we diverge from the 32-bit version. It computes the following + // (instructions reordered for clarity): + // + // veor \$t0#lo, \$t0#lo, \$t0#hi @ t0 = P0 + P1 (L) + // vand \$t0#hi, \$t0#hi, \$k48 + // veor \$t0#lo, \$t0#lo, \$t0#hi + // + // veor \$t1#lo, \$t1#lo, \$t1#hi @ t1 = P2 + P3 (M) + // vand \$t1#hi, \$t1#hi, \$k32 + // veor \$t1#lo, \$t1#lo, \$t1#hi + // + // veor \$t2#lo, \$t2#lo, \$t2#hi @ t2 = P4 + P5 (N) + // vand \$t2#hi, \$t2#hi, \$k16 + // veor \$t2#lo, \$t2#lo, \$t2#hi + // + // veor \$t3#lo, \$t3#lo, \$t3#hi @ t3 = P6 + P7 (K) + // vmov.i64 \$t3#hi, #0 + // + // \$kN is a mask with the bottom N bits set. AArch64 cannot compute on + // upper halves of SIMD registers, so we must split each half into + // separate registers. To compensate, we pair computations up and + // parallelize. + + ext $t3.8b, $b.8b, $b.8b, #4 // B4 + eor $t2.16b, $t2.16b, $r.16b // N = I + J + pmull $t3.8h, $a.8b, $t3.8b // K = A*B4 + + // This can probably be scheduled more efficiently. For now, we just + // pair up independent instructions. + zip1 $t0l_t1l.2d, $t0.2d, $t1.2d + zip1 $t2l_t3l.2d, $t2.2d, $t3.2d + zip2 $t0h_t1h.2d, $t0.2d, $t1.2d + zip2 $t2h_t3h.2d, $t2.2d, $t3.2d + eor $t0l_t1l.16b, $t0l_t1l.16b, $t0h_t1h.16b + eor $t2l_t3l.16b, $t2l_t3l.16b, $t2h_t3h.16b + and $t0h_t1h.16b, $t0h_t1h.16b, $k48_k32.16b + and $t2h_t3h.16b, $t2h_t3h.16b, $k16_k0.16b + eor $t0l_t1l.16b, $t0l_t1l.16b, $t0h_t1h.16b + eor $t2l_t3l.16b, $t2l_t3l.16b, $t2h_t3h.16b + zip1 $t0.2d, $t0l_t1l.2d, $t0h_t1h.2d + zip1 $t2.2d, $t2l_t3l.2d, $t2h_t3h.2d + zip2 $t1.2d, $t0l_t1l.2d, $t0h_t1h.2d + zip2 $t3.2d, $t2l_t3l.2d, $t2h_t3h.2d + + ext $t0.16b, $t0.16b, $t0.16b, #15 // t0 = t0 << 8 + ext $t1.16b, $t1.16b, $t1.16b, #14 // t1 = t1 << 16 + pmull $r.8h, $a.8b, $b.8b // D = A*B + ext $t3.16b, $t3.16b, $t3.16b, #12 // t3 = t3 << 32 + ext $t2.16b, $t2.16b, $t2.16b, #13 // t2 = t2 << 24 + eor $t0.16b, $t0.16b, $t1.16b + eor $t2.16b, $t2.16b, $t3.16b + eor $r.16b, $r.16b, $t0.16b + eor $r.16b, $r.16b, $t2.16b +___ +} + +$code .= <<___; +.text + +.global gcm_init_neon +.type gcm_init_neon,%function +.align 4 +gcm_init_neon: + AARCH64_VALID_CALL_TARGET + // This function is adapted from gcm_init_v8. xC2 is t3. + ld1 {$t1.2d}, [x1] // load H + movi $t3.16b, #0xe1 + shl $t3.2d, $t3.2d, #57 // 0xc2.0 + ext $INlo.16b, $t1.16b, $t1.16b, #8 + ushr $t2.2d, $t3.2d, #63 + dup $t1.4s, $t1.s[1] + ext $t0.16b, $t2.16b, $t3.16b, #8 // t0=0xc2....01 + ushr $t2.2d, $INlo.2d, #63 + sshr $t1.4s, $t1.4s, #31 // broadcast carry bit + and $t2.16b, $t2.16b, $t0.16b + shl $INlo.2d, $INlo.2d, #1 + ext $t2.16b, $t2.16b, $t2.16b, #8 + and $t0.16b, $t0.16b, $t1.16b + orr $INlo.16b, $INlo.16b, $t2.16b // H<<<=1 + eor $Hlo.16b, $INlo.16b, $t0.16b // twisted H + st1 {$Hlo.2d}, [x0] // store Htable[0] + ret +.size gcm_init_neon,.-gcm_init_neon + +.global gcm_gmult_neon +.type gcm_gmult_neon,%function +.align 4 +gcm_gmult_neon: + AARCH64_VALID_CALL_TARGET + ld1 {$INlo.16b}, [$Xi] // load Xi + ld1 {$Hlo.1d}, [$Htbl], #8 // load twisted H + ld1 {$Hhi.1d}, [$Htbl] + adrp x9, :pg_hi21:.Lmasks // load constants + add x9, x9, :lo12:.Lmasks + ld1 {$k48_k32.2d, $k16_k0.2d}, [x9] + rev64 $INlo.16b, $INlo.16b // byteswap Xi + ext $INlo.16b, $INlo.16b, $INlo.16b, #8 + eor $Hhl.8b, $Hlo.8b, $Hhi.8b // Karatsuba pre-processing + + mov $len, #16 + b .Lgmult_neon +.size gcm_gmult_neon,.-gcm_gmult_neon + +.global gcm_ghash_neon +.type gcm_ghash_neon,%function +.align 4 +gcm_ghash_neon: + AARCH64_VALID_CALL_TARGET + ld1 {$Xl.16b}, [$Xi] // load Xi + ld1 {$Hlo.1d}, [$Htbl], #8 // load twisted H + ld1 {$Hhi.1d}, [$Htbl] + adrp x9, :pg_hi21:.Lmasks // load constants + add x9, x9, :lo12:.Lmasks + ld1 {$k48_k32.2d, $k16_k0.2d}, [x9] + rev64 $Xl.16b, $Xl.16b // byteswap Xi + ext $Xl.16b, $Xl.16b, $Xl.16b, #8 + eor $Hhl.8b, $Hlo.8b, $Hhi.8b // Karatsuba pre-processing + +.Loop_neon: + ld1 {$INlo.16b}, [$inp], #16 // load inp + rev64 $INlo.16b, $INlo.16b // byteswap inp + ext $INlo.16b, $INlo.16b, $INlo.16b, #8 + eor $INlo.16b, $INlo.16b, $Xl.16b // inp ^= Xi + +.Lgmult_neon: + // Split the input into $INlo and $INhi. (The upper halves are unused, + // so it is okay to leave them alone.) + ins $INhi.d[0], $INlo.d[1] +___ +&clmul64x64 ($Xl, $Hlo, $INlo); # H.lo·Xi.lo +$code .= <<___; + eor $INlo.8b, $INlo.8b, $INhi.8b // Karatsuba pre-processing +___ +&clmul64x64 ($Xm, $Hhl, $INlo); # (H.lo+H.hi)·(Xi.lo+Xi.hi) +&clmul64x64 ($Xh, $Hhi, $INhi); # H.hi·Xi.hi +$code .= <<___; + ext $t0.16b, $Xl.16b, $Xh.16b, #8 + eor $Xm.16b, $Xm.16b, $Xl.16b // Karatsuba post-processing + eor $Xm.16b, $Xm.16b, $Xh.16b + eor $Xm.16b, $Xm.16b, $t0.16b // Xm overlaps Xh.lo and Xl.hi + ins $Xl.d[1], $Xm.d[0] // Xh|Xl - 256-bit result + // This is a no-op due to the ins instruction below. + // ins $Xh.d[0], $Xm.d[1] + + // equivalent of reduction_avx from ghash-x86_64.pl + shl $t1.2d, $Xl.2d, #57 // 1st phase + shl $t2.2d, $Xl.2d, #62 + eor $t2.16b, $t2.16b, $t1.16b // + shl $t1.2d, $Xl.2d, #63 + eor $t2.16b, $t2.16b, $t1.16b // + // Note Xm contains {Xl.d[1], Xh.d[0]}. + eor $t2.16b, $t2.16b, $Xm.16b + ins $Xl.d[1], $t2.d[0] // Xl.d[1] ^= t2.d[0] + ins $Xh.d[0], $t2.d[1] // Xh.d[0] ^= t2.d[1] + + ushr $t2.2d, $Xl.2d, #1 // 2nd phase + eor $Xh.16b, $Xh.16b,$Xl.16b + eor $Xl.16b, $Xl.16b,$t2.16b // + ushr $t2.2d, $t2.2d, #6 + ushr $Xl.2d, $Xl.2d, #1 // + eor $Xl.16b, $Xl.16b, $Xh.16b // + eor $Xl.16b, $Xl.16b, $t2.16b // + + subs $len, $len, #16 + bne .Loop_neon + + rev64 $Xl.16b, $Xl.16b // byteswap Xi and write + ext $Xl.16b, $Xl.16b, $Xl.16b, #8 + st1 {$Xl.16b}, [$Xi] + + ret +.size gcm_ghash_neon,.-gcm_ghash_neon + +.section .rodata +.align 4 +.Lmasks: +.quad 0x0000ffffffffffff // k48 +.quad 0x00000000ffffffff // k32 +.quad 0x000000000000ffff // k16 +.quad 0x0000000000000000 // k0 +.asciz "GHASH for ARMv8, derived from ARMv4 version by " +.align 2 +___ + +foreach (split("\n",$code)) { + s/\`([^\`]*)\`/eval $1/geo; + + print $_,"\n"; +} +close STDOUT or die "error closing STDOUT: $!"; # enforce flush diff --git a/http/vendor/ring/crypto/fipsmodule/aes/asm/ghash-x86.pl b/http/vendor/ring/crypto/fipsmodule/aes/asm/ghash-x86.pl new file mode 100644 index 0000000..1cebb4b --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/aes/asm/ghash-x86.pl @@ -0,0 +1,460 @@ +#! /usr/bin/env perl +# Copyright 2010-2016 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# ==================================================================== +# Written by Andy Polyakov for the OpenSSL +# project. +# ==================================================================== +# +# March, May, June 2010 +# +# The module implements "4-bit" GCM GHASH function and underlying +# single multiplication operation in GF(2^128). "4-bit" means that it +# uses 256 bytes per-key table [+64/128 bytes fixed table]. It has two +# code paths: vanilla x86 and vanilla SSE. Former will be executed on +# 486 and Pentium, latter on all others. SSE GHASH features so called +# "528B" variant of "4-bit" method utilizing additional 256+16 bytes +# of per-key storage [+512 bytes shared table]. Performance results +# are for streamed GHASH subroutine and are expressed in cycles per +# processed byte, less is better: +# +# gcc 2.95.3(*) SSE assembler x86 assembler +# +# Pentium 105/111(**) - 50 +# PIII 68 /75 12.2 24 +# P4 125/125 17.8 84(***) +# Opteron 66 /70 10.1 30 +# Core2 54 /67 8.4 18 +# Atom 105/105 16.8 53 +# VIA Nano 69 /71 13.0 27 +# +# (*) gcc 3.4.x was observed to generate few percent slower code, +# which is one of reasons why 2.95.3 results were chosen, +# another reason is lack of 3.4.x results for older CPUs; +# comparison with SSE results is not completely fair, because C +# results are for vanilla "256B" implementation, while +# assembler results are for "528B";-) +# (**) second number is result for code compiled with -fPIC flag, +# which is actually more relevant, because assembler code is +# position-independent; +# (***) see comment in non-MMX routine for further details; +# +# To summarize, it's >2-5 times faster than gcc-generated code. To +# anchor it to something else SHA1 assembler processes one byte in +# ~7 cycles on contemporary x86 cores. As for choice of MMX/SSE +# in particular, see comment at the end of the file... + +# May 2010 +# +# Add PCLMULQDQ version performing at 2.10 cycles per processed byte. +# The question is how close is it to theoretical limit? The pclmulqdq +# instruction latency appears to be 14 cycles and there can't be more +# than 2 of them executing at any given time. This means that single +# Karatsuba multiplication would take 28 cycles *plus* few cycles for +# pre- and post-processing. Then multiplication has to be followed by +# modulo-reduction. Given that aggregated reduction method [see +# "Carry-less Multiplication and Its Usage for Computing the GCM Mode" +# white paper by Intel] allows you to perform reduction only once in +# a while we can assume that asymptotic performance can be estimated +# as (28+Tmod/Naggr)/16, where Tmod is time to perform reduction +# and Naggr is the aggregation factor. +# +# Before we proceed to this implementation let's have closer look at +# the best-performing code suggested by Intel in their white paper. +# By tracing inter-register dependencies Tmod is estimated as ~19 +# cycles and Naggr chosen by Intel is 4, resulting in 2.05 cycles per +# processed byte. As implied, this is quite optimistic estimate, +# because it does not account for Karatsuba pre- and post-processing, +# which for a single multiplication is ~5 cycles. Unfortunately Intel +# does not provide performance data for GHASH alone. But benchmarking +# AES_GCM_encrypt ripped out of Fig. 15 of the white paper with aadt +# alone resulted in 2.46 cycles per byte of out 16KB buffer. Note that +# the result accounts even for pre-computing of degrees of the hash +# key H, but its portion is negligible at 16KB buffer size. +# +# Moving on to the implementation in question. Tmod is estimated as +# ~13 cycles and Naggr is 2, giving asymptotic performance of ... +# 2.16. How is it possible that measured performance is better than +# optimistic theoretical estimate? There is one thing Intel failed +# to recognize. By serializing GHASH with CTR in same subroutine +# former's performance is really limited to above (Tmul + Tmod/Naggr) +# equation. But if GHASH procedure is detached, the modulo-reduction +# can be interleaved with Naggr-1 multiplications at instruction level +# and under ideal conditions even disappear from the equation. So that +# optimistic theoretical estimate for this implementation is ... +# 28/16=1.75, and not 2.16. Well, it's probably way too optimistic, +# at least for such small Naggr. I'd argue that (28+Tproc/Naggr), +# where Tproc is time required for Karatsuba pre- and post-processing, +# is more realistic estimate. In this case it gives ... 1.91 cycles. +# Or in other words, depending on how well we can interleave reduction +# and one of the two multiplications the performance should be between +# 1.91 and 2.16. As already mentioned, this implementation processes +# one byte out of 8KB buffer in 2.10 cycles, while x86_64 counterpart +# - in 2.02. x86_64 performance is better, because larger register +# bank allows to interleave reduction and multiplication better. +# +# Does it make sense to increase Naggr? To start with it's virtually +# impossible in 32-bit mode, because of limited register bank +# capacity. Otherwise improvement has to be weighed against slower +# setup, as well as code size and complexity increase. As even +# optimistic estimate doesn't promise 30% performance improvement, +# there are currently no plans to increase Naggr. +# +# Special thanks to David Woodhouse for providing access to a +# Westmere-based system on behalf of Intel Open Source Technology Centre. + +# January 2010 +# +# Tweaked to optimize transitions between integer and FP operations +# on same XMM register, PCLMULQDQ subroutine was measured to process +# one byte in 2.07 cycles on Sandy Bridge, and in 2.12 - on Westmere. +# The minor regression on Westmere is outweighed by ~15% improvement +# on Sandy Bridge. Strangely enough attempt to modify 64-bit code in +# similar manner resulted in almost 20% degradation on Sandy Bridge, +# where original 64-bit code processes one byte in 1.95 cycles. + +##################################################################### +# For reference, AMD Bulldozer processes one byte in 1.98 cycles in +# 32-bit mode and 1.89 in 64-bit. + +# February 2013 +# +# Overhaul: aggregate Karatsuba post-processing, improve ILP in +# reduction_alg9. Resulting performance is 1.96 cycles per byte on +# Westmere, 1.95 - on Sandy/Ivy Bridge, 1.76 - on Bulldozer. + +# This file was patched in BoringSSL to remove the variable-time 4-bit +# implementation. + +$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; +push(@INC,"${dir}","${dir}../../../perlasm"); +require "x86asm.pl"; + +$output=pop; +open STDOUT,">$output"; + +&asm_init($ARGV[0]); + +$x86only=0; +$sse2=1; + +if (!$x86only) {{{ +if ($sse2) {{ +###################################################################### +# PCLMULQDQ version. + +$Xip="eax"; +$Htbl="edx"; +$const="ecx"; +$inp="esi"; +$len="ebx"; + +($Xi,$Xhi)=("xmm0","xmm1"); $Hkey="xmm2"; +($T1,$T2,$T3)=("xmm3","xmm4","xmm5"); +($Xn,$Xhn)=("xmm6","xmm7"); + +&static_label("bswap"); + +sub clmul64x64_T2 { # minimal "register" pressure +my ($Xhi,$Xi,$Hkey,$HK)=@_; + + &movdqa ($Xhi,$Xi); # + &pshufd ($T1,$Xi,0b01001110); + &pshufd ($T2,$Hkey,0b01001110) if (!defined($HK)); + &pxor ($T1,$Xi); # + &pxor ($T2,$Hkey) if (!defined($HK)); + $HK=$T2 if (!defined($HK)); + + &pclmulqdq ($Xi,$Hkey,0x00); ####### + &pclmulqdq ($Xhi,$Hkey,0x11); ####### + &pclmulqdq ($T1,$HK,0x00); ####### + &xorps ($T1,$Xi); # + &xorps ($T1,$Xhi); # + + &movdqa ($T2,$T1); # + &psrldq ($T1,8); + &pslldq ($T2,8); # + &pxor ($Xhi,$T1); + &pxor ($Xi,$T2); # +} + + +if (1) { # Algorithm 9 with <<1 twist. + # Reduction is shorter and uses only two + # temporary registers, which makes it better + # candidate for interleaving with 64x64 + # multiplication. Pre-modulo-scheduled loop + # was found to be ~20% faster than Algorithm 5 + # below. Algorithm 9 was therefore chosen for + # further optimization... + +sub reduction_alg9 { # 17/11 times faster than Intel version +my ($Xhi,$Xi) = @_; + + # 1st phase + &movdqa ($T2,$Xi); # + &movdqa ($T1,$Xi); + &psllq ($Xi,5); + &pxor ($T1,$Xi); # + &psllq ($Xi,1); + &pxor ($Xi,$T1); # + &psllq ($Xi,57); # + &movdqa ($T1,$Xi); # + &pslldq ($Xi,8); + &psrldq ($T1,8); # + &pxor ($Xi,$T2); + &pxor ($Xhi,$T1); # + + # 2nd phase + &movdqa ($T2,$Xi); + &psrlq ($Xi,1); + &pxor ($Xhi,$T2); # + &pxor ($T2,$Xi); + &psrlq ($Xi,5); + &pxor ($Xi,$T2); # + &psrlq ($Xi,1); # + &pxor ($Xi,$Xhi) # +} + +&function_begin_B("gcm_init_clmul"); + &mov ($Htbl,&wparam(0)); + &mov ($Xip,&wparam(1)); + + &call (&label("pic")); +&set_label("pic"); + &blindpop ($const); + &lea ($const,&DWP(&label("bswap")."-".&label("pic"),$const)); + + &movdqu ($Hkey,&QWP(0,$Xip)); + &pshufd ($Hkey,$Hkey,0b01001110);# dword swap + + # <<1 twist + &pshufd ($T2,$Hkey,0b11111111); # broadcast uppermost dword + &movdqa ($T1,$Hkey); + &psllq ($Hkey,1); + &pxor ($T3,$T3); # + &psrlq ($T1,63); + &pcmpgtd ($T3,$T2); # broadcast carry bit + &pslldq ($T1,8); + &por ($Hkey,$T1); # H<<=1 + + # magic reduction + &pand ($T3,&QWP(16,$const)); # 0x1c2_polynomial + &pxor ($Hkey,$T3); # if(carry) H^=0x1c2_polynomial + + # calculate H^2 + &movdqa ($Xi,$Hkey); + &clmul64x64_T2 ($Xhi,$Xi,$Hkey); + &reduction_alg9 ($Xhi,$Xi); + + &pshufd ($T1,$Hkey,0b01001110); + &pshufd ($T2,$Xi,0b01001110); + &pxor ($T1,$Hkey); # Karatsuba pre-processing + &movdqu (&QWP(0,$Htbl),$Hkey); # save H + &pxor ($T2,$Xi); # Karatsuba pre-processing + &movdqu (&QWP(16,$Htbl),$Xi); # save H^2 + &palignr ($T2,$T1,8); # low part is H.lo^H.hi + &movdqu (&QWP(32,$Htbl),$T2); # save Karatsuba "salt" + + &ret (); +&function_end_B("gcm_init_clmul"); + +&function_begin("gcm_ghash_clmul"); + &mov ($Xip,&wparam(0)); + &mov ($Htbl,&wparam(1)); + &mov ($inp,&wparam(2)); + &mov ($len,&wparam(3)); + + &call (&label("pic")); +&set_label("pic"); + &blindpop ($const); + &lea ($const,&DWP(&label("bswap")."-".&label("pic"),$const)); + + &movdqu ($Xi,&QWP(0,$Xip)); + &movdqa ($T3,&QWP(0,$const)); + &movdqu ($Hkey,&QWP(0,$Htbl)); + &pshufb ($Xi,$T3); + + &sub ($len,0x10); + &jz (&label("odd_tail")); + + ####### + # Xi+2 =[H*(Ii+1 + Xi+1)] mod P = + # [(H*Ii+1) + (H*Xi+1)] mod P = + # [(H*Ii+1) + H^2*(Ii+Xi)] mod P + # + &movdqu ($T1,&QWP(0,$inp)); # Ii + &movdqu ($Xn,&QWP(16,$inp)); # Ii+1 + &pshufb ($T1,$T3); + &pshufb ($Xn,$T3); + &movdqu ($T3,&QWP(32,$Htbl)); + &pxor ($Xi,$T1); # Ii+Xi + + &pshufd ($T1,$Xn,0b01001110); # H*Ii+1 + &movdqa ($Xhn,$Xn); + &pxor ($T1,$Xn); # + &lea ($inp,&DWP(32,$inp)); # i+=2 + + &pclmulqdq ($Xn,$Hkey,0x00); ####### + &pclmulqdq ($Xhn,$Hkey,0x11); ####### + &pclmulqdq ($T1,$T3,0x00); ####### + &movups ($Hkey,&QWP(16,$Htbl)); # load H^2 + &nop (); + + &sub ($len,0x20); + &jbe (&label("even_tail")); + &jmp (&label("mod_loop")); + +&set_label("mod_loop",32); + &pshufd ($T2,$Xi,0b01001110); # H^2*(Ii+Xi) + &movdqa ($Xhi,$Xi); + &pxor ($T2,$Xi); # + &nop (); + + &pclmulqdq ($Xi,$Hkey,0x00); ####### + &pclmulqdq ($Xhi,$Hkey,0x11); ####### + &pclmulqdq ($T2,$T3,0x10); ####### + &movups ($Hkey,&QWP(0,$Htbl)); # load H + + &xorps ($Xi,$Xn); # (H*Ii+1) + H^2*(Ii+Xi) + &movdqa ($T3,&QWP(0,$const)); + &xorps ($Xhi,$Xhn); + &movdqu ($Xhn,&QWP(0,$inp)); # Ii + &pxor ($T1,$Xi); # aggregated Karatsuba post-processing + &movdqu ($Xn,&QWP(16,$inp)); # Ii+1 + &pxor ($T1,$Xhi); # + + &pshufb ($Xhn,$T3); + &pxor ($T2,$T1); # + + &movdqa ($T1,$T2); # + &psrldq ($T2,8); + &pslldq ($T1,8); # + &pxor ($Xhi,$T2); + &pxor ($Xi,$T1); # + &pshufb ($Xn,$T3); + &pxor ($Xhi,$Xhn); # "Ii+Xi", consume early + + &movdqa ($Xhn,$Xn); #&clmul64x64_TX ($Xhn,$Xn,$Hkey); H*Ii+1 + &movdqa ($T2,$Xi); #&reduction_alg9($Xhi,$Xi); 1st phase + &movdqa ($T1,$Xi); + &psllq ($Xi,5); + &pxor ($T1,$Xi); # + &psllq ($Xi,1); + &pxor ($Xi,$T1); # + &pclmulqdq ($Xn,$Hkey,0x00); ####### + &movups ($T3,&QWP(32,$Htbl)); + &psllq ($Xi,57); # + &movdqa ($T1,$Xi); # + &pslldq ($Xi,8); + &psrldq ($T1,8); # + &pxor ($Xi,$T2); + &pxor ($Xhi,$T1); # + &pshufd ($T1,$Xhn,0b01001110); + &movdqa ($T2,$Xi); # 2nd phase + &psrlq ($Xi,1); + &pxor ($T1,$Xhn); + &pxor ($Xhi,$T2); # + &pclmulqdq ($Xhn,$Hkey,0x11); ####### + &movups ($Hkey,&QWP(16,$Htbl)); # load H^2 + &pxor ($T2,$Xi); + &psrlq ($Xi,5); + &pxor ($Xi,$T2); # + &psrlq ($Xi,1); # + &pxor ($Xi,$Xhi) # + &pclmulqdq ($T1,$T3,0x00); ####### + + &lea ($inp,&DWP(32,$inp)); + &sub ($len,0x20); + &ja (&label("mod_loop")); + +&set_label("even_tail"); + &pshufd ($T2,$Xi,0b01001110); # H^2*(Ii+Xi) + &movdqa ($Xhi,$Xi); + &pxor ($T2,$Xi); # + + &pclmulqdq ($Xi,$Hkey,0x00); ####### + &pclmulqdq ($Xhi,$Hkey,0x11); ####### + &pclmulqdq ($T2,$T3,0x10); ####### + &movdqa ($T3,&QWP(0,$const)); + + &xorps ($Xi,$Xn); # (H*Ii+1) + H^2*(Ii+Xi) + &xorps ($Xhi,$Xhn); + &pxor ($T1,$Xi); # aggregated Karatsuba post-processing + &pxor ($T1,$Xhi); # + + &pxor ($T2,$T1); # + + &movdqa ($T1,$T2); # + &psrldq ($T2,8); + &pslldq ($T1,8); # + &pxor ($Xhi,$T2); + &pxor ($Xi,$T1); # + + &reduction_alg9 ($Xhi,$Xi); + + &test ($len,$len); + &jnz (&label("done")); + + &movups ($Hkey,&QWP(0,$Htbl)); # load H +&set_label("odd_tail"); + &movdqu ($T1,&QWP(0,$inp)); # Ii + &pshufb ($T1,$T3); + &pxor ($Xi,$T1); # Ii+Xi + + &clmul64x64_T2 ($Xhi,$Xi,$Hkey); # H*(Ii+Xi) + &reduction_alg9 ($Xhi,$Xi); + +&set_label("done"); + &pshufb ($Xi,$T3); + &movdqu (&QWP(0,$Xip),$Xi); +&function_end("gcm_ghash_clmul"); + +} + +&set_label("bswap",64); + &data_byte(15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0); + &data_byte(1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0xc2); # 0x1c2_polynomial +}} # $sse2 +}}} # !$x86only + +&asciz("GHASH for x86, CRYPTOGAMS by "); +&asm_finish(); + +close STDOUT or die "error closing STDOUT: $!"; + +# A question was risen about choice of vanilla MMX. Or rather why wasn't +# SSE2 chosen instead? In addition to the fact that MMX runs on legacy +# CPUs such as PIII, "4-bit" MMX version was observed to provide better +# performance than *corresponding* SSE2 one even on contemporary CPUs. +# SSE2 results were provided by Peter-Michael Hager. He maintains SSE2 +# implementation featuring full range of lookup-table sizes, but with +# per-invocation lookup table setup. Latter means that table size is +# chosen depending on how much data is to be hashed in every given call, +# more data - larger table. Best reported result for Core2 is ~4 cycles +# per processed byte out of 64KB block. This number accounts even for +# 64KB table setup overhead. As discussed in gcm128.c we choose to be +# more conservative in respect to lookup table sizes, but how do the +# results compare? Minimalistic "256B" MMX version delivers ~11 cycles +# on same platform. As also discussed in gcm128.c, next in line "8-bit +# Shoup's" or "4KB" method should deliver twice the performance of +# "256B" one, in other words not worse than ~6 cycles per byte. It +# should be also be noted that in SSE2 case improvement can be "super- +# linear," i.e. more than twice, mostly because >>8 maps to single +# instruction on SSE2 register. This is unlike "4-bit" case when >>4 +# maps to same amount of instructions in both MMX and SSE2 cases. +# Bottom line is that switch to SSE2 is considered to be justifiable +# only in case we choose to implement "8-bit" method... diff --git a/http/vendor/ring/crypto/fipsmodule/aes/asm/ghash-x86_64.pl b/http/vendor/ring/crypto/fipsmodule/aes/asm/ghash-x86_64.pl new file mode 100644 index 0000000..1a228d7 --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/aes/asm/ghash-x86_64.pl @@ -0,0 +1,1266 @@ +#! /usr/bin/env perl +# Copyright 2010-2016 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# ==================================================================== +# Written by Andy Polyakov for the OpenSSL +# project. +# ==================================================================== +# +# March, June 2010 +# +# The module implements "4-bit" GCM GHASH function and underlying +# single multiplication operation in GF(2^128). "4-bit" means that +# it uses 256 bytes per-key table [+128 bytes shared table]. GHASH +# function features so called "528B" variant utilizing additional +# 256+16 bytes of per-key storage [+512 bytes shared table]. +# Performance results are for this streamed GHASH subroutine and are +# expressed in cycles per processed byte, less is better: +# +# gcc 3.4.x(*) assembler +# +# P4 28.6 14.0 +100% +# Opteron 19.3 7.7 +150% +# Core2 17.8 8.1(**) +120% +# Atom 31.6 16.8 +88% +# VIA Nano 21.8 10.1 +115% +# +# (*) comparison is not completely fair, because C results are +# for vanilla "256B" implementation, while assembler results +# are for "528B";-) +# (**) it's mystery [to me] why Core2 result is not same as for +# Opteron; + +# May 2010 +# +# Add PCLMULQDQ version performing at 2.02 cycles per processed byte. +# See ghash-x86.pl for background information and details about coding +# techniques. +# +# Special thanks to David Woodhouse for providing access to a +# Westmere-based system on behalf of Intel Open Source Technology Centre. + +# December 2012 +# +# Overhaul: aggregate Karatsuba post-processing, improve ILP in +# reduction_alg9, increase reduction aggregate factor to 4x. As for +# the latter. ghash-x86.pl discusses that it makes lesser sense to +# increase aggregate factor. Then why increase here? Critical path +# consists of 3 independent pclmulqdq instructions, Karatsuba post- +# processing and reduction. "On top" of this we lay down aggregated +# multiplication operations, triplets of independent pclmulqdq's. As +# issue rate for pclmulqdq is limited, it makes lesser sense to +# aggregate more multiplications than it takes to perform remaining +# non-multiplication operations. 2x is near-optimal coefficient for +# contemporary Intel CPUs (therefore modest improvement coefficient), +# but not for Bulldozer. Latter is because logical SIMD operations +# are twice as slow in comparison to Intel, so that critical path is +# longer. A CPU with higher pclmulqdq issue rate would also benefit +# from higher aggregate factor... +# +# Westmere 1.78(+13%) +# Sandy Bridge 1.80(+8%) +# Ivy Bridge 1.80(+7%) +# Haswell 0.55(+93%) (if system doesn't support AVX) +# Broadwell 0.45(+110%)(if system doesn't support AVX) +# Skylake 0.44(+110%)(if system doesn't support AVX) +# Bulldozer 1.49(+27%) +# Silvermont 2.88(+13%) +# Knights L 2.12(-) (if system doesn't support AVX) +# Goldmont 1.08(+24%) + +# March 2013 +# +# ... 8x aggregate factor AVX code path is using reduction algorithm +# suggested by Shay Gueron[1]. Even though contemporary AVX-capable +# CPUs such as Sandy and Ivy Bridge can execute it, the code performs +# sub-optimally in comparison to above mentioned version. But thanks +# to Ilya Albrekht and Max Locktyukhin of Intel Corp. we knew that +# it performs in 0.41 cycles per byte on Haswell processor, in +# 0.29 on Broadwell, and in 0.36 on Skylake. +# +# Knights Landing achieves 1.09 cpb. +# +# [1] http://rt.openssl.org/Ticket/Display.html?id=2900&user=guest&pass=guest + +# This file was patched in BoringSSL to remove the variable-time 4-bit +# implementation. + +$flavour = shift; +$output = shift; +if ($flavour =~ /\./) { $output = $flavour; undef $flavour; } + +$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/); + +$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; +( $xlate="${dir}x86_64-xlate.pl" and -f $xlate ) or +( $xlate="${dir}../../../perlasm/x86_64-xlate.pl" and -f $xlate) or +die "can't locate x86_64-xlate.pl"; + +# See the notes about |$avx| in aesni-gcm-x86_64.pl; otherwise tags will be +# computed incorrectly. +# +# In upstream, this is controlled by shelling out to the compiler to check +# versions, but BoringSSL is intended to be used with pre-generated perlasm +# output, so this isn't useful anyway. +$avx = 1; + +open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""; +*STDOUT=*OUT; + +$do4xaggr=1; + + +$code=<<___; +.text +___ + + +###################################################################### +# PCLMULQDQ version. + +@_4args=$win64? ("%rcx","%rdx","%r8", "%r9") : # Win64 order + ("%rdi","%rsi","%rdx","%rcx"); # Unix order + +($Xi,$Xhi)=("%xmm0","%xmm1"); $Hkey="%xmm2"; +($T1,$T2,$T3)=("%xmm3","%xmm4","%xmm5"); + +sub clmul64x64_T2 { # minimal register pressure +my ($Xhi,$Xi,$Hkey,$HK)=@_; + +if (!defined($HK)) { $HK = $T2; +$code.=<<___; + movdqa $Xi,$Xhi # + pshufd \$0b01001110,$Xi,$T1 + pshufd \$0b01001110,$Hkey,$T2 + pxor $Xi,$T1 # + pxor $Hkey,$T2 +___ +} else { +$code.=<<___; + movdqa $Xi,$Xhi # + pshufd \$0b01001110,$Xi,$T1 + pxor $Xi,$T1 # +___ +} +$code.=<<___; + pclmulqdq \$0x00,$Hkey,$Xi ####### + pclmulqdq \$0x11,$Hkey,$Xhi ####### + pclmulqdq \$0x00,$HK,$T1 ####### + pxor $Xi,$T1 # + pxor $Xhi,$T1 # + + movdqa $T1,$T2 # + psrldq \$8,$T1 + pslldq \$8,$T2 # + pxor $T1,$Xhi + pxor $T2,$Xi # +___ +} + +sub reduction_alg9 { # 17/11 times faster than Intel version +my ($Xhi,$Xi) = @_; + +$code.=<<___; + # 1st phase + movdqa $Xi,$T2 # + movdqa $Xi,$T1 + psllq \$5,$Xi + pxor $Xi,$T1 # + psllq \$1,$Xi + pxor $T1,$Xi # + psllq \$57,$Xi # + movdqa $Xi,$T1 # + pslldq \$8,$Xi + psrldq \$8,$T1 # + pxor $T2,$Xi + pxor $T1,$Xhi # + + # 2nd phase + movdqa $Xi,$T2 + psrlq \$1,$Xi + pxor $T2,$Xhi # + pxor $Xi,$T2 + psrlq \$5,$Xi + pxor $T2,$Xi # + psrlq \$1,$Xi # + pxor $Xhi,$Xi # +___ +} + +{ my ($Htbl,$Xip)=@_4args; + my $HK="%xmm6"; + +$code.=<<___; +.globl gcm_init_clmul +.type gcm_init_clmul,\@abi-omnipotent +.align 16 +gcm_init_clmul: +.cfi_startproc +.seh_startproc + _CET_ENDBR +.L_init_clmul: +___ +$code.=<<___ if ($win64); + sub \$0x18,%rsp +.seh_stackalloc 0x18 + movaps %xmm6,(%rsp) +.seh_savexmm %xmm6, 0 +.seh_endprologue +___ +$code.=<<___; + movdqu ($Xip),$Hkey + pshufd \$0b01001110,$Hkey,$Hkey # dword swap + + # <<1 twist + pshufd \$0b11111111,$Hkey,$T2 # broadcast uppermost dword + movdqa $Hkey,$T1 + psllq \$1,$Hkey + pxor $T3,$T3 # + psrlq \$63,$T1 + pcmpgtd $T2,$T3 # broadcast carry bit + pslldq \$8,$T1 + por $T1,$Hkey # H<<=1 + + # magic reduction + pand .L0x1c2_polynomial(%rip),$T3 + pxor $T3,$Hkey # if(carry) H^=0x1c2_polynomial + + # calculate H^2 + pshufd \$0b01001110,$Hkey,$HK + movdqa $Hkey,$Xi + pxor $Hkey,$HK +___ + &clmul64x64_T2 ($Xhi,$Xi,$Hkey,$HK); + &reduction_alg9 ($Xhi,$Xi); +$code.=<<___; + pshufd \$0b01001110,$Hkey,$T1 + pshufd \$0b01001110,$Xi,$T2 + pxor $Hkey,$T1 # Karatsuba pre-processing + movdqu $Hkey,0x00($Htbl) # save H + pxor $Xi,$T2 # Karatsuba pre-processing + movdqu $Xi,0x10($Htbl) # save H^2 + palignr \$8,$T1,$T2 # low part is H.lo^H.hi... + movdqu $T2,0x20($Htbl) # save Karatsuba "salt" +___ +if ($do4xaggr) { + &clmul64x64_T2 ($Xhi,$Xi,$Hkey,$HK); # H^3 + &reduction_alg9 ($Xhi,$Xi); +$code.=<<___; + movdqa $Xi,$T3 +___ + &clmul64x64_T2 ($Xhi,$Xi,$Hkey,$HK); # H^4 + &reduction_alg9 ($Xhi,$Xi); +$code.=<<___; + pshufd \$0b01001110,$T3,$T1 + pshufd \$0b01001110,$Xi,$T2 + pxor $T3,$T1 # Karatsuba pre-processing + movdqu $T3,0x30($Htbl) # save H^3 + pxor $Xi,$T2 # Karatsuba pre-processing + movdqu $Xi,0x40($Htbl) # save H^4 + palignr \$8,$T1,$T2 # low part is H^3.lo^H^3.hi... + movdqu $T2,0x50($Htbl) # save Karatsuba "salt" +___ +} +$code.=<<___ if ($win64); + movaps (%rsp),%xmm6 + lea 0x18(%rsp),%rsp +___ +$code.=<<___; + ret +.cfi_endproc +.seh_endproc +.size gcm_init_clmul,.-gcm_init_clmul +___ +} + + +{ my ($Xip,$Htbl,$inp,$len)=@_4args; + my ($Xln,$Xmn,$Xhn,$Hkey2,$HK) = map("%xmm$_",(3..7)); + my ($T1,$T2,$T3)=map("%xmm$_",(8..10)); + +$code.=<<___; +.globl gcm_ghash_clmul +.type gcm_ghash_clmul,\@abi-omnipotent +.align 32 +gcm_ghash_clmul: +.cfi_startproc +.seh_startproc + _CET_ENDBR +.L_ghash_clmul: +___ +$code.=<<___ if ($win64); + lea -0x88(%rsp),%rax + lea -0x20(%rax),%rsp +.seh_stackalloc 0x20+0x88 + movaps %xmm6,-0x20(%rax) +.seh_savexmm %xmm6, 0x20-0x20 + movaps %xmm7,-0x10(%rax) +.seh_savexmm %xmm7, 0x20-0x10 + movaps %xmm8,0(%rax) +.seh_savexmm %xmm8, 0x20+0 + movaps %xmm9,0x10(%rax) +.seh_savexmm %xmm9, 0x20+0x10 + movaps %xmm10,0x20(%rax) +.seh_savexmm %xmm10, 0x20+0x20 + movaps %xmm11,0x30(%rax) +.seh_savexmm %xmm11, 0x20+0x30 + movaps %xmm12,0x40(%rax) +.seh_savexmm %xmm12, 0x20+0x40 + movaps %xmm13,0x50(%rax) +.seh_savexmm %xmm13, 0x20+0x50 + movaps %xmm14,0x60(%rax) +.seh_savexmm %xmm14, 0x20+0x60 + movaps %xmm15,0x70(%rax) +.seh_savexmm %xmm15, 0x20+0x70 +.seh_endprologue +___ +$code.=<<___; + movdqa .Lbswap_mask(%rip),$T3 + + movdqu ($Xip),$Xi + movdqu ($Htbl),$Hkey + movdqu 0x20($Htbl),$HK + pshufb $T3,$Xi + + sub \$0x10,$len + jz .Lodd_tail + + movdqu 0x10($Htbl),$Hkey2 +___ +if ($do4xaggr) { +my ($Xl,$Xm,$Xh,$Hkey3,$Hkey4)=map("%xmm$_",(11..15)); + +$code.=<<___; + cmp \$0x30,$len + jb .Lskip4x + + sub \$0x30,$len + mov \$0xA040608020C0E000,%rax # ((7..0)·0xE0)&0xff + movdqu 0x30($Htbl),$Hkey3 + movdqu 0x40($Htbl),$Hkey4 + + ####### + # Xi+4 =[(H*Ii+3) + (H^2*Ii+2) + (H^3*Ii+1) + H^4*(Ii+Xi)] mod P + # + movdqu 0x30($inp),$Xln + movdqu 0x20($inp),$Xl + pshufb $T3,$Xln + pshufb $T3,$Xl + movdqa $Xln,$Xhn + pshufd \$0b01001110,$Xln,$Xmn + pxor $Xln,$Xmn + pclmulqdq \$0x00,$Hkey,$Xln + pclmulqdq \$0x11,$Hkey,$Xhn + pclmulqdq \$0x00,$HK,$Xmn + + movdqa $Xl,$Xh + pshufd \$0b01001110,$Xl,$Xm + pxor $Xl,$Xm + pclmulqdq \$0x00,$Hkey2,$Xl + pclmulqdq \$0x11,$Hkey2,$Xh + pclmulqdq \$0x10,$HK,$Xm + xorps $Xl,$Xln + xorps $Xh,$Xhn + movups 0x50($Htbl),$HK + xorps $Xm,$Xmn + + movdqu 0x10($inp),$Xl + movdqu 0($inp),$T1 + pshufb $T3,$Xl + pshufb $T3,$T1 + movdqa $Xl,$Xh + pshufd \$0b01001110,$Xl,$Xm + pxor $T1,$Xi + pxor $Xl,$Xm + pclmulqdq \$0x00,$Hkey3,$Xl + movdqa $Xi,$Xhi + pshufd \$0b01001110,$Xi,$T1 + pxor $Xi,$T1 + pclmulqdq \$0x11,$Hkey3,$Xh + pclmulqdq \$0x00,$HK,$Xm + xorps $Xl,$Xln + xorps $Xh,$Xhn + + lea 0x40($inp),$inp + sub \$0x40,$len + jc .Ltail4x + + jmp .Lmod4_loop +.align 32 +.Lmod4_loop: + pclmulqdq \$0x00,$Hkey4,$Xi + xorps $Xm,$Xmn + movdqu 0x30($inp),$Xl + pshufb $T3,$Xl + pclmulqdq \$0x11,$Hkey4,$Xhi + xorps $Xln,$Xi + movdqu 0x20($inp),$Xln + movdqa $Xl,$Xh + pclmulqdq \$0x10,$HK,$T1 + pshufd \$0b01001110,$Xl,$Xm + xorps $Xhn,$Xhi + pxor $Xl,$Xm + pshufb $T3,$Xln + movups 0x20($Htbl),$HK + xorps $Xmn,$T1 + pclmulqdq \$0x00,$Hkey,$Xl + pshufd \$0b01001110,$Xln,$Xmn + + pxor $Xi,$T1 # aggregated Karatsuba post-processing + movdqa $Xln,$Xhn + pxor $Xhi,$T1 # + pxor $Xln,$Xmn + movdqa $T1,$T2 # + pclmulqdq \$0x11,$Hkey,$Xh + pslldq \$8,$T1 + psrldq \$8,$T2 # + pxor $T1,$Xi + movdqa .L7_mask(%rip),$T1 + pxor $T2,$Xhi # + movq %rax,$T2 + + pand $Xi,$T1 # 1st phase + pshufb $T1,$T2 # + pxor $Xi,$T2 # + pclmulqdq \$0x00,$HK,$Xm + psllq \$57,$T2 # + movdqa $T2,$T1 # + pslldq \$8,$T2 + pclmulqdq \$0x00,$Hkey2,$Xln + psrldq \$8,$T1 # + pxor $T2,$Xi + pxor $T1,$Xhi # + movdqu 0($inp),$T1 + + movdqa $Xi,$T2 # 2nd phase + psrlq \$1,$Xi + pclmulqdq \$0x11,$Hkey2,$Xhn + xorps $Xl,$Xln + movdqu 0x10($inp),$Xl + pshufb $T3,$Xl + pclmulqdq \$0x10,$HK,$Xmn + xorps $Xh,$Xhn + movups 0x50($Htbl),$HK + pshufb $T3,$T1 + pxor $T2,$Xhi # + pxor $Xi,$T2 + psrlq \$5,$Xi + + movdqa $Xl,$Xh + pxor $Xm,$Xmn + pshufd \$0b01001110,$Xl,$Xm + pxor $T2,$Xi # + pxor $T1,$Xhi + pxor $Xl,$Xm + pclmulqdq \$0x00,$Hkey3,$Xl + psrlq \$1,$Xi # + pxor $Xhi,$Xi # + movdqa $Xi,$Xhi + pclmulqdq \$0x11,$Hkey3,$Xh + xorps $Xl,$Xln + pshufd \$0b01001110,$Xi,$T1 + pxor $Xi,$T1 + + pclmulqdq \$0x00,$HK,$Xm + xorps $Xh,$Xhn + + lea 0x40($inp),$inp + sub \$0x40,$len + jnc .Lmod4_loop + +.Ltail4x: + pclmulqdq \$0x00,$Hkey4,$Xi + pclmulqdq \$0x11,$Hkey4,$Xhi + pclmulqdq \$0x10,$HK,$T1 + xorps $Xm,$Xmn + xorps $Xln,$Xi + xorps $Xhn,$Xhi + pxor $Xi,$Xhi # aggregated Karatsuba post-processing + pxor $Xmn,$T1 + + pxor $Xhi,$T1 # + pxor $Xi,$Xhi + + movdqa $T1,$T2 # + psrldq \$8,$T1 + pslldq \$8,$T2 # + pxor $T1,$Xhi + pxor $T2,$Xi # +___ + &reduction_alg9($Xhi,$Xi); +$code.=<<___; + add \$0x40,$len + jz .Ldone + movdqu 0x20($Htbl),$HK + sub \$0x10,$len + jz .Lodd_tail +.Lskip4x: +___ +} +$code.=<<___; + ####### + # Xi+2 =[H*(Ii+1 + Xi+1)] mod P = + # [(H*Ii+1) + (H*Xi+1)] mod P = + # [(H*Ii+1) + H^2*(Ii+Xi)] mod P + # + movdqu ($inp),$T1 # Ii + movdqu 16($inp),$Xln # Ii+1 + pshufb $T3,$T1 + pshufb $T3,$Xln + pxor $T1,$Xi # Ii+Xi + + movdqa $Xln,$Xhn + pshufd \$0b01001110,$Xln,$Xmn + pxor $Xln,$Xmn + pclmulqdq \$0x00,$Hkey,$Xln + pclmulqdq \$0x11,$Hkey,$Xhn + pclmulqdq \$0x00,$HK,$Xmn + + lea 32($inp),$inp # i+=2 + nop + sub \$0x20,$len + jbe .Leven_tail + nop + jmp .Lmod_loop + +.align 32 +.Lmod_loop: + movdqa $Xi,$Xhi + movdqa $Xmn,$T1 + pshufd \$0b01001110,$Xi,$Xmn # + pxor $Xi,$Xmn # + + pclmulqdq \$0x00,$Hkey2,$Xi + pclmulqdq \$0x11,$Hkey2,$Xhi + pclmulqdq \$0x10,$HK,$Xmn + + pxor $Xln,$Xi # (H*Ii+1) + H^2*(Ii+Xi) + pxor $Xhn,$Xhi + movdqu ($inp),$T2 # Ii + pxor $Xi,$T1 # aggregated Karatsuba post-processing + pshufb $T3,$T2 + movdqu 16($inp),$Xln # Ii+1 + + pxor $Xhi,$T1 + pxor $T2,$Xhi # "Ii+Xi", consume early + pxor $T1,$Xmn + pshufb $T3,$Xln + movdqa $Xmn,$T1 # + psrldq \$8,$T1 + pslldq \$8,$Xmn # + pxor $T1,$Xhi + pxor $Xmn,$Xi # + + movdqa $Xln,$Xhn # + + movdqa $Xi,$T2 # 1st phase + movdqa $Xi,$T1 + psllq \$5,$Xi + pxor $Xi,$T1 # + pclmulqdq \$0x00,$Hkey,$Xln ####### + psllq \$1,$Xi + pxor $T1,$Xi # + psllq \$57,$Xi # + movdqa $Xi,$T1 # + pslldq \$8,$Xi + psrldq \$8,$T1 # + pxor $T2,$Xi + pshufd \$0b01001110,$Xhn,$Xmn + pxor $T1,$Xhi # + pxor $Xhn,$Xmn # + + movdqa $Xi,$T2 # 2nd phase + psrlq \$1,$Xi + pclmulqdq \$0x11,$Hkey,$Xhn ####### + pxor $T2,$Xhi # + pxor $Xi,$T2 + psrlq \$5,$Xi + pxor $T2,$Xi # + lea 32($inp),$inp + psrlq \$1,$Xi # + pclmulqdq \$0x00,$HK,$Xmn ####### + pxor $Xhi,$Xi # + + sub \$0x20,$len + ja .Lmod_loop + +.Leven_tail: + movdqa $Xi,$Xhi + movdqa $Xmn,$T1 + pshufd \$0b01001110,$Xi,$Xmn # + pxor $Xi,$Xmn # + + pclmulqdq \$0x00,$Hkey2,$Xi + pclmulqdq \$0x11,$Hkey2,$Xhi + pclmulqdq \$0x10,$HK,$Xmn + + pxor $Xln,$Xi # (H*Ii+1) + H^2*(Ii+Xi) + pxor $Xhn,$Xhi + pxor $Xi,$T1 + pxor $Xhi,$T1 + pxor $T1,$Xmn + movdqa $Xmn,$T1 # + psrldq \$8,$T1 + pslldq \$8,$Xmn # + pxor $T1,$Xhi + pxor $Xmn,$Xi # +___ + &reduction_alg9 ($Xhi,$Xi); +$code.=<<___; + test $len,$len + jnz .Ldone + +.Lodd_tail: + movdqu ($inp),$T1 # Ii + pshufb $T3,$T1 + pxor $T1,$Xi # Ii+Xi +___ + &clmul64x64_T2 ($Xhi,$Xi,$Hkey,$HK); # H*(Ii+Xi) + &reduction_alg9 ($Xhi,$Xi); +$code.=<<___; +.Ldone: + pshufb $T3,$Xi + movdqu $Xi,($Xip) +___ +$code.=<<___ if ($win64); + movaps (%rsp),%xmm6 + movaps 0x10(%rsp),%xmm7 + movaps 0x20(%rsp),%xmm8 + movaps 0x30(%rsp),%xmm9 + movaps 0x40(%rsp),%xmm10 + movaps 0x50(%rsp),%xmm11 + movaps 0x60(%rsp),%xmm12 + movaps 0x70(%rsp),%xmm13 + movaps 0x80(%rsp),%xmm14 + movaps 0x90(%rsp),%xmm15 + lea 0xa8(%rsp),%rsp +___ +$code.=<<___; + ret +.cfi_endproc +.seh_endproc +.size gcm_ghash_clmul,.-gcm_ghash_clmul +___ +} + +$code.=<<___; +.globl gcm_init_avx +.type gcm_init_avx,\@abi-omnipotent +.align 32 +gcm_init_avx: +.cfi_startproc +.seh_startproc + _CET_ENDBR +___ +if ($avx) { +my ($Htbl,$Xip)=@_4args; +my $HK="%xmm6"; + +$code.=<<___ if ($win64); + sub \$0x18,%rsp +.seh_stackalloc 0x18 + movaps %xmm6,(%rsp) +.seh_savexmm %xmm6, 0 +.seh_endprologue +___ +$code.=<<___; + vzeroupper + + vmovdqu ($Xip),$Hkey + vpshufd \$0b01001110,$Hkey,$Hkey # dword swap + + # <<1 twist + vpshufd \$0b11111111,$Hkey,$T2 # broadcast uppermost dword + vpsrlq \$63,$Hkey,$T1 + vpsllq \$1,$Hkey,$Hkey + vpxor $T3,$T3,$T3 # + vpcmpgtd $T2,$T3,$T3 # broadcast carry bit + vpslldq \$8,$T1,$T1 + vpor $T1,$Hkey,$Hkey # H<<=1 + + # magic reduction + vpand .L0x1c2_polynomial(%rip),$T3,$T3 + vpxor $T3,$Hkey,$Hkey # if(carry) H^=0x1c2_polynomial + + vpunpckhqdq $Hkey,$Hkey,$HK + vmovdqa $Hkey,$Xi + vpxor $Hkey,$HK,$HK + mov \$4,%r10 # up to H^8 + jmp .Linit_start_avx +___ + +sub clmul64x64_avx { +my ($Xhi,$Xi,$Hkey,$HK)=@_; + +if (!defined($HK)) { $HK = $T2; +$code.=<<___; + vpunpckhqdq $Xi,$Xi,$T1 + vpunpckhqdq $Hkey,$Hkey,$T2 + vpxor $Xi,$T1,$T1 # + vpxor $Hkey,$T2,$T2 +___ +} else { +$code.=<<___; + vpunpckhqdq $Xi,$Xi,$T1 + vpxor $Xi,$T1,$T1 # +___ +} +$code.=<<___; + vpclmulqdq \$0x11,$Hkey,$Xi,$Xhi ####### + vpclmulqdq \$0x00,$Hkey,$Xi,$Xi ####### + vpclmulqdq \$0x00,$HK,$T1,$T1 ####### + vpxor $Xi,$Xhi,$T2 # + vpxor $T2,$T1,$T1 # + + vpslldq \$8,$T1,$T2 # + vpsrldq \$8,$T1,$T1 + vpxor $T2,$Xi,$Xi # + vpxor $T1,$Xhi,$Xhi +___ +} + +sub reduction_avx { +my ($Xhi,$Xi) = @_; + +$code.=<<___; + vpsllq \$57,$Xi,$T1 # 1st phase + vpsllq \$62,$Xi,$T2 + vpxor $T1,$T2,$T2 # + vpsllq \$63,$Xi,$T1 + vpxor $T1,$T2,$T2 # + vpslldq \$8,$T2,$T1 # + vpsrldq \$8,$T2,$T2 + vpxor $T1,$Xi,$Xi # + vpxor $T2,$Xhi,$Xhi + + vpsrlq \$1,$Xi,$T2 # 2nd phase + vpxor $Xi,$Xhi,$Xhi + vpxor $T2,$Xi,$Xi # + vpsrlq \$5,$T2,$T2 + vpxor $T2,$Xi,$Xi # + vpsrlq \$1,$Xi,$Xi # + vpxor $Xhi,$Xi,$Xi # +___ +} + +$code.=<<___; +.align 32 +.Linit_loop_avx: + vpalignr \$8,$T1,$T2,$T3 # low part is H.lo^H.hi... + vmovdqu $T3,-0x10($Htbl) # save Karatsuba "salt" +___ + &clmul64x64_avx ($Xhi,$Xi,$Hkey,$HK); # calculate H^3,5,7 + &reduction_avx ($Xhi,$Xi); +$code.=<<___; +.Linit_start_avx: + vmovdqa $Xi,$T3 +___ + &clmul64x64_avx ($Xhi,$Xi,$Hkey,$HK); # calculate H^2,4,6,8 + &reduction_avx ($Xhi,$Xi); +$code.=<<___; + vpshufd \$0b01001110,$T3,$T1 + vpshufd \$0b01001110,$Xi,$T2 + vpxor $T3,$T1,$T1 # Karatsuba pre-processing + vmovdqu $T3,0x00($Htbl) # save H^1,3,5,7 + vpxor $Xi,$T2,$T2 # Karatsuba pre-processing + vmovdqu $Xi,0x10($Htbl) # save H^2,4,6,8 + lea 0x30($Htbl),$Htbl + sub \$1,%r10 + jnz .Linit_loop_avx + + vpalignr \$8,$T2,$T1,$T3 # last "salt" is flipped + vmovdqu $T3,-0x10($Htbl) + + vzeroupper +___ +$code.=<<___ if ($win64); + movaps (%rsp),%xmm6 + lea 0x18(%rsp),%rsp +___ +$code.=<<___; + ret +.seh_endproc +.cfi_endproc +.size gcm_init_avx,.-gcm_init_avx +___ +} else { +$code.=<<___; + jmp .L_init_clmul +.size gcm_init_avx,.-gcm_init_avx +___ +} + +$code.=<<___; +.globl gcm_ghash_avx +.type gcm_ghash_avx,\@abi-omnipotent +.align 32 +gcm_ghash_avx: +.cfi_startproc +.seh_startproc + _CET_ENDBR +___ +if ($avx) { +my ($Xip,$Htbl,$inp,$len)=@_4args; +my ($Xlo,$Xhi,$Xmi, + $Zlo,$Zhi,$Zmi, + $Hkey,$HK,$T1,$T2, + $Xi,$Xo,$Tred,$bswap,$Ii,$Ij) = map("%xmm$_",(0..15)); + +$code.=<<___ if ($win64); + lea -0x88(%rsp),%rax + lea -0x20(%rax),%rsp +.seh_stackalloc 0x20+0x88 + movaps %xmm6,-0x20(%rax) +.seh_savexmm %xmm6, 0x20-0x20 + movaps %xmm7,-0x10(%rax) +.seh_savexmm %xmm7, 0x20-0x10 + movaps %xmm8,0(%rax) +.seh_savexmm %xmm8, 0x20+0 + movaps %xmm9,0x10(%rax) +.seh_savexmm %xmm9, 0x20+0x10 + movaps %xmm10,0x20(%rax) +.seh_savexmm %xmm10, 0x20+0x20 + movaps %xmm11,0x30(%rax) +.seh_savexmm %xmm11, 0x20+0x30 + movaps %xmm12,0x40(%rax) +.seh_savexmm %xmm12, 0x20+0x40 + movaps %xmm13,0x50(%rax) +.seh_savexmm %xmm13, 0x20+0x50 + movaps %xmm14,0x60(%rax) +.seh_savexmm %xmm14, 0x20+0x60 + movaps %xmm15,0x70(%rax) +.seh_savexmm %xmm15, 0x20+0x70 +.seh_endprologue +___ +$code.=<<___; + vzeroupper + + vmovdqu ($Xip),$Xi # load $Xi + lea .L0x1c2_polynomial(%rip),%r10 + lea 0x40($Htbl),$Htbl # size optimization + vmovdqu .Lbswap_mask(%rip),$bswap + vpshufb $bswap,$Xi,$Xi + cmp \$0x80,$len + jb .Lshort_avx + sub \$0x80,$len + + vmovdqu 0x70($inp),$Ii # I[7] + vmovdqu 0x00-0x40($Htbl),$Hkey # $Hkey^1 + vpshufb $bswap,$Ii,$Ii + vmovdqu 0x20-0x40($Htbl),$HK + + vpunpckhqdq $Ii,$Ii,$T2 + vmovdqu 0x60($inp),$Ij # I[6] + vpclmulqdq \$0x00,$Hkey,$Ii,$Xlo + vpxor $Ii,$T2,$T2 + vpshufb $bswap,$Ij,$Ij + vpclmulqdq \$0x11,$Hkey,$Ii,$Xhi + vmovdqu 0x10-0x40($Htbl),$Hkey # $Hkey^2 + vpunpckhqdq $Ij,$Ij,$T1 + vmovdqu 0x50($inp),$Ii # I[5] + vpclmulqdq \$0x00,$HK,$T2,$Xmi + vpxor $Ij,$T1,$T1 + + vpshufb $bswap,$Ii,$Ii + vpclmulqdq \$0x00,$Hkey,$Ij,$Zlo + vpunpckhqdq $Ii,$Ii,$T2 + vpclmulqdq \$0x11,$Hkey,$Ij,$Zhi + vmovdqu 0x30-0x40($Htbl),$Hkey # $Hkey^3 + vpxor $Ii,$T2,$T2 + vmovdqu 0x40($inp),$Ij # I[4] + vpclmulqdq \$0x10,$HK,$T1,$Zmi + vmovdqu 0x50-0x40($Htbl),$HK + + vpshufb $bswap,$Ij,$Ij + vpxor $Xlo,$Zlo,$Zlo + vpclmulqdq \$0x00,$Hkey,$Ii,$Xlo + vpxor $Xhi,$Zhi,$Zhi + vpunpckhqdq $Ij,$Ij,$T1 + vpclmulqdq \$0x11,$Hkey,$Ii,$Xhi + vmovdqu 0x40-0x40($Htbl),$Hkey # $Hkey^4 + vpxor $Xmi,$Zmi,$Zmi + vpclmulqdq \$0x00,$HK,$T2,$Xmi + vpxor $Ij,$T1,$T1 + + vmovdqu 0x30($inp),$Ii # I[3] + vpxor $Zlo,$Xlo,$Xlo + vpclmulqdq \$0x00,$Hkey,$Ij,$Zlo + vpxor $Zhi,$Xhi,$Xhi + vpshufb $bswap,$Ii,$Ii + vpclmulqdq \$0x11,$Hkey,$Ij,$Zhi + vmovdqu 0x60-0x40($Htbl),$Hkey # $Hkey^5 + vpxor $Zmi,$Xmi,$Xmi + vpunpckhqdq $Ii,$Ii,$T2 + vpclmulqdq \$0x10,$HK,$T1,$Zmi + vmovdqu 0x80-0x40($Htbl),$HK + vpxor $Ii,$T2,$T2 + + vmovdqu 0x20($inp),$Ij # I[2] + vpxor $Xlo,$Zlo,$Zlo + vpclmulqdq \$0x00,$Hkey,$Ii,$Xlo + vpxor $Xhi,$Zhi,$Zhi + vpshufb $bswap,$Ij,$Ij + vpclmulqdq \$0x11,$Hkey,$Ii,$Xhi + vmovdqu 0x70-0x40($Htbl),$Hkey # $Hkey^6 + vpxor $Xmi,$Zmi,$Zmi + vpunpckhqdq $Ij,$Ij,$T1 + vpclmulqdq \$0x00,$HK,$T2,$Xmi + vpxor $Ij,$T1,$T1 + + vmovdqu 0x10($inp),$Ii # I[1] + vpxor $Zlo,$Xlo,$Xlo + vpclmulqdq \$0x00,$Hkey,$Ij,$Zlo + vpxor $Zhi,$Xhi,$Xhi + vpshufb $bswap,$Ii,$Ii + vpclmulqdq \$0x11,$Hkey,$Ij,$Zhi + vmovdqu 0x90-0x40($Htbl),$Hkey # $Hkey^7 + vpxor $Zmi,$Xmi,$Xmi + vpunpckhqdq $Ii,$Ii,$T2 + vpclmulqdq \$0x10,$HK,$T1,$Zmi + vmovdqu 0xb0-0x40($Htbl),$HK + vpxor $Ii,$T2,$T2 + + vmovdqu ($inp),$Ij # I[0] + vpxor $Xlo,$Zlo,$Zlo + vpclmulqdq \$0x00,$Hkey,$Ii,$Xlo + vpxor $Xhi,$Zhi,$Zhi + vpshufb $bswap,$Ij,$Ij + vpclmulqdq \$0x11,$Hkey,$Ii,$Xhi + vmovdqu 0xa0-0x40($Htbl),$Hkey # $Hkey^8 + vpxor $Xmi,$Zmi,$Zmi + vpclmulqdq \$0x10,$HK,$T2,$Xmi + + lea 0x80($inp),$inp + cmp \$0x80,$len + jb .Ltail_avx + + vpxor $Xi,$Ij,$Ij # accumulate $Xi + sub \$0x80,$len + jmp .Loop8x_avx + +.align 32 +.Loop8x_avx: + vpunpckhqdq $Ij,$Ij,$T1 + vmovdqu 0x70($inp),$Ii # I[7] + vpxor $Xlo,$Zlo,$Zlo + vpxor $Ij,$T1,$T1 + vpclmulqdq \$0x00,$Hkey,$Ij,$Xi + vpshufb $bswap,$Ii,$Ii + vpxor $Xhi,$Zhi,$Zhi + vpclmulqdq \$0x11,$Hkey,$Ij,$Xo + vmovdqu 0x00-0x40($Htbl),$Hkey # $Hkey^1 + vpunpckhqdq $Ii,$Ii,$T2 + vpxor $Xmi,$Zmi,$Zmi + vpclmulqdq \$0x00,$HK,$T1,$Tred + vmovdqu 0x20-0x40($Htbl),$HK + vpxor $Ii,$T2,$T2 + + vmovdqu 0x60($inp),$Ij # I[6] + vpclmulqdq \$0x00,$Hkey,$Ii,$Xlo + vpxor $Zlo,$Xi,$Xi # collect result + vpshufb $bswap,$Ij,$Ij + vpclmulqdq \$0x11,$Hkey,$Ii,$Xhi + vxorps $Zhi,$Xo,$Xo + vmovdqu 0x10-0x40($Htbl),$Hkey # $Hkey^2 + vpunpckhqdq $Ij,$Ij,$T1 + vpclmulqdq \$0x00,$HK, $T2,$Xmi + vpxor $Zmi,$Tred,$Tred + vxorps $Ij,$T1,$T1 + + vmovdqu 0x50($inp),$Ii # I[5] + vpxor $Xi,$Tred,$Tred # aggregated Karatsuba post-processing + vpclmulqdq \$0x00,$Hkey,$Ij,$Zlo + vpxor $Xo,$Tred,$Tred + vpslldq \$8,$Tred,$T2 + vpxor $Xlo,$Zlo,$Zlo + vpclmulqdq \$0x11,$Hkey,$Ij,$Zhi + vpsrldq \$8,$Tred,$Tred + vpxor $T2, $Xi, $Xi + vmovdqu 0x30-0x40($Htbl),$Hkey # $Hkey^3 + vpshufb $bswap,$Ii,$Ii + vxorps $Tred,$Xo, $Xo + vpxor $Xhi,$Zhi,$Zhi + vpunpckhqdq $Ii,$Ii,$T2 + vpclmulqdq \$0x10,$HK, $T1,$Zmi + vmovdqu 0x50-0x40($Htbl),$HK + vpxor $Ii,$T2,$T2 + vpxor $Xmi,$Zmi,$Zmi + + vmovdqu 0x40($inp),$Ij # I[4] + vpalignr \$8,$Xi,$Xi,$Tred # 1st phase + vpclmulqdq \$0x00,$Hkey,$Ii,$Xlo + vpshufb $bswap,$Ij,$Ij + vpxor $Zlo,$Xlo,$Xlo + vpclmulqdq \$0x11,$Hkey,$Ii,$Xhi + vmovdqu 0x40-0x40($Htbl),$Hkey # $Hkey^4 + vpunpckhqdq $Ij,$Ij,$T1 + vpxor $Zhi,$Xhi,$Xhi + vpclmulqdq \$0x00,$HK, $T2,$Xmi + vxorps $Ij,$T1,$T1 + vpxor $Zmi,$Xmi,$Xmi + + vmovdqu 0x30($inp),$Ii # I[3] + vpclmulqdq \$0x10,(%r10),$Xi,$Xi + vpclmulqdq \$0x00,$Hkey,$Ij,$Zlo + vpshufb $bswap,$Ii,$Ii + vpxor $Xlo,$Zlo,$Zlo + vpclmulqdq \$0x11,$Hkey,$Ij,$Zhi + vmovdqu 0x60-0x40($Htbl),$Hkey # $Hkey^5 + vpunpckhqdq $Ii,$Ii,$T2 + vpxor $Xhi,$Zhi,$Zhi + vpclmulqdq \$0x10,$HK, $T1,$Zmi + vmovdqu 0x80-0x40($Htbl),$HK + vpxor $Ii,$T2,$T2 + vpxor $Xmi,$Zmi,$Zmi + + vmovdqu 0x20($inp),$Ij # I[2] + vpclmulqdq \$0x00,$Hkey,$Ii,$Xlo + vpshufb $bswap,$Ij,$Ij + vpxor $Zlo,$Xlo,$Xlo + vpclmulqdq \$0x11,$Hkey,$Ii,$Xhi + vmovdqu 0x70-0x40($Htbl),$Hkey # $Hkey^6 + vpunpckhqdq $Ij,$Ij,$T1 + vpxor $Zhi,$Xhi,$Xhi + vpclmulqdq \$0x00,$HK, $T2,$Xmi + vpxor $Ij,$T1,$T1 + vpxor $Zmi,$Xmi,$Xmi + vxorps $Tred,$Xi,$Xi + + vmovdqu 0x10($inp),$Ii # I[1] + vpalignr \$8,$Xi,$Xi,$Tred # 2nd phase + vpclmulqdq \$0x00,$Hkey,$Ij,$Zlo + vpshufb $bswap,$Ii,$Ii + vpxor $Xlo,$Zlo,$Zlo + vpclmulqdq \$0x11,$Hkey,$Ij,$Zhi + vmovdqu 0x90-0x40($Htbl),$Hkey # $Hkey^7 + vpclmulqdq \$0x10,(%r10),$Xi,$Xi + vxorps $Xo,$Tred,$Tred + vpunpckhqdq $Ii,$Ii,$T2 + vpxor $Xhi,$Zhi,$Zhi + vpclmulqdq \$0x10,$HK, $T1,$Zmi + vmovdqu 0xb0-0x40($Htbl),$HK + vpxor $Ii,$T2,$T2 + vpxor $Xmi,$Zmi,$Zmi + + vmovdqu ($inp),$Ij # I[0] + vpclmulqdq \$0x00,$Hkey,$Ii,$Xlo + vpshufb $bswap,$Ij,$Ij + vpclmulqdq \$0x11,$Hkey,$Ii,$Xhi + vmovdqu 0xa0-0x40($Htbl),$Hkey # $Hkey^8 + vpxor $Tred,$Ij,$Ij + vpclmulqdq \$0x10,$HK, $T2,$Xmi + vpxor $Xi,$Ij,$Ij # accumulate $Xi + + lea 0x80($inp),$inp + sub \$0x80,$len + jnc .Loop8x_avx + + add \$0x80,$len + jmp .Ltail_no_xor_avx + +.align 32 +.Lshort_avx: + vmovdqu -0x10($inp,$len),$Ii # very last word + lea ($inp,$len),$inp + vmovdqu 0x00-0x40($Htbl),$Hkey # $Hkey^1 + vmovdqu 0x20-0x40($Htbl),$HK + vpshufb $bswap,$Ii,$Ij + + vmovdqa $Xlo,$Zlo # subtle way to zero $Zlo, + vmovdqa $Xhi,$Zhi # $Zhi and + vmovdqa $Xmi,$Zmi # $Zmi + sub \$0x10,$len + jz .Ltail_avx + + vpunpckhqdq $Ij,$Ij,$T1 + vpxor $Xlo,$Zlo,$Zlo + vpclmulqdq \$0x00,$Hkey,$Ij,$Xlo + vpxor $Ij,$T1,$T1 + vmovdqu -0x20($inp),$Ii + vpxor $Xhi,$Zhi,$Zhi + vpclmulqdq \$0x11,$Hkey,$Ij,$Xhi + vmovdqu 0x10-0x40($Htbl),$Hkey # $Hkey^2 + vpshufb $bswap,$Ii,$Ij + vpxor $Xmi,$Zmi,$Zmi + vpclmulqdq \$0x00,$HK,$T1,$Xmi + vpsrldq \$8,$HK,$HK + sub \$0x10,$len + jz .Ltail_avx + + vpunpckhqdq $Ij,$Ij,$T1 + vpxor $Xlo,$Zlo,$Zlo + vpclmulqdq \$0x00,$Hkey,$Ij,$Xlo + vpxor $Ij,$T1,$T1 + vmovdqu -0x30($inp),$Ii + vpxor $Xhi,$Zhi,$Zhi + vpclmulqdq \$0x11,$Hkey,$Ij,$Xhi + vmovdqu 0x30-0x40($Htbl),$Hkey # $Hkey^3 + vpshufb $bswap,$Ii,$Ij + vpxor $Xmi,$Zmi,$Zmi + vpclmulqdq \$0x00,$HK,$T1,$Xmi + vmovdqu 0x50-0x40($Htbl),$HK + sub \$0x10,$len + jz .Ltail_avx + + vpunpckhqdq $Ij,$Ij,$T1 + vpxor $Xlo,$Zlo,$Zlo + vpclmulqdq \$0x00,$Hkey,$Ij,$Xlo + vpxor $Ij,$T1,$T1 + vmovdqu -0x40($inp),$Ii + vpxor $Xhi,$Zhi,$Zhi + vpclmulqdq \$0x11,$Hkey,$Ij,$Xhi + vmovdqu 0x40-0x40($Htbl),$Hkey # $Hkey^4 + vpshufb $bswap,$Ii,$Ij + vpxor $Xmi,$Zmi,$Zmi + vpclmulqdq \$0x00,$HK,$T1,$Xmi + vpsrldq \$8,$HK,$HK + sub \$0x10,$len + jz .Ltail_avx + + vpunpckhqdq $Ij,$Ij,$T1 + vpxor $Xlo,$Zlo,$Zlo + vpclmulqdq \$0x00,$Hkey,$Ij,$Xlo + vpxor $Ij,$T1,$T1 + vmovdqu -0x50($inp),$Ii + vpxor $Xhi,$Zhi,$Zhi + vpclmulqdq \$0x11,$Hkey,$Ij,$Xhi + vmovdqu 0x60-0x40($Htbl),$Hkey # $Hkey^5 + vpshufb $bswap,$Ii,$Ij + vpxor $Xmi,$Zmi,$Zmi + vpclmulqdq \$0x00,$HK,$T1,$Xmi + vmovdqu 0x80-0x40($Htbl),$HK + sub \$0x10,$len + jz .Ltail_avx + + vpunpckhqdq $Ij,$Ij,$T1 + vpxor $Xlo,$Zlo,$Zlo + vpclmulqdq \$0x00,$Hkey,$Ij,$Xlo + vpxor $Ij,$T1,$T1 + vmovdqu -0x60($inp),$Ii + vpxor $Xhi,$Zhi,$Zhi + vpclmulqdq \$0x11,$Hkey,$Ij,$Xhi + vmovdqu 0x70-0x40($Htbl),$Hkey # $Hkey^6 + vpshufb $bswap,$Ii,$Ij + vpxor $Xmi,$Zmi,$Zmi + vpclmulqdq \$0x00,$HK,$T1,$Xmi + vpsrldq \$8,$HK,$HK + sub \$0x10,$len + jz .Ltail_avx + + vpunpckhqdq $Ij,$Ij,$T1 + vpxor $Xlo,$Zlo,$Zlo + vpclmulqdq \$0x00,$Hkey,$Ij,$Xlo + vpxor $Ij,$T1,$T1 + vmovdqu -0x70($inp),$Ii + vpxor $Xhi,$Zhi,$Zhi + vpclmulqdq \$0x11,$Hkey,$Ij,$Xhi + vmovdqu 0x90-0x40($Htbl),$Hkey # $Hkey^7 + vpshufb $bswap,$Ii,$Ij + vpxor $Xmi,$Zmi,$Zmi + vpclmulqdq \$0x00,$HK,$T1,$Xmi + vmovq 0xb8-0x40($Htbl),$HK + sub \$0x10,$len + jmp .Ltail_avx + +.align 32 +.Ltail_avx: + vpxor $Xi,$Ij,$Ij # accumulate $Xi +.Ltail_no_xor_avx: + vpunpckhqdq $Ij,$Ij,$T1 + vpxor $Xlo,$Zlo,$Zlo + vpclmulqdq \$0x00,$Hkey,$Ij,$Xlo + vpxor $Ij,$T1,$T1 + vpxor $Xhi,$Zhi,$Zhi + vpclmulqdq \$0x11,$Hkey,$Ij,$Xhi + vpxor $Xmi,$Zmi,$Zmi + vpclmulqdq \$0x00,$HK,$T1,$Xmi + + vmovdqu (%r10),$Tred + + vpxor $Xlo,$Zlo,$Xi + vpxor $Xhi,$Zhi,$Xo + vpxor $Xmi,$Zmi,$Zmi + + vpxor $Xi, $Zmi,$Zmi # aggregated Karatsuba post-processing + vpxor $Xo, $Zmi,$Zmi + vpslldq \$8, $Zmi,$T2 + vpsrldq \$8, $Zmi,$Zmi + vpxor $T2, $Xi, $Xi + vpxor $Zmi,$Xo, $Xo + + vpclmulqdq \$0x10,$Tred,$Xi,$T2 # 1st phase + vpalignr \$8,$Xi,$Xi,$Xi + vpxor $T2,$Xi,$Xi + + vpclmulqdq \$0x10,$Tred,$Xi,$T2 # 2nd phase + vpalignr \$8,$Xi,$Xi,$Xi + vpxor $Xo,$Xi,$Xi + vpxor $T2,$Xi,$Xi + + cmp \$0,$len + jne .Lshort_avx + + vpshufb $bswap,$Xi,$Xi + vmovdqu $Xi,($Xip) + vzeroupper +___ +$code.=<<___ if ($win64); + movaps (%rsp),%xmm6 + movaps 0x10(%rsp),%xmm7 + movaps 0x20(%rsp),%xmm8 + movaps 0x30(%rsp),%xmm9 + movaps 0x40(%rsp),%xmm10 + movaps 0x50(%rsp),%xmm11 + movaps 0x60(%rsp),%xmm12 + movaps 0x70(%rsp),%xmm13 + movaps 0x80(%rsp),%xmm14 + movaps 0x90(%rsp),%xmm15 + lea 0xa8(%rsp),%rsp +___ +$code.=<<___; + ret +.cfi_endproc +.seh_endproc +.size gcm_ghash_avx,.-gcm_ghash_avx +___ +} else { +$code.=<<___; + jmp .L_ghash_clmul +.size gcm_ghash_avx,.-gcm_ghash_avx +___ +} + +$code.=<<___; +.section .rodata +.align 64 +.Lbswap_mask: + .byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 +.L0x1c2_polynomial: + .byte 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0xc2 +.L7_mask: + .long 7,0,7,0 +.align 64 + +.asciz "GHASH for x86_64, CRYPTOGAMS by " +.align 64 +.text +___ + +$code =~ s/\`([^\`]*)\`/eval($1)/gem; + +print $code; + +close STDOUT or die "error closing STDOUT: $!"; diff --git a/http/vendor/ring/crypto/fipsmodule/aes/asm/ghashv8-armx.pl b/http/vendor/ring/crypto/fipsmodule/aes/asm/ghashv8-armx.pl new file mode 100644 index 0000000..1f1df1c --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/aes/asm/ghashv8-armx.pl @@ -0,0 +1,334 @@ +#! /usr/bin/env perl +# Copyright 2014-2020 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# ==================================================================== +# Written by Andy Polyakov for the OpenSSL +# project. +# ==================================================================== +# +# GHASH for ARMv8 Crypto Extension, 64-bit polynomial multiplication. +# +# June 2014 +# +# Initial version was developed in tight cooperation with Ard +# Biesheuvel of Linaro from bits-n-pieces from other assembly modules. +# Just like aesv8-armx.pl this module supports both AArch32 and +# AArch64 execution modes. +# +# July 2014 +# +# Implement 2x aggregated reduction [see ghash-x86.pl for background +# information]. +# +# November 2017 +# +# AArch64 register bank to "accommodate" 4x aggregated reduction and +# improve performance by 20-70% depending on processor. +# +# Current performance in cycles per processed byte: +# +# 64-bit PMULL 32-bit PMULL 32-bit NEON(*) +# Apple A7 0.58 0.92 5.62 +# Cortex-A53 0.85 1.01 8.39 +# Cortex-A57 0.73 1.17 7.61 +# Denver 0.51 0.65 6.02 +# Mongoose 0.65 1.10 8.06 +# Kryo 0.76 1.16 8.00 +# +# (*) presented for reference/comparison purposes; + +$flavour = shift; +$output = shift; + +$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; +( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or +( $xlate="${dir}../../../perlasm/arm-xlate.pl" and -f $xlate) or +die "can't locate arm-xlate.pl"; + +open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""; +*STDOUT=*OUT; + +$Xi="x0"; # argument block +$Htbl="x1"; +$inp="x2"; +$len="x3"; + +$inc="x12"; + +{ +my ($Xl,$Xm,$Xh,$IN)=map("q$_",(0..3)); +my ($t0,$t1,$t2,$xC2,$H,$Hhl,$H2)=map("q$_",(8..14)); + +$code=<<___; +#if __ARM_MAX_ARCH__>=7 +.text +___ +$code.=".arch armv8-a+crypto\n" if ($flavour =~ /64/); +$code.=<<___ if ($flavour !~ /64/); +.fpu neon +.code 32 +#undef __thumb2__ +___ + +################################################################################ +# void gcm_init_clmul(u128 Htable[16],const u64 H[2]); +# +# input: 128-bit H - secret parameter E(K,0^128) +# output: precomputed table filled with degrees of twisted H; +# H is twisted to handle reverse bitness of GHASH; +# only few of 16 slots of Htable[16] are used; +# data is opaque to outside world (which allows to +# optimize the code independently); +# +$code.=<<___; +.global gcm_init_clmul +.type gcm_init_clmul,%function +.align 4 +gcm_init_clmul: + AARCH64_VALID_CALL_TARGET + vld1.64 {$t1},[x1] @ load input H + vmov.i8 $xC2,#0xe1 + vshl.i64 $xC2,$xC2,#57 @ 0xc2.0 + vext.8 $IN,$t1,$t1,#8 + vshr.u64 $t2,$xC2,#63 + vdup.32 $t1,${t1}[1] + vext.8 $t0,$t2,$xC2,#8 @ t0=0xc2....01 + vshr.u64 $t2,$IN,#63 + vshr.s32 $t1,$t1,#31 @ broadcast carry bit + vand $t2,$t2,$t0 + vshl.i64 $IN,$IN,#1 + vext.8 $t2,$t2,$t2,#8 + vand $t0,$t0,$t1 + vorr $IN,$IN,$t2 @ H<<<=1 + veor $H,$IN,$t0 @ twisted H + vst1.64 {$H},[x0],#16 @ store Htable[0] + + @ calculate H^2 + vext.8 $t0,$H,$H,#8 @ Karatsuba pre-processing + vpmull.p64 $Xl,$H,$H + veor $t0,$t0,$H + vpmull2.p64 $Xh,$H,$H + vpmull.p64 $Xm,$t0,$t0 + + vext.8 $t1,$Xl,$Xh,#8 @ Karatsuba post-processing + veor $t2,$Xl,$Xh + veor $Xm,$Xm,$t1 + veor $Xm,$Xm,$t2 + vpmull.p64 $t2,$Xl,$xC2 @ 1st phase + + vmov $Xh#lo,$Xm#hi @ Xh|Xm - 256-bit result + vmov $Xm#hi,$Xl#lo @ Xm is rotated Xl + veor $Xl,$Xm,$t2 + + vext.8 $t2,$Xl,$Xl,#8 @ 2nd phase + vpmull.p64 $Xl,$Xl,$xC2 + veor $t2,$t2,$Xh + veor $H2,$Xl,$t2 + + vext.8 $t1,$H2,$H2,#8 @ Karatsuba pre-processing + veor $t1,$t1,$H2 + vext.8 $Hhl,$t0,$t1,#8 @ pack Karatsuba pre-processed + vst1.64 {$Hhl-$H2},[x0],#32 @ store Htable[1..2] +___ +if ($flavour =~ /64/) { +my ($t3,$Yl,$Ym,$Yh) = map("q$_",(4..7)); + +$code.=<<___; + @ calculate H^3 and H^4 + vpmull.p64 $Xl,$H, $H2 + vpmull.p64 $Yl,$H2,$H2 + vpmull2.p64 $Xh,$H, $H2 + vpmull2.p64 $Yh,$H2,$H2 + vpmull.p64 $Xm,$t0,$t1 + vpmull.p64 $Ym,$t1,$t1 + + vext.8 $t0,$Xl,$Xh,#8 @ Karatsuba post-processing + vext.8 $t1,$Yl,$Yh,#8 + veor $t2,$Xl,$Xh + veor $Xm,$Xm,$t0 + veor $t3,$Yl,$Yh + veor $Ym,$Ym,$t1 + veor $Xm,$Xm,$t2 + vpmull.p64 $t2,$Xl,$xC2 @ 1st phase + veor $Ym,$Ym,$t3 + vpmull.p64 $t3,$Yl,$xC2 + + vmov $Xh#lo,$Xm#hi @ Xh|Xm - 256-bit result + vmov $Yh#lo,$Ym#hi + vmov $Xm#hi,$Xl#lo @ Xm is rotated Xl + vmov $Ym#hi,$Yl#lo + veor $Xl,$Xm,$t2 + veor $Yl,$Ym,$t3 + + vext.8 $t2,$Xl,$Xl,#8 @ 2nd phase + vext.8 $t3,$Yl,$Yl,#8 + vpmull.p64 $Xl,$Xl,$xC2 + vpmull.p64 $Yl,$Yl,$xC2 + veor $t2,$t2,$Xh + veor $t3,$t3,$Yh + veor $H, $Xl,$t2 @ H^3 + veor $H2,$Yl,$t3 @ H^4 + + vext.8 $t0,$H, $H,#8 @ Karatsuba pre-processing + vext.8 $t1,$H2,$H2,#8 + veor $t0,$t0,$H + veor $t1,$t1,$H2 + vext.8 $Hhl,$t0,$t1,#8 @ pack Karatsuba pre-processed + vst1.64 {$H-$H2},[x0] @ store Htable[3..5] +___ +} +$code.=<<___; + ret +.size gcm_init_clmul,.-gcm_init_clmul +___ +################################################################################ +# void gcm_gmult_clmul(u64 Xi[2],const u128 Htable[16]); +# +# input: Xi - current hash value; +# Htable - table precomputed in gcm_init_clmul; +# output: Xi - next hash value Xi; +# +$code.=<<___; +.global gcm_gmult_clmul +.type gcm_gmult_clmul,%function +.align 4 +gcm_gmult_clmul: + AARCH64_VALID_CALL_TARGET + vld1.64 {$t1},[$Xi] @ load Xi + vmov.i8 $xC2,#0xe1 + vld1.64 {$H-$Hhl},[$Htbl] @ load twisted H, ... + vshl.u64 $xC2,$xC2,#57 +#ifndef __ARMEB__ + vrev64.8 $t1,$t1 +#endif + vext.8 $IN,$t1,$t1,#8 + + vpmull.p64 $Xl,$H,$IN @ H.lo·Xi.lo + veor $t1,$t1,$IN @ Karatsuba pre-processing + vpmull2.p64 $Xh,$H,$IN @ H.hi·Xi.hi + vpmull.p64 $Xm,$Hhl,$t1 @ (H.lo+H.hi)·(Xi.lo+Xi.hi) + + vext.8 $t1,$Xl,$Xh,#8 @ Karatsuba post-processing + veor $t2,$Xl,$Xh + veor $Xm,$Xm,$t1 + veor $Xm,$Xm,$t2 + vpmull.p64 $t2,$Xl,$xC2 @ 1st phase of reduction + + vmov $Xh#lo,$Xm#hi @ Xh|Xm - 256-bit result + vmov $Xm#hi,$Xl#lo @ Xm is rotated Xl + veor $Xl,$Xm,$t2 + + vext.8 $t2,$Xl,$Xl,#8 @ 2nd phase of reduction + vpmull.p64 $Xl,$Xl,$xC2 + veor $t2,$t2,$Xh + veor $Xl,$Xl,$t2 + +#ifndef __ARMEB__ + vrev64.8 $Xl,$Xl +#endif + vext.8 $Xl,$Xl,$Xl,#8 + vst1.64 {$Xl},[$Xi] @ write out Xi + + ret +.size gcm_gmult_clmul,.-gcm_gmult_clmul +___ +} + +$code.=<<___; +.asciz "GHASH for ARMv8, CRYPTOGAMS by " +.align 2 +#endif +___ + +if ($flavour =~ /64/) { ######## 64-bit code + sub unvmov { + my $arg=shift; + + $arg =~ m/q([0-9]+)#(lo|hi),\s*q([0-9]+)#(lo|hi)/o && + sprintf "ins v%d.d[%d],v%d.d[%d]",$1<8?$1:$1+8,($2 eq "lo")?0:1, + $3<8?$3:$3+8,($4 eq "lo")?0:1; + } + foreach(split("\n",$code)) { + s/cclr\s+([wx])([^,]+),\s*([a-z]+)/csel $1$2,$1zr,$1$2,$3/o or + s/vmov\.i8/movi/o or # fix up legacy mnemonics + s/vmov\s+(.*)/unvmov($1)/geo or + s/vext\.8/ext/o or + s/vshr\.s/sshr\.s/o or + s/vshr/ushr/o or + s/^(\s+)v/$1/o or # strip off v prefix + s/\bbx\s+lr\b/ret/o; + + s/\bq([0-9]+)\b/"v".($1<8?$1:$1+8).".16b"/geo; # old->new registers + s/@\s/\/\//o; # old->new style commentary + + # fix up remaining legacy suffixes + s/\.[ui]?8(\s)/$1/o; + s/\.[uis]?32//o and s/\.16b/\.4s/go; + m/\.p64/o and s/\.16b/\.1q/o; # 1st pmull argument + m/l\.p64/o and s/\.16b/\.1d/go; # 2nd and 3rd pmull arguments + s/\.[uisp]?64//o and s/\.16b/\.2d/go; + s/\.[42]([sd])\[([0-3])\]/\.$1\[$2\]/o; + + # Switch preprocessor checks to aarch64 versions. + s/__ARME([BL])__/__AARCH64E$1__/go; + + print $_,"\n"; + } +} else { ######## 32-bit code + sub unvdup32 { + my $arg=shift; + + $arg =~ m/q([0-9]+),\s*q([0-9]+)\[([0-3])\]/o && + sprintf "vdup.32 q%d,d%d[%d]",$1,2*$2+($3>>1),$3&1; + } + sub unvpmullp64 { + my ($mnemonic,$arg)=@_; + + if ($arg =~ m/q([0-9]+),\s*q([0-9]+),\s*q([0-9]+)/o) { + my $word = 0xf2a00e00|(($1&7)<<13)|(($1&8)<<19) + |(($2&7)<<17)|(($2&8)<<4) + |(($3&7)<<1) |(($3&8)<<2); + $word |= 0x00010001 if ($mnemonic =~ "2"); + # since ARMv7 instructions are always encoded little-endian. + # correct solution is to use .inst directive, but older + # assemblers don't implement it:-( + sprintf ".byte\t0x%02x,0x%02x,0x%02x,0x%02x\t@ %s %s", + $word&0xff,($word>>8)&0xff, + ($word>>16)&0xff,($word>>24)&0xff, + $mnemonic,$arg; + } + } + + foreach(split("\n",$code)) { + s/\b[wx]([0-9]+)\b/r$1/go; # new->old registers + s/\bv([0-9])\.[12468]+[bsd]\b/q$1/go; # new->old registers + s/\/\/\s?/@ /o; # new->old style commentary + + # fix up remaining new-style suffixes + s/\],#[0-9]+/]!/o; + + s/cclr\s+([^,]+),\s*([a-z]+)/mov$2 $1,#0/o or + s/vdup\.32\s+(.*)/unvdup32($1)/geo or + s/v?(pmull2?)\.p64\s+(.*)/unvpmullp64($1,$2)/geo or + s/\bq([0-9]+)#(lo|hi)/sprintf "d%d",2*$1+($2 eq "hi")/geo or + s/^(\s+)b\./$1b/o or + s/^(\s+)ret/$1bx\tlr/o; + + print $_,"\n"; + } +} + +close STDOUT or die "error closing STDOUT: $!"; # enforce flush diff --git a/http/vendor/ring/crypto/fipsmodule/aes/asm/vpaes-armv7.pl b/http/vendor/ring/crypto/fipsmodule/aes/asm/vpaes-armv7.pl new file mode 100644 index 0000000..a46ad6c --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/aes/asm/vpaes-armv7.pl @@ -0,0 +1,884 @@ +#! /usr/bin/env perl +# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +###################################################################### +## Constant-time SSSE3 AES core implementation. +## version 0.1 +## +## By Mike Hamburg (Stanford University), 2009 +## Public domain. +## +## For details see http://shiftleft.org/papers/vector_aes/ and +## http://crypto.stanford.edu/vpaes/. +## +###################################################################### +# Adapted from the original x86_64 version and 's ARMv8 +# version. +# +# armv7, aarch64, and x86_64 differ in several ways: +# +# * x86_64 SSSE3 instructions are two-address (destination operand is also a +# source), while NEON is three-address (destination operand is separate from +# two sources). +# +# * aarch64 has 32 SIMD registers available, while x86_64 and armv7 have 16. +# +# * x86_64 instructions can take memory references, while ARM is a load/store +# architecture. This means we sometimes need a spare register. +# +# * aarch64 and x86_64 have 128-bit byte shuffle instructions (tbl and pshufb), +# while armv7 only has a 64-bit byte shuffle (vtbl). +# +# This means this armv7 version must be a mix of both aarch64 and x86_64 +# implementations. armv7 and aarch64 have analogous SIMD instructions, so we +# base the instructions on aarch64. However, we cannot use aarch64's register +# allocation. x86_64's register count matches, but x86_64 is two-address. +# vpaes-armv8.pl already accounts for this in the comments, which use +# three-address AVX instructions instead of the original SSSE3 ones. We base +# register usage on these comments, which are preserved in this file. +# +# This means we do not use separate input and output registers as in aarch64 and +# cannot pin as many constants in the preheat functions. However, the load/store +# architecture means we must still deviate from x86_64 in places. +# +# Next, we account for the byte shuffle instructions. vtbl takes 64-bit source +# and destination and 128-bit table. Fortunately, armv7 also allows addressing +# upper and lower halves of each 128-bit register. The lower half of q{N} is +# d{2*N}. The upper half is d{2*N+1}. Instead of the following non-existent +# instruction, +# +# vtbl.8 q0, q1, q2 @ Index each of q2's 16 bytes into q1. Store in q0. +# +# we write: +# +# vtbl.8 d0, q1, d4 @ Index each of d4's 8 bytes into q1. Store in d0. +# vtbl.8 d1, q1, d5 @ Index each of d5's 8 bytes into q1. Store in d1. +# +# For readability, we write d0 and d1 as q0#lo and q0#hi, respectively and +# post-process before outputting. (This is adapted from ghash-armv4.pl.) Note, +# however, that destination (q0) and table (q1) registers may no longer match. +# We adjust the register usage from x86_64 to avoid this. (Unfortunately, the +# two-address pshufb always matched these operands, so this is common.) +# +# This file also runs against the limit of ARMv7's ADR pseudo-instruction. ADR +# expands to an ADD or SUB of the pc register to find an address. That immediate +# must fit in ARM's encoding scheme: 8 bits of constant and 4 bits of rotation. +# This means larger values must be more aligned. +# +# ARM additionally has two encodings, ARM and Thumb mode. Our assembly files may +# use either encoding (do we actually need to support this?). In ARM mode, the +# distances get large enough to require 16-byte alignment. Moving constants +# closer to their use resolves most of this, but common constants in +# _vpaes_consts are used by the whole file. Affected ADR instructions must be +# placed at 8 mod 16 (the pc register is 8 ahead). Instructions with this +# constraint have been commented. +# +# For details on ARM's immediate value encoding scheme, see +# https://alisdair.mcdiarmid.org/arm-immediate-value-encoding/ +# +# Finally, a summary of armv7 and aarch64 SIMD syntax differences: +# +# * armv7 prefixes SIMD instructions with 'v', while aarch64 does not. +# +# * armv7 SIMD registers are named like q0 (and d0 for the half-width ones). +# aarch64 names registers like v0, and denotes half-width operations in an +# instruction suffix (see below). +# +# * aarch64 embeds size and lane information in register suffixes. v0.16b is +# 16 bytes, v0.8h is eight u16s, v0.4s is four u32s, and v0.2d is two u64s. +# armv7 embeds the total size in the register name (see above) and the size of +# each element in an instruction suffix, which may look like vmov.i8, +# vshr.u8, or vtbl.8, depending on instruction. + +use strict; + +my $flavour = shift; +my $output; +while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {} + +$0 =~ m/(.*[\/\\])[^\/\\]+$/; +my $dir=$1; +my $xlate; +( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or +( $xlate="${dir}../../../perlasm/arm-xlate.pl" and -f $xlate) or +die "can't locate arm-xlate.pl"; + +open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""; +*STDOUT=*OUT; + +my $code = ""; + +$code.=<<___; +.syntax unified + +.arch armv7-a +.fpu neon + +#if defined(__thumb2__) +.thumb +#else +.code 32 +#endif + +.text + +.type _vpaes_consts,%object +.align 7 @ totally strategic alignment +_vpaes_consts: +.Lk_mc_forward: @ mc_forward + .quad 0x0407060500030201, 0x0C0F0E0D080B0A09 + .quad 0x080B0A0904070605, 0x000302010C0F0E0D + .quad 0x0C0F0E0D080B0A09, 0x0407060500030201 + .quad 0x000302010C0F0E0D, 0x080B0A0904070605 +.Lk_mc_backward:@ mc_backward + .quad 0x0605040702010003, 0x0E0D0C0F0A09080B + .quad 0x020100030E0D0C0F, 0x0A09080B06050407 + .quad 0x0E0D0C0F0A09080B, 0x0605040702010003 + .quad 0x0A09080B06050407, 0x020100030E0D0C0F +.Lk_sr: @ sr + .quad 0x0706050403020100, 0x0F0E0D0C0B0A0908 + .quad 0x030E09040F0A0500, 0x0B06010C07020D08 + .quad 0x0F060D040B020900, 0x070E050C030A0108 + .quad 0x0B0E0104070A0D00, 0x0306090C0F020508 + +@ +@ "Hot" constants +@ +.Lk_inv: @ inv, inva + .quad 0x0E05060F0D080180, 0x040703090A0B0C02 + .quad 0x01040A060F0B0780, 0x030D0E0C02050809 +.Lk_ipt: @ input transform (lo, hi) + .quad 0xC2B2E8985A2A7000, 0xCABAE09052227808 + .quad 0x4C01307D317C4D00, 0xCD80B1FCB0FDCC81 +.Lk_sbo: @ sbou, sbot + .quad 0xD0D26D176FBDC700, 0x15AABF7AC502A878 + .quad 0xCFE474A55FBB6A00, 0x8E1E90D1412B35FA +.Lk_sb1: @ sb1u, sb1t + .quad 0x3618D415FAE22300, 0x3BF7CCC10D2ED9EF + .quad 0xB19BE18FCB503E00, 0xA5DF7A6E142AF544 +.Lk_sb2: @ sb2u, sb2t + .quad 0x69EB88400AE12900, 0xC2A163C8AB82234A + .quad 0xE27A93C60B712400, 0x5EB7E955BC982FCD + +.asciz "Vector Permutation AES for ARMv7 NEON, Mike Hamburg (Stanford University)" +.size _vpaes_consts,.-_vpaes_consts +.align 6 +___ + +{ +my ($inp,$out,$key) = map("r$_", (0..2)); + +my ($invlo,$invhi) = map("q$_", (10..11)); +my ($sb1u,$sb1t,$sb2u,$sb2t) = map("q$_", (12..15)); + +$code.=<<___; +@@ +@@ _aes_preheat +@@ +@@ Fills q9-q15 as specified below. +@@ +.type _vpaes_preheat,%function +.align 4 +_vpaes_preheat: + adr r10, .Lk_inv + vmov.i8 q9, #0x0f @ .Lk_s0F + vld1.64 {q10,q11}, [r10]! @ .Lk_inv + add r10, r10, #64 @ Skip .Lk_ipt, .Lk_sbo + vld1.64 {q12,q13}, [r10]! @ .Lk_sb1 + vld1.64 {q14,q15}, [r10] @ .Lk_sb2 + bx lr + +@@ +@@ _aes_encrypt_core +@@ +@@ AES-encrypt q0. +@@ +@@ Inputs: +@@ q0 = input +@@ q9-q15 as in _vpaes_preheat +@@ [$key] = scheduled keys +@@ +@@ Output in q0 +@@ Clobbers q1-q5, r8-r11 +@@ Preserves q6-q8 so you get some local vectors +@@ +@@ +.type _vpaes_encrypt_core,%function +.align 4 +_vpaes_encrypt_core: + mov r9, $key + ldr r8, [$key,#240] @ pull rounds + adr r11, .Lk_ipt + @ vmovdqa .Lk_ipt(%rip), %xmm2 # iptlo + @ vmovdqa .Lk_ipt+16(%rip), %xmm3 # ipthi + vld1.64 {q2, q3}, [r11] + adr r11, .Lk_mc_forward+16 + vld1.64 {q5}, [r9]! @ vmovdqu (%r9), %xmm5 # round0 key + vand q1, q0, q9 @ vpand %xmm9, %xmm0, %xmm1 + vshr.u8 q0, q0, #4 @ vpsrlb \$4, %xmm0, %xmm0 + vtbl.8 q1#lo, {q2}, q1#lo @ vpshufb %xmm1, %xmm2, %xmm1 + vtbl.8 q1#hi, {q2}, q1#hi + vtbl.8 q2#lo, {q3}, q0#lo @ vpshufb %xmm0, %xmm3, %xmm2 + vtbl.8 q2#hi, {q3}, q0#hi + veor q0, q1, q5 @ vpxor %xmm5, %xmm1, %xmm0 + veor q0, q0, q2 @ vpxor %xmm2, %xmm0, %xmm0 + + @ .Lenc_entry ends with a bnz instruction which is normally paired with + @ subs in .Lenc_loop. + tst r8, r8 + b .Lenc_entry + +.align 4 +.Lenc_loop: + @ middle of middle round + add r10, r11, #0x40 + vtbl.8 q4#lo, {$sb1t}, q2#lo @ vpshufb %xmm2, %xmm13, %xmm4 # 4 = sb1u + vtbl.8 q4#hi, {$sb1t}, q2#hi + vld1.64 {q1}, [r11]! @ vmovdqa -0x40(%r11,%r10), %xmm1 # .Lk_mc_forward[] + vtbl.8 q0#lo, {$sb1u}, q3#lo @ vpshufb %xmm3, %xmm12, %xmm0 # 0 = sb1t + vtbl.8 q0#hi, {$sb1u}, q3#hi + veor q4, q4, q5 @ vpxor %xmm5, %xmm4, %xmm4 # 4 = sb1u + k + vtbl.8 q5#lo, {$sb2t}, q2#lo @ vpshufb %xmm2, %xmm15, %xmm5 # 4 = sb2u + vtbl.8 q5#hi, {$sb2t}, q2#hi + veor q0, q0, q4 @ vpxor %xmm4, %xmm0, %xmm0 # 0 = A + vtbl.8 q2#lo, {$sb2u}, q3#lo @ vpshufb %xmm3, %xmm14, %xmm2 # 2 = sb2t + vtbl.8 q2#hi, {$sb2u}, q3#hi + vld1.64 {q4}, [r10] @ vmovdqa (%r11,%r10), %xmm4 # .Lk_mc_backward[] + vtbl.8 q3#lo, {q0}, q1#lo @ vpshufb %xmm1, %xmm0, %xmm3 # 0 = B + vtbl.8 q3#hi, {q0}, q1#hi + veor q2, q2, q5 @ vpxor %xmm5, %xmm2, %xmm2 # 2 = 2A + @ Write to q5 instead of q0, so the table and destination registers do + @ not overlap. + vtbl.8 q5#lo, {q0}, q4#lo @ vpshufb %xmm4, %xmm0, %xmm0 # 3 = D + vtbl.8 q5#hi, {q0}, q4#hi + veor q3, q3, q2 @ vpxor %xmm2, %xmm3, %xmm3 # 0 = 2A+B + vtbl.8 q4#lo, {q3}, q1#lo @ vpshufb %xmm1, %xmm3, %xmm4 # 0 = 2B+C + vtbl.8 q4#hi, {q3}, q1#hi + @ Here we restore the original q0/q5 usage. + veor q0, q5, q3 @ vpxor %xmm3, %xmm0, %xmm0 # 3 = 2A+B+D + and r11, r11, #~(1<<6) @ and \$0x30, %r11 # ... mod 4 + veor q0, q0, q4 @ vpxor %xmm4, %xmm0, %xmm0 # 0 = 2A+3B+C+D + subs r8, r8, #1 @ nr-- + +.Lenc_entry: + @ top of round + vand q1, q0, q9 @ vpand %xmm0, %xmm9, %xmm1 # 0 = k + vshr.u8 q0, q0, #4 @ vpsrlb \$4, %xmm0, %xmm0 # 1 = i + vtbl.8 q5#lo, {$invhi}, q1#lo @ vpshufb %xmm1, %xmm11, %xmm5 # 2 = a/k + vtbl.8 q5#hi, {$invhi}, q1#hi + veor q1, q1, q0 @ vpxor %xmm0, %xmm1, %xmm1 # 0 = j + vtbl.8 q3#lo, {$invlo}, q0#lo @ vpshufb %xmm0, %xmm10, %xmm3 # 3 = 1/i + vtbl.8 q3#hi, {$invlo}, q0#hi + vtbl.8 q4#lo, {$invlo}, q1#lo @ vpshufb %xmm1, %xmm10, %xmm4 # 4 = 1/j + vtbl.8 q4#hi, {$invlo}, q1#hi + veor q3, q3, q5 @ vpxor %xmm5, %xmm3, %xmm3 # 3 = iak = 1/i + a/k + veor q4, q4, q5 @ vpxor %xmm5, %xmm4, %xmm4 # 4 = jak = 1/j + a/k + vtbl.8 q2#lo, {$invlo}, q3#lo @ vpshufb %xmm3, %xmm10, %xmm2 # 2 = 1/iak + vtbl.8 q2#hi, {$invlo}, q3#hi + vtbl.8 q3#lo, {$invlo}, q4#lo @ vpshufb %xmm4, %xmm10, %xmm3 # 3 = 1/jak + vtbl.8 q3#hi, {$invlo}, q4#hi + veor q2, q2, q1 @ vpxor %xmm1, %xmm2, %xmm2 # 2 = io + veor q3, q3, q0 @ vpxor %xmm0, %xmm3, %xmm3 # 3 = jo + vld1.64 {q5}, [r9]! @ vmovdqu (%r9), %xmm5 + bne .Lenc_loop + + @ middle of last round + add r10, r11, #0x80 + + adr r11, .Lk_sbo + @ Read to q1 instead of q4, so the vtbl.8 instruction below does not + @ overlap table and destination registers. + vld1.64 {q1}, [r11]! @ vmovdqa -0x60(%r10), %xmm4 # 3 : sbou + vld1.64 {q0}, [r11] @ vmovdqa -0x50(%r10), %xmm0 # 0 : sbot .Lk_sbo+16 + vtbl.8 q4#lo, {q1}, q2#lo @ vpshufb %xmm2, %xmm4, %xmm4 # 4 = sbou + vtbl.8 q4#hi, {q1}, q2#hi + vld1.64 {q1}, [r10] @ vmovdqa 0x40(%r11,%r10), %xmm1 # .Lk_sr[] + @ Write to q2 instead of q0 below, to avoid overlapping table and + @ destination registers. + vtbl.8 q2#lo, {q0}, q3#lo @ vpshufb %xmm3, %xmm0, %xmm0 # 0 = sb1t + vtbl.8 q2#hi, {q0}, q3#hi + veor q4, q4, q5 @ vpxor %xmm5, %xmm4, %xmm4 # 4 = sb1u + k + veor q2, q2, q4 @ vpxor %xmm4, %xmm0, %xmm0 # 0 = A + @ Here we restore the original q0/q2 usage. + vtbl.8 q0#lo, {q2}, q1#lo @ vpshufb %xmm1, %xmm0, %xmm0 + vtbl.8 q0#hi, {q2}, q1#hi + bx lr +.size _vpaes_encrypt_core,.-_vpaes_encrypt_core +___ +} +{ +my ($inp,$bits,$out,$dir)=("r0","r1","r2","r3"); +my ($rcon,$s0F,$invlo,$invhi,$s63) = map("q$_",(8..12)); + +$code.=<<___; +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +@@ @@ +@@ AES key schedule @@ +@@ @@ +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + +@ This function diverges from both x86_64 and armv7 in which constants are +@ pinned. x86_64 has a common preheat function for all operations. aarch64 +@ separates them because it has enough registers to pin nearly all constants. +@ armv7 does not have enough registers, but needing explicit loads and stores +@ also complicates using x86_64's register allocation directly. +@ +@ We pin some constants for convenience and leave q14 and q15 free to load +@ others on demand. + +@ +@ Key schedule constants +@ +.type _vpaes_key_consts,%object +.align 4 +_vpaes_key_consts: +.Lk_rcon: @ rcon + .quad 0x1F8391B9AF9DEEB6, 0x702A98084D7C7D81 + +.Lk_opt: @ output transform + .quad 0xFF9F4929D6B66000, 0xF7974121DEBE6808 + .quad 0x01EDBD5150BCEC00, 0xE10D5DB1B05C0CE0 +.Lk_deskew: @ deskew tables: inverts the sbox's "skew" + .quad 0x07E4A34047A4E300, 0x1DFEB95A5DBEF91A + .quad 0x5F36B5DC83EA6900, 0x2841C2ABF49D1E77 +.size _vpaes_key_consts,.-_vpaes_key_consts + +.type _vpaes_key_preheat,%function +.align 4 +_vpaes_key_preheat: + adr r11, .Lk_rcon + vmov.i8 $s63, #0x5b @ .Lk_s63 + adr r10, .Lk_inv @ Must be aligned to 8 mod 16. + vmov.i8 $s0F, #0x0f @ .Lk_s0F + vld1.64 {$invlo,$invhi}, [r10] @ .Lk_inv + vld1.64 {$rcon}, [r11] @ .Lk_rcon + bx lr +.size _vpaes_key_preheat,.-_vpaes_key_preheat + +.type _vpaes_schedule_core,%function +.align 4 +_vpaes_schedule_core: + @ We only need to save lr, but ARM requires an 8-byte stack alignment, + @ so save an extra register. + stmdb sp!, {r3,lr} + + bl _vpaes_key_preheat @ load the tables + + adr r11, .Lk_ipt @ Must be aligned to 8 mod 16. + vld1.64 {q0}, [$inp]! @ vmovdqu (%rdi), %xmm0 # load key (unaligned) + + @ input transform + @ Use q4 here rather than q3 so .Lschedule_am_decrypting does not + @ overlap table and destination. + vmov q4, q0 @ vmovdqa %xmm0, %xmm3 + bl _vpaes_schedule_transform + adr r10, .Lk_sr @ Must be aligned to 8 mod 16. + vmov q7, q0 @ vmovdqa %xmm0, %xmm7 + + add r8, r8, r10 + + @ encrypting, output zeroth round key after transform + vst1.64 {q0}, [$out] @ vmovdqu %xmm0, (%rdx) + + @ *ring*: Decryption removed. + +.Lschedule_go: + cmp $bits, #192 @ cmp \$192, %esi + bhi .Lschedule_256 + @ 128: fall though + +@@ +@@ .schedule_128 +@@ +@@ 128-bit specific part of key schedule. +@@ +@@ This schedule is really simple, because all its parts +@@ are accomplished by the subroutines. +@@ +.Lschedule_128: + mov $inp, #10 @ mov \$10, %esi + +.Loop_schedule_128: + bl _vpaes_schedule_round + subs $inp, $inp, #1 @ dec %esi + beq .Lschedule_mangle_last + bl _vpaes_schedule_mangle @ write output + b .Loop_schedule_128 + +@@ +@@ .aes_schedule_256 +@@ +@@ 256-bit specific part of key schedule. +@@ +@@ The structure here is very similar to the 128-bit +@@ schedule, but with an additional "low side" in +@@ q6. The low side's rounds are the same as the +@@ high side's, except no rcon and no rotation. +@@ +.align 4 +.Lschedule_256: + vld1.64 {q0}, [$inp] @ vmovdqu 16(%rdi),%xmm0 # load key part 2 (unaligned) + bl _vpaes_schedule_transform @ input transform + mov $inp, #7 @ mov \$7, %esi + +.Loop_schedule_256: + bl _vpaes_schedule_mangle @ output low result + vmov q6, q0 @ vmovdqa %xmm0, %xmm6 # save cur_lo in xmm6 + + @ high round + bl _vpaes_schedule_round + subs $inp, $inp, #1 @ dec %esi + beq .Lschedule_mangle_last + bl _vpaes_schedule_mangle + + @ low round. swap xmm7 and xmm6 + vdup.32 q0, q0#hi[1] @ vpshufd \$0xFF, %xmm0, %xmm0 + vmov.i8 q4, #0 + vmov q5, q7 @ vmovdqa %xmm7, %xmm5 + vmov q7, q6 @ vmovdqa %xmm6, %xmm7 + bl _vpaes_schedule_low_round + vmov q7, q5 @ vmovdqa %xmm5, %xmm7 + + b .Loop_schedule_256 + +@@ +@@ .aes_schedule_mangle_last +@@ +@@ Mangler for last round of key schedule +@@ Mangles q0 +@@ when encrypting, outputs out(q0) ^ 63 +@@ when decrypting, outputs unskew(q0) +@@ +@@ Always called right before return... jumps to cleanup and exits +@@ +.align 4 +.Lschedule_mangle_last: + @ schedule last round key from xmm0 + adr r11, .Lk_deskew @ lea .Lk_deskew(%rip),%r11 # prepare to deskew + + @ encrypting + vld1.64 {q1}, [r8] @ vmovdqa (%r8,%r10),%xmm1 + adr r11, .Lk_opt @ lea .Lk_opt(%rip), %r11 # prepare to output transform + add $out, $out, #32 @ add \$32, %rdx + vmov q2, q0 + vtbl.8 q0#lo, {q2}, q1#lo @ vpshufb %xmm1, %xmm0, %xmm0 # output permute + vtbl.8 q0#hi, {q2}, q1#hi + +.Lschedule_mangle_last_dec: + sub $out, $out, #16 @ add \$-16, %rdx + veor q0, q0, $s63 @ vpxor .Lk_s63(%rip), %xmm0, %xmm0 + bl _vpaes_schedule_transform @ output transform + vst1.64 {q0}, [$out] @ vmovdqu %xmm0, (%rdx) # save last key + + @ cleanup + veor q0, q0, q0 @ vpxor %xmm0, %xmm0, %xmm0 + veor q1, q1, q1 @ vpxor %xmm1, %xmm1, %xmm1 + veor q2, q2, q2 @ vpxor %xmm2, %xmm2, %xmm2 + veor q3, q3, q3 @ vpxor %xmm3, %xmm3, %xmm3 + veor q4, q4, q4 @ vpxor %xmm4, %xmm4, %xmm4 + veor q5, q5, q5 @ vpxor %xmm5, %xmm5, %xmm5 + veor q6, q6, q6 @ vpxor %xmm6, %xmm6, %xmm6 + veor q7, q7, q7 @ vpxor %xmm7, %xmm7, %xmm7 + ldmia sp!, {r3,pc} @ return +.size _vpaes_schedule_core,.-_vpaes_schedule_core + +@@ +@@ .aes_schedule_round +@@ +@@ Runs one main round of the key schedule on q0, q7 +@@ +@@ Specifically, runs subbytes on the high dword of q0 +@@ then rotates it by one byte and xors into the low dword of +@@ q7. +@@ +@@ Adds rcon from low byte of q8, then rotates q8 for +@@ next rcon. +@@ +@@ Smears the dwords of q7 by xoring the low into the +@@ second low, result into third, result into highest. +@@ +@@ Returns results in q7 = q0. +@@ Clobbers q1-q4, r11. +@@ +.type _vpaes_schedule_round,%function +.align 4 +_vpaes_schedule_round: + @ extract rcon from xmm8 + vmov.i8 q4, #0 @ vpxor %xmm4, %xmm4, %xmm4 + vext.8 q1, $rcon, q4, #15 @ vpalignr \$15, %xmm8, %xmm4, %xmm1 + vext.8 $rcon, $rcon, $rcon, #15 @ vpalignr \$15, %xmm8, %xmm8, %xmm8 + veor q7, q7, q1 @ vpxor %xmm1, %xmm7, %xmm7 + + @ rotate + vdup.32 q0, q0#hi[1] @ vpshufd \$0xFF, %xmm0, %xmm0 + vext.8 q0, q0, q0, #1 @ vpalignr \$1, %xmm0, %xmm0, %xmm0 + + @ fall through... + + @ low round: same as high round, but no rotation and no rcon. +_vpaes_schedule_low_round: + @ The x86_64 version pins .Lk_sb1 in %xmm13 and .Lk_sb1+16 in %xmm12. + @ We pin other values in _vpaes_key_preheat, so load them now. + adr r11, .Lk_sb1 + vld1.64 {q14,q15}, [r11] + + @ smear xmm7 + vext.8 q1, q4, q7, #12 @ vpslldq \$4, %xmm7, %xmm1 + veor q7, q7, q1 @ vpxor %xmm1, %xmm7, %xmm7 + vext.8 q4, q4, q7, #8 @ vpslldq \$8, %xmm7, %xmm4 + + @ subbytes + vand q1, q0, $s0F @ vpand %xmm9, %xmm0, %xmm1 # 0 = k + vshr.u8 q0, q0, #4 @ vpsrlb \$4, %xmm0, %xmm0 # 1 = i + veor q7, q7, q4 @ vpxor %xmm4, %xmm7, %xmm7 + vtbl.8 q2#lo, {$invhi}, q1#lo @ vpshufb %xmm1, %xmm11, %xmm2 # 2 = a/k + vtbl.8 q2#hi, {$invhi}, q1#hi + veor q1, q1, q0 @ vpxor %xmm0, %xmm1, %xmm1 # 0 = j + vtbl.8 q3#lo, {$invlo}, q0#lo @ vpshufb %xmm0, %xmm10, %xmm3 # 3 = 1/i + vtbl.8 q3#hi, {$invlo}, q0#hi + veor q3, q3, q2 @ vpxor %xmm2, %xmm3, %xmm3 # 3 = iak = 1/i + a/k + vtbl.8 q4#lo, {$invlo}, q1#lo @ vpshufb %xmm1, %xmm10, %xmm4 # 4 = 1/j + vtbl.8 q4#hi, {$invlo}, q1#hi + veor q7, q7, $s63 @ vpxor .Lk_s63(%rip), %xmm7, %xmm7 + vtbl.8 q3#lo, {$invlo}, q3#lo @ vpshufb %xmm3, %xmm10, %xmm3 # 2 = 1/iak + vtbl.8 q3#hi, {$invlo}, q3#hi + veor q4, q4, q2 @ vpxor %xmm2, %xmm4, %xmm4 # 4 = jak = 1/j + a/k + vtbl.8 q2#lo, {$invlo}, q4#lo @ vpshufb %xmm4, %xmm10, %xmm2 # 3 = 1/jak + vtbl.8 q2#hi, {$invlo}, q4#hi + veor q3, q3, q1 @ vpxor %xmm1, %xmm3, %xmm3 # 2 = io + veor q2, q2, q0 @ vpxor %xmm0, %xmm2, %xmm2 # 3 = jo + vtbl.8 q4#lo, {q15}, q3#lo @ vpshufb %xmm3, %xmm13, %xmm4 # 4 = sbou + vtbl.8 q4#hi, {q15}, q3#hi + vtbl.8 q1#lo, {q14}, q2#lo @ vpshufb %xmm2, %xmm12, %xmm1 # 0 = sb1t + vtbl.8 q1#hi, {q14}, q2#hi + veor q1, q1, q4 @ vpxor %xmm4, %xmm1, %xmm1 # 0 = sbox output + + @ add in smeared stuff + veor q0, q1, q7 @ vpxor %xmm7, %xmm1, %xmm0 + veor q7, q1, q7 @ vmovdqa %xmm0, %xmm7 + bx lr +.size _vpaes_schedule_round,.-_vpaes_schedule_round + +@@ +@@ .aes_schedule_transform +@@ +@@ Linear-transform q0 according to tables at [r11] +@@ +@@ Requires that q9 = 0x0F0F... as in preheat +@@ Output in q0 +@@ Clobbers q1, q2, q14, q15 +@@ +.type _vpaes_schedule_transform,%function +.align 4 +_vpaes_schedule_transform: + vld1.64 {q14,q15}, [r11] @ vmovdqa (%r11), %xmm2 # lo + @ vmovdqa 16(%r11), %xmm1 # hi + vand q1, q0, $s0F @ vpand %xmm9, %xmm0, %xmm1 + vshr.u8 q0, q0, #4 @ vpsrlb \$4, %xmm0, %xmm0 + vtbl.8 q2#lo, {q14}, q1#lo @ vpshufb %xmm1, %xmm2, %xmm2 + vtbl.8 q2#hi, {q14}, q1#hi + vtbl.8 q0#lo, {q15}, q0#lo @ vpshufb %xmm0, %xmm1, %xmm0 + vtbl.8 q0#hi, {q15}, q0#hi + veor q0, q0, q2 @ vpxor %xmm2, %xmm0, %xmm0 + bx lr +.size _vpaes_schedule_transform,.-_vpaes_schedule_transform + +@@ +@@ .aes_schedule_mangle +@@ +@@ Mangles q0 from (basis-transformed) standard version +@@ to our version. +@@ +@@ On encrypt, +@@ xor with 0x63 +@@ multiply by circulant 0,1,1,1 +@@ apply shiftrows transform +@@ +@@ On decrypt, +@@ xor with 0x63 +@@ multiply by "inverse mixcolumns" circulant E,B,D,9 +@@ deskew +@@ apply shiftrows transform +@@ +@@ +@@ Writes out to [r2], and increments or decrements it +@@ Keeps track of round number mod 4 in r8 +@@ Preserves q0 +@@ Clobbers q1-q5 +@@ +.type _vpaes_schedule_mangle,%function +.align 4 +_vpaes_schedule_mangle: + tst $dir, $dir + vmov q4, q0 @ vmovdqa %xmm0, %xmm4 # save xmm0 for later + adr r11, .Lk_mc_forward @ Must be aligned to 8 mod 16. + vld1.64 {q5}, [r11] @ vmovdqa .Lk_mc_forward(%rip),%xmm5 + + @ encrypting + @ Write to q2 so we do not overlap table and destination below. + veor q2, q0, $s63 @ vpxor .Lk_s63(%rip), %xmm0, %xmm4 + add $out, $out, #16 @ add \$16, %rdx + vtbl.8 q4#lo, {q2}, q5#lo @ vpshufb %xmm5, %xmm4, %xmm4 + vtbl.8 q4#hi, {q2}, q5#hi + vtbl.8 q1#lo, {q4}, q5#lo @ vpshufb %xmm5, %xmm4, %xmm1 + vtbl.8 q1#hi, {q4}, q5#hi + vtbl.8 q3#lo, {q1}, q5#lo @ vpshufb %xmm5, %xmm1, %xmm3 + vtbl.8 q3#hi, {q1}, q5#hi + veor q4, q4, q1 @ vpxor %xmm1, %xmm4, %xmm4 + vld1.64 {q1}, [r8] @ vmovdqa (%r8,%r10), %xmm1 + veor q3, q3, q4 @ vpxor %xmm4, %xmm3, %xmm3 + +.Lschedule_mangle_both: + @ Write to q2 so table and destination do not overlap. + vtbl.8 q2#lo, {q3}, q1#lo @ vpshufb %xmm1, %xmm3, %xmm3 + vtbl.8 q2#hi, {q3}, q1#hi + add r8, r8, #64-16 @ add \$-16, %r8 + and r8, r8, #~(1<<6) @ and \$0x30, %r8 + vst1.64 {q2}, [$out] @ vmovdqu %xmm3, (%rdx) + bx lr +.size _vpaes_schedule_mangle,.-_vpaes_schedule_mangle + +.globl vpaes_set_encrypt_key +.type vpaes_set_encrypt_key,%function +.align 4 +vpaes_set_encrypt_key: + stmdb sp!, {r7-r11, lr} + vstmdb sp!, {d8-d15} + + lsr r9, $bits, #5 @ shr \$5,%eax + add r9, r9, #5 @ \$5,%eax + str r9, [$out,#240] @ mov %eax,240(%rdx) # AES_KEY->rounds = nbits/32+5; + + mov $dir, #0 @ mov \$0,%ecx + mov r8, #0x30 @ mov \$0x30,%r8d + bl _vpaes_schedule_core + eor r0, r0, r0 + + vldmia sp!, {d8-d15} + ldmia sp!, {r7-r11, pc} @ return +.size vpaes_set_encrypt_key,.-vpaes_set_encrypt_key +___ +} + +{ +my ($out, $inp) = map("r$_", (0..1)); +my ($s0F, $s63, $s63_raw, $mc_forward) = map("q$_", (9..12)); + +$code .= <<___; + +@ Additional constants for converting to bsaes. +.type _vpaes_convert_consts,%object +.align 4 +_vpaes_convert_consts: +@ .Lk_opt_then_skew applies skew(opt(x)) XOR 0x63, where skew is the linear +@ transform in the AES S-box. 0x63 is incorporated into the low half of the +@ table. This was computed with the following script: +@ +@ def u64s_to_u128(x, y): +@ return x | (y << 64) +@ def u128_to_u64s(w): +@ return w & ((1<<64)-1), w >> 64 +@ def get_byte(w, i): +@ return (w >> (i*8)) & 0xff +@ def apply_table(table, b): +@ lo = b & 0xf +@ hi = b >> 4 +@ return get_byte(table[0], lo) ^ get_byte(table[1], hi) +@ def opt(b): +@ table = [ +@ u64s_to_u128(0xFF9F4929D6B66000, 0xF7974121DEBE6808), +@ u64s_to_u128(0x01EDBD5150BCEC00, 0xE10D5DB1B05C0CE0), +@ ] +@ return apply_table(table, b) +@ def rot_byte(b, n): +@ return 0xff & ((b << n) | (b >> (8-n))) +@ def skew(x): +@ return (x ^ rot_byte(x, 1) ^ rot_byte(x, 2) ^ rot_byte(x, 3) ^ +@ rot_byte(x, 4)) +@ table = [0, 0] +@ for i in range(16): +@ table[0] |= (skew(opt(i)) ^ 0x63) << (i*8) +@ table[1] |= skew(opt(i<<4)) << (i*8) +@ print("\t.quad\t0x%016x, 0x%016x" % u128_to_u64s(table[0])) +@ print("\t.quad\t0x%016x, 0x%016x" % u128_to_u64s(table[1])) +.Lk_opt_then_skew: + .quad 0x9cb8436798bc4763, 0x6440bb9f6044bf9b + .quad 0x1f30062936192f00, 0xb49bad829db284ab + +@ void vpaes_encrypt_key_to_bsaes(AES_KEY *bsaes, const AES_KEY *vpaes); +.globl vpaes_encrypt_key_to_bsaes +.type vpaes_encrypt_key_to_bsaes,%function +.align 4 +vpaes_encrypt_key_to_bsaes: + stmdb sp!, {r11, lr} + + @ See _vpaes_schedule_core for the key schedule logic. In particular, + @ _vpaes_schedule_transform(.Lk_ipt) (section 2.2 of the paper), + @ _vpaes_schedule_mangle (section 4.3), and .Lschedule_mangle_last + @ contain the transformations not in the bsaes representation. This + @ function inverts those transforms. + @ + @ Note also that bsaes-armv7.pl expects aes-armv4.pl's key + @ representation, which does not match the other aes_nohw_* + @ implementations. The ARM aes_nohw_* stores each 32-bit word + @ byteswapped, as a convenience for (unsupported) big-endian ARM, at the + @ cost of extra REV and VREV32 operations in little-endian ARM. + + vmov.i8 $s0F, #0x0f @ Required by _vpaes_schedule_transform + adr r2, .Lk_mc_forward @ Must be aligned to 8 mod 16. + add r3, r2, 0x90 @ .Lk_sr+0x10-.Lk_mc_forward = 0x90 (Apple's toolchain doesn't support the expression) + + vld1.64 {$mc_forward}, [r2] + vmov.i8 $s63, #0x5b @ .Lk_s63 from vpaes-x86_64 + adr r11, .Lk_opt @ Must be aligned to 8 mod 16. + vmov.i8 $s63_raw, #0x63 @ .LK_s63 without .Lk_ipt applied + + @ vpaes stores one fewer round count than bsaes, but the number of keys + @ is the same. + ldr r2, [$inp,#240] + add r2, r2, #1 + str r2, [$out,#240] + + @ The first key is transformed with _vpaes_schedule_transform(.Lk_ipt). + @ Invert this with .Lk_opt. + vld1.64 {q0}, [$inp]! + bl _vpaes_schedule_transform + vrev32.8 q0, q0 + vst1.64 {q0}, [$out]! + + @ The middle keys have _vpaes_schedule_transform(.Lk_ipt) applied, + @ followed by _vpaes_schedule_mangle. _vpaes_schedule_mangle XORs 0x63, + @ multiplies by the circulant 0,1,1,1, then applies ShiftRows. +.Loop_enc_key_to_bsaes: + vld1.64 {q0}, [$inp]! + + @ Invert the ShiftRows step (see .Lschedule_mangle_both). Note we cycle + @ r3 in the opposite direction and start at .Lk_sr+0x10 instead of 0x30. + @ We use r3 rather than r8 to avoid a callee-saved register. + vld1.64 {q1}, [r3] + vtbl.8 q2#lo, {q0}, q1#lo + vtbl.8 q2#hi, {q0}, q1#hi + add r3, r3, #16 + and r3, r3, #~(1<<6) + vmov q0, q2 + + @ Handle the last key differently. + subs r2, r2, #1 + beq .Loop_enc_key_to_bsaes_last + + @ Multiply by the circulant. This is its own inverse. + vtbl.8 q1#lo, {q0}, $mc_forward#lo + vtbl.8 q1#hi, {q0}, $mc_forward#hi + vmov q0, q1 + vtbl.8 q2#lo, {q1}, $mc_forward#lo + vtbl.8 q2#hi, {q1}, $mc_forward#hi + veor q0, q0, q2 + vtbl.8 q1#lo, {q2}, $mc_forward#lo + vtbl.8 q1#hi, {q2}, $mc_forward#hi + veor q0, q0, q1 + + @ XOR and finish. + veor q0, q0, $s63 + bl _vpaes_schedule_transform + vrev32.8 q0, q0 + vst1.64 {q0}, [$out]! + b .Loop_enc_key_to_bsaes + +.Loop_enc_key_to_bsaes_last: + @ The final key does not have a basis transform (note + @ .Lschedule_mangle_last inverts the original transform). It only XORs + @ 0x63 and applies ShiftRows. The latter was already inverted in the + @ loop. Note that, because we act on the original representation, we use + @ $s63_raw, not $s63. + veor q0, q0, $s63_raw + vrev32.8 q0, q0 + vst1.64 {q0}, [$out] + + @ Wipe registers which contained key material. + veor q0, q0, q0 + veor q1, q1, q1 + veor q2, q2, q2 + + ldmia sp!, {r11, pc} @ return +.size vpaes_encrypt_key_to_bsaes,.-vpaes_encrypt_key_to_bsaes +___ +} + +{ +# Register-passed parameters. +my ($inp, $out, $len, $key) = map("r$_", 0..3); +# Temporaries. _vpaes_encrypt_core already uses r8..r11, so overlap $ivec and +# $tmp. $ctr is r7 because it must be preserved across calls. +my ($ctr, $ivec, $tmp) = map("r$_", 7..9); + +# void vpaes_ctr32_encrypt_blocks(const uint8_t *in, uint8_t *out, size_t len, +# const AES_KEY *key, const uint8_t ivec[16]); +$code .= <<___; +.globl vpaes_ctr32_encrypt_blocks +.type vpaes_ctr32_encrypt_blocks,%function +.align 4 +vpaes_ctr32_encrypt_blocks: + mov ip, sp + stmdb sp!, {r7-r11, lr} + @ This function uses q4-q7 (d8-d15), which are callee-saved. + vstmdb sp!, {d8-d15} + + cmp $len, #0 + @ $ivec is passed on the stack. + ldr $ivec, [ip] + beq .Lctr32_done + + @ _vpaes_encrypt_core expects the key in r2, so swap $len and $key. + mov $tmp, $key + mov $key, $len + mov $len, $tmp +___ +my ($len, $key) = ($key, $len); +$code .= <<___; + + @ Load the IV and counter portion. + ldr $ctr, [$ivec, #12] + vld1.8 {q7}, [$ivec] + + bl _vpaes_preheat + rev $ctr, $ctr @ The counter is big-endian. + +.Lctr32_loop: + vmov q0, q7 + vld1.8 {q6}, [$inp]! @ Load input ahead of time + bl _vpaes_encrypt_core + veor q0, q0, q6 @ XOR input and result + vst1.8 {q0}, [$out]! + subs $len, $len, #1 + @ Update the counter. + add $ctr, $ctr, #1 + rev $tmp, $ctr + vmov.32 q7#hi[1], $tmp + bne .Lctr32_loop + +.Lctr32_done: + vldmia sp!, {d8-d15} + ldmia sp!, {r7-r11, pc} @ return +.size vpaes_ctr32_encrypt_blocks,.-vpaes_ctr32_encrypt_blocks +___ +} + +foreach (split("\n",$code)) { + s/\bq([0-9]+)#(lo|hi)/sprintf "d%d",2*$1+($2 eq "hi")/geo; + print $_,"\n"; +} + +close STDOUT or die "error closing STDOUT: $!"; diff --git a/http/vendor/ring/crypto/fipsmodule/aes/asm/vpaes-armv8.pl b/http/vendor/ring/crypto/fipsmodule/aes/asm/vpaes-armv8.pl new file mode 100644 index 0000000..d5e4bce --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/aes/asm/vpaes-armv8.pl @@ -0,0 +1,824 @@ +#! /usr/bin/env perl +# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +###################################################################### +## Constant-time SSSE3 AES core implementation. +## version 0.1 +## +## By Mike Hamburg (Stanford University), 2009 +## Public domain. +## +## For details see http://shiftleft.org/papers/vector_aes/ and +## http://crypto.stanford.edu/vpaes/. +## +###################################################################### +# ARMv8 NEON adaptation by +# +# Reason for undertaken effort is that there is at least one popular +# SoC based on Cortex-A53 that doesn't have crypto extensions. +# +# CBC enc ECB enc/dec(*) [bit-sliced enc/dec] +# Cortex-A53 21.5 18.1/20.6 [17.5/19.8 ] +# Cortex-A57 36.0(**) 20.4/24.9(**) [14.4/16.6 ] +# X-Gene 45.9(**) 45.8/57.7(**) [33.1/37.6(**) ] +# Denver(***) 16.6(**) 15.1/17.8(**) [8.80/9.93 ] +# Apple A7(***) 22.7(**) 10.9/14.3 [8.45/10.0 ] +# Mongoose(***) 26.3(**) 21.0/25.0(**) [13.3/16.8 ] +# +# (*) ECB denotes approximate result for parallelizable modes +# such as CBC decrypt, CTR, etc.; +# (**) these results are worse than scalar compiler-generated +# code, but it's constant-time and therefore preferred; +# (***) presented for reference/comparison purposes; + +$flavour = shift; +while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {} + +$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; +( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or +( $xlate="${dir}../../../perlasm/arm-xlate.pl" and -f $xlate) or +die "can't locate arm-xlate.pl"; + +open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""; +*STDOUT=*OUT; + +$code.=<<___; +.section .rodata + +.type _vpaes_consts,%object +.align 7 // totally strategic alignment +_vpaes_consts: +.Lk_mc_forward: // mc_forward + .quad 0x0407060500030201, 0x0C0F0E0D080B0A09 + .quad 0x080B0A0904070605, 0x000302010C0F0E0D + .quad 0x0C0F0E0D080B0A09, 0x0407060500030201 + .quad 0x000302010C0F0E0D, 0x080B0A0904070605 +.Lk_mc_backward:// mc_backward + .quad 0x0605040702010003, 0x0E0D0C0F0A09080B + .quad 0x020100030E0D0C0F, 0x0A09080B06050407 + .quad 0x0E0D0C0F0A09080B, 0x0605040702010003 + .quad 0x0A09080B06050407, 0x020100030E0D0C0F +.Lk_sr: // sr + .quad 0x0706050403020100, 0x0F0E0D0C0B0A0908 + .quad 0x030E09040F0A0500, 0x0B06010C07020D08 + .quad 0x0F060D040B020900, 0x070E050C030A0108 + .quad 0x0B0E0104070A0D00, 0x0306090C0F020508 + +// +// "Hot" constants +// +.Lk_inv: // inv, inva + .quad 0x0E05060F0D080180, 0x040703090A0B0C02 + .quad 0x01040A060F0B0780, 0x030D0E0C02050809 +.Lk_ipt: // input transform (lo, hi) + .quad 0xC2B2E8985A2A7000, 0xCABAE09052227808 + .quad 0x4C01307D317C4D00, 0xCD80B1FCB0FDCC81 +.Lk_sbo: // sbou, sbot + .quad 0xD0D26D176FBDC700, 0x15AABF7AC502A878 + .quad 0xCFE474A55FBB6A00, 0x8E1E90D1412B35FA +.Lk_sb1: // sb1u, sb1t + .quad 0x3618D415FAE22300, 0x3BF7CCC10D2ED9EF + .quad 0xB19BE18FCB503E00, 0xA5DF7A6E142AF544 +.Lk_sb2: // sb2u, sb2t + .quad 0x69EB88400AE12900, 0xC2A163C8AB82234A + .quad 0xE27A93C60B712400, 0x5EB7E955BC982FCD + +// +// Key schedule constants +// +.Lk_dksd: // decryption key schedule: invskew x*D + .quad 0xFEB91A5DA3E44700, 0x0740E3A45A1DBEF9 + .quad 0x41C277F4B5368300, 0x5FDC69EAAB289D1E +.Lk_dksb: // decryption key schedule: invskew x*B + .quad 0x9A4FCA1F8550D500, 0x03D653861CC94C99 + .quad 0x115BEDA7B6FC4A00, 0xD993256F7E3482C8 +.Lk_dkse: // decryption key schedule: invskew x*E + 0x63 + .quad 0xD5031CCA1FC9D600, 0x53859A4C994F5086 + .quad 0xA23196054FDC7BE8, 0xCD5EF96A20B31487 +.Lk_dks9: // decryption key schedule: invskew x*9 + .quad 0xB6116FC87ED9A700, 0x4AED933482255BFC + .quad 0x4576516227143300, 0x8BB89FACE9DAFDCE + +.Lk_rcon: // rcon + .quad 0x1F8391B9AF9DEEB6, 0x702A98084D7C7D81 + +.Lk_opt: // output transform + .quad 0xFF9F4929D6B66000, 0xF7974121DEBE6808 + .quad 0x01EDBD5150BCEC00, 0xE10D5DB1B05C0CE0 +.Lk_deskew: // deskew tables: inverts the sbox's "skew" + .quad 0x07E4A34047A4E300, 0x1DFEB95A5DBEF91A + .quad 0x5F36B5DC83EA6900, 0x2841C2ABF49D1E77 + +.asciz "Vector Permutation AES for ARMv8, Mike Hamburg (Stanford University)" +.size _vpaes_consts,.-_vpaes_consts +.align 6 + +.text +___ + +{ +my ($inp,$out,$key) = map("x$_",(0..2)); + +my ($invlo,$invhi,$iptlo,$ipthi,$sbou,$sbot) = map("v$_.16b",(18..23)); +my ($sb1u,$sb1t,$sb2u,$sb2t) = map("v$_.16b",(24..27)); +my ($sb9u,$sb9t,$sbdu,$sbdt,$sbbu,$sbbt,$sbeu,$sbet)=map("v$_.16b",(24..31)); + +$code.=<<___; +## +## _aes_preheat +## +## Fills register %r10 -> .aes_consts (so you can -fPIC) +## and %xmm9-%xmm15 as specified below. +## +.type _vpaes_encrypt_preheat,%function +.align 4 +_vpaes_encrypt_preheat: + adrp x10, :pg_hi21:.Lk_inv + add x10, x10, :lo12:.Lk_inv + movi v17.16b, #0x0f + ld1 {v18.2d-v19.2d}, [x10],#32 // .Lk_inv + ld1 {v20.2d-v23.2d}, [x10],#64 // .Lk_ipt, .Lk_sbo + ld1 {v24.2d-v27.2d}, [x10] // .Lk_sb1, .Lk_sb2 + ret +.size _vpaes_encrypt_preheat,.-_vpaes_encrypt_preheat + +## +## _aes_encrypt_core +## +## AES-encrypt %xmm0. +## +## Inputs: +## %xmm0 = input +## %xmm9-%xmm15 as in _vpaes_preheat +## (%rdx) = scheduled keys +## +## Output in %xmm0 +## Clobbers %xmm1-%xmm5, %r9, %r10, %r11, %rax +## Preserves %xmm6 - %xmm8 so you get some local vectors +## +## +.type _vpaes_encrypt_core,%function +.align 4 +_vpaes_encrypt_core: + mov x9, $key + ldr w8, [$key,#240] // pull rounds + adrp x11, :pg_hi21:.Lk_mc_forward+16 + add x11, x11, :lo12:.Lk_mc_forward+16 + // vmovdqa .Lk_ipt(%rip), %xmm2 # iptlo + ld1 {v16.2d}, [x9], #16 // vmovdqu (%r9), %xmm5 # round0 key + and v1.16b, v7.16b, v17.16b // vpand %xmm9, %xmm0, %xmm1 + ushr v0.16b, v7.16b, #4 // vpsrlb \$4, %xmm0, %xmm0 + tbl v1.16b, {$iptlo}, v1.16b // vpshufb %xmm1, %xmm2, %xmm1 + // vmovdqa .Lk_ipt+16(%rip), %xmm3 # ipthi + tbl v2.16b, {$ipthi}, v0.16b // vpshufb %xmm0, %xmm3, %xmm2 + eor v0.16b, v1.16b, v16.16b // vpxor %xmm5, %xmm1, %xmm0 + eor v0.16b, v0.16b, v2.16b // vpxor %xmm2, %xmm0, %xmm0 + b .Lenc_entry + +.align 4 +.Lenc_loop: + // middle of middle round + add x10, x11, #0x40 + tbl v4.16b, {$sb1t}, v2.16b // vpshufb %xmm2, %xmm13, %xmm4 # 4 = sb1u + ld1 {v1.2d}, [x11], #16 // vmovdqa -0x40(%r11,%r10), %xmm1 # .Lk_mc_forward[] + tbl v0.16b, {$sb1u}, v3.16b // vpshufb %xmm3, %xmm12, %xmm0 # 0 = sb1t + eor v4.16b, v4.16b, v16.16b // vpxor %xmm5, %xmm4, %xmm4 # 4 = sb1u + k + tbl v5.16b, {$sb2t}, v2.16b // vpshufb %xmm2, %xmm15, %xmm5 # 4 = sb2u + eor v0.16b, v0.16b, v4.16b // vpxor %xmm4, %xmm0, %xmm0 # 0 = A + tbl v2.16b, {$sb2u}, v3.16b // vpshufb %xmm3, %xmm14, %xmm2 # 2 = sb2t + ld1 {v4.2d}, [x10] // vmovdqa (%r11,%r10), %xmm4 # .Lk_mc_backward[] + tbl v3.16b, {v0.16b}, v1.16b // vpshufb %xmm1, %xmm0, %xmm3 # 0 = B + eor v2.16b, v2.16b, v5.16b // vpxor %xmm5, %xmm2, %xmm2 # 2 = 2A + tbl v0.16b, {v0.16b}, v4.16b // vpshufb %xmm4, %xmm0, %xmm0 # 3 = D + eor v3.16b, v3.16b, v2.16b // vpxor %xmm2, %xmm3, %xmm3 # 0 = 2A+B + tbl v4.16b, {v3.16b}, v1.16b // vpshufb %xmm1, %xmm3, %xmm4 # 0 = 2B+C + eor v0.16b, v0.16b, v3.16b // vpxor %xmm3, %xmm0, %xmm0 # 3 = 2A+B+D + and x11, x11, #~(1<<6) // and \$0x30, %r11 # ... mod 4 + eor v0.16b, v0.16b, v4.16b // vpxor %xmm4, %xmm0, %xmm0 # 0 = 2A+3B+C+D + sub w8, w8, #1 // nr-- + +.Lenc_entry: + // top of round + and v1.16b, v0.16b, v17.16b // vpand %xmm0, %xmm9, %xmm1 # 0 = k + ushr v0.16b, v0.16b, #4 // vpsrlb \$4, %xmm0, %xmm0 # 1 = i + tbl v5.16b, {$invhi}, v1.16b // vpshufb %xmm1, %xmm11, %xmm5 # 2 = a/k + eor v1.16b, v1.16b, v0.16b // vpxor %xmm0, %xmm1, %xmm1 # 0 = j + tbl v3.16b, {$invlo}, v0.16b // vpshufb %xmm0, %xmm10, %xmm3 # 3 = 1/i + tbl v4.16b, {$invlo}, v1.16b // vpshufb %xmm1, %xmm10, %xmm4 # 4 = 1/j + eor v3.16b, v3.16b, v5.16b // vpxor %xmm5, %xmm3, %xmm3 # 3 = iak = 1/i + a/k + eor v4.16b, v4.16b, v5.16b // vpxor %xmm5, %xmm4, %xmm4 # 4 = jak = 1/j + a/k + tbl v2.16b, {$invlo}, v3.16b // vpshufb %xmm3, %xmm10, %xmm2 # 2 = 1/iak + tbl v3.16b, {$invlo}, v4.16b // vpshufb %xmm4, %xmm10, %xmm3 # 3 = 1/jak + eor v2.16b, v2.16b, v1.16b // vpxor %xmm1, %xmm2, %xmm2 # 2 = io + eor v3.16b, v3.16b, v0.16b // vpxor %xmm0, %xmm3, %xmm3 # 3 = jo + ld1 {v16.2d}, [x9],#16 // vmovdqu (%r9), %xmm5 + cbnz w8, .Lenc_loop + + // middle of last round + add x10, x11, #0x80 + // vmovdqa -0x60(%r10), %xmm4 # 3 : sbou .Lk_sbo + // vmovdqa -0x50(%r10), %xmm0 # 0 : sbot .Lk_sbo+16 + tbl v4.16b, {$sbou}, v2.16b // vpshufb %xmm2, %xmm4, %xmm4 # 4 = sbou + ld1 {v1.2d}, [x10] // vmovdqa 0x40(%r11,%r10), %xmm1 # .Lk_sr[] + tbl v0.16b, {$sbot}, v3.16b // vpshufb %xmm3, %xmm0, %xmm0 # 0 = sb1t + eor v4.16b, v4.16b, v16.16b // vpxor %xmm5, %xmm4, %xmm4 # 4 = sb1u + k + eor v0.16b, v0.16b, v4.16b // vpxor %xmm4, %xmm0, %xmm0 # 0 = A + tbl v0.16b, {v0.16b}, v1.16b // vpshufb %xmm1, %xmm0, %xmm0 + ret +.size _vpaes_encrypt_core,.-_vpaes_encrypt_core + +.type _vpaes_encrypt_2x,%function +.align 4 +_vpaes_encrypt_2x: + mov x9, $key + ldr w8, [$key,#240] // pull rounds + adrp x11, :pg_hi21:.Lk_mc_forward+16 + add x11, x11, :lo12:.Lk_mc_forward+16 + // vmovdqa .Lk_ipt(%rip), %xmm2 # iptlo + ld1 {v16.2d}, [x9], #16 // vmovdqu (%r9), %xmm5 # round0 key + and v1.16b, v14.16b, v17.16b // vpand %xmm9, %xmm0, %xmm1 + ushr v0.16b, v14.16b, #4 // vpsrlb \$4, %xmm0, %xmm0 + and v9.16b, v15.16b, v17.16b + ushr v8.16b, v15.16b, #4 + tbl v1.16b, {$iptlo}, v1.16b // vpshufb %xmm1, %xmm2, %xmm1 + tbl v9.16b, {$iptlo}, v9.16b + // vmovdqa .Lk_ipt+16(%rip), %xmm3 # ipthi + tbl v2.16b, {$ipthi}, v0.16b // vpshufb %xmm0, %xmm3, %xmm2 + tbl v10.16b, {$ipthi}, v8.16b + eor v0.16b, v1.16b, v16.16b // vpxor %xmm5, %xmm1, %xmm0 + eor v8.16b, v9.16b, v16.16b + eor v0.16b, v0.16b, v2.16b // vpxor %xmm2, %xmm0, %xmm0 + eor v8.16b, v8.16b, v10.16b + b .Lenc_2x_entry + +.align 4 +.Lenc_2x_loop: + // middle of middle round + add x10, x11, #0x40 + tbl v4.16b, {$sb1t}, v2.16b // vpshufb %xmm2, %xmm13, %xmm4 # 4 = sb1u + tbl v12.16b, {$sb1t}, v10.16b + ld1 {v1.2d}, [x11], #16 // vmovdqa -0x40(%r11,%r10), %xmm1 # .Lk_mc_forward[] + tbl v0.16b, {$sb1u}, v3.16b // vpshufb %xmm3, %xmm12, %xmm0 # 0 = sb1t + tbl v8.16b, {$sb1u}, v11.16b + eor v4.16b, v4.16b, v16.16b // vpxor %xmm5, %xmm4, %xmm4 # 4 = sb1u + k + eor v12.16b, v12.16b, v16.16b + tbl v5.16b, {$sb2t}, v2.16b // vpshufb %xmm2, %xmm15, %xmm5 # 4 = sb2u + tbl v13.16b, {$sb2t}, v10.16b + eor v0.16b, v0.16b, v4.16b // vpxor %xmm4, %xmm0, %xmm0 # 0 = A + eor v8.16b, v8.16b, v12.16b + tbl v2.16b, {$sb2u}, v3.16b // vpshufb %xmm3, %xmm14, %xmm2 # 2 = sb2t + tbl v10.16b, {$sb2u}, v11.16b + ld1 {v4.2d}, [x10] // vmovdqa (%r11,%r10), %xmm4 # .Lk_mc_backward[] + tbl v3.16b, {v0.16b}, v1.16b // vpshufb %xmm1, %xmm0, %xmm3 # 0 = B + tbl v11.16b, {v8.16b}, v1.16b + eor v2.16b, v2.16b, v5.16b // vpxor %xmm5, %xmm2, %xmm2 # 2 = 2A + eor v10.16b, v10.16b, v13.16b + tbl v0.16b, {v0.16b}, v4.16b // vpshufb %xmm4, %xmm0, %xmm0 # 3 = D + tbl v8.16b, {v8.16b}, v4.16b + eor v3.16b, v3.16b, v2.16b // vpxor %xmm2, %xmm3, %xmm3 # 0 = 2A+B + eor v11.16b, v11.16b, v10.16b + tbl v4.16b, {v3.16b}, v1.16b // vpshufb %xmm1, %xmm3, %xmm4 # 0 = 2B+C + tbl v12.16b, {v11.16b},v1.16b + eor v0.16b, v0.16b, v3.16b // vpxor %xmm3, %xmm0, %xmm0 # 3 = 2A+B+D + eor v8.16b, v8.16b, v11.16b + and x11, x11, #~(1<<6) // and \$0x30, %r11 # ... mod 4 + eor v0.16b, v0.16b, v4.16b // vpxor %xmm4, %xmm0, %xmm0 # 0 = 2A+3B+C+D + eor v8.16b, v8.16b, v12.16b + sub w8, w8, #1 // nr-- + +.Lenc_2x_entry: + // top of round + and v1.16b, v0.16b, v17.16b // vpand %xmm0, %xmm9, %xmm1 # 0 = k + ushr v0.16b, v0.16b, #4 // vpsrlb \$4, %xmm0, %xmm0 # 1 = i + and v9.16b, v8.16b, v17.16b + ushr v8.16b, v8.16b, #4 + tbl v5.16b, {$invhi},v1.16b // vpshufb %xmm1, %xmm11, %xmm5 # 2 = a/k + tbl v13.16b, {$invhi},v9.16b + eor v1.16b, v1.16b, v0.16b // vpxor %xmm0, %xmm1, %xmm1 # 0 = j + eor v9.16b, v9.16b, v8.16b + tbl v3.16b, {$invlo},v0.16b // vpshufb %xmm0, %xmm10, %xmm3 # 3 = 1/i + tbl v11.16b, {$invlo},v8.16b + tbl v4.16b, {$invlo},v1.16b // vpshufb %xmm1, %xmm10, %xmm4 # 4 = 1/j + tbl v12.16b, {$invlo},v9.16b + eor v3.16b, v3.16b, v5.16b // vpxor %xmm5, %xmm3, %xmm3 # 3 = iak = 1/i + a/k + eor v11.16b, v11.16b, v13.16b + eor v4.16b, v4.16b, v5.16b // vpxor %xmm5, %xmm4, %xmm4 # 4 = jak = 1/j + a/k + eor v12.16b, v12.16b, v13.16b + tbl v2.16b, {$invlo},v3.16b // vpshufb %xmm3, %xmm10, %xmm2 # 2 = 1/iak + tbl v10.16b, {$invlo},v11.16b + tbl v3.16b, {$invlo},v4.16b // vpshufb %xmm4, %xmm10, %xmm3 # 3 = 1/jak + tbl v11.16b, {$invlo},v12.16b + eor v2.16b, v2.16b, v1.16b // vpxor %xmm1, %xmm2, %xmm2 # 2 = io + eor v10.16b, v10.16b, v9.16b + eor v3.16b, v3.16b, v0.16b // vpxor %xmm0, %xmm3, %xmm3 # 3 = jo + eor v11.16b, v11.16b, v8.16b + ld1 {v16.2d}, [x9],#16 // vmovdqu (%r9), %xmm5 + cbnz w8, .Lenc_2x_loop + + // middle of last round + add x10, x11, #0x80 + // vmovdqa -0x60(%r10), %xmm4 # 3 : sbou .Lk_sbo + // vmovdqa -0x50(%r10), %xmm0 # 0 : sbot .Lk_sbo+16 + tbl v4.16b, {$sbou}, v2.16b // vpshufb %xmm2, %xmm4, %xmm4 # 4 = sbou + tbl v12.16b, {$sbou}, v10.16b + ld1 {v1.2d}, [x10] // vmovdqa 0x40(%r11,%r10), %xmm1 # .Lk_sr[] + tbl v0.16b, {$sbot}, v3.16b // vpshufb %xmm3, %xmm0, %xmm0 # 0 = sb1t + tbl v8.16b, {$sbot}, v11.16b + eor v4.16b, v4.16b, v16.16b // vpxor %xmm5, %xmm4, %xmm4 # 4 = sb1u + k + eor v12.16b, v12.16b, v16.16b + eor v0.16b, v0.16b, v4.16b // vpxor %xmm4, %xmm0, %xmm0 # 0 = A + eor v8.16b, v8.16b, v12.16b + tbl v0.16b, {v0.16b},v1.16b // vpshufb %xmm1, %xmm0, %xmm0 + tbl v1.16b, {v8.16b},v1.16b + ret +.size _vpaes_encrypt_2x,.-_vpaes_encrypt_2x +___ +} +{ +my ($inp,$bits,$out,$dir)=("x0","w1","x2","w3"); +my ($invlo,$invhi,$iptlo,$ipthi,$rcon) = map("v$_.16b",(18..21,8)); + +$code.=<<___; +######################################################## +## ## +## AES key schedule ## +## ## +######################################################## +.type _vpaes_key_preheat,%function +.align 4 +_vpaes_key_preheat: + adrp x10, :pg_hi21:.Lk_inv + add x10, x10, :lo12:.Lk_inv + movi v16.16b, #0x5b // .Lk_s63 + adrp x11, :pg_hi21:.Lk_sb1 + add x11, x11, :lo12:.Lk_sb1 + movi v17.16b, #0x0f // .Lk_s0F + ld1 {v18.2d-v21.2d}, [x10] // .Lk_inv, .Lk_ipt + adrp x10, :pg_hi21:.Lk_dksd + add x10, x10, :lo12:.Lk_dksd + ld1 {v22.2d-v23.2d}, [x11] // .Lk_sb1 + adrp x11, :pg_hi21:.Lk_mc_forward + add x11, x11, :lo12:.Lk_mc_forward + ld1 {v24.2d-v27.2d}, [x10],#64 // .Lk_dksd, .Lk_dksb + ld1 {v28.2d-v31.2d}, [x10],#64 // .Lk_dkse, .Lk_dks9 + ld1 {v8.2d}, [x10] // .Lk_rcon + ld1 {v9.2d}, [x11] // .Lk_mc_forward[0] + ret +.size _vpaes_key_preheat,.-_vpaes_key_preheat + +.type _vpaes_schedule_core,%function +.align 4 +_vpaes_schedule_core: + AARCH64_SIGN_LINK_REGISTER + stp x29, x30, [sp,#-16]! + add x29,sp,#0 + + bl _vpaes_key_preheat // load the tables + + ld1 {v0.16b}, [$inp],#16 // vmovdqu (%rdi), %xmm0 # load key (unaligned) + + // input transform + mov v3.16b, v0.16b // vmovdqa %xmm0, %xmm3 + bl _vpaes_schedule_transform + mov v7.16b, v0.16b // vmovdqa %xmm0, %xmm7 + + adrp x10, :pg_hi21:.Lk_sr // lea .Lk_sr(%rip),%r10 + add x10, x10, :lo12:.Lk_sr + + add x8, x8, x10 + + // encrypting, output zeroth round key after transform + st1 {v0.2d}, [$out] // vmovdqu %xmm0, (%rdx) + + cmp $bits, #192 // cmp \$192, %esi + b.hi .Lschedule_256 + b.eq .Lschedule_192 + // 128: fall though + +## +## .schedule_128 +## +## 128-bit specific part of key schedule. +## +## This schedule is really simple, because all its parts +## are accomplished by the subroutines. +## +.Lschedule_128: + mov $inp, #10 // mov \$10, %esi + +.Loop_schedule_128: + sub $inp, $inp, #1 // dec %esi + bl _vpaes_schedule_round + cbz $inp, .Lschedule_mangle_last + bl _vpaes_schedule_mangle // write output + b .Loop_schedule_128 + +## +## .aes_schedule_192 +## +## 192-bit specific part of key schedule. +## +## The main body of this schedule is the same as the 128-bit +## schedule, but with more smearing. The long, high side is +## stored in %xmm7 as before, and the short, low side is in +## the high bits of %xmm6. +## +## This schedule is somewhat nastier, however, because each +## round produces 192 bits of key material, or 1.5 round keys. +## Therefore, on each cycle we do 2 rounds and produce 3 round +## keys. +## +.align 4 +.Lschedule_192: + sub $inp, $inp, #8 + ld1 {v0.16b}, [$inp] // vmovdqu 8(%rdi),%xmm0 # load key part 2 (very unaligned) + bl _vpaes_schedule_transform // input transform + mov v6.16b, v0.16b // vmovdqa %xmm0, %xmm6 # save short part + eor v4.16b, v4.16b, v4.16b // vpxor %xmm4, %xmm4, %xmm4 # clear 4 + ins v6.d[0], v4.d[0] // vmovhlps %xmm4, %xmm6, %xmm6 # clobber low side with zeros + mov $inp, #4 // mov \$4, %esi + +.Loop_schedule_192: + sub $inp, $inp, #1 // dec %esi + bl _vpaes_schedule_round + ext v0.16b, v6.16b, v0.16b, #8 // vpalignr \$8,%xmm6,%xmm0,%xmm0 + bl _vpaes_schedule_mangle // save key n + bl _vpaes_schedule_192_smear + bl _vpaes_schedule_mangle // save key n+1 + bl _vpaes_schedule_round + cbz $inp, .Lschedule_mangle_last + bl _vpaes_schedule_mangle // save key n+2 + bl _vpaes_schedule_192_smear + b .Loop_schedule_192 + +## +## .aes_schedule_256 +## +## 256-bit specific part of key schedule. +## +## The structure here is very similar to the 128-bit +## schedule, but with an additional "low side" in +## %xmm6. The low side's rounds are the same as the +## high side's, except no rcon and no rotation. +## +.align 4 +.Lschedule_256: + ld1 {v0.16b}, [$inp] // vmovdqu 16(%rdi),%xmm0 # load key part 2 (unaligned) + bl _vpaes_schedule_transform // input transform + mov $inp, #7 // mov \$7, %esi + +.Loop_schedule_256: + sub $inp, $inp, #1 // dec %esi + bl _vpaes_schedule_mangle // output low result + mov v6.16b, v0.16b // vmovdqa %xmm0, %xmm6 # save cur_lo in xmm6 + + // high round + bl _vpaes_schedule_round + cbz $inp, .Lschedule_mangle_last + bl _vpaes_schedule_mangle + + // low round. swap xmm7 and xmm6 + dup v0.4s, v0.s[3] // vpshufd \$0xFF, %xmm0, %xmm0 + movi v4.16b, #0 + mov v5.16b, v7.16b // vmovdqa %xmm7, %xmm5 + mov v7.16b, v6.16b // vmovdqa %xmm6, %xmm7 + bl _vpaes_schedule_low_round + mov v7.16b, v5.16b // vmovdqa %xmm5, %xmm7 + + b .Loop_schedule_256 + +## +## .aes_schedule_mangle_last +## +## Mangler for last round of key schedule +## Mangles %xmm0 +## when encrypting, outputs out(%xmm0) ^ 63 +## when decrypting, outputs unskew(%xmm0) +## +## Always called right before return... jumps to cleanup and exits +## +.align 4 +.Lschedule_mangle_last: + // schedule last round key from xmm0 + adrp x11, :pg_hi21:.Lk_deskew // lea .Lk_deskew(%rip),%r11 # prepare to deskew + add x11, x11, :lo12:.Lk_deskew + + cbnz $dir, .Lschedule_mangle_last_dec + + // encrypting + ld1 {v1.2d}, [x8] // vmovdqa (%r8,%r10),%xmm1 + adrp x11, :pg_hi21:.Lk_opt // lea .Lk_opt(%rip), %r11 # prepare to output transform + add x11, x11, :lo12:.Lk_opt + add $out, $out, #32 // add \$32, %rdx + tbl v0.16b, {v0.16b}, v1.16b // vpshufb %xmm1, %xmm0, %xmm0 # output permute + +.Lschedule_mangle_last_dec: + ld1 {v20.2d-v21.2d}, [x11] // reload constants + sub $out, $out, #16 // add \$-16, %rdx + eor v0.16b, v0.16b, v16.16b // vpxor .Lk_s63(%rip), %xmm0, %xmm0 + bl _vpaes_schedule_transform // output transform + st1 {v0.2d}, [$out] // vmovdqu %xmm0, (%rdx) # save last key + + // cleanup + eor v0.16b, v0.16b, v0.16b // vpxor %xmm0, %xmm0, %xmm0 + eor v1.16b, v1.16b, v1.16b // vpxor %xmm1, %xmm1, %xmm1 + eor v2.16b, v2.16b, v2.16b // vpxor %xmm2, %xmm2, %xmm2 + eor v3.16b, v3.16b, v3.16b // vpxor %xmm3, %xmm3, %xmm3 + eor v4.16b, v4.16b, v4.16b // vpxor %xmm4, %xmm4, %xmm4 + eor v5.16b, v5.16b, v5.16b // vpxor %xmm5, %xmm5, %xmm5 + eor v6.16b, v6.16b, v6.16b // vpxor %xmm6, %xmm6, %xmm6 + eor v7.16b, v7.16b, v7.16b // vpxor %xmm7, %xmm7, %xmm7 + ldp x29, x30, [sp],#16 + AARCH64_VALIDATE_LINK_REGISTER + ret +.size _vpaes_schedule_core,.-_vpaes_schedule_core + +## +## .aes_schedule_192_smear +## +## Smear the short, low side in the 192-bit key schedule. +## +## Inputs: +## %xmm7: high side, b a x y +## %xmm6: low side, d c 0 0 +## %xmm13: 0 +## +## Outputs: +## %xmm6: b+c+d b+c 0 0 +## %xmm0: b+c+d b+c b a +## +.type _vpaes_schedule_192_smear,%function +.align 4 +_vpaes_schedule_192_smear: + movi v1.16b, #0 + dup v0.4s, v7.s[3] + ins v1.s[3], v6.s[2] // vpshufd \$0x80, %xmm6, %xmm1 # d c 0 0 -> c 0 0 0 + ins v0.s[0], v7.s[2] // vpshufd \$0xFE, %xmm7, %xmm0 # b a _ _ -> b b b a + eor v6.16b, v6.16b, v1.16b // vpxor %xmm1, %xmm6, %xmm6 # -> c+d c 0 0 + eor v1.16b, v1.16b, v1.16b // vpxor %xmm1, %xmm1, %xmm1 + eor v6.16b, v6.16b, v0.16b // vpxor %xmm0, %xmm6, %xmm6 # -> b+c+d b+c b a + mov v0.16b, v6.16b // vmovdqa %xmm6, %xmm0 + ins v6.d[0], v1.d[0] // vmovhlps %xmm1, %xmm6, %xmm6 # clobber low side with zeros + ret +.size _vpaes_schedule_192_smear,.-_vpaes_schedule_192_smear + +## +## .aes_schedule_round +## +## Runs one main round of the key schedule on %xmm0, %xmm7 +## +## Specifically, runs subbytes on the high dword of %xmm0 +## then rotates it by one byte and xors into the low dword of +## %xmm7. +## +## Adds rcon from low byte of %xmm8, then rotates %xmm8 for +## next rcon. +## +## Smears the dwords of %xmm7 by xoring the low into the +## second low, result into third, result into highest. +## +## Returns results in %xmm7 = %xmm0. +## Clobbers %xmm1-%xmm4, %r11. +## +.type _vpaes_schedule_round,%function +.align 4 +_vpaes_schedule_round: + // extract rcon from xmm8 + movi v4.16b, #0 // vpxor %xmm4, %xmm4, %xmm4 + ext v1.16b, $rcon, v4.16b, #15 // vpalignr \$15, %xmm8, %xmm4, %xmm1 + ext $rcon, $rcon, $rcon, #15 // vpalignr \$15, %xmm8, %xmm8, %xmm8 + eor v7.16b, v7.16b, v1.16b // vpxor %xmm1, %xmm7, %xmm7 + + // rotate + dup v0.4s, v0.s[3] // vpshufd \$0xFF, %xmm0, %xmm0 + ext v0.16b, v0.16b, v0.16b, #1 // vpalignr \$1, %xmm0, %xmm0, %xmm0 + + // fall through... + + // low round: same as high round, but no rotation and no rcon. +_vpaes_schedule_low_round: + // smear xmm7 + ext v1.16b, v4.16b, v7.16b, #12 // vpslldq \$4, %xmm7, %xmm1 + eor v7.16b, v7.16b, v1.16b // vpxor %xmm1, %xmm7, %xmm7 + ext v4.16b, v4.16b, v7.16b, #8 // vpslldq \$8, %xmm7, %xmm4 + + // subbytes + and v1.16b, v0.16b, v17.16b // vpand %xmm9, %xmm0, %xmm1 # 0 = k + ushr v0.16b, v0.16b, #4 // vpsrlb \$4, %xmm0, %xmm0 # 1 = i + eor v7.16b, v7.16b, v4.16b // vpxor %xmm4, %xmm7, %xmm7 + tbl v2.16b, {$invhi}, v1.16b // vpshufb %xmm1, %xmm11, %xmm2 # 2 = a/k + eor v1.16b, v1.16b, v0.16b // vpxor %xmm0, %xmm1, %xmm1 # 0 = j + tbl v3.16b, {$invlo}, v0.16b // vpshufb %xmm0, %xmm10, %xmm3 # 3 = 1/i + eor v3.16b, v3.16b, v2.16b // vpxor %xmm2, %xmm3, %xmm3 # 3 = iak = 1/i + a/k + tbl v4.16b, {$invlo}, v1.16b // vpshufb %xmm1, %xmm10, %xmm4 # 4 = 1/j + eor v7.16b, v7.16b, v16.16b // vpxor .Lk_s63(%rip), %xmm7, %xmm7 + tbl v3.16b, {$invlo}, v3.16b // vpshufb %xmm3, %xmm10, %xmm3 # 2 = 1/iak + eor v4.16b, v4.16b, v2.16b // vpxor %xmm2, %xmm4, %xmm4 # 4 = jak = 1/j + a/k + tbl v2.16b, {$invlo}, v4.16b // vpshufb %xmm4, %xmm10, %xmm2 # 3 = 1/jak + eor v3.16b, v3.16b, v1.16b // vpxor %xmm1, %xmm3, %xmm3 # 2 = io + eor v2.16b, v2.16b, v0.16b // vpxor %xmm0, %xmm2, %xmm2 # 3 = jo + tbl v4.16b, {v23.16b}, v3.16b // vpshufb %xmm3, %xmm13, %xmm4 # 4 = sbou + tbl v1.16b, {v22.16b}, v2.16b // vpshufb %xmm2, %xmm12, %xmm1 # 0 = sb1t + eor v1.16b, v1.16b, v4.16b // vpxor %xmm4, %xmm1, %xmm1 # 0 = sbox output + + // add in smeared stuff + eor v0.16b, v1.16b, v7.16b // vpxor %xmm7, %xmm1, %xmm0 + eor v7.16b, v1.16b, v7.16b // vmovdqa %xmm0, %xmm7 + ret +.size _vpaes_schedule_round,.-_vpaes_schedule_round + +## +## .aes_schedule_transform +## +## Linear-transform %xmm0 according to tables at (%r11) +## +## Requires that %xmm9 = 0x0F0F... as in preheat +## Output in %xmm0 +## Clobbers %xmm1, %xmm2 +## +.type _vpaes_schedule_transform,%function +.align 4 +_vpaes_schedule_transform: + and v1.16b, v0.16b, v17.16b // vpand %xmm9, %xmm0, %xmm1 + ushr v0.16b, v0.16b, #4 // vpsrlb \$4, %xmm0, %xmm0 + // vmovdqa (%r11), %xmm2 # lo + tbl v2.16b, {$iptlo}, v1.16b // vpshufb %xmm1, %xmm2, %xmm2 + // vmovdqa 16(%r11), %xmm1 # hi + tbl v0.16b, {$ipthi}, v0.16b // vpshufb %xmm0, %xmm1, %xmm0 + eor v0.16b, v0.16b, v2.16b // vpxor %xmm2, %xmm0, %xmm0 + ret +.size _vpaes_schedule_transform,.-_vpaes_schedule_transform + +## +## .aes_schedule_mangle +## +## Mangle xmm0 from (basis-transformed) standard version +## to our version. +## +## On encrypt, +## xor with 0x63 +## multiply by circulant 0,1,1,1 +## apply shiftrows transform +## +## On decrypt, +## xor with 0x63 +## multiply by "inverse mixcolumns" circulant E,B,D,9 +## deskew +## apply shiftrows transform +## +## +## Writes out to (%rdx), and increments or decrements it +## Keeps track of round number mod 4 in %r8 +## Preserves xmm0 +## Clobbers xmm1-xmm5 +## +.type _vpaes_schedule_mangle,%function +.align 4 +_vpaes_schedule_mangle: + mov v4.16b, v0.16b // vmovdqa %xmm0, %xmm4 # save xmm0 for later + // vmovdqa .Lk_mc_forward(%rip),%xmm5 + + // encrypting + eor v4.16b, v0.16b, v16.16b // vpxor .Lk_s63(%rip), %xmm0, %xmm4 + add $out, $out, #16 // add \$16, %rdx + tbl v4.16b, {v4.16b}, v9.16b // vpshufb %xmm5, %xmm4, %xmm4 + tbl v1.16b, {v4.16b}, v9.16b // vpshufb %xmm5, %xmm4, %xmm1 + tbl v3.16b, {v1.16b}, v9.16b // vpshufb %xmm5, %xmm1, %xmm3 + eor v4.16b, v4.16b, v1.16b // vpxor %xmm1, %xmm4, %xmm4 + ld1 {v1.2d}, [x8] // vmovdqa (%r8,%r10), %xmm1 + eor v3.16b, v3.16b, v4.16b // vpxor %xmm4, %xmm3, %xmm3 + +.Lschedule_mangle_both: + tbl v3.16b, {v3.16b}, v1.16b // vpshufb %xmm1, %xmm3, %xmm3 + add x8, x8, #48 // add \$-16, %r8 + and x8, x8, #~(1<<6) // and \$0x30, %r8 + st1 {v3.2d}, [$out] // vmovdqu %xmm3, (%rdx) + ret +.size _vpaes_schedule_mangle,.-_vpaes_schedule_mangle + +.globl vpaes_set_encrypt_key +.type vpaes_set_encrypt_key,%function +.align 4 +vpaes_set_encrypt_key: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-16]! + add x29,sp,#0 + stp d8,d9,[sp,#-16]! // ABI spec says so + + lsr w9, $bits, #5 // shr \$5,%eax + add w9, w9, #5 // \$5,%eax + str w9, [$out,#240] // mov %eax,240(%rdx) # AES_KEY->rounds = nbits/32+5; + + mov $dir, #0 // mov \$0,%ecx + mov x8, #0x30 // mov \$0x30,%r8d + bl _vpaes_schedule_core + eor x0, x0, x0 + + ldp d8,d9,[sp],#16 + ldp x29,x30,[sp],#16 + AARCH64_VALIDATE_LINK_REGISTER + ret +.size vpaes_set_encrypt_key,.-vpaes_set_encrypt_key +___ +} +{ +my ($inp,$out,$len,$key,$ivec) = map("x$_",(0..4)); +my ($ctr, $ctr_tmp) = ("w6", "w7"); + +# void vpaes_ctr32_encrypt_blocks(const uint8_t *in, uint8_t *out, size_t len, +# const AES_KEY *key, const uint8_t ivec[16]); +$code.=<<___; +.globl vpaes_ctr32_encrypt_blocks +.type vpaes_ctr32_encrypt_blocks,%function +.align 4 +vpaes_ctr32_encrypt_blocks: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-16]! + add x29,sp,#0 + stp d8,d9,[sp,#-16]! // ABI spec says so + stp d10,d11,[sp,#-16]! + stp d12,d13,[sp,#-16]! + stp d14,d15,[sp,#-16]! + + cbz $len, .Lctr32_done + + // Note, unlike the other functions, $len here is measured in blocks, + // not bytes. + mov x17, $len + mov x2, $key + + // Load the IV and counter portion. + ldr $ctr, [$ivec, #12] + ld1 {v7.16b}, [$ivec] + + bl _vpaes_encrypt_preheat + tst x17, #1 + rev $ctr, $ctr // The counter is big-endian. + b.eq .Lctr32_prep_loop + + // Handle one block so the remaining block count is even for + // _vpaes_encrypt_2x. + ld1 {v6.16b}, [$inp], #16 // Load input ahead of time + bl _vpaes_encrypt_core + eor v0.16b, v0.16b, v6.16b // XOR input and result + st1 {v0.16b}, [$out], #16 + subs x17, x17, #1 + // Update the counter. + add $ctr, $ctr, #1 + rev $ctr_tmp, $ctr + mov v7.s[3], $ctr_tmp + b.ls .Lctr32_done + +.Lctr32_prep_loop: + // _vpaes_encrypt_core takes its input from v7, while _vpaes_encrypt_2x + // uses v14 and v15. + mov v15.16b, v7.16b + mov v14.16b, v7.16b + add $ctr, $ctr, #1 + rev $ctr_tmp, $ctr + mov v15.s[3], $ctr_tmp + +.Lctr32_loop: + ld1 {v6.16b,v7.16b}, [$inp], #32 // Load input ahead of time + bl _vpaes_encrypt_2x + eor v0.16b, v0.16b, v6.16b // XOR input and result + eor v1.16b, v1.16b, v7.16b // XOR input and result (#2) + st1 {v0.16b,v1.16b}, [$out], #32 + subs x17, x17, #2 + // Update the counter. + add $ctr_tmp, $ctr, #1 + add $ctr, $ctr, #2 + rev $ctr_tmp, $ctr_tmp + mov v14.s[3], $ctr_tmp + rev $ctr_tmp, $ctr + mov v15.s[3], $ctr_tmp + b.hi .Lctr32_loop + +.Lctr32_done: + ldp d14,d15,[sp],#16 + ldp d12,d13,[sp],#16 + ldp d10,d11,[sp],#16 + ldp d8,d9,[sp],#16 + ldp x29,x30,[sp],#16 + AARCH64_VALIDATE_LINK_REGISTER + ret +.size vpaes_ctr32_encrypt_blocks,.-vpaes_ctr32_encrypt_blocks +___ +} + +print $code; + +close STDOUT or die "error closing STDOUT: $!"; diff --git a/http/vendor/ring/crypto/fipsmodule/aes/asm/vpaes-x86.pl b/http/vendor/ring/crypto/fipsmodule/aes/asm/vpaes-x86.pl new file mode 100644 index 0000000..6410e7a --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/aes/asm/vpaes-x86.pl @@ -0,0 +1,617 @@ +#! /usr/bin/env perl +# Copyright 2011-2016 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +###################################################################### +## Constant-time SSSE3 AES core implementation. +## version 0.1 +## +## By Mike Hamburg (Stanford University), 2009 +## Public domain. +## +## For details see http://shiftleft.org/papers/vector_aes/ and +## http://crypto.stanford.edu/vpaes/. + +###################################################################### +# September 2011. +# +# Port vpaes-x86_64.pl as 32-bit "almost" drop-in replacement for +# aes-586.pl. "Almost" refers to the fact that AES_cbc_encrypt +# doesn't handle partial vectors (doesn't have to if called from +# EVP only). "Drop-in" implies that this module doesn't share key +# schedule structure with the original nor does it make assumption +# about its alignment... +# +# Performance summary. aes-586.pl column lists large-block CBC +# encrypt/decrypt/with-hyper-threading-off(*) results in cycles per +# byte processed with 128-bit key, and vpaes-x86.pl column - [also +# large-block CBC] encrypt/decrypt. +# +# aes-586.pl vpaes-x86.pl +# +# Core 2(**) 28.1/41.4/18.3 21.9/25.2(***) +# Nehalem 27.9/40.4/18.1 10.2/11.9 +# Atom 70.7/92.1/60.1 61.1/75.4(***) +# Silvermont 45.4/62.9/24.1 49.2/61.1(***) +# +# (*) "Hyper-threading" in the context refers rather to cache shared +# among multiple cores, than to specifically Intel HTT. As vast +# majority of contemporary cores share cache, slower code path +# is common place. In other words "with-hyper-threading-off" +# results are presented mostly for reference purposes. +# +# (**) "Core 2" refers to initial 65nm design, a.k.a. Conroe. +# +# (***) Less impressive improvement on Core 2 and Atom is due to slow +# pshufb, yet it's respectable +28%/64% improvement on Core 2 +# and +15% on Atom (as implied, over "hyper-threading-safe" +# code path). +# +# + +$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; +push(@INC,"${dir}","${dir}../../../perlasm"); +require "x86asm.pl"; + +$output = pop; +open OUT,">$output"; +*STDOUT=*OUT; + +&asm_init($ARGV[0]); + +$PREFIX="vpaes"; + +my ($round, $base, $magic, $key, $const, $inp, $out)= + ("eax", "ebx", "ecx", "edx","ebp", "esi","edi"); + +&preprocessor_ifdef("BORINGSSL_DISPATCH_TEST") +&external_label("BORINGSSL_function_hit"); +&preprocessor_endif(); +&static_label("_vpaes_consts"); +&static_label("_vpaes_schedule_low_round"); + +&set_label("_vpaes_consts",64); +$k_inv=-0x30; # inv, inva + &data_word(0x0D080180,0x0E05060F,0x0A0B0C02,0x04070309); + &data_word(0x0F0B0780,0x01040A06,0x02050809,0x030D0E0C); + +$k_s0F=-0x10; # s0F + &data_word(0x0F0F0F0F,0x0F0F0F0F,0x0F0F0F0F,0x0F0F0F0F); + +$k_ipt=0x00; # input transform (lo, hi) + &data_word(0x5A2A7000,0xC2B2E898,0x52227808,0xCABAE090); + &data_word(0x317C4D00,0x4C01307D,0xB0FDCC81,0xCD80B1FC); + +$k_sb1=0x20; # sb1u, sb1t + &data_word(0xCB503E00,0xB19BE18F,0x142AF544,0xA5DF7A6E); + &data_word(0xFAE22300,0x3618D415,0x0D2ED9EF,0x3BF7CCC1); +$k_sb2=0x40; # sb2u, sb2t + &data_word(0x0B712400,0xE27A93C6,0xBC982FCD,0x5EB7E955); + &data_word(0x0AE12900,0x69EB8840,0xAB82234A,0xC2A163C8); +$k_sbo=0x60; # sbou, sbot + &data_word(0x6FBDC700,0xD0D26D17,0xC502A878,0x15AABF7A); + &data_word(0x5FBB6A00,0xCFE474A5,0x412B35FA,0x8E1E90D1); + +$k_mc_forward=0x80; # mc_forward + &data_word(0x00030201,0x04070605,0x080B0A09,0x0C0F0E0D); + &data_word(0x04070605,0x080B0A09,0x0C0F0E0D,0x00030201); + &data_word(0x080B0A09,0x0C0F0E0D,0x00030201,0x04070605); + &data_word(0x0C0F0E0D,0x00030201,0x04070605,0x080B0A09); + +$k_mc_backward=0xc0; # mc_backward + &data_word(0x02010003,0x06050407,0x0A09080B,0x0E0D0C0F); + &data_word(0x0E0D0C0F,0x02010003,0x06050407,0x0A09080B); + &data_word(0x0A09080B,0x0E0D0C0F,0x02010003,0x06050407); + &data_word(0x06050407,0x0A09080B,0x0E0D0C0F,0x02010003); + +$k_sr=0x100; # sr + &data_word(0x03020100,0x07060504,0x0B0A0908,0x0F0E0D0C); + &data_word(0x0F0A0500,0x030E0904,0x07020D08,0x0B06010C); + &data_word(0x0B020900,0x0F060D04,0x030A0108,0x070E050C); + &data_word(0x070A0D00,0x0B0E0104,0x0F020508,0x0306090C); + +$k_rcon=0x140; # rcon + &data_word(0xAF9DEEB6,0x1F8391B9,0x4D7C7D81,0x702A9808); + +$k_s63=0x150; # s63: all equal to 0x63 transformed + &data_word(0x5B5B5B5B,0x5B5B5B5B,0x5B5B5B5B,0x5B5B5B5B); + +$k_opt=0x160; # output transform + &data_word(0xD6B66000,0xFF9F4929,0xDEBE6808,0xF7974121); + &data_word(0x50BCEC00,0x01EDBD51,0xB05C0CE0,0xE10D5DB1); + +$k_deskew=0x180; # deskew tables: inverts the sbox's "skew" + &data_word(0x47A4E300,0x07E4A340,0x5DBEF91A,0x1DFEB95A); + &data_word(0x83EA6900,0x5F36B5DC,0xF49D1E77,0x2841C2AB); + +&asciz ("Vector Permutation AES for x86/SSSE3, Mike Hamburg (Stanford University)"); +&align (64); + +&function_begin_B("_vpaes_preheat"); + &add ($const,&DWP(0,"esp")); + &movdqa ("xmm7",&QWP($k_inv,$const)); + &movdqa ("xmm6",&QWP($k_s0F,$const)); + &ret (); +&function_end_B("_vpaes_preheat"); + +## +## _aes_encrypt_core +## +## AES-encrypt %xmm0. +## +## Inputs: +## %xmm0 = input +## %xmm6-%xmm7 as in _vpaes_preheat +## (%edx) = scheduled keys +## +## Output in %xmm0 +## Clobbers %xmm1-%xmm5, %eax, %ebx, %ecx, %edx +## +## +&function_begin_B("_vpaes_encrypt_core"); + &mov ($magic,16); + &mov ($round,&DWP(240,$key)); + &movdqa ("xmm1","xmm6") + &movdqa ("xmm2",&QWP($k_ipt,$const)); + &pandn ("xmm1","xmm0"); + &pand ("xmm0","xmm6"); + &movdqu ("xmm5",&QWP(0,$key)); + &pshufb ("xmm2","xmm0"); + &movdqa ("xmm0",&QWP($k_ipt+16,$const)); + &pxor ("xmm2","xmm5"); + &psrld ("xmm1",4); + &add ($key,16); + &pshufb ("xmm0","xmm1"); + &lea ($base,&DWP($k_mc_backward,$const)); + &pxor ("xmm0","xmm2"); + &jmp (&label("enc_entry")); + + +&set_label("enc_loop",16); + # middle of middle round + &movdqa ("xmm4",&QWP($k_sb1,$const)); # 4 : sb1u + &movdqa ("xmm0",&QWP($k_sb1+16,$const));# 0 : sb1t + &pshufb ("xmm4","xmm2"); # 4 = sb1u + &pshufb ("xmm0","xmm3"); # 0 = sb1t + &pxor ("xmm4","xmm5"); # 4 = sb1u + k + &movdqa ("xmm5",&QWP($k_sb2,$const)); # 4 : sb2u + &pxor ("xmm0","xmm4"); # 0 = A + &movdqa ("xmm1",&QWP(-0x40,$base,$magic));# .Lk_mc_forward[] + &pshufb ("xmm5","xmm2"); # 4 = sb2u + &movdqa ("xmm2",&QWP($k_sb2+16,$const));# 2 : sb2t + &movdqa ("xmm4",&QWP(0,$base,$magic)); # .Lk_mc_backward[] + &pshufb ("xmm2","xmm3"); # 2 = sb2t + &movdqa ("xmm3","xmm0"); # 3 = A + &pxor ("xmm2","xmm5"); # 2 = 2A + &pshufb ("xmm0","xmm1"); # 0 = B + &add ($key,16); # next key + &pxor ("xmm0","xmm2"); # 0 = 2A+B + &pshufb ("xmm3","xmm4"); # 3 = D + &add ($magic,16); # next mc + &pxor ("xmm3","xmm0"); # 3 = 2A+B+D + &pshufb ("xmm0","xmm1"); # 0 = 2B+C + &and ($magic,0x30); # ... mod 4 + &sub ($round,1); # nr-- + &pxor ("xmm0","xmm3"); # 0 = 2A+3B+C+D + +&set_label("enc_entry"); + # top of round + &movdqa ("xmm1","xmm6"); # 1 : i + &movdqa ("xmm5",&QWP($k_inv+16,$const));# 2 : a/k + &pandn ("xmm1","xmm0"); # 1 = i<<4 + &psrld ("xmm1",4); # 1 = i + &pand ("xmm0","xmm6"); # 0 = k + &pshufb ("xmm5","xmm0"); # 2 = a/k + &movdqa ("xmm3","xmm7"); # 3 : 1/i + &pxor ("xmm0","xmm1"); # 0 = j + &pshufb ("xmm3","xmm1"); # 3 = 1/i + &movdqa ("xmm4","xmm7"); # 4 : 1/j + &pxor ("xmm3","xmm5"); # 3 = iak = 1/i + a/k + &pshufb ("xmm4","xmm0"); # 4 = 1/j + &movdqa ("xmm2","xmm7"); # 2 : 1/iak + &pxor ("xmm4","xmm5"); # 4 = jak = 1/j + a/k + &pshufb ("xmm2","xmm3"); # 2 = 1/iak + &movdqa ("xmm3","xmm7"); # 3 : 1/jak + &pxor ("xmm2","xmm0"); # 2 = io + &pshufb ("xmm3","xmm4"); # 3 = 1/jak + &movdqu ("xmm5",&QWP(0,$key)); + &pxor ("xmm3","xmm1"); # 3 = jo + &jnz (&label("enc_loop")); + + # middle of last round + &movdqa ("xmm4",&QWP($k_sbo,$const)); # 3 : sbou .Lk_sbo + &movdqa ("xmm0",&QWP($k_sbo+16,$const));# 3 : sbot .Lk_sbo+16 + &pshufb ("xmm4","xmm2"); # 4 = sbou + &pxor ("xmm4","xmm5"); # 4 = sb1u + k + &pshufb ("xmm0","xmm3"); # 0 = sb1t + &movdqa ("xmm1",&QWP(0x40,$base,$magic));# .Lk_sr[] + &pxor ("xmm0","xmm4"); # 0 = A + &pshufb ("xmm0","xmm1"); + &ret (); +&function_end_B("_vpaes_encrypt_core"); + +######################################################## +## ## +## AES key schedule ## +## ## +######################################################## +&function_begin_B("_vpaes_schedule_core"); + &add ($const,&DWP(0,"esp")); + &movdqu ("xmm0",&QWP(0,$inp)); # load key (unaligned) + &movdqa ("xmm2",&QWP($k_rcon,$const)); # load rcon + + # input transform + &movdqa ("xmm3","xmm0"); + &lea ($base,&DWP($k_ipt,$const)); + &movdqa (&QWP(4,"esp"),"xmm2"); # xmm8 + &call ("_vpaes_schedule_transform"); + &movdqa ("xmm7","xmm0"); + + &test ($out,$out); + &jnz (&label("schedule_am_decrypting")); + + # encrypting, output zeroth round key after transform + &movdqu (&QWP(0,$key),"xmm0"); + &jmp (&label("schedule_go")); + +&set_label("schedule_am_decrypting"); + # decrypting, output zeroth round key after shiftrows + &movdqa ("xmm1",&QWP($k_sr,$const,$magic)); + &pshufb ("xmm3","xmm1"); + &movdqu (&QWP(0,$key),"xmm3"); + &xor ($magic,0x30); + +&set_label("schedule_go"); + &cmp ($round,192); + &ja (&label("schedule_256")); + # 192-bit key support was removed. + # 128: fall though + +## +## .schedule_128 +## +## 128-bit specific part of key schedule. +## +## This schedule is really simple, because all its parts +## are accomplished by the subroutines. +## +&set_label("schedule_128"); + &mov ($round,10); + +&set_label("loop_schedule_128"); + &call ("_vpaes_schedule_round"); + &dec ($round); + &jz (&label("schedule_mangle_last")); + &call ("_vpaes_schedule_mangle"); # write output + &jmp (&label("loop_schedule_128")); + +## +## .aes_schedule_256 +## +## 256-bit specific part of key schedule. +## +## The structure here is very similar to the 128-bit +## schedule, but with an additional "low side" in +## %xmm6. The low side's rounds are the same as the +## high side's, except no rcon and no rotation. +## +&set_label("schedule_256",16); + &movdqu ("xmm0",&QWP(16,$inp)); # load key part 2 (unaligned) + &call ("_vpaes_schedule_transform"); # input transform + &mov ($round,7); + +&set_label("loop_schedule_256"); + &call ("_vpaes_schedule_mangle"); # output low result + &movdqa ("xmm6","xmm0"); # save cur_lo in xmm6 + + # high round + &call ("_vpaes_schedule_round"); + &dec ($round); + &jz (&label("schedule_mangle_last")); + &call ("_vpaes_schedule_mangle"); + + # low round. swap xmm7 and xmm6 + &pshufd ("xmm0","xmm0",0xFF); + &movdqa (&QWP(20,"esp"),"xmm7"); + &movdqa ("xmm7","xmm6"); + &call ("_vpaes_schedule_low_round"); + &movdqa ("xmm7",&QWP(20,"esp")); + + &jmp (&label("loop_schedule_256")); + +## +## .aes_schedule_mangle_last +## +## Mangler for last round of key schedule +## Mangles %xmm0 +## when encrypting, outputs out(%xmm0) ^ 63 +## when decrypting, outputs unskew(%xmm0) +## +## Always called right before return... jumps to cleanup and exits +## +&set_label("schedule_mangle_last",16); + # schedule last round key from xmm0 + &lea ($base,&DWP($k_deskew,$const)); + &test ($out,$out); + &jnz (&label("schedule_mangle_last_dec")); + + # encrypting + &movdqa ("xmm1",&QWP($k_sr,$const,$magic)); + &pshufb ("xmm0","xmm1"); # output permute + &lea ($base,&DWP($k_opt,$const)); # prepare to output transform + &add ($key,32); + +&set_label("schedule_mangle_last_dec"); + &add ($key,-16); + &pxor ("xmm0",&QWP($k_s63,$const)); + &call ("_vpaes_schedule_transform"); # output transform + &movdqu (&QWP(0,$key),"xmm0"); # save last key + + # cleanup + &pxor ("xmm0","xmm0"); + &pxor ("xmm1","xmm1"); + &pxor ("xmm2","xmm2"); + &pxor ("xmm3","xmm3"); + &pxor ("xmm4","xmm4"); + &pxor ("xmm5","xmm5"); + &pxor ("xmm6","xmm6"); + &pxor ("xmm7","xmm7"); + &ret (); +&function_end_B("_vpaes_schedule_core"); + +## +## .aes_schedule_round +## +## Runs one main round of the key schedule on %xmm0, %xmm7 +## +## Specifically, runs subbytes on the high dword of %xmm0 +## then rotates it by one byte and xors into the low dword of +## %xmm7. +## +## Adds rcon from low byte of %xmm8, then rotates %xmm8 for +## next rcon. +## +## Smears the dwords of %xmm7 by xoring the low into the +## second low, result into third, result into highest. +## +## Returns results in %xmm7 = %xmm0. +## Clobbers %xmm1-%xmm5. +## +&function_begin_B("_vpaes_schedule_round"); + # extract rcon from xmm8 + &movdqa ("xmm2",&QWP(8,"esp")); # xmm8 + &pxor ("xmm1","xmm1"); + &palignr("xmm1","xmm2",15); + &palignr("xmm2","xmm2",15); + &pxor ("xmm7","xmm1"); + + # rotate + &pshufd ("xmm0","xmm0",0xFF); + &palignr("xmm0","xmm0",1); + + # fall through... + &movdqa (&QWP(8,"esp"),"xmm2"); # xmm8 + + # low round: same as high round, but no rotation and no rcon. +&set_label("_vpaes_schedule_low_round"); + # smear xmm7 + &movdqa ("xmm1","xmm7"); + &pslldq ("xmm7",4); + &pxor ("xmm7","xmm1"); + &movdqa ("xmm1","xmm7"); + &pslldq ("xmm7",8); + &pxor ("xmm7","xmm1"); + &pxor ("xmm7",&QWP($k_s63,$const)); + + # subbyte + &movdqa ("xmm4",&QWP($k_s0F,$const)); + &movdqa ("xmm5",&QWP($k_inv,$const)); # 4 : 1/j + &movdqa ("xmm1","xmm4"); + &pandn ("xmm1","xmm0"); + &psrld ("xmm1",4); # 1 = i + &pand ("xmm0","xmm4"); # 0 = k + &movdqa ("xmm2",&QWP($k_inv+16,$const));# 2 : a/k + &pshufb ("xmm2","xmm0"); # 2 = a/k + &pxor ("xmm0","xmm1"); # 0 = j + &movdqa ("xmm3","xmm5"); # 3 : 1/i + &pshufb ("xmm3","xmm1"); # 3 = 1/i + &pxor ("xmm3","xmm2"); # 3 = iak = 1/i + a/k + &movdqa ("xmm4","xmm5"); # 4 : 1/j + &pshufb ("xmm4","xmm0"); # 4 = 1/j + &pxor ("xmm4","xmm2"); # 4 = jak = 1/j + a/k + &movdqa ("xmm2","xmm5"); # 2 : 1/iak + &pshufb ("xmm2","xmm3"); # 2 = 1/iak + &pxor ("xmm2","xmm0"); # 2 = io + &movdqa ("xmm3","xmm5"); # 3 : 1/jak + &pshufb ("xmm3","xmm4"); # 3 = 1/jak + &pxor ("xmm3","xmm1"); # 3 = jo + &movdqa ("xmm4",&QWP($k_sb1,$const)); # 4 : sbou + &pshufb ("xmm4","xmm2"); # 4 = sbou + &movdqa ("xmm0",&QWP($k_sb1+16,$const));# 0 : sbot + &pshufb ("xmm0","xmm3"); # 0 = sb1t + &pxor ("xmm0","xmm4"); # 0 = sbox output + + # add in smeared stuff + &pxor ("xmm0","xmm7"); + &movdqa ("xmm7","xmm0"); + &ret (); +&function_end_B("_vpaes_schedule_round"); + +## +## .aes_schedule_transform +## +## Linear-transform %xmm0 according to tables at (%ebx) +## +## Output in %xmm0 +## Clobbers %xmm1, %xmm2 +## +&function_begin_B("_vpaes_schedule_transform"); + &movdqa ("xmm2",&QWP($k_s0F,$const)); + &movdqa ("xmm1","xmm2"); + &pandn ("xmm1","xmm0"); + &psrld ("xmm1",4); + &pand ("xmm0","xmm2"); + &movdqa ("xmm2",&QWP(0,$base)); + &pshufb ("xmm2","xmm0"); + &movdqa ("xmm0",&QWP(16,$base)); + &pshufb ("xmm0","xmm1"); + &pxor ("xmm0","xmm2"); + &ret (); +&function_end_B("_vpaes_schedule_transform"); + +## +## .aes_schedule_mangle +## +## Mangle xmm0 from (basis-transformed) standard version +## to our version. +## +## On encrypt, +## xor with 0x63 +## multiply by circulant 0,1,1,1 +## apply shiftrows transform +## +## On decrypt, +## xor with 0x63 +## multiply by "inverse mixcolumns" circulant E,B,D,9 +## deskew +## apply shiftrows transform +## +## +## Writes out to (%edx), and increments or decrements it +## Keeps track of round number mod 4 in %ecx +## Preserves xmm0 +## Clobbers xmm1-xmm5 +## +&function_begin_B("_vpaes_schedule_mangle"); + &movdqa ("xmm4","xmm0"); # save xmm0 for later + &movdqa ("xmm5",&QWP($k_mc_forward,$const)); + &test ($out,$out); + &jnz (&label("schedule_mangle_dec")); + + # encrypting + &add ($key,16); + &pxor ("xmm4",&QWP($k_s63,$const)); + &pshufb ("xmm4","xmm5"); + &movdqa ("xmm3","xmm4"); + &pshufb ("xmm4","xmm5"); + &pxor ("xmm3","xmm4"); + &pshufb ("xmm4","xmm5"); + &pxor ("xmm3","xmm4"); + + &jmp (&label("schedule_mangle_both")); + +&set_label("schedule_mangle_dec",16); + # inverse mix columns + &movdqa ("xmm2",&QWP($k_s0F,$const)); + &lea ($inp,&DWP($k_dksd,$const)); + &movdqa ("xmm1","xmm2"); + &pandn ("xmm1","xmm4"); + &psrld ("xmm1",4); # 1 = hi + &pand ("xmm4","xmm2"); # 4 = lo + + &movdqa ("xmm2",&QWP(0,$inp)); + &pshufb ("xmm2","xmm4"); + &movdqa ("xmm3",&QWP(0x10,$inp)); + &pshufb ("xmm3","xmm1"); + &pxor ("xmm3","xmm2"); + &pshufb ("xmm3","xmm5"); + + &movdqa ("xmm2",&QWP(0x20,$inp)); + &pshufb ("xmm2","xmm4"); + &pxor ("xmm2","xmm3"); + &movdqa ("xmm3",&QWP(0x30,$inp)); + &pshufb ("xmm3","xmm1"); + &pxor ("xmm3","xmm2"); + &pshufb ("xmm3","xmm5"); + + &movdqa ("xmm2",&QWP(0x40,$inp)); + &pshufb ("xmm2","xmm4"); + &pxor ("xmm2","xmm3"); + &movdqa ("xmm3",&QWP(0x50,$inp)); + &pshufb ("xmm3","xmm1"); + &pxor ("xmm3","xmm2"); + &pshufb ("xmm3","xmm5"); + + &movdqa ("xmm2",&QWP(0x60,$inp)); + &pshufb ("xmm2","xmm4"); + &pxor ("xmm2","xmm3"); + &movdqa ("xmm3",&QWP(0x70,$inp)); + &pshufb ("xmm3","xmm1"); + &pxor ("xmm3","xmm2"); + + &add ($key,-16); + +&set_label("schedule_mangle_both"); + &movdqa ("xmm1",&QWP($k_sr,$const,$magic)); + &pshufb ("xmm3","xmm1"); + &add ($magic,-16); + &and ($magic,0x30); + &movdqu (&QWP(0,$key),"xmm3"); + &ret (); +&function_end_B("_vpaes_schedule_mangle"); + +# +# Interface to OpenSSL +# +&function_begin("${PREFIX}_set_encrypt_key"); + record_function_hit(5); + + &mov ($inp,&wparam(0)); # inp + &lea ($base,&DWP(-56,"esp")); + &mov ($round,&wparam(1)); # bits + &and ($base,-16); + &mov ($key,&wparam(2)); # key + &xchg ($base,"esp"); # alloca + &mov (&DWP(48,"esp"),$base); + + &mov ($base,$round); + &shr ($base,5); + &add ($base,5); + &mov (&DWP(240,$key),$base); # AES_KEY->rounds = nbits/32+5; + &mov ($magic,0x30); + &mov ($out,0); + + &lea ($const,&DWP(&label("_vpaes_consts")."+0x30-".&label("pic_point"))); + &call ("_vpaes_schedule_core"); +&set_label("pic_point"); + + &mov ("esp",&DWP(48,"esp")); + &xor ("eax","eax"); +&function_end("${PREFIX}_set_encrypt_key"); + +&function_begin("${PREFIX}_encrypt"); + record_function_hit(4); + + &lea ($const,&DWP(&label("_vpaes_consts")."+0x30-".&label("pic_point"))); + &call ("_vpaes_preheat"); +&set_label("pic_point"); + &mov ($inp,&wparam(0)); # inp + &lea ($base,&DWP(-56,"esp")); + &mov ($out,&wparam(1)); # out + &and ($base,-16); + &mov ($key,&wparam(2)); # key + &xchg ($base,"esp"); # alloca + &mov (&DWP(48,"esp"),$base); + + &movdqu ("xmm0",&QWP(0,$inp)); + &call ("_vpaes_encrypt_core"); + &movdqu (&QWP(0,$out),"xmm0"); + + &mov ("esp",&DWP(48,"esp")); +&function_end("${PREFIX}_encrypt"); + +&asm_finish(); + +close STDOUT or die "error closing STDOUT: $!"; diff --git a/http/vendor/ring/crypto/fipsmodule/aes/asm/vpaes-x86_64.pl b/http/vendor/ring/crypto/fipsmodule/aes/asm/vpaes-x86_64.pl new file mode 100644 index 0000000..09c1ba3 --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/aes/asm/vpaes-x86_64.pl @@ -0,0 +1,1023 @@ +#! /usr/bin/env perl +# Copyright 2011-2016 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +###################################################################### +## Constant-time SSSE3 AES core implementation. +## version 0.1 +## +## By Mike Hamburg (Stanford University), 2009 +## Public domain. +## +## For details see http://shiftleft.org/papers/vector_aes/ and +## http://crypto.stanford.edu/vpaes/. + +###################################################################### +# September 2011. +# +# Interface to OpenSSL as "almost" drop-in replacement for +# aes-x86_64.pl. "Almost" refers to the fact that AES_cbc_encrypt +# doesn't handle partial vectors (doesn't have to if called from +# EVP only). "Drop-in" implies that this module doesn't share key +# schedule structure with the original nor does it make assumption +# about its alignment... +# +# Performance summary. aes-x86_64.pl column lists large-block CBC +# encrypt/decrypt/with-hyper-threading-off(*) results in cycles per +# byte processed with 128-bit key, and vpaes-x86_64.pl column - +# [also large-block CBC] encrypt/decrypt. +# +# aes-x86_64.pl vpaes-x86_64.pl +# +# Core 2(**) 29.6/41.1/14.3 21.9/25.2(***) +# Nehalem 29.6/40.3/14.6 10.0/11.8 +# Atom 57.3/74.2/32.1 60.9/77.2(***) +# Silvermont 52.7/64.0/19.5 48.8/60.8(***) +# Goldmont 38.9/49.0/17.8 10.6/12.6 +# +# (*) "Hyper-threading" in the context refers rather to cache shared +# among multiple cores, than to specifically Intel HTT. As vast +# majority of contemporary cores share cache, slower code path +# is common place. In other words "with-hyper-threading-off" +# results are presented mostly for reference purposes. +# +# (**) "Core 2" refers to initial 65nm design, a.k.a. Conroe. +# +# (***) Less impressive improvement on Core 2 and Atom is due to slow +# pshufb, yet it's respectable +36%/62% improvement on Core 2 +# (as implied, over "hyper-threading-safe" code path). +# +# + +$flavour = shift; +$output = shift; +if ($flavour =~ /\./) { $output = $flavour; undef $flavour; } + +$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/); + +$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; +( $xlate="${dir}x86_64-xlate.pl" and -f $xlate ) or +( $xlate="${dir}../../../perlasm/x86_64-xlate.pl" and -f $xlate) or +die "can't locate x86_64-xlate.pl"; + +open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""; +*STDOUT=*OUT; + +$PREFIX="vpaes"; + +$code.=<<___; +.text + +## +## _aes_encrypt_core +## +## AES-encrypt %xmm0. +## +## Inputs: +## %xmm0 = input +## %xmm9-%xmm15 as in _vpaes_preheat +## (%rdx) = scheduled keys +## +## Output in %xmm0 +## Clobbers %xmm1-%xmm5, %r9, %r10, %r11, %rax +## Preserves %xmm6 - %xmm8 so you get some local vectors +## +## +.type _vpaes_encrypt_core,\@abi-omnipotent +.align 16 +_vpaes_encrypt_core: +.cfi_startproc + mov %rdx, %r9 + mov \$16, %r11 + mov 240(%rdx),%eax + movdqa %xmm9, %xmm1 + movdqa .Lk_ipt(%rip), %xmm2 # iptlo + pandn %xmm0, %xmm1 + movdqu (%r9), %xmm5 # round0 key + psrld \$4, %xmm1 + pand %xmm9, %xmm0 + pshufb %xmm0, %xmm2 + movdqa .Lk_ipt+16(%rip), %xmm0 # ipthi + pshufb %xmm1, %xmm0 + pxor %xmm5, %xmm2 + add \$16, %r9 + pxor %xmm2, %xmm0 + lea .Lk_mc_backward(%rip),%r10 + jmp .Lenc_entry + +.align 16 +.Lenc_loop: + # middle of middle round + movdqa %xmm13, %xmm4 # 4 : sb1u + movdqa %xmm12, %xmm0 # 0 : sb1t + pshufb %xmm2, %xmm4 # 4 = sb1u + pshufb %xmm3, %xmm0 # 0 = sb1t + pxor %xmm5, %xmm4 # 4 = sb1u + k + movdqa %xmm15, %xmm5 # 4 : sb2u + pxor %xmm4, %xmm0 # 0 = A + movdqa -0x40(%r11,%r10), %xmm1 # .Lk_mc_forward[] + pshufb %xmm2, %xmm5 # 4 = sb2u + movdqa (%r11,%r10), %xmm4 # .Lk_mc_backward[] + movdqa %xmm14, %xmm2 # 2 : sb2t + pshufb %xmm3, %xmm2 # 2 = sb2t + movdqa %xmm0, %xmm3 # 3 = A + pxor %xmm5, %xmm2 # 2 = 2A + pshufb %xmm1, %xmm0 # 0 = B + add \$16, %r9 # next key + pxor %xmm2, %xmm0 # 0 = 2A+B + pshufb %xmm4, %xmm3 # 3 = D + add \$16, %r11 # next mc + pxor %xmm0, %xmm3 # 3 = 2A+B+D + pshufb %xmm1, %xmm0 # 0 = 2B+C + and \$0x30, %r11 # ... mod 4 + sub \$1,%rax # nr-- + pxor %xmm3, %xmm0 # 0 = 2A+3B+C+D + +.Lenc_entry: + # top of round + movdqa %xmm9, %xmm1 # 1 : i + movdqa %xmm11, %xmm5 # 2 : a/k + pandn %xmm0, %xmm1 # 1 = i<<4 + psrld \$4, %xmm1 # 1 = i + pand %xmm9, %xmm0 # 0 = k + pshufb %xmm0, %xmm5 # 2 = a/k + movdqa %xmm10, %xmm3 # 3 : 1/i + pxor %xmm1, %xmm0 # 0 = j + pshufb %xmm1, %xmm3 # 3 = 1/i + movdqa %xmm10, %xmm4 # 4 : 1/j + pxor %xmm5, %xmm3 # 3 = iak = 1/i + a/k + pshufb %xmm0, %xmm4 # 4 = 1/j + movdqa %xmm10, %xmm2 # 2 : 1/iak + pxor %xmm5, %xmm4 # 4 = jak = 1/j + a/k + pshufb %xmm3, %xmm2 # 2 = 1/iak + movdqa %xmm10, %xmm3 # 3 : 1/jak + pxor %xmm0, %xmm2 # 2 = io + pshufb %xmm4, %xmm3 # 3 = 1/jak + movdqu (%r9), %xmm5 + pxor %xmm1, %xmm3 # 3 = jo + jnz .Lenc_loop + + # middle of last round + movdqa -0x60(%r10), %xmm4 # 3 : sbou .Lk_sbo + movdqa -0x50(%r10), %xmm0 # 0 : sbot .Lk_sbo+16 + pshufb %xmm2, %xmm4 # 4 = sbou + pxor %xmm5, %xmm4 # 4 = sb1u + k + pshufb %xmm3, %xmm0 # 0 = sb1t + movdqa 0x40(%r11,%r10), %xmm1 # .Lk_sr[] + pxor %xmm4, %xmm0 # 0 = A + pshufb %xmm1, %xmm0 + ret +.cfi_endproc +.size _vpaes_encrypt_core,.-_vpaes_encrypt_core + +## +## _aes_encrypt_core_2x +## +## AES-encrypt %xmm0 and %xmm6 in parallel. +## +## Inputs: +## %xmm0 and %xmm6 = input +## %xmm9 and %xmm10 as in _vpaes_preheat +## (%rdx) = scheduled keys +## +## Output in %xmm0 and %xmm6 +## Clobbers %xmm1-%xmm5, %xmm7, %xmm8, %xmm11-%xmm13, %r9, %r10, %r11, %rax +## Preserves %xmm14 and %xmm15 +## +## This function stitches two parallel instances of _vpaes_encrypt_core. x86_64 +## provides 16 XMM registers. _vpaes_encrypt_core computes over six registers +## (%xmm0-%xmm5) and additionally uses seven registers with preloaded constants +## from _vpaes_preheat (%xmm9-%xmm15). This does not quite fit two instances, +## so we spill some of %xmm9 through %xmm15 back to memory. We keep %xmm9 and +## %xmm10 in registers as these values are used several times in a row. The +## remainder are read once per round and are spilled to memory. This leaves two +## registers preserved for the caller. +## +## Thus, of the two _vpaes_encrypt_core instances, the first uses (%xmm0-%xmm5) +## as before. The second uses %xmm6-%xmm8,%xmm11-%xmm13. (Add 6 to %xmm2 and +## below. Add 8 to %xmm3 and up.) Instructions in the second instance are +## indented by one space. +## +## +.type _vpaes_encrypt_core_2x,\@abi-omnipotent +.align 16 +_vpaes_encrypt_core_2x: +.cfi_startproc + mov %rdx, %r9 + mov \$16, %r11 + mov 240(%rdx),%eax + movdqa %xmm9, %xmm1 + movdqa %xmm9, %xmm7 + movdqa .Lk_ipt(%rip), %xmm2 # iptlo + movdqa %xmm2, %xmm8 + pandn %xmm0, %xmm1 + pandn %xmm6, %xmm7 + movdqu (%r9), %xmm5 # round0 key + # Also use %xmm5 in the second instance. + psrld \$4, %xmm1 + psrld \$4, %xmm7 + pand %xmm9, %xmm0 + pand %xmm9, %xmm6 + pshufb %xmm0, %xmm2 + pshufb %xmm6, %xmm8 + movdqa .Lk_ipt+16(%rip), %xmm0 # ipthi + movdqa %xmm0, %xmm6 + pshufb %xmm1, %xmm0 + pshufb %xmm7, %xmm6 + pxor %xmm5, %xmm2 + pxor %xmm5, %xmm8 + add \$16, %r9 + pxor %xmm2, %xmm0 + pxor %xmm8, %xmm6 + lea .Lk_mc_backward(%rip),%r10 + jmp .Lenc2x_entry + +.align 16 +.Lenc2x_loop: + # middle of middle round + movdqa .Lk_sb1(%rip), %xmm4 # 4 : sb1u + movdqa .Lk_sb1+16(%rip),%xmm0 # 0 : sb1t + movdqa %xmm4, %xmm12 + movdqa %xmm0, %xmm6 + pshufb %xmm2, %xmm4 # 4 = sb1u + pshufb %xmm8, %xmm12 + pshufb %xmm3, %xmm0 # 0 = sb1t + pshufb %xmm11, %xmm6 + pxor %xmm5, %xmm4 # 4 = sb1u + k + pxor %xmm5, %xmm12 + movdqa .Lk_sb2(%rip), %xmm5 # 4 : sb2u + movdqa %xmm5, %xmm13 + pxor %xmm4, %xmm0 # 0 = A + pxor %xmm12, %xmm6 + movdqa -0x40(%r11,%r10), %xmm1 # .Lk_mc_forward[] + # Also use %xmm1 in the second instance. + pshufb %xmm2, %xmm5 # 4 = sb2u + pshufb %xmm8, %xmm13 + movdqa (%r11,%r10), %xmm4 # .Lk_mc_backward[] + # Also use %xmm4 in the second instance. + movdqa .Lk_sb2+16(%rip), %xmm2 # 2 : sb2t + movdqa %xmm2, %xmm8 + pshufb %xmm3, %xmm2 # 2 = sb2t + pshufb %xmm11, %xmm8 + movdqa %xmm0, %xmm3 # 3 = A + movdqa %xmm6, %xmm11 + pxor %xmm5, %xmm2 # 2 = 2A + pxor %xmm13, %xmm8 + pshufb %xmm1, %xmm0 # 0 = B + pshufb %xmm1, %xmm6 + add \$16, %r9 # next key + pxor %xmm2, %xmm0 # 0 = 2A+B + pxor %xmm8, %xmm6 + pshufb %xmm4, %xmm3 # 3 = D + pshufb %xmm4, %xmm11 + add \$16, %r11 # next mc + pxor %xmm0, %xmm3 # 3 = 2A+B+D + pxor %xmm6, %xmm11 + pshufb %xmm1, %xmm0 # 0 = 2B+C + pshufb %xmm1, %xmm6 + and \$0x30, %r11 # ... mod 4 + sub \$1,%rax # nr-- + pxor %xmm3, %xmm0 # 0 = 2A+3B+C+D + pxor %xmm11, %xmm6 + +.Lenc2x_entry: + # top of round + movdqa %xmm9, %xmm1 # 1 : i + movdqa %xmm9, %xmm7 + movdqa .Lk_inv+16(%rip), %xmm5 # 2 : a/k + movdqa %xmm5, %xmm13 + pandn %xmm0, %xmm1 # 1 = i<<4 + pandn %xmm6, %xmm7 + psrld \$4, %xmm1 # 1 = i + psrld \$4, %xmm7 + pand %xmm9, %xmm0 # 0 = k + pand %xmm9, %xmm6 + pshufb %xmm0, %xmm5 # 2 = a/k + pshufb %xmm6, %xmm13 + movdqa %xmm10, %xmm3 # 3 : 1/i + movdqa %xmm10, %xmm11 + pxor %xmm1, %xmm0 # 0 = j + pxor %xmm7, %xmm6 + pshufb %xmm1, %xmm3 # 3 = 1/i + pshufb %xmm7, %xmm11 + movdqa %xmm10, %xmm4 # 4 : 1/j + movdqa %xmm10, %xmm12 + pxor %xmm5, %xmm3 # 3 = iak = 1/i + a/k + pxor %xmm13, %xmm11 + pshufb %xmm0, %xmm4 # 4 = 1/j + pshufb %xmm6, %xmm12 + movdqa %xmm10, %xmm2 # 2 : 1/iak + movdqa %xmm10, %xmm8 + pxor %xmm5, %xmm4 # 4 = jak = 1/j + a/k + pxor %xmm13, %xmm12 + pshufb %xmm3, %xmm2 # 2 = 1/iak + pshufb %xmm11, %xmm8 + movdqa %xmm10, %xmm3 # 3 : 1/jak + movdqa %xmm10, %xmm11 + pxor %xmm0, %xmm2 # 2 = io + pxor %xmm6, %xmm8 + pshufb %xmm4, %xmm3 # 3 = 1/jak + pshufb %xmm12, %xmm11 + movdqu (%r9), %xmm5 + # Also use %xmm5 in the second instance. + pxor %xmm1, %xmm3 # 3 = jo + pxor %xmm7, %xmm11 + jnz .Lenc2x_loop + + # middle of last round + movdqa -0x60(%r10), %xmm4 # 3 : sbou .Lk_sbo + movdqa -0x50(%r10), %xmm0 # 0 : sbot .Lk_sbo+16 + movdqa %xmm4, %xmm12 + movdqa %xmm0, %xmm6 + pshufb %xmm2, %xmm4 # 4 = sbou + pshufb %xmm8, %xmm12 + pxor %xmm5, %xmm4 # 4 = sb1u + k + pxor %xmm5, %xmm12 + pshufb %xmm3, %xmm0 # 0 = sb1t + pshufb %xmm11, %xmm6 + movdqa 0x40(%r11,%r10), %xmm1 # .Lk_sr[] + # Also use %xmm1 in the second instance. + pxor %xmm4, %xmm0 # 0 = A + pxor %xmm12, %xmm6 + pshufb %xmm1, %xmm0 + pshufb %xmm1, %xmm6 + ret +.cfi_endproc +.size _vpaes_encrypt_core_2x,.-_vpaes_encrypt_core_2x + +######################################################## +## ## +## AES key schedule ## +## ## +######################################################## +.type _vpaes_schedule_core,\@abi-omnipotent +.align 16 +_vpaes_schedule_core: +.cfi_startproc + # rdi = key + # rsi = size in bits + # rdx = buffer + # rcx = direction. 0=encrypt, 1=decrypt + + call _vpaes_preheat # load the tables + movdqa .Lk_rcon(%rip), %xmm8 # load rcon + movdqu (%rdi), %xmm0 # load key (unaligned) + + # input transform + movdqa %xmm0, %xmm3 + lea .Lk_ipt(%rip), %r11 + call _vpaes_schedule_transform + movdqa %xmm0, %xmm7 + + lea .Lk_sr(%rip),%r10 + + # encrypting, output zeroth round key after transform + movdqu %xmm0, (%rdx) + +.Lschedule_go: + cmp \$192, %esi + ja .Lschedule_256 + # 192-bit key support was removed. + # 128: fall though + +## +## .schedule_128 +## +## 128-bit specific part of key schedule. +## +## This schedule is really simple, because all its parts +## are accomplished by the subroutines. +## +.Lschedule_128: + mov \$10, %esi + +.Loop_schedule_128: + call _vpaes_schedule_round + dec %rsi + jz .Lschedule_mangle_last + call _vpaes_schedule_mangle # write output + jmp .Loop_schedule_128 + +## +## .aes_schedule_256 +## +## 256-bit specific part of key schedule. +## +## The structure here is very similar to the 128-bit +## schedule, but with an additional "low side" in +## %xmm6. The low side's rounds are the same as the +## high side's, except no rcon and no rotation. +## +.align 16 +.Lschedule_256: + movdqu 16(%rdi),%xmm0 # load key part 2 (unaligned) + call _vpaes_schedule_transform # input transform + mov \$7, %esi + +.Loop_schedule_256: + call _vpaes_schedule_mangle # output low result + movdqa %xmm0, %xmm6 # save cur_lo in xmm6 + + # high round + call _vpaes_schedule_round + dec %rsi + jz .Lschedule_mangle_last + call _vpaes_schedule_mangle + + # low round. swap xmm7 and xmm6 + pshufd \$0xFF, %xmm0, %xmm0 + movdqa %xmm7, %xmm5 + movdqa %xmm6, %xmm7 + call _vpaes_schedule_low_round + movdqa %xmm5, %xmm7 + + jmp .Loop_schedule_256 + + +## +## .aes_schedule_mangle_last +## +## Mangler for last round of key schedule +## Mangles %xmm0 +## when encrypting, outputs out(%xmm0) ^ 63 +## when decrypting, outputs unskew(%xmm0) +## +## Always called right before return... jumps to cleanup and exits +## +.align 16 +.Lschedule_mangle_last: + # schedule last round key from xmm0 + lea .Lk_deskew(%rip),%r11 # prepare to deskew + + # encrypting + movdqa (%r8,%r10),%xmm1 + pshufb %xmm1, %xmm0 # output permute + lea .Lk_opt(%rip), %r11 # prepare to output transform + add \$32, %rdx + +.Lschedule_mangle_last_dec: + add \$-16, %rdx + pxor .Lk_s63(%rip), %xmm0 + call _vpaes_schedule_transform # output transform + movdqu %xmm0, (%rdx) # save last key + + # cleanup + pxor %xmm0, %xmm0 + pxor %xmm1, %xmm1 + pxor %xmm2, %xmm2 + pxor %xmm3, %xmm3 + pxor %xmm4, %xmm4 + pxor %xmm5, %xmm5 + pxor %xmm6, %xmm6 + pxor %xmm7, %xmm7 + ret +.cfi_endproc +.size _vpaes_schedule_core,.-_vpaes_schedule_core + +## +## .aes_schedule_round +## +## Runs one main round of the key schedule on %xmm0, %xmm7 +## +## Specifically, runs subbytes on the high dword of %xmm0 +## then rotates it by one byte and xors into the low dword of +## %xmm7. +## +## Adds rcon from low byte of %xmm8, then rotates %xmm8 for +## next rcon. +## +## Smears the dwords of %xmm7 by xoring the low into the +## second low, result into third, result into highest. +## +## Returns results in %xmm7 = %xmm0. +## Clobbers %xmm1-%xmm4, %r11. +## +.type _vpaes_schedule_round,\@abi-omnipotent +.align 16 +_vpaes_schedule_round: +.cfi_startproc + # extract rcon from xmm8 + pxor %xmm1, %xmm1 + palignr \$15, %xmm8, %xmm1 + palignr \$15, %xmm8, %xmm8 + pxor %xmm1, %xmm7 + + # rotate + pshufd \$0xFF, %xmm0, %xmm0 + palignr \$1, %xmm0, %xmm0 + + # fall through... + + # low round: same as high round, but no rotation and no rcon. +_vpaes_schedule_low_round: + # smear xmm7 + movdqa %xmm7, %xmm1 + pslldq \$4, %xmm7 + pxor %xmm1, %xmm7 + movdqa %xmm7, %xmm1 + pslldq \$8, %xmm7 + pxor %xmm1, %xmm7 + pxor .Lk_s63(%rip), %xmm7 + + # subbytes + movdqa %xmm9, %xmm1 + pandn %xmm0, %xmm1 + psrld \$4, %xmm1 # 1 = i + pand %xmm9, %xmm0 # 0 = k + movdqa %xmm11, %xmm2 # 2 : a/k + pshufb %xmm0, %xmm2 # 2 = a/k + pxor %xmm1, %xmm0 # 0 = j + movdqa %xmm10, %xmm3 # 3 : 1/i + pshufb %xmm1, %xmm3 # 3 = 1/i + pxor %xmm2, %xmm3 # 3 = iak = 1/i + a/k + movdqa %xmm10, %xmm4 # 4 : 1/j + pshufb %xmm0, %xmm4 # 4 = 1/j + pxor %xmm2, %xmm4 # 4 = jak = 1/j + a/k + movdqa %xmm10, %xmm2 # 2 : 1/iak + pshufb %xmm3, %xmm2 # 2 = 1/iak + pxor %xmm0, %xmm2 # 2 = io + movdqa %xmm10, %xmm3 # 3 : 1/jak + pshufb %xmm4, %xmm3 # 3 = 1/jak + pxor %xmm1, %xmm3 # 3 = jo + movdqa %xmm13, %xmm4 # 4 : sbou + pshufb %xmm2, %xmm4 # 4 = sbou + movdqa %xmm12, %xmm0 # 0 : sbot + pshufb %xmm3, %xmm0 # 0 = sb1t + pxor %xmm4, %xmm0 # 0 = sbox output + + # add in smeared stuff + pxor %xmm7, %xmm0 + movdqa %xmm0, %xmm7 + ret +.cfi_endproc +.size _vpaes_schedule_round,.-_vpaes_schedule_round + +## +## .aes_schedule_transform +## +## Linear-transform %xmm0 according to tables at (%r11) +## +## Requires that %xmm9 = 0x0F0F... as in preheat +## Output in %xmm0 +## Clobbers %xmm1, %xmm2 +## +.type _vpaes_schedule_transform,\@abi-omnipotent +.align 16 +_vpaes_schedule_transform: +.cfi_startproc + movdqa %xmm9, %xmm1 + pandn %xmm0, %xmm1 + psrld \$4, %xmm1 + pand %xmm9, %xmm0 + movdqa (%r11), %xmm2 # lo + pshufb %xmm0, %xmm2 + movdqa 16(%r11), %xmm0 # hi + pshufb %xmm1, %xmm0 + pxor %xmm2, %xmm0 + ret +.cfi_endproc +.size _vpaes_schedule_transform,.-_vpaes_schedule_transform + +## +## .aes_schedule_mangle +## +## Mangle xmm0 from (basis-transformed) standard version +## to our version. +## +## On encrypt, +## xor with 0x63 +## multiply by circulant 0,1,1,1 +## apply shiftrows transform +## +## On decrypt, +## xor with 0x63 +## multiply by "inverse mixcolumns" circulant E,B,D,9 +## deskew +## apply shiftrows transform +## +## +## Writes out to (%rdx), and increments or decrements it +## Keeps track of round number mod 4 in %r8 +## Preserves xmm0 +## Clobbers xmm1-xmm5 +## +.type _vpaes_schedule_mangle,\@abi-omnipotent +.align 16 +_vpaes_schedule_mangle: +.cfi_startproc + movdqa %xmm0, %xmm4 # save xmm0 for later + movdqa .Lk_mc_forward(%rip),%xmm5 + + # encrypting + add \$16, %rdx + pxor .Lk_s63(%rip),%xmm4 + pshufb %xmm5, %xmm4 + movdqa %xmm4, %xmm3 + pshufb %xmm5, %xmm4 + pxor %xmm4, %xmm3 + pshufb %xmm5, %xmm4 + pxor %xmm4, %xmm3 + +.Lschedule_mangle_both: + movdqa (%r8,%r10),%xmm1 + pshufb %xmm1,%xmm3 + add \$-16, %r8 + and \$0x30, %r8 + movdqu %xmm3, (%rdx) + ret +.cfi_endproc +.size _vpaes_schedule_mangle,.-_vpaes_schedule_mangle + +# +# Interface to OpenSSL +# +.globl ${PREFIX}_set_encrypt_key +.type ${PREFIX}_set_encrypt_key,\@function,3 +.align 16 +${PREFIX}_set_encrypt_key: +.cfi_startproc + _CET_ENDBR +#ifdef BORINGSSL_DISPATCH_TEST +.extern BORINGSSL_function_hit + movb \$1, BORINGSSL_function_hit+5(%rip) +#endif + +___ +$code.=<<___ if ($win64); + lea -0xb8(%rsp),%rsp + movaps %xmm6,0x10(%rsp) + movaps %xmm7,0x20(%rsp) + movaps %xmm8,0x30(%rsp) + movaps %xmm9,0x40(%rsp) + movaps %xmm10,0x50(%rsp) + movaps %xmm11,0x60(%rsp) + movaps %xmm12,0x70(%rsp) + movaps %xmm13,0x80(%rsp) + movaps %xmm14,0x90(%rsp) + movaps %xmm15,0xa0(%rsp) +.Lenc_key_body: +___ +$code.=<<___; + mov %esi,%eax + shr \$5,%eax + add \$5,%eax + mov %eax,240(%rdx) # AES_KEY->rounds = nbits/32+5; + + mov \$0,%ecx + mov \$0x30,%r8d + call _vpaes_schedule_core +___ +$code.=<<___ if ($win64); + movaps 0x10(%rsp),%xmm6 + movaps 0x20(%rsp),%xmm7 + movaps 0x30(%rsp),%xmm8 + movaps 0x40(%rsp),%xmm9 + movaps 0x50(%rsp),%xmm10 + movaps 0x60(%rsp),%xmm11 + movaps 0x70(%rsp),%xmm12 + movaps 0x80(%rsp),%xmm13 + movaps 0x90(%rsp),%xmm14 + movaps 0xa0(%rsp),%xmm15 + lea 0xb8(%rsp),%rsp +.Lenc_key_epilogue: +___ +$code.=<<___; + xor %eax,%eax + ret +.cfi_endproc +.size ${PREFIX}_set_encrypt_key,.-${PREFIX}_set_encrypt_key +___ +{ +my ($inp,$out,$blocks,$key,$ivp)=("%rdi","%rsi","%rdx","%rcx","%r8"); +# void vpaes_ctr32_encrypt_blocks(const uint8_t *inp, uint8_t *out, +# size_t blocks, const AES_KEY *key, +# const uint8_t ivp[16]); +$code.=<<___; +.globl ${PREFIX}_ctr32_encrypt_blocks +.type ${PREFIX}_ctr32_encrypt_blocks,\@function,5 +.align 16 +${PREFIX}_ctr32_encrypt_blocks: +.cfi_startproc + _CET_ENDBR + # _vpaes_encrypt_core and _vpaes_encrypt_core_2x expect the key in %rdx. + xchg $key, $blocks +___ +($blocks,$key)=($key,$blocks); +$code.=<<___; + test $blocks, $blocks + jz .Lctr32_abort +___ +$code.=<<___ if ($win64); + lea -0xb8(%rsp),%rsp + movaps %xmm6,0x10(%rsp) + movaps %xmm7,0x20(%rsp) + movaps %xmm8,0x30(%rsp) + movaps %xmm9,0x40(%rsp) + movaps %xmm10,0x50(%rsp) + movaps %xmm11,0x60(%rsp) + movaps %xmm12,0x70(%rsp) + movaps %xmm13,0x80(%rsp) + movaps %xmm14,0x90(%rsp) + movaps %xmm15,0xa0(%rsp) +.Lctr32_body: +___ +$code.=<<___; + movdqu ($ivp), %xmm0 # Load IV. + movdqa .Lctr_add_one(%rip), %xmm8 + sub $inp, $out # This allows only incrementing $inp. + call _vpaes_preheat + movdqa %xmm0, %xmm6 + pshufb .Lrev_ctr(%rip), %xmm6 + + test \$1, $blocks + jz .Lctr32_prep_loop + + # Handle one block so the remaining block count is even for + # _vpaes_encrypt_core_2x. + movdqu ($inp), %xmm7 # Load input. + call _vpaes_encrypt_core + pxor %xmm7, %xmm0 + paddd %xmm8, %xmm6 + movdqu %xmm0, ($out,$inp) + sub \$1, $blocks + lea 16($inp), $inp + jz .Lctr32_done + +.Lctr32_prep_loop: + # _vpaes_encrypt_core_2x leaves only %xmm14 and %xmm15 as spare + # registers. We maintain two byte-swapped counters in them. + movdqa %xmm6, %xmm14 + movdqa %xmm6, %xmm15 + paddd %xmm8, %xmm15 + +.Lctr32_loop: + movdqa .Lrev_ctr(%rip), %xmm1 # Set up counters. + movdqa %xmm14, %xmm0 + movdqa %xmm15, %xmm6 + pshufb %xmm1, %xmm0 + pshufb %xmm1, %xmm6 + call _vpaes_encrypt_core_2x + movdqu ($inp), %xmm1 # Load input. + movdqu 16($inp), %xmm2 + movdqa .Lctr_add_two(%rip), %xmm3 + pxor %xmm1, %xmm0 # XOR input. + pxor %xmm2, %xmm6 + paddd %xmm3, %xmm14 # Increment counters. + paddd %xmm3, %xmm15 + movdqu %xmm0, ($out,$inp) # Write output. + movdqu %xmm6, 16($out,$inp) + sub \$2, $blocks # Advance loop. + lea 32($inp), $inp + jnz .Lctr32_loop + +.Lctr32_done: +___ +$code.=<<___ if ($win64); + movaps 0x10(%rsp),%xmm6 + movaps 0x20(%rsp),%xmm7 + movaps 0x30(%rsp),%xmm8 + movaps 0x40(%rsp),%xmm9 + movaps 0x50(%rsp),%xmm10 + movaps 0x60(%rsp),%xmm11 + movaps 0x70(%rsp),%xmm12 + movaps 0x80(%rsp),%xmm13 + movaps 0x90(%rsp),%xmm14 + movaps 0xa0(%rsp),%xmm15 + lea 0xb8(%rsp),%rsp +.Lctr32_epilogue: +___ +$code.=<<___; +.Lctr32_abort: + ret +.cfi_endproc +.size ${PREFIX}_ctr32_encrypt_blocks,.-${PREFIX}_ctr32_encrypt_blocks +___ +} +$code.=<<___; +## +## _aes_preheat +## +## Fills register %r10 -> .aes_consts (so you can -fPIC) +## and %xmm9-%xmm15 as specified below. +## +.type _vpaes_preheat,\@abi-omnipotent +.align 16 +_vpaes_preheat: +.cfi_startproc + lea .Lk_s0F(%rip), %r10 + movdqa -0x20(%r10), %xmm10 # .Lk_inv + movdqa -0x10(%r10), %xmm11 # .Lk_inv+16 + movdqa 0x00(%r10), %xmm9 # .Lk_s0F + movdqa 0x30(%r10), %xmm13 # .Lk_sb1 + movdqa 0x40(%r10), %xmm12 # .Lk_sb1+16 + movdqa 0x50(%r10), %xmm15 # .Lk_sb2 + movdqa 0x60(%r10), %xmm14 # .Lk_sb2+16 + ret +.cfi_endproc +.size _vpaes_preheat,.-_vpaes_preheat +######################################################## +## ## +## Constants ## +## ## +######################################################## +.type _vpaes_consts,\@object +.section .rodata +.align 64 +_vpaes_consts: +.Lk_inv: # inv, inva + .quad 0x0E05060F0D080180, 0x040703090A0B0C02 + .quad 0x01040A060F0B0780, 0x030D0E0C02050809 + +.Lk_s0F: # s0F + .quad 0x0F0F0F0F0F0F0F0F, 0x0F0F0F0F0F0F0F0F + +.Lk_ipt: # input transform (lo, hi) + .quad 0xC2B2E8985A2A7000, 0xCABAE09052227808 + .quad 0x4C01307D317C4D00, 0xCD80B1FCB0FDCC81 + +.Lk_sb1: # sb1u, sb1t + .quad 0xB19BE18FCB503E00, 0xA5DF7A6E142AF544 + .quad 0x3618D415FAE22300, 0x3BF7CCC10D2ED9EF +.Lk_sb2: # sb2u, sb2t + .quad 0xE27A93C60B712400, 0x5EB7E955BC982FCD + .quad 0x69EB88400AE12900, 0xC2A163C8AB82234A +.Lk_sbo: # sbou, sbot + .quad 0xD0D26D176FBDC700, 0x15AABF7AC502A878 + .quad 0xCFE474A55FBB6A00, 0x8E1E90D1412B35FA + +.Lk_mc_forward: # mc_forward + .quad 0x0407060500030201, 0x0C0F0E0D080B0A09 + .quad 0x080B0A0904070605, 0x000302010C0F0E0D + .quad 0x0C0F0E0D080B0A09, 0x0407060500030201 + .quad 0x000302010C0F0E0D, 0x080B0A0904070605 + +.Lk_mc_backward:# mc_backward + .quad 0x0605040702010003, 0x0E0D0C0F0A09080B + .quad 0x020100030E0D0C0F, 0x0A09080B06050407 + .quad 0x0E0D0C0F0A09080B, 0x0605040702010003 + .quad 0x0A09080B06050407, 0x020100030E0D0C0F + +.Lk_sr: # sr + .quad 0x0706050403020100, 0x0F0E0D0C0B0A0908 + .quad 0x030E09040F0A0500, 0x0B06010C07020D08 + .quad 0x0F060D040B020900, 0x070E050C030A0108 + .quad 0x0B0E0104070A0D00, 0x0306090C0F020508 + +.Lk_rcon: # rcon + .quad 0x1F8391B9AF9DEEB6, 0x702A98084D7C7D81 + +.Lk_s63: # s63: all equal to 0x63 transformed + .quad 0x5B5B5B5B5B5B5B5B, 0x5B5B5B5B5B5B5B5B + +.Lk_opt: # output transform + .quad 0xFF9F4929D6B66000, 0xF7974121DEBE6808 + .quad 0x01EDBD5150BCEC00, 0xE10D5DB1B05C0CE0 + +.Lk_deskew: # deskew tables: inverts the sbox's "skew" + .quad 0x07E4A34047A4E300, 0x1DFEB95A5DBEF91A + .quad 0x5F36B5DC83EA6900, 0x2841C2ABF49D1E77 + +# .Lrev_ctr is a permutation which byte-swaps the counter portion of the IV. +.Lrev_ctr: + .quad 0x0706050403020100, 0x0c0d0e0f0b0a0908 +# .Lctr_add_* may be added to a byte-swapped xmm register to increment the +# counter. The register must be byte-swapped again to form the actual input. +.Lctr_add_one: + .quad 0x0000000000000000, 0x0000000100000000 +.Lctr_add_two: + .quad 0x0000000000000000, 0x0000000200000000 + +.asciz "Vector Permutation AES for x86_64/SSSE3, Mike Hamburg (Stanford University)" +.align 64 +.size _vpaes_consts,.-_vpaes_consts +.text +___ + +if ($win64) { +# EXCEPTION_DISPOSITION handler (EXCEPTION_RECORD *rec,ULONG64 frame, +# CONTEXT *context,DISPATCHER_CONTEXT *disp) +$rec="%rcx"; +$frame="%rdx"; +$context="%r8"; +$disp="%r9"; + +$code.=<<___; +.extern __imp_RtlVirtualUnwind +.type se_handler,\@abi-omnipotent +.align 16 +se_handler: + push %rsi + push %rdi + push %rbx + push %rbp + push %r12 + push %r13 + push %r14 + push %r15 + pushfq + sub \$64,%rsp + + mov 120($context),%rax # pull context->Rax + mov 248($context),%rbx # pull context->Rip + + mov 8($disp),%rsi # disp->ImageBase + mov 56($disp),%r11 # disp->HandlerData + + mov 0(%r11),%r10d # HandlerData[0] + lea (%rsi,%r10),%r10 # prologue label + cmp %r10,%rbx # context->RipRsp + + mov 4(%r11),%r10d # HandlerData[1] + lea (%rsi,%r10),%r10 # epilogue label + cmp %r10,%rbx # context->Rip>=epilogue label + jae .Lin_prologue + + lea 16(%rax),%rsi # %xmm save area + lea 512($context),%rdi # &context.Xmm6 + mov \$20,%ecx # 10*sizeof(%xmm0)/sizeof(%rax) + .long 0xa548f3fc # cld; rep movsq + lea 0xb8(%rax),%rax # adjust stack pointer + +.Lin_prologue: + mov 8(%rax),%rdi + mov 16(%rax),%rsi + mov %rax,152($context) # restore context->Rsp + mov %rsi,168($context) # restore context->Rsi + mov %rdi,176($context) # restore context->Rdi + + mov 40($disp),%rdi # disp->ContextRecord + mov $context,%rsi # context + mov \$`1232/8`,%ecx # sizeof(CONTEXT) + .long 0xa548f3fc # cld; rep movsq + + mov $disp,%rsi + xor %rcx,%rcx # arg1, UNW_FLAG_NHANDLER + mov 8(%rsi),%rdx # arg2, disp->ImageBase + mov 0(%rsi),%r8 # arg3, disp->ControlPc + mov 16(%rsi),%r9 # arg4, disp->FunctionEntry + mov 40(%rsi),%r10 # disp->ContextRecord + lea 56(%rsi),%r11 # &disp->HandlerData + lea 24(%rsi),%r12 # &disp->EstablisherFrame + mov %r10,32(%rsp) # arg5 + mov %r11,40(%rsp) # arg6 + mov %r12,48(%rsp) # arg7 + mov %rcx,56(%rsp) # arg8, (NULL) + call *__imp_RtlVirtualUnwind(%rip) + + mov \$1,%eax # ExceptionContinueSearch + add \$64,%rsp + popfq + pop %r15 + pop %r14 + pop %r13 + pop %r12 + pop %rbp + pop %rbx + pop %rdi + pop %rsi + ret +.size se_handler,.-se_handler + +.section .pdata +.align 4 + .rva .LSEH_begin_${PREFIX}_set_encrypt_key + .rva .LSEH_end_${PREFIX}_set_encrypt_key + .rva .LSEH_info_${PREFIX}_set_encrypt_key + + .rva .LSEH_begin_${PREFIX}_ctr32_encrypt_blocks + .rva .LSEH_end_${PREFIX}_ctr32_encrypt_blocks + .rva .LSEH_info_${PREFIX}_ctr32_encrypt_blocks + +.section .xdata +.align 8 +.LSEH_info_${PREFIX}_set_encrypt_key: + .byte 9,0,0,0 + .rva se_handler + .rva .Lenc_key_body,.Lenc_key_epilogue # HandlerData[] +.LSEH_info_${PREFIX}_ctr32_encrypt_blocks: + .byte 9,0,0,0 + .rva se_handler + .rva .Lctr32_body,.Lctr32_epilogue # HandlerData[] +___ +} + +$code =~ s/\`([^\`]*)\`/eval($1)/gem; + +print $code; + +close STDOUT or die "error closing STDOUT: $!"; diff --git a/http/vendor/ring/crypto/fipsmodule/bn/asm/armv4-mont.pl b/http/vendor/ring/crypto/fipsmodule/bn/asm/armv4-mont.pl new file mode 100644 index 0000000..acae4e5 --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/bn/asm/armv4-mont.pl @@ -0,0 +1,739 @@ +#! /usr/bin/env perl +# Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# ==================================================================== +# Written by Andy Polyakov for the OpenSSL +# project. +# ==================================================================== + +# January 2007. + +# Montgomery multiplication for ARMv4. +# +# Performance improvement naturally varies among CPU implementations +# and compilers. The code was observed to provide +65-35% improvement +# [depending on key length, less for longer keys] on ARM920T, and +# +115-80% on Intel IXP425. This is compared to pre-bn_mul_mont code +# base and compiler generated code with in-lined umull and even umlal +# instructions. The latter means that this code didn't really have an +# "advantage" of utilizing some "secret" instruction. +# +# The code is interoperable with Thumb ISA and is rather compact, less +# than 1/2KB. Windows CE port would be trivial, as it's exclusively +# about decorations, ABI and instruction syntax are identical. + +# November 2013 +# +# Add NEON code path, which handles lengths divisible by 8. RSA/DSA +# performance improvement on Cortex-A8 is ~45-100% depending on key +# length, more for longer keys. On Cortex-A15 the span is ~10-105%. +# On Snapdragon S4 improvement was measured to vary from ~70% to +# incredible ~380%, yes, 4.8x faster, for RSA4096 sign. But this is +# rather because original integer-only code seems to perform +# suboptimally on S4. Situation on Cortex-A9 is unfortunately +# different. It's being looked into, but the trouble is that +# performance for vectors longer than 256 bits is actually couple +# of percent worse than for integer-only code. The code is chosen +# for execution on all NEON-capable processors, because gain on +# others outweighs the marginal loss on Cortex-A9. + +# September 2015 +# +# Align Cortex-A9 performance with November 2013 improvements, i.e. +# NEON code is now ~20-105% faster than integer-only one on this +# processor. But this optimization further improved performance even +# on other processors: NEON code path is ~45-180% faster than original +# integer-only on Cortex-A8, ~10-210% on Cortex-A15, ~70-450% on +# Snapdragon S4. + +$flavour = shift; +if ($flavour=~/\w[\w\-]*\.\w+$/) { $output=$flavour; undef $flavour; } +else { while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {} } + +if ($flavour && $flavour ne "void") { + $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; + ( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or + ( $xlate="${dir}../../../perlasm/arm-xlate.pl" and -f $xlate) or + die "can't locate arm-xlate.pl"; + + open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""; + *STDOUT=*OUT; +} else { + open OUT,">$output"; + *STDOUT=*OUT; +} + +$num="r0"; # starts as num argument, but holds &tp[num-1] +$ap="r1"; +$bp="r2"; $bi="r2"; $rp="r2"; +$np="r3"; +$tp="r4"; +$aj="r5"; +$nj="r6"; +$tj="r7"; +$n0="r8"; +########### # r9 is reserved by ELF as platform specific, e.g. TLS pointer +$alo="r10"; # sl, gcc uses it to keep @GOT +$ahi="r11"; # fp +$nlo="r12"; # ip +########### # r13 is stack pointer +$nhi="r14"; # lr +########### # r15 is program counter + +#### argument block layout relative to &tp[num-1], a.k.a. $num +$_rp="$num,#12*4"; +# ap permanently resides in r1 +$_bp="$num,#13*4"; +# np permanently resides in r3 +$_n0="$num,#14*4"; +$_num="$num,#15*4"; $_bpend=$_num; + +$code=<<___; +@ Silence ARMv8 deprecated IT instruction warnings. This file is used by both +@ ARMv7 and ARMv8 processors and does not use ARMv8 instructions. +.arch armv7-a + +.text +#if defined(__thumb2__) +.syntax unified +.thumb +#else +.code 32 +#endif + +.global bn_mul_mont_nohw +.type bn_mul_mont_nohw,%function + +.align 5 +bn_mul_mont_nohw: + ldr ip,[sp,#4] @ load num + stmdb sp!,{r0,r2} @ sp points at argument block + cmp ip,#2 + mov $num,ip @ load num +#ifdef __thumb2__ + ittt lt +#endif + movlt r0,#0 + addlt sp,sp,#2*4 + blt .Labrt + + stmdb sp!,{r4-r12,lr} @ save 10 registers + + mov $num,$num,lsl#2 @ rescale $num for byte count + sub sp,sp,$num @ alloca(4*num) + sub sp,sp,#4 @ +extra dword + sub $num,$num,#4 @ "num=num-1" + add $tp,$bp,$num @ &bp[num-1] + + add $num,sp,$num @ $num to point at &tp[num-1] + ldr $n0,[$_n0] @ &n0 + ldr $bi,[$bp] @ bp[0] + ldr $aj,[$ap],#4 @ ap[0],ap++ + ldr $nj,[$np],#4 @ np[0],np++ + ldr $n0,[$n0] @ *n0 + str $tp,[$_bpend] @ save &bp[num] + + umull $alo,$ahi,$aj,$bi @ ap[0]*bp[0] + str $n0,[$_n0] @ save n0 value + mul $n0,$alo,$n0 @ "tp[0]"*n0 + mov $nlo,#0 + umlal $alo,$nlo,$nj,$n0 @ np[0]*n0+"t[0]" + mov $tp,sp + +.L1st: + ldr $aj,[$ap],#4 @ ap[j],ap++ + mov $alo,$ahi + ldr $nj,[$np],#4 @ np[j],np++ + mov $ahi,#0 + umlal $alo,$ahi,$aj,$bi @ ap[j]*bp[0] + mov $nhi,#0 + umlal $nlo,$nhi,$nj,$n0 @ np[j]*n0 + adds $nlo,$nlo,$alo + str $nlo,[$tp],#4 @ tp[j-1]=,tp++ + adc $nlo,$nhi,#0 + cmp $tp,$num + bne .L1st + + adds $nlo,$nlo,$ahi + ldr $tp,[$_bp] @ restore bp + mov $nhi,#0 + ldr $n0,[$_n0] @ restore n0 + adc $nhi,$nhi,#0 + str $nlo,[$num] @ tp[num-1]= + mov $tj,sp + str $nhi,[$num,#4] @ tp[num]= + +.Louter: + sub $tj,$num,$tj @ "original" $num-1 value + sub $ap,$ap,$tj @ "rewind" ap to &ap[1] + ldr $bi,[$tp,#4]! @ *(++bp) + sub $np,$np,$tj @ "rewind" np to &np[1] + ldr $aj,[$ap,#-4] @ ap[0] + ldr $alo,[sp] @ tp[0] + ldr $nj,[$np,#-4] @ np[0] + ldr $tj,[sp,#4] @ tp[1] + + mov $ahi,#0 + umlal $alo,$ahi,$aj,$bi @ ap[0]*bp[i]+tp[0] + str $tp,[$_bp] @ save bp + mul $n0,$alo,$n0 + mov $nlo,#0 + umlal $alo,$nlo,$nj,$n0 @ np[0]*n0+"tp[0]" + mov $tp,sp + +.Linner: + ldr $aj,[$ap],#4 @ ap[j],ap++ + adds $alo,$ahi,$tj @ +=tp[j] + ldr $nj,[$np],#4 @ np[j],np++ + mov $ahi,#0 + umlal $alo,$ahi,$aj,$bi @ ap[j]*bp[i] + mov $nhi,#0 + umlal $nlo,$nhi,$nj,$n0 @ np[j]*n0 + adc $ahi,$ahi,#0 + ldr $tj,[$tp,#8] @ tp[j+1] + adds $nlo,$nlo,$alo + str $nlo,[$tp],#4 @ tp[j-1]=,tp++ + adc $nlo,$nhi,#0 + cmp $tp,$num + bne .Linner + + adds $nlo,$nlo,$ahi + mov $nhi,#0 + ldr $tp,[$_bp] @ restore bp + adc $nhi,$nhi,#0 + ldr $n0,[$_n0] @ restore n0 + adds $nlo,$nlo,$tj + ldr $tj,[$_bpend] @ restore &bp[num] + adc $nhi,$nhi,#0 + str $nlo,[$num] @ tp[num-1]= + str $nhi,[$num,#4] @ tp[num]= + + cmp $tp,$tj +#ifdef __thumb2__ + itt ne +#endif + movne $tj,sp + bne .Louter + + ldr $rp,[$_rp] @ pull rp + mov $aj,sp + add $num,$num,#4 @ $num to point at &tp[num] + sub $aj,$num,$aj @ "original" num value + mov $tp,sp @ "rewind" $tp + mov $ap,$tp @ "borrow" $ap + sub $np,$np,$aj @ "rewind" $np to &np[0] + + subs $tj,$tj,$tj @ "clear" carry flag +.Lsub: ldr $tj,[$tp],#4 + ldr $nj,[$np],#4 + sbcs $tj,$tj,$nj @ tp[j]-np[j] + str $tj,[$rp],#4 @ rp[j]= + teq $tp,$num @ preserve carry + bne .Lsub + sbcs $nhi,$nhi,#0 @ upmost carry + mov $tp,sp @ "rewind" $tp + sub $rp,$rp,$aj @ "rewind" $rp + +.Lcopy: ldr $tj,[$tp] @ conditional copy + ldr $aj,[$rp] + str sp,[$tp],#4 @ zap tp +#ifdef __thumb2__ + it cc +#endif + movcc $aj,$tj + str $aj,[$rp],#4 + teq $tp,$num @ preserve carry + bne .Lcopy + + mov sp,$num + add sp,sp,#4 @ skip over tp[num+1] + ldmia sp!,{r4-r12,lr} @ restore registers + add sp,sp,#2*4 @ skip over {r0,r2} + mov r0,#1 +.Labrt: +#if __ARM_ARCH>=5 + ret @ bx lr +#else + tst lr,#1 + moveq pc,lr @ be binary compatible with V4, yet + bx lr @ interoperable with Thumb ISA:-) +#endif +.size bn_mul_mont_nohw,.-bn_mul_mont_nohw +___ +{ +my ($A0,$A1,$A2,$A3)=map("d$_",(0..3)); +my ($N0,$N1,$N2,$N3)=map("d$_",(4..7)); +my ($Z,$Temp)=("q4","q5"); +my @ACC=map("q$_",(6..13)); +my ($Bi,$Ni,$M0)=map("d$_",(28..31)); +my $zero="$Z#lo"; +my $temp="$Temp#lo"; + +my ($rptr,$aptr,$bptr,$nptr,$n0,$num)=map("r$_",(0..5)); +my ($tinptr,$toutptr,$inner,$outer,$bnptr)=map("r$_",(6..11)); + +$code.=<<___; +#if __ARM_MAX_ARCH__>=7 +.arch armv7-a +.fpu neon + +.global bn_mul8x_mont_neon +.type bn_mul8x_mont_neon,%function +.align 5 +bn_mul8x_mont_neon: + mov ip,sp + stmdb sp!,{r4-r11} + vstmdb sp!,{d8-d15} @ ABI specification says so + ldmia ip,{r4-r5} @ load rest of parameter block + mov ip,sp + + cmp $num,#8 + bhi .LNEON_8n + + @ special case for $num==8, everything is in register bank... + + vld1.32 {${Bi}[0]}, [$bptr,:32]! + veor $zero,$zero,$zero + sub $toutptr,sp,$num,lsl#4 + vld1.32 {$A0-$A3}, [$aptr]! @ can't specify :32 :-( + and $toutptr,$toutptr,#-64 + vld1.32 {${M0}[0]}, [$n0,:32] + mov sp,$toutptr @ alloca + vzip.16 $Bi,$zero + + vmull.u32 @ACC[0],$Bi,${A0}[0] + vmull.u32 @ACC[1],$Bi,${A0}[1] + vmull.u32 @ACC[2],$Bi,${A1}[0] + vshl.i64 $Ni,@ACC[0]#hi,#16 + vmull.u32 @ACC[3],$Bi,${A1}[1] + + vadd.u64 $Ni,$Ni,@ACC[0]#lo + veor $zero,$zero,$zero + vmul.u32 $Ni,$Ni,$M0 + + vmull.u32 @ACC[4],$Bi,${A2}[0] + vld1.32 {$N0-$N3}, [$nptr]! + vmull.u32 @ACC[5],$Bi,${A2}[1] + vmull.u32 @ACC[6],$Bi,${A3}[0] + vzip.16 $Ni,$zero + vmull.u32 @ACC[7],$Bi,${A3}[1] + + vmlal.u32 @ACC[0],$Ni,${N0}[0] + sub $outer,$num,#1 + vmlal.u32 @ACC[1],$Ni,${N0}[1] + vmlal.u32 @ACC[2],$Ni,${N1}[0] + vmlal.u32 @ACC[3],$Ni,${N1}[1] + + vmlal.u32 @ACC[4],$Ni,${N2}[0] + vmov $Temp,@ACC[0] + vmlal.u32 @ACC[5],$Ni,${N2}[1] + vmov @ACC[0],@ACC[1] + vmlal.u32 @ACC[6],$Ni,${N3}[0] + vmov @ACC[1],@ACC[2] + vmlal.u32 @ACC[7],$Ni,${N3}[1] + vmov @ACC[2],@ACC[3] + vmov @ACC[3],@ACC[4] + vshr.u64 $temp,$temp,#16 + vmov @ACC[4],@ACC[5] + vmov @ACC[5],@ACC[6] + vadd.u64 $temp,$temp,$Temp#hi + vmov @ACC[6],@ACC[7] + veor @ACC[7],@ACC[7] + vshr.u64 $temp,$temp,#16 + + b .LNEON_outer8 + +.align 4 +.LNEON_outer8: + vld1.32 {${Bi}[0]}, [$bptr,:32]! + veor $zero,$zero,$zero + vzip.16 $Bi,$zero + vadd.u64 @ACC[0]#lo,@ACC[0]#lo,$temp + + vmlal.u32 @ACC[0],$Bi,${A0}[0] + vmlal.u32 @ACC[1],$Bi,${A0}[1] + vmlal.u32 @ACC[2],$Bi,${A1}[0] + vshl.i64 $Ni,@ACC[0]#hi,#16 + vmlal.u32 @ACC[3],$Bi,${A1}[1] + + vadd.u64 $Ni,$Ni,@ACC[0]#lo + veor $zero,$zero,$zero + subs $outer,$outer,#1 + vmul.u32 $Ni,$Ni,$M0 + + vmlal.u32 @ACC[4],$Bi,${A2}[0] + vmlal.u32 @ACC[5],$Bi,${A2}[1] + vmlal.u32 @ACC[6],$Bi,${A3}[0] + vzip.16 $Ni,$zero + vmlal.u32 @ACC[7],$Bi,${A3}[1] + + vmlal.u32 @ACC[0],$Ni,${N0}[0] + vmlal.u32 @ACC[1],$Ni,${N0}[1] + vmlal.u32 @ACC[2],$Ni,${N1}[0] + vmlal.u32 @ACC[3],$Ni,${N1}[1] + + vmlal.u32 @ACC[4],$Ni,${N2}[0] + vmov $Temp,@ACC[0] + vmlal.u32 @ACC[5],$Ni,${N2}[1] + vmov @ACC[0],@ACC[1] + vmlal.u32 @ACC[6],$Ni,${N3}[0] + vmov @ACC[1],@ACC[2] + vmlal.u32 @ACC[7],$Ni,${N3}[1] + vmov @ACC[2],@ACC[3] + vmov @ACC[3],@ACC[4] + vshr.u64 $temp,$temp,#16 + vmov @ACC[4],@ACC[5] + vmov @ACC[5],@ACC[6] + vadd.u64 $temp,$temp,$Temp#hi + vmov @ACC[6],@ACC[7] + veor @ACC[7],@ACC[7] + vshr.u64 $temp,$temp,#16 + + bne .LNEON_outer8 + + vadd.u64 @ACC[0]#lo,@ACC[0]#lo,$temp + mov $toutptr,sp + vshr.u64 $temp,@ACC[0]#lo,#16 + mov $inner,$num + vadd.u64 @ACC[0]#hi,@ACC[0]#hi,$temp + add $tinptr,sp,#96 + vshr.u64 $temp,@ACC[0]#hi,#16 + vzip.16 @ACC[0]#lo,@ACC[0]#hi + + b .LNEON_tail_entry + +.align 4 +.LNEON_8n: + veor @ACC[0],@ACC[0],@ACC[0] + sub $toutptr,sp,#128 + veor @ACC[1],@ACC[1],@ACC[1] + sub $toutptr,$toutptr,$num,lsl#4 + veor @ACC[2],@ACC[2],@ACC[2] + and $toutptr,$toutptr,#-64 + veor @ACC[3],@ACC[3],@ACC[3] + mov sp,$toutptr @ alloca + veor @ACC[4],@ACC[4],@ACC[4] + add $toutptr,$toutptr,#256 + veor @ACC[5],@ACC[5],@ACC[5] + sub $inner,$num,#8 + veor @ACC[6],@ACC[6],@ACC[6] + veor @ACC[7],@ACC[7],@ACC[7] + +.LNEON_8n_init: + vst1.64 {@ACC[0]-@ACC[1]},[$toutptr,:256]! + subs $inner,$inner,#8 + vst1.64 {@ACC[2]-@ACC[3]},[$toutptr,:256]! + vst1.64 {@ACC[4]-@ACC[5]},[$toutptr,:256]! + vst1.64 {@ACC[6]-@ACC[7]},[$toutptr,:256]! + bne .LNEON_8n_init + + add $tinptr,sp,#256 + vld1.32 {$A0-$A3},[$aptr]! + add $bnptr,sp,#8 + vld1.32 {${M0}[0]},[$n0,:32] + mov $outer,$num + b .LNEON_8n_outer + +.align 4 +.LNEON_8n_outer: + vld1.32 {${Bi}[0]},[$bptr,:32]! @ *b++ + veor $zero,$zero,$zero + vzip.16 $Bi,$zero + add $toutptr,sp,#128 + vld1.32 {$N0-$N3},[$nptr]! + + vmlal.u32 @ACC[0],$Bi,${A0}[0] + vmlal.u32 @ACC[1],$Bi,${A0}[1] + veor $zero,$zero,$zero + vmlal.u32 @ACC[2],$Bi,${A1}[0] + vshl.i64 $Ni,@ACC[0]#hi,#16 + vmlal.u32 @ACC[3],$Bi,${A1}[1] + vadd.u64 $Ni,$Ni,@ACC[0]#lo + vmlal.u32 @ACC[4],$Bi,${A2}[0] + vmul.u32 $Ni,$Ni,$M0 + vmlal.u32 @ACC[5],$Bi,${A2}[1] + vst1.32 {$Bi},[sp,:64] @ put aside smashed b[8*i+0] + vmlal.u32 @ACC[6],$Bi,${A3}[0] + vzip.16 $Ni,$zero + vmlal.u32 @ACC[7],$Bi,${A3}[1] +___ +for ($i=0; $i<7;) { +$code.=<<___; + vld1.32 {${Bi}[0]},[$bptr,:32]! @ *b++ + vmlal.u32 @ACC[0],$Ni,${N0}[0] + veor $temp,$temp,$temp + vmlal.u32 @ACC[1],$Ni,${N0}[1] + vzip.16 $Bi,$temp + vmlal.u32 @ACC[2],$Ni,${N1}[0] + vshr.u64 @ACC[0]#lo,@ACC[0]#lo,#16 + vmlal.u32 @ACC[3],$Ni,${N1}[1] + vmlal.u32 @ACC[4],$Ni,${N2}[0] + vadd.u64 @ACC[0]#lo,@ACC[0]#lo,@ACC[0]#hi + vmlal.u32 @ACC[5],$Ni,${N2}[1] + vshr.u64 @ACC[0]#lo,@ACC[0]#lo,#16 + vmlal.u32 @ACC[6],$Ni,${N3}[0] + vmlal.u32 @ACC[7],$Ni,${N3}[1] + vadd.u64 @ACC[1]#lo,@ACC[1]#lo,@ACC[0]#lo + vst1.32 {$Ni},[$bnptr,:64]! @ put aside smashed m[8*i+$i] +___ + push(@ACC,shift(@ACC)); $i++; +$code.=<<___; + vmlal.u32 @ACC[0],$Bi,${A0}[0] + vld1.64 {@ACC[7]},[$tinptr,:128]! + vmlal.u32 @ACC[1],$Bi,${A0}[1] + veor $zero,$zero,$zero + vmlal.u32 @ACC[2],$Bi,${A1}[0] + vshl.i64 $Ni,@ACC[0]#hi,#16 + vmlal.u32 @ACC[3],$Bi,${A1}[1] + vadd.u64 $Ni,$Ni,@ACC[0]#lo + vmlal.u32 @ACC[4],$Bi,${A2}[0] + vmul.u32 $Ni,$Ni,$M0 + vmlal.u32 @ACC[5],$Bi,${A2}[1] + vst1.32 {$Bi},[$bnptr,:64]! @ put aside smashed b[8*i+$i] + vmlal.u32 @ACC[6],$Bi,${A3}[0] + vzip.16 $Ni,$zero + vmlal.u32 @ACC[7],$Bi,${A3}[1] +___ +} +$code.=<<___; + vld1.32 {$Bi},[sp,:64] @ pull smashed b[8*i+0] + vmlal.u32 @ACC[0],$Ni,${N0}[0] + vld1.32 {$A0-$A3},[$aptr]! + vmlal.u32 @ACC[1],$Ni,${N0}[1] + vmlal.u32 @ACC[2],$Ni,${N1}[0] + vshr.u64 @ACC[0]#lo,@ACC[0]#lo,#16 + vmlal.u32 @ACC[3],$Ni,${N1}[1] + vmlal.u32 @ACC[4],$Ni,${N2}[0] + vadd.u64 @ACC[0]#lo,@ACC[0]#lo,@ACC[0]#hi + vmlal.u32 @ACC[5],$Ni,${N2}[1] + vshr.u64 @ACC[0]#lo,@ACC[0]#lo,#16 + vmlal.u32 @ACC[6],$Ni,${N3}[0] + vmlal.u32 @ACC[7],$Ni,${N3}[1] + vadd.u64 @ACC[1]#lo,@ACC[1]#lo,@ACC[0]#lo + vst1.32 {$Ni},[$bnptr,:64] @ put aside smashed m[8*i+$i] + add $bnptr,sp,#8 @ rewind +___ + push(@ACC,shift(@ACC)); +$code.=<<___; + sub $inner,$num,#8 + b .LNEON_8n_inner + +.align 4 +.LNEON_8n_inner: + subs $inner,$inner,#8 + vmlal.u32 @ACC[0],$Bi,${A0}[0] + vld1.64 {@ACC[7]},[$tinptr,:128] + vmlal.u32 @ACC[1],$Bi,${A0}[1] + vld1.32 {$Ni},[$bnptr,:64]! @ pull smashed m[8*i+0] + vmlal.u32 @ACC[2],$Bi,${A1}[0] + vld1.32 {$N0-$N3},[$nptr]! + vmlal.u32 @ACC[3],$Bi,${A1}[1] + it ne + addne $tinptr,$tinptr,#16 @ don't advance in last iteration + vmlal.u32 @ACC[4],$Bi,${A2}[0] + vmlal.u32 @ACC[5],$Bi,${A2}[1] + vmlal.u32 @ACC[6],$Bi,${A3}[0] + vmlal.u32 @ACC[7],$Bi,${A3}[1] +___ +for ($i=1; $i<8; $i++) { +$code.=<<___; + vld1.32 {$Bi},[$bnptr,:64]! @ pull smashed b[8*i+$i] + vmlal.u32 @ACC[0],$Ni,${N0}[0] + vmlal.u32 @ACC[1],$Ni,${N0}[1] + vmlal.u32 @ACC[2],$Ni,${N1}[0] + vmlal.u32 @ACC[3],$Ni,${N1}[1] + vmlal.u32 @ACC[4],$Ni,${N2}[0] + vmlal.u32 @ACC[5],$Ni,${N2}[1] + vmlal.u32 @ACC[6],$Ni,${N3}[0] + vmlal.u32 @ACC[7],$Ni,${N3}[1] + vst1.64 {@ACC[0]},[$toutptr,:128]! +___ + push(@ACC,shift(@ACC)); +$code.=<<___; + vmlal.u32 @ACC[0],$Bi,${A0}[0] + vld1.64 {@ACC[7]},[$tinptr,:128] + vmlal.u32 @ACC[1],$Bi,${A0}[1] + vld1.32 {$Ni},[$bnptr,:64]! @ pull smashed m[8*i+$i] + vmlal.u32 @ACC[2],$Bi,${A1}[0] + it ne + addne $tinptr,$tinptr,#16 @ don't advance in last iteration + vmlal.u32 @ACC[3],$Bi,${A1}[1] + vmlal.u32 @ACC[4],$Bi,${A2}[0] + vmlal.u32 @ACC[5],$Bi,${A2}[1] + vmlal.u32 @ACC[6],$Bi,${A3}[0] + vmlal.u32 @ACC[7],$Bi,${A3}[1] +___ +} +$code.=<<___; + it eq + subeq $aptr,$aptr,$num,lsl#2 @ rewind + vmlal.u32 @ACC[0],$Ni,${N0}[0] + vld1.32 {$Bi},[sp,:64] @ pull smashed b[8*i+0] + vmlal.u32 @ACC[1],$Ni,${N0}[1] + vld1.32 {$A0-$A3},[$aptr]! + vmlal.u32 @ACC[2],$Ni,${N1}[0] + add $bnptr,sp,#8 @ rewind + vmlal.u32 @ACC[3],$Ni,${N1}[1] + vmlal.u32 @ACC[4],$Ni,${N2}[0] + vmlal.u32 @ACC[5],$Ni,${N2}[1] + vmlal.u32 @ACC[6],$Ni,${N3}[0] + vst1.64 {@ACC[0]},[$toutptr,:128]! + vmlal.u32 @ACC[7],$Ni,${N3}[1] + + bne .LNEON_8n_inner +___ + push(@ACC,shift(@ACC)); +$code.=<<___; + add $tinptr,sp,#128 + vst1.64 {@ACC[0]-@ACC[1]},[$toutptr,:256]! + veor q2,q2,q2 @ $N0-$N1 + vst1.64 {@ACC[2]-@ACC[3]},[$toutptr,:256]! + veor q3,q3,q3 @ $N2-$N3 + vst1.64 {@ACC[4]-@ACC[5]},[$toutptr,:256]! + vst1.64 {@ACC[6]},[$toutptr,:128] + + subs $outer,$outer,#8 + vld1.64 {@ACC[0]-@ACC[1]},[$tinptr,:256]! + vld1.64 {@ACC[2]-@ACC[3]},[$tinptr,:256]! + vld1.64 {@ACC[4]-@ACC[5]},[$tinptr,:256]! + vld1.64 {@ACC[6]-@ACC[7]},[$tinptr,:256]! + + itt ne + subne $nptr,$nptr,$num,lsl#2 @ rewind + bne .LNEON_8n_outer + + add $toutptr,sp,#128 + vst1.64 {q2-q3}, [sp,:256]! @ start wiping stack frame + vshr.u64 $temp,@ACC[0]#lo,#16 + vst1.64 {q2-q3},[sp,:256]! + vadd.u64 @ACC[0]#hi,@ACC[0]#hi,$temp + vst1.64 {q2-q3}, [sp,:256]! + vshr.u64 $temp,@ACC[0]#hi,#16 + vst1.64 {q2-q3}, [sp,:256]! + vzip.16 @ACC[0]#lo,@ACC[0]#hi + + mov $inner,$num + b .LNEON_tail_entry + +.align 4 +.LNEON_tail: + vadd.u64 @ACC[0]#lo,@ACC[0]#lo,$temp + vshr.u64 $temp,@ACC[0]#lo,#16 + vld1.64 {@ACC[2]-@ACC[3]}, [$tinptr, :256]! + vadd.u64 @ACC[0]#hi,@ACC[0]#hi,$temp + vld1.64 {@ACC[4]-@ACC[5]}, [$tinptr, :256]! + vshr.u64 $temp,@ACC[0]#hi,#16 + vld1.64 {@ACC[6]-@ACC[7]}, [$tinptr, :256]! + vzip.16 @ACC[0]#lo,@ACC[0]#hi + +.LNEON_tail_entry: +___ +for ($i=1; $i<8; $i++) { +$code.=<<___; + vadd.u64 @ACC[1]#lo,@ACC[1]#lo,$temp + vst1.32 {@ACC[0]#lo[0]}, [$toutptr, :32]! + vshr.u64 $temp,@ACC[1]#lo,#16 + vadd.u64 @ACC[1]#hi,@ACC[1]#hi,$temp + vshr.u64 $temp,@ACC[1]#hi,#16 + vzip.16 @ACC[1]#lo,@ACC[1]#hi +___ + push(@ACC,shift(@ACC)); +} + push(@ACC,shift(@ACC)); +$code.=<<___; + vld1.64 {@ACC[0]-@ACC[1]}, [$tinptr, :256]! + subs $inner,$inner,#8 + vst1.32 {@ACC[7]#lo[0]}, [$toutptr, :32]! + bne .LNEON_tail + + vst1.32 {${temp}[0]}, [$toutptr, :32] @ top-most bit + sub $nptr,$nptr,$num,lsl#2 @ rewind $nptr + subs $aptr,sp,#0 @ clear carry flag + add $bptr,sp,$num,lsl#2 + +.LNEON_sub: + ldmia $aptr!, {r4-r7} + ldmia $nptr!, {r8-r11} + sbcs r8, r4,r8 + sbcs r9, r5,r9 + sbcs r10,r6,r10 + sbcs r11,r7,r11 + teq $aptr,$bptr @ preserves carry + stmia $rptr!, {r8-r11} + bne .LNEON_sub + + ldr r10, [$aptr] @ load top-most bit + mov r11,sp + veor q0,q0,q0 + sub r11,$bptr,r11 @ this is num*4 + veor q1,q1,q1 + mov $aptr,sp + sub $rptr,$rptr,r11 @ rewind $rptr + mov $nptr,$bptr @ second 3/4th of frame + sbcs r10,r10,#0 @ result is carry flag + +.LNEON_copy_n_zap: + ldmia $aptr!, {r4-r7} + ldmia $rptr, {r8-r11} + it cc + movcc r8, r4 + vst1.64 {q0-q1}, [$nptr,:256]! @ wipe + itt cc + movcc r9, r5 + movcc r10,r6 + vst1.64 {q0-q1}, [$nptr,:256]! @ wipe + it cc + movcc r11,r7 + ldmia $aptr, {r4-r7} + stmia $rptr!, {r8-r11} + sub $aptr,$aptr,#16 + ldmia $rptr, {r8-r11} + it cc + movcc r8, r4 + vst1.64 {q0-q1}, [$aptr,:256]! @ wipe + itt cc + movcc r9, r5 + movcc r10,r6 + vst1.64 {q0-q1}, [$nptr,:256]! @ wipe + it cc + movcc r11,r7 + teq $aptr,$bptr @ preserves carry + stmia $rptr!, {r8-r11} + bne .LNEON_copy_n_zap + + mov sp,ip + vldmia sp!,{d8-d15} + ldmia sp!,{r4-r11} + ret @ bx lr +.size bn_mul8x_mont_neon,.-bn_mul8x_mont_neon +#endif +___ +} +$code.=<<___; +.asciz "Montgomery multiplication for ARMv4/NEON, CRYPTOGAMS by " +___ + +foreach (split("\n",$code)) { + s/\`([^\`]*)\`/eval $1/ge; + + s/\bq([0-9]+)#(lo|hi)/sprintf "d%d",2*$1+($2 eq "hi")/ge or + s/\bret\b/bx lr/g or + s/\bbx\s+lr\b/.word\t0xe12fff1e/g; # make it possible to compile with -march=armv4 + + print $_,"\n"; +} + +close STDOUT or die "error closing STDOUT: $!"; diff --git a/http/vendor/ring/crypto/fipsmodule/bn/asm/armv8-mont.pl b/http/vendor/ring/crypto/fipsmodule/bn/asm/armv8-mont.pl new file mode 100644 index 0000000..0c32c8b --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/bn/asm/armv8-mont.pl @@ -0,0 +1,1517 @@ +#! /usr/bin/env perl +# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# ==================================================================== +# Written by Andy Polyakov for the OpenSSL +# project. +# ==================================================================== + +# March 2015 +# +# "Teaser" Montgomery multiplication module for ARMv8. Needs more +# work. While it does improve RSA sign performance by 20-30% (less for +# longer keys) on most processors, for some reason RSA2048 is not +# faster and RSA4096 goes 15-20% slower on Cortex-A57. Multiplication +# instruction issue rate is limited on processor in question, meaning +# that dedicated squaring procedure is a must. Well, actually all +# contemporary AArch64 processors seem to have limited multiplication +# issue rate, i.e. they can't issue multiplication every cycle, which +# explains moderate improvement coefficients in comparison to +# compiler-generated code. Recall that compiler is instructed to use +# umulh and therefore uses same amount of multiplication instructions +# to do the job. Assembly's edge is to minimize number of "collateral" +# instructions and of course instruction scheduling. +# +# April 2015 +# +# Squaring procedure that handles lengths divisible by 8 improves +# RSA/DSA performance by 25-40-60% depending on processor and key +# length. Overall improvement coefficients are always positive in +# comparison to compiler-generated code. On Cortex-A57 improvement +# is still modest on longest key lengths, while others exhibit e.g. +# 50-70% improvement for RSA4096 sign. RSA2048 sign is ~25% faster +# on Cortex-A57 and ~60-100% faster on others. + +$flavour = shift; +$output = shift; + +$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; +( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or +( $xlate="${dir}../../../perlasm/arm-xlate.pl" and -f $xlate) or +die "can't locate arm-xlate.pl"; + +open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""; +*STDOUT=*OUT; + +($lo0,$hi0,$aj,$m0,$alo,$ahi, + $lo1,$hi1,$nj,$m1,$nlo,$nhi, + $ovf, $i,$j,$tp,$tj) = map("x$_",6..17,19..24); + +# void bn_mul_mont_nohw( +$rp="x0"; # BN_ULONG *rp, +$ap="x1"; # const BN_ULONG *ap, +$bp="x2"; # const BN_ULONG *bp, +$np="x3"; # const BN_ULONG *np, +$n0="x4"; # const BN_ULONG *n0, +$num="x5"; # size_t num); + +$code.=<<___; +.text + +.globl bn_mul_mont_nohw +.type bn_mul_mont_nohw,%function +.align 5 +bn_mul_mont_nohw: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-64]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + + ldr $m0,[$bp],#8 // bp[0] + sub $tp,sp,$num,lsl#3 + ldp $hi0,$aj,[$ap],#16 // ap[0..1] + lsl $num,$num,#3 + ldr $n0,[$n0] // *n0 + and $tp,$tp,#-16 // ABI says so + ldp $hi1,$nj,[$np],#16 // np[0..1] + + mul $lo0,$hi0,$m0 // ap[0]*bp[0] + sub $j,$num,#16 // j=num-2 + umulh $hi0,$hi0,$m0 + mul $alo,$aj,$m0 // ap[1]*bp[0] + umulh $ahi,$aj,$m0 + + mul $m1,$lo0,$n0 // "tp[0]"*n0 + mov sp,$tp // alloca + + // (*) mul $lo1,$hi1,$m1 // np[0]*m1 + umulh $hi1,$hi1,$m1 + mul $nlo,$nj,$m1 // np[1]*m1 + // (*) adds $lo1,$lo1,$lo0 // discarded + // (*) As for removal of first multiplication and addition + // instructions. The outcome of first addition is + // guaranteed to be zero, which leaves two computationally + // significant outcomes: it either carries or not. Then + // question is when does it carry? Is there alternative + // way to deduce it? If you follow operations, you can + // observe that condition for carry is quite simple: + // $lo0 being non-zero. So that carry can be calculated + // by adding -1 to $lo0. That's what next instruction does. + subs xzr,$lo0,#1 // (*) + umulh $nhi,$nj,$m1 + adc $hi1,$hi1,xzr + cbz $j,.L1st_skip + +.L1st: + ldr $aj,[$ap],#8 + adds $lo0,$alo,$hi0 + sub $j,$j,#8 // j-- + adc $hi0,$ahi,xzr + + ldr $nj,[$np],#8 + adds $lo1,$nlo,$hi1 + mul $alo,$aj,$m0 // ap[j]*bp[0] + adc $hi1,$nhi,xzr + umulh $ahi,$aj,$m0 + + adds $lo1,$lo1,$lo0 + mul $nlo,$nj,$m1 // np[j]*m1 + adc $hi1,$hi1,xzr + umulh $nhi,$nj,$m1 + str $lo1,[$tp],#8 // tp[j-1] + cbnz $j,.L1st + +.L1st_skip: + adds $lo0,$alo,$hi0 + sub $ap,$ap,$num // rewind $ap + adc $hi0,$ahi,xzr + + adds $lo1,$nlo,$hi1 + sub $np,$np,$num // rewind $np + adc $hi1,$nhi,xzr + + adds $lo1,$lo1,$lo0 + sub $i,$num,#8 // i=num-1 + adcs $hi1,$hi1,$hi0 + + adc $ovf,xzr,xzr // upmost overflow bit + stp $lo1,$hi1,[$tp] + +.Louter: + ldr $m0,[$bp],#8 // bp[i] + ldp $hi0,$aj,[$ap],#16 + ldr $tj,[sp] // tp[0] + add $tp,sp,#8 + + mul $lo0,$hi0,$m0 // ap[0]*bp[i] + sub $j,$num,#16 // j=num-2 + umulh $hi0,$hi0,$m0 + ldp $hi1,$nj,[$np],#16 + mul $alo,$aj,$m0 // ap[1]*bp[i] + adds $lo0,$lo0,$tj + umulh $ahi,$aj,$m0 + adc $hi0,$hi0,xzr + + mul $m1,$lo0,$n0 + sub $i,$i,#8 // i-- + + // (*) mul $lo1,$hi1,$m1 // np[0]*m1 + umulh $hi1,$hi1,$m1 + mul $nlo,$nj,$m1 // np[1]*m1 + // (*) adds $lo1,$lo1,$lo0 + subs xzr,$lo0,#1 // (*) + umulh $nhi,$nj,$m1 + cbz $j,.Linner_skip + +.Linner: + ldr $aj,[$ap],#8 + adc $hi1,$hi1,xzr + ldr $tj,[$tp],#8 // tp[j] + adds $lo0,$alo,$hi0 + sub $j,$j,#8 // j-- + adc $hi0,$ahi,xzr + + adds $lo1,$nlo,$hi1 + ldr $nj,[$np],#8 + adc $hi1,$nhi,xzr + + mul $alo,$aj,$m0 // ap[j]*bp[i] + adds $lo0,$lo0,$tj + umulh $ahi,$aj,$m0 + adc $hi0,$hi0,xzr + + mul $nlo,$nj,$m1 // np[j]*m1 + adds $lo1,$lo1,$lo0 + umulh $nhi,$nj,$m1 + str $lo1,[$tp,#-16] // tp[j-1] + cbnz $j,.Linner + +.Linner_skip: + ldr $tj,[$tp],#8 // tp[j] + adc $hi1,$hi1,xzr + adds $lo0,$alo,$hi0 + sub $ap,$ap,$num // rewind $ap + adc $hi0,$ahi,xzr + + adds $lo1,$nlo,$hi1 + sub $np,$np,$num // rewind $np + adcs $hi1,$nhi,$ovf + adc $ovf,xzr,xzr + + adds $lo0,$lo0,$tj + adc $hi0,$hi0,xzr + + adds $lo1,$lo1,$lo0 + adcs $hi1,$hi1,$hi0 + adc $ovf,$ovf,xzr // upmost overflow bit + stp $lo1,$hi1,[$tp,#-16] + + cbnz $i,.Louter + + // Final step. We see if result is larger than modulus, and + // if it is, subtract the modulus. But comparison implies + // subtraction. So we subtract modulus, see if it borrowed, + // and conditionally copy original value. + ldr $tj,[sp] // tp[0] + add $tp,sp,#8 + ldr $nj,[$np],#8 // np[0] + subs $j,$num,#8 // j=num-1 and clear borrow + mov $ap,$rp +.Lsub: + sbcs $aj,$tj,$nj // tp[j]-np[j] + ldr $tj,[$tp],#8 + sub $j,$j,#8 // j-- + ldr $nj,[$np],#8 + str $aj,[$ap],#8 // rp[j]=tp[j]-np[j] + cbnz $j,.Lsub + + sbcs $aj,$tj,$nj + sbcs $ovf,$ovf,xzr // did it borrow? + str $aj,[$ap],#8 // rp[num-1] + + ldr $tj,[sp] // tp[0] + add $tp,sp,#8 + ldr $aj,[$rp],#8 // rp[0] + sub $num,$num,#8 // num-- + nop +.Lcond_copy: + sub $num,$num,#8 // num-- + csel $nj,$tj,$aj,lo // did it borrow? + ldr $tj,[$tp],#8 + ldr $aj,[$rp],#8 + str xzr,[$tp,#-16] // wipe tp + str $nj,[$rp,#-16] + cbnz $num,.Lcond_copy + + csel $nj,$tj,$aj,lo + str xzr,[$tp,#-8] // wipe tp + str $nj,[$rp,#-8] + + ldp x19,x20,[x29,#16] + mov sp,x29 + ldp x21,x22,[x29,#32] + mov x0,#1 + ldp x23,x24,[x29,#48] + ldr x29,[sp],#64 + AARCH64_VALIDATE_LINK_REGISTER + ret +.size bn_mul_mont_nohw,.-bn_mul_mont_nohw +___ +{ +######################################################################## +# Following is ARMv8 adaptation of sqrx8x_mont from x86_64-mont5 module. + +my ($a0,$a1,$a2,$a3,$a4,$a5,$a6,$a7)=map("x$_",(6..13)); +my ($t0,$t1,$t2,$t3)=map("x$_",(14..17)); +my ($acc0,$acc1,$acc2,$acc3,$acc4,$acc5,$acc6,$acc7)=map("x$_",(19..26)); +my ($cnt,$carry,$topmost)=("x27","x28","x30"); +my ($tp,$ap_end,$na0)=($bp,$np,$carry); + +$code.=<<___; +.globl bn_sqr8x_mont +.type bn_sqr8x_mont,%function +.align 5 +bn_sqr8x_mont: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-128]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + stp x27,x28,[sp,#80] + stp $rp,$np,[sp,#96] // offload rp and np + + ldp $a0,$a1,[$ap,#8*0] + ldp $a2,$a3,[$ap,#8*2] + ldp $a4,$a5,[$ap,#8*4] + ldp $a6,$a7,[$ap,#8*6] + + sub $tp,sp,$num,lsl#4 + lsl $num,$num,#3 + ldr $n0,[$n0] // *n0 + mov sp,$tp // alloca + sub $cnt,$num,#8*8 + b .Lsqr8x_zero_start + +.Lsqr8x_zero: + sub $cnt,$cnt,#8*8 + stp xzr,xzr,[$tp,#8*0] + stp xzr,xzr,[$tp,#8*2] + stp xzr,xzr,[$tp,#8*4] + stp xzr,xzr,[$tp,#8*6] +.Lsqr8x_zero_start: + stp xzr,xzr,[$tp,#8*8] + stp xzr,xzr,[$tp,#8*10] + stp xzr,xzr,[$tp,#8*12] + stp xzr,xzr,[$tp,#8*14] + add $tp,$tp,#8*16 + cbnz $cnt,.Lsqr8x_zero + + add $ap_end,$ap,$num + add $ap,$ap,#8*8 + mov $acc0,xzr + mov $acc1,xzr + mov $acc2,xzr + mov $acc3,xzr + mov $acc4,xzr + mov $acc5,xzr + mov $acc6,xzr + mov $acc7,xzr + mov $tp,sp + str $n0,[x29,#112] // offload n0 + + // Multiply everything but a[i]*a[i] +.align 4 +.Lsqr8x_outer_loop: + // a[1]a[0] (i) + // a[2]a[0] + // a[3]a[0] + // a[4]a[0] + // a[5]a[0] + // a[6]a[0] + // a[7]a[0] + // a[2]a[1] (ii) + // a[3]a[1] + // a[4]a[1] + // a[5]a[1] + // a[6]a[1] + // a[7]a[1] + // a[3]a[2] (iii) + // a[4]a[2] + // a[5]a[2] + // a[6]a[2] + // a[7]a[2] + // a[4]a[3] (iv) + // a[5]a[3] + // a[6]a[3] + // a[7]a[3] + // a[5]a[4] (v) + // a[6]a[4] + // a[7]a[4] + // a[6]a[5] (vi) + // a[7]a[5] + // a[7]a[6] (vii) + + mul $t0,$a1,$a0 // lo(a[1..7]*a[0]) (i) + mul $t1,$a2,$a0 + mul $t2,$a3,$a0 + mul $t3,$a4,$a0 + adds $acc1,$acc1,$t0 // t[1]+lo(a[1]*a[0]) + mul $t0,$a5,$a0 + adcs $acc2,$acc2,$t1 + mul $t1,$a6,$a0 + adcs $acc3,$acc3,$t2 + mul $t2,$a7,$a0 + adcs $acc4,$acc4,$t3 + umulh $t3,$a1,$a0 // hi(a[1..7]*a[0]) + adcs $acc5,$acc5,$t0 + umulh $t0,$a2,$a0 + adcs $acc6,$acc6,$t1 + umulh $t1,$a3,$a0 + adcs $acc7,$acc7,$t2 + umulh $t2,$a4,$a0 + stp $acc0,$acc1,[$tp],#8*2 // t[0..1] + adc $acc0,xzr,xzr // t[8] + adds $acc2,$acc2,$t3 // t[2]+lo(a[1]*a[0]) + umulh $t3,$a5,$a0 + adcs $acc3,$acc3,$t0 + umulh $t0,$a6,$a0 + adcs $acc4,$acc4,$t1 + umulh $t1,$a7,$a0 + adcs $acc5,$acc5,$t2 + mul $t2,$a2,$a1 // lo(a[2..7]*a[1]) (ii) + adcs $acc6,$acc6,$t3 + mul $t3,$a3,$a1 + adcs $acc7,$acc7,$t0 + mul $t0,$a4,$a1 + adc $acc0,$acc0,$t1 + + mul $t1,$a5,$a1 + adds $acc3,$acc3,$t2 + mul $t2,$a6,$a1 + adcs $acc4,$acc4,$t3 + mul $t3,$a7,$a1 + adcs $acc5,$acc5,$t0 + umulh $t0,$a2,$a1 // hi(a[2..7]*a[1]) + adcs $acc6,$acc6,$t1 + umulh $t1,$a3,$a1 + adcs $acc7,$acc7,$t2 + umulh $t2,$a4,$a1 + adcs $acc0,$acc0,$t3 + umulh $t3,$a5,$a1 + stp $acc2,$acc3,[$tp],#8*2 // t[2..3] + adc $acc1,xzr,xzr // t[9] + adds $acc4,$acc4,$t0 + umulh $t0,$a6,$a1 + adcs $acc5,$acc5,$t1 + umulh $t1,$a7,$a1 + adcs $acc6,$acc6,$t2 + mul $t2,$a3,$a2 // lo(a[3..7]*a[2]) (iii) + adcs $acc7,$acc7,$t3 + mul $t3,$a4,$a2 + adcs $acc0,$acc0,$t0 + mul $t0,$a5,$a2 + adc $acc1,$acc1,$t1 + + mul $t1,$a6,$a2 + adds $acc5,$acc5,$t2 + mul $t2,$a7,$a2 + adcs $acc6,$acc6,$t3 + umulh $t3,$a3,$a2 // hi(a[3..7]*a[2]) + adcs $acc7,$acc7,$t0 + umulh $t0,$a4,$a2 + adcs $acc0,$acc0,$t1 + umulh $t1,$a5,$a2 + adcs $acc1,$acc1,$t2 + umulh $t2,$a6,$a2 + stp $acc4,$acc5,[$tp],#8*2 // t[4..5] + adc $acc2,xzr,xzr // t[10] + adds $acc6,$acc6,$t3 + umulh $t3,$a7,$a2 + adcs $acc7,$acc7,$t0 + mul $t0,$a4,$a3 // lo(a[4..7]*a[3]) (iv) + adcs $acc0,$acc0,$t1 + mul $t1,$a5,$a3 + adcs $acc1,$acc1,$t2 + mul $t2,$a6,$a3 + adc $acc2,$acc2,$t3 + + mul $t3,$a7,$a3 + adds $acc7,$acc7,$t0 + umulh $t0,$a4,$a3 // hi(a[4..7]*a[3]) + adcs $acc0,$acc0,$t1 + umulh $t1,$a5,$a3 + adcs $acc1,$acc1,$t2 + umulh $t2,$a6,$a3 + adcs $acc2,$acc2,$t3 + umulh $t3,$a7,$a3 + stp $acc6,$acc7,[$tp],#8*2 // t[6..7] + adc $acc3,xzr,xzr // t[11] + adds $acc0,$acc0,$t0 + mul $t0,$a5,$a4 // lo(a[5..7]*a[4]) (v) + adcs $acc1,$acc1,$t1 + mul $t1,$a6,$a4 + adcs $acc2,$acc2,$t2 + mul $t2,$a7,$a4 + adc $acc3,$acc3,$t3 + + umulh $t3,$a5,$a4 // hi(a[5..7]*a[4]) + adds $acc1,$acc1,$t0 + umulh $t0,$a6,$a4 + adcs $acc2,$acc2,$t1 + umulh $t1,$a7,$a4 + adcs $acc3,$acc3,$t2 + mul $t2,$a6,$a5 // lo(a[6..7]*a[5]) (vi) + adc $acc4,xzr,xzr // t[12] + adds $acc2,$acc2,$t3 + mul $t3,$a7,$a5 + adcs $acc3,$acc3,$t0 + umulh $t0,$a6,$a5 // hi(a[6..7]*a[5]) + adc $acc4,$acc4,$t1 + + umulh $t1,$a7,$a5 + adds $acc3,$acc3,$t2 + mul $t2,$a7,$a6 // lo(a[7]*a[6]) (vii) + adcs $acc4,$acc4,$t3 + umulh $t3,$a7,$a6 // hi(a[7]*a[6]) + adc $acc5,xzr,xzr // t[13] + adds $acc4,$acc4,$t0 + sub $cnt,$ap_end,$ap // done yet? + adc $acc5,$acc5,$t1 + + adds $acc5,$acc5,$t2 + sub $t0,$ap_end,$num // rewinded ap + adc $acc6,xzr,xzr // t[14] + add $acc6,$acc6,$t3 + + cbz $cnt,.Lsqr8x_outer_break + + mov $n0,$a0 + ldp $a0,$a1,[$tp,#8*0] + ldp $a2,$a3,[$tp,#8*2] + ldp $a4,$a5,[$tp,#8*4] + ldp $a6,$a7,[$tp,#8*6] + adds $acc0,$acc0,$a0 + adcs $acc1,$acc1,$a1 + ldp $a0,$a1,[$ap,#8*0] + adcs $acc2,$acc2,$a2 + adcs $acc3,$acc3,$a3 + ldp $a2,$a3,[$ap,#8*2] + adcs $acc4,$acc4,$a4 + adcs $acc5,$acc5,$a5 + ldp $a4,$a5,[$ap,#8*4] + adcs $acc6,$acc6,$a6 + mov $rp,$ap + adcs $acc7,xzr,$a7 + ldp $a6,$a7,[$ap,#8*6] + add $ap,$ap,#8*8 + //adc $carry,xzr,xzr // moved below + mov $cnt,#-8*8 + + // a[8]a[0] + // a[9]a[0] + // a[a]a[0] + // a[b]a[0] + // a[c]a[0] + // a[d]a[0] + // a[e]a[0] + // a[f]a[0] + // a[8]a[1] + // a[f]a[1]........................ + // a[8]a[2] + // a[f]a[2]........................ + // a[8]a[3] + // a[f]a[3]........................ + // a[8]a[4] + // a[f]a[4]........................ + // a[8]a[5] + // a[f]a[5]........................ + // a[8]a[6] + // a[f]a[6]........................ + // a[8]a[7] + // a[f]a[7]........................ +.Lsqr8x_mul: + mul $t0,$a0,$n0 + adc $carry,xzr,xzr // carry bit, modulo-scheduled + mul $t1,$a1,$n0 + add $cnt,$cnt,#8 + mul $t2,$a2,$n0 + mul $t3,$a3,$n0 + adds $acc0,$acc0,$t0 + mul $t0,$a4,$n0 + adcs $acc1,$acc1,$t1 + mul $t1,$a5,$n0 + adcs $acc2,$acc2,$t2 + mul $t2,$a6,$n0 + adcs $acc3,$acc3,$t3 + mul $t3,$a7,$n0 + adcs $acc4,$acc4,$t0 + umulh $t0,$a0,$n0 + adcs $acc5,$acc5,$t1 + umulh $t1,$a1,$n0 + adcs $acc6,$acc6,$t2 + umulh $t2,$a2,$n0 + adcs $acc7,$acc7,$t3 + umulh $t3,$a3,$n0 + adc $carry,$carry,xzr + str $acc0,[$tp],#8 + adds $acc0,$acc1,$t0 + umulh $t0,$a4,$n0 + adcs $acc1,$acc2,$t1 + umulh $t1,$a5,$n0 + adcs $acc2,$acc3,$t2 + umulh $t2,$a6,$n0 + adcs $acc3,$acc4,$t3 + umulh $t3,$a7,$n0 + ldr $n0,[$rp,$cnt] + adcs $acc4,$acc5,$t0 + adcs $acc5,$acc6,$t1 + adcs $acc6,$acc7,$t2 + adcs $acc7,$carry,$t3 + //adc $carry,xzr,xzr // moved above + cbnz $cnt,.Lsqr8x_mul + // note that carry flag is guaranteed + // to be zero at this point + cmp $ap,$ap_end // done yet? + b.eq .Lsqr8x_break + + ldp $a0,$a1,[$tp,#8*0] + ldp $a2,$a3,[$tp,#8*2] + ldp $a4,$a5,[$tp,#8*4] + ldp $a6,$a7,[$tp,#8*6] + adds $acc0,$acc0,$a0 + ldr $n0,[$rp,#-8*8] + adcs $acc1,$acc1,$a1 + ldp $a0,$a1,[$ap,#8*0] + adcs $acc2,$acc2,$a2 + adcs $acc3,$acc3,$a3 + ldp $a2,$a3,[$ap,#8*2] + adcs $acc4,$acc4,$a4 + adcs $acc5,$acc5,$a5 + ldp $a4,$a5,[$ap,#8*4] + adcs $acc6,$acc6,$a6 + mov $cnt,#-8*8 + adcs $acc7,$acc7,$a7 + ldp $a6,$a7,[$ap,#8*6] + add $ap,$ap,#8*8 + //adc $carry,xzr,xzr // moved above + b .Lsqr8x_mul + +.align 4 +.Lsqr8x_break: + ldp $a0,$a1,[$rp,#8*0] + add $ap,$rp,#8*8 + ldp $a2,$a3,[$rp,#8*2] + sub $t0,$ap_end,$ap // is it last iteration? + ldp $a4,$a5,[$rp,#8*4] + sub $t1,$tp,$t0 + ldp $a6,$a7,[$rp,#8*6] + cbz $t0,.Lsqr8x_outer_loop + + stp $acc0,$acc1,[$tp,#8*0] + ldp $acc0,$acc1,[$t1,#8*0] + stp $acc2,$acc3,[$tp,#8*2] + ldp $acc2,$acc3,[$t1,#8*2] + stp $acc4,$acc5,[$tp,#8*4] + ldp $acc4,$acc5,[$t1,#8*4] + stp $acc6,$acc7,[$tp,#8*6] + mov $tp,$t1 + ldp $acc6,$acc7,[$t1,#8*6] + b .Lsqr8x_outer_loop + +.align 4 +.Lsqr8x_outer_break: + // Now multiply above result by 2 and add a[n-1]*a[n-1]|...|a[0]*a[0] + ldp $a1,$a3,[$t0,#8*0] // recall that $t0 is &a[0] + ldp $t1,$t2,[sp,#8*1] + ldp $a5,$a7,[$t0,#8*2] + add $ap,$t0,#8*4 + ldp $t3,$t0,[sp,#8*3] + + stp $acc0,$acc1,[$tp,#8*0] + mul $acc0,$a1,$a1 + stp $acc2,$acc3,[$tp,#8*2] + umulh $a1,$a1,$a1 + stp $acc4,$acc5,[$tp,#8*4] + mul $a2,$a3,$a3 + stp $acc6,$acc7,[$tp,#8*6] + mov $tp,sp + umulh $a3,$a3,$a3 + adds $acc1,$a1,$t1,lsl#1 + extr $t1,$t2,$t1,#63 + sub $cnt,$num,#8*4 + +.Lsqr4x_shift_n_add: + adcs $acc2,$a2,$t1 + extr $t2,$t3,$t2,#63 + sub $cnt,$cnt,#8*4 + adcs $acc3,$a3,$t2 + ldp $t1,$t2,[$tp,#8*5] + mul $a4,$a5,$a5 + ldp $a1,$a3,[$ap],#8*2 + umulh $a5,$a5,$a5 + mul $a6,$a7,$a7 + umulh $a7,$a7,$a7 + extr $t3,$t0,$t3,#63 + stp $acc0,$acc1,[$tp,#8*0] + adcs $acc4,$a4,$t3 + extr $t0,$t1,$t0,#63 + stp $acc2,$acc3,[$tp,#8*2] + adcs $acc5,$a5,$t0 + ldp $t3,$t0,[$tp,#8*7] + extr $t1,$t2,$t1,#63 + adcs $acc6,$a6,$t1 + extr $t2,$t3,$t2,#63 + adcs $acc7,$a7,$t2 + ldp $t1,$t2,[$tp,#8*9] + mul $a0,$a1,$a1 + ldp $a5,$a7,[$ap],#8*2 + umulh $a1,$a1,$a1 + mul $a2,$a3,$a3 + umulh $a3,$a3,$a3 + stp $acc4,$acc5,[$tp,#8*4] + extr $t3,$t0,$t3,#63 + stp $acc6,$acc7,[$tp,#8*6] + add $tp,$tp,#8*8 + adcs $acc0,$a0,$t3 + extr $t0,$t1,$t0,#63 + adcs $acc1,$a1,$t0 + ldp $t3,$t0,[$tp,#8*3] + extr $t1,$t2,$t1,#63 + cbnz $cnt,.Lsqr4x_shift_n_add +___ +my ($np,$np_end)=($ap,$ap_end); +$code.=<<___; + ldp $np,$n0,[x29,#104] // pull np and n0 + + adcs $acc2,$a2,$t1 + extr $t2,$t3,$t2,#63 + adcs $acc3,$a3,$t2 + ldp $t1,$t2,[$tp,#8*5] + mul $a4,$a5,$a5 + umulh $a5,$a5,$a5 + stp $acc0,$acc1,[$tp,#8*0] + mul $a6,$a7,$a7 + umulh $a7,$a7,$a7 + stp $acc2,$acc3,[$tp,#8*2] + extr $t3,$t0,$t3,#63 + adcs $acc4,$a4,$t3 + extr $t0,$t1,$t0,#63 + ldp $acc0,$acc1,[sp,#8*0] + adcs $acc5,$a5,$t0 + extr $t1,$t2,$t1,#63 + ldp $a0,$a1,[$np,#8*0] + adcs $acc6,$a6,$t1 + extr $t2,xzr,$t2,#63 + ldp $a2,$a3,[$np,#8*2] + adc $acc7,$a7,$t2 + ldp $a4,$a5,[$np,#8*4] + + // Reduce by 512 bits per iteration + mul $na0,$n0,$acc0 // t[0]*n0 + ldp $a6,$a7,[$np,#8*6] + add $np_end,$np,$num + ldp $acc2,$acc3,[sp,#8*2] + stp $acc4,$acc5,[$tp,#8*4] + ldp $acc4,$acc5,[sp,#8*4] + stp $acc6,$acc7,[$tp,#8*6] + ldp $acc6,$acc7,[sp,#8*6] + add $np,$np,#8*8 + mov $topmost,xzr // initial top-most carry + mov $tp,sp + mov $cnt,#8 + +.Lsqr8x_reduction: + // (*) mul $t0,$a0,$na0 // lo(n[0-7])*lo(t[0]*n0) + mul $t1,$a1,$na0 + sub $cnt,$cnt,#1 + mul $t2,$a2,$na0 + str $na0,[$tp],#8 // put aside t[0]*n0 for tail processing + mul $t3,$a3,$na0 + // (*) adds xzr,$acc0,$t0 + subs xzr,$acc0,#1 // (*) + mul $t0,$a4,$na0 + adcs $acc0,$acc1,$t1 + mul $t1,$a5,$na0 + adcs $acc1,$acc2,$t2 + mul $t2,$a6,$na0 + adcs $acc2,$acc3,$t3 + mul $t3,$a7,$na0 + adcs $acc3,$acc4,$t0 + umulh $t0,$a0,$na0 // hi(n[0-7])*lo(t[0]*n0) + adcs $acc4,$acc5,$t1 + umulh $t1,$a1,$na0 + adcs $acc5,$acc6,$t2 + umulh $t2,$a2,$na0 + adcs $acc6,$acc7,$t3 + umulh $t3,$a3,$na0 + adc $acc7,xzr,xzr + adds $acc0,$acc0,$t0 + umulh $t0,$a4,$na0 + adcs $acc1,$acc1,$t1 + umulh $t1,$a5,$na0 + adcs $acc2,$acc2,$t2 + umulh $t2,$a6,$na0 + adcs $acc3,$acc3,$t3 + umulh $t3,$a7,$na0 + mul $na0,$n0,$acc0 // next t[0]*n0 + adcs $acc4,$acc4,$t0 + adcs $acc5,$acc5,$t1 + adcs $acc6,$acc6,$t2 + adc $acc7,$acc7,$t3 + cbnz $cnt,.Lsqr8x_reduction + + ldp $t0,$t1,[$tp,#8*0] + ldp $t2,$t3,[$tp,#8*2] + mov $rp,$tp + sub $cnt,$np_end,$np // done yet? + adds $acc0,$acc0,$t0 + adcs $acc1,$acc1,$t1 + ldp $t0,$t1,[$tp,#8*4] + adcs $acc2,$acc2,$t2 + adcs $acc3,$acc3,$t3 + ldp $t2,$t3,[$tp,#8*6] + adcs $acc4,$acc4,$t0 + adcs $acc5,$acc5,$t1 + adcs $acc6,$acc6,$t2 + adcs $acc7,$acc7,$t3 + //adc $carry,xzr,xzr // moved below + cbz $cnt,.Lsqr8x8_post_condition + + ldr $n0,[$tp,#-8*8] + ldp $a0,$a1,[$np,#8*0] + ldp $a2,$a3,[$np,#8*2] + ldp $a4,$a5,[$np,#8*4] + mov $cnt,#-8*8 + ldp $a6,$a7,[$np,#8*6] + add $np,$np,#8*8 + +.Lsqr8x_tail: + mul $t0,$a0,$n0 + adc $carry,xzr,xzr // carry bit, modulo-scheduled + mul $t1,$a1,$n0 + add $cnt,$cnt,#8 + mul $t2,$a2,$n0 + mul $t3,$a3,$n0 + adds $acc0,$acc0,$t0 + mul $t0,$a4,$n0 + adcs $acc1,$acc1,$t1 + mul $t1,$a5,$n0 + adcs $acc2,$acc2,$t2 + mul $t2,$a6,$n0 + adcs $acc3,$acc3,$t3 + mul $t3,$a7,$n0 + adcs $acc4,$acc4,$t0 + umulh $t0,$a0,$n0 + adcs $acc5,$acc5,$t1 + umulh $t1,$a1,$n0 + adcs $acc6,$acc6,$t2 + umulh $t2,$a2,$n0 + adcs $acc7,$acc7,$t3 + umulh $t3,$a3,$n0 + adc $carry,$carry,xzr + str $acc0,[$tp],#8 + adds $acc0,$acc1,$t0 + umulh $t0,$a4,$n0 + adcs $acc1,$acc2,$t1 + umulh $t1,$a5,$n0 + adcs $acc2,$acc3,$t2 + umulh $t2,$a6,$n0 + adcs $acc3,$acc4,$t3 + umulh $t3,$a7,$n0 + ldr $n0,[$rp,$cnt] + adcs $acc4,$acc5,$t0 + adcs $acc5,$acc6,$t1 + adcs $acc6,$acc7,$t2 + adcs $acc7,$carry,$t3 + //adc $carry,xzr,xzr // moved above + cbnz $cnt,.Lsqr8x_tail + // note that carry flag is guaranteed + // to be zero at this point + ldp $a0,$a1,[$tp,#8*0] + sub $cnt,$np_end,$np // done yet? + sub $t2,$np_end,$num // rewinded np + ldp $a2,$a3,[$tp,#8*2] + ldp $a4,$a5,[$tp,#8*4] + ldp $a6,$a7,[$tp,#8*6] + cbz $cnt,.Lsqr8x_tail_break + + ldr $n0,[$rp,#-8*8] + adds $acc0,$acc0,$a0 + adcs $acc1,$acc1,$a1 + ldp $a0,$a1,[$np,#8*0] + adcs $acc2,$acc2,$a2 + adcs $acc3,$acc3,$a3 + ldp $a2,$a3,[$np,#8*2] + adcs $acc4,$acc4,$a4 + adcs $acc5,$acc5,$a5 + ldp $a4,$a5,[$np,#8*4] + adcs $acc6,$acc6,$a6 + mov $cnt,#-8*8 + adcs $acc7,$acc7,$a7 + ldp $a6,$a7,[$np,#8*6] + add $np,$np,#8*8 + //adc $carry,xzr,xzr // moved above + b .Lsqr8x_tail + +.align 4 +.Lsqr8x_tail_break: + ldr $n0,[x29,#112] // pull n0 + add $cnt,$tp,#8*8 // end of current t[num] window + + subs xzr,$topmost,#1 // "move" top-most carry to carry bit + adcs $t0,$acc0,$a0 + adcs $t1,$acc1,$a1 + ldp $acc0,$acc1,[$rp,#8*0] + adcs $acc2,$acc2,$a2 + ldp $a0,$a1,[$t2,#8*0] // recall that $t2 is &n[0] + adcs $acc3,$acc3,$a3 + ldp $a2,$a3,[$t2,#8*2] + adcs $acc4,$acc4,$a4 + adcs $acc5,$acc5,$a5 + ldp $a4,$a5,[$t2,#8*4] + adcs $acc6,$acc6,$a6 + adcs $acc7,$acc7,$a7 + ldp $a6,$a7,[$t2,#8*6] + add $np,$t2,#8*8 + adc $topmost,xzr,xzr // top-most carry + mul $na0,$n0,$acc0 + stp $t0,$t1,[$tp,#8*0] + stp $acc2,$acc3,[$tp,#8*2] + ldp $acc2,$acc3,[$rp,#8*2] + stp $acc4,$acc5,[$tp,#8*4] + ldp $acc4,$acc5,[$rp,#8*4] + cmp $cnt,x29 // did we hit the bottom? + stp $acc6,$acc7,[$tp,#8*6] + mov $tp,$rp // slide the window + ldp $acc6,$acc7,[$rp,#8*6] + mov $cnt,#8 + b.ne .Lsqr8x_reduction + + // Final step. We see if result is larger than modulus, and + // if it is, subtract the modulus. But comparison implies + // subtraction. So we subtract modulus, see if it borrowed, + // and conditionally copy original value. + ldr $rp,[x29,#96] // pull rp + add $tp,$tp,#8*8 + subs $t0,$acc0,$a0 + sbcs $t1,$acc1,$a1 + sub $cnt,$num,#8*8 + mov $ap_end,$rp // $rp copy + +.Lsqr8x_sub: + sbcs $t2,$acc2,$a2 + ldp $a0,$a1,[$np,#8*0] + sbcs $t3,$acc3,$a3 + stp $t0,$t1,[$rp,#8*0] + sbcs $t0,$acc4,$a4 + ldp $a2,$a3,[$np,#8*2] + sbcs $t1,$acc5,$a5 + stp $t2,$t3,[$rp,#8*2] + sbcs $t2,$acc6,$a6 + ldp $a4,$a5,[$np,#8*4] + sbcs $t3,$acc7,$a7 + ldp $a6,$a7,[$np,#8*6] + add $np,$np,#8*8 + ldp $acc0,$acc1,[$tp,#8*0] + sub $cnt,$cnt,#8*8 + ldp $acc2,$acc3,[$tp,#8*2] + ldp $acc4,$acc5,[$tp,#8*4] + ldp $acc6,$acc7,[$tp,#8*6] + add $tp,$tp,#8*8 + stp $t0,$t1,[$rp,#8*4] + sbcs $t0,$acc0,$a0 + stp $t2,$t3,[$rp,#8*6] + add $rp,$rp,#8*8 + sbcs $t1,$acc1,$a1 + cbnz $cnt,.Lsqr8x_sub + + sbcs $t2,$acc2,$a2 + mov $tp,sp + add $ap,sp,$num + ldp $a0,$a1,[$ap_end,#8*0] + sbcs $t3,$acc3,$a3 + stp $t0,$t1,[$rp,#8*0] + sbcs $t0,$acc4,$a4 + ldp $a2,$a3,[$ap_end,#8*2] + sbcs $t1,$acc5,$a5 + stp $t2,$t3,[$rp,#8*2] + sbcs $t2,$acc6,$a6 + ldp $acc0,$acc1,[$ap,#8*0] + sbcs $t3,$acc7,$a7 + ldp $acc2,$acc3,[$ap,#8*2] + sbcs xzr,$topmost,xzr // did it borrow? + ldr x30,[x29,#8] // pull return address + stp $t0,$t1,[$rp,#8*4] + stp $t2,$t3,[$rp,#8*6] + + sub $cnt,$num,#8*4 +.Lsqr4x_cond_copy: + sub $cnt,$cnt,#8*4 + csel $t0,$acc0,$a0,lo + stp xzr,xzr,[$tp,#8*0] + csel $t1,$acc1,$a1,lo + ldp $a0,$a1,[$ap_end,#8*4] + ldp $acc0,$acc1,[$ap,#8*4] + csel $t2,$acc2,$a2,lo + stp xzr,xzr,[$tp,#8*2] + add $tp,$tp,#8*4 + csel $t3,$acc3,$a3,lo + ldp $a2,$a3,[$ap_end,#8*6] + ldp $acc2,$acc3,[$ap,#8*6] + add $ap,$ap,#8*4 + stp $t0,$t1,[$ap_end,#8*0] + stp $t2,$t3,[$ap_end,#8*2] + add $ap_end,$ap_end,#8*4 + stp xzr,xzr,[$ap,#8*0] + stp xzr,xzr,[$ap,#8*2] + cbnz $cnt,.Lsqr4x_cond_copy + + csel $t0,$acc0,$a0,lo + stp xzr,xzr,[$tp,#8*0] + csel $t1,$acc1,$a1,lo + stp xzr,xzr,[$tp,#8*2] + csel $t2,$acc2,$a2,lo + csel $t3,$acc3,$a3,lo + stp $t0,$t1,[$ap_end,#8*0] + stp $t2,$t3,[$ap_end,#8*2] + + b .Lsqr8x_done + +.align 4 +.Lsqr8x8_post_condition: + adc $carry,xzr,xzr + ldr x30,[x29,#8] // pull return address + // $acc0-7,$carry hold result, $a0-7 hold modulus + subs $a0,$acc0,$a0 + ldr $ap,[x29,#96] // pull rp + sbcs $a1,$acc1,$a1 + stp xzr,xzr,[sp,#8*0] + sbcs $a2,$acc2,$a2 + stp xzr,xzr,[sp,#8*2] + sbcs $a3,$acc3,$a3 + stp xzr,xzr,[sp,#8*4] + sbcs $a4,$acc4,$a4 + stp xzr,xzr,[sp,#8*6] + sbcs $a5,$acc5,$a5 + stp xzr,xzr,[sp,#8*8] + sbcs $a6,$acc6,$a6 + stp xzr,xzr,[sp,#8*10] + sbcs $a7,$acc7,$a7 + stp xzr,xzr,[sp,#8*12] + sbcs $carry,$carry,xzr // did it borrow? + stp xzr,xzr,[sp,#8*14] + + // $a0-7 hold result-modulus + csel $a0,$acc0,$a0,lo + csel $a1,$acc1,$a1,lo + csel $a2,$acc2,$a2,lo + csel $a3,$acc3,$a3,lo + stp $a0,$a1,[$ap,#8*0] + csel $a4,$acc4,$a4,lo + csel $a5,$acc5,$a5,lo + stp $a2,$a3,[$ap,#8*2] + csel $a6,$acc6,$a6,lo + csel $a7,$acc7,$a7,lo + stp $a4,$a5,[$ap,#8*4] + stp $a6,$a7,[$ap,#8*6] + +.Lsqr8x_done: + ldp x19,x20,[x29,#16] + mov sp,x29 + ldp x21,x22,[x29,#32] + mov x0,#1 + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldr x29,[sp],#128 + // x30 is popped earlier + AARCH64_VALIDATE_LINK_REGISTER + ret +.size bn_sqr8x_mont,.-bn_sqr8x_mont +___ +} + +{ +######################################################################## +# Even though this might look as ARMv8 adaptation of mulx4x_mont from +# x86_64-mont5 module, it's different in sense that it performs +# reduction 256 bits at a time. + +my ($a0,$a1,$a2,$a3, + $t0,$t1,$t2,$t3, + $m0,$m1,$m2,$m3, + $acc0,$acc1,$acc2,$acc3,$acc4, + $bi,$mi,$tp,$ap_end,$cnt) = map("x$_",(6..17,19..28)); +my $bp_end=$rp; +my ($carry,$topmost) = ($rp,"x30"); + +$code.=<<___; +.globl bn_mul4x_mont +.type bn_mul4x_mont,%function +.align 5 +bn_mul4x_mont: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-128]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + stp x27,x28,[sp,#80] + + sub $tp,sp,$num,lsl#3 + lsl $num,$num,#3 + ldr $n0,[$n0] // *n0 + sub sp,$tp,#8*4 // alloca + + add $t0,$bp,$num + add $ap_end,$ap,$num + stp $rp,$t0,[x29,#96] // offload rp and &b[num] + + ldr $bi,[$bp,#8*0] // b[0] + ldp $a0,$a1,[$ap,#8*0] // a[0..3] + ldp $a2,$a3,[$ap,#8*2] + add $ap,$ap,#8*4 + mov $acc0,xzr + mov $acc1,xzr + mov $acc2,xzr + mov $acc3,xzr + ldp $m0,$m1,[$np,#8*0] // n[0..3] + ldp $m2,$m3,[$np,#8*2] + adds $np,$np,#8*4 // clear carry bit + mov $carry,xzr + mov $cnt,#0 + mov $tp,sp + +.Loop_mul4x_1st_reduction: + mul $t0,$a0,$bi // lo(a[0..3]*b[0]) + adc $carry,$carry,xzr // modulo-scheduled + mul $t1,$a1,$bi + add $cnt,$cnt,#8 + mul $t2,$a2,$bi + and $cnt,$cnt,#31 + mul $t3,$a3,$bi + adds $acc0,$acc0,$t0 + umulh $t0,$a0,$bi // hi(a[0..3]*b[0]) + adcs $acc1,$acc1,$t1 + mul $mi,$acc0,$n0 // t[0]*n0 + adcs $acc2,$acc2,$t2 + umulh $t1,$a1,$bi + adcs $acc3,$acc3,$t3 + umulh $t2,$a2,$bi + adc $acc4,xzr,xzr + umulh $t3,$a3,$bi + ldr $bi,[$bp,$cnt] // next b[i] (or b[0]) + adds $acc1,$acc1,$t0 + // (*) mul $t0,$m0,$mi // lo(n[0..3]*t[0]*n0) + str $mi,[$tp],#8 // put aside t[0]*n0 for tail processing + adcs $acc2,$acc2,$t1 + mul $t1,$m1,$mi + adcs $acc3,$acc3,$t2 + mul $t2,$m2,$mi + adc $acc4,$acc4,$t3 // can't overflow + mul $t3,$m3,$mi + // (*) adds xzr,$acc0,$t0 + subs xzr,$acc0,#1 // (*) + umulh $t0,$m0,$mi // hi(n[0..3]*t[0]*n0) + adcs $acc0,$acc1,$t1 + umulh $t1,$m1,$mi + adcs $acc1,$acc2,$t2 + umulh $t2,$m2,$mi + adcs $acc2,$acc3,$t3 + umulh $t3,$m3,$mi + adcs $acc3,$acc4,$carry + adc $carry,xzr,xzr + adds $acc0,$acc0,$t0 + sub $t0,$ap_end,$ap + adcs $acc1,$acc1,$t1 + adcs $acc2,$acc2,$t2 + adcs $acc3,$acc3,$t3 + //adc $carry,$carry,xzr + cbnz $cnt,.Loop_mul4x_1st_reduction + + cbz $t0,.Lmul4x4_post_condition + + ldp $a0,$a1,[$ap,#8*0] // a[4..7] + ldp $a2,$a3,[$ap,#8*2] + add $ap,$ap,#8*4 + ldr $mi,[sp] // a[0]*n0 + ldp $m0,$m1,[$np,#8*0] // n[4..7] + ldp $m2,$m3,[$np,#8*2] + add $np,$np,#8*4 + +.Loop_mul4x_1st_tail: + mul $t0,$a0,$bi // lo(a[4..7]*b[i]) + adc $carry,$carry,xzr // modulo-scheduled + mul $t1,$a1,$bi + add $cnt,$cnt,#8 + mul $t2,$a2,$bi + and $cnt,$cnt,#31 + mul $t3,$a3,$bi + adds $acc0,$acc0,$t0 + umulh $t0,$a0,$bi // hi(a[4..7]*b[i]) + adcs $acc1,$acc1,$t1 + umulh $t1,$a1,$bi + adcs $acc2,$acc2,$t2 + umulh $t2,$a2,$bi + adcs $acc3,$acc3,$t3 + umulh $t3,$a3,$bi + adc $acc4,xzr,xzr + ldr $bi,[$bp,$cnt] // next b[i] (or b[0]) + adds $acc1,$acc1,$t0 + mul $t0,$m0,$mi // lo(n[4..7]*a[0]*n0) + adcs $acc2,$acc2,$t1 + mul $t1,$m1,$mi + adcs $acc3,$acc3,$t2 + mul $t2,$m2,$mi + adc $acc4,$acc4,$t3 // can't overflow + mul $t3,$m3,$mi + adds $acc0,$acc0,$t0 + umulh $t0,$m0,$mi // hi(n[4..7]*a[0]*n0) + adcs $acc1,$acc1,$t1 + umulh $t1,$m1,$mi + adcs $acc2,$acc2,$t2 + umulh $t2,$m2,$mi + adcs $acc3,$acc3,$t3 + adcs $acc4,$acc4,$carry + umulh $t3,$m3,$mi + adc $carry,xzr,xzr + ldr $mi,[sp,$cnt] // next t[0]*n0 + str $acc0,[$tp],#8 // result!!! + adds $acc0,$acc1,$t0 + sub $t0,$ap_end,$ap // done yet? + adcs $acc1,$acc2,$t1 + adcs $acc2,$acc3,$t2 + adcs $acc3,$acc4,$t3 + //adc $carry,$carry,xzr + cbnz $cnt,.Loop_mul4x_1st_tail + + sub $t1,$ap_end,$num // rewinded $ap + cbz $t0,.Lmul4x_proceed + + ldp $a0,$a1,[$ap,#8*0] + ldp $a2,$a3,[$ap,#8*2] + add $ap,$ap,#8*4 + ldp $m0,$m1,[$np,#8*0] + ldp $m2,$m3,[$np,#8*2] + add $np,$np,#8*4 + b .Loop_mul4x_1st_tail + +.align 5 +.Lmul4x_proceed: + ldr $bi,[$bp,#8*4]! // *++b + adc $topmost,$carry,xzr + ldp $a0,$a1,[$t1,#8*0] // a[0..3] + sub $np,$np,$num // rewind np + ldp $a2,$a3,[$t1,#8*2] + add $ap,$t1,#8*4 + + stp $acc0,$acc1,[$tp,#8*0] // result!!! + ldp $acc0,$acc1,[sp,#8*4] // t[0..3] + stp $acc2,$acc3,[$tp,#8*2] // result!!! + ldp $acc2,$acc3,[sp,#8*6] + + ldp $m0,$m1,[$np,#8*0] // n[0..3] + mov $tp,sp + ldp $m2,$m3,[$np,#8*2] + adds $np,$np,#8*4 // clear carry bit + mov $carry,xzr + +.align 4 +.Loop_mul4x_reduction: + mul $t0,$a0,$bi // lo(a[0..3]*b[4]) + adc $carry,$carry,xzr // modulo-scheduled + mul $t1,$a1,$bi + add $cnt,$cnt,#8 + mul $t2,$a2,$bi + and $cnt,$cnt,#31 + mul $t3,$a3,$bi + adds $acc0,$acc0,$t0 + umulh $t0,$a0,$bi // hi(a[0..3]*b[4]) + adcs $acc1,$acc1,$t1 + mul $mi,$acc0,$n0 // t[0]*n0 + adcs $acc2,$acc2,$t2 + umulh $t1,$a1,$bi + adcs $acc3,$acc3,$t3 + umulh $t2,$a2,$bi + adc $acc4,xzr,xzr + umulh $t3,$a3,$bi + ldr $bi,[$bp,$cnt] // next b[i] + adds $acc1,$acc1,$t0 + // (*) mul $t0,$m0,$mi + str $mi,[$tp],#8 // put aside t[0]*n0 for tail processing + adcs $acc2,$acc2,$t1 + mul $t1,$m1,$mi // lo(n[0..3]*t[0]*n0 + adcs $acc3,$acc3,$t2 + mul $t2,$m2,$mi + adc $acc4,$acc4,$t3 // can't overflow + mul $t3,$m3,$mi + // (*) adds xzr,$acc0,$t0 + subs xzr,$acc0,#1 // (*) + umulh $t0,$m0,$mi // hi(n[0..3]*t[0]*n0 + adcs $acc0,$acc1,$t1 + umulh $t1,$m1,$mi + adcs $acc1,$acc2,$t2 + umulh $t2,$m2,$mi + adcs $acc2,$acc3,$t3 + umulh $t3,$m3,$mi + adcs $acc3,$acc4,$carry + adc $carry,xzr,xzr + adds $acc0,$acc0,$t0 + adcs $acc1,$acc1,$t1 + adcs $acc2,$acc2,$t2 + adcs $acc3,$acc3,$t3 + //adc $carry,$carry,xzr + cbnz $cnt,.Loop_mul4x_reduction + + adc $carry,$carry,xzr + ldp $t0,$t1,[$tp,#8*4] // t[4..7] + ldp $t2,$t3,[$tp,#8*6] + ldp $a0,$a1,[$ap,#8*0] // a[4..7] + ldp $a2,$a3,[$ap,#8*2] + add $ap,$ap,#8*4 + adds $acc0,$acc0,$t0 + adcs $acc1,$acc1,$t1 + adcs $acc2,$acc2,$t2 + adcs $acc3,$acc3,$t3 + //adc $carry,$carry,xzr + + ldr $mi,[sp] // t[0]*n0 + ldp $m0,$m1,[$np,#8*0] // n[4..7] + ldp $m2,$m3,[$np,#8*2] + add $np,$np,#8*4 + +.align 4 +.Loop_mul4x_tail: + mul $t0,$a0,$bi // lo(a[4..7]*b[4]) + adc $carry,$carry,xzr // modulo-scheduled + mul $t1,$a1,$bi + add $cnt,$cnt,#8 + mul $t2,$a2,$bi + and $cnt,$cnt,#31 + mul $t3,$a3,$bi + adds $acc0,$acc0,$t0 + umulh $t0,$a0,$bi // hi(a[4..7]*b[4]) + adcs $acc1,$acc1,$t1 + umulh $t1,$a1,$bi + adcs $acc2,$acc2,$t2 + umulh $t2,$a2,$bi + adcs $acc3,$acc3,$t3 + umulh $t3,$a3,$bi + adc $acc4,xzr,xzr + ldr $bi,[$bp,$cnt] // next b[i] + adds $acc1,$acc1,$t0 + mul $t0,$m0,$mi // lo(n[4..7]*t[0]*n0) + adcs $acc2,$acc2,$t1 + mul $t1,$m1,$mi + adcs $acc3,$acc3,$t2 + mul $t2,$m2,$mi + adc $acc4,$acc4,$t3 // can't overflow + mul $t3,$m3,$mi + adds $acc0,$acc0,$t0 + umulh $t0,$m0,$mi // hi(n[4..7]*t[0]*n0) + adcs $acc1,$acc1,$t1 + umulh $t1,$m1,$mi + adcs $acc2,$acc2,$t2 + umulh $t2,$m2,$mi + adcs $acc3,$acc3,$t3 + umulh $t3,$m3,$mi + adcs $acc4,$acc4,$carry + ldr $mi,[sp,$cnt] // next a[0]*n0 + adc $carry,xzr,xzr + str $acc0,[$tp],#8 // result!!! + adds $acc0,$acc1,$t0 + sub $t0,$ap_end,$ap // done yet? + adcs $acc1,$acc2,$t1 + adcs $acc2,$acc3,$t2 + adcs $acc3,$acc4,$t3 + //adc $carry,$carry,xzr + cbnz $cnt,.Loop_mul4x_tail + + sub $t1,$np,$num // rewinded np? + adc $carry,$carry,xzr + cbz $t0,.Loop_mul4x_break + + ldp $t0,$t1,[$tp,#8*4] + ldp $t2,$t3,[$tp,#8*6] + ldp $a0,$a1,[$ap,#8*0] + ldp $a2,$a3,[$ap,#8*2] + add $ap,$ap,#8*4 + adds $acc0,$acc0,$t0 + adcs $acc1,$acc1,$t1 + adcs $acc2,$acc2,$t2 + adcs $acc3,$acc3,$t3 + //adc $carry,$carry,xzr + ldp $m0,$m1,[$np,#8*0] + ldp $m2,$m3,[$np,#8*2] + add $np,$np,#8*4 + b .Loop_mul4x_tail + +.align 4 +.Loop_mul4x_break: + ldp $t2,$t3,[x29,#96] // pull rp and &b[num] + adds $acc0,$acc0,$topmost + add $bp,$bp,#8*4 // bp++ + adcs $acc1,$acc1,xzr + sub $ap,$ap,$num // rewind ap + adcs $acc2,$acc2,xzr + stp $acc0,$acc1,[$tp,#8*0] // result!!! + adcs $acc3,$acc3,xzr + ldp $acc0,$acc1,[sp,#8*4] // t[0..3] + adc $topmost,$carry,xzr + stp $acc2,$acc3,[$tp,#8*2] // result!!! + cmp $bp,$t3 // done yet? + ldp $acc2,$acc3,[sp,#8*6] + ldp $m0,$m1,[$t1,#8*0] // n[0..3] + ldp $m2,$m3,[$t1,#8*2] + add $np,$t1,#8*4 + b.eq .Lmul4x_post + + ldr $bi,[$bp] + ldp $a0,$a1,[$ap,#8*0] // a[0..3] + ldp $a2,$a3,[$ap,#8*2] + adds $ap,$ap,#8*4 // clear carry bit + mov $carry,xzr + mov $tp,sp + b .Loop_mul4x_reduction + +.align 4 +.Lmul4x_post: + // Final step. We see if result is larger than modulus, and + // if it is, subtract the modulus. But comparison implies + // subtraction. So we subtract modulus, see if it borrowed, + // and conditionally copy original value. + mov $rp,$t2 + mov $ap_end,$t2 // $rp copy + subs $t0,$acc0,$m0 + add $tp,sp,#8*8 + sbcs $t1,$acc1,$m1 + sub $cnt,$num,#8*4 + +.Lmul4x_sub: + sbcs $t2,$acc2,$m2 + ldp $m0,$m1,[$np,#8*0] + sub $cnt,$cnt,#8*4 + ldp $acc0,$acc1,[$tp,#8*0] + sbcs $t3,$acc3,$m3 + ldp $m2,$m3,[$np,#8*2] + add $np,$np,#8*4 + ldp $acc2,$acc3,[$tp,#8*2] + add $tp,$tp,#8*4 + stp $t0,$t1,[$rp,#8*0] + sbcs $t0,$acc0,$m0 + stp $t2,$t3,[$rp,#8*2] + add $rp,$rp,#8*4 + sbcs $t1,$acc1,$m1 + cbnz $cnt,.Lmul4x_sub + + sbcs $t2,$acc2,$m2 + mov $tp,sp + add $ap,sp,#8*4 + ldp $a0,$a1,[$ap_end,#8*0] + sbcs $t3,$acc3,$m3 + stp $t0,$t1,[$rp,#8*0] + ldp $a2,$a3,[$ap_end,#8*2] + stp $t2,$t3,[$rp,#8*2] + ldp $acc0,$acc1,[$ap,#8*0] + ldp $acc2,$acc3,[$ap,#8*2] + sbcs xzr,$topmost,xzr // did it borrow? + ldr x30,[x29,#8] // pull return address + + sub $cnt,$num,#8*4 +.Lmul4x_cond_copy: + sub $cnt,$cnt,#8*4 + csel $t0,$acc0,$a0,lo + stp xzr,xzr,[$tp,#8*0] + csel $t1,$acc1,$a1,lo + ldp $a0,$a1,[$ap_end,#8*4] + ldp $acc0,$acc1,[$ap,#8*4] + csel $t2,$acc2,$a2,lo + stp xzr,xzr,[$tp,#8*2] + add $tp,$tp,#8*4 + csel $t3,$acc3,$a3,lo + ldp $a2,$a3,[$ap_end,#8*6] + ldp $acc2,$acc3,[$ap,#8*6] + add $ap,$ap,#8*4 + stp $t0,$t1,[$ap_end,#8*0] + stp $t2,$t3,[$ap_end,#8*2] + add $ap_end,$ap_end,#8*4 + cbnz $cnt,.Lmul4x_cond_copy + + csel $t0,$acc0,$a0,lo + stp xzr,xzr,[$tp,#8*0] + csel $t1,$acc1,$a1,lo + stp xzr,xzr,[$tp,#8*2] + csel $t2,$acc2,$a2,lo + stp xzr,xzr,[$tp,#8*3] + csel $t3,$acc3,$a3,lo + stp xzr,xzr,[$tp,#8*4] + stp $t0,$t1,[$ap_end,#8*0] + stp $t2,$t3,[$ap_end,#8*2] + + b .Lmul4x_done + +.align 4 +.Lmul4x4_post_condition: + adc $carry,$carry,xzr + ldr $ap,[x29,#96] // pull rp + // $acc0-3,$carry hold result, $m0-7 hold modulus + subs $a0,$acc0,$m0 + ldr x30,[x29,#8] // pull return address + sbcs $a1,$acc1,$m1 + stp xzr,xzr,[sp,#8*0] + sbcs $a2,$acc2,$m2 + stp xzr,xzr,[sp,#8*2] + sbcs $a3,$acc3,$m3 + stp xzr,xzr,[sp,#8*4] + sbcs xzr,$carry,xzr // did it borrow? + stp xzr,xzr,[sp,#8*6] + + // $a0-3 hold result-modulus + csel $a0,$acc0,$a0,lo + csel $a1,$acc1,$a1,lo + csel $a2,$acc2,$a2,lo + csel $a3,$acc3,$a3,lo + stp $a0,$a1,[$ap,#8*0] + stp $a2,$a3,[$ap,#8*2] + +.Lmul4x_done: + ldp x19,x20,[x29,#16] + mov sp,x29 + ldp x21,x22,[x29,#32] + mov x0,#1 + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldr x29,[sp],#128 + // x30 is popped earlier + AARCH64_VALIDATE_LINK_REGISTER + ret +.size bn_mul4x_mont,.-bn_mul4x_mont +___ +} +$code.=<<___; +.asciz "Montgomery Multiplication for ARMv8, CRYPTOGAMS by " +.align 4 +___ + +print $code; + +close STDOUT or die "error closing STDOUT: $!"; diff --git a/http/vendor/ring/crypto/fipsmodule/bn/asm/x86-mont.pl b/http/vendor/ring/crypto/fipsmodule/bn/asm/x86-mont.pl new file mode 100644 index 0000000..afa0994 --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/bn/asm/x86-mont.pl @@ -0,0 +1,334 @@ +#! /usr/bin/env perl +# Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# ==================================================================== +# Written by Andy Polyakov for the OpenSSL +# project. +# ==================================================================== + +# October 2005 +# +# This is a "teaser" code, as it can be improved in several ways... +# First of all non-SSE2 path should be implemented (yes, for now it +# performs Montgomery multiplication/convolution only on SSE2-capable +# CPUs such as P4, others fall down to original code). Then inner loop +# can be unrolled and modulo-scheduled to improve ILP and possibly +# moved to 128-bit XMM register bank (though it would require input +# rearrangement and/or increase bus bandwidth utilization). Dedicated +# squaring procedure should give further performance improvement... +# Yet, for being draft, the code improves rsa512 *sign* benchmark by +# 110%(!), rsa1024 one - by 70% and rsa4096 - by 20%:-) + +# December 2006 +# +# Modulo-scheduling SSE2 loops results in further 15-20% improvement. +# Integer-only code [being equipped with dedicated squaring procedure] +# gives ~40% on rsa512 sign benchmark... + +$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; +push(@INC,"${dir}","${dir}../../../perlasm"); +require "x86asm.pl"; + +$output = pop; +open STDOUT,">$output"; + +&asm_init($ARGV[0]); + +$sse2=1; + +&function_begin("bn_mul_mont"); + +$i="edx"; +$j="ecx"; +$ap="esi"; $tp="esi"; # overlapping variables!!! +$rp="edi"; $bp="edi"; # overlapping variables!!! +$np="ebp"; +$num="ebx"; + +$_num=&DWP(4*0,"esp"); # stack top layout +$_rp=&DWP(4*1,"esp"); +$_ap=&DWP(4*2,"esp"); +$_bp=&DWP(4*3,"esp"); +$_np=&DWP(4*4,"esp"); +$_n0=&DWP(4*5,"esp"); $_n0q=&QWP(4*5,"esp"); +$_sp=&DWP(4*6,"esp"); +$_bpend=&DWP(4*7,"esp"); +$frame=32; # size of above frame rounded up to 16n + + &xor ("eax","eax"); + &mov ("edi",&wparam(5)); # int num + + &lea ("esi",&wparam(0)); # put aside pointer to argument block + &lea ("edx",&wparam(1)); # load ap + &add ("edi",2); # extra two words on top of tp + &neg ("edi"); + &lea ("ebp",&DWP(-$frame,"esp","edi",4)); # future alloca($frame+4*(num+2)) + &neg ("edi"); + + # minimize cache contention by arranging 2K window between stack + # pointer and ap argument [np is also position sensitive vector, + # but it's assumed to be near ap, as it's allocated at ~same + # time]. + &mov ("eax","ebp"); + &sub ("eax","edx"); + &and ("eax",2047); + &sub ("ebp","eax"); # this aligns sp and ap modulo 2048 + + &xor ("edx","ebp"); + &and ("edx",2048); + &xor ("edx",2048); + &sub ("ebp","edx"); # this splits them apart modulo 4096 + + &and ("ebp",-64); # align to cache line + + # An OS-agnostic version of __chkstk. + # + # Some OSes (Windows) insist on stack being "wired" to + # physical memory in strictly sequential manner, i.e. if stack + # allocation spans two pages, then reference to farmost one can + # be punishable by SEGV. But page walking can do good even on + # other OSes, because it guarantees that villain thread hits + # the guard page before it can make damage to innocent one... + &mov ("eax","esp"); + &sub ("eax","ebp"); + &and ("eax",-4096); + &mov ("edx","esp"); # saved stack pointer! + &lea ("esp",&DWP(0,"ebp","eax")); + &mov ("eax",&DWP(0,"esp")); + &cmp ("esp","ebp"); + &ja (&label("page_walk")); + &jmp (&label("page_walk_done")); + +&set_label("page_walk",16); + &lea ("esp",&DWP(-4096,"esp")); + &mov ("eax",&DWP(0,"esp")); + &cmp ("esp","ebp"); + &ja (&label("page_walk")); +&set_label("page_walk_done"); + + ################################# load argument block... + &mov ("eax",&DWP(0*4,"esi"));# BN_ULONG *rp + &mov ("ebx",&DWP(1*4,"esi"));# const BN_ULONG *ap + &mov ("ecx",&DWP(2*4,"esi"));# const BN_ULONG *bp + &mov ("ebp",&DWP(3*4,"esi"));# const BN_ULONG *np + &mov ("esi",&DWP(4*4,"esi"));# const BN_ULONG *n0 + #&mov ("edi",&DWP(5*4,"esi"));# int num + + &mov ("esi",&DWP(0,"esi")); # pull n0[0] + &mov ($_rp,"eax"); # ... save a copy of argument block + &mov ($_ap,"ebx"); + &mov ($_bp,"ecx"); + &mov ($_np,"ebp"); + &mov ($_n0,"esi"); + &lea ($num,&DWP(-3,"edi")); # num=num-1 to assist modulo-scheduling + #&mov ($_num,$num); # redundant as $num is not reused + &mov ($_sp,"edx"); # saved stack pointer! + +if($sse2) { +$acc0="mm0"; # mmx register bank layout +$acc1="mm1"; +$car0="mm2"; +$car1="mm3"; +$mul0="mm4"; +$mul1="mm5"; +$temp="mm6"; +$mask="mm7"; + + &mov ("eax",-1); + &movd ($mask,"eax"); # mask 32 lower bits + + &mov ($ap,$_ap); # load input pointers + &mov ($bp,$_bp); + &mov ($np,$_np); + + &xor ($i,$i); # i=0 + &xor ($j,$j); # j=0 + + &movd ($mul0,&DWP(0,$bp)); # bp[0] + &movd ($mul1,&DWP(0,$ap)); # ap[0] + &movd ($car1,&DWP(0,$np)); # np[0] + + &pmuludq($mul1,$mul0); # ap[0]*bp[0] + &movq ($car0,$mul1); + &movq ($acc0,$mul1); # I wish movd worked for + &pand ($acc0,$mask); # inter-register transfers + + &pmuludq($mul1,$_n0q); # *=n0 + + &pmuludq($car1,$mul1); # "t[0]"*np[0]*n0 + &paddq ($car1,$acc0); + + &movd ($acc1,&DWP(4,$np)); # np[1] + &movd ($acc0,&DWP(4,$ap)); # ap[1] + + &psrlq ($car0,32); + &psrlq ($car1,32); + + &inc ($j); # j++ +&set_label("1st",16); + &pmuludq($acc0,$mul0); # ap[j]*bp[0] + &pmuludq($acc1,$mul1); # np[j]*m1 + &paddq ($car0,$acc0); # +=c0 + &paddq ($car1,$acc1); # +=c1 + + &movq ($acc0,$car0); + &pand ($acc0,$mask); + &movd ($acc1,&DWP(4,$np,$j,4)); # np[j+1] + &paddq ($car1,$acc0); # +=ap[j]*bp[0]; + &movd ($acc0,&DWP(4,$ap,$j,4)); # ap[j+1] + &psrlq ($car0,32); + &movd (&DWP($frame-4,"esp",$j,4),$car1); # tp[j-1]= + &psrlq ($car1,32); + + &lea ($j,&DWP(1,$j)); + &cmp ($j,$num); + &jl (&label("1st")); + + &pmuludq($acc0,$mul0); # ap[num-1]*bp[0] + &pmuludq($acc1,$mul1); # np[num-1]*m1 + &paddq ($car0,$acc0); # +=c0 + &paddq ($car1,$acc1); # +=c1 + + &movq ($acc0,$car0); + &pand ($acc0,$mask); + &paddq ($car1,$acc0); # +=ap[num-1]*bp[0]; + &movd (&DWP($frame-4,"esp",$j,4),$car1); # tp[num-2]= + + &psrlq ($car0,32); + &psrlq ($car1,32); + + &paddq ($car1,$car0); + &movq (&QWP($frame,"esp",$num,4),$car1); # tp[num].tp[num-1] + + &inc ($i); # i++ +&set_label("outer"); + &xor ($j,$j); # j=0 + + &movd ($mul0,&DWP(0,$bp,$i,4)); # bp[i] + &movd ($mul1,&DWP(0,$ap)); # ap[0] + &movd ($temp,&DWP($frame,"esp")); # tp[0] + &movd ($car1,&DWP(0,$np)); # np[0] + &pmuludq($mul1,$mul0); # ap[0]*bp[i] + + &paddq ($mul1,$temp); # +=tp[0] + &movq ($acc0,$mul1); + &movq ($car0,$mul1); + &pand ($acc0,$mask); + + &pmuludq($mul1,$_n0q); # *=n0 + + &pmuludq($car1,$mul1); + &paddq ($car1,$acc0); + + &movd ($temp,&DWP($frame+4,"esp")); # tp[1] + &movd ($acc1,&DWP(4,$np)); # np[1] + &movd ($acc0,&DWP(4,$ap)); # ap[1] + + &psrlq ($car0,32); + &psrlq ($car1,32); + &paddq ($car0,$temp); # +=tp[1] + + &inc ($j); # j++ + &dec ($num); +&set_label("inner"); + &pmuludq($acc0,$mul0); # ap[j]*bp[i] + &pmuludq($acc1,$mul1); # np[j]*m1 + &paddq ($car0,$acc0); # +=c0 + &paddq ($car1,$acc1); # +=c1 + + &movq ($acc0,$car0); + &movd ($temp,&DWP($frame+4,"esp",$j,4));# tp[j+1] + &pand ($acc0,$mask); + &movd ($acc1,&DWP(4,$np,$j,4)); # np[j+1] + &paddq ($car1,$acc0); # +=ap[j]*bp[i]+tp[j] + &movd ($acc0,&DWP(4,$ap,$j,4)); # ap[j+1] + &psrlq ($car0,32); + &movd (&DWP($frame-4,"esp",$j,4),$car1);# tp[j-1]= + &psrlq ($car1,32); + &paddq ($car0,$temp); # +=tp[j+1] + + &dec ($num); + &lea ($j,&DWP(1,$j)); # j++ + &jnz (&label("inner")); + + &mov ($num,$j); + &pmuludq($acc0,$mul0); # ap[num-1]*bp[i] + &pmuludq($acc1,$mul1); # np[num-1]*m1 + &paddq ($car0,$acc0); # +=c0 + &paddq ($car1,$acc1); # +=c1 + + &movq ($acc0,$car0); + &pand ($acc0,$mask); + &paddq ($car1,$acc0); # +=ap[num-1]*bp[i]+tp[num-1] + &movd (&DWP($frame-4,"esp",$j,4),$car1); # tp[num-2]= + &psrlq ($car0,32); + &psrlq ($car1,32); + + &movd ($temp,&DWP($frame+4,"esp",$num,4)); # += tp[num] + &paddq ($car1,$car0); + &paddq ($car1,$temp); + &movq (&QWP($frame,"esp",$num,4),$car1); # tp[num].tp[num-1] + + &lea ($i,&DWP(1,$i)); # i++ + &cmp ($i,$num); + &jle (&label("outer")); + + &emms (); # done with mmx bank + &jmp (&label("common_tail")); +} + +&set_label("common_tail",16); + &mov ($np,$_np); # load modulus pointer + &mov ($rp,$_rp); # load result pointer + &lea ($tp,&DWP($frame,"esp")); # [$ap and $bp are zapped] + + &mov ("eax",&DWP(0,$tp)); # tp[0] + &mov ($j,$num); # j=num-1 + &xor ($i,$i); # i=0 and clear CF! + +&set_label("sub",16); + &sbb ("eax",&DWP(0,$np,$i,4)); + &mov (&DWP(0,$rp,$i,4),"eax"); # rp[i]=tp[i]-np[i] + &dec ($j); # doesn't affect CF! + &mov ("eax",&DWP(4,$tp,$i,4)); # tp[i+1] + &lea ($i,&DWP(1,$i)); # i++ + &jge (&label("sub")); + + &sbb ("eax",0); # handle upmost overflow bit + &mov ("edx",-1); + &xor ("edx","eax"); + &jmp (&label("copy")); + +&set_label("copy",16); # conditional copy + &mov ($tp,&DWP($frame,"esp",$num,4)); + &mov ($np,&DWP(0,$rp,$num,4)); + &mov (&DWP($frame,"esp",$num,4),$j); # zap temporary vector + &and ($tp,"eax"); + &and ($np,"edx"); + &or ($np,$tp); + &mov (&DWP(0,$rp,$num,4),$np); + &dec ($num); + &jge (&label("copy")); + + &mov ("esp",$_sp); # pull saved stack pointer + &mov ("eax",1); +&function_end("bn_mul_mont"); + +&asciz("Montgomery Multiplication for x86, CRYPTOGAMS by "); + +&asm_finish(); + +close STDOUT or die "error closing STDOUT: $!"; diff --git a/http/vendor/ring/crypto/fipsmodule/bn/asm/x86_64-mont.pl b/http/vendor/ring/crypto/fipsmodule/bn/asm/x86_64-mont.pl new file mode 100644 index 0000000..acbcd31 --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/bn/asm/x86_64-mont.pl @@ -0,0 +1,1561 @@ +#! /usr/bin/env perl +# Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# ==================================================================== +# Written by Andy Polyakov for the OpenSSL +# project. +# ==================================================================== + +# October 2005. +# +# Montgomery multiplication routine for x86_64. While it gives modest +# 9% improvement of rsa4096 sign on Opteron, rsa512 sign runs more +# than twice, >2x, as fast. Most common rsa1024 sign is improved by +# respectful 50%. It remains to be seen if loop unrolling and +# dedicated squaring routine can provide further improvement... + +# July 2011. +# +# Add dedicated squaring procedure. Performance improvement varies +# from platform to platform, but in average it's ~5%/15%/25%/33% +# for 512-/1024-/2048-/4096-bit RSA *sign* benchmarks respectively. + +# August 2011. +# +# Unroll and modulo-schedule inner loops in such manner that they +# are "fallen through" for input lengths of 8, which is critical for +# 1024-bit RSA *sign*. Average performance improvement in comparison +# to *initial* version of this module from 2005 is ~0%/30%/40%/45% +# for 512-/1024-/2048-/4096-bit RSA *sign* benchmarks respectively. + +# June 2013. +# +# Optimize reduction in squaring procedure and improve 1024+-bit RSA +# sign performance by 10-16% on Intel Sandy Bridge and later +# (virtually same on non-Intel processors). + +# August 2013. +# +# Add MULX/ADOX/ADCX code path. + +$flavour = shift; +$output = shift; +if ($flavour =~ /\./) { $output = $flavour; undef $flavour; } + +$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/); + +$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; +( $xlate="${dir}x86_64-xlate.pl" and -f $xlate ) or +( $xlate="${dir}../../../perlasm/x86_64-xlate.pl" and -f $xlate) or +die "can't locate x86_64-xlate.pl"; + +open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""; +*STDOUT=*OUT; + +# In upstream, this is controlled by shelling out to the compiler to check +# versions, but BoringSSL is intended to be used with pre-generated perlasm +# output, so this isn't useful anyway. +$addx = 1; + +# void bn_mul_mont_nohw( +$rp="%rdi"; # BN_ULONG *rp, +$ap="%rsi"; # const BN_ULONG *ap, +$bp="%rdx"; # const BN_ULONG *bp, +$np="%rcx"; # const BN_ULONG *np, +$n0="%r8"; # const BN_ULONG *n0, +# TODO(davidben): The code below treats $num as an int, but C passes in a +# size_t. +$num="%r9"; # size_t num); +$lo0="%r10"; +$hi0="%r11"; +$hi1="%r13"; +$i="%r14"; +$j="%r15"; +$m0="%rbx"; +$m1="%rbp"; + +$code=<<___; +.text + +.globl bn_mul_mont_nohw +.type bn_mul_mont_nohw,\@function,6 +.align 16 +bn_mul_mont_nohw: +.cfi_startproc + _CET_ENDBR + mov ${num}d,${num}d + mov %rsp,%rax +.cfi_def_cfa_register %rax + push %rbx +.cfi_push %rbx + push %rbp +.cfi_push %rbp + push %r12 +.cfi_push %r12 + push %r13 +.cfi_push %r13 + push %r14 +.cfi_push %r14 + push %r15 +.cfi_push %r15 + + neg $num + mov %rsp,%r11 + lea -16(%rsp,$num,8),%r10 # future alloca(8*(num+2)) + neg $num # restore $num + and \$-1024,%r10 # minimize TLB usage + + # An OS-agnostic version of __chkstk. + # + # Some OSes (Windows) insist on stack being "wired" to + # physical memory in strictly sequential manner, i.e. if stack + # allocation spans two pages, then reference to farmost one can + # be punishable by SEGV. But page walking can do good even on + # other OSes, because it guarantees that villain thread hits + # the guard page before it can make damage to innocent one... + sub %r10,%r11 + and \$-4096,%r11 + lea (%r10,%r11),%rsp + mov (%rsp),%r11 + cmp %r10,%rsp + ja .Lmul_page_walk + jmp .Lmul_page_walk_done + +.align 16 +.Lmul_page_walk: + lea -4096(%rsp),%rsp + mov (%rsp),%r11 + cmp %r10,%rsp + ja .Lmul_page_walk +.Lmul_page_walk_done: + + mov %rax,8(%rsp,$num,8) # tp[num+1]=%rsp +.cfi_cfa_expression %rsp+8,$num,8,mul,plus,deref,+8 +.Lmul_body: + mov $bp,%r12 # reassign $bp +___ + $bp="%r12"; +$code.=<<___; + mov ($n0),$n0 # pull n0[0] value + mov ($bp),$m0 # m0=bp[0] + mov ($ap),%rax + + xor $i,$i # i=0 + xor $j,$j # j=0 + + mov $n0,$m1 + mulq $m0 # ap[0]*bp[0] + mov %rax,$lo0 + mov ($np),%rax + + imulq $lo0,$m1 # "tp[0]"*n0 + mov %rdx,$hi0 + + mulq $m1 # np[0]*m1 + add %rax,$lo0 # discarded + mov 8($ap),%rax + adc \$0,%rdx + mov %rdx,$hi1 + + lea 1($j),$j # j++ + jmp .L1st_enter + +.align 16 +.L1st: + add %rax,$hi1 + mov ($ap,$j,8),%rax + adc \$0,%rdx + add $hi0,$hi1 # np[j]*m1+ap[j]*bp[0] + mov $lo0,$hi0 + adc \$0,%rdx + mov $hi1,-16(%rsp,$j,8) # tp[j-1] + mov %rdx,$hi1 + +.L1st_enter: + mulq $m0 # ap[j]*bp[0] + add %rax,$hi0 + mov ($np,$j,8),%rax + adc \$0,%rdx + lea 1($j),$j # j++ + mov %rdx,$lo0 + + mulq $m1 # np[j]*m1 + cmp $num,$j + jne .L1st + + add %rax,$hi1 + mov ($ap),%rax # ap[0] + adc \$0,%rdx + add $hi0,$hi1 # np[j]*m1+ap[j]*bp[0] + adc \$0,%rdx + mov $hi1,-16(%rsp,$j,8) # tp[j-1] + mov %rdx,$hi1 + mov $lo0,$hi0 + + xor %rdx,%rdx + add $hi0,$hi1 + adc \$0,%rdx + mov $hi1,-8(%rsp,$num,8) + mov %rdx,(%rsp,$num,8) # store upmost overflow bit + + lea 1($i),$i # i++ + jmp .Louter +.align 16 +.Louter: + mov ($bp,$i,8),$m0 # m0=bp[i] + xor $j,$j # j=0 + mov $n0,$m1 + mov (%rsp),$lo0 + mulq $m0 # ap[0]*bp[i] + add %rax,$lo0 # ap[0]*bp[i]+tp[0] + mov ($np),%rax + adc \$0,%rdx + + imulq $lo0,$m1 # tp[0]*n0 + mov %rdx,$hi0 + + mulq $m1 # np[0]*m1 + add %rax,$lo0 # discarded + mov 8($ap),%rax + adc \$0,%rdx + mov 8(%rsp),$lo0 # tp[1] + mov %rdx,$hi1 + + lea 1($j),$j # j++ + jmp .Linner_enter + +.align 16 +.Linner: + add %rax,$hi1 + mov ($ap,$j,8),%rax + adc \$0,%rdx + add $lo0,$hi1 # np[j]*m1+ap[j]*bp[i]+tp[j] + mov (%rsp,$j,8),$lo0 + adc \$0,%rdx + mov $hi1,-16(%rsp,$j,8) # tp[j-1] + mov %rdx,$hi1 + +.Linner_enter: + mulq $m0 # ap[j]*bp[i] + add %rax,$hi0 + mov ($np,$j,8),%rax + adc \$0,%rdx + add $hi0,$lo0 # ap[j]*bp[i]+tp[j] + mov %rdx,$hi0 + adc \$0,$hi0 + lea 1($j),$j # j++ + + mulq $m1 # np[j]*m1 + cmp $num,$j + jne .Linner + + add %rax,$hi1 + mov ($ap),%rax # ap[0] + adc \$0,%rdx + add $lo0,$hi1 # np[j]*m1+ap[j]*bp[i]+tp[j] + mov (%rsp,$j,8),$lo0 + adc \$0,%rdx + mov $hi1,-16(%rsp,$j,8) # tp[j-1] + mov %rdx,$hi1 + + xor %rdx,%rdx + add $hi0,$hi1 + adc \$0,%rdx + add $lo0,$hi1 # pull upmost overflow bit + adc \$0,%rdx + mov $hi1,-8(%rsp,$num,8) + mov %rdx,(%rsp,$num,8) # store upmost overflow bit + + lea 1($i),$i # i++ + cmp $num,$i + jb .Louter + + xor $i,$i # i=0 and clear CF! + mov (%rsp),%rax # tp[0] + mov $num,$j # j=num + +.align 16 +.Lsub: sbb ($np,$i,8),%rax + mov %rax,($rp,$i,8) # rp[i]=tp[i]-np[i] + mov 8(%rsp,$i,8),%rax # tp[i+1] + lea 1($i),$i # i++ + dec $j # doesn't affect CF! + jnz .Lsub + + sbb \$0,%rax # handle upmost overflow bit + mov \$-1,%rbx + xor %rax,%rbx # not %rax + xor $i,$i + mov $num,$j # j=num + +.Lcopy: # conditional copy + mov ($rp,$i,8),%rcx + mov (%rsp,$i,8),%rdx + and %rbx,%rcx + and %rax,%rdx + mov $num,(%rsp,$i,8) # zap temporary vector + or %rcx,%rdx + mov %rdx,($rp,$i,8) # rp[i]=tp[i] + lea 1($i),$i + sub \$1,$j + jnz .Lcopy + + mov 8(%rsp,$num,8),%rsi # restore %rsp +.cfi_def_cfa %rsi,8 + mov \$1,%rax + mov -48(%rsi),%r15 +.cfi_restore %r15 + mov -40(%rsi),%r14 +.cfi_restore %r14 + mov -32(%rsi),%r13 +.cfi_restore %r13 + mov -24(%rsi),%r12 +.cfi_restore %r12 + mov -16(%rsi),%rbp +.cfi_restore %rbp + mov -8(%rsi),%rbx +.cfi_restore %rbx + lea (%rsi),%rsp +.cfi_def_cfa_register %rsp +.Lmul_epilogue: + ret +.cfi_endproc +.size bn_mul_mont_nohw,.-bn_mul_mont_nohw +___ +{{{ +my @A=("%r10","%r11"); +my @N=("%r13","%rdi"); +$code.=<<___; +.globl bn_mul4x_mont +.type bn_mul4x_mont,\@function,6 +.align 16 +bn_mul4x_mont: +.cfi_startproc + _CET_ENDBR + mov ${num}d,${num}d + mov %rsp,%rax +.cfi_def_cfa_register %rax + push %rbx +.cfi_push %rbx + push %rbp +.cfi_push %rbp + push %r12 +.cfi_push %r12 + push %r13 +.cfi_push %r13 + push %r14 +.cfi_push %r14 + push %r15 +.cfi_push %r15 + + neg $num + mov %rsp,%r11 + lea -32(%rsp,$num,8),%r10 # future alloca(8*(num+4)) + neg $num # restore + and \$-1024,%r10 # minimize TLB usage + + sub %r10,%r11 + and \$-4096,%r11 + lea (%r10,%r11),%rsp + mov (%rsp),%r11 + cmp %r10,%rsp + ja .Lmul4x_page_walk + jmp .Lmul4x_page_walk_done + +.Lmul4x_page_walk: + lea -4096(%rsp),%rsp + mov (%rsp),%r11 + cmp %r10,%rsp + ja .Lmul4x_page_walk +.Lmul4x_page_walk_done: + + mov %rax,8(%rsp,$num,8) # tp[num+1]=%rsp +.cfi_cfa_expression %rsp+8,$num,8,mul,plus,deref,+8 +.Lmul4x_body: + mov $rp,16(%rsp,$num,8) # tp[num+2]=$rp + mov %rdx,%r12 # reassign $bp +___ + $bp="%r12"; +$code.=<<___; + mov ($n0),$n0 # pull n0[0] value + mov ($bp),$m0 # m0=bp[0] + mov ($ap),%rax + + xor $i,$i # i=0 + xor $j,$j # j=0 + + mov $n0,$m1 + mulq $m0 # ap[0]*bp[0] + mov %rax,$A[0] + mov ($np),%rax + + imulq $A[0],$m1 # "tp[0]"*n0 + mov %rdx,$A[1] + + mulq $m1 # np[0]*m1 + add %rax,$A[0] # discarded + mov 8($ap),%rax + adc \$0,%rdx + mov %rdx,$N[1] + + mulq $m0 + add %rax,$A[1] + mov 8($np),%rax + adc \$0,%rdx + mov %rdx,$A[0] + + mulq $m1 + add %rax,$N[1] + mov 16($ap),%rax + adc \$0,%rdx + add $A[1],$N[1] + lea 4($j),$j # j++ + adc \$0,%rdx + mov $N[1],(%rsp) + mov %rdx,$N[0] + jmp .L1st4x +.align 16 +.L1st4x: + mulq $m0 # ap[j]*bp[0] + add %rax,$A[0] + mov -16($np,$j,8),%rax + adc \$0,%rdx + mov %rdx,$A[1] + + mulq $m1 # np[j]*m1 + add %rax,$N[0] + mov -8($ap,$j,8),%rax + adc \$0,%rdx + add $A[0],$N[0] # np[j]*m1+ap[j]*bp[0] + adc \$0,%rdx + mov $N[0],-24(%rsp,$j,8) # tp[j-1] + mov %rdx,$N[1] + + mulq $m0 # ap[j]*bp[0] + add %rax,$A[1] + mov -8($np,$j,8),%rax + adc \$0,%rdx + mov %rdx,$A[0] + + mulq $m1 # np[j]*m1 + add %rax,$N[1] + mov ($ap,$j,8),%rax + adc \$0,%rdx + add $A[1],$N[1] # np[j]*m1+ap[j]*bp[0] + adc \$0,%rdx + mov $N[1],-16(%rsp,$j,8) # tp[j-1] + mov %rdx,$N[0] + + mulq $m0 # ap[j]*bp[0] + add %rax,$A[0] + mov ($np,$j,8),%rax + adc \$0,%rdx + mov %rdx,$A[1] + + mulq $m1 # np[j]*m1 + add %rax,$N[0] + mov 8($ap,$j,8),%rax + adc \$0,%rdx + add $A[0],$N[0] # np[j]*m1+ap[j]*bp[0] + adc \$0,%rdx + mov $N[0],-8(%rsp,$j,8) # tp[j-1] + mov %rdx,$N[1] + + mulq $m0 # ap[j]*bp[0] + add %rax,$A[1] + mov 8($np,$j,8),%rax + adc \$0,%rdx + lea 4($j),$j # j++ + mov %rdx,$A[0] + + mulq $m1 # np[j]*m1 + add %rax,$N[1] + mov -16($ap,$j,8),%rax + adc \$0,%rdx + add $A[1],$N[1] # np[j]*m1+ap[j]*bp[0] + adc \$0,%rdx + mov $N[1],-32(%rsp,$j,8) # tp[j-1] + mov %rdx,$N[0] + cmp $num,$j + jb .L1st4x + + mulq $m0 # ap[j]*bp[0] + add %rax,$A[0] + mov -16($np,$j,8),%rax + adc \$0,%rdx + mov %rdx,$A[1] + + mulq $m1 # np[j]*m1 + add %rax,$N[0] + mov -8($ap,$j,8),%rax + adc \$0,%rdx + add $A[0],$N[0] # np[j]*m1+ap[j]*bp[0] + adc \$0,%rdx + mov $N[0],-24(%rsp,$j,8) # tp[j-1] + mov %rdx,$N[1] + + mulq $m0 # ap[j]*bp[0] + add %rax,$A[1] + mov -8($np,$j,8),%rax + adc \$0,%rdx + mov %rdx,$A[0] + + mulq $m1 # np[j]*m1 + add %rax,$N[1] + mov ($ap),%rax # ap[0] + adc \$0,%rdx + add $A[1],$N[1] # np[j]*m1+ap[j]*bp[0] + adc \$0,%rdx + mov $N[1],-16(%rsp,$j,8) # tp[j-1] + mov %rdx,$N[0] + + xor $N[1],$N[1] + add $A[0],$N[0] + adc \$0,$N[1] + mov $N[0],-8(%rsp,$j,8) + mov $N[1],(%rsp,$j,8) # store upmost overflow bit + + lea 1($i),$i # i++ +.align 4 +.Louter4x: + mov ($bp,$i,8),$m0 # m0=bp[i] + xor $j,$j # j=0 + mov (%rsp),$A[0] + mov $n0,$m1 + mulq $m0 # ap[0]*bp[i] + add %rax,$A[0] # ap[0]*bp[i]+tp[0] + mov ($np),%rax + adc \$0,%rdx + + imulq $A[0],$m1 # tp[0]*n0 + mov %rdx,$A[1] + + mulq $m1 # np[0]*m1 + add %rax,$A[0] # "$N[0]", discarded + mov 8($ap),%rax + adc \$0,%rdx + mov %rdx,$N[1] + + mulq $m0 # ap[j]*bp[i] + add %rax,$A[1] + mov 8($np),%rax + adc \$0,%rdx + add 8(%rsp),$A[1] # +tp[1] + adc \$0,%rdx + mov %rdx,$A[0] + + mulq $m1 # np[j]*m1 + add %rax,$N[1] + mov 16($ap),%rax + adc \$0,%rdx + add $A[1],$N[1] # np[j]*m1+ap[j]*bp[i]+tp[j] + lea 4($j),$j # j+=2 + adc \$0,%rdx + mov $N[1],(%rsp) # tp[j-1] + mov %rdx,$N[0] + jmp .Linner4x +.align 16 +.Linner4x: + mulq $m0 # ap[j]*bp[i] + add %rax,$A[0] + mov -16($np,$j,8),%rax + adc \$0,%rdx + add -16(%rsp,$j,8),$A[0] # ap[j]*bp[i]+tp[j] + adc \$0,%rdx + mov %rdx,$A[1] + + mulq $m1 # np[j]*m1 + add %rax,$N[0] + mov -8($ap,$j,8),%rax + adc \$0,%rdx + add $A[0],$N[0] + adc \$0,%rdx + mov $N[0],-24(%rsp,$j,8) # tp[j-1] + mov %rdx,$N[1] + + mulq $m0 # ap[j]*bp[i] + add %rax,$A[1] + mov -8($np,$j,8),%rax + adc \$0,%rdx + add -8(%rsp,$j,8),$A[1] + adc \$0,%rdx + mov %rdx,$A[0] + + mulq $m1 # np[j]*m1 + add %rax,$N[1] + mov ($ap,$j,8),%rax + adc \$0,%rdx + add $A[1],$N[1] + adc \$0,%rdx + mov $N[1],-16(%rsp,$j,8) # tp[j-1] + mov %rdx,$N[0] + + mulq $m0 # ap[j]*bp[i] + add %rax,$A[0] + mov ($np,$j,8),%rax + adc \$0,%rdx + add (%rsp,$j,8),$A[0] # ap[j]*bp[i]+tp[j] + adc \$0,%rdx + mov %rdx,$A[1] + + mulq $m1 # np[j]*m1 + add %rax,$N[0] + mov 8($ap,$j,8),%rax + adc \$0,%rdx + add $A[0],$N[0] + adc \$0,%rdx + mov $N[0],-8(%rsp,$j,8) # tp[j-1] + mov %rdx,$N[1] + + mulq $m0 # ap[j]*bp[i] + add %rax,$A[1] + mov 8($np,$j,8),%rax + adc \$0,%rdx + add 8(%rsp,$j,8),$A[1] + adc \$0,%rdx + lea 4($j),$j # j++ + mov %rdx,$A[0] + + mulq $m1 # np[j]*m1 + add %rax,$N[1] + mov -16($ap,$j,8),%rax + adc \$0,%rdx + add $A[1],$N[1] + adc \$0,%rdx + mov $N[1],-32(%rsp,$j,8) # tp[j-1] + mov %rdx,$N[0] + cmp $num,$j + jb .Linner4x + + mulq $m0 # ap[j]*bp[i] + add %rax,$A[0] + mov -16($np,$j,8),%rax + adc \$0,%rdx + add -16(%rsp,$j,8),$A[0] # ap[j]*bp[i]+tp[j] + adc \$0,%rdx + mov %rdx,$A[1] + + mulq $m1 # np[j]*m1 + add %rax,$N[0] + mov -8($ap,$j,8),%rax + adc \$0,%rdx + add $A[0],$N[0] + adc \$0,%rdx + mov $N[0],-24(%rsp,$j,8) # tp[j-1] + mov %rdx,$N[1] + + mulq $m0 # ap[j]*bp[i] + add %rax,$A[1] + mov -8($np,$j,8),%rax + adc \$0,%rdx + add -8(%rsp,$j,8),$A[1] + adc \$0,%rdx + lea 1($i),$i # i++ + mov %rdx,$A[0] + + mulq $m1 # np[j]*m1 + add %rax,$N[1] + mov ($ap),%rax # ap[0] + adc \$0,%rdx + add $A[1],$N[1] + adc \$0,%rdx + mov $N[1],-16(%rsp,$j,8) # tp[j-1] + mov %rdx,$N[0] + + xor $N[1],$N[1] + add $A[0],$N[0] + adc \$0,$N[1] + add (%rsp,$num,8),$N[0] # pull upmost overflow bit + adc \$0,$N[1] + mov $N[0],-8(%rsp,$j,8) + mov $N[1],(%rsp,$j,8) # store upmost overflow bit + + cmp $num,$i + jb .Louter4x +___ +{ +my @ri=("%rax","%rdx",$m0,$m1); +$code.=<<___; + mov 16(%rsp,$num,8),$rp # restore $rp + lea -4($num),$j + mov 0(%rsp),@ri[0] # tp[0] + mov 8(%rsp),@ri[1] # tp[1] + shr \$2,$j # j=num/4-1 + lea (%rsp),$ap # borrow ap for tp + xor $i,$i # i=0 and clear CF! + + sub 0($np),@ri[0] + mov 16($ap),@ri[2] # tp[2] + mov 24($ap),@ri[3] # tp[3] + sbb 8($np),@ri[1] + +.Lsub4x: + mov @ri[0],0($rp,$i,8) # rp[i]=tp[i]-np[i] + mov @ri[1],8($rp,$i,8) # rp[i]=tp[i]-np[i] + sbb 16($np,$i,8),@ri[2] + mov 32($ap,$i,8),@ri[0] # tp[i+1] + mov 40($ap,$i,8),@ri[1] + sbb 24($np,$i,8),@ri[3] + mov @ri[2],16($rp,$i,8) # rp[i]=tp[i]-np[i] + mov @ri[3],24($rp,$i,8) # rp[i]=tp[i]-np[i] + sbb 32($np,$i,8),@ri[0] + mov 48($ap,$i,8),@ri[2] + mov 56($ap,$i,8),@ri[3] + sbb 40($np,$i,8),@ri[1] + lea 4($i),$i # i++ + dec $j # doesn't affect CF! + jnz .Lsub4x + + mov @ri[0],0($rp,$i,8) # rp[i]=tp[i]-np[i] + mov 32($ap,$i,8),@ri[0] # load overflow bit + sbb 16($np,$i,8),@ri[2] + mov @ri[1],8($rp,$i,8) # rp[i]=tp[i]-np[i] + sbb 24($np,$i,8),@ri[3] + mov @ri[2],16($rp,$i,8) # rp[i]=tp[i]-np[i] + + sbb \$0,@ri[0] # handle upmost overflow bit + mov @ri[3],24($rp,$i,8) # rp[i]=tp[i]-np[i] + pxor %xmm0,%xmm0 + movq @ri[0],%xmm4 + pcmpeqd %xmm5,%xmm5 + pshufd \$0,%xmm4,%xmm4 + mov $num,$j + pxor %xmm4,%xmm5 + shr \$2,$j # j=num/4 + xor %eax,%eax # i=0 + + jmp .Lcopy4x +.align 16 +.Lcopy4x: # conditional copy + movdqa (%rsp,%rax),%xmm1 + movdqu ($rp,%rax),%xmm2 + pand %xmm4,%xmm1 + pand %xmm5,%xmm2 + movdqa 16(%rsp,%rax),%xmm3 + movdqa %xmm0,(%rsp,%rax) + por %xmm2,%xmm1 + movdqu 16($rp,%rax),%xmm2 + movdqu %xmm1,($rp,%rax) + pand %xmm4,%xmm3 + pand %xmm5,%xmm2 + movdqa %xmm0,16(%rsp,%rax) + por %xmm2,%xmm3 + movdqu %xmm3,16($rp,%rax) + lea 32(%rax),%rax + dec $j + jnz .Lcopy4x +___ +} +$code.=<<___; + mov 8(%rsp,$num,8),%rsi # restore %rsp +.cfi_def_cfa %rsi, 8 + mov \$1,%rax + mov -48(%rsi),%r15 +.cfi_restore %r15 + mov -40(%rsi),%r14 +.cfi_restore %r14 + mov -32(%rsi),%r13 +.cfi_restore %r13 + mov -24(%rsi),%r12 +.cfi_restore %r12 + mov -16(%rsi),%rbp +.cfi_restore %rbp + mov -8(%rsi),%rbx +.cfi_restore %rbx + lea (%rsi),%rsp +.cfi_def_cfa_register %rsp +.Lmul4x_epilogue: + ret +.cfi_endproc +.size bn_mul4x_mont,.-bn_mul4x_mont +___ +}}} + {{{ +###################################################################### +# void bn_sqr8x_mont( +my $rptr="%rdi"; # const BN_ULONG *rptr, +my $aptr="%rsi"; # const BN_ULONG *aptr, +my $mulx_adx_capable="%rdx"; # Different than upstream! +my $nptr="%rcx"; # const BN_ULONG *nptr, +my $n0 ="%r8"; # const BN_ULONG *n0); +my $num ="%r9"; # int num, has to be divisible by 8 + +my ($i,$j,$tptr)=("%rbp","%rcx",$rptr); +my @A0=("%r10","%r11"); +my @A1=("%r12","%r13"); +my ($a0,$a1,$ai)=("%r14","%r15","%rbx"); + +$code.=<<___ if ($addx); +.extern bn_sqrx8x_internal # see x86_64-mont5 module +___ +$code.=<<___; +.extern bn_sqr8x_internal # see x86_64-mont5 module + +.globl bn_sqr8x_mont +.type bn_sqr8x_mont,\@function,6 +.align 32 +bn_sqr8x_mont: +.cfi_startproc + _CET_ENDBR + mov ${num}d,${num}d + mov %rsp,%rax +.cfi_def_cfa_register %rax + push %rbx +.cfi_push %rbx + push %rbp +.cfi_push %rbp + push %r12 +.cfi_push %r12 + push %r13 +.cfi_push %r13 + push %r14 +.cfi_push %r14 + push %r15 +.cfi_push %r15 +.Lsqr8x_prologue: + + mov ${num}d,%r10d + shl \$3,${num}d # convert $num to bytes + shl \$3+2,%r10 # 4*$num + neg $num + + ############################################################## + # ensure that stack frame doesn't alias with $aptr modulo + # 4096. this is done to allow memory disambiguation logic + # do its job. + # + lea -64(%rsp,$num,2),%r11 + mov %rsp,%rbp + mov ($n0),$n0 # *n0 + sub $aptr,%r11 + and \$4095,%r11 + cmp %r11,%r10 + jb .Lsqr8x_sp_alt + sub %r11,%rbp # align with $aptr + lea -64(%rbp,$num,2),%rbp # future alloca(frame+2*$num) + jmp .Lsqr8x_sp_done + +.align 32 +.Lsqr8x_sp_alt: + lea 4096-64(,$num,2),%r10 # 4096-frame-2*$num + lea -64(%rbp,$num,2),%rbp # future alloca(frame+2*$num) + sub %r10,%r11 + mov \$0,%r10 + cmovc %r10,%r11 + sub %r11,%rbp +.Lsqr8x_sp_done: + and \$-64,%rbp + mov %rsp,%r11 + sub %rbp,%r11 + and \$-4096,%r11 + lea (%rbp,%r11),%rsp + mov (%rsp),%r10 + cmp %rbp,%rsp + ja .Lsqr8x_page_walk + jmp .Lsqr8x_page_walk_done + +.align 16 +.Lsqr8x_page_walk: + lea -4096(%rsp),%rsp + mov (%rsp),%r10 + cmp %rbp,%rsp + ja .Lsqr8x_page_walk +.Lsqr8x_page_walk_done: + + mov $num,%r10 + neg $num + + mov $n0, 32(%rsp) + mov %rax, 40(%rsp) # save original %rsp +.cfi_cfa_expression %rsp+40,deref,+8 +.Lsqr8x_body: + + movq $nptr, %xmm2 # save pointer to modulus + pxor %xmm0,%xmm0 + movq $rptr,%xmm1 # save $rptr + movq %r10, %xmm3 # -$num +___ +$code.=<<___ if ($addx); + test $mulx_adx_capable,$mulx_adx_capable + jz .Lsqr8x_nox + + call bn_sqrx8x_internal # see x86_64-mont5 module + # %rax top-most carry + # %rbp nptr + # %rcx -8*num + # %r8 end of tp[2*num] + lea (%r8,%rcx),%rbx + mov %rcx,$num + mov %rcx,%rdx + movq %xmm1,$rptr + sar \$3+2,%rcx # %cf=0 + jmp .Lsqr8x_sub + +.align 32 +.Lsqr8x_nox: +___ +$code.=<<___; + call bn_sqr8x_internal # see x86_64-mont5 module + # %rax top-most carry + # %rbp nptr + # %r8 -8*num + # %rdi end of tp[2*num] + lea (%rdi,$num),%rbx + mov $num,%rcx + mov $num,%rdx + movq %xmm1,$rptr + sar \$3+2,%rcx # %cf=0 + jmp .Lsqr8x_sub + +.align 32 +.Lsqr8x_sub: + mov 8*0(%rbx),%r12 + mov 8*1(%rbx),%r13 + mov 8*2(%rbx),%r14 + mov 8*3(%rbx),%r15 + lea 8*4(%rbx),%rbx + sbb 8*0(%rbp),%r12 + sbb 8*1(%rbp),%r13 + sbb 8*2(%rbp),%r14 + sbb 8*3(%rbp),%r15 + lea 8*4(%rbp),%rbp + mov %r12,8*0($rptr) + mov %r13,8*1($rptr) + mov %r14,8*2($rptr) + mov %r15,8*3($rptr) + lea 8*4($rptr),$rptr + inc %rcx # preserves %cf + jnz .Lsqr8x_sub + + sbb \$0,%rax # top-most carry + lea (%rbx,$num),%rbx # rewind + lea ($rptr,$num),$rptr # rewind + + movq %rax,%xmm1 + pxor %xmm0,%xmm0 + pshufd \$0,%xmm1,%xmm1 + mov 40(%rsp),%rsi # restore %rsp +.cfi_def_cfa %rsi,8 + jmp .Lsqr8x_cond_copy + +.align 32 +.Lsqr8x_cond_copy: + movdqa 16*0(%rbx),%xmm2 + movdqa 16*1(%rbx),%xmm3 + lea 16*2(%rbx),%rbx + movdqu 16*0($rptr),%xmm4 + movdqu 16*1($rptr),%xmm5 + lea 16*2($rptr),$rptr + movdqa %xmm0,-16*2(%rbx) # zero tp + movdqa %xmm0,-16*1(%rbx) + movdqa %xmm0,-16*2(%rbx,%rdx) + movdqa %xmm0,-16*1(%rbx,%rdx) + pcmpeqd %xmm1,%xmm0 + pand %xmm1,%xmm2 + pand %xmm1,%xmm3 + pand %xmm0,%xmm4 + pand %xmm0,%xmm5 + pxor %xmm0,%xmm0 + por %xmm2,%xmm4 + por %xmm3,%xmm5 + movdqu %xmm4,-16*2($rptr) + movdqu %xmm5,-16*1($rptr) + add \$32,$num + jnz .Lsqr8x_cond_copy + + mov \$1,%rax + mov -48(%rsi),%r15 +.cfi_restore %r15 + mov -40(%rsi),%r14 +.cfi_restore %r14 + mov -32(%rsi),%r13 +.cfi_restore %r13 + mov -24(%rsi),%r12 +.cfi_restore %r12 + mov -16(%rsi),%rbp +.cfi_restore %rbp + mov -8(%rsi),%rbx +.cfi_restore %rbx + lea (%rsi),%rsp +.cfi_def_cfa_register %rsp +.Lsqr8x_epilogue: + ret +.cfi_endproc +.size bn_sqr8x_mont,.-bn_sqr8x_mont +___ +}}} + +if ($addx) {{{ +my $bp="%rdx"; # original value + +$code.=<<___; +.globl bn_mulx4x_mont +.type bn_mulx4x_mont,\@function,6 +.align 32 +bn_mulx4x_mont: +.cfi_startproc + _CET_ENDBR + mov %rsp,%rax +.cfi_def_cfa_register %rax + push %rbx +.cfi_push %rbx + push %rbp +.cfi_push %rbp + push %r12 +.cfi_push %r12 + push %r13 +.cfi_push %r13 + push %r14 +.cfi_push %r14 + push %r15 +.cfi_push %r15 +.Lmulx4x_prologue: + + shl \$3,${num}d # convert $num to bytes + xor %r10,%r10 + sub $num,%r10 # -$num + mov ($n0),$n0 # *n0 + lea -72(%rsp,%r10),%rbp # future alloca(frame+$num+8) + and \$-128,%rbp + mov %rsp,%r11 + sub %rbp,%r11 + and \$-4096,%r11 + lea (%rbp,%r11),%rsp + mov (%rsp),%r10 + cmp %rbp,%rsp + ja .Lmulx4x_page_walk + jmp .Lmulx4x_page_walk_done + +.align 16 +.Lmulx4x_page_walk: + lea -4096(%rsp),%rsp + mov (%rsp),%r10 + cmp %rbp,%rsp + ja .Lmulx4x_page_walk +.Lmulx4x_page_walk_done: + + lea ($bp,$num),%r10 + ############################################################## + # Stack layout + # +0 num + # +8 off-loaded &b[i] + # +16 end of b[num] + # +24 saved n0 + # +32 saved rp + # +40 saved %rsp + # +48 inner counter + # +56 + # +64 tmp[num+1] + # + mov $num,0(%rsp) # save $num + shr \$5,$num + mov %r10,16(%rsp) # end of b[num] + sub \$1,$num + mov $n0, 24(%rsp) # save *n0 + mov $rp, 32(%rsp) # save $rp + mov %rax,40(%rsp) # save original %rsp +.cfi_cfa_expression %rsp+40,deref,+8 + mov $num,48(%rsp) # inner counter + jmp .Lmulx4x_body + +.align 32 +.Lmulx4x_body: +___ +my ($aptr, $bptr, $nptr, $tptr, $mi, $bi, $zero, $num)= + ("%rsi","%rdi","%rcx","%rbx","%r8","%r9","%rbp","%rax"); +my $rptr=$bptr; +$code.=<<___; + lea 8($bp),$bptr + mov ($bp),%rdx # b[0], $bp==%rdx actually + lea 64+32(%rsp),$tptr + mov %rdx,$bi + + mulx 0*8($aptr),$mi,%rax # a[0]*b[0] + mulx 1*8($aptr),%r11,%r14 # a[1]*b[0] + add %rax,%r11 + mov $bptr,8(%rsp) # off-load &b[i] + mulx 2*8($aptr),%r12,%r13 # ... + adc %r14,%r12 + adc \$0,%r13 + + mov $mi,$bptr # borrow $bptr + imulq 24(%rsp),$mi # "t[0]"*n0 + xor $zero,$zero # cf=0, of=0 + + mulx 3*8($aptr),%rax,%r14 + mov $mi,%rdx + lea 4*8($aptr),$aptr + adcx %rax,%r13 + adcx $zero,%r14 # cf=0 + + mulx 0*8($nptr),%rax,%r10 + adcx %rax,$bptr # discarded + adox %r11,%r10 + mulx 1*8($nptr),%rax,%r11 + adcx %rax,%r10 + adox %r12,%r11 + .byte 0xc4,0x62,0xfb,0xf6,0xa1,0x10,0x00,0x00,0x00 # mulx 2*8($nptr),%rax,%r12 + mov 48(%rsp),$bptr # counter value + mov %r10,-4*8($tptr) + adcx %rax,%r11 + adox %r13,%r12 + mulx 3*8($nptr),%rax,%r15 + mov $bi,%rdx + mov %r11,-3*8($tptr) + adcx %rax,%r12 + adox $zero,%r15 # of=0 + lea 4*8($nptr),$nptr + mov %r12,-2*8($tptr) + + jmp .Lmulx4x_1st + +.align 32 +.Lmulx4x_1st: + adcx $zero,%r15 # cf=0, modulo-scheduled + mulx 0*8($aptr),%r10,%rax # a[4]*b[0] + adcx %r14,%r10 + mulx 1*8($aptr),%r11,%r14 # a[5]*b[0] + adcx %rax,%r11 + mulx 2*8($aptr),%r12,%rax # ... + adcx %r14,%r12 + mulx 3*8($aptr),%r13,%r14 + .byte 0x67,0x67 + mov $mi,%rdx + adcx %rax,%r13 + adcx $zero,%r14 # cf=0 + lea 4*8($aptr),$aptr + lea 4*8($tptr),$tptr + + adox %r15,%r10 + mulx 0*8($nptr),%rax,%r15 + adcx %rax,%r10 + adox %r15,%r11 + mulx 1*8($nptr),%rax,%r15 + adcx %rax,%r11 + adox %r15,%r12 + mulx 2*8($nptr),%rax,%r15 + mov %r10,-5*8($tptr) + adcx %rax,%r12 + mov %r11,-4*8($tptr) + adox %r15,%r13 + mulx 3*8($nptr),%rax,%r15 + mov $bi,%rdx + mov %r12,-3*8($tptr) + adcx %rax,%r13 + adox $zero,%r15 + lea 4*8($nptr),$nptr + mov %r13,-2*8($tptr) + + dec $bptr # of=0, pass cf + jnz .Lmulx4x_1st + + mov 0(%rsp),$num # load num + mov 8(%rsp),$bptr # re-load &b[i] + adc $zero,%r15 # modulo-scheduled + add %r15,%r14 + sbb %r15,%r15 # top-most carry + mov %r14,-1*8($tptr) + jmp .Lmulx4x_outer + +.align 32 +.Lmulx4x_outer: + mov ($bptr),%rdx # b[i] + lea 8($bptr),$bptr # b++ + sub $num,$aptr # rewind $aptr + mov %r15,($tptr) # save top-most carry + lea 64+4*8(%rsp),$tptr + sub $num,$nptr # rewind $nptr + + mulx 0*8($aptr),$mi,%r11 # a[0]*b[i] + xor %ebp,%ebp # xor $zero,$zero # cf=0, of=0 + mov %rdx,$bi + mulx 1*8($aptr),%r14,%r12 # a[1]*b[i] + adox -4*8($tptr),$mi + adcx %r14,%r11 + mulx 2*8($aptr),%r15,%r13 # ... + adox -3*8($tptr),%r11 + adcx %r15,%r12 + adox -2*8($tptr),%r12 + adcx $zero,%r13 + adox $zero,%r13 + + mov $bptr,8(%rsp) # off-load &b[i] + mov $mi,%r15 + imulq 24(%rsp),$mi # "t[0]"*n0 + xor %ebp,%ebp # xor $zero,$zero # cf=0, of=0 + + mulx 3*8($aptr),%rax,%r14 + mov $mi,%rdx + adcx %rax,%r13 + adox -1*8($tptr),%r13 + adcx $zero,%r14 + lea 4*8($aptr),$aptr + adox $zero,%r14 + + mulx 0*8($nptr),%rax,%r10 + adcx %rax,%r15 # discarded + adox %r11,%r10 + mulx 1*8($nptr),%rax,%r11 + adcx %rax,%r10 + adox %r12,%r11 + mulx 2*8($nptr),%rax,%r12 + mov %r10,-4*8($tptr) + adcx %rax,%r11 + adox %r13,%r12 + mulx 3*8($nptr),%rax,%r15 + mov $bi,%rdx + mov %r11,-3*8($tptr) + lea 4*8($nptr),$nptr + adcx %rax,%r12 + adox $zero,%r15 # of=0 + mov 48(%rsp),$bptr # counter value + mov %r12,-2*8($tptr) + + jmp .Lmulx4x_inner + +.align 32 +.Lmulx4x_inner: + mulx 0*8($aptr),%r10,%rax # a[4]*b[i] + adcx $zero,%r15 # cf=0, modulo-scheduled + adox %r14,%r10 + mulx 1*8($aptr),%r11,%r14 # a[5]*b[i] + adcx 0*8($tptr),%r10 + adox %rax,%r11 + mulx 2*8($aptr),%r12,%rax # ... + adcx 1*8($tptr),%r11 + adox %r14,%r12 + mulx 3*8($aptr),%r13,%r14 + mov $mi,%rdx + adcx 2*8($tptr),%r12 + adox %rax,%r13 + adcx 3*8($tptr),%r13 + adox $zero,%r14 # of=0 + lea 4*8($aptr),$aptr + lea 4*8($tptr),$tptr + adcx $zero,%r14 # cf=0 + + adox %r15,%r10 + mulx 0*8($nptr),%rax,%r15 + adcx %rax,%r10 + adox %r15,%r11 + mulx 1*8($nptr),%rax,%r15 + adcx %rax,%r11 + adox %r15,%r12 + mulx 2*8($nptr),%rax,%r15 + mov %r10,-5*8($tptr) + adcx %rax,%r12 + adox %r15,%r13 + mulx 3*8($nptr),%rax,%r15 + mov $bi,%rdx + mov %r11,-4*8($tptr) + mov %r12,-3*8($tptr) + adcx %rax,%r13 + adox $zero,%r15 + lea 4*8($nptr),$nptr + mov %r13,-2*8($tptr) + + dec $bptr # of=0, pass cf + jnz .Lmulx4x_inner + + mov 0(%rsp),$num # load num + mov 8(%rsp),$bptr # re-load &b[i] + adc $zero,%r15 # modulo-scheduled + sub 0*8($tptr),$zero # pull top-most carry + adc %r15,%r14 + sbb %r15,%r15 # top-most carry + mov %r14,-1*8($tptr) + + cmp 16(%rsp),$bptr + jne .Lmulx4x_outer + + lea 64(%rsp),$tptr + sub $num,$nptr # rewind $nptr + neg %r15 + mov $num,%rdx + shr \$3+2,$num # %cf=0 + mov 32(%rsp),$rptr # restore rp + jmp .Lmulx4x_sub + +.align 32 +.Lmulx4x_sub: + mov 8*0($tptr),%r11 + mov 8*1($tptr),%r12 + mov 8*2($tptr),%r13 + mov 8*3($tptr),%r14 + lea 8*4($tptr),$tptr + sbb 8*0($nptr),%r11 + sbb 8*1($nptr),%r12 + sbb 8*2($nptr),%r13 + sbb 8*3($nptr),%r14 + lea 8*4($nptr),$nptr + mov %r11,8*0($rptr) + mov %r12,8*1($rptr) + mov %r13,8*2($rptr) + mov %r14,8*3($rptr) + lea 8*4($rptr),$rptr + dec $num # preserves %cf + jnz .Lmulx4x_sub + + sbb \$0,%r15 # top-most carry + lea 64(%rsp),$tptr + sub %rdx,$rptr # rewind + + movq %r15,%xmm1 + pxor %xmm0,%xmm0 + pshufd \$0,%xmm1,%xmm1 + mov 40(%rsp),%rsi # restore %rsp +.cfi_def_cfa %rsi,8 + jmp .Lmulx4x_cond_copy + +.align 32 +.Lmulx4x_cond_copy: + movdqa 16*0($tptr),%xmm2 + movdqa 16*1($tptr),%xmm3 + lea 16*2($tptr),$tptr + movdqu 16*0($rptr),%xmm4 + movdqu 16*1($rptr),%xmm5 + lea 16*2($rptr),$rptr + movdqa %xmm0,-16*2($tptr) # zero tp + movdqa %xmm0,-16*1($tptr) + pcmpeqd %xmm1,%xmm0 + pand %xmm1,%xmm2 + pand %xmm1,%xmm3 + pand %xmm0,%xmm4 + pand %xmm0,%xmm5 + pxor %xmm0,%xmm0 + por %xmm2,%xmm4 + por %xmm3,%xmm5 + movdqu %xmm4,-16*2($rptr) + movdqu %xmm5,-16*1($rptr) + sub \$32,%rdx + jnz .Lmulx4x_cond_copy + + mov %rdx,($tptr) + + mov \$1,%rax + mov -48(%rsi),%r15 +.cfi_restore %r15 + mov -40(%rsi),%r14 +.cfi_restore %r14 + mov -32(%rsi),%r13 +.cfi_restore %r13 + mov -24(%rsi),%r12 +.cfi_restore %r12 + mov -16(%rsi),%rbp +.cfi_restore %rbp + mov -8(%rsi),%rbx +.cfi_restore %rbx + lea (%rsi),%rsp +.cfi_def_cfa_register %rsp +.Lmulx4x_epilogue: + ret +.cfi_endproc +.size bn_mulx4x_mont,.-bn_mulx4x_mont +___ +}}} +$code.=<<___; +.asciz "Montgomery Multiplication for x86_64, CRYPTOGAMS by " +.align 16 +___ + +# EXCEPTION_DISPOSITION handler (EXCEPTION_RECORD *rec,ULONG64 frame, +# CONTEXT *context,DISPATCHER_CONTEXT *disp) +if ($win64) { +$rec="%rcx"; +$frame="%rdx"; +$context="%r8"; +$disp="%r9"; + +$code.=<<___; +.extern __imp_RtlVirtualUnwind +.type mul_handler,\@abi-omnipotent +.align 16 +mul_handler: + push %rsi + push %rdi + push %rbx + push %rbp + push %r12 + push %r13 + push %r14 + push %r15 + pushfq + sub \$64,%rsp + + mov 120($context),%rax # pull context->Rax + mov 248($context),%rbx # pull context->Rip + + mov 8($disp),%rsi # disp->ImageBase + mov 56($disp),%r11 # disp->HandlerData + + mov 0(%r11),%r10d # HandlerData[0] + lea (%rsi,%r10),%r10 # end of prologue label + cmp %r10,%rbx # context->RipRsp + + mov 4(%r11),%r10d # HandlerData[1] + lea (%rsi,%r10),%r10 # epilogue label + cmp %r10,%rbx # context->Rip>=epilogue label + jae .Lcommon_seh_tail + + mov 192($context),%r10 # pull $num + mov 8(%rax,%r10,8),%rax # pull saved stack pointer + + jmp .Lcommon_pop_regs +.size mul_handler,.-mul_handler + +.type sqr_handler,\@abi-omnipotent +.align 16 +sqr_handler: + push %rsi + push %rdi + push %rbx + push %rbp + push %r12 + push %r13 + push %r14 + push %r15 + pushfq + sub \$64,%rsp + + mov 120($context),%rax # pull context->Rax + mov 248($context),%rbx # pull context->Rip + + mov 8($disp),%rsi # disp->ImageBase + mov 56($disp),%r11 # disp->HandlerData + + mov 0(%r11),%r10d # HandlerData[0] + lea (%rsi,%r10),%r10 # end of prologue label + cmp %r10,%rbx # context->Rip<.Lsqr_prologue + jb .Lcommon_seh_tail + + mov 4(%r11),%r10d # HandlerData[1] + lea (%rsi,%r10),%r10 # body label + cmp %r10,%rbx # context->Rip<.Lsqr_body + jb .Lcommon_pop_regs + + mov 152($context),%rax # pull context->Rsp + + mov 8(%r11),%r10d # HandlerData[2] + lea (%rsi,%r10),%r10 # epilogue label + cmp %r10,%rbx # context->Rip>=.Lsqr_epilogue + jae .Lcommon_seh_tail + + mov 40(%rax),%rax # pull saved stack pointer + +.Lcommon_pop_regs: + mov -8(%rax),%rbx + mov -16(%rax),%rbp + mov -24(%rax),%r12 + mov -32(%rax),%r13 + mov -40(%rax),%r14 + mov -48(%rax),%r15 + mov %rbx,144($context) # restore context->Rbx + mov %rbp,160($context) # restore context->Rbp + mov %r12,216($context) # restore context->R12 + mov %r13,224($context) # restore context->R13 + mov %r14,232($context) # restore context->R14 + mov %r15,240($context) # restore context->R15 + +.Lcommon_seh_tail: + mov 8(%rax),%rdi + mov 16(%rax),%rsi + mov %rax,152($context) # restore context->Rsp + mov %rsi,168($context) # restore context->Rsi + mov %rdi,176($context) # restore context->Rdi + + mov 40($disp),%rdi # disp->ContextRecord + mov $context,%rsi # context + mov \$154,%ecx # sizeof(CONTEXT) + .long 0xa548f3fc # cld; rep movsq + + mov $disp,%rsi + xor %rcx,%rcx # arg1, UNW_FLAG_NHANDLER + mov 8(%rsi),%rdx # arg2, disp->ImageBase + mov 0(%rsi),%r8 # arg3, disp->ControlPc + mov 16(%rsi),%r9 # arg4, disp->FunctionEntry + mov 40(%rsi),%r10 # disp->ContextRecord + lea 56(%rsi),%r11 # &disp->HandlerData + lea 24(%rsi),%r12 # &disp->EstablisherFrame + mov %r10,32(%rsp) # arg5 + mov %r11,40(%rsp) # arg6 + mov %r12,48(%rsp) # arg7 + mov %rcx,56(%rsp) # arg8, (NULL) + call *__imp_RtlVirtualUnwind(%rip) + + mov \$1,%eax # ExceptionContinueSearch + add \$64,%rsp + popfq + pop %r15 + pop %r14 + pop %r13 + pop %r12 + pop %rbp + pop %rbx + pop %rdi + pop %rsi + ret +.size sqr_handler,.-sqr_handler + +.section .pdata +.align 4 + .rva .LSEH_begin_bn_mul_mont_nohw + .rva .LSEH_end_bn_mul_mont_nohw + .rva .LSEH_info_bn_mul_mont_nohw + + .rva .LSEH_begin_bn_mul4x_mont + .rva .LSEH_end_bn_mul4x_mont + .rva .LSEH_info_bn_mul4x_mont + + .rva .LSEH_begin_bn_sqr8x_mont + .rva .LSEH_end_bn_sqr8x_mont + .rva .LSEH_info_bn_sqr8x_mont +___ +$code.=<<___ if ($addx); + .rva .LSEH_begin_bn_mulx4x_mont + .rva .LSEH_end_bn_mulx4x_mont + .rva .LSEH_info_bn_mulx4x_mont +___ +$code.=<<___; +.section .xdata +.align 8 +.LSEH_info_bn_mul_mont_nohw: + .byte 9,0,0,0 + .rva mul_handler + .rva .Lmul_body,.Lmul_epilogue # HandlerData[] +.LSEH_info_bn_mul4x_mont: + .byte 9,0,0,0 + .rva mul_handler + .rva .Lmul4x_body,.Lmul4x_epilogue # HandlerData[] +.LSEH_info_bn_sqr8x_mont: + .byte 9,0,0,0 + .rva sqr_handler + .rva .Lsqr8x_prologue,.Lsqr8x_body,.Lsqr8x_epilogue # HandlerData[] +.align 8 +___ +$code.=<<___ if ($addx); +.LSEH_info_bn_mulx4x_mont: + .byte 9,0,0,0 + .rva sqr_handler + .rva .Lmulx4x_prologue,.Lmulx4x_body,.Lmulx4x_epilogue # HandlerData[] +.align 8 +___ +} + +print $code; +close STDOUT or die "error closing STDOUT: $!"; diff --git a/http/vendor/ring/crypto/fipsmodule/bn/asm/x86_64-mont5.pl b/http/vendor/ring/crypto/fipsmodule/bn/asm/x86_64-mont5.pl new file mode 100644 index 0000000..e762871 --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/bn/asm/x86_64-mont5.pl @@ -0,0 +1,3352 @@ +#! /usr/bin/env perl +# Copyright 2011-2016 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# ==================================================================== +# Written by Andy Polyakov for the OpenSSL +# project. +# ==================================================================== + +# August 2011. +# +# Companion to x86_64-mont.pl that optimizes cache-timing attack +# countermeasures. The subroutines are produced by replacing bp[i] +# references in their x86_64-mont.pl counterparts with cache-neutral +# references to powers table computed in BN_mod_exp_mont_consttime. +# In addition subroutine that scatters elements of the powers table +# is implemented, so that scatter-/gathering can be tuned without +# bn_exp.c modifications. + +# August 2013. +# +# Add MULX/AD*X code paths and additional interfaces to optimize for +# branch prediction unit. For input lengths that are multiples of 8 +# the np argument is not just modulus value, but one interleaved +# with 0. This is to optimize post-condition... + +$flavour = shift; +$output = shift; +if ($flavour =~ /\./) { $output = $flavour; undef $flavour; } + +$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/); + +$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; +( $xlate="${dir}x86_64-xlate.pl" and -f $xlate ) or +( $xlate="${dir}../../../perlasm/x86_64-xlate.pl" and -f $xlate) or +die "can't locate x86_64-xlate.pl"; + +open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""; +*STDOUT=*OUT; + +# In upstream, this is controlled by shelling out to the compiler to check +# versions, but BoringSSL is intended to be used with pre-generated perlasm +# output, so this isn't useful anyway. +$addx = 1; + +# int bn_mul_mont_gather5_nohw( +$rp="%rdi"; # BN_ULONG *rp, +$ap="%rsi"; # const BN_ULONG *ap, +$bp="%rdx"; # const BN_ULONG *bp, +$np="%rcx"; # const BN_ULONG *np, +$n0="%r8"; # const BN_ULONG *n0, +$num="%r9"; # int num, + # int idx); # 0 to 2^5-1, "index" in $bp holding + # pre-computed powers of a', interlaced + # in such manner that b[0] is $bp[idx], + # b[1] is [2^5+idx], etc. +$lo0="%r10"; +$hi0="%r11"; +$hi1="%r13"; +$i="%r14"; +$j="%r15"; +$m0="%rbx"; +$m1="%rbp"; + +$code=<<___; +.text + +___ +{{{ +my @A=("%r10","%r11"); +my @N=("%r13","%rdi"); +$code.=<<___; +.globl bn_mul4x_mont_gather5 +.type bn_mul4x_mont_gather5,\@function,6 +.align 32 +bn_mul4x_mont_gather5: +.cfi_startproc + _CET_ENDBR + .byte 0x67 + mov %rsp,%rax +.cfi_def_cfa_register %rax + push %rbx +.cfi_push %rbx + push %rbp +.cfi_push %rbp + push %r12 +.cfi_push %r12 + push %r13 +.cfi_push %r13 + push %r14 +.cfi_push %r14 + push %r15 +.cfi_push %r15 +.Lmul4x_prologue: + + .byte 0x67 + # num is declared as an int, a 32-bit parameter, so the upper half is + # undefined. It is important that this write to ${num}, which zeros the + # upper half, predates the first access. + shl \$3,${num}d # convert $num to bytes + lea ($num,$num,2),%r10 # 3*$num in bytes + neg $num # -$num + + ############################################################## + # Ensure that stack frame doesn't alias with $rptr+3*$num + # modulo 4096, which covers ret[num], am[num] and n[num] + # (see bn_exp.c). This is done to allow memory disambiguation + # logic do its magic. [Extra [num] is allocated in order + # to align with bn_power5's frame, which is cleansed after + # completing exponentiation. Extra 256 bytes is for power mask + # calculated from 7th argument, the index.] + # + lea -320(%rsp,$num,2),%r11 + mov %rsp,%rbp + sub $rp,%r11 + and \$4095,%r11 + cmp %r11,%r10 + jb .Lmul4xsp_alt + sub %r11,%rbp # align with $rp + lea -320(%rbp,$num,2),%rbp # future alloca(frame+2*num*8+256) + jmp .Lmul4xsp_done + +.align 32 +.Lmul4xsp_alt: + lea 4096-320(,$num,2),%r10 + lea -320(%rbp,$num,2),%rbp # future alloca(frame+2*num*8+256) + sub %r10,%r11 + mov \$0,%r10 + cmovc %r10,%r11 + sub %r11,%rbp +.Lmul4xsp_done: + and \$-64,%rbp + mov %rsp,%r11 + sub %rbp,%r11 + and \$-4096,%r11 + lea (%rbp,%r11),%rsp + mov (%rsp),%r10 + cmp %rbp,%rsp + ja .Lmul4x_page_walk + jmp .Lmul4x_page_walk_done + +.Lmul4x_page_walk: + lea -4096(%rsp),%rsp + mov (%rsp),%r10 + cmp %rbp,%rsp + ja .Lmul4x_page_walk +.Lmul4x_page_walk_done: + + neg $num + + mov %rax,40(%rsp) +.cfi_cfa_expression %rsp+40,deref,+8 +.Lmul4x_body: + + call mul4x_internal + + mov 40(%rsp),%rsi # restore %rsp +.cfi_def_cfa %rsi,8 + mov \$1,%rax + + mov -48(%rsi),%r15 +.cfi_restore %r15 + mov -40(%rsi),%r14 +.cfi_restore %r14 + mov -32(%rsi),%r13 +.cfi_restore %r13 + mov -24(%rsi),%r12 +.cfi_restore %r12 + mov -16(%rsi),%rbp +.cfi_restore %rbp + mov -8(%rsi),%rbx +.cfi_restore %rbx + lea (%rsi),%rsp +.cfi_def_cfa_register %rsp +.Lmul4x_epilogue: + ret +.cfi_endproc +.size bn_mul4x_mont_gather5,.-bn_mul4x_mont_gather5 + +.type mul4x_internal,\@abi-omnipotent +.align 32 +mul4x_internal: +.cfi_startproc + shl \$5,$num # $num was in bytes + movd `($win64?56:8)`(%rax),%xmm5 # load 7th argument, index + lea .Linc(%rip),%rax + lea 128(%rdx,$num),%r13 # end of powers table (+size optimization) + shr \$5,$num # restore $num +___ + $bp="%r12"; + $STRIDE=2**5*8; # 5 is "window size" + $tp=$i; +$code.=<<___; + movdqa 0(%rax),%xmm0 # 00000001000000010000000000000000 + movdqa 16(%rax),%xmm1 # 00000002000000020000000200000002 + lea 88-112(%rsp,$num),%r10 # place the mask after tp[num+1] (+ICache optimization) + lea 128(%rdx),$bp # size optimization + + pshufd \$0,%xmm5,%xmm5 # broadcast index + movdqa %xmm1,%xmm4 + .byte 0x67,0x67 + movdqa %xmm1,%xmm2 +___ +######################################################################## +# Calculate masks by comparing 0..31 to $idx and save result to stack. +# +# We compute sixteen 16-byte masks and store them on the stack. Mask i is stored +# in `16*i - 128`(%rax) and contains the comparisons for idx == 2*i and +# idx == 2*i + 1 in its lower and upper halves, respectively. Mask calculations +# are scheduled in groups of four. +$code.=<<___; + paddd %xmm0,%xmm1 + pcmpeqd %xmm5,%xmm0 # compare to 1,0 + .byte 0x67 + movdqa %xmm4,%xmm3 +___ +for($i=0;$i<$STRIDE/16-4;$i+=4) { +$code.=<<___; + paddd %xmm1,%xmm2 + pcmpeqd %xmm5,%xmm1 # compare to 3,2 + movdqa %xmm0,`16*($i+0)+112`(%r10) + movdqa %xmm4,%xmm0 + + paddd %xmm2,%xmm3 + pcmpeqd %xmm5,%xmm2 # compare to 5,4 + movdqa %xmm1,`16*($i+1)+112`(%r10) + movdqa %xmm4,%xmm1 + + paddd %xmm3,%xmm0 + pcmpeqd %xmm5,%xmm3 # compare to 7,6 + movdqa %xmm2,`16*($i+2)+112`(%r10) + movdqa %xmm4,%xmm2 + + paddd %xmm0,%xmm1 + pcmpeqd %xmm5,%xmm0 + movdqa %xmm3,`16*($i+3)+112`(%r10) + movdqa %xmm4,%xmm3 +___ +} +$code.=<<___; # last iteration can be optimized + paddd %xmm1,%xmm2 + pcmpeqd %xmm5,%xmm1 + movdqa %xmm0,`16*($i+0)+112`(%r10) + + paddd %xmm2,%xmm3 + .byte 0x67 + pcmpeqd %xmm5,%xmm2 + movdqa %xmm1,`16*($i+1)+112`(%r10) + + pcmpeqd %xmm5,%xmm3 + movdqa %xmm2,`16*($i+2)+112`(%r10) + pand `16*($i+0)-128`($bp),%xmm0 # while it's still in register + + pand `16*($i+1)-128`($bp),%xmm1 + pand `16*($i+2)-128`($bp),%xmm2 + movdqa %xmm3,`16*($i+3)+112`(%r10) + pand `16*($i+3)-128`($bp),%xmm3 + por %xmm2,%xmm0 + por %xmm3,%xmm1 +___ +for($i=0;$i<$STRIDE/16-4;$i+=4) { +$code.=<<___; + movdqa `16*($i+0)-128`($bp),%xmm4 + movdqa `16*($i+1)-128`($bp),%xmm5 + movdqa `16*($i+2)-128`($bp),%xmm2 + pand `16*($i+0)+112`(%r10),%xmm4 + movdqa `16*($i+3)-128`($bp),%xmm3 + pand `16*($i+1)+112`(%r10),%xmm5 + por %xmm4,%xmm0 + pand `16*($i+2)+112`(%r10),%xmm2 + por %xmm5,%xmm1 + pand `16*($i+3)+112`(%r10),%xmm3 + por %xmm2,%xmm0 + por %xmm3,%xmm1 +___ +} +$code.=<<___; + por %xmm1,%xmm0 + # Combine the upper and lower halves of %xmm0. + pshufd \$0x4e,%xmm0,%xmm1 # Swap upper and lower halves. + por %xmm1,%xmm0 + lea $STRIDE($bp),$bp + movq %xmm0,$m0 # m0=bp[0] + + mov %r13,16+8(%rsp) # save end of b[num] + mov $rp, 56+8(%rsp) # save $rp + + mov ($n0),$n0 # pull n0[0] value + mov ($ap),%rax + lea ($ap,$num),$ap # end of a[num] + neg $num + + mov $n0,$m1 + mulq $m0 # ap[0]*bp[0] + mov %rax,$A[0] + mov ($np),%rax + + imulq $A[0],$m1 # "tp[0]"*n0 + lea 64+8(%rsp),$tp + mov %rdx,$A[1] + + mulq $m1 # np[0]*m1 + add %rax,$A[0] # discarded + mov 8($ap,$num),%rax + adc \$0,%rdx + mov %rdx,$N[1] + + mulq $m0 + add %rax,$A[1] + mov 8*1($np),%rax + adc \$0,%rdx + mov %rdx,$A[0] + + mulq $m1 + add %rax,$N[1] + mov 16($ap,$num),%rax + adc \$0,%rdx + add $A[1],$N[1] + lea 4*8($num),$j # j=4 + lea 8*4($np),$np + adc \$0,%rdx + mov $N[1],($tp) + mov %rdx,$N[0] + jmp .L1st4x + +.align 32 +.L1st4x: + mulq $m0 # ap[j]*bp[0] + add %rax,$A[0] + mov -8*2($np),%rax + lea 32($tp),$tp + adc \$0,%rdx + mov %rdx,$A[1] + + mulq $m1 # np[j]*m1 + add %rax,$N[0] + mov -8($ap,$j),%rax + adc \$0,%rdx + add $A[0],$N[0] # np[j]*m1+ap[j]*bp[0] + adc \$0,%rdx + mov $N[0],-24($tp) # tp[j-1] + mov %rdx,$N[1] + + mulq $m0 # ap[j]*bp[0] + add %rax,$A[1] + mov -8*1($np),%rax + adc \$0,%rdx + mov %rdx,$A[0] + + mulq $m1 # np[j]*m1 + add %rax,$N[1] + mov ($ap,$j),%rax + adc \$0,%rdx + add $A[1],$N[1] # np[j]*m1+ap[j]*bp[0] + adc \$0,%rdx + mov $N[1],-16($tp) # tp[j-1] + mov %rdx,$N[0] + + mulq $m0 # ap[j]*bp[0] + add %rax,$A[0] + mov 8*0($np),%rax + adc \$0,%rdx + mov %rdx,$A[1] + + mulq $m1 # np[j]*m1 + add %rax,$N[0] + mov 8($ap,$j),%rax + adc \$0,%rdx + add $A[0],$N[0] # np[j]*m1+ap[j]*bp[0] + adc \$0,%rdx + mov $N[0],-8($tp) # tp[j-1] + mov %rdx,$N[1] + + mulq $m0 # ap[j]*bp[0] + add %rax,$A[1] + mov 8*1($np),%rax + adc \$0,%rdx + mov %rdx,$A[0] + + mulq $m1 # np[j]*m1 + add %rax,$N[1] + mov 16($ap,$j),%rax + adc \$0,%rdx + add $A[1],$N[1] # np[j]*m1+ap[j]*bp[0] + lea 8*4($np),$np + adc \$0,%rdx + mov $N[1],($tp) # tp[j-1] + mov %rdx,$N[0] + + add \$32,$j # j+=4 + jnz .L1st4x + + mulq $m0 # ap[j]*bp[0] + add %rax,$A[0] + mov -8*2($np),%rax + lea 32($tp),$tp + adc \$0,%rdx + mov %rdx,$A[1] + + mulq $m1 # np[j]*m1 + add %rax,$N[0] + mov -8($ap),%rax + adc \$0,%rdx + add $A[0],$N[0] # np[j]*m1+ap[j]*bp[0] + adc \$0,%rdx + mov $N[0],-24($tp) # tp[j-1] + mov %rdx,$N[1] + + mulq $m0 # ap[j]*bp[0] + add %rax,$A[1] + mov -8*1($np),%rax + adc \$0,%rdx + mov %rdx,$A[0] + + mulq $m1 # np[j]*m1 + add %rax,$N[1] + mov ($ap,$num),%rax # ap[0] + adc \$0,%rdx + add $A[1],$N[1] # np[j]*m1+ap[j]*bp[0] + adc \$0,%rdx + mov $N[1],-16($tp) # tp[j-1] + mov %rdx,$N[0] + + lea ($np,$num),$np # rewind $np + + xor $N[1],$N[1] + add $A[0],$N[0] + adc \$0,$N[1] + mov $N[0],-8($tp) + + jmp .Louter4x + +.align 32 +.Louter4x: + lea 16+128($tp),%rdx # where 256-byte mask is (+size optimization) + pxor %xmm4,%xmm4 + pxor %xmm5,%xmm5 +___ +for($i=0;$i<$STRIDE/16;$i+=4) { +$code.=<<___; + movdqa `16*($i+0)-128`($bp),%xmm0 + movdqa `16*($i+1)-128`($bp),%xmm1 + movdqa `16*($i+2)-128`($bp),%xmm2 + movdqa `16*($i+3)-128`($bp),%xmm3 + pand `16*($i+0)-128`(%rdx),%xmm0 + pand `16*($i+1)-128`(%rdx),%xmm1 + por %xmm0,%xmm4 + pand `16*($i+2)-128`(%rdx),%xmm2 + por %xmm1,%xmm5 + pand `16*($i+3)-128`(%rdx),%xmm3 + por %xmm2,%xmm4 + por %xmm3,%xmm5 +___ +} +$code.=<<___; + por %xmm5,%xmm4 + # Combine the upper and lower halves of %xmm4 as %xmm0. + pshufd \$0x4e,%xmm4,%xmm0 # Swap upper and lower halves. + por %xmm4,%xmm0 + lea $STRIDE($bp),$bp + movq %xmm0,$m0 # m0=bp[i] + + mov ($tp,$num),$A[0] + mov $n0,$m1 + mulq $m0 # ap[0]*bp[i] + add %rax,$A[0] # ap[0]*bp[i]+tp[0] + mov ($np),%rax + adc \$0,%rdx + + imulq $A[0],$m1 # tp[0]*n0 + mov %rdx,$A[1] + mov $N[1],($tp) # store upmost overflow bit + + lea ($tp,$num),$tp # rewind $tp + + mulq $m1 # np[0]*m1 + add %rax,$A[0] # "$N[0]", discarded + mov 8($ap,$num),%rax + adc \$0,%rdx + mov %rdx,$N[1] + + mulq $m0 # ap[j]*bp[i] + add %rax,$A[1] + mov 8*1($np),%rax + adc \$0,%rdx + add 8($tp),$A[1] # +tp[1] + adc \$0,%rdx + mov %rdx,$A[0] + + mulq $m1 # np[j]*m1 + add %rax,$N[1] + mov 16($ap,$num),%rax + adc \$0,%rdx + add $A[1],$N[1] # np[j]*m1+ap[j]*bp[i]+tp[j] + lea 4*8($num),$j # j=4 + lea 8*4($np),$np + adc \$0,%rdx + mov %rdx,$N[0] + jmp .Linner4x + +.align 32 +.Linner4x: + mulq $m0 # ap[j]*bp[i] + add %rax,$A[0] + mov -8*2($np),%rax + adc \$0,%rdx + add 16($tp),$A[0] # ap[j]*bp[i]+tp[j] + lea 32($tp),$tp + adc \$0,%rdx + mov %rdx,$A[1] + + mulq $m1 # np[j]*m1 + add %rax,$N[0] + mov -8($ap,$j),%rax + adc \$0,%rdx + add $A[0],$N[0] + adc \$0,%rdx + mov $N[1],-32($tp) # tp[j-1] + mov %rdx,$N[1] + + mulq $m0 # ap[j]*bp[i] + add %rax,$A[1] + mov -8*1($np),%rax + adc \$0,%rdx + add -8($tp),$A[1] + adc \$0,%rdx + mov %rdx,$A[0] + + mulq $m1 # np[j]*m1 + add %rax,$N[1] + mov ($ap,$j),%rax + adc \$0,%rdx + add $A[1],$N[1] + adc \$0,%rdx + mov $N[0],-24($tp) # tp[j-1] + mov %rdx,$N[0] + + mulq $m0 # ap[j]*bp[i] + add %rax,$A[0] + mov 8*0($np),%rax + adc \$0,%rdx + add ($tp),$A[0] # ap[j]*bp[i]+tp[j] + adc \$0,%rdx + mov %rdx,$A[1] + + mulq $m1 # np[j]*m1 + add %rax,$N[0] + mov 8($ap,$j),%rax + adc \$0,%rdx + add $A[0],$N[0] + adc \$0,%rdx + mov $N[1],-16($tp) # tp[j-1] + mov %rdx,$N[1] + + mulq $m0 # ap[j]*bp[i] + add %rax,$A[1] + mov 8*1($np),%rax + adc \$0,%rdx + add 8($tp),$A[1] + adc \$0,%rdx + mov %rdx,$A[0] + + mulq $m1 # np[j]*m1 + add %rax,$N[1] + mov 16($ap,$j),%rax + adc \$0,%rdx + add $A[1],$N[1] + lea 8*4($np),$np + adc \$0,%rdx + mov $N[0],-8($tp) # tp[j-1] + mov %rdx,$N[0] + + add \$32,$j # j+=4 + jnz .Linner4x + + mulq $m0 # ap[j]*bp[i] + add %rax,$A[0] + mov -8*2($np),%rax + adc \$0,%rdx + add 16($tp),$A[0] # ap[j]*bp[i]+tp[j] + lea 32($tp),$tp + adc \$0,%rdx + mov %rdx,$A[1] + + mulq $m1 # np[j]*m1 + add %rax,$N[0] + mov -8($ap),%rax + adc \$0,%rdx + add $A[0],$N[0] + adc \$0,%rdx + mov $N[1],-32($tp) # tp[j-1] + mov %rdx,$N[1] + + mulq $m0 # ap[j]*bp[i] + add %rax,$A[1] + mov $m1,%rax + mov -8*1($np),$m1 + adc \$0,%rdx + add -8($tp),$A[1] + adc \$0,%rdx + mov %rdx,$A[0] + + mulq $m1 # np[j]*m1 + add %rax,$N[1] + mov ($ap,$num),%rax # ap[0] + adc \$0,%rdx + add $A[1],$N[1] + adc \$0,%rdx + mov $N[0],-24($tp) # tp[j-1] + mov %rdx,$N[0] + + mov $N[1],-16($tp) # tp[j-1] + lea ($np,$num),$np # rewind $np + + xor $N[1],$N[1] + add $A[0],$N[0] + adc \$0,$N[1] + add ($tp),$N[0] # pull upmost overflow bit + adc \$0,$N[1] # upmost overflow bit + mov $N[0],-8($tp) + + cmp 16+8(%rsp),$bp + jb .Louter4x +___ +if (1) { +$code.=<<___; + xor %rax,%rax + sub $N[0],$m1 # compare top-most words + adc $j,$j # $j is zero + or $j,$N[1] + sub $N[1],%rax # %rax=-$N[1] + lea ($tp,$num),%rbx # tptr in .sqr4x_sub + mov ($np),%r12 + lea ($np),%rbp # nptr in .sqr4x_sub + mov %r9,%rcx + sar \$3+2,%rcx + mov 56+8(%rsp),%rdi # rptr in .sqr4x_sub + dec %r12 # so that after 'not' we get -n[0] + xor %r10,%r10 + mov 8*1(%rbp),%r13 + mov 8*2(%rbp),%r14 + mov 8*3(%rbp),%r15 + jmp .Lsqr4x_sub_entry +___ +} +$code.=<<___; +.cfi_endproc +.size mul4x_internal,.-mul4x_internal +___ +}}} + {{{ +###################################################################### +# void bn_power5_nohw( +my $rptr="%rdi"; # BN_ULONG *rptr, +my $aptr="%rsi"; # const BN_ULONG *aptr, +my $bptr="%rdx"; # const void *table, +my $nptr="%rcx"; # const BN_ULONG *nptr, +my $n0 ="%r8"; # const BN_ULONG *n0); +my $num ="%r9"; # int num, has to be divisible by 8 + # int pwr + +my ($i,$j,$tptr)=("%rbp","%rcx",$rptr); +my @A0=("%r10","%r11"); +my @A1=("%r12","%r13"); +my ($a0,$a1,$ai)=("%r14","%r15","%rbx"); + +$code.=<<___; +.globl bn_power5_nohw +.type bn_power5_nohw,\@function,6 +.align 32 +bn_power5_nohw: +.cfi_startproc + _CET_ENDBR + mov %rsp,%rax +.cfi_def_cfa_register %rax + push %rbx +.cfi_push %rbx + push %rbp +.cfi_push %rbp + push %r12 +.cfi_push %r12 + push %r13 +.cfi_push %r13 + push %r14 +.cfi_push %r14 + push %r15 +.cfi_push %r15 +.Lpower5_prologue: + + # num is declared as an int, a 32-bit parameter, so the upper half is + # undefined. It is important that this write to ${num}, which zeros the + # upper half, come before the first access. + shl \$3,${num}d # convert $num to bytes + lea ($num,$num,2),%r10d # 3*$num + neg $num + mov ($n0),$n0 # *n0 + + ############################################################## + # Ensure that stack frame doesn't alias with $rptr+3*$num + # modulo 4096, which covers ret[num], am[num] and n[num] + # (see bn_exp.c). This is done to allow memory disambiguation + # logic do its magic. [Extra 256 bytes is for power mask + # calculated from 7th argument, the index.] + # + lea -320(%rsp,$num,2),%r11 + mov %rsp,%rbp + sub $rptr,%r11 + and \$4095,%r11 + cmp %r11,%r10 + jb .Lpwr_sp_alt + sub %r11,%rbp # align with $aptr + lea -320(%rbp,$num,2),%rbp # future alloca(frame+2*num*8+256) + jmp .Lpwr_sp_done + +.align 32 +.Lpwr_sp_alt: + lea 4096-320(,$num,2),%r10 + lea -320(%rbp,$num,2),%rbp # future alloca(frame+2*num*8+256) + sub %r10,%r11 + mov \$0,%r10 + cmovc %r10,%r11 + sub %r11,%rbp +.Lpwr_sp_done: + and \$-64,%rbp + mov %rsp,%r11 + sub %rbp,%r11 + and \$-4096,%r11 + lea (%rbp,%r11),%rsp + mov (%rsp),%r10 + cmp %rbp,%rsp + ja .Lpwr_page_walk + jmp .Lpwr_page_walk_done + +.Lpwr_page_walk: + lea -4096(%rsp),%rsp + mov (%rsp),%r10 + cmp %rbp,%rsp + ja .Lpwr_page_walk +.Lpwr_page_walk_done: + + mov $num,%r10 + neg $num + + ############################################################## + # Stack layout + # + # +0 saved $num, used in reduction section + # +8 &t[2*$num], used in reduction section + # +32 saved *n0 + # +40 saved %rsp + # +48 t[2*$num] + # + mov $n0, 32(%rsp) + mov %rax, 40(%rsp) # save original %rsp +.cfi_cfa_expression %rsp+40,deref,+8 +.Lpower5_body: + movq $rptr,%xmm1 # save $rptr, used in sqr8x + movq $nptr,%xmm2 # save $nptr + movq %r10, %xmm3 # -$num, used in sqr8x + movq $bptr,%xmm4 + + call __bn_sqr8x_internal + call __bn_post4x_internal + call __bn_sqr8x_internal + call __bn_post4x_internal + call __bn_sqr8x_internal + call __bn_post4x_internal + call __bn_sqr8x_internal + call __bn_post4x_internal + call __bn_sqr8x_internal + call __bn_post4x_internal + + movq %xmm2,$nptr + movq %xmm4,$bptr + mov $aptr,$rptr + mov 40(%rsp),%rax + lea 32(%rsp),$n0 + + call mul4x_internal + + mov 40(%rsp),%rsi # restore %rsp +.cfi_def_cfa %rsi,8 + mov \$1,%rax + mov -48(%rsi),%r15 +.cfi_restore %r15 + mov -40(%rsi),%r14 +.cfi_restore %r14 + mov -32(%rsi),%r13 +.cfi_restore %r13 + mov -24(%rsi),%r12 +.cfi_restore %r12 + mov -16(%rsi),%rbp +.cfi_restore %rbp + mov -8(%rsi),%rbx +.cfi_restore %rbx + lea (%rsi),%rsp +.cfi_def_cfa_register %rsp +.Lpower5_epilogue: + ret +.cfi_endproc +.size bn_power5_nohw,.-bn_power5_nohw + +.globl bn_sqr8x_internal +.hidden bn_sqr8x_internal +.type bn_sqr8x_internal,\@abi-omnipotent +.align 32 +bn_sqr8x_internal: +__bn_sqr8x_internal: +.cfi_startproc + _CET_ENDBR + ############################################################## + # Squaring part: + # + # a) multiply-n-add everything but a[i]*a[i]; + # b) shift result of a) by 1 to the left and accumulate + # a[i]*a[i] products; + # + ############################################################## + # a[1]a[0] + # a[2]a[0] + # a[3]a[0] + # a[2]a[1] + # a[4]a[0] + # a[3]a[1] + # a[5]a[0] + # a[4]a[1] + # a[3]a[2] + # a[6]a[0] + # a[5]a[1] + # a[4]a[2] + # a[7]a[0] + # a[6]a[1] + # a[5]a[2] + # a[4]a[3] + # a[7]a[1] + # a[6]a[2] + # a[5]a[3] + # a[7]a[2] + # a[6]a[3] + # a[5]a[4] + # a[7]a[3] + # a[6]a[4] + # a[7]a[4] + # a[6]a[5] + # a[7]a[5] + # a[7]a[6] + # a[1]a[0] + # a[2]a[0] + # a[3]a[0] + # a[4]a[0] + # a[5]a[0] + # a[6]a[0] + # a[7]a[0] + # a[2]a[1] + # a[3]a[1] + # a[4]a[1] + # a[5]a[1] + # a[6]a[1] + # a[7]a[1] + # a[3]a[2] + # a[4]a[2] + # a[5]a[2] + # a[6]a[2] + # a[7]a[2] + # a[4]a[3] + # a[5]a[3] + # a[6]a[3] + # a[7]a[3] + # a[5]a[4] + # a[6]a[4] + # a[7]a[4] + # a[6]a[5] + # a[7]a[5] + # a[7]a[6] + # a[0]a[0] + # a[1]a[1] + # a[2]a[2] + # a[3]a[3] + # a[4]a[4] + # a[5]a[5] + # a[6]a[6] + # a[7]a[7] + + lea 32(%r10),$i # $i=-($num-32) + lea ($aptr,$num),$aptr # end of a[] buffer, ($aptr,$i)=&ap[2] + + mov $num,$j # $j=$num + + # comments apply to $num==8 case + mov -32($aptr,$i),$a0 # a[0] + lea 48+8(%rsp,$num,2),$tptr # end of tp[] buffer, &tp[2*$num] + mov -24($aptr,$i),%rax # a[1] + lea -32($tptr,$i),$tptr # end of tp[] window, &tp[2*$num-"$i"] + mov -16($aptr,$i),$ai # a[2] + mov %rax,$a1 + + mul $a0 # a[1]*a[0] + mov %rax,$A0[0] # a[1]*a[0] + mov $ai,%rax # a[2] + mov %rdx,$A0[1] + mov $A0[0],-24($tptr,$i) # t[1] + + mul $a0 # a[2]*a[0] + add %rax,$A0[1] + mov $ai,%rax + adc \$0,%rdx + mov $A0[1],-16($tptr,$i) # t[2] + mov %rdx,$A0[0] + + + mov -8($aptr,$i),$ai # a[3] + mul $a1 # a[2]*a[1] + mov %rax,$A1[0] # a[2]*a[1]+t[3] + mov $ai,%rax + mov %rdx,$A1[1] + + lea ($i),$j + mul $a0 # a[3]*a[0] + add %rax,$A0[0] # a[3]*a[0]+a[2]*a[1]+t[3] + mov $ai,%rax + mov %rdx,$A0[1] + adc \$0,$A0[1] + add $A1[0],$A0[0] + adc \$0,$A0[1] + mov $A0[0],-8($tptr,$j) # t[3] + jmp .Lsqr4x_1st + +.align 32 +.Lsqr4x_1st: + mov ($aptr,$j),$ai # a[4] + mul $a1 # a[3]*a[1] + add %rax,$A1[1] # a[3]*a[1]+t[4] + mov $ai,%rax + mov %rdx,$A1[0] + adc \$0,$A1[0] + + mul $a0 # a[4]*a[0] + add %rax,$A0[1] # a[4]*a[0]+a[3]*a[1]+t[4] + mov $ai,%rax # a[3] + mov 8($aptr,$j),$ai # a[5] + mov %rdx,$A0[0] + adc \$0,$A0[0] + add $A1[1],$A0[1] + adc \$0,$A0[0] + + + mul $a1 # a[4]*a[3] + add %rax,$A1[0] # a[4]*a[3]+t[5] + mov $ai,%rax + mov $A0[1],($tptr,$j) # t[4] + mov %rdx,$A1[1] + adc \$0,$A1[1] + + mul $a0 # a[5]*a[2] + add %rax,$A0[0] # a[5]*a[2]+a[4]*a[3]+t[5] + mov $ai,%rax + mov 16($aptr,$j),$ai # a[6] + mov %rdx,$A0[1] + adc \$0,$A0[1] + add $A1[0],$A0[0] + adc \$0,$A0[1] + + mul $a1 # a[5]*a[3] + add %rax,$A1[1] # a[5]*a[3]+t[6] + mov $ai,%rax + mov $A0[0],8($tptr,$j) # t[5] + mov %rdx,$A1[0] + adc \$0,$A1[0] + + mul $a0 # a[6]*a[2] + add %rax,$A0[1] # a[6]*a[2]+a[5]*a[3]+t[6] + mov $ai,%rax # a[3] + mov 24($aptr,$j),$ai # a[7] + mov %rdx,$A0[0] + adc \$0,$A0[0] + add $A1[1],$A0[1] + adc \$0,$A0[0] + + + mul $a1 # a[6]*a[5] + add %rax,$A1[0] # a[6]*a[5]+t[7] + mov $ai,%rax + mov $A0[1],16($tptr,$j) # t[6] + mov %rdx,$A1[1] + adc \$0,$A1[1] + lea 32($j),$j + + mul $a0 # a[7]*a[4] + add %rax,$A0[0] # a[7]*a[4]+a[6]*a[5]+t[6] + mov $ai,%rax + mov %rdx,$A0[1] + adc \$0,$A0[1] + add $A1[0],$A0[0] + adc \$0,$A0[1] + mov $A0[0],-8($tptr,$j) # t[7] + + cmp \$0,$j + jne .Lsqr4x_1st + + mul $a1 # a[7]*a[5] + add %rax,$A1[1] + lea 16($i),$i + adc \$0,%rdx + add $A0[1],$A1[1] + adc \$0,%rdx + + mov $A1[1],($tptr) # t[8] + mov %rdx,$A1[0] + mov %rdx,8($tptr) # t[9] + jmp .Lsqr4x_outer + +.align 32 +.Lsqr4x_outer: # comments apply to $num==6 case + mov -32($aptr,$i),$a0 # a[0] + lea 48+8(%rsp,$num,2),$tptr # end of tp[] buffer, &tp[2*$num] + mov -24($aptr,$i),%rax # a[1] + lea -32($tptr,$i),$tptr # end of tp[] window, &tp[2*$num-"$i"] + mov -16($aptr,$i),$ai # a[2] + mov %rax,$a1 + + mul $a0 # a[1]*a[0] + mov -24($tptr,$i),$A0[0] # t[1] + add %rax,$A0[0] # a[1]*a[0]+t[1] + mov $ai,%rax # a[2] + adc \$0,%rdx + mov $A0[0],-24($tptr,$i) # t[1] + mov %rdx,$A0[1] + + mul $a0 # a[2]*a[0] + add %rax,$A0[1] + mov $ai,%rax + adc \$0,%rdx + add -16($tptr,$i),$A0[1] # a[2]*a[0]+t[2] + mov %rdx,$A0[0] + adc \$0,$A0[0] + mov $A0[1],-16($tptr,$i) # t[2] + + xor $A1[0],$A1[0] + + mov -8($aptr,$i),$ai # a[3] + mul $a1 # a[2]*a[1] + add %rax,$A1[0] # a[2]*a[1]+t[3] + mov $ai,%rax + adc \$0,%rdx + add -8($tptr,$i),$A1[0] + mov %rdx,$A1[1] + adc \$0,$A1[1] + + mul $a0 # a[3]*a[0] + add %rax,$A0[0] # a[3]*a[0]+a[2]*a[1]+t[3] + mov $ai,%rax + adc \$0,%rdx + add $A1[0],$A0[0] + mov %rdx,$A0[1] + adc \$0,$A0[1] + mov $A0[0],-8($tptr,$i) # t[3] + + lea ($i),$j + jmp .Lsqr4x_inner + +.align 32 +.Lsqr4x_inner: + mov ($aptr,$j),$ai # a[4] + mul $a1 # a[3]*a[1] + add %rax,$A1[1] # a[3]*a[1]+t[4] + mov $ai,%rax + mov %rdx,$A1[0] + adc \$0,$A1[0] + add ($tptr,$j),$A1[1] + adc \$0,$A1[0] + + .byte 0x67 + mul $a0 # a[4]*a[0] + add %rax,$A0[1] # a[4]*a[0]+a[3]*a[1]+t[4] + mov $ai,%rax # a[3] + mov 8($aptr,$j),$ai # a[5] + mov %rdx,$A0[0] + adc \$0,$A0[0] + add $A1[1],$A0[1] + adc \$0,$A0[0] + + mul $a1 # a[4]*a[3] + add %rax,$A1[0] # a[4]*a[3]+t[5] + mov $A0[1],($tptr,$j) # t[4] + mov $ai,%rax + mov %rdx,$A1[1] + adc \$0,$A1[1] + add 8($tptr,$j),$A1[0] + lea 16($j),$j # j++ + adc \$0,$A1[1] + + mul $a0 # a[5]*a[2] + add %rax,$A0[0] # a[5]*a[2]+a[4]*a[3]+t[5] + mov $ai,%rax + adc \$0,%rdx + add $A1[0],$A0[0] + mov %rdx,$A0[1] + adc \$0,$A0[1] + mov $A0[0],-8($tptr,$j) # t[5], "preloaded t[1]" below + + cmp \$0,$j + jne .Lsqr4x_inner + + .byte 0x67 + mul $a1 # a[5]*a[3] + add %rax,$A1[1] + adc \$0,%rdx + add $A0[1],$A1[1] + adc \$0,%rdx + + mov $A1[1],($tptr) # t[6], "preloaded t[2]" below + mov %rdx,$A1[0] + mov %rdx,8($tptr) # t[7], "preloaded t[3]" below + + add \$16,$i + jnz .Lsqr4x_outer + + # comments apply to $num==4 case + mov -32($aptr),$a0 # a[0] + lea 48+8(%rsp,$num,2),$tptr # end of tp[] buffer, &tp[2*$num] + mov -24($aptr),%rax # a[1] + lea -32($tptr,$i),$tptr # end of tp[] window, &tp[2*$num-"$i"] + mov -16($aptr),$ai # a[2] + mov %rax,$a1 + + mul $a0 # a[1]*a[0] + add %rax,$A0[0] # a[1]*a[0]+t[1], preloaded t[1] + mov $ai,%rax # a[2] + mov %rdx,$A0[1] + adc \$0,$A0[1] + + mul $a0 # a[2]*a[0] + add %rax,$A0[1] + mov $ai,%rax + mov $A0[0],-24($tptr) # t[1] + mov %rdx,$A0[0] + adc \$0,$A0[0] + add $A1[1],$A0[1] # a[2]*a[0]+t[2], preloaded t[2] + mov -8($aptr),$ai # a[3] + adc \$0,$A0[0] + + mul $a1 # a[2]*a[1] + add %rax,$A1[0] # a[2]*a[1]+t[3], preloaded t[3] + mov $ai,%rax + mov $A0[1],-16($tptr) # t[2] + mov %rdx,$A1[1] + adc \$0,$A1[1] + + mul $a0 # a[3]*a[0] + add %rax,$A0[0] # a[3]*a[0]+a[2]*a[1]+t[3] + mov $ai,%rax + mov %rdx,$A0[1] + adc \$0,$A0[1] + add $A1[0],$A0[0] + adc \$0,$A0[1] + mov $A0[0],-8($tptr) # t[3] + + mul $a1 # a[3]*a[1] + add %rax,$A1[1] + mov -16($aptr),%rax # a[2] + adc \$0,%rdx + add $A0[1],$A1[1] + adc \$0,%rdx + + mov $A1[1],($tptr) # t[4] + mov %rdx,$A1[0] + mov %rdx,8($tptr) # t[5] + + mul $ai # a[2]*a[3] +___ +{ +my ($shift,$carry)=($a0,$a1); +my @S=(@A1,$ai,$n0); +$code.=<<___; + add \$16,$i + xor $shift,$shift + sub $num,$i # $i=16-$num + xor $carry,$carry + + add $A1[0],%rax # t[5] + adc \$0,%rdx + mov %rax,8($tptr) # t[5] + mov %rdx,16($tptr) # t[6] + mov $carry,24($tptr) # t[7] + + mov -16($aptr,$i),%rax # a[0] + lea 48+8(%rsp),$tptr + xor $A0[0],$A0[0] # t[0] + mov 8($tptr),$A0[1] # t[1] + + lea ($shift,$A0[0],2),$S[0] # t[2*i]<<1 | shift + shr \$63,$A0[0] + lea ($j,$A0[1],2),$S[1] # t[2*i+1]<<1 | + shr \$63,$A0[1] + or $A0[0],$S[1] # | t[2*i]>>63 + mov 16($tptr),$A0[0] # t[2*i+2] # prefetch + mov $A0[1],$shift # shift=t[2*i+1]>>63 + mul %rax # a[i]*a[i] + neg $carry # mov $carry,cf + mov 24($tptr),$A0[1] # t[2*i+2+1] # prefetch + adc %rax,$S[0] + mov -8($aptr,$i),%rax # a[i+1] # prefetch + mov $S[0],($tptr) + adc %rdx,$S[1] + + lea ($shift,$A0[0],2),$S[2] # t[2*i]<<1 | shift + mov $S[1],8($tptr) + sbb $carry,$carry # mov cf,$carry + shr \$63,$A0[0] + lea ($j,$A0[1],2),$S[3] # t[2*i+1]<<1 | + shr \$63,$A0[1] + or $A0[0],$S[3] # | t[2*i]>>63 + mov 32($tptr),$A0[0] # t[2*i+2] # prefetch + mov $A0[1],$shift # shift=t[2*i+1]>>63 + mul %rax # a[i]*a[i] + neg $carry # mov $carry,cf + mov 40($tptr),$A0[1] # t[2*i+2+1] # prefetch + adc %rax,$S[2] + mov 0($aptr,$i),%rax # a[i+1] # prefetch + mov $S[2],16($tptr) + adc %rdx,$S[3] + lea 16($i),$i + mov $S[3],24($tptr) + sbb $carry,$carry # mov cf,$carry + lea 64($tptr),$tptr + jmp .Lsqr4x_shift_n_add + +.align 32 +.Lsqr4x_shift_n_add: + lea ($shift,$A0[0],2),$S[0] # t[2*i]<<1 | shift + shr \$63,$A0[0] + lea ($j,$A0[1],2),$S[1] # t[2*i+1]<<1 | + shr \$63,$A0[1] + or $A0[0],$S[1] # | t[2*i]>>63 + mov -16($tptr),$A0[0] # t[2*i+2] # prefetch + mov $A0[1],$shift # shift=t[2*i+1]>>63 + mul %rax # a[i]*a[i] + neg $carry # mov $carry,cf + mov -8($tptr),$A0[1] # t[2*i+2+1] # prefetch + adc %rax,$S[0] + mov -8($aptr,$i),%rax # a[i+1] # prefetch + mov $S[0],-32($tptr) + adc %rdx,$S[1] + + lea ($shift,$A0[0],2),$S[2] # t[2*i]<<1 | shift + mov $S[1],-24($tptr) + sbb $carry,$carry # mov cf,$carry + shr \$63,$A0[0] + lea ($j,$A0[1],2),$S[3] # t[2*i+1]<<1 | + shr \$63,$A0[1] + or $A0[0],$S[3] # | t[2*i]>>63 + mov 0($tptr),$A0[0] # t[2*i+2] # prefetch + mov $A0[1],$shift # shift=t[2*i+1]>>63 + mul %rax # a[i]*a[i] + neg $carry # mov $carry,cf + mov 8($tptr),$A0[1] # t[2*i+2+1] # prefetch + adc %rax,$S[2] + mov 0($aptr,$i),%rax # a[i+1] # prefetch + mov $S[2],-16($tptr) + adc %rdx,$S[3] + + lea ($shift,$A0[0],2),$S[0] # t[2*i]<<1 | shift + mov $S[3],-8($tptr) + sbb $carry,$carry # mov cf,$carry + shr \$63,$A0[0] + lea ($j,$A0[1],2),$S[1] # t[2*i+1]<<1 | + shr \$63,$A0[1] + or $A0[0],$S[1] # | t[2*i]>>63 + mov 16($tptr),$A0[0] # t[2*i+2] # prefetch + mov $A0[1],$shift # shift=t[2*i+1]>>63 + mul %rax # a[i]*a[i] + neg $carry # mov $carry,cf + mov 24($tptr),$A0[1] # t[2*i+2+1] # prefetch + adc %rax,$S[0] + mov 8($aptr,$i),%rax # a[i+1] # prefetch + mov $S[0],0($tptr) + adc %rdx,$S[1] + + lea ($shift,$A0[0],2),$S[2] # t[2*i]<<1 | shift + mov $S[1],8($tptr) + sbb $carry,$carry # mov cf,$carry + shr \$63,$A0[0] + lea ($j,$A0[1],2),$S[3] # t[2*i+1]<<1 | + shr \$63,$A0[1] + or $A0[0],$S[3] # | t[2*i]>>63 + mov 32($tptr),$A0[0] # t[2*i+2] # prefetch + mov $A0[1],$shift # shift=t[2*i+1]>>63 + mul %rax # a[i]*a[i] + neg $carry # mov $carry,cf + mov 40($tptr),$A0[1] # t[2*i+2+1] # prefetch + adc %rax,$S[2] + mov 16($aptr,$i),%rax # a[i+1] # prefetch + mov $S[2],16($tptr) + adc %rdx,$S[3] + mov $S[3],24($tptr) + sbb $carry,$carry # mov cf,$carry + lea 64($tptr),$tptr + add \$32,$i + jnz .Lsqr4x_shift_n_add + + lea ($shift,$A0[0],2),$S[0] # t[2*i]<<1 | shift + .byte 0x67 + shr \$63,$A0[0] + lea ($j,$A0[1],2),$S[1] # t[2*i+1]<<1 | + shr \$63,$A0[1] + or $A0[0],$S[1] # | t[2*i]>>63 + mov -16($tptr),$A0[0] # t[2*i+2] # prefetch + mov $A0[1],$shift # shift=t[2*i+1]>>63 + mul %rax # a[i]*a[i] + neg $carry # mov $carry,cf + mov -8($tptr),$A0[1] # t[2*i+2+1] # prefetch + adc %rax,$S[0] + mov -8($aptr),%rax # a[i+1] # prefetch + mov $S[0],-32($tptr) + adc %rdx,$S[1] + + lea ($shift,$A0[0],2),$S[2] # t[2*i]<<1|shift + mov $S[1],-24($tptr) + sbb $carry,$carry # mov cf,$carry + shr \$63,$A0[0] + lea ($j,$A0[1],2),$S[3] # t[2*i+1]<<1 | + shr \$63,$A0[1] + or $A0[0],$S[3] # | t[2*i]>>63 + mul %rax # a[i]*a[i] + neg $carry # mov $carry,cf + adc %rax,$S[2] + adc %rdx,$S[3] + mov $S[2],-16($tptr) + mov $S[3],-8($tptr) +___ +} +###################################################################### +# Montgomery reduction part, "word-by-word" algorithm. +# +# This new path is inspired by multiple submissions from Intel, by +# Shay Gueron, Vlad Krasnov, Erdinc Ozturk, James Guilford, +# Vinodh Gopal... +{ +my ($nptr,$tptr,$carry,$m0)=("%rbp","%rdi","%rsi","%rbx"); + +$code.=<<___; + movq %xmm2,$nptr +__bn_sqr8x_reduction: + xor %rax,%rax + lea ($nptr,$num),%rcx # end of n[] + lea 48+8(%rsp,$num,2),%rdx # end of t[] buffer + mov %rcx,0+8(%rsp) + lea 48+8(%rsp,$num),$tptr # end of initial t[] window + mov %rdx,8+8(%rsp) + neg $num + jmp .L8x_reduction_loop + +.align 32 +.L8x_reduction_loop: + lea ($tptr,$num),$tptr # start of current t[] window + .byte 0x66 + mov 8*0($tptr),$m0 + mov 8*1($tptr),%r9 + mov 8*2($tptr),%r10 + mov 8*3($tptr),%r11 + mov 8*4($tptr),%r12 + mov 8*5($tptr),%r13 + mov 8*6($tptr),%r14 + mov 8*7($tptr),%r15 + mov %rax,(%rdx) # store top-most carry bit + lea 8*8($tptr),$tptr + + .byte 0x67 + mov $m0,%r8 + imulq 32+8(%rsp),$m0 # n0*a[0] + mov 8*0($nptr),%rax # n[0] + mov \$8,%ecx + jmp .L8x_reduce + +.align 32 +.L8x_reduce: + mulq $m0 + mov 8*1($nptr),%rax # n[1] + neg %r8 + mov %rdx,%r8 + adc \$0,%r8 + + mulq $m0 + add %rax,%r9 + mov 8*2($nptr),%rax + adc \$0,%rdx + add %r9,%r8 + mov $m0,48-8+8(%rsp,%rcx,8) # put aside n0*a[i] + mov %rdx,%r9 + adc \$0,%r9 + + mulq $m0 + add %rax,%r10 + mov 8*3($nptr),%rax + adc \$0,%rdx + add %r10,%r9 + mov 32+8(%rsp),$carry # pull n0, borrow $carry + mov %rdx,%r10 + adc \$0,%r10 + + mulq $m0 + add %rax,%r11 + mov 8*4($nptr),%rax + adc \$0,%rdx + imulq %r8,$carry # modulo-scheduled + add %r11,%r10 + mov %rdx,%r11 + adc \$0,%r11 + + mulq $m0 + add %rax,%r12 + mov 8*5($nptr),%rax + adc \$0,%rdx + add %r12,%r11 + mov %rdx,%r12 + adc \$0,%r12 + + mulq $m0 + add %rax,%r13 + mov 8*6($nptr),%rax + adc \$0,%rdx + add %r13,%r12 + mov %rdx,%r13 + adc \$0,%r13 + + mulq $m0 + add %rax,%r14 + mov 8*7($nptr),%rax + adc \$0,%rdx + add %r14,%r13 + mov %rdx,%r14 + adc \$0,%r14 + + mulq $m0 + mov $carry,$m0 # n0*a[i] + add %rax,%r15 + mov 8*0($nptr),%rax # n[0] + adc \$0,%rdx + add %r15,%r14 + mov %rdx,%r15 + adc \$0,%r15 + + dec %ecx + jnz .L8x_reduce + + lea 8*8($nptr),$nptr + xor %rax,%rax + mov 8+8(%rsp),%rdx # pull end of t[] + cmp 0+8(%rsp),$nptr # end of n[]? + jae .L8x_no_tail + + .byte 0x66 + add 8*0($tptr),%r8 + adc 8*1($tptr),%r9 + adc 8*2($tptr),%r10 + adc 8*3($tptr),%r11 + adc 8*4($tptr),%r12 + adc 8*5($tptr),%r13 + adc 8*6($tptr),%r14 + adc 8*7($tptr),%r15 + sbb $carry,$carry # top carry + + mov 48+56+8(%rsp),$m0 # pull n0*a[0] + mov \$8,%ecx + mov 8*0($nptr),%rax + jmp .L8x_tail + +.align 32 +.L8x_tail: + mulq $m0 + add %rax,%r8 + mov 8*1($nptr),%rax + mov %r8,($tptr) # save result + mov %rdx,%r8 + adc \$0,%r8 + + mulq $m0 + add %rax,%r9 + mov 8*2($nptr),%rax + adc \$0,%rdx + add %r9,%r8 + lea 8($tptr),$tptr # $tptr++ + mov %rdx,%r9 + adc \$0,%r9 + + mulq $m0 + add %rax,%r10 + mov 8*3($nptr),%rax + adc \$0,%rdx + add %r10,%r9 + mov %rdx,%r10 + adc \$0,%r10 + + mulq $m0 + add %rax,%r11 + mov 8*4($nptr),%rax + adc \$0,%rdx + add %r11,%r10 + mov %rdx,%r11 + adc \$0,%r11 + + mulq $m0 + add %rax,%r12 + mov 8*5($nptr),%rax + adc \$0,%rdx + add %r12,%r11 + mov %rdx,%r12 + adc \$0,%r12 + + mulq $m0 + add %rax,%r13 + mov 8*6($nptr),%rax + adc \$0,%rdx + add %r13,%r12 + mov %rdx,%r13 + adc \$0,%r13 + + mulq $m0 + add %rax,%r14 + mov 8*7($nptr),%rax + adc \$0,%rdx + add %r14,%r13 + mov %rdx,%r14 + adc \$0,%r14 + + mulq $m0 + mov 48-16+8(%rsp,%rcx,8),$m0# pull n0*a[i] + add %rax,%r15 + adc \$0,%rdx + add %r15,%r14 + mov 8*0($nptr),%rax # pull n[0] + mov %rdx,%r15 + adc \$0,%r15 + + dec %ecx + jnz .L8x_tail + + lea 8*8($nptr),$nptr + mov 8+8(%rsp),%rdx # pull end of t[] + cmp 0+8(%rsp),$nptr # end of n[]? + jae .L8x_tail_done # break out of loop + + mov 48+56+8(%rsp),$m0 # pull n0*a[0] + neg $carry + mov 8*0($nptr),%rax # pull n[0] + adc 8*0($tptr),%r8 + adc 8*1($tptr),%r9 + adc 8*2($tptr),%r10 + adc 8*3($tptr),%r11 + adc 8*4($tptr),%r12 + adc 8*5($tptr),%r13 + adc 8*6($tptr),%r14 + adc 8*7($tptr),%r15 + sbb $carry,$carry # top carry + + mov \$8,%ecx + jmp .L8x_tail + +.align 32 +.L8x_tail_done: + xor %rax,%rax + add (%rdx),%r8 # can this overflow? + adc \$0,%r9 + adc \$0,%r10 + adc \$0,%r11 + adc \$0,%r12 + adc \$0,%r13 + adc \$0,%r14 + adc \$0,%r15 + adc \$0,%rax + + neg $carry +.L8x_no_tail: + adc 8*0($tptr),%r8 + adc 8*1($tptr),%r9 + adc 8*2($tptr),%r10 + adc 8*3($tptr),%r11 + adc 8*4($tptr),%r12 + adc 8*5($tptr),%r13 + adc 8*6($tptr),%r14 + adc 8*7($tptr),%r15 + adc \$0,%rax # top-most carry + mov -8($nptr),%rcx # np[num-1] + xor $carry,$carry + + movq %xmm2,$nptr # restore $nptr + + mov %r8,8*0($tptr) # store top 512 bits + mov %r9,8*1($tptr) + movq %xmm3,$num # $num is %r9, can't be moved upwards + mov %r10,8*2($tptr) + mov %r11,8*3($tptr) + mov %r12,8*4($tptr) + mov %r13,8*5($tptr) + mov %r14,8*6($tptr) + mov %r15,8*7($tptr) + lea 8*8($tptr),$tptr + + cmp %rdx,$tptr # end of t[]? + jb .L8x_reduction_loop + ret +.cfi_endproc +.size bn_sqr8x_internal,.-bn_sqr8x_internal +___ +} +############################################################## +# Post-condition, 4x unrolled +# +{ +my ($tptr,$nptr)=("%rbx","%rbp"); +$code.=<<___; +.type __bn_post4x_internal,\@abi-omnipotent +.align 32 +__bn_post4x_internal: +.cfi_startproc + mov 8*0($nptr),%r12 + lea (%rdi,$num),$tptr # %rdi was $tptr above + mov $num,%rcx + movq %xmm1,$rptr # restore $rptr + neg %rax + movq %xmm1,$aptr # prepare for back-to-back call + sar \$3+2,%rcx + dec %r12 # so that after 'not' we get -n[0] + xor %r10,%r10 + mov 8*1($nptr),%r13 + mov 8*2($nptr),%r14 + mov 8*3($nptr),%r15 + jmp .Lsqr4x_sub_entry + +.align 16 +.Lsqr4x_sub: + mov 8*0($nptr),%r12 + mov 8*1($nptr),%r13 + mov 8*2($nptr),%r14 + mov 8*3($nptr),%r15 +.Lsqr4x_sub_entry: + lea 8*4($nptr),$nptr + not %r12 + not %r13 + not %r14 + not %r15 + and %rax,%r12 + and %rax,%r13 + and %rax,%r14 + and %rax,%r15 + + neg %r10 # mov %r10,%cf + adc 8*0($tptr),%r12 + adc 8*1($tptr),%r13 + adc 8*2($tptr),%r14 + adc 8*3($tptr),%r15 + mov %r12,8*0($rptr) + lea 8*4($tptr),$tptr + mov %r13,8*1($rptr) + sbb %r10,%r10 # mov %cf,%r10 + mov %r14,8*2($rptr) + mov %r15,8*3($rptr) + lea 8*4($rptr),$rptr + + inc %rcx # pass %cf + jnz .Lsqr4x_sub + + mov $num,%r10 # prepare for back-to-back call + neg $num # restore $num + ret +.cfi_endproc +.size __bn_post4x_internal,.-__bn_post4x_internal +___ +} +}}} + +if ($addx) {{{ +my $bp="%rdx"; # restore original value + +$code.=<<___; +.globl bn_mulx4x_mont_gather5 +.type bn_mulx4x_mont_gather5,\@function,6 +.align 32 +bn_mulx4x_mont_gather5: +.cfi_startproc + _CET_ENDBR + mov %rsp,%rax +.cfi_def_cfa_register %rax + push %rbx +.cfi_push %rbx + push %rbp +.cfi_push %rbp + push %r12 +.cfi_push %r12 + push %r13 +.cfi_push %r13 + push %r14 +.cfi_push %r14 + push %r15 +.cfi_push %r15 +.Lmulx4x_prologue: + + # num is declared as an int, a 32-bit parameter, so the upper half is + # undefined. It is important that this write to ${num}, which zeros the + # upper half, predates the first access. + shl \$3,${num}d # convert $num to bytes + lea ($num,$num,2),%r10 # 3*$num in bytes + neg $num # -$num + mov ($n0),$n0 # *n0 + + ############################################################## + # Ensure that stack frame doesn't alias with $rptr+3*$num + # modulo 4096, which covers ret[num], am[num] and n[num] + # (see bn_exp.c). This is done to allow memory disambiguation + # logic do its magic. [Extra [num] is allocated in order + # to align with bn_power5's frame, which is cleansed after + # completing exponentiation. Extra 256 bytes is for power mask + # calculated from 7th argument, the index.] + # + lea -320(%rsp,$num,2),%r11 + mov %rsp,%rbp + sub $rp,%r11 + and \$4095,%r11 + cmp %r11,%r10 + jb .Lmulx4xsp_alt + sub %r11,%rbp # align with $aptr + lea -320(%rbp,$num,2),%rbp # future alloca(frame+2*$num*8+256) + jmp .Lmulx4xsp_done + +.Lmulx4xsp_alt: + lea 4096-320(,$num,2),%r10 + lea -320(%rbp,$num,2),%rbp # future alloca(frame+2*$num*8+256) + sub %r10,%r11 + mov \$0,%r10 + cmovc %r10,%r11 + sub %r11,%rbp +.Lmulx4xsp_done: + and \$-64,%rbp # ensure alignment + mov %rsp,%r11 + sub %rbp,%r11 + and \$-4096,%r11 + lea (%rbp,%r11),%rsp + mov (%rsp),%r10 + cmp %rbp,%rsp + ja .Lmulx4x_page_walk + jmp .Lmulx4x_page_walk_done + +.Lmulx4x_page_walk: + lea -4096(%rsp),%rsp + mov (%rsp),%r10 + cmp %rbp,%rsp + ja .Lmulx4x_page_walk +.Lmulx4x_page_walk_done: + + ############################################################## + # Stack layout + # +0 -num + # +8 off-loaded &b[i] + # +16 end of b[num] + # +24 inner counter + # +32 saved n0 + # +40 saved %rsp + # +48 + # +56 saved rp + # +64 tmp[num+1] + # + mov $n0, 32(%rsp) # save *n0 + mov %rax,40(%rsp) # save original %rsp +.cfi_cfa_expression %rsp+40,deref,+8 +.Lmulx4x_body: + call mulx4x_internal + + mov 40(%rsp),%rsi # restore %rsp +.cfi_def_cfa %rsi,8 + mov \$1,%rax + + mov -48(%rsi),%r15 +.cfi_restore %r15 + mov -40(%rsi),%r14 +.cfi_restore %r14 + mov -32(%rsi),%r13 +.cfi_restore %r13 + mov -24(%rsi),%r12 +.cfi_restore %r12 + mov -16(%rsi),%rbp +.cfi_restore %rbp + mov -8(%rsi),%rbx +.cfi_restore %rbx + lea (%rsi),%rsp +.cfi_def_cfa_register %rsp +.Lmulx4x_epilogue: + ret +.cfi_endproc +.size bn_mulx4x_mont_gather5,.-bn_mulx4x_mont_gather5 + +.type mulx4x_internal,\@abi-omnipotent +.align 32 +mulx4x_internal: +.cfi_startproc + mov $num,8(%rsp) # save -$num (it was in bytes) + mov $num,%r10 + neg $num # restore $num + shl \$5,$num + neg %r10 # restore $num + lea 128($bp,$num),%r13 # end of powers table (+size optimization) + shr \$5+5,$num + movd `($win64?56:8)`(%rax),%xmm5 # load 7th argument + sub \$1,$num + lea .Linc(%rip),%rax + mov %r13,16+8(%rsp) # end of b[num] + mov $num,24+8(%rsp) # inner counter + mov $rp, 56+8(%rsp) # save $rp +___ +my ($aptr, $bptr, $nptr, $tptr, $mi, $bi, $zero, $num)= + ("%rsi","%rdi","%rcx","%rbx","%r8","%r9","%rbp","%rax"); +my $rptr=$bptr; +my $STRIDE=2**5*8; # 5 is "window size" +$code.=<<___; + movdqa 0(%rax),%xmm0 # 00000001000000010000000000000000 + movdqa 16(%rax),%xmm1 # 00000002000000020000000200000002 + lea 88-112(%rsp,%r10),%r10 # place the mask after tp[num+1] (+ICache optimization) + lea 128($bp),$bptr # size optimization + + pshufd \$0,%xmm5,%xmm5 # broadcast index + movdqa %xmm1,%xmm4 + .byte 0x67 + movdqa %xmm1,%xmm2 +___ +######################################################################## +# Calculate masks by comparing 0..31 to $idx and save result to stack. +# +# We compute sixteen 16-byte masks and store them on the stack. Mask i is stored +# in `16*i - 128`(%rax) and contains the comparisons for idx == 2*i and +# idx == 2*i + 1 in its lower and upper halves, respectively. Mask calculations +# are scheduled in groups of four. +$code.=<<___; + .byte 0x67 + paddd %xmm0,%xmm1 + pcmpeqd %xmm5,%xmm0 # compare to 1,0 + movdqa %xmm4,%xmm3 +___ +for($i=0;$i<$STRIDE/16-4;$i+=4) { +$code.=<<___; + paddd %xmm1,%xmm2 + pcmpeqd %xmm5,%xmm1 # compare to 3,2 + movdqa %xmm0,`16*($i+0)+112`(%r10) + movdqa %xmm4,%xmm0 + + paddd %xmm2,%xmm3 + pcmpeqd %xmm5,%xmm2 # compare to 5,4 + movdqa %xmm1,`16*($i+1)+112`(%r10) + movdqa %xmm4,%xmm1 + + paddd %xmm3,%xmm0 + pcmpeqd %xmm5,%xmm3 # compare to 7,6 + movdqa %xmm2,`16*($i+2)+112`(%r10) + movdqa %xmm4,%xmm2 + + paddd %xmm0,%xmm1 + pcmpeqd %xmm5,%xmm0 + movdqa %xmm3,`16*($i+3)+112`(%r10) + movdqa %xmm4,%xmm3 +___ +} +$code.=<<___; # last iteration can be optimized + .byte 0x67 + paddd %xmm1,%xmm2 + pcmpeqd %xmm5,%xmm1 + movdqa %xmm0,`16*($i+0)+112`(%r10) + + paddd %xmm2,%xmm3 + pcmpeqd %xmm5,%xmm2 + movdqa %xmm1,`16*($i+1)+112`(%r10) + + pcmpeqd %xmm5,%xmm3 + movdqa %xmm2,`16*($i+2)+112`(%r10) + + pand `16*($i+0)-128`($bptr),%xmm0 # while it's still in register + pand `16*($i+1)-128`($bptr),%xmm1 + pand `16*($i+2)-128`($bptr),%xmm2 + movdqa %xmm3,`16*($i+3)+112`(%r10) + pand `16*($i+3)-128`($bptr),%xmm3 + por %xmm2,%xmm0 + por %xmm3,%xmm1 +___ +for($i=0;$i<$STRIDE/16-4;$i+=4) { +$code.=<<___; + movdqa `16*($i+0)-128`($bptr),%xmm4 + movdqa `16*($i+1)-128`($bptr),%xmm5 + movdqa `16*($i+2)-128`($bptr),%xmm2 + pand `16*($i+0)+112`(%r10),%xmm4 + movdqa `16*($i+3)-128`($bptr),%xmm3 + pand `16*($i+1)+112`(%r10),%xmm5 + por %xmm4,%xmm0 + pand `16*($i+2)+112`(%r10),%xmm2 + por %xmm5,%xmm1 + pand `16*($i+3)+112`(%r10),%xmm3 + por %xmm2,%xmm0 + por %xmm3,%xmm1 +___ +} +$code.=<<___; + pxor %xmm1,%xmm0 + # Combine the upper and lower halves of %xmm0. + pshufd \$0x4e,%xmm0,%xmm1 # Swap upper and lower halves. + por %xmm1,%xmm0 + lea $STRIDE($bptr),$bptr + movq %xmm0,%rdx # bp[0] + lea 64+8*4+8(%rsp),$tptr + + mov %rdx,$bi + mulx 0*8($aptr),$mi,%rax # a[0]*b[0] + mulx 1*8($aptr),%r11,%r12 # a[1]*b[0] + add %rax,%r11 + mulx 2*8($aptr),%rax,%r13 # ... + adc %rax,%r12 + adc \$0,%r13 + mulx 3*8($aptr),%rax,%r14 + + mov $mi,%r15 + imulq 32+8(%rsp),$mi # "t[0]"*n0 + xor $zero,$zero # cf=0, of=0 + mov $mi,%rdx + + mov $bptr,8+8(%rsp) # off-load &b[i] + + lea 4*8($aptr),$aptr + adcx %rax,%r13 + adcx $zero,%r14 # cf=0 + + mulx 0*8($nptr),%rax,%r10 + adcx %rax,%r15 # discarded + adox %r11,%r10 + mulx 1*8($nptr),%rax,%r11 + adcx %rax,%r10 + adox %r12,%r11 + mulx 2*8($nptr),%rax,%r12 + mov 24+8(%rsp),$bptr # counter value + mov %r10,-8*4($tptr) + adcx %rax,%r11 + adox %r13,%r12 + mulx 3*8($nptr),%rax,%r15 + mov $bi,%rdx + mov %r11,-8*3($tptr) + adcx %rax,%r12 + adox $zero,%r15 # of=0 + lea 4*8($nptr),$nptr + mov %r12,-8*2($tptr) + jmp .Lmulx4x_1st + +.align 32 +.Lmulx4x_1st: + adcx $zero,%r15 # cf=0, modulo-scheduled + mulx 0*8($aptr),%r10,%rax # a[4]*b[0] + adcx %r14,%r10 + mulx 1*8($aptr),%r11,%r14 # a[5]*b[0] + adcx %rax,%r11 + mulx 2*8($aptr),%r12,%rax # ... + adcx %r14,%r12 + mulx 3*8($aptr),%r13,%r14 + .byte 0x67,0x67 + mov $mi,%rdx + adcx %rax,%r13 + adcx $zero,%r14 # cf=0 + lea 4*8($aptr),$aptr + lea 4*8($tptr),$tptr + + adox %r15,%r10 + mulx 0*8($nptr),%rax,%r15 + adcx %rax,%r10 + adox %r15,%r11 + mulx 1*8($nptr),%rax,%r15 + adcx %rax,%r11 + adox %r15,%r12 + mulx 2*8($nptr),%rax,%r15 + mov %r10,-5*8($tptr) + adcx %rax,%r12 + mov %r11,-4*8($tptr) + adox %r15,%r13 + mulx 3*8($nptr),%rax,%r15 + mov $bi,%rdx + mov %r12,-3*8($tptr) + adcx %rax,%r13 + adox $zero,%r15 + lea 4*8($nptr),$nptr + mov %r13,-2*8($tptr) + + dec $bptr # of=0, pass cf + jnz .Lmulx4x_1st + + mov 8(%rsp),$num # load -num + adc $zero,%r15 # modulo-scheduled + lea ($aptr,$num),$aptr # rewind $aptr + add %r15,%r14 + mov 8+8(%rsp),$bptr # re-load &b[i] + adc $zero,$zero # top-most carry + mov %r14,-1*8($tptr) + jmp .Lmulx4x_outer + +.align 32 +.Lmulx4x_outer: + lea 16-256($tptr),%r10 # where 256-byte mask is (+density control) + pxor %xmm4,%xmm4 + .byte 0x67,0x67 + pxor %xmm5,%xmm5 +___ +for($i=0;$i<$STRIDE/16;$i+=4) { +$code.=<<___; + movdqa `16*($i+0)-128`($bptr),%xmm0 + movdqa `16*($i+1)-128`($bptr),%xmm1 + movdqa `16*($i+2)-128`($bptr),%xmm2 + pand `16*($i+0)+256`(%r10),%xmm0 + movdqa `16*($i+3)-128`($bptr),%xmm3 + pand `16*($i+1)+256`(%r10),%xmm1 + por %xmm0,%xmm4 + pand `16*($i+2)+256`(%r10),%xmm2 + por %xmm1,%xmm5 + pand `16*($i+3)+256`(%r10),%xmm3 + por %xmm2,%xmm4 + por %xmm3,%xmm5 +___ +} +$code.=<<___; + por %xmm5,%xmm4 + # Combine the upper and lower halves of %xmm4 as %xmm0. + pshufd \$0x4e,%xmm4,%xmm0 # Swap upper and lower halves. + por %xmm4,%xmm0 + lea $STRIDE($bptr),$bptr + movq %xmm0,%rdx # m0=bp[i] + + mov $zero,($tptr) # save top-most carry + lea 4*8($tptr,$num),$tptr # rewind $tptr + mulx 0*8($aptr),$mi,%r11 # a[0]*b[i] + xor $zero,$zero # cf=0, of=0 + mov %rdx,$bi + mulx 1*8($aptr),%r14,%r12 # a[1]*b[i] + adox -4*8($tptr),$mi # +t[0] + adcx %r14,%r11 + mulx 2*8($aptr),%r15,%r13 # ... + adox -3*8($tptr),%r11 + adcx %r15,%r12 + mulx 3*8($aptr),%rdx,%r14 + adox -2*8($tptr),%r12 + adcx %rdx,%r13 + lea ($nptr,$num),$nptr # rewind $nptr + lea 4*8($aptr),$aptr + adox -1*8($tptr),%r13 + adcx $zero,%r14 + adox $zero,%r14 + + mov $mi,%r15 + imulq 32+8(%rsp),$mi # "t[0]"*n0 + + mov $mi,%rdx + xor $zero,$zero # cf=0, of=0 + mov $bptr,8+8(%rsp) # off-load &b[i] + + mulx 0*8($nptr),%rax,%r10 + adcx %rax,%r15 # discarded + adox %r11,%r10 + mulx 1*8($nptr),%rax,%r11 + adcx %rax,%r10 + adox %r12,%r11 + mulx 2*8($nptr),%rax,%r12 + adcx %rax,%r11 + adox %r13,%r12 + mulx 3*8($nptr),%rax,%r15 + mov $bi,%rdx + mov 24+8(%rsp),$bptr # counter value + mov %r10,-8*4($tptr) + adcx %rax,%r12 + mov %r11,-8*3($tptr) + adox $zero,%r15 # of=0 + mov %r12,-8*2($tptr) + lea 4*8($nptr),$nptr + jmp .Lmulx4x_inner + +.align 32 +.Lmulx4x_inner: + mulx 0*8($aptr),%r10,%rax # a[4]*b[i] + adcx $zero,%r15 # cf=0, modulo-scheduled + adox %r14,%r10 + mulx 1*8($aptr),%r11,%r14 # a[5]*b[i] + adcx 0*8($tptr),%r10 + adox %rax,%r11 + mulx 2*8($aptr),%r12,%rax # ... + adcx 1*8($tptr),%r11 + adox %r14,%r12 + mulx 3*8($aptr),%r13,%r14 + mov $mi,%rdx + adcx 2*8($tptr),%r12 + adox %rax,%r13 + adcx 3*8($tptr),%r13 + adox $zero,%r14 # of=0 + lea 4*8($aptr),$aptr + lea 4*8($tptr),$tptr + adcx $zero,%r14 # cf=0 + + adox %r15,%r10 + mulx 0*8($nptr),%rax,%r15 + adcx %rax,%r10 + adox %r15,%r11 + mulx 1*8($nptr),%rax,%r15 + adcx %rax,%r11 + adox %r15,%r12 + mulx 2*8($nptr),%rax,%r15 + mov %r10,-5*8($tptr) + adcx %rax,%r12 + adox %r15,%r13 + mov %r11,-4*8($tptr) + mulx 3*8($nptr),%rax,%r15 + mov $bi,%rdx + lea 4*8($nptr),$nptr + mov %r12,-3*8($tptr) + adcx %rax,%r13 + adox $zero,%r15 + mov %r13,-2*8($tptr) + + dec $bptr # of=0, pass cf + jnz .Lmulx4x_inner + + mov 0+8(%rsp),$num # load -num + adc $zero,%r15 # modulo-scheduled + sub 0*8($tptr),$bptr # pull top-most carry to %cf + mov 8+8(%rsp),$bptr # re-load &b[i] + mov 16+8(%rsp),%r10 + adc %r15,%r14 + lea ($aptr,$num),$aptr # rewind $aptr + adc $zero,$zero # top-most carry + mov %r14,-1*8($tptr) + + cmp %r10,$bptr + jb .Lmulx4x_outer + + mov -8($nptr),%r10 + mov $zero,%r8 + mov ($nptr,$num),%r12 + lea ($nptr,$num),%rbp # rewind $nptr + mov $num,%rcx + lea ($tptr,$num),%rdi # rewind $tptr + xor %eax,%eax + xor %r15,%r15 + sub %r14,%r10 # compare top-most words + adc %r15,%r15 + or %r15,%r8 + sar \$3+2,%rcx + sub %r8,%rax # %rax=-%r8 + mov 56+8(%rsp),%rdx # restore rp + dec %r12 # so that after 'not' we get -n[0] + mov 8*1(%rbp),%r13 + xor %r8,%r8 + mov 8*2(%rbp),%r14 + mov 8*3(%rbp),%r15 + jmp .Lsqrx4x_sub_entry # common post-condition +.cfi_endproc +.size mulx4x_internal,.-mulx4x_internal +___ +} { +###################################################################### +# void bn_powerx5( +my $rptr="%rdi"; # BN_ULONG *rptr, +my $aptr="%rsi"; # const BN_ULONG *aptr, +my $bptr="%rdx"; # const void *table, +my $nptr="%rcx"; # const BN_ULONG *nptr, +my $n0 ="%r8"; # const BN_ULONG *n0); +my $num ="%r9"; # int num, has to be divisible by 8 + # int pwr); + +my ($i,$j,$tptr)=("%rbp","%rcx",$rptr); +my @A0=("%r10","%r11"); +my @A1=("%r12","%r13"); +my ($a0,$a1,$ai)=("%r14","%r15","%rbx"); + +$code.=<<___; +.globl bn_powerx5 +.type bn_powerx5,\@function,6 +.align 32 +bn_powerx5: +.cfi_startproc + _CET_ENDBR + mov %rsp,%rax +.cfi_def_cfa_register %rax + push %rbx +.cfi_push %rbx + push %rbp +.cfi_push %rbp + push %r12 +.cfi_push %r12 + push %r13 +.cfi_push %r13 + push %r14 +.cfi_push %r14 + push %r15 +.cfi_push %r15 +.Lpowerx5_prologue: + + # num is declared as an int, a 32-bit parameter, so the upper half is + # undefined. It is important that this write to ${num}, which zeros the + # upper half, predates the first access. + shl \$3,${num}d # convert $num to bytes + lea ($num,$num,2),%r10 # 3*$num in bytes + neg $num + mov ($n0),$n0 # *n0 + + ############################################################## + # Ensure that stack frame doesn't alias with $rptr+3*$num + # modulo 4096, which covers ret[num], am[num] and n[num] + # (see bn_exp.c). This is done to allow memory disambiguation + # logic do its magic. [Extra 256 bytes is for power mask + # calculated from 7th argument, the index.] + # + lea -320(%rsp,$num,2),%r11 + mov %rsp,%rbp + sub $rptr,%r11 + and \$4095,%r11 + cmp %r11,%r10 + jb .Lpwrx_sp_alt + sub %r11,%rbp # align with $aptr + lea -320(%rbp,$num,2),%rbp # future alloca(frame+2*$num*8+256) + jmp .Lpwrx_sp_done + +.align 32 +.Lpwrx_sp_alt: + lea 4096-320(,$num,2),%r10 + lea -320(%rbp,$num,2),%rbp # alloca(frame+2*$num*8+256) + sub %r10,%r11 + mov \$0,%r10 + cmovc %r10,%r11 + sub %r11,%rbp +.Lpwrx_sp_done: + and \$-64,%rbp + mov %rsp,%r11 + sub %rbp,%r11 + and \$-4096,%r11 + lea (%rbp,%r11),%rsp + mov (%rsp),%r10 + cmp %rbp,%rsp + ja .Lpwrx_page_walk + jmp .Lpwrx_page_walk_done + +.Lpwrx_page_walk: + lea -4096(%rsp),%rsp + mov (%rsp),%r10 + cmp %rbp,%rsp + ja .Lpwrx_page_walk +.Lpwrx_page_walk_done: + + mov $num,%r10 + neg $num + + ############################################################## + # Stack layout + # + # +0 saved $num, used in reduction section + # +8 &t[2*$num], used in reduction section + # +16 intermediate carry bit + # +24 top-most carry bit, used in reduction section + # +32 saved *n0 + # +40 saved %rsp + # +48 t[2*$num] + # + pxor %xmm0,%xmm0 + movq $rptr,%xmm1 # save $rptr + movq $nptr,%xmm2 # save $nptr + movq %r10, %xmm3 # -$num + movq $bptr,%xmm4 + mov $n0, 32(%rsp) + mov %rax, 40(%rsp) # save original %rsp +.cfi_cfa_expression %rsp+40,deref,+8 +.Lpowerx5_body: + + call __bn_sqrx8x_internal + call __bn_postx4x_internal + call __bn_sqrx8x_internal + call __bn_postx4x_internal + call __bn_sqrx8x_internal + call __bn_postx4x_internal + call __bn_sqrx8x_internal + call __bn_postx4x_internal + call __bn_sqrx8x_internal + call __bn_postx4x_internal + + mov %r10,$num # -num + mov $aptr,$rptr + movq %xmm2,$nptr + movq %xmm4,$bptr + mov 40(%rsp),%rax + + call mulx4x_internal + + mov 40(%rsp),%rsi # restore %rsp +.cfi_def_cfa %rsi,8 + mov \$1,%rax + + mov -48(%rsi),%r15 +.cfi_restore %r15 + mov -40(%rsi),%r14 +.cfi_restore %r14 + mov -32(%rsi),%r13 +.cfi_restore %r13 + mov -24(%rsi),%r12 +.cfi_restore %r12 + mov -16(%rsi),%rbp +.cfi_restore %rbp + mov -8(%rsi),%rbx +.cfi_restore %rbx + lea (%rsi),%rsp +.cfi_def_cfa_register %rsp +.Lpowerx5_epilogue: + ret +.cfi_endproc +.size bn_powerx5,.-bn_powerx5 + +.globl bn_sqrx8x_internal +.hidden bn_sqrx8x_internal +.type bn_sqrx8x_internal,\@abi-omnipotent +.align 32 +bn_sqrx8x_internal: +__bn_sqrx8x_internal: +.cfi_startproc + _CET_ENDBR + ################################################################## + # Squaring part: + # + # a) multiply-n-add everything but a[i]*a[i]; + # b) shift result of a) by 1 to the left and accumulate + # a[i]*a[i] products; + # + ################################################################## + # a[7]a[7]a[6]a[6]a[5]a[5]a[4]a[4]a[3]a[3]a[2]a[2]a[1]a[1]a[0]a[0] + # a[1]a[0] + # a[2]a[0] + # a[3]a[0] + # a[2]a[1] + # a[3]a[1] + # a[3]a[2] + # + # a[4]a[0] + # a[5]a[0] + # a[6]a[0] + # a[7]a[0] + # a[4]a[1] + # a[5]a[1] + # a[6]a[1] + # a[7]a[1] + # a[4]a[2] + # a[5]a[2] + # a[6]a[2] + # a[7]a[2] + # a[4]a[3] + # a[5]a[3] + # a[6]a[3] + # a[7]a[3] + # + # a[5]a[4] + # a[6]a[4] + # a[7]a[4] + # a[6]a[5] + # a[7]a[5] + # a[7]a[6] + # a[7]a[7]a[6]a[6]a[5]a[5]a[4]a[4]a[3]a[3]a[2]a[2]a[1]a[1]a[0]a[0] +___ +{ +my ($zero,$carry)=("%rbp","%rcx"); +my $aaptr=$zero; +$code.=<<___; + lea 48+8(%rsp),$tptr + lea ($aptr,$num),$aaptr + mov $num,0+8(%rsp) # save $num + mov $aaptr,8+8(%rsp) # save end of $aptr + jmp .Lsqr8x_zero_start + +.align 32 +.byte 0x66,0x66,0x66,0x2e,0x0f,0x1f,0x84,0x00,0x00,0x00,0x00,0x00 +.Lsqrx8x_zero: + .byte 0x3e + movdqa %xmm0,0*8($tptr) + movdqa %xmm0,2*8($tptr) + movdqa %xmm0,4*8($tptr) + movdqa %xmm0,6*8($tptr) +.Lsqr8x_zero_start: # aligned at 32 + movdqa %xmm0,8*8($tptr) + movdqa %xmm0,10*8($tptr) + movdqa %xmm0,12*8($tptr) + movdqa %xmm0,14*8($tptr) + lea 16*8($tptr),$tptr + sub \$64,$num + jnz .Lsqrx8x_zero + + mov 0*8($aptr),%rdx # a[0], modulo-scheduled + #xor %r9,%r9 # t[1], ex-$num, zero already + xor %r10,%r10 + xor %r11,%r11 + xor %r12,%r12 + xor %r13,%r13 + xor %r14,%r14 + xor %r15,%r15 + lea 48+8(%rsp),$tptr + xor $zero,$zero # cf=0, cf=0 + jmp .Lsqrx8x_outer_loop + +.align 32 +.Lsqrx8x_outer_loop: + mulx 1*8($aptr),%r8,%rax # a[1]*a[0] + adcx %r9,%r8 # a[1]*a[0]+=t[1] + adox %rax,%r10 + mulx 2*8($aptr),%r9,%rax # a[2]*a[0] + adcx %r10,%r9 + adox %rax,%r11 + .byte 0xc4,0xe2,0xab,0xf6,0x86,0x18,0x00,0x00,0x00 # mulx 3*8($aptr),%r10,%rax # ... + adcx %r11,%r10 + adox %rax,%r12 + .byte 0xc4,0xe2,0xa3,0xf6,0x86,0x20,0x00,0x00,0x00 # mulx 4*8($aptr),%r11,%rax + adcx %r12,%r11 + adox %rax,%r13 + mulx 5*8($aptr),%r12,%rax + adcx %r13,%r12 + adox %rax,%r14 + mulx 6*8($aptr),%r13,%rax + adcx %r14,%r13 + adox %r15,%rax + mulx 7*8($aptr),%r14,%r15 + mov 1*8($aptr),%rdx # a[1] + adcx %rax,%r14 + adox $zero,%r15 + adc 8*8($tptr),%r15 + mov %r8,1*8($tptr) # t[1] + mov %r9,2*8($tptr) # t[2] + sbb $carry,$carry # mov %cf,$carry + xor $zero,$zero # cf=0, of=0 + + + mulx 2*8($aptr),%r8,%rbx # a[2]*a[1] + mulx 3*8($aptr),%r9,%rax # a[3]*a[1] + adcx %r10,%r8 + adox %rbx,%r9 + mulx 4*8($aptr),%r10,%rbx # ... + adcx %r11,%r9 + adox %rax,%r10 + .byte 0xc4,0xe2,0xa3,0xf6,0x86,0x28,0x00,0x00,0x00 # mulx 5*8($aptr),%r11,%rax + adcx %r12,%r10 + adox %rbx,%r11 + .byte 0xc4,0xe2,0x9b,0xf6,0x9e,0x30,0x00,0x00,0x00 # mulx 6*8($aptr),%r12,%rbx + adcx %r13,%r11 + adox %r14,%r12 + .byte 0xc4,0x62,0x93,0xf6,0xb6,0x38,0x00,0x00,0x00 # mulx 7*8($aptr),%r13,%r14 + mov 2*8($aptr),%rdx # a[2] + adcx %rax,%r12 + adox %rbx,%r13 + adcx %r15,%r13 + adox $zero,%r14 # of=0 + adcx $zero,%r14 # cf=0 + + mov %r8,3*8($tptr) # t[3] + mov %r9,4*8($tptr) # t[4] + + mulx 3*8($aptr),%r8,%rbx # a[3]*a[2] + mulx 4*8($aptr),%r9,%rax # a[4]*a[2] + adcx %r10,%r8 + adox %rbx,%r9 + mulx 5*8($aptr),%r10,%rbx # ... + adcx %r11,%r9 + adox %rax,%r10 + .byte 0xc4,0xe2,0xa3,0xf6,0x86,0x30,0x00,0x00,0x00 # mulx 6*8($aptr),%r11,%rax + adcx %r12,%r10 + adox %r13,%r11 + .byte 0xc4,0x62,0x9b,0xf6,0xae,0x38,0x00,0x00,0x00 # mulx 7*8($aptr),%r12,%r13 + .byte 0x3e + mov 3*8($aptr),%rdx # a[3] + adcx %rbx,%r11 + adox %rax,%r12 + adcx %r14,%r12 + mov %r8,5*8($tptr) # t[5] + mov %r9,6*8($tptr) # t[6] + mulx 4*8($aptr),%r8,%rax # a[4]*a[3] + adox $zero,%r13 # of=0 + adcx $zero,%r13 # cf=0 + + mulx 5*8($aptr),%r9,%rbx # a[5]*a[3] + adcx %r10,%r8 + adox %rax,%r9 + mulx 6*8($aptr),%r10,%rax # ... + adcx %r11,%r9 + adox %r12,%r10 + mulx 7*8($aptr),%r11,%r12 + mov 4*8($aptr),%rdx # a[4] + mov 5*8($aptr),%r14 # a[5] + adcx %rbx,%r10 + adox %rax,%r11 + mov 6*8($aptr),%r15 # a[6] + adcx %r13,%r11 + adox $zero,%r12 # of=0 + adcx $zero,%r12 # cf=0 + + mov %r8,7*8($tptr) # t[7] + mov %r9,8*8($tptr) # t[8] + + mulx %r14,%r9,%rax # a[5]*a[4] + mov 7*8($aptr),%r8 # a[7] + adcx %r10,%r9 + mulx %r15,%r10,%rbx # a[6]*a[4] + adox %rax,%r10 + adcx %r11,%r10 + mulx %r8,%r11,%rax # a[7]*a[4] + mov %r14,%rdx # a[5] + adox %rbx,%r11 + adcx %r12,%r11 + #adox $zero,%rax # of=0 + adcx $zero,%rax # cf=0 + + mulx %r15,%r14,%rbx # a[6]*a[5] + mulx %r8,%r12,%r13 # a[7]*a[5] + mov %r15,%rdx # a[6] + lea 8*8($aptr),$aptr + adcx %r14,%r11 + adox %rbx,%r12 + adcx %rax,%r12 + adox $zero,%r13 + + .byte 0x67,0x67 + mulx %r8,%r8,%r14 # a[7]*a[6] + adcx %r8,%r13 + adcx $zero,%r14 + + cmp 8+8(%rsp),$aptr + je .Lsqrx8x_outer_break + + neg $carry # mov $carry,%cf + mov \$-8,%rcx + mov $zero,%r15 + mov 8*8($tptr),%r8 + adcx 9*8($tptr),%r9 # +=t[9] + adcx 10*8($tptr),%r10 # ... + adcx 11*8($tptr),%r11 + adc 12*8($tptr),%r12 + adc 13*8($tptr),%r13 + adc 14*8($tptr),%r14 + adc 15*8($tptr),%r15 + lea ($aptr),$aaptr + lea 2*64($tptr),$tptr + sbb %rax,%rax # mov %cf,$carry + + mov -64($aptr),%rdx # a[0] + mov %rax,16+8(%rsp) # offload $carry + mov $tptr,24+8(%rsp) + + #lea 8*8($tptr),$tptr # see 2*8*8($tptr) above + xor %eax,%eax # cf=0, of=0 + jmp .Lsqrx8x_loop + +.align 32 +.Lsqrx8x_loop: + mov %r8,%rbx + mulx 0*8($aaptr),%rax,%r8 # a[8]*a[i] + adcx %rax,%rbx # +=t[8] + adox %r9,%r8 + + mulx 1*8($aaptr),%rax,%r9 # ... + adcx %rax,%r8 + adox %r10,%r9 + + mulx 2*8($aaptr),%rax,%r10 + adcx %rax,%r9 + adox %r11,%r10 + + mulx 3*8($aaptr),%rax,%r11 + adcx %rax,%r10 + adox %r12,%r11 + + .byte 0xc4,0x62,0xfb,0xf6,0xa5,0x20,0x00,0x00,0x00 # mulx 4*8($aaptr),%rax,%r12 + adcx %rax,%r11 + adox %r13,%r12 + + mulx 5*8($aaptr),%rax,%r13 + adcx %rax,%r12 + adox %r14,%r13 + + mulx 6*8($aaptr),%rax,%r14 + mov %rbx,($tptr,%rcx,8) # store t[8+i] + mov \$0,%ebx + adcx %rax,%r13 + adox %r15,%r14 + + .byte 0xc4,0x62,0xfb,0xf6,0xbd,0x38,0x00,0x00,0x00 # mulx 7*8($aaptr),%rax,%r15 + mov 8($aptr,%rcx,8),%rdx # a[i] + adcx %rax,%r14 + adox %rbx,%r15 # %rbx is 0, of=0 + adcx %rbx,%r15 # cf=0 + + .byte 0x67 + inc %rcx # of=0 + jnz .Lsqrx8x_loop + + lea 8*8($aaptr),$aaptr + mov \$-8,%rcx + cmp 8+8(%rsp),$aaptr # done? + je .Lsqrx8x_break + + sub 16+8(%rsp),%rbx # mov 16(%rsp),%cf + .byte 0x66 + mov -64($aptr),%rdx + adcx 0*8($tptr),%r8 + adcx 1*8($tptr),%r9 + adc 2*8($tptr),%r10 + adc 3*8($tptr),%r11 + adc 4*8($tptr),%r12 + adc 5*8($tptr),%r13 + adc 6*8($tptr),%r14 + adc 7*8($tptr),%r15 + lea 8*8($tptr),$tptr + .byte 0x67 + sbb %rax,%rax # mov %cf,%rax + xor %ebx,%ebx # cf=0, of=0 + mov %rax,16+8(%rsp) # offload carry + jmp .Lsqrx8x_loop + +.align 32 +.Lsqrx8x_break: + xor $zero,$zero + sub 16+8(%rsp),%rbx # mov 16(%rsp),%cf + adcx $zero,%r8 + mov 24+8(%rsp),$carry # initial $tptr, borrow $carry + adcx $zero,%r9 + mov 0*8($aptr),%rdx # a[8], modulo-scheduled + adc \$0,%r10 + mov %r8,0*8($tptr) + adc \$0,%r11 + adc \$0,%r12 + adc \$0,%r13 + adc \$0,%r14 + adc \$0,%r15 + cmp $carry,$tptr # cf=0, of=0 + je .Lsqrx8x_outer_loop + + mov %r9,1*8($tptr) + mov 1*8($carry),%r9 + mov %r10,2*8($tptr) + mov 2*8($carry),%r10 + mov %r11,3*8($tptr) + mov 3*8($carry),%r11 + mov %r12,4*8($tptr) + mov 4*8($carry),%r12 + mov %r13,5*8($tptr) + mov 5*8($carry),%r13 + mov %r14,6*8($tptr) + mov 6*8($carry),%r14 + mov %r15,7*8($tptr) + mov 7*8($carry),%r15 + mov $carry,$tptr + jmp .Lsqrx8x_outer_loop + +.align 32 +.Lsqrx8x_outer_break: + mov %r9,9*8($tptr) # t[9] + movq %xmm3,%rcx # -$num + mov %r10,10*8($tptr) # ... + mov %r11,11*8($tptr) + mov %r12,12*8($tptr) + mov %r13,13*8($tptr) + mov %r14,14*8($tptr) +___ +} { +my $i="%rcx"; +$code.=<<___; + lea 48+8(%rsp),$tptr + mov ($aptr,$i),%rdx # a[0] + + mov 8($tptr),$A0[1] # t[1] + xor $A0[0],$A0[0] # t[0], of=0, cf=0 + mov 0+8(%rsp),$num # restore $num + adox $A0[1],$A0[1] + mov 16($tptr),$A1[0] # t[2] # prefetch + mov 24($tptr),$A1[1] # t[3] # prefetch + #jmp .Lsqrx4x_shift_n_add # happens to be aligned + +.align 32 +.Lsqrx4x_shift_n_add: + mulx %rdx,%rax,%rbx + adox $A1[0],$A1[0] + adcx $A0[0],%rax + .byte 0x48,0x8b,0x94,0x0e,0x08,0x00,0x00,0x00 # mov 8($aptr,$i),%rdx # a[i+1] # prefetch + .byte 0x4c,0x8b,0x97,0x20,0x00,0x00,0x00 # mov 32($tptr),$A0[0] # t[2*i+4] # prefetch + adox $A1[1],$A1[1] + adcx $A0[1],%rbx + mov 40($tptr),$A0[1] # t[2*i+4+1] # prefetch + mov %rax,0($tptr) + mov %rbx,8($tptr) + + mulx %rdx,%rax,%rbx + adox $A0[0],$A0[0] + adcx $A1[0],%rax + mov 16($aptr,$i),%rdx # a[i+2] # prefetch + mov 48($tptr),$A1[0] # t[2*i+6] # prefetch + adox $A0[1],$A0[1] + adcx $A1[1],%rbx + mov 56($tptr),$A1[1] # t[2*i+6+1] # prefetch + mov %rax,16($tptr) + mov %rbx,24($tptr) + + mulx %rdx,%rax,%rbx + adox $A1[0],$A1[0] + adcx $A0[0],%rax + mov 24($aptr,$i),%rdx # a[i+3] # prefetch + lea 32($i),$i + mov 64($tptr),$A0[0] # t[2*i+8] # prefetch + adox $A1[1],$A1[1] + adcx $A0[1],%rbx + mov 72($tptr),$A0[1] # t[2*i+8+1] # prefetch + mov %rax,32($tptr) + mov %rbx,40($tptr) + + mulx %rdx,%rax,%rbx + adox $A0[0],$A0[0] + adcx $A1[0],%rax + jrcxz .Lsqrx4x_shift_n_add_break + .byte 0x48,0x8b,0x94,0x0e,0x00,0x00,0x00,0x00 # mov 0($aptr,$i),%rdx # a[i+4] # prefetch + adox $A0[1],$A0[1] + adcx $A1[1],%rbx + mov 80($tptr),$A1[0] # t[2*i+10] # prefetch + mov 88($tptr),$A1[1] # t[2*i+10+1] # prefetch + mov %rax,48($tptr) + mov %rbx,56($tptr) + lea 64($tptr),$tptr + nop + jmp .Lsqrx4x_shift_n_add + +.align 32 +.Lsqrx4x_shift_n_add_break: + adcx $A1[1],%rbx + mov %rax,48($tptr) + mov %rbx,56($tptr) + lea 64($tptr),$tptr # end of t[] buffer +___ +} +###################################################################### +# Montgomery reduction part, "word-by-word" algorithm. +# +# This new path is inspired by multiple submissions from Intel, by +# Shay Gueron, Vlad Krasnov, Erdinc Ozturk, James Guilford, +# Vinodh Gopal... +{ +my ($nptr,$carry,$m0)=("%rbp","%rsi","%rdx"); + +$code.=<<___; + movq %xmm2,$nptr +__bn_sqrx8x_reduction: + xor %eax,%eax # initial top-most carry bit + mov 32+8(%rsp),%rbx # n0 + mov 48+8(%rsp),%rdx # "%r8", 8*0($tptr) + lea -8*8($nptr,$num),%rcx # end of n[] + #lea 48+8(%rsp,$num,2),$tptr # end of t[] buffer + mov %rcx, 0+8(%rsp) # save end of n[] + mov $tptr,8+8(%rsp) # save end of t[] + + lea 48+8(%rsp),$tptr # initial t[] window + jmp .Lsqrx8x_reduction_loop + +.align 32 +.Lsqrx8x_reduction_loop: + mov 8*1($tptr),%r9 + mov 8*2($tptr),%r10 + mov 8*3($tptr),%r11 + mov 8*4($tptr),%r12 + mov %rdx,%r8 + imulq %rbx,%rdx # n0*a[i] + mov 8*5($tptr),%r13 + mov 8*6($tptr),%r14 + mov 8*7($tptr),%r15 + mov %rax,24+8(%rsp) # store top-most carry bit + + lea 8*8($tptr),$tptr + xor $carry,$carry # cf=0,of=0 + mov \$-8,%rcx + jmp .Lsqrx8x_reduce + +.align 32 +.Lsqrx8x_reduce: + mov %r8, %rbx + mulx 8*0($nptr),%rax,%r8 # n[0] + adcx %rbx,%rax # discarded + adox %r9,%r8 + + mulx 8*1($nptr),%rbx,%r9 # n[1] + adcx %rbx,%r8 + adox %r10,%r9 + + mulx 8*2($nptr),%rbx,%r10 + adcx %rbx,%r9 + adox %r11,%r10 + + mulx 8*3($nptr),%rbx,%r11 + adcx %rbx,%r10 + adox %r12,%r11 + + .byte 0xc4,0x62,0xe3,0xf6,0xa5,0x20,0x00,0x00,0x00 # mulx 8*4($nptr),%rbx,%r12 + mov %rdx,%rax + mov %r8,%rdx + adcx %rbx,%r11 + adox %r13,%r12 + + mulx 32+8(%rsp),%rbx,%rdx # %rdx discarded + mov %rax,%rdx + mov %rax,64+48+8(%rsp,%rcx,8) # put aside n0*a[i] + + mulx 8*5($nptr),%rax,%r13 + adcx %rax,%r12 + adox %r14,%r13 + + mulx 8*6($nptr),%rax,%r14 + adcx %rax,%r13 + adox %r15,%r14 + + mulx 8*7($nptr),%rax,%r15 + mov %rbx,%rdx + adcx %rax,%r14 + adox $carry,%r15 # $carry is 0 + adcx $carry,%r15 # cf=0 + + .byte 0x67,0x67,0x67 + inc %rcx # of=0 + jnz .Lsqrx8x_reduce + + mov $carry,%rax # xor %rax,%rax + cmp 0+8(%rsp),$nptr # end of n[]? + jae .Lsqrx8x_no_tail + + mov 48+8(%rsp),%rdx # pull n0*a[0] + add 8*0($tptr),%r8 + lea 8*8($nptr),$nptr + mov \$-8,%rcx + adcx 8*1($tptr),%r9 + adcx 8*2($tptr),%r10 + adc 8*3($tptr),%r11 + adc 8*4($tptr),%r12 + adc 8*5($tptr),%r13 + adc 8*6($tptr),%r14 + adc 8*7($tptr),%r15 + lea 8*8($tptr),$tptr + sbb %rax,%rax # top carry + + xor $carry,$carry # of=0, cf=0 + mov %rax,16+8(%rsp) + jmp .Lsqrx8x_tail + +.align 32 +.Lsqrx8x_tail: + mov %r8,%rbx + mulx 8*0($nptr),%rax,%r8 + adcx %rax,%rbx + adox %r9,%r8 + + mulx 8*1($nptr),%rax,%r9 + adcx %rax,%r8 + adox %r10,%r9 + + mulx 8*2($nptr),%rax,%r10 + adcx %rax,%r9 + adox %r11,%r10 + + mulx 8*3($nptr),%rax,%r11 + adcx %rax,%r10 + adox %r12,%r11 + + .byte 0xc4,0x62,0xfb,0xf6,0xa5,0x20,0x00,0x00,0x00 # mulx 8*4($nptr),%rax,%r12 + adcx %rax,%r11 + adox %r13,%r12 + + mulx 8*5($nptr),%rax,%r13 + adcx %rax,%r12 + adox %r14,%r13 + + mulx 8*6($nptr),%rax,%r14 + adcx %rax,%r13 + adox %r15,%r14 + + mulx 8*7($nptr),%rax,%r15 + mov 72+48+8(%rsp,%rcx,8),%rdx # pull n0*a[i] + adcx %rax,%r14 + adox $carry,%r15 + mov %rbx,($tptr,%rcx,8) # save result + mov %r8,%rbx + adcx $carry,%r15 # cf=0 + + inc %rcx # of=0 + jnz .Lsqrx8x_tail + + cmp 0+8(%rsp),$nptr # end of n[]? + jae .Lsqrx8x_tail_done # break out of loop + + sub 16+8(%rsp),$carry # mov 16(%rsp),%cf + mov 48+8(%rsp),%rdx # pull n0*a[0] + lea 8*8($nptr),$nptr + adc 8*0($tptr),%r8 + adc 8*1($tptr),%r9 + adc 8*2($tptr),%r10 + adc 8*3($tptr),%r11 + adc 8*4($tptr),%r12 + adc 8*5($tptr),%r13 + adc 8*6($tptr),%r14 + adc 8*7($tptr),%r15 + lea 8*8($tptr),$tptr + sbb %rax,%rax + sub \$8,%rcx # mov \$-8,%rcx + + xor $carry,$carry # of=0, cf=0 + mov %rax,16+8(%rsp) + jmp .Lsqrx8x_tail + +.align 32 +.Lsqrx8x_tail_done: + xor %rax,%rax + add 24+8(%rsp),%r8 # can this overflow? + adc \$0,%r9 + adc \$0,%r10 + adc \$0,%r11 + adc \$0,%r12 + adc \$0,%r13 + adc \$0,%r14 + adc \$0,%r15 + adc \$0,%rax + + sub 16+8(%rsp),$carry # mov 16(%rsp),%cf +.Lsqrx8x_no_tail: # %cf is 0 if jumped here + adc 8*0($tptr),%r8 + movq %xmm3,%rcx + adc 8*1($tptr),%r9 + mov 8*7($nptr),$carry + movq %xmm2,$nptr # restore $nptr + adc 8*2($tptr),%r10 + adc 8*3($tptr),%r11 + adc 8*4($tptr),%r12 + adc 8*5($tptr),%r13 + adc 8*6($tptr),%r14 + adc 8*7($tptr),%r15 + adc \$0,%rax # top-most carry + + mov 32+8(%rsp),%rbx # n0 + mov 8*8($tptr,%rcx),%rdx # modulo-scheduled "%r8" + + mov %r8,8*0($tptr) # store top 512 bits + lea 8*8($tptr),%r8 # borrow %r8 + mov %r9,8*1($tptr) + mov %r10,8*2($tptr) + mov %r11,8*3($tptr) + mov %r12,8*4($tptr) + mov %r13,8*5($tptr) + mov %r14,8*6($tptr) + mov %r15,8*7($tptr) + + lea 8*8($tptr,%rcx),$tptr # start of current t[] window + cmp 8+8(%rsp),%r8 # end of t[]? + jb .Lsqrx8x_reduction_loop + ret +.cfi_endproc +.size bn_sqrx8x_internal,.-bn_sqrx8x_internal +___ +} +############################################################## +# Post-condition, 4x unrolled +# +{ +my ($rptr,$nptr)=("%rdx","%rbp"); +$code.=<<___; +.align 32 +.type __bn_postx4x_internal,\@abi-omnipotent +__bn_postx4x_internal: +.cfi_startproc + mov 8*0($nptr),%r12 + mov %rcx,%r10 # -$num + mov %rcx,%r9 # -$num + neg %rax + sar \$3+2,%rcx + #lea 48+8(%rsp,%r9),$tptr + movq %xmm1,$rptr # restore $rptr + movq %xmm1,$aptr # prepare for back-to-back call + dec %r12 # so that after 'not' we get -n[0] + mov 8*1($nptr),%r13 + xor %r8,%r8 + mov 8*2($nptr),%r14 + mov 8*3($nptr),%r15 + jmp .Lsqrx4x_sub_entry + +.align 16 +.Lsqrx4x_sub: + mov 8*0($nptr),%r12 + mov 8*1($nptr),%r13 + mov 8*2($nptr),%r14 + mov 8*3($nptr),%r15 +.Lsqrx4x_sub_entry: + andn %rax,%r12,%r12 + lea 8*4($nptr),$nptr + andn %rax,%r13,%r13 + andn %rax,%r14,%r14 + andn %rax,%r15,%r15 + + neg %r8 # mov %r8,%cf + adc 8*0($tptr),%r12 + adc 8*1($tptr),%r13 + adc 8*2($tptr),%r14 + adc 8*3($tptr),%r15 + mov %r12,8*0($rptr) + lea 8*4($tptr),$tptr + mov %r13,8*1($rptr) + sbb %r8,%r8 # mov %cf,%r8 + mov %r14,8*2($rptr) + mov %r15,8*3($rptr) + lea 8*4($rptr),$rptr + + inc %rcx + jnz .Lsqrx4x_sub + + neg %r9 # restore $num + + ret +.cfi_endproc +.size __bn_postx4x_internal,.-__bn_postx4x_internal +___ +} +}}} +{ +my ($inp,$num,$tbl,$idx)=$win64?("%rcx","%edx","%r8", "%r9d") : # Win64 order + ("%rdi","%esi","%rdx","%ecx"); # Unix order +my $out=$inp; +my $STRIDE=2**5*8; +my $N=$STRIDE/4; + +$code.=<<___; +.globl bn_scatter5 +.type bn_scatter5,\@abi-omnipotent +.align 16 +bn_scatter5: +.cfi_startproc + _CET_ENDBR + cmp \$0, $num + jz .Lscatter_epilogue + + # $tbl stores 32 entries, t0 through t31. Each entry has $num words. + # They are interleaved in memory as follows: + # + # t0[0] t1[0] t2[0] ... t31[0] + # t0[1] t1[1] t2[1] ... t31[1] + # ... + # t0[$num-1] t1[$num-1] t2[$num-1] ... t31[$num-1] + + lea ($tbl,$idx,8),$tbl +.Lscatter: + mov ($inp),%rax + lea 8($inp),$inp + mov %rax,($tbl) + lea 32*8($tbl),$tbl + sub \$1,$num + jnz .Lscatter +.Lscatter_epilogue: + ret +.cfi_endproc +.size bn_scatter5,.-bn_scatter5 + +.globl bn_gather5 +.type bn_gather5,\@abi-omnipotent +.align 32 +bn_gather5: +.cfi_startproc +.LSEH_begin_bn_gather5: # Win64 thing, but harmless in other cases + _CET_ENDBR + # I can't trust assembler to use specific encoding:-( + .byte 0x4c,0x8d,0x14,0x24 #lea (%rsp),%r10 +.cfi_def_cfa_register %r10 + .byte 0x48,0x81,0xec,0x08,0x01,0x00,0x00 #sub $0x108,%rsp + lea .Linc(%rip),%rax + and \$-16,%rsp # shouldn't be formally required + + movd $idx,%xmm5 + movdqa 0(%rax),%xmm0 # 00000001000000010000000000000000 + movdqa 16(%rax),%xmm1 # 00000002000000020000000200000002 + lea 128($tbl),%r11 # size optimization + lea 128(%rsp),%rax # size optimization + + pshufd \$0,%xmm5,%xmm5 # broadcast $idx + movdqa %xmm1,%xmm4 + movdqa %xmm1,%xmm2 +___ +######################################################################## +# Calculate masks by comparing 0..31 to $idx and save result to stack. +# +# We compute sixteen 16-byte masks and store them on the stack. Mask i is stored +# in `16*i - 128`(%rax) and contains the comparisons for idx == 2*i and +# idx == 2*i + 1 in its lower and upper halves, respectively. Mask calculations +# are scheduled in groups of four. +for($i=0;$i<$STRIDE/16;$i+=4) { +$code.=<<___; + paddd %xmm0,%xmm1 + pcmpeqd %xmm5,%xmm0 # compare to 1,0 +___ +$code.=<<___ if ($i); + movdqa %xmm3,`16*($i-1)-128`(%rax) +___ +$code.=<<___; + movdqa %xmm4,%xmm3 + + paddd %xmm1,%xmm2 + pcmpeqd %xmm5,%xmm1 # compare to 3,2 + movdqa %xmm0,`16*($i+0)-128`(%rax) + movdqa %xmm4,%xmm0 + + paddd %xmm2,%xmm3 + pcmpeqd %xmm5,%xmm2 # compare to 5,4 + movdqa %xmm1,`16*($i+1)-128`(%rax) + movdqa %xmm4,%xmm1 + + paddd %xmm3,%xmm0 + pcmpeqd %xmm5,%xmm3 # compare to 7,6 + movdqa %xmm2,`16*($i+2)-128`(%rax) + movdqa %xmm4,%xmm2 +___ +} +$code.=<<___; + movdqa %xmm3,`16*($i-1)-128`(%rax) + jmp .Lgather + +.align 32 +.Lgather: + pxor %xmm4,%xmm4 + pxor %xmm5,%xmm5 +___ +for($i=0;$i<$STRIDE/16;$i+=4) { +# Combine the masks with the corresponding table entries to select the correct +# entry. +$code.=<<___; + movdqa `16*($i+0)-128`(%r11),%xmm0 + movdqa `16*($i+1)-128`(%r11),%xmm1 + movdqa `16*($i+2)-128`(%r11),%xmm2 + pand `16*($i+0)-128`(%rax),%xmm0 + movdqa `16*($i+3)-128`(%r11),%xmm3 + pand `16*($i+1)-128`(%rax),%xmm1 + por %xmm0,%xmm4 + pand `16*($i+2)-128`(%rax),%xmm2 + por %xmm1,%xmm5 + pand `16*($i+3)-128`(%rax),%xmm3 + por %xmm2,%xmm4 + por %xmm3,%xmm5 +___ +} +$code.=<<___; + por %xmm5,%xmm4 + lea $STRIDE(%r11),%r11 + # Combine the upper and lower halves of %xmm0. + pshufd \$0x4e,%xmm4,%xmm0 # Swap upper and lower halves. + por %xmm4,%xmm0 + movq %xmm0,($out) # m0=bp[0] + lea 8($out),$out + sub \$1,$num + jnz .Lgather + + lea (%r10),%rsp +.cfi_def_cfa_register %rsp + ret +.LSEH_end_bn_gather5: +.cfi_endproc +.size bn_gather5,.-bn_gather5 +___ +} +$code.=<<___; +.section .rodata +.align 64 +.Linc: + .long 0,0, 1,1 + .long 2,2, 2,2 +.asciz "Montgomery Multiplication with scatter/gather for x86_64, CRYPTOGAMS by " +.text +___ + +# EXCEPTION_DISPOSITION handler (EXCEPTION_RECORD *rec,ULONG64 frame, +# CONTEXT *context,DISPATCHER_CONTEXT *disp) +if ($win64) { +$rec="%rcx"; +$frame="%rdx"; +$context="%r8"; +$disp="%r9"; + +$code.=<<___; +.extern __imp_RtlVirtualUnwind +.type mul_handler,\@abi-omnipotent +.align 16 +mul_handler: + push %rsi + push %rdi + push %rbx + push %rbp + push %r12 + push %r13 + push %r14 + push %r15 + pushfq + sub \$64,%rsp + + mov 120($context),%rax # pull context->Rax + mov 248($context),%rbx # pull context->Rip + + mov 8($disp),%rsi # disp->ImageBase + mov 56($disp),%r11 # disp->HandlerData + + mov 0(%r11),%r10d # HandlerData[0] + lea (%rsi,%r10),%r10 # end of prologue label + cmp %r10,%rbx # context->RipRipRsp + + mov 8(%r11),%r10d # HandlerData[2] + lea (%rsi,%r10),%r10 # epilogue label + cmp %r10,%rbx # context->Rip>=epilogue label + jae .Lcommon_seh_tail + + lea .Lmul4x_epilogue(%rip),%r10 # *ring*: hacked for deletion of _nohw + cmp %r10,%rbx + ja .Lbody_40 + + mov 192($context),%r10 # pull $num + mov 8(%rax,%r10,8),%rax # pull saved stack pointer + + jmp .Lcommon_pop_regs + +.Lbody_40: + mov 40(%rax),%rax # pull saved stack pointer +.Lcommon_pop_regs: + mov -8(%rax),%rbx + mov -16(%rax),%rbp + mov -24(%rax),%r12 + mov -32(%rax),%r13 + mov -40(%rax),%r14 + mov -48(%rax),%r15 + mov %rbx,144($context) # restore context->Rbx + mov %rbp,160($context) # restore context->Rbp + mov %r12,216($context) # restore context->R12 + mov %r13,224($context) # restore context->R13 + mov %r14,232($context) # restore context->R14 + mov %r15,240($context) # restore context->R15 + +.Lcommon_seh_tail: + mov 8(%rax),%rdi + mov 16(%rax),%rsi + mov %rax,152($context) # restore context->Rsp + mov %rsi,168($context) # restore context->Rsi + mov %rdi,176($context) # restore context->Rdi + + mov 40($disp),%rdi # disp->ContextRecord + mov $context,%rsi # context + mov \$154,%ecx # sizeof(CONTEXT) + .long 0xa548f3fc # cld; rep movsq + + mov $disp,%rsi + xor %rcx,%rcx # arg1, UNW_FLAG_NHANDLER + mov 8(%rsi),%rdx # arg2, disp->ImageBase + mov 0(%rsi),%r8 # arg3, disp->ControlPc + mov 16(%rsi),%r9 # arg4, disp->FunctionEntry + mov 40(%rsi),%r10 # disp->ContextRecord + lea 56(%rsi),%r11 # &disp->HandlerData + lea 24(%rsi),%r12 # &disp->EstablisherFrame + mov %r10,32(%rsp) # arg5 + mov %r11,40(%rsp) # arg6 + mov %r12,48(%rsp) # arg7 + mov %rcx,56(%rsp) # arg8, (NULL) + call *__imp_RtlVirtualUnwind(%rip) + + mov \$1,%eax # ExceptionContinueSearch + add \$64,%rsp + popfq + pop %r15 + pop %r14 + pop %r13 + pop %r12 + pop %rbp + pop %rbx + pop %rdi + pop %rsi + ret +.size mul_handler,.-mul_handler + +.section .pdata +.align 4 + .rva .LSEH_begin_bn_mul4x_mont_gather5 + .rva .LSEH_end_bn_mul4x_mont_gather5 + .rva .LSEH_info_bn_mul4x_mont_gather5 + + .rva .LSEH_begin_bn_power5_nohw + .rva .LSEH_end_bn_power5_nohw + .rva .LSEH_info_bn_power5_nohw +___ +$code.=<<___ if ($addx); + .rva .LSEH_begin_bn_mulx4x_mont_gather5 + .rva .LSEH_end_bn_mulx4x_mont_gather5 + .rva .LSEH_info_bn_mulx4x_mont_gather5 + + .rva .LSEH_begin_bn_powerx5 + .rva .LSEH_end_bn_powerx5 + .rva .LSEH_info_bn_powerx5 +___ +$code.=<<___; + .rva .LSEH_begin_bn_gather5 + .rva .LSEH_end_bn_gather5 + .rva .LSEH_info_bn_gather5 + +.section .xdata +.align 8 +.LSEH_info_bn_mul4x_mont_gather5: + .byte 9,0,0,0 + .rva mul_handler + .rva .Lmul4x_prologue,.Lmul4x_body,.Lmul4x_epilogue # HandlerData[] +.align 8 +.LSEH_info_bn_power5_nohw: + .byte 9,0,0,0 + .rva mul_handler + .rva .Lpower5_prologue,.Lpower5_body,.Lpower5_epilogue # HandlerData[] +___ +$code.=<<___ if ($addx); +.align 8 +.LSEH_info_bn_mulx4x_mont_gather5: + .byte 9,0,0,0 + .rva mul_handler + .rva .Lmulx4x_prologue,.Lmulx4x_body,.Lmulx4x_epilogue # HandlerData[] +.align 8 +.LSEH_info_bn_powerx5: + .byte 9,0,0,0 + .rva mul_handler + .rva .Lpowerx5_prologue,.Lpowerx5_body,.Lpowerx5_epilogue # HandlerData[] +___ +$code.=<<___; +.align 8 +.LSEH_info_bn_gather5: + .byte 0x01,0x0b,0x03,0x0a + .byte 0x0b,0x01,0x21,0x00 # sub rsp,0x108 + .byte 0x04,0xa3,0x00,0x00 # lea r10,(rsp) +.align 8 +___ +} + +$code =~ s/\`([^\`]*)\`/eval($1)/gem; + +print $code; +close STDOUT or die "error closing STDOUT: $!"; diff --git a/http/vendor/ring/crypto/fipsmodule/bn/internal.h b/http/vendor/ring/crypto/fipsmodule/bn/internal.h new file mode 100644 index 0000000..f59b5af --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/bn/internal.h @@ -0,0 +1,154 @@ +// Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. +// Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef OPENSSL_HEADER_BN_INTERNAL_H +#define OPENSSL_HEADER_BN_INTERNAL_H + +#include + +#if defined(OPENSSL_X86_64) && defined(_MSC_VER) && !defined(__clang__) +#pragma warning(push, 3) +#include +#pragma warning(pop) +#pragma intrinsic(_umul128) +#endif + +#include "../../internal.h" + +typedef crypto_word_t BN_ULONG; + +#if defined(OPENSSL_64_BIT) + +#if defined(BORINGSSL_HAS_UINT128) +// MSVC doesn't support two-word integers on 64-bit. +#define BN_ULLONG uint128_t +#endif + +#define BN_BITS2 64 +#define BN_MONT_CTX_N0_LIMBS 1 +#define BN_MONT_CTX_N0(hi, lo) TOBN(hi, lo), 0 +#define TOBN(hi, lo) ((BN_ULONG)(hi) << 32 | (lo)) + +#elif defined(OPENSSL_32_BIT) + +#define BN_ULLONG uint64_t +#define BN_BITS2 32 +// On some 32-bit platforms, Montgomery multiplication is done using 64-bit +// arithmetic with SIMD instructions. On such platforms, |BN_MONT_CTX::n0| +// needs to be two words long. Only certain 32-bit platforms actually make use +// of n0[1] and shorter R value would suffice for the others. However, +// currently only the assembly files know which is which. +#define BN_MONT_CTX_N0_LIMBS 2 +#define BN_MONT_CTX_N0(hi, lo) TOBN(hi, lo) +#define TOBN(hi, lo) (lo), (hi) + +#else +#error "Must define either OPENSSL_32_BIT or OPENSSL_64_BIT" +#endif + + + +// BN_MONTGOMERY_MAX_WORDS is the maximum numer of words allowed in a |BIGNUM| +// used with Montgomery reduction. Ideally this limit would be applied to all +// |BIGNUM|s, in |bn_wexpand|, but the exactfloat library needs to create 8 MiB +// values for other operations. +// #define BN_MONTGOMERY_MAX_WORDS (8 * 1024 / sizeof(BN_ULONG)) + +// bn_mul_mont writes |ap| * |bp| mod |np| to |rp|, each |num| words +// long. Inputs and outputs are in Montgomery form. |n0| is a pointer to +// an |N0|. +// +// If at least one of |ap| or |bp| is fully reduced, |rp| will be fully reduced. +// If neither is fully-reduced, the output may not be either. +// +// This function allocates |num| words on the stack, so |num| should be at most +// |BN_MONTGOMERY_MAX_WORDS|. +// +// TODO(davidben): The x86_64 implementation expects a 32-bit input and masks +// off upper bits. The aarch64 implementation expects a 64-bit input and does +// not. |size_t| is the safer option but not strictly correct for x86_64. But +// the |BN_MONTGOMERY_MAX_WORDS| bound makes this moot. +// +// See also discussion in |ToWord| in abi_test.h for notes on smaller-than-word +// inputs. +// +// |num| must be at least 4, at least on x86. +// +// In other forks, |bn_mul_mont| returns an |int| indicating whether it +// actually did the multiplication. All our implementations always do the +// multiplication, and forcing callers to deal with the possibility of it +// failing just leads to further problems. +OPENSSL_STATIC_ASSERT(sizeof(int) == sizeof(size_t) || + (sizeof(int) == 4 && sizeof(size_t) == 8), + "int and size_t ABI mismatch"); +#if defined(OPENSSL_X86_64) +void bn_mul_mont_nohw(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, + const BN_ULONG *np, const BN_ULONG *n0, size_t num); +static inline void bn_mul_mont_small( + BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, + const BN_ULONG *np, const BN_ULONG *n0, size_t num) { + bn_mul_mont_nohw(rp, ap, bp, np, n0, num); +} +#elif defined(OPENSSL_AARCH64) +void bn_mul_mont_nohw(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, + const BN_ULONG *np, const BN_ULONG *n0, size_t num); +static inline void bn_mul_mont_small( + BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, + const BN_ULONG *np, const BN_ULONG *n0, size_t num) { + // No point in optimizing for P-256 because P-256 doesn't call into + // this on AArch64. + bn_mul_mont_nohw(rp, ap, bp, np, n0, num); +} +#elif defined(OPENSSL_ARM) +void bn_mul8x_mont_neon(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, + const BN_ULONG *np, const BN_ULONG *n0, size_t num); +void bn_mul_mont_nohw(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, + const BN_ULONG *np, const BN_ULONG *n0, size_t num); +static inline void bn_mul_mont_small( + BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, + const BN_ULONG *np, const BN_ULONG *n0, size_t num) { + // Approximate what `bn_mul_mont` did so that the NEON version for P-256 + // when practical. + if (num == 8) { + // XXX: This should not be accessing `neon_available` directly. + if (neon_available) { + bn_mul8x_mont_neon(rp, ap, bp, np, n0, num); + return; + } + } + bn_mul_mont_nohw(rp, ap, bp, np, n0, num); +} +#else +void bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, + const BN_ULONG *np, const BN_ULONG *n0, size_t num); +static inline void bn_mul_mont_small( + BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, + const BN_ULONG *np, const BN_ULONG *n0, size_t num) { + bn_mul_mont(rp, ap, bp, np, n0, num); +} +#endif + +static inline void bn_umult_lohi(BN_ULONG *low_out, BN_ULONG *high_out, + BN_ULONG a, BN_ULONG b) { +#if defined(OPENSSL_X86_64) && defined(_MSC_VER) && !defined(__clang__) + *low_out = _umul128(a, b, high_out); +#else + BN_ULLONG result = (BN_ULLONG)a * b; + *low_out = (BN_ULONG)result; + *high_out = (BN_ULONG)(result >> BN_BITS2); +#endif +} + +#endif // OPENSSL_HEADER_BN_INTERNAL_H diff --git a/http/vendor/ring/crypto/fipsmodule/bn/montgomery.c b/http/vendor/ring/crypto/fipsmodule/bn/montgomery.c new file mode 100644 index 0000000..07e757d --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/bn/montgomery.c @@ -0,0 +1,64 @@ +// Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "internal.h" +#include "../../internal.h" + +#include "../../limbs/limbs.h" +#include "../../limbs/limbs.inl" + +OPENSSL_STATIC_ASSERT(BN_MONT_CTX_N0_LIMBS == 1 || BN_MONT_CTX_N0_LIMBS == 2, + "BN_MONT_CTX_N0_LIMBS value is invalid"); +OPENSSL_STATIC_ASSERT( + sizeof(BN_ULONG) * BN_MONT_CTX_N0_LIMBS == sizeof(uint64_t), + "uint64_t is insufficient precision for n0"); + +int bn_from_montgomery_in_place(BN_ULONG r[], size_t num_r, BN_ULONG a[], + size_t num_a, const BN_ULONG n[], + size_t num_n, + const BN_ULONG n0_[BN_MONT_CTX_N0_LIMBS]) { + if (num_n == 0 || num_r != num_n || num_a != 2 * num_n) { + return 0; + } + + // Add multiples of |n| to |r| until R = 2^(nl * BN_BITS2) divides it. On + // input, we had |r| < |n| * R, so now |r| < 2 * |n| * R. Note that |r| + // includes |carry| which is stored separately. + BN_ULONG n0 = n0_[0]; + BN_ULONG carry = 0; + for (size_t i = 0; i < num_n; i++) { + BN_ULONG v = limbs_mul_add_limb(a + i, n, a[i] * n0, num_n); + v += carry + a[i + num_n]; + carry |= (v != a[i + num_n]); + carry &= (v <= a[i + num_n]); + a[i + num_n] = v; + } + + // Shift |num_n| words to divide by R. We have |a| < 2 * |n|. Note that |a| + // includes |carry| which is stored separately. + a += num_n; + + // |a| thus requires at most one additional subtraction |n| to be reduced. + // Subtract |n| and select the answer in constant time. + BN_ULONG v = limbs_sub(r, a, n, num_n) - carry; + // |v| is one if |a| - |n| underflowed or zero if it did not. Note |v| cannot + // be -1. That would imply the subtraction did not fit in |num_n| words, and + // we know at most one subtraction is needed. + v = 0u - v; + for (size_t i = 0; i < num_n; i++) { + r[i] = constant_time_select_w(v, a[i], r[i]); + a[i] = 0; + } + return 1; +} diff --git a/http/vendor/ring/crypto/fipsmodule/bn/montgomery_inv.c b/http/vendor/ring/crypto/fipsmodule/bn/montgomery_inv.c new file mode 100644 index 0000000..070cdc1 --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/bn/montgomery_inv.c @@ -0,0 +1,105 @@ +/* Copyright 2016 Brian Smith. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#include "internal.h" +#include "../../internal.h" + + +OPENSSL_STATIC_ASSERT(BN_MONT_CTX_N0_LIMBS == 1 || BN_MONT_CTX_N0_LIMBS == 2, + "BN_MONT_CTX_N0_LIMBS value is invalid"); +OPENSSL_STATIC_ASSERT(sizeof(BN_ULONG) * BN_MONT_CTX_N0_LIMBS == sizeof(uint64_t), + "uint64_t is insufficient precision for n0"); + +// LG_LITTLE_R is log_2(r). +#define LG_LITTLE_R (BN_MONT_CTX_N0_LIMBS * BN_BITS2) + +// bn_neg_inv_r_mod_n_u64 calculates the -1/n mod r; i.e. it calculates |v| +// such that u*r - v*n == 1. |r| is the constant defined in |bn_mont_n0|. |n| +// must be odd. +// +// This is derived from |xbinGCD| in Henry S. Warren, Jr.'s "Montgomery +// Multiplication" (http://www.hackersdelight.org/MontgomeryMultiplication.pdf). +// It is very similar to the MODULAR-INVERSE function in Stephen R. Dussé's and +// Burton S. Kaliski Jr.'s "A Cryptographic Library for the Motorola DSP56000" +// (http://link.springer.com/chapter/10.1007%2F3-540-46877-3_21). +// +// This is inspired by Joppe W. Bos's "Constant Time Modular Inversion" +// (http://www.joppebos.com/files/CTInversion.pdf) so that the inversion is +// constant-time with respect to |n|. We assume uint64_t additions, +// subtractions, shifts, and bitwise operations are all constant time, which +// may be a large leap of faith on 32-bit targets. We avoid division and +// multiplication, which tend to be the most problematic in terms of timing +// leaks. +// +// Most GCD implementations return values such that |u*r + v*n == 1|, so the +// caller would have to negate the resultant |v| for the purpose of Montgomery +// multiplication. This implementation does the negation implicitly by doing +// the computations as a difference instead of a sum. +uint64_t bn_neg_inv_mod_r_u64(uint64_t n) { + dev_assert_secret(n % 2 == 1); + + // alpha == 2**(lg r - 1) == r / 2. + static const uint64_t alpha = UINT64_C(1) << (LG_LITTLE_R - 1); + + const uint64_t beta = n; + + uint64_t u = 1; + uint64_t v = 0; + + // The invariant maintained from here on is: + // 2**(lg r - i) == u*2*alpha - v*beta. + for (size_t i = 0; i < LG_LITTLE_R; ++i) { +#if BN_BITS2 == 64 && defined(BN_ULLONG) + dev_assert_secret((BN_ULLONG)(1) << (LG_LITTLE_R - i) == + ((BN_ULLONG)u * 2 * alpha) - ((BN_ULLONG)v * beta)); +#endif + + // Delete a common factor of 2 in u and v if |u| is even. Otherwise, set + // |u = (u + beta) / 2| and |v = (v / 2) + alpha|. + + uint64_t u_is_odd = UINT64_C(0) - (u & 1); // Either 0xff..ff or 0. + + // The addition can overflow, so use Dietz's method for it. + // + // Dietz calculates (x+y)/2 by (x xor y)>>1 + x&y. This is valid for all + // (unsigned) x and y, even when x+y overflows. Evidence for 32-bit values + // (embedded in 64 bits to so that overflow can be ignored): + // + // (declare-fun x () (_ BitVec 64)) + // (declare-fun y () (_ BitVec 64)) + // (assert (let ( + // (one (_ bv1 64)) + // (thirtyTwo (_ bv32 64))) + // (and + // (bvult x (bvshl one thirtyTwo)) + // (bvult y (bvshl one thirtyTwo)) + // (not (= + // (bvadd (bvlshr (bvxor x y) one) (bvand x y)) + // (bvlshr (bvadd x y) one))) + // ))) + // (check-sat) + uint64_t beta_if_u_is_odd = beta & u_is_odd; // Either |beta| or 0. + u = ((u ^ beta_if_u_is_odd) >> 1) + (u & beta_if_u_is_odd); + + uint64_t alpha_if_u_is_odd = alpha & u_is_odd; /* Either |alpha| or 0. */ + v = (v >> 1) + alpha_if_u_is_odd; + } + + // The invariant now shows that u*r - v*n == 1 since r == 2 * alpha. +#if BN_BITS2 == 64 && defined(BN_ULLONG) + declassify_assert(1 == ((BN_ULLONG)u * 2 * alpha) - ((BN_ULLONG)v * beta)); +#endif + + return v; +} diff --git a/http/vendor/ring/crypto/fipsmodule/ec/asm/p256-armv8-asm.pl b/http/vendor/ring/crypto/fipsmodule/ec/asm/p256-armv8-asm.pl new file mode 100644 index 0000000..720b3b4 --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/ec/asm/p256-armv8-asm.pl @@ -0,0 +1,1567 @@ +#! /usr/bin/env perl +# Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# ==================================================================== +# Written by Andy Polyakov for the OpenSSL +# project. +# ==================================================================== +# +# ECP_NISTZ256 module for ARMv8. +# +# February 2015. +# +# Original ECP_NISTZ256 submission targeting x86_64 is detailed in +# http://eprint.iacr.org/2013/816. +# +# with/without -DECP_NISTZ256_ASM +# Apple A7 +190-360% +# Cortex-A53 +190-400% +# Cortex-A57 +190-350% +# Denver +230-400% +# +# Ranges denote minimum and maximum improvement coefficients depending +# on benchmark. Lower coefficients are for ECDSA sign, server-side +# operation. Keep in mind that +400% means 5x improvement. + +# The first two arguments should always be the flavour and output file path. +if ($#ARGV < 1) { die "Not enough arguments provided. + Two arguments are necessary: the flavour and the output file path."; } + +$flavour = shift; +$output = shift; + +$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; +( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or +( $xlate="${dir}../../../perlasm/arm-xlate.pl" and -f $xlate) or +die "can't locate arm-xlate.pl"; + +open OUT,"| \"$^X\" $xlate $flavour $output"; +*STDOUT=*OUT; + +{ +my ($rp,$ap,$bp,$bi,$a0,$a1,$a2,$a3,$t0,$t1,$t2,$t3,$poly1,$poly3, + $acc0,$acc1,$acc2,$acc3,$acc4,$acc5) = + map("x$_",(0..17,19,20)); + +my ($acc6,$acc7)=($ap,$bp); # used in __ecp_nistz256_sqr_mont + +$code.=<<___; +.section .rodata +.align 5 +.Lpoly: +.quad 0xffffffffffffffff,0x00000000ffffffff,0x0000000000000000,0xffffffff00000001 +.LRR: // 2^512 mod P precomputed for NIST P256 polynomial +.quad 0x0000000000000003,0xfffffffbffffffff,0xfffffffffffffffe,0x00000004fffffffd +.Lone_mont: +.quad 0x0000000000000001,0xffffffff00000000,0xffffffffffffffff,0x00000000fffffffe +.Lone: +.quad 1,0,0,0 +.Lord: +.quad 0xf3b9cac2fc632551,0xbce6faada7179e84,0xffffffffffffffff,0xffffffff00000000 +.LordK: +.quad 0xccd1c8aaee00bc4f +.asciz "ECP_NISTZ256 for ARMv8, CRYPTOGAMS by " +.text + +// void ecp_nistz256_mul_mont(BN_ULONG x0[4],const BN_ULONG x1[4], +// const BN_ULONG x2[4]); +.globl ecp_nistz256_mul_mont +.type ecp_nistz256_mul_mont,%function +.align 4 +ecp_nistz256_mul_mont: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-32]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + + ldr $bi,[$bp] // bp[0] + ldp $a0,$a1,[$ap] + ldp $a2,$a3,[$ap,#16] + adrp $poly3,:pg_hi21:.Lpoly + add $poly3,$poly3,:lo12:.Lpoly + ldr $poly1,[$poly3,#8] + ldr $poly3,[$poly3,#24] + + bl __ecp_nistz256_mul_mont + + ldp x19,x20,[sp,#16] + ldp x29,x30,[sp],#32 + AARCH64_VALIDATE_LINK_REGISTER + ret +.size ecp_nistz256_mul_mont,.-ecp_nistz256_mul_mont + +// void ecp_nistz256_sqr_mont(BN_ULONG x0[4],const BN_ULONG x1[4]); +.globl ecp_nistz256_sqr_mont +.type ecp_nistz256_sqr_mont,%function +.align 4 +ecp_nistz256_sqr_mont: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-32]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + + ldp $a0,$a1,[$ap] + ldp $a2,$a3,[$ap,#16] + adrp $poly3,:pg_hi21:.Lpoly + add $poly3,$poly3,:lo12:.Lpoly + ldr $poly1,[$poly3,#8] + ldr $poly3,[$poly3,#24] + + bl __ecp_nistz256_sqr_mont + + ldp x19,x20,[sp,#16] + ldp x29,x30,[sp],#32 + AARCH64_VALIDATE_LINK_REGISTER + ret +.size ecp_nistz256_sqr_mont,.-ecp_nistz256_sqr_mont + +// void ecp_nistz256_neg(BN_ULONG x0[4],const BN_ULONG x1[4]); +.globl ecp_nistz256_neg +.type ecp_nistz256_neg,%function +.align 4 +ecp_nistz256_neg: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-16]! + add x29,sp,#0 + + mov $bp,$ap + mov $acc0,xzr // a = 0 + mov $acc1,xzr + mov $acc2,xzr + mov $acc3,xzr + adrp $poly3,:pg_hi21:.Lpoly + add $poly3,$poly3,:lo12:.Lpoly + ldr $poly1,[$poly3,#8] + ldr $poly3,[$poly3,#24] + + bl __ecp_nistz256_sub_from + + ldp x29,x30,[sp],#16 + AARCH64_VALIDATE_LINK_REGISTER + ret +.size ecp_nistz256_neg,.-ecp_nistz256_neg + +// note that __ecp_nistz256_mul_mont expects a[0-3] input pre-loaded +// to $a0-$a3 and b[0] - to $bi +.type __ecp_nistz256_mul_mont,%function +.align 4 +__ecp_nistz256_mul_mont: + mul $acc0,$a0,$bi // a[0]*b[0] + umulh $t0,$a0,$bi + + mul $acc1,$a1,$bi // a[1]*b[0] + umulh $t1,$a1,$bi + + mul $acc2,$a2,$bi // a[2]*b[0] + umulh $t2,$a2,$bi + + mul $acc3,$a3,$bi // a[3]*b[0] + umulh $t3,$a3,$bi + ldr $bi,[$bp,#8] // b[1] + + adds $acc1,$acc1,$t0 // accumulate high parts of multiplication + lsl $t0,$acc0,#32 + adcs $acc2,$acc2,$t1 + lsr $t1,$acc0,#32 + adcs $acc3,$acc3,$t2 + adc $acc4,xzr,$t3 + mov $acc5,xzr +___ +for($i=1;$i<4;$i++) { + # Reduction iteration is normally performed by accumulating + # result of multiplication of modulus by "magic" digit [and + # omitting least significant word, which is guaranteed to + # be 0], but thanks to special form of modulus and "magic" + # digit being equal to least significant word, it can be + # performed with additions and subtractions alone. Indeed: + # + # ffff0001.00000000.0000ffff.ffffffff + # * abcdefgh + # + xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx.abcdefgh + # + # Now observing that ff..ff*x = (2^n-1)*x = 2^n*x-x, we + # rewrite above as: + # + # xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx.abcdefgh + # + abcdefgh.abcdefgh.0000abcd.efgh0000.00000000 + # - 0000abcd.efgh0000.00000000.00000000.abcdefgh + # + # or marking redundant operations: + # + # xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx.-------- + # + abcdefgh.abcdefgh.0000abcd.efgh0000.-------- + # - 0000abcd.efgh0000.--------.--------.-------- + +$code.=<<___; + subs $t2,$acc0,$t0 // "*0xffff0001" + sbc $t3,$acc0,$t1 + adds $acc0,$acc1,$t0 // +=acc[0]<<96 and omit acc[0] + mul $t0,$a0,$bi // lo(a[0]*b[i]) + adcs $acc1,$acc2,$t1 + mul $t1,$a1,$bi // lo(a[1]*b[i]) + adcs $acc2,$acc3,$t2 // +=acc[0]*0xffff0001 + mul $t2,$a2,$bi // lo(a[2]*b[i]) + adcs $acc3,$acc4,$t3 + mul $t3,$a3,$bi // lo(a[3]*b[i]) + adc $acc4,$acc5,xzr + + adds $acc0,$acc0,$t0 // accumulate low parts of multiplication + umulh $t0,$a0,$bi // hi(a[0]*b[i]) + adcs $acc1,$acc1,$t1 + umulh $t1,$a1,$bi // hi(a[1]*b[i]) + adcs $acc2,$acc2,$t2 + umulh $t2,$a2,$bi // hi(a[2]*b[i]) + adcs $acc3,$acc3,$t3 + umulh $t3,$a3,$bi // hi(a[3]*b[i]) + adc $acc4,$acc4,xzr +___ +$code.=<<___ if ($i<3); + ldr $bi,[$bp,#8*($i+1)] // b[$i+1] +___ +$code.=<<___; + adds $acc1,$acc1,$t0 // accumulate high parts of multiplication + lsl $t0,$acc0,#32 + adcs $acc2,$acc2,$t1 + lsr $t1,$acc0,#32 + adcs $acc3,$acc3,$t2 + adcs $acc4,$acc4,$t3 + adc $acc5,xzr,xzr +___ +} +$code.=<<___; + // last reduction + subs $t2,$acc0,$t0 // "*0xffff0001" + sbc $t3,$acc0,$t1 + adds $acc0,$acc1,$t0 // +=acc[0]<<96 and omit acc[0] + adcs $acc1,$acc2,$t1 + adcs $acc2,$acc3,$t2 // +=acc[0]*0xffff0001 + adcs $acc3,$acc4,$t3 + adc $acc4,$acc5,xzr + + adds $t0,$acc0,#1 // subs $t0,$acc0,#-1 // tmp = ret-modulus + sbcs $t1,$acc1,$poly1 + sbcs $t2,$acc2,xzr + sbcs $t3,$acc3,$poly3 + sbcs xzr,$acc4,xzr // did it borrow? + + csel $acc0,$acc0,$t0,lo // ret = borrow ? ret : ret-modulus + csel $acc1,$acc1,$t1,lo + csel $acc2,$acc2,$t2,lo + stp $acc0,$acc1,[$rp] + csel $acc3,$acc3,$t3,lo + stp $acc2,$acc3,[$rp,#16] + + ret +.size __ecp_nistz256_mul_mont,.-__ecp_nistz256_mul_mont + +// note that __ecp_nistz256_sqr_mont expects a[0-3] input pre-loaded +// to $a0-$a3 +.type __ecp_nistz256_sqr_mont,%function +.align 4 +__ecp_nistz256_sqr_mont: + // | | | | | |a1*a0| | + // | | | | |a2*a0| | | + // | |a3*a2|a3*a0| | | | + // | | | |a2*a1| | | | + // | | |a3*a1| | | | | + // *| | | | | | | | 2| + // +|a3*a3|a2*a2|a1*a1|a0*a0| + // |--+--+--+--+--+--+--+--| + // |A7|A6|A5|A4|A3|A2|A1|A0|, where Ax is $accx, i.e. follow $accx + // + // "can't overflow" below mark carrying into high part of + // multiplication result, which can't overflow, because it + // can never be all ones. + + mul $acc1,$a1,$a0 // a[1]*a[0] + umulh $t1,$a1,$a0 + mul $acc2,$a2,$a0 // a[2]*a[0] + umulh $t2,$a2,$a0 + mul $acc3,$a3,$a0 // a[3]*a[0] + umulh $acc4,$a3,$a0 + + adds $acc2,$acc2,$t1 // accumulate high parts of multiplication + mul $t0,$a2,$a1 // a[2]*a[1] + umulh $t1,$a2,$a1 + adcs $acc3,$acc3,$t2 + mul $t2,$a3,$a1 // a[3]*a[1] + umulh $t3,$a3,$a1 + adc $acc4,$acc4,xzr // can't overflow + + mul $acc5,$a3,$a2 // a[3]*a[2] + umulh $acc6,$a3,$a2 + + adds $t1,$t1,$t2 // accumulate high parts of multiplication + mul $acc0,$a0,$a0 // a[0]*a[0] + adc $t2,$t3,xzr // can't overflow + + adds $acc3,$acc3,$t0 // accumulate low parts of multiplication + umulh $a0,$a0,$a0 + adcs $acc4,$acc4,$t1 + mul $t1,$a1,$a1 // a[1]*a[1] + adcs $acc5,$acc5,$t2 + umulh $a1,$a1,$a1 + adc $acc6,$acc6,xzr // can't overflow + + adds $acc1,$acc1,$acc1 // acc[1-6]*=2 + mul $t2,$a2,$a2 // a[2]*a[2] + adcs $acc2,$acc2,$acc2 + umulh $a2,$a2,$a2 + adcs $acc3,$acc3,$acc3 + mul $t3,$a3,$a3 // a[3]*a[3] + adcs $acc4,$acc4,$acc4 + umulh $a3,$a3,$a3 + adcs $acc5,$acc5,$acc5 + adcs $acc6,$acc6,$acc6 + adc $acc7,xzr,xzr + + adds $acc1,$acc1,$a0 // +a[i]*a[i] + adcs $acc2,$acc2,$t1 + adcs $acc3,$acc3,$a1 + adcs $acc4,$acc4,$t2 + adcs $acc5,$acc5,$a2 + lsl $t0,$acc0,#32 + adcs $acc6,$acc6,$t3 + lsr $t1,$acc0,#32 + adc $acc7,$acc7,$a3 +___ +for($i=0;$i<3;$i++) { # reductions, see commentary in + # multiplication for details +$code.=<<___; + subs $t2,$acc0,$t0 // "*0xffff0001" + sbc $t3,$acc0,$t1 + adds $acc0,$acc1,$t0 // +=acc[0]<<96 and omit acc[0] + adcs $acc1,$acc2,$t1 + lsl $t0,$acc0,#32 + adcs $acc2,$acc3,$t2 // +=acc[0]*0xffff0001 + lsr $t1,$acc0,#32 + adc $acc3,$t3,xzr // can't overflow +___ +} +$code.=<<___; + subs $t2,$acc0,$t0 // "*0xffff0001" + sbc $t3,$acc0,$t1 + adds $acc0,$acc1,$t0 // +=acc[0]<<96 and omit acc[0] + adcs $acc1,$acc2,$t1 + adcs $acc2,$acc3,$t2 // +=acc[0]*0xffff0001 + adc $acc3,$t3,xzr // can't overflow + + adds $acc0,$acc0,$acc4 // accumulate upper half + adcs $acc1,$acc1,$acc5 + adcs $acc2,$acc2,$acc6 + adcs $acc3,$acc3,$acc7 + adc $acc4,xzr,xzr + + adds $t0,$acc0,#1 // subs $t0,$acc0,#-1 // tmp = ret-modulus + sbcs $t1,$acc1,$poly1 + sbcs $t2,$acc2,xzr + sbcs $t3,$acc3,$poly3 + sbcs xzr,$acc4,xzr // did it borrow? + + csel $acc0,$acc0,$t0,lo // ret = borrow ? ret : ret-modulus + csel $acc1,$acc1,$t1,lo + csel $acc2,$acc2,$t2,lo + stp $acc0,$acc1,[$rp] + csel $acc3,$acc3,$t3,lo + stp $acc2,$acc3,[$rp,#16] + + ret +.size __ecp_nistz256_sqr_mont,.-__ecp_nistz256_sqr_mont + +// Note that __ecp_nistz256_add_to expects both input vectors pre-loaded to +// $a0-$a3 and $t0-$t3. This is done because it's used in multiple +// contexts, e.g. in multiplication by 2 and 3... +.type __ecp_nistz256_add_to,%function +.align 4 +__ecp_nistz256_add_to: + adds $acc0,$acc0,$t0 // ret = a+b + adcs $acc1,$acc1,$t1 + adcs $acc2,$acc2,$t2 + adcs $acc3,$acc3,$t3 + adc $ap,xzr,xzr // zap $ap + + adds $t0,$acc0,#1 // subs $t0,$a0,#-1 // tmp = ret-modulus + sbcs $t1,$acc1,$poly1 + sbcs $t2,$acc2,xzr + sbcs $t3,$acc3,$poly3 + sbcs xzr,$ap,xzr // did subtraction borrow? + + csel $acc0,$acc0,$t0,lo // ret = borrow ? ret : ret-modulus + csel $acc1,$acc1,$t1,lo + csel $acc2,$acc2,$t2,lo + stp $acc0,$acc1,[$rp] + csel $acc3,$acc3,$t3,lo + stp $acc2,$acc3,[$rp,#16] + + ret +.size __ecp_nistz256_add_to,.-__ecp_nistz256_add_to + +.type __ecp_nistz256_sub_from,%function +.align 4 +__ecp_nistz256_sub_from: + ldp $t0,$t1,[$bp] + ldp $t2,$t3,[$bp,#16] + subs $acc0,$acc0,$t0 // ret = a-b + sbcs $acc1,$acc1,$t1 + sbcs $acc2,$acc2,$t2 + sbcs $acc3,$acc3,$t3 + sbc $ap,xzr,xzr // zap $ap + + subs $t0,$acc0,#1 // adds $t0,$a0,#-1 // tmp = ret+modulus + adcs $t1,$acc1,$poly1 + adcs $t2,$acc2,xzr + adc $t3,$acc3,$poly3 + cmp $ap,xzr // did subtraction borrow? + + csel $acc0,$acc0,$t0,eq // ret = borrow ? ret+modulus : ret + csel $acc1,$acc1,$t1,eq + csel $acc2,$acc2,$t2,eq + stp $acc0,$acc1,[$rp] + csel $acc3,$acc3,$t3,eq + stp $acc2,$acc3,[$rp,#16] + + ret +.size __ecp_nistz256_sub_from,.-__ecp_nistz256_sub_from + +.type __ecp_nistz256_sub_morf,%function +.align 4 +__ecp_nistz256_sub_morf: + ldp $t0,$t1,[$bp] + ldp $t2,$t3,[$bp,#16] + subs $acc0,$t0,$acc0 // ret = b-a + sbcs $acc1,$t1,$acc1 + sbcs $acc2,$t2,$acc2 + sbcs $acc3,$t3,$acc3 + sbc $ap,xzr,xzr // zap $ap + + subs $t0,$acc0,#1 // adds $t0,$a0,#-1 // tmp = ret+modulus + adcs $t1,$acc1,$poly1 + adcs $t2,$acc2,xzr + adc $t3,$acc3,$poly3 + cmp $ap,xzr // did subtraction borrow? + + csel $acc0,$acc0,$t0,eq // ret = borrow ? ret+modulus : ret + csel $acc1,$acc1,$t1,eq + csel $acc2,$acc2,$t2,eq + stp $acc0,$acc1,[$rp] + csel $acc3,$acc3,$t3,eq + stp $acc2,$acc3,[$rp,#16] + + ret +.size __ecp_nistz256_sub_morf,.-__ecp_nistz256_sub_morf + +.type __ecp_nistz256_div_by_2,%function +.align 4 +__ecp_nistz256_div_by_2: + subs $t0,$acc0,#1 // adds $t0,$a0,#-1 // tmp = a+modulus + adcs $t1,$acc1,$poly1 + adcs $t2,$acc2,xzr + adcs $t3,$acc3,$poly3 + adc $ap,xzr,xzr // zap $ap + tst $acc0,#1 // is a even? + + csel $acc0,$acc0,$t0,eq // ret = even ? a : a+modulus + csel $acc1,$acc1,$t1,eq + csel $acc2,$acc2,$t2,eq + csel $acc3,$acc3,$t3,eq + csel $ap,xzr,$ap,eq + + lsr $acc0,$acc0,#1 // ret >>= 1 + orr $acc0,$acc0,$acc1,lsl#63 + lsr $acc1,$acc1,#1 + orr $acc1,$acc1,$acc2,lsl#63 + lsr $acc2,$acc2,#1 + orr $acc2,$acc2,$acc3,lsl#63 + lsr $acc3,$acc3,#1 + stp $acc0,$acc1,[$rp] + orr $acc3,$acc3,$ap,lsl#63 + stp $acc2,$acc3,[$rp,#16] + + ret +.size __ecp_nistz256_div_by_2,.-__ecp_nistz256_div_by_2 +___ +######################################################################## +# following subroutines are "literal" implementation of those found in +# ecp_nistz256.c +# +######################################################################## +# void ecp_nistz256_point_double(P256_POINT *out,const P256_POINT *inp); +# +{ +my ($S,$M,$Zsqr,$tmp0)=map(32*$_,(0..3)); +# above map() describes stack layout with 4 temporary +# 256-bit vectors on top. +my ($rp_real,$ap_real) = map("x$_",(21,22)); + +$code.=<<___; +.globl ecp_nistz256_point_double +.type ecp_nistz256_point_double,%function +.align 5 +ecp_nistz256_point_double: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-96]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + sub sp,sp,#32*4 + +.Ldouble_shortcut: + ldp $acc0,$acc1,[$ap,#32] + mov $rp_real,$rp + ldp $acc2,$acc3,[$ap,#48] + mov $ap_real,$ap + adrp $poly3,:pg_hi21:.Lpoly + add $poly3,$poly3,:lo12:.Lpoly + ldr $poly1,[$poly3,#8] + mov $t0,$acc0 + ldr $poly3,[$poly3,#24] + mov $t1,$acc1 + ldp $a0,$a1,[$ap_real,#64] // forward load for p256_sqr_mont + mov $t2,$acc2 + mov $t3,$acc3 + ldp $a2,$a3,[$ap_real,#64+16] + add $rp,sp,#$S + bl __ecp_nistz256_add_to // p256_mul_by_2(S, in_y); + + add $rp,sp,#$Zsqr + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(Zsqr, in_z); + + ldp $t0,$t1,[$ap_real] + ldp $t2,$t3,[$ap_real,#16] + mov $a0,$acc0 // put Zsqr aside for p256_sub + mov $a1,$acc1 + mov $a2,$acc2 + mov $a3,$acc3 + add $rp,sp,#$M + bl __ecp_nistz256_add_to // p256_add(M, Zsqr, in_x); + + add $bp,$ap_real,#0 + mov $acc0,$a0 // restore Zsqr + mov $acc1,$a1 + ldp $a0,$a1,[sp,#$S] // forward load for p256_sqr_mont + mov $acc2,$a2 + mov $acc3,$a3 + ldp $a2,$a3,[sp,#$S+16] + add $rp,sp,#$Zsqr + bl __ecp_nistz256_sub_morf // p256_sub(Zsqr, in_x, Zsqr); + + add $rp,sp,#$S + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(S, S); + + ldr $bi,[$ap_real,#32] + ldp $a0,$a1,[$ap_real,#64] + ldp $a2,$a3,[$ap_real,#64+16] + add $bp,$ap_real,#32 + add $rp,sp,#$tmp0 + bl __ecp_nistz256_mul_mont // p256_mul_mont(tmp0, in_z, in_y); + + mov $t0,$acc0 + mov $t1,$acc1 + ldp $a0,$a1,[sp,#$S] // forward load for p256_sqr_mont + mov $t2,$acc2 + mov $t3,$acc3 + ldp $a2,$a3,[sp,#$S+16] + add $rp,$rp_real,#64 + bl __ecp_nistz256_add_to // p256_mul_by_2(res_z, tmp0); + + add $rp,sp,#$tmp0 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(tmp0, S); + + ldr $bi,[sp,#$Zsqr] // forward load for p256_mul_mont + ldp $a0,$a1,[sp,#$M] + ldp $a2,$a3,[sp,#$M+16] + add $rp,$rp_real,#32 + bl __ecp_nistz256_div_by_2 // p256_div_by_2(res_y, tmp0); + + add $bp,sp,#$Zsqr + add $rp,sp,#$M + bl __ecp_nistz256_mul_mont // p256_mul_mont(M, M, Zsqr); + + mov $t0,$acc0 // duplicate M + mov $t1,$acc1 + mov $t2,$acc2 + mov $t3,$acc3 + mov $a0,$acc0 // put M aside + mov $a1,$acc1 + mov $a2,$acc2 + mov $a3,$acc3 + add $rp,sp,#$M + bl __ecp_nistz256_add_to + mov $t0,$a0 // restore M + mov $t1,$a1 + ldr $bi,[$ap_real] // forward load for p256_mul_mont + mov $t2,$a2 + ldp $a0,$a1,[sp,#$S] + mov $t3,$a3 + ldp $a2,$a3,[sp,#$S+16] + bl __ecp_nistz256_add_to // p256_mul_by_3(M, M); + + add $bp,$ap_real,#0 + add $rp,sp,#$S + bl __ecp_nistz256_mul_mont // p256_mul_mont(S, S, in_x); + + mov $t0,$acc0 + mov $t1,$acc1 + ldp $a0,$a1,[sp,#$M] // forward load for p256_sqr_mont + mov $t2,$acc2 + mov $t3,$acc3 + ldp $a2,$a3,[sp,#$M+16] + add $rp,sp,#$tmp0 + bl __ecp_nistz256_add_to // p256_mul_by_2(tmp0, S); + + add $rp,$rp_real,#0 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(res_x, M); + + add $bp,sp,#$tmp0 + bl __ecp_nistz256_sub_from // p256_sub(res_x, res_x, tmp0); + + add $bp,sp,#$S + add $rp,sp,#$S + bl __ecp_nistz256_sub_morf // p256_sub(S, S, res_x); + + ldr $bi,[sp,#$M] + mov $a0,$acc0 // copy S + mov $a1,$acc1 + mov $a2,$acc2 + mov $a3,$acc3 + add $bp,sp,#$M + bl __ecp_nistz256_mul_mont // p256_mul_mont(S, S, M); + + add $bp,$rp_real,#32 + add $rp,$rp_real,#32 + bl __ecp_nistz256_sub_from // p256_sub(res_y, S, res_y); + + add sp,x29,#0 // destroy frame + ldp x19,x20,[x29,#16] + ldp x21,x22,[x29,#32] + ldp x29,x30,[sp],#96 + AARCH64_VALIDATE_LINK_REGISTER + ret +.size ecp_nistz256_point_double,.-ecp_nistz256_point_double +___ +} + +######################################################################## +# void ecp_nistz256_point_add(P256_POINT *out,const P256_POINT *in1, +# const P256_POINT *in2); +{ +my ($res_x,$res_y,$res_z, + $H,$Hsqr,$R,$Rsqr,$Hcub, + $U1,$U2,$S1,$S2)=map(32*$_,(0..11)); +my ($Z1sqr, $Z2sqr) = ($Hsqr, $Rsqr); +# above map() describes stack layout with 12 temporary +# 256-bit vectors on top. +my ($rp_real,$ap_real,$bp_real,$in1infty,$in2infty,$temp0,$temp1,$temp2)=map("x$_",(21..28)); + +$code.=<<___; +.globl ecp_nistz256_point_add +.type ecp_nistz256_point_add,%function +.align 5 +ecp_nistz256_point_add: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-96]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + stp x27,x28,[sp,#80] + sub sp,sp,#32*12 + + ldp $a0,$a1,[$bp,#64] // in2_z + ldp $a2,$a3,[$bp,#64+16] + mov $rp_real,$rp + mov $ap_real,$ap + mov $bp_real,$bp + adrp $poly3,:pg_hi21:.Lpoly + add $poly3,$poly3,:lo12:.Lpoly + ldr $poly1,[$poly3,#8] + ldr $poly3,[$poly3,#24] + orr $t0,$a0,$a1 + orr $t2,$a2,$a3 + orr $in2infty,$t0,$t2 + cmp $in2infty,#0 + csetm $in2infty,ne // ~in2infty + add $rp,sp,#$Z2sqr + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(Z2sqr, in2_z); + + ldp $a0,$a1,[$ap_real,#64] // in1_z + ldp $a2,$a3,[$ap_real,#64+16] + orr $t0,$a0,$a1 + orr $t2,$a2,$a3 + orr $in1infty,$t0,$t2 + cmp $in1infty,#0 + csetm $in1infty,ne // ~in1infty + add $rp,sp,#$Z1sqr + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(Z1sqr, in1_z); + + ldr $bi,[$bp_real,#64] + ldp $a0,$a1,[sp,#$Z2sqr] + ldp $a2,$a3,[sp,#$Z2sqr+16] + add $bp,$bp_real,#64 + add $rp,sp,#$S1 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S1, Z2sqr, in2_z); + + ldr $bi,[$ap_real,#64] + ldp $a0,$a1,[sp,#$Z1sqr] + ldp $a2,$a3,[sp,#$Z1sqr+16] + add $bp,$ap_real,#64 + add $rp,sp,#$S2 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S2, Z1sqr, in1_z); + + ldr $bi,[$ap_real,#32] + ldp $a0,$a1,[sp,#$S1] + ldp $a2,$a3,[sp,#$S1+16] + add $bp,$ap_real,#32 + add $rp,sp,#$S1 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S1, S1, in1_y); + + ldr $bi,[$bp_real,#32] + ldp $a0,$a1,[sp,#$S2] + ldp $a2,$a3,[sp,#$S2+16] + add $bp,$bp_real,#32 + add $rp,sp,#$S2 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S2, S2, in2_y); + + add $bp,sp,#$S1 + ldr $bi,[sp,#$Z2sqr] // forward load for p256_mul_mont + ldp $a0,$a1,[$ap_real] + ldp $a2,$a3,[$ap_real,#16] + add $rp,sp,#$R + bl __ecp_nistz256_sub_from // p256_sub(R, S2, S1); + + orr $acc0,$acc0,$acc1 // see if result is zero + orr $acc2,$acc2,$acc3 + orr $temp0,$acc0,$acc2 // ~is_equal(S1,S2) + + add $bp,sp,#$Z2sqr + add $rp,sp,#$U1 + bl __ecp_nistz256_mul_mont // p256_mul_mont(U1, in1_x, Z2sqr); + + ldr $bi,[sp,#$Z1sqr] + ldp $a0,$a1,[$bp_real] + ldp $a2,$a3,[$bp_real,#16] + add $bp,sp,#$Z1sqr + add $rp,sp,#$U2 + bl __ecp_nistz256_mul_mont // p256_mul_mont(U2, in2_x, Z1sqr); + + add $bp,sp,#$U1 + ldp $a0,$a1,[sp,#$R] // forward load for p256_sqr_mont + ldp $a2,$a3,[sp,#$R+16] + add $rp,sp,#$H + bl __ecp_nistz256_sub_from // p256_sub(H, U2, U1); + + orr $acc0,$acc0,$acc1 // see if result is zero + orr $acc2,$acc2,$acc3 + orr $acc0,$acc0,$acc2 // ~is_equal(U1,U2) + + mvn $temp1,$in1infty // -1/0 -> 0/-1 + mvn $temp2,$in2infty // -1/0 -> 0/-1 + orr $acc0,$acc0,$temp1 + orr $acc0,$acc0,$temp2 + orr $acc0,$acc0,$temp0 + cbnz $acc0,.Ladd_proceed // if(~is_equal(U1,U2) | in1infty | in2infty | ~is_equal(S1,S2)) + +.Ladd_double: + mov $ap,$ap_real + mov $rp,$rp_real + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + add sp,sp,#256 // #256 is from #32*(12-4). difference in stack frames + b .Ldouble_shortcut + +.align 4 +.Ladd_proceed: + add $rp,sp,#$Rsqr + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(Rsqr, R); + + ldr $bi,[$ap_real,#64] + ldp $a0,$a1,[sp,#$H] + ldp $a2,$a3,[sp,#$H+16] + add $bp,$ap_real,#64 + add $rp,sp,#$res_z + bl __ecp_nistz256_mul_mont // p256_mul_mont(res_z, H, in1_z); + + ldp $a0,$a1,[sp,#$H] + ldp $a2,$a3,[sp,#$H+16] + add $rp,sp,#$Hsqr + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(Hsqr, H); + + ldr $bi,[$bp_real,#64] + ldp $a0,$a1,[sp,#$res_z] + ldp $a2,$a3,[sp,#$res_z+16] + add $bp,$bp_real,#64 + add $rp,sp,#$res_z + bl __ecp_nistz256_mul_mont // p256_mul_mont(res_z, res_z, in2_z); + + ldr $bi,[sp,#$H] + ldp $a0,$a1,[sp,#$Hsqr] + ldp $a2,$a3,[sp,#$Hsqr+16] + add $bp,sp,#$H + add $rp,sp,#$Hcub + bl __ecp_nistz256_mul_mont // p256_mul_mont(Hcub, Hsqr, H); + + ldr $bi,[sp,#$Hsqr] + ldp $a0,$a1,[sp,#$U1] + ldp $a2,$a3,[sp,#$U1+16] + add $bp,sp,#$Hsqr + add $rp,sp,#$U2 + bl __ecp_nistz256_mul_mont // p256_mul_mont(U2, U1, Hsqr); + + mov $t0,$acc0 + mov $t1,$acc1 + mov $t2,$acc2 + mov $t3,$acc3 + add $rp,sp,#$Hsqr + bl __ecp_nistz256_add_to // p256_mul_by_2(Hsqr, U2); + + add $bp,sp,#$Rsqr + add $rp,sp,#$res_x + bl __ecp_nistz256_sub_morf // p256_sub(res_x, Rsqr, Hsqr); + + add $bp,sp,#$Hcub + bl __ecp_nistz256_sub_from // p256_sub(res_x, res_x, Hcub); + + add $bp,sp,#$U2 + ldr $bi,[sp,#$Hcub] // forward load for p256_mul_mont + ldp $a0,$a1,[sp,#$S1] + ldp $a2,$a3,[sp,#$S1+16] + add $rp,sp,#$res_y + bl __ecp_nistz256_sub_morf // p256_sub(res_y, U2, res_x); + + add $bp,sp,#$Hcub + add $rp,sp,#$S2 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S2, S1, Hcub); + + ldr $bi,[sp,#$R] + ldp $a0,$a1,[sp,#$res_y] + ldp $a2,$a3,[sp,#$res_y+16] + add $bp,sp,#$R + add $rp,sp,#$res_y + bl __ecp_nistz256_mul_mont // p256_mul_mont(res_y, res_y, R); + + add $bp,sp,#$S2 + bl __ecp_nistz256_sub_from // p256_sub(res_y, res_y, S2); + + ldp $a0,$a1,[sp,#$res_x] // res + ldp $a2,$a3,[sp,#$res_x+16] + ldp $t0,$t1,[$bp_real] // in2 + ldp $t2,$t3,[$bp_real,#16] +___ +for($i=0;$i<64;$i+=32) { # conditional moves +$code.=<<___; + ldp $acc0,$acc1,[$ap_real,#$i] // in1 + cmp $in1infty,#0 // ~$in1intfy, remember? + ldp $acc2,$acc3,[$ap_real,#$i+16] + csel $t0,$a0,$t0,ne + csel $t1,$a1,$t1,ne + ldp $a0,$a1,[sp,#$res_x+$i+32] // res + csel $t2,$a2,$t2,ne + csel $t3,$a3,$t3,ne + cmp $in2infty,#0 // ~$in2intfy, remember? + ldp $a2,$a3,[sp,#$res_x+$i+48] + csel $acc0,$t0,$acc0,ne + csel $acc1,$t1,$acc1,ne + ldp $t0,$t1,[$bp_real,#$i+32] // in2 + csel $acc2,$t2,$acc2,ne + csel $acc3,$t3,$acc3,ne + ldp $t2,$t3,[$bp_real,#$i+48] + stp $acc0,$acc1,[$rp_real,#$i] + stp $acc2,$acc3,[$rp_real,#$i+16] +___ +} +$code.=<<___; + ldp $acc0,$acc1,[$ap_real,#$i] // in1 + cmp $in1infty,#0 // ~$in1intfy, remember? + ldp $acc2,$acc3,[$ap_real,#$i+16] + csel $t0,$a0,$t0,ne + csel $t1,$a1,$t1,ne + csel $t2,$a2,$t2,ne + csel $t3,$a3,$t3,ne + cmp $in2infty,#0 // ~$in2intfy, remember? + csel $acc0,$t0,$acc0,ne + csel $acc1,$t1,$acc1,ne + csel $acc2,$t2,$acc2,ne + csel $acc3,$t3,$acc3,ne + stp $acc0,$acc1,[$rp_real,#$i] + stp $acc2,$acc3,[$rp_real,#$i+16] + +.Ladd_done: + add sp,x29,#0 // destroy frame + ldp x19,x20,[x29,#16] + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldp x29,x30,[sp],#96 + AARCH64_VALIDATE_LINK_REGISTER + ret +.size ecp_nistz256_point_add,.-ecp_nistz256_point_add +___ +} + +######################################################################## +# void ecp_nistz256_point_add_affine(P256_POINT *out,const P256_POINT *in1, +# const P256_POINT_AFFINE *in2); +{ +my ($res_x,$res_y,$res_z, + $U2,$S2,$H,$R,$Hsqr,$Hcub,$Rsqr)=map(32*$_,(0..9)); +my $Z1sqr = $S2; +# above map() describes stack layout with 10 temporary +# 256-bit vectors on top. +my ($rp_real,$ap_real,$bp_real,$in1infty,$in2infty,$temp)=map("x$_",(21..26)); + +$code.=<<___; +.globl ecp_nistz256_point_add_affine +.type ecp_nistz256_point_add_affine,%function +.align 5 +ecp_nistz256_point_add_affine: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-80]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + sub sp,sp,#32*10 + + mov $rp_real,$rp + mov $ap_real,$ap + mov $bp_real,$bp + adrp $poly3,:pg_hi21:.Lpoly + add $poly3,$poly3,:lo12:.Lpoly + ldr $poly1,[$poly3,#8] + ldr $poly3,[$poly3,#24] + + ldp $a0,$a1,[$ap,#64] // in1_z + ldp $a2,$a3,[$ap,#64+16] + orr $t0,$a0,$a1 + orr $t2,$a2,$a3 + orr $in1infty,$t0,$t2 + cmp $in1infty,#0 + csetm $in1infty,ne // ~in1infty + + ldp $acc0,$acc1,[$bp] // in2_x + ldp $acc2,$acc3,[$bp,#16] + ldp $t0,$t1,[$bp,#32] // in2_y + ldp $t2,$t3,[$bp,#48] + orr $acc0,$acc0,$acc1 + orr $acc2,$acc2,$acc3 + orr $t0,$t0,$t1 + orr $t2,$t2,$t3 + orr $acc0,$acc0,$acc2 + orr $t0,$t0,$t2 + orr $in2infty,$acc0,$t0 + cmp $in2infty,#0 + csetm $in2infty,ne // ~in2infty + + add $rp,sp,#$Z1sqr + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(Z1sqr, in1_z); + + mov $a0,$acc0 + mov $a1,$acc1 + mov $a2,$acc2 + mov $a3,$acc3 + ldr $bi,[$bp_real] + add $bp,$bp_real,#0 + add $rp,sp,#$U2 + bl __ecp_nistz256_mul_mont // p256_mul_mont(U2, Z1sqr, in2_x); + + add $bp,$ap_real,#0 + ldr $bi,[$ap_real,#64] // forward load for p256_mul_mont + ldp $a0,$a1,[sp,#$Z1sqr] + ldp $a2,$a3,[sp,#$Z1sqr+16] + add $rp,sp,#$H + bl __ecp_nistz256_sub_from // p256_sub(H, U2, in1_x); + + add $bp,$ap_real,#64 + add $rp,sp,#$S2 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S2, Z1sqr, in1_z); + + ldr $bi,[$ap_real,#64] + ldp $a0,$a1,[sp,#$H] + ldp $a2,$a3,[sp,#$H+16] + add $bp,$ap_real,#64 + add $rp,sp,#$res_z + bl __ecp_nistz256_mul_mont // p256_mul_mont(res_z, H, in1_z); + + ldr $bi,[$bp_real,#32] + ldp $a0,$a1,[sp,#$S2] + ldp $a2,$a3,[sp,#$S2+16] + add $bp,$bp_real,#32 + add $rp,sp,#$S2 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S2, S2, in2_y); + + add $bp,$ap_real,#32 + ldp $a0,$a1,[sp,#$H] // forward load for p256_sqr_mont + ldp $a2,$a3,[sp,#$H+16] + add $rp,sp,#$R + bl __ecp_nistz256_sub_from // p256_sub(R, S2, in1_y); + + add $rp,sp,#$Hsqr + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(Hsqr, H); + + ldp $a0,$a1,[sp,#$R] + ldp $a2,$a3,[sp,#$R+16] + add $rp,sp,#$Rsqr + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(Rsqr, R); + + ldr $bi,[sp,#$H] + ldp $a0,$a1,[sp,#$Hsqr] + ldp $a2,$a3,[sp,#$Hsqr+16] + add $bp,sp,#$H + add $rp,sp,#$Hcub + bl __ecp_nistz256_mul_mont // p256_mul_mont(Hcub, Hsqr, H); + + ldr $bi,[$ap_real] + ldp $a0,$a1,[sp,#$Hsqr] + ldp $a2,$a3,[sp,#$Hsqr+16] + add $bp,$ap_real,#0 + add $rp,sp,#$U2 + bl __ecp_nistz256_mul_mont // p256_mul_mont(U2, in1_x, Hsqr); + + mov $t0,$acc0 + mov $t1,$acc1 + mov $t2,$acc2 + mov $t3,$acc3 + add $rp,sp,#$Hsqr + bl __ecp_nistz256_add_to // p256_mul_by_2(Hsqr, U2); + + add $bp,sp,#$Rsqr + add $rp,sp,#$res_x + bl __ecp_nistz256_sub_morf // p256_sub(res_x, Rsqr, Hsqr); + + add $bp,sp,#$Hcub + bl __ecp_nistz256_sub_from // p256_sub(res_x, res_x, Hcub); + + add $bp,sp,#$U2 + ldr $bi,[$ap_real,#32] // forward load for p256_mul_mont + ldp $a0,$a1,[sp,#$Hcub] + ldp $a2,$a3,[sp,#$Hcub+16] + add $rp,sp,#$res_y + bl __ecp_nistz256_sub_morf // p256_sub(res_y, U2, res_x); + + add $bp,$ap_real,#32 + add $rp,sp,#$S2 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S2, in1_y, Hcub); + + ldr $bi,[sp,#$R] + ldp $a0,$a1,[sp,#$res_y] + ldp $a2,$a3,[sp,#$res_y+16] + add $bp,sp,#$R + add $rp,sp,#$res_y + bl __ecp_nistz256_mul_mont // p256_mul_mont(res_y, res_y, R); + + add $bp,sp,#$S2 + bl __ecp_nistz256_sub_from // p256_sub(res_y, res_y, S2); + + ldp $a0,$a1,[sp,#$res_x] // res + ldp $a2,$a3,[sp,#$res_x+16] + ldp $t0,$t1,[$bp_real] // in2 + ldp $t2,$t3,[$bp_real,#16] +___ +for($i=0;$i<64;$i+=32) { # conditional moves +$code.=<<___; + ldp $acc0,$acc1,[$ap_real,#$i] // in1 + cmp $in1infty,#0 // ~$in1intfy, remember? + ldp $acc2,$acc3,[$ap_real,#$i+16] + csel $t0,$a0,$t0,ne + csel $t1,$a1,$t1,ne + ldp $a0,$a1,[sp,#$res_x+$i+32] // res + csel $t2,$a2,$t2,ne + csel $t3,$a3,$t3,ne + cmp $in2infty,#0 // ~$in2intfy, remember? + ldp $a2,$a3,[sp,#$res_x+$i+48] + csel $acc0,$t0,$acc0,ne + csel $acc1,$t1,$acc1,ne + ldp $t0,$t1,[$bp_real,#$i+32] // in2 + csel $acc2,$t2,$acc2,ne + csel $acc3,$t3,$acc3,ne + ldp $t2,$t3,[$bp_real,#$i+48] + stp $acc0,$acc1,[$rp_real,#$i] + stp $acc2,$acc3,[$rp_real,#$i+16] +___ +$code.=<<___ if ($i == 0); + adrp $bp_real,:pg_hi21:.Lone_mont-64 + add $bp_real,$bp_real,:lo12:.Lone_mont-64 +___ +} +$code.=<<___; + ldp $acc0,$acc1,[$ap_real,#$i] // in1 + cmp $in1infty,#0 // ~$in1intfy, remember? + ldp $acc2,$acc3,[$ap_real,#$i+16] + csel $t0,$a0,$t0,ne + csel $t1,$a1,$t1,ne + csel $t2,$a2,$t2,ne + csel $t3,$a3,$t3,ne + cmp $in2infty,#0 // ~$in2intfy, remember? + csel $acc0,$t0,$acc0,ne + csel $acc1,$t1,$acc1,ne + csel $acc2,$t2,$acc2,ne + csel $acc3,$t3,$acc3,ne + stp $acc0,$acc1,[$rp_real,#$i] + stp $acc2,$acc3,[$rp_real,#$i+16] + + add sp,x29,#0 // destroy frame + ldp x19,x20,[x29,#16] + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x29,x30,[sp],#80 + AARCH64_VALIDATE_LINK_REGISTER + ret +.size ecp_nistz256_point_add_affine,.-ecp_nistz256_point_add_affine +___ +} +if (1) { +my ($ord0,$ord1) = ($poly1,$poly3); +my ($ord2,$ord3,$ordk,$t4) = map("x$_",(21..24)); +my $acc7 = $bi; + +$code.=<<___; +//////////////////////////////////////////////////////////////////////// +// void ecp_nistz256_ord_mul_mont(uint64_t res[4], uint64_t a[4], +// uint64_t b[4]); +.globl ecp_nistz256_ord_mul_mont +.type ecp_nistz256_ord_mul_mont,%function +.align 4 +ecp_nistz256_ord_mul_mont: + AARCH64_VALID_CALL_TARGET + // Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later. + stp x29,x30,[sp,#-64]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + + adrp $ordk,:pg_hi21:.Lord + add $ordk,$ordk,:lo12:.Lord + ldr $bi,[$bp] // bp[0] + ldp $a0,$a1,[$ap] + ldp $a2,$a3,[$ap,#16] + + ldp $ord0,$ord1,[$ordk,#0] + ldp $ord2,$ord3,[$ordk,#16] + ldr $ordk,[$ordk,#32] + + mul $acc0,$a0,$bi // a[0]*b[0] + umulh $t0,$a0,$bi + + mul $acc1,$a1,$bi // a[1]*b[0] + umulh $t1,$a1,$bi + + mul $acc2,$a2,$bi // a[2]*b[0] + umulh $t2,$a2,$bi + + mul $acc3,$a3,$bi // a[3]*b[0] + umulh $acc4,$a3,$bi + + mul $t4,$acc0,$ordk + + adds $acc1,$acc1,$t0 // accumulate high parts of multiplication + adcs $acc2,$acc2,$t1 + adcs $acc3,$acc3,$t2 + adc $acc4,$acc4,xzr + mov $acc5,xzr +___ +for ($i=1;$i<4;$i++) { + ################################################################ + # ffff0000.ffffffff.yyyyyyyy.zzzzzzzz + # * abcdefgh + # + xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx + # + # Now observing that ff..ff*x = (2^n-1)*x = 2^n*x-x, we + # rewrite above as: + # + # xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx.xxxxxxxx + # - 0000abcd.efgh0000.abcdefgh.00000000.00000000 + # + abcdefgh.abcdefgh.yzayzbyz.cyzdyzey.zfyzgyzh +$code.=<<___; + ldr $bi,[$bp,#8*$i] // b[i] + + lsl $t0,$t4,#32 + subs $acc2,$acc2,$t4 + lsr $t1,$t4,#32 + sbcs $acc3,$acc3,$t0 + sbcs $acc4,$acc4,$t1 + sbc $acc5,$acc5,xzr + + subs xzr,$acc0,#1 + umulh $t1,$ord0,$t4 + mul $t2,$ord1,$t4 + umulh $t3,$ord1,$t4 + + adcs $t2,$t2,$t1 + mul $t0,$a0,$bi + adc $t3,$t3,xzr + mul $t1,$a1,$bi + + adds $acc0,$acc1,$t2 + mul $t2,$a2,$bi + adcs $acc1,$acc2,$t3 + mul $t3,$a3,$bi + adcs $acc2,$acc3,$t4 + adcs $acc3,$acc4,$t4 + adc $acc4,$acc5,xzr + + adds $acc0,$acc0,$t0 // accumulate low parts + umulh $t0,$a0,$bi + adcs $acc1,$acc1,$t1 + umulh $t1,$a1,$bi + adcs $acc2,$acc2,$t2 + umulh $t2,$a2,$bi + adcs $acc3,$acc3,$t3 + umulh $t3,$a3,$bi + adc $acc4,$acc4,xzr + mul $t4,$acc0,$ordk + adds $acc1,$acc1,$t0 // accumulate high parts + adcs $acc2,$acc2,$t1 + adcs $acc3,$acc3,$t2 + adcs $acc4,$acc4,$t3 + adc $acc5,xzr,xzr +___ +} +$code.=<<___; + lsl $t0,$t4,#32 // last reduction + subs $acc2,$acc2,$t4 + lsr $t1,$t4,#32 + sbcs $acc3,$acc3,$t0 + sbcs $acc4,$acc4,$t1 + sbc $acc5,$acc5,xzr + + subs xzr,$acc0,#1 + umulh $t1,$ord0,$t4 + mul $t2,$ord1,$t4 + umulh $t3,$ord1,$t4 + + adcs $t2,$t2,$t1 + adc $t3,$t3,xzr + + adds $acc0,$acc1,$t2 + adcs $acc1,$acc2,$t3 + adcs $acc2,$acc3,$t4 + adcs $acc3,$acc4,$t4 + adc $acc4,$acc5,xzr + + subs $t0,$acc0,$ord0 // ret -= modulus + sbcs $t1,$acc1,$ord1 + sbcs $t2,$acc2,$ord2 + sbcs $t3,$acc3,$ord3 + sbcs xzr,$acc4,xzr + + csel $acc0,$acc0,$t0,lo // ret = borrow ? ret : ret-modulus + csel $acc1,$acc1,$t1,lo + csel $acc2,$acc2,$t2,lo + stp $acc0,$acc1,[$rp] + csel $acc3,$acc3,$t3,lo + stp $acc2,$acc3,[$rp,#16] + + ldp x19,x20,[sp,#16] + ldp x21,x22,[sp,#32] + ldp x23,x24,[sp,#48] + ldr x29,[sp],#64 + ret +.size ecp_nistz256_ord_mul_mont,.-ecp_nistz256_ord_mul_mont + +//////////////////////////////////////////////////////////////////////// +// void ecp_nistz256_ord_sqr_mont(uint64_t res[4], uint64_t a[4], +// uint64_t rep); +.globl ecp_nistz256_ord_sqr_mont +.type ecp_nistz256_ord_sqr_mont,%function +.align 4 +ecp_nistz256_ord_sqr_mont: + AARCH64_VALID_CALL_TARGET + // Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later. + stp x29,x30,[sp,#-64]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + + adrp $ordk,:pg_hi21:.Lord + add $ordk,$ordk,:lo12:.Lord + ldp $a0,$a1,[$ap] + ldp $a2,$a3,[$ap,#16] + + ldp $ord0,$ord1,[$ordk,#0] + ldp $ord2,$ord3,[$ordk,#16] + ldr $ordk,[$ordk,#32] + b .Loop_ord_sqr + +.align 4 +.Loop_ord_sqr: + sub $bp,$bp,#1 + //////////////////////////////////////////////////////////////// + // | | | | | |a1*a0| | + // | | | | |a2*a0| | | + // | |a3*a2|a3*a0| | | | + // | | | |a2*a1| | | | + // | | |a3*a1| | | | | + // *| | | | | | | | 2| + // +|a3*a3|a2*a2|a1*a1|a0*a0| + // |--+--+--+--+--+--+--+--| + // |A7|A6|A5|A4|A3|A2|A1|A0|, where Ax is $accx, i.e. follow $accx + // + // "can't overflow" below mark carrying into high part of + // multiplication result, which can't overflow, because it + // can never be all ones. + + mul $acc1,$a1,$a0 // a[1]*a[0] + umulh $t1,$a1,$a0 + mul $acc2,$a2,$a0 // a[2]*a[0] + umulh $t2,$a2,$a0 + mul $acc3,$a3,$a0 // a[3]*a[0] + umulh $acc4,$a3,$a0 + + adds $acc2,$acc2,$t1 // accumulate high parts of multiplication + mul $t0,$a2,$a1 // a[2]*a[1] + umulh $t1,$a2,$a1 + adcs $acc3,$acc3,$t2 + mul $t2,$a3,$a1 // a[3]*a[1] + umulh $t3,$a3,$a1 + adc $acc4,$acc4,xzr // can't overflow + + mul $acc5,$a3,$a2 // a[3]*a[2] + umulh $acc6,$a3,$a2 + + adds $t1,$t1,$t2 // accumulate high parts of multiplication + mul $acc0,$a0,$a0 // a[0]*a[0] + adc $t2,$t3,xzr // can't overflow + + adds $acc3,$acc3,$t0 // accumulate low parts of multiplication + umulh $a0,$a0,$a0 + adcs $acc4,$acc4,$t1 + mul $t1,$a1,$a1 // a[1]*a[1] + adcs $acc5,$acc5,$t2 + umulh $a1,$a1,$a1 + adc $acc6,$acc6,xzr // can't overflow + + adds $acc1,$acc1,$acc1 // acc[1-6]*=2 + mul $t2,$a2,$a2 // a[2]*a[2] + adcs $acc2,$acc2,$acc2 + umulh $a2,$a2,$a2 + adcs $acc3,$acc3,$acc3 + mul $t3,$a3,$a3 // a[3]*a[3] + adcs $acc4,$acc4,$acc4 + umulh $a3,$a3,$a3 + adcs $acc5,$acc5,$acc5 + adcs $acc6,$acc6,$acc6 + adc $acc7,xzr,xzr + + adds $acc1,$acc1,$a0 // +a[i]*a[i] + mul $t4,$acc0,$ordk + adcs $acc2,$acc2,$t1 + adcs $acc3,$acc3,$a1 + adcs $acc4,$acc4,$t2 + adcs $acc5,$acc5,$a2 + adcs $acc6,$acc6,$t3 + adc $acc7,$acc7,$a3 +___ +for($i=0; $i<4; $i++) { # reductions +$code.=<<___; + subs xzr,$acc0,#1 + umulh $t1,$ord0,$t4 + mul $t2,$ord1,$t4 + umulh $t3,$ord1,$t4 + + adcs $t2,$t2,$t1 + adc $t3,$t3,xzr + + adds $acc0,$acc1,$t2 + adcs $acc1,$acc2,$t3 + adcs $acc2,$acc3,$t4 + adc $acc3,xzr,$t4 // can't overflow +___ +$code.=<<___ if ($i<3); + mul $t3,$acc0,$ordk +___ +$code.=<<___; + lsl $t0,$t4,#32 + subs $acc1,$acc1,$t4 + lsr $t1,$t4,#32 + sbcs $acc2,$acc2,$t0 + sbc $acc3,$acc3,$t1 // can't borrow +___ + ($t3,$t4) = ($t4,$t3); +} +$code.=<<___; + adds $acc0,$acc0,$acc4 // accumulate upper half + adcs $acc1,$acc1,$acc5 + adcs $acc2,$acc2,$acc6 + adcs $acc3,$acc3,$acc7 + adc $acc4,xzr,xzr + + subs $t0,$acc0,$ord0 // ret -= modulus + sbcs $t1,$acc1,$ord1 + sbcs $t2,$acc2,$ord2 + sbcs $t3,$acc3,$ord3 + sbcs xzr,$acc4,xzr + + csel $a0,$acc0,$t0,lo // ret = borrow ? ret : ret-modulus + csel $a1,$acc1,$t1,lo + csel $a2,$acc2,$t2,lo + csel $a3,$acc3,$t3,lo + + cbnz $bp,.Loop_ord_sqr + + stp $a0,$a1,[$rp] + stp $a2,$a3,[$rp,#16] + + ldp x19,x20,[sp,#16] + ldp x21,x22,[sp,#32] + ldp x23,x24,[sp,#48] + ldr x29,[sp],#64 + ret +.size ecp_nistz256_ord_sqr_mont,.-ecp_nistz256_ord_sqr_mont +___ +} } + +######################################################################## +# select subroutines +# These select functions are similar to those in p256-x86_64-asm.pl +# They load all points in the lookup table +# keeping in the output only the one corresponding to the input index. +{ +my ($val,$in_t)=map("x$_",(0..1)); +my ($index)=("w2"); +my ($Idx_ctr,$Val_in, $Mask_64)=("w9", "x10", "x11"); +my ($Mask)=("v3"); +my ($Ra,$Rb,$Rc,$Rd,$Re,$Rf)=map("v$_",(16..21)); +my ($T0a,$T0b,$T0c,$T0d,$T0e,$T0f)=map("v$_",(22..27)); +$code.=<<___; +//////////////////////////////////////////////////////////////////////// +// void ecp_nistz256_select_w5(uint64_t *val, uint64_t *in_t, int index); +.globl ecp_nistz256_select_w5 +.type ecp_nistz256_select_w5,%function +.align 4 +ecp_nistz256_select_w5: + AARCH64_VALID_CALL_TARGET + + // $Val_in := $val + // $Idx_ctr := 0; loop counter and incremented internal index + mov $Val_in, $val + mov $Idx_ctr, #0 + + // [$Ra-$Rf] := 0 + movi $Ra.16b, #0 + movi $Rb.16b, #0 + movi $Rc.16b, #0 + movi $Rd.16b, #0 + movi $Re.16b, #0 + movi $Rf.16b, #0 + +.Lselect_w5_loop: + // Loop 16 times. + + // Increment index (loop counter); tested at the end of the loop + add $Idx_ctr, $Idx_ctr, #1 + + // [$T0a-$T0f] := Load a (3*256-bit = 6*128-bit) table entry starting at $in_t + // and advance $in_t to point to the next entry + ld1 {$T0a.2d, $T0b.2d, $T0c.2d, $T0d.2d}, [$in_t],#64 + + // $Mask_64 := ($Idx_ctr == $index)? All 1s : All 0s + cmp $Idx_ctr, $index + csetm $Mask_64, eq + + // continue loading ... + ld1 {$T0e.2d, $T0f.2d}, [$in_t],#32 + + // duplicate mask_64 into Mask (all 0s or all 1s) + dup $Mask.2d, $Mask_64 + + // [$Ra-$Rd] := (Mask == all 1s)? [$T0a-$T0d] : [$Ra-$Rd] + // i.e., values in output registers will remain the same if $Idx_ctr != $index + bit $Ra.16b, $T0a.16b, $Mask.16b + bit $Rb.16b, $T0b.16b, $Mask.16b + + bit $Rc.16b, $T0c.16b, $Mask.16b + bit $Rd.16b, $T0d.16b, $Mask.16b + + bit $Re.16b, $T0e.16b, $Mask.16b + bit $Rf.16b, $T0f.16b, $Mask.16b + + // If bit #4 is not 0 (i.e. idx_ctr < 16) loop back + tbz $Idx_ctr, #4, .Lselect_w5_loop + + // Write [$Ra-$Rf] to memory at the output pointer + st1 {$Ra.2d, $Rb.2d, $Rc.2d, $Rd.2d}, [$Val_in],#64 + st1 {$Re.2d, $Rf.2d}, [$Val_in] + + ret +.size ecp_nistz256_select_w5,.-ecp_nistz256_select_w5 + + +//////////////////////////////////////////////////////////////////////// +// void ecp_nistz256_select_w7(uint64_t *val, uint64_t *in_t, int index); +.globl ecp_nistz256_select_w7 +.type ecp_nistz256_select_w7,%function +.align 4 +ecp_nistz256_select_w7: + AARCH64_VALID_CALL_TARGET + + // $Idx_ctr := 0; loop counter and incremented internal index + mov $Idx_ctr, #0 + + // [$Ra-$Rf] := 0 + movi $Ra.16b, #0 + movi $Rb.16b, #0 + movi $Rc.16b, #0 + movi $Rd.16b, #0 + +.Lselect_w7_loop: + // Loop 64 times. + + // Increment index (loop counter); tested at the end of the loop + add $Idx_ctr, $Idx_ctr, #1 + + // [$T0a-$T0d] := Load a (2*256-bit = 4*128-bit) table entry starting at $in_t + // and advance $in_t to point to the next entry + ld1 {$T0a.2d, $T0b.2d, $T0c.2d, $T0d.2d}, [$in_t],#64 + + // $Mask_64 := ($Idx_ctr == $index)? All 1s : All 0s + cmp $Idx_ctr, $index + csetm $Mask_64, eq + + // duplicate mask_64 into Mask (all 0s or all 1s) + dup $Mask.2d, $Mask_64 + + // [$Ra-$Rd] := (Mask == all 1s)? [$T0a-$T0d] : [$Ra-$Rd] + // i.e., values in output registers will remain the same if $Idx_ctr != $index + bit $Ra.16b, $T0a.16b, $Mask.16b + bit $Rb.16b, $T0b.16b, $Mask.16b + + bit $Rc.16b, $T0c.16b, $Mask.16b + bit $Rd.16b, $T0d.16b, $Mask.16b + + // If bit #6 is not 0 (i.e. idx_ctr < 64) loop back + tbz $Idx_ctr, #6, .Lselect_w7_loop + + // Write [$Ra-$Rd] to memory at the output pointer + st1 {$Ra.2d, $Rb.2d, $Rc.2d, $Rd.2d}, [$val] + + ret +.size ecp_nistz256_select_w7,.-ecp_nistz256_select_w7 +___ +} + +foreach (split("\n",$code)) { + s/\`([^\`]*)\`/eval $1/ge; + + print $_,"\n"; +} +close STDOUT or die "error closing STDOUT: $!"; # enforce flush diff --git a/http/vendor/ring/crypto/fipsmodule/ec/asm/p256-x86_64-asm.pl b/http/vendor/ring/crypto/fipsmodule/ec/asm/p256-x86_64-asm.pl new file mode 100644 index 0000000..87d9852 --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/ec/asm/p256-x86_64-asm.pl @@ -0,0 +1,4144 @@ +#! /usr/bin/env perl +# Copyright 2014-2016 The OpenSSL Project Authors. All Rights Reserved. +# Copyright (c) 2014, Intel Corporation. All Rights Reserved. +# Copyright (c) 2015 CloudFlare, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Originally written by Shay Gueron (1, 2), and Vlad Krasnov (1, 3) +# (1) Intel Corporation, Israel Development Center, Haifa, Israel +# (2) University of Haifa, Israel +# (3) CloudFlare, Inc. +# +# Reference: +# S.Gueron and V.Krasnov, "Fast Prime Field Elliptic Curve Cryptography with +# 256 Bit Primes" + +# Further optimization by : +# +# this/original with/without -DECP_NISTZ256_ASM(*) +# Opteron +15-49% +150-195% +# Bulldozer +18-45% +175-240% +# P4 +24-46% +100-150% +# Westmere +18-34% +87-160% +# Sandy Bridge +14-35% +120-185% +# Ivy Bridge +11-35% +125-180% +# Haswell +10-37% +160-200% +# Broadwell +24-58% +210-270% +# Atom +20-50% +180-240% +# VIA Nano +50-160% +480-480% +# +# (*) "without -DECP_NISTZ256_ASM" refers to build with +# "enable-ec_nistp_64_gcc_128"; +# +# Ranges denote minimum and maximum improvement coefficients depending +# on benchmark. In "this/original" column lower coefficient is for +# ECDSA sign, while in "with/without" - for ECDH key agreement, and +# higher - for ECDSA sign, relatively fastest server-side operation. +# Keep in mind that +100% means 2x improvement. + +$flavour = shift; +$output = shift; +if ($flavour =~ /\./) { $output = $flavour; undef $flavour; } + +$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/); + +$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; +( $xlate="${dir}x86_64-xlate.pl" and -f $xlate ) or +( $xlate="${dir}../../../perlasm/x86_64-xlate.pl" and -f $xlate) or +die "can't locate x86_64-xlate.pl"; + +open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""; +*STDOUT=*OUT; + +$avx = 2; +$addx = 1; + +$code.=<<___; +.text + +# The polynomial +.section .rodata +.align 64 +.Lpoly: +.quad 0xffffffffffffffff, 0x00000000ffffffff, 0x0000000000000000, 0xffffffff00000001 + +.LOne: +.long 1,1,1,1,1,1,1,1 +.LTwo: +.long 2,2,2,2,2,2,2,2 +.LThree: +.long 3,3,3,3,3,3,3,3 +.LONE_mont: +.quad 0x0000000000000001, 0xffffffff00000000, 0xffffffffffffffff, 0x00000000fffffffe + +# Constants for computations modulo ord(p256) +.Lord: +.quad 0xf3b9cac2fc632551, 0xbce6faada7179e84, 0xffffffffffffffff, 0xffffffff00000000 +.LordK: +.quad 0xccd1c8aaee00bc4f +.text +___ + +{ +my ($a0,$a1,$a2,$a3)=map("%r$_",(8..11)); +my ($t0,$t1,$t2,$t3,$t4)=("%rax","%rdx","%rcx","%r12","%r13"); +my ($r_ptr,$a_ptr,$b_ptr)=("%rdi","%rsi","%rdx"); + +$code.=<<___; + +################################################################################ +# void ecp_nistz256_neg(uint64_t res[4], uint64_t a[4]); +.globl ecp_nistz256_neg +.type ecp_nistz256_neg,\@function,2 +.align 32 +ecp_nistz256_neg: +.cfi_startproc + _CET_ENDBR + push %r12 +.cfi_push %r12 + push %r13 +.cfi_push %r13 +.Lneg_body: + + xor $a0, $a0 + xor $a1, $a1 + xor $a2, $a2 + xor $a3, $a3 + xor $t4, $t4 + + sub 8*0($a_ptr), $a0 + sbb 8*1($a_ptr), $a1 + sbb 8*2($a_ptr), $a2 + mov $a0, $t0 + sbb 8*3($a_ptr), $a3 + lea .Lpoly(%rip), $a_ptr + mov $a1, $t1 + sbb \$0, $t4 + + add 8*0($a_ptr), $a0 + mov $a2, $t2 + adc 8*1($a_ptr), $a1 + adc 8*2($a_ptr), $a2 + mov $a3, $t3 + adc 8*3($a_ptr), $a3 + test $t4, $t4 + + cmovz $t0, $a0 + cmovz $t1, $a1 + mov $a0, 8*0($r_ptr) + cmovz $t2, $a2 + mov $a1, 8*1($r_ptr) + cmovz $t3, $a3 + mov $a2, 8*2($r_ptr) + mov $a3, 8*3($r_ptr) + + mov 0(%rsp),%r13 +.cfi_restore %r13 + mov 8(%rsp),%r12 +.cfi_restore %r12 + lea 16(%rsp),%rsp +.cfi_adjust_cfa_offset -16 +.Lneg_epilogue: + ret +.cfi_endproc +.size ecp_nistz256_neg,.-ecp_nistz256_neg +___ +} +{ +my ($r_ptr,$a_ptr,$b_org,$b_ptr)=("%rdi","%rsi","%rdx","%rbx"); +my ($acc0,$acc1,$acc2,$acc3,$acc4,$acc5,$acc6,$acc7)=map("%r$_",(8..15)); +my ($t0,$t1,$t2,$t3,$t4)=("%rcx","%rbp","%rbx","%rdx","%rax"); +my ($poly1,$poly3)=($acc6,$acc7); + +$code.=<<___; +################################################################################ +# void ecp_nistz256_ord_mul_mont( +# uint64_t res[4], +# uint64_t a[4], +# uint64_t b[4]); + +.globl ecp_nistz256_ord_mul_mont_nohw +.type ecp_nistz256_ord_mul_mont_nohw,\@function,3 +.align 32 +ecp_nistz256_ord_mul_mont_nohw: +.cfi_startproc + _CET_ENDBR + push %rbp +.cfi_push %rbp + push %rbx +.cfi_push %rbx + push %r12 +.cfi_push %r12 + push %r13 +.cfi_push %r13 + push %r14 +.cfi_push %r14 + push %r15 +.cfi_push %r15 +.Lord_mul_body: + + mov 8*0($b_org), %rax + mov $b_org, $b_ptr + lea .Lord(%rip), %r14 + mov .LordK(%rip), %r15 + + ################################# * b[0] + mov %rax, $t0 + mulq 8*0($a_ptr) + mov %rax, $acc0 + mov $t0, %rax + mov %rdx, $acc1 + + mulq 8*1($a_ptr) + add %rax, $acc1 + mov $t0, %rax + adc \$0, %rdx + mov %rdx, $acc2 + + mulq 8*2($a_ptr) + add %rax, $acc2 + mov $t0, %rax + adc \$0, %rdx + + mov $acc0, $acc5 + imulq %r15,$acc0 + + mov %rdx, $acc3 + mulq 8*3($a_ptr) + add %rax, $acc3 + mov $acc0, %rax + adc \$0, %rdx + mov %rdx, $acc4 + + ################################# First reduction step + mulq 8*0(%r14) + mov $acc0, $t1 + add %rax, $acc5 # guaranteed to be zero + mov $acc0, %rax + adc \$0, %rdx + mov %rdx, $t0 + + sub $acc0, $acc2 + sbb \$0, $acc0 # can't borrow + + mulq 8*1(%r14) + add $t0, $acc1 + adc \$0, %rdx + add %rax, $acc1 + mov $t1, %rax + adc %rdx, $acc2 + mov $t1, %rdx + adc \$0, $acc0 # can't overflow + + shl \$32, %rax + shr \$32, %rdx + sub %rax, $acc3 + mov 8*1($b_ptr), %rax + sbb %rdx, $t1 # can't borrow + + add $acc0, $acc3 + adc $t1, $acc4 + adc \$0, $acc5 + + ################################# * b[1] + mov %rax, $t0 + mulq 8*0($a_ptr) + add %rax, $acc1 + mov $t0, %rax + adc \$0, %rdx + mov %rdx, $t1 + + mulq 8*1($a_ptr) + add $t1, $acc2 + adc \$0, %rdx + add %rax, $acc2 + mov $t0, %rax + adc \$0, %rdx + mov %rdx, $t1 + + mulq 8*2($a_ptr) + add $t1, $acc3 + adc \$0, %rdx + add %rax, $acc3 + mov $t0, %rax + adc \$0, %rdx + + mov $acc1, $t0 + imulq %r15, $acc1 + + mov %rdx, $t1 + mulq 8*3($a_ptr) + add $t1, $acc4 + adc \$0, %rdx + xor $acc0, $acc0 + add %rax, $acc4 + mov $acc1, %rax + adc %rdx, $acc5 + adc \$0, $acc0 + + ################################# Second reduction step + mulq 8*0(%r14) + mov $acc1, $t1 + add %rax, $t0 # guaranteed to be zero + mov $acc1, %rax + adc %rdx, $t0 + + sub $acc1, $acc3 + sbb \$0, $acc1 # can't borrow + + mulq 8*1(%r14) + add $t0, $acc2 + adc \$0, %rdx + add %rax, $acc2 + mov $t1, %rax + adc %rdx, $acc3 + mov $t1, %rdx + adc \$0, $acc1 # can't overflow + + shl \$32, %rax + shr \$32, %rdx + sub %rax, $acc4 + mov 8*2($b_ptr), %rax + sbb %rdx, $t1 # can't borrow + + add $acc1, $acc4 + adc $t1, $acc5 + adc \$0, $acc0 + + ################################## * b[2] + mov %rax, $t0 + mulq 8*0($a_ptr) + add %rax, $acc2 + mov $t0, %rax + adc \$0, %rdx + mov %rdx, $t1 + + mulq 8*1($a_ptr) + add $t1, $acc3 + adc \$0, %rdx + add %rax, $acc3 + mov $t0, %rax + adc \$0, %rdx + mov %rdx, $t1 + + mulq 8*2($a_ptr) + add $t1, $acc4 + adc \$0, %rdx + add %rax, $acc4 + mov $t0, %rax + adc \$0, %rdx + + mov $acc2, $t0 + imulq %r15, $acc2 + + mov %rdx, $t1 + mulq 8*3($a_ptr) + add $t1, $acc5 + adc \$0, %rdx + xor $acc1, $acc1 + add %rax, $acc5 + mov $acc2, %rax + adc %rdx, $acc0 + adc \$0, $acc1 + + ################################# Third reduction step + mulq 8*0(%r14) + mov $acc2, $t1 + add %rax, $t0 # guaranteed to be zero + mov $acc2, %rax + adc %rdx, $t0 + + sub $acc2, $acc4 + sbb \$0, $acc2 # can't borrow + + mulq 8*1(%r14) + add $t0, $acc3 + adc \$0, %rdx + add %rax, $acc3 + mov $t1, %rax + adc %rdx, $acc4 + mov $t1, %rdx + adc \$0, $acc2 # can't overflow + + shl \$32, %rax + shr \$32, %rdx + sub %rax, $acc5 + mov 8*3($b_ptr), %rax + sbb %rdx, $t1 # can't borrow + + add $acc2, $acc5 + adc $t1, $acc0 + adc \$0, $acc1 + + ################################# * b[3] + mov %rax, $t0 + mulq 8*0($a_ptr) + add %rax, $acc3 + mov $t0, %rax + adc \$0, %rdx + mov %rdx, $t1 + + mulq 8*1($a_ptr) + add $t1, $acc4 + adc \$0, %rdx + add %rax, $acc4 + mov $t0, %rax + adc \$0, %rdx + mov %rdx, $t1 + + mulq 8*2($a_ptr) + add $t1, $acc5 + adc \$0, %rdx + add %rax, $acc5 + mov $t0, %rax + adc \$0, %rdx + + mov $acc3, $t0 + imulq %r15, $acc3 + + mov %rdx, $t1 + mulq 8*3($a_ptr) + add $t1, $acc0 + adc \$0, %rdx + xor $acc2, $acc2 + add %rax, $acc0 + mov $acc3, %rax + adc %rdx, $acc1 + adc \$0, $acc2 + + ################################# Last reduction step + mulq 8*0(%r14) + mov $acc3, $t1 + add %rax, $t0 # guaranteed to be zero + mov $acc3, %rax + adc %rdx, $t0 + + sub $acc3, $acc5 + sbb \$0, $acc3 # can't borrow + + mulq 8*1(%r14) + add $t0, $acc4 + adc \$0, %rdx + add %rax, $acc4 + mov $t1, %rax + adc %rdx, $acc5 + mov $t1, %rdx + adc \$0, $acc3 # can't overflow + + shl \$32, %rax + shr \$32, %rdx + sub %rax, $acc0 + sbb %rdx, $t1 # can't borrow + + add $acc3, $acc0 + adc $t1, $acc1 + adc \$0, $acc2 + + ################################# Subtract ord + mov $acc4, $a_ptr + sub 8*0(%r14), $acc4 + mov $acc5, $acc3 + sbb 8*1(%r14), $acc5 + mov $acc0, $t0 + sbb 8*2(%r14), $acc0 + mov $acc1, $t1 + sbb 8*3(%r14), $acc1 + sbb \$0, $acc2 + + cmovc $a_ptr, $acc4 + cmovc $acc3, $acc5 + cmovc $t0, $acc0 + cmovc $t1, $acc1 + + mov $acc4, 8*0($r_ptr) + mov $acc5, 8*1($r_ptr) + mov $acc0, 8*2($r_ptr) + mov $acc1, 8*3($r_ptr) + + mov 0(%rsp),%r15 +.cfi_restore %r15 + mov 8(%rsp),%r14 +.cfi_restore %r14 + mov 16(%rsp),%r13 +.cfi_restore %r13 + mov 24(%rsp),%r12 +.cfi_restore %r12 + mov 32(%rsp),%rbx +.cfi_restore %rbx + mov 40(%rsp),%rbp +.cfi_restore %rbp + lea 48(%rsp),%rsp +.cfi_adjust_cfa_offset -48 +.Lord_mul_epilogue: + ret +.cfi_endproc +.size ecp_nistz256_ord_mul_mont_nohw,.-ecp_nistz256_ord_mul_mont_nohw + +################################################################################ +# void ecp_nistz256_ord_sqr_mont( +# uint64_t res[4], +# uint64_t a[4], +# uint64_t rep); + +.globl ecp_nistz256_ord_sqr_mont_nohw +.type ecp_nistz256_ord_sqr_mont_nohw,\@function,3 +.align 32 +ecp_nistz256_ord_sqr_mont_nohw: +.cfi_startproc + _CET_ENDBR + push %rbp +.cfi_push %rbp + push %rbx +.cfi_push %rbx + push %r12 +.cfi_push %r12 + push %r13 +.cfi_push %r13 + push %r14 +.cfi_push %r14 + push %r15 +.cfi_push %r15 +.Lord_sqr_body: + + mov 8*0($a_ptr), $acc0 + mov 8*1($a_ptr), %rax + mov 8*2($a_ptr), $acc6 + mov 8*3($a_ptr), $acc7 + lea .Lord(%rip), $a_ptr # pointer to modulus + mov $b_org, $b_ptr + jmp .Loop_ord_sqr + +.align 32 +.Loop_ord_sqr: + ################################# a[1:] * a[0] + mov %rax, $t1 # put aside a[1] + mul $acc0 # a[1] * a[0] + mov %rax, $acc1 + movq $t1, %xmm1 # offload a[1] + mov $acc6, %rax + mov %rdx, $acc2 + + mul $acc0 # a[2] * a[0] + add %rax, $acc2 + mov $acc7, %rax + movq $acc6, %xmm2 # offload a[2] + adc \$0, %rdx + mov %rdx, $acc3 + + mul $acc0 # a[3] * a[0] + add %rax, $acc3 + mov $acc7, %rax + movq $acc7, %xmm3 # offload a[3] + adc \$0, %rdx + mov %rdx, $acc4 + + ################################# a[3] * a[2] + mul $acc6 # a[3] * a[2] + mov %rax, $acc5 + mov $acc6, %rax + mov %rdx, $acc6 + + ################################# a[2:] * a[1] + mul $t1 # a[2] * a[1] + add %rax, $acc3 + mov $acc7, %rax + adc \$0, %rdx + mov %rdx, $acc7 + + mul $t1 # a[3] * a[1] + add %rax, $acc4 + adc \$0, %rdx + + add $acc7, $acc4 + adc %rdx, $acc5 + adc \$0, $acc6 # can't overflow + + ################################# *2 + xor $acc7, $acc7 + mov $acc0, %rax + add $acc1, $acc1 + adc $acc2, $acc2 + adc $acc3, $acc3 + adc $acc4, $acc4 + adc $acc5, $acc5 + adc $acc6, $acc6 + adc \$0, $acc7 + + ################################# Missing products + mul %rax # a[0] * a[0] + mov %rax, $acc0 + movq %xmm1, %rax + mov %rdx, $t1 + + mul %rax # a[1] * a[1] + add $t1, $acc1 + adc %rax, $acc2 + movq %xmm2, %rax + adc \$0, %rdx + mov %rdx, $t1 + + mul %rax # a[2] * a[2] + add $t1, $acc3 + adc %rax, $acc4 + movq %xmm3, %rax + adc \$0, %rdx + mov %rdx, $t1 + + mov $acc0, $t0 + imulq 8*4($a_ptr), $acc0 # *= .LordK + + mul %rax # a[3] * a[3] + add $t1, $acc5 + adc %rax, $acc6 + mov 8*0($a_ptr), %rax # modulus[0] + adc %rdx, $acc7 # can't overflow + + ################################# First reduction step + mul $acc0 + mov $acc0, $t1 + add %rax, $t0 # guaranteed to be zero + mov 8*1($a_ptr), %rax # modulus[1] + adc %rdx, $t0 + + sub $acc0, $acc2 + sbb \$0, $t1 # can't borrow + + mul $acc0 + add $t0, $acc1 + adc \$0, %rdx + add %rax, $acc1 + mov $acc0, %rax + adc %rdx, $acc2 + mov $acc0, %rdx + adc \$0, $t1 # can't overflow + + mov $acc1, $t0 + imulq 8*4($a_ptr), $acc1 # *= .LordK + + shl \$32, %rax + shr \$32, %rdx + sub %rax, $acc3 + mov 8*0($a_ptr), %rax + sbb %rdx, $acc0 # can't borrow + + add $t1, $acc3 + adc \$0, $acc0 # can't overflow + + ################################# Second reduction step + mul $acc1 + mov $acc1, $t1 + add %rax, $t0 # guaranteed to be zero + mov 8*1($a_ptr), %rax + adc %rdx, $t0 + + sub $acc1, $acc3 + sbb \$0, $t1 # can't borrow + + mul $acc1 + add $t0, $acc2 + adc \$0, %rdx + add %rax, $acc2 + mov $acc1, %rax + adc %rdx, $acc3 + mov $acc1, %rdx + adc \$0, $t1 # can't overflow + + mov $acc2, $t0 + imulq 8*4($a_ptr), $acc2 # *= .LordK + + shl \$32, %rax + shr \$32, %rdx + sub %rax, $acc0 + mov 8*0($a_ptr), %rax + sbb %rdx, $acc1 # can't borrow + + add $t1, $acc0 + adc \$0, $acc1 # can't overflow + + ################################# Third reduction step + mul $acc2 + mov $acc2, $t1 + add %rax, $t0 # guaranteed to be zero + mov 8*1($a_ptr), %rax + adc %rdx, $t0 + + sub $acc2, $acc0 + sbb \$0, $t1 # can't borrow + + mul $acc2 + add $t0, $acc3 + adc \$0, %rdx + add %rax, $acc3 + mov $acc2, %rax + adc %rdx, $acc0 + mov $acc2, %rdx + adc \$0, $t1 # can't overflow + + mov $acc3, $t0 + imulq 8*4($a_ptr), $acc3 # *= .LordK + + shl \$32, %rax + shr \$32, %rdx + sub %rax, $acc1 + mov 8*0($a_ptr), %rax + sbb %rdx, $acc2 # can't borrow + + add $t1, $acc1 + adc \$0, $acc2 # can't overflow + + ################################# Last reduction step + mul $acc3 + mov $acc3, $t1 + add %rax, $t0 # guaranteed to be zero + mov 8*1($a_ptr), %rax + adc %rdx, $t0 + + sub $acc3, $acc1 + sbb \$0, $t1 # can't borrow + + mul $acc3 + add $t0, $acc0 + adc \$0, %rdx + add %rax, $acc0 + mov $acc3, %rax + adc %rdx, $acc1 + mov $acc3, %rdx + adc \$0, $t1 # can't overflow + + shl \$32, %rax + shr \$32, %rdx + sub %rax, $acc2 + sbb %rdx, $acc3 # can't borrow + + add $t1, $acc2 + adc \$0, $acc3 # can't overflow + + ################################# Add bits [511:256] of the sqr result + xor %rdx, %rdx + add $acc4, $acc0 + adc $acc5, $acc1 + mov $acc0, $acc4 + adc $acc6, $acc2 + adc $acc7, $acc3 + mov $acc1, %rax + adc \$0, %rdx + + ################################# Compare to modulus + sub 8*0($a_ptr), $acc0 + mov $acc2, $acc6 + sbb 8*1($a_ptr), $acc1 + sbb 8*2($a_ptr), $acc2 + mov $acc3, $acc7 + sbb 8*3($a_ptr), $acc3 + sbb \$0, %rdx + + cmovc $acc4, $acc0 + cmovnc $acc1, %rax + cmovnc $acc2, $acc6 + cmovnc $acc3, $acc7 + + dec $b_ptr + jnz .Loop_ord_sqr + + mov $acc0, 8*0($r_ptr) + mov %rax, 8*1($r_ptr) + pxor %xmm1, %xmm1 + mov $acc6, 8*2($r_ptr) + pxor %xmm2, %xmm2 + mov $acc7, 8*3($r_ptr) + pxor %xmm3, %xmm3 + + mov 0(%rsp),%r15 +.cfi_restore %r15 + mov 8(%rsp),%r14 +.cfi_restore %r14 + mov 16(%rsp),%r13 +.cfi_restore %r13 + mov 24(%rsp),%r12 +.cfi_restore %r12 + mov 32(%rsp),%rbx +.cfi_restore %rbx + mov 40(%rsp),%rbp +.cfi_restore %rbp + lea 48(%rsp),%rsp +.cfi_adjust_cfa_offset -48 +.Lord_sqr_epilogue: + ret +.cfi_endproc +.size ecp_nistz256_ord_sqr_mont_nohw,.-ecp_nistz256_ord_sqr_mont_nohw +___ + +$code.=<<___ if ($addx); +################################################################################ +.globl ecp_nistz256_ord_mul_mont_adx +.type ecp_nistz256_ord_mul_mont_adx,\@function,3 +.align 32 +ecp_nistz256_ord_mul_mont_adx: +.cfi_startproc +.Lecp_nistz256_ord_mul_mont_adx: + _CET_ENDBR + push %rbp +.cfi_push %rbp + push %rbx +.cfi_push %rbx + push %r12 +.cfi_push %r12 + push %r13 +.cfi_push %r13 + push %r14 +.cfi_push %r14 + push %r15 +.cfi_push %r15 +.Lord_mulx_body: + + mov $b_org, $b_ptr + mov 8*0($b_org), %rdx + mov 8*0($a_ptr), $acc1 + mov 8*1($a_ptr), $acc2 + mov 8*2($a_ptr), $acc3 + mov 8*3($a_ptr), $acc4 + lea -128($a_ptr), $a_ptr # control u-op density + lea .Lord-128(%rip), %r14 + mov .LordK(%rip), %r15 + + ################################# Multiply by b[0] + mulx $acc1, $acc0, $acc1 + mulx $acc2, $t0, $acc2 + mulx $acc3, $t1, $acc3 + add $t0, $acc1 + mulx $acc4, $t0, $acc4 + mov $acc0, %rdx + mulx %r15, %rdx, %rax + adc $t1, $acc2 + adc $t0, $acc3 + adc \$0, $acc4 + + ################################# reduction + xor $acc5, $acc5 # $acc5=0, cf=0, of=0 + mulx 8*0+128(%r14), $t0, $t1 + adcx $t0, $acc0 # guaranteed to be zero + adox $t1, $acc1 + + mulx 8*1+128(%r14), $t0, $t1 + adcx $t0, $acc1 + adox $t1, $acc2 + + mulx 8*2+128(%r14), $t0, $t1 + adcx $t0, $acc2 + adox $t1, $acc3 + + mulx 8*3+128(%r14), $t0, $t1 + mov 8*1($b_ptr), %rdx + adcx $t0, $acc3 + adox $t1, $acc4 + adcx $acc0, $acc4 + adox $acc0, $acc5 + adc \$0, $acc5 # cf=0, of=0 + + ################################# Multiply by b[1] + mulx 8*0+128($a_ptr), $t0, $t1 + adcx $t0, $acc1 + adox $t1, $acc2 + + mulx 8*1+128($a_ptr), $t0, $t1 + adcx $t0, $acc2 + adox $t1, $acc3 + + mulx 8*2+128($a_ptr), $t0, $t1 + adcx $t0, $acc3 + adox $t1, $acc4 + + mulx 8*3+128($a_ptr), $t0, $t1 + mov $acc1, %rdx + mulx %r15, %rdx, %rax + adcx $t0, $acc4 + adox $t1, $acc5 + + adcx $acc0, $acc5 + adox $acc0, $acc0 + adc \$0, $acc0 # cf=0, of=0 + + ################################# reduction + mulx 8*0+128(%r14), $t0, $t1 + adcx $t0, $acc1 # guaranteed to be zero + adox $t1, $acc2 + + mulx 8*1+128(%r14), $t0, $t1 + adcx $t0, $acc2 + adox $t1, $acc3 + + mulx 8*2+128(%r14), $t0, $t1 + adcx $t0, $acc3 + adox $t1, $acc4 + + mulx 8*3+128(%r14), $t0, $t1 + mov 8*2($b_ptr), %rdx + adcx $t0, $acc4 + adox $t1, $acc5 + adcx $acc1, $acc5 + adox $acc1, $acc0 + adc \$0, $acc0 # cf=0, of=0 + + ################################# Multiply by b[2] + mulx 8*0+128($a_ptr), $t0, $t1 + adcx $t0, $acc2 + adox $t1, $acc3 + + mulx 8*1+128($a_ptr), $t0, $t1 + adcx $t0, $acc3 + adox $t1, $acc4 + + mulx 8*2+128($a_ptr), $t0, $t1 + adcx $t0, $acc4 + adox $t1, $acc5 + + mulx 8*3+128($a_ptr), $t0, $t1 + mov $acc2, %rdx + mulx %r15, %rdx, %rax + adcx $t0, $acc5 + adox $t1, $acc0 + + adcx $acc1, $acc0 + adox $acc1, $acc1 + adc \$0, $acc1 # cf=0, of=0 + + ################################# reduction + mulx 8*0+128(%r14), $t0, $t1 + adcx $t0, $acc2 # guaranteed to be zero + adox $t1, $acc3 + + mulx 8*1+128(%r14), $t0, $t1 + adcx $t0, $acc3 + adox $t1, $acc4 + + mulx 8*2+128(%r14), $t0, $t1 + adcx $t0, $acc4 + adox $t1, $acc5 + + mulx 8*3+128(%r14), $t0, $t1 + mov 8*3($b_ptr), %rdx + adcx $t0, $acc5 + adox $t1, $acc0 + adcx $acc2, $acc0 + adox $acc2, $acc1 + adc \$0, $acc1 # cf=0, of=0 + + ################################# Multiply by b[3] + mulx 8*0+128($a_ptr), $t0, $t1 + adcx $t0, $acc3 + adox $t1, $acc4 + + mulx 8*1+128($a_ptr), $t0, $t1 + adcx $t0, $acc4 + adox $t1, $acc5 + + mulx 8*2+128($a_ptr), $t0, $t1 + adcx $t0, $acc5 + adox $t1, $acc0 + + mulx 8*3+128($a_ptr), $t0, $t1 + mov $acc3, %rdx + mulx %r15, %rdx, %rax + adcx $t0, $acc0 + adox $t1, $acc1 + + adcx $acc2, $acc1 + adox $acc2, $acc2 + adc \$0, $acc2 # cf=0, of=0 + + ################################# reduction + mulx 8*0+128(%r14), $t0, $t1 + adcx $t0, $acc3 # guranteed to be zero + adox $t1, $acc4 + + mulx 8*1+128(%r14), $t0, $t1 + adcx $t0, $acc4 + adox $t1, $acc5 + + mulx 8*2+128(%r14), $t0, $t1 + adcx $t0, $acc5 + adox $t1, $acc0 + + mulx 8*3+128(%r14), $t0, $t1 + lea 128(%r14),%r14 + mov $acc4, $t2 + adcx $t0, $acc0 + adox $t1, $acc1 + mov $acc5, $t3 + adcx $acc3, $acc1 + adox $acc3, $acc2 + adc \$0, $acc2 + + ################################# + # Branch-less conditional subtraction of P + mov $acc0, $t0 + sub 8*0(%r14), $acc4 + sbb 8*1(%r14), $acc5 + sbb 8*2(%r14), $acc0 + mov $acc1, $t1 + sbb 8*3(%r14), $acc1 + sbb \$0, $acc2 + + cmovc $t2, $acc4 + cmovc $t3, $acc5 + cmovc $t0, $acc0 + cmovc $t1, $acc1 + + mov $acc4, 8*0($r_ptr) + mov $acc5, 8*1($r_ptr) + mov $acc0, 8*2($r_ptr) + mov $acc1, 8*3($r_ptr) + + mov 0(%rsp),%r15 +.cfi_restore %r15 + mov 8(%rsp),%r14 +.cfi_restore %r14 + mov 16(%rsp),%r13 +.cfi_restore %r13 + mov 24(%rsp),%r12 +.cfi_restore %r12 + mov 32(%rsp),%rbx +.cfi_restore %rbx + mov 40(%rsp),%rbp +.cfi_restore %rbp + lea 48(%rsp),%rsp +.cfi_adjust_cfa_offset -48 +.Lord_mulx_epilogue: + ret +.cfi_endproc +.size ecp_nistz256_ord_mul_mont_adx,.-ecp_nistz256_ord_mul_mont_adx + +.globl ecp_nistz256_ord_sqr_mont_adx +.type ecp_nistz256_ord_sqr_mont_adx,\@function,3 +.align 32 +ecp_nistz256_ord_sqr_mont_adx: +.cfi_startproc + _CET_ENDBR +.Lecp_nistz256_ord_sqr_mont_adx: + push %rbp +.cfi_push %rbp + push %rbx +.cfi_push %rbx + push %r12 +.cfi_push %r12 + push %r13 +.cfi_push %r13 + push %r14 +.cfi_push %r14 + push %r15 +.cfi_push %r15 +.Lord_sqrx_body: + + mov $b_org, $b_ptr + mov 8*0($a_ptr), %rdx + mov 8*1($a_ptr), $acc6 + mov 8*2($a_ptr), $acc7 + mov 8*3($a_ptr), $acc0 + lea .Lord(%rip), $a_ptr + jmp .Loop_ord_sqrx + +.align 32 +.Loop_ord_sqrx: + mulx $acc6, $acc1, $acc2 # a[0]*a[1] + mulx $acc7, $t0, $acc3 # a[0]*a[2] + mov %rdx, %rax # offload a[0] + movq $acc6, %xmm1 # offload a[1] + mulx $acc0, $t1, $acc4 # a[0]*a[3] + mov $acc6, %rdx + add $t0, $acc2 + movq $acc7, %xmm2 # offload a[2] + adc $t1, $acc3 + adc \$0, $acc4 + xor $acc5, $acc5 # $acc5=0,cf=0,of=0 + ################################# + mulx $acc7, $t0, $t1 # a[1]*a[2] + adcx $t0, $acc3 + adox $t1, $acc4 + + mulx $acc0, $t0, $t1 # a[1]*a[3] + mov $acc7, %rdx + adcx $t0, $acc4 + adox $t1, $acc5 + adc \$0, $acc5 + ################################# + mulx $acc0, $t0, $acc6 # a[2]*a[3] + mov %rax, %rdx + movq $acc0, %xmm3 # offload a[3] + xor $acc7, $acc7 # $acc7=0,cf=0,of=0 + adcx $acc1, $acc1 # acc1:6<<1 + adox $t0, $acc5 + adcx $acc2, $acc2 + adox $acc7, $acc6 # of=0 + + ################################# a[i]*a[i] + mulx %rdx, $acc0, $t1 + movq %xmm1, %rdx + adcx $acc3, $acc3 + adox $t1, $acc1 + adcx $acc4, $acc4 + mulx %rdx, $t0, $t4 + movq %xmm2, %rdx + adcx $acc5, $acc5 + adox $t0, $acc2 + adcx $acc6, $acc6 + mulx %rdx, $t0, $t1 + .byte 0x67 + movq %xmm3, %rdx + adox $t4, $acc3 + adcx $acc7, $acc7 + adox $t0, $acc4 + adox $t1, $acc5 + mulx %rdx, $t0, $t4 + adox $t0, $acc6 + adox $t4, $acc7 + + ################################# reduction + mov $acc0, %rdx + mulx 8*4($a_ptr), %rdx, $t0 + + xor %rax, %rax # cf=0, of=0 + mulx 8*0($a_ptr), $t0, $t1 + adcx $t0, $acc0 # guaranteed to be zero + adox $t1, $acc1 + mulx 8*1($a_ptr), $t0, $t1 + adcx $t0, $acc1 + adox $t1, $acc2 + mulx 8*2($a_ptr), $t0, $t1 + adcx $t0, $acc2 + adox $t1, $acc3 + mulx 8*3($a_ptr), $t0, $t1 + adcx $t0, $acc3 + adox $t1, $acc0 # of=0 + adcx %rax, $acc0 # cf=0 + + ################################# + mov $acc1, %rdx + mulx 8*4($a_ptr), %rdx, $t0 + + mulx 8*0($a_ptr), $t0, $t1 + adox $t0, $acc1 # guaranteed to be zero + adcx $t1, $acc2 + mulx 8*1($a_ptr), $t0, $t1 + adox $t0, $acc2 + adcx $t1, $acc3 + mulx 8*2($a_ptr), $t0, $t1 + adox $t0, $acc3 + adcx $t1, $acc0 + mulx 8*3($a_ptr), $t0, $t1 + adox $t0, $acc0 + adcx $t1, $acc1 # cf=0 + adox %rax, $acc1 # of=0 + + ################################# + mov $acc2, %rdx + mulx 8*4($a_ptr), %rdx, $t0 + + mulx 8*0($a_ptr), $t0, $t1 + adcx $t0, $acc2 # guaranteed to be zero + adox $t1, $acc3 + mulx 8*1($a_ptr), $t0, $t1 + adcx $t0, $acc3 + adox $t1, $acc0 + mulx 8*2($a_ptr), $t0, $t1 + adcx $t0, $acc0 + adox $t1, $acc1 + mulx 8*3($a_ptr), $t0, $t1 + adcx $t0, $acc1 + adox $t1, $acc2 # of=0 + adcx %rax, $acc2 # cf=0 + + ################################# + mov $acc3, %rdx + mulx 8*4($a_ptr), %rdx, $t0 + + mulx 8*0($a_ptr), $t0, $t1 + adox $t0, $acc3 # guaranteed to be zero + adcx $t1, $acc0 + mulx 8*1($a_ptr), $t0, $t1 + adox $t0, $acc0 + adcx $t1, $acc1 + mulx 8*2($a_ptr), $t0, $t1 + adox $t0, $acc1 + adcx $t1, $acc2 + mulx 8*3($a_ptr), $t0, $t1 + adox $t0, $acc2 + adcx $t1, $acc3 + adox %rax, $acc3 + + ################################# accumulate upper half + add $acc0, $acc4 # add $acc4, $acc0 + adc $acc5, $acc1 + mov $acc4, %rdx + adc $acc6, $acc2 + adc $acc7, $acc3 + mov $acc1, $acc6 + adc \$0, %rax + + ################################# compare to modulus + sub 8*0($a_ptr), $acc4 + mov $acc2, $acc7 + sbb 8*1($a_ptr), $acc1 + sbb 8*2($a_ptr), $acc2 + mov $acc3, $acc0 + sbb 8*3($a_ptr), $acc3 + sbb \$0, %rax + + cmovnc $acc4, %rdx + cmovnc $acc1, $acc6 + cmovnc $acc2, $acc7 + cmovnc $acc3, $acc0 + + dec $b_ptr + jnz .Loop_ord_sqrx + + mov %rdx, 8*0($r_ptr) + mov $acc6, 8*1($r_ptr) + pxor %xmm1, %xmm1 + mov $acc7, 8*2($r_ptr) + pxor %xmm2, %xmm2 + mov $acc0, 8*3($r_ptr) + pxor %xmm3, %xmm3 + + mov 0(%rsp),%r15 +.cfi_restore %r15 + mov 8(%rsp),%r14 +.cfi_restore %r14 + mov 16(%rsp),%r13 +.cfi_restore %r13 + mov 24(%rsp),%r12 +.cfi_restore %r12 + mov 32(%rsp),%rbx +.cfi_restore %rbx + mov 40(%rsp),%rbp +.cfi_restore %rbp + lea 48(%rsp),%rsp +.cfi_adjust_cfa_offset -48 +.Lord_sqrx_epilogue: + ret +.cfi_endproc +.size ecp_nistz256_ord_sqr_mont_adx,.-ecp_nistz256_ord_sqr_mont_adx +___ + +$code.=<<___; +################################################################################ +# void ecp_nistz256_mul_mont( +# uint64_t res[4], +# uint64_t a[4], +# uint64_t b[4]); + +.globl ecp_nistz256_mul_mont_nohw +.type ecp_nistz256_mul_mont_nohw,\@function,3 +.align 32 +ecp_nistz256_mul_mont_nohw: +.cfi_startproc + _CET_ENDBR + push %rbp +.cfi_push %rbp + push %rbx +.cfi_push %rbx + push %r12 +.cfi_push %r12 + push %r13 +.cfi_push %r13 + push %r14 +.cfi_push %r14 + push %r15 +.cfi_push %r15 +.Lmul_body: + mov $b_org, $b_ptr + mov 8*0($b_org), %rax + mov 8*0($a_ptr), $acc1 + mov 8*1($a_ptr), $acc2 + mov 8*2($a_ptr), $acc3 + mov 8*3($a_ptr), $acc4 + + call __ecp_nistz256_mul_montq + + mov 0(%rsp),%r15 +.cfi_restore %r15 + mov 8(%rsp),%r14 +.cfi_restore %r14 + mov 16(%rsp),%r13 +.cfi_restore %r13 + mov 24(%rsp),%r12 +.cfi_restore %r12 + mov 32(%rsp),%rbx +.cfi_restore %rbx + mov 40(%rsp),%rbp +.cfi_restore %rbp + lea 48(%rsp),%rsp +.cfi_adjust_cfa_offset -48 +.Lmul_epilogue: + ret +.cfi_endproc +.size ecp_nistz256_mul_mont_nohw,.-ecp_nistz256_mul_mont_nohw + +.type __ecp_nistz256_mul_montq,\@abi-omnipotent +.align 32 +__ecp_nistz256_mul_montq: +.cfi_startproc + ######################################################################## + # Multiply a by b[0] + mov %rax, $t1 + mulq $acc1 + mov .Lpoly+8*1(%rip),$poly1 + mov %rax, $acc0 + mov $t1, %rax + mov %rdx, $acc1 + + mulq $acc2 + mov .Lpoly+8*3(%rip),$poly3 + add %rax, $acc1 + mov $t1, %rax + adc \$0, %rdx + mov %rdx, $acc2 + + mulq $acc3 + add %rax, $acc2 + mov $t1, %rax + adc \$0, %rdx + mov %rdx, $acc3 + + mulq $acc4 + add %rax, $acc3 + mov $acc0, %rax + adc \$0, %rdx + xor $acc5, $acc5 + mov %rdx, $acc4 + + ######################################################################## + # First reduction step + # Basically now we want to multiply acc[0] by p256, + # and add the result to the acc. + # Due to the special form of p256 we do some optimizations + # + # acc[0] x p256[0..1] = acc[0] x 2^96 - acc[0] + # then we add acc[0] and get acc[0] x 2^96 + + mov $acc0, $t1 + shl \$32, $acc0 + mulq $poly3 + shr \$32, $t1 + add $acc0, $acc1 # +=acc[0]<<96 + adc $t1, $acc2 + adc %rax, $acc3 + mov 8*1($b_ptr), %rax + adc %rdx, $acc4 + adc \$0, $acc5 + xor $acc0, $acc0 + + ######################################################################## + # Multiply by b[1] + mov %rax, $t1 + mulq 8*0($a_ptr) + add %rax, $acc1 + mov $t1, %rax + adc \$0, %rdx + mov %rdx, $t0 + + mulq 8*1($a_ptr) + add $t0, $acc2 + adc \$0, %rdx + add %rax, $acc2 + mov $t1, %rax + adc \$0, %rdx + mov %rdx, $t0 + + mulq 8*2($a_ptr) + add $t0, $acc3 + adc \$0, %rdx + add %rax, $acc3 + mov $t1, %rax + adc \$0, %rdx + mov %rdx, $t0 + + mulq 8*3($a_ptr) + add $t0, $acc4 + adc \$0, %rdx + add %rax, $acc4 + mov $acc1, %rax + adc %rdx, $acc5 + adc \$0, $acc0 + + ######################################################################## + # Second reduction step + mov $acc1, $t1 + shl \$32, $acc1 + mulq $poly3 + shr \$32, $t1 + add $acc1, $acc2 + adc $t1, $acc3 + adc %rax, $acc4 + mov 8*2($b_ptr), %rax + adc %rdx, $acc5 + adc \$0, $acc0 + xor $acc1, $acc1 + + ######################################################################## + # Multiply by b[2] + mov %rax, $t1 + mulq 8*0($a_ptr) + add %rax, $acc2 + mov $t1, %rax + adc \$0, %rdx + mov %rdx, $t0 + + mulq 8*1($a_ptr) + add $t0, $acc3 + adc \$0, %rdx + add %rax, $acc3 + mov $t1, %rax + adc \$0, %rdx + mov %rdx, $t0 + + mulq 8*2($a_ptr) + add $t0, $acc4 + adc \$0, %rdx + add %rax, $acc4 + mov $t1, %rax + adc \$0, %rdx + mov %rdx, $t0 + + mulq 8*3($a_ptr) + add $t0, $acc5 + adc \$0, %rdx + add %rax, $acc5 + mov $acc2, %rax + adc %rdx, $acc0 + adc \$0, $acc1 + + ######################################################################## + # Third reduction step + mov $acc2, $t1 + shl \$32, $acc2 + mulq $poly3 + shr \$32, $t1 + add $acc2, $acc3 + adc $t1, $acc4 + adc %rax, $acc5 + mov 8*3($b_ptr), %rax + adc %rdx, $acc0 + adc \$0, $acc1 + xor $acc2, $acc2 + + ######################################################################## + # Multiply by b[3] + mov %rax, $t1 + mulq 8*0($a_ptr) + add %rax, $acc3 + mov $t1, %rax + adc \$0, %rdx + mov %rdx, $t0 + + mulq 8*1($a_ptr) + add $t0, $acc4 + adc \$0, %rdx + add %rax, $acc4 + mov $t1, %rax + adc \$0, %rdx + mov %rdx, $t0 + + mulq 8*2($a_ptr) + add $t0, $acc5 + adc \$0, %rdx + add %rax, $acc5 + mov $t1, %rax + adc \$0, %rdx + mov %rdx, $t0 + + mulq 8*3($a_ptr) + add $t0, $acc0 + adc \$0, %rdx + add %rax, $acc0 + mov $acc3, %rax + adc %rdx, $acc1 + adc \$0, $acc2 + + ######################################################################## + # Final reduction step + mov $acc3, $t1 + shl \$32, $acc3 + mulq $poly3 + shr \$32, $t1 + add $acc3, $acc4 + adc $t1, $acc5 + mov $acc4, $t0 + adc %rax, $acc0 + adc %rdx, $acc1 + mov $acc5, $t1 + adc \$0, $acc2 + + ######################################################################## + # Branch-less conditional subtraction of P + sub \$-1, $acc4 # .Lpoly[0] + mov $acc0, $t2 + sbb $poly1, $acc5 # .Lpoly[1] + sbb \$0, $acc0 # .Lpoly[2] + mov $acc1, $t3 + sbb $poly3, $acc1 # .Lpoly[3] + sbb \$0, $acc2 + + cmovc $t0, $acc4 + cmovc $t1, $acc5 + mov $acc4, 8*0($r_ptr) + cmovc $t2, $acc0 + mov $acc5, 8*1($r_ptr) + cmovc $t3, $acc1 + mov $acc0, 8*2($r_ptr) + mov $acc1, 8*3($r_ptr) + + ret +.cfi_endproc +.size __ecp_nistz256_mul_montq,.-__ecp_nistz256_mul_montq + +################################################################################ +# void ecp_nistz256_sqr_mont( +# uint64_t res[4], +# uint64_t a[4]); + +# we optimize the square according to S.Gueron and V.Krasnov, +# "Speeding up Big-Number Squaring" +.globl ecp_nistz256_sqr_mont_nohw +.type ecp_nistz256_sqr_mont_nohw,\@function,2 +.align 32 +ecp_nistz256_sqr_mont_nohw: +.cfi_startproc + _CET_ENDBR + push %rbp +.cfi_push %rbp + push %rbx +.cfi_push %rbx + push %r12 +.cfi_push %r12 + push %r13 +.cfi_push %r13 + push %r14 +.cfi_push %r14 + push %r15 +.cfi_push %r15 +.Lsqr_body: + mov 8*0($a_ptr), %rax + mov 8*1($a_ptr), $acc6 + mov 8*2($a_ptr), $acc7 + mov 8*3($a_ptr), $acc0 + + call __ecp_nistz256_sqr_montq + + mov 0(%rsp),%r15 +.cfi_restore %r15 + mov 8(%rsp),%r14 +.cfi_restore %r14 + mov 16(%rsp),%r13 +.cfi_restore %r13 + mov 24(%rsp),%r12 +.cfi_restore %r12 + mov 32(%rsp),%rbx +.cfi_restore %rbx + mov 40(%rsp),%rbp +.cfi_restore %rbp + lea 48(%rsp),%rsp +.cfi_adjust_cfa_offset -48 +.Lsqr_epilogue: + ret +.cfi_endproc +.size ecp_nistz256_sqr_mont_nohw,.-ecp_nistz256_sqr_mont_nohw + +.type __ecp_nistz256_sqr_montq,\@abi-omnipotent +.align 32 +__ecp_nistz256_sqr_montq: +.cfi_startproc + mov %rax, $acc5 + mulq $acc6 # a[1]*a[0] + mov %rax, $acc1 + mov $acc7, %rax + mov %rdx, $acc2 + + mulq $acc5 # a[0]*a[2] + add %rax, $acc2 + mov $acc0, %rax + adc \$0, %rdx + mov %rdx, $acc3 + + mulq $acc5 # a[0]*a[3] + add %rax, $acc3 + mov $acc7, %rax + adc \$0, %rdx + mov %rdx, $acc4 + + ################################# + mulq $acc6 # a[1]*a[2] + add %rax, $acc3 + mov $acc0, %rax + adc \$0, %rdx + mov %rdx, $t1 + + mulq $acc6 # a[1]*a[3] + add %rax, $acc4 + mov $acc0, %rax + adc \$0, %rdx + add $t1, $acc4 + mov %rdx, $acc5 + adc \$0, $acc5 + + ################################# + mulq $acc7 # a[2]*a[3] + xor $acc7, $acc7 + add %rax, $acc5 + mov 8*0($a_ptr), %rax + mov %rdx, $acc6 + adc \$0, $acc6 + + add $acc1, $acc1 # acc1:6<<1 + adc $acc2, $acc2 + adc $acc3, $acc3 + adc $acc4, $acc4 + adc $acc5, $acc5 + adc $acc6, $acc6 + adc \$0, $acc7 + + mulq %rax + mov %rax, $acc0 + mov 8*1($a_ptr), %rax + mov %rdx, $t0 + + mulq %rax + add $t0, $acc1 + adc %rax, $acc2 + mov 8*2($a_ptr), %rax + adc \$0, %rdx + mov %rdx, $t0 + + mulq %rax + add $t0, $acc3 + adc %rax, $acc4 + mov 8*3($a_ptr), %rax + adc \$0, %rdx + mov %rdx, $t0 + + mulq %rax + add $t0, $acc5 + adc %rax, $acc6 + mov $acc0, %rax + adc %rdx, $acc7 + + mov .Lpoly+8*1(%rip), $a_ptr + mov .Lpoly+8*3(%rip), $t1 + + ########################################## + # Now the reduction + # First iteration + mov $acc0, $t0 + shl \$32, $acc0 + mulq $t1 + shr \$32, $t0 + add $acc0, $acc1 # +=acc[0]<<96 + adc $t0, $acc2 + adc %rax, $acc3 + mov $acc1, %rax + adc \$0, %rdx + + ########################################## + # Second iteration + mov $acc1, $t0 + shl \$32, $acc1 + mov %rdx, $acc0 + mulq $t1 + shr \$32, $t0 + add $acc1, $acc2 + adc $t0, $acc3 + adc %rax, $acc0 + mov $acc2, %rax + adc \$0, %rdx + + ########################################## + # Third iteration + mov $acc2, $t0 + shl \$32, $acc2 + mov %rdx, $acc1 + mulq $t1 + shr \$32, $t0 + add $acc2, $acc3 + adc $t0, $acc0 + adc %rax, $acc1 + mov $acc3, %rax + adc \$0, %rdx + + ########################################### + # Last iteration + mov $acc3, $t0 + shl \$32, $acc3 + mov %rdx, $acc2 + mulq $t1 + shr \$32, $t0 + add $acc3, $acc0 + adc $t0, $acc1 + adc %rax, $acc2 + adc \$0, %rdx + xor $acc3, $acc3 + + ############################################ + # Add the rest of the acc + add $acc0, $acc4 + adc $acc1, $acc5 + mov $acc4, $acc0 + adc $acc2, $acc6 + adc %rdx, $acc7 + mov $acc5, $acc1 + adc \$0, $acc3 + + sub \$-1, $acc4 # .Lpoly[0] + mov $acc6, $acc2 + sbb $a_ptr, $acc5 # .Lpoly[1] + sbb \$0, $acc6 # .Lpoly[2] + mov $acc7, $t0 + sbb $t1, $acc7 # .Lpoly[3] + sbb \$0, $acc3 + + cmovc $acc0, $acc4 + cmovc $acc1, $acc5 + mov $acc4, 8*0($r_ptr) + cmovc $acc2, $acc6 + mov $acc5, 8*1($r_ptr) + cmovc $t0, $acc7 + mov $acc6, 8*2($r_ptr) + mov $acc7, 8*3($r_ptr) + + ret +.cfi_endproc +.size __ecp_nistz256_sqr_montq,.-__ecp_nistz256_sqr_montq +___ + +if ($addx) { +$code.=<<___; +.globl ecp_nistz256_mul_mont_adx +.type ecp_nistz256_mul_mont_adx,\@function,3 +.align 32 +ecp_nistz256_mul_mont_adx: +.cfi_startproc + _CET_ENDBR + push %rbp +.cfi_push %rbp + push %rbx +.cfi_push %rbx + push %r12 +.cfi_push %r12 + push %r13 +.cfi_push %r13 + push %r14 +.cfi_push %r14 + push %r15 +.cfi_push %r15 +.Lmulx_body: + mov $b_org, $b_ptr + mov 8*0($b_org), %rdx + mov 8*0($a_ptr), $acc1 + mov 8*1($a_ptr), $acc2 + mov 8*2($a_ptr), $acc3 + mov 8*3($a_ptr), $acc4 + lea -128($a_ptr), $a_ptr # control u-op density + + call __ecp_nistz256_mul_montx + + mov 0(%rsp),%r15 +.cfi_restore %r15 + mov 8(%rsp),%r14 +.cfi_restore %r14 + mov 16(%rsp),%r13 +.cfi_restore %r13 + mov 24(%rsp),%r12 +.cfi_restore %r12 + mov 32(%rsp),%rbx +.cfi_restore %rbx + mov 40(%rsp),%rbp +.cfi_restore %rbp + lea 48(%rsp),%rsp +.cfi_adjust_cfa_offset -48 +.Lmulx_epilogue: + ret +.cfi_endproc +.size ecp_nistz256_mul_mont_adx,.-ecp_nistz256_mul_mont_adx + +.type __ecp_nistz256_mul_montx,\@abi-omnipotent +.align 32 +__ecp_nistz256_mul_montx: +.cfi_startproc + ######################################################################## + # Multiply by b[0] + mulx $acc1, $acc0, $acc1 + mulx $acc2, $t0, $acc2 + mov \$32, $poly1 + xor $acc5, $acc5 # cf=0 + mulx $acc3, $t1, $acc3 + mov .Lpoly+8*3(%rip), $poly3 + adc $t0, $acc1 + mulx $acc4, $t0, $acc4 + mov $acc0, %rdx + adc $t1, $acc2 + shlx $poly1,$acc0,$t1 + adc $t0, $acc3 + shrx $poly1,$acc0,$t0 + adc \$0, $acc4 + + ######################################################################## + # First reduction step + add $t1, $acc1 + adc $t0, $acc2 + + mulx $poly3, $t0, $t1 + mov 8*1($b_ptr), %rdx + adc $t0, $acc3 + adc $t1, $acc4 + adc \$0, $acc5 + xor $acc0, $acc0 # $acc0=0,cf=0,of=0 + + ######################################################################## + # Multiply by b[1] + mulx 8*0+128($a_ptr), $t0, $t1 + adcx $t0, $acc1 + adox $t1, $acc2 + + mulx 8*1+128($a_ptr), $t0, $t1 + adcx $t0, $acc2 + adox $t1, $acc3 + + mulx 8*2+128($a_ptr), $t0, $t1 + adcx $t0, $acc3 + adox $t1, $acc4 + + mulx 8*3+128($a_ptr), $t0, $t1 + mov $acc1, %rdx + adcx $t0, $acc4 + shlx $poly1, $acc1, $t0 + adox $t1, $acc5 + shrx $poly1, $acc1, $t1 + + adcx $acc0, $acc5 + adox $acc0, $acc0 + adc \$0, $acc0 + + ######################################################################## + # Second reduction step + add $t0, $acc2 + adc $t1, $acc3 + + mulx $poly3, $t0, $t1 + mov 8*2($b_ptr), %rdx + adc $t0, $acc4 + adc $t1, $acc5 + adc \$0, $acc0 + xor $acc1 ,$acc1 # $acc1=0,cf=0,of=0 + + ######################################################################## + # Multiply by b[2] + mulx 8*0+128($a_ptr), $t0, $t1 + adcx $t0, $acc2 + adox $t1, $acc3 + + mulx 8*1+128($a_ptr), $t0, $t1 + adcx $t0, $acc3 + adox $t1, $acc4 + + mulx 8*2+128($a_ptr), $t0, $t1 + adcx $t0, $acc4 + adox $t1, $acc5 + + mulx 8*3+128($a_ptr), $t0, $t1 + mov $acc2, %rdx + adcx $t0, $acc5 + shlx $poly1, $acc2, $t0 + adox $t1, $acc0 + shrx $poly1, $acc2, $t1 + + adcx $acc1, $acc0 + adox $acc1, $acc1 + adc \$0, $acc1 + + ######################################################################## + # Third reduction step + add $t0, $acc3 + adc $t1, $acc4 + + mulx $poly3, $t0, $t1 + mov 8*3($b_ptr), %rdx + adc $t0, $acc5 + adc $t1, $acc0 + adc \$0, $acc1 + xor $acc2, $acc2 # $acc2=0,cf=0,of=0 + + ######################################################################## + # Multiply by b[3] + mulx 8*0+128($a_ptr), $t0, $t1 + adcx $t0, $acc3 + adox $t1, $acc4 + + mulx 8*1+128($a_ptr), $t0, $t1 + adcx $t0, $acc4 + adox $t1, $acc5 + + mulx 8*2+128($a_ptr), $t0, $t1 + adcx $t0, $acc5 + adox $t1, $acc0 + + mulx 8*3+128($a_ptr), $t0, $t1 + mov $acc3, %rdx + adcx $t0, $acc0 + shlx $poly1, $acc3, $t0 + adox $t1, $acc1 + shrx $poly1, $acc3, $t1 + + adcx $acc2, $acc1 + adox $acc2, $acc2 + adc \$0, $acc2 + + ######################################################################## + # Fourth reduction step + add $t0, $acc4 + adc $t1, $acc5 + + mulx $poly3, $t0, $t1 + mov $acc4, $t2 + mov .Lpoly+8*1(%rip), $poly1 + adc $t0, $acc0 + mov $acc5, $t3 + adc $t1, $acc1 + adc \$0, $acc2 + + ######################################################################## + # Branch-less conditional subtraction of P + xor %eax, %eax + mov $acc0, $t0 + sbb \$-1, $acc4 # .Lpoly[0] + sbb $poly1, $acc5 # .Lpoly[1] + sbb \$0, $acc0 # .Lpoly[2] + mov $acc1, $t1 + sbb $poly3, $acc1 # .Lpoly[3] + sbb \$0, $acc2 + + cmovc $t2, $acc4 + cmovc $t3, $acc5 + mov $acc4, 8*0($r_ptr) + cmovc $t0, $acc0 + mov $acc5, 8*1($r_ptr) + cmovc $t1, $acc1 + mov $acc0, 8*2($r_ptr) + mov $acc1, 8*3($r_ptr) + + ret +.cfi_endproc +.size __ecp_nistz256_mul_montx,.-__ecp_nistz256_mul_montx + +.globl ecp_nistz256_sqr_mont_adx +.type ecp_nistz256_sqr_mont_adx,\@function,2 +.align 32 +ecp_nistz256_sqr_mont_adx: +.cfi_startproc + _CET_ENDBR + push %rbp +.cfi_push %rbp + push %rbx +.cfi_push %rbx + push %r12 +.cfi_push %r12 + push %r13 +.cfi_push %r13 + push %r14 +.cfi_push %r14 + push %r15 +.cfi_push %r15 +.Lsqrx_body: + mov 8*0($a_ptr), %rdx + mov 8*1($a_ptr), $acc6 + mov 8*2($a_ptr), $acc7 + mov 8*3($a_ptr), $acc0 + lea -128($a_ptr), $a_ptr # control u-op density + + call __ecp_nistz256_sqr_montx + + mov 0(%rsp),%r15 +.cfi_restore %r15 + mov 8(%rsp),%r14 +.cfi_restore %r14 + mov 16(%rsp),%r13 +.cfi_restore %r13 + mov 24(%rsp),%r12 +.cfi_restore %r12 + mov 32(%rsp),%rbx +.cfi_restore %rbx + mov 40(%rsp),%rbp +.cfi_restore %rbp + lea 48(%rsp),%rsp +.cfi_adjust_cfa_offset -48 +.Lsqrx_epilogue: + ret +.cfi_endproc +.size ecp_nistz256_sqr_mont_adx,.-ecp_nistz256_sqr_mont_adx + +.type __ecp_nistz256_sqr_montx,\@abi-omnipotent +.align 32 +__ecp_nistz256_sqr_montx: +.cfi_startproc + mulx $acc6, $acc1, $acc2 # a[0]*a[1] + mulx $acc7, $t0, $acc3 # a[0]*a[2] + xor %eax, %eax + adc $t0, $acc2 + mulx $acc0, $t1, $acc4 # a[0]*a[3] + mov $acc6, %rdx + adc $t1, $acc3 + adc \$0, $acc4 + xor $acc5, $acc5 # $acc5=0,cf=0,of=0 + + ################################# + mulx $acc7, $t0, $t1 # a[1]*a[2] + adcx $t0, $acc3 + adox $t1, $acc4 + + mulx $acc0, $t0, $t1 # a[1]*a[3] + mov $acc7, %rdx + adcx $t0, $acc4 + adox $t1, $acc5 + adc \$0, $acc5 + + ################################# + mulx $acc0, $t0, $acc6 # a[2]*a[3] + mov 8*0+128($a_ptr), %rdx + xor $acc7, $acc7 # $acc7=0,cf=0,of=0 + adcx $acc1, $acc1 # acc1:6<<1 + adox $t0, $acc5 + adcx $acc2, $acc2 + adox $acc7, $acc6 # of=0 + + mulx %rdx, $acc0, $t1 + mov 8*1+128($a_ptr), %rdx + adcx $acc3, $acc3 + adox $t1, $acc1 + adcx $acc4, $acc4 + mulx %rdx, $t0, $t4 + mov 8*2+128($a_ptr), %rdx + adcx $acc5, $acc5 + adox $t0, $acc2 + adcx $acc6, $acc6 + .byte 0x67 + mulx %rdx, $t0, $t1 + mov 8*3+128($a_ptr), %rdx + adox $t4, $acc3 + adcx $acc7, $acc7 + adox $t0, $acc4 + mov \$32, $a_ptr + adox $t1, $acc5 + .byte 0x67,0x67 + mulx %rdx, $t0, $t4 + mov .Lpoly+8*3(%rip), %rdx + adox $t0, $acc6 + shlx $a_ptr, $acc0, $t0 + adox $t4, $acc7 + shrx $a_ptr, $acc0, $t4 + mov %rdx,$t1 + + # reduction step 1 + add $t0, $acc1 + adc $t4, $acc2 + + mulx $acc0, $t0, $acc0 + adc $t0, $acc3 + shlx $a_ptr, $acc1, $t0 + adc \$0, $acc0 + shrx $a_ptr, $acc1, $t4 + + # reduction step 2 + add $t0, $acc2 + adc $t4, $acc3 + + mulx $acc1, $t0, $acc1 + adc $t0, $acc0 + shlx $a_ptr, $acc2, $t0 + adc \$0, $acc1 + shrx $a_ptr, $acc2, $t4 + + # reduction step 3 + add $t0, $acc3 + adc $t4, $acc0 + + mulx $acc2, $t0, $acc2 + adc $t0, $acc1 + shlx $a_ptr, $acc3, $t0 + adc \$0, $acc2 + shrx $a_ptr, $acc3, $t4 + + # reduction step 4 + add $t0, $acc0 + adc $t4, $acc1 + + mulx $acc3, $t0, $acc3 + adc $t0, $acc2 + adc \$0, $acc3 + + xor $t3, $t3 + add $acc0, $acc4 # accumulate upper half + mov .Lpoly+8*1(%rip), $a_ptr + adc $acc1, $acc5 + mov $acc4, $acc0 + adc $acc2, $acc6 + adc $acc3, $acc7 + mov $acc5, $acc1 + adc \$0, $t3 + + sub \$-1, $acc4 # .Lpoly[0] + mov $acc6, $acc2 + sbb $a_ptr, $acc5 # .Lpoly[1] + sbb \$0, $acc6 # .Lpoly[2] + mov $acc7, $acc3 + sbb $t1, $acc7 # .Lpoly[3] + sbb \$0, $t3 + + cmovc $acc0, $acc4 + cmovc $acc1, $acc5 + mov $acc4, 8*0($r_ptr) + cmovc $acc2, $acc6 + mov $acc5, 8*1($r_ptr) + cmovc $acc3, $acc7 + mov $acc6, 8*2($r_ptr) + mov $acc7, 8*3($r_ptr) + + ret +.cfi_endproc +.size __ecp_nistz256_sqr_montx,.-__ecp_nistz256_sqr_montx +___ +} +} +{ +my ($val,$in_t,$index)=$win64?("%rcx","%rdx","%r8d"):("%rdi","%rsi","%edx"); +my ($ONE,$INDEX,$Ra,$Rb,$Rc,$Rd,$Re,$Rf)=map("%xmm$_",(0..7)); +my ($M0,$T0a,$T0b,$T0c,$T0d,$T0e,$T0f,$TMP0)=map("%xmm$_",(8..15)); +my ($M1,$T2a,$T2b,$TMP2,$M2,$T2a,$T2b,$TMP2)=map("%xmm$_",(8..15)); + +$code.=<<___; +################################################################################ +# void ecp_nistz256_select_w5_nohw(uint64_t *val, uint64_t *in_t, int index); +.globl ecp_nistz256_select_w5_nohw +.type ecp_nistz256_select_w5_nohw,\@abi-omnipotent +.align 32 +ecp_nistz256_select_w5_nohw: +.cfi_startproc + _CET_ENDBR +___ +$code.=<<___ if ($win64); + lea -0x88(%rsp), %rax +.LSEH_begin_ecp_nistz256_select_w5_nohw: + .byte 0x48,0x8d,0x60,0xe0 #lea -0x20(%rax), %rsp + .byte 0x0f,0x29,0x70,0xe0 #movaps %xmm6, -0x20(%rax) + .byte 0x0f,0x29,0x78,0xf0 #movaps %xmm7, -0x10(%rax) + .byte 0x44,0x0f,0x29,0x00 #movaps %xmm8, 0(%rax) + .byte 0x44,0x0f,0x29,0x48,0x10 #movaps %xmm9, 0x10(%rax) + .byte 0x44,0x0f,0x29,0x50,0x20 #movaps %xmm10, 0x20(%rax) + .byte 0x44,0x0f,0x29,0x58,0x30 #movaps %xmm11, 0x30(%rax) + .byte 0x44,0x0f,0x29,0x60,0x40 #movaps %xmm12, 0x40(%rax) + .byte 0x44,0x0f,0x29,0x68,0x50 #movaps %xmm13, 0x50(%rax) + .byte 0x44,0x0f,0x29,0x70,0x60 #movaps %xmm14, 0x60(%rax) + .byte 0x44,0x0f,0x29,0x78,0x70 #movaps %xmm15, 0x70(%rax) +___ +$code.=<<___; + movdqa .LOne(%rip), $ONE + movd $index, $INDEX + + pxor $Ra, $Ra + pxor $Rb, $Rb + pxor $Rc, $Rc + pxor $Rd, $Rd + pxor $Re, $Re + pxor $Rf, $Rf + + movdqa $ONE, $M0 + pshufd \$0, $INDEX, $INDEX + + mov \$16, %rax +.Lselect_loop_sse_w5: + + movdqa $M0, $TMP0 + paddd $ONE, $M0 + pcmpeqd $INDEX, $TMP0 + + movdqa 16*0($in_t), $T0a + movdqa 16*1($in_t), $T0b + movdqa 16*2($in_t), $T0c + movdqa 16*3($in_t), $T0d + movdqa 16*4($in_t), $T0e + movdqa 16*5($in_t), $T0f + lea 16*6($in_t), $in_t + + pand $TMP0, $T0a + pand $TMP0, $T0b + por $T0a, $Ra + pand $TMP0, $T0c + por $T0b, $Rb + pand $TMP0, $T0d + por $T0c, $Rc + pand $TMP0, $T0e + por $T0d, $Rd + pand $TMP0, $T0f + por $T0e, $Re + por $T0f, $Rf + + dec %rax + jnz .Lselect_loop_sse_w5 + + movdqu $Ra, 16*0($val) + movdqu $Rb, 16*1($val) + movdqu $Rc, 16*2($val) + movdqu $Rd, 16*3($val) + movdqu $Re, 16*4($val) + movdqu $Rf, 16*5($val) +___ +$code.=<<___ if ($win64); + movaps (%rsp), %xmm6 + movaps 0x10(%rsp), %xmm7 + movaps 0x20(%rsp), %xmm8 + movaps 0x30(%rsp), %xmm9 + movaps 0x40(%rsp), %xmm10 + movaps 0x50(%rsp), %xmm11 + movaps 0x60(%rsp), %xmm12 + movaps 0x70(%rsp), %xmm13 + movaps 0x80(%rsp), %xmm14 + movaps 0x90(%rsp), %xmm15 + lea 0xa8(%rsp), %rsp +___ +$code.=<<___; + ret +.cfi_endproc +.LSEH_end_ecp_nistz256_select_w5_nohw: +.size ecp_nistz256_select_w5_nohw,.-ecp_nistz256_select_w5_nohw + +################################################################################ +# void ecp_nistz256_select_w7_nohw(uint64_t *val, uint64_t *in_t, int index); +.globl ecp_nistz256_select_w7_nohw +.type ecp_nistz256_select_w7_nohw,\@abi-omnipotent +.align 32 +ecp_nistz256_select_w7_nohw: +.cfi_startproc + _CET_ENDBR +___ +$code.=<<___ if ($win64); + lea -0x88(%rsp), %rax +.LSEH_begin_ecp_nistz256_select_w7_nohw: + .byte 0x48,0x8d,0x60,0xe0 #lea -0x20(%rax), %rsp + .byte 0x0f,0x29,0x70,0xe0 #movaps %xmm6, -0x20(%rax) + .byte 0x0f,0x29,0x78,0xf0 #movaps %xmm7, -0x10(%rax) + .byte 0x44,0x0f,0x29,0x00 #movaps %xmm8, 0(%rax) + .byte 0x44,0x0f,0x29,0x48,0x10 #movaps %xmm9, 0x10(%rax) + .byte 0x44,0x0f,0x29,0x50,0x20 #movaps %xmm10, 0x20(%rax) + .byte 0x44,0x0f,0x29,0x58,0x30 #movaps %xmm11, 0x30(%rax) + .byte 0x44,0x0f,0x29,0x60,0x40 #movaps %xmm12, 0x40(%rax) + .byte 0x44,0x0f,0x29,0x68,0x50 #movaps %xmm13, 0x50(%rax) + .byte 0x44,0x0f,0x29,0x70,0x60 #movaps %xmm14, 0x60(%rax) + .byte 0x44,0x0f,0x29,0x78,0x70 #movaps %xmm15, 0x70(%rax) +___ +$code.=<<___; + movdqa .LOne(%rip), $M0 + movd $index, $INDEX + + pxor $Ra, $Ra + pxor $Rb, $Rb + pxor $Rc, $Rc + pxor $Rd, $Rd + + movdqa $M0, $ONE + pshufd \$0, $INDEX, $INDEX + mov \$64, %rax + +.Lselect_loop_sse_w7: + movdqa $M0, $TMP0 + paddd $ONE, $M0 + movdqa 16*0($in_t), $T0a + movdqa 16*1($in_t), $T0b + pcmpeqd $INDEX, $TMP0 + movdqa 16*2($in_t), $T0c + movdqa 16*3($in_t), $T0d + lea 16*4($in_t), $in_t + + pand $TMP0, $T0a + pand $TMP0, $T0b + por $T0a, $Ra + pand $TMP0, $T0c + por $T0b, $Rb + pand $TMP0, $T0d + por $T0c, $Rc + prefetcht0 255($in_t) + por $T0d, $Rd + + dec %rax + jnz .Lselect_loop_sse_w7 + + movdqu $Ra, 16*0($val) + movdqu $Rb, 16*1($val) + movdqu $Rc, 16*2($val) + movdqu $Rd, 16*3($val) +___ +$code.=<<___ if ($win64); + movaps (%rsp), %xmm6 + movaps 0x10(%rsp), %xmm7 + movaps 0x20(%rsp), %xmm8 + movaps 0x30(%rsp), %xmm9 + movaps 0x40(%rsp), %xmm10 + movaps 0x50(%rsp), %xmm11 + movaps 0x60(%rsp), %xmm12 + movaps 0x70(%rsp), %xmm13 + movaps 0x80(%rsp), %xmm14 + movaps 0x90(%rsp), %xmm15 + lea 0xa8(%rsp), %rsp +___ +$code.=<<___; + ret +.cfi_endproc +.LSEH_end_ecp_nistz256_select_w7_nohw: +.size ecp_nistz256_select_w7_nohw,.-ecp_nistz256_select_w7_nohw +___ +} +if ($avx>1) { +my ($val,$in_t,$index)=$win64?("%rcx","%rdx","%r8d"):("%rdi","%rsi","%edx"); +my ($TWO,$INDEX,$Ra,$Rb,$Rc)=map("%ymm$_",(0..4)); +my ($M0,$T0a,$T0b,$T0c,$TMP0)=map("%ymm$_",(5..9)); +my ($M1,$T1a,$T1b,$T1c,$TMP1)=map("%ymm$_",(10..14)); + +$code.=<<___; +################################################################################ +# void ecp_nistz256_select_w5_avx2(uint64_t *val, uint64_t *in_t, int index); +.globl ecp_nistz256_select_w5_avx2 +.type ecp_nistz256_select_w5_avx2,\@abi-omnipotent +.align 32 +ecp_nistz256_select_w5_avx2: +.cfi_startproc + _CET_ENDBR + vzeroupper +___ +$code.=<<___ if ($win64); + lea -0x88(%rsp), %rax + mov %rsp,%r11 +.LSEH_begin_ecp_nistz256_select_w5_avx2: + .byte 0x48,0x8d,0x60,0xe0 # lea -0x20(%rax), %rsp + .byte 0xc5,0xf8,0x29,0x70,0xe0 # vmovaps %xmm6, -0x20(%rax) + .byte 0xc5,0xf8,0x29,0x78,0xf0 # vmovaps %xmm7, -0x10(%rax) + .byte 0xc5,0x78,0x29,0x40,0x00 # vmovaps %xmm8, 8(%rax) + .byte 0xc5,0x78,0x29,0x48,0x10 # vmovaps %xmm9, 0x10(%rax) + .byte 0xc5,0x78,0x29,0x50,0x20 # vmovaps %xmm10, 0x20(%rax) + .byte 0xc5,0x78,0x29,0x58,0x30 # vmovaps %xmm11, 0x30(%rax) + .byte 0xc5,0x78,0x29,0x60,0x40 # vmovaps %xmm12, 0x40(%rax) + .byte 0xc5,0x78,0x29,0x68,0x50 # vmovaps %xmm13, 0x50(%rax) + .byte 0xc5,0x78,0x29,0x70,0x60 # vmovaps %xmm14, 0x60(%rax) + .byte 0xc5,0x78,0x29,0x78,0x70 # vmovaps %xmm15, 0x70(%rax) +___ +$code.=<<___; + vmovdqa .LTwo(%rip), $TWO + + vpxor $Ra, $Ra, $Ra + vpxor $Rb, $Rb, $Rb + vpxor $Rc, $Rc, $Rc + + vmovdqa .LOne(%rip), $M0 + vmovdqa .LTwo(%rip), $M1 + + vmovd $index, %xmm1 + vpermd $INDEX, $Ra, $INDEX + + mov \$8, %rax +.Lselect_loop_avx2_w5: + + vmovdqa 32*0($in_t), $T0a + vmovdqa 32*1($in_t), $T0b + vmovdqa 32*2($in_t), $T0c + + vmovdqa 32*3($in_t), $T1a + vmovdqa 32*4($in_t), $T1b + vmovdqa 32*5($in_t), $T1c + + vpcmpeqd $INDEX, $M0, $TMP0 + vpcmpeqd $INDEX, $M1, $TMP1 + + vpaddd $TWO, $M0, $M0 + vpaddd $TWO, $M1, $M1 + lea 32*6($in_t), $in_t + + vpand $TMP0, $T0a, $T0a + vpand $TMP0, $T0b, $T0b + vpand $TMP0, $T0c, $T0c + vpand $TMP1, $T1a, $T1a + vpand $TMP1, $T1b, $T1b + vpand $TMP1, $T1c, $T1c + + vpxor $T0a, $Ra, $Ra + vpxor $T0b, $Rb, $Rb + vpxor $T0c, $Rc, $Rc + vpxor $T1a, $Ra, $Ra + vpxor $T1b, $Rb, $Rb + vpxor $T1c, $Rc, $Rc + + dec %rax + jnz .Lselect_loop_avx2_w5 + + vmovdqu $Ra, 32*0($val) + vmovdqu $Rb, 32*1($val) + vmovdqu $Rc, 32*2($val) + vzeroupper +___ +$code.=<<___ if ($win64); + movaps (%rsp), %xmm6 + movaps 0x10(%rsp), %xmm7 + movaps 0x20(%rsp), %xmm8 + movaps 0x30(%rsp), %xmm9 + movaps 0x40(%rsp), %xmm10 + movaps 0x50(%rsp), %xmm11 + movaps 0x60(%rsp), %xmm12 + movaps 0x70(%rsp), %xmm13 + movaps 0x80(%rsp), %xmm14 + movaps 0x90(%rsp), %xmm15 + lea (%r11), %rsp +___ +$code.=<<___; + ret +.cfi_endproc +.LSEH_end_ecp_nistz256_select_w5_avx2: +.size ecp_nistz256_select_w5_avx2,.-ecp_nistz256_select_w5_avx2 +___ +} +if ($avx>1) { +my ($val,$in_t,$index)=$win64?("%rcx","%rdx","%r8d"):("%rdi","%rsi","%edx"); +my ($THREE,$INDEX,$Ra,$Rb)=map("%ymm$_",(0..3)); +my ($M0,$T0a,$T0b,$TMP0)=map("%ymm$_",(4..7)); +my ($M1,$T1a,$T1b,$TMP1)=map("%ymm$_",(8..11)); +my ($M2,$T2a,$T2b,$TMP2)=map("%ymm$_",(12..15)); + +$code.=<<___; + +################################################################################ +# void ecp_nistz256_select_w7_avx2(uint64_t *val, uint64_t *in_t, int index); +.globl ecp_nistz256_select_w7_avx2 +.type ecp_nistz256_select_w7_avx2,\@abi-omnipotent +.align 32 +ecp_nistz256_select_w7_avx2: +.cfi_startproc + _CET_ENDBR + vzeroupper +___ +$code.=<<___ if ($win64); + mov %rsp,%r11 + lea -0x88(%rsp), %rax +.LSEH_begin_ecp_nistz256_select_w7_avx2: + .byte 0x48,0x8d,0x60,0xe0 # lea -0x20(%rax), %rsp + .byte 0xc5,0xf8,0x29,0x70,0xe0 # vmovaps %xmm6, -0x20(%rax) + .byte 0xc5,0xf8,0x29,0x78,0xf0 # vmovaps %xmm7, -0x10(%rax) + .byte 0xc5,0x78,0x29,0x40,0x00 # vmovaps %xmm8, 8(%rax) + .byte 0xc5,0x78,0x29,0x48,0x10 # vmovaps %xmm9, 0x10(%rax) + .byte 0xc5,0x78,0x29,0x50,0x20 # vmovaps %xmm10, 0x20(%rax) + .byte 0xc5,0x78,0x29,0x58,0x30 # vmovaps %xmm11, 0x30(%rax) + .byte 0xc5,0x78,0x29,0x60,0x40 # vmovaps %xmm12, 0x40(%rax) + .byte 0xc5,0x78,0x29,0x68,0x50 # vmovaps %xmm13, 0x50(%rax) + .byte 0xc5,0x78,0x29,0x70,0x60 # vmovaps %xmm14, 0x60(%rax) + .byte 0xc5,0x78,0x29,0x78,0x70 # vmovaps %xmm15, 0x70(%rax) +___ +$code.=<<___; + vmovdqa .LThree(%rip), $THREE + + vpxor $Ra, $Ra, $Ra + vpxor $Rb, $Rb, $Rb + + vmovdqa .LOne(%rip), $M0 + vmovdqa .LTwo(%rip), $M1 + vmovdqa .LThree(%rip), $M2 + + vmovd $index, %xmm1 + vpermd $INDEX, $Ra, $INDEX + # Skip index = 0, because it is implicitly the point at infinity + + mov \$21, %rax +.Lselect_loop_avx2_w7: + + vmovdqa 32*0($in_t), $T0a + vmovdqa 32*1($in_t), $T0b + + vmovdqa 32*2($in_t), $T1a + vmovdqa 32*3($in_t), $T1b + + vmovdqa 32*4($in_t), $T2a + vmovdqa 32*5($in_t), $T2b + + vpcmpeqd $INDEX, $M0, $TMP0 + vpcmpeqd $INDEX, $M1, $TMP1 + vpcmpeqd $INDEX, $M2, $TMP2 + + vpaddd $THREE, $M0, $M0 + vpaddd $THREE, $M1, $M1 + vpaddd $THREE, $M2, $M2 + lea 32*6($in_t), $in_t + + vpand $TMP0, $T0a, $T0a + vpand $TMP0, $T0b, $T0b + vpand $TMP1, $T1a, $T1a + vpand $TMP1, $T1b, $T1b + vpand $TMP2, $T2a, $T2a + vpand $TMP2, $T2b, $T2b + + vpxor $T0a, $Ra, $Ra + vpxor $T0b, $Rb, $Rb + vpxor $T1a, $Ra, $Ra + vpxor $T1b, $Rb, $Rb + vpxor $T2a, $Ra, $Ra + vpxor $T2b, $Rb, $Rb + + dec %rax + jnz .Lselect_loop_avx2_w7 + + + vmovdqa 32*0($in_t), $T0a + vmovdqa 32*1($in_t), $T0b + + vpcmpeqd $INDEX, $M0, $TMP0 + + vpand $TMP0, $T0a, $T0a + vpand $TMP0, $T0b, $T0b + + vpxor $T0a, $Ra, $Ra + vpxor $T0b, $Rb, $Rb + + vmovdqu $Ra, 32*0($val) + vmovdqu $Rb, 32*1($val) + vzeroupper +___ +$code.=<<___ if ($win64); + movaps (%rsp), %xmm6 + movaps 0x10(%rsp), %xmm7 + movaps 0x20(%rsp), %xmm8 + movaps 0x30(%rsp), %xmm9 + movaps 0x40(%rsp), %xmm10 + movaps 0x50(%rsp), %xmm11 + movaps 0x60(%rsp), %xmm12 + movaps 0x70(%rsp), %xmm13 + movaps 0x80(%rsp), %xmm14 + movaps 0x90(%rsp), %xmm15 + lea (%r11), %rsp +___ +$code.=<<___; + ret +.cfi_endproc +.LSEH_end_ecp_nistz256_select_w7_avx2: +.size ecp_nistz256_select_w7_avx2,.-ecp_nistz256_select_w7_avx2 +___ +} +{{{ +######################################################################## +# This block implements higher level point_double, point_add and +# point_add_affine. The key to performance in this case is to allow +# out-of-order execution logic to overlap computations from next step +# with tail processing from current step. By using tailored calling +# sequence we minimize inter-step overhead to give processor better +# shot at overlapping operations... +# +# You will notice that input data is copied to stack. Trouble is that +# there are no registers to spare for holding original pointers and +# reloading them, pointers, would create undesired dependencies on +# effective addresses calculation paths. In other words it's too done +# to favour out-of-order execution logic. +# + +my ($r_ptr,$a_ptr,$b_org,$b_ptr)=("%rdi","%rsi","%rdx","%rbx"); +my ($acc0,$acc1,$acc2,$acc3,$acc4,$acc5,$acc6,$acc7)=map("%r$_",(8..15)); +my ($t0,$t1,$t2,$t3,$t4)=("%rax","%rbp","%rcx",$acc4,$acc4); +my ($poly1,$poly3)=($acc6,$acc7); + +sub load_for_mul () { +my ($a,$b,$src0) = @_; +my $bias = $src0 eq "%rax" ? 0 : -128; + +" mov $b, $src0 + lea $b, $b_ptr + mov 8*0+$a, $acc1 + mov 8*1+$a, $acc2 + lea $bias+$a, $a_ptr + mov 8*2+$a, $acc3 + mov 8*3+$a, $acc4" +} + +sub load_for_sqr () { +my ($a,$src0) = @_; +my $bias = $src0 eq "%rax" ? 0 : -128; + +" mov 8*0+$a, $src0 + mov 8*1+$a, $acc6 + lea $bias+$a, $a_ptr + mov 8*2+$a, $acc7 + mov 8*3+$a, $acc0" +} + + { +######################################################################## +# operate in 4-5-0-1 "name space" that matches multiplication output +# +my ($a0,$a1,$a2,$a3,$t3,$t4)=($acc4,$acc5,$acc0,$acc1,$acc2,$acc3); + +$code.=<<___; +.type __ecp_nistz256_add_toq,\@abi-omnipotent +.align 32 +__ecp_nistz256_add_toq: +.cfi_startproc + xor $t4,$t4 + add 8*0($b_ptr), $a0 + adc 8*1($b_ptr), $a1 + mov $a0, $t0 + adc 8*2($b_ptr), $a2 + adc 8*3($b_ptr), $a3 + mov $a1, $t1 + adc \$0, $t4 + + sub \$-1, $a0 + mov $a2, $t2 + sbb $poly1, $a1 + sbb \$0, $a2 + mov $a3, $t3 + sbb $poly3, $a3 + sbb \$0, $t4 + + cmovc $t0, $a0 + cmovc $t1, $a1 + mov $a0, 8*0($r_ptr) + cmovc $t2, $a2 + mov $a1, 8*1($r_ptr) + cmovc $t3, $a3 + mov $a2, 8*2($r_ptr) + mov $a3, 8*3($r_ptr) + + ret +.cfi_endproc +.size __ecp_nistz256_add_toq,.-__ecp_nistz256_add_toq + +.type __ecp_nistz256_sub_fromq,\@abi-omnipotent +.align 32 +__ecp_nistz256_sub_fromq: +.cfi_startproc + sub 8*0($b_ptr), $a0 + sbb 8*1($b_ptr), $a1 + mov $a0, $t0 + sbb 8*2($b_ptr), $a2 + sbb 8*3($b_ptr), $a3 + mov $a1, $t1 + sbb $t4, $t4 + + add \$-1, $a0 + mov $a2, $t2 + adc $poly1, $a1 + adc \$0, $a2 + mov $a3, $t3 + adc $poly3, $a3 + test $t4, $t4 + + cmovz $t0, $a0 + cmovz $t1, $a1 + mov $a0, 8*0($r_ptr) + cmovz $t2, $a2 + mov $a1, 8*1($r_ptr) + cmovz $t3, $a3 + mov $a2, 8*2($r_ptr) + mov $a3, 8*3($r_ptr) + + ret +.cfi_endproc +.size __ecp_nistz256_sub_fromq,.-__ecp_nistz256_sub_fromq + +.type __ecp_nistz256_subq,\@abi-omnipotent +.align 32 +__ecp_nistz256_subq: +.cfi_startproc + sub $a0, $t0 + sbb $a1, $t1 + mov $t0, $a0 + sbb $a2, $t2 + sbb $a3, $t3 + mov $t1, $a1 + sbb $t4, $t4 + + add \$-1, $t0 + mov $t2, $a2 + adc $poly1, $t1 + adc \$0, $t2 + mov $t3, $a3 + adc $poly3, $t3 + test $t4, $t4 + + cmovnz $t0, $a0 + cmovnz $t1, $a1 + cmovnz $t2, $a2 + cmovnz $t3, $a3 + + ret +.cfi_endproc +.size __ecp_nistz256_subq,.-__ecp_nistz256_subq + +.type __ecp_nistz256_mul_by_2q,\@abi-omnipotent +.align 32 +__ecp_nistz256_mul_by_2q: +.cfi_startproc + xor $t4, $t4 + add $a0, $a0 # a0:a3+a0:a3 + adc $a1, $a1 + mov $a0, $t0 + adc $a2, $a2 + adc $a3, $a3 + mov $a1, $t1 + adc \$0, $t4 + + sub \$-1, $a0 + mov $a2, $t2 + sbb $poly1, $a1 + sbb \$0, $a2 + mov $a3, $t3 + sbb $poly3, $a3 + sbb \$0, $t4 + + cmovc $t0, $a0 + cmovc $t1, $a1 + mov $a0, 8*0($r_ptr) + cmovc $t2, $a2 + mov $a1, 8*1($r_ptr) + cmovc $t3, $a3 + mov $a2, 8*2($r_ptr) + mov $a3, 8*3($r_ptr) + + ret +.cfi_endproc +.size __ecp_nistz256_mul_by_2q,.-__ecp_nistz256_mul_by_2q +___ + } +sub gen_double () { + my $x = shift; + my ($src0,$sfx,$bias); + my ($S,$M,$Zsqr,$in_x,$tmp0)=map(32*$_,(0..4)); + + if ($x ne "x") { + $src0 = "%rax"; + $sfx = "_nohw"; + $bias = 0; + } else { + $src0 = "%rdx"; + $sfx = "_adx"; + $bias = 128; + } +$code.=<<___; +.globl ecp_nistz256_point_double$sfx +.type ecp_nistz256_point_double$sfx,\@function,2 +.align 32 +ecp_nistz256_point_double$sfx: +.cfi_startproc + _CET_ENDBR + push %rbp +.cfi_push %rbp + push %rbx +.cfi_push %rbx + push %r12 +.cfi_push %r12 + push %r13 +.cfi_push %r13 + push %r14 +.cfi_push %r14 + push %r15 +.cfi_push %r15 + sub \$32*5+8, %rsp +.cfi_adjust_cfa_offset 32*5+8 +.Lpoint_double${x}_body: + +.Lpoint_double_shortcut$x: + movdqu 0x00($a_ptr), %xmm0 # copy *(P256_POINT *)$a_ptr.x + mov $a_ptr, $b_ptr # backup copy + movdqu 0x10($a_ptr), %xmm1 + mov 0x20+8*0($a_ptr), $acc4 # load in_y in "5-4-0-1" order + mov 0x20+8*1($a_ptr), $acc5 + mov 0x20+8*2($a_ptr), $acc0 + mov 0x20+8*3($a_ptr), $acc1 + mov .Lpoly+8*1(%rip), $poly1 + mov .Lpoly+8*3(%rip), $poly3 + movdqa %xmm0, $in_x(%rsp) + movdqa %xmm1, $in_x+0x10(%rsp) + lea 0x20($r_ptr), $acc2 + lea 0x40($r_ptr), $acc3 + movq $r_ptr, %xmm0 + movq $acc2, %xmm1 + movq $acc3, %xmm2 + + lea $S(%rsp), $r_ptr + call __ecp_nistz256_mul_by_2$x # p256_mul_by_2(S, in_y); + + mov 0x40+8*0($a_ptr), $src0 + mov 0x40+8*1($a_ptr), $acc6 + mov 0x40+8*2($a_ptr), $acc7 + mov 0x40+8*3($a_ptr), $acc0 + lea 0x40-$bias($a_ptr), $a_ptr + lea $Zsqr(%rsp), $r_ptr + call __ecp_nistz256_sqr_mont$x # p256_sqr_mont(Zsqr, in_z); + + `&load_for_sqr("$S(%rsp)", "$src0")` + lea $S(%rsp), $r_ptr + call __ecp_nistz256_sqr_mont$x # p256_sqr_mont(S, S); + + mov 0x20($b_ptr), $src0 # $b_ptr is still valid + mov 0x40+8*0($b_ptr), $acc1 + mov 0x40+8*1($b_ptr), $acc2 + mov 0x40+8*2($b_ptr), $acc3 + mov 0x40+8*3($b_ptr), $acc4 + lea 0x40-$bias($b_ptr), $a_ptr + lea 0x20($b_ptr), $b_ptr + movq %xmm2, $r_ptr + call __ecp_nistz256_mul_mont$x # p256_mul_mont(res_z, in_z, in_y); + call __ecp_nistz256_mul_by_2$x # p256_mul_by_2(res_z, res_z); + + mov $in_x+8*0(%rsp), $acc4 # "5-4-0-1" order + mov $in_x+8*1(%rsp), $acc5 + lea $Zsqr(%rsp), $b_ptr + mov $in_x+8*2(%rsp), $acc0 + mov $in_x+8*3(%rsp), $acc1 + lea $M(%rsp), $r_ptr + call __ecp_nistz256_add_to$x # p256_add(M, in_x, Zsqr); + + mov $in_x+8*0(%rsp), $acc4 # "5-4-0-1" order + mov $in_x+8*1(%rsp), $acc5 + lea $Zsqr(%rsp), $b_ptr + mov $in_x+8*2(%rsp), $acc0 + mov $in_x+8*3(%rsp), $acc1 + lea $Zsqr(%rsp), $r_ptr + call __ecp_nistz256_sub_from$x # p256_sub(Zsqr, in_x, Zsqr); + + `&load_for_sqr("$S(%rsp)", "$src0")` + movq %xmm1, $r_ptr + call __ecp_nistz256_sqr_mont$x # p256_sqr_mont(res_y, S); +___ +{ +######## ecp_nistz256_div_by_2(res_y, res_y); ########################## +# operate in 4-5-6-7 "name space" that matches squaring output +# +my ($poly1,$poly3)=($a_ptr,$t1); +my ($a0,$a1,$a2,$a3,$t3,$t4,$t1)=($acc4,$acc5,$acc6,$acc7,$acc0,$acc1,$acc2); + +$code.=<<___; + xor $t4, $t4 + mov $a0, $t0 + add \$-1, $a0 + mov $a1, $t1 + adc $poly1, $a1 + mov $a2, $t2 + adc \$0, $a2 + mov $a3, $t3 + adc $poly3, $a3 + adc \$0, $t4 + xor $a_ptr, $a_ptr # borrow $a_ptr + test \$1, $t0 + + cmovz $t0, $a0 + cmovz $t1, $a1 + cmovz $t2, $a2 + cmovz $t3, $a3 + cmovz $a_ptr, $t4 + + mov $a1, $t0 # a0:a3>>1 + shr \$1, $a0 + shl \$63, $t0 + mov $a2, $t1 + shr \$1, $a1 + or $t0, $a0 + shl \$63, $t1 + mov $a3, $t2 + shr \$1, $a2 + or $t1, $a1 + shl \$63, $t2 + mov $a0, 8*0($r_ptr) + shr \$1, $a3 + mov $a1, 8*1($r_ptr) + shl \$63, $t4 + or $t2, $a2 + or $t4, $a3 + mov $a2, 8*2($r_ptr) + mov $a3, 8*3($r_ptr) +___ +} +$code.=<<___; + `&load_for_mul("$M(%rsp)", "$Zsqr(%rsp)", "$src0")` + lea $M(%rsp), $r_ptr + call __ecp_nistz256_mul_mont$x # p256_mul_mont(M, M, Zsqr); + + lea $tmp0(%rsp), $r_ptr + call __ecp_nistz256_mul_by_2$x + + lea $M(%rsp), $b_ptr + lea $M(%rsp), $r_ptr + call __ecp_nistz256_add_to$x # p256_mul_by_3(M, M); + + `&load_for_mul("$S(%rsp)", "$in_x(%rsp)", "$src0")` + lea $S(%rsp), $r_ptr + call __ecp_nistz256_mul_mont$x # p256_mul_mont(S, S, in_x); + + lea $tmp0(%rsp), $r_ptr + call __ecp_nistz256_mul_by_2$x # p256_mul_by_2(tmp0, S); + + `&load_for_sqr("$M(%rsp)", "$src0")` + movq %xmm0, $r_ptr + call __ecp_nistz256_sqr_mont$x # p256_sqr_mont(res_x, M); + + lea $tmp0(%rsp), $b_ptr + mov $acc6, $acc0 # harmonize sqr output and sub input + mov $acc7, $acc1 + mov $a_ptr, $poly1 + mov $t1, $poly3 + call __ecp_nistz256_sub_from$x # p256_sub(res_x, res_x, tmp0); + + mov $S+8*0(%rsp), $t0 + mov $S+8*1(%rsp), $t1 + mov $S+8*2(%rsp), $t2 + mov $S+8*3(%rsp), $acc2 # "4-5-0-1" order + lea $S(%rsp), $r_ptr + call __ecp_nistz256_sub$x # p256_sub(S, S, res_x); + + mov $M(%rsp), $src0 + lea $M(%rsp), $b_ptr + mov $acc4, $acc6 # harmonize sub output and mul input + xor %ecx, %ecx + mov $acc4, $S+8*0(%rsp) # have to save:-( + mov $acc5, $acc2 + mov $acc5, $S+8*1(%rsp) + cmovz $acc0, $acc3 + mov $acc0, $S+8*2(%rsp) + lea $S-$bias(%rsp), $a_ptr + cmovz $acc1, $acc4 + mov $acc1, $S+8*3(%rsp) + mov $acc6, $acc1 + lea $S(%rsp), $r_ptr + call __ecp_nistz256_mul_mont$x # p256_mul_mont(S, S, M); + + movq %xmm1, $b_ptr + movq %xmm1, $r_ptr + call __ecp_nistz256_sub_from$x # p256_sub(res_y, S, res_y); + + lea 32*5+56(%rsp), %rsi +.cfi_def_cfa %rsi,8 + mov -48(%rsi),%r15 +.cfi_restore %r15 + mov -40(%rsi),%r14 +.cfi_restore %r14 + mov -32(%rsi),%r13 +.cfi_restore %r13 + mov -24(%rsi),%r12 +.cfi_restore %r12 + mov -16(%rsi),%rbx +.cfi_restore %rbx + mov -8(%rsi),%rbp +.cfi_restore %rbp + lea (%rsi),%rsp +.cfi_def_cfa_register %rsp +.Lpoint_double${x}_epilogue: + ret +.cfi_endproc +.size ecp_nistz256_point_double$sfx,.-ecp_nistz256_point_double$sfx +___ +} +&gen_double("q"); + +sub gen_add () { + my $x = shift; + my ($src0,$sfx,$bias); + my ($H,$Hsqr,$R,$Rsqr,$Hcub, + $U1,$U2,$S1,$S2, + $res_x,$res_y,$res_z, + $in1_x,$in1_y,$in1_z, + $in2_x,$in2_y,$in2_z)=map(32*$_,(0..17)); + my ($Z1sqr, $Z2sqr) = ($Hsqr, $Rsqr); + + if ($x ne "x") { + $src0 = "%rax"; + $sfx = "_nohw"; + $bias = 0; + } else { + $src0 = "%rdx"; + $sfx = "_adx"; + $bias = 128; + } +$code.=<<___; +.globl ecp_nistz256_point_add$sfx +.type ecp_nistz256_point_add$sfx,\@function,3 +.align 32 +ecp_nistz256_point_add$sfx: +.cfi_startproc + _CET_ENDBR + push %rbp +.cfi_push %rbp + push %rbx +.cfi_push %rbx + push %r12 +.cfi_push %r12 + push %r13 +.cfi_push %r13 + push %r14 +.cfi_push %r14 + push %r15 +.cfi_push %r15 + sub \$32*18+8, %rsp +.cfi_adjust_cfa_offset 32*18+8 +.Lpoint_add${x}_body: + + movdqu 0x00($a_ptr), %xmm0 # copy *(P256_POINT *)$a_ptr + movdqu 0x10($a_ptr), %xmm1 + movdqu 0x20($a_ptr), %xmm2 + movdqu 0x30($a_ptr), %xmm3 + movdqu 0x40($a_ptr), %xmm4 + movdqu 0x50($a_ptr), %xmm5 + mov $a_ptr, $b_ptr # reassign + mov $b_org, $a_ptr # reassign + movdqa %xmm0, $in1_x(%rsp) + movdqa %xmm1, $in1_x+0x10(%rsp) + movdqa %xmm2, $in1_y(%rsp) + movdqa %xmm3, $in1_y+0x10(%rsp) + movdqa %xmm4, $in1_z(%rsp) + movdqa %xmm5, $in1_z+0x10(%rsp) + por %xmm4, %xmm5 + + movdqu 0x00($a_ptr), %xmm0 # copy *(P256_POINT *)$b_ptr + pshufd \$0xb1, %xmm5, %xmm3 + movdqu 0x10($a_ptr), %xmm1 + movdqu 0x20($a_ptr), %xmm2 + por %xmm3, %xmm5 + movdqu 0x30($a_ptr), %xmm3 + mov 0x40+8*0($a_ptr), $src0 # load original in2_z + mov 0x40+8*1($a_ptr), $acc6 + mov 0x40+8*2($a_ptr), $acc7 + mov 0x40+8*3($a_ptr), $acc0 + movdqa %xmm0, $in2_x(%rsp) + pshufd \$0x1e, %xmm5, %xmm4 + movdqa %xmm1, $in2_x+0x10(%rsp) + movdqu 0x40($a_ptr),%xmm0 # in2_z again + movdqu 0x50($a_ptr),%xmm1 + movdqa %xmm2, $in2_y(%rsp) + movdqa %xmm3, $in2_y+0x10(%rsp) + por %xmm4, %xmm5 + pxor %xmm4, %xmm4 + por %xmm0, %xmm1 + movq $r_ptr, %xmm0 # save $r_ptr + + lea 0x40-$bias($a_ptr), $a_ptr # $a_ptr is still valid + mov $src0, $in2_z+8*0(%rsp) # make in2_z copy + mov $acc6, $in2_z+8*1(%rsp) + mov $acc7, $in2_z+8*2(%rsp) + mov $acc0, $in2_z+8*3(%rsp) + lea $Z2sqr(%rsp), $r_ptr # Z2^2 + call __ecp_nistz256_sqr_mont$x # p256_sqr_mont(Z2sqr, in2_z); + + pcmpeqd %xmm4, %xmm5 + pshufd \$0xb1, %xmm1, %xmm4 + por %xmm1, %xmm4 + pshufd \$0, %xmm5, %xmm5 # in1infty + pshufd \$0x1e, %xmm4, %xmm3 + por %xmm3, %xmm4 + pxor %xmm3, %xmm3 + pcmpeqd %xmm3, %xmm4 + pshufd \$0, %xmm4, %xmm4 # in2infty + mov 0x40+8*0($b_ptr), $src0 # load original in1_z + mov 0x40+8*1($b_ptr), $acc6 + mov 0x40+8*2($b_ptr), $acc7 + mov 0x40+8*3($b_ptr), $acc0 + movq $b_ptr, %xmm1 + + lea 0x40-$bias($b_ptr), $a_ptr + lea $Z1sqr(%rsp), $r_ptr # Z1^2 + call __ecp_nistz256_sqr_mont$x # p256_sqr_mont(Z1sqr, in1_z); + + `&load_for_mul("$Z2sqr(%rsp)", "$in2_z(%rsp)", "$src0")` + lea $S1(%rsp), $r_ptr # S1 = Z2^3 + call __ecp_nistz256_mul_mont$x # p256_mul_mont(S1, Z2sqr, in2_z); + + `&load_for_mul("$Z1sqr(%rsp)", "$in1_z(%rsp)", "$src0")` + lea $S2(%rsp), $r_ptr # S2 = Z1^3 + call __ecp_nistz256_mul_mont$x # p256_mul_mont(S2, Z1sqr, in1_z); + + `&load_for_mul("$S1(%rsp)", "$in1_y(%rsp)", "$src0")` + lea $S1(%rsp), $r_ptr # S1 = Y1*Z2^3 + call __ecp_nistz256_mul_mont$x # p256_mul_mont(S1, S1, in1_y); + + `&load_for_mul("$S2(%rsp)", "$in2_y(%rsp)", "$src0")` + lea $S2(%rsp), $r_ptr # S2 = Y2*Z1^3 + call __ecp_nistz256_mul_mont$x # p256_mul_mont(S2, S2, in2_y); + + lea $S1(%rsp), $b_ptr + lea $R(%rsp), $r_ptr # R = S2 - S1 + call __ecp_nistz256_sub_from$x # p256_sub(R, S2, S1); + + or $acc5, $acc4 # see if result is zero + movdqa %xmm4, %xmm2 + or $acc0, $acc4 + or $acc1, $acc4 + por %xmm5, %xmm2 # in1infty || in2infty + movq $acc4, %xmm3 + + `&load_for_mul("$Z2sqr(%rsp)", "$in1_x(%rsp)", "$src0")` + lea $U1(%rsp), $r_ptr # U1 = X1*Z2^2 + call __ecp_nistz256_mul_mont$x # p256_mul_mont(U1, in1_x, Z2sqr); + + `&load_for_mul("$Z1sqr(%rsp)", "$in2_x(%rsp)", "$src0")` + lea $U2(%rsp), $r_ptr # U2 = X2*Z1^2 + call __ecp_nistz256_mul_mont$x # p256_mul_mont(U2, in2_x, Z1sqr); + + lea $U1(%rsp), $b_ptr + lea $H(%rsp), $r_ptr # H = U2 - U1 + call __ecp_nistz256_sub_from$x # p256_sub(H, U2, U1); + + or $acc5, $acc4 # see if result is zero + or $acc0, $acc4 + or $acc1, $acc4 # !is_equal(U1, U2) + + movq %xmm2, $acc0 + movq %xmm3, $acc1 + or $acc0, $acc4 + .byte 0x3e # predict taken + jnz .Ladd_proceed$x # !is_equal(U1, U2) || in1infty || in2infty + + # We now know A = B or A = -B and neither is infinity. Compare the + # y-coordinates via S1 and S2. + test $acc1, $acc1 + jz .Ladd_double$x # is_equal(S1, S2) + + # A = -B, so the result is infinity. + # + # TODO(davidben): Does .Ladd_proceed handle this case? It seems to, in + # which case we should eliminate this special-case and simplify the + # timing analysis. + movq %xmm0, $r_ptr # restore $r_ptr + pxor %xmm0, %xmm0 + movdqu %xmm0, 0x00($r_ptr) + movdqu %xmm0, 0x10($r_ptr) + movdqu %xmm0, 0x20($r_ptr) + movdqu %xmm0, 0x30($r_ptr) + movdqu %xmm0, 0x40($r_ptr) + movdqu %xmm0, 0x50($r_ptr) + jmp .Ladd_done$x + +.align 32 +.Ladd_double$x: + movq %xmm1, $a_ptr # restore $a_ptr + movq %xmm0, $r_ptr # restore $r_ptr + add \$`32*(18-5)`, %rsp # difference in frame sizes +.cfi_adjust_cfa_offset `-32*(18-5)` + jmp .Lpoint_double_shortcut$x +.cfi_adjust_cfa_offset `32*(18-5)` + +.align 32 +.Ladd_proceed$x: + `&load_for_sqr("$R(%rsp)", "$src0")` + lea $Rsqr(%rsp), $r_ptr # R^2 + call __ecp_nistz256_sqr_mont$x # p256_sqr_mont(Rsqr, R); + + `&load_for_mul("$H(%rsp)", "$in1_z(%rsp)", "$src0")` + lea $res_z(%rsp), $r_ptr # Z3 = H*Z1*Z2 + call __ecp_nistz256_mul_mont$x # p256_mul_mont(res_z, H, in1_z); + + `&load_for_sqr("$H(%rsp)", "$src0")` + lea $Hsqr(%rsp), $r_ptr # H^2 + call __ecp_nistz256_sqr_mont$x # p256_sqr_mont(Hsqr, H); + + `&load_for_mul("$res_z(%rsp)", "$in2_z(%rsp)", "$src0")` + lea $res_z(%rsp), $r_ptr # Z3 = H*Z1*Z2 + call __ecp_nistz256_mul_mont$x # p256_mul_mont(res_z, res_z, in2_z); + + `&load_for_mul("$Hsqr(%rsp)", "$H(%rsp)", "$src0")` + lea $Hcub(%rsp), $r_ptr # H^3 + call __ecp_nistz256_mul_mont$x # p256_mul_mont(Hcub, Hsqr, H); + + `&load_for_mul("$Hsqr(%rsp)", "$U1(%rsp)", "$src0")` + lea $U2(%rsp), $r_ptr # U1*H^2 + call __ecp_nistz256_mul_mont$x # p256_mul_mont(U2, U1, Hsqr); +___ +{ +####################################################################### +# operate in 4-5-0-1 "name space" that matches multiplication output +# +my ($acc0,$acc1,$acc2,$acc3,$t3,$t4)=($acc4,$acc5,$acc0,$acc1,$acc2,$acc3); +my ($poly1, $poly3)=($acc6,$acc7); + +$code.=<<___; + #lea $U2(%rsp), $a_ptr + #lea $Hsqr(%rsp), $r_ptr # 2*U1*H^2 + #call __ecp_nistz256_mul_by_2 # ecp_nistz256_mul_by_2(Hsqr, U2); + + xor $t4, $t4 + add $acc0, $acc0 # a0:a3+a0:a3 + lea $Rsqr(%rsp), $a_ptr + adc $acc1, $acc1 + mov $acc0, $t0 + adc $acc2, $acc2 + adc $acc3, $acc3 + mov $acc1, $t1 + adc \$0, $t4 + + sub \$-1, $acc0 + mov $acc2, $t2 + sbb $poly1, $acc1 + sbb \$0, $acc2 + mov $acc3, $t3 + sbb $poly3, $acc3 + sbb \$0, $t4 + + cmovc $t0, $acc0 + mov 8*0($a_ptr), $t0 + cmovc $t1, $acc1 + mov 8*1($a_ptr), $t1 + cmovc $t2, $acc2 + mov 8*2($a_ptr), $t2 + cmovc $t3, $acc3 + mov 8*3($a_ptr), $t3 + + call __ecp_nistz256_sub$x # p256_sub(res_x, Rsqr, Hsqr); + + lea $Hcub(%rsp), $b_ptr + lea $res_x(%rsp), $r_ptr + call __ecp_nistz256_sub_from$x # p256_sub(res_x, res_x, Hcub); + + mov $U2+8*0(%rsp), $t0 + mov $U2+8*1(%rsp), $t1 + mov $U2+8*2(%rsp), $t2 + mov $U2+8*3(%rsp), $t3 + lea $res_y(%rsp), $r_ptr + + call __ecp_nistz256_sub$x # p256_sub(res_y, U2, res_x); + + mov $acc0, 8*0($r_ptr) # save the result, as + mov $acc1, 8*1($r_ptr) # __ecp_nistz256_sub doesn't + mov $acc2, 8*2($r_ptr) + mov $acc3, 8*3($r_ptr) +___ +} +$code.=<<___; + `&load_for_mul("$S1(%rsp)", "$Hcub(%rsp)", "$src0")` + lea $S2(%rsp), $r_ptr + call __ecp_nistz256_mul_mont$x # p256_mul_mont(S2, S1, Hcub); + + `&load_for_mul("$R(%rsp)", "$res_y(%rsp)", "$src0")` + lea $res_y(%rsp), $r_ptr + call __ecp_nistz256_mul_mont$x # p256_mul_mont(res_y, R, res_y); + + lea $S2(%rsp), $b_ptr + lea $res_y(%rsp), $r_ptr + call __ecp_nistz256_sub_from$x # p256_sub(res_y, res_y, S2); + + movq %xmm0, $r_ptr # restore $r_ptr + + movdqa %xmm5, %xmm0 # copy_conditional(res_z, in2_z, in1infty); + movdqa %xmm5, %xmm1 + pandn $res_z(%rsp), %xmm0 + movdqa %xmm5, %xmm2 + pandn $res_z+0x10(%rsp), %xmm1 + movdqa %xmm5, %xmm3 + pand $in2_z(%rsp), %xmm2 + pand $in2_z+0x10(%rsp), %xmm3 + por %xmm0, %xmm2 + por %xmm1, %xmm3 + + movdqa %xmm4, %xmm0 # copy_conditional(res_z, in1_z, in2infty); + movdqa %xmm4, %xmm1 + pandn %xmm2, %xmm0 + movdqa %xmm4, %xmm2 + pandn %xmm3, %xmm1 + movdqa %xmm4, %xmm3 + pand $in1_z(%rsp), %xmm2 + pand $in1_z+0x10(%rsp), %xmm3 + por %xmm0, %xmm2 + por %xmm1, %xmm3 + movdqu %xmm2, 0x40($r_ptr) + movdqu %xmm3, 0x50($r_ptr) + + movdqa %xmm5, %xmm0 # copy_conditional(res_x, in2_x, in1infty); + movdqa %xmm5, %xmm1 + pandn $res_x(%rsp), %xmm0 + movdqa %xmm5, %xmm2 + pandn $res_x+0x10(%rsp), %xmm1 + movdqa %xmm5, %xmm3 + pand $in2_x(%rsp), %xmm2 + pand $in2_x+0x10(%rsp), %xmm3 + por %xmm0, %xmm2 + por %xmm1, %xmm3 + + movdqa %xmm4, %xmm0 # copy_conditional(res_x, in1_x, in2infty); + movdqa %xmm4, %xmm1 + pandn %xmm2, %xmm0 + movdqa %xmm4, %xmm2 + pandn %xmm3, %xmm1 + movdqa %xmm4, %xmm3 + pand $in1_x(%rsp), %xmm2 + pand $in1_x+0x10(%rsp), %xmm3 + por %xmm0, %xmm2 + por %xmm1, %xmm3 + movdqu %xmm2, 0x00($r_ptr) + movdqu %xmm3, 0x10($r_ptr) + + movdqa %xmm5, %xmm0 # copy_conditional(res_y, in2_y, in1infty); + movdqa %xmm5, %xmm1 + pandn $res_y(%rsp), %xmm0 + movdqa %xmm5, %xmm2 + pandn $res_y+0x10(%rsp), %xmm1 + movdqa %xmm5, %xmm3 + pand $in2_y(%rsp), %xmm2 + pand $in2_y+0x10(%rsp), %xmm3 + por %xmm0, %xmm2 + por %xmm1, %xmm3 + + movdqa %xmm4, %xmm0 # copy_conditional(res_y, in1_y, in2infty); + movdqa %xmm4, %xmm1 + pandn %xmm2, %xmm0 + movdqa %xmm4, %xmm2 + pandn %xmm3, %xmm1 + movdqa %xmm4, %xmm3 + pand $in1_y(%rsp), %xmm2 + pand $in1_y+0x10(%rsp), %xmm3 + por %xmm0, %xmm2 + por %xmm1, %xmm3 + movdqu %xmm2, 0x20($r_ptr) + movdqu %xmm3, 0x30($r_ptr) + +.Ladd_done$x: + lea 32*18+56(%rsp), %rsi +.cfi_def_cfa %rsi,8 + mov -48(%rsi),%r15 +.cfi_restore %r15 + mov -40(%rsi),%r14 +.cfi_restore %r14 + mov -32(%rsi),%r13 +.cfi_restore %r13 + mov -24(%rsi),%r12 +.cfi_restore %r12 + mov -16(%rsi),%rbx +.cfi_restore %rbx + mov -8(%rsi),%rbp +.cfi_restore %rbp + lea (%rsi),%rsp +.cfi_def_cfa_register %rsp +.Lpoint_add${x}_epilogue: + ret +.cfi_endproc +.size ecp_nistz256_point_add$sfx,.-ecp_nistz256_point_add$sfx +___ +} +&gen_add("q"); + +sub gen_add_affine () { + my $x = shift; + my ($src0,$sfx,$bias); + my ($U2,$S2,$H,$R,$Hsqr,$Hcub,$Rsqr, + $res_x,$res_y,$res_z, + $in1_x,$in1_y,$in1_z, + $in2_x,$in2_y)=map(32*$_,(0..14)); + my $Z1sqr = $S2; + + if ($x ne "x") { + $src0 = "%rax"; + $sfx = "_nohw"; + $bias = 0; + } else { + $src0 = "%rdx"; + $sfx = "_adx"; + $bias = 128; + } +$code.=<<___; +.globl ecp_nistz256_point_add_affine$sfx +.type ecp_nistz256_point_add_affine$sfx,\@function,3 +.align 32 +ecp_nistz256_point_add_affine$sfx: +.cfi_startproc + _CET_ENDBR + push %rbp +.cfi_push %rbp + push %rbx +.cfi_push %rbx + push %r12 +.cfi_push %r12 + push %r13 +.cfi_push %r13 + push %r14 +.cfi_push %r14 + push %r15 +.cfi_push %r15 + sub \$32*15+8, %rsp +.cfi_adjust_cfa_offset 32*15+8 +.Ladd_affine${x}_body: + + movdqu 0x00($a_ptr), %xmm0 # copy *(P256_POINT *)$a_ptr + mov $b_org, $b_ptr # reassign + movdqu 0x10($a_ptr), %xmm1 + movdqu 0x20($a_ptr), %xmm2 + movdqu 0x30($a_ptr), %xmm3 + movdqu 0x40($a_ptr), %xmm4 + movdqu 0x50($a_ptr), %xmm5 + mov 0x40+8*0($a_ptr), $src0 # load original in1_z + mov 0x40+8*1($a_ptr), $acc6 + mov 0x40+8*2($a_ptr), $acc7 + mov 0x40+8*3($a_ptr), $acc0 + movdqa %xmm0, $in1_x(%rsp) + movdqa %xmm1, $in1_x+0x10(%rsp) + movdqa %xmm2, $in1_y(%rsp) + movdqa %xmm3, $in1_y+0x10(%rsp) + movdqa %xmm4, $in1_z(%rsp) + movdqa %xmm5, $in1_z+0x10(%rsp) + por %xmm4, %xmm5 + + movdqu 0x00($b_ptr), %xmm0 # copy *(P256_POINT_AFFINE *)$b_ptr + pshufd \$0xb1, %xmm5, %xmm3 + movdqu 0x10($b_ptr), %xmm1 + movdqu 0x20($b_ptr), %xmm2 + por %xmm3, %xmm5 + movdqu 0x30($b_ptr), %xmm3 + movdqa %xmm0, $in2_x(%rsp) + pshufd \$0x1e, %xmm5, %xmm4 + movdqa %xmm1, $in2_x+0x10(%rsp) + por %xmm0, %xmm1 + movq $r_ptr, %xmm0 # save $r_ptr + movdqa %xmm2, $in2_y(%rsp) + movdqa %xmm3, $in2_y+0x10(%rsp) + por %xmm2, %xmm3 + por %xmm4, %xmm5 + pxor %xmm4, %xmm4 + por %xmm1, %xmm3 + + lea 0x40-$bias($a_ptr), $a_ptr # $a_ptr is still valid + lea $Z1sqr(%rsp), $r_ptr # Z1^2 + call __ecp_nistz256_sqr_mont$x # p256_sqr_mont(Z1sqr, in1_z); + + pcmpeqd %xmm4, %xmm5 + pshufd \$0xb1, %xmm3, %xmm4 + mov 0x00($b_ptr), $src0 # $b_ptr is still valid + #lea 0x00($b_ptr), $b_ptr + mov $acc4, $acc1 # harmonize sqr output and mul input + por %xmm3, %xmm4 + pshufd \$0, %xmm5, %xmm5 # in1infty + pshufd \$0x1e, %xmm4, %xmm3 + mov $acc5, $acc2 + por %xmm3, %xmm4 + pxor %xmm3, %xmm3 + mov $acc6, $acc3 + pcmpeqd %xmm3, %xmm4 + pshufd \$0, %xmm4, %xmm4 # in2infty + + lea $Z1sqr-$bias(%rsp), $a_ptr + mov $acc7, $acc4 + lea $U2(%rsp), $r_ptr # U2 = X2*Z1^2 + call __ecp_nistz256_mul_mont$x # p256_mul_mont(U2, Z1sqr, in2_x); + + lea $in1_x(%rsp), $b_ptr + lea $H(%rsp), $r_ptr # H = U2 - U1 + call __ecp_nistz256_sub_from$x # p256_sub(H, U2, in1_x); + + `&load_for_mul("$Z1sqr(%rsp)", "$in1_z(%rsp)", "$src0")` + lea $S2(%rsp), $r_ptr # S2 = Z1^3 + call __ecp_nistz256_mul_mont$x # p256_mul_mont(S2, Z1sqr, in1_z); + + `&load_for_mul("$H(%rsp)", "$in1_z(%rsp)", "$src0")` + lea $res_z(%rsp), $r_ptr # Z3 = H*Z1*Z2 + call __ecp_nistz256_mul_mont$x # p256_mul_mont(res_z, H, in1_z); + + `&load_for_mul("$S2(%rsp)", "$in2_y(%rsp)", "$src0")` + lea $S2(%rsp), $r_ptr # S2 = Y2*Z1^3 + call __ecp_nistz256_mul_mont$x # p256_mul_mont(S2, S2, in2_y); + + lea $in1_y(%rsp), $b_ptr + lea $R(%rsp), $r_ptr # R = S2 - S1 + call __ecp_nistz256_sub_from$x # p256_sub(R, S2, in1_y); + + `&load_for_sqr("$H(%rsp)", "$src0")` + lea $Hsqr(%rsp), $r_ptr # H^2 + call __ecp_nistz256_sqr_mont$x # p256_sqr_mont(Hsqr, H); + + `&load_for_sqr("$R(%rsp)", "$src0")` + lea $Rsqr(%rsp), $r_ptr # R^2 + call __ecp_nistz256_sqr_mont$x # p256_sqr_mont(Rsqr, R); + + `&load_for_mul("$H(%rsp)", "$Hsqr(%rsp)", "$src0")` + lea $Hcub(%rsp), $r_ptr # H^3 + call __ecp_nistz256_mul_mont$x # p256_mul_mont(Hcub, Hsqr, H); + + `&load_for_mul("$Hsqr(%rsp)", "$in1_x(%rsp)", "$src0")` + lea $U2(%rsp), $r_ptr # U1*H^2 + call __ecp_nistz256_mul_mont$x # p256_mul_mont(U2, in1_x, Hsqr); +___ +{ +####################################################################### +# operate in 4-5-0-1 "name space" that matches multiplication output +# +my ($acc0,$acc1,$acc2,$acc3,$t3,$t4)=($acc4,$acc5,$acc0,$acc1,$acc2,$acc3); +my ($poly1, $poly3)=($acc6,$acc7); + +$code.=<<___; + #lea $U2(%rsp), $a_ptr + #lea $Hsqr(%rsp), $r_ptr # 2*U1*H^2 + #call __ecp_nistz256_mul_by_2 # ecp_nistz256_mul_by_2(Hsqr, U2); + + xor $t4, $t4 + add $acc0, $acc0 # a0:a3+a0:a3 + lea $Rsqr(%rsp), $a_ptr + adc $acc1, $acc1 + mov $acc0, $t0 + adc $acc2, $acc2 + adc $acc3, $acc3 + mov $acc1, $t1 + adc \$0, $t4 + + sub \$-1, $acc0 + mov $acc2, $t2 + sbb $poly1, $acc1 + sbb \$0, $acc2 + mov $acc3, $t3 + sbb $poly3, $acc3 + sbb \$0, $t4 + + cmovc $t0, $acc0 + mov 8*0($a_ptr), $t0 + cmovc $t1, $acc1 + mov 8*1($a_ptr), $t1 + cmovc $t2, $acc2 + mov 8*2($a_ptr), $t2 + cmovc $t3, $acc3 + mov 8*3($a_ptr), $t3 + + call __ecp_nistz256_sub$x # p256_sub(res_x, Rsqr, Hsqr); + + lea $Hcub(%rsp), $b_ptr + lea $res_x(%rsp), $r_ptr + call __ecp_nistz256_sub_from$x # p256_sub(res_x, res_x, Hcub); + + mov $U2+8*0(%rsp), $t0 + mov $U2+8*1(%rsp), $t1 + mov $U2+8*2(%rsp), $t2 + mov $U2+8*3(%rsp), $t3 + lea $H(%rsp), $r_ptr + + call __ecp_nistz256_sub$x # p256_sub(H, U2, res_x); + + mov $acc0, 8*0($r_ptr) # save the result, as + mov $acc1, 8*1($r_ptr) # __ecp_nistz256_sub doesn't + mov $acc2, 8*2($r_ptr) + mov $acc3, 8*3($r_ptr) +___ +} +$code.=<<___; + `&load_for_mul("$Hcub(%rsp)", "$in1_y(%rsp)", "$src0")` + lea $S2(%rsp), $r_ptr + call __ecp_nistz256_mul_mont$x # p256_mul_mont(S2, Hcub, in1_y); + + `&load_for_mul("$H(%rsp)", "$R(%rsp)", "$src0")` + lea $H(%rsp), $r_ptr + call __ecp_nistz256_mul_mont$x # p256_mul_mont(H, H, R); + + lea $S2(%rsp), $b_ptr + lea $res_y(%rsp), $r_ptr + call __ecp_nistz256_sub_from$x # p256_sub(res_y, H, S2); + + movq %xmm0, $r_ptr # restore $r_ptr + + movdqa %xmm5, %xmm0 # copy_conditional(res_z, ONE, in1infty); + movdqa %xmm5, %xmm1 + pandn $res_z(%rsp), %xmm0 + movdqa %xmm5, %xmm2 + pandn $res_z+0x10(%rsp), %xmm1 + movdqa %xmm5, %xmm3 + pand .LONE_mont(%rip), %xmm2 + pand .LONE_mont+0x10(%rip), %xmm3 + por %xmm0, %xmm2 + por %xmm1, %xmm3 + + movdqa %xmm4, %xmm0 # copy_conditional(res_z, in1_z, in2infty); + movdqa %xmm4, %xmm1 + pandn %xmm2, %xmm0 + movdqa %xmm4, %xmm2 + pandn %xmm3, %xmm1 + movdqa %xmm4, %xmm3 + pand $in1_z(%rsp), %xmm2 + pand $in1_z+0x10(%rsp), %xmm3 + por %xmm0, %xmm2 + por %xmm1, %xmm3 + movdqu %xmm2, 0x40($r_ptr) + movdqu %xmm3, 0x50($r_ptr) + + movdqa %xmm5, %xmm0 # copy_conditional(res_x, in2_x, in1infty); + movdqa %xmm5, %xmm1 + pandn $res_x(%rsp), %xmm0 + movdqa %xmm5, %xmm2 + pandn $res_x+0x10(%rsp), %xmm1 + movdqa %xmm5, %xmm3 + pand $in2_x(%rsp), %xmm2 + pand $in2_x+0x10(%rsp), %xmm3 + por %xmm0, %xmm2 + por %xmm1, %xmm3 + + movdqa %xmm4, %xmm0 # copy_conditional(res_x, in1_x, in2infty); + movdqa %xmm4, %xmm1 + pandn %xmm2, %xmm0 + movdqa %xmm4, %xmm2 + pandn %xmm3, %xmm1 + movdqa %xmm4, %xmm3 + pand $in1_x(%rsp), %xmm2 + pand $in1_x+0x10(%rsp), %xmm3 + por %xmm0, %xmm2 + por %xmm1, %xmm3 + movdqu %xmm2, 0x00($r_ptr) + movdqu %xmm3, 0x10($r_ptr) + + movdqa %xmm5, %xmm0 # copy_conditional(res_y, in2_y, in1infty); + movdqa %xmm5, %xmm1 + pandn $res_y(%rsp), %xmm0 + movdqa %xmm5, %xmm2 + pandn $res_y+0x10(%rsp), %xmm1 + movdqa %xmm5, %xmm3 + pand $in2_y(%rsp), %xmm2 + pand $in2_y+0x10(%rsp), %xmm3 + por %xmm0, %xmm2 + por %xmm1, %xmm3 + + movdqa %xmm4, %xmm0 # copy_conditional(res_y, in1_y, in2infty); + movdqa %xmm4, %xmm1 + pandn %xmm2, %xmm0 + movdqa %xmm4, %xmm2 + pandn %xmm3, %xmm1 + movdqa %xmm4, %xmm3 + pand $in1_y(%rsp), %xmm2 + pand $in1_y+0x10(%rsp), %xmm3 + por %xmm0, %xmm2 + por %xmm1, %xmm3 + movdqu %xmm2, 0x20($r_ptr) + movdqu %xmm3, 0x30($r_ptr) + + lea 32*15+56(%rsp), %rsi +.cfi_def_cfa %rsi,8 + mov -48(%rsi),%r15 +.cfi_restore %r15 + mov -40(%rsi),%r14 +.cfi_restore %r14 + mov -32(%rsi),%r13 +.cfi_restore %r13 + mov -24(%rsi),%r12 +.cfi_restore %r12 + mov -16(%rsi),%rbx +.cfi_restore %rbx + mov -8(%rsi),%rbp +.cfi_restore %rbp + lea (%rsi),%rsp +.cfi_def_cfa_register %rsp +.Ladd_affine${x}_epilogue: + ret +.cfi_endproc +.size ecp_nistz256_point_add_affine$sfx,.-ecp_nistz256_point_add_affine$sfx +___ +} +&gen_add_affine("q"); + +######################################################################## +# AD*X magic +# +if ($addx) { { +######################################################################## +# operate in 4-5-0-1 "name space" that matches multiplication output +# +my ($a0,$a1,$a2,$a3,$t3,$t4)=($acc4,$acc5,$acc0,$acc1,$acc2,$acc3); + +$code.=<<___; +.type __ecp_nistz256_add_tox,\@abi-omnipotent +.align 32 +__ecp_nistz256_add_tox: +.cfi_startproc + xor $t4, $t4 + adc 8*0($b_ptr), $a0 + adc 8*1($b_ptr), $a1 + mov $a0, $t0 + adc 8*2($b_ptr), $a2 + adc 8*3($b_ptr), $a3 + mov $a1, $t1 + adc \$0, $t4 + + xor $t3, $t3 + sbb \$-1, $a0 + mov $a2, $t2 + sbb $poly1, $a1 + sbb \$0, $a2 + mov $a3, $t3 + sbb $poly3, $a3 + sbb \$0, $t4 + + cmovc $t0, $a0 + cmovc $t1, $a1 + mov $a0, 8*0($r_ptr) + cmovc $t2, $a2 + mov $a1, 8*1($r_ptr) + cmovc $t3, $a3 + mov $a2, 8*2($r_ptr) + mov $a3, 8*3($r_ptr) + + ret +.cfi_endproc +.size __ecp_nistz256_add_tox,.-__ecp_nistz256_add_tox + +.type __ecp_nistz256_sub_fromx,\@abi-omnipotent +.align 32 +__ecp_nistz256_sub_fromx: +.cfi_startproc + xor $t4, $t4 + sbb 8*0($b_ptr), $a0 + sbb 8*1($b_ptr), $a1 + mov $a0, $t0 + sbb 8*2($b_ptr), $a2 + sbb 8*3($b_ptr), $a3 + mov $a1, $t1 + sbb \$0, $t4 + + xor $t3, $t3 + adc \$-1, $a0 + mov $a2, $t2 + adc $poly1, $a1 + adc \$0, $a2 + mov $a3, $t3 + adc $poly3, $a3 + + bt \$0, $t4 + cmovnc $t0, $a0 + cmovnc $t1, $a1 + mov $a0, 8*0($r_ptr) + cmovnc $t2, $a2 + mov $a1, 8*1($r_ptr) + cmovnc $t3, $a3 + mov $a2, 8*2($r_ptr) + mov $a3, 8*3($r_ptr) + + ret +.cfi_endproc +.size __ecp_nistz256_sub_fromx,.-__ecp_nistz256_sub_fromx + +.type __ecp_nistz256_subx,\@abi-omnipotent +.align 32 +__ecp_nistz256_subx: +.cfi_startproc + xor $t4, $t4 + sbb $a0, $t0 + sbb $a1, $t1 + mov $t0, $a0 + sbb $a2, $t2 + sbb $a3, $t3 + mov $t1, $a1 + sbb \$0, $t4 + + xor $a3 ,$a3 + adc \$-1, $t0 + mov $t2, $a2 + adc $poly1, $t1 + adc \$0, $t2 + mov $t3, $a3 + adc $poly3, $t3 + + bt \$0, $t4 + cmovc $t0, $a0 + cmovc $t1, $a1 + cmovc $t2, $a2 + cmovc $t3, $a3 + + ret +.cfi_endproc +.size __ecp_nistz256_subx,.-__ecp_nistz256_subx + +.type __ecp_nistz256_mul_by_2x,\@abi-omnipotent +.align 32 +__ecp_nistz256_mul_by_2x: +.cfi_startproc + xor $t4, $t4 + adc $a0, $a0 # a0:a3+a0:a3 + adc $a1, $a1 + mov $a0, $t0 + adc $a2, $a2 + adc $a3, $a3 + mov $a1, $t1 + adc \$0, $t4 + + xor $t3, $t3 + sbb \$-1, $a0 + mov $a2, $t2 + sbb $poly1, $a1 + sbb \$0, $a2 + mov $a3, $t3 + sbb $poly3, $a3 + sbb \$0, $t4 + + cmovc $t0, $a0 + cmovc $t1, $a1 + mov $a0, 8*0($r_ptr) + cmovc $t2, $a2 + mov $a1, 8*1($r_ptr) + cmovc $t3, $a3 + mov $a2, 8*2($r_ptr) + mov $a3, 8*3($r_ptr) + + ret +.cfi_endproc +.size __ecp_nistz256_mul_by_2x,.-__ecp_nistz256_mul_by_2x +___ + } +&gen_double("x"); +&gen_add("x"); +&gen_add_affine("x"); +} +}}} + +# EXCEPTION_DISPOSITION handler (EXCEPTION_RECORD *rec,ULONG64 frame, +# CONTEXT *context,DISPATCHER_CONTEXT *disp) +if ($win64) { +$rec="%rcx"; +$frame="%rdx"; +$context="%r8"; +$disp="%r9"; + +$code.=<<___; +.extern __imp_RtlVirtualUnwind + +.type short_handler,\@abi-omnipotent +.align 16 +short_handler: + push %rsi + push %rdi + push %rbx + push %rbp + push %r12 + push %r13 + push %r14 + push %r15 + pushfq + sub \$64,%rsp + + mov 120($context),%rax # pull context->Rax + mov 248($context),%rbx # pull context->Rip + + mov 8($disp),%rsi # disp->ImageBase + mov 56($disp),%r11 # disp->HandlerData + + mov 0(%r11),%r10d # HandlerData[0] + lea (%rsi,%r10),%r10 # end of prologue label + cmp %r10,%rbx # context->RipRsp + + mov 4(%r11),%r10d # HandlerData[1] + lea (%rsi,%r10),%r10 # epilogue label + cmp %r10,%rbx # context->Rip>=epilogue label + jae .Lcommon_seh_tail + + lea 16(%rax),%rax + + mov -8(%rax),%r12 + mov -16(%rax),%r13 + mov %r12,216($context) # restore context->R12 + mov %r13,224($context) # restore context->R13 + + jmp .Lcommon_seh_tail +.size short_handler,.-short_handler + +.type full_handler,\@abi-omnipotent +.align 16 +full_handler: + push %rsi + push %rdi + push %rbx + push %rbp + push %r12 + push %r13 + push %r14 + push %r15 + pushfq + sub \$64,%rsp + + mov 120($context),%rax # pull context->Rax + mov 248($context),%rbx # pull context->Rip + + mov 8($disp),%rsi # disp->ImageBase + mov 56($disp),%r11 # disp->HandlerData + + mov 0(%r11),%r10d # HandlerData[0] + lea (%rsi,%r10),%r10 # end of prologue label + cmp %r10,%rbx # context->RipRsp + + mov 4(%r11),%r10d # HandlerData[1] + lea (%rsi,%r10),%r10 # epilogue label + cmp %r10,%rbx # context->Rip>=epilogue label + jae .Lcommon_seh_tail + + mov 8(%r11),%r10d # HandlerData[2] + lea (%rax,%r10),%rax + + mov -8(%rax),%rbp + mov -16(%rax),%rbx + mov -24(%rax),%r12 + mov -32(%rax),%r13 + mov -40(%rax),%r14 + mov -48(%rax),%r15 + mov %rbx,144($context) # restore context->Rbx + mov %rbp,160($context) # restore context->Rbp + mov %r12,216($context) # restore context->R12 + mov %r13,224($context) # restore context->R13 + mov %r14,232($context) # restore context->R14 + mov %r15,240($context) # restore context->R15 + +.Lcommon_seh_tail: + mov 8(%rax),%rdi + mov 16(%rax),%rsi + mov %rax,152($context) # restore context->Rsp + mov %rsi,168($context) # restore context->Rsi + mov %rdi,176($context) # restore context->Rdi + + mov 40($disp),%rdi # disp->ContextRecord + mov $context,%rsi # context + mov \$154,%ecx # sizeof(CONTEXT) + .long 0xa548f3fc # cld; rep movsq + + mov $disp,%rsi + xor %rcx,%rcx # arg1, UNW_FLAG_NHANDLER + mov 8(%rsi),%rdx # arg2, disp->ImageBase + mov 0(%rsi),%r8 # arg3, disp->ControlPc + mov 16(%rsi),%r9 # arg4, disp->FunctionEntry + mov 40(%rsi),%r10 # disp->ContextRecord + lea 56(%rsi),%r11 # &disp->HandlerData + lea 24(%rsi),%r12 # &disp->EstablisherFrame + mov %r10,32(%rsp) # arg5 + mov %r11,40(%rsp) # arg6 + mov %r12,48(%rsp) # arg7 + mov %rcx,56(%rsp) # arg8, (NULL) + call *__imp_RtlVirtualUnwind(%rip) + + mov \$1,%eax # ExceptionContinueSearch + add \$64,%rsp + popfq + pop %r15 + pop %r14 + pop %r13 + pop %r12 + pop %rbp + pop %rbx + pop %rdi + pop %rsi + ret +.size full_handler,.-full_handler + +.section .pdata +.align 4 + .rva .LSEH_begin_ecp_nistz256_neg + .rva .LSEH_end_ecp_nistz256_neg + .rva .LSEH_info_ecp_nistz256_neg + + .rva .LSEH_begin_ecp_nistz256_ord_mul_mont_nohw + .rva .LSEH_end_ecp_nistz256_ord_mul_mont_nohw + .rva .LSEH_info_ecp_nistz256_ord_mul_mont_nohw + + .rva .LSEH_begin_ecp_nistz256_ord_sqr_mont_nohw + .rva .LSEH_end_ecp_nistz256_ord_sqr_mont_nohw + .rva .LSEH_info_ecp_nistz256_ord_sqr_mont_nohw +___ +$code.=<<___ if ($addx); + .rva .LSEH_begin_ecp_nistz256_ord_mul_mont_adx + .rva .LSEH_end_ecp_nistz256_ord_mul_mont_adx + .rva .LSEH_info_ecp_nistz256_ord_mul_mont_adx + + .rva .LSEH_begin_ecp_nistz256_ord_sqr_mont_adx + .rva .LSEH_end_ecp_nistz256_ord_sqr_mont_adx + .rva .LSEH_info_ecp_nistz256_ord_sqr_mont_adx +___ +$code.=<<___; + .rva .LSEH_begin_ecp_nistz256_mul_mont_nohw + .rva .LSEH_end_ecp_nistz256_mul_mont_nohw + .rva .LSEH_info_ecp_nistz256_mul_mont_nohw + + .rva .LSEH_begin_ecp_nistz256_sqr_mont_nohw + .rva .LSEH_end_ecp_nistz256_sqr_mont_nohw + .rva .LSEH_info_ecp_nistz256_sqr_mont_nohw +___ +$code.=<<___ if ($addx); + .rva .LSEH_begin_ecp_nistz256_mul_mont_adx + .rva .LSEH_end_ecp_nistz256_mul_mont_adx + .rva .LSEH_info_ecp_nistz256_mul_mont_adx + + .rva .LSEH_begin_ecp_nistz256_sqr_mont_adx + .rva .LSEH_end_ecp_nistz256_sqr_mont_adx + .rva .LSEH_info_ecp_nistz256_sqr_mont_adx +___ +$code.=<<___; + .rva .LSEH_begin_ecp_nistz256_select_w5_nohw + .rva .LSEH_end_ecp_nistz256_select_w5_nohw + .rva .LSEH_info_ecp_nistz256_select_wX_nohw + + .rva .LSEH_begin_ecp_nistz256_select_w7_nohw + .rva .LSEH_end_ecp_nistz256_select_w7_nohw + .rva .LSEH_info_ecp_nistz256_select_wX_nohw +___ +$code.=<<___ if ($avx>1); + .rva .LSEH_begin_ecp_nistz256_select_w5_avx2 + .rva .LSEH_end_ecp_nistz256_select_w5_avx2 + .rva .LSEH_info_ecp_nistz256_select_wX_avx2 + + .rva .LSEH_begin_ecp_nistz256_select_w7_avx2 + .rva .LSEH_end_ecp_nistz256_select_w7_avx2 + .rva .LSEH_info_ecp_nistz256_select_wX_avx2 +___ +$code.=<<___; + .rva .LSEH_begin_ecp_nistz256_point_double_nohw + .rva .LSEH_end_ecp_nistz256_point_double_nohw + .rva .LSEH_info_ecp_nistz256_point_double_nohw + + .rva .LSEH_begin_ecp_nistz256_point_add_nohw + .rva .LSEH_end_ecp_nistz256_point_add_nohw + .rva .LSEH_info_ecp_nistz256_point_add_nohw + + .rva .LSEH_begin_ecp_nistz256_point_add_affine_nohw + .rva .LSEH_end_ecp_nistz256_point_add_affine_nohw + .rva .LSEH_info_ecp_nistz256_point_add_affine_nohw +___ +$code.=<<___ if ($addx); + .rva .LSEH_begin_ecp_nistz256_point_double_adx + .rva .LSEH_end_ecp_nistz256_point_double_adx + .rva .LSEH_info_ecp_nistz256_point_double_adx + + .rva .LSEH_begin_ecp_nistz256_point_add_adx + .rva .LSEH_end_ecp_nistz256_point_add_adx + .rva .LSEH_info_ecp_nistz256_point_add_adx + + .rva .LSEH_begin_ecp_nistz256_point_add_affine_adx + .rva .LSEH_end_ecp_nistz256_point_add_affine_adx + .rva .LSEH_info_ecp_nistz256_point_add_affine_adx +___ +$code.=<<___; + +.section .xdata +.align 8 +.LSEH_info_ecp_nistz256_neg: + .byte 9,0,0,0 + .rva short_handler + .rva .Lneg_body,.Lneg_epilogue # HandlerData[] +.LSEH_info_ecp_nistz256_ord_mul_mont_nohw: + .byte 9,0,0,0 + .rva full_handler + .rva .Lord_mul_body,.Lord_mul_epilogue # HandlerData[] + .long 48,0 +.LSEH_info_ecp_nistz256_ord_sqr_mont_nohw: + .byte 9,0,0,0 + .rva full_handler + .rva .Lord_sqr_body,.Lord_sqr_epilogue # HandlerData[] + .long 48,0 +___ +$code.=<<___ if ($addx); +.LSEH_info_ecp_nistz256_ord_mul_mont_adx: + .byte 9,0,0,0 + .rva full_handler + .rva .Lord_mulx_body,.Lord_mulx_epilogue # HandlerData[] + .long 48,0 +.LSEH_info_ecp_nistz256_ord_sqr_mont_adx: + .byte 9,0,0,0 + .rva full_handler + .rva .Lord_sqrx_body,.Lord_sqrx_epilogue # HandlerData[] + .long 48,0 +___ +$code.=<<___; +.LSEH_info_ecp_nistz256_mul_mont_nohw: + .byte 9,0,0,0 + .rva full_handler + .rva .Lmul_body,.Lmul_epilogue # HandlerData[] + .long 48,0 +.LSEH_info_ecp_nistz256_sqr_mont_nohw: + .byte 9,0,0,0 + .rva full_handler + .rva .Lsqr_body,.Lsqr_epilogue # HandlerData[] + .long 48,0 +___ +$code.=<<___ if ($addx); +.LSEH_info_ecp_nistz256_mul_mont_adx: + .byte 9,0,0,0 + .rva full_handler + .rva .Lmulx_body,.Lmulx_epilogue # HandlerData[] + .long 48,0 +.LSEH_info_ecp_nistz256_sqr_mont_adx: + .byte 9,0,0,0 + .rva full_handler + .rva .Lsqrx_body,.Lsqrx_epilogue # HandlerData[] + .long 48,0 +___ +$code.=<<___; +.LSEH_info_ecp_nistz256_select_wX_nohw: + .byte 0x01,0x33,0x16,0x00 + .byte 0x33,0xf8,0x09,0x00 #movaps 0x90(rsp),xmm15 + .byte 0x2e,0xe8,0x08,0x00 #movaps 0x80(rsp),xmm14 + .byte 0x29,0xd8,0x07,0x00 #movaps 0x70(rsp),xmm13 + .byte 0x24,0xc8,0x06,0x00 #movaps 0x60(rsp),xmm12 + .byte 0x1f,0xb8,0x05,0x00 #movaps 0x50(rsp),xmm11 + .byte 0x1a,0xa8,0x04,0x00 #movaps 0x40(rsp),xmm10 + .byte 0x15,0x98,0x03,0x00 #movaps 0x30(rsp),xmm9 + .byte 0x10,0x88,0x02,0x00 #movaps 0x20(rsp),xmm8 + .byte 0x0c,0x78,0x01,0x00 #movaps 0x10(rsp),xmm7 + .byte 0x08,0x68,0x00,0x00 #movaps 0x00(rsp),xmm6 + .byte 0x04,0x01,0x15,0x00 #sub rsp,0xa8 + .align 8 +___ +$code.=<<___ if ($avx>1); +.LSEH_info_ecp_nistz256_select_wX_avx2: + .byte 0x01,0x36,0x17,0x0b + .byte 0x36,0xf8,0x09,0x00 # vmovaps 0x90(rsp),xmm15 + .byte 0x31,0xe8,0x08,0x00 # vmovaps 0x80(rsp),xmm14 + .byte 0x2c,0xd8,0x07,0x00 # vmovaps 0x70(rsp),xmm13 + .byte 0x27,0xc8,0x06,0x00 # vmovaps 0x60(rsp),xmm12 + .byte 0x22,0xb8,0x05,0x00 # vmovaps 0x50(rsp),xmm11 + .byte 0x1d,0xa8,0x04,0x00 # vmovaps 0x40(rsp),xmm10 + .byte 0x18,0x98,0x03,0x00 # vmovaps 0x30(rsp),xmm9 + .byte 0x13,0x88,0x02,0x00 # vmovaps 0x20(rsp),xmm8 + .byte 0x0e,0x78,0x01,0x00 # vmovaps 0x10(rsp),xmm7 + .byte 0x09,0x68,0x00,0x00 # vmovaps 0x00(rsp),xmm6 + .byte 0x04,0x01,0x15,0x00 # sub rsp,0xa8 + .byte 0x00,0xb3,0x00,0x00 # set_frame r11 + .align 8 +___ +$code.=<<___; +.LSEH_info_ecp_nistz256_point_double_nohw: + .byte 9,0,0,0 + .rva full_handler + .rva .Lpoint_doubleq_body,.Lpoint_doubleq_epilogue # HandlerData[] + .long 32*5+56,0 +.LSEH_info_ecp_nistz256_point_add_nohw: + .byte 9,0,0,0 + .rva full_handler + .rva .Lpoint_addq_body,.Lpoint_addq_epilogue # HandlerData[] + .long 32*18+56,0 +.LSEH_info_ecp_nistz256_point_add_affine_nohw: + .byte 9,0,0,0 + .rva full_handler + .rva .Ladd_affineq_body,.Ladd_affineq_epilogue # HandlerData[] + .long 32*15+56,0 +___ +$code.=<<___ if ($addx); +.align 8 +.LSEH_info_ecp_nistz256_point_double_adx: + .byte 9,0,0,0 + .rva full_handler + .rva .Lpoint_doublex_body,.Lpoint_doublex_epilogue # HandlerData[] + .long 32*5+56,0 +.LSEH_info_ecp_nistz256_point_add_adx: + .byte 9,0,0,0 + .rva full_handler + .rva .Lpoint_addx_body,.Lpoint_addx_epilogue # HandlerData[] + .long 32*18+56,0 +.LSEH_info_ecp_nistz256_point_add_affine_adx: + .byte 9,0,0,0 + .rva full_handler + .rva .Ladd_affinex_body,.Ladd_affinex_epilogue # HandlerData[] + .long 32*15+56,0 +___ +} + +$code =~ s/\`([^\`]*)\`/eval $1/gem; +print $code; +close STDOUT or die "error closing STDOUT: $!"; diff --git a/http/vendor/ring/crypto/fipsmodule/ec/ecp_nistz.c b/http/vendor/ring/crypto/fipsmodule/ec/ecp_nistz.c new file mode 100644 index 0000000..1811e28 --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/ec/ecp_nistz.c @@ -0,0 +1,52 @@ +/* Copyright (c) 2014, Intel Corporation. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#include "ecp_nistz.h" + +#if defined(__GNUC__) +#pragma GCC diagnostic ignored "-Wconversion" +#endif + +/* Fills |str| with the bytewise little-endian encoding of |scalar|, where + * |scalar| has |num_limbs| limbs. |str| is padded with zeros at the end up + * to |str_len| bytes. Actually, |str_len| must be exactly one byte more than + * needed to encode |num_limbs| losslessly, so that there is an extra byte at + * the end. The extra byte is useful because the caller will be breaking |str| + * up into windows of a number of bits (5 or 7) that isn't divisible by 8, and + * so it is useful for it to be able to read an extra zero byte. */ +void little_endian_bytes_from_scalar(uint8_t str[], size_t str_len, + const Limb scalar[], + size_t num_limbs) { + debug_assert_nonsecret(str_len == (num_limbs * sizeof(Limb)) + 1); + + size_t i; + for (i = 0; i < num_limbs * sizeof(Limb); i += sizeof(Limb)) { + Limb d = scalar[i / sizeof(Limb)]; + + str[i + 0] = d & 0xff; + str[i + 1] = (d >> 8) & 0xff; + str[i + 2] = (d >> 16) & 0xff; + str[i + 3] = (d >>= 24) & 0xff; + if (sizeof(Limb) == 8) { + d >>= 8; + str[i + 4] = d & 0xff; + str[i + 5] = (d >> 8) & 0xff; + str[i + 6] = (d >> 16) & 0xff; + str[i + 7] = (d >> 24) & 0xff; + } + } + for (; i < str_len; i++) { + str[i] = 0; + } +} diff --git a/http/vendor/ring/crypto/fipsmodule/ec/ecp_nistz.h b/http/vendor/ring/crypto/fipsmodule/ec/ecp_nistz.h new file mode 100644 index 0000000..3c04c47 --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/ec/ecp_nistz.h @@ -0,0 +1,274 @@ +/* Copyright (c) 2015, Google Inc. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#ifndef OPENSSL_HEADER_EC_ECP_NISTZ_H +#define OPENSSL_HEADER_EC_ECP_NISTZ_H + +#include + +#include "../../limbs/limbs.h" + +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + +// This function looks at `w + 1` scalar bits (`w` current, 1 adjacent less +// significant bit), and recodes them into a signed digit for use in fast point +// multiplication: the use of signed rather than unsigned digits means that +// fewer points need to be precomputed, given that point inversion is easy (a +// precomputed point dP makes -dP available as well). +// +// BACKGROUND: +// +// Signed digits for multiplication were introduced by Booth ("A signed binary +// multiplication technique", Quart. Journ. Mech. and Applied Math., vol. IV, +// pt. 2 (1951), pp. 236-240), in that case for multiplication of integers. +// Booth's original encoding did not generally improve the density of nonzero +// digits over the binary representation, and was merely meant to simplify the +// handling of signed factors given in two's complement; but it has since been +// shown to be the basis of various signed-digit representations that do have +// further advantages, including the wNAF, using the following general +// approach: +// +// (1) Given a binary representation +// +// b_k ... b_2 b_1 b_0, +// +// of a nonnegative integer (b_k in {0, 1}), rewrite it in digits 0, 1, -1 +// by using bit-wise subtraction as follows: +// +// b_k b_(k-1) ... b_2 b_1 b_0 +// - b_k ... b_3 b_2 b_1 b_0 +// ----------------------------------------- +// s_(k+1) s_k ... s_3 s_2 s_1 s_0 +// +// A left-shift followed by subtraction of the original value yields a new +// representation of the same value, using signed bits s_i = b_(i-1) - b_i. +// This representation from Booth's paper has since appeared in the +// literature under a variety of different names including "reversed binary +// form", "alternating greedy expansion", "mutual opposite form", and +// "sign-alternating {+-1}-representation". +// +// An interesting property is that among the nonzero bits, values 1 and -1 +// strictly alternate. +// +// (2) Various window schemes can be applied to the Booth representation of +// integers: for example, right-to-left sliding windows yield the wNAF +// (a signed-digit encoding independently discovered by various researchers +// in the 1990s), and left-to-right sliding windows yield a left-to-right +// equivalent of the wNAF (independently discovered by various researchers +// around 2004). +// +// To prevent leaking information through side channels in point multiplication, +// we need to recode the given integer into a regular pattern: sliding windows +// as in wNAFs won't do, we need their fixed-window equivalent -- which is a few +// decades older: we'll be using the so-called "modified Booth encoding" due to +// MacSorley ("High-speed arithmetic in binary computers", Proc. IRE, vol. 49 +// (1961), pp. 67-91), in a radix-2**w setting. That is, we always combine `w` +// signed bits into a signed digit, e.g. (for `w == 5`): +// +// s_(5j + 4) s_(5j + 3) s_(5j + 2) s_(5j + 1) s_(5j) +// +// The sign-alternating property implies that the resulting digit values are +// integers from `-2**(w-1)` to `2**(w-1)`, e.g. -16 to 16 for `w == 5`. +// +// Of course, we don't actually need to compute the signed digits s_i as an +// intermediate step (that's just a nice way to see how this scheme relates +// to the wNAF): a direct computation obtains the recoded digit from the +// six bits b_(5j + 4) ... b_(5j - 1). +// +// This function takes those `w` bits as an integer (e.g. 0 .. 63), writing the +// recoded digit to *sign (0 for positive, 1 for negative) and *digit (absolute +// value, in the range 0 .. 2**(w-1). Note that this integer essentially provides +// the input bits "shifted to the left" by one position: for example, the input +// to compute the least significant recoded digit, given that there's no bit +// b_-1, has to be b_4 b_3 b_2 b_1 b_0 0. +// +// DOUBLING CASE: +// +// Point addition formulas for short Weierstrass curves are often incomplete. +// Edge cases such as P + P or P + ∞ must be handled separately. This +// complicates constant-time requirements. P + ∞ cannot be avoided (any window +// may be zero) and is handled with constant-time selects. P + P (where P is not +// ∞) usually is not. Instead, windowing strategies are chosen to avoid this +// case. Whether this happens depends on the group order. +// +// Let w be the window width (in this function, w = 5). The non-trivial doubling +// case in single-point scalar multiplication may occur if and only if the +// 2^(w-1) bit of the group order is zero. +// +// Note the above only holds if the scalar is fully reduced and the group order +// is a prime that is much larger than 2^w. It also only holds when windows +// are applied from most significant to least significant, doubling between each +// window. It does not apply to more complex table strategies such as +// |EC_nistz256_method|. +// +// PROOF: +// +// Let n be the group order. Let l be the number of bits needed to represent n. +// Assume there exists some 0 <= k < n such that signed w-bit windowed +// multiplication hits the doubling case. +// +// Windowed multiplication consists of iterating over groups of s_i (defined +// above based on k's binary representation) from most to least significant. At +// iteration i (for i = ..., 3w, 2w, w, 0, starting from the most significant +// window), we: +// +// 1. Double the accumulator A, w times. Let A_i be the value of A at this +// point. +// +// 2. Set A to T_i + A_i, where T_i is a precomputed multiple of P +// corresponding to the window s_(i+w-1) ... s_i. +// +// Let j be the index such that A_j = T_j ≠ ∞. Looking at A_i and T_i as +// multiples of P, define a_i and t_i to be scalar coefficients of A_i and T_i. +// Thus a_j = t_j ≠ 0 (mod n). Note a_i and t_i may not be reduced mod n. t_i is +// the value of the w signed bits s_(i+w-1) ... s_i. a_i is computed as a_i = +// 2^w * (a_(i+w) + t_(i+w)). +// +// t_i is bounded by -2^(w-1) <= t_i <= 2^(w-1). Additionally, we may write it +// in terms of unsigned bits b_i. t_i consists of signed bits s_(i+w-1) ... s_i. +// This is computed as: +// +// b_(i+w-2) b_(i+w-3) ... b_i b_(i-1) +// - b_(i+w-1) b_(i+w-2) ... b_(i+1) b_i +// -------------------------------------------- +// t_i = s_(i+w-1) s_(i+w-2) ... s_(i+1) s_i +// +// Observe that b_(i+w-2) through b_i occur in both terms. Let x be the integer +// represented by that bit string, i.e. 2^(w-2)*b_(i+w-2) + ... + b_i. +// +// t_i = (2*x + b_(i-1)) - (2^(w-1)*b_(i+w-1) + x) +// = x - 2^(w-1)*b_(i+w-1) + b_(i-1) +// +// Or, using C notation for bit operations: +// +// t_i = (k>>i) & ((1<<(w-1)) - 1) - (k>>i) & (1<<(w-1)) + (k>>(i-1)) & 1 +// +// Note b_(i-1) is added in left-shifted by one (or doubled) from its place. +// This is compensated by t_(i-w)'s subtraction term. Thus, a_i may be computed +// by adding b_l b_(l-1) ... b_(i+1) b_i and an extra copy of b_(i-1). In C +// notation, this is: +// +// a_i = (k>>(i+w)) << w + ((k>>(i+w-1)) & 1) << w +// +// Observe that, while t_i may be positive or negative, a_i is bounded by +// 0 <= a_i < n + 2^w. Additionally, a_i can only be zero if b_(i+w-1) and up +// are all zero. (Note this implies a non-trivial P + (-P) is unreachable for +// all groups. That would imply the subsequent a_i is zero, which means all +// terms thus far were zero.) +// +// Returning to our doubling position, we have a_j = t_j (mod n). We now +// determine the value of a_j - t_j, which must be divisible by n. Our bounds on +// a_j and t_j imply a_j - t_j is 0 or n. If it is 0, a_j = t_j. However, 2^w +// divides a_j and -2^(w-1) <= t_j <= 2^(w-1), so this can only happen if +// a_j = t_j = 0, which is a trivial doubling. Therefore, a_j - t_j = n. +// +// Now we determine j. Suppose j > 0. w divides j, so j >= w. Then, +// +// n = a_j - t_j = (k>>(j+w)) << w + ((k>>(j+w-1)) & 1) << w - t_j +// <= k/2^j + 2^w - t_j +// < n/2^w + 2^w + 2^(w-1) +// +// n is much larger than 2^w, so this is impossible. Thus, j = 0: only the final +// addition may hit the doubling case. +// +// Finally, we consider bit patterns for n and k. Divide k into k_H + k_M + k_L +// such that k_H is the contribution from b_(l-1) .. b_w, k_M is the +// contribution from b_(w-1), and k_L is the contribution from b_(w-2) ... b_0. +// That is: +// +// - 2^w divides k_H +// - k_M is 0 or 2^(w-1) +// - 0 <= k_L < 2^(w-1) +// +// Divide n into n_H + n_M + n_L similarly. We thus have: +// +// t_0 = (k>>0) & ((1<<(w-1)) - 1) - (k>>0) & (1<<(w-1)) + (k>>(0-1)) & 1 +// = k & ((1<<(w-1)) - 1) - k & (1<<(w-1)) +// = k_L - k_M +// +// a_0 = (k>>(0+w)) << w + ((k>>(0+w-1)) & 1) << w +// = (k>>w) << w + ((k>>(w-1)) & 1) << w +// = k_H + 2*k_M +// +// n = a_0 - t_0 +// n_H + n_M + n_L = (k_H + 2*k_M) - (k_L - k_M) +// = k_H + 3*k_M - k_L +// +// k_H - k_L < k and k < n, so k_H - k_L ≠ n. Therefore k_M is not 0 and must be +// 2^(w-1). Now we consider k_H and n_H. We know k_H <= n_H. Suppose k_H = n_H. +// Then, +// +// n_M + n_L = 3*(2^(w-1)) - k_L +// > 3*(2^(w-1)) - 2^(w-1) +// = 2^w +// +// Contradiction (n_M + n_L is the bottom w bits of n). Thus k_H < n_H. Suppose +// k_H < n_H - 2*2^w. Then, +// +// n_H + n_M + n_L = k_H + 3*(2^(w-1)) - k_L +// < n_H - 2*2^w + 3*(2^(w-1)) - k_L +// n_M + n_L < -2^(w-1) - k_L +// +// Contradiction. Thus, k_H = n_H - 2^w. (Note 2^w divides n_H and k_H.) Thus, +// +// n_H + n_M + n_L = k_H + 3*(2^(w-1)) - k_L +// = n_H - 2^w + 3*(2^(w-1)) - k_L +// n_M + n_L = 2^(w-1) - k_L +// <= 2^(w-1) +// +// Equality would mean 2^(w-1) divides n, which is impossible if n is prime. +// Thus n_M + n_L < 2^(w-1), so n_M is zero, proving our condition. +// +// This proof constructs k, so, to show the converse, let k_H = n_H - 2^w, +// k_M = 2^(w-1), k_L = 2^(w-1) - n_L. This will result in a non-trivial point +// doubling in the final addition and is the only such scalar. +// +// COMMON CURVES: +// +// The group orders for common curves end in the following bit patterns: +// +// P-521: ...00001001; w = 4 is okay +// P-384: ...01110011; w = 2, 5, 6, 7 are okay +// P-256: ...01010001; w = 5, 7 are okay +// P-224: ...00111101; w = 3, 4, 5, 6 are okay +static inline void booth_recode(crypto_word_t *is_negative, crypto_word_t *digit, + crypto_word_t in, crypto_word_t w) { + debug_assert_nonsecret(w >= 2); + debug_assert_nonsecret(w <= 7); + + // Set all bits of `s` to MSB(in), similar to |constant_time_msb_s|, + // but 'in' seen as (`w+1`)-bit value. + crypto_word_t s = ~((in >> w) - 1); + crypto_word_t d; + d = ((crypto_word_t)1u << (w + 1)) - in - 1; + d = (d & s) | (in & ~s); + d = (d >> 1) + (d & 1); + + *is_negative = constant_time_is_nonzero_w(s & 1); + *digit = d; +} + +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif + +void little_endian_bytes_from_scalar(uint8_t str[], size_t str_len, + const Limb scalar[], + size_t num_limbs); + +#endif // OPENSSL_HEADER_EC_ECP_NISTZ_H diff --git a/http/vendor/ring/crypto/fipsmodule/ec/ecp_nistz384.h b/http/vendor/ring/crypto/fipsmodule/ec/ecp_nistz384.h new file mode 100644 index 0000000..ca87e60 --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/ec/ecp_nistz384.h @@ -0,0 +1,34 @@ +/* Copyright (c) 2014, Intel Corporation. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#ifndef OPENSSL_HEADER_EC_ECP_NISTZ384_H +#define OPENSSL_HEADER_EC_ECP_NISTZ384_H + +#include "../../limbs/limbs.h" + +#define P384_LIMBS (384u / LIMB_BITS) + +typedef struct { + Limb X[P384_LIMBS]; + Limb Y[P384_LIMBS]; + Limb Z[P384_LIMBS]; +} P384_POINT; + +typedef struct { + Limb X[P384_LIMBS]; + Limb Y[P384_LIMBS]; +} P384_POINT_AFFINE; + + +#endif // OPENSSL_HEADER_EC_ECP_NISTZ384_H diff --git a/http/vendor/ring/crypto/fipsmodule/ec/ecp_nistz384.inl b/http/vendor/ring/crypto/fipsmodule/ec/ecp_nistz384.inl new file mode 100644 index 0000000..ae28f97 --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/ec/ecp_nistz384.inl @@ -0,0 +1,300 @@ +/* Copyright (c) 2014, Intel Corporation. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +/* Developers and authors: + * Shay Gueron (1, 2), and Vlad Krasnov (1) + * (1) Intel Corporation, Israel Development Center + * (2) University of Haifa + * Reference: + * Shay Gueron and Vlad Krasnov + * "Fast Prime Field Elliptic Curve Cryptography with 256 Bit Primes" + * http://eprint.iacr.org/2013/816 */ + +#include "ecp_nistz.h" + +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + +/* Point double: r = 2*a */ +static void nistz384_point_double(P384_POINT *r, const P384_POINT *a) { + BN_ULONG S[P384_LIMBS]; + BN_ULONG M[P384_LIMBS]; + BN_ULONG Zsqr[P384_LIMBS]; + BN_ULONG tmp0[P384_LIMBS]; + + const BN_ULONG *in_x = a->X; + const BN_ULONG *in_y = a->Y; + const BN_ULONG *in_z = a->Z; + + BN_ULONG *res_x = r->X; + BN_ULONG *res_y = r->Y; + BN_ULONG *res_z = r->Z; + + elem_mul_by_2(S, in_y); + + elem_sqr_mont(Zsqr, in_z); + + elem_sqr_mont(S, S); + + elem_mul_mont(res_z, in_z, in_y); + elem_mul_by_2(res_z, res_z); + + elem_add(M, in_x, Zsqr); + elem_sub(Zsqr, in_x, Zsqr); + + elem_sqr_mont(res_y, S); + elem_div_by_2(res_y, res_y); + + elem_mul_mont(M, M, Zsqr); + elem_mul_by_3(M, M); + + elem_mul_mont(S, S, in_x); + elem_mul_by_2(tmp0, S); + + elem_sqr_mont(res_x, M); + + elem_sub(res_x, res_x, tmp0); + elem_sub(S, S, res_x); + + elem_mul_mont(S, S, M); + elem_sub(res_y, S, res_y); +} + +/* Point addition: r = a+b */ +static void nistz384_point_add(P384_POINT *r, const P384_POINT *a, + const P384_POINT *b) { + BN_ULONG U2[P384_LIMBS], S2[P384_LIMBS]; + BN_ULONG U1[P384_LIMBS], S1[P384_LIMBS]; + BN_ULONG Z1sqr[P384_LIMBS]; + BN_ULONG Z2sqr[P384_LIMBS]; + BN_ULONG H[P384_LIMBS], R[P384_LIMBS]; + BN_ULONG Hsqr[P384_LIMBS]; + BN_ULONG Rsqr[P384_LIMBS]; + BN_ULONG Hcub[P384_LIMBS]; + + BN_ULONG res_x[P384_LIMBS]; + BN_ULONG res_y[P384_LIMBS]; + BN_ULONG res_z[P384_LIMBS]; + + const BN_ULONG *in1_x = a->X; + const BN_ULONG *in1_y = a->Y; + const BN_ULONG *in1_z = a->Z; + + const BN_ULONG *in2_x = b->X; + const BN_ULONG *in2_y = b->Y; + const BN_ULONG *in2_z = b->Z; + + BN_ULONG in1infty = is_zero(a->Z); + BN_ULONG in2infty = is_zero(b->Z); + + elem_sqr_mont(Z2sqr, in2_z); /* Z2^2 */ + elem_sqr_mont(Z1sqr, in1_z); /* Z1^2 */ + + elem_mul_mont(S1, Z2sqr, in2_z); /* S1 = Z2^3 */ + elem_mul_mont(S2, Z1sqr, in1_z); /* S2 = Z1^3 */ + + elem_mul_mont(S1, S1, in1_y); /* S1 = Y1*Z2^3 */ + elem_mul_mont(S2, S2, in2_y); /* S2 = Y2*Z1^3 */ + elem_sub(R, S2, S1); /* R = S2 - S1 */ + + elem_mul_mont(U1, in1_x, Z2sqr); /* U1 = X1*Z2^2 */ + elem_mul_mont(U2, in2_x, Z1sqr); /* U2 = X2*Z1^2 */ + elem_sub(H, U2, U1); /* H = U2 - U1 */ + + BN_ULONG is_exceptional = is_equal(U1, U2) & ~in1infty & ~in2infty; + if (is_exceptional) { + if (is_equal(S1, S2)) { + nistz384_point_double(r, a); + } else { + limbs_zero(r->X, P384_LIMBS); + limbs_zero(r->Y, P384_LIMBS); + limbs_zero(r->Z, P384_LIMBS); + } + return; + } + + elem_sqr_mont(Rsqr, R); /* R^2 */ + elem_mul_mont(res_z, H, in1_z); /* Z3 = H*Z1*Z2 */ + elem_sqr_mont(Hsqr, H); /* H^2 */ + elem_mul_mont(res_z, res_z, in2_z); /* Z3 = H*Z1*Z2 */ + elem_mul_mont(Hcub, Hsqr, H); /* H^3 */ + + elem_mul_mont(U2, U1, Hsqr); /* U1*H^2 */ + elem_mul_by_2(Hsqr, U2); /* 2*U1*H^2 */ + + elem_sub(res_x, Rsqr, Hsqr); + elem_sub(res_x, res_x, Hcub); + + elem_sub(res_y, U2, res_x); + + elem_mul_mont(S2, S1, Hcub); + elem_mul_mont(res_y, R, res_y); + elem_sub(res_y, res_y, S2); + + copy_conditional(res_x, in2_x, in1infty); + copy_conditional(res_y, in2_y, in1infty); + copy_conditional(res_z, in2_z, in1infty); + + copy_conditional(res_x, in1_x, in2infty); + copy_conditional(res_y, in1_y, in2infty); + copy_conditional(res_z, in1_z, in2infty); + + limbs_copy(r->X, res_x, P384_LIMBS); + limbs_copy(r->Y, res_y, P384_LIMBS); + limbs_copy(r->Z, res_z, P384_LIMBS); +} + +static void add_precomputed_w5(P384_POINT *r, crypto_word_t wvalue, + const P384_POINT table[16]) { + crypto_word_t recoded_is_negative; + crypto_word_t recoded; + booth_recode(&recoded_is_negative, &recoded, wvalue, 5); + + alignas(64) P384_POINT h; + p384_point_select_w5(&h, table, recoded); + + alignas(64) BN_ULONG tmp[P384_LIMBS]; + p384_elem_neg(tmp, h.Y); + copy_conditional(h.Y, tmp, recoded_is_negative); + + nistz384_point_add(r, r, &h); +} + +/* r = p * p_scalar */ +static void nistz384_point_mul(P384_POINT *r, + const BN_ULONG p_scalar[P384_LIMBS], + const Limb p_x[P384_LIMBS], + const Limb p_y[P384_LIMBS]) { + static const size_t kWindowSize = 5; + static const crypto_word_t kMask = (1 << (5 /* kWindowSize */ + 1)) - 1; + + uint8_t p_str[(P384_LIMBS * sizeof(Limb)) + 1]; + little_endian_bytes_from_scalar(p_str, sizeof(p_str) / sizeof(p_str[0]), + p_scalar, P384_LIMBS); + + /* A |P384_POINT| is (3 * 48) = 144 bytes, and the 64-byte alignment should + * add no more than 63 bytes of overhead. Thus, |table| should require + * ~2367 ((144 * 16) + 63) bytes of stack space. */ + alignas(64) P384_POINT table[16]; + + /* table[0] is implicitly (0,0,0) (the point at infinity), therefore it is + * not stored. All other values are actually stored with an offset of -1 in + * table. */ + P384_POINT *row = table; + + limbs_copy(row[1 - 1].X, p_x, P384_LIMBS); + limbs_copy(row[1 - 1].Y, p_y, P384_LIMBS); + limbs_copy(row[1 - 1].Z, ONE, P384_LIMBS); + + nistz384_point_double(&row[2 - 1], &row[1 - 1]); + nistz384_point_add(&row[3 - 1], &row[2 - 1], &row[1 - 1]); + nistz384_point_double(&row[4 - 1], &row[2 - 1]); + nistz384_point_double(&row[6 - 1], &row[3 - 1]); + nistz384_point_double(&row[8 - 1], &row[4 - 1]); + nistz384_point_double(&row[12 - 1], &row[6 - 1]); + nistz384_point_add(&row[5 - 1], &row[4 - 1], &row[1 - 1]); + nistz384_point_add(&row[7 - 1], &row[6 - 1], &row[1 - 1]); + nistz384_point_add(&row[9 - 1], &row[8 - 1], &row[1 - 1]); + nistz384_point_add(&row[13 - 1], &row[12 - 1], &row[1 - 1]); + nistz384_point_double(&row[14 - 1], &row[7 - 1]); + nistz384_point_double(&row[10 - 1], &row[5 - 1]); + nistz384_point_add(&row[15 - 1], &row[14 - 1], &row[1 - 1]); + nistz384_point_add(&row[11 - 1], &row[10 - 1], &row[1 - 1]); + nistz384_point_double(&row[16 - 1], &row[8 - 1]); + + static const size_t START_INDEX = 384 - 4; + size_t index = START_INDEX; + + BN_ULONG recoded_is_negative; + crypto_word_t recoded; + + crypto_word_t wvalue = p_str[(index - 1) / 8]; + wvalue = (wvalue >> ((index - 1) % 8)) & kMask; + + booth_recode(&recoded_is_negative, &recoded, wvalue, 5); + dev_assert_secret(!recoded_is_negative); + + p384_point_select_w5(r, table, recoded); + + while (index >= kWindowSize) { + if (index != START_INDEX) { + size_t off = (index - 1) / 8; + + wvalue = p_str[off] | p_str[off + 1] << 8; + wvalue = (wvalue >> ((index - 1) % 8)) & kMask; + add_precomputed_w5(r, wvalue, table); + } + + index -= kWindowSize; + + nistz384_point_double(r, r); + nistz384_point_double(r, r); + nistz384_point_double(r, r); + nistz384_point_double(r, r); + nistz384_point_double(r, r); + } + + /* Final window */ + wvalue = p_str[0]; + wvalue = (wvalue << 1) & kMask; + add_precomputed_w5(r, wvalue, table); +} + +void p384_point_double(Limb r[3][P384_LIMBS], const Limb a[3][P384_LIMBS]) +{ + P384_POINT t; + limbs_copy(t.X, a[0], P384_LIMBS); + limbs_copy(t.Y, a[1], P384_LIMBS); + limbs_copy(t.Z, a[2], P384_LIMBS); + nistz384_point_double(&t, &t); + limbs_copy(r[0], t.X, P384_LIMBS); + limbs_copy(r[1], t.Y, P384_LIMBS); + limbs_copy(r[2], t.Z, P384_LIMBS); +} + +void p384_point_add(Limb r[3][P384_LIMBS], + const Limb a[3][P384_LIMBS], + const Limb b[3][P384_LIMBS]) +{ + P384_POINT t1; + limbs_copy(t1.X, a[0], P384_LIMBS); + limbs_copy(t1.Y, a[1], P384_LIMBS); + limbs_copy(t1.Z, a[2], P384_LIMBS); + + P384_POINT t2; + limbs_copy(t2.X, b[0], P384_LIMBS); + limbs_copy(t2.Y, b[1], P384_LIMBS); + limbs_copy(t2.Z, b[2], P384_LIMBS); + + nistz384_point_add(&t1, &t1, &t2); + + limbs_copy(r[0], t1.X, P384_LIMBS); + limbs_copy(r[1], t1.Y, P384_LIMBS); + limbs_copy(r[2], t1.Z, P384_LIMBS); +} + +void p384_point_mul(Limb r[3][P384_LIMBS], const BN_ULONG p_scalar[P384_LIMBS], + const Limb p_x[P384_LIMBS], const Limb p_y[P384_LIMBS]) { + alignas(64) P384_POINT acc; + nistz384_point_mul(&acc, p_scalar, p_x, p_y); + limbs_copy(r[0], acc.X, P384_LIMBS); + limbs_copy(r[1], acc.Y, P384_LIMBS); + limbs_copy(r[2], acc.Z, P384_LIMBS); +} + +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif diff --git a/http/vendor/ring/crypto/fipsmodule/ec/gfp_p256.c b/http/vendor/ring/crypto/fipsmodule/ec/gfp_p256.c new file mode 100644 index 0000000..2aa0ae2 --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/ec/gfp_p256.c @@ -0,0 +1,54 @@ +/* Copyright 2016 Brian Smith. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#include "./p256_shared.h" + +#include "../../limbs/limbs.h" + +#if !defined(OPENSSL_USE_NISTZ256) + +typedef Limb ScalarMont[P256_LIMBS]; +typedef Limb Scalar[P256_LIMBS]; + +#include "../bn/internal.h" + +static const BN_ULONG N[P256_LIMBS] = { +#if defined(OPENSSL_64_BIT) + 0xf3b9cac2fc632551, 0xbce6faada7179e84, 0xffffffffffffffff, 0xffffffff00000000 +#else + 0xfc632551, 0xf3b9cac2, 0xa7179e84, 0xbce6faad, 0xffffffff, 0xffffffff, 0, + 0xffffffff +#endif +}; + +static const BN_ULONG N_N0[] = { + BN_MONT_CTX_N0(0xccd1c8aa, 0xee00bc4f) +}; + +void p256_scalar_mul_mont(ScalarMont r, const ScalarMont a, + const ScalarMont b) { + /* XXX: Inefficient. TODO: optimize with dedicated multiplication routine. */ + bn_mul_mont_small(r, a, b, N, N_N0, P256_LIMBS); +} + +/* XXX: Inefficient. TODO: optimize with dedicated squaring routine. */ +void p256_scalar_sqr_rep_mont(ScalarMont r, const ScalarMont a, Limb rep) { + dev_assert_secret(rep >= 1); + p256_scalar_mul_mont(r, a, a); + for (Limb i = 1; i < rep; ++i) { + p256_scalar_mul_mont(r, r, r); + } +} + +#endif diff --git a/http/vendor/ring/crypto/fipsmodule/ec/gfp_p384.c b/http/vendor/ring/crypto/fipsmodule/ec/gfp_p384.c new file mode 100644 index 0000000..f9a66fa --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/ec/gfp_p384.c @@ -0,0 +1,246 @@ +/* Copyright 2016 Brian Smith. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#include "../../limbs/limbs.h" + +#include "ecp_nistz384.h" +#include "../bn/internal.h" +#include "../../internal.h" + +#include "../../limbs/limbs.inl" + + /* XXX: Here we assume that the conversion from |Carry| to |Limb| is + * constant-time, but we haven't verified that assumption. TODO: Fix it so + * we don't need to make that assumption. */ + + +typedef Limb Elem[P384_LIMBS]; +typedef Limb ScalarMont[P384_LIMBS]; +typedef Limb Scalar[P384_LIMBS]; + +static const BN_ULONG Q[P384_LIMBS] = { +#if defined(OPENSSL_64_BIT) + 0xffffffff, 0xffffffff00000000, 0xfffffffffffffffe, 0xffffffffffffffff, + 0xffffffffffffffff, 0xffffffffffffffff +#else + 0xffffffff, 0, 0, 0xffffffff, 0xfffffffe, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff +#endif +}; + +static const BN_ULONG N[P384_LIMBS] = { +#if defined(OPENSSL_64_BIT) + 0xecec196accc52973, 0x581a0db248b0a77a, 0xc7634d81f4372ddf, 0xffffffffffffffff, + 0xffffffffffffffff, 0xffffffffffffffff +#else + 0xccc52973, 0xecec196a, 0x48b0a77a, 0x581a0db2, 0xf4372ddf, 0xc7634d81, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff +#endif +}; + +static const BN_ULONG ONE[P384_LIMBS] = { +#if defined(OPENSSL_64_BIT) + 0xffffffff00000001, 0xffffffff, 1, 0, 0 +#else + 1, 0xffffffff, 0xffffffff, 0, 1, 0, 0, 0, 0, 0 +#endif +}; + +static const Elem Q_PLUS_1_SHR_1 = { +#if defined(OPENSSL_64_BIT) + 0x80000000, 0x7fffffff80000000, 0xffffffffffffffff, 0xffffffffffffffff, + 0xffffffffffffffff, 0x7fffffffffffffff +#else + 0x80000000, 0, 0x80000000, 0x7fffffff, 0xffffffff, 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x7fffffff +#endif +}; + +static const BN_ULONG Q_N0[] = { + BN_MONT_CTX_N0(1, 1) +}; + +static const BN_ULONG N_N0[] = { + BN_MONT_CTX_N0(0x6ed46089, 0xe88fdc45) +}; + +/* XXX: MSVC for x86 warns when it fails to inline these functions it should + * probably inline. */ +#if defined(_MSC_VER) && !defined(__clang__) && defined(OPENSSL_X86) +#define INLINE_IF_POSSIBLE __forceinline +#else +#define INLINE_IF_POSSIBLE inline +#endif + +static inline Limb is_equal(const Elem a, const Elem b) { + return LIMBS_equal(a, b, P384_LIMBS); +} + +static inline Limb is_zero(const BN_ULONG a[P384_LIMBS]) { + return LIMBS_are_zero(a, P384_LIMBS); +} + +static inline void copy_conditional(Elem r, const Elem a, + const Limb condition) { + for (size_t i = 0; i < P384_LIMBS; ++i) { + r[i] = constant_time_select_w(condition, a[i], r[i]); + } +} + + +static inline void elem_add(Elem r, const Elem a, const Elem b) { + LIMBS_add_mod(r, a, b, Q, P384_LIMBS); +} + +static inline void elem_sub(Elem r, const Elem a, const Elem b) { + LIMBS_sub_mod(r, a, b, Q, P384_LIMBS); +} + +static void elem_div_by_2(Elem r, const Elem a) { + /* Consider the case where `a` is even. Then we can shift `a` right one bit + * and the result will still be valid because we didn't lose any bits and so + * `(a >> 1) * 2 == a (mod q)`, which is the invariant we must satisfy. + * + * The remainder of this comment is considering the case where `a` is odd. + * + * Since `a` is odd, it isn't the case that `(a >> 1) * 2 == a (mod q)` + * because the lowest bit is lost during the shift. For example, consider: + * + * ```python + * q = 2**384 - 2**128 - 2**96 + 2**32 - 1 + * a = 2**383 + * two_a = a * 2 % q + * assert two_a == 0x100000000ffffffffffffffff00000001 + * ``` + * + * Notice there how `(2 * a) % q` wrapped around to a smaller odd value. When + * we divide `two_a` by two (mod q), we need to get the value `2**383`, which + * we obviously can't get with just a right shift. + * + * `q` is odd, and `a` is odd, so `a + q` is even. We could calculate + * `(a + q) >> 1` and then reduce it mod `q`. However, then we would have to + * keep track of an extra most significant bit. We can avoid that by instead + * calculating `(a >> 1) + ((q + 1) >> 1)`. The `1` in `q + 1` is the least + * significant bit of `a`. `q + 1` is even, which means it can be shifted + * without losing any bits. Since `q` is odd, `q - 1` is even, so the largest + * odd field element is `q - 2`. Thus we know that `a <= q - 2`. We know + * `(q + 1) >> 1` is `(q + 1) / 2` since (`q + 1`) is even. The value of + * `a >> 1` is `(a - 1)/2` since the shift will drop the least significant + * bit of `a`, which is 1. Thus: + * + * sum = ((q + 1) >> 1) + (a >> 1) + * sum = (q + 1)/2 + (a >> 1) (substituting (q + 1)/2) + * <= (q + 1)/2 + (q - 2 - 1)/2 (substituting a <= q - 2) + * <= (q + 1)/2 + (q - 3)/2 (simplifying) + * <= (q + 1 + q - 3)/2 (factoring out the common divisor) + * <= (2q - 2)/2 (simplifying) + * <= q - 1 (simplifying) + * + * Thus, no reduction of the sum mod `q` is necessary. */ + + Limb is_odd = constant_time_is_nonzero_w(a[0] & 1); + + /* r = a >> 1. */ + Limb carry = a[P384_LIMBS - 1] & 1; + r[P384_LIMBS - 1] = a[P384_LIMBS - 1] >> 1; + for (size_t i = 1; i < P384_LIMBS; ++i) { + Limb new_carry = a[P384_LIMBS - i - 1]; + r[P384_LIMBS - i - 1] = + (a[P384_LIMBS - i - 1] >> 1) | (carry << (LIMB_BITS - 1)); + carry = new_carry; + } + + Elem adjusted; + BN_ULONG carry2 = limbs_add(adjusted, r, Q_PLUS_1_SHR_1, P384_LIMBS); + dev_assert_secret(carry2 == 0); + (void)carry2; + copy_conditional(r, adjusted, is_odd); +} + +static inline void elem_mul_mont(Elem r, const Elem a, const Elem b) { + /* XXX: Not (clearly) constant-time; inefficient.*/ + bn_mul_mont_small(r, a, b, Q, Q_N0, P384_LIMBS); +} + +static inline void elem_mul_by_2(Elem r, const Elem a) { + LIMBS_shl_mod(r, a, Q, P384_LIMBS); +} + +static INLINE_IF_POSSIBLE void elem_mul_by_3(Elem r, const Elem a) { + /* XXX: inefficient. TODO: Replace with an integrated shift + add. */ + Elem doubled; + elem_add(doubled, a, a); + elem_add(r, doubled, a); +} + +static inline void elem_sqr_mont(Elem r, const Elem a) { + /* XXX: Inefficient. TODO: Add a dedicated squaring routine. */ + elem_mul_mont(r, a, a); +} + +void p384_elem_sub(Elem r, const Elem a, const Elem b) { + elem_sub(r, a, b); +} + +void p384_elem_div_by_2(Elem r, const Elem a) { + elem_div_by_2(r, a); +} + +void p384_elem_mul_mont(Elem r, const Elem a, const Elem b) { + elem_mul_mont(r, a, b); +} + +void p384_elem_neg(Elem r, const Elem a) { + Limb is_zero = LIMBS_are_zero(a, P384_LIMBS); + Carry borrow = limbs_sub(r, Q, a, P384_LIMBS); + dev_assert_secret(borrow == 0); + (void)borrow; + for (size_t i = 0; i < P384_LIMBS; ++i) { + r[i] = constant_time_select_w(is_zero, 0, r[i]); + } +} + + +void p384_scalar_mul_mont(ScalarMont r, const ScalarMont a, + const ScalarMont b) { + /* XXX: Inefficient. TODO: Add dedicated multiplication routine. */ + bn_mul_mont_small(r, a, b, N, N_N0, P384_LIMBS); +} + + +/* TODO(perf): Optimize this. */ + +static void p384_point_select_w5(P384_POINT *out, + const P384_POINT table[16], size_t index) { + Elem x; limbs_zero(x, P384_LIMBS); + Elem y; limbs_zero(y, P384_LIMBS); + Elem z; limbs_zero(z, P384_LIMBS); + + // TODO: Rewrite in terms of |limbs_select|. + for (size_t i = 0; i < 16; ++i) { + crypto_word_t equal = constant_time_eq_w(index, (crypto_word_t)i + 1); + for (size_t j = 0; j < P384_LIMBS; ++j) { + x[j] = constant_time_select_w(equal, table[i].X[j], x[j]); + y[j] = constant_time_select_w(equal, table[i].Y[j], y[j]); + z[j] = constant_time_select_w(equal, table[i].Z[j], z[j]); + } + } + + limbs_copy(out->X, x, P384_LIMBS); + limbs_copy(out->Y, y, P384_LIMBS); + limbs_copy(out->Z, z, P384_LIMBS); +} + + +#include "ecp_nistz384.inl" diff --git a/http/vendor/ring/crypto/fipsmodule/ec/p256-nistz-table.h b/http/vendor/ring/crypto/fipsmodule/ec/p256-nistz-table.h new file mode 100644 index 0000000..03bf782 --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/ec/p256-nistz-table.h @@ -0,0 +1,9502 @@ +// Copyright 2014-2016 The OpenSSL Project Authors. All Rights Reserved. +// Copyright (c) 2015, Intel Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This is the precomputed constant time access table for the code in +// p256-nistz.c, for the default generator. The table consists of 37 +// subtables, each subtable contains 64 affine points. The affine points are +// encoded as eight uint64's, four for the x coordinate and four for the y. +// Both values are in little-endian order. There are 37 tables because a +// signed, 6-bit wNAF form of the scalar is used and ceil(256/(6 + 1)) = 37. +// Within each table there are 64 values because the 6-bit wNAF value can take +// 64 values, ignoring the sign bit, which is implemented by performing a +// negation of the affine point when required. We would like to align it to 2MB +// in order to increase the chances of using a large page but that appears to +// lead to invalid ELF files being produced. + +// This file is generated by make_tables.go. + +static const alignas(4096) PRECOMP256_ROW ecp_nistz256_precomputed[37] = { + {{{TOBN(0x79e730d4, 0x18a9143c), TOBN(0x75ba95fc, 0x5fedb601), + TOBN(0x79fb732b, 0x77622510), TOBN(0x18905f76, 0xa53755c6)}, + {TOBN(0xddf25357, 0xce95560a), TOBN(0x8b4ab8e4, 0xba19e45c), + TOBN(0xd2e88688, 0xdd21f325), TOBN(0x8571ff18, 0x25885d85)}}, + {{TOBN(0x850046d4, 0x10ddd64d), TOBN(0xaa6ae3c1, 0xa433827d), + TOBN(0x73220503, 0x8d1490d9), TOBN(0xf6bb32e4, 0x3dcf3a3b)}, + {TOBN(0x2f3648d3, 0x61bee1a5), TOBN(0x152cd7cb, 0xeb236ff8), + TOBN(0x19a8fb0e, 0x92042dbe), TOBN(0x78c57751, 0x0a5b8a3b)}}, + {{TOBN(0xffac3f90, 0x4eebc127), TOBN(0xb027f84a, 0x087d81fb), + TOBN(0x66ad77dd, 0x87cbbc98), TOBN(0x26936a3f, 0xb6ff747e)}, + {TOBN(0xb04c5c1f, 0xc983a7eb), TOBN(0x583e47ad, 0x0861fe1a), + TOBN(0x78820831, 0x1a2ee98e), TOBN(0xd5f06a29, 0xe587cc07)}}, + {{TOBN(0x74b0b50d, 0x46918dcc), TOBN(0x4650a6ed, 0xc623c173), + TOBN(0x0cdaacac, 0xe8100af2), TOBN(0x577362f5, 0x41b0176b)}, + {TOBN(0x2d96f24c, 0xe4cbaba6), TOBN(0x17628471, 0xfad6f447), + TOBN(0x6b6c36de, 0xe5ddd22e), TOBN(0x84b14c39, 0x4c5ab863)}}, + {{TOBN(0xbe1b8aae, 0xc45c61f5), TOBN(0x90ec649a, 0x94b9537d), + TOBN(0x941cb5aa, 0xd076c20c), TOBN(0xc9079605, 0x890523c8)}, + {TOBN(0xeb309b4a, 0xe7ba4f10), TOBN(0x73c568ef, 0xe5eb882b), + TOBN(0x3540a987, 0x7e7a1f68), TOBN(0x73a076bb, 0x2dd1e916)}}, + {{TOBN(0x40394737, 0x3e77664a), TOBN(0x55ae744f, 0x346cee3e), + TOBN(0xd50a961a, 0x5b17a3ad), TOBN(0x13074b59, 0x54213673)}, + {TOBN(0x93d36220, 0xd377e44b), TOBN(0x299c2b53, 0xadff14b5), + TOBN(0xf424d44c, 0xef639f11), TOBN(0xa4c9916d, 0x4a07f75f)}}, + {{TOBN(0x0746354e, 0xa0173b4f), TOBN(0x2bd20213, 0xd23c00f7), + TOBN(0xf43eaab5, 0x0c23bb08), TOBN(0x13ba5119, 0xc3123e03)}, + {TOBN(0x2847d030, 0x3f5b9d4d), TOBN(0x6742f2f2, 0x5da67bdd), + TOBN(0xef933bdc, 0x77c94195), TOBN(0xeaedd915, 0x6e240867)}}, + {{TOBN(0x27f14cd1, 0x9499a78f), TOBN(0x462ab5c5, 0x6f9b3455), + TOBN(0x8f90f02a, 0xf02cfc6b), TOBN(0xb763891e, 0xb265230d)}, + {TOBN(0xf59da3a9, 0x532d4977), TOBN(0x21e3327d, 0xcf9eba15), + TOBN(0x123c7b84, 0xbe60bbf0), TOBN(0x56ec12f2, 0x7706df76)}}, + {{TOBN(0x75c96e8f, 0x264e20e8), TOBN(0xabe6bfed, 0x59a7a841), + TOBN(0x2cc09c04, 0x44c8eb00), TOBN(0xe05b3080, 0xf0c4e16b)}, + {TOBN(0x1eb7777a, 0xa45f3314), TOBN(0x56af7bed, 0xce5d45e3), + TOBN(0x2b6e019a, 0x88b12f1a), TOBN(0x086659cd, 0xfd835f9b)}}, + {{TOBN(0x2c18dbd1, 0x9dc21ec8), TOBN(0x98f9868a, 0x0fcf8139), + TOBN(0x737d2cd6, 0x48250b49), TOBN(0xcc61c947, 0x24b3428f)}, + {TOBN(0x0c2b4078, 0x80dd9e76), TOBN(0xc43a8991, 0x383fbe08), + TOBN(0x5f7d2d65, 0x779be5d2), TOBN(0x78719a54, 0xeb3b4ab5)}}, + {{TOBN(0xea7d260a, 0x6245e404), TOBN(0x9de40795, 0x6e7fdfe0), + TOBN(0x1ff3a415, 0x8dac1ab5), TOBN(0x3e7090f1, 0x649c9073)}, + {TOBN(0x1a768561, 0x2b944e88), TOBN(0x250f939e, 0xe57f61c8), + TOBN(0x0c0daa89, 0x1ead643d), TOBN(0x68930023, 0xe125b88e)}}, + {{TOBN(0x04b71aa7, 0xd2697768), TOBN(0xabdedef5, 0xca345a33), + TOBN(0x2409d29d, 0xee37385e), TOBN(0x4ee1df77, 0xcb83e156)}, + {TOBN(0x0cac12d9, 0x1cbb5b43), TOBN(0x170ed2f6, 0xca895637), + TOBN(0x28228cfa, 0x8ade6d66), TOBN(0x7ff57c95, 0x53238aca)}}, + {{TOBN(0xccc42563, 0x4b2ed709), TOBN(0x0e356769, 0x856fd30d), + TOBN(0xbcbcd43f, 0x559e9811), TOBN(0x738477ac, 0x5395b759)}, + {TOBN(0x35752b90, 0xc00ee17f), TOBN(0x68748390, 0x742ed2e3), + TOBN(0x7cd06422, 0xbd1f5bc1), TOBN(0xfbc08769, 0xc9e7b797)}}, + {{TOBN(0xa242a35b, 0xb0cf664a), TOBN(0x126e48f7, 0x7f9707e3), + TOBN(0x1717bf54, 0xc6832660), TOBN(0xfaae7332, 0xfd12c72e)}, + {TOBN(0x27b52db7, 0x995d586b), TOBN(0xbe29569e, 0x832237c2), + TOBN(0xe8e4193e, 0x2a65e7db), TOBN(0x152706dc, 0x2eaa1bbb)}}, + {{TOBN(0x72bcd8b7, 0xbc60055b), TOBN(0x03cc23ee, 0x56e27e4b), + TOBN(0xee337424, 0xe4819370), TOBN(0xe2aa0e43, 0x0ad3da09)}, + {TOBN(0x40b8524f, 0x6383c45d), TOBN(0xd7663554, 0x42a41b25), + TOBN(0x64efa6de, 0x778a4797), TOBN(0x2042170a, 0x7079adf4)}}, + {{TOBN(0x808b0b65, 0x0bc6fb80), TOBN(0x5882e075, 0x3ffe2e6b), + TOBN(0xd5ef2f7c, 0x2c83f549), TOBN(0x54d63c80, 0x9103b723)}, + {TOBN(0xf2f11bd6, 0x52a23f9b), TOBN(0x3670c319, 0x4b0b6587), + TOBN(0x55c4623b, 0xb1580e9e), TOBN(0x64edf7b2, 0x01efe220)}}, + {{TOBN(0x97091dcb, 0xd53c5c9d), TOBN(0xf17624b6, 0xac0a177b), + TOBN(0xb0f13975, 0x2cfe2dff), TOBN(0xc1a35c0a, 0x6c7a574e)}, + {TOBN(0x227d3146, 0x93e79987), TOBN(0x0575bf30, 0xe89cb80e), + TOBN(0x2f4e247f, 0x0d1883bb), TOBN(0xebd51226, 0x3274c3d0)}}, + {{TOBN(0x5f3e51c8, 0x56ada97a), TOBN(0x4afc964d, 0x8f8b403e), + TOBN(0xa6f247ab, 0x412e2979), TOBN(0x675abd1b, 0x6f80ebda)}, + {TOBN(0x66a2bd72, 0x5e485a1d), TOBN(0x4b2a5caf, 0x8f4f0b3c), + TOBN(0x2626927f, 0x1b847bba), TOBN(0x6c6fc7d9, 0x0502394d)}}, + {{TOBN(0xfea912ba, 0xa5659ae8), TOBN(0x68363aba, 0x25e1a16e), + TOBN(0xb8842277, 0x752c41ac), TOBN(0xfe545c28, 0x2897c3fc)}, + {TOBN(0x2d36e9e7, 0xdc4c696b), TOBN(0x5806244a, 0xfba977c5), + TOBN(0x85665e9b, 0xe39508c1), TOBN(0xf720ee25, 0x6d12597b)}}, + {{TOBN(0x8a979129, 0xd2337a31), TOBN(0x5916868f, 0x0f862bdc), + TOBN(0x048099d9, 0x5dd283ba), TOBN(0xe2d1eeb6, 0xfe5bfb4e)}, + {TOBN(0x82ef1c41, 0x7884005d), TOBN(0xa2d4ec17, 0xffffcbae), + TOBN(0x9161c53f, 0x8aa95e66), TOBN(0x5ee104e1, 0xc5fee0d0)}}, + {{TOBN(0x562e4cec, 0xc135b208), TOBN(0x74e1b265, 0x4783f47d), + TOBN(0x6d2a506c, 0x5a3f3b30), TOBN(0xecead9f4, 0xc16762fc)}, + {TOBN(0xf29dd4b2, 0xe286e5b9), TOBN(0x1b0fadc0, 0x83bb3c61), + TOBN(0x7a75023e, 0x7fac29a4), TOBN(0xc086d5f1, 0xc9477fa3)}}, + {{TOBN(0x0fc61135, 0x2f6f3076), TOBN(0xc99ffa23, 0xe3912a9a), + TOBN(0x6a0b0685, 0xd2f8ba3d), TOBN(0xfdc777e8, 0xe93358a4)}, + {TOBN(0x94a787bb, 0x35415f04), TOBN(0x640c2d6a, 0x4d23fea4), + TOBN(0x9de917da, 0x153a35b5), TOBN(0x793e8d07, 0x5d5cd074)}}, + {{TOBN(0xf4f87653, 0x2de45068), TOBN(0x37c7a7e8, 0x9e2e1f6e), + TOBN(0xd0825fa2, 0xa3584069), TOBN(0xaf2cea7c, 0x1727bf42)}, + {TOBN(0x0360a4fb, 0x9e4785a9), TOBN(0xe5fda49c, 0x27299f4a), + TOBN(0x48068e13, 0x71ac2f71), TOBN(0x83d0687b, 0x9077666f)}}, + {{TOBN(0x6d3883b2, 0x15d02819), TOBN(0x6d0d7550, 0x40dd9a35), + TOBN(0x61d7cbf9, 0x1d2b469f), TOBN(0xf97b232f, 0x2efc3115)}, + {TOBN(0xa551d750, 0xb24bcbc7), TOBN(0x11ea4949, 0x88a1e356), + TOBN(0x7669f031, 0x93cb7501), TOBN(0x595dc55e, 0xca737b8a)}}, + {{TOBN(0xa4a319ac, 0xd837879f), TOBN(0x6fc1b49e, 0xed6b67b0), + TOBN(0xe3959933, 0x32f1f3af), TOBN(0x966742eb, 0x65432a2e)}, + {TOBN(0x4b8dc9fe, 0xb4966228), TOBN(0x96cc6312, 0x43f43950), + TOBN(0x12068859, 0xc9b731ee), TOBN(0x7b948dc3, 0x56f79968)}}, + {{TOBN(0x61e4ad32, 0xed1f8008), TOBN(0xe6c9267a, 0xd8b17538), + TOBN(0x1ac7c5eb, 0x857ff6fb), TOBN(0x994baaa8, 0x55f2fb10)}, + {TOBN(0x84cf14e1, 0x1d248018), TOBN(0x5a39898b, 0x628ac508), + TOBN(0x14fde97b, 0x5fa944f5), TOBN(0xed178030, 0xd12e5ac7)}}, + {{TOBN(0x042c2af4, 0x97e2feb4), TOBN(0xd36a42d7, 0xaebf7313), + TOBN(0x49d2c9eb, 0x084ffdd7), TOBN(0x9f8aa54b, 0x2ef7c76a)}, + {TOBN(0x9200b7ba, 0x09895e70), TOBN(0x3bd0c66f, 0xddb7fb58), + TOBN(0x2d97d108, 0x78eb4cbb), TOBN(0x2d431068, 0xd84bde31)}}, + {{TOBN(0x4b523eb7, 0x172ccd1f), TOBN(0x7323cb28, 0x30a6a892), + TOBN(0x97082ec0, 0xcfe153eb), TOBN(0xe97f6b6a, 0xf2aadb97)}, + {TOBN(0x1d3d393e, 0xd1a83da1), TOBN(0xa6a7f9c7, 0x804b2a68), + TOBN(0x4a688b48, 0x2d0cb71e), TOBN(0xa9b4cc5f, 0x40585278)}}, + {{TOBN(0x5e5db46a, 0xcb66e132), TOBN(0xf1be963a, 0x0d925880), + TOBN(0x944a7027, 0x0317b9e2), TOBN(0xe266f959, 0x48603d48)}, + {TOBN(0x98db6673, 0x5c208899), TOBN(0x90472447, 0xa2fb18a3), + TOBN(0x8a966939, 0x777c619f), TOBN(0x3798142a, 0x2a3be21b)}}, + {{TOBN(0xb4241cb1, 0x3298b343), TOBN(0xa3a14e49, 0xb44f65a1), + TOBN(0xc5f4d6cd, 0x3ac77acd), TOBN(0xd0288cb5, 0x52b6fc3c)}, + {TOBN(0xd5cc8c2f, 0x1c040abc), TOBN(0xb675511e, 0x06bf9b4a), + TOBN(0xd667da37, 0x9b3aa441), TOBN(0x460d45ce, 0x51601f72)}}, + {{TOBN(0xe2f73c69, 0x6755ff89), TOBN(0xdd3cf7e7, 0x473017e6), + TOBN(0x8ef5689d, 0x3cf7600d), TOBN(0x948dc4f8, 0xb1fc87b4)}, + {TOBN(0xd9e9fe81, 0x4ea53299), TOBN(0x2d921ca2, 0x98eb6028), + TOBN(0xfaecedfd, 0x0c9803fc), TOBN(0xf38ae891, 0x4d7b4745)}}, + {{TOBN(0xd8c5fccf, 0xc5e3a3d8), TOBN(0xbefd904c, 0x4079dfbf), + TOBN(0xbc6d6a58, 0xfead0197), TOBN(0x39227077, 0x695532a4)}, + {TOBN(0x09e23e6d, 0xdbef42f5), TOBN(0x7e449b64, 0x480a9908), + TOBN(0x7b969c1a, 0xad9a2e40), TOBN(0x6231d792, 0x9591c2a4)}}, + {{TOBN(0x87151456, 0x0f664534), TOBN(0x85ceae7c, 0x4b68f103), + TOBN(0xac09c4ae, 0x65578ab9), TOBN(0x33ec6868, 0xf044b10c)}, + {TOBN(0x6ac4832b, 0x3a8ec1f1), TOBN(0x5509d128, 0x5847d5ef), + TOBN(0xf909604f, 0x763f1574), TOBN(0xb16c4303, 0xc32f63c4)}}, + {{TOBN(0xb6ab2014, 0x7ca23cd3), TOBN(0xcaa7a5c6, 0xa391849d), + TOBN(0x5b0673a3, 0x75678d94), TOBN(0xc982ddd4, 0xdd303e64)}, + {TOBN(0xfd7b000b, 0x5db6f971), TOBN(0xbba2cb1f, 0x6f876f92), + TOBN(0xc77332a3, 0x3c569426), TOBN(0xa159100c, 0x570d74f8)}}, + {{TOBN(0xfd16847f, 0xdec67ef5), TOBN(0x742ee464, 0x233e76b7), + TOBN(0x0b8e4134, 0xefc2b4c8), TOBN(0xca640b86, 0x42a3e521)}, + {TOBN(0x653a0190, 0x8ceb6aa9), TOBN(0x313c300c, 0x547852d5), + TOBN(0x24e4ab12, 0x6b237af7), TOBN(0x2ba90162, 0x8bb47af8)}}, + {{TOBN(0x3d5e58d6, 0xa8219bb7), TOBN(0xc691d0bd, 0x1b06c57f), + TOBN(0x0ae4cb10, 0xd257576e), TOBN(0x3569656c, 0xd54a3dc3)}, + {TOBN(0xe5ebaebd, 0x94cda03a), TOBN(0x934e82d3, 0x162bfe13), + TOBN(0x450ac0ba, 0xe251a0c6), TOBN(0x480b9e11, 0xdd6da526)}}, + {{TOBN(0x00467bc5, 0x8cce08b5), TOBN(0xb636458c, 0x7f178d55), + TOBN(0xc5748bae, 0xa677d806), TOBN(0x2763a387, 0xdfa394eb)}, + {TOBN(0xa12b448a, 0x7d3cebb6), TOBN(0xe7adda3e, 0x6f20d850), + TOBN(0xf63ebce5, 0x1558462c), TOBN(0x58b36143, 0x620088a8)}}, + {{TOBN(0x8a2cc3ca, 0x4d63c0ee), TOBN(0x51233117, 0x0fe948ce), + TOBN(0x7463fd85, 0x222ef33b), TOBN(0xadf0c7dc, 0x7c603d6c)}, + {TOBN(0x0ec32d3b, 0xfe7765e5), TOBN(0xccaab359, 0xbf380409), + TOBN(0xbdaa84d6, 0x8e59319c), TOBN(0xd9a4c280, 0x9c80c34d)}}, + {{TOBN(0xa9d89488, 0xa059c142), TOBN(0x6f5ae714, 0xff0b9346), + TOBN(0x068f237d, 0x16fb3664), TOBN(0x5853e4c4, 0x363186ac)}, + {TOBN(0xe2d87d23, 0x63c52f98), TOBN(0x2ec4a766, 0x81828876), + TOBN(0x47b864fa, 0xe14e7b1c), TOBN(0x0c0bc0e5, 0x69192408)}}, + {{TOBN(0xe4d7681d, 0xb82e9f3e), TOBN(0x83200f0b, 0xdf25e13c), + TOBN(0x8909984c, 0x66f27280), TOBN(0x462d7b00, 0x75f73227)}, + {TOBN(0xd90ba188, 0xf2651798), TOBN(0x74c6e18c, 0x36ab1c34), + TOBN(0xab256ea3, 0x5ef54359), TOBN(0x03466612, 0xd1aa702f)}}, + {{TOBN(0x624d6049, 0x2ed22e91), TOBN(0x6fdfe0b5, 0x6f072822), + TOBN(0xeeca1115, 0x39ce2271), TOBN(0x98100a4f, 0xdb01614f)}, + {TOBN(0xb6b0daa2, 0xa35c628f), TOBN(0xb6f94d2e, 0xc87e9a47), + TOBN(0xc6773259, 0x1d57d9ce), TOBN(0xf70bfeec, 0x03884a7b)}}, + {{TOBN(0x5fb35ccf, 0xed2bad01), TOBN(0xa155cbe3, 0x1da6a5c7), + TOBN(0xc2e2594c, 0x30a92f8f), TOBN(0x649c89ce, 0x5bfafe43)}, + {TOBN(0xd158667d, 0xe9ff257a), TOBN(0x9b359611, 0xf32c50ae), + TOBN(0x4b00b20b, 0x906014cf), TOBN(0xf3a8cfe3, 0x89bc7d3d)}}, + {{TOBN(0x4ff23ffd, 0x248a7d06), TOBN(0x80c5bfb4, 0x878873fa), + TOBN(0xb7d9ad90, 0x05745981), TOBN(0x179c85db, 0x3db01994)}, + {TOBN(0xba41b062, 0x61a6966c), TOBN(0x4d82d052, 0xeadce5a8), + TOBN(0x9e91cd3b, 0xa5e6a318), TOBN(0x47795f4f, 0x95b2dda0)}}, + {{TOBN(0xecfd7c1f, 0xd55a897c), TOBN(0x009194ab, 0xb29110fb), + TOBN(0x5f0e2046, 0xe381d3b0), TOBN(0x5f3425f6, 0xa98dd291)}, + {TOBN(0xbfa06687, 0x730d50da), TOBN(0x0423446c, 0x4b083b7f), + TOBN(0x397a247d, 0xd69d3417), TOBN(0xeb629f90, 0x387ba42a)}}, + {{TOBN(0x1ee426cc, 0xd5cd79bf), TOBN(0x0032940b, 0x946c6e18), + TOBN(0x1b1e8ae0, 0x57477f58), TOBN(0xe94f7d34, 0x6d823278)}, + {TOBN(0xc747cb96, 0x782ba21a), TOBN(0xc5254469, 0xf72b33a5), + TOBN(0x772ef6de, 0xc7f80c81), TOBN(0xd73acbfe, 0x2cd9e6b5)}}, + {{TOBN(0x4075b5b1, 0x49ee90d9), TOBN(0x785c339a, 0xa06e9eba), + TOBN(0xa1030d5b, 0xabf825e0), TOBN(0xcec684c3, 0xa42931dc)}, + {TOBN(0x42ab62c9, 0xc1586e63), TOBN(0x45431d66, 0x5ab43f2b), + TOBN(0x57c8b2c0, 0x55f7835d), TOBN(0x033da338, 0xc1b7f865)}}, + {{TOBN(0x283c7513, 0xcaa76097), TOBN(0x0a624fa9, 0x36c83906), + TOBN(0x6b20afec, 0x715af2c7), TOBN(0x4b969974, 0xeba78bfd)}, + {TOBN(0x220755cc, 0xd921d60e), TOBN(0x9b944e10, 0x7baeca13), + TOBN(0x04819d51, 0x5ded93d4), TOBN(0x9bbff86e, 0x6dddfd27)}}, + {{TOBN(0x6b344130, 0x77adc612), TOBN(0xa7496529, 0xbbd803a0), + TOBN(0x1a1baaa7, 0x6d8805bd), TOBN(0xc8403902, 0x470343ad)}, + {TOBN(0x39f59f66, 0x175adff1), TOBN(0x0b26d7fb, 0xb7d8c5b7), + TOBN(0xa875f5ce, 0x529d75e3), TOBN(0x85efc7e9, 0x41325cc2)}}, + {{TOBN(0x21950b42, 0x1ff6acd3), TOBN(0xffe70484, 0x53dc6909), + TOBN(0xff4cd0b2, 0x28766127), TOBN(0xabdbe608, 0x4fb7db2b)}, + {TOBN(0x837c9228, 0x5e1109e8), TOBN(0x26147d27, 0xf4645b5a), + TOBN(0x4d78f592, 0xf7818ed8), TOBN(0xd394077e, 0xf247fa36)}}, + {{TOBN(0x0fb9c2d0, 0x488c171a), TOBN(0xa78bfbaa, 0x13685278), + TOBN(0xedfbe268, 0xd5b1fa6a), TOBN(0x0dceb8db, 0x2b7eaba7)}, + {TOBN(0xbf9e8089, 0x9ae2b710), TOBN(0xefde7ae6, 0xa4449c96), + TOBN(0x43b7716b, 0xcc143a46), TOBN(0xd7d34194, 0xc3628c13)}}, + {{TOBN(0x508cec1c, 0x3b3f64c9), TOBN(0xe20bc0ba, 0x1e5edf3f), + TOBN(0xda1deb85, 0x2f4318d4), TOBN(0xd20ebe0d, 0x5c3fa443)}, + {TOBN(0x370b4ea7, 0x73241ea3), TOBN(0x61f1511c, 0x5e1a5f65), + TOBN(0x99a5e23d, 0x82681c62), TOBN(0xd731e383, 0xa2f54c2d)}}, + {{TOBN(0x2692f36e, 0x83445904), TOBN(0x2e0ec469, 0xaf45f9c0), + TOBN(0x905a3201, 0xc67528b7), TOBN(0x88f77f34, 0xd0e5e542)}, + {TOBN(0xf67a8d29, 0x5864687c), TOBN(0x23b92eae, 0x22df3562), + TOBN(0x5c27014b, 0x9bbec39e), TOBN(0x7ef2f226, 0x9c0f0f8d)}}, + {{TOBN(0x97359638, 0x546c4d8d), TOBN(0x5f9c3fc4, 0x92f24679), + TOBN(0x912e8bed, 0xa8c8acd9), TOBN(0xec3a318d, 0x306634b0)}, + {TOBN(0x80167f41, 0xc31cb264), TOBN(0x3db82f6f, 0x522113f2), + TOBN(0xb155bcd2, 0xdcafe197), TOBN(0xfba1da59, 0x43465283)}}, + {{TOBN(0xa0425b8e, 0xb212cf53), TOBN(0x4f2e512e, 0xf8557c5f), + TOBN(0xc1286ff9, 0x25c4d56c), TOBN(0xbb8a0fea, 0xee26c851)}, + {TOBN(0xc28f70d2, 0xe7d6107e), TOBN(0x7ee0c444, 0xe76265aa), + TOBN(0x3df277a4, 0x1d1936b1), TOBN(0x1a556e3f, 0xea9595eb)}}, + {{TOBN(0x258bbbf9, 0xe7305683), TOBN(0x31eea5bf, 0x07ef5be6), + TOBN(0x0deb0e4a, 0x46c814c1), TOBN(0x5cee8449, 0xa7b730dd)}, + {TOBN(0xeab495c5, 0xa0182bde), TOBN(0xee759f87, 0x9e27a6b4), + TOBN(0xc2cf6a68, 0x80e518ca), TOBN(0x25e8013f, 0xf14cf3f4)}}, + {{TOBN(0x8fc44140, 0x7e8d7a14), TOBN(0xbb1ff3ca, 0x9556f36a), + TOBN(0x6a844385, 0x14600044), TOBN(0xba3f0c4a, 0x7451ae63)}, + {TOBN(0xdfcac25b, 0x1f9af32a), TOBN(0x01e0db86, 0xb1f2214b), + TOBN(0x4e9a5bc2, 0xa4b596ac), TOBN(0x83927681, 0x026c2c08)}}, + {{TOBN(0x3ec832e7, 0x7acaca28), TOBN(0x1bfeea57, 0xc7385b29), + TOBN(0x068212e3, 0xfd1eaf38), TOBN(0xc1329830, 0x6acf8ccc)}, + {TOBN(0xb909f2db, 0x2aac9e59), TOBN(0x5748060d, 0xb661782a), + TOBN(0xc5ab2632, 0xc79b7a01), TOBN(0xda44c6c6, 0x00017626)}}, + {{TOBN(0xf26c00e8, 0xa7ea82f0), TOBN(0x99cac80d, 0xe4299aaf), + TOBN(0xd66fe3b6, 0x7ed78be1), TOBN(0x305f725f, 0x648d02cd)}, + {TOBN(0x33ed1bc4, 0x623fb21b), TOBN(0xfa70533e, 0x7a6319ad), + TOBN(0x17ab562d, 0xbe5ffb3e), TOBN(0x06374994, 0x56674741)}}, + {{TOBN(0x69d44ed6, 0x5c46aa8e), TOBN(0x2100d5d3, 0xa8d063d1), + TOBN(0xcb9727ea, 0xa2d17c36), TOBN(0x4c2bab1b, 0x8add53b7)}, + {TOBN(0xa084e90c, 0x15426704), TOBN(0x778afcd3, 0xa837ebea), + TOBN(0x6651f701, 0x7ce477f8), TOBN(0xa0624998, 0x46fb7a8b)}}, + {{TOBN(0xdc1e6828, 0xed8a6e19), TOBN(0x33fc2336, 0x4189d9c7), + TOBN(0x026f8fe2, 0x671c39bc), TOBN(0xd40c4ccd, 0xbc6f9915)}, + {TOBN(0xafa135bb, 0xf80e75ca), TOBN(0x12c651a0, 0x22adff2c), + TOBN(0xc40a04bd, 0x4f51ad96), TOBN(0x04820109, 0xbbe4e832)}}, + {{TOBN(0x3667eb1a, 0x7f4c04cc), TOBN(0x59556621, 0xa9404f84), + TOBN(0x71cdf653, 0x7eceb50a), TOBN(0x994a44a6, 0x9b8335fa)}, + {TOBN(0xd7faf819, 0xdbeb9b69), TOBN(0x473c5680, 0xeed4350d), + TOBN(0xb6658466, 0xda44bba2), TOBN(0x0d1bc780, 0x872bdbf3)}}, + {{TOBN(0xe535f175, 0xa1962f91), TOBN(0x6ed7e061, 0xed58f5a7), + TOBN(0x177aa4c0, 0x2089a233), TOBN(0x0dbcb03a, 0xe539b413)}, + {TOBN(0xe3dc424e, 0xbb32e38e), TOBN(0x6472e5ef, 0x6806701e), + TOBN(0xdd47ff98, 0x814be9ee), TOBN(0x6b60cfff, 0x35ace009)}}, + {{TOBN(0xb8d3d931, 0x9ff91fe5), TOBN(0x039c4800, 0xf0518eed), + TOBN(0x95c37632, 0x9182cb26), TOBN(0x0763a434, 0x82fc568d)}, + {TOBN(0x707c04d5, 0x383e76ba), TOBN(0xac98b930, 0x824e8197), + TOBN(0x92bf7c8f, 0x91230de0), TOBN(0x90876a01, 0x40959b70)}}, + {{TOBN(0xdb6d96f3, 0x05968b80), TOBN(0x380a0913, 0x089f73b9), + TOBN(0x7da70b83, 0xc2c61e01), TOBN(0x95fb8394, 0x569b38c7)}, + {TOBN(0x9a3c6512, 0x80edfe2f), TOBN(0x8f726bb9, 0x8faeaf82), + TOBN(0x8010a4a0, 0x78424bf8), TOBN(0x29672044, 0x0e844970)}}}, + {{{TOBN(0x63c5cb81, 0x7a2ad62a), TOBN(0x7ef2b6b9, 0xac62ff54), + TOBN(0x3749bba4, 0xb3ad9db5), TOBN(0xad311f2c, 0x46d5a617)}, + {TOBN(0xb77a8087, 0xc2ff3b6d), TOBN(0xb46feaf3, 0x367834ff), + TOBN(0xf8aa266d, 0x75d6b138), TOBN(0xfa38d320, 0xec008188)}}, + {{TOBN(0x486d8ffa, 0x696946fc), TOBN(0x50fbc6d8, 0xb9cba56d), + TOBN(0x7e3d423e, 0x90f35a15), TOBN(0x7c3da195, 0xc0dd962c)}, + {TOBN(0xe673fdb0, 0x3cfd5d8b), TOBN(0x0704b7c2, 0x889dfca5), + TOBN(0xf6ce581f, 0xf52305aa), TOBN(0x399d49eb, 0x914d5e53)}}, + {{TOBN(0x380a496d, 0x6ec293cd), TOBN(0x733dbda7, 0x8e7051f5), + TOBN(0x037e388d, 0xb849140a), TOBN(0xee4b32b0, 0x5946dbf6)}, + {TOBN(0xb1c4fda9, 0xcae368d1), TOBN(0x5001a7b0, 0xfdb0b2f3), + TOBN(0x6df59374, 0x2e3ac46e), TOBN(0x4af675f2, 0x39b3e656)}}, + {{TOBN(0x44e38110, 0x39949296), TOBN(0x5b63827b, 0x361db1b5), + TOBN(0x3e5323ed, 0x206eaff5), TOBN(0x942370d2, 0xc21f4290)}, + {TOBN(0xf2caaf2e, 0xe0d985a1), TOBN(0x192cc64b, 0x7239846d), + TOBN(0x7c0b8f47, 0xae6312f8), TOBN(0x7dc61f91, 0x96620108)}}, + {{TOBN(0xb830fb5b, 0xc2da7de9), TOBN(0xd0e643df, 0x0ff8d3be), + TOBN(0x31ee77ba, 0x188a9641), TOBN(0x4e8aa3aa, 0xbcf6d502)}, + {TOBN(0xf9fb6532, 0x9a49110f), TOBN(0xd18317f6, 0x2dd6b220), + TOBN(0x7e3ced41, 0x52c3ea5a), TOBN(0x0d296a14, 0x7d579c4a)}}, + {{TOBN(0x35d6a53e, 0xed4c3717), TOBN(0x9f8240cf, 0x3d0ed2a3), + TOBN(0x8c0d4d05, 0xe5543aa5), TOBN(0x45d5bbfb, 0xdd33b4b4)}, + {TOBN(0xfa04cc73, 0x137fd28e), TOBN(0x862ac6ef, 0xc73b3ffd), + TOBN(0x403ff9f5, 0x31f51ef2), TOBN(0x34d5e0fc, 0xbc73f5a2)}}, + {{TOBN(0xf2526820, 0x08913f4f), TOBN(0xea20ed61, 0xeac93d95), + TOBN(0x51ed38b4, 0x6ca6b26c), TOBN(0x8662dcbc, 0xea4327b0)}, + {TOBN(0x6daf295c, 0x725d2aaa), TOBN(0xbad2752f, 0x8e52dcda), + TOBN(0x2210e721, 0x0b17dacc), TOBN(0xa37f7912, 0xd51e8232)}}, + {{TOBN(0x4f7081e1, 0x44cc3add), TOBN(0xd5ffa1d6, 0x87be82cf), + TOBN(0x89890b6c, 0x0edd6472), TOBN(0xada26e1a, 0x3ed17863)}, + {TOBN(0x276f2715, 0x63483caa), TOBN(0xe6924cd9, 0x2f6077fd), + TOBN(0x05a7fe98, 0x0a466e3c), TOBN(0xf1c794b0, 0xb1902d1f)}}, + {{TOBN(0xe5213688, 0x82a8042c), TOBN(0xd931cfaf, 0xcd278298), + TOBN(0x069a0ae0, 0xf597a740), TOBN(0x0adbb3f3, 0xeb59107c)}, + {TOBN(0x983e951e, 0x5eaa8eb8), TOBN(0xe663a8b5, 0x11b48e78), + TOBN(0x1631cc0d, 0x8a03f2c5), TOBN(0x7577c11e, 0x11e271e2)}}, + {{TOBN(0x33b2385c, 0x08369a90), TOBN(0x2990c59b, 0x190eb4f8), + TOBN(0x819a6145, 0xc68eac80), TOBN(0x7a786d62, 0x2ec4a014)}, + {TOBN(0x33faadbe, 0x20ac3a8d), TOBN(0x31a21781, 0x5aba2d30), + TOBN(0x209d2742, 0xdba4f565), TOBN(0xdb2ce9e3, 0x55aa0fbb)}}, + {{TOBN(0x8cef334b, 0x168984df), TOBN(0xe81dce17, 0x33879638), + TOBN(0xf6e6949c, 0x263720f0), TOBN(0x5c56feaf, 0xf593cbec)}, + {TOBN(0x8bff5601, 0xfde58c84), TOBN(0x74e24117, 0x2eccb314), + TOBN(0xbcf01b61, 0x4c9a8a78), TOBN(0xa233e35e, 0x544c9868)}}, + {{TOBN(0xb3156bf3, 0x8bd7aff1), TOBN(0x1b5ee4cb, 0x1d81b146), + TOBN(0x7ba1ac41, 0xd628a915), TOBN(0x8f3a8f9c, 0xfd89699e)}, + {TOBN(0x7329b9c9, 0xa0748be7), TOBN(0x1d391c95, 0xa92e621f), + TOBN(0xe51e6b21, 0x4d10a837), TOBN(0xd255f53a, 0x4947b435)}}, + {{TOBN(0x07669e04, 0xf1788ee3), TOBN(0xc14f27af, 0xa86938a2), + TOBN(0x8b47a334, 0xe93a01c0), TOBN(0xff627438, 0xd9366808)}, + {TOBN(0x7a0985d8, 0xca2a5965), TOBN(0x3d9a5542, 0xd6e9b9b3), + TOBN(0xc23eb80b, 0x4cf972e8), TOBN(0x5c1c33bb, 0x4fdf72fd)}}, + {{TOBN(0x0c4a58d4, 0x74a86108), TOBN(0xf8048a8f, 0xee4c5d90), + TOBN(0xe3c7c924, 0xe86d4c80), TOBN(0x28c889de, 0x056a1e60)}, + {TOBN(0x57e2662e, 0xb214a040), TOBN(0xe8c48e98, 0x37e10347), + TOBN(0x87742862, 0x80ac748a), TOBN(0xf1c24022, 0x186b06f2)}}, + {{TOBN(0xac2dd4c3, 0x5f74040a), TOBN(0x409aeb71, 0xfceac957), + TOBN(0x4fbad782, 0x55c4ec23), TOBN(0xb359ed61, 0x8a7b76ec)}, + {TOBN(0x12744926, 0xed6f4a60), TOBN(0xe21e8d7f, 0x4b912de3), + TOBN(0xe2575a59, 0xfc705a59), TOBN(0x72f1d4de, 0xed2dbc0e)}}, + {{TOBN(0x3d2b24b9, 0xeb7926b8), TOBN(0xbff88cb3, 0xcdbe5509), + TOBN(0xd0f399af, 0xe4dd640b), TOBN(0x3c5fe130, 0x2f76ed45)}, + {TOBN(0x6f3562f4, 0x3764fb3d), TOBN(0x7b5af318, 0x3151b62d), + TOBN(0xd5bd0bc7, 0xd79ce5f3), TOBN(0xfdaf6b20, 0xec66890f)}}, + {{TOBN(0x735c67ec, 0x6063540c), TOBN(0x50b259c2, 0xe5f9cb8f), + TOBN(0xb8734f9a, 0x3f99c6ab), TOBN(0xf8cc13d5, 0xa3a7bc85)}, + {TOBN(0x80c1b305, 0xc5217659), TOBN(0xfe5364d4, 0x4ec12a54), + TOBN(0xbd87045e, 0x681345fe), TOBN(0x7f8efeb1, 0x582f897f)}}, + {{TOBN(0xe8cbf1e5, 0xd5923359), TOBN(0xdb0cea9d, 0x539b9fb0), + TOBN(0x0c5b34cf, 0x49859b98), TOBN(0x5e583c56, 0xa4403cc6)}, + {TOBN(0x11fc1a2d, 0xd48185b7), TOBN(0xc93fbc7e, 0x6e521787), + TOBN(0x47e7a058, 0x05105b8b), TOBN(0x7b4d4d58, 0xdb8260c8)}}, + {{TOBN(0xe33930b0, 0x46eb842a), TOBN(0x8e844a9a, 0x7bdae56d), + TOBN(0x34ef3a9e, 0x13f7fdfc), TOBN(0xb3768f82, 0x636ca176)}, + {TOBN(0x2821f4e0, 0x4e09e61c), TOBN(0x414dc3a1, 0xa0c7cddc), + TOBN(0xd5379437, 0x54945fcd), TOBN(0x151b6eef, 0xb3555ff1)}}, + {{TOBN(0xb31bd613, 0x6339c083), TOBN(0x39ff8155, 0xdfb64701), + TOBN(0x7c3388d2, 0xe29604ab), TOBN(0x1e19084b, 0xa6b10442)}, + {TOBN(0x17cf54c0, 0xeccd47ef), TOBN(0x89693385, 0x4a5dfb30), + TOBN(0x69d023fb, 0x47daf9f6), TOBN(0x9222840b, 0x7d91d959)}}, + {{TOBN(0x439108f5, 0x803bac62), TOBN(0x0b7dd91d, 0x379bd45f), + TOBN(0xd651e827, 0xca63c581), TOBN(0x5c5d75f6, 0x509c104f)}, + {TOBN(0x7d5fc738, 0x1f2dc308), TOBN(0x20faa7bf, 0xd98454be), + TOBN(0x95374bee, 0xa517b031), TOBN(0xf036b9b1, 0x642692ac)}}, + {{TOBN(0xc5106109, 0x39842194), TOBN(0xb7e2353e, 0x49d05295), + TOBN(0xfc8c1d5c, 0xefb42ee0), TOBN(0xe04884eb, 0x08ce811c)}, + {TOBN(0xf1f75d81, 0x7419f40e), TOBN(0x5b0ac162, 0xa995c241), + TOBN(0x120921bb, 0xc4c55646), TOBN(0x713520c2, 0x8d33cf97)}}, + {{TOBN(0xb4a65a5c, 0xe98c5100), TOBN(0x6cec871d, 0x2ddd0f5a), + TOBN(0x251f0b7f, 0x9ba2e78b), TOBN(0x224a8434, 0xce3a2a5f)}, + {TOBN(0x26827f61, 0x25f5c46f), TOBN(0x6a22bedc, 0x48545ec0), + TOBN(0x25ae5fa0, 0xb1bb5cdc), TOBN(0xd693682f, 0xfcb9b98f)}}, + {{TOBN(0x32027fe8, 0x91e5d7d3), TOBN(0xf14b7d17, 0x73a07678), + TOBN(0xf88497b3, 0xc0dfdd61), TOBN(0xf7c2eec0, 0x2a8c4f48)}, + {TOBN(0xaa5573f4, 0x3756e621), TOBN(0xc013a240, 0x1825b948), + TOBN(0x1c03b345, 0x63878572), TOBN(0xa0472bea, 0x653a4184)}}, + {{TOBN(0xf4222e27, 0x0ac69a80), TOBN(0x34096d25, 0xf51e54f6), + TOBN(0x00a648cb, 0x8fffa591), TOBN(0x4e87acdc, 0x69b6527f)}, + {TOBN(0x0575e037, 0xe285ccb4), TOBN(0x188089e4, 0x50ddcf52), + TOBN(0xaa96c9a8, 0x870ff719), TOBN(0x74a56cd8, 0x1fc7e369)}}, + {{TOBN(0x41d04ee2, 0x1726931a), TOBN(0x0bbbb2c8, 0x3660ecfd), + TOBN(0xa6ef6de5, 0x24818e18), TOBN(0xe421cc51, 0xe7d57887)}, + {TOBN(0xf127d208, 0xbea87be6), TOBN(0x16a475d3, 0xb1cdd682), + TOBN(0x9db1b684, 0x439b63f7), TOBN(0x5359b3db, 0xf0f113b6)}}, + {{TOBN(0xdfccf1de, 0x8bf06e31), TOBN(0x1fdf8f44, 0xdd383901), + TOBN(0x10775cad, 0x5017e7d2), TOBN(0xdfc3a597, 0x58d11eef)}, + {TOBN(0x6ec9c8a0, 0xb1ecff10), TOBN(0xee6ed6cc, 0x28400549), + TOBN(0xb5ad7bae, 0x1b4f8d73), TOBN(0x61b4f11d, 0xe00aaab9)}}, + {{TOBN(0x7b32d69b, 0xd4eff2d7), TOBN(0x88ae6771, 0x4288b60f), + TOBN(0x159461b4, 0x37a1e723), TOBN(0x1f3d4789, 0x570aae8c)}, + {TOBN(0x869118c0, 0x7f9871da), TOBN(0x35fbda78, 0xf635e278), + TOBN(0x738f3641, 0xe1541dac), TOBN(0x6794b13a, 0xc0dae45f)}}, + {{TOBN(0x065064ac, 0x09cc0917), TOBN(0x27c53729, 0xc68540fd), + TOBN(0x0d2d4c8e, 0xef227671), TOBN(0xd23a9f80, 0xa1785a04)}, + {TOBN(0x98c59528, 0x52650359), TOBN(0xfa09ad01, 0x74a1acad), + TOBN(0x082d5a29, 0x0b55bf5c), TOBN(0xa40f1c67, 0x419b8084)}}, + {{TOBN(0x3a5c752e, 0xdcc18770), TOBN(0x4baf1f2f, 0x8825c3a5), + TOBN(0xebd63f74, 0x21b153ed), TOBN(0xa2383e47, 0xb2f64723)}, + {TOBN(0xe7bf620a, 0x2646d19a), TOBN(0x56cb44ec, 0x03c83ffd), + TOBN(0xaf7267c9, 0x4f6be9f1), TOBN(0x8b2dfd7b, 0xc06bb5e9)}}, + {{TOBN(0xb87072f2, 0xa672c5c7), TOBN(0xeacb11c8, 0x0d53c5e2), + TOBN(0x22dac29d, 0xff435932), TOBN(0x37bdb99d, 0x4408693c)}, + {TOBN(0xf6e62fb6, 0x2899c20f), TOBN(0x3535d512, 0x447ece24), + TOBN(0xfbdc6b88, 0xff577ce3), TOBN(0x726693bd, 0x190575f2)}}, + {{TOBN(0x6772b0e5, 0xab4b35a2), TOBN(0x1d8b6001, 0xf5eeaacf), + TOBN(0x728f7ce4, 0x795b9580), TOBN(0x4a20ed2a, 0x41fb81da)}, + {TOBN(0x9f685cd4, 0x4fec01e6), TOBN(0x3ed7ddcc, 0xa7ff50ad), + TOBN(0x460fd264, 0x0c2d97fd), TOBN(0x3a241426, 0xeb82f4f9)}}, + {{TOBN(0x17d1df2c, 0x6a8ea820), TOBN(0xb2b50d3b, 0xf22cc254), + TOBN(0x03856cba, 0xb7291426), TOBN(0x87fd26ae, 0x04f5ee39)}, + {TOBN(0x9cb696cc, 0x02bee4ba), TOBN(0x53121804, 0x06820fd6), + TOBN(0xa5dfc269, 0x0212e985), TOBN(0x666f7ffa, 0x160f9a09)}}, + {{TOBN(0xc503cd33, 0xbccd9617), TOBN(0x365dede4, 0xba7730a3), + TOBN(0x798c6355, 0x5ddb0786), TOBN(0xa6c3200e, 0xfc9cd3bc)}, + {TOBN(0x060ffb2c, 0xe5e35efd), TOBN(0x99a4e25b, 0x5555a1c1), + TOBN(0x11d95375, 0xf70b3751), TOBN(0x0a57354a, 0x160e1bf6)}}, + {{TOBN(0xecb3ae4b, 0xf8e4b065), TOBN(0x07a834c4, 0x2e53022b), + TOBN(0x1cd300b3, 0x8692ed96), TOBN(0x16a6f792, 0x61ee14ec)}, + {TOBN(0x8f1063c6, 0x6a8649ed), TOBN(0xfbcdfcfe, 0x869f3e14), + TOBN(0x2cfb97c1, 0x00a7b3ec), TOBN(0xcea49b3c, 0x7130c2f1)}}, + {{TOBN(0x462d044f, 0xe9d96488), TOBN(0x4b53d52e, 0x8182a0c1), + TOBN(0x84b6ddd3, 0x0391e9e9), TOBN(0x80ab7b48, 0xb1741a09)}, + {TOBN(0xec0e15d4, 0x27d3317f), TOBN(0x8dfc1ddb, 0x1a64671e), + TOBN(0x93cc5d5f, 0xd49c5b92), TOBN(0xc995d53d, 0x3674a331)}}, + {{TOBN(0x302e41ec, 0x090090ae), TOBN(0x2278a0cc, 0xedb06830), + TOBN(0x1d025932, 0xfbc99690), TOBN(0x0c32fbd2, 0xb80d68da)}, + {TOBN(0xd79146da, 0xf341a6c1), TOBN(0xae0ba139, 0x1bef68a0), + TOBN(0xc6b8a563, 0x8d774b3a), TOBN(0x1cf307bd, 0x880ba4d7)}}, + {{TOBN(0xc033bdc7, 0x19803511), TOBN(0xa9f97b3b, 0x8888c3be), + TOBN(0x3d68aebc, 0x85c6d05e), TOBN(0xc3b88a9d, 0x193919eb)}, + {TOBN(0x2d300748, 0xc48b0ee3), TOBN(0x7506bc7c, 0x07a746c1), + TOBN(0xfc48437c, 0x6e6d57f3), TOBN(0x5bd71587, 0xcfeaa91a)}}, + {{TOBN(0xa4ed0408, 0xc1bc5225), TOBN(0xd0b946db, 0x2719226d), + TOBN(0x109ecd62, 0x758d2d43), TOBN(0x75c8485a, 0x2751759b)}, + {TOBN(0xb0b75f49, 0x9ce4177a), TOBN(0x4fa61a1e, 0x79c10c3d), + TOBN(0xc062d300, 0xa167fcd7), TOBN(0x4df3874c, 0x750f0fa8)}}, + {{TOBN(0x29ae2cf9, 0x83dfedc9), TOBN(0xf8437134, 0x8d87631a), + TOBN(0xaf571711, 0x7429c8d2), TOBN(0x18d15867, 0x146d9272)}, + {TOBN(0x83053ecf, 0x69769bb7), TOBN(0xc55eb856, 0xc479ab82), + TOBN(0x5ef7791c, 0x21b0f4b2), TOBN(0xaa5956ba, 0x3d491525)}}, + {{TOBN(0x407a96c2, 0x9fe20eba), TOBN(0xf27168bb, 0xe52a5ad3), + TOBN(0x43b60ab3, 0xbf1d9d89), TOBN(0xe45c51ef, 0x710e727a)}, + {TOBN(0xdfca5276, 0x099b4221), TOBN(0x8dc6407c, 0x2557a159), + TOBN(0x0ead8335, 0x91035895), TOBN(0x0a9db957, 0x9c55dc32)}}, + {{TOBN(0xe40736d3, 0xdf61bc76), TOBN(0x13a619c0, 0x3f778cdb), + TOBN(0x6dd921a4, 0xc56ea28f), TOBN(0x76a52433, 0x2fa647b4)}, + {TOBN(0x23591891, 0xac5bdc5d), TOBN(0xff4a1a72, 0xbac7dc01), + TOBN(0x9905e261, 0x62df8453), TOBN(0x3ac045df, 0xe63b265f)}}, + {{TOBN(0x8a3f341b, 0xad53dba7), TOBN(0x8ec269cc, 0x837b625a), + TOBN(0xd71a2782, 0x3ae31189), TOBN(0x8fb4f9a3, 0x55e96120)}, + {TOBN(0x804af823, 0xff9875cf), TOBN(0x23224f57, 0x5d442a9b), + TOBN(0x1c4d3b9e, 0xecc62679), TOBN(0x91da22fb, 0xa0e7ddb1)}}, + {{TOBN(0xa370324d, 0x6c04a661), TOBN(0x9710d3b6, 0x5e376d17), + TOBN(0xed8c98f0, 0x3044e357), TOBN(0xc364ebbe, 0x6422701c)}, + {TOBN(0x347f5d51, 0x7733d61c), TOBN(0xd55644b9, 0xcea826c3), + TOBN(0x80c6e0ad, 0x55a25548), TOBN(0x0aa7641d, 0x844220a7)}}, + {{TOBN(0x1438ec81, 0x31810660), TOBN(0x9dfa6507, 0xde4b4043), + TOBN(0x10b515d8, 0xcc3e0273), TOBN(0x1b6066dd, 0x28d8cfb2)}, + {TOBN(0xd3b04591, 0x9c9efebd), TOBN(0x425d4bdf, 0xa21c1ff4), + TOBN(0x5fe5af19, 0xd57607d3), TOBN(0xbbf773f7, 0x54481084)}}, + {{TOBN(0x8435bd69, 0x94b03ed1), TOBN(0xd9ad1de3, 0x634cc546), + TOBN(0x2cf423fc, 0x00e420ca), TOBN(0xeed26d80, 0xa03096dd)}, + {TOBN(0xd7f60be7, 0xa4db09d2), TOBN(0xf47f569d, 0x960622f7), + TOBN(0xe5925fd7, 0x7296c729), TOBN(0xeff2db26, 0x26ca2715)}}, + {{TOBN(0xa6fcd014, 0xb913e759), TOBN(0x53da4786, 0x8ff4de93), + TOBN(0x14616d79, 0xc32068e1), TOBN(0xb187d664, 0xccdf352e)}, + {TOBN(0xf7afb650, 0x1dc90b59), TOBN(0x8170e943, 0x7daa1b26), + TOBN(0xc8e3bdd8, 0x700c0a84), TOBN(0x6e8d345f, 0x6482bdfa)}}, + {{TOBN(0x84cfbfa1, 0xc5c5ea50), TOBN(0xd3baf14c, 0x67960681), + TOBN(0x26398403, 0x0dd50942), TOBN(0xe4b7839c, 0x4716a663)}, + {TOBN(0xd5f1f794, 0xe7de6dc0), TOBN(0x5cd0f4d4, 0x622aa7ce), + TOBN(0x5295f3f1, 0x59acfeec), TOBN(0x8d933552, 0x953e0607)}}, + {{TOBN(0xc7db8ec5, 0x776c5722), TOBN(0xdc467e62, 0x2b5f290c), + TOBN(0xd4297e70, 0x4ff425a9), TOBN(0x4be924c1, 0x0cf7bb72)}, + {TOBN(0x0d5dc5ae, 0xa1892131), TOBN(0x8bf8a8e3, 0xa705c992), + TOBN(0x73a0b064, 0x7a305ac5), TOBN(0x00c9ca4e, 0x9a8c77a8)}}, + {{TOBN(0x5dfee80f, 0x83774bdd), TOBN(0x63131602, 0x85734485), + TOBN(0xa1b524ae, 0x914a69a9), TOBN(0xebc2ffaf, 0xd4e300d7)}, + {TOBN(0x52c93db7, 0x7cfa46a5), TOBN(0x71e6161f, 0x21653b50), + TOBN(0x3574fc57, 0xa4bc580a), TOBN(0xc09015dd, 0xe1bc1253)}}, + {{TOBN(0x4b7b47b2, 0xd174d7aa), TOBN(0x4072d8e8, 0xf3a15d04), + TOBN(0xeeb7d47f, 0xd6fa07ed), TOBN(0x6f2b9ff9, 0xedbdafb1)}, + {TOBN(0x18c51615, 0x3760fe8a), TOBN(0x7a96e6bf, 0xf06c6c13), + TOBN(0x4d7a0410, 0x0ea2d071), TOBN(0xa1914e9b, 0x0be2a5ce)}}, + {{TOBN(0x5726e357, 0xd8a3c5cf), TOBN(0x1197ecc3, 0x2abb2b13), + TOBN(0x6c0d7f7f, 0x31ae88dd), TOBN(0x15b20d1a, 0xfdbb3efe)}, + {TOBN(0xcd06aa26, 0x70584039), TOBN(0x2277c969, 0xa7dc9747), + TOBN(0xbca69587, 0x7855d815), TOBN(0x899ea238, 0x5188b32a)}}, + {{TOBN(0x37d9228b, 0x760c1c9d), TOBN(0xc7efbb11, 0x9b5c18da), + TOBN(0x7f0d1bc8, 0x19f6dbc5), TOBN(0x4875384b, 0x07e6905b)}, + {TOBN(0xc7c50baa, 0x3ba8cd86), TOBN(0xb0ce40fb, 0xc2905de0), + TOBN(0x70840673, 0x7a231952), TOBN(0xa912a262, 0xcf43de26)}}, + {{TOBN(0x9c38ddcc, 0xeb5b76c1), TOBN(0x746f5285, 0x26fc0ab4), + TOBN(0x52a63a50, 0xd62c269f), TOBN(0x60049c55, 0x99458621)}, + {TOBN(0xe7f48f82, 0x3c2f7c9e), TOBN(0x6bd99043, 0x917d5cf3), + TOBN(0xeb1317a8, 0x8701f469), TOBN(0xbd3fe2ed, 0x9a449fe0)}}, + {{TOBN(0x421e79ca, 0x12ef3d36), TOBN(0x9ee3c36c, 0x3e7ea5de), + TOBN(0xe48198b5, 0xcdff36f7), TOBN(0xaff4f967, 0xc6b82228)}, + {TOBN(0x15e19dd0, 0xc47adb7e), TOBN(0x45699b23, 0x032e7dfa), + TOBN(0x40680c8b, 0x1fae026a), TOBN(0x5a347a48, 0x550dbf4d)}}, + {{TOBN(0xe652533b, 0x3cef0d7d), TOBN(0xd94f7b18, 0x2bbb4381), + TOBN(0x838752be, 0x0e80f500), TOBN(0x8e6e2488, 0x9e9c9bfb)}, + {TOBN(0xc9751697, 0x16caca6a), TOBN(0x866c49d8, 0x38531ad9), + TOBN(0xc917e239, 0x7151ade1), TOBN(0x2d016ec1, 0x6037c407)}}, + {{TOBN(0xa407ccc9, 0x00eac3f9), TOBN(0x835f6280, 0xe2ed4748), + TOBN(0xcc54c347, 0x1cc98e0d), TOBN(0x0e969937, 0xdcb572eb)}, + {TOBN(0x1b16c8e8, 0x8f30c9cb), TOBN(0xa606ae75, 0x373c4661), + TOBN(0x47aa689b, 0x35502cab), TOBN(0xf89014ae, 0x4d9bb64f)}}, + {{TOBN(0x202f6a9c, 0x31c71f7b), TOBN(0x01f95aa3, 0x296ffe5c), + TOBN(0x5fc06014, 0x53cec3a3), TOBN(0xeb991237, 0x5f498a45)}, + {TOBN(0xae9a935e, 0x5d91ba87), TOBN(0xc6ac6281, 0x0b564a19), + TOBN(0x8a8fe81c, 0x3bd44e69), TOBN(0x7c8b467f, 0x9dd11d45)}}, + {{TOBN(0xf772251f, 0xea5b8e69), TOBN(0xaeecb3bd, 0xc5b75fbc), + TOBN(0x1aca3331, 0x887ff0e5), TOBN(0xbe5d49ff, 0x19f0a131)}, + {TOBN(0x582c13aa, 0xe5c8646f), TOBN(0xdbaa12e8, 0x20e19980), + TOBN(0x8f40f31a, 0xf7abbd94), TOBN(0x1f13f5a8, 0x1dfc7663)}}, + {{TOBN(0x5d81f1ee, 0xaceb4fc0), TOBN(0x36256002, 0x5e6f0f42), + TOBN(0x4b67d6d7, 0x751370c8), TOBN(0x2608b698, 0x03e80589)}, + {TOBN(0xcfc0d2fc, 0x05268301), TOBN(0xa6943d39, 0x40309212), + TOBN(0x192a90c2, 0x1fd0e1c2), TOBN(0xb209f113, 0x37f1dc76)}}, + {{TOBN(0xefcc5e06, 0x97bf1298), TOBN(0xcbdb6730, 0x219d639e), + TOBN(0xd009c116, 0xb81e8c6f), TOBN(0xa3ffdde3, 0x1a7ce2e5)}, + {TOBN(0xc53fbaaa, 0xa914d3ba), TOBN(0x836d500f, 0x88df85ee), + TOBN(0xd98dc71b, 0x66ee0751), TOBN(0x5a3d7005, 0x714516fd)}}, + {{TOBN(0x21d3634d, 0x39eedbba), TOBN(0x35cd2e68, 0x0455a46d), + TOBN(0xc8cafe65, 0xf9d7eb0c), TOBN(0xbda3ce9e, 0x00cefb3e)}, + {TOBN(0xddc17a60, 0x2c9cf7a4), TOBN(0x01572ee4, 0x7bcb8773), + TOBN(0xa92b2b01, 0x8c7548df), TOBN(0x732fd309, 0xa84600e3)}}, + {{TOBN(0xe22109c7, 0x16543a40), TOBN(0x9acafd36, 0xfede3c6c), + TOBN(0xfb206852, 0x6824e614), TOBN(0x2a4544a9, 0xda25dca0)}, + {TOBN(0x25985262, 0x91d60b06), TOBN(0x281b7be9, 0x28753545), + TOBN(0xec667b1a, 0x90f13b27), TOBN(0x33a83aff, 0x940e2eb4)}}, + {{TOBN(0x80009862, 0xd5d721d5), TOBN(0x0c3357a3, 0x5bd3a182), + TOBN(0x27f3a83b, 0x7aa2cda4), TOBN(0xb58ae74e, 0xf6f83085)}, + {TOBN(0x2a911a81, 0x2e6dad6b), TOBN(0xde286051, 0xf43d6c5b), + TOBN(0x4bdccc41, 0xf996c4d8), TOBN(0xe7312ec0, 0x0ae1e24e)}}}, + {{{TOBN(0xf8d112e7, 0x6e6485b3), TOBN(0x4d3e24db, 0x771c52f8), + TOBN(0x48e3ee41, 0x684a2f6d), TOBN(0x7161957d, 0x21d95551)}, + {TOBN(0x19631283, 0xcdb12a6c), TOBN(0xbf3fa882, 0x2e50e164), + TOBN(0xf6254b63, 0x3166cc73), TOBN(0x3aefa7ae, 0xaee8cc38)}}, + {{TOBN(0x79b0fe62, 0x3b36f9fd), TOBN(0x26543b23, 0xfde19fc0), + TOBN(0x136e64a0, 0x958482ef), TOBN(0x23f63771, 0x9b095825)}, + {TOBN(0x14cfd596, 0xb6a1142e), TOBN(0x5ea6aac6, 0x335aac0b), + TOBN(0x86a0e8bd, 0xf3081dd5), TOBN(0x5fb89d79, 0x003dc12a)}}, + {{TOBN(0xf615c33a, 0xf72e34d4), TOBN(0x0bd9ea40, 0x110eec35), + TOBN(0x1c12bc5b, 0xc1dea34e), TOBN(0x686584c9, 0x49ae4699)}, + {TOBN(0x13ad95d3, 0x8c97b942), TOBN(0x4609561a, 0x4e5c7562), + TOBN(0x9e94a4ae, 0xf2737f89), TOBN(0xf57594c6, 0x371c78b6)}}, + {{TOBN(0x0f0165fc, 0xe3779ee3), TOBN(0xe00e7f9d, 0xbd495d9e), + TOBN(0x1fa4efa2, 0x20284e7a), TOBN(0x4564bade, 0x47ac6219)}, + {TOBN(0x90e6312a, 0xc4708e8e), TOBN(0x4f5725fb, 0xa71e9adf), + TOBN(0xe95f55ae, 0x3d684b9f), TOBN(0x47f7ccb1, 0x1e94b415)}}, + {{TOBN(0x7322851b, 0x8d946581), TOBN(0xf0d13133, 0xbdf4a012), + TOBN(0xa3510f69, 0x6584dae0), TOBN(0x03a7c171, 0x3c9f6c6d)}, + {TOBN(0x5be97f38, 0xe475381a), TOBN(0xca1ba422, 0x85823334), + TOBN(0xf83cc5c7, 0x0be17dda), TOBN(0x158b1494, 0x0b918c0f)}}, + {{TOBN(0xda3a77e5, 0x522e6b69), TOBN(0x69c908c3, 0xbbcd6c18), + TOBN(0x1f1b9e48, 0xd924fd56), TOBN(0x37c64e36, 0xaa4bb3f7)}, + {TOBN(0x5a4fdbdf, 0xee478d7d), TOBN(0xba75c8bc, 0x0193f7a0), + TOBN(0x84bc1e84, 0x56cd16df), TOBN(0x1fb08f08, 0x46fad151)}}, + {{TOBN(0x8a7cabf9, 0x842e9f30), TOBN(0xa331d4bf, 0x5eab83af), + TOBN(0xd272cfba, 0x017f2a6a), TOBN(0x27560abc, 0x83aba0e3)}, + {TOBN(0x94b83387, 0x0e3a6b75), TOBN(0x25c6aea2, 0x6b9f50f5), + TOBN(0x803d691d, 0xb5fdf6d0), TOBN(0x03b77509, 0xe6333514)}}, + {{TOBN(0x36178903, 0x61a341c1), TOBN(0x3604dc60, 0x0cfd6142), + TOBN(0x022295eb, 0x8533316c), TOBN(0x3dbde4ac, 0x44af2922)}, + {TOBN(0x898afc5d, 0x1c7eef69), TOBN(0x58896805, 0xd14f4fa1), + TOBN(0x05002160, 0x203c21ca), TOBN(0x6f0d1f30, 0x40ef730b)}}, + {{TOBN(0x8e8c44d4, 0x196224f8), TOBN(0x75a4ab95, 0x374d079d), + TOBN(0x79085ecc, 0x7d48f123), TOBN(0x56f04d31, 0x1bf65ad8)}, + {TOBN(0xe220bf1c, 0xbda602b2), TOBN(0x73ee1742, 0xf9612c69), + TOBN(0x76008fc8, 0x084fd06b), TOBN(0x4000ef9f, 0xf11380d1)}}, + {{TOBN(0x48201b4b, 0x12cfe297), TOBN(0x3eee129c, 0x292f74e5), + TOBN(0xe1fe114e, 0xc9e874e8), TOBN(0x899b055c, 0x92c5fc41)}, + {TOBN(0x4e477a64, 0x3a39c8cf), TOBN(0x82f09efe, 0x78963cc9), + TOBN(0x6fd3fd8f, 0xd333f863), TOBN(0x85132b2a, 0xdc949c63)}}, + {{TOBN(0x7e06a3ab, 0x516eb17b), TOBN(0x73bec06f, 0xd2c7372b), + TOBN(0xe4f74f55, 0xba896da6), TOBN(0xbb4afef8, 0x8e9eb40f)}, + {TOBN(0x2d75bec8, 0xe61d66b0), TOBN(0x02bda4b4, 0xef29300b), + TOBN(0x8bbaa8de, 0x026baa5a), TOBN(0xff54befd, 0xa07f4440)}}, + {{TOBN(0xbd9b8b1d, 0xbe7a2af3), TOBN(0xec51caa9, 0x4fb74a72), + TOBN(0xb9937a4b, 0x63879697), TOBN(0x7c9a9d20, 0xec2687d5)}, + {TOBN(0x1773e44f, 0x6ef5f014), TOBN(0x8abcf412, 0xe90c6900), + TOBN(0x387bd022, 0x8142161e), TOBN(0x50393755, 0xfcb6ff2a)}}, + {{TOBN(0x9813fd56, 0xed6def63), TOBN(0x53cf6482, 0x7d53106c), + TOBN(0x991a35bd, 0x431f7ac1), TOBN(0xf1e274dd, 0x63e65faf)}, + {TOBN(0xf63ffa3c, 0x44cc7880), TOBN(0x411a426b, 0x7c256981), + TOBN(0xb698b9fd, 0x93a420e0), TOBN(0x89fdddc0, 0xae53f8fe)}}, + {{TOBN(0x766e0722, 0x32398baa), TOBN(0x205fee42, 0x5cfca031), + TOBN(0xa49f5341, 0x7a029cf2), TOBN(0xa88c68b8, 0x4023890d)}, + {TOBN(0xbc275041, 0x7337aaa8), TOBN(0x9ed364ad, 0x0eb384f4), + TOBN(0xe0816f85, 0x29aba92f), TOBN(0x2e9e1941, 0x04e38a88)}}, + {{TOBN(0x57eef44a, 0x3dafd2d5), TOBN(0x35d1fae5, 0x97ed98d8), + TOBN(0x50628c09, 0x2307f9b1), TOBN(0x09d84aae, 0xd6cba5c6)}, + {TOBN(0x67071bc7, 0x88aaa691), TOBN(0x2dea57a9, 0xafe6cb03), + TOBN(0xdfe11bb4, 0x3d78ac01), TOBN(0x7286418c, 0x7fd7aa51)}}, + {{TOBN(0xfabf7709, 0x77f7195a), TOBN(0x8ec86167, 0xadeb838f), + TOBN(0xea1285a8, 0xbb4f012d), TOBN(0xd6883503, 0x9a3eab3f)}, + {TOBN(0xee5d24f8, 0x309004c2), TOBN(0xa96e4b76, 0x13ffe95e), + TOBN(0x0cdffe12, 0xbd223ea4), TOBN(0x8f5c2ee5, 0xb6739a53)}}, + {{TOBN(0x5cb4aaa5, 0xdd968198), TOBN(0xfa131c52, 0x72413a6c), + TOBN(0x53d46a90, 0x9536d903), TOBN(0xb270f0d3, 0x48606d8e)}, + {TOBN(0x518c7564, 0xa053a3bc), TOBN(0x088254b7, 0x1a86caef), + TOBN(0xb3ba8cb4, 0x0ab5efd0), TOBN(0x5c59900e, 0x4605945d)}}, + {{TOBN(0xecace1dd, 0xa1887395), TOBN(0x40960f36, 0x932a65de), + TOBN(0x9611ff5c, 0x3aa95529), TOBN(0xc58215b0, 0x7c1e5a36)}, + {TOBN(0xd48c9b58, 0xf0e1a524), TOBN(0xb406856b, 0xf590dfb8), + TOBN(0xc7605e04, 0x9cd95662), TOBN(0x0dd036ee, 0xa33ecf82)}}, + {{TOBN(0xa50171ac, 0xc33156b3), TOBN(0xf09d24ea, 0x4a80172e), + TOBN(0x4e1f72c6, 0x76dc8eef), TOBN(0xe60caadc, 0x5e3d44ee)}, + {TOBN(0x006ef8a6, 0x979b1d8f), TOBN(0x60908a1c, 0x97788d26), + TOBN(0x6e08f95b, 0x266feec0), TOBN(0x618427c2, 0x22e8c94e)}}, + {{TOBN(0x3d613339, 0x59145a65), TOBN(0xcd9bc368, 0xfa406337), + TOBN(0x82d11be3, 0x2d8a52a0), TOBN(0xf6877b27, 0x97a1c590)}, + {TOBN(0x837a819b, 0xf5cbdb25), TOBN(0x2a4fd1d8, 0xde090249), + TOBN(0x622a7de7, 0x74990e5f), TOBN(0x840fa5a0, 0x7945511b)}}, + {{TOBN(0x30b974be, 0x6558842d), TOBN(0x70df8c64, 0x17f3d0a6), + TOBN(0x7c803520, 0x7542e46d), TOBN(0x7251fe7f, 0xe4ecc823)}, + {TOBN(0xe59134cb, 0x5e9aac9a), TOBN(0x11bb0934, 0xf0045d71), + TOBN(0x53e5d9b5, 0xdbcb1d4e), TOBN(0x8d97a905, 0x92defc91)}}, + {{TOBN(0xfe289327, 0x7946d3f9), TOBN(0xe132bd24, 0x07472273), + TOBN(0xeeeb510c, 0x1eb6ae86), TOBN(0x777708c5, 0xf0595067)}, + {TOBN(0x18e2c8cd, 0x1297029e), TOBN(0x2c61095c, 0xbbf9305e), + TOBN(0xe466c258, 0x6b85d6d9), TOBN(0x8ac06c36, 0xda1ea530)}}, + {{TOBN(0xa365dc39, 0xa1304668), TOBN(0xe4a9c885, 0x07f89606), + TOBN(0x65a4898f, 0xacc7228d), TOBN(0x3e2347ff, 0x84ca8303)}, + {TOBN(0xa5f6fb77, 0xea7d23a3), TOBN(0x2fac257d, 0x672a71cd), + TOBN(0x6908bef8, 0x7e6a44d3), TOBN(0x8ff87566, 0x891d3d7a)}}, + {{TOBN(0xe58e90b3, 0x6b0cf82e), TOBN(0x6438d246, 0x2615b5e7), + TOBN(0x07b1f8fc, 0x669c145a), TOBN(0xb0d8b2da, 0x36f1e1cb)}, + {TOBN(0x54d5dadb, 0xd9184c4d), TOBN(0x3dbb18d5, 0xf93d9976), + TOBN(0x0a3e0f56, 0xd1147d47), TOBN(0x2afa8c8d, 0xa0a48609)}}, + {{TOBN(0x275353e8, 0xbc36742c), TOBN(0x898f427e, 0xeea0ed90), + TOBN(0x26f4947e, 0x3e477b00), TOBN(0x8ad8848a, 0x308741e3)}, + {TOBN(0x6c703c38, 0xd74a2a46), TOBN(0x5e3e05a9, 0x9ba17ba2), + TOBN(0xc1fa6f66, 0x4ab9a9e4), TOBN(0x474a2d9a, 0x3841d6ec)}}, + {{TOBN(0x871239ad, 0x653ae326), TOBN(0x14bcf72a, 0xa74cbb43), + TOBN(0x8737650e, 0x20d4c083), TOBN(0x3df86536, 0x110ed4af)}, + {TOBN(0xd2d86fe7, 0xb53ca555), TOBN(0x688cb00d, 0xabd5d538), + TOBN(0xcf81bda3, 0x1ad38468), TOBN(0x7ccfe3cc, 0xf01167b6)}}, + {{TOBN(0xcf4f47e0, 0x6c4c1fe6), TOBN(0x557e1f1a, 0x298bbb79), + TOBN(0xf93b974f, 0x30d45a14), TOBN(0x174a1d2d, 0x0baf97c4)}, + {TOBN(0x7a003b30, 0xc51fbf53), TOBN(0xd8940991, 0xee68b225), + TOBN(0x5b0aa7b7, 0x1c0f4173), TOBN(0x975797c9, 0xa20a7153)}}, + {{TOBN(0x26e08c07, 0xe3533d77), TOBN(0xd7222e6a, 0x2e341c99), + TOBN(0x9d60ec3d, 0x8d2dc4ed), TOBN(0xbdfe0d8f, 0x7c476cf8)}, + {TOBN(0x1fe59ab6, 0x1d056605), TOBN(0xa9ea9df6, 0x86a8551f), + TOBN(0x8489941e, 0x47fb8d8c), TOBN(0xfeb874eb, 0x4a7f1b10)}}, + {{TOBN(0xfe5fea86, 0x7ee0d98f), TOBN(0x201ad34b, 0xdbf61864), + TOBN(0x45d8fe47, 0x37c031d4), TOBN(0xd5f49fae, 0x795f0822)}, + {TOBN(0xdb0fb291, 0xc7f4a40c), TOBN(0x2e69d9c1, 0x730ddd92), + TOBN(0x754e1054, 0x49d76987), TOBN(0x8a24911d, 0x7662db87)}}, + {{TOBN(0x61fc1810, 0x60a71676), TOBN(0xe852d1a8, 0xf66a8ad1), + TOBN(0x172bbd65, 0x6417231e), TOBN(0x0d6de7bd, 0x3babb11f)}, + {TOBN(0x6fde6f88, 0xc8e347f8), TOBN(0x1c587547, 0x9bd99cc3), + TOBN(0x78e54ed0, 0x34076950), TOBN(0x97f0f334, 0x796e83ba)}}, + {{TOBN(0xe4dbe1ce, 0x4924867a), TOBN(0xbd5f51b0, 0x60b84917), + TOBN(0x37530040, 0x3cb09a79), TOBN(0xdb3fe0f8, 0xff1743d8)}, + {TOBN(0xed7894d8, 0x556fa9db), TOBN(0xfa262169, 0x23412fbf), + TOBN(0x563be0db, 0xba7b9291), TOBN(0x6ca8b8c0, 0x0c9fb234)}}, + {{TOBN(0xed406aa9, 0xbd763802), TOBN(0xc21486a0, 0x65303da1), + TOBN(0x61ae291e, 0xc7e62ec4), TOBN(0x622a0492, 0xdf99333e)}, + {TOBN(0x7fd80c9d, 0xbb7a8ee0), TOBN(0xdc2ed3bc, 0x6c01aedb), + TOBN(0x35c35a12, 0x08be74ec), TOBN(0xd540cb1a, 0x469f671f)}}, + {{TOBN(0xd16ced4e, 0xcf84f6c7), TOBN(0x8561fb9c, 0x2d090f43), + TOBN(0x7e693d79, 0x6f239db4), TOBN(0xa736f928, 0x77bd0d94)}, + {TOBN(0x07b4d929, 0x2c1950ee), TOBN(0xda177543, 0x56dc11b3), + TOBN(0xa5dfbbaa, 0x7a6a878e), TOBN(0x1c70cb29, 0x4decb08a)}}, + {{TOBN(0xfba28c8b, 0x6f0f7c50), TOBN(0xa8eba2b8, 0x854dcc6d), + TOBN(0x5ff8e89a, 0x36b78642), TOBN(0x070c1c8e, 0xf6873adf)}, + {TOBN(0xbbd3c371, 0x6484d2e4), TOBN(0xfb78318f, 0x0d414129), + TOBN(0x2621a39c, 0x6ad93b0b), TOBN(0x979d74c2, 0xa9e917f7)}}, + {{TOBN(0xfc195647, 0x61fb0428), TOBN(0x4d78954a, 0xbee624d4), + TOBN(0xb94896e0, 0xb8ae86fd), TOBN(0x6667ac0c, 0xc91c8b13)}, + {TOBN(0x9f180512, 0x43bcf832), TOBN(0xfbadf8b7, 0xa0010137), + TOBN(0xc69b4089, 0xb3ba8aa7), TOBN(0xfac4bacd, 0xe687ce85)}}, + {{TOBN(0x9164088d, 0x977eab40), TOBN(0x51f4c5b6, 0x2760b390), + TOBN(0xd238238f, 0x340dd553), TOBN(0x358566c3, 0xdb1d31c9)}, + {TOBN(0x3a5ad69e, 0x5068f5ff), TOBN(0xf31435fc, 0xdaff6b06), + TOBN(0xae549a5b, 0xd6debff0), TOBN(0x59e5f0b7, 0x75e01331)}}, + {{TOBN(0x5d492fb8, 0x98559acf), TOBN(0x96018c2e, 0x4db79b50), + TOBN(0x55f4a48f, 0x609f66aa), TOBN(0x1943b3af, 0x4900a14f)}, + {TOBN(0xc22496df, 0x15a40d39), TOBN(0xb2a44684, 0x4c20f7c5), + TOBN(0x76a35afa, 0x3b98404c), TOBN(0xbec75725, 0xff5d1b77)}}, + {{TOBN(0xb67aa163, 0xbea06444), TOBN(0x27e95bb2, 0xf724b6f2), + TOBN(0x3c20e3e9, 0xd238c8ab), TOBN(0x1213754e, 0xddd6ae17)}, + {TOBN(0x8c431020, 0x716e0f74), TOBN(0x6679c82e, 0xffc095c2), + TOBN(0x2eb3adf4, 0xd0ac2932), TOBN(0x2cc970d3, 0x01bb7a76)}}, + {{TOBN(0x70c71f2f, 0x740f0e66), TOBN(0x545c616b, 0x2b6b23cc), + TOBN(0x4528cfcb, 0xb40a8bd7), TOBN(0xff839633, 0x2ab27722)}, + {TOBN(0x049127d9, 0x025ac99a), TOBN(0xd314d4a0, 0x2b63e33b), + TOBN(0xc8c310e7, 0x28d84519), TOBN(0x0fcb8983, 0xb3bc84ba)}}, + {{TOBN(0x2cc52261, 0x38634818), TOBN(0x501814f4, 0xb44c2e0b), + TOBN(0xf7e181aa, 0x54dfdba3), TOBN(0xcfd58ff0, 0xe759718c)}, + {TOBN(0xf90cdb14, 0xd3b507a8), TOBN(0x57bd478e, 0xc50bdad8), + TOBN(0x29c197e2, 0x50e5f9aa), TOBN(0x4db6eef8, 0xe40bc855)}}, + {{TOBN(0x2cc8f21a, 0xd1fc0654), TOBN(0xc71cc963, 0x81269d73), + TOBN(0xecfbb204, 0x077f49f9), TOBN(0xdde92571, 0xca56b793)}, + {TOBN(0x9abed6a3, 0xf97ad8f7), TOBN(0xe6c19d3f, 0x924de3bd), + TOBN(0x8dce92f4, 0xa140a800), TOBN(0x85f44d1e, 0x1337af07)}}, + {{TOBN(0x5953c08b, 0x09d64c52), TOBN(0xa1b5e49f, 0xf5df9749), + TOBN(0x336a8fb8, 0x52735f7d), TOBN(0xb332b6db, 0x9add676b)}, + {TOBN(0x558b88a0, 0xb4511aa4), TOBN(0x09788752, 0xdbd5cc55), + TOBN(0x16b43b9c, 0xd8cd52bd), TOBN(0x7f0bc5a0, 0xc2a2696b)}}, + {{TOBN(0x146e12d4, 0xc11f61ef), TOBN(0x9ce10754, 0x3a83e79e), + TOBN(0x08ec73d9, 0x6cbfca15), TOBN(0x09ff29ad, 0x5b49653f)}, + {TOBN(0xe31b72bd, 0xe7da946e), TOBN(0xebf9eb3b, 0xee80a4f2), + TOBN(0xd1aabd08, 0x17598ce4), TOBN(0x18b5fef4, 0x53f37e80)}}, + {{TOBN(0xd5d5cdd3, 0x5958cd79), TOBN(0x3580a1b5, 0x1d373114), + TOBN(0xa36e4c91, 0xfa935726), TOBN(0xa38c534d, 0xef20d760)}, + {TOBN(0x7088e40a, 0x2ff5845b), TOBN(0xe5bb40bd, 0xbd78177f), + TOBN(0x4f06a7a8, 0x857f9920), TOBN(0xe3cc3e50, 0xe968f05d)}}, + {{TOBN(0x1d68b7fe, 0xe5682d26), TOBN(0x5206f76f, 0xaec7f87c), + TOBN(0x41110530, 0x041951ab), TOBN(0x58ec52c1, 0xd4b5a71a)}, + {TOBN(0xf3488f99, 0x0f75cf9a), TOBN(0xf411951f, 0xba82d0d5), + TOBN(0x27ee75be, 0x618895ab), TOBN(0xeae060d4, 0x6d8aab14)}}, + {{TOBN(0x9ae1df73, 0x7fb54dc2), TOBN(0x1f3e391b, 0x25963649), + TOBN(0x242ec32a, 0xfe055081), TOBN(0x5bd450ef, 0x8491c9bd)}, + {TOBN(0x367efc67, 0x981eb389), TOBN(0xed7e1928, 0x3a0550d5), + TOBN(0x362e776b, 0xab3ce75c), TOBN(0xe890e308, 0x1f24c523)}}, + {{TOBN(0xb961b682, 0xfeccef76), TOBN(0x8b8e11f5, 0x8bba6d92), + TOBN(0x8f2ccc4c, 0x2b2375c4), TOBN(0x0d7f7a52, 0xe2f86cfa)}, + {TOBN(0xfd94d30a, 0x9efe5633), TOBN(0x2d8d246b, 0x5451f934), + TOBN(0x2234c6e3, 0x244e6a00), TOBN(0xde2b5b0d, 0xddec8c50)}}, + {{TOBN(0x2ce53c5a, 0xbf776f5b), TOBN(0x6f724071, 0x60357b05), + TOBN(0xb2593717, 0x71bf3f7a), TOBN(0x87d2501c, 0x440c4a9f)}, + {TOBN(0x440552e1, 0x87b05340), TOBN(0xb7bf7cc8, 0x21624c32), + TOBN(0x4155a6ce, 0x22facddb), TOBN(0x5a4228cb, 0x889837ef)}}, + {{TOBN(0xef87d6d6, 0xfd4fd671), TOBN(0xa233687e, 0xc2daa10e), + TOBN(0x75622244, 0x03c0eb96), TOBN(0x7632d184, 0x8bf19be6)}, + {TOBN(0x05d0f8e9, 0x40735ff4), TOBN(0x3a3e6e13, 0xc00931f1), + TOBN(0x31ccde6a, 0xdafe3f18), TOBN(0xf381366a, 0xcfe51207)}}, + {{TOBN(0x24c222a9, 0x60167d92), TOBN(0x62f9d6f8, 0x7529f18c), + TOBN(0x412397c0, 0x0353b114), TOBN(0x334d89dc, 0xef808043)}, + {TOBN(0xd9ec63ba, 0x2a4383ce), TOBN(0xcec8e937, 0x5cf92ba0), + TOBN(0xfb8b4288, 0xc8be74c0), TOBN(0x67d6912f, 0x105d4391)}}, + {{TOBN(0x7b996c46, 0x1b913149), TOBN(0x36aae2ef, 0x3a4e02da), + TOBN(0xb68aa003, 0x972de594), TOBN(0x284ec70d, 0x4ec6d545)}, + {TOBN(0xf3d2b2d0, 0x61391d54), TOBN(0x69c5d5d6, 0xfe114e92), + TOBN(0xbe0f00b5, 0xb4482dff), TOBN(0xe1596fa5, 0xf5bf33c5)}}, + {{TOBN(0x10595b56, 0x96a71cba), TOBN(0x944938b2, 0xfdcadeb7), + TOBN(0xa282da4c, 0xfccd8471), TOBN(0x98ec05f3, 0x0d37bfe1)}, + {TOBN(0xe171ce1b, 0x0698304a), TOBN(0x2d691444, 0x21bdf79b), + TOBN(0xd0cd3b74, 0x1b21dec1), TOBN(0x712ecd8b, 0x16a15f71)}}, + {{TOBN(0x8d4c00a7, 0x00fd56e1), TOBN(0x02ec9692, 0xf9527c18), + TOBN(0x21c44937, 0x4a3e42e1), TOBN(0x9176fbab, 0x1392ae0a)}, + {TOBN(0x8726f1ba, 0x44b7b618), TOBN(0xb4d7aae9, 0xf1de491c), + TOBN(0xf91df7b9, 0x07b582c0), TOBN(0x7e116c30, 0xef60aa3a)}}, + {{TOBN(0x99270f81, 0x466265d7), TOBN(0xb15b6fe2, 0x4df7adf0), + TOBN(0xfe33b2d3, 0xf9738f7f), TOBN(0x48553ab9, 0xd6d70f95)}, + {TOBN(0x2cc72ac8, 0xc21e94db), TOBN(0x795ac38d, 0xbdc0bbee), + TOBN(0x0a1be449, 0x2e40478f), TOBN(0x81bd3394, 0x052bde55)}}, + {{TOBN(0x63c8dbe9, 0x56b3c4f2), TOBN(0x017a99cf, 0x904177cc), + TOBN(0x947bbddb, 0x4d010fc1), TOBN(0xacf9b00b, 0xbb2c9b21)}, + {TOBN(0x2970bc8d, 0x47173611), TOBN(0x1a4cbe08, 0xac7d756f), + TOBN(0x06d9f4aa, 0x67d541a2), TOBN(0xa3e8b689, 0x59c2cf44)}}, + {{TOBN(0xaad066da, 0x4d88f1dd), TOBN(0xc604f165, 0x7ad35dea), + TOBN(0x7edc0720, 0x4478ca67), TOBN(0xa10dfae0, 0xba02ce06)}, + {TOBN(0xeceb1c76, 0xaf36f4e4), TOBN(0x994b2292, 0xaf3f8f48), + TOBN(0xbf9ed77b, 0x77c8a68c), TOBN(0x74f544ea, 0x51744c9d)}}, + {{TOBN(0x82d05bb9, 0x8113a757), TOBN(0x4ef2d2b4, 0x8a9885e4), + TOBN(0x1e332be5, 0x1aa7865f), TOBN(0x22b76b18, 0x290d1a52)}, + {TOBN(0x308a2310, 0x44351683), TOBN(0x9d861896, 0xa3f22840), + TOBN(0x5959ddcd, 0x841ed947), TOBN(0x0def0c94, 0x154b73bf)}}, + {{TOBN(0xf0105417, 0x4c7c15e0), TOBN(0x539bfb02, 0x3a277c32), + TOBN(0xe699268e, 0xf9dccf5f), TOBN(0x9f5796a5, 0x0247a3bd)}, + {TOBN(0x8b839de8, 0x4f157269), TOBN(0xc825c1e5, 0x7a30196b), + TOBN(0x6ef0aabc, 0xdc8a5a91), TOBN(0xf4a8ce6c, 0x498b7fe6)}}, + {{TOBN(0x1cce35a7, 0x70cbac78), TOBN(0x83488e9b, 0xf6b23958), + TOBN(0x0341a070, 0xd76cb011), TOBN(0xda6c9d06, 0xae1b2658)}, + {TOBN(0xb701fb30, 0xdd648c52), TOBN(0x994ca02c, 0x52fb9fd1), + TOBN(0x06933117, 0x6f563086), TOBN(0x3d2b8100, 0x17856bab)}}, + {{TOBN(0xe89f48c8, 0x5963a46e), TOBN(0x658ab875, 0xa99e61c7), + TOBN(0x6e296f87, 0x4b8517b4), TOBN(0x36c4fcdc, 0xfc1bc656)}, + {TOBN(0xde5227a1, 0xa3906def), TOBN(0x9fe95f57, 0x62418945), + TOBN(0x20c91e81, 0xfdd96cde), TOBN(0x5adbe47e, 0xda4480de)}}, + {{TOBN(0xa009370f, 0x396de2b6), TOBN(0x98583d4b, 0xf0ecc7bd), + TOBN(0xf44f6b57, 0xe51d0672), TOBN(0x03d6b078, 0x556b1984)}, + {TOBN(0x27dbdd93, 0xb0b64912), TOBN(0x9b3a3434, 0x15687b09), + TOBN(0x0dba6461, 0x51ec20a9), TOBN(0xec93db7f, 0xff28187c)}}, + {{TOBN(0x00ff8c24, 0x66e48bdd), TOBN(0x2514f2f9, 0x11ccd78e), + TOBN(0xeba11f4f, 0xe1250603), TOBN(0x8a22cd41, 0x243fa156)}, + {TOBN(0xa4e58df4, 0xb283e4c6), TOBN(0x78c29859, 0x8b39783f), + TOBN(0x5235aee2, 0xa5259809), TOBN(0xc16284b5, 0x0e0227dd)}}, + {{TOBN(0xa5f57916, 0x1338830d), TOBN(0x6d4b8a6b, 0xd2123fca), + TOBN(0x236ea68a, 0xf9c546f8), TOBN(0xc1d36873, 0xfa608d36)}, + {TOBN(0xcd76e495, 0x8d436d13), TOBN(0xd4d9c221, 0x8fb080af), + TOBN(0x665c1728, 0xe8ad3fb5), TOBN(0xcf1ebe4d, 0xb3d572e0)}}, + {{TOBN(0xa7a8746a, 0x584c5e20), TOBN(0x267e4ea1, 0xb9dc7035), + TOBN(0x593a15cf, 0xb9548c9b), TOBN(0x5e6e2135, 0x4bd012f3)}, + {TOBN(0xdf31cc6a, 0x8c8f936e), TOBN(0x8af84d04, 0xb5c241dc), + TOBN(0x63990a6f, 0x345efb86), TOBN(0x6fef4e61, 0xb9b962cb)}}}, + {{{TOBN(0xf6368f09, 0x25722608), TOBN(0x131260db, 0x131cf5c6), + TOBN(0x40eb353b, 0xfab4f7ac), TOBN(0x85c78880, 0x37eee829)}, + {TOBN(0x4c1581ff, 0xc3bdf24e), TOBN(0x5bff75cb, 0xf5c3c5a8), + TOBN(0x35e8c83f, 0xa14e6f40), TOBN(0xb81d1c0f, 0x0295e0ca)}}, + {{TOBN(0xfcde7cc8, 0xf43a730f), TOBN(0xe89b6f3c, 0x33ab590e), + TOBN(0xc823f529, 0xad03240b), TOBN(0x82b79afe, 0x98bea5db)}, + {TOBN(0x568f2856, 0x962fe5de), TOBN(0x0c590adb, 0x60c591f3), + TOBN(0x1fc74a14, 0x4a28a858), TOBN(0x3b662498, 0xb3203f4c)}}, + {{TOBN(0x91e3cf0d, 0x6c39765a), TOBN(0xa2db3acd, 0xac3cca0b), + TOBN(0x288f2f08, 0xcb953b50), TOBN(0x2414582c, 0xcf43cf1a)}, + {TOBN(0x8dec8bbc, 0x60eee9a8), TOBN(0x54c79f02, 0x729aa042), + TOBN(0xd81cd5ec, 0x6532f5d5), TOBN(0xa672303a, 0xcf82e15f)}}, + {{TOBN(0x376aafa8, 0x719c0563), TOBN(0xcd8ad2dc, 0xbc5fc79f), + TOBN(0x303fdb9f, 0xcb750cd3), TOBN(0x14ff052f, 0x4418b08e)}, + {TOBN(0xf75084cf, 0x3e2d6520), TOBN(0x7ebdf0f8, 0x144ed509), + TOBN(0xf43bf0f2, 0xd3f25b98), TOBN(0x86ad71cf, 0xa354d837)}}, + {{TOBN(0xb827fe92, 0x26f43572), TOBN(0xdfd3ab5b, 0x5d824758), + TOBN(0x315dd23a, 0x539094c1), TOBN(0x85c0e37a, 0x66623d68)}, + {TOBN(0x575c7972, 0x7be19ae0), TOBN(0x616a3396, 0xdf0d36b5), + TOBN(0xa1ebb3c8, 0x26b1ff7e), TOBN(0x635b9485, 0x140ad453)}}, + {{TOBN(0x92bf3cda, 0xda430c0b), TOBN(0x4702850e, 0x3a96dac6), + TOBN(0xc91cf0a5, 0x15ac326a), TOBN(0x95de4f49, 0xab8c25e4)}, + {TOBN(0xb01bad09, 0xe265c17c), TOBN(0x24e45464, 0x087b3881), + TOBN(0xd43e583c, 0xe1fac5ca), TOBN(0xe17cb318, 0x6ead97a6)}}, + {{TOBN(0x6cc39243, 0x74dcec46), TOBN(0x33cfc02d, 0x54c2b73f), + TOBN(0x82917844, 0xf26cd99c), TOBN(0x8819dd95, 0xd1773f89)}, + {TOBN(0x09572aa6, 0x0871f427), TOBN(0x8e0cf365, 0xf6f01c34), + TOBN(0x7fa52988, 0xbff1f5af), TOBN(0x4eb357ea, 0xe75e8e50)}}, + {{TOBN(0xd9d0c8c4, 0x868af75d), TOBN(0xd7325cff, 0x45c8c7ea), + TOBN(0xab471996, 0xcc81ecb0), TOBN(0xff5d55f3, 0x611824ed)}, + {TOBN(0xbe314541, 0x1977a0ee), TOBN(0x5085c4c5, 0x722038c6), + TOBN(0x2d5335bf, 0xf94bb495), TOBN(0x894ad8a6, 0xc8e2a082)}}, + {{TOBN(0x5c3e2341, 0xada35438), TOBN(0xf4a9fc89, 0x049b8c4e), + TOBN(0xbeeb355a, 0x9f17cf34), TOBN(0x3f311e0e, 0x6c91fe10)}, + {TOBN(0xc2d20038, 0x92ab9891), TOBN(0x257bdcc1, 0x3e8ce9a9), + TOBN(0x1b2d9789, 0x88c53bee), TOBN(0x927ce89a, 0xcdba143a)}}, + {{TOBN(0xb0a32cca, 0x523db280), TOBN(0x5c889f8a, 0x50d43783), + TOBN(0x503e04b3, 0x4897d16f), TOBN(0x8cdb6e78, 0x08f5f2e8)}, + {TOBN(0x6ab91cf0, 0x179c8e74), TOBN(0xd8874e52, 0x48211d60), + TOBN(0xf948d4d5, 0xea851200), TOBN(0x4076d41e, 0xe6f9840a)}}, + {{TOBN(0xc20e263c, 0x47b517ea), TOBN(0x79a448fd, 0x30685e5e), + TOBN(0xe55f6f78, 0xf90631a0), TOBN(0x88a790b1, 0xa79e6346)}, + {TOBN(0x62160c7d, 0x80969fe8), TOBN(0x54f92fd4, 0x41491bb9), + TOBN(0xa6645c23, 0x5c957526), TOBN(0xf44cc5ae, 0xbea3ce7b)}}, + {{TOBN(0xf7628327, 0x8b1e68b7), TOBN(0xc731ad7a, 0x303f29d3), + TOBN(0xfe5a9ca9, 0x57d03ecb), TOBN(0x96c0d50c, 0x41bc97a7)}, + {TOBN(0xc4669fe7, 0x9b4f7f24), TOBN(0xfdd781d8, 0x3d9967ef), + TOBN(0x7892c7c3, 0x5d2c208d), TOBN(0x8bf64f7c, 0xae545cb3)}}, + {{TOBN(0xc01f862c, 0x467be912), TOBN(0xf4c85ee9, 0xc73d30cc), + TOBN(0x1fa6f4be, 0x6ab83ec7), TOBN(0xa07a3c1c, 0x4e3e3cf9)}, + {TOBN(0x87f8ef45, 0x0c00beb3), TOBN(0x30e2c2b3, 0x000d4c3e), + TOBN(0x1aa00b94, 0xfe08bf5b), TOBN(0x32c133aa, 0x9224ef52)}}, + {{TOBN(0x38df16bb, 0x32e5685d), TOBN(0x68a9e069, 0x58e6f544), + TOBN(0x495aaff7, 0xcdc5ebc6), TOBN(0xf894a645, 0x378b135f)}, + {TOBN(0xf316350a, 0x09e27ecf), TOBN(0xeced201e, 0x58f7179d), + TOBN(0x2eec273c, 0xe97861ba), TOBN(0x47ec2cae, 0xd693be2e)}}, + {{TOBN(0xfa4c97c4, 0xf68367ce), TOBN(0xe4f47d0b, 0xbe5a5755), + TOBN(0x17de815d, 0xb298a979), TOBN(0xd7eca659, 0xc177dc7d)}, + {TOBN(0x20fdbb71, 0x49ded0a3), TOBN(0x4cb2aad4, 0xfb34d3c5), + TOBN(0x2cf31d28, 0x60858a33), TOBN(0x3b6873ef, 0xa24aa40f)}}, + {{TOBN(0x540234b2, 0x2c11bb37), TOBN(0x2d0366dd, 0xed4c74a3), + TOBN(0xf9a968da, 0xeec5f25d), TOBN(0x36601068, 0x67b63142)}, + {TOBN(0x07cd6d2c, 0x68d7b6d4), TOBN(0xa8f74f09, 0x0c842942), + TOBN(0xe2751404, 0x7768b1ee), TOBN(0x4b5f7e89, 0xfe62aee4)}}, + {{TOBN(0xc6a77177, 0x89070d26), TOBN(0xa1f28e4e, 0xdd1c8bc7), + TOBN(0xea5f4f06, 0x469e1f17), TOBN(0x78fc242a, 0xfbdb78e0)}, + {TOBN(0xc9c7c592, 0x8b0588f1), TOBN(0xb6b7a0fd, 0x1535921e), + TOBN(0xcc5bdb91, 0xbde5ae35), TOBN(0xb42c485e, 0x12ff1864)}}, + {{TOBN(0xa1113e13, 0xdbab98aa), TOBN(0xde9d469b, 0xa17b1024), + TOBN(0x23f48b37, 0xc0462d3a), TOBN(0x3752e537, 0x7c5c078d)}, + {TOBN(0xe3a86add, 0x15544eb9), TOBN(0xf013aea7, 0x80fba279), + TOBN(0x8b5bb76c, 0xf22001b5), TOBN(0xe617ba14, 0xf02891ab)}}, + {{TOBN(0xd39182a6, 0x936219d3), TOBN(0x5ce1f194, 0xae51cb19), + TOBN(0xc78f8598, 0xbf07a74c), TOBN(0x6d7158f2, 0x22cbf1bc)}, + {TOBN(0x3b846b21, 0xe300ce18), TOBN(0x35fba630, 0x2d11275d), + TOBN(0x5fe25c36, 0xa0239b9b), TOBN(0xd8beb35d, 0xdf05d940)}}, + {{TOBN(0x4db02bb0, 0x1f7e320d), TOBN(0x0641c364, 0x6da320ea), + TOBN(0x6d95fa5d, 0x821389a3), TOBN(0x92699748, 0x8fcd8e3d)}, + {TOBN(0x316fef17, 0xceb6c143), TOBN(0x67fcb841, 0xd933762b), + TOBN(0xbb837e35, 0x118b17f8), TOBN(0x4b92552f, 0x9fd24821)}}, + {{TOBN(0xae6bc70e, 0x46aca793), TOBN(0x1cf0b0e4, 0xe579311b), + TOBN(0x8dc631be, 0x5802f716), TOBN(0x099bdc6f, 0xbddbee4d)}, + {TOBN(0xcc352bb2, 0x0caf8b05), TOBN(0xf74d505a, 0x72d63df2), + TOBN(0xb9876d4b, 0x91c4f408), TOBN(0x1ce18473, 0x9e229b2d)}}, + {{TOBN(0x49507597, 0x83abdb4a), TOBN(0x850fbcb6, 0xdee84b18), + TOBN(0x6325236e, 0x609e67dc), TOBN(0x04d831d9, 0x9336c6d8)}, + {TOBN(0x8deaae3b, 0xfa12d45d), TOBN(0xe425f8ce, 0x4746e246), + TOBN(0x8004c175, 0x24f5f31e), TOBN(0xaca16d8f, 0xad62c3b7)}}, + {{TOBN(0x0dc15a6a, 0x9152f934), TOBN(0xf1235e5d, 0xed0e12c1), + TOBN(0xc33c06ec, 0xda477dac), TOBN(0x76be8732, 0xb2ea0006)}, + {TOBN(0xcf3f7831, 0x0c0cd313), TOBN(0x3c524553, 0xa614260d), + TOBN(0x31a756f8, 0xcab22d15), TOBN(0x03ee10d1, 0x77827a20)}}, + {{TOBN(0xd1e059b2, 0x1994ef20), TOBN(0x2a653b69, 0x638ae318), + TOBN(0x70d5eb58, 0x2f699010), TOBN(0x279739f7, 0x09f5f84a)}, + {TOBN(0x5da4663c, 0x8b799336), TOBN(0xfdfdf14d, 0x203c37eb), + TOBN(0x32d8a9dc, 0xa1dbfb2d), TOBN(0xab40cff0, 0x77d48f9b)}}, + {{TOBN(0xc018b383, 0xd20b42d5), TOBN(0xf9a810ef, 0x9f78845f), + TOBN(0x40af3753, 0xbdba9df0), TOBN(0xb90bdcfc, 0x131dfdf9)}, + {TOBN(0x18720591, 0xf01ab782), TOBN(0xc823f211, 0x6af12a88), + TOBN(0xa51b80f3, 0x0dc14401), TOBN(0xde248f77, 0xfb2dfbe3)}}, + {{TOBN(0xef5a44e5, 0x0cafe751), TOBN(0x73997c9c, 0xd4dcd221), + TOBN(0x32fd86d1, 0xde854024), TOBN(0xd5b53adc, 0xa09b84bb)}, + {TOBN(0x008d7a11, 0xdcedd8d1), TOBN(0x406bd1c8, 0x74b32c84), + TOBN(0x5d4472ff, 0x05dde8b1), TOBN(0x2e25f2cd, 0xfce2b32f)}}, + {{TOBN(0xbec0dd5e, 0x29dfc254), TOBN(0x4455fcf6, 0x2b98b267), + TOBN(0x0b4d43a5, 0xc72df2ad), TOBN(0xea70e6be, 0x48a75397)}, + {TOBN(0x2aad6169, 0x5820f3bf), TOBN(0xf410d2dd, 0x9e37f68f), + TOBN(0x70fb7dba, 0x7be5ac83), TOBN(0x636bb645, 0x36ec3eec)}}, + {{TOBN(0x27104ea3, 0x9754e21c), TOBN(0xbc87a3e6, 0x8d63c373), + TOBN(0x483351d7, 0x4109db9a), TOBN(0x0fa724e3, 0x60134da7)}, + {TOBN(0x9ff44c29, 0xb0720b16), TOBN(0x2dd0cf13, 0x06aceead), + TOBN(0x5942758c, 0xe26929a6), TOBN(0x96c5db92, 0xb766a92b)}}, + {{TOBN(0xcec7d4c0, 0x5f18395e), TOBN(0xd3f22744, 0x1f80d032), + TOBN(0x7a68b37a, 0xcb86075b), TOBN(0x074764dd, 0xafef92db)}, + {TOBN(0xded1e950, 0x7bc7f389), TOBN(0xc580c850, 0xb9756460), + TOBN(0xaeeec2a4, 0x7da48157), TOBN(0x3f0b4e7f, 0x82c587b3)}}, + {{TOBN(0x231c6de8, 0xa9f19c53), TOBN(0x5717bd73, 0x6974e34e), + TOBN(0xd9e1d216, 0xf1508fa9), TOBN(0x9f112361, 0xdadaa124)}, + {TOBN(0x80145e31, 0x823b7348), TOBN(0x4dd8f0d5, 0xac634069), + TOBN(0xe3d82fc7, 0x2297c258), TOBN(0x276fcfee, 0x9cee7431)}}, + {{TOBN(0x8eb61b5e, 0x2bc0aea9), TOBN(0x4f668fd5, 0xde329431), + TOBN(0x03a32ab1, 0x38e4b87e), TOBN(0xe1374517, 0x73d0ef0b)}, + {TOBN(0x1a46f7e6, 0x853ac983), TOBN(0xc3bdf42e, 0x68e78a57), + TOBN(0xacf20785, 0x2ea96dd1), TOBN(0xa10649b9, 0xf1638460)}}, + {{TOBN(0xf2369f0b, 0x879fbbed), TOBN(0x0ff0ae86, 0xda9d1869), + TOBN(0x5251d759, 0x56766f45), TOBN(0x4984d8c0, 0x2be8d0fc)}, + {TOBN(0x7ecc95a6, 0xd21008f0), TOBN(0x29bd54a0, 0x3a1a1c49), + TOBN(0xab9828c5, 0xd26c50f3), TOBN(0x32c0087c, 0x51d0d251)}}, + {{TOBN(0x9bac3ce6, 0x0c1cdb26), TOBN(0xcd94d947, 0x557ca205), + TOBN(0x1b1bd598, 0x9db1fdcd), TOBN(0x0eda0108, 0xa3d8b149)}, + {TOBN(0x95066610, 0x56152fcc), TOBN(0xc2f037e6, 0xe7192b33), + TOBN(0xdeffb41a, 0xc92e05a4), TOBN(0x1105f6c2, 0xc2f6c62e)}}, + {{TOBN(0x68e73500, 0x8733913c), TOBN(0xcce86163, 0x3f3adc40), + TOBN(0xf407a942, 0x38a278e9), TOBN(0xd13c1b9d, 0x2ab21292)}, + {TOBN(0x93ed7ec7, 0x1c74cf5c), TOBN(0x8887dc48, 0xf1a4c1b4), + TOBN(0x3830ff30, 0x4b3a11f1), TOBN(0x358c5a3c, 0x58937cb6)}}, + {{TOBN(0x027dc404, 0x89022829), TOBN(0x40e93977, 0x3b798f79), + TOBN(0x90ad3337, 0x38be6ead), TOBN(0x9c23f6bc, 0xf34c0a5d)}, + {TOBN(0xd1711a35, 0xfbffd8bb), TOBN(0x60fcfb49, 0x1949d3dd), + TOBN(0x09c8ef4b, 0x7825d93a), TOBN(0x24233cff, 0xa0a8c968)}}, + {{TOBN(0x67ade46c, 0xe6d982af), TOBN(0xebb6bf3e, 0xe7544d7c), + TOBN(0xd6b9ba76, 0x3d8bd087), TOBN(0x46fe382d, 0x4dc61280)}, + {TOBN(0xbd39a7e8, 0xb5bdbd75), TOBN(0xab381331, 0xb8f228fe), + TOBN(0x0709a77c, 0xce1c4300), TOBN(0x6a247e56, 0xf337ceac)}}, + {{TOBN(0x8f34f21b, 0x636288be), TOBN(0x9dfdca74, 0xc8a7c305), + TOBN(0x6decfd1b, 0xea919e04), TOBN(0xcdf2688d, 0x8e1991f8)}, + {TOBN(0xe607df44, 0xd0f8a67e), TOBN(0xd985df4b, 0x0b58d010), + TOBN(0x57f834c5, 0x0c24f8f4), TOBN(0xe976ef56, 0xa0bf01ae)}}, + {{TOBN(0x536395ac, 0xa1c32373), TOBN(0x351027aa, 0x734c0a13), + TOBN(0xd2f1b5d6, 0x5e6bd5bc), TOBN(0x2b539e24, 0x223debed)}, + {TOBN(0xd4994cec, 0x0eaa1d71), TOBN(0x2a83381d, 0x661dcf65), + TOBN(0x5f1aed2f, 0x7b54c740), TOBN(0x0bea3fa5, 0xd6dda5ee)}}, + {{TOBN(0x9d4fb684, 0x36cc6134), TOBN(0x8eb9bbf3, 0xc0a443dd), + TOBN(0xfc500e2e, 0x383b7d2a), TOBN(0x7aad621c, 0x5b775257)}, + {TOBN(0x69284d74, 0x0a8f7cc0), TOBN(0xe820c2ce, 0x07562d65), + TOBN(0xbf9531b9, 0x499758ee), TOBN(0x73e95ca5, 0x6ee0cc2d)}}, + {{TOBN(0xf61790ab, 0xfbaf50a5), TOBN(0xdf55e76b, 0x684e0750), + TOBN(0xec516da7, 0xf176b005), TOBN(0x575553bb, 0x7a2dddc7)}, + {TOBN(0x37c87ca3, 0x553afa73), TOBN(0x315f3ffc, 0x4d55c251), + TOBN(0xe846442a, 0xaf3e5d35), TOBN(0x61b91149, 0x6495ff28)}}, + {{TOBN(0x23cc95d3, 0xfa326dc3), TOBN(0x1df4da1f, 0x18fc2cea), + TOBN(0x24bf9adc, 0xd0a37d59), TOBN(0xb6710053, 0x320d6e1e)}, + {TOBN(0x96f9667e, 0x618344d1), TOBN(0xcc7ce042, 0xa06445af), + TOBN(0xa02d8514, 0xd68dbc3a), TOBN(0x4ea109e4, 0x280b5a5b)}}, + {{TOBN(0x5741a7ac, 0xb40961bf), TOBN(0x4ada5937, 0x6aa56bfa), + TOBN(0x7feb9145, 0x02b765d1), TOBN(0x561e97be, 0xe6ad1582)}, + {TOBN(0xbbc4a5b6, 0xda3982f5), TOBN(0x0c2659ed, 0xb546f468), + TOBN(0xb8e7e6aa, 0x59612d20), TOBN(0xd83dfe20, 0xac19e8e0)}}, + {{TOBN(0x8530c45f, 0xb835398c), TOBN(0x6106a8bf, 0xb38a41c2), + TOBN(0x21e8f9a6, 0x35f5dcdb), TOBN(0x39707137, 0xcae498ed)}, + {TOBN(0x70c23834, 0xd8249f00), TOBN(0x9f14b58f, 0xab2537a0), + TOBN(0xd043c365, 0x5f61c0c2), TOBN(0xdc5926d6, 0x09a194a7)}}, + {{TOBN(0xddec0339, 0x8e77738a), TOBN(0xd07a63ef, 0xfba46426), + TOBN(0x2e58e79c, 0xee7f6e86), TOBN(0xe59b0459, 0xff32d241)}, + {TOBN(0xc5ec84e5, 0x20fa0338), TOBN(0x97939ac8, 0xeaff5ace), + TOBN(0x0310a4e3, 0xb4a38313), TOBN(0x9115fba2, 0x8f9d9885)}}, + {{TOBN(0x8dd710c2, 0x5fadf8c3), TOBN(0x66be38a2, 0xce19c0e2), + TOBN(0xd42a279c, 0x4cfe5022), TOBN(0x597bb530, 0x0e24e1b8)}, + {TOBN(0x3cde86b7, 0xc153ca7f), TOBN(0xa8d30fb3, 0x707d63bd), + TOBN(0xac905f92, 0xbd60d21e), TOBN(0x98e7ffb6, 0x7b9a54ab)}}, + {{TOBN(0xd7147df8, 0xe9726a30), TOBN(0xb5e216ff, 0xafce3533), + TOBN(0xb550b799, 0x2ff1ec40), TOBN(0x6b613b87, 0xa1e953fd)}, + {TOBN(0x87b88dba, 0x792d5610), TOBN(0x2ee1270a, 0xa190fbe1), + TOBN(0x02f4e2dc, 0x2ef581da), TOBN(0x016530e4, 0xeff82a95)}}, + {{TOBN(0xcbb93dfd, 0x8fd6ee89), TOBN(0x16d3d986, 0x46848fff), + TOBN(0x600eff24, 0x1da47adf), TOBN(0x1b9754a0, 0x0ad47a71)}, + {TOBN(0x8f9266df, 0x70c33b98), TOBN(0xaadc87ae, 0xdf34186e), + TOBN(0x0d2ce8e1, 0x4ad24132), TOBN(0x8a47cbfc, 0x19946eba)}}, + {{TOBN(0x47feeb66, 0x62b5f3af), TOBN(0xcefab561, 0x0abb3734), + TOBN(0x449de60e, 0x19f35cb1), TOBN(0x39f8db14, 0x157f0eb9)}, + {TOBN(0xffaecc5b, 0x3c61bfd6), TOBN(0xa5a4d41d, 0x41216703), + TOBN(0x7f8fabed, 0x224e1cc2), TOBN(0x0d5a8186, 0x871ad953)}}, + {{TOBN(0xf10774f7, 0xd22da9a9), TOBN(0x45b8a678, 0xcc8a9b0d), + TOBN(0xd9c2e722, 0xbdc32cff), TOBN(0xbf71b5f5, 0x337202a5)}, + {TOBN(0x95c57f2f, 0x69fc4db9), TOBN(0xb6dad34c, 0x765d01e1), + TOBN(0x7e0bd13f, 0xcb904635), TOBN(0x61751253, 0x763a588c)}}, + {{TOBN(0xd85c2997, 0x81af2c2d), TOBN(0xc0f7d9c4, 0x81b9d7da), + TOBN(0x838a34ae, 0x08533e8d), TOBN(0x15c4cb08, 0x311d8311)}, + {TOBN(0x97f83285, 0x8e121e14), TOBN(0xeea7dc1e, 0x85000a5f), + TOBN(0x0c6059b6, 0x5d256274), TOBN(0xec9beace, 0xb95075c0)}}, + {{TOBN(0x173daad7, 0x1df97828), TOBN(0xbf851cb5, 0xa8937877), + TOBN(0xb083c594, 0x01646f3c), TOBN(0x3bad30cf, 0x50c6d352)}, + {TOBN(0xfeb2b202, 0x496bbcea), TOBN(0x3cf9fd4f, 0x18a1e8ba), + TOBN(0xd26de7ff, 0x1c066029), TOBN(0x39c81e9e, 0x4e9ed4f8)}}, + {{TOBN(0xd8be0cb9, 0x7b390d35), TOBN(0x01df2bbd, 0x964aab27), + TOBN(0x3e8c1a65, 0xc3ef64f8), TOBN(0x567291d1, 0x716ed1dd)}, + {TOBN(0x95499c6c, 0x5f5406d3), TOBN(0x71fdda39, 0x5ba8e23f), + TOBN(0xcfeb320e, 0xd5096ece), TOBN(0xbe7ba92b, 0xca66dd16)}}, + {{TOBN(0x4608d36b, 0xc6fb5a7d), TOBN(0xe3eea15a, 0x6d2dd0e0), + TOBN(0x75b0a3eb, 0x8f97a36a), TOBN(0xf59814cc, 0x1c83de1e)}, + {TOBN(0x56c9c5b0, 0x1c33c23f), TOBN(0xa96c1da4, 0x6faa4136), + TOBN(0x46bf2074, 0xde316551), TOBN(0x3b866e7b, 0x1f756c8f)}}, + {{TOBN(0x727727d8, 0x1495ed6b), TOBN(0xb2394243, 0xb682dce7), + TOBN(0x8ab8454e, 0x758610f3), TOBN(0xc243ce84, 0x857d72a4)}, + {TOBN(0x7b320d71, 0xdbbf370f), TOBN(0xff9afa37, 0x78e0f7ca), + TOBN(0x0119d1e0, 0xea7b523f), TOBN(0xb997f8cb, 0x058c7d42)}}, + {{TOBN(0x285bcd2a, 0x37bbb184), TOBN(0x51dcec49, 0xa45d1fa6), + TOBN(0x6ade3b64, 0xe29634cb), TOBN(0x080c94a7, 0x26b86ef1)}, + {TOBN(0xba583db1, 0x2283fbe3), TOBN(0x902bddc8, 0x5a9315ed), + TOBN(0x07c1ccb3, 0x86964bec), TOBN(0x78f4eacf, 0xb6258301)}}, + {{TOBN(0x4bdf3a49, 0x56f90823), TOBN(0xba0f5080, 0x741d777b), + TOBN(0x091d71c3, 0xf38bf760), TOBN(0x9633d50f, 0x9b625b02)}, + {TOBN(0x03ecb743, 0xb8c9de61), TOBN(0xb4751254, 0x5de74720), + TOBN(0x9f9defc9, 0x74ce1cb2), TOBN(0x774a4f6a, 0x00bd32ef)}}, + {{TOBN(0xaca385f7, 0x73848f22), TOBN(0x53dad716, 0xf3f8558e), + TOBN(0xab7b34b0, 0x93c471f9), TOBN(0xf530e069, 0x19644bc7)}, + {TOBN(0x3d9fb1ff, 0xdd59d31a), TOBN(0x4382e0df, 0x08daa795), + TOBN(0x165c6f4b, 0xd5cc88d7), TOBN(0xeaa392d5, 0x4a18c900)}}, + {{TOBN(0x94203c67, 0x648024ee), TOBN(0x188763f2, 0x8c2fabcd), + TOBN(0xa80f87ac, 0xbbaec835), TOBN(0x632c96e0, 0xf29d8d54)}, + {TOBN(0x29b0a60e, 0x4c00a95e), TOBN(0x2ef17f40, 0xe011e9fa), + TOBN(0xf6c0e1d1, 0x15b77223), TOBN(0xaaec2c62, 0x14b04e32)}}, + {{TOBN(0xd35688d8, 0x3d84e58c), TOBN(0x2af5094c, 0x958571db), + TOBN(0x4fff7e19, 0x760682a6), TOBN(0x4cb27077, 0xe39a407c)}, + {TOBN(0x0f59c547, 0x4ff0e321), TOBN(0x169f34a6, 0x1b34c8ff), + TOBN(0x2bff1096, 0x52bc1ba7), TOBN(0xa25423b7, 0x83583544)}}, + {{TOBN(0x5d55d5d5, 0x0ac8b782), TOBN(0xff6622ec, 0x2db3c892), + TOBN(0x48fce741, 0x6b8bb642), TOBN(0x31d6998c, 0x69d7e3dc)}, + {TOBN(0xdbaf8004, 0xcadcaed0), TOBN(0x801b0142, 0xd81d053c), + TOBN(0x94b189fc, 0x59630ec6), TOBN(0x120e9934, 0xaf762c8e)}}, + {{TOBN(0x53a29aa4, 0xfdc6a404), TOBN(0x19d8e01e, 0xa1909948), + TOBN(0x3cfcabf1, 0xd7e89681), TOBN(0x3321a50d, 0x4e132d37)}, + {TOBN(0xd0496863, 0xe9a86111), TOBN(0x8c0cde61, 0x06a3bc65), + TOBN(0xaf866c49, 0xfc9f8eef), TOBN(0x2066350e, 0xff7f5141)}}, + {{TOBN(0x4f8a4689, 0xe56ddfbd), TOBN(0xea1b0c07, 0xfe32983a), + TOBN(0x2b317462, 0x873cb8cb), TOBN(0x658deddc, 0x2d93229f)}, + {TOBN(0x65efaf4d, 0x0f64ef58), TOBN(0xfe43287d, 0x730cc7a8), + TOBN(0xaebc0c72, 0x3d047d70), TOBN(0x92efa539, 0xd92d26c9)}}, + {{TOBN(0x06e78457, 0x94b56526), TOBN(0x415cb80f, 0x0961002d), + TOBN(0x89e5c565, 0x76dcb10f), TOBN(0x8bbb6982, 0xff9259fe)}, + {TOBN(0x4fe8795b, 0x9abc2668), TOBN(0xb5d4f534, 0x1e678fb1), + TOBN(0x6601f3be, 0x7b7da2b9), TOBN(0x98da59e2, 0xa13d6805)}}, + {{TOBN(0x190d8ea6, 0x01799a52), TOBN(0xa20cec41, 0xb86d2952), + TOBN(0x3062ffb2, 0x7fff2a7c), TOBN(0x741b32e5, 0x79f19d37)}, + {TOBN(0xf80d8181, 0x4eb57d47), TOBN(0x7a2d0ed4, 0x16aef06b), + TOBN(0x09735fb0, 0x1cecb588), TOBN(0x1641caaa, 0xc6061f5b)}}}, + {{{TOBN(0x7f99824f, 0x20151427), TOBN(0x206828b6, 0x92430206), + TOBN(0xaa9097d7, 0xe1112357), TOBN(0xacf9a2f2, 0x09e414ec)}, + {TOBN(0xdbdac9da, 0x27915356), TOBN(0x7e0734b7, 0x001efee3), + TOBN(0x54fab5bb, 0xd2b288e2), TOBN(0x4c630fc4, 0xf62dd09c)}}, + {{TOBN(0x8537107a, 0x1ac2703b), TOBN(0xb49258d8, 0x6bc857b5), + TOBN(0x57df14de, 0xbcdaccd1), TOBN(0x24ab68d7, 0xc4ae8529)}, + {TOBN(0x7ed8b5d4, 0x734e59d0), TOBN(0x5f8740c8, 0xc495cc80), + TOBN(0x84aedd5a, 0x291db9b3), TOBN(0x80b360f8, 0x4fb995be)}}, + {{TOBN(0xae915f5d, 0x5fa067d1), TOBN(0x4134b57f, 0x9668960c), + TOBN(0xbd3656d6, 0xa48edaac), TOBN(0xdac1e3e4, 0xfc1d7436)}, + {TOBN(0x674ff869, 0xd81fbb26), TOBN(0x449ed3ec, 0xb26c33d4), + TOBN(0x85138705, 0xd94203e8), TOBN(0xccde538b, 0xbeeb6f4a)}}, + {{TOBN(0x55d5c68d, 0xa61a76fa), TOBN(0x598b441d, 0xca1554dc), + TOBN(0xd39923b9, 0x773b279c), TOBN(0x33331d3c, 0x36bf9efc)}, + {TOBN(0x2d4c848e, 0x298de399), TOBN(0xcfdb8e77, 0xa1a27f56), + TOBN(0x94c855ea, 0x57b8ab70), TOBN(0xdcdb9dae, 0x6f7879ba)}}, + {{TOBN(0x7bdff8c2, 0x019f2a59), TOBN(0xb3ce5bb3, 0xcb4fbc74), + TOBN(0xea907f68, 0x8a9173dd), TOBN(0x6cd3d0d3, 0x95a75439)}, + {TOBN(0x92ecc4d6, 0xefed021c), TOBN(0x09a9f9b0, 0x6a77339a), + TOBN(0x87ca6b15, 0x7188c64a), TOBN(0x10c29968, 0x44899158)}}, + {{TOBN(0x5859a229, 0xed6e82ef), TOBN(0x16f338e3, 0x65ebaf4e), + TOBN(0x0cd31387, 0x5ead67ae), TOBN(0x1c73d228, 0x54ef0bb4)}, + {TOBN(0x4cb55131, 0x74a5c8c7), TOBN(0x01cd2970, 0x7f69ad6a), + TOBN(0xa04d00dd, 0xe966f87e), TOBN(0xd96fe447, 0x0b7b0321)}}, + {{TOBN(0x342ac06e, 0x88fbd381), TOBN(0x02cd4a84, 0x5c35a493), + TOBN(0xe8fa89de, 0x54f1bbcd), TOBN(0x341d6367, 0x2575ed4c)}, + {TOBN(0xebe357fb, 0xd238202b), TOBN(0x600b4d1a, 0xa984ead9), + TOBN(0xc35c9f44, 0x52436ea0), TOBN(0x96fe0a39, 0xa370751b)}}, + {{TOBN(0x4c4f0736, 0x7f636a38), TOBN(0x9f943fb7, 0x0e76d5cb), + TOBN(0xb03510ba, 0xa8b68b8b), TOBN(0xc246780a, 0x9ed07a1f)}, + {TOBN(0x3c051415, 0x6d549fc2), TOBN(0xc2953f31, 0x607781ca), + TOBN(0x955e2c69, 0xd8d95413), TOBN(0xb300fadc, 0x7bd282e3)}}, + {{TOBN(0x81fe7b50, 0x87e9189f), TOBN(0xdb17375c, 0xf42dda27), + TOBN(0x22f7d896, 0xcf0a5904), TOBN(0xa0e57c5a, 0xebe348e6)}, + {TOBN(0xa61011d3, 0xf40e3c80), TOBN(0xb1189321, 0x8db705c5), + TOBN(0x4ed9309e, 0x50fedec3), TOBN(0xdcf14a10, 0x4d6d5c1d)}}, + {{TOBN(0x056c265b, 0x55691342), TOBN(0xe8e08504, 0x91049dc7), + TOBN(0x131329f5, 0xc9bae20a), TOBN(0x96c8b3e8, 0xd9dccdb4)}, + {TOBN(0x8c5ff838, 0xfb4ee6b4), TOBN(0xfc5a9aeb, 0x41e8ccf0), + TOBN(0x7417b764, 0xfae050c6), TOBN(0x0953c3d7, 0x00452080)}}, + {{TOBN(0x21372682, 0x38dfe7e8), TOBN(0xea417e15, 0x2bb79d4b), + TOBN(0x59641f1c, 0x76e7cf2d), TOBN(0x271e3059, 0xea0bcfcc)}, + {TOBN(0x624c7dfd, 0x7253ecbd), TOBN(0x2f552e25, 0x4fca6186), + TOBN(0xcbf84ecd, 0x4d866e9c), TOBN(0x73967709, 0xf68d4610)}}, + {{TOBN(0xa14b1163, 0xc27901b4), TOBN(0xfd9236e0, 0x899b8bf3), + TOBN(0x42b091ec, 0xcbc6da0a), TOBN(0xbb1dac6f, 0x5ad1d297)}, + {TOBN(0x80e61d53, 0xa91cf76e), TOBN(0x4110a412, 0xd31f1ee7), + TOBN(0x2d87c3ba, 0x13efcf77), TOBN(0x1f374bb4, 0xdf450d76)}}, + {{TOBN(0x5e78e2f2, 0x0d188dab), TOBN(0xe3968ed0, 0xf4b885ef), + TOBN(0x46c0568e, 0x7314570f), TOBN(0x31616338, 0x01170521)}, + {TOBN(0x18e1e7e2, 0x4f0c8afe), TOBN(0x4caa75ff, 0xdeea78da), + TOBN(0x82db67f2, 0x7c5d8a51), TOBN(0x36a44d86, 0x6f505370)}}, + {{TOBN(0xd72c5bda, 0x0333974f), TOBN(0x5db516ae, 0x27a70146), + TOBN(0x34705281, 0x210ef921), TOBN(0xbff17a8f, 0x0c9c38e5)}, + {TOBN(0x78f4814e, 0x12476da1), TOBN(0xc1e16613, 0x33c16980), + TOBN(0x9e5b386f, 0x424d4bca), TOBN(0x4c274e87, 0xc85740de)}}, + {{TOBN(0xb6a9b88d, 0x6c2f5226), TOBN(0x14d1b944, 0x550d7ca8), + TOBN(0x580c85fc, 0x1fc41709), TOBN(0xc1da368b, 0x54c6d519)}, + {TOBN(0x2b0785ce, 0xd5113cf7), TOBN(0x0670f633, 0x5a34708f), + TOBN(0x46e23767, 0x15cc3f88), TOBN(0x1b480cfa, 0x50c72c8f)}}, + {{TOBN(0x20288602, 0x4147519a), TOBN(0xd0981eac, 0x26b372f0), + TOBN(0xa9d4a7ca, 0xa785ebc8), TOBN(0xd953c50d, 0xdbdf58e9)}, + {TOBN(0x9d6361cc, 0xfd590f8f), TOBN(0x72e9626b, 0x44e6c917), + TOBN(0x7fd96110, 0x22eb64cf), TOBN(0x863ebb7e, 0x9eb288f3)}}, + {{TOBN(0x6e6ab761, 0x6aca8ee7), TOBN(0x97d10b39, 0xd7b40358), + TOBN(0x1687d377, 0x1e5feb0d), TOBN(0xc83e50e4, 0x8265a27a)}, + {TOBN(0x8f75a9fe, 0xc954b313), TOBN(0xcc2e8f47, 0x310d1f61), + TOBN(0xf5ba81c5, 0x6557d0e0), TOBN(0x25f9680c, 0x3eaf6207)}}, + {{TOBN(0xf95c6609, 0x4354080b), TOBN(0x5225bfa5, 0x7bf2fe1c), + TOBN(0xc5c004e2, 0x5c7d98fa), TOBN(0x3561bf1c, 0x019aaf60)}, + {TOBN(0x5e6f9f17, 0xba151474), TOBN(0xdec2f934, 0xb04f6eca), + TOBN(0x64e368a1, 0x269acb1e), TOBN(0x1332d9e4, 0x0cdda493)}}, + {{TOBN(0x60d6cf69, 0xdf23de05), TOBN(0x66d17da2, 0x009339a0), + TOBN(0x9fcac985, 0x0a693923), TOBN(0xbcf057fc, 0xed7c6a6d)}, + {TOBN(0xc3c5c8c5, 0xf0b5662c), TOBN(0x25318dd8, 0xdcba4f24), + TOBN(0x60e8cb75, 0x082b69ff), TOBN(0x7c23b3ee, 0x1e728c01)}}, + {{TOBN(0x15e10a0a, 0x097e4403), TOBN(0xcb3d0a86, 0x19854665), + TOBN(0x88d8e211, 0xd67d4826), TOBN(0xb39af66e, 0x0b9d2839)}, + {TOBN(0xa5f94588, 0xbd475ca8), TOBN(0xe06b7966, 0xc077b80b), + TOBN(0xfedb1485, 0xda27c26c), TOBN(0xd290d33a, 0xfe0fd5e0)}}, + {{TOBN(0xa40bcc47, 0xf34fb0fa), TOBN(0xb4760cc8, 0x1fb1ab09), + TOBN(0x8fca0993, 0xa273bfe3), TOBN(0x13e4fe07, 0xf70b213c)}, + {TOBN(0x3bcdb992, 0xfdb05163), TOBN(0x8c484b11, 0x0c2b19b6), + TOBN(0x1acb815f, 0xaaf2e3e2), TOBN(0xc6905935, 0xb89ff1b4)}}, + {{TOBN(0xb2ad6f9d, 0x586e74e1), TOBN(0x488883ad, 0x67b80484), + TOBN(0x758aa2c7, 0x369c3ddb), TOBN(0x8ab74e69, 0x9f9afd31)}, + {TOBN(0x10fc2d28, 0x5e21beb1), TOBN(0x3484518a, 0x318c42f9), + TOBN(0x377427dc, 0x53cf40c3), TOBN(0x9de0781a, 0x391bc1d9)}}, + {{TOBN(0x8faee858, 0x693807e1), TOBN(0xa3865327, 0x4e81ccc7), + TOBN(0x02c30ff2, 0x6f835b84), TOBN(0xb604437b, 0x0d3d38d4)}, + {TOBN(0xb3fc8a98, 0x5ca1823d), TOBN(0xb82f7ec9, 0x03be0324), + TOBN(0xee36d761, 0xcf684a33), TOBN(0x5a01df0e, 0x9f29bf7d)}}, + {{TOBN(0x686202f3, 0x1306583d), TOBN(0x05b10da0, 0x437c622e), + TOBN(0xbf9aaa0f, 0x076a7bc8), TOBN(0x25e94efb, 0x8f8f4e43)}, + {TOBN(0x8a35c9b7, 0xfa3dc26d), TOBN(0xe0e5fb93, 0x96ff03c5), + TOBN(0xa77e3843, 0xebc394ce), TOBN(0xcede6595, 0x8361de60)}}, + {{TOBN(0xd27c22f6, 0xa1993545), TOBN(0xab01cc36, 0x24d671ba), + TOBN(0x63fa2877, 0xa169c28e), TOBN(0x925ef904, 0x2eb08376)}, + {TOBN(0x3b2fa3cf, 0x53aa0b32), TOBN(0xb27beb5b, 0x71c49d7a), + TOBN(0xb60e1834, 0xd105e27f), TOBN(0xd6089788, 0x4f68570d)}}, + {{TOBN(0x23094ce0, 0xd6fbc2ac), TOBN(0x738037a1, 0x815ff551), + TOBN(0xda73b1bb, 0x6bef119c), TOBN(0xdcf6c430, 0xeef506ba)}, + {TOBN(0x00e4fe7b, 0xe3ef104a), TOBN(0xebdd9a2c, 0x0a065628), + TOBN(0x853a81c3, 0x8792043e), TOBN(0x22ad6ece, 0xb3b59108)}}, + {{TOBN(0x9fb813c0, 0x39cd297d), TOBN(0x8ec7e16e, 0x05bda5d9), + TOBN(0x2834797c, 0x0d104b96), TOBN(0xcc11a2e7, 0x7c511510)}, + {TOBN(0x96ca5a53, 0x96ee6380), TOBN(0x054c8655, 0xcea38742), + TOBN(0xb5946852, 0xd54dfa7d), TOBN(0x97c422e7, 0x1f4ab207)}}, + {{TOBN(0xbf907509, 0x0c22b540), TOBN(0x2cde42aa, 0xb7c267d4), + TOBN(0xba18f9ed, 0x5ab0d693), TOBN(0x3ba62aa6, 0x6e4660d9)}, + {TOBN(0xb24bf97b, 0xab9ea96a), TOBN(0x5d039642, 0xe3b60e32), + TOBN(0x4e6a4506, 0x7c4d9bd5), TOBN(0x666c5b9e, 0x7ed4a6a4)}}, + {{TOBN(0xfa3fdcd9, 0x8edbd7cc), TOBN(0x4660bb87, 0xc6ccd753), + TOBN(0x9ae90820, 0x21e6b64f), TOBN(0x8a56a713, 0xb36bfb3f)}, + {TOBN(0xabfce096, 0x5726d47f), TOBN(0x9eed01b2, 0x0b1a9a7f), + TOBN(0x30e9cad4, 0x4eb74a37), TOBN(0x7b2524cc, 0x53e9666d)}}, + {{TOBN(0x6a29683b, 0x8f4b002f), TOBN(0xc2200d7a, 0x41f4fc20), + TOBN(0xcf3af47a, 0x3a338acc), TOBN(0x6539a4fb, 0xe7128975)}, + {TOBN(0xcec31c14, 0xc33c7fcf), TOBN(0x7eb6799b, 0xc7be322b), + TOBN(0x119ef4e9, 0x6646f623), TOBN(0x7b7a26a5, 0x54d7299b)}}, + {{TOBN(0xcb37f08d, 0x403f46f2), TOBN(0x94b8fc43, 0x1a0ec0c7), + TOBN(0xbb8514e3, 0xc332142f), TOBN(0xf3ed2c33, 0xe80d2a7a)}, + {TOBN(0x8d2080af, 0xb639126c), TOBN(0xf7b6be60, 0xe3553ade), + TOBN(0x3950aa9f, 0x1c7e2b09), TOBN(0x847ff958, 0x6410f02b)}}, + {{TOBN(0x877b7cf5, 0x678a31b0), TOBN(0xd50301ae, 0x3998b620), + TOBN(0x734257c5, 0xc00fb396), TOBN(0xf9fb18a0, 0x04e672a6)}, + {TOBN(0xff8bd8eb, 0xe8758851), TOBN(0x1e64e4c6, 0x5d99ba44), + TOBN(0x4b8eaedf, 0x7dfd93b7), TOBN(0xba2f2a98, 0x04e76b8c)}}, + {{TOBN(0x7d790cba, 0xe8053433), TOBN(0xc8e725a0, 0x3d2c9585), + TOBN(0x58c5c476, 0xcdd8f5ed), TOBN(0xd106b952, 0xefa9fe1d)}, + {TOBN(0x3c5c775b, 0x0eff13a9), TOBN(0x242442ba, 0xe057b930), + TOBN(0xe9f458d4, 0xc9b70cbd), TOBN(0x69b71448, 0xa3cdb89a)}}, + {{TOBN(0x41ee46f6, 0x0e2ed742), TOBN(0x573f1045, 0x40067493), + TOBN(0xb1e154ff, 0x9d54c304), TOBN(0x2ad0436a, 0x8d3a7502)}, + {TOBN(0xee4aaa2d, 0x431a8121), TOBN(0xcd38b3ab, 0x886f11ed), + TOBN(0x57d49ea6, 0x034a0eb7), TOBN(0xd2b773bd, 0xf7e85e58)}}, + {{TOBN(0x4a559ac4, 0x9b5c1f14), TOBN(0xc444be1a, 0x3e54df2b), + TOBN(0x13aad704, 0xeda41891), TOBN(0xcd927bec, 0x5eb5c788)}, + {TOBN(0xeb3c8516, 0xe48c8a34), TOBN(0x1b7ac812, 0x4b546669), + TOBN(0x1815f896, 0x594df8ec), TOBN(0x87c6a79c, 0x79227865)}}, + {{TOBN(0xae02a2f0, 0x9b56ddbd), TOBN(0x1339b5ac, 0x8a2f1cf3), + TOBN(0xf2b569c7, 0x839dff0d), TOBN(0xb0b9e864, 0xfee9a43d)}, + {TOBN(0x4ff8ca41, 0x77bb064e), TOBN(0x145a2812, 0xfd249f63), + TOBN(0x3ab7beac, 0xf86f689a), TOBN(0x9bafec27, 0x01d35f5e)}}, + {{TOBN(0x28054c65, 0x4265aa91), TOBN(0xa4b18304, 0x035efe42), + TOBN(0x6887b0e6, 0x9639dec7), TOBN(0xf4b8f6ad, 0x3d52aea5)}, + {TOBN(0xfb9293cc, 0x971a8a13), TOBN(0x3f159e5d, 0x4c934d07), + TOBN(0x2c50e9b1, 0x09acbc29), TOBN(0x08eb65e6, 0x7154d129)}}, + {{TOBN(0x4feff589, 0x30b75c3e), TOBN(0x0bb82fe2, 0x94491c93), + TOBN(0xd8ac377a, 0x89af62bb), TOBN(0xd7b51490, 0x9685e49f)}, + {TOBN(0xabca9a7b, 0x04497f19), TOBN(0x1b35ed0a, 0x1a7ad13f), + TOBN(0x6b601e21, 0x3ec86ed6), TOBN(0xda91fcb9, 0xce0c76f1)}}, + {{TOBN(0x9e28507b, 0xd7ab27e1), TOBN(0x7c19a555, 0x63945b7b), + TOBN(0x6b43f0a1, 0xaafc9827), TOBN(0x443b4fbd, 0x3aa55b91)}, + {TOBN(0x962b2e65, 0x6962c88f), TOBN(0x139da8d4, 0xce0db0ca), + TOBN(0xb93f05dd, 0x1b8d6c4f), TOBN(0x779cdff7, 0x180b9824)}}, + {{TOBN(0xbba23fdd, 0xae57c7b7), TOBN(0x345342f2, 0x1b932522), + TOBN(0xfd9c80fe, 0x556d4aa3), TOBN(0xa03907ba, 0x6525bb61)}, + {TOBN(0x38b010e1, 0xff218933), TOBN(0xc066b654, 0xaa52117b), + TOBN(0x8e141920, 0x94f2e6ea), TOBN(0x66a27dca, 0x0d32f2b2)}}, + {{TOBN(0x69c7f993, 0x048b3717), TOBN(0xbf5a989a, 0xb178ae1c), + TOBN(0x49fa9058, 0x564f1d6b), TOBN(0x27ec6e15, 0xd31fde4e)}, + {TOBN(0x4cce0373, 0x7276e7fc), TOBN(0x64086d79, 0x89d6bf02), + TOBN(0x5a72f046, 0x4ccdd979), TOBN(0x909c3566, 0x47775631)}}, + {{TOBN(0x1c07bc6b, 0x75dd7125), TOBN(0xb4c6bc97, 0x87a0428d), + TOBN(0x507ece52, 0xfdeb6b9d), TOBN(0xfca56512, 0xb2c95432)}, + {TOBN(0x15d97181, 0xd0e8bd06), TOBN(0x384dd317, 0xc6bb46ea), + TOBN(0x5441ea20, 0x3952b624), TOBN(0xbcf70dee, 0x4e7dc2fb)}}, + {{TOBN(0x372b016e, 0x6628e8c3), TOBN(0x07a0d667, 0xb60a7522), + TOBN(0xcf05751b, 0x0a344ee2), TOBN(0x0ec09a48, 0x118bdeec)}, + {TOBN(0x6e4b3d4e, 0xd83dce46), TOBN(0x43a6316d, 0x99d2fc6e), + TOBN(0xa99d8989, 0x56cf044c), TOBN(0x7c7f4454, 0xae3e5fb7)}}, + {{TOBN(0xb2e6b121, 0xfbabbe92), TOBN(0x281850fb, 0xe1330076), + TOBN(0x093581ec, 0x97890015), TOBN(0x69b1dded, 0x75ff77f5)}, + {TOBN(0x7cf0b18f, 0xab105105), TOBN(0x953ced31, 0xa89ccfef), + TOBN(0x3151f85f, 0xeb914009), TOBN(0x3c9f1b87, 0x88ed48ad)}}, + {{TOBN(0xc9aba1a1, 0x4a7eadcb), TOBN(0x928e7501, 0x522e71cf), + TOBN(0xeaede727, 0x3a2e4f83), TOBN(0x467e10d1, 0x1ce3bbd3)}, + {TOBN(0xf3442ac3, 0xb955dcf0), TOBN(0xba96307d, 0xd3d5e527), + TOBN(0xf763a10e, 0xfd77f474), TOBN(0x5d744bd0, 0x6a6e1ff0)}}, + {{TOBN(0xd287282a, 0xa777899e), TOBN(0xe20eda8f, 0xd03f3cde), + TOBN(0x6a7e75bb, 0x50b07d31), TOBN(0x0b7e2a94, 0x6f379de4)}, + {TOBN(0x31cb64ad, 0x19f593cf), TOBN(0x7b1a9e4f, 0x1e76ef1d), + TOBN(0xe18c9c9d, 0xb62d609c), TOBN(0x439bad6d, 0xe779a650)}}, + {{TOBN(0x219d9066, 0xe032f144), TOBN(0x1db632b8, 0xe8b2ec6a), + TOBN(0xff0d0fd4, 0xfda12f78), TOBN(0x56fb4c2d, 0x2a25d265)}, + {TOBN(0x5f4e2ee1, 0x255a03f1), TOBN(0x61cd6af2, 0xe96af176), + TOBN(0xe0317ba8, 0xd068bc97), TOBN(0x927d6bab, 0x264b988e)}}, + {{TOBN(0xa18f07e0, 0xe90fb21e), TOBN(0x00fd2b80, 0xbba7fca1), + TOBN(0x20387f27, 0x95cd67b5), TOBN(0x5b89a4e7, 0xd39707f7)}, + {TOBN(0x8f83ad3f, 0x894407ce), TOBN(0xa0025b94, 0x6c226132), + TOBN(0xc79563c7, 0xf906c13b), TOBN(0x5f548f31, 0x4e7bb025)}}, + {{TOBN(0x2b4c6b8f, 0xeac6d113), TOBN(0xa67e3f9c, 0x0e813c76), + TOBN(0x3982717c, 0x3fe1f4b9), TOBN(0x58865819, 0x26d8050e)}, + {TOBN(0x99f3640c, 0xf7f06f20), TOBN(0xdc610216, 0x2a66ebc2), + TOBN(0x52f2c175, 0x767a1e08), TOBN(0x05660e1a, 0x5999871b)}}, + {{TOBN(0x6b0f1762, 0x6d3c4693), TOBN(0xf0e7d627, 0x37ed7bea), + TOBN(0xc51758c7, 0xb75b226d), TOBN(0x40a88628, 0x1f91613b)}, + {TOBN(0x889dbaa7, 0xbbb38ce0), TOBN(0xe0404b65, 0xbddcad81), + TOBN(0xfebccd3a, 0x8bc9671f), TOBN(0xfbf9a357, 0xee1f5375)}}, + {{TOBN(0x5dc169b0, 0x28f33398), TOBN(0xb07ec11d, 0x72e90f65), + TOBN(0xae7f3b4a, 0xfaab1eb1), TOBN(0xd970195e, 0x5f17538a)}, + {TOBN(0x52b05cbe, 0x0181e640), TOBN(0xf5debd62, 0x2643313d), + TOBN(0x76148154, 0x5df31f82), TOBN(0x23e03b33, 0x3a9e13c5)}}, + {{TOBN(0xff758949, 0x4fde0c1f), TOBN(0xbf8a1abe, 0xe5b6ec20), + TOBN(0x702278fb, 0x87e1db6c), TOBN(0xc447ad7a, 0x35ed658f)}, + {TOBN(0x48d4aa38, 0x03d0ccf2), TOBN(0x80acb338, 0x819a7c03), + TOBN(0x9bc7c89e, 0x6e17cecc), TOBN(0x46736b8b, 0x03be1d82)}}, + {{TOBN(0xd65d7b60, 0xc0432f96), TOBN(0xddebe7a3, 0xdeb5442f), + TOBN(0x79a25307, 0x7dff69a2), TOBN(0x37a56d94, 0x02cf3122)}, + {TOBN(0x8bab8aed, 0xf2350d0a), TOBN(0x13c3f276, 0x037b0d9a), + TOBN(0xc664957c, 0x44c65cae), TOBN(0x88b44089, 0xc2e71a88)}}, + {{TOBN(0xdb88e5a3, 0x5cb02664), TOBN(0x5d4c0bf1, 0x8686c72e), + TOBN(0xea3d9b62, 0xa682d53e), TOBN(0x9b605ef4, 0x0b2ad431)}, + {TOBN(0x71bac202, 0xc69645d0), TOBN(0xa115f03a, 0x6a1b66e7), + TOBN(0xfe2c563a, 0x158f4dc4), TOBN(0xf715b3a0, 0x4d12a78c)}}, + {{TOBN(0x8f7f0a48, 0xd413213a), TOBN(0x2035806d, 0xc04becdb), + TOBN(0xecd34a99, 0x5d8587f5), TOBN(0x4d8c3079, 0x9f6d3a71)}, + {TOBN(0x1b2a2a67, 0x8d95a8f6), TOBN(0xc58c9d7d, 0xf2110d0d), + TOBN(0xdeee81d5, 0xcf8fba3f), TOBN(0xa42be3c0, 0x0c7cdf68)}}, + {{TOBN(0x2126f742, 0xd43b5eaa), TOBN(0x054a0766, 0xdfa59b85), + TOBN(0x9d0d5e36, 0x126bfd45), TOBN(0xa1f8fbd7, 0x384f8a8f)}, + {TOBN(0x317680f5, 0xd563fccc), TOBN(0x48ca5055, 0xf280a928), + TOBN(0xe00b81b2, 0x27b578cf), TOBN(0x10aad918, 0x2994a514)}}, + {{TOBN(0xd9e07b62, 0xb7bdc953), TOBN(0x9f0f6ff2, 0x5bc086dd), + TOBN(0x09d1ccff, 0x655eee77), TOBN(0x45475f79, 0x5bef7df1)}, + {TOBN(0x3faa28fa, 0x86f702cc), TOBN(0x92e60905, 0x0f021f07), + TOBN(0xe9e62968, 0x7f8fa8c6), TOBN(0xbd71419a, 0xf036ea2c)}}, + {{TOBN(0x171ee1cc, 0x6028da9a), TOBN(0x5352fe1a, 0xc251f573), + TOBN(0xf8ff236e, 0x3fa997f4), TOBN(0xd831b6c9, 0xa5749d5f)}, + {TOBN(0x7c872e1d, 0xe350e2c2), TOBN(0xc56240d9, 0x1e0ce403), + TOBN(0xf9deb077, 0x6974f5cb), TOBN(0x7d50ba87, 0x961c3728)}}, + {{TOBN(0xd6f89426, 0x5a3a2518), TOBN(0xcf817799, 0xc6303d43), + TOBN(0x510a0471, 0x619e5696), TOBN(0xab049ff6, 0x3a5e307b)}, + {TOBN(0xe4cdf9b0, 0xfeb13ec7), TOBN(0xd5e97117, 0x9d8ff90c), + TOBN(0xf6f64d06, 0x9afa96af), TOBN(0x00d0bf5e, 0x9d2012a2)}}, + {{TOBN(0xe63f301f, 0x358bcdc0), TOBN(0x07689e99, 0x0a9d47f8), + TOBN(0x1f689e2f, 0x4f43d43a), TOBN(0x4d542a16, 0x90920904)}, + {TOBN(0xaea293d5, 0x9ca0a707), TOBN(0xd061fe45, 0x8ac68065), + TOBN(0x1033bf1b, 0x0090008c), TOBN(0x29749558, 0xc08a6db6)}}, + {{TOBN(0x74b5fc59, 0xc1d5d034), TOBN(0xf712e9f6, 0x67e215e0), + TOBN(0xfd520cbd, 0x860200e6), TOBN(0x0229acb4, 0x3ea22588)}, + {TOBN(0x9cd1e14c, 0xfff0c82e), TOBN(0x87684b62, 0x59c69e73), + TOBN(0xda85e61c, 0x96ccb989), TOBN(0x2d5dbb02, 0xa3d06493)}}, + {{TOBN(0xf22ad33a, 0xe86b173c), TOBN(0xe8e41ea5, 0xa79ff0e3), + TOBN(0x01d2d725, 0xdd0d0c10), TOBN(0x31f39088, 0x032d28f9)}, + {TOBN(0x7b3f71e1, 0x7829839e), TOBN(0x0cf691b4, 0x4502ae58), + TOBN(0xef658dbd, 0xbefc6115), TOBN(0xa5cd6ee5, 0xb3ab5314)}}, + {{TOBN(0x206c8d7b, 0x5f1d2347), TOBN(0x794645ba, 0x4cc2253a), + TOBN(0xd517d8ff, 0x58389e08), TOBN(0x4fa20dee, 0x9f847288)}, + {TOBN(0xeba072d8, 0xd797770a), TOBN(0x7360c91d, 0xbf429e26), + TOBN(0x7200a3b3, 0x80af8279), TOBN(0x6a1c9150, 0x82dadce3)}}, + {{TOBN(0x0ee6d3a7, 0xc35d8794), TOBN(0x042e6558, 0x0356bae5), + TOBN(0x9f59698d, 0x643322fd), TOBN(0x9379ae15, 0x50a61967)}, + {TOBN(0x64b9ae62, 0xfcc9981e), TOBN(0xaed3d631, 0x6d2934c6), + TOBN(0x2454b302, 0x5e4e65eb), TOBN(0xab09f647, 0xf9950428)}}}, + {{{TOBN(0xb2083a12, 0x22248acc), TOBN(0x1f6ec0ef, 0x3264e366), + TOBN(0x5659b704, 0x5afdee28), TOBN(0x7a823a40, 0xe6430bb5)}, + {TOBN(0x24592a04, 0xe1900a79), TOBN(0xcde09d4a, 0xc9ee6576), + TOBN(0x52b6463f, 0x4b5ea54a), TOBN(0x1efe9ed3, 0xd3ca65a7)}}, + {{TOBN(0xe27a6dbe, 0x305406dd), TOBN(0x8eb7dc7f, 0xdd5d1957), + TOBN(0xf54a6876, 0x387d4d8f), TOBN(0x9c479409, 0xc7762de4)}, + {TOBN(0xbe4d5b5d, 0x99b30778), TOBN(0x25380c56, 0x6e793682), + TOBN(0x602d37f3, 0xdac740e3), TOBN(0x140deabe, 0x1566e4ae)}}, + {{TOBN(0x4481d067, 0xafd32acf), TOBN(0xd8f0fcca, 0xe1f71ccf), + TOBN(0xd208dd0c, 0xb596f2da), TOBN(0xd049d730, 0x9aad93f9)}, + {TOBN(0xc79f263d, 0x42ab580e), TOBN(0x09411bb1, 0x23f707b4), + TOBN(0x8cfde1ff, 0x835e0eda), TOBN(0x72707490, 0x90f03402)}}, + {{TOBN(0xeaee6126, 0xc49a861e), TOBN(0x024f3b65, 0xe14f0d06), + TOBN(0x51a3f1e8, 0xc69bfc17), TOBN(0xc3c3a8e9, 0xa7686381)}, + {TOBN(0x3400752c, 0xb103d4c8), TOBN(0x02bc4613, 0x9218b36b), + TOBN(0xc67f75eb, 0x7651504a), TOBN(0xd6848b56, 0xd02aebfa)}}, + {{TOBN(0xbd9802e6, 0xc30fa92b), TOBN(0x5a70d96d, 0x9a552784), + TOBN(0x9085c4ea, 0x3f83169b), TOBN(0xfa9423bb, 0x06908228)}, + {TOBN(0x2ffebe12, 0xfe97a5b9), TOBN(0x85da6049, 0x71b99118), + TOBN(0x9cbc2f7f, 0x63178846), TOBN(0xfd96bc70, 0x9153218e)}}, + {{TOBN(0x958381db, 0x1782269b), TOBN(0xae34bf79, 0x2597e550), + TOBN(0xbb5c6064, 0x5f385153), TOBN(0x6f0e96af, 0xe3088048)}, + {TOBN(0xbf6a0215, 0x77884456), TOBN(0xb3b5688c, 0x69310ea7), + TOBN(0x17c94295, 0x04fad2de), TOBN(0xe020f0e5, 0x17896d4d)}}, + {{TOBN(0x730ba0ab, 0x0976505f), TOBN(0x567f6813, 0x095e2ec5), + TOBN(0x47062010, 0x6331ab71), TOBN(0x72cfa977, 0x41d22b9f)}, + {TOBN(0x33e55ead, 0x8a2373da), TOBN(0xa8d0d5f4, 0x7ba45a68), + TOBN(0xba1d8f9c, 0x03029d15), TOBN(0x8f34f1cc, 0xfc55b9f3)}}, + {{TOBN(0xcca4428d, 0xbbe5a1a9), TOBN(0x8187fd5f, 0x3126bd67), + TOBN(0x0036973a, 0x48105826), TOBN(0xa39b6663, 0xb8bd61a0)}, + {TOBN(0x6d42deef, 0x2d65a808), TOBN(0x4969044f, 0x94636b19), + TOBN(0xf611ee47, 0xdd5d564c), TOBN(0x7b2f3a49, 0xd2873077)}}, + {{TOBN(0x94157d45, 0x300eb294), TOBN(0x2b2a656e, 0x169c1494), + TOBN(0xc000dd76, 0xd3a47aa9), TOBN(0xa2864e4f, 0xa6243ea4)}, + {TOBN(0x82716c47, 0xdb89842e), TOBN(0x12dfd7d7, 0x61479fb7), + TOBN(0x3b9a2c56, 0xe0b2f6dc), TOBN(0x46be862a, 0xd7f85d67)}}, + {{TOBN(0x03b0d8dd, 0x0f82b214), TOBN(0x460c34f9, 0xf103cbc6), + TOBN(0xf32e5c03, 0x18d79e19), TOBN(0x8b8888ba, 0xa84117f8)}, + {TOBN(0x8f3c37dc, 0xc0722677), TOBN(0x10d21be9, 0x1c1c0f27), + TOBN(0xd47c8468, 0xe0f7a0c6), TOBN(0x9bf02213, 0xadecc0e0)}}, + {{TOBN(0x0baa7d12, 0x42b48b99), TOBN(0x1bcb665d, 0x48424096), + TOBN(0x8b847cd6, 0xebfb5cfb), TOBN(0x87c2ae56, 0x9ad4d10d)}, + {TOBN(0xf1cbb122, 0x0de36726), TOBN(0xe7043c68, 0x3fdfbd21), + TOBN(0x4bd0826a, 0x4e79d460), TOBN(0x11f5e598, 0x4bd1a2cb)}}, + {{TOBN(0x97554160, 0xb7fe7b6e), TOBN(0x7d16189a, 0x400a3fb2), + TOBN(0xd73e9bea, 0xe328ca1e), TOBN(0x0dd04b97, 0xe793d8cc)}, + {TOBN(0xa9c83c9b, 0x506db8cc), TOBN(0x5cd47aae, 0xcf38814c), + TOBN(0x26fc430d, 0xb64b45e6), TOBN(0x079b5499, 0xd818ea84)}}, + {{TOBN(0xebb01102, 0xc1c24a3b), TOBN(0xca24e568, 0x1c161c1a), + TOBN(0x103eea69, 0x36f00a4a), TOBN(0x9ad76ee8, 0x76176c7b)}, + {TOBN(0x97451fc2, 0x538e0ff7), TOBN(0x94f89809, 0x6604b3b0), + TOBN(0x6311436e, 0x3249cfd7), TOBN(0x27b4a7bd, 0x41224f69)}}, + {{TOBN(0x03b5d21a, 0xe0ac2941), TOBN(0x279b0254, 0xc2d31937), + TOBN(0x3307c052, 0xcac992d0), TOBN(0x6aa7cb92, 0xefa8b1f3)}, + {TOBN(0x5a182580, 0x0d37c7a5), TOBN(0x13380c37, 0x342d5422), + TOBN(0x92ac2d66, 0xd5d2ef92), TOBN(0x035a70c9, 0x030c63c6)}}, + {{TOBN(0xc16025dd, 0x4ce4f152), TOBN(0x1f419a71, 0xf9df7c06), + TOBN(0x6d5b2214, 0x91e4bb14), TOBN(0xfc43c6cc, 0x839fb4ce)}, + {TOBN(0x49f06591, 0x925d6b2d), TOBN(0x4b37d9d3, 0x62186598), + TOBN(0x8c54a971, 0xd01b1629), TOBN(0xe1a9c29f, 0x51d50e05)}}, + {{TOBN(0x5109b785, 0x71ba1861), TOBN(0x48b22d5c, 0xd0c8f93d), + TOBN(0xe8fa84a7, 0x8633bb93), TOBN(0x53fba6ba, 0x5aebbd08)}, + {TOBN(0x7ff27df3, 0xe5eea7d8), TOBN(0x521c8796, 0x68ca7158), + TOBN(0xb9d5133b, 0xce6f1a05), TOBN(0x2d50cd53, 0xfd0ebee4)}}, + {{TOBN(0xc82115d6, 0xc5a3ef16), TOBN(0x993eff9d, 0xba079221), + TOBN(0xe4da2c5e, 0x4b5da81c), TOBN(0x9a89dbdb, 0x8033fd85)}, + {TOBN(0x60819ebf, 0x2b892891), TOBN(0x53902b21, 0x5d14a4d5), + TOBN(0x6ac35051, 0xd7fda421), TOBN(0xcc6ab885, 0x61c83284)}}, + {{TOBN(0x14eba133, 0xf74cff17), TOBN(0x240aaa03, 0xecb813f2), + TOBN(0xcfbb6540, 0x6f665bee), TOBN(0x084b1fe4, 0xa425ad73)}, + {TOBN(0x009d5d16, 0xd081f6a6), TOBN(0x35304fe8, 0xeef82c90), + TOBN(0xf20346d5, 0xaa9eaa22), TOBN(0x0ada9f07, 0xac1c91e3)}}, + {{TOBN(0xa6e21678, 0x968a6144), TOBN(0x54c1f77c, 0x07b31a1e), + TOBN(0xd6bb787e, 0x5781fbe1), TOBN(0x61bd2ee0, 0xe31f1c4a)}, + {TOBN(0xf25aa1e9, 0x781105fc), TOBN(0x9cf2971f, 0x7b2f8e80), + TOBN(0x26d15412, 0xcdff919b), TOBN(0x01db4ebe, 0x34bc896e)}}, + {{TOBN(0x7d9b3e23, 0xb40df1cf), TOBN(0x59337373, 0x94e971b4), + TOBN(0xbf57bd14, 0x669cf921), TOBN(0x865daedf, 0x0c1a1064)}, + {TOBN(0x3eb70bd3, 0x83279125), TOBN(0xbc3d5b9f, 0x34ecdaab), + TOBN(0x91e3ed7e, 0x5f755caf), TOBN(0x49699f54, 0xd41e6f02)}}, + {{TOBN(0x185770e1, 0xd4a7a15b), TOBN(0x08f3587a, 0xeaac87e7), + TOBN(0x352018db, 0x473133ea), TOBN(0x674ce719, 0x04fd30fc)}, + {TOBN(0x7b8d9835, 0x088b3e0e), TOBN(0x7a0356a9, 0x5d0d47a1), + TOBN(0x9d9e7659, 0x6474a3c4), TOBN(0x61ea48a7, 0xff66966c)}}, + {{TOBN(0x30417758, 0x0f3e4834), TOBN(0xfdbb21c2, 0x17a9afcb), + TOBN(0x756fa17f, 0x2f9a67b3), TOBN(0x2a6b2421, 0xa245c1a8)}, + {TOBN(0x64be2794, 0x4af02291), TOBN(0xade465c6, 0x2a5804fe), + TOBN(0x8dffbd39, 0xa6f08fd7), TOBN(0xc4efa84c, 0xaa14403b)}}, + {{TOBN(0xa1b91b2a, 0x442b0f5c), TOBN(0xb748e317, 0xcf997736), + TOBN(0x8d1b62bf, 0xcee90e16), TOBN(0x907ae271, 0x0b2078c0)}, + {TOBN(0xdf31534b, 0x0c9bcddd), TOBN(0x043fb054, 0x39adce83), + TOBN(0x99031043, 0xd826846a), TOBN(0x61a9c0d6, 0xb144f393)}}, + {{TOBN(0xdab48046, 0x47718427), TOBN(0xdf17ff9b, 0x6e830f8b), + TOBN(0x408d7ee8, 0xe49a1347), TOBN(0x6ac71e23, 0x91c1d4ae)}, + {TOBN(0xc8cbb9fd, 0x1defd73c), TOBN(0x19840657, 0xbbbbfec5), + TOBN(0x39db1cb5, 0x9e7ef8ea), TOBN(0x78aa8296, 0x64105f30)}}, + {{TOBN(0xa3d9b7f0, 0xa3738c29), TOBN(0x0a2f235a, 0xbc3250a3), + TOBN(0x55e506f6, 0x445e4caf), TOBN(0x0974f73d, 0x33475f7a)}, + {TOBN(0xd37dbba3, 0x5ba2f5a8), TOBN(0x542c6e63, 0x6af40066), + TOBN(0x26d99b53, 0xc5d73e2c), TOBN(0x06060d7d, 0x6c3ca33e)}}, + {{TOBN(0xcdbef1c2, 0x065fef4a), TOBN(0x77e60f7d, 0xfd5b92e3), + TOBN(0xd7c549f0, 0x26708350), TOBN(0x201b3ad0, 0x34f121bf)}, + {TOBN(0x5fcac2a1, 0x0334fc14), TOBN(0x8a9a9e09, 0x344552f6), + TOBN(0x7dd8a1d3, 0x97653082), TOBN(0x5fc0738f, 0x79d4f289)}}, + {{TOBN(0x787d244d, 0x17d2d8c3), TOBN(0xeffc6345, 0x70830684), + TOBN(0x5ddb96dd, 0xe4f73ae5), TOBN(0x8efb14b1, 0x172549a5)}, + {TOBN(0x6eb73eee, 0x2245ae7a), TOBN(0xbca4061e, 0xea11f13e), + TOBN(0xb577421d, 0x30b01f5d), TOBN(0xaa688b24, 0x782e152c)}}, + {{TOBN(0x67608e71, 0xbd3502ba), TOBN(0x4ef41f24, 0xb4de75a0), + TOBN(0xb08dde5e, 0xfd6125e5), TOBN(0xde484825, 0xa409543f)}, + {TOBN(0x1f198d98, 0x65cc2295), TOBN(0x428a3771, 0x6e0edfa2), + TOBN(0x4f9697a2, 0xadf35fc7), TOBN(0x01a43c79, 0xf7cac3c7)}}, + {{TOBN(0xb05d7059, 0x0fd3659a), TOBN(0x8927f30c, 0xbb7f2d9a), + TOBN(0x4023d1ac, 0x8cf984d3), TOBN(0x32125ed3, 0x02897a45)}, + {TOBN(0xfb572dad, 0x3d414205), TOBN(0x73000ef2, 0xe3fa82a9), + TOBN(0x4c0868e9, 0xf10a5581), TOBN(0x5b61fc67, 0x6b0b3ca5)}}, + {{TOBN(0xc1258d5b, 0x7cae440c), TOBN(0x21c08b41, 0x402b7531), + TOBN(0xf61a8955, 0xde932321), TOBN(0x3568faf8, 0x2d1408af)}, + {TOBN(0x71b15e99, 0x9ecf965b), TOBN(0xf14ed248, 0xe917276f), + TOBN(0xc6f4caa1, 0x820cf9e2), TOBN(0x681b20b2, 0x18d83c7e)}}, + {{TOBN(0x6cde738d, 0xc6c01120), TOBN(0x71db0813, 0xae70e0db), + TOBN(0x95fc0644, 0x74afe18c), TOBN(0x34619053, 0x129e2be7)}, + {TOBN(0x80615cea, 0xdb2a3b15), TOBN(0x0a49a19e, 0xdb4c7073), + TOBN(0x0e1b84c8, 0x8fd2d367), TOBN(0xd74bf462, 0x033fb8aa)}}, + {{TOBN(0x889f6d65, 0x533ef217), TOBN(0x7158c7e4, 0xc3ca2e87), + TOBN(0xfb670dfb, 0xdc2b4167), TOBN(0x75910a01, 0x844c257f)}, + {TOBN(0xf336bf07, 0xcf88577d), TOBN(0x22245250, 0xe45e2ace), + TOBN(0x2ed92e8d, 0x7ca23d85), TOBN(0x29f8be4c, 0x2b812f58)}}, + {{TOBN(0xdd9ebaa7, 0x076fe12b), TOBN(0x3f2400cb, 0xae1537f9), + TOBN(0x1aa93528, 0x17bdfb46), TOBN(0xc0f98430, 0x67883b41)}, + {TOBN(0x5590ede1, 0x0170911d), TOBN(0x7562f5bb, 0x34d4b17f), + TOBN(0xe1fa1df2, 0x1826b8d2), TOBN(0xb40b796a, 0x6bd80d59)}}, + {{TOBN(0xd65bf197, 0x3467ba92), TOBN(0x8c9b46db, 0xf70954b0), + TOBN(0x97c8a0f3, 0x0e78f15d), TOBN(0xa8f3a69a, 0x85a4c961)}, + {TOBN(0x4242660f, 0x61e4ce9b), TOBN(0xbf06aab3, 0x6ea6790c), + TOBN(0xc6706f8e, 0xec986416), TOBN(0x9e56dec1, 0x9a9fc225)}}, + {{TOBN(0x527c46f4, 0x9a9898d9), TOBN(0xd799e77b, 0x5633cdef), + TOBN(0x24eacc16, 0x7d9e4297), TOBN(0xabb61cea, 0x6b1cb734)}, + {TOBN(0xbee2e8a7, 0xf778443c), TOBN(0x3bb42bf1, 0x29de2fe6), + TOBN(0xcbed86a1, 0x3003bb6f), TOBN(0xd3918e6c, 0xd781cdf6)}}, + {{TOBN(0x4bee3271, 0x9a5103f1), TOBN(0x5243efc6, 0xf50eac06), + TOBN(0xb8e122cb, 0x6adcc119), TOBN(0x1b7faa84, 0xc0b80a08)}, + {TOBN(0x32c3d1bd, 0x6dfcd08c), TOBN(0x129dec4e, 0x0be427de), + TOBN(0x98ab679c, 0x1d263c83), TOBN(0xafc83cb7, 0xcef64eff)}}, + {{TOBN(0x85eb6088, 0x2fa6be76), TOBN(0x892585fb, 0x1328cbfe), + TOBN(0xc154d3ed, 0xcf618dda), TOBN(0xc44f601b, 0x3abaf26e)}, + {TOBN(0x7bf57d0b, 0x2be1fdfd), TOBN(0xa833bd2d, 0x21137fee), + TOBN(0x9353af36, 0x2db591a8), TOBN(0xc76f26dc, 0x5562a056)}}, + {{TOBN(0x1d87e47d, 0x3fdf5a51), TOBN(0x7afb5f93, 0x55c9cab0), + TOBN(0x91bbf58f, 0x89e0586e), TOBN(0x7c72c018, 0x0d843709)}, + {TOBN(0xa9a5aafb, 0x99b5c3dc), TOBN(0xa48a0f1d, 0x3844aeb0), + TOBN(0x7178b7dd, 0xb667e482), TOBN(0x453985e9, 0x6e23a59a)}}, + {{TOBN(0x4a54c860, 0x01b25dd8), TOBN(0x0dd37f48, 0xfb897c8a), + TOBN(0x5f8aa610, 0x0ea90cd9), TOBN(0xc8892c68, 0x16d5830d)}, + {TOBN(0xeb4befc0, 0xef514ca5), TOBN(0x478eb679, 0xe72c9ee6), + TOBN(0x9bca20da, 0xdbc40d5f), TOBN(0xf015de21, 0xdde4f64a)}}, + {{TOBN(0xaa6a4de0, 0xeaf4b8a5), TOBN(0x68cfd9ca, 0x4bc60e32), + TOBN(0x668a4b01, 0x7fd15e70), TOBN(0xd9f0694a, 0xf27dc09d)}, + {TOBN(0xf6c3cad5, 0xba708bcd), TOBN(0x5cd2ba69, 0x5bb95c2a), + TOBN(0xaa28c1d3, 0x33c0a58f), TOBN(0x23e274e3, 0xabc77870)}}, + {{TOBN(0x44c3692d, 0xdfd20a4a), TOBN(0x091c5fd3, 0x81a66653), + TOBN(0x6c0bb691, 0x09a0757d), TOBN(0x9072e8b9, 0x667343ea)}, + {TOBN(0x31d40eb0, 0x80848bec), TOBN(0x95bd480a, 0x79fd36cc), + TOBN(0x01a77c61, 0x65ed43f5), TOBN(0xafccd127, 0x2e0d40bf)}}, + {{TOBN(0xeccfc82d, 0x1cc1884b), TOBN(0xc85ac201, 0x5d4753b4), + TOBN(0xc7a6caac, 0x658e099f), TOBN(0xcf46369e, 0x04b27390)}, + {TOBN(0xe2e7d049, 0x506467ea), TOBN(0x481b63a2, 0x37cdeccc), + TOBN(0x4029abd8, 0xed80143a), TOBN(0x28bfe3c7, 0xbcb00b88)}}, + {{TOBN(0x3bec1009, 0x0643d84a), TOBN(0x885f3668, 0xabd11041), + TOBN(0xdb02432c, 0xf83a34d6), TOBN(0x32f7b360, 0x719ceebe)}, + {TOBN(0xf06c7837, 0xdad1fe7a), TOBN(0x60a157a9, 0x5441a0b0), + TOBN(0x704970e9, 0xe2d47550), TOBN(0xcd2bd553, 0x271b9020)}}, + {{TOBN(0xff57f82f, 0x33e24a0b), TOBN(0x9cbee23f, 0xf2565079), + TOBN(0x16353427, 0xeb5f5825), TOBN(0x276feec4, 0xe948d662)}, + {TOBN(0xd1b62bc6, 0xda10032b), TOBN(0x718351dd, 0xf0e72a53), + TOBN(0x93452076, 0x2420e7ba), TOBN(0x96368fff, 0x3a00118d)}}, + {{TOBN(0x00ce2d26, 0x150a49e4), TOBN(0x0c28b636, 0x3f04706b), + TOBN(0xbad65a46, 0x58b196d0), TOBN(0x6c8455fc, 0xec9f8b7c)}, + {TOBN(0xe90c895f, 0x2d71867e), TOBN(0x5c0be31b, 0xedf9f38c), + TOBN(0x2a37a15e, 0xd8f6ec04), TOBN(0x239639e7, 0x8cd85251)}}, + {{TOBN(0xd8975315, 0x9c7c4c6b), TOBN(0x603aa3c0, 0xd7409af7), + TOBN(0xb8d53d0c, 0x007132fb), TOBN(0x68d12af7, 0xa6849238)}, + {TOBN(0xbe0607e7, 0xbf5d9279), TOBN(0x9aa50055, 0xaada74ce), + TOBN(0xe81079cb, 0xba7e8ccb), TOBN(0x610c71d1, 0xa5f4ff5e)}}, + {{TOBN(0x9e2ee1a7, 0x5aa07093), TOBN(0xca84004b, 0xa75da47c), + TOBN(0x074d3951, 0x3de75401), TOBN(0xf938f756, 0xbb311592)}, + {TOBN(0x96197618, 0x00a43421), TOBN(0x39a25362, 0x07bc78c8), + TOBN(0x278f710a, 0x0a171276), TOBN(0xb28446ea, 0x8d1a8f08)}}, + {{TOBN(0x184781bf, 0xe3b6a661), TOBN(0x7751cb1d, 0xe6d279f7), + TOBN(0xf8ff95d6, 0xc59eb662), TOBN(0x186d90b7, 0x58d3dea7)}, + {TOBN(0x0e4bb6c1, 0xdfb4f754), TOBN(0x5c5cf56b, 0x2b2801dc), + TOBN(0xc561e452, 0x1f54564d), TOBN(0xb4fb8c60, 0xf0dd7f13)}}, + {{TOBN(0xf8849630, 0x33ff98c7), TOBN(0x9619fffa, 0xcf17769c), + TOBN(0xf8090bf6, 0x1bfdd80a), TOBN(0x14d9a149, 0x422cfe63)}, + {TOBN(0xb354c360, 0x6f6df9ea), TOBN(0xdbcf770d, 0x218f17ea), + TOBN(0x207db7c8, 0x79eb3480), TOBN(0x213dbda8, 0x559b6a26)}}, + {{TOBN(0xac4c200b, 0x29fc81b3), TOBN(0xebc3e09f, 0x171d87c1), + TOBN(0x91799530, 0x1481aa9e), TOBN(0x051b92e1, 0x92e114fa)}, + {TOBN(0xdf8f92e9, 0xecb5537f), TOBN(0x44b1b2cc, 0x290c7483), + TOBN(0xa711455a, 0x2adeb016), TOBN(0x964b6856, 0x81a10c2c)}}, + {{TOBN(0x4f159d99, 0xcec03623), TOBN(0x05532225, 0xef3271ea), + TOBN(0xb231bea3, 0xc5ee4849), TOBN(0x57a54f50, 0x7094f103)}, + {TOBN(0x3e2d421d, 0x9598b352), TOBN(0xe865a49c, 0x67412ab4), + TOBN(0xd2998a25, 0x1cc3a912), TOBN(0x5d092808, 0x0c74d65d)}}, + {{TOBN(0x73f45908, 0x4088567a), TOBN(0xeb6b280e, 0x1f214a61), + TOBN(0x8c9adc34, 0xcaf0c13d), TOBN(0x39d12938, 0xf561fb80)}, + {TOBN(0xb2dc3a5e, 0xbc6edfb4), TOBN(0x7485b1b1, 0xfe4d210e), + TOBN(0x062e0400, 0xe186ae72), TOBN(0x91e32d5c, 0x6eeb3b88)}}, + {{TOBN(0x6df574d7, 0x4be59224), TOBN(0xebc88ccc, 0x716d55f3), + TOBN(0x26c2e6d0, 0xcad6ed33), TOBN(0xc6e21e7d, 0x0d3e8b10)}, + {TOBN(0x2cc5840e, 0x5bcc36bb), TOBN(0x9292445e, 0x7da74f69), + TOBN(0x8be8d321, 0x4e5193a8), TOBN(0x3ec23629, 0x8df06413)}}, + {{TOBN(0xc7e9ae85, 0xb134defa), TOBN(0x6073b1d0, 0x1bb2d475), + TOBN(0xb9ad615e, 0x2863c00d), TOBN(0x9e29493d, 0x525f4ac4)}, + {TOBN(0xc32b1dea, 0x4e9acf4f), TOBN(0x3e1f01c8, 0xa50db88d), + TOBN(0xb05d70ea, 0x04da916c), TOBN(0x714b0d0a, 0xd865803e)}}, + {{TOBN(0x4bd493fc, 0x9920cb5e), TOBN(0x5b44b1f7, 0x92c7a3ac), + TOBN(0xa2a77293, 0xbcec9235), TOBN(0x5ee06e87, 0xcd378553)}, + {TOBN(0xceff8173, 0xda621607), TOBN(0x2bb03e4c, 0x99f5d290), + TOBN(0x2945106a, 0xa6f734ac), TOBN(0xb5056604, 0xd25c4732)}}, + {{TOBN(0x5945920c, 0xe079afee), TOBN(0x686e17a0, 0x6789831f), + TOBN(0x5966bee8, 0xb74a5ae5), TOBN(0x38a673a2, 0x1e258d46)}, + {TOBN(0xbd1cc1f2, 0x83141c95), TOBN(0x3b2ecf4f, 0x0e96e486), + TOBN(0xcd3aa896, 0x74e5fc78), TOBN(0x415ec10c, 0x2482fa7a)}}, + {{TOBN(0x15234419, 0x80503380), TOBN(0x513d917a, 0xd314b392), + TOBN(0xb0b52f4e, 0x63caecae), TOBN(0x07bf22ad, 0x2dc7780b)}, + {TOBN(0xe761e8a1, 0xe4306839), TOBN(0x1b3be962, 0x5dd7feaa), + TOBN(0x4fe728de, 0x74c778f1), TOBN(0xf1fa0bda, 0x5e0070f6)}}, + {{TOBN(0x85205a31, 0x6ec3f510), TOBN(0x2c7e4a14, 0xd2980475), + TOBN(0xde3c19c0, 0x6f30ebfd), TOBN(0xdb1c1f38, 0xd4b7e644)}, + {TOBN(0xfe291a75, 0x5dce364a), TOBN(0xb7b22a3c, 0x058f5be3), + TOBN(0x2cd2c302, 0x37fea38c), TOBN(0x2930967a, 0x2e17be17)}}, + {{TOBN(0x87f009de, 0x0c061c65), TOBN(0xcb014aac, 0xedc6ed44), + TOBN(0x49bd1cb4, 0x3bafb1eb), TOBN(0x81bd8b5c, 0x282d3688)}, + {TOBN(0x1cdab87e, 0xf01a17af), TOBN(0x21f37ac4, 0xe710063b), + TOBN(0x5a6c5676, 0x42fc8193), TOBN(0xf4753e70, 0x56a6015c)}}, + {{TOBN(0x020f795e, 0xa15b0a44), TOBN(0x8f37c8d7, 0x8958a958), + TOBN(0x63b7e89b, 0xa4b675b5), TOBN(0xb4fb0c0c, 0x0fc31aea)}, + {TOBN(0xed95e639, 0xa7ff1f2e), TOBN(0x9880f5a3, 0x619614fb), + TOBN(0xdeb6ff02, 0x947151ab), TOBN(0x5bc5118c, 0xa868dcdb)}}, + {{TOBN(0xd8da2055, 0x4c20cea5), TOBN(0xcac2776e, 0x14c4d69a), + TOBN(0xcccb22c1, 0x622d599b), TOBN(0xa4ddb653, 0x68a9bb50)}, + {TOBN(0x2c4ff151, 0x1b4941b4), TOBN(0xe1ff19b4, 0x6efba588), + TOBN(0x35034363, 0xc48345e0), TOBN(0x45542e3d, 0x1e29dfc4)}}, + {{TOBN(0xf197cb91, 0x349f7aed), TOBN(0x3b2b5a00, 0x8fca8420), + TOBN(0x7c175ee8, 0x23aaf6d8), TOBN(0x54dcf421, 0x35af32b6)}, + {TOBN(0x0ba14307, 0x27d6561e), TOBN(0x879d5ee4, 0xd175b1e2), + TOBN(0xc7c43673, 0x99807db5), TOBN(0x77a54455, 0x9cd55bcd)}}, + {{TOBN(0xe6c2ff13, 0x0105c072), TOBN(0x18f7a99f, 0x8dda7da4), + TOBN(0x4c301820, 0x0e2d35c1), TOBN(0x06a53ca0, 0xd9cc6c82)}, + {TOBN(0xaa21cc1e, 0xf1aa1d9e), TOBN(0x32414334, 0x4a75b1e8), + TOBN(0x2a6d1328, 0x0ebe9fdc), TOBN(0x16bd173f, 0x98a4755a)}}, + {{TOBN(0xfbb9b245, 0x2133ffd9), TOBN(0x39a8b2f1, 0x830f1a20), + TOBN(0x484bc97d, 0xd5a1f52a), TOBN(0xd6aebf56, 0xa40eddf8)}, + {TOBN(0x32257acb, 0x76ccdac6), TOBN(0xaf4d36ec, 0x1586ff27), + TOBN(0x8eaa8863, 0xf8de7dd1), TOBN(0x0045d5cf, 0x88647c16)}}}, + {{{TOBN(0xa6f3d574, 0xc005979d), TOBN(0xc2072b42, 0x6a40e350), + TOBN(0xfca5c156, 0x8de2ecf9), TOBN(0xa8c8bf5b, 0xa515344e)}, + {TOBN(0x97aee555, 0x114df14a), TOBN(0xd4374a4d, 0xfdc5ec6b), + TOBN(0x754cc28f, 0x2ca85418), TOBN(0x71cb9e27, 0xd3c41f78)}}, + {{TOBN(0x89105079, 0x03605c39), TOBN(0xf0843d9e, 0xa142c96c), + TOBN(0xf3744934, 0x16923684), TOBN(0x732caa2f, 0xfa0a2893)}, + {TOBN(0xb2e8c270, 0x61160170), TOBN(0xc32788cc, 0x437fbaa3), + TOBN(0x39cd818e, 0xa6eda3ac), TOBN(0xe2e94239, 0x9e2b2e07)}}, + {{TOBN(0x6967d39b, 0x0260e52a), TOBN(0xd42585cc, 0x90653325), + TOBN(0x0d9bd605, 0x21ca7954), TOBN(0x4fa20877, 0x81ed57b3)}, + {TOBN(0x60c1eff8, 0xe34a0bbe), TOBN(0x56b0040c, 0x84f6ef64), + TOBN(0x28be2b24, 0xb1af8483), TOBN(0xb2278163, 0xf5531614)}}, + {{TOBN(0x8df27545, 0x5922ac1c), TOBN(0xa7b3ef5c, 0xa52b3f63), + TOBN(0x8e77b214, 0x71de57c4), TOBN(0x31682c10, 0x834c008b)}, + {TOBN(0xc76824f0, 0x4bd55d31), TOBN(0xb6d1c086, 0x17b61c71), + TOBN(0x31db0903, 0xc2a5089d), TOBN(0x9c092172, 0x184e5d3f)}}, + {{TOBN(0xdd7ced5b, 0xc00cc638), TOBN(0x1a2015eb, 0x61278fc2), + TOBN(0x2e8e5288, 0x6a37f8d6), TOBN(0xc457786f, 0xe79933ad)}, + {TOBN(0xb3fe4cce, 0x2c51211a), TOBN(0xad9b10b2, 0x24c20498), + TOBN(0x90d87a4f, 0xd28db5e5), TOBN(0x698cd105, 0x3aca2fc3)}}, + {{TOBN(0x4f112d07, 0xe91b536d), TOBN(0xceb982f2, 0x9eba09d6), + TOBN(0x3c157b2c, 0x197c396f), TOBN(0xe23c2d41, 0x7b66eb24)}, + {TOBN(0x480c57d9, 0x3f330d37), TOBN(0xb3a4c8a1, 0x79108deb), + TOBN(0x702388de, 0xcb199ce5), TOBN(0x0b019211, 0xb944a8d4)}}, + {{TOBN(0x24f2a692, 0x840bb336), TOBN(0x7c353bdc, 0xa669fa7b), + TOBN(0xda20d6fc, 0xdec9c300), TOBN(0x625fbe2f, 0xa13a4f17)}, + {TOBN(0xa2b1b61a, 0xdbc17328), TOBN(0x008965bf, 0xa9515621), + TOBN(0x49690939, 0xc620ff46), TOBN(0x182dd27d, 0x8717e91c)}}, + {{TOBN(0x5ace5035, 0xea6c3997), TOBN(0x54259aaa, 0xc2610bef), + TOBN(0xef18bb3f, 0x3c80dd39), TOBN(0x6910b95b, 0x5fc3fa39)}, + {TOBN(0xfce2f510, 0x43e09aee), TOBN(0xced56c9f, 0xa7675665), + TOBN(0x10e265ac, 0xd872db61), TOBN(0x6982812e, 0xae9fce69)}}, + {{TOBN(0x29be11c6, 0xce800998), TOBN(0x72bb1752, 0xb90360d9), + TOBN(0x2c193197, 0x5a4ad590), TOBN(0x2ba2f548, 0x9fc1dbc0)}, + {TOBN(0x7fe4eebb, 0xe490ebe0), TOBN(0x12a0a4cd, 0x7fae11c0), + TOBN(0x7197cf81, 0xe903ba37), TOBN(0xcf7d4aa8, 0xde1c6dd8)}}, + {{TOBN(0x92af6bf4, 0x3fd5684c), TOBN(0x2b26eecf, 0x80360aa1), + TOBN(0xbd960f30, 0x00546a82), TOBN(0x407b3c43, 0xf59ad8fe)}, + {TOBN(0x86cae5fe, 0x249c82ba), TOBN(0x9e0faec7, 0x2463744c), + TOBN(0x87f551e8, 0x94916272), TOBN(0x033f9344, 0x6ceb0615)}}, + {{TOBN(0x1e5eb0d1, 0x8be82e84), TOBN(0x89967f0e, 0x7a582fef), + TOBN(0xbcf687d5, 0xa6e921fa), TOBN(0xdfee4cf3, 0xd37a09ba)}, + {TOBN(0x94f06965, 0xb493c465), TOBN(0x638b9a1c, 0x7635c030), + TOBN(0x76667864, 0x66f05e9f), TOBN(0xccaf6808, 0xc04da725)}}, + {{TOBN(0xca2eb690, 0x768fccfc), TOBN(0xf402d37d, 0xb835b362), + TOBN(0x0efac0d0, 0xe2fdfcce), TOBN(0xefc9cdef, 0xb638d990)}, + {TOBN(0x2af12b72, 0xd1669a8b), TOBN(0x33c536bc, 0x5774ccbd), + TOBN(0x30b21909, 0xfb34870e), TOBN(0xc38fa2f7, 0x7df25aca)}}, + {{TOBN(0x74c5f02b, 0xbf81f3f5), TOBN(0x0525a5ae, 0xaf7e4581), + TOBN(0x88d2aaba, 0x433c54ae), TOBN(0xed9775db, 0x806a56c5)}, + {TOBN(0xd320738a, 0xc0edb37d), TOBN(0x25fdb6ee, 0x66cc1f51), + TOBN(0xac661d17, 0x10600d76), TOBN(0x931ec1f3, 0xbdd1ed76)}}, + {{TOBN(0x65c11d62, 0x19ee43f1), TOBN(0x5cd57c3e, 0x60829d97), + TOBN(0xd26c91a3, 0x984be6e8), TOBN(0xf08d9309, 0x8b0c53bd)}, + {TOBN(0x94bc9e5b, 0xc016e4ea), TOBN(0xd3916839, 0x11d43d2b), + TOBN(0x886c5ad7, 0x73701155), TOBN(0xe0377626, 0x20b00715)}}, + {{TOBN(0x7f01c9ec, 0xaa80ba59), TOBN(0x3083411a, 0x68538e51), + TOBN(0x970370f1, 0xe88128af), TOBN(0x625cc3db, 0x91dec14b)}, + {TOBN(0xfef9666c, 0x01ac3107), TOBN(0xb2a8d577, 0xd5057ac3), + TOBN(0xb0f26299, 0x92be5df7), TOBN(0xf579c8e5, 0x00353924)}}, + {{TOBN(0xb8fa3d93, 0x1341ed7a), TOBN(0x4223272c, 0xa7b59d49), + TOBN(0x3dcb1947, 0x83b8c4a4), TOBN(0x4e413c01, 0xed1302e4)}, + {TOBN(0x6d999127, 0xe17e44ce), TOBN(0xee86bf75, 0x33b3adfb), + TOBN(0xf6902fe6, 0x25aa96ca), TOBN(0xb73540e4, 0xe5aae47d)}}, + {{TOBN(0x32801d7b, 0x1b4a158c), TOBN(0xe571c99e, 0x27e2a369), + TOBN(0x40cb76c0, 0x10d9f197), TOBN(0xc308c289, 0x3167c0ae)}, + {TOBN(0xa6ef9dd3, 0xeb7958f2), TOBN(0xa7226dfc, 0x300879b1), + TOBN(0x6cd0b362, 0x7edf0636), TOBN(0x4efbce6c, 0x7bc37eed)}}, + {{TOBN(0x75f92a05, 0x8d699021), TOBN(0x586d4c79, 0x772566e3), + TOBN(0x378ca5f1, 0x761ad23a), TOBN(0x650d86fc, 0x1465a8ac)}, + {TOBN(0x7a4ed457, 0x842ba251), TOBN(0x6b65e3e6, 0x42234933), + TOBN(0xaf1543b7, 0x31aad657), TOBN(0xa4cefe98, 0xcbfec369)}}, + {{TOBN(0xb587da90, 0x9f47befb), TOBN(0x6562e9fb, 0x41312d13), + TOBN(0xa691ea59, 0xeff1cefe), TOBN(0xcc30477a, 0x05fc4cf6)}, + {TOBN(0xa1632461, 0x0b0ffd3d), TOBN(0xa1f16f3b, 0x5b355956), + TOBN(0x5b148d53, 0x4224ec24), TOBN(0xdc834e7b, 0xf977012a)}}, + {{TOBN(0x7bfc5e75, 0xb2c69dbc), TOBN(0x3aa77a29, 0x03c3da6c), + TOBN(0xde0df03c, 0xca910271), TOBN(0xcbd5ca4a, 0x7806dc55)}, + {TOBN(0xe1ca5807, 0x6db476cb), TOBN(0xfde15d62, 0x5f37a31e), + TOBN(0xf49af520, 0xf41af416), TOBN(0x96c5c5b1, 0x7d342db5)}}, + {{TOBN(0x155c43b7, 0xeb4ceb9b), TOBN(0x2e993010, 0x4e77371a), + TOBN(0x1d2987da, 0x675d43af), TOBN(0xef2bc1c0, 0x8599fd72)}, + {TOBN(0x96894b7b, 0x9342f6b2), TOBN(0x201eadf2, 0x7c8e71f0), + TOBN(0xf3479d9f, 0x4a1f3efc), TOBN(0xe0f8a742, 0x702a9704)}}, + {{TOBN(0xeafd44b6, 0xb3eba40c), TOBN(0xf9739f29, 0xc1c1e0d0), + TOBN(0x0091471a, 0x619d505e), TOBN(0xc15f9c96, 0x9d7c263e)}, + {TOBN(0x5be47285, 0x83afbe33), TOBN(0xa3b6d6af, 0x04f1e092), + TOBN(0xe76526b9, 0x751a9d11), TOBN(0x2ec5b26d, 0x9a4ae4d2)}}, + {{TOBN(0xeb66f4d9, 0x02f6fb8d), TOBN(0x4063c561, 0x96912164), + TOBN(0xeb7050c1, 0x80ef3000), TOBN(0x288d1c33, 0xeaa5b3f0)}, + {TOBN(0xe87c68d6, 0x07806fd8), TOBN(0xb2f7f9d5, 0x4bbbf50f), + TOBN(0x25972f3a, 0xac8d6627), TOBN(0xf8547774, 0x10e8c13b)}}, + {{TOBN(0xcc50ef6c, 0x872b4a60), TOBN(0xab2a34a4, 0x4613521b), + TOBN(0x39c5c190, 0x983e15d1), TOBN(0x61dde5df, 0x59905512)}, + {TOBN(0xe417f621, 0x9f2275f3), TOBN(0x0750c8b6, 0x451d894b), + TOBN(0x75b04ab9, 0x78b0bdaa), TOBN(0x3bfd9fd4, 0x458589bd)}}, + {{TOBN(0xf1013e30, 0xee9120b6), TOBN(0x2b51af93, 0x23a4743e), + TOBN(0xea96ffae, 0x48d14d9e), TOBN(0x71dc0dbe, 0x698a1d32)}, + {TOBN(0x914962d2, 0x0180cca4), TOBN(0x1ae60677, 0xc3568963), + TOBN(0x8cf227b1, 0x437bc444), TOBN(0xc650c83b, 0xc9962c7a)}}, + {{TOBN(0x23c2c7dd, 0xfe7ccfc4), TOBN(0xf925c89d, 0x1b929d48), + TOBN(0x4460f74b, 0x06783c33), TOBN(0xac2c8d49, 0xa590475a)}, + {TOBN(0xfb40b407, 0xb807bba0), TOBN(0x9d1e362d, 0x69ff8f3a), + TOBN(0xa33e9681, 0xcbef64a4), TOBN(0x67ece5fa, 0x332fb4b2)}}, + {{TOBN(0x6900a99b, 0x739f10e3), TOBN(0xc3341ca9, 0xff525925), + TOBN(0xee18a626, 0xa9e2d041), TOBN(0xa5a83685, 0x29580ddd)}, + {TOBN(0xf3470c81, 0x9d7de3cd), TOBN(0xedf02586, 0x2062cf9c), + TOBN(0xf43522fa, 0xc010edb0), TOBN(0x30314135, 0x13a4b1ae)}}, + {{TOBN(0xc792e02a, 0xdb22b94b), TOBN(0x993d8ae9, 0xa1eaa45b), + TOBN(0x8aad6cd3, 0xcd1e1c63), TOBN(0x89529ca7, 0xc5ce688a)}, + {TOBN(0x2ccee3aa, 0xe572a253), TOBN(0xe02b6438, 0x02a21efb), + TOBN(0xa7091b6e, 0xc9430358), TOBN(0x06d1b1fa, 0x9d7db504)}}, + {{TOBN(0x58846d32, 0xc4744733), TOBN(0x40517c71, 0x379f9e34), + TOBN(0x2f65655f, 0x130ef6ca), TOBN(0x526e4488, 0xf1f3503f)}, + {TOBN(0x8467bd17, 0x7ee4a976), TOBN(0x1d9dc913, 0x921363d1), + TOBN(0xd8d24c33, 0xb069e041), TOBN(0x5eb5da0a, 0x2cdf7f51)}}, + {{TOBN(0x1c0f3cb1, 0x197b994f), TOBN(0x3c95a6c5, 0x2843eae9), + TOBN(0x7766ffc9, 0xa6097ea5), TOBN(0x7bea4093, 0xd723b867)}, + {TOBN(0xb48e1f73, 0x4db378f9), TOBN(0x70025b00, 0xe37b77ac), + TOBN(0x943dc8e7, 0xaf24ad46), TOBN(0xb98a15ac, 0x16d00a85)}}, + {{TOBN(0x3adc38ba, 0x2743b004), TOBN(0xb1c7f4f7, 0x334415ee), + TOBN(0xea43df8f, 0x1e62d05a), TOBN(0x32618905, 0x9d76a3b6)}, + {TOBN(0x2fbd0bb5, 0xa23a0f46), TOBN(0x5bc971db, 0x6a01918c), + TOBN(0x7801d94a, 0xb4743f94), TOBN(0xb94df65e, 0x676ae22b)}}, + {{TOBN(0xaafcbfab, 0xaf95894c), TOBN(0x7b9bdc07, 0x276b2241), + TOBN(0xeaf98362, 0x5bdda48b), TOBN(0x5977faf2, 0xa3fcb4df)}, + {TOBN(0xbed042ef, 0x052c4b5b), TOBN(0x9fe87f71, 0x067591f0), + TOBN(0xc89c73ca, 0x22f24ec7), TOBN(0x7d37fa9e, 0xe64a9f1b)}}, + {{TOBN(0x2710841a, 0x15562627), TOBN(0x2c01a613, 0xc243b034), + TOBN(0x1d135c56, 0x2bc68609), TOBN(0xc2ca1715, 0x8b03f1f6)}, + {TOBN(0xc9966c2d, 0x3eb81d82), TOBN(0xc02abf4a, 0x8f6df13e), + TOBN(0x77b34bd7, 0x8f72b43b), TOBN(0xaff6218f, 0x360c82b0)}}, + {{TOBN(0x0aa5726c, 0x8d55b9d2), TOBN(0xdc0adbe9, 0x99e9bffb), + TOBN(0x9097549c, 0xefb9e72a), TOBN(0x16755712, 0x9dfb3111)}, + {TOBN(0xdd8bf984, 0xf26847f9), TOBN(0xbcb8e387, 0xdfb30cb7), + TOBN(0xc1fd32a7, 0x5171ef9c), TOBN(0x977f3fc7, 0x389b363f)}}, + {{TOBN(0x116eaf2b, 0xf4babda0), TOBN(0xfeab68bd, 0xf7113c8e), + TOBN(0xd1e3f064, 0xb7def526), TOBN(0x1ac30885, 0xe0b3fa02)}, + {TOBN(0x1c5a6e7b, 0x40142d9d), TOBN(0x839b5603, 0x30921c0b), + TOBN(0x48f301fa, 0x36a116a3), TOBN(0x380e1107, 0xcfd9ee6d)}}, + {{TOBN(0x7945ead8, 0x58854be1), TOBN(0x4111c12e, 0xcbd4d49d), + TOBN(0xece3b1ec, 0x3a29c2ef), TOBN(0x6356d404, 0x8d3616f5)}, + {TOBN(0x9f0d6a8f, 0x594d320e), TOBN(0x0989316d, 0xf651ccd2), + TOBN(0x6c32117a, 0x0f8fdde4), TOBN(0x9abe5cc5, 0xa26a9bbc)}}, + {{TOBN(0xcff560fb, 0x9723f671), TOBN(0x21b2a12d, 0x7f3d593c), + TOBN(0xe4cb18da, 0x24ba0696), TOBN(0x186e2220, 0xc3543384)}, + {TOBN(0x722f64e0, 0x88312c29), TOBN(0x94282a99, 0x17dc7752), + TOBN(0x62467bbf, 0x5a85ee89), TOBN(0xf435c650, 0xf10076a0)}}, + {{TOBN(0xc9ff1539, 0x43b3a50b), TOBN(0x7132130c, 0x1a53efbc), + TOBN(0x31bfe063, 0xf7b0c5b7), TOBN(0xb0179a7d, 0x4ea994cc)}, + {TOBN(0x12d064b3, 0xc85f455b), TOBN(0x47259328, 0x8f6e0062), + TOBN(0xf64e590b, 0xb875d6d9), TOBN(0x22dd6225, 0xad92bcc7)}}, + {{TOBN(0xb658038e, 0xb9c3bd6d), TOBN(0x00cdb0d6, 0xfbba27c8), + TOBN(0x0c681337, 0x1062c45d), TOBN(0xd8515b8c, 0x2d33407d)}, + {TOBN(0xcb8f699e, 0x8cbb5ecf), TOBN(0x8c4347f8, 0xc608d7d8), + TOBN(0x2c11850a, 0xbb3e00db), TOBN(0x20a8dafd, 0xecb49d19)}}, + {{TOBN(0xbd781480, 0x45ee2f40), TOBN(0x75e354af, 0x416b60cf), + TOBN(0xde0b58a1, 0x8d49a8c4), TOBN(0xe40e94e2, 0xfa359536)}, + {TOBN(0xbd4fa59f, 0x62accd76), TOBN(0x05cf466a, 0x8c762837), + TOBN(0xb5abda99, 0x448c277b), TOBN(0x5a9e01bf, 0x48b13740)}}, + {{TOBN(0x9d457798, 0x326aad8d), TOBN(0xbdef4954, 0xc396f7e7), + TOBN(0x6fb274a2, 0xc253e292), TOBN(0x2800bf0a, 0x1cfe53e7)}, + {TOBN(0x22426d31, 0x44438fd4), TOBN(0xef233923, 0x5e259f9a), + TOBN(0x4188503c, 0x03f66264), TOBN(0x9e5e7f13, 0x7f9fdfab)}}, + {{TOBN(0x565eb76c, 0x5fcc1aba), TOBN(0xea632548, 0x59b5bff8), + TOBN(0x5587c087, 0xaab6d3fa), TOBN(0x92b639ea, 0x6ce39c1b)}, + {TOBN(0x0706e782, 0x953b135c), TOBN(0x7308912e, 0x425268ef), + TOBN(0x599e92c7, 0x090e7469), TOBN(0x83b90f52, 0x9bc35e75)}}, + {{TOBN(0x4750b3d0, 0x244975b3), TOBN(0xf3a44358, 0x11965d72), + TOBN(0x179c6774, 0x9c8dc751), TOBN(0xff18cdfe, 0xd23d9ff0)}, + {TOBN(0xc4013833, 0x2028e247), TOBN(0x96e280e2, 0xf3bfbc79), + TOBN(0xf60417bd, 0xd0880a84), TOBN(0x263c9f3d, 0x2a568151)}}, + {{TOBN(0x36be15b3, 0x2d2ce811), TOBN(0x846dc0c2, 0xf8291d21), + TOBN(0x5cfa0ecb, 0x789fcfdb), TOBN(0x45a0beed, 0xd7535b9a)}, + {TOBN(0xec8e9f07, 0x96d69af1), TOBN(0x31a7c5b8, 0x599ab6dc), + TOBN(0xd36d45ef, 0xf9e2e09f), TOBN(0x3cf49ef1, 0xdcee954b)}}, + {{TOBN(0x6be34cf3, 0x086cff9b), TOBN(0x88dbd491, 0x39a3360f), + TOBN(0x1e96b8cc, 0x0dbfbd1d), TOBN(0xc1e5f7bf, 0xcb7e2552)}, + {TOBN(0x0547b214, 0x28819d98), TOBN(0xc770dd9c, 0x7aea9dcb), + TOBN(0xaef0d4c7, 0x041d68c8), TOBN(0xcc2b9818, 0x13cb9ba8)}}, + {{TOBN(0x7fc7bc76, 0xfe86c607), TOBN(0x6b7b9337, 0x502a9a95), + TOBN(0x1948dc27, 0xd14dab63), TOBN(0x249dd198, 0xdae047be)}, + {TOBN(0xe8356584, 0xa981a202), TOBN(0x3531dd18, 0x3a893387), + TOBN(0x1be11f90, 0xc85c7209), TOBN(0x93d2fe1e, 0xe2a52b5a)}}, + {{TOBN(0x8225bfe2, 0xec6d6b97), TOBN(0x9cf6d6f4, 0xbd0aa5de), + TOBN(0x911459cb, 0x54779f5f), TOBN(0x5649cddb, 0x86aeb1f3)}, + {TOBN(0x32133579, 0x3f26ce5a), TOBN(0xc289a102, 0x550f431e), + TOBN(0x559dcfda, 0x73b84c6f), TOBN(0x84973819, 0xee3ac4d7)}}, + {{TOBN(0xb51e55e6, 0xf2606a82), TOBN(0xe25f7061, 0x90f2fb57), + TOBN(0xacef6c2a, 0xb1a4e37c), TOBN(0x864e359d, 0x5dcf2706)}, + {TOBN(0x479e6b18, 0x7ce57316), TOBN(0x2cab2500, 0x3a96b23d), + TOBN(0xed489862, 0x8ef16df7), TOBN(0x2056538c, 0xef3758b5)}}, + {{TOBN(0xa7df865e, 0xf15d3101), TOBN(0x80c5533a, 0x61b553d7), + TOBN(0x366e1997, 0x4ed14294), TOBN(0x6620741f, 0xb3c0bcd6)}, + {TOBN(0x21d1d9c4, 0xedc45418), TOBN(0x005b859e, 0xc1cc4a9d), + TOBN(0xdf01f630, 0xa1c462f0), TOBN(0x15d06cf3, 0xf26820c7)}}, + {{TOBN(0x9f7f24ee, 0x3484be47), TOBN(0x2ff33e96, 0x4a0c902f), + TOBN(0x00bdf457, 0x5a0bc453), TOBN(0x2378dfaf, 0x1aa238db)}, + {TOBN(0x272420ec, 0x856720f2), TOBN(0x2ad9d95b, 0x96797291), + TOBN(0xd1242cc6, 0x768a1558), TOBN(0x2e287f8b, 0x5cc86aa8)}}, + {{TOBN(0x796873d0, 0x990cecaa), TOBN(0xade55f81, 0x675d4080), + TOBN(0x2645eea3, 0x21f0cd84), TOBN(0x7a1efa0f, 0xb4e17d02)}, + {TOBN(0xf6858420, 0x037cc061), TOBN(0x682e05f0, 0xd5d43e12), + TOBN(0x59c36994, 0x27218710), TOBN(0x85cbba4d, 0x3f7cd2fc)}}, + {{TOBN(0x726f9729, 0x7a3cd22a), TOBN(0x9f8cd5dc, 0x4a628397), + TOBN(0x17b93ab9, 0xc23165ed), TOBN(0xff5f5dbf, 0x122823d4)}, + {TOBN(0xc1e4e4b5, 0x654a446d), TOBN(0xd1a9496f, 0x677257ba), + TOBN(0x6387ba94, 0xde766a56), TOBN(0x23608bc8, 0x521ec74a)}}, + {{TOBN(0x16a522d7, 0x6688c4d4), TOBN(0x9d6b4282, 0x07373abd), + TOBN(0xa62f07ac, 0xb42efaa3), TOBN(0xf73e00f7, 0xe3b90180)}, + {TOBN(0x36175fec, 0x49421c3e), TOBN(0xc4e44f9b, 0x3dcf2678), + TOBN(0x76df436b, 0x7220f09f), TOBN(0x172755fb, 0x3aa8b6cf)}}, + {{TOBN(0xbab89d57, 0x446139cc), TOBN(0x0a0a6e02, 0x5fe0208f), + TOBN(0xcdbb63e2, 0x11e5d399), TOBN(0x33ecaa12, 0xa8977f0b)}, + {TOBN(0x59598b21, 0xf7c42664), TOBN(0xb3e91b32, 0xab65d08a), + TOBN(0x035822ee, 0xf4502526), TOBN(0x1dcf0176, 0x720a82a9)}}, + {{TOBN(0x50f8598f, 0x3d589e02), TOBN(0xdf0478ff, 0xb1d63d2c), + TOBN(0x8b8068bd, 0x1571cd07), TOBN(0x30c3aa4f, 0xd79670cd)}, + {TOBN(0x25e8fd4b, 0x941ade7f), TOBN(0x3d1debdc, 0x32790011), + TOBN(0x65b6dcbd, 0x3a3f9ff0), TOBN(0x282736a4, 0x793de69c)}}, + {{TOBN(0xef69a0c3, 0xd41d3bd3), TOBN(0xb533b8c9, 0x07a26bde), + TOBN(0xe2801d97, 0xdb2edf9f), TOBN(0xdc4a8269, 0xe1877af0)}, + {TOBN(0x6c1c5851, 0x3d590dbe), TOBN(0x84632f6b, 0xee4e9357), + TOBN(0xd36d36b7, 0x79b33374), TOBN(0xb46833e3, 0x9bbca2e6)}}, + {{TOBN(0x37893913, 0xf7fc0586), TOBN(0x385315f7, 0x66bf4719), + TOBN(0x72c56293, 0xb31855dc), TOBN(0xd1416d4e, 0x849061fe)}, + {TOBN(0xbeb3ab78, 0x51047213), TOBN(0x447f6e61, 0xf040c996), + TOBN(0xd06d310d, 0x638b1d0c), TOBN(0xe28a413f, 0xbad1522e)}}, + {{TOBN(0x685a76cb, 0x82003f86), TOBN(0x610d07f7, 0x0bcdbca3), + TOBN(0x6ff66021, 0x9ca4c455), TOBN(0x7df39b87, 0xcea10eec)}, + {TOBN(0xb9255f96, 0xe22db218), TOBN(0x8cc6d9eb, 0x08a34c44), + TOBN(0xcd4ffb86, 0x859f9276), TOBN(0x8fa15eb2, 0x50d07335)}}, + {{TOBN(0xdf553845, 0xcf2c24b5), TOBN(0x89f66a9f, 0x52f9c3ba), + TOBN(0x8f22b5b9, 0xe4a7ceb3), TOBN(0xaffef809, 0x0e134686)}, + {TOBN(0x3e53e1c6, 0x8eb8fac2), TOBN(0x93c1e4eb, 0x28aec98e), + TOBN(0xb6b91ec5, 0x32a43bcb), TOBN(0x2dbfa947, 0xb2d74a51)}}, + {{TOBN(0xe065d190, 0xca84bad7), TOBN(0xfb13919f, 0xad58e65c), + TOBN(0x3c41718b, 0xf1cb6e31), TOBN(0x688969f0, 0x06d05c3f)}, + {TOBN(0xd4f94ce7, 0x21264d45), TOBN(0xfdfb65e9, 0x7367532b), + TOBN(0x5b1be8b1, 0x0945a39d), TOBN(0x229f789c, 0x2b8baf3b)}}, + {{TOBN(0xd8f41f3e, 0x6f49f15d), TOBN(0x678ce828, 0x907f0792), + TOBN(0xc69ace82, 0xfca6e867), TOBN(0x106451ae, 0xd01dcc89)}, + {TOBN(0x1bb4f7f0, 0x19fc32d2), TOBN(0x64633dfc, 0xb00c52d2), + TOBN(0x8f13549a, 0xad9ea445), TOBN(0x99a3bf50, 0xfb323705)}}, + {{TOBN(0x0c9625a2, 0x534d4dbc), TOBN(0x45b8f1d1, 0xc2a2fea3), + TOBN(0x76ec21a1, 0xa530fc1a), TOBN(0x4bac9c2a, 0x9e5bd734)}, + {TOBN(0x5996d76a, 0x7b4e3587), TOBN(0x0045cdee, 0x1182d9e3), + TOBN(0x1aee24b9, 0x1207f13d), TOBN(0x66452e97, 0x97345a41)}}, + {{TOBN(0x16e5b054, 0x9f950cd0), TOBN(0x9cc72fb1, 0xd7fdd075), + TOBN(0x6edd61e7, 0x66249663), TOBN(0xde4caa4d, 0xf043cccb)}, + {TOBN(0x11b1f57a, 0x55c7ac17), TOBN(0x779cbd44, 0x1a85e24d), + TOBN(0x78030f86, 0xe46081e7), TOBN(0xfd4a6032, 0x8e20f643)}}, + {{TOBN(0xcc7a6488, 0x0a750c0f), TOBN(0x39bacfe3, 0x4e548e83), + TOBN(0x3d418c76, 0x0c110f05), TOBN(0x3e4daa4c, 0xb1f11588)}, + {TOBN(0x2733e7b5, 0x5ffc69ff), TOBN(0x46f147bc, 0x92053127), + TOBN(0x885b2434, 0xd722df94), TOBN(0x6a444f65, 0xe6fc6b7c)}}}, + {{{TOBN(0x7a1a465a, 0xc3f16ea8), TOBN(0x115a461d, 0xb2f1d11c), + TOBN(0x4767dd95, 0x6c68a172), TOBN(0x3392f2eb, 0xd13a4698)}, + {TOBN(0xc7a99ccd, 0xe526cdc7), TOBN(0x8e537fdc, 0x22292b81), + TOBN(0x76d8cf69, 0xa6d39198), TOBN(0xffc5ff43, 0x2446852d)}}, + {{TOBN(0x97b14f7e, 0xa90567e6), TOBN(0x513257b7, 0xb6ae5cb7), + TOBN(0x85454a3c, 0x9f10903d), TOBN(0xd8d2c9ad, 0x69bc3724)}, + {TOBN(0x38da9324, 0x6b29cb44), TOBN(0xb540a21d, 0x77c8cbac), + TOBN(0x9bbfe435, 0x01918e42), TOBN(0xfffa707a, 0x56c3614e)}}, + {{TOBN(0x0ce4e3f1, 0xd4e353b7), TOBN(0x062d8a14, 0xef46b0a0), + TOBN(0x6408d5ab, 0x574b73fd), TOBN(0xbc41d1c9, 0xd3273ffd)}, + {TOBN(0x3538e1e7, 0x6be77800), TOBN(0x71fe8b37, 0xc5655031), + TOBN(0x1cd91621, 0x6b9b331a), TOBN(0xad825d0b, 0xbb388f73)}}, + {{TOBN(0x56c2e05b, 0x1cb76219), TOBN(0x0ec0bf91, 0x71567e7e), + TOBN(0xe7076f86, 0x61c4c910), TOBN(0xd67b085b, 0xbabc04d9)}, + {TOBN(0x9fb90459, 0x5e93a96a), TOBN(0x7526c1ea, 0xfbdc249a), + TOBN(0x0d44d367, 0xecdd0bb7), TOBN(0x95399917, 0x9dc0d695)}}, + {{TOBN(0x61360ee9, 0x9e240d18), TOBN(0x057cdcac, 0xb4b94466), + TOBN(0xe7667cd1, 0x2fe5325c), TOBN(0x1fa297b5, 0x21974e3b)}, + {TOBN(0xfa4081e7, 0xdb083d76), TOBN(0x31993be6, 0xf206bd15), + TOBN(0x8949269b, 0x14c19f8c), TOBN(0x21468d72, 0xa9d92357)}}, + {{TOBN(0x2ccbc583, 0xa4c506ec), TOBN(0x957ed188, 0xd1acfe97), + TOBN(0x8baed833, 0x12f1aea2), TOBN(0xef2a6cb4, 0x8325362d)}, + {TOBN(0x130dde42, 0x8e195c43), TOBN(0xc842025a, 0x0e6050c6), + TOBN(0x2da972a7, 0x08686a5d), TOBN(0xb52999a1, 0xe508b4a8)}}, + {{TOBN(0xd9f090b9, 0x10a5a8bd), TOBN(0xca91d249, 0x096864da), + TOBN(0x8e6a93be, 0x3f67dbc1), TOBN(0xacae6fba, 0xf5f4764c)}, + {TOBN(0x1563c6e0, 0xd21411a0), TOBN(0x28fa787f, 0xda0a4ad8), + TOBN(0xd524491c, 0x908c8030), TOBN(0x1257ba0e, 0x4c795f07)}}, + {{TOBN(0x83f49167, 0xceca9754), TOBN(0x426d2cf6, 0x4b7939a0), + TOBN(0x2555e355, 0x723fd0bf), TOBN(0xa96e6d06, 0xc4f144e2)}, + {TOBN(0x4768a8dd, 0x87880e61), TOBN(0x15543815, 0xe508e4d5), + TOBN(0x09d7e772, 0xb1b65e15), TOBN(0x63439dd6, 0xac302fa0)}}, + {{TOBN(0xb93f802f, 0xc14e35c2), TOBN(0x71735b7c, 0x4341333c), + TOBN(0x03a25104, 0x16d4f362), TOBN(0x3f4d069b, 0xbf433c8e)}, + {TOBN(0x0d83ae01, 0xf78f5a7c), TOBN(0x50a8ffbe, 0x7c4eed07), + TOBN(0xc74f8906, 0x76e10f83), TOBN(0x7d080966, 0x9ddaf8e1)}}, + {{TOBN(0xb11df8e1, 0x698e04cc), TOBN(0x877be203, 0x169005c8), + TOBN(0x32749e8c, 0x4f3c6179), TOBN(0x2dbc9d0a, 0x7853fc05)}, + {TOBN(0x187d4f93, 0x9454d937), TOBN(0xe682ce9d, 0xb4800e1b), + TOBN(0xa9129ad8, 0x165e68e8), TOBN(0x0fe29735, 0xbe7f785b)}}, + {{TOBN(0x5303f40c, 0x5b9e02b7), TOBN(0xa37c9692, 0x35ee04e8), + TOBN(0x5f46cc20, 0x34d6632b), TOBN(0x55ef72b2, 0x96ac545b)}, + {TOBN(0xabec5c1f, 0x7b91b062), TOBN(0x0a79e1c7, 0xbb33e821), + TOBN(0xbb04b428, 0x3a9f4117), TOBN(0x0de1f28f, 0xfd2a475a)}}, + {{TOBN(0x31019ccf, 0x3a4434b4), TOBN(0xa3458111, 0x1a7954dc), + TOBN(0xa9dac80d, 0xe34972a7), TOBN(0xb043d054, 0x74f6b8dd)}, + {TOBN(0x021c319e, 0x11137b1a), TOBN(0x00a754ce, 0xed5cc03f), + TOBN(0x0aa2c794, 0xcbea5ad4), TOBN(0x093e67f4, 0x70c015b6)}}, + {{TOBN(0x72cdfee9, 0xc97e3f6b), TOBN(0xc10bcab4, 0xb6da7461), + TOBN(0x3b02d2fc, 0xb59806b9), TOBN(0x85185e89, 0xa1de6f47)}, + {TOBN(0x39e6931f, 0x0eb6c4d4), TOBN(0x4d4440bd, 0xd4fa5b04), + TOBN(0x5418786e, 0x34be7eb8), TOBN(0x6380e521, 0x9d7259bc)}}, + {{TOBN(0x20ac0351, 0xd598d710), TOBN(0x272c4166, 0xcb3a4da4), + TOBN(0xdb82fe1a, 0xca71de1f), TOBN(0x746e79f2, 0xd8f54b0f)}, + {TOBN(0x6e7fc736, 0x4b573e9b), TOBN(0x75d03f46, 0xfd4b5040), + TOBN(0x5c1cc36d, 0x0b98d87b), TOBN(0x513ba3f1, 0x1f472da1)}}, + {{TOBN(0x79d0af26, 0xabb177dd), TOBN(0xf82ab568, 0x7891d564), + TOBN(0x2b6768a9, 0x72232173), TOBN(0xefbb3bb0, 0x8c1f6619)}, + {TOBN(0xb29c11db, 0xa6d18358), TOBN(0x519e2797, 0xb0916d3a), + TOBN(0xd4dc18f0, 0x9188e290), TOBN(0x648e86e3, 0x98b0ca7f)}}, + {{TOBN(0x859d3145, 0x983c38b5), TOBN(0xb14f176c, 0x637abc8b), + TOBN(0x2793fb9d, 0xcaff7be6), TOBN(0xebe5a55f, 0x35a66a5a)}, + {TOBN(0x7cec1dcd, 0x9f87dc59), TOBN(0x7c595cd3, 0xfbdbf560), + TOBN(0x5b543b22, 0x26eb3257), TOBN(0x69080646, 0xc4c935fd)}}, + {{TOBN(0x7f2e4403, 0x81e9ede3), TOBN(0x243c3894, 0xcaf6df0a), + TOBN(0x7c605bb1, 0x1c073b11), TOBN(0xcd06a541, 0xba6a4a62)}, + {TOBN(0x29168949, 0x49d4e2e5), TOBN(0x33649d07, 0x4af66880), + TOBN(0xbfc0c885, 0xe9a85035), TOBN(0xb4e52113, 0xfc410f4b)}}, + {{TOBN(0xdca3b706, 0x78a6513b), TOBN(0x92ea4a2a, 0x9edb1943), + TOBN(0x02642216, 0xdb6e2dd8), TOBN(0x9b45d0b4, 0x9fd57894)}, + {TOBN(0x114e70db, 0xc69d11ae), TOBN(0x1477dd19, 0x4c57595f), + TOBN(0xbc2208b4, 0xec77c272), TOBN(0x95c5b4d7, 0xdb68f59c)}}, + {{TOBN(0xb8c4fc63, 0x42e532b7), TOBN(0x386ba422, 0x9ae35290), + TOBN(0xfb5dda42, 0xd201ecbc), TOBN(0x2353dc8b, 0xa0e38fd6)}, + {TOBN(0x9a0b85ea, 0x68f7e978), TOBN(0x96ec5682, 0x2ad6d11f), + TOBN(0x5e279d6c, 0xe5f6886d), TOBN(0xd3fe03cd, 0x3cb1914d)}}, + {{TOBN(0xfe541fa4, 0x7ea67c77), TOBN(0x952bd2af, 0xe3ea810c), + TOBN(0x791fef56, 0x8d01d374), TOBN(0xa3a1c621, 0x0f11336e)}, + {TOBN(0x5ad0d5a9, 0xc7ec6d79), TOBN(0xff7038af, 0x3225c342), + TOBN(0x003c6689, 0xbc69601b), TOBN(0x25059bc7, 0x45e8747d)}}, + {{TOBN(0xfa4965b2, 0xf2086fbf), TOBN(0xf6840ea6, 0x86916078), + TOBN(0xd7ac7620, 0x70081d6c), TOBN(0xe600da31, 0xb5328645)}, + {TOBN(0x01916f63, 0x529b8a80), TOBN(0xe80e4858, 0x2d7d6f3e), + TOBN(0x29eb0fe8, 0xd664ca7c), TOBN(0xf017637b, 0xe7b43b0c)}}, + {{TOBN(0x9a75c806, 0x76cb2566), TOBN(0x8f76acb1, 0xb24892d9), + TOBN(0x7ae7b9cc, 0x1f08fe45), TOBN(0x19ef7329, 0x6a4907d8)}, + {TOBN(0x2db4ab71, 0x5f228bf0), TOBN(0xf3cdea39, 0x817032d7), + TOBN(0x0b1f482e, 0xdcabe3c0), TOBN(0x3baf76b4, 0xbb86325c)}}, + {{TOBN(0xd49065e0, 0x10089465), TOBN(0x3bab5d29, 0x8e77c596), + TOBN(0x7636c3a6, 0x193dbd95), TOBN(0xdef5d294, 0xb246e499)}, + {TOBN(0xb22c58b9, 0x286b2475), TOBN(0xa0b93939, 0xcd80862b), + TOBN(0x3002c83a, 0xf0992388), TOBN(0x6de01f9b, 0xeacbe14c)}}, + {{TOBN(0x6aac688e, 0xadd70482), TOBN(0x708de92a, 0x7b4a4e8a), + TOBN(0x75b6dd73, 0x758a6eef), TOBN(0xea4bf352, 0x725b3c43)}, + {TOBN(0x10041f2c, 0x87912868), TOBN(0xb1b1be95, 0xef09297a), + TOBN(0x19ae23c5, 0xa9f3860a), TOBN(0xc4f0f839, 0x515dcf4b)}}, + {{TOBN(0x3c7ecca3, 0x97f6306a), TOBN(0x744c44ae, 0x68a3a4b0), + TOBN(0x69cd13a0, 0xb3a1d8a2), TOBN(0x7cad0a1e, 0x5256b578)}, + {TOBN(0xea653fcd, 0x33791d9e), TOBN(0x9cc2a05d, 0x74b2e05f), + TOBN(0x73b391dc, 0xfd7affa2), TOBN(0xddb7091e, 0xb6b05442)}}, + {{TOBN(0xc71e27bf, 0x8538a5c6), TOBN(0x195c63dd, 0x89abff17), + TOBN(0xfd315285, 0x1b71e3da), TOBN(0x9cbdfda7, 0xfa680fa0)}, + {TOBN(0x9db876ca, 0x849d7eab), TOBN(0xebe2764b, 0x3c273271), + TOBN(0x663357e3, 0xf208dcea), TOBN(0x8c5bd833, 0x565b1b70)}}, + {{TOBN(0xccc3b4f5, 0x9837fc0d), TOBN(0x9b641ba8, 0xa79cf00f), + TOBN(0x7428243d, 0xdfdf3990), TOBN(0x83a594c4, 0x020786b1)}, + {TOBN(0xb712451a, 0x526c4502), TOBN(0x9d39438e, 0x6adb3f93), + TOBN(0xfdb261e3, 0xe9ff0ccd), TOBN(0x80344e3c, 0xe07af4c3)}}, + {{TOBN(0x75900d7c, 0x2fa4f126), TOBN(0x08a3b865, 0x5c99a232), + TOBN(0x2478b6bf, 0xdb25e0c3), TOBN(0x482cc2c2, 0x71db2edf)}, + {TOBN(0x37df7e64, 0x5f321bb8), TOBN(0x8a93821b, 0x9a8005b4), + TOBN(0x3fa2f10c, 0xcc8c1958), TOBN(0x0d332218, 0x2c269d0a)}}, + {{TOBN(0x20ab8119, 0xe246b0e6), TOBN(0xb39781e4, 0xd349fd17), + TOBN(0xd293231e, 0xb31aa100), TOBN(0x4b779c97, 0xbb032168)}, + {TOBN(0x4b3f19e1, 0xc8470500), TOBN(0x45b7efe9, 0x0c4c869d), + TOBN(0xdb84f38a, 0xa1a6bbcc), TOBN(0x3b59cb15, 0xb2fddbc1)}}, + {{TOBN(0xba5514df, 0x3fd165e8), TOBN(0x499fd6a9, 0x061f8811), + TOBN(0x72cd1fe0, 0xbfef9f00), TOBN(0x120a4bb9, 0x79ad7e8a)}, + {TOBN(0xf2ffd095, 0x5f4a5ac5), TOBN(0xcfd174f1, 0x95a7a2f0), + TOBN(0xd42301ba, 0x9d17baf1), TOBN(0xd2fa487a, 0x77f22089)}}, + {{TOBN(0x9cb09efe, 0xb1dc77e1), TOBN(0xe9566939, 0x21c99682), + TOBN(0x8c546901, 0x6c6067bb), TOBN(0xfd378574, 0x61c24456)}, + {TOBN(0x2b6a6cbe, 0x81796b33), TOBN(0x62d550f6, 0x58e87f8b), + TOBN(0x1b763e1c, 0x7f1b01b4), TOBN(0x4b93cfea, 0x1b1b5e12)}}, + {{TOBN(0xb9345238, 0x1d531696), TOBN(0x57201c00, 0x88cdde69), + TOBN(0xdde92251, 0x9a86afc7), TOBN(0xe3043895, 0xbd35cea8)}, + {TOBN(0x7608c1e1, 0x8555970d), TOBN(0x8267dfa9, 0x2535935e), + TOBN(0xd4c60a57, 0x322ea38b), TOBN(0xe0bf7977, 0x804ef8b5)}}, + {{TOBN(0x1a0dab28, 0xc06fece4), TOBN(0xd405991e, 0x94e7b49d), + TOBN(0xc542b6d2, 0x706dab28), TOBN(0xcb228da3, 0xa91618fb)}, + {TOBN(0x224e4164, 0x107d1cea), TOBN(0xeb9fdab3, 0xd0f5d8f1), + TOBN(0xc02ba386, 0x0d6e41cd), TOBN(0x676a72c5, 0x9b1f7146)}}, + {{TOBN(0xffd6dd98, 0x4d6cb00b), TOBN(0xcef9c5ca, 0xde2e8d7c), + TOBN(0xa1bbf5d7, 0x641c7936), TOBN(0x1b95b230, 0xee8f772e)}, + {TOBN(0xf765a92e, 0xe8ac25b1), TOBN(0xceb04cfc, 0x3a18b7c6), + TOBN(0x27944cef, 0x0acc8966), TOBN(0xcbb3c957, 0x434c1004)}}, + {{TOBN(0x9c9971a1, 0xa43ff93c), TOBN(0x5bc2db17, 0xa1e358a9), + TOBN(0x45b4862e, 0xa8d9bc82), TOBN(0x70ebfbfb, 0x2201e052)}, + {TOBN(0xafdf64c7, 0x92871591), TOBN(0xea5bcae6, 0xb42d0219), + TOBN(0xde536c55, 0x2ad8f03c), TOBN(0xcd6c3f4d, 0xa76aa33c)}}, + {{TOBN(0xbeb5f623, 0x0bca6de3), TOBN(0xdd20dd99, 0xb1e706fd), + TOBN(0x90b3ff9d, 0xac9059d4), TOBN(0x2d7b2902, 0x7ccccc4e)}, + {TOBN(0x8a090a59, 0xce98840f), TOBN(0xa5d947e0, 0x8410680a), + TOBN(0x49ae346a, 0x923379a5), TOBN(0x7dbc84f9, 0xb28a3156)}}, + {{TOBN(0xfd40d916, 0x54a1aff2), TOBN(0xabf318ba, 0x3a78fb9b), + TOBN(0x50152ed8, 0x3029f95e), TOBN(0x9fc1dd77, 0xc58ad7fa)}, + {TOBN(0x5fa57915, 0x13595c17), TOBN(0xb9504668, 0x8f62b3a9), + TOBN(0x907b5b24, 0xff3055b0), TOBN(0x2e995e35, 0x9a84f125)}}, + {{TOBN(0x87dacf69, 0x7e9bbcfb), TOBN(0x95d0c1d6, 0xe86d96e3), + TOBN(0x65726e3c, 0x2d95a75c), TOBN(0x2c3c9001, 0xacd27f21)}, + {TOBN(0x1deab561, 0x6c973f57), TOBN(0x108b7e2c, 0xa5221643), + TOBN(0x5fee9859, 0xc4ef79d4), TOBN(0xbd62b88a, 0x40d4b8c6)}}, + {{TOBN(0xb4dd29c4, 0x197c75d6), TOBN(0x266a6df2, 0xb7076feb), + TOBN(0x9512d0ea, 0x4bf2df11), TOBN(0x1320c24f, 0x6b0cc9ec)}, + {TOBN(0x6bb1e0e1, 0x01a59596), TOBN(0x8317c5bb, 0xeff9aaac), + TOBN(0x65bb405e, 0x385aa6c9), TOBN(0x613439c1, 0x8f07988f)}}, + {{TOBN(0xd730049f, 0x16a66e91), TOBN(0xe97f2820, 0xfa1b0e0d), + TOBN(0x4131e003, 0x304c28ea), TOBN(0x820ab732, 0x526bac62)}, + {TOBN(0xb2ac9ef9, 0x28714423), TOBN(0x54ecfffa, 0xadb10cb2), + TOBN(0x8781476e, 0xf886a4cc), TOBN(0x4b2c87b5, 0xdb2f8d49)}}, + {{TOBN(0xe857cd20, 0x0a44295d), TOBN(0x707d7d21, 0x58c6b044), + TOBN(0xae8521f9, 0xf596757c), TOBN(0x87448f03, 0x67b2b714)}, + {TOBN(0x13a9bc45, 0x5ebcd58d), TOBN(0x79bcced9, 0x9122d3c1), + TOBN(0x3c644247, 0x9e076642), TOBN(0x0cf22778, 0x2df4767d)}}, + {{TOBN(0x5e61aee4, 0x71d444b6), TOBN(0x211236bf, 0xc5084a1d), + TOBN(0x7e15bc9a, 0x4fd3eaf6), TOBN(0x68df2c34, 0xab622bf5)}, + {TOBN(0x9e674f0f, 0x59bf4f36), TOBN(0xf883669b, 0xd7f34d73), + TOBN(0xc48ac1b8, 0x31497b1d), TOBN(0x323b925d, 0x5106703b)}}, + {{TOBN(0x22156f42, 0x74082008), TOBN(0xeffc521a, 0xc8482bcb), + TOBN(0x5c6831bf, 0x12173479), TOBN(0xcaa2528f, 0xc4739490)}, + {TOBN(0x84d2102a, 0x8f1b3c4d), TOBN(0xcf64dfc1, 0x2d9bec0d), + TOBN(0x433febad, 0x78a546ef), TOBN(0x1f621ec3, 0x7b73cef1)}}, + {{TOBN(0x6aecd627, 0x37338615), TOBN(0x162082ab, 0x01d8edf6), + TOBN(0x833a8119, 0x19e86b66), TOBN(0x6023a251, 0xd299b5db)}, + {TOBN(0xf5bb0c3a, 0xbbf04b89), TOBN(0x6735eb69, 0xae749a44), + TOBN(0xd0e058c5, 0x4713de3b), TOBN(0xfdf2593e, 0x2c3d4ccd)}}, + {{TOBN(0x1b8f414e, 0xfdd23667), TOBN(0xdd52aaca, 0xfa2015ee), + TOBN(0x3e31b517, 0xbd9625ff), TOBN(0x5ec9322d, 0x8db5918c)}, + {TOBN(0xbc73ac85, 0xa96f5294), TOBN(0x82aa5bf3, 0x61a0666a), + TOBN(0x49755810, 0xbf08ac42), TOBN(0xd21cdfd5, 0x891cedfc)}}, + {{TOBN(0x918cb57b, 0x67f8be10), TOBN(0x365d1a7c, 0x56ffa726), + TOBN(0x2435c504, 0x6532de93), TOBN(0xc0fc5e10, 0x2674cd02)}, + {TOBN(0x6e51fcf8, 0x9cbbb142), TOBN(0x1d436e5a, 0xafc50692), + TOBN(0x766bffff, 0x3fbcae22), TOBN(0x3148c2fd, 0xfd55d3b8)}}, + {{TOBN(0x52c7fdc9, 0x233222fa), TOBN(0x89ff1092, 0xe419fb6b), + TOBN(0x3cd6db99, 0x25254977), TOBN(0x2e85a161, 0x1cf12ca7)}, + {TOBN(0xadd2547c, 0xdc810bc9), TOBN(0xea3f458f, 0x9d257c22), + TOBN(0x642c1fbe, 0x27d6b19b), TOBN(0xed07e6b5, 0x140481a6)}}, + {{TOBN(0x6ada1d42, 0x86d2e0f8), TOBN(0xe5920122, 0x0e8a9fd5), + TOBN(0x02c936af, 0x708c1b49), TOBN(0x60f30fee, 0x2b4bfaff)}, + {TOBN(0x6637ad06, 0x858e6a61), TOBN(0xce4c7767, 0x3fd374d0), + TOBN(0x39d54b2d, 0x7188defb), TOBN(0xa8c9d250, 0xf56a6b66)}}, + {{TOBN(0x58fc0f5e, 0xb24fe1dc), TOBN(0x9eaf9dee, 0x6b73f24c), + TOBN(0xa90d588b, 0x33650705), TOBN(0xde5b62c5, 0xaf2ec729)}, + {TOBN(0x5c72cfae, 0xd3c2b36e), TOBN(0x868c19d5, 0x034435da), + TOBN(0x88605f93, 0xe17ee145), TOBN(0xaa60c4ee, 0x77a5d5b1)}}, + {{TOBN(0xbcf5bfd2, 0x3b60c472), TOBN(0xaf4ef13c, 0xeb1d3049), + TOBN(0x373f44fc, 0xe13895c9), TOBN(0xf29b382f, 0x0cbc9822)}, + {TOBN(0x1bfcb853, 0x73efaef6), TOBN(0xcf56ac9c, 0xa8c96f40), + TOBN(0xd7adf109, 0x7a191e24), TOBN(0x98035f44, 0xbf8a8dc2)}}, + {{TOBN(0xf40a71b9, 0x1e750c84), TOBN(0xc57f7b0c, 0x5dc6c469), + TOBN(0x49a0e79c, 0x6fbc19c1), TOBN(0x6b0f5889, 0xa48ebdb8)}, + {TOBN(0x5d3fd084, 0xa07c4e9f), TOBN(0xc3830111, 0xab27de14), + TOBN(0x0e4929fe, 0x33e08dcc), TOBN(0xf4a5ad24, 0x40bb73a3)}}, + {{TOBN(0xde86c2bf, 0x490f97ca), TOBN(0x288f09c6, 0x67a1ce18), + TOBN(0x364bb886, 0x1844478d), TOBN(0x7840fa42, 0xceedb040)}, + {TOBN(0x1269fdd2, 0x5a631b37), TOBN(0x94761f1e, 0xa47c8b7d), + TOBN(0xfc0c2e17, 0x481c6266), TOBN(0x85e16ea2, 0x3daa5fa7)}}, + {{TOBN(0xccd86033, 0x92491048), TOBN(0x0c2f6963, 0xf4d402d7), + TOBN(0x6336f7df, 0xdf6a865c), TOBN(0x0a2a463c, 0xb5c02a87)}, + {TOBN(0xb0e29be7, 0xbf2f12ee), TOBN(0xf0a22002, 0x66bad988), + TOBN(0x27f87e03, 0x9123c1d7), TOBN(0x21669c55, 0x328a8c98)}}, + {{TOBN(0x186b9803, 0x92f14529), TOBN(0xd3d056cc, 0x63954df3), + TOBN(0x2f03fd58, 0x175a46f6), TOBN(0x63e34ebe, 0x11558558)}, + {TOBN(0xe13fedee, 0x5b80cfa5), TOBN(0xe872a120, 0xd401dbd1), + TOBN(0x52657616, 0xe8a9d667), TOBN(0xbc8da4b6, 0xe08d6693)}}, + {{TOBN(0x370fb9bb, 0x1b703e75), TOBN(0x6773b186, 0xd4338363), + TOBN(0x18dad378, 0xecef7bff), TOBN(0xaac787ed, 0x995677da)}, + {TOBN(0x4801ea8b, 0x0437164b), TOBN(0xf430ad20, 0x73fe795e), + TOBN(0xb164154d, 0x8ee5eb73), TOBN(0x0884ecd8, 0x108f7c0e)}}, + {{TOBN(0x0e6ec096, 0x5f520698), TOBN(0x640631fe, 0x44f7b8d9), + TOBN(0x92fd34fc, 0xa35a68b9), TOBN(0x9c5a4b66, 0x4d40cf4e)}, + {TOBN(0x949454bf, 0x80b6783d), TOBN(0x80e701fe, 0x3a320a10), + TOBN(0x8d1a564a, 0x1a0a39b2), TOBN(0x1436d53d, 0x320587db)}}, + {{TOBN(0xf5096e6d, 0x6556c362), TOBN(0xbc23a3c0, 0xe2455d7e), + TOBN(0x3a7aee54, 0x807230f9), TOBN(0x9ba1cfa6, 0x22ae82fd)}, + {TOBN(0x833a057a, 0x99c5d706), TOBN(0x8be85f4b, 0x842315c9), + TOBN(0xd083179a, 0x66a72f12), TOBN(0x2fc77d5d, 0xcdcc73cd)}}, + {{TOBN(0x22b88a80, 0x5616ee30), TOBN(0xfb09548f, 0xe7ab1083), + TOBN(0x8ad6ab0d, 0x511270cd), TOBN(0x61f6c57a, 0x6924d9ab)}, + {TOBN(0xa0f7bf72, 0x90aecb08), TOBN(0x849f87c9, 0x0df784a4), + TOBN(0x27c79c15, 0xcfaf1d03), TOBN(0xbbf9f675, 0xc463face)}}, + {{TOBN(0x91502c65, 0x765ba543), TOBN(0x18ce3cac, 0x42ea60dd), + TOBN(0xe5cee6ac, 0x6e43ecb3), TOBN(0x63e4e910, 0x68f2aeeb)}, + {TOBN(0x26234fa3, 0xc85932ee), TOBN(0x96883e8b, 0x4c90c44d), + TOBN(0x29b9e738, 0xa18a50f6), TOBN(0xbfc62b2a, 0x3f0420df)}}, + {{TOBN(0xd22a7d90, 0x6d3e1fa9), TOBN(0x17115618, 0xfe05b8a3), + TOBN(0x2a0c9926, 0xbb2b9c01), TOBN(0xc739fcc6, 0xe07e76a2)}, + {TOBN(0x540e9157, 0x165e439a), TOBN(0x06353a62, 0x6a9063d8), + TOBN(0x84d95594, 0x61e927a3), TOBN(0x013b9b26, 0xe2e0be7f)}}, + {{TOBN(0x4feaec3b, 0x973497f1), TOBN(0x15c0f94e, 0x093ebc2d), + TOBN(0x6af5f227, 0x33af0583), TOBN(0x0c2af206, 0xc61f3340)}, + {TOBN(0xd25dbdf1, 0x4457397c), TOBN(0x2e8ed017, 0xcabcbae0), + TOBN(0xe3010938, 0xc2815306), TOBN(0xbaa99337, 0xe8c6cd68)}}, + {{TOBN(0x08513182, 0x3b0ec7de), TOBN(0x1e1b822b, 0x58df05df), + TOBN(0x5c14842f, 0xa5c3b683), TOBN(0x98fe977e, 0x3eba34ce)}, + {TOBN(0xfd2316c2, 0x0d5e8873), TOBN(0xe48d839a, 0xbd0d427d), + TOBN(0x495b2218, 0x623fc961), TOBN(0x24ee56e7, 0xb46fba5e)}}, + {{TOBN(0x9184a55b, 0x91e4de58), TOBN(0xa7488ca5, 0xdfdea288), + TOBN(0xa723862e, 0xa8dcc943), TOBN(0x92d762b2, 0x849dc0fc)}, + {TOBN(0x3c444a12, 0x091ff4a9), TOBN(0x581113fa, 0x0cada274), + TOBN(0xb9de0a45, 0x30d8eae2), TOBN(0x5e0fcd85, 0xdf6b41ea)}}, + {{TOBN(0x6233ea68, 0xc094dbb5), TOBN(0xb77d062e, 0xd968d410), + TOBN(0x3e719bbc, 0x58b3002d), TOBN(0x68e7dd3d, 0x3dc49d58)}, + {TOBN(0x8d825740, 0x013a5e58), TOBN(0x21311747, 0x3c9e3c1b), + TOBN(0x0cb0a2a7, 0x7c99b6ab), TOBN(0x5c48a3b3, 0xc2f888f2)}}}, + {{{TOBN(0xc7913e91, 0x991724f3), TOBN(0x5eda799c, 0x39cbd686), + TOBN(0xddb595c7, 0x63d4fc1e), TOBN(0x6b63b80b, 0xac4fed54)}, + {TOBN(0x6ea0fc69, 0x7e5fb516), TOBN(0x737708ba, 0xd0f1c964), + TOBN(0x9628745f, 0x11a92ca5), TOBN(0x61f37958, 0x9a86967a)}}, + {{TOBN(0x9af39b2c, 0xaa665072), TOBN(0x78322fa4, 0xefd324ef), + TOBN(0x3d153394, 0xc327bd31), TOBN(0x81d5f271, 0x3129dab0)}, + {TOBN(0xc72e0c42, 0xf48027f5), TOBN(0xaa40cdbc, 0x8536e717), + TOBN(0xf45a657a, 0x2d369d0f), TOBN(0xb03bbfc4, 0xea7f74e6)}}, + {{TOBN(0x46a8c418, 0x0d738ded), TOBN(0x6f1a5bb0, 0xe0de5729), + TOBN(0xf10230b9, 0x8ba81675), TOBN(0x32c6f30c, 0x112b33d4)}, + {TOBN(0x7559129d, 0xd8fffb62), TOBN(0x6a281b47, 0xb459bf05), + TOBN(0x77c1bd3a, 0xfa3b6776), TOBN(0x0709b380, 0x7829973a)}}, + {{TOBN(0x8c26b232, 0xa3326505), TOBN(0x38d69272, 0xee1d41bf), + TOBN(0x0459453e, 0xffe32afa), TOBN(0xce8143ad, 0x7cb3ea87)}, + {TOBN(0x932ec1fa, 0x7e6ab666), TOBN(0x6cd2d230, 0x22286264), + TOBN(0x459a46fe, 0x6736f8ed), TOBN(0x50bf0d00, 0x9eca85bb)}}, + {{TOBN(0x0b825852, 0x877a21ec), TOBN(0x300414a7, 0x0f537a94), + TOBN(0x3f1cba40, 0x21a9a6a2), TOBN(0x50824eee, 0x76943c00)}, + {TOBN(0xa0dbfcec, 0xf83cba5d), TOBN(0xf9538148, 0x93b4f3c0), + TOBN(0x61744162, 0x48f24dd7), TOBN(0x5322d64d, 0xe4fb09dd)}}, + {{TOBN(0x57447384, 0x3d9325f3), TOBN(0xa9bef2d0, 0xf371cb84), + TOBN(0x77d2188b, 0xa61e36c5), TOBN(0xbbd6a7d7, 0xc602df72)}, + {TOBN(0xba3aa902, 0x8f61bc0b), TOBN(0xf49085ed, 0x6ed0b6a1), + TOBN(0x8bc625d6, 0xae6e8298), TOBN(0x832b0b1d, 0xa2e9c01d)}}, + {{TOBN(0xa337c447, 0xf1f0ced1), TOBN(0x800cc793, 0x9492dd2b), + TOBN(0x4b93151d, 0xbea08efa), TOBN(0x820cf3f8, 0xde0a741e)}, + {TOBN(0xff1982dc, 0x1c0f7d13), TOBN(0xef921960, 0x84dde6ca), + TOBN(0x1ad7d972, 0x45f96ee3), TOBN(0x319c8dbe, 0x29dea0c7)}}, + {{TOBN(0xd3ea3871, 0x7b82b99b), TOBN(0x75922d4d, 0x470eb624), + TOBN(0x8f66ec54, 0x3b95d466), TOBN(0x66e673cc, 0xbee1e346)}, + {TOBN(0x6afe67c4, 0xb5f2b89a), TOBN(0x3de9c1e6, 0x290e5cd3), + TOBN(0x8c278bb6, 0x310a2ada), TOBN(0x420fa384, 0x0bdb323b)}}, + {{TOBN(0x0ae1d63b, 0x0eb919b0), TOBN(0xd74ee51d, 0xa74b9620), + TOBN(0x395458d0, 0xa674290c), TOBN(0x324c930f, 0x4620a510)}, + {TOBN(0x2d1f4d19, 0xfbac27d4), TOBN(0x4086e8ca, 0x9bedeeac), + TOBN(0x0cdd211b, 0x9b679ab8), TOBN(0x5970167d, 0x7090fec4)}}, + {{TOBN(0x3420f2c9, 0xfaf1fc63), TOBN(0x616d333a, 0x328c8bb4), + TOBN(0x7d65364c, 0x57f1fe4a), TOBN(0x9343e877, 0x55e5c73a)}, + {TOBN(0x5795176b, 0xe970e78c), TOBN(0xa36ccebf, 0x60533627), + TOBN(0xfc7c7380, 0x09cdfc1b), TOBN(0xb39a2afe, 0xb3fec326)}}, + {{TOBN(0xb7ff1ba1, 0x6224408a), TOBN(0xcc856e92, 0x247cfc5e), + TOBN(0x01f102e7, 0xc18bc493), TOBN(0x4613ab74, 0x2091c727)}, + {TOBN(0xaa25e89c, 0xc420bf2b), TOBN(0x00a53176, 0x90337ec2), + TOBN(0xd2be9f43, 0x7d025fc7), TOBN(0x3316fb85, 0x6e6fe3dc)}}, + {{TOBN(0x27520af5, 0x9ac50814), TOBN(0xfdf95e78, 0x9a8e4223), + TOBN(0xb7e7df2a, 0x56bec5a0), TOBN(0xf7022f7d, 0xdf159e5d)}, + {TOBN(0x93eeeab1, 0xcac1fe8f), TOBN(0x8040188c, 0x37451168), + TOBN(0x7ee8aa8a, 0xd967dce6), TOBN(0xfa0e79e7, 0x3abc9299)}}, + {{TOBN(0x67332cfc, 0x2064cfd1), TOBN(0x339c31de, 0xb0651934), + TOBN(0x719b28d5, 0x2a3bcbea), TOBN(0xee74c82b, 0x9d6ae5c6)}, + {TOBN(0x0927d05e, 0xbaf28ee6), TOBN(0x82cecf2c, 0x9d719028), + TOBN(0x0b0d353e, 0xddb30289), TOBN(0xfe4bb977, 0xfddb2e29)}}, + {{TOBN(0xbb5bb990, 0x640bfd9e), TOBN(0xd226e277, 0x82f62108), + TOBN(0x4bf00985, 0x02ffdd56), TOBN(0x7756758a, 0x2ca1b1b5)}, + {TOBN(0xc32b62a3, 0x5285fe91), TOBN(0xedbc546a, 0x8c9cd140), + TOBN(0x1e47a013, 0xaf5cb008), TOBN(0xbca7e720, 0x073ce8f2)}}, + {{TOBN(0xe10b2ab8, 0x17a91cae), TOBN(0xb89aab65, 0x08e27f63), + TOBN(0x7b3074a7, 0xdba3ddf9), TOBN(0x1c20ce09, 0x330c2972)}, + {TOBN(0x6b9917b4, 0x5fcf7e33), TOBN(0xe6793743, 0x945ceb42), + TOBN(0x18fc2215, 0x5c633d19), TOBN(0xad1adb3c, 0xc7485474)}}, + {{TOBN(0x646f9679, 0x6424c49b), TOBN(0xf888dfe8, 0x67c241c9), + TOBN(0xe12d4b93, 0x24f68b49), TOBN(0x9a6b62d8, 0xa571df20)}, + {TOBN(0x81b4b26d, 0x179483cb), TOBN(0x666f9632, 0x9511fae2), + TOBN(0xd281b3e4, 0xd53aa51f), TOBN(0x7f96a765, 0x7f3dbd16)}}, + {{TOBN(0xa7f8b5bf, 0x074a30ce), TOBN(0xd7f52107, 0x005a32e6), + TOBN(0x6f9e0907, 0x50237ed4), TOBN(0x2f21da47, 0x8096fa2b)}, + {TOBN(0xf3e19cb4, 0xeec863a0), TOBN(0xd18f77fd, 0x9527620a), + TOBN(0x9505c81c, 0x407c1cf8), TOBN(0x9998db4e, 0x1b6ec284)}}, + {{TOBN(0x7e3389e5, 0xc247d44d), TOBN(0x12507141, 0x3f4f3d80), + TOBN(0xd4ba0110, 0x4a78a6c7), TOBN(0x312874a0, 0x767720be)}, + {TOBN(0xded059a6, 0x75944370), TOBN(0xd6123d90, 0x3b2c0bdd), + TOBN(0xa56b717b, 0x51c108e3), TOBN(0x9bb7940e, 0x070623e9)}}, + {{TOBN(0x794e2d59, 0x84ac066c), TOBN(0xf5954a92, 0xe68c69a0), + TOBN(0x28c52458, 0x4fd99dcc), TOBN(0x60e639fc, 0xb1012517)}, + {TOBN(0xc2e60125, 0x7de79248), TOBN(0xe9ef6404, 0xf12fc6d7), + TOBN(0x4c4f2808, 0x2a3b5d32), TOBN(0x865ad32e, 0xc768eb8a)}}, + {{TOBN(0xac02331b, 0x13fb70b6), TOBN(0x037b44c1, 0x95599b27), + TOBN(0x1a860fc4, 0x60bd082c), TOBN(0xa2e25745, 0xc980cd01)}, + {TOBN(0xee3387a8, 0x1da0263e), TOBN(0x931bfb95, 0x2d10f3d6), + TOBN(0x5b687270, 0xa1f24a32), TOBN(0xf140e65d, 0xca494b86)}}, + {{TOBN(0x4f4ddf91, 0xb2f1ac7a), TOBN(0xf99eaabb, 0x760fee27), + TOBN(0x57f4008a, 0x49c228e5), TOBN(0x090be440, 0x1cf713bb)}, + {TOBN(0xac91fbe4, 0x5004f022), TOBN(0xd838c2c2, 0x569e1af6), + TOBN(0xd6c7d20b, 0x0f1daaa5), TOBN(0xaa063ac1, 0x1bbb02c0)}}, + {{TOBN(0x0938a422, 0x59558a78), TOBN(0x5343c669, 0x8435da2f), + TOBN(0x96f67b18, 0x034410dc), TOBN(0x7cc1e424, 0x84510804)}, + {TOBN(0x86a1543f, 0x16dfbb7d), TOBN(0x921fa942, 0x5b5bd592), + TOBN(0x9dcccb6e, 0xb33dd03c), TOBN(0x8581ddd9, 0xb843f51e)}}, + {{TOBN(0x54935fcb, 0x81d73c9e), TOBN(0x6d07e979, 0x0a5e97ab), + TOBN(0x4dc7b30a, 0xcf3a6bab), TOBN(0x147ab1f3, 0x170bee11)}, + {TOBN(0x0aaf8e3d, 0x9fafdee4), TOBN(0xfab3dbcb, 0x538a8b95), + TOBN(0x405df4b3, 0x6ef13871), TOBN(0xf1f4e9cb, 0x088d5a49)}}, + {{TOBN(0x9bcd24d3, 0x66b33f1d), TOBN(0x3b97b820, 0x5ce445c0), + TOBN(0xe2926549, 0xba93ff61), TOBN(0xd9c341ce, 0x4dafe616)}, + {TOBN(0xfb30a76e, 0x16efb6f3), TOBN(0xdf24b8ca, 0x605b953c), + TOBN(0x8bd52afe, 0xc2fffb9f), TOBN(0xbbac5ff7, 0xe19d0b96)}}, + {{TOBN(0x43c01b87, 0x459afccd), TOBN(0x6bd45143, 0xb7432652), + TOBN(0x84734530, 0x55b5d78e), TOBN(0x81088fdb, 0x1554ba7d)}, + {TOBN(0xada0a52c, 0x1e269375), TOBN(0xf9f037c4, 0x2dc5ec10), + TOBN(0xc0660607, 0x94bfbc11), TOBN(0xc0a630bb, 0xc9c40d2f)}}, + {{TOBN(0x5efc797e, 0xab64c31e), TOBN(0xffdb1dab, 0x74507144), + TOBN(0xf6124287, 0x1ca6790c), TOBN(0xe9609d81, 0xe69bf1bf)}, + {TOBN(0xdb898595, 0x00d24fc9), TOBN(0x9c750333, 0xe51fb417), + TOBN(0x51830a91, 0xfef7bbde), TOBN(0x0ce67dc8, 0x945f585c)}}, + {{TOBN(0x9a730ed4, 0x4763eb50), TOBN(0x24a0e221, 0xc1ab0d66), + TOBN(0x643b6393, 0x648748f3), TOBN(0x1982daa1, 0x6d3c6291)}, + {TOBN(0x6f00a9f7, 0x8bbc5549), TOBN(0x7a1783e1, 0x7f36384e), + TOBN(0xe8346323, 0xde977f50), TOBN(0x91ab688d, 0xb245502a)}}, + {{TOBN(0x331ab6b5, 0x6d0bdd66), TOBN(0x0a6ef32e, 0x64b71229), + TOBN(0x1028150e, 0xfe7c352f), TOBN(0x27e04350, 0xce7b39d3)}, + {TOBN(0x2a3c8acd, 0xc1070c82), TOBN(0xfb2034d3, 0x80c9feef), + TOBN(0x2d729621, 0x709f3729), TOBN(0x8df290bf, 0x62cb4549)}}, + {{TOBN(0x02f99f33, 0xfc2e4326), TOBN(0x3b30076d, 0x5eddf032), + TOBN(0xbb21f8cf, 0x0c652fb5), TOBN(0x314fb49e, 0xed91cf7b)}, + {TOBN(0xa013eca5, 0x2f700750), TOBN(0x2b9e3c23, 0x712a4575), + TOBN(0xe5355557, 0xaf30fbb0), TOBN(0x1ada3516, 0x7c77e771)}}, + {{TOBN(0x45f6ecb2, 0x7b135670), TOBN(0xe85d19df, 0x7cfc202e), + TOBN(0x0f1b50c7, 0x58d1be9f), TOBN(0x5ebf2c0a, 0xead2e344)}, + {TOBN(0x1531fe4e, 0xabc199c9), TOBN(0xc7032592, 0x56bab0ae), + TOBN(0x16ab2e48, 0x6c1fec54), TOBN(0x0f87fda8, 0x04280188)}}, + {{TOBN(0xdc9f46fc, 0x609e4a74), TOBN(0x2a44a143, 0xba667f91), + TOBN(0xbc3d8b95, 0xb4d83436), TOBN(0xa01e4bd0, 0xc7bd2958)}, + {TOBN(0x7b182932, 0x73483c90), TOBN(0xa79c6aa1, 0xa7c7b598), + TOBN(0xbf3983c6, 0xeaaac07e), TOBN(0x8f18181e, 0x96e0d4e6)}}, + {{TOBN(0x8553d37c, 0x051af62b), TOBN(0xe9a998eb, 0x0bf94496), + TOBN(0xe0844f9f, 0xb0d59aa1), TOBN(0x983fd558, 0xe6afb813)}, + {TOBN(0x9670c0ca, 0x65d69804), TOBN(0x732b22de, 0x6ea5ff2d), + TOBN(0xd7640ba9, 0x5fd8623b), TOBN(0x9f619163, 0xa6351782)}}, + {{TOBN(0x0bfc27ee, 0xacee5043), TOBN(0xae419e73, 0x2eb10f02), + TOBN(0x19c028d1, 0x8943fb05), TOBN(0x71f01cf7, 0xff13aa2a)}, + {TOBN(0x7790737e, 0x8887a132), TOBN(0x67513309, 0x66318410), + TOBN(0x9819e8a3, 0x7ddb795e), TOBN(0xfecb8ef5, 0xdad100b2)}}, + {{TOBN(0x59f74a22, 0x3021926a), TOBN(0xb7c28a49, 0x6f9b4c1c), + TOBN(0xed1a733f, 0x912ad0ab), TOBN(0x42a910af, 0x01a5659c)}, + {TOBN(0x3842c6e0, 0x7bd68cab), TOBN(0x2b57fa38, 0x76d70ac8), + TOBN(0x8a6707a8, 0x3c53aaeb), TOBN(0x62c1c510, 0x65b4db18)}}, + {{TOBN(0x8de2c1fb, 0xb2d09dc7), TOBN(0xc3dfed12, 0x266bd23b), + TOBN(0x927d039b, 0xd5b27db6), TOBN(0x2fb2f0f1, 0x103243da)}, + {TOBN(0xf855a07b, 0x80be7399), TOBN(0xed9327ce, 0x1f9f27a8), + TOBN(0xa0bd99c7, 0x729bdef7), TOBN(0x2b67125e, 0x28250d88)}}, + {{TOBN(0x784b26e8, 0x8670ced7), TOBN(0xe3dfe41f, 0xc31bd3b4), + TOBN(0x9e353a06, 0xbcc85cbc), TOBN(0x302e2909, 0x60178a9d)}, + {TOBN(0x860abf11, 0xa6eac16e), TOBN(0x76447000, 0xaa2b3aac), + TOBN(0x46ff9d19, 0x850afdab), TOBN(0x35bdd6a5, 0xfdb2d4c1)}}, + {{TOBN(0xe82594b0, 0x7e5c9ce9), TOBN(0x0f379e53, 0x20af346e), + TOBN(0x608b31e3, 0xbc65ad4a), TOBN(0x710c6b12, 0x267c4826)}, + {TOBN(0x51c966f9, 0x71954cf1), TOBN(0xb1cec793, 0x0d0aa215), + TOBN(0x1f155989, 0x86bd23a8), TOBN(0xae2ff99c, 0xf9452e86)}}, + {{TOBN(0xd8dd953c, 0x340ceaa2), TOBN(0x26355275, 0x2e2e9333), + TOBN(0x15d4e5f9, 0x8586f06d), TOBN(0xd6bf94a8, 0xf7cab546)}, + {TOBN(0x33c59a0a, 0xb76a9af0), TOBN(0x52740ab3, 0xba095af7), + TOBN(0xc444de8a, 0x24389ca0), TOBN(0xcc6f9863, 0x706da0cb)}}, + {{TOBN(0xb5a741a7, 0x6b2515cf), TOBN(0x71c41601, 0x9585c749), + TOBN(0x78350d4f, 0xe683de97), TOBN(0x31d61524, 0x63d0b5f5)}, + {TOBN(0x7a0cc5e1, 0xfbce090b), TOBN(0xaac927ed, 0xfbcb2a5b), + TOBN(0xe920de49, 0x20d84c35), TOBN(0x8c06a0b6, 0x22b4de26)}}, + {{TOBN(0xd34dd58b, 0xafe7ddf3), TOBN(0x55851fed, 0xc1e6e55b), + TOBN(0xd1395616, 0x960696e7), TOBN(0x940304b2, 0x5f22705f)}, + {TOBN(0x6f43f861, 0xb0a2a860), TOBN(0xcf121282, 0x0e7cc981), + TOBN(0x12186212, 0x0ab64a96), TOBN(0x09215b9a, 0xb789383c)}}, + {{TOBN(0x311eb305, 0x37387c09), TOBN(0xc5832fce, 0xf03ee760), + TOBN(0x30358f58, 0x32f7ea19), TOBN(0xe01d3c34, 0x91d53551)}, + {TOBN(0x1ca5ee41, 0xda48ea80), TOBN(0x34e71e8e, 0xcf4fa4c1), + TOBN(0x312abd25, 0x7af1e1c7), TOBN(0xe3afcdeb, 0x2153f4a5)}}, + {{TOBN(0x9d5c84d7, 0x00235e9a), TOBN(0x0308d3f4, 0x8c4c836f), + TOBN(0xc0a66b04, 0x89332de5), TOBN(0x610dd399, 0x89e566ef)}, + {TOBN(0xf8eea460, 0xd1ac1635), TOBN(0x84cbb3fb, 0x20a2c0df), + TOBN(0x40afb488, 0xe74a48c5), TOBN(0x29738198, 0xd326b150)}}, + {{TOBN(0x2a17747f, 0xa6d74081), TOBN(0x60ea4c05, 0x55a26214), + TOBN(0x53514bb4, 0x1f88c5fe), TOBN(0xedd64567, 0x7e83426c)}, + {TOBN(0xd5d6cbec, 0x96460b25), TOBN(0xa12fd0ce, 0x68dc115e), + TOBN(0xc5bc3ed2, 0x697840ea), TOBN(0x969876a8, 0xa6331e31)}}, + {{TOBN(0x60c36217, 0x472ff580), TOBN(0xf4229705, 0x4ad41393), + TOBN(0x4bd99ef0, 0xa03b8b92), TOBN(0x501c7317, 0xc144f4f6)}, + {TOBN(0x159009b3, 0x18464945), TOBN(0x6d5e594c, 0x74c5c6be), + TOBN(0x2d587011, 0x321a3660), TOBN(0xd1e184b1, 0x3898d022)}}, + {{TOBN(0x5ba04752, 0x4c6a7e04), TOBN(0x47fa1e2b, 0x45550b65), + TOBN(0x9419daf0, 0x48c0a9a5), TOBN(0x66362953, 0x7c243236)}, + {TOBN(0xcd0744b1, 0x5cb12a88), TOBN(0x561b6f9a, 0x2b646188), + TOBN(0x599415a5, 0x66c2c0c0), TOBN(0xbe3f0859, 0x0f83f09a)}}, + {{TOBN(0x9141c5be, 0xb92041b8), TOBN(0x01ae38c7, 0x26477d0d), + TOBN(0xca8b71f3, 0xd12c7a94), TOBN(0xfab5b31f, 0x765c70db)}, + {TOBN(0x76ae7492, 0x487443e9), TOBN(0x8595a310, 0x990d1349), + TOBN(0xf8dbeda8, 0x7d460a37), TOBN(0x7f7ad082, 0x1e45a38f)}}, + {{TOBN(0xed1d4db6, 0x1059705a), TOBN(0xa3dd492a, 0xe6b9c697), + TOBN(0x4b92ee3a, 0x6eb38bd5), TOBN(0xbab2609d, 0x67cc0bb7)}, + {TOBN(0x7fc4fe89, 0x6e70ee82), TOBN(0xeff2c56e, 0x13e6b7e3), + TOBN(0x9b18959e, 0x34d26fca), TOBN(0x2517ab66, 0x889d6b45)}}, + {{TOBN(0xf167b4e0, 0xbdefdd4f), TOBN(0x69958465, 0xf366e401), + TOBN(0x5aa368ab, 0xa73bbec0), TOBN(0x12148709, 0x7b240c21)}, + {TOBN(0x378c3233, 0x18969006), TOBN(0xcb4d73ce, 0xe1fe53d1), + TOBN(0x5f50a80e, 0x130c4361), TOBN(0xd67f5951, 0x7ef5212b)}}, + {{TOBN(0xf145e21e, 0x9e70c72e), TOBN(0xb2e52e29, 0x5566d2fb), + TOBN(0x44eaba4a, 0x032397f5), TOBN(0x5e56937b, 0x7e31a7de)}, + {TOBN(0x68dcf517, 0x456c61e1), TOBN(0xbc2e954a, 0xa8b0a388), + TOBN(0xe3552fa7, 0x60a8b755), TOBN(0x03442dae, 0x73ad0cde)}}, + {{TOBN(0x37ffe747, 0xceb26210), TOBN(0x983545e8, 0x787baef9), + TOBN(0x8b8c8535, 0x86a3de31), TOBN(0xc621dbcb, 0xfacd46db)}, + {TOBN(0x82e442e9, 0x59266fbb), TOBN(0xa3514c37, 0x339d471c), + TOBN(0x3a11b771, 0x62cdad96), TOBN(0xf0cb3b3c, 0xecf9bdf0)}}, + {{TOBN(0x3fcbdbce, 0x478e2135), TOBN(0x7547b5cf, 0xbda35342), + TOBN(0xa97e81f1, 0x8a677af6), TOBN(0xc8c2bf83, 0x28817987)}, + {TOBN(0xdf07eaaf, 0x45580985), TOBN(0xc68d1f05, 0xc93b45cb), + TOBN(0x106aa2fe, 0xc77b4cac), TOBN(0x4c1d8afc, 0x04a7ae86)}}, + {{TOBN(0xdb41c3fd, 0x9eb45ab2), TOBN(0x5b234b5b, 0xd4b22e74), + TOBN(0xda253dec, 0xf215958a), TOBN(0x67e0606e, 0xa04edfa0)}, + {TOBN(0xabbbf070, 0xef751b11), TOBN(0xf352f175, 0xf6f06dce), + TOBN(0xdfc4b6af, 0x6839f6b4), TOBN(0x53ddf9a8, 0x9959848e)}}, + {{TOBN(0xda49c379, 0xc21520b0), TOBN(0x90864ff0, 0xdbd5d1b6), + TOBN(0x2f055d23, 0x5f49c7f7), TOBN(0xe51e4e6a, 0xa796b2d8)}, + {TOBN(0xc361a67f, 0x5c9dc340), TOBN(0x5ad53c37, 0xbca7c620), + TOBN(0xda1d6588, 0x32c756d0), TOBN(0xad60d911, 0x8bb67e13)}}, + {{TOBN(0xd6c47bdf, 0x0eeec8c6), TOBN(0x4a27fec1, 0x078a1821), + TOBN(0x081f7415, 0xc3099524), TOBN(0x8effdf0b, 0x82cd8060)}, + {TOBN(0xdb70ec1c, 0x65842df8), TOBN(0x8821b358, 0xd319a901), + TOBN(0x72ee56ee, 0xde42b529), TOBN(0x5bb39592, 0x236e4286)}}, + {{TOBN(0xd1183316, 0xfd6f7140), TOBN(0xf9fadb5b, 0xbd8e81f7), + TOBN(0x701d5e0c, 0x5a02d962), TOBN(0xfdee4dbf, 0x1b601324)}, + {TOBN(0xbed17407, 0x35d7620e), TOBN(0x04e3c2c3, 0xf48c0012), + TOBN(0x9ee29da7, 0x3455449a), TOBN(0x562cdef4, 0x91a836c4)}}, + {{TOBN(0x8f682a5f, 0x47701097), TOBN(0x617125d8, 0xff88d0c2), + TOBN(0x948fda24, 0x57bb86dd), TOBN(0x348abb8f, 0x289f7286)}, + {TOBN(0xeb10eab5, 0x99d94bbd), TOBN(0xd51ba28e, 0x4684d160), + TOBN(0xabe0e51c, 0x30c8f41a), TOBN(0x66588b45, 0x13254f4a)}}, + {{TOBN(0x147ebf01, 0xfad097a5), TOBN(0x49883ea8, 0x610e815d), + TOBN(0xe44d60ba, 0x8a11de56), TOBN(0xa970de6e, 0x827a7a6d)}, + {TOBN(0x2be41424, 0x5e17fc19), TOBN(0xd833c657, 0x01214057), + TOBN(0x1375813b, 0x363e723f), TOBN(0x6820bb88, 0xe6a52e9b)}}, + {{TOBN(0x7e7f6970, 0xd875d56a), TOBN(0xd6a0a9ac, 0x51fbf6bf), + TOBN(0x54ba8790, 0xa3083c12), TOBN(0xebaeb23d, 0x6ae7eb64)}, + {TOBN(0xa8685c3a, 0xb99a907a), TOBN(0xf1e74550, 0x026bf40b), + TOBN(0x7b73a027, 0xc802cd9e), TOBN(0x9a8a927c, 0x4fef4635)}}, + {{TOBN(0xe1b6f60c, 0x08191224), TOBN(0xc4126ebb, 0xde4ec091), + TOBN(0xe1dff4dc, 0x4ae38d84), TOBN(0xde3f57db, 0x4f2ef985)}, + {TOBN(0x34964337, 0xd446a1dd), TOBN(0x7bf217a0, 0x859e77f6), + TOBN(0x8ff10527, 0x8e1d13f5), TOBN(0xa304ef03, 0x74eeae27)}}, + {{TOBN(0xfc6f5e47, 0xd19dfa5a), TOBN(0xdb007de3, 0x7fad982b), + TOBN(0x28205ad1, 0x613715f5), TOBN(0x251e6729, 0x7889529e)}, + {TOBN(0x72705184, 0x1ae98e78), TOBN(0xf818537d, 0x271cac32), + TOBN(0xc8a15b7e, 0xb7f410f5), TOBN(0xc474356f, 0x81f62393)}}, + {{TOBN(0x92dbdc5a, 0xc242316b), TOBN(0xabe060ac, 0xdbf4aff5), + TOBN(0x6e8c38fe, 0x909a8ec6), TOBN(0x43e514e5, 0x6116cb94)}, + {TOBN(0x2078fa38, 0x07d784f9), TOBN(0x1161a880, 0xf4b5b357), + TOBN(0x5283ce79, 0x13adea3d), TOBN(0x0756c3e6, 0xcc6a910b)}}, + {{TOBN(0x60bcfe01, 0xaaa79697), TOBN(0x04a73b29, 0x56391db1), + TOBN(0xdd8dad47, 0x189b45a0), TOBN(0xbfac0dd0, 0x48d5b8d9)}, + {TOBN(0x34ab3af5, 0x7d3d2ec2), TOBN(0x6fa2fc2d, 0x207bd3af), + TOBN(0x9ff40092, 0x66550ded), TOBN(0x719b3e87, 0x1fd5b913)}}, + {{TOBN(0xa573a496, 0x6d17fbc7), TOBN(0x0cd1a70a, 0x73d2b24e), + TOBN(0x34e2c5ca, 0xb2676937), TOBN(0xe7050b06, 0xbf669f21)}, + {TOBN(0xfbe948b6, 0x1ede9046), TOBN(0xa0530051, 0x97662659), + TOBN(0x58cbd4ed, 0xf10124c5), TOBN(0xde2646e4, 0xdd6c06c8)}}, + {{TOBN(0x332f8108, 0x8cad38c0), TOBN(0x471b7e90, 0x6bd68ae2), + TOBN(0x56ac3fb2, 0x0d8e27a3), TOBN(0xb54660db, 0x136b4b0d)}, + {TOBN(0x123a1e11, 0xa6fd8de4), TOBN(0x44dbffea, 0xa37799ef), + TOBN(0x4540b977, 0xce6ac17c), TOBN(0x495173a8, 0xaf60acef)}}}, + {{{TOBN(0x9ebb284d, 0x391c2a82), TOBN(0xbcdd4863, 0x158308e8), + TOBN(0x006f16ec, 0x83f1edca), TOBN(0xa13e2c37, 0x695dc6c8)}, + {TOBN(0x2ab756f0, 0x4a057a87), TOBN(0xa8765500, 0xa6b48f98), + TOBN(0x4252face, 0x68651c44), TOBN(0xa52b540b, 0xe1765e02)}}, + {{TOBN(0x4f922fc5, 0x16a0d2bb), TOBN(0x0d5cc16c, 0x1a623499), + TOBN(0x9241cf3a, 0x57c62c8b), TOBN(0x2f5e6961, 0xfd1b667f)}, + {TOBN(0x5c15c70b, 0xf5a01797), TOBN(0x3d20b44d, 0x60956192), + TOBN(0x04911b37, 0x071fdb52), TOBN(0xf648f916, 0x8d6f0f7b)}}, + {{TOBN(0x6dc1acaf, 0xe60b7cf7), TOBN(0x25860a50, 0x84a9d869), + TOBN(0x56fc6f09, 0xe7ba8ac4), TOBN(0x828c5bd0, 0x6148d29e)}, + {TOBN(0xac6b435e, 0xdc55ae5f), TOBN(0xa527f56c, 0xc0117411), + TOBN(0x94d5045e, 0xfd24342c), TOBN(0x2c4c0a35, 0x70b67c0d)}}, + {{TOBN(0x027cc8b8, 0xfac61d9a), TOBN(0x7d25e062, 0xe3c6fe8a), + TOBN(0xe08805bf, 0xe5bff503), TOBN(0x13271e6c, 0x6ff632f7)}, + {TOBN(0x55dca6c0, 0x232f76a5), TOBN(0x8957c32d, 0x701ef426), + TOBN(0xee728bcb, 0xa10a5178), TOBN(0x5ea60411, 0xb62c5173)}}, + {{TOBN(0xfc4e964e, 0xd0b8892b), TOBN(0x9ea17683, 0x9301bb74), + TOBN(0x6265c5ae, 0xfcc48626), TOBN(0xe60cf82e, 0xbb3e9102)}, + {TOBN(0x57adf797, 0xd4df5531), TOBN(0x235b59a1, 0x8deeefe2), + TOBN(0x60adcf58, 0x3f306eb1), TOBN(0x105c2753, 0x3d09492d)}}, + {{TOBN(0x4090914b, 0xb5def996), TOBN(0x1cb69c83, 0x233dd1e7), + TOBN(0xc1e9c1d3, 0x9b3d5e76), TOBN(0x1f3338ed, 0xfccf6012)}, + {TOBN(0xb1e95d0d, 0x2f5378a8), TOBN(0xacf4c2c7, 0x2f00cd21), + TOBN(0x6e984240, 0xeb5fe290), TOBN(0xd66c038d, 0x248088ae)}}, + {{TOBN(0x804d264a, 0xf94d70cf), TOBN(0xbdb802ef, 0x7314bf7e), + TOBN(0x8fb54de2, 0x4333ed02), TOBN(0x740461e0, 0x285635d9)}, + {TOBN(0x4113b2c8, 0x365e9383), TOBN(0xea762c83, 0x3fdef652), + TOBN(0x4eec6e2e, 0x47b956c1), TOBN(0xa3d814be, 0x65620fa4)}}, + {{TOBN(0x9ad5462b, 0xb4d8bc50), TOBN(0x181c0b16, 0xa9195770), + TOBN(0xebd4fe1c, 0x78412a68), TOBN(0xae0341bc, 0xc0dff48c)}, + {TOBN(0xb6bc45cf, 0x7003e866), TOBN(0xf11a6dea, 0x8a24a41b), + TOBN(0x5407151a, 0xd04c24c2), TOBN(0x62c9d27d, 0xda5b7b68)}}, + {{TOBN(0x2e964235, 0x88cceff6), TOBN(0x8594c54f, 0x8b07ed69), + TOBN(0x1578e73c, 0xc84d0d0d), TOBN(0x7b4e1055, 0xff532868)}, + {TOBN(0xa348c0d5, 0xb5ec995a), TOBN(0xbf4b9d55, 0x14289a54), + TOBN(0x9ba155a6, 0x58fbd777), TOBN(0x186ed7a8, 0x1a84491d)}}, + {{TOBN(0xd4992b30, 0x614c0900), TOBN(0xda98d121, 0xbd00c24b), + TOBN(0x7f534dc8, 0x7ec4bfa1), TOBN(0x4a5ff674, 0x37dc34bc)}, + {TOBN(0x68c196b8, 0x1d7ea1d7), TOBN(0x38cf2893, 0x80a6d208), + TOBN(0xfd56cd09, 0xe3cbbd6e), TOBN(0xec72e27e, 0x4205a5b6)}}, + {{TOBN(0x15ea68f5, 0xa44f77f7), TOBN(0x7aa5f9fd, 0xb43c52bc), + TOBN(0x86ff676f, 0x94f0e609), TOBN(0xa4cde963, 0x2e2d432b)}, + {TOBN(0x8cafa0c0, 0xeee470af), TOBN(0x84137d0e, 0x8a3f5ec8), + TOBN(0xebb40411, 0xfaa31231), TOBN(0xa239c13f, 0x6f7f7ccf)}}, + {{TOBN(0x32865719, 0xa8afd30b), TOBN(0x86798328, 0x8a826dce), + TOBN(0xdf04e891, 0xc4a8fbe0), TOBN(0xbb6b6e1b, 0xebf56ad3)}, + {TOBN(0x0a695b11, 0x471f1ff0), TOBN(0xd76c3389, 0xbe15baf0), + TOBN(0x018edb95, 0xbe96c43e), TOBN(0xf2beaaf4, 0x90794158)}}, + {{TOBN(0x152db09e, 0xc3076a27), TOBN(0x5e82908e, 0xe416545d), + TOBN(0xa2c41272, 0x356d6f2e), TOBN(0xdc9c9642, 0x31fd74e1)}, + {TOBN(0x66ceb88d, 0x519bf615), TOBN(0xe29ecd76, 0x05a2274e), + TOBN(0x3a0473c4, 0xbf5e2fa0), TOBN(0x6b6eb671, 0x64284e67)}}, + {{TOBN(0xe8b97932, 0xb88756dd), TOBN(0xed4e8652, 0xf17e3e61), + TOBN(0xc2dd1499, 0x3ee1c4a4), TOBN(0xc0aaee17, 0x597f8c0e)}, + {TOBN(0x15c4edb9, 0x6c168af3), TOBN(0x6563c7bf, 0xb39ae875), + TOBN(0xadfadb6f, 0x20adb436), TOBN(0xad55e8c9, 0x9a042ac0)}}, + {{TOBN(0x975a1ed8, 0xb76da1f5), TOBN(0x10dfa466, 0xa58acb94), + TOBN(0x8dd7f7e3, 0xac060282), TOBN(0x6813e66a, 0x572a051e)}, + {TOBN(0xb4ccae1e, 0x350cb901), TOBN(0xb653d656, 0x50cb7822), + TOBN(0x42484710, 0xdfab3b87), TOBN(0xcd7ee537, 0x9b670fd0)}}, + {{TOBN(0x0a50b12e, 0x523b8bf6), TOBN(0x8009eb5b, 0x8f910c1b), + TOBN(0xf535af82, 0x4a167588), TOBN(0x0f835f9c, 0xfb2a2abd)}, + {TOBN(0xf59b2931, 0x2afceb62), TOBN(0xc797df2a, 0x169d383f), + TOBN(0xeb3f5fb0, 0x66ac02b0), TOBN(0x029d4c6f, 0xdaa2d0ca)}}, + {{TOBN(0xd4059bc1, 0xafab4bc5), TOBN(0x833f5c6f, 0x56783247), + TOBN(0xb5346630, 0x8d2d3605), TOBN(0x83387891, 0xd34d8433)}, + {TOBN(0xd973b30f, 0xadd9419a), TOBN(0xbcca1099, 0xafe3fce8), + TOBN(0x08178315, 0x0809aac6), TOBN(0x01b7f21a, 0x540f0f11)}}, + {{TOBN(0x65c29219, 0x909523c8), TOBN(0xa62f648f, 0xa3a1c741), + TOBN(0x88598d4f, 0x60c9e55a), TOBN(0xbce9141b, 0x0e4f347a)}, + {TOBN(0x9af97d84, 0x35f9b988), TOBN(0x0210da62, 0x320475b6), + TOBN(0x3c076e22, 0x9191476c), TOBN(0x7520dbd9, 0x44fc7834)}}, + {{TOBN(0x6a6b2cfe, 0xc1ab1bbd), TOBN(0xef8a65be, 0xdc650938), + TOBN(0x72855540, 0x805d7bc4), TOBN(0xda389396, 0xed11fdfd)}, + {TOBN(0xa9d5bd36, 0x74660876), TOBN(0x11d67c54, 0xb45dff35), + TOBN(0x6af7d148, 0xa4f5da94), TOBN(0xbb8d4c3f, 0xc0bbeb31)}}, + {{TOBN(0x87a7ebd1, 0xe0a1b12a), TOBN(0x1e4ef88d, 0x770ba95f), + TOBN(0x8c33345c, 0xdc2ae9cb), TOBN(0xcecf1276, 0x01cc8403)}, + {TOBN(0x687c012e, 0x1b39b80f), TOBN(0xfd90d0ad, 0x35c33ba4), + TOBN(0xa3ef5a67, 0x5c9661c2), TOBN(0x368fc88e, 0xe017429e)}}, + {{TOBN(0xd30c6761, 0x196a2fa2), TOBN(0x931b9817, 0xbd5b312e), + TOBN(0xba01000c, 0x72f54a31), TOBN(0xa203d2c8, 0x66eaa541)}, + {TOBN(0xf2abdee0, 0x98939db3), TOBN(0xe37d6c2c, 0x3e606c02), + TOBN(0xf2921574, 0x521ff643), TOBN(0x2781b3c4, 0xd7e2fca3)}}, + {{TOBN(0x664300b0, 0x7850ec06), TOBN(0xac5a38b9, 0x7d3a10cf), + TOBN(0x9233188d, 0xe34ab39d), TOBN(0xe77057e4, 0x5072cbb9)}, + {TOBN(0xbcf0c042, 0xb59e78df), TOBN(0x4cfc91e8, 0x1d97de52), + TOBN(0x4661a26c, 0x3ee0ca4a), TOBN(0x5620a4c1, 0xfb8507bc)}}, + {{TOBN(0x4b44d4aa, 0x049f842c), TOBN(0xceabc5d5, 0x1540e82b), + TOBN(0x306710fd, 0x15c6f156), TOBN(0xbe5ae52b, 0x63db1d72)}, + {TOBN(0x06f1e7e6, 0x334957f1), TOBN(0x57e388f0, 0x31144a70), + TOBN(0xfb69bb2f, 0xdf96447b), TOBN(0x0f78ebd3, 0x73e38a12)}}, + {{TOBN(0xb8222605, 0x2b7ce542), TOBN(0xe6d4ce99, 0x7472bde1), + TOBN(0x53e16ebe, 0x09d2f4da), TOBN(0x180ff42e, 0x53b92b2e)}, + {TOBN(0xc59bcc02, 0x2c34a1c6), TOBN(0x3803d6f9, 0x422c46c2), + TOBN(0x18aff74f, 0x5c14a8a2), TOBN(0x55aebf80, 0x10a08b28)}}, + {{TOBN(0x66097d58, 0x7135593f), TOBN(0x32e6eff7, 0x2be570cd), + TOBN(0x584e6a10, 0x2a8c860d), TOBN(0xcd185890, 0xa2eb4163)}, + {TOBN(0x7ceae99d, 0x6d97e134), TOBN(0xd42c6b70, 0xdd8447ce), + TOBN(0x59ddbb4a, 0xb8c50273), TOBN(0x03c612df, 0x3cf34e1e)}}, + {{TOBN(0x84b9ca15, 0x04b6c5a0), TOBN(0x35216f39, 0x18f0e3a3), + TOBN(0x3ec2d2bc, 0xbd986c00), TOBN(0x8bf546d9, 0xd19228fe)}, + {TOBN(0xd1c655a4, 0x4cd623c3), TOBN(0x366ce718, 0x502b8e5a), + TOBN(0x2cfc84b4, 0xeea0bfe7), TOBN(0xe01d5cee, 0xcf443e8e)}}, + {{TOBN(0x8ec045d9, 0x036520f8), TOBN(0xdfb3c3d1, 0x92d40e98), + TOBN(0x0bac4cce, 0xcc559a04), TOBN(0x35eccae5, 0x240ea6b1)}, + {TOBN(0x180b32db, 0xf8a5a0ac), TOBN(0x547972a5, 0xeb699700), + TOBN(0xa3765801, 0xca26bca0), TOBN(0x57e09d0e, 0xa647f25a)}}, + {{TOBN(0xb956970e, 0x2fdd23cc), TOBN(0xb80288bc, 0x5682e971), + TOBN(0xe6e6d91e, 0x9ae86ebc), TOBN(0x0564c83f, 0x8c9f1939)}, + {TOBN(0x551932a2, 0x39560368), TOBN(0xe893752b, 0x049c28e2), + TOBN(0x0b03cee5, 0xa6a158c3), TOBN(0xe12d656b, 0x04964263)}}, + {{TOBN(0x4b47554e, 0x63e3bc1d), TOBN(0xc719b6a2, 0x45044ff7), + TOBN(0x4f24d30a, 0xe48daa07), TOBN(0xa3f37556, 0xc8c1edc3)}, + {TOBN(0x9a47bf76, 0x0700d360), TOBN(0xbb1a1824, 0x822ae4e2), + TOBN(0x22e275a3, 0x89f1fb4c), TOBN(0x72b1aa23, 0x9968c5f5)}}, + {{TOBN(0xa75feaca, 0xbe063f64), TOBN(0x9b392f43, 0xbce47a09), + TOBN(0xd4241509, 0x1ad07aca), TOBN(0x4b0c591b, 0x8d26cd0f)}, + {TOBN(0x2d42ddfd, 0x92f1169a), TOBN(0x63aeb1ac, 0x4cbf2392), + TOBN(0x1de9e877, 0x0691a2af), TOBN(0xebe79af7, 0xd98021da)}}, + {{TOBN(0xcfdf2a4e, 0x40e50acf), TOBN(0xf0a98ad7, 0xaf01d665), + TOBN(0xefb640bf, 0x1831be1f), TOBN(0x6fe8bd2f, 0x80e9ada0)}, + {TOBN(0x94c103a1, 0x6cafbc91), TOBN(0x170f8759, 0x8308e08c), + TOBN(0x5de2d2ab, 0x9780ff4f), TOBN(0x666466bc, 0x45b201f2)}}, + {{TOBN(0x58af2010, 0xf5b343bc), TOBN(0x0f2e400a, 0xf2f142fe), + TOBN(0x3483bfde, 0xa85f4bdf), TOBN(0xf0b1d093, 0x03bfeaa9)}, + {TOBN(0x2ea01b95, 0xc7081603), TOBN(0xe943e4c9, 0x3dba1097), + TOBN(0x47be92ad, 0xb438f3a6), TOBN(0x00bb7742, 0xe5bf6636)}}, + {{TOBN(0x136b7083, 0x824297b4), TOBN(0x9d0e5580, 0x5584455f), + TOBN(0xab48cedc, 0xf1c7d69e), TOBN(0x53a9e481, 0x2a256e76)}, + {TOBN(0x0402b0e0, 0x65eb2413), TOBN(0xdadbbb84, 0x8fc407a7), + TOBN(0xa65cd5a4, 0x8d7f5492), TOBN(0x21d44293, 0x74bae294)}}, + {{TOBN(0x66917ce6, 0x3b5f1cc4), TOBN(0x37ae52ea, 0xce872e62), + TOBN(0xbb087b72, 0x2905f244), TOBN(0x12077086, 0x1e6af74f)}, + {TOBN(0x4b644e49, 0x1058edea), TOBN(0x827510e3, 0xb638ca1d), + TOBN(0x8cf2b704, 0x6038591c), TOBN(0xffc8b47a, 0xfe635063)}}, + {{TOBN(0x3ae220e6, 0x1b4d5e63), TOBN(0xbd864742, 0x9d961b4b), + TOBN(0x610c107e, 0x9bd16bed), TOBN(0x4270352a, 0x1127147b)}, + {TOBN(0x7d17ffe6, 0x64cfc50e), TOBN(0x50dee01a, 0x1e36cb42), + TOBN(0x068a7622, 0x35dc5f9a), TOBN(0x9a08d536, 0xdf53f62c)}}, + {{TOBN(0x4ed71457, 0x6be5f7de), TOBN(0xd93006f8, 0xc2263c9e), + TOBN(0xe073694c, 0xcacacb36), TOBN(0x2ff7a5b4, 0x3ae118ab)}, + {TOBN(0x3cce53f1, 0xcd871236), TOBN(0xf156a39d, 0xc2aa6d52), + TOBN(0x9cc5f271, 0xb198d76d), TOBN(0xbc615b6f, 0x81383d39)}}, + {{TOBN(0xa54538e8, 0xde3eee6b), TOBN(0x58c77538, 0xab910d91), + TOBN(0x31e5bdbc, 0x58d278bd), TOBN(0x3cde4adf, 0xb963acae)}, + {TOBN(0xb1881fd2, 0x5302169c), TOBN(0x8ca60fa0, 0xa989ed8b), + TOBN(0xa1999458, 0xff96a0ee), TOBN(0xc1141f03, 0xac6c283d)}}, + {{TOBN(0x7677408d, 0x6dfafed3), TOBN(0x33a01653, 0x39661588), + TOBN(0x3c9c15ec, 0x0b726fa0), TOBN(0x090cfd93, 0x6c9b56da)}, + {TOBN(0xe34f4bae, 0xa3c40af5), TOBN(0x3469eadb, 0xd21129f1), + TOBN(0xcc51674a, 0x1e207ce8), TOBN(0x1e293b24, 0xc83b1ef9)}}, + {{TOBN(0x17173d13, 0x1e6c0bb4), TOBN(0x19004695, 0x90776d35), + TOBN(0xe7980e34, 0x6de6f922), TOBN(0x873554cb, 0xf4dd9a22)}, + {TOBN(0x0316c627, 0xcbf18a51), TOBN(0x4d93651b, 0x3032c081), + TOBN(0x207f2771, 0x3946834d), TOBN(0x2c08d7b4, 0x30cdbf80)}}, + {{TOBN(0x137a4fb4, 0x86df2a61), TOBN(0xa1ed9c07, 0xecf7b4a2), + TOBN(0xb2e460e2, 0x7bd042ff), TOBN(0xb7f5e2fa, 0x5f62f5ec)}, + {TOBN(0x7aa6ec6b, 0xcc2423b7), TOBN(0x75ce0a7f, 0xba63eea7), + TOBN(0x67a45fb1, 0xf250a6e1), TOBN(0x93bc919c, 0xe53cdc9f)}}, + {{TOBN(0x9271f56f, 0x871942df), TOBN(0x2372ff6f, 0x7859ad66), + TOBN(0x5f4c2b96, 0x33cb1a78), TOBN(0xe3e29101, 0x5838aa83)}, + {TOBN(0xa7ed1611, 0xe4e8110c), TOBN(0x2a2d70d5, 0x330198ce), + TOBN(0xbdf132e8, 0x6720efe0), TOBN(0xe61a8962, 0x66a471bf)}}, + {{TOBN(0x796d3a85, 0x825808bd), TOBN(0x51dc3cb7, 0x3fd6e902), + TOBN(0x643c768a, 0x916219d1), TOBN(0x36cd7685, 0xa2ad7d32)}, + {TOBN(0xe3db9d05, 0xb22922a4), TOBN(0x6494c87e, 0xdba29660), + TOBN(0xf0ac91df, 0xbcd2ebc7), TOBN(0x4deb57a0, 0x45107f8d)}}, + {{TOBN(0x42271f59, 0xc3d12a73), TOBN(0x5f71687c, 0xa5c2c51d), + TOBN(0xcb1f50c6, 0x05797bcb), TOBN(0x29ed0ed9, 0xd6d34eb0)}, + {TOBN(0xe5fe5b47, 0x4683c2eb), TOBN(0x4956eeb5, 0x97447c46), + TOBN(0x5b163a43, 0x71207167), TOBN(0x93fa2fed, 0x0248c5ef)}}, + {{TOBN(0x67930af2, 0x31f63950), TOBN(0xa77797c1, 0x14caa2c9), + TOBN(0x526e80ee, 0x27ac7e62), TOBN(0xe1e6e626, 0x58b28aec)}, + {TOBN(0x636178b0, 0xb3c9fef0), TOBN(0xaf7752e0, 0x6d5f90be), + TOBN(0x94ecaf18, 0xeece51cf), TOBN(0x2864d0ed, 0xca806e1f)}}, + {{TOBN(0x6de2e383, 0x97c69134), TOBN(0x5a42c316, 0xeb291293), + TOBN(0xc7779219, 0x6a60bae0), TOBN(0xa24de346, 0x6b7599d1)}, + {TOBN(0x49d374aa, 0xb75d4941), TOBN(0x98900586, 0x2d501ff0), + TOBN(0x9f16d40e, 0xeb7974cf), TOBN(0x1033860b, 0xcdd8c115)}}, + {{TOBN(0xb6c69ac8, 0x2094cec3), TOBN(0x9976fb88, 0x403b770c), + TOBN(0x1dea026c, 0x4859590d), TOBN(0xb6acbb46, 0x8562d1fd)}, + {TOBN(0x7cd6c461, 0x44569d85), TOBN(0xc3190a36, 0x97f0891d), + TOBN(0xc6f53195, 0x48d5a17d), TOBN(0x7d919966, 0xd749abc8)}}, + {{TOBN(0x65104837, 0xdd1c8a20), TOBN(0x7e5410c8, 0x2f683419), + TOBN(0x958c3ca8, 0xbe94022e), TOBN(0x605c3197, 0x6145dac2)}, + {TOBN(0x3fc07501, 0x01683d54), TOBN(0x1d7127c5, 0x595b1234), + TOBN(0x10b8f87c, 0x9481277f), TOBN(0x677db2a8, 0xe65a1adb)}}, + {{TOBN(0xec2fccaa, 0xddce3345), TOBN(0x2a6811b7, 0x012a4350), + TOBN(0x96760ff1, 0xac598bdc), TOBN(0x054d652a, 0xd1bf4128)}, + {TOBN(0x0a1151d4, 0x92a21005), TOBN(0xad7f3971, 0x33110fdf), + TOBN(0x8c95928c, 0x1960100f), TOBN(0x6c91c825, 0x7bf03362)}}, + {{TOBN(0xc8c8b2a2, 0xce309f06), TOBN(0xfdb27b59, 0xca27204b), + TOBN(0xd223eaa5, 0x0848e32e), TOBN(0xb93e4b2e, 0xe7bfaf1e)}, + {TOBN(0xc5308ae6, 0x44aa3ded), TOBN(0x317a666a, 0xc015d573), + TOBN(0xc888ce23, 0x1a979707), TOBN(0xf141c1e6, 0x0d5c4958)}}, + {{TOBN(0xb53b7de5, 0x61906373), TOBN(0x858dbade, 0xeb999595), + TOBN(0x8cbb47b2, 0xa59e5c36), TOBN(0x660318b3, 0xdcf4e842)}, + {TOBN(0xbd161ccd, 0x12ba4b7a), TOBN(0xf399daab, 0xf8c8282a), + TOBN(0x1587633a, 0xeeb2130d), TOBN(0xa465311a, 0xda38dd7d)}}, + {{TOBN(0x5f75eec8, 0x64d3779b), TOBN(0x3c5d0476, 0xad64c171), + TOBN(0x87410371, 0x2a914428), TOBN(0x8096a891, 0x90e2fc29)}, + {TOBN(0xd3d2ae9d, 0x23b3ebc2), TOBN(0x90bdd6db, 0xa580cfd6), + TOBN(0x52dbb7f3, 0xc5b01f6c), TOBN(0xe68eded4, 0xe102a2dc)}}, + {{TOBN(0x17785b77, 0x99eb6df0), TOBN(0x26c3cc51, 0x7386b779), + TOBN(0x345ed988, 0x6417a48e), TOBN(0xe990b4e4, 0x07d6ef31)}, + {TOBN(0x0f456b7e, 0x2586abba), TOBN(0x239ca6a5, 0x59c96e9a), + TOBN(0xe327459c, 0xe2eb4206), TOBN(0x3a4c3313, 0xa002b90a)}}, + {{TOBN(0x2a114806, 0xf6a3f6fb), TOBN(0xad5cad2f, 0x85c251dd), + TOBN(0x92c1f613, 0xf5a784d3), TOBN(0xec7bfacf, 0x349766d5)}, + {TOBN(0x04b3cd33, 0x3e23cb3b), TOBN(0x3979fe84, 0xc5a64b2d), + TOBN(0x192e2720, 0x7e589106), TOBN(0xa60c43d1, 0xa15b527f)}}, + {{TOBN(0x2dae9082, 0xbe7cf3a6), TOBN(0xcc86ba92, 0xbc967274), + TOBN(0xf28a2ce8, 0xaea0a8a9), TOBN(0x404ca6d9, 0x6ee988b3)}, + {TOBN(0xfd7e9c5d, 0x005921b8), TOBN(0xf56297f1, 0x44e79bf9), + TOBN(0xa163b460, 0x0d75ddc2), TOBN(0x30b23616, 0xa1f2be87)}}, + {{TOBN(0x4b070d21, 0xbfe50e2b), TOBN(0x7ef8cfd0, 0xe1bfede1), + TOBN(0xadba0011, 0x2aac4ae0), TOBN(0x2a3e7d01, 0xb9ebd033)}, + {TOBN(0x995277ec, 0xe38d9d1c), TOBN(0xb500249e, 0x9c5d2de3), + TOBN(0x8912b820, 0xf13ca8c9), TOBN(0xc8798114, 0x877793af)}}, + {{TOBN(0x19e6125d, 0xec3f1dec), TOBN(0x07b1f040, 0x911178da), + TOBN(0xd93ededa, 0x904a6738), TOBN(0x55187a5a, 0x0bebedcd)}, + {TOBN(0xf7d04722, 0xeb329d41), TOBN(0xf449099e, 0xf170b391), + TOBN(0xfd317a69, 0xca99f828), TOBN(0x50c3db2b, 0x34a4976d)}}, + {{TOBN(0xe9ba7784, 0x3757b392), TOBN(0x326caefd, 0xaa3ca05a), + TOBN(0x78e5293b, 0xf1e593d4), TOBN(0x7842a937, 0x0d98fd13)}, + {TOBN(0xe694bf96, 0x5f96b10d), TOBN(0x373a9df6, 0x06a8cd05), + TOBN(0x997d1e51, 0xe8f0c7fc), TOBN(0x1d019790, 0x63fd972e)}}, + {{TOBN(0x0064d858, 0x5499fb32), TOBN(0x7b67bad9, 0x77a8aeb7), + TOBN(0x1d3eb977, 0x2d08eec5), TOBN(0x5fc047a6, 0xcbabae1d)}, + {TOBN(0x0577d159, 0xe54a64bb), TOBN(0x8862201b, 0xc43497e4), + TOBN(0xad6b4e28, 0x2ce0608d), TOBN(0x8b687b7d, 0x0b167aac)}}, + {{TOBN(0x6ed4d367, 0x8b2ecfa9), TOBN(0x24dfe62d, 0xa90c3c38), + TOBN(0xa1862e10, 0x3fe5c42b), TOBN(0x1ca73dca, 0xd5732a9f)}, + {TOBN(0x35f038b7, 0x76bb87ad), TOBN(0x674976ab, 0xf242b81f), + TOBN(0x4f2bde7e, 0xb0fd90cd), TOBN(0x6efc172e, 0xa7fdf092)}}, + {{TOBN(0x3806b69b, 0x92222f1f), TOBN(0x5a2459ca, 0x6cf7ae70), + TOBN(0x6789f69c, 0xa85217ee), TOBN(0x5f232b5e, 0xe3dc85ac)}, + {TOBN(0x660e3ec5, 0x48e9e516), TOBN(0x124b4e47, 0x3197eb31), + TOBN(0x10a0cb13, 0xaafcca23), TOBN(0x7bd63ba4, 0x8213224f)}}, + {{TOBN(0xaffad7cc, 0x290a7f4f), TOBN(0x6b409c9e, 0x0286b461), + TOBN(0x58ab809f, 0xffa407af), TOBN(0xc3122eed, 0xc68ac073)}, + {TOBN(0x17bf9e50, 0x4ef24d7e), TOBN(0x5d929794, 0x3e2a5811), + TOBN(0x519bc867, 0x02902e01), TOBN(0x76bba5da, 0x39c8a851)}}, + {{TOBN(0xe9f9669c, 0xda94951e), TOBN(0x4b6af58d, 0x66b8d418), + TOBN(0xfa321074, 0x17d426a4), TOBN(0xc78e66a9, 0x9dde6027)}, + {TOBN(0x0516c083, 0x4a53b964), TOBN(0xfc659d38, 0xff602330), + TOBN(0x0ab55e5c, 0x58c5c897), TOBN(0x985099b2, 0x838bc5df)}}, + {{TOBN(0x061d9efc, 0xc52fc238), TOBN(0x712b2728, 0x6ac1da3f), + TOBN(0xfb658149, 0x9283fe08), TOBN(0x4954ac94, 0xb8aaa2f7)}, + {TOBN(0x85c0ada4, 0x7fb2e74f), TOBN(0xee8ba98e, 0xb89926b0), + TOBN(0xe4f9d37d, 0x23d1af5b), TOBN(0x14ccdbf9, 0xba9b015e)}}, + {{TOBN(0xb674481b, 0x7bfe7178), TOBN(0x4e1debae, 0x65405868), + TOBN(0x061b2821, 0xc48c867d), TOBN(0x69c15b35, 0x513b30ea)}, + {TOBN(0x3b4a1666, 0x36871088), TOBN(0xe5e29f5d, 0x1220b1ff), + TOBN(0x4b82bb35, 0x233d9f4d), TOBN(0x4e076333, 0x18cdc675)}}}, + {{{TOBN(0x0d53f5c7, 0xa3e6fced), TOBN(0xe8cbbdd5, 0xf45fbdeb), + TOBN(0xf85c01df, 0x13339a70), TOBN(0x0ff71880, 0x142ceb81)}, + {TOBN(0x4c4e8774, 0xbd70437a), TOBN(0x5fb32891, 0xba0bda6a), + TOBN(0x1cdbebd2, 0xf18bd26e), TOBN(0x2f9526f1, 0x03a9d522)}}, + {{TOBN(0x40ce3051, 0x92c4d684), TOBN(0x8b04d725, 0x7612efcd), + TOBN(0xb9dcda36, 0x6f9cae20), TOBN(0x0edc4d24, 0xf058856c)}, + {TOBN(0x64f2e6bf, 0x85427900), TOBN(0x3de81295, 0xdc09dfea), + TOBN(0xd41b4487, 0x379bf26c), TOBN(0x50b62c6d, 0x6df135a9)}}, + {{TOBN(0xd4f8e3b4, 0xc72dfe67), TOBN(0xc416b0f6, 0x90e19fdf), + TOBN(0x18b9098d, 0x4c13bd35), TOBN(0xac11118a, 0x15b8cb9e)}, + {TOBN(0xf598a318, 0xf0062841), TOBN(0xbfe0602f, 0x89f356f4), + TOBN(0x7ae3637e, 0x30177a0c), TOBN(0x34097747, 0x61136537)}}, + {{TOBN(0x0db2fb5e, 0xd005832a), TOBN(0x5f5efd3b, 0x91042e4f), + TOBN(0x8c4ffdc6, 0xed70f8ca), TOBN(0xe4645d0b, 0xb52da9cc)}, + {TOBN(0x9596f58b, 0xc9001d1f), TOBN(0x52c8f0bc, 0x4e117205), + TOBN(0xfd4aa0d2, 0xe398a084), TOBN(0x815bfe3a, 0x104f49de)}}, + {{TOBN(0x97e5443f, 0x23885e5f), TOBN(0xf72f8f99, 0xe8433aab), + TOBN(0xbd00b154, 0xe4d4e604), TOBN(0xd0b35e6a, 0xe5e173ff)}, + {TOBN(0x57b2a048, 0x9164722d), TOBN(0x3e3c665b, 0x88761ec8), + TOBN(0x6bdd1397, 0x3da83832), TOBN(0x3c8b1a1e, 0x73dafe3b)}}, + {{TOBN(0x4497ace6, 0x54317cac), TOBN(0xbe600ab9, 0x521771b3), + TOBN(0xb42e409e, 0xb0dfe8b8), TOBN(0x386a67d7, 0x3942310f)}, + {TOBN(0x25548d8d, 0x4431cc28), TOBN(0xa7cff142, 0x985dc524), + TOBN(0x4d60f5a1, 0x93c4be32), TOBN(0x83ebd5c8, 0xd071c6e1)}}, + {{TOBN(0xba3a80a7, 0xb1fd2b0b), TOBN(0x9b3ad396, 0x5bec33e8), + TOBN(0xb3868d61, 0x79743fb3), TOBN(0xcfd169fc, 0xfdb462fa)}, + {TOBN(0xd3b499d7, 0x9ce0a6af), TOBN(0x55dc1cf1, 0xe42d3ff8), + TOBN(0x04fb9e6c, 0xc6c3e1b2), TOBN(0x47e6961d, 0x6f69a474)}}, + {{TOBN(0x54eb3acc, 0xe548b37b), TOBN(0xb38e7542, 0x84d40549), + TOBN(0x8c3daa51, 0x7b341b4f), TOBN(0x2f6928ec, 0x690bf7fa)}, + {TOBN(0x0496b323, 0x86ce6c41), TOBN(0x01be1c55, 0x10adadcd), + TOBN(0xc04e67e7, 0x4bb5faf9), TOBN(0x3cbaf678, 0xe15c9985)}}, + {{TOBN(0x8cd12145, 0x50ca4247), TOBN(0xba1aa47a, 0xe7dd30aa), + TOBN(0x2f81ddf1, 0xe58fee24), TOBN(0x03452936, 0xeec9b0e8)}, + {TOBN(0x8bdc3b81, 0x243aea96), TOBN(0x9a2919af, 0x15c3d0e5), + TOBN(0x9ea640ec, 0x10948361), TOBN(0x5ac86d5b, 0x6e0bcccf)}}, + {{TOBN(0xf892d918, 0xc36cf440), TOBN(0xaed3e837, 0xc939719c), + TOBN(0xb07b08d2, 0xc0218b64), TOBN(0x6f1bcbba, 0xce9790dd)}, + {TOBN(0x4a84d6ed, 0x60919b8e), TOBN(0xd8900791, 0x8ac1f9eb), + TOBN(0xf84941aa, 0x0dd5daef), TOBN(0xb22fe40a, 0x67fd62c5)}}, + {{TOBN(0x97e15ba2, 0x157f2db3), TOBN(0xbda2fc8f, 0x8e28ca9c), + TOBN(0x5d050da4, 0x37b9f454), TOBN(0x3d57eb57, 0x2379d72e)}, + {TOBN(0xe9b5eba2, 0xfb5ee997), TOBN(0x01648ca2, 0xe11538ca), + TOBN(0x32bb76f6, 0xf6327974), TOBN(0x338f14b8, 0xff3f4bb7)}}, + {{TOBN(0x524d226a, 0xd7ab9a2d), TOBN(0x9c00090d, 0x7dfae958), + TOBN(0x0ba5f539, 0x8751d8c2), TOBN(0x8afcbcdd, 0x3ab8262d)}, + {TOBN(0x57392729, 0xe99d043b), TOBN(0xef51263b, 0xaebc943a), + TOBN(0x9feace93, 0x20862935), TOBN(0x639efc03, 0xb06c817b)}}, + {{TOBN(0x1fe054b3, 0x66b4be7a), TOBN(0x3f25a9de, 0x84a37a1e), + TOBN(0xf39ef1ad, 0x78d75cd9), TOBN(0xd7b58f49, 0x5062c1b5)}, + {TOBN(0x6f74f9a9, 0xff563436), TOBN(0xf718ff29, 0xe8af51e7), + TOBN(0x5234d313, 0x15e97fec), TOBN(0xb6a8e2b1, 0x292f1c0a)}}, + {{TOBN(0xa7f53aa8, 0x327720c1), TOBN(0x956ca322, 0xba092cc8), + TOBN(0x8f03d64a, 0x28746c4d), TOBN(0x51fe1782, 0x66d0d392)}, + {TOBN(0xd19b34db, 0x3c832c80), TOBN(0x60dccc5c, 0x6da2e3b4), + TOBN(0x245dd62e, 0x0a104ccc), TOBN(0xa7ab1de1, 0x620b21fd)}}, + {{TOBN(0xb293ae0b, 0x3893d123), TOBN(0xf7b75783, 0xb15ee71c), + TOBN(0x5aa3c614, 0x42a9468b), TOBN(0xd686123c, 0xdb15d744)}, + {TOBN(0x8c616891, 0xa7ab4116), TOBN(0x6fcd72c8, 0xa4e6a459), + TOBN(0xac219110, 0x77e5fad7), TOBN(0xfb6a20e7, 0x704fa46b)}}, + {{TOBN(0xe839be7d, 0x341d81dc), TOBN(0xcddb6889, 0x32148379), + TOBN(0xda6211a1, 0xf7026ead), TOBN(0xf3b2575f, 0xf4d1cc5e)}, + {TOBN(0x40cfc8f6, 0xa7a73ae6), TOBN(0x83879a5e, 0x61d5b483), + TOBN(0xc5acb1ed, 0x41a50ebc), TOBN(0x59a60cc8, 0x3c07d8fa)}}, + {{TOBN(0x1b73bdce, 0xb1876262), TOBN(0x2b0d79f0, 0x12af4ee9), + TOBN(0x8bcf3b0b, 0xd46e1d07), TOBN(0x17d6af9d, 0xe45d152f)}, + {TOBN(0x73520461, 0x6d736451), TOBN(0x43cbbd97, 0x56b0bf5a), + TOBN(0xb0833a5b, 0xd5999b9d), TOBN(0x702614f0, 0xeb72e398)}}, + {{TOBN(0x0aadf01a, 0x59c3e9f8), TOBN(0x40200e77, 0xce6b3d16), + TOBN(0xda22bdd3, 0xdeddafad), TOBN(0x76dedaf4, 0x310d72e1)}, + {TOBN(0x49ef807c, 0x4bc2e88f), TOBN(0x6ba81291, 0x146dd5a5), + TOBN(0xa1a4077a, 0x7d8d59e9), TOBN(0x87b6a2e7, 0x802db349)}}, + {{TOBN(0xd5679997, 0x1b4e598e), TOBN(0xf499ef1f, 0x06fe4b1d), + TOBN(0x3978d3ae, 0xfcb267c5), TOBN(0xb582b557, 0x235786d0)}, + {TOBN(0x32b3b2ca, 0x1715cb07), TOBN(0x4c3de6a2, 0x8480241d), + TOBN(0x63b5ffed, 0xcb571ecd), TOBN(0xeaf53900, 0xed2fe9a9)}}, + {{TOBN(0xdec98d4a, 0xc3b81990), TOBN(0x1cb83722, 0x9e0cc8fe), + TOBN(0xfe0b0491, 0xd2b427b9), TOBN(0x0f2386ac, 0xe983a66c)}, + {TOBN(0x930c4d1e, 0xb3291213), TOBN(0xa2f82b2e, 0x59a62ae4), + TOBN(0x77233853, 0xf93e89e3), TOBN(0x7f8063ac, 0x11777c7f)}}, + {{TOBN(0xff0eb567, 0x59ad2877), TOBN(0x6f454642, 0x9865c754), + TOBN(0xe6fe701a, 0x236e9a84), TOBN(0xc586ef16, 0x06e40fc3)}, + {TOBN(0x3f62b6e0, 0x24bafad9), TOBN(0xc8b42bd2, 0x64da906a), + TOBN(0xc98e1eb4, 0xda3276a0), TOBN(0x30d0e5fc, 0x06cbf852)}}, + {{TOBN(0x1b6b2ae1, 0xe8b4dfd4), TOBN(0xd754d5c7, 0x8301cbac), + TOBN(0x66097629, 0x112a39ac), TOBN(0xf86b5999, 0x93ba4ab9)}, + {TOBN(0x26c9dea7, 0x99f9d581), TOBN(0x0473b1a8, 0xc2fafeaa), + TOBN(0x1469af55, 0x3b2505a5), TOBN(0x227d16d7, 0xd6a43323)}}, + {{TOBN(0x3316f73c, 0xad3d97f9), TOBN(0x52bf3bb5, 0x1f137455), + TOBN(0x953eafeb, 0x09954e7c), TOBN(0xa721dfed, 0xdd732411)}, + {TOBN(0xb4929821, 0x141d4579), TOBN(0x3411321c, 0xaa3bd435), + TOBN(0xafb355aa, 0x17fa6015), TOBN(0xb4e7ef4a, 0x18e42f0e)}}, + {{TOBN(0x604ac97c, 0x59371000), TOBN(0xe1c48c70, 0x7f759c18), + TOBN(0x3f62ecc5, 0xa5db6b65), TOBN(0x0a78b173, 0x38a21495)}, + {TOBN(0x6be1819d, 0xbcc8ad94), TOBN(0x70dc04f6, 0xd89c3400), + TOBN(0x462557b4, 0xa6b4840a), TOBN(0x544c6ade, 0x60bd21c0)}}, + {{TOBN(0x6a00f24e, 0x907a544b), TOBN(0xa7520dcb, 0x313da210), + TOBN(0xfe939b75, 0x11e4994b), TOBN(0x918b6ba6, 0xbc275d70)}, + {TOBN(0xd3e5e0fc, 0x644be892), TOBN(0x707a9816, 0xfdaf6c42), + TOBN(0x60145567, 0xf15c13fe), TOBN(0x4818ebaa, 0xe130a54a)}}, + {{TOBN(0x28aad3ad, 0x58d2f767), TOBN(0xdc5267fd, 0xd7e7c773), + TOBN(0x4919cc88, 0xc3afcc98), TOBN(0xaa2e6ab0, 0x2db8cd4b)}, + {TOBN(0xd46fec04, 0xd0c63eaa), TOBN(0xa1cb92c5, 0x19ffa832), + TOBN(0x678dd178, 0xe43a631f), TOBN(0xfb5ae1cd, 0x3dc788b3)}}, + {{TOBN(0x68b4fb90, 0x6e77de04), TOBN(0x7992bcf0, 0xf06dbb97), + TOBN(0x896e6a13, 0xc417c01d), TOBN(0x8d96332c, 0xb956be01)}, + {TOBN(0x902fc93a, 0x413aa2b9), TOBN(0x99a4d915, 0xfc98c8a5), + TOBN(0x52c29407, 0x565f1137), TOBN(0x4072690f, 0x21e4f281)}}, + {{TOBN(0x36e607cf, 0x02ff6072), TOBN(0xa47d2ca9, 0x8ad98cdc), + TOBN(0xbf471d1e, 0xf5f56609), TOBN(0xbcf86623, 0xf264ada0)}, + {TOBN(0xb70c0687, 0xaa9e5cb6), TOBN(0xc98124f2, 0x17401c6c), + TOBN(0x8189635f, 0xd4a61435), TOBN(0xd28fb8af, 0xa9d98ea6)}}, + {{TOBN(0xb9a67c2a, 0x40c251f8), TOBN(0x88cd5d87, 0xa2da44be), + TOBN(0x437deb96, 0xe09b5423), TOBN(0x150467db, 0x64287dc1)}, + {TOBN(0xe161debb, 0xcdabb839), TOBN(0xa79e9742, 0xf1839a3e), + TOBN(0xbb8dd3c2, 0x652d202b), TOBN(0x7b3e67f7, 0xe9f97d96)}}, + {{TOBN(0x5aa5d78f, 0xb1cb6ac9), TOBN(0xffa13e8e, 0xca1d0d45), + TOBN(0x369295dd, 0x2ba5bf95), TOBN(0xd68bd1f8, 0x39aff05e)}, + {TOBN(0xaf0d86f9, 0x26d783f2), TOBN(0x543a59b3, 0xfc3aafc1), + TOBN(0x3fcf81d2, 0x7b7da97c), TOBN(0xc990a056, 0xd25dee46)}}, + {{TOBN(0x3e6775b8, 0x519cce2c), TOBN(0xfc9af71f, 0xae13d863), + TOBN(0x774a4a6f, 0x47c1605c), TOBN(0x46ba4245, 0x2fd205e8)}, + {TOBN(0xa06feea4, 0xd3fd524d), TOBN(0x1e724641, 0x6de1acc2), + TOBN(0xf53816f1, 0x334e2b42), TOBN(0x49e5918e, 0x922f0024)}}, + {{TOBN(0x439530b6, 0x65c7322d), TOBN(0xcf12cc01, 0xb3c1b3fb), + TOBN(0xc70b0186, 0x0172f685), TOBN(0xb915ee22, 0x1b58391d)}, + {TOBN(0x9afdf03b, 0xa317db24), TOBN(0x87dec659, 0x17b8ffc4), + TOBN(0x7f46597b, 0xe4d3d050), TOBN(0x80a1c1ed, 0x006500e7)}}, + {{TOBN(0x84902a96, 0x78bf030e), TOBN(0xfb5e9c9a, 0x50560148), + TOBN(0x6dae0a92, 0x63362426), TOBN(0xdcaeecf4, 0xa9e30c40)}, + {TOBN(0xc0d887bb, 0x518d0c6b), TOBN(0x99181152, 0xcb985b9d), + TOBN(0xad186898, 0xef7bc381), TOBN(0x18168ffb, 0x9ee46201)}}, + {{TOBN(0x9a04cdaa, 0x2502753c), TOBN(0xbb279e26, 0x51407c41), + TOBN(0xeacb03aa, 0xf23564e5), TOBN(0x18336582, 0x71e61016)}, + {TOBN(0x8684b8c4, 0xeb809877), TOBN(0xb336e18d, 0xea0e672e), + TOBN(0xefb601f0, 0x34ee5867), TOBN(0x2733edbe, 0x1341cfd1)}}, + {{TOBN(0xb15e809a, 0x26025c3c), TOBN(0xe6e981a6, 0x9350df88), + TOBN(0x92376237, 0x8502fd8e), TOBN(0x4791f216, 0x0c12be9b)}, + {TOBN(0xb7256789, 0x25f02425), TOBN(0xec863194, 0x7a974443), + TOBN(0x7c0ce882, 0xfb41cc52), TOBN(0xc266ff7e, 0xf25c07f2)}}, + {{TOBN(0x3d4da8c3, 0x017025f3), TOBN(0xefcf628c, 0xfb9579b4), + TOBN(0x5c4d0016, 0x1f3716ec), TOBN(0x9c27ebc4, 0x6801116e)}, + {TOBN(0x5eba0ea1, 0x1da1767e), TOBN(0xfe151452, 0x47004c57), + TOBN(0x3ace6df6, 0x8c2373b7), TOBN(0x75c3dffe, 0x5dbc37ac)}}, + {{TOBN(0x3dc32a73, 0xddc925fc), TOBN(0xb679c841, 0x2f65ee0b), + TOBN(0x715a3295, 0x451cbfeb), TOBN(0xd9889768, 0xf76e9a29)}, + {TOBN(0xec20ce7f, 0xb28ad247), TOBN(0xe99146c4, 0x00894d79), + TOBN(0x71457d7c, 0x9f5e3ea7), TOBN(0x097b2662, 0x38030031)}}, + {{TOBN(0xdb7f6ae6, 0xcf9f82a8), TOBN(0x319decb9, 0x438f473a), + TOBN(0xa63ab386, 0x283856c3), TOBN(0x13e3172f, 0xb06a361b)}, + {TOBN(0x2959f8dc, 0x7d5a006c), TOBN(0x2dbc27c6, 0x75fba752), + TOBN(0xc1227ab2, 0x87c22c9e), TOBN(0x06f61f75, 0x71a268b2)}}, + {{TOBN(0x1b6bb971, 0x04779ce2), TOBN(0xaca83812, 0x0aadcb1d), + TOBN(0x297ae0bc, 0xaeaab2d5), TOBN(0xa5c14ee7, 0x5bfb9f13)}, + {TOBN(0xaa00c583, 0xf17a62c7), TOBN(0x39eb962c, 0x173759f6), + TOBN(0x1eeba1d4, 0x86c9a88f), TOBN(0x0ab6c37a, 0xdf016c5e)}}, + {{TOBN(0xa2a147db, 0xa28a0749), TOBN(0x246c20d6, 0xee519165), + TOBN(0x5068d1b1, 0xd3810715), TOBN(0xb1e7018c, 0x748160b9)}, + {TOBN(0x03f5b1fa, 0xf380ff62), TOBN(0xef7fb1dd, 0xf3cb2c1e), + TOBN(0xeab539a8, 0xfc91a7da), TOBN(0x83ddb707, 0xf3f9b561)}}, + {{TOBN(0xc550e211, 0xfe7df7a4), TOBN(0xa7cd07f2, 0x063f6f40), + TOBN(0xb0de3635, 0x2976879c), TOBN(0xb5f83f85, 0xe55741da)}, + {TOBN(0x4ea9d25e, 0xf3d8ac3d), TOBN(0x6fe2066f, 0x62819f02), + TOBN(0x4ab2b9c2, 0xcef4a564), TOBN(0x1e155d96, 0x5ffa2de3)}}, + {{TOBN(0x0eb0a19b, 0xc3a72d00), TOBN(0x4037665b, 0x8513c31b), + TOBN(0x2fb2b6bf, 0x04c64637), TOBN(0x45c34d6e, 0x08cdc639)}, + {TOBN(0x56f1e10f, 0xf01fd796), TOBN(0x4dfb8101, 0xfe3667b8), + TOBN(0xe0eda253, 0x9021d0c0), TOBN(0x7a94e9ff, 0x8a06c6ab)}}, + {{TOBN(0x2d3bb0d9, 0xbb9aa882), TOBN(0xea20e4e5, 0xec05fd10), + TOBN(0xed7eeb5f, 0x1a1ca64e), TOBN(0x2fa6b43c, 0xc6327cbd)}, + {TOBN(0xb577e3cf, 0x3aa91121), TOBN(0x8c6bd5ea, 0x3a34079b), + TOBN(0xd7e5ba39, 0x60e02fc0), TOBN(0xf16dd2c3, 0x90141bf8)}}, + {{TOBN(0xb57276d9, 0x80101b98), TOBN(0x760883fd, 0xb82f0f66), + TOBN(0x89d7de75, 0x4bc3eff3), TOBN(0x03b60643, 0x5dc2ab40)}, + {TOBN(0xcd6e53df, 0xe05beeac), TOBN(0xf2f1e862, 0xbc3325cd), + TOBN(0xdd0f7921, 0x774f03c3), TOBN(0x97ca7221, 0x4552cc1b)}}, + {{TOBN(0x5a0d6afe, 0x1cd19f72), TOBN(0xa20915dc, 0xf183fbeb), + TOBN(0x9fda4b40, 0x832c403c), TOBN(0x32738edd, 0xbe425442)}, + {TOBN(0x469a1df6, 0xb5eccf1a), TOBN(0x4b5aff42, 0x28bbe1f0), + TOBN(0x31359d7f, 0x570dfc93), TOBN(0xa18be235, 0xf0088628)}}, + {{TOBN(0xa5b30fba, 0xb00ed3a9), TOBN(0x34c61374, 0x73cdf8be), + TOBN(0x2c5c5f46, 0xabc56797), TOBN(0x5cecf93d, 0xb82a8ae2)}, + {TOBN(0x7d3dbe41, 0xa968fbf0), TOBN(0xd23d4583, 0x1a5c7f3d), + TOBN(0xf28f69a0, 0xc087a9c7), TOBN(0xc2d75471, 0x474471ca)}}, + {{TOBN(0x36ec9f4a, 0x4eb732ec), TOBN(0x6c943bbd, 0xb1ca6bed), + TOBN(0xd64535e1, 0xf2457892), TOBN(0x8b84a8ea, 0xf7e2ac06)}, + {TOBN(0xe0936cd3, 0x2499dd5f), TOBN(0x12053d7e, 0x0ed04e57), + TOBN(0x4bdd0076, 0xe4305d9d), TOBN(0x34a527b9, 0x1f67f0a2)}}, + {{TOBN(0xe79a4af0, 0x9cec46ea), TOBN(0xb15347a1, 0x658b9bc7), + TOBN(0x6bd2796f, 0x35af2f75), TOBN(0xac957990, 0x4051c435)}, + {TOBN(0x2669dda3, 0xc33a655d), TOBN(0x5d503c2e, 0x88514aa3), + TOBN(0xdfa11337, 0x3753dd41), TOBN(0x3f054673, 0x0b754f78)}}, + {{TOBN(0xbf185677, 0x496125bd), TOBN(0xfb0023c8, 0x3775006c), + TOBN(0xfa0f072f, 0x3a037899), TOBN(0x4222b6eb, 0x0e4aea57)}, + {TOBN(0x3dde5e76, 0x7866d25a), TOBN(0xb6eb04f8, 0x4837aa6f), + TOBN(0x5315591a, 0x2cf1cdb8), TOBN(0x6dfb4f41, 0x2d4e683c)}}, + {{TOBN(0x7e923ea4, 0x48ee1f3a), TOBN(0x9604d9f7, 0x05a2afd5), + TOBN(0xbe1d4a33, 0x40ea4948), TOBN(0x5b45f1f4, 0xb44cbd2f)}, + {TOBN(0x5faf8376, 0x4acc757e), TOBN(0xa7cf9ab8, 0x63d68ff7), + TOBN(0x8ad62f69, 0xdf0e404b), TOBN(0xd65f33c2, 0x12bdafdf)}}, + {{TOBN(0xc365de15, 0xa377b14e), TOBN(0x6bf5463b, 0x8e39f60c), + TOBN(0x62030d2d, 0x2ce68148), TOBN(0xd95867ef, 0xe6f843a8)}, + {TOBN(0xd39a0244, 0xef5ab017), TOBN(0x0bd2d8c1, 0x4ab55d12), + TOBN(0xc9503db3, 0x41639169), TOBN(0x2d4e25b0, 0xf7660c8a)}}, + {{TOBN(0x760cb3b5, 0xe224c5d7), TOBN(0xfa3baf8c, 0x68616919), + TOBN(0x9fbca113, 0x8d142552), TOBN(0x1ab18bf1, 0x7669ebf5)}, + {TOBN(0x55e6f53e, 0x9bdf25dd), TOBN(0x04cc0bf3, 0xcb6cd154), + TOBN(0x595bef49, 0x95e89080), TOBN(0xfe9459a8, 0x104a9ac1)}}, + {{TOBN(0xad2d89ca, 0xcce9bb32), TOBN(0xddea65e1, 0xf7de8285), + TOBN(0x62ed8c35, 0xb351bd4b), TOBN(0x4150ff36, 0x0c0e19a7)}, + {TOBN(0x86e3c801, 0x345f4e47), TOBN(0x3bf21f71, 0x203a266c), + TOBN(0x7ae110d4, 0x855b1f13), TOBN(0x5d6aaf6a, 0x07262517)}}, + {{TOBN(0x1e0f12e1, 0x813d28f1), TOBN(0x6000e11d, 0x7ad7a523), + TOBN(0xc7d8deef, 0xc744a17b), TOBN(0x1e990b48, 0x14c05a00)}, + {TOBN(0x68fddaee, 0x93e976d5), TOBN(0x696241d1, 0x46610d63), + TOBN(0xb204e7c3, 0x893dda88), TOBN(0x8bccfa65, 0x6a3a6946)}}, + {{TOBN(0xb59425b4, 0xc5cd1411), TOBN(0x701b4042, 0xff3658b1), + TOBN(0xe3e56bca, 0x4784cf93), TOBN(0x27de5f15, 0x8fe68d60)}, + {TOBN(0x4ab9cfce, 0xf8d53f19), TOBN(0xddb10311, 0xa40a730d), + TOBN(0x6fa73cd1, 0x4eee0a8a), TOBN(0xfd548748, 0x5249719d)}}, + {{TOBN(0x49d66316, 0xa8123ef0), TOBN(0x73c32db4, 0xe7f95438), + TOBN(0x2e2ed209, 0x0d9e7854), TOBN(0xf98a9329, 0x9d9f0507)}, + {TOBN(0xc5d33cf6, 0x0c6aa20a), TOBN(0x9a32ba14, 0x75279bb2), + TOBN(0x7e3202cb, 0x774a7307), TOBN(0x64ed4bc4, 0xe8c42dbd)}}, + {{TOBN(0xc20f1a06, 0xd4caed0d), TOBN(0xb8021407, 0x171d22b3), + TOBN(0xd426ca04, 0xd13268d7), TOBN(0x92377007, 0x25f4d126)}, + {TOBN(0x4204cbc3, 0x71f21a85), TOBN(0x18461b7a, 0xf82369ba), + TOBN(0xc0c07d31, 0x3fc858f9), TOBN(0x5deb5a50, 0xe2bab569)}}, + {{TOBN(0xd5959d46, 0xd5eea89e), TOBN(0xfdff8424, 0x08437f4b), + TOBN(0xf21071e4, 0x3cfe254f), TOBN(0x72417696, 0x95468321)}, + {TOBN(0x5d8288b9, 0x102cae3e), TOBN(0x2d143e3d, 0xf1965dff), + TOBN(0x00c9a376, 0xa078d847), TOBN(0x6fc0da31, 0x26028731)}}, + {{TOBN(0xa2baeadf, 0xe45083a2), TOBN(0x66bc7218, 0x5e5b4bcd), + TOBN(0x2c826442, 0xd04b8e7f), TOBN(0xc19f5451, 0x6c4b586b)}, + {TOBN(0x60182c49, 0x5b7eeed5), TOBN(0xd9954ecd, 0x7aa9dfa1), + TOBN(0xa403a8ec, 0xc73884ad), TOBN(0x7fb17de2, 0x9bb39041)}}, + {{TOBN(0x694b64c5, 0xabb020e8), TOBN(0x3d18c184, 0x19c4eec7), + TOBN(0x9c4673ef, 0x1c4793e5), TOBN(0xc7b8aeb5, 0x056092e6)}, + {TOBN(0x3aa1ca43, 0xf0f8c16b), TOBN(0x224ed5ec, 0xd679b2f6), + TOBN(0x0d56eeaf, 0x55a205c9), TOBN(0xbfe115ba, 0x4b8e028b)}}, + {{TOBN(0x97e60849, 0x3927f4fe), TOBN(0xf91fbf94, 0x759aa7c5), + TOBN(0x985af769, 0x6be90a51), TOBN(0xc1277b78, 0x78ccb823)}, + {TOBN(0x395b656e, 0xe7a75952), TOBN(0x00df7de0, 0x928da5f5), + TOBN(0x09c23175, 0x4ca4454f), TOBN(0x4ec971f4, 0x7aa2d3c1)}}, + {{TOBN(0x45c3c507, 0xe75d9ccc), TOBN(0x63b7be8a, 0x3dc90306), + TOBN(0x37e09c66, 0x5db44bdc), TOBN(0x50d60da1, 0x6841c6a2)}, + {TOBN(0x6f9b65ee, 0x08df1b12), TOBN(0x38734879, 0x7ff089df), + TOBN(0x9c331a66, 0x3fe8013d), TOBN(0x017f5de9, 0x5f42fcc8)}}, + {{TOBN(0x43077866, 0xe8e57567), TOBN(0xc9f781ce, 0xf9fcdb18), + TOBN(0x38131dda, 0x9b12e174), TOBN(0x25d84aa3, 0x8a03752a)}, + {TOBN(0x45e09e09, 0x4d0c0ce2), TOBN(0x1564008b, 0x92bebba5), + TOBN(0xf7e8ad31, 0xa87284c7), TOBN(0xb7c4b46c, 0x97e7bbaa)}}, + {{TOBN(0x3e22a7b3, 0x97acf4ec), TOBN(0x0426c400, 0x5ea8b640), + TOBN(0x5e3295a6, 0x4e969285), TOBN(0x22aabc59, 0xa6a45670)}, + {TOBN(0xb929714c, 0x5f5942bc), TOBN(0x9a6168bd, 0xfa3182ed), + TOBN(0x2216a665, 0x104152ba), TOBN(0x46908d03, 0xb6926368)}}}, + {{{TOBN(0xa9f5d874, 0x5a1251fb), TOBN(0x967747a8, 0xc72725c7), + TOBN(0x195c33e5, 0x31ffe89e), TOBN(0x609d210f, 0xe964935e)}, + {TOBN(0xcafd6ca8, 0x2fe12227), TOBN(0xaf9b5b96, 0x0426469d), + TOBN(0x2e9ee04c, 0x5693183c), TOBN(0x1084a333, 0xc8146fef)}}, + {{TOBN(0x96649933, 0xaed1d1f7), TOBN(0x566eaff3, 0x50563090), + TOBN(0x345057f0, 0xad2e39cf), TOBN(0x148ff65b, 0x1f832124)}, + {TOBN(0x042e89d4, 0xcf94cf0d), TOBN(0x319bec84, 0x520c58b3), + TOBN(0x2a267626, 0x5361aa0d), TOBN(0xc86fa302, 0x8fbc87ad)}}, + {{TOBN(0xfc83d2ab, 0x5c8b06d5), TOBN(0xb1a785a2, 0xfe4eac46), + TOBN(0xb99315bc, 0x846f7779), TOBN(0xcf31d816, 0xef9ea505)}, + {TOBN(0x2391fe6a, 0x15d7dc85), TOBN(0x2f132b04, 0xb4016b33), + TOBN(0x29547fe3, 0x181cb4c7), TOBN(0xdb66d8a6, 0x650155a1)}}, + {{TOBN(0x6b66d7e1, 0xadc1696f), TOBN(0x98ebe593, 0x0acd72d0), + TOBN(0x65f24550, 0xcc1b7435), TOBN(0xce231393, 0xb4b9a5ec)}, + {TOBN(0x234a22d4, 0xdb067df9), TOBN(0x98dda095, 0xcaff9b00), + TOBN(0x1bbc75a0, 0x6100c9c1), TOBN(0x1560a9c8, 0x939cf695)}}, + {{TOBN(0xcf006d3e, 0x99e0925f), TOBN(0x2dd74a96, 0x6322375a), + TOBN(0xc58b446a, 0xb56af5ba), TOBN(0x50292683, 0xe0b9b4f1)}, + {TOBN(0xe2c34cb4, 0x1aeaffa3), TOBN(0x8b17203f, 0x9b9587c1), + TOBN(0x6d559207, 0xead1350c), TOBN(0x2b66a215, 0xfb7f9604)}}, + {{TOBN(0x0850325e, 0xfe51bf74), TOBN(0x9c4f579e, 0x5e460094), + TOBN(0x5c87b92a, 0x76da2f25), TOBN(0x889de4e0, 0x6febef33)}, + {TOBN(0x6900ec06, 0x646083ce), TOBN(0xbe2a0335, 0xbfe12773), + TOBN(0xadd1da35, 0xc5344110), TOBN(0x757568b7, 0xb802cd20)}}, + {{TOBN(0x75559779, 0x00f7e6c8), TOBN(0x38e8b94f, 0x0facd2f0), + TOBN(0xfea1f3af, 0x03fde375), TOBN(0x5e11a1d8, 0x75881dfc)}, + {TOBN(0xb3a6b02e, 0xc1e2f2ef), TOBN(0x193d2bbb, 0xc605a6c5), + TOBN(0x325ffeee, 0x339a0b2d), TOBN(0x27b6a724, 0x9e0c8846)}}, + {{TOBN(0xe4050f1c, 0xf1c367ca), TOBN(0x9bc85a9b, 0xc90fbc7d), + TOBN(0xa373c4a2, 0xe1a11032), TOBN(0xb64232b7, 0xad0393a9)}, + {TOBN(0xf5577eb0, 0x167dad29), TOBN(0x1604f301, 0x94b78ab2), + TOBN(0x0baa94af, 0xe829348b), TOBN(0x77fbd8dd, 0x41654342)}}, + {{TOBN(0xdab50ea5, 0xb964e39a), TOBN(0xd4c29e3c, 0xd0d3c76e), + TOBN(0x80dae67c, 0x56d11964), TOBN(0x7307a8bf, 0xe5ffcc2f)}, + {TOBN(0x65bbc1aa, 0x91708c3b), TOBN(0xa151e62c, 0x28bf0eeb), + TOBN(0x6cb53381, 0x6fa34db7), TOBN(0x5139e05c, 0xa29403a8)}}, + {{TOBN(0x6ff651b4, 0x94a7cd2e), TOBN(0x5671ffd1, 0x0699336c), + TOBN(0x6f5fd2cc, 0x979a896a), TOBN(0x11e893a8, 0xd8148cef)}, + {TOBN(0x988906a1, 0x65cf7b10), TOBN(0x81b67178, 0xc50d8485), + TOBN(0x7c0deb35, 0x8a35b3de), TOBN(0x423ac855, 0xc1d29799)}}, + {{TOBN(0xaf580d87, 0xdac50b74), TOBN(0x28b2b89f, 0x5869734c), + TOBN(0x99a3b936, 0x874e28fb), TOBN(0xbb2c9190, 0x25f3f73a)}, + {TOBN(0x199f6918, 0x84a9d5b7), TOBN(0x7ebe2325, 0x7e770374), + TOBN(0xf442e107, 0x0738efe2), TOBN(0xcf9f3f56, 0xcf9082d2)}}, + {{TOBN(0x719f69e1, 0x09618708), TOBN(0xcc9e8364, 0xc183f9b1), + TOBN(0xec203a95, 0x366a21af), TOBN(0x6aec5d6d, 0x068b141f)}, + {TOBN(0xee2df78a, 0x994f04e9), TOBN(0xb39ccae8, 0x271245b0), + TOBN(0xb875a4a9, 0x97e43f4f), TOBN(0x507dfe11, 0xdb2cea98)}}, + {{TOBN(0x4fbf81cb, 0x489b03e9), TOBN(0xdb86ec5b, 0x6ec414fa), + TOBN(0xfad444f9, 0xf51b3ae5), TOBN(0xca7d33d6, 0x1914e3fe)}, + {TOBN(0xa9c32f5c, 0x0ae6c4d0), TOBN(0xa9ca1d1e, 0x73969568), + TOBN(0x98043c31, 0x1aa7467e), TOBN(0xe832e75c, 0xe21b5ac6)}}, + {{TOBN(0x314b7aea, 0x5232123d), TOBN(0x08307c8c, 0x65ae86db), + TOBN(0x06e7165c, 0xaa4668ed), TOBN(0xb170458b, 0xb4d3ec39)}, + {TOBN(0x4d2e3ec6, 0xc19bb986), TOBN(0xc5f34846, 0xae0304ed), + TOBN(0x917695a0, 0x6c9f9722), TOBN(0x6c7f7317, 0x4cab1c0a)}}, + {{TOBN(0x6295940e, 0x9d6d2e8b), TOBN(0xd318b8c1, 0x549f7c97), + TOBN(0x22453204, 0x97713885), TOBN(0x468d834b, 0xa8a440fe)}, + {TOBN(0xd81fe5b2, 0xbfba796e), TOBN(0x152364db, 0x6d71f116), + TOBN(0xbb8c7c59, 0xb5b66e53), TOBN(0x0b12c61b, 0x2641a192)}}, + {{TOBN(0x31f14802, 0xfcf0a7fd), TOBN(0x42fd0789, 0x5488b01e), + TOBN(0x71d78d6d, 0x9952b498), TOBN(0x8eb572d9, 0x07ac5201)}, + {TOBN(0xe0a2a44c, 0x4d194a88), TOBN(0xd2b63fd9, 0xba017e66), + TOBN(0x78efc6c8, 0xf888aefc), TOBN(0xb76f6bda, 0x4a881a11)}}, + {{TOBN(0x187f314b, 0xb46c2397), TOBN(0x004cf566, 0x5ded2819), + TOBN(0xa9ea5704, 0x38764d34), TOBN(0xbba45217, 0x78084709)}, + {TOBN(0x06474571, 0x1171121e), TOBN(0xad7b7eb1, 0xe7c9b671), + TOBN(0xdacfbc40, 0x730f7507), TOBN(0x178cd8c6, 0xc7ad7bd1)}}, + {{TOBN(0xbf0be101, 0xb2a67238), TOBN(0x3556d367, 0xaf9c14f2), + TOBN(0x104b7831, 0xa5662075), TOBN(0x58ca59bb, 0x79d9e60a)}, + {TOBN(0x4bc45392, 0xa569a73b), TOBN(0x517a52e8, 0x5698f6c9), + TOBN(0x85643da5, 0xaeadd755), TOBN(0x1aed0cd5, 0x2a581b84)}}, + {{TOBN(0xb9b4ff84, 0x80af1372), TOBN(0x244c3113, 0xf1ba5d1f), + TOBN(0x2a5dacbe, 0xf5f98d31), TOBN(0x2c3323e8, 0x4375bc2a)}, + {TOBN(0x17a3ab4a, 0x5594b1dd), TOBN(0xa1928bfb, 0xceb4797e), + TOBN(0xe83af245, 0xe4886a19), TOBN(0x8979d546, 0x72b5a74a)}}, + {{TOBN(0xa0f726bc, 0x19f9e967), TOBN(0xd9d03152, 0xe8fbbf4e), + TOBN(0xcfd6f51d, 0xb7707d40), TOBN(0x633084d9, 0x63f6e6e0)}, + {TOBN(0xedcd9cdc, 0x55667eaf), TOBN(0x73b7f92b, 0x2e44d56f), + TOBN(0xfb2e39b6, 0x4e962b14), TOBN(0x7d408f6e, 0xf671fcbf)}}, + {{TOBN(0xcc634ddc, 0x164a89bb), TOBN(0x74a42bb2, 0x3ef3bd05), + TOBN(0x1280dbb2, 0x428decbb), TOBN(0x6103f6bb, 0x402c8596)}, + {TOBN(0xfa2bf581, 0x355a5752), TOBN(0x562f96a8, 0x00946674), + TOBN(0x4e4ca16d, 0x6da0223b), TOBN(0xfe47819f, 0x28d3aa25)}}, + {{TOBN(0x9eea3075, 0xf8dfcf8a), TOBN(0xa284f0aa, 0x95669825), + TOBN(0xb3fca250, 0x867d3fd8), TOBN(0x20757b5f, 0x269d691e)}, + {TOBN(0xf2c24020, 0x93b8a5de), TOBN(0xd3f93359, 0xebc06da6), + TOBN(0x1178293e, 0xb2739c33), TOBN(0xd2a3e770, 0xbcd686e5)}}, + {{TOBN(0xa76f49f4, 0xcd941534), TOBN(0x0d37406b, 0xe3c71c0e), + TOBN(0x172d9397, 0x3b97f7e3), TOBN(0xec17e239, 0xbd7fd0de)}, + {TOBN(0xe3290551, 0x6f496ba2), TOBN(0x6a693172, 0x36ad50e7), + TOBN(0xc4e539a2, 0x83e7eff5), TOBN(0x752737e7, 0x18e1b4cf)}}, + {{TOBN(0xa2f7932c, 0x68af43ee), TOBN(0x5502468e, 0x703d00bd), + TOBN(0xe5dc978f, 0x2fb061f5), TOBN(0xc9a1904a, 0x28c815ad)}, + {TOBN(0xd3af538d, 0x470c56a4), TOBN(0x159abc5f, 0x193d8ced), + TOBN(0x2a37245f, 0x20108ef3), TOBN(0xfa17081e, 0x223f7178)}}, + {{TOBN(0x27b0fb2b, 0x10c8c0f5), TOBN(0x2102c3ea, 0x40650547), + TOBN(0x594564df, 0x8ac3bfa7), TOBN(0x98102033, 0x509dad96)}, + {TOBN(0x6989643f, 0xf1d18a13), TOBN(0x35eebd91, 0xd7fc5af0), + TOBN(0x078d096a, 0xfaeaafd8), TOBN(0xb7a89341, 0xdef3de98)}}, + {{TOBN(0x2a206e8d, 0xecf2a73a), TOBN(0x066a6397, 0x8e551994), + TOBN(0x3a6a088a, 0xb98d53a2), TOBN(0x0ce7c67c, 0x2d1124aa)}, + {TOBN(0x48cec671, 0x759a113c), TOBN(0xe3b373d3, 0x4f6f67fa), + TOBN(0x5455d479, 0xfd36727b), TOBN(0xe5a428ee, 0xa13c0d81)}}, + {{TOBN(0xb853dbc8, 0x1c86682b), TOBN(0xb78d2727, 0xb8d02b2a), + TOBN(0xaaf69bed, 0x8ebc329a), TOBN(0xdb6b40b3, 0x293b2148)}, + {TOBN(0xe42ea77d, 0xb8c4961f), TOBN(0xb1a12f7c, 0x20e5e0ab), + TOBN(0xa0ec5274, 0x79e8b05e), TOBN(0x68027391, 0xfab60a80)}}, + {{TOBN(0x6bfeea5f, 0x16b1bd5e), TOBN(0xf957e420, 0x4de30ad3), + TOBN(0xcbaf664e, 0x6a353b9e), TOBN(0x5c873312, 0x26d14feb)}, + {TOBN(0x4e87f98c, 0xb65f57cb), TOBN(0xdb60a621, 0x5e0cdd41), + TOBN(0x67c16865, 0xa6881440), TOBN(0x1093ef1a, 0x46ab52aa)}}, + {{TOBN(0xc095afb5, 0x3f4ece64), TOBN(0x6a6bb02e, 0x7604551a), + TOBN(0x55d44b4e, 0x0b26b8cd), TOBN(0xe5f9a999, 0xf971268a)}, + {TOBN(0xc08ec425, 0x11a7de84), TOBN(0x83568095, 0xfda469dd), + TOBN(0x737bfba1, 0x6c6c90a2), TOBN(0x1cb9c4a0, 0xbe229831)}}, + {{TOBN(0x93bccbba, 0xbb2eec64), TOBN(0xa0c23b64, 0xda03adbe), + TOBN(0x5f7aa00a, 0xe0e86ac4), TOBN(0x470b941e, 0xfc1401e6)}, + {TOBN(0x5ad8d679, 0x9df43574), TOBN(0x4ccfb8a9, 0x0f65d810), + TOBN(0x1bce80e3, 0xaa7fbd81), TOBN(0x273291ad, 0x9508d20a)}}, + {{TOBN(0xf5c4b46b, 0x42a92806), TOBN(0x810684ec, 0xa86ab44a), + TOBN(0x4591640b, 0xca0bc9f8), TOBN(0xb5efcdfc, 0x5c4b6054)}, + {TOBN(0x16fc8907, 0x6e9edd12), TOBN(0xe29d0b50, 0xd4d792f9), + TOBN(0xa45fd01c, 0x9b03116d), TOBN(0x85035235, 0xc81765a4)}}, + {{TOBN(0x1fe2a9b2, 0xb4b4b67c), TOBN(0xc1d10df0, 0xe8020604), + TOBN(0x9d64abfc, 0xbc8058d8), TOBN(0x8943b9b2, 0x712a0fbb)}, + {TOBN(0x90eed914, 0x3b3def04), TOBN(0x85ab3aa2, 0x4ce775ff), + TOBN(0x605fd4ca, 0x7bbc9040), TOBN(0x8b34a564, 0xe2c75dfb)}}, + {{TOBN(0x41ffc94a, 0x10358560), TOBN(0x2d8a5072, 0x9e5c28aa), + TOBN(0xe915a0fc, 0x4cc7eb15), TOBN(0xe9efab05, 0x8f6d0f5d)}, + {TOBN(0xdbab47a9, 0xd19e9b91), TOBN(0x8cfed745, 0x0276154c), + TOBN(0x154357ae, 0x2cfede0d), TOBN(0x520630df, 0x19f5a4ef)}}, + {{TOBN(0x25759f7c, 0xe382360f), TOBN(0xb6db05c9, 0x88bf5857), + TOBN(0x2917d61d, 0x6c58d46c), TOBN(0x14f8e491, 0xfd20cb7a)}, + {TOBN(0xb68a727a, 0x11c20340), TOBN(0x0386f86f, 0xaf7ccbb6), + TOBN(0x5c8bc6cc, 0xfee09a20), TOBN(0x7d76ff4a, 0xbb7eea35)}}, + {{TOBN(0xa7bdebe7, 0xdb15be7a), TOBN(0x67a08054, 0xd89f0302), + TOBN(0x56bf0ea9, 0xc1193364), TOBN(0xc8244467, 0x62837ebe)}, + {TOBN(0x32bd8e8b, 0x20d841b8), TOBN(0x127a0548, 0xdbb8a54f), + TOBN(0x83dd4ca6, 0x63b20236), TOBN(0x87714718, 0x203491fa)}}, + {{TOBN(0x4dabcaaa, 0xaa8a5288), TOBN(0x91cc0c8a, 0xaf23a1c9), + TOBN(0x34c72c6a, 0x3f220e0c), TOBN(0xbcc20bdf, 0x1232144a)}, + {TOBN(0x6e2f42da, 0xa20ede1b), TOBN(0xc441f00c, 0x74a00515), + TOBN(0xbf46a5b6, 0x734b8c4b), TOBN(0x57409503, 0x7b56c9a4)}}, + {{TOBN(0x9f735261, 0xe4585d45), TOBN(0x9231faed, 0x6734e642), + TOBN(0x1158a176, 0xbe70ee6c), TOBN(0x35f1068d, 0x7c3501bf)}, + {TOBN(0x6beef900, 0xa2d26115), TOBN(0x649406f2, 0xef0afee3), + TOBN(0x3f43a60a, 0xbc2420a1), TOBN(0x509002a7, 0xd5aee4ac)}}, + {{TOBN(0xb46836a5, 0x3ff3571b), TOBN(0x24f98b78, 0x837927c1), + TOBN(0x6254256a, 0x4533c716), TOBN(0xf27abb0b, 0xd07ee196)}, + {TOBN(0xd7cf64fc, 0x5c6d5bfd), TOBN(0x6915c751, 0xf0cd7a77), + TOBN(0xd9f59012, 0x8798f534), TOBN(0x772b0da8, 0xf81d8b5f)}}, + {{TOBN(0x1244260c, 0x2e03fa69), TOBN(0x36cf0e3a, 0x3be1a374), + TOBN(0x6e7c1633, 0xef06b960), TOBN(0xa71a4c55, 0x671f90f6)}, + {TOBN(0x7a941251, 0x33c673db), TOBN(0xc0bea510, 0x73e8c131), + TOBN(0x61a8a699, 0xd4f6c734), TOBN(0x25e78c88, 0x341ed001)}}, + {{TOBN(0x5c18acf8, 0x8e2f7d90), TOBN(0xfdbf33d7, 0x77be32cd), + TOBN(0x0a085cd7, 0xd2eb5ee9), TOBN(0x2d702cfb, 0xb3201115)}, + {TOBN(0xb6e0ebdb, 0x85c88ce8), TOBN(0x23a3ce3c, 0x1e01d617), + TOBN(0x3041618e, 0x567333ac), TOBN(0x9dd0fd8f, 0x157edb6b)}}, + {{TOBN(0x27f74702, 0xb57872b8), TOBN(0x2ef26b4f, 0x657d5fe1), + TOBN(0x95426f0a, 0x57cf3d40), TOBN(0x847e2ad1, 0x65a6067a)}, + {TOBN(0xd474d9a0, 0x09996a74), TOBN(0x16a56acd, 0x2a26115c), + TOBN(0x02a615c3, 0xd16f4d43), TOBN(0xcc3fc965, 0xaadb85b7)}}, + {{TOBN(0x386bda73, 0xce07d1b0), TOBN(0xd82910c2, 0x58ad4178), + TOBN(0x124f82cf, 0xcd2617f4), TOBN(0xcc2f5e8d, 0xef691770)}, + {TOBN(0x82702550, 0xb8c30ccc), TOBN(0x7b856aea, 0x1a8e575a), + TOBN(0xbb822fef, 0xb1ab9459), TOBN(0x085928bc, 0xec24e38e)}}, + {{TOBN(0x5d0402ec, 0xba8f4b4d), TOBN(0xc07cd4ba, 0x00b4d58b), + TOBN(0x5d8dffd5, 0x29227e7a), TOBN(0x61d44d0c, 0x31bf386f)}, + {TOBN(0xe486dc2b, 0x135e6f4d), TOBN(0x680962eb, 0xe79410ef), + TOBN(0xa61bd343, 0xf10088b5), TOBN(0x6aa76076, 0xe2e28686)}}, + {{TOBN(0x80463d11, 0x8fb98871), TOBN(0xcb26f5c3, 0xbbc76aff), + TOBN(0xd4ab8edd, 0xfbe03614), TOBN(0xc8eb579b, 0xc0cf2dee)}, + {TOBN(0xcc004c15, 0xc93bae41), TOBN(0x46fbae5d, 0x3aeca3b2), + TOBN(0x671235cf, 0x0f1e9ab1), TOBN(0xadfba934, 0x9ec285c1)}}, + {{TOBN(0x88ded013, 0xf216c980), TOBN(0xc8ac4fb8, 0xf79e0bc1), + TOBN(0xa29b89c6, 0xfb97a237), TOBN(0xb697b780, 0x9922d8e7)}, + {TOBN(0x3142c639, 0xddb945b5), TOBN(0x447b06c7, 0xe094c3a9), + TOBN(0xcdcb3642, 0x72266c90), TOBN(0x633aad08, 0xa9385046)}}, + {{TOBN(0xa36c936b, 0xb57c6477), TOBN(0x871f8b64, 0xe94dbcc6), + TOBN(0x28d0fb62, 0xa591a67b), TOBN(0x9d40e081, 0xc1d926f5)}, + {TOBN(0x3111eaf6, 0xf2d84b5a), TOBN(0x228993f9, 0xa565b644), + TOBN(0x0ccbf592, 0x2c83188b), TOBN(0xf87b30ab, 0x3df3e197)}}, + {{TOBN(0xb8658b31, 0x7642bca8), TOBN(0x1a032d7f, 0x52800f17), + TOBN(0x051dcae5, 0x79bf9445), TOBN(0xeba6b8ee, 0x54a2e253)}, + {TOBN(0x5c8b9cad, 0xd4485692), TOBN(0x84bda40e, 0x8986e9be), + TOBN(0xd16d16a4, 0x2f0db448), TOBN(0x8ec80050, 0xa14d4188)}}, + {{TOBN(0xb2b26107, 0x98fa7aaa), TOBN(0x41209ee4, 0xf073aa4e), + TOBN(0xf1570359, 0xf2d6b19b), TOBN(0xcbe6868c, 0xfc577caf)}, + {TOBN(0x186c4bdc, 0x32c04dd3), TOBN(0xa6c35fae, 0xcfeee397), + TOBN(0xb4a1b312, 0xf086c0cf), TOBN(0xe0a5ccc6, 0xd9461fe2)}}, + {{TOBN(0xc32278aa, 0x1536189f), TOBN(0x1126c55f, 0xba6df571), + TOBN(0x0f71a602, 0xb194560e), TOBN(0x8b2d7405, 0x324bd6e1)}, + {TOBN(0x8481939e, 0x3738be71), TOBN(0xb5090b1a, 0x1a4d97a9), + TOBN(0x116c65a3, 0xf05ba915), TOBN(0x21863ad3, 0xaae448aa)}}, + {{TOBN(0xd24e2679, 0xa7aae5d3), TOBN(0x7076013d, 0x0de5c1c4), + TOBN(0x2d50f8ba, 0xbb05b629), TOBN(0x73c1abe2, 0x6e66efbb)}, + {TOBN(0xefd4b422, 0xf2488af7), TOBN(0xe4105d02, 0x663ba575), + TOBN(0x7eb60a8b, 0x53a69457), TOBN(0x62210008, 0xc945973b)}}, + {{TOBN(0xfb255478, 0x77a50ec6), TOBN(0xbf0392f7, 0x0a37a72c), + TOBN(0xa0a7a19c, 0x4be18e7a), TOBN(0x90d8ea16, 0x25b1e0af)}, + {TOBN(0x7582a293, 0xef953f57), TOBN(0x90a64d05, 0xbdc5465a), + TOBN(0xca79c497, 0xe2510717), TOBN(0x560dbb7c, 0x18cb641f)}}, + {{TOBN(0x1d8e3286, 0x4b66abfb), TOBN(0xd26f52e5, 0x59030900), + TOBN(0x1ee3f643, 0x5584941a), TOBN(0x6d3b3730, 0x569f5958)}, + {TOBN(0x9ff2a62f, 0x4789dba5), TOBN(0x91fcb815, 0x72b5c9b7), + TOBN(0xf446cb7d, 0x6c8f9a0e), TOBN(0x48f625c1, 0x39b7ecb5)}}, + {{TOBN(0xbabae801, 0x1c6219b8), TOBN(0xe7a562d9, 0x28ac2f23), + TOBN(0xe1b48732, 0x26e20588), TOBN(0x06ee1cad, 0x775af051)}, + {TOBN(0xda29ae43, 0xfaff79f7), TOBN(0xc141a412, 0x652ee9e0), + TOBN(0x1e127f6f, 0x195f4bd0), TOBN(0x29c6ab4f, 0x072f34f8)}}, + {{TOBN(0x7b7c1477, 0x30448112), TOBN(0x82b51af1, 0xe4a38656), + TOBN(0x2bf2028a, 0x2f315010), TOBN(0xc9a4a01f, 0x6ea88cd4)}, + {TOBN(0xf63e95d8, 0x257e5818), TOBN(0xdd8efa10, 0xb4519b16), + TOBN(0xed8973e0, 0x0da910bf), TOBN(0xed49d077, 0x5c0fe4a9)}}, + {{TOBN(0xac3aac5e, 0xb7caee1e), TOBN(0x1033898d, 0xa7f4da57), + TOBN(0x42145c0e, 0x5c6669b9), TOBN(0x42daa688, 0xc1aa2aa0)}, + {TOBN(0x629cc15c, 0x1a1d885a), TOBN(0x25572ec0, 0xf4b76817), + TOBN(0x8312e435, 0x9c8f8f28), TOBN(0x8107f8cd, 0x81965490)}}, + {{TOBN(0x516ff3a3, 0x6fa6110c), TOBN(0x74fb1eb1, 0xfb93561f), + TOBN(0x6c0c9047, 0x8457522b), TOBN(0xcfd32104, 0x6bb8bdc6)}, + {TOBN(0x2d6884a2, 0xcc80ad57), TOBN(0x7c27fc35, 0x86a9b637), + TOBN(0x3461baed, 0xadf4e8cd), TOBN(0x1d56251a, 0x617242f0)}}, + {{TOBN(0x0b80d209, 0xc955bef4), TOBN(0xdf02cad2, 0x06adb047), + TOBN(0xf0d7cb91, 0x5ec74fee), TOBN(0xd2503375, 0x1111ba44)}, + {TOBN(0x9671755e, 0xdf53cb36), TOBN(0x54dcb612, 0x3368551b), + TOBN(0x66d69aac, 0xc8a025a4), TOBN(0x6be946c6, 0xe77ef445)}}, + {{TOBN(0x719946d1, 0xa995e094), TOBN(0x65e848f6, 0xe51e04d8), + TOBN(0xe62f3300, 0x6a1e3113), TOBN(0x1541c7c1, 0x501de503)}, + {TOBN(0x4daac9fa, 0xf4acfade), TOBN(0x0e585897, 0x44cd0b71), + TOBN(0x544fd869, 0x0a51cd77), TOBN(0x60fc20ed, 0x0031016d)}}, + {{TOBN(0x58b404ec, 0xa4276867), TOBN(0x46f6c3cc, 0x34f34993), + TOBN(0x477ca007, 0xc636e5bd), TOBN(0x8018f5e5, 0x7c458b47)}, + {TOBN(0xa1202270, 0xe47b668f), TOBN(0xcef48ccd, 0xee14f203), + TOBN(0x23f98bae, 0x62ff9b4d), TOBN(0x55acc035, 0xc589eddd)}}, + {{TOBN(0x3fe712af, 0x64db4444), TOBN(0x19e9d634, 0xbecdd480), + TOBN(0xe08bc047, 0xa930978a), TOBN(0x2dbf24ec, 0xa1280733)}, + {TOBN(0x3c0ae38c, 0x2cd706b2), TOBN(0x5b012a5b, 0x359017b9), + TOBN(0x3943c38c, 0x72e0f5ae), TOBN(0x786167ea, 0x57176fa3)}}, + {{TOBN(0xe5f9897d, 0x594881dc), TOBN(0x6b5efad8, 0xcfb820c1), + TOBN(0xb2179093, 0xd55018de), TOBN(0x39ad7d32, 0x0bac56ce)}, + {TOBN(0xb55122e0, 0x2cfc0e81), TOBN(0x117c4661, 0xf6d89daa), + TOBN(0x362d01e1, 0xcb64fa09), TOBN(0x6a309b4e, 0x3e9c4ddd)}}, + {{TOBN(0xfa979fb7, 0xabea49b1), TOBN(0xb4b1d27d, 0x10e2c6c5), + TOBN(0xbd61c2c4, 0x23afde7a), TOBN(0xeb6614f8, 0x9786d358)}, + {TOBN(0x4a5d816b, 0x7f6f7459), TOBN(0xe431a44f, 0x09360e7b), + TOBN(0x8c27a032, 0xc309914c), TOBN(0xcea5d68a, 0xcaede3d8)}}, + {{TOBN(0x3668f665, 0x3a0a3f95), TOBN(0x89369416, 0x7ceba27b), + TOBN(0x89981fad, 0xe4728fe9), TOBN(0x7102c8a0, 0x8a093562)}, + {TOBN(0xbb80310e, 0x235d21c8), TOBN(0x505e55d1, 0xbefb7f7b), + TOBN(0xa0a90811, 0x12958a67), TOBN(0xd67e106a, 0x4d851fef)}}, + {{TOBN(0xb84011a9, 0x431dd80e), TOBN(0xeb7c7cca, 0x73306cd9), + TOBN(0x20fadd29, 0xd1b3b730), TOBN(0x83858b5b, 0xfe37b3d3)}, + {TOBN(0xbf4cd193, 0xb6251d5c), TOBN(0x1cca1fd3, 0x1352d952), + TOBN(0xc66157a4, 0x90fbc051), TOBN(0x7990a638, 0x89b98636)}}}, + {{{TOBN(0xe5aa692a, 0x87dec0e1), TOBN(0x010ded8d, 0xf7b39d00), + TOBN(0x7b1b80c8, 0x54cfa0b5), TOBN(0x66beb876, 0xa0f8ea28)}, + {TOBN(0x50d7f531, 0x3476cd0e), TOBN(0xa63d0e65, 0xb08d3949), + TOBN(0x1a09eea9, 0x53479fc6), TOBN(0x82ae9891, 0xf499e742)}}, + {{TOBN(0xab58b910, 0x5ca7d866), TOBN(0x582967e2, 0x3adb3b34), + TOBN(0x89ae4447, 0xcceac0bc), TOBN(0x919c667c, 0x7bf56af5)}, + {TOBN(0x9aec17b1, 0x60f5dcd7), TOBN(0xec697b9f, 0xddcaadbc), + TOBN(0x0b98f341, 0x463467f5), TOBN(0xb187f1f7, 0xa967132f)}}, + {{TOBN(0x90fe7a1d, 0x214aeb18), TOBN(0x1506af3c, 0x741432f7), + TOBN(0xbb5565f9, 0xe591a0c4), TOBN(0x10d41a77, 0xb44f1bc3)}, + {TOBN(0xa09d65e4, 0xa84bde96), TOBN(0x42f060d8, 0xf20a6a1c), + TOBN(0x652a3bfd, 0xf27f9ce7), TOBN(0xb6bdb65c, 0x3b3d739f)}}, + {{TOBN(0xeb5ddcb6, 0xec7fae9f), TOBN(0x995f2714, 0xefb66e5a), + TOBN(0xdee95d8e, 0x69445d52), TOBN(0x1b6c2d46, 0x09e27620)}, + {TOBN(0x32621c31, 0x8129d716), TOBN(0xb03909f1, 0x0958c1aa), + TOBN(0x8c468ef9, 0x1af4af63), TOBN(0x162c429f, 0xfba5cdf6)}}, + {{TOBN(0x2f682343, 0x753b9371), TOBN(0x29cab45a, 0x5f1f9cd7), + TOBN(0x571623ab, 0xb245db96), TOBN(0xc507db09, 0x3fd79999)}, + {TOBN(0x4e2ef652, 0xaf036c32), TOBN(0x86f0cc78, 0x05018e5c), + TOBN(0xc10a73d4, 0xab8be350), TOBN(0x6519b397, 0x7e826327)}}, + {{TOBN(0xe8cb5eef, 0x9c053df7), TOBN(0x8de25b37, 0xb300ea6f), + TOBN(0xdb03fa92, 0xc849cffb), TOBN(0x242e43a7, 0xe84169bb)}, + {TOBN(0xe4fa51f4, 0xdd6f958e), TOBN(0x6925a77f, 0xf4445a8d), + TOBN(0xe6e72a50, 0xe90d8949), TOBN(0xc66648e3, 0x2b1f6390)}}, + {{TOBN(0xb2ab1957, 0x173e460c), TOBN(0x1bbbce75, 0x30704590), + TOBN(0xc0a90dbd, 0xdb1c7162), TOBN(0x505e399e, 0x15cdd65d)}, + {TOBN(0x68434dcb, 0x57797ab7), TOBN(0x60ad35ba, 0x6a2ca8e8), + TOBN(0x4bfdb1e0, 0xde3336c1), TOBN(0xbbef99eb, 0xd8b39015)}}, + {{TOBN(0x6c3b96f3, 0x1711ebec), TOBN(0x2da40f1f, 0xce98fdc4), + TOBN(0xb99774d3, 0x57b4411f), TOBN(0x87c8bdf4, 0x15b65bb6)}, + {TOBN(0xda3a89e3, 0xc2eef12d), TOBN(0xde95bb9b, 0x3c7471f3), + TOBN(0x600f225b, 0xd812c594), TOBN(0x54907c5d, 0x2b75a56b)}}, + {{TOBN(0xa93cc5f0, 0x8db60e35), TOBN(0x743e3cd6, 0xfa833319), + TOBN(0x7dad5c41, 0xf81683c9), TOBN(0x70c1e7d9, 0x9c34107e)}, + {TOBN(0x0edc4a39, 0xa6be0907), TOBN(0x36d47035, 0x86d0b7d3), + TOBN(0x8c76da03, 0x272bfa60), TOBN(0x0b4a07ea, 0x0f08a414)}}, + {{TOBN(0x699e4d29, 0x45c1dd53), TOBN(0xcadc5898, 0x231debb5), + TOBN(0xdf49fcc7, 0xa77f00e0), TOBN(0x93057bbf, 0xa73e5a0e)}, + {TOBN(0x2f8b7ecd, 0x027a4cd1), TOBN(0x114734b3, 0xc614011a), + TOBN(0xe7a01db7, 0x67677c68), TOBN(0x89d9be5e, 0x7e273f4f)}}, + {{TOBN(0xd225cb2e, 0x089808ef), TOBN(0xf1f7a27d, 0xd59e4107), + TOBN(0x53afc761, 0x8211b9c9), TOBN(0x0361bc67, 0xe6819159)}, + {TOBN(0x2a865d0b, 0x7f071426), TOBN(0x6a3c1810, 0xe7072567), + TOBN(0x3e3bca1e, 0x0d6bcabd), TOBN(0xa1b02bc1, 0x408591bc)}}, + {{TOBN(0xe0deee59, 0x31fba239), TOBN(0xf47424d3, 0x98bd91d1), + TOBN(0x0f8886f4, 0x071a3c1d), TOBN(0x3f7d41e8, 0xa819233b)}, + {TOBN(0x708623c2, 0xcf6eb998), TOBN(0x86bb49af, 0x609a287f), + TOBN(0x942bb249, 0x63c90762), TOBN(0x0ef6eea5, 0x55a9654b)}}, + {{TOBN(0x5f6d2d72, 0x36f5defe), TOBN(0xfa9922dc, 0x56f99176), + TOBN(0x6c8c5ece, 0xf78ce0c7), TOBN(0x7b44589d, 0xbe09b55e)}, + {TOBN(0xe11b3bca, 0x9ea83770), TOBN(0xd7fa2c7f, 0x2ab71547), + TOBN(0x2a3dd6fa, 0x2a1ddcc0), TOBN(0x09acb430, 0x5a7b7707)}}, + {{TOBN(0x4add4a2e, 0x649d4e57), TOBN(0xcd53a2b0, 0x1917526e), + TOBN(0xc5262330, 0x20b44ac4), TOBN(0x4028746a, 0xbaa2c31d)}, + {TOBN(0x51318390, 0x64291d4c), TOBN(0xbf48f151, 0xee5ad909), + TOBN(0xcce57f59, 0x7b185681), TOBN(0x7c3ac1b0, 0x4854d442)}}, + {{TOBN(0x65587dc3, 0xc093c171), TOBN(0xae7acb24, 0x24f42b65), + TOBN(0x5a338adb, 0x955996cb), TOBN(0xc8e65675, 0x6051f91b)}, + {TOBN(0x66711fba, 0x28b8d0b1), TOBN(0x15d74137, 0xb6c10a90), + TOBN(0x70cdd7eb, 0x3a232a80), TOBN(0xc9e2f07f, 0x6191ed24)}}, + {{TOBN(0xa80d1db6, 0xf79588c0), TOBN(0xfa52fc69, 0xb55768cc), + TOBN(0x0b4df1ae, 0x7f54438a), TOBN(0x0cadd1a7, 0xf9b46a4f)}, + {TOBN(0xb40ea6b3, 0x1803dd6f), TOBN(0x488e4fa5, 0x55eaae35), + TOBN(0x9f047d55, 0x382e4e16), TOBN(0xc9b5b7e0, 0x2f6e0c98)}}, + {{TOBN(0x6b1bd2d3, 0x95762649), TOBN(0xa9604ee7, 0xc7aea3f6), + TOBN(0x3646ff27, 0x6dc6f896), TOBN(0x9bf0e7f5, 0x2860bad1)}, + {TOBN(0x2d92c821, 0x7cb44b92), TOBN(0xa2f5ce63, 0xaea9c182), + TOBN(0xd0a2afb1, 0x9154a5fd), TOBN(0x482e474c, 0x95801da6)}}, + {{TOBN(0xc19972d0, 0xb611c24b), TOBN(0x1d468e65, 0x60a8f351), + TOBN(0xeb758069, 0x7bcf6421), TOBN(0xec9dd0ee, 0x88fbc491)}, + {TOBN(0x5b59d2bf, 0x956c2e32), TOBN(0x73dc6864, 0xdcddf94e), + TOBN(0xfd5e2321, 0xbcee7665), TOBN(0xa7b4f8ef, 0x5e9a06c4)}}, + {{TOBN(0xfba918dd, 0x7280f855), TOBN(0xbbaac260, 0x8baec688), + TOBN(0xa3b3f00f, 0x33400f42), TOBN(0x3d2dba29, 0x66f2e6e4)}, + {TOBN(0xb6f71a94, 0x98509375), TOBN(0x8f33031f, 0xcea423cc), + TOBN(0x009b8dd0, 0x4807e6fb), TOBN(0x5163cfe5, 0x5cdb954c)}}, + {{TOBN(0x03cc8f17, 0xcf41c6e8), TOBN(0xf1f03c2a, 0x037b925c), + TOBN(0xc39c19cc, 0x66d2427c), TOBN(0x823d24ba, 0x7b6c18e4)}, + {TOBN(0x32ef9013, 0x901f0b4f), TOBN(0x684360f1, 0xf8941c2e), + TOBN(0x0ebaff52, 0x2c28092e), TOBN(0x7891e4e3, 0x256c932f)}}, + {{TOBN(0x51264319, 0xac445e3d), TOBN(0x553432e7, 0x8ea74381), + TOBN(0xe6eeaa69, 0x67e9c50a), TOBN(0x27ced284, 0x62e628c7)}, + {TOBN(0x3f96d375, 0x7a4afa57), TOBN(0xde0a14c3, 0xe484c150), + TOBN(0x364a24eb, 0x38bd9923), TOBN(0x1df18da0, 0xe5177422)}}, + {{TOBN(0x174e8f82, 0xd8d38a9b), TOBN(0x2e97c600, 0xe7de1391), + TOBN(0xc5709850, 0xa1c175dd), TOBN(0x969041a0, 0x32ae5035)}, + {TOBN(0xcbfd533b, 0x76a2086b), TOBN(0xd6bba71b, 0xd7c2e8fe), + TOBN(0xb2d58ee6, 0x099dfb67), TOBN(0x3a8b342d, 0x064a85d9)}}, + {{TOBN(0x3bc07649, 0x522f9be3), TOBN(0x690c075b, 0xdf1f49a8), + TOBN(0x80e1aee8, 0x3854ec42), TOBN(0x2a7dbf44, 0x17689dc7)}, + {TOBN(0xc004fc0e, 0x3faf4078), TOBN(0xb2f02e9e, 0xdf11862c), + TOBN(0xf10a5e0f, 0xa0a1b7b3), TOBN(0x30aca623, 0x8936ec80)}}, + {{TOBN(0xf83cbf05, 0x02f40d9a), TOBN(0x4681c468, 0x2c318a4d), + TOBN(0x98575618, 0x0e9c2674), TOBN(0xbe79d046, 0x1847092e)}, + {TOBN(0xaf1e480a, 0x78bd01e0), TOBN(0x6dd359e4, 0x72a51db9), + TOBN(0x62ce3821, 0xe3afbab6), TOBN(0xc5cee5b6, 0x17733199)}}, + {{TOBN(0xe08b30d4, 0x6ffd9fbb), TOBN(0x6e5bc699, 0x36c610b7), + TOBN(0xf343cff2, 0x9ce262cf), TOBN(0xca2e4e35, 0x68b914c1)}, + {TOBN(0x011d64c0, 0x16de36c5), TOBN(0xe0b10fdd, 0x42e2b829), + TOBN(0x78942981, 0x6685aaf8), TOBN(0xe7511708, 0x230ede97)}}, + {{TOBN(0x671ed8fc, 0x3b922bf8), TOBN(0xe4d8c0a0, 0x4c29b133), + TOBN(0x87eb1239, 0x3b6e99c4), TOBN(0xaff3974c, 0x8793beba)}, + {TOBN(0x03749405, 0x2c18df9b), TOBN(0xc5c3a293, 0x91007139), + TOBN(0x6a77234f, 0xe37a0b95), TOBN(0x02c29a21, 0xb661c96b)}}, + {{TOBN(0xc3aaf1d6, 0x141ecf61), TOBN(0x9195509e, 0x3bb22f53), + TOBN(0x29597404, 0x22d51357), TOBN(0x1b083822, 0x537bed60)}, + {TOBN(0xcd7d6e35, 0xe07289f0), TOBN(0x1f94c48c, 0x6dd86eff), + TOBN(0xc8bb1f82, 0xeb0f9cfa), TOBN(0x9ee0b7e6, 0x1b2eb97d)}}, + {{TOBN(0x5a52fe2e, 0x34d74e31), TOBN(0xa352c310, 0x3bf79ab6), + TOBN(0x97ff6c5a, 0xabfeeb8f), TOBN(0xbfbe8fef, 0xf5c97305)}, + {TOBN(0xd6081ce6, 0xa7904608), TOBN(0x1f812f3a, 0xc4fca249), + TOBN(0x9b24bc9a, 0xb9e5e200), TOBN(0x91022c67, 0x38012ee8)}}, + {{TOBN(0xe83d9c5d, 0x30a713a1), TOBN(0x4876e3f0, 0x84ef0f93), + TOBN(0xc9777029, 0xc1fbf928), TOBN(0xef7a6bb3, 0xbce7d2a4)}, + {TOBN(0xb8067228, 0xdfa2a659), TOBN(0xd5cd3398, 0xd877a48f), + TOBN(0xbea4fd8f, 0x025d0f3f), TOBN(0xd67d2e35, 0x2eae7c2b)}}, + {{TOBN(0x184de7d7, 0xcc5f4394), TOBN(0xb5551b5c, 0x4536e142), + TOBN(0x2e89b212, 0xd34aa60a), TOBN(0x14a96fea, 0xf50051d5)}, + {TOBN(0x4e21ef74, 0x0d12bb0b), TOBN(0xc522f020, 0x60b9677e), + TOBN(0x8b12e467, 0x2df7731d), TOBN(0x39f80382, 0x7b326d31)}}, + {{TOBN(0xdfb8630c, 0x39024a94), TOBN(0xaacb96a8, 0x97319452), + TOBN(0xd68a3961, 0xeda3867c), TOBN(0x0c58e2b0, 0x77c4ffca)}, + {TOBN(0x3d545d63, 0x4da919fa), TOBN(0xef79b69a, 0xf15e2289), + TOBN(0x54bc3d3d, 0x808bab10), TOBN(0xc8ab3007, 0x45f82c37)}}, + {{TOBN(0xc12738b6, 0x7c4a658a), TOBN(0xb3c47639, 0x40e72182), + TOBN(0x3b77be46, 0x8798e44f), TOBN(0xdc047df2, 0x17a7f85f)}, + {TOBN(0x2439d4c5, 0x5e59d92d), TOBN(0xcedca475, 0xe8e64d8d), + TOBN(0xa724cd0d, 0x87ca9b16), TOBN(0x35e4fd59, 0xa5540dfe)}}, + {{TOBN(0xf8c1ff18, 0xe4bcf6b1), TOBN(0x856d6285, 0x295018fa), + TOBN(0x433f665c, 0x3263c949), TOBN(0xa6a76dd6, 0xa1f21409)}, + {TOBN(0x17d32334, 0xcc7b4f79), TOBN(0xa1d03122, 0x06720e4a), + TOBN(0xadb6661d, 0x81d9bed5), TOBN(0xf0d6fb02, 0x11db15d1)}}, + {{TOBN(0x7fd11ad5, 0x1fb747d2), TOBN(0xab50f959, 0x3033762b), + TOBN(0x2a7e711b, 0xfbefaf5a), TOBN(0xc7393278, 0x3fef2bbf)}, + {TOBN(0xe29fa244, 0x0df6f9be), TOBN(0x9092757b, 0x71efd215), + TOBN(0xee60e311, 0x4f3d6fd9), TOBN(0x338542d4, 0x0acfb78b)}}, + {{TOBN(0x44a23f08, 0x38961a0f), TOBN(0x1426eade, 0x986987ca), + TOBN(0x36e6ee2e, 0x4a863cc6), TOBN(0x48059420, 0x628b8b79)}, + {TOBN(0x30303ad8, 0x7396e1de), TOBN(0x5c8bdc48, 0x38c5aad1), + TOBN(0x3e40e11f, 0x5c8f5066), TOBN(0xabd6e768, 0x8d246bbd)}}, + {{TOBN(0x68aa40bb, 0x23330a01), TOBN(0xd23f5ee4, 0xc34eafa0), + TOBN(0x3bbee315, 0x5de02c21), TOBN(0x18dd4397, 0xd1d8dd06)}, + {TOBN(0x3ba1939a, 0x122d7b44), TOBN(0xe6d3b40a, 0xa33870d6), + TOBN(0x8e620f70, 0x1c4fe3f8), TOBN(0xf6bba1a5, 0xd3a50cbf)}}, + {{TOBN(0x4a78bde5, 0xcfc0aee0), TOBN(0x847edc46, 0xc08c50bd), + TOBN(0xbaa2439c, 0xad63c9b2), TOBN(0xceb4a728, 0x10fc2acb)}, + {TOBN(0xa419e40e, 0x26da033d), TOBN(0x6cc3889d, 0x03e02683), + TOBN(0x1cd28559, 0xfdccf725), TOBN(0x0fd7e0f1, 0x8d13d208)}}, + {{TOBN(0x01b9733b, 0x1f0df9d4), TOBN(0x8cc2c5f3, 0xa2b5e4f3), + TOBN(0x43053bfa, 0x3a304fd4), TOBN(0x8e87665c, 0x0a9f1aa7)}, + {TOBN(0x087f29ec, 0xd73dc965), TOBN(0x15ace455, 0x3e9023db), + TOBN(0x2370e309, 0x2bce28b4), TOBN(0xf9723442, 0xb6b1e84a)}}, + {{TOBN(0xbeee662e, 0xb72d9f26), TOBN(0xb19396de, 0xf0e47109), + TOBN(0x85b1fa73, 0xe13289d0), TOBN(0x436cf77e, 0x54e58e32)}, + {TOBN(0x0ec833b3, 0xe990ef77), TOBN(0x7373e3ed, 0x1b11fc25), + TOBN(0xbe0eda87, 0x0fc332ce), TOBN(0xced04970, 0x8d7ea856)}}, + {{TOBN(0xf85ff785, 0x7e977ca0), TOBN(0xb66ee8da, 0xdfdd5d2b), + TOBN(0xf5e37950, 0x905af461), TOBN(0x587b9090, 0x966d487c)}, + {TOBN(0x6a198a1b, 0x32ba0127), TOBN(0xa7720e07, 0x141615ac), + TOBN(0xa23f3499, 0x996ef2f2), TOBN(0xef5f64b4, 0x470bcb3d)}}, + {{TOBN(0xa526a962, 0x92b8c559), TOBN(0x0c14aac0, 0x69740a0f), + TOBN(0x0d41a9e3, 0xa6bdc0a5), TOBN(0x97d52106, 0x9c48aef4)}, + {TOBN(0xcf16bd30, 0x3e7c253b), TOBN(0xcc834b1a, 0x47fdedc1), + TOBN(0x7362c6e5, 0x373aab2e), TOBN(0x264ed85e, 0xc5f590ff)}}, + {{TOBN(0x7a46d9c0, 0x66d41870), TOBN(0xa50c20b1, 0x4787ba09), + TOBN(0x185e7e51, 0xe3d44635), TOBN(0xb3b3e080, 0x31e2d8dc)}, + {TOBN(0xbed1e558, 0xa179e9d9), TOBN(0x2daa3f79, 0x74a76781), + TOBN(0x4372baf2, 0x3a40864f), TOBN(0x46900c54, 0x4fe75cb5)}}, + {{TOBN(0xb95f171e, 0xf76765d0), TOBN(0x4ad726d2, 0x95c87502), + TOBN(0x2ec769da, 0x4d7c99bd), TOBN(0x5e2ddd19, 0xc36cdfa8)}, + {TOBN(0xc22117fc, 0xa93e6dea), TOBN(0xe8a2583b, 0x93771123), + TOBN(0xbe2f6089, 0xfa08a3a2), TOBN(0x4809d5ed, 0x8f0e1112)}}, + {{TOBN(0x3b414aa3, 0xda7a095e), TOBN(0x9049acf1, 0x26f5aadd), + TOBN(0x78d46a4d, 0x6be8b84a), TOBN(0xd66b1963, 0xb732b9b3)}, + {TOBN(0x5c2ac2a0, 0xde6e9555), TOBN(0xcf52d098, 0xb5bd8770), + TOBN(0x15a15fa6, 0x0fd28921), TOBN(0x56ccb81e, 0x8b27536d)}}, + {{TOBN(0x0f0d8ab8, 0x9f4ccbb8), TOBN(0xed5f44d2, 0xdb221729), + TOBN(0x43141988, 0x00bed10c), TOBN(0xc94348a4, 0x1d735b8b)}, + {TOBN(0x79f3e9c4, 0x29ef8479), TOBN(0x4c13a4e3, 0x614c693f), + TOBN(0x32c9af56, 0x8e143a14), TOBN(0xbc517799, 0xe29ac5c4)}}, + {{TOBN(0x05e17992, 0x2774856f), TOBN(0x6e52fb05, 0x6c1bf55f), + TOBN(0xaeda4225, 0xe4f19e16), TOBN(0x70f4728a, 0xaf5ccb26)}, + {TOBN(0x5d2118d1, 0xb2947f22), TOBN(0xc827ea16, 0x281d6fb9), + TOBN(0x8412328d, 0x8cf0eabd), TOBN(0x45ee9fb2, 0x03ef9dcf)}}, + {{TOBN(0x8e700421, 0xbb937d63), TOBN(0xdf8ff2d5, 0xcc4b37a6), + TOBN(0xa4c0d5b2, 0x5ced7b68), TOBN(0x6537c1ef, 0xc7308f59)}, + {TOBN(0x25ce6a26, 0x3b37f8e8), TOBN(0x170e9a9b, 0xdeebc6ce), + TOBN(0xdd037952, 0x8728d72c), TOBN(0x445b0e55, 0x850154bc)}}, + {{TOBN(0x4b7d0e06, 0x83a7337b), TOBN(0x1e3416d4, 0xffecf249), + TOBN(0x24840eff, 0x66a2b71f), TOBN(0xd0d9a50a, 0xb37cc26d)}, + {TOBN(0xe2198150, 0x6fe28ef7), TOBN(0x3cc5ef16, 0x23324c7f), + TOBN(0x220f3455, 0x769b5263), TOBN(0xe2ade2f1, 0xa10bf475)}}, + {{TOBN(0x28cd20fa, 0x458d3671), TOBN(0x1549722c, 0x2dc4847b), + TOBN(0x6dd01e55, 0x591941e3), TOBN(0x0e6fbcea, 0x27128ccb)}, + {TOBN(0xae1a1e6b, 0x3bef0262), TOBN(0xfa8c472c, 0x8f54e103), + TOBN(0x7539c0a8, 0x72c052ec), TOBN(0xd7b27369, 0x5a3490e9)}}, + {{TOBN(0x143fe1f1, 0x71684349), TOBN(0x36b4722e, 0x32e19b97), + TOBN(0xdc059227, 0x90980aff), TOBN(0x175c9c88, 0x9e13d674)}, + {TOBN(0xa7de5b22, 0x6e6bfdb1), TOBN(0x5ea5b7b2, 0xbedb4b46), + TOBN(0xd5570191, 0xd34a6e44), TOBN(0xfcf60d2e, 0xa24ff7e6)}}, + {{TOBN(0x614a392d, 0x677819e1), TOBN(0x7be74c7e, 0xaa5a29e8), + TOBN(0xab50fece, 0x63c85f3f), TOBN(0xaca2e2a9, 0x46cab337)}, + {TOBN(0x7f700388, 0x122a6fe3), TOBN(0xdb69f703, 0x882a04a8), + TOBN(0x9a77935d, 0xcf7aed57), TOBN(0xdf16207c, 0x8d91c86f)}}, + {{TOBN(0x2fca49ab, 0x63ed9998), TOBN(0xa3125c44, 0xa77ddf96), + TOBN(0x05dd8a86, 0x24344072), TOBN(0xa023dda2, 0xfec3fb56)}, + {TOBN(0x421b41fc, 0x0c743032), TOBN(0x4f2120c1, 0x5e438639), + TOBN(0xfb7cae51, 0xc83c1b07), TOBN(0xb2370caa, 0xcac2171a)}}, + {{TOBN(0x2eb2d962, 0x6cc820fb), TOBN(0x59feee5c, 0xb85a44bf), + TOBN(0x94620fca, 0x5b6598f0), TOBN(0x6b922cae, 0x7e314051)}, + {TOBN(0xff8745ad, 0x106bed4e), TOBN(0x546e71f5, 0xdfa1e9ab), + TOBN(0x935c1e48, 0x1ec29487), TOBN(0x9509216c, 0x4d936530)}}, + {{TOBN(0xc7ca3067, 0x85c9a2db), TOBN(0xd6ae5152, 0x6be8606f), + TOBN(0x09dbcae6, 0xe14c651d), TOBN(0xc9536e23, 0x9bc32f96)}, + {TOBN(0xa90535a9, 0x34521b03), TOBN(0xf39c526c, 0x878756ff), + TOBN(0x383172ec, 0x8aedf03c), TOBN(0x20a8075e, 0xefe0c034)}}, + {{TOBN(0xf22f9c62, 0x64026422), TOBN(0x8dd10780, 0x24b9d076), + TOBN(0x944c742a, 0x3bef2950), TOBN(0x55b9502e, 0x88a2b00b)}, + {TOBN(0xa59e14b4, 0x86a09817), TOBN(0xa39dd3ac, 0x47bb4071), + TOBN(0x55137f66, 0x3be0592f), TOBN(0x07fcafd4, 0xc9e63f5b)}}, + {{TOBN(0x963652ee, 0x346eb226), TOBN(0x7dfab085, 0xec2facb7), + TOBN(0x273bf2b8, 0x691add26), TOBN(0x30d74540, 0xf2b46c44)}, + {TOBN(0x05e8e73e, 0xf2c2d065), TOBN(0xff9b8a00, 0xd42eeac9), + TOBN(0x2fcbd205, 0x97209d22), TOBN(0xeb740ffa, 0xde14ea2c)}}, + {{TOBN(0xc71ff913, 0xa8aef518), TOBN(0x7bfc74bb, 0xfff4cfa2), + TOBN(0x1716680c, 0xb6b36048), TOBN(0x121b2cce, 0x9ef79af1)}, + {TOBN(0xbff3c836, 0xa01eb3d3), TOBN(0x50eb1c6a, 0x5f79077b), + TOBN(0xa48c32d6, 0xa004bbcf), TOBN(0x47a59316, 0x7d64f61d)}}, + {{TOBN(0x6068147f, 0x93102016), TOBN(0x12c5f654, 0x94d12576), + TOBN(0xefb071a7, 0xc9bc6b91), TOBN(0x7c2da0c5, 0x6e23ea95)}, + {TOBN(0xf4fd45b6, 0xd4a1dd5d), TOBN(0x3e7ad9b6, 0x9122b13c), + TOBN(0x342ca118, 0xe6f57a48), TOBN(0x1c2e94a7, 0x06f8288f)}}, + {{TOBN(0x99e68f07, 0x5a97d231), TOBN(0x7c80de97, 0x4d838758), + TOBN(0xbce0f5d0, 0x05872727), TOBN(0xbe5d95c2, 0x19c4d016)}, + {TOBN(0x921d5cb1, 0x9c2492ee), TOBN(0x42192dc1, 0x404d6fb3), + TOBN(0x4c84dcd1, 0x32f988d3), TOBN(0xde26d61f, 0xa17b8e85)}}, + {{TOBN(0xc466dcb6, 0x137c7408), TOBN(0x9a38d7b6, 0x36a266da), + TOBN(0x7ef5cb06, 0x83bebf1b), TOBN(0xe5cdcbbf, 0x0fd014e3)}, + {TOBN(0x30aa376d, 0xf65965a0), TOBN(0x60fe88c2, 0xebb3e95e), + TOBN(0x33fd0b61, 0x66ee6f20), TOBN(0x8827dcdb, 0x3f41f0a0)}}, + {{TOBN(0xbf8a9d24, 0x0c56c690), TOBN(0x40265dad, 0xddb7641d), + TOBN(0x522b05bf, 0x3a6b662b), TOBN(0x466d1dfe, 0xb1478c9b)}, + {TOBN(0xaa616962, 0x1484469b), TOBN(0x0db60549, 0x02df8f9f), + TOBN(0xc37bca02, 0x3cb8bf51), TOBN(0x5effe346, 0x21371ce8)}}, + {{TOBN(0xe8f65264, 0xff112c32), TOBN(0x8a9c736d, 0x7b971fb2), + TOBN(0xa4f19470, 0x7b75080d), TOBN(0xfc3f2c5a, 0x8839c59b)}, + {TOBN(0x1d6c777e, 0x5aeb49c2), TOBN(0xf3db034d, 0xda1addfe), + TOBN(0xd76fee5a, 0x5535affc), TOBN(0x0853ac70, 0xb92251fd)}}, + {{TOBN(0x37e3d594, 0x8b2a29d5), TOBN(0x28f1f457, 0x4de00ddb), + TOBN(0x8083c1b5, 0xf42c328b), TOBN(0xd8ef1d8f, 0xe493c73b)}, + {TOBN(0x96fb6260, 0x41dc61bd), TOBN(0xf74e8a9d, 0x27ee2f8a), + TOBN(0x7c605a80, 0x2c946a5d), TOBN(0xeed48d65, 0x3839ccfd)}}, + {{TOBN(0x9894344f, 0x3a29467a), TOBN(0xde81e949, 0xc51eba6d), + TOBN(0xdaea066b, 0xa5e5c2f2), TOBN(0x3fc8a614, 0x08c8c7b3)}, + {TOBN(0x7adff88f, 0x06d0de9f), TOBN(0xbbc11cf5, 0x3b75ce0a), + TOBN(0x9fbb7acc, 0xfbbc87d5), TOBN(0xa1458e26, 0x7badfde2)}}}, + {{{TOBN(0x1cb43668, 0xe039c256), TOBN(0x5f26fb8b, 0x7c17fd5d), + TOBN(0xeee426af, 0x79aa062b), TOBN(0x072002d0, 0xd78fbf04)}, + {TOBN(0x4c9ca237, 0xe84fb7e3), TOBN(0xb401d8a1, 0x0c82133d), + TOBN(0xaaa52592, 0x6d7e4181), TOBN(0xe9430833, 0x73dbb152)}}, + {{TOBN(0xf92dda31, 0xbe24319a), TOBN(0x03f7d28b, 0xe095a8e7), + TOBN(0xa52fe840, 0x98782185), TOBN(0x276ddafe, 0x29c24dbc)}, + {TOBN(0x80cd5496, 0x1d7a64eb), TOBN(0xe4360889, 0x7f1dbe42), + TOBN(0x2f81a877, 0x8438d2d5), TOBN(0x7e4d52a8, 0x85169036)}}, + {{TOBN(0x19e3d5b1, 0x1d59715d), TOBN(0xc7eaa762, 0xd788983e), + TOBN(0xe5a730b0, 0xabf1f248), TOBN(0xfbab8084, 0xfae3fd83)}, + {TOBN(0x65e50d21, 0x53765b2f), TOBN(0xbdd4e083, 0xfa127f3d), + TOBN(0x9cf3c074, 0x397b1b10), TOBN(0x59f8090c, 0xb1b59fd3)}}, + {{TOBN(0x7b15fd9d, 0x615faa8f), TOBN(0x8fa1eb40, 0x968554ed), + TOBN(0x7bb4447e, 0x7aa44882), TOBN(0x2bb2d0d1, 0x029fff32)}, + {TOBN(0x075e2a64, 0x6caa6d2f), TOBN(0x8eb879de, 0x22e7351b), + TOBN(0xbcd5624e, 0x9a506c62), TOBN(0x218eaef0, 0xa87e24dc)}}, + {{TOBN(0x37e56847, 0x44ddfa35), TOBN(0x9ccfc5c5, 0xdab3f747), + TOBN(0x9ac1df3f, 0x1ee96cf4), TOBN(0x0c0571a1, 0x3b480b8f)}, + {TOBN(0x2fbeb3d5, 0x4b3a7b3c), TOBN(0x35c03669, 0x5dcdbb99), + TOBN(0x52a0f5dc, 0xb2415b3a), TOBN(0xd57759b4, 0x4413ed9a)}}, + {{TOBN(0x1fe647d8, 0x3d30a2c5), TOBN(0x0857f77e, 0xf78a81dc), + TOBN(0x11d5a334, 0x131a4a9b), TOBN(0xc0a94af9, 0x29d393f5)}, + {TOBN(0xbc3a5c0b, 0xdaa6ec1a), TOBN(0xba9fe493, 0x88d2d7ed), + TOBN(0xbb4335b4, 0xbb614797), TOBN(0x991c4d68, 0x72f83533)}}, + {{TOBN(0x53258c28, 0xd2f01cb3), TOBN(0x93d6eaa3, 0xd75db0b1), + TOBN(0x419a2b0d, 0xe87d0db4), TOBN(0xa1e48f03, 0xd8fe8493)}, + {TOBN(0xf747faf6, 0xc508b23a), TOBN(0xf137571a, 0x35d53549), + TOBN(0x9f5e58e2, 0xfcf9b838), TOBN(0xc7186cee, 0xa7fd3cf5)}}, + {{TOBN(0x77b868ce, 0xe978a1d3), TOBN(0xe3a68b33, 0x7ab92d04), + TOBN(0x51029794, 0x87a5b862), TOBN(0x5f0606c3, 0x3a61d41d)}, + {TOBN(0x2814be27, 0x6f9326f1), TOBN(0x2f521c14, 0xc6fe3c2e), + TOBN(0x17464d7d, 0xacdf7351), TOBN(0x10f5f9d3, 0x777f7e44)}}, + {{TOBN(0xce8e616b, 0x269fb37d), TOBN(0xaaf73804, 0x7de62de5), + TOBN(0xaba11175, 0x4fdd4153), TOBN(0x515759ba, 0x3770b49b)}, + {TOBN(0x8b09ebf8, 0xaa423a61), TOBN(0x592245a1, 0xcd41fb92), + TOBN(0x1cba8ec1, 0x9b4c8936), TOBN(0xa87e91e3, 0xaf36710e)}}, + {{TOBN(0x1fd84ce4, 0x3d34a2e3), TOBN(0xee3759ce, 0xb43b5d61), + TOBN(0x895bc78c, 0x619186c7), TOBN(0xf19c3809, 0xcbb9725a)}, + {TOBN(0xc0be21aa, 0xde744b1f), TOBN(0xa7d222b0, 0x60f8056b), + TOBN(0x74be6157, 0xb23efe11), TOBN(0x6fab2b4f, 0x0cd68253)}}, + {{TOBN(0xad33ea5f, 0x4bf1d725), TOBN(0x9c1d8ee2, 0x4f6c950f), + TOBN(0x544ee78a, 0xa377af06), TOBN(0x54f489bb, 0x94a113e1)}, + {TOBN(0x8f11d634, 0x992fb7e8), TOBN(0x0169a7aa, 0xa2a44347), + TOBN(0x1d49d4af, 0x95020e00), TOBN(0x95945722, 0xe08e120b)}}, + {{TOBN(0xb6e33878, 0xa4d32282), TOBN(0xe36e029d, 0x48020ae7), + TOBN(0xe05847fb, 0x37a9b750), TOBN(0xf876812c, 0xb29e3819)}, + {TOBN(0x84ad138e, 0xd23a17f0), TOBN(0x6d7b4480, 0xf0b3950e), + TOBN(0xdfa8aef4, 0x2fd67ae0), TOBN(0x8d3eea24, 0x52333af6)}}, + {{TOBN(0x0d052075, 0xb15d5acc), TOBN(0xc6d9c79f, 0xbd815bc4), + TOBN(0x8dcafd88, 0xdfa36cf2), TOBN(0x908ccbe2, 0x38aa9070)}, + {TOBN(0x638722c4, 0xba35afce), TOBN(0x5a3da8b0, 0xfd6abf0b), + TOBN(0x2dce252c, 0xc9c335c1), TOBN(0x84e7f0de, 0x65aa799b)}}, + {{TOBN(0x2101a522, 0xb99a72cb), TOBN(0x06de6e67, 0x87618016), + TOBN(0x5ff8c7cd, 0xe6f3653e), TOBN(0x0a821ab5, 0xc7a6754a)}, + {TOBN(0x7e3fa52b, 0x7cb0b5a2), TOBN(0xa7fb121c, 0xc9048790), + TOBN(0x1a725020, 0x06ce053a), TOBN(0xb490a31f, 0x04e929b0)}}, + {{TOBN(0xe17be47d, 0x62dd61ad), TOBN(0x781a961c, 0x6be01371), + TOBN(0x1063bfd3, 0xdae3cbba), TOBN(0x35647406, 0x7f73c9ba)}, + {TOBN(0xf50e957b, 0x2736a129), TOBN(0xa6313702, 0xed13f256), + TOBN(0x9436ee65, 0x3a19fcc5), TOBN(0xcf2bdb29, 0xe7a4c8b6)}}, + {{TOBN(0xb06b1244, 0xc5f95cd8), TOBN(0xda8c8af0, 0xf4ab95f4), + TOBN(0x1bae59c2, 0xb9e5836d), TOBN(0x07d51e7e, 0x3acffffc)}, + {TOBN(0x01e15e6a, 0xc2ccbcda), TOBN(0x3bc1923f, 0x8528c3e0), + TOBN(0x43324577, 0xa49fead4), TOBN(0x61a1b884, 0x2aa7a711)}}, + {{TOBN(0xf9a86e08, 0x700230ef), TOBN(0x0af585a1, 0xbd19adf8), + TOBN(0x7645f361, 0xf55ad8f2), TOBN(0x6e676223, 0x46c3614c)}, + {TOBN(0x23cb257c, 0x4e774d3f), TOBN(0x82a38513, 0xac102d1b), + TOBN(0x9bcddd88, 0x7b126aa5), TOBN(0xe716998b, 0xeefd3ee4)}}, + {{TOBN(0x4239d571, 0xfb167583), TOBN(0xdd011c78, 0xd16c8f8a), + TOBN(0x271c2895, 0x69a27519), TOBN(0x9ce0a3b7, 0xd2d64b6a)}, + {TOBN(0x8c977289, 0xd5ec6738), TOBN(0xa3b49f9a, 0x8840ef6b), + TOBN(0x808c14c9, 0x9a453419), TOBN(0x5c00295b, 0x0cf0a2d5)}}, + {{TOBN(0x524414fb, 0x1d4bcc76), TOBN(0xb07691d2, 0x459a88f1), + TOBN(0x77f43263, 0xf70d110f), TOBN(0x64ada5e0, 0xb7abf9f3)}, + {TOBN(0xafd0f94e, 0x5b544cf5), TOBN(0xb4a13a15, 0xfd2713fe), + TOBN(0xb99b7d6e, 0x250c74f4), TOBN(0x097f2f73, 0x20324e45)}}, + {{TOBN(0x994b37d8, 0xaffa8208), TOBN(0xc3c31b0b, 0xdc29aafc), + TOBN(0x3da74651, 0x7a3a607f), TOBN(0xd8e1b8c1, 0xfe6955d6)}, + {TOBN(0x716e1815, 0xc8418682), TOBN(0x541d487f, 0x7dc91d97), + TOBN(0x48a04669, 0xc6996982), TOBN(0xf39cab15, 0x83a6502e)}}, + {{TOBN(0x025801a0, 0xe68db055), TOBN(0xf3569758, 0xba3338d5), + TOBN(0xb0c8c0aa, 0xee2afa84), TOBN(0x4f6985d3, 0xfb6562d1)}, + {TOBN(0x351f1f15, 0x132ed17a), TOBN(0x510ed0b4, 0xc04365fe), + TOBN(0xa3f98138, 0xe5b1f066), TOBN(0xbc9d95d6, 0x32df03dc)}}, + {{TOBN(0xa83ccf6e, 0x19abd09e), TOBN(0x0b4097c1, 0x4ff17edb), + TOBN(0x58a5c478, 0xd64a06ce), TOBN(0x2ddcc3fd, 0x544a58fd)}, + {TOBN(0xd449503d, 0x9e8153b8), TOBN(0x3324fd02, 0x7774179b), + TOBN(0xaf5d47c8, 0xdbd9120c), TOBN(0xeb860162, 0x34fa94db)}}, + {{TOBN(0x5817bdd1, 0x972f07f4), TOBN(0xe5579e2e, 0xd27bbceb), + TOBN(0x86847a1f, 0x5f11e5a6), TOBN(0xb39ed255, 0x7c3cf048)}, + {TOBN(0xe1076417, 0xa2f62e55), TOBN(0x6b9ab38f, 0x1bcf82a2), + TOBN(0x4bb7c319, 0x7aeb29f9), TOBN(0xf6d17da3, 0x17227a46)}}, + {{TOBN(0xab53ddbd, 0x0f968c00), TOBN(0xa03da7ec, 0x000c880b), + TOBN(0x7b239624, 0x6a9ad24d), TOBN(0x612c0401, 0x01ec60d0)}, + {TOBN(0x70d10493, 0x109f5df1), TOBN(0xfbda4030, 0x80af7550), + TOBN(0x30b93f95, 0xc6b9a9b3), TOBN(0x0c74ec71, 0x007d9418)}}, + {{TOBN(0x94175564, 0x6edb951f), TOBN(0x5f4a9d78, 0x7f22c282), + TOBN(0xb7870895, 0xb38d1196), TOBN(0xbc593df3, 0xa228ce7c)}, + {TOBN(0xc78c5bd4, 0x6af3641a), TOBN(0x7802200b, 0x3d9b3dcc), + TOBN(0x0dc73f32, 0x8be33304), TOBN(0x847ed87d, 0x61ffb79a)}}, + {{TOBN(0xf85c974e, 0x6d671192), TOBN(0x1e14100a, 0xde16f60f), + TOBN(0x45cb0d5a, 0x95c38797), TOBN(0x18923bba, 0x9b022da4)}, + {TOBN(0xef2be899, 0xbbe7e86e), TOBN(0x4a1510ee, 0x216067bf), + TOBN(0xd98c8154, 0x84d5ce3e), TOBN(0x1af777f0, 0xf92a2b90)}}, + {{TOBN(0x9fbcb400, 0x4ef65724), TOBN(0x3e04a4c9, 0x3c0ca6fe), + TOBN(0xfb3e2cb5, 0x55002994), TOBN(0x1f3a93c5, 0x5363ecab)}, + {TOBN(0x1fe00efe, 0x3923555b), TOBN(0x744bedd9, 0x1e1751ea), + TOBN(0x3fb2db59, 0x6ab69357), TOBN(0x8dbd7365, 0xf5e6618b)}}, + {{TOBN(0x99d53099, 0xdf1ea40e), TOBN(0xb3f24a0b, 0x57d61e64), + TOBN(0xd088a198, 0x596eb812), TOBN(0x22c8361b, 0x5762940b)}, + {TOBN(0x66f01f97, 0xf9c0d95c), TOBN(0x88461172, 0x8e43cdae), + TOBN(0x11599a7f, 0xb72b15c3), TOBN(0x135a7536, 0x420d95cc)}}, + {{TOBN(0x2dcdf0f7, 0x5f7ae2f6), TOBN(0x15fc6e1d, 0xd7fa6da2), + TOBN(0x81ca829a, 0xd1d441b6), TOBN(0x84c10cf8, 0x04a106b6)}, + {TOBN(0xa9b26c95, 0xa73fbbd0), TOBN(0x7f24e0cb, 0x4d8f6ee8), + TOBN(0x48b45937, 0x1e25a043), TOBN(0xf8a74fca, 0x036f3dfe)}}, + {{TOBN(0x1ed46585, 0xc9f84296), TOBN(0x7fbaa8fb, 0x3bc278b0), + TOBN(0xa8e96cd4, 0x6c4fcbd0), TOBN(0x940a1202, 0x73b60a5f)}, + {TOBN(0x34aae120, 0x55a4aec8), TOBN(0x550e9a74, 0xdbd742f0), + TOBN(0x794456d7, 0x228c68ab), TOBN(0x492f8868, 0xa4e25ec6)}}, + {{TOBN(0x682915ad, 0xb2d8f398), TOBN(0xf13b51cc, 0x5b84c953), + TOBN(0xcda90ab8, 0x5bb917d6), TOBN(0x4b615560, 0x4ea3dee1)}, + {TOBN(0x578b4e85, 0x0a52c1c8), TOBN(0xeab1a695, 0x20b75fc4), + TOBN(0x60c14f3c, 0xaa0bb3c6), TOBN(0x220f448a, 0xb8216094)}}, + {{TOBN(0x4fe7ee31, 0xb0e63d34), TOBN(0xf4600572, 0xa9e54fab), + TOBN(0xc0493334, 0xd5e7b5a4), TOBN(0x8589fb92, 0x06d54831)}, + {TOBN(0xaa70f5cc, 0x6583553a), TOBN(0x0879094a, 0xe25649e5), + TOBN(0xcc904507, 0x10044652), TOBN(0xebb0696d, 0x02541c4f)}}, + {{TOBN(0x5a171fde, 0xb9718710), TOBN(0x38f1bed8, 0xf374a9f5), + TOBN(0xc8c582e1, 0xba39bdc1), TOBN(0xfc457b0a, 0x908cc0ce)}, + {TOBN(0x9a187fd4, 0x883841e2), TOBN(0x8ec25b39, 0x38725381), + TOBN(0x2553ed05, 0x96f84395), TOBN(0x095c7661, 0x6f6c6897)}}, + {{TOBN(0x917ac85c, 0x4bdc5610), TOBN(0xb2885fe4, 0x179eb301), + TOBN(0x5fc65547, 0x8b78bdcc), TOBN(0x4a9fc893, 0xe59e4699)}, + {TOBN(0xbb7ff0cd, 0x3ce299af), TOBN(0x195be9b3, 0xadf38b20), + TOBN(0x6a929c87, 0xd38ddb8f), TOBN(0x55fcc99c, 0xb21a51b9)}}, + {{TOBN(0x2b695b4c, 0x721a4593), TOBN(0xed1e9a15, 0x768eaac2), + TOBN(0xfb63d71c, 0x7489f914), TOBN(0xf98ba31c, 0x78118910)}, + {TOBN(0x80291373, 0x9b128eb4), TOBN(0x7801214e, 0xd448af4a), + TOBN(0xdbd2e22b, 0x55418dd3), TOBN(0xeffb3c0d, 0xd3998242)}}, + {{TOBN(0xdfa6077c, 0xc7bf3827), TOBN(0xf2165bcb, 0x47f8238f), + TOBN(0xfe37cf68, 0x8564d554), TOBN(0xe5f825c4, 0x0a81fb98)}, + {TOBN(0x43cc4f67, 0xffed4d6f), TOBN(0xbc609578, 0xb50a34b0), + TOBN(0x8aa8fcf9, 0x5041faf1), TOBN(0x5659f053, 0x651773b6)}}, + {{TOBN(0xe87582c3, 0x6044d63b), TOBN(0xa6089409, 0x0cdb0ca0), + TOBN(0x8c993e0f, 0xbfb2bcf6), TOBN(0xfc64a719, 0x45985cfc)}, + {TOBN(0x15c4da80, 0x83dbedba), TOBN(0x804ae112, 0x2be67df7), + TOBN(0xda4c9658, 0xa23defde), TOBN(0x12002ddd, 0x5156e0d3)}}, + {{TOBN(0xe68eae89, 0x5dd21b96), TOBN(0x8b99f28b, 0xcf44624d), + TOBN(0x0ae00808, 0x1ec8897a), TOBN(0xdd0a9303, 0x6712f76e)}, + {TOBN(0x96237522, 0x4e233de4), TOBN(0x192445b1, 0x2b36a8a5), + TOBN(0xabf9ff74, 0x023993d9), TOBN(0x21f37bf4, 0x2aad4a8f)}}, + {{TOBN(0x340a4349, 0xf8bd2bbd), TOBN(0x1d902cd9, 0x4868195d), + TOBN(0x3d27bbf1, 0xe5fdb6f1), TOBN(0x7a5ab088, 0x124f9f1c)}, + {TOBN(0xc466ab06, 0xf7a09e03), TOBN(0x2f8a1977, 0x31f2c123), + TOBN(0xda355dc7, 0x041b6657), TOBN(0xcb840d12, 0x8ece2a7c)}}, + {{TOBN(0xb600ad9f, 0x7db32675), TOBN(0x78fea133, 0x07a06f1b), + TOBN(0x5d032269, 0xb31f6094), TOBN(0x07753ef5, 0x83ec37aa)}, + {TOBN(0x03485aed, 0x9c0bea78), TOBN(0x41bb3989, 0xbc3f4524), + TOBN(0x09403761, 0x697f726d), TOBN(0x6109beb3, 0xdf394820)}}, + {{TOBN(0x804111ea, 0x3b6d1145), TOBN(0xb6271ea9, 0xa8582654), + TOBN(0x619615e6, 0x24e66562), TOBN(0xa2554945, 0xd7b6ad9c)}, + {TOBN(0xd9c4985e, 0x99bfe35f), TOBN(0x9770ccc0, 0x7b51cdf6), + TOBN(0x7c327013, 0x92881832), TOBN(0x8777d45f, 0x286b26d1)}}, + {{TOBN(0x9bbeda22, 0xd847999d), TOBN(0x03aa33b6, 0xc3525d32), + TOBN(0x4b7b96d4, 0x28a959a1), TOBN(0xbb3786e5, 0x31e5d234)}, + {TOBN(0xaeb5d3ce, 0x6961f247), TOBN(0x20aa85af, 0x02f93d3f), + TOBN(0x9cd1ad3d, 0xd7a7ae4f), TOBN(0xbf6688f0, 0x781adaa8)}}, + {{TOBN(0xb1b40e86, 0x7469cead), TOBN(0x1904c524, 0x309fca48), + TOBN(0x9b7312af, 0x4b54bbc7), TOBN(0xbe24bf8f, 0x593affa2)}, + {TOBN(0xbe5e0790, 0xbd98764b), TOBN(0xa0f45f17, 0xa26e299e), + TOBN(0x4af0d2c2, 0x6b8fe4c7), TOBN(0xef170db1, 0x8ae8a3e6)}}, + {{TOBN(0x0e8d61a0, 0x29e0ccc1), TOBN(0xcd53e87e, 0x60ad36ca), + TOBN(0x328c6623, 0xc8173822), TOBN(0x7ee1767d, 0xa496be55)}, + {TOBN(0x89f13259, 0x648945af), TOBN(0x9e45a5fd, 0x25c8009c), + TOBN(0xaf2febd9, 0x1f61ab8c), TOBN(0x43f6bc86, 0x8a275385)}}, + {{TOBN(0x87792348, 0xf2142e79), TOBN(0x17d89259, 0xc6e6238a), + TOBN(0x7536d2f6, 0x4a839d9b), TOBN(0x1f428fce, 0x76a1fbdc)}, + {TOBN(0x1c109601, 0x0db06dfe), TOBN(0xbfc16bc1, 0x50a3a3cc), + TOBN(0xf9cbd9ec, 0x9b30f41b), TOBN(0x5b5da0d6, 0x00138cce)}}, + {{TOBN(0xec1d0a48, 0x56ef96a7), TOBN(0xb47eb848, 0x982bf842), + TOBN(0x66deae32, 0xec3f700d), TOBN(0x4e43c42c, 0xaa1181e0)}, + {TOBN(0xa1d72a31, 0xd1a4aa2a), TOBN(0x440d4668, 0xc004f3ce), + TOBN(0x0d6a2d3b, 0x45fe8a7a), TOBN(0x820e52e2, 0xfb128365)}}, + {{TOBN(0x29ac5fcf, 0x25e51b09), TOBN(0x180cd2bf, 0x2023d159), + TOBN(0xa9892171, 0xa1ebf90e), TOBN(0xf97c4c87, 0x7c132181)}, + {TOBN(0x9f1dc724, 0xc03dbb7e), TOBN(0xae043765, 0x018cbbe4), + TOBN(0xfb0b2a36, 0x0767d153), TOBN(0xa8e2f4d6, 0x249cbaeb)}}, + {{TOBN(0x172a5247, 0xd95ea168), TOBN(0x1758fada, 0x2970764a), + TOBN(0xac803a51, 0x1d978169), TOBN(0x299cfe2e, 0xde77e01b)}, + {TOBN(0x652a1e17, 0xb0a98927), TOBN(0x2e26e1d1, 0x20014495), + TOBN(0x7ae0af9f, 0x7175b56a), TOBN(0xc2e22a80, 0xd64b9f95)}}, + {{TOBN(0x4d0ff9fb, 0xd90a060a), TOBN(0x496a27db, 0xbaf38085), + TOBN(0x32305401, 0xda776bcf), TOBN(0xb8cdcef6, 0x725f209e)}, + {TOBN(0x61ba0f37, 0x436a0bba), TOBN(0x263fa108, 0x76860049), + TOBN(0x92beb98e, 0xda3542cf), TOBN(0xa2d4d14a, 0xd5849538)}}, + {{TOBN(0x989b9d68, 0x12e9a1bc), TOBN(0x61d9075c, 0x5f6e3268), + TOBN(0x352c6aa9, 0x99ace638), TOBN(0xde4e4a55, 0x920f43ff)}, + {TOBN(0xe5e4144a, 0xd673c017), TOBN(0x667417ae, 0x6f6e05ea), + TOBN(0x613416ae, 0xdcd1bd56), TOBN(0x5eb36201, 0x86693711)}}, + {{TOBN(0x2d7bc504, 0x3a1aa914), TOBN(0x175a1299, 0x76dc5975), + TOBN(0xe900e0f2, 0x3fc8125c), TOBN(0x569ef68c, 0x11198875)}, + {TOBN(0x9012db63, 0x63a113b4), TOBN(0xe3bd3f56, 0x98835766), + TOBN(0xa5c94a52, 0x76412dea), TOBN(0xad9e2a09, 0xaa735e5c)}}, + {{TOBN(0x405a984c, 0x508b65e9), TOBN(0xbde4a1d1, 0x6df1a0d1), + TOBN(0x1a9433a1, 0xdfba80da), TOBN(0xe9192ff9, 0x9440ad2e)}, + {TOBN(0x9f649696, 0x5099fe92), TOBN(0x25ddb65c, 0x0b27a54a), + TOBN(0x178279dd, 0xc590da61), TOBN(0x5479a999, 0xfbde681a)}}, + {{TOBN(0xd0e84e05, 0x013fe162), TOBN(0xbe11dc92, 0x632d471b), + TOBN(0xdf0b0c45, 0xfc0e089f), TOBN(0x04fb15b0, 0x4c144025)}, + {TOBN(0xa61d5fc2, 0x13c99927), TOBN(0xa033e9e0, 0x3de2eb35), + TOBN(0xf8185d5c, 0xb8dacbb4), TOBN(0x9a88e265, 0x8644549d)}}, + {{TOBN(0xf717af62, 0x54671ff6), TOBN(0x4bd4241b, 0x5fa58603), + TOBN(0x06fba40b, 0xe67773c0), TOBN(0xc1d933d2, 0x6a2847e9)}, + {TOBN(0xf4f5acf3, 0x689e2c70), TOBN(0x92aab0e7, 0x46bafd31), + TOBN(0x798d76aa, 0x3473f6e5), TOBN(0xcc6641db, 0x93141934)}}, + {{TOBN(0xcae27757, 0xd31e535e), TOBN(0x04cc43b6, 0x87c2ee11), + TOBN(0x8d1f9675, 0x2e029ffa), TOBN(0xc2150672, 0xe4cc7a2c)}, + {TOBN(0x3b03c1e0, 0x8d68b013), TOBN(0xa9d6816f, 0xedf298f3), + TOBN(0x1bfbb529, 0xa2804464), TOBN(0x95a52fae, 0x5db22125)}}, + {{TOBN(0x55b32160, 0x0e1cb64e), TOBN(0x004828f6, 0x7e7fc9fe), + TOBN(0x13394b82, 0x1bb0fb93), TOBN(0xb6293a2d, 0x35f1a920)}, + {TOBN(0xde35ef21, 0xd145d2d9), TOBN(0xbe6225b3, 0xbb8fa603), + TOBN(0x00fc8f6b, 0x32cf252d), TOBN(0xa28e52e6, 0x117cf8c2)}}, + {{TOBN(0x9d1dc89b, 0x4c371e6d), TOBN(0xcebe0675, 0x36ef0f28), + TOBN(0x5de05d09, 0xa4292f81), TOBN(0xa8303593, 0x353e3083)}, + {TOBN(0xa1715b0a, 0x7e37a9bb), TOBN(0x8c56f61e, 0x2b8faec3), + TOBN(0x52507431, 0x33c9b102), TOBN(0x0130cefc, 0xa44431f0)}}, + {{TOBN(0x56039fa0, 0xbd865cfb), TOBN(0x4b03e578, 0xbc5f1dd7), + TOBN(0x40edf2e4, 0xbabe7224), TOBN(0xc752496d, 0x3a1988f6)}, + {TOBN(0xd1572d3b, 0x564beb6b), TOBN(0x0db1d110, 0x39a1c608), + TOBN(0x568d1934, 0x16f60126), TOBN(0x05ae9668, 0xf354af33)}}, + {{TOBN(0x19de6d37, 0xc92544f2), TOBN(0xcc084353, 0xa35837d5), + TOBN(0xcbb6869c, 0x1a514ece), TOBN(0xb633e728, 0x2e1d1066)}, + {TOBN(0xf15dd69f, 0x936c581c), TOBN(0x96e7b8ce, 0x7439c4f9), + TOBN(0x5e676f48, 0x2e448a5b), TOBN(0xb2ca7d5b, 0xfd916bbb)}}, + {{TOBN(0xd55a2541, 0xf5024025), TOBN(0x47bc5769, 0xe4c2d937), + TOBN(0x7d31b92a, 0x0362189f), TOBN(0x83f3086e, 0xef7816f9)}, + {TOBN(0xf9f46d94, 0xb587579a), TOBN(0xec2d22d8, 0x30e76c5f), + TOBN(0x27d57461, 0xb000ffcf), TOBN(0xbb7e65f9, 0x364ffc2c)}}, + {{TOBN(0x7c7c9477, 0x6652a220), TOBN(0x61618f89, 0xd696c981), + TOBN(0x5021701d, 0x89effff3), TOBN(0xf2c8ff8e, 0x7c314163)}, + {TOBN(0x2da413ad, 0x8efb4d3e), TOBN(0x937b5adf, 0xce176d95), + TOBN(0x22867d34, 0x2a67d51c), TOBN(0x262b9b10, 0x18eb3ac9)}}, + {{TOBN(0x4e314fe4, 0xc43ff28b), TOBN(0x76476627, 0x6a664e7a), + TOBN(0x3e90e40b, 0xb7a565c2), TOBN(0x8588993a, 0xc1acf831)}, + {TOBN(0xd7b501d6, 0x8f938829), TOBN(0x996627ee, 0x3edd7d4c), + TOBN(0x37d44a62, 0x90cd34c7), TOBN(0xa8327499, 0xf3833e8d)}}, + {{TOBN(0x2e18917d, 0x4bf50353), TOBN(0x85dd726b, 0x556765fb), + TOBN(0x54fe65d6, 0x93d5ab66), TOBN(0x3ddbaced, 0x915c25fe)}, + {TOBN(0xa799d9a4, 0x12f22e85), TOBN(0xe2a24867, 0x6d06f6bc), + TOBN(0xf4f1ee56, 0x43ca1637), TOBN(0xfda2828b, 0x61ece30a)}}, + {{TOBN(0x758c1a3e, 0xa2dee7a6), TOBN(0xdcde2f3c, 0x734b2284), + TOBN(0xaba445d2, 0x4eaba6ad), TOBN(0x35aaf668, 0x76cee0a7)}, + {TOBN(0x7e0b04a9, 0xe5aa049a), TOBN(0xe74083ad, 0x91103e84), + TOBN(0xbeb183ce, 0x40afecc3), TOBN(0x6b89de9f, 0xea043f7a)}}}, + {{{TOBN(0x0e299d23, 0xfe67ba66), TOBN(0x91450760, 0x93cf2f34), + TOBN(0xf45b5ea9, 0x97fcf913), TOBN(0x5be00843, 0x8bd7ddda)}, + {TOBN(0x358c3e05, 0xd53ff04d), TOBN(0xbf7ccdc3, 0x5de91ef7), + TOBN(0xad684dbf, 0xb69ec1a0), TOBN(0x367e7cf2, 0x801fd997)}}, + {{TOBN(0x0ca1f3b7, 0xb0dc8595), TOBN(0x27de4608, 0x9f1d9f2e), + TOBN(0x1af3bf39, 0xbadd82a7), TOBN(0x79356a79, 0x65862448)}, + {TOBN(0xc0602345, 0xf5f9a052), TOBN(0x1a8b0f89, 0x139a42f9), + TOBN(0xb53eee42, 0x844d40fc), TOBN(0x93b0bfe5, 0x4e5b6368)}}, + {{TOBN(0x5434dd02, 0xc024789c), TOBN(0x90dca9ea, 0x41b57bfc), + TOBN(0x8aa898e2, 0x243398df), TOBN(0xf607c834, 0x894a94bb)}, + {TOBN(0xbb07be97, 0xc2c99b76), TOBN(0x6576ba67, 0x18c29302), + TOBN(0x3d79efcc, 0xe703a88c), TOBN(0xf259ced7, 0xb6a0d106)}}, + {{TOBN(0x0f893a5d, 0xc8de610b), TOBN(0xe8c515fb, 0x67e223ce), + TOBN(0x7774bfa6, 0x4ead6dc5), TOBN(0x89d20f95, 0x925c728f)}, + {TOBN(0x7a1e0966, 0x098583ce), TOBN(0xa2eedb94, 0x93f2a7d7), + TOBN(0x1b282097, 0x4c304d4a), TOBN(0x0842e3da, 0xc077282d)}}, + {{TOBN(0xe4d972a3, 0x3b9e2d7b), TOBN(0x7cc60b27, 0xc48218ff), + TOBN(0x8fc70838, 0x84149d91), TOBN(0x5c04346f, 0x2f461ecc)}, + {TOBN(0xebe9fdf2, 0x614650a9), TOBN(0x5e35b537, 0xc1f666ac), + TOBN(0x645613d1, 0x88babc83), TOBN(0x88cace3a, 0xc5e1c93e)}}, + {{TOBN(0x209ca375, 0x3de92e23), TOBN(0xccb03cc8, 0x5fbbb6e3), + TOBN(0xccb90f03, 0xd7b1487e), TOBN(0xfa9c2a38, 0xc710941f)}, + {TOBN(0x756c3823, 0x6724ceed), TOBN(0x3a902258, 0x192d0323), + TOBN(0xb150e519, 0xea5e038e), TOBN(0xdcba2865, 0xc7427591)}}, + {{TOBN(0xe549237f, 0x78890732), TOBN(0xc443bef9, 0x53fcb4d9), + TOBN(0x9884d8a6, 0xeb3480d6), TOBN(0x8a35b6a1, 0x3048b186)}, + {TOBN(0xb4e44716, 0x65e9a90a), TOBN(0x45bf380d, 0x653006c0), + TOBN(0x8f3f820d, 0x4fe9ae3b), TOBN(0x244a35a0, 0x979a3b71)}}, + {{TOBN(0xa1010e9d, 0x74cd06ff), TOBN(0x9c17c7df, 0xaca3eeac), + TOBN(0x74c86cd3, 0x8063aa2b), TOBN(0x8595c4b3, 0x734614ff)}, + {TOBN(0xa3de00ca, 0x990f62cc), TOBN(0xd9bed213, 0xca0c3be5), + TOBN(0x7886078a, 0xdf8ce9f5), TOBN(0xddb27ce3, 0x5cd44444)}}, + {{TOBN(0xed374a66, 0x58926ddd), TOBN(0x138b2d49, 0x908015b8), + TOBN(0x886c6579, 0xde1f7ab8), TOBN(0x888b9aa0, 0xc3020b7a)}, + {TOBN(0xd3ec034e, 0x3a96e355), TOBN(0xba65b0b8, 0xf30fbe9a), + TOBN(0x064c8e50, 0xff21367a), TOBN(0x1f508ea4, 0x0b04b46e)}}, + {{TOBN(0x98561a49, 0x747c866c), TOBN(0xbbb1e5fe, 0x0518a062), + TOBN(0x20ff4e8b, 0xecdc3608), TOBN(0x7f55cded, 0x20184027)}, + {TOBN(0x8d73ec95, 0xf38c85f0), TOBN(0x5b589fdf, 0x8bc3b8c3), + TOBN(0xbe95dd98, 0x0f12b66f), TOBN(0xf5bd1a09, 0x0e338e01)}}, + {{TOBN(0x65163ae5, 0x5e915918), TOBN(0x6158d6d9, 0x86f8a46b), + TOBN(0x8466b538, 0xeeebf99c), TOBN(0xca8761f6, 0xbca477ef)}, + {TOBN(0xaf3449c2, 0x9ebbc601), TOBN(0xef3b0f41, 0xe0c3ae2f), + TOBN(0xaa6c577d, 0x5de63752), TOBN(0xe9166601, 0x64682a51)}}, + {{TOBN(0x5a3097be, 0xfc15aa1e), TOBN(0x40d12548, 0xb54b0745), + TOBN(0x5bad4706, 0x519a5f12), TOBN(0xed03f717, 0xa439dee6)}, + {TOBN(0x0794bb6c, 0x4a02c499), TOBN(0xf725083d, 0xcffe71d2), + TOBN(0x2cad7519, 0x0f3adcaf), TOBN(0x7f68ea1c, 0x43729310)}}, + {{TOBN(0xe747c8c7, 0xb7ffd977), TOBN(0xec104c35, 0x80761a22), + TOBN(0x8395ebaf, 0x5a3ffb83), TOBN(0xfb3261f4, 0xe4b63db7)}, + {TOBN(0x53544960, 0xd883e544), TOBN(0x13520d70, 0x8cc2eeb8), + TOBN(0x08f6337b, 0xd3d65f99), TOBN(0x83997db2, 0x781cf95b)}}, + {{TOBN(0xce6ff106, 0x0dbd2c01), TOBN(0x4f8eea6b, 0x1f9ce934), + TOBN(0x546f7c4b, 0x0e993921), TOBN(0x6236a324, 0x5e753fc7)}, + {TOBN(0x65a41f84, 0xa16022e9), TOBN(0x0c18d878, 0x43d1dbb2), + TOBN(0x73c55640, 0x2d4cef9c), TOBN(0xa0428108, 0x70444c74)}}, + {{TOBN(0x68e4f15e, 0x9afdfb3c), TOBN(0x49a56143, 0x5bdfb6df), + TOBN(0xa9bc1bd4, 0x5f823d97), TOBN(0xbceb5970, 0xea111c2a)}, + {TOBN(0x366b455f, 0xb269bbc4), TOBN(0x7cd85e1e, 0xe9bc5d62), + TOBN(0xc743c41c, 0x4f18b086), TOBN(0xa4b40990, 0x95294fb9)}}, + {{TOBN(0x9c7c581d, 0x26ee8382), TOBN(0xcf17dcc5, 0x359d638e), + TOBN(0xee8273ab, 0xb728ae3d), TOBN(0x1d112926, 0xf821f047)}, + {TOBN(0x11498477, 0x50491a74), TOBN(0x687fa761, 0xfde0dfb9), + TOBN(0x2c258022, 0x7ea435ab), TOBN(0x6b8bdb94, 0x91ce7e3f)}}, + {{TOBN(0x4c5b5dc9, 0x3bf834aa), TOBN(0x04371819, 0x4f6c7e4b), + TOBN(0xc284e00a, 0x3736bcad), TOBN(0x0d881118, 0x21ae8f8d)}, + {TOBN(0xf9cf0f82, 0xf48c8e33), TOBN(0xa11fd075, 0xa1bf40db), + TOBN(0xdceab0de, 0xdc2733e5), TOBN(0xc560a8b5, 0x8e986bd7)}}, + {{TOBN(0x48dd1fe2, 0x3929d097), TOBN(0x3885b290, 0x92f188f1), + TOBN(0x0f2ae613, 0xda6fcdac), TOBN(0x9054303e, 0xb662a46c)}, + {TOBN(0xb6871e44, 0x0738042a), TOBN(0x98e6a977, 0xbdaf6449), + TOBN(0xd8bc0650, 0xd1c9df1b), TOBN(0xef3d6451, 0x36e098f9)}}, + {{TOBN(0x03fbae82, 0xb6d72d28), TOBN(0x77ca9db1, 0xf5d84080), + TOBN(0x8a112cff, 0xa58efc1c), TOBN(0x518d761c, 0xc564cb4a)}, + {TOBN(0x69b5740e, 0xf0d1b5ce), TOBN(0x717039cc, 0xe9eb1785), + TOBN(0x3fe29f90, 0x22f53382), TOBN(0x8e54ba56, 0x6bc7c95c)}}, + {{TOBN(0x9c806d8a, 0xf7f91d0f), TOBN(0x3b61b0f1, 0xa82a5728), + TOBN(0x4640032d, 0x94d76754), TOBN(0x273eb5de, 0x47d834c6)}, + {TOBN(0x2988abf7, 0x7b4e4d53), TOBN(0xb7ce66bf, 0xde401777), + TOBN(0x9fba6b32, 0x715071b3), TOBN(0x82413c24, 0xad3a1a98)}}, + {{TOBN(0x5b7fc8c4, 0xe0e8ad93), TOBN(0xb5679aee, 0x5fab868d), + TOBN(0xb1f9d2fa, 0x2b3946f3), TOBN(0x458897dc, 0x5685b50a)}, + {TOBN(0x1e98c930, 0x89d0caf3), TOBN(0x39564c5f, 0x78642e92), + TOBN(0x1b77729a, 0x0dbdaf18), TOBN(0xf9170722, 0x579e82e6)}}, + {{TOBN(0x680c0317, 0xe4515fa5), TOBN(0xf85cff84, 0xfb0c790f), + TOBN(0xc7a82aab, 0x6d2e0765), TOBN(0x7446bca9, 0x35c82b32)}, + {TOBN(0x5de607aa, 0x6d63184f), TOBN(0x7c1a46a8, 0x262803a6), + TOBN(0xd218313d, 0xaebe8035), TOBN(0x92113ffd, 0xc73c51f8)}}, + {{TOBN(0x4b38e083, 0x12e7e46c), TOBN(0x69d0a37a, 0x56126bd5), + TOBN(0xfb3f324b, 0x73c07e04), TOBN(0xa0c22f67, 0x8fda7267)}, + {TOBN(0x8f2c0051, 0x4d2c7d8f), TOBN(0xbc45ced3, 0xcbe2cae5), + TOBN(0xe1c6cf07, 0xa8f0f277), TOBN(0xbc392312, 0x1eb99a98)}}, + {{TOBN(0x75537b7e, 0x3cc8ac85), TOBN(0x8d725f57, 0xdd02753b), + TOBN(0xfd05ff64, 0xb737df2f), TOBN(0x55fe8712, 0xf6d2531d)}, + {TOBN(0x57ce04a9, 0x6ab6b01c), TOBN(0x69a02a89, 0x7cd93724), + TOBN(0x4f82ac35, 0xcf86699b), TOBN(0x8242d3ad, 0x9cb4b232)}}, + {{TOBN(0x713d0f65, 0xd62105e5), TOBN(0xbb222bfa, 0x2d29be61), + TOBN(0xf2f9a79e, 0x6cfbef09), TOBN(0xfc24d8d3, 0xd5d6782f)}, + {TOBN(0x5db77085, 0xd4129967), TOBN(0xdb81c3cc, 0xdc3c2a43), + TOBN(0x9d655fc0, 0x05d8d9a3), TOBN(0x3f5d057a, 0x54298026)}}, + {{TOBN(0x1157f56d, 0x88c54694), TOBN(0xb26baba5, 0x9b09573e), + TOBN(0x2cab03b0, 0x22adffd1), TOBN(0x60a412c8, 0xdd69f383)}, + {TOBN(0xed76e98b, 0x54b25039), TOBN(0xd4ee67d3, 0x687e714d), + TOBN(0x87739648, 0x7b00b594), TOBN(0xce419775, 0xc9ef709b)}}, + {{TOBN(0x40f76f85, 0x1c203a40), TOBN(0x30d352d6, 0xeafd8f91), + TOBN(0xaf196d3d, 0x95578dd2), TOBN(0xea4bb3d7, 0x77cc3f3d)}, + {TOBN(0x42a5bd03, 0xb98e782b), TOBN(0xac958c40, 0x0624920d), + TOBN(0xb838134c, 0xfc56fcc8), TOBN(0x86ec4ccf, 0x89572e5e)}}, + {{TOBN(0x69c43526, 0x9be47be0), TOBN(0x323b7dd8, 0xcb28fea1), + TOBN(0xfa5538ba, 0x3a6c67e5), TOBN(0xef921d70, 0x1d378e46)}, + {TOBN(0xf92961fc, 0x3c4b880e), TOBN(0x3f6f914e, 0x98940a67), + TOBN(0xa990eb0a, 0xfef0ff39), TOBN(0xa6c2920f, 0xf0eeff9c)}}, + {{TOBN(0xca804166, 0x51b8d9a3), TOBN(0x42531bc9, 0x0ffb0db1), + TOBN(0x72ce4718, 0xaa82e7ce), TOBN(0x6e199913, 0xdf574741)}, + {TOBN(0xd5f1b13d, 0xd5d36946), TOBN(0x8255dc65, 0xf68f0194), + TOBN(0xdc9df4cd, 0x8710d230), TOBN(0x3453c20f, 0x138c1988)}}, + {{TOBN(0x9af98dc0, 0x89a6ef01), TOBN(0x4dbcc3f0, 0x9857df85), + TOBN(0x34805601, 0x5c1ad924), TOBN(0x40448da5, 0xd0493046)}, + {TOBN(0xf629926d, 0x4ee343e2), TOBN(0x6343f1bd, 0x90e8a301), + TOBN(0xefc93491, 0x40815b3f), TOBN(0xf882a423, 0xde8f66fb)}}, + {{TOBN(0x3a12d5f4, 0xe7db9f57), TOBN(0x7dfba38a, 0x3c384c27), + TOBN(0x7a904bfd, 0x6fc660b1), TOBN(0xeb6c5db3, 0x2773b21c)}, + {TOBN(0xc350ee66, 0x1cdfe049), TOBN(0x9baac0ce, 0x44540f29), + TOBN(0xbc57b6ab, 0xa5ec6aad), TOBN(0x167ce8c3, 0x0a7c1baa)}}, + {{TOBN(0xb23a03a5, 0x53fb2b56), TOBN(0x6ce141e7, 0x4e057f78), + TOBN(0x796525c3, 0x89e490d9), TOBN(0x0bc95725, 0xa31a7e75)}, + {TOBN(0x1ec56791, 0x1220fd06), TOBN(0x716e3a3c, 0x408b0bd6), + TOBN(0x31cd6bf7, 0xe8ebeba9), TOBN(0xa7326ca6, 0xbee6b670)}}, + {{TOBN(0x3d9f851c, 0xcd090c43), TOBN(0x561e8f13, 0xf12c3988), + TOBN(0x50490b6a, 0x904b7be4), TOBN(0x61690ce1, 0x0410737b)}, + {TOBN(0x299e9a37, 0x0f009052), TOBN(0x258758f0, 0xf026092e), + TOBN(0x9fa255f3, 0xfdfcdc0f), TOBN(0xdbc9fb1f, 0xc0e1bcd2)}}, + {{TOBN(0x35f9dd6e, 0x24651840), TOBN(0xdca45a84, 0xa5c59abc), + TOBN(0x103d396f, 0xecca4938), TOBN(0x4532da0a, 0xb97b3f29)}, + {TOBN(0xc4135ea5, 0x1999a6bf), TOBN(0x3aa9505a, 0x5e6bf2ee), + TOBN(0xf77cef06, 0x3f5be093), TOBN(0x97d1a0f8, 0xa943152e)}}, + {{TOBN(0x2cb0ebba, 0x2e1c21dd), TOBN(0xf41b29fc, 0x2c6797c4), + TOBN(0xc6e17321, 0xb300101f), TOBN(0x4422b0e9, 0xd0d79a89)}, + {TOBN(0x49e4901c, 0x92f1bfc4), TOBN(0x06ab1f8f, 0xe1e10ed9), + TOBN(0x84d35577, 0xdb2926b8), TOBN(0xca349d39, 0x356e8ec2)}}, + {{TOBN(0x70b63d32, 0x343bf1a9), TOBN(0x8fd3bd28, 0x37d1a6b1), + TOBN(0x0454879c, 0x316865b4), TOBN(0xee959ff6, 0xc458efa2)}, + {TOBN(0x0461dcf8, 0x9706dc3f), TOBN(0x737db0e2, 0x164e4b2e), + TOBN(0x09262680, 0x2f8843c8), TOBN(0x54498bbc, 0x7745e6f6)}}, + {{TOBN(0x359473fa, 0xa29e24af), TOBN(0xfcc3c454, 0x70aa87a1), + TOBN(0xfd2c4bf5, 0x00573ace), TOBN(0xb65b514e, 0x28dd1965)}, + {TOBN(0xe46ae7cf, 0x2193e393), TOBN(0x60e9a4e1, 0xf5444d97), + TOBN(0xe7594e96, 0x00ff38ed), TOBN(0x43d84d2f, 0x0a0e0f02)}}, + {{TOBN(0x8b6db141, 0xee398a21), TOBN(0xb88a56ae, 0xe3bcc5be), + TOBN(0x0a1aa52f, 0x373460ea), TOBN(0x20da1a56, 0x160bb19b)}, + {TOBN(0xfb54999d, 0x65bf0384), TOBN(0x71a14d24, 0x5d5a180e), + TOBN(0xbc44db7b, 0x21737b04), TOBN(0xd84fcb18, 0x01dd8e92)}}, + {{TOBN(0x80de937b, 0xfa44b479), TOBN(0x53505499, 0x5c98fd4f), + TOBN(0x1edb12ab, 0x28f08727), TOBN(0x4c58b582, 0xa5f3ef53)}, + {TOBN(0xbfb236d8, 0x8327f246), TOBN(0xc3a3bfaa, 0x4d7df320), + TOBN(0xecd96c59, 0xb96024f2), TOBN(0xfc293a53, 0x7f4e0433)}}, + {{TOBN(0x5341352b, 0x5acf6e10), TOBN(0xc50343fd, 0xafe652c3), + TOBN(0x4af3792d, 0x18577a7f), TOBN(0xe1a4c617, 0xaf16823d)}, + {TOBN(0x9b26d0cd, 0x33425d0a), TOBN(0x306399ed, 0x9b7bc47f), + TOBN(0x2a792f33, 0x706bb20b), TOBN(0x31219614, 0x98111055)}}, + {{TOBN(0x864ec064, 0x87f5d28b), TOBN(0x11392d91, 0x962277fd), + TOBN(0xb5aa7942, 0xbb6aed5f), TOBN(0x080094dc, 0x47e799d9)}, + {TOBN(0x4afa588c, 0x208ba19b), TOBN(0xd3e7570f, 0x8512f284), + TOBN(0xcbae64e6, 0x02f5799a), TOBN(0xdeebe7ef, 0x514b9492)}}, + {{TOBN(0x30300f98, 0xe5c298ff), TOBN(0x17f561be, 0x3678361f), + TOBN(0xf52ff312, 0x98cb9a16), TOBN(0x6233c3bc, 0x5562d490)}, + {TOBN(0x7bfa15a1, 0x92e3a2cb), TOBN(0x961bcfd1, 0xe6365119), + TOBN(0x3bdd29bf, 0x2c8c53b1), TOBN(0x739704df, 0x822844ba)}}, + {{TOBN(0x7dacfb58, 0x7e7b754b), TOBN(0x23360791, 0xa806c9b9), + TOBN(0xe7eb88c9, 0x23504452), TOBN(0x2983e996, 0x852c1783)}, + {TOBN(0xdd4ae529, 0x958d881d), TOBN(0x026bae03, 0x262c7b3c), + TOBN(0x3a6f9193, 0x960b52d1), TOBN(0xd0980f90, 0x92696cfb)}}, + {{TOBN(0x4c1f428c, 0xd5f30851), TOBN(0x94dfed27, 0x2a4f6630), + TOBN(0x4df53772, 0xfc5d48a4), TOBN(0xdd2d5a2f, 0x933260ce)}, + {TOBN(0x574115bd, 0xd44cc7a5), TOBN(0x4ba6b20d, 0xbd12533a), + TOBN(0x30e93cb8, 0x243057c9), TOBN(0x794c486a, 0x14de320e)}}, + {{TOBN(0xe925d4ce, 0xf21496e4), TOBN(0xf951d198, 0xec696331), + TOBN(0x9810e2de, 0x3e8d812f), TOBN(0xd0a47259, 0x389294ab)}, + {TOBN(0x513ba2b5, 0x0e3bab66), TOBN(0x462caff5, 0xabad306f), + TOBN(0xe2dc6d59, 0xaf04c49e), TOBN(0x1aeb8750, 0xe0b84b0b)}}, + {{TOBN(0xc034f12f, 0x2f7d0ca2), TOBN(0x6d2e8128, 0xe06acf2f), + TOBN(0x801f4f83, 0x21facc2f), TOBN(0xa1170c03, 0xf40ef607)}, + {TOBN(0xfe0a1d4f, 0x7805a99c), TOBN(0xbde56a36, 0xcc26aba5), + TOBN(0x5b1629d0, 0x35531f40), TOBN(0xac212c2b, 0x9afa6108)}}, + {{TOBN(0x30a06bf3, 0x15697be5), TOBN(0x6f0545dc, 0x2c63c7c1), + TOBN(0x5d8cb842, 0x7ccdadaf), TOBN(0xd52e379b, 0xac7015bb)}, + {TOBN(0xc4f56147, 0xf462c23e), TOBN(0xd44a4298, 0x46bc24b0), + TOBN(0xbc73d23a, 0xe2856d4f), TOBN(0x61cedd8c, 0x0832bcdf)}}, + {{TOBN(0x60953556, 0x99f241d7), TOBN(0xee4adbd7, 0x001a349d), + TOBN(0x0b35bf6a, 0xaa89e491), TOBN(0x7f0076f4, 0x136f7546)}, + {TOBN(0xd19a18ba, 0x9264da3d), TOBN(0x6eb2d2cd, 0x62a7a28b), + TOBN(0xcdba941f, 0x8761c971), TOBN(0x1550518b, 0xa3be4a5d)}}, + {{TOBN(0xd0e8e2f0, 0x57d0b70c), TOBN(0xeea8612e, 0xcd133ba3), + TOBN(0x814670f0, 0x44416aec), TOBN(0x424db6c3, 0x30775061)}, + {TOBN(0xd96039d1, 0x16213fd1), TOBN(0xc61e7fa5, 0x18a3478f), + TOBN(0xa805bdcc, 0xcb0c5021), TOBN(0xbdd6f3a8, 0x0cc616dd)}}, + {{TOBN(0x06009667, 0x5d97f7e2), TOBN(0x31db0fc1, 0xaf0bf4b6), + TOBN(0x23680ed4, 0x5491627a), TOBN(0xb99a3c66, 0x7d741fb1)}, + {TOBN(0xe9bb5f55, 0x36b1ff92), TOBN(0x29738577, 0x512b388d), + TOBN(0xdb8a2ce7, 0x50fcf263), TOBN(0x385346d4, 0x6c4f7b47)}}, + {{TOBN(0xbe86c5ef, 0x31631f9e), TOBN(0xbf91da21, 0x03a57a29), + TOBN(0xc3b1f796, 0x7b23f821), TOBN(0x0f7d00d2, 0x770db354)}, + {TOBN(0x8ffc6c3b, 0xd8fe79da), TOBN(0xcc5e8c40, 0xd525c996), + TOBN(0x4640991d, 0xcfff632a), TOBN(0x64d97e8c, 0x67112528)}}, + {{TOBN(0xc232d973, 0x02f1cd1e), TOBN(0xce87eacb, 0x1dd212a4), + TOBN(0x6e4c8c73, 0xe69802f7), TOBN(0x12ef0290, 0x1fffddbd)}, + {TOBN(0x941ec74e, 0x1bcea6e2), TOBN(0xd0b54024, 0x3cb92cbb), + TOBN(0x809fb9d4, 0x7e8f9d05), TOBN(0x3bf16159, 0xf2992aae)}}, + {{TOBN(0xad40f279, 0xf8a7a838), TOBN(0x11aea631, 0x05615660), + TOBN(0xbf52e6f1, 0xa01f6fa1), TOBN(0xef046995, 0x3dc2aec9)}, + {TOBN(0x785dbec9, 0xd8080711), TOBN(0xe1aec60a, 0x9fdedf76), + TOBN(0xece797b5, 0xfa21c126), TOBN(0xc66e898f, 0x05e52732)}}, + {{TOBN(0x39bb69c4, 0x08811fdb), TOBN(0x8bfe1ef8, 0x2fc7f082), + TOBN(0xc8e7a393, 0x174f4138), TOBN(0xfba8ad1d, 0xd58d1f98)}, + {TOBN(0xbc21d0ce, 0xbfd2fd5b), TOBN(0x0b839a82, 0x6ee60d61), + TOBN(0xaacf7658, 0xafd22253), TOBN(0xb526bed8, 0xaae396b3)}}, + {{TOBN(0xccc1bbc2, 0x38564464), TOBN(0x9e3ff947, 0x8c45bc73), + TOBN(0xcde9bca3, 0x58188a78), TOBN(0x138b8ee0, 0xd73bf8f7)}, + {TOBN(0x5c7e234c, 0x4123c489), TOBN(0x66e69368, 0xfa643297), + TOBN(0x0629eeee, 0x39a15fa3), TOBN(0x95fab881, 0xa9e2a927)}}, + {{TOBN(0xb2497007, 0xeafbb1e1), TOBN(0xd75c9ce6, 0xe75b7a93), + TOBN(0x3558352d, 0xefb68d78), TOBN(0xa2f26699, 0x223f6396)}, + {TOBN(0xeb911ecf, 0xe469b17a), TOBN(0x62545779, 0xe72d3ec2), + TOBN(0x8ea47de7, 0x82cb113f), TOBN(0xebe4b086, 0x4e1fa98d)}}, + {{TOBN(0xec2d5ed7, 0x8cdfedb1), TOBN(0xa535c077, 0xfe211a74), + TOBN(0x9678109b, 0x11d244c5), TOBN(0xf17c8bfb, 0xbe299a76)}, + {TOBN(0xb651412e, 0xfb11fbc4), TOBN(0xea0b5482, 0x94ab3f65), + TOBN(0xd8dffd95, 0x0cf78243), TOBN(0x2e719e57, 0xce0361d4)}}, + {{TOBN(0x9007f085, 0x304ddc5b), TOBN(0x095e8c6d, 0x4daba2ea), + TOBN(0x5a33cdb4, 0x3f9d28a9), TOBN(0x85b95cd8, 0xe2283003)}, + {TOBN(0xbcd6c819, 0xb9744733), TOBN(0x29c5f538, 0xfc7f5783), + TOBN(0x6c49b2fa, 0xd59038e4), TOBN(0x68349cc1, 0x3bbe1018)}}, + {{TOBN(0xcc490c1d, 0x21830ee5), TOBN(0x36f9c4ee, 0xe9bfa297), + TOBN(0x58fd7294, 0x48de1a94), TOBN(0xaadb13a8, 0x4e8f2cdc)}, + {TOBN(0x515eaaa0, 0x81313dba), TOBN(0xc76bb468, 0xc2152dd8), + TOBN(0x357f8d75, 0xa653dbf8), TOBN(0xe4d8c4d1, 0xb14ac143)}}, + {{TOBN(0xbdb8e675, 0xb055cb40), TOBN(0x898f8e7b, 0x977b5167), + TOBN(0xecc65651, 0xb82fb863), TOBN(0x56544814, 0x6d88f01f)}, + {TOBN(0xb0928e95, 0x263a75a9), TOBN(0xcfb6836f, 0x1a22fcda), + TOBN(0x651d14db, 0x3f3bd37c), TOBN(0x1d3837fb, 0xb6ad4664)}}, + {{TOBN(0x7c5fb538, 0xff4f94ab), TOBN(0x7243c712, 0x6d7fb8f2), + TOBN(0xef13d60c, 0xa85c5287), TOBN(0x18cfb7c7, 0x4bb8dd1b)}, + {TOBN(0x82f9bfe6, 0x72908219), TOBN(0x35c4592b, 0x9d5144ab), + TOBN(0x52734f37, 0x9cf4b42f), TOBN(0x6bac55e7, 0x8c60ddc4)}}, + {{TOBN(0xb5cd811e, 0x94dea0f6), TOBN(0x259ecae4, 0xe18cc1a3), + TOBN(0x6a0e836e, 0x15e660f8), TOBN(0x6c639ea6, 0x0e02bff2)}, + {TOBN(0x8721b8cb, 0x7e1026fd), TOBN(0x9e73b50b, 0x63261942), + TOBN(0xb8c70974, 0x77f01da3), TOBN(0x1839e6a6, 0x8268f57f)}}, + {{TOBN(0x571b9415, 0x5150b805), TOBN(0x1892389e, 0xf92c7097), + TOBN(0x8d69c18e, 0x4a084b95), TOBN(0x7014c512, 0xbe5b495c)}, + {TOBN(0x4780db36, 0x1b07523c), TOBN(0x2f6219ce, 0x2c1c64fa), + TOBN(0xc38b81b0, 0x602c105a), TOBN(0xab4f4f20, 0x5dc8e360)}}, + {{TOBN(0x20d3c982, 0xcf7d62d2), TOBN(0x1f36e29d, 0x23ba8150), + TOBN(0x48ae0bf0, 0x92763f9e), TOBN(0x7a527e6b, 0x1d3a7007)}, + {TOBN(0xb4a89097, 0x581a85e3), TOBN(0x1f1a520f, 0xdc158be5), + TOBN(0xf98db37d, 0x167d726e), TOBN(0x8802786e, 0x1113e862)}}}, + {{{TOBN(0xefb2149e, 0x36f09ab0), TOBN(0x03f163ca, 0x4a10bb5b), + TOBN(0xd0297045, 0x06e20998), TOBN(0x56f0af00, 0x1b5a3bab)}, + {TOBN(0x7af4cfec, 0x70880e0d), TOBN(0x7332a66f, 0xbe3d913f), + TOBN(0x32e6c84a, 0x7eceb4bd), TOBN(0xedc4a79a, 0x9c228f55)}}, + {{TOBN(0xc37c7dd0, 0xc55c4496), TOBN(0xa6a96357, 0x25bbabd2), + TOBN(0x5b7e63f2, 0xadd7f363), TOBN(0x9dce3782, 0x2e73f1df)}, + {TOBN(0xe1e5a16a, 0xb2b91f71), TOBN(0xe4489823, 0x5ba0163c), + TOBN(0xf2759c32, 0xf6e515ad), TOBN(0xa5e2f1f8, 0x8615eecf)}}, + {{TOBN(0x74519be7, 0xabded551), TOBN(0x03d358b8, 0xc8b74410), + TOBN(0x4d00b10b, 0x0e10d9a9), TOBN(0x6392b0b1, 0x28da52b7)}, + {TOBN(0x6744a298, 0x0b75c904), TOBN(0xc305b0ae, 0xa8f7f96c), + TOBN(0x042e421d, 0x182cf932), TOBN(0xf6fc5d50, 0x9e4636ca)}}, + {{TOBN(0x795847c9, 0xd64cc78c), TOBN(0x6c50621b, 0x9b6cb27b), + TOBN(0x07099bf8, 0xdf8022ab), TOBN(0x48f862eb, 0xc04eda1d)}, + {TOBN(0xd12732ed, 0xe1603c16), TOBN(0x19a80e0f, 0x5c9a9450), + TOBN(0xe2257f54, 0xb429b4fc), TOBN(0x66d3b2c6, 0x45460515)}}, + {{TOBN(0x6ca4f87e, 0x822e37be), TOBN(0x73f237b4, 0x253bda4e), + TOBN(0xf747f3a2, 0x41190aeb), TOBN(0xf06fa36f, 0x804cf284)}, + {TOBN(0x0a6bbb6e, 0xfc621c12), TOBN(0x5d624b64, 0x40b80ec6), + TOBN(0x4b072425, 0x7ba556f3), TOBN(0x7fa0c354, 0x3e2d20a8)}}, + {{TOBN(0xe921fa31, 0xe3229d41), TOBN(0xa929c652, 0x94531bd4), + TOBN(0x84156027, 0xa6d38209), TOBN(0xf3d69f73, 0x6bdb97bd)}, + {TOBN(0x8906d19a, 0x16833631), TOBN(0x68a34c2e, 0x03d51be3), + TOBN(0xcb59583b, 0x0e511cd8), TOBN(0x99ce6bfd, 0xfdc132a8)}}, + {{TOBN(0x3facdaaa, 0xffcdb463), TOBN(0x658bbc1a, 0x34a38b08), + TOBN(0x12a801f8, 0xf1a9078d), TOBN(0x1567bcf9, 0x6ab855de)}, + {TOBN(0xe08498e0, 0x3572359b), TOBN(0xcf0353e5, 0x8659e68b), + TOBN(0xbb86e9c8, 0x7d23807c), TOBN(0xbc08728d, 0x2198e8a2)}}, + {{TOBN(0x8de2b7bc, 0x453cadd6), TOBN(0x203900a7, 0xbc0bc1f8), + TOBN(0xbcd86e47, 0xa6abd3af), TOBN(0x911cac12, 0x8502effb)}, + {TOBN(0x2d550242, 0xec965469), TOBN(0x0e9f7692, 0x29e0017e), + TOBN(0x633f078f, 0x65979885), TOBN(0xfb87d449, 0x4cf751ef)}}, + {{TOBN(0xe1790e4b, 0xfc25419a), TOBN(0x36467203, 0x4bff3cfd), + TOBN(0xc8db6386, 0x25b6e83f), TOBN(0x6cc69f23, 0x6cad6fd2)}, + {TOBN(0x0219e45a, 0x6bc68bb9), TOBN(0xe43d79b6, 0x297f7334), + TOBN(0x7d445368, 0x465dc97c), TOBN(0x4b9eea32, 0x2a0b949a)}}, + {{TOBN(0x1b96c6ba, 0x6102d021), TOBN(0xeaafac78, 0x2f4461ea), + TOBN(0xd4b85c41, 0xc49f19a8), TOBN(0x275c28e4, 0xcf538875)}, + {TOBN(0x35451a9d, 0xdd2e54e0), TOBN(0x6991adb5, 0x0605618b), + TOBN(0x5b8b4bcd, 0x7b36cd24), TOBN(0x372a4f8c, 0x56f37216)}}, + {{TOBN(0xc890bd73, 0xa6a5da60), TOBN(0x6f083da0, 0xdc4c9ff0), + TOBN(0xf4e14d94, 0xf0536e57), TOBN(0xf9ee1eda, 0xaaec8243)}, + {TOBN(0x571241ec, 0x8bdcf8e7), TOBN(0xa5db8271, 0x0b041e26), + TOBN(0x9a0b9a99, 0xe3fff040), TOBN(0xcaaf21dd, 0x7c271202)}}, + {{TOBN(0xb4e2b2e1, 0x4f0dd2e8), TOBN(0xe77e7c4f, 0x0a377ac7), + TOBN(0x69202c3f, 0x0d7a2198), TOBN(0xf759b7ff, 0x28200eb8)}, + {TOBN(0xc87526ed, 0xdcfe314e), TOBN(0xeb84c524, 0x53d5cf99), + TOBN(0xb1b52ace, 0x515138b6), TOBN(0x5aa7ff8c, 0x23fca3f4)}}, + {{TOBN(0xff0b13c3, 0xb9791a26), TOBN(0x960022da, 0xcdd58b16), + TOBN(0xdbd55c92, 0x57aad2de), TOBN(0x3baaaaa3, 0xf30fe619)}, + {TOBN(0x9a4b2346, 0x0d881efd), TOBN(0x506416c0, 0x46325e2a), + TOBN(0x91381e76, 0x035c18d4), TOBN(0xb3bb68be, 0xf27817b0)}}, + {{TOBN(0x15bfb8bf, 0x5116f937), TOBN(0x7c64a586, 0xc1268943), + TOBN(0x71e25cc3, 0x8419a2c8), TOBN(0x9fd6b0c4, 0x8335f463)}, + {TOBN(0x4bf0ba3c, 0xe8ee0e0e), TOBN(0x6f6fba60, 0x298c21fa), + TOBN(0x57d57b39, 0xae66bee0), TOBN(0x292d5130, 0x22672544)}}, + {{TOBN(0xf451105d, 0xbab093b3), TOBN(0x012f59b9, 0x02839986), + TOBN(0x8a915802, 0x3474a89c), TOBN(0x048c919c, 0x2de03e97)}, + {TOBN(0xc476a2b5, 0x91071cd5), TOBN(0x791ed89a, 0x034970a5), + TOBN(0x89bd9042, 0xe1b7994b), TOBN(0x8eaf5179, 0xa1057ffd)}}, + {{TOBN(0x6066e2a2, 0xd551ee10), TOBN(0x87a8f1d8, 0x727e09a6), + TOBN(0x00d08bab, 0x2c01148d), TOBN(0x6da8e4f1, 0x424f33fe)}, + {TOBN(0x466d17f0, 0xcf9a4e71), TOBN(0xff502010, 0x3bf5cb19), + TOBN(0xdccf97d8, 0xd062ecc0), TOBN(0x80c0d9af, 0x81d80ac4)}}, + {{TOBN(0xe87771d8, 0x033f2876), TOBN(0xb0186ec6, 0x7d5cc3db), + TOBN(0x58e8bb80, 0x3bc9bc1d), TOBN(0x4d1395cc, 0x6f6ef60e)}, + {TOBN(0xa73c62d6, 0x186244a0), TOBN(0x918e5f23, 0x110a5b53), + TOBN(0xed4878ca, 0x741b7eab), TOBN(0x3038d71a, 0xdbe03e51)}}, + {{TOBN(0x840204b7, 0xa93c3246), TOBN(0x21ab6069, 0xa0b9b4cd), + TOBN(0xf5fa6e2b, 0xb1d64218), TOBN(0x1de6ad0e, 0xf3d56191)}, + {TOBN(0x570aaa88, 0xff1929c7), TOBN(0xc6df4c6b, 0x640e87b5), + TOBN(0xde8a74f2, 0xc65f0ccc), TOBN(0x8b972fd5, 0xe6f6cc01)}}, + {{TOBN(0x3fff36b6, 0x0b846531), TOBN(0xba7e45e6, 0x10a5e475), + TOBN(0x84a1d10e, 0x4145b6c5), TOBN(0xf1f7f91a, 0x5e046d9d)}, + {TOBN(0x0317a692, 0x44de90d7), TOBN(0x951a1d4a, 0xf199c15e), + TOBN(0x91f78046, 0xc9d73deb), TOBN(0x74c82828, 0xfab8224f)}}, + {{TOBN(0xaa6778fc, 0xe7560b90), TOBN(0xb4073e61, 0xa7e824ce), + TOBN(0xff0d693c, 0xd642eba8), TOBN(0x7ce2e57a, 0x5dccef38)}, + {TOBN(0x89c2c789, 0x1df1ad46), TOBN(0x83a06922, 0x098346fd), + TOBN(0x2d715d72, 0xda2fc177), TOBN(0x7b6dd71d, 0x85b6cf1d)}}, + {{TOBN(0xc60a6d0a, 0x73fa9cb0), TOBN(0xedd3992e, 0x328bf5a9), + TOBN(0xc380ddd0, 0x832c8c82), TOBN(0xd182d410, 0xa2a0bf50)}, + {TOBN(0x7d9d7438, 0xd9a528db), TOBN(0xe8b1a0e9, 0xcaf53994), + TOBN(0xddd6e5fe, 0x0e19987c), TOBN(0xacb8df03, 0x190b059d)}}, + {{TOBN(0x53703a32, 0x8300129f), TOBN(0x1f637662, 0x68c43bfd), + TOBN(0xbcbd1913, 0x00e54051), TOBN(0x812fcc62, 0x7bf5a8c5)}, + {TOBN(0x3f969d5f, 0x29fb85da), TOBN(0x72f4e00a, 0x694759e8), + TOBN(0x426b6e52, 0x790726b7), TOBN(0x617bbc87, 0x3bdbb209)}}, + {{TOBN(0x511f8bb9, 0x97aee317), TOBN(0x812a4096, 0xe81536a8), + TOBN(0x137dfe59, 0x3ac09b9b), TOBN(0x0682238f, 0xba8c9a7a)}, + {TOBN(0x7072ead6, 0xaeccb4bd), TOBN(0x6a34e9aa, 0x692ba633), + TOBN(0xc82eaec2, 0x6fff9d33), TOBN(0xfb753512, 0x1d4d2b62)}}, + {{TOBN(0x1a0445ff, 0x1d7aadab), TOBN(0x65d38260, 0xd5f6a67c), + TOBN(0x6e62fb08, 0x91cfb26f), TOBN(0xef1e0fa5, 0x5c7d91d6)}, + {TOBN(0x47e7c7ba, 0x33db72cd), TOBN(0x017cbc09, 0xfa7c74b2), + TOBN(0x3c931590, 0xf50a503c), TOBN(0xcac54f60, 0x616baa42)}}, + {{TOBN(0x9b6cd380, 0xb2369f0f), TOBN(0x97d3a70d, 0x23c76151), + TOBN(0x5f9dd6fc, 0x9862a9c6), TOBN(0x044c4ab2, 0x12312f51)}, + {TOBN(0x035ea0fd, 0x834a2ddc), TOBN(0x49e6b862, 0xcc7b826d), + TOBN(0xb03d6883, 0x62fce490), TOBN(0x62f2497a, 0xb37e36e9)}}, + {{TOBN(0x04b005b6, 0xc6458293), TOBN(0x36bb5276, 0xe8d10af7), + TOBN(0xacf2dc13, 0x8ee617b8), TOBN(0x470d2d35, 0xb004b3d4)}, + {TOBN(0x06790832, 0xfeeb1b77), TOBN(0x2bb75c39, 0x85657f9c), + TOBN(0xd70bd4ed, 0xc0f60004), TOBN(0xfe797ecc, 0x219b018b)}}, + {{TOBN(0x9b5bec2a, 0x753aebcc), TOBN(0xdaf9f3dc, 0xc939eca5), + TOBN(0xd6bc6833, 0xd095ad09), TOBN(0x98abdd51, 0xdaa4d2fc)}, + {TOBN(0xd9840a31, 0x8d168be5), TOBN(0xcf7c10e0, 0x2325a23c), + TOBN(0xa5c02aa0, 0x7e6ecfaf), TOBN(0x2462e7e6, 0xb5bfdf18)}}, + {{TOBN(0xab2d8a8b, 0xa0cc3f12), TOBN(0x68dd485d, 0xbc672a29), + TOBN(0x72039752, 0x596f2cd3), TOBN(0x5d3eea67, 0xa0cf3d8d)}, + {TOBN(0x810a1a81, 0xe6602671), TOBN(0x8f144a40, 0x14026c0c), + TOBN(0xbc753a6d, 0x76b50f85), TOBN(0xc4dc21e8, 0x645cd4a4)}}, + {{TOBN(0xc5262dea, 0x521d0378), TOBN(0x802b8e0e, 0x05011c6f), + TOBN(0x1ba19cbb, 0x0b4c19ea), TOBN(0x21db64b5, 0xebf0aaec)}, + {TOBN(0x1f394ee9, 0x70342f9d), TOBN(0x93a10aee, 0x1bc44a14), + TOBN(0xa7eed31b, 0x3efd0baa), TOBN(0x6e7c824e, 0x1d154e65)}}, + {{TOBN(0xee23fa81, 0x9966e7ee), TOBN(0x64ec4aa8, 0x05b7920d), + TOBN(0x2d44462d, 0x2d90aad4), TOBN(0xf44dd195, 0xdf277ad5)}, + {TOBN(0x8d6471f1, 0xbb46b6a1), TOBN(0x1e65d313, 0xfd885090), + TOBN(0x33a800f5, 0x13a977b4), TOBN(0xaca9d721, 0x0797e1ef)}}, + {{TOBN(0x9a5a85a0, 0xfcff6a17), TOBN(0x9970a3f3, 0x1eca7cee), + TOBN(0xbb9f0d6b, 0xc9504be3), TOBN(0xe0c504be, 0xadd24ee2)}, + {TOBN(0x7e09d956, 0x77fcc2f4), TOBN(0xef1a5227, 0x65bb5fc4), + TOBN(0x145d4fb1, 0x8b9286aa), TOBN(0x66fd0c5d, 0x6649028b)}}, + {{TOBN(0x98857ceb, 0x1bf4581c), TOBN(0xe635e186, 0xaca7b166), + TOBN(0x278ddd22, 0x659722ac), TOBN(0xa0903c4c, 0x1db68007)}, + {TOBN(0x366e4589, 0x48f21402), TOBN(0x31b49c14, 0xb96abda2), + TOBN(0x329c4b09, 0xe0403190), TOBN(0x97197ca3, 0xd29f43fe)}}, + {{TOBN(0x8073dd1e, 0x274983d8), TOBN(0xda1a3bde, 0x55717c8f), + TOBN(0xfd3d4da2, 0x0361f9d1), TOBN(0x1332d081, 0x4c7de1ce)}, + {TOBN(0x9b7ef7a3, 0xaa6d0e10), TOBN(0x17db2e73, 0xf54f1c4a), + TOBN(0xaf3dffae, 0x4cd35567), TOBN(0xaaa2f406, 0xe56f4e71)}}, + {{TOBN(0x8966759e, 0x7ace3fc7), TOBN(0x9594eacf, 0x45a8d8c6), + TOBN(0x8de3bd8b, 0x91834e0e), TOBN(0xafe4ca53, 0x548c0421)}, + {TOBN(0xfdd7e856, 0xe6ee81c6), TOBN(0x8f671beb, 0x6b891a3a), + TOBN(0xf7a58f2b, 0xfae63829), TOBN(0x9ab186fb, 0x9c11ac9f)}}, + {{TOBN(0x8d6eb369, 0x10b5be76), TOBN(0x046b7739, 0xfb040bcd), + TOBN(0xccb4529f, 0xcb73de88), TOBN(0x1df0fefc, 0xcf26be03)}, + {TOBN(0xad7757a6, 0xbcfcd027), TOBN(0xa8786c75, 0xbb3165ca), + TOBN(0xe9db1e34, 0x7e99a4d9), TOBN(0x99ee86df, 0xb06c504b)}}, + {{TOBN(0x5b7c2ddd, 0xc15c9f0a), TOBN(0xdf87a734, 0x4295989e), + TOBN(0x59ece47c, 0x03d08fda), TOBN(0xb074d3dd, 0xad5fc702)}, + {TOBN(0x20407903, 0x51a03776), TOBN(0x2bb1f77b, 0x2a608007), + TOBN(0x25c58f4f, 0xe1153185), TOBN(0xe6df62f6, 0x766e6447)}}, + {{TOBN(0xefb3d1be, 0xed51275a), TOBN(0x5de47dc7, 0x2f0f483f), + TOBN(0x7932d98e, 0x97c2bedf), TOBN(0xd5c11927, 0x0219f8a1)}, + {TOBN(0x9d751200, 0xa73a294e), TOBN(0x5f88434a, 0x9dc20172), + TOBN(0xd28d9fd3, 0xa26f506a), TOBN(0xa890cd31, 0x9d1dcd48)}}, + {{TOBN(0x0aebaec1, 0x70f4d3b4), TOBN(0xfd1a1369, 0x0ffc8d00), + TOBN(0xb9d9c240, 0x57d57838), TOBN(0x45929d26, 0x68bac361)}, + {TOBN(0x5a2cd060, 0x25b15ca6), TOBN(0x4b3c83e1, 0x6e474446), + TOBN(0x1aac7578, 0xee1e5134), TOBN(0xa418f5d6, 0xc91e2f41)}}, + {{TOBN(0x6936fc8a, 0x213ed68b), TOBN(0x860ae7ed, 0x510a5224), + TOBN(0x63660335, 0xdef09b53), TOBN(0x641b2897, 0xcd79c98d)}, + {TOBN(0x29bd38e1, 0x01110f35), TOBN(0x79c26f42, 0x648b1937), + TOBN(0x64dae519, 0x9d9164f4), TOBN(0xd85a2310, 0x0265c273)}}, + {{TOBN(0x7173dd5d, 0x4b07e2b1), TOBN(0xd144c4cb, 0x8d9ea221), + TOBN(0xe8b04ea4, 0x1105ab14), TOBN(0x92dda542, 0xfe80d8f1)}, + {TOBN(0xe9982fa8, 0xcf03dce6), TOBN(0x8b5ea965, 0x1a22cffc), + TOBN(0xf7f4ea7f, 0x3fad88c4), TOBN(0x62db773e, 0x6a5ba95c)}}, + {{TOBN(0xd20f02fb, 0x93f24567), TOBN(0xfd46c69a, 0x315257ca), + TOBN(0x0ac74cc7, 0x8bcab987), TOBN(0x46f31c01, 0x5ceca2f5)}, + {TOBN(0x40aedb59, 0x888b219e), TOBN(0xe50ecc37, 0xe1fccd02), + TOBN(0x1bcd9dad, 0x911f816c), TOBN(0x583cc1ec, 0x8db9b00c)}}, + {{TOBN(0xf3cd2e66, 0xa483bf11), TOBN(0xfa08a6f5, 0xb1b2c169), + TOBN(0xf375e245, 0x4be9fa28), TOBN(0x99a7ffec, 0x5b6d011f)}, + {TOBN(0x6a3ebddb, 0xc4ae62da), TOBN(0x6cea00ae, 0x374aef5d), + TOBN(0xab5fb98d, 0x9d4d05bc), TOBN(0x7cba1423, 0xd560f252)}}, + {{TOBN(0x49b2cc21, 0x208490de), TOBN(0x1ca66ec3, 0xbcfb2879), + TOBN(0x7f1166b7, 0x1b6fb16f), TOBN(0xfff63e08, 0x65fe5db3)}, + {TOBN(0xb8345abe, 0x8b2610be), TOBN(0xb732ed80, 0x39de3df4), + TOBN(0x0e24ed50, 0x211c32b4), TOBN(0xd10d8a69, 0x848ff27d)}}, + {{TOBN(0xc1074398, 0xed4de248), TOBN(0xd7cedace, 0x10488927), + TOBN(0xa4aa6bf8, 0x85673e13), TOBN(0xb46bae91, 0x6daf30af)}, + {TOBN(0x07088472, 0xfcef7ad8), TOBN(0x61151608, 0xd4b35e97), + TOBN(0xbcfe8f26, 0xdde29986), TOBN(0xeb84c4c7, 0xd5a34c79)}}, + {{TOBN(0xc1eec55c, 0x164e1214), TOBN(0x891be86d, 0xa147bb03), + TOBN(0x9fab4d10, 0x0ba96835), TOBN(0xbf01e9b8, 0xa5c1ae9f)}, + {TOBN(0x6b4de139, 0xb186ebc0), TOBN(0xd5c74c26, 0x85b91bca), + TOBN(0x5086a99c, 0xc2d93854), TOBN(0xeed62a7b, 0xa7a9dfbc)}}, + {{TOBN(0x8778ed6f, 0x76b7618a), TOBN(0xbff750a5, 0x03b66062), + TOBN(0x4cb7be22, 0xb65186db), TOBN(0x369dfbf0, 0xcc3a6d13)}, + {TOBN(0xc7dab26c, 0x7191a321), TOBN(0x9edac3f9, 0x40ed718e), + TOBN(0xbc142b36, 0xd0cfd183), TOBN(0xc8af82f6, 0x7c991693)}}, + {{TOBN(0xb3d1e4d8, 0x97ce0b2a), TOBN(0xe6d7c87f, 0xc3a55cdf), + TOBN(0x35846b95, 0x68b81afe), TOBN(0x018d12af, 0xd3c239d8)}, + {TOBN(0x2b2c6208, 0x01206e15), TOBN(0xe0e42453, 0xa3b882c6), + TOBN(0x854470a3, 0xa50162d5), TOBN(0x08157478, 0x7017a62a)}}, + {{TOBN(0x18bd3fb4, 0x820357c7), TOBN(0x992039ae, 0x6f1458ad), + TOBN(0x9a1df3c5, 0x25b44aa1), TOBN(0x2d780357, 0xed3d5281)}, + {TOBN(0x58cf7e4d, 0xc77ad4d4), TOBN(0xd49a7998, 0xf9df4fc4), + TOBN(0x4465a8b5, 0x1d71205e), TOBN(0xa0ee0ea6, 0x649254aa)}}, + {{TOBN(0x4b5eeecf, 0xab7bd771), TOBN(0x6c873073, 0x35c262b9), + TOBN(0xdc5bd648, 0x3c9d61e7), TOBN(0x233d6d54, 0x321460d2)}, + {TOBN(0xd20c5626, 0xfc195bcc), TOBN(0x25445958, 0x04d78b63), + TOBN(0xe03fcb3d, 0x17ec8ef3), TOBN(0x54b690d1, 0x46b8f781)}}, + {{TOBN(0x82fa2c8a, 0x21230646), TOBN(0xf51aabb9, 0x084f418c), + TOBN(0xff4fbec1, 0x1a30ba43), TOBN(0x6a5acf73, 0x743c9df7)}, + {TOBN(0x1da2b357, 0xd635b4d5), TOBN(0xc3de68dd, 0xecd5c1da), + TOBN(0xa689080b, 0xd61af0dd), TOBN(0xdea5938a, 0xd665bf99)}}, + {{TOBN(0x0231d71a, 0xfe637294), TOBN(0x01968aa6, 0xa5a81cd8), + TOBN(0x11252d50, 0x048e63b5), TOBN(0xc446bc52, 0x6ca007e9)}, + {TOBN(0xef8c50a6, 0x96d6134b), TOBN(0x9361fbf5, 0x9e09a05c), + TOBN(0xf17f85a6, 0xdca3291a), TOBN(0xb178d548, 0xff251a21)}}, + {{TOBN(0x87f6374b, 0xa4df3915), TOBN(0x566ce1bf, 0x2fd5d608), + TOBN(0x425cba4d, 0x7de35102), TOBN(0x6b745f8f, 0x58c5d5e2)}, + {TOBN(0x88402af6, 0x63122edf), TOBN(0x3190f9ed, 0x3b989a89), + TOBN(0x4ad3d387, 0xebba3156), TOBN(0xef385ad9, 0xc7c469a5)}}, + {{TOBN(0xb08281de, 0x3f642c29), TOBN(0x20be0888, 0x910ffb88), + TOBN(0xf353dd4a, 0xd5292546), TOBN(0x3f1627de, 0x8377a262)}, + {TOBN(0xa5faa013, 0xeefcd638), TOBN(0x8f3bf626, 0x74cc77c3), + TOBN(0x32618f65, 0xa348f55e), TOBN(0x5787c0dc, 0x9fefeb9e)}}, + {{TOBN(0xf1673aa2, 0xd9a23e44), TOBN(0x88dfa993, 0x4e10690d), + TOBN(0x1ced1b36, 0x2bf91108), TOBN(0x9193ceca, 0x3af48649)}, + {TOBN(0xfb34327d, 0x2d738fc5), TOBN(0x6697b037, 0x975fee6c), + TOBN(0x2f485da0, 0xc04079a5), TOBN(0x2cdf5735, 0x2feaa1ac)}}, + {{TOBN(0x76944420, 0xbd55659e), TOBN(0x7973e32b, 0x4376090c), + TOBN(0x86bb4fe1, 0x163b591a), TOBN(0x10441aed, 0xc196f0ca)}, + {TOBN(0x3b431f4a, 0x045ad915), TOBN(0x6c11b437, 0xa4afacb1), + TOBN(0x30b0c7db, 0x71fdbbd8), TOBN(0xb642931f, 0xeda65acd)}}, + {{TOBN(0x4baae6e8, 0x9c92b235), TOBN(0xa73bbd0e, 0x6b3993a1), + TOBN(0xd06d60ec, 0x693dd031), TOBN(0x03cab91b, 0x7156881c)}, + {TOBN(0xd615862f, 0x1db3574b), TOBN(0x485b0185, 0x64bb061a), + TOBN(0x27434988, 0xa0181e06), TOBN(0x2cd61ad4, 0xc1c0c757)}}, + {{TOBN(0x3effed5a, 0x2ff9f403), TOBN(0x8dc98d8b, 0x62239029), + TOBN(0x2206021e, 0x1f17b70d), TOBN(0xafbec0ca, 0xbf510015)}, + {TOBN(0x9fed7164, 0x80130dfa), TOBN(0x306dc2b5, 0x8a02dcf5), + TOBN(0x48f06620, 0xfeb10fc0), TOBN(0x78d1e1d5, 0x5a57cf51)}}, + {{TOBN(0xadef8c5a, 0x192ef710), TOBN(0x88afbd4b, 0x3b7431f9), + TOBN(0x7e1f7407, 0x64250c9e), TOBN(0x6e31318d, 0xb58bec07)}, + {TOBN(0xfd4fc4b8, 0x24f89b4e), TOBN(0x65a5dd88, 0x48c36a2a), + TOBN(0x4f1eccff, 0xf024baa7), TOBN(0x22a21cf2, 0xcba94650)}}, + {{TOBN(0x95d29dee, 0x42a554f7), TOBN(0x828983a5, 0x002ec4ba), + TOBN(0x8112a1f7, 0x8badb73d), TOBN(0x79ea8897, 0xa27c1839)}, + {TOBN(0x8969a5a7, 0xd065fd83), TOBN(0xf49af791, 0xb262a0bc), + TOBN(0xfcdea8b6, 0xaf2b5127), TOBN(0x10e913e1, 0x564c2dbc)}}, + {{TOBN(0x51239d14, 0xbc21ef51), TOBN(0xe51c3ceb, 0x4ce57292), + TOBN(0x795ff068, 0x47bbcc3b), TOBN(0x86b46e1e, 0xbd7e11e6)}, + {TOBN(0x0ea6ba23, 0x80041ef4), TOBN(0xd72fe505, 0x6262342e), + TOBN(0x8abc6dfd, 0x31d294d4), TOBN(0xbbe017a2, 0x1278c2c9)}}, + {{TOBN(0xb1fcfa09, 0xb389328a), TOBN(0x322fbc62, 0xd01771b5), + TOBN(0x04c0d063, 0x60b045bf), TOBN(0xdb652edc, 0x10e52d01)}, + {TOBN(0x50ef932c, 0x03ec6627), TOBN(0xde1b3b2d, 0xc1ee50e3), + TOBN(0x5ab7bdc5, 0xdc37a90d), TOBN(0xfea67213, 0x31e33a96)}}, + {{TOBN(0x6482b5cb, 0x4f2999aa), TOBN(0x38476cc6, 0xb8cbf0dd), + TOBN(0x93ebfacb, 0x173405bb), TOBN(0x15cdafe7, 0xe52369ec)}, + {TOBN(0xd42d5ba4, 0xd935b7db), TOBN(0x648b6004, 0x1c99a4cd), + TOBN(0x785101bd, 0xa3b5545b), TOBN(0x4bf2c38a, 0x9dd67faf)}}, + {{TOBN(0xb1aadc63, 0x4442449c), TOBN(0xe0e9921a, 0x33ad4fb8), + TOBN(0x5c552313, 0xaa686d82), TOBN(0xdee635fa, 0x465d866c)}, + {TOBN(0xbc3c224a, 0x18ee6e8a), TOBN(0xeed748a6, 0xed42e02f), + TOBN(0xe70f930a, 0xd474cd08), TOBN(0x774ea6ec, 0xfff24adf)}}, + {{TOBN(0x03e2de1c, 0xf3480d4a), TOBN(0xf0d8edc7, 0xbc8acf1a), + TOBN(0xf23e3303, 0x68295a9c), TOBN(0xfadd5f68, 0xc546a97d)}, + {TOBN(0x895597ad, 0x96f8acb1), TOBN(0xbddd49d5, 0x671bdae2), + TOBN(0x16fcd528, 0x21dd43f4), TOBN(0xa5a45412, 0x6619141a)}}}, + {{{TOBN(0x8ce9b6bf, 0xc360e25a), TOBN(0xe6425195, 0x075a1a78), + TOBN(0x9dc756a8, 0x481732f4), TOBN(0x83c0440f, 0x5432b57a)}, + {TOBN(0xc670b3f1, 0xd720281f), TOBN(0x2205910e, 0xd135e051), + TOBN(0xded14b0e, 0xdb052be7), TOBN(0x697b3d27, 0xc568ea39)}}, + {{TOBN(0x2e599b9a, 0xfb3ff9ed), TOBN(0x28c2e0ab, 0x17f6515c), + TOBN(0x1cbee4fd, 0x474da449), TOBN(0x071279a4, 0x4f364452)}, + {TOBN(0x97abff66, 0x01fbe855), TOBN(0x3ee394e8, 0x5fda51c4), + TOBN(0x190385f6, 0x67597c0b), TOBN(0x6e9fccc6, 0xa27ee34b)}}, + {{TOBN(0x0b89de93, 0x14092ebb), TOBN(0xf17256bd, 0x428e240c), + TOBN(0xcf89a7f3, 0x93d2f064), TOBN(0x4f57841e, 0xe1ed3b14)}, + {TOBN(0x4ee14405, 0xe708d855), TOBN(0x856aae72, 0x03f1c3d0), + TOBN(0xc8e5424f, 0xbdd7eed5), TOBN(0x3333e4ef, 0x73ab4270)}}, + {{TOBN(0x3bc77ade, 0xdda492f8), TOBN(0xc11a3aea, 0x78297205), + TOBN(0x5e89a3e7, 0x34931b4c), TOBN(0x17512e2e, 0x9f5694bb)}, + {TOBN(0x5dc349f3, 0x177bf8b6), TOBN(0x232ea4ba, 0x08c7ff3e), + TOBN(0x9c4f9d16, 0xf511145d), TOBN(0xccf109a3, 0x33b379c3)}}, + {{TOBN(0xe75e7a88, 0xa1f25897), TOBN(0x7ac6961f, 0xa1b5d4d8), + TOBN(0xe3e10773, 0x08f3ed5c), TOBN(0x208a54ec, 0x0a892dfb)}, + {TOBN(0xbe826e19, 0x78660710), TOBN(0x0cf70a97, 0x237df2c8), + TOBN(0x418a7340, 0xed704da5), TOBN(0xa3eeb9a9, 0x08ca33fd)}}, + {{TOBN(0x49d96233, 0x169bca96), TOBN(0x04d286d4, 0x2da6aafb), + TOBN(0xc09606ec, 0xa0c2fa94), TOBN(0x8869d0d5, 0x23ff0fb3)}, + {TOBN(0xa99937e5, 0xd0150d65), TOBN(0xa92e2503, 0x240c14c9), + TOBN(0x656bf945, 0x108e2d49), TOBN(0x152a733a, 0xa2f59e2b)}}, + {{TOBN(0xb4323d58, 0x8434a920), TOBN(0xc0af8e93, 0x622103c5), + TOBN(0x667518ef, 0x938dbf9a), TOBN(0xa1843073, 0x83a9cdf2)}, + {TOBN(0x350a94aa, 0x5447ab80), TOBN(0xe5e5a325, 0xc75a3d61), + TOBN(0x74ba507f, 0x68411a9e), TOBN(0x10581fc1, 0x594f70c5)}}, + {{TOBN(0x60e28570, 0x80eb24a9), TOBN(0x7bedfb4d, 0x488e0cfd), + TOBN(0x721ebbd7, 0xc259cdb8), TOBN(0x0b0da855, 0xbc6390a9)}, + {TOBN(0x2b4d04db, 0xde314c70), TOBN(0xcdbf1fbc, 0x6c32e846), + TOBN(0x33833eab, 0xb162fc9e), TOBN(0x9939b48b, 0xb0dd3ab7)}}, + {{TOBN(0x5aaa98a7, 0xcb0c9c8c), TOBN(0x75105f30, 0x81c4375c), + TOBN(0xceee5057, 0x5ef1c90f), TOBN(0xb31e065f, 0xc23a17bf)}, + {TOBN(0x5364d275, 0xd4b6d45a), TOBN(0xd363f3ad, 0x62ec8996), + TOBN(0xb5d21239, 0x4391c65b), TOBN(0x84564765, 0xebb41b47)}}, + {{TOBN(0x20d18ecc, 0x37107c78), TOBN(0xacff3b6b, 0x570c2a66), + TOBN(0x22f975d9, 0x9bd0d845), TOBN(0xef0a0c46, 0xba178fa0)}, + {TOBN(0x1a419651, 0x76b6028e), TOBN(0xc49ec674, 0x248612d4), + TOBN(0x5b6ac4f2, 0x7338af55), TOBN(0x06145e62, 0x7bee5a36)}}, + {{TOBN(0x33e95d07, 0xe75746b5), TOBN(0x1c1e1f6d, 0xc40c78be), + TOBN(0x967833ef, 0x222ff8e2), TOBN(0x4bedcf6a, 0xb49180ad)}, + {TOBN(0x6b37e9c1, 0x3d7a4c8a), TOBN(0x2748887c, 0x6ddfe760), + TOBN(0xf7055123, 0xaa3a5bbc), TOBN(0x954ff225, 0x7bbb8e74)}}, + {{TOBN(0xc42b8ab1, 0x97c3dfb9), TOBN(0x55a549b0, 0xcf168154), + TOBN(0xad6748e7, 0xc1b50692), TOBN(0x2775780f, 0x6fc5cbcb)}, + {TOBN(0x4eab80b8, 0xe1c9d7c8), TOBN(0x8c69dae1, 0x3fdbcd56), + TOBN(0x47e6b4fb, 0x9969eace), TOBN(0x002f1085, 0xa705cb5a)}}, + {{TOBN(0x4e23ca44, 0x6d3fea55), TOBN(0xb4ae9c86, 0xf4810568), + TOBN(0x47bfb91b, 0x2a62f27d), TOBN(0x60deb4c9, 0xd9bac28c)}, + {TOBN(0xa892d894, 0x7de6c34c), TOBN(0x4ee68259, 0x4494587d), + TOBN(0x914ee14e, 0x1a3f8a5b), TOBN(0xbb113eaa, 0x28700385)}}, + {{TOBN(0x81ca03b9, 0x2115b4c9), TOBN(0x7c163d38, 0x8908cad1), + TOBN(0xc912a118, 0xaa18179a), TOBN(0xe09ed750, 0x886e3081)}, + {TOBN(0xa676e3fa, 0x26f516ca), TOBN(0x753cacf7, 0x8e732f91), + TOBN(0x51592aea, 0x833da8b4), TOBN(0xc626f42f, 0x4cbea8aa)}}, + {{TOBN(0xef9dc899, 0xa7b56eaf), TOBN(0x00c0e52c, 0x34ef7316), + TOBN(0x5b1e4e24, 0xfe818a86), TOBN(0x9d31e20d, 0xc538be47)}, + {TOBN(0x22eb932d, 0x3ed68974), TOBN(0xe44bbc08, 0x7c4e87c4), + TOBN(0x4121086e, 0x0dde9aef), TOBN(0x8e6b9cff, 0x134f4345)}}, + {{TOBN(0x96892c1f, 0x711b0eb9), TOBN(0xb905f2c8, 0x780ab954), + TOBN(0xace26309, 0xa20792db), TOBN(0xec8ac9b3, 0x0684e126)}, + {TOBN(0x486ad8b6, 0xb40a2447), TOBN(0x60121fc1, 0x9fe3fb24), + TOBN(0x5626fccf, 0x1a8e3b3f), TOBN(0x4e568622, 0x6ad1f394)}}, + {{TOBN(0xda7aae0d, 0x196aa5a1), TOBN(0xe0df8c77, 0x1041b5fb), + TOBN(0x451465d9, 0x26b318b7), TOBN(0xc29b6e55, 0x7ab136e9)}, + {TOBN(0x2c2ab48b, 0x71148463), TOBN(0xb5738de3, 0x64454a76), + TOBN(0x54ccf9a0, 0x5a03abe4), TOBN(0x377c0296, 0x0427d58e)}}, + {{TOBN(0x73f5f0b9, 0x2bb39c1f), TOBN(0x14373f2c, 0xe608d8c5), + TOBN(0xdcbfd314, 0x00fbb805), TOBN(0xdf18fb20, 0x83afdcfb)}, + {TOBN(0x81a57f42, 0x42b3523f), TOBN(0xe958532d, 0x87f650fb), + TOBN(0xaa8dc8b6, 0x8b0a7d7c), TOBN(0x1b75dfb7, 0x150166be)}}, + {{TOBN(0x90e4f7c9, 0x2d7d1413), TOBN(0x67e2d6b5, 0x9834f597), + TOBN(0x4fd4f4f9, 0xa808c3e8), TOBN(0xaf8237e0, 0xd5281ec1)}, + {TOBN(0x25ab5fdc, 0x84687cee), TOBN(0xc5ded6b1, 0xa5b26c09), + TOBN(0x8e4a5aec, 0xc8ea7650), TOBN(0x23b73e5c, 0x14cc417f)}}, + {{TOBN(0x2bfb4318, 0x3037bf52), TOBN(0xb61e6db5, 0x78c725d7), + TOBN(0x8efd4060, 0xbbb3e5d7), TOBN(0x2e014701, 0xdbac488e)}, + {TOBN(0xac75cf9a, 0x360aa449), TOBN(0xb70cfd05, 0x79634d08), + TOBN(0xa591536d, 0xfffb15ef), TOBN(0xb2c37582, 0xd07c106c)}}, + {{TOBN(0xb4293fdc, 0xf50225f9), TOBN(0xc52e175c, 0xb0e12b03), + TOBN(0xf649c3ba, 0xd0a8bf64), TOBN(0x745a8fef, 0xeb8ae3c6)}, + {TOBN(0x30d7e5a3, 0x58321bc3), TOBN(0xb1732be7, 0x0bc4df48), + TOBN(0x1f217993, 0xe9ea5058), TOBN(0xf7a71cde, 0x3e4fd745)}}, + {{TOBN(0x86cc533e, 0x894c5bbb), TOBN(0x6915c7d9, 0x69d83082), + TOBN(0xa6aa2d05, 0x5815c244), TOBN(0xaeeee592, 0x49b22ce5)}, + {TOBN(0x89e39d13, 0x78135486), TOBN(0x3a275c1f, 0x16b76f2f), + TOBN(0xdb6bcc1b, 0xe036e8f5), TOBN(0x4df69b21, 0x5e4709f5)}}, + {{TOBN(0xa188b250, 0x2d0f39aa), TOBN(0x622118bb, 0x15a85947), + TOBN(0x2ebf520f, 0xfde0f4fa), TOBN(0xa40e9f29, 0x4860e539)}, + {TOBN(0x7b6a51eb, 0x22b57f0f), TOBN(0x849a33b9, 0x7e80644a), + TOBN(0x50e5d16f, 0x1cf095fe), TOBN(0xd754b54e, 0xec55f002)}}, + {{TOBN(0x5cfbbb22, 0x236f4a98), TOBN(0x0b0c59e9, 0x066800bb), + TOBN(0x4ac69a8f, 0x5a9a7774), TOBN(0x2b33f804, 0xd6bec948)}, + {TOBN(0xb3729295, 0x32e6c466), TOBN(0x68956d0f, 0x4e599c73), + TOBN(0xa47a249f, 0x155c31cc), TOBN(0x24d80f0d, 0xe1ce284e)}}, + {{TOBN(0xcd821dfb, 0x988baf01), TOBN(0xe6331a7d, 0xdbb16647), + TOBN(0x1eb8ad33, 0x094cb960), TOBN(0x593cca38, 0xc91bbca5)}, + {TOBN(0x384aac8d, 0x26567456), TOBN(0x40fa0309, 0xc04b6490), + TOBN(0x97834cd6, 0xdab6c8f6), TOBN(0x68a7318d, 0x3f91e55f)}}, + {{TOBN(0xa00fd04e, 0xfc4d3157), TOBN(0xb56f8ab2, 0x2bf3bdea), + TOBN(0x014f5648, 0x4fa57172), TOBN(0x948c5860, 0x450abdb3)}, + {TOBN(0x342b5df0, 0x0ebd4f08), TOBN(0x3e5168cd, 0x0e82938e), + TOBN(0x7aedc1ce, 0xb0df5dd0), TOBN(0x6bbbc6d9, 0xe5732516)}}, + {{TOBN(0xc7bfd486, 0x605daaa6), TOBN(0x46fd72b7, 0xbb9a6c9e), + TOBN(0xe4847fb1, 0xa124fb89), TOBN(0x75959cbd, 0xa2d8ffbc)}, + {TOBN(0x42579f65, 0xc8a588ee), TOBN(0x368c92e6, 0xb80b499d), + TOBN(0xea4ef6cd, 0x999a5df1), TOBN(0xaa73bb7f, 0x936fe604)}}, + {{TOBN(0xf347a70d, 0x6457d188), TOBN(0x86eda86b, 0x8b7a388b), + TOBN(0xb7cdff06, 0x0ccd6013), TOBN(0xbeb1b6c7, 0xd0053fb2)}, + {TOBN(0x0b022387, 0x99240a9f), TOBN(0x1bbb384f, 0x776189b2), + TOBN(0x8695e71e, 0x9066193a), TOBN(0x2eb50097, 0x06ffac7e)}}, + {{TOBN(0x0654a9c0, 0x4a7d2caa), TOBN(0x6f3fb3d1, 0xa5aaa290), + TOBN(0x835db041, 0xff476e8f), TOBN(0x540b8b0b, 0xc42295e4)}, + {TOBN(0xa5c73ac9, 0x05e214f5), TOBN(0x9a74075a, 0x56a0b638), + TOBN(0x2e4b1090, 0xce9e680b), TOBN(0x57a5b479, 0x6b8d9afa)}}, + {{TOBN(0x0dca48e7, 0x26bfe65c), TOBN(0x097e391c, 0x7290c307), + TOBN(0x683c462e, 0x6669e72e), TOBN(0xf505be1e, 0x062559ac)}, + {TOBN(0x5fbe3ea1, 0xe3a3035a), TOBN(0x6431ebf6, 0x9cd50da8), + TOBN(0xfd169d5c, 0x1f6407f2), TOBN(0x8d838a95, 0x60fce6b8)}}, + {{TOBN(0x2a2bfa7f, 0x650006f0), TOBN(0xdfd7dad3, 0x50c0fbb2), + TOBN(0x92452495, 0xccf9ad96), TOBN(0x183bf494, 0xd95635f9)}, + {TOBN(0x02d5df43, 0x4a7bd989), TOBN(0x505385cc, 0xa5431095), + TOBN(0xdd98e67d, 0xfd43f53e), TOBN(0xd61e1a6c, 0x500c34a9)}}, + {{TOBN(0x5a4b46c6, 0x4a8a3d62), TOBN(0x8469c4d0, 0x247743d2), + TOBN(0x2bb3a13d, 0x88f7e433), TOBN(0x62b23a10, 0x01be5849)}, + {TOBN(0xe83596b4, 0xa63d1a4c), TOBN(0x454e7fea, 0x7d183f3e), + TOBN(0x643fce61, 0x17afb01c), TOBN(0x4e65e5e6, 0x1c4c3638)}}, + {{TOBN(0x41d85ea1, 0xef74c45b), TOBN(0x2cfbfa66, 0xae328506), + TOBN(0x98b078f5, 0x3ada7da9), TOBN(0xd985fe37, 0xec752fbb)}, + {TOBN(0xeece68fe, 0x5a0148b4), TOBN(0x6f9a55c7, 0x2d78136d), + TOBN(0x232dccc4, 0xd2b729ce), TOBN(0xa27e0dfd, 0x90aafbc4)}}, + {{TOBN(0x96474452, 0x12b4603e), TOBN(0xa876c551, 0x6b706d14), + TOBN(0xdf145fcf, 0x69a9d412), TOBN(0xe2ab75b7, 0x2d479c34)}, + {TOBN(0x12df9a76, 0x1a23ff97), TOBN(0xc6138992, 0x5d359d10), + TOBN(0x6e51c7ae, 0xfa835f22), TOBN(0x69a79cb1, 0xc0fcc4d9)}}, + {{TOBN(0xf57f350d, 0x594cc7e1), TOBN(0x3079ca63, 0x3350ab79), + TOBN(0x226fb614, 0x9aff594a), TOBN(0x35afec02, 0x6d59a62b)}, + {TOBN(0x9bee46f4, 0x06ed2c6e), TOBN(0x58da1735, 0x7d939a57), + TOBN(0x44c50402, 0x8fd1797e), TOBN(0xd8853e7c, 0x5ccea6ca)}}, + {{TOBN(0x4065508d, 0xa35fcd5f), TOBN(0x8965df8c, 0x495ccaeb), + TOBN(0x0f2da850, 0x12e1a962), TOBN(0xee471b94, 0xc1cf1cc4)}, + {TOBN(0xcef19bc8, 0x0a08fb75), TOBN(0x704958f5, 0x81de3591), + TOBN(0x2867f8b2, 0x3aef4f88), TOBN(0x8d749384, 0xea9f9a5f)}}, + {{TOBN(0x1b385537, 0x8c9049f4), TOBN(0x5be948f3, 0x7b92d8b6), + TOBN(0xd96f725d, 0xb6e2bd6b), TOBN(0x37a222bc, 0x958c454d)}, + {TOBN(0xe7c61abb, 0x8809bf61), TOBN(0x46f07fbc, 0x1346f18d), + TOBN(0xfb567a7a, 0xe87c0d1c), TOBN(0x84a461c8, 0x7ef3d07a)}}, + {{TOBN(0x0a5adce6, 0xd9278d98), TOBN(0x24d94813, 0x9dfc73e1), + TOBN(0x4f3528b6, 0x054321c3), TOBN(0x2e03fdde, 0x692ea706)}, + {TOBN(0x10e60619, 0x47b533c0), TOBN(0x1a8bc73f, 0x2ca3c055), + TOBN(0xae58d4b2, 0x1bb62b8f), TOBN(0xb2045a73, 0x584a24e3)}}, + {{TOBN(0x3ab3d5af, 0xbd76e195), TOBN(0x478dd1ad, 0x6938a810), + TOBN(0x6ffab393, 0x6ee3d5cb), TOBN(0xdfb693db, 0x22b361e4)}, + {TOBN(0xf9694496, 0x51dbf1a7), TOBN(0xcab4b4ef, 0x08a2e762), + TOBN(0xe8c92f25, 0xd39bba9a), TOBN(0x850e61bc, 0xf1464d96)}}, + {{TOBN(0xb7e830e3, 0xdc09508b), TOBN(0xfaf6d2cf, 0x74317655), + TOBN(0x72606ceb, 0xdf690355), TOBN(0x48bb92b3, 0xd0c3ded6)}, + {TOBN(0x65b75484, 0x5c7cf892), TOBN(0xf6cd7ac9, 0xd5d5f01f), + TOBN(0xc2c30a59, 0x96401d69), TOBN(0x91268650, 0xed921878)}}, + {{TOBN(0x380bf913, 0xb78c558f), TOBN(0x43c0baeb, 0xc8afdaa9), + TOBN(0x377f61d5, 0x54f169d3), TOBN(0xf8da07e3, 0xae5ff20b)}, + {TOBN(0xb676c49d, 0xa8a90ea8), TOBN(0x81c1ff2b, 0x83a29b21), + TOBN(0x383297ac, 0x2ad8d276), TOBN(0x3001122f, 0xba89f982)}}, + {{TOBN(0xe1d794be, 0x6718e448), TOBN(0x246c1482, 0x7c3e6e13), + TOBN(0x56646ef8, 0x5d26b5ef), TOBN(0x80f5091e, 0x88069cdd)}, + {TOBN(0xc5992e2f, 0x724bdd38), TOBN(0x02e915b4, 0x8471e8c7), + TOBN(0x96ff320a, 0x0d0ff2a9), TOBN(0xbf886487, 0x4384d1a0)}}, + {{TOBN(0xbbe1e6a6, 0xc93f72d6), TOBN(0xd5f75d12, 0xcad800ea), + TOBN(0xfa40a09f, 0xe7acf117), TOBN(0x32c8cdd5, 0x7581a355)}, + {TOBN(0x74221992, 0x7023c499), TOBN(0xa8afe5d7, 0x38ec3901), + TOBN(0x5691afcb, 0xa90e83f0), TOBN(0x41bcaa03, 0x0b8f8eac)}}, + {{TOBN(0xe38b5ff9, 0x8d2668d5), TOBN(0x0715281a, 0x7ad81965), + TOBN(0x1bc8fc7c, 0x03c6ce11), TOBN(0xcbbee6e2, 0x8b650436)}, + {TOBN(0x06b00fe8, 0x0cdb9808), TOBN(0x17d6e066, 0xfe3ed315), + TOBN(0x2e9d38c6, 0x4d0b5018), TOBN(0xab8bfd56, 0x844dcaef)}}, + {{TOBN(0x42894a59, 0x513aed8b), TOBN(0xf77f3b6d, 0x314bd07a), + TOBN(0xbbdecb8f, 0x8e42b582), TOBN(0xf10e2fa8, 0xd2390fe6)}, + {TOBN(0xefb95022, 0x62a2f201), TOBN(0x4d59ea50, 0x50ee32b0), + TOBN(0xd87f7728, 0x6da789a8), TOBN(0xcf98a2cf, 0xf79492c4)}}, + {{TOBN(0xf9577239, 0x720943c2), TOBN(0xba044cf5, 0x3990b9d0), + TOBN(0x5aa8e823, 0x95f2884a), TOBN(0x834de6ed, 0x0278a0af)}, + {TOBN(0xc8e1ee9a, 0x5f25bd12), TOBN(0x9259ceaa, 0x6f7ab271), + TOBN(0x7e6d97a2, 0x77d00b76), TOBN(0x5c0c6eea, 0xa437832a)}}, + {{TOBN(0x5232c20f, 0x5606b81d), TOBN(0xabd7b375, 0x0d991ee5), + TOBN(0x4d2bfe35, 0x8632d951), TOBN(0x78f85146, 0x98ed9364)}, + {TOBN(0x951873f0, 0xf30c3282), TOBN(0x0da8ac80, 0xa789230b), + TOBN(0x3ac7789c, 0x5398967f), TOBN(0xa69b8f7f, 0xbdda0fb5)}}, + {{TOBN(0xe5db7717, 0x6add8545), TOBN(0x1b71cb66, 0x72c49b66), + TOBN(0xd8560739, 0x68421d77), TOBN(0x03840fe8, 0x83e3afea)}, + {TOBN(0xb391dad5, 0x1ec69977), TOBN(0xae243fb9, 0x307f6726), + TOBN(0xc88ac87b, 0xe8ca160c), TOBN(0x5174cced, 0x4ce355f4)}}, + {{TOBN(0x98a35966, 0xe58ba37d), TOBN(0xfdcc8da2, 0x7817335d), + TOBN(0x5b752830, 0x83fbc7bf), TOBN(0x68e419d4, 0xd9c96984)}, + {TOBN(0x409a39f4, 0x02a40380), TOBN(0x88940faf, 0x1fe977bc), + TOBN(0xc640a94b, 0x8f8edea6), TOBN(0x1e22cd17, 0xed11547d)}}, + {{TOBN(0xe28568ce, 0x59ffc3e2), TOBN(0x60aa1b55, 0xc1dee4e7), + TOBN(0xc67497c8, 0x837cb363), TOBN(0x06fb438a, 0x105a2bf2)}, + {TOBN(0x30357ec4, 0x500d8e20), TOBN(0x1ad9095d, 0x0670db10), + TOBN(0x7f589a05, 0xc73b7cfd), TOBN(0xf544607d, 0x880d6d28)}}, + {{TOBN(0x17ba93b1, 0xa20ef103), TOBN(0xad859130, 0x6ba6577b), + TOBN(0x65c91cf6, 0x6fa214a0), TOBN(0xd7d49c6c, 0x27990da5)}, + {TOBN(0xecd9ec8d, 0x20bb569d), TOBN(0xbd4b2502, 0xeeffbc33), + TOBN(0x2056ca5a, 0x6bed0467), TOBN(0x7916a1f7, 0x5b63728c)}}, + {{TOBN(0xd4f9497d, 0x53a4f566), TOBN(0x89734664, 0x97b56810), + TOBN(0xf8e1da74, 0x0494a621), TOBN(0x82546a93, 0x8d011c68)}, + {TOBN(0x1f3acb19, 0xc61ac162), TOBN(0x52f8fa9c, 0xabad0d3e), + TOBN(0x15356523, 0xb4b7ea43), TOBN(0x5a16ad61, 0xae608125)}}, + {{TOBN(0xb0bcb87f, 0x4faed184), TOBN(0x5f236b1d, 0x5029f45f), + TOBN(0xd42c7607, 0x0bc6b1fc), TOBN(0xc644324e, 0x68aefce3)}, + {TOBN(0x8e191d59, 0x5c5d8446), TOBN(0xc0208077, 0x13ae1979), + TOBN(0xadcaee55, 0x3ba59cc7), TOBN(0x20ed6d6b, 0xa2cb81ba)}}, + {{TOBN(0x0952ba19, 0xb6efcffc), TOBN(0x60f12d68, 0x97c0b87c), + TOBN(0x4ee2c7c4, 0x9caa30bc), TOBN(0x767238b7, 0x97fbff4e)}, + {TOBN(0xebc73921, 0x501b5d92), TOBN(0x3279e3df, 0xc2a37737), + TOBN(0x9fc12bc8, 0x6d197543), TOBN(0xfa94dc6f, 0x0a40db4e)}}, + {{TOBN(0x7392b41a, 0x530ccbbd), TOBN(0x87c82146, 0xea823525), + TOBN(0xa52f984c, 0x05d98d0c), TOBN(0x2ae57d73, 0x5ef6974c)}, + {TOBN(0x9377f7bf, 0x3042a6dd), TOBN(0xb1a007c0, 0x19647a64), + TOBN(0xfaa9079a, 0x0cca9767), TOBN(0x3d81a25b, 0xf68f72d5)}}, + {{TOBN(0x752067f8, 0xff81578e), TOBN(0x78622150, 0x9045447d), + TOBN(0xc0c22fcf, 0x0505aa6f), TOBN(0x1030f0a6, 0x6bed1c77)}, + {TOBN(0x31f29f15, 0x1f0bd739), TOBN(0x2d7989c7, 0xe6debe85), + TOBN(0x5c070e72, 0x8e677e98), TOBN(0x0a817bd3, 0x06e81fd5)}}, + {{TOBN(0xc110d830, 0xb0f2ac95), TOBN(0x48d0995a, 0xab20e64e), + TOBN(0x0f3e00e1, 0x7729cd9a), TOBN(0x2a570c20, 0xdd556946)}, + {TOBN(0x912dbcfd, 0x4e86214d), TOBN(0x2d014ee2, 0xcf615498), + TOBN(0x55e2b1e6, 0x3530d76e), TOBN(0xc5135ae4, 0xfd0fd6d1)}}, + {{TOBN(0x0066273a, 0xd4f3049f), TOBN(0xbb8e9893, 0xe7087477), + TOBN(0x2dba1ddb, 0x14c6e5fd), TOBN(0xdba37886, 0x51f57e6c)}, + {TOBN(0x5aaee0a6, 0x5a72f2cf), TOBN(0x1208bfbf, 0x7bea5642), + TOBN(0xf5c6aa3b, 0x67872c37), TOBN(0xd726e083, 0x43f93224)}}, + {{TOBN(0x1854daa5, 0x061f1658), TOBN(0xc0016df1, 0xdf0cd2b3), + TOBN(0xc2a3f23e, 0x833d50de), TOBN(0x73b681d2, 0xbbbd3017)}, + {TOBN(0x2f046dc4, 0x3ac343c0), TOBN(0x9c847e7d, 0x85716421), + TOBN(0xe1e13c91, 0x0917eed4), TOBN(0x3fc9eebd, 0x63a1b9c6)}}, + {{TOBN(0x0f816a72, 0x7fe02299), TOBN(0x6335ccc2, 0x294f3319), + TOBN(0x3820179f, 0x4745c5be), TOBN(0xe647b782, 0x922f066e)}, + {TOBN(0xc22e49de, 0x02cafb8a), TOBN(0x299bc2ff, 0xfcc2eccc), + TOBN(0x9a8feea2, 0x6e0e8282), TOBN(0xa627278b, 0xfe893205)}}, + {{TOBN(0xa7e19733, 0x7933e47b), TOBN(0xf4ff6b13, 0x2e766402), + TOBN(0xa4d8be0a, 0x98440d9f), TOBN(0x658f5c2f, 0x38938808)}, + {TOBN(0x90b75677, 0xc95b3b3e), TOBN(0xfa044269, 0x3137b6ff), + TOBN(0x077b039b, 0x43c47c29), TOBN(0xcca95dd3, 0x8a6445b2)}}, + {{TOBN(0x0b498ba4, 0x2333fc4c), TOBN(0x274f8e68, 0xf736a1b1), + TOBN(0x6ca348fd, 0x5f1d4b2e), TOBN(0x24d3be78, 0xa8f10199)}, + {TOBN(0x8535f858, 0xca14f530), TOBN(0xa6e7f163, 0x5b982e51), + TOBN(0x847c8512, 0x36e1bf62), TOBN(0xf6a7c58e, 0x03448418)}}, + {{TOBN(0x583f3703, 0xf9374ab6), TOBN(0x864f9195, 0x6e564145), + TOBN(0x33bc3f48, 0x22526d50), TOBN(0x9f323c80, 0x1262a496)}, + {TOBN(0xaa97a7ae, 0x3f046a9a), TOBN(0x70da183e, 0xdf8a039a), + TOBN(0x5b68f71c, 0x52aa0ba6), TOBN(0x9be0fe51, 0x21459c2d)}}, + {{TOBN(0xc1e17eb6, 0xcbc613e5), TOBN(0x33131d55, 0x497ea61c), + TOBN(0x2f69d39e, 0xaf7eded5), TOBN(0x73c2f434, 0xde6af11b)}, + {TOBN(0x4ca52493, 0xa4a375fa), TOBN(0x5f06787c, 0xb833c5c2), + TOBN(0x814e091f, 0x3e6e71cf), TOBN(0x76451f57, 0x8b746666)}}}, + {{{TOBN(0x80f9bdef, 0x694db7e0), TOBN(0xedca8787, 0xb9fcddc6), + TOBN(0x51981c34, 0x03b8dce1), TOBN(0x4274dcf1, 0x70e10ba1)}, + {TOBN(0xf72743b8, 0x6def6d1a), TOBN(0xd25b1670, 0xebdb1866), + TOBN(0xc4491e8c, 0x050c6f58), TOBN(0x2be2b2ab, 0x87fbd7f5)}}, + {{TOBN(0x3e0e5c9d, 0xd111f8ec), TOBN(0xbcc33f8d, 0xb7c4e760), + TOBN(0x702f9a91, 0xbd392a51), TOBN(0x7da4a795, 0xc132e92d)}, + {TOBN(0x1a0b0ae3, 0x0bb1151b), TOBN(0x54febac8, 0x02e32251), + TOBN(0xea3a5082, 0x694e9e78), TOBN(0xe58ffec1, 0xe4fe40b8)}}, + {{TOBN(0xf85592fc, 0xd1e0cf9e), TOBN(0xdea75f0d, 0xc0e7b2e8), + TOBN(0xc04215cf, 0xc135584e), TOBN(0x174fc727, 0x2f57092a)}, + {TOBN(0xe7277877, 0xeb930bea), TOBN(0x504caccb, 0x5eb02a5a), + TOBN(0xf9fe08f7, 0xf5241b9b), TOBN(0xe7fb62f4, 0x8d5ca954)}}, + {{TOBN(0xfbb8349d, 0x29c4120b), TOBN(0x9f94391f, 0xc0d0d915), + TOBN(0xc4074fa7, 0x5410ba51), TOBN(0xa66adbf6, 0x150a5911)}, + {TOBN(0xc164543c, 0x34bfca38), TOBN(0xe0f27560, 0xb9e1ccfc), + TOBN(0x99da0f53, 0xe820219c), TOBN(0xe8234498, 0xc6b4997a)}}, + {{TOBN(0xcfb88b76, 0x9d4c5423), TOBN(0x9e56eb10, 0xb0521c49), + TOBN(0x418e0b5e, 0xbe8700a1), TOBN(0x00cbaad6, 0xf93cb58a)}, + {TOBN(0xe923fbde, 0xd92a5e67), TOBN(0xca4979ac, 0x1f347f11), + TOBN(0x89162d85, 0x6bc0585b), TOBN(0xdd6254af, 0xac3c70e3)}}, + {{TOBN(0x7b23c513, 0x516e19e4), TOBN(0x56e2e847, 0xc5c4d593), + TOBN(0x9f727d73, 0x5ce71ef6), TOBN(0x5b6304a6, 0xf79a44c5)}, + {TOBN(0x6638a736, 0x3ab7e433), TOBN(0x1adea470, 0xfe742f83), + TOBN(0xe054b854, 0x5b7fc19f), TOBN(0xf935381a, 0xba1d0698)}}, + {{TOBN(0x546eab2d, 0x799e9a74), TOBN(0x96239e0e, 0xa949f729), + TOBN(0xca274c6b, 0x7090055a), TOBN(0x835142c3, 0x9020c9b0)}, + {TOBN(0xa405667a, 0xa2e8807f), TOBN(0x29f2c085, 0x1aa3d39e), + TOBN(0xcc555d64, 0x42fc72f5), TOBN(0xe856e0e7, 0xfbeacb3c)}}, + {{TOBN(0xb5504f9d, 0x918e4936), TOBN(0x65035ef6, 0xb2513982), + TOBN(0x0553a0c2, 0x6f4d9cb9), TOBN(0x6cb10d56, 0xbea85509)}, + {TOBN(0x48d957b7, 0xa242da11), TOBN(0x16a4d3dd, 0x672b7268), + TOBN(0x3d7e637c, 0x8502a96b), TOBN(0x27c7032b, 0x730d463b)}}, + {{TOBN(0xbdc02b18, 0xe4136a14), TOBN(0xbacf969d, 0x678e32bf), + TOBN(0xc98d89a3, 0xdd9c3c03), TOBN(0x7b92420a, 0x23becc4f)}, + {TOBN(0xd4b41f78, 0xc64d565c), TOBN(0x9f969d00, 0x10f28295), + TOBN(0xec7f7f76, 0xb13d051a), TOBN(0x08945e1e, 0xa92da585)}}, + {{TOBN(0x55366b7d, 0x5846426f), TOBN(0xe7d09e89, 0x247d441d), + TOBN(0x510b404d, 0x736fbf48), TOBN(0x7fa003d0, 0xe784bd7d)}, + {TOBN(0x25f7614f, 0x17fd9596), TOBN(0x49e0e0a1, 0x35cb98db), + TOBN(0x2c65957b, 0x2e83a76a), TOBN(0x5d40da8d, 0xcddbe0f8)}}, + {{TOBN(0xf2b8c405, 0x050bad24), TOBN(0x8918426d, 0xc2aa4823), + TOBN(0x2aeab3dd, 0xa38365a7), TOBN(0x72031717, 0x7c91b690)}, + {TOBN(0x8b00d699, 0x60a94120), TOBN(0x478a255d, 0xe99eaeec), + TOBN(0xbf656a5f, 0x6f60aafd), TOBN(0xdfd7cb75, 0x5dee77b3)}}, + {{TOBN(0x37f68bb4, 0xa595939d), TOBN(0x03556479, 0x28740217), + TOBN(0x8e740e7c, 0x84ad7612), TOBN(0xd89bc843, 0x9044695f)}, + {TOBN(0xf7f3da5d, 0x85a9184d), TOBN(0x562563bb, 0x9fc0b074), + TOBN(0x06d2e6aa, 0xf88a888e), TOBN(0x612d8643, 0x161fbe7c)}}, + {{TOBN(0x465edba7, 0xf64085e7), TOBN(0xb230f304, 0x29aa8511), + TOBN(0x53388426, 0xcda2d188), TOBN(0x90885735, 0x4b666649)}, + {TOBN(0x6f02ff9a, 0x652f54f6), TOBN(0x65c82294, 0x5fae2bf0), + TOBN(0x7816ade0, 0x62f5eee3), TOBN(0xdcdbdf43, 0xfcc56d70)}}, + {{TOBN(0x9fb3bba3, 0x54530bb2), TOBN(0xbde3ef77, 0xcb0869ea), + TOBN(0x89bc9046, 0x0b431163), TOBN(0x4d03d7d2, 0xe4819a35)}, + {TOBN(0x33ae4f9e, 0x43b6a782), TOBN(0x216db307, 0x9c88a686), + TOBN(0x91dd88e0, 0x00ffedd9), TOBN(0xb280da9f, 0x12bd4840)}}, + {{TOBN(0x32a7cb8a, 0x1635e741), TOBN(0xfe14008a, 0x78be02a7), + TOBN(0x3fafb334, 0x1b7ae030), TOBN(0x7fd508e7, 0x5add0ce9)}, + {TOBN(0x72c83219, 0xd607ad51), TOBN(0x0f229c0a, 0x8d40964a), + TOBN(0x1be2c336, 0x1c878da2), TOBN(0xe0c96742, 0xeab2ab86)}}, + {{TOBN(0x458f8691, 0x3e538cd7), TOBN(0xa7001f6c, 0x8e08ad53), + TOBN(0x52b8c6e6, 0xbf5d15ff), TOBN(0x548234a4, 0x011215dd)}, + {TOBN(0xff5a9d2d, 0x3d5b4045), TOBN(0xb0ffeeb6, 0x4a904190), + TOBN(0x55a3aca4, 0x48607f8b), TOBN(0x8cbd665c, 0x30a0672a)}}, + {{TOBN(0x87f834e0, 0x42583068), TOBN(0x02da2aeb, 0xf3f6e683), + TOBN(0x6b763e5d, 0x05c12248), TOBN(0x7230378f, 0x65a8aefc)}, + {TOBN(0x93bd80b5, 0x71e8e5ca), TOBN(0x53ab041c, 0xb3b62524), + TOBN(0x1b860513, 0x6c9c552e), TOBN(0xe84d402c, 0xd5524e66)}}, + {{TOBN(0xa37f3573, 0xf37f5937), TOBN(0xeb0f6c7d, 0xd1e4fca5), + TOBN(0x2965a554, 0xac8ab0fc), TOBN(0x17fbf56c, 0x274676ac)}, + {TOBN(0x2e2f6bd9, 0xacf7d720), TOBN(0x41fc8f88, 0x10224766), + TOBN(0x517a14b3, 0x85d53bef), TOBN(0xdae327a5, 0x7d76a7d1)}}, + {{TOBN(0x6ad0a065, 0xc4818267), TOBN(0x33aa189b, 0x37c1bbc1), + TOBN(0x64970b52, 0x27392a92), TOBN(0x21699a1c, 0x2d1535ea)}, + {TOBN(0xcd20779c, 0xc2d7a7fd), TOBN(0xe3186059, 0x99c83cf2), + TOBN(0x9b69440b, 0x72c0b8c7), TOBN(0xa81497d7, 0x7b9e0e4d)}}, + {{TOBN(0x515d5c89, 0x1f5f82dc), TOBN(0x9a7f67d7, 0x6361079e), + TOBN(0xa8da81e3, 0x11a35330), TOBN(0xe44990c4, 0x4b18be1b)}, + {TOBN(0xc7d5ed95, 0xaf103e59), TOBN(0xece8aba7, 0x8dac9261), + TOBN(0xbe82b099, 0x9394b8d3), TOBN(0x6830f09a, 0x16adfe83)}}, + {{TOBN(0x250a29b4, 0x88172d01), TOBN(0x8b20bd65, 0xcaff9e02), + TOBN(0xb8a7661e, 0xe8a6329a), TOBN(0x4520304d, 0xd3fce920)}, + {TOBN(0xae45da1f, 0x2b47f7ef), TOBN(0xe07f5288, 0x5bffc540), + TOBN(0xf7997009, 0x3464f874), TOBN(0x2244c2cd, 0xa6fa1f38)}}, + {{TOBN(0x43c41ac1, 0x94d7d9b1), TOBN(0x5bafdd82, 0xc82e7f17), + TOBN(0xdf0614c1, 0x5fda0fca), TOBN(0x74b043a7, 0xa8ae37ad)}, + {TOBN(0x3ba6afa1, 0x9e71734c), TOBN(0x15d5437e, 0x9c450f2e), + TOBN(0x4a5883fe, 0x67e242b1), TOBN(0x5143bdc2, 0x2c1953c2)}}, + {{TOBN(0x542b8b53, 0xfc5e8920), TOBN(0x363bf9a8, 0x9a9cee08), + TOBN(0x02375f10, 0xc3486e08), TOBN(0x2037543b, 0x8c5e70d2)}, + {TOBN(0x7109bccc, 0x625640b4), TOBN(0xcbc1051e, 0x8bc62c3b), + TOBN(0xf8455fed, 0x803f26ea), TOBN(0x6badceab, 0xeb372424)}}, + {{TOBN(0xa2a9ce7c, 0x6b53f5f9), TOBN(0x64246595, 0x1b176d99), + TOBN(0xb1298d36, 0xb95c081b), TOBN(0x53505bb8, 0x1d9a9ee6)}, + {TOBN(0x3f6f9e61, 0xf2ba70b0), TOBN(0xd07e16c9, 0x8afad453), + TOBN(0x9f1694bb, 0xe7eb4a6a), TOBN(0xdfebced9, 0x3cb0bc8e)}}, + {{TOBN(0x92d3dcdc, 0x53868c8b), TOBN(0x174311a2, 0x386107a6), + TOBN(0x4109e07c, 0x689b4e64), TOBN(0x30e4587f, 0x2df3dcb6)}, + {TOBN(0x841aea31, 0x0811b3b2), TOBN(0x6144d41d, 0x0cce43ea), + TOBN(0x464c4581, 0x2a9a7803), TOBN(0xd03d371f, 0x3e158930)}}, + {{TOBN(0xc676d7f2, 0xb1f3390b), TOBN(0x9f7a1b8c, 0xa5b61272), + TOBN(0x4ebebfc9, 0xc2e127a9), TOBN(0x4602500c, 0x5dd997bf)}, + {TOBN(0x7f09771c, 0x4711230f), TOBN(0x058eb37c, 0x020f09c1), + TOBN(0xab693d4b, 0xfee5e38b), TOBN(0x9289eb1f, 0x4653cbc0)}}, + {{TOBN(0xbecf46ab, 0xd51b9cf5), TOBN(0xd2aa9c02, 0x9f0121af), + TOBN(0x36aaf7d2, 0xe90dc274), TOBN(0x909e4ea0, 0x48b95a3c)}, + {TOBN(0xe6b70496, 0x6f32dbdb), TOBN(0x672188a0, 0x8b030b3e), + TOBN(0xeeffe5b3, 0xcfb617e2), TOBN(0x87e947de, 0x7c82709e)}}, + {{TOBN(0xa44d2b39, 0x1770f5a7), TOBN(0xe4d4d791, 0x0e44eb82), + TOBN(0x42e69d1e, 0x3f69712a), TOBN(0xbf11c4d6, 0xac6a820e)}, + {TOBN(0xb5e7f3e5, 0x42c4224c), TOBN(0xd6b4e81c, 0x449d941c), + TOBN(0x5d72bd16, 0x5450e878), TOBN(0x6a61e28a, 0xee25ac54)}}, + {{TOBN(0x33272094, 0xe6f1cd95), TOBN(0x7512f30d, 0x0d18673f), + TOBN(0x32f7a4ca, 0x5afc1464), TOBN(0x2f095656, 0x6bbb977b)}, + {TOBN(0x586f47ca, 0xa8226200), TOBN(0x02c868ad, 0x1ac07369), + TOBN(0x4ef2b845, 0xc613acbe), TOBN(0x43d7563e, 0x0386054c)}}, + {{TOBN(0x54da9dc7, 0xab952578), TOBN(0xb5423df2, 0x26e84d0b), + TOBN(0xa8b64eeb, 0x9b872042), TOBN(0xac205782, 0x5990f6df)}, + {TOBN(0x4ff696eb, 0x21f4c77a), TOBN(0x1a79c3e4, 0xaab273af), + TOBN(0x29bc922e, 0x9436b3f1), TOBN(0xff807ef8, 0xd6d9a27a)}}, + {{TOBN(0x82acea3d, 0x778f22a0), TOBN(0xfb10b2e8, 0x5b5e7469), + TOBN(0xc0b16980, 0x2818ee7d), TOBN(0x011afff4, 0xc91c1a2f)}, + {TOBN(0x95a6d126, 0xad124418), TOBN(0x31c081a5, 0xe72e295f), + TOBN(0x36bb283a, 0xf2f4db75), TOBN(0xd115540f, 0x7acef462)}}, + {{TOBN(0xc7f3a8f8, 0x33f6746c), TOBN(0x21e46f65, 0xfea990ca), + TOBN(0x915fd5c5, 0xcaddb0a9), TOBN(0xbd41f016, 0x78614555)}, + {TOBN(0x346f4434, 0x426ffb58), TOBN(0x80559436, 0x14dbc204), + TOBN(0xf3dd20fe, 0x5a969b7f), TOBN(0x9d59e956, 0xe899a39a)}}, + {{TOBN(0xf1b0971c, 0x8ad4cf4b), TOBN(0x03448860, 0x2ffb8fb8), + TOBN(0xf071ac3c, 0x65340ba4), TOBN(0x408d0596, 0xb27fd758)}, + {TOBN(0xe7c78ea4, 0x98c364b0), TOBN(0xa4aac4a5, 0x051e8ab5), + TOBN(0xb9e1d560, 0x485d9002), TOBN(0x9acd518a, 0x88844455)}}, + {{TOBN(0xe4ca688f, 0xd06f56c0), TOBN(0xa48af70d, 0xdf027972), + TOBN(0x691f0f04, 0x5e9a609d), TOBN(0xa9dd82cd, 0xee61270e)}, + {TOBN(0x8903ca63, 0xa0ef18d3), TOBN(0x9fb7ee35, 0x3d6ca3bd), + TOBN(0xa7b4a09c, 0xabf47d03), TOBN(0x4cdada01, 0x1c67de8e)}}, + {{TOBN(0x52003749, 0x9355a244), TOBN(0xe77fd2b6, 0x4f2151a9), + TOBN(0x695d6cf6, 0x66b4efcb), TOBN(0xc5a0cacf, 0xda2cfe25)}, + {TOBN(0x104efe5c, 0xef811865), TOBN(0xf52813e8, 0x9ea5cc3d), + TOBN(0x855683dc, 0x40b58dbc), TOBN(0x0338ecde, 0x175fcb11)}}, + {{TOBN(0xf9a05637, 0x74921592), TOBN(0xb4f1261d, 0xb9bb9d31), + TOBN(0x551429b7, 0x4e9c5459), TOBN(0xbe182e6f, 0x6ea71f53)}, + {TOBN(0xd3a3b07c, 0xdfc50573), TOBN(0x9ba1afda, 0x62be8d44), + TOBN(0x9bcfd2cb, 0x52ab65d3), TOBN(0xdf11d547, 0xa9571802)}}, + {{TOBN(0x099403ee, 0x02a2404a), TOBN(0x497406f4, 0x21088a71), + TOBN(0x99479409, 0x5004ae71), TOBN(0xbdb42078, 0xa812c362)}, + {TOBN(0x2b72a30f, 0xd8828442), TOBN(0x283add27, 0xfcb5ed1c), + TOBN(0xf7c0e200, 0x66a40015), TOBN(0x3e3be641, 0x08b295ef)}}, + {{TOBN(0xac127dc1, 0xe038a675), TOBN(0x729deff3, 0x8c5c6320), + TOBN(0xb7df8fd4, 0xa90d2c53), TOBN(0x9b74b0ec, 0x681e7cd3)}, + {TOBN(0x5cb5a623, 0xdab407e5), TOBN(0xcdbd3615, 0x76b340c6), + TOBN(0xa184415a, 0x7d28392c), TOBN(0xc184c1d8, 0xe96f7830)}}, + {{TOBN(0xc3204f19, 0x81d3a80f), TOBN(0xfde0c841, 0xc8e02432), + TOBN(0x78203b3e, 0x8149e0c1), TOBN(0x5904bdbb, 0x08053a73)}, + {TOBN(0x30fc1dd1, 0x101b6805), TOBN(0x43c223bc, 0x49aa6d49), + TOBN(0x9ed67141, 0x7a174087), TOBN(0x311469a0, 0xd5997008)}}, + {{TOBN(0xb189b684, 0x5e43fc61), TOBN(0xf3282375, 0xe0d3ab57), + TOBN(0x4fa34b67, 0xb1181da8), TOBN(0x621ed0b2, 0x99ee52b8)}, + {TOBN(0x9b178de1, 0xad990676), TOBN(0xd51de67b, 0x56d54065), + TOBN(0x2a2c27c4, 0x7538c201), TOBN(0x33856ec8, 0x38a40f5c)}}, + {{TOBN(0x2522fc15, 0xbe6cdcde), TOBN(0x1e603f33, 0x9f0c6f89), + TOBN(0x7994edc3, 0x103e30a6), TOBN(0x033a00db, 0x220c853e)}, + {TOBN(0xd3cfa409, 0xf7bb7fd7), TOBN(0x70f8781e, 0x462d18f6), + TOBN(0xbbd82980, 0x687fe295), TOBN(0x6eef4c32, 0x595669f3)}}, + {{TOBN(0x86a9303b, 0x2f7e85c3), TOBN(0x5fce4621, 0x71988f9b), + TOBN(0x5b935bf6, 0xc138acb5), TOBN(0x30ea7d67, 0x25661212)}, + {TOBN(0xef1eb5f4, 0xe51ab9a2), TOBN(0x0587c98a, 0xae067c78), + TOBN(0xb3ce1b3c, 0x77ca9ca6), TOBN(0x2a553d4d, 0x54b5f057)}}, + {{TOBN(0xc7898236, 0x4da29ec2), TOBN(0xdbdd5d13, 0xb9c57316), + TOBN(0xc57d6e6b, 0x2cd80d47), TOBN(0x80b460cf, 0xfe9e7391)}, + {TOBN(0x98648cab, 0xf963c31e), TOBN(0x67f9f633, 0xcc4d32fd), + TOBN(0x0af42a9d, 0xfdf7c687), TOBN(0x55f292a3, 0x0b015ea7)}}, + {{TOBN(0x89e468b2, 0xcd21ab3d), TOBN(0xe504f022, 0xc393d392), + TOBN(0xab21e1d4, 0xa5013af9), TOBN(0xe3283f78, 0xc2c28acb)}, + {TOBN(0xf38b35f6, 0x226bf99f), TOBN(0xe8354274, 0x0e291e69), + TOBN(0x61673a15, 0xb20c162d), TOBN(0xc101dc75, 0xb04fbdbe)}}, + {{TOBN(0x8323b4c2, 0x255bd617), TOBN(0x6c969693, 0x6c2a9154), + TOBN(0xc6e65860, 0x62679387), TOBN(0x8e01db0c, 0xb8c88e23)}, + {TOBN(0x33c42873, 0x893a5559), TOBN(0x7630f04b, 0x47a3e149), + TOBN(0xb5d80805, 0xddcf35f8), TOBN(0x582ca080, 0x77dfe732)}}, + {{TOBN(0x2c7156e1, 0x0b1894a0), TOBN(0x92034001, 0xd81c68c0), + TOBN(0xed225d00, 0xc8b115b5), TOBN(0x237f9c22, 0x83b907f2)}, + {TOBN(0x0ea2f32f, 0x4470e2c0), TOBN(0xb725f7c1, 0x58be4e95), + TOBN(0x0f1dcafa, 0xb1ae5463), TOBN(0x59ed5187, 0x1ba2fc04)}}, + {{TOBN(0xf6e0f316, 0xd0115d4d), TOBN(0x5180b12f, 0xd3691599), + TOBN(0x157e32c9, 0x527f0a41), TOBN(0x7b0b081d, 0xa8e0ecc0)}, + {TOBN(0x6dbaaa8a, 0xbf4f0dd0), TOBN(0x99b289c7, 0x4d252696), + TOBN(0x79b7755e, 0xdbf864fe), TOBN(0x6974e2b1, 0x76cad3ab)}}, + {{TOBN(0x35dbbee2, 0x06ddd657), TOBN(0xe7cbdd11, 0x2ff3a96d), + TOBN(0x88381968, 0x076be758), TOBN(0x2d737e72, 0x08c91f5d)}, + {TOBN(0x5f83ab62, 0x86ec3776), TOBN(0x98aa649d, 0x945fa7a1), + TOBN(0xf477ec37, 0x72ef0933), TOBN(0x66f52b1e, 0x098c17b1)}}, + {{TOBN(0x9eec58fb, 0xd803738b), TOBN(0x91aaade7, 0xe4e86aa4), + TOBN(0x6b1ae617, 0xa5b51492), TOBN(0x63272121, 0xbbc45974)}, + {TOBN(0x7e0e28f0, 0x862c5129), TOBN(0x0a8f79a9, 0x3321a4a0), + TOBN(0xe26d1664, 0x5041c88f), TOBN(0x0571b805, 0x53233e3a)}}, + {{TOBN(0xd1b0ccde, 0xc9520711), TOBN(0x55a9e4ed, 0x3c8b84bf), + TOBN(0x9426bd39, 0xa1fef314), TOBN(0x4f5f638e, 0x6eb93f2b)}, + {TOBN(0xba2a1ed3, 0x2bf9341b), TOBN(0xd63c1321, 0x4d42d5a9), + TOBN(0xd2964a89, 0x316dc7c5), TOBN(0xd1759606, 0xca511851)}}, + {{TOBN(0xd8a9201f, 0xf9e6ed35), TOBN(0xb7b5ee45, 0x6736925a), + TOBN(0x0a83fbbc, 0x99581af7), TOBN(0x3076bc40, 0x64eeb051)}, + {TOBN(0x5511c98c, 0x02dec312), TOBN(0x270de898, 0x238dcb78), + TOBN(0x2cf4cf9c, 0x539c08c9), TOBN(0xa70cb65e, 0x38d3b06e)}}, + {{TOBN(0xb12ec10e, 0xcfe57bbd), TOBN(0x82c7b656, 0x35a0c2b5), + TOBN(0xddc7d5cd, 0x161c67bd), TOBN(0xe32e8985, 0xae3a32cc)}, + {TOBN(0x7aba9444, 0xd11a5529), TOBN(0xe964ed02, 0x2427fa1a), + TOBN(0x1528392d, 0x24a1770a), TOBN(0xa152ce2c, 0x12c72fcd)}}, + {{TOBN(0x714553a4, 0x8ec07649), TOBN(0x18b4c290, 0x459dd453), + TOBN(0xea32b714, 0x7b64b110), TOBN(0xb871bfa5, 0x2e6f07a2)}, + {TOBN(0xb67112e5, 0x9e2e3c9b), TOBN(0xfbf250e5, 0x44aa90f6), + TOBN(0xf77aedb8, 0xbd539006), TOBN(0x3b0cdf9a, 0xd172a66f)}}, + {{TOBN(0xedf69fea, 0xf8c51187), TOBN(0x05bb67ec, 0x741e4da7), + TOBN(0x47df0f32, 0x08114345), TOBN(0x56facb07, 0xbb9792b1)}, + {TOBN(0xf3e007e9, 0x8f6229e4), TOBN(0x62d103f4, 0x526fba0f), + TOBN(0x4f33bef7, 0xb0339d79), TOBN(0x9841357b, 0xb59bfec1)}}, + {{TOBN(0xfa8dbb59, 0xc34e6705), TOBN(0xc3c7180b, 0x7fdaa84c), + TOBN(0xf95872fc, 0xa4108537), TOBN(0x8750cc3b, 0x932a3e5a)}, + {TOBN(0xb61cc69d, 0xb7275d7d), TOBN(0xffa0168b, 0x2e59b2e9), + TOBN(0xca032abc, 0x6ecbb493), TOBN(0x1d86dbd3, 0x2c9082d8)}}, + {{TOBN(0xae1e0b67, 0xe28ef5ba), TOBN(0x2c9a4699, 0xcb18e169), + TOBN(0x0ecd0e33, 0x1e6bbd20), TOBN(0x571b360e, 0xaf5e81d2)}, + {TOBN(0xcd9fea58, 0x101c1d45), TOBN(0x6651788e, 0x18880452), + TOBN(0xa9972635, 0x1f8dd446), TOBN(0x44bed022, 0xe37281d0)}}, + {{TOBN(0x094b2b2d, 0x33da525d), TOBN(0xf193678e, 0x13144fd8), + TOBN(0xb8ab5ba4, 0xf4c1061d), TOBN(0x4343b5fa, 0xdccbe0f4)}, + {TOBN(0xa8702371, 0x63812713), TOBN(0x47bf6d2d, 0xf7611d93), + TOBN(0x46729b8c, 0xbd21e1d7), TOBN(0x7484d4e0, 0xd629e77d)}}, + {{TOBN(0x830e6eea, 0x60dbac1f), TOBN(0x23d8c484, 0xda06a2f7), + TOBN(0x896714b0, 0x50ca535b), TOBN(0xdc8d3644, 0xebd97a9b)}, + {TOBN(0x106ef9fa, 0xb12177b4), TOBN(0xf79bf464, 0x534d5d9c), + TOBN(0x2537a349, 0xa6ab360b), TOBN(0xc7c54253, 0xa00c744f)}}, + {{TOBN(0xb3c7a047, 0xe5911a76), TOBN(0x61ffa5c8, 0x647f1ee7), + TOBN(0x15aed36f, 0x8f56ab42), TOBN(0x6a0d41b0, 0xa3ff9ac9)}, + {TOBN(0x68f469f5, 0xcc30d357), TOBN(0xbe9adf81, 0x6b72be96), + TOBN(0x1cd926fe, 0x903ad461), TOBN(0x7e89e38f, 0xcaca441b)}}, + {{TOBN(0xf0f82de5, 0xfacf69d4), TOBN(0x363b7e76, 0x4775344c), + TOBN(0x6894f312, 0xb2e36d04), TOBN(0x3c6cb4fe, 0x11d1c9a5)}, + {TOBN(0x85d9c339, 0x4008e1f2), TOBN(0x5e9a85ea, 0x249f326c), + TOBN(0xdc35c60a, 0x678c5e06), TOBN(0xc08b944f, 0x9f86fba9)}}, + {{TOBN(0xde40c02c, 0x89f71f0f), TOBN(0xad8f3e31, 0xff3da3c0), + TOBN(0x3ea5096b, 0x42125ded), TOBN(0x13879cbf, 0xa7379183)}, + {TOBN(0x6f4714a5, 0x6b306a0b), TOBN(0x359c2ea6, 0x67646c5e), + TOBN(0xfacf8943, 0x07726368), TOBN(0x07a58935, 0x65ff431e)}}, + {{TOBN(0x24d661d1, 0x68754ab0), TOBN(0x801fce1d, 0x6f429a76), + TOBN(0xc068a85f, 0xa58ce769), TOBN(0xedc35c54, 0x5d5eca2b)}, + {TOBN(0xea31276f, 0xa3f660d1), TOBN(0xa0184ebe, 0xb8fc7167), + TOBN(0x0f20f21a, 0x1d8db0ae), TOBN(0xd96d095f, 0x56c35e12)}}, + {{TOBN(0xedf402b5, 0xf8c2a25b), TOBN(0x1bb772b9, 0x059204b6), + TOBN(0x50cbeae2, 0x19b4e34c), TOBN(0x93109d80, 0x3fa0845a)}, + {TOBN(0x54f7ccf7, 0x8ef59fb5), TOBN(0x3b438fe2, 0x88070963), + TOBN(0x9e28c659, 0x31f3ba9b), TOBN(0x9cc31b46, 0xead9da92)}}, + {{TOBN(0x3c2f0ba9, 0xb733aa5f), TOBN(0xdece47cb, 0xf05af235), + TOBN(0xf8e3f715, 0xa2ac82a5), TOBN(0xc97ba641, 0x2203f18a)}, + {TOBN(0xc3af5504, 0x09c11060), TOBN(0x56ea2c05, 0x46af512d), + TOBN(0xfac28daf, 0xf3f28146), TOBN(0x87fab43a, 0x959ef494)}}}, + {{{TOBN(0x09891641, 0xd4c5105f), TOBN(0x1ae80f8e, 0x6d7fbd65), + TOBN(0x9d67225f, 0xbee6bdb0), TOBN(0x3b433b59, 0x7fc4d860)}, + {TOBN(0x44e66db6, 0x93e85638), TOBN(0xf7b59252, 0xe3e9862f), + TOBN(0xdb785157, 0x665c32ec), TOBN(0x702fefd7, 0xae362f50)}}, + {{TOBN(0x3754475d, 0x0fefb0c3), TOBN(0xd48fb56b, 0x46d7c35d), + TOBN(0xa070b633, 0x363798a4), TOBN(0xae89f3d2, 0x8fdb98e6)}, + {TOBN(0x970b89c8, 0x6363d14c), TOBN(0x89817521, 0x67abd27d), + TOBN(0x9bf7d474, 0x44d5a021), TOBN(0xb3083baf, 0xcac72aee)}}, + {{TOBN(0x389741de, 0xbe949a44), TOBN(0x638e9388, 0x546a4fa5), + TOBN(0x3fe6419c, 0xa0047bdc), TOBN(0x7047f648, 0xaaea57ca)}, + {TOBN(0x54e48a90, 0x41fbab17), TOBN(0xda8e0b28, 0x576bdba2), + TOBN(0xe807eebc, 0xc72afddc), TOBN(0x07d3336d, 0xf42577bf)}}, + {{TOBN(0x62a8c244, 0xbfe20925), TOBN(0x91c19ac3, 0x8fdce867), + TOBN(0x5a96a5d5, 0xdd387063), TOBN(0x61d587d4, 0x21d324f6)}, + {TOBN(0xe87673a2, 0xa37173ea), TOBN(0x23848008, 0x53778b65), + TOBN(0x10f8441e, 0x05bab43e), TOBN(0xfa11fe12, 0x4621efbe)}}, + {{TOBN(0x047b772e, 0x81685d7b), TOBN(0x23f27d81, 0xbf34a976), + TOBN(0xc27608e2, 0x915f48ef), TOBN(0x3b0b43fa, 0xa521d5c3)}, + {TOBN(0x7613fb26, 0x63ca7284), TOBN(0x7f5729b4, 0x1d4db837), + TOBN(0x87b14898, 0x583b526b), TOBN(0x00b732a6, 0xbbadd3d1)}}, + {{TOBN(0x8e02f426, 0x2048e396), TOBN(0x436b50b6, 0x383d9de4), + TOBN(0xf78d3481, 0x471e85ad), TOBN(0x8b01ea6a, 0xd005c8d6)}, + {TOBN(0xd3c7afee, 0x97015c07), TOBN(0x46cdf1a9, 0x4e3ba2ae), + TOBN(0x7a42e501, 0x83d3a1d2), TOBN(0xd54b5268, 0xb541dff4)}}, + {{TOBN(0x3f24cf30, 0x4e23e9bc), TOBN(0x4387f816, 0x126e3624), + TOBN(0x26a46a03, 0x3b0b6d61), TOBN(0xaf1bc845, 0x8b2d777c)}, + {TOBN(0x25c401ba, 0x527de79c), TOBN(0x0e1346d4, 0x4261bbb6), + TOBN(0x4b96c44b, 0x287b4bc7), TOBN(0x658493c7, 0x5254562f)}}, + {{TOBN(0x23f949fe, 0xb8a24a20), TOBN(0x17ebfed1, 0xf52ca53f), + TOBN(0x9b691bbe, 0xbcfb4853), TOBN(0x5617ff6b, 0x6278a05d)}, + {TOBN(0x241b34c5, 0xe3c99ebd), TOBN(0xfc64242e, 0x1784156a), + TOBN(0x4206482f, 0x695d67df), TOBN(0xb967ce0e, 0xee27c011)}}, + {{TOBN(0x65db3751, 0x21c80b5d), TOBN(0x2e7a563c, 0xa31ecca0), + TOBN(0xe56ffc4e, 0x5238a07e), TOBN(0x3d6c2966, 0x32ced854)}, + {TOBN(0xe99d7d1a, 0xaf70b885), TOBN(0xafc3bad9, 0x2d686459), + TOBN(0x9c78bf46, 0x0cc8ba5b), TOBN(0x5a439519, 0x18955aa3)}}, + {{TOBN(0xf8b517a8, 0x5fe4e314), TOBN(0xe60234d0, 0xfcb8906f), + TOBN(0xffe542ac, 0xf2061b23), TOBN(0x287e191f, 0x6b4cb59c)}, + {TOBN(0x21857ddc, 0x09d877d8), TOBN(0x1c23478c, 0x14678941), + TOBN(0xbbf0c056, 0xb6e05ea4), TOBN(0x82da4b53, 0xb01594fe)}}, + {{TOBN(0xf7526791, 0xfadb8608), TOBN(0x049e832d, 0x7b74cdf6), + TOBN(0xa43581cc, 0xc2b90a34), TOBN(0x73639eb8, 0x9360b10c)}, + {TOBN(0x4fba331f, 0xe1e4a71b), TOBN(0x6ffd6b93, 0x8072f919), + TOBN(0x6e53271c, 0x65679032), TOBN(0x67206444, 0xf14272ce)}}, + {{TOBN(0xc0f734a3, 0xb2335834), TOBN(0x9526205a, 0x90ef6860), + TOBN(0xcb8be717, 0x04e2bb0d), TOBN(0x2418871e, 0x02f383fa)}, + {TOBN(0xd7177681, 0x4082c157), TOBN(0xcc914ad0, 0x29c20073), + TOBN(0xf186c1eb, 0xe587e728), TOBN(0x6fdb3c22, 0x61bcd5fd)}}, + {{TOBN(0x30d014a6, 0xf2f9f8e9), TOBN(0x963ece23, 0x4fec49d2), + TOBN(0x862025c5, 0x9605a8d9), TOBN(0x39874445, 0x19f8929a)}, + {TOBN(0x01b6ff65, 0x12bf476a), TOBN(0x598a64d8, 0x09cf7d91), + TOBN(0xd7ec7749, 0x93be56ca), TOBN(0x10899785, 0xcbb33615)}}, + {{TOBN(0xb8a092fd, 0x02eee3ad), TOBN(0xa86b3d35, 0x30145270), + TOBN(0x323d98c6, 0x8512b675), TOBN(0x4b8bc785, 0x62ebb40f)}, + {TOBN(0x7d301f54, 0x413f9cde), TOBN(0xa5e4fb4f, 0x2bab5664), + TOBN(0x1d2b252d, 0x1cbfec23), TOBN(0xfcd576bb, 0xe177120d)}}, + {{TOBN(0x04427d3e, 0x83731a34), TOBN(0x2bb9028e, 0xed836e8e), + TOBN(0xb36acff8, 0xb612ca7c), TOBN(0xb88fe5ef, 0xd3d9c73a)}, + {TOBN(0xbe2a6bc6, 0xedea4eb3), TOBN(0x43b93133, 0x488eec77), + TOBN(0xf41ff566, 0xb17106e1), TOBN(0x469e9172, 0x654efa32)}}, + {{TOBN(0xb4480f04, 0x41c23fa3), TOBN(0xb4712eb0, 0xc1989a2e), + TOBN(0x3ccbba0f, 0x93a29ca7), TOBN(0x6e205c14, 0xd619428c)}, + {TOBN(0x90db7957, 0xb3641686), TOBN(0x0432691d, 0x45ac8b4e), + TOBN(0x07a759ac, 0xf64e0350), TOBN(0x0514d89c, 0x9c972517)}}, + {{TOBN(0x1701147f, 0xa8e67fc3), TOBN(0x9e2e0b8b, 0xab2085be), + TOBN(0xd5651824, 0xac284e57), TOBN(0x890d4325, 0x74893664)}, + {TOBN(0x8a7c5e6e, 0xc55e68a3), TOBN(0xbf12e90b, 0x4339c85a), + TOBN(0x31846b85, 0xf922b655), TOBN(0x9a54ce4d, 0x0bf4d700)}}, + {{TOBN(0xd7f4e83a, 0xf1a14295), TOBN(0x916f955c, 0xb285d4f9), + TOBN(0xe57bb0e0, 0x99ffdaba), TOBN(0x28a43034, 0xeab0d152)}, + {TOBN(0x0a36ffa2, 0xb8a9cef8), TOBN(0x5517407e, 0xb9ec051a), + TOBN(0x9c796096, 0xea68e672), TOBN(0x853db5fb, 0xfb3c77fb)}}, + {{TOBN(0x21474ba9, 0xe864a51a), TOBN(0x6c267699, 0x6e8a1b8b), + TOBN(0x7c823626, 0x94120a28), TOBN(0xe61e9a48, 0x8383a5db)}, + {TOBN(0x7dd75003, 0x9f84216d), TOBN(0xab020d07, 0xad43cd85), + TOBN(0x9437ae48, 0xda12c659), TOBN(0x6449c2eb, 0xe65452ad)}}, + {{TOBN(0xcc7c4c1c, 0x2cf9d7c1), TOBN(0x1320886a, 0xee95e5ab), + TOBN(0xbb7b9056, 0xbeae170c), TOBN(0xc8a5b250, 0xdbc0d662)}, + {TOBN(0x4ed81432, 0xc11d2303), TOBN(0x7da66912, 0x1f03769f), + TOBN(0x3ac7a5fd, 0x84539828), TOBN(0x14dada94, 0x3bccdd02)}}, + {{TOBN(0x8b84c321, 0x7ef6b0d1), TOBN(0x52a9477a, 0x7c933f22), + TOBN(0x5ef6728a, 0xfd440b82), TOBN(0x5c3bd859, 0x6ce4bd5e)}, + {TOBN(0x918b80f5, 0xf22c2d3e), TOBN(0x368d5040, 0xb7bb6cc5), + TOBN(0xb66142a1, 0x2695a11c), TOBN(0x60ac583a, 0xeb19ea70)}}, + {{TOBN(0x317cbb98, 0x0eab2437), TOBN(0x8cc08c55, 0x5e2654c8), + TOBN(0xfe2d6520, 0xe6d8307f), TOBN(0xe9f147f3, 0x57428993)}, + {TOBN(0x5f9c7d14, 0xd2fd6cf1), TOBN(0xa3ecd064, 0x2d4fcbb0), + TOBN(0xad83fef0, 0x8e7341f7), TOBN(0x643f23a0, 0x3a63115c)}}, + {{TOBN(0xd38a78ab, 0xe65ab743), TOBN(0xbf7c75b1, 0x35edc89c), + TOBN(0x3dd8752e, 0x530df568), TOBN(0xf85c4a76, 0xe308c682)}, + {TOBN(0x4c9955b2, 0xe68acf37), TOBN(0xa544df3d, 0xab32af85), + TOBN(0x4b8ec3f5, 0xa25cf493), TOBN(0x4d8f2764, 0x1a622feb)}}, + {{TOBN(0x7bb4f7aa, 0xf0dcbc49), TOBN(0x7de551f9, 0x70bbb45b), + TOBN(0xcfd0f3e4, 0x9f2ca2e5), TOBN(0xece58709, 0x1f5c76ef)}, + {TOBN(0x32920edd, 0x167d79ae), TOBN(0x039df8a2, 0xfa7d7ec1), + TOBN(0xf46206c0, 0xbb30af91), TOBN(0x1ff5e2f5, 0x22676b59)}}, + {{TOBN(0x11f4a039, 0x6ea51d66), TOBN(0x506c1445, 0x807d7a26), + TOBN(0x60da5705, 0x755a9b24), TOBN(0x8fc8cc32, 0x1f1a319e)}, + {TOBN(0x83642d4d, 0x9433d67d), TOBN(0x7fa5cb8f, 0x6a7dd296), + TOBN(0x576591db, 0x9b7bde07), TOBN(0x13173d25, 0x419716fb)}}, + {{TOBN(0xea30599d, 0xd5b340ff), TOBN(0xfc6b5297, 0xb0fe76c5), + TOBN(0x1c6968c8, 0xab8f5adc), TOBN(0xf723c7f5, 0x901c928d)}, + {TOBN(0x4203c321, 0x9773d402), TOBN(0xdf7c6aa3, 0x1b51dd47), + TOBN(0x3d49e37a, 0x552be23c), TOBN(0x57febee8, 0x0b5a6e87)}}, + {{TOBN(0xc5ecbee4, 0x7bd8e739), TOBN(0x79d44994, 0xae63bf75), + TOBN(0x168bd00f, 0x38fb8923), TOBN(0x75d48ee4, 0xd0533130)}, + {TOBN(0x554f77aa, 0xdb5cdf33), TOBN(0x3396e896, 0x3c696769), + TOBN(0x2fdddbf2, 0xd3fd674e), TOBN(0xbbb8f6ee, 0x99d0e3e5)}}, + {{TOBN(0x51b90651, 0xcbae2f70), TOBN(0xefc4bc05, 0x93aaa8eb), + TOBN(0x8ecd8689, 0xdd1df499), TOBN(0x1aee99a8, 0x22f367a5)}, + {TOBN(0x95d485b9, 0xae8274c5), TOBN(0x6c14d445, 0x7d30b39c), + TOBN(0xbafea90b, 0xbcc1ef81), TOBN(0x7c5f317a, 0xa459a2ed)}}, + {{TOBN(0x01211075, 0x4ef44227), TOBN(0xa17bed6e, 0xdc20f496), + TOBN(0x0cdfe424, 0x819853cd), TOBN(0x13793298, 0xf71e2ce7)}, + {TOBN(0x3c1f3078, 0xdbbe307b), TOBN(0x6dd1c20e, 0x76ee9936), + TOBN(0x23ee4b57, 0x423caa20), TOBN(0x4ac3793b, 0x8efb840e)}}, + {{TOBN(0x934438eb, 0xed1f8ca0), TOBN(0x3e546658, 0x4ebb25a2), + TOBN(0xc415af0e, 0xc069896f), TOBN(0xc13eddb0, 0x9a5aa43d)}, + {TOBN(0x7a04204f, 0xd49eb8f6), TOBN(0xd0d5bdfc, 0xd74f1670), + TOBN(0x3697e286, 0x56fc0558), TOBN(0x10207371, 0x01cebade)}}, + {{TOBN(0x5f87e690, 0x0647a82b), TOBN(0x908e0ed4, 0x8f40054f), + TOBN(0xa9f633d4, 0x79853803), TOBN(0x8ed13c9a, 0x4a28b252)}, + {TOBN(0x3e2ef676, 0x1f460f64), TOBN(0x53930b9b, 0x36d06336), + TOBN(0x347073ac, 0x8fc4979b), TOBN(0x84380e0e, 0x5ecd5597)}}, + {{TOBN(0xe3b22c6b, 0xc4fe3c39), TOBN(0xba4a8153, 0x6c7bebdf), + TOBN(0xf23ab6b7, 0x25693459), TOBN(0x53bc3770, 0x14922b11)}, + {TOBN(0x4645c8ab, 0x5afc60db), TOBN(0xaa022355, 0x20b9f2a3), + TOBN(0x52a2954c, 0xce0fc507), TOBN(0x8c2731bb, 0x7ce1c2e7)}}, + {{TOBN(0xf39608ab, 0x18a0339d), TOBN(0xac7a658d, 0x3735436c), + TOBN(0xb22c2b07, 0xcd992b4f), TOBN(0x4e83daec, 0xf40dcfd4)}, + {TOBN(0x8a34c7be, 0x2f39ea3e), TOBN(0xef0c005f, 0xb0a56d2e), + TOBN(0x62731f6a, 0x6edd8038), TOBN(0x5721d740, 0x4e3cb075)}}, + {{TOBN(0x1ea41511, 0xfbeeee1b), TOBN(0xd1ef5e73, 0xef1d0c05), + TOBN(0x42feefd1, 0x73c07d35), TOBN(0xe530a00a, 0x8a329493)}, + {TOBN(0x5d55b7fe, 0xf15ebfb0), TOBN(0x549de03c, 0xd322491a), + TOBN(0xf7b5f602, 0x745b3237), TOBN(0x3632a3a2, 0x1ab6e2b6)}}, + {{TOBN(0x0d3bba89, 0x0ef59f78), TOBN(0x0dfc6443, 0xc9e52b9a), + TOBN(0x1dc79699, 0x72631447), TOBN(0xef033917, 0xb3be20b1)}, + {TOBN(0x0c92735d, 0xb1383948), TOBN(0xc1fc29a2, 0xc0dd7d7d), + TOBN(0x6485b697, 0x403ed068), TOBN(0x13bfaab3, 0xaac93bdc)}}, + {{TOBN(0x410dc6a9, 0x0deeaf52), TOBN(0xb003fb02, 0x4c641c15), + TOBN(0x1384978c, 0x5bc504c4), TOBN(0x37640487, 0x864a6a77)}, + {TOBN(0x05991bc6, 0x222a77da), TOBN(0x62260a57, 0x5e47eb11), + TOBN(0xc7af6613, 0xf21b432c), TOBN(0x22f3acc9, 0xab4953e9)}}, + {{TOBN(0x52934922, 0x8e41d155), TOBN(0x4d024568, 0x3ac059ef), + TOBN(0xb0201755, 0x4d884411), TOBN(0xce8055cf, 0xa59a178f)}, + {TOBN(0xcd77d1af, 0xf6204549), TOBN(0xa0a00a3e, 0xc7066759), + TOBN(0x471071ef, 0x0272c229), TOBN(0x009bcf6b, 0xd3c4b6b0)}}, + {{TOBN(0x2a2638a8, 0x22305177), TOBN(0xd51d59df, 0x41645bbf), + TOBN(0xa81142fd, 0xc0a7a3c0), TOBN(0xa17eca6d, 0x4c7063ee)}, + {TOBN(0x0bb887ed, 0x60d9dcec), TOBN(0xd6d28e51, 0x20ad2455), + TOBN(0xebed6308, 0xa67102ba), TOBN(0x042c3114, 0x8bffa408)}}, + {{TOBN(0xfd099ac5, 0x8aa68e30), TOBN(0x7a6a3d7c, 0x1483513e), + TOBN(0xffcc6b75, 0xba2d8f0c), TOBN(0x54dacf96, 0x1e78b954)}, + {TOBN(0xf645696f, 0xa4a9af89), TOBN(0x3a411940, 0x06ac98ec), + TOBN(0x41b8b3f6, 0x22a67a20), TOBN(0x2d0b1e0f, 0x99dec626)}}, + {{TOBN(0x27c89192, 0x40be34e8), TOBN(0xc7162b37, 0x91907f35), + TOBN(0x90188ec1, 0xa956702b), TOBN(0xca132f7d, 0xdf93769c)}, + {TOBN(0x3ece44f9, 0x0e2025b4), TOBN(0x67aaec69, 0x0c62f14c), + TOBN(0xad741418, 0x22e3cc11), TOBN(0xcf9b75c3, 0x7ff9a50e)}}, + {{TOBN(0x02fa2b16, 0x4d348272), TOBN(0xbd99d61a, 0x9959d56d), + TOBN(0xbc4f19db, 0x18762916), TOBN(0xcc7cce50, 0x49c1ac80)}, + {TOBN(0x4d59ebaa, 0xd846bd83), TOBN(0x8775a9dc, 0xa9202849), + TOBN(0x07ec4ae1, 0x6e1f4ca9), TOBN(0x27eb5875, 0xba893f11)}}, + {{TOBN(0x00284d51, 0x662cc565), TOBN(0x82353a6b, 0x0db4138d), + TOBN(0xd9c7aaaa, 0xaa32a594), TOBN(0xf5528b5e, 0xa5669c47)}, + {TOBN(0xf3220231, 0x2f23c5ff), TOBN(0xe3e8147a, 0x6affa3a1), + TOBN(0xfb423d5c, 0x202ddda0), TOBN(0x3d6414ac, 0x6b871bd4)}}, + {{TOBN(0x586f82e1, 0xa51a168a), TOBN(0xb712c671, 0x48ae5448), + TOBN(0x9a2e4bd1, 0x76233eb8), TOBN(0x0188223a, 0x78811ca9)}, + {TOBN(0x553c5e21, 0xf7c18de1), TOBN(0x7682e451, 0xb27bb286), + TOBN(0x3ed036b3, 0x0e51e929), TOBN(0xf487211b, 0xec9cb34f)}}, + {{TOBN(0x0d094277, 0x0c24efc8), TOBN(0x0349fd04, 0xbef737a4), + TOBN(0x6d1c9dd2, 0x514cdd28), TOBN(0x29c135ff, 0x30da9521)}, + {TOBN(0xea6e4508, 0xf78b0b6f), TOBN(0x176f5dd2, 0x678c143c), + TOBN(0x08148418, 0x4be21e65), TOBN(0x27f7525c, 0xe7df38c4)}}, + {{TOBN(0x1fb70e09, 0x748ab1a4), TOBN(0x9cba50a0, 0x5efe4433), + TOBN(0x7846c7a6, 0x15f75af2), TOBN(0x2a7c2c57, 0x5ee73ea8)}, + {TOBN(0x42e566a4, 0x3f0a449a), TOBN(0x45474c3b, 0xad90fc3d), + TOBN(0x7447be3d, 0x8b61d057), TOBN(0x3e9d1cf1, 0x3a4ec092)}}, + {{TOBN(0x1603e453, 0xf380a6e6), TOBN(0x0b86e431, 0x9b1437c2), + TOBN(0x7a4173f2, 0xef29610a), TOBN(0x8fa729a7, 0xf03d57f7)}, + {TOBN(0x3e186f6e, 0x6c9c217e), TOBN(0xbe1d3079, 0x91919524), + TOBN(0x92a62a70, 0x153d4fb1), TOBN(0x32ed3e34, 0xd68c2f71)}}, + {{TOBN(0xd785027f, 0x9eb1a8b7), TOBN(0xbc37eb77, 0xc5b22fe8), + TOBN(0x466b34f0, 0xb9d6a191), TOBN(0x008a89af, 0x9a05f816)}, + {TOBN(0x19b028fb, 0x7d42c10a), TOBN(0x7fe8c92f, 0x49b3f6b8), + TOBN(0x58907cc0, 0xa5a0ade3), TOBN(0xb3154f51, 0x559d1a7c)}}, + {{TOBN(0x5066efb6, 0xd9790ed6), TOBN(0xa77a0cbc, 0xa6aa793b), + TOBN(0x1a915f3c, 0x223e042e), TOBN(0x1c5def04, 0x69c5874b)}, + {TOBN(0x0e830078, 0x73b6c1da), TOBN(0x55cf85d2, 0xfcd8557a), + TOBN(0x0f7c7c76, 0x0460f3b1), TOBN(0x87052acb, 0x46e58063)}}, + {{TOBN(0x09212b80, 0x907eae66), TOBN(0x3cb068e0, 0x4d721c89), + TOBN(0xa87941ae, 0xdd45ac1c), TOBN(0xde8d5c0d, 0x0daa0dbb)}, + {TOBN(0xda421fdc, 0xe3502e6e), TOBN(0xc8944201, 0x4d89a084), + TOBN(0x7307ba5e, 0xf0c24bfb), TOBN(0xda212beb, 0x20bde0ef)}}, + {{TOBN(0xea2da24b, 0xf82ce682), TOBN(0x058d3816, 0x07f71fe4), + TOBN(0x35a02462, 0x5ffad8de), TOBN(0xcd7b05dc, 0xaadcefab)}, + {TOBN(0xd442f8ed, 0x1d9f54ec), TOBN(0x8be3d618, 0xb2d3b5ca), + TOBN(0xe2220ed0, 0xe06b2ce2), TOBN(0x82699a5f, 0x1b0da4c0)}}, + {{TOBN(0x3ff106f5, 0x71c0c3a7), TOBN(0x8f580f5a, 0x0d34180c), + TOBN(0x4ebb120e, 0x22d7d375), TOBN(0x5e5782cc, 0xe9513675)}, + {TOBN(0x2275580c, 0x99c82a70), TOBN(0xe8359fbf, 0x15ea8c4c), + TOBN(0x53b48db8, 0x7b415e70), TOBN(0xaacf2240, 0x100c6014)}}, + {{TOBN(0x9faaccf5, 0xe4652f1d), TOBN(0xbd6fdd2a, 0xd56157b2), + TOBN(0xa4f4fb1f, 0x6261ec50), TOBN(0x244e55ad, 0x476bcd52)}, + {TOBN(0x881c9305, 0x047d320b), TOBN(0x1ca983d5, 0x6181263f), + TOBN(0x354e9a44, 0x278fb8ee), TOBN(0xad2dbc0f, 0x396e4964)}}, + {{TOBN(0x723f3aa2, 0x9268b3de), TOBN(0x0d1ca29a, 0xe6e0609a), + TOBN(0x794866aa, 0x6cf44252), TOBN(0x0b59f3e3, 0x01af87ed)}, + {TOBN(0xe234e5ff, 0x7f4a6c51), TOBN(0xa8768fd2, 0x61dc2f7e), + TOBN(0xdafc7332, 0x0a94d81f), TOBN(0xd7f84282, 0x06938ce1)}}, + {{TOBN(0xae0b3c0e, 0x0546063e), TOBN(0x7fbadcb2, 0x5d61abc6), + TOBN(0xd5d7a2c9, 0x369ac400), TOBN(0xa5978d09, 0xae67d10c)}, + {TOBN(0x290f211e, 0x4f85eaac), TOBN(0xe61e2ad1, 0xfacac681), + TOBN(0xae125225, 0x388384cd), TOBN(0xa7fb68e9, 0xccfde30f)}}, + {{TOBN(0x7a59b936, 0x3daed4c2), TOBN(0x80a9aa40, 0x2606f789), + TOBN(0xb40c1ea5, 0xf6a6d90a), TOBN(0x948364d3, 0x514d5885)}, + {TOBN(0x062ebc60, 0x70985182), TOBN(0xa6db5b0e, 0x33310895), + TOBN(0x64a12175, 0xe329c2f5), TOBN(0xc5f25bd2, 0x90ea237e)}}, + {{TOBN(0x7915c524, 0x2d0a4c23), TOBN(0xeb5d26e4, 0x6bb3cc52), + TOBN(0x369a9116, 0xc09e2c92), TOBN(0x0c527f92, 0xcf182cf8)}, + {TOBN(0x9e591938, 0x2aede0ac), TOBN(0xb2922208, 0x6cc34939), + TOBN(0x3c9d8962, 0x99a34361), TOBN(0x3c81836d, 0xc1905fe6)}}, + {{TOBN(0x4bfeb57f, 0xa001ec5a), TOBN(0xe993f5bb, 0xa0dc5dba), + TOBN(0x47884109, 0x724a1380), TOBN(0x8a0369ab, 0x32fe9a04)}, + {TOBN(0xea068d60, 0x8c927db8), TOBN(0xbf5f37cf, 0x94655741), + TOBN(0x47d402a2, 0x04b6c7ea), TOBN(0x4551c295, 0x6af259cb)}}, + {{TOBN(0x698b71e7, 0xed77ee8b), TOBN(0xbddf7bd0, 0xf309d5c7), + TOBN(0x6201c22c, 0x34e780ca), TOBN(0xab04f7d8, 0x4c295ef4)}, + {TOBN(0x1c947294, 0x4313a8ce), TOBN(0xe532e4ac, 0x92ca4cfe), + TOBN(0x89738f80, 0xd0a7a97a), TOBN(0xec088c88, 0xa580fd5b)}}, + {{TOBN(0x612b1ecc, 0x42ce9e51), TOBN(0x8f9840fd, 0xb25fdd2a), + TOBN(0x3cda78c0, 0x01e7f839), TOBN(0x546b3d3a, 0xece05480)}, + {TOBN(0x271719a9, 0x80d30916), TOBN(0x45497107, 0x584c20c4), + TOBN(0xaf8f9478, 0x5bc78608), TOBN(0x28c7d484, 0x277e2a4c)}}, + {{TOBN(0xfce01767, 0x88a2ffe4), TOBN(0xdc506a35, 0x28e169a5), + TOBN(0x0ea10861, 0x7af9c93a), TOBN(0x1ed24361, 0x03fa0e08)}, + {TOBN(0x96eaaa92, 0xa3d694e7), TOBN(0xc0f43b4d, 0xef50bc74), + TOBN(0xce6aa58c, 0x64114db4), TOBN(0x8218e8ea, 0x7c000fd4)}}, + {{TOBN(0xac815dfb, 0x185f8844), TOBN(0xcd7e90cb, 0x1557abfb), + TOBN(0x23d16655, 0xafbfecdf), TOBN(0x80f3271f, 0x085cac4a)}, + {TOBN(0x7fc39aa7, 0xd0e62f47), TOBN(0x88d519d1, 0x460a48e5), + TOBN(0x59559ac4, 0xd28f101e), TOBN(0x7981d9e9, 0xca9ae816)}}, + {{TOBN(0x5c38652c, 0x9ac38203), TOBN(0x86eaf87f, 0x57657fe5), + TOBN(0x568fc472, 0xe21f5416), TOBN(0x2afff39c, 0xe7e597b5)}, + {TOBN(0x3adbbb07, 0x256d4eab), TOBN(0x22598692, 0x8285ab89), + TOBN(0x35f8112a, 0x041caefe), TOBN(0x95df02e3, 0xa5064c8b)}}, + {{TOBN(0x4d63356e, 0xc7004bf3), TOBN(0x230a08f4, 0xdb83c7de), + TOBN(0xca27b270, 0x8709a7b7), TOBN(0x0d1c4cc4, 0xcb9abd2d)}, + {TOBN(0x8a0bc66e, 0x7550fee8), TOBN(0x369cd4c7, 0x9cf7247e), + TOBN(0x75562e84, 0x92b5b7e7), TOBN(0x8fed0da0, 0x5802af7b)}}, + {{TOBN(0x6a7091c2, 0xe48fb889), TOBN(0x26882c13, 0x7b8a9d06), + TOBN(0xa2498663, 0x1b82a0e2), TOBN(0x844ed736, 0x3518152d)}, + {TOBN(0x282f476f, 0xd86e27c7), TOBN(0xa04edaca, 0x04afefdc), + TOBN(0x8b256ebc, 0x6119e34d), TOBN(0x56a413e9, 0x0787d78b)}}}, + {{{TOBN(0x82ee061d, 0x5a74be50), TOBN(0xe41781c4, 0xdea16ff5), + TOBN(0xe0b0c81e, 0x99bfc8a2), TOBN(0x624f4d69, 0x0b547e2d)}, + {TOBN(0x3a83545d, 0xbdcc9ae4), TOBN(0x2573dbb6, 0x409b1e8e), + TOBN(0x482960c4, 0xa6c93539), TOBN(0xf01059ad, 0x5ae18798)}}, + {{TOBN(0x715c9f97, 0x3112795f), TOBN(0xe8244437, 0x984e6ee1), + TOBN(0x55cb4858, 0xecb66bcd), TOBN(0x7c136735, 0xabaffbee)}, + {TOBN(0x54661595, 0x5dbec38e), TOBN(0x51c0782c, 0x388ad153), + TOBN(0x9ba4c53a, 0xc6e0952f), TOBN(0x27e6782a, 0x1b21dfa8)}}, + {{TOBN(0x682f903d, 0x4ed2dbc2), TOBN(0x0eba59c8, 0x7c3b2d83), + TOBN(0x8e9dc84d, 0x9c7e9335), TOBN(0x5f9b21b0, 0x0eb226d7)}, + {TOBN(0xe33bd394, 0xaf267bae), TOBN(0xaa86cc25, 0xbe2e15ae), + TOBN(0x4f0bf67d, 0x6a8ec500), TOBN(0x5846aa44, 0xf9630658)}}, + {{TOBN(0xfeb09740, 0xe2c2bf15), TOBN(0x627a2205, 0xa9e99704), + TOBN(0xec8d73d0, 0xc2fbc565), TOBN(0x223eed8f, 0xc20c8de8)}, + {TOBN(0x1ee32583, 0xa8363b49), TOBN(0x1a0b6cb9, 0xc9c2b0a6), + TOBN(0x49f7c3d2, 0x90dbc85c), TOBN(0xa8dfbb97, 0x1ef4c1ac)}}, + {{TOBN(0xafb34d4c, 0x65c7c2ab), TOBN(0x1d4610e7, 0xe2c5ea84), + TOBN(0x893f6d1b, 0x973c4ab5), TOBN(0xa3cdd7e9, 0x945ba5c4)}, + {TOBN(0x60514983, 0x064417ee), TOBN(0x1459b23c, 0xad6bdf2b), + TOBN(0x23b2c341, 0x5cf726c3), TOBN(0x3a829635, 0x32d6354a)}}, + {{TOBN(0x294f901f, 0xab192c18), TOBN(0xec5fcbfe, 0x7030164f), + TOBN(0xe2e2fcb7, 0xe2246ba6), TOBN(0x1e7c88b3, 0x221a1a0c)}, + {TOBN(0x72c7dd93, 0xc92d88c5), TOBN(0x41c2148e, 0x1106fb59), + TOBN(0x547dd4f5, 0xa0f60f14), TOBN(0xed9b52b2, 0x63960f31)}}, + {{TOBN(0x6c8349eb, 0xb0a5b358), TOBN(0xb154c5c2, 0x9e7e2ed6), + TOBN(0xcad5eccf, 0xeda462db), TOBN(0xf2d6dbe4, 0x2de66b69)}, + {TOBN(0x426aedf3, 0x8665e5b2), TOBN(0x488a8513, 0x7b7f5723), + TOBN(0x15cc43b3, 0x8bcbb386), TOBN(0x27ad0af3, 0xd791d879)}}, + {{TOBN(0xc16c236e, 0x846e364f), TOBN(0x7f33527c, 0xdea50ca0), + TOBN(0xc4810775, 0x0926b86d), TOBN(0x6c2a3609, 0x0598e70c)}, + {TOBN(0xa6755e52, 0xf024e924), TOBN(0xe0fa07a4, 0x9db4afca), + TOBN(0x15c3ce7d, 0x66831790), TOBN(0x5b4ef350, 0xa6cbb0d6)}}, + {{TOBN(0x2c4aafc4, 0xb6205969), TOBN(0x42563f02, 0xf6c7854f), + TOBN(0x016aced5, 0x1d983b48), TOBN(0xfeb356d8, 0x99949755)}, + {TOBN(0x8c2a2c81, 0xd1a39bd7), TOBN(0x8f44340f, 0xe6934ae9), + TOBN(0x148cf91c, 0x447904da), TOBN(0x7340185f, 0x0f51a926)}}, + {{TOBN(0x2f8f00fb, 0x7409ab46), TOBN(0x057e78e6, 0x80e289b2), + TOBN(0x03e5022c, 0xa888e5d1), TOBN(0x3c87111a, 0x9dede4e2)}, + {TOBN(0x5b9b0e1c, 0x7809460b), TOBN(0xe751c852, 0x71c9abc7), + TOBN(0x8b944e28, 0xc7cc1dc9), TOBN(0x4f201ffa, 0x1d3cfa08)}}, + {{TOBN(0x02fc905c, 0x3e6721ce), TOBN(0xd52d70da, 0xd0b3674c), + TOBN(0x5dc2e5ca, 0x18810da4), TOBN(0xa984b273, 0x5c69dd99)}, + {TOBN(0x63b92527, 0x84de5ca4), TOBN(0x2f1c9872, 0xc852dec4), + TOBN(0x18b03593, 0xc2e3de09), TOBN(0x19d70b01, 0x9813dc2f)}}, + {{TOBN(0x42806b2d, 0xa6dc1d29), TOBN(0xd3030009, 0xf871e144), + TOBN(0xa1feb333, 0xaaf49276), TOBN(0xb5583b9e, 0xc70bc04b)}, + {TOBN(0x1db0be78, 0x95695f20), TOBN(0xfc841811, 0x89d012b5), + TOBN(0x6409f272, 0x05f61643), TOBN(0x40d34174, 0xd5883128)}}, + {{TOBN(0xd79196f5, 0x67419833), TOBN(0x6059e252, 0x863b7b08), + TOBN(0x84da1817, 0x1c56700c), TOBN(0x5758ee56, 0xb28d3ec4)}, + {TOBN(0x7da2771d, 0x013b0ea6), TOBN(0xfddf524b, 0x54c5e9b9), + TOBN(0x7df4faf8, 0x24305d80), TOBN(0x58f5c1bf, 0x3a97763f)}}, + {{TOBN(0xa5af37f1, 0x7c696042), TOBN(0xd4cba22c, 0x4a2538de), + TOBN(0x211cb995, 0x9ea42600), TOBN(0xcd105f41, 0x7b069889)}, + {TOBN(0xb1e1cf19, 0xddb81e74), TOBN(0x472f2d89, 0x5157b8ca), + TOBN(0x086fb008, 0xee9db885), TOBN(0x365cd570, 0x0f26d131)}}, + {{TOBN(0x284b02bb, 0xa2be7053), TOBN(0xdcbbf7c6, 0x7ab9a6d6), + TOBN(0x4425559c, 0x20f7a530), TOBN(0x961f2dfa, 0x188767c8)}, + {TOBN(0xe2fd9435, 0x70dc80c4), TOBN(0x104d6b63, 0xf0784120), + TOBN(0x7f592bc1, 0x53567122), TOBN(0xf6bc1246, 0xf688ad77)}}, + {{TOBN(0x05214c05, 0x0f15dde9), TOBN(0xa47a76a8, 0x0d5f2b82), + TOBN(0xbb254d30, 0x62e82b62), TOBN(0x11a05fe0, 0x3ec955ee)}, + {TOBN(0x7eaff46e, 0x9d529b36), TOBN(0x55ab1301, 0x8f9e3df6), + TOBN(0xc463e371, 0x99317698), TOBN(0xfd251438, 0xccda47ad)}}, + {{TOBN(0xca9c3547, 0x23d695ea), TOBN(0x48ce626e, 0x16e589b5), + TOBN(0x6b5b64c7, 0xb187d086), TOBN(0xd02e1794, 0xb2207948)}, + {TOBN(0x8b58e98f, 0x7198111d), TOBN(0x90ca6305, 0xdcf9c3cc), + TOBN(0x5691fe72, 0xf34089b0), TOBN(0x60941af1, 0xfc7c80ff)}}, + {{TOBN(0xa09bc0a2, 0x22eb51e5), TOBN(0xc0bb7244, 0xaa9cf09a), + TOBN(0x36a8077f, 0x80159f06), TOBN(0x8b5c989e, 0xdddc560e)}, + {TOBN(0x19d2f316, 0x512e1f43), TOBN(0x02eac554, 0xad08ff62), + TOBN(0x012ab84c, 0x07d20b4e), TOBN(0x37d1e115, 0xd6d4e4e1)}}, + {{TOBN(0xb6443e1a, 0xab7b19a8), TOBN(0xf08d067e, 0xdef8cd45), + TOBN(0x63adf3e9, 0x685e03da), TOBN(0xcf15a10e, 0x4792b916)}, + {TOBN(0xf44bcce5, 0xb738a425), TOBN(0xebe131d5, 0x9636b2fd), + TOBN(0x94068841, 0x7850d605), TOBN(0x09684eaa, 0xb40d749d)}}, + {{TOBN(0x8c3c669c, 0x72ba075b), TOBN(0x89f78b55, 0xba469015), + TOBN(0x5706aade, 0x3e9f8ba8), TOBN(0x6d8bd565, 0xb32d7ed7)}, + {TOBN(0x25f4e63b, 0x805f08d6), TOBN(0x7f48200d, 0xc3bcc1b5), + TOBN(0x4e801968, 0xb025d847), TOBN(0x74afac04, 0x87cbe0a8)}}, + {{TOBN(0x43ed2c2b, 0x7e63d690), TOBN(0xefb6bbf0, 0x0223cdb8), + TOBN(0x4fec3cae, 0x2884d3fe), TOBN(0x065ecce6, 0xd75e25a4)}, + {TOBN(0x6c2294ce, 0x69f79071), TOBN(0x0d9a8e5f, 0x044b8666), + TOBN(0x5009f238, 0x17b69d8f), TOBN(0x3c29f8fe, 0xc5dfdaf7)}}, + {{TOBN(0x9067528f, 0xebae68c4), TOBN(0x5b385632, 0x30c5ba21), + TOBN(0x540df119, 0x1fdd1aec), TOBN(0xcf37825b, 0xcfba4c78)}, + {TOBN(0x77eff980, 0xbeb11454), TOBN(0x40a1a991, 0x60c1b066), + TOBN(0xe8018980, 0xf889a1c7), TOBN(0xb9c52ae9, 0x76c24be0)}}, + {{TOBN(0x05fbbcce, 0x45650ef4), TOBN(0xae000f10, 0x8aa29ac7), + TOBN(0x884b7172, 0x4f04c470), TOBN(0x7cd4fde2, 0x19bb5c25)}, + {TOBN(0x6477b22a, 0xe8840869), TOBN(0xa8868859, 0x5fbd0686), + TOBN(0xf23cc02e, 0x1116dfba), TOBN(0x76cd563f, 0xd87d7776)}}, + {{TOBN(0xe2a37598, 0xa9d82abf), TOBN(0x5f188ccb, 0xe6c170f5), + TOBN(0x81682200, 0x5066b087), TOBN(0xda22c212, 0xc7155ada)}, + {TOBN(0x151e5d3a, 0xfbddb479), TOBN(0x4b606b84, 0x6d715b99), + TOBN(0x4a73b54b, 0xf997cb2e), TOBN(0x9a1bfe43, 0x3ecd8b66)}}, + {{TOBN(0x1c312809, 0x2a67d48a), TOBN(0xcd6a671e, 0x031fa9e2), + TOBN(0xbec3312a, 0x0e43a34a), TOBN(0x1d935639, 0x55ef47d3)}, + {TOBN(0x5ea02489, 0x8fea73ea), TOBN(0x8247b364, 0xa035afb2), + TOBN(0xb58300a6, 0x5265b54c), TOBN(0x3286662f, 0x722c7148)}}, + {{TOBN(0xb77fd76b, 0xb4ec4c20), TOBN(0xf0a12fa7, 0x0f3fe3fd), + TOBN(0xf845bbf5, 0x41d8c7e8), TOBN(0xe4d969ca, 0x5ec10aa8)}, + {TOBN(0x4c0053b7, 0x43e232a3), TOBN(0xdc7a3fac, 0x37f8a45a), + TOBN(0x3c4261c5, 0x20d81c8f), TOBN(0xfd4b3453, 0xb00eab00)}}, + {{TOBN(0x76d48f86, 0xd36e3062), TOBN(0x626c5277, 0xa143ff02), + TOBN(0x538174de, 0xaf76f42e), TOBN(0x2267aa86, 0x6407ceac)}, + {TOBN(0xfad76351, 0x72e572d5), TOBN(0xab861af7, 0xba7330eb), + TOBN(0xa0a1c8c7, 0x418d8657), TOBN(0x988821cb, 0x20289a52)}}, + {{TOBN(0x79732522, 0xcccc18ad), TOBN(0xaadf3f8d, 0xf1a6e027), + TOBN(0xf7382c93, 0x17c2354d), TOBN(0x5ce1680c, 0xd818b689)}, + {TOBN(0x359ebbfc, 0xd9ecbee9), TOBN(0x4330689c, 0x1cae62ac), + TOBN(0xb55ce5b4, 0xc51ac38a), TOBN(0x7921dfea, 0xfe238ee8)}}, + {{TOBN(0x3972bef8, 0x271d1ca5), TOBN(0x3e423bc7, 0xe8aabd18), + TOBN(0x57b09f3f, 0x44a3e5e3), TOBN(0x5da886ae, 0x7b444d66)}, + {TOBN(0x68206634, 0xa9964375), TOBN(0x356a2fa3, 0x699cd0ff), + TOBN(0xaf0faa24, 0xdba515e9), TOBN(0x536e1f5c, 0xb321d79a)}}, + {{TOBN(0xd3b9913a, 0x5c04e4ea), TOBN(0xd549dcfe, 0xd6f11513), + TOBN(0xee227bf5, 0x79fd1d94), TOBN(0x9f35afee, 0xb43f2c67)}, + {TOBN(0xd2638d24, 0xf1314f53), TOBN(0x62baf948, 0xcabcd822), + TOBN(0x5542de29, 0x4ef48db0), TOBN(0xb3eb6a04, 0xfc5f6bb2)}}, + {{TOBN(0x23c110ae, 0x1208e16a), TOBN(0x1a4d15b5, 0xf8363e24), + TOBN(0x30716844, 0x164be00b), TOBN(0xa8e24824, 0xf6f4690d)}, + {TOBN(0x548773a2, 0x90b170cf), TOBN(0xa1bef331, 0x42f191f4), + TOBN(0x70f418d0, 0x9247aa97), TOBN(0xea06028e, 0x48be9147)}}, + {{TOBN(0xe13122f3, 0xdbfb894e), TOBN(0xbe9b79f6, 0xce274b18), + TOBN(0x85a49de5, 0xca58aadf), TOBN(0x24957758, 0x11487351)}, + {TOBN(0x111def61, 0xbb939099), TOBN(0x1d6a974a, 0x26d13694), + TOBN(0x4474b4ce, 0xd3fc253b), TOBN(0x3a1485e6, 0x4c5db15e)}}, + {{TOBN(0xe79667b4, 0x147c15b4), TOBN(0xe34f553b, 0x7bc61301), + TOBN(0x032b80f8, 0x17094381), TOBN(0x55d8bafd, 0x723eaa21)}, + {TOBN(0x5a987995, 0xf1c0e74e), TOBN(0x5a9b292e, 0xebba289c), + TOBN(0x413cd4b2, 0xeb4c8251), TOBN(0x98b5d243, 0xd162db0a)}}, + {{TOBN(0xbb47bf66, 0x68342520), TOBN(0x08d68949, 0xbaa862d1), + TOBN(0x11f349c7, 0xe906abcd), TOBN(0x454ce985, 0xed7bf00e)}, + {TOBN(0xacab5c9e, 0xb55b803b), TOBN(0xb03468ea, 0x31e3c16d), + TOBN(0x5c24213d, 0xd273bf12), TOBN(0x211538eb, 0x71587887)}}, + {{TOBN(0x198e4a2f, 0x731dea2d), TOBN(0xd5856cf2, 0x74ed7b2a), + TOBN(0x86a632eb, 0x13a664fe), TOBN(0x932cd909, 0xbda41291)}, + {TOBN(0x850e95d4, 0xc0c4ddc0), TOBN(0xc0f422f8, 0x347fc2c9), + TOBN(0xe68cbec4, 0x86076bcb), TOBN(0xf9e7c0c0, 0xcd6cd286)}}, + {{TOBN(0x65994ddb, 0x0f5f27ca), TOBN(0xe85461fb, 0xa80d59ff), + TOBN(0xff05481a, 0x66601023), TOBN(0xc665427a, 0xfc9ebbfb)}, + {TOBN(0xb0571a69, 0x7587fd52), TOBN(0x935289f8, 0x8d49efce), + TOBN(0x61becc60, 0xea420688), TOBN(0xb22639d9, 0x13a786af)}}, + {{TOBN(0x1a8e6220, 0x361ecf90), TOBN(0x001f23e0, 0x25506463), + TOBN(0xe4ae9b5d, 0x0a5c2b79), TOBN(0xebc9cdad, 0xd8149db5)}, + {TOBN(0xb33164a1, 0x934aa728), TOBN(0x750eb00e, 0xae9b60f3), + TOBN(0x5a91615b, 0x9b9cfbfd), TOBN(0x97015cbf, 0xef45f7f6)}}, + {{TOBN(0xb462c4a5, 0xbf5151df), TOBN(0x21adcc41, 0xb07118f2), + TOBN(0xd60c545b, 0x043fa42c), TOBN(0xfc21aa54, 0xe96be1ab)}, + {TOBN(0xe84bc32f, 0x4e51ea80), TOBN(0x3dae45f0, 0x259b5d8d), + TOBN(0xbb73c7eb, 0xc38f1b5e), TOBN(0xe405a74a, 0xe8ae617d)}}, + {{TOBN(0xbb1ae9c6, 0x9f1c56bd), TOBN(0x8c176b98, 0x49f196a4), + TOBN(0xc448f311, 0x6875092b), TOBN(0xb5afe3de, 0x9f976033)}, + {TOBN(0xa8dafd49, 0x145813e5), TOBN(0x687fc4d9, 0xe2b34226), + TOBN(0xf2dfc92d, 0x4c7ff57f), TOBN(0x004e3fc1, 0x401f1b46)}}, + {{TOBN(0x5afddab6, 0x1430c9ab), TOBN(0x0bdd41d3, 0x2238e997), + TOBN(0xf0947430, 0x418042ae), TOBN(0x71f9adda, 0xcdddc4cb)}, + {TOBN(0x7090c016, 0xc52dd907), TOBN(0xd9bdf44d, 0x29e2047f), + TOBN(0xe6f1fe80, 0x1b1011a6), TOBN(0xb63accbc, 0xd9acdc78)}}, + {{TOBN(0xcfc7e235, 0x1272a95b), TOBN(0x0c667717, 0xa6276ac8), + TOBN(0x3c0d3709, 0xe2d7eef7), TOBN(0x5add2b06, 0x9a685b3e)}, + {TOBN(0x363ad32d, 0x14ea5d65), TOBN(0xf8e01f06, 0x8d7dd506), + TOBN(0xc9ea2213, 0x75b4aac6), TOBN(0xed2a2bf9, 0x0d353466)}}, + {{TOBN(0x439d79b5, 0xe9d3a7c3), TOBN(0x8e0ee5a6, 0x81b7f34b), + TOBN(0xcf3dacf5, 0x1dc4ba75), TOBN(0x1d3d1773, 0xeb3310c7)}, + {TOBN(0xa8e67112, 0x7747ae83), TOBN(0x31f43160, 0x197d6b40), + TOBN(0x0521ccee, 0xcd961400), TOBN(0x67246f11, 0xf6535768)}}, + {{TOBN(0x702fcc5a, 0xef0c3133), TOBN(0x247cc45d, 0x7e16693b), + TOBN(0xfd484e49, 0xc729b749), TOBN(0x522cef7d, 0xb218320f)}, + {TOBN(0xe56ef405, 0x59ab93b3), TOBN(0x225fba11, 0x9f181071), + TOBN(0x33bd6595, 0x15330ed0), TOBN(0xc4be69d5, 0x1ddb32f7)}}, + {{TOBN(0x264c7668, 0x0448087c), TOBN(0xac30903f, 0x71432dae), + TOBN(0x3851b266, 0x00f9bf47), TOBN(0x400ed311, 0x6cdd6d03)}, + {TOBN(0x045e79fe, 0xf8fd2424), TOBN(0xfdfd974a, 0xfa6da98b), + TOBN(0x45c9f641, 0x0c1e673a), TOBN(0x76f2e733, 0x5b2c5168)}}, + {{TOBN(0x1adaebb5, 0x2a601753), TOBN(0xb286514c, 0xc57c2d49), + TOBN(0xd8769670, 0x1e0bfd24), TOBN(0x950c547e, 0x04478922)}, + {TOBN(0xd1d41969, 0xe5d32bfe), TOBN(0x30bc1472, 0x750d6c3e), + TOBN(0x8f3679fe, 0xe0e27f3a), TOBN(0x8f64a7dc, 0xa4a6ee0c)}}, + {{TOBN(0x2fe59937, 0x633dfb1f), TOBN(0xea82c395, 0x977f2547), + TOBN(0xcbdfdf1a, 0x661ea646), TOBN(0xc7ccc591, 0xb9085451)}, + {TOBN(0x82177962, 0x81761e13), TOBN(0xda57596f, 0x9196885c), + TOBN(0xbc17e849, 0x28ffbd70), TOBN(0x1e6e0a41, 0x2671d36f)}}, + {{TOBN(0x61ae872c, 0x4152fcf5), TOBN(0x441c87b0, 0x9e77e754), + TOBN(0xd0799dd5, 0xa34dff09), TOBN(0x766b4e44, 0x88a6b171)}, + {TOBN(0xdc06a512, 0x11f1c792), TOBN(0xea02ae93, 0x4be35c3e), + TOBN(0xe5ca4d6d, 0xe90c469e), TOBN(0x4df4368e, 0x56e4ff5c)}}, + {{TOBN(0x7817acab, 0x4baef62e), TOBN(0x9f5a2202, 0xa85b91e8), + TOBN(0x9666ebe6, 0x6ce57610), TOBN(0x32ad31f3, 0xf73bfe03)}, + {TOBN(0x628330a4, 0x25bcf4d6), TOBN(0xea950593, 0x515056e6), + TOBN(0x59811c89, 0xe1332156), TOBN(0xc89cf1fe, 0x8c11b2d7)}}, + {{TOBN(0x75b63913, 0x04e60cc0), TOBN(0xce811e8d, 0x4625d375), + TOBN(0x030e43fc, 0x2d26e562), TOBN(0xfbb30b4b, 0x608d36a0)}, + {TOBN(0x634ff82c, 0x48528118), TOBN(0x7c6fe085, 0xcd285911), + TOBN(0x7f2830c0, 0x99358f28), TOBN(0x2e60a95e, 0x665e6c09)}}, + {{TOBN(0x08407d3d, 0x9b785dbf), TOBN(0x530889ab, 0xa759bce7), + TOBN(0xf228e0e6, 0x52f61239), TOBN(0x2b6d1461, 0x6879be3c)}, + {TOBN(0xe6902c04, 0x51a7bbf7), TOBN(0x30ad99f0, 0x76f24a64), + TOBN(0x66d9317a, 0x98bc6da0), TOBN(0xf4f877f3, 0xcb596ac0)}}, + {{TOBN(0xb05ff62d, 0x4c44f119), TOBN(0x4555f536, 0xe9b77416), + TOBN(0xc7c0d059, 0x8caed63b), TOBN(0x0cd2b7ce, 0xc358b2a9)}, + {TOBN(0x3f33287b, 0x46945fa3), TOBN(0xf8785b20, 0xd67c8791), + TOBN(0xc54a7a61, 0x9637bd08), TOBN(0x54d4598c, 0x18be79d7)}}, + {{TOBN(0x889e5acb, 0xc46d7ce1), TOBN(0x9a515bb7, 0x8b085877), + TOBN(0xfac1a03d, 0x0b7a5050), TOBN(0x7d3e738a, 0xf2926035)}, + {TOBN(0x861cc2ce, 0x2a6cb0eb), TOBN(0x6f2e2955, 0x8f7adc79), + TOBN(0x61c4d451, 0x33016376), TOBN(0xd9fd2c80, 0x5ad59090)}}, + {{TOBN(0xe5a83738, 0xb2b836a1), TOBN(0x855b41a0, 0x7c0d6622), + TOBN(0x186fe317, 0x7cc19af1), TOBN(0x6465c1ff, 0xfdd99acb)}, + {TOBN(0x46e5c23f, 0x6974b99e), TOBN(0x75a7cf8b, 0xa2717cbe), + TOBN(0x4d2ebc3f, 0x062be658), TOBN(0x094b4447, 0x5f209c98)}}, + {{TOBN(0x4af285ed, 0xb940cb5a), TOBN(0x6706d792, 0x7cc82f10), + TOBN(0xc8c8776c, 0x030526fa), TOBN(0xfa8e6f76, 0xa0da9140)}, + {TOBN(0x77ea9d34, 0x591ee4f0), TOBN(0x5f46e337, 0x40274166), + TOBN(0x1bdf98bb, 0xea671457), TOBN(0xd7c08b46, 0x862a1fe2)}}, + {{TOBN(0x46cc303c, 0x1c08ad63), TOBN(0x99543440, 0x4c845e7b), + TOBN(0x1b8fbdb5, 0x48f36bf7), TOBN(0x5b82c392, 0x8c8273a7)}, + {TOBN(0x08f712c4, 0x928435d5), TOBN(0x071cf0f1, 0x79330380), + TOBN(0xc74c2d24, 0xa8da054a), TOBN(0xcb0e7201, 0x43c46b5c)}}, + {{TOBN(0x0ad7337a, 0xc0b7eff3), TOBN(0x8552225e, 0xc5e48b3c), + TOBN(0xe6f78b0c, 0x73f13a5f), TOBN(0x5e70062e, 0x82349cbe)}, + {TOBN(0x6b8d5048, 0xe7073969), TOBN(0x392d2a29, 0xc33cb3d2), + TOBN(0xee4f727c, 0x4ecaa20f), TOBN(0xa068c99e, 0x2ccde707)}}, + {{TOBN(0xfcd5651f, 0xb87a2913), TOBN(0xea3e3c15, 0x3cc252f0), + TOBN(0x777d92df, 0x3b6cd3e4), TOBN(0x7a414143, 0xc5a732e7)}, + {TOBN(0xa895951a, 0xa71ff493), TOBN(0xfe980c92, 0xbbd37cf6), + TOBN(0x45bd5e64, 0xdecfeeff), TOBN(0x910dc2a9, 0xa44c43e9)}}, + {{TOBN(0xcb403f26, 0xcca9f54d), TOBN(0x928bbdfb, 0x9303f6db), + TOBN(0x3c37951e, 0xa9eee67c), TOBN(0x3bd61a52, 0xf79961c3)}, + {TOBN(0x09a238e6, 0x395c9a79), TOBN(0x6940ca2d, 0x61eb352d), + TOBN(0x7d1e5c5e, 0xc1875631), TOBN(0x1e19742c, 0x1e1b20d1)}}, + {{TOBN(0x4633d908, 0x23fc2e6e), TOBN(0xa76e29a9, 0x08959149), + TOBN(0x61069d9c, 0x84ed7da5), TOBN(0x0baa11cf, 0x5dbcad51)}, + {TOBN(0xd01eec64, 0x961849da), TOBN(0x93b75f1f, 0xaf3d8c28), + TOBN(0x57bc4f9f, 0x1ca2ee44), TOBN(0x5a26322d, 0x00e00558)}}, + {{TOBN(0x1888d658, 0x61a023ef), TOBN(0x1d72aab4, 0xb9e5246e), + TOBN(0xa9a26348, 0xe5563ec0), TOBN(0xa0971963, 0xc3439a43)}, + {TOBN(0x567dd54b, 0xadb9b5b7), TOBN(0x73fac1a1, 0xc45a524b), + TOBN(0x8fe97ef7, 0xfe38e608), TOBN(0x608748d2, 0x3f384f48)}}, + {{TOBN(0xb0571794, 0xc486094f), TOBN(0x869254a3, 0x8bf3a8d6), + TOBN(0x148a8dd1, 0x310b0e25), TOBN(0x99ab9f3f, 0x9aa3f7d8)}, + {TOBN(0x0927c68a, 0x6706c02e), TOBN(0x22b5e76c, 0x69790e6c), + TOBN(0x6c325260, 0x6c71376c), TOBN(0x53a57690, 0x09ef6657)}}, + {{TOBN(0x8d63f852, 0xedffcf3a), TOBN(0xb4d2ed04, 0x3c0a6f55), + TOBN(0xdb3aa8de, 0x12519b9e), TOBN(0x5d38e9c4, 0x1e0a569a)}, + {TOBN(0x871528bf, 0x303747e2), TOBN(0xa208e77c, 0xf5b5c18d), + TOBN(0x9d129c88, 0xca6bf923), TOBN(0xbcbf197f, 0xbf02839f)}}, + {{TOBN(0x9b9bf030, 0x27323194), TOBN(0x3b055a8b, 0x339ca59d), + TOBN(0xb46b2312, 0x0f669520), TOBN(0x19789f1f, 0x497e5f24)}, + {TOBN(0x9c499468, 0xaaf01801), TOBN(0x72ee1190, 0x8b69d59c), + TOBN(0x8bd39595, 0xacf4c079), TOBN(0x3ee11ece, 0x8e0cd048)}}, + {{TOBN(0xebde86ec, 0x1ed66f18), TOBN(0x225d906b, 0xd61fce43), + TOBN(0x5cab07d6, 0xe8bed74d), TOBN(0x16e4617f, 0x27855ab7)}, + {TOBN(0x6568aadd, 0xb2fbc3dd), TOBN(0xedb5484f, 0x8aeddf5b), + TOBN(0x878f20e8, 0x6dcf2fad), TOBN(0x3516497c, 0x615f5699)}}}, + {{{TOBN(0xef0a3fec, 0xfa181e69), TOBN(0x9ea02f81, 0x30d69a98), + TOBN(0xb2e9cf8e, 0x66eab95d), TOBN(0x520f2beb, 0x24720021)}, + {TOBN(0x621c540a, 0x1df84361), TOBN(0x12037721, 0x71fa6d5d), + TOBN(0x6e3c7b51, 0x0ff5f6ff), TOBN(0x817a069b, 0xabb2bef3)}}, + {{TOBN(0x83572fb6, 0xb294cda6), TOBN(0x6ce9bf75, 0xb9039f34), + TOBN(0x20e012f0, 0x095cbb21), TOBN(0xa0aecc1b, 0xd063f0da)}, + {TOBN(0x57c21c3a, 0xf02909e5), TOBN(0xc7d59ecf, 0x48ce9cdc), + TOBN(0x2732b844, 0x8ae336f8), TOBN(0x056e3723, 0x3f4f85f4)}}, + {{TOBN(0x8a10b531, 0x89e800ca), TOBN(0x50fe0c17, 0x145208fd), + TOBN(0x9e43c0d3, 0xb714ba37), TOBN(0x427d200e, 0x34189acc)}, + {TOBN(0x05dee24f, 0xe616e2c0), TOBN(0x9c25f4c8, 0xee1854c1), + TOBN(0x4d3222a5, 0x8f342a73), TOBN(0x0807804f, 0xa027c952)}}, + {{TOBN(0xc222653a, 0x4f0d56f3), TOBN(0x961e4047, 0xca28b805), + TOBN(0x2c03f8b0, 0x4a73434b), TOBN(0x4c966787, 0xab712a19)}, + {TOBN(0xcc196c42, 0x864fee42), TOBN(0xc1be93da, 0x5b0ece5c), + TOBN(0xa87d9f22, 0xc131c159), TOBN(0x2bb6d593, 0xdce45655)}}, + {{TOBN(0x22c49ec9, 0xb809b7ce), TOBN(0x8a41486b, 0xe2c72c2c), + TOBN(0x813b9420, 0xfea0bf36), TOBN(0xb3d36ee9, 0xa66dac69)}, + {TOBN(0x6fddc08a, 0x328cc987), TOBN(0x0a3bcd2c, 0x3a326461), + TOBN(0x7103c49d, 0xd810dbba), TOBN(0xf9d81a28, 0x4b78a4c4)}}, + {{TOBN(0x3de865ad, 0xe4d55941), TOBN(0xdedafa5e, 0x30384087), + TOBN(0x6f414abb, 0x4ef18b9b), TOBN(0x9ee9ea42, 0xfaee5268)}, + {TOBN(0x260faa16, 0x37a55a4a), TOBN(0xeb19a514, 0x015f93b9), + TOBN(0x51d7ebd2, 0x9e9c3598), TOBN(0x523fc56d, 0x1932178e)}}, + {{TOBN(0x501d070c, 0xb98fe684), TOBN(0xd60fbe9a, 0x124a1458), + TOBN(0xa45761c8, 0x92bc6b3f), TOBN(0xf5384858, 0xfe6f27cb)}, + {TOBN(0x4b0271f7, 0xb59e763b), TOBN(0x3d4606a9, 0x5b5a8e5e), + TOBN(0x1eda5d9b, 0x05a48292), TOBN(0xda7731d0, 0xe6fec446)}}, + {{TOBN(0xa3e33693, 0x90d45871), TOBN(0xe9764040, 0x06166d8d), + TOBN(0xb5c33682, 0x89a90403), TOBN(0x4bd17983, 0x72f1d637)}, + {TOBN(0xa616679e, 0xd5d2c53a), TOBN(0x5ec4bcd8, 0xfdcf3b87), + TOBN(0xae6d7613, 0xb66a694e), TOBN(0x7460fc76, 0xe3fc27e5)}}, + {{TOBN(0x70469b82, 0x95caabee), TOBN(0xde024ca5, 0x889501e3), + TOBN(0x6bdadc06, 0x076ed265), TOBN(0x0cb1236b, 0x5a0ef8b2)}, + {TOBN(0x4065ddbf, 0x0972ebf9), TOBN(0xf1dd3875, 0x22aca432), + TOBN(0xa88b97cf, 0x744aff76), TOBN(0xd1359afd, 0xfe8e3d24)}}, + {{TOBN(0x52a3ba2b, 0x91502cf3), TOBN(0x2c3832a8, 0x084db75d), + TOBN(0x04a12ddd, 0xde30b1c9), TOBN(0x7802eabc, 0xe31fd60c)}, + {TOBN(0x33707327, 0xa37fddab), TOBN(0x65d6f2ab, 0xfaafa973), + TOBN(0x3525c5b8, 0x11e6f91a), TOBN(0x76aeb0c9, 0x5f46530b)}}, + {{TOBN(0xe8815ff6, 0x2f93a675), TOBN(0xa6ec9684, 0x05f48679), + TOBN(0x6dcbb556, 0x358ae884), TOBN(0x0af61472, 0xe19e3873)}, + {TOBN(0x72334372, 0xa5f696be), TOBN(0xc65e57ea, 0x6f22fb70), + TOBN(0x268da30c, 0x946cea90), TOBN(0x136a8a87, 0x65681b2a)}}, + {{TOBN(0xad5e81dc, 0x0f9f44d4), TOBN(0xf09a6960, 0x2c46585a), + TOBN(0xd1649164, 0xc447d1b1), TOBN(0x3b4b36c8, 0x879dc8b1)}, + {TOBN(0x20d4177b, 0x3b6b234c), TOBN(0x096a2505, 0x1730d9d0), + TOBN(0x0611b9b8, 0xef80531d), TOBN(0xba904b3b, 0x64bb495d)}}, + {{TOBN(0x1192d9d4, 0x93a3147a), TOBN(0x9f30a5dc, 0x9a565545), + TOBN(0x90b1f9cb, 0x6ef07212), TOBN(0x29958546, 0x0d87fc13)}, + {TOBN(0xd3323eff, 0xc17db9ba), TOBN(0xcb18548c, 0xcb1644a8), + TOBN(0x18a306d4, 0x4f49ffbc), TOBN(0x28d658f1, 0x4c2e8684)}}, + {{TOBN(0x44ba60cd, 0xa99f8c71), TOBN(0x67b7abdb, 0x4bf742ff), + TOBN(0x66310f9c, 0x914b3f99), TOBN(0xae430a32, 0xf412c161)}, + {TOBN(0x1e6776d3, 0x88ace52f), TOBN(0x4bc0fa24, 0x52d7067d), + TOBN(0x03c286aa, 0x8f07cd1b), TOBN(0x4cb8f38c, 0xa985b2c1)}}, + {{TOBN(0x83ccbe80, 0x8c3bff36), TOBN(0x005a0bd2, 0x5263e575), + TOBN(0x460d7dda, 0x259bdcd1), TOBN(0x4a1c5642, 0xfa5cab6b)}, + {TOBN(0x2b7bdbb9, 0x9fe4fc88), TOBN(0x09418e28, 0xcc97bbb5), + TOBN(0xd8274fb4, 0xa12321ae), TOBN(0xb137007d, 0x5c87b64e)}}, + {{TOBN(0x80531fe1, 0xc63c4962), TOBN(0x50541e89, 0x981fdb25), + TOBN(0xdc1291a1, 0xfd4c2b6b), TOBN(0xc0693a17, 0xa6df4fca)}, + {TOBN(0xb2c4604e, 0x0117f203), TOBN(0x245f1963, 0x0a99b8d0), + TOBN(0xaedc20aa, 0xc6212c44), TOBN(0xb1ed4e56, 0x520f52a8)}}, + {{TOBN(0xfe48f575, 0xf8547be3), TOBN(0x0a7033cd, 0xa9e45f98), + TOBN(0x4b45d3a9, 0x18c50100), TOBN(0xb2a6cd6a, 0xa61d41da)}, + {TOBN(0x60bbb4f5, 0x57933c6b), TOBN(0xa7538ebd, 0x2b0d7ffc), + TOBN(0x9ea3ab8d, 0x8cd626b6), TOBN(0x8273a484, 0x3601625a)}}, + {{TOBN(0x88859845, 0x0168e508), TOBN(0x8cbc9bb2, 0x99a94abd), + TOBN(0x713ac792, 0xfab0a671), TOBN(0xa3995b19, 0x6c9ebffc)}, + {TOBN(0xe711668e, 0x1239e152), TOBN(0x56892558, 0xbbb8dff4), + TOBN(0x8bfc7dab, 0xdbf17963), TOBN(0x5b59fe5a, 0xb3de1253)}}, + {{TOBN(0x7e3320eb, 0x34a9f7ae), TOBN(0xe5e8cf72, 0xd751efe4), + TOBN(0x7ea003bc, 0xd9be2f37), TOBN(0xc0f551a0, 0xb6c08ef7)}, + {TOBN(0x56606268, 0x038f6725), TOBN(0x1dd38e35, 0x6d92d3b6), + TOBN(0x07dfce7c, 0xc3cbd686), TOBN(0x4e549e04, 0x651c5da8)}}, + {{TOBN(0x4058f93b, 0x08b19340), TOBN(0xc2fae6f4, 0xcac6d89d), + TOBN(0x4bad8a8c, 0x8f159cc7), TOBN(0x0ddba4b3, 0xcb0b601c)}, + {TOBN(0xda4fc7b5, 0x1dd95f8c), TOBN(0x1d163cd7, 0xcea5c255), + TOBN(0x30707d06, 0x274a8c4c), TOBN(0x79d9e008, 0x2802e9ce)}}, + {{TOBN(0x02a29ebf, 0xe6ddd505), TOBN(0x37064e74, 0xb50bed1a), + TOBN(0x3f6bae65, 0xa7327d57), TOBN(0x3846f5f1, 0xf83920bc)}, + {TOBN(0x87c37491, 0x60df1b9b), TOBN(0x4cfb2895, 0x2d1da29f), + TOBN(0x10a478ca, 0x4ed1743c), TOBN(0x390c6030, 0x3edd47c6)}}, + {{TOBN(0x8f3e5312, 0x8c0a78de), TOBN(0xccd02bda, 0x1e85df70), + TOBN(0xd6c75c03, 0xa61b6582), TOBN(0x0762921c, 0xfc0eebd1)}, + {TOBN(0xd34d0823, 0xd85010c0), TOBN(0xd73aaacb, 0x0044cf1f), + TOBN(0xfb4159bb, 0xa3b5e78a), TOBN(0x2287c7f7, 0xe5826f3f)}}, + {{TOBN(0x4aeaf742, 0x580b1a01), TOBN(0xf080415d, 0x60423b79), + TOBN(0xe12622cd, 0xa7dea144), TOBN(0x49ea4996, 0x59d62472)}, + {TOBN(0xb42991ef, 0x571f3913), TOBN(0x0610f214, 0xf5b25a8a), + TOBN(0x47adc585, 0x30b79e8f), TOBN(0xf90e3df6, 0x07a065a2)}}, + {{TOBN(0x5d0a5deb, 0x43e2e034), TOBN(0x53fb5a34, 0x444024aa), + TOBN(0xa8628c68, 0x6b0c9f7f), TOBN(0x9c69c29c, 0xac563656)}, + {TOBN(0x5a231feb, 0xbace47b6), TOBN(0xbdce0289, 0x9ea5a2ec), + TOBN(0x05da1fac, 0x9463853e), TOBN(0x96812c52, 0x509e78aa)}}, + {{TOBN(0xd3fb5771, 0x57151692), TOBN(0xeb2721f8, 0xd98e1c44), + TOBN(0xc0506087, 0x32399be1), TOBN(0xda5a5511, 0xd979d8b8)}, + {TOBN(0x737ed55d, 0xc6f56780), TOBN(0xe20d3004, 0x0dc7a7f4), + TOBN(0x02ce7301, 0xf5941a03), TOBN(0x91ef5215, 0xed30f83a)}}, + {{TOBN(0x28727fc1, 0x4092d85f), TOBN(0x72d223c6, 0x5c49e41a), + TOBN(0xa7cf30a2, 0xba6a4d81), TOBN(0x7c086209, 0xb030d87d)}, + {TOBN(0x04844c7d, 0xfc588b09), TOBN(0x728cd499, 0x5874bbb0), + TOBN(0xcc1281ee, 0xe84c0495), TOBN(0x0769b5ba, 0xec31958f)}}, + {{TOBN(0x665c228b, 0xf99c2471), TOBN(0xf2d8a11b, 0x191eb110), + TOBN(0x4594f494, 0xd36d7024), TOBN(0x482ded8b, 0xcdcb25a1)}, + {TOBN(0xc958a9d8, 0xdadd4885), TOBN(0x7004477e, 0xf1d2b547), + TOBN(0x0a45f6ef, 0x2a0af550), TOBN(0x4fc739d6, 0x2f8d6351)}}, + {{TOBN(0x75cdaf27, 0x786f08a9), TOBN(0x8700bb26, 0x42c2737f), + TOBN(0x855a7141, 0x1c4e2670), TOBN(0x810188c1, 0x15076fef)}, + {TOBN(0xc251d0c9, 0xabcd3297), TOBN(0xae4c8967, 0xf48108eb), + TOBN(0xbd146de7, 0x18ceed30), TOBN(0xf9d4f07a, 0xc986bced)}}, + {{TOBN(0x5ad98ed5, 0x83fa1e08), TOBN(0x7780d33e, 0xbeabd1fb), + TOBN(0xe330513c, 0x903b1196), TOBN(0xba11de9e, 0xa47bc8c4)}, + {TOBN(0x684334da, 0x02c2d064), TOBN(0x7ecf360d, 0xa48de23b), + TOBN(0x57a1b474, 0x0a9089d8), TOBN(0xf28fa439, 0xff36734c)}}, + {{TOBN(0xf2a482cb, 0xea4570b3), TOBN(0xee65d68b, 0xa5ebcee9), + TOBN(0x988d0036, 0xb9694cd5), TOBN(0x53edd0e9, 0x37885d32)}, + {TOBN(0xe37e3307, 0xbeb9bc6d), TOBN(0xe9abb907, 0x9f5c6768), + TOBN(0x4396ccd5, 0x51f2160f), TOBN(0x2500888c, 0x47336da6)}}, + {{TOBN(0x383f9ed9, 0x926fce43), TOBN(0x809dd1c7, 0x04da2930), + TOBN(0x30f6f596, 0x8a4cb227), TOBN(0x0d700c7f, 0x73a56b38)}, + {TOBN(0x1825ea33, 0xab64a065), TOBN(0xaab9b735, 0x1338df80), + TOBN(0x1516100d, 0x9b63f57f), TOBN(0x2574395a, 0x27a6a634)}}, + {{TOBN(0xb5560fb6, 0x700a1acd), TOBN(0xe823fd73, 0xfd999681), + TOBN(0xda915d1f, 0x6cb4e1ba), TOBN(0x0d030118, 0x6ebe00a3)}, + {TOBN(0x744fb0c9, 0x89fca8cd), TOBN(0x970d01db, 0xf9da0e0b), + TOBN(0x0ad8c564, 0x7931d76f), TOBN(0xb15737bf, 0xf659b96a)}}, + {{TOBN(0xdc9933e8, 0xa8b484e7), TOBN(0xb2fdbdf9, 0x7a26dec7), + TOBN(0x2349e9a4, 0x9f1f0136), TOBN(0x7860368e, 0x70fddddb)}, + {TOBN(0xd93d2c1c, 0xf9ad3e18), TOBN(0x6d6c5f17, 0x689f4e79), + TOBN(0x7a544d91, 0xb24ff1b6), TOBN(0x3e12a5eb, 0xfe16cd8c)}}, + {{TOBN(0x543574e9, 0xa56b872f), TOBN(0xa1ad550c, 0xfcf68ea2), + TOBN(0x689e37d2, 0x3f560ef7), TOBN(0x8c54b9ca, 0xc9d47a8b)}, + {TOBN(0x46d40a4a, 0x088ac342), TOBN(0xec450c7c, 0x1576c6d0), + TOBN(0xb589e31c, 0x1f9689e9), TOBN(0xdacf2602, 0xb8781718)}}, + {{TOBN(0xa89237c6, 0xc8cb6b42), TOBN(0x1326fc93, 0xb96ef381), + TOBN(0x55d56c6d, 0xb5f07825), TOBN(0xacba2eea, 0x7449e22d)}, + {TOBN(0x74e0887a, 0x633c3000), TOBN(0xcb6cd172, 0xd7cbcf71), + TOBN(0x309e81de, 0xc36cf1be), TOBN(0x07a18a6d, 0x60ae399b)}}, + {{TOBN(0xb36c2679, 0x9edce57e), TOBN(0x52b892f4, 0xdf001d41), + TOBN(0xd884ae5d, 0x16a1f2c6), TOBN(0x9b329424, 0xefcc370a)}, + {TOBN(0x3120daf2, 0xbd2e21df), TOBN(0x55298d2d, 0x02470a99), + TOBN(0x0b78af6c, 0xa05db32e), TOBN(0x5c76a331, 0x601f5636)}}, + {{TOBN(0xaae861ff, 0xf8a4f29c), TOBN(0x70dc9240, 0xd68f8d49), + TOBN(0x960e649f, 0x81b1321c), TOBN(0x3d2c801b, 0x8792e4ce)}, + {TOBN(0xf479f772, 0x42521876), TOBN(0x0bed93bc, 0x416c79b1), + TOBN(0xa67fbc05, 0x263e5bc9), TOBN(0x01e8e630, 0x521db049)}}, + {{TOBN(0x76f26738, 0xc6f3431e), TOBN(0xe609cb02, 0xe3267541), + TOBN(0xb10cff2d, 0x818c877c), TOBN(0x1f0e75ce, 0x786a13cb)}, + {TOBN(0xf4fdca64, 0x1158544d), TOBN(0x5d777e89, 0x6cb71ed0), + TOBN(0x3c233737, 0xa9aa4755), TOBN(0x7b453192, 0xe527ab40)}}, + {{TOBN(0xdb59f688, 0x39f05ffe), TOBN(0x8f4f4be0, 0x6d82574e), + TOBN(0xcce3450c, 0xee292d1b), TOBN(0xaa448a12, 0x61ccd086)}, + {TOBN(0xabce91b3, 0xf7914967), TOBN(0x4537f09b, 0x1908a5ed), + TOBN(0xa812421e, 0xf51042e7), TOBN(0xfaf5cebc, 0xec0b3a34)}}, + {{TOBN(0x730ffd87, 0x4ca6b39a), TOBN(0x70fb72ed, 0x02efd342), + TOBN(0xeb4735f9, 0xd75c8edb), TOBN(0xc11f2157, 0xc278aa51)}, + {TOBN(0xc459f635, 0xbf3bfebf), TOBN(0x3a1ff0b4, 0x6bd9601f), + TOBN(0xc9d12823, 0xc420cb73), TOBN(0x3e9af3e2, 0x3c2915a3)}}, + {{TOBN(0xe0c82c72, 0xb41c3440), TOBN(0x175239e5, 0xe3039a5f), + TOBN(0xe1084b8a, 0x558795a3), TOBN(0x328d0a1d, 0xd01e5c60)}, + {TOBN(0x0a495f2e, 0xd3788a04), TOBN(0x25d8ff16, 0x66c11a9f), + TOBN(0xf5155f05, 0x9ed692d6), TOBN(0x954fa107, 0x4f425fe4)}}, + {{TOBN(0xd16aabf2, 0xe98aaa99), TOBN(0x90cd8ba0, 0x96b0f88a), + TOBN(0x957f4782, 0xc154026a), TOBN(0x54ee0734, 0x52af56d2)}, + {TOBN(0xbcf89e54, 0x45b4147a), TOBN(0x3d102f21, 0x9a52816c), + TOBN(0x6808517e, 0x39b62e77), TOBN(0x92e25421, 0x69169ad8)}}, + {{TOBN(0xd721d871, 0xbb608558), TOBN(0x60e4ebae, 0xf6d4ff9b), + TOBN(0x0ba10819, 0x41f2763e), TOBN(0xca2e45be, 0x51ee3247)}, + {TOBN(0x66d172ec, 0x2bfd7a5f), TOBN(0x528a8f2f, 0x74d0b12d), + TOBN(0xe17f1e38, 0xdabe70dc), TOBN(0x1d5d7316, 0x9f93983c)}}, + {{TOBN(0x51b2184a, 0xdf423e31), TOBN(0xcb417291, 0xaedb1a10), + TOBN(0x2054ca93, 0x625bcab9), TOBN(0x54396860, 0xa98998f0)}, + {TOBN(0x4e53f6c4, 0xa54ae57e), TOBN(0x0ffeb590, 0xee648e9d), + TOBN(0xfbbdaadc, 0x6afaf6bc), TOBN(0xf88ae796, 0xaa3bfb8a)}}, + {{TOBN(0x209f1d44, 0xd2359ed9), TOBN(0xac68dd03, 0xf3544ce2), + TOBN(0xf378da47, 0xfd51e569), TOBN(0xe1abd860, 0x2cc80097)}, + {TOBN(0x23ca18d9, 0x343b6e3a), TOBN(0x480797e8, 0xb40a1bae), + TOBN(0xd1f0c717, 0x533f3e67), TOBN(0x44896970, 0x06e6cdfc)}}, + {{TOBN(0x8ca21055, 0x52a82e8d), TOBN(0xb2caf785, 0x78460cdc), + TOBN(0x4c1b7b62, 0xe9037178), TOBN(0xefc09d2c, 0xdb514b58)}, + {TOBN(0x5f2df9ee, 0x9113be5c), TOBN(0x2fbda78f, 0xb3f9271c), + TOBN(0xe09a81af, 0x8f83fc54), TOBN(0x06b13866, 0x8afb5141)}}, + {{TOBN(0x38f6480f, 0x43e3865d), TOBN(0x72dd77a8, 0x1ddf47d9), + TOBN(0xf2a8e971, 0x4c205ff7), TOBN(0x46d449d8, 0x9d088ad8)}, + {TOBN(0x926619ea, 0x185d706f), TOBN(0xe47e02eb, 0xc7dd7f62), + TOBN(0xe7f120a7, 0x8cbc2031), TOBN(0xc18bef00, 0x998d4ac9)}}, + {{TOBN(0x18f37a9c, 0x6bdf22da), TOBN(0xefbc432f, 0x90dc82df), + TOBN(0xc52cef8e, 0x5d703651), TOBN(0x82887ba0, 0xd99881a5)}, + {TOBN(0x7cec9dda, 0xb920ec1d), TOBN(0xd0d7e8c3, 0xec3e8d3b), + TOBN(0x445bc395, 0x4ca88747), TOBN(0xedeaa2e0, 0x9fd53535)}}, + {{TOBN(0x461b1d93, 0x6cc87475), TOBN(0xd92a52e2, 0x6d2383bd), + TOBN(0xfabccb59, 0xd7903546), TOBN(0x6111a761, 0x3d14b112)}, + {TOBN(0x0ae584fe, 0xb3d5f612), TOBN(0x5ea69b8d, 0x60e828ec), + TOBN(0x6c078985, 0x54087030), TOBN(0x649cab04, 0xac4821fe)}}, + {{TOBN(0x25ecedcf, 0x8bdce214), TOBN(0xb5622f72, 0x86af7361), + TOBN(0x0e1227aa, 0x7038b9e2), TOBN(0xd0efb273, 0xac20fa77)}, + {TOBN(0x817ff88b, 0x79df975b), TOBN(0x856bf286, 0x1999503e), + TOBN(0xb4d5351f, 0x5038ec46), TOBN(0x740a52c5, 0xfc42af6e)}}, + {{TOBN(0x2e38bb15, 0x2cbb1a3f), TOBN(0xc3eb99fe, 0x17a83429), + TOBN(0xca4fcbf1, 0xdd66bb74), TOBN(0x880784d6, 0xcde5e8fc)}, + {TOBN(0xddc84c1c, 0xb4e7a0be), TOBN(0x8780510d, 0xbd15a72f), + TOBN(0x44bcf1af, 0x81ec30e1), TOBN(0x141e50a8, 0x0a61073e)}}, + {{TOBN(0x0d955718, 0x47be87ae), TOBN(0x68a61417, 0xf76a4372), + TOBN(0xf57e7e87, 0xc607c3d3), TOBN(0x043afaf8, 0x5252f332)}, + {TOBN(0xcc14e121, 0x1552a4d2), TOBN(0xb6dee692, 0xbb4d4ab4), + TOBN(0xb6ab74c8, 0xa03816a4), TOBN(0x84001ae4, 0x6f394a29)}}, + {{TOBN(0x5bed8344, 0xd795fb45), TOBN(0x57326e7d, 0xb79f55a5), + TOBN(0xc9533ce0, 0x4accdffc), TOBN(0x53473caf, 0x3993fa04)}, + {TOBN(0x7906eb93, 0xa13df4c8), TOBN(0xa73e51f6, 0x97cbe46f), + TOBN(0xd1ab3ae1, 0x0ae4ccf8), TOBN(0x25614508, 0x8a5b3dbc)}}, + {{TOBN(0x61eff962, 0x11a71b27), TOBN(0xdf71412b, 0x6bb7fa39), + TOBN(0xb31ba6b8, 0x2bd7f3ef), TOBN(0xb0b9c415, 0x69180d29)}, + {TOBN(0xeec14552, 0x014cdde5), TOBN(0x702c624b, 0x227b4bbb), + TOBN(0x2b15e8c2, 0xd3e988f3), TOBN(0xee3bcc6d, 0xa4f7fd04)}}, + {{TOBN(0x9d00822a, 0x42ac6c85), TOBN(0x2db0cea6, 0x1df9f2b7), + TOBN(0xd7cad2ab, 0x42de1e58), TOBN(0x346ed526, 0x2d6fbb61)}, + {TOBN(0xb3962995, 0x1a2faf09), TOBN(0x2fa8a580, 0x7c25612e), + TOBN(0x30ae04da, 0x7cf56490), TOBN(0x75662908, 0x0eea3961)}}, + {{TOBN(0x3609f5c5, 0x3d080847), TOBN(0xcb081d39, 0x5241d4f6), + TOBN(0xb4fb3810, 0x77961a63), TOBN(0xc20c5984, 0x2abb66fc)}, + {TOBN(0x3d40aa7c, 0xf902f245), TOBN(0x9cb12736, 0x4e536b1e), + TOBN(0x5eda24da, 0x99b3134f), TOBN(0xafbd9c69, 0x5cd011af)}}, + {{TOBN(0x9a16e30a, 0xc7088c7d), TOBN(0x5ab65710, 0x3207389f), + TOBN(0x1b09547f, 0xe7407a53), TOBN(0x2322f9d7, 0x4fdc6eab)}, + {TOBN(0xc0f2f22d, 0x7430de4d), TOBN(0x19382696, 0xe68ca9a9), + TOBN(0x17f1eff1, 0x918e5868), TOBN(0xe3b5b635, 0x586f4204)}}, + {{TOBN(0x146ef980, 0x3fbc4341), TOBN(0x359f2c80, 0x5b5eed4e), + TOBN(0x9f35744e, 0x7482e41d), TOBN(0x9a9ac3ec, 0xf3b224c2)}, + {TOBN(0x9161a6fe, 0x91fc50ae), TOBN(0x89ccc66b, 0xc613fa7c), + TOBN(0x89268b14, 0xc732f15a), TOBN(0x7cd6f4e2, 0xb467ed03)}}, + {{TOBN(0xfbf79869, 0xce56b40e), TOBN(0xf93e094c, 0xc02dde98), + TOBN(0xefe0c3a8, 0xedee2cd7), TOBN(0x90f3ffc0, 0xb268fd42)}, + {TOBN(0x81a7fd56, 0x08241aed), TOBN(0x95ab7ad8, 0x00b1afe8), + TOBN(0x40127056, 0x3e310d52), TOBN(0xd3ffdeb1, 0x09d9fc43)}}, + {{TOBN(0xc8f85c91, 0xd11a8594), TOBN(0x2e74d258, 0x31cf6db8), + TOBN(0x829c7ca3, 0x02b5dfd0), TOBN(0xe389cfbe, 0x69143c86)}, + {TOBN(0xd01b6405, 0x941768d8), TOBN(0x45103995, 0x03bf825d), + TOBN(0xcc4ee166, 0x56cd17e2), TOBN(0xbea3c283, 0xba037e79)}}, + {{TOBN(0x4e1ac06e, 0xd9a47520), TOBN(0xfbfe18aa, 0xaf852404), + TOBN(0x5615f8e2, 0x8087648a), TOBN(0x7301e47e, 0xb9d150d9)}, + {TOBN(0x79f9f9dd, 0xb299b977), TOBN(0x76697a7b, 0xa5b78314), + TOBN(0x10d67468, 0x7d7c90e7), TOBN(0x7afffe03, 0x937210b5)}}, + {{TOBN(0x5aef3e4b, 0x28c22cee), TOBN(0xefb0ecd8, 0x09fd55ae), + TOBN(0x4cea7132, 0x0d2a5d6a), TOBN(0x9cfb5fa1, 0x01db6357)}, + {TOBN(0x395e0b57, 0xf36e1ac5), TOBN(0x008fa9ad, 0x36cafb7d), + TOBN(0x8f6cdf70, 0x5308c4db), TOBN(0x51527a37, 0x95ed2477)}}, + {{TOBN(0xba0dee30, 0x5bd21311), TOBN(0x6ed41b22, 0x909c90d7), + TOBN(0xc5f6b758, 0x7c8696d3), TOBN(0x0db8eaa8, 0x3ce83a80)}, + {TOBN(0xd297fe37, 0xb24b4b6f), TOBN(0xfe58afe8, 0x522d1f0d), + TOBN(0x97358736, 0x8c98dbd9), TOBN(0x6bc226ca, 0x9454a527)}}, + {{TOBN(0xa12b384e, 0xce53c2d0), TOBN(0x779d897d, 0x5e4606da), + TOBN(0xa53e47b0, 0x73ec12b0), TOBN(0x462dbbba, 0x5756f1ad)}, + {TOBN(0x69fe09f2, 0xcafe37b6), TOBN(0x273d1ebf, 0xecce2e17), + TOBN(0x8ac1d538, 0x3cf607fd), TOBN(0x8035f7ff, 0x12e10c25)}}}, + {{{TOBN(0x854d34c7, 0x7e6c5520), TOBN(0xc27df9ef, 0xdcb9ea58), + TOBN(0x405f2369, 0xd686666d), TOBN(0x29d1febf, 0x0417aa85)}, + {TOBN(0x9846819e, 0x93470afe), TOBN(0x3e6a9669, 0xe2a27f9e), + TOBN(0x24d008a2, 0xe31e6504), TOBN(0xdba7cecf, 0x9cb7680a)}}, + {{TOBN(0xecaff541, 0x338d6e43), TOBN(0x56f7dd73, 0x4541d5cc), + TOBN(0xb5d426de, 0x96bc88ca), TOBN(0x48d94f6b, 0x9ed3a2c3)}, + {TOBN(0x6354a3bb, 0x2ef8279c), TOBN(0xd575465b, 0x0b1867f2), + TOBN(0xef99b0ff, 0x95225151), TOBN(0xf3e19d88, 0xf94500d8)}}, + {{TOBN(0x92a83268, 0xe32dd620), TOBN(0x913ec99f, 0x627849a2), + TOBN(0xedd8fdfa, 0x2c378882), TOBN(0xaf96f33e, 0xee6f8cfe)}, + {TOBN(0xc06737e5, 0xdc3fa8a5), TOBN(0x236bb531, 0xb0b03a1d), + TOBN(0x33e59f29, 0x89f037b0), TOBN(0x13f9b5a7, 0xd9a12a53)}}, + {{TOBN(0x0d0df6ce, 0x51efb310), TOBN(0xcb5b2eb4, 0x958df5be), + TOBN(0xd6459e29, 0x36158e59), TOBN(0x82aae2b9, 0x1466e336)}, + {TOBN(0xfb658a39, 0x411aa636), TOBN(0x7152ecc5, 0xd4c0a933), + TOBN(0xf10c758a, 0x49f026b7), TOBN(0xf4837f97, 0xcb09311f)}}, + {{TOBN(0xddfb02c4, 0xc753c45f), TOBN(0x18ca81b6, 0xf9c840fe), + TOBN(0x846fd09a, 0xb0f8a3e6), TOBN(0xb1162add, 0xe7733dbc)}, + {TOBN(0x7070ad20, 0x236e3ab6), TOBN(0xf88cdaf5, 0xb2a56326), + TOBN(0x05fc8719, 0x997cbc7a), TOBN(0x442cd452, 0x4b665272)}}, + {{TOBN(0x7807f364, 0xb71698f5), TOBN(0x6ba418d2, 0x9f7b605e), + TOBN(0xfd20b00f, 0xa03b2cbb), TOBN(0x883eca37, 0xda54386f)}, + {TOBN(0xff0be43f, 0xf3437f24), TOBN(0xe910b432, 0xa48bb33c), + TOBN(0x4963a128, 0x329df765), TOBN(0xac1dd556, 0xbe2fe6f7)}}, + {{TOBN(0x557610f9, 0x24a0a3fc), TOBN(0x38e17bf4, 0xe881c3f9), + TOBN(0x6ba84faf, 0xed0dac99), TOBN(0xd4a222c3, 0x59eeb918)}, + {TOBN(0xc79c1dbe, 0x13f542b6), TOBN(0x1fc65e0d, 0xe425d457), + TOBN(0xeffb754f, 0x1debb779), TOBN(0x638d8fd0, 0x9e08af60)}}, + {{TOBN(0x994f523a, 0x626332d5), TOBN(0x7bc38833, 0x5561bb44), + TOBN(0x005ed4b0, 0x3d845ea2), TOBN(0xd39d3ee1, 0xc2a1f08a)}, + {TOBN(0x6561fdd3, 0xe7676b0d), TOBN(0x620e35ff, 0xfb706017), + TOBN(0x36ce424f, 0xf264f9a8), TOBN(0xc4c3419f, 0xda2681f7)}}, + {{TOBN(0xfb6afd2f, 0x69beb6e8), TOBN(0x3a50b993, 0x6d700d03), + TOBN(0xc840b2ad, 0x0c83a14f), TOBN(0x573207be, 0x54085bef)}, + {TOBN(0x5af882e3, 0x09fe7e5b), TOBN(0x957678a4, 0x3b40a7e1), + TOBN(0x172d4bdd, 0x543056e2), TOBN(0x9c1b26b4, 0x0df13c0a)}}, + {{TOBN(0x1c30861c, 0xf405ff06), TOBN(0xebac86bd, 0x486e828b), + TOBN(0xe791a971, 0x636933fc), TOBN(0x50e7c2be, 0x7aeee947)}, + {TOBN(0xc3d4a095, 0xfa90d767), TOBN(0xae60eb7b, 0xe670ab7b), + TOBN(0x17633a64, 0x397b056d), TOBN(0x93a21f33, 0x105012aa)}}, + {{TOBN(0x663c370b, 0xabb88643), TOBN(0x91df36d7, 0x22e21599), + TOBN(0x183ba835, 0x8b761671), TOBN(0x381eea1d, 0x728f3bf1)}, + {TOBN(0xb9b2f1ba, 0x39966e6c), TOBN(0x7c464a28, 0xe7295492), + TOBN(0x0fd5f70a, 0x09b26b7f), TOBN(0xa9aba1f9, 0xfbe009df)}}, + {{TOBN(0x857c1f22, 0x369b87ad), TOBN(0x3c00e5d9, 0x32fca556), + TOBN(0x1ad74cab, 0x90b06466), TOBN(0xa7112386, 0x550faaf2)}, + {TOBN(0x7435e198, 0x6d9bd5f5), TOBN(0x2dcc7e38, 0x59c3463f), + TOBN(0xdc7df748, 0xca7bd4b2), TOBN(0x13cd4c08, 0x9dec2f31)}}, + {{TOBN(0x0d3b5df8, 0xe3237710), TOBN(0x0dadb26e, 0xcbd2f7b0), + TOBN(0x9f5966ab, 0xe4aa082b), TOBN(0x666ec8de, 0x350e966e)}, + {TOBN(0x1bfd1ed5, 0xee524216), TOBN(0xcd93c59b, 0x41dab0b6), + TOBN(0x658a8435, 0xd186d6ba), TOBN(0x1b7d34d2, 0x159d1195)}}, + {{TOBN(0x5936e460, 0x22caf46b), TOBN(0x6a45dd8f, 0x9a96fe4f), + TOBN(0xf7925434, 0xb98f474e), TOBN(0x41410412, 0x0053ef15)}, + {TOBN(0x71cf8d12, 0x41de97bf), TOBN(0xb8547b61, 0xbd80bef4), + TOBN(0xb47d3970, 0xc4db0037), TOBN(0xf1bcd328, 0xfef20dff)}}, + {{TOBN(0x31a92e09, 0x10caad67), TOBN(0x1f591960, 0x5531a1e1), + TOBN(0x3bb852e0, 0x5f4fc840), TOBN(0x63e297ca, 0x93a72c6c)}, + {TOBN(0x3c2b0b2e, 0x49abad67), TOBN(0x6ec405fc, 0xed3db0d9), + TOBN(0xdc14a530, 0x7fef1d40), TOBN(0xccd19846, 0x280896fc)}}, + {{TOBN(0x00f83176, 0x9bb81648), TOBN(0xd69eb485, 0x653120d0), + TOBN(0xd17d75f4, 0x4ccabc62), TOBN(0x34a07f82, 0xb749fcb1)}, + {TOBN(0x2c3af787, 0xbbfb5554), TOBN(0xb06ed4d0, 0x62e283f8), + TOBN(0x5722889f, 0xa19213a0), TOBN(0x162b085e, 0xdcf3c7b4)}}, + {{TOBN(0xbcaecb31, 0xe0dd3eca), TOBN(0xc6237fbc, 0xe52f13a5), + TOBN(0xcc2b6b03, 0x27bac297), TOBN(0x2ae1cac5, 0xb917f54a)}, + {TOBN(0x474807d4, 0x7845ae4f), TOBN(0xfec7dd92, 0xce5972e0), + TOBN(0xc3bd2541, 0x1d7915bb), TOBN(0x66f85dc4, 0xd94907ca)}}, + {{TOBN(0xd981b888, 0xbdbcf0ca), TOBN(0xd75f5da6, 0xdf279e9f), + TOBN(0x128bbf24, 0x7054e934), TOBN(0x3c6ff6e5, 0x81db134b)}, + {TOBN(0x795b7cf4, 0x047d26e4), TOBN(0xf370f7b8, 0x5049ec37), + TOBN(0xc6712d4d, 0xced945af), TOBN(0xdf30b5ec, 0x095642bc)}}, + {{TOBN(0x9b034c62, 0x4896246e), TOBN(0x5652c016, 0xee90bbd1), + TOBN(0xeb38636f, 0x87fedb73), TOBN(0x5e32f847, 0x0135a613)}, + {TOBN(0x0703b312, 0xcf933c83), TOBN(0xd05bb76e, 0x1a7f47e6), + TOBN(0x825e4f0c, 0x949c2415), TOBN(0x569e5622, 0x7250d6f8)}}, + {{TOBN(0xbbe9eb3a, 0x6568013e), TOBN(0x8dbd203f, 0x22f243fc), + TOBN(0x9dbd7694, 0xb342734a), TOBN(0x8f6d12f8, 0x46afa984)}, + {TOBN(0xb98610a2, 0xc9eade29), TOBN(0xbab4f323, 0x47dd0f18), + TOBN(0x5779737b, 0x671c0d46), TOBN(0x10b6a7c6, 0xd3e0a42a)}}, + {{TOBN(0xfb19ddf3, 0x3035b41c), TOBN(0xd336343f, 0x99c45895), + TOBN(0x61fe4938, 0x54c857e5), TOBN(0xc4d506be, 0xae4e57d5)}, + {TOBN(0x3cd8c8cb, 0xbbc33f75), TOBN(0x7281f08a, 0x9262c77d), + TOBN(0x083f4ea6, 0xf11a2823), TOBN(0x8895041e, 0x9fba2e33)}}, + {{TOBN(0xfcdfea49, 0x9c438edf), TOBN(0x7678dcc3, 0x91edba44), + TOBN(0xf07b3b87, 0xe2ba50f0), TOBN(0xc13888ef, 0x43948c1b)}, + {TOBN(0xc2135ad4, 0x1140af42), TOBN(0x8e5104f3, 0x926ed1a7), + TOBN(0xf24430cb, 0x88f6695f), TOBN(0x0ce0637b, 0x6d73c120)}}, + {{TOBN(0xb2db01e6, 0xfe631e8f), TOBN(0x1c5563d7, 0xd7bdd24b), + TOBN(0x8daea3ba, 0x369ad44f), TOBN(0x000c81b6, 0x8187a9f9)}, + {TOBN(0x5f48a951, 0xaae1fd9a), TOBN(0xe35626c7, 0x8d5aed8a), + TOBN(0x20952763, 0x0498c622), TOBN(0x76d17634, 0x773aa504)}}, + {{TOBN(0x36d90dda, 0xeb300f7a), TOBN(0x9dcf7dfc, 0xedb5e801), + TOBN(0x645cb268, 0x74d5244c), TOBN(0xa127ee79, 0x348e3aa2)}, + {TOBN(0x488acc53, 0x575f1dbb), TOBN(0x95037e85, 0x80e6161e), + TOBN(0x57e59283, 0x292650d0), TOBN(0xabe67d99, 0x14938216)}}, + {{TOBN(0x3c7f944b, 0x3f8e1065), TOBN(0xed908cb6, 0x330e8924), + TOBN(0x08ee8fd5, 0x6f530136), TOBN(0x2227b7d5, 0xd7ffc169)}, + {TOBN(0x4f55c893, 0xb5cd6dd5), TOBN(0x82225e11, 0xa62796e8), + TOBN(0x5c6cead1, 0xcb18e12c), TOBN(0x4381ae0c, 0x84f5a51a)}}, + {{TOBN(0x345913d3, 0x7fafa4c8), TOBN(0x3d918082, 0x0491aac0), + TOBN(0x9347871f, 0x3e69264c), TOBN(0xbea9dd3c, 0xb4f4f0cd)}, + {TOBN(0xbda5d067, 0x3eadd3e7), TOBN(0x0033c1b8, 0x0573bcd8), + TOBN(0x25589379, 0x5da2486c), TOBN(0xcb89ee5b, 0x86abbee7)}}, + {{TOBN(0x8fe0a8f3, 0x22532e5d), TOBN(0xb6410ff0, 0x727dfc4c), + TOBN(0x619b9d58, 0x226726db), TOBN(0x5ec25669, 0x7a2b2dc7)}, + {TOBN(0xaf4d2e06, 0x4c3beb01), TOBN(0x852123d0, 0x7acea556), + TOBN(0x0e9470fa, 0xf783487a), TOBN(0x75a7ea04, 0x5664b3eb)}}, + {{TOBN(0x4ad78f35, 0x6798e4ba), TOBN(0x9214e6e5, 0xc7d0e091), + TOBN(0xc420b488, 0xb1290403), TOBN(0x64049e0a, 0xfc295749)}, + {TOBN(0x03ef5af1, 0x3ae9841f), TOBN(0xdbe4ca19, 0xb0b662a6), + TOBN(0x46845c5f, 0xfa453458), TOBN(0xf8dabf19, 0x10b66722)}}, + {{TOBN(0xb650f0aa, 0xcce2793b), TOBN(0x71db851e, 0xc5ec47c1), + TOBN(0x3eb78f3e, 0x3b234fa9), TOBN(0xb0c60f35, 0xfc0106ce)}, + {TOBN(0x05427121, 0x774eadbd), TOBN(0x25367faf, 0xce323863), + TOBN(0x7541b5c9, 0xcd086976), TOBN(0x4ff069e2, 0xdc507ad1)}}, + {{TOBN(0x74145256, 0x8776e667), TOBN(0x6e76142c, 0xb23c6bb5), + TOBN(0xdbf30712, 0x1b3a8a87), TOBN(0x60e7363e, 0x98450836)}, + {TOBN(0x5741450e, 0xb7366d80), TOBN(0xe4ee14ca, 0x4837dbdf), + TOBN(0xa765eb9b, 0x69d4316f), TOBN(0x04548dca, 0x8ef43825)}}, + {{TOBN(0x9c9f4e4c, 0x5ae888eb), TOBN(0x733abb51, 0x56e9ac99), + TOBN(0xdaad3c20, 0xba6ac029), TOBN(0x9b8dd3d3, 0x2ba3e38e)}, + {TOBN(0xa9bb4c92, 0x0bc5d11a), TOBN(0xf20127a7, 0x9c5f88a3), + TOBN(0x4f52b06e, 0x161d3cb8), TOBN(0x26c1ff09, 0x6afaf0a6)}}, + {{TOBN(0x32670d2f, 0x7189e71f), TOBN(0xc6438748, 0x5ecf91e7), + TOBN(0x15758e57, 0xdb757a21), TOBN(0x427d09f8, 0x290a9ce5)}, + {TOBN(0x846a308f, 0x38384a7a), TOBN(0xaac3acb4, 0xb0732b99), + TOBN(0x9e941009, 0x17845819), TOBN(0x95cba111, 0xa7ce5e03)}}, + {{TOBN(0x6f3d4f7f, 0xb00009c4), TOBN(0xb8396c27, 0x8ff28b5f), + TOBN(0xb1a9ae43, 0x1c97975d), TOBN(0x9d7ba8af, 0xe5d9fed5)}, + {TOBN(0x338cf09f, 0x34f485b6), TOBN(0xbc0ddacc, 0x64122516), + TOBN(0xa450da12, 0x05d471fe), TOBN(0x4c3a6250, 0x628dd8c9)}}, + {{TOBN(0x69c7d103, 0xd1295837), TOBN(0xa2893e50, 0x3807eb2f), + TOBN(0xd6e1e1de, 0xbdb41491), TOBN(0xc630745b, 0x5e138235)}, + {TOBN(0xc892109e, 0x48661ae1), TOBN(0x8d17e7eb, 0xea2b2674), + TOBN(0x00ec0f87, 0xc328d6b5), TOBN(0x6d858645, 0xf079ff9e)}}, + {{TOBN(0x6cdf243e, 0x19115ead), TOBN(0x1ce1393e, 0x4bac4fcf), + TOBN(0x2c960ed0, 0x9c29f25b), TOBN(0x59be4d8e, 0x9d388a05)}, + {TOBN(0x0d46e06c, 0xd0def72b), TOBN(0xb923db5d, 0xe0342748), + TOBN(0xf7d3aacd, 0x936d4a3d), TOBN(0x558519cc, 0x0b0b099e)}}, + {{TOBN(0x3ea8ebf8, 0x827097ef), TOBN(0x259353db, 0xd054f55d), + TOBN(0x84c89abc, 0x6d2ed089), TOBN(0x5c548b69, 0x8e096a7c)}, + {TOBN(0xd587f616, 0x994b995d), TOBN(0x4d1531f6, 0xa5845601), + TOBN(0x792ab31e, 0x451fd9f0), TOBN(0xc8b57bb2, 0x65adf6ca)}}, + {{TOBN(0x68440fcb, 0x1cd5ad73), TOBN(0xb9c860e6, 0x6144da4f), + TOBN(0x2ab286aa, 0x8462beb8), TOBN(0xcc6b8fff, 0xef46797f)}, + {TOBN(0xac820da4, 0x20c8a471), TOBN(0x69ae05a1, 0x77ff7faf), + TOBN(0xb9163f39, 0xbfb5da77), TOBN(0xbd03e590, 0x2c73ab7a)}}, + {{TOBN(0x7e862b5e, 0xb2940d9e), TOBN(0x3c663d86, 0x4b9af564), + TOBN(0xd8309031, 0xbde3033d), TOBN(0x298231b2, 0xd42c5bc6)}, + {TOBN(0x42090d2c, 0x552ad093), TOBN(0xa4799d1c, 0xff854695), + TOBN(0x0a88b5d6, 0xd31f0d00), TOBN(0xf8b40825, 0xa2f26b46)}}, + {{TOBN(0xec29b1ed, 0xf1bd7218), TOBN(0xd491c53b, 0x4b24c86e), + TOBN(0xd2fe588f, 0x3395ea65), TOBN(0x6f3764f7, 0x4456ef15)}, + {TOBN(0xdb43116d, 0xcdc34800), TOBN(0xcdbcd456, 0xc1e33955), + TOBN(0xefdb5540, 0x74ab286b), TOBN(0x948c7a51, 0xd18c5d7c)}}, + {{TOBN(0xeb81aa37, 0x7378058e), TOBN(0x41c746a1, 0x04411154), + TOBN(0xa10c73bc, 0xfb828ac7), TOBN(0x6439be91, 0x9d972b29)}, + {TOBN(0x4bf3b4b0, 0x43a2fbad), TOBN(0x39e6dadf, 0x82b5e840), + TOBN(0x4f716408, 0x6397bd4c), TOBN(0x0f7de568, 0x7f1eeccb)}}, + {{TOBN(0x5865c5a1, 0xd2ffbfc1), TOBN(0xf74211fa, 0x4ccb6451), + TOBN(0x66368a88, 0xc0b32558), TOBN(0x5b539dc2, 0x9ad7812e)}, + {TOBN(0x579483d0, 0x2f3af6f6), TOBN(0x52132078, 0x99934ece), + TOBN(0x50b9650f, 0xdcc9e983), TOBN(0xca989ec9, 0xaee42b8a)}}, + {{TOBN(0x6a44c829, 0xd6f62f99), TOBN(0x8f06a309, 0x4c2a7c0c), + TOBN(0x4ea2b3a0, 0x98a0cb0a), TOBN(0x5c547b70, 0xbeee8364)}, + {TOBN(0x461d40e1, 0x682afe11), TOBN(0x9e0fc77a, 0x7b41c0a8), + TOBN(0x79e4aefd, 0xe20d5d36), TOBN(0x2916e520, 0x32dd9f63)}}, + {{TOBN(0xf59e52e8, 0x3f883faf), TOBN(0x396f9639, 0x2b868d35), + TOBN(0xc902a9df, 0x4ca19881), TOBN(0x0fc96822, 0xdb2401a6)}, + {TOBN(0x41237587, 0x66f1c68d), TOBN(0x10fc6de3, 0xfb476c0d), + TOBN(0xf8b6b579, 0x841f5d90), TOBN(0x2ba8446c, 0xfa24f44a)}}, + {{TOBN(0xa237b920, 0xef4a9975), TOBN(0x60bb6004, 0x2330435f), + TOBN(0xd6f4ab5a, 0xcfb7e7b5), TOBN(0xb2ac5097, 0x83435391)}, + {TOBN(0xf036ee2f, 0xb0d1ea67), TOBN(0xae779a6a, 0x74c56230), + TOBN(0x59bff8c8, 0xab838ae6), TOBN(0xcd83ca99, 0x9b38e6f0)}}, + {{TOBN(0xbb27bef5, 0xe33deed3), TOBN(0xe6356f6f, 0x001892a8), + TOBN(0xbf3be6cc, 0x7adfbd3e), TOBN(0xaecbc81c, 0x33d1ac9d)}, + {TOBN(0xe4feb909, 0xe6e861dc), TOBN(0x90a247a4, 0x53f5f801), + TOBN(0x01c50acb, 0x27346e57), TOBN(0xce29242e, 0x461acc1b)}}, + {{TOBN(0x04dd214a, 0x2f998a91), TOBN(0x271ee9b1, 0xd4baf27b), + TOBN(0x7e3027d1, 0xe8c26722), TOBN(0x21d1645c, 0x1820dce5)}, + {TOBN(0x086f242c, 0x7501779c), TOBN(0xf0061407, 0xfa0e8009), + TOBN(0xf23ce477, 0x60187129), TOBN(0x05bbdedb, 0x0fde9bd0)}}, + {{TOBN(0x682f4832, 0x25d98473), TOBN(0xf207fe85, 0x5c658427), + TOBN(0xb6fdd7ba, 0x4166ffa1), TOBN(0x0c314056, 0x9eed799d)}, + {TOBN(0x0db8048f, 0x4107e28f), TOBN(0x74ed3871, 0x41216840), + TOBN(0x74489f8f, 0x56a3c06e), TOBN(0x1e1c005b, 0x12777134)}}, + {{TOBN(0xdb332a73, 0xf37ec3c3), TOBN(0xc65259bd, 0xdd59eba0), + TOBN(0x2291709c, 0xdb4d3257), TOBN(0x9a793b25, 0xbd389390)}, + {TOBN(0xf39fe34b, 0xe43756f0), TOBN(0x2f76bdce, 0x9afb56c9), + TOBN(0x9f37867a, 0x61208b27), TOBN(0xea1d4307, 0x089972c3)}}, + {{TOBN(0x8c595330, 0x8bdf623a), TOBN(0x5f5accda, 0x8441fb7d), + TOBN(0xfafa9418, 0x32ddfd95), TOBN(0x6ad40c5a, 0x0fde9be7)}, + {TOBN(0x43faba89, 0xaeca8709), TOBN(0xc64a7cf1, 0x2c248a9d), + TOBN(0x16620252, 0x72637a76), TOBN(0xaee1c791, 0x22b8d1bb)}}, + {{TOBN(0xf0f798fd, 0x21a843b2), TOBN(0x56e4ed4d, 0x8d005cb1), + TOBN(0x355f7780, 0x1f0d8abe), TOBN(0x197b04cf, 0x34522326)}, + {TOBN(0x41f9b31f, 0xfd42c13f), TOBN(0x5ef7feb2, 0xb40f933d), + TOBN(0x27326f42, 0x5d60bad4), TOBN(0x027ecdb2, 0x8c92cf89)}}, + {{TOBN(0x04aae4d1, 0x4e3352fe), TOBN(0x08414d2f, 0x73591b90), + TOBN(0x5ed6124e, 0xb7da7d60), TOBN(0xb985b931, 0x4d13d4ec)}, + {TOBN(0xa592d3ab, 0x96bf36f9), TOBN(0x012dbed5, 0xbbdf51df), + TOBN(0xa57963c0, 0xdf6c177d), TOBN(0x010ec869, 0x87ca29cf)}}, + {{TOBN(0xba1700f6, 0xbf926dff), TOBN(0x7c9fdbd1, 0xf4bf6bc2), + TOBN(0xdc18dc8f, 0x64da11f5), TOBN(0xa6074b7a, 0xd938ae75)}, + {TOBN(0x14270066, 0xe84f44a4), TOBN(0x99998d38, 0xd27b954e), + TOBN(0xc1be8ab2, 0xb4f38e9a), TOBN(0x8bb55bbf, 0x15c01016)}}, + {{TOBN(0xf73472b4, 0x0ea2ab30), TOBN(0xd365a340, 0xf73d68dd), + TOBN(0xc01a7168, 0x19c2e1eb), TOBN(0x32f49e37, 0x34061719)}, + {TOBN(0xb73c57f1, 0x01d8b4d6), TOBN(0x03c8423c, 0x26b47700), + TOBN(0x321d0bc8, 0xa4d8826a), TOBN(0x6004213c, 0x4bc0e638)}}, + {{TOBN(0xf78c64a1, 0xc1c06681), TOBN(0x16e0a16f, 0xef018e50), + TOBN(0x31cbdf91, 0xdb42b2b3), TOBN(0xf8f4ffce, 0xe0d36f58)}, + {TOBN(0xcdcc71cd, 0x4cc5e3e0), TOBN(0xd55c7cfa, 0xa129e3e0), + TOBN(0xccdb6ba0, 0x0fb2cbf1), TOBN(0x6aba0005, 0xc4bce3cb)}}, + {{TOBN(0x501cdb30, 0xd232cfc4), TOBN(0x9ddcf12e, 0xd58a3cef), + TOBN(0x02d2cf9c, 0x87e09149), TOBN(0xdc5d7ec7, 0x2c976257)}, + {TOBN(0x6447986e, 0x0b50d7dd), TOBN(0x88fdbaf7, 0x807f112a), + TOBN(0x58c9822a, 0xb00ae9f6), TOBN(0x6abfb950, 0x6d3d27e0)}}, + {{TOBN(0xd0a74487, 0x8a429f4f), TOBN(0x0649712b, 0xdb516609), + TOBN(0xb826ba57, 0xe769b5df), TOBN(0x82335df2, 0x1fc7aaf2)}, + {TOBN(0x2389f067, 0x5c93d995), TOBN(0x59ac367a, 0x68677be6), + TOBN(0xa77985ff, 0x21d9951b), TOBN(0x038956fb, 0x85011cce)}}, + {{TOBN(0x608e48cb, 0xbb734e37), TOBN(0xc08c0bf2, 0x2be5b26f), + TOBN(0x17bbdd3b, 0xf9b1a0d9), TOBN(0xeac7d898, 0x10483319)}, + {TOBN(0xc95c4baf, 0xbc1a6dea), TOBN(0xfdd0e2bf, 0x172aafdb), + TOBN(0x40373cbc, 0x8235c41a), TOBN(0x14303f21, 0xfb6f41d5)}}, + {{TOBN(0xba063621, 0x0408f237), TOBN(0xcad3b09a, 0xecd2d1ed), + TOBN(0x4667855a, 0x52abb6a2), TOBN(0xba9157dc, 0xaa8b417b)}, + {TOBN(0xfe7f3507, 0x4f013efb), TOBN(0x1b112c4b, 0xaa38c4a2), + TOBN(0xa1406a60, 0x9ba64345), TOBN(0xe53cba33, 0x6993c80b)}}, + {{TOBN(0x45466063, 0xded40d23), TOBN(0x3d5f1f4d, 0x54908e25), + TOBN(0x9ebefe62, 0x403c3c31), TOBN(0x274ea0b5, 0x0672a624)}, + {TOBN(0xff818d99, 0x451d1b71), TOBN(0x80e82643, 0x8f79cf79), + TOBN(0xa165df13, 0x73ce37f5), TOBN(0xa744ef4f, 0xfe3a21fd)}}, + {{TOBN(0x73f1e7f5, 0xcf551396), TOBN(0xc616898e, 0x868c676b), + TOBN(0x671c28c7, 0x8c442c36), TOBN(0xcfe5e558, 0x5e0a317d)}, + {TOBN(0x1242d818, 0x7051f476), TOBN(0x56fad2a6, 0x14f03442), + TOBN(0x262068bc, 0x0a44d0f6), TOBN(0xdfa2cd6e, 0xce6edf4e)}}, + {{TOBN(0x0f43813a, 0xd15d1517), TOBN(0x61214cb2, 0x377d44f5), + TOBN(0xd399aa29, 0xc639b35f), TOBN(0x42136d71, 0x54c51c19)}, + {TOBN(0x9774711b, 0x08417221), TOBN(0x0a5546b3, 0x52545a57), + TOBN(0x80624c41, 0x1150582d), TOBN(0x9ec5c418, 0xfbc555bc)}}, + {{TOBN(0x2c87dcad, 0x771849f1), TOBN(0xb0c932c5, 0x01d7bf6f), + TOBN(0x6aa5cd3e, 0x89116eb2), TOBN(0xd378c25a, 0x51ca7bd3)}, + {TOBN(0xc612a0da, 0x9e6e3e31), TOBN(0x0417a54d, 0xb68ad5d0), + TOBN(0x00451e4a, 0x22c6edb8), TOBN(0x9fbfe019, 0xb42827ce)}}, + {{TOBN(0x2fa92505, 0xba9384a2), TOBN(0x21b8596e, 0x64ad69c1), + TOBN(0x8f4fcc49, 0x983b35a6), TOBN(0xde093760, 0x72754672)}, + {TOBN(0x2f14ccc8, 0xf7bffe6d), TOBN(0x27566bff, 0x5d94263d), + TOBN(0xb5b4e9c6, 0x2df3ec30), TOBN(0x94f1d7d5, 0x3e6ea6ba)}}, + {{TOBN(0x97b7851a, 0xaaca5e9b), TOBN(0x518aa521, 0x56713b97), + TOBN(0x3357e8c7, 0x150a61f6), TOBN(0x7842e7e2, 0xec2c2b69)}, + {TOBN(0x8dffaf65, 0x6868a548), TOBN(0xd963bd82, 0xe068fc81), + TOBN(0x64da5c8b, 0x65917733), TOBN(0x927090ff, 0x7b247328)}}}, + {{{TOBN(0x214bc9a7, 0xd298c241), TOBN(0xe3b697ba, 0x56807cfd), + TOBN(0xef1c7802, 0x4564eadb), TOBN(0xdde8cdcf, 0xb48149c5)}, + {TOBN(0x946bf0a7, 0x5a4d2604), TOBN(0x27154d7f, 0x6c1538af), + TOBN(0x95cc9230, 0xde5b1fcc), TOBN(0xd88519e9, 0x66864f82)}}, + {{TOBN(0xb828dd1a, 0x7cb1282c), TOBN(0xa08d7626, 0xbe46973a), + TOBN(0x6baf8d40, 0xe708d6b2), TOBN(0x72571fa1, 0x4daeb3f3)}, + {TOBN(0x85b1732f, 0xf22dfd98), TOBN(0x87ab01a7, 0x0087108d), + TOBN(0xaaaafea8, 0x5988207a), TOBN(0xccc832f8, 0x69f00755)}}, + {{TOBN(0x964d950e, 0x36ff3bf0), TOBN(0x8ad20f6f, 0xf0b34638), + TOBN(0x4d9177b3, 0xb5d7585f), TOBN(0xcf839760, 0xef3f019f)}, + {TOBN(0x582fc5b3, 0x8288c545), TOBN(0x2f8e4e9b, 0x13116bd1), + TOBN(0xf91e1b2f, 0x332120ef), TOBN(0xcf568724, 0x2a17dd23)}}, + {{TOBN(0x488f1185, 0xca8d9d1a), TOBN(0xadf2c77d, 0xd987ded2), + TOBN(0x5f3039f0, 0x60c46124), TOBN(0xe5d70b75, 0x71e095f4)}, + {TOBN(0x82d58650, 0x6260e70f), TOBN(0x39d75ea7, 0xf750d105), + TOBN(0x8cf3d0b1, 0x75bac364), TOBN(0xf3a7564d, 0x21d01329)}}, + {{TOBN(0x182f04cd, 0x2f52d2a7), TOBN(0x4fde149a, 0xe2df565a), + TOBN(0xb80c5eec, 0xa79fb2f7), TOBN(0xab491d7b, 0x22ddc897)}, + {TOBN(0x99d76c18, 0xc6312c7f), TOBN(0xca0d5f3d, 0x6aa41a57), + TOBN(0x71207325, 0xd15363a0), TOBN(0xe82aa265, 0xbeb252c2)}}, + {{TOBN(0x94ab4700, 0xec3128c2), TOBN(0x6c76d862, 0x8e383f49), + TOBN(0xdc36b150, 0xc03024eb), TOBN(0xfb439477, 0x53daac69)}, + {TOBN(0xfc68764a, 0x8dc79623), TOBN(0x5b86995d, 0xb440fbb2), + TOBN(0xd66879bf, 0xccc5ee0d), TOBN(0x05228942, 0x95aa8bd3)}}, + {{TOBN(0xb51a40a5, 0x1e6a75c1), TOBN(0x24327c76, 0x0ea7d817), + TOBN(0x06630182, 0x07774597), TOBN(0xd6fdbec3, 0x97fa7164)}, + {TOBN(0x20c99dfb, 0x13c90f48), TOBN(0xd6ac5273, 0x686ef263), + TOBN(0xc6a50bdc, 0xfef64eeb), TOBN(0xcd87b281, 0x86fdfc32)}}, + {{TOBN(0xb24aa43e, 0x3fcd3efc), TOBN(0xdd26c034, 0xb8088e9a), + TOBN(0xa5ef4dc9, 0xbd3d46ea), TOBN(0xa2f99d58, 0x8a4c6a6f)}, + {TOBN(0xddabd355, 0x2f1da46c), TOBN(0x72c3f8ce, 0x1afacdd1), + TOBN(0xd90c4eee, 0x92d40578), TOBN(0xd28bb41f, 0xca623b94)}}, + {{TOBN(0x50fc0711, 0x745edc11), TOBN(0x9dd9ad7d, 0x3dc87558), + TOBN(0xce6931fb, 0xb49d1e64), TOBN(0x6c77a0a2, 0xc98bd0f9)}, + {TOBN(0x62b9a629, 0x6baf7cb1), TOBN(0xcf065f91, 0xccf72d22), + TOBN(0x7203cce9, 0x79639071), TOBN(0x09ae4885, 0xf9cb732f)}}, + {{TOBN(0x5e7c3bec, 0xee8314f3), TOBN(0x1c068aed, 0xdbea298f), + TOBN(0x08d381f1, 0x7c80acec), TOBN(0x03b56be8, 0xe330495b)}, + {TOBN(0xaeffb8f2, 0x9222882d), TOBN(0x95ff38f6, 0xc4af8bf7), + TOBN(0x50e32d35, 0x1fc57d8c), TOBN(0x6635be52, 0x17b444f0)}}, + {{TOBN(0x04d15276, 0xa5177900), TOBN(0x4e1dbb47, 0xf6858752), + TOBN(0x5b475622, 0xc615796c), TOBN(0xa6fa0387, 0x691867bf)}, + {TOBN(0xed7f5d56, 0x2844c6d0), TOBN(0xc633cf9b, 0x03a2477d), + TOBN(0xf6be5c40, 0x2d3721d6), TOBN(0xaf312eb7, 0xe9fd68e6)}}, + {{TOBN(0x242792d2, 0xe7417ce1), TOBN(0xff42bc71, 0x970ee7f5), + TOBN(0x1ff4dc6d, 0x5c67a41e), TOBN(0x77709b7b, 0x20882a58)}, + {TOBN(0x3554731d, 0xbe217f2c), TOBN(0x2af2a8cd, 0x5bb72177), + TOBN(0x58eee769, 0x591dd059), TOBN(0xbb2930c9, 0x4bba6477)}}, + {{TOBN(0x863ee047, 0x7d930cfc), TOBN(0x4c262ad1, 0x396fd1f4), + TOBN(0xf4765bc8, 0x039af7e1), TOBN(0x2519834b, 0x5ba104f6)}, + {TOBN(0x7cd61b4c, 0xd105f961), TOBN(0xa5415da5, 0xd63bca54), + TOBN(0x778280a0, 0x88a1f17c), TOBN(0xc4968949, 0x2329512c)}}, + {{TOBN(0x174a9126, 0xcecdaa7a), TOBN(0xfc8c7e0e, 0x0b13247b), + TOBN(0x29c110d2, 0x3484c1c4), TOBN(0xf8eb8757, 0x831dfc3b)}, + {TOBN(0x022f0212, 0xc0067452), TOBN(0x3f6f69ee, 0x7b9b926c), + TOBN(0x09032da0, 0xef42daf4), TOBN(0x79f00ade, 0x83f80de4)}}, + {{TOBN(0x6210db71, 0x81236c97), TOBN(0x74f7685b, 0x3ee0781f), + TOBN(0x4df7da7b, 0xa3e41372), TOBN(0x2aae38b1, 0xb1a1553e)}, + {TOBN(0x1688e222, 0xf6dd9d1b), TOBN(0x57695448, 0x5b8b6487), + TOBN(0x478d2127, 0x4b2edeaa), TOBN(0xb2818fa5, 0x1e85956a)}}, + {{TOBN(0x1e6addda, 0xf176f2c0), TOBN(0x01ca4604, 0xe2572658), + TOBN(0x0a404ded, 0x85342ffb), TOBN(0x8cf60f96, 0x441838d6)}, + {TOBN(0x9bbc691c, 0xc9071c4a), TOBN(0xfd588744, 0x34442803), + TOBN(0x97101c85, 0x809c0d81), TOBN(0xa7fb754c, 0x8c456f7f)}}, + {{TOBN(0xc95f3c5c, 0xd51805e1), TOBN(0xab4ccd39, 0xb299dca8), + TOBN(0x3e03d20b, 0x47eaf500), TOBN(0xfa3165c1, 0xd7b80893)}, + {TOBN(0x005e8b54, 0xe160e552), TOBN(0xdc4972ba, 0x9019d11f), + TOBN(0x21a6972e, 0x0c9a4a7a), TOBN(0xa52c258f, 0x37840fd7)}}, + {{TOBN(0xf8559ff4, 0xc1e99d81), TOBN(0x08e1a7d6, 0xa3c617c0), + TOBN(0xb398fd43, 0x248c6ba7), TOBN(0x6ffedd91, 0xd1283794)}, + {TOBN(0x8a6a59d2, 0xd629d208), TOBN(0xa9d141d5, 0x3490530e), + TOBN(0x42f6fc18, 0x38505989), TOBN(0x09bf250d, 0x479d94ee)}}, + {{TOBN(0x223ad3b1, 0xb3822790), TOBN(0x6c5926c0, 0x93b8971c), + TOBN(0x609efc7e, 0x75f7fa62), TOBN(0x45d66a6d, 0x1ec2d989)}, + {TOBN(0x4422d663, 0x987d2792), TOBN(0x4a73caad, 0x3eb31d2b), + TOBN(0xf06c2ac1, 0xa32cb9e6), TOBN(0xd9445c5f, 0x91aeba84)}}, + {{TOBN(0x6af7a1d5, 0xaf71013f), TOBN(0xe68216e5, 0x0bedc946), + TOBN(0xf4cba30b, 0xd27370a0), TOBN(0x7981afbf, 0x870421cc)}, + {TOBN(0x02496a67, 0x9449f0e1), TOBN(0x86cfc4be, 0x0a47edae), + TOBN(0x3073c936, 0xb1feca22), TOBN(0xf5694612, 0x03f8f8fb)}}, + {{TOBN(0xd063b723, 0x901515ea), TOBN(0x4c6c77a5, 0x749cf038), + TOBN(0x6361e360, 0xab9e5059), TOBN(0x596cf171, 0xa76a37c0)}, + {TOBN(0x800f53fa, 0x6530ae7a), TOBN(0x0f5e631e, 0x0792a7a6), + TOBN(0x5cc29c24, 0xefdb81c9), TOBN(0xa269e868, 0x3f9c40ba)}}, + {{TOBN(0xec14f9e1, 0x2cb7191e), TOBN(0x78ea1bd8, 0xe5b08ea6), + TOBN(0x3c65aa9b, 0x46332bb9), TOBN(0x84cc22b3, 0xbf80ce25)}, + {TOBN(0x0098e9e9, 0xd49d5bf1), TOBN(0xcd4ec1c6, 0x19087da4), + TOBN(0x3c9d07c5, 0xaef6e357), TOBN(0x839a0268, 0x9f8f64b8)}}, + {{TOBN(0xc5e9eb62, 0xc6d8607f), TOBN(0x759689f5, 0x6aa995e4), + TOBN(0x70464669, 0xbbb48317), TOBN(0x921474bf, 0xe402417d)}, + {TOBN(0xcabe135b, 0x2a354c8c), TOBN(0xd51e52d2, 0x812fa4b5), + TOBN(0xec741096, 0x53311fe8), TOBN(0x4f774535, 0xb864514b)}}, + {{TOBN(0xbcadd671, 0x5bde48f8), TOBN(0xc9703873, 0x2189bc7d), + TOBN(0x5d45299e, 0xc709ee8a), TOBN(0xd1287ee2, 0x845aaff8)}, + {TOBN(0x7d1f8874, 0xdb1dbf1f), TOBN(0xea46588b, 0x990c88d6), + TOBN(0x60ba649a, 0x84368313), TOBN(0xd5fdcbce, 0x60d543ae)}}, + {{TOBN(0x90b46d43, 0x810d5ab0), TOBN(0x6739d8f9, 0x04d7e5cc), + TOBN(0x021c1a58, 0x0d337c33), TOBN(0x00a61162, 0x68e67c40)}, + {TOBN(0x95ef413b, 0x379f0a1f), TOBN(0xfe126605, 0xe9e2ab95), + TOBN(0x67578b85, 0x2f5f199c), TOBN(0xf5c00329, 0x2cb84913)}}, + {{TOBN(0xf7956430, 0x37577dd8), TOBN(0x83b82af4, 0x29c5fe88), + TOBN(0x9c1bea26, 0xcdbdc132), TOBN(0x589fa086, 0x9c04339e)}, + {TOBN(0x033e9538, 0xb13799df), TOBN(0x85fa8b21, 0xd295d034), + TOBN(0xdf17f73f, 0xbd9ddcca), TOBN(0xf32bd122, 0xddb66334)}}, + {{TOBN(0x55ef88a7, 0x858b044c), TOBN(0x1f0d69c2, 0x5aa9e397), + TOBN(0x55fd9cc3, 0x40d85559), TOBN(0xc774df72, 0x7785ddb2)}, + {TOBN(0x5dcce9f6, 0xd3bd2e1c), TOBN(0xeb30da20, 0xa85dfed0), + TOBN(0x5ed7f5bb, 0xd3ed09c4), TOBN(0x7d42a35c, 0x82a9c1bd)}}, + {{TOBN(0xcf3de995, 0x9890272d), TOBN(0x75f3432a, 0x3e713a10), + TOBN(0x5e13479f, 0xe28227b8), TOBN(0xb8561ea9, 0xfefacdc8)}, + {TOBN(0xa6a297a0, 0x8332aafd), TOBN(0x9b0d8bb5, 0x73809b62), + TOBN(0xd2fa1cfd, 0x0c63036f), TOBN(0x7a16eb55, 0xbd64bda8)}}, + {{TOBN(0x3f5cf5f6, 0x78e62ddc), TOBN(0x2267c454, 0x07fd752b), + TOBN(0x5e361b6b, 0x5e437bbe), TOBN(0x95c59501, 0x8354e075)}, + {TOBN(0xec725f85, 0xf2b254d9), TOBN(0x844b617d, 0x2cb52b4e), + TOBN(0xed8554f5, 0xcf425fb5), TOBN(0xab67703e, 0x2af9f312)}}, + {{TOBN(0x4cc34ec1, 0x3cf48283), TOBN(0xb09daa25, 0x9c8a705e), + TOBN(0xd1e9d0d0, 0x5b7d4f84), TOBN(0x4df6ef64, 0xdb38929d)}, + {TOBN(0xe16b0763, 0xaa21ba46), TOBN(0xc6b1d178, 0xa293f8fb), + TOBN(0x0ff5b602, 0xd520aabf), TOBN(0x94d671bd, 0xc339397a)}}, + {{TOBN(0x7c7d98cf, 0x4f5792fa), TOBN(0x7c5e0d67, 0x11215261), + TOBN(0x9b19a631, 0xa7c5a6d4), TOBN(0xc8511a62, 0x7a45274d)}, + {TOBN(0x0c16621c, 0xa5a60d99), TOBN(0xf7fbab88, 0xcf5e48cb), + TOBN(0xab1e6ca2, 0xf7ddee08), TOBN(0x83bd08ce, 0xe7867f3c)}}, + {{TOBN(0xf7e48e8a, 0x2ac13e27), TOBN(0x4494f6df, 0x4eb1a9f5), + TOBN(0xedbf84eb, 0x981f0a62), TOBN(0x49badc32, 0x536438f0)}, + {TOBN(0x50bea541, 0x004f7571), TOBN(0xbac67d10, 0xdf1c94ee), + TOBN(0x253d73a1, 0xb727bc31), TOBN(0xb3d01cf2, 0x30686e28)}}, + {{TOBN(0x51b77b1b, 0x55fd0b8b), TOBN(0xa099d183, 0xfeec3173), + TOBN(0x202b1fb7, 0x670e72b7), TOBN(0xadc88b33, 0xa8e1635f)}, + {TOBN(0x34e8216a, 0xf989d905), TOBN(0xc2e68d20, 0x29b58d01), + TOBN(0x11f81c92, 0x6fe55a93), TOBN(0x15f1462a, 0x8f296f40)}}, + {{TOBN(0x1915d375, 0xea3d62f2), TOBN(0xa17765a3, 0x01c8977d), + TOBN(0x7559710a, 0xe47b26f6), TOBN(0xe0bd29c8, 0x535077a5)}, + {TOBN(0x615f976d, 0x08d84858), TOBN(0x370dfe85, 0x69ced5c1), + TOBN(0xbbc7503c, 0xa734fa56), TOBN(0xfbb9f1ec, 0x91ac4574)}}, + {{TOBN(0x95d7ec53, 0x060dd7ef), TOBN(0xeef2dacd, 0x6e657979), + TOBN(0x54511af3, 0xe2a08235), TOBN(0x1e324aa4, 0x1f4aea3d)}, + {TOBN(0x550e7e71, 0xe6e67671), TOBN(0xbccd5190, 0xbf52faf7), + TOBN(0xf880d316, 0x223cc62a), TOBN(0x0d402c7e, 0x2b32eb5d)}}, + {{TOBN(0xa40bc039, 0x306a5a3b), TOBN(0x4e0a41fd, 0x96783a1b), + TOBN(0xa1e8d39a, 0x0253cdd4), TOBN(0x6480be26, 0xc7388638)}, + {TOBN(0xee365e1d, 0x2285f382), TOBN(0x188d8d8f, 0xec0b5c36), + TOBN(0x34ef1a48, 0x1f0f4d82), TOBN(0x1a8f43e1, 0xa487d29a)}}, + {{TOBN(0x8168226d, 0x77aefb3a), TOBN(0xf69a751e, 0x1e72c253), + TOBN(0x8e04359a, 0xe9594df1), TOBN(0x475ffd7d, 0xd14c0467)}, + {TOBN(0xb5a2c2b1, 0x3844e95c), TOBN(0x85caf647, 0xdd12ef94), + TOBN(0x1ecd2a9f, 0xf1063d00), TOBN(0x1dd2e229, 0x23843311)}}, + {{TOBN(0x38f0e09d, 0x73d17244), TOBN(0x3ede7746, 0x8fc653f1), + TOBN(0xae4459f5, 0xdc20e21c), TOBN(0x00db2ffa, 0x6a8599ea)}, + {TOBN(0x11682c39, 0x30cfd905), TOBN(0x4934d074, 0xa5c112a6), + TOBN(0xbdf063c5, 0x568bfe95), TOBN(0x779a440a, 0x016c441a)}}, + {{TOBN(0x0c23f218, 0x97d6fbdc), TOBN(0xd3a5cd87, 0xe0776aac), + TOBN(0xcee37f72, 0xd712e8db), TOBN(0xfb28c70d, 0x26f74e8d)}, + {TOBN(0xffe0c728, 0xb61301a0), TOBN(0xa6282168, 0xd3724354), + TOBN(0x7ff4cb00, 0x768ffedc), TOBN(0xc51b3088, 0x03b02de9)}}, + {{TOBN(0xa5a8147c, 0x3902dda5), TOBN(0x35d2f706, 0xfe6973b4), + TOBN(0x5ac2efcf, 0xc257457e), TOBN(0x933f48d4, 0x8700611b)}, + {TOBN(0xc365af88, 0x4912beb2), TOBN(0x7f5a4de6, 0x162edf94), + TOBN(0xc646ba7c, 0x0c32f34b), TOBN(0x632c6af3, 0xb2091074)}}, + {{TOBN(0x58d4f2e3, 0x753e43a9), TOBN(0x70e1d217, 0x24d4e23f), + TOBN(0xb24bf729, 0xafede6a6), TOBN(0x7f4a94d8, 0x710c8b60)}, + {TOBN(0xaad90a96, 0x8d4faa6a), TOBN(0xd9ed0b32, 0xb066b690), + TOBN(0x52fcd37b, 0x78b6dbfd), TOBN(0x0b64615e, 0x8bd2b431)}}, + {{TOBN(0x228e2048, 0xcfb9fad5), TOBN(0xbeaa386d, 0x240b76bd), + TOBN(0x2d6681c8, 0x90dad7bc), TOBN(0x3e553fc3, 0x06d38f5e)}, + {TOBN(0xf27cdb9b, 0x9d5f9750), TOBN(0x3e85c52a, 0xd28c5b0e), + TOBN(0x190795af, 0x5247c39b), TOBN(0x547831eb, 0xbddd6828)}}, + {{TOBN(0xf327a227, 0x4a82f424), TOBN(0x36919c78, 0x7e47f89d), + TOBN(0xe4783919, 0x43c7392c), TOBN(0xf101b9aa, 0x2316fefe)}, + {TOBN(0xbcdc9e9c, 0x1c5009d2), TOBN(0xfb55ea13, 0x9cd18345), + TOBN(0xf5b5e231, 0xa3ce77c7), TOBN(0xde6b4527, 0xd2f2cb3d)}}, + {{TOBN(0x10f6a333, 0x9bb26f5f), TOBN(0x1e85db8e, 0x044d85b6), + TOBN(0xc3697a08, 0x94197e54), TOBN(0x65e18cc0, 0xa7cb4ea8)}, + {TOBN(0xa38c4f50, 0xa471fe6e), TOBN(0xf031747a, 0x2f13439c), + TOBN(0x53c4a6ba, 0xc007318b), TOBN(0xa8da3ee5, 0x1deccb3d)}}, + {{TOBN(0x0555b31c, 0x558216b1), TOBN(0x90c7810c, 0x2f79e6c2), + TOBN(0x9b669f4d, 0xfe8eed3c), TOBN(0x70398ec8, 0xe0fac126)}, + {TOBN(0xa96a449e, 0xf701b235), TOBN(0x0ceecdb3, 0xeb94f395), + TOBN(0x285fc368, 0xd0cb7431), TOBN(0x0d37bb52, 0x16a18c64)}}, + {{TOBN(0x05110d38, 0xb880d2dd), TOBN(0xa60f177b, 0x65930d57), + TOBN(0x7da34a67, 0xf36235f5), TOBN(0x47f5e17c, 0x183816b9)}, + {TOBN(0xc7664b57, 0xdb394af4), TOBN(0x39ba215d, 0x7036f789), + TOBN(0x46d2ca0e, 0x2f27b472), TOBN(0xc42647ee, 0xf73a84b7)}}, + {{TOBN(0x44bc7545, 0x64488f1d), TOBN(0xaa922708, 0xf4cf85d5), + TOBN(0x721a01d5, 0x53e4df63), TOBN(0x649c0c51, 0x5db46ced)}, + {TOBN(0x6bf0d64e, 0x3cffcb6c), TOBN(0xe3bf93fe, 0x50f71d96), + TOBN(0x75044558, 0xbcc194a0), TOBN(0x16ae3372, 0x6afdc554)}}, + {{TOBN(0xbfc01adf, 0x5ca48f3f), TOBN(0x64352f06, 0xe22a9b84), + TOBN(0xcee54da1, 0xc1099e4a), TOBN(0xbbda54e8, 0xfa1b89c0)}, + {TOBN(0x166a3df5, 0x6f6e55fb), TOBN(0x1ca44a24, 0x20176f88), + TOBN(0x936afd88, 0xdfb7b5ff), TOBN(0xe34c2437, 0x8611d4a0)}}, + {{TOBN(0x7effbb75, 0x86142103), TOBN(0x6704ba1b, 0x1f34fc4d), + TOBN(0x7c2a468f, 0x10c1b122), TOBN(0x36b3a610, 0x8c6aace9)}, + {TOBN(0xabfcc0a7, 0x75a0d050), TOBN(0x066f9197, 0x3ce33e32), + TOBN(0xce905ef4, 0x29fe09be), TOBN(0x89ee25ba, 0xa8376351)}}, + {{TOBN(0x2a3ede22, 0xfd29dc76), TOBN(0x7fd32ed9, 0x36f17260), + TOBN(0x0cadcf68, 0x284b4126), TOBN(0x63422f08, 0xa7951fc8)}, + {TOBN(0x562b24f4, 0x0807e199), TOBN(0xfe9ce5d1, 0x22ad4490), + TOBN(0xc2f51b10, 0x0db2b1b4), TOBN(0xeb3613ff, 0xe4541d0d)}}, + {{TOBN(0xbd2c4a05, 0x2680813b), TOBN(0x527aa55d, 0x561b08d6), + TOBN(0xa9f8a40e, 0xa7205558), TOBN(0xe3eea56f, 0x243d0bec)}, + {TOBN(0x7b853817, 0xa0ff58b3), TOBN(0xb67d3f65, 0x1a69e627), + TOBN(0x0b76bbb9, 0xa869b5d6), TOBN(0xa3afeb82, 0x546723ed)}}, + {{TOBN(0x5f24416d, 0x3e554892), TOBN(0x8413b53d, 0x430e2a45), + TOBN(0x99c56aee, 0x9032a2a0), TOBN(0x09432bf6, 0xeec367b1)}, + {TOBN(0x552850c6, 0xdaf0ecc1), TOBN(0x49ebce55, 0x5bc92048), + TOBN(0xdfb66ba6, 0x54811307), TOBN(0x1b84f797, 0x6f298597)}}, + {{TOBN(0x79590481, 0x8d1d7a0d), TOBN(0xd9fabe03, 0x3a6fa556), + TOBN(0xa40f9c59, 0xba9e5d35), TOBN(0xcb1771c1, 0xf6247577)}, + {TOBN(0x542a47ca, 0xe9a6312b), TOBN(0xa34b3560, 0x552dd8c5), + TOBN(0xfdf94de0, 0x0d794716), TOBN(0xd46124a9, 0x9c623094)}}, + {{TOBN(0x56b7435d, 0x68afe8b4), TOBN(0x27f20540, 0x6c0d8ea1), + TOBN(0x12b77e14, 0x73186898), TOBN(0xdbc3dd46, 0x7479490f)}, + {TOBN(0x951a9842, 0xc03b0c05), TOBN(0x8b1b3bb3, 0x7921bc96), + TOBN(0xa573b346, 0x2b202e0a), TOBN(0x77e4665d, 0x47254d56)}}, + {{TOBN(0x08b70dfc, 0xd23e3984), TOBN(0xab86e8bc, 0xebd14236), + TOBN(0xaa3e07f8, 0x57114ba7), TOBN(0x5ac71689, 0xab0ef4f2)}, + {TOBN(0x88fca384, 0x0139d9af), TOBN(0x72733f88, 0x76644af0), + TOBN(0xf122f72a, 0x65d74f4a), TOBN(0x13931577, 0xa5626c7a)}}, + {{TOBN(0xd5b5d9eb, 0x70f8d5a4), TOBN(0x375adde7, 0xd7bbb228), + TOBN(0x31e88b86, 0x0c1c0b32), TOBN(0xd1f568c4, 0x173edbaa)}, + {TOBN(0x1592fc83, 0x5459df02), TOBN(0x2beac0fb, 0x0fcd9a7e), + TOBN(0xb0a6fdb8, 0x1b473b0a), TOBN(0xe3224c6f, 0x0fe8fc48)}}, + {{TOBN(0x680bd00e, 0xe87edf5b), TOBN(0x30385f02, 0x20e77cf5), + TOBN(0xe9ab98c0, 0x4d42d1b2), TOBN(0x72d191d2, 0xd3816d77)}, + {TOBN(0x1564daca, 0x0917d9e5), TOBN(0x394eab59, 0x1f8fed7f), + TOBN(0xa209aa8d, 0x7fbb3896), TOBN(0x5564f3b9, 0xbe6ac98e)}}, + {{TOBN(0xead21d05, 0xd73654ef), TOBN(0x68d1a9c4, 0x13d78d74), + TOBN(0x61e01708, 0x6d4973a0), TOBN(0x83da3500, 0x46e6d32a)}, + {TOBN(0x6a3dfca4, 0x68ae0118), TOBN(0xa1b9a4c9, 0xd02da069), + TOBN(0x0b2ff9c7, 0xebab8302), TOBN(0x98af07c3, 0x944ba436)}}, + {{TOBN(0x85997326, 0x995f0f9f), TOBN(0x467fade0, 0x71b58bc6), + TOBN(0x47e4495a, 0xbd625a2b), TOBN(0xfdd2d01d, 0x33c3b8cd)}, + {TOBN(0x2c38ae28, 0xc693f9fa), TOBN(0x48622329, 0x348f7999), + TOBN(0x97bf738e, 0x2161f583), TOBN(0x15ee2fa7, 0x565e8cc9)}}, + {{TOBN(0xa1a5c845, 0x5777e189), TOBN(0xcc10bee0, 0x456f2829), + TOBN(0x8ad95c56, 0xda762bd5), TOBN(0x152e2214, 0xe9d91da8)}, + {TOBN(0x975b0e72, 0x7cb23c74), TOBN(0xfd5d7670, 0xa90c66df), + TOBN(0xb5b5b8ad, 0x225ffc53), TOBN(0xab6dff73, 0xfaded2ae)}}, + {{TOBN(0xebd56781, 0x6f4cbe9d), TOBN(0x0ed8b249, 0x6a574bd7), + TOBN(0x41c246fe, 0x81a881fa), TOBN(0x91564805, 0xc3db9c70)}, + {TOBN(0xd7c12b08, 0x5b862809), TOBN(0x1facd1f1, 0x55858d7b), + TOBN(0x7693747c, 0xaf09e92a), TOBN(0x3b69dcba, 0x189a425f)}}, + {{TOBN(0x0be28e9f, 0x967365ef), TOBN(0x57300eb2, 0xe801f5c9), + TOBN(0x93b8ac6a, 0xd583352f), TOBN(0xa2cf1f89, 0xcd05b2b7)}, + {TOBN(0x7c0c9b74, 0x4dcc40cc), TOBN(0xfee38c45, 0xada523fb), + TOBN(0xb49a4dec, 0x1099cc4d), TOBN(0x325c377f, 0x69f069c6)}}, + {{TOBN(0xe12458ce, 0x476cc9ff), TOBN(0x580e0b6c, 0xc6d4cb63), + TOBN(0xd561c8b7, 0x9072289b), TOBN(0x0377f264, 0xa619e6da)}, + {TOBN(0x26685362, 0x88e591a5), TOBN(0xa453a7bd, 0x7523ca2b), + TOBN(0x8a9536d2, 0xc1df4533), TOBN(0xc8e50f2f, 0xbe972f79)}}, + {{TOBN(0xd433e50f, 0x6d3549cf), TOBN(0x6f33696f, 0xfacd665e), + TOBN(0x695bfdac, 0xce11fcb4), TOBN(0x810ee252, 0xaf7c9860)}, + {TOBN(0x65450fe1, 0x7159bb2c), TOBN(0xf7dfbebe, 0x758b357b), + TOBN(0x2b057e74, 0xd69fea72), TOBN(0xd485717a, 0x92731745)}}}, + {{{TOBN(0x896c42e8, 0xee36860c), TOBN(0xdaf04dfd, 0x4113c22d), + TOBN(0x1adbb7b7, 0x44104213), TOBN(0xe5fd5fa1, 0x1fd394ea)}, + {TOBN(0x68235d94, 0x1a4e0551), TOBN(0x6772cfbe, 0x18d10151), + TOBN(0x276071e3, 0x09984523), TOBN(0xe4e879de, 0x5a56ba98)}}, + {{TOBN(0xaaafafb0, 0x285b9491), TOBN(0x01a0be88, 0x1e4c705e), + TOBN(0xff1d4f5d, 0x2ad9caab), TOBN(0x6e349a4a, 0xc37a233f)}, + {TOBN(0xcf1c1246, 0x4a1c6a16), TOBN(0xd99e6b66, 0x29383260), + TOBN(0xea3d4366, 0x5f6d5471), TOBN(0x36974d04, 0xff8cc89b)}}, + {{TOBN(0xc26c49a1, 0xcfe89d80), TOBN(0xb42c026d, 0xda9c8371), + TOBN(0xca6c013a, 0xdad066d2), TOBN(0xfb8f7228, 0x56a4f3ee)}, + {TOBN(0x08b579ec, 0xd850935b), TOBN(0x34c1a74c, 0xd631e1b3), + TOBN(0xcb5fe596, 0xac198534), TOBN(0x39ff21f6, 0xe1f24f25)}}, + {{TOBN(0x27f29e14, 0x8f929057), TOBN(0x7a64ae06, 0xc0c853df), + TOBN(0x256cd183, 0x58e9c5ce), TOBN(0x9d9cce82, 0xded092a5)}, + {TOBN(0xcc6e5979, 0x6e93b7c7), TOBN(0xe1e47092, 0x31bb9e27), + TOBN(0xb70b3083, 0xaa9e29a0), TOBN(0xbf181a75, 0x3785e644)}}, + {{TOBN(0xf53f2c65, 0x8ead09f7), TOBN(0x1335e1d5, 0x9780d14d), + TOBN(0x69cc20e0, 0xcd1b66bc), TOBN(0x9b670a37, 0xbbe0bfc8)}, + {TOBN(0xce53dc81, 0x28efbeed), TOBN(0x0c74e77c, 0x8326a6e5), + TOBN(0x3604e0d2, 0xb88e9a63), TOBN(0xbab38fca, 0x13dc2248)}}, + {{TOBN(0x8ed6e8c8, 0x5c0a3f1e), TOBN(0xbcad2492, 0x7c87c37f), + TOBN(0xfdfb62bb, 0x9ee3b78d), TOBN(0xeba8e477, 0xcbceba46)}, + {TOBN(0x37d38cb0, 0xeeaede4b), TOBN(0x0bc498e8, 0x7976deb6), + TOBN(0xb2944c04, 0x6b6147fb), TOBN(0x8b123f35, 0xf71f9609)}}, + {{TOBN(0xa155dcc7, 0xde79dc24), TOBN(0xf1168a32, 0x558f69cd), + TOBN(0xbac21595, 0x0d1850df), TOBN(0x15c8295b, 0xb204c848)}, + {TOBN(0xf661aa36, 0x7d8184ff), TOBN(0xc396228e, 0x30447bdb), + TOBN(0x11cd5143, 0xbde4a59e), TOBN(0xe3a26e3b, 0x6beab5e6)}}, + {{TOBN(0xd3b3a13f, 0x1402b9d0), TOBN(0x573441c3, 0x2c7bc863), + TOBN(0x4b301ec4, 0x578c3e6e), TOBN(0xc26fc9c4, 0x0adaf57e)}, + {TOBN(0x96e71bfd, 0x7493cea3), TOBN(0xd05d4b3f, 0x1af81456), + TOBN(0xdaca2a8a, 0x6a8c608f), TOBN(0x53ef07f6, 0x0725b276)}}, + {{TOBN(0x07a5fbd2, 0x7824fc56), TOBN(0x34675218, 0x13289077), + TOBN(0x5bf69fd5, 0xe0c48349), TOBN(0xa613ddd3, 0xb6aa7875)}, + {TOBN(0x7f78c19c, 0x5450d866), TOBN(0x46f4409c, 0x8f84a481), + TOBN(0x9f1d1928, 0x90fce239), TOBN(0x016c4168, 0xb2ce44b9)}}, + {{TOBN(0xbae023f0, 0xc7435978), TOBN(0xb152c888, 0x20e30e19), + TOBN(0x9c241645, 0xe3fa6faf), TOBN(0x735d95c1, 0x84823e60)}, + {TOBN(0x03197573, 0x03955317), TOBN(0x0b4b02a9, 0xf03b4995), + TOBN(0x076bf559, 0x70274600), TOBN(0x32c5cc53, 0xaaf57508)}}, + {{TOBN(0xe8af6d1f, 0x60624129), TOBN(0xb7bc5d64, 0x9a5e2b5e), + TOBN(0x3814b048, 0x5f082d72), TOBN(0x76f267f2, 0xce19677a)}, + {TOBN(0x626c630f, 0xb36eed93), TOBN(0x55230cd7, 0x3bf56803), + TOBN(0x78837949, 0xce2736a0), TOBN(0x0d792d60, 0xaa6c55f1)}}, + {{TOBN(0x0318dbfd, 0xd5c7c5d2), TOBN(0xb38f8da7, 0x072b342d), + TOBN(0x3569bddc, 0x7b8de38a), TOBN(0xf25b5887, 0xa1c94842)}, + {TOBN(0xb2d5b284, 0x2946ad60), TOBN(0x854f29ad, 0xe9d1707e), + TOBN(0xaa5159dc, 0x2c6a4509), TOBN(0x899f94c0, 0x57189837)}}, + {{TOBN(0xcf6adc51, 0xf4a55b03), TOBN(0x261762de, 0x35e3b2d5), + TOBN(0x4cc43012, 0x04827b51), TOBN(0xcd22a113, 0xc6021442)}, + {TOBN(0xce2fd61a, 0x247c9569), TOBN(0x59a50973, 0xd152beca), + TOBN(0x6c835a11, 0x63a716d4), TOBN(0xc26455ed, 0x187dedcf)}}, + {{TOBN(0x27f536e0, 0x49ce89e7), TOBN(0x18908539, 0xcc890cb5), + TOBN(0x308909ab, 0xd83c2aa1), TOBN(0xecd3142b, 0x1ab73bd3)}, + {TOBN(0x6a85bf59, 0xb3f5ab84), TOBN(0x3c320a68, 0xf2bea4c6), + TOBN(0xad8dc538, 0x6da4541f), TOBN(0xeaf34eb0, 0xb7c41186)}}, + {{TOBN(0x1c780129, 0x977c97c4), TOBN(0x5ff9beeb, 0xc57eb9fa), + TOBN(0xa24d0524, 0xc822c478), TOBN(0xfd8eec2a, 0x461cd415)}, + {TOBN(0xfbde194e, 0xf027458c), TOBN(0xb4ff5319, 0x1d1be115), + TOBN(0x63f874d9, 0x4866d6f4), TOBN(0x35c75015, 0xb21ad0c9)}}, + {{TOBN(0xa6b5c9d6, 0x46ac49d2), TOBN(0x42c77c0b, 0x83137aa9), + TOBN(0x24d000fc, 0x68225a38), TOBN(0x0f63cfc8, 0x2fe1e907)}, + {TOBN(0x22d1b01b, 0xc6441f95), TOBN(0x7d38f719, 0xec8e448f), + TOBN(0x9b33fa5f, 0x787fb1ba), TOBN(0x94dcfda1, 0x190158df)}}, + {{TOBN(0xc47cb339, 0x5f6d4a09), TOBN(0x6b4f355c, 0xee52b826), + TOBN(0x3d100f5d, 0xf51b930a), TOBN(0xf4512fac, 0x9f668f69)}, + {TOBN(0x546781d5, 0x206c4c74), TOBN(0xd021d4d4, 0xcb4d2e48), + TOBN(0x494a54c2, 0xca085c2d), TOBN(0xf1dbaca4, 0x520850a8)}}, + {{TOBN(0x63c79326, 0x490a1aca), TOBN(0xcb64dd9c, 0x41526b02), + TOBN(0xbb772591, 0xa2979258), TOBN(0x3f582970, 0x48d97846)}, + {TOBN(0xd66b70d1, 0x7c213ba7), TOBN(0xc28febb5, 0xe8a0ced4), + TOBN(0x6b911831, 0xc10338c1), TOBN(0x0d54e389, 0xbf0126f3)}}, + {{TOBN(0x7048d460, 0x4af206ee), TOBN(0x786c88f6, 0x77e97cb9), + TOBN(0xd4375ae1, 0xac64802e), TOBN(0x469bcfe1, 0xd53ec11c)}, + {TOBN(0xfc9b340d, 0x47062230), TOBN(0xe743bb57, 0xc5b4a3ac), + TOBN(0xfe00b4aa, 0x59ef45ac), TOBN(0x29a4ef23, 0x59edf188)}}, + {{TOBN(0x40242efe, 0xb483689b), TOBN(0x2575d3f6, 0x513ac262), + TOBN(0xf30037c8, 0x0ca6db72), TOBN(0xc9fcce82, 0x98864be2)}, + {TOBN(0x84a112ff, 0x0149362d), TOBN(0x95e57582, 0x1c4ae971), + TOBN(0x1fa4b1a8, 0x945cf86c), TOBN(0x4525a734, 0x0b024a2f)}}, + {{TOBN(0xe76c8b62, 0x8f338360), TOBN(0x483ff593, 0x28edf32b), + TOBN(0x67e8e90a, 0x298b1aec), TOBN(0x9caab338, 0x736d9a21)}, + {TOBN(0x5c09d2fd, 0x66892709), TOBN(0x2496b4dc, 0xb55a1d41), + TOBN(0x93f5fb1a, 0xe24a4394), TOBN(0x08c75049, 0x6fa8f6c1)}}, + {{TOBN(0xcaead1c2, 0xc905d85f), TOBN(0xe9d7f790, 0x0733ae57), + TOBN(0x24c9a65c, 0xf07cdd94), TOBN(0x7389359c, 0xa4b55931)}, + {TOBN(0xf58709b7, 0x367e45f7), TOBN(0x1f203067, 0xcb7e7adc), + TOBN(0x82444bff, 0xc7b72818), TOBN(0x07303b35, 0xbaac8033)}}, + {{TOBN(0x1e1ee4e4, 0xd13b7ea1), TOBN(0xe6489b24, 0xe0e74180), + TOBN(0xa5f2c610, 0x7e70ef70), TOBN(0xa1655412, 0xbdd10894)}, + {TOBN(0x555ebefb, 0x7af4194e), TOBN(0x533c1c3c, 0x8e89bd9c), + TOBN(0x735b9b57, 0x89895856), TOBN(0x15fb3cd2, 0x567f5c15)}}, + {{TOBN(0x057fed45, 0x526f09fd), TOBN(0xe8a4f10c, 0x8128240a), + TOBN(0x9332efc4, 0xff2bfd8d), TOBN(0x214e77a0, 0xbd35aa31)}, + {TOBN(0x32896d73, 0x14faa40e), TOBN(0x767867ec, 0x01e5f186), + TOBN(0xc9adf8f1, 0x17a1813e), TOBN(0xcb6cda78, 0x54741795)}}, + {{TOBN(0xb7521b6d, 0x349d51aa), TOBN(0xf56b5a9e, 0xe3c7b8e9), + TOBN(0xc6f1e5c9, 0x32a096df), TOBN(0x083667c4, 0xa3635024)}, + {TOBN(0x365ea135, 0x18087f2f), TOBN(0xf1b8eaac, 0xd136e45d), + TOBN(0xc8a0e484, 0x73aec989), TOBN(0xd75a324b, 0x142c9259)}}, + {{TOBN(0xb7b4d001, 0x01dae185), TOBN(0x45434e0b, 0x9b7a94bc), + TOBN(0xf54339af, 0xfbd8cb0b), TOBN(0xdcc4569e, 0xe98ef49e)}, + {TOBN(0x7789318a, 0x09a51299), TOBN(0x81b4d206, 0xb2b025d8), + TOBN(0xf64aa418, 0xfae85792), TOBN(0x3e50258f, 0xacd7baf7)}}, + {{TOBN(0xdce84cdb, 0x2996864b), TOBN(0xa2e67089, 0x1f485fa4), + TOBN(0xb28b2bb6, 0x534c6a5a), TOBN(0x31a7ec6b, 0xc94b9d39)}, + {TOBN(0x1d217766, 0xd6bc20da), TOBN(0x4acdb5ec, 0x86761190), + TOBN(0x68726328, 0x73701063), TOBN(0x4d24ee7c, 0x2128c29b)}}, + {{TOBN(0xc072ebd3, 0xa19fd868), TOBN(0x612e481c, 0xdb8ddd3b), + TOBN(0xb4e1d754, 0x1a64d852), TOBN(0x00ef95ac, 0xc4c6c4ab)}, + {TOBN(0x1536d2ed, 0xaa0a6c46), TOBN(0x61294086, 0x43774790), + TOBN(0x54af25e8, 0x343fda10), TOBN(0x9ff9d98d, 0xfd25d6f2)}}, + {{TOBN(0x0746af7c, 0x468b8835), TOBN(0x977a31cb, 0x730ecea7), + TOBN(0xa5096b80, 0xc2cf4a81), TOBN(0xaa986833, 0x6458c37a)}, + {TOBN(0x6af29bf3, 0xa6bd9d34), TOBN(0x6a62fe9b, 0x33c5d854), + TOBN(0x50e6c304, 0xb7133b5e), TOBN(0x04b60159, 0x7d6e6848)}}, + {{TOBN(0x4cd296df, 0x5579bea4), TOBN(0x10e35ac8, 0x5ceedaf1), + TOBN(0x04c4c5fd, 0xe3bcc5b1), TOBN(0x95f9ee8a, 0x89412cf9)}, + {TOBN(0x2c9459ee, 0x82b6eb0f), TOBN(0x2e845765, 0x95c2aadd), + TOBN(0x774a84ae, 0xd327fcfe), TOBN(0xd8c93722, 0x0368d476)}}, + {{TOBN(0x0dbd5748, 0xf83e8a3b), TOBN(0xa579aa96, 0x8d2495f3), + TOBN(0x535996a0, 0xae496e9b), TOBN(0x07afbfe9, 0xb7f9bcc2)}, + {TOBN(0x3ac1dc6d, 0x5b7bd293), TOBN(0x3b592cff, 0x7022323d), + TOBN(0xba0deb98, 0x9c0a3e76), TOBN(0x18e78e9f, 0x4b197acb)}}, + {{TOBN(0x211cde10, 0x296c36ef), TOBN(0x7ee89672, 0x82c4da77), + TOBN(0xb617d270, 0xa57836da), TOBN(0xf0cd9c31, 0x9cb7560b)}, + {TOBN(0x01fdcbf7, 0xe455fe90), TOBN(0x3fb53cbb, 0x7e7334f3), + TOBN(0x781e2ea4, 0x4e7de4ec), TOBN(0x8adab3ad, 0x0b384fd0)}}, + {{TOBN(0x129eee2f, 0x53d64829), TOBN(0x7a471e17, 0xa261492b), + TOBN(0xe4f9adb9, 0xe4cb4a2c), TOBN(0x3d359f6f, 0x97ba2c2d)}, + {TOBN(0x346c6786, 0x0aacd697), TOBN(0x92b444c3, 0x75c2f8a8), + TOBN(0xc79fa117, 0xd85df44e), TOBN(0x56782372, 0x398ddf31)}}, + {{TOBN(0x60e690f2, 0xbbbab3b8), TOBN(0x4851f8ae, 0x8b04816b), + TOBN(0xc72046ab, 0x9c92e4d2), TOBN(0x518c74a1, 0x7cf3136b)}, + {TOBN(0xff4eb50a, 0xf9877d4c), TOBN(0x14578d90, 0xa919cabb), + TOBN(0x8218f8c4, 0xac5eb2b6), TOBN(0xa3ccc547, 0x542016e4)}}, + {{TOBN(0x025bf48e, 0x327f8349), TOBN(0xf3e97346, 0xf43cb641), + TOBN(0xdc2bafdf, 0x500f1085), TOBN(0x57167876, 0x2f063055)}, + {TOBN(0x5bd914b9, 0x411925a6), TOBN(0x7c078d48, 0xa1123de5), + TOBN(0xee6bf835, 0x182b165d), TOBN(0xb11b5e5b, 0xba519727)}}, + {{TOBN(0xe33ea76c, 0x1eea7b85), TOBN(0x2352b461, 0x92d4f85e), + TOBN(0xf101d334, 0xafe115bb), TOBN(0xfabc1294, 0x889175a3)}, + {TOBN(0x7f6bcdc0, 0x5233f925), TOBN(0xe0a802db, 0xe77fec55), + TOBN(0xbdb47b75, 0x8069b659), TOBN(0x1c5e12de, 0xf98fbd74)}}, + {{TOBN(0x869c58c6, 0x4b8457ee), TOBN(0xa5360f69, 0x4f7ea9f7), + TOBN(0xe576c09f, 0xf460b38f), TOBN(0x6b70d548, 0x22b7fb36)}, + {TOBN(0x3fd237f1, 0x3bfae315), TOBN(0x33797852, 0xcbdff369), + TOBN(0x97df25f5, 0x25b516f9), TOBN(0x46f388f2, 0xba38ad2d)}}, + {{TOBN(0x656c4658, 0x89d8ddbb), TOBN(0x8830b26e, 0x70f38ee8), + TOBN(0x4320fd5c, 0xde1212b0), TOBN(0xc34f30cf, 0xe4a2edb2)}, + {TOBN(0xabb131a3, 0x56ab64b8), TOBN(0x7f77f0cc, 0xd99c5d26), + TOBN(0x66856a37, 0xbf981d94), TOBN(0x19e76d09, 0x738bd76e)}}, + {{TOBN(0xe76c8ac3, 0x96238f39), TOBN(0xc0a482be, 0xa830b366), + TOBN(0xb7b8eaff, 0x0b4eb499), TOBN(0x8ecd83bc, 0x4bfb4865)}, + {TOBN(0x971b2cb7, 0xa2f3776f), TOBN(0xb42176a4, 0xf4b88adf), + TOBN(0xb9617df5, 0xbe1fa446), TOBN(0x8b32d508, 0xcd031bd2)}}, + {{TOBN(0x1c6bd47d, 0x53b618c0), TOBN(0xc424f46c, 0x6a227923), + TOBN(0x7303ffde, 0xdd92d964), TOBN(0xe9712878, 0x71b5abf2)}, + {TOBN(0x8f48a632, 0xf815561d), TOBN(0x85f48ff5, 0xd3c055d1), + TOBN(0x222a1427, 0x7525684f), TOBN(0xd0d841a0, 0x67360cc3)}}, + {{TOBN(0x4245a926, 0x0b9267c6), TOBN(0xc78913f1, 0xcf07f863), + TOBN(0xaa844c8e, 0x4d0d9e24), TOBN(0xa42ad522, 0x3d5f9017)}, + {TOBN(0xbd371749, 0xa2c989d5), TOBN(0x928292df, 0xe1f5e78e), + TOBN(0x493b383e, 0x0a1ea6da), TOBN(0x5136fd8d, 0x13aee529)}}, + {{TOBN(0x860c44b1, 0xf2c34a99), TOBN(0x3b00aca4, 0xbf5855ac), + TOBN(0xabf6aaa0, 0xfaaf37be), TOBN(0x65f43682, 0x2a53ec08)}, + {TOBN(0x1d9a5801, 0xa11b12e1), TOBN(0x78a7ab2c, 0xe20ed475), + TOBN(0x0de1067e, 0x9a41e0d5), TOBN(0x30473f5f, 0x305023ea)}}, + {{TOBN(0xdd3ae09d, 0x169c7d97), TOBN(0x5cd5baa4, 0xcfaef9cd), + TOBN(0x5cd7440b, 0x65a44803), TOBN(0xdc13966a, 0x47f364de)}, + {TOBN(0x077b2be8, 0x2b8357c1), TOBN(0x0cb1b4c5, 0xe9d57c2a), + TOBN(0x7a4ceb32, 0x05ff363e), TOBN(0xf310fa4d, 0xca35a9ef)}}, + {{TOBN(0xdbb7b352, 0xf97f68c6), TOBN(0x0c773b50, 0x0b02cf58), + TOBN(0xea2e4821, 0x3c1f96d9), TOBN(0xffb357b0, 0xeee01815)}, + {TOBN(0xb9c924cd, 0xe0f28039), TOBN(0x0b36c95a, 0x46a3fbe4), + TOBN(0x1faaaea4, 0x5e46db6c), TOBN(0xcae575c3, 0x1928aaff)}}, + {{TOBN(0x7f671302, 0xa70dab86), TOBN(0xfcbd12a9, 0x71c58cfc), + TOBN(0xcbef9acf, 0xbee0cb92), TOBN(0x573da0b9, 0xf8c1b583)}, + {TOBN(0x4752fcfe, 0x0d41d550), TOBN(0xe7eec0e3, 0x2155cffe), + TOBN(0x0fc39fcb, 0x545ae248), TOBN(0x522cb8d1, 0x8065f44e)}}, + {{TOBN(0x263c962a, 0x70cbb96c), TOBN(0xe034362a, 0xbcd124a9), + TOBN(0xf120db28, 0x3c2ae58d), TOBN(0xb9a38d49, 0xfef6d507)}, + {TOBN(0xb1fd2a82, 0x1ff140fd), TOBN(0xbd162f30, 0x20aee7e0), + TOBN(0x4e17a5d4, 0xcb251949), TOBN(0x2aebcb83, 0x4f7e1c3d)}}, + {{TOBN(0x608eb25f, 0x937b0527), TOBN(0xf42e1e47, 0xeb7d9997), + TOBN(0xeba699c4, 0xb8a53a29), TOBN(0x1f921c71, 0xe091b536)}, + {TOBN(0xcce29e7b, 0x5b26bbd5), TOBN(0x7a8ef5ed, 0x3b61a680), + TOBN(0xe5ef8043, 0xba1f1c7e), TOBN(0x16ea8217, 0x18158dda)}}, + {{TOBN(0x01778a2b, 0x599ff0f9), TOBN(0x68a923d7, 0x8104fc6b), + TOBN(0x5bfa44df, 0xda694ff3), TOBN(0x4f7199db, 0xf7667f12)}, + {TOBN(0xc06d8ff6, 0xe46f2a79), TOBN(0x08b5dead, 0xe9f8131d), + TOBN(0x02519a59, 0xabb4ce7c), TOBN(0xc4f710bc, 0xb42aec3e)}}, + {{TOBN(0x3d77b057, 0x78bde41a), TOBN(0x6474bf80, 0xb4186b5a), + TOBN(0x048b3f67, 0x88c65741), TOBN(0xc64519de, 0x03c7c154)}, + {TOBN(0xdf073846, 0x0edfcc4f), TOBN(0x319aa737, 0x48f1aa6b), + TOBN(0x8b9f8a02, 0xca909f77), TOBN(0x90258139, 0x7580bfef)}}, + {{TOBN(0xd8bfd3ca, 0xc0c22719), TOBN(0xc60209e4, 0xc9ca151e), + TOBN(0x7a744ab5, 0xd9a1a69c), TOBN(0x6de5048b, 0x14937f8f)}, + {TOBN(0x171938d8, 0xe115ac04), TOBN(0x7df70940, 0x1c6b16d2), + TOBN(0xa6aeb663, 0x7f8e94e7), TOBN(0xc130388e, 0x2a2cf094)}}, + {{TOBN(0x1850be84, 0x77f54e6e), TOBN(0x9f258a72, 0x65d60fe5), + TOBN(0xff7ff0c0, 0x6c9146d6), TOBN(0x039aaf90, 0xe63a830b)}, + {TOBN(0x38f27a73, 0x9460342f), TOBN(0x4703148c, 0x3f795f8a), + TOBN(0x1bb5467b, 0x9681a97e), TOBN(0x00931ba5, 0xecaeb594)}}, + {{TOBN(0xcdb6719d, 0x786f337c), TOBN(0xd9c01cd2, 0xe704397d), + TOBN(0x0f4a3f20, 0x555c2fef), TOBN(0x00452509, 0x7c0af223)}, + {TOBN(0x54a58047, 0x84db8e76), TOBN(0x3bacf1aa, 0x93c8aa06), + TOBN(0x11ca957c, 0xf7919422), TOBN(0x50641053, 0x78cdaa40)}}, + {{TOBN(0x7a303874, 0x9f7144ae), TOBN(0x170c963f, 0x43d4acfd), + TOBN(0x5e148149, 0x58ddd3ef), TOBN(0xa7bde582, 0x9e72dba8)}, + {TOBN(0x0769da8b, 0x6fa68750), TOBN(0xfa64e532, 0x572e0249), + TOBN(0xfcaadf9d, 0x2619ad31), TOBN(0x87882daa, 0xa7b349cd)}}, + {{TOBN(0x9f6eb731, 0x6c67a775), TOBN(0xcb10471a, 0xefc5d0b1), + TOBN(0xb433750c, 0xe1b806b2), TOBN(0x19c5714d, 0x57b1ae7e)}, + {TOBN(0xc0dc8b7b, 0xed03fd3f), TOBN(0xdd03344f, 0x31bc194e), + TOBN(0xa66c52a7, 0x8c6320b5), TOBN(0x8bc82ce3, 0xd0b6fd93)}}, + {{TOBN(0xf8e13501, 0xb35f1341), TOBN(0xe53156dd, 0x25a43e42), + TOBN(0xd3adf27e, 0x4daeb85c), TOBN(0xb81d8379, 0xbbeddeb5)}, + {TOBN(0x1b0b546e, 0x2e435867), TOBN(0x9020eb94, 0xeba5dd60), + TOBN(0x37d91161, 0x8210cb9d), TOBN(0x4c596b31, 0x5c91f1cf)}}, + {{TOBN(0xb228a90f, 0x0e0b040d), TOBN(0xbaf02d82, 0x45ff897f), + TOBN(0x2aac79e6, 0x00fa6122), TOBN(0x24828817, 0x8e36f557)}, + {TOBN(0xb9521d31, 0x113ec356), TOBN(0x9e48861e, 0x15eff1f8), + TOBN(0x2aa1d412, 0xe0d41715), TOBN(0x71f86203, 0x53f131b8)}}, + {{TOBN(0xf60da8da, 0x3fd19408), TOBN(0x4aa716dc, 0x278d9d99), + TOBN(0x394531f7, 0xa8c51c90), TOBN(0xb560b0e8, 0xf59db51c)}, + {TOBN(0xa28fc992, 0xfa34bdad), TOBN(0xf024fa14, 0x9cd4f8bd), + TOBN(0x5cf530f7, 0x23a9d0d3), TOBN(0x615ca193, 0xe28c9b56)}}, + {{TOBN(0x6d2a483d, 0x6f73c51e), TOBN(0xa4cb2412, 0xea0dc2dd), + TOBN(0x50663c41, 0x1eb917ff), TOBN(0x3d3a74cf, 0xeade299e)}, + {TOBN(0x29b3990f, 0x4a7a9202), TOBN(0xa9bccf59, 0xa7b15c3d), + TOBN(0x66a3ccdc, 0xa5df9208), TOBN(0x48027c14, 0x43f2f929)}}, + {{TOBN(0xd385377c, 0x40b557f0), TOBN(0xe001c366, 0xcd684660), + TOBN(0x1b18ed6b, 0xe2183a27), TOBN(0x879738d8, 0x63210329)}, + {TOBN(0xa687c74b, 0xbda94882), TOBN(0xd1bbcc48, 0xa684b299), + TOBN(0xaf6f1112, 0x863b3724), TOBN(0x6943d1b4, 0x2c8ce9f8)}}, + {{TOBN(0xe044a3bb, 0x098cafb4), TOBN(0x27ed2310, 0x60d48caf), + TOBN(0x542b5675, 0x3a31b84d), TOBN(0xcbf3dd50, 0xfcddbed7)}, + {TOBN(0x25031f16, 0x41b1d830), TOBN(0xa7ec851d, 0xcb0c1e27), + TOBN(0xac1c8fe0, 0xb5ae75db), TOBN(0xb24c7557, 0x08c52120)}}, + {{TOBN(0x57f811dc, 0x1d4636c3), TOBN(0xf8436526, 0x681a9939), + TOBN(0x1f6bc6d9, 0x9c81adb3), TOBN(0x840f8ac3, 0x5b7d80d4)}, + {TOBN(0x731a9811, 0xf4387f1a), TOBN(0x7c501cd3, 0xb5156880), + TOBN(0xa5ca4a07, 0xdfe68867), TOBN(0xf123d8f0, 0x5fcea120)}}, + {{TOBN(0x1fbb0e71, 0xd607039e), TOBN(0x2b70e215, 0xcd3a4546), + TOBN(0x32d2f01d, 0x53324091), TOBN(0xb796ff08, 0x180ab19b)}, + {TOBN(0x32d87a86, 0x3c57c4aa), TOBN(0x2aed9caf, 0xb7c49a27), + TOBN(0x9fb35eac, 0x31630d98), TOBN(0x338e8cdf, 0x5c3e20a3)}}, + {{TOBN(0x80f16182, 0x66cde8db), TOBN(0x4e159980, 0x2d72fd36), + TOBN(0xd7b8f13b, 0x9b6e5072), TOBN(0xf5213907, 0x3b7b5dc1)}, + {TOBN(0x4d431f1d, 0x8ce4396e), TOBN(0x37a1a680, 0xa7ed2142), + TOBN(0xbf375696, 0xd01aaf6b), TOBN(0xaa1c0c54, 0xe63aab66)}}, + {{TOBN(0x3014368b, 0x4ed80940), TOBN(0x67e6d056, 0x7a6fcedd), + TOBN(0x7c208c49, 0xca97579f), TOBN(0xfe3d7a81, 0xa23597f6)}, + {TOBN(0x5e203202, 0x7e096ae2), TOBN(0xb1f3e1e7, 0x24b39366), + TOBN(0x26da26f3, 0x2fdcdffc), TOBN(0x79422f1d, 0x6097be83)}}}, + {{{TOBN(0x263a2cfb, 0x9db3b381), TOBN(0x9c3a2dee, 0xd4df0a4b), + TOBN(0x728d06e9, 0x7d04e61f), TOBN(0x8b1adfbc, 0x42449325)}, + {TOBN(0x6ec1d939, 0x7e053a1b), TOBN(0xee2be5c7, 0x66daf707), + TOBN(0x80ba1e14, 0x810ac7ab), TOBN(0xdd2ae778, 0xf530f174)}}, + {{TOBN(0x0435d97a, 0x205b9d8b), TOBN(0x6eb8f064, 0x056756d4), + TOBN(0xd5e88a8b, 0xb6f8210e), TOBN(0x070ef12d, 0xec9fd9ea)}, + {TOBN(0x4d849505, 0x3bcc876a), TOBN(0x12a75338, 0xa7404ce3), + TOBN(0xd22b49e1, 0xb8a1db5e), TOBN(0xec1f2051, 0x14bfa5ad)}}, + {{TOBN(0xadbaeb79, 0xb6828f36), TOBN(0x9d7a0258, 0x01bd5b9e), + TOBN(0xeda01e0d, 0x1e844b0c), TOBN(0x4b625175, 0x887edfc9)}, + {TOBN(0x14109fdd, 0x9669b621), TOBN(0x88a2ca56, 0xf6f87b98), + TOBN(0xfe2eb788, 0x170df6bc), TOBN(0x0cea06f4, 0xffa473f9)}}, + {{TOBN(0x43ed81b5, 0xc4e83d33), TOBN(0xd9f35879, 0x5efd488b), + TOBN(0x164a620f, 0x9deb4d0f), TOBN(0xc6927bdb, 0xac6a7394)}, + {TOBN(0x45c28df7, 0x9f9e0f03), TOBN(0x2868661e, 0xfcd7e1a9), + TOBN(0x7cf4e8d0, 0xffa348f1), TOBN(0x6bd4c284, 0x398538e0)}}, + {{TOBN(0x2618a091, 0x289a8619), TOBN(0xef796e60, 0x6671b173), + TOBN(0x664e46e5, 0x9090c632), TOBN(0xa38062d4, 0x1e66f8fb)}, + {TOBN(0x6c744a20, 0x0573274e), TOBN(0xd07b67e4, 0xa9271394), + TOBN(0x391223b2, 0x6bdc0e20), TOBN(0xbe2d93f1, 0xeb0a05a7)}}, + {{TOBN(0xf23e2e53, 0x3f36d141), TOBN(0xe84bb3d4, 0x4dfca442), + TOBN(0xb804a48d, 0x6b7c023a), TOBN(0x1e16a8fa, 0x76431c3b)}, + {TOBN(0x1b5452ad, 0xddd472e0), TOBN(0x7d405ee7, 0x0d1ee127), + TOBN(0x50fc6f1d, 0xffa27599), TOBN(0x351ac53c, 0xbf391b35)}}, + {{TOBN(0x7efa14b8, 0x4444896b), TOBN(0x64974d2f, 0xf94027fb), + TOBN(0xefdcd0e8, 0xde84487d), TOBN(0x8c45b260, 0x2b48989b)}, + {TOBN(0xa8fcbbc2, 0xd8463487), TOBN(0xd1b2b3f7, 0x3fbc476c), + TOBN(0x21d005b7, 0xc8f443c0), TOBN(0x518f2e67, 0x40c0139c)}}, + {{TOBN(0x56036e8c, 0x06d75fc1), TOBN(0x2dcf7bb7, 0x3249a89f), + TOBN(0x81dd1d3d, 0xe245e7dd), TOBN(0xf578dc4b, 0xebd6e2a7)}, + {TOBN(0x4c028903, 0xdf2ce7a0), TOBN(0xaee36288, 0x9c39afac), + TOBN(0xdc847c31, 0x146404ab), TOBN(0x6304c0d8, 0xa4e97818)}}, + {{TOBN(0xae51dca2, 0xa91f6791), TOBN(0x2abe4190, 0x9baa9efc), + TOBN(0xd9d2e2f4, 0x559c7ac1), TOBN(0xe82f4b51, 0xfc9f773a)}, + {TOBN(0xa7713027, 0x4073e81c), TOBN(0xc0276fac, 0xfbb596fc), + TOBN(0x1d819fc9, 0xa684f70c), TOBN(0x29b47fdd, 0xc9f7b1e0)}}, + {{TOBN(0x358de103, 0x459b1940), TOBN(0xec881c59, 0x5b013e93), + TOBN(0x51574c93, 0x49532ad3), TOBN(0x2db1d445, 0xb37b46de)}, + {TOBN(0xc6445b87, 0xdf239fd8), TOBN(0xc718af75, 0x151d24ee), + TOBN(0xaea1c4a4, 0xf43c6259), TOBN(0x40c0e5d7, 0x70be02f7)}}, + {{TOBN(0x6a4590f4, 0x721b33f2), TOBN(0x2124f1fb, 0xfedf04ea), + TOBN(0xf8e53cde, 0x9745efe7), TOBN(0xe7e10432, 0x65f046d9)}, + {TOBN(0xc3fca28e, 0xe4d0c7e6), TOBN(0x847e339a, 0x87253b1b), + TOBN(0x9b595348, 0x3743e643), TOBN(0xcb6a0a0b, 0x4fd12fc5)}}, + {{TOBN(0xfb6836c3, 0x27d02dcc), TOBN(0x5ad00982, 0x7a68bcc2), + TOBN(0x1b24b44c, 0x005e912d), TOBN(0xcc83d20f, 0x811fdcfe)}, + {TOBN(0x36527ec1, 0x666fba0c), TOBN(0x69948197, 0x14754635), + TOBN(0xfcdcb1a8, 0x556da9c2), TOBN(0xa5934267, 0x81a732b2)}}, + {{TOBN(0xec1214ed, 0xa714181d), TOBN(0x609ac13b, 0x6067b341), + TOBN(0xff4b4c97, 0xa545df1f), TOBN(0xa1240501, 0x34d2076b)}, + {TOBN(0x6efa0c23, 0x1409ca97), TOBN(0x254cc1a8, 0x20638c43), + TOBN(0xd4e363af, 0xdcfb46cd), TOBN(0x62c2adc3, 0x03942a27)}}, + {{TOBN(0xc67b9df0, 0x56e46483), TOBN(0xa55abb20, 0x63736356), + TOBN(0xab93c098, 0xc551bc52), TOBN(0x382b49f9, 0xb15fe64b)}, + {TOBN(0x9ec221ad, 0x4dff8d47), TOBN(0x79caf615, 0x437df4d6), + TOBN(0x5f13dc64, 0xbb456509), TOBN(0xe4c589d9, 0x191f0714)}}, + {{TOBN(0x27b6a8ab, 0x3fd40e09), TOBN(0xe455842e, 0x77313ea9), + TOBN(0x8b51d1e2, 0x1f55988b), TOBN(0x5716dd73, 0x062bbbfc)}, + {TOBN(0x633c11e5, 0x4e8bf3de), TOBN(0x9a0e77b6, 0x1b85be3b), + TOBN(0x56510729, 0x0911cca6), TOBN(0x27e76495, 0xefa6590f)}}, + {{TOBN(0xe4ac8b33, 0x070d3aab), TOBN(0x2643672b, 0x9a2cd5e5), + TOBN(0x52eff79b, 0x1cfc9173), TOBN(0x665ca49b, 0x90a7c13f)}, + {TOBN(0x5a8dda59, 0xb3efb998), TOBN(0x8a5b922d, 0x052f1341), + TOBN(0xae9ebbab, 0x3cf9a530), TOBN(0x35986e7b, 0xf56da4d7)}}, + {{TOBN(0x3a636b5c, 0xff3513cc), TOBN(0xbb0cf8ba, 0x3198f7dd), + TOBN(0xb8d40522, 0x41f16f86), TOBN(0x760575d8, 0xde13a7bf)}, + {TOBN(0x36f74e16, 0x9f7aa181), TOBN(0x163a3ecf, 0xf509ed1c), + TOBN(0x6aead61f, 0x3c40a491), TOBN(0x158c95fc, 0xdfe8fcaa)}}, + {{TOBN(0xa3991b6e, 0x13cda46f), TOBN(0x79482415, 0x342faed0), + TOBN(0xf3ba5bde, 0x666b5970), TOBN(0x1d52e6bc, 0xb26ab6dd)}, + {TOBN(0x768ba1e7, 0x8608dd3d), TOBN(0x4930db2a, 0xea076586), + TOBN(0xd9575714, 0xe7dc1afa), TOBN(0x1fc7bf7d, 0xf7c58817)}}, + {{TOBN(0x6b47accd, 0xd9eee96c), TOBN(0x0ca277fb, 0xe58cec37), + TOBN(0x113fe413, 0xe702c42a), TOBN(0xdd1764ee, 0xc47cbe51)}, + {TOBN(0x041e7cde, 0x7b3ed739), TOBN(0x50cb7459, 0x5ce9e1c0), + TOBN(0x35568513, 0x2925b212), TOBN(0x7cff95c4, 0x001b081c)}}, + {{TOBN(0x63ee4cbd, 0x8088b454), TOBN(0xdb7f32f7, 0x9a9e0c8a), + TOBN(0xb377d418, 0x6b2447cb), TOBN(0xe3e982aa, 0xd370219b)}, + {TOBN(0x06ccc1e4, 0xc2a2a593), TOBN(0x72c36865, 0x0773f24f), + TOBN(0xa13b4da7, 0x95859423), TOBN(0x8bbf1d33, 0x75040c8f)}}, + {{TOBN(0x726f0973, 0xda50c991), TOBN(0x48afcd5b, 0x822d6ee2), + TOBN(0xe5fc718b, 0x20fd7771), TOBN(0xb9e8e77d, 0xfd0807a1)}, + {TOBN(0x7f5e0f44, 0x99a7703d), TOBN(0x6972930e, 0x618e36f3), + TOBN(0x2b7c77b8, 0x23807bbe), TOBN(0xe5b82405, 0xcb27ff50)}}, + {{TOBN(0xba8b8be3, 0xbd379062), TOBN(0xd64b7a1d, 0x2dce4a92), + TOBN(0x040a73c5, 0xb2952e37), TOBN(0x0a9e252e, 0xd438aeca)}, + {TOBN(0xdd43956b, 0xc39d3bcb), TOBN(0x1a31ca00, 0xb32b2d63), + TOBN(0xd67133b8, 0x5c417a18), TOBN(0xd08e4790, 0x2ef442c8)}}, + {{TOBN(0x98cb1ae9, 0x255c0980), TOBN(0x4bd86381, 0x2b4a739f), + TOBN(0x5a5c31e1, 0x1e4a45a1), TOBN(0x1e5d55fe, 0x9cb0db2f)}, + {TOBN(0x74661b06, 0x8ff5cc29), TOBN(0x026b389f, 0x0eb8a4f4), + TOBN(0x536b21a4, 0x58848c24), TOBN(0x2e5bf8ec, 0x81dc72b0)}}, + {{TOBN(0x03c187d0, 0xad886aac), TOBN(0x5c16878a, 0xb771b645), + TOBN(0xb07dfc6f, 0xc74045ab), TOBN(0x2c6360bf, 0x7800caed)}, + {TOBN(0x24295bb5, 0xb9c972a3), TOBN(0xc9e6f88e, 0x7c9a6dba), + TOBN(0x90ffbf24, 0x92a79aa6), TOBN(0xde29d50a, 0x41c26ac2)}}, + {{TOBN(0x9f0af483, 0xd309cbe6), TOBN(0x5b020d8a, 0xe0bced4f), + TOBN(0x606e986d, 0xb38023e3), TOBN(0xad8f2c9d, 0x1abc6933)}, + {TOBN(0x19292e1d, 0xe7400e93), TOBN(0xfe3e18a9, 0x52be5e4d), + TOBN(0xe8e9771d, 0x2e0680bf), TOBN(0x8c5bec98, 0xc54db063)}}, + {{TOBN(0x2af9662a, 0x74a55d1f), TOBN(0xe3fbf28f, 0x046f66d8), + TOBN(0xa3a72ab4, 0xd4dc4794), TOBN(0x09779f45, 0x5c7c2dd8)}, + {TOBN(0xd893bdaf, 0xc3d19d8d), TOBN(0xd5a75094, 0x57d6a6df), + TOBN(0x8cf8fef9, 0x952e6255), TOBN(0x3da67cfb, 0xda9a8aff)}}, + {{TOBN(0x4c23f62a, 0x2c160dcd), TOBN(0x34e6c5e3, 0x8f90eaef), + TOBN(0x35865519, 0xa9a65d5a), TOBN(0x07c48aae, 0x8fd38a3d)}, + {TOBN(0xb7e7aeda, 0x50068527), TOBN(0x2c09ef23, 0x1c90936a), + TOBN(0x31ecfeb6, 0xe879324c), TOBN(0xa0871f6b, 0xfb0ec938)}}, + {{TOBN(0xb1f0fb68, 0xd84d835d), TOBN(0xc90caf39, 0x861dc1e6), + TOBN(0x12e5b046, 0x7594f8d7), TOBN(0x26897ae2, 0x65012b92)}, + {TOBN(0xbcf68a08, 0xa4d6755d), TOBN(0x403ee41c, 0x0991fbda), + TOBN(0x733e343e, 0x3bbf17e8), TOBN(0xd2c7980d, 0x679b3d65)}}, + {{TOBN(0x33056232, 0xd2e11305), TOBN(0x966be492, 0xf3c07a6f), + TOBN(0x6a8878ff, 0xbb15509d), TOBN(0xff221101, 0x0a9b59a4)}, + {TOBN(0x6c9f564a, 0xabe30129), TOBN(0xc6f2c940, 0x336e64cf), + TOBN(0x0fe75262, 0x8b0c8022), TOBN(0xbe0267e9, 0x6ae8db87)}}, + {{TOBN(0x22e192f1, 0x93bc042b), TOBN(0xf085b534, 0xb237c458), + TOBN(0xa0d192bd, 0x832c4168), TOBN(0x7a76e9e3, 0xbdf6271d)}, + {TOBN(0x52a882fa, 0xb88911b5), TOBN(0xc85345e4, 0xb4db0eb5), + TOBN(0xa3be02a6, 0x81a7c3ff), TOBN(0x51889c8c, 0xf0ec0469)}}, + {{TOBN(0x9d031369, 0xa5e829e5), TOBN(0xcbb4c6fc, 0x1607aa41), + TOBN(0x75ac59a6, 0x241d84c1), TOBN(0xc043f2bf, 0x8829e0ee)}, + {TOBN(0x82a38f75, 0x8ea5e185), TOBN(0x8bda40b9, 0xd87cbd9f), + TOBN(0x9e65e75e, 0x2d8fc601), TOBN(0x3d515f74, 0xa35690b3)}}, + {{TOBN(0x534acf4f, 0xda79e5ac), TOBN(0x68b83b3a, 0x8630215f), + TOBN(0x5c748b2e, 0xd085756e), TOBN(0xb0317258, 0xe5d37cb2)}, + {TOBN(0x6735841a, 0xc5ccc2c4), TOBN(0x7d7dc96b, 0x3d9d5069), + TOBN(0xa147e410, 0xfd1754bd), TOBN(0x65296e94, 0xd399ddd5)}}, + {{TOBN(0xf6b5b2d0, 0xbc8fa5bc), TOBN(0x8a5ead67, 0x500c277b), + TOBN(0x214625e6, 0xdfa08a5d), TOBN(0x51fdfedc, 0x959cf047)}, + {TOBN(0x6bc9430b, 0x289fca32), TOBN(0xe36ff0cf, 0x9d9bdc3f), + TOBN(0x2fe187cb, 0x58ea0ede), TOBN(0xed66af20, 0x5a900b3f)}}, + {{TOBN(0x00e0968b, 0x5fa9f4d6), TOBN(0x2d4066ce, 0x37a362e7), + TOBN(0xa99a9748, 0xbd07e772), TOBN(0x710989c0, 0x06a4f1d0)}, + {TOBN(0xd5dedf35, 0xce40cbd8), TOBN(0xab55c5f0, 0x1743293d), + TOBN(0x766f1144, 0x8aa24e2c), TOBN(0x94d874f8, 0x605fbcb4)}}, + {{TOBN(0xa365f0e8, 0xa518001b), TOBN(0xee605eb6, 0x9d04ef0f), + TOBN(0x5a3915cd, 0xba8d4d25), TOBN(0x44c0e1b8, 0xb5113472)}, + {TOBN(0xcbb024e8, 0x8b6740dc), TOBN(0x89087a53, 0xee1d4f0c), + TOBN(0xa88fa05c, 0x1fc4e372), TOBN(0x8bf395cb, 0xaf8b3af2)}}, + {{TOBN(0x1e71c9a1, 0xdeb8568b), TOBN(0xa35daea0, 0x80fb3d32), + TOBN(0xe8b6f266, 0x2cf8fb81), TOBN(0x6d51afe8, 0x9490696a)}, + {TOBN(0x81beac6e, 0x51803a19), TOBN(0xe3d24b7f, 0x86219080), + TOBN(0x727cfd9d, 0xdf6f463c), TOBN(0x8c6865ca, 0x72284ee8)}}, + {{TOBN(0x32c88b7d, 0xb743f4ef), TOBN(0x3793909b, 0xe7d11dce), + TOBN(0xd398f922, 0x2ff2ebe8), TOBN(0x2c70ca44, 0xe5e49796)}, + {TOBN(0xdf4d9929, 0xcb1131b1), TOBN(0x7826f298, 0x25888e79), + TOBN(0x4d3a112c, 0xf1d8740a), TOBN(0x00384cb6, 0x270afa8b)}}, + {{TOBN(0xcb64125b, 0x3ab48095), TOBN(0x3451c256, 0x62d05106), + TOBN(0xd73d577d, 0xa4955845), TOBN(0x39570c16, 0xbf9f4433)}, + {TOBN(0xd7dfaad3, 0xadecf263), TOBN(0xf1c3d8d1, 0xdc76e102), + TOBN(0x5e774a58, 0x54c6a836), TOBN(0xdad4b672, 0x3e92d47b)}}, + {{TOBN(0xbe7e990f, 0xf0d796a0), TOBN(0x5fc62478, 0xdf0e8b02), + TOBN(0x8aae8bf4, 0x030c00ad), TOBN(0x3d2db93b, 0x9004ba0f)}, + {TOBN(0xe48c8a79, 0xd85d5ddc), TOBN(0xe907caa7, 0x6bb07f34), + TOBN(0x58db343a, 0xa39eaed5), TOBN(0x0ea6e007, 0xadaf5724)}}, + {{TOBN(0xe00df169, 0xd23233f3), TOBN(0x3e322796, 0x77cb637f), + TOBN(0x1f897c0e, 0x1da0cf6c), TOBN(0xa651f5d8, 0x31d6bbdd)}, + {TOBN(0xdd61af19, 0x1a230c76), TOBN(0xbd527272, 0xcdaa5e4a), + TOBN(0xca753636, 0xd0abcd7e), TOBN(0x78bdd37c, 0x370bd8dc)}}, + {{TOBN(0xc23916c2, 0x17cd93fe), TOBN(0x65b97a4d, 0xdadce6e2), + TOBN(0xe04ed4eb, 0x174e42f8), TOBN(0x1491ccaa, 0xbb21480a)}, + {TOBN(0x145a8280, 0x23196332), TOBN(0x3c3862d7, 0x587b479a), + TOBN(0x9f4a88a3, 0x01dcd0ed), TOBN(0x4da2b7ef, 0x3ea12f1f)}}, + {{TOBN(0xf8e7ae33, 0xb126e48e), TOBN(0x404a0b32, 0xf494e237), + TOBN(0x9beac474, 0xc55acadb), TOBN(0x4ee5cf3b, 0xcbec9fd9)}, + {TOBN(0x336b33b9, 0x7df3c8c3), TOBN(0xbd905fe3, 0xb76808fd), + TOBN(0x8f436981, 0xaa45c16a), TOBN(0x255c5bfa, 0x3dd27b62)}}, + {{TOBN(0x71965cbf, 0xc3dd9b4d), TOBN(0xce23edbf, 0xfc068a87), + TOBN(0xb78d4725, 0x745b029b), TOBN(0x74610713, 0xcefdd9bd)}, + {TOBN(0x7116f75f, 0x1266bf52), TOBN(0x02046722, 0x18e49bb6), + TOBN(0xdf43df9f, 0x3d6f19e3), TOBN(0xef1bc7d0, 0xe685cb2f)}}, + {{TOBN(0xcddb27c1, 0x7078c432), TOBN(0xe1961b9c, 0xb77fedb7), + TOBN(0x1edc2f5c, 0xc2290570), TOBN(0x2c3fefca, 0x19cbd886)}, + {TOBN(0xcf880a36, 0xc2af389a), TOBN(0x96c610fd, 0xbda71cea), + TOBN(0xf03977a9, 0x32aa8463), TOBN(0x8eb7763f, 0x8586d90a)}}, + {{TOBN(0x3f342454, 0x2a296e77), TOBN(0xc8718683, 0x42837a35), + TOBN(0x7dc71090, 0x6a09c731), TOBN(0x54778ffb, 0x51b816db)}, + {TOBN(0x6b33bfec, 0xaf06defd), TOBN(0xfe3c105f, 0x8592b70b), + TOBN(0xf937fda4, 0x61da6114), TOBN(0x3c13e651, 0x4c266ad7)}}, + {{TOBN(0xe363a829, 0x855938e8), TOBN(0x2eeb5d9e, 0x9de54b72), + TOBN(0xbeb93b0e, 0x20ccfab9), TOBN(0x3dffbb5f, 0x25e61a25)}, + {TOBN(0x7f655e43, 0x1acc093d), TOBN(0x0cb6cc3d, 0x3964ce61), + TOBN(0x6ab283a1, 0xe5e9b460), TOBN(0x55d787c5, 0xa1c7e72d)}}, + {{TOBN(0x4d2efd47, 0xdeadbf02), TOBN(0x11e80219, 0xac459068), + TOBN(0x810c7626, 0x71f311f0), TOBN(0xfa17ef8d, 0x4ab6ef53)}, + {TOBN(0xaf47fd25, 0x93e43bff), TOBN(0x5cb5ff3f, 0x0be40632), + TOBN(0x54687106, 0x8ee61da3), TOBN(0x7764196e, 0xb08afd0f)}}, + {{TOBN(0x831ab3ed, 0xf0290a8f), TOBN(0xcae81966, 0xcb47c387), + TOBN(0xaad7dece, 0x184efb4f), TOBN(0xdcfc53b3, 0x4749110e)}, + {TOBN(0x6698f23c, 0x4cb632f9), TOBN(0xc42a1ad6, 0xb91f8067), + TOBN(0xb116a81d, 0x6284180a), TOBN(0xebedf5f8, 0xe901326f)}}, + {{TOBN(0xf2274c9f, 0x97e3e044), TOBN(0x42018520, 0x11d09fc9), + TOBN(0x56a65f17, 0xd18e6e23), TOBN(0x2ea61e2a, 0x352b683c)}, + {TOBN(0x27d291bc, 0x575eaa94), TOBN(0x9e7bc721, 0xb8ff522d), + TOBN(0x5f7268bf, 0xa7f04d6f), TOBN(0x5868c73f, 0xaba41748)}}, + {{TOBN(0x9f85c2db, 0x7be0eead), TOBN(0x511e7842, 0xff719135), + TOBN(0x5a06b1e9, 0xc5ea90d7), TOBN(0x0c19e283, 0x26fab631)}, + {TOBN(0x8af8f0cf, 0xe9206c55), TOBN(0x89389cb4, 0x3553c06a), + TOBN(0x39dbed97, 0xf65f8004), TOBN(0x0621b037, 0xc508991d)}}, + {{TOBN(0x1c52e635, 0x96e78cc4), TOBN(0x5385c8b2, 0x0c06b4a8), + TOBN(0xd84ddfdb, 0xb0e87d03), TOBN(0xc49dfb66, 0x934bafad)}, + {TOBN(0x7071e170, 0x59f70772), TOBN(0x3a073a84, 0x3a1db56b), + TOBN(0x03494903, 0x3b8af190), TOBN(0x7d882de3, 0xd32920f0)}}, + {{TOBN(0x91633f0a, 0xb2cf8940), TOBN(0x72b0b178, 0x6f948f51), + TOBN(0x2d28dc30, 0x782653c8), TOBN(0x88829849, 0xdb903a05)}, + {TOBN(0xb8095d0c, 0x6a19d2bb), TOBN(0x4b9e7f0c, 0x86f782cb), + TOBN(0x7af73988, 0x2d907064), TOBN(0xd12be0fe, 0x8b32643c)}}, + {{TOBN(0x358ed23d, 0x0e165dc3), TOBN(0x3d47ce62, 0x4e2378ce), + TOBN(0x7e2bb0b9, 0xfeb8a087), TOBN(0x3246e8ae, 0xe29e10b9)}, + {TOBN(0x459f4ec7, 0x03ce2b4d), TOBN(0xe9b4ca1b, 0xbbc077cf), + TOBN(0x2613b4f2, 0x0e9940c1), TOBN(0xfc598bb9, 0x047d1eb1)}}, + {{TOBN(0x9744c62b, 0x45036099), TOBN(0xa9dee742, 0x167c65d8), + TOBN(0x0c511525, 0xdabe1943), TOBN(0xda110554, 0x93c6c624)}, + {TOBN(0xae00a52c, 0x651a3be2), TOBN(0xcda5111d, 0x884449a6), + TOBN(0x063c06f4, 0xff33bed1), TOBN(0x73baaf9a, 0x0d3d76b4)}}, + {{TOBN(0x52fb0c9d, 0x7fc63668), TOBN(0x6886c9dd, 0x0c039cde), + TOBN(0x602bd599, 0x55b22351), TOBN(0xb00cab02, 0x360c7c13)}, + {TOBN(0x8cb616bc, 0x81b69442), TOBN(0x41486700, 0xb55c3cee), + TOBN(0x71093281, 0xf49ba278), TOBN(0xad956d9c, 0x64a50710)}}, + {{TOBN(0x9561f28b, 0x638a7e81), TOBN(0x54155cdf, 0x5980ddc3), + TOBN(0xb2db4a96, 0xd26f247a), TOBN(0x9d774e4e, 0x4787d100)}, + {TOBN(0x1a9e6e2e, 0x078637d2), TOBN(0x1c363e2d, 0x5e0ae06a), + TOBN(0x7493483e, 0xe9cfa354), TOBN(0x76843cb3, 0x7f74b98d)}}, + {{TOBN(0xbaca6591, 0xd4b66947), TOBN(0xb452ce98, 0x04460a8c), + TOBN(0x6830d246, 0x43768f55), TOBN(0xf4197ed8, 0x7dff12df)}, + {TOBN(0x6521b472, 0x400dd0f7), TOBN(0x59f5ca8f, 0x4b1e7093), + TOBN(0x6feff11b, 0x080338ae), TOBN(0x0ada31f6, 0xa29ca3c6)}}, + {{TOBN(0x24794eb6, 0x94a2c215), TOBN(0xd83a43ab, 0x05a57ab4), + TOBN(0x264a543a, 0x2a6f89fe), TOBN(0x2c2a3868, 0xdd5ec7c2)}, + {TOBN(0xd3373940, 0x8439d9b2), TOBN(0x715ea672, 0x0acd1f11), + TOBN(0x42c1d235, 0xe7e6cc19), TOBN(0x81ce6e96, 0xb990585c)}}, + {{TOBN(0x04e5dfe0, 0xd809c7bd), TOBN(0xd7b2580c, 0x8f1050ab), + TOBN(0x6d91ad78, 0xd8a4176f), TOBN(0x0af556ee, 0x4e2e897c)}, + {TOBN(0x162a8b73, 0x921de0ac), TOBN(0x52ac9c22, 0x7ea78400), + TOBN(0xee2a4eea, 0xefce2174), TOBN(0xbe61844e, 0x6d637f79)}}, + {{TOBN(0x0491f1bc, 0x789a283b), TOBN(0x72d3ac3d, 0x880836f4), + TOBN(0xaa1c5ea3, 0x88e5402d), TOBN(0x1b192421, 0xd5cc473d)}, + {TOBN(0x5c0b9998, 0x9dc84cac), TOBN(0xb0a8482d, 0x9c6e75b8), + TOBN(0x639961d0, 0x3a191ce2), TOBN(0xda3bc865, 0x6d837930)}}, + {{TOBN(0xca990653, 0x056e6f8f), TOBN(0x84861c41, 0x64d133a7), + TOBN(0x8b403276, 0x746abe40), TOBN(0xb7b4d51a, 0xebf8e303)}, + {TOBN(0x05b43211, 0x220a255d), TOBN(0xc997152c, 0x02419e6e), + TOBN(0x76ff47b6, 0x630c2fea), TOBN(0x50518677, 0x281fdade)}}, + {{TOBN(0x3283b8ba, 0xcf902b0b), TOBN(0x8d4b4eb5, 0x37db303b), + TOBN(0xcc89f42d, 0x755011bc), TOBN(0xb43d74bb, 0xdd09d19b)}, + {TOBN(0x65746bc9, 0x8adba350), TOBN(0x364eaf8c, 0xb51c1927), + TOBN(0x13c76596, 0x10ad72ec), TOBN(0x30045121, 0xf8d40c20)}}, + {{TOBN(0x6d2d99b7, 0xea7b979b), TOBN(0xcd78cd74, 0xe6fb3bcd), + TOBN(0x11e45a9e, 0x86cffbfe), TOBN(0x78a61cf4, 0x637024f6)}, + {TOBN(0xd06bc872, 0x3d502295), TOBN(0xf1376854, 0x458cb288), + TOBN(0xb9db26a1, 0x342f8586), TOBN(0xf33effcf, 0x4beee09e)}}, + {{TOBN(0xd7e0c4cd, 0xb30cfb3a), TOBN(0x6d09b8c1, 0x6c9db4c8), + TOBN(0x40ba1a42, 0x07c8d9df), TOBN(0x6fd495f7, 0x1c52c66d)}, + {TOBN(0xfb0e169f, 0x275264da), TOBN(0x80c2b746, 0xe57d8362), + TOBN(0xedd987f7, 0x49ad7222), TOBN(0xfdc229af, 0x4398ec7b)}}}, + {{{TOBN(0xb0d1ed84, 0x52666a58), TOBN(0x4bcb6e00, 0xe6a9c3c2), + TOBN(0x3c57411c, 0x26906408), TOBN(0xcfc20755, 0x13556400)}, + {TOBN(0xa08b1c50, 0x5294dba3), TOBN(0xa30ba286, 0x8b7dd31e), + TOBN(0xd70ba90e, 0x991eca74), TOBN(0x094e142c, 0xe762c2b9)}}, + {{TOBN(0xb81d783e, 0x979f3925), TOBN(0x1efd130a, 0xaf4c89a7), + TOBN(0x525c2144, 0xfd1bf7fa), TOBN(0x4b296904, 0x1b265a9e)}, + {TOBN(0xed8e9634, 0xb9db65b6), TOBN(0x35c82e32, 0x03599d8a), + TOBN(0xdaa7a54f, 0x403563f3), TOBN(0x9df088ad, 0x022c38ab)}}, + {{TOBN(0xe5cfb066, 0xbb3fd30a), TOBN(0x429169da, 0xeff0354e), + TOBN(0x809cf852, 0x3524e36c), TOBN(0x136f4fb3, 0x0155be1d)}, + {TOBN(0x4826af01, 0x1fbba712), TOBN(0x6ef0f0b4, 0x506ba1a1), + TOBN(0xd9928b31, 0x77aea73e), TOBN(0xe2bf6af2, 0x5eaa244e)}}, + {{TOBN(0x8d084f12, 0x4237b64b), TOBN(0x688ebe99, 0xe3ecfd07), + TOBN(0x57b8a70c, 0xf6845dd8), TOBN(0x808fc59c, 0x5da4a325)}, + {TOBN(0xa9032b2b, 0xa3585862), TOBN(0xb66825d5, 0xedf29386), + TOBN(0xb5a5a8db, 0x431ec29b), TOBN(0xbb143a98, 0x3a1e8dc8)}}, + {{TOBN(0x35ee94ce, 0x12ae381b), TOBN(0x3a7f176c, 0x86ccda90), + TOBN(0xc63a657e, 0x4606eaca), TOBN(0x9ae5a380, 0x43cd04df)}, + {TOBN(0x9bec8d15, 0xed251b46), TOBN(0x1f5d6d30, 0xcaca5e64), + TOBN(0x347b3b35, 0x9ff20f07), TOBN(0x4d65f034, 0xf7e4b286)}}, + {{TOBN(0x9e93ba24, 0xf111661e), TOBN(0xedced484, 0xb105eb04), + TOBN(0x96dc9ba1, 0xf424b578), TOBN(0xbf8f66b7, 0xe83e9069)}, + {TOBN(0x872d4df4, 0xd7ed8216), TOBN(0xbf07f377, 0x8e2cbecf), + TOBN(0x4281d899, 0x98e73754), TOBN(0xfec85fbb, 0x8aab8708)}}, + {{TOBN(0x9a3c0dee, 0xa5ba5b0b), TOBN(0xe6a116ce, 0x42d05299), + TOBN(0xae9775fe, 0xe9b02d42), TOBN(0x72b05200, 0xa1545cb6)}, + {TOBN(0xbc506f7d, 0x31a3b4ea), TOBN(0xe5893078, 0x8bbd9b32), + TOBN(0xc8bc5f37, 0xe4b12a97), TOBN(0x6b000c06, 0x4a73b671)}}, + {{TOBN(0x13b5bf22, 0x765fa7d0), TOBN(0x59805bf0, 0x1d6a5370), + TOBN(0x67a5e29d, 0x4280db98), TOBN(0x4f53916f, 0x776b1ce3)}, + {TOBN(0x714ff61f, 0x33ddf626), TOBN(0x4206238e, 0xa085d103), + TOBN(0x1c50d4b7, 0xe5809ee3), TOBN(0x999f450d, 0x85f8eb1d)}}, + {{TOBN(0x658a6051, 0xe4c79e9b), TOBN(0x1394cb73, 0xc66a9fea), + TOBN(0x27f31ed5, 0xc6be7b23), TOBN(0xf4c88f36, 0x5aa6f8fe)}, + {TOBN(0x0fb0721f, 0x4aaa499e), TOBN(0x68b3a7d5, 0xe3fb2a6b), + TOBN(0xa788097d, 0x3a92851d), TOBN(0x060e7f8a, 0xe96f4913)}}, + {{TOBN(0x82eebe73, 0x1a3a93bc), TOBN(0x42bbf465, 0xa21adc1a), + TOBN(0xc10b6fa4, 0xef030efd), TOBN(0x247aa4c7, 0x87b097bb)}, + {TOBN(0x8b8dc632, 0xf60c77da), TOBN(0x6ffbc26a, 0xc223523e), + TOBN(0xa4f6ff11, 0x344579cf), TOBN(0x5825653c, 0x980250f6)}}, + {{TOBN(0xb2dd097e, 0xbc1aa2b9), TOBN(0x07889393, 0x37a0333a), + TOBN(0x1cf55e71, 0x37a0db38), TOBN(0x2648487f, 0x792c1613)}, + {TOBN(0xdad01336, 0x3fcef261), TOBN(0x6239c81d, 0x0eabf129), + TOBN(0x8ee761de, 0x9d276be2), TOBN(0x406a7a34, 0x1eda6ad3)}}, + {{TOBN(0x4bf367ba, 0x4a493b31), TOBN(0x54f20a52, 0x9bf7f026), + TOBN(0xb696e062, 0x9795914b), TOBN(0xcddab96d, 0x8bf236ac)}, + {TOBN(0x4ff2c70a, 0xed25ea13), TOBN(0xfa1d09eb, 0x81cbbbe7), + TOBN(0x88fc8c87, 0x468544c5), TOBN(0x847a670d, 0x696b3317)}}, + {{TOBN(0xf133421e, 0x64bcb626), TOBN(0xaea638c8, 0x26dee0b5), + TOBN(0xd6e7680b, 0xb310346c), TOBN(0xe06f4097, 0xd5d4ced3)}, + {TOBN(0x09961452, 0x7512a30b), TOBN(0xf3d867fd, 0xe589a59a), + TOBN(0x2e73254f, 0x52d0c180), TOBN(0x9063d8a3, 0x333c74ac)}}, + {{TOBN(0xeda6c595, 0xd314e7bc), TOBN(0x2ee7464b, 0x467899ed), + TOBN(0x1cef423c, 0x0a1ed5d3), TOBN(0x217e76ea, 0x69cc7613)}, + {TOBN(0x27ccce1f, 0xe7cda917), TOBN(0x12d8016b, 0x8a893f16), + TOBN(0xbcd6de84, 0x9fc74f6b), TOBN(0xfa5817e2, 0xf3144e61)}}, + {{TOBN(0x1f354164, 0x0821ee4c), TOBN(0x1583eab4, 0x0bc61992), + TOBN(0x7490caf6, 0x1d72879f), TOBN(0x998ad9f3, 0xf76ae7b2)}, + {TOBN(0x1e181950, 0xa41157f7), TOBN(0xa9d7e1e6, 0xe8da3a7e), + TOBN(0x963784eb, 0x8426b95f), TOBN(0x0ee4ed6e, 0x542e2a10)}}, + {{TOBN(0xb79d4cc5, 0xac751e7b), TOBN(0x93f96472, 0xfd4211bd), + TOBN(0x8c72d3d2, 0xc8de4fc6), TOBN(0x7b69cbf5, 0xdf44f064)}, + {TOBN(0x3da90ca2, 0xf4bf94e1), TOBN(0x1a5325f8, 0xf12894e2), + TOBN(0x0a437f6c, 0x7917d60b), TOBN(0x9be70486, 0x96c9cb5d)}}, + {{TOBN(0xb4d880bf, 0xe1dc5c05), TOBN(0xd738adda, 0xeebeeb57), + TOBN(0x6f0119d3, 0xdf0fe6a3), TOBN(0x5c686e55, 0x66eaaf5a)}, + {TOBN(0x9cb10b50, 0xdfd0b7ec), TOBN(0xbdd0264b, 0x6a497c21), + TOBN(0xfc093514, 0x8c546c96), TOBN(0x58a947fa, 0x79dbf42a)}}, + {{TOBN(0xc0b48d4e, 0x49ccd6d7), TOBN(0xff8fb02c, 0x88bd5580), + TOBN(0xc75235e9, 0x07d473b2), TOBN(0x4fab1ac5, 0xa2188af3)}, + {TOBN(0x030fa3bc, 0x97576ec0), TOBN(0xe8c946e8, 0x0b7e7d2f), + TOBN(0x40a5c9cc, 0x70305600), TOBN(0x6d8260a9, 0xc8b013b4)}}, + {{TOBN(0x0368304f, 0x70bba85c), TOBN(0xad090da1, 0xa4a0d311), + TOBN(0x7170e870, 0x2415eec1), TOBN(0xbfba35fe, 0x8461ea47)}, + {TOBN(0x6279019a, 0xc1e91938), TOBN(0xa47638f3, 0x1afc415f), + TOBN(0x36c65cbb, 0xbcba0e0f), TOBN(0x02160efb, 0x034e2c48)}}, + {{TOBN(0xe6c51073, 0x615cd9e4), TOBN(0x498ec047, 0xf1243c06), + TOBN(0x3e5a8809, 0xb17b3d8c), TOBN(0x5cd99e61, 0x0cc565f1)}, + {TOBN(0x81e312df, 0x7851dafe), TOBN(0xf156f5ba, 0xa79061e2), + TOBN(0x80d62b71, 0x880c590e), TOBN(0xbec9746f, 0x0a39faa1)}}, + {{TOBN(0x1d98a9c1, 0xc8ed1f7a), TOBN(0x09e43bb5, 0xa81d5ff2), + TOBN(0xd5f00f68, 0x0da0794a), TOBN(0x412050d9, 0x661aa836)}, + {TOBN(0xa89f7c4e, 0x90747e40), TOBN(0x6dc05ebb, 0xb62a3686), + TOBN(0xdf4de847, 0x308e3353), TOBN(0x53868fbb, 0x9fb53bb9)}}, + {{TOBN(0x2b09d2c3, 0xcfdcf7dd), TOBN(0x41a9fce3, 0x723fcab4), + TOBN(0x73d905f7, 0x07f57ca3), TOBN(0x080f9fb1, 0xac8e1555)}, + {TOBN(0x7c088e84, 0x9ba7a531), TOBN(0x07d35586, 0xed9a147f), + TOBN(0x602846ab, 0xaf48c336), TOBN(0x7320fd32, 0x0ccf0e79)}}, + {{TOBN(0xaa780798, 0xb18bd1ff), TOBN(0x52c2e300, 0xafdd2905), + TOBN(0xf27ea3d6, 0x434267cd), TOBN(0x8b96d16d, 0x15605b5f)}, + {TOBN(0x7bb31049, 0x4b45706b), TOBN(0xe7f58b8e, 0x743d25f8), + TOBN(0xe9b5e45b, 0x87f30076), TOBN(0xd19448d6, 0x5d053d5a)}}, + {{TOBN(0x1ecc8cb9, 0xd3210a04), TOBN(0x6bc7d463, 0xdafb5269), + TOBN(0x3e59b10a, 0x67c3489f), TOBN(0x1769788c, 0x65641e1b)}, + {TOBN(0x8a53b82d, 0xbd6cb838), TOBN(0x7066d6e6, 0x236d5f22), + TOBN(0x03aa1c61, 0x6908536e), TOBN(0xc971da0d, 0x66ae9809)}}, + {{TOBN(0x01b3a86b, 0xc49a2fac), TOBN(0x3b8420c0, 0x3092e77a), + TOBN(0x02057300, 0x7d6fb556), TOBN(0x6941b2a1, 0xbff40a87)}, + {TOBN(0x140b6308, 0x0658ff2a), TOBN(0x87804363, 0x3424ab36), + TOBN(0x0253bd51, 0x5751e299), TOBN(0xc75bcd76, 0x449c3e3a)}}, + {{TOBN(0x92eb4090, 0x7f8f875d), TOBN(0x9c9d754e, 0x56c26bbf), + TOBN(0x158cea61, 0x8110bbe7), TOBN(0x62a6b802, 0x745f91ea)}, + {TOBN(0xa79c41aa, 0xc6e7394b), TOBN(0x445b6a83, 0xad57ef10), + TOBN(0x0c5277eb, 0x6ea6f40c), TOBN(0x319fe96b, 0x88633365)}}, + {{TOBN(0x0b0fc61f, 0x385f63cb), TOBN(0x41250c84, 0x22bdd127), + TOBN(0x67d153f1, 0x09e942c2), TOBN(0x60920d08, 0xc021ad5d)}, + {TOBN(0x229f5746, 0x724d81a5), TOBN(0xb7ffb892, 0x5bba3299), + TOBN(0x518c51a1, 0xde413032), TOBN(0x2a9bfe77, 0x3c2fd94c)}}, + {{TOBN(0xcbcde239, 0x3191f4fd), TOBN(0x43093e16, 0xd3d6ada1), + TOBN(0x184579f3, 0x58769606), TOBN(0x2c94a8b3, 0xd236625c)}, + {TOBN(0x6922b9c0, 0x5c437d8e), TOBN(0x3d4ae423, 0xd8d9f3c8), + TOBN(0xf72c31c1, 0x2e7090a2), TOBN(0x4ac3f5f3, 0xd76a55bd)}}, + {{TOBN(0x342508fc, 0x6b6af991), TOBN(0x0d527100, 0x1b5cebbd), + TOBN(0xb84740d0, 0xdd440dd7), TOBN(0x748ef841, 0x780162fd)}, + {TOBN(0xa8dbfe0e, 0xdfc6fafb), TOBN(0xeadfdf05, 0xf7300f27), + TOBN(0x7d06555f, 0xfeba4ec9), TOBN(0x12c56f83, 0x9e25fa97)}}, + {{TOBN(0x77f84203, 0xd39b8c34), TOBN(0xed8b1be6, 0x3125eddb), + TOBN(0x5bbf2441, 0xf6e39dc5), TOBN(0xb00f6ee6, 0x6a5d678a)}, + {TOBN(0xba456ecf, 0x57d0ea99), TOBN(0xdcae0f58, 0x17e06c43), + TOBN(0x01643de4, 0x0f5b4baa), TOBN(0x2c324341, 0xd161b9be)}}, + {{TOBN(0x80177f55, 0xe126d468), TOBN(0xed325f1f, 0x76748e09), + TOBN(0x6116004a, 0xcfa9bdc2), TOBN(0x2d8607e6, 0x3a9fb468)}, + {TOBN(0x0e573e27, 0x6009d660), TOBN(0x3a525d2e, 0x8d10c5a1), + TOBN(0xd26cb45c, 0x3b9009a0), TOBN(0xb6b0cdc0, 0xde9d7448)}}, + {{TOBN(0x949c9976, 0xe1337c26), TOBN(0x6faadebd, 0xd73d68e5), + TOBN(0x9e158614, 0xf1b768d9), TOBN(0x22dfa557, 0x9cc4f069)}, + {TOBN(0xccd6da17, 0xbe93c6d6), TOBN(0x24866c61, 0xa504f5b9), + TOBN(0x2121353c, 0x8d694da1), TOBN(0x1c6ca580, 0x0140b8c6)}}, + {{TOBN(0xc245ad8c, 0xe964021e), TOBN(0xb83bffba, 0x032b82b3), + TOBN(0xfaa220c6, 0x47ef9898), TOBN(0x7e8d3ac6, 0x982c948a)}, + {TOBN(0x1faa2091, 0xbc2d124a), TOBN(0xbd54c3dd, 0x05b15ff4), + TOBN(0x386bf3ab, 0xc87c6fb7), TOBN(0xfb2b0563, 0xfdeb6f66)}}, + {{TOBN(0x4e77c557, 0x5b45afb4), TOBN(0xe9ded649, 0xefb8912d), + TOBN(0x7ec9bbf5, 0x42f6e557), TOBN(0x2570dfff, 0x62671f00)}, + {TOBN(0x2b3bfb78, 0x88e084bd), TOBN(0xa024b238, 0xf37fe5b4), + TOBN(0x44e7dc04, 0x95649aee), TOBN(0x498ca255, 0x5e7ec1d8)}}, + {{TOBN(0x3bc766ea, 0xaaa07e86), TOBN(0x0db6facb, 0xf3608586), + TOBN(0xbadd2549, 0xbdc259c8), TOBN(0x95af3c6e, 0x041c649f)}, + {TOBN(0xb36a928c, 0x02e30afb), TOBN(0x9b5356ad, 0x008a88b8), + TOBN(0x4b67a5f1, 0xcf1d9e9d), TOBN(0xc6542e47, 0xa5d8d8ce)}}, + {{TOBN(0x73061fe8, 0x7adfb6cc), TOBN(0xcc826fd3, 0x98678141), + TOBN(0x00e758b1, 0x3c80515a), TOBN(0x6afe3247, 0x41485083)}, + {TOBN(0x0fcb08b9, 0xb6ae8a75), TOBN(0xb8cf388d, 0x4acf51e1), + TOBN(0x344a5560, 0x6961b9d6), TOBN(0x1a6778b8, 0x6a97fd0c)}}, + {{TOBN(0xd840fdc1, 0xecc4c7e3), TOBN(0xde9fe47d, 0x16db68cc), + TOBN(0xe95f89de, 0xa3e216aa), TOBN(0x84f1a6a4, 0x9594a8be)}, + {TOBN(0x7ddc7d72, 0x5a7b162b), TOBN(0xc5cfda19, 0xadc817a3), + TOBN(0x80a5d350, 0x78b58d46), TOBN(0x93365b13, 0x82978f19)}}, + {{TOBN(0x2e44d225, 0x26a1fc90), TOBN(0x0d6d10d2, 0x4d70705d), + TOBN(0xd94b6b10, 0xd70c45f4), TOBN(0x0f201022, 0xb216c079)}, + {TOBN(0xcec966c5, 0x658fde41), TOBN(0xa8d2bc7d, 0x7e27601d), + TOBN(0xbfcce3e1, 0xff230be7), TOBN(0x3394ff6b, 0x0033ffb5)}}, + {{TOBN(0xd890c509, 0x8132c9af), TOBN(0xaac4b0eb, 0x361e7868), + TOBN(0x5194ded3, 0xe82d15aa), TOBN(0x4550bd2e, 0x23ae6b7d)}, + {TOBN(0x3fda318e, 0xea5399d4), TOBN(0xd989bffa, 0x91638b80), + TOBN(0x5ea124d0, 0xa14aa12d), TOBN(0x1fb1b899, 0x3667b944)}}, + {{TOBN(0x95ec7969, 0x44c44d6a), TOBN(0x91df144a, 0x57e86137), + TOBN(0x915fd620, 0x73adac44), TOBN(0x8f01732d, 0x59a83801)}, + {TOBN(0xec579d25, 0x3aa0a633), TOBN(0x06de5e7c, 0xc9d6d59c), + TOBN(0xc132f958, 0xb1ef8010), TOBN(0x29476f96, 0xe65c1a02)}}, + {{TOBN(0x336a77c0, 0xd34c3565), TOBN(0xef1105b2, 0x1b9f1e9e), + TOBN(0x63e6d08b, 0xf9e08002), TOBN(0x9aff2f21, 0xc613809e)}, + {TOBN(0xb5754f85, 0x3a80e75d), TOBN(0xde71853e, 0x6bbda681), + TOBN(0x86f041df, 0x8197fd7a), TOBN(0x8b332e08, 0x127817fa)}}, + {{TOBN(0x05d99be8, 0xb9c20cda), TOBN(0x89f7aad5, 0xd5cd0c98), + TOBN(0x7ef936fe, 0x5bb94183), TOBN(0x92ca0753, 0xb05cd7f2)}, + {TOBN(0x9d65db11, 0x74a1e035), TOBN(0x02628cc8, 0x13eaea92), + TOBN(0xf2d9e242, 0x49e4fbf2), TOBN(0x94fdfd9b, 0xe384f8b7)}}, + {{TOBN(0x65f56054, 0x63428c6b), TOBN(0x2f7205b2, 0x90b409a5), + TOBN(0xf778bb78, 0xff45ae11), TOBN(0xa13045be, 0xc5ee53b2)}, + {TOBN(0xe00a14ff, 0x03ef77fe), TOBN(0x689cd59f, 0xffef8bef), + TOBN(0x3578f0ed, 0x1e9ade22), TOBN(0xe99f3ec0, 0x6268b6a8)}}, + {{TOBN(0xa2057d91, 0xea1b3c3e), TOBN(0x2d1a7053, 0xb8823a4a), + TOBN(0xabbb336a, 0x2cca451e), TOBN(0xcd2466e3, 0x2218bb5d)}, + {TOBN(0x3ac1f42f, 0xc8cb762d), TOBN(0x7e312aae, 0x7690211f), + TOBN(0xebb9bd73, 0x45d07450), TOBN(0x207c4b82, 0x46c2213f)}}, + {{TOBN(0x99d425c1, 0x375913ec), TOBN(0x94e45e96, 0x67908220), + TOBN(0xc08f3087, 0xcd67dbf6), TOBN(0xa5670fbe, 0xc0887056)}, + {TOBN(0x6717b64a, 0x66f5b8fc), TOBN(0xd5a56aea, 0x786fec28), + TOBN(0xa8c3f55f, 0xc0ff4952), TOBN(0xa77fefae, 0x457ac49b)}}, + {{TOBN(0x29882d7c, 0x98379d44), TOBN(0xd000bdfb, 0x509edc8a), + TOBN(0xc6f95979, 0xe66fe464), TOBN(0x504a6115, 0xfa61bde0)}, + {TOBN(0x56b3b871, 0xeffea31a), TOBN(0x2d3de26d, 0xf0c21a54), + TOBN(0x21dbff31, 0x834753bf), TOBN(0xe67ecf49, 0x69269d86)}}, + {{TOBN(0x7a176952, 0x151fe690), TOBN(0x03515804, 0x7f2adb5f), + TOBN(0xee794b15, 0xd1b62a8d), TOBN(0xf004ceec, 0xaae454e6)}, + {TOBN(0x0897ea7c, 0xf0386fac), TOBN(0x3b62ff12, 0xd1fca751), + TOBN(0x154181df, 0x1b7a04ec), TOBN(0x2008e04a, 0xfb5847ec)}}, + {{TOBN(0xd147148e, 0x41dbd772), TOBN(0x2b419f73, 0x22942654), + TOBN(0x669f30d3, 0xe9c544f7), TOBN(0x52a2c223, 0xc8540149)}, + {TOBN(0x5da9ee14, 0x634dfb02), TOBN(0x5f074ff0, 0xf47869f3), + TOBN(0x74ee878d, 0xa3933acc), TOBN(0xe6510651, 0x4fe35ed1)}}, + {{TOBN(0xb3eb9482, 0xf1012e7a), TOBN(0x51013cc0, 0xa8a566ae), + TOBN(0xdd5e9243, 0x47c00d3b), TOBN(0x7fde089d, 0x946bb0e5)}, + {TOBN(0x030754fe, 0xc731b4b3), TOBN(0x12a136a4, 0x99fda062), + TOBN(0x7c1064b8, 0x5a1a35bc), TOBN(0xbf1f5763, 0x446c84ef)}}, + {{TOBN(0xed29a56d, 0xa16d4b34), TOBN(0x7fba9d09, 0xdca21c4f), + TOBN(0x66d7ac00, 0x6d8de486), TOBN(0x60061987, 0x73a2a5e1)}, + {TOBN(0x8b400f86, 0x9da28ff0), TOBN(0x3133f708, 0x43c4599c), + TOBN(0x9911c9b8, 0xee28cb0d), TOBN(0xcd7e2874, 0x8e0af61d)}}, + {{TOBN(0x5a85f0f2, 0x72ed91fc), TOBN(0x85214f31, 0x9cd4a373), + TOBN(0x881fe5be, 0x1925253c), TOBN(0xd8dc98e0, 0x91e8bc76)}, + {TOBN(0x7120affe, 0x585cc3a2), TOBN(0x724952ed, 0x735bf97a), + TOBN(0x5581e7dc, 0x3eb34581), TOBN(0x5cbff4f2, 0xe52ee57d)}}, + {{TOBN(0x8d320a0e, 0x87d8cc7b), TOBN(0x9beaa7f3, 0xf1d280d0), + TOBN(0x7a0b9571, 0x9beec704), TOBN(0x9126332e, 0x5b7f0057)}, + {TOBN(0x01fbc1b4, 0x8ed3bd6d), TOBN(0x35bb2c12, 0xd945eb24), + TOBN(0x6404694e, 0x9a8ae255), TOBN(0xb6092eec, 0x8d6abfb3)}}, + {{TOBN(0x4d76143f, 0xcc058865), TOBN(0x7b0a5af2, 0x6e249922), + TOBN(0x8aef9440, 0x6a50d353), TOBN(0xe11e4bcc, 0x64f0e07a)}, + {TOBN(0x4472993a, 0xa14a90fa), TOBN(0x7706e20c, 0xba0c51d4), + TOBN(0xf403292f, 0x1532672d), TOBN(0x52573bfa, 0x21829382)}}, + {{TOBN(0x6a7bb6a9, 0x3b5bdb83), TOBN(0x08da65c0, 0xa4a72318), + TOBN(0xc58d22aa, 0x63eb065f), TOBN(0x1717596c, 0x1b15d685)}, + {TOBN(0x112df0d0, 0xb266d88b), TOBN(0xf688ae97, 0x5941945a), + TOBN(0x487386e3, 0x7c292cac), TOBN(0x42f3b50d, 0x57d6985c)}}, + {{TOBN(0x6da4f998, 0x6a90fc34), TOBN(0xc8f257d3, 0x65ca8a8d), + TOBN(0xc2feabca, 0x6951f762), TOBN(0xe1bc81d0, 0x74c323ac)}, + {TOBN(0x1bc68f67, 0x251a2a12), TOBN(0x10d86587, 0xbe8a70dc), + TOBN(0xd648af7f, 0xf0f84d2e), TOBN(0xf0aa9ebc, 0x6a43ac92)}}, + {{TOBN(0x69e3be04, 0x27596893), TOBN(0xb6bb02a6, 0x45bf452b), + TOBN(0x0875c11a, 0xf4c698c8), TOBN(0x6652b5c7, 0xbece3794)}, + {TOBN(0x7b3755fd, 0x4f5c0499), TOBN(0x6ea16558, 0xb5532b38), + TOBN(0xd1c69889, 0xa2e96ef7), TOBN(0x9c773c3a, 0x61ed8f48)}}, + {{TOBN(0x2b653a40, 0x9b323abc), TOBN(0xe26605e1, 0xf0e1d791), + TOBN(0x45d41064, 0x4a87157a), TOBN(0x8f9a78b7, 0xcbbce616)}, + {TOBN(0xcf1e44aa, 0xc407eddd), TOBN(0x81ddd1d8, 0xa35b964f), + TOBN(0x473e339e, 0xfd083999), TOBN(0x6c94bdde, 0x8e796802)}}, + {{TOBN(0x5a304ada, 0x8545d185), TOBN(0x82ae44ea, 0x738bb8cb), + TOBN(0x628a35e3, 0xdf87e10e), TOBN(0xd3624f3d, 0xa15b9fe3)}, + {TOBN(0xcc44209b, 0x14be4254), TOBN(0x7d0efcbc, 0xbdbc2ea5), + TOBN(0x1f603362, 0x04c37bbe), TOBN(0x21f363f5, 0x56a5852c)}}, + {{TOBN(0xa1503d1c, 0xa8501550), TOBN(0x2251e0e1, 0xd8ab10bb), + TOBN(0xde129c96, 0x6961c51c), TOBN(0x1f7246a4, 0x81910f68)}, + {TOBN(0x2eb744ee, 0x5f2591f2), TOBN(0x3c47d33f, 0x5e627157), + TOBN(0x4d6d62c9, 0x22f3bd68), TOBN(0x6120a64b, 0xcb8df856)}}, + {{TOBN(0x3a9ac6c0, 0x7b5d07df), TOBN(0xa92b9558, 0x7ef39783), + TOBN(0xe128a134, 0xab3a9b4f), TOBN(0x41c18807, 0xb1252f05)}, + {TOBN(0xfc7ed089, 0x80ba9b1c), TOBN(0xac8dc6de, 0xc532a9dd), + TOBN(0xbf829cef, 0x55246809), TOBN(0x101b784f, 0x5b4ee80f)}}, + {{TOBN(0xc09945bb, 0xb6f11603), TOBN(0x57b09dbe, 0x41d2801e), + TOBN(0xfba5202f, 0xa97534a8), TOBN(0x7fd8ae5f, 0xc17b9614)}, + {TOBN(0xa50ba666, 0x78308435), TOBN(0x9572f77c, 0xd3868c4d), + TOBN(0x0cef7bfd, 0x2dd7aab0), TOBN(0xe7958e08, 0x2c7c79ff)}}, + {{TOBN(0x81262e42, 0x25346689), TOBN(0x716da290, 0xb07c7004), + TOBN(0x35f911ea, 0xb7950ee3), TOBN(0x6fd72969, 0x261d21b5)}, + {TOBN(0x52389803, 0x08b640d3), TOBN(0x5b0026ee, 0x887f12a1), + TOBN(0x20e21660, 0x742e9311), TOBN(0x0ef6d541, 0x5ff77ff7)}}, + {{TOBN(0x969127f0, 0xf9c41135), TOBN(0xf21d60c9, 0x68a64993), + TOBN(0x656e5d0c, 0xe541875c), TOBN(0xf1e0f84e, 0xa1d3c233)}, + {TOBN(0x9bcca359, 0x06002d60), TOBN(0xbe2da60c, 0x06191552), + TOBN(0x5da8bbae, 0x61181ec3), TOBN(0x9f04b823, 0x65806f19)}}, + {{TOBN(0xf1604a7d, 0xd4b79bb8), TOBN(0xaee806fb, 0x52c878c8), + TOBN(0x34144f11, 0x8d47b8e8), TOBN(0x72edf52b, 0x949f9054)}, + {TOBN(0xebfca84e, 0x2127015a), TOBN(0x9051d0c0, 0x9cb7cef3), + TOBN(0x86e8fe58, 0x296deec8), TOBN(0x33b28188, 0x41010d74)}}}, + {{{TOBN(0x01079383, 0x171b445f), TOBN(0x9bcf21e3, 0x8131ad4c), + TOBN(0x8cdfe205, 0xc93987e8), TOBN(0xe63f4152, 0xc92e8c8f)}, + {TOBN(0x729462a9, 0x30add43d), TOBN(0x62ebb143, 0xc980f05a), + TOBN(0x4f3954e5, 0x3b06e968), TOBN(0xfe1d75ad, 0x242cf6b1)}}, + {{TOBN(0x5f95c6c7, 0xaf8685c8), TOBN(0xd4c1c8ce, 0x2f8f01aa), + TOBN(0xc44bbe32, 0x2574692a), TOBN(0xb8003478, 0xd4a4a068)}, + {TOBN(0x7c8fc6e5, 0x2eca3cdb), TOBN(0xea1db16b, 0xec04d399), + TOBN(0xb05bc82e, 0x8f2bc5cf), TOBN(0x763d517f, 0xf44793d2)}}, + {{TOBN(0x4451c1b8, 0x08bd98d0), TOBN(0x644b1cd4, 0x6575f240), + TOBN(0x6907eb33, 0x7375d270), TOBN(0x56c8bebd, 0xfa2286bd)}, + {TOBN(0xc713d2ac, 0xc4632b46), TOBN(0x17da427a, 0xafd60242), + TOBN(0x313065b7, 0xc95c7546), TOBN(0xf8239898, 0xbf17a3de)}}, + {{TOBN(0xf3b7963f, 0x4c830320), TOBN(0x842c7aa0, 0x903203e3), + TOBN(0xaf22ca0a, 0xe7327afb), TOBN(0x38e13092, 0x967609b6)}, + {TOBN(0x73b8fb62, 0x757558f1), TOBN(0x3cc3e831, 0xf7eca8c1), + TOBN(0xe4174474, 0xf6331627), TOBN(0xa77989ca, 0xc3c40234)}}, + {{TOBN(0xe5fd17a1, 0x44a081e0), TOBN(0xd797fb7d, 0xb70e296a), + TOBN(0x2b472b30, 0x481f719c), TOBN(0x0e632a98, 0xfe6f8c52)}, + {TOBN(0x89ccd116, 0xc5f0c284), TOBN(0xf51088af, 0x2d987c62), + TOBN(0x2a2bccda, 0x4c2de6cf), TOBN(0x810f9efe, 0xf679f0f9)}}, + {{TOBN(0xb0f394b9, 0x7ffe4b3e), TOBN(0x0b691d21, 0xe5fa5d21), + TOBN(0xb0bd7747, 0x9dfbbc75), TOBN(0xd2830fda, 0xfaf78b00)}, + {TOBN(0xf78c249c, 0x52434f57), TOBN(0x4b1f7545, 0x98096dab), + TOBN(0x73bf6f94, 0x8ff8c0b3), TOBN(0x34aef03d, 0x454e134c)}}, + {{TOBN(0xf8d151f4, 0xb7ac7ec5), TOBN(0xd6ceb95a, 0xe50da7d5), + TOBN(0xa1b492b0, 0xdc3a0eb8), TOBN(0x75157b69, 0xb3dd2863)}, + {TOBN(0xe2c4c74e, 0xc5413d62), TOBN(0xbe329ff7, 0xbc5fc4c7), + TOBN(0x835a2aea, 0x60fa9dda), TOBN(0xf117f5ad, 0x7445cb87)}}, + {{TOBN(0xae8317f4, 0xb0166f7a), TOBN(0xfbd3e3f7, 0xceec74e6), + TOBN(0xfdb516ac, 0xe0874bfd), TOBN(0x3d846019, 0xc681f3a3)}, + {TOBN(0x0b12ee5c, 0x7c1620b0), TOBN(0xba68b4dd, 0x2b63c501), + TOBN(0xac03cd32, 0x6668c51e), TOBN(0x2a6279f7, 0x4e0bcb5b)}}, + {{TOBN(0x17bd69b0, 0x6ae85c10), TOBN(0x72946979, 0x1dfdd3a6), + TOBN(0xd9a03268, 0x2c078bec), TOBN(0x41c6a658, 0xbfd68a52)}, + {TOBN(0xcdea1024, 0x0e023900), TOBN(0xbaeec121, 0xb10d144d), + TOBN(0x5a600e74, 0x058ab8dc), TOBN(0x1333af21, 0xbb89ccdd)}}, + {{TOBN(0xdf25eae0, 0x3aaba1f1), TOBN(0x2cada16e, 0x3b7144cf), + TOBN(0x657ee27d, 0x71ab98bc), TOBN(0x99088b4c, 0x7a6fc96e)}, + {TOBN(0x05d5c0a0, 0x3549dbd4), TOBN(0x42cbdf8f, 0xf158c3ac), + TOBN(0x3fb6b3b0, 0x87edd685), TOBN(0x22071cf6, 0x86f064d0)}}, + {{TOBN(0xd2d6721f, 0xff2811e5), TOBN(0xdb81b703, 0xfe7fae8c), + TOBN(0x3cfb74ef, 0xd3f1f7bb), TOBN(0x0cdbcd76, 0x16cdeb5d)}, + {TOBN(0x4f39642a, 0x566a808c), TOBN(0x02b74454, 0x340064d6), + TOBN(0xfabbadca, 0x0528fa6f), TOBN(0xe4c3074c, 0xd3fc0bb6)}}, + {{TOBN(0xb32cb8b0, 0xb796d219), TOBN(0xc3e95f4f, 0x34741dd9), + TOBN(0x87212125, 0x68edf6f5), TOBN(0x7a03aee4, 0xa2b9cb8e)}, + {TOBN(0x0cd3c376, 0xf53a89aa), TOBN(0x0d8af9b1, 0x948a28dc), + TOBN(0xcf86a3f4, 0x902ab04f), TOBN(0x8aacb62a, 0x7f42002d)}}, + {{TOBN(0x106985eb, 0xf62ffd52), TOBN(0xe670b54e, 0x5797bf10), + TOBN(0x4b405209, 0xc5e30aef), TOBN(0x12c97a20, 0x4365b5e9)}, + {TOBN(0x104646ce, 0x1fe32093), TOBN(0x13cb4ff6, 0x3907a8c9), + TOBN(0x8b9f30d1, 0xd46e726b), TOBN(0xe1985e21, 0xaba0f499)}}, + {{TOBN(0xc573dea9, 0x10a230cd), TOBN(0x24f46a93, 0xcd30f947), + TOBN(0xf2623fcf, 0xabe2010a), TOBN(0x3f278cb2, 0x73f00e4f)}, + {TOBN(0xed55c67d, 0x50b920eb), TOBN(0xf1cb9a2d, 0x8e760571), + TOBN(0x7c50d109, 0x0895b709), TOBN(0x4207cf07, 0x190d4369)}}, + {{TOBN(0x3b027e81, 0xc4127fe1), TOBN(0xa9f8b9ad, 0x3ae9c566), + TOBN(0x5ab10851, 0xacbfbba5), TOBN(0xa747d648, 0x569556f5)}, + {TOBN(0xcc172b5c, 0x2ba97bf7), TOBN(0x15e0f77d, 0xbcfa3324), + TOBN(0xa345b797, 0x7686279d), TOBN(0x5a723480, 0xe38003d3)}}, + {{TOBN(0xfd8e139f, 0x8f5fcda8), TOBN(0xf3e558c4, 0xbdee5bfd), + TOBN(0xd76cbaf4, 0xe33f9f77), TOBN(0x3a4c97a4, 0x71771969)}, + {TOBN(0xda27e84b, 0xf6dce6a7), TOBN(0xff373d96, 0x13e6c2d1), + TOBN(0xf115193c, 0xd759a6e9), TOBN(0x3f9b7025, 0x63d2262c)}}, + {{TOBN(0xd9764a31, 0x317cd062), TOBN(0x30779d8e, 0x199f8332), + TOBN(0xd8074106, 0x16b11b0b), TOBN(0x7917ab9f, 0x78aeaed8)}, + {TOBN(0xb67a9cbe, 0x28fb1d8e), TOBN(0x2e313563, 0x136eda33), + TOBN(0x010b7069, 0xa371a86c), TOBN(0x44d90fa2, 0x6744e6b7)}}, + {{TOBN(0x68190867, 0xd6b3e243), TOBN(0x9fe6cd9d, 0x59048c48), + TOBN(0xb900b028, 0x95731538), TOBN(0xa012062f, 0x32cae04f)}, + {TOBN(0x8107c8bc, 0x9399d082), TOBN(0x47e8c54a, 0x41df12e2), + TOBN(0x14ba5117, 0xb6ef3f73), TOBN(0x22260bea, 0x81362f0b)}}, + {{TOBN(0x90ea261e, 0x1a18cc20), TOBN(0x2192999f, 0x2321d636), + TOBN(0xef64d314, 0xe311b6a0), TOBN(0xd7401e4c, 0x3b54a1f5)}, + {TOBN(0x19019983, 0x6fbca2ba), TOBN(0x46ad3293, 0x8fbffc4b), + TOBN(0xa142d3f6, 0x3786bf40), TOBN(0xeb5cbc26, 0xb67039fc)}}, + {{TOBN(0x9cb0ae6c, 0x252bd479), TOBN(0x05e0f88a, 0x12b5848f), + TOBN(0x78f6d2b2, 0xa5c97663), TOBN(0x6f6e149b, 0xc162225c)}, + {TOBN(0xe602235c, 0xde601a89), TOBN(0xd17bbe98, 0xf373be1f), + TOBN(0xcaf49a5b, 0xa8471827), TOBN(0x7e1a0a85, 0x18aaa116)}}, + {{TOBN(0x6c833196, 0x270580c3), TOBN(0x1e233839, 0xf1c98a14), + TOBN(0x67b2f7b4, 0xae34e0a5), TOBN(0x47ac8745, 0xd8ce7289)}, + {TOBN(0x2b74779a, 0x100dd467), TOBN(0x274a4337, 0x4ee50d09), + TOBN(0x603dcf13, 0x83608bc9), TOBN(0xcd9da6c3, 0xc89e8388)}}, + {{TOBN(0x2660199f, 0x355116ac), TOBN(0xcc38bb59, 0xb6d18eed), + TOBN(0x3075f31f, 0x2f4bc071), TOBN(0x9774457f, 0x265dc57e)}, + {TOBN(0x06a6a9c8, 0xc6db88bb), TOBN(0x6429d07f, 0x4ec98e04), + TOBN(0x8d05e57b, 0x05ecaa8b), TOBN(0x20f140b1, 0x7872ea7b)}}, + {{TOBN(0xdf8c0f09, 0xca494693), TOBN(0x48d3a020, 0xf252e909), + TOBN(0x4c5c29af, 0x57b14b12), TOBN(0x7e6fa37d, 0xbf47ad1c)}, + {TOBN(0x66e7b506, 0x49a0c938), TOBN(0xb72c0d48, 0x6be5f41f), + TOBN(0x6a6242b8, 0xb2359412), TOBN(0xcd35c774, 0x8e859480)}}, + {{TOBN(0x12536fea, 0x87baa627), TOBN(0x58c1fec1, 0xf72aa680), + TOBN(0x6c29b637, 0x601e5dc9), TOBN(0x9e3c3c1c, 0xde9e01b9)}, + {TOBN(0xefc8127b, 0x2bcfe0b0), TOBN(0x35107102, 0x2a12f50d), + TOBN(0x6ccd6cb1, 0x4879b397), TOBN(0xf792f804, 0xf8a82f21)}}, + {{TOBN(0x509d4804, 0xa9b46402), TOBN(0xedddf85d, 0xc10f0850), + TOBN(0x928410dc, 0x4b6208aa), TOBN(0xf6229c46, 0x391012dc)}, + {TOBN(0xc5a7c41e, 0x7727b9b6), TOBN(0x289e4e4b, 0xaa444842), + TOBN(0x049ba1d9, 0xe9a947ea), TOBN(0x44f9e47f, 0x83c8debc)}}, + {{TOBN(0xfa77a1fe, 0x611f8b8e), TOBN(0xfd2e416a, 0xf518f427), + TOBN(0xc5fffa70, 0x114ebac3), TOBN(0xfe57c4e9, 0x5d89697b)}, + {TOBN(0xfdd053ac, 0xb1aaf613), TOBN(0x31df210f, 0xea585a45), + TOBN(0x318cc10e, 0x24985034), TOBN(0x1a38efd1, 0x5f1d6130)}}, + {{TOBN(0xbf86f237, 0x0b1e9e21), TOBN(0xb258514d, 0x1dbe88aa), + TOBN(0x1e38a588, 0x90c1baf9), TOBN(0x2936a01e, 0xbdb9b692)}, + {TOBN(0xd576de98, 0x6dd5b20c), TOBN(0xb586bf71, 0x70f98ecf), + TOBN(0xcccf0f12, 0xc42d2fd7), TOBN(0x8717e61c, 0xfb35bd7b)}}, + {{TOBN(0x8b1e5722, 0x35e6fc06), TOBN(0x3477728f, 0x0b3e13d5), + TOBN(0x150c294d, 0xaa8a7372), TOBN(0xc0291d43, 0x3bfa528a)}, + {TOBN(0xc6c8bc67, 0xcec5a196), TOBN(0xdeeb31e4, 0x5c2e8a7c), + TOBN(0xba93e244, 0xfb6e1c51), TOBN(0xb9f8b71b, 0x2e28e156)}}, + {{TOBN(0xce65a287, 0x968a2ab9), TOBN(0xe3c5ce69, 0x46bbcb1f), + TOBN(0xf8c835b9, 0xe7ae3f30), TOBN(0x16bbee26, 0xff72b82b)}, + {TOBN(0x665e2017, 0xfd42cd22), TOBN(0x1e139970, 0xf8b1d2a0), + TOBN(0x125cda29, 0x79204932), TOBN(0x7aee94a5, 0x49c3bee5)}}, + {{TOBN(0x68c70160, 0x89821a66), TOBN(0xf7c37678, 0x8f981669), + TOBN(0xd90829fc, 0x48cc3645), TOBN(0x346af049, 0xd70addfc)}, + {TOBN(0x2057b232, 0x370bf29c), TOBN(0xf90c73ce, 0x42e650ee), + TOBN(0xe03386ea, 0xa126ab90), TOBN(0x0e266e7e, 0x975a087b)}}, + {{TOBN(0x80578eb9, 0x0fca65d9), TOBN(0x7e2989ea, 0x16af45b8), + TOBN(0x7438212d, 0xcac75a4e), TOBN(0x38c7ca39, 0x4fef36b8)}, + {TOBN(0x8650c494, 0xd402676a), TOBN(0x26ab5a66, 0xf72c7c48), + TOBN(0x4e6cb426, 0xce3a464e), TOBN(0xf8f99896, 0x2b72f841)}}, + {{TOBN(0x8c318491, 0x1a335cc8), TOBN(0x563459ba, 0x6a5913e4), + TOBN(0x1b920d61, 0xc7b32919), TOBN(0x805ab8b6, 0xa02425ad)}, + {TOBN(0x2ac512da, 0x8d006086), TOBN(0x6ca4846a, 0xbcf5c0fd), + TOBN(0xafea51d8, 0xac2138d7), TOBN(0xcb647545, 0x344cd443)}}, + {{TOBN(0x0429ee8f, 0xbd7d9040), TOBN(0xee66a2de, 0x819b9c96), + TOBN(0x54f9ec25, 0xdea7d744), TOBN(0x2ffea642, 0x671721bb)}, + {TOBN(0x4f19dbd1, 0x114344ea), TOBN(0x04304536, 0xfd0dbc8b), + TOBN(0x014b50aa, 0x29ec7f91), TOBN(0xb5fc22fe, 0xbb06014d)}}, + {{TOBN(0x60d963a9, 0x1ee682e0), TOBN(0xdf48abc0, 0xfe85c727), + TOBN(0x0cadba13, 0x2e707c2d), TOBN(0xde608d3a, 0xa645aeff)}, + {TOBN(0x05f1c28b, 0xedafd883), TOBN(0x3c362ede, 0xbd94de1f), + TOBN(0x8dd0629d, 0x13593e41), TOBN(0x0a5e736f, 0x766d6eaf)}}, + {{TOBN(0xbfa92311, 0xf68cf9d1), TOBN(0xa4f9ef87, 0xc1797556), + TOBN(0x10d75a1f, 0x5601c209), TOBN(0x651c374c, 0x09b07361)}, + {TOBN(0x49950b58, 0x88b5cead), TOBN(0x0ef00058, 0x6fa9dbaa), + TOBN(0xf51ddc26, 0x4e15f33a), TOBN(0x1f8b5ca6, 0x2ef46140)}}, + {{TOBN(0x343ac0a3, 0xee9523f0), TOBN(0xbb75eab2, 0x975ea978), + TOBN(0x1bccf332, 0x107387f4), TOBN(0x790f9259, 0x9ab0062e)}, + {TOBN(0xf1a363ad, 0x1e4f6a5f), TOBN(0x06e08b84, 0x62519a50), + TOBN(0x60915187, 0x7265f1ee), TOBN(0x6a80ca34, 0x93ae985e)}}, + {{TOBN(0x81b29768, 0xaaba4864), TOBN(0xb13cabf2, 0x8d52a7d6), + TOBN(0xb5c36348, 0x8ead03f1), TOBN(0xc932ad95, 0x81c7c1c0)}, + {TOBN(0x5452708e, 0xcae1e27b), TOBN(0x9dac4269, 0x1b0df648), + TOBN(0x233e3f0c, 0xdfcdb8bc), TOBN(0xe6ceccdf, 0xec540174)}}, + {{TOBN(0xbd0d845e, 0x95081181), TOBN(0xcc8a7920, 0x699355d5), + TOBN(0x111c0f6d, 0xc3b375a8), TOBN(0xfd95bc6b, 0xfd51e0dc)}, + {TOBN(0x4a106a26, 0x6888523a), TOBN(0x4d142bd6, 0xcb01a06d), + TOBN(0x79bfd289, 0xadb9b397), TOBN(0x0bdbfb94, 0xe9863914)}}, + {{TOBN(0x29d8a229, 0x1660f6a6), TOBN(0x7f6abcd6, 0x551c042d), + TOBN(0x13039deb, 0x0ac3ffe8), TOBN(0xa01be628, 0xec8523fb)}, + {TOBN(0x6ea34103, 0x0ca1c328), TOBN(0xc74114bd, 0xb903928e), + TOBN(0x8aa4ff4e, 0x9e9144b0), TOBN(0x7064091f, 0x7f9a4b17)}}, + {{TOBN(0xa3f4f521, 0xe447f2c4), TOBN(0x81b8da7a, 0x604291f0), + TOBN(0xd680bc46, 0x7d5926de), TOBN(0x84f21fd5, 0x34a1202f)}, + {TOBN(0x1d1e3181, 0x4e9df3d8), TOBN(0x1ca4861a, 0x39ab8d34), + TOBN(0x809ddeec, 0x5b19aa4a), TOBN(0x59f72f7e, 0x4d329366)}}, + {{TOBN(0xa2f93f41, 0x386d5087), TOBN(0x40bf739c, 0xdd67d64f), + TOBN(0xb4494205, 0x66702158), TOBN(0xc33c65be, 0x73b1e178)}, + {TOBN(0xcdcd657c, 0x38ca6153), TOBN(0x97f4519a, 0xdc791976), + TOBN(0xcc7c7f29, 0xcd6e1f39), TOBN(0x38de9cfb, 0x7e3c3932)}}, + {{TOBN(0xe448eba3, 0x7b793f85), TOBN(0xe9f8dbf9, 0xf067e914), + TOBN(0xc0390266, 0xf114ae87), TOBN(0x39ed75a7, 0xcd6a8e2a)}, + {TOBN(0xadb14848, 0x7ffba390), TOBN(0x67f8cb8b, 0x6af9bc09), + TOBN(0x322c3848, 0x9c7476db), TOBN(0xa320fecf, 0x52a538d6)}}, + {{TOBN(0xe0493002, 0xb2aced2b), TOBN(0xdfba1809, 0x616bd430), + TOBN(0x531c4644, 0xc331be70), TOBN(0xbc04d32e, 0x90d2e450)}, + {TOBN(0x1805a0d1, 0x0f9f142d), TOBN(0x2c44a0c5, 0x47ee5a23), + TOBN(0x31875a43, 0x3989b4e3), TOBN(0x6b1949fd, 0x0c063481)}}, + {{TOBN(0x2dfb9e08, 0xbe0f4492), TOBN(0x3ff0da03, 0xe9d5e517), + TOBN(0x03dbe9a1, 0xf79466a8), TOBN(0x0b87bcd0, 0x15ea9932)}, + {TOBN(0xeb64fc83, 0xab1f58ab), TOBN(0x6d9598da, 0x817edc8a), + TOBN(0x699cff66, 0x1d3b67e5), TOBN(0x645c0f29, 0x92635853)}}, + {{TOBN(0x253cdd82, 0xeabaf21c), TOBN(0x82b9602a, 0x2241659e), + TOBN(0x2cae07ec, 0x2d9f7091), TOBN(0xbe4c720c, 0x8b48cd9b)}, + {TOBN(0x6ce5bc03, 0x6f08d6c9), TOBN(0x36e8a997, 0xaf10bf40), + TOBN(0x83422d21, 0x3e10ff12), TOBN(0x7b26d3eb, 0xbcc12494)}}, + {{TOBN(0xb240d2d0, 0xc9469ad6), TOBN(0xc4a11b4d, 0x30afa05b), + TOBN(0x4b604ace, 0xdd6ba286), TOBN(0x18486600, 0x3ee2864c)}, + {TOBN(0x5869d6ba, 0x8d9ce5be), TOBN(0x0d8f68c5, 0xff4bfb0d), + TOBN(0xb69f210b, 0x5700cf73), TOBN(0x61f6653a, 0x6d37c135)}}, + {{TOBN(0xff3d432b, 0x5aff5a48), TOBN(0x0d81c4b9, 0x72ba3a69), + TOBN(0xee879ae9, 0xfa1899ef), TOBN(0xbac7e2a0, 0x2d6acafd)}, + {TOBN(0xd6d93f6c, 0x1c664399), TOBN(0x4c288de1, 0x5bcb135d), + TOBN(0x83031dab, 0x9dab7cbf), TOBN(0xfe23feb0, 0x3abbf5f0)}}, + {{TOBN(0x9f1b2466, 0xcdedca85), TOBN(0x140bb710, 0x1a09538c), + TOBN(0xac8ae851, 0x5e11115d), TOBN(0x0d63ff67, 0x6f03f59e)}, + {TOBN(0x755e5551, 0x7d234afb), TOBN(0x61c2db4e, 0x7e208fc1), + TOBN(0xaa9859ce, 0xf28a4b5d), TOBN(0xbdd6d4fc, 0x34af030f)}}, + {{TOBN(0xd1c4a26d, 0x3be01cb1), TOBN(0x9ba14ffc, 0x243aa07c), + TOBN(0xf95cd3a9, 0xb2503502), TOBN(0xe379bc06, 0x7d2a93ab)}, + {TOBN(0x3efc18e9, 0xd4ca8d68), TOBN(0x083558ec, 0x80bb412a), + TOBN(0xd903b940, 0x9645a968), TOBN(0xa499f0b6, 0x9ba6054f)}}, + {{TOBN(0x208b573c, 0xb8349abe), TOBN(0x3baab3e5, 0x30b4fc1c), + TOBN(0x87e978ba, 0xcb524990), TOBN(0x3524194e, 0xccdf0e80)}, + {TOBN(0x62711725, 0x7d4bcc42), TOBN(0xe90a3d9b, 0xb90109ba), + TOBN(0x3b1bdd57, 0x1323e1e0), TOBN(0xb78e9bd5, 0x5eae1599)}}, + {{TOBN(0x0794b746, 0x9e03d278), TOBN(0x80178605, 0xd70e6297), + TOBN(0x171792f8, 0x99c97855), TOBN(0x11b393ee, 0xf5a86b5c)}, + {TOBN(0x48ef6582, 0xd8884f27), TOBN(0xbd44737a, 0xbf19ba5f), + TOBN(0x8698de4c, 0xa42062c6), TOBN(0x8975eb80, 0x61ce9c54)}}, + {{TOBN(0xd50e57c7, 0xd7fe71f3), TOBN(0x15342190, 0xbc97ce38), + TOBN(0x51bda2de, 0x4df07b63), TOBN(0xba12aeae, 0x200eb87d)}, + {TOBN(0xabe135d2, 0xa9b4f8f6), TOBN(0x04619d65, 0xfad6d99c), + TOBN(0x4a6683a7, 0x7994937c), TOBN(0x7a778c8b, 0x6f94f09a)}}, + {{TOBN(0x8c508623, 0x20a71b89), TOBN(0x241a2aed, 0x1c229165), + TOBN(0x352be595, 0xaaf83a99), TOBN(0x9fbfee7f, 0x1562bac8)}, + {TOBN(0xeaf658b9, 0x5c4017e3), TOBN(0x1dc7f9e0, 0x15120b86), + TOBN(0xd84f13dd, 0x4c034d6f), TOBN(0x283dd737, 0xeaea3038)}}, + {{TOBN(0x197f2609, 0xcd85d6a2), TOBN(0x6ebbc345, 0xfae60177), + TOBN(0xb80f031b, 0x4e12fede), TOBN(0xde55d0c2, 0x07a2186b)}, + {TOBN(0x1fb3e37f, 0x24dcdd5a), TOBN(0x8d602da5, 0x7ed191fb), + TOBN(0x108fb056, 0x76023e0d), TOBN(0x70178c71, 0x459c20c0)}}, + {{TOBN(0xfad5a386, 0x3fe54cf0), TOBN(0xa4a3ec4f, 0x02bbb475), + TOBN(0x1aa5ec20, 0x919d94d7), TOBN(0x5d3b63b5, 0xa81e4ab3)}, + {TOBN(0x7fa733d8, 0x5ad3d2af), TOBN(0xfbc586dd, 0xd1ac7a37), + TOBN(0x282925de, 0x40779614), TOBN(0xfe0ffffb, 0xe74a242a)}}, + {{TOBN(0x3f39e67f, 0x906151e5), TOBN(0xcea27f5f, 0x55e10649), + TOBN(0xdca1d4e1, 0xc17cf7b7), TOBN(0x0c326d12, 0x2fe2362d)}, + {TOBN(0x05f7ac33, 0x7dd35df3), TOBN(0x0c3b7639, 0xc396dbdf), + TOBN(0x0912f5ac, 0x03b7db1c), TOBN(0x9dea4b70, 0x5c9ed4a9)}}, + {{TOBN(0x475e6e53, 0xaae3f639), TOBN(0xfaba0e7c, 0xfc278bac), + TOBN(0x16f9e221, 0x9490375f), TOBN(0xaebf9746, 0xa5a7ed0a)}, + {TOBN(0x45f9af3f, 0xf41ad5d6), TOBN(0x03c4623c, 0xb2e99224), + TOBN(0x82c5bb5c, 0xb3cf56aa), TOBN(0x64311819, 0x34567ed3)}}, + {{TOBN(0xec57f211, 0x8be489ac), TOBN(0x2821895d, 0xb9a1104b), + TOBN(0x610dc875, 0x6064e007), TOBN(0x8e526f3f, 0x5b20d0fe)}, + {TOBN(0x6e71ca77, 0x5b645aee), TOBN(0x3d1dcb9f, 0x800e10ff), + TOBN(0x36b51162, 0x189cf6de), TOBN(0x2c5a3e30, 0x6bb17353)}}, + {{TOBN(0xc186cd3e, 0x2a6c6fbf), TOBN(0xa74516fa, 0x4bf97906), + TOBN(0x5b4b8f4b, 0x279d6901), TOBN(0x0c4e57b4, 0x2b573743)}, + {TOBN(0x75fdb229, 0xb6e386b6), TOBN(0xb46793fd, 0x99deac27), + TOBN(0xeeec47ea, 0xcf712629), TOBN(0xe965f3c4, 0xcbc3b2dd)}}, + {{TOBN(0x8dd1fb83, 0x425c6559), TOBN(0x7fc00ee6, 0x0af06fda), + TOBN(0xe98c9225, 0x33d956df), TOBN(0x0f1ef335, 0x4fbdc8a2)}, + {TOBN(0x2abb5145, 0xb79b8ea2), TOBN(0x40fd2945, 0xbdbff288), + TOBN(0x6a814ac4, 0xd7185db7), TOBN(0xc4329d6f, 0xc084609a)}}, + {{TOBN(0xc9ba7b52, 0xed1be45d), TOBN(0x891dd20d, 0xe4cd2c74), + TOBN(0x5a4d4a7f, 0x824139b1), TOBN(0x66c17716, 0xb873c710)}, + {TOBN(0x5e5bc141, 0x2843c4e0), TOBN(0xd5ac4817, 0xb97eb5bf), + TOBN(0xc0f8af54, 0x450c95c7), TOBN(0xc91b3fa0, 0x318406c5)}}, + {{TOBN(0x360c340a, 0xab9d97f8), TOBN(0xfb57bd07, 0x90a2d611), + TOBN(0x4339ae3c, 0xa6a6f7e5), TOBN(0x9c1fcd2a, 0x2feb8a10)}, + {TOBN(0x972bcca9, 0xc7ea7432), TOBN(0x1b0b924c, 0x308076f6), + TOBN(0x80b2814a, 0x2a5b4ca5), TOBN(0x2f78f55b, 0x61ef3b29)}}, + {{TOBN(0xf838744a, 0xc18a414f), TOBN(0xc611eaae, 0x903d0a86), + TOBN(0x94dabc16, 0x2a453f55), TOBN(0xe6f2e3da, 0x14efb279)}, + {TOBN(0x5b7a6017, 0x9320dc3c), TOBN(0x692e382f, 0x8df6b5a4), + TOBN(0x3f5e15e0, 0x2d40fa90), TOBN(0xc87883ae, 0x643dd318)}}, + {{TOBN(0x511053e4, 0x53544774), TOBN(0x834d0ecc, 0x3adba2bc), + TOBN(0x4215d7f7, 0xbae371f5), TOBN(0xfcfd57bf, 0x6c8663bc)}, + {TOBN(0xded2383d, 0xd6901b1d), TOBN(0x3b49fbb4, 0xb5587dc3), + TOBN(0xfd44a08d, 0x07625f62), TOBN(0x3ee4d65b, 0x9de9b762)}}}, + {{{TOBN(0x64e5137d, 0x0d63d1fa), TOBN(0x658fc052, 0x02a9d89f), + TOBN(0x48894874, 0x50436309), TOBN(0xe9ae30f8, 0xd598da61)}, + {TOBN(0x2ed710d1, 0x818baf91), TOBN(0xe27e9e06, 0x8b6a0c20), + TOBN(0x1e28dcfb, 0x1c1a6b44), TOBN(0x883acb64, 0xd6ac57dc)}}, + {{TOBN(0x8735728d, 0xc2c6ff70), TOBN(0x79d6122f, 0xc5dc2235), + TOBN(0x23f5d003, 0x19e277f9), TOBN(0x7ee84e25, 0xdded8cc7)}, + {TOBN(0x91a8afb0, 0x63cd880a), TOBN(0x3f3ea7c6, 0x3574af60), + TOBN(0x0cfcdc84, 0x02de7f42), TOBN(0x62d0792f, 0xb31aa152)}}, + {{TOBN(0x8e1b4e43, 0x8a5807ce), TOBN(0xad283893, 0xe4109a7e), + TOBN(0xc30cc9cb, 0xafd59dda), TOBN(0xf65f36c6, 0x3d8d8093)}, + {TOBN(0xdf31469e, 0xa60d32b2), TOBN(0xee93df4b, 0x3e8191c8), + TOBN(0x9c1017c5, 0x355bdeb5), TOBN(0xd2623185, 0x8616aa28)}}, + {{TOBN(0xb02c83f9, 0xdec31a21), TOBN(0x988c8b23, 0x6ad9d573), + TOBN(0x53e983ae, 0xa57be365), TOBN(0xe968734d, 0x646f834e)}, + {TOBN(0x9137ea8f, 0x5da6309b), TOBN(0x10f3a624, 0xc1f1ce16), + TOBN(0x782a9ea2, 0xca440921), TOBN(0xdf94739e, 0x5b46f1b5)}}, + {{TOBN(0x9f9be006, 0xcce85c9b), TOBN(0x360e70d6, 0xa4c7c2d3), + TOBN(0x2cd5beea, 0xaefa1e60), TOBN(0x64cf63c0, 0x8c3d2b6d)}, + {TOBN(0xfb107fa3, 0xe1cf6f90), TOBN(0xb7e937c6, 0xd5e044e6), + TOBN(0x74e8ca78, 0xce34db9f), TOBN(0x4f8b36c1, 0x3e210bd0)}}, + {{TOBN(0x1df165a4, 0x34a35ea8), TOBN(0x3418e0f7, 0x4d4412f6), + TOBN(0x5af1f8af, 0x518836c3), TOBN(0x42ceef4d, 0x130e1965)}, + {TOBN(0x5560ca0b, 0x543a1957), TOBN(0xc33761e5, 0x886cb123), + TOBN(0x66624b1f, 0xfe98ed30), TOBN(0xf772f4bf, 0x1090997d)}}, + {{TOBN(0xf4e540bb, 0x4885d410), TOBN(0x7287f810, 0x9ba5f8d7), + TOBN(0x22d0d865, 0xde98dfb1), TOBN(0x49ff51a1, 0xbcfbb8a3)}, + {TOBN(0xb6b6fa53, 0x6bc3012e), TOBN(0x3d31fd72, 0x170d541d), + TOBN(0x8018724f, 0x4b0f4966), TOBN(0x79e7399f, 0x87dbde07)}}, + {{TOBN(0x56f8410e, 0xf4f8b16a), TOBN(0x97241afe, 0xc47b266a), + TOBN(0x0a406b8e, 0x6d9c87c1), TOBN(0x803f3e02, 0xcd42ab1b)}, + {TOBN(0x7f0309a8, 0x04dbec69), TOBN(0xa83b85f7, 0x3bbad05f), + TOBN(0xc6097273, 0xad8e197f), TOBN(0xc097440e, 0x5067adc1)}}, + {{TOBN(0x730eafb6, 0x3524ff16), TOBN(0xd7f9b51e, 0x823fc6ce), + TOBN(0x27bd0d32, 0x443e4ac0), TOBN(0x40c59ad9, 0x4d66f217)}, + {TOBN(0x6c33136f, 0x17c387a4), TOBN(0x5043b8d5, 0xeb86804d), + TOBN(0x74970312, 0x675a73c9), TOBN(0x838fdb31, 0xf16669b6)}}, + {{TOBN(0xc507b6dd, 0x418e7ddd), TOBN(0x39888d93, 0x472f19d6), + TOBN(0x7eae26be, 0x0c27eb4d), TOBN(0x17b53ed3, 0xfbabb884)}, + {TOBN(0xfc27021b, 0x2b01ae4f), TOBN(0x88462e87, 0xcf488682), + TOBN(0xbee096ec, 0x215e2d87), TOBN(0xeb2fea9a, 0xd242e29b)}}, + {{TOBN(0x5d985b5f, 0xb821fc28), TOBN(0x89d2e197, 0xdc1e2ad2), + TOBN(0x55b566b8, 0x9030ba62), TOBN(0xe3fd41b5, 0x4f41b1c6)}, + {TOBN(0xb738ac2e, 0xb9a96d61), TOBN(0x7f8567ca, 0x369443f4), + TOBN(0x8698622d, 0xf803a440), TOBN(0x2b586236, 0x8fe2f4dc)}}, + {{TOBN(0xbbcc00c7, 0x56b95bce), TOBN(0x5ec03906, 0x616da680), + TOBN(0x79162ee6, 0x72214252), TOBN(0x43132b63, 0x86a892d2)}, + {TOBN(0x4bdd3ff2, 0x2f3263bf), TOBN(0xd5b3733c, 0x9cd0a142), + TOBN(0x592eaa82, 0x44415ccb), TOBN(0x663e8924, 0x8d5474ea)}}, + {{TOBN(0x8058a25e, 0x5236344e), TOBN(0x82e8df9d, 0xbda76ee6), + TOBN(0xdcf6efd8, 0x11cc3d22), TOBN(0x00089cda, 0x3b4ab529)}, + {TOBN(0x91d3a071, 0xbd38a3db), TOBN(0x4ea97fc0, 0xef72b925), + TOBN(0x0c9fc15b, 0xea3edf75), TOBN(0x5a6297cd, 0xa4348ed3)}}, + {{TOBN(0x0d38ab35, 0xce7c42d4), TOBN(0x9fd493ef, 0x82feab10), + TOBN(0x46056b6d, 0x82111b45), TOBN(0xda11dae1, 0x73efc5c3)}, + {TOBN(0xdc740278, 0x5545a7fb), TOBN(0xbdb2601c, 0x40d507e6), + TOBN(0x121dfeeb, 0x7066fa58), TOBN(0x214369a8, 0x39ae8c2a)}}, + {{TOBN(0x195709cb, 0x06e0956c), TOBN(0x4c9d254f, 0x010cd34b), + TOBN(0xf51e13f7, 0x0471a532), TOBN(0xe19d6791, 0x1e73054d)}, + {TOBN(0xf702a628, 0xdb5c7be3), TOBN(0xc7141218, 0xb24dde05), + TOBN(0xdc18233c, 0xf29b2e2e), TOBN(0x3a6bd1e8, 0x85342dba)}}, + {{TOBN(0x3f747fa0, 0xb311898c), TOBN(0xe2a272e4, 0xcd0eac65), + TOBN(0x4bba5851, 0xf914d0bc), TOBN(0x7a1a9660, 0xc4a43ee3)}, + {TOBN(0xe5a367ce, 0xa1c8cde9), TOBN(0x9d958ba9, 0x7271abe3), + TOBN(0xf3ff7eb6, 0x3d1615cd), TOBN(0xa2280dce, 0xf5ae20b0)}}, + {{TOBN(0x56dba5c1, 0xcf640147), TOBN(0xea5a2e3d, 0x5e83d118), + TOBN(0x04cd6b6d, 0xda24c511), TOBN(0x1c0f4671, 0xe854d214)}, + {TOBN(0x91a6b7a9, 0x69565381), TOBN(0xdc966240, 0xdecf1f5b), + TOBN(0x1b22d21c, 0xfcf5d009), TOBN(0x2a05f641, 0x9021dbd5)}}, + {{TOBN(0x8c0ed566, 0xd4312483), TOBN(0x5179a95d, 0x643e216f), + TOBN(0xcc185fec, 0x17044493), TOBN(0xb3063339, 0x54991a21)}, + {TOBN(0xd801ecdb, 0x0081a726), TOBN(0x0149b0c6, 0x4fa89bbb), + TOBN(0xafe9065a, 0x4391b6b9), TOBN(0xedc92786, 0xd633f3a3)}}, + {{TOBN(0xe408c24a, 0xae6a8e13), TOBN(0x85833fde, 0x9f3897ab), + TOBN(0x43800e7e, 0xd81a0715), TOBN(0xde08e346, 0xb44ffc5f)}, + {TOBN(0x7094184c, 0xcdeff2e0), TOBN(0x49f9387b, 0x165eaed1), + TOBN(0x635d6129, 0x777c468a), TOBN(0x8c0dcfd1, 0x538c2dd8)}}, + {{TOBN(0xd6d9d9e3, 0x7a6a308b), TOBN(0x62375830, 0x4c2767d3), + TOBN(0x874a8bc6, 0xf38cbeb6), TOBN(0xd94d3f1a, 0xccb6fd9e)}, + {TOBN(0x92a9735b, 0xba21f248), TOBN(0x272ad0e5, 0x6cd1efb0), + TOBN(0x7437b69c, 0x05b03284), TOBN(0xe7f04702, 0x6948c225)}}, + {{TOBN(0x8a56c04a, 0xcba2ecec), TOBN(0x0c181270, 0xe3a73e41), + TOBN(0x6cb34e9d, 0x03e93725), TOBN(0xf77c8713, 0x496521a9)}, + {TOBN(0x94569183, 0xfa7f9f90), TOBN(0xf2e7aa4c, 0x8c9707ad), + TOBN(0xced2c9ba, 0x26c1c9a3), TOBN(0x9109fe96, 0x40197507)}}, + {{TOBN(0x9ae868a9, 0xe9adfe1c), TOBN(0x3984403d, 0x314e39bb), + TOBN(0xb5875720, 0xf2fe378f), TOBN(0x33f901e0, 0xba44a628)}, + {TOBN(0xea1125fe, 0x3652438c), TOBN(0xae9ec4e6, 0x9dd1f20b), + TOBN(0x1e740d9e, 0xbebf7fbd), TOBN(0x6dbd3ddc, 0x42dbe79c)}}, + {{TOBN(0x62082aec, 0xedd36776), TOBN(0xf612c478, 0xe9859039), + TOBN(0xa493b201, 0x032f7065), TOBN(0xebd4d8f2, 0x4ff9b211)}, + {TOBN(0x3f23a0aa, 0xaac4cb32), TOBN(0xea3aadb7, 0x15ed4005), + TOBN(0xacf17ea4, 0xafa27e63), TOBN(0x56125c1a, 0xc11fd66c)}}, + {{TOBN(0x266344a4, 0x3794f8dc), TOBN(0xdcca923a, 0x483c5c36), + TOBN(0x2d6b6bbf, 0x3f9d10a0), TOBN(0xb320c5ca, 0x81d9bdf3)}, + {TOBN(0x620e28ff, 0x47b50a95), TOBN(0x933e3b01, 0xcef03371), + TOBN(0xf081bf85, 0x99100153), TOBN(0x183be9a0, 0xc3a8c8d6)}}, + {{TOBN(0x4e3ddc5a, 0xd6bbe24d), TOBN(0xc6c74630, 0x53843795), + TOBN(0x78193dd7, 0x65ec2d4c), TOBN(0xb8df26cc, 0xcd3c89b2)}, + {TOBN(0x98dbe399, 0x5a483f8d), TOBN(0x72d8a957, 0x7dd3313a), + TOBN(0x65087294, 0xab0bd375), TOBN(0xfcd89248, 0x7c259d16)}}, + {{TOBN(0x8a9443d7, 0x7613aa81), TOBN(0x80100800, 0x85fe6584), + TOBN(0x70fc4dbc, 0x7fb10288), TOBN(0xf58280d3, 0xe86beee8)}, + {TOBN(0x14fdd82f, 0x7c978c38), TOBN(0xdf1204c1, 0x0de44d7b), + TOBN(0xa08a1c84, 0x4160252f), TOBN(0x591554ca, 0xc17646a5)}}, + {{TOBN(0x214a37d6, 0xa05bd525), TOBN(0x48d5f09b, 0x07957b3c), + TOBN(0x0247cdcb, 0xd7109bc9), TOBN(0x40f9e4bb, 0x30599ce7)}, + {TOBN(0xc325fa03, 0xf46ad2ec), TOBN(0x00f766cf, 0xc3e3f9ee), + TOBN(0xab556668, 0xd43a4577), TOBN(0x68d30a61, 0x3ee03b93)}}, + {{TOBN(0x7ddc81ea, 0x77b46a08), TOBN(0xcf5a6477, 0xc7480699), + TOBN(0x43a8cb34, 0x6633f683), TOBN(0x1b867e6b, 0x92363c60)}, + {TOBN(0x43921114, 0x1f60558e), TOBN(0xcdbcdd63, 0x2f41450e), + TOBN(0x7fc04601, 0xcc630e8b), TOBN(0xea7c66d5, 0x97038b43)}}, + {{TOBN(0x7259b8a5, 0x04e99fd8), TOBN(0x98a8dd12, 0x4785549a), + TOBN(0x0e459a7c, 0x840552e1), TOBN(0xcdfcf4d0, 0x4bb0909e)}, + {TOBN(0x34a86db2, 0x53758da7), TOBN(0xe643bb83, 0xeac997e1), + TOBN(0x96400bd7, 0x530c5b7e), TOBN(0x9f97af87, 0xb41c8b52)}}, + {{TOBN(0x34fc8820, 0xfbeee3f9), TOBN(0x93e53490, 0x49091afd), + TOBN(0x764b9be5, 0x9a31f35c), TOBN(0x71f37864, 0x57e3d924)}, + {TOBN(0x02fb34e0, 0x943aa75e), TOBN(0xa18c9c58, 0xab8ff6e4), + TOBN(0x080f31b1, 0x33cf0d19), TOBN(0x5c9682db, 0x083518a7)}}, + {{TOBN(0x873d4ca6, 0xb709c3de), TOBN(0x64a84262, 0x3575b8f0), + TOBN(0x6275da1f, 0x020154bb), TOBN(0x97678caa, 0xd17cf1ab)}, + {TOBN(0x8779795f, 0x951a95c3), TOBN(0xdd35b163, 0x50fccc08), + TOBN(0x32709627, 0x33d8f031), TOBN(0x3c5ab10a, 0x498dd85c)}}, + {{TOBN(0xb6c185c3, 0x41dca566), TOBN(0x7de7feda, 0xd8622aa3), + TOBN(0x99e84d92, 0x901b6dfb), TOBN(0x30a02b0e, 0x7c4ad288)}, + {TOBN(0xc7c81daa, 0x2fd3cf36), TOBN(0xd1319547, 0xdf89e59f), + TOBN(0xb2be8184, 0xcd496733), TOBN(0xd5f449eb, 0x93d3412b)}}, + {{TOBN(0x7ea41b1b, 0x25fe531d), TOBN(0xf9797432, 0x6a1d5646), + TOBN(0x86067f72, 0x2bde501a), TOBN(0xf91481c0, 0x0c85e89c)}, + {TOBN(0xca8ee465, 0xf8b05bc6), TOBN(0x1844e1cf, 0x02e83cda), + TOBN(0xca82114a, 0xb4dbe33b), TOBN(0x0f9f8769, 0x4eabfde2)}}, + {{TOBN(0x4936b1c0, 0x38b27fe2), TOBN(0x63b6359b, 0xaba402df), + TOBN(0x40c0ea2f, 0x656bdbab), TOBN(0x9c992a89, 0x6580c39c)}, + {TOBN(0x600e8f15, 0x2a60aed1), TOBN(0xeb089ca4, 0xe0bf49df), + TOBN(0x9c233d7d, 0x2d42d99a), TOBN(0x648d3f95, 0x4c6bc2fa)}}, + {{TOBN(0xdcc383a8, 0xe1add3f3), TOBN(0xf42c0c6a, 0x4f64a348), + TOBN(0x2abd176f, 0x0030dbdb), TOBN(0x4de501a3, 0x7d6c215e)}, + {TOBN(0x4a107c1f, 0x4b9a64bc), TOBN(0xa77f0ad3, 0x2496cd59), + TOBN(0xfb78ac62, 0x7688dffb), TOBN(0x7025a2ca, 0x67937d8e)}}, + {{TOBN(0xfde8b2d1, 0xd1a8f4e7), TOBN(0xf5b3da47, 0x7354927c), + TOBN(0xe48606a3, 0xd9205735), TOBN(0xac477cc6, 0xe177b917)}, + {TOBN(0xfb1f73d2, 0xa883239a), TOBN(0xe12572f6, 0xcc8b8357), + TOBN(0x9d355e9c, 0xfb1f4f86), TOBN(0x89b795f8, 0xd9f3ec6e)}}, + {{TOBN(0x27be56f1, 0xb54398dc), TOBN(0x1890efd7, 0x3fedeed5), + TOBN(0x62f77f1f, 0x9c6d0140), TOBN(0x7ef0e314, 0x596f0ee4)}, + {TOBN(0x50ca6631, 0xcc61dab3), TOBN(0x4a39801d, 0xf4866e4f), + TOBN(0x66c8d032, 0xae363b39), TOBN(0x22c591e5, 0x2ead66aa)}}, + {{TOBN(0x954ba308, 0xde02a53e), TOBN(0x2a6c060f, 0xd389f357), + TOBN(0xe6cfcde8, 0xfbf40b66), TOBN(0x8e02fc56, 0xc6340ce1)}, + {TOBN(0xe4957795, 0x73adb4ba), TOBN(0x7b86122c, 0xa7b03805), + TOBN(0x63f83512, 0x0c8e6fa6), TOBN(0x83660ea0, 0x057d7804)}}, + {{TOBN(0xbad79105, 0x21ba473c), TOBN(0xb6c50bee, 0xded5389d), + TOBN(0xee2caf4d, 0xaa7c9bc0), TOBN(0xd97b8de4, 0x8c4e98a7)}, + {TOBN(0xa9f63e70, 0xab3bbddb), TOBN(0x3898aabf, 0x2597815a), + TOBN(0x7659af89, 0xac15b3d9), TOBN(0xedf7725b, 0x703ce784)}}, + {{TOBN(0x25470fab, 0xe085116b), TOBN(0x04a43375, 0x87285310), + TOBN(0x4e39187e, 0xe2bfd52f), TOBN(0x36166b44, 0x7d9ebc74)}, + {TOBN(0x92ad433c, 0xfd4b322c), TOBN(0x726aa817, 0xba79ab51), + TOBN(0xf96eacd8, 0xc1db15eb), TOBN(0xfaf71e91, 0x0476be63)}}, + {{TOBN(0xdd69a640, 0x641fad98), TOBN(0xb7995918, 0x29622559), + TOBN(0x03c6daa5, 0xde4199dc), TOBN(0x92cadc97, 0xad545eb4)}, + {TOBN(0x1028238b, 0x256534e4), TOBN(0x73e80ce6, 0x8595409a), + TOBN(0x690d4c66, 0xd05dc59b), TOBN(0xc95f7b8f, 0x981dee80)}}, + {{TOBN(0xf4337014, 0xd856ac25), TOBN(0x441bd9dd, 0xac524dca), + TOBN(0x640b3d85, 0x5f0499f5), TOBN(0x39cf84a9, 0xd5fda182)}, + {TOBN(0x04e7b055, 0xb2aa95a0), TOBN(0x29e33f0a, 0x0ddf1860), + TOBN(0x082e74b5, 0x423f6b43), TOBN(0x217edeb9, 0x0aaa2b0f)}}, + {{TOBN(0x58b83f35, 0x83cbea55), TOBN(0xc485ee4d, 0xbc185d70), + TOBN(0x833ff03b, 0x1e5f6992), TOBN(0xb5b9b9cc, 0xcf0c0dd5)}, + {TOBN(0x7caaee8e, 0x4e9e8a50), TOBN(0x462e907b, 0x6269dafd), + TOBN(0x6ed5cee9, 0xfbe791c6), TOBN(0x68ca3259, 0xed430790)}}, + {{TOBN(0x2b72bdf2, 0x13b5ba88), TOBN(0x60294c8a, 0x35ef0ac4), + TOBN(0x9c3230ed, 0x19b99b08), TOBN(0x560fff17, 0x6c2589aa)}, + {TOBN(0x552b8487, 0xd6770374), TOBN(0xa373202d, 0x9a56f685), + TOBN(0xd3e7f907, 0x45f175d9), TOBN(0x3c2f315f, 0xd080d810)}}, + {{TOBN(0x1130e9dd, 0x7b9520e8), TOBN(0xc078f9e2, 0x0af037b5), + TOBN(0x38cd2ec7, 0x1e9c104c), TOBN(0x0f684368, 0xc472fe92)}, + {TOBN(0xd3f1b5ed, 0x6247e7ef), TOBN(0xb32d33a9, 0x396dfe21), + TOBN(0x46f59cf4, 0x4a9aa2c2), TOBN(0x69cd5168, 0xff0f7e41)}}, + {{TOBN(0x3f59da0f, 0x4b3234da), TOBN(0xcf0b0235, 0xb4579ebe), + TOBN(0x6d1cbb25, 0x6d2476c7), TOBN(0x4f0837e6, 0x9dc30f08)}, + {TOBN(0x9a4075bb, 0x906f6e98), TOBN(0x253bb434, 0xc761e7d1), + TOBN(0xde2e645f, 0x6e73af10), TOBN(0xb89a4060, 0x0c5f131c)}}, + {{TOBN(0xd12840c5, 0xb8cc037f), TOBN(0x3d093a5b, 0x7405bb47), + TOBN(0x6202c253, 0x206348b8), TOBN(0xbf5d57fc, 0xc55a3ca7)}, + {TOBN(0x89f6c90c, 0x8c3bef48), TOBN(0x23ac7623, 0x5a0a960a), + TOBN(0xdfbd3d6b, 0x552b42ab), TOBN(0x3ef22458, 0x132061f6)}}, + {{TOBN(0xd74e9bda, 0xc97e6516), TOBN(0x88779360, 0xc230f49e), + TOBN(0xa6ec1de3, 0x1e74ea49), TOBN(0x581dcee5, 0x3fb645a2)}, + {TOBN(0xbaef2391, 0x8f483f14), TOBN(0x6d2dddfc, 0xd137d13b), + TOBN(0x54cde50e, 0xd2743a42), TOBN(0x89a34fc5, 0xe4d97e67)}}, + {{TOBN(0x13f1f5b3, 0x12e08ce5), TOBN(0xa80540b8, 0xa7f0b2ca), + TOBN(0x854bcf77, 0x01982805), TOBN(0xb8653ffd, 0x233bea04)}, + {TOBN(0x8e7b8787, 0x02b0b4c9), TOBN(0x2675261f, 0x9acb170a), + TOBN(0x061a9d90, 0x930c14e5), TOBN(0xb59b30e0, 0xdef0abea)}}, + {{TOBN(0x1dc19ea6, 0x0200ec7d), TOBN(0xb6f4a3f9, 0x0bce132b), + TOBN(0xb8d5de90, 0xf13e27e0), TOBN(0xbaee5ef0, 0x1fade16f)}, + {TOBN(0x6f406aaa, 0xe4c6cf38), TOBN(0xab4cfe06, 0xd1369815), + TOBN(0x0dcffe87, 0xefd550c6), TOBN(0x9d4f59c7, 0x75ff7d39)}}, + {{TOBN(0xb02553b1, 0x51deb6ad), TOBN(0x812399a4, 0xb1877749), + TOBN(0xce90f71f, 0xca6006e1), TOBN(0xc32363a6, 0xb02b6e77)}, + {TOBN(0x02284fbe, 0xdc36c64d), TOBN(0x86c81e31, 0xa7e1ae61), + TOBN(0x2576c7e5, 0xb909d94a), TOBN(0x8b6f7d02, 0x818b2bb0)}}, + {{TOBN(0xeca3ed07, 0x56faa38a), TOBN(0xa3790e6c, 0x9305bb54), + TOBN(0xd784eeda, 0x7bc73061), TOBN(0xbd56d369, 0x6dd50614)}, + {TOBN(0xd6575949, 0x229a8aa9), TOBN(0xdcca8f47, 0x4595ec28), + TOBN(0x814305c1, 0x06ab4fe6), TOBN(0xc8c39768, 0x24f43f16)}}, + {{TOBN(0xe2a45f36, 0x523f2b36), TOBN(0x995c6493, 0x920d93bb), + TOBN(0xf8afdab7, 0x90f1632b), TOBN(0x79ebbecd, 0x1c295954)}, + {TOBN(0xc7bb3ddb, 0x79592f48), TOBN(0x67216a7b, 0x5f88e998), + TOBN(0xd91f098b, 0xbc01193e), TOBN(0xf7d928a5, 0xb1db83fc)}}, + {{TOBN(0x55e38417, 0xe991f600), TOBN(0x2a91113e, 0x2981a934), + TOBN(0xcbc9d648, 0x06b13bde), TOBN(0xb011b6ac, 0x0755ff44)}, + {TOBN(0x6f4cb518, 0x045ec613), TOBN(0x522d2d31, 0xc2f5930a), + TOBN(0x5acae1af, 0x382e65de), TOBN(0x57643067, 0x27bc966f)}}, + {{TOBN(0x5e12705d, 0x1c7193f0), TOBN(0xf0f32f47, 0x3be8858e), + TOBN(0x785c3d7d, 0x96c6dfc7), TOBN(0xd75b4a20, 0xbf31795d)}, + {TOBN(0x91acf17b, 0x342659d4), TOBN(0xe596ea34, 0x44f0378f), + TOBN(0x4515708f, 0xce52129d), TOBN(0x17387e1e, 0x79f2f585)}}, + {{TOBN(0x72cfd2e9, 0x49dee168), TOBN(0x1ae05223, 0x3e2af239), + TOBN(0x009e75be, 0x1d94066a), TOBN(0x6cca31c7, 0x38abf413)}, + {TOBN(0xb50bd61d, 0x9bc49908), TOBN(0x4a9b4a8c, 0xf5e2bc1e), + TOBN(0xeb6cc5f7, 0x946f83ac), TOBN(0x27da93fc, 0xebffab28)}}, + {{TOBN(0xea314c96, 0x4821c8c5), TOBN(0x8de49ded, 0xa83c15f4), + TOBN(0x7a64cf20, 0x7af33004), TOBN(0x45f1bfeb, 0xc9627e10)}, + {TOBN(0x878b0626, 0x54b9df60), TOBN(0x5e4fdc3c, 0xa95c0b33), + TOBN(0xe54a37ca, 0xc2035d8e), TOBN(0x9087cda9, 0x80f20b8c)}}, + {{TOBN(0x36f61c23, 0x8319ade4), TOBN(0x766f287a, 0xde8cfdf8), + TOBN(0x48821948, 0x346f3705), TOBN(0x49a7b853, 0x16e4f4a2)}, + {TOBN(0xb9b3f8a7, 0x5cedadfd), TOBN(0x8f562815, 0x8db2a815), + TOBN(0xc0b7d554, 0x01f68f95), TOBN(0x12971e27, 0x688a208e)}}, + {{TOBN(0xc9f8b696, 0xd0ff34fc), TOBN(0x20824de2, 0x1222718c), + TOBN(0x7213cf9f, 0x0c95284d), TOBN(0xe2ad741b, 0xdc158240)}, + {TOBN(0x0ee3a6df, 0x54043ccf), TOBN(0x16ff479b, 0xd84412b3), + TOBN(0xf6c74ee0, 0xdfc98af0), TOBN(0xa78a169f, 0x52fcd2fb)}}, + {{TOBN(0xd8ae8746, 0x99c930e9), TOBN(0x1d33e858, 0x49e117a5), + TOBN(0x7581fcb4, 0x6624759f), TOBN(0xde50644f, 0x5bedc01d)}, + {TOBN(0xbeec5d00, 0xcaf3155e), TOBN(0x672d66ac, 0xbc73e75f), + TOBN(0x86b9d8c6, 0x270b01db), TOBN(0xd249ef83, 0x50f55b79)}}, + {{TOBN(0x6131d6d4, 0x73978fe3), TOBN(0xcc4e4542, 0x754b00a1), + TOBN(0x4e05df05, 0x57dfcfe9), TOBN(0x94b29cdd, 0x51ef6bf0)}, + {TOBN(0xe4530cff, 0x9bc7edf2), TOBN(0x8ac236fd, 0xd3da65f3), + TOBN(0x0faf7d5f, 0xc8eb0b48), TOBN(0x4d2de14c, 0x660eb039)}}, + {{TOBN(0xc006bba7, 0x60430e54), TOBN(0x10a2d0d6, 0xda3289ab), + TOBN(0x9c037a5d, 0xd7979c59), TOBN(0x04d1f3d3, 0xa116d944)}, + {TOBN(0x9ff22473, 0x8a0983cd), TOBN(0x28e25b38, 0xc883cabb), + TOBN(0xe968dba5, 0x47a58995), TOBN(0x2c80b505, 0x774eebdf)}}, + {{TOBN(0xee763b71, 0x4a953beb), TOBN(0x502e223f, 0x1642e7f6), + TOBN(0x6fe4b641, 0x61d5e722), TOBN(0x9d37c5b0, 0xdbef5316)}, + {TOBN(0x0115ed70, 0xf8330bc7), TOBN(0x139850e6, 0x75a72789), + TOBN(0x27d7faec, 0xffceccc2), TOBN(0x3016a860, 0x4fd9f7f6)}}, + {{TOBN(0xc492ec64, 0x4cd8f64c), TOBN(0x58a2d790, 0x279d7b51), + TOBN(0x0ced1fc5, 0x1fc75256), TOBN(0x3e658aed, 0x8f433017)}, + {TOBN(0x0b61942e, 0x05da59eb), TOBN(0xba3d60a3, 0x0ddc3722), + TOBN(0x7c311cd1, 0x742e7f87), TOBN(0x6473ffee, 0xf6b01b6e)}}}, + {{{TOBN(0x8303604f, 0x692ac542), TOBN(0xf079ffe1, 0x227b91d3), + TOBN(0x19f63e63, 0x15aaf9bd), TOBN(0xf99ee565, 0xf1f344fb)}, + {TOBN(0x8a1d661f, 0xd6219199), TOBN(0x8c883bc6, 0xd48ce41c), + TOBN(0x1065118f, 0x3c74d904), TOBN(0x713889ee, 0x0faf8b1b)}}, + {{TOBN(0x972b3f8f, 0x81a1b3be), TOBN(0x4f3ce145, 0xce2764a0), + TOBN(0xe2d0f1cc, 0x28c4f5f7), TOBN(0xdeee0c0d, 0xc7f3985b)}, + {TOBN(0x7df4adc0, 0xd39e25c3), TOBN(0x40619820, 0xc467a080), + TOBN(0x440ebc93, 0x61cf5a58), TOBN(0x527729a6, 0x422ad600)}}, + {{TOBN(0xca6c0937, 0xb1b76ba6), TOBN(0x1a2eab85, 0x4d2026dc), + TOBN(0xb1715e15, 0x19d9ae0a), TOBN(0xf1ad9199, 0xbac4a026)}, + {TOBN(0x35b3dfb8, 0x07ea7b0e), TOBN(0xedf5496f, 0x3ed9eb89), + TOBN(0x8932e5ff, 0x2d6d08ab), TOBN(0xf314874e, 0x25bd2731)}}, + {{TOBN(0xefb26a75, 0x3f73f449), TOBN(0x1d1c94f8, 0x8d44fc79), + TOBN(0x49f0fbc5, 0x3bc0dc4d), TOBN(0xb747ea0b, 0x3698a0d0)}, + {TOBN(0x5218c3fe, 0x228d291e), TOBN(0x35b804b5, 0x43c129d6), + TOBN(0xfac859b8, 0xd1acc516), TOBN(0x6c10697d, 0x95d6e668)}}, + {{TOBN(0xc38e438f, 0x0876fd4e), TOBN(0x45f0c307, 0x83d2f383), + TOBN(0x203cc2ec, 0xb10934cb), TOBN(0x6a8f2439, 0x2c9d46ee)}, + {TOBN(0xf16b431b, 0x65ccde7b), TOBN(0x41e2cd18, 0x27e76a6f), + TOBN(0xb9c8cf8f, 0x4e3484d7), TOBN(0x64426efd, 0x8315244a)}}, + {{TOBN(0x1c0a8e44, 0xfc94dea3), TOBN(0x34c8cdbf, 0xdad6a0b0), + TOBN(0x919c3840, 0x04113cef), TOBN(0xfd32fba4, 0x15490ffa)}, + {TOBN(0x58d190f6, 0x795dcfb7), TOBN(0xfef01b03, 0x83588baf), + TOBN(0x9e6d1d63, 0xca1fc1c0), TOBN(0x53173f96, 0xf0a41ac9)}}, + {{TOBN(0x2b1d402a, 0xba16f73b), TOBN(0x2fb31014, 0x8cf9b9fc), + TOBN(0x2d51e60e, 0x446ef7bf), TOBN(0xc731021b, 0xb91e1745)}, + {TOBN(0x9d3b4724, 0x4fee99d4), TOBN(0x4bca48b6, 0xfac5c1ea), + TOBN(0x70f5f514, 0xbbea9af7), TOBN(0x751f55a5, 0x974c283a)}}, + {{TOBN(0x6e30251a, 0xcb452fdb), TOBN(0x31ee6965, 0x50f30650), + TOBN(0xb0b3e508, 0x933548d9), TOBN(0xb8949a4f, 0xf4b0ef5b)}, + {TOBN(0x208b8326, 0x3c88f3bd), TOBN(0xab147c30, 0xdb1d9989), + TOBN(0xed6515fd, 0x44d4df03), TOBN(0x17a12f75, 0xe72eb0c5)}}, + {{TOBN(0x3b59796d, 0x36cf69db), TOBN(0x1219eee9, 0x56670c18), + TOBN(0xfe3341f7, 0x7a070d8e), TOBN(0x9b70130b, 0xa327f90c)}, + {TOBN(0x36a32462, 0x0ae18e0e), TOBN(0x2021a623, 0x46c0a638), + TOBN(0x251b5817, 0xc62eb0d4), TOBN(0x87bfbcdf, 0x4c762293)}}, + {{TOBN(0xf78ab505, 0xcdd61d64), TOBN(0x8c7a53fc, 0xc8c18857), + TOBN(0xa653ce6f, 0x16147515), TOBN(0x9c923aa5, 0xea7d52d5)}, + {TOBN(0xc24709cb, 0x5c18871f), TOBN(0x7d53bec8, 0x73b3cc74), + TOBN(0x59264aff, 0xfdd1d4c4), TOBN(0x5555917e, 0x240da582)}}, + {{TOBN(0xcae8bbda, 0x548f5a0e), TOBN(0x1910eaba, 0x3bbfbbe1), + TOBN(0xae579685, 0x7677afc3), TOBN(0x49ea61f1, 0x73ff0b5c)}, + {TOBN(0x78655478, 0x4f7c3922), TOBN(0x95d337cd, 0x20c68eef), + TOBN(0x68f1e1e5, 0xdf779ab9), TOBN(0x14b491b0, 0xb5cf69a8)}}, + {{TOBN(0x7a6cbbe0, 0x28e3fe89), TOBN(0xe7e1fee4, 0xc5aac0eb), + TOBN(0x7f47eda5, 0x697e5140), TOBN(0x4f450137, 0xb454921f)}, + {TOBN(0xdb625f84, 0x95cd8185), TOBN(0x74be0ba1, 0xcdb2e583), + TOBN(0xaee4fd7c, 0xdd5e6de4), TOBN(0x4251437d, 0xe8101739)}}, + {{TOBN(0x686d72a0, 0xac620366), TOBN(0x4be3fb9c, 0xb6d59344), + TOBN(0x6e8b44e7, 0xa1eb75b9), TOBN(0x84e39da3, 0x91a5c10c)}, + {TOBN(0x37cc1490, 0xb38f0409), TOBN(0x02951943, 0x2c2ade82), + TOBN(0x9b688783, 0x1190a2d8), TOBN(0x25627d14, 0x231182ba)}}, + {{TOBN(0x6eb550aa, 0x658a6d87), TOBN(0x1405aaa7, 0xcf9c7325), + TOBN(0xd147142e, 0x5c8748c9), TOBN(0x7f637e4f, 0x53ede0e0)}, + {TOBN(0xf8ca2776, 0x14ffad2c), TOBN(0xe58fb1bd, 0xbafb6791), + TOBN(0x17158c23, 0xbf8f93fc), TOBN(0x7f15b373, 0x0a4a4655)}}, + {{TOBN(0x39d4add2, 0xd842ca72), TOBN(0xa71e4391, 0x3ed96305), + TOBN(0x5bb09cbe, 0x6700be14), TOBN(0x68d69d54, 0xd8befcf6)}, + {TOBN(0xa45f5367, 0x37183bcf), TOBN(0x7152b7bb, 0x3370dff7), + TOBN(0xcf887baa, 0xbf12525b), TOBN(0xe7ac7bdd, 0xd6d1e3cd)}}, + {{TOBN(0x25914f78, 0x81fdad90), TOBN(0xcf638f56, 0x0d2cf6ab), + TOBN(0xb90bc03f, 0xcc054de5), TOBN(0x932811a7, 0x18b06350)}, + {TOBN(0x2f00b330, 0x9bbd11ff), TOBN(0x76108a6f, 0xb4044974), + TOBN(0x801bb9e0, 0xa851d266), TOBN(0x0dd099be, 0xbf8990c1)}}, + {{TOBN(0x58c5aaaa, 0xabe32986), TOBN(0x0fe9dd2a, 0x50d59c27), + TOBN(0x84951ff4, 0x8d307305), TOBN(0x6c23f829, 0x86529b78)}, + {TOBN(0x50bb2218, 0x0b136a79), TOBN(0x7e2174de, 0x77a20996), + TOBN(0x6f00a4b9, 0xc0bb4da6), TOBN(0x89a25a17, 0xefdde8da)}}, + {{TOBN(0xf728a27e, 0xc11ee01d), TOBN(0xf900553a, 0xe5f10dfb), + TOBN(0x189a83c8, 0x02ec893c), TOBN(0x3ca5bdc1, 0x23f66d77)}, + {TOBN(0x98781537, 0x97eada9f), TOBN(0x59c50ab3, 0x10256230), + TOBN(0x346042d9, 0x323c69b3), TOBN(0x1b715a6d, 0x2c460449)}}, + {{TOBN(0xa41dd476, 0x6ae06e0b), TOBN(0xcdd7888e, 0x9d42e25f), + TOBN(0x0f395f74, 0x56b25a20), TOBN(0xeadfe0ae, 0x8700e27e)}, + {TOBN(0xb09d52a9, 0x69950093), TOBN(0x3525d9cb, 0x327f8d40), + TOBN(0xb8235a94, 0x67df886a), TOBN(0x77e4b0dd, 0x035faec2)}}, + {{TOBN(0x115eb20a, 0x517d7061), TOBN(0x77fe3433, 0x6c2df683), + TOBN(0x6870ddc7, 0xcdc6fc67), TOBN(0xb1610588, 0x0b87de83)}, + {TOBN(0x343584ca, 0xd9c4ddbe), TOBN(0xb3164f1c, 0x3d754be2), + TOBN(0x0731ed3a, 0xc1e6c894), TOBN(0x26327dec, 0x4f6b904c)}}, + {{TOBN(0x9d49c6de, 0x97b5cd32), TOBN(0x40835dae, 0xb5eceecd), + TOBN(0xc66350ed, 0xd9ded7fe), TOBN(0x8aeebb5c, 0x7a678804)}, + {TOBN(0x51d42fb7, 0x5b8ee9ec), TOBN(0xd7a17bdd, 0x8e3ca118), + TOBN(0x40d7511a, 0x2ef4400e), TOBN(0xc48990ac, 0x875a66f4)}}, + {{TOBN(0x8de07d2a, 0x2199e347), TOBN(0xbee75556, 0x2a39e051), + TOBN(0x56918786, 0x916e51dc), TOBN(0xeb191313, 0x4a2d89ec)}, + {TOBN(0x6679610d, 0x37d341ed), TOBN(0x434fbb41, 0x56d51c2b), + TOBN(0xe54b7ee7, 0xd7492dba), TOBN(0xaa33a79a, 0x59021493)}}, + {{TOBN(0x49fc5054, 0xe4bd6d3d), TOBN(0x09540f04, 0x5ab551d0), + TOBN(0x8acc9085, 0x4942d3a6), TOBN(0x231af02f, 0x2d28323b)}, + {TOBN(0x93458cac, 0x0992c163), TOBN(0x1fef8e71, 0x888e3bb4), + TOBN(0x27578da5, 0xbe8c268c), TOBN(0xcc8be792, 0xe805ec00)}}, + {{TOBN(0x29267bae, 0xc61c3855), TOBN(0xebff429d, 0x58c1fd3b), + TOBN(0x22d886c0, 0x8c0b93b8), TOBN(0xca5e00b2, 0x2ddb8953)}, + {TOBN(0xcf330117, 0xc3fed8b7), TOBN(0xd49ac6fa, 0x819c01f6), + TOBN(0x6ddaa6bd, 0x3c0fbd54), TOBN(0x91743068, 0x8049a2cf)}}, + {{TOBN(0xd67f981e, 0xaff2ef81), TOBN(0xc3654d35, 0x2818ae80), + TOBN(0x81d05044, 0x1b2aa892), TOBN(0x2db067bf, 0x3d099328)}, + {TOBN(0xe7c79e86, 0x703dcc97), TOBN(0xe66f9b37, 0xe133e215), + TOBN(0xcdf119a6, 0xe39a7a5c), TOBN(0x47c60de3, 0x876f1b61)}}, + {{TOBN(0x6e405939, 0xd860f1b2), TOBN(0x3e9a1dbc, 0xf5ed4d4a), + TOBN(0x3f23619e, 0xc9b6bcbd), TOBN(0x5ee790cf, 0x734e4497)}, + {TOBN(0xf0a834b1, 0x5bdaf9bb), TOBN(0x02cedda7, 0x4ca295f0), + TOBN(0x4619aa2b, 0xcb8e378c), TOBN(0xe5613244, 0xcc987ea4)}}, + {{TOBN(0x0bc022cc, 0x76b23a50), TOBN(0x4a2793ad, 0x0a6c21ce), + TOBN(0x38328780, 0x89cac3f5), TOBN(0x29176f1b, 0xcba26d56)}, + {TOBN(0x06296187, 0x4f6f59eb), TOBN(0x86e9bca9, 0x8bdc658e), + TOBN(0x2ca9c4d3, 0x57e30402), TOBN(0x5438b216, 0x516a09bb)}}, + {{TOBN(0x0a6a063c, 0x7672765a), TOBN(0x37a3ce64, 0x0547b9bf), + TOBN(0x42c099c8, 0x98b1a633), TOBN(0xb5ab800d, 0x05ee6961)}, + {TOBN(0xf1963f59, 0x11a5acd6), TOBN(0xbaee6157, 0x46201063), + TOBN(0x36d9a649, 0xa596210a), TOBN(0xaed04363, 0x1ba7138c)}}, + {{TOBN(0xcf817d1c, 0xa4a82b76), TOBN(0x5586960e, 0xf3806be9), + TOBN(0x7ab67c89, 0x09dc6bb5), TOBN(0x52ace7a0, 0x114fe7eb)}, + {TOBN(0xcd987618, 0xcbbc9b70), TOBN(0x4f06fd5a, 0x604ca5e1), + TOBN(0x90af14ca, 0x6dbde133), TOBN(0x1afe4322, 0x948a3264)}}, + {{TOBN(0xa70d2ca6, 0xc44b2c6c), TOBN(0xab726799, 0x0ef87dfe), + TOBN(0x310f64dc, 0x2e696377), TOBN(0x49b42e68, 0x4c8126a0)}, + {TOBN(0x0ea444c3, 0xcea0b176), TOBN(0x53a8ddf7, 0xcb269182), + TOBN(0xf3e674eb, 0xbbba9dcb), TOBN(0x0d2878a8, 0xd8669d33)}}, + {{TOBN(0x04b935d5, 0xd019b6a3), TOBN(0xbb5cf88e, 0x406f1e46), + TOBN(0xa1912d16, 0x5b57c111), TOBN(0x9803fc21, 0x19ebfd78)}, + {TOBN(0x4f231c9e, 0xc07764a9), TOBN(0xd93286ee, 0xb75bd055), + TOBN(0x83a9457d, 0x8ee6c9de), TOBN(0x04695915, 0x6087ec90)}}, + {{TOBN(0x14c6dd8a, 0x58d6cd46), TOBN(0x9cb633b5, 0x8e6634d2), + TOBN(0xc1305047, 0xf81bc328), TOBN(0x12ede0e2, 0x26a177e5)}, + {TOBN(0x332cca62, 0x065a6f4f), TOBN(0xc3a47ecd, 0x67be487b), + TOBN(0x741eb187, 0x0f47ed1c), TOBN(0x99e66e58, 0xe7598b14)}}, + {{TOBN(0x6f0544ca, 0x63d0ff12), TOBN(0xe5efc784, 0xb610a05f), + TOBN(0xf72917b1, 0x7cad7b47), TOBN(0x3ff6ea20, 0xf2cac0c0)}, + {TOBN(0xcc23791b, 0xf21db8b7), TOBN(0x7dac70b1, 0xd7d93565), + TOBN(0x682cda1d, 0x694bdaad), TOBN(0xeb88bb8c, 0x1023516d)}}, + {{TOBN(0xc4c634b4, 0xdfdbeb1b), TOBN(0x22f5ca72, 0xb4ee4dea), + TOBN(0x1045a368, 0xe6524821), TOBN(0xed9e8a3f, 0x052b18b2)}, + {TOBN(0x9b7f2cb1, 0xb961f49a), TOBN(0x7fee2ec1, 0x7b009670), + TOBN(0x350d8754, 0x22507a6d), TOBN(0x561bd711, 0x4db55f1d)}}, + {{TOBN(0x4c189ccc, 0x320bbcaf), TOBN(0x568434cf, 0xdf1de48c), + TOBN(0x6af1b00e, 0x0fa8f128), TOBN(0xf0ba9d02, 0x8907583c)}, + {TOBN(0x735a4004, 0x32ff9f60), TOBN(0x3dd8e4b6, 0xc25dcf33), + TOBN(0xf2230f16, 0x42c74cef), TOBN(0xd8117623, 0x013fa8ad)}}, + {{TOBN(0x36822876, 0xf51fe76e), TOBN(0x8a6811cc, 0x11d62589), + TOBN(0xc3fc7e65, 0x46225718), TOBN(0xb7df2c9f, 0xc82fdbcd)}, + {TOBN(0x3b1d4e52, 0xdd7b205b), TOBN(0xb6959478, 0x47a2e414), + TOBN(0x05e4d793, 0xefa91148), TOBN(0xb47ed446, 0xfd2e9675)}}, + {{TOBN(0x1a7098b9, 0x04c9d9bf), TOBN(0x661e2881, 0x1b793048), + TOBN(0xb1a16966, 0xb01ee461), TOBN(0xbc521308, 0x2954746f)}, + {TOBN(0xc909a0fc, 0x2477de50), TOBN(0xd80bb41c, 0x7dbd51ef), + TOBN(0xa85be7ec, 0x53294905), TOBN(0x6d465b18, 0x83958f97)}}, + {{TOBN(0x16f6f330, 0xfb6840fd), TOBN(0xfaaeb214, 0x3401e6c8), + TOBN(0xaf83d30f, 0xccb5b4f8), TOBN(0x22885739, 0x266dec4b)}, + {TOBN(0x51b4367c, 0x7bc467df), TOBN(0x926562e3, 0xd842d27a), + TOBN(0xdfcb6614, 0x0fea14a6), TOBN(0xeb394dae, 0xf2734cd9)}}, + {{TOBN(0x3eeae5d2, 0x11c0be98), TOBN(0xb1e6ed11, 0x814e8165), + TOBN(0x191086bc, 0xe52bce1c), TOBN(0x14b74cc6, 0xa75a04da)}, + {TOBN(0x63cf1186, 0x8c060985), TOBN(0x071047de, 0x2dbd7f7c), + TOBN(0x4e433b8b, 0xce0942ca), TOBN(0xecbac447, 0xd8fec61d)}}, + {{TOBN(0x8f0ed0e2, 0xebf3232f), TOBN(0xfff80f9e, 0xc52a2edd), + TOBN(0xad9ab433, 0x75b55fdb), TOBN(0x73ca7820, 0xe42e0c11)}, + {TOBN(0x6dace0a0, 0xe6251b46), TOBN(0x89bc6b5c, 0x4c0d932d), + TOBN(0x3438cd77, 0x095da19a), TOBN(0x2f24a939, 0x8d48bdfb)}}, + {{TOBN(0x99b47e46, 0x766561b7), TOBN(0x736600e6, 0x0ed0322a), + TOBN(0x06a47cb1, 0x638e1865), TOBN(0x927c1c2d, 0xcb136000)}, + {TOBN(0x29542337, 0x0cc5df69), TOBN(0x99b37c02, 0x09d649a9), + TOBN(0xc5f0043c, 0x6aefdb27), TOBN(0x6cdd9987, 0x1be95c27)}}, + {{TOBN(0x69850931, 0x390420d2), TOBN(0x299c40ac, 0x0983efa4), + TOBN(0x3a05e778, 0xaf39aead), TOBN(0x84274408, 0x43a45193)}, + {TOBN(0x6bcd0fb9, 0x91a711a0), TOBN(0x461592c8, 0x9f52ab17), + TOBN(0xb49302b4, 0xda3c6ed6), TOBN(0xc51fddc7, 0x330d7067)}}, + {{TOBN(0x94babeb6, 0xda50d531), TOBN(0x521b840d, 0xa6a7b9da), + TOBN(0x5305151e, 0x404bdc89), TOBN(0x1bcde201, 0xd0d07449)}, + {TOBN(0xf427a78b, 0x3b76a59a), TOBN(0xf84841ce, 0x07791a1b), + TOBN(0xebd314be, 0xbf91ed1c), TOBN(0x8e61d34c, 0xbf172943)}}, + {{TOBN(0x1d5dc451, 0x5541b892), TOBN(0xb186ee41, 0xfc9d9e54), + TOBN(0x9d9f345e, 0xd5bf610d), TOBN(0x3e7ba65d, 0xf6acca9f)}, + {TOBN(0x9dda787a, 0xa8369486), TOBN(0x09f9dab7, 0x8eb5ba53), + TOBN(0x5afb2033, 0xd6481bc3), TOBN(0x76f4ce30, 0xafa62104)}}, + {{TOBN(0xa8fa00cf, 0xf4f066b5), TOBN(0x89ab5143, 0x461dafc2), + TOBN(0x44339ed7, 0xa3389998), TOBN(0x2ff862f1, 0xbc214903)}, + {TOBN(0x2c88f985, 0xb05556e3), TOBN(0xcd96058e, 0x3467081e), + TOBN(0x7d6a4176, 0xedc637ea), TOBN(0xe1743d09, 0x36a5acdc)}}, + {{TOBN(0x66fd72e2, 0x7eb37726), TOBN(0xf7fa264e, 0x1481a037), + TOBN(0x9fbd3bde, 0x45f4aa79), TOBN(0xed1e0147, 0x767c3e22)}, + {TOBN(0x7621f979, 0x82e7abe2), TOBN(0x19eedc72, 0x45f633f8), + TOBN(0xe69b155e, 0x6137bf3a), TOBN(0xa0ad13ce, 0x414ee94e)}}, + {{TOBN(0x93e3d524, 0x1c0e651a), TOBN(0xab1a6e2a, 0x02ce227e), + TOBN(0xe7af1797, 0x4ab27eca), TOBN(0x245446de, 0xbd444f39)}, + {TOBN(0x59e22a21, 0x56c07613), TOBN(0x43deafce, 0xf4275498), + TOBN(0x10834ccb, 0x67fd0946), TOBN(0xa75841e5, 0x47406edf)}}, + {{TOBN(0xebd6a677, 0x7b0ac93d), TOBN(0xa6e37b0d, 0x78f5e0d7), + TOBN(0x2516c096, 0x76f5492b), TOBN(0x1e4bf888, 0x9ac05f3a)}, + {TOBN(0xcdb42ce0, 0x4df0ba2b), TOBN(0x935d5cfd, 0x5062341b), + TOBN(0x8a303333, 0x82acac20), TOBN(0x429438c4, 0x5198b00e)}}, + {{TOBN(0x1d083bc9, 0x049d33fa), TOBN(0x58b82dda, 0x946f67ff), + TOBN(0xac3e2db8, 0x67a1d6a3), TOBN(0x62e6bead, 0x1798aac8)}, + {TOBN(0xfc85980f, 0xde46c58c), TOBN(0xa7f69379, 0x69c8d7be), + TOBN(0x23557927, 0x837b35ec), TOBN(0x06a933d8, 0xe0790c0c)}}, + {{TOBN(0x827c0e9b, 0x077ff55d), TOBN(0x53977798, 0xbb26e680), + TOBN(0x59530874, 0x1d9cb54f), TOBN(0xcca3f449, 0x4aac53ef)}, + {TOBN(0x11dc5c87, 0xa07eda0f), TOBN(0xc138bccf, 0xfd6400c8), + TOBN(0x549680d3, 0x13e5da72), TOBN(0xc93eed82, 0x4540617e)}}, + {{TOBN(0xfd3db157, 0x4d0b75c0), TOBN(0x9716eb42, 0x6386075b), + TOBN(0x0639605c, 0x817b2c16), TOBN(0x09915109, 0xf1e4f201)}, + {TOBN(0x35c9a928, 0x5cca6c3b), TOBN(0xb25f7d1a, 0x3505c900), + TOBN(0xeb9f7d20, 0x630480c4), TOBN(0xc3c7b8c6, 0x2a1a501c)}}, + {{TOBN(0x3f99183c, 0x5a1f8e24), TOBN(0xfdb118fa, 0x9dd255f0), + TOBN(0xb9b18b90, 0xc27f62a6), TOBN(0xe8f732f7, 0x396ec191)}, + {TOBN(0x524a2d91, 0x0be786ab), TOBN(0x5d32adef, 0x0ac5a0f5), + TOBN(0x9b53d4d6, 0x9725f694), TOBN(0x032a76c6, 0x0510ba89)}}, + {{TOBN(0x840391a3, 0xebeb1544), TOBN(0x44b7b88c, 0x3ed73ac3), + TOBN(0xd24bae7a, 0x256cb8b3), TOBN(0x7ceb151a, 0xe394cb12)}, + {TOBN(0xbd6b66d0, 0x5bc1e6a8), TOBN(0xec70cecb, 0x090f07bf), + TOBN(0x270644ed, 0x7d937589), TOBN(0xee9e1a3d, 0x5f1dccfe)}}, + {{TOBN(0xb0d40a84, 0x745b98d2), TOBN(0xda429a21, 0x2556ed40), + TOBN(0xf676eced, 0x85148cb9), TOBN(0x5a22d40c, 0xded18936)}, + {TOBN(0x3bc4b9e5, 0x70e8a4ce), TOBN(0xbfd1445b, 0x9eae0379), + TOBN(0xf23f2c0c, 0x1a0bd47e), TOBN(0xa9c0bb31, 0xe1845531)}}, + {{TOBN(0x9ddc4d60, 0x0a4c3f6b), TOBN(0xbdfaad79, 0x2c15ef44), + TOBN(0xce55a236, 0x7f484acc), TOBN(0x08653ca7, 0x055b1f15)}, + {TOBN(0x2efa8724, 0x538873a3), TOBN(0x09299e5d, 0xace1c7e7), + TOBN(0x07afab66, 0xade332ba), TOBN(0x9be1fdf6, 0x92dd71b7)}}, + {{TOBN(0xa49b5d59, 0x5758b11c), TOBN(0x0b852893, 0xc8654f40), + TOBN(0xb63ef6f4, 0x52379447), TOBN(0xd4957d29, 0x105e690c)}, + {TOBN(0x7d484363, 0x646559b0), TOBN(0xf4a8273c, 0x49788a8e), + TOBN(0xee406cb8, 0x34ce54a9), TOBN(0x1e1c260f, 0xf86fda9b)}}, + {{TOBN(0xe150e228, 0xcf6a4a81), TOBN(0x1fa3b6a3, 0x1b488772), + TOBN(0x1e6ff110, 0xc5a9c15b), TOBN(0xc6133b91, 0x8ad6aa47)}, + {TOBN(0x8ac5d55c, 0x9dffa978), TOBN(0xba1d1c1d, 0x5f3965f2), + TOBN(0xf969f4e0, 0x7732b52f), TOBN(0xfceecdb5, 0xa5172a07)}}, + {{TOBN(0xb0120a5f, 0x10f2b8f5), TOBN(0xc83a6cdf, 0x5c4c2f63), + TOBN(0x4d47a491, 0xf8f9c213), TOBN(0xd9e1cce5, 0xd3f1bbd5)}, + {TOBN(0x0d91bc7c, 0xaba7e372), TOBN(0xfcdc74c8, 0xdfd1a2db), + TOBN(0x05efa800, 0x374618e5), TOBN(0x11216969, 0x15a7925e)}}, + {{TOBN(0xd4c89823, 0xf6021c5d), TOBN(0x880d5e84, 0xeff14423), + TOBN(0x6523bc5a, 0x6dcd1396), TOBN(0xd1acfdfc, 0x113c978b)}, + {TOBN(0xb0c164e8, 0xbbb66840), TOBN(0xf7f4301e, 0x72b58459), + TOBN(0xc29ad4a6, 0xa638e8ec), TOBN(0xf5ab8961, 0x46b78699)}}, + {{TOBN(0x9dbd7974, 0x0e954750), TOBN(0x0121de88, 0x64f9d2c6), + TOBN(0x2e597b42, 0xd985232e), TOBN(0x55b6c3c5, 0x53451777)}, + {TOBN(0xbb53e547, 0x519cb9fb), TOBN(0xf134019f, 0x8428600d), + TOBN(0x5a473176, 0xe081791a), TOBN(0x2f3e2263, 0x35fb0c08)}}, + {{TOBN(0xb28c3017, 0x73d273b0), TOBN(0xccd21076, 0x7721ef9a), + TOBN(0x054cc292, 0xb650dc39), TOBN(0x662246de, 0x6188045e)}, + {TOBN(0x904b52fa, 0x6b83c0d1), TOBN(0xa72df267, 0x97e9cd46), + TOBN(0x886b43cd, 0x899725e4), TOBN(0x2b651688, 0xd849ff22)}}, + {{TOBN(0x60479b79, 0x02f34533), TOBN(0x5e354c14, 0x0c77c148), + TOBN(0xb4bb7581, 0xa8537c78), TOBN(0x188043d7, 0xefe1495f)}, + {TOBN(0x9ba12f42, 0x8c1d5026), TOBN(0x2e0c8a26, 0x93d4aaab), + TOBN(0xbdba7b8b, 0xaa57c450), TOBN(0x140c9ad6, 0x9bbdafef)}}, + {{TOBN(0x2067aa42, 0x25ac0f18), TOBN(0xf7b1295b, 0x04d1fbf3), + TOBN(0x14829111, 0xa4b04824), TOBN(0x2ce3f192, 0x33bd5e91)}, + {TOBN(0x9c7a1d55, 0x8f2e1b72), TOBN(0xfe932286, 0x302aa243), + TOBN(0x497ca7b4, 0xd4be9554), TOBN(0xb8e821b8, 0xe0547a6e)}}, + {{TOBN(0xfb2838be, 0x67e573e0), TOBN(0x05891db9, 0x4084c44b), + TOBN(0x91311373, 0x96c1c2c5), TOBN(0x6aebfa3f, 0xd958444b)}, + {TOBN(0xac9cdce9, 0xe56e55c1), TOBN(0x7148ced3, 0x2caa46d0), + TOBN(0x2e10c7ef, 0xb61fe8eb), TOBN(0x9fd835da, 0xff97cf4d)}}}, + {{{TOBN(0xa36da109, 0x081e9387), TOBN(0xfb9780d7, 0x8c935828), + TOBN(0xd5940332, 0xe540b015), TOBN(0xc9d7b51b, 0xe0f466fa)}, + {TOBN(0xfaadcd41, 0xd6d9f671), TOBN(0xba6c1e28, 0xb1a2ac17), + TOBN(0x066a7833, 0xed201e5f), TOBN(0x19d99719, 0xf90f462b)}}, + {{TOBN(0xf431f462, 0x060b5f61), TOBN(0xa56f46b4, 0x7bd057c2), + TOBN(0x348dca6c, 0x47e1bf65), TOBN(0x9a38783e, 0x41bcf1ff)}, + {TOBN(0x7a5d33a9, 0xda710718), TOBN(0x5a779987, 0x2e0aeaf6), + TOBN(0xca87314d, 0x2d29d187), TOBN(0xfa0edc3e, 0xc687d733)}}, + {{TOBN(0x9df33621, 0x6a31e09b), TOBN(0xde89e44d, 0xc1350e35), + TOBN(0x29214871, 0x4ca0cf52), TOBN(0xdf379672, 0x0b88a538)}, + {TOBN(0xc92a510a, 0x2591d61b), TOBN(0x79aa87d7, 0x585b447b), + TOBN(0xf67db604, 0xe5287f77), TOBN(0x1697c8bf, 0x5efe7a80)}}, + {{TOBN(0x1c894849, 0xcb198ac7), TOBN(0xa884a93d, 0x0f264665), + TOBN(0x2da964ef, 0x9b200678), TOBN(0x3c351b87, 0x009834e6)}, + {TOBN(0xafb2ef9f, 0xe2c4b44b), TOBN(0x580f6c47, 0x3326790c), + TOBN(0xb8480521, 0x0b02264a), TOBN(0x8ba6f9e2, 0x42a194e2)}}, + {{TOBN(0xfc87975f, 0x8fb54738), TOBN(0x35160788, 0x27c3ead3), + TOBN(0x834116d2, 0xb74a085a), TOBN(0x53c99a73, 0xa62fe996)}, + {TOBN(0x87585be0, 0x5b81c51b), TOBN(0x925bafa8, 0xbe0852b7), + TOBN(0x76a4fafd, 0xa84d19a7), TOBN(0x39a45982, 0x585206d4)}}, + {{TOBN(0x499b6ab6, 0x5eb03c0e), TOBN(0xf19b7954, 0x72bc3fde), + TOBN(0xa86b5b9c, 0x6e3a80d2), TOBN(0xe4377508, 0x6d42819f)}, + {TOBN(0xc1663650, 0xbb3ee8a3), TOBN(0x75eb14fc, 0xb132075f), + TOBN(0xa8ccc906, 0x7ad834f6), TOBN(0xea6a2474, 0xe6e92ffd)}}, + {{TOBN(0x9d72fd95, 0x0f8d6758), TOBN(0xcb84e101, 0x408c07dd), + TOBN(0xb9114bfd, 0xa5e23221), TOBN(0x358b5fe2, 0xe94e742c)}, + {TOBN(0x1c0577ec, 0x95f40e75), TOBN(0xf0155451, 0x3d73f3d6), + TOBN(0x9d55cd67, 0xbd1b9b66), TOBN(0x63e86e78, 0xaf8d63c7)}}, + {{TOBN(0x39d934ab, 0xd3c095f1), TOBN(0x04b261be, 0xe4b76d71), + TOBN(0x1d2e6970, 0xe73e6984), TOBN(0x879fb23b, 0x5e5fcb11)}, + {TOBN(0x11506c72, 0xdfd75490), TOBN(0x3a97d085, 0x61bcf1c1), + TOBN(0x43201d82, 0xbf5e7007), TOBN(0x7f0ac52f, 0x798232a7)}}, + {{TOBN(0x2715cbc4, 0x6eb564d4), TOBN(0x8d6c752c, 0x9e570e29), + TOBN(0xf80247c8, 0x9ef5fd5d), TOBN(0xc3c66b46, 0xd53eb514)}, + {TOBN(0x9666b401, 0x0f87de56), TOBN(0xce62c06f, 0xc6c603b5), + TOBN(0xae7b4c60, 0x7e4fc942), TOBN(0x38ac0b77, 0x663a9c19)}}, + {{TOBN(0xcb4d20ee, 0x4b049136), TOBN(0x8b63bf12, 0x356a4613), + TOBN(0x1221aef6, 0x70e08128), TOBN(0xe62d8c51, 0x4acb6b16)}, + {TOBN(0x71f64a67, 0x379e7896), TOBN(0xb25237a2, 0xcafd7fa5), + TOBN(0xf077bd98, 0x3841ba6a), TOBN(0xc4ac0244, 0x3cd16e7e)}}, + {{TOBN(0x548ba869, 0x21fea4ca), TOBN(0xd36d0817, 0xf3dfdac1), + TOBN(0x09d8d71f, 0xf4685faf), TOBN(0x8eff66be, 0xc52c459a)}, + {TOBN(0x182faee7, 0x0b57235e), TOBN(0xee3c39b1, 0x0106712b), + TOBN(0x5107331f, 0xc0fcdcb0), TOBN(0x669fb9dc, 0xa51054ba)}}, + {{TOBN(0xb25101fb, 0x319d7682), TOBN(0xb0293129, 0x0a982fee), + TOBN(0x51c1c9b9, 0x0261b344), TOBN(0x0e008c5b, 0xbfd371fa)}, + {TOBN(0xd866dd1c, 0x0278ca33), TOBN(0x666f76a6, 0xe5aa53b1), + TOBN(0xe5cfb779, 0x6013a2cf), TOBN(0x1d3a1aad, 0xa3521836)}}, + {{TOBN(0xcedd2531, 0x73faa485), TOBN(0xc8ee6c4f, 0xc0a76878), + TOBN(0xddbccfc9, 0x2a11667d), TOBN(0x1a418ea9, 0x1c2f695a)}, + {TOBN(0xdb11bd92, 0x51f73971), TOBN(0x3e4b3c82, 0xda2ed89f), + TOBN(0x9a44f3f4, 0xe73e0319), TOBN(0xd1e3de0f, 0x303431af)}}, + {{TOBN(0x3c5604ff, 0x50f75f9c), TOBN(0x1d8eddf3, 0x7e752b22), + TOBN(0x0ef074dd, 0x3c9a1118), TOBN(0xd0ffc172, 0xccb86d7b)}, + {TOBN(0xabd1ece3, 0x037d90f2), TOBN(0xe3f307d6, 0x6055856c), + TOBN(0x422f9328, 0x7e4c6daf), TOBN(0x902aac66, 0x334879a0)}}, + {{TOBN(0xb6a1e7bf, 0x94cdfade), TOBN(0x6c97e1ed, 0x7fc6d634), + TOBN(0x662ad24d, 0xa2fb63f8), TOBN(0xf81be1b9, 0xa5928405)}, + {TOBN(0x86d765e4, 0xd14b4206), TOBN(0xbecc2e0e, 0x8fa0db65), + TOBN(0xa28838e0, 0xb17fc76c), TOBN(0xe49a602a, 0xe37cf24e)}}, + {{TOBN(0x76b4131a, 0x567193ec), TOBN(0xaf3c305a, 0xe5f6e70b), + TOBN(0x9587bd39, 0x031eebdd), TOBN(0x5709def8, 0x71bbe831)}, + {TOBN(0x57059983, 0x0eb2b669), TOBN(0x4d80ce1b, 0x875b7029), + TOBN(0x838a7da8, 0x0364ac16), TOBN(0x2f431d23, 0xbe1c83ab)}}, + {{TOBN(0xe56812a6, 0xf9294dd3), TOBN(0xb448d01f, 0x9b4b0d77), + TOBN(0xf3ae6061, 0x04e8305c), TOBN(0x2bead645, 0x94d8c63e)}, + {TOBN(0x0a85434d, 0x84fd8b07), TOBN(0x537b983f, 0xf7a9dee5), + TOBN(0xedcc5f18, 0xef55bd85), TOBN(0x2041af62, 0x21c6cf8b)}}, + {{TOBN(0x8e52874c, 0xb940c71e), TOBN(0x211935a9, 0xdb5f4b3a), + TOBN(0x94350492, 0x301b1dc3), TOBN(0x33d2646d, 0x29958620)}, + {TOBN(0x16b0d64b, 0xef911404), TOBN(0x9d1f25ea, 0x9a3c5ef4), + TOBN(0x20f200eb, 0x4a352c78), TOBN(0x43929f2c, 0x4bd0b428)}}, + {{TOBN(0xa5656667, 0xc7196e29), TOBN(0x7992c2f0, 0x9391be48), + TOBN(0xaaa97cbd, 0x9ee0cd6e), TOBN(0x51b0310c, 0x3dc8c9bf)}, + {TOBN(0x237f8acf, 0xdd9f22cb), TOBN(0xbb1d81a1, 0xb585d584), + TOBN(0x8d5d85f5, 0x8c416388), TOBN(0x0d6e5a5a, 0x42fe474f)}}, + {{TOBN(0xe7812766, 0x38235d4e), TOBN(0x1c62bd67, 0x496e3298), + TOBN(0x8378660c, 0x3f175bc8), TOBN(0x4d04e189, 0x17afdd4d)}, + {TOBN(0x32a81601, 0x85a8068c), TOBN(0xdb58e4e1, 0x92b29a85), + TOBN(0xe8a65b86, 0xc70d8a3b), TOBN(0x5f0e6f4e, 0x98a0403b)}}, + {{TOBN(0x08129684, 0x69ed2370), TOBN(0x34dc30bd, 0x0871ee26), + TOBN(0x3a5ce948, 0x7c9c5b05), TOBN(0x7d487b80, 0x43a90c87)}, + {TOBN(0x4089ba37, 0xdd0e7179), TOBN(0x45f80191, 0xb4041811), + TOBN(0x1c3e1058, 0x98747ba5), TOBN(0x98c4e13a, 0x6e1ae592)}}, + {{TOBN(0xd44636e6, 0xe82c9f9e), TOBN(0x711db87c, 0xc33a1043), + TOBN(0x6f431263, 0xaa8aec05), TOBN(0x43ff120d, 0x2744a4aa)}, + {TOBN(0xd3bd892f, 0xae77779b), TOBN(0xf0fe0cc9, 0x8cdc9f82), + TOBN(0xca5f7fe6, 0xf1c5b1bc), TOBN(0xcc63a682, 0x44929a72)}}, + {{TOBN(0xc7eaba0c, 0x09dbe19a), TOBN(0x2f3585ad, 0x6b5c73c2), + TOBN(0x8ab8924b, 0x0ae50c30), TOBN(0x17fcd27a, 0x638b30ba)}, + {TOBN(0xaf414d34, 0x10b3d5a5), TOBN(0x09c107d2, 0x2a9accf1), + TOBN(0x15dac49f, 0x946a6242), TOBN(0xaec3df2a, 0xd707d642)}}, + {{TOBN(0x2c2492b7, 0x3f894ae0), TOBN(0xf59df3e5, 0xb75f18ce), + TOBN(0x7cb740d2, 0x8f53cad0), TOBN(0x3eb585fb, 0xc4f01294)}, + {TOBN(0x17da0c86, 0x32c7f717), TOBN(0xeb8c795b, 0xaf943f4c), + TOBN(0x4ee23fb5, 0xf67c51d2), TOBN(0xef187575, 0x68889949)}}, + {{TOBN(0xa6b4bdb2, 0x0389168b), TOBN(0xc4ecd258, 0xea577d03), + TOBN(0x3a63782b, 0x55743082), TOBN(0x6f678f4c, 0xc72f08cd)}, + {TOBN(0x553511cf, 0x65e58dd8), TOBN(0xd53b4e3e, 0xd402c0cd), + TOBN(0x37de3e29, 0xa037c14c), TOBN(0x86b6c516, 0xc05712aa)}}, + {{TOBN(0x2834da3e, 0xb38dff6f), TOBN(0xbe012c52, 0xea636be8), + TOBN(0x292d238c, 0x61dd37f8), TOBN(0x0e54523f, 0x8f8142db)}, + {TOBN(0xe31eb436, 0x036a05d8), TOBN(0x83e3cdff, 0x1e93c0ff), + TOBN(0x3fd2fe0f, 0x50821ddf), TOBN(0xc8e19b0d, 0xff9eb33b)}}, + {{TOBN(0xc8cc943f, 0xb569a5fe), TOBN(0xad0090d4, 0xd4342d75), + TOBN(0x82090b4b, 0xcaeca000), TOBN(0xca39687f, 0x1bd410eb)}, + {TOBN(0xe7bb0df7, 0x65959d77), TOBN(0x39d78218, 0x9c964999), + TOBN(0xd87f62e8, 0xb2415451), TOBN(0xe5efb774, 0xbed76108)}}, + {{TOBN(0x3ea011a4, 0xe822f0d0), TOBN(0xbc647ad1, 0x5a8704f8), + TOBN(0xbb315b35, 0x50c6820f), TOBN(0x863dec3d, 0xb7e76bec)}, + {TOBN(0x01ff5d3a, 0xf017bfc7), TOBN(0x20054439, 0x976b8229), + TOBN(0x067fca37, 0x0bbd0d3b), TOBN(0xf63dde64, 0x7f5e3d0f)}}, + {{TOBN(0x22dbefb3, 0x2a4c94e9), TOBN(0xafbff0fe, 0x96f8278a), + TOBN(0x80aea0b1, 0x3503793d), TOBN(0xb2238029, 0x5f06cd29)}, + {TOBN(0x65703e57, 0x8ec3feca), TOBN(0x06c38314, 0x393e7053), + TOBN(0xa0b751eb, 0x7c6734c4), TOBN(0xd2e8a435, 0xc59f0f1e)}}, + {{TOBN(0x147d9052, 0x5e9ca895), TOBN(0x2f4dd31e, 0x972072df), + TOBN(0xa16fda8e, 0xe6c6755c), TOBN(0xc66826ff, 0xcf196558)}, + {TOBN(0x1f1a76a3, 0x0cf43895), TOBN(0xa9d604e0, 0x83c3097b), + TOBN(0xe1908309, 0x66390e0e), TOBN(0xa50bf753, 0xb3c85eff)}}, + {{TOBN(0x0696bdde, 0xf6a70251), TOBN(0x548b801b, 0x3c6ab16a), + TOBN(0x37fcf704, 0xa4d08762), TOBN(0x090b3def, 0xdff76c4e)}, + {TOBN(0x87e8cb89, 0x69cb9158), TOBN(0x44a90744, 0x995ece43), + TOBN(0xf85395f4, 0x0ad9fbf5), TOBN(0x49b0f6c5, 0x4fb0c82d)}}, + {{TOBN(0x75d9bc15, 0xadf7cccf), TOBN(0x81a3e5d6, 0xdfa1e1b0), + TOBN(0x8c39e444, 0x249bc17e), TOBN(0xf37dccb2, 0x8ea7fd43)}, + {TOBN(0xda654873, 0x907fba12), TOBN(0x35daa6da, 0x4a372904), + TOBN(0x0564cfc6, 0x6283a6c5), TOBN(0xd09fa4f6, 0x4a9395bf)}}, + {{TOBN(0x688e9ec9, 0xaeb19a36), TOBN(0xd913f1ce, 0xc7bfbfb4), + TOBN(0x797b9a3c, 0x61c2faa6), TOBN(0x2f979bec, 0x6a0a9c12)}, + {TOBN(0xb5969d0f, 0x359679ec), TOBN(0xebcf523d, 0x079b0460), + TOBN(0xfd6b0008, 0x10fab870), TOBN(0x3f2edcda, 0x9373a39c)}}, + {{TOBN(0x0d64f9a7, 0x6f568431), TOBN(0xf848c27c, 0x02f8898c), + TOBN(0xf418ade1, 0x260b5bd5), TOBN(0xc1f3e323, 0x6973dee8)}, + {TOBN(0x46e9319c, 0x26c185dd), TOBN(0x6d85b7d8, 0x546f0ac4), + TOBN(0x427965f2, 0x247f9d57), TOBN(0xb519b636, 0xb0035f48)}}, + {{TOBN(0x6b6163a9, 0xab87d59c), TOBN(0xff9f58c3, 0x39caaa11), + TOBN(0x4ac39cde, 0x3177387b), TOBN(0x5f6557c2, 0x873e77f9)}, + {TOBN(0x67504006, 0x36a83041), TOBN(0x9b1c96ca, 0x75ef196c), + TOBN(0xf34283de, 0xb08c7940), TOBN(0x7ea09644, 0x1128c316)}}, + {{TOBN(0xb510b3b5, 0x6aa39dff), TOBN(0x59b43da2, 0x9f8e4d8c), + TOBN(0xa8ce31fd, 0x9e4c4b9f), TOBN(0x0e20be26, 0xc1303c01)}, + {TOBN(0x18187182, 0xe8ee47c9), TOBN(0xd9687cdb, 0x7db98101), + TOBN(0x7a520e4d, 0xa1e14ff6), TOBN(0x429808ba, 0x8836d572)}}, + {{TOBN(0xa37ca60d, 0x4944b663), TOBN(0xf901f7a9, 0xa3f91ae5), + TOBN(0xe4e3e76e, 0x9e36e3b1), TOBN(0x9aa219cf, 0x29d93250)}, + {TOBN(0x347fe275, 0x056a2512), TOBN(0xa4d643d9, 0xde65d95c), + TOBN(0x9669d396, 0x699fc3ed), TOBN(0xb598dee2, 0xcf8c6bbe)}}, + {{TOBN(0x682ac1e5, 0xdda9e5c6), TOBN(0x4e0d3c72, 0xcaa9fc95), + TOBN(0x17faaade, 0x772bea44), TOBN(0x5ef8428c, 0xab0009c8)}, + {TOBN(0xcc4ce47a, 0x460ff016), TOBN(0xda6d12bf, 0x725281cb), + TOBN(0x44c67848, 0x0223aad2), TOBN(0x6e342afa, 0x36256e28)}}, + {{TOBN(0x1400bb0b, 0x93a37c04), TOBN(0x62b1bc9b, 0xdd10bd96), + TOBN(0x7251adeb, 0x0dac46b7), TOBN(0x7d33b92e, 0x7be4ef51)}, + {TOBN(0x28b2a94b, 0xe61fa29a), TOBN(0x4b2be13f, 0x06422233), + TOBN(0x36d6d062, 0x330d8d37), TOBN(0x5ef80e1e, 0xb28ca005)}}, + {{TOBN(0x174d4699, 0x6d16768e), TOBN(0x9fc4ff6a, 0x628bf217), + TOBN(0x77705a94, 0x154e490d), TOBN(0x9d96dd28, 0x8d2d997a)}, + {TOBN(0x77e2d9d8, 0xce5d72c4), TOBN(0x9d06c5a4, 0xc11c714f), + TOBN(0x02aa5136, 0x79e4a03e), TOBN(0x1386b3c2, 0x030ff28b)}}, + {{TOBN(0xfe82e8a6, 0xfb283f61), TOBN(0x7df203e5, 0xf3abc3fb), + TOBN(0xeec7c351, 0x3a4d3622), TOBN(0xf7d17dbf, 0xdf762761)}, + {TOBN(0xc3956e44, 0x522055f0), TOBN(0xde3012db, 0x8fa748db), + TOBN(0xca9fcb63, 0xbf1dcc14), TOBN(0xa56d9dcf, 0xbe4e2f3a)}}, + {{TOBN(0xb86186b6, 0x8bcec9c2), TOBN(0x7cf24df9, 0x680b9f06), + TOBN(0xc46b45ea, 0xc0d29281), TOBN(0xfff42bc5, 0x07b10e12)}, + {TOBN(0x12263c40, 0x4d289427), TOBN(0x3d5f1899, 0xb4848ec4), + TOBN(0x11f97010, 0xd040800c), TOBN(0xb4c5f529, 0x300feb20)}}, + {{TOBN(0xcc543f8f, 0xde94fdcb), TOBN(0xe96af739, 0xc7c2f05e), + TOBN(0xaa5e0036, 0x882692e1), TOBN(0x09c75b68, 0x950d4ae9)}, + {TOBN(0x62f63df2, 0xb5932a7a), TOBN(0x2658252e, 0xde0979ad), + TOBN(0x2a19343f, 0xb5e69631), TOBN(0x718c7501, 0x525b666b)}}, + {{TOBN(0x26a42d69, 0xea40dc3a), TOBN(0xdc84ad22, 0xaecc018f), + TOBN(0x25c36c7b, 0x3270f04a), TOBN(0x46ba6d47, 0x50fa72ed)}, + {TOBN(0x6c37d1c5, 0x93e58a8e), TOBN(0xa2394731, 0x120c088c), + TOBN(0xc3be4263, 0xcb6e86da), TOBN(0x2c417d36, 0x7126d038)}}, + {{TOBN(0x5b70f9c5, 0x8b6f8efa), TOBN(0x671a2faa, 0x37718536), + TOBN(0xd3ced3c6, 0xb539c92b), TOBN(0xe56f1bd9, 0xa31203c2)}, + {TOBN(0x8b096ec4, 0x9ff3c8eb), TOBN(0x2deae432, 0x43491cea), + TOBN(0x2465c6eb, 0x17943794), TOBN(0x5d267e66, 0x20586843)}}, + {{TOBN(0x9d3d116d, 0xb07159d0), TOBN(0xae07a67f, 0xc1896210), + TOBN(0x8fc84d87, 0xbb961579), TOBN(0x30009e49, 0x1c1f8dd6)}, + {TOBN(0x8a8caf22, 0xe3132819), TOBN(0xcffa197c, 0xf23ab4ff), + TOBN(0x58103a44, 0x205dd687), TOBN(0x57b796c3, 0x0ded67a2)}}, + {{TOBN(0x0b9c3a6c, 0xa1779ad7), TOBN(0xa33cfe2e, 0x357c09c5), + TOBN(0x2ea29315, 0x3db4a57e), TOBN(0x91959695, 0x8ebeb52e)}, + {TOBN(0x118db9a6, 0xe546c879), TOBN(0x8e996df4, 0x6295c8d6), + TOBN(0xdd990484, 0x55ec806b), TOBN(0x24f291ca, 0x165c1035)}}, + {{TOBN(0xcca523bb, 0x440e2229), TOBN(0x324673a2, 0x73ef4d04), + TOBN(0xaf3adf34, 0x3e11ec39), TOBN(0x6136d7f1, 0xdc5968d3)}, + {TOBN(0x7a7b2899, 0xb053a927), TOBN(0x3eaa2661, 0xae067ecd), + TOBN(0x8549b9c8, 0x02779cd9), TOBN(0x061d7940, 0xc53385ea)}}, + {{TOBN(0x3e0ba883, 0xf06d18bd), TOBN(0x4ba6de53, 0xb2700843), + TOBN(0xb966b668, 0x591a9e4d), TOBN(0x93f67567, 0x7f4fa0ed)}, + {TOBN(0x5a02711b, 0x4347237b), TOBN(0xbc041e2f, 0xe794608e), + TOBN(0x55af10f5, 0x70f73d8c), TOBN(0xd2d4d4f7, 0xbb7564f7)}}, + {{TOBN(0xd7d27a89, 0xb3e93ce7), TOBN(0xf7b5a875, 0x5d3a2c1b), + TOBN(0xb29e68a0, 0x255b218a), TOBN(0xb533837e, 0x8af76754)}, + {TOBN(0xd1b05a73, 0x579fab2e), TOBN(0xb41055a1, 0xecd74385), + TOBN(0xb2369274, 0x445e9115), TOBN(0x2972a7c4, 0xf520274e)}}, + {{TOBN(0x6c08334e, 0xf678e68a), TOBN(0x4e4160f0, 0x99b057ed), + TOBN(0x3cfe11b8, 0x52ccb69a), TOBN(0x2fd1823a, 0x21c8f772)}, + {TOBN(0xdf7f072f, 0x3298f055), TOBN(0x8c0566f9, 0xfec74a6e), + TOBN(0xe549e019, 0x5bb4d041), TOBN(0x7c3930ba, 0x9208d850)}}, + {{TOBN(0xe07141fc, 0xaaa2902b), TOBN(0x539ad799, 0xe4f69ad3), + TOBN(0xa6453f94, 0x813f9ffd), TOBN(0xc58d3c48, 0x375bc2f7)}, + {TOBN(0xb3326fad, 0x5dc64e96), TOBN(0x3aafcaa9, 0xb240e354), + TOBN(0x1d1b0903, 0xaca1e7a9), TOBN(0x4ceb9767, 0x1211b8a0)}}, + {{TOBN(0xeca83e49, 0xe32a858e), TOBN(0x4c32892e, 0xae907bad), + TOBN(0xd5b42ab6, 0x2eb9b494), TOBN(0x7fde3ee2, 0x1eabae1b)}, + {TOBN(0x13b5ab09, 0xcaf54957), TOBN(0xbfb028be, 0xe5f5d5d5), + TOBN(0x928a0650, 0x2003e2c0), TOBN(0x90793aac, 0x67476843)}}, + {{TOBN(0x5e942e79, 0xc81710a0), TOBN(0x557e4a36, 0x27ccadd4), + TOBN(0x72a2bc56, 0x4bcf6d0c), TOBN(0x09ee5f43, 0x26d7b80c)}, + {TOBN(0x6b70dbe9, 0xd4292f19), TOBN(0x56f74c26, 0x63f16b18), + TOBN(0xc23db0f7, 0x35fbb42a), TOBN(0xb606bdf6, 0x6ae10040)}}, + {{TOBN(0x1eb15d4d, 0x044573ac), TOBN(0x7dc3cf86, 0x556b0ba4), + TOBN(0x97af9a33, 0xc60df6f7), TOBN(0x0b1ef85c, 0xa716ce8c)}, + {TOBN(0x2922f884, 0xc96958be), TOBN(0x7c32fa94, 0x35690963), + TOBN(0x2d7f667c, 0xeaa00061), TOBN(0xeaaf7c17, 0x3547365c)}}, + {{TOBN(0x1eb4de46, 0x87032d58), TOBN(0xc54f3d83, 0x5e2c79e0), + TOBN(0x07818df4, 0x5d04ef23), TOBN(0x55faa9c8, 0x673d41b4)}, + {TOBN(0xced64f6f, 0x89b95355), TOBN(0x4860d2ea, 0xb7415c84), + TOBN(0x5fdb9bd2, 0x050ebad3), TOBN(0xdb53e0cc, 0x6685a5bf)}}, + {{TOBN(0xb830c031, 0x9feb6593), TOBN(0xdd87f310, 0x6accff17), + TOBN(0x2303ebab, 0x9f555c10), TOBN(0x94603695, 0x287e7065)}, + {TOBN(0xf88311c3, 0x2e83358c), TOBN(0x508dd9b4, 0xeefb0178), + TOBN(0x7ca23706, 0x2dba8652), TOBN(0x62aac5a3, 0x0047abe5)}}, + {{TOBN(0x9a61d2a0, 0x8b1ea7b3), TOBN(0xd495ab63, 0xae8b1485), + TOBN(0x38740f84, 0x87052f99), TOBN(0x178ebe5b, 0xb2974eea)}, + {TOBN(0x030bbcca, 0x5b36d17f), TOBN(0xb5e4cce3, 0xaaf86eea), + TOBN(0xb51a0220, 0x68f8e9e0), TOBN(0xa4348796, 0x09eb3e75)}}, + {{TOBN(0xbe592309, 0xeef1a752), TOBN(0x5d7162d7, 0x6f2aa1ed), + TOBN(0xaebfb5ed, 0x0f007dd2), TOBN(0x255e14b2, 0xc89edd22)}, + {TOBN(0xba85e072, 0x0303b697), TOBN(0xc5d17e25, 0xf05720ff), + TOBN(0x02b58d6e, 0x5128ebb6), TOBN(0x2c80242d, 0xd754e113)}}, + {{TOBN(0x919fca5f, 0xabfae1ca), TOBN(0x937afaac, 0x1a21459b), + TOBN(0x9e0ca91c, 0x1f66a4d2), TOBN(0x194cc7f3, 0x23ec1331)}, + {TOBN(0xad25143a, 0x8aa11690), TOBN(0xbe40ad8d, 0x09b59e08), + TOBN(0x37d60d9b, 0xe750860a), TOBN(0x6c53b008, 0xc6bf434c)}}, + {{TOBN(0xb572415d, 0x1356eb80), TOBN(0xb8bf9da3, 0x9578ded8), + TOBN(0x22658e36, 0x5e8fb38b), TOBN(0x9b70ce22, 0x5af8cb22)}, + {TOBN(0x7c00018a, 0x829a8180), TOBN(0x84329f93, 0xb81ed295), + TOBN(0x7c343ea2, 0x5f3cea83), TOBN(0x38f8655f, 0x67586536)}}, + {{TOBN(0xa661a0d0, 0x1d3ec517), TOBN(0x98744652, 0x512321ae), + TOBN(0x084ca591, 0xeca92598), TOBN(0xa9bb9dc9, 0x1dcb3feb)}, + {TOBN(0x14c54355, 0x78b4c240), TOBN(0x5ed62a3b, 0x610cafdc), + TOBN(0x07512f37, 0x1b38846b), TOBN(0x571bb70a, 0xb0e38161)}}, + {{TOBN(0xb556b95b, 0x2da705d2), TOBN(0x3ef8ada6, 0xb1a08f98), + TOBN(0x85302ca7, 0xddecfbe5), TOBN(0x0e530573, 0x943105cd)}, + {TOBN(0x60554d55, 0x21a9255d), TOBN(0x63a32fa1, 0xf2f3802a), + TOBN(0x35c8c5b0, 0xcd477875), TOBN(0x97f458ea, 0x6ad42da1)}}, + {{TOBN(0x832d7080, 0xeb6b242d), TOBN(0xd30bd023, 0x3b71e246), + TOBN(0x7027991b, 0xbe31139d), TOBN(0x68797e91, 0x462e4e53)}, + {TOBN(0x423fe20a, 0x6b4e185a), TOBN(0x82f2c67e, 0x42d9b707), + TOBN(0x25c81768, 0x4cf7811b), TOBN(0xbd53005e, 0x045bb95d)}}}, + {{{TOBN(0xe5f649be, 0x9d8e68fd), TOBN(0xdb0f0533, 0x1b044320), + TOBN(0xf6fde9b3, 0xe0c33398), TOBN(0x92f4209b, 0x66c8cfae)}, + {TOBN(0xe9d1afcc, 0x1a739d4b), TOBN(0x09aea75f, 0xa28ab8de), + TOBN(0x14375fb5, 0xeac6f1d0), TOBN(0x6420b560, 0x708f7aa5)}}, + {{TOBN(0x9eae499c, 0x6254dc41), TOBN(0x7e293924, 0x7a837e7e), + TOBN(0x74aec08c, 0x090524a7), TOBN(0xf82b9219, 0x8d6f55f2)}, + {TOBN(0x493c962e, 0x1402cec5), TOBN(0x9f17ca17, 0xfa2f30e7), + TOBN(0xbcd783e8, 0xe9b879cb), TOBN(0xea3d8c14, 0x5a6f145f)}}, + {{TOBN(0xdede15e7, 0x5e0dee6e), TOBN(0x74f24872, 0xdc628aa2), + TOBN(0xd3e9c4fe, 0x7861bb93), TOBN(0x56d4822a, 0x6187b2e0)}, + {TOBN(0xb66417cf, 0xc59826f9), TOBN(0xca260969, 0x2408169e), + TOBN(0xedf69d06, 0xc79ef885), TOBN(0x00031f8a, 0xdc7d138f)}}, + {{TOBN(0x103c46e6, 0x0ebcf726), TOBN(0x4482b831, 0x6231470e), + TOBN(0x6f6dfaca, 0x487c2109), TOBN(0x2e0ace97, 0x62e666ef)}, + {TOBN(0x3246a9d3, 0x1f8d1f42), TOBN(0x1b1e83f1, 0x574944d2), + TOBN(0x13dfa63a, 0xa57f334b), TOBN(0x0cf8daed, 0x9f025d81)}}, + {{TOBN(0x30d78ea8, 0x00ee11c1), TOBN(0xeb053cd4, 0xb5e3dd75), + TOBN(0x9b65b13e, 0xd58c43c5), TOBN(0xc3ad49bd, 0xbd151663)}, + {TOBN(0x99fd8e41, 0xb6427990), TOBN(0x12cf15bd, 0x707eae1e), + TOBN(0x29ad4f1b, 0x1aabb71e), TOBN(0x5143e74d, 0x07545d0e)}}, + {{TOBN(0x30266336, 0xc88bdee1), TOBN(0x25f29306, 0x5876767c), + TOBN(0x9c078571, 0xc6731996), TOBN(0xc88690b2, 0xed552951)}, + {TOBN(0x274f2c2d, 0x852705b4), TOBN(0xb0bf8d44, 0x4e09552d), + TOBN(0x7628beeb, 0x986575d1), TOBN(0x407be238, 0x7f864651)}}, + {{TOBN(0x0e5e3049, 0xa639fc6b), TOBN(0xe75c35d9, 0x86003625), + TOBN(0x0cf35bd8, 0x5dcc1646), TOBN(0x8bcaced2, 0x6c26273a)}, + {TOBN(0xe22ecf1d, 0xb5536742), TOBN(0x013dd897, 0x1a9e068b), + TOBN(0x17f411cb, 0x8a7909c5), TOBN(0x5757ac98, 0x861dd506)}}, + {{TOBN(0x85de1f0d, 0x1e935abb), TOBN(0xdefd10b4, 0x154de37a), + TOBN(0xb8d9e392, 0x369cebb5), TOBN(0x54d5ef9b, 0x761324be)}, + {TOBN(0x4d6341ba, 0x74f17e26), TOBN(0xc0a0e3c8, 0x78c1dde4), + TOBN(0xa6d77581, 0x87d918fd), TOBN(0x66876015, 0x02ca3a13)}}, + {{TOBN(0xc7313e9c, 0xf36658f0), TOBN(0xc433ef1c, 0x71f8057e), + TOBN(0x85326246, 0x1b6a835a), TOBN(0xc8f05398, 0x7c86394c)}, + {TOBN(0xff398cdf, 0xe983c4a1), TOBN(0xbf5e8162, 0x03b7b931), + TOBN(0x93193c46, 0xb7b9045b), TOBN(0x1e4ebf5d, 0xa4a6e46b)}}, + {{TOBN(0xf9942a60, 0x43a24fe7), TOBN(0x29c1191e, 0xffb3492b), + TOBN(0x9f662449, 0x902fde05), TOBN(0xc792a7ac, 0x6713c32d)}, + {TOBN(0x2fd88ad8, 0xb737982c), TOBN(0x7e3a0319, 0xa21e60e3), + TOBN(0x09b0de44, 0x7383591a), TOBN(0x6df141ee, 0x8310a456)}}, + {{TOBN(0xaec1a039, 0xe6d6f471), TOBN(0x14b2ba0f, 0x1198d12e), + TOBN(0xebc1a160, 0x3aeee5ac), TOBN(0x401f4836, 0xe0b964ce)}, + {TOBN(0x2ee43796, 0x4fd03f66), TOBN(0x3fdb4e49, 0xdd8f3f12), + TOBN(0x6ef267f6, 0x29380f18), TOBN(0x3e8e9670, 0x8da64d16)}}, + {{TOBN(0xbc19180c, 0x207674f1), TOBN(0x112e09a7, 0x33ae8fdb), + TOBN(0x99667554, 0x6aaeb71e), TOBN(0x79432af1, 0xe101b1c7)}, + {TOBN(0xd5eb558f, 0xde2ddec6), TOBN(0x81392d1f, 0x5357753f), + TOBN(0xa7a76b97, 0x3ae1158a), TOBN(0x416fbbff, 0x4a899991)}}, + {{TOBN(0x9e65fdfd, 0x0d4a9dcf), TOBN(0x7bc29e48, 0x944ddf12), + TOBN(0xbc1a92d9, 0x3c856866), TOBN(0x273c6905, 0x6e98dfe2)}, + {TOBN(0x69fce418, 0xcdfaa6b8), TOBN(0x606bd823, 0x5061c69f), + TOBN(0x42d495a0, 0x6af75e27), TOBN(0x8ed3d505, 0x6d873a1f)}}, + {{TOBN(0xaf552841, 0x6ab25b6a), TOBN(0xc6c0ffc7, 0x2b1a4523), + TOBN(0xab18827b, 0x21c99e03), TOBN(0x060e8648, 0x9034691b)}, + {TOBN(0x5207f90f, 0x93c7f398), TOBN(0x9f4a96cb, 0x82f8d10b), + TOBN(0xdd71cd79, 0x3ad0f9e3), TOBN(0x84f435d2, 0xfc3a54f5)}}, + {{TOBN(0x4b03c55b, 0x8e33787f), TOBN(0xef42f975, 0xa6384673), + TOBN(0xff7304f7, 0x5051b9f0), TOBN(0x18aca1dc, 0x741c87c2)}, + {TOBN(0x56f120a7, 0x2d4bfe80), TOBN(0xfd823b3d, 0x053e732c), + TOBN(0x11bccfe4, 0x7537ca16), TOBN(0xdf6c9c74, 0x1b5a996b)}}, + {{TOBN(0xee7332c7, 0x904fc3fa), TOBN(0x14a23f45, 0xc7e3636a), + TOBN(0xc38659c3, 0xf091d9aa), TOBN(0x4a995e5d, 0xb12d8540)}, + {TOBN(0x20a53bec, 0xf3a5598a), TOBN(0x56534b17, 0xb1eaa995), + TOBN(0x9ed3dca4, 0xbf04e03c), TOBN(0x716c563a, 0xd8d56268)}}, + {{TOBN(0x27ba77a4, 0x1d6178e7), TOBN(0xe4c80c40, 0x68a1ff8e), + TOBN(0x75011099, 0x0a13f63d), TOBN(0x7bf33521, 0xa61d46f3)}, + {TOBN(0x0aff218e, 0x10b365bb), TOBN(0x81021804, 0x0fd7ea75), + TOBN(0x05a3fd8a, 0xa4b3a925), TOBN(0xb829e75f, 0x9b3db4e6)}}, + {{TOBN(0x6bdc75a5, 0x4d53e5fb), TOBN(0x04a5dc02, 0xd52717e3), + TOBN(0x86af502f, 0xe9a42ec2), TOBN(0x8867e8fb, 0x2630e382)}, + {TOBN(0xbf845c6e, 0xbec9889b), TOBN(0x54f491f2, 0xcb47c98d), + TOBN(0xa3091fba, 0x790c2a12), TOBN(0xd7f6fd78, 0xc20f708b)}}, + {{TOBN(0xa569ac30, 0xacde5e17), TOBN(0xd0f996d0, 0x6852b4d7), + TOBN(0xe51d4bb5, 0x4609ae54), TOBN(0x3fa37d17, 0x0daed061)}, + {TOBN(0x62a88684, 0x34b8fb41), TOBN(0x99a2acbd, 0x9efb64f1), + TOBN(0xb75c1a5e, 0x6448e1f2), TOBN(0xfa99951a, 0x42b5a069)}}, + {{TOBN(0x6d956e89, 0x2f3b26e7), TOBN(0xf4709860, 0xda875247), + TOBN(0x3ad15179, 0x2482dda3), TOBN(0xd64110e3, 0x017d82f0)}, + {TOBN(0x14928d2c, 0xfad414e4), TOBN(0x2b155f58, 0x2ed02b24), + TOBN(0x481a141b, 0xcb821bf1), TOBN(0x12e3c770, 0x4f81f5da)}}, + {{TOBN(0xe49c5de5, 0x9fff8381), TOBN(0x11053232, 0x5bbec894), + TOBN(0xa0d051cc, 0x454d88c4), TOBN(0x4f6db89c, 0x1f8e531b)}, + {TOBN(0x34fe3fd6, 0xca563a44), TOBN(0x7f5c2215, 0x58da8ab9), + TOBN(0x8445016d, 0x9474f0a1), TOBN(0x17d34d61, 0xcb7d8a0a)}}, + {{TOBN(0x8e9d3910, 0x1c474019), TOBN(0xcaff2629, 0xd52ceefb), + TOBN(0xf9cf3e32, 0xc1622c2b), TOBN(0xd4b95e3c, 0xe9071a05)}, + {TOBN(0xfbbca61f, 0x1594438c), TOBN(0x1eb6e6a6, 0x04aadedf), + TOBN(0x853027f4, 0x68e14940), TOBN(0x221d322a, 0xdfabda9c)}}, + {{TOBN(0xed8ea9f6, 0xb7cb179a), TOBN(0xdc7b764d, 0xb7934dcc), + TOBN(0xfcb13940, 0x5e09180d), TOBN(0x6629a6bf, 0xb47dc2dd)}, + {TOBN(0xbfc55e4e, 0x9f5a915e), TOBN(0xb1db9d37, 0x6204441e), + TOBN(0xf82d68cf, 0x930c5f53), TOBN(0x17d3a142, 0xcbb605b1)}}, + {{TOBN(0xdd5944ea, 0x308780f2), TOBN(0xdc8de761, 0x3845f5e4), + TOBN(0x6beaba7d, 0x7624d7a3), TOBN(0x1e709afd, 0x304df11e)}, + {TOBN(0x95364376, 0x02170456), TOBN(0xbf204b3a, 0xc8f94b64), + TOBN(0x4e53af7c, 0x5680ca68), TOBN(0x0526074a, 0xe0c67574)}}, + {{TOBN(0x95d8cef8, 0xecd92af6), TOBN(0xe6b9fa7a, 0x6cd1745a), + TOBN(0x3d546d3d, 0xa325c3e4), TOBN(0x1f57691d, 0x9ae93aae)}, + {TOBN(0xe891f3fe, 0x9d2e1a33), TOBN(0xd430093f, 0xac063d35), + TOBN(0xeda59b12, 0x5513a327), TOBN(0xdc2134f3, 0x5536f18f)}}, + {{TOBN(0xaa51fe2c, 0x5c210286), TOBN(0x3f68aaee, 0x1cab658c), + TOBN(0x5a23a00b, 0xf9357292), TOBN(0x9a626f39, 0x7efdabed)}, + {TOBN(0xfe2b3bf3, 0x199d78e3), TOBN(0xb7a2af77, 0x71bbc345), + TOBN(0x3d19827a, 0x1e59802c), TOBN(0x823bbc15, 0xb487a51c)}}, + {{TOBN(0x856139f2, 0x99d0a422), TOBN(0x9ac3df65, 0xf456c6fb), + TOBN(0xaddf65c6, 0x701f8bd6), TOBN(0x149f321e, 0x3758df87)}, + {TOBN(0xb1ecf714, 0x721b7eba), TOBN(0xe17df098, 0x31a3312a), + TOBN(0xdb2fd6ec, 0xd5c4d581), TOBN(0xfd02996f, 0x8fcea1b3)}}, + {{TOBN(0xe29fa63e, 0x7882f14f), TOBN(0xc9f6dc35, 0x07c6cadc), + TOBN(0x46f22d6f, 0xb882bed0), TOBN(0x1a45755b, 0xd118e52c)}, + {TOBN(0x9f2c7c27, 0x7c4608cf), TOBN(0x7ccbdf32, 0x568012c2), + TOBN(0xfcb0aedd, 0x61729b0e), TOBN(0x7ca2ca9e, 0xf7d75dbf)}}, + {{TOBN(0xf58fecb1, 0x6f640f62), TOBN(0xe274b92b, 0x39f51946), + TOBN(0x7f4dfc04, 0x6288af44), TOBN(0x0a91f32a, 0xeac329e5)}, + {TOBN(0x43ad274b, 0xd6aaba31), TOBN(0x719a1640, 0x0f6884f9), + TOBN(0x685d29f6, 0xdaf91e20), TOBN(0x5ec1cc33, 0x27e49d52)}}, + {{TOBN(0x38f4de96, 0x3b54a059), TOBN(0x0e0015e5, 0xefbcfdb3), + TOBN(0x177d23d9, 0x4dbb8da6), TOBN(0x98724aa2, 0x97a617ad)}, + {TOBN(0x30f0885b, 0xfdb6558e), TOBN(0xf9f7a28a, 0xc7899a96), + TOBN(0xd2ae8ac8, 0x872dc112), TOBN(0xfa0642ca, 0x73c3c459)}}, + {{TOBN(0x15296981, 0xe7dfc8d6), TOBN(0x67cd4450, 0x1fb5b94a), + TOBN(0x0ec71cf1, 0x0eddfd37), TOBN(0xc7e5eeb3, 0x9a8eddc7)}, + {TOBN(0x02ac8e3d, 0x81d95028), TOBN(0x0088f172, 0x70b0e35d), + TOBN(0xec041fab, 0xe1881fe3), TOBN(0x62cf71b8, 0xd99e7faa)}}, + {{TOBN(0x5043dea7, 0xe0f222c2), TOBN(0x309d42ac, 0x72e65142), + TOBN(0x94fe9ddd, 0x9216cd30), TOBN(0xd6539c7d, 0x0f87feec)}, + {TOBN(0x03c5a57c, 0x432ac7d7), TOBN(0x72692cf0, 0x327fda10), + TOBN(0xec28c85f, 0x280698de), TOBN(0x2331fb46, 0x7ec283b1)}}, + {{TOBN(0xd34bfa32, 0x2867e633), TOBN(0x78709a82, 0x0a9cc815), + TOBN(0xb7fe6964, 0x875e2fa5), TOBN(0x25cc064f, 0x9e98bfb5)}, + {TOBN(0x9eb0151c, 0x493a65c5), TOBN(0x5fb5d941, 0x53182464), + TOBN(0x69e6f130, 0xf04618e2), TOBN(0xa8ecec22, 0xf89c8ab6)}}, + {{TOBN(0xcd6ac88b, 0xb96209bd), TOBN(0x65fa8cdb, 0xb3e1c9e0), + TOBN(0xa47d22f5, 0x4a8d8eac), TOBN(0x83895cdf, 0x8d33f963)}, + {TOBN(0xa8adca59, 0xb56cd3d1), TOBN(0x10c8350b, 0xdaf38232), + TOBN(0x2b161fb3, 0xa5080a9f), TOBN(0xbe7f5c64, 0x3af65b3a)}}, + {{TOBN(0x2c754039, 0x97403a11), TOBN(0x94626cf7, 0x121b96af), + TOBN(0x431de7c4, 0x6a983ec2), TOBN(0x3780dd3a, 0x52cc3df7)}, + {TOBN(0xe28a0e46, 0x2baf8e3b), TOBN(0xabe68aad, 0x51d299ae), + TOBN(0x603eb8f9, 0x647a2408), TOBN(0x14c61ed6, 0x5c750981)}}, + {{TOBN(0x88b34414, 0xc53352e7), TOBN(0x5a34889c, 0x1337d46e), + TOBN(0x612c1560, 0xf95f2bc8), TOBN(0x8a3f8441, 0xd4807a3a)}, + {TOBN(0x680d9e97, 0x5224da68), TOBN(0x60cd6e88, 0xc3eb00e9), + TOBN(0x3875a98e, 0x9a6bc375), TOBN(0xdc80f924, 0x4fd554c2)}}, + {{TOBN(0x6c4b3415, 0x6ac77407), TOBN(0xa1e5ea8f, 0x25420681), + TOBN(0x541bfa14, 0x4607a458), TOBN(0x5dbc7e7a, 0x96d7fbf9)}, + {TOBN(0x646a851b, 0x31590a47), TOBN(0x039e85ba, 0x15ee6df8), + TOBN(0xd19fa231, 0xd7b43fc0), TOBN(0x84bc8be8, 0x299a0e04)}}, + {{TOBN(0x2b9d2936, 0xf20df03a), TOBN(0x24054382, 0x8608d472), + TOBN(0x76b6ba04, 0x9149202a), TOBN(0xb21c3831, 0x3670e7b7)}, + {TOBN(0xddd93059, 0xd6fdee10), TOBN(0x9da47ad3, 0x78488e71), + TOBN(0x99cc1dfd, 0xa0fcfb25), TOBN(0x42abde10, 0x64696954)}}, + {{TOBN(0x14cc15fc, 0x17eab9fe), TOBN(0xd6e863e4, 0xd3e70972), + TOBN(0x29a7765c, 0x6432112c), TOBN(0x88660001, 0x5b0774d8)}, + {TOBN(0x3729175a, 0x2c088eae), TOBN(0x13afbcae, 0x8230b8d4), + TOBN(0x44768151, 0x915f4379), TOBN(0xf086431a, 0xd8d22812)}}, + {{TOBN(0x37461955, 0xc298b974), TOBN(0x905fb5f0, 0xf8711e04), + TOBN(0x787abf3a, 0xfe969d18), TOBN(0x392167c2, 0x6f6a494e)}, + {TOBN(0xfc7a0d2d, 0x28c511da), TOBN(0xf127c7dc, 0xb66a262d), + TOBN(0xf9c4bb95, 0xfd63fdf0), TOBN(0x90016589, 0x3913ef46)}}, + {{TOBN(0x74d2a73c, 0x11aa600d), TOBN(0x2f5379bd, 0x9fb5ab52), + TOBN(0xe49e53a4, 0x7fb70068), TOBN(0x68dd39e5, 0x404aa9a7)}, + {TOBN(0xb9b0cf57, 0x2ecaa9c3), TOBN(0xba0e103b, 0xe824826b), + TOBN(0x60c2198b, 0x4631a3c4), TOBN(0xc5ff84ab, 0xfa8966a2)}}, + {{TOBN(0x2d6ebe22, 0xac95aff8), TOBN(0x1c9bb6db, 0xb5a46d09), + TOBN(0x419062da, 0x53ee4f8d), TOBN(0x7b9042d0, 0xbb97efef)}, + {TOBN(0x0f87f080, 0x830cf6bd), TOBN(0x4861d19a, 0x6ec8a6c6), + TOBN(0xd3a0daa1, 0x202f01aa), TOBN(0xb0111674, 0xf25afbd5)}}, + {{TOBN(0x6d00d6cf, 0x1afb20d9), TOBN(0x13695000, 0x40671bc5), + TOBN(0x913ab0dc, 0x2485ea9b), TOBN(0x1f2bed06, 0x9eef61ac)}, + {TOBN(0x850c8217, 0x6d799e20), TOBN(0x93415f37, 0x3271c2de), + TOBN(0x5afb06e9, 0x6c4f5910), TOBN(0x688a52df, 0xc4e9e421)}}, + {{TOBN(0x30495ba3, 0xe2a9a6db), TOBN(0x4601303d, 0x58f9268b), + TOBN(0xbe3b0dad, 0x7eb0f04f), TOBN(0x4ea47250, 0x4456936d)}, + {TOBN(0x8caf8798, 0xd33fd3e7), TOBN(0x1ccd8a89, 0xeb433708), + TOBN(0x9effe3e8, 0x87fd50ad), TOBN(0xbe240a56, 0x6b29c4df)}}, + {{TOBN(0xec4ffd98, 0xca0e7ebd), TOBN(0xf586783a, 0xe748616e), + TOBN(0xa5b00d8f, 0xc77baa99), TOBN(0x0acada29, 0xb4f34c9c)}, + {TOBN(0x36dad67d, 0x0fe723ac), TOBN(0x1d8e53a5, 0x39c36c1e), + TOBN(0xe4dd342d, 0x1f4bea41), TOBN(0x64fd5e35, 0xebc9e4e0)}}, + {{TOBN(0x96f01f90, 0x57908805), TOBN(0xb5b9ea3d, 0x5ed480dd), + TOBN(0x366c5dc2, 0x3efd2dd0), TOBN(0xed2fe305, 0x6e9dfa27)}, + {TOBN(0x4575e892, 0x6e9197e2), TOBN(0x11719c09, 0xab502a5d), + TOBN(0x264c7bec, 0xe81f213f), TOBN(0x741b9241, 0x55f5c457)}}, + {{TOBN(0x78ac7b68, 0x49a5f4f4), TOBN(0xf91d70a2, 0x9fc45b7d), + TOBN(0x39b05544, 0xb0f5f355), TOBN(0x11f06bce, 0xeef930d9)}, + {TOBN(0xdb84d25d, 0x038d05e1), TOBN(0x04838ee5, 0xbacc1d51), + TOBN(0x9da3ce86, 0x9e8ee00b), TOBN(0xc3412057, 0xc36eda1f)}}, + {{TOBN(0xae80b913, 0x64d9c2f4), TOBN(0x7468bac3, 0xa010a8ff), + TOBN(0xdfd20037, 0x37359d41), TOBN(0x1a0f5ab8, 0x15efeacc)}, + {TOBN(0x7c25ad2f, 0x659d0ce0), TOBN(0x4011bcbb, 0x6785cff1), + TOBN(0x128b9912, 0x7e2192c7), TOBN(0xa549d8e1, 0x13ccb0e8)}}, + {{TOBN(0x805588d8, 0xc85438b1), TOBN(0x5680332d, 0xbc25cb27), + TOBN(0xdcd1bc96, 0x1a4bfdf4), TOBN(0x779ff428, 0x706f6566)}, + {TOBN(0x8bbee998, 0xf059987a), TOBN(0xf6ce8cf2, 0xcc686de7), + TOBN(0xf8ad3c4a, 0x953cfdb2), TOBN(0xd1d426d9, 0x2205da36)}}, + {{TOBN(0xb3c0f13f, 0xc781a241), TOBN(0x3e89360e, 0xd75362a8), + TOBN(0xccd05863, 0xc8a91184), TOBN(0x9bd0c9b7, 0xefa8a7f4)}, + {TOBN(0x97ee4d53, 0x8a912a4b), TOBN(0xde5e15f8, 0xbcf518fd), + TOBN(0x6a055bf8, 0xc467e1e0), TOBN(0x10be4b4b, 0x1587e256)}}, + {{TOBN(0xd90c14f2, 0x668621c9), TOBN(0xd5518f51, 0xab9c92c1), + TOBN(0x8e6a0100, 0xd6d47b3c), TOBN(0xcbe980dd, 0x66716175)}, + {TOBN(0x500d3f10, 0xddd83683), TOBN(0x3b6cb35d, 0x99cac73c), + TOBN(0x53730c8b, 0x6083d550), TOBN(0xcf159767, 0xdf0a1987)}}, + {{TOBN(0x84bfcf53, 0x43ad73b3), TOBN(0x1b528c20, 0x4f035a94), + TOBN(0x4294edf7, 0x33eeac69), TOBN(0xb6283e83, 0x817f3240)}, + {TOBN(0xc3fdc959, 0x0a5f25b1), TOBN(0xefaf8aa5, 0x5844ee22), + TOBN(0xde269ba5, 0xdbdde4de), TOBN(0xe3347160, 0xc56133bf)}}, + {{TOBN(0xc1184219, 0x8d9ea9f8), TOBN(0x090de5db, 0xf3fc1ab5), + TOBN(0x404c37b1, 0x0bf22cda), TOBN(0x7de20ec8, 0xf5618894)}, + {TOBN(0x754c588e, 0xecdaecab), TOBN(0x6ca4b0ed, 0x88342743), + TOBN(0x76f08bdd, 0xf4a938ec), TOBN(0xd182de89, 0x91493ccb)}}, + {{TOBN(0xd652c53e, 0xc8a4186a), TOBN(0xb3e878db, 0x946d8e33), + TOBN(0x088453c0, 0x5f37663c), TOBN(0x5cd9daaa, 0xb407748b)}, + {TOBN(0xa1f5197f, 0x586d5e72), TOBN(0x47500be8, 0xc443ca59), + TOBN(0x78ef35b2, 0xe2652424), TOBN(0x09c5d26f, 0x6dd7767d)}}, + {{TOBN(0x7175a79a, 0xa74d3f7b), TOBN(0x0428fd8d, 0xcf5ea459), + TOBN(0x511cb97c, 0xa5d1746d), TOBN(0x36363939, 0xe71d1278)}, + {TOBN(0xcf2df955, 0x10350bf4), TOBN(0xb3817439, 0x60aae782), + TOBN(0xa748c0e4, 0x3e688809), TOBN(0x98021fbf, 0xd7a5a006)}}, + {{TOBN(0x9076a70c, 0x0e367a98), TOBN(0xbea1bc15, 0x0f62b7c2), + TOBN(0x2645a68c, 0x30fe0343), TOBN(0xacaffa78, 0x699dc14f)}, + {TOBN(0xf4469964, 0x457bf9c4), TOBN(0x0db6407b, 0x0d2ead83), + TOBN(0x68d56cad, 0xb2c6f3eb), TOBN(0x3b512e73, 0xf376356c)}}, + {{TOBN(0xe43b0e1f, 0xfce10408), TOBN(0x89ddc003, 0x5a5e257d), + TOBN(0xb0ae0d12, 0x0362e5b3), TOBN(0x07f983c7, 0xb0519161)}, + {TOBN(0xc2e94d15, 0x5d5231e7), TOBN(0xcff22aed, 0x0b4f9513), + TOBN(0xb02588dd, 0x6ad0b0b5), TOBN(0xb967d1ac, 0x11d0dcd5)}}, + {{TOBN(0x8dac6bc6, 0xcf777b6c), TOBN(0x0062bdbd, 0x4c6d1959), + TOBN(0x53da71b5, 0x0ef5cc85), TOBN(0x07012c7d, 0x4006f14f)}, + {TOBN(0x4617f962, 0xac47800d), TOBN(0x53365f2b, 0xc102ed75), + TOBN(0xb422efcb, 0x4ab8c9d3), TOBN(0x195cb26b, 0x34af31c9)}}, + {{TOBN(0x3a926e29, 0x05f2c4ce), TOBN(0xbd2bdecb, 0x9856966c), + TOBN(0x5d16ab3a, 0x85527015), TOBN(0x9f81609e, 0x4486c231)}, + {TOBN(0xd8b96b2c, 0xda350002), TOBN(0xbd054690, 0xfa1b7d36), + TOBN(0xdc90ebf5, 0xe71d79bc), TOBN(0xf241b6f9, 0x08964e4e)}}, + {{TOBN(0x7c838643, 0x2fe3cd4c), TOBN(0xe0f33acb, 0xb4bc633c), + TOBN(0xb4a9ecec, 0x3d139f1f), TOBN(0x05ce69cd, 0xdc4a1f49)}, + {TOBN(0xa19d1b16, 0xf5f98aaf), TOBN(0x45bb71d6, 0x6f23e0ef), + TOBN(0x33789fcd, 0x46cdfdd3), TOBN(0x9b8e2978, 0xcee040ca)}}, + {{TOBN(0x9c69b246, 0xae0a6828), TOBN(0xba533d24, 0x7078d5aa), + TOBN(0x7a2e42c0, 0x7bb4fbdb), TOBN(0xcfb4879a, 0x7035385c)}, + {TOBN(0x8c3dd30b, 0x3281705b), TOBN(0x7e361c6c, 0x404fe081), + TOBN(0x7b21649c, 0x3f604edf), TOBN(0x5dbf6a3f, 0xe52ffe47)}}, + {{TOBN(0xc41b7c23, 0x4b54d9bf), TOBN(0x1374e681, 0x3511c3d9), + TOBN(0x1863bf16, 0xc1b2b758), TOBN(0x90e78507, 0x1e9e6a96)}, + {TOBN(0xab4bf98d, 0x5d86f174), TOBN(0xd74e0bd3, 0x85e96fe4), + TOBN(0x8afde39f, 0xcac5d344), TOBN(0x90946dbc, 0xbd91b847)}}, + {{TOBN(0xf5b42358, 0xfe1a838c), TOBN(0x05aae6c5, 0x620ac9d8), + TOBN(0x8e193bd8, 0xa1ce5a0b), TOBN(0x8f710571, 0x4dabfd72)}, + {TOBN(0x8d8fdd48, 0x182caaac), TOBN(0x8c4aeefa, 0x040745cf), + TOBN(0x73c6c30a, 0xf3b93e6d), TOBN(0x991241f3, 0x16f42011)}}, + {{TOBN(0xa0158eea, 0xe457a477), TOBN(0xd19857db, 0xee6ddc05), + TOBN(0xb3265224, 0x18c41671), TOBN(0x3ffdfc7e, 0x3c2c0d58)}, + {TOBN(0x3a3a5254, 0x26ee7cda), TOBN(0x341b0869, 0xdf02c3a8), + TOBN(0xa023bf42, 0x723bbfc8), TOBN(0x3d15002a, 0x14452691)}}}, + {{{TOBN(0x5ef7324c, 0x85edfa30), TOBN(0x25976554, 0x87d4f3da), + TOBN(0x352f5bc0, 0xdcb50c86), TOBN(0x8f6927b0, 0x4832a96c)}, + {TOBN(0xd08ee1ba, 0x55f2f94c), TOBN(0x6a996f99, 0x344b45fa), + TOBN(0xe133cb8d, 0xa8aa455d), TOBN(0x5d0721ec, 0x758dc1f7)}}, + {{TOBN(0x6ba7a920, 0x79e5fb67), TOBN(0xe1331feb, 0x70aa725e), + TOBN(0x5080ccf5, 0x7df5d837), TOBN(0xe4cae01d, 0x7ff72e21)}, + {TOBN(0xd9243ee6, 0x0412a77d), TOBN(0x06ff7cac, 0xdf449025), + TOBN(0xbe75f7cd, 0x23ef5a31), TOBN(0xbc957822, 0x0ddef7a8)}}, + {{TOBN(0x8cf7230c, 0xb0ce1c55), TOBN(0x5b534d05, 0x0bbfb607), + TOBN(0xee1ef113, 0x0e16363b), TOBN(0x27e0aa7a, 0xb4999e82)}, + {TOBN(0xce1dac2d, 0x79362c41), TOBN(0x67920c90, 0x91bb6cb0), + TOBN(0x1e648d63, 0x2223df24), TOBN(0x0f7d9eef, 0xe32e8f28)}}, + {{TOBN(0x6943f39a, 0xfa833834), TOBN(0x22951722, 0xa6328562), + TOBN(0x81d63dd5, 0x4170fc10), TOBN(0x9f5fa58f, 0xaecc2e6d)}, + {TOBN(0xb66c8725, 0xe77d9a3b), TOBN(0x11235cea, 0x6384ebe0), + TOBN(0x06a8c118, 0x5845e24a), TOBN(0x0137b286, 0xebd093b1)}}, + {{TOBN(0xc589e1ce, 0x44ace150), TOBN(0xe0f8d3d9, 0x4381e97c), + TOBN(0x59e99b11, 0x62c5a4b8), TOBN(0x90d262f7, 0xfd0ec9f9)}, + {TOBN(0xfbc854c9, 0x283e13c9), TOBN(0x2d04fde7, 0xaedc7085), + TOBN(0x057d7765, 0x47dcbecb), TOBN(0x8dbdf591, 0x9a76fa5f)}}, + {{TOBN(0xd0150695, 0x0de1e578), TOBN(0x2e1463e7, 0xe9f72bc6), + TOBN(0xffa68441, 0x1b39eca5), TOBN(0x673c8530, 0x7c037f2f)}, + {TOBN(0xd0d6a600, 0x747f91da), TOBN(0xb08d43e1, 0xc9cb78e9), + TOBN(0x0fc0c644, 0x27b5cef5), TOBN(0x5c1d160a, 0xa60a2fd6)}}, + {{TOBN(0xf98cae53, 0x28c8e13b), TOBN(0x375f10c4, 0xb2eddcd1), + TOBN(0xd4eb8b7f, 0x5cce06ad), TOBN(0xb4669f45, 0x80a2e1ef)}, + {TOBN(0xd593f9d0, 0x5bbd8699), TOBN(0x5528a4c9, 0xe7976d13), + TOBN(0x3923e095, 0x1c7e28d3), TOBN(0xb9293790, 0x3f6bb577)}}, + {{TOBN(0xdb567d6a, 0xc42bd6d2), TOBN(0x6df86468, 0xbb1f96ae), + TOBN(0x0efe5b1a, 0x4843b28e), TOBN(0x961bbb05, 0x6379b240)}, + {TOBN(0xb6caf5f0, 0x70a6a26b), TOBN(0x70686c0d, 0x328e6e39), + TOBN(0x80da06cf, 0x895fc8d3), TOBN(0x804d8810, 0xb363fdc9)}}, + {{TOBN(0xbe22877b, 0x207f1670), TOBN(0x9b0dd188, 0x4e615291), + TOBN(0x625ae8dc, 0x97a3c2bf), TOBN(0x08584ef7, 0x439b86e8)}, + {TOBN(0xde7190a5, 0xdcd898ff), TOBN(0x26286c40, 0x2058ee3d), + TOBN(0x3db0b217, 0x5f87b1c1), TOBN(0xcc334771, 0x102a6db5)}}, + {{TOBN(0xd99de954, 0x2f770fb1), TOBN(0x97c1c620, 0x4cd7535e), + TOBN(0xd3b6c448, 0x3f09cefc), TOBN(0xd725af15, 0x5a63b4f8)}, + {TOBN(0x0c95d24f, 0xc01e20ec), TOBN(0xdfd37494, 0x9ae7121f), + TOBN(0x7d6ddb72, 0xec77b7ec), TOBN(0xfe079d3b, 0x0353a4ae)}}, + {{TOBN(0x3066e70a, 0x2e6ac8d2), TOBN(0x9c6b5a43, 0x106e5c05), + TOBN(0x52d3c6f5, 0xede59b8c), TOBN(0x30d6a5c3, 0xfccec9ae)}, + {TOBN(0xedec7c22, 0x4fc0a9ef), TOBN(0x190ff083, 0x95c16ced), + TOBN(0xbe12ec8f, 0x94de0fde), TOBN(0x0d131ab8, 0x852d3433)}}, + {{TOBN(0x42ace07e, 0x85701291), TOBN(0x94793ed9, 0x194061a8), + TOBN(0x30e83ed6, 0xd7f4a485), TOBN(0x9eec7269, 0xf9eeff4d)}, + {TOBN(0x90acba59, 0x0c9d8005), TOBN(0x5feca458, 0x1e79b9d1), + TOBN(0x8fbe5427, 0x1d506a1e), TOBN(0xa32b2c8e, 0x2439cfa7)}}, + {{TOBN(0x1671c173, 0x73dd0b4e), TOBN(0x37a28214, 0x44a054c6), + TOBN(0x81760a1b, 0x4e8b53f1), TOBN(0xa6c04224, 0xf9f93b9e)}, + {TOBN(0x18784b34, 0xcf671e3c), TOBN(0x81bbecd2, 0xcda9b994), + TOBN(0x38831979, 0xb2ab3848), TOBN(0xef54feb7, 0xf2e03c2d)}}, + {{TOBN(0xcf197ca7, 0xfb8088fa), TOBN(0x01427247, 0x4ddc96c5), + TOBN(0xa2d2550a, 0x30777176), TOBN(0x53469898, 0x4d0cf71d)}, + {TOBN(0x6ce937b8, 0x3a2aaac6), TOBN(0xe9f91dc3, 0x5af38d9b), + TOBN(0x2598ad83, 0xc8bf2899), TOBN(0x8e706ac9, 0xb5536c16)}}, + {{TOBN(0x40dc7495, 0xf688dc98), TOBN(0x26490cd7, 0x124c4afc), + TOBN(0xe651ec84, 0x1f18775c), TOBN(0x393ea6c3, 0xb4fdaf4a)}, + {TOBN(0x1e1f3343, 0x7f338e0d), TOBN(0x39fb832b, 0x6053e7b5), + TOBN(0x46e702da, 0x619e14d5), TOBN(0x859cacd1, 0xcdeef6e0)}}, + {{TOBN(0x63b99ce7, 0x4462007d), TOBN(0xb8ab48a5, 0x4cb5f5b7), + TOBN(0x9ec673d2, 0xf55edde7), TOBN(0xd1567f74, 0x8cfaefda)}, + {TOBN(0x46381b6b, 0x0887bcec), TOBN(0x694497ce, 0xe178f3c2), + TOBN(0x5e6525e3, 0x1e6266cb), TOBN(0x5931de26, 0x697d6413)}}, + {{TOBN(0x87f8df7c, 0x0e58d493), TOBN(0xb1ae5ed0, 0x58b73f12), + TOBN(0xc368f784, 0xdea0c34d), TOBN(0x9bd0a120, 0x859a91a0)}, + {TOBN(0xb00d88b7, 0xcc863c68), TOBN(0x3a1cc11e, 0x3d1f4d65), + TOBN(0xea38e0e7, 0x0aa85593), TOBN(0x37f13e98, 0x7dc4aee8)}}, + {{TOBN(0x10d38667, 0xbc947bad), TOBN(0x738e07ce, 0x2a36ee2e), + TOBN(0xc93470cd, 0xc577fcac), TOBN(0xdee1b616, 0x2782470d)}, + {TOBN(0x36a25e67, 0x2e793d12), TOBN(0xd6aa6cae, 0xe0f186da), + TOBN(0x474d0fd9, 0x80e07af7), TOBN(0xf7cdc47d, 0xba8a5cd4)}}, + {{TOBN(0x28af6d9d, 0xab15247f), TOBN(0x7c789c10, 0x493a537f), + TOBN(0x7ac9b110, 0x23a334e7), TOBN(0x0236ac09, 0x12c9c277)}, + {TOBN(0xa7e5bd25, 0x1d7a5144), TOBN(0x098b9c2a, 0xf13ec4ec), + TOBN(0x3639daca, 0xd3f0abca), TOBN(0x642da81a, 0xa23960f9)}}, + {{TOBN(0x7d2e5c05, 0x4f7269b1), TOBN(0xfcf30777, 0xe287c385), + TOBN(0x10edc84f, 0xf2a46f21), TOBN(0x35441757, 0x4f43fa36)}, + {TOBN(0xf1327899, 0xfd703431), TOBN(0xa438d7a6, 0x16dd587a), + TOBN(0x65c34c57, 0xe9c8352d), TOBN(0xa728edab, 0x5cc5a24e)}}, + {{TOBN(0xaed78abc, 0x42531689), TOBN(0x0a51a0e8, 0x010963ef), + TOBN(0x5776fa0a, 0xd717d9b3), TOBN(0xf356c239, 0x7dd3428b)}, + {TOBN(0x29903fff, 0x8d3a3dac), TOBN(0x409597fa, 0x3d94491f), + TOBN(0x4cd7a5ff, 0xbf4a56a4), TOBN(0xe5096474, 0x8adab462)}}, + {{TOBN(0xa97b5126, 0x5c3427b0), TOBN(0x6401405c, 0xd282c9bd), + TOBN(0x3629f8d7, 0x222c5c45), TOBN(0xb1c02c16, 0xe8d50aed)}, + {TOBN(0xbea2ed75, 0xd9635bc9), TOBN(0x226790c7, 0x6e24552f), + TOBN(0x3c33f2a3, 0x65f1d066), TOBN(0x2a43463e, 0x6dfccc2e)}}, + {{TOBN(0x8cc3453a, 0xdb483761), TOBN(0xe7cc6085, 0x65d5672b), + TOBN(0x277ed6cb, 0xde3efc87), TOBN(0x19f2f368, 0x69234eaf)}, + {TOBN(0x9aaf4317, 0x5c0b800b), TOBN(0x1f1e7c89, 0x8b6da6e2), + TOBN(0x6cfb4715, 0xb94ec75e), TOBN(0xd590dd5f, 0x453118c2)}}, + {{TOBN(0x14e49da1, 0x1f17a34c), TOBN(0x5420ab39, 0x235a1456), + TOBN(0xb7637241, 0x2f50363b), TOBN(0x7b15d623, 0xc3fabb6e)}, + {TOBN(0xa0ef40b1, 0xe274e49c), TOBN(0x5cf50744, 0x96b1860a), + TOBN(0xd6583fbf, 0x66afe5a4), TOBN(0x44240510, 0xf47e3e9a)}}, + {{TOBN(0x99254343, 0x11b2d595), TOBN(0xf1367499, 0xeec8df57), + TOBN(0x3cb12c61, 0x3e73dd05), TOBN(0xd248c033, 0x7dac102a)}, + {TOBN(0xcf154f13, 0xa77739f5), TOBN(0xbf4288cb, 0x23d2af42), + TOBN(0xaa64c9b6, 0x32e4a1cf), TOBN(0xee8c07a8, 0xc8a208f3)}}, + {{TOBN(0xe10d4999, 0x6fe8393f), TOBN(0x0f809a3f, 0xe91f3a32), + TOBN(0x61096d1c, 0x802f63c8), TOBN(0x289e1462, 0x57750d3d)}, + {TOBN(0xed06167e, 0x9889feea), TOBN(0xd5c9c0e2, 0xe0993909), + TOBN(0x46fca0d8, 0x56508ac6), TOBN(0x91826047, 0x4f1b8e83)}}, + {{TOBN(0x4f2c877a, 0x9a4a2751), TOBN(0x71bd0072, 0xcae6fead), + TOBN(0x38df8dcc, 0x06aa1941), TOBN(0x5a074b4c, 0x63beeaa8)}, + {TOBN(0xd6d65934, 0xc1cec8ed), TOBN(0xa6ecb49e, 0xaabc03bd), + TOBN(0xaade91c2, 0xde8a8415), TOBN(0xcfb0efdf, 0x691136e0)}}, + {{TOBN(0x11af45ee, 0x23ab3495), TOBN(0xa132df88, 0x0b77463d), + TOBN(0x8923c15c, 0x815d06f4), TOBN(0xc3ceb3f5, 0x0d61a436)}, + {TOBN(0xaf52291d, 0xe88fb1da), TOBN(0xea057974, 0x1da12179), + TOBN(0xb0d7218c, 0xd2fef720), TOBN(0x6c0899c9, 0x8e1d8845)}}, + {{TOBN(0x98157504, 0x752ddad7), TOBN(0xd60bd74f, 0xa1a68a97), + TOBN(0x7047a3a9, 0xf658fb99), TOBN(0x1f5d86d6, 0x5f8511e4)}, + {TOBN(0xb8a4bc42, 0x4b5a6d88), TOBN(0x69eb2c33, 0x1abefa7d), + TOBN(0x95bf39e8, 0x13c9c510), TOBN(0xf571960a, 0xd48aab43)}}, + {{TOBN(0x7e8cfbcf, 0x704e23c6), TOBN(0xc71b7d22, 0x28aaa65b), + TOBN(0xa041b2bd, 0x245e3c83), TOBN(0x69b98834, 0xd21854ff)}, + {TOBN(0x89d227a3, 0x963bfeec), TOBN(0x99947aaa, 0xde7da7cb), + TOBN(0x1d9ee9db, 0xee68a9b1), TOBN(0x0a08f003, 0x698ec368)}}, + {{TOBN(0xe9ea4094, 0x78ef2487), TOBN(0xc8d2d415, 0x02cfec26), + TOBN(0xc52f9a6e, 0xb7dcf328), TOBN(0x0ed489e3, 0x85b6a937)}, + {TOBN(0x9b94986b, 0xbef3366e), TOBN(0x0de59c70, 0xedddddb8), + TOBN(0xffdb748c, 0xeadddbe2), TOBN(0x9b9784bb, 0x8266ea40)}}, + {{TOBN(0x142b5502, 0x1a93507a), TOBN(0xb4cd1187, 0x8d3c06cf), + TOBN(0xdf70e76a, 0x91ec3f40), TOBN(0x484e81ad, 0x4e7553c2)}, + {TOBN(0x830f87b5, 0x272e9d6e), TOBN(0xea1c93e5, 0xc6ff514a), + TOBN(0x67cc2adc, 0xc4192a8e), TOBN(0xc77e27e2, 0x42f4535a)}}, + {{TOBN(0x9cdbab36, 0xd2b713c5), TOBN(0x86274ea0, 0xcf7b0cd3), + TOBN(0x784680f3, 0x09af826b), TOBN(0xbfcc837a, 0x0c72dea3)}, + {TOBN(0xa8bdfe9d, 0xd6529b73), TOBN(0x708aa228, 0x63a88002), + TOBN(0x6c7a9a54, 0xc91d45b9), TOBN(0xdf1a38bb, 0xfd004f56)}}, + {{TOBN(0x2e8c9a26, 0xb8bad853), TOBN(0x2d52cea3, 0x3723eae7), + TOBN(0x054d6d81, 0x56ca2830), TOBN(0xa3317d14, 0x9a8dc411)}, + {TOBN(0xa08662fe, 0xfd4ddeda), TOBN(0xed2a153a, 0xb55d792b), + TOBN(0x7035c16a, 0xbfc6e944), TOBN(0xb6bc5834, 0x00171cf3)}}, + {{TOBN(0xe27152b3, 0x83d102b6), TOBN(0xfe695a47, 0x0646b848), + TOBN(0xa5bb09d8, 0x916e6d37), TOBN(0xb4269d64, 0x0d17015e)}, + {TOBN(0x8d8156a1, 0x0a1d2285), TOBN(0xfeef6c51, 0x46d26d72), + TOBN(0x9dac57c8, 0x4c5434a7), TOBN(0x0282e5be, 0x59d39e31)}}, + {{TOBN(0xedfff181, 0x721c486d), TOBN(0x301baf10, 0xbc58824e), + TOBN(0x8136a6aa, 0x00570031), TOBN(0x55aaf78c, 0x1cddde68)}, + {TOBN(0x26829371, 0x59c63952), TOBN(0x3a3bd274, 0x8bc25baf), + TOBN(0xecdf8657, 0xb7e52dc3), TOBN(0x2dd8c087, 0xfd78e6c8)}}, + {{TOBN(0x20553274, 0xf5531461), TOBN(0x8b4a1281, 0x5d95499b), + TOBN(0xe2c8763a, 0x1a80f9d2), TOBN(0xd1dbe32b, 0x4ddec758)}, + {TOBN(0xaf12210d, 0x30c34169), TOBN(0xba74a953, 0x78baa533), + TOBN(0x3d133c6e, 0xa438f254), TOBN(0xa431531a, 0x201bef5b)}}, + {{TOBN(0x15295e22, 0xf669d7ec), TOBN(0xca374f64, 0x357fb515), + TOBN(0x8a8406ff, 0xeaa3fdb3), TOBN(0x106ae448, 0xdf3f2da8)}, + {TOBN(0x8f9b0a90, 0x33c8e9a1), TOBN(0x234645e2, 0x71ad5885), + TOBN(0x3d083224, 0x1c0aed14), TOBN(0xf10a7d3e, 0x7a942d46)}}, + {{TOBN(0x7c11deee, 0x40d5c9be), TOBN(0xb2bae7ff, 0xba84ed98), + TOBN(0x93e97139, 0xaad58ddd), TOBN(0x3d872796, 0x3f6d1fa3)}, + {TOBN(0x483aca81, 0x8569ff13), TOBN(0x8b89a5fb, 0x9a600f72), + TOBN(0x4cbc27c3, 0xc06f2b86), TOBN(0x22130713, 0x63ad9c0b)}}, + {{TOBN(0xb5358b1e, 0x48ac2840), TOBN(0x18311294, 0xecba9477), + TOBN(0xda58f990, 0xa6946b43), TOBN(0x3098baf9, 0x9ab41819)}, + {TOBN(0x66c4c158, 0x4198da52), TOBN(0xab4fc17c, 0x146bfd1b), + TOBN(0x2f0a4c3c, 0xbf36a908), TOBN(0x2ae9e34b, 0x58cf7838)}}, + {{TOBN(0xf411529e, 0x3fa11b1f), TOBN(0x21e43677, 0x974af2b4), + TOBN(0x7c20958e, 0xc230793b), TOBN(0x710ea885, 0x16e840f3)}, + {TOBN(0xfc0b21fc, 0xc5dc67cf), TOBN(0x08d51647, 0x88405718), + TOBN(0xd955c21f, 0xcfe49eb7), TOBN(0x9722a5d5, 0x56dd4a1f)}}, + {{TOBN(0xc9ef50e2, 0xc861baa5), TOBN(0xc0c21a5d, 0x9505ac3e), + TOBN(0xaf6b9a33, 0x8b7c063f), TOBN(0xc6370339, 0x2f4779c1)}, + {TOBN(0x22df99c7, 0x638167c3), TOBN(0xfe6ffe76, 0x795db30c), + TOBN(0x2b822d33, 0xa4854989), TOBN(0xfef031dd, 0x30563aa5)}}, + {{TOBN(0x16b09f82, 0xd57c667f), TOBN(0xc70312ce, 0xcc0b76f1), + TOBN(0xbf04a9e6, 0xc9118aec), TOBN(0x82fcb419, 0x3409d133)}, + {TOBN(0x1a8ab385, 0xab45d44d), TOBN(0xfba07222, 0x617b83a3), + TOBN(0xb05f50dd, 0x58e81b52), TOBN(0x1d8db553, 0x21ce5aff)}}, + {{TOBN(0x3097b8d4, 0xe344a873), TOBN(0x7d8d116d, 0xfe36d53e), + TOBN(0x6db22f58, 0x7875e750), TOBN(0x2dc5e373, 0x43e144ea)}, + {TOBN(0xc05f32e6, 0xe799eb95), TOBN(0xe9e5f4df, 0x6899e6ec), + TOBN(0xbdc3bd68, 0x1fab23d5), TOBN(0xb72b8ab7, 0x73af60e6)}}, + {{TOBN(0x8db27ae0, 0x2cecc84a), TOBN(0x600016d8, 0x7bdb871c), + TOBN(0x42a44b13, 0xd7c46f58), TOBN(0xb8919727, 0xc3a77d39)}, + {TOBN(0xcfc6bbbd, 0xdafd6088), TOBN(0x1a740146, 0x6bd20d39), + TOBN(0x8c747abd, 0x98c41072), TOBN(0x4c91e765, 0xbdf68ea1)}}, + {{TOBN(0x7c95e5ca, 0x08819a78), TOBN(0xcf48b729, 0xc9587921), + TOBN(0x091c7c5f, 0xdebbcc7d), TOBN(0x6f287404, 0xf0e05149)}, + {TOBN(0xf83b5ac2, 0x26cd44ec), TOBN(0x88ae32a6, 0xcfea250e), + TOBN(0x6ac5047a, 0x1d06ebc5), TOBN(0xc7e550b4, 0xd434f781)}}, + {{TOBN(0x61ab1cf2, 0x5c727bd2), TOBN(0x2e4badb1, 0x1cf915b0), + TOBN(0x1b4dadec, 0xf69d3920), TOBN(0xe61b1ca6, 0xf14c1dfe)}, + {TOBN(0x90b479cc, 0xbd6bd51f), TOBN(0x8024e401, 0x8045ec30), + TOBN(0xcab29ca3, 0x25ef0e62), TOBN(0x4f2e9416, 0x49e4ebc0)}}, + {{TOBN(0x45eb40ec, 0x0ccced58), TOBN(0x25cd4b9c, 0x0da44f98), + TOBN(0x43e06458, 0x871812c6), TOBN(0x99f80d55, 0x16cef651)}, + {TOBN(0x571340c9, 0xce6dc153), TOBN(0x138d5117, 0xd8665521), + TOBN(0xacdb45bc, 0x4e07014d), TOBN(0x2f34bb38, 0x84b60b91)}}, + {{TOBN(0xf44a4fd2, 0x2ae8921e), TOBN(0xb039288e, 0x892ba1e2), + TOBN(0x9da50174, 0xb1c180b2), TOBN(0x6b70ab66, 0x1693dc87)}, + {TOBN(0x7e9babc9, 0xe7057481), TOBN(0x4581ddef, 0x9c80dc41), + TOBN(0x0c890da9, 0x51294682), TOBN(0x0b5629d3, 0x3f4736e5)}}, + {{TOBN(0x2340c79e, 0xb06f5b41), TOBN(0xa42e84ce, 0x4e243469), + TOBN(0xf9a20135, 0x045a71a9), TOBN(0xefbfb415, 0xd27b6fb6)}, + {TOBN(0x25ebea23, 0x9d33cd6f), TOBN(0x9caedb88, 0xaa6c0af8), + TOBN(0x53dc7e9a, 0xd9ce6f96), TOBN(0x3897f9fd, 0x51e0b15a)}}, + {{TOBN(0xf51cb1f8, 0x8e5d788e), TOBN(0x1aec7ba8, 0xe1d490ee), + TOBN(0x265991e0, 0xcc58cb3c), TOBN(0x9f306e8c, 0x9fc3ad31)}, + {TOBN(0x5fed006e, 0x5040a0ac), TOBN(0xca9d5043, 0xfb476f2e), + TOBN(0xa19c06e8, 0xbeea7a23), TOBN(0xd2865801, 0x0edabb63)}}, + {{TOBN(0xdb92293f, 0x6967469a), TOBN(0x2894d839, 0x8d8a8ed8), + TOBN(0x87c9e406, 0xbbc77122), TOBN(0x8671c6f1, 0x2ea3a26a)}, + {TOBN(0xe42df8d6, 0xd7de9853), TOBN(0x2e3ce346, 0xb1f2bcc7), + TOBN(0xda601dfc, 0x899d50cf), TOBN(0xbfc913de, 0xfb1b598f)}}, + {{TOBN(0x81c4909f, 0xe61f7908), TOBN(0x192e304f, 0x9bbc7b29), + TOBN(0xc3ed8738, 0xc104b338), TOBN(0xedbe9e47, 0x783f5d61)}, + {TOBN(0x0c06e9be, 0x2db30660), TOBN(0xda3e613f, 0xc0eb7d8e), + TOBN(0xd8fa3e97, 0x322e096e), TOBN(0xfebd91e8, 0xd336e247)}}, + {{TOBN(0x8f13ccc4, 0xdf655a49), TOBN(0xa9e00dfc, 0x5eb20210), + TOBN(0x84631d0f, 0xc656b6ea), TOBN(0x93a058cd, 0xd8c0d947)}, + {TOBN(0x6846904a, 0x67bd3448), TOBN(0x4a3d4e1a, 0xf394fd5c), + TOBN(0xc102c1a5, 0xdb225f52), TOBN(0xe3455bba, 0xfc4f5e9a)}}, + {{TOBN(0x6b36985b, 0x4b9ad1ce), TOBN(0xa9818536, 0x5bb7f793), + TOBN(0x6c25e1d0, 0x48b1a416), TOBN(0x1381dd53, 0x3c81bee7)}, + {TOBN(0xd2a30d61, 0x7a4a7620), TOBN(0xc8412926, 0x39b8944c), + TOBN(0x3c1c6fbe, 0x7a97c33a), TOBN(0x941e541d, 0x938664e7)}}, + {{TOBN(0x417499e8, 0x4a34f239), TOBN(0x15fdb83c, 0xb90402d5), + TOBN(0xb75f46bf, 0x433aa832), TOBN(0xb61e15af, 0x63215db1)}, + {TOBN(0xaabe59d4, 0xa127f89a), TOBN(0x5d541e0c, 0x07e816da), + TOBN(0xaaba0659, 0xa618b692), TOBN(0x55327733, 0x17266026)}}, + {{TOBN(0xaf53a0fc, 0x95f57552), TOBN(0x32947650, 0x6cacb0c9), + TOBN(0x253ff58d, 0xc821be01), TOBN(0xb0309531, 0xa06f1146)}, + {TOBN(0x59bbbdf5, 0x05c2e54d), TOBN(0x158f27ad, 0x26e8dd22), + TOBN(0xcc5b7ffb, 0x397e1e53), TOBN(0xae03f65b, 0x7fc1e50d)}}, + {{TOBN(0xa9784ebd, 0x9c95f0f9), TOBN(0x5ed9deb2, 0x24640771), + TOBN(0x31244af7, 0x035561c4), TOBN(0x87332f3a, 0x7ee857de)}, + {TOBN(0x09e16e9e, 0x2b9e0d88), TOBN(0x52d910f4, 0x56a06049), + TOBN(0x507ed477, 0xa9592f48), TOBN(0x85cb917b, 0x2365d678)}}, + {{TOBN(0xf8511c93, 0x4c8998d1), TOBN(0x2186a3f1, 0x730ea58f), + TOBN(0x50189626, 0xb2029db0), TOBN(0x9137a6d9, 0x02ceb75a)}, + {TOBN(0x2fe17f37, 0x748bc82c), TOBN(0x87c2e931, 0x80469f8c), + TOBN(0x850f71cd, 0xbf891aa2), TOBN(0x0ca1b89b, 0x75ec3d8d)}}, + {{TOBN(0x516c43aa, 0x5e1cd3cd), TOBN(0x89397808, 0x9a887c28), + TOBN(0x0059c699, 0xddea1f9f), TOBN(0x7737d6fa, 0x8e6868f7)}, + {TOBN(0x6d93746a, 0x60f1524b), TOBN(0x36985e55, 0xba052aa7), + TOBN(0x41b1d322, 0xed923ea5), TOBN(0x3429759f, 0x25852a11)}}, + {{TOBN(0xbeca6ec3, 0x092e9f41), TOBN(0x3a238c66, 0x62256bbd), + TOBN(0xd82958ea, 0x70ad487d), TOBN(0x4ac8aaf9, 0x65610d93)}, + {TOBN(0x3fa101b1, 0x5e4ccab0), TOBN(0x9bf430f2, 0x9de14bfb), + TOBN(0xa10f5cc6, 0x6531899d), TOBN(0x590005fb, 0xea8ce17d)}}, + {{TOBN(0xc437912f, 0x24544cb6), TOBN(0x9987b71a, 0xd79ac2e3), + TOBN(0x13e3d9dd, 0xc058a212), TOBN(0x00075aac, 0xd2de9606)}, + {TOBN(0x80ab508b, 0x6cac8369), TOBN(0x87842be7, 0xf54f6c89), + TOBN(0xa7ad663d, 0x6bc532a4), TOBN(0x67813de7, 0x78a91bc8)}}, + {{TOBN(0x5dcb61ce, 0xc3427239), TOBN(0x5f3c7cf0, 0xc56934d9), + TOBN(0xc079e0fb, 0xe3191591), TOBN(0xe40896bd, 0xb01aada7)}, + {TOBN(0x8d466791, 0x0492d25f), TOBN(0x8aeb30c9, 0xe7408276), + TOBN(0xe9437495, 0x9287aacc), TOBN(0x23d4708d, 0x79fe03d4)}}, + {{TOBN(0x8cda9cf2, 0xd0c05199), TOBN(0x502fbc22, 0xfae78454), + TOBN(0xc0bda9df, 0xf572a182), TOBN(0x5f9b71b8, 0x6158b372)}, + {TOBN(0xe0f33a59, 0x2b82dd07), TOBN(0x76302735, 0x9523032e), + TOBN(0x7fe1a721, 0xc4505a32), TOBN(0x7b6e3e82, 0xf796409f)}}}, + {{{TOBN(0xe3417bc0, 0x35d0b34a), TOBN(0x440b386b, 0x8327c0a7), + TOBN(0x8fb7262d, 0xac0362d1), TOBN(0x2c41114c, 0xe0cdf943)}, + {TOBN(0x2ba5cef1, 0xad95a0b1), TOBN(0xc09b37a8, 0x67d54362), + TOBN(0x26d6cdd2, 0x01e486c9), TOBN(0x20477abf, 0x42ff9297)}}, + {{TOBN(0xa004dcb3, 0x292a9287), TOBN(0xddc15cf6, 0x77b092c7), + TOBN(0x083a8464, 0x806c0605), TOBN(0x4a68df70, 0x3db997b0)}, + {TOBN(0x9c134e45, 0x05bf7dd0), TOBN(0xa4e63d39, 0x8ccf7f8c), + TOBN(0xa6e6517f, 0x41b5f8af), TOBN(0xaa8b9342, 0xad7bc1cc)}}, + {{TOBN(0x126f35b5, 0x1e706ad9), TOBN(0xb99cebb4, 0xc3a9ebdf), + TOBN(0xa75389af, 0xbf608d90), TOBN(0x76113c4f, 0xc6c89858)}, + {TOBN(0x80de8eb0, 0x97e2b5aa), TOBN(0x7e1022cc, 0x63b91304), + TOBN(0x3bdab605, 0x6ccc066c), TOBN(0x33cbb144, 0xb2edf900)}}, + {{TOBN(0xc4176471, 0x7af715d2), TOBN(0xe2f7f594, 0xd0134a96), + TOBN(0x2c1873ef, 0xa41ec956), TOBN(0xe4e7b4f6, 0x77821304)}, + {TOBN(0xe5c8ff97, 0x88d5374a), TOBN(0x2b915e63, 0x80823d5b), + TOBN(0xea6bc755, 0xb2ee8fe2), TOBN(0x6657624c, 0xe7112651)}}, + {{TOBN(0x157af101, 0xdace5aca), TOBN(0xc4fdbcf2, 0x11a6a267), + TOBN(0xdaddf340, 0xc49c8609), TOBN(0x97e49f52, 0xe9604a65)}, + {TOBN(0x9be8e790, 0x937e2ad5), TOBN(0x846e2508, 0x326e17f1), + TOBN(0x3f38007a, 0x0bbbc0dc), TOBN(0xcf03603f, 0xb11e16d6)}}, + {{TOBN(0xd6f800e0, 0x7442f1d5), TOBN(0x475607d1, 0x66e0e3ab), + TOBN(0x82807f16, 0xb7c64047), TOBN(0x8858e1e3, 0xa749883d)}, + {TOBN(0x5859120b, 0x8231ee10), TOBN(0x1b80e7eb, 0x638a1ece), + TOBN(0xcb72525a, 0xc6aa73a4), TOBN(0xa7cdea3d, 0x844423ac)}}, + {{TOBN(0x5ed0c007, 0xf8ae7c38), TOBN(0x6db07a5c, 0x3d740192), + TOBN(0xbe5e9c2a, 0x5fe36db3), TOBN(0xd5b9d57a, 0x76e95046)}, + {TOBN(0x54ac32e7, 0x8eba20f2), TOBN(0xef11ca8f, 0x71b9a352), + TOBN(0x305e373e, 0xff98a658), TOBN(0xffe5a100, 0x823eb667)}}, + {{TOBN(0x57477b11, 0xe51732d2), TOBN(0xdfd6eb28, 0x2538fc0e), + TOBN(0x5c43b0cc, 0x3b39eec5), TOBN(0x6af12778, 0xcb36cc57)}, + {TOBN(0x70b0852d, 0x06c425ae), TOBN(0x6df92f8c, 0x5c221b9b), + TOBN(0x6c8d4f9e, 0xce826d9c), TOBN(0xf59aba7b, 0xb49359c3)}}, + {{TOBN(0x5c8ed8d5, 0xda64309d), TOBN(0x61a6de56, 0x91b30704), + TOBN(0xd6b52f6a, 0x2f9b5808), TOBN(0x0eee4194, 0x98c958a7)}, + {TOBN(0xcddd9aab, 0x771e4caa), TOBN(0x83965dfd, 0x78bc21be), + TOBN(0x02affce3, 0xb3b504f5), TOBN(0x30847a21, 0x561c8291)}}, + {{TOBN(0xd2eb2cf1, 0x52bfda05), TOBN(0xe0e4c4e9, 0x6197b98c), + TOBN(0x1d35076c, 0xf8a1726f), TOBN(0x6c06085b, 0x2db11e3d)}, + {TOBN(0x15c0c4d7, 0x4463ba14), TOBN(0x9d292f83, 0x0030238c), + TOBN(0x1311ee8b, 0x3727536d), TOBN(0xfeea86ef, 0xbeaedc1e)}}, + {{TOBN(0xb9d18cd3, 0x66131e2e), TOBN(0xf31d974f, 0x80fe2682), + TOBN(0xb6e49e0f, 0xe4160289), TOBN(0x7c48ec0b, 0x08e92799)}, + {TOBN(0x818111d8, 0xd1989aa7), TOBN(0xb34fa0aa, 0xebf926f9), + TOBN(0xdb5fe2f5, 0xa245474a), TOBN(0xf80a6ebb, 0x3c7ca756)}}, + {{TOBN(0xa7f96054, 0xafa05dd8), TOBN(0x26dfcf21, 0xfcaf119e), + TOBN(0xe20ef2e3, 0x0564bb59), TOBN(0xef4dca50, 0x61cb02b8)}, + {TOBN(0xcda7838a, 0x65d30672), TOBN(0x8b08d534, 0xfd657e86), + TOBN(0x4c5b4395, 0x46d595c8), TOBN(0x39b58725, 0x425cb836)}}, + {{TOBN(0x8ea61059, 0x3de9abe3), TOBN(0x40434881, 0x9cdc03be), + TOBN(0x9b261245, 0xcfedce8c), TOBN(0x78c318b4, 0xcf5234a1)}, + {TOBN(0x510bcf16, 0xfde24c99), TOBN(0x2a77cb75, 0xa2c2ff5d), + TOBN(0x9c895c2b, 0x27960fb4), TOBN(0xd30ce975, 0xb0eda42b)}}, + {{TOBN(0xfda85393, 0x1a62cc26), TOBN(0x23c69b96, 0x50c0e052), + TOBN(0xa227df15, 0xbfc633f3), TOBN(0x2ac78848, 0x1bae7d48)}, + {TOBN(0x487878f9, 0x187d073d), TOBN(0x6c2be919, 0x967f807d), + TOBN(0x765861d8, 0x336e6d8f), TOBN(0x88b8974c, 0xce528a43)}}, + {{TOBN(0x09521177, 0xff57d051), TOBN(0x2ff38037, 0xfb6a1961), + TOBN(0xfc0aba74, 0xa3d76ad4), TOBN(0x7c764803, 0x25a7ec17)}, + {TOBN(0x7532d75f, 0x48879bc8), TOBN(0xea7eacc0, 0x58ce6bc1), + TOBN(0xc82176b4, 0x8e896c16), TOBN(0x9a30e0b2, 0x2c750fed)}}, + {{TOBN(0xc37e2c2e, 0x421d3aa4), TOBN(0xf926407c, 0xe84fa840), + TOBN(0x18abc03d, 0x1454e41c), TOBN(0x26605ecd, 0x3f7af644)}, + {TOBN(0x242341a6, 0xd6a5eabf), TOBN(0x1edb84f4, 0x216b668e), + TOBN(0xd836edb8, 0x04010102), TOBN(0x5b337ce7, 0x945e1d8c)}}, + {{TOBN(0xd2075c77, 0xc055dc14), TOBN(0x2a0ffa25, 0x81d89cdf), + TOBN(0x8ce815ea, 0x6ffdcbaf), TOBN(0xa3428878, 0xfb648867)}, + {TOBN(0x277699cf, 0x884655fb), TOBN(0xfa5b5bd6, 0x364d3e41), + TOBN(0x01f680c6, 0x441e1cb7), TOBN(0x3fd61e66, 0xb70a7d67)}}, + {{TOBN(0x666ba2dc, 0xcc78cf66), TOBN(0xb3018174, 0x6fdbff77), + TOBN(0x8d4dd0db, 0x168d4668), TOBN(0x259455d0, 0x1dab3a2a)}, + {TOBN(0xf58564c5, 0xcde3acec), TOBN(0x77141925, 0x13adb276), + TOBN(0x527d725d, 0x8a303f65), TOBN(0x55deb6c9, 0xe6f38f7b)}}, + {{TOBN(0xfd5bb657, 0xb1fa70fb), TOBN(0xfa07f50f, 0xd8073a00), + TOBN(0xf72e3aa7, 0xbca02500), TOBN(0xf68f895d, 0x9975740d)}, + {TOBN(0x30112060, 0x5cae2a6a), TOBN(0x01bd7218, 0x02874842), + TOBN(0x3d423891, 0x7ce47bd3), TOBN(0xa66663c1, 0x789544f6)}}, + {{TOBN(0x864d05d7, 0x3272d838), TOBN(0xe22924f9, 0xfa6295c5), + TOBN(0x8189593f, 0x6c2fda32), TOBN(0x330d7189, 0xb184b544)}, + {TOBN(0x79efa62c, 0xbde1f714), TOBN(0x35771c94, 0xe5cb1a63), + TOBN(0x2f4826b8, 0x641c8332), TOBN(0x00a894fb, 0xc8cee854)}}, + {{TOBN(0xb4b9a39b, 0x36194d40), TOBN(0xe857a7c5, 0x77612601), + TOBN(0xf4209dd2, 0x4ecf2f58), TOBN(0x82b9e66d, 0x5a033487)}, + {TOBN(0xc1e36934, 0xe4e8b9dd), TOBN(0xd2372c9d, 0xa42377d7), + TOBN(0x51dc94c7, 0x0e3ae43b), TOBN(0x4c57761e, 0x04474f6f)}}, + {{TOBN(0xdcdacd0a, 0x1058a318), TOBN(0x369cf3f5, 0x78053a9a), + TOBN(0xc6c3de50, 0x31c68de2), TOBN(0x4653a576, 0x3c4b6d9f)}, + {TOBN(0x1688dd5a, 0xaa4e5c97), TOBN(0x5be80aa1, 0xb7ab3c74), + TOBN(0x70cefe7c, 0xbc65c283), TOBN(0x57f95f13, 0x06867091)}}, + {{TOBN(0xa39114e2, 0x4415503b), TOBN(0xc08ff7c6, 0x4cbb17e9), + TOBN(0x1eff674d, 0xd7dec966), TOBN(0x6d4690af, 0x53376f63)}, + {TOBN(0xff6fe32e, 0xea74237b), TOBN(0xc436d17e, 0xcd57508e), + TOBN(0x15aa28e1, 0xedcc40fe), TOBN(0x0d769c04, 0x581bbb44)}}, + {{TOBN(0xc240b6de, 0x34eaacda), TOBN(0xd9e116e8, 0x2ba0f1de), + TOBN(0xcbe45ec7, 0x79438e55), TOBN(0x91787c9d, 0x96f752d7)}, + {TOBN(0x897f532b, 0xf129ac2f), TOBN(0xd307b7c8, 0x5a36e22c), + TOBN(0x91940675, 0x749fb8f3), TOBN(0xd14f95d0, 0x157fdb28)}}, + {{TOBN(0xfe51d029, 0x6ae55043), TOBN(0x8931e98f, 0x44a87de1), + TOBN(0xe57f1cc6, 0x09e4fee2), TOBN(0x0d063b67, 0x4e072d92)}, + {TOBN(0x70a998b9, 0xed0e4316), TOBN(0xe74a736b, 0x306aca46), + TOBN(0xecf0fbf2, 0x4fda97c7), TOBN(0xa40f65cb, 0x3e178d93)}}, + {{TOBN(0x16253604, 0x16df4285), TOBN(0xb0c9babb, 0xd0c56ae2), + TOBN(0x73032b19, 0xcfc5cfc3), TOBN(0xe497e5c3, 0x09752056)}, + {TOBN(0x12096bb4, 0x164bda96), TOBN(0x1ee42419, 0xa0b74da1), + TOBN(0x8fc36243, 0x403826ba), TOBN(0x0c8f0069, 0xdc09e660)}}, + {{TOBN(0x8667e981, 0xc27253c9), TOBN(0x05a6aefb, 0x92b36a45), + TOBN(0xa62c4b36, 0x9cb7bb46), TOBN(0x8394f375, 0x11f7027b)}, + {TOBN(0x747bc79c, 0x5f109d0f), TOBN(0xcad88a76, 0x5b8cc60a), + TOBN(0x80c5a66b, 0x58f09e68), TOBN(0xe753d451, 0xf6127eac)}}, + {{TOBN(0xc44b74a1, 0x5b0ec6f5), TOBN(0x47989fe4, 0x5289b2b8), + TOBN(0x745f8484, 0x58d6fc73), TOBN(0xec362a6f, 0xf61c70ab)}, + {TOBN(0x070c98a7, 0xb3a8ad41), TOBN(0x73a20fc0, 0x7b63db51), + TOBN(0xed2c2173, 0xf44c35f4), TOBN(0x8a56149d, 0x9acc9dca)}}, + {{TOBN(0x98f17881, 0x9ac6e0f4), TOBN(0x360fdeaf, 0xa413b5ed), + TOBN(0x0625b8f4, 0xa300b0fd), TOBN(0xf1f4d76a, 0x5b3222d3)}, + {TOBN(0x9d6f5109, 0x587f76b8), TOBN(0x8b4ee08d, 0x2317fdb5), + TOBN(0x88089bb7, 0x8c68b095), TOBN(0x95570e9a, 0x5808d9b9)}}, + {{TOBN(0xa395c36f, 0x35d33ae7), TOBN(0x200ea123, 0x50bb5a94), + TOBN(0x20c789bd, 0x0bafe84b), TOBN(0x243ef52d, 0x0919276a)}, + {TOBN(0x3934c577, 0xe23ae233), TOBN(0xb93807af, 0xa460d1ec), + TOBN(0xb72a53b1, 0xf8fa76a4), TOBN(0xd8914cb0, 0xc3ca4491)}}, + {{TOBN(0x2e128494, 0x3fb42622), TOBN(0x3b2700ac, 0x500907d5), + TOBN(0xf370fb09, 0x1a95ec63), TOBN(0xf8f30be2, 0x31b6dfbd)}, + {TOBN(0xf2b2f8d2, 0x69e55f15), TOBN(0x1fead851, 0xcc1323e9), + TOBN(0xfa366010, 0xd9e5eef6), TOBN(0x64d487b0, 0xe316107e)}}, + {{TOBN(0x4c076b86, 0xd23ddc82), TOBN(0x03fd344c, 0x7e0143f0), + TOBN(0xa95362ff, 0x317af2c5), TOBN(0x0add3db7, 0xe18b7a4f)}, + {TOBN(0x9c673e3f, 0x8260e01b), TOBN(0xfbeb49e5, 0x54a1cc91), + TOBN(0x91351bf2, 0x92f2e433), TOBN(0xc755e7ec, 0x851141eb)}}, + {{TOBN(0xc9a95139, 0x29607745), TOBN(0x0ca07420, 0xa26f2b28), + TOBN(0xcb2790e7, 0x4bc6f9dd), TOBN(0x345bbb58, 0xadcaffc0)}, + {TOBN(0xc65ea38c, 0xbe0f27a2), TOBN(0x67c24d7c, 0x641fcb56), + TOBN(0x2c25f0a7, 0xa9e2c757), TOBN(0x93f5cdb0, 0x16f16c49)}}, + {{TOBN(0x2ca5a9d7, 0xc5ee30a1), TOBN(0xd1593635, 0xb909b729), + TOBN(0x804ce9f3, 0xdadeff48), TOBN(0xec464751, 0xb07c30c3)}, + {TOBN(0x89d65ff3, 0x9e49af6a), TOBN(0xf2d6238a, 0x6f3d01bc), + TOBN(0x1095561e, 0x0bced843), TOBN(0x51789e12, 0xc8a13fd8)}}, + {{TOBN(0xd633f929, 0x763231df), TOBN(0x46df9f7d, 0xe7cbddef), + TOBN(0x01c889c0, 0xcb265da8), TOBN(0xfce1ad10, 0xaf4336d2)}, + {TOBN(0x8d110df6, 0xfc6a0a7e), TOBN(0xdd431b98, 0x6da425dc), + TOBN(0xcdc4aeab, 0x1834aabe), TOBN(0x84deb124, 0x8439b7fc)}}, + {{TOBN(0x8796f169, 0x3c2a5998), TOBN(0x9b9247b4, 0x7947190d), + TOBN(0x55b9d9a5, 0x11597014), TOBN(0x7e9dd70d, 0x7b1566ee)}, + {TOBN(0x94ad78f7, 0xcbcd5e64), TOBN(0x0359ac17, 0x9bd4c032), + TOBN(0x3b11baaf, 0x7cc222ae), TOBN(0xa6a6e284, 0xba78e812)}}, + {{TOBN(0x8392053f, 0x24cea1a0), TOBN(0xc97bce4a, 0x33621491), + TOBN(0x7eb1db34, 0x35399ee9), TOBN(0x473f78ef, 0xece81ad1)}, + {TOBN(0x41d72fe0, 0xf63d3d0d), TOBN(0xe620b880, 0xafab62fc), + TOBN(0x92096bc9, 0x93158383), TOBN(0x41a21357, 0x8f896f6c)}}, + {{TOBN(0x1b5ee2fa, 0xc7dcfcab), TOBN(0x650acfde, 0x9546e007), + TOBN(0xc081b749, 0xb1b02e07), TOBN(0xda9e41a0, 0xf9eca03d)}, + {TOBN(0x013ba727, 0x175a54ab), TOBN(0xca0cd190, 0xea5d8d10), + TOBN(0x85ea52c0, 0x95fd96a9), TOBN(0x2c591b9f, 0xbc5c3940)}}, + {{TOBN(0x6fb4d4e4, 0x2bad4d5f), TOBN(0xfa4c3590, 0xfef0059b), + TOBN(0x6a10218a, 0xf5122294), TOBN(0x9a78a81a, 0xa85751d1)}, + {TOBN(0x04f20579, 0xa98e84e7), TOBN(0xfe1242c0, 0x4997e5b5), + TOBN(0xe77a273b, 0xca21e1e4), TOBN(0xfcc8b1ef, 0x9411939d)}}, + {{TOBN(0xe20ea302, 0x92d0487a), TOBN(0x1442dbec, 0x294b91fe), + TOBN(0x1f7a4afe, 0xbb6b0e8f), TOBN(0x1700ef74, 0x6889c318)}, + {TOBN(0xf5bbffc3, 0x70f1fc62), TOBN(0x3b31d4b6, 0x69c79cca), + TOBN(0xe8bc2aab, 0xa7f6340d), TOBN(0xb0b08ab4, 0xa725e10a)}}, + {{TOBN(0x44f05701, 0xae340050), TOBN(0xba4b3016, 0x1cf0c569), + TOBN(0x5aa29f83, 0xfbe19a51), TOBN(0x1b9ed428, 0xb71d752e)}, + {TOBN(0x1666e54e, 0xeb4819f5), TOBN(0x616cdfed, 0x9e18b75b), + TOBN(0x112ed5be, 0x3ee27b0b), TOBN(0xfbf28319, 0x44c7de4d)}}, + {{TOBN(0xd685ec85, 0xe0e60d84), TOBN(0x68037e30, 0x1db7ee78), + TOBN(0x5b65bdcd, 0x003c4d6e), TOBN(0x33e7363a, 0x93e29a6a)}, + {TOBN(0x995b3a61, 0x08d0756c), TOBN(0xd727f85c, 0x2faf134b), + TOBN(0xfac6edf7, 0x1d337823), TOBN(0x99b9aa50, 0x0439b8b4)}}, + {{TOBN(0x722eb104, 0xe2b4e075), TOBN(0x49987295, 0x437c4926), + TOBN(0xb1e4c0e4, 0x46a9b82d), TOBN(0xd0cb3197, 0x57a006f5)}, + {TOBN(0xf3de0f7d, 0xd7808c56), TOBN(0xb5c54d8f, 0x51f89772), + TOBN(0x500a114a, 0xadbd31aa), TOBN(0x9afaaaa6, 0x295f6cab)}}, + {{TOBN(0x94705e21, 0x04cf667a), TOBN(0xfc2a811b, 0x9d3935d7), + TOBN(0x560b0280, 0x6d09267c), TOBN(0xf19ed119, 0xf780e53b)}, + {TOBN(0xf0227c09, 0x067b6269), TOBN(0x967b8533, 0x5caef599), + TOBN(0x155b9243, 0x68efeebc), TOBN(0xcd6d34f5, 0xc497bae6)}}, + {{TOBN(0x1dd8d5d3, 0x6cceb370), TOBN(0x2aeac579, 0xa78d7bf9), + TOBN(0x5d65017d, 0x70b67a62), TOBN(0x70c8e44f, 0x17c53f67)}, + {TOBN(0xd1fc0950, 0x86a34d09), TOBN(0xe0fca256, 0xe7134907), + TOBN(0xe24fa29c, 0x80fdd315), TOBN(0x2c4acd03, 0xd87499ad)}}, + {{TOBN(0xbaaf7517, 0x3b5a9ba6), TOBN(0xb9cbe1f6, 0x12e51a51), + TOBN(0xd88edae3, 0x5e154897), TOBN(0xe4309c3c, 0x77b66ca0)}, + {TOBN(0xf5555805, 0xf67f3746), TOBN(0x85fc37ba, 0xa36401ff), + TOBN(0xdf86e2ca, 0xd9499a53), TOBN(0x6270b2a3, 0xecbc955b)}}, + {{TOBN(0xafae64f5, 0x974ad33b), TOBN(0x04d85977, 0xfe7b2df1), + TOBN(0x2a3db3ff, 0x4ab03f73), TOBN(0x0b87878a, 0x8702740a)}, + {TOBN(0x6d263f01, 0x5a061732), TOBN(0xc25430ce, 0xa32a1901), + TOBN(0xf7ebab3d, 0xdb155018), TOBN(0x3a86f693, 0x63a9b78e)}}, + {{TOBN(0x349ae368, 0xda9f3804), TOBN(0x470f07fe, 0xa164349c), + TOBN(0xd52f4cc9, 0x8562baa5), TOBN(0xc74a9e86, 0x2b290df3)}, + {TOBN(0xd3a1aa35, 0x43471a24), TOBN(0x239446be, 0xb8194511), + TOBN(0xbec2dd00, 0x81dcd44d), TOBN(0xca3d7f0f, 0xc42ac82d)}}, + {{TOBN(0x1f3db085, 0xfdaf4520), TOBN(0xbb6d3e80, 0x4549daf2), + TOBN(0xf5969d8a, 0x19ad5c42), TOBN(0x7052b13d, 0xdbfd1511)}, + {TOBN(0x11890d1b, 0x682b9060), TOBN(0xa71d3883, 0xac34452c), + TOBN(0xa438055b, 0x783805b4), TOBN(0x43241277, 0x4725b23e)}}, + {{TOBN(0xf20cf96e, 0x4901bbed), TOBN(0x6419c710, 0xf432a2bb), + TOBN(0x57a0fbb9, 0xdfa9cd7d), TOBN(0x589111e4, 0x00daa249)}, + {TOBN(0x19809a33, 0x7b60554e), TOBN(0xea5f8887, 0xede283a4), + TOBN(0x2d713802, 0x503bfd35), TOBN(0x151bb0af, 0x585d2a53)}}, + {{TOBN(0x40b08f74, 0x43b30ca8), TOBN(0xe10b5bba, 0xd9934583), + TOBN(0xe8a546d6, 0xb51110ad), TOBN(0x1dd50e66, 0x28e0b6c5)}, + {TOBN(0x292e9d54, 0xcff2b821), TOBN(0x3882555d, 0x47281760), + TOBN(0x134838f8, 0x3724d6e3), TOBN(0xf2c679e0, 0x22ddcda1)}}, + {{TOBN(0x40ee8815, 0x6d2a5768), TOBN(0x7f227bd2, 0x1c1e7e2d), + TOBN(0x487ba134, 0xd04ff443), TOBN(0x76e2ff3d, 0xc614e54b)}, + {TOBN(0x36b88d6f, 0xa3177ec7), TOBN(0xbf731d51, 0x2328fff5), + TOBN(0x758caea2, 0x49ba158e), TOBN(0x5ab8ff4c, 0x02938188)}}, + {{TOBN(0x33e16056, 0x35edc56d), TOBN(0x5a69d349, 0x7e940d79), + TOBN(0x6c4fd001, 0x03866dcb), TOBN(0x20a38f57, 0x4893cdef)}, + {TOBN(0xfbf3e790, 0xfac3a15b), TOBN(0x6ed7ea2e, 0x7a4f8e6b), + TOBN(0xa663eb4f, 0xbc3aca86), TOBN(0x22061ea5, 0x080d53f7)}}, + {{TOBN(0x2480dfe6, 0xf546783f), TOBN(0xd38bc6da, 0x5a0a641e), + TOBN(0xfb093cd1, 0x2ede8965), TOBN(0x89654db4, 0xacb455cf)}, + {TOBN(0x413cbf9a, 0x26e1adee), TOBN(0x291f3764, 0x373294d4), + TOBN(0x00797257, 0x648083fe), TOBN(0x25f504d3, 0x208cc341)}}, + {{TOBN(0x635a8e5e, 0xc3a0ee43), TOBN(0x70aaebca, 0x679898ff), + TOBN(0x9ee9f547, 0x5dc63d56), TOBN(0xce987966, 0xffb34d00)}, + {TOBN(0xf9f86b19, 0x5e26310a), TOBN(0x9e435484, 0x382a8ca8), + TOBN(0x253bcb81, 0xc2352fe4), TOBN(0xa4eac8b0, 0x4474b571)}}, + {{TOBN(0xc1b97512, 0xc1ad8cf8), TOBN(0x193b4e9e, 0x99e0b697), + TOBN(0x939d2716, 0x01e85df0), TOBN(0x4fb265b3, 0xcd44eafd)}, + {TOBN(0x321e7dcd, 0xe51e1ae2), TOBN(0x8e3a8ca6, 0xe3d8b096), + TOBN(0x8de46cb0, 0x52604998), TOBN(0x91099ad8, 0x39072aa7)}}, + {{TOBN(0x2617f91c, 0x93aa96b8), TOBN(0x0fc8716b, 0x7fca2e13), + TOBN(0xa7106f5e, 0x95328723), TOBN(0xd1c9c40b, 0x262e6522)}, + {TOBN(0xb9bafe86, 0x42b7c094), TOBN(0x1873439d, 0x1543c021), + TOBN(0xe1baa5de, 0x5cbefd5d), TOBN(0xa363fc5e, 0x521e8aff)}}, + {{TOBN(0xefe6320d, 0xf862eaac), TOBN(0x14419c63, 0x22c647dc), + TOBN(0x0e06707c, 0x4e46d428), TOBN(0xcb6c834f, 0x4a178f8f)}, + {TOBN(0x0f993a45, 0xd30f917c), TOBN(0xd4c4b049, 0x9879afee), + TOBN(0xb6142a1e, 0x70500063), TOBN(0x7c9b41c3, 0xa5d9d605)}}, + {{TOBN(0xbc00fc2f, 0x2f8ba2c7), TOBN(0x0966eb2f, 0x7c67aa28), + TOBN(0x13f7b516, 0x5a786972), TOBN(0x3bfb7557, 0x8a2fbba0)}, + {TOBN(0x131c4f23, 0x5a2b9620), TOBN(0xbff3ed27, 0x6faf46be), + TOBN(0x9b4473d1, 0x7e172323), TOBN(0x421e8878, 0x339f6246)}}, + {{TOBN(0x0fa8587a, 0x25a41632), TOBN(0xc0814124, 0xa35b6c93), + TOBN(0x2b18a9f5, 0x59ebb8db), TOBN(0x264e3357, 0x76edb29c)}, + {TOBN(0xaf245ccd, 0xc87c51e2), TOBN(0x16b3015b, 0x501e6214), + TOBN(0xbb31c560, 0x0a3882ce), TOBN(0x6961bb94, 0xfec11e04)}}, + {{TOBN(0x3b825b8d, 0xeff7a3a0), TOBN(0xbec33738, 0xb1df7326), + TOBN(0x68ad747c, 0x99604a1f), TOBN(0xd154c934, 0x9a3bd499)}, + {TOBN(0xac33506f, 0x1cc7a906), TOBN(0x73bb5392, 0x6c560e8f), + TOBN(0x6428fcbe, 0x263e3944), TOBN(0xc11828d5, 0x1c387434)}}, + {{TOBN(0x3cd04be1, 0x3e4b12ff), TOBN(0xc3aad9f9, 0x2d88667c), + TOBN(0xc52ddcf8, 0x248120cf), TOBN(0x985a892e, 0x2a389532)}, + {TOBN(0xfbb4b21b, 0x3bb85fa0), TOBN(0xf95375e0, 0x8dfc6269), + TOBN(0xfb4fb06c, 0x7ee2acea), TOBN(0x6785426e, 0x309c4d1f)}}, + {{TOBN(0x659b17c8, 0xd8ceb147), TOBN(0x9b649eee, 0xb70a5554), + TOBN(0x6b7fa0b5, 0xac6bc634), TOBN(0xd99fe2c7, 0x1d6e732f)}, + {TOBN(0x30e6e762, 0x8d3abba2), TOBN(0x18fee6e7, 0xa797b799), + TOBN(0x5c9d360d, 0xc696464d), TOBN(0xe3baeb48, 0x27bfde12)}}, + {{TOBN(0x2bf5db47, 0xf23206d5), TOBN(0x2f6d3420, 0x1d260152), + TOBN(0x17b87653, 0x3f8ff89a), TOBN(0x5157c30c, 0x378fa458)}, + {TOBN(0x7517c5c5, 0x2d4fb936), TOBN(0xef22f7ac, 0xe6518cdc), + TOBN(0xdeb483e6, 0xbf847a64), TOBN(0xf5084558, 0x92e0fa89)}}}, + {{{TOBN(0xab9659d8, 0xdf7304d4), TOBN(0xb71bcf1b, 0xff210e8e), + TOBN(0xa9a2438b, 0xd73fbd60), TOBN(0x4595cd1f, 0x5d11b4de)}, + {TOBN(0x9c0d329a, 0x4835859d), TOBN(0x4a0f0d2d, 0x7dbb6e56), + TOBN(0xc6038e5e, 0xdf928a4e), TOBN(0xc9429621, 0x8f5ad154)}}, + {{TOBN(0x91213462, 0xf23f2d92), TOBN(0x6cab71bd, 0x60b94078), + TOBN(0x6bdd0a63, 0x176cde20), TOBN(0x54c9b20c, 0xee4d54bc)}, + {TOBN(0x3cd2d8aa, 0x9f2ac02f), TOBN(0x03f8e617, 0x206eedb0), + TOBN(0xc7f68e16, 0x93086434), TOBN(0x831469c5, 0x92dd3db9)}}, + {{TOBN(0x8521df24, 0x8f981354), TOBN(0x587e23ec, 0x3588a259), + TOBN(0xcbedf281, 0xd7a0992c), TOBN(0x06930a55, 0x38961407)}, + {TOBN(0x09320deb, 0xbe5bbe21), TOBN(0xa7ffa5b5, 0x2491817f), + TOBN(0xe6c8b4d9, 0x09065160), TOBN(0xac4f3992, 0xfff6d2a9)}}, + {{TOBN(0x7aa7a158, 0x3ae9c1bd), TOBN(0xe0af6d98, 0xe37ce240), + TOBN(0xe54342d9, 0x28ab38b4), TOBN(0xe8b75007, 0x0a1c98ca)}, + {TOBN(0xefce86af, 0xe02358f2), TOBN(0x31b8b856, 0xea921228), + TOBN(0x052a1912, 0x0a1c67fc), TOBN(0xb4069ea4, 0xe3aead59)}}, + {{TOBN(0x3232d6e2, 0x7fa03cb3), TOBN(0xdb938e5b, 0x0fdd7d88), + TOBN(0x04c1d2cd, 0x2ccbfc5d), TOBN(0xd2f45c12, 0xaf3a580f)}, + {TOBN(0x592620b5, 0x7883e614), TOBN(0x5fd27e68, 0xbe7c5f26), + TOBN(0x139e45a9, 0x1567e1e3), TOBN(0x2cc71d2d, 0x44d8aaaf)}}, + {{TOBN(0x4a9090cd, 0xe36d0757), TOBN(0xf722d7b1, 0xd9a29382), + TOBN(0xfb7fb04c, 0x04b48ddf), TOBN(0x628ad2a7, 0xebe16f43)}, + {TOBN(0xcd3fbfb5, 0x20226040), TOBN(0x6c34ecb1, 0x5104b6c4), + TOBN(0x30c0754e, 0xc903c188), TOBN(0xec336b08, 0x2d23cab0)}}, + {{TOBN(0x473d62a2, 0x1e206ee5), TOBN(0xf1e27480, 0x8c49a633), + TOBN(0x87ab956c, 0xe9f6b2c3), TOBN(0x61830b48, 0x62b606ea)}, + {TOBN(0x67cd6846, 0xe78e815f), TOBN(0xfe40139f, 0x4c02082a), + TOBN(0x52bbbfcb, 0x952ec365), TOBN(0x74c11642, 0x6b9836ab)}}, + {{TOBN(0x9f51439e, 0x558df019), TOBN(0x230da4ba, 0xac712b27), + TOBN(0x518919e3, 0x55185a24), TOBN(0x4dcefcdd, 0x84b78f50)}, + {TOBN(0xa7d90fb2, 0xa47d4c5a), TOBN(0x55ac9abf, 0xb30e009e), + TOBN(0xfd2fc359, 0x74eed273), TOBN(0xb72d824c, 0xdbea8faf)}}, + {{TOBN(0xce721a74, 0x4513e2ca), TOBN(0x0b418612, 0x38240b2c), + TOBN(0x05199968, 0xd5baa450), TOBN(0xeb1757ed, 0x2b0e8c25)}, + {TOBN(0x6ebc3e28, 0x3dfac6d5), TOBN(0xb2431e2e, 0x48a237f5), + TOBN(0x2acb5e23, 0x52f61499), TOBN(0x5558a2a7, 0xe06c936b)}}, + {{TOBN(0xd213f923, 0xcbb13d1b), TOBN(0x98799f42, 0x5bfb9bfe), + TOBN(0x1ae8ddc9, 0x701144a9), TOBN(0x0b8b3bb6, 0x4c5595ee)}, + {TOBN(0x0ea9ef2e, 0x3ecebb21), TOBN(0x17cb6c4b, 0x3671f9a7), + TOBN(0x47ef464f, 0x726f1d1f), TOBN(0x171b9484, 0x6943a276)}}, + {{TOBN(0x51a4ae2d, 0x7ef0329c), TOBN(0x08509222, 0x91c4402a), + TOBN(0x64a61d35, 0xafd45bbc), TOBN(0x38f096fe, 0x3035a851)}, + {TOBN(0xc7468b74, 0xa1dec027), TOBN(0xe8cf10e7, 0x4fc7dcba), + TOBN(0xea35ff40, 0xf4a06353), TOBN(0x0b4c0dfa, 0x8b77dd66)}}, + {{TOBN(0x779b8552, 0xde7e5c19), TOBN(0xfab28609, 0xc1c0256c), + TOBN(0x64f58eee, 0xabd4743d), TOBN(0x4e8ef838, 0x7b6cc93b)}, + {TOBN(0xee650d26, 0x4cb1bf3d), TOBN(0x4c1f9d09, 0x73dedf61), + TOBN(0xaef7c9d7, 0xbfb70ced), TOBN(0x1ec0507e, 0x1641de1e)}}, + {{TOBN(0xcd7e5cc7, 0xcde45079), TOBN(0xde173c9a, 0x516ac9e4), + TOBN(0x517a8494, 0xc170315c), TOBN(0x438fd905, 0x91d8e8fb)}, + {TOBN(0x5145c506, 0xc7d9630b), TOBN(0x6457a87b, 0xf47d4d75), + TOBN(0xd31646bf, 0x0d9a80e8), TOBN(0x453add2b, 0xcef3aabe)}}, + {{TOBN(0xc9941109, 0xa607419d), TOBN(0xfaa71e62, 0xbb6bca80), + TOBN(0x34158c13, 0x07c431f3), TOBN(0x594abebc, 0x992bc47a)}, + {TOBN(0x6dfea691, 0xeb78399f), TOBN(0x48aafb35, 0x3f42cba4), + TOBN(0xedcd65af, 0x077c04f0), TOBN(0x1a29a366, 0xe884491a)}}, + {{TOBN(0x023a40e5, 0x1c21f2bf), TOBN(0xf99a513c, 0xa5057aee), + TOBN(0xa3fe7e25, 0xbcab072e), TOBN(0x8568d2e1, 0x40e32bcf)}, + {TOBN(0x904594eb, 0xd3f69d9f), TOBN(0x181a9733, 0x07affab1), + TOBN(0xe4d68d76, 0xb6e330f4), TOBN(0x87a6dafb, 0xc75a7fc1)}}, + {{TOBN(0x549db2b5, 0xef7d9289), TOBN(0x2480d4a8, 0x197f015a), + TOBN(0x61d5590b, 0xc40493b6), TOBN(0x3a55b52e, 0x6f780331)}, + {TOBN(0x40eb8115, 0x309eadb0), TOBN(0xdea7de5a, 0x92e5c625), + TOBN(0x64d631f0, 0xcc6a3d5a), TOBN(0x9d5e9d7c, 0x93e8dd61)}}, + {{TOBN(0xf297bef5, 0x206d3ffc), TOBN(0x23d5e033, 0x7d808bd4), + TOBN(0x4a4f6912, 0xd24cf5ba), TOBN(0xe4d8163b, 0x09cdaa8a)}, + {TOBN(0x0e0de9ef, 0xd3082e8e), TOBN(0x4fe1246c, 0x0192f360), + TOBN(0x1f900150, 0x4b8eee0a), TOBN(0x5219da81, 0xf1da391b)}}, + {{TOBN(0x7bf6a5c1, 0xf7ea25aa), TOBN(0xd165e6bf, 0xfbb07d5f), + TOBN(0xe3539361, 0x89e78671), TOBN(0xa3fcac89, 0x2bac4219)}, + {TOBN(0xdfab6fd4, 0xf0baa8ab), TOBN(0x5a4adac1, 0xe2c1c2e5), + TOBN(0x6cd75e31, 0x40d85849), TOBN(0xce263fea, 0x19b39181)}}, + {{TOBN(0xcb6803d3, 0x07032c72), TOBN(0x7f40d5ce, 0x790968c8), + TOBN(0xa6de86bd, 0xdce978f0), TOBN(0x25547c4f, 0x368f751c)}, + {TOBN(0xb1e685fd, 0x65fb2a9e), TOBN(0xce69336f, 0x1eb9179c), + TOBN(0xb15d1c27, 0x12504442), TOBN(0xb7df465c, 0xb911a06b)}}, + {{TOBN(0xb8d804a3, 0x315980cd), TOBN(0x693bc492, 0xfa3bebf7), + TOBN(0x3578aeee, 0x2253c504), TOBN(0x158de498, 0xcd2474a2)}, + {TOBN(0x1331f5c7, 0xcfda8368), TOBN(0xd2d7bbb3, 0x78d7177e), + TOBN(0xdf61133a, 0xf3c1e46e), TOBN(0x5836ce7d, 0xd30e7be8)}}, + {{TOBN(0x83084f19, 0x94f834cb), TOBN(0xd35653d4, 0x429ed782), + TOBN(0xa542f16f, 0x59e58243), TOBN(0xc2b52f65, 0x0470a22d)}, + {TOBN(0xe3b6221b, 0x18f23d96), TOBN(0xcb05abac, 0x3f5252b4), + TOBN(0xca00938b, 0x87d61402), TOBN(0x2f186cdd, 0x411933e4)}}, + {{TOBN(0xe042ece5, 0x9a29a5c5), TOBN(0xb19b3c07, 0x3b6c8402), + TOBN(0xc97667c7, 0x19d92684), TOBN(0xb5624622, 0xebc66372)}, + {TOBN(0x0cb96e65, 0x3c04fa02), TOBN(0x83a7176c, 0x8eaa39aa), + TOBN(0x2033561d, 0xeaa1633f), TOBN(0x45a9d086, 0x4533df73)}}, + {{TOBN(0xe0542c1d, 0x3dc090bc), TOBN(0x82c996ef, 0xaa59c167), + TOBN(0xe3f735e8, 0x0ee7fc4d), TOBN(0x7b179393, 0x7c35db79)}, + {TOBN(0xb6419e25, 0xf8c5dbfd), TOBN(0x4d9d7a1e, 0x1f327b04), + TOBN(0x979f6f9b, 0x298dfca8), TOBN(0xc7c5dff1, 0x8de9366a)}}, + {{TOBN(0x1b7a588d, 0x04c82bdd), TOBN(0x68005534, 0xf8319dfd), + TOBN(0xde8a55b5, 0xd8eb9580), TOBN(0x5ea886da, 0x8d5bca81)}, + {TOBN(0xe8530a01, 0x252a0b4d), TOBN(0x1bffb4fe, 0x35eaa0a1), + TOBN(0x2ad828b1, 0xd8e99563), TOBN(0x7de96ef5, 0x95f9cd87)}}, + {{TOBN(0x4abb2d0c, 0xd77d970c), TOBN(0x03cfb933, 0xd33ef9cb), + TOBN(0xb0547c01, 0x8b211fe9), TOBN(0x2fe64809, 0xa56ed1c6)}, + {TOBN(0xcb7d5624, 0xc2ac98cc), TOBN(0x2a1372c0, 0x1a393e33), + TOBN(0xc8d1ec1c, 0x29660521), TOBN(0xf3d31b04, 0xb37ac3e9)}}, + {{TOBN(0xa29ae9df, 0x5ece6e7c), TOBN(0x0603ac8f, 0x0facfb55), + TOBN(0xcfe85b7a, 0xdda233a5), TOBN(0xe618919f, 0xbd75f0b8)}, + {TOBN(0xf555a3d2, 0x99bf1603), TOBN(0x1f43afc9, 0xf184255a), + TOBN(0xdcdaf341, 0x319a3e02), TOBN(0xd3b117ef, 0x03903a39)}}, + {{TOBN(0xe095da13, 0x65d1d131), TOBN(0x86f16367, 0xc37ad03e), + TOBN(0x5f37389e, 0x462cd8dd), TOBN(0xc103fa04, 0xd67a60e6)}, + {TOBN(0x57c34344, 0xf4b478f0), TOBN(0xce91edd8, 0xe117c98d), + TOBN(0x001777b0, 0x231fc12e), TOBN(0x11ae47f2, 0xb207bccb)}}, + {{TOBN(0xd983cf8d, 0x20f8a242), TOBN(0x7aff5b1d, 0xf22e1ad8), + TOBN(0x68fd11d0, 0x7fc4feb3), TOBN(0x5d53ae90, 0xb0f1c3e1)}, + {TOBN(0x50fb7905, 0xec041803), TOBN(0x85e3c977, 0x14404888), + TOBN(0x0e67faed, 0xac628d8f), TOBN(0x2e865150, 0x6668532c)}}, + {{TOBN(0x15acaaa4, 0x6a67a6b0), TOBN(0xf4cdee25, 0xb25cec41), + TOBN(0x49ee565a, 0xe4c6701e), TOBN(0x2a04ca66, 0xfc7d63d8)}, + {TOBN(0xeb105018, 0xef0543fb), TOBN(0xf709a4f5, 0xd1b0d81d), + TOBN(0x5b906ee6, 0x2915d333), TOBN(0xf4a87412, 0x96f1f0ab)}}, + {{TOBN(0xb6b82fa7, 0x4d82f4c2), TOBN(0x90725a60, 0x6804efb3), + TOBN(0xbc82ec46, 0xadc3425e), TOBN(0xb7b80581, 0x2787843e)}, + {TOBN(0xdf46d91c, 0xdd1fc74c), TOBN(0xdc1c62cb, 0xe783a6c4), + TOBN(0x59d1b9f3, 0x1a04cbba), TOBN(0xd87f6f72, 0x95e40764)}}, + {{TOBN(0x02b4cfc1, 0x317f4a76), TOBN(0x8d2703eb, 0x91036bce), + TOBN(0x98206cc6, 0xa5e72a56), TOBN(0x57be9ed1, 0xcf53fb0f)}, + {TOBN(0x09374571, 0xef0b17ac), TOBN(0x74b2655e, 0xd9181b38), + TOBN(0xc8f80ea8, 0x89935d0e), TOBN(0xc0d9e942, 0x91529936)}}, + {{TOBN(0x19686041, 0x1e84e0e5), TOBN(0xa5db84d3, 0xaea34c93), + TOBN(0xf9d5bb19, 0x7073a732), TOBN(0xb8d2fe56, 0x6bcfd7c0)}, + {TOBN(0x45775f36, 0xf3eb82fa), TOBN(0x8cb20ccc, 0xfdff8b58), + TOBN(0x1659b65f, 0x8374c110), TOBN(0xb8b4a422, 0x330c789a)}}, + {{TOBN(0x75e3c3ea, 0x6fe8208b), TOBN(0xbd74b9e4, 0x286e78fe), + TOBN(0x0be2e81b, 0xd7d93a1a), TOBN(0x7ed06e27, 0xdd0a5aae)}, + {TOBN(0x721f5a58, 0x6be8b800), TOBN(0x428299d1, 0xd846db28), + TOBN(0x95cb8e6b, 0x5be88ed3), TOBN(0xc3186b23, 0x1c034e11)}}, + {{TOBN(0xa6312c9e, 0x8977d99b), TOBN(0xbe944331, 0x83f531e7), + TOBN(0x8232c0c2, 0x18d3b1d4), TOBN(0x617aae8b, 0xe1247b73)}, + {TOBN(0x40153fc4, 0x282aec3b), TOBN(0xc6063d2f, 0xf7b8f823), + TOBN(0x68f10e58, 0x3304f94c), TOBN(0x31efae74, 0xee676346)}}, + {{TOBN(0xbadb6c6d, 0x40a9b97c), TOBN(0x14702c63, 0x4f666256), + TOBN(0xdeb954f1, 0x5184b2e3), TOBN(0x5184a526, 0x94b6ca40)}, + {TOBN(0xfff05337, 0x003c32ea), TOBN(0x5aa374dd, 0x205974c7), + TOBN(0x9a763854, 0x4b0dd71a), TOBN(0x459cd27f, 0xdeb947ec)}}, + {{TOBN(0xa6e28161, 0x459c2b92), TOBN(0x2f020fa8, 0x75ee8ef5), + TOBN(0xb132ec2d, 0x30b06310), TOBN(0xc3e15899, 0xbc6a4530)}, + {TOBN(0xdc5f53fe, 0xaa3f451a), TOBN(0x3a3c7f23, 0xc2d9acac), + TOBN(0x2ec2f892, 0x6b27e58b), TOBN(0x68466ee7, 0xd742799f)}}, + {{TOBN(0x98324dd4, 0x1fa26613), TOBN(0xa2dc6dab, 0xbdc29d63), + TOBN(0xf9675faa, 0xd712d657), TOBN(0x813994be, 0x21fd8d15)}, + {TOBN(0x5ccbb722, 0xfd4f7553), TOBN(0x5135ff8b, 0xf3a36b20), + TOBN(0x44be28af, 0x69559df5), TOBN(0x40b65bed, 0x9d41bf30)}}, + {{TOBN(0xd98bf2a4, 0x3734e520), TOBN(0x5e3abbe3, 0x209bdcba), + TOBN(0x77c76553, 0xbc945b35), TOBN(0x5331c093, 0xc6ef14aa)}, + {TOBN(0x518ffe29, 0x76b60c80), TOBN(0x2285593b, 0x7ace16f8), + TOBN(0xab1f64cc, 0xbe2b9784), TOBN(0xe8f2c0d9, 0xab2421b6)}}, + {{TOBN(0x617d7174, 0xc1df065c), TOBN(0xafeeb5ab, 0x5f6578fa), + TOBN(0x16ff1329, 0x263b54a8), TOBN(0x45c55808, 0xc990dce3)}, + {TOBN(0x42eab6c0, 0xecc8c177), TOBN(0x799ea9b5, 0x5982ecaa), + TOBN(0xf65da244, 0xb607ef8e), TOBN(0x8ab226ce, 0x32a3fc2c)}}, + {{TOBN(0x745741e5, 0x7ea973dc), TOBN(0x5c00ca70, 0x20888f2e), + TOBN(0x7cdce3cf, 0x45fd9cf1), TOBN(0x8a741ef1, 0x5507f872)}, + {TOBN(0x47c51c2f, 0x196b4cec), TOBN(0x70d08e43, 0xc97ea618), + TOBN(0x930da15c, 0x15b18a2b), TOBN(0x33b6c678, 0x2f610514)}}, + {{TOBN(0xc662e4f8, 0x07ac9794), TOBN(0x1eccf050, 0xba06cb79), + TOBN(0x1ff08623, 0xe7d954e5), TOBN(0x6ef2c5fb, 0x24cf71c3)}, + {TOBN(0xb2c063d2, 0x67978453), TOBN(0xa0cf3796, 0x1d654af8), + TOBN(0x7cb242ea, 0x7ebdaa37), TOBN(0x206e0b10, 0xb86747e0)}}, + {{TOBN(0x481dae5f, 0xd5ecfefc), TOBN(0x07084fd8, 0xc2bff8fc), + TOBN(0x8040a01a, 0xea324596), TOBN(0x4c646980, 0xd4de4036)}, + {TOBN(0x9eb8ab4e, 0xd65abfc3), TOBN(0xe01cb91f, 0x13541ec7), + TOBN(0x8f029adb, 0xfd695012), TOBN(0x9ae28483, 0x3c7569ec)}}, + {{TOBN(0xa5614c9e, 0xa66d80a1), TOBN(0x680a3e44, 0x75f5f911), + TOBN(0x0c07b14d, 0xceba4fc1), TOBN(0x891c285b, 0xa13071c1)}, + {TOBN(0xcac67ceb, 0x799ece3c), TOBN(0x29b910a9, 0x41e07e27), + TOBN(0x66bdb409, 0xf2e43123), TOBN(0x06f8b137, 0x7ac9ecbe)}}, + {{TOBN(0x5981fafd, 0x38547090), TOBN(0x19ab8b9f, 0x85e3415d), + TOBN(0xfc28c194, 0xc7e31b27), TOBN(0x843be0aa, 0x6fbcbb42)}, + {TOBN(0xf3b1ed43, 0xa6db836c), TOBN(0x2a1330e4, 0x01a45c05), + TOBN(0x4f19f3c5, 0x95c1a377), TOBN(0xa85f39d0, 0x44b5ee33)}}, + {{TOBN(0x3da18e6d, 0x4ae52834), TOBN(0x5a403b39, 0x7423dcb0), + TOBN(0xbb555e0a, 0xf2374aef), TOBN(0x2ad599c4, 0x1e8ca111)}, + {TOBN(0x1b3a2fb9, 0x014b3bf8), TOBN(0x73092684, 0xf66d5007), + TOBN(0x079f1426, 0xc4340102), TOBN(0x1827cf81, 0x8fddf4de)}}, + {{TOBN(0xc83605f6, 0xf10ff927), TOBN(0xd3871451, 0x23739fc6), + TOBN(0x6d163450, 0xcac1c2cc), TOBN(0x6b521296, 0xa2ec1ac5)}, + {TOBN(0x0606c4f9, 0x6e3cb4a5), TOBN(0xe47d3f41, 0x778abff7), + TOBN(0x425a8d5e, 0xbe8e3a45), TOBN(0x53ea9e97, 0xa6102160)}}, + {{TOBN(0x477a106e, 0x39cbb688), TOBN(0x532401d2, 0xf3386d32), + TOBN(0x8e564f64, 0xb1b9b421), TOBN(0xca9b8388, 0x81dad33f)}, + {TOBN(0xb1422b4e, 0x2093913e), TOBN(0x533d2f92, 0x69bc8112), + TOBN(0x3fa017be, 0xebe7b2c7), TOBN(0xb2767c4a, 0xcaf197c6)}}, + {{TOBN(0xc925ff87, 0xaedbae9f), TOBN(0x7daf0eb9, 0x36880a54), + TOBN(0x9284ddf5, 0x9c4d0e71), TOBN(0x1581cf93, 0x316f8cf5)}, + {TOBN(0x3eeca887, 0x3ac1f452), TOBN(0xb417fce9, 0xfb6aeffe), + TOBN(0xa5918046, 0xeefb8dc3), TOBN(0x73d318ac, 0x02209400)}}, + {{TOBN(0xe800400f, 0x728693e5), TOBN(0xe87d814b, 0x339927ed), + TOBN(0x93e94d3b, 0x57ea9910), TOBN(0xff8a35b6, 0x2245fb69)}, + {TOBN(0x043853d7, 0x7f200d34), TOBN(0x470f1e68, 0x0f653ce1), + TOBN(0x81ac05bd, 0x59a06379), TOBN(0xa14052c2, 0x03930c29)}}, + {{TOBN(0x6b72fab5, 0x26bc2797), TOBN(0x13670d16, 0x99f16771), + TOBN(0x00170052, 0x1e3e48d1), TOBN(0x978fe401, 0xb7adf678)}, + {TOBN(0x55ecfb92, 0xd41c5dd4), TOBN(0x5ff8e247, 0xc7b27da5), + TOBN(0xe7518272, 0x013fb606), TOBN(0x5768d7e5, 0x2f547a3c)}}, + {{TOBN(0xbb24eaa3, 0x60017a5f), TOBN(0x6b18e6e4, 0x9c64ce9b), + TOBN(0xc225c655, 0x103dde07), TOBN(0xfc3672ae, 0x7592f7ea)}, + {TOBN(0x9606ad77, 0xd06283a1), TOBN(0x542fc650, 0xe4d59d99), + TOBN(0xabb57c49, 0x2a40e7c2), TOBN(0xac948f13, 0xa8db9f55)}}, + {{TOBN(0x6d4c9682, 0xb04465c3), TOBN(0xe3d062fa, 0x6468bd15), + TOBN(0xa51729ac, 0x5f318d7e), TOBN(0x1fc87df6, 0x9eb6fc95)}, + {TOBN(0x63d146a8, 0x0591f652), TOBN(0xa861b8f7, 0x589621aa), + TOBN(0x59f5f15a, 0xce31348c), TOBN(0x8f663391, 0x440da6da)}}, + {{TOBN(0xcfa778ac, 0xb591ffa3), TOBN(0x027ca9c5, 0x4cdfebce), + TOBN(0xbe8e05a5, 0x444ea6b3), TOBN(0x8aab4e69, 0xa78d8254)}, + {TOBN(0x2437f04f, 0xb474d6b8), TOBN(0x6597ffd4, 0x045b3855), + TOBN(0xbb0aea4e, 0xca47ecaa), TOBN(0x568aae83, 0x85c7ebfc)}}, + {{TOBN(0x0e966e64, 0xc73b2383), TOBN(0x49eb3447, 0xd17d8762), + TOBN(0xde107821, 0x8da05dab), TOBN(0x443d8baa, 0x016b7236)}, + {TOBN(0x163b63a5, 0xea7610d6), TOBN(0xe47e4185, 0xce1ca979), + TOBN(0xae648b65, 0x80baa132), TOBN(0xebf53de2, 0x0e0d5b64)}}, + {{TOBN(0x8d3bfcb4, 0xd3c8c1ca), TOBN(0x0d914ef3, 0x5d04b309), + TOBN(0x55ef6415, 0x3de7d395), TOBN(0xbde1666f, 0x26b850e8)}, + {TOBN(0xdbe1ca6e, 0xd449ab19), TOBN(0x8902b322, 0xe89a2672), + TOBN(0xb1674b7e, 0xdacb7a53), TOBN(0x8e9faf6e, 0xf52523ff)}}, + {{TOBN(0x6ba535da, 0x9a85788b), TOBN(0xd21f03ae, 0xbd0626d4), + TOBN(0x099f8c47, 0xe873dc64), TOBN(0xcda8564d, 0x018ec97e)}, + {TOBN(0x3e8d7a5c, 0xde92c68c), TOBN(0x78e035a1, 0x73323cc4), + TOBN(0x3ef26275, 0xf880ff7c), TOBN(0xa4ee3dff, 0x273eedaa)}}, + {{TOBN(0x58823507, 0xaf4e18f8), TOBN(0x967ec9b5, 0x0672f328), + TOBN(0x9ded19d9, 0x559d3186), TOBN(0x5e2ab3de, 0x6cdce39c)}, + {TOBN(0xabad6e4d, 0x11c226df), TOBN(0xf9783f43, 0x87723014), + TOBN(0x9a49a0cf, 0x1a885719), TOBN(0xfc0c1a5a, 0x90da9dbf)}}, + {{TOBN(0x8bbaec49, 0x571d92ac), TOBN(0x569e85fe, 0x4692517f), + TOBN(0x8333b014, 0xa14ea4af), TOBN(0x32f2a62f, 0x12e5c5ad)}, + {TOBN(0x98c2ce3a, 0x06d89b85), TOBN(0xb90741aa, 0x2ff77a08), + TOBN(0x2530defc, 0x01f795a2), TOBN(0xd6e5ba0b, 0x84b3c199)}}, + {{TOBN(0x7d8e8451, 0x12e4c936), TOBN(0xae419f7d, 0xbd0be17b), + TOBN(0xa583fc8c, 0x22262bc9), TOBN(0x6b842ac7, 0x91bfe2bd)}, + {TOBN(0x33cef4e9, 0x440d6827), TOBN(0x5f69f4de, 0xef81fb14), + TOBN(0xf16cf6f6, 0x234fbb92), TOBN(0x76ae3fc3, 0xd9e7e158)}}, + {{TOBN(0x4e89f6c2, 0xe9740b33), TOBN(0x677bc85d, 0x4962d6a1), + TOBN(0x6c6d8a7f, 0x68d10d15), TOBN(0x5f9a7224, 0x0257b1cd)}, + {TOBN(0x7096b916, 0x4ad85961), TOBN(0x5f8c47f7, 0xe657ab4a), + TOBN(0xde57d7d0, 0xf7461d7e), TOBN(0x7eb6094d, 0x80ce5ee2)}}, + {{TOBN(0x0b1e1dfd, 0x34190547), TOBN(0x8a394f43, 0xf05dd150), + TOBN(0x0a9eb24d, 0x97df44e6), TOBN(0x78ca06bf, 0x87675719)}, + {TOBN(0x6f0b3462, 0x6ffeec22), TOBN(0x9d91bcea, 0x36cdd8fb), + TOBN(0xac83363c, 0xa105be47), TOBN(0x81ba76c1, 0x069710e3)}}, + {{TOBN(0x3d1b24cb, 0x28c682c6), TOBN(0x27f25228, 0x8612575b), + TOBN(0xb587c779, 0xe8e66e98), TOBN(0x7b0c03e9, 0x405eb1fe)}, + {TOBN(0xfdf0d030, 0x15b548e7), TOBN(0xa8be76e0, 0x38b36af7), + TOBN(0x4cdab04a, 0x4f310c40), TOBN(0x6287223e, 0xf47ecaec)}}, + {{TOBN(0x678e6055, 0x8b399320), TOBN(0x61fe3fa6, 0xc01e4646), + TOBN(0xc482866b, 0x03261a5e), TOBN(0xdfcf45b8, 0x5c2f244a)}, + {TOBN(0x8fab9a51, 0x2f684b43), TOBN(0xf796c654, 0xc7220a66), + TOBN(0x1d90707e, 0xf5afa58f), TOBN(0x2c421d97, 0x4fdbe0de)}}, + {{TOBN(0xc4f4cda3, 0xaf2ebc2f), TOBN(0xa0af843d, 0xcb4efe24), + TOBN(0x53b857c1, 0x9ccd10b1), TOBN(0xddc9d1eb, 0x914d3e04)}, + {TOBN(0x7bdec8bb, 0x62771deb), TOBN(0x829277aa, 0x91c5aa81), + TOBN(0x7af18dd6, 0x832391ae), TOBN(0x1740f316, 0xc71a84ca)}}}, + {{{TOBN(0x8928e99a, 0xeeaf8c49), TOBN(0xee7aa73d, 0x6e24d728), + TOBN(0x4c5007c2, 0xe72b156c), TOBN(0x5fcf57c5, 0xed408a1d)}, + {TOBN(0x9f719e39, 0xb6057604), TOBN(0x7d343c01, 0xc2868bbf), + TOBN(0x2cca254b, 0x7e103e2d), TOBN(0xe6eb38a9, 0xf131bea2)}}, + {{TOBN(0xb33e624f, 0x8be762b4), TOBN(0x2a9ee4d1, 0x058e3413), + TOBN(0x968e6369, 0x67d805fa), TOBN(0x9848949b, 0x7db8bfd7)}, + {TOBN(0x5308d7e5, 0xd23a8417), TOBN(0x892f3b1d, 0xf3e29da5), + TOBN(0xc95c139e, 0x3dee471f), TOBN(0x8631594d, 0xd757e089)}}, + {{TOBN(0xe0c82a3c, 0xde918dcc), TOBN(0x2e7b5994, 0x26fdcf4b), + TOBN(0x82c50249, 0x32cb1b2d), TOBN(0xea613a9d, 0x7657ae07)}, + {TOBN(0xc2eb5f6c, 0xf1fdc9f7), TOBN(0xb6eae8b8, 0x879fe682), + TOBN(0x253dfee0, 0x591cbc7f), TOBN(0x000da713, 0x3e1290e6)}}, + {{TOBN(0x1083e2ea, 0x1f095615), TOBN(0x0a28ad77, 0x14e68c33), + TOBN(0x6bfc0252, 0x3d8818be), TOBN(0xb585113a, 0xf35850cd)}, + {TOBN(0x7d935f0b, 0x30df8aa1), TOBN(0xaddda07c, 0x4ab7e3ac), + TOBN(0x92c34299, 0x552f00cb), TOBN(0xc33ed1de, 0x2909df6c)}}, + {{TOBN(0x22c2195d, 0x80e87766), TOBN(0x9e99e6d8, 0x9ddf4ac0), + TOBN(0x09642e4e, 0x65e74934), TOBN(0x2610ffa2, 0xff1ff241)}, + {TOBN(0x4d1d47d4, 0x751c8159), TOBN(0x697b4985, 0xaf3a9363), + TOBN(0x0318ca46, 0x87477c33), TOBN(0xa90cb565, 0x9441eff3)}}, + {{TOBN(0x58bb3848, 0x36f024cb), TOBN(0x85be1f77, 0x36016168), + TOBN(0x6c59587c, 0xdc7e07f1), TOBN(0x191be071, 0xaf1d8f02)}, + {TOBN(0xbf169fa5, 0xcca5e55c), TOBN(0x3864ba3c, 0xf7d04eac), + TOBN(0x915e367f, 0x8d7d05db), TOBN(0xb48a876d, 0xa6549e5d)}}, + {{TOBN(0xef89c656, 0x580e40a2), TOBN(0xf194ed8c, 0x728068bc), + TOBN(0x74528045, 0xa47990c9), TOBN(0xf53fc7d7, 0x5e1a4649)}, + {TOBN(0xbec5ae9b, 0x78593e7d), TOBN(0x2cac4ee3, 0x41db65d7), + TOBN(0xa8c1eb24, 0x04a3d39b), TOBN(0x53b7d634, 0x03f8f3ef)}}, + {{TOBN(0x2dc40d48, 0x3e07113c), TOBN(0x6e4a5d39, 0x7d8b63ae), + TOBN(0x5582a94b, 0x79684c2b), TOBN(0x932b33d4, 0x622da26c)}, + {TOBN(0xf534f651, 0x0dbbf08d), TOBN(0x211d07c9, 0x64c23a52), + TOBN(0x0eeece0f, 0xee5bdc9b), TOBN(0xdf178168, 0xf7015558)}}, + {{TOBN(0xd4294635, 0x0a712229), TOBN(0x93cbe448, 0x09273f8c), + TOBN(0x00b095ef, 0x8f13bc83), TOBN(0xbb741972, 0x8798978c)}, + {TOBN(0x9d7309a2, 0x56dbe6e7), TOBN(0xe578ec56, 0x5a5d39ec), + TOBN(0x3961151b, 0x851f9a31), TOBN(0x2da7715d, 0xe5709eb4)}}, + {{TOBN(0x867f3017, 0x53dfabf0), TOBN(0x728d2078, 0xb8e39259), + TOBN(0x5c75a0cd, 0x815d9958), TOBN(0xf84867a6, 0x16603be1)}, + {TOBN(0xc865b13d, 0x70e35b1c), TOBN(0x02414468, 0x19b03e2c), + TOBN(0xe46041da, 0xac1f3121), TOBN(0x7c9017ad, 0x6f028a7c)}}, + {{TOBN(0xabc96de9, 0x0a482873), TOBN(0x4265d6b1, 0xb77e54d4), + TOBN(0x68c38e79, 0xa57d88e7), TOBN(0xd461d766, 0x9ce82de3)}, + {TOBN(0x817a9ec5, 0x64a7e489), TOBN(0xcc5675cd, 0xa0def5f2), + TOBN(0x9a00e785, 0x985d494e), TOBN(0xc626833f, 0x1b03514a)}}, + {{TOBN(0xabe7905a, 0x83cdd60e), TOBN(0x50602fb5, 0xa1170184), + TOBN(0x689886cd, 0xb023642a), TOBN(0xd568d090, 0xa6e1fb00)}, + {TOBN(0x5b1922c7, 0x0259217f), TOBN(0x93831cd9, 0xc43141e4), + TOBN(0xdfca3587, 0x0c95f86e), TOBN(0xdec2057a, 0x568ae828)}}, + {{TOBN(0xc44ea599, 0xf98a759a), TOBN(0x55a0a7a2, 0xf7c23c1d), + TOBN(0xd5ffb6e6, 0x94c4f687), TOBN(0x3563cce2, 0x12848478)}, + {TOBN(0x812b3517, 0xe7b1fbe1), TOBN(0x8a7dc979, 0x4f7338e0), + TOBN(0x211ecee9, 0x52d048db), TOBN(0x2eea4056, 0xc86ea3b8)}}, + {{TOBN(0xd8cb68a7, 0xba772b34), TOBN(0xe16ed341, 0x5f4e2541), + TOBN(0x9b32f6a6, 0x0fec14db), TOBN(0xeee376f7, 0x391698be)}, + {TOBN(0xe9a7aa17, 0x83674c02), TOBN(0x65832f97, 0x5843022a), + TOBN(0x29f3a8da, 0x5ba4990f), TOBN(0x79a59c3a, 0xfb8e3216)}}, + {{TOBN(0x9cdc4d2e, 0xbd19bb16), TOBN(0xc6c7cfd0, 0xb3262d86), + TOBN(0xd4ce14d0, 0x969c0b47), TOBN(0x1fa352b7, 0x13e56128)}, + {TOBN(0x383d55b8, 0x973db6d3), TOBN(0x71836850, 0xe8e5b7bf), + TOBN(0xc7714596, 0xe6bb571f), TOBN(0x259df31f, 0x2d5b2dd2)}}, + {{TOBN(0x568f8925, 0x913cc16d), TOBN(0x18bc5b6d, 0xe1a26f5a), + TOBN(0xdfa413be, 0xf5f499ae), TOBN(0xf8835dec, 0xc3f0ae84)}, + {TOBN(0xb6e60bd8, 0x65a40ab0), TOBN(0x65596439, 0x194b377e), + TOBN(0xbcd85625, 0x92084a69), TOBN(0x5ce433b9, 0x4f23ede0)}}, + {{TOBN(0xe8e8f04f, 0x6ad65143), TOBN(0x11511827, 0xd6e14af6), + TOBN(0x3d390a10, 0x8295c0c7), TOBN(0x71e29ee4, 0x621eba16)}, + {TOBN(0xa588fc09, 0x63717b46), TOBN(0x02be02fe, 0xe06ad4a2), + TOBN(0x931558c6, 0x04c22b22), TOBN(0xbb4d4bd6, 0x12f3c849)}}, + {{TOBN(0x54a4f496, 0x20efd662), TOBN(0x92ba6d20, 0xc5952d14), + TOBN(0x2db8ea1e, 0xcc9784c2), TOBN(0x81cc10ca, 0x4b353644)}, + {TOBN(0x40b570ad, 0x4b4d7f6c), TOBN(0x5c9f1d96, 0x84a1dcd2), + TOBN(0x01379f81, 0x3147e797), TOBN(0xe5c6097b, 0x2bd499f5)}}, + {{TOBN(0x40dcafa6, 0x328e5e20), TOBN(0xf7b5244a, 0x54815550), + TOBN(0xb9a4f118, 0x47bfc978), TOBN(0x0ea0e79f, 0xd25825b1)}, + {TOBN(0xa50f96eb, 0x646c7ecf), TOBN(0xeb811493, 0x446dea9d), + TOBN(0x2af04677, 0xdfabcf69), TOBN(0xbe3a068f, 0xc713f6e8)}}, + {{TOBN(0x860d523d, 0x42e06189), TOBN(0xbf077941, 0x4e3aff13), + TOBN(0x0b616dca, 0xc1b20650), TOBN(0xe66dd6d1, 0x2131300d)}, + {TOBN(0xd4a0fd67, 0xff99abde), TOBN(0xc9903550, 0xc7aac50d), + TOBN(0x022ecf8b, 0x7c46b2d7), TOBN(0x3333b1e8, 0x3abf92af)}}, + {{TOBN(0x11cc113c, 0x6c491c14), TOBN(0x05976688, 0x80dd3f88), + TOBN(0xf5b4d9e7, 0x29d932ed), TOBN(0xe982aad8, 0xa2c38b6d)}, + {TOBN(0x6f925347, 0x8be0dcf0), TOBN(0x700080ae, 0x65ca53f2), + TOBN(0xd8131156, 0x443ca77f), TOBN(0xe92d6942, 0xec51f984)}}, + {{TOBN(0xd2a08af8, 0x85dfe9ae), TOBN(0xd825d9a5, 0x4d2a86ca), + TOBN(0x2c53988d, 0x39dff020), TOBN(0xf38b135a, 0x430cdc40)}, + {TOBN(0x0c918ae0, 0x62a7150b), TOBN(0xf31fd8de, 0x0c340e9b), + TOBN(0xafa0e7ae, 0x4dbbf02e), TOBN(0x5847fb2a, 0x5eba6239)}}, + {{TOBN(0x6b1647dc, 0xdccbac8b), TOBN(0xb642aa78, 0x06f485c8), + TOBN(0x873f3765, 0x7038ecdf), TOBN(0x2ce5e865, 0xfa49d3fe)}, + {TOBN(0xea223788, 0xc98c4400), TOBN(0x8104a8cd, 0xf1fa5279), + TOBN(0xbcf7cc7a, 0x06becfd7), TOBN(0x49424316, 0xc8f974ae)}}, + {{TOBN(0xc0da65e7, 0x84d6365d), TOBN(0xbcb7443f, 0x8f759fb8), + TOBN(0x35c712b1, 0x7ae81930), TOBN(0x80428dff, 0x4c6e08ab)}, + {TOBN(0xf19dafef, 0xa4faf843), TOBN(0xced8538d, 0xffa9855f), + TOBN(0x20ac409c, 0xbe3ac7ce), TOBN(0x358c1fb6, 0x882da71e)}}, + {{TOBN(0xafa9c0e5, 0xfd349961), TOBN(0x2b2cfa51, 0x8421c2fc), + TOBN(0x2a80db17, 0xf3a28d38), TOBN(0xa8aba539, 0x5d138e7e)}, + {TOBN(0x52012d1d, 0x6e96eb8d), TOBN(0x65d8dea0, 0xcbaf9622), + TOBN(0x57735447, 0xb264f56c), TOBN(0xbeebef3f, 0x1b6c8da2)}}, + {{TOBN(0xfc346d98, 0xce785254), TOBN(0xd50e8d72, 0xbb64a161), + TOBN(0xc03567c7, 0x49794add), TOBN(0x15a76065, 0x752c7ef6)}, + {TOBN(0x59f3a222, 0x961f23d6), TOBN(0x378e4438, 0x73ecc0b0), + TOBN(0xc74be434, 0x5a82fde4), TOBN(0xae509af2, 0xd8b9cf34)}}, + {{TOBN(0x4a61ee46, 0x577f44a1), TOBN(0xe09b748c, 0xb611deeb), + TOBN(0xc0481b2c, 0xf5f7b884), TOBN(0x35626678, 0x61acfa6b)}, + {TOBN(0x37f4c518, 0xbf8d21e6), TOBN(0x22d96531, 0xb205a76d), + TOBN(0x37fb85e1, 0x954073c0), TOBN(0xbceafe4f, 0x65b3a567)}}, + {{TOBN(0xefecdef7, 0xbe42a582), TOBN(0xd3fc6080, 0x65046be6), + TOBN(0xc9af13c8, 0x09e8dba9), TOBN(0x1e6c9847, 0x641491ff)}, + {TOBN(0x3b574925, 0xd30c31f7), TOBN(0xb7eb72ba, 0xac2a2122), + TOBN(0x776a0dac, 0xef0859e7), TOBN(0x06fec314, 0x21900942)}}, + {{TOBN(0x2464bc10, 0xf8c22049), TOBN(0x9bfbcce7, 0x875ebf69), + TOBN(0xd7a88e2a, 0x4336326b), TOBN(0xda05261c, 0x5bc2acfa)}, + {TOBN(0xc29f5bdc, 0xeba7efc8), TOBN(0x471237ca, 0x25dbbf2e), + TOBN(0xa72773f2, 0x2975f127), TOBN(0xdc744e8e, 0x04d0b326)}}, + {{TOBN(0x38a7ed16, 0xa56edb73), TOBN(0x64357e37, 0x2c007e70), + TOBN(0xa167d15b, 0x5080b400), TOBN(0x07b41164, 0x23de4be1)}, + {TOBN(0xb2d91e32, 0x74c89883), TOBN(0x3c162821, 0x2882e7ed), + TOBN(0xad6b36ba, 0x7503e482), TOBN(0x48434e8e, 0x0ea34331)}}, + {{TOBN(0x79f4f24f, 0x2c7ae0b9), TOBN(0xc46fbf81, 0x1939b44a), + TOBN(0x76fefae8, 0x56595eb1), TOBN(0x417b66ab, 0xcd5f29c7)}, + {TOBN(0x5f2332b2, 0xc5ceec20), TOBN(0xd69661ff, 0xe1a1cae2), + TOBN(0x5ede7e52, 0x9b0286e6), TOBN(0x9d062529, 0xe276b993)}}, + {{TOBN(0x324794b0, 0x7e50122b), TOBN(0xdd744f8b, 0x4af07ca5), + TOBN(0x30a12f08, 0xd63fc97b), TOBN(0x39650f1a, 0x76626d9d)}, + {TOBN(0x101b47f7, 0x1fa38477), TOBN(0x3d815f19, 0xd4dc124f), + TOBN(0x1569ae95, 0xb26eb58a), TOBN(0xc3cde188, 0x95fb1887)}}, + {{TOBN(0x54e9f37b, 0xf9539a48), TOBN(0xb0100e06, 0x7408c1a5), + TOBN(0x821d9811, 0xea580cbb), TOBN(0x8af52d35, 0x86e50c56)}, + {TOBN(0xdfbd9d47, 0xdbbf698b), TOBN(0x2961a1ea, 0x03dc1c73), + TOBN(0x203d38f8, 0xe76a5df8), TOBN(0x08a53a68, 0x6def707a)}}, + {{TOBN(0x26eefb48, 0x1bee45d4), TOBN(0xb3cee346, 0x3c688036), + TOBN(0x463c5315, 0xc42f2469), TOBN(0x19d84d2e, 0x81378162)}, + {TOBN(0x22d7c3c5, 0x1c4d349f), TOBN(0x65965844, 0x163d59c5), + TOBN(0xcf198c56, 0xb8abceae), TOBN(0x6fb1fb1b, 0x628559d5)}}, + {{TOBN(0x8bbffd06, 0x07bf8fe3), TOBN(0x46259c58, 0x3467734b), + TOBN(0xd8953cea, 0x35f7f0d3), TOBN(0x1f0bece2, 0xd65b0ff1)}, + {TOBN(0xf7d5b4b3, 0xf3c72914), TOBN(0x29e8ea95, 0x3cb53389), + TOBN(0x4a365626, 0x836b6d46), TOBN(0xe849f910, 0xea174fde)}}, + {{TOBN(0x7ec62fbb, 0xf4737f21), TOBN(0xd8dba5ab, 0x6209f5ac), + TOBN(0x24b5d7a9, 0xa5f9adbe), TOBN(0x707d28f7, 0xa61dc768)}, + {TOBN(0x7711460b, 0xcaa999ea), TOBN(0xba7b174d, 0x1c92e4cc), + TOBN(0x3c4bab66, 0x18d4bf2d), TOBN(0xb8f0c980, 0xeb8bd279)}}, + {{TOBN(0x024bea9a, 0x324b4737), TOBN(0xfba9e423, 0x32a83bca), + TOBN(0x6e635643, 0xa232dced), TOBN(0x99619367, 0x2571c8ba)}, + {TOBN(0xe8c9f357, 0x54b7032b), TOBN(0xf936b3ba, 0x2442d54a), + TOBN(0x2263f0f0, 0x8290c65a), TOBN(0x48989780, 0xee2c7fdb)}}, + {{TOBN(0xadc5d55a, 0x13d4f95e), TOBN(0x737cff85, 0xad9b8500), + TOBN(0x271c557b, 0x8a73f43d), TOBN(0xbed617a4, 0xe18bc476)}, + {TOBN(0x66245401, 0x7dfd8ab2), TOBN(0xae7b89ae, 0x3a2870aa), + TOBN(0x1b555f53, 0x23a7e545), TOBN(0x6791e247, 0xbe057e4c)}}, + {{TOBN(0x860136ad, 0x324fa34d), TOBN(0xea111447, 0x4cbeae28), + TOBN(0x023a4270, 0xbedd3299), TOBN(0x3d5c3a7f, 0xc1c35c34)}, + {TOBN(0xb0f6db67, 0x8d0412d2), TOBN(0xd92625e2, 0xfcdc6b9a), + TOBN(0x92ae5ccc, 0x4e28a982), TOBN(0xea251c36, 0x47a3ce7e)}}, + {{TOBN(0x9d658932, 0x790691bf), TOBN(0xed610589, 0x06b736ae), + TOBN(0x712c2f04, 0xc0d63b6e), TOBN(0x5cf06fd5, 0xc63d488f)}, + {TOBN(0x97363fac, 0xd9588e41), TOBN(0x1f9bf762, 0x2b93257e), + TOBN(0xa9d1ffc4, 0x667acace), TOBN(0x1cf4a1aa, 0x0a061ecf)}}, + {{TOBN(0x40e48a49, 0xdc1818d0), TOBN(0x0643ff39, 0xa3621ab0), + TOBN(0x5768640c, 0xe39ef639), TOBN(0x1fc099ea, 0x04d86854)}, + {TOBN(0x9130b9c3, 0xeccd28fd), TOBN(0xd743cbd2, 0x7eec54ab), + TOBN(0x052b146f, 0xe5b475b6), TOBN(0x058d9a82, 0x900a7d1f)}}, + {{TOBN(0x65e02292, 0x91262b72), TOBN(0x96f924f9, 0xbb0edf03), + TOBN(0x5cfa59c8, 0xfe206842), TOBN(0xf6037004, 0x5eafa720)}, + {TOBN(0x5f30699e, 0x18d7dd96), TOBN(0x381e8782, 0xcbab2495), + TOBN(0x91669b46, 0xdd8be949), TOBN(0xb40606f5, 0x26aae8ef)}}, + {{TOBN(0x2812b839, 0xfc6751a4), TOBN(0x16196214, 0xfba800ef), + TOBN(0x4398d5ca, 0x4c1a2875), TOBN(0x720c00ee, 0x653d8349)}, + {TOBN(0xc2699eb0, 0xd820007c), TOBN(0x880ee660, 0xa39b5825), + TOBN(0x70694694, 0x471f6984), TOBN(0xf7d16ea8, 0xe3dda99a)}}, + {{TOBN(0x28d675b2, 0xc0519a23), TOBN(0x9ebf94fe, 0x4f6952e3), + TOBN(0xf28bb767, 0xa2294a8a), TOBN(0x85512b4d, 0xfe0af3f5)}, + {TOBN(0x18958ba8, 0x99b16a0d), TOBN(0x95c2430c, 0xba7548a7), + TOBN(0xb30d1b10, 0xa16be615), TOBN(0xe3ebbb97, 0x85bfb74c)}}, + {{TOBN(0xa3273cfe, 0x18549fdb), TOBN(0xf6e200bf, 0x4fcdb792), + TOBN(0x54a76e18, 0x83aba56c), TOBN(0x73ec66f6, 0x89ef6aa2)}, + {TOBN(0x8d17add7, 0xd1b9a305), TOBN(0xa959c5b9, 0xb7ae1b9d), + TOBN(0x88643522, 0x6bcc094a), TOBN(0xcc5616c4, 0xd7d429b9)}}, + {{TOBN(0xa6dada01, 0xe6a33f7c), TOBN(0xc6217a07, 0x9d4e70ad), + TOBN(0xd619a818, 0x09c15b7c), TOBN(0xea06b329, 0x0e80c854)}, + {TOBN(0x174811ce, 0xa5f5e7b9), TOBN(0x66dfc310, 0x787c65f4), + TOBN(0x4ea7bd69, 0x3316ab54), TOBN(0xc12c4acb, 0x1dcc0f70)}}, + {{TOBN(0xe4308d1a, 0x1e407dd9), TOBN(0xe8a3587c, 0x91afa997), + TOBN(0xea296c12, 0xab77b7a5), TOBN(0xb5ad49e4, 0x673c0d52)}, + {TOBN(0x40f9b2b2, 0x7006085a), TOBN(0xa88ff340, 0x87bf6ec2), + TOBN(0x978603b1, 0x4e3066a6), TOBN(0xb3f99fc2, 0xb5e486e2)}}, + {{TOBN(0x07b53f5e, 0xb2e63645), TOBN(0xbe57e547, 0x84c84232), + TOBN(0xd779c216, 0x7214d5cf), TOBN(0x617969cd, 0x029a3aca)}, + {TOBN(0xd17668cd, 0x8a7017a0), TOBN(0x77b4d19a, 0xbe9b7ee8), + TOBN(0x58fd0e93, 0x9c161776), TOBN(0xa8c4f4ef, 0xd5968a72)}}, + {{TOBN(0x296071cc, 0x67b3de77), TOBN(0xae3c0b8e, 0x634f7905), + TOBN(0x67e440c2, 0x8a7100c9), TOBN(0xbb8c3c1b, 0xeb4b9b42)}, + {TOBN(0x6d71e8ea, 0xc51b3583), TOBN(0x7591f5af, 0x9525e642), + TOBN(0xf73a2f7b, 0x13f509f3), TOBN(0x618487aa, 0x5619ac9b)}}, + {{TOBN(0x3a72e5f7, 0x9d61718a), TOBN(0x00413bcc, 0x7592d28c), + TOBN(0x7d9b11d3, 0x963c35cf), TOBN(0x77623bcf, 0xb90a46ed)}, + {TOBN(0xdeef273b, 0xdcdd2a50), TOBN(0x4a741f9b, 0x0601846e), + TOBN(0x33b89e51, 0x0ec6e929), TOBN(0xcb02319f, 0x8b7f22cd)}}, + {{TOBN(0xbbe1500d, 0x084bae24), TOBN(0x2f0ae8d7, 0x343d2693), + TOBN(0xacffb5f2, 0x7cdef811), TOBN(0xaa0c030a, 0x263fb94f)}, + {TOBN(0x6eef0d61, 0xa0f442de), TOBN(0xf92e1817, 0x27b139d3), + TOBN(0x1ae6deb7, 0x0ad8bc28), TOBN(0xa89e38dc, 0xc0514130)}}, + {{TOBN(0x81eeb865, 0xd2fdca23), TOBN(0x5a15ee08, 0xcc8ef895), + TOBN(0x768fa10a, 0x01905614), TOBN(0xeff5b8ef, 0x880ee19b)}, + {TOBN(0xf0c0cabb, 0xcb1c8a0e), TOBN(0x2e1ee9cd, 0xb8c838f9), + TOBN(0x0587d8b8, 0x8a4a14c0), TOBN(0xf6f27896, 0x2ff698e5)}}, + {{TOBN(0xed38ef1c, 0x89ee6256), TOBN(0xf44ee1fe, 0x6b353b45), + TOBN(0x9115c0c7, 0x70e903b3), TOBN(0xc78ec0a1, 0x818f31df)}, + {TOBN(0x6c003324, 0xb7dccbc6), TOBN(0xd96dd1f3, 0x163bbc25), + TOBN(0x33aa82dd, 0x5cedd805), TOBN(0x123aae4f, 0x7f7eb2f1)}}, + {{TOBN(0x1723fcf5, 0xa26262cd), TOBN(0x1f7f4d5d, 0x0060ebd5), + TOBN(0xf19c5c01, 0xb2eaa3af), TOBN(0x2ccb9b14, 0x9790accf)}, + {TOBN(0x1f9c1cad, 0x52324aa6), TOBN(0x63200526, 0x7247df54), + TOBN(0x5732fe42, 0xbac96f82), TOBN(0x52fe771f, 0x01a1c384)}}, + {{TOBN(0x546ca13d, 0xb1001684), TOBN(0xb56b4eee, 0xa1709f75), + TOBN(0x266545a9, 0xd5db8672), TOBN(0xed971c90, 0x1e8f3cfb)}, + {TOBN(0x4e7d8691, 0xe3a07b29), TOBN(0x7570d9ec, 0xe4b696b9), + TOBN(0xdc5fa067, 0x7bc7e9ae), TOBN(0x68b44caf, 0xc82c4844)}}, + {{TOBN(0x519d34b3, 0xbf44da80), TOBN(0x283834f9, 0x5ab32e66), + TOBN(0x6e608797, 0x6278a000), TOBN(0x1e62960e, 0x627312f6)}, + {TOBN(0x9b87b27b, 0xe6901c55), TOBN(0x80e78538, 0x24fdbc1f), + TOBN(0xbbbc0951, 0x2facc27d), TOBN(0x06394239, 0xac143b5a)}}, + {{TOBN(0x35bb4a40, 0x376c1944), TOBN(0x7cb62694, 0x63da1511), + TOBN(0xafd29161, 0xb7148a3b), TOBN(0xa6f9d9ed, 0x4e2ea2ee)}, + {TOBN(0x15dc2ca2, 0x880dd212), TOBN(0x903c3813, 0xa61139a9), + TOBN(0x2aa7b46d, 0x6c0f8785), TOBN(0x36ce2871, 0x901c60ff)}}, + {{TOBN(0xc683b028, 0xe10d9c12), TOBN(0x7573baa2, 0x032f33d3), + TOBN(0x87a9b1f6, 0x67a31b58), TOBN(0xfd3ed11a, 0xf4ffae12)}, + {TOBN(0x83dcaa9a, 0x0cb2748e), TOBN(0x8239f018, 0x5d6fdf16), + TOBN(0xba67b49c, 0x72753941), TOBN(0x2beec455, 0xc321cb36)}}, + {{TOBN(0x88015606, 0x3f8b84ce), TOBN(0x76417083, 0x8d38c86f), + TOBN(0x054f1ca7, 0x598953dd), TOBN(0xc939e110, 0x4e8e7429)}, + {TOBN(0x9b1ac2b3, 0x5a914f2f), TOBN(0x39e35ed3, 0xe74b8f9c), + TOBN(0xd0debdb2, 0x781b2fb0), TOBN(0x1585638f, 0x2d997ba2)}}, + {{TOBN(0x9c4b646e, 0x9e2fce99), TOBN(0x68a21081, 0x1e80857f), + TOBN(0x06d54e44, 0x3643b52a), TOBN(0xde8d6d63, 0x0d8eb843)}, + {TOBN(0x70321563, 0x42146a0a), TOBN(0x8ba826f2, 0x5eaa3622), + TOBN(0x227a58bd, 0x86138787), TOBN(0x43b6c03c, 0x10281d37)}}, + {{TOBN(0x6326afbb, 0xb54dde39), TOBN(0x744e5e8a, 0xdb6f2d5f), + TOBN(0x48b2a99a, 0xcff158e1), TOBN(0xa93c8fa0, 0xef87918f)}, + {TOBN(0x2182f956, 0xde058c5c), TOBN(0x216235d2, 0x936f9e7a), + TOBN(0xace0c0db, 0xd2e31e67), TOBN(0xc96449bf, 0xf23ac3e7)}}, + {{TOBN(0x7e9a2874, 0x170693bd), TOBN(0xa28e14fd, 0xa45e6335), + TOBN(0x5757f6b3, 0x56427344), TOBN(0x822e4556, 0xacf8edf9)}, + {TOBN(0x2b7a6ee2, 0xe6a285cd), TOBN(0x5866f211, 0xa9df3af0), + TOBN(0x40dde2dd, 0xf845b844), TOBN(0x986c3726, 0x110e5e49)}}, + {{TOBN(0x73680c2a, 0xf7172277), TOBN(0x57b94f0f, 0x0cccb244), + TOBN(0xbdff7267, 0x2d438ca7), TOBN(0xbad1ce11, 0xcf4663fd)}, + {TOBN(0x9813ed9d, 0xd8f71cae), TOBN(0xf43272a6, 0x961fdaa6), + TOBN(0xbeff0119, 0xbd6d1637), TOBN(0xfebc4f91, 0x30361978)}}, + {{TOBN(0x02b37a95, 0x2f41deff), TOBN(0x0e44a59a, 0xe63b89b7), + TOBN(0x673257dc, 0x143ff951), TOBN(0x19c02205, 0xd752baf4)}, + {TOBN(0x46c23069, 0xc4b7d692), TOBN(0x2e6392c3, 0xfd1502ac), + TOBN(0x6057b1a2, 0x1b220846), TOBN(0xe51ff946, 0x0c1b5b63)}}}, + {{{TOBN(0x6e85cb51, 0x566c5c43), TOBN(0xcff9c919, 0x3597f046), + TOBN(0x9354e90c, 0x4994d94a), TOBN(0xe0a39332, 0x2147927d)}, + {TOBN(0x8427fac1, 0x0dc1eb2b), TOBN(0x88cfd8c2, 0x2ff319fa), + TOBN(0xe2d4e684, 0x01965274), TOBN(0xfa2e067d, 0x67aaa746)}}, + {{TOBN(0xb6d92a7f, 0x3e5f9f11), TOBN(0x9afe153a, 0xd6cb3b8e), + TOBN(0x4d1a6dd7, 0xddf800bd), TOBN(0xf6c13cc0, 0xcaf17e19)}, + {TOBN(0x15f6c58e, 0x325fc3ee), TOBN(0x71095400, 0xa31dc3b2), + TOBN(0x168e7c07, 0xafa3d3e7), TOBN(0x3f8417a1, 0x94c7ae2d)}}, + {{TOBN(0xec234772, 0x813b230d), TOBN(0x634d0f5f, 0x17344427), + TOBN(0x11548ab1, 0xd77fc56a), TOBN(0x7fab1750, 0xce06af77)}, + {TOBN(0xb62c10a7, 0x4f7c4f83), TOBN(0xa7d2edc4, 0x220a67d9), + TOBN(0x1c404170, 0x921209a0), TOBN(0x0b9815a0, 0xface59f0)}}, + {{TOBN(0x2842589b, 0x319540c3), TOBN(0x18490f59, 0xa283d6f8), + TOBN(0xa2731f84, 0xdaae9fcb), TOBN(0x3db6d960, 0xc3683ba0)}, + {TOBN(0xc85c63bb, 0x14611069), TOBN(0xb19436af, 0x0788bf05), + TOBN(0x905459df, 0x347460d2), TOBN(0x73f6e094, 0xe11a7db1)}}, + {{TOBN(0xdc7f938e, 0xb6357f37), TOBN(0xc5d00f79, 0x2bd8aa62), + TOBN(0xc878dcb9, 0x2ca979fc), TOBN(0x37e83ed9, 0xeb023a99)}, + {TOBN(0x6b23e273, 0x1560bf3d), TOBN(0x1086e459, 0x1d0fae61), + TOBN(0x78248316, 0x9a9414bd), TOBN(0x1b956bc0, 0xf0ea9ea1)}}, + {{TOBN(0x7b85bb91, 0xc31b9c38), TOBN(0x0c5aa90b, 0x48ef57b5), + TOBN(0xdedeb169, 0xaf3bab6f), TOBN(0xe610ad73, 0x2d373685)}, + {TOBN(0xf13870df, 0x02ba8e15), TOBN(0x0337edb6, 0x8ca7f771), + TOBN(0xe4acf747, 0xb62c036c), TOBN(0xd921d576, 0xb6b94e81)}}, + {{TOBN(0xdbc86439, 0x2c422f7a), TOBN(0xfb635362, 0xed348898), + TOBN(0x83084668, 0xc45bfcd1), TOBN(0xc357c9e3, 0x2b315e11)}, + {TOBN(0xb173b540, 0x5b2e5b8c), TOBN(0x7e946931, 0xe102b9a4), + TOBN(0x17c890eb, 0x7b0fb199), TOBN(0xec225a83, 0xd61b662b)}}, + {{TOBN(0xf306a3c8, 0xee3c76cb), TOBN(0x3cf11623, 0xd32a1f6e), + TOBN(0xe6d5ab64, 0x6863e956), TOBN(0x3b8a4cbe, 0x5c005c26)}, + {TOBN(0xdcd529a5, 0x9ce6bb27), TOBN(0xc4afaa52, 0x04d4b16f), + TOBN(0xb0624a26, 0x7923798d), TOBN(0x85e56df6, 0x6b307fab)}}, + {{TOBN(0x0281893c, 0x2bf29698), TOBN(0x91fc19a4, 0xd7ce7603), + TOBN(0x75a5dca3, 0xad9a558f), TOBN(0x40ceb3fa, 0x4d50bf77)}, + {TOBN(0x1baf6060, 0xbc9ba369), TOBN(0x927e1037, 0x597888c2), + TOBN(0xd936bf19, 0x86a34c07), TOBN(0xd4cf10c1, 0xc34ae980)}}, + {{TOBN(0x3a3e5334, 0x859dd614), TOBN(0x9c475b5b, 0x18d0c8ee), + TOBN(0x63080d1f, 0x07cd51d5), TOBN(0xc9c0d0a6, 0xb88b4326)}, + {TOBN(0x1ac98691, 0xc234296f), TOBN(0x2a0a83a4, 0x94887fb6), + TOBN(0x56511427, 0x0cea9cf2), TOBN(0x5230a6e8, 0xa24802f5)}}, + {{TOBN(0xf7a2bf0f, 0x72e3d5c1), TOBN(0x37717446, 0x4f21439e), + TOBN(0xfedcbf25, 0x9ce30334), TOBN(0xe0030a78, 0x7ce202f9)}, + {TOBN(0x6f2d9ebf, 0x1202e9ca), TOBN(0xe79dde6c, 0x75e6e591), + TOBN(0xf52072af, 0xf1dac4f8), TOBN(0x6c8d087e, 0xbb9b404d)}}, + {{TOBN(0xad0fc73d, 0xbce913af), TOBN(0x909e587b, 0x458a07cb), + TOBN(0x1300da84, 0xd4f00c8a), TOBN(0x425cd048, 0xb54466ac)}, + {TOBN(0xb59cb9be, 0x90e9d8bf), TOBN(0x991616db, 0x3e431b0e), + TOBN(0xd3aa117a, 0x531aecff), TOBN(0x91af92d3, 0x59f4dc3b)}}, + {{TOBN(0x9b1ec292, 0xe93fda29), TOBN(0x76bb6c17, 0xe97d91bc), + TOBN(0x7509d95f, 0xaface1e6), TOBN(0x3653fe47, 0xbe855ae3)}, + {TOBN(0x73180b28, 0x0f680e75), TOBN(0x75eefd1b, 0xeeb6c26c), + TOBN(0xa4cdf29f, 0xb66d4236), TOBN(0x2d70a997, 0x6b5821d8)}}, + {{TOBN(0x7a3ee207, 0x20445c36), TOBN(0x71d1ac82, 0x59877174), + TOBN(0x0fc539f7, 0x949f73e9), TOBN(0xd05cf3d7, 0x982e3081)}, + {TOBN(0x8758e20b, 0x7b1c7129), TOBN(0xffadcc20, 0x569e61f2), + TOBN(0xb05d3a2f, 0x59544c2d), TOBN(0xbe16f5c1, 0x9fff5e53)}}, + {{TOBN(0x73cf65b8, 0xaad58135), TOBN(0x622c2119, 0x037aa5be), + TOBN(0x79373b3f, 0x646fd6a0), TOBN(0x0e029db5, 0x0d3978cf)}, + {TOBN(0x8bdfc437, 0x94fba037), TOBN(0xaefbd687, 0x620797a6), + TOBN(0x3fa5382b, 0xbd30d38e), TOBN(0x7627cfbf, 0x585d7464)}}, + {{TOBN(0xb2330fef, 0x4e4ca463), TOBN(0xbcef7287, 0x3566cc63), + TOBN(0xd161d2ca, 0xcf780900), TOBN(0x135dc539, 0x5b54827d)}, + {TOBN(0x638f052e, 0x27bf1bc6), TOBN(0x10a224f0, 0x07dfa06c), + TOBN(0xe973586d, 0x6d3321da), TOBN(0x8b0c5738, 0x26152c8f)}}, + {{TOBN(0x07ef4f2a, 0x34606074), TOBN(0x80fe7fe8, 0xa0f7047a), + TOBN(0x3d1a8152, 0xe1a0e306), TOBN(0x32cf43d8, 0x88da5222)}, + {TOBN(0xbf89a95f, 0x5f02ffe6), TOBN(0x3d9eb9a4, 0x806ad3ea), + TOBN(0x012c17bb, 0x79c8e55e), TOBN(0xfdcd1a74, 0x99c81dac)}}, + {{TOBN(0x7043178b, 0xb9556098), TOBN(0x4090a1df, 0x801c3886), + TOBN(0x759800ff, 0x9b67b912), TOBN(0x3e5c0304, 0x232620c8)}, + {TOBN(0x4b9d3c4b, 0x70dceeca), TOBN(0xbb2d3c15, 0x181f648e), + TOBN(0xf981d837, 0x6e33345c), TOBN(0xb626289b, 0x0cf2297a)}}, + {{TOBN(0x766ac659, 0x8baebdcf), TOBN(0x1a28ae09, 0x75df01e5), + TOBN(0xb71283da, 0x375876d8), TOBN(0x4865a96d, 0x607b9800)}, + {TOBN(0x25dd1bcd, 0x237936b2), TOBN(0x332f4f4b, 0x60417494), + TOBN(0xd0923d68, 0x370a2147), TOBN(0x497f5dfb, 0xdc842203)}}, + {{TOBN(0x9dc74cbd, 0x32be5e0f), TOBN(0x7475bcb7, 0x17a01375), + TOBN(0x438477c9, 0x50d872b1), TOBN(0xcec67879, 0xffe1d63d)}, + {TOBN(0x9b006014, 0xd8578c70), TOBN(0xc9ad99a8, 0x78bb6b8b), + TOBN(0x6799008e, 0x11fb3806), TOBN(0xcfe81435, 0xcd44cab3)}}, + {{TOBN(0xa2ee1582, 0x2f4fb344), TOBN(0xb8823450, 0x483fa6eb), + TOBN(0x622d323d, 0x652c7749), TOBN(0xd8474a98, 0xbeb0a15b)}, + {TOBN(0xe43c154d, 0x5d1c00d0), TOBN(0x7fd581d9, 0x0e3e7aac), + TOBN(0x2b44c619, 0x2525ddf8), TOBN(0x67a033eb, 0xb8ae9739)}}, + {{TOBN(0x113ffec1, 0x9ef2d2e4), TOBN(0x1bf6767e, 0xd5a0ea7f), + TOBN(0x57fff75e, 0x03714c0a), TOBN(0xa23c422e, 0x0a23e9ee)}, + {TOBN(0xdd5f6b2d, 0x540f83af), TOBN(0xc2c2c27e, 0x55ea46a7), + TOBN(0xeb6b4246, 0x672a1208), TOBN(0xd13599f7, 0xae634f7a)}}, + {{TOBN(0xcf914b5c, 0xd7b32c6e), TOBN(0x61a5a640, 0xeaf61814), + TOBN(0x8dc3df8b, 0x208a1bbb), TOBN(0xef627fd6, 0xb6d79aa5)}, + {TOBN(0x44232ffc, 0xc4c86bc8), TOBN(0xe6f9231b, 0x061539fe), + TOBN(0x1d04f25a, 0x958b9533), TOBN(0x180cf934, 0x49e8c885)}}, + {{TOBN(0x89689595, 0x9884aaf7), TOBN(0xb1959be3, 0x07b348a6), + TOBN(0x96250e57, 0x3c147c87), TOBN(0xae0efb3a, 0xdd0c61f8)}, + {TOBN(0xed00745e, 0xca8c325e), TOBN(0x3c911696, 0xecff3f70), + TOBN(0x73acbc65, 0x319ad41d), TOBN(0x7b01a020, 0xf0b1c7ef)}}, + {{TOBN(0xea32b293, 0x63a1483f), TOBN(0x89eabe71, 0x7a248f96), + TOBN(0x9c6231d3, 0x343157e5), TOBN(0x93a375e5, 0xdf3c546d)}, + {TOBN(0xe76e9343, 0x6a2afe69), TOBN(0xc4f89100, 0xe166c88e), + TOBN(0x248efd0d, 0x4f872093), TOBN(0xae0eb3ea, 0x8fe0ea61)}}, + {{TOBN(0xaf89790d, 0x9d79046e), TOBN(0x4d650f2d, 0x6cee0976), + TOBN(0xa3935d9a, 0x43071eca), TOBN(0x66fcd2c9, 0x283b0bfe)}, + {TOBN(0x0e665eb5, 0x696605f1), TOBN(0xe77e5d07, 0xa54cd38d), + TOBN(0x90ee050a, 0x43d950cf), TOBN(0x86ddebda, 0xd32e69b5)}}, + {{TOBN(0x6ad94a3d, 0xfddf7415), TOBN(0xf7fa1309, 0x3f6e8d5a), + TOBN(0xc4831d1d, 0xe9957f75), TOBN(0x7de28501, 0xd5817447)}, + {TOBN(0x6f1d7078, 0x9e2aeb6b), TOBN(0xba2b9ff4, 0xf67a53c2), + TOBN(0x36963767, 0xdf9defc3), TOBN(0x479deed3, 0x0d38022c)}}, + {{TOBN(0xd2edb89b, 0x3a8631e8), TOBN(0x8de855de, 0x7a213746), + TOBN(0xb2056cb7, 0xb00c5f11), TOBN(0xdeaefbd0, 0x2c9b85e4)}, + {TOBN(0x03f39a8d, 0xd150892d), TOBN(0x37b84686, 0x218b7985), + TOBN(0x36296dd8, 0xb7375f1a), TOBN(0x472cd4b1, 0xb78e898e)}}, + {{TOBN(0x15dff651, 0xe9f05de9), TOBN(0xd4045069, 0x2ce98ba9), + TOBN(0x8466a7ae, 0x9b38024c), TOBN(0xb910e700, 0xe5a6b5ef)}, + {TOBN(0xae1c56ea, 0xb3aa8f0d), TOBN(0xbab2a507, 0x7eee74a6), + TOBN(0x0dca11e2, 0x4b4c4620), TOBN(0xfd896e2e, 0x4c47d1f4)}}, + {{TOBN(0xeb45ae53, 0x308fbd93), TOBN(0x46cd5a2e, 0x02c36fda), + TOBN(0x6a3d4e90, 0xbaa48385), TOBN(0xdd55e62e, 0x9dbe9960)}, + {TOBN(0xa1406aa0, 0x2a81ede7), TOBN(0x6860dd14, 0xf9274ea7), + TOBN(0xcfdcb0c2, 0x80414f86), TOBN(0xff410b10, 0x22f94327)}}, + {{TOBN(0x5a33cc38, 0x49ad467b), TOBN(0xefb48b6c, 0x0a7335f1), + TOBN(0x14fb54a4, 0xb153a360), TOBN(0x604aa9d2, 0xb52469cc)}, + {TOBN(0x5e9dc486, 0x754e48e9), TOBN(0x693cb455, 0x37471e8e), + TOBN(0xfb2fd7cd, 0x8d3b37b6), TOBN(0x63345e16, 0xcf09ff07)}}, + {{TOBN(0x9910ba6b, 0x23a5d896), TOBN(0x1fe19e35, 0x7fe4364e), + TOBN(0x6e1da8c3, 0x9a33c677), TOBN(0x15b4488b, 0x29fd9fd0)}, + {TOBN(0x1f439254, 0x1a1f22bf), TOBN(0x920a8a70, 0xab8163e8), + TOBN(0x3fd1b249, 0x07e5658e), TOBN(0xf2c4f79c, 0xb6ec839b)}}, + {{TOBN(0x1abbc3d0, 0x4aa38d1b), TOBN(0x3b0db35c, 0xb5d9510e), + TOBN(0x1754ac78, 0x3e60dec0), TOBN(0x53272fd7, 0xea099b33)}, + {TOBN(0x5fb0494f, 0x07a8e107), TOBN(0x4a89e137, 0x6a8191fa), + TOBN(0xa113b7f6, 0x3c4ad544), TOBN(0x88a2e909, 0x6cb9897b)}}, + {{TOBN(0x17d55de3, 0xb44a3f84), TOBN(0xacb2f344, 0x17c6c690), + TOBN(0x32088168, 0x10232390), TOBN(0xf2e8a61f, 0x6c733bf7)}, + {TOBN(0xa774aab6, 0x9c2d7652), TOBN(0xfb5307e3, 0xed95c5bc), + TOBN(0xa05c73c2, 0x4981f110), TOBN(0x1baae31c, 0xa39458c9)}}, + {{TOBN(0x1def185b, 0xcbea62e7), TOBN(0xe8ac9eae, 0xeaf63059), + TOBN(0x098a8cfd, 0x9921851c), TOBN(0xd959c3f1, 0x3abe2f5b)}, + {TOBN(0xa4f19525, 0x20e40ae5), TOBN(0x320789e3, 0x07a24aa1), + TOBN(0x259e6927, 0x7392b2bc), TOBN(0x58f6c667, 0x1918668b)}}, + {{TOBN(0xce1db2bb, 0xc55d2d8b), TOBN(0x41d58bb7, 0xf4f6ca56), + TOBN(0x7650b680, 0x8f877614), TOBN(0x905e16ba, 0xf4c349ed)}, + {TOBN(0xed415140, 0xf661acac), TOBN(0x3b8784f0, 0xcb2270af), + TOBN(0x3bc280ac, 0x8a402cba), TOBN(0xd53f7146, 0x0937921a)}}, + {{TOBN(0xc03c8ee5, 0xe5681e83), TOBN(0x62126105, 0xf6ac9e4a), + TOBN(0x9503a53f, 0x936b1a38), TOBN(0x3d45e2d4, 0x782fecbd)}, + {TOBN(0x69a5c439, 0x76e8ae98), TOBN(0xb53b2eeb, 0xbfb4b00e), + TOBN(0xf1674712, 0x72386c89), TOBN(0x30ca34a2, 0x4268bce4)}}, + {{TOBN(0x7f1ed86c, 0x78341730), TOBN(0x8ef5beb8, 0xb525e248), + TOBN(0xbbc489fd, 0xb74fbf38), TOBN(0x38a92a0e, 0x91a0b382)}, + {TOBN(0x7a77ba3f, 0x22433ccf), TOBN(0xde8362d6, 0xa29f05a9), + TOBN(0x7f6a30ea, 0x61189afc), TOBN(0x693b5505, 0x59ef114f)}}, + {{TOBN(0x50266bc0, 0xcd1797a1), TOBN(0xea17b47e, 0xf4b7af2d), + TOBN(0xd6c4025c, 0x3df9483e), TOBN(0x8cbb9d9f, 0xa37b18c9)}, + {TOBN(0x91cbfd9c, 0x4d8424cf), TOBN(0xdb7048f1, 0xab1c3506), + TOBN(0x9eaf641f, 0x028206a3), TOBN(0xf986f3f9, 0x25bdf6ce)}}, + {{TOBN(0x262143b5, 0x224c08dc), TOBN(0x2bbb09b4, 0x81b50c91), + TOBN(0xc16ed709, 0xaca8c84f), TOBN(0xa6210d9d, 0xb2850ca8)}, + {TOBN(0x6d8df67a, 0x09cb54d6), TOBN(0x91eef6e0, 0x500919a4), + TOBN(0x90f61381, 0x0f132857), TOBN(0x9acede47, 0xf8d5028b)}}, + {{TOBN(0x844d1b71, 0x90b771c3), TOBN(0x563b71e4, 0xba6426be), + TOBN(0x2efa2e83, 0xbdb802ff), TOBN(0x3410cbab, 0xab5b4a41)}, + {TOBN(0x555b2d26, 0x30da84dd), TOBN(0xd0711ae9, 0xee1cc29a), + TOBN(0xcf3e8c60, 0x2f547792), TOBN(0x03d7d5de, 0xdc678b35)}}, + {{TOBN(0x071a2fa8, 0xced806b8), TOBN(0x222e6134, 0x697f1478), + TOBN(0xdc16fd5d, 0xabfcdbbf), TOBN(0x44912ebf, 0x121b53b8)}, + {TOBN(0xac943674, 0x2496c27c), TOBN(0x8ea3176c, 0x1ffc26b0), + TOBN(0xb6e224ac, 0x13debf2c), TOBN(0x524cc235, 0xf372a832)}}, + {{TOBN(0xd706e1d8, 0x9f6f1b18), TOBN(0x2552f005, 0x44cce35b), + TOBN(0x8c8326c2, 0xa88e31fc), TOBN(0xb5468b2c, 0xf9552047)}, + {TOBN(0xce683e88, 0x3ff90f2b), TOBN(0x77947bdf, 0x2f0a5423), + TOBN(0xd0a1b28b, 0xed56e328), TOBN(0xaee35253, 0xc20134ac)}}, + {{TOBN(0x7e98367d, 0x3567962f), TOBN(0x379ed61f, 0x8188bffb), + TOBN(0x73bba348, 0xfaf130a1), TOBN(0x6c1f75e1, 0x904ed734)}, + {TOBN(0x18956642, 0x3b4a79fc), TOBN(0xf20bc83d, 0x54ef4493), + TOBN(0x836d425d, 0x9111eca1), TOBN(0xe5b5c318, 0x009a8dcf)}}, + {{TOBN(0x3360b25d, 0x13221bc5), TOBN(0x707baad2, 0x6b3eeaf7), + TOBN(0xd7279ed8, 0x743a95a1), TOBN(0x7450a875, 0x969e809f)}, + {TOBN(0x32b6bd53, 0xe5d0338f), TOBN(0x1e77f7af, 0x2b883bbc), + TOBN(0x90da12cc, 0x1063ecd0), TOBN(0xe2697b58, 0xc315be47)}}, + {{TOBN(0x2771a5bd, 0xda85d534), TOBN(0x53e78c1f, 0xff980eea), + TOBN(0xadf1cf84, 0x900385e7), TOBN(0x7d3b14f6, 0xc9387b62)}, + {TOBN(0x170e74b0, 0xcb8f2bd2), TOBN(0x2d50b486, 0x827fa993), + TOBN(0xcdbe8c9a, 0xf6f32bab), TOBN(0x55e906b0, 0xc3b93ab8)}}, + {{TOBN(0x747f22fc, 0x8fe280d1), TOBN(0xcd8e0de5, 0xb2e114ab), + TOBN(0x5ab7dbeb, 0xe10b68b0), TOBN(0x9dc63a9c, 0xa480d4b2)}, + {TOBN(0x78d4bc3b, 0x4be1495f), TOBN(0x25eb3db8, 0x9359122d), + TOBN(0x3f8ac05b, 0x0809cbdc), TOBN(0xbf4187bb, 0xd37c702f)}}, + {{TOBN(0x84cea069, 0x1416a6a5), TOBN(0x8f860c79, 0x43ef881c), + TOBN(0x41311f8a, 0x38038a5d), TOBN(0xe78c2ec0, 0xfc612067)}, + {TOBN(0x494d2e81, 0x5ad73581), TOBN(0xb4cc9e00, 0x59604097), + TOBN(0xff558aec, 0xf3612cba), TOBN(0x35beef7a, 0x9e36c39e)}}, + {{TOBN(0x1845c7cf, 0xdbcf41b9), TOBN(0x5703662a, 0xaea997c0), + TOBN(0x8b925afe, 0xe402f6d8), TOBN(0xd0a1b1ae, 0x4dd72162)}, + {TOBN(0x9f47b375, 0x03c41c4b), TOBN(0xa023829b, 0x0391d042), + TOBN(0x5f5045c3, 0x503b8b0a), TOBN(0x123c2688, 0x98c010e5)}}, + {{TOBN(0x324ec0cc, 0x36ba06ee), TOBN(0xface3115, 0x3dd2cc0c), + TOBN(0xb364f3be, 0xf333e91f), TOBN(0xef8aff73, 0x28e832b0)}, + {TOBN(0x1e9bad04, 0x2d05841b), TOBN(0x42f0e3df, 0x356a21e2), + TOBN(0xa3270bcb, 0x4add627e), TOBN(0xb09a8158, 0xd322e711)}}, + {{TOBN(0x86e326a1, 0x0fee104a), TOBN(0xad7788f8, 0x3703f65d), + TOBN(0x7e765430, 0x47bc4833), TOBN(0x6cee582b, 0x2b9b893a)}, + {TOBN(0x9cd2a167, 0xe8f55a7b), TOBN(0xefbee3c6, 0xd9e4190d), + TOBN(0x33ee7185, 0xd40c2e9d), TOBN(0x844cc9c5, 0xa380b548)}}, + {{TOBN(0x323f8ecd, 0x66926e04), TOBN(0x0001e38f, 0x8110c1ba), + TOBN(0x8dbcac12, 0xfc6a7f07), TOBN(0xd65e1d58, 0x0cec0827)}, + {TOBN(0xd2cd4141, 0xbe76ca2d), TOBN(0x7895cf5c, 0xe892f33a), + TOBN(0x956d230d, 0x367139d2), TOBN(0xa91abd3e, 0xd012c4c1)}}, + {{TOBN(0x34fa4883, 0x87eb36bf), TOBN(0xc5f07102, 0x914b8fb4), + TOBN(0x90f0e579, 0xadb9c95f), TOBN(0xfe6ea8cb, 0x28888195)}, + {TOBN(0x7b9b5065, 0xedfa9284), TOBN(0x6c510bd2, 0x2b8c8d65), + TOBN(0xd7b8ebef, 0xcbe8aafd), TOBN(0xedb3af98, 0x96b1da07)}}, + {{TOBN(0x28ff779d, 0x6295d426), TOBN(0x0c4f6ac7, 0x3fa3ad7b), + TOBN(0xec44d054, 0x8b8e2604), TOBN(0x9b32a66d, 0x8b0050e1)}, + {TOBN(0x1f943366, 0xf0476ce2), TOBN(0x7554d953, 0xa602c7b4), + TOBN(0xbe35aca6, 0x524f2809), TOBN(0xb6881229, 0xfd4edbea)}}, + {{TOBN(0xe8cd0c8f, 0x508efb63), TOBN(0x9eb5b5c8, 0x6abcefc7), + TOBN(0xf5621f5f, 0xb441ab4f), TOBN(0x79e6c046, 0xb76a2b22)}, + {TOBN(0x74a4792c, 0xe37a1f69), TOBN(0xcbd252cb, 0x03542b60), + TOBN(0x785f65d5, 0xb3c20bd3), TOBN(0x8dea6143, 0x4fabc60c)}}, + {{TOBN(0x45e21446, 0xde673629), TOBN(0x57f7aa1e, 0x703c2d21), + TOBN(0xa0e99b7f, 0x98c868c7), TOBN(0x4e42f66d, 0x8b641676)}, + {TOBN(0x602884dc, 0x91077896), TOBN(0xa0d690cf, 0xc2c9885b), + TOBN(0xfeb4da33, 0x3b9a5187), TOBN(0x5f789598, 0x153c87ee)}}, + {{TOBN(0x2192dd47, 0x52b16dba), TOBN(0xdeefc0e6, 0x3524c1b1), + TOBN(0x465ea76e, 0xe4383693), TOBN(0x79401711, 0x361b8d98)}, + {TOBN(0xa5f9ace9, 0xf21a15cb), TOBN(0x73d26163, 0xefee9aeb), + TOBN(0xcca844b3, 0xe677016c), TOBN(0x6c122b07, 0x57eaee06)}}, + {{TOBN(0xb782dce7, 0x15f09690), TOBN(0x508b9b12, 0x2dfc0fc9), + TOBN(0x9015ab4b, 0x65d89fc6), TOBN(0x5e79dab7, 0xd6d5bb0f)}, + {TOBN(0x64f021f0, 0x6c775aa2), TOBN(0xdf09d8cc, 0x37c7eca1), + TOBN(0x9a761367, 0xef2fa506), TOBN(0xed4ca476, 0x5b81eec6)}}, + {{TOBN(0x262ede36, 0x10bbb8b5), TOBN(0x0737ce83, 0x0641ada3), + TOBN(0x4c94288a, 0xe9831ccc), TOBN(0x487fc1ce, 0x8065e635)}, + {TOBN(0xb13d7ab3, 0xb8bb3659), TOBN(0xdea5df3e, 0x855e4120), + TOBN(0xb9a18573, 0x85eb0244), TOBN(0x1a1b8ea3, 0xa7cfe0a3)}}, + {{TOBN(0x3b837119, 0x67b0867c), TOBN(0x8d5e0d08, 0x9d364520), + TOBN(0x52dccc1e, 0xd930f0e3), TOBN(0xefbbcec7, 0xbf20bbaf)}, + {TOBN(0x99cffcab, 0x0263ad10), TOBN(0xd8199e6d, 0xfcd18f8a), + TOBN(0x64e2773f, 0xe9f10617), TOBN(0x0079e8e1, 0x08704848)}}, + {{TOBN(0x1169989f, 0x8a342283), TOBN(0x8097799c, 0xa83012e6), + TOBN(0xece966cb, 0x8a6a9001), TOBN(0x93b3afef, 0x072ac7fc)}, + {TOBN(0xe6893a2a, 0x2db3d5ba), TOBN(0x263dc462, 0x89bf4fdc), + TOBN(0x8852dfc9, 0xe0396673), TOBN(0x7ac70895, 0x3af362b6)}}, + {{TOBN(0xbb9cce4d, 0x5c2f342b), TOBN(0xbf80907a, 0xb52d7aae), + TOBN(0x97f3d3cd, 0x2161bcd0), TOBN(0xb25b0834, 0x0962744d)}, + {TOBN(0xc5b18ea5, 0x6c3a1dda), TOBN(0xfe4ec7eb, 0x06c92317), + TOBN(0xb787b890, 0xad1c4afe), TOBN(0xdccd9a92, 0x0ede801a)}}, + {{TOBN(0x9ac6ddda, 0xdb58da1f), TOBN(0x22bbc12f, 0xb8cae6ee), + TOBN(0xc6f8bced, 0x815c4a43), TOBN(0x8105a92c, 0xf96480c7)}, + {TOBN(0x0dc3dbf3, 0x7a859d51), TOBN(0xe3ec7ce6, 0x3041196b), + TOBN(0xd9f64b25, 0x0d1067c9), TOBN(0xf2321321, 0x3d1f8dd8)}}, + {{TOBN(0x8b5c619c, 0x76497ee8), TOBN(0x5d2b0ac6, 0xc717370e), + TOBN(0x98204cb6, 0x4fcf68e1), TOBN(0x0bdec211, 0x62bc6792)}, + {TOBN(0x6973ccef, 0xa63b1011), TOBN(0xf9e3fa97, 0xe0de1ac5), + TOBN(0x5efb693e, 0x3d0e0c8b), TOBN(0x037248e9, 0xd2d4fcb4)}}}, + {{{TOBN(0x80802dc9, 0x1ec34f9e), TOBN(0xd8772d35, 0x33810603), + TOBN(0x3f06d66c, 0x530cb4f3), TOBN(0x7be5ed0d, 0xc475c129)}, + {TOBN(0xcb9e3c19, 0x31e82b10), TOBN(0xc63d2857, 0xc9ff6b4c), + TOBN(0xb92118c6, 0x92a1b45e), TOBN(0x0aec4414, 0x7285bbca)}}, + {{TOBN(0xfc189ae7, 0x1e29a3ef), TOBN(0xcbe906f0, 0x4c93302e), + TOBN(0xd0107914, 0xceaae10e), TOBN(0xb7a23f34, 0xb68e19f8)}, + {TOBN(0xe9d875c2, 0xefd2119d), TOBN(0x03198c6e, 0xfcadc9c8), + TOBN(0x65591bf6, 0x4da17113), TOBN(0x3cf0bbf8, 0x3d443038)}}, + {{TOBN(0xae485bb7, 0x2b724759), TOBN(0x945353e1, 0xb2d4c63a), + TOBN(0x82159d07, 0xde7d6f2c), TOBN(0x389caef3, 0x4ec5b109)}, + {TOBN(0x4a8ebb53, 0xdb65ef14), TOBN(0x2dc2cb7e, 0xdd99de43), + TOBN(0x816fa3ed, 0x83f2405f), TOBN(0x73429bb9, 0xc14208a3)}}, + {{TOBN(0xb618d590, 0xb01e6e27), TOBN(0x047e2ccd, 0xe180b2dc), + TOBN(0xd1b299b5, 0x04aea4a9), TOBN(0x412c9e1e, 0x9fa403a4)}, + {TOBN(0x88d28a36, 0x79407552), TOBN(0x49c50136, 0xf332b8e3), + TOBN(0x3a1b6fcc, 0xe668de19), TOBN(0x178851bc, 0x75122b97)}}, + {{TOBN(0xb1e13752, 0xfb85fa4c), TOBN(0xd61257ce, 0x383c8ce9), + TOBN(0xd43da670, 0xd2f74dae), TOBN(0xa35aa23f, 0xbf846bbb)}, + {TOBN(0x5e74235d, 0x4421fc83), TOBN(0xf6df8ee0, 0xc363473b), + TOBN(0x34d7f52a, 0x3c4aa158), TOBN(0x50d05aab, 0x9bc6d22e)}}, + {{TOBN(0x8c56e735, 0xa64785f4), TOBN(0xbc56637b, 0x5f29cd07), + TOBN(0x53b2bb80, 0x3ee35067), TOBN(0x50235a0f, 0xdc919270)}, + {TOBN(0x191ab6d8, 0xf2c4aa65), TOBN(0xc3475831, 0x8396023b), + TOBN(0x80400ba5, 0xf0f805ba), TOBN(0x8881065b, 0x5ec0f80f)}}, + {{TOBN(0xc370e522, 0xcc1b5e83), TOBN(0xde2d4ad1, 0x860b8bfb), + TOBN(0xad364df0, 0x67b256df), TOBN(0x8f12502e, 0xe0138997)}, + {TOBN(0x503fa0dc, 0x7783920a), TOBN(0xe80014ad, 0xc0bc866a), + TOBN(0x3f89b744, 0xd3064ba6), TOBN(0x03511dcd, 0xcba5dba5)}}, + {{TOBN(0x197dd46d, 0x95a7b1a2), TOBN(0x9c4e7ad6, 0x3c6341fb), + TOBN(0x426eca29, 0x484c2ece), TOBN(0x9211e489, 0xde7f4f8a)}, + {TOBN(0x14997f6e, 0xc78ef1f4), TOBN(0x2b2c0910, 0x06574586), + TOBN(0x17286a6e, 0x1c3eede8), TOBN(0x25f92e47, 0x0f60e018)}}, + {{TOBN(0x805c5646, 0x31890a36), TOBN(0x703ef600, 0x57feea5b), + TOBN(0x389f747c, 0xaf3c3030), TOBN(0xe0e5daeb, 0x54dd3739)}, + {TOBN(0xfe24a4c3, 0xc9c9f155), TOBN(0x7e4bf176, 0xb5393962), + TOBN(0x37183de2, 0xaf20bf29), TOBN(0x4a1bd7b5, 0xf95a8c3b)}}, + {{TOBN(0xa83b9699, 0x46191d3d), TOBN(0x281fc8dd, 0x7b87f257), + TOBN(0xb18e2c13, 0x54107588), TOBN(0x6372def7, 0x9b2bafe8)}, + {TOBN(0xdaf4bb48, 0x0d8972ca), TOBN(0x3f2dd4b7, 0x56167a3f), + TOBN(0x1eace32d, 0x84310cf4), TOBN(0xe3bcefaf, 0xe42700aa)}}, + {{TOBN(0x5fe5691e, 0xd785e73d), TOBN(0xa5db5ab6, 0x2ea60467), + TOBN(0x02e23d41, 0xdfc6514a), TOBN(0x35e8048e, 0xe03c3665)}, + {TOBN(0x3f8b118f, 0x1adaa0f8), TOBN(0x28ec3b45, 0x84ce1a5a), + TOBN(0xe8cacc6e, 0x2c6646b8), TOBN(0x1343d185, 0xdbd0e40f)}}, + {{TOBN(0xe5d7f844, 0xcaaa358c), TOBN(0x1a1db7e4, 0x9924182a), + TOBN(0xd64cd42d, 0x9c875d9a), TOBN(0xb37b515f, 0x042eeec8)}, + {TOBN(0x4d4dd409, 0x7b165fbe), TOBN(0xfc322ed9, 0xe206eff3), + TOBN(0x7dee4102, 0x59b7e17e), TOBN(0x55a481c0, 0x8236ca00)}}, + {{TOBN(0x8c885312, 0xc23fc975), TOBN(0x15715806, 0x05d6297b), + TOBN(0xa078868e, 0xf78edd39), TOBN(0x956b31e0, 0x03c45e52)}, + {TOBN(0x470275d5, 0xff7b33a6), TOBN(0xc8d5dc3a, 0x0c7e673f), + TOBN(0x419227b4, 0x7e2f2598), TOBN(0x8b37b634, 0x4c14a975)}}, + {{TOBN(0xd0667ed6, 0x8b11888c), TOBN(0x5e0e8c3e, 0x803e25dc), + TOBN(0x34e5d0dc, 0xb987a24a), TOBN(0x9f40ac3b, 0xae920323)}, + {TOBN(0x5463de95, 0x34e0f63a), TOBN(0xa128bf92, 0x6b6328f9), + TOBN(0x491ccd7c, 0xda64f1b7), TOBN(0x7ef1ec27, 0xc47bde35)}}, + {{TOBN(0xa857240f, 0xa36a2737), TOBN(0x35dc1366, 0x63621bc1), + TOBN(0x7a3a6453, 0xd4fb6897), TOBN(0x80f1a439, 0xc929319d)}, + {TOBN(0xfc18274b, 0xf8cb0ba0), TOBN(0xb0b53766, 0x8078c5eb), + TOBN(0xfb0d4924, 0x1e01d0ef), TOBN(0x50d7c67d, 0x372ab09c)}}, + {{TOBN(0xb4e370af, 0x3aeac968), TOBN(0xe4f7fee9, 0xc4b63266), + TOBN(0xb4acd4c2, 0xe3ac5664), TOBN(0xf8910bd2, 0xceb38cbf)}, + {TOBN(0x1c3ae50c, 0xc9c0726e), TOBN(0x15309569, 0xd97b40bf), + TOBN(0x70884b7f, 0xfd5a5a1b), TOBN(0x3890896a, 0xef8314cd)}}, + {{TOBN(0x58e1515c, 0xa5618c93), TOBN(0xe665432b, 0x77d942d1), + TOBN(0xb32181bf, 0xb6f767a8), TOBN(0x753794e8, 0x3a604110)}, + {TOBN(0x09afeb7c, 0xe8c0dbcc), TOBN(0x31e02613, 0x598673a3), + TOBN(0x5d98e557, 0x7d46db00), TOBN(0xfc21fb8c, 0x9d985b28)}}, + {{TOBN(0xc9040116, 0xb0843e0b), TOBN(0x53b1b3a8, 0x69b04531), + TOBN(0xdd1649f0, 0x85d7d830), TOBN(0xbb3bcc87, 0xcb7427e8)}, + {TOBN(0x77261100, 0xc93dce83), TOBN(0x7e79da61, 0xa1922a2a), + TOBN(0x587a2b02, 0xf3149ce8), TOBN(0x147e1384, 0xde92ec83)}}, + {{TOBN(0x484c83d3, 0xaf077f30), TOBN(0xea78f844, 0x0658b53a), + TOBN(0x912076c2, 0x027aec53), TOBN(0xf34714e3, 0x93c8177d)}, + {TOBN(0x37ef5d15, 0xc2376c84), TOBN(0x8315b659, 0x3d1aa783), + TOBN(0x3a75c484, 0xef852a90), TOBN(0x0ba0c58a, 0x16086bd4)}}, + {{TOBN(0x29688d7a, 0x529a6d48), TOBN(0x9c7f250d, 0xc2f19203), + TOBN(0x123042fb, 0x682e2df9), TOBN(0x2b7587e7, 0xad8121bc)}, + {TOBN(0x30fc0233, 0xe0182a65), TOBN(0xb82ecf87, 0xe3e1128a), + TOBN(0x71682861, 0x93fb098f), TOBN(0x043e21ae, 0x85e9e6a7)}}, + {{TOBN(0xab5b49d6, 0x66c834ea), TOBN(0x3be43e18, 0x47414287), + TOBN(0xf40fb859, 0x219a2a47), TOBN(0x0e6559e9, 0xcc58df3c)}, + {TOBN(0xfe1dfe8e, 0x0c6615b4), TOBN(0x14abc8fd, 0x56459d70), + TOBN(0x7be0fa8e, 0x05de0386), TOBN(0x8e63ef68, 0xe9035c7c)}}, + {{TOBN(0x116401b4, 0x53b31e91), TOBN(0x0cba7ad4, 0x4436b4d8), + TOBN(0x9151f9a0, 0x107afd66), TOBN(0xafaca8d0, 0x1f0ee4c4)}, + {TOBN(0x75fe5c1d, 0x9ee9761c), TOBN(0x3497a16b, 0xf0c0588f), + TOBN(0x3ee2bebd, 0x0304804c), TOBN(0xa8fb9a60, 0xc2c990b9)}}, + {{TOBN(0xd14d32fe, 0x39251114), TOBN(0x36bf25bc, 0xcac73366), + TOBN(0xc9562c66, 0xdba7495c), TOBN(0x324d301b, 0x46ad348b)}, + {TOBN(0x9f46620c, 0xd670407e), TOBN(0x0ea8d4f1, 0xe3733a01), + TOBN(0xd396d532, 0xb0c324e0), TOBN(0x5b211a0e, 0x03c317cd)}}, + {{TOBN(0x090d7d20, 0x5ffe7b37), TOBN(0x3b7f3efb, 0x1747d2da), + TOBN(0xa2cb525f, 0xb54fc519), TOBN(0x6e220932, 0xf66a971e)}, + {TOBN(0xddc160df, 0xb486d440), TOBN(0x7fcfec46, 0x3fe13465), + TOBN(0x83da7e4e, 0x76e4c151), TOBN(0xd6fa48a1, 0xd8d302b5)}}, + {{TOBN(0xc6304f26, 0x5872cd88), TOBN(0x806c1d3c, 0x278b90a1), + TOBN(0x3553e725, 0xcaf0bc1c), TOBN(0xff59e603, 0xbb9d8d5c)}, + {TOBN(0xa4550f32, 0x7a0b85dd), TOBN(0xdec5720a, 0x93ecc217), + TOBN(0x0b88b741, 0x69d62213), TOBN(0x7212f245, 0x5b365955)}}, + {{TOBN(0x20764111, 0xb5cae787), TOBN(0x13cb7f58, 0x1dfd3124), + TOBN(0x2dca77da, 0x1175aefb), TOBN(0xeb75466b, 0xffaae775)}, + {TOBN(0x74d76f3b, 0xdb6cff32), TOBN(0x7440f37a, 0x61fcda9a), + TOBN(0x1bb3ac92, 0xb525028b), TOBN(0x20fbf8f7, 0xa1975f29)}}, + {{TOBN(0x982692e1, 0xdf83097f), TOBN(0x28738f6c, 0x554b0800), + TOBN(0xdc703717, 0xa2ce2f2f), TOBN(0x7913b93c, 0x40814194)}, + {TOBN(0x04924593, 0x1fe89636), TOBN(0x7b98443f, 0xf78834a6), + TOBN(0x11c6ab01, 0x5114a5a1), TOBN(0x60deb383, 0xffba5f4c)}}, + {{TOBN(0x4caa54c6, 0x01a982e6), TOBN(0x1dd35e11, 0x3491cd26), + TOBN(0x973c315f, 0x7cbd6b05), TOBN(0xcab00775, 0x52494724)}, + {TOBN(0x04659b1f, 0x6565e15a), TOBN(0xbf30f529, 0x8c8fb026), + TOBN(0xfc21641b, 0xa8a0de37), TOBN(0xe9c7a366, 0xfa5e5114)}}, + {{TOBN(0xdb849ca5, 0x52f03ad8), TOBN(0xc7e8dbe9, 0x024e35c0), + TOBN(0xa1a2bbac, 0xcfc3c789), TOBN(0xbf733e7d, 0x9c26f262)}, + {TOBN(0x882ffbf5, 0xb8444823), TOBN(0xb7224e88, 0x6bf8483b), + TOBN(0x53023b8b, 0x65bef640), TOBN(0xaabfec91, 0xd4d5f8cd)}}, + {{TOBN(0xa40e1510, 0x079ea1bd), TOBN(0x1ad9addc, 0xd05d5d26), + TOBN(0xdb3f2eab, 0x13e68d4f), TOBN(0x1cff1ae2, 0x640f803f)}, + {TOBN(0xe0e7b749, 0xd4cee117), TOBN(0x8e9f275b, 0x4036d909), + TOBN(0xce34e31d, 0x8f4d4c38), TOBN(0x22b37f69, 0xd75130fc)}}, + {{TOBN(0x83e0f1fd, 0xb4014604), TOBN(0xa8ce9919, 0x89415078), + TOBN(0x82375b75, 0x41792efe), TOBN(0x4f59bf5c, 0x97d4515b)}, + {TOBN(0xac4f324f, 0x923a277d), TOBN(0xd9bc9b7d, 0x650f3406), + TOBN(0xc6fa87d1, 0x8a39bc51), TOBN(0x82588530, 0x5ccc108f)}}, + {{TOBN(0x5ced3c9f, 0x82e4c634), TOBN(0x8efb8314, 0x3a4464f8), + TOBN(0xe706381b, 0x7a1dca25), TOBN(0x6cd15a3c, 0x5a2a412b)}, + {TOBN(0x9347a8fd, 0xbfcd8fb5), TOBN(0x31db2eef, 0x6e54cd22), + TOBN(0xc4aeb11e, 0xf8d8932f), TOBN(0x11e7c1ed, 0x344411af)}}, + {{TOBN(0x2653050c, 0xdc9a151e), TOBN(0x9edbfc08, 0x3bb0a859), + TOBN(0x926c81c7, 0xfd5691e7), TOBN(0x9c1b2342, 0x6f39019a)}, + {TOBN(0x64a81c8b, 0x7f8474b9), TOBN(0x90657c07, 0x01761819), + TOBN(0x390b3331, 0x55e0375a), TOBN(0xc676c626, 0xb6ebc47d)}}, + {{TOBN(0x51623247, 0xb7d6dee8), TOBN(0x0948d927, 0x79659313), + TOBN(0x99700161, 0xe9ab35ed), TOBN(0x06cc32b4, 0x8ddde408)}, + {TOBN(0x6f2fd664, 0x061ef338), TOBN(0x1606fa02, 0xc202e9ed), + TOBN(0x55388bc1, 0x929ba99b), TOBN(0xc4428c5e, 0x1e81df69)}}, + {{TOBN(0xce2028ae, 0xf91b0b2a), TOBN(0xce870a23, 0xf03dfd3f), + TOBN(0x66ec2c87, 0x0affe8ed), TOBN(0xb205fb46, 0x284d0c00)}, + {TOBN(0xbf5dffe7, 0x44cefa48), TOBN(0xb6fc37a8, 0xa19876d7), + TOBN(0xbecfa84c, 0x08b72863), TOBN(0xd7205ff5, 0x2576374f)}}, + {{TOBN(0x80330d32, 0x8887de41), TOBN(0x5de0df0c, 0x869ea534), + TOBN(0x13f42753, 0x3c56ea17), TOBN(0xeb1f6069, 0x452b1a78)}, + {TOBN(0x50474396, 0xe30ea15c), TOBN(0x575816a1, 0xc1494125), + TOBN(0xbe1ce55b, 0xfe6bb38f), TOBN(0xb901a948, 0x96ae30f7)}}, + {{TOBN(0xe5af0f08, 0xd8fc3548), TOBN(0x5010b5d0, 0xd73bfd08), + TOBN(0x993d2880, 0x53fe655a), TOBN(0x99f2630b, 0x1c1309fd)}, + {TOBN(0xd8677baf, 0xb4e3b76f), TOBN(0x14e51ddc, 0xb840784b), + TOBN(0x326c750c, 0xbf0092ce), TOBN(0xc83d306b, 0xf528320f)}}, + {{TOBN(0xc4456715, 0x77d4715c), TOBN(0xd30019f9, 0x6b703235), + TOBN(0x207ccb2e, 0xd669e986), TOBN(0x57c824af, 0xf6dbfc28)}, + {TOBN(0xf0eb532f, 0xd8f92a23), TOBN(0x4a557fd4, 0x9bb98fd2), + TOBN(0xa57acea7, 0xc1e6199a), TOBN(0x0c663820, 0x8b94b1ed)}}, + {{TOBN(0x9b42be8f, 0xf83a9266), TOBN(0xc7741c97, 0x0101bd45), + TOBN(0x95770c11, 0x07bd9ceb), TOBN(0x1f50250a, 0x8b2e0744)}, + {TOBN(0xf762eec8, 0x1477b654), TOBN(0xc65b900e, 0x15efe59a), + TOBN(0x88c96148, 0x9546a897), TOBN(0x7e8025b3, 0xc30b4d7c)}}, + {{TOBN(0xae4065ef, 0x12045cf9), TOBN(0x6fcb2caf, 0x9ccce8bd), + TOBN(0x1fa0ba4e, 0xf2cf6525), TOBN(0xf683125d, 0xcb72c312)}, + {TOBN(0xa01da4ea, 0xe312410e), TOBN(0x67e28677, 0x6cd8e830), + TOBN(0xabd95752, 0x98fb3f07), TOBN(0x05f11e11, 0xeef649a5)}}, + {{TOBN(0xba47faef, 0x9d3472c2), TOBN(0x3adff697, 0xc77d1345), + TOBN(0x4761fa04, 0xdd15afee), TOBN(0x64f1f61a, 0xb9e69462)}, + {TOBN(0xfa691fab, 0x9bfb9093), TOBN(0x3df8ae8f, 0xa1133dfe), + TOBN(0xcd5f8967, 0x58cc710d), TOBN(0xfbb88d50, 0x16c7fe79)}}, + {{TOBN(0x8e011b4c, 0xe88c50d1), TOBN(0x7532e807, 0xa8771c4f), + TOBN(0x64c78a48, 0xe2278ee4), TOBN(0x0b283e83, 0x3845072a)}, + {TOBN(0x98a6f291, 0x49e69274), TOBN(0xb96e9668, 0x1868b21c), + TOBN(0x38f0adc2, 0xb1a8908e), TOBN(0x90afcff7, 0x1feb829d)}}, + {{TOBN(0x9915a383, 0x210b0856), TOBN(0xa5a80602, 0xdef04889), + TOBN(0x800e9af9, 0x7c64d509), TOBN(0x81382d0b, 0xb8996f6f)}, + {TOBN(0x490eba53, 0x81927e27), TOBN(0x46c63b32, 0x4af50182), + TOBN(0x784c5fd9, 0xd3ad62ce), TOBN(0xe4fa1870, 0xf8ae8736)}}, + {{TOBN(0x4ec9d0bc, 0xd7466b25), TOBN(0x84ddbe1a, 0xdb235c65), + TOBN(0x5e2645ee, 0x163c1688), TOBN(0x570bd00e, 0x00eba747)}, + {TOBN(0xfa51b629, 0x128bfa0f), TOBN(0x92fce1bd, 0x6c1d3b68), + TOBN(0x3e7361dc, 0xb66778b1), TOBN(0x9c7d249d, 0x5561d2bb)}}, + {{TOBN(0xa40b28bf, 0x0bbc6229), TOBN(0x1c83c05e, 0xdfd91497), + TOBN(0x5f9f5154, 0xf083df05), TOBN(0xbac38b3c, 0xeee66c9d)}, + {TOBN(0xf71db7e3, 0xec0dfcfd), TOBN(0xf2ecda8e, 0x8b0a8416), + TOBN(0x52fddd86, 0x7812aa66), TOBN(0x2896ef10, 0x4e6f4272)}}, + {{TOBN(0xff27186a, 0x0fe9a745), TOBN(0x08249fcd, 0x49ca70db), + TOBN(0x7425a2e6, 0x441cac49), TOBN(0xf4a0885a, 0xece5ff57)}, + {TOBN(0x6e2cb731, 0x7d7ead58), TOBN(0xf96cf7d6, 0x1898d104), + TOBN(0xafe67c9d, 0x4f2c9a89), TOBN(0x89895a50, 0x1c7bf5bc)}}, + {{TOBN(0xdc7cb8e5, 0x573cecfa), TOBN(0x66497eae, 0xd15f03e6), + TOBN(0x6bc0de69, 0x3f084420), TOBN(0x323b9b36, 0xacd532b0)}, + {TOBN(0xcfed390a, 0x0115a3c1), TOBN(0x9414c40b, 0x2d65ca0e), + TOBN(0x641406bd, 0x2f530c78), TOBN(0x29369a44, 0x833438f2)}}, + {{TOBN(0x996884f5, 0x903fa271), TOBN(0xe6da0fd2, 0xb9da921e), + TOBN(0xa6f2f269, 0x5db01e54), TOBN(0x1ee3e9bd, 0x6876214e)}, + {TOBN(0xa26e181c, 0xe27a9497), TOBN(0x36d254e4, 0x8e215e04), + TOBN(0x42f32a6c, 0x252cabca), TOBN(0x99481487, 0x80b57614)}}, + {{TOBN(0x4c4dfe69, 0x40d9cae1), TOBN(0x05869580, 0x11a10f09), + TOBN(0xca287b57, 0x3491b64b), TOBN(0x77862d5d, 0x3fd4a53b)}, + {TOBN(0xbf94856e, 0x50349126), TOBN(0x2be30bd1, 0x71c5268f), + TOBN(0x10393f19, 0xcbb650a6), TOBN(0x639531fe, 0x778cf9fd)}}, + {{TOBN(0x02556a11, 0xb2935359), TOBN(0xda38aa96, 0xaf8c126e), + TOBN(0x47dbe6c2, 0x0960167f), TOBN(0x37bbabb6, 0x501901cd)}, + {TOBN(0xb6e979e0, 0x2c947778), TOBN(0xd69a5175, 0x7a1a1dc6), + TOBN(0xc3ed5095, 0x9d9faf0c), TOBN(0x4dd9c096, 0x1d5fa5f0)}}, + {{TOBN(0xa0c4304d, 0x64f16ea8), TOBN(0x8b1cac16, 0x7e718623), + TOBN(0x0b576546, 0x7c67f03e), TOBN(0x559cf5ad, 0xcbd88c01)}, + {TOBN(0x074877bb, 0x0e2af19a), TOBN(0x1f717ec1, 0xa1228c92), + TOBN(0x70bcb800, 0x326e8920), TOBN(0xec6e2c5c, 0x4f312804)}}, + {{TOBN(0x426aea7d, 0x3fca4752), TOBN(0xf12c0949, 0x2211f62a), + TOBN(0x24beecd8, 0x7be7b6b5), TOBN(0xb77eaf4c, 0x36d7a27d)}, + {TOBN(0x154c2781, 0xfda78fd3), TOBN(0x848a83b0, 0x264eeabe), + TOBN(0x81287ef0, 0x4ffe2bc4), TOBN(0x7b6d88c6, 0xb6b6fc2a)}}, + {{TOBN(0x805fb947, 0xce417d99), TOBN(0x4b93dcc3, 0x8b916cc4), + TOBN(0x72e65bb3, 0x21273323), TOBN(0xbcc1badd, 0x6ea9886e)}, + {TOBN(0x0e223011, 0x4bc5ee85), TOBN(0xa561be74, 0xc18ee1e4), + TOBN(0x762fd2d4, 0xa6bcf1f1), TOBN(0x50e6a5a4, 0x95231489)}}, + {{TOBN(0xca96001f, 0xa00b500b), TOBN(0x5c098cfc, 0x5d7dcdf5), + TOBN(0xa64e2d2e, 0x8c446a85), TOBN(0xbae9bcf1, 0x971f3c62)}, + {TOBN(0x4ec22683, 0x8435a2c5), TOBN(0x8ceaed6c, 0x4bad4643), + TOBN(0xe9f8fb47, 0xccccf4e3), TOBN(0xbd4f3fa4, 0x1ce3b21e)}}, + {{TOBN(0xd79fb110, 0xa3db3292), TOBN(0xe28a37da, 0xb536c66a), + TOBN(0x279ce87b, 0x8e49e6a9), TOBN(0x70ccfe8d, 0xfdcec8e3)}, + {TOBN(0x2193e4e0, 0x3ba464b2), TOBN(0x0f39d60e, 0xaca9a398), + TOBN(0x7d7932af, 0xf82c12ab), TOBN(0xd8ff50ed, 0x91e7e0f7)}}, + {{TOBN(0xea961058, 0xfa28a7e0), TOBN(0xc726cf25, 0x0bf5ec74), + TOBN(0xe74d55c8, 0xdb229666), TOBN(0x0bd9abbf, 0xa57f5799)}, + {TOBN(0x7479ef07, 0x4dfc47b3), TOBN(0xd9c65fc3, 0x0c52f91d), + TOBN(0x8e0283fe, 0x36a8bde2), TOBN(0xa32a8b5e, 0x7d4b7280)}}, + {{TOBN(0x6a677c61, 0x12e83233), TOBN(0x0fbb3512, 0xdcc9bf28), + TOBN(0x562e8ea5, 0x0d780f61), TOBN(0x0db8b22b, 0x1dc4e89c)}, + {TOBN(0x0a6fd1fb, 0x89be0144), TOBN(0x8c77d246, 0xca57113b), + TOBN(0x4639075d, 0xff09c91c), TOBN(0x5b47b17f, 0x5060824c)}}, + {{TOBN(0x58aea2b0, 0x16287b52), TOBN(0xa1343520, 0xd0cd8eb0), + TOBN(0x6148b4d0, 0xc5d58573), TOBN(0xdd2b6170, 0x291c68ae)}, + {TOBN(0xa61b3929, 0x1da3b3b7), TOBN(0x5f946d79, 0x08c4ac10), + TOBN(0x4105d4a5, 0x7217d583), TOBN(0x5061da3d, 0x25e6de5e)}}, + {{TOBN(0x3113940d, 0xec1b4991), TOBN(0xf12195e1, 0x36f485ae), + TOBN(0xa7507fb2, 0x731a2ee0), TOBN(0x95057a8e, 0x6e9e196e)}, + {TOBN(0xa3c2c911, 0x2e130136), TOBN(0x97dfbb36, 0x33c60d15), + TOBN(0xcaf3c581, 0xb300ee2b), TOBN(0x77f25d90, 0xf4bac8b8)}}, + {{TOBN(0xdb1c4f98, 0x6d840cd6), TOBN(0x471d62c0, 0xe634288c), + TOBN(0x8ec2f85e, 0xcec8a161), TOBN(0x41f37cbc, 0xfa6f4ae2)}, + {TOBN(0x6793a20f, 0x4b709985), TOBN(0x7a7bd33b, 0xefa8985b), + TOBN(0x2c6a3fbd, 0x938e6446), TOBN(0x19042619, 0x2a8d47c1)}}, + {{TOBN(0x16848667, 0xcc36975f), TOBN(0x02acf168, 0x9d5f1dfb), + TOBN(0x62d41ad4, 0x613baa94), TOBN(0xb56fbb92, 0x9f684670)}, + {TOBN(0xce610d0d, 0xe9e40569), TOBN(0x7b99c65f, 0x35489fef), + TOBN(0x0c88ad1b, 0x3df18b97), TOBN(0x81b7d9be, 0x5d0e9edb)}}, + {{TOBN(0xd85218c0, 0xc716cc0a), TOBN(0xf4b5ff90, 0x85691c49), + TOBN(0xa4fd666b, 0xce356ac6), TOBN(0x17c72895, 0x4b327a7a)}, + {TOBN(0xf93d5085, 0xda6be7de), TOBN(0xff71530e, 0x3301d34e), + TOBN(0x4cd96442, 0xd8f448e8), TOBN(0x9283d331, 0x2ed18ffa)}}, + {{TOBN(0x4d33dd99, 0x2a849870), TOBN(0xa716964b, 0x41576335), + TOBN(0xff5e3a9b, 0x179be0e5), TOBN(0x5b9d6b1b, 0x83b13632)}, + {TOBN(0x3b8bd7d4, 0xa52f313b), TOBN(0xc9dd95a0, 0x637a4660), + TOBN(0x30035962, 0x0b3e218f), TOBN(0xce1481a3, 0xc7b28a3c)}}, + {{TOBN(0xab41b43a, 0x43228d83), TOBN(0x24ae1c30, 0x4ad63f99), + TOBN(0x8e525f1a, 0x46a51229), TOBN(0x14af860f, 0xcd26d2b4)}, + {TOBN(0xd6baef61, 0x3f714aa1), TOBN(0xf51865ad, 0xeb78795e), + TOBN(0xd3e21fce, 0xe6a9d694), TOBN(0x82ceb1dd, 0x8a37b527)}}}}; diff --git a/http/vendor/ring/crypto/fipsmodule/ec/p256-nistz.c b/http/vendor/ring/crypto/fipsmodule/ec/p256-nistz.c new file mode 100644 index 0000000..7ae2ffd --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/ec/p256-nistz.c @@ -0,0 +1,437 @@ +// Copyright 2014-2016 The OpenSSL Project Authors. All Rights Reserved. +// Copyright (c) 2014, Intel Corporation. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Originally written by Shay Gueron (1, 2), and Vlad Krasnov (1) +// (1) Intel Corporation, Israel Development Center, Haifa, Israel +// (2) University of Haifa, Israel +// +// Reference: +// S.Gueron and V.Krasnov, "Fast Prime Field Elliptic Curve Cryptography with +// 256 Bit Primes" + +#include + +#include "../../limbs/limbs.inl" + +#include + +#include "p256-nistz.h" + +#if defined(OPENSSL_USE_NISTZ256) + +typedef P256_POINT_AFFINE PRECOMP256_ROW[64]; + +// One converted into the Montgomery domain +static const BN_ULONG ONE_MONT[P256_LIMBS] = { + TOBN(0x00000000, 0x00000001), + TOBN(0xffffffff, 0x00000000), + TOBN(0xffffffff, 0xffffffff), + TOBN(0x00000000, 0xfffffffe), +}; + +// Precomputed tables for the default generator +#include "p256-nistz-table.h" + +// Recode window to a signed digit, see |ec_GFp_nistp_recode_scalar_bits| in +// util.c for details +static crypto_word_t booth_recode_w5(crypto_word_t in) { + crypto_word_t s, d; + + s = ~((in >> 5) - 1); + d = (1 << 6) - in - 1; + d = (d & s) | (in & ~s); + d = (d >> 1) + (d & 1); + + return (d << 1) + (s & 1); +} + +static crypto_word_t booth_recode_w7(crypto_word_t in) { + crypto_word_t s, d; + + s = ~((in >> 7) - 1); + d = (1 << 8) - in - 1; + d = (d & s) | (in & ~s); + d = (d >> 1) + (d & 1); + + return (d << 1) + (s & 1); +} + +// The `(P256_LIMBS == 8)` case is unreachable for 64-bit targets. +#if defined(OPENSSL_64_BIT) && defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunreachable-code" +#endif + +// copy_conditional copies |src| to |dst| if |move| is one and leaves it as-is +// if |move| is zero. +// +// WARNING: this breaks the usual convention of constant-time functions +// returning masks. +static void copy_conditional(BN_ULONG dst[P256_LIMBS], + const BN_ULONG src[P256_LIMBS], BN_ULONG move) { + BN_ULONG mask1 = ((BN_ULONG)0) - move; + BN_ULONG mask2 = ~mask1; + + dst[0] = (src[0] & mask1) ^ (dst[0] & mask2); + dst[1] = (src[1] & mask1) ^ (dst[1] & mask2); + dst[2] = (src[2] & mask1) ^ (dst[2] & mask2); + dst[3] = (src[3] & mask1) ^ (dst[3] & mask2); + if (P256_LIMBS == 8) { + dst[4] = (src[4] & mask1) ^ (dst[4] & mask2); + dst[5] = (src[5] & mask1) ^ (dst[5] & mask2); + dst[6] = (src[6] & mask1) ^ (dst[6] & mask2); + dst[7] = (src[7] & mask1) ^ (dst[7] & mask2); + } +} + +#if defined(__clang__) +#pragma GCC diagnostic pop +#endif + +// is_not_zero returns one iff in != 0 and zero otherwise. +// +// WARNING: this breaks the usual convention of constant-time functions +// returning masks. +// +// (define-fun is_not_zero ((in (_ BitVec 64))) (_ BitVec 64) +// (bvlshr (bvor in (bvsub #x0000000000000000 in)) #x000000000000003f) +// ) +// +// (declare-fun x () (_ BitVec 64)) +// +// (assert (and (= x #x0000000000000000) (= (is_not_zero x) +// #x0000000000000001))) (check-sat) +// +// (assert (and (not (= x #x0000000000000000)) (= (is_not_zero x) +// #x0000000000000000))) (check-sat) +// +static BN_ULONG is_not_zero(BN_ULONG in) { + in |= (0 - in); + in >>= BN_BITS2 - 1; + return in; +} + +#if defined(OPENSSL_X86_64) +// Dispatch between CPU variations. The "_adx" suffixed functions use MULX in +// addition to ADCX/ADOX. MULX is part of BMI2, not ADX, so we must check both +// capabilities. + void ecp_nistz256_mul_mont(BN_ULONG res[P256_LIMBS], + const BN_ULONG a[P256_LIMBS], + const BN_ULONG b[P256_LIMBS]) { + if (adx_bmi2_available) { + ecp_nistz256_mul_mont_adx(res, a, b); + } else { + ecp_nistz256_mul_mont_nohw(res, a, b); + } +} + + void ecp_nistz256_sqr_mont(BN_ULONG res[P256_LIMBS], + const BN_ULONG a[P256_LIMBS]) { + if (adx_bmi2_available) { + ecp_nistz256_sqr_mont_adx(res, a); + } else { + ecp_nistz256_sqr_mont_nohw(res, a); + } +} + + void ecp_nistz256_ord_mul_mont(BN_ULONG res[P256_LIMBS], + const BN_ULONG a[P256_LIMBS], + const BN_ULONG b[P256_LIMBS]) { + if (adx_bmi2_available) { + ecp_nistz256_ord_mul_mont_adx(res, a, b); + } else { + ecp_nistz256_ord_mul_mont_nohw(res, a, b); + } +} + + void ecp_nistz256_ord_sqr_mont(BN_ULONG res[P256_LIMBS], + const BN_ULONG a[P256_LIMBS], + BN_ULONG rep) { + if (adx_bmi2_available) { + ecp_nistz256_ord_sqr_mont_adx(res, a, rep); + } else { + ecp_nistz256_ord_sqr_mont_nohw(res, a, rep); + } +} + +static void ecp_nistz256_select_w5(P256_POINT *val, const P256_POINT in_t[16], + int index) { + if (avx2_available) { + ecp_nistz256_select_w5_avx2(val, in_t, index); + } else { + ecp_nistz256_select_w5_nohw(val, in_t, index); + } +} + +static void ecp_nistz256_select_w7(P256_POINT_AFFINE *val, + const P256_POINT_AFFINE in_t[64], + int index) { + if (avx2_available) { + ecp_nistz256_select_w7_avx2(val, in_t, index); + } else { + ecp_nistz256_select_w7_nohw(val, in_t, index); + } +} + + void ecp_nistz256_point_double(P256_POINT *r, const P256_POINT *a) { + if (adx_bmi2_available) { + ecp_nistz256_point_double_adx(r, a); + } else { + ecp_nistz256_point_double_nohw(r, a); + } +} + + void ecp_nistz256_point_add(P256_POINT *r, const P256_POINT *a, + const P256_POINT *b) { + if (adx_bmi2_available) { + ecp_nistz256_point_add_adx(r, a, b); + } else { + ecp_nistz256_point_add_nohw(r, a, b); + } +} + + void ecp_nistz256_point_add_affine(P256_POINT *r, const P256_POINT *a, + const P256_POINT_AFFINE *b) { + if (adx_bmi2_available) { + ecp_nistz256_point_add_affine_adx(r, a, b); + } else { + ecp_nistz256_point_add_affine_nohw(r, a, b); + } +} +#endif // OPENSSL_X86_64 + +// r = p * p_scalar +static void ecp_nistz256_windowed_mul(P256_POINT *r, + const BN_ULONG p_scalar[P256_LIMBS], + const BN_ULONG p_x[P256_LIMBS], + const BN_ULONG p_y[P256_LIMBS]) { + debug_assert_nonsecret(r != NULL); + debug_assert_nonsecret(p_scalar != NULL); + debug_assert_nonsecret(p_x != NULL); + debug_assert_nonsecret(p_y != NULL); + + static const size_t kWindowSize = 5; + static const crypto_word_t kMask = (1 << (5 /* kWindowSize */ + 1)) - 1; + + // A |P256_POINT| is (3 * 32) = 96 bytes, and the 64-byte alignment should + // add no more than 63 bytes of overhead. Thus, |table| should require + // ~1599 ((96 * 16) + 63) bytes of stack space. + alignas(64) P256_POINT table[16]; + P256_SCALAR_BYTES p_str; + p256_scalar_bytes_from_limbs(p_str, p_scalar); + + // table[0] is implicitly (0,0,0) (the point at infinity), therefore it is + // not stored. All other values are actually stored with an offset of -1 in + // table. + P256_POINT *row = table; + + limbs_copy(row[1 - 1].X, p_x, P256_LIMBS); + limbs_copy(row[1 - 1].Y, p_y, P256_LIMBS); + limbs_copy(row[1 - 1].Z, ONE_MONT, P256_LIMBS); + + ecp_nistz256_point_double(&row[2 - 1], &row[1 - 1]); + ecp_nistz256_point_add(&row[3 - 1], &row[2 - 1], &row[1 - 1]); + ecp_nistz256_point_double(&row[4 - 1], &row[2 - 1]); + ecp_nistz256_point_double(&row[6 - 1], &row[3 - 1]); + ecp_nistz256_point_double(&row[8 - 1], &row[4 - 1]); + ecp_nistz256_point_double(&row[12 - 1], &row[6 - 1]); + ecp_nistz256_point_add(&row[5 - 1], &row[4 - 1], &row[1 - 1]); + ecp_nistz256_point_add(&row[7 - 1], &row[6 - 1], &row[1 - 1]); + ecp_nistz256_point_add(&row[9 - 1], &row[8 - 1], &row[1 - 1]); + ecp_nistz256_point_add(&row[13 - 1], &row[12 - 1], &row[1 - 1]); + ecp_nistz256_point_double(&row[14 - 1], &row[7 - 1]); + ecp_nistz256_point_double(&row[10 - 1], &row[5 - 1]); + ecp_nistz256_point_add(&row[15 - 1], &row[14 - 1], &row[1 - 1]); + ecp_nistz256_point_add(&row[11 - 1], &row[10 - 1], &row[1 - 1]); + ecp_nistz256_point_double(&row[16 - 1], &row[8 - 1]); + + BN_ULONG tmp[P256_LIMBS]; + alignas(32) P256_POINT h; + size_t index = 255; + crypto_word_t wvalue = p_str[(index - 1) / 8]; + wvalue = (wvalue >> ((index - 1) % 8)) & kMask; + + ecp_nistz256_select_w5(r, table, (int)(booth_recode_w5(wvalue) >> 1)); + + while (index >= 5) { + if (index != 255) { + size_t off = (index - 1) / 8; + + wvalue = (crypto_word_t)p_str[off] | (crypto_word_t)p_str[off + 1] << 8; + wvalue = (wvalue >> ((index - 1) % 8)) & kMask; + + wvalue = booth_recode_w5(wvalue); + + ecp_nistz256_select_w5(&h, table, (int)(wvalue >> 1)); + + ecp_nistz256_neg(tmp, h.Y); + copy_conditional(h.Y, tmp, (wvalue & 1)); + + ecp_nistz256_point_add(r, r, &h); + } + + index -= kWindowSize; + + ecp_nistz256_point_double(r, r); + ecp_nistz256_point_double(r, r); + ecp_nistz256_point_double(r, r); + ecp_nistz256_point_double(r, r); + ecp_nistz256_point_double(r, r); + } + + // Final window + wvalue = p_str[0]; + wvalue = (wvalue << 1) & kMask; + + wvalue = booth_recode_w5(wvalue); + + ecp_nistz256_select_w5(&h, table, (int)(wvalue >> 1)); + + ecp_nistz256_neg(tmp, h.Y); + copy_conditional(h.Y, tmp, wvalue & 1); + + ecp_nistz256_point_add(r, r, &h); +} + +static crypto_word_t calc_first_wvalue(size_t *index, const uint8_t p_str[33]) { + static const size_t kWindowSize = 7; + static const crypto_word_t kMask = (1 << (7 /* kWindowSize */ + 1)) - 1; + *index = kWindowSize; + + crypto_word_t wvalue = ((crypto_word_t)p_str[0] << 1) & kMask; + return booth_recode_w7(wvalue); +} + +static crypto_word_t calc_wvalue(size_t *index, const uint8_t p_str[33]) { + static const size_t kWindowSize = 7; + static const crypto_word_t kMask = (1 << (7 /* kWindowSize */ + 1)) - 1; + + const size_t off = (*index - 1) / 8; + crypto_word_t wvalue = + (crypto_word_t)p_str[off] | (crypto_word_t)p_str[off + 1] << 8; + wvalue = (wvalue >> ((*index - 1) % 8)) & kMask; + *index += kWindowSize; + + return booth_recode_w7(wvalue); +} + +void p256_point_mul(Limb r[3][P256_LIMBS], const Limb p_scalar[P256_LIMBS], + const Limb p_x[P256_LIMBS], + const Limb p_y[P256_LIMBS]) { + alignas(32) P256_POINT out; + ecp_nistz256_windowed_mul(&out, p_scalar, p_x, p_y); + + limbs_copy(r[0], out.X, P256_LIMBS); + limbs_copy(r[1], out.Y, P256_LIMBS); + limbs_copy(r[2], out.Z, P256_LIMBS); +} + +void p256_point_mul_base(Limb r[3][P256_LIMBS], const Limb scalar[P256_LIMBS]) { + P256_SCALAR_BYTES p_str; + p256_scalar_bytes_from_limbs(p_str, scalar); + + // First window + size_t index = 0; + crypto_word_t wvalue = calc_first_wvalue(&index, p_str); + + alignas(32) P256_POINT_AFFINE t; + alignas(32) P256_POINT p; + ecp_nistz256_select_w7(&t, ecp_nistz256_precomputed[0], (int)(wvalue >> 1)); + ecp_nistz256_neg(p.Z, t.Y); + copy_conditional(t.Y, p.Z, wvalue & 1); + + // Convert |t| from affine to Jacobian coordinates. We set Z to zero if |t| + // is infinity and |ONE| otherwise. |t| was computed from the table, so it + // is infinity iff |wvalue >> 1| is zero. + limbs_copy(p.X, t.X, P256_LIMBS); + limbs_copy(p.Y, t.Y, P256_LIMBS); + limbs_zero(p.Z, P256_LIMBS); + copy_conditional(p.Z, ONE_MONT, is_not_zero(wvalue >> 1)); + + for (int i = 1; i < 37; i++) { + wvalue = calc_wvalue(&index, p_str); + + ecp_nistz256_select_w7(&t, ecp_nistz256_precomputed[i], (int)(wvalue >> 1)); + + alignas(32) BN_ULONG neg_Y[P256_LIMBS]; + ecp_nistz256_neg(neg_Y, t.Y); + copy_conditional(t.Y, neg_Y, wvalue & 1); + + // Note |ecp_nistz256_point_add_affine| does not work if |p| and |t| are the + // same non-infinity point. + ecp_nistz256_point_add_affine(&p, &p, &t); + } + + limbs_copy(r[0], p.X, P256_LIMBS); + limbs_copy(r[1], p.Y, P256_LIMBS); + limbs_copy(r[2], p.Z, P256_LIMBS); +} + +void p256_point_mul_base_vartime(Limb r[3][P256_LIMBS], + const Limb g_scalar[P256_LIMBS]) { + alignas(32) P256_POINT p; + uint8_t p_str[33]; + OPENSSL_memcpy(p_str, g_scalar, 32); + p_str[32] = 0; + + // First window + size_t index = 0; + size_t wvalue = calc_first_wvalue(&index, p_str); + + // Convert |p| from affine to Jacobian coordinates. We set Z to zero if |p| + // is infinity and |ONE_MONT| otherwise. |p| was computed from the table, so + // it is infinity iff |wvalue >> 1| is zero. + if ((wvalue >> 1) != 0) { + OPENSSL_memcpy(p.X, &ecp_nistz256_precomputed[0][(wvalue >> 1) - 1].X, + sizeof(p.X)); + OPENSSL_memcpy(p.Y, &ecp_nistz256_precomputed[0][(wvalue >> 1) - 1].Y, + sizeof(p.Y)); + OPENSSL_memcpy(p.Z, ONE_MONT, sizeof(p.Z)); + } else { + OPENSSL_memset(p.X, 0, sizeof(p.X)); + OPENSSL_memset(p.Y, 0, sizeof(p.Y)); + OPENSSL_memset(p.Z, 0, sizeof(p.Z)); + } + + if ((wvalue & 1) == 1) { + ecp_nistz256_neg(p.Y, p.Y); + } + + for (int i = 1; i < 37; i++) { + wvalue = calc_wvalue(&index, p_str); + if ((wvalue >> 1) == 0) { + continue; + } + + alignas(32) P256_POINT_AFFINE t; + OPENSSL_memcpy(&t, &ecp_nistz256_precomputed[i][(wvalue >> 1) - 1], + sizeof(t)); + if ((wvalue & 1) == 1) { + ecp_nistz256_neg(t.Y, t.Y); + } + + // Note |ecp_nistz256_point_add_affine| does not work if |p| and |t| are + // the same non-infinity point, so it is important that we compute the + // |g_scalar| term before the |p_scalar| term. + ecp_nistz256_point_add_affine(&p, &p, &t); + } + + + limbs_copy(r[0], p.X, P256_LIMBS); + limbs_copy(r[1], p.Y, P256_LIMBS); + limbs_copy(r[2], p.Z, P256_LIMBS); +} + +#endif /* defined(OPENSSL_USE_NISTZ256) */ diff --git a/http/vendor/ring/crypto/fipsmodule/ec/p256-nistz.h b/http/vendor/ring/crypto/fipsmodule/ec/p256-nistz.h new file mode 100644 index 0000000..ff01f50 --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/ec/p256-nistz.h @@ -0,0 +1,171 @@ +// Copyright 2014-2016 The OpenSSL Project Authors. All Rights Reserved. +// Copyright (c) 2014, Intel Corporation. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Originally written by Shay Gueron (1, 2), and Vlad Krasnov (1) +// (1) Intel Corporation, Israel Development Center, Haifa, Israel +// (2) University of Haifa, Israel +// +// Reference: +// S.Gueron and V.Krasnov, "Fast Prime Field Elliptic Curve Cryptography with +// 256 Bit Primes" + +#ifndef OPENSSL_HEADER_EC_P256_X86_64_H +#define OPENSSL_HEADER_EC_P256_X86_64_H + +#include + +#include "p256_shared.h" + +#include "../bn/internal.h" + +#if defined(OPENSSL_USE_NISTZ256) + +// ecp_nistz256_neg sets |res| to -|a| mod P. +void ecp_nistz256_neg(BN_ULONG res[P256_LIMBS], const BN_ULONG a[P256_LIMBS]); + +// ecp_nistz256_mul_mont sets |res| to |a| * |b| * 2^-256 mod P. +#if defined(OPENSSL_X86_64) +void ecp_nistz256_mul_mont_nohw(BN_ULONG res[P256_LIMBS], + const BN_ULONG a[P256_LIMBS], + const BN_ULONG b[P256_LIMBS]); +void ecp_nistz256_mul_mont_adx(BN_ULONG res[P256_LIMBS], + const BN_ULONG a[P256_LIMBS], + const BN_ULONG b[P256_LIMBS]); +#else +void ecp_nistz256_mul_mont(BN_ULONG res[P256_LIMBS], + const BN_ULONG a[P256_LIMBS], + const BN_ULONG b[P256_LIMBS]); +#endif + +// ecp_nistz256_sqr_mont sets |res| to |a| * |a| * 2^-256 mod P. +#if defined(OPENSSL_X86_64) +void ecp_nistz256_sqr_mont_nohw(BN_ULONG res[P256_LIMBS], + const BN_ULONG a[P256_LIMBS]); +void ecp_nistz256_sqr_mont_adx(BN_ULONG res[P256_LIMBS], + const BN_ULONG a[P256_LIMBS]); +#else +void ecp_nistz256_sqr_mont(BN_ULONG res[P256_LIMBS], + const BN_ULONG a[P256_LIMBS]); +#endif + + +// P-256 scalar operations. +// +// The following functions compute modulo N, where N is the order of P-256. They +// take fully-reduced inputs and give fully-reduced outputs. + +// ecp_nistz256_ord_mul_mont sets |res| to |a| * |b| where inputs and outputs +// are in Montgomery form. That is, |res| is |a| * |b| * 2^-256 mod N. +#if defined(OPENSSL_X86_64) +void ecp_nistz256_ord_mul_mont_nohw(BN_ULONG res[P256_LIMBS], + const BN_ULONG a[P256_LIMBS], + const BN_ULONG b[P256_LIMBS]); +void ecp_nistz256_ord_mul_mont_adx(BN_ULONG res[P256_LIMBS], + const BN_ULONG a[P256_LIMBS], + const BN_ULONG b[P256_LIMBS]); +#else +void ecp_nistz256_ord_mul_mont(BN_ULONG res[P256_LIMBS], + const BN_ULONG a[P256_LIMBS], + const BN_ULONG b[P256_LIMBS]); +#endif + +// ecp_nistz256_ord_sqr_mont sets |res| to |a|^(2*|rep|) where inputs and +// outputs are in Montgomery form. That is, |res| is +// (|a| * 2^-256)^(2*|rep|) * 2^256 mod N. +#if defined(OPENSSL_X86_64) +void ecp_nistz256_ord_sqr_mont_nohw(BN_ULONG res[P256_LIMBS], + const BN_ULONG a[P256_LIMBS], BN_ULONG rep); +void ecp_nistz256_ord_sqr_mont_adx(BN_ULONG res[P256_LIMBS], + const BN_ULONG a[P256_LIMBS], BN_ULONG rep); +#else +void ecp_nistz256_ord_sqr_mont(BN_ULONG res[P256_LIMBS], + const BN_ULONG a[P256_LIMBS], BN_ULONG rep); +#endif + + + +// P-256 point operations. +// +// The following functions may be used in-place. All coordinates are in the +// Montgomery domain. + +// A P256_POINT_AFFINE represents a P-256 point in affine coordinates. Infinity +// is encoded as (0, 0). +typedef struct { + BN_ULONG X[P256_LIMBS]; + BN_ULONG Y[P256_LIMBS]; +} P256_POINT_AFFINE; + +// ecp_nistz256_select_w5 sets |*val| to |in_t[index-1]| if 1 <= |index| <= 16 +// and all zeros (the point at infinity) if |index| is 0. This is done in +// constant time. +#if defined(OPENSSL_X86_64) +void ecp_nistz256_select_w5_nohw(P256_POINT *val, const P256_POINT in_t[16], + int index); +void ecp_nistz256_select_w5_avx2(P256_POINT *val, const P256_POINT in_t[16], + int index); +#else +void ecp_nistz256_select_w5(P256_POINT *val, const P256_POINT in_t[16], + int index); +#endif + +// ecp_nistz256_select_w7 sets |*val| to |in_t[index-1]| if 1 <= |index| <= 64 +// and all zeros (the point at infinity) if |index| is 0. This is done in +// constant time. +#if defined(OPENSSL_X86_64) +void ecp_nistz256_select_w7_nohw(P256_POINT_AFFINE *val, + const P256_POINT_AFFINE in_t[64], int index); +void ecp_nistz256_select_w7_avx2(P256_POINT_AFFINE *val, + const P256_POINT_AFFINE in_t[64], int index); +#else +void ecp_nistz256_select_w7(P256_POINT_AFFINE *val, + const P256_POINT_AFFINE in_t[64], int index); +#endif + +// ecp_nistz256_point_double sets |r| to |a| doubled. +#if defined(OPENSSL_X86_64) +void ecp_nistz256_point_double_nohw(P256_POINT *r, const P256_POINT *a); +void ecp_nistz256_point_double_adx(P256_POINT *r, const P256_POINT *a); +#else +void ecp_nistz256_point_double(P256_POINT *r, const P256_POINT *a); +#endif + +// ecp_nistz256_point_add adds |a| to |b| and places the result in |r|. +#if defined(OPENSSL_X86_64) +void ecp_nistz256_point_add_nohw(P256_POINT *r, const P256_POINT *a, + const P256_POINT *b); +void ecp_nistz256_point_add_adx(P256_POINT *r, const P256_POINT *a, + const P256_POINT *b); +#else +void ecp_nistz256_point_add(P256_POINT *r, const P256_POINT *a, + const P256_POINT *b); +#endif + +// ecp_nistz256_point_add_affine adds |a| to |b| and places the result in +// |r|. |a| and |b| must not represent the same point unless they are both +// infinity. +#if defined(OPENSSL_X86_64) +void ecp_nistz256_point_add_affine_adx(P256_POINT *r, const P256_POINT *a, + const P256_POINT_AFFINE *b); +void ecp_nistz256_point_add_affine_nohw(P256_POINT *r, const P256_POINT *a, + const P256_POINT_AFFINE *b); +#else +void ecp_nistz256_point_add_affine(P256_POINT *r, const P256_POINT *a, + const P256_POINT_AFFINE *b); +#endif + +#endif /* defined(OPENSSL_USE_NISTZ256) */ + +#endif // OPENSSL_HEADER_EC_P256_X86_64_H diff --git a/http/vendor/ring/crypto/fipsmodule/ec/p256.c b/http/vendor/ring/crypto/fipsmodule/ec/p256.c new file mode 100644 index 0000000..0117916 --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/ec/p256.c @@ -0,0 +1,539 @@ +// Copyright 2020 The BoringSSL Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// An implementation of the NIST P-256 elliptic curve point multiplication. +// 256-bit Montgomery form for 64 and 32-bit. Field operations are generated by +// Fiat, which lives in //third_party/fiat. + +#include + +#include "../../limbs/limbs.h" +#include "../../limbs/limbs.inl" + +#include "p256_shared.h" + +#include "../../internal.h" +#include "./util.h" + +#if !defined(OPENSSL_USE_NISTZ256) + +#if defined(_MSC_VER) && !defined(__clang__) +// '=': conversion from 'int64_t' to 'int32_t', possible loss of data +#pragma warning(disable: 4242) +// '=': conversion from 'int32_t' to 'uint8_t', possible loss of data +#pragma warning(disable: 4244) +// 'initializing': conversion from 'size_t' to 'fiat_p256_limb_t' +#pragma warning(disable: 4267) +#endif + +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic ignored "-Winline" +#endif + +#if defined(BORINGSSL_HAS_UINT128) +#if defined(__GNUC__) +#pragma GCC diagnostic ignored "-Wpedantic" +#endif +#include "../../../third_party/fiat/p256_64.h" +#elif defined(OPENSSL_64_BIT) +#include "../../../third_party/fiat/p256_64_msvc.h" +#else +#include "../../../third_party/fiat/p256_32.h" +#endif + + +// utility functions, handwritten + +#if defined(OPENSSL_64_BIT) +#define FIAT_P256_NLIMBS 4 +typedef uint64_t fiat_p256_limb_t; +typedef uint64_t fiat_p256_felem[FIAT_P256_NLIMBS]; +static const fiat_p256_felem fiat_p256_one = {0x1, 0xffffffff00000000, + 0xffffffffffffffff, 0xfffffffe}; +#else // 64BIT; else 32BIT +#define FIAT_P256_NLIMBS 8 +typedef uint32_t fiat_p256_limb_t; +typedef uint32_t fiat_p256_felem[FIAT_P256_NLIMBS]; +static const fiat_p256_felem fiat_p256_one = { + 0x1, 0x0, 0x0, 0xffffffff, 0xffffffff, 0xffffffff, 0xfffffffe, 0x0}; +#endif // 64BIT + + +static fiat_p256_limb_t fiat_p256_nz( + const fiat_p256_limb_t in1[FIAT_P256_NLIMBS]) { + fiat_p256_limb_t ret; + fiat_p256_nonzero(&ret, in1); + return ret; +} + +static void fiat_p256_copy(fiat_p256_limb_t out[FIAT_P256_NLIMBS], + const fiat_p256_limb_t in1[FIAT_P256_NLIMBS]) { + for (size_t i = 0; i < FIAT_P256_NLIMBS; i++) { + out[i] = in1[i]; + } +} + +static void fiat_p256_cmovznz(fiat_p256_limb_t out[FIAT_P256_NLIMBS], + fiat_p256_limb_t t, + const fiat_p256_limb_t z[FIAT_P256_NLIMBS], + const fiat_p256_limb_t nz[FIAT_P256_NLIMBS]) { + fiat_p256_selectznz(out, !!t, z, nz); +} + +static void fiat_p256_from_words(fiat_p256_felem out, + const Limb in[32 / sizeof(BN_ULONG)]) { + // Typically, |BN_ULONG| and |fiat_p256_limb_t| will be the same type, but on + // 64-bit platforms without |uint128_t|, they are different. However, on + // little-endian systems, |uint64_t[4]| and |uint32_t[8]| have the same + // layout. + OPENSSL_memcpy(out, in, 32); +} + +static void fiat_p256_to_words(Limb out[32 / sizeof(BN_ULONG)], const fiat_p256_felem in) { + // See |fiat_p256_from_words|. + OPENSSL_memcpy(out, in, 32); +} + + +// Group operations +// ---------------- +// +// Building on top of the field operations we have the operations on the +// elliptic curve group itself. Points on the curve are represented in Jacobian +// coordinates. +// +// Both operations were transcribed to Coq and proven to correspond to naive +// implementations using Affine coordinates, for all suitable fields. In the +// Coq proofs, issues of constant-time execution and memory layout (aliasing) +// conventions were not considered. Specification of affine coordinates: +// +// As a sanity check, a proof that these points form a commutative group: +// + +// fiat_p256_point_double calculates 2*(x_in, y_in, z_in) +// +// The method is taken from: +// http://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b +// +// Coq transcription and correctness proof: +// +// +// +// Outputs can equal corresponding inputs, i.e., x_out == x_in is allowed. +// while x_out == y_in is not (maybe this works, but it's not tested). +static void fiat_p256_point_double(fiat_p256_felem x_out, fiat_p256_felem y_out, + fiat_p256_felem z_out, + const fiat_p256_felem x_in, + const fiat_p256_felem y_in, + const fiat_p256_felem z_in) { + fiat_p256_felem delta, gamma, beta, ftmp, ftmp2, tmptmp, alpha, fourbeta; + // delta = z^2 + fiat_p256_square(delta, z_in); + // gamma = y^2 + fiat_p256_square(gamma, y_in); + // beta = x*gamma + fiat_p256_mul(beta, x_in, gamma); + + // alpha = 3*(x-delta)*(x+delta) + fiat_p256_sub(ftmp, x_in, delta); + fiat_p256_add(ftmp2, x_in, delta); + + fiat_p256_add(tmptmp, ftmp2, ftmp2); + fiat_p256_add(ftmp2, ftmp2, tmptmp); + fiat_p256_mul(alpha, ftmp, ftmp2); + + // x' = alpha^2 - 8*beta + fiat_p256_square(x_out, alpha); + fiat_p256_add(fourbeta, beta, beta); + fiat_p256_add(fourbeta, fourbeta, fourbeta); + fiat_p256_add(tmptmp, fourbeta, fourbeta); + fiat_p256_sub(x_out, x_out, tmptmp); + + // z' = (y + z)^2 - gamma - delta + fiat_p256_add(delta, gamma, delta); + fiat_p256_add(ftmp, y_in, z_in); + fiat_p256_square(z_out, ftmp); + fiat_p256_sub(z_out, z_out, delta); + + // y' = alpha*(4*beta - x') - 8*gamma^2 + fiat_p256_sub(y_out, fourbeta, x_out); + fiat_p256_add(gamma, gamma, gamma); + fiat_p256_square(gamma, gamma); + fiat_p256_mul(y_out, alpha, y_out); + fiat_p256_add(gamma, gamma, gamma); + fiat_p256_sub(y_out, y_out, gamma); +} + +// fiat_p256_point_add calculates (x1, y1, z1) + (x2, y2, z2) +// +// The method is taken from: +// http://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#addition-add-2007-bl, +// adapted for mixed addition (z2 = 1, or z2 = 0 for the point at infinity). +// +// Coq transcription and correctness proof: +// +// +// +// This function includes a branch for checking whether the two input points +// are equal, (while not equal to the point at infinity). This case never +// happens during single point multiplication, so there is no timing leak for +// ECDH or ECDSA signing. +static void fiat_p256_point_add(fiat_p256_felem x3, fiat_p256_felem y3, + fiat_p256_felem z3, const fiat_p256_felem x1, + const fiat_p256_felem y1, + const fiat_p256_felem z1, const int mixed, + const fiat_p256_felem x2, + const fiat_p256_felem y2, + const fiat_p256_felem z2) { + fiat_p256_felem x_out, y_out, z_out; + fiat_p256_limb_t z1nz = fiat_p256_nz(z1); + fiat_p256_limb_t z2nz = fiat_p256_nz(z2); + + // z1z1 = z1z1 = z1**2 + fiat_p256_felem z1z1; + fiat_p256_square(z1z1, z1); + + fiat_p256_felem u1, s1, two_z1z2; + if (!mixed) { + // z2z2 = z2**2 + fiat_p256_felem z2z2; + fiat_p256_square(z2z2, z2); + + // u1 = x1*z2z2 + fiat_p256_mul(u1, x1, z2z2); + + // two_z1z2 = (z1 + z2)**2 - (z1z1 + z2z2) = 2z1z2 + fiat_p256_add(two_z1z2, z1, z2); + fiat_p256_square(two_z1z2, two_z1z2); + fiat_p256_sub(two_z1z2, two_z1z2, z1z1); + fiat_p256_sub(two_z1z2, two_z1z2, z2z2); + + // s1 = y1 * z2**3 + fiat_p256_mul(s1, z2, z2z2); + fiat_p256_mul(s1, s1, y1); + } else { + // We'll assume z2 = 1 (special case z2 = 0 is handled later). + + // u1 = x1*z2z2 + fiat_p256_copy(u1, x1); + // two_z1z2 = 2z1z2 + fiat_p256_add(two_z1z2, z1, z1); + // s1 = y1 * z2**3 + fiat_p256_copy(s1, y1); + } + + // u2 = x2*z1z1 + fiat_p256_felem u2; + fiat_p256_mul(u2, x2, z1z1); + + // h = u2 - u1 + fiat_p256_felem h; + fiat_p256_sub(h, u2, u1); + + fiat_p256_limb_t xneq = fiat_p256_nz(h); + + // z_out = two_z1z2 * h + fiat_p256_mul(z_out, h, two_z1z2); + + // z1z1z1 = z1 * z1z1 + fiat_p256_felem z1z1z1; + fiat_p256_mul(z1z1z1, z1, z1z1); + + // s2 = y2 * z1**3 + fiat_p256_felem s2; + fiat_p256_mul(s2, y2, z1z1z1); + + // r = (s2 - s1)*2 + fiat_p256_felem r; + fiat_p256_sub(r, s2, s1); + fiat_p256_add(r, r, r); + + fiat_p256_limb_t yneq = fiat_p256_nz(r); + + fiat_p256_limb_t is_nontrivial_double = constant_time_is_zero_w(xneq | yneq) & + ~constant_time_is_zero_w(z1nz) & + ~constant_time_is_zero_w(z2nz); + if (constant_time_declassify_w(is_nontrivial_double)) { + fiat_p256_point_double(x3, y3, z3, x1, y1, z1); + return; + } + + // I = (2h)**2 + fiat_p256_felem i; + fiat_p256_add(i, h, h); + fiat_p256_square(i, i); + + // J = h * I + fiat_p256_felem j; + fiat_p256_mul(j, h, i); + + // V = U1 * I + fiat_p256_felem v; + fiat_p256_mul(v, u1, i); + + // x_out = r**2 - J - 2V + fiat_p256_square(x_out, r); + fiat_p256_sub(x_out, x_out, j); + fiat_p256_sub(x_out, x_out, v); + fiat_p256_sub(x_out, x_out, v); + + // y_out = r(V-x_out) - 2 * s1 * J + fiat_p256_sub(y_out, v, x_out); + fiat_p256_mul(y_out, y_out, r); + fiat_p256_felem s1j; + fiat_p256_mul(s1j, s1, j); + fiat_p256_sub(y_out, y_out, s1j); + fiat_p256_sub(y_out, y_out, s1j); + + fiat_p256_cmovznz(x_out, z1nz, x2, x_out); + fiat_p256_cmovznz(x3, z2nz, x1, x_out); + fiat_p256_cmovznz(y_out, z1nz, y2, y_out); + fiat_p256_cmovznz(y3, z2nz, y1, y_out); + fiat_p256_cmovznz(z_out, z1nz, z2, z_out); + fiat_p256_cmovznz(z3, z2nz, z1, z_out); +} + +#include "./p256_table.h" + +// fiat_p256_select_point_affine selects the |idx-1|th point from a +// precomputation table and copies it to out. If |idx| is zero, the output is +// the point at infinity. +static void fiat_p256_select_point_affine( + const fiat_p256_limb_t idx, size_t size, + const fiat_p256_felem pre_comp[/*size*/][2], fiat_p256_felem out[3]) { + OPENSSL_memset(out, 0, sizeof(fiat_p256_felem) * 3); + for (size_t i = 0; i < size; i++) { + fiat_p256_limb_t mismatch = i ^ (idx - 1); + fiat_p256_cmovznz(out[0], mismatch, pre_comp[i][0], out[0]); + fiat_p256_cmovznz(out[1], mismatch, pre_comp[i][1], out[1]); + } + fiat_p256_cmovznz(out[2], idx, out[2], fiat_p256_one); +} + +// fiat_p256_select_point selects the |idx|th point from a precomputation table +// and copies it to out. +static void fiat_p256_select_point(const fiat_p256_limb_t idx, size_t size, + const fiat_p256_felem pre_comp[/*size*/][3], + fiat_p256_felem out[3]) { + OPENSSL_memset(out, 0, sizeof(fiat_p256_felem) * 3); + for (size_t i = 0; i < size; i++) { + fiat_p256_limb_t mismatch = i ^ idx; + fiat_p256_cmovznz(out[0], mismatch, pre_comp[i][0], out[0]); + fiat_p256_cmovznz(out[1], mismatch, pre_comp[i][1], out[1]); + fiat_p256_cmovznz(out[2], mismatch, pre_comp[i][2], out[2]); + } +} + +// fiat_p256_get_bit returns the |i|th bit in |in| +static crypto_word_t fiat_p256_get_bit(const Limb in[P256_LIMBS], int i) { + if (i < 0 || i >= 256) { + return 0; + } +#if defined(OPENSSL_64_BIT) + OPENSSL_STATIC_ASSERT(sizeof(Limb) == 8, "BN_ULONG was not 64-bit"); + return (in[i >> 6] >> (i & 63)) & 1; +#else + OPENSSL_STATIC_ASSERT(sizeof(Limb) == 4, "BN_ULONG was not 32-bit"); + return (in[i >> 5] >> (i & 31)) & 1; +#endif +} + +void p256_point_mul(Limb r[3][P256_LIMBS], const Limb scalar[P256_LIMBS], + const Limb p_x[P256_LIMBS], const Limb p_y[P256_LIMBS]) { + debug_assert_nonsecret(r != NULL); + debug_assert_nonsecret(scalar != NULL); + debug_assert_nonsecret(p_x != NULL); + debug_assert_nonsecret(p_y != NULL); + + fiat_p256_felem p_pre_comp[17][3]; + OPENSSL_memset(&p_pre_comp, 0, sizeof(p_pre_comp)); + // Precompute multiples. + fiat_p256_from_words(p_pre_comp[1][0], p_x); + fiat_p256_from_words(p_pre_comp[1][1], p_y); + fiat_p256_copy(p_pre_comp[1][2], fiat_p256_one); + + for (size_t j = 2; j <= 16; ++j) { + if (j & 1) { + fiat_p256_point_add(p_pre_comp[j][0], p_pre_comp[j][1], p_pre_comp[j][2], + p_pre_comp[1][0], p_pre_comp[1][1], p_pre_comp[1][2], + 0, p_pre_comp[j - 1][0], p_pre_comp[j - 1][1], + p_pre_comp[j - 1][2]); + } else { + fiat_p256_point_double(p_pre_comp[j][0], p_pre_comp[j][1], + p_pre_comp[j][2], p_pre_comp[j / 2][0], + p_pre_comp[j / 2][1], p_pre_comp[j / 2][2]); + } + } + + // Set nq to the point at infinity. + fiat_p256_felem nq[3] = {{0}, {0}, {0}}, ftmp, tmp[3]; + + // Loop over |scalar| msb-to-lsb, incorporating |p_pre_comp| every 5th round. + int skip = 1; // Save two point operations in the first round. + for (size_t i = 255; i < 256; i--) { + // double + if (!skip) { + fiat_p256_point_double(nq[0], nq[1], nq[2], nq[0], nq[1], nq[2]); + } + + // do other additions every 5 doublings + if (i % 5 == 0) { + crypto_word_t bits = fiat_p256_get_bit(scalar, i + 4) << 5; + bits |= fiat_p256_get_bit(scalar, i + 3) << 4; + bits |= fiat_p256_get_bit(scalar, i + 2) << 3; + bits |= fiat_p256_get_bit(scalar, i + 1) << 2; + bits |= fiat_p256_get_bit(scalar, i) << 1; + bits |= fiat_p256_get_bit(scalar, i - 1); + crypto_word_t sign, digit; + recode_scalar_bits(&sign, &digit, bits); + + // select the point to add or subtract, in constant time. + fiat_p256_select_point((fiat_p256_limb_t)digit, 17, + RING_CORE_POINTLESS_ARRAY_CONST_CAST((const fiat_p256_felem(*)[3]))p_pre_comp, + tmp); + fiat_p256_opp(ftmp, tmp[1]); // (X, -Y, Z) is the negative point. + fiat_p256_cmovznz(tmp[1], (fiat_p256_limb_t)sign, tmp[1], ftmp); + + if (!skip) { + fiat_p256_point_add(nq[0], nq[1], nq[2], nq[0], nq[1], nq[2], + 0 /* mixed */, tmp[0], tmp[1], tmp[2]); + } else { + fiat_p256_copy(nq[0], tmp[0]); + fiat_p256_copy(nq[1], tmp[1]); + fiat_p256_copy(nq[2], tmp[2]); + skip = 0; + } + } + } + + fiat_p256_to_words(r[0], nq[0]); + fiat_p256_to_words(r[1], nq[1]); + fiat_p256_to_words(r[2], nq[2]); +} + +void p256_point_mul_base(Limb r[3][P256_LIMBS], const Limb scalar[P256_LIMBS]) { + // Set nq to the point at infinity. + fiat_p256_felem nq[3] = {{0}, {0}, {0}}, tmp[3]; + + int skip = 1; // Save two point operations in the first round. + for (size_t i = 31; i < 32; i--) { + if (!skip) { + fiat_p256_point_double(nq[0], nq[1], nq[2], nq[0], nq[1], nq[2]); + } + + // First, look 32 bits upwards. + crypto_word_t bits = fiat_p256_get_bit(scalar, i + 224) << 3; + bits |= fiat_p256_get_bit(scalar, i + 160) << 2; + bits |= fiat_p256_get_bit(scalar, i + 96) << 1; + bits |= fiat_p256_get_bit(scalar, i + 32); + // Select the point to add, in constant time. + fiat_p256_select_point_affine((fiat_p256_limb_t)bits, 15, + fiat_p256_g_pre_comp[1], tmp); + + if (!skip) { + fiat_p256_point_add(nq[0], nq[1], nq[2], nq[0], nq[1], nq[2], + 1 /* mixed */, tmp[0], tmp[1], tmp[2]); + } else { + fiat_p256_copy(nq[0], tmp[0]); + fiat_p256_copy(nq[1], tmp[1]); + fiat_p256_copy(nq[2], tmp[2]); + skip = 0; + } + + // Second, look at the current position. + bits = fiat_p256_get_bit(scalar, i + 192) << 3; + bits |= fiat_p256_get_bit(scalar, i + 128) << 2; + bits |= fiat_p256_get_bit(scalar, i + 64) << 1; + bits |= fiat_p256_get_bit(scalar, i); + // Select the point to add, in constant time. + fiat_p256_select_point_affine((fiat_p256_limb_t)bits, 15, + fiat_p256_g_pre_comp[0], tmp); + fiat_p256_point_add(nq[0], nq[1], nq[2], nq[0], nq[1], nq[2], 1 /* mixed */, + tmp[0], tmp[1], tmp[2]); + } + + fiat_p256_to_words(r[0], nq[0]); + fiat_p256_to_words(r[1], nq[1]); + fiat_p256_to_words(r[2], nq[2]); +} + +void p256_mul_mont(Limb r[P256_LIMBS], const Limb a[P256_LIMBS], + const Limb b[P256_LIMBS]) { + fiat_p256_felem a_, b_; + fiat_p256_from_words(a_, a); + fiat_p256_from_words(b_, b); + fiat_p256_mul(a_, a_, b_); + fiat_p256_to_words(r, a_); +} + +void p256_sqr_mont(Limb r[P256_LIMBS], const Limb a[P256_LIMBS]) { + fiat_p256_felem x; + fiat_p256_from_words(x, a); + fiat_p256_square(x, x); + fiat_p256_to_words(r, x); +} + +void p256_point_add(Limb r[3][P256_LIMBS], const Limb a[3][P256_LIMBS], + const Limb b[3][P256_LIMBS]) { + fiat_p256_felem x1, y1, z1, x2, y2, z2; + fiat_p256_from_words(x1, a[0]); + fiat_p256_from_words(y1, a[1]); + fiat_p256_from_words(z1, a[2]); + fiat_p256_from_words(x2, b[0]); + fiat_p256_from_words(y2, b[1]); + fiat_p256_from_words(z2, b[2]); + fiat_p256_point_add(x1, y1, z1, x1, y1, z1, 0 /* both Jacobian */, x2, y2, + z2); + fiat_p256_to_words(r[0], x1); + fiat_p256_to_words(r[1], y1); + fiat_p256_to_words(r[2], z1); +} + +void p256_point_double(Limb r[3][P256_LIMBS], const Limb a[3][P256_LIMBS]) { + fiat_p256_felem x, y, z; + fiat_p256_from_words(x, a[0]); + fiat_p256_from_words(y, a[1]); + fiat_p256_from_words(z, a[2]); + fiat_p256_point_double(x, y, z, x, y, z); + fiat_p256_to_words(r[0], x); + fiat_p256_to_words(r[1], y); + fiat_p256_to_words(r[2], z); +} + +// For testing only. +void p256_point_add_affine(Limb r[3][P256_LIMBS], const Limb a[3][P256_LIMBS], + const Limb b[2][P256_LIMBS]) { + fiat_p256_felem x1, y1, z1, x2, y2; + fiat_p256_from_words(x1, a[0]); + fiat_p256_from_words(y1, a[1]); + fiat_p256_from_words(z1, a[2]); + fiat_p256_from_words(x2, b[0]); + fiat_p256_from_words(y2, b[1]); + + fiat_p256_felem z2 = {0}; + fiat_p256_cmovznz(z2, fiat_p256_nz(x2) & fiat_p256_nz(y2), z2, fiat_p256_one); + + fiat_p256_point_add(x1, y1, z1, x1, y1, z1, 1 /* mixed */, x2, y2, z2); + + fiat_p256_to_words(r[0], x1); + fiat_p256_to_words(r[1], y1); + fiat_p256_to_words(r[2], z1); +} + +#endif diff --git a/http/vendor/ring/crypto/fipsmodule/ec/p256_shared.h b/http/vendor/ring/crypto/fipsmodule/ec/p256_shared.h new file mode 100644 index 0000000..ef717b1 --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/ec/p256_shared.h @@ -0,0 +1,62 @@ +// Copyright 2014-2016 The OpenSSL Project Authors. All Rights Reserved. +// Copyright (c) 2014, Intel Corporation. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Originally written by Shay Gueron (1, 2), and Vlad Krasnov (1) +// (1) Intel Corporation, Israel Development Center, Haifa, Israel +// (2) University of Haifa, Israel +// +// Reference: +// S.Gueron and V.Krasnov, "Fast Prime Field Elliptic Curve Cryptography with +// 256 Bit Primes" + +#ifndef OPENSSL_HEADER_EC_P256_SHARED_H +#define OPENSSL_HEADER_EC_P256_SHARED_H + +#include "ring-core/base.h" + +#include "../bn/internal.h" + +#if !defined(OPENSSL_NO_ASM) && \ + (defined(OPENSSL_X86_64) || defined(OPENSSL_AARCH64)) && \ + !defined(OPENSSL_SMALL) +# define OPENSSL_USE_NISTZ256 +#endif + +// P-256 field operations. +// +// An element mod P in P-256 is represented as a little-endian array of +// |P256_LIMBS| |BN_ULONG|s, spanning the full range of values. +// +// The following functions take fully-reduced inputs mod P and give +// fully-reduced outputs. They may be used in-place. + +#define P256_LIMBS (256 / BN_BITS2) + +// A P256_POINT represents a P-256 point in Jacobian coordinates. +typedef struct { + BN_ULONG X[P256_LIMBS]; + BN_ULONG Y[P256_LIMBS]; + BN_ULONG Z[P256_LIMBS]; +} P256_POINT; + +typedef unsigned char P256_SCALAR_BYTES[33]; + +static inline void p256_scalar_bytes_from_limbs( + P256_SCALAR_BYTES bytes_out, const BN_ULONG limbs[P256_LIMBS]) { + OPENSSL_memcpy(bytes_out, limbs, 32); + bytes_out[32] = 0; +} + +#endif /* !defined(OPENSSL_USE_NISTZ256) */ diff --git a/http/vendor/ring/crypto/fipsmodule/ec/p256_table.h b/http/vendor/ring/crypto/fipsmodule/ec/p256_table.h new file mode 100644 index 0000000..e16eaba --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/ec/p256_table.h @@ -0,0 +1,297 @@ +// Copyright 2020 The BoringSSL Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// This file is generated by make_tables.go. + +// Base point pre computation +// -------------------------- +// +// Two different sorts of precomputed tables are used in the following code. +// Each contain various points on the curve, where each point is three field +// elements (x, y, z). +// +// For the base point table, z is usually 1 (0 for the point at infinity). +// This table has 2 * 16 elements, starting with the following: +// index | bits | point +// ------+---------+------------------------------ +// 0 | 0 0 0 0 | 0G +// 1 | 0 0 0 1 | 1G +// 2 | 0 0 1 0 | 2^64G +// 3 | 0 0 1 1 | (2^64 + 1)G +// 4 | 0 1 0 0 | 2^128G +// 5 | 0 1 0 1 | (2^128 + 1)G +// 6 | 0 1 1 0 | (2^128 + 2^64)G +// 7 | 0 1 1 1 | (2^128 + 2^64 + 1)G +// 8 | 1 0 0 0 | 2^192G +// 9 | 1 0 0 1 | (2^192 + 1)G +// 10 | 1 0 1 0 | (2^192 + 2^64)G +// 11 | 1 0 1 1 | (2^192 + 2^64 + 1)G +// 12 | 1 1 0 0 | (2^192 + 2^128)G +// 13 | 1 1 0 1 | (2^192 + 2^128 + 1)G +// 14 | 1 1 1 0 | (2^192 + 2^128 + 2^64)G +// 15 | 1 1 1 1 | (2^192 + 2^128 + 2^64 + 1)G +// followed by a copy of this with each element multiplied by 2^32. +// +// The reason for this is so that we can clock bits into four different +// locations when doing simple scalar multiplies against the base point, +// and then another four locations using the second 16 elements. +// +// Tables for other points have table[i] = iG for i in 0 .. 16. + +// fiat_p256_g_pre_comp is the table of precomputed base points +#if defined(OPENSSL_64_BIT) +static const fiat_p256_felem fiat_p256_g_pre_comp[2][15][2] = { + {{{0x79e730d418a9143c, 0x75ba95fc5fedb601, 0x79fb732b77622510, + 0x18905f76a53755c6}, + {0xddf25357ce95560a, 0x8b4ab8e4ba19e45c, 0xd2e88688dd21f325, + 0x8571ff1825885d85}}, + {{0x4f922fc516a0d2bb, 0x0d5cc16c1a623499, 0x9241cf3a57c62c8b, + 0x2f5e6961fd1b667f}, + {0x5c15c70bf5a01797, 0x3d20b44d60956192, 0x04911b37071fdb52, + 0xf648f9168d6f0f7b}}, + {{0x9e566847e137bbbc, 0xe434469e8a6a0bec, 0xb1c4276179d73463, + 0x5abe0285133d0015}, + {0x92aa837cc04c7dab, 0x573d9f4c43260c07, 0x0c93156278e6cc37, + 0x94bb725b6b6f7383}}, + {{0x62a8c244bfe20925, 0x91c19ac38fdce867, 0x5a96a5d5dd387063, + 0x61d587d421d324f6}, + {0xe87673a2a37173ea, 0x2384800853778b65, 0x10f8441e05bab43e, + 0xfa11fe124621efbe}}, + {{0x1c891f2b2cb19ffd, 0x01ba8d5bb1923c23, 0xb6d03d678ac5ca8e, + 0x586eb04c1f13bedc}, + {0x0c35c6e527e8ed09, 0x1e81a33c1819ede2, 0x278fd6c056c652fa, + 0x19d5ac0870864f11}}, + {{0x62577734d2b533d5, 0x673b8af6a1bdddc0, 0x577e7c9aa79ec293, + 0xbb6de651c3b266b1}, + {0xe7e9303ab65259b3, 0xd6a0afd3d03a7480, 0xc5ac83d19b3cfc27, + 0x60b4619a5d18b99b}}, + {{0xbd6a38e11ae5aa1c, 0xb8b7652b49e73658, 0x0b130014ee5f87ed, + 0x9d0f27b2aeebffcd}, + {0xca9246317a730a55, 0x9c955b2fddbbc83a, 0x07c1dfe0ac019a71, + 0x244a566d356ec48d}}, + {{0x56f8410ef4f8b16a, 0x97241afec47b266a, 0x0a406b8e6d9c87c1, + 0x803f3e02cd42ab1b}, + {0x7f0309a804dbec69, 0xa83b85f73bbad05f, 0xc6097273ad8e197f, + 0xc097440e5067adc1}}, + {{0x846a56f2c379ab34, 0xa8ee068b841df8d1, 0x20314459176c68ef, + 0xf1af32d5915f1f30}, + {0x99c375315d75bd50, 0x837cffbaf72f67bc, 0x0613a41848d7723f, + 0x23d0f130e2d41c8b}}, + {{0xed93e225d5be5a2b, 0x6fe799835934f3c6, 0x4314092622626ffc, + 0x50bbb4d97990216a}, + {0x378191c6e57ec63e, 0x65422c40181dcdb2, 0x41a8099b0236e0f6, + 0x2b10011801fe49c3}}, + {{0xfc68b5c59b391593, 0xc385f5a2598270fc, 0x7144f3aad19adcbb, + 0xdd55899983fbae0c}, + {0x93b88b8e74b82ff4, 0xd2e03c4071e734c9, 0x9a7a9eaf43c0322a, + 0xe6e4c551149d6041}}, + {{0x5fe14bfe80ec21fe, 0xf6ce116ac255be82, 0x98bc5a072f4a5d67, + 0xfad27148db7e63af}, + {0x90c0b6ac29ab05b3, 0x37a9a83c4e251ae6, 0x0a7dc875c2aade7d, + 0x77387de39f0e1a84}}, + {{0x1e9ecc49a56c0dd7, 0xa5cffcd846086c74, 0x8f7a1408f505aece, + 0xb37b85c0bef0c47e}, + {0x3596b6e4cc0e6a8f, 0xfd6d4bbf6b388f23, 0xaba453fac39cef4e, + 0x9c135ac8f9f628d5}}, + {{0x0a1c729495c8f8be, 0x2961c4803bf362bf, 0x9e418403df63d4ac, + 0xc109f9cb91ece900}, + {0xc2d095d058945705, 0xb9083d96ddeb85c0, 0x84692b8d7a40449b, + 0x9bc3344f2eee1ee1}}, + {{0x0d5ae35642913074, 0x55491b2748a542b1, 0x469ca665b310732a, + 0x29591d525f1a4cc1}, + {0xe76f5b6bb84f983f, 0xbe7eef419f5f84e1, 0x1200d49680baa189, + 0x6376551f18ef332c}}}, + {{{0x202886024147519a, 0xd0981eac26b372f0, 0xa9d4a7caa785ebc8, + 0xd953c50ddbdf58e9}, + {0x9d6361ccfd590f8f, 0x72e9626b44e6c917, 0x7fd9611022eb64cf, + 0x863ebb7e9eb288f3}}, + {{0x4fe7ee31b0e63d34, 0xf4600572a9e54fab, 0xc0493334d5e7b5a4, + 0x8589fb9206d54831}, + {0xaa70f5cc6583553a, 0x0879094ae25649e5, 0xcc90450710044652, + 0xebb0696d02541c4f}}, + {{0xabbaa0c03b89da99, 0xa6f2d79eb8284022, 0x27847862b81c05e8, + 0x337a4b5905e54d63}, + {0x3c67500d21f7794a, 0x207005b77d6d7f61, 0x0a5a378104cfd6e8, + 0x0d65e0d5f4c2fbd6}}, + {{0xd433e50f6d3549cf, 0x6f33696ffacd665e, 0x695bfdacce11fcb4, + 0x810ee252af7c9860}, + {0x65450fe17159bb2c, 0xf7dfbebe758b357b, 0x2b057e74d69fea72, + 0xd485717a92731745}}, + {{0xce1f69bbe83f7669, 0x09f8ae8272877d6b, 0x9548ae543244278d, + 0x207755dee3c2c19c}, + {0x87bd61d96fef1945, 0x18813cefb12d28c3, 0x9fbcd1d672df64aa, + 0x48dc5ee57154b00d}}, + {{0xef0f469ef49a3154, 0x3e85a5956e2b2e9a, 0x45aaec1eaa924a9c, + 0xaa12dfc8a09e4719}, + {0x26f272274df69f1d, 0xe0e4c82ca2ff5e73, 0xb9d8ce73b7a9dd44, + 0x6c036e73e48ca901}}, + {{0xe1e421e1a47153f0, 0xb86c3b79920418c9, 0x93bdce87705d7672, + 0xf25ae793cab79a77}, + {0x1f3194a36d869d0c, 0x9d55c8824986c264, 0x49fb5ea3096e945e, + 0x39b8e65313db0a3e}}, + {{0xe3417bc035d0b34a, 0x440b386b8327c0a7, 0x8fb7262dac0362d1, + 0x2c41114ce0cdf943}, + {0x2ba5cef1ad95a0b1, 0xc09b37a867d54362, 0x26d6cdd201e486c9, + 0x20477abf42ff9297}}, + {{0x0f121b41bc0a67d2, 0x62d4760a444d248a, 0x0e044f1d659b4737, + 0x08fde365250bb4a8}, + {0xaceec3da848bf287, 0xc2a62182d3369d6e, 0x3582dfdc92449482, + 0x2f7e2fd2565d6cd7}}, + {{0x0a0122b5178a876b, 0x51ff96ff085104b4, 0x050b31ab14f29f76, + 0x84abb28b5f87d4e6}, + {0xd5ed439f8270790a, 0x2d6cb59d85e3f46b, 0x75f55c1b6c1e2212, + 0xe5436f6717655640}}, + {{0xc2965ecc9aeb596d, 0x01ea03e7023c92b4, 0x4704b4b62e013961, + 0x0ca8fd3f905ea367}, + {0x92523a42551b2b61, 0x1eb7a89c390fcd06, 0xe7f1d2be0392a63e, + 0x96dca2644ddb0c33}}, + {{0x231c210e15339848, 0xe87a28e870778c8d, 0x9d1de6616956e170, + 0x4ac3c9382bb09c0b}, + {0x19be05516998987d, 0x8b2376c4ae09f4d6, 0x1de0b7651a3f933d, + 0x380d94c7e39705f4}}, + {{0x3685954b8c31c31d, 0x68533d005bf21a0c, 0x0bd7626e75c79ec9, + 0xca17754742c69d54}, + {0xcc6edafff6d2dbb2, 0xfd0d8cbd174a9d18, 0x875e8793aa4578e8, + 0xa976a7139cab2ce6}}, + {{0xce37ab11b43ea1db, 0x0a7ff1a95259d292, 0x851b02218f84f186, + 0xa7222beadefaad13}, + {0xa2ac78ec2b0a9144, 0x5a024051f2fa59c5, 0x91d1eca56147ce38, + 0xbe94d523bc2ac690}}, + {{0x2d8daefd79ec1a0f, 0x3bbcd6fdceb39c97, 0xf5575ffc58f61a95, + 0xdbd986c4adf7b420}, + {0x81aa881415f39eb7, 0x6ee2fcf5b98d976c, 0x5465475dcf2f717d, + 0x8e24d3c46860bbd0}}}}; +#else +static const fiat_p256_felem fiat_p256_g_pre_comp[2][15][2] = { + {{{0x18a9143c, 0x79e730d4, 0x5fedb601, 0x75ba95fc, 0x77622510, 0x79fb732b, + 0xa53755c6, 0x18905f76}, + {0xce95560a, 0xddf25357, 0xba19e45c, 0x8b4ab8e4, 0xdd21f325, 0xd2e88688, + 0x25885d85, 0x8571ff18}}, + {{0x16a0d2bb, 0x4f922fc5, 0x1a623499, 0x0d5cc16c, 0x57c62c8b, 0x9241cf3a, + 0xfd1b667f, 0x2f5e6961}, + {0xf5a01797, 0x5c15c70b, 0x60956192, 0x3d20b44d, 0x071fdb52, 0x04911b37, + 0x8d6f0f7b, 0xf648f916}}, + {{0xe137bbbc, 0x9e566847, 0x8a6a0bec, 0xe434469e, 0x79d73463, 0xb1c42761, + 0x133d0015, 0x5abe0285}, + {0xc04c7dab, 0x92aa837c, 0x43260c07, 0x573d9f4c, 0x78e6cc37, 0x0c931562, + 0x6b6f7383, 0x94bb725b}}, + {{0xbfe20925, 0x62a8c244, 0x8fdce867, 0x91c19ac3, 0xdd387063, 0x5a96a5d5, + 0x21d324f6, 0x61d587d4}, + {0xa37173ea, 0xe87673a2, 0x53778b65, 0x23848008, 0x05bab43e, 0x10f8441e, + 0x4621efbe, 0xfa11fe12}}, + {{0x2cb19ffd, 0x1c891f2b, 0xb1923c23, 0x01ba8d5b, 0x8ac5ca8e, 0xb6d03d67, + 0x1f13bedc, 0x586eb04c}, + {0x27e8ed09, 0x0c35c6e5, 0x1819ede2, 0x1e81a33c, 0x56c652fa, 0x278fd6c0, + 0x70864f11, 0x19d5ac08}}, + {{0xd2b533d5, 0x62577734, 0xa1bdddc0, 0x673b8af6, 0xa79ec293, 0x577e7c9a, + 0xc3b266b1, 0xbb6de651}, + {0xb65259b3, 0xe7e9303a, 0xd03a7480, 0xd6a0afd3, 0x9b3cfc27, 0xc5ac83d1, + 0x5d18b99b, 0x60b4619a}}, + {{0x1ae5aa1c, 0xbd6a38e1, 0x49e73658, 0xb8b7652b, 0xee5f87ed, 0x0b130014, + 0xaeebffcd, 0x9d0f27b2}, + {0x7a730a55, 0xca924631, 0xddbbc83a, 0x9c955b2f, 0xac019a71, 0x07c1dfe0, + 0x356ec48d, 0x244a566d}}, + {{0xf4f8b16a, 0x56f8410e, 0xc47b266a, 0x97241afe, 0x6d9c87c1, 0x0a406b8e, + 0xcd42ab1b, 0x803f3e02}, + {0x04dbec69, 0x7f0309a8, 0x3bbad05f, 0xa83b85f7, 0xad8e197f, 0xc6097273, + 0x5067adc1, 0xc097440e}}, + {{0xc379ab34, 0x846a56f2, 0x841df8d1, 0xa8ee068b, 0x176c68ef, 0x20314459, + 0x915f1f30, 0xf1af32d5}, + {0x5d75bd50, 0x99c37531, 0xf72f67bc, 0x837cffba, 0x48d7723f, 0x0613a418, + 0xe2d41c8b, 0x23d0f130}}, + {{0xd5be5a2b, 0xed93e225, 0x5934f3c6, 0x6fe79983, 0x22626ffc, 0x43140926, + 0x7990216a, 0x50bbb4d9}, + {0xe57ec63e, 0x378191c6, 0x181dcdb2, 0x65422c40, 0x0236e0f6, 0x41a8099b, + 0x01fe49c3, 0x2b100118}}, + {{0x9b391593, 0xfc68b5c5, 0x598270fc, 0xc385f5a2, 0xd19adcbb, 0x7144f3aa, + 0x83fbae0c, 0xdd558999}, + {0x74b82ff4, 0x93b88b8e, 0x71e734c9, 0xd2e03c40, 0x43c0322a, 0x9a7a9eaf, + 0x149d6041, 0xe6e4c551}}, + {{0x80ec21fe, 0x5fe14bfe, 0xc255be82, 0xf6ce116a, 0x2f4a5d67, 0x98bc5a07, + 0xdb7e63af, 0xfad27148}, + {0x29ab05b3, 0x90c0b6ac, 0x4e251ae6, 0x37a9a83c, 0xc2aade7d, 0x0a7dc875, + 0x9f0e1a84, 0x77387de3}}, + {{0xa56c0dd7, 0x1e9ecc49, 0x46086c74, 0xa5cffcd8, 0xf505aece, 0x8f7a1408, + 0xbef0c47e, 0xb37b85c0}, + {0xcc0e6a8f, 0x3596b6e4, 0x6b388f23, 0xfd6d4bbf, 0xc39cef4e, 0xaba453fa, + 0xf9f628d5, 0x9c135ac8}}, + {{0x95c8f8be, 0x0a1c7294, 0x3bf362bf, 0x2961c480, 0xdf63d4ac, 0x9e418403, + 0x91ece900, 0xc109f9cb}, + {0x58945705, 0xc2d095d0, 0xddeb85c0, 0xb9083d96, 0x7a40449b, 0x84692b8d, + 0x2eee1ee1, 0x9bc3344f}}, + {{0x42913074, 0x0d5ae356, 0x48a542b1, 0x55491b27, 0xb310732a, 0x469ca665, + 0x5f1a4cc1, 0x29591d52}, + {0xb84f983f, 0xe76f5b6b, 0x9f5f84e1, 0xbe7eef41, 0x80baa189, 0x1200d496, + 0x18ef332c, 0x6376551f}}}, + {{{0x4147519a, 0x20288602, 0x26b372f0, 0xd0981eac, 0xa785ebc8, 0xa9d4a7ca, + 0xdbdf58e9, 0xd953c50d}, + {0xfd590f8f, 0x9d6361cc, 0x44e6c917, 0x72e9626b, 0x22eb64cf, 0x7fd96110, + 0x9eb288f3, 0x863ebb7e}}, + {{0xb0e63d34, 0x4fe7ee31, 0xa9e54fab, 0xf4600572, 0xd5e7b5a4, 0xc0493334, + 0x06d54831, 0x8589fb92}, + {0x6583553a, 0xaa70f5cc, 0xe25649e5, 0x0879094a, 0x10044652, 0xcc904507, + 0x02541c4f, 0xebb0696d}}, + {{0x3b89da99, 0xabbaa0c0, 0xb8284022, 0xa6f2d79e, 0xb81c05e8, 0x27847862, + 0x05e54d63, 0x337a4b59}, + {0x21f7794a, 0x3c67500d, 0x7d6d7f61, 0x207005b7, 0x04cfd6e8, 0x0a5a3781, + 0xf4c2fbd6, 0x0d65e0d5}}, + {{0x6d3549cf, 0xd433e50f, 0xfacd665e, 0x6f33696f, 0xce11fcb4, 0x695bfdac, + 0xaf7c9860, 0x810ee252}, + {0x7159bb2c, 0x65450fe1, 0x758b357b, 0xf7dfbebe, 0xd69fea72, 0x2b057e74, + 0x92731745, 0xd485717a}}, + {{0xe83f7669, 0xce1f69bb, 0x72877d6b, 0x09f8ae82, 0x3244278d, 0x9548ae54, + 0xe3c2c19c, 0x207755de}, + {0x6fef1945, 0x87bd61d9, 0xb12d28c3, 0x18813cef, 0x72df64aa, 0x9fbcd1d6, + 0x7154b00d, 0x48dc5ee5}}, + {{0xf49a3154, 0xef0f469e, 0x6e2b2e9a, 0x3e85a595, 0xaa924a9c, 0x45aaec1e, + 0xa09e4719, 0xaa12dfc8}, + {0x4df69f1d, 0x26f27227, 0xa2ff5e73, 0xe0e4c82c, 0xb7a9dd44, 0xb9d8ce73, + 0xe48ca901, 0x6c036e73}}, + {{0xa47153f0, 0xe1e421e1, 0x920418c9, 0xb86c3b79, 0x705d7672, 0x93bdce87, + 0xcab79a77, 0xf25ae793}, + {0x6d869d0c, 0x1f3194a3, 0x4986c264, 0x9d55c882, 0x096e945e, 0x49fb5ea3, + 0x13db0a3e, 0x39b8e653}}, + {{0x35d0b34a, 0xe3417bc0, 0x8327c0a7, 0x440b386b, 0xac0362d1, 0x8fb7262d, + 0xe0cdf943, 0x2c41114c}, + {0xad95a0b1, 0x2ba5cef1, 0x67d54362, 0xc09b37a8, 0x01e486c9, 0x26d6cdd2, + 0x42ff9297, 0x20477abf}}, + {{0xbc0a67d2, 0x0f121b41, 0x444d248a, 0x62d4760a, 0x659b4737, 0x0e044f1d, + 0x250bb4a8, 0x08fde365}, + {0x848bf287, 0xaceec3da, 0xd3369d6e, 0xc2a62182, 0x92449482, 0x3582dfdc, + 0x565d6cd7, 0x2f7e2fd2}}, + {{0x178a876b, 0x0a0122b5, 0x085104b4, 0x51ff96ff, 0x14f29f76, 0x050b31ab, + 0x5f87d4e6, 0x84abb28b}, + {0x8270790a, 0xd5ed439f, 0x85e3f46b, 0x2d6cb59d, 0x6c1e2212, 0x75f55c1b, + 0x17655640, 0xe5436f67}}, + {{0x9aeb596d, 0xc2965ecc, 0x023c92b4, 0x01ea03e7, 0x2e013961, 0x4704b4b6, + 0x905ea367, 0x0ca8fd3f}, + {0x551b2b61, 0x92523a42, 0x390fcd06, 0x1eb7a89c, 0x0392a63e, 0xe7f1d2be, + 0x4ddb0c33, 0x96dca264}}, + {{0x15339848, 0x231c210e, 0x70778c8d, 0xe87a28e8, 0x6956e170, 0x9d1de661, + 0x2bb09c0b, 0x4ac3c938}, + {0x6998987d, 0x19be0551, 0xae09f4d6, 0x8b2376c4, 0x1a3f933d, 0x1de0b765, + 0xe39705f4, 0x380d94c7}}, + {{0x8c31c31d, 0x3685954b, 0x5bf21a0c, 0x68533d00, 0x75c79ec9, 0x0bd7626e, + 0x42c69d54, 0xca177547}, + {0xf6d2dbb2, 0xcc6edaff, 0x174a9d18, 0xfd0d8cbd, 0xaa4578e8, 0x875e8793, + 0x9cab2ce6, 0xa976a713}}, + {{0xb43ea1db, 0xce37ab11, 0x5259d292, 0x0a7ff1a9, 0x8f84f186, 0x851b0221, + 0xdefaad13, 0xa7222bea}, + {0x2b0a9144, 0xa2ac78ec, 0xf2fa59c5, 0x5a024051, 0x6147ce38, 0x91d1eca5, + 0xbc2ac690, 0xbe94d523}}, + {{0x79ec1a0f, 0x2d8daefd, 0xceb39c97, 0x3bbcd6fd, 0x58f61a95, 0xf5575ffc, + 0xadf7b420, 0xdbd986c4}, + {0x15f39eb7, 0x81aa8814, 0xb98d976c, 0x6ee2fcf5, 0xcf2f717d, 0x5465475d, + 0x6860bbd0, 0x8e24d3c4}}}}; +#endif diff --git a/http/vendor/ring/crypto/fipsmodule/ec/util.h b/http/vendor/ring/crypto/fipsmodule/ec/util.h new file mode 100644 index 0000000..1fef3da --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/ec/util.h @@ -0,0 +1,258 @@ +// Copyright 2015 The BoringSSL Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +#include "../../internal.h" + +#if defined(__GNUC__) +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif + + +// This function looks at 5+1 scalar bits (5 current, 1 adjacent less +// significant bit), and recodes them into a signed digit for use in fast point +// multiplication: the use of signed rather than unsigned digits means that +// fewer points need to be precomputed, given that point inversion is easy (a +// precomputed point dP makes -dP available as well). +// +// BACKGROUND: +// +// Signed digits for multiplication were introduced by Booth ("A signed binary +// multiplication technique", Quart. Journ. Mech. and Applied Math., vol. IV, +// pt. 2 (1951), pp. 236-240), in that case for multiplication of integers. +// Booth's original encoding did not generally improve the density of nonzero +// digits over the binary representation, and was merely meant to simplify the +// handling of signed factors given in two's complement; but it has since been +// shown to be the basis of various signed-digit representations that do have +// further advantages, including the wNAF, using the following general +// approach: +// +// (1) Given a binary representation +// +// b_k ... b_2 b_1 b_0, +// +// of a nonnegative integer (b_k in {0, 1}), rewrite it in digits 0, 1, -1 +// by using bit-wise subtraction as follows: +// +// b_k b_(k-1) ... b_2 b_1 b_0 +// - b_k ... b_3 b_2 b_1 b_0 +// ----------------------------------------- +// s_(k+1) s_k ... s_3 s_2 s_1 s_0 +// +// A left-shift followed by subtraction of the original value yields a new +// representation of the same value, using signed bits s_i = b_(i-1) - b_i. +// This representation from Booth's paper has since appeared in the +// literature under a variety of different names including "reversed binary +// form", "alternating greedy expansion", "mutual opposite form", and +// "sign-alternating {+-1}-representation". +// +// An interesting property is that among the nonzero bits, values 1 and -1 +// strictly alternate. +// +// (2) Various window schemes can be applied to the Booth representation of +// integers: for example, right-to-left sliding windows yield the wNAF +// (a signed-digit encoding independently discovered by various researchers +// in the 1990s), and left-to-right sliding windows yield a left-to-right +// equivalent of the wNAF (independently discovered by various researchers +// around 2004). +// +// To prevent leaking information through side channels in point multiplication, +// we need to recode the given integer into a regular pattern: sliding windows +// as in wNAFs won't do, we need their fixed-window equivalent -- which is a few +// decades older: we'll be using the so-called "modified Booth encoding" due to +// MacSorley ("High-speed arithmetic in binary computers", Proc. IRE, vol. 49 +// (1961), pp. 67-91), in a radix-2^5 setting. That is, we always combine five +// signed bits into a signed digit: +// +// s_(5j + 4) s_(5j + 3) s_(5j + 2) s_(5j + 1) s_(5j) +// +// The sign-alternating property implies that the resulting digit values are +// integers from -16 to 16. +// +// Of course, we don't actually need to compute the signed digits s_i as an +// intermediate step (that's just a nice way to see how this scheme relates +// to the wNAF): a direct computation obtains the recoded digit from the +// six bits b_(5j + 4) ... b_(5j - 1). +// +// This function takes those six bits as an integer (0 .. 63), writing the +// recoded digit to *sign (0 for positive, 1 for negative) and *digit (absolute +// value, in the range 0 .. 16). Note that this integer essentially provides +// the input bits "shifted to the left" by one position: for example, the input +// to compute the least significant recoded digit, given that there's no bit +// b_-1, has to be b_4 b_3 b_2 b_1 b_0 0. +// +// DOUBLING CASE: +// +// Point addition formulas for short Weierstrass curves are often incomplete. +// Edge cases such as P + P or P + ∞ must be handled separately. This +// complicates constant-time requirements. P + ∞ cannot be avoided (any window +// may be zero) and is handled with constant-time selects. P + P (where P is not +// ∞) usually is not. Instead, windowing strategies are chosen to avoid this +// case. Whether this happens depends on the group order. +// +// Let w be the window width (in this function, w = 5). The non-trivial doubling +// case in single-point scalar multiplication may occur if and only if the +// 2^(w-1) bit of the group order is zero. +// +// Note the above only holds if the scalar is fully reduced and the group order +// is a prime that is much larger than 2^w. It also only holds when windows +// are applied from most significant to least significant, doubling between each +// window. It does not apply to more complex table strategies such as +// |EC_nistz256_method|. +// +// PROOF: +// +// Let n be the group order. Let l be the number of bits needed to represent n. +// Assume there exists some 0 <= k < n such that signed w-bit windowed +// multiplication hits the doubling case. +// +// Windowed multiplication consists of iterating over groups of s_i (defined +// above based on k's binary representation) from most to least significant. At +// iteration i (for i = ..., 3w, 2w, w, 0, starting from the most significant +// window), we: +// +// 1. Double the accumulator A, w times. Let A_i be the value of A at this +// point. +// +// 2. Set A to T_i + A_i, where T_i is a precomputed multiple of P +// corresponding to the window s_(i+w-1) ... s_i. +// +// Let j be the index such that A_j = T_j ≠ ∞. Looking at A_i and T_i as +// multiples of P, define a_i and t_i to be scalar coefficients of A_i and T_i. +// Thus a_j = t_j ≠ 0 (mod n). Note a_i and t_i may not be reduced mod n. t_i is +// the value of the w signed bits s_(i+w-1) ... s_i. a_i is computed as a_i = +// 2^w * (a_(i+w) + t_(i+w)). +// +// t_i is bounded by -2^(w-1) <= t_i <= 2^(w-1). Additionally, we may write it +// in terms of unsigned bits b_i. t_i consists of signed bits s_(i+w-1) ... s_i. +// This is computed as: +// +// b_(i+w-2) b_(i+w-3) ... b_i b_(i-1) +// - b_(i+w-1) b_(i+w-2) ... b_(i+1) b_i +// -------------------------------------------- +// t_i = s_(i+w-1) s_(i+w-2) ... s_(i+1) s_i +// +// Observe that b_(i+w-2) through b_i occur in both terms. Let x be the integer +// represented by that bit string, i.e. 2^(w-2)*b_(i+w-2) + ... + b_i. +// +// t_i = (2*x + b_(i-1)) - (2^(w-1)*b_(i+w-1) + x) +// = x - 2^(w-1)*b_(i+w-1) + b_(i-1) +// +// Or, using C notation for bit operations: +// +// t_i = (k>>i) & ((1<<(w-1)) - 1) - (k>>i) & (1<<(w-1)) + (k>>(i-1)) & 1 +// +// Note b_(i-1) is added in left-shifted by one (or doubled) from its place. +// This is compensated by t_(i-w)'s subtraction term. Thus, a_i may be computed +// by adding b_l b_(l-1) ... b_(i+1) b_i and an extra copy of b_(i-1). In C +// notation, this is: +// +// a_i = (k>>(i+w)) << w + ((k>>(i+w-1)) & 1) << w +// +// Observe that, while t_i may be positive or negative, a_i is bounded by +// 0 <= a_i < n + 2^w. Additionally, a_i can only be zero if b_(i+w-1) and up +// are all zero. (Note this implies a non-trivial P + (-P) is unreachable for +// all groups. That would imply the subsequent a_i is zero, which means all +// terms thus far were zero.) +// +// Returning to our doubling position, we have a_j = t_j (mod n). We now +// determine the value of a_j - t_j, which must be divisible by n. Our bounds on +// a_j and t_j imply a_j - t_j is 0 or n. If it is 0, a_j = t_j. However, 2^w +// divides a_j and -2^(w-1) <= t_j <= 2^(w-1), so this can only happen if +// a_j = t_j = 0, which is a trivial doubling. Therefore, a_j - t_j = n. +// +// Now we determine j. Suppose j > 0. w divides j, so j >= w. Then, +// +// n = a_j - t_j = (k>>(j+w)) << w + ((k>>(j+w-1)) & 1) << w - t_j +// <= k/2^j + 2^w - t_j +// < n/2^w + 2^w + 2^(w-1) +// +// n is much larger than 2^w, so this is impossible. Thus, j = 0: only the final +// addition may hit the doubling case. +// +// Finally, we consider bit patterns for n and k. Divide k into k_H + k_M + k_L +// such that k_H is the contribution from b_(l-1) .. b_w, k_M is the +// contribution from b_(w-1), and k_L is the contribution from b_(w-2) ... b_0. +// That is: +// +// - 2^w divides k_H +// - k_M is 0 or 2^(w-1) +// - 0 <= k_L < 2^(w-1) +// +// Divide n into n_H + n_M + n_L similarly. We thus have: +// +// t_0 = (k>>0) & ((1<<(w-1)) - 1) - (k>>0) & (1<<(w-1)) + (k>>(0-1)) & 1 +// = k & ((1<<(w-1)) - 1) - k & (1<<(w-1)) +// = k_L - k_M +// +// a_0 = (k>>(0+w)) << w + ((k>>(0+w-1)) & 1) << w +// = (k>>w) << w + ((k>>(w-1)) & 1) << w +// = k_H + 2*k_M +// +// n = a_0 - t_0 +// n_H + n_M + n_L = (k_H + 2*k_M) - (k_L - k_M) +// = k_H + 3*k_M - k_L +// +// k_H - k_L < k and k < n, so k_H - k_L ≠ n. Therefore k_M is not 0 and must be +// 2^(w-1). Now we consider k_H and n_H. We know k_H <= n_H. Suppose k_H = n_H. +// Then, +// +// n_M + n_L = 3*(2^(w-1)) - k_L +// > 3*(2^(w-1)) - 2^(w-1) +// = 2^w +// +// Contradiction (n_M + n_L is the bottom w bits of n). Thus k_H < n_H. Suppose +// k_H < n_H - 2*2^w. Then, +// +// n_H + n_M + n_L = k_H + 3*(2^(w-1)) - k_L +// < n_H - 2*2^w + 3*(2^(w-1)) - k_L +// n_M + n_L < -2^(w-1) - k_L +// +// Contradiction. Thus, k_H = n_H - 2^w. (Note 2^w divides n_H and k_H.) Thus, +// +// n_H + n_M + n_L = k_H + 3*(2^(w-1)) - k_L +// = n_H - 2^w + 3*(2^(w-1)) - k_L +// n_M + n_L = 2^(w-1) - k_L +// <= 2^(w-1) +// +// Equality would mean 2^(w-1) divides n, which is impossible if n is prime. +// Thus n_M + n_L < 2^(w-1), so n_M is zero, proving our condition. +// +// This proof constructs k, so, to show the converse, let k_H = n_H - 2^w, +// k_M = 2^(w-1), k_L = 2^(w-1) - n_L. This will result in a non-trivial point +// doubling in the final addition and is the only such scalar. +// +// COMMON CURVES: +// +// The group orders for common curves end in the following bit patterns: +// +// P-521: ...00001001; w = 4 is okay +// P-384: ...01110011; w = 2, 5, 6, 7 are okay +// P-256: ...01010001; w = 5, 7 are okay +// P-224: ...00111101; w = 3, 4, 5, 6 are okay +static inline void recode_scalar_bits(crypto_word_t *sign, crypto_word_t *digit, + crypto_word_t in) { + crypto_word_t s, d; + + s = ~((in >> 5) - 1); /* sets all bits to MSB(in), 'in' seen as + * 6-bit value */ + d = (1 << 6) - in - 1; + d = (d & s) | (in & ~s); + d = (d >> 1) + (d & 1); + + *sign = s & 1; + *digit = d; +} diff --git a/http/vendor/ring/crypto/fipsmodule/ecdsa/ecdsa_verify_tests.txt b/http/vendor/ring/crypto/fipsmodule/ecdsa/ecdsa_verify_tests.txt new file mode 100644 index 0000000..c00af6c --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/ecdsa/ecdsa_verify_tests.txt @@ -0,0 +1,1362 @@ +# Tests from NIST CAVP 186-4 ECDSA2VS Test Vectors, Signature Verification Test +# http://csrc.nist.gov/groups/STM/cavp/documents/dss/186-3ecdsatestvectors.zip +# +# NIST's files provide message and digest pairs. Since this is a low-level test, +# the digests have been extracted. P-521 test vectors were fixed to have the +# right number of leading zeros. + +Curve = P-256 +X = 1198b3c409a8b47edb1347e0982d533cb1813e5cb2a92c824b2881b3cd2f3f4a +Y = 0bdbac5fa02e41e775f8d602446d58ecb2209b5a3d79ae69eef399016e992e87 +Digest = 01ed0c41d650479c47057f61433d7e8b24492649 +R = 9206d435f148f88c15b2effbf3c506e41b2c620102022b801e371d0767b54bea +S = cbc4e1674ae1af69873946ccf6275946e59e0107278749b2d0010795833d80fa +Invalid = Y + +Curve = P-256 +X = f7c6280aecd6b936513b0ca84e63346333dc41437a15442e605d46bba93ae101 +Y = 3c834cecc16167b07866a9478f9f2d882de7ef937da447cd837e60cb5ed65d81 +Digest = f91b4dfddd5eb33a875d2e50d1e949211ac819da +R = f615af212ab030c4bbf9362d9815a1462312df4beb4358a7ce80d820355420bf +S = d12ed715ef65cfe6fe6bf348364088a0e7f70927bbafe4c12fc4cb65c0cc51bc +Invalid = Y + +Curve = P-256 +X = 0e7632dbc4db879e10d1d80f2789d9fa414c1fe77a6c1e56d6667af43e36e610 +Y = 6f0dd2a5840e5a6f6ff7e23f656f5c945b7a493fbb0cfd5b9b531bf04435b1ef +Digest = 3905696f8bad8205fa1445df0e91ade3dbc413e6 +R = 2b0b9ab4a575732a168f28494b66a855fc1a757fb1177864bf3e4f0a000c4a86 +S = 54901ce2f92f55ac112afa0f8b62bc00b44c8c10fe0c863675bfd305d6dc0cd8 +Invalid = Y + +Curve = P-256 +X = 1613f12bae8e98d09b4bba53f5229596a0d417d2c625f41bb15f923b3c1e4b57 +Y = 411319fa85227997a4cf3b1756161485124d2cedc38c9c30d82f42dc2647d545 +Digest = 580d31ce22700a20c2db81bcdac37330b491c86f +R = ed058d476a77be99c1b0fc8502abe545541b4c0ff3eed3f558133ae2f02042b0 +S = c571b4895712a4f64f7220b0694cab767379b09f1824fe7874acd127deb2371e +Invalid = Y + +Curve = P-256 +X = 88bb041dcb1733a676a7f4ae8d3e407d72d5396547f07db77078485c1d5db077 +Y = 72cf2b55e596cd140c58228f1b0a19c34fca26ffac043528a417c5abb6fca9c9 +Digest = 7900a02f768b0718a13525c33adace583de15c50 +R = 87208734deb125dca68f0d33f9d369cf1b79cf5a021391b9c6c1727d2efe663a +S = b984f722de18f1ce407104342948f03f2b55413a096c4b5fca1e032a2c814a4a +Invalid = Y + +Curve = P-256 +X = 811eb5180def7fb60d632f8cb2cba831b88cee778aa2a82ec3a5fc3d80ff7fb6 +Y = db88d65b0fc35d9ba1f1ced0400434979ae895d371d1441d7c7a441a9fb1709b +Digest = 17b7451ea903125ccb293ffaa9d1a4ca1141a2c5 +R = c329fa28dac0018276c5af0cd770e60be50bc14e2562d5556991971edc7d4916 +S = 2d111d13837a02fa279fe835a7dc59a521864d92b26649ca4e24b36ae93878e8 +Invalid = Y + +Curve = P-256 +X = 4a6f1e7f7268174d23993b8b58aa60c2a87b18de79b36a750ec86dd6f9e12227 +Y = 572df22bd6487a863a51ca544b8c5de2b47f801372a881cb996a97d9a98aa825 +Digest = 54e9a048559f370425e9c8e54a460ec91bcc930a +R = 4a800e24de65e5c57d4cab4dd1ef7b6c38a2f0aa5cfd3a571a4b552fb1993e69 +S = d9c89fb983640a7e65edf632cacd1de0823b7efbc798fc1f7bbfacdda7398955 +Invalid = Y + +Curve = P-256 +X = f3033d1e548d245b5e45ff1147db8cd44db8a1f2823c3c164125be88f9a982c2 +Y = 3c078f6cee2f50e95e8916aa9c4e93de3fdf9b045abac6f707cfcb22d065638e +Digest = e8d38e4c6a905a814b04c2841d898ed6da023c34 +R = d4255db86a416a5a688de4e238071ef16e5f2a20e31b9490c03dee9ae6164c34 +S = 4e0ac1e1a6725bf7c6bd207439b2d370c5f2dea1ff4decf1650ab84c7769efc0 + +Curve = P-256 +X = 0ea0a6bb6c70966fad1a2307479c12de2322795bdecb70e4b286bd6200ba9c1a +Y = c40eda3947021348db691ac4086fb6c06b587ce37c155bb0a7d912b93226de81 +Digest = 3b08bf1b67abc03c1cd69b0e24743b5c2d49e506 +R = f5509deff7bfda3f3759800fa4033af6a84466b114ecb48eac37eff48d2ae1b3 +S = 8c4b62dce2082f80caf220cdbb1d02567bbdfab40564b90ef31d86e3e10ce80a +Invalid = Y + +Curve = P-256 +X = e7a57e0f6ec0fa9c7c34978034cf82f039f8fd62804070ad943573fc8efa5775 +Y = 87b2cc85dfff2dae5620fbe3e6256bd728de28fc9dc1b5eb6b5d7bd5d29186ad +Digest = a8c5dc0344b1442dfdb5f8836251893d6c4ecbe9 +R = 97642038932fdddbe2021ec1af53ae6b9af00ef9c8b9f26aea582892e80e6285 +S = 9cb14918359338041cf795cf6781e4905837fa5ce3b3e50ffafb5f13c73b5bc8 +Invalid = Y + +Curve = P-256 +X = be7a651be0c87278569987cf62d7fa1dd1b3d6e1b868d8f4dfb56135a9960eec +Y = b7a62c588a987760b915edbd7f95506870c60f042471de1d8b2d4cd9d6563391 +Digest = 2f93ee45db133a14c26d418c2ffd3470ae63bf50 +R = aa889fb608b6939f6eeacf2f64c3b2e3a6061f2834058c7e724321720b737a63 +S = 6cd6d0ef2b93a760daa914e11b9b414bd4d72457405f00a62ab63f36d76efb73 +Invalid = Y + +Curve = P-256 +X = 76ddc46d8db8d7ce2ce837f60cdabcee92b7c7817ee41c8f066f1ae65f85c318 +Y = bea47191f1c584c87250370ce337a1de1583bcfc20ccc23b7a82e83f19adaa88 +Digest = 2136a5470ff9d45214a0b2c300042efea8ff7266 +R = 84a42efbf7ec04166ad144d19cd98c120aa2e79d483b5eea6fbdfa7f1222e07b +S = e41531205e691e65668f69f518abc7b60f32c373434872a043b7358462babf83 +Invalid = Y + +Curve = P-256 +X = 2f71b932f770ba9daf7c1dd47444ab6cb8881f71a1c597e719845b15cb84ca35 +Y = ab928625b40ec0738d0fc8dbc4df4a1f65d20bc0447b69cfa13bb20b95bb41d4 +Digest = ae6093bb37c1264ca3ead439e4f678721912c8c4 +R = 63fca172bbca6197cd2802a9cb61d74c2b47cf35f6d35203e67ffbaa838be775 +S = e70ec283cd212df6ba3723e26b697501f112d7cf64e4f45185dae76055e09f1e + +Curve = P-256 +X = ce775648b928db82ac5edb3b009d32959a73b86c45e96d4b8d5b6e640b7c2790 +Y = 52455caf08ee94d86f0984e9ec9268d74823f2102dd97fced59638055f6af18e +Digest = 60054807acb29e3091a023c42b9885c4945249e1 +R = 2a64b29146588f3153fee1029a0131ac0a8a25ba2ecc494f697c166c7c91fc08 +S = 7b429bc12a72ca3d76c119eea9f4098633cc31c87831e54d5d93afd6e8d20f4f +Invalid = Y + +Curve = P-256 +X = cd2f29a53f0ce57e0e4a542c3256e65ebbdc30415f4de771d5d706d3aeacc852 +Y = dbbf2c129f30d11fe77d7816a24187764eae3fb2ff70c1ec745e876e26f5232f +Digest = 5f50e35b134942295c16d003742fd6bce5bdab45 +R = 2454c5ee84e4f77b554acd368dd412389db8c78429590a092f24db2da43cb761 +S = 63e870ce2fa4085d4ff1e360f7a5c101a1f8b288abe71cca56887e613ad034b7 + +Curve = P-256 +X = 843f6d83d777aac75b758d58c670f417c8deea8d339a440bb626114318c34f29 +Y = 83e0c70008521c8509044b724420463e3478e3c91874d424be44413d1ce555f3 +Digest = cda2c7ad9abb2a858c4981550f78974c69e41cc31fa33509e3e83dc2 +R = d08e9a5db411019d826b20ac889227ed245503a6d839494db1e8d7995a6b245b +S = 8d46a204054125d0dc776ab1055302ec4eb0f20b90bca6d205f21d3cefd29097 + +Curve = P-256 +X = f08b56f73f7a0e098444f6f0a02ad81ce0b914a11cafa15893d1c84704e1c564 +Y = bbee9aeb91cdc2d1d1437b4168df73acfd64e8b02962b14c85e67187e1ef80a4 +Digest = 5453c2656550e9b3dc6c40a3f1362a73522396bc35d383dd6451128f +R = 71b3ec982725a007ac18a5cf60587e1fd1beb57685a1f9df3cddd9df25dcbc18 +S = 407e41217325f92f8a031cfcc4eb64c1a4b17b0a7459c254af754a7ea9eac997 +Invalid = Y + +Curve = P-256 +X = 0b688e761e1ddda2305e002809da65bf5916dfe1356a5b99b61f5576a9b90efa +Y = 90ec958e2e3a676e7bbf8e9394f72742875836125a317b0ae38374953f746a91 +Digest = 7289573d6bb7486e428e086bec9da9d7ff3c5f8bd0db2ec209fed6ae +R = ef89df3bbf079fb250f7e882c4f85c0023fc3804e862d9ef4d9530a15f1013f0 +S = 4ba985e900e6737b8e07eac638f7b38277ead4faee6d2076a2eee90fd2a6bf0f +Invalid = Y + +Curve = P-256 +X = 0b64480783e260e1e9caef37b4cc9c650d2d57e2c594b1106314843d8d7ab74e +Y = 29d373d8522deffe40055aef539f53f38937eb799b44f05a8d8c0b381f12907f +Digest = 497656e780360ec3b4bd1be97570615e4a32467982cd9330bc6aa224 +R = c5c26b0b21eef0f7a0f1cff38d0079d890376759369b01d8d8e959c1c785e203 +S = fecc400bf0deab99d87da168b9d0dd31d2dfa3435b0fe9d38b5fb8efd45195a4 +Invalid = Y + +Curve = P-256 +X = 7f78a8fd880c509940e2b83de67c9ab553ab91489bae75cdc1d5b523b06ab7f5 +Y = 7786aee7032c373cdfad7d9ddb6fa09a026f6da30fd477ab014d30a289d542a1 +Digest = 6d88da9e83ae9457e233d7977172c062dfbdd17d365694515251e031 +R = c93ada69db326f76b1362d610cb8bcc6e7ef1dc03d3d11367e153c0e39d5dc86 +S = d0c02c71b14ef7a4af4e23bd207ce98449f5d6e7e5b3ec8cbbca9549e97d379d + +Curve = P-256 +X = e58cdc207c56f62e0bb7c0b55b7f7236a6b308f8fc4de3e61cdb3bf20ad2f62c +Y = 6056c0ee827e85ba284838954d0c6cc096df03b4611b1e0f7f9002bac86856d4 +Digest = 3f9a97b8ea807edc88788df8956c296b1daaed8dd12d50c712344091 +R = 2df3906527ad322000285bccdd11dd09130d633cf43534f5802604639eb847e0 +S = adaaad19b7c66836ef0f4afeff8ac5e898cd2523246a74a1a291a3a1ff583322 + +Curve = P-256 +X = 70b4bba10b7bbc6d4175ada8d485f3685b13916d0c992301f47e45b629c63d0e +Y = 257a93be31b09ff4cd22e3375e30b5a79f3bf3c74c80dde93e5d65e88c07c1c4 +Digest = cc3a0d3a5d4f28dc9144a3cdb276eb92265f1157a8d8192cf628673c +R = 6e714a737b07a4784d26bde0399d8eee81998a13363785e2e4fb527e6a5c9e4e +S = 94c0220f0f3fa66ff24f96717f464b66ae3a7b0f228ab6a0b5775038da13768a +Invalid = Y + +Curve = P-256 +X = 8b11b48d2397355000a5289d816b9892ae64dffc842abec02a2fb2db2bb34310 +Y = fc1a42528a0473cfc2c2e184b8bc5055096350fe1549d24b526d6536681026e8 +Digest = f340e491fa935be8945b8caa485d0699c66331e0e17c7407da1b018e +R = 61a91dd1c80049e70dc4aea84bda0efc6ec9c7b9dd16ecbccf687244c51184ce +S = e381e7b32bab49578c7e7ce7784ce19263e4a7dab4b614df411d20eaebfc391c +Invalid = Y + +Curve = P-256 +X = 7bad1b3d8bad4355a44511d2eb50daeae793af99418ada118327359936aa0e1d +Y = e7eff40334b7a5455f6b0d0ecdcdc513702857bb5bbb73c910c86746092bcd7d +Digest = 9cf84546c046b370c372c167ebba39af6aadd60463626453787bb058 +R = fd961b60b21be32b47abafa77e22197dc99af6825dcca46e0e3b1991a90aa202 +S = a0477f97b94a1c26a3b2d186791d7fc9dfa8130bbae79c28fa11ec93a3aeac0b +Invalid = Y + +Curve = P-256 +X = 407d92c9b28723602bf09f20f0de002afdf90e22cb709a8d38e3c51e82cba96c +Y = 4530659432e1dd74237768133e1f9808e62d0fbe5d1d979d1571baf645dcb84c +Digest = 0cf5cd48c93f45472d254196bebea4bddb272a2adff23bab8c3adf99 +R = a7dc65293ee3deb0008ae3e2d7ef9e9a4ebb8bf7b10d165f80ab8bed58d6fdef +S = 3e8300a3ee603a8d8234fe265c628e705015bf1903eb74c943323050626f701f +Invalid = Y + +Curve = P-256 +X = 26aea3dd5c53f984dbdaf415c7f26e1e73048658a548eb3b59dd5f721899919a +Y = dff15f57bd9b08644d49cbb214403647195725cd4d4511bc8a48b0770466ae9f +Digest = 75d6b6b575d0a2c89528b83c94ef864c825b66253ab662b36bb0e716 +R = 726af92afe53e8125b0b9f3659745be401a37ae658b7b1aa88c3cb97e9de22c3 +S = 794484c5837a419efe11a4e4293341a6fa36d21230925a0e5e135887302acca9 +Invalid = Y + +Curve = P-256 +X = e73418677ce044b331a6d60773cbae199221699d31e1bec4b68b9bc0b87e4cd0 +Y = 37215db4e3d9161f3351b385a61ddb2fcf1cec469d1659e7574610ed27fe879f +Digest = dcbb92e3be3951d37e37852d508f78da29c8183c5dbe59d6549f78ed +R = ac469290a8f61a2a8c6adc7533dd5cfe804e2e7bf101cc74e5f624f301bccd23 +S = 4c328c3bc259316641fff44753743afebe89b8627f904df7245e42adcff2dc76 +Invalid = Y + +Curve = P-256 +X = b0892b19c508b3543a5ae864ba9194084c8f7ae544760759550cc160972e87ff +Y = 9208e9b0c86ad6bc833e53026f233db9a42298cdb35d906326008377520b7d98 +Digest = 90333facb4f5068c1d05d1a478fb46d02f367e271a000474c06a5fec +R = a62dd0d1518c6b9c60de766b952312a8d8c6eaa36a68196d2a30a46fb17dc067 +S = b9ded660e978129277f74c1d436003d1e6d556dc8eed9d505bbaf4c67cb13d21 +Invalid = Y + +Curve = P-256 +X = 8c5c41cb07d828a6a86be4533aef791d3a70a95cb285aa2956b21feeac2f8c49 +Y = 84101581cad7a48b7d0596df7ffed47085d22e8a4af685cddbeeb32ea69ae190 +Digest = 8bb52bd045c985167f673c07b613a3402f435a54c122877bc0c5fe34 +R = 9812449df0a51f7a2a8f78aa9a589ca9644dce285f1e69658daaea759fa5bd7e +S = beb4c27c748a7944e37afe861576f76b5a749a8ccbbd7dec00838ba250ddfe1a +Invalid = Y + +Curve = P-256 +X = 788d7e54ab03020e4954f41259052ee5af68361492b180da31fbbe68d868aa95 +Y = 982a3ababa6d351649e56da3faeb7160b9de74e22fe93a06ead1bd9a8dffdf7e +Digest = 9870ae25b0f0403eff1079b94669cf95fb250fb098eeb885ff08f117 +R = 3ddea06bf8aa4a1b0c68674a2c4796def0bfb52236f4efb3332204a41fd8ea89 +S = 871237039431a41aeefcdd08f67848b2b09067e3a1344c8ed9b372d1b1c754a6 +Invalid = Y + +Curve = P-256 +X = 87f8f2b218f49845f6f10eec3877136269f5c1a54736dbdf69f89940cad41555 +Y = e15f369036f49842fac7a86c8a2b0557609776814448b8f5e84aa9f4395205e9 +Digest = a82c31412f537135d1c418bd7136fb5fde9426e70c70e7c2fb11f02f30fdeae2 +R = d19ff48b324915576416097d2544f7cbdf8768b1454ad20e0baac50e211f23b0 +S = a3e81e59311cdfff2d4784949f7a2cb50ba6c3a91fa54710568e61aca3e847c6 +Invalid = Y + +Curve = P-256 +X = 5cf02a00d205bdfee2016f7421807fc38ae69e6b7ccd064ee689fc1a94a9f7d2 +Y = ec530ce3cc5c9d1af463f264d685afe2b4db4b5828d7e61b748930f3ce622a85 +Digest = 5984eab8854d0a9aa5f0c70f96deeb510e5f9ff8c51befcdc3c41bac53577f22 +R = dc23d130c6117fb5751201455e99f36f59aba1a6a21cf2d0e7481a97451d6693 +S = d6ce7708c18dbf35d4f8aa7240922dc6823f2e7058cbc1484fcad1599db5018c +Invalid = Y + +Curve = P-256 +X = 2ddfd145767883ffbb0ac003ab4a44346d08fa2570b3120dcce94562422244cb +Y = 5f70c7d11ac2b7a435ccfbbae02c3df1ea6b532cc0e9db74f93fffca7c6f9a64 +Digest = 44b02ad3088076f997220a68ff0b27a58ecfa528b604427097cce5ca956274c5 +R = 9913111cff6f20c5bf453a99cd2c2019a4e749a49724a08774d14e4c113edda8 +S = 9467cd4cd21ecb56b0cab0a9a453b43386845459127a952421f5c6382866c5cc +Invalid = Y + +Curve = P-256 +X = e424dc61d4bb3cb7ef4344a7f8957a0c5134e16f7a67c074f82e6e12f49abf3c +Y = 970eed7aa2bc48651545949de1dddaf0127e5965ac85d1243d6f60e7dfaee927 +Digest = d1b8ef21eb4182ee270638061063a3f3c16c114e33937f69fb232cc833965a94 +R = bf96b99aa49c705c910be33142017c642ff540c76349b9dab72f981fd9347f4f +S = 17c55095819089c2e03b9cd415abdf12444e323075d98f31920b9e0f57ec871c + +Curve = P-256 +X = e0fc6a6f50e1c57475673ee54e3a57f9a49f3328e743bf52f335e3eeaa3d2864 +Y = 7f59d689c91e463607d9194d99faf316e25432870816dde63f5d4b373f12f22a +Digest = b9336a8d1f3e8ede001d19f41320bc7672d772a3d2cb0e435fff3c27d6804a2c +R = 1d75830cd36f4c9aa181b2c4221e87f176b7f05b7c87824e82e396c88315c407 +S = cb2acb01dac96efc53a32d4a0d85d0c2e48955214783ecf50a4f0414a319c05a + +Curve = P-256 +X = a849bef575cac3c6920fbce675c3b787136209f855de19ffe2e8d29b31a5ad86 +Y = bf5fe4f7858f9b805bd8dcc05ad5e7fb889de2f822f3d8b41694e6c55c16b471 +Digest = 640c13e290147a48c83e0ea75a0f92723cda125ee21a747e34c8d1b36f16cf2d +R = 25acc3aa9d9e84c7abf08f73fa4195acc506491d6fc37cb9074528a7db87b9d6 +S = 9b21d5b5259ed3f2ef07dfec6cc90d3a37855d1ce122a85ba6a333f307d31537 +Invalid = Y + +Curve = P-256 +X = 3dfb6f40f2471b29b77fdccba72d37c21bba019efa40c1c8f91ec405d7dcc5df +Y = f22f953f1e395a52ead7f3ae3fc47451b438117b1e04d613bc8555b7d6e6d1bb +Digest = 8a3e7ad7b9b1b0cdc48e58d1e651fe6d710fef1420addeb61582bdd982d2b44c +R = 548886278e5ec26bed811dbb72db1e154b6f17be70deb1b210107decb1ec2a5a +S = e93bfebd2f14f3d827ca32b464be6e69187f5edbd52def4f96599c37d58eee75 +Invalid = Y + +Curve = P-256 +X = 69b7667056e1e11d6caf6e45643f8b21e7a4bebda463c7fdbc13bc98efbd0214 +Y = d3f9b12eb46c7c6fda0da3fc85bc1fd831557f9abc902a3be3cb3e8be7d1aa2f +Digest = d80e9933e86769731ec16ff31e6821531bcf07fcbad9e2ac16ec9e6cb343a870 +R = 288f7a1cd391842cce21f00e6f15471c04dc182fe4b14d92dc18910879799790 +S = 247b3c4e89a3bcadfea73c7bfd361def43715fa382b8c3edf4ae15d6e55e9979 +Invalid = Y + +Curve = P-256 +X = bf02cbcf6d8cc26e91766d8af0b164fc5968535e84c158eb3bc4e2d79c3cc682 +Y = 069ba6cb06b49d60812066afa16ecf7b51352f2c03bd93ec220822b1f3dfba03 +Digest = 7c1048884558961c7e178b3a9b22583fca0d17f355a9887e2f96d363d2a776a3 +R = f5acb06c59c2b4927fb852faa07faf4b1852bbb5d06840935e849c4d293d1bad +S = 049dab79c89cc02f1484c437f523e080a75f134917fda752f2d5ca397addfe5d +Invalid = Y + +Curve = P-256 +X = 224a4d65b958f6d6afb2904863efd2a734b31798884801fcab5a590f4d6da9de +Y = 178d51fddada62806f097aa615d33b8f2404e6b1479f5fd4859d595734d6d2b9 +Digest = 4c8d1afb724ad0c2ec458d866ac1dbb4497e273bbf05f88153102987e376fa75 +R = 87b93ee2fecfda54deb8dff8e426f3c72c8864991f8ec2b3205bb3b416de93d2 +S = 4044a24df85be0cc76f21a4430b75b8e77b932a87f51e4eccbc45c263ebf8f66 +Invalid = Y + +Curve = P-256 +X = 43691c7795a57ead8c5c68536fe934538d46f12889680a9cb6d055a066228369 +Y = f8790110b3c3b281aa1eae037d4f1234aff587d903d93ba3af225c27ddc9ccac +Digest = 8581034ec7d7a6b163d71820923f616b362748f2846042c9896d8e4bf7577960 +R = 8acd62e8c262fa50dd9840480969f4ef70f218ebf8ef9584f199031132c6b1ce +S = cfca7ed3d4347fb2a29e526b43c348ae1ce6c60d44f3191b6d8ea3a2d9c92154 +Invalid = Y + +Curve = P-256 +X = 9157dbfcf8cf385f5bb1568ad5c6e2a8652ba6dfc63bc1753edf5268cb7eb596 +Y = 972570f4313d47fc96f7c02d5594d77d46f91e949808825b3d31f029e8296405 +Digest = e5b30e0041a33281210644938d9aaa15ef2c1247b4178f7ca1ee935ce23daabc +R = dfaea6f297fa320b707866125c2a7d5d515b51a503bee817de9faa343cc48eeb +S = 8f780ad713f9c3e5a4f7fa4c519833dfefc6a7432389b1e4af463961f09764f2 +Invalid = Y + +Curve = P-256 +X = 072b10c081a4c1713a294f248aef850e297991aca47fa96a7470abe3b8acfdda +Y = 9581145cca04a0fb94cedce752c8f0370861916d2a94e7c647c5373ce6a4c8f5 +Digest = edd72dc0aa91649e09e2489c37ec27efab3b61953762c6b4532a9b1cd08a500d +R = 09f5483eccec80f9d104815a1be9cc1a8e5b12b6eb482a65c6907b7480cf4f19 +S = a4f90e560c5e4eb8696cb276e5165b6a9d486345dedfb094a76e8442d026378d +Invalid = Y + +Curve = P-256 +X = 09308ea5bfad6e5adf408634b3d5ce9240d35442f7fe116452aaec0d25be8c24 +Y = f40c93e023ef494b1c3079b2d10ef67f3170740495ce2cc57f8ee4b0618b8ee5 +Digest = 0d06ba42d256062e16b319a0f3099109518a765f26bac3b9f56930d965617726 +R = 5cc8aa7c35743ec0c23dde88dabd5e4fcd0192d2116f6926fef788cddb754e73 +S = 9c9c045ebaa1b828c32f82ace0d18daebf5e156eb7cbfdc1eff4399a8a900ae7 +Invalid = Y + +Curve = P-256 +X = 2d98ea01f754d34bbc3003df5050200abf445ec728556d7ed7d5c54c55552b6d +Y = 9b52672742d637a32add056dfd6d8792f2a33c2e69dafabea09b960bc61e230a +Digest = 41007876926a20f821d72d9c6f2c9dae6c03954123ea6e6939d7e6e669438891 +R = 06108e525f845d0155bf60193222b3219c98e3d49424c2fb2a0987f825c17959 +S = 62b5cdd591e5b507e560167ba8f6f7cda74673eb315680cb89ccbc4eec477dce + +Curve = P-256 +X = 40ded13dbbe72c629c38f07f7f95cf75a50e2a524897604c84fafde5e4cafb9f +Y = a17202e92d7d6a37c438779349fd79567d75a40ef22b7d09ca21ccf4aec9a66c +Digest = 5aa8e8a6f0622b841416e1a70d79a54641d2c699a075b6960fe5dcf96301da8ca6f15b0948d4ededac30a42e00d3b310 +R = be34730c31730b4e412e6c52c23edbd36583ace2102b39afa11d24b6848cb77f +S = 03655202d5fd8c9e3ae971b6f080640c406112fd95e7015874e9b6ee77752b10 +Invalid = Y + +Curve = P-256 +X = 1f80e19ffeb51dd74f1c397ac3dfd3415ab16ebd0847ed119e6c3b15a1a884b8 +Y = 9b395787371dbfb55d1347d7bed1c261d2908121fb78de1d1bf2d00666a62aed +Digest = 244656186c11c2e67be88099d55e60f4b68e61fba0b214aac3399dc559cfccc02f9884e85623426dbdc3243f2b5374f7 +R = 249ca2c3eb6e04ac57334c2f75dc5e658bbb485bf187100774f5099dd13ef707 +S = 97363a05202b602d13166346694e38135bbce025be94950e9233f4c8013bf5bf +Invalid = Y + +Curve = P-256 +X = ce4dcfa7384c83443ace0fb82c4ac1adfa100a9b2c7bf09f093f8b6d084e50c2 +Y = d98ae7b91abee648d0bfde192703741ac21daad7262af418b50e406d825eb0d6 +Digest = adaeadda3f0e941fba1d3e206a84e6d7530d800e0f215b3ddd82022f27c5be44fed27bc73084c6f7ca55555532be2e3b +R = 597e1e04d93a6b444ccc447a48651f17657ff43fb65fe94461d2bf816b01af40 +S = 359fe3817963548e676d6da34c2d0866aa42499237b682002889eaf8893814d2 + +Curve = P-256 +X = 1b677f535ac69d1acd4592c0d12fac13c9131e5a6f8ab4f9d0afdcb3a3f327e0 +Y = 5dca2c73ec89e58ef8267cba2bb5eb0f551f412f9dc087c1a6944f0ce475277a +Digest = e34a541f87ff0eaa0c640f555caec6bf11a1320c74c47a8ff172c4e2ec902e48d499732b12a86189e750bbf4c0424c72 +R = df0b0cd76d2555d4c38b3d70bfdf964884d0beeb9f74385f0893e87d20c9642d +S = 128299aabf1f5496112be1fe04365f5f8215b08a040abdfeca4626f4d15c005b +Invalid = Y + +Curve = P-256 +X = 7ffc2853f3e17887dda13b0eb43f183ce50a5ac0f8bba75fb1921172484f9b94 +Y = 4cc523d14192f80bd5b27d30b3b41e064da87bfbae15572dd382b9a176c123a2 +Digest = 0689927a38486cccf28fe9454e08e0d74843424b89be4cdee8e48f39a69addec730184da72f914cea67231c765ee2574 +R = 3156176d52eb26f9391229de4251993a41b8172f78970bb70e32a245be4bb653 +S = 62827a29e12d2f29b00fb2d02dd5f2d5412e17a4455f4431a5c996881fdfc0ee +Invalid = Y + +Curve = P-256 +X = 5569f76dc94243cde819fb6fc85144ec67e2b5d49539f62e24d406d1b68f0058 +Y = 1208c38dbe25870deab53c486f793a1e250c9d1b8e7c147ea68b71196c440730 +Digest = 97f8f8cea435282ac746730ac744bf97d85d4e249c0b1d9c7b83c7e59aed172ffc3724d7e6fab7d6ab55ffb3a39c0775 +R = 706f2ba4025e7c06b66d6369a3f93b2fec46c51eceff42a158f7431919506cfb +S = b4e75ac34a96393237fc4337789e37168d79382705b248051c9c72bcbac5f516 +Invalid = Y + +Curve = P-256 +X = e4b470c65b2c04db060d7105ec6911589863d3c7f7ce48726ba3f369ea3467e8 +Y = 44c38d3ae098de05f5915a5868c17fee296a6e150beb1f000df5f3bec8fc4532 +Digest = 5b937a2af46dbf18b4a6fb042ea353a6878e0d4beac016002b3d91a42bcba52856c07a3f35c08dfecb4f03e1c0b9948e +R = c9c347ee5717e4c759ddaf09e86f4e1db2c8658593177cfda4e6514b5e3ecb87 +S = baae01e9e44a7b04d69c8eaaed77c9e3a36ce8962f95cc50a0db146b4e49eb40 +Invalid = Y + +Curve = P-256 +X = 96050c5fa2ddd1b2e5451d89ee74a0b7b54347364ddc0231715a6ef1146fe8dc +Y = e0888a9e78aeea87f6e1e9002b2651169f36c4ee53013cfc8c9912b7fd504858 +Digest = b123e07744f05ad523790ea5bfa3f848869a3bfdbf936a496c8606b577ed8427eb7ee888e0fe18d4e3cfac73baad883f +R = 2353d6cd3c21b8ea7dbc1cd940519812dbe365a3b15cd6aebba9d11cf269867a +S = 85f560273cd9e82e6801e4cb1c8cd29cdac34a020da211d77453756b604b8fa7 + +Curve = P-256 +X = 0c07bb79f44012299fbfd5a0f31397aaf7d757f8a38437407c1b09271c6551a0 +Y = 84fe7846d5d403dc92c0091fbd39f3c5cbca3f94c10b5cae44e2e96562131b13 +Digest = fb8d12652de59e63ef5297641dfbce084808de146720e9069c2ef814bcd80b6187f7422a6cd9c706f8d64ccf80e8bc54 +R = 49e9425f82d0a8c503009cead24e12adc9d48a08594094ca4f6d13ad1e3c571d +S = 1f1b70aaa30a8ff639aa0935944e9b88326a213ab8fce5194c1a9dec070eb433 +Invalid = Y + +Curve = P-256 +X = 71db1de1a1f38f356c91feaff5cfe395d1a5b9d23cf6aa19f38ae0bcc90a486d +Y = ecdd6ffb174a50f1cc792985c2f9608c399c98b8a64a69d2b5b7cdd9241f67e2 +Digest = 2d8c6585a3b6319a556e27b53d434f455f73e771c8fc6a115f5c92a8e9a81ce2b4336a5c3edf98910689d11f4c93632a +R = b0443b33a6f249470d2f943675009d21b9ccbead1525ae57815df86bb20470bf +S = 316dbee27d998e09128539c269e297ac8f34b9ef8249a0619168c3495c5c1198 +Invalid = Y + +Curve = P-256 +X = 8219b225aa15472262c648cac8de9aad4173d17a231ba24352a5a1c4eea70fad +Y = 0fee2b08ad39fbf0db0016ef2896ca99adc07efc8c415f640f3720498be26037 +Digest = a4cc3b23f54d9d48ba6b0ad3da3b2e3a0806f41348bd7844e9c9b8648753bdeef8a039e1fa4f5172c89148d65b14056f +R = 134fb689101aaad3954de2819d9fbd12072fe2bc36f496bbf0d13fa72114ab96 +S = e65c232bd915b59e087e7fd5ec90bf636cfa80526345c79a0adfd75003045d6f +Invalid = Y + +Curve = P-256 +X = c934195de33b60cf00461fc3c45dad068e9f5f7af5c7fa78591e95aeb04e2617 +Y = b588dd5f9965fdaa523b475c2812c251bc6973e2df21d9beaace976abf5728cb +Digest = b962b63a7743ad77f9072f2f08d277f6dda8cc3420ddd37d873746008895902bcce218fbfed1a8cb28406978dd8e5134 +R = 71f302440eb4ed2a939b69e33e905e6fdc545c743458d38f7e1a1d456e35f389 +S = 54eaa0eb9cd7503b19a9658f0a04955d9f0ab20ebc8a0877e33c89ee88ad068f +Invalid = Y + +Curve = P-256 +X = 9e1adcd48e2e3f0e4c213501808228e587c40558f52bb54ddbb6102d4048ea92 +Y = 34eff98704790938e7e0bdf87ae39807a6b77dfdc9ecdfe6dd0f241abae1aeb2 +Digest = 21b883fae159867731b123a2606e9b3320fb53a00e4a5dfe3bc3429dd53b8068197be3c7288c1e0bf28a4fc7b13bd70f +R = ce4f0d7480522c8dd1b02dd0eb382f22406642f038c1ede9411883d72b3e7ed0 +S = 8546e1ee3b77f9927cdaccbc2f1cf19d6b5576b0f738bb1b86a0c66b39ca56fb +Invalid = Y + +Curve = P-256 +X = 93edbecb0b019c2cc03060f54cb4904b920fdb34eb83badd752be9443036ae13 +Y = b494e9295e080a9080fe7e73249b3a5904aa84e1c028121eecd3e2cf1a55f598 +Digest = fcc17b88077570c053650e1de42ae6bb1522900b38996decc87704aab6a87ab01d52f83f6442875f378a262c22d23ab2 +R = eec2986d47b71995892b0915d3d5becc4dcb2ab55206d772e0189541b2184ddf +S = 8a6c1edeb6452627ad27c8319599c54ac44cdd831ea66f13f49d90affe6ad45b + +Curve = P-256 +X = 3205bae876f9bd50b0713959e72457165e826cbbe3895d67320909daa48b0ebc +Y = d1592562273e5e0f57bbfb92cedd9af7f133255684ee050af9b6f02019bbcafa +Digest = 299a6070d32a5557010753d7559dbd8d2bde8a8feae5417616ceb5b167997fd2fac0c2bd44264106d3a9720d5e805a04 +R = 0124f3f1c61ec458561a4eaa6c155bd29e59703d14556324924683db3a4cf43b +S = 688a5c5fc0c7ba92210c50cce5b512a468a880e05acc21ca56571d89f45f603a +Invalid = Y + +Curve = P-256 +X = 484e31e69ef70bb8527853c22c6b6b4cd2a51311dde66c7b63f097dbb6ab27bf +Y = e1ff8177f4061d4fbbacbbc70519f0fc8c8b6053d72af0fe4f048d615004f74e +Digest = f1e9cda2e096ece9a1fc57e55eeeb56b1c635380c0f9a1800a4a1a5f105d1fc0c60e776234daaa8a6f7c0f5286bb420b3f607e7cc0a7d840ad5dcbab26c797b0 +R = 91a303d8fe3ab4176070f6406267f6b79bfe5eb5f62ae6aeb374d90667858518 +S = e152119cefa26826ea07ec40a428869132d70812c5578c5a260e48d6800e046a +Invalid = Y + +Curve = P-256 +X = 8b75fc0129c9a78f8395c63ae9694b05cd6950665cf5da7d66118de451422624 +Y = b394171981d4896d6e1b4ef2336d9befe7d27e1eb87f1c14b8ddda622af379dc +Digest = 0527199fadea30f9e5e66166a3ebcdf6aedf906984535f48165e591eff36f1c0de6b0fa69aefb6399e8a213cc2ce53268fbe18c3471b7708bc27c426aaa769a4 +R = 17e298e67ad2af76f6892fdcead00a88256573868f79dc74431b55103058f0b0 +S = 881328cd91e43d30133f6e471e0b9b04353b17893fb7614fd7333d812a3df6b4 +Invalid = Y + +Curve = P-256 +X = 76e51086e078b2b116fd1e9c6fa3d53f675ae40252fb9f0cc62817bd9ce8831d +Y = ca7e609a0b1d14b7c9249b53da0b2050450e2a25cb6c8f81c5311974a7efb576 +Digest = c926a5026d8f83ffa2092caf863f2d8a886af391462969b13a11d3c6c5fa66bb4281bc6e60a1e99a2e1ae95d689a66282096a0f27aacc048f32d39297649a014 +R = 23b653faaa7d4552388771931803ce939dd5ee62d3fa72b019be1b2272c85592 +S = a03c6f5c54a10861d6b8922821708e9306fd6d5d10d566845a106539cbf4fadd +Invalid = Y + +Curve = P-256 +X = bc7c8e09bd093468f706740a4130c544374fdc924a535ef02e9d3be6c6d3bbfa +Y = af3f813ae6646f5b6dbfb0f261fd42537705c800bb1647386343428a9f2e10fc +Digest = 4d74631eb67fd1a6fa93ecb6e6112b6699e78c1d4c24ae81d0d5842efe5d93c2fd7a7863f8d45d1b2fafecbe41b7dc19c4b2bc208e014ffdc216e7eda0392a70 +R = 6bd7ce95af25abfbf14aef4b17392f1da877ab562eca38d785fe39682e9c9324 +S = 6688bea20c87bab34d420642da9bdd4c69456bdec50835887367bb4fb7cd8650 +Invalid = Y + +Curve = P-256 +X = 9cb0cf69303dafc761d4e4687b4ecf039e6d34ab964af80810d8d558a4a8d6f7 +Y = 2d51233a1788920a86ee08a1962c79efa317fb7879e297dad2146db995fa1c78 +Digest = 0250f93e6932887df519921f9a8dcff110be0768dc351ef73a940a579fae2d20061759e892e289c3e4ba5f7fe17d6ebb15c5931d48db55ebc81549f6637292fe +R = 4b9f91e4285287261a1d1c923cf619cd52c175cfe7f1be60a5258c610348ba3d +S = 28c45f901d71c41b298638ec0d6a85d7fcb0c33bbfec5a9c810846b639289a84 + +Curve = P-256 +X = e31096c2d512fbf84f81e9bdb16f33121702897605b43a3db546f8fb695b5f6f +Y = 6fbec6a04a8c59d61c900a851d8bf8522187d3ec2637b10fa8f377689e086bba +Digest = f91b09107d10904d3968ec29f85e456ac4e828f32e8da3db6a13f5566bfa625e2ad03f8dad5425a073c0d61d25de63dcafa9f4fcd206f29e9cb6b0fecd74aa57 +R = 1b244c21c08c0c0a10477fb7a21382d405b95c755088292859ca0e71bab68361 +S = 852f4cbfd346e90f404e1dd5c4b2c1debca3ea1abefe8400685d703aea6c5c7f +Invalid = Y + +Curve = P-256 +X = 633c2ee5630b62c9ce839efd4d485a6d35e8b9430d264ffe501d28dbace79123 +Y = 4b668a1a6d1a25b089f75c2bd8d8c6a9a14fe7b729f45a82565da2e866e2c490 +Digest = 575c64df58c8dc517ce65b388fa3ed69470163afecbabc3fa94b497ff7f3fe36ff12fabe2b84cebbf667744195091e4e2335a71d36414e0af0d0260fc8e8ea44 +R = bf2111c93ec055a7eda90c106fce494fd866045634fd2aa28d6e018f9106994e +S = 86b0341208a0aa55edecfd272f49cb34408ce54b7febc1d0a1c2ce77ab6988f8 +Invalid = Y + +Curve = P-256 +X = f78dce40d1cb8c4af2749bf22c6f8a9a470b1e41112796215dd017e57df1b38a +Y = 61b29b0bc03dff7fa00613b4de1e2317cfbf2badd50dee3376c032a887c5b865 +Digest = 4c097f2f5b2489c94258b34d529675bb5d77d4be083b51b01188dd42b4b5473982728763ee6fbad479375c5eacb5edaaec0b6583a10b19aad81ec88dde2d0e7f +R = 4a96169a5dea36a2594011537ee0dc19e8f9f74e82c07434079447155a830152 +S = a204eaa4e97d7553a1521d9f6baadc0b6d6183ba0f385d8593d6ca83607c4d82 +Invalid = Y + +Curve = P-256 +X = 3fcc3b3e1b103fe435ac214c756bdaad309389e1c803e6d84bbbc27039fcf900 +Y = 7f09edd1ec87a6d36dc81c1528d52a62776e666c274415a9f441d6a8df6b9237 +Digest = 1a3dd21cb6ac1fa7fc196319cf534b7608afb93805420fcb5250dff453564a5b22e22971a3ce6dd222405fea018cd0508d86c561eca15e1ac7d79c14e916b86a +R = 1cac13f277354456ae67ab09b09e07eb1af2a2bf45108da70f5c8c6a4cbcd538 +S = 5d83752e540525602ba7e6fee4d4263f3eda59e67df20aac79ca67e8899fed0d +Invalid = Y + +Curve = P-256 +X = 5ec702d43a67ada86efbfc136cf16d96078906954a3f1f9e440674cd907e4676 +Y = 05a62044fed8470dd4fca38d89d583ce36d50d28b66ab0b51922b21da92c56d9 +Digest = c5c016f6c9b525987dd835131def77cc72d8360d364eeccdd7af8b95712b6cd487c0b846201f3b64466fd140833514ae8d765da395fbd9d3c03ca410effa9a69 +R = 75f3037298f1457dba55743999976a1c2636b2b8ab2ed3df4736a6d2934acc83 +S = 19d43ad168dda1bb8ac423f8f08876515234b3d841e57faef1b5ab27359b27ef +Invalid = Y + +Curve = P-256 +X = f63afe99e1b5fc652782f86b59926af22e6072be93390fe41f541204f9c935d1 +Y = f6e19ce5935e336183c21becf66596b8f559d2d02ee282aa87a7d6f936f7260c +Digest = 9eb2f9fa96a1f3ffcef9600522730e86d26d328ec0c1bf2fbfe55a38754610341fda1b894fdcf10c9bc4f48819010fdcf0d24f27ff539e40c6855cafbd306386 +R = cef4831e4515c77ca062282614b54a11b7dc4057e6997685c2fbfa95b392bf72 +S = f20dc01bf38e1344ba675a22239d9893b3a3e33d9a403329a3d21650e9125b75 + +Curve = P-256 +X = 6d11b09d2767cf8d275faee746c203486259f66dd2bfa3a65c39371a66b23385 +Y = 4eb05c73e05261e979182833f20311e5366f72f4b949665ff294f959375534c6 +Digest = 0e71b28b0a1eac7aa881c09daec616c93d9a9286b5f5fdf2642d211021b125fa884b2595b73c7c3e649e61cd7157ef6660076a3b87ddf830db46533f3aa30afa +R = 15a697cdb614e11c0810e1e764cd501fcabc70874c957587bc4883d9438e177f +S = 7bf6244f92bc768063cecb5336c8eaacd23db930b28703560f241c7d93950dfd +Invalid = Y + +Curve = P-256 +X = f3899caba038efb534c4cea0bd276814ffd80194473c903b81af11c8c05cb6e6 +Y = 6ea6b17402fcf2e8e737d11ffc7c2ed3b2d0bc3b8f271a381f4294cff62682c3 +Digest = 104ace16689d785df09a81c5cf47a496db30fbd696aa4df080219487575a23641436e70329dd1c13290582c0d03aae200e51189d43666c86f38a5203c16cd7e4 +R = 57b99380452e1d37b133c49b9ba493dee8630940477ca3351a43d90b99871e6a +S = df599c3a37105af3ecc159b3b685ccb3e151b7d5cf2d97147974ae71f466b615 +Invalid = Y + +Curve = P-256 +X = 1fd6f4b98d0755291e7a230e9f81ecf909e6350aadb08e42a3262ff19200fbd2 +Y = 5578fef79bc477acfb8ed0dc10c4f5809c14dc5492405b3792a7940650b305d7 +Digest = 761a54f3718985b6d7bcfdd57d6c4823f854831bd29305fcb07e34e3f825d451fca28a62ce9582e3957d89ea7c1bc1afe3aa58fd2fa18566974600fc394cf2a8 +R = 97a99e96e407b3ada2c2dcf9ceeeb984d9a4d0aa66ddf0a74ca23cabfb1566cc +S = 0ecac315dc199cfea3c15348c130924a1f787019fe4cd3ae47ca8b111268754a +Invalid = Y + +Curve = P-256 +X = 2dcbd8790cee552e9f18f2b3149a2252dcd58b99ca7dc9680b92c8c43aa33874 +Y = 5dbc8bb8813c8e019d80e19acdb0792f537980fecde93db621aaf1f6d0e6ee34 +Digest = 45b082e804443b53a82229cdf13e4c5f8f31fe93170cc8a23f63eef506cb7748388e1a971a2f81e3daa324cf2bb69118f7418f40df66a24f50c34a55e1416c3a +R = 2bdbd8b0d759595662cc10b10236136ef6ce429641f68cf6480f472fcc77bc9f +S = 7e7df0c8b86f7db06caf1610166f7b9c4c75447f991d5aaf4dea720c25985c8c + +Curve = P-384 +X = 6881154cfe3f09affbee04cd387b27b7854326faf8906c4b9c9e6ac2c632e0d59717b3f33f6d747d7b7cbb4e4dc01fb8 +Y = ba295ae0966f06ad9d84b3bb4da7f99b56044c99f88d71082cfea6964ea3c63bb79806a6a41fcc314b55b3f64f82b68a +Digest = 8a6429d55885146f7aab582a1aa9360fa9591b0a +R = 2112385a75d4edda89ae2bc3c74524dc792544a3a52fdb588da3f0feaee6a11623db275e2ab8abdd998cc42a29c60856 +S = 8d308a3987b81c595f8cec19898b1a42da8eda97496af280033b0f915283f171fed7e2a221fa9c78927962189333f437 +Invalid = Y + +Curve = P-384 +X = 2f2f43f244ae027c3d2ec5c900393f80a8ad0e9b9a12a047195d29a39f2b7026b071688dd9a6764379d02a5ed8035ec1 +Y = e43d45851bc76c37d34dbed996a65ffcfbbaf0e2cbfbc9f62d2116bdf3b330bbef5acdbcd0aa6d949f771daa17cda1e3 +Digest = 5f41322db1a276042ae807f0f0d6f1e04cb5cd26 +R = c011c52e9cb02048957a233704ff9a2c1d4c56e08ebb083aa8ba351f041a23a7d0da19088ac6c60ea2ca117531c7cf35 +S = a66ca9bf06c35d129a8253a0f793acf681e482d9994868b275a230b215286e03a66a0de77c7a53174375137fd4688556 +Invalid = Y + +Curve = P-384 +X = 9a5e1932d318bfa7986f0dac4489c6f55775427bb60fb24bac7646b9994bbc3a9b5cd15e818cc4e832afc1c3fca9abae +Y = 64c89e7c3399c136b2718ab675944207157f0bf23d9e2a807ae7ac3bef81da7ec3c56c2d2c08afc53301af2a3cc71861 +Digest = d36ef9ee70a3b61ba31cdfcd0cac6e49331a407f +R = 4cf6c63fea6c80efc105cd99afe2b53da05ae16566ddb20b9d40a076575ffac419b6807fa336fc6e7c7416c59775ef09 +S = aec2d96054b4b23c49faaf9903ccf63bc96281fb7c1b9d14daa54bba51bb2b2f4d3a901f3b0b9cb2b62976459219350c +Invalid = Y + +Curve = P-384 +X = b3aeff27b65540c6da10a88008404b1d49239c87fbf47932518fb87a9bb132403d1f310f531d086340bb4a68c3e64b9b +Y = 567e75f442fcd81017b8adc4cce634f5ffa3cd497d38221d34dc1f43aef99133131ff1b197f7b9f37beecae5c438849a +Digest = dd0f9c326fb50593fd0a0df31abeeb00a22eb956 +R = 3b94a2514eb915b71e18c867ad7f508a35375c5bcd4b797b86054798569870b2477e2ac14406628017d829400efc63b2 +S = 179a10441a0beea3b375248e697e0d19e24bb68184c373fe4302839b97dd7353a5a25929c2733796b0c0d8211bd67c51 +Invalid = Y + +Curve = P-384 +X = 0874a2e0b8ff448f0e54321e27f4f1e64d064cdeb7d26f458c32e930120f4e57dc85c2693f977eed4a8ecc8db981b4d9 +Y = 1f69446df4f4c6f5de19003f45f891d0ebcd2fffdb5c81c040e8d6994c43c7feedb98a4a31edfb35e89a30013c3b9267 +Digest = a871caf9fff9856031a79a55b96753c1a34ccb73 +R = 8d9d3e3d0b2b2871ea2f03f27ba8699f214be8d875c0d770b0fff1c4ce341f0c834ac11f9ec12bfdb8320b1724c8c220 +S = 62150dfba8e65c0c7be7ef81c87241d2c37a83c27eb31ccc2b3c3957670a744c81be6d741340b5189cc0c547df81b0d2 + +Curve = P-384 +X = b4b92211edbd41c5468d2ba70810bc37b5e7c954c7bd0db80c4fa89ccba10bf07cdab953828a068bc0104d28e4040c14 +Y = 93ed318efce3dff98fc782b788d78658ea5ecde4f716e2d5d0ec2d87a2e761daa1f1658cfb857762caa567baaccf9924 +Digest = 765343d50541bc2c0e20193648048016a95e7588 +R = aa3978eabd196ddf9cab2815cc9cbab0b61cd639deaf70e093a10a58ddf9f410ee1ab965ff8fbb98efbe812421a613d3 +S = 02761a2947e1855806b8a25b9ebb0762be9f5517461a371e5783f34b184f32c4ea684b362119b1a2d8a3ff439f10291f + +Curve = P-384 +X = 63b4cc14f9efd3b8f29e65806591d1e9c54f34a3f5231339bcdbfa4109c42d946a59cdd7bbd2591fd1b2383a0819772f +Y = 55ab3d208109da6ef039c23cddd52a5af619266d8fe066dcabb1af885ad5501401a78c44ed3b5fff2892fdcb2a3ac8b2 +Digest = 4535ef8d7396b4f2af65660ebbb56f356cacefd9 +R = a3f9b840fd7201356f35b5dde39027410aad26ac61919c14fe7b0535bb74e7218cb3312bfa60aac63f14166f32ceff26 +S = 1b1bcbcb0237fad4e406c8d4e3e39b55642d8535afa9ccbc9c601cb4e01891df79f1bc792687cb3a5ee7703565c4a13b +Invalid = Y + +Curve = P-384 +X = f82f82f8f7454ce7a94a040ec0bbb52d49e3b9f8ddd095704973c760ee6067a5c28369656f22d70d8bb1cd70ef9bfea0 +Y = 0e36e256d02870ee5646a17aac4b280c9d1d2e1d4803eb3cb32e7f754cc889522120efd7c4d8a82e509a4d8f266d3ce4 +Digest = 26302c41e6da59e2df2e26c12382738880be94cc +R = 27a2332f3c59464f5dfe7bb1201a3936248d375bde603724c048eb8f7c0c2be3ed4b56c14b51d7d68bd2554526b36d9e +S = e1f90367b0cc530c545f95163d9ffb1208c943685d5ae221052b83ee40953397be581e5979c9855b20246e9d26d57acc +Invalid = Y + +Curve = P-384 +X = 7d40b51127cb1642dd8538d4124138a2f49c41b4d12f702c1b0cec8deba50c3712e01c2e1e693e00438af0e86025da33 +Y = e734b5939b673c45dd32baf20d234f01b7124b391d14beea231e9c604e813fc83b3a77b0cb1f2ce4873a69b0165e369d +Digest = 0b30b209147432207a72177997d28d6f1d03330f +R = abf16821b6657e0005071f78c679cbbb130bee6e7ca63526eef0f747fb721feefe6258dae1aa02064a700e963bd9dedf +S = 3f7e61c34a30cc5ff7a8be375fcc9c38a76dbc0c30a4356843421ca37a7bcf24edcd41d8235903bb522fb6e5a8033885 +Invalid = Y + +Curve = P-384 +X = a5b59d59599c105e39f61354da99c7c9135c749cf996cc2252eb83b008299cdafbcb44227d2d2c4a5ffa44823922893b +Y = 0399fb0edcbfd0b76b524f22b7b87ddbb4fa02f510661615312a4492eb3f2001e0fc0e479f77c33a88f9a7e20757373c +Digest = 44aa3083d111bbce7feb412af74a782cd320becd +R = a4c9cac2409a9bfea1ebe28fec4e19545f08cd18fdd31048f52a3f2d32b2ed859dcae4dc12fb2fecabe542c4f03191ba +S = b4d83f927ad1980d96cbb0ccc36aa640f786293b8b19e4dd97a797d192b420f630a5e42ac42d8736e7d42008f445dbc1 +Invalid = Y + +Curve = P-384 +X = 29178ce9127e1048ea70c7d435439e9ff9915387e51b7e5ca10bfdafe53565978eb3784d9a4226f443d4834f4d451685 +Y = 5cc2970589a453488649711bdf3cdac9a200519aae65b1c6bd54fed0d965755b36b74d978d674275bd71a03e8f054b0e +Digest = c679b4a0e61406c4869d721192bd314d77e1cb39 +R = 5d6f5e9a94d9c92a0890c558bc0408b3405cd04e33f663df16701e80520e4394f1c54d3c8225d36f4753a799aaf6ff90 +S = d895b1cc522ceec6a7867867b8f603245c6e4d48945dfc43af721ebae4683d40a3c21b905ca3bd4b974d36806825b2cd +Invalid = Y + +Curve = P-384 +X = 9f03569f8c6ca2c16d707f0ca36a8a8cf214a9d5c14034829d709e283cd675eb4e3090c6b973429efdf476c0782e0a7c +Y = e1b842536731e91596782787d57af17db85dc92fd2fb95ac65339174aee66775ce0a4721d1faeb29da968ea5eb705e59 +Digest = ae1a63f88a59c7da5d9f512d11bbd5d75dd1f583 +R = 31ccbe22a360b1786dac89394c6ef4ed6604943e50837395f96052821f6182914840096e90f2ad650917bd91d7bd4cfd +S = d97199a6b952dcaefb1defe23def92bf2ee236ad18046a2ccf8924d42ee10a62e70ffe7f3c909b11112278f160d98b7a + +Curve = P-384 +X = b85e78a935d169dd5ba8f558f964b21c07804464816f9231233184675f557463a8b00470ac0ca8278cd008f4642e7962 +Y = 8edf7be8584c5f207939d479e65173e2e69673090a8538fa93efb4432127895d92b4e4cf13b7632a830e9a33b37f75e1 +Digest = 811685f7ff2701e692f6830a33d8712d0432cd5a +R = fd2876b250a94ced71734aa7a0d32423b2c6f039c926c557e748f38e23bbdb46e17d1204832c6f76c3ea854e1da23979 +S = 76409e381799502c81194ba87540aec0b89fc4680dd683780d49f82a46a7191b40f5f06ccb02e45e704c31fcd59382b9 +Invalid = Y + +Curve = P-384 +X = 0c74aaa0527524cb6171ab741896b405a6ac4615e474cdc09c9457b18bed33c6383e1b92f2fa1306e8e5dcd1667e45fe +Y = 7b00d934dfd876f6e07dc0582b20ed650be104fa603a5a1255c62b6059d2685aa9773f1ba31254d213c815d0efc8ed93 +Digest = 328029316d73d1b8d2b8927d12332036e5671384 +R = 832c62b0f34986eda9d1ace5068a0c5318051b0d0166d3dacf137ac072cc359f109ad6e17059e700bb1958bcf4101246 +S = 6bb56f4eb550688ea66e5dd09aebe7e0b39e2716b4697ebb68f113e080f0ff26fd0fc947a34f3c5a8a2f10e07dc1405e +Invalid = Y + +Curve = P-384 +X = 4104de08b4108ee26ee239e0a5d340c1b1aa48b1b3b40717debd6ed3ff0d777923c106f857a3830ce7f3d08d0d6d7908 +Y = 00498c38393e6393edcf254804558f86e461df1f5a6557bc5144f8d2f3806413d372b6ce417d531c08a52d1e38e8b949 +Digest = a13ebaf4431c43b684d1e18e610a75fd7527200e +R = 9924a3273248db20db007309560a0e616572ac799d773529a5215786cf4a6e03cc73bea81d4810c1eee4b5e975652eee +S = 6cc8ea4c4c56da87c25946a198e86917227bcb90da7be1dcde7b6547bc45a98e8175dd54af15bb6ef955b4cb48b7bb0a +Invalid = Y + +Curve = P-384 +X = b6bc9418f3da0cce38a65f1b52bb3a9d22a0368e02f5f12fa1f1303ac67df1cffa55d049a782bf5bddb5e841b125aed6 +Y = 3b578a0560280a2958a14286e10faa7f5dec77fd8d90123aff5780efa8a636cee833fc9f10d7a164f1254a483b613746 +Digest = 7b44de2e448107197558cb071bb5bec9a5849467827d29b2c6625708 +R = 6602090aec001c16e5f6e7e3e488bed5d1702d36b258b6a8a2d8392a5ff30a6af12fbf4308d67eed6aaa8b7be8b831c5 +S = 65d0c3bb1910ba0b7cc108ae1ccaae63405ff01a8df91021e17cd46aa6f8ca8f4eaeac6d6fc26fc816a3ea537fd9576b +Invalid = Y + +Curve = P-384 +X = b4ab83a4ded7d76aa15eaecb1bafe59427d3cfc38564af9123cb707da2405184acd40a6c093ba29e321ba0f67c1e0c6a +Y = 26e2902499495f8550e798617a44ac9990c4c1cc3527dc0dd003a15aee3cbd3955151f7863de1692a94aafd3730e7665 +Digest = 8f902a34f36d7cd36748d5ddcc8fba6040be223a462842d506f185d1 +R = 61e48d5a100049578e820768ea57f30f27ffd1a1f839fabc55e8f4816c9b95d042619cd3bcc7180fd99834e344f53e7f +S = 977b81d43216f31d8bedc3ffe873047817de3441df8b80a321aa0a80931f25a15c6628f43cf8e48d5c6aeca7626b0a18 + +Curve = P-384 +X = f886f36fcf34e8df2a7e09220051b9981a3a6f693ec5999f28864e012c13896d633c9564f0118a95631cea8355b25b20 +Y = 746f9a77835325f18338dee5dc88a9b086b858ce15b4e4462a98844bb01811195f4fae0bee8f457c32823e142210dbb8 +Digest = 6a80377d3c7f0e6a50f6dc1656cef5a0d33cf7934441244f69f0062a +R = 665390653ed280b8f6bd3718d8423f26cb38d2d7faa10fc0f094295677d9dafad45fc64cfc22ded56afdd86a77cf3c33 +S = 864f0eb3a8d93c388d987cfcb60bba76098039d46bf4ff4be083961f70a29e724c25cf56685802b7b5be048107ad52e3 +Invalid = Y + +Curve = P-384 +X = 5fc835a2f5429adb719ed22f11dfcb02731da6759a8ea75c21d1af9631187626c31e191f4dcdc183df01c48e13dbbce6 +Y = 9ed2d03df1cbeaefd4478b8106e90f92e0b6e958145cb81b9648aef0b96b71d1d55918564694b1987d68cc8e7cbd7dd1 +Digest = 807f609592e2ededa12792a7006a6db641904e86a1df3cec477dfd3c +R = 94d9dedd27f2d014ba84ea58d2e88d68f3e86ba88b93750e50255211effe88b0a0e2f62017f22965726cdc77c55bca4f +S = 14814bd09d9b7ba81b2485777cc588b5c0a4064df95c63f18a8bfd57494cd0f40c5bda9dc6c01ea72540f57a354360ef +Invalid = Y + +Curve = P-384 +X = 0b86851d7c19f0f04a16e5e2903a36d09bf1863e152d87936fb2d74cf916bcf6dedf3c066d242f7dd327df0fcb42270a +Y = b0c93480740bb635e6c25fb61630fdfcc462a1418366a51b1265656f721e18ba89ebf754c7dfdad865a252c884a6c4fc +Digest = c34e896a31fc4de7596679e12bb2416a51e58e8942eabd5cb01f0737 +R = 33fa5fe3e495076e90f4b62753d3cdc7603aa7f5b407dbf89a854b9521d15e6c381d3cf28f103035dc4291ae318c5f82 +S = 30919a2a3fae71e1afe8378aedcaa08fadfab6c6bf954031452d4fe514969ede2acf0347a2f1e81abf1bfb9d8bd55a36 +Invalid = Y + +Curve = P-384 +X = 6f8f2fc40d1db28309c8850bf94d77c01c5449b4fc556e6bf50e5ee805209c4489d8ff9bd781699eb0e42f6a962d56fe +Y = a4c7c77271dbbe7e00d1c6e4287dddc5463c6803a577a18f89a5eea01c6addc12404353abbc128cb9cf2496732312d65 +Digest = c19cabc6141b2adf67fe4bd0a3fead50473dea8cb0276de1fdc467c5 +R = 327c4642019a635d80dab82f7dc22e3102a3c1ba684c2b6de67d3d3009a17d39ae3d58ca2caec9f6f03f5ba3b406178c +S = 6b1af807cc7265cc6d3049959cd7779ae0de819036647f9510b0e9f7e4c0e3fece5fc3741b68881145a2c944dc5c54d1 + +Curve = P-384 +X = e98ba8016a976dcc3c50127d2af792969835b1096b1644b37c004d1786f4fb1026233f33ad56cd9444ba0a332c92efb8 +Y = 54bbcb78ffa3c855dd24bf182376ff5d28dd7b7551e4b05a19549c9f59c83dcc12a43092d63c5967fc0256612475b7d4 +Digest = d8d9319d3f705d03dfc992e8e7596586200fb1574f2a918350deb268 +R = 3b76a0c0ece2348085f3554fc92b9e5b0fe84801ab2adf1d239d7c81c9697b62285e8e5667774559d1bbc6e86f2ade64 +S = 91d929e42f8223ccc74d4cb09ee7eb619d3a348886c21091ec55d36164ad3cc04e1da6edd88ad89710a908ca4bc00333 +Invalid = Y + +Curve = P-384 +X = b8d7a836715635a8b095d3712817aa9e6ffdd98d24be2db751bb0c1fad42b082542500ea255cde17525ec159afca7002 +Y = 1a526c876d4771157b4f66e3056485c95066d4bd1e73e991ce6d5d3642807efe80015c52ef3cf8c86e57ab9a510ec86a +Digest = fe23e8ab9dc934144247930a48babb0d8ba57703c2bef60e0e9a1e2b +R = 9e36f47ec1b7ffdc6e3472f3cbec913494c0bbaa0c073f597e01845b5a3107c0e23a4575de4f2b582e1c2fe3067ec048 +S = b013cf51008a89b379a2a6b519b8d229ff0374401eae21a8da350fe35756b94168e7fafbd81f0f681f21c056941a82eb +Invalid = Y + +Curve = P-384 +X = 4ffdecf5d5f7c1164297a93742c8a685bb425b97fdfe85f630dab2064ab29e52a0df34629c2531048c288216723fc9bf +Y = 84fcff3e7e478a6932ace6f6b0ab70e61d8a5137b76886c59e721d938e0e252e2f7e57c2ab7dab90493446ad85c3fe4c +Digest = 28d44c363bfb2e36bc59bb68c56e8b5d2587f149839fd3b8c05d9eb3 +R = 7d909d9aacf064c32d070c3149ace8b8f5d83b2006e8460b84c4bce664fc20e91c61ac8b415965b6155eddbe9238fe3d +S = 19d909e358e71985179dab9113941ecad21e4f3608cb3a32dd065868af1657df8e06aa86855ac7ad757a7f8fb568a953 +Invalid = Y + +Curve = P-384 +X = e805e0733fc156bd582faaf794e58d4630ce73fc383cdc964dd337728f774e4989a697d79665a3282ee6e0ee343d6c7b +Y = 43821b7b9a6ce1ddf0c59ada552668a0cfc85a87a610b5c36b7a691947116b49a4099340306e53494fc6b496cb8d12b0 +Digest = fd1bb27d666e3d40f5bd19d8c026a3614404b9edc11e582eb80b044c +R = 3d4fa4ec95b55feac607fddc618d6f4eed71da65dc49d732e64460e5c80c57dc4421c64bacf3ef1e22995fd19c2a3cf5 +S = b11898ba475f2b28402d038afc15f171b99aab93437b35a2f8a3b89f42fdb7f93a0469d9da7652882000dd5bb1e8b9a8 +Invalid = Y + +Curve = P-384 +X = e15c7ef9791b9392c3e97389f2597ee161545c267e584b94262870ef25fda348f72349f396c27ac884fa8d776387fdd8 +Y = 107b4a7da8be564a14f9c45e4df5cc9b62f0671b3f2c0573c33fa37f985fefd1ae3ff2640947ebb12dffda72757db6af +Digest = 3d9611421379fc93226fff23f5fe472a33f6bdc759d5705f7e9a2be3 +R = 9d715fd1a3668283fa83c407242e8d2a4f3fa1bf41919ca4101114bd0e0ac1b16c4379edb11de5210eee8618d42e9ed1 +S = 2dc37f453c8cfe01ea80c56d1865daf0f28847b12970132a1853c3ed80da6693e0da47a2476207947f29da34d68d604a +Invalid = Y + +Curve = P-384 +X = efcb97dd73106b0a2be4f665c496352f6938da9d0fa97690dc0e8d018b06dce2ba8d19b93ddfe889d549a33e64497c31 +Y = 66a0cb7e64f40470b6d09b9e12f217b59e9e6615af52fbdc4ddcb379e77809361eca2093a3e24c7103e971567018400f +Digest = 5598b06acf834ffbb2e50784fe2bc493fa51967f7ffadf1ece63f9b2 +R = 4ea5d4faf8ee52540db2f4c6283cea5302a3540a56e14c8a7533441c248465be99e10f23bba85be9634efaba7a8b172e +S = 4c98a2142ecaba7db44c78658efffc1175f810a147306ba2e6498553526adb1507d7a99a372e0f84c8dbd160ef7fd5bf + +Curve = P-384 +X = 4e916a3cf2561580b49ecc52321db7103292fd2fcce8dd4d6f86be6035808e0df51c3c4ac1894f0b08ef6ebf953e0d18 +Y = 4e6f28895d024b4c71220b27052ddd4bf6115a260825acade48c043b3e06d2b6b8e4ebdf465980f3b013cb575d475bbb +Digest = 1668ee6ae19c2d6f23b9184b6895ede8f55549b23095d53ef89487f6 +R = efce00544ebe0d98ba6015c07e3e9d09af808d49a0820c22ef572a3ef9c8a684b377bef1f8b3bbddb734b9b0bd0b1cd4 +S = e80d0e183b3f00098308e20e5b4ae393a07f1d1a8defda9a9d10f19b3e5236e42f593b1dc57f6718dd8d4583f0175ff7 +Invalid = Y + +Curve = P-384 +X = 3c6528c82d9d5e8dddf41a211c70f78604d81f49853bdc746270f1340a2a645dca3bc7844c3680268fa5973cd1758313 +Y = 4b9e697f1caf83d3224486bb0a8cd6a7c56e47c91043d8cba3aba51b6e504441d37abcc9b7b2d49b9126463703e514a0 +Digest = 1b39217bcc5dc841b32ddf00245623c581f19cac8a4ecd03eb2c07f0 +R = 848814c01c3d18534f39bcd53a8736db16f0f77a015a0e578cbb2f831739723e83b29cb6d4eee7822c76ff056d0f467d +S = 05beb19f766bd1d4ec5e65786042258298a2dc617e3f13d8e2f0f4b50d934565f3162c737fa791a81897397f29305943 +Invalid = Y + +Curve = P-384 +X = 80c3f6488dcd76f33cdb75e30f8452ab9a3bd6110f14e25179b0aefe4c19c60a07b4af10844b130b0b75a7024e341298 +Y = 6c85a17ad4bbefb33910250e05ac02a17c892c3380712d06dd070843dff0d040e219dae78679b774cd5eff0adb67189a +Digest = 23cd0066d1d88702c5d4461deff89aa5662b517806a04c4da30e0d82 +R = bc444deb0c7dd9f96f20a7ffd3ddb35a1189316655531860c39b5f87f09992106985e5562e083ee9f538c8e2d5363c52 +S = 91adde5d47eae80a98661f4347fd6e4778478c3d4aff3cff8aa92e2345a8e03cd4ab64adfd38e461bb98b496516439e7 +Invalid = Y + +Curve = P-384 +X = 97c3f446803a61a7014f61cb7f8b3f36486c7ea96d90ee1767f5c7e1d896dd5114255abb36c74be218c1f0a4e7ebba3d +Y = 553ed1fed72c62851e042f0171454f120029adba4ee26855ab881d9470355f1947aa1d2e806a7ff2583660fedbd037a0 +Digest = 647eb206a8477440b4bd048d00f37dca8635b15c2a8e79e2a9d74fb9a5553211 +R = 7b06d6c2b63f1cc3bfdaa897d07dc15a83bdf35d979f70c34578332b3f4920422bb24867c51bde10831324df424e04ec +S = 4bef715161f400dc98d4b63bd13ff4ad4a6c981ead44bfc662fe9bca4b56cd790698e4deddf9a4bd69327f26bfe801e6 +Invalid = Y + +Curve = P-384 +X = 08bd5c6cdc1f8c611df96485090e20e9188df6abb766bff3c1ba341ed209ad5dfd78b628ec60998ddfdd0dd029352fbd +Y = d9831d75dec760e9f405d1aa5e23aac506dc019fb64d44bd57f6c570d017e6609f8fdbb2dc7b28ca9e00e37cd32a3b73 +Digest = 9a4985f744dd6f2774cb6f20ad6b6969e212abf4ac035b72ad3f8b1955ae1862 +R = 8b372c86ed1eec2163d6f7152e53696b4a10958948d863eb622873b471702ac5b2e75ff852149a499e61510905f98e4c +S = b2ed728e8b30787a28f2a6d3740872e47348686c7cb426411379411310241d25f08a026b853789b1157f1fc1a7f6ff49 +Invalid = Y + +Curve = P-384 +X = 10a784abb3c549444a62c28df1c926b8aabb20c8d9aa4b1f7ca830258857cbe9718dbc9845fa9cbb78587a373baee80d +Y = a1ad0c10b5ab6780cad49c8cd3eebd27de8f1b382ddd7a604458cef8e76ca632a7e44e1c63141a742426cec598029e2e +Digest = f5b47101b4ff9baf64aca830b6afbc4f9620035d88a1d84a12cefa6f7f99faf2 +R = d9e52be2a3f7f566899cf6daaa38116d092473066f3a1bf91f3df44d81bca1deb438d9d25ce1632599c1d3576a30f128 +S = 0cad30bce4b3d7f40b3eef762a21bb1a3bad77439838b13024b7b2c70316875a99e80723a74a9e7a404715ca06a5d673 +Invalid = Y + +Curve = P-384 +X = 8760182393132d69011edfa127e36f92eeac8272641c27f52f3337ef8af7451e6d14f4e4590c7eb9fafb76e8c92865cf +Y = ebc2b123ed871ca570ead40ae8f6f32335393c569b21b38f626d09c064a3c8668e9fb10a4667e0f0c68bf25ca98fd6dc +Digest = 979131ca1d07e0b4ac6f27b20a978e0a230159eec4906db5dbd22b10ec71af87 +R = 1db957e5c2d294035d7f476a0cbc28a4aac2614d8212de5017076cd836bf04ffe237dce8fec91f2fb5ef82449ff1c65d +S = 3e3b9058d0a9c5b417f9c6f86557b9d50e7a902694a7012a1be6bb70708497e4d39fc1f6d6bc60dfa52d23cab173385f +Invalid = Y + +Curve = P-384 +X = 2b1f98d2acdda8347b9a68c75174408eae7de3d6b9c08c26e73ce9ed2ac147b8d90cd82e30ab43909d63f6b457de2071 +Y = 33f5e6f5f5793201991e014cce0045d04adc352298e32f45f4e374450111c8456b5c2efaec43d157949b5c191b2bc934 +Digest = a1daaf888d93a2a7e52bcd2a66cca3ff2e02916616d1919adefdd7257490e5b8 +R = 23d046402cbce807d232bcf0dc96d53c72992e0ba1ffce0d79050c0f4c5ad9bfbbdc1c96c730d67ff3aa3edaa3845da9 +S = 2cd46a4fe5d120b3af3a6d9ea63cc78f4079e8b5520a8fa96828334a4f182ff4d5e3d79470019e4eb8afc4f598b6becb +Invalid = Y + +Curve = P-384 +X = 86ac12dd0a7fe5b81fdae86b12435d316ef9392a3f50b307ab65d9c6079dd0d2d819dc09e22861459c2ed99fbab66fae +Y = ac8444077aaed6d6ccacbe67a4caacee0b5a094a3575ca12ea4b4774c030fe1c870c9249023f5dc4d9ad6e333668cc38 +Digest = e3bcded61cbb0bf6ec20d59f91e8e73e532f15b082b89c984c1b51fb0d1db8a9 +R = 798065f1d1cbd3a1897794f4a025ed47565df773843f4fa74c85fe4d30e3a394783ec5723b530fc5f57906f946ce15e8 +S = b57166044c57c7d9582066805b5885abc06e0bfc02433850c2b74973205ca357a2da94a65172086f5a1580baa697400b + +Curve = P-384 +X = 9e7553eab8cc7e2e7396128f42ab260c6dbb5457cbff2070ea7c0db21def1537939e3f02699e5dd460eca3798d08bd6d +Y = 892c0c8e47dddf858e89099a8fc1026e8b8333532b22f561f7647f63f9c79dbf5e8dd18fbfe6ff34902233119c5d5aa3 +Digest = 0f2a9b447ea5cfcfb9e67d661d7f0752befd3b4e3454fe40b9ae1eca47806025 +R = 2452da6a48c3749b66e576e0f1f768d51728be17aea149164c4e1654c5ce27f625a4610c4a2eeddb3a0626d3abc6c37c +S = 499504fb58c9db24a7ff5f7921e1312f8aa583c08a308e080f5ef1acf5cdae7927c4101573db069ab0b6de7f4f1cab38 +Invalid = Y + +Curve = P-384 +X = 0cf4dc51e71185a29c0c6fa3c075d9da5bd7ede085053344dce5dbbe8329e8ac9045f7246c9d0efed393b8e113c71429 +Y = fdb7917b73974b355cf9f3bef6a0a460c2d39fdf1fe32a7744be0a54ddd1cfa8d03914cff4b5ca536b40707ff2629aa4 +Digest = 331aefe2369b9c5ee6dd9f850259b3b8512f5934434e61573f97fe2c1cd2b147 +R = 3812c2dc2881d7ef7f621993b161672329b261ff100bbd19fb5826c9face09aec2017b6843d69336b813b673c5402527 +S = 5dc102fab9d6325131c556ec00309c2959d1031a63fbc1e2d5d04996d3234ed33875c0ab98e5878e9bc72742519ed398 +Invalid = Y + +Curve = P-384 +X = 6c590434988155236b43147389c6dbfdd27dcd3387e9b4c2587ece670753a542a13a736579887791cf53d31e5ce99994 +Y = 35a20194ff3f1b55f7ffb2758ddd4b98dd0d9e0cc213e10ed25e8e0430fe861066c1d4423c67f0c93f7ebd87fd3c561e +Digest = 153475076a003545d3ca3d4a772866f12cc85f6e69f8c486a91a80fd709206b1 +R = 89ff866889245e797926509e563b1746920b78c9370a6cdae52663730d131e558e327d1f5fef8faf9e6c802fa29504ed +S = 8dd68e2de2f788e598b3e5a60c18d81849a0cc14b3b0e3c931910639f3125e5d6045f00330b1fa989252a80f95419b04 +Invalid = Y + +Curve = P-384 +X = 499cbdf18ec4e69b88051543c7da80845fa2de8be2b9d9045fee7f104a8b5b7d04e69142de9955c5ab18c5a34ebff075 +Y = a29cb8d28836b201a389922b6f8f93870f09c80a00242d00d32656a43ac1440fc55bcb123551a73290f603c3469be9ed +Digest = 5f00b3b48c1ee8287abe6f3fbc3438b91f4268f318ae2aa1e7810369d6716020 +R = 25d4d243da6fd9b439a9242c3656fade7acb7a306e8cf23ea89e3ff4f9330be19c61aaa42d7b426d12c8e0f96b80dae5 +S = e7a99cf4b269bb4a6210d185e9654602523b5cfa1cddc94b1db92018aa557ecb6adda44c816975f5ec1756b6df3c44fd +Invalid = Y + +Curve = P-384 +X = 9a74ea00203c571bd91ae873ce0ed517f8f0a929c1854d68abd3b83a5051c0b686bb37d12958a54940cfa2de23902da7 +Y = 6f20ccf8fa360a9ec03d7bb79ff17ad885f714757ef62995f824908561dc0c3dffc49d873627936a2fff018b82879ced +Digest = 45c3a1b29a18780234f12f5e4b64e7af9de2acf0029ce55b706cc79a7e4df994 +R = acc1fcac98c593fb0a0765fce35a601c2e9570d63ea1e612fff8bc99ac2d4d877750bb44cfb1014e52e00b9235e350af +S = 7f53de3afa4146b1447e829ebac8f5645e948cc99e871c07280cc631613cfdaf52ccaeccbe93588a3fd12170a7ec79fa + +Curve = P-384 +X = e22f221809fb7a054ac799a70b3d24744eb7c5096c8671770399527c88ccf9ddaea0257a0ae9430d927ff5d9f109c533 +Y = af4101d60df9b306ae92da7592f4faf3df422a3e33f1c2ed2973b2b900eefc346b4cf024de650abf537cecd12ac77618 +Digest = ef1057d83a6e6481be7caf2c12c15f085ff971f02f0db8544352558e2b9fd61c +R = c39a8e79f0560b9f26504469a470c7b2230c0d25de07c206e87dfbde9aff0a5d85322f56dfb50d4c1fc67c67d615dad7 +S = 2ad94dd13a39cf4f4cb24c2c81d4c1181652363addd856dc9ba7455458e40ed047cd113129bc87f43949d5a98a0d5205 +Invalid = Y + +Curve = P-384 +X = fa8ebc3682d90ac7356f0b75b9e3376e76518676e0bedd176cfa7fa57fea4b3a399dbb2bf735ec90b9c1705cf9fa6f57 +Y = 18c3fbca0150ec10696b3851f31fb3ba62c0b6be509d249e0d4b374c7a08e49338e0922e2a8a9319999e6569ab8d292e +Digest = 0c7152ec620fe9b783625196b41192dd5d49df184ad26965c970ac5e28bb1c4b +R = fb58ab09b8a7ef7a6ec05b854eae11af9b713f7c7540e25115f609846e636ad4f88dcf4dd61e311273df23ccda474f03 +S = 485be4c21b7c3a9c6b39ffc9f0c39f4050f76d2a6b3fae203d016318c541c1b4ad6cfc0d0950636ff6883895dd49e4e9 + +Curve = P-384 +X = e5f331536a2940cd67234bedf813c12e15aefa9a1a68429f8754bf2769a47c9c2efb5c42135e7b01a110d7302e097eac +Y = 63b2398612c863febd482184e834d3acb51408c49aacbbd35d8719746f37cb13e013c9505ce034cd815aacd10d2f7a0d +Digest = d925955406f6b6dd4df05270a2539a5924830dfbcbf6a5a34f21354db246244b +R = 96c35f22d036785a392dc6abf9b3cfb0ad37b5c59caefcc0b5212e94e86739a2674020ff79258094d90d7d59f09d47a1 +S = 373cbc865384734c56952f7a35a1fdecd88e8b343ee3aa073d30f5f25b73506f1e5f5857f668b0080dec6edeb5e1be96 +Invalid = Y + +Curve = P-384 +X = c53ad865beb1e2b92764065f1a6bb465ee94aacabe43426a93c277d02e00fe36be1c859ba08a031fc518a0d007668979 +Y = 6728d42bae9bc097151748ffa0982964bdd16076fa0e7cc15837c1f773b08d02c3dbc57339091ccc34105b84781150b4 +Digest = 6d5fa5b492406a1e93df6bb6364d7b17a24ef43807a1159acc77486dd7b49b60 +R = d4f0dd94fc3b657dbd234767949207624082ff946de9ce0aeb0d9993b8c7d7935760e1bf9d8b233bc7d6cd34928f5218 +S = 0941df05062aa8849610f4b37d184db77ed1bc19ad2bb42f9a12c123017592bf4086bf424b3caad9a404b260a0f69efb +Invalid = Y + +Curve = P-384 +X = 1f94eb6f439a3806f8054dd79124847d138d14d4f52bac93b042f2ee3cdb7dc9e09925c2a5fee70d4ce08c61e3b19160 +Y = 1c4fd111f6e33303069421deb31e873126be35eeb436fe2034856a3ed1e897f26c846ee3233cd16240989a7990c19d8c +Digest = 8cf5e81c6858b8395421d8c913f1ac887e282b5818eab525fb79feb9bc64bca7eb98f94b9e48b705e6c28311bb0ca672 +R = 3c15c3cedf2a6fbff2f906e661f5932f2542f0ce68e2a8182e5ed3858f33bd3c5666f17ac39e52cb004b80a0d4ba73cd +S = 9de879083cbb0a97973c94f1963d84f581e4c6541b7d000f9850deb25154b23a37dd72267bdd72665cc7027f88164fab +Invalid = Y + +Curve = P-384 +X = cb908b1fd516a57b8ee1e14383579b33cb154fece20c5035e2b3765195d1951d75bd78fb23e00fef37d7d064fd9af144 +Y = cd99c46b5857401ddcff2cf7cf822121faf1cbad9a011bed8c551f6f59b2c360f79bfbe32adbcaa09583bdfdf7c374bb +Digest = 965b83f5d34f7443eb88e78fcc23479156c9cb0080dd68334dac0ad33ba8c774100e440063db28b40b51ac37705d4d70 +R = 33f64fb65cd6a8918523f23aea0bbcf56bba1daca7aff817c8791dc92428d605ac629de2e847d43cee55ba9e4a0e83ba +S = 4428bb478a43ac73ecd6de51ddf7c28ff3c2441625a081714337dd44fea8011bae71959a10947b6ea33f77e128d3c6ae + +Curve = P-384 +X = 9b3c48d924194146eca4172b6d7d618423682686f43e1dbc54ed909053d075ca53b68ae12f0f16a1633d5d9cb17011ec +Y = 695039f837b68e59330ee95d11d5315a8fb5602a7b60c15142dbba6e93b5e4aba8ae4469eac39fa6436323eccc60dcb6 +Digest = c68382d0641ffad850c41365a8ec68e3d55acba376d1bb941e7dcdf7b71f37b8288b023b942373a40be1dfaaf4aea633 +R = 202da4e4e9632bcb6bf0f6dafb7e348528d0b469d77e46b9f939e2fa946a608dd1f166bcbcde96cfad551701da69f6c2 +S = db595b49983882c48df8a396884cd98893a469c4d590e56c6a59b6150d9a0acdf142cf92151052644702ed857a5b7981 +Invalid = Y + +Curve = P-384 +X = 5140108b93b52d9ad572d6129ed6564766f8df3755e49fa53eba41a5a0d6c1d24a483c90070583a66e3cfa52b6fb1f31 +Y = ff52498446a40c61e60c97554256472625633eda0c1a8b4061481fecfbe9c4503e99dfc69e86c9e85c8cc53dca6b8dc4 +Digest = 4b945020c329a61221060e924ec682eceb842c09537fe26265ad084753b89f7650cee4e8df30b38126984d80fd25d246 +R = b2726b2ba9da02de35e9953fc283d1e78700860d4c33dce8db04dd41499d904866c1b8debb377f6c0dfcb0704252174f +S = 0775b027068d7ad55121a278a819f52099ace750d5e996eaec9dee7be72758736cf769650148fbd5c411beb9b88f979e +Invalid = Y + +Curve = P-384 +X = 31f4fc2fac3a163a5796f5e414af6f8107ab5e4a98c755d81efa9d5a83c10128c16c863190112fc29d3d5f3057a2edf1 +Y = fe208743f3e96c3a34b5fff78c9716c074a1ce3dc01c3f0e471ddfae91cd88e7dda38dd0e5e1f91b00b8539da3cc10bc +Digest = 2d6affdf541609f649dbe9fd5829059bf42021fcfefee42d8c9cd5c127015c06b4c3c13ef56d08767788955887752e44 +R = 706911812ec9e7370234efd57b2855975eab81e9c2fe783aa8e442dc6e7d681dab2dc0dfc6765f87ab67001108e3facf +S = 42c89efa22d853d32f619c9fe13e9852889ac98a9fed5d4fa47fed238e1cbe70d7970af9f7bdf84e51176af4885f2490 +Invalid = Y + +Curve = P-384 +X = 1f7911dcfe63a6f270cf75b8584d9b1b4a00afc1fa43543c945945b8a821ebeb37fbc705a000f9cc7c35f7d27027b7bb +Y = f11835ec80c4ac06d99247e73bf72522109ac255e6109262de4dfbf9619244f74fb6c9ee57694537d7e79c248db34dc4 +Digest = f4b0a912331e7fc59a7071e5f47c9dafa6dc09b32c5c3d05301b3833bbe0b9168e2b63f12248849572a322b2f5423b8d +R = 3587c9c6885adf3be1086825f9a41ccd2edfa0bd95e7fc4dba5a9710f41d539132de7772f14c18e318f8992b66d2a86c +S = 73a844d729599d4e3e3c1b63e9c4bf5a73d1f69e0160857fe63a56c381c051f5c37ea6b4cc4caacb6ff26ef9699efe30 +Invalid = Y + +Curve = P-384 +X = 2039661db813d494a9ecb2c4e0cdd7b54068aae8a5d0597009f67f4f36f32c8ee939abe03716e94970bba69f595fead6 +Y = e2d5236e7e357744514e66a3fb111073336de929598eb79fb4368c5bf80814e7584a3b94118faac9321df37452a846fc +Digest = cae50a424395e38bde9ba31fa5ea0c107ccceaff06663719162aac2c3e15f2b2cfd376f90d371326e1d29e0392a756ee +R = 164b8ac2b34c4c499b9d6727e130b5ef37c296bd22c306d1396c6aa54ca661f729aa6353b55d7cf1793b80b5a485115f +S = 4e7187f8f735b7272f2c0985315b5602bb9b1a09f32233aa10570c82d1ccedef6e725800336511e47f88ddbbbdc08f54 +Invalid = Y + +Curve = P-384 +X = 46dcf8ee848c6459fa66d1cae91ccd471401a5782cb2d3b9b9264189f0e9ddf7197b05c694931bde3306240cf9d24b7e +Y = 79d9508f82c5ead05c3f9392f3b1458f6d6c02f44420b9021d656e59402e2645bf3ba1a6b244ddb12edbb69516d5873b +Digest = 039fe89dfc54e7f2162545af700a8c49a1216b08854643656b07d74e7032516fd0c9368c5e5ce54655e4d08baa29b6f0 +R = 5ffba3b5bd7c3a89ec40b47884b0b3464e8abb78608c6d61e1e62c2ca98d44fcdf61825d69dffee8408d0849d0623bac +S = 0d2597b5fc3842ffce1957172253a8c9c0e4dbe770ce54f70f139e0545dc34ec639d609e14175bdb2b812ccfda00c9d4 +Invalid = Y + +Curve = P-384 +X = 097cea75f685cf4d54324ad2124ce3f77b1e490bbaa1ffacde40dd988f7591e1c5d158e6f232500d958762831914af7f +Y = 716d8bc056daf69ca2edd21b89a6ae9923cfcae87bfda5f9a6e514dd4b9d28d164fcc613ca2afb9660adfece59f09b66 +Digest = 02afb35f1df33b3d83df3391ca4184121ca52f520dd12ffc891aee77eab6503f232a5b1231bd997239751f46c4133edb +R = 1c5d4561d2a3af8835839b543098c101c715c545eb7d00300c5cb05bb08dac29e732ffdc31c50915e691999ad505104c +S = c3442f2fb1498fd47c2f959edff37a19783e3ccee80dc6955ca64db087fd188e67358e7b9223535bbb858d21ba6a978c +Invalid = Y + +Curve = P-384 +X = d2e2b3d262bb1105d914c32c007ea23d15a98197f0ed90b46a17f3d403e406a76c8f752be1a8cd01a94fd45157f6511a +Y = e585fba180017b9983b4c853ad3a5dd52e079c5f0ef792d1a0213b6085e390b073de1a4b01749ceab27806e5604980fe +Digest = e66b11b84f87c38526438e5e3c5b4521248c358eaab80e40526906a05fb29d14d4e5686681f03bc3f0025d45dfb83b5f +R = 49c001c47bbcee10c81c0cdfdb84c86e5b388510801e9c9dc7f81bf667e43f74b6a6769c4ac0a38863dc4f21c558f286 +S = 1fb4ff67340cc44f212404ba60f39a2cb8dcd3f354c81b7219289d32e849d4915e9d2f91969ba71e3dd4414f1e8f18f7 +Invalid = Y + +Curve = P-384 +X = cd887c65c01a1f0880bf58611bf360a8435573bc6704bfb249f1192793f6d3283637cd50f3911e5134b0d6130a1db60e +Y = f2b3cbf4fe475fd15a7897561e5c898f10caa6d9d73fef10d4345917b527ce30caeaef138e21ac6d0a49ef2fef14bee6 +Digest = f6325d6bcaaaf1aba1197a290b33974f2fe8af200d5d726e78705904e9894ec31988e35dc76b9976834b7cd1c4c67146 +R = addfa475b998f391144156c418561d323bdfd0c4f416a2f71a946712c349bb79ba1334c3de5b86c2567b8657fe4ca1f1 +S = 1c314b1339f73545ff457323470695e0474c4b6860b35d703784fbf66e9c665de6ca3acb60283df61413e0740906f19e +Invalid = Y + +Curve = P-384 +X = a370cdbef95d1df5bf68ec487122514a107db87df3f8852068fd4694abcadb9b14302c72491a76a64442fc07bd99f02c +Y = d397c25dc1a5781573d039f2520cf329bf65120fdbe964b6b80101160e533d5570e62125b9f3276c49244b8d0f3e44ec +Digest = 709d1bf45b5817f5a67b859651eb47133ebed2622fda09ab66d3467b5e95da50ecc2c74d8f4d289feebec29729a4bfa3 +R = c6c7bb516cc3f37a304328d136b2f44bb89d3dac78f1f5bcd36b412a8b4d879f6cdb75175292c696b58bfa9c91fe6391 +S = 6b711425e1b14f7224cd4b96717a84d65a60ec9951a30152ea1dd3b6ea66a0088d1fd3e9a1ef069804b7d969148c37a0 + +Curve = P-384 +X = d1cf635ca04f09b58879d29012f2025479a002bda590020e6a238bccc764478131cac7e6980c67027d92ece947fea5a6 +Y = 21f7675c2be60c0a5b7d6df2bcc89b56212a2849ec0210c59316200c59864fd86b9a19e1641d206fd8b29af7768b61d3 +Digest = 5d54d236db6ab4691b3d50dc81471c5d388e5735ebdd435e9742a5a8a0ad0e841bab57326c8535a680ada57d2b3a70fa +R = 6101d26e76690634b7294b6b162dcc1a5e6233813ba09edf8567fb57a8f707e024abe0eb3ce948675cd518bb3bfd4383 +S = 4e2a30f71c8f18b74184837f981a90485cd5943c7a184aba9ac787d179f170114a96ddbb8720860a213cc289ae340f1f +Invalid = Y + +Curve = P-384 +X = d15ca4b2d944d5539658a19be8ef85874f0c363b870f1cd1f2dc9cb68b2a43a10d37064697c84543e60982ab62bb32c8 +Y = 062fb7dfc379fc6465302ac5d8d11d3b957b594c9ef445cfe856765dd59e6f10f11809e115ac64969baa23543f2e5661 +Digest = 67cf9e6f9e9558a379ef7361771323a4f3925f2c7a5d94d9156bf2d9d45f9f8fc4d47322da622fbce92fc764a2ccc327 +R = e2cf123ce15ca4edad5f087778d483d9536e4a37d2d55599541c06f878e60354aa31df250b2fc4ed252b80219552c958 +S = 696707a7e3f9a4b918e7c994e7332103d8e816bbe6d0d1cf72877318e087ed0e230b0d1269902f369acb432b9e97a389 + +Curve = P-384 +X = c83d30de9c4e18167cb41c990781b34b9fceb52793b4627e696796c5803515dbc4d142977d914bc04c153261cc5b537f +Y = 42318e5c15d65c3f545189781619267d899250d80acc611fe7ed0943a0f5bfc9d4328ff7ccf675ae0aac069ccb4b4d6e +Digest = e8d6b550271b486e79f6975cff753d49519ed9393b207af7039b4c070cbc2fe7d49dd1bb87f7021e442fadd80ce8a5b0 +R = b567c37f7c84107ef72639e52065486c2e5bf4125b861d37ea3b44fc0b75bcd96dcea3e4dbb9e8f4f45923240b2b9e44 +S = d06266e0f27cfe4be1c6210734a8fa689a6cd1d63240cb19127961365e35890a5f1b464dcb4305f3e8295c6f842ef344 +Invalid = Y + +Curve = P-384 +X = d4e93c4bafb54c06814011309e9f3d8e68b76a5452e364ef05ccc3b44b271e576c9028106b1584f09271c886d467f41d +Y = db730ccfdeb6644362f4fb510d5254bfe6f23e891e936132f90f1913e93baa8b1f8c0613a0f0c61a760ce659f22babc6 +Digest = d5c82ff11f555ce21c3f20a9ecfa6047cb6895e32fa0fb379f49085a59f61b7c8fa05058ef144cf47db5738fa40f4890cb59695998a2358162bbbf6d7f53517b +R = 8d0fd14a59c24b0c2a34b438e162f1f536fe09a698cacfe0760d026d1593265d02f2668d2a5e49ac0b21e93807aa9c18 +S = 3162ffd2adc9dd5ec1bb1d97d2b0c27b8ae234235ffb374878d0b76382002ea505e885c178d56a2d7809bd1d83117ef1 +Invalid = Y + +Curve = P-384 +X = c665feccf51e6bca31593087df60f65b9fe14a12022814615deb892eedb99d86069a82aa91319310b66588185282dad6 +Y = 1e6e25bb8ae7714415b94f89def0f75dcb81d4af6b78d61f277b74b990c11aff51bd12fc88d691c99f2afde7fbd13e51 +Digest = ea056beb112fa9aad69c8dfe51ea947b772bf1c11287edcede43a98089d21492ed581edcb6d1823e2873aabba213b84291db3bffa6eac3ae43a92fc2da276a24 +R = 0e18c4063137468fe864fdc405ad4e120176eb91b4538b28ce43a22ae1a310cc22a2f7a2b3a0f3d15e0f82038b4a4301 +S = 5a1620e42041ce4357daf824befbb2ed65596bcd8214e88726149b26b1f416b9472a8877413f1c3705fc2edf4731943b + +Curve = P-384 +X = a6bbf85e8068151482ce855ccf0ed22988fcf4b162c4b811cb7243b849299e3390a083147fbd68683203ba33588b13ae +Y = 5c837ec9f2eda225c83ab2d5f10b1aa5bfb56387deebf27ecda779f6254a17968260247c75dd813ea0e1926887d46f86 +Digest = 81b1303e10f25d37877b09f9d82dbd894e40264992d86cc74656ebeef505b46fdf9dec312a7f0a26e3f56a7195d5b01d198c378fff9d049e00cbad9586da20c9 +R = 9c11879e59659848274fc1ef5a6a181af813d23708b09a24dc06c089b93b918828dd938a75a34d5a681b0af362dc19a0 +S = 9c362231962ba7579c4a874e87bdc60dc15cb2e0677149c8ea31162963e05a6614616f67a5269616071cf095be7ff44b +Invalid = Y + +Curve = P-384 +X = 9c1eb5cdb1a873e4c275b7ded8712b9058ee0d9ded06c96a2a8d7c652b82e894e2f918dd8e18138e5c34821744b97952 +Y = dd474c93619f02b5d4fe30ea7805c1a13fb80008a81bb5f3eeb95cd11f38841b8e34d64f2c6cc2d6cc2587365eed6b6e +Digest = c0f9ae90fe8aaf54962e7d47a832e4ca6e60355e4066cd2b08bff78650d4e4a5d1eb1de296f9f0ef92887e09f82e0db4411aa9c3c6b109159bd39feed40419a3 +R = f17b2f2fa3b5c8e9c62a633e5d417139ddf3dafba75b464fa156c99b3948a0aca532c7fd3e14a266eb17e7fa80881da2 +S = 01c246866983fa74d6dff38b1ea091f8afd218b5a42467761b147c19a3bb20cd24be8ed1f95f1e61863a709d2d0148e2 +Invalid = Y + +Curve = P-384 +X = 20622a293edc96d83fee77cf1ee8077c61d6f8ed0073d53cfb5ee9c68e764c553fa4fc35fe42dade3a7307179d6fc9c2 +Y = 710fa24383f78cc4568fe0f4ecbbe6b11f0dce5434f4483712a6d2befae975a2efb554907aa46356f29bf7c6c2707c65 +Digest = 5cb8ed471a4001e280a0927faf25183c857b9b2de21c8566e8a1bf04ee085c36db7fab9d8f627898b3bb23c10225305938b56a732659f2cab3fa857d80dfde19 +R = 45a6cf5cef06256139caa709292d1e0f963d176add188572e9c7be29af21a95853a98e23aef0a0850e58d44d60b6d780 +S = df8d71cd5ab22fc718070078103483e5258734872ab935435f21ea199018e49a69c064a63801beb0759fde6e2c4a85b8 +Invalid = Y + +Curve = P-384 +X = 83a4fecc0bf0a353b0acf6f54094b822f2b12564e172b296f3461cafa7315d7d31d0089b1b4c18ad3c86bd18f539774a +Y = e4fd57c5b2937e6fba1e7d72fc3f02352bd79c13611931935f4dfd073b9379f862f2277585137e996e212b5b6533dcba +Digest = cd7c623c3c3b52f46be0ebb2b353ff97db3cd7dfc1a059a57668fc50101aeeb37b8aee9ddda8ab611546999a120cc9acb0e2c3df48dee66d5c31a46a7be94bc7 +R = fb02804010a570d702ebfbcf3d6cc9d55ddac2bd4b4de56d325e9790571b1737f91d3fa1d4caeec6eea806195aed3187 +S = 1fd20fe383e907e77639c05594642798619b2742090919bedeefb672c5700881baf0df19b9529d64bc7bb02683226103 + +Curve = P-384 +X = 208a8c5a6b59458160c5b680116c8b23799c54a7ee8954a4869425a717739facfe4fe24540505cdc133fde8c74bfca78 +Y = 22aa7aba797bde1e8389c3c3f8d8d9aa2a914f4d2d7aaf7187ebed9b2761975718ef97660ba0b8a71dee17f2b982e2cf +Digest = 007b907b90fa60835d45d2f0201a4486d9782fea4f0a235d97d4968336c5369c6c2e82bded56288a10fd6741f4c15d1633bc92e0196308d9f0490fc2077d3b6c +R = 0b4e835ed83151d2bde96e201c54544ba5f301aca853957d3c538c9858fcce796b60fc50f5600a48dcdf13e5bc029827 +S = 0270adf02d31d5428d523e13d7d315c1929a1d89bbd0f61eec0b1186abe1c307cbba6b1067a68bc3947e6196d49719a0 +Invalid = Y + +Curve = P-384 +X = 80ae47e99107d6148b1088c6694df5c1273ff336b66e45b68a7c65fed735129dadcaf2b900e9f8ec50eff70a5ba89ea3 +Y = 47450efb5669bfacd7cbff1f801aafa0812ff88a6ae7b5a1f85e88e19129ed995f509fbf8dec15ce42bbbbd33814c09e +Digest = 1cacc8f609080e7b8339529f944850a700977ef9107f40956fb35645e15fdd54ef01755f07a2582d0bf2ca0cb84ee8ab154fe0914dfc9ad7ad5fe54b857d0f4e +R = bae6fba7b1485ecdca48219ead3c39295fa9c196b1f0941445b1ac768e33962f68d37f1f1749eaad7200064aa202fb41 +S = b411a38d02deb42d1015a7837b033c89d2f37d92c70fa8bb1f592223f7750520b950f30277abfb4155a3ab194b3beca0 +Invalid = Y + +Curve = P-384 +X = 45cb6dcca8d2e80ac04536a22f9d68ea2313245550108ddcd32799d154c0a55492e49463e826275bd9bf0d5e380205c1 +Y = 6fd124f5a6c745751ccfb3ba4dd9144ea8fd41a4d9a4b34820434da66aa7385e73ffe71e6c11ed1beb6c7af22ce00edf +Digest = dd7947a5b9a1c988dd7dff537e15335aacafd3e602adc8373765013f338334dd58aed4fb7144de0007c3410d79f5e78bcd4cf0dd63cc33ed3dd564882e299c7b +R = 2c782c4263eeee63657fbf20fa287a1a81fcd14b1d3bae333928ba4fc31abb20edebc130714380608e38ea74309eca9d +S = 716113d95bc9dba532bfb470112b0d43d9cd6560ad15e0de2e514994801ff339bcf19ad4ee2b8af573f57c038fbd70f0 + +Curve = P-384 +X = 36c1459d9e9f7b6c1598778c784cbf94661a2b11370c02ee092f6ea0ca20acf81f1ed5048a28a1466a91689df26bc291 +Y = d1367418c7b216bd32c6dafc8b2be99d02cab68df990758b2ddd543b7eb6ff6e285b649ffe588b1811b549cfb5f0289b +Digest = 242ff2713c03e3d5277652f8e7fb1e5a1f0422b6652e1bdd696e46c03cdd3aaac329b1d88e7aa345ff7224ce6dc6df05c7e9d7dc2665282c817d15a15b8288fd +R = 40c338adeb504193444bdb95336177362031aaadc5b7e151e42030df9dd8687f3cb8fe2292fd4f9206989c089d966dae +S = be4b2ba251094c24de006c89af2b5c77e6937f36d7bb703b4f8edcfe65d45f4b2fd2486222163ae0ed9e215c0a96f488 +Invalid = Y + +Curve = P-384 +X = b5eb6670bb0b0d3aef10e533d3660756b7372a2a081d9d920130034f48202cd43b9e2d1e5893d0cfb322db65ab839716 +Y = e28444770396041b489b302786a57fca9a98f19685cb4b455d219151e64645ad30dd3149ec96f3bc90879834b65e58aa +Digest = 8d2e653807e87962883956ee3705b2167c50370c3af12eb8f6c26f0f15ede56dddc7d0c9642a1c1c2444b06571fa1a4d47e7884acc7ea3884daaa50940f782e2 +R = 0887a13df940907864b425ec0d8f91ac719abcc62b276fa08c5122b38831c8930abd3c8454e98182bb588fc72843717a +S = a380284eacaa36a34e35f04fbf6e28ffb59176f41ea52d9c9bc1362eccd8e0d699c2e08111d93e9dc2785637b1f4f09e +Invalid = Y + +Curve = P-384 +X = 700e8f65e052e918a63a96fa57f4eda849f9f9faca3302d6ead66ebf85838f8145a6d6718a681b7bef73170d7254958f +Y = 9e9e10357658913007803859165926cd1e5e92c3a644d834098cb1cbfab466349bf4238a5154cf50ed77c77a78263e81 +Digest = cf885fa7a96db595f825a0ccc56b70b60e0e1c30d0a15af636d1f4957328aecb7eeb734d5874bd72ddaf15c357ca36bd42abf387f7b771ea6160e2e23a08652e +R = 59be870e0fd684b000cce95c616d9f34674354e9d20db15d204b8a6285ff55258e4eeb49da1573ef1030cd6b2626dcfb +S = c0bbbf71d87479d82575458be9f4d686921db7ea458d620271f51ec3f4d1afe3bf25ef9c0c400eb7b92cd7058fb17346 +Invalid = Y + +Curve = P-384 +X = a9de6f029445fffcf16349b44095cc83b11e3d0d9f08654b158014803b1cc31b8dfe00b1a8167c6f704d69cdd62c6512 +Y = 27336a503a669ba1d1f3619f51dc8aa2a44b2075c682a36f071be486e7dafba9adfac2ce74be0442b7251e99304ffc05 +Digest = b7e73f38767f253790e7fff019b4e0e61562aeb97b2b749afec2a61c87ab0e15916d4286c0a13989912f6bafdf3efc6f64ddc3b944f9041266e5abd4480c1606 +R = f93a4d2eb94d087f28572847e0099ae2ee944efacdad392ec268c9c1e632e6ccd670c36584e58aba52a4c2b07127d55a +S = 941ee89cea6e7ed20213a95482fae134707ddf4d292ab1952ed5464f1f1138669dedbfc9998b696eaf469be5fb240c80 +Invalid = Y + +Curve = P-384 +X = e63500d6d13069c01fafc4518f1d429661c5bb6ad1ff0383037ca6a469a5c20c453dce03bf6e4164f7e26f849016b3d0 +Y = 83b7b731c2531c3ac61b194cf3db6dc02ccdfa16d9eb49f97bc4ec3fe6c8bd865ea27f1538531ad07dc44fc5107af8e6 +Digest = afc0ed355377d0ab0c4f79d420dcf67ad4920c013d5c8afde2287525da4596672927540418a61568b21ae7799d7659f16b85f611bd6e8d2066a55903da0c48b9 +R = eb78733e73fd64a6a1f23eba5311af23d26816fb8847671e01fdbd8dc7d5fce1a0823b080ee99e8d75edb3f100e16077 +S = bcaedfe599f98b51542c0f94ae1010611c6767ac3abb2bd887399d62fd0f1b3a0e97deb24c95a76de44521bf24c8645e +Invalid = Y + +Curve = P-384 +X = 3ebd869be687f82d844416e6816d698d82e1e22a1f451d50b6c146134deb07f05204c0b04e7dc07ebdcfd916531dc7c3 +Y = 6e4d7bde063edb7254a82b9d9249d2a2b9ad8988c37a84ac9f7c09daed42b1fd28f7cca1ea8b4f91a66e878224800bdc +Digest = 56a61339a35750e95770f28846930e3f594e8d759e07423718734a82b2a80430b0fb3378e40bdcf5c12be135be9a9bec32916b4988a763091a6da7b44631414e +R = 575f87a8a7980555a198cfdec279cbb2f89551b5271d242397c29f6bc4bf413dc30312a7e626ef7fc77a9124a79bf9be +S = f0b7d759246ad36ba8240c537b1eeb5d148c38d324f48028c598eaef6e49d79ff3f6cfe3a32fbbf6f3ed3aaaec31d572 +Invalid = Y + +# The following tests use digests equal to the order and 2^n - 1, where n is +# the number of bits in the order. This is to test the truncated digest not +# being fully reduced. + +Curve = P-256 +X = e57231383637c82c1ac801724cf7e03e67198f467a9beb60ac13cb582d13afa8 +Y = 8f190e090155fcf63810b858bc88e259dc49afef8bdef6fd06d93dddb1991aed +Digest = ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551 +R = 05cc6037bb021f4910ea2e489fab2bae6bb6a2769a97f42ba5736994102b7f10 +S = 5db54832ceabf8bccdb8be99b1a49cecff8feee045cb697dec43118e2695b1da + +Curve = P-256 +X = 6e0e2897b9a554ee287cdaf43bfbe25ca8404373971575a0e4b61c61aff5a2fe +Y = 23ea7823a411eb1b39f81bbde24c2cd6ac68be2c7eec3a0671c8676131b8905c +Digest = ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +R = 16831feeceab2fab1c575e073e944d73ce7e6f3e9b06312088f06159c530ff50 +S = 870cb824692638538b1569c6093fcb693c054e8e3b9a919e3bb26798910f66e9 + +Curve = P-384 +X = f4a961c19f9cc4ebe4f43081110955f3cede085a08c1415d726e80b2eb774028c5fc96f092ba3ea7d1288dd57fe1db08 +Y = 981398eed0895e09b3b582a0616f3024e51cca7b1ecc347dbf0d24a5f6a222b0c31912f8f5e427d4dde5c6c45212bb10 +Digest = ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973 +R = 0b77eaff05bbd922dd80525d2ab301cc119318f5a920a12c71c4b5ff5bb77d25a538983df9bdd5984b0d159daf21f1a2 +S = 73af85ad03a34b6b3993082bf719018d25d1555717b2d2f2535d0601af06a71ad020eff8232d065ab9d7fc4cd0c0ee42 + +Curve = P-384 +X = 54dd8d7cbf2ccdf1a42f5bbc615a372803b094f6040e3c7b651a61bc6912432c836cf2410ab7d67f543236751d81066f +Y = 2219d6257b1c80bf327c96786f2b5d0b5a9b9bf7eee9c853bf66a3bf09520494cb1f7823e4c566d79a617b7e201ead96 +Digest = ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +R = 9d923e199d98272e44b8fba382bf3c19660ecb4a9aae3513ff6802a73fef510c15c202807c3f9334b0bce7d6c6a80839 +S = 520784e6290d04d9b61993ee5ebc6fa8ff527fb0777c43cdefc7586701e60edb399005a5648ff852de80208232849fbd + +# The following tests are intended to stress the final comparison in ECDSA. +# ECDSA verification computes some curve point (x, y), picking the fully-reduced +# representive of x mod p, and checking that x mod n is r. (n is the order of +# the group and p defines the underlying prime field.) +# +# This makes the computation sensitive to values near n and p, and which of n or +# p is larger. Additionally, there is an optimization that performs the +# comparison mod p rather than n and compensates for the difference. +# +# These tests were generated by picking a target value of r and x, adjusting +# both until x corresponded to a point on the curve, and then computing the +# public key by solving for P in ECDSA's (x, y) = u1*G + u2*P. The digest is the +# hash of "hello, world" with the suitably-sized SHA-2 hash, so the test vectors +# are suitable for both message- and digest-based APIs. +# +# "x" in the comments refer to the x-coordinate of the computed point, not that +# of the public key. + +# r = 5, x = 5 is valid. +Curve = P-256 +X = 264d796a0dab9b376d34eea6fe297dde1c7b73e53944bc96c8f1e8a6850bb6c9 +Y = cf5308020eed460c649ddae61d4ef8bb79958113f106befaf4f18876d12a5e64 +Digest = 09ca7e4eaa6e8ae9c7d261167129184883644d07dfba7cbfbc4c8a2e08360d5b +R = 0000000000000000000000000000000000000000000000000000000000000005 +S = ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254e + +# r = 5 + n, x = 5 is invalid. r must already be reduced. +Curve = P-256 +X = 264d796a0dab9b376d34eea6fe297dde1c7b73e53944bc96c8f1e8a6850bb6c9 +Y = cf5308020eed460c649ddae61d4ef8bb79958113f106befaf4f18876d12a5e64 +Digest = 09ca7e4eaa6e8ae9c7d261167129184883644d07dfba7cbfbc4c8a2e08360d5b +R = ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632556 +S = ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254e +Invalid = Y + +# r = n-2, x = n-2 is the largest x without a reduction. +Curve = P-256 +X = 50a50c01132bf79e42b31fb278f7317b29515e9e1c973a41266b69048826fb8e +Y = aac53e7df37b5eb25ce4ddb705fc7135c6b1e00a7f56e30744f62f258afa5537 +Digest = 09ca7e4eaa6e8ae9c7d261167129184883644d07dfba7cbfbc4c8a2e08360d5b +R = ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254f +S = ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254e + +# r = n-3, x = n-2 is incorrect. +Curve = P-256 +X = 50a50c01132bf79e42b31fb278f7317b29515e9e1c973a41266b69048826fb8e +Y = aac53e7df37b5eb25ce4ddb705fc7135c6b1e00a7f56e30744f62f258afa5537 +Digest = 09ca7e4eaa6e8ae9c7d261167129184883644d07dfba7cbfbc4c8a2e08360d5b +R = ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254e +S = ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254e +Invalid = Y + +# r = 3, x = n+3 is the smallest x with a reduction. +Curve = P-256 +X = ce24c99032d52ac6ead23c0ae3ec68ef41e51a281fd457808c83136d7dcce90e +Y = 8f7a154b551e9f39c59279357aa491b2a62bdebc2bb78613883fc72936c057e0 +Digest = 09ca7e4eaa6e8ae9c7d261167129184883644d07dfba7cbfbc4c8a2e08360d5b +R = 0000000000000000000000000000000000000000000000000000000000000003 +S = ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254e + +# r = 4, x = n+3 is incorrect. +Curve = P-256 +X = ce24c99032d52ac6ead23c0ae3ec68ef41e51a281fd457808c83136d7dcce90e +Y = 8f7a154b551e9f39c59279357aa491b2a62bdebc2bb78613883fc72936c057e0 +Digest = 09ca7e4eaa6e8ae9c7d261167129184883644d07dfba7cbfbc4c8a2e08360d5b +R = 0000000000000000000000000000000000000000000000000000000000000004 +S = ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254e +Invalid = Y + +# r = p-3-n, x = p-3 is the largest valid x. +Curve = P-256 +X = 768a0d300a595005a520130e50927d403395c8e1e40be997b48fc048410f7cdb +Y = 16f217d8e1c02bd887e5de388a17783b182e61b5d534152dc2c4be8d75fdd706 +Digest = 09ca7e4eaa6e8ae9c7d261167129184883644d07dfba7cbfbc4c8a2e08360d5b +R = 000000000000000000000000000000004319055358e8617b0c46353d039cdaab +S = ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254e + +# r = p-n+5, x = 5 is incorrect. r is too large to compare r+n with x. +Curve = P-256 +X = 0ec505bc19b14a43e05678cccf07a443d3e871a2e19b68a4da91859a0650f324 +Y = 77300e4f64e9982d94dff5d294428bb37cc9be66117cae9c389d2d495f68b987 +Digest = 09ca7e4eaa6e8ae9c7d261167129184883644d07dfba7cbfbc4c8a2e08360d5b +R = 000000000000000000000000000000004319055358e8617b0c46353d039cdab3 +S = ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254e +Invalid = Y + +# r = 2, x = 2 is valid. +Curve = P-384 +X = 016d2db67561bc126ad6c344d6eeb2713a9e2892c649af0f015c6b7617f160c8a3b3a88add669d7155025073c5ac5b4f +Y = 43bf2ed0088af08645c80aa0a24a567a94ba2d794e9689d3ad4b185bc5d2dd008333e2dd2ebb5069a9b32251a3cac71e +Digest = 1fcdb6059ce05172a26bbe2a3ccc88ed5a8cd5fc53edfd9053304d429296a6da23b1cd9e5c9ed3bb34f00418a70cdb7e +R = 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002 +S = ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52970 + +# r = 2 + n, x = 2 is invalid. r must already be reduced. +Curve = P-384 +X = 016d2db67561bc126ad6c344d6eeb2713a9e2892c649af0f015c6b7617f160c8a3b3a88add669d7155025073c5ac5b4f +Y = 43bf2ed0088af08645c80aa0a24a567a94ba2d794e9689d3ad4b185bc5d2dd008333e2dd2ebb5069a9b32251a3cac71e +Digest = 1fcdb6059ce05172a26bbe2a3ccc88ed5a8cd5fc53edfd9053304d429296a6da23b1cd9e5c9ed3bb34f00418a70cdb7e +R = ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52975 +S = ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52970 +Invalid = Y + +# r = n-1, x = n-1 is the largest x without a reduction. +Curve = P-384 +X = b5b375264c09acf145ca91d12ab10a096092a41ec43f4d718e129ea1c12b2dea62c7785efc52f46f009fb1dba133e811 +Y = bc0b2af172b4b3068d032a798080e76f4d56f72069519e3c19a43682a41794e52cb3ca139348d6bbc923e6a4f7945cb1 +Digest = 1fcdb6059ce05172a26bbe2a3ccc88ed5a8cd5fc53edfd9053304d429296a6da23b1cd9e5c9ed3bb34f00418a70cdb7e +R = ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52972 +S = ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52970 + +# r = n-2, x = n-1 is incorrect. +Curve = P-384 +X = b5b375264c09acf145ca91d12ab10a096092a41ec43f4d718e129ea1c12b2dea62c7785efc52f46f009fb1dba133e811 +Y = bc0b2af172b4b3068d032a798080e76f4d56f72069519e3c19a43682a41794e52cb3ca139348d6bbc923e6a4f7945cb1 +Digest = 1fcdb6059ce05172a26bbe2a3ccc88ed5a8cd5fc53edfd9053304d429296a6da23b1cd9e5c9ed3bb34f00418a70cdb7e +R = ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52971 +S = ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52970 +Invalid = Y + +# r = 2, x = n+2 is the smallest x with a reduction. +Curve = P-384 +X = 01b54a697305092bac2939fb906d7471b411c4eba8654169166a5da3810e1fc96795df921f7abbf519be4a027435176c +Y = a19012a3518773d508106d4153adee43c3c384fa62ce36a4addea08f593ec9c76b09a6b9c69d29bd7d47eb48e167dd2f +Digest = 1fcdb6059ce05172a26bbe2a3ccc88ed5a8cd5fc53edfd9053304d429296a6da23b1cd9e5c9ed3bb34f00418a70cdb7e +R = 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002 +S = ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52970 + +# r = 3, x = n+2 is incorrect. +Curve = P-384 +X = 01b54a697305092bac2939fb906d7471b411c4eba8654169166a5da3810e1fc96795df921f7abbf519be4a027435176c +Y = a19012a3518773d508106d4153adee43c3c384fa62ce36a4addea08f593ec9c76b09a6b9c69d29bd7d47eb48e167dd2f +Digest = 1fcdb6059ce05172a26bbe2a3ccc88ed5a8cd5fc53edfd9053304d429296a6da23b1cd9e5c9ed3bb34f00418a70cdb7e +R = 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003 +S = ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52970 +Invalid = Y + +# r = p-1-n, x = p-1 is the largest valid x. +Curve = P-384 +X = c4fd8e68006b83f7b7b20b731ae405813aa05f6e57374589b36ae1cecd1d49cae1418c22f398188bcf4ef02e89fe7394 +Y = dd1164b3707f59e05129fa228b8448031db159985f035d93470dc42b3ab4129f0760c46cf201d42e73a7e33ba7402ea6 +Digest = 1fcdb6059ce05172a26bbe2a3ccc88ed5a8cd5fc53edfd9053304d429296a6da23b1cd9e5c9ed3bb34f00418a70cdb7e +R = 000000000000000000000000000000000000000000000000389cb27e0bc8d21fa7e5f24cb74f58851313e696333ad68b +S = ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52970 + +# r = p-n+2, x = 2 is incorrect. r is too large to compare r+n with x. +Curve = P-384 +X = 4e5e4f1a6e97059a6cf2f4e8129e5c7c64cb84f9994a41ff5bf30b29c1bf5ba6898627c91a23c73e05cd1a43c8f908c0 +Y = 06a0aed7f1e63a728f87dbd5360a67571a076ab0b4cde81b10d499959814ddb3a8c7854b0bbfa87cc272f90bca2a2254 +Digest = 1fcdb6059ce05172a26bbe2a3ccc88ed5a8cd5fc53edfd9053304d429296a6da23b1cd9e5c9ed3bb34f00418a70cdb7e +R = 000000000000000000000000000000000000000000000000389cb27e0bc8d21fa7e5f24cb74f58851313e696333ad68e +S = ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52970 +Invalid = Y diff --git a/http/vendor/ring/crypto/fipsmodule/sha/asm/sha256-armv4.pl b/http/vendor/ring/crypto/fipsmodule/sha/asm/sha256-armv4.pl new file mode 100644 index 0000000..5bcdb3f --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/sha/asm/sha256-armv4.pl @@ -0,0 +1,625 @@ +#! /usr/bin/env perl +# Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# ==================================================================== +# Written by Andy Polyakov for the OpenSSL +# project. +# ==================================================================== + +# SHA256 block procedure for ARMv4. May 2007. + +# Performance is ~2x better than gcc 3.4 generated code and in "abso- +# lute" terms is ~2250 cycles per 64-byte block or ~35 cycles per +# byte [on single-issue Xscale PXA250 core]. + +# July 2010. +# +# Rescheduling for dual-issue pipeline resulted in 22% improvement on +# Cortex A8 core and ~20 cycles per processed byte. + +# February 2011. +# +# Profiler-assisted and platform-specific optimization resulted in 16% +# improvement on Cortex A8 core and ~15.4 cycles per processed byte. + +# September 2013. +# +# Add NEON implementation. On Cortex A8 it was measured to process one +# byte in 12.5 cycles or 23% faster than integer-only code. Snapdragon +# S4 does it in 12.5 cycles too, but it's 50% faster than integer-only +# code (meaning that latter performs sub-optimally, nothing was done +# about it). + +# May 2014. +# +# Add ARMv8 code path performing at 2.0 cpb on Apple A7. + +$flavour = shift; +if ($flavour=~/\w[\w\-]*\.\w+$/) { $output=$flavour; undef $flavour; } +else { while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {} } + +if ($flavour && $flavour ne "void") { + $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; + ( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or + ( $xlate="${dir}../../../perlasm/arm-xlate.pl" and -f $xlate) or + die "can't locate arm-xlate.pl"; + + open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""; + *STDOUT=*OUT; +} else { + open OUT,">$output"; + *STDOUT=*OUT; +} + +$ctx="r0"; $t0="r0"; +$inp="r1"; $t4="r1"; +$len="r2"; $t1="r2"; +$T1="r3"; $t3="r3"; +$A="r4"; +$B="r5"; +$C="r6"; +$D="r7"; +$E="r8"; +$F="r9"; +$G="r10"; +$H="r11"; +@V=($A,$B,$C,$D,$E,$F,$G,$H); +$t2="r12"; +$Ktbl="r14"; + +@Sigma0=( 2,13,22); +@Sigma1=( 6,11,25); +@sigma0=( 7,18, 3); +@sigma1=(17,19,10); + +sub BODY_00_15 { +my ($i,$a,$b,$c,$d,$e,$f,$g,$h) = @_; + +$code.=<<___ if ($i<16); +#if __ARM_ARCH>=7 + @ ldr $t1,[$inp],#4 @ $i +# if $i==15 + str $inp,[sp,#17*4] @ make room for $t4 +# endif + eor $t0,$e,$e,ror#`$Sigma1[1]-$Sigma1[0]` + add $a,$a,$t2 @ h+=Maj(a,b,c) from the past + eor $t0,$t0,$e,ror#`$Sigma1[2]-$Sigma1[0]` @ Sigma1(e) +# ifndef __ARMEB__ + rev $t1,$t1 +# endif +#else + @ ldrb $t1,[$inp,#3] @ $i + add $a,$a,$t2 @ h+=Maj(a,b,c) from the past + ldrb $t2,[$inp,#2] + ldrb $t0,[$inp,#1] + orr $t1,$t1,$t2,lsl#8 + ldrb $t2,[$inp],#4 + orr $t1,$t1,$t0,lsl#16 +# if $i==15 + str $inp,[sp,#17*4] @ make room for $t4 +# endif + eor $t0,$e,$e,ror#`$Sigma1[1]-$Sigma1[0]` + orr $t1,$t1,$t2,lsl#24 + eor $t0,$t0,$e,ror#`$Sigma1[2]-$Sigma1[0]` @ Sigma1(e) +#endif +___ +$code.=<<___; + ldr $t2,[$Ktbl],#4 @ *K256++ + add $h,$h,$t1 @ h+=X[i] + str $t1,[sp,#`$i%16`*4] + eor $t1,$f,$g + add $h,$h,$t0,ror#$Sigma1[0] @ h+=Sigma1(e) + and $t1,$t1,$e + add $h,$h,$t2 @ h+=K256[i] + eor $t1,$t1,$g @ Ch(e,f,g) + eor $t0,$a,$a,ror#`$Sigma0[1]-$Sigma0[0]` + add $h,$h,$t1 @ h+=Ch(e,f,g) +#if $i==31 + and $t2,$t2,#0xff + cmp $t2,#0xf2 @ done? +#endif +#if $i<15 +# if __ARM_ARCH>=7 + ldr $t1,[$inp],#4 @ prefetch +# else + ldrb $t1,[$inp,#3] +# endif + eor $t2,$a,$b @ a^b, b^c in next round +#else + ldr $t1,[sp,#`($i+2)%16`*4] @ from future BODY_16_xx + eor $t2,$a,$b @ a^b, b^c in next round + ldr $t4,[sp,#`($i+15)%16`*4] @ from future BODY_16_xx +#endif + eor $t0,$t0,$a,ror#`$Sigma0[2]-$Sigma0[0]` @ Sigma0(a) + and $t3,$t3,$t2 @ (b^c)&=(a^b) + add $d,$d,$h @ d+=h + eor $t3,$t3,$b @ Maj(a,b,c) + add $h,$h,$t0,ror#$Sigma0[0] @ h+=Sigma0(a) + @ add $h,$h,$t3 @ h+=Maj(a,b,c) +___ + ($t2,$t3)=($t3,$t2); +} + +sub BODY_16_XX { +my ($i,$a,$b,$c,$d,$e,$f,$g,$h) = @_; + +$code.=<<___; + @ ldr $t1,[sp,#`($i+1)%16`*4] @ $i + @ ldr $t4,[sp,#`($i+14)%16`*4] + mov $t0,$t1,ror#$sigma0[0] + add $a,$a,$t2 @ h+=Maj(a,b,c) from the past + mov $t2,$t4,ror#$sigma1[0] + eor $t0,$t0,$t1,ror#$sigma0[1] + eor $t2,$t2,$t4,ror#$sigma1[1] + eor $t0,$t0,$t1,lsr#$sigma0[2] @ sigma0(X[i+1]) + ldr $t1,[sp,#`($i+0)%16`*4] + eor $t2,$t2,$t4,lsr#$sigma1[2] @ sigma1(X[i+14]) + ldr $t4,[sp,#`($i+9)%16`*4] + + add $t2,$t2,$t0 + eor $t0,$e,$e,ror#`$Sigma1[1]-$Sigma1[0]` @ from BODY_00_15 + add $t1,$t1,$t2 + eor $t0,$t0,$e,ror#`$Sigma1[2]-$Sigma1[0]` @ Sigma1(e) + add $t1,$t1,$t4 @ X[i] +___ + &BODY_00_15(@_); +} + +$code=<<___; +#ifdef __KERNEL__ +# define __ARM_ARCH __LINUX_ARM_ARCH__ +# define __ARM_MAX_ARCH__ 7 +#endif + +@ Silence ARMv8 deprecated IT instruction warnings. This file is used by both +@ ARMv7 and ARMv8 processors. It does have ARMv8-only code, but those +@ instructions are manually-encoded. (See unsha256.) +.arch armv7-a + +.text +#if defined(__thumb2__) +.syntax unified +.thumb +#else +.code 32 +#endif + +.type K256,%object +.align 5 +K256: +.word 0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5 +.word 0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5 +.word 0xd807aa98,0x12835b01,0x243185be,0x550c7dc3 +.word 0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174 +.word 0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc +.word 0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da +.word 0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7 +.word 0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967 +.word 0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13 +.word 0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85 +.word 0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3 +.word 0xd192e819,0xd6990624,0xf40e3585,0x106aa070 +.word 0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5 +.word 0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3 +.word 0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208 +.word 0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2 +.size K256,.-K256 +.word 0 @ terminator +.align 5 + +.global sha256_block_data_order_nohw +.type sha256_block_data_order_nohw,%function +sha256_block_data_order_nohw: + add $len,$inp,$len,lsl#6 @ len to point at the end of inp + stmdb sp!,{$ctx,$inp,$len,r4-r11,lr} + ldmia $ctx,{$A,$B,$C,$D,$E,$F,$G,$H} + adr $Ktbl,K256 + sub sp,sp,#16*4 @ alloca(X[16]) +.Loop: +# if __ARM_ARCH>=7 + ldr $t1,[$inp],#4 +# else + ldrb $t1,[$inp,#3] +# endif + eor $t3,$B,$C @ magic + eor $t2,$t2,$t2 +___ +for($i=0;$i<16;$i++) { &BODY_00_15($i,@V); unshift(@V,pop(@V)); } +$code.=".Lrounds_16_xx:\n"; +for (;$i<32;$i++) { &BODY_16_XX($i,@V); unshift(@V,pop(@V)); } +$code.=<<___; +#if __ARM_ARCH>=7 + ite eq @ Thumb2 thing, sanity check in ARM +#endif + ldreq $t3,[sp,#16*4] @ pull ctx + bne .Lrounds_16_xx + + add $A,$A,$t2 @ h+=Maj(a,b,c) from the past + ldr $t0,[$t3,#0] + ldr $t1,[$t3,#4] + ldr $t2,[$t3,#8] + add $A,$A,$t0 + ldr $t0,[$t3,#12] + add $B,$B,$t1 + ldr $t1,[$t3,#16] + add $C,$C,$t2 + ldr $t2,[$t3,#20] + add $D,$D,$t0 + ldr $t0,[$t3,#24] + add $E,$E,$t1 + ldr $t1,[$t3,#28] + add $F,$F,$t2 + ldr $inp,[sp,#17*4] @ pull inp + ldr $t2,[sp,#18*4] @ pull inp+len + add $G,$G,$t0 + add $H,$H,$t1 + stmia $t3,{$A,$B,$C,$D,$E,$F,$G,$H} + cmp $inp,$t2 + sub $Ktbl,$Ktbl,#256 @ rewind Ktbl + bne .Loop + + add sp,sp,#`16+3`*4 @ destroy frame +#if __ARM_ARCH>=5 + ldmia sp!,{r4-r11,pc} +#else + ldmia sp!,{r4-r11,lr} + tst lr,#1 + moveq pc,lr @ be binary compatible with V4, yet + bx lr @ interoperable with Thumb ISA:-) +#endif +.size sha256_block_data_order_nohw,.-sha256_block_data_order_nohw +___ +###################################################################### +# NEON stuff +# +{{{ +my @X=map("q$_",(0..3)); +my ($T0,$T1,$T2,$T3,$T4,$T5)=("q8","q9","q10","q11","d24","d25"); +my $Xfer=$t4; +my $j=0; + +sub Dlo() { shift=~m|q([1]?[0-9])|?"d".($1*2):""; } +sub Dhi() { shift=~m|q([1]?[0-9])|?"d".($1*2+1):""; } + +sub AUTOLOAD() # thunk [simplified] x86-style perlasm +{ my $opcode = $AUTOLOAD; $opcode =~ s/.*:://; $opcode =~ s/_/\./; + my $arg = pop; + $arg = "#$arg" if ($arg*1 eq $arg); + $code .= "\t$opcode\t".join(',',@_,$arg)."\n"; +} + +sub Xupdate() +{ use integer; + my $body = shift; + my @insns = (&$body,&$body,&$body,&$body); + my ($a,$b,$c,$d,$e,$f,$g,$h); + + &vext_8 ($T0,@X[0],@X[1],4); # X[1..4] + eval(shift(@insns)); + eval(shift(@insns)); + eval(shift(@insns)); + &vext_8 ($T1,@X[2],@X[3],4); # X[9..12] + eval(shift(@insns)); + eval(shift(@insns)); + eval(shift(@insns)); + &vshr_u32 ($T2,$T0,$sigma0[0]); + eval(shift(@insns)); + eval(shift(@insns)); + &vadd_i32 (@X[0],@X[0],$T1); # X[0..3] += X[9..12] + eval(shift(@insns)); + eval(shift(@insns)); + &vshr_u32 ($T1,$T0,$sigma0[2]); + eval(shift(@insns)); + eval(shift(@insns)); + &vsli_32 ($T2,$T0,32-$sigma0[0]); + eval(shift(@insns)); + eval(shift(@insns)); + &vshr_u32 ($T3,$T0,$sigma0[1]); + eval(shift(@insns)); + eval(shift(@insns)); + &veor ($T1,$T1,$T2); + eval(shift(@insns)); + eval(shift(@insns)); + &vsli_32 ($T3,$T0,32-$sigma0[1]); + eval(shift(@insns)); + eval(shift(@insns)); + &vshr_u32 ($T4,&Dhi(@X[3]),$sigma1[0]); + eval(shift(@insns)); + eval(shift(@insns)); + &veor ($T1,$T1,$T3); # sigma0(X[1..4]) + eval(shift(@insns)); + eval(shift(@insns)); + &vsli_32 ($T4,&Dhi(@X[3]),32-$sigma1[0]); + eval(shift(@insns)); + eval(shift(@insns)); + &vshr_u32 ($T5,&Dhi(@X[3]),$sigma1[2]); + eval(shift(@insns)); + eval(shift(@insns)); + &vadd_i32 (@X[0],@X[0],$T1); # X[0..3] += sigma0(X[1..4]) + eval(shift(@insns)); + eval(shift(@insns)); + &veor ($T5,$T5,$T4); + eval(shift(@insns)); + eval(shift(@insns)); + &vshr_u32 ($T4,&Dhi(@X[3]),$sigma1[1]); + eval(shift(@insns)); + eval(shift(@insns)); + &vsli_32 ($T4,&Dhi(@X[3]),32-$sigma1[1]); + eval(shift(@insns)); + eval(shift(@insns)); + &veor ($T5,$T5,$T4); # sigma1(X[14..15]) + eval(shift(@insns)); + eval(shift(@insns)); + &vadd_i32 (&Dlo(@X[0]),&Dlo(@X[0]),$T5);# X[0..1] += sigma1(X[14..15]) + eval(shift(@insns)); + eval(shift(@insns)); + &vshr_u32 ($T4,&Dlo(@X[0]),$sigma1[0]); + eval(shift(@insns)); + eval(shift(@insns)); + &vsli_32 ($T4,&Dlo(@X[0]),32-$sigma1[0]); + eval(shift(@insns)); + eval(shift(@insns)); + &vshr_u32 ($T5,&Dlo(@X[0]),$sigma1[2]); + eval(shift(@insns)); + eval(shift(@insns)); + &veor ($T5,$T5,$T4); + eval(shift(@insns)); + eval(shift(@insns)); + &vshr_u32 ($T4,&Dlo(@X[0]),$sigma1[1]); + eval(shift(@insns)); + eval(shift(@insns)); + &vld1_32 ("{$T0}","[$Ktbl,:128]!"); + eval(shift(@insns)); + eval(shift(@insns)); + &vsli_32 ($T4,&Dlo(@X[0]),32-$sigma1[1]); + eval(shift(@insns)); + eval(shift(@insns)); + &veor ($T5,$T5,$T4); # sigma1(X[16..17]) + eval(shift(@insns)); + eval(shift(@insns)); + &vadd_i32 (&Dhi(@X[0]),&Dhi(@X[0]),$T5);# X[2..3] += sigma1(X[16..17]) + eval(shift(@insns)); + eval(shift(@insns)); + &vadd_i32 ($T0,$T0,@X[0]); + while($#insns>=2) { eval(shift(@insns)); } + &vst1_32 ("{$T0}","[$Xfer,:128]!"); + eval(shift(@insns)); + eval(shift(@insns)); + + push(@X,shift(@X)); # "rotate" X[] +} + +sub Xpreload() +{ use integer; + my $body = shift; + my @insns = (&$body,&$body,&$body,&$body); + my ($a,$b,$c,$d,$e,$f,$g,$h); + + eval(shift(@insns)); + eval(shift(@insns)); + eval(shift(@insns)); + eval(shift(@insns)); + &vld1_32 ("{$T0}","[$Ktbl,:128]!"); + eval(shift(@insns)); + eval(shift(@insns)); + eval(shift(@insns)); + eval(shift(@insns)); + &vrev32_8 (@X[0],@X[0]); + eval(shift(@insns)); + eval(shift(@insns)); + eval(shift(@insns)); + eval(shift(@insns)); + &vadd_i32 ($T0,$T0,@X[0]); + foreach (@insns) { eval; } # remaining instructions + &vst1_32 ("{$T0}","[$Xfer,:128]!"); + + push(@X,shift(@X)); # "rotate" X[] +} + +sub body_00_15 () { + ( + '($a,$b,$c,$d,$e,$f,$g,$h)=@V;'. + '&add ($h,$h,$t1)', # h+=X[i]+K[i] + '&eor ($t1,$f,$g)', + '&eor ($t0,$e,$e,"ror#".($Sigma1[1]-$Sigma1[0]))', + '&add ($a,$a,$t2)', # h+=Maj(a,b,c) from the past + '&and ($t1,$t1,$e)', + '&eor ($t2,$t0,$e,"ror#".($Sigma1[2]-$Sigma1[0]))', # Sigma1(e) + '&eor ($t0,$a,$a,"ror#".($Sigma0[1]-$Sigma0[0]))', + '&eor ($t1,$t1,$g)', # Ch(e,f,g) + '&add ($h,$h,$t2,"ror#$Sigma1[0]")', # h+=Sigma1(e) + '&eor ($t2,$a,$b)', # a^b, b^c in next round + '&eor ($t0,$t0,$a,"ror#".($Sigma0[2]-$Sigma0[0]))', # Sigma0(a) + '&add ($h,$h,$t1)', # h+=Ch(e,f,g) + '&ldr ($t1,sprintf "[sp,#%d]",4*(($j+1)&15)) if (($j&15)!=15);'. + '&ldr ($t1,"[$Ktbl]") if ($j==15);'. + '&ldr ($t1,"[sp,#64]") if ($j==31)', + '&and ($t3,$t3,$t2)', # (b^c)&=(a^b) + '&add ($d,$d,$h)', # d+=h + '&add ($h,$h,$t0,"ror#$Sigma0[0]");'. # h+=Sigma0(a) + '&eor ($t3,$t3,$b)', # Maj(a,b,c) + '$j++; unshift(@V,pop(@V)); ($t2,$t3)=($t3,$t2);' + ) +} + +$code.=<<___; +#if __ARM_MAX_ARCH__>=7 +.arch armv7-a +.fpu neon + +.LK256_shortcut_neon: +@ PC is 8 bytes ahead in Arm mode and 4 bytes ahead in Thumb mode. +#if defined(__thumb2__) +.word K256-(.LK256_add_neon+4) +#else +.word K256-(.LK256_add_neon+8) +#endif + +.global sha256_block_data_order_neon +.type sha256_block_data_order_neon,%function +.align 5 +.skip 16 +sha256_block_data_order_neon: + stmdb sp!,{r4-r12,lr} + + sub $H,sp,#16*4+16 + + @ K256 is just at the boundary of being easily referenced by an ADR from + @ this function. In Arm mode, when building with __ARM_ARCH=6, it does + @ not fit. By moving code around, we could make it fit, but this is too + @ fragile. For simplicity, just load the offset from + @ .LK256_shortcut_neon. + @ + @ TODO(davidben): adrl would avoid a load, but clang-assembler does not + @ support it. We might be able to emulate it with a macro, but Android's + @ did not work when I tried it. + @ https://android.googlesource.com/platform/ndk/+/refs/heads/main/docs/ClangMigration.md#arm + ldr $Ktbl,.LK256_shortcut_neon +.LK256_add_neon: + add $Ktbl,pc,$Ktbl + + bic $H,$H,#15 @ align for 128-bit stores + mov $t2,sp + mov sp,$H @ alloca + add $len,$inp,$len,lsl#6 @ len to point at the end of inp + + vld1.8 {@X[0]},[$inp]! + vld1.8 {@X[1]},[$inp]! + vld1.8 {@X[2]},[$inp]! + vld1.8 {@X[3]},[$inp]! + vld1.32 {$T0},[$Ktbl,:128]! + vld1.32 {$T1},[$Ktbl,:128]! + vld1.32 {$T2},[$Ktbl,:128]! + vld1.32 {$T3},[$Ktbl,:128]! + vrev32.8 @X[0],@X[0] @ yes, even on + str $ctx,[sp,#64] + vrev32.8 @X[1],@X[1] @ big-endian + str $inp,[sp,#68] + mov $Xfer,sp + vrev32.8 @X[2],@X[2] + str $len,[sp,#72] + vrev32.8 @X[3],@X[3] + str $t2,[sp,#76] @ save original sp + vadd.i32 $T0,$T0,@X[0] + vadd.i32 $T1,$T1,@X[1] + vst1.32 {$T0},[$Xfer,:128]! + vadd.i32 $T2,$T2,@X[2] + vst1.32 {$T1},[$Xfer,:128]! + vadd.i32 $T3,$T3,@X[3] + vst1.32 {$T2},[$Xfer,:128]! + vst1.32 {$T3},[$Xfer,:128]! + + ldmia $ctx,{$A-$H} + sub $Xfer,$Xfer,#64 + ldr $t1,[sp,#0] + eor $t2,$t2,$t2 + eor $t3,$B,$C + b .L_00_48 + +.align 4 +.L_00_48: +___ + &Xupdate(\&body_00_15); + &Xupdate(\&body_00_15); + &Xupdate(\&body_00_15); + &Xupdate(\&body_00_15); +$code.=<<___; + teq $t1,#0 @ check for K256 terminator + ldr $t1,[sp,#0] + sub $Xfer,$Xfer,#64 + bne .L_00_48 + + ldr $inp,[sp,#68] + ldr $t0,[sp,#72] + sub $Ktbl,$Ktbl,#256 @ rewind $Ktbl + teq $inp,$t0 + it eq + subeq $inp,$inp,#64 @ avoid SEGV + vld1.8 {@X[0]},[$inp]! @ load next input block + vld1.8 {@X[1]},[$inp]! + vld1.8 {@X[2]},[$inp]! + vld1.8 {@X[3]},[$inp]! + it ne + strne $inp,[sp,#68] + mov $Xfer,sp +___ + &Xpreload(\&body_00_15); + &Xpreload(\&body_00_15); + &Xpreload(\&body_00_15); + &Xpreload(\&body_00_15); +$code.=<<___; + ldr $t0,[$t1,#0] + add $A,$A,$t2 @ h+=Maj(a,b,c) from the past + ldr $t2,[$t1,#4] + ldr $t3,[$t1,#8] + ldr $t4,[$t1,#12] + add $A,$A,$t0 @ accumulate + ldr $t0,[$t1,#16] + add $B,$B,$t2 + ldr $t2,[$t1,#20] + add $C,$C,$t3 + ldr $t3,[$t1,#24] + add $D,$D,$t4 + ldr $t4,[$t1,#28] + add $E,$E,$t0 + str $A,[$t1],#4 + add $F,$F,$t2 + str $B,[$t1],#4 + add $G,$G,$t3 + str $C,[$t1],#4 + add $H,$H,$t4 + str $D,[$t1],#4 + stmia $t1,{$E-$H} + + ittte ne + movne $Xfer,sp + ldrne $t1,[sp,#0] + eorne $t2,$t2,$t2 + ldreq sp,[sp,#76] @ restore original sp + itt ne + eorne $t3,$B,$C + bne .L_00_48 + + ldmia sp!,{r4-r12,pc} +.size sha256_block_data_order_neon,.-sha256_block_data_order_neon +#endif +___ +}}} + +$code.=<<___; +.asciz "SHA256 block transform for ARMv4/NEON/ARMv8, CRYPTOGAMS by " +.align 2 +___ + +open SELF,$0; +while() { + next if (/^#!/); + last if (!s/^#/@/ and !/^$/); + print; +} +close SELF; + +foreach (split($/,$code)) { + + s/\`([^\`]*)\`/eval $1/geo; + + s/\bret\b/bx lr/go or + s/\bbx\s+lr\b/.word\t0xe12fff1e/go; # make it possible to compile with -march=armv4 + + print $_,"\n"; +} + +close STDOUT or die "error closing STDOUT: $!"; # enforce flush diff --git a/http/vendor/ring/crypto/fipsmodule/sha/asm/sha512-armv4.pl b/http/vendor/ring/crypto/fipsmodule/sha/asm/sha512-armv4.pl new file mode 100644 index 0000000..b1fa016 --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/sha/asm/sha512-armv4.pl @@ -0,0 +1,649 @@ +#! /usr/bin/env perl +# Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# ==================================================================== +# Written by Andy Polyakov for the OpenSSL +# project. +# ==================================================================== + +# SHA512 block procedure for ARMv4. September 2007. + +# This code is ~4.5 (four and a half) times faster than code generated +# by gcc 3.4 and it spends ~72 clock cycles per byte [on single-issue +# Xscale PXA250 core]. +# +# July 2010. +# +# Rescheduling for dual-issue pipeline resulted in 6% improvement on +# Cortex A8 core and ~40 cycles per processed byte. + +# February 2011. +# +# Profiler-assisted and platform-specific optimization resulted in 7% +# improvement on Coxtex A8 core and ~38 cycles per byte. + +# March 2011. +# +# Add NEON implementation. On Cortex A8 it was measured to process +# one byte in 23.3 cycles or ~60% faster than integer-only code. + +# August 2012. +# +# Improve NEON performance by 12% on Snapdragon S4. In absolute +# terms it's 22.6 cycles per byte, which is disappointing result. +# Technical writers asserted that 3-way S4 pipeline can sustain +# multiple NEON instructions per cycle, but dual NEON issue could +# not be observed, see http://www.openssl.org/~appro/Snapdragon-S4.html +# for further details. On side note Cortex-A15 processes one byte in +# 16 cycles. + +# Byte order [in]dependence. ========================================= +# +# Originally caller was expected to maintain specific *dword* order in +# h[0-7], namely with most significant dword at *lower* address, which +# was reflected in below two parameters as 0 and 4. Now caller is +# expected to maintain native byte order for whole 64-bit values. +$hi="HI"; +$lo="LO"; +# ==================================================================== + +$flavour = shift; +if ($flavour=~/\w[\w\-]*\.\w+$/) { $output=$flavour; undef $flavour; } +else { while (($output=shift) && ($output!~/\w[\w\-]*\.\w+$/)) {} } + +if ($flavour && $flavour ne "void") { + $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; + ( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or + ( $xlate="${dir}../../../perlasm/arm-xlate.pl" and -f $xlate) or + die "can't locate arm-xlate.pl"; + + open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""; + *STDOUT=*OUT; +} else { + open OUT,">$output"; + *STDOUT=*OUT; +} + +$ctx="r0"; # parameter block +$inp="r1"; +$len="r2"; + +$Tlo="r3"; +$Thi="r4"; +$Alo="r5"; +$Ahi="r6"; +$Elo="r7"; +$Ehi="r8"; +$t0="r9"; +$t1="r10"; +$t2="r11"; +$t3="r12"; +############ r13 is stack pointer +$Ktbl="r14"; +############ r15 is program counter + +$Aoff=8*0; +$Boff=8*1; +$Coff=8*2; +$Doff=8*3; +$Eoff=8*4; +$Foff=8*5; +$Goff=8*6; +$Hoff=8*7; +$Xoff=8*8; + +sub BODY_00_15() { +my $magic = shift; +$code.=<<___; + @ Sigma1(x) (ROTR((x),14) ^ ROTR((x),18) ^ ROTR((x),41)) + @ LO lo>>14^hi<<18 ^ lo>>18^hi<<14 ^ hi>>9^lo<<23 + @ HI hi>>14^lo<<18 ^ hi>>18^lo<<14 ^ lo>>9^hi<<23 + mov $t0,$Elo,lsr#14 + str $Tlo,[sp,#$Xoff+0] + mov $t1,$Ehi,lsr#14 + str $Thi,[sp,#$Xoff+4] + eor $t0,$t0,$Ehi,lsl#18 + ldr $t2,[sp,#$Hoff+0] @ h.lo + eor $t1,$t1,$Elo,lsl#18 + ldr $t3,[sp,#$Hoff+4] @ h.hi + eor $t0,$t0,$Elo,lsr#18 + eor $t1,$t1,$Ehi,lsr#18 + eor $t0,$t0,$Ehi,lsl#14 + eor $t1,$t1,$Elo,lsl#14 + eor $t0,$t0,$Ehi,lsr#9 + eor $t1,$t1,$Elo,lsr#9 + eor $t0,$t0,$Elo,lsl#23 + eor $t1,$t1,$Ehi,lsl#23 @ Sigma1(e) + adds $Tlo,$Tlo,$t0 + ldr $t0,[sp,#$Foff+0] @ f.lo + adc $Thi,$Thi,$t1 @ T += Sigma1(e) + ldr $t1,[sp,#$Foff+4] @ f.hi + adds $Tlo,$Tlo,$t2 + ldr $t2,[sp,#$Goff+0] @ g.lo + adc $Thi,$Thi,$t3 @ T += h + ldr $t3,[sp,#$Goff+4] @ g.hi + + eor $t0,$t0,$t2 + str $Elo,[sp,#$Eoff+0] + eor $t1,$t1,$t3 + str $Ehi,[sp,#$Eoff+4] + and $t0,$t0,$Elo + str $Alo,[sp,#$Aoff+0] + and $t1,$t1,$Ehi + str $Ahi,[sp,#$Aoff+4] + eor $t0,$t0,$t2 + ldr $t2,[$Ktbl,#$lo] @ K[i].lo + eor $t1,$t1,$t3 @ Ch(e,f,g) + ldr $t3,[$Ktbl,#$hi] @ K[i].hi + + adds $Tlo,$Tlo,$t0 + ldr $Elo,[sp,#$Doff+0] @ d.lo + adc $Thi,$Thi,$t1 @ T += Ch(e,f,g) + ldr $Ehi,[sp,#$Doff+4] @ d.hi + adds $Tlo,$Tlo,$t2 + and $t0,$t2,#0xff + adc $Thi,$Thi,$t3 @ T += K[i] + adds $Elo,$Elo,$Tlo + ldr $t2,[sp,#$Boff+0] @ b.lo + adc $Ehi,$Ehi,$Thi @ d += T + teq $t0,#$magic + + ldr $t3,[sp,#$Coff+0] @ c.lo +#if __ARM_ARCH>=7 + it eq @ Thumb2 thing, sanity check in ARM +#endif + orreq $Ktbl,$Ktbl,#1 + @ Sigma0(x) (ROTR((x),28) ^ ROTR((x),34) ^ ROTR((x),39)) + @ LO lo>>28^hi<<4 ^ hi>>2^lo<<30 ^ hi>>7^lo<<25 + @ HI hi>>28^lo<<4 ^ lo>>2^hi<<30 ^ lo>>7^hi<<25 + mov $t0,$Alo,lsr#28 + mov $t1,$Ahi,lsr#28 + eor $t0,$t0,$Ahi,lsl#4 + eor $t1,$t1,$Alo,lsl#4 + eor $t0,$t0,$Ahi,lsr#2 + eor $t1,$t1,$Alo,lsr#2 + eor $t0,$t0,$Alo,lsl#30 + eor $t1,$t1,$Ahi,lsl#30 + eor $t0,$t0,$Ahi,lsr#7 + eor $t1,$t1,$Alo,lsr#7 + eor $t0,$t0,$Alo,lsl#25 + eor $t1,$t1,$Ahi,lsl#25 @ Sigma0(a) + adds $Tlo,$Tlo,$t0 + and $t0,$Alo,$t2 + adc $Thi,$Thi,$t1 @ T += Sigma0(a) + + ldr $t1,[sp,#$Boff+4] @ b.hi + orr $Alo,$Alo,$t2 + ldr $t2,[sp,#$Coff+4] @ c.hi + and $Alo,$Alo,$t3 + and $t3,$Ahi,$t1 + orr $Ahi,$Ahi,$t1 + orr $Alo,$Alo,$t0 @ Maj(a,b,c).lo + and $Ahi,$Ahi,$t2 + adds $Alo,$Alo,$Tlo + orr $Ahi,$Ahi,$t3 @ Maj(a,b,c).hi + sub sp,sp,#8 + adc $Ahi,$Ahi,$Thi @ h += T + tst $Ktbl,#1 + add $Ktbl,$Ktbl,#8 +___ +} +$code=<<___; +#ifndef __KERNEL__ +# define VFP_ABI_PUSH vstmdb sp!,{d8-d15} +# define VFP_ABI_POP vldmia sp!,{d8-d15} +#else +# define __ARM_MAX_ARCH__ 7 +# define VFP_ABI_PUSH +# define VFP_ABI_POP +#endif + +@ Silence ARMv8 deprecated IT instruction warnings. This file is used by both +@ ARMv7 and ARMv8 processors and does not use ARMv8 instructions. +.arch armv7-a + +#ifdef __ARMEL__ +# define LO 0 +# define HI 4 +# define WORD64(hi0,lo0,hi1,lo1) .word lo0,hi0, lo1,hi1 +#else +# define HI 0 +# define LO 4 +# define WORD64(hi0,lo0,hi1,lo1) .word hi0,lo0, hi1,lo1 +#endif + +.text +#if defined(__thumb2__) +.syntax unified +.thumb +# define adrl adr +#else +.code 32 +#endif + +.type K512,%object +.align 5 +K512: +WORD64(0x428a2f98,0xd728ae22, 0x71374491,0x23ef65cd) +WORD64(0xb5c0fbcf,0xec4d3b2f, 0xe9b5dba5,0x8189dbbc) +WORD64(0x3956c25b,0xf348b538, 0x59f111f1,0xb605d019) +WORD64(0x923f82a4,0xaf194f9b, 0xab1c5ed5,0xda6d8118) +WORD64(0xd807aa98,0xa3030242, 0x12835b01,0x45706fbe) +WORD64(0x243185be,0x4ee4b28c, 0x550c7dc3,0xd5ffb4e2) +WORD64(0x72be5d74,0xf27b896f, 0x80deb1fe,0x3b1696b1) +WORD64(0x9bdc06a7,0x25c71235, 0xc19bf174,0xcf692694) +WORD64(0xe49b69c1,0x9ef14ad2, 0xefbe4786,0x384f25e3) +WORD64(0x0fc19dc6,0x8b8cd5b5, 0x240ca1cc,0x77ac9c65) +WORD64(0x2de92c6f,0x592b0275, 0x4a7484aa,0x6ea6e483) +WORD64(0x5cb0a9dc,0xbd41fbd4, 0x76f988da,0x831153b5) +WORD64(0x983e5152,0xee66dfab, 0xa831c66d,0x2db43210) +WORD64(0xb00327c8,0x98fb213f, 0xbf597fc7,0xbeef0ee4) +WORD64(0xc6e00bf3,0x3da88fc2, 0xd5a79147,0x930aa725) +WORD64(0x06ca6351,0xe003826f, 0x14292967,0x0a0e6e70) +WORD64(0x27b70a85,0x46d22ffc, 0x2e1b2138,0x5c26c926) +WORD64(0x4d2c6dfc,0x5ac42aed, 0x53380d13,0x9d95b3df) +WORD64(0x650a7354,0x8baf63de, 0x766a0abb,0x3c77b2a8) +WORD64(0x81c2c92e,0x47edaee6, 0x92722c85,0x1482353b) +WORD64(0xa2bfe8a1,0x4cf10364, 0xa81a664b,0xbc423001) +WORD64(0xc24b8b70,0xd0f89791, 0xc76c51a3,0x0654be30) +WORD64(0xd192e819,0xd6ef5218, 0xd6990624,0x5565a910) +WORD64(0xf40e3585,0x5771202a, 0x106aa070,0x32bbd1b8) +WORD64(0x19a4c116,0xb8d2d0c8, 0x1e376c08,0x5141ab53) +WORD64(0x2748774c,0xdf8eeb99, 0x34b0bcb5,0xe19b48a8) +WORD64(0x391c0cb3,0xc5c95a63, 0x4ed8aa4a,0xe3418acb) +WORD64(0x5b9cca4f,0x7763e373, 0x682e6ff3,0xd6b2b8a3) +WORD64(0x748f82ee,0x5defb2fc, 0x78a5636f,0x43172f60) +WORD64(0x84c87814,0xa1f0ab72, 0x8cc70208,0x1a6439ec) +WORD64(0x90befffa,0x23631e28, 0xa4506ceb,0xde82bde9) +WORD64(0xbef9a3f7,0xb2c67915, 0xc67178f2,0xe372532b) +WORD64(0xca273ece,0xea26619c, 0xd186b8c7,0x21c0c207) +WORD64(0xeada7dd6,0xcde0eb1e, 0xf57d4f7f,0xee6ed178) +WORD64(0x06f067aa,0x72176fba, 0x0a637dc5,0xa2c898a6) +WORD64(0x113f9804,0xbef90dae, 0x1b710b35,0x131c471b) +WORD64(0x28db77f5,0x23047d84, 0x32caab7b,0x40c72493) +WORD64(0x3c9ebe0a,0x15c9bebc, 0x431d67c4,0x9c100d4c) +WORD64(0x4cc5d4be,0xcb3e42b6, 0x597f299c,0xfc657e2a) +WORD64(0x5fcb6fab,0x3ad6faec, 0x6c44198c,0x4a475817) +.size K512,.-K512 + +.global sha512_block_data_order_nohw +.type sha512_block_data_order_nohw,%function +sha512_block_data_order_nohw: + add $len,$inp,$len,lsl#7 @ len to point at the end of inp + stmdb sp!,{r4-r12,lr} + adr $Ktbl,K512 + sub sp,sp,#9*8 + + ldr $Elo,[$ctx,#$Eoff+$lo] + ldr $Ehi,[$ctx,#$Eoff+$hi] + ldr $t0, [$ctx,#$Goff+$lo] + ldr $t1, [$ctx,#$Goff+$hi] + ldr $t2, [$ctx,#$Hoff+$lo] + ldr $t3, [$ctx,#$Hoff+$hi] +.Loop: + str $t0, [sp,#$Goff+0] + str $t1, [sp,#$Goff+4] + str $t2, [sp,#$Hoff+0] + str $t3, [sp,#$Hoff+4] + ldr $Alo,[$ctx,#$Aoff+$lo] + ldr $Ahi,[$ctx,#$Aoff+$hi] + ldr $Tlo,[$ctx,#$Boff+$lo] + ldr $Thi,[$ctx,#$Boff+$hi] + ldr $t0, [$ctx,#$Coff+$lo] + ldr $t1, [$ctx,#$Coff+$hi] + ldr $t2, [$ctx,#$Doff+$lo] + ldr $t3, [$ctx,#$Doff+$hi] + str $Tlo,[sp,#$Boff+0] + str $Thi,[sp,#$Boff+4] + str $t0, [sp,#$Coff+0] + str $t1, [sp,#$Coff+4] + str $t2, [sp,#$Doff+0] + str $t3, [sp,#$Doff+4] + ldr $Tlo,[$ctx,#$Foff+$lo] + ldr $Thi,[$ctx,#$Foff+$hi] + str $Tlo,[sp,#$Foff+0] + str $Thi,[sp,#$Foff+4] + +.L00_15: +#if __ARM_ARCH<7 + ldrb $Tlo,[$inp,#7] + ldrb $t0, [$inp,#6] + ldrb $t1, [$inp,#5] + ldrb $t2, [$inp,#4] + ldrb $Thi,[$inp,#3] + ldrb $t3, [$inp,#2] + orr $Tlo,$Tlo,$t0,lsl#8 + ldrb $t0, [$inp,#1] + orr $Tlo,$Tlo,$t1,lsl#16 + ldrb $t1, [$inp],#8 + orr $Tlo,$Tlo,$t2,lsl#24 + orr $Thi,$Thi,$t3,lsl#8 + orr $Thi,$Thi,$t0,lsl#16 + orr $Thi,$Thi,$t1,lsl#24 +#else + ldr $Tlo,[$inp,#4] + ldr $Thi,[$inp],#8 +#ifdef __ARMEL__ + rev $Tlo,$Tlo + rev $Thi,$Thi +#endif +#endif +___ + &BODY_00_15(0x94); +$code.=<<___; + tst $Ktbl,#1 + beq .L00_15 + ldr $t0,[sp,#`$Xoff+8*(16-1)`+0] + ldr $t1,[sp,#`$Xoff+8*(16-1)`+4] + bic $Ktbl,$Ktbl,#1 +.L16_79: + @ sigma0(x) (ROTR((x),1) ^ ROTR((x),8) ^ ((x)>>7)) + @ LO lo>>1^hi<<31 ^ lo>>8^hi<<24 ^ lo>>7^hi<<25 + @ HI hi>>1^lo<<31 ^ hi>>8^lo<<24 ^ hi>>7 + mov $Tlo,$t0,lsr#1 + ldr $t2,[sp,#`$Xoff+8*(16-14)`+0] + mov $Thi,$t1,lsr#1 + ldr $t3,[sp,#`$Xoff+8*(16-14)`+4] + eor $Tlo,$Tlo,$t1,lsl#31 + eor $Thi,$Thi,$t0,lsl#31 + eor $Tlo,$Tlo,$t0,lsr#8 + eor $Thi,$Thi,$t1,lsr#8 + eor $Tlo,$Tlo,$t1,lsl#24 + eor $Thi,$Thi,$t0,lsl#24 + eor $Tlo,$Tlo,$t0,lsr#7 + eor $Thi,$Thi,$t1,lsr#7 + eor $Tlo,$Tlo,$t1,lsl#25 + + @ sigma1(x) (ROTR((x),19) ^ ROTR((x),61) ^ ((x)>>6)) + @ LO lo>>19^hi<<13 ^ hi>>29^lo<<3 ^ lo>>6^hi<<26 + @ HI hi>>19^lo<<13 ^ lo>>29^hi<<3 ^ hi>>6 + mov $t0,$t2,lsr#19 + mov $t1,$t3,lsr#19 + eor $t0,$t0,$t3,lsl#13 + eor $t1,$t1,$t2,lsl#13 + eor $t0,$t0,$t3,lsr#29 + eor $t1,$t1,$t2,lsr#29 + eor $t0,$t0,$t2,lsl#3 + eor $t1,$t1,$t3,lsl#3 + eor $t0,$t0,$t2,lsr#6 + eor $t1,$t1,$t3,lsr#6 + ldr $t2,[sp,#`$Xoff+8*(16-9)`+0] + eor $t0,$t0,$t3,lsl#26 + + ldr $t3,[sp,#`$Xoff+8*(16-9)`+4] + adds $Tlo,$Tlo,$t0 + ldr $t0,[sp,#`$Xoff+8*16`+0] + adc $Thi,$Thi,$t1 + + ldr $t1,[sp,#`$Xoff+8*16`+4] + adds $Tlo,$Tlo,$t2 + adc $Thi,$Thi,$t3 + adds $Tlo,$Tlo,$t0 + adc $Thi,$Thi,$t1 +___ + &BODY_00_15(0x17); +$code.=<<___; +#if __ARM_ARCH>=7 + ittt eq @ Thumb2 thing, sanity check in ARM +#endif + ldreq $t0,[sp,#`$Xoff+8*(16-1)`+0] + ldreq $t1,[sp,#`$Xoff+8*(16-1)`+4] + beq .L16_79 + bic $Ktbl,$Ktbl,#1 + + ldr $Tlo,[sp,#$Boff+0] + ldr $Thi,[sp,#$Boff+4] + ldr $t0, [$ctx,#$Aoff+$lo] + ldr $t1, [$ctx,#$Aoff+$hi] + ldr $t2, [$ctx,#$Boff+$lo] + ldr $t3, [$ctx,#$Boff+$hi] + adds $t0,$Alo,$t0 + str $t0, [$ctx,#$Aoff+$lo] + adc $t1,$Ahi,$t1 + str $t1, [$ctx,#$Aoff+$hi] + adds $t2,$Tlo,$t2 + str $t2, [$ctx,#$Boff+$lo] + adc $t3,$Thi,$t3 + str $t3, [$ctx,#$Boff+$hi] + + ldr $Alo,[sp,#$Coff+0] + ldr $Ahi,[sp,#$Coff+4] + ldr $Tlo,[sp,#$Doff+0] + ldr $Thi,[sp,#$Doff+4] + ldr $t0, [$ctx,#$Coff+$lo] + ldr $t1, [$ctx,#$Coff+$hi] + ldr $t2, [$ctx,#$Doff+$lo] + ldr $t3, [$ctx,#$Doff+$hi] + adds $t0,$Alo,$t0 + str $t0, [$ctx,#$Coff+$lo] + adc $t1,$Ahi,$t1 + str $t1, [$ctx,#$Coff+$hi] + adds $t2,$Tlo,$t2 + str $t2, [$ctx,#$Doff+$lo] + adc $t3,$Thi,$t3 + str $t3, [$ctx,#$Doff+$hi] + + ldr $Tlo,[sp,#$Foff+0] + ldr $Thi,[sp,#$Foff+4] + ldr $t0, [$ctx,#$Eoff+$lo] + ldr $t1, [$ctx,#$Eoff+$hi] + ldr $t2, [$ctx,#$Foff+$lo] + ldr $t3, [$ctx,#$Foff+$hi] + adds $Elo,$Elo,$t0 + str $Elo,[$ctx,#$Eoff+$lo] + adc $Ehi,$Ehi,$t1 + str $Ehi,[$ctx,#$Eoff+$hi] + adds $t2,$Tlo,$t2 + str $t2, [$ctx,#$Foff+$lo] + adc $t3,$Thi,$t3 + str $t3, [$ctx,#$Foff+$hi] + + ldr $Alo,[sp,#$Goff+0] + ldr $Ahi,[sp,#$Goff+4] + ldr $Tlo,[sp,#$Hoff+0] + ldr $Thi,[sp,#$Hoff+4] + ldr $t0, [$ctx,#$Goff+$lo] + ldr $t1, [$ctx,#$Goff+$hi] + ldr $t2, [$ctx,#$Hoff+$lo] + ldr $t3, [$ctx,#$Hoff+$hi] + adds $t0,$Alo,$t0 + str $t0, [$ctx,#$Goff+$lo] + adc $t1,$Ahi,$t1 + str $t1, [$ctx,#$Goff+$hi] + adds $t2,$Tlo,$t2 + str $t2, [$ctx,#$Hoff+$lo] + adc $t3,$Thi,$t3 + str $t3, [$ctx,#$Hoff+$hi] + + add sp,sp,#640 + sub $Ktbl,$Ktbl,#640 + + teq $inp,$len + bne .Loop + + add sp,sp,#8*9 @ destroy frame +#if __ARM_ARCH>=5 + ldmia sp!,{r4-r12,pc} +#else + ldmia sp!,{r4-r12,lr} + tst lr,#1 + moveq pc,lr @ be binary compatible with V4, yet + bx lr @ interoperable with Thumb ISA:-) +#endif +.size sha512_block_data_order_nohw,.-sha512_block_data_order_nohw +___ + +{ +my @Sigma0=(28,34,39); +my @Sigma1=(14,18,41); +my @sigma0=(1, 8, 7); +my @sigma1=(19,61,6); + +my $Ktbl="r3"; +my $cnt="r12"; # volatile register known as ip, intra-procedure-call scratch + +my @X=map("d$_",(0..15)); +my @V=($A,$B,$C,$D,$E,$F,$G,$H)=map("d$_",(16..23)); + +sub NEON_00_15() { +my $i=shift; +my ($a,$b,$c,$d,$e,$f,$g,$h)=@_; +my ($t0,$t1,$t2,$T1,$K,$Ch,$Maj)=map("d$_",(24..31)); # temps + +$code.=<<___ if ($i<16 || $i&1); + vshr.u64 $t0,$e,#@Sigma1[0] @ $i +#if $i<16 + vld1.64 {@X[$i%16]},[$inp]! @ handles unaligned +#endif + vshr.u64 $t1,$e,#@Sigma1[1] +#if $i>0 + vadd.i64 $a,$Maj @ h+=Maj from the past +#endif + vshr.u64 $t2,$e,#@Sigma1[2] +___ +$code.=<<___; + vld1.64 {$K},[$Ktbl,:64]! @ K[i++] + vsli.64 $t0,$e,#`64-@Sigma1[0]` + vsli.64 $t1,$e,#`64-@Sigma1[1]` + vmov $Ch,$e + vsli.64 $t2,$e,#`64-@Sigma1[2]` +#if $i<16 && defined(__ARMEL__) + vrev64.8 @X[$i],@X[$i] +#endif + veor $t1,$t0 + vbsl $Ch,$f,$g @ Ch(e,f,g) + vshr.u64 $t0,$a,#@Sigma0[0] + veor $t2,$t1 @ Sigma1(e) + vadd.i64 $T1,$Ch,$h + vshr.u64 $t1,$a,#@Sigma0[1] + vsli.64 $t0,$a,#`64-@Sigma0[0]` + vadd.i64 $T1,$t2 + vshr.u64 $t2,$a,#@Sigma0[2] + vadd.i64 $K,@X[$i%16] + vsli.64 $t1,$a,#`64-@Sigma0[1]` + veor $Maj,$a,$b + vsli.64 $t2,$a,#`64-@Sigma0[2]` + veor $h,$t0,$t1 + vadd.i64 $T1,$K + vbsl $Maj,$c,$b @ Maj(a,b,c) + veor $h,$t2 @ Sigma0(a) + vadd.i64 $d,$T1 + vadd.i64 $Maj,$T1 + @ vadd.i64 $h,$Maj +___ +} + +sub NEON_16_79() { +my $i=shift; + +if ($i&1) { &NEON_00_15($i,@_); return; } + +# 2x-vectorized, therefore runs every 2nd round +my @X=map("q$_",(0..7)); # view @X as 128-bit vector +my ($t0,$t1,$s0,$s1) = map("q$_",(12..15)); # temps +my ($d0,$d1,$d2) = map("d$_",(24..26)); # temps from NEON_00_15 +my $e=@_[4]; # $e from NEON_00_15 +$i /= 2; +$code.=<<___; + vshr.u64 $t0,@X[($i+7)%8],#@sigma1[0] + vshr.u64 $t1,@X[($i+7)%8],#@sigma1[1] + vadd.i64 @_[0],d30 @ h+=Maj from the past + vshr.u64 $s1,@X[($i+7)%8],#@sigma1[2] + vsli.64 $t0,@X[($i+7)%8],#`64-@sigma1[0]` + vext.8 $s0,@X[$i%8],@X[($i+1)%8],#8 @ X[i+1] + vsli.64 $t1,@X[($i+7)%8],#`64-@sigma1[1]` + veor $s1,$t0 + vshr.u64 $t0,$s0,#@sigma0[0] + veor $s1,$t1 @ sigma1(X[i+14]) + vshr.u64 $t1,$s0,#@sigma0[1] + vadd.i64 @X[$i%8],$s1 + vshr.u64 $s1,$s0,#@sigma0[2] + vsli.64 $t0,$s0,#`64-@sigma0[0]` + vsli.64 $t1,$s0,#`64-@sigma0[1]` + vext.8 $s0,@X[($i+4)%8],@X[($i+5)%8],#8 @ X[i+9] + veor $s1,$t0 + vshr.u64 $d0,$e,#@Sigma1[0] @ from NEON_00_15 + vadd.i64 @X[$i%8],$s0 + vshr.u64 $d1,$e,#@Sigma1[1] @ from NEON_00_15 + veor $s1,$t1 @ sigma0(X[i+1]) + vshr.u64 $d2,$e,#@Sigma1[2] @ from NEON_00_15 + vadd.i64 @X[$i%8],$s1 +___ + &NEON_00_15(2*$i,@_); +} + +$code.=<<___; +#if __ARM_MAX_ARCH__>=7 +.arch armv7-a +.fpu neon + +.global sha512_block_data_order_neon +.type sha512_block_data_order_neon,%function +.align 4 +sha512_block_data_order_neon: + dmb @ errata #451034 on early Cortex A8 + add $len,$inp,$len,lsl#7 @ len to point at the end of inp + adr $Ktbl,K512 + VFP_ABI_PUSH + vldmia $ctx,{$A-$H} @ load context +.Loop_neon: +___ +for($i=0;$i<16;$i++) { &NEON_00_15($i,@V); unshift(@V,pop(@V)); } +$code.=<<___; + mov $cnt,#4 +.L16_79_neon: + subs $cnt,#1 +___ +for(;$i<32;$i++) { &NEON_16_79($i,@V); unshift(@V,pop(@V)); } +$code.=<<___; + bne .L16_79_neon + + vadd.i64 $A,d30 @ h+=Maj from the past + vldmia $ctx,{d24-d31} @ load context to temp + vadd.i64 q8,q12 @ vectorized accumulate + vadd.i64 q9,q13 + vadd.i64 q10,q14 + vadd.i64 q11,q15 + vstmia $ctx,{$A-$H} @ save context + teq $inp,$len + sub $Ktbl,#640 @ rewind K512 + bne .Loop_neon + + VFP_ABI_POP + ret @ bx lr +.size sha512_block_data_order_neon,.-sha512_block_data_order_neon +#endif +___ +} +$code.=<<___; +.asciz "SHA512 block transform for ARMv4/NEON, CRYPTOGAMS by " +.align 2 +___ + +$code =~ s/\`([^\`]*)\`/eval $1/gem; +$code =~ s/\bbx\s+lr\b/.word\t0xe12fff1e/gm; # make it possible to compile with -march=armv4 +$code =~ s/\bret\b/bx lr/gm; + +open SELF,$0; +while() { + next if (/^#!/); + last if (!s/^#/@/ and !/^$/); + print; +} +close SELF; + +print $code; +close STDOUT or die "error closing STDOUT: $!"; # enforce flush diff --git a/http/vendor/ring/crypto/fipsmodule/sha/asm/sha512-armv8.pl b/http/vendor/ring/crypto/fipsmodule/sha/asm/sha512-armv8.pl new file mode 100644 index 0000000..a3ed706 --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/sha/asm/sha512-armv8.pl @@ -0,0 +1,575 @@ +#! /usr/bin/env perl +# Copyright 2014-2020 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# ==================================================================== +# Written by Andy Polyakov for the OpenSSL +# project. +# ==================================================================== +# +# SHA256/512 for ARMv8. +# +# Performance in cycles per processed byte and improvement coefficient +# over code generated with "default" compiler: +# +# SHA256-hw SHA256(*) SHA512 +# Apple A7 1.97 10.5 (+33%) 6.73 (-1%(**)) +# Cortex-A53 2.38 15.5 (+115%) 10.0 (+150%(***)) +# Cortex-A57 2.31 11.6 (+86%) 7.51 (+260%(***)) +# Denver 2.01 10.5 (+26%) 6.70 (+8%) +# X-Gene 20.0 (+100%) 12.8 (+300%(***)) +# Mongoose 2.36 13.0 (+50%) 8.36 (+33%) +# Kryo 1.92 17.4 (+30%) 11.2 (+8%) +# +# (*) Software SHA256 results are of lesser relevance, presented +# mostly for informational purposes. +# (**) The result is a trade-off: it's possible to improve it by +# 10% (or by 1 cycle per round), but at the cost of 20% loss +# on Cortex-A53 (or by 4 cycles per round). +# (***) Super-impressive coefficients over gcc-generated code are +# indication of some compiler "pathology", most notably code +# generated with -mgeneral-regs-only is significantly faster +# and the gap is only 40-90%. + +my ($flavour, $output) = @ARGV; + +if ($output =~ /sha512-armv8/) { + $BITS=512; + $SZ=8; + @Sigma0=(28,34,39); + @Sigma1=(14,18,41); + @sigma0=(1, 8, 7); + @sigma1=(19,61, 6); + $rounds=80; + $reg_t="x"; +} else { + $BITS=256; + $SZ=4; + @Sigma0=( 2,13,22); + @Sigma1=( 6,11,25); + @sigma0=( 7,18, 3); + @sigma1=(17,19,10); + $rounds=64; + $reg_t="w"; +} + +if ($flavour && $flavour ne "void") { + $0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; + ( $xlate="${dir}arm-xlate.pl" and -f $xlate ) or + ( $xlate="${dir}../../../perlasm/arm-xlate.pl" and -f $xlate) or + die "can't locate arm-xlate.pl"; + + open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""; + *STDOUT=*OUT; +} else { + open OUT,">$output"; + *STDOUT=*OUT; +} + +$func="sha${BITS}_block_data_order_nohw"; + +($ctx,$inp,$num,$Ktbl)=map("x$_",(0..2,30)); + +@X=map("$reg_t$_",(3..15,0..2)); +@V=($A,$B,$C,$D,$E,$F,$G,$H)=map("$reg_t$_",(20..27)); +($t0,$t1,$t2,$t3)=map("$reg_t$_",(16,17,19,28)); + +sub BODY_00_xx { +my ($i,$a,$b,$c,$d,$e,$f,$g,$h)=@_; +my $j=($i+1)&15; +my ($T0,$T1,$T2)=(@X[($i-8)&15],@X[($i-9)&15],@X[($i-10)&15]); + $T0=@X[$i+3] if ($i<11); + +$code.=<<___ if ($i<16); +#ifndef __AARCH64EB__ + rev @X[$i],@X[$i] // $i +#endif +___ +$code.=<<___ if ($i<13 && ($i&1)); + ldp @X[$i+1],@X[$i+2],[$inp],#2*$SZ +___ +$code.=<<___ if ($i==13); + ldp @X[14],@X[15],[$inp] +___ +$code.=<<___ if ($i>=14); + ldr @X[($i-11)&15],[sp,#`$SZ*(($i-11)%4)`] +___ +$code.=<<___ if ($i>0 && $i<16); + add $a,$a,$t1 // h+=Sigma0(a) +___ +$code.=<<___ if ($i>=11); + str @X[($i-8)&15],[sp,#`$SZ*(($i-8)%4)`] +___ +# While ARMv8 specifies merged rotate-n-logical operation such as +# 'eor x,y,z,ror#n', it was found to negatively affect performance +# on Apple A7. The reason seems to be that it requires even 'y' to +# be available earlier. This means that such merged instruction is +# not necessarily best choice on critical path... On the other hand +# Cortex-A5x handles merged instructions much better than disjoint +# rotate and logical... See (**) footnote above. +$code.=<<___ if ($i<15); + ror $t0,$e,#$Sigma1[0] + add $h,$h,$t2 // h+=K[i] + eor $T0,$e,$e,ror#`$Sigma1[2]-$Sigma1[1]` + and $t1,$f,$e + bic $t2,$g,$e + add $h,$h,@X[$i&15] // h+=X[i] + orr $t1,$t1,$t2 // Ch(e,f,g) + eor $t2,$a,$b // a^b, b^c in next round + eor $t0,$t0,$T0,ror#$Sigma1[1] // Sigma1(e) + ror $T0,$a,#$Sigma0[0] + add $h,$h,$t1 // h+=Ch(e,f,g) + eor $t1,$a,$a,ror#`$Sigma0[2]-$Sigma0[1]` + add $h,$h,$t0 // h+=Sigma1(e) + and $t3,$t3,$t2 // (b^c)&=(a^b) + add $d,$d,$h // d+=h + eor $t3,$t3,$b // Maj(a,b,c) + eor $t1,$T0,$t1,ror#$Sigma0[1] // Sigma0(a) + add $h,$h,$t3 // h+=Maj(a,b,c) + ldr $t3,[$Ktbl],#$SZ // *K++, $t2 in next round + //add $h,$h,$t1 // h+=Sigma0(a) +___ +$code.=<<___ if ($i>=15); + ror $t0,$e,#$Sigma1[0] + add $h,$h,$t2 // h+=K[i] + ror $T1,@X[($j+1)&15],#$sigma0[0] + and $t1,$f,$e + ror $T2,@X[($j+14)&15],#$sigma1[0] + bic $t2,$g,$e + ror $T0,$a,#$Sigma0[0] + add $h,$h,@X[$i&15] // h+=X[i] + eor $t0,$t0,$e,ror#$Sigma1[1] + eor $T1,$T1,@X[($j+1)&15],ror#$sigma0[1] + orr $t1,$t1,$t2 // Ch(e,f,g) + eor $t2,$a,$b // a^b, b^c in next round + eor $t0,$t0,$e,ror#$Sigma1[2] // Sigma1(e) + eor $T0,$T0,$a,ror#$Sigma0[1] + add $h,$h,$t1 // h+=Ch(e,f,g) + and $t3,$t3,$t2 // (b^c)&=(a^b) + eor $T2,$T2,@X[($j+14)&15],ror#$sigma1[1] + eor $T1,$T1,@X[($j+1)&15],lsr#$sigma0[2] // sigma0(X[i+1]) + add $h,$h,$t0 // h+=Sigma1(e) + eor $t3,$t3,$b // Maj(a,b,c) + eor $t1,$T0,$a,ror#$Sigma0[2] // Sigma0(a) + eor $T2,$T2,@X[($j+14)&15],lsr#$sigma1[2] // sigma1(X[i+14]) + add @X[$j],@X[$j],@X[($j+9)&15] + add $d,$d,$h // d+=h + add $h,$h,$t3 // h+=Maj(a,b,c) + ldr $t3,[$Ktbl],#$SZ // *K++, $t2 in next round + add @X[$j],@X[$j],$T1 + add $h,$h,$t1 // h+=Sigma0(a) + add @X[$j],@X[$j],$T2 +___ + ($t2,$t3)=($t3,$t2); +} + +$code.=<<___; +#ifndef __KERNEL__ +#endif + +.text + +.globl $func +.type $func,%function +.align 6 +$func: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-128]! + add x29,sp,#0 + + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + stp x27,x28,[sp,#80] + sub sp,sp,#4*$SZ + + ldp $A,$B,[$ctx] // load context + ldp $C,$D,[$ctx,#2*$SZ] + ldp $E,$F,[$ctx,#4*$SZ] + add $num,$inp,$num,lsl#`log(16*$SZ)/log(2)` // end of input + ldp $G,$H,[$ctx,#6*$SZ] + adrp $Ktbl,:pg_hi21:.LK$BITS + add $Ktbl,$Ktbl,:lo12:.LK$BITS + stp $ctx,$num,[x29,#96] + +.Loop: + ldp @X[0],@X[1],[$inp],#2*$SZ + ldr $t2,[$Ktbl],#$SZ // *K++ + eor $t3,$B,$C // magic seed + str $inp,[x29,#112] +___ +for ($i=0;$i<16;$i++) { &BODY_00_xx($i,@V); unshift(@V,pop(@V)); } +$code.=".Loop_16_xx:\n"; +for (;$i<32;$i++) { &BODY_00_xx($i,@V); unshift(@V,pop(@V)); } +$code.=<<___; + cbnz $t2,.Loop_16_xx + + ldp $ctx,$num,[x29,#96] + ldr $inp,[x29,#112] + sub $Ktbl,$Ktbl,#`$SZ*($rounds+1)` // rewind + + ldp @X[0],@X[1],[$ctx] + ldp @X[2],@X[3],[$ctx,#2*$SZ] + add $inp,$inp,#14*$SZ // advance input pointer + ldp @X[4],@X[5],[$ctx,#4*$SZ] + add $A,$A,@X[0] + ldp @X[6],@X[7],[$ctx,#6*$SZ] + add $B,$B,@X[1] + add $C,$C,@X[2] + add $D,$D,@X[3] + stp $A,$B,[$ctx] + add $E,$E,@X[4] + add $F,$F,@X[5] + stp $C,$D,[$ctx,#2*$SZ] + add $G,$G,@X[6] + add $H,$H,@X[7] + cmp $inp,$num + stp $E,$F,[$ctx,#4*$SZ] + stp $G,$H,[$ctx,#6*$SZ] + b.ne .Loop + + ldp x19,x20,[x29,#16] + add sp,sp,#4*$SZ + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldp x29,x30,[sp],#128 + AARCH64_VALIDATE_LINK_REGISTER + ret +.size $func,.-$func + +.section .rodata +.align 6 +.type .LK$BITS,%object +.LK$BITS: +___ +$code.=<<___ if ($SZ==8); + .quad 0x428a2f98d728ae22,0x7137449123ef65cd + .quad 0xb5c0fbcfec4d3b2f,0xe9b5dba58189dbbc + .quad 0x3956c25bf348b538,0x59f111f1b605d019 + .quad 0x923f82a4af194f9b,0xab1c5ed5da6d8118 + .quad 0xd807aa98a3030242,0x12835b0145706fbe + .quad 0x243185be4ee4b28c,0x550c7dc3d5ffb4e2 + .quad 0x72be5d74f27b896f,0x80deb1fe3b1696b1 + .quad 0x9bdc06a725c71235,0xc19bf174cf692694 + .quad 0xe49b69c19ef14ad2,0xefbe4786384f25e3 + .quad 0x0fc19dc68b8cd5b5,0x240ca1cc77ac9c65 + .quad 0x2de92c6f592b0275,0x4a7484aa6ea6e483 + .quad 0x5cb0a9dcbd41fbd4,0x76f988da831153b5 + .quad 0x983e5152ee66dfab,0xa831c66d2db43210 + .quad 0xb00327c898fb213f,0xbf597fc7beef0ee4 + .quad 0xc6e00bf33da88fc2,0xd5a79147930aa725 + .quad 0x06ca6351e003826f,0x142929670a0e6e70 + .quad 0x27b70a8546d22ffc,0x2e1b21385c26c926 + .quad 0x4d2c6dfc5ac42aed,0x53380d139d95b3df + .quad 0x650a73548baf63de,0x766a0abb3c77b2a8 + .quad 0x81c2c92e47edaee6,0x92722c851482353b + .quad 0xa2bfe8a14cf10364,0xa81a664bbc423001 + .quad 0xc24b8b70d0f89791,0xc76c51a30654be30 + .quad 0xd192e819d6ef5218,0xd69906245565a910 + .quad 0xf40e35855771202a,0x106aa07032bbd1b8 + .quad 0x19a4c116b8d2d0c8,0x1e376c085141ab53 + .quad 0x2748774cdf8eeb99,0x34b0bcb5e19b48a8 + .quad 0x391c0cb3c5c95a63,0x4ed8aa4ae3418acb + .quad 0x5b9cca4f7763e373,0x682e6ff3d6b2b8a3 + .quad 0x748f82ee5defb2fc,0x78a5636f43172f60 + .quad 0x84c87814a1f0ab72,0x8cc702081a6439ec + .quad 0x90befffa23631e28,0xa4506cebde82bde9 + .quad 0xbef9a3f7b2c67915,0xc67178f2e372532b + .quad 0xca273eceea26619c,0xd186b8c721c0c207 + .quad 0xeada7dd6cde0eb1e,0xf57d4f7fee6ed178 + .quad 0x06f067aa72176fba,0x0a637dc5a2c898a6 + .quad 0x113f9804bef90dae,0x1b710b35131c471b + .quad 0x28db77f523047d84,0x32caab7b40c72493 + .quad 0x3c9ebe0a15c9bebc,0x431d67c49c100d4c + .quad 0x4cc5d4becb3e42b6,0x597f299cfc657e2a + .quad 0x5fcb6fab3ad6faec,0x6c44198c4a475817 + .quad 0 // terminator +___ +$code.=<<___ if ($SZ==4); + .long 0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5 + .long 0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5 + .long 0xd807aa98,0x12835b01,0x243185be,0x550c7dc3 + .long 0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174 + .long 0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc + .long 0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da + .long 0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7 + .long 0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967 + .long 0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13 + .long 0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85 + .long 0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3 + .long 0xd192e819,0xd6990624,0xf40e3585,0x106aa070 + .long 0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5 + .long 0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3 + .long 0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208 + .long 0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2 + .long 0 //terminator +___ +$code.=<<___; +.size .LK$BITS,.-.LK$BITS +.asciz "SHA$BITS block transform for ARMv8, CRYPTOGAMS by " +.align 2 +___ + +if ($SZ==4) { +my $Ktbl="x3"; + +my ($ABCD,$EFGH,$abcd)=map("v$_.16b",(0..2)); +my @MSG=map("v$_.16b",(4..7)); +my ($W0,$W1)=("v16.4s","v17.4s"); +my ($ABCD_SAVE,$EFGH_SAVE)=("v18.16b","v19.16b"); + +$code.=<<___; +.text +#ifndef __KERNEL__ +.globl sha256_block_data_order_hw +.type sha256_block_data_order_hw,%function +.align 6 +sha256_block_data_order_hw: + // Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later. + AARCH64_VALID_CALL_TARGET + stp x29,x30,[sp,#-16]! + add x29,sp,#0 + + ld1.32 {$ABCD,$EFGH},[$ctx] + adrp $Ktbl,:pg_hi21:.LK256 + add $Ktbl,$Ktbl,:lo12:.LK256 + +.Loop_hw: + ld1 {@MSG[0]-@MSG[3]},[$inp],#64 + sub $num,$num,#1 + ld1.32 {$W0},[$Ktbl],#16 + rev32 @MSG[0],@MSG[0] + rev32 @MSG[1],@MSG[1] + rev32 @MSG[2],@MSG[2] + rev32 @MSG[3],@MSG[3] + orr $ABCD_SAVE,$ABCD,$ABCD // offload + orr $EFGH_SAVE,$EFGH,$EFGH +___ +for($i=0;$i<12;$i++) { +$code.=<<___; + ld1.32 {$W1},[$Ktbl],#16 + add.i32 $W0,$W0,@MSG[0] + sha256su0 @MSG[0],@MSG[1] + orr $abcd,$ABCD,$ABCD + sha256h $ABCD,$EFGH,$W0 + sha256h2 $EFGH,$abcd,$W0 + sha256su1 @MSG[0],@MSG[2],@MSG[3] +___ + ($W0,$W1)=($W1,$W0); push(@MSG,shift(@MSG)); +} +$code.=<<___; + ld1.32 {$W1},[$Ktbl],#16 + add.i32 $W0,$W0,@MSG[0] + orr $abcd,$ABCD,$ABCD + sha256h $ABCD,$EFGH,$W0 + sha256h2 $EFGH,$abcd,$W0 + + ld1.32 {$W0},[$Ktbl],#16 + add.i32 $W1,$W1,@MSG[1] + orr $abcd,$ABCD,$ABCD + sha256h $ABCD,$EFGH,$W1 + sha256h2 $EFGH,$abcd,$W1 + + ld1.32 {$W1},[$Ktbl] + add.i32 $W0,$W0,@MSG[2] + sub $Ktbl,$Ktbl,#$rounds*$SZ-16 // rewind + orr $abcd,$ABCD,$ABCD + sha256h $ABCD,$EFGH,$W0 + sha256h2 $EFGH,$abcd,$W0 + + add.i32 $W1,$W1,@MSG[3] + orr $abcd,$ABCD,$ABCD + sha256h $ABCD,$EFGH,$W1 + sha256h2 $EFGH,$abcd,$W1 + + add.i32 $ABCD,$ABCD,$ABCD_SAVE + add.i32 $EFGH,$EFGH,$EFGH_SAVE + + cbnz $num,.Loop_hw + + st1.32 {$ABCD,$EFGH},[$ctx] + + ldr x29,[sp],#16 + ret +.size sha256_block_data_order_hw,.-sha256_block_data_order_hw +#endif +___ +} + +if ($SZ==8) { +my $Ktbl="x3"; + +my @H = map("v$_.16b",(0..4)); +my ($fg,$de,$m9_10)=map("v$_.16b",(5..7)); +my @MSG=map("v$_.16b",(16..23)); +my ($W0,$W1)=("v24.2d","v25.2d"); +my ($AB,$CD,$EF,$GH)=map("v$_.16b",(26..29)); + +$code.=<<___; +.text +#ifndef __KERNEL__ +.globl sha512_block_data_order_hw +.type sha512_block_data_order_hw,%function +.align 6 +sha512_block_data_order_hw: + // Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later. + AARCH64_VALID_CALL_TARGET + stp x29,x30,[sp,#-16]! + add x29,sp,#0 + + ld1 {@MSG[0]-@MSG[3]},[$inp],#64 // load input + ld1 {@MSG[4]-@MSG[7]},[$inp],#64 + + ld1.64 {@H[0]-@H[3]},[$ctx] // load context + adrp $Ktbl,:pg_hi21:.LK512 + add $Ktbl,$Ktbl,:lo12:.LK512 + + rev64 @MSG[0],@MSG[0] + rev64 @MSG[1],@MSG[1] + rev64 @MSG[2],@MSG[2] + rev64 @MSG[3],@MSG[3] + rev64 @MSG[4],@MSG[4] + rev64 @MSG[5],@MSG[5] + rev64 @MSG[6],@MSG[6] + rev64 @MSG[7],@MSG[7] + b .Loop_hw + +.align 4 +.Loop_hw: + ld1.64 {$W0},[$Ktbl],#16 + subs $num,$num,#1 + sub x4,$inp,#128 + orr $AB,@H[0],@H[0] // offload + orr $CD,@H[1],@H[1] + orr $EF,@H[2],@H[2] + orr $GH,@H[3],@H[3] + csel $inp,$inp,x4,ne // conditional rewind +___ +for($i=0;$i<32;$i++) { +$code.=<<___; + add.i64 $W0,$W0,@MSG[0] + ld1.64 {$W1},[$Ktbl],#16 + ext $W0,$W0,$W0,#8 + ext $fg,@H[2],@H[3],#8 + ext $de,@H[1],@H[2],#8 + add.i64 @H[3],@H[3],$W0 // "T1 + H + K512[i]" + sha512su0 @MSG[0],@MSG[1] + ext $m9_10,@MSG[4],@MSG[5],#8 + sha512h @H[3],$fg,$de + sha512su1 @MSG[0],@MSG[7],$m9_10 + add.i64 @H[4],@H[1],@H[3] // "D + T1" + sha512h2 @H[3],$H[1],@H[0] +___ + ($W0,$W1)=($W1,$W0); push(@MSG,shift(@MSG)); + @H = (@H[3],@H[0],@H[4],@H[2],@H[1]); +} +for(;$i<40;$i++) { +$code.=<<___ if ($i<39); + ld1.64 {$W1},[$Ktbl],#16 +___ +$code.=<<___ if ($i==39); + sub $Ktbl,$Ktbl,#$rounds*$SZ // rewind +___ +$code.=<<___; + add.i64 $W0,$W0,@MSG[0] + ld1 {@MSG[0]},[$inp],#16 // load next input + ext $W0,$W0,$W0,#8 + ext $fg,@H[2],@H[3],#8 + ext $de,@H[1],@H[2],#8 + add.i64 @H[3],@H[3],$W0 // "T1 + H + K512[i]" + sha512h @H[3],$fg,$de + rev64 @MSG[0],@MSG[0] + add.i64 @H[4],@H[1],@H[3] // "D + T1" + sha512h2 @H[3],$H[1],@H[0] +___ + ($W0,$W1)=($W1,$W0); push(@MSG,shift(@MSG)); + @H = (@H[3],@H[0],@H[4],@H[2],@H[1]); +} +$code.=<<___; + add.i64 @H[0],@H[0],$AB // accumulate + add.i64 @H[1],@H[1],$CD + add.i64 @H[2],@H[2],$EF + add.i64 @H[3],@H[3],$GH + + cbnz $num,.Loop_hw + + st1.64 {@H[0]-@H[3]},[$ctx] // store context + + ldr x29,[sp],#16 + ret +.size sha512_block_data_order_hw,.-sha512_block_data_order_hw +#endif +___ +} + +{ my %opcode = ( + "sha256h" => 0x5e004000, "sha256h2" => 0x5e005000, + "sha256su0" => 0x5e282800, "sha256su1" => 0x5e006000 ); + + sub unsha256 { + my ($mnemonic,$arg)=@_; + + $arg =~ m/[qv]([0-9]+)[^,]*,\s*[qv]([0-9]+)[^,]*(?:,\s*[qv]([0-9]+))?/o + && + sprintf ".inst\t0x%08x\t//%s %s", + $opcode{$mnemonic}|$1|($2<<5)|($3<<16), + $mnemonic,$arg; + } +} + +{ my %opcode = ( + "sha512h" => 0xce608000, "sha512h2" => 0xce608400, + "sha512su0" => 0xcec08000, "sha512su1" => 0xce608800 ); + + sub unsha512 { + my ($mnemonic,$arg)=@_; + + $arg =~ m/[qv]([0-9]+)[^,]*,\s*[qv]([0-9]+)[^,]*(?:,\s*[qv]([0-9]+))?/o + && + sprintf ".inst\t0x%08x\t//%s %s", + $opcode{$mnemonic}|$1|($2<<5)|($3<<16), + $mnemonic,$arg; + } +} + +open SELF,$0; +while() { + next if (/^#!/); + last if (!s/^#/\/\// and !/^$/); + print; +} +close SELF; + +foreach(split("\n",$code)) { + + s/\`([^\`]*)\`/eval($1)/ge; + + s/\b(sha512\w+)\s+([qv].*)/unsha512($1,$2)/ge or + s/\b(sha256\w+)\s+([qv].*)/unsha256($1,$2)/ge; + + s/\bq([0-9]+)\b/v$1.16b/g; # old->new registers + + s/\.[ui]?8(\s)/$1/; + s/\.\w?64\b// and s/\.16b/\.2d/g or + s/\.\w?32\b// and s/\.16b/\.4s/g; + m/\bext\b/ and s/\.2d/\.16b/g or + m/(ld|st)1[^\[]+\[0\]/ and s/\.4s/\.s/g; + + print $_,"\n"; +} + +close STDOUT or die "error closing STDOUT: $!"; diff --git a/http/vendor/ring/crypto/fipsmodule/sha/asm/sha512-x86_64.pl b/http/vendor/ring/crypto/fipsmodule/sha/asm/sha512-x86_64.pl new file mode 100644 index 0000000..76a4110 --- /dev/null +++ b/http/vendor/ring/crypto/fipsmodule/sha/asm/sha512-x86_64.pl @@ -0,0 +1,1655 @@ +#! /usr/bin/env perl +# Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# +# ==================================================================== +# Written by Andy Polyakov for the OpenSSL +# project. Rights for redistribution and usage in source and binary +# forms are granted according to the License. +# ==================================================================== +# +# sha256/512_block procedure for x86_64. +# +# 40% improvement over compiler-generated code on Opteron. On EM64T +# sha256 was observed to run >80% faster and sha512 - >40%. No magical +# tricks, just straight implementation... I really wonder why gcc +# [being armed with inline assembler] fails to generate as fast code. +# The only thing which is cool about this module is that it's very +# same instruction sequence used for both SHA-256 and SHA-512. In +# former case the instructions operate on 32-bit operands, while in +# latter - on 64-bit ones. All I had to do is to get one flavor right, +# the other one passed the test right away:-) +# +# sha256_block runs in ~1005 cycles on Opteron, which gives you +# asymptotic performance of 64*1000/1005=63.7MBps times CPU clock +# frequency in GHz. sha512_block runs in ~1275 cycles, which results +# in 128*1000/1275=100MBps per GHz. Is there room for improvement? +# Well, if you compare it to IA-64 implementation, which maintains +# X[16] in register bank[!], tends to 4 instructions per CPU clock +# cycle and runs in 1003 cycles, 1275 is very good result for 3-way +# issue Opteron pipeline and X[16] maintained in memory. So that *if* +# there is a way to improve it, *then* the only way would be to try to +# offload X[16] updates to SSE unit, but that would require "deeper" +# loop unroll, which in turn would naturally cause size blow-up, not +# to mention increased complexity! And once again, only *if* it's +# actually possible to noticeably improve overall ILP, instruction +# level parallelism, on a given CPU implementation in this case. +# +# Special note on Intel EM64T. While Opteron CPU exhibits perfect +# performance ratio of 1.5 between 64- and 32-bit flavors [see above], +# [currently available] EM64T CPUs apparently are far from it. On the +# contrary, 64-bit version, sha512_block, is ~30% *slower* than 32-bit +# sha256_block:-( This is presumably because 64-bit shifts/rotates +# apparently are not atomic instructions, but implemented in microcode. +# +# May 2012. +# +# Optimization including one of Pavel Semjanov's ideas, alternative +# Maj, resulted in >=5% improvement on most CPUs, +20% SHA256 and +# unfortunately -2% SHA512 on P4 [which nobody should care about +# that much]. +# +# June 2012. +# +# Add SIMD code paths, see below for improvement coefficients. SSSE3 +# code path was not attempted for SHA512, because improvement is not +# estimated to be high enough, noticeably less than 9%, to justify +# the effort, not on pre-AVX processors. [Obviously with exclusion +# for VIA Nano, but it has SHA512 instruction that is faster and +# should be used instead.] For reference, corresponding estimated +# upper limit for improvement for SSSE3 SHA256 is 28%. The fact that +# higher coefficients are observed on VIA Nano and Bulldozer has more +# to do with specifics of their architecture [which is topic for +# separate discussion]. +# +# November 2012. +# +# Add AVX2 code path. Two consecutive input blocks are loaded to +# 256-bit %ymm registers, with data from first block to least +# significant 128-bit halves and data from second to most significant. +# The data is then processed with same SIMD instruction sequence as +# for AVX, but with %ymm as operands. Side effect is increased stack +# frame, 448 additional bytes in SHA256 and 1152 in SHA512, and 1.2KB +# code size increase. +# +# March 2014. +# +# Add support for Intel SHA Extensions. + +###################################################################### +# Current performance in cycles per processed byte (less is better): +# +# SHA256 SSSE3 AVX/XOP(*) SHA512 AVX/XOP(*) +# +# AMD K8 14.9 - - 9.57 - +# P4 17.3 - - 30.8 - +# Core 2 15.6 13.8(+13%) - 9.97 - +# Westmere 14.8 12.3(+19%) - 9.58 - +# Sandy Bridge 17.4 14.2(+23%) 11.6(+50%(**)) 11.2 8.10(+38%(**)) +# Ivy Bridge 12.6 10.5(+20%) 10.3(+22%) 8.17 7.22(+13%) +# Haswell 12.2 9.28(+31%) 7.80(+56%) 7.66 5.40(+42%) +# Skylake 11.4 9.03(+26%) 7.70(+48%) 7.25 5.20(+40%) +# Bulldozer 21.1 13.6(+54%) 13.6(+54%(***)) 13.5 8.58(+57%) +# Ryzen 11.0 9.02(+22%) 2.05(+440%) 7.05 5.67(+20%) +# VIA Nano 23.0 16.5(+39%) - 14.7 - +# Atom 23.0 18.9(+22%) - 14.7 - +# Silvermont 27.4 20.6(+33%) - 17.5 - +# Knights L 27.4 21.0(+30%) 19.6(+40%) 17.5 12.8(+37%) +# Goldmont 18.9 14.3(+32%) 4.16(+350%) 12.0 - +# +# (*) whichever best applicable, including SHAEXT; +# (**) switch from ror to shrd stands for fair share of improvement; +# (***) execution time is fully determined by remaining integer-only +# part, body_00_15; reducing the amount of SIMD instructions +# below certain limit makes no difference/sense; to conserve +# space SHA256 XOP code path is therefore omitted; +# +# Modified from upstream OpenSSL to remove the XOP code. + +my ($flavour, $output) = @ARGV; + +if ($output =~ /sha512-x86_64/) { + $func="sha512_block_data_order"; + $TABLE="K512"; + $SZ=8; + @ROT=($A,$B,$C,$D,$E,$F,$G,$H)=("%rax","%rbx","%rcx","%rdx", + "%r8", "%r9", "%r10","%r11"); + ($T1,$a0,$a1,$a2,$a3)=("%r12","%r13","%r14","%r15","%rdi"); + @Sigma0=(28,34,39); + @Sigma1=(14,18,41); + @sigma0=(1, 8, 7); + @sigma1=(19,61, 6); + $rounds=80; +} else { + $func="sha256_block_data_order"; + $TABLE="K256"; + $SZ=4; + @ROT=($A,$B,$C,$D,$E,$F,$G,$H)=("%eax","%ebx","%ecx","%edx", + "%r8d","%r9d","%r10d","%r11d"); + ($T1,$a0,$a1,$a2,$a3)=("%r12d","%r13d","%r14d","%r15d","%edi"); + @Sigma0=( 2,13,22); + @Sigma1=( 6,11,25); + @sigma0=( 7,18, 3); + @sigma1=(17,19,10); + $rounds=64; +} + +$win64=0; $win64=1 if ($flavour =~ /[nm]asm|mingw64/ || $output =~ /\.asm$/); + +$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1; +( $xlate="${dir}x86_64-xlate.pl" and -f $xlate ) or +( $xlate="${dir}../../../perlasm/x86_64-xlate.pl" and -f $xlate) or +die "can't locate x86_64-xlate.pl"; + +# In upstream, this is controlled by shelling out to the compiler to check +# versions, but BoringSSL is intended to be used with pre-generated perlasm +# output, so this isn't useful anyway. +# +# This file also has an AVX2 implementation, controlled by setting $avx to 2. +# For now, we intentionally disable it. While it gives a 13-16% perf boost, the +# CFI annotations are wrong. It allocates stack in a loop and should be +# rewritten to avoid this. +$avx = 1; +$shaext = 1; + +open OUT,"| \"$^X\" \"$xlate\" $flavour \"$output\""; +*STDOUT=*OUT; + +$ctx="%rdi"; # 1st arg, zapped by $a3 +$inp="%rsi"; # 2nd arg +$Tbl="%rbp"; + +$_ctx="16*$SZ+0*8(%rsp)"; +$_inp="16*$SZ+1*8(%rsp)"; +$_end="16*$SZ+2*8(%rsp)"; +$_rsp="`16*$SZ+3*8`(%rsp)"; +$framesz="16*$SZ+4*8"; + + +sub ROUND_00_15() +{ my ($i,$a,$b,$c,$d,$e,$f,$g,$h) = @_; + my $STRIDE=$SZ; + $STRIDE += 16 if ($i%(16/$SZ)==(16/$SZ-1)); + +$code.=<<___; + ror \$`$Sigma1[2]-$Sigma1[1]`,$a0 + mov $f,$a2 + + xor $e,$a0 + ror \$`$Sigma0[2]-$Sigma0[1]`,$a1 + xor $g,$a2 # f^g + + mov $T1,`$SZ*($i&0xf)`(%rsp) + xor $a,$a1 + and $e,$a2 # (f^g)&e + + ror \$`$Sigma1[1]-$Sigma1[0]`,$a0 + add $h,$T1 # T1+=h + xor $g,$a2 # Ch(e,f,g)=((f^g)&e)^g + + ror \$`$Sigma0[1]-$Sigma0[0]`,$a1 + xor $e,$a0 + add $a2,$T1 # T1+=Ch(e,f,g) + + mov $a,$a2 + add ($Tbl),$T1 # T1+=K[round] + xor $a,$a1 + + xor $b,$a2 # a^b, b^c in next round + ror \$$Sigma1[0],$a0 # Sigma1(e) + mov $b,$h + + and $a2,$a3 + ror \$$Sigma0[0],$a1 # Sigma0(a) + add $a0,$T1 # T1+=Sigma1(e) + + xor $a3,$h # h=Maj(a,b,c)=Ch(a^b,c,b) + add $T1,$d # d+=T1 + add $T1,$h # h+=T1 + + lea $STRIDE($Tbl),$Tbl # round++ +___ +$code.=<<___ if ($i<15); + add $a1,$h # h+=Sigma0(a) +___ + ($a2,$a3) = ($a3,$a2); +} + +sub ROUND_16_XX() +{ my ($i,$a,$b,$c,$d,$e,$f,$g,$h) = @_; + +$code.=<<___; + mov `$SZ*(($i+1)&0xf)`(%rsp),$a0 + mov `$SZ*(($i+14)&0xf)`(%rsp),$a2 + + mov $a0,$T1 + ror \$`$sigma0[1]-$sigma0[0]`,$a0 + add $a1,$a # modulo-scheduled h+=Sigma0(a) + mov $a2,$a1 + ror \$`$sigma1[1]-$sigma1[0]`,$a2 + + xor $T1,$a0 + shr \$$sigma0[2],$T1 + ror \$$sigma0[0],$a0 + xor $a1,$a2 + shr \$$sigma1[2],$a1 + + ror \$$sigma1[0],$a2 + xor $a0,$T1 # sigma0(X[(i+1)&0xf]) + xor $a1,$a2 # sigma1(X[(i+14)&0xf]) + add `$SZ*(($i+9)&0xf)`(%rsp),$T1 + + add `$SZ*($i&0xf)`(%rsp),$T1 + mov $e,$a0 + add $a2,$T1 + mov $a,$a1 +___ + &ROUND_00_15(@_); +} + +$code=<<___; +.text + +.globl ${func}_nohw +.type ${func}_nohw,\@function,3 +.align 16 +${func}_nohw: +.cfi_startproc + _CET_ENDBR + mov %rsp,%rax # copy %rsp +.cfi_def_cfa_register %rax + push %rbx +.cfi_push %rbx + push %rbp +.cfi_push %rbp + push %r12 +.cfi_push %r12 + push %r13 +.cfi_push %r13 + push %r14 +.cfi_push %r14 + push %r15 +.cfi_push %r15 + shl \$4,%rdx # num*16 + sub \$$framesz,%rsp + lea ($inp,%rdx,$SZ),%rdx # inp+num*16*$SZ + and \$-64,%rsp # align stack frame + mov $ctx,$_ctx # save ctx, 1st arg + mov $inp,$_inp # save inp, 2nd arh + mov %rdx,$_end # save end pointer, "3rd" arg + mov %rax,$_rsp # save copy of %rsp +.cfi_cfa_expression $_rsp,deref,+8 +.Lprologue: + + mov $SZ*0($ctx),$A + mov $SZ*1($ctx),$B + mov $SZ*2($ctx),$C + mov $SZ*3($ctx),$D + mov $SZ*4($ctx),$E + mov $SZ*5($ctx),$F + mov $SZ*6($ctx),$G + mov $SZ*7($ctx),$H + jmp .Lloop + +.align 16 +.Lloop: + mov $B,$a3 + lea $TABLE(%rip),$Tbl + xor $C,$a3 # magic +___ + for($i=0;$i<16;$i++) { + $code.=" mov $SZ*$i($inp),$T1\n"; + $code.=" mov @ROT[4],$a0\n"; + $code.=" mov @ROT[0],$a1\n"; + $code.=" bswap $T1\n"; + &ROUND_00_15($i,@ROT); + unshift(@ROT,pop(@ROT)); + } +$code.=<<___; + jmp .Lrounds_16_xx +.align 16 +.Lrounds_16_xx: +___ + for(;$i<32;$i++) { + &ROUND_16_XX($i,@ROT); + unshift(@ROT,pop(@ROT)); + } + +$code.=<<___; + cmpb \$0,`$SZ-1`($Tbl) + jnz .Lrounds_16_xx + + mov $_ctx,$ctx + add $a1,$A # modulo-scheduled h+=Sigma0(a) + lea 16*$SZ($inp),$inp + + add $SZ*0($ctx),$A + add $SZ*1($ctx),$B + add $SZ*2($ctx),$C + add $SZ*3($ctx),$D + add $SZ*4($ctx),$E + add $SZ*5($ctx),$F + add $SZ*6($ctx),$G + add $SZ*7($ctx),$H + + cmp $_end,$inp + + mov $A,$SZ*0($ctx) + mov $B,$SZ*1($ctx) + mov $C,$SZ*2($ctx) + mov $D,$SZ*3($ctx) + mov $E,$SZ*4($ctx) + mov $F,$SZ*5($ctx) + mov $G,$SZ*6($ctx) + mov $H,$SZ*7($ctx) + jb .Lloop + + mov $_rsp,%rsi +.cfi_def_cfa %rsi,8 + mov -48(%rsi),%r15 +.cfi_restore %r15 + mov -40(%rsi),%r14 +.cfi_restore %r14 + mov -32(%rsi),%r13 +.cfi_restore %r13 + mov -24(%rsi),%r12 +.cfi_restore %r12 + mov -16(%rsi),%rbp +.cfi_restore %rbp + mov -8(%rsi),%rbx +.cfi_restore %rbx + lea (%rsi),%rsp +.cfi_def_cfa_register %rsp +.Lepilogue: + ret +.cfi_endproc +.size ${func}_nohw,.-${func}_nohw +___ + +if ($SZ==4) { +$code.=<<___; +.section .rodata +.align 64 +.type $TABLE,\@object +$TABLE: + .long 0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5 + .long 0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5 + .long 0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5 + .long 0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5 + .long 0xd807aa98,0x12835b01,0x243185be,0x550c7dc3 + .long 0xd807aa98,0x12835b01,0x243185be,0x550c7dc3 + .long 0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174 + .long 0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174 + .long 0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc + .long 0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc + .long 0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da + .long 0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da + .long 0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7 + .long 0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7 + .long 0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967 + .long 0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967 + .long 0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13 + .long 0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13 + .long 0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85 + .long 0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85 + .long 0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3 + .long 0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3 + .long 0xd192e819,0xd6990624,0xf40e3585,0x106aa070 + .long 0xd192e819,0xd6990624,0xf40e3585,0x106aa070 + .long 0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5 + .long 0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5 + .long 0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3 + .long 0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3 + .long 0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208 + .long 0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208 + .long 0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2 + .long 0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2 + + .long 0x00010203,0x04050607,0x08090a0b,0x0c0d0e0f + .long 0x00010203,0x04050607,0x08090a0b,0x0c0d0e0f + .long 0x03020100,0x0b0a0908,0xffffffff,0xffffffff + .long 0x03020100,0x0b0a0908,0xffffffff,0xffffffff + .long 0xffffffff,0xffffffff,0x03020100,0x0b0a0908 + .long 0xffffffff,0xffffffff,0x03020100,0x0b0a0908 + .asciz "SHA256 block transform for x86_64, CRYPTOGAMS by " +.text +___ +} else { +$code.=<<___; +.section .rodata +.align 64 +.type $TABLE,\@object +$TABLE: + .quad 0x428a2f98d728ae22,0x7137449123ef65cd + .quad 0x428a2f98d728ae22,0x7137449123ef65cd + .quad 0xb5c0fbcfec4d3b2f,0xe9b5dba58189dbbc + .quad 0xb5c0fbcfec4d3b2f,0xe9b5dba58189dbbc + .quad 0x3956c25bf348b538,0x59f111f1b605d019 + .quad 0x3956c25bf348b538,0x59f111f1b605d019 + .quad 0x923f82a4af194f9b,0xab1c5ed5da6d8118 + .quad 0x923f82a4af194f9b,0xab1c5ed5da6d8118 + .quad 0xd807aa98a3030242,0x12835b0145706fbe + .quad 0xd807aa98a3030242,0x12835b0145706fbe + .quad 0x243185be4ee4b28c,0x550c7dc3d5ffb4e2 + .quad 0x243185be4ee4b28c,0x550c7dc3d5ffb4e2 + .quad 0x72be5d74f27b896f,0x80deb1fe3b1696b1 + .quad 0x72be5d74f27b896f,0x80deb1fe3b1696b1 + .quad 0x9bdc06a725c71235,0xc19bf174cf692694 + .quad 0x9bdc06a725c71235,0xc19bf174cf692694 + .quad 0xe49b69c19ef14ad2,0xefbe4786384f25e3 + .quad 0xe49b69c19ef14ad2,0xefbe4786384f25e3 + .quad 0x0fc19dc68b8cd5b5,0x240ca1cc77ac9c65 + .quad 0x0fc19dc68b8cd5b5,0x240ca1cc77ac9c65 + .quad 0x2de92c6f592b0275,0x4a7484aa6ea6e483 + .quad 0x2de92c6f592b0275,0x4a7484aa6ea6e483 + .quad 0x5cb0a9dcbd41fbd4,0x76f988da831153b5 + .quad 0x5cb0a9dcbd41fbd4,0x76f988da831153b5 + .quad 0x983e5152ee66dfab,0xa831c66d2db43210 + .quad 0x983e5152ee66dfab,0xa831c66d2db43210 + .quad 0xb00327c898fb213f,0xbf597fc7beef0ee4 + .quad 0xb00327c898fb213f,0xbf597fc7beef0ee4 + .quad 0xc6e00bf33da88fc2,0xd5a79147930aa725 + .quad 0xc6e00bf33da88fc2,0xd5a79147930aa725 + .quad 0x06ca6351e003826f,0x142929670a0e6e70 + .quad 0x06ca6351e003826f,0x142929670a0e6e70 + .quad 0x27b70a8546d22ffc,0x2e1b21385c26c926 + .quad 0x27b70a8546d22ffc,0x2e1b21385c26c926 + .quad 0x4d2c6dfc5ac42aed,0x53380d139d95b3df + .quad 0x4d2c6dfc5ac42aed,0x53380d139d95b3df + .quad 0x650a73548baf63de,0x766a0abb3c77b2a8 + .quad 0x650a73548baf63de,0x766a0abb3c77b2a8 + .quad 0x81c2c92e47edaee6,0x92722c851482353b + .quad 0x81c2c92e47edaee6,0x92722c851482353b + .quad 0xa2bfe8a14cf10364,0xa81a664bbc423001 + .quad 0xa2bfe8a14cf10364,0xa81a664bbc423001 + .quad 0xc24b8b70d0f89791,0xc76c51a30654be30 + .quad 0xc24b8b70d0f89791,0xc76c51a30654be30 + .quad 0xd192e819d6ef5218,0xd69906245565a910 + .quad 0xd192e819d6ef5218,0xd69906245565a910 + .quad 0xf40e35855771202a,0x106aa07032bbd1b8 + .quad 0xf40e35855771202a,0x106aa07032bbd1b8 + .quad 0x19a4c116b8d2d0c8,0x1e376c085141ab53 + .quad 0x19a4c116b8d2d0c8,0x1e376c085141ab53 + .quad 0x2748774cdf8eeb99,0x34b0bcb5e19b48a8 + .quad 0x2748774cdf8eeb99,0x34b0bcb5e19b48a8 + .quad 0x391c0cb3c5c95a63,0x4ed8aa4ae3418acb + .quad 0x391c0cb3c5c95a63,0x4ed8aa4ae3418acb + .quad 0x5b9cca4f7763e373,0x682e6ff3d6b2b8a3 + .quad 0x5b9cca4f7763e373,0x682e6ff3d6b2b8a3 + .quad 0x748f82ee5defb2fc,0x78a5636f43172f60 + .quad 0x748f82ee5defb2fc,0x78a5636f43172f60 + .quad 0x84c87814a1f0ab72,0x8cc702081a6439ec + .quad 0x84c87814a1f0ab72,0x8cc702081a6439ec + .quad 0x90befffa23631e28,0xa4506cebde82bde9 + .quad 0x90befffa23631e28,0xa4506cebde82bde9 + .quad 0xbef9a3f7b2c67915,0xc67178f2e372532b + .quad 0xbef9a3f7b2c67915,0xc67178f2e372532b + .quad 0xca273eceea26619c,0xd186b8c721c0c207 + .quad 0xca273eceea26619c,0xd186b8c721c0c207 + .quad 0xeada7dd6cde0eb1e,0xf57d4f7fee6ed178 + .quad 0xeada7dd6cde0eb1e,0xf57d4f7fee6ed178 + .quad 0x06f067aa72176fba,0x0a637dc5a2c898a6 + .quad 0x06f067aa72176fba,0x0a637dc5a2c898a6 + .quad 0x113f9804bef90dae,0x1b710b35131c471b + .quad 0x113f9804bef90dae,0x1b710b35131c471b + .quad 0x28db77f523047d84,0x32caab7b40c72493 + .quad 0x28db77f523047d84,0x32caab7b40c72493 + .quad 0x3c9ebe0a15c9bebc,0x431d67c49c100d4c + .quad 0x3c9ebe0a15c9bebc,0x431d67c49c100d4c + .quad 0x4cc5d4becb3e42b6,0x597f299cfc657e2a + .quad 0x4cc5d4becb3e42b6,0x597f299cfc657e2a + .quad 0x5fcb6fab3ad6faec,0x6c44198c4a475817 + .quad 0x5fcb6fab3ad6faec,0x6c44198c4a475817 + + .quad 0x0001020304050607,0x08090a0b0c0d0e0f + .quad 0x0001020304050607,0x08090a0b0c0d0e0f + .asciz "SHA512 block transform for x86_64, CRYPTOGAMS by " +.text +___ +} + +###################################################################### +# SIMD code paths +# +if ($SZ==4 && $shaext) {{{ +###################################################################### +# Intel SHA Extensions implementation of SHA256 update function. +# +my ($ctx,$inp,$num,$Tbl)=("%rdi","%rsi","%rdx","%rcx"); + +my ($Wi,$ABEF,$CDGH,$TMP,$BSWAP,$ABEF_SAVE,$CDGH_SAVE)=map("%xmm$_",(0..2,7..10)); +my @MSG=map("%xmm$_",(3..6)); + +$code.=<<___; +.globl sha256_block_data_order_hw +.type sha256_block_data_order_hw,\@function,3 +.align 64 +sha256_block_data_order_hw: +.cfi_startproc + _CET_ENDBR +___ +$code.=<<___ if ($win64); + lea `-8-5*16`(%rsp),%rsp + movaps %xmm6,-8-5*16(%rax) + movaps %xmm7,-8-4*16(%rax) + movaps %xmm8,-8-3*16(%rax) + movaps %xmm9,-8-2*16(%rax) + movaps %xmm10,-8-1*16(%rax) +.Lprologue_shaext: +___ +$code.=<<___; + lea K256+0x80(%rip),$Tbl + movdqu ($ctx),$ABEF # DCBA + movdqu 16($ctx),$CDGH # HGFE + movdqa 0x200-0x80($Tbl),$TMP # byte swap mask + + pshufd \$0x1b,$ABEF,$Wi # ABCD + pshufd \$0xb1,$ABEF,$ABEF # CDAB + pshufd \$0x1b,$CDGH,$CDGH # EFGH + movdqa $TMP,$BSWAP # offload + palignr \$8,$CDGH,$ABEF # ABEF + punpcklqdq $Wi,$CDGH # CDGH + jmp .Loop_shaext + +.align 16 +.Loop_shaext: + movdqu ($inp),@MSG[0] + movdqu 0x10($inp),@MSG[1] + movdqu 0x20($inp),@MSG[2] + pshufb $TMP,@MSG[0] + movdqu 0x30($inp),@MSG[3] + + movdqa 0*32-0x80($Tbl),$Wi + paddd @MSG[0],$Wi + pshufb $TMP,@MSG[1] + movdqa $CDGH,$CDGH_SAVE # offload + sha256rnds2 $ABEF,$CDGH # 0-3 + pshufd \$0x0e,$Wi,$Wi + nop + movdqa $ABEF,$ABEF_SAVE # offload + sha256rnds2 $CDGH,$ABEF + + movdqa 1*32-0x80($Tbl),$Wi + paddd @MSG[1],$Wi + pshufb $TMP,@MSG[2] + sha256rnds2 $ABEF,$CDGH # 4-7 + pshufd \$0x0e,$Wi,$Wi + lea 0x40($inp),$inp + sha256msg1 @MSG[1],@MSG[0] + sha256rnds2 $CDGH,$ABEF + + movdqa 2*32-0x80($Tbl),$Wi + paddd @MSG[2],$Wi + pshufb $TMP,@MSG[3] + sha256rnds2 $ABEF,$CDGH # 8-11 + pshufd \$0x0e,$Wi,$Wi + movdqa @MSG[3],$TMP + palignr \$4,@MSG[2],$TMP + nop + paddd $TMP,@MSG[0] + sha256msg1 @MSG[2],@MSG[1] + sha256rnds2 $CDGH,$ABEF + + movdqa 3*32-0x80($Tbl),$Wi + paddd @MSG[3],$Wi + sha256msg2 @MSG[3],@MSG[0] + sha256rnds2 $ABEF,$CDGH # 12-15 + pshufd \$0x0e,$Wi,$Wi + movdqa @MSG[0],$TMP + palignr \$4,@MSG[3],$TMP + nop + paddd $TMP,@MSG[1] + sha256msg1 @MSG[3],@MSG[2] + sha256rnds2 $CDGH,$ABEF +___ +for($i=4;$i<16-3;$i++) { +$code.=<<___; + movdqa $i*32-0x80($Tbl),$Wi + paddd @MSG[0],$Wi + sha256msg2 @MSG[0],@MSG[1] + sha256rnds2 $ABEF,$CDGH # 16-19... + pshufd \$0x0e,$Wi,$Wi + movdqa @MSG[1],$TMP + palignr \$4,@MSG[0],$TMP + nop + paddd $TMP,@MSG[2] + sha256msg1 @MSG[0],@MSG[3] + sha256rnds2 $CDGH,$ABEF +___ + push(@MSG,shift(@MSG)); +} +$code.=<<___; + movdqa 13*32-0x80($Tbl),$Wi + paddd @MSG[0],$Wi + sha256msg2 @MSG[0],@MSG[1] + sha256rnds2 $ABEF,$CDGH # 52-55 + pshufd \$0x0e,$Wi,$Wi + movdqa @MSG[1],$TMP + palignr \$4,@MSG[0],$TMP + sha256rnds2 $CDGH,$ABEF + paddd $TMP,@MSG[2] + + movdqa 14*32-0x80($Tbl),$Wi + paddd @MSG[1],$Wi + sha256rnds2 $ABEF,$CDGH # 56-59 + pshufd \$0x0e,$Wi,$Wi + sha256msg2 @MSG[1],@MSG[2] + movdqa $BSWAP,$TMP + sha256rnds2 $CDGH,$ABEF + + movdqa 15*32-0x80($Tbl),$Wi + paddd @MSG[2],$Wi + nop + sha256rnds2 $ABEF,$CDGH # 60-63 + pshufd \$0x0e,$Wi,$Wi + dec $num + nop + sha256rnds2 $CDGH,$ABEF + + paddd $CDGH_SAVE,$CDGH + paddd $ABEF_SAVE,$ABEF + jnz .Loop_shaext + + pshufd \$0xb1,$CDGH,$CDGH # DCHG + pshufd \$0x1b,$ABEF,$TMP # FEBA + pshufd \$0xb1,$ABEF,$ABEF # BAFE + punpckhqdq $CDGH,$ABEF # DCBA + palignr \$8,$TMP,$CDGH # HGFE + + movdqu $ABEF,($ctx) + movdqu $CDGH,16($ctx) +___ +$code.=<<___ if ($win64); + movaps -8-5*16(%rax),%xmm6 + movaps -8-4*16(%rax),%xmm7 + movaps -8-3*16(%rax),%xmm8 + movaps -8-2*16(%rax),%xmm9 + movaps -8-1*16(%rax),%xmm10 + mov %rax,%rsp +.Lepilogue_shaext: +___ +$code.=<<___; + ret +.cfi_endproc +.size sha256_block_data_order_hw,.-sha256_block_data_order_hw +___ +}}} +{{{ + +my $a4=$T1; +my ($a,$b,$c,$d,$e,$f,$g,$h); + +sub AUTOLOAD() # thunk [simplified] 32-bit style perlasm +{ my $opcode = $AUTOLOAD; $opcode =~ s/.*:://; + my $arg = pop; + $arg = "\$$arg" if ($arg*1 eq $arg); + $code .= "\t$opcode\t".join(',',$arg,reverse @_)."\n"; +} + +sub body_00_15 () { + ( + '($a,$b,$c,$d,$e,$f,$g,$h)=@ROT;'. + + '&ror ($a0,$Sigma1[2]-$Sigma1[1])', + '&mov ($a,$a1)', + '&mov ($a4,$f)', + + '&ror ($a1,$Sigma0[2]-$Sigma0[1])', + '&xor ($a0,$e)', + '&xor ($a4,$g)', # f^g + + '&ror ($a0,$Sigma1[1]-$Sigma1[0])', + '&xor ($a1,$a)', + '&and ($a4,$e)', # (f^g)&e + + '&xor ($a0,$e)', + '&add ($h,$SZ*($i&15)."(%rsp)")', # h+=X[i]+K[i] + '&mov ($a2,$a)', + + '&xor ($a4,$g)', # Ch(e,f,g)=((f^g)&e)^g + '&ror ($a1,$Sigma0[1]-$Sigma0[0])', + '&xor ($a2,$b)', # a^b, b^c in next round + + '&add ($h,$a4)', # h+=Ch(e,f,g) + '&ror ($a0,$Sigma1[0])', # Sigma1(e) + '&and ($a3,$a2)', # (b^c)&(a^b) + + '&xor ($a1,$a)', + '&add ($h,$a0)', # h+=Sigma1(e) + '&xor ($a3,$b)', # Maj(a,b,c)=Ch(a^b,c,b) + + '&ror ($a1,$Sigma0[0])', # Sigma0(a) + '&add ($d,$h)', # d+=h + '&add ($h,$a3)', # h+=Maj(a,b,c) + + '&mov ($a0,$d)', + '&add ($a1,$h);'. # h+=Sigma0(a) + '($a2,$a3) = ($a3,$a2); unshift(@ROT,pop(@ROT)); $i++;' + ); +} + +###################################################################### +# SSSE3 code path +# +if ($SZ==4) { # SHA256 only +my @X = map("%xmm$_",(0..3)); +my ($t0,$t1,$t2,$t3, $t4,$t5) = map("%xmm$_",(4..9)); + +$code.=<<___; +.globl ${func}_ssse3 +.type ${func}_ssse3,\@function,3 +.align 64 +${func}_ssse3: +.cfi_startproc + _CET_ENDBR + mov %rsp,%rax # copy %rsp +.cfi_def_cfa_register %rax + push %rbx +.cfi_push %rbx + push %rbp +.cfi_push %rbp + push %r12 +.cfi_push %r12 + push %r13 +.cfi_push %r13 + push %r14 +.cfi_push %r14 + push %r15 +.cfi_push %r15 + shl \$4,%rdx # num*16 + sub \$`$framesz+$win64*16*4`,%rsp + lea ($inp,%rdx,$SZ),%rdx # inp+num*16*$SZ + and \$-64,%rsp # align stack frame + mov $ctx,$_ctx # save ctx, 1st arg + mov $inp,$_inp # save inp, 2nd arh + mov %rdx,$_end # save end pointer, "3rd" arg + mov %rax,$_rsp # save copy of %rsp +.cfi_cfa_expression $_rsp,deref,+8 +___ +$code.=<<___ if ($win64); + movaps %xmm6,16*$SZ+32(%rsp) + movaps %xmm7,16*$SZ+48(%rsp) + movaps %xmm8,16*$SZ+64(%rsp) + movaps %xmm9,16*$SZ+80(%rsp) +___ +$code.=<<___; +.Lprologue_ssse3: + + mov $SZ*0($ctx),$A + mov $SZ*1($ctx),$B + mov $SZ*2($ctx),$C + mov $SZ*3($ctx),$D + mov $SZ*4($ctx),$E + mov $SZ*5($ctx),$F + mov $SZ*6($ctx),$G + mov $SZ*7($ctx),$H +___ + +$code.=<<___; + #movdqa $TABLE+`$SZ*2*$rounds`+32(%rip),$t4 + #movdqa $TABLE+`$SZ*2*$rounds`+64(%rip),$t5 + jmp .Lloop_ssse3 +.align 16 +.Lloop_ssse3: + movdqa $TABLE+`$SZ*2*$rounds`(%rip),$t3 + movdqu 0x00($inp),@X[0] + movdqu 0x10($inp),@X[1] + movdqu 0x20($inp),@X[2] + pshufb $t3,@X[0] + movdqu 0x30($inp),@X[3] + lea $TABLE(%rip),$Tbl + pshufb $t3,@X[1] + movdqa 0x00($Tbl),$t0 + movdqa 0x20($Tbl),$t1 + pshufb $t3,@X[2] + paddd @X[0],$t0 + movdqa 0x40($Tbl),$t2 + pshufb $t3,@X[3] + movdqa 0x60($Tbl),$t3 + paddd @X[1],$t1 + paddd @X[2],$t2 + paddd @X[3],$t3 + movdqa $t0,0x00(%rsp) + mov $A,$a1 + movdqa $t1,0x10(%rsp) + mov $B,$a3 + movdqa $t2,0x20(%rsp) + xor $C,$a3 # magic + movdqa $t3,0x30(%rsp) + mov $E,$a0 + jmp .Lssse3_00_47 + +.align 16 +.Lssse3_00_47: + sub \$`-16*2*$SZ`,$Tbl # size optimization +___ +sub Xupdate_256_SSSE3 () { + ( + '&movdqa ($t0,@X[1]);', + '&movdqa ($t3,@X[3])', + '&palignr ($t0,@X[0],$SZ)', # X[1..4] + '&palignr ($t3,@X[2],$SZ);', # X[9..12] + '&movdqa ($t1,$t0)', + '&movdqa ($t2,$t0);', + '&psrld ($t0,$sigma0[2])', + '&paddd (@X[0],$t3);', # X[0..3] += X[9..12] + '&psrld ($t2,$sigma0[0])', + '&pshufd ($t3,@X[3],0b11111010)',# X[14..15] + '&pslld ($t1,8*$SZ-$sigma0[1]);'. + '&pxor ($t0,$t2)', + '&psrld ($t2,$sigma0[1]-$sigma0[0]);'. + '&pxor ($t0,$t1)', + '&pslld ($t1,$sigma0[1]-$sigma0[0]);'. + '&pxor ($t0,$t2);', + '&movdqa ($t2,$t3)', + '&pxor ($t0,$t1);', # sigma0(X[1..4]) + '&psrld ($t3,$sigma1[2])', + '&paddd (@X[0],$t0);', # X[0..3] += sigma0(X[1..4]) + '&psrlq ($t2,$sigma1[0])', + '&pxor ($t3,$t2);', + '&psrlq ($t2,$sigma1[1]-$sigma1[0])', + '&pxor ($t3,$t2)', + '&pshufb ($t3,$t4)', # sigma1(X[14..15]) + '&paddd (@X[0],$t3)', # X[0..1] += sigma1(X[14..15]) + '&pshufd ($t3,@X[0],0b01010000)',# X[16..17] + '&movdqa ($t2,$t3);', + '&psrld ($t3,$sigma1[2])', + '&psrlq ($t2,$sigma1[0])', + '&pxor ($t3,$t2);', + '&psrlq ($t2,$sigma1[1]-$sigma1[0])', + '&pxor ($t3,$t2);', + '&movdqa ($t2,16*2*$j."($Tbl)")', + '&pshufb ($t3,$t5)', + '&paddd (@X[0],$t3)' # X[2..3] += sigma1(X[16..17]) + ); +} + +sub SSSE3_256_00_47 () { +my $j = shift; +my $body = shift; +my @X = @_; +my @insns = (&$body,&$body,&$body,&$body); # 104 instructions + + if (0) { + foreach (Xupdate_256_SSSE3()) { # 36 instructions + eval; + eval(shift(@insns)); + eval(shift(@insns)); + eval(shift(@insns)); + } + } else { # squeeze extra 4% on Westmere and 19% on Atom + eval(shift(@insns)); #@ + &movdqa ($t0,@X[1]); + eval(shift(@insns)); + eval(shift(@insns)); + &movdqa ($t3,@X[3]); + eval(shift(@insns)); #@ + eval(shift(@insns)); + eval(shift(@insns)); + eval(shift(@insns)); #@ + eval(shift(@insns)); + &palignr ($t0,@X[0],$SZ); # X[1..4] + eval(shift(@insns)); + eval(shift(@insns)); + &palignr ($t3,@X[2],$SZ); # X[9..12] + eval(shift(@insns)); + eval(shift(@insns)); + eval(shift(@insns)); + eval(shift(@insns)); #@ + &movdqa ($t1,$t0); + eval(shift(@insns)); + eval(shift(@insns)); + &movdqa ($t2,$t0); + eval(shift(@insns)); #@ + eval(shift(@insns)); + &psrld ($t0,$sigma0[2]); + eval(shift(@insns)); + eval(shift(@insns)); + eval(shift(@insns)); + &paddd (@X[0],$t3); # X[0..3] += X[9..12] + eval(shift(@insns)); #@ + eval(shift(@insns)); + &psrld ($t2,$sigma0[0]); + eval(shift(@insns)); + eval(shift(@insns)); + &pshufd ($t3,@X[3],0b11111010); # X[4..15] + eval(shift(@insns)); + eval(shift(@insns)); #@ + &pslld ($t1,8*$SZ-$sigma0[1]); + eval(shift(@insns)); + eval(shift(@insns)); + &pxor ($t0,$t2); + eval(shift(@insns)); #@ + eval(shift(@insns)); + eval(shift(@insns)); + eval(shift(@insns)); #@ + &psrld ($t2,$sigma0[1]-$sigma0[0]); + eval(shift(@insns)); + &pxor ($t0,$t1); + eval(shift(@insns)); + eval(shift(@insns)); + &pslld ($t1,$sigma0[1]-$sigma0[0]); + eval(shift(@insns)); + eval(shift(@insns)); + &pxor ($t0,$t2); + eval(shift(@insns)); + eval(shift(@insns)); #@ + &movdqa ($t2,$t3); + eval(shift(@insns)); + eval(shift(@insns)); + &pxor ($t0,$t1); # sigma0(X[1..4]) + eval(shift(@insns)); #@ + eval(shift(@insns)); + eval(shift(@insns)); + &psrld ($t3,$sigma1[2]); + eval(shift(@insns)); + eval(shift(@insns)); + &paddd (@X[0],$t0); # X[0..3] += sigma0(X[1..4]) + eval(shift(@insns)); #@ + eval(shift(@insns)); + &psrlq ($t2,$sigma1[0]); + eval(shift(@insns)); + eval(shift(@insns)); + eval(shift(@insns)); + &pxor ($t3,$t2); + eval(shift(@insns)); #@ + eval(shift(@insns)); + eval(shift(@insns)); + eval(shift(@insns)); #@ + &psrlq ($t2,$sigma1[1]-$sigma1[0]); + eval(shift(@insns)); + eval(shift(@insns)); + &pxor ($t3,$t2); + eval(shift(@insns)); #@ + eval(shift(@insns)); + eval(shift(@insns)); + #&pshufb ($t3,$t4); # sigma1(X[14..15]) + &pshufd ($t3,$t3,0b10000000); + eval(shift(@insns)); + eval(shift(@insns)); + eval(shift(@insns)); + &psrldq ($t3,8); + eval(shift(@insns)); + eval(shift(@insns)); #@ + eval(shift(@insns)); + eval(shift(@insns)); + eval(shift(@insns)); #@ + &paddd (@X[0],$t3); # X[0..1] += sigma1(X[14..15]) + eval(shift(@insns)); + eval(shift(@insns)); + eval(shift(@insns)); + &pshufd ($t3,@X[0],0b01010000); # X[16..17] + eval(shift(@insns)); + eval(shift(@insns)); #@ + eval(shift(@insns)); + &movdqa ($t2,$t3); + eval(shift(@insns)); + eval(shift(@insns)); + &psrld ($t3,$sigma1[2]); + eval(shift(@insns)); + eval(shift(@insns)); #@ + &psrlq ($t2,$sigma1[0]); + eval(shift(@insns)); + eval(shift(@insns)); + &pxor ($t3,$t2); + eval(shift(@insns)); #@ + eval(shift(@insns)); + eval(shift(@insns)); + eval(shift(@insns)); #@ + eval(shift(@insns)); + &psrlq ($t2,$sigma1[1]-$sigma1[0]); + eval(shift(@insns)); + eval(shift(@insns)); + eval(shift(@insns)); + &pxor ($t3,$t2); + eval(shift(@insns)); + eval(shift(@insns)); + eval(shift(@insns)); #@ + #&pshufb ($t3,$t5); + &pshufd ($t3,$t3,0b00001000); + eval(shift(@insns)); + eval(shift(@insns)); + &movdqa ($t2,16*2*$j."($Tbl)"); + eval(shift(@insns)); #@ + eval(shift(@insns)); + &pslldq ($t3,8); + eval(shift(@insns)); + eval(shift(@insns)); + eval(shift(@insns)); + &paddd (@X[0],$t3); # X[2..3] += sigma1(X[16..17]) + eval(shift(@insns)); #@ + eval(shift(@insns)); + eval(shift(@insns)); + } + &paddd ($t2,@X[0]); + foreach (@insns) { eval; } # remaining instructions + &movdqa (16*$j."(%rsp)",$t2); +} + + for ($i=0,$j=0; $j<4; $j++) { + &SSSE3_256_00_47($j,\&body_00_15,@X); + push(@X,shift(@X)); # rotate(@X) + } + &cmpb ($SZ-1+16*2*$SZ."($Tbl)",0); + &jne (".Lssse3_00_47"); + + for ($i=0; $i<16; ) { + foreach(body_00_15()) { eval; } + } +$code.=<<___; + mov $_ctx,$ctx + mov $a1,$A + + add $SZ*0($ctx),$A + lea 16*$SZ($inp),$inp + add $SZ*1($ctx),$B + add $SZ*2($ctx),$C + add $SZ*3($ctx),$D + add $SZ*4($ctx),$E + add $SZ*5($ctx),$F + add $SZ*6($ctx),$G + add $SZ*7($ctx),$H + + cmp $_end,$inp + + mov $A,$SZ*0($ctx) + mov $B,$SZ*1($ctx) + mov $C,$SZ*2($ctx) + mov $D,$SZ*3($ctx) + mov $E,$SZ*4($ctx) + mov $F,$SZ*5($ctx) + mov $G,$SZ*6($ctx) + mov $H,$SZ*7($ctx) + jb .Lloop_ssse3 + + mov $_rsp,%rsi +.cfi_def_cfa %rsi,8 +___ +$code.=<<___ if ($win64); + movaps 16*$SZ+32(%rsp),%xmm6 + movaps 16*$SZ+48(%rsp),%xmm7 + movaps 16*$SZ+64(%rsp),%xmm8 + movaps 16*$SZ+80(%rsp),%xmm9 +___ +$code.=<<___; + mov -48(%rsi),%r15 +.cfi_restore %r15 + mov -40(%rsi),%r14 +.cfi_restore %r14 + mov -32(%rsi),%r13 +.cfi_restore %r13 + mov -24(%rsi),%r12 +.cfi_restore %r12 + mov -16(%rsi),%rbp +.cfi_restore %rbp + mov -8(%rsi),%rbx +.cfi_restore %rbx + lea (%rsi),%rsp +.cfi_def_cfa_register %rsp +.Lepilogue_ssse3: + ret +.cfi_endproc +.size ${func}_ssse3,.-${func}_ssse3 +___ +} + +if ($avx) {{ +###################################################################### +# AVX+shrd code path +# +local *ror = sub { &shrd(@_[0],@_) }; + +$code.=<<___; +.globl ${func}_avx +.type ${func}_avx,\@function,3 +.align 64 +${func}_avx: +.cfi_startproc + _CET_ENDBR + mov %rsp,%rax # copy %rsp +.cfi_def_cfa_register %rax + push %rbx +.cfi_push %rbx + push %rbp +.cfi_push %rbp + push %r12 +.cfi_push %r12 + push %r13 +.cfi_push %r13 + push %r14 +.cfi_push %r14 + push %r15 +.cfi_push %r15 + shl \$4,%rdx # num*16 + sub \$`$framesz+$win64*16*($SZ==4?4:6)`,%rsp + lea ($inp,%rdx,$SZ),%rdx # inp+num*16*$SZ + and \$-64,%rsp # align stack frame + mov $ctx,$_ctx # save ctx, 1st arg + mov $inp,$_inp # save inp, 2nd arh + mov %rdx,$_end # save end pointer, "3rd" arg + mov %rax,$_rsp # save copy of %rsp +.cfi_cfa_expression $_rsp,deref,+8 +___ +$code.=<<___ if ($win64); + movaps %xmm6,16*$SZ+32(%rsp) + movaps %xmm7,16*$SZ+48(%rsp) + movaps %xmm8,16*$SZ+64(%rsp) + movaps %xmm9,16*$SZ+80(%rsp) +___ +$code.=<<___ if ($win64 && $SZ>4); + movaps %xmm10,16*$SZ+96(%rsp) + movaps %xmm11,16*$SZ+112(%rsp) +___ +$code.=<<___; +.Lprologue_avx: + + vzeroupper + mov $SZ*0($ctx),$A + mov $SZ*1($ctx),$B + mov $SZ*2($ctx),$C + mov $SZ*3($ctx),$D + mov $SZ*4($ctx),$E + mov $SZ*5($ctx),$F + mov $SZ*6($ctx),$G + mov $SZ*7($ctx),$H +___ + if ($SZ==4) { # SHA256 + my @X = map("%xmm$_",(0..3)); + my ($t0,$t1,$t2,$t3, $t4,$t5) = map("%xmm$_",(4..9)); + +$code.=<<___; + vmovdqa $TABLE+`$SZ*2*$rounds`+32(%rip),$t4 + vmovdqa $TABLE+`$SZ*2*$rounds`+64(%rip),$t5 + jmp .Lloop_avx +.align 16 +.Lloop_avx: + vmovdqa $TABLE+`$SZ*2*$rounds`(%rip),$t3 + vmovdqu 0x00($inp),@X[0] + vmovdqu 0x10($inp),@X[1] + vmovdqu 0x20($inp),@X[2] + vmovdqu 0x30($inp),@X[3] + vpshufb $t3,@X[0],@X[0] + lea $TABLE(%rip),$Tbl + vpshufb $t3,@X[1],@X[1] + vpshufb $t3,@X[2],@X[2] + vpaddd 0x00($Tbl),@X[0],$t0 + vpshufb $t3,@X[3],@X[3] + vpaddd 0x20($Tbl),@X[1],$t1 + vpaddd 0x40($Tbl),@X[2],$t2 + vpaddd 0x60($Tbl),@X[3],$t3 + vmovdqa $t0,0x00(%rsp) + mov $A,$a1 + vmovdqa $t1,0x10(%rsp) + mov $B,$a3 + vmovdqa $t2,0x20(%rsp) + xor $C,$a3 # magic + vmovdqa $t3,0x30(%rsp) + mov $E,$a0 + jmp .Lavx_00_47 + +.align 16 +.Lavx_00_47: + sub \$`-16*2*$SZ`,$Tbl # size optimization +___ +sub Xupdate_256_AVX () { + ( + '&vpalignr ($t0,@X[1],@X[0],$SZ)', # X[1..4] + '&vpalignr ($t3,@X[3],@X[2],$SZ)', # X[9..12] + '&vpsrld ($t2,$t0,$sigma0[0]);', + '&vpaddd (@X[0],@X[0],$t3)', # X[0..3] += X[9..12] + '&vpsrld ($t3,$t0,$sigma0[2])', + '&vpslld ($t1,$t0,8*$SZ-$sigma0[1]);', + '&vpxor ($t0,$t3,$t2)', + '&vpshufd ($t3,@X[3],0b11111010)',# X[14..15] + '&vpsrld ($t2,$t2,$sigma0[1]-$sigma0[0]);', + '&vpxor ($t0,$t0,$t1)', + '&vpslld ($t1,$t1,$sigma0[1]-$sigma0[0]);', + '&vpxor ($t0,$t0,$t2)', + '&vpsrld ($t2,$t3,$sigma1[2]);', + '&vpxor ($t0,$t0,$t1)', # sigma0(X[1..4]) + '&vpsrlq ($t3,$t3,$sigma1[0]);', + '&vpaddd (@X[0],@X[0],$t0)', # X[0..3] += sigma0(X[1..4]) + '&vpxor ($t2,$t2,$t3);', + '&vpsrlq ($t3,$t3,$sigma1[1]-$sigma1[0])', + '&vpxor ($t2,$t2,$t3)', + '&vpshufb ($t2,$t2,$t4)', # sigma1(X[14..15]) + '&vpaddd (@X[0],@X[0],$t2)', # X[0..1] += sigma1(X[14..15]) + '&vpshufd ($t3,@X[0],0b01010000)',# X[16..17] + '&vpsrld ($t2,$t3,$sigma1[2])', + '&vpsrlq ($t3,$t3,$sigma1[0])', + '&vpxor ($t2,$t2,$t3);', + '&vpsrlq ($t3,$t3,$sigma1[1]-$sigma1[0])', + '&vpxor ($t2,$t2,$t3)', + '&vpshufb ($t2,$t2,$t5)', + '&vpaddd (@X[0],@X[0],$t2)' # X[2..3] += sigma1(X[16..17]) + ); +} + +sub AVX_256_00_47 () { +my $j = shift; +my $body = shift; +my @X = @_; +my @insns = (&$body,&$body,&$body,&$body); # 104 instructions + + foreach (Xupdate_256_AVX()) { # 29 instructions + eval; + eval(shift(@insns)); + eval(shift(@insns)); + eval(shift(@insns)); + } + &vpaddd ($t2,@X[0],16*2*$j."($Tbl)"); + foreach (@insns) { eval; } # remaining instructions + &vmovdqa (16*$j."(%rsp)",$t2); +} + + for ($i=0,$j=0; $j<4; $j++) { + &AVX_256_00_47($j,\&body_00_15,@X); + push(@X,shift(@X)); # rotate(@X) + } + &cmpb ($SZ-1+16*2*$SZ."($Tbl)",0); + &jne (".Lavx_00_47"); + + for ($i=0; $i<16; ) { + foreach(body_00_15()) { eval; } + } + + } else { # SHA512 + my @X = map("%xmm$_",(0..7)); + my ($t0,$t1,$t2,$t3) = map("%xmm$_",(8..11)); + +$code.=<<___; + jmp .Lloop_avx +.align 16 +.Lloop_avx: + vmovdqa $TABLE+`$SZ*2*$rounds`(%rip),$t3 + vmovdqu 0x00($inp),@X[0] + lea $TABLE+0x80(%rip),$Tbl # size optimization + vmovdqu 0x10($inp),@X[1] + vmovdqu 0x20($inp),@X[2] + vpshufb $t3,@X[0],@X[0] + vmovdqu 0x30($inp),@X[3] + vpshufb $t3,@X[1],@X[1] + vmovdqu 0x40($inp),@X[4] + vpshufb $t3,@X[2],@X[2] + vmovdqu 0x50($inp),@X[5] + vpshufb $t3,@X[3],@X[3] + vmovdqu 0x60($inp),@X[6] + vpshufb $t3,@X[4],@X[4] + vmovdqu 0x70($inp),@X[7] + vpshufb $t3,@X[5],@X[5] + vpaddq -0x80($Tbl),@X[0],$t0 + vpshufb $t3,@X[6],@X[6] + vpaddq -0x60($Tbl),@X[1],$t1 + vpshufb $t3,@X[7],@X[7] + vpaddq -0x40($Tbl),@X[2],$t2 + vpaddq -0x20($Tbl),@X[3],$t3 + vmovdqa $t0,0x00(%rsp) + vpaddq 0x00($Tbl),@X[4],$t0 + vmovdqa $t1,0x10(%rsp) + vpaddq 0x20($Tbl),@X[5],$t1 + vmovdqa $t2,0x20(%rsp) + vpaddq 0x40($Tbl),@X[6],$t2 + vmovdqa $t3,0x30(%rsp) + vpaddq 0x60($Tbl),@X[7],$t3 + vmovdqa $t0,0x40(%rsp) + mov $A,$a1 + vmovdqa $t1,0x50(%rsp) + mov $B,$a3 + vmovdqa $t2,0x60(%rsp) + xor $C,$a3 # magic + vmovdqa $t3,0x70(%rsp) + mov $E,$a0 + jmp .Lavx_00_47 + +.align 16 +.Lavx_00_47: + add \$`16*2*$SZ`,$Tbl +___ +sub Xupdate_512_AVX () { + ( + '&vpalignr ($t0,@X[1],@X[0],$SZ)', # X[1..2] + '&vpalignr ($t3,@X[5],@X[4],$SZ)', # X[9..10] + '&vpsrlq ($t2,$t0,$sigma0[0])', + '&vpaddq (@X[0],@X[0],$t3);', # X[0..1] += X[9..10] + '&vpsrlq ($t3,$t0,$sigma0[2])', + '&vpsllq ($t1,$t0,8*$SZ-$sigma0[1]);', + '&vpxor ($t0,$t3,$t2)', + '&vpsrlq ($t2,$t2,$sigma0[1]-$sigma0[0]);', + '&vpxor ($t0,$t0,$t1)', + '&vpsllq ($t1,$t1,$sigma0[1]-$sigma0[0]);', + '&vpxor ($t0,$t0,$t2)', + '&vpsrlq ($t3,@X[7],$sigma1[2]);', + '&vpxor ($t0,$t0,$t1)', # sigma0(X[1..2]) + '&vpsllq ($t2,@X[7],8*$SZ-$sigma1[1]);', + '&vpaddq (@X[0],@X[0],$t0)', # X[0..1] += sigma0(X[1..2]) + '&vpsrlq ($t1,@X[7],$sigma1[0]);', + '&vpxor ($t3,$t3,$t2)', + '&vpsllq ($t2,$t2,$sigma1[1]-$sigma1[0]);', + '&vpxor ($t3,$t3,$t1)', + '&vpsrlq ($t1,$t1,$sigma1[1]-$sigma1[0]);', + '&vpxor ($t3,$t3,$t2)', + '&vpxor ($t3,$t3,$t1)', # sigma1(X[14..15]) + '&vpaddq (@X[0],@X[0],$t3)', # X[0..1] += sigma1(X[14..15]) + ); +} + +sub AVX_512_00_47 () { +my $j = shift; +my $body = shift; +my @X = @_; +my @insns = (&$body,&$body); # 52 instructions + + foreach (Xupdate_512_AVX()) { # 23 instructions + eval; + eval(shift(@insns)); + eval(shift(@insns)); + } + &vpaddq ($t2,@X[0],16*2*$j-0x80."($Tbl)"); + foreach (@insns) { eval; } # remaining instructions + &vmovdqa (16*$j."(%rsp)",$t2); +} + + for ($i=0,$j=0; $j<8; $j++) { + &AVX_512_00_47($j,\&body_00_15,@X); + push(@X,shift(@X)); # rotate(@X) + } + &cmpb ($SZ-1+16*2*$SZ-0x80."($Tbl)",0); + &jne (".Lavx_00_47"); + + for ($i=0; $i<16; ) { + foreach(body_00_15()) { eval; } + } +} +$code.=<<___; + mov $_ctx,$ctx + mov $a1,$A + + add $SZ*0($ctx),$A + lea 16*$SZ($inp),$inp + add $SZ*1($ctx),$B + add $SZ*2($ctx),$C + add $SZ*3($ctx),$D + add $SZ*4($ctx),$E + add $SZ*5($ctx),$F + add $SZ*6($ctx),$G + add $SZ*7($ctx),$H + + cmp $_end,$inp + + mov $A,$SZ*0($ctx) + mov $B,$SZ*1($ctx) + mov $C,$SZ*2($ctx) + mov $D,$SZ*3($ctx) + mov $E,$SZ*4($ctx) + mov $F,$SZ*5($ctx) + mov $G,$SZ*6($ctx) + mov $H,$SZ*7($ctx) + jb .Lloop_avx + + mov $_rsp,%rsi +.cfi_def_cfa %rsi,8 + vzeroupper +___ +$code.=<<___ if ($win64); + movaps 16*$SZ+32(%rsp),%xmm6 + movaps 16*$SZ+48(%rsp),%xmm7 + movaps 16*$SZ+64(%rsp),%xmm8 + movaps 16*$SZ+80(%rsp),%xmm9 +___ +$code.=<<___ if ($win64 && $SZ>4); + movaps 16*$SZ+96(%rsp),%xmm10 + movaps 16*$SZ+112(%rsp),%xmm11 +___ +$code.=<<___; + mov -48(%rsi),%r15 +.cfi_restore %r15 + mov -40(%rsi),%r14 +.cfi_restore %r14 + mov -32(%rsi),%r13 +.cfi_restore %r13 + mov -24(%rsi),%r12 +.cfi_restore %r12 + mov -16(%rsi),%rbp +.cfi_restore %rbp + mov -8(%rsi),%rbx +.cfi_restore %rbx + lea (%rsi),%rsp +.cfi_def_cfa_register %rsp +.Lepilogue_avx: + ret +.cfi_endproc +.size ${func}_avx,.-${func}_avx +___ + +}}}}} + +# EXCEPTION_DISPOSITION handler (EXCEPTION_RECORD *rec,ULONG64 frame, +# CONTEXT *context,DISPATCHER_CONTEXT *disp) +if ($win64) { +$rec="%rcx"; +$frame="%rdx"; +$context="%r8"; +$disp="%r9"; + +$code.=<<___; +.extern __imp_RtlVirtualUnwind +.type se_handler,\@abi-omnipotent +.align 16 +se_handler: + push %rsi + push %rdi + push %rbx + push %rbp + push %r12 + push %r13 + push %r14 + push %r15 + pushfq + sub \$64,%rsp + + mov 120($context),%rax # pull context->Rax + mov 248($context),%rbx # pull context->Rip + + mov 8($disp),%rsi # disp->ImageBase + mov 56($disp),%r11 # disp->HanderlData + + mov 0(%r11),%r10d # HandlerData[0] + lea (%rsi,%r10),%r10 # prologue label + cmp %r10,%rbx # context->RipRsp + + mov 4(%r11),%r10d # HandlerData[1] + lea (%rsi,%r10),%r10 # epilogue label + cmp %r10,%rbx # context->Rip>=epilogue label + jae .Lin_prologue +___ +$code.=<<___; + mov %rax,%rsi # put aside Rsp + mov 16*$SZ+3*8(%rax),%rax # pull $_rsp + + mov -8(%rax),%rbx + mov -16(%rax),%rbp + mov -24(%rax),%r12 + mov -32(%rax),%r13 + mov -40(%rax),%r14 + mov -48(%rax),%r15 + mov %rbx,144($context) # restore context->Rbx + mov %rbp,160($context) # restore context->Rbp + mov %r12,216($context) # restore context->R12 + mov %r13,224($context) # restore context->R13 + mov %r14,232($context) # restore context->R14 + mov %r15,240($context) # restore context->R15 + + lea .Lepilogue(%rip),%r10 + cmp %r10,%rbx + jb .Lin_prologue # non-AVX code + + lea 16*$SZ+4*8(%rsi),%rsi # Xmm6- save area + lea 512($context),%rdi # &context.Xmm6 + mov \$`$SZ==4?8:12`,%ecx + .long 0xa548f3fc # cld; rep movsq + +.Lin_prologue: + mov 8(%rax),%rdi + mov 16(%rax),%rsi + mov %rax,152($context) # restore context->Rsp + mov %rsi,168($context) # restore context->Rsi + mov %rdi,176($context) # restore context->Rdi + + mov 40($disp),%rdi # disp->ContextRecord + mov $context,%rsi # context + mov \$154,%ecx # sizeof(CONTEXT) + .long 0xa548f3fc # cld; rep movsq + + mov $disp,%rsi + xor %rcx,%rcx # arg1, UNW_FLAG_NHANDLER + mov 8(%rsi),%rdx # arg2, disp->ImageBase + mov 0(%rsi),%r8 # arg3, disp->ControlPc + mov 16(%rsi),%r9 # arg4, disp->FunctionEntry + mov 40(%rsi),%r10 # disp->ContextRecord + lea 56(%rsi),%r11 # &disp->HandlerData + lea 24(%rsi),%r12 # &disp->EstablisherFrame + mov %r10,32(%rsp) # arg5 + mov %r11,40(%rsp) # arg6 + mov %r12,48(%rsp) # arg7 + mov %rcx,56(%rsp) # arg8, (NULL) + call *__imp_RtlVirtualUnwind(%rip) + + mov \$1,%eax # ExceptionContinueSearch + add \$64,%rsp + popfq + pop %r15 + pop %r14 + pop %r13 + pop %r12 + pop %rbp + pop %rbx + pop %rdi + pop %rsi + ret +.size se_handler,.-se_handler +___ + +$code.=<<___ if ($SZ==4 && $shaext); +.type shaext_handler,\@abi-omnipotent +.align 16 +shaext_handler: + push %rsi + push %rdi + push %rbx + push %rbp + push %r12 + push %r13 + push %r14 + push %r15 + pushfq + sub \$64,%rsp + + mov 120($context),%rax # pull context->Rax + mov 248($context),%rbx # pull context->Rip + + lea .Lprologue_shaext(%rip),%r10 + cmp %r10,%rbx # context->Rip<.Lprologue + jb .Lin_prologue + + lea .Lepilogue_shaext(%rip),%r10 + cmp %r10,%rbx # context->Rip>=.Lepilogue + jae .Lin_prologue + + lea -8-5*16(%rax),%rsi + lea 512($context),%rdi # &context.Xmm6 + mov \$10,%ecx + .long 0xa548f3fc # cld; rep movsq + + jmp .Lin_prologue +.size shaext_handler,.-shaext_handler +___ + +$code.=<<___; +.section .pdata +.align 4 + .rva .LSEH_begin_${func}_nohw + .rva .LSEH_end_${func}_nohw + .rva .LSEH_info_${func}_nohw +___ +$code.=<<___ if ($SZ==4 && $shaext); + .rva .LSEH_begin_${func}_hw + .rva .LSEH_end_${func}_hw + .rva .LSEH_info_${func}_hw +___ +$code.=<<___ if ($SZ==4); + .rva .LSEH_begin_${func}_ssse3 + .rva .LSEH_end_${func}_ssse3 + .rva .LSEH_info_${func}_ssse3 +___ +$code.=<<___ if ($avx); + .rva .LSEH_begin_${func}_avx + .rva .LSEH_end_${func}_avx + .rva .LSEH_info_${func}_avx +___ +$code.=<<___; +.section .xdata +.align 8 +.LSEH_info_${func}_nohw: + .byte 9,0,0,0 + .rva se_handler + .rva .Lprologue,.Lepilogue # HandlerData[] +___ +$code.=<<___ if ($SZ==4 && $shaext); +.LSEH_info_${func}_hw: + .byte 9,0,0,0 + .rva shaext_handler +___ +$code.=<<___ if ($SZ==4); +.LSEH_info_${func}_ssse3: + .byte 9,0,0,0 + .rva se_handler + .rva .Lprologue_ssse3,.Lepilogue_ssse3 # HandlerData[] +___ +$code.=<<___ if ($avx); +.LSEH_info_${func}_avx: + .byte 9,0,0,0 + .rva se_handler + .rva .Lprologue_avx,.Lepilogue_avx # HandlerData[] +___ +} + +sub sha256op38 { + my $instr = shift; + my %opcodelet = ( + "sha256rnds2" => 0xcb, + "sha256msg1" => 0xcc, + "sha256msg2" => 0xcd ); + + if (defined($opcodelet{$instr}) && @_[0] =~ /%xmm([0-7]),\s*%xmm([0-7])/) { + my @opcode=(0x0f,0x38); + push @opcode,$opcodelet{$instr}; + push @opcode,0xc0|($1&7)|(($2&7)<<3); # ModR/M + return ".byte\t".join(',',@opcode); + } else { + return $instr."\t".@_[0]; + } +} + +foreach (split("\n",$code)) { + s/\`([^\`]*)\`/eval $1/geo; + + s/\b(sha256[^\s]*)\s+(.*)/sha256op38($1,$2)/geo; + + print $_,"\n"; +} +close STDOUT or die "error closing STDOUT: $!"; diff --git a/http/vendor/ring/crypto/internal.h b/http/vendor/ring/crypto/internal.h new file mode 100644 index 0000000..99223d1 --- /dev/null +++ b/http/vendor/ring/crypto/internal.h @@ -0,0 +1,474 @@ +// Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef OPENSSL_HEADER_CRYPTO_INTERNAL_H +#define OPENSSL_HEADER_CRYPTO_INTERNAL_H + +#include // Must be first. + +#include "ring-core/check.h" + +#if defined(__clang__) +// Don't require prototypes for functions defined in C that are only +// used from Rust. +#pragma GCC diagnostic ignored "-Wmissing-prototypes" +#endif + +#if defined(__GNUC__) && \ + (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) < 40800 +// |alignas| and |alignof| were added in C11. GCC added support in version 4.8. +// Testing for __STDC_VERSION__/__cplusplus doesn't work because 4.7 already +// reports support for C11. +#define alignas(x) __attribute__ ((aligned (x))) +#elif defined(_MSC_VER) && !defined(__clang__) +#define alignas(x) __declspec(align(x)) +#else +#include +#endif + +#if defined(__clang__) || defined(__GNUC__) +#define RING_NOINLINE __attribute__((noinline)) +#elif defined(_MSC_VER) +#define RING_NOINLINE __declspec(noinline) +#else +#define RING_NOINLINE +#endif + +// Some C compilers require a useless cast when dealing with arrays for the +// reason explained in +// https://gustedt.wordpress.com/2011/02/12/const-and-arrays/ +#if defined(__clang__) || defined(_MSC_VER) +#define RING_CORE_POINTLESS_ARRAY_CONST_CAST(cast) +#else +#define RING_CORE_POINTLESS_ARRAY_CONST_CAST(cast) cast +#endif + +// `uint8_t` isn't guaranteed to be 'unsigned char' and only 'char' and +// 'unsigned char' are allowed to alias according to ISO C. +typedef unsigned char aliasing_uint8_t; + +#if (!defined(_MSC_VER) || defined(__clang__)) && defined(OPENSSL_64_BIT) +#define BORINGSSL_HAS_UINT128 +typedef __int128_t int128_t; +typedef __uint128_t uint128_t; +#endif + +// GCC-like compilers indicate SSE2 with |__SSE2__|. MSVC leaves the caller to +// know that x86_64 has SSE2, and uses _M_IX86_FP to indicate SSE2 on x86. +// https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-170 +#if defined(OPENSSL_X86) || defined(OPENSSL_X86_64) +# if defined(_MSC_VER) && !defined(__clang__) +# if defined(_M_AMD64) || defined(_M_X64) || (defined(_M_IX86_FP) && _M_IX86_FP >= 2) +# define OPENSSL_SSE2 +# else +# error "SSE2 is required." +# endif +# elif !defined(__SSE2__) +# error "SSE2 is required." +# endif +#endif + +// For convenience in testing the fallback code, we allow disabling SSE2 +// intrinsics via |OPENSSL_NO_SSE2_FOR_TESTING|. We require SSE2 on x86 and +// x86_64, so we would otherwise need to test such code on a non-x86 platform. +// +// This does not remove the above requirement for SSE2 support with assembly +// optimizations. It only disables some intrinsics-based optimizations so that +// we can test the fallback code on CI. +#if defined(OPENSSL_SSE2) && defined(OPENSSL_NO_SSE2_FOR_TESTING) +#undef OPENSSL_SSE2 +#endif + +// Pointer utility functions. + +// buffers_alias returns one if |a| and |b| alias and zero otherwise. +static inline int buffers_alias(const void *a, size_t a_bytes, + const void *b, size_t b_bytes) { + // Cast |a| and |b| to integers. In C, pointer comparisons between unrelated + // objects are undefined whereas pointer to integer conversions are merely + // implementation-defined. We assume the implementation defined it in a sane + // way. + uintptr_t a_u = (uintptr_t)a; + uintptr_t b_u = (uintptr_t)b; + return a_u + a_bytes > b_u && b_u + b_bytes > a_u; +} + + +// Constant-time utility functions. +// +// The following methods return a bitmask of all ones (0xff...f) for true and 0 +// for false. This is useful for choosing a value based on the result of a +// conditional in constant time. For example, +// +// if (a < b) { +// c = a; +// } else { +// c = b; +// } +// +// can be written as +// +// crypto_word_t lt = constant_time_lt_w(a, b); +// c = constant_time_select_w(lt, a, b); + +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wconversion" +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif +#if defined(_MSC_VER) && !defined(__clang__) +#pragma warning(push) +// '=': conversion from 'crypto_word_t' to 'uint8_t', possible loss of data +#pragma warning(disable: 4242) +// 'initializing': conversion from 'crypto_word_t' to 'uint8_t', ... +#pragma warning(disable: 4244) +#endif + +// crypto_word_t is the type that most constant-time functions use. Ideally we +// would like it to be |size_t|, but NaCl builds in 64-bit mode with 32-bit +// pointers, which means that |size_t| can be 32 bits when |BN_ULONG| is 64 +// bits. Since we want to be able to do constant-time operations on a +// |BN_ULONG|, |crypto_word_t| is defined as an unsigned value with the native +// word length. +#if defined(OPENSSL_64_BIT) +typedef uint64_t crypto_word_t; +#define CRYPTO_WORD_BITS (64u) +#elif defined(OPENSSL_32_BIT) +typedef uint32_t crypto_word_t; +#define CRYPTO_WORD_BITS (32u) +#else +#error "Must define either OPENSSL_32_BIT or OPENSSL_64_BIT" +#endif + +#define CONSTTIME_TRUE_W ~((crypto_word_t)0) +#define CONSTTIME_FALSE_W ((crypto_word_t)0) + +// value_barrier_w returns |a|, but prevents GCC and Clang from reasoning about +// the returned value. This is used to mitigate compilers undoing constant-time +// code, until we can express our requirements directly in the language. +// +// Note the compiler is aware that |value_barrier_w| has no side effects and +// always has the same output for a given input. This allows it to eliminate +// dead code, move computations across loops, and vectorize. +static inline crypto_word_t value_barrier_w(crypto_word_t a) { +#if defined(__GNUC__) || defined(__clang__) + __asm__("" : "+r"(a) : /* no inputs */); +#endif + return a; +} + +// value_barrier_u32 behaves like |value_barrier_w| but takes a |uint32_t|. +static inline uint32_t value_barrier_u32(uint32_t a) { +#if defined(__GNUC__) || defined(__clang__) + __asm__("" : "+r"(a) : /* no inputs */); +#endif + return a; +} + +// |value_barrier_u8| could be defined as above, but compilers other than +// clang seem to still materialize 0x00..00MM instead of reusing 0x??..??MM. + +// constant_time_msb_w returns the given value with the MSB copied to all the +// other bits. +static inline crypto_word_t constant_time_msb_w(crypto_word_t a) { + return 0u - (a >> (sizeof(a) * 8 - 1)); +} + +// constant_time_is_zero returns 0xff..f if a == 0 and 0 otherwise. +static inline crypto_word_t constant_time_is_zero_w(crypto_word_t a) { + // Here is an SMT-LIB verification of this formula: + // + // (define-fun is_zero ((a (_ BitVec 32))) (_ BitVec 32) + // (bvand (bvnot a) (bvsub a #x00000001)) + // ) + // + // (declare-fun a () (_ BitVec 32)) + // + // (assert (not (= (= #x00000001 (bvlshr (is_zero a) #x0000001f)) (= a #x00000000)))) + // (check-sat) + // (get-model) + return constant_time_msb_w(~a & (a - 1)); +} + +static inline crypto_word_t constant_time_is_nonzero_w(crypto_word_t a) { + return ~constant_time_is_zero_w(a); +} + +// constant_time_eq_w returns 0xff..f if a == b and 0 otherwise. +static inline crypto_word_t constant_time_eq_w(crypto_word_t a, + crypto_word_t b) { + return constant_time_is_zero_w(a ^ b); +} + +// constant_time_select_w returns (mask & a) | (~mask & b). When |mask| is all +// 1s or all 0s (as returned by the methods above), the select methods return +// either |a| (if |mask| is nonzero) or |b| (if |mask| is zero). +static inline crypto_word_t constant_time_select_w(crypto_word_t mask, + crypto_word_t a, + crypto_word_t b) { + // Clang recognizes this pattern as a select. While it usually transforms it + // to a cmov, it sometimes further transforms it into a branch, which we do + // not want. + // + // Hiding the value of the mask from the compiler evades this transformation. + mask = value_barrier_w(mask); + return (mask & a) | (~mask & b); +} + +// constant_time_select_8 acts like |constant_time_select| but operates on +// 8-bit values. +static inline uint8_t constant_time_select_8(crypto_word_t mask, uint8_t a, + uint8_t b) { + // |mask| is a word instead of |uint8_t| to avoid materializing 0x000..0MM + // Making both |mask| and its value barrier |uint8_t| would allow the compiler + // to materialize 0x????..?MM instead, but only clang is that clever. + // However, vectorization of bitwise operations seems to work better on + // |uint8_t| than a mix of |uint64_t| and |uint8_t|, so |m| is cast to + // |uint8_t| after the value barrier but before the bitwise operations. + uint8_t m = value_barrier_w(mask); + return (m & a) | (~m & b); +} + +// constant_time_conditional_memcpy copies |n| bytes from |src| to |dst| if +// |mask| is 0xff..ff and does nothing if |mask| is 0. The |n|-byte memory +// ranges at |dst| and |src| must not overlap, as when calling |memcpy|. +static inline void constant_time_conditional_memcpy(void *dst, const void *src, + const size_t n, + const crypto_word_t mask) { + debug_assert_nonsecret(!buffers_alias(dst, n, src, n)); + uint8_t *out = (uint8_t *)dst; + const uint8_t *in = (const uint8_t *)src; + for (size_t i = 0; i < n; i++) { + out[i] = constant_time_select_8(mask, in[i], out[i]); + } +} + +// constant_time_conditional_memxor xors |n| bytes from |src| to |dst| if +// |mask| is 0xff..ff and does nothing if |mask| is 0. The |n|-byte memory +// ranges at |dst| and |src| must not overlap, as when calling |memcpy|. +static inline void constant_time_conditional_memxor(void *dst, const void *src, + size_t n, + const crypto_word_t mask) { + debug_assert_nonsecret(!buffers_alias(dst, n, src, n)); + aliasing_uint8_t *out = dst; + const aliasing_uint8_t *in = src; +#if defined(__GNUC__) && !defined(__clang__) + // gcc 13.2.0 doesn't automatically vectorize this loop regardless of barrier + typedef aliasing_uint8_t v32u8 __attribute__((vector_size(32), aligned(1), may_alias)); + size_t n_vec = n&~(size_t)31; + v32u8 masks = ((aliasing_uint8_t)mask-(v32u8){}); // broadcast + for (size_t i = 0; i < n_vec; i += 32) { + *(v32u8*)&out[i] ^= masks & *(v32u8 const*)&in[i]; + } + out += n_vec; + n -= n_vec; +#endif + for (size_t i = 0; i < n; i++) { + out[i] ^= value_barrier_w(mask) & in[i]; + } +} + +#if defined(BORINGSSL_CONSTANT_TIME_VALIDATION) + +// CONSTTIME_SECRET takes a pointer and a number of bytes and marks that region +// of memory as secret. Secret data is tracked as it flows to registers and +// other parts of a memory. If secret data is used as a condition for a branch, +// or as a memory index, it will trigger warnings in valgrind. +#define CONSTTIME_SECRET(ptr, len) VALGRIND_MAKE_MEM_UNDEFINED(ptr, len) + +// CONSTTIME_DECLASSIFY takes a pointer and a number of bytes and marks that +// region of memory as public. Public data is not subject to constant-time +// rules. +#define CONSTTIME_DECLASSIFY(ptr, len) VALGRIND_MAKE_MEM_DEFINED(ptr, len) + +#else + +#define CONSTTIME_SECRET(ptr, len) +#define CONSTTIME_DECLASSIFY(ptr, len) + +#endif // BORINGSSL_CONSTANT_TIME_VALIDATION + +static inline crypto_word_t constant_time_declassify_w(crypto_word_t v) { + // Return |v| through a value barrier to be safe. Valgrind-based constant-time + // validation is partly to check the compiler has not undone any constant-time + // work. Any place |BORINGSSL_CONSTANT_TIME_VALIDATION| influences + // optimizations, this validation is inaccurate. + // + // However, by sending pointers through valgrind, we likely inhibit escape + // analysis. On local variables, particularly booleans, we likely + // significantly impact optimizations. + // + // Thus, to be safe, stick a value barrier, in hopes of comparably inhibiting + // compiler analysis. + CONSTTIME_DECLASSIFY(&v, sizeof(v)); + return value_barrier_w(v); +} + +static inline int constant_time_declassify_int(int v) { + OPENSSL_STATIC_ASSERT(sizeof(uint32_t) == sizeof(int), + "int is not the same size as uint32_t"); + // See comment above. + CONSTTIME_DECLASSIFY(&v, sizeof(v)); + return value_barrier_u32((uint32_t)v); +} + +#if defined(_MSC_VER) && !defined(__clang__) +// '=': conversion from 'int64_t' to 'int32_t', possible loss of data +#pragma warning(pop) +#endif +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic pop +#endif + +// declassify_assert behaves like |assert| but declassifies the result of +// evaluating |expr|. This allows the assertion to branch on the (presumably +// public) result, but still ensures that values leading up to the computation +// were secret. +#define declassify_assert(expr) dev_assert_secret(constant_time_declassify_int(expr)) + +// Endianness conversions. + +#if defined(__GNUC__) && __GNUC__ >= 2 +static inline uint32_t CRYPTO_bswap4(uint32_t x) { + return __builtin_bswap32(x); +} + +static inline uint64_t CRYPTO_bswap8(uint64_t x) { + return __builtin_bswap64(x); +} +#elif defined(_MSC_VER) +#pragma warning(push, 3) +#include +#pragma warning(pop) +#pragma intrinsic(_byteswap_ulong) +static inline uint32_t CRYPTO_bswap4(uint32_t x) { + return _byteswap_ulong(x); +} +#endif + +#if !defined(RING_CORE_NOSTDLIBINC) +#include +#endif + +static inline void *OPENSSL_memcpy(void *dst, const void *src, size_t n) { +#if !defined(RING_CORE_NOSTDLIBINC) + if (n == 0) { + return dst; + } + return memcpy(dst, src, n); +#else + aliasing_uint8_t *d = dst; + const aliasing_uint8_t *s = src; + for (size_t i = 0; i < n; ++i) { + d[i] = s[i]; + } + return dst; +#endif +} + +static inline void *OPENSSL_memset(void *dst, int c, size_t n) { +#if !defined(RING_CORE_NOSTDLIBINC) + if (n == 0) { + return dst; + } + return memset(dst, c, n); +#else + aliasing_uint8_t *d = dst; + for (size_t i = 0; i < n; ++i) { + d[i] = (aliasing_uint8_t)c; + } + return dst; +#endif +} + + +// Loads and stores. +// +// The following functions load and store sized integers with the specified +// endianness. They use |memcpy|, and so avoid alignment or strict aliasing +// requirements on the input and output pointers. + +#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +#define RING_BIG_ENDIAN +#endif +#endif + +static inline uint32_t CRYPTO_load_u32_le(const void *in) { + uint32_t v; + OPENSSL_memcpy(&v, in, sizeof(v)); +#if defined(RING_BIG_ENDIAN) + return CRYPTO_bswap4(v); +#else + return v; +#endif +} + +static inline void CRYPTO_store_u32_le(void *out, uint32_t v) { +#if defined(RING_BIG_ENDIAN) + v = CRYPTO_bswap4(v); +#endif + OPENSSL_memcpy(out, &v, sizeof(v)); +} + +static inline uint32_t CRYPTO_load_u32_be(const void *in) { + uint32_t v; + OPENSSL_memcpy(&v, in, sizeof(v)); +#if !defined(RING_BIG_ENDIAN) + return CRYPTO_bswap4(v); +#else + return v; +#endif +} + +static inline void CRYPTO_store_u32_be(void *out, uint32_t v) { +#if !defined(RING_BIG_ENDIAN) + v = CRYPTO_bswap4(v); +#endif + OPENSSL_memcpy(out, &v, sizeof(v)); +} + +// Runtime CPU feature support + +#if defined(OPENSSL_X86) || defined(OPENSSL_X86_64) +// OPENSSL_ia32cap_P contains the Intel CPUID bits when running on an x86 or +// x86-64 system. +// +// Index 0: +// EDX for CPUID where EAX = 1 +// Bit 30 is used to indicate an Intel CPU +// Index 1: +// ECX for CPUID where EAX = 1 +// Index 2: +// EBX for CPUID where EAX = 7, ECX = 0 +// Bit 14 (for removed feature MPX) is used to indicate a preference for ymm +// registers over zmm even when zmm registers are supported +// Index 3: +// ECX for CPUID where EAX = 7, ECX = 0 +// +// Note: the CPUID bits are pre-adjusted for the OSXSAVE bit and the XMM, YMM, +// and AVX512 bits in XCR0, so it is not necessary to check those. (WARNING: See +// caveats in cpu_intel.c.) +#if defined(OPENSSL_X86_64) +extern uint32_t avx2_available; +extern uint32_t adx_bmi2_available; +#endif +#endif + + +#if defined(OPENSSL_ARM) +extern alignas(4) uint32_t neon_available; +#endif // OPENSSL_ARM + +#endif // OPENSSL_HEADER_CRYPTO_INTERNAL_H diff --git a/http/vendor/ring/crypto/limbs/limbs.c b/http/vendor/ring/crypto/limbs/limbs.c new file mode 100644 index 0000000..d0027d4 --- /dev/null +++ b/http/vendor/ring/crypto/limbs/limbs.c @@ -0,0 +1,170 @@ +/* Copyright 2016-2017 Brian Smith. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#include "limbs.h" + +#include "../internal.h" +#include "../fipsmodule/bn/internal.h" +#include "limbs.inl" + + +/* XXX: We assume that the conversion from |Carry| to |Limb| is constant-time, + * but we haven't verified that assumption. TODO: Fix it so we don't need to + * make that assumption. */ + +/* Returns 0xfff..f if |a| is zero, and zero otherwise. */ +Limb LIMB_is_zero(const Limb a) { + return constant_time_is_zero_w(a); +} + +/* Returns 0xfff..f if |a| is all zero limbs, and zero otherwise. |num_limbs| + * may be zero. */ +Limb LIMBS_are_zero(const Limb a[], size_t num_limbs) { + Limb all = 0; + for (size_t i = 0; i < num_limbs; ++i) { + all |= a[i]; + } + return LIMB_is_zero(all); +} + +/* Returns 0xffff..f if |a == b|, and zero otherwise. |num_limbs| may be zero. */ +Limb LIMBS_equal(const Limb a[], const Limb b[], size_t num_limbs) { + Limb eq = CONSTTIME_TRUE_W; + for (size_t i = 0; i < num_limbs; ++i) { + eq = constant_time_select_w(eq, constant_time_eq_w(a[i], b[i]), eq); + } + return eq; +} + +/* Returns 0xffff...f if |a| is less than |b|, and zero otherwise. */ +Limb LIMBS_less_than(const Limb a[], const Limb b[], size_t num_limbs) { + debug_assert_nonsecret(num_limbs >= 1); + /* There are lots of ways to implement this. It is implemented this way to + * be consistent with |LIMBS_limbs_reduce_once| and other code that makes such + * comparisons as part of doing conditional reductions. */ + Limb dummy; + Carry borrow = limb_sub(&dummy, a[0], b[0]); + for (size_t i = 1; i < num_limbs; ++i) { + borrow = limb_sbb(&dummy, a[i], b[i], borrow); + } + return constant_time_is_nonzero_w(borrow); +} + +/* if (r >= m) { r -= m; } */ +void LIMBS_reduce_once(Limb r[], const Limb m[], size_t num_limbs) { + debug_assert_nonsecret(num_limbs >= 1); + /* This could be done more efficiently if we had |num_limbs| of extra space + * available, by storing |r - m| and then doing a conditional copy of either + * |r| or |r - m|. But, in order to operate in constant space, with an eye + * towards this function being used in RSA in the future, we do things a + * slightly less efficient way. */ + Limb lt = LIMBS_less_than(r, m, num_limbs); + Carry borrow = + limb_sub(&r[0], r[0], constant_time_select_w(lt, 0, m[0])); + for (size_t i = 1; i < num_limbs; ++i) { + /* XXX: This is probably particularly inefficient because the operations in + * constant_time_select affect the carry flag, so there will likely be + * loads and stores of |borrow|. */ + borrow = + limb_sbb(&r[i], r[i], constant_time_select_w(lt, 0, m[i]), borrow); + } + dev_assert_secret(borrow == 0); +} + +void LIMBS_add_mod(Limb r[], const Limb a[], const Limb b[], const Limb m[], + size_t num_limbs) { + Limb overflow1 = + constant_time_is_nonzero_w(limbs_add(r, a, b, num_limbs)); + Limb overflow2 = ~LIMBS_less_than(r, m, num_limbs); + Limb overflow = overflow1 | overflow2; + Carry borrow = limb_sub(&r[0], r[0], m[0] & overflow); + for (size_t i = 1; i < num_limbs; ++i) { + borrow = limb_sbb(&r[i], r[i], m[i] & overflow, borrow); + } +} + +void LIMBS_sub_mod(Limb r[], const Limb a[], const Limb b[], const Limb m[], + size_t num_limbs) { + Limb underflow = + constant_time_is_nonzero_w(limbs_sub(r, a, b, num_limbs)); + Carry carry = limb_add(&r[0], r[0], m[0] & underflow); + for (size_t i = 1; i < num_limbs; ++i) { + carry = limb_adc(&r[i], r[i], m[i] & underflow, carry); + } +} + +void LIMBS_shl_mod(Limb r[], const Limb a[], const Limb m[], size_t num_limbs) { + Limb overflow1 = + constant_time_is_nonzero_w(a[num_limbs - 1] & LIMB_HIGH_BIT); + Limb carry = 0; + for (size_t i = 0; i < num_limbs; ++i) { + Limb limb = a[i]; + Limb new_carry = limb >> (LIMB_BITS - 1); + r[i] = (limb << 1) | carry; + carry = new_carry; + } + Limb overflow2 = ~LIMBS_less_than(r, m, num_limbs); + Limb overflow = overflow1 | overflow2; + Carry borrow = limb_sub(&r[0], r[0], m[0] & overflow); + for (size_t i = 1; i < num_limbs; ++i) { + borrow = limb_sbb(&r[i], r[i], m[i] & overflow, borrow); + } +} + +int LIMBS_select_512_32(Limb r[], const Limb table[], size_t num_limbs, + crypto_word_t index) { + if (num_limbs % (512 / LIMB_BITS) != 0) { + return 0; + } + limbs_select(r, table, num_limbs, 32, index); + return 1; +} + +static const Limb FIVE_BITS_MASK = 0x1f; + +crypto_word_t LIMBS_window5_split_window(Limb lower_limb, Limb higher_limb, size_t index_within_word) { + Limb high_bits = (higher_limb << (LIMB_BITS - index_within_word)) + & FIVE_BITS_MASK; + // There are no bits outside the window above |index_within_word| (if there + // were then this wouldn't be a split window), so we don't need to mask + // |low_bits|. + Limb low_bits = lower_limb >> index_within_word; + return low_bits | high_bits; +} + +crypto_word_t LIMBS_window5_unsplit_window(Limb limb, size_t index_within_word) { + return (limb >> index_within_word) & FIVE_BITS_MASK; +} + +Limb LIMB_shr(Limb a, size_t shift) { + return a >> shift; +} + +Limb limbs_mul_add_limb(Limb r[], const Limb a[], Limb b, size_t num_limbs) { + Limb carried = 0; + for (size_t i = 0; i < num_limbs; ++i) { + Limb lo; + Limb hi; + bn_umult_lohi(&lo, &hi, a[i], b); + Limb tmp; + Carry c = limb_add(&tmp, lo, carried); + c = limb_adc(&carried, hi, 0, c); + dev_assert_secret(c == 0); + c = limb_add(&r[i], r[i], tmp); + c = limb_adc(&carried, carried, 0, c); + // (A * B) + C + D never carries. + dev_assert_secret(c == 0); + } + return carried; +} diff --git a/http/vendor/ring/crypto/limbs/limbs.h b/http/vendor/ring/crypto/limbs/limbs.h new file mode 100644 index 0000000..0cf83dd --- /dev/null +++ b/http/vendor/ring/crypto/limbs/limbs.h @@ -0,0 +1,38 @@ +/* Copyright 2016 Brian Smith. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#ifndef RING_LIMBS_H +#define RING_LIMBS_H + +#include + +#include "../internal.h" + +typedef crypto_word_t Limb; + +#define LIMB_BITS CRYPTO_WORD_BITS +#define LIMB_HIGH_BIT ((Limb)(1) << (LIMB_BITS - 1)) + + +Limb LIMBS_are_zero(const Limb a[], size_t num_limbs); +Limb LIMBS_equal(const Limb a[], const Limb b[], size_t num_limbs); +void LIMBS_reduce_once(Limb r[], const Limb m[], size_t num_limbs); +void LIMBS_add_mod(Limb r[], const Limb a[], const Limb b[], const Limb m[], + size_t num_limbs); +void LIMBS_sub_mod(Limb r[], const Limb a[], const Limb b[], const Limb m[], + size_t num_limbs); +void LIMBS_shl_mod(Limb r[], const Limb a[], const Limb m[], size_t num_limbs); +Limb limbs_mul_add_limb(Limb r[], const Limb a[], Limb b, size_t num_limbs); + +#endif /* RING_LIMBS_H */ diff --git a/http/vendor/ring/crypto/limbs/limbs.inl b/http/vendor/ring/crypto/limbs/limbs.inl new file mode 100644 index 0000000..1ca72cb --- /dev/null +++ b/http/vendor/ring/crypto/limbs/limbs.inl @@ -0,0 +1,162 @@ +/* Copyright 2016 Brian Smith. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#include "limbs.h" +#include "ring-core/check.h" + +#if defined(_MSC_VER) && !defined(__clang__) +#pragma warning(push, 3) +#include +#pragma warning(pop) + +/* MSVC 2015 RC, when compiling for x86 with /Ox (at least), miscompiles + * _addcarry_u32(c, 0, prod_hi, &x) like so: + * + * add eax,esi ; The previous add that might have set the carry flag. + * xor esi,esi ; OOPS! Carry flag is now reset! + * mov dword ptr [edi-4],eax + * adc esi,dword ptr [prod_hi] + * + * We test with MSVC 2015 update 2, so make sure we're using a version at least + * as new as that. */ +#if _MSC_FULL_VER < 190023918 +#error "MSVC 2015 Update 2 or later is required." +#endif +typedef uint8_t Carry; +#if LIMB_BITS == 64 +#pragma intrinsic(_addcarry_u64, _subborrow_u64) +#define RING_CORE_ADDCARRY_INTRINSIC _addcarry_u64 +#define RING_CORE_SUBBORROW_INTRINSIC _subborrow_u64 +#elif LIMB_BITS == 32 +#pragma intrinsic(_addcarry_u32, _subborrow_u32) +#define RING_CORE_ADDCARRY_INTRINSIC _addcarry_u32 +#define RING_CORE_SUBBORROW_INTRINSIC _subborrow_u32 +typedef uint64_t DoubleLimb; +#endif +#else +typedef Limb Carry; +#if LIMB_BITS == 64 +typedef __uint128_t DoubleLimb; +#elif LIMB_BITS == 32 +typedef uint64_t DoubleLimb; +#endif +#endif + +/* |*r = a + b + carry_in|, returning carry out bit. |carry_in| must be 0 or 1. + */ +static inline Carry limb_adc(Limb *r, Limb a, Limb b, Carry carry_in) { + dev_assert_secret(carry_in == 0 || carry_in == 1); + Carry ret; +#if defined(RING_CORE_ADDCARRY_INTRINSIC) + ret = RING_CORE_ADDCARRY_INTRINSIC(carry_in, a, b, r); +#else + DoubleLimb x = (DoubleLimb)a + b + carry_in; + *r = (Limb)x; + ret = (Carry)(x >> LIMB_BITS); +#endif + dev_assert_secret(ret == 0 || ret == 1); + return ret; +} + +/* |*r = a + b|, returning carry bit. */ +static inline Carry limb_add(Limb *r, Limb a, Limb b) { + Carry ret; +#if defined(RING_CORE_ADDCARRY_INTRINSIC) + ret = RING_CORE_ADDCARRY_INTRINSIC(0, a, b, r); +#else + DoubleLimb x = (DoubleLimb)a + b; + *r = (Limb)x; + ret = (Carry)(x >> LIMB_BITS); +#endif + dev_assert_secret(ret == 0 || ret == 1); + return ret; +} + +/* |*r = a - b - borrow_in|, returning the borrow out bit. |borrow_in| must be + * 0 or 1. */ +static inline Carry limb_sbb(Limb *r, Limb a, Limb b, Carry borrow_in) { + dev_assert_secret(borrow_in == 0 || borrow_in == 1); + Carry ret; +#if defined(RING_CORE_SUBBORROW_INTRINSIC) + ret = RING_CORE_SUBBORROW_INTRINSIC(borrow_in, a, b, r); +#else + DoubleLimb x = (DoubleLimb)a - b - borrow_in; + *r = (Limb)x; + ret = (Carry)((x >> LIMB_BITS) & 1); +#endif + dev_assert_secret(ret == 0 || ret == 1); + return ret; +} + +/* |*r = a - b|, returning borrow bit. */ +static inline Carry limb_sub(Limb *r, Limb a, Limb b) { + Carry ret; +#if defined(RING_CORE_SUBBORROW_INTRINSIC) + ret = RING_CORE_SUBBORROW_INTRINSIC(0, a, b, r); +#else + DoubleLimb x = (DoubleLimb)a - b; + *r = (Limb)x; + ret = (Carry)((x >> LIMB_BITS) & 1); +#endif + dev_assert_secret(ret == 0 || ret == 1); + return ret; +} + +static inline Carry limbs_add(Limb r[], const Limb a[], const Limb b[], + size_t num_limbs) { + debug_assert_nonsecret(num_limbs >= 1); + Carry carry = limb_add(&r[0], a[0], b[0]); + for (size_t i = 1; i < num_limbs; ++i) { + carry = limb_adc(&r[i], a[i], b[i], carry); + } + return carry; +} + +/* |r -= s|, returning the borrow. */ +static inline Carry limbs_sub(Limb r[], const Limb a[], const Limb b[], + size_t num_limbs) { + debug_assert_nonsecret(num_limbs >= 1); + Carry borrow = limb_sub(&r[0], a[0], b[0]); + for (size_t i = 1; i < num_limbs; ++i) { + borrow = limb_sbb(&r[i], a[i], b[i], borrow); + } + return borrow; +} + +static inline void limbs_copy(Limb r[], const Limb a[], size_t num_limbs) { + for (size_t i = 0; i < num_limbs; ++i) { + r[i] = a[i]; + } +} + +static inline void limbs_select(Limb r[], const Limb table[], + size_t num_limbs, size_t num_entries, + crypto_word_t index) { + for (size_t i = 0; i < num_limbs; ++i) { + r[i] = 0; + } + + for (size_t e = 0; e < num_entries; ++e) { + Limb equal = constant_time_eq_w(index, e); + for (size_t i = 0; i < num_limbs; ++i) { + r[i] = constant_time_select_w(equal, table[(e * num_limbs) + i], r[i]); + } + } +} + +static inline void limbs_zero(Limb r[], size_t num_limbs) { + for (size_t i = 0; i < num_limbs; ++i) { + r[i] = 0; + } +} diff --git a/http/vendor/ring/crypto/mem.c b/http/vendor/ring/crypto/mem.c new file mode 100644 index 0000000..5a85cea --- /dev/null +++ b/http/vendor/ring/crypto/mem.c @@ -0,0 +1,28 @@ +// Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include "internal.h" + +int CRYPTO_memcmp(const void *in_a, const void *in_b, size_t len) { + const aliasing_uint8_t *a = in_a; + const aliasing_uint8_t *b = in_b; + uint8_t x = 0; + + for (size_t i = 0; i < len; i++) { + x |= a[i] ^ b[i]; + } + + return x; +} diff --git a/http/vendor/ring/crypto/perlasm/arm-xlate.pl b/http/vendor/ring/crypto/perlasm/arm-xlate.pl new file mode 100644 index 0000000..3697138 --- /dev/null +++ b/http/vendor/ring/crypto/perlasm/arm-xlate.pl @@ -0,0 +1,263 @@ +#! /usr/bin/env perl +# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +use strict; + +my $flavour = shift; +my $output = shift; +open STDOUT,">$output" || die "can't open $output: $!"; + +$flavour = "linux32" if (!$flavour or $flavour eq "void"); + +my %GLOBALS; +my $dotinlocallabels=($flavour=~/linux/)?1:0; + +################################################################ +# directives which need special treatment on different platforms +################################################################ +my $arch = sub { + if ($flavour =~ /linux/) { ".arch\t".join(',',@_); } + elsif ($flavour =~ /win64/) { ".arch\t".join(',',@_); } + else { ""; } +}; +my $fpu = sub { + if ($flavour =~ /linux/) { ".fpu\t".join(',',@_); } + else { ""; } +}; +my $hidden = sub { + if ($flavour =~ /ios/) { ".private_extern\t".join(',',@_); } + elsif ($flavour =~ /win64/) { ""; } + else { ".hidden\t".join(',',@_); } +}; +my $comm = sub { + my @args = split(/,\s*/,shift); + my $name = @args[0]; + my $global = \$GLOBALS{$name}; + my $ret; + + if ($flavour =~ /ios32/) { + $ret = ".comm\t_$name,@args[1]\n"; + $ret .= ".non_lazy_symbol_pointer\n"; + $ret .= "$name:\n"; + $ret .= ".indirect_symbol\t_$name\n"; + $ret .= ".long\t0"; + $name = "_$name"; + } else { $ret = ".comm\t".join(',',@args); } + + $$global = $name; + $ret; +}; +my $globl = sub { + my $name = shift; + my $global = \$GLOBALS{$name}; + my $ret; + + SWITCH: for ($flavour) { + /ios/ && do { $name = "_$name"; + last; + }; + } + + $ret = ".globl $name\n"; + # All symbols in assembly files are hidden. + $ret .= &$hidden($name); + $$global = $name; + $ret; +}; +my $global = $globl; +my $extern = sub { + &$globl(@_); + return; # return nothing +}; +my $type = sub { + if ($flavour =~ /linux/) { ".type\t".join(',',@_); } + elsif ($flavour =~ /ios32/) { if (join(',',@_) =~ /(\w+),%function/) { + "#ifdef __thumb2__\n". + ".thumb_func $1\n". + "#endif"; + } + } + elsif ($flavour =~ /win64/) { if (join(',',@_) =~ /(\w+),%function/) { + # See https://sourceware.org/binutils/docs/as/Pseudo-Ops.html + # Per https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#coff-symbol-table, + # the type for functions is 0x20, or 32. + ".def $1\n". + " .type 32\n". + ".endef"; + } + } + else { ""; } +}; +my $size = sub { + if ($flavour =~ /linux/) { ".size\t".join(',',@_); } + else { ""; } +}; +my $inst = sub { + if ($flavour =~ /linux/) { ".inst\t".join(',',@_); } + else { ".long\t".join(',',@_); } +}; +my $asciz = sub { + my $line = join(",",@_); + if ($line =~ /^"(.*)"$/) + { ".byte " . join(",",unpack("C*",$1),0) . "\n.align 2"; } + else + { ""; } +}; +my $section = sub { + if ($flavour =~ /ios/) { + if ($_[0] eq ".rodata") { + return ".section\t__TEXT,__const"; + } + die "Unknown section name $_[0]"; + } else { + return ".section\t" . join(",", @_); + } +}; + +sub range { + my ($r,$sfx,$start,$end) = @_; + + join(",",map("$r$_$sfx",($start..$end))); +} + +sub expand_line { + my $line = shift; + my @ret = (); + + pos($line)=0; + + while ($line =~ m/\G[^@\/\{\"]*/g) { + if ($line =~ m/\G(@|\/\/|$)/gc) { + last; + } + elsif ($line =~ m/\G\{/gc) { + my $saved_pos = pos($line); + $line =~ s/\G([rdqv])([0-9]+)([^\-]*)\-\1([0-9]+)\3/range($1,$3,$2,$4)/e; + pos($line) = $saved_pos; + $line =~ m/\G[^\}]*\}/g; + } + elsif ($line =~ m/\G\"/gc) { + $line =~ m/\G[^\"]*\"/g; + } + } + + $line =~ s/\b(\w+)/$GLOBALS{$1} or $1/ge; + + return $line; +} + +my ($arch_defines, $target_defines); +if ($flavour =~ /32/) { + $arch_defines = "defined(OPENSSL_ARM)"; +} elsif ($flavour =~ /64/) { + $arch_defines = "defined(OPENSSL_AARCH64)"; +} else { + die "unknown architecture: $flavour"; +} +if ($flavour =~ /linux/) { + # Although the flavour is specified as "linux", it is really used by all + # ELF platforms. + $target_defines = "defined(__ELF__)"; +} elsif ($flavour =~ /ios/) { + # Although the flavour is specified as "ios", it is really used by all Apple + # platforms. + $target_defines = "defined(__APPLE__)"; +} elsif ($flavour =~ /win/) { + $target_defines = "defined(_WIN32)"; +} else { + die "unknown target: $flavour"; +} + +print <<___; +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && $arch_defines && $target_defines +___ + +while(my $line=<>) { + + if ($line =~ m/^\s*(#|@|\/\/)/) { print $line; next; } + + $line =~ s|/\*.*\*/||; # get rid of C-style comments... + $line =~ s|^\s+||; # ... and skip white spaces in beginning... + $line =~ s|\s+$||; # ... and at the end + + if ($flavour =~ /64/) { + my $copy = $line; + # Also remove line comments. + $copy =~ s|//.*||; + if ($copy =~ /\b[wx]18\b/) { + die "r18 is reserved by the platform and may not be used."; + } + } + + { + $line =~ s|[\b\.]L(\w{2,})|L$1|g; # common denominator for Locallabel + $line =~ s|\bL(\w{2,})|\.L$1|g if ($dotinlocallabels); + } + + { + $line =~ s|(^[\.\w]+)\:\s*||; + my $label = $1; + if ($label) { + printf "%s:",($GLOBALS{$label} or $label); + } + } + + if ($line !~ m/^[#@]/) { + $line =~ s|^\s*(\.?)(\S+)\s*||; + my $c = $1; $c = "\t" if ($c eq ""); + my $mnemonic = $2; + my $opcode; + if ($mnemonic =~ m/([^\.]+)\.([^\.]+)/) { + $opcode = eval("\$$1_$2"); + } else { + $opcode = eval("\$$mnemonic"); + } + + if ($flavour =~ /ios/) { + # Mach-O and ELF use different syntax for these relocations. Note + # that we require :pg_hi21: to be explicitly listed. It is normally + # optional with adrp instructions. + $line =~ s|:pg_hi21:(\w+)|\1\@PAGE|; + $line =~ s|:lo12:(\w+)|\1\@PAGEOFF|; + } else { + # Clang's integrated assembly does not support the optional + # :pg_hi21: markers, so erase them. + $line =~ s|:pg_hi21:||; + } + + my $arg=expand_line($line); + + if (ref($opcode) eq 'CODE') { + $line = &$opcode($arg); + } elsif ($mnemonic) { + $line = $c.$mnemonic; + $line.= "\t$arg" if ($arg ne ""); + } + } + + print $line if ($line); + print "\n"; +} + +print <<___; +#endif // !OPENSSL_NO_ASM && $arch_defines && $target_defines +___ + +close STDOUT or die "error closing STDOUT: $!"; diff --git a/http/vendor/ring/crypto/perlasm/x86_64-xlate.pl b/http/vendor/ring/crypto/perlasm/x86_64-xlate.pl new file mode 100644 index 0000000..f9d71e1 --- /dev/null +++ b/http/vendor/ring/crypto/perlasm/x86_64-xlate.pl @@ -0,0 +1,1894 @@ +#! /usr/bin/env perl +# Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# Ascetic x86_64 AT&T to MASM/NASM assembler translator by . +# +# Why AT&T to MASM and not vice versa? Several reasons. Because AT&T +# format is way easier to parse. Because it's simpler to "gear" from +# Unix ABI to Windows one [see cross-reference "card" at the end of +# file]. Because Linux targets were available first... +# +# In addition the script also "distills" code suitable for GNU +# assembler, so that it can be compiled with more rigid assemblers, +# such as Solaris /usr/ccs/bin/as. +# +# This translator is not designed to convert *arbitrary* assembler +# code from AT&T format to MASM one. It's designed to convert just +# enough to provide for dual-ABI OpenSSL modules development... +# There *are* limitations and you might have to modify your assembler +# code or this script to achieve the desired result... +# +# Currently recognized limitations: +# +# - can't use multiple ops per line; +# +# Dual-ABI styling rules. +# +# 1. Adhere to Unix register and stack layout [see cross-reference +# ABI "card" at the end for explanation]. +# 2. Forget about "red zone," stick to more traditional blended +# stack frame allocation. If volatile storage is actually required +# that is. If not, just leave the stack as is. +# 3. Functions tagged with ".type name,@function" get crafted with +# unified Win64 prologue and epilogue automatically. If you want +# to take care of ABI differences yourself, tag functions as +# ".type name,@abi-omnipotent" instead. +# 4. To optimize the Win64 prologue you can specify number of input +# arguments as ".type name,@function,N." Keep in mind that if N is +# larger than 6, then you *have to* write "abi-omnipotent" code, +# because >6 cases can't be addressed with unified prologue. +# 5. Name local labels as .L*, do *not* use dynamic labels such as 1: +# (sorry about latter). +# 6. Don't use [or hand-code with .byte] "rep ret." "ret" mnemonic is +# required to identify the spots, where to inject Win64 epilogue! +# 7. Stick to explicit ip-relative addressing. If you have to use +# GOTPCREL addressing, stick to mov symbol@GOTPCREL(%rip),%r??. +# Both are recognized and translated to proper Win64 addressing +# modes. +# +# 8. In order to provide for structured exception handling unified +# Win64 prologue copies %rsp value to %rax. For further details +# see SEH paragraph at the end. +# 9. .init segment is allowed to contain calls to functions only. +# a. If function accepts more than 4 arguments *and* >4th argument +# is declared as non 64-bit value, do clear its upper part. +# +# TODO(https://crbug.com/boringssl/259): The dual-ABI mechanism described here +# does not quite unwind correctly on Windows. The seh_directive logic below has +# the start of a new mechanism. + + +use strict; + +my $flavour = shift; +my $output = shift; +if ($flavour =~ /\./) { $output = $flavour; undef $flavour; } + +open STDOUT,">$output" || die "can't open $output: $!" + if (defined($output)); + +my $gas=1; $gas=0 if ($output =~ /\.asm$/); +my $elf=1; $elf=0 if (!$gas); +my $apple=0; +my $win64=0; +my $prefix=""; +my $decor=".L"; + +my $masmref=8 + 50727*2**-32; # 8.00.50727 shipped with VS2005 +my $masm=0; +my $PTR=" PTR"; + +my $nasmref=2.03; +my $nasm=0; + +if ($flavour eq "mingw64") { $gas=1; $elf=0; $win64=1; + # TODO(davidben): Before supporting the + # mingw64 perlasm flavour, do away with this + # environment variable check. + die "mingw64 not supported"; + $prefix=`echo __USER_LABEL_PREFIX__ | $ENV{CC} -E -P -`; + $prefix =~ s|\R$||; # Better chomp + } +elsif ($flavour eq "macosx") { $gas=1; $elf=0; $apple=1; $prefix="_"; $decor="L\$"; } +elsif ($flavour eq "masm") { $gas=0; $elf=0; $masm=$masmref; $win64=1; $decor="\$L\$"; } +elsif ($flavour eq "nasm") { $gas=0; $elf=0; $nasm=$nasmref; $win64=1; $decor="\$L\$"; $PTR=""; } +elsif (!$gas) { die "unknown flavour $flavour"; } + +my $current_segment; +my $current_function; +my %globals; + +{ package opcode; # pick up opcodes + sub re { + my ($class, $line) = @_; + my $self = {}; + my $ret; + + if ($$line =~ /^([a-z][a-z0-9]*)/i) { + bless $self,$class; + $self->{op} = $1; + $ret = $self; + $$line = substr($$line,@+[0]); $$line =~ s/^\s+//; + + undef $self->{sz}; + if ($self->{op} =~ /^(movz)x?([bw]).*/) { # movz is pain... + $self->{op} = $1; + $self->{sz} = $2; + } elsif ($self->{op} =~ /call|jmp/) { + $self->{sz} = ""; + } elsif ($self->{op} =~ /^p/ && $' !~ /^(ush|op|insrw)/) { # SSEn + $self->{sz} = ""; + } elsif ($self->{op} =~ /^[vk]/) { # VEX or k* such as kmov + $self->{sz} = ""; + } elsif ($self->{op} =~ /mov[dq]/ && $$line =~ /%xmm/) { + $self->{sz} = ""; + } elsif ($self->{op} =~ /^or([qlwb])$/) { + $self->{op} = "or"; + $self->{sz} = $1; + } elsif ($self->{op} =~ /([a-z]{3,})([qlwb])$/) { + $self->{op} = $1; + $self->{sz} = $2; + } + } + $ret; + } + sub size { + my ($self, $sz) = @_; + $self->{sz} = $sz if (defined($sz) && !defined($self->{sz})); + $self->{sz}; + } + sub out { + my $self = shift; + if ($gas) { + if ($self->{op} eq "movz") { # movz is pain... + sprintf "%s%s%s",$self->{op},$self->{sz},shift; + } elsif ($self->{op} =~ /^set/) { + "$self->{op}"; + } elsif ($self->{op} eq "ret") { + my $epilogue = ""; + if ($win64 && $current_function->{abi} eq "svr4") { + $epilogue = "movq 8(%rsp),%rdi\n\t" . + "movq 16(%rsp),%rsi\n\t"; + } + $epilogue . "ret"; + } elsif ($self->{op} eq "call" && !$elf && $current_segment eq ".init") { + ".p2align\t3\n\t.quad"; + } else { + "$self->{op}$self->{sz}"; + } + } else { + $self->{op} =~ s/^movz/movzx/; + if ($self->{op} eq "ret") { + $self->{op} = ""; + if ($win64 && $current_function->{abi} eq "svr4") { + $self->{op} = "mov rdi,QWORD$PTR\[8+rsp\]\t;WIN64 epilogue\n\t". + "mov rsi,QWORD$PTR\[16+rsp\]\n\t"; + } + $self->{op} .= "ret"; + } elsif ($self->{op} =~ /^(pop|push)f/) { + $self->{op} .= $self->{sz}; + } elsif ($self->{op} eq "call" && $current_segment eq ".CRT\$XCU") { + $self->{op} = "\tDQ"; + } + $self->{op}; + } + } + sub mnemonic { + my ($self, $op) = @_; + $self->{op}=$op if (defined($op)); + $self->{op}; + } +} +{ package const; # pick up constants, which start with $ + sub re { + my ($class, $line) = @_; + my $self = {}; + my $ret; + + if ($$line =~ /^\$([^,]+)/) { + bless $self, $class; + $self->{value} = $1; + $ret = $self; + $$line = substr($$line,@+[0]); $$line =~ s/^\s+//; + } + $ret; + } + sub out { + my $self = shift; + + $self->{value} =~ s/\b(0b[0-1]+)/oct($1)/eig; + if ($gas) { + # Solaris /usr/ccs/bin/as can't handle multiplications + # in $self->{value} + my $value = $self->{value}; + no warnings; # oct might complain about overflow, ignore here... + $value =~ s/(?{value} = $value; + } + sprintf "\$%s",$self->{value}; + } else { + my $value = $self->{value}; + $value =~ s/0x([0-9a-f]+)/0$1h/ig if ($masm); + sprintf "%s",$value; + } + } +} +{ package ea; # pick up effective addresses: expr(%reg,%reg,scale) + + my %szmap = ( b=>"BYTE$PTR", w=>"WORD$PTR", + l=>"DWORD$PTR", d=>"DWORD$PTR", + q=>"QWORD$PTR", o=>"OWORD$PTR", + x=>"XMMWORD$PTR", y=>"YMMWORD$PTR", + z=>"ZMMWORD$PTR" ) if (!$gas); + + sub re { + my ($class, $line, $opcode) = @_; + my $self = {}; + my $ret; + + # optional * ----vvv--- appears in indirect jmp/call + if ($$line =~ /^(\*?)([^\(,]*)\(([%\w,]+)\)((?:{[^}]+})*)/) { + bless $self, $class; + $self->{asterisk} = $1; + $self->{label} = $2; + ($self->{base},$self->{index},$self->{scale})=split(/,/,$3); + $self->{scale} = 1 if (!defined($self->{scale})); + $self->{opmask} = $4; + $ret = $self; + $$line = substr($$line,@+[0]); $$line =~ s/^\s+//; + + if ($win64 && $self->{label} =~ s/\@GOTPCREL//) { + die if ($opcode->mnemonic() ne "mov"); + $opcode->mnemonic("lea"); + } + $self->{base} =~ s/^%//; + $self->{index} =~ s/^%// if (defined($self->{index})); + $self->{opcode} = $opcode; + } + $ret; + } + sub size {} + sub out { + my ($self, $sz) = @_; + + $self->{label} =~ s/([_a-z][_a-z0-9]*)/$globals{$1} or $1/gei; + $self->{label} =~ s/\.L/$decor/g; + + # Silently convert all EAs to 64-bit. This is required for + # elder GNU assembler and results in more compact code, + # *but* most importantly AES module depends on this feature! + $self->{index} =~ s/^[er](.?[0-9xpi])[d]?$/r\1/; + $self->{base} =~ s/^[er](.?[0-9xpi])[d]?$/r\1/; + + # Solaris /usr/ccs/bin/as can't handle multiplications + # in $self->{label}... + use integer; + $self->{label} =~ s/(?{label} =~ s/\b([0-9]+\s*[\*\/\%]\s*[0-9]+)\b/eval($1)/eg; + + # Some assemblers insist on signed presentation of 32-bit + # offsets, but sign extension is a tricky business in perl... + if ((1<<31)<<1) { + $self->{label} =~ s/\b([0-9]+)\b/$1<<32>>32/eg; + } else { + $self->{label} =~ s/\b([0-9]+)\b/$1>>0/eg; + } + + # if base register is %rbp or %r13, see if it's possible to + # flip base and index registers [for better performance] + if (!$self->{label} && $self->{index} && $self->{scale}==1 && + $self->{base} =~ /(rbp|r13)/) { + $self->{base} = $self->{index}; $self->{index} = $1; + } + + if ($gas) { + $self->{label} =~ s/^___imp_/__imp__/ if ($flavour eq "mingw64"); + + if (defined($self->{index})) { + sprintf "%s%s(%s,%%%s,%d)%s", + $self->{asterisk},$self->{label}, + $self->{base}?"%$self->{base}":"", + $self->{index},$self->{scale}, + $self->{opmask}; + } else { + sprintf "%s%s(%%%s)%s", $self->{asterisk},$self->{label}, + $self->{base},$self->{opmask}; + } + } else { + $self->{label} =~ s/\./\$/g; + $self->{label} =~ s/(?{label} = "($self->{label})" if ($self->{label} =~ /[\*\+\-\/]/); + + my $mnemonic = $self->{opcode}->mnemonic(); + ($self->{asterisk}) && ($sz="q") || + ($mnemonic =~ /^v?mov([qd])$/) && ($sz=$1) || + ($mnemonic =~ /^v?pinsr([qdwb])$/) && ($sz=$1) || + ($mnemonic =~ /^vpbroadcast([qdwb])$/) && ($sz=$1) || + ($mnemonic =~ /^v(?!perm)[a-z]+[fi]128$/) && ($sz="x"); + + $self->{opmask} =~ s/%(k[0-7])/$1/; + + if (defined($self->{index})) { + sprintf "%s[%s%s*%d%s]%s",$szmap{$sz}, + $self->{label}?"$self->{label}+":"", + $self->{index},$self->{scale}, + $self->{base}?"+$self->{base}":"", + $self->{opmask}; + } elsif ($self->{base} eq "rip") { + sprintf "%s[%s]",$szmap{$sz},$self->{label}; + } else { + sprintf "%s[%s%s]%s", $szmap{$sz}, + $self->{label}?"$self->{label}+":"", + $self->{base},$self->{opmask}; + } + } + } +} +{ package register; # pick up registers, which start with %. + sub re { + my ($class, $line, $opcode) = @_; + my $self = {}; + my $ret; + + # optional * ----vvv--- appears in indirect jmp/call + if ($$line =~ /^(\*?)%(\w+)((?:{[^}]+})*)/) { + bless $self,$class; + $self->{asterisk} = $1; + $self->{value} = $2; + $self->{opmask} = $3; + $opcode->size($self->size()); + $ret = $self; + $$line = substr($$line,@+[0]); $$line =~ s/^\s+//; + } + $ret; + } + sub size { + my $self = shift; + my $ret; + + if ($self->{value} =~ /^r[\d]+b$/i) { $ret="b"; } + elsif ($self->{value} =~ /^r[\d]+w$/i) { $ret="w"; } + elsif ($self->{value} =~ /^r[\d]+d$/i) { $ret="l"; } + elsif ($self->{value} =~ /^r[\w]+$/i) { $ret="q"; } + elsif ($self->{value} =~ /^[a-d][hl]$/i){ $ret="b"; } + elsif ($self->{value} =~ /^[\w]{2}l$/i) { $ret="b"; } + elsif ($self->{value} =~ /^[\w]{2}$/i) { $ret="w"; } + elsif ($self->{value} =~ /^e[a-z]{2}$/i){ $ret="l"; } + + $ret; + } + sub out { + my $self = shift; + if ($gas) { sprintf "%s%%%s%s", $self->{asterisk}, + $self->{value}, + $self->{opmask}; } + else { $self->{opmask} =~ s/%(k[0-7])/$1/; + $self->{value}.$self->{opmask}; } + } +} +{ package label; # pick up labels, which end with : + sub re { + my ($class, $line) = @_; + my $self = {}; + my $ret; + + if ($$line =~ /(^[\.\w]+)\:/) { + bless $self,$class; + $self->{value} = $1; + $ret = $self; + $$line = substr($$line,@+[0]); $$line =~ s/^\s+//; + + $self->{value} =~ s/^\.L/$decor/; + } + $ret; + } + sub out { + my $self = shift; + + if ($gas) { + my $func = ($globals{$self->{value}} or $self->{value}) . ":"; + if ($win64 && $current_function->{name} eq $self->{value} + && $current_function->{abi} eq "svr4") { + $func .= "\n"; + $func .= " movq %rdi,8(%rsp)\n"; + $func .= " movq %rsi,16(%rsp)\n"; + $func .= " movq %rsp,%rax\n"; + $func .= "${decor}SEH_begin_$current_function->{name}:\n"; + my $narg = $current_function->{narg}; + $narg=6 if (!defined($narg)); + $func .= " movq %rcx,%rdi\n" if ($narg>0); + $func .= " movq %rdx,%rsi\n" if ($narg>1); + $func .= " movq %r8,%rdx\n" if ($narg>2); + $func .= " movq %r9,%rcx\n" if ($narg>3); + $func .= " movq 40(%rsp),%r8\n" if ($narg>4); + $func .= " movq 48(%rsp),%r9\n" if ($narg>5); + } + $func; + } elsif ($self->{value} ne "$current_function->{name}") { + # Make all labels in masm global. + $self->{value} .= ":" if ($masm); + $self->{value} . ":"; + } elsif ($win64 && $current_function->{abi} eq "svr4") { + my $func = "$current_function->{name}" . + ($nasm ? ":" : "\tPROC $current_function->{scope}") . + "\n"; + $func .= " mov QWORD$PTR\[8+rsp\],rdi\t;WIN64 prologue\n"; + $func .= " mov QWORD$PTR\[16+rsp\],rsi\n"; + $func .= " mov rax,rsp\n"; + $func .= "${decor}SEH_begin_$current_function->{name}:"; + $func .= ":" if ($masm); + $func .= "\n"; + my $narg = $current_function->{narg}; + $narg=6 if (!defined($narg)); + $func .= " mov rdi,rcx\n" if ($narg>0); + $func .= " mov rsi,rdx\n" if ($narg>1); + $func .= " mov rdx,r8\n" if ($narg>2); + $func .= " mov rcx,r9\n" if ($narg>3); + $func .= " mov r8,QWORD$PTR\[40+rsp\]\n" if ($narg>4); + $func .= " mov r9,QWORD$PTR\[48+rsp\]\n" if ($narg>5); + $func .= "\n"; + } else { + "$current_function->{name}". + ($nasm ? ":" : "\tPROC $current_function->{scope}"); + } + } +} +{ package expr; # pick up expressions + sub re { + my ($class, $line, $opcode) = @_; + my $self = {}; + my $ret; + + if ($$line =~ /(^[^,]+)/) { + bless $self,$class; + $self->{value} = $1; + $ret = $self; + $$line = substr($$line,@+[0]); $$line =~ s/^\s+//; + + $self->{value} =~ s/\@PLT// if (!$elf); + $self->{value} =~ s/([_a-z][_a-z0-9]*)/$globals{$1} or $1/gei; + $self->{value} =~ s/\.L/$decor/g; + $self->{opcode} = $opcode; + } + $ret; + } + sub out { + my $self = shift; + if ($nasm && $self->{opcode}->mnemonic()=~m/^j(?![re]cxz)/) { + "NEAR ".$self->{value}; + } else { + $self->{value}; + } + } +} +{ package cfi_directive; + # CFI directives annotate instructions that are significant for + # stack unwinding procedure compliant with DWARF specification, + # see http://dwarfstd.org/. Besides naturally expected for this + # script platform-specific filtering function, this module adds + # three auxiliary synthetic directives not recognized by [GNU] + # assembler: + # + # - .cfi_push to annotate push instructions in prologue, which + # translates to .cfi_adjust_cfa_offset (if needed) and + # .cfi_offset; + # - .cfi_pop to annotate pop instructions in epilogue, which + # translates to .cfi_adjust_cfa_offset (if needed) and + # .cfi_restore; + # - [and most notably] .cfi_cfa_expression which encodes + # DW_CFA_def_cfa_expression and passes it to .cfi_escape as + # byte vector; + # + # CFA expressions were introduced in DWARF specification version + # 3 and describe how to deduce CFA, Canonical Frame Address. This + # becomes handy if your stack frame is variable and you can't + # spare register for [previous] frame pointer. Suggested directive + # syntax is made-up mix of DWARF operator suffixes [subset of] + # and references to registers with optional bias. Following example + # describes offloaded *original* stack pointer at specific offset + # from *current* stack pointer: + # + # .cfi_cfa_expression %rsp+40,deref,+8 + # + # Final +8 has everything to do with the fact that CFA is defined + # as reference to top of caller's stack, and on x86_64 call to + # subroutine pushes 8-byte return address. In other words original + # stack pointer upon entry to a subroutine is 8 bytes off from CFA. + + # Below constants are taken from "DWARF Expressions" section of the + # DWARF specification, section is numbered 7.7 in versions 3 and 4. + my %DW_OP_simple = ( # no-arg operators, mapped directly + deref => 0x06, dup => 0x12, + drop => 0x13, over => 0x14, + pick => 0x15, swap => 0x16, + rot => 0x17, xderef => 0x18, + + abs => 0x19, and => 0x1a, + div => 0x1b, minus => 0x1c, + mod => 0x1d, mul => 0x1e, + neg => 0x1f, not => 0x20, + or => 0x21, plus => 0x22, + shl => 0x24, shr => 0x25, + shra => 0x26, xor => 0x27, + ); + + my %DW_OP_complex = ( # used in specific subroutines + constu => 0x10, # uleb128 + consts => 0x11, # sleb128 + plus_uconst => 0x23, # uleb128 + lit0 => 0x30, # add 0-31 to opcode + reg0 => 0x50, # add 0-31 to opcode + breg0 => 0x70, # add 0-31 to opcole, sleb128 + regx => 0x90, # uleb28 + fbreg => 0x91, # sleb128 + bregx => 0x92, # uleb128, sleb128 + piece => 0x93, # uleb128 + ); + + # Following constants are defined in x86_64 ABI supplement, for + # example available at https://www.uclibc.org/docs/psABI-x86_64.pdf, + # see section 3.7 "Stack Unwind Algorithm". + my %DW_reg_idx = ( + "%rax"=>0, "%rdx"=>1, "%rcx"=>2, "%rbx"=>3, + "%rsi"=>4, "%rdi"=>5, "%rbp"=>6, "%rsp"=>7, + "%r8" =>8, "%r9" =>9, "%r10"=>10, "%r11"=>11, + "%r12"=>12, "%r13"=>13, "%r14"=>14, "%r15"=>15 + ); + + my ($cfa_reg, $cfa_rsp); + my @cfa_stack; + + # [us]leb128 format is variable-length integer representation base + # 2^128, with most significant bit of each byte being 0 denoting + # *last* most significant digit. See "Variable Length Data" in the + # DWARF specification, numbered 7.6 at least in versions 3 and 4. + sub sleb128 { + use integer; # get right shift extend sign + + my $val = shift; + my $sign = ($val < 0) ? -1 : 0; + my @ret = (); + + while(1) { + push @ret, $val&0x7f; + + # see if remaining bits are same and equal to most + # significant bit of the current digit, if so, it's + # last digit... + last if (($val>>6) == $sign); + + @ret[-1] |= 0x80; + $val >>= 7; + } + + return @ret; + } + sub uleb128 { + my $val = shift; + my @ret = (); + + while(1) { + push @ret, $val&0x7f; + + # see if it's last significant digit... + last if (($val >>= 7) == 0); + + @ret[-1] |= 0x80; + } + + return @ret; + } + sub const { + my $val = shift; + + if ($val >= 0 && $val < 32) { + return ($DW_OP_complex{lit0}+$val); + } + return ($DW_OP_complex{consts}, sleb128($val)); + } + sub reg { + my $val = shift; + + return if ($val !~ m/^(%r\w+)(?:([\+\-])((?:0x)?[0-9a-f]+))?/); + + my $reg = $DW_reg_idx{$1}; + my $off = eval ("0 $2 $3"); + + return (($DW_OP_complex{breg0} + $reg), sleb128($off)); + # Yes, we use DW_OP_bregX+0 to push register value and not + # DW_OP_regX, because latter would require even DW_OP_piece, + # which would be a waste under the circumstances. If you have + # to use DWP_OP_reg, use "regx:N"... + } + sub cfa_expression { + my $line = shift; + my @ret; + + foreach my $token (split(/,\s*/,$line)) { + if ($token =~ /^%r/) { + push @ret,reg($token); + } elsif ($token =~ /((?:0x)?[0-9a-f]+)\((%r\w+)\)/) { + push @ret,reg("$2+$1"); + } elsif ($token =~ /(\w+):(\-?(?:0x)?[0-9a-f]+)(U?)/i) { + my $i = 1*eval($2); + push @ret,$DW_OP_complex{$1}, ($3 ? uleb128($i) : sleb128($i)); + } elsif (my $i = 1*eval($token) or $token eq "0") { + if ($token =~ /^\+/) { + push @ret,$DW_OP_complex{plus_uconst},uleb128($i); + } else { + push @ret,const($i); + } + } else { + push @ret,$DW_OP_simple{$token}; + } + } + + # Finally we return DW_CFA_def_cfa_expression, 15, followed by + # length of the expression and of course the expression itself. + return (15,scalar(@ret),@ret); + } + sub re { + my ($class, $line) = @_; + my $self = {}; + my $ret; + + if ($$line =~ s/^\s*\.cfi_(\w+)\s*//) { + bless $self,$class; + $ret = $self; + undef $self->{value}; + my $dir = $1; + + SWITCH: for ($dir) { + # What is $cfa_rsp? Effectively it's difference between %rsp + # value and current CFA, Canonical Frame Address, which is + # why it starts with -8. Recall that CFA is top of caller's + # stack... + /startproc/ && do { ($cfa_reg, $cfa_rsp) = ("%rsp", -8); last; }; + /endproc/ && do { ($cfa_reg, $cfa_rsp) = ("%rsp", 0); last; }; + /def_cfa_register/ + && do { $cfa_reg = $$line; last; }; + /def_cfa_offset/ + && do { $cfa_rsp = -1*eval($$line) if ($cfa_reg eq "%rsp"); + last; + }; + /adjust_cfa_offset/ + && do { $cfa_rsp -= 1*eval($$line) if ($cfa_reg eq "%rsp"); + last; + }; + /def_cfa/ && do { if ($$line =~ /(%r\w+)\s*,\s*(.+)/) { + $cfa_reg = $1; + $cfa_rsp = -1*eval($2) if ($cfa_reg eq "%rsp"); + } + last; + }; + /push/ && do { $dir = undef; + $cfa_rsp -= 8; + if ($cfa_reg eq "%rsp") { + $self->{value} = ".cfi_adjust_cfa_offset\t8\n"; + } + $self->{value} .= ".cfi_offset\t$$line,$cfa_rsp"; + last; + }; + /pop/ && do { $dir = undef; + $cfa_rsp += 8; + if ($cfa_reg eq "%rsp") { + $self->{value} = ".cfi_adjust_cfa_offset\t-8\n"; + } + $self->{value} .= ".cfi_restore\t$$line"; + last; + }; + /cfa_expression/ + && do { $dir = undef; + $self->{value} = ".cfi_escape\t" . + join(",", map(sprintf("0x%02x", $_), + cfa_expression($$line))); + last; + }; + /remember_state/ + && do { push @cfa_stack, [$cfa_reg, $cfa_rsp]; + last; + }; + /restore_state/ + && do { ($cfa_reg, $cfa_rsp) = @{pop @cfa_stack}; + last; + }; + } + + $self->{value} = ".cfi_$dir\t$$line" if ($dir); + + $$line = ""; + } + + return $ret; + } + sub out { + my $self = shift; + return ($elf ? $self->{value} : undef); + } +} +{ package seh_directive; + # This implements directives, like MASM, gas, and clang-assembler for + # specifying Windows unwind codes. See + # https://learn.microsoft.com/en-us/cpp/build/exception-handling-x64?view=msvc-170 + # for details on the Windows unwind mechanism. As perlasm generally uses gas + # syntax, the syntax is patterned after the gas spelling, described in + # https://sourceware.org/legacy-ml/binutils/2009-08/msg00193.html + # + # TODO(https://crbug.com/boringssl/571): Translate to the MASM directives + # when using the MASM output. Emit as-is when using "mingw64" output, which + # is Windows with gas syntax. + # + # TODO(https://crbug.com/boringssl/259): For now, SEH directives are ignored + # on non-Windows platforms. This means functions need to specify both CFI + # and SEH directives, often redundantly. Ideally we'd abstract between the + # two. E.g., we can synthesize CFI from SEH prologues, but SEH does not + # annotate epilogs, so we'd need to combine parts from both. Or we can + # restrict ourselves to a subset of CFI and synthesize SEH from CFI. + # + # Additionally, this only supports @abi-omnipotent functions. It is + # incompatible with the automatic calling convention conversion. The main + # complication is the current scheme modifies RDI and RSI (non-volatile on + # Windows) at the start of the function, and saves them in the parameter + # stack area. This can be expressed with .seh_savereg, but .seh_savereg is + # only usable late in the prologue. However, unwind information gives enough + # information to locate the parameter stack area at any point in the + # function, so we can defer conversion or implement other schemes. + + my $UWOP_PUSH_NONVOL = 0; + my $UWOP_ALLOC_LARGE = 1; + my $UWOP_ALLOC_SMALL = 2; + my $UWOP_SET_FPREG = 3; + my $UWOP_SAVE_NONVOL = 4; + my $UWOP_SAVE_NONVOL_FAR = 5; + my $UWOP_SAVE_XMM128 = 8; + my $UWOP_SAVE_XMM128_FAR = 9; + + my %UWOP_REG_TO_NUMBER = ("%rax" => 0, "%rcx" => 1, "%rdx" => 2, "%rbx" => 3, + "%rsp" => 4, "%rbp" => 5, "%rsi" => 6, "%rdi" => 7, + map(("%r$_" => $_), (8..15))); + my %UWOP_NUMBER_TO_REG = reverse %UWOP_REG_TO_NUMBER; + + # The contents of the pdata and xdata sections so far. + my ($xdata, $pdata) = ("", ""); + + my %info; + + my $next_label = 0; + my $current_label_func = ""; + + # _new_unwind_label allocates a new label, unique to the file. + sub _new_unwind_label { + my ($name) = (@_); + # Labels only need to be unique, but to make diffs easier to read, scope + # them all under the current function. + my $func = $current_function->{name}; + if ($func ne $current_label_func) { + $current_label_func = $func; + $next_label = 0; + } + + my $num = $next_label++; + return ".LSEH_${name}_${func}_${num}"; + } + + sub _check_in_proc { + die "Missing .seh_startproc directive" unless %info; + } + + sub _check_in_prologue { + _check_in_proc(); + die "Invalid SEH directive after .seh_endprologue" if defined($info{endprologue}); + } + + sub _check_not_in_proc { + die "Missing .seh_endproc directive" if %info; + } + + sub _startproc { + _check_not_in_proc(); + if ($current_function->{abi} eq "svr4") { + die "SEH directives can only be used with \@abi-omnipotent"; + } + + my $info_label = _new_unwind_label("info"); + my $start_label = _new_unwind_label("begin"); + %info = ( + # info_label is the label of the function's entry in .xdata. + info_label => $info_label, + # start_label is the start of the function. + start_label => $start_label, + # endprologue is the label of the end of the prologue. + endprologue => undef, + # unwind_codes contains the textual representation of the + # unwind codes in the function so far. + unwind_codes => "", + # num_codes is the number of 16-bit words in unwind_codes. + num_codes => 0, + # frame_reg is the number of the frame register, or zero if + # there is none. + frame_reg => 0, + # frame_offset is the offset into the fixed part of the stack that + # the frame register points into. + frame_offset => 0, + # has_offset is whether directives taking an offset have + # been used. This is used to check that such directives + # come after the fixed portion of the stack frame is established. + has_offset => 0, + # has_nonpushreg is whether directives other than + # .seh_pushreg have been used. This is used to check that + # .seh_pushreg directives are first. + has_nonpushreg => 0, + ); + return $start_label; + } + + sub _add_unwind_code { + my ($op, $value, @extra) = @_; + _check_in_prologue(); + if ($op != $UWOP_PUSH_NONVOL) { + $info{has_nonpushreg} = 1; + } elsif ($info{has_nonpushreg}) { + die ".seh_pushreg directives must appear first in the prologue"; + } + + my $label = _new_unwind_label("prologue"); + # Encode an UNWIND_CODE structure. See + # https://learn.microsoft.com/en-us/cpp/build/exception-handling-x64?view=msvc-170#struct-unwind_code + my $encoded = $op | ($value << 4); + my $codes = <<____; + .byte $label-$info{start_label} + .byte $encoded +____ + # Some opcodes need additional values to encode themselves. + foreach (@extra) { + $codes .= "\t.value\t$_\n"; + } + + $info{num_codes} += 1 + scalar(@extra); + # Unwind codes are listed in reverse order. + $info{unwind_codes} = $codes . $info{unwind_codes}; + return $label; + } + + sub _updating_fixed_allocation { + _check_in_prologue(); + if ($info{frame_reg} != 0) { + # Windows documentation does not explicitly forbid .seh_stackalloc + # after .seh_setframe, but it appears to have no effect. Offsets are + # still relative to the fixed allocation when the frame register was + # established. + die "fixed allocation may not be increased after .seh_setframe"; + } + if ($info{has_offset}) { + # Windows documentation does not explicitly forbid .seh_savereg + # before .seh_stackalloc, but it does not work very well. Offsets + # are relative to the top of the final fixed allocation, not where + # RSP currently is. + die "directives with an offset must come after the fixed allocation is established."; + } + } + + sub _endproc { + _check_in_proc(); + if (!defined($info{endprologue})) { + die "Missing .seh_endprologue"; + } + + my $end_label = _new_unwind_label("end"); + # Encode a RUNTIME_FUNCTION. See + # https://learn.microsoft.com/en-us/cpp/build/exception-handling-x64?view=msvc-170#struct-runtime_function + $pdata .= <<____; + .rva $info{start_label} + .rva $end_label + .rva $info{info_label} + +____ + + # Encode an UNWIND_INFO. See + # https://learn.microsoft.com/en-us/cpp/build/exception-handling-x64?view=msvc-170#struct-unwind_info + my $frame_encoded = $info{frame_reg} | (($info{frame_offset} / 16) << 4); + $xdata .= <<____; +$info{info_label}: + .byte 1 # version 1, no flags + .byte $info{endprologue}-$info{start_label} + .byte $info{num_codes} + .byte $frame_encoded +$info{unwind_codes} +____ + + # UNWIND_INFOs must be 4-byte aligned. If needed, we must add an extra + # unwind code. This does not change the unwind code count. Windows + # documentation says "For alignment purposes, this array always has an + # even number of entries, and the final entry is potentially unused. In + # that case, the array is one longer than indicated by the count of + # unwind codes field." + if ($info{num_codes} & 1) { + $xdata .= "\t.value\t0\n"; + } + + %info = (); + return $end_label; + } + + sub re { + my ($class, $line) = @_; + if ($$line =~ s/^\s*\.seh_(\w+)\s*//) { + my $dir = $1; + if (!$win64) { + $$line = ""; + return; + } + + my $label; + SWITCH: for ($dir) { + /^startproc$/ && do { + $label = _startproc($1); + last; + }; + /^pushreg$/ && do { + $$line =~ /^(%\w+)\s*$/ or die "could not parse .seh_$dir"; + my $reg_num = $UWOP_REG_TO_NUMBER{$1} or die "unknown register $1"; + _updating_fixed_allocation(); + $label = _add_unwind_code($UWOP_PUSH_NONVOL, $reg_num); + last; + }; + /^stackalloc$/ && do { + my $num = eval($$line); + if ($num <= 0 || $num % 8 != 0) { + die "invalid stack allocation: $num"; + } + _updating_fixed_allocation(); + if ($num <= 128) { + $label = _add_unwind_code($UWOP_ALLOC_SMALL, ($num - 8) / 8); + } elsif ($num < 512 * 1024) { + $label = _add_unwind_code($UWOP_ALLOC_LARGE, 0, $num / 8); + } elsif ($num < 4 * 1024 * 1024 * 1024) { + $label = _add_unwind_code($UWOP_ALLOC_LARGE, 1, $num >> 16, $num & 0xffff); + } else { + die "stack allocation too large: $num" + } + last; + }; + /^setframe$/ && do { + if ($info{frame_reg} != 0) { + die "duplicate .seh_setframe directive"; + } + if ($info{has_offset}) { + die "directives with with an offset must come after .seh_setframe."; + } + $$line =~ /(%\w+)\s*,\s*(.+)/ or die "could not parse .seh_$dir"; + my $reg_num = $UWOP_REG_TO_NUMBER{$1} or die "unknown register $1"; + my $offset = eval($2); + if ($offset < 0 || $offset % 16 != 0 || $offset > 240) { + die "invalid offset: $offset"; + } + $info{frame_reg} = $reg_num; + $info{frame_offset} = $offset; + $label = _add_unwind_code($UWOP_SET_FPREG, 0); + last; + }; + /^savereg$/ && do { + $$line =~ /(%\w+)\s*,\s*(.+)/ or die "could not parse .seh_$dir"; + my $reg_num = $UWOP_REG_TO_NUMBER{$1} or die "unknown register $1"; + my $offset = eval($2); + if ($offset < 0 || $offset % 8 != 0) { + die "invalid offset: $offset"; + } + if ($offset < 8 * 65536) { + $label = _add_unwind_code($UWOP_SAVE_NONVOL, $reg_num, $offset / 8); + } else { + $label = _add_unwind_code($UWOP_SAVE_NONVOL_FAR, $reg_num, $offset >> 16, $offset & 0xffff); + } + $info{has_offset} = 1; + last; + }; + /^savexmm$/ && do { + $$line =~ /%xmm(\d+)\s*,\s*(.+)/ or die "could not parse .seh_$dir"; + my $reg_num = $1; + my $offset = eval($2); + if ($offset < 0 || $offset % 16 != 0) { + die "invalid offset: $offset"; + } + if ($offset < 16 * 65536) { + $label = _add_unwind_code($UWOP_SAVE_XMM128, $reg_num, $offset / 16); + } else { + $label = _add_unwind_code($UWOP_SAVE_XMM128_FAR, $reg_num, $offset >> 16, $offset & 0xffff); + } + $info{has_offset} = 1; + last; + }; + /^endprologue$/ && do { + _check_in_prologue(); + if ($info{num_codes} == 0) { + # If a Windows function has no directives (i.e. it + # doesn't touch the stack), it is a leaf function and is + # not expected to appear in .pdata or .xdata. + die ".seh_endprologue found with no unwind codes"; + } + + $label = _new_unwind_label("endprologue"); + $info{endprologue} = $label; + last; + }; + /^endproc$/ && do { + $label = _endproc(); + last; + }; + die "unknown SEH directive .seh_$dir"; + } + + # All SEH directives compile to labels inline. The other data is + # emitted later. + $$line = ""; + $label .= ":"; + return label->re(\$label); + } + } + + sub pdata_and_xdata { + return "" unless $win64; + + my $ret = ""; + if ($pdata ne "") { + $ret .= <<____; +.section .pdata +.align 4 +$pdata +____ + } + if ($xdata ne "") { + $ret .= <<____; +.section .xdata +.align 4 +$xdata +____ + } + return $ret; + } +} +{ package directive; # pick up directives, which start with . + my %sections; + sub nasm_section { + my ($name, $qualifiers) = @_; + my $ret = "section\t$name"; + if (exists $sections{$name}) { + # Work around https://bugzilla.nasm.us/show_bug.cgi?id=3392701. Only + # emit section qualifiers the first time a section is referenced. + # For all subsequent references, require the qualifiers match and + # omit them. + # + # See also https://crbug.com/1422018 and b/270643835. + my $old = $sections{$name}; + die "Inconsistent qualifiers: $qualifiers vs $old" if ($qualifiers ne "" && $qualifiers ne $old); + } else { + $sections{$name} = $qualifiers; + if ($qualifiers ne "") { + $ret .= " $qualifiers"; + } + } + return $ret; + } + sub re { + my ($class, $line) = @_; + my $self = {}; + my $ret; + my $dir; + + # chain-call to cfi_directive and seh_directive. + $ret = cfi_directive->re($line) and return $ret; + $ret = seh_directive->re($line) and return $ret; + + if ($$line =~ /^\s*(\.\w+)/) { + bless $self,$class; + $dir = $1; + $ret = $self; + undef $self->{value}; + $$line = substr($$line,@+[0]); $$line =~ s/^\s+//; + + SWITCH: for ($dir) { + /\.global|\.globl|\.extern/ + && do { $globals{$$line} = $prefix . $$line; + $$line = $globals{$$line} if ($prefix); + last; + }; + /\.type/ && do { my ($sym,$type,$narg) = split(/\s*,\s*/,$$line); + if ($type eq "\@function") { + undef $current_function; + $current_function->{name} = $sym; + $current_function->{abi} = "svr4"; + $current_function->{narg} = $narg; + $current_function->{scope} = defined($globals{$sym})?"PUBLIC":"PRIVATE"; + } elsif ($type eq "\@abi-omnipotent") { + undef $current_function; + $current_function->{name} = $sym; + $current_function->{scope} = defined($globals{$sym})?"PUBLIC":"PRIVATE"; + } + $$line =~ s/\@abi\-omnipotent/\@function/; + $$line =~ s/\@function.*/\@function/; + last; + }; + /\.asciz/ && do { if ($$line =~ /^"(.*)"$/) { + $dir = ".byte"; + $$line = join(",",unpack("C*",$1),0); + } + last; + }; + /\.rva|\.long|\.quad|\.byte/ + && do { $$line =~ s/([_a-z][_a-z0-9]*)/$globals{$1} or $1/gei; + $$line =~ s/\.L/$decor/g; + last; + }; + } + + if ($gas) { + $self->{value} = $dir . "\t" . $$line; + + if ($dir =~ /\.extern/) { + if ($flavour eq "elf") { + $self->{value} .= "\n.hidden $$line"; + } else { + $self->{value} = ""; + } + } elsif (!$elf && $dir =~ /\.type/) { + $self->{value} = ""; + $self->{value} = ".def\t" . ($globals{$1} or $1) . ";\t" . + (defined($globals{$1})?".scl 2;":".scl 3;") . + "\t.type 32;\t.endef" + if ($win64 && $$line =~ /([^,]+),\@function/); + } elsif (!$elf && $dir =~ /\.size/) { + $self->{value} = ""; + if (defined($current_function)) { + $self->{value} .= "${decor}SEH_end_$current_function->{name}:" + if ($win64 && $current_function->{abi} eq "svr4"); + undef $current_function; + } + } elsif (!$elf && $dir =~ /\.align/) { + $self->{value} = ".p2align\t" . (log($$line)/log(2)); + } elsif ($dir eq ".section") { + $current_segment=$$line; + if (!$elf && $current_segment eq ".rodata") { + if ($flavour eq "macosx") { $self->{value} = ".section\t__DATA,__const"; } + } + if (!$elf && $current_segment eq ".init") { + if ($flavour eq "macosx") { $self->{value} = ".mod_init_func"; } + elsif ($flavour eq "mingw64") { $self->{value} = ".section\t.ctors"; } + } + } elsif ($dir =~ /\.(text|data)/) { + $current_segment=".$1"; + } elsif ($dir =~ /\.global|\.globl|\.extern/) { + if ($flavour eq "macosx") { + $self->{value} .= "\n.private_extern $$line"; + } else { + $self->{value} .= "\n.hidden $$line"; + } + } elsif ($dir =~ /\.hidden/) { + if ($flavour eq "macosx") { $self->{value} = ".private_extern\t$prefix$$line"; } + elsif ($flavour eq "mingw64") { $self->{value} = ""; } + } elsif ($dir =~ /\.comm/) { + $self->{value} = "$dir\t$prefix$$line"; + $self->{value} =~ s|,([0-9]+),([0-9]+)$|",$1,".log($2)/log(2)|e if ($flavour eq "macosx"); + } + $$line = ""; + return $self; + } + + # non-gas case or nasm/masm + SWITCH: for ($dir) { + /\.text/ && do { my $v=undef; + if ($nasm) { + $v=nasm_section(".text", "code align=64")."\n"; + } else { + $v="$current_segment\tENDS\n" if ($current_segment); + $current_segment = ".text\$"; + $v.="$current_segment\tSEGMENT "; + $v.=$masm>=$masmref ? "ALIGN(256)" : "PAGE"; + $v.=" 'CODE'"; + } + $self->{value} = $v; + last; + }; + /\.data/ && do { my $v=undef; + if ($nasm) { + $v=nasm_section(".data", "data align=8")."\n"; + } else { + $v="$current_segment\tENDS\n" if ($current_segment); + $current_segment = "_DATA"; + $v.="$current_segment\tSEGMENT"; + } + $self->{value} = $v; + last; + }; + /\.section/ && do { my $v=undef; + $$line =~ s/([^,]*).*/$1/; + $$line = ".CRT\$XCU" if ($$line eq ".init"); + $$line = ".rdata" if ($$line eq ".rodata"); + if ($nasm) { + my $qualifiers = ""; + if ($$line=~/\.([prx])data/) { + $qualifiers = "rdata align="; + $qualifiers .= $1 eq "p"? 4 : 8; + } elsif ($$line=~/\.CRT\$/i) { + $qualifiers = "rdata align=8"; + } + $v = nasm_section($$line, $qualifiers); + } else { + $v="$current_segment\tENDS\n" if ($current_segment); + $v.="$$line\tSEGMENT"; + if ($$line=~/\.([prx])data/) { + $v.=" READONLY"; + $v.=" ALIGN(".($1 eq "p" ? 4 : 8).")" if ($masm>=$masmref); + } elsif ($$line=~/\.CRT\$/i) { + $v.=" READONLY "; + $v.=$masm>=$masmref ? "ALIGN(8)" : "DWORD"; + } + } + $current_segment = $$line; + $self->{value} = $v; + last; + }; + /\.extern/ && do { $self->{value} = "EXTERN\t".$$line; + $self->{value} .= ":NEAR" if ($masm); + last; + }; + /\.globl|.global/ + && do { $self->{value} = $masm?"PUBLIC":"global"; + $self->{value} .= "\t".$$line; + last; + }; + /\.size/ && do { if (defined($current_function)) { + undef $self->{value}; + if ($current_function->{abi} eq "svr4") { + $self->{value}="${decor}SEH_end_$current_function->{name}:"; + $self->{value}.=":\n" if($masm); + } + $self->{value}.="$current_function->{name}\tENDP" if($masm && $current_function->{name}); + undef $current_function; + } + last; + }; + /\.align/ && do { my $max = ($masm && $masm>=$masmref) ? 256 : 4096; + $self->{value} = "ALIGN\t".($$line>$max?$max:$$line); + last; + }; + /\.(value|long|rva|quad)/ + && do { my $sz = substr($1,0,1); + my @arr = split(/,\s*/,$$line); + my $last = pop(@arr); + my $conv = sub { my $var=shift; + $var=~s/^(0b[0-1]+)/oct($1)/eig; + $var=~s/^0x([0-9a-f]+)/0$1h/ig if ($masm); + if ($sz eq "D" && ($current_segment=~/.[px]data/ || $dir eq ".rva")) + { $var=~s/^([_a-z\$\@][_a-z0-9\$\@]*)/$nasm?"$1 wrt ..imagebase":"imagerel $1"/egi; } + $var; + }; + + $sz =~ tr/bvlrq/BWDDQ/; + $self->{value} = "\tD$sz\t"; + for (@arr) { $self->{value} .= &$conv($_).","; } + $self->{value} .= &$conv($last); + last; + }; + /\.byte/ && do { my @str=split(/,\s*/,$$line); + map(s/(0b[0-1]+)/oct($1)/eig,@str); + map(s/0x([0-9a-f]+)/0$1h/ig,@str) if ($masm); + while ($#str>15) { + $self->{value}.="\tDB\t" + .join(",",@str[0..15])."\n"; + foreach (0..15) { shift @str; } + } + $self->{value}.="\tDB\t" + .join(",",@str) if (@str); + last; + }; + /\.comm/ && do { my @str=split(/,\s*/,$$line); + my $v=undef; + if ($nasm) { + $v.="common $prefix@str[0] @str[1]"; + } else { + $v="$current_segment\tENDS\n" if ($current_segment); + $current_segment = "_DATA"; + $v.="$current_segment\tSEGMENT\n"; + $v.="COMM @str[0]:DWORD:".@str[1]/4; + } + $self->{value} = $v; + last; + }; + } + $$line = ""; + } + + $ret; + } + sub out { + my $self = shift; + $self->{value}; + } +} + +# Upon initial x86_64 introduction SSE>2 extensions were not introduced +# yet. In order not to be bothered by tracing exact assembler versions, +# but at the same time to provide a bare security minimum of AES-NI, we +# hard-code some instructions. Extensions past AES-NI on the other hand +# are traced by examining assembler version in individual perlasm +# modules... + +my %regrm = ( "%eax"=>0, "%ecx"=>1, "%edx"=>2, "%ebx"=>3, + "%esp"=>4, "%ebp"=>5, "%esi"=>6, "%edi"=>7 ); + +sub rex { + my $opcode=shift; + my ($dst,$src,$rex)=@_; + + $rex|=0x04 if($dst>=8); + $rex|=0x01 if($src>=8); + push @$opcode,($rex|0x40) if ($rex); +} + +my $movq = sub { # elderly gas can't handle inter-register movq + my $arg = shift; + my @opcode=(0x66); + if ($arg =~ /%xmm([0-9]+),\s*%r(\w+)/) { + my ($src,$dst)=($1,$2); + if ($dst !~ /[0-9]+/) { $dst = $regrm{"%e$dst"}; } + rex(\@opcode,$src,$dst,0x8); + push @opcode,0x0f,0x7e; + push @opcode,0xc0|(($src&7)<<3)|($dst&7); # ModR/M + @opcode; + } elsif ($arg =~ /%r(\w+),\s*%xmm([0-9]+)/) { + my ($src,$dst)=($2,$1); + if ($dst !~ /[0-9]+/) { $dst = $regrm{"%e$dst"}; } + rex(\@opcode,$src,$dst,0x8); + push @opcode,0x0f,0x6e; + push @opcode,0xc0|(($src&7)<<3)|($dst&7); # ModR/M + @opcode; + } else { + (); + } +}; + +my $pextrd = sub { + if (shift =~ /\$([0-9]+),\s*%xmm([0-9]+),\s*(%\w+)/) { + my @opcode=(0x66); + my $imm=$1; + my $src=$2; + my $dst=$3; + if ($dst =~ /%r([0-9]+)d/) { $dst = $1; } + elsif ($dst =~ /%e/) { $dst = $regrm{$dst}; } + rex(\@opcode,$src,$dst); + push @opcode,0x0f,0x3a,0x16; + push @opcode,0xc0|(($src&7)<<3)|($dst&7); # ModR/M + push @opcode,$imm; + @opcode; + } else { + (); + } +}; + +my $pinsrd = sub { + if (shift =~ /\$([0-9]+),\s*(%\w+),\s*%xmm([0-9]+)/) { + my @opcode=(0x66); + my $imm=$1; + my $src=$2; + my $dst=$3; + if ($src =~ /%r([0-9]+)/) { $src = $1; } + elsif ($src =~ /%e/) { $src = $regrm{$src}; } + rex(\@opcode,$dst,$src); + push @opcode,0x0f,0x3a,0x22; + push @opcode,0xc0|(($dst&7)<<3)|($src&7); # ModR/M + push @opcode,$imm; + @opcode; + } else { + (); + } +}; + +my $pshufb = sub { + if (shift =~ /%xmm([0-9]+),\s*%xmm([0-9]+)/) { + my @opcode=(0x66); + rex(\@opcode,$2,$1); + push @opcode,0x0f,0x38,0x00; + push @opcode,0xc0|($1&7)|(($2&7)<<3); # ModR/M + @opcode; + } else { + (); + } +}; + +my $palignr = sub { + if (shift =~ /\$([0-9]+),\s*%xmm([0-9]+),\s*%xmm([0-9]+)/) { + my @opcode=(0x66); + rex(\@opcode,$3,$2); + push @opcode,0x0f,0x3a,0x0f; + push @opcode,0xc0|($2&7)|(($3&7)<<3); # ModR/M + push @opcode,$1; + @opcode; + } else { + (); + } +}; + +my $pclmulqdq = sub { + if (shift =~ /\$([x0-9a-f]+),\s*%xmm([0-9]+),\s*%xmm([0-9]+)/) { + my @opcode=(0x66); + rex(\@opcode,$3,$2); + push @opcode,0x0f,0x3a,0x44; + push @opcode,0xc0|($2&7)|(($3&7)<<3); # ModR/M + my $c=$1; + push @opcode,$c=~/^0/?oct($c):$c; + @opcode; + } else { + (); + } +}; + +my $rdrand = sub { + if (shift =~ /%[er](\w+)/) { + my @opcode=(); + my $dst=$1; + if ($dst !~ /[0-9]+/) { $dst = $regrm{"%e$dst"}; } + rex(\@opcode,0,$dst,8); + push @opcode,0x0f,0xc7,0xf0|($dst&7); + @opcode; + } else { + (); + } +}; + +my $rdseed = sub { + if (shift =~ /%[er](\w+)/) { + my @opcode=(); + my $dst=$1; + if ($dst !~ /[0-9]+/) { $dst = $regrm{"%e$dst"}; } + rex(\@opcode,0,$dst,8); + push @opcode,0x0f,0xc7,0xf8|($dst&7); + @opcode; + } else { + (); + } +}; + +# Not all AVX-capable assemblers recognize AMD XOP extension. Since we +# are using only two instructions hand-code them in order to be excused +# from chasing assembler versions... + +sub rxb { + my $opcode=shift; + my ($dst,$src1,$src2,$rxb)=@_; + + $rxb|=0x7<<5; + $rxb&=~(0x04<<5) if($dst>=8); + $rxb&=~(0x01<<5) if($src1>=8); + $rxb&=~(0x02<<5) if($src2>=8); + push @$opcode,$rxb; +} + +my $vprotd = sub { + if (shift =~ /\$([x0-9a-f]+),\s*%xmm([0-9]+),\s*%xmm([0-9]+)/) { + my @opcode=(0x8f); + rxb(\@opcode,$3,$2,-1,0x08); + push @opcode,0x78,0xc2; + push @opcode,0xc0|($2&7)|(($3&7)<<3); # ModR/M + my $c=$1; + push @opcode,$c=~/^0/?oct($c):$c; + @opcode; + } else { + (); + } +}; + +my $vprotq = sub { + if (shift =~ /\$([x0-9a-f]+),\s*%xmm([0-9]+),\s*%xmm([0-9]+)/) { + my @opcode=(0x8f); + rxb(\@opcode,$3,$2,-1,0x08); + push @opcode,0x78,0xc3; + push @opcode,0xc0|($2&7)|(($3&7)<<3); # ModR/M + my $c=$1; + push @opcode,$c=~/^0/?oct($c):$c; + @opcode; + } else { + (); + } +}; + +# Intel Control-flow Enforcement Technology extension. All functions and +# indirect branch targets will have to start with this instruction... + +my $endbranch = sub { + (0xf3,0x0f,0x1e,0xfa); +}; + +######################################################################## + +{ + my $comment = "//"; + $comment = ";" if ($masm || $nasm); + print <<___; +$comment This file is generated from a similarly-named Perl script in the BoringSSL +$comment source tree. Do not edit by hand. + +___ +} + +if ($nasm) { + die "unknown target" unless ($win64); + print <<___; +\%ifidn __OUTPUT_FORMAT__, win64 +default rel +\%define XMMWORD +\%define YMMWORD +\%define ZMMWORD +\%define _CET_ENDBR + +\%include "ring_core_generated/prefix_symbols_nasm.inc" +___ +} elsif ($masm) { + print <<___; +OPTION DOTNAME +___ +} + +if ($gas) { + my $target; + if ($elf) { + # The "elf" target is really ELF with SysV ABI, but every ELF platform + # uses the SysV ABI. + $target = "defined(__ELF__)"; + } elsif ($apple) { + $target = "defined(__APPLE__)"; + } else { + die "unknown target: $flavour"; + } + print <<___; +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && $target +___ +} + +sub process_line { + my $line = shift; + $line =~ s|\R$||; # Better chomp + + if ($nasm) { + $line =~ s|^#ifdef |%ifdef |; + $line =~ s|^#ifndef |%ifndef |; + $line =~ s|^#endif|%endif|; + $line =~ s|[#!].*$||; # get rid of asm-style comments... + } else { + # Get rid of asm-style comments but not preprocessor directives. The + # former are identified by having a letter after the '#' and starting in + # the first column. + $line =~ s|!.*$||; + $line =~ s|(?<=.)#.*$||; + $line =~ s|^#([^a-z].*)?$||; + } + + $line =~ s|/\*.*\*/||; # ... and C-style comments... + $line =~ s|^\s+||; # ... and skip white spaces in beginning + $line =~ s|\s+$||; # ... and at the end + + if (my $label=label->re(\$line)) { print $label->out(); } + + if (my $directive=directive->re(\$line)) { + printf "%s",$directive->out(); + } elsif (my $opcode=opcode->re(\$line)) { + my $asm = eval("\$".$opcode->mnemonic()); + + if ((ref($asm) eq 'CODE') && scalar(my @bytes=&$asm($line))) { + print $gas?".byte\t":"DB\t",join(',',@bytes),"\n"; + next; + } + + my @args; + ARGUMENT: while (1) { + my $arg; + + ($arg=register->re(\$line, $opcode))|| + ($arg=const->re(\$line)) || + ($arg=ea->re(\$line, $opcode)) || + ($arg=expr->re(\$line, $opcode)) || + last ARGUMENT; + + push @args,$arg; + + last ARGUMENT if ($line !~ /^,/); + + $line =~ s/^,\s*//; + } # ARGUMENT: + + if ($#args>=0) { + my $insn; + my $sz=$opcode->size(); + + if ($gas) { + $insn = $opcode->out($#args>=1?$args[$#args]->size():$sz); + @args = map($_->out($sz),@args); + printf "\t%s\t%s",$insn,join(",",@args); + } else { + $insn = $opcode->out(); + foreach (@args) { + my $arg = $_->out(); + # $insn.=$sz compensates for movq, pinsrw, ... + if ($arg =~ /^xmm[0-9]+$/) { $insn.=$sz; $sz="x" if(!$sz); last; } + if ($arg =~ /^ymm[0-9]+$/) { $insn.=$sz; $sz="y" if(!$sz); last; } + if ($arg =~ /^zmm[0-9]+$/) { $insn.=$sz; $sz="z" if(!$sz); last; } + if ($arg =~ /^mm[0-9]+$/) { $insn.=$sz; $sz="q" if(!$sz); last; } + } + @args = reverse(@args); + undef $sz if ($nasm && $opcode->mnemonic() eq "lea"); + printf "\t%s\t%s",$insn,join(",",map($_->out($sz),@args)); + } + } else { + printf "\t%s",$opcode->out(); + } + } + + print $line,"\n"; +} + +while(defined(my $line=<>)) { + process_line($line); +} +foreach my $line (split(/\n/, seh_directive->pdata_and_xdata())) { + process_line($line); +} + +print "\n$current_segment\tENDS\n" if ($current_segment && $masm); +if ($masm) { + print "END\n"; +} elsif ($gas) { + print "#endif\n"; +} elsif ($nasm) { + print <<___; +\%else +; Work around https://bugzilla.nasm.us/show_bug.cgi?id=3392738 +ret +\%endif +___ +} else { + die "unknown assembler"; +} + +close STDOUT or die "error closing STDOUT: $!"; + + ################################################# +# Cross-reference x86_64 ABI "card" +# +# Unix Win64 +# %rax * * +# %rbx - - +# %rcx #4 #1 +# %rdx #3 #2 +# %rsi #2 - +# %rdi #1 - +# %rbp - - +# %rsp - - +# %r8 #5 #3 +# %r9 #6 #4 +# %r10 * * +# %r11 * * +# %r12 - - +# %r13 - - +# %r14 - - +# %r15 - - +# +# (*) volatile register +# (-) preserved by callee +# (#) Nth argument, volatile +# +# In Unix terms top of stack is argument transfer area for arguments +# which could not be accommodated in registers. Or in other words 7th +# [integer] argument resides at 8(%rsp) upon function entry point. +# 128 bytes above %rsp constitute a "red zone" which is not touched +# by signal handlers and can be used as temporal storage without +# allocating a frame. +# +# In Win64 terms N*8 bytes on top of stack is argument transfer area, +# which belongs to/can be overwritten by callee. N is the number of +# arguments passed to callee, *but* not less than 4! This means that +# upon function entry point 5th argument resides at 40(%rsp), as well +# as that 32 bytes from 8(%rsp) can always be used as temporal +# storage [without allocating a frame]. One can actually argue that +# one can assume a "red zone" above stack pointer under Win64 as well. +# Point is that at apparently no occasion Windows kernel would alter +# the area above user stack pointer in true asynchronous manner... +# +# All the above means that if assembler programmer adheres to Unix +# register and stack layout, but disregards the "red zone" existence, +# it's possible to use following prologue and epilogue to "gear" from +# Unix to Win64 ABI in leaf functions with not more than 6 arguments. +# +# omnipotent_function: +# ifdef WIN64 +# movq %rdi,8(%rsp) +# movq %rsi,16(%rsp) +# movq %rcx,%rdi ; if 1st argument is actually present +# movq %rdx,%rsi ; if 2nd argument is actually ... +# movq %r8,%rdx ; if 3rd argument is ... +# movq %r9,%rcx ; if 4th argument ... +# movq 40(%rsp),%r8 ; if 5th ... +# movq 48(%rsp),%r9 ; if 6th ... +# endif +# ... +# ifdef WIN64 +# movq 8(%rsp),%rdi +# movq 16(%rsp),%rsi +# endif +# ret +# + ################################################# +# Win64 SEH, Structured Exception Handling. +# +# Unlike on Unix systems(*) lack of Win64 stack unwinding information +# has undesired side-effect at run-time: if an exception is raised in +# assembler subroutine such as those in question (basically we're +# referring to segmentation violations caused by malformed input +# parameters), the application is briskly terminated without invoking +# any exception handlers, most notably without generating memory dump +# or any user notification whatsoever. This poses a problem. It's +# possible to address it by registering custom language-specific +# handler that would restore processor context to the state at +# subroutine entry point and return "exception is not handled, keep +# unwinding" code. Writing such handler can be a challenge... But it's +# doable, though requires certain coding convention. Consider following +# snippet: +# +# .type function,@function +# function: +# movq %rsp,%rax # copy rsp to volatile register +# pushq %r15 # save non-volatile registers +# pushq %rbx +# pushq %rbp +# movq %rsp,%r11 +# subq %rdi,%r11 # prepare [variable] stack frame +# andq $-64,%r11 +# movq %rax,0(%r11) # check for exceptions +# movq %r11,%rsp # allocate [variable] stack frame +# movq %rax,0(%rsp) # save original rsp value +# magic_point: +# ... +# movq 0(%rsp),%rcx # pull original rsp value +# movq -24(%rcx),%rbp # restore non-volatile registers +# movq -16(%rcx),%rbx +# movq -8(%rcx),%r15 +# movq %rcx,%rsp # restore original rsp +# magic_epilogue: +# ret +# .size function,.-function +# +# The key is that up to magic_point copy of original rsp value remains +# in chosen volatile register and no non-volatile register, except for +# rsp, is modified. While past magic_point rsp remains constant till +# the very end of the function. In this case custom language-specific +# exception handler would look like this: +# +# EXCEPTION_DISPOSITION handler (EXCEPTION_RECORD *rec,ULONG64 frame, +# CONTEXT *context,DISPATCHER_CONTEXT *disp) +# { ULONG64 *rsp = (ULONG64 *)context->Rax; +# ULONG64 rip = context->Rip; +# +# if (rip >= magic_point) +# { rsp = (ULONG64 *)context->Rsp; +# if (rip < magic_epilogue) +# { rsp = (ULONG64 *)rsp[0]; +# context->Rbp = rsp[-3]; +# context->Rbx = rsp[-2]; +# context->R15 = rsp[-1]; +# } +# } +# context->Rsp = (ULONG64)rsp; +# context->Rdi = rsp[1]; +# context->Rsi = rsp[2]; +# +# memcpy (disp->ContextRecord,context,sizeof(CONTEXT)); +# RtlVirtualUnwind(UNW_FLAG_NHANDLER,disp->ImageBase, +# dips->ControlPc,disp->FunctionEntry,disp->ContextRecord, +# &disp->HandlerData,&disp->EstablisherFrame,NULL); +# return ExceptionContinueSearch; +# } +# +# It's appropriate to implement this handler in assembler, directly in +# function's module. In order to do that one has to know members' +# offsets in CONTEXT and DISPATCHER_CONTEXT structures and some constant +# values. Here they are: +# +# CONTEXT.Rax 120 +# CONTEXT.Rcx 128 +# CONTEXT.Rdx 136 +# CONTEXT.Rbx 144 +# CONTEXT.Rsp 152 +# CONTEXT.Rbp 160 +# CONTEXT.Rsi 168 +# CONTEXT.Rdi 176 +# CONTEXT.R8 184 +# CONTEXT.R9 192 +# CONTEXT.R10 200 +# CONTEXT.R11 208 +# CONTEXT.R12 216 +# CONTEXT.R13 224 +# CONTEXT.R14 232 +# CONTEXT.R15 240 +# CONTEXT.Rip 248 +# CONTEXT.Xmm6 512 +# sizeof(CONTEXT) 1232 +# DISPATCHER_CONTEXT.ControlPc 0 +# DISPATCHER_CONTEXT.ImageBase 8 +# DISPATCHER_CONTEXT.FunctionEntry 16 +# DISPATCHER_CONTEXT.EstablisherFrame 24 +# DISPATCHER_CONTEXT.TargetIp 32 +# DISPATCHER_CONTEXT.ContextRecord 40 +# DISPATCHER_CONTEXT.LanguageHandler 48 +# DISPATCHER_CONTEXT.HandlerData 56 +# UNW_FLAG_NHANDLER 0 +# ExceptionContinueSearch 1 +# +# In order to tie the handler to the function one has to compose +# couple of structures: one for .xdata segment and one for .pdata. +# +# UNWIND_INFO structure for .xdata segment would be +# +# function_unwind_info: +# .byte 9,0,0,0 +# .rva handler +# +# This structure designates exception handler for a function with +# zero-length prologue, no stack frame or frame register. +# +# To facilitate composing of .pdata structures, auto-generated "gear" +# prologue copies rsp value to rax and denotes next instruction with +# .LSEH_begin_{function_name} label. This essentially defines the SEH +# styling rule mentioned in the beginning. Position of this label is +# chosen in such manner that possible exceptions raised in the "gear" +# prologue would be accounted to caller and unwound from latter's frame. +# End of function is marked with respective .LSEH_end_{function_name} +# label. To summarize, .pdata segment would contain +# +# .rva .LSEH_begin_function +# .rva .LSEH_end_function +# .rva function_unwind_info +# +# Reference to function_unwind_info from .xdata segment is the anchor. +# In case you wonder why references are 32-bit .rvas and not 64-bit +# .quads. References put into these two segments are required to be +# *relative* to the base address of the current binary module, a.k.a. +# image base. No Win64 module, be it .exe or .dll, can be larger than +# 2GB and thus such relative references can be and are accommodated in +# 32 bits. +# +# Having reviewed the example function code, one can argue that "movq +# %rsp,%rax" above is redundant. It is not! Keep in mind that on Unix +# rax would contain an undefined value. If this "offends" you, use +# another register and refrain from modifying rax till magic_point is +# reached, i.e. as if it was a non-volatile register. If more registers +# are required prior [variable] frame setup is completed, note that +# nobody says that you can have only one "magic point." You can +# "liberate" non-volatile registers by denoting last stack off-load +# instruction and reflecting it in finer grade unwind logic in handler. +# After all, isn't it why it's called *language-specific* handler... +# +# SE handlers are also involved in unwinding stack when executable is +# profiled or debugged. Profiling implies additional limitations that +# are too subtle to discuss here. For now it's sufficient to say that +# in order to simplify handlers one should either a) offload original +# %rsp to stack (like discussed above); or b) if you have a register to +# spare for frame pointer, choose volatile one. +# +# (*) Note that we're talking about run-time, not debug-time. Lack of +# unwind information makes debugging hard on both Windows and +# Unix. "Unlike" refers to the fact that on Unix signal handler +# will always be invoked, core dumped and appropriate exit code +# returned to parent (for user notification). diff --git a/http/vendor/ring/crypto/perlasm/x86asm.pl b/http/vendor/ring/crypto/perlasm/x86asm.pl new file mode 100644 index 0000000..7b685e0 --- /dev/null +++ b/http/vendor/ring/crypto/perlasm/x86asm.pl @@ -0,0 +1,368 @@ +#! /usr/bin/env perl +# Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# require 'x86asm.pl'; +# &asm_init([,$i386only]); +# &function_begin("foo"); +# ... +# &function_end("foo"); +# &asm_finish + +$out=(); +$i386=0; + +# AUTOLOAD is this context has quite unpleasant side effect, namely +# that typos in function calls effectively go to assembler output, +# but on the pros side we don't have to implement one subroutine per +# each opcode... +sub ::AUTOLOAD +{ my $opcode = $AUTOLOAD; + + die "more than 4 arguments passed to $opcode" if ($#_>3); + + $opcode =~ s/.*:://; + if ($opcode =~ /^push/) { $stack+=4; } + elsif ($opcode =~ /^pop/) { $stack-=4; } + + &generic($opcode,@_) or die "undefined subroutine \&$AUTOLOAD"; +} + +# record_function_hit(int) writes a byte with value one to the given offset of +# |BORINGSSL_function_hit|, but only if BORINGSSL_DISPATCH_TEST is defined. +# This is used in impl_dispatch_test.cc to test whether the expected assembly +# functions are triggered by high-level API calls. +sub ::record_function_hit +{ my($index)=@_; + &preprocessor_ifdef("BORINGSSL_DISPATCH_TEST"); + &push("ebx"); + &push("edx"); + &call(&label("pic_for_function_hit")); + &set_label("pic_for_function_hit"); + &blindpop("ebx"); + &lea("ebx",&DWP("BORINGSSL_function_hit+$index"."-".&label("pic_for_function_hit"),"ebx")); + &mov("edx", 1); + &movb(&BP(0, "ebx"), "dl"); + &pop("edx"); + &pop("ebx"); + &preprocessor_endif(); +} + +sub ::emit +{ my $opcode=shift; + + if ($#_==-1) { push(@out,"\t$opcode\n"); } + else { push(@out,"\t$opcode\t".join(',',@_)."\n"); } +} + +sub ::LB +{ $_[0] =~ m/^e?([a-d])x$/o or die "$_[0] does not have a 'low byte'"; + $1."l"; +} +sub ::HB +{ $_[0] =~ m/^e?([a-d])x$/o or die "$_[0] does not have a 'high byte'"; + $1."h"; +} +sub ::stack_push{ my $num=$_[0]*4; $stack+=$num; &sub("esp",$num); } +sub ::stack_pop { my $num=$_[0]*4; $stack-=$num; &add("esp",$num); } +sub ::blindpop { &pop($_[0]); $stack+=4; } +sub ::wparam { &DWP($stack+4*$_[0],"esp"); } +sub ::swtmp { &DWP(4*$_[0],"esp"); } + +sub ::bswap +{ if ($i386) # emulate bswap for i386 + { &comment("bswap @_"); + &xchg(&HB(@_),&LB(@_)); + &ror (@_,16); + &xchg(&HB(@_),&LB(@_)); + } + else + { &generic("bswap",@_); } +} +# These are made-up opcodes introduced over the years essentially +# by ignorance, just alias them to real ones... +sub ::movb { &mov(@_); } +sub ::xorb { &xor(@_); } +sub ::rotl { &rol(@_); } +sub ::rotr { &ror(@_); } +sub ::exch { &xchg(@_); } +sub ::halt { &hlt; } +sub ::movz { &movzx(@_); } +sub ::pushf { &pushfd; } +sub ::popf { &popfd; } + +# 3 argument instructions +sub ::movq +{ my($p1,$p2,$optimize)=@_; + + if ($optimize && $p1=~/^mm[0-7]$/ && $p2=~/^mm[0-7]$/) + # movq between mmx registers can sink Intel CPUs + { &::pshufw($p1,$p2,0xe4); } + else + { &::generic("movq",@_); } +} + +# SSE>2 instructions +my %regrm = ( "eax"=>0, "ecx"=>1, "edx"=>2, "ebx"=>3, + "esp"=>4, "ebp"=>5, "esi"=>6, "edi"=>7 ); +sub ::pextrd +{ my($dst,$src,$imm)=@_; + if ("$dst:$src" =~ /(e[a-dsd][ixp]):xmm([0-7])/) + { &::data_byte(0x66,0x0f,0x3a,0x16,0xc0|($2<<3)|$regrm{$1},$imm); } + else + { &::generic("pextrd",@_); } +} + +sub ::pinsrd +{ my($dst,$src,$imm)=@_; + if ("$dst:$src" =~ /xmm([0-7]):(e[a-dsd][ixp])/) + { &::data_byte(0x66,0x0f,0x3a,0x22,0xc0|($1<<3)|$regrm{$2},$imm); } + else + { &::generic("pinsrd",@_); } +} + +sub ::pshufb +{ my($dst,$src)=@_; + if ("$dst:$src" =~ /xmm([0-7]):xmm([0-7])/) + { &data_byte(0x66,0x0f,0x38,0x00,0xc0|($1<<3)|$2); } + else + { &::generic("pshufb",@_); } +} + +sub ::palignr +{ my($dst,$src,$imm)=@_; + if ("$dst:$src" =~ /xmm([0-7]):xmm([0-7])/) + { &::data_byte(0x66,0x0f,0x3a,0x0f,0xc0|($1<<3)|$2,$imm); } + else + { &::generic("palignr",@_); } +} + +sub ::pclmulqdq +{ my($dst,$src,$imm)=@_; + if ("$dst:$src" =~ /xmm([0-7]):xmm([0-7])/) + { &::data_byte(0x66,0x0f,0x3a,0x44,0xc0|($1<<3)|$2,$imm); } + else + { &::generic("pclmulqdq",@_); } +} + +sub ::rdrand +{ my ($dst)=@_; + if ($dst =~ /(e[a-dsd][ixp])/) + { &::data_byte(0x0f,0xc7,0xf0|$regrm{$dst}); } + else + { &::generic("rdrand",@_); } +} + +sub ::rdseed +{ my ($dst)=@_; + if ($dst =~ /(e[a-dsd][ixp])/) + { &::data_byte(0x0f,0xc7,0xf8|$regrm{$dst}); } + else + { &::generic("rdrand",@_); } +} + +sub rxb { + local *opcode=shift; + my ($dst,$src1,$src2,$rxb)=@_; + + $rxb|=0x7<<5; + $rxb&=~(0x04<<5) if($dst>=8); + $rxb&=~(0x01<<5) if($src1>=8); + $rxb&=~(0x02<<5) if($src2>=8); + push @opcode,$rxb; +} + +sub ::vprotd +{ my $args=join(',',@_); + if ($args =~ /xmm([0-7]),xmm([0-7]),([x0-9a-f]+)/) + { my @opcode=(0x8f); + rxb(\@opcode,$1,$2,-1,0x08); + push @opcode,0x78,0xc2; + push @opcode,0xc0|($2&7)|(($1&7)<<3); # ModR/M + my $c=$3; + push @opcode,$c=~/^0/?oct($c):$c; + &::data_byte(@opcode); + } + else + { &::generic("vprotd",@_); } +} + +sub ::endbranch +{ + &::data_byte(0xf3,0x0f,0x1e,0xfb); +} + +# label management +$lbdecor="L"; # local label decoration, set by package +$label="000"; + +sub ::islabel # see is argument is a known label +{ my $i; + foreach $i (values %label) { return $i if ($i eq $_[0]); } + $label{$_[0]}; # can be undef +} + +sub ::label # instantiate a function-scope label +{ if (!defined($label{$_[0]})) + { $label{$_[0]}="${lbdecor}${label}${_[0]}"; $label++; } + $label{$_[0]}; +} + +sub ::LABEL # instantiate a file-scope label +{ $label{$_[0]}=$_[1] if (!defined($label{$_[0]})); + $label{$_[0]}; +} + +sub ::static_label { &::LABEL($_[0],$lbdecor.$_[0]); } + +sub ::set_label_B { push(@out,"@_:\n"); } +sub ::set_label +{ my $label=&::label($_[0]); + &::align($_[1]) if ($_[1]>1); + &::set_label_B($label); + $label; +} + +sub ::wipe_labels # wipes function-scope labels +{ foreach $i (keys %label) + { delete $label{$i} if ($label{$i} =~ /^\Q${lbdecor}\E[0-9]{3}/); } +} + +# subroutine management +sub ::function_begin +{ &function_begin_B(@_); + $stack=4; + &push("ebp"); + &push("ebx"); + &push("esi"); + &push("edi"); +} + +sub ::function_end +{ &pop("edi"); + &pop("esi"); + &pop("ebx"); + &pop("ebp"); + &ret(); + &function_end_B(@_); + $stack=0; + &wipe_labels(); +} + +sub ::function_end_A +{ &pop("edi"); + &pop("esi"); + &pop("ebx"); + &pop("ebp"); + &ret(); + $stack+=16; # readjust esp as if we didn't pop anything +} + +sub ::asciz +{ my @str=unpack("C*",shift); + push @str,0; + while ($#str>15) { + &data_byte(@str[0..15]); + foreach (0..15) { shift @str; } + } + &data_byte(@str) if (@str); +} + +sub ::asm_finish +{ &file_end(); + my $comment = "//"; + $comment = ";" if ($win32); + print <<___; +$comment This file is generated from a similarly-named Perl script in the BoringSSL +$comment source tree. Do not edit by hand. + +___ + if ($win32) { + print <<___ unless $masm; +\%include "ring_core_generated/prefix_symbols_nasm.inc" +\%ifidn __OUTPUT_FORMAT__, win32 +___ + print @out; + print <<___ unless $masm; +\%else +; Work around https://bugzilla.nasm.us/show_bug.cgi?id=3392738 +ret +\%endif +___ + } else { + my $target; + if ($elf) { + $target = "defined(__ELF__)"; + } elsif ($macosx) { + $target = "defined(__APPLE__)"; + } else { + die "unknown target"; + } + + print <<___; +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && $target +___ + print @out; + print <<___; +#endif // !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && $target +___ + } +} + +sub ::asm_init +{ my ($type,$cpu)=@_; + + $i386=$cpu; + + $elf=$cpp=$coff=$aout=$macosx=$win32=$mwerks=$android=0; + if (($type eq "elf")) + { $elf=1; require "x86gas.pl"; } + elsif (($type eq "elf-1")) + { $elf=-1; require "x86gas.pl"; } + elsif (($type eq "a\.out")) + { $aout=1; require "x86gas.pl"; } + elsif (($type eq "coff" or $type eq "gaswin")) + { $coff=1; require "x86gas.pl"; } + elsif (($type eq "win32n")) + { $win32=1; require "x86nasm.pl"; } + elsif (($type eq "win32")) + { $win32=1; $masm=1; require "x86masm.pl"; } + elsif (($type eq "macosx")) + { $aout=1; $macosx=1; require "x86gas.pl"; } + elsif (($type eq "android")) + { $elf=1; $android=1; require "x86gas.pl"; } + else + { print STDERR <<"EOF"; +Pick one target type from + elf - Linux, FreeBSD, Solaris x86, etc. + a.out - DJGPP, elder OpenBSD, etc. + coff - GAS/COFF such as Win32 targets + win32n - Windows 95/Windows NT NASM format + macosx - Mac OS X +EOF + exit(1); + } + + $pic=0; + for (@ARGV) { $pic=1 if (/\-[fK]PIC/i); } + + &file(); +} + +sub ::hidden {} + +1; diff --git a/http/vendor/ring/crypto/perlasm/x86gas.pl b/http/vendor/ring/crypto/perlasm/x86gas.pl new file mode 100644 index 0000000..62a5710 --- /dev/null +++ b/http/vendor/ring/crypto/perlasm/x86gas.pl @@ -0,0 +1,285 @@ +#! /usr/bin/env perl +# Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +package x86gas; + +*out=\@::out; + +$::lbdecor=$::aout?"L":".L"; # local label decoration +$nmdecor=($::aout or $::coff)?"_":""; # external name decoration + +$initseg=""; + +$align=16; +$align=log($align)/log(2) if ($::aout); +$com_start="#" if ($::aout or $::coff); + +sub opsize() +{ my $reg=shift; + if ($reg =~ m/^%e/o) { "l"; } + elsif ($reg =~ m/^%[a-d][hl]$/o) { "b"; } + elsif ($reg =~ m/^%[yxm]/o) { undef; } + else { "w"; } +} + +# swap arguments; +# expand opcode with size suffix; +# prefix numeric constants with $; +sub ::generic +{ my($opcode,@arg)=@_; + my($suffix,$dst,$src); + + @arg=reverse(@arg); + + for (@arg) + { s/^(\*?)(e?[a-dsixphl]{2})$/$1%$2/o; # gp registers + s/^([xy]?mm[0-7])$/%$1/o; # xmm/mmx registers + s/^(\-?[0-9]+)$/\$$1/o; # constants + s/^(\-?0x[0-9a-f]+)$/\$$1/o; # constants + } + + $dst = $arg[$#arg] if ($#arg>=0); + $src = $arg[$#arg-1] if ($#arg>=1); + if ($dst =~ m/^%/o) { $suffix=&opsize($dst); } + elsif ($src =~ m/^%/o) { $suffix=&opsize($src); } + else { $suffix="l"; } + undef $suffix if ($dst =~ m/^%[xm]/o || $src =~ m/^%[xm]/o); + + if ($#_==0) { &::emit($opcode); } + elsif ($#_==1 && $opcode =~ m/^(call|clflush|j|loop|set)/o) + { &::emit($opcode,@arg); } + else { &::emit($opcode.$suffix,@arg);} + + 1; +} +# +# opcodes not covered by ::generic above, mostly inconsistent namings... +# +sub ::movzx { &::movzb(@_); } +sub ::pushfd { &::pushfl; } +sub ::popfd { &::popfl; } +sub ::cpuid { &::emit(".byte\t0x0f,0xa2"); } +sub ::rdtsc { &::emit(".byte\t0x0f,0x31"); } + +sub ::call { &::emit("call",(&::islabel($_[0]) or "$nmdecor$_[0]")); } +sub ::call_ptr { &::generic("call","*$_[0]"); } +sub ::jmp_ptr { &::generic("jmp","*$_[0]"); } + +*::bswap = sub { &::emit("bswap","%$_[0]"); } if (!$::i386); + +sub ::DWP +{ my($addr,$reg1,$reg2,$idx)=@_; + my $ret=""; + + if (!defined($idx) && 1*$reg2) { $idx=$reg2; $reg2=$reg1; undef $reg1; } + + $addr =~ s/^\s+//; + # prepend global references with optional underscore + $addr =~ s/^([^\+\-0-9][^\+\-]*)/&::islabel($1) or "$nmdecor$1"/ige; + + $reg1 = "%$reg1" if ($reg1); + $reg2 = "%$reg2" if ($reg2); + + $ret .= $addr if (($addr ne "") && ($addr ne 0)); + + if ($reg2) + { $idx!= 0 or $idx=1; + $ret .= "($reg1,$reg2,$idx)"; + } + elsif ($reg1) + { $ret .= "($reg1)"; } + + $ret; +} +sub ::QWP { &::DWP(@_); } +sub ::BP { &::DWP(@_); } +sub ::WP { &::DWP(@_); } +sub ::BC { @_; } +sub ::DWC { @_; } + +sub ::file +{ push(@out,".text\n"); } + +sub ::function_begin_B +{ my $func=shift; + my $global=($func !~ /^_/); + my $begin="${::lbdecor}_${func}_begin"; + + &::LABEL($func,$global?"$begin":"$nmdecor$func"); + $func=$nmdecor.$func; + + push(@out,".globl\t$func\n") if ($global); + if ($::macosx) { + push(@out,".private_extern\t$func\n"); + } else { + push(@out,".hidden\t$func\n"); + } + if ($::coff) + { push(@out,".def\t$func;\t.scl\t".(3-$global).";\t.type\t32;\t.endef\n"); } + elsif (($::aout and !$::pic) or $::macosx) + { } + else + { push(@out,".type $func,\@function\n"); } + push(@out,".align\t$align\n"); + push(@out,"$func:\n"); + push(@out,"$begin:\n") if ($global); + $::stack=4; +} + +sub ::function_end_B +{ my $func=shift; + push(@out,".size\t$nmdecor$func,.-".&::LABEL($func)."\n") if ($::elf); + $::stack=0; + &::wipe_labels(); +} + +sub ::comment + { + if (!defined($com_start) or $::elf) + { # Regarding $::elf above... + # GNU and SVR4 as'es use different comment delimiters, + push(@out,"\n"); # so we just skip ELF comments... + return; + } + foreach (@_) + { + if (/^\s*$/) + { push(@out,"\n"); } + else + { push(@out,"\t$com_start $_ $com_end\n"); } + } + } + +sub ::external_label +{ foreach(@_) { &::LABEL($_,$nmdecor.$_); } } + +sub ::public_label +{ push(@out,".globl\t".&::LABEL($_[0],$nmdecor.$_[0])."\n"); } + +sub ::file_end +{ if ($::macosx) + { if (%non_lazy_ptr) + { push(@out,".section __IMPORT,__pointers,non_lazy_symbol_pointers\n"); + foreach $i (keys %non_lazy_ptr) + { push(@out,"$non_lazy_ptr{$i}:\n.indirect_symbol\t$i\n.long\t0\n"); } + } + } + if (0 && grep {/\b${nmdecor}OPENSSL_ia32cap_P\b/i} @out) { + my $tmp=".comm\t${nmdecor}OPENSSL_ia32cap_P,16"; + if ($::macosx) { push (@out,"$tmp,2\n"); } + elsif ($::elf) { push (@out,"$tmp,4\n"); } + else { push (@out,"$tmp\n"); } + } + push(@out,$initseg) if ($initseg); +} + +sub ::data_byte { push(@out,".byte\t".join(',',@_)."\n"); } +sub ::data_short{ push(@out,".value\t".join(',',@_)."\n"); } +sub ::data_word { push(@out,".long\t".join(',',@_)."\n"); } + +sub ::align +{ my $val=$_[0]; + if ($::aout) + { $val=int(log($val)/log(2)); + $val.=",0x90"; + } + push(@out,".align\t$val\n"); +} + +sub ::picmeup +{ my($dst,$sym,$base,$reflabel)=@_; + + if (($::pic && ($::elf || $::aout)) || $::macosx) + { if (!defined($base)) + { &::call(&::label("PIC_me_up")); + &::set_label("PIC_me_up"); + &::blindpop($dst); + $base=$dst; + $reflabel=&::label("PIC_me_up"); + } + if ($::macosx) + { my $indirect=&::static_label("$nmdecor$sym\$non_lazy_ptr"); + &::mov($dst,&::DWP("$indirect-$reflabel",$base)); + $non_lazy_ptr{"$nmdecor$sym"}=$indirect; + } + elsif ($sym eq "OPENSSL_ia32cap_P" && $::elf>0) + { &::lea($dst,&::DWP("$sym-$reflabel",$base)); } + else + { &::lea($dst,&::DWP("_GLOBAL_OFFSET_TABLE_+[.-$reflabel]", + $base)); + &::mov($dst,&::DWP("$sym\@GOT",$dst)); + } + } + else + { &::lea($dst,&::DWP($sym)); } +} + +sub ::initseg +{ my $f=$nmdecor.shift; + + if ($::android) + { $initseg.=<<___; +.section .init_array +.align 4 +.long $f +___ + } + elsif ($::elf) + { $initseg.=<<___; +.section .init + call $f +___ + } + elsif ($::coff) + { $initseg.=<<___; # applies to both Cygwin and Mingw +.section .ctors +.long $f +___ + } + elsif ($::macosx) + { $initseg.=<<___; +.mod_init_func +.align 2 +.long $f +___ + } + elsif ($::aout) + { my $ctor="${nmdecor}_GLOBAL_\$I\$$f"; + $initseg.=".text\n"; + $initseg.=".type $ctor,\@function\n" if ($::pic); + $initseg.=<<___; # OpenBSD way... +.globl $ctor +.align 2 +$ctor: + jmp $f +___ + } +} + +sub ::dataseg +{ push(@out,".data\n"); } + +sub ::preprocessor_ifdef +{ my($define)=@_; + push(@out,"#ifdef ${define}\n"); +} + +sub ::preprocessor_endif +{ push(@out,"#endif\n"); } + +*::hidden = sub { push(@out,".hidden\t$nmdecor$_[0]\n"); } if ($::elf); + +1; diff --git a/http/vendor/ring/crypto/perlasm/x86nasm.pl b/http/vendor/ring/crypto/perlasm/x86nasm.pl new file mode 100644 index 0000000..61c70f4 --- /dev/null +++ b/http/vendor/ring/crypto/perlasm/x86nasm.pl @@ -0,0 +1,201 @@ +#! /usr/bin/env perl +# Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +package x86nasm; + +*out=\@::out; + +$::lbdecor="L\$"; # local label decoration +$nmdecor="_"; # external name decoration +$drdecor=$::mwerks?".":""; # directive decoration + +$initseg=""; + +sub ::generic +{ my $opcode=shift; + my $tmp; + + if (!$::mwerks) + { if ($opcode =~ m/^j/o && $#_==0) # optimize jumps + { $_[0] = "NEAR $_[0]"; } + elsif ($opcode eq "lea" && $#_==1) # wipe storage qualifier from lea + { $_[1] =~ s/^[^\[]*\[/\[/o; } + elsif ($opcode eq "clflush" && $#_==0) + { $_[0] =~ s/^[^\[]*\[/\[/o; } + } + &::emit($opcode,@_); + 1; +} +# +# opcodes not covered by ::generic above, mostly inconsistent namings... +# +sub ::call { &::emit("call",(&::islabel($_[0]) or "$nmdecor$_[0]")); } +sub ::call_ptr { &::emit("call",@_); } +sub ::jmp_ptr { &::emit("jmp",@_); } + +sub get_mem +{ my($size,$addr,$reg1,$reg2,$idx)=@_; + my($post,$ret); + + if (!defined($idx) && 1*$reg2) { $idx=$reg2; $reg2=$reg1; undef $reg1; } + + if ($size ne "") + { $ret .= "$size"; + $ret .= " PTR" if ($::mwerks); + $ret .= " "; + } + $ret .= "["; + + $addr =~ s/^\s+//; + # prepend global references with optional underscore + $addr =~ s/^([^\+\-0-9][^\+\-]*)/::islabel($1) or "$nmdecor$1"/ige; + # put address arithmetic expression in parenthesis + $addr="($addr)" if ($addr =~ /^.+[\-\+].+$/); + + if (($addr ne "") && ($addr ne 0)) + { if ($addr !~ /^-/) { $ret .= "$addr+"; } + else { $post=$addr; } + } + + if ($reg2 ne "") + { $idx!=0 or $idx=1; + $ret .= "$reg2*$idx"; + $ret .= "+$reg1" if ($reg1 ne ""); + } + else + { $ret .= "$reg1"; } + + $ret .= "$post]"; + $ret =~ s/\+\]/]/; # in case $addr was the only argument + + $ret; +} +sub ::BP { &get_mem("BYTE",@_); } +sub ::DWP { &get_mem("DWORD",@_); } +sub ::WP { &get_mem("WORD",@_); } +sub ::QWP { &get_mem("",@_); } +sub ::BC { (($::mwerks)?"":"BYTE ")."@_"; } +sub ::DWC { (($::mwerks)?"":"DWORD ")."@_"; } + +sub ::file +{ if ($::mwerks) { push(@out,".section\t.text,64\n"); } + else + { my $tmp=<<___; +%ifidn __OUTPUT_FORMAT__,obj +section code use32 class=code align=64 +%elifidn __OUTPUT_FORMAT__,win32 +\$\@feat.00 equ 1 +section .text code align=64 +%else +section .text code +%endif +___ + push(@out,$tmp); + } +} + +sub ::function_begin_B +{ my $func=shift; + my $global=($func !~ /^_/); + my $begin="${::lbdecor}_${func}_begin"; + + $begin =~ s/^\@/./ if ($::mwerks); # the torture never stops + + &::LABEL($func,$global?"$begin":"$nmdecor$func"); + $func=$nmdecor.$func; + + push(@out,"${drdecor}global $func\n") if ($global); + push(@out,"${drdecor}align 16\n"); + push(@out,"$func:\n"); + push(@out,"$begin:\n") if ($global); + $::stack=4; +} + +sub ::function_end_B +{ $::stack=0; + &::wipe_labels(); +} + +sub ::file_end +{ if (grep {/\b${nmdecor}OPENSSL_ia32cap_P\b/i} @out) + { my $comm=<<___; +${drdecor}segment .bss +${drdecor}common ${nmdecor}OPENSSL_ia32cap_P 16 +___ + # comment out OPENSSL_ia32cap_P declarations + grep {s/(^extern\s+${nmdecor}OPENSSL_ia32cap_P)/\;$1/} @out; + push (@out,$comm) + } + push (@out,$initseg) if ($initseg); +} + +sub ::comment { foreach (@_) { push(@out,"\t; $_\n"); } } + +sub ::external_label +{ foreach(@_) + { push(@out,"${drdecor}extern\t".&::LABEL($_,$nmdecor.$_)."\n"); } +} + +sub ::public_label +{ push(@out,"${drdecor}global\t".&::LABEL($_[0],$nmdecor.$_[0])."\n"); } + +sub ::data_byte +{ push(@out,(($::mwerks)?".byte\t":"db\t").join(',',@_)."\n"); } +sub ::data_short +{ push(@out,(($::mwerks)?".word\t":"dw\t").join(',',@_)."\n"); } +sub ::data_word +{ push(@out,(($::mwerks)?".long\t":"dd\t").join(',',@_)."\n"); } + +sub ::align +{ push(@out,"${drdecor}align\t$_[0]\n"); } + +sub ::picmeup +{ my($dst,$sym)=@_; + &::lea($dst,&::DWP($sym)); +} + +sub ::initseg +{ my $f=$nmdecor.shift; + if ($::win32) + { $initseg=<<___; +segment .CRT\$XCU data align=4 +extern $f +dd $f +___ + } +} + +sub ::dataseg +{ if ($mwerks) { push(@out,".section\t.data,4\n"); } + else { push(@out,"section\t.data align=4\n"); } +} + +sub ::safeseh +{ my $nm=shift; + push(@out,"%if __NASM_VERSION_ID__ >= 0x02030000\n"); + push(@out,"safeseh ".&::LABEL($nm,$nmdecor.$nm)."\n"); + push(@out,"%endif\n"); +} + +sub ::preprocessor_ifdef +{ my($define)=@_; + push(@out,"%ifdef ${define}\n"); +} + +sub ::preprocessor_endif +{ push(@out,"%endif\n"); } + +1; diff --git a/http/vendor/ring/crypto/poly1305/poly1305.c b/http/vendor/ring/crypto/poly1305/poly1305.c new file mode 100644 index 0000000..6759536 --- /dev/null +++ b/http/vendor/ring/crypto/poly1305/poly1305.c @@ -0,0 +1,246 @@ +/* Copyright (c) 2014, Google Inc. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +// This implementation of poly1305 is by Andrew Moon +// (https://github.com/floodyberry/poly1305-donna) and released as public +// domain. + +#include + +#include "../internal.h" +#include "ring-core/check.h" + +#if defined(__GNUC__) || defined(__clang__) +#pragma GCC diagnostic ignored "-Wsign-conversion" +#pragma GCC diagnostic ignored "-Wconversion" +#endif + +static uint64_t mul32x32_64(uint32_t a, uint32_t b) { return (uint64_t)a * b; } + +// Keep in sync with `poly1305_state_st` in ffi_fallback.rs. +struct poly1305_state_st { + alignas(64) uint32_t r0; + uint32_t r1, r2, r3, r4; + uint32_t s1, s2, s3, s4; + uint32_t h0, h1, h2, h3, h4; + uint8_t key[16]; +}; + +// poly1305_blocks updates |state| given some amount of input data. This +// function may only be called with a |len| that is not a multiple of 16 at the +// end of the data. Otherwise the input must be buffered into 16 byte blocks. +static void poly1305_update(struct poly1305_state_st *state, const uint8_t *in, + size_t len) { + debug_assert_nonsecret((uintptr_t)state % 64 == 0); + + uint32_t t0, t1, t2, t3; + uint64_t t[5]; + uint32_t b; + uint64_t c; + size_t j; + uint8_t mp[16]; + + if (len < 16) { + goto poly1305_donna_atmost15bytes; + } + +poly1305_donna_16bytes: + t0 = CRYPTO_load_u32_le(in); + t1 = CRYPTO_load_u32_le(in + 4); + t2 = CRYPTO_load_u32_le(in + 8); + t3 = CRYPTO_load_u32_le(in + 12); + + in += 16; + len -= 16; + + state->h0 += t0 & 0x3ffffff; + state->h1 += ((((uint64_t)t1 << 32) | t0) >> 26) & 0x3ffffff; + state->h2 += ((((uint64_t)t2 << 32) | t1) >> 20) & 0x3ffffff; + state->h3 += ((((uint64_t)t3 << 32) | t2) >> 14) & 0x3ffffff; + state->h4 += (t3 >> 8) | (1 << 24); + +poly1305_donna_mul: + t[0] = mul32x32_64(state->h0, state->r0) + mul32x32_64(state->h1, state->s4) + + mul32x32_64(state->h2, state->s3) + mul32x32_64(state->h3, state->s2) + + mul32x32_64(state->h4, state->s1); + t[1] = mul32x32_64(state->h0, state->r1) + mul32x32_64(state->h1, state->r0) + + mul32x32_64(state->h2, state->s4) + mul32x32_64(state->h3, state->s3) + + mul32x32_64(state->h4, state->s2); + t[2] = mul32x32_64(state->h0, state->r2) + mul32x32_64(state->h1, state->r1) + + mul32x32_64(state->h2, state->r0) + mul32x32_64(state->h3, state->s4) + + mul32x32_64(state->h4, state->s3); + t[3] = mul32x32_64(state->h0, state->r3) + mul32x32_64(state->h1, state->r2) + + mul32x32_64(state->h2, state->r1) + mul32x32_64(state->h3, state->r0) + + mul32x32_64(state->h4, state->s4); + t[4] = mul32x32_64(state->h0, state->r4) + mul32x32_64(state->h1, state->r3) + + mul32x32_64(state->h2, state->r2) + mul32x32_64(state->h3, state->r1) + + mul32x32_64(state->h4, state->r0); + + state->h0 = (uint32_t)t[0] & 0x3ffffff; + c = (t[0] >> 26); + t[1] += c; + state->h1 = (uint32_t)t[1] & 0x3ffffff; + b = (uint32_t)(t[1] >> 26); + t[2] += b; + state->h2 = (uint32_t)t[2] & 0x3ffffff; + b = (uint32_t)(t[2] >> 26); + t[3] += b; + state->h3 = (uint32_t)t[3] & 0x3ffffff; + b = (uint32_t)(t[3] >> 26); + t[4] += b; + state->h4 = (uint32_t)t[4] & 0x3ffffff; + b = (uint32_t)(t[4] >> 26); + state->h0 += b * 5; + + if (len >= 16) { + goto poly1305_donna_16bytes; + } + +// final bytes +poly1305_donna_atmost15bytes: + if (!len) { + return; + } + + for (j = 0; j < len; j++) { + mp[j] = in[j]; + } + mp[j++] = 1; + for (; j < 16; j++) { + mp[j] = 0; + } + len = 0; + + t0 = CRYPTO_load_u32_le(mp + 0); + t1 = CRYPTO_load_u32_le(mp + 4); + t2 = CRYPTO_load_u32_le(mp + 8); + t3 = CRYPTO_load_u32_le(mp + 12); + + state->h0 += t0 & 0x3ffffff; + state->h1 += ((((uint64_t)t1 << 32) | t0) >> 26) & 0x3ffffff; + state->h2 += ((((uint64_t)t2 << 32) | t1) >> 20) & 0x3ffffff; + state->h3 += ((((uint64_t)t3 << 32) | t2) >> 14) & 0x3ffffff; + state->h4 += (t3 >> 8); + + goto poly1305_donna_mul; +} + +void CRYPTO_poly1305_init(struct poly1305_state_st *state, const uint8_t key[32]) { + debug_assert_nonsecret((uintptr_t)state % 64 == 0); + + uint32_t t0, t1, t2, t3; + + t0 = CRYPTO_load_u32_le(key + 0); + t1 = CRYPTO_load_u32_le(key + 4); + t2 = CRYPTO_load_u32_le(key + 8); + t3 = CRYPTO_load_u32_le(key + 12); + + // precompute multipliers + state->r0 = t0 & 0x3ffffff; + t0 >>= 26; + t0 |= t1 << 6; + state->r1 = t0 & 0x3ffff03; + t1 >>= 20; + t1 |= t2 << 12; + state->r2 = t1 & 0x3ffc0ff; + t2 >>= 14; + t2 |= t3 << 18; + state->r3 = t2 & 0x3f03fff; + t3 >>= 8; + state->r4 = t3 & 0x00fffff; + + state->s1 = state->r1 * 5; + state->s2 = state->r2 * 5; + state->s3 = state->r3 * 5; + state->s4 = state->r4 * 5; + + // init state + state->h0 = 0; + state->h1 = 0; + state->h2 = 0; + state->h3 = 0; + state->h4 = 0; + + OPENSSL_memcpy(state->key, key + 16, sizeof(state->key)); +} + +void CRYPTO_poly1305_update(struct poly1305_state_st *state, const uint8_t *in, + size_t in_len) { + // Work around a C language bug. See https://crbug.com/1019588. + if (in_len == 0) { + return; + } + + poly1305_update(state, in, in_len); +} + +void CRYPTO_poly1305_finish(struct poly1305_state_st *state, uint8_t mac[16]) { + uint32_t g0, g1, g2, g3, g4; + uint32_t b, nb; + + b = state->h0 >> 26; + state->h0 = state->h0 & 0x3ffffff; + state->h1 += b; + b = state->h1 >> 26; + state->h1 = state->h1 & 0x3ffffff; + state->h2 += b; + b = state->h2 >> 26; + state->h2 = state->h2 & 0x3ffffff; + state->h3 += b; + b = state->h3 >> 26; + state->h3 = state->h3 & 0x3ffffff; + state->h4 += b; + b = state->h4 >> 26; + state->h4 = state->h4 & 0x3ffffff; + state->h0 += b * 5; + + g0 = state->h0 + 5; + b = g0 >> 26; + g0 &= 0x3ffffff; + g1 = state->h1 + b; + b = g1 >> 26; + g1 &= 0x3ffffff; + g2 = state->h2 + b; + b = g2 >> 26; + g2 &= 0x3ffffff; + g3 = state->h3 + b; + b = g3 >> 26; + g3 &= 0x3ffffff; + g4 = state->h4 + b - (1 << 26); + + b = (g4 >> 31) - 1; + nb = ~b; + state->h0 = (state->h0 & nb) | (g0 & b); + state->h1 = (state->h1 & nb) | (g1 & b); + state->h2 = (state->h2 & nb) | (g2 & b); + state->h3 = (state->h3 & nb) | (g3 & b); + state->h4 = (state->h4 & nb) | (g4 & b); + + uint64_t f0 = ((state->h0) | (state->h1 << 26)) + + (uint64_t)CRYPTO_load_u32_le(&state->key[0]); + uint64_t f1 = ((state->h1 >> 6) | (state->h2 << 20)) + + (uint64_t)CRYPTO_load_u32_le(&state->key[4]); + uint64_t f2 = ((state->h2 >> 12) | (state->h3 << 14)) + + (uint64_t)CRYPTO_load_u32_le(&state->key[8]); + uint64_t f3 = ((state->h3 >> 18) | (state->h4 << 8)) + + (uint64_t)CRYPTO_load_u32_le(&state->key[12]); + + CRYPTO_store_u32_le(&mac[0], (uint32_t)f0); + f1 += (f0 >> 32); + CRYPTO_store_u32_le(&mac[4], (uint32_t)f1); + f2 += (f1 >> 32); + CRYPTO_store_u32_le(&mac[8], (uint32_t)f2); + f3 += (f2 >> 32); + CRYPTO_store_u32_le(&mac[12], (uint32_t)f3); +} diff --git a/http/vendor/ring/crypto/poly1305/poly1305_arm.c b/http/vendor/ring/crypto/poly1305/poly1305_arm.c new file mode 100644 index 0000000..632ecca --- /dev/null +++ b/http/vendor/ring/crypto/poly1305/poly1305_arm.c @@ -0,0 +1,302 @@ +/* Copyright (c) 2014, Google Inc. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +// This implementation was taken from the public domain, neon2 version in +// SUPERCOP by D. J. Bernstein and Peter Schwabe. + +#include + +#include "../internal.h" + + +#pragma GCC diagnostic ignored "-Wsign-conversion" + +// Keep in sync with ffi_arm_neon.rs +typedef struct { + uint32_t v[12]; // for alignment; only using 10 +} fe1305x2; + +#define addmulmod openssl_poly1305_neon2_addmulmod +#define blocks openssl_poly1305_neon2_blocks + +extern void addmulmod(fe1305x2 *r, const fe1305x2 *x, const fe1305x2 *y, + const fe1305x2 *c); + +extern int blocks(fe1305x2 *h, const fe1305x2 *precomp, const uint8_t *in, + size_t inlen); + +static void freeze(fe1305x2 *r) { + int i; + + uint32_t x0 = r->v[0]; + uint32_t x1 = r->v[2]; + uint32_t x2 = r->v[4]; + uint32_t x3 = r->v[6]; + uint32_t x4 = r->v[8]; + uint32_t y0; + uint32_t y1; + uint32_t y2; + uint32_t y3; + uint32_t y4; + uint32_t swap; + + for (i = 0; i < 3; ++i) { + x1 += x0 >> 26; + x0 &= 0x3ffffff; + x2 += x1 >> 26; + x1 &= 0x3ffffff; + x3 += x2 >> 26; + x2 &= 0x3ffffff; + x4 += x3 >> 26; + x3 &= 0x3ffffff; + x0 += 5 * (x4 >> 26); + x4 &= 0x3ffffff; + } + + y0 = x0 + 5; + y1 = x1 + (y0 >> 26); + y0 &= 0x3ffffff; + y2 = x2 + (y1 >> 26); + y1 &= 0x3ffffff; + y3 = x3 + (y2 >> 26); + y2 &= 0x3ffffff; + y4 = x4 + (y3 >> 26); + y3 &= 0x3ffffff; + swap = -(y4 >> 26); + y4 &= 0x3ffffff; + + y0 ^= x0; + y1 ^= x1; + y2 ^= x2; + y3 ^= x3; + y4 ^= x4; + + y0 &= swap; + y1 &= swap; + y2 &= swap; + y3 &= swap; + y4 &= swap; + + y0 ^= x0; + y1 ^= x1; + y2 ^= x2; + y3 ^= x3; + y4 ^= x4; + + r->v[0] = y0; + r->v[2] = y1; + r->v[4] = y2; + r->v[6] = y3; + r->v[8] = y4; +} + +static void store32(uint8_t out[4], uint32_t v) { OPENSSL_memcpy(out, &v, 4); } + +// load32 exists to avoid breaking strict aliasing rules in +// fe1305x2_frombytearray. +static uint32_t load32(const uint8_t t[4]) { + uint32_t tmp; + OPENSSL_memcpy(&tmp, t, sizeof(tmp)); + return tmp; +} + +static void fe1305x2_tobytearray(uint8_t r[16], fe1305x2 *x) { + uint32_t x0 = x->v[0]; + uint32_t x1 = x->v[2]; + uint32_t x2 = x->v[4]; + uint32_t x3 = x->v[6]; + uint32_t x4 = x->v[8]; + + x1 += x0 >> 26; + x0 &= 0x3ffffff; + x2 += x1 >> 26; + x1 &= 0x3ffffff; + x3 += x2 >> 26; + x2 &= 0x3ffffff; + x4 += x3 >> 26; + x3 &= 0x3ffffff; + + store32(r, x0 + (x1 << 26)); + store32(r + 4, (x1 >> 6) + (x2 << 20)); + store32(r + 8, (x2 >> 12) + (x3 << 14)); + store32(r + 12, (x3 >> 18) + (x4 << 8)); +} + +static void fe1305x2_frombytearray(fe1305x2 *r, const uint8_t *x, size_t xlen) { + size_t i; + uint8_t t[17]; + + for (i = 0; (i < 16) && (i < xlen); i++) { + t[i] = x[i]; + } + xlen -= i; + x += i; + t[i++] = 1; + for (; i < 17; i++) { + t[i] = 0; + } + + r->v[0] = 0x3ffffff & load32(t); + r->v[2] = 0x3ffffff & (load32(t + 3) >> 2); + r->v[4] = 0x3ffffff & (load32(t + 6) >> 4); + r->v[6] = 0x3ffffff & (load32(t + 9) >> 6); + r->v[8] = load32(t + 13); + + if (xlen) { + for (i = 0; (i < 16) && (i < xlen); i++) { + t[i] = x[i]; + } + t[i++] = 1; + for (; i < 17; i++) { + t[i] = 0; + } + + r->v[1] = 0x3ffffff & load32(t); + r->v[3] = 0x3ffffff & (load32(t + 3) >> 2); + r->v[5] = 0x3ffffff & (load32(t + 6) >> 4); + r->v[7] = 0x3ffffff & (load32(t + 9) >> 6); + r->v[9] = load32(t + 13); + } else { + r->v[1] = r->v[3] = r->v[5] = r->v[7] = r->v[9] = 0; + } +} + +static const alignas(16) fe1305x2 zero; + +// Keep in sync with ffi_arm_neon.rs +struct poly1305_state_st { + alignas(16) fe1305x2 r; + fe1305x2 h; + fe1305x2 c; + fe1305x2 precomp[2]; + uint8_t data[128]; + + uint8_t buf[32]; + size_t buf_used; + uint8_t key[16]; +}; + +OPENSSL_STATIC_ASSERT(sizeof(fe1305x2) == 48, "fe1305x2 size is different than expected"); + +void CRYPTO_poly1305_init_neon(struct poly1305_state_st *st, const uint8_t key[32]) { + fe1305x2 *const r = &st->r; + fe1305x2 *const h = &st->h; + fe1305x2 *const precomp = &st->precomp[0]; + + r->v[1] = r->v[0] = 0x3ffffff & load32(key); + r->v[3] = r->v[2] = 0x3ffff03 & (load32(key + 3) >> 2); + r->v[5] = r->v[4] = 0x3ffc0ff & (load32(key + 6) >> 4); + r->v[7] = r->v[6] = 0x3f03fff & (load32(key + 9) >> 6); + r->v[9] = r->v[8] = 0x00fffff & (load32(key + 12) >> 8); + + for (size_t j = 0; j < 10; j++) { + h->v[j] = 0; // XXX: should fast-forward a bit + } + + addmulmod(precomp, r, r, &zero); // precompute r^2 + addmulmod(precomp + 1, precomp, precomp, &zero); // precompute r^4 + + OPENSSL_memcpy(st->key, key + 16, 16); + st->buf_used = 0; +} + +void CRYPTO_poly1305_update_neon(struct poly1305_state_st *st, const uint8_t *in, + size_t in_len) { + fe1305x2 *const h = &st->h; + fe1305x2 *const c = &st->c; + fe1305x2 *const precomp = &st->precomp[0]; + + if (st->buf_used) { + size_t todo = 32 - st->buf_used; + if (todo > in_len) { + todo = in_len; + } + for (size_t i = 0; i < todo; i++) { + st->buf[st->buf_used + i] = in[i]; + } + st->buf_used += todo; + in_len -= todo; + in += todo; + + if (st->buf_used == sizeof(st->buf) && in_len) { + addmulmod(h, h, precomp, &zero); + fe1305x2_frombytearray(c, st->buf, sizeof(st->buf)); + for (size_t i = 0; i < 10; i++) { + h->v[i] += c->v[i]; + } + st->buf_used = 0; + } + } + + while (in_len > 32) { + size_t tlen = 1048576; + if (in_len < tlen) { + tlen = in_len; + } + tlen -= blocks(h, precomp, in, tlen); + in_len -= tlen; + in += tlen; + } + + if (in_len) { + for (size_t i = 0; i < in_len; i++) { + st->buf[i] = in[i]; + } + st->buf_used = in_len; + } +} + +void CRYPTO_poly1305_finish_neon(struct poly1305_state_st *st, uint8_t mac[16]) { + fe1305x2 *const r = &st->r; + fe1305x2 *const h = &st->h; + fe1305x2 *const c = &st->c; + fe1305x2 *const precomp = &st->precomp[0]; + + addmulmod(h, h, precomp, &zero); + + if (st->buf_used > 16) { + fe1305x2_frombytearray(c, st->buf, st->buf_used); + precomp->v[1] = r->v[1]; + precomp->v[3] = r->v[3]; + precomp->v[5] = r->v[5]; + precomp->v[7] = r->v[7]; + precomp->v[9] = r->v[9]; + addmulmod(h, h, precomp, c); + } else if (st->buf_used > 0) { + fe1305x2_frombytearray(c, st->buf, st->buf_used); + r->v[1] = 1; + r->v[3] = 0; + r->v[5] = 0; + r->v[7] = 0; + r->v[9] = 0; + addmulmod(h, h, r, c); + } + + h->v[0] += h->v[1]; + h->v[2] += h->v[3]; + h->v[4] += h->v[5]; + h->v[6] += h->v[7]; + h->v[8] += h->v[9]; + freeze(h); + + fe1305x2_frombytearray(c, st->key, 16); + c->v[8] ^= (1 << 24); + + h->v[0] += c->v[0]; + h->v[2] += c->v[2]; + h->v[4] += c->v[4]; + h->v[6] += c->v[6]; + h->v[8] += c->v[8]; + fe1305x2_tobytearray(mac, h); +} diff --git a/http/vendor/ring/crypto/poly1305/poly1305_arm_asm.S b/http/vendor/ring/crypto/poly1305/poly1305_arm_asm.S new file mode 100644 index 0000000..df464d0 --- /dev/null +++ b/http/vendor/ring/crypto/poly1305/poly1305_arm_asm.S @@ -0,0 +1,2019 @@ +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_ARM) && defined(__ELF__) + +#pragma GCC diagnostic ignored "-Wlanguage-extension-token" + +# This implementation was taken from the public domain, neon2 version in +# SUPERCOP by D. J. Bernstein and Peter Schwabe. + +# qhasm: int32 input_0 + +# qhasm: int32 input_1 + +# qhasm: int32 input_2 + +# qhasm: int32 input_3 + +# qhasm: stack32 input_4 + +# qhasm: stack32 input_5 + +# qhasm: stack32 input_6 + +# qhasm: stack32 input_7 + +# qhasm: int32 caller_r4 + +# qhasm: int32 caller_r5 + +# qhasm: int32 caller_r6 + +# qhasm: int32 caller_r7 + +# qhasm: int32 caller_r8 + +# qhasm: int32 caller_r9 + +# qhasm: int32 caller_r10 + +# qhasm: int32 caller_r11 + +# qhasm: int32 caller_r12 + +# qhasm: int32 caller_r14 + +# qhasm: reg128 caller_q4 + +# qhasm: reg128 caller_q5 + +# qhasm: reg128 caller_q6 + +# qhasm: reg128 caller_q7 + +# qhasm: startcode +.fpu neon +.text + +# qhasm: reg128 r0 + +# qhasm: reg128 r1 + +# qhasm: reg128 r2 + +# qhasm: reg128 r3 + +# qhasm: reg128 r4 + +# qhasm: reg128 x01 + +# qhasm: reg128 x23 + +# qhasm: reg128 x4 + +# qhasm: reg128 y0 + +# qhasm: reg128 y12 + +# qhasm: reg128 y34 + +# qhasm: reg128 5y12 + +# qhasm: reg128 5y34 + +# qhasm: stack128 y0_stack + +# qhasm: stack128 y12_stack + +# qhasm: stack128 y34_stack + +# qhasm: stack128 5y12_stack + +# qhasm: stack128 5y34_stack + +# qhasm: reg128 z0 + +# qhasm: reg128 z12 + +# qhasm: reg128 z34 + +# qhasm: reg128 5z12 + +# qhasm: reg128 5z34 + +# qhasm: stack128 z0_stack + +# qhasm: stack128 z12_stack + +# qhasm: stack128 z34_stack + +# qhasm: stack128 5z12_stack + +# qhasm: stack128 5z34_stack + +# qhasm: stack128 two24 + +# qhasm: int32 ptr + +# qhasm: reg128 c01 + +# qhasm: reg128 c23 + +# qhasm: reg128 d01 + +# qhasm: reg128 d23 + +# qhasm: reg128 t0 + +# qhasm: reg128 t1 + +# qhasm: reg128 t2 + +# qhasm: reg128 t3 + +# qhasm: reg128 t4 + +# qhasm: reg128 mask + +# qhasm: reg128 u0 + +# qhasm: reg128 u1 + +# qhasm: reg128 u2 + +# qhasm: reg128 u3 + +# qhasm: reg128 u4 + +# qhasm: reg128 v01 + +# qhasm: reg128 mid + +# qhasm: reg128 v23 + +# qhasm: reg128 v4 + +# qhasm: int32 len + +# qhasm: qpushenter crypto_onetimeauth_poly1305_neon2_blocks +.align 4 +.global openssl_poly1305_neon2_blocks +.hidden openssl_poly1305_neon2_blocks +.type openssl_poly1305_neon2_blocks STT_FUNC +openssl_poly1305_neon2_blocks: +vpush {q4,q5,q6,q7} +mov r12,sp +sub sp,sp,#192 +bic sp,sp,#31 + +# qhasm: len = input_3 +# asm 1: mov >len=int32#4,len=r3,y12=reg128#2%bot->y12=reg128#2%top},[y12=d2->y12=d3},[y34=reg128#3%bot->y34=reg128#3%top},[y34=d4->y34=d5},[input_1=int32#2,input_1=r1,z12=reg128#5%bot->z12=reg128#5%top},[z12=d8->z12=d9},[z34=reg128#6%bot->z34=reg128#6%top},[z34=d10->z34=d11},[mask=reg128#7,#0xffffffff +# asm 2: vmov.i64 >mask=q6,#0xffffffff +vmov.i64 q6,#0xffffffff + +# qhasm: 2x u4 = 0xff +# asm 1: vmov.i64 >u4=reg128#8,#0xff +# asm 2: vmov.i64 >u4=q7,#0xff +vmov.i64 q7,#0xff + +# qhasm: x01 aligned= mem128[input_0];input_0+=16 +# asm 1: vld1.8 {>x01=reg128#9%bot->x01=reg128#9%top},[x01=d16->x01=d17},[x23=reg128#10%bot->x23=reg128#10%top},[x23=d18->x23=d19},[input_0=int32#1,input_0=r0,>=6 +# asm 1: vshr.u64 >mask=reg128#7,mask=q6,>= 7 +# asm 1: vshr.u64 >u4=reg128#8,u4=q7,5y12=reg128#12,5y12=q11,5y34=reg128#13,5y34=q12,5y12=reg128#12,<5y12=reg128#12,5y12=q11,<5y12=q11,5y34=reg128#13,<5y34=reg128#13,5y34=q12,<5y34=q12,u4=reg128#8,u4=q7,5z12=reg128#14,5z12=q13,5z34=reg128#15,5z34=q14,5z12=reg128#14,<5z12=reg128#14,5z12=q13,<5z12=q13,5z34=reg128#15,<5z34=reg128#15,5z34=q14,<5z34=q14,ptr=int32#2,ptr=r1,r4=reg128#16,r4=q15,r0=reg128#8,r0=q7,ptr=int32#2,ptr=r1,ptr=int32#2,ptr=r1,ptr=int32#2,ptr=r1,ptr=int32#2,ptr=r1,ptr=int32#2,ptr=r1,ptr=int32#2,ptr=r1,ptr=int32#2,<5y12_stack=stack128#5 +# asm 2: lea >ptr=r1,<5y12_stack=[sp,#64] +add r1,sp,#64 + +# qhasm: mem128[ptr] aligned= 5y12 +# asm 1: vst1.8 {<5y12=reg128#12%bot-<5y12=reg128#12%top},[ptr=int32#2,<5y34_stack=stack128#6 +# asm 2: lea >ptr=r1,<5y34_stack=[sp,#80] +add r1,sp,#80 + +# qhasm: mem128[ptr] aligned= 5y34 +# asm 1: vst1.8 {<5y34=reg128#13%bot-<5y34=reg128#13%top},[ptr=int32#2,<5z12_stack=stack128#10 +# asm 2: lea >ptr=r1,<5z12_stack=[sp,#144] +add r1,sp,#144 + +# qhasm: mem128[ptr] aligned= 5z12 +# asm 1: vst1.8 {<5z12=reg128#14%bot-<5z12=reg128#14%top},[ptr=int32#2,<5z34_stack=stack128#11 +# asm 2: lea >ptr=r1,<5z34_stack=[sp,#160] +add r1,sp,#160 + +# qhasm: mem128[ptr] aligned= 5z34 +# asm 1: vst1.8 {<5z34=reg128#15%bot-<5z34=reg128#15%top},[? len - 64 +# asm 1: cmp +bls ._below64bytes + +# qhasm: input_2 += 32 +# asm 1: add >input_2=int32#2,input_2=r1,c01=reg128#1%bot->c01=reg128#1%top},[c01=d0->c01=d1},[c23=reg128#2%bot->c23=reg128#2%top},[c23=d2->c23=d3},[ptr=int32#3,ptr=r2,z12=reg128#3%bot->z12=reg128#3%top},[z12=d4->z12=d5},[ptr=int32#3,ptr=r2,z0=reg128#4%bot->z0=reg128#4%top},[z0=d6->z0=d7},[r3=reg128#5,r3=q4,input_2=int32#2,input_2=r1,ptr=int32#3,<5z34_stack=stack128#11 +# asm 2: lea >ptr=r2,<5z34_stack=[sp,#160] +add r2,sp,#160 + +# qhasm: 5z34 aligned= mem128[ptr] +# asm 1: vld1.8 {>5z34=reg128#6%bot->5z34=reg128#6%top},[5z34=d10->5z34=d11},[r0=reg128#8,r0=q7,r2=reg128#14,r2=q13,d01=reg128#12%bot->d01=reg128#12%top},[d01=d22->d01=d23},[r1=reg128#15,r1=q14,ptr=int32#3,<5z12_stack=stack128#10 +# asm 2: lea >ptr=r2,<5z12_stack=[sp,#144] +add r2,sp,#144 + +# qhasm: 5z12 aligned= mem128[ptr] +# asm 1: vld1.8 {>5z12=reg128#1%bot->5z12=reg128#1%top},[5z12=d0->5z12=d1},[d23=reg128#2%bot->d23=reg128#2%top},[d23=d2->d23=d3},[input_2=int32#2,input_2=r1,> 40 +# asm 1: vshr.u64 >v4=reg128#4,v4=q3,> 14; v23[3] = d23[2,3] unsigned>> 14 +# asm 1: vshrn.u64 > 26; v01[3] = d01[2,3] unsigned>> 26 +# asm 1: vshrn.u64 > 20; v23[1] = mid[2,3] unsigned>> 20 +# asm 1: vshrn.u64 ptr=int32#3,ptr=r2,y34=reg128#3%bot->y34=reg128#3%top},[y34=d4->y34=d5},[ptr=int32#3,ptr=r2,y12=reg128#2%bot->y12=reg128#2%top},[y12=d2->y12=d3},[ptr=int32#3,ptr=r2,y0=reg128#1%bot->y0=reg128#1%top},[y0=d0->y0=d1},[ptr=int32#3,<5y34_stack=stack128#6 +# asm 2: lea >ptr=r2,<5y34_stack=[sp,#80] +add r2,sp,#80 + +# qhasm: 5y34 aligned= mem128[ptr] +# asm 1: vld1.8 {>5y34=reg128#13%bot->5y34=reg128#13%top},[5y34=d24->5y34=d25},[ptr=int32#3,<5y12_stack=stack128#5 +# asm 2: lea >ptr=r2,<5y12_stack=[sp,#64] +add r2,sp,#64 + +# qhasm: 5y12 aligned= mem128[ptr] +# asm 1: vld1.8 {>5y12=reg128#12%bot->5y12=reg128#12%top},[5y12=d22->5y12=d23},[ptr=int32#3,ptr=r2,> 26 +# asm 1: vshr.u64 >t1=reg128#4,t1=q3,len=int32#4,len=r3,r0=reg128#6,r0=q5,r1=reg128#4,r1=q3,> 26 +# asm 1: vshr.u64 >t4=reg128#8,t4=q7,r3=reg128#5,r3=q4,x4=reg128#8,x4=q7,r4=reg128#16%bot->r4=reg128#16%top},[r4=d30->r4=d31},[> 26 +# asm 1: vshr.u64 >t2=reg128#9,t2=q8,r1=reg128#4,r1=q3,> 26 +# asm 1: vshr.u64 >t0=reg128#10,t0=q9,r2=reg128#9,r2=q8,x4=reg128#11,x4=q10,x01=reg128#6,x01=q5,r0=reg128#8%bot->r0=reg128#8%top},[r0=d14->r0=d15},[ptr=int32#3,ptr=r2,t0=reg128#10,t0=q9,> 26 +# asm 1: vshr.u64 >t3=reg128#14,t3=q13,x01=reg128#15,x01=q14,z34=reg128#6%bot->z34=reg128#6%top},[z34=d10->z34=d11},[x23=reg128#10,x23=q9,r3=reg128#5,r3=q4,input_2=int32#2,input_2=r1,> 26 +# asm 1: vshr.u64 >t1=reg128#14,t1=q13,x01=reg128#9,x01=q8,r1=reg128#4,r1=q3,> 26 +# asm 1: vshr.u64 >t4=reg128#14,t4=q13,r3=reg128#5,r3=q4,x4=reg128#11,x4=q10,? len - 64 +# asm 1: cmp +bhi ._mainloop2 + +# qhasm: input_2 -= 32 +# asm 1: sub >input_2=int32#3,input_2=r2,? len - 32 +# asm 1: cmp +bls ._end + +# qhasm: mainloop: +._mainloop: + +# qhasm: new r0 + +# qhasm: ptr = &two24 +# asm 1: lea >ptr=int32#2,ptr=r1,r4=reg128#5%bot->r4=reg128#5%top},[r4=d8->r4=d9},[u4=reg128#6%bot->u4=reg128#6%top},[u4=d10->u4=d11},[c01=reg128#8%bot->c01=reg128#8%top},[c01=d14->c01=d15},[c23=reg128#14%bot->c23=reg128#14%top},[c23=d26->c23=d27},[r0=reg128#4,r0=q3,r3=reg128#6,r3=q5,r1=reg128#14,r1=q13,r2=reg128#8,r2=q7,> 26 +# asm 1: vshr.u64 >t1=reg128#9,t1=q8,r0=reg128#4,r0=q3,r1=reg128#9,r1=q8,> 26 +# asm 1: vshr.u64 >t4=reg128#10,t4=q9,r3=reg128#6,r3=q5,r4=reg128#5,r4=q4,> 26 +# asm 1: vshr.u64 >t2=reg128#10,t2=q9,r1=reg128#11,r1=q10,> 26 +# asm 1: vshr.u64 >t0=reg128#9,t0=q8,r2=reg128#8,r2=q7,r4=reg128#5,r4=q4,r0=reg128#4,r0=q3,t0=reg128#9,t0=q8,> 26 +# asm 1: vshr.u64 >t3=reg128#14,t3=q13,r0=reg128#4,r0=q3,x23=reg128#10,x23=q9,r3=reg128#6,r3=q5,> 26 +# asm 1: vshr.u64 >t1=reg128#8,t1=q7,x01=reg128#9,x01=q8,r1=reg128#4,r1=q3,> 26 +# asm 1: vshr.u64 >t4=reg128#8,t4=q7,r3=reg128#6,r3=q5,x4=reg128#11,x4=q10,len=int32#4,len=r3,? len - 32 +# asm 1: cmp +bhi ._mainloop + +# qhasm: end: +._end: + +# qhasm: mem128[input_0] = x01;input_0+=16 +# asm 1: vst1.8 {len=int32#1,len=r0,mask=reg128#1,#0xffffffff +# asm 2: vmov.i64 >mask=q0,#0xffffffff +vmov.i64 q0,#0xffffffff + +# qhasm: y01 aligned= mem128[input_2];input_2+=16 +# asm 1: vld1.8 {>y01=reg128#2%bot->y01=reg128#2%top},[y01=d2->y01=d3},[_5y01=reg128#3,_5y01=q2,y23=reg128#4%bot->y23=reg128#4%top},[y23=d6->y23=d7},[_5y23=reg128#9,_5y23=q8,_5y4=reg128#11,_5y4=q10,x01=reg128#12%bot->x01=reg128#12%top},[x01=d22->x01=d23},[_5y01=reg128#3,<_5y01=reg128#3,_5y01=q2,<_5y01=q2,x23=reg128#13%bot->x23=reg128#13%top},[x23=d24->x23=d25},[_5y23=reg128#9,<_5y23=reg128#9,_5y23=q8,<_5y23=q8,_5y4=reg128#11,<_5y4=reg128#11,_5y4=q10,<_5y4=q10,c01=reg128#14%bot->c01=reg128#14%top},[c01=d26->c01=d27},[x01=reg128#12,x01=q11,c23=reg128#14%bot->c23=reg128#14%top},[c23=d26->c23=d27},[x23=reg128#13,x23=q12,>=6 +# asm 1: vshr.u64 >mask=reg128#1,mask=q0,x4=reg128#14,x4=q13,r0=reg128#15,r0=q14,r1=reg128#3,r1=q2,r2=reg128#16,r2=q15,r3=reg128#9,r3=q8,r4=reg128#10,r4=q9,> 26 +# asm 1: vshr.u64 >t1=reg128#2,t1=q1,r0=reg128#4,r0=q3,r1=reg128#2,r1=q1,> 26 +# asm 1: vshr.u64 >t4=reg128#3,t4=q2,r3=reg128#9,r3=q8,r4=reg128#3,r4=q2,> 26 +# asm 1: vshr.u64 >t2=reg128#10,t2=q9,r1=reg128#2,r1=q1,> 26 +# asm 1: vshr.u64 >t0=reg128#11,t0=q10,r2=reg128#10,r2=q9,r4=reg128#3,r4=q2,r0=reg128#4,r0=q3,t0=reg128#11,t0=q10,> 26 +# asm 1: vshr.u64 >t3=reg128#12,t3=q11,r0=reg128#4,r0=q3,x23=reg128#10,x23=q9,r3=reg128#9,r3=q8,> 26 +# asm 1: vshr.u64 >t1=reg128#11,t1=q10,x01=reg128#4,x01=q3,r1=reg128#2,r1=q1,> 26 +# asm 1: vshr.u64 >t4=reg128#11,t4=q10,r3=reg128#1,r3=q0,x4=reg128#3,x4=q2, + +// Raw AES functions. + + +// AES_MAXNR is the maximum number of AES rounds. +#define AES_MAXNR 14 + +// aes_key_st should be an opaque type, but EVP requires that the size be +// known. +struct aes_key_st { + uint32_t rd_key[4 * (AES_MAXNR + 1)]; + unsigned rounds; +}; +typedef struct aes_key_st AES_KEY; + +#endif // OPENSSL_HEADER_AES_H diff --git a/http/vendor/ring/include/ring-core/asm_base.h b/http/vendor/ring/include/ring-core/asm_base.h new file mode 100644 index 0000000..ef83326 --- /dev/null +++ b/http/vendor/ring/include/ring-core/asm_base.h @@ -0,0 +1,204 @@ +// Copyright 2023 The BoringSSL Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef OPENSSL_HEADER_ASM_BASE_H +#define OPENSSL_HEADER_ASM_BASE_H + +#include + + +// This header contains symbols and common sections used by assembly files. It +// is included as a public header to simplify the build, but is not intended for +// external use. +// +// Every assembly file must include this header. Some linker features require +// all object files to be tagged with some section metadata. This header file, +// when included in assembly, adds that metadata. It also makes defines like +// |OPENSSL_X86_64| available and includes the prefixing macros. +// +// Including this header in an assembly file imples: +// +// - The file does not require an executable stack. +// +// - The file, on aarch64, uses the macros defined below to be compatible with +// BTI and PAC. +// +// - The file, on x86_64, requires the program to be compatible with Intel IBT +// and SHSTK + +#if defined(__ASSEMBLER__) + +#include + +#if defined(__ELF__) +// Every ELF object file, even empty ones, should disable executable stacks. See +// https://www.airs.com/blog/archives/518. +.pushsection .note.GNU-stack, "", %progbits +.popsection +#endif + +#if defined(__CET__) && defined(OPENSSL_X86_64) +// Clang and GCC define __CET__ and provide when they support Intel's +// Indirect Branch Tracking. +// https://lpc.events/event/7/contributions/729/attachments/496/903/CET-LPC-2020.pdf +// +// cet.h defines _CET_ENDBR which is used to mark function entry points for IBT. +// and adds the assembly marker. The value of _CET_ENDBR is made dependant on if +// '-fcf-protection' is passed to the compiler. _CET_ENDBR is only required when +// the function is the target of an indirect jump, but BoringSSL chooses to mark +// all assembly entry points because it is easier, and allows BoringSSL's ABI +// tester to call the assembly entry points via an indirect jump. +#include +#else +#define _CET_ENDBR +#endif + +#if defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64) + +// We require the ARM assembler provide |__ARM_ARCH| from Arm C Language +// Extensions (ACLE). This is supported in GCC 4.8+ and Clang 3.2+. MSVC does +// not implement ACLE, but we require Clang's assembler on Windows. +#if !defined(__ARM_ARCH) +#error "ARM assembler must define __ARM_ARCH" +#endif + +// Even when building for 32-bit ARM, support for aarch64 crypto instructions +// will be included. +// +// TODO(davidben): Remove this and the corresponding ifdefs? This is only +// defined because some OpenSSL assembly files would allow disabling the NEON +// code entirely. I think we'd prefer to do that by lifting the dispatch to C +// anyway. +#define __ARM_MAX_ARCH__ 8 + +// Support macros for +// - Armv8.3-A Pointer Authentication and +// - Armv8.5-A Branch Target Identification +// features which require emitting a .note.gnu.property section with the +// appropriate architecture-dependent feature bits set. +// +// |AARCH64_SIGN_LINK_REGISTER| and |AARCH64_VALIDATE_LINK_REGISTER| expand to +// PACIxSP and AUTIxSP, respectively. |AARCH64_SIGN_LINK_REGISTER| should be +// used immediately before saving the LR register (x30) to the stack. +// |AARCH64_VALIDATE_LINK_REGISTER| should be used immediately after restoring +// it. Note |AARCH64_SIGN_LINK_REGISTER|'s modifications to LR must be undone +// with |AARCH64_VALIDATE_LINK_REGISTER| before RET. The SP register must also +// have the same value at the two points. For example: +// +// .global f +// f: +// AARCH64_SIGN_LINK_REGISTER +// stp x29, x30, [sp, #-96]! +// mov x29, sp +// ... +// ldp x29, x30, [sp], #96 +// AARCH64_VALIDATE_LINK_REGISTER +// ret +// +// |AARCH64_VALID_CALL_TARGET| expands to BTI 'c'. Either it, or +// |AARCH64_SIGN_LINK_REGISTER|, must be used at every point that may be an +// indirect call target. In particular, all symbols exported from a file must +// begin with one of these macros. For example, a leaf function that does not +// save LR can instead use |AARCH64_VALID_CALL_TARGET|: +// +// .globl return_zero +// return_zero: +// AARCH64_VALID_CALL_TARGET +// mov x0, #0 +// ret +// +// A non-leaf function which does not immediately save LR may need both macros +// because |AARCH64_SIGN_LINK_REGISTER| appears late. For example, the function +// may jump to an alternate implementation before setting up the stack: +// +// .globl with_early_jump +// with_early_jump: +// AARCH64_VALID_CALL_TARGET +// cmp x0, #128 +// b.lt .Lwith_early_jump_128 +// AARCH64_SIGN_LINK_REGISTER +// stp x29, x30, [sp, #-96]! +// mov x29, sp +// ... +// ldp x29, x30, [sp], #96 +// AARCH64_VALIDATE_LINK_REGISTER +// ret +// +// .Lwith_early_jump_128: +// ... +// ret +// +// These annotations are only required with indirect calls. Private symbols that +// are only the target of direct calls do not require annotations. Also note +// that |AARCH64_VALID_CALL_TARGET| is only valid for indirect calls (BLR), not +// indirect jumps (BR). Indirect jumps in assembly are currently not supported +// and would require a macro for BTI 'j'. +// +// Although not necessary, it is safe to use these macros in 32-bit ARM +// assembly. This may be used to simplify dual 32-bit and 64-bit files. +// +// References: +// - "ELF for the Arm® 64-bit Architecture" +// https://github.com/ARM-software/abi-aa/blob/master/aaelf64/aaelf64.rst +// - "Providing protection for complex software" +// https://developer.arm.com/architectures/learn-the-architecture/providing-protection-for-complex-software + +#if defined(__ARM_FEATURE_BTI_DEFAULT) && __ARM_FEATURE_BTI_DEFAULT == 1 +#define GNU_PROPERTY_AARCH64_BTI (1 << 0) // Has Branch Target Identification +#define AARCH64_VALID_CALL_TARGET hint #34 // BTI 'c' +#else +#define GNU_PROPERTY_AARCH64_BTI 0 // No Branch Target Identification +#define AARCH64_VALID_CALL_TARGET +#endif + +#if defined(__ARM_FEATURE_PAC_DEFAULT) && \ + (__ARM_FEATURE_PAC_DEFAULT & 1) == 1 // Signed with A-key +#define GNU_PROPERTY_AARCH64_POINTER_AUTH \ + (1 << 1) // Has Pointer Authentication +#define AARCH64_SIGN_LINK_REGISTER hint #25 // PACIASP +#define AARCH64_VALIDATE_LINK_REGISTER hint #29 // AUTIASP +#elif defined(__ARM_FEATURE_PAC_DEFAULT) && \ + (__ARM_FEATURE_PAC_DEFAULT & 2) == 2 // Signed with B-key +#define GNU_PROPERTY_AARCH64_POINTER_AUTH \ + (1 << 1) // Has Pointer Authentication +#define AARCH64_SIGN_LINK_REGISTER hint #27 // PACIBSP +#define AARCH64_VALIDATE_LINK_REGISTER hint #31 // AUTIBSP +#else +#define GNU_PROPERTY_AARCH64_POINTER_AUTH 0 // No Pointer Authentication +#if GNU_PROPERTY_AARCH64_BTI != 0 +#define AARCH64_SIGN_LINK_REGISTER AARCH64_VALID_CALL_TARGET +#else +#define AARCH64_SIGN_LINK_REGISTER +#endif +#define AARCH64_VALIDATE_LINK_REGISTER +#endif + +#if GNU_PROPERTY_AARCH64_POINTER_AUTH != 0 || GNU_PROPERTY_AARCH64_BTI != 0 +.pushsection .note.gnu.property, "a"; +.balign 8; +.long 4; +.long 0x10; +.long 0x5; +.asciz "GNU"; +.long 0xc0000000; /* GNU_PROPERTY_AARCH64_FEATURE_1_AND */ +.long 4; +.long (GNU_PROPERTY_AARCH64_POINTER_AUTH | GNU_PROPERTY_AARCH64_BTI); +.long 0; +.popsection; +#endif +#endif // ARM || AARCH64 + +#endif // __ASSEMBLER__ + +#endif // OPENSSL_HEADER_ASM_BASE_H diff --git a/http/vendor/ring/include/ring-core/base.h b/http/vendor/ring/include/ring-core/base.h new file mode 100644 index 0000000..d18a55e --- /dev/null +++ b/http/vendor/ring/include/ring-core/base.h @@ -0,0 +1,66 @@ +// Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef OPENSSL_HEADER_BASE_H +#define OPENSSL_HEADER_BASE_H + + +// This file should be the first included by all BoringSSL headers. + +#if defined(_MSC_VER) && !defined(__clang__) +#pragma warning(push, 3) +#endif + +#include +#include + +#if defined(_MSC_VER) && !defined(__clang__) +#pragma warning(pop) +#endif + +#if defined(__APPLE__) +#include +#endif + +#include // IWYU pragma: export + +#include + +#include + +#if defined(__APPLE__) +// Note |TARGET_OS_MAC| is set for all Apple OS variants. |TARGET_OS_OSX| +// targets macOS specifically. +#if defined(TARGET_OS_OSX) && TARGET_OS_OSX +#define OPENSSL_MACOS +#endif +#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE +#define OPENSSL_IOS +#endif +#endif + +// *ring* doesn't support the `BORINGSSL_SHARED_LIBRARY` configuration, so +// the default (usually "hidden") visibility is always used, even for exported +// items. +#define OPENSSL_EXPORT + +// `ring::c` would need to be customized on any platform where these assertions +// fail. Keep in sync with `ring::c`. +OPENSSL_STATIC_ASSERT(sizeof(int32_t) == sizeof(int), "int isn't 32 bits."); +OPENSSL_STATIC_ASSERT(sizeof(uint32_t) == sizeof(unsigned int), "unsigned int isn't 32 bits."); +OPENSSL_STATIC_ASSERT(sizeof(size_t) == sizeof(uintptr_t), "uintptr_t and size_t differ."); +OPENSSL_STATIC_ASSERT(sizeof(size_t) <= sizeof(uint64_t), "size_t is larger than uint64_t."); +OPENSSL_STATIC_ASSERT(sizeof(size_t) >= sizeof(uint32_t), "size_t is smaller than uint32_t."); + +#endif // OPENSSL_HEADER_BASE_H diff --git a/http/vendor/ring/include/ring-core/check.h b/http/vendor/ring/include/ring-core/check.h new file mode 100644 index 0000000..998289a --- /dev/null +++ b/http/vendor/ring/include/ring-core/check.h @@ -0,0 +1,52 @@ +// Copyright 2020 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#ifndef RING_CHECK_H +#define RING_CHECK_H + +// |debug_assert_nonsecret| is like |assert| and should be used (only) when the +// assertion does not have any potential to leak a secret. |NDEBUG| controls this +// exactly like |assert|. It is emulated when there is no assert.h to make +// cross-building easier. +// +// When reviewing uses of |debug_assert_nonsecret|, verify that the check +// really does not have potential to leak a secret. + +#if !defined(RING_CORE_NOSTDLIBINC) +# include +# define debug_assert_nonsecret(x) assert(x) +#else +# if !defined(NDEBUG) +# define debug_assert_nonsecret(x) ((x) ? ((void)0) : __builtin_trap()) +# else +# define debug_assert_nonsecret(x) ((void)0) +# endif +#endif + +// |dev_assert_secret| is like |assert| and should be used (only) when the +// assertion operates on secret data in a way that has the potential to leak +// the secret. |dev_assert_secret| can only be enabled by changing the |#if 0| +// here to |#if 1| (or equivalent) when |NDEBUG| is not defined. This is not +// controlled only through |NDEBUG| so that such checks do not leak into debug +// builds that may make it into production use. +// +// When reviewing uses of |dev_assert_secret|, verify that the check really +// does have the potential to leak a secret. +#if 0 // DO NOT COMMIT CHANGES TO THIS LINE. +# define dev_assert_secret debug_assert_nonsecret +#else +# define dev_assert_secret(x) ((void)0) +#endif + +#endif // RING_CHECK_H diff --git a/http/vendor/ring/include/ring-core/mem.h b/http/vendor/ring/include/ring-core/mem.h new file mode 100644 index 0000000..8f8f32e --- /dev/null +++ b/http/vendor/ring/include/ring-core/mem.h @@ -0,0 +1,27 @@ +// Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef OPENSSL_HEADER_MEM_H +#define OPENSSL_HEADER_MEM_H + +#include + +// CRYPTO_memcmp returns zero iff the |len| bytes at |a| and |b| are equal. It +// takes an amount of time dependent on |len|, but independent of the contents +// of |a| and |b|. Unlike memcmp, it cannot be used to put elements into a +// defined order as the return value when a != b is undefined, other than to be +// non-zero. +OPENSSL_EXPORT int CRYPTO_memcmp(const void *a, const void *b, size_t len); + +#endif // OPENSSL_HEADER_MEM_H diff --git a/http/vendor/ring/include/ring-core/target.h b/http/vendor/ring/include/ring-core/target.h new file mode 100644 index 0000000..fe40db7 --- /dev/null +++ b/http/vendor/ring/include/ring-core/target.h @@ -0,0 +1,97 @@ +// Copyright 2023 The BoringSSL Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef OPENSSL_HEADER_TARGET_H +#define OPENSSL_HEADER_TARGET_H + +// Preprocessor symbols that define the target platform. +// +// This file may be included in C, C++, and assembler and must be compatible +// with each environment. It is separated out only to share code between +// and . Prefer to include those headers +// instead. + +#if defined(__x86_64) || defined(_M_AMD64) || defined(_M_X64) +#define OPENSSL_64_BIT +#define OPENSSL_X86_64 +#elif defined(__x86) || defined(__i386) || defined(__i386__) || defined(_M_IX86) +#define OPENSSL_32_BIT +#define OPENSSL_X86 +#elif defined(__AARCH64EL__) || defined(_M_ARM64) +#define OPENSSL_64_BIT +#define OPENSSL_AARCH64 +#elif defined(__ARMEL__) || defined(_M_ARM) +#define OPENSSL_32_BIT +#define OPENSSL_ARM +// All of following architectures are only supported when `__BYTE_ORDER__` can be used to detect +// endianness (in crypto/internal.h). +#elif !defined(__BYTE_ORDER__) +#error "Cannot determine endianness because __BYTE_ORDER__ is not defined" +// Targets are assumed to be little-endian unless __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__. +#elif !(defined(__ORDER_LITTLE_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) && \ + !(defined(__ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)) +#error "Unsupported endianness" +#elif defined(__LP64__) +#define OPENSSL_64_BIT +#elif defined(__ILP32__) +#define OPENSSL_32_BIT +// Versions of GCC before 10.0 didn't define `__ILP32__` for all 32-bit targets. +#elif defined(__MIPSEL__) || defined(__MIPSEB__) || defined(__PPC__) || defined(__powerpc__) || defined(__csky__) || defined(__XTENSA__) +#define OPENSSL_32_BIT +#else +#error "Unknown target CPU" +#endif + +#if defined(__APPLE__) +#define OPENSSL_APPLE +#endif + +#if defined(_WIN32) +#define OPENSSL_WINDOWS +#endif + +#if defined(__has_feature) +#if __has_feature(address_sanitizer) +#define OPENSSL_ASAN +#endif +#if __has_feature(thread_sanitizer) +#define OPENSSL_TSAN +#endif +#if __has_feature(memory_sanitizer) +#define OPENSSL_MSAN +#define OPENSSL_ASM_INCOMPATIBLE +#endif +#if __has_feature(hwaddress_sanitizer) +#define OPENSSL_HWASAN +#endif +#endif + +// Disable 32-bit Arm assembly on Apple platforms. The last iOS version that +// supported 32-bit Arm was iOS 10. +#if defined(OPENSSL_APPLE) && defined(OPENSSL_ARM) +#define OPENSSL_ASM_INCOMPATIBLE +#endif + +#if defined(OPENSSL_ASM_INCOMPATIBLE) +#undef OPENSSL_ASM_INCOMPATIBLE +#if !defined(OPENSSL_NO_ASM) +#define OPENSSL_NO_ASM +#endif +#endif // OPENSSL_ASM_INCOMPATIBLE + +#if !defined(OPENSSL_X86_64) && !defined(OPENSSL_AARCH64) +#define OPENSSL_SMALL +#endif + +#endif // OPENSSL_HEADER_TARGET_H diff --git a/http/vendor/ring/include/ring-core/type_check.h b/http/vendor/ring/include/ring-core/type_check.h new file mode 100644 index 0000000..532fc8e --- /dev/null +++ b/http/vendor/ring/include/ring-core/type_check.h @@ -0,0 +1,32 @@ +// Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef OPENSSL_HEADER_TYPE_CHECK_H +#define OPENSSL_HEADER_TYPE_CHECK_H + +#include + + +#if defined(__cplusplus) || (defined(_MSC_VER) && !defined(__clang__)) +// In C++ and non-clang MSVC, |static_assert| is a keyword. +#define OPENSSL_STATIC_ASSERT(cond, msg) static_assert(cond, msg) +#else +// C11 defines the |_Static_assert| keyword and the |static_assert| macro in +// assert.h. While the former is available at all versions in Clang and GCC, the +// later depends on libc and, in glibc, depends on being built in C11 mode. We +// do not require this, for now, so use |_Static_assert| directly. +#define OPENSSL_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg) +#endif + +#endif // OPENSSL_HEADER_TYPE_CHECK_H diff --git a/http/vendor/ring/pregenerated/aes-gcm-avx2-x86_64-elf.S b/http/vendor/ring/pregenerated/aes-gcm-avx2-x86_64-elf.S new file mode 100644 index 0000000..597264b --- /dev/null +++ b/http/vendor/ring/pregenerated/aes-gcm-avx2-x86_64-elf.S @@ -0,0 +1,1172 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__) +.section .rodata +.align 16 + + +.Lbswap_mask: +.quad 0x08090a0b0c0d0e0f, 0x0001020304050607 + + + + + + + + +.Lgfpoly: +.quad 1, 0xc200000000000000 + + +.Lgfpoly_and_internal_carrybit: +.quad 1, 0xc200000000000001 + +.align 32 + +.Lctr_pattern: +.quad 0, 0 +.quad 1, 0 +.Linc_2blocks: +.quad 2, 0 +.quad 2, 0 + +.text +.globl gcm_init_vpclmulqdq_avx2 +.hidden gcm_init_vpclmulqdq_avx2 +.type gcm_init_vpclmulqdq_avx2,@function +.align 32 +gcm_init_vpclmulqdq_avx2: +.cfi_startproc + +_CET_ENDBR + + + + + + vpshufd $0x4e,(%rsi),%xmm3 + + + + + + vpshufd $0xd3,%xmm3,%xmm0 + vpsrad $31,%xmm0,%xmm0 + vpaddq %xmm3,%xmm3,%xmm3 + vpand .Lgfpoly_and_internal_carrybit(%rip),%xmm0,%xmm0 + vpxor %xmm0,%xmm3,%xmm3 + + vbroadcasti128 .Lgfpoly(%rip),%ymm6 + + + vpclmulqdq $0x00,%xmm3,%xmm3,%xmm0 + vpclmulqdq $0x01,%xmm3,%xmm3,%xmm1 + vpclmulqdq $0x10,%xmm3,%xmm3,%xmm2 + vpxor %xmm2,%xmm1,%xmm1 + vpclmulqdq $0x01,%xmm0,%xmm6,%xmm2 + vpshufd $0x4e,%xmm0,%xmm0 + vpxor %xmm0,%xmm1,%xmm1 + vpxor %xmm2,%xmm1,%xmm1 + vpclmulqdq $0x11,%xmm3,%xmm3,%xmm5 + vpclmulqdq $0x01,%xmm1,%xmm6,%xmm0 + vpshufd $0x4e,%xmm1,%xmm1 + vpxor %xmm1,%xmm5,%xmm5 + vpxor %xmm0,%xmm5,%xmm5 + + + + vinserti128 $1,%xmm3,%ymm5,%ymm3 + vinserti128 $1,%xmm5,%ymm5,%ymm5 + + +.byte 0xc4,0xe3,0x65,0x44,0xc5,0x00 +.byte 0xc4,0xe3,0x65,0x44,0xcd,0x01 +.byte 0xc4,0xe3,0x65,0x44,0xd5,0x10 + vpxor %ymm2,%ymm1,%ymm1 +.byte 0xc4,0xe3,0x4d,0x44,0xd0,0x01 + vpshufd $0x4e,%ymm0,%ymm0 + vpxor %ymm0,%ymm1,%ymm1 + vpxor %ymm2,%ymm1,%ymm1 +.byte 0xc4,0xe3,0x65,0x44,0xe5,0x11 +.byte 0xc4,0xe3,0x4d,0x44,0xc1,0x01 + vpshufd $0x4e,%ymm1,%ymm1 + vpxor %ymm1,%ymm4,%ymm4 + vpxor %ymm0,%ymm4,%ymm4 + + + + vmovdqu %ymm3,96(%rdi) + vmovdqu %ymm4,64(%rdi) + + + + vpunpcklqdq %ymm3,%ymm4,%ymm0 + vpunpckhqdq %ymm3,%ymm4,%ymm1 + vpxor %ymm1,%ymm0,%ymm0 + vmovdqu %ymm0,128+32(%rdi) + + +.byte 0xc4,0xe3,0x5d,0x44,0xc5,0x00 +.byte 0xc4,0xe3,0x5d,0x44,0xcd,0x01 +.byte 0xc4,0xe3,0x5d,0x44,0xd5,0x10 + vpxor %ymm2,%ymm1,%ymm1 +.byte 0xc4,0xe3,0x4d,0x44,0xd0,0x01 + vpshufd $0x4e,%ymm0,%ymm0 + vpxor %ymm0,%ymm1,%ymm1 + vpxor %ymm2,%ymm1,%ymm1 +.byte 0xc4,0xe3,0x5d,0x44,0xdd,0x11 +.byte 0xc4,0xe3,0x4d,0x44,0xc1,0x01 + vpshufd $0x4e,%ymm1,%ymm1 + vpxor %ymm1,%ymm3,%ymm3 + vpxor %ymm0,%ymm3,%ymm3 + +.byte 0xc4,0xe3,0x65,0x44,0xc5,0x00 +.byte 0xc4,0xe3,0x65,0x44,0xcd,0x01 +.byte 0xc4,0xe3,0x65,0x44,0xd5,0x10 + vpxor %ymm2,%ymm1,%ymm1 +.byte 0xc4,0xe3,0x4d,0x44,0xd0,0x01 + vpshufd $0x4e,%ymm0,%ymm0 + vpxor %ymm0,%ymm1,%ymm1 + vpxor %ymm2,%ymm1,%ymm1 +.byte 0xc4,0xe3,0x65,0x44,0xe5,0x11 +.byte 0xc4,0xe3,0x4d,0x44,0xc1,0x01 + vpshufd $0x4e,%ymm1,%ymm1 + vpxor %ymm1,%ymm4,%ymm4 + vpxor %ymm0,%ymm4,%ymm4 + + vmovdqu %ymm3,32(%rdi) + vmovdqu %ymm4,0(%rdi) + + + + vpunpcklqdq %ymm3,%ymm4,%ymm0 + vpunpckhqdq %ymm3,%ymm4,%ymm1 + vpxor %ymm1,%ymm0,%ymm0 + vmovdqu %ymm0,128(%rdi) + + vzeroupper + ret + +.cfi_endproc +.size gcm_init_vpclmulqdq_avx2, . - gcm_init_vpclmulqdq_avx2 +.globl gcm_ghash_vpclmulqdq_avx2_1 +.hidden gcm_ghash_vpclmulqdq_avx2_1 +.type gcm_ghash_vpclmulqdq_avx2_1,@function +.align 32 +gcm_ghash_vpclmulqdq_avx2_1: +.cfi_startproc + +_CET_ENDBR + + + + + + + vmovdqu .Lbswap_mask(%rip),%xmm6 + vmovdqu .Lgfpoly(%rip),%xmm7 + + + vmovdqu (%rdi),%xmm5 + vpshufb %xmm6,%xmm5,%xmm5 + + + +.Lghash_lastblock: + vmovdqu (%rdx),%xmm0 + vpshufb %xmm6,%xmm0,%xmm0 + vpxor %xmm0,%xmm5,%xmm5 + vmovdqu 128-16(%rsi),%xmm0 + vpclmulqdq $0x00,%xmm0,%xmm5,%xmm1 + vpclmulqdq $0x01,%xmm0,%xmm5,%xmm2 + vpclmulqdq $0x10,%xmm0,%xmm5,%xmm3 + vpxor %xmm3,%xmm2,%xmm2 + vpclmulqdq $0x01,%xmm1,%xmm7,%xmm3 + vpshufd $0x4e,%xmm1,%xmm1 + vpxor %xmm1,%xmm2,%xmm2 + vpxor %xmm3,%xmm2,%xmm2 + vpclmulqdq $0x11,%xmm0,%xmm5,%xmm5 + vpclmulqdq $0x01,%xmm2,%xmm7,%xmm1 + vpshufd $0x4e,%xmm2,%xmm2 + vpxor %xmm2,%xmm5,%xmm5 + vpxor %xmm1,%xmm5,%xmm5 + + +.Lghash_done: + + vpshufb %xmm6,%xmm5,%xmm5 + vmovdqu %xmm5,(%rdi) + + vzeroupper + ret + +.cfi_endproc +.size gcm_ghash_vpclmulqdq_avx2_1, . - gcm_ghash_vpclmulqdq_avx2_1 +.globl aes_gcm_enc_update_vaes_avx2 +.hidden aes_gcm_enc_update_vaes_avx2 +.type aes_gcm_enc_update_vaes_avx2,@function +.align 32 +aes_gcm_enc_update_vaes_avx2: +.cfi_startproc + +_CET_ENDBR + pushq %r12 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r12,-16 + + movq 16(%rsp),%r12 +#ifdef BORINGSSL_DISPATCH_TEST +.extern BORINGSSL_function_hit +.hidden BORINGSSL_function_hit + movb $1,BORINGSSL_function_hit+8(%rip) +#endif + vbroadcasti128 .Lbswap_mask(%rip),%ymm0 + + + + vmovdqu (%r12),%xmm1 + vpshufb %xmm0,%xmm1,%xmm1 + vbroadcasti128 (%r8),%ymm11 + vpshufb %ymm0,%ymm11,%ymm11 + + + + movl 240(%rcx),%r10d + leal -20(,%r10,4),%r10d + + + + + leaq 96(%rcx,%r10,4),%r11 + vbroadcasti128 (%rcx),%ymm9 + vbroadcasti128 (%r11),%ymm10 + + + vpaddd .Lctr_pattern(%rip),%ymm11,%ymm11 + + + + cmpq $127,%rdx + jbe .Lcrypt_loop_4x_done__func1 + + vmovdqu 128(%r9),%ymm7 + vmovdqu 128+32(%r9),%ymm8 + + + + vmovdqu .Linc_2blocks(%rip),%ymm2 + vpshufb %ymm0,%ymm11,%ymm12 + vpaddd %ymm2,%ymm11,%ymm11 + vpshufb %ymm0,%ymm11,%ymm13 + vpaddd %ymm2,%ymm11,%ymm11 + vpshufb %ymm0,%ymm11,%ymm14 + vpaddd %ymm2,%ymm11,%ymm11 + vpshufb %ymm0,%ymm11,%ymm15 + vpaddd %ymm2,%ymm11,%ymm11 + + + vpxor %ymm9,%ymm12,%ymm12 + vpxor %ymm9,%ymm13,%ymm13 + vpxor %ymm9,%ymm14,%ymm14 + vpxor %ymm9,%ymm15,%ymm15 + + leaq 16(%rcx),%rax +.Lvaesenc_loop_first_4_vecs__func1: + vbroadcasti128 (%rax),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + addq $16,%rax + cmpq %rax,%r11 + jne .Lvaesenc_loop_first_4_vecs__func1 + vpxor 0(%rdi),%ymm10,%ymm2 + vpxor 32(%rdi),%ymm10,%ymm3 + vpxor 64(%rdi),%ymm10,%ymm5 + vpxor 96(%rdi),%ymm10,%ymm6 +.byte 0xc4,0x62,0x1d,0xdd,0xe2 +.byte 0xc4,0x62,0x15,0xdd,0xeb +.byte 0xc4,0x62,0x0d,0xdd,0xf5 +.byte 0xc4,0x62,0x05,0xdd,0xfe + vmovdqu %ymm12,0(%rsi) + vmovdqu %ymm13,32(%rsi) + vmovdqu %ymm14,64(%rsi) + vmovdqu %ymm15,96(%rsi) + + subq $-128,%rdi + addq $-128,%rdx + cmpq $127,%rdx + jbe .Lghash_last_ciphertext_4x__func1 +.align 16 +.Lcrypt_loop_4x__func1: + + + + + vmovdqu .Linc_2blocks(%rip),%ymm2 + vpshufb %ymm0,%ymm11,%ymm12 + vpaddd %ymm2,%ymm11,%ymm11 + vpshufb %ymm0,%ymm11,%ymm13 + vpaddd %ymm2,%ymm11,%ymm11 + vpshufb %ymm0,%ymm11,%ymm14 + vpaddd %ymm2,%ymm11,%ymm11 + vpshufb %ymm0,%ymm11,%ymm15 + vpaddd %ymm2,%ymm11,%ymm11 + + + vpxor %ymm9,%ymm12,%ymm12 + vpxor %ymm9,%ymm13,%ymm13 + vpxor %ymm9,%ymm14,%ymm14 + vpxor %ymm9,%ymm15,%ymm15 + + cmpl $24,%r10d + jl .Laes128__func1 + je .Laes192__func1 + + vbroadcasti128 -208(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + vbroadcasti128 -192(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + +.Laes192__func1: + vbroadcasti128 -176(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + vbroadcasti128 -160(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + +.Laes128__func1: + prefetcht0 512(%rdi) + prefetcht0 512+64(%rdi) + + vmovdqu 0(%rsi),%ymm3 + vpshufb %ymm0,%ymm3,%ymm3 + vmovdqu 0(%r9),%ymm4 + vpxor %ymm1,%ymm3,%ymm3 +.byte 0xc4,0xe3,0x65,0x44,0xec,0x00 +.byte 0xc4,0xe3,0x65,0x44,0xcc,0x11 + vpunpckhqdq %ymm3,%ymm3,%ymm2 + vpxor %ymm3,%ymm2,%ymm2 +.byte 0xc4,0xe3,0x6d,0x44,0xf7,0x00 + + vbroadcasti128 -144(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + + vbroadcasti128 -128(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + + vmovdqu 32(%rsi),%ymm3 + vpshufb %ymm0,%ymm3,%ymm3 + vmovdqu 32(%r9),%ymm4 +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x00 + vpxor %ymm2,%ymm5,%ymm5 +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x11 + vpxor %ymm2,%ymm1,%ymm1 + vpunpckhqdq %ymm3,%ymm3,%ymm2 + vpxor %ymm3,%ymm2,%ymm2 +.byte 0xc4,0xe3,0x6d,0x44,0xd7,0x10 + vpxor %ymm2,%ymm6,%ymm6 + + vbroadcasti128 -112(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + + vmovdqu 64(%rsi),%ymm3 + vpshufb %ymm0,%ymm3,%ymm3 + vmovdqu 64(%r9),%ymm4 + + vbroadcasti128 -96(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x00 + vpxor %ymm2,%ymm5,%ymm5 +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x11 + vpxor %ymm2,%ymm1,%ymm1 + + vbroadcasti128 -80(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + vpunpckhqdq %ymm3,%ymm3,%ymm2 + vpxor %ymm3,%ymm2,%ymm2 +.byte 0xc4,0xc3,0x6d,0x44,0xd0,0x00 + vpxor %ymm2,%ymm6,%ymm6 + + + vmovdqu 96(%rsi),%ymm3 + vpshufb %ymm0,%ymm3,%ymm3 + + vbroadcasti128 -64(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + vmovdqu 96(%r9),%ymm4 +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x00 + vpxor %ymm2,%ymm5,%ymm5 +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x11 + vpxor %ymm2,%ymm1,%ymm1 + vpunpckhqdq %ymm3,%ymm3,%ymm2 + vpxor %ymm3,%ymm2,%ymm2 +.byte 0xc4,0xc3,0x6d,0x44,0xd0,0x10 + vpxor %ymm2,%ymm6,%ymm6 + + vbroadcasti128 -48(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + + vpxor %ymm5,%ymm6,%ymm6 + vpxor %ymm1,%ymm6,%ymm6 + + + vbroadcasti128 .Lgfpoly(%rip),%ymm4 +.byte 0xc4,0xe3,0x5d,0x44,0xd5,0x01 + vpshufd $0x4e,%ymm5,%ymm5 + vpxor %ymm5,%ymm6,%ymm6 + vpxor %ymm2,%ymm6,%ymm6 + + vbroadcasti128 -32(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + +.byte 0xc4,0xe3,0x5d,0x44,0xd6,0x01 + vpshufd $0x4e,%ymm6,%ymm6 + vpxor %ymm6,%ymm1,%ymm1 + vpxor %ymm2,%ymm1,%ymm1 + + vbroadcasti128 -16(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + vextracti128 $1,%ymm1,%xmm2 + vpxor %xmm2,%xmm1,%xmm1 + + + subq $-128,%rsi + vpxor 0(%rdi),%ymm10,%ymm2 + vpxor 32(%rdi),%ymm10,%ymm3 + vpxor 64(%rdi),%ymm10,%ymm5 + vpxor 96(%rdi),%ymm10,%ymm6 +.byte 0xc4,0x62,0x1d,0xdd,0xe2 +.byte 0xc4,0x62,0x15,0xdd,0xeb +.byte 0xc4,0x62,0x0d,0xdd,0xf5 +.byte 0xc4,0x62,0x05,0xdd,0xfe + vmovdqu %ymm12,0(%rsi) + vmovdqu %ymm13,32(%rsi) + vmovdqu %ymm14,64(%rsi) + vmovdqu %ymm15,96(%rsi) + + subq $-128,%rdi + + addq $-128,%rdx + cmpq $127,%rdx + ja .Lcrypt_loop_4x__func1 +.Lghash_last_ciphertext_4x__func1: + + vmovdqu 0(%rsi),%ymm3 + vpshufb %ymm0,%ymm3,%ymm3 + vmovdqu 0(%r9),%ymm4 + vpxor %ymm1,%ymm3,%ymm3 +.byte 0xc4,0xe3,0x65,0x44,0xec,0x00 +.byte 0xc4,0xe3,0x65,0x44,0xcc,0x11 + vpunpckhqdq %ymm3,%ymm3,%ymm2 + vpxor %ymm3,%ymm2,%ymm2 +.byte 0xc4,0xe3,0x6d,0x44,0xf7,0x00 + + vmovdqu 32(%rsi),%ymm3 + vpshufb %ymm0,%ymm3,%ymm3 + vmovdqu 32(%r9),%ymm4 +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x00 + vpxor %ymm2,%ymm5,%ymm5 +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x11 + vpxor %ymm2,%ymm1,%ymm1 + vpunpckhqdq %ymm3,%ymm3,%ymm2 + vpxor %ymm3,%ymm2,%ymm2 +.byte 0xc4,0xe3,0x6d,0x44,0xd7,0x10 + vpxor %ymm2,%ymm6,%ymm6 + + vmovdqu 64(%rsi),%ymm3 + vpshufb %ymm0,%ymm3,%ymm3 + vmovdqu 64(%r9),%ymm4 +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x00 + vpxor %ymm2,%ymm5,%ymm5 +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x11 + vpxor %ymm2,%ymm1,%ymm1 + vpunpckhqdq %ymm3,%ymm3,%ymm2 + vpxor %ymm3,%ymm2,%ymm2 +.byte 0xc4,0xc3,0x6d,0x44,0xd0,0x00 + vpxor %ymm2,%ymm6,%ymm6 + + + vmovdqu 96(%rsi),%ymm3 + vpshufb %ymm0,%ymm3,%ymm3 + vmovdqu 96(%r9),%ymm4 +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x00 + vpxor %ymm2,%ymm5,%ymm5 +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x11 + vpxor %ymm2,%ymm1,%ymm1 + vpunpckhqdq %ymm3,%ymm3,%ymm2 + vpxor %ymm3,%ymm2,%ymm2 +.byte 0xc4,0xc3,0x6d,0x44,0xd0,0x10 + vpxor %ymm2,%ymm6,%ymm6 + + vpxor %ymm5,%ymm6,%ymm6 + vpxor %ymm1,%ymm6,%ymm6 + + + vbroadcasti128 .Lgfpoly(%rip),%ymm4 +.byte 0xc4,0xe3,0x5d,0x44,0xd5,0x01 + vpshufd $0x4e,%ymm5,%ymm5 + vpxor %ymm5,%ymm6,%ymm6 + vpxor %ymm2,%ymm6,%ymm6 + +.byte 0xc4,0xe3,0x5d,0x44,0xd6,0x01 + vpshufd $0x4e,%ymm6,%ymm6 + vpxor %ymm6,%ymm1,%ymm1 + vpxor %ymm2,%ymm1,%ymm1 + vextracti128 $1,%ymm1,%xmm2 + vpxor %xmm2,%xmm1,%xmm1 + + subq $-128,%rsi +.Lcrypt_loop_4x_done__func1: + + testq %rdx,%rdx + jz .Ldone__func1 + + + + + + leaq 128(%r9),%r8 + subq %rdx,%r8 + + + vpxor %xmm5,%xmm5,%xmm5 + vpxor %xmm6,%xmm6,%xmm6 + vpxor %xmm7,%xmm7,%xmm7 + + cmpq $64,%rdx + jb .Llessthan64bytes__func1 + + + vpshufb %ymm0,%ymm11,%ymm12 + vpaddd .Linc_2blocks(%rip),%ymm11,%ymm11 + vpshufb %ymm0,%ymm11,%ymm13 + vpaddd .Linc_2blocks(%rip),%ymm11,%ymm11 + vpxor %ymm9,%ymm12,%ymm12 + vpxor %ymm9,%ymm13,%ymm13 + leaq 16(%rcx),%rax +.Lvaesenc_loop_tail_1__func1: + vbroadcasti128 (%rax),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea + addq $16,%rax + cmpq %rax,%r11 + jne .Lvaesenc_loop_tail_1__func1 +.byte 0xc4,0x42,0x1d,0xdd,0xe2 +.byte 0xc4,0x42,0x15,0xdd,0xea + + + vmovdqu 0(%rdi),%ymm2 + vmovdqu 32(%rdi),%ymm3 + vpxor %ymm2,%ymm12,%ymm12 + vpxor %ymm3,%ymm13,%ymm13 + vmovdqu %ymm12,0(%rsi) + vmovdqu %ymm13,32(%rsi) + + + vpshufb %ymm0,%ymm12,%ymm12 + vpshufb %ymm0,%ymm13,%ymm13 + vpxor %ymm1,%ymm12,%ymm12 + vmovdqu (%r8),%ymm2 + vmovdqu 32(%r8),%ymm3 +.byte 0xc4,0xe3,0x1d,0x44,0xea,0x00 +.byte 0xc4,0xe3,0x1d,0x44,0xf2,0x01 +.byte 0xc4,0xe3,0x1d,0x44,0xe2,0x10 + vpxor %ymm4,%ymm6,%ymm6 +.byte 0xc4,0xe3,0x1d,0x44,0xfa,0x11 +.byte 0xc4,0xe3,0x15,0x44,0xe3,0x00 + vpxor %ymm4,%ymm5,%ymm5 +.byte 0xc4,0xe3,0x15,0x44,0xe3,0x01 + vpxor %ymm4,%ymm6,%ymm6 +.byte 0xc4,0xe3,0x15,0x44,0xe3,0x10 + vpxor %ymm4,%ymm6,%ymm6 +.byte 0xc4,0xe3,0x15,0x44,0xe3,0x11 + vpxor %ymm4,%ymm7,%ymm7 + + addq $64,%r8 + addq $64,%rdi + addq $64,%rsi + subq $64,%rdx + jz .Lreduce__func1 + + vpxor %xmm1,%xmm1,%xmm1 + + +.Llessthan64bytes__func1: + vpshufb %ymm0,%ymm11,%ymm12 + vpaddd .Linc_2blocks(%rip),%ymm11,%ymm11 + vpshufb %ymm0,%ymm11,%ymm13 + vpxor %ymm9,%ymm12,%ymm12 + vpxor %ymm9,%ymm13,%ymm13 + leaq 16(%rcx),%rax +.Lvaesenc_loop_tail_2__func1: + vbroadcasti128 (%rax),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea + addq $16,%rax + cmpq %rax,%r11 + jne .Lvaesenc_loop_tail_2__func1 +.byte 0xc4,0x42,0x1d,0xdd,0xe2 +.byte 0xc4,0x42,0x15,0xdd,0xea + + + + + cmpq $32,%rdx + jb .Lxor_one_block__func1 + je .Lxor_two_blocks__func1 + +.Lxor_three_blocks__func1: + vmovdqu 0(%rdi),%ymm2 + vmovdqu 32(%rdi),%xmm3 + vpxor %ymm2,%ymm12,%ymm12 + vpxor %xmm3,%xmm13,%xmm13 + vmovdqu %ymm12,0(%rsi) + vmovdqu %xmm13,32(%rsi) + + vpshufb %ymm0,%ymm12,%ymm12 + vpshufb %xmm0,%xmm13,%xmm13 + vpxor %ymm1,%ymm12,%ymm12 + vmovdqu (%r8),%ymm2 + vmovdqu 32(%r8),%xmm3 + vpclmulqdq $0x00,%xmm3,%xmm13,%xmm4 + vpxor %ymm4,%ymm5,%ymm5 + vpclmulqdq $0x01,%xmm3,%xmm13,%xmm4 + vpxor %ymm4,%ymm6,%ymm6 + vpclmulqdq $0x10,%xmm3,%xmm13,%xmm4 + vpxor %ymm4,%ymm6,%ymm6 + vpclmulqdq $0x11,%xmm3,%xmm13,%xmm4 + vpxor %ymm4,%ymm7,%ymm7 + jmp .Lghash_mul_one_vec_unreduced__func1 + +.Lxor_two_blocks__func1: + vmovdqu (%rdi),%ymm2 + vpxor %ymm2,%ymm12,%ymm12 + vmovdqu %ymm12,(%rsi) + vpshufb %ymm0,%ymm12,%ymm12 + vpxor %ymm1,%ymm12,%ymm12 + vmovdqu (%r8),%ymm2 + jmp .Lghash_mul_one_vec_unreduced__func1 + +.Lxor_one_block__func1: + vmovdqu (%rdi),%xmm2 + vpxor %xmm2,%xmm12,%xmm12 + vmovdqu %xmm12,(%rsi) + vpshufb %xmm0,%xmm12,%xmm12 + vpxor %xmm1,%xmm12,%xmm12 + vmovdqu (%r8),%xmm2 + +.Lghash_mul_one_vec_unreduced__func1: +.byte 0xc4,0xe3,0x1d,0x44,0xe2,0x00 + vpxor %ymm4,%ymm5,%ymm5 +.byte 0xc4,0xe3,0x1d,0x44,0xe2,0x01 + vpxor %ymm4,%ymm6,%ymm6 +.byte 0xc4,0xe3,0x1d,0x44,0xe2,0x10 + vpxor %ymm4,%ymm6,%ymm6 +.byte 0xc4,0xe3,0x1d,0x44,0xe2,0x11 + vpxor %ymm4,%ymm7,%ymm7 + +.Lreduce__func1: + + vbroadcasti128 .Lgfpoly(%rip),%ymm2 +.byte 0xc4,0xe3,0x6d,0x44,0xdd,0x01 + vpshufd $0x4e,%ymm5,%ymm5 + vpxor %ymm5,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 +.byte 0xc4,0xe3,0x6d,0x44,0xde,0x01 + vpshufd $0x4e,%ymm6,%ymm6 + vpxor %ymm6,%ymm7,%ymm7 + vpxor %ymm3,%ymm7,%ymm7 + vextracti128 $1,%ymm7,%xmm1 + vpxor %xmm7,%xmm1,%xmm1 + +.Ldone__func1: + + vpshufb %xmm0,%xmm1,%xmm1 + vmovdqu %xmm1,(%r12) + + vzeroupper + popq %r12 +.cfi_adjust_cfa_offset -8 +.cfi_restore %r12 + ret + +.cfi_endproc +.size aes_gcm_enc_update_vaes_avx2, . - aes_gcm_enc_update_vaes_avx2 +.globl aes_gcm_dec_update_vaes_avx2 +.hidden aes_gcm_dec_update_vaes_avx2 +.type aes_gcm_dec_update_vaes_avx2,@function +.align 32 +aes_gcm_dec_update_vaes_avx2: +.cfi_startproc + +_CET_ENDBR + pushq %r12 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r12,-16 + + movq 16(%rsp),%r12 + vbroadcasti128 .Lbswap_mask(%rip),%ymm0 + + + + vmovdqu (%r12),%xmm1 + vpshufb %xmm0,%xmm1,%xmm1 + vbroadcasti128 (%r8),%ymm11 + vpshufb %ymm0,%ymm11,%ymm11 + + + + movl 240(%rcx),%r10d + leal -20(,%r10,4),%r10d + + + + + leaq 96(%rcx,%r10,4),%r11 + vbroadcasti128 (%rcx),%ymm9 + vbroadcasti128 (%r11),%ymm10 + + + vpaddd .Lctr_pattern(%rip),%ymm11,%ymm11 + + + + cmpq $127,%rdx + jbe .Lcrypt_loop_4x_done__func2 + + vmovdqu 128(%r9),%ymm7 + vmovdqu 128+32(%r9),%ymm8 +.align 16 +.Lcrypt_loop_4x__func2: + + + + + vmovdqu .Linc_2blocks(%rip),%ymm2 + vpshufb %ymm0,%ymm11,%ymm12 + vpaddd %ymm2,%ymm11,%ymm11 + vpshufb %ymm0,%ymm11,%ymm13 + vpaddd %ymm2,%ymm11,%ymm11 + vpshufb %ymm0,%ymm11,%ymm14 + vpaddd %ymm2,%ymm11,%ymm11 + vpshufb %ymm0,%ymm11,%ymm15 + vpaddd %ymm2,%ymm11,%ymm11 + + + vpxor %ymm9,%ymm12,%ymm12 + vpxor %ymm9,%ymm13,%ymm13 + vpxor %ymm9,%ymm14,%ymm14 + vpxor %ymm9,%ymm15,%ymm15 + + cmpl $24,%r10d + jl .Laes128__func2 + je .Laes192__func2 + + vbroadcasti128 -208(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + vbroadcasti128 -192(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + +.Laes192__func2: + vbroadcasti128 -176(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + vbroadcasti128 -160(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + +.Laes128__func2: + prefetcht0 512(%rdi) + prefetcht0 512+64(%rdi) + + vmovdqu 0(%rdi),%ymm3 + vpshufb %ymm0,%ymm3,%ymm3 + vmovdqu 0(%r9),%ymm4 + vpxor %ymm1,%ymm3,%ymm3 +.byte 0xc4,0xe3,0x65,0x44,0xec,0x00 +.byte 0xc4,0xe3,0x65,0x44,0xcc,0x11 + vpunpckhqdq %ymm3,%ymm3,%ymm2 + vpxor %ymm3,%ymm2,%ymm2 +.byte 0xc4,0xe3,0x6d,0x44,0xf7,0x00 + + vbroadcasti128 -144(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + + vbroadcasti128 -128(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + + vmovdqu 32(%rdi),%ymm3 + vpshufb %ymm0,%ymm3,%ymm3 + vmovdqu 32(%r9),%ymm4 +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x00 + vpxor %ymm2,%ymm5,%ymm5 +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x11 + vpxor %ymm2,%ymm1,%ymm1 + vpunpckhqdq %ymm3,%ymm3,%ymm2 + vpxor %ymm3,%ymm2,%ymm2 +.byte 0xc4,0xe3,0x6d,0x44,0xd7,0x10 + vpxor %ymm2,%ymm6,%ymm6 + + vbroadcasti128 -112(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + + vmovdqu 64(%rdi),%ymm3 + vpshufb %ymm0,%ymm3,%ymm3 + vmovdqu 64(%r9),%ymm4 + + vbroadcasti128 -96(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x00 + vpxor %ymm2,%ymm5,%ymm5 +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x11 + vpxor %ymm2,%ymm1,%ymm1 + + vbroadcasti128 -80(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + vpunpckhqdq %ymm3,%ymm3,%ymm2 + vpxor %ymm3,%ymm2,%ymm2 +.byte 0xc4,0xc3,0x6d,0x44,0xd0,0x00 + vpxor %ymm2,%ymm6,%ymm6 + + + vmovdqu 96(%rdi),%ymm3 + vpshufb %ymm0,%ymm3,%ymm3 + + vbroadcasti128 -64(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + vmovdqu 96(%r9),%ymm4 +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x00 + vpxor %ymm2,%ymm5,%ymm5 +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x11 + vpxor %ymm2,%ymm1,%ymm1 + vpunpckhqdq %ymm3,%ymm3,%ymm2 + vpxor %ymm3,%ymm2,%ymm2 +.byte 0xc4,0xc3,0x6d,0x44,0xd0,0x10 + vpxor %ymm2,%ymm6,%ymm6 + + vbroadcasti128 -48(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + + vpxor %ymm5,%ymm6,%ymm6 + vpxor %ymm1,%ymm6,%ymm6 + + + vbroadcasti128 .Lgfpoly(%rip),%ymm4 +.byte 0xc4,0xe3,0x5d,0x44,0xd5,0x01 + vpshufd $0x4e,%ymm5,%ymm5 + vpxor %ymm5,%ymm6,%ymm6 + vpxor %ymm2,%ymm6,%ymm6 + + vbroadcasti128 -32(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + +.byte 0xc4,0xe3,0x5d,0x44,0xd6,0x01 + vpshufd $0x4e,%ymm6,%ymm6 + vpxor %ymm6,%ymm1,%ymm1 + vpxor %ymm2,%ymm1,%ymm1 + + vbroadcasti128 -16(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + vextracti128 $1,%ymm1,%xmm2 + vpxor %xmm2,%xmm1,%xmm1 + + + + vpxor 0(%rdi),%ymm10,%ymm2 + vpxor 32(%rdi),%ymm10,%ymm3 + vpxor 64(%rdi),%ymm10,%ymm5 + vpxor 96(%rdi),%ymm10,%ymm6 +.byte 0xc4,0x62,0x1d,0xdd,0xe2 +.byte 0xc4,0x62,0x15,0xdd,0xeb +.byte 0xc4,0x62,0x0d,0xdd,0xf5 +.byte 0xc4,0x62,0x05,0xdd,0xfe + vmovdqu %ymm12,0(%rsi) + vmovdqu %ymm13,32(%rsi) + vmovdqu %ymm14,64(%rsi) + vmovdqu %ymm15,96(%rsi) + + subq $-128,%rdi + subq $-128,%rsi + addq $-128,%rdx + cmpq $127,%rdx + ja .Lcrypt_loop_4x__func2 +.Lcrypt_loop_4x_done__func2: + + testq %rdx,%rdx + jz .Ldone__func2 + + + + + + leaq 128(%r9),%r8 + subq %rdx,%r8 + + + vpxor %xmm5,%xmm5,%xmm5 + vpxor %xmm6,%xmm6,%xmm6 + vpxor %xmm7,%xmm7,%xmm7 + + cmpq $64,%rdx + jb .Llessthan64bytes__func2 + + + vpshufb %ymm0,%ymm11,%ymm12 + vpaddd .Linc_2blocks(%rip),%ymm11,%ymm11 + vpshufb %ymm0,%ymm11,%ymm13 + vpaddd .Linc_2blocks(%rip),%ymm11,%ymm11 + vpxor %ymm9,%ymm12,%ymm12 + vpxor %ymm9,%ymm13,%ymm13 + leaq 16(%rcx),%rax +.Lvaesenc_loop_tail_1__func2: + vbroadcasti128 (%rax),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea + addq $16,%rax + cmpq %rax,%r11 + jne .Lvaesenc_loop_tail_1__func2 +.byte 0xc4,0x42,0x1d,0xdd,0xe2 +.byte 0xc4,0x42,0x15,0xdd,0xea + + + vmovdqu 0(%rdi),%ymm2 + vmovdqu 32(%rdi),%ymm3 + vpxor %ymm2,%ymm12,%ymm12 + vpxor %ymm3,%ymm13,%ymm13 + vmovdqu %ymm12,0(%rsi) + vmovdqu %ymm13,32(%rsi) + + + vpshufb %ymm0,%ymm2,%ymm12 + vpshufb %ymm0,%ymm3,%ymm13 + vpxor %ymm1,%ymm12,%ymm12 + vmovdqu (%r8),%ymm2 + vmovdqu 32(%r8),%ymm3 +.byte 0xc4,0xe3,0x1d,0x44,0xea,0x00 +.byte 0xc4,0xe3,0x1d,0x44,0xf2,0x01 +.byte 0xc4,0xe3,0x1d,0x44,0xe2,0x10 + vpxor %ymm4,%ymm6,%ymm6 +.byte 0xc4,0xe3,0x1d,0x44,0xfa,0x11 +.byte 0xc4,0xe3,0x15,0x44,0xe3,0x00 + vpxor %ymm4,%ymm5,%ymm5 +.byte 0xc4,0xe3,0x15,0x44,0xe3,0x01 + vpxor %ymm4,%ymm6,%ymm6 +.byte 0xc4,0xe3,0x15,0x44,0xe3,0x10 + vpxor %ymm4,%ymm6,%ymm6 +.byte 0xc4,0xe3,0x15,0x44,0xe3,0x11 + vpxor %ymm4,%ymm7,%ymm7 + + addq $64,%r8 + addq $64,%rdi + addq $64,%rsi + subq $64,%rdx + jz .Lreduce__func2 + + vpxor %xmm1,%xmm1,%xmm1 + + +.Llessthan64bytes__func2: + vpshufb %ymm0,%ymm11,%ymm12 + vpaddd .Linc_2blocks(%rip),%ymm11,%ymm11 + vpshufb %ymm0,%ymm11,%ymm13 + vpxor %ymm9,%ymm12,%ymm12 + vpxor %ymm9,%ymm13,%ymm13 + leaq 16(%rcx),%rax +.Lvaesenc_loop_tail_2__func2: + vbroadcasti128 (%rax),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea + addq $16,%rax + cmpq %rax,%r11 + jne .Lvaesenc_loop_tail_2__func2 +.byte 0xc4,0x42,0x1d,0xdd,0xe2 +.byte 0xc4,0x42,0x15,0xdd,0xea + + + + + cmpq $32,%rdx + jb .Lxor_one_block__func2 + je .Lxor_two_blocks__func2 + +.Lxor_three_blocks__func2: + vmovdqu 0(%rdi),%ymm2 + vmovdqu 32(%rdi),%xmm3 + vpxor %ymm2,%ymm12,%ymm12 + vpxor %xmm3,%xmm13,%xmm13 + vmovdqu %ymm12,0(%rsi) + vmovdqu %xmm13,32(%rsi) + + vpshufb %ymm0,%ymm2,%ymm12 + vpshufb %xmm0,%xmm3,%xmm13 + vpxor %ymm1,%ymm12,%ymm12 + vmovdqu (%r8),%ymm2 + vmovdqu 32(%r8),%xmm3 + vpclmulqdq $0x00,%xmm3,%xmm13,%xmm4 + vpxor %ymm4,%ymm5,%ymm5 + vpclmulqdq $0x01,%xmm3,%xmm13,%xmm4 + vpxor %ymm4,%ymm6,%ymm6 + vpclmulqdq $0x10,%xmm3,%xmm13,%xmm4 + vpxor %ymm4,%ymm6,%ymm6 + vpclmulqdq $0x11,%xmm3,%xmm13,%xmm4 + vpxor %ymm4,%ymm7,%ymm7 + jmp .Lghash_mul_one_vec_unreduced__func2 + +.Lxor_two_blocks__func2: + vmovdqu (%rdi),%ymm2 + vpxor %ymm2,%ymm12,%ymm12 + vmovdqu %ymm12,(%rsi) + vpshufb %ymm0,%ymm2,%ymm12 + vpxor %ymm1,%ymm12,%ymm12 + vmovdqu (%r8),%ymm2 + jmp .Lghash_mul_one_vec_unreduced__func2 + +.Lxor_one_block__func2: + vmovdqu (%rdi),%xmm2 + vpxor %xmm2,%xmm12,%xmm12 + vmovdqu %xmm12,(%rsi) + vpshufb %xmm0,%xmm2,%xmm12 + vpxor %xmm1,%xmm12,%xmm12 + vmovdqu (%r8),%xmm2 + +.Lghash_mul_one_vec_unreduced__func2: +.byte 0xc4,0xe3,0x1d,0x44,0xe2,0x00 + vpxor %ymm4,%ymm5,%ymm5 +.byte 0xc4,0xe3,0x1d,0x44,0xe2,0x01 + vpxor %ymm4,%ymm6,%ymm6 +.byte 0xc4,0xe3,0x1d,0x44,0xe2,0x10 + vpxor %ymm4,%ymm6,%ymm6 +.byte 0xc4,0xe3,0x1d,0x44,0xe2,0x11 + vpxor %ymm4,%ymm7,%ymm7 + +.Lreduce__func2: + + vbroadcasti128 .Lgfpoly(%rip),%ymm2 +.byte 0xc4,0xe3,0x6d,0x44,0xdd,0x01 + vpshufd $0x4e,%ymm5,%ymm5 + vpxor %ymm5,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 +.byte 0xc4,0xe3,0x6d,0x44,0xde,0x01 + vpshufd $0x4e,%ymm6,%ymm6 + vpxor %ymm6,%ymm7,%ymm7 + vpxor %ymm3,%ymm7,%ymm7 + vextracti128 $1,%ymm7,%xmm1 + vpxor %xmm7,%xmm1,%xmm1 + +.Ldone__func2: + + vpshufb %xmm0,%xmm1,%xmm1 + vmovdqu %xmm1,(%r12) + + vzeroupper + popq %r12 +.cfi_adjust_cfa_offset -8 +.cfi_restore %r12 + ret + +.cfi_endproc +.size aes_gcm_dec_update_vaes_avx2, . - aes_gcm_dec_update_vaes_avx2 +#endif diff --git a/http/vendor/ring/pregenerated/aes-gcm-avx2-x86_64-macosx.S b/http/vendor/ring/pregenerated/aes-gcm-avx2-x86_64-macosx.S new file mode 100644 index 0000000..9cb6127 --- /dev/null +++ b/http/vendor/ring/pregenerated/aes-gcm-avx2-x86_64-macosx.S @@ -0,0 +1,1167 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__) +.section __DATA,__const +.p2align 4 + + +L$bswap_mask: +.quad 0x08090a0b0c0d0e0f, 0x0001020304050607 + + + + + + + + +L$gfpoly: +.quad 1, 0xc200000000000000 + + +L$gfpoly_and_internal_carrybit: +.quad 1, 0xc200000000000001 + +.p2align 5 + +L$ctr_pattern: +.quad 0, 0 +.quad 1, 0 +L$inc_2blocks: +.quad 2, 0 +.quad 2, 0 + +.text +.globl _gcm_init_vpclmulqdq_avx2 +.private_extern _gcm_init_vpclmulqdq_avx2 + +.p2align 5 +_gcm_init_vpclmulqdq_avx2: + + +_CET_ENDBR + + + + + + vpshufd $0x4e,(%rsi),%xmm3 + + + + + + vpshufd $0xd3,%xmm3,%xmm0 + vpsrad $31,%xmm0,%xmm0 + vpaddq %xmm3,%xmm3,%xmm3 + vpand L$gfpoly_and_internal_carrybit(%rip),%xmm0,%xmm0 + vpxor %xmm0,%xmm3,%xmm3 + + vbroadcasti128 L$gfpoly(%rip),%ymm6 + + + vpclmulqdq $0x00,%xmm3,%xmm3,%xmm0 + vpclmulqdq $0x01,%xmm3,%xmm3,%xmm1 + vpclmulqdq $0x10,%xmm3,%xmm3,%xmm2 + vpxor %xmm2,%xmm1,%xmm1 + vpclmulqdq $0x01,%xmm0,%xmm6,%xmm2 + vpshufd $0x4e,%xmm0,%xmm0 + vpxor %xmm0,%xmm1,%xmm1 + vpxor %xmm2,%xmm1,%xmm1 + vpclmulqdq $0x11,%xmm3,%xmm3,%xmm5 + vpclmulqdq $0x01,%xmm1,%xmm6,%xmm0 + vpshufd $0x4e,%xmm1,%xmm1 + vpxor %xmm1,%xmm5,%xmm5 + vpxor %xmm0,%xmm5,%xmm5 + + + + vinserti128 $1,%xmm3,%ymm5,%ymm3 + vinserti128 $1,%xmm5,%ymm5,%ymm5 + + +.byte 0xc4,0xe3,0x65,0x44,0xc5,0x00 +.byte 0xc4,0xe3,0x65,0x44,0xcd,0x01 +.byte 0xc4,0xe3,0x65,0x44,0xd5,0x10 + vpxor %ymm2,%ymm1,%ymm1 +.byte 0xc4,0xe3,0x4d,0x44,0xd0,0x01 + vpshufd $0x4e,%ymm0,%ymm0 + vpxor %ymm0,%ymm1,%ymm1 + vpxor %ymm2,%ymm1,%ymm1 +.byte 0xc4,0xe3,0x65,0x44,0xe5,0x11 +.byte 0xc4,0xe3,0x4d,0x44,0xc1,0x01 + vpshufd $0x4e,%ymm1,%ymm1 + vpxor %ymm1,%ymm4,%ymm4 + vpxor %ymm0,%ymm4,%ymm4 + + + + vmovdqu %ymm3,96(%rdi) + vmovdqu %ymm4,64(%rdi) + + + + vpunpcklqdq %ymm3,%ymm4,%ymm0 + vpunpckhqdq %ymm3,%ymm4,%ymm1 + vpxor %ymm1,%ymm0,%ymm0 + vmovdqu %ymm0,128+32(%rdi) + + +.byte 0xc4,0xe3,0x5d,0x44,0xc5,0x00 +.byte 0xc4,0xe3,0x5d,0x44,0xcd,0x01 +.byte 0xc4,0xe3,0x5d,0x44,0xd5,0x10 + vpxor %ymm2,%ymm1,%ymm1 +.byte 0xc4,0xe3,0x4d,0x44,0xd0,0x01 + vpshufd $0x4e,%ymm0,%ymm0 + vpxor %ymm0,%ymm1,%ymm1 + vpxor %ymm2,%ymm1,%ymm1 +.byte 0xc4,0xe3,0x5d,0x44,0xdd,0x11 +.byte 0xc4,0xe3,0x4d,0x44,0xc1,0x01 + vpshufd $0x4e,%ymm1,%ymm1 + vpxor %ymm1,%ymm3,%ymm3 + vpxor %ymm0,%ymm3,%ymm3 + +.byte 0xc4,0xe3,0x65,0x44,0xc5,0x00 +.byte 0xc4,0xe3,0x65,0x44,0xcd,0x01 +.byte 0xc4,0xe3,0x65,0x44,0xd5,0x10 + vpxor %ymm2,%ymm1,%ymm1 +.byte 0xc4,0xe3,0x4d,0x44,0xd0,0x01 + vpshufd $0x4e,%ymm0,%ymm0 + vpxor %ymm0,%ymm1,%ymm1 + vpxor %ymm2,%ymm1,%ymm1 +.byte 0xc4,0xe3,0x65,0x44,0xe5,0x11 +.byte 0xc4,0xe3,0x4d,0x44,0xc1,0x01 + vpshufd $0x4e,%ymm1,%ymm1 + vpxor %ymm1,%ymm4,%ymm4 + vpxor %ymm0,%ymm4,%ymm4 + + vmovdqu %ymm3,32(%rdi) + vmovdqu %ymm4,0(%rdi) + + + + vpunpcklqdq %ymm3,%ymm4,%ymm0 + vpunpckhqdq %ymm3,%ymm4,%ymm1 + vpxor %ymm1,%ymm0,%ymm0 + vmovdqu %ymm0,128(%rdi) + + vzeroupper + ret + + + +.globl _gcm_ghash_vpclmulqdq_avx2_1 +.private_extern _gcm_ghash_vpclmulqdq_avx2_1 + +.p2align 5 +_gcm_ghash_vpclmulqdq_avx2_1: + + +_CET_ENDBR + + + + + + + vmovdqu L$bswap_mask(%rip),%xmm6 + vmovdqu L$gfpoly(%rip),%xmm7 + + + vmovdqu (%rdi),%xmm5 + vpshufb %xmm6,%xmm5,%xmm5 + + + +L$ghash_lastblock: + vmovdqu (%rdx),%xmm0 + vpshufb %xmm6,%xmm0,%xmm0 + vpxor %xmm0,%xmm5,%xmm5 + vmovdqu 128-16(%rsi),%xmm0 + vpclmulqdq $0x00,%xmm0,%xmm5,%xmm1 + vpclmulqdq $0x01,%xmm0,%xmm5,%xmm2 + vpclmulqdq $0x10,%xmm0,%xmm5,%xmm3 + vpxor %xmm3,%xmm2,%xmm2 + vpclmulqdq $0x01,%xmm1,%xmm7,%xmm3 + vpshufd $0x4e,%xmm1,%xmm1 + vpxor %xmm1,%xmm2,%xmm2 + vpxor %xmm3,%xmm2,%xmm2 + vpclmulqdq $0x11,%xmm0,%xmm5,%xmm5 + vpclmulqdq $0x01,%xmm2,%xmm7,%xmm1 + vpshufd $0x4e,%xmm2,%xmm2 + vpxor %xmm2,%xmm5,%xmm5 + vpxor %xmm1,%xmm5,%xmm5 + + +L$ghash_done: + + vpshufb %xmm6,%xmm5,%xmm5 + vmovdqu %xmm5,(%rdi) + + vzeroupper + ret + + + +.globl _aes_gcm_enc_update_vaes_avx2 +.private_extern _aes_gcm_enc_update_vaes_avx2 + +.p2align 5 +_aes_gcm_enc_update_vaes_avx2: + + +_CET_ENDBR + pushq %r12 + + + movq 16(%rsp),%r12 +#ifdef BORINGSSL_DISPATCH_TEST + + movb $1,_BORINGSSL_function_hit+8(%rip) +#endif + vbroadcasti128 L$bswap_mask(%rip),%ymm0 + + + + vmovdqu (%r12),%xmm1 + vpshufb %xmm0,%xmm1,%xmm1 + vbroadcasti128 (%r8),%ymm11 + vpshufb %ymm0,%ymm11,%ymm11 + + + + movl 240(%rcx),%r10d + leal -20(,%r10,4),%r10d + + + + + leaq 96(%rcx,%r10,4),%r11 + vbroadcasti128 (%rcx),%ymm9 + vbroadcasti128 (%r11),%ymm10 + + + vpaddd L$ctr_pattern(%rip),%ymm11,%ymm11 + + + + cmpq $127,%rdx + jbe L$crypt_loop_4x_done__func1 + + vmovdqu 128(%r9),%ymm7 + vmovdqu 128+32(%r9),%ymm8 + + + + vmovdqu L$inc_2blocks(%rip),%ymm2 + vpshufb %ymm0,%ymm11,%ymm12 + vpaddd %ymm2,%ymm11,%ymm11 + vpshufb %ymm0,%ymm11,%ymm13 + vpaddd %ymm2,%ymm11,%ymm11 + vpshufb %ymm0,%ymm11,%ymm14 + vpaddd %ymm2,%ymm11,%ymm11 + vpshufb %ymm0,%ymm11,%ymm15 + vpaddd %ymm2,%ymm11,%ymm11 + + + vpxor %ymm9,%ymm12,%ymm12 + vpxor %ymm9,%ymm13,%ymm13 + vpxor %ymm9,%ymm14,%ymm14 + vpxor %ymm9,%ymm15,%ymm15 + + leaq 16(%rcx),%rax +L$vaesenc_loop_first_4_vecs__func1: + vbroadcasti128 (%rax),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + addq $16,%rax + cmpq %rax,%r11 + jne L$vaesenc_loop_first_4_vecs__func1 + vpxor 0(%rdi),%ymm10,%ymm2 + vpxor 32(%rdi),%ymm10,%ymm3 + vpxor 64(%rdi),%ymm10,%ymm5 + vpxor 96(%rdi),%ymm10,%ymm6 +.byte 0xc4,0x62,0x1d,0xdd,0xe2 +.byte 0xc4,0x62,0x15,0xdd,0xeb +.byte 0xc4,0x62,0x0d,0xdd,0xf5 +.byte 0xc4,0x62,0x05,0xdd,0xfe + vmovdqu %ymm12,0(%rsi) + vmovdqu %ymm13,32(%rsi) + vmovdqu %ymm14,64(%rsi) + vmovdqu %ymm15,96(%rsi) + + subq $-128,%rdi + addq $-128,%rdx + cmpq $127,%rdx + jbe L$ghash_last_ciphertext_4x__func1 +.p2align 4 +L$crypt_loop_4x__func1: + + + + + vmovdqu L$inc_2blocks(%rip),%ymm2 + vpshufb %ymm0,%ymm11,%ymm12 + vpaddd %ymm2,%ymm11,%ymm11 + vpshufb %ymm0,%ymm11,%ymm13 + vpaddd %ymm2,%ymm11,%ymm11 + vpshufb %ymm0,%ymm11,%ymm14 + vpaddd %ymm2,%ymm11,%ymm11 + vpshufb %ymm0,%ymm11,%ymm15 + vpaddd %ymm2,%ymm11,%ymm11 + + + vpxor %ymm9,%ymm12,%ymm12 + vpxor %ymm9,%ymm13,%ymm13 + vpxor %ymm9,%ymm14,%ymm14 + vpxor %ymm9,%ymm15,%ymm15 + + cmpl $24,%r10d + jl L$aes128__func1 + je L$aes192__func1 + + vbroadcasti128 -208(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + vbroadcasti128 -192(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + +L$aes192__func1: + vbroadcasti128 -176(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + vbroadcasti128 -160(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + +L$aes128__func1: + prefetcht0 512(%rdi) + prefetcht0 512+64(%rdi) + + vmovdqu 0(%rsi),%ymm3 + vpshufb %ymm0,%ymm3,%ymm3 + vmovdqu 0(%r9),%ymm4 + vpxor %ymm1,%ymm3,%ymm3 +.byte 0xc4,0xe3,0x65,0x44,0xec,0x00 +.byte 0xc4,0xe3,0x65,0x44,0xcc,0x11 + vpunpckhqdq %ymm3,%ymm3,%ymm2 + vpxor %ymm3,%ymm2,%ymm2 +.byte 0xc4,0xe3,0x6d,0x44,0xf7,0x00 + + vbroadcasti128 -144(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + + vbroadcasti128 -128(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + + vmovdqu 32(%rsi),%ymm3 + vpshufb %ymm0,%ymm3,%ymm3 + vmovdqu 32(%r9),%ymm4 +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x00 + vpxor %ymm2,%ymm5,%ymm5 +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x11 + vpxor %ymm2,%ymm1,%ymm1 + vpunpckhqdq %ymm3,%ymm3,%ymm2 + vpxor %ymm3,%ymm2,%ymm2 +.byte 0xc4,0xe3,0x6d,0x44,0xd7,0x10 + vpxor %ymm2,%ymm6,%ymm6 + + vbroadcasti128 -112(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + + vmovdqu 64(%rsi),%ymm3 + vpshufb %ymm0,%ymm3,%ymm3 + vmovdqu 64(%r9),%ymm4 + + vbroadcasti128 -96(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x00 + vpxor %ymm2,%ymm5,%ymm5 +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x11 + vpxor %ymm2,%ymm1,%ymm1 + + vbroadcasti128 -80(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + vpunpckhqdq %ymm3,%ymm3,%ymm2 + vpxor %ymm3,%ymm2,%ymm2 +.byte 0xc4,0xc3,0x6d,0x44,0xd0,0x00 + vpxor %ymm2,%ymm6,%ymm6 + + + vmovdqu 96(%rsi),%ymm3 + vpshufb %ymm0,%ymm3,%ymm3 + + vbroadcasti128 -64(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + vmovdqu 96(%r9),%ymm4 +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x00 + vpxor %ymm2,%ymm5,%ymm5 +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x11 + vpxor %ymm2,%ymm1,%ymm1 + vpunpckhqdq %ymm3,%ymm3,%ymm2 + vpxor %ymm3,%ymm2,%ymm2 +.byte 0xc4,0xc3,0x6d,0x44,0xd0,0x10 + vpxor %ymm2,%ymm6,%ymm6 + + vbroadcasti128 -48(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + + vpxor %ymm5,%ymm6,%ymm6 + vpxor %ymm1,%ymm6,%ymm6 + + + vbroadcasti128 L$gfpoly(%rip),%ymm4 +.byte 0xc4,0xe3,0x5d,0x44,0xd5,0x01 + vpshufd $0x4e,%ymm5,%ymm5 + vpxor %ymm5,%ymm6,%ymm6 + vpxor %ymm2,%ymm6,%ymm6 + + vbroadcasti128 -32(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + +.byte 0xc4,0xe3,0x5d,0x44,0xd6,0x01 + vpshufd $0x4e,%ymm6,%ymm6 + vpxor %ymm6,%ymm1,%ymm1 + vpxor %ymm2,%ymm1,%ymm1 + + vbroadcasti128 -16(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + vextracti128 $1,%ymm1,%xmm2 + vpxor %xmm2,%xmm1,%xmm1 + + + subq $-128,%rsi + vpxor 0(%rdi),%ymm10,%ymm2 + vpxor 32(%rdi),%ymm10,%ymm3 + vpxor 64(%rdi),%ymm10,%ymm5 + vpxor 96(%rdi),%ymm10,%ymm6 +.byte 0xc4,0x62,0x1d,0xdd,0xe2 +.byte 0xc4,0x62,0x15,0xdd,0xeb +.byte 0xc4,0x62,0x0d,0xdd,0xf5 +.byte 0xc4,0x62,0x05,0xdd,0xfe + vmovdqu %ymm12,0(%rsi) + vmovdqu %ymm13,32(%rsi) + vmovdqu %ymm14,64(%rsi) + vmovdqu %ymm15,96(%rsi) + + subq $-128,%rdi + + addq $-128,%rdx + cmpq $127,%rdx + ja L$crypt_loop_4x__func1 +L$ghash_last_ciphertext_4x__func1: + + vmovdqu 0(%rsi),%ymm3 + vpshufb %ymm0,%ymm3,%ymm3 + vmovdqu 0(%r9),%ymm4 + vpxor %ymm1,%ymm3,%ymm3 +.byte 0xc4,0xe3,0x65,0x44,0xec,0x00 +.byte 0xc4,0xe3,0x65,0x44,0xcc,0x11 + vpunpckhqdq %ymm3,%ymm3,%ymm2 + vpxor %ymm3,%ymm2,%ymm2 +.byte 0xc4,0xe3,0x6d,0x44,0xf7,0x00 + + vmovdqu 32(%rsi),%ymm3 + vpshufb %ymm0,%ymm3,%ymm3 + vmovdqu 32(%r9),%ymm4 +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x00 + vpxor %ymm2,%ymm5,%ymm5 +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x11 + vpxor %ymm2,%ymm1,%ymm1 + vpunpckhqdq %ymm3,%ymm3,%ymm2 + vpxor %ymm3,%ymm2,%ymm2 +.byte 0xc4,0xe3,0x6d,0x44,0xd7,0x10 + vpxor %ymm2,%ymm6,%ymm6 + + vmovdqu 64(%rsi),%ymm3 + vpshufb %ymm0,%ymm3,%ymm3 + vmovdqu 64(%r9),%ymm4 +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x00 + vpxor %ymm2,%ymm5,%ymm5 +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x11 + vpxor %ymm2,%ymm1,%ymm1 + vpunpckhqdq %ymm3,%ymm3,%ymm2 + vpxor %ymm3,%ymm2,%ymm2 +.byte 0xc4,0xc3,0x6d,0x44,0xd0,0x00 + vpxor %ymm2,%ymm6,%ymm6 + + + vmovdqu 96(%rsi),%ymm3 + vpshufb %ymm0,%ymm3,%ymm3 + vmovdqu 96(%r9),%ymm4 +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x00 + vpxor %ymm2,%ymm5,%ymm5 +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x11 + vpxor %ymm2,%ymm1,%ymm1 + vpunpckhqdq %ymm3,%ymm3,%ymm2 + vpxor %ymm3,%ymm2,%ymm2 +.byte 0xc4,0xc3,0x6d,0x44,0xd0,0x10 + vpxor %ymm2,%ymm6,%ymm6 + + vpxor %ymm5,%ymm6,%ymm6 + vpxor %ymm1,%ymm6,%ymm6 + + + vbroadcasti128 L$gfpoly(%rip),%ymm4 +.byte 0xc4,0xe3,0x5d,0x44,0xd5,0x01 + vpshufd $0x4e,%ymm5,%ymm5 + vpxor %ymm5,%ymm6,%ymm6 + vpxor %ymm2,%ymm6,%ymm6 + +.byte 0xc4,0xe3,0x5d,0x44,0xd6,0x01 + vpshufd $0x4e,%ymm6,%ymm6 + vpxor %ymm6,%ymm1,%ymm1 + vpxor %ymm2,%ymm1,%ymm1 + vextracti128 $1,%ymm1,%xmm2 + vpxor %xmm2,%xmm1,%xmm1 + + subq $-128,%rsi +L$crypt_loop_4x_done__func1: + + testq %rdx,%rdx + jz L$done__func1 + + + + + + leaq 128(%r9),%r8 + subq %rdx,%r8 + + + vpxor %xmm5,%xmm5,%xmm5 + vpxor %xmm6,%xmm6,%xmm6 + vpxor %xmm7,%xmm7,%xmm7 + + cmpq $64,%rdx + jb L$lessthan64bytes__func1 + + + vpshufb %ymm0,%ymm11,%ymm12 + vpaddd L$inc_2blocks(%rip),%ymm11,%ymm11 + vpshufb %ymm0,%ymm11,%ymm13 + vpaddd L$inc_2blocks(%rip),%ymm11,%ymm11 + vpxor %ymm9,%ymm12,%ymm12 + vpxor %ymm9,%ymm13,%ymm13 + leaq 16(%rcx),%rax +L$vaesenc_loop_tail_1__func1: + vbroadcasti128 (%rax),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea + addq $16,%rax + cmpq %rax,%r11 + jne L$vaesenc_loop_tail_1__func1 +.byte 0xc4,0x42,0x1d,0xdd,0xe2 +.byte 0xc4,0x42,0x15,0xdd,0xea + + + vmovdqu 0(%rdi),%ymm2 + vmovdqu 32(%rdi),%ymm3 + vpxor %ymm2,%ymm12,%ymm12 + vpxor %ymm3,%ymm13,%ymm13 + vmovdqu %ymm12,0(%rsi) + vmovdqu %ymm13,32(%rsi) + + + vpshufb %ymm0,%ymm12,%ymm12 + vpshufb %ymm0,%ymm13,%ymm13 + vpxor %ymm1,%ymm12,%ymm12 + vmovdqu (%r8),%ymm2 + vmovdqu 32(%r8),%ymm3 +.byte 0xc4,0xe3,0x1d,0x44,0xea,0x00 +.byte 0xc4,0xe3,0x1d,0x44,0xf2,0x01 +.byte 0xc4,0xe3,0x1d,0x44,0xe2,0x10 + vpxor %ymm4,%ymm6,%ymm6 +.byte 0xc4,0xe3,0x1d,0x44,0xfa,0x11 +.byte 0xc4,0xe3,0x15,0x44,0xe3,0x00 + vpxor %ymm4,%ymm5,%ymm5 +.byte 0xc4,0xe3,0x15,0x44,0xe3,0x01 + vpxor %ymm4,%ymm6,%ymm6 +.byte 0xc4,0xe3,0x15,0x44,0xe3,0x10 + vpxor %ymm4,%ymm6,%ymm6 +.byte 0xc4,0xe3,0x15,0x44,0xe3,0x11 + vpxor %ymm4,%ymm7,%ymm7 + + addq $64,%r8 + addq $64,%rdi + addq $64,%rsi + subq $64,%rdx + jz L$reduce__func1 + + vpxor %xmm1,%xmm1,%xmm1 + + +L$lessthan64bytes__func1: + vpshufb %ymm0,%ymm11,%ymm12 + vpaddd L$inc_2blocks(%rip),%ymm11,%ymm11 + vpshufb %ymm0,%ymm11,%ymm13 + vpxor %ymm9,%ymm12,%ymm12 + vpxor %ymm9,%ymm13,%ymm13 + leaq 16(%rcx),%rax +L$vaesenc_loop_tail_2__func1: + vbroadcasti128 (%rax),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea + addq $16,%rax + cmpq %rax,%r11 + jne L$vaesenc_loop_tail_2__func1 +.byte 0xc4,0x42,0x1d,0xdd,0xe2 +.byte 0xc4,0x42,0x15,0xdd,0xea + + + + + cmpq $32,%rdx + jb L$xor_one_block__func1 + je L$xor_two_blocks__func1 + +L$xor_three_blocks__func1: + vmovdqu 0(%rdi),%ymm2 + vmovdqu 32(%rdi),%xmm3 + vpxor %ymm2,%ymm12,%ymm12 + vpxor %xmm3,%xmm13,%xmm13 + vmovdqu %ymm12,0(%rsi) + vmovdqu %xmm13,32(%rsi) + + vpshufb %ymm0,%ymm12,%ymm12 + vpshufb %xmm0,%xmm13,%xmm13 + vpxor %ymm1,%ymm12,%ymm12 + vmovdqu (%r8),%ymm2 + vmovdqu 32(%r8),%xmm3 + vpclmulqdq $0x00,%xmm3,%xmm13,%xmm4 + vpxor %ymm4,%ymm5,%ymm5 + vpclmulqdq $0x01,%xmm3,%xmm13,%xmm4 + vpxor %ymm4,%ymm6,%ymm6 + vpclmulqdq $0x10,%xmm3,%xmm13,%xmm4 + vpxor %ymm4,%ymm6,%ymm6 + vpclmulqdq $0x11,%xmm3,%xmm13,%xmm4 + vpxor %ymm4,%ymm7,%ymm7 + jmp L$ghash_mul_one_vec_unreduced__func1 + +L$xor_two_blocks__func1: + vmovdqu (%rdi),%ymm2 + vpxor %ymm2,%ymm12,%ymm12 + vmovdqu %ymm12,(%rsi) + vpshufb %ymm0,%ymm12,%ymm12 + vpxor %ymm1,%ymm12,%ymm12 + vmovdqu (%r8),%ymm2 + jmp L$ghash_mul_one_vec_unreduced__func1 + +L$xor_one_block__func1: + vmovdqu (%rdi),%xmm2 + vpxor %xmm2,%xmm12,%xmm12 + vmovdqu %xmm12,(%rsi) + vpshufb %xmm0,%xmm12,%xmm12 + vpxor %xmm1,%xmm12,%xmm12 + vmovdqu (%r8),%xmm2 + +L$ghash_mul_one_vec_unreduced__func1: +.byte 0xc4,0xe3,0x1d,0x44,0xe2,0x00 + vpxor %ymm4,%ymm5,%ymm5 +.byte 0xc4,0xe3,0x1d,0x44,0xe2,0x01 + vpxor %ymm4,%ymm6,%ymm6 +.byte 0xc4,0xe3,0x1d,0x44,0xe2,0x10 + vpxor %ymm4,%ymm6,%ymm6 +.byte 0xc4,0xe3,0x1d,0x44,0xe2,0x11 + vpxor %ymm4,%ymm7,%ymm7 + +L$reduce__func1: + + vbroadcasti128 L$gfpoly(%rip),%ymm2 +.byte 0xc4,0xe3,0x6d,0x44,0xdd,0x01 + vpshufd $0x4e,%ymm5,%ymm5 + vpxor %ymm5,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 +.byte 0xc4,0xe3,0x6d,0x44,0xde,0x01 + vpshufd $0x4e,%ymm6,%ymm6 + vpxor %ymm6,%ymm7,%ymm7 + vpxor %ymm3,%ymm7,%ymm7 + vextracti128 $1,%ymm7,%xmm1 + vpxor %xmm7,%xmm1,%xmm1 + +L$done__func1: + + vpshufb %xmm0,%xmm1,%xmm1 + vmovdqu %xmm1,(%r12) + + vzeroupper + popq %r12 + + ret + + + +.globl _aes_gcm_dec_update_vaes_avx2 +.private_extern _aes_gcm_dec_update_vaes_avx2 + +.p2align 5 +_aes_gcm_dec_update_vaes_avx2: + + +_CET_ENDBR + pushq %r12 + + + movq 16(%rsp),%r12 + vbroadcasti128 L$bswap_mask(%rip),%ymm0 + + + + vmovdqu (%r12),%xmm1 + vpshufb %xmm0,%xmm1,%xmm1 + vbroadcasti128 (%r8),%ymm11 + vpshufb %ymm0,%ymm11,%ymm11 + + + + movl 240(%rcx),%r10d + leal -20(,%r10,4),%r10d + + + + + leaq 96(%rcx,%r10,4),%r11 + vbroadcasti128 (%rcx),%ymm9 + vbroadcasti128 (%r11),%ymm10 + + + vpaddd L$ctr_pattern(%rip),%ymm11,%ymm11 + + + + cmpq $127,%rdx + jbe L$crypt_loop_4x_done__func2 + + vmovdqu 128(%r9),%ymm7 + vmovdqu 128+32(%r9),%ymm8 +.p2align 4 +L$crypt_loop_4x__func2: + + + + + vmovdqu L$inc_2blocks(%rip),%ymm2 + vpshufb %ymm0,%ymm11,%ymm12 + vpaddd %ymm2,%ymm11,%ymm11 + vpshufb %ymm0,%ymm11,%ymm13 + vpaddd %ymm2,%ymm11,%ymm11 + vpshufb %ymm0,%ymm11,%ymm14 + vpaddd %ymm2,%ymm11,%ymm11 + vpshufb %ymm0,%ymm11,%ymm15 + vpaddd %ymm2,%ymm11,%ymm11 + + + vpxor %ymm9,%ymm12,%ymm12 + vpxor %ymm9,%ymm13,%ymm13 + vpxor %ymm9,%ymm14,%ymm14 + vpxor %ymm9,%ymm15,%ymm15 + + cmpl $24,%r10d + jl L$aes128__func2 + je L$aes192__func2 + + vbroadcasti128 -208(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + vbroadcasti128 -192(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + +L$aes192__func2: + vbroadcasti128 -176(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + vbroadcasti128 -160(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + +L$aes128__func2: + prefetcht0 512(%rdi) + prefetcht0 512+64(%rdi) + + vmovdqu 0(%rdi),%ymm3 + vpshufb %ymm0,%ymm3,%ymm3 + vmovdqu 0(%r9),%ymm4 + vpxor %ymm1,%ymm3,%ymm3 +.byte 0xc4,0xe3,0x65,0x44,0xec,0x00 +.byte 0xc4,0xe3,0x65,0x44,0xcc,0x11 + vpunpckhqdq %ymm3,%ymm3,%ymm2 + vpxor %ymm3,%ymm2,%ymm2 +.byte 0xc4,0xe3,0x6d,0x44,0xf7,0x00 + + vbroadcasti128 -144(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + + vbroadcasti128 -128(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + + vmovdqu 32(%rdi),%ymm3 + vpshufb %ymm0,%ymm3,%ymm3 + vmovdqu 32(%r9),%ymm4 +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x00 + vpxor %ymm2,%ymm5,%ymm5 +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x11 + vpxor %ymm2,%ymm1,%ymm1 + vpunpckhqdq %ymm3,%ymm3,%ymm2 + vpxor %ymm3,%ymm2,%ymm2 +.byte 0xc4,0xe3,0x6d,0x44,0xd7,0x10 + vpxor %ymm2,%ymm6,%ymm6 + + vbroadcasti128 -112(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + + vmovdqu 64(%rdi),%ymm3 + vpshufb %ymm0,%ymm3,%ymm3 + vmovdqu 64(%r9),%ymm4 + + vbroadcasti128 -96(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x00 + vpxor %ymm2,%ymm5,%ymm5 +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x11 + vpxor %ymm2,%ymm1,%ymm1 + + vbroadcasti128 -80(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + vpunpckhqdq %ymm3,%ymm3,%ymm2 + vpxor %ymm3,%ymm2,%ymm2 +.byte 0xc4,0xc3,0x6d,0x44,0xd0,0x00 + vpxor %ymm2,%ymm6,%ymm6 + + + vmovdqu 96(%rdi),%ymm3 + vpshufb %ymm0,%ymm3,%ymm3 + + vbroadcasti128 -64(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + vmovdqu 96(%r9),%ymm4 +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x00 + vpxor %ymm2,%ymm5,%ymm5 +.byte 0xc4,0xe3,0x65,0x44,0xd4,0x11 + vpxor %ymm2,%ymm1,%ymm1 + vpunpckhqdq %ymm3,%ymm3,%ymm2 + vpxor %ymm3,%ymm2,%ymm2 +.byte 0xc4,0xc3,0x6d,0x44,0xd0,0x10 + vpxor %ymm2,%ymm6,%ymm6 + + vbroadcasti128 -48(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + + vpxor %ymm5,%ymm6,%ymm6 + vpxor %ymm1,%ymm6,%ymm6 + + + vbroadcasti128 L$gfpoly(%rip),%ymm4 +.byte 0xc4,0xe3,0x5d,0x44,0xd5,0x01 + vpshufd $0x4e,%ymm5,%ymm5 + vpxor %ymm5,%ymm6,%ymm6 + vpxor %ymm2,%ymm6,%ymm6 + + vbroadcasti128 -32(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + +.byte 0xc4,0xe3,0x5d,0x44,0xd6,0x01 + vpshufd $0x4e,%ymm6,%ymm6 + vpxor %ymm6,%ymm1,%ymm1 + vpxor %ymm2,%ymm1,%ymm1 + + vbroadcasti128 -16(%r11),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea +.byte 0xc4,0x62,0x0d,0xdc,0xf2 +.byte 0xc4,0x62,0x05,0xdc,0xfa + + vextracti128 $1,%ymm1,%xmm2 + vpxor %xmm2,%xmm1,%xmm1 + + + + vpxor 0(%rdi),%ymm10,%ymm2 + vpxor 32(%rdi),%ymm10,%ymm3 + vpxor 64(%rdi),%ymm10,%ymm5 + vpxor 96(%rdi),%ymm10,%ymm6 +.byte 0xc4,0x62,0x1d,0xdd,0xe2 +.byte 0xc4,0x62,0x15,0xdd,0xeb +.byte 0xc4,0x62,0x0d,0xdd,0xf5 +.byte 0xc4,0x62,0x05,0xdd,0xfe + vmovdqu %ymm12,0(%rsi) + vmovdqu %ymm13,32(%rsi) + vmovdqu %ymm14,64(%rsi) + vmovdqu %ymm15,96(%rsi) + + subq $-128,%rdi + subq $-128,%rsi + addq $-128,%rdx + cmpq $127,%rdx + ja L$crypt_loop_4x__func2 +L$crypt_loop_4x_done__func2: + + testq %rdx,%rdx + jz L$done__func2 + + + + + + leaq 128(%r9),%r8 + subq %rdx,%r8 + + + vpxor %xmm5,%xmm5,%xmm5 + vpxor %xmm6,%xmm6,%xmm6 + vpxor %xmm7,%xmm7,%xmm7 + + cmpq $64,%rdx + jb L$lessthan64bytes__func2 + + + vpshufb %ymm0,%ymm11,%ymm12 + vpaddd L$inc_2blocks(%rip),%ymm11,%ymm11 + vpshufb %ymm0,%ymm11,%ymm13 + vpaddd L$inc_2blocks(%rip),%ymm11,%ymm11 + vpxor %ymm9,%ymm12,%ymm12 + vpxor %ymm9,%ymm13,%ymm13 + leaq 16(%rcx),%rax +L$vaesenc_loop_tail_1__func2: + vbroadcasti128 (%rax),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea + addq $16,%rax + cmpq %rax,%r11 + jne L$vaesenc_loop_tail_1__func2 +.byte 0xc4,0x42,0x1d,0xdd,0xe2 +.byte 0xc4,0x42,0x15,0xdd,0xea + + + vmovdqu 0(%rdi),%ymm2 + vmovdqu 32(%rdi),%ymm3 + vpxor %ymm2,%ymm12,%ymm12 + vpxor %ymm3,%ymm13,%ymm13 + vmovdqu %ymm12,0(%rsi) + vmovdqu %ymm13,32(%rsi) + + + vpshufb %ymm0,%ymm2,%ymm12 + vpshufb %ymm0,%ymm3,%ymm13 + vpxor %ymm1,%ymm12,%ymm12 + vmovdqu (%r8),%ymm2 + vmovdqu 32(%r8),%ymm3 +.byte 0xc4,0xe3,0x1d,0x44,0xea,0x00 +.byte 0xc4,0xe3,0x1d,0x44,0xf2,0x01 +.byte 0xc4,0xe3,0x1d,0x44,0xe2,0x10 + vpxor %ymm4,%ymm6,%ymm6 +.byte 0xc4,0xe3,0x1d,0x44,0xfa,0x11 +.byte 0xc4,0xe3,0x15,0x44,0xe3,0x00 + vpxor %ymm4,%ymm5,%ymm5 +.byte 0xc4,0xe3,0x15,0x44,0xe3,0x01 + vpxor %ymm4,%ymm6,%ymm6 +.byte 0xc4,0xe3,0x15,0x44,0xe3,0x10 + vpxor %ymm4,%ymm6,%ymm6 +.byte 0xc4,0xe3,0x15,0x44,0xe3,0x11 + vpxor %ymm4,%ymm7,%ymm7 + + addq $64,%r8 + addq $64,%rdi + addq $64,%rsi + subq $64,%rdx + jz L$reduce__func2 + + vpxor %xmm1,%xmm1,%xmm1 + + +L$lessthan64bytes__func2: + vpshufb %ymm0,%ymm11,%ymm12 + vpaddd L$inc_2blocks(%rip),%ymm11,%ymm11 + vpshufb %ymm0,%ymm11,%ymm13 + vpxor %ymm9,%ymm12,%ymm12 + vpxor %ymm9,%ymm13,%ymm13 + leaq 16(%rcx),%rax +L$vaesenc_loop_tail_2__func2: + vbroadcasti128 (%rax),%ymm2 +.byte 0xc4,0x62,0x1d,0xdc,0xe2 +.byte 0xc4,0x62,0x15,0xdc,0xea + addq $16,%rax + cmpq %rax,%r11 + jne L$vaesenc_loop_tail_2__func2 +.byte 0xc4,0x42,0x1d,0xdd,0xe2 +.byte 0xc4,0x42,0x15,0xdd,0xea + + + + + cmpq $32,%rdx + jb L$xor_one_block__func2 + je L$xor_two_blocks__func2 + +L$xor_three_blocks__func2: + vmovdqu 0(%rdi),%ymm2 + vmovdqu 32(%rdi),%xmm3 + vpxor %ymm2,%ymm12,%ymm12 + vpxor %xmm3,%xmm13,%xmm13 + vmovdqu %ymm12,0(%rsi) + vmovdqu %xmm13,32(%rsi) + + vpshufb %ymm0,%ymm2,%ymm12 + vpshufb %xmm0,%xmm3,%xmm13 + vpxor %ymm1,%ymm12,%ymm12 + vmovdqu (%r8),%ymm2 + vmovdqu 32(%r8),%xmm3 + vpclmulqdq $0x00,%xmm3,%xmm13,%xmm4 + vpxor %ymm4,%ymm5,%ymm5 + vpclmulqdq $0x01,%xmm3,%xmm13,%xmm4 + vpxor %ymm4,%ymm6,%ymm6 + vpclmulqdq $0x10,%xmm3,%xmm13,%xmm4 + vpxor %ymm4,%ymm6,%ymm6 + vpclmulqdq $0x11,%xmm3,%xmm13,%xmm4 + vpxor %ymm4,%ymm7,%ymm7 + jmp L$ghash_mul_one_vec_unreduced__func2 + +L$xor_two_blocks__func2: + vmovdqu (%rdi),%ymm2 + vpxor %ymm2,%ymm12,%ymm12 + vmovdqu %ymm12,(%rsi) + vpshufb %ymm0,%ymm2,%ymm12 + vpxor %ymm1,%ymm12,%ymm12 + vmovdqu (%r8),%ymm2 + jmp L$ghash_mul_one_vec_unreduced__func2 + +L$xor_one_block__func2: + vmovdqu (%rdi),%xmm2 + vpxor %xmm2,%xmm12,%xmm12 + vmovdqu %xmm12,(%rsi) + vpshufb %xmm0,%xmm2,%xmm12 + vpxor %xmm1,%xmm12,%xmm12 + vmovdqu (%r8),%xmm2 + +L$ghash_mul_one_vec_unreduced__func2: +.byte 0xc4,0xe3,0x1d,0x44,0xe2,0x00 + vpxor %ymm4,%ymm5,%ymm5 +.byte 0xc4,0xe3,0x1d,0x44,0xe2,0x01 + vpxor %ymm4,%ymm6,%ymm6 +.byte 0xc4,0xe3,0x1d,0x44,0xe2,0x10 + vpxor %ymm4,%ymm6,%ymm6 +.byte 0xc4,0xe3,0x1d,0x44,0xe2,0x11 + vpxor %ymm4,%ymm7,%ymm7 + +L$reduce__func2: + + vbroadcasti128 L$gfpoly(%rip),%ymm2 +.byte 0xc4,0xe3,0x6d,0x44,0xdd,0x01 + vpshufd $0x4e,%ymm5,%ymm5 + vpxor %ymm5,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 +.byte 0xc4,0xe3,0x6d,0x44,0xde,0x01 + vpshufd $0x4e,%ymm6,%ymm6 + vpxor %ymm6,%ymm7,%ymm7 + vpxor %ymm3,%ymm7,%ymm7 + vextracti128 $1,%ymm7,%xmm1 + vpxor %xmm7,%xmm1,%xmm1 + +L$done__func2: + + vpshufb %xmm0,%xmm1,%xmm1 + vmovdqu %xmm1,(%r12) + + vzeroupper + popq %r12 + + ret + + + +#endif diff --git a/http/vendor/ring/pregenerated/aes-gcm-avx2-x86_64-nasm.asm b/http/vendor/ring/pregenerated/aes-gcm-avx2-x86_64-nasm.asm new file mode 100644 index 0000000..f07e5a3 --- /dev/null +++ b/http/vendor/ring/pregenerated/aes-gcm-avx2-x86_64-nasm.asm @@ -0,0 +1,1423 @@ +; This file is generated from a similarly-named Perl script in the BoringSSL +; source tree. Do not edit by hand. + +%ifidn __OUTPUT_FORMAT__, win64 +default rel +%define XMMWORD +%define YMMWORD +%define ZMMWORD +%define _CET_ENDBR + +%include "ring_core_generated/prefix_symbols_nasm.inc" +section .rdata rdata align=8 +ALIGN 16 + + +$L$bswap_mask: + DQ 0x08090a0b0c0d0e0f,0x0001020304050607 + + + + + + + + +$L$gfpoly: + DQ 1,0xc200000000000000 + + +$L$gfpoly_and_internal_carrybit: + DQ 1,0xc200000000000001 + +ALIGN 32 + +$L$ctr_pattern: + DQ 0,0 + DQ 1,0 +$L$inc_2blocks: + DQ 2,0 + DQ 2,0 + +section .text code align=64 + +global gcm_init_vpclmulqdq_avx2 + +ALIGN 32 +gcm_init_vpclmulqdq_avx2: + +$L$SEH_begin_gcm_init_vpclmulqdq_avx2_1: +_CET_ENDBR + sub rsp,24 +$L$SEH_prologue_gcm_init_vpclmulqdq_avx2_2: + movdqa XMMWORD[rsp],xmm6 +$L$SEH_prologue_gcm_init_vpclmulqdq_avx2_3: + +$L$SEH_endprologue_gcm_init_vpclmulqdq_avx2_4: + + + + vpshufd xmm3,XMMWORD[rdx],0x4e + + + + + + vpshufd xmm0,xmm3,0xd3 + vpsrad xmm0,xmm0,31 + vpaddq xmm3,xmm3,xmm3 + vpand xmm0,xmm0,XMMWORD[$L$gfpoly_and_internal_carrybit] + vpxor xmm3,xmm3,xmm0 + + vbroadcasti128 ymm6,XMMWORD[$L$gfpoly] + + + vpclmulqdq xmm0,xmm3,xmm3,0x00 + vpclmulqdq xmm1,xmm3,xmm3,0x01 + vpclmulqdq xmm2,xmm3,xmm3,0x10 + vpxor xmm1,xmm1,xmm2 + vpclmulqdq xmm2,xmm6,xmm0,0x01 + vpshufd xmm0,xmm0,0x4e + vpxor xmm1,xmm1,xmm0 + vpxor xmm1,xmm1,xmm2 + vpclmulqdq xmm5,xmm3,xmm3,0x11 + vpclmulqdq xmm0,xmm6,xmm1,0x01 + vpshufd xmm1,xmm1,0x4e + vpxor xmm5,xmm5,xmm1 + vpxor xmm5,xmm5,xmm0 + + + + vinserti128 ymm3,ymm5,xmm3,1 + vinserti128 ymm5,ymm5,xmm5,1 + + + DB 0xc4,0xe3,0x65,0x44,0xc5,0x00 + DB 0xc4,0xe3,0x65,0x44,0xcd,0x01 + DB 0xc4,0xe3,0x65,0x44,0xd5,0x10 + vpxor ymm1,ymm1,ymm2 + DB 0xc4,0xe3,0x4d,0x44,0xd0,0x01 + vpshufd ymm0,ymm0,0x4e + vpxor ymm1,ymm1,ymm0 + vpxor ymm1,ymm1,ymm2 + DB 0xc4,0xe3,0x65,0x44,0xe5,0x11 + DB 0xc4,0xe3,0x4d,0x44,0xc1,0x01 + vpshufd ymm1,ymm1,0x4e + vpxor ymm4,ymm4,ymm1 + vpxor ymm4,ymm4,ymm0 + + + + vmovdqu YMMWORD[96+rcx],ymm3 + vmovdqu YMMWORD[64+rcx],ymm4 + + + + vpunpcklqdq ymm0,ymm4,ymm3 + vpunpckhqdq ymm1,ymm4,ymm3 + vpxor ymm0,ymm0,ymm1 + vmovdqu YMMWORD[(128+32)+rcx],ymm0 + + + DB 0xc4,0xe3,0x5d,0x44,0xc5,0x00 + DB 0xc4,0xe3,0x5d,0x44,0xcd,0x01 + DB 0xc4,0xe3,0x5d,0x44,0xd5,0x10 + vpxor ymm1,ymm1,ymm2 + DB 0xc4,0xe3,0x4d,0x44,0xd0,0x01 + vpshufd ymm0,ymm0,0x4e + vpxor ymm1,ymm1,ymm0 + vpxor ymm1,ymm1,ymm2 + DB 0xc4,0xe3,0x5d,0x44,0xdd,0x11 + DB 0xc4,0xe3,0x4d,0x44,0xc1,0x01 + vpshufd ymm1,ymm1,0x4e + vpxor ymm3,ymm3,ymm1 + vpxor ymm3,ymm3,ymm0 + + DB 0xc4,0xe3,0x65,0x44,0xc5,0x00 + DB 0xc4,0xe3,0x65,0x44,0xcd,0x01 + DB 0xc4,0xe3,0x65,0x44,0xd5,0x10 + vpxor ymm1,ymm1,ymm2 + DB 0xc4,0xe3,0x4d,0x44,0xd0,0x01 + vpshufd ymm0,ymm0,0x4e + vpxor ymm1,ymm1,ymm0 + vpxor ymm1,ymm1,ymm2 + DB 0xc4,0xe3,0x65,0x44,0xe5,0x11 + DB 0xc4,0xe3,0x4d,0x44,0xc1,0x01 + vpshufd ymm1,ymm1,0x4e + vpxor ymm4,ymm4,ymm1 + vpxor ymm4,ymm4,ymm0 + + vmovdqu YMMWORD[32+rcx],ymm3 + vmovdqu YMMWORD[rcx],ymm4 + + + + vpunpcklqdq ymm0,ymm4,ymm3 + vpunpckhqdq ymm1,ymm4,ymm3 + vpxor ymm0,ymm0,ymm1 + vmovdqu YMMWORD[128+rcx],ymm0 + + vzeroupper + movdqa xmm6,XMMWORD[rsp] + add rsp,24 + ret +$L$SEH_end_gcm_init_vpclmulqdq_avx2_5: + + +global gcm_ghash_vpclmulqdq_avx2_1 + +ALIGN 32 +gcm_ghash_vpclmulqdq_avx2_1: + +$L$SEH_begin_gcm_ghash_vpclmulqdq_avx2_1_1: +_CET_ENDBR + sub rsp,72 +$L$SEH_prologue_gcm_ghash_vpclmulqdq_avx2_1_2: + movdqa XMMWORD[rsp],xmm6 +$L$SEH_prologue_gcm_ghash_vpclmulqdq_avx2_1_3: + movdqa XMMWORD[16+rsp],xmm7 +$L$SEH_prologue_gcm_ghash_vpclmulqdq_avx2_1_4: + movdqa XMMWORD[32+rsp],xmm8 +$L$SEH_prologue_gcm_ghash_vpclmulqdq_avx2_1_5: + movdqa XMMWORD[48+rsp],xmm9 +$L$SEH_prologue_gcm_ghash_vpclmulqdq_avx2_1_6: + +$L$SEH_endprologue_gcm_ghash_vpclmulqdq_avx2_1_7: + + + + + vmovdqu xmm6,XMMWORD[$L$bswap_mask] + vmovdqu xmm7,XMMWORD[$L$gfpoly] + + + vmovdqu xmm5,XMMWORD[rcx] + vpshufb xmm5,xmm5,xmm6 + + + +$L$ghash_lastblock: + vmovdqu xmm0,XMMWORD[r8] + vpshufb xmm0,xmm0,xmm6 + vpxor xmm5,xmm5,xmm0 + vmovdqu xmm0,XMMWORD[((128-16))+rdx] + vpclmulqdq xmm1,xmm5,xmm0,0x00 + vpclmulqdq xmm2,xmm5,xmm0,0x01 + vpclmulqdq xmm3,xmm5,xmm0,0x10 + vpxor xmm2,xmm2,xmm3 + vpclmulqdq xmm3,xmm7,xmm1,0x01 + vpshufd xmm1,xmm1,0x4e + vpxor xmm2,xmm2,xmm1 + vpxor xmm2,xmm2,xmm3 + vpclmulqdq xmm5,xmm5,xmm0,0x11 + vpclmulqdq xmm1,xmm7,xmm2,0x01 + vpshufd xmm2,xmm2,0x4e + vpxor xmm5,xmm5,xmm2 + vpxor xmm5,xmm5,xmm1 + + +$L$ghash_done: + + vpshufb xmm5,xmm5,xmm6 + vmovdqu XMMWORD[rcx],xmm5 + + vzeroupper + movdqa xmm6,XMMWORD[rsp] + movdqa xmm7,XMMWORD[16+rsp] + movdqa xmm8,XMMWORD[32+rsp] + movdqa xmm9,XMMWORD[48+rsp] + add rsp,72 + ret +$L$SEH_end_gcm_ghash_vpclmulqdq_avx2_1_8: + + +global aes_gcm_enc_update_vaes_avx2 + +ALIGN 32 +aes_gcm_enc_update_vaes_avx2: + +$L$SEH_begin_aes_gcm_enc_update_vaes_avx2_1: +_CET_ENDBR + push rsi +$L$SEH_prologue_aes_gcm_enc_update_vaes_avx2_2: + push rdi +$L$SEH_prologue_aes_gcm_enc_update_vaes_avx2_3: + push r12 +$L$SEH_prologue_aes_gcm_enc_update_vaes_avx2_4: + + mov rsi,QWORD[64+rsp] + mov rdi,QWORD[72+rsp] + mov r12,QWORD[80+rsp] + sub rsp,160 +$L$SEH_prologue_aes_gcm_enc_update_vaes_avx2_5: + movdqa XMMWORD[rsp],xmm6 +$L$SEH_prologue_aes_gcm_enc_update_vaes_avx2_6: + movdqa XMMWORD[16+rsp],xmm7 +$L$SEH_prologue_aes_gcm_enc_update_vaes_avx2_7: + movdqa XMMWORD[32+rsp],xmm8 +$L$SEH_prologue_aes_gcm_enc_update_vaes_avx2_8: + movdqa XMMWORD[48+rsp],xmm9 +$L$SEH_prologue_aes_gcm_enc_update_vaes_avx2_9: + movdqa XMMWORD[64+rsp],xmm10 +$L$SEH_prologue_aes_gcm_enc_update_vaes_avx2_10: + movdqa XMMWORD[80+rsp],xmm11 +$L$SEH_prologue_aes_gcm_enc_update_vaes_avx2_11: + movdqa XMMWORD[96+rsp],xmm12 +$L$SEH_prologue_aes_gcm_enc_update_vaes_avx2_12: + movdqa XMMWORD[112+rsp],xmm13 +$L$SEH_prologue_aes_gcm_enc_update_vaes_avx2_13: + movdqa XMMWORD[128+rsp],xmm14 +$L$SEH_prologue_aes_gcm_enc_update_vaes_avx2_14: + movdqa XMMWORD[144+rsp],xmm15 +$L$SEH_prologue_aes_gcm_enc_update_vaes_avx2_15: + +$L$SEH_endprologue_aes_gcm_enc_update_vaes_avx2_16: +%ifdef BORINGSSL_DISPATCH_TEST +EXTERN BORINGSSL_function_hit + mov BYTE[((BORINGSSL_function_hit+8))],1 +%endif + vbroadcasti128 ymm0,XMMWORD[$L$bswap_mask] + + + + vmovdqu xmm1,XMMWORD[r12] + vpshufb xmm1,xmm1,xmm0 + vbroadcasti128 ymm11,XMMWORD[rsi] + vpshufb ymm11,ymm11,ymm0 + + + + mov r10d,DWORD[240+r9] + lea r10d,[((-20))+r10*4] + + + + + lea r11,[96+r10*4+r9] + vbroadcasti128 ymm9,XMMWORD[r9] + vbroadcasti128 ymm10,XMMWORD[r11] + + + vpaddd ymm11,ymm11,YMMWORD[$L$ctr_pattern] + + + + cmp r8,127 + jbe NEAR $L$crypt_loop_4x_done__func1 + + vmovdqu ymm7,YMMWORD[128+rdi] + vmovdqu ymm8,YMMWORD[((128+32))+rdi] + + + + vmovdqu ymm2,YMMWORD[$L$inc_2blocks] + vpshufb ymm12,ymm11,ymm0 + vpaddd ymm11,ymm11,ymm2 + vpshufb ymm13,ymm11,ymm0 + vpaddd ymm11,ymm11,ymm2 + vpshufb ymm14,ymm11,ymm0 + vpaddd ymm11,ymm11,ymm2 + vpshufb ymm15,ymm11,ymm0 + vpaddd ymm11,ymm11,ymm2 + + + vpxor ymm12,ymm12,ymm9 + vpxor ymm13,ymm13,ymm9 + vpxor ymm14,ymm14,ymm9 + vpxor ymm15,ymm15,ymm9 + + lea rax,[16+r9] +$L$vaesenc_loop_first_4_vecs__func1: + vbroadcasti128 ymm2,XMMWORD[rax] + DB 0xc4,0x62,0x1d,0xdc,0xe2 + DB 0xc4,0x62,0x15,0xdc,0xea + DB 0xc4,0x62,0x0d,0xdc,0xf2 + DB 0xc4,0x62,0x05,0xdc,0xfa + + add rax,16 + cmp r11,rax + jne NEAR $L$vaesenc_loop_first_4_vecs__func1 + vpxor ymm2,ymm10,YMMWORD[rcx] + vpxor ymm3,ymm10,YMMWORD[32+rcx] + vpxor ymm5,ymm10,YMMWORD[64+rcx] + vpxor ymm6,ymm10,YMMWORD[96+rcx] + DB 0xc4,0x62,0x1d,0xdd,0xe2 + DB 0xc4,0x62,0x15,0xdd,0xeb + DB 0xc4,0x62,0x0d,0xdd,0xf5 + DB 0xc4,0x62,0x05,0xdd,0xfe + vmovdqu YMMWORD[rdx],ymm12 + vmovdqu YMMWORD[32+rdx],ymm13 + vmovdqu YMMWORD[64+rdx],ymm14 + vmovdqu YMMWORD[96+rdx],ymm15 + + sub rcx,-128 + add r8,-128 + cmp r8,127 + jbe NEAR $L$ghash_last_ciphertext_4x__func1 +ALIGN 16 +$L$crypt_loop_4x__func1: + + + + + vmovdqu ymm2,YMMWORD[$L$inc_2blocks] + vpshufb ymm12,ymm11,ymm0 + vpaddd ymm11,ymm11,ymm2 + vpshufb ymm13,ymm11,ymm0 + vpaddd ymm11,ymm11,ymm2 + vpshufb ymm14,ymm11,ymm0 + vpaddd ymm11,ymm11,ymm2 + vpshufb ymm15,ymm11,ymm0 + vpaddd ymm11,ymm11,ymm2 + + + vpxor ymm12,ymm12,ymm9 + vpxor ymm13,ymm13,ymm9 + vpxor ymm14,ymm14,ymm9 + vpxor ymm15,ymm15,ymm9 + + cmp r10d,24 + jl NEAR $L$aes128__func1 + je NEAR $L$aes192__func1 + + vbroadcasti128 ymm2,XMMWORD[((-208))+r11] + DB 0xc4,0x62,0x1d,0xdc,0xe2 + DB 0xc4,0x62,0x15,0xdc,0xea + DB 0xc4,0x62,0x0d,0xdc,0xf2 + DB 0xc4,0x62,0x05,0xdc,0xfa + + vbroadcasti128 ymm2,XMMWORD[((-192))+r11] + DB 0xc4,0x62,0x1d,0xdc,0xe2 + DB 0xc4,0x62,0x15,0xdc,0xea + DB 0xc4,0x62,0x0d,0xdc,0xf2 + DB 0xc4,0x62,0x05,0xdc,0xfa + +$L$aes192__func1: + vbroadcasti128 ymm2,XMMWORD[((-176))+r11] + DB 0xc4,0x62,0x1d,0xdc,0xe2 + DB 0xc4,0x62,0x15,0xdc,0xea + DB 0xc4,0x62,0x0d,0xdc,0xf2 + DB 0xc4,0x62,0x05,0xdc,0xfa + + vbroadcasti128 ymm2,XMMWORD[((-160))+r11] + DB 0xc4,0x62,0x1d,0xdc,0xe2 + DB 0xc4,0x62,0x15,0xdc,0xea + DB 0xc4,0x62,0x0d,0xdc,0xf2 + DB 0xc4,0x62,0x05,0xdc,0xfa + +$L$aes128__func1: + prefetcht0 [512+rcx] + prefetcht0 [((512+64))+rcx] + + vmovdqu ymm3,YMMWORD[rdx] + vpshufb ymm3,ymm3,ymm0 + vmovdqu ymm4,YMMWORD[rdi] + vpxor ymm3,ymm3,ymm1 + DB 0xc4,0xe3,0x65,0x44,0xec,0x00 + DB 0xc4,0xe3,0x65,0x44,0xcc,0x11 + vpunpckhqdq ymm2,ymm3,ymm3 + vpxor ymm2,ymm2,ymm3 + DB 0xc4,0xe3,0x6d,0x44,0xf7,0x00 + + vbroadcasti128 ymm2,XMMWORD[((-144))+r11] + DB 0xc4,0x62,0x1d,0xdc,0xe2 + DB 0xc4,0x62,0x15,0xdc,0xea + DB 0xc4,0x62,0x0d,0xdc,0xf2 + DB 0xc4,0x62,0x05,0xdc,0xfa + + + vbroadcasti128 ymm2,XMMWORD[((-128))+r11] + DB 0xc4,0x62,0x1d,0xdc,0xe2 + DB 0xc4,0x62,0x15,0xdc,0xea + DB 0xc4,0x62,0x0d,0xdc,0xf2 + DB 0xc4,0x62,0x05,0xdc,0xfa + + + vmovdqu ymm3,YMMWORD[32+rdx] + vpshufb ymm3,ymm3,ymm0 + vmovdqu ymm4,YMMWORD[32+rdi] + DB 0xc4,0xe3,0x65,0x44,0xd4,0x00 + vpxor ymm5,ymm5,ymm2 + DB 0xc4,0xe3,0x65,0x44,0xd4,0x11 + vpxor ymm1,ymm1,ymm2 + vpunpckhqdq ymm2,ymm3,ymm3 + vpxor ymm2,ymm2,ymm3 + DB 0xc4,0xe3,0x6d,0x44,0xd7,0x10 + vpxor ymm6,ymm6,ymm2 + + vbroadcasti128 ymm2,XMMWORD[((-112))+r11] + DB 0xc4,0x62,0x1d,0xdc,0xe2 + DB 0xc4,0x62,0x15,0xdc,0xea + DB 0xc4,0x62,0x0d,0xdc,0xf2 + DB 0xc4,0x62,0x05,0xdc,0xfa + + + vmovdqu ymm3,YMMWORD[64+rdx] + vpshufb ymm3,ymm3,ymm0 + vmovdqu ymm4,YMMWORD[64+rdi] + + vbroadcasti128 ymm2,XMMWORD[((-96))+r11] + DB 0xc4,0x62,0x1d,0xdc,0xe2 + DB 0xc4,0x62,0x15,0xdc,0xea + DB 0xc4,0x62,0x0d,0xdc,0xf2 + DB 0xc4,0x62,0x05,0xdc,0xfa + + DB 0xc4,0xe3,0x65,0x44,0xd4,0x00 + vpxor ymm5,ymm5,ymm2 + DB 0xc4,0xe3,0x65,0x44,0xd4,0x11 + vpxor ymm1,ymm1,ymm2 + + vbroadcasti128 ymm2,XMMWORD[((-80))+r11] + DB 0xc4,0x62,0x1d,0xdc,0xe2 + DB 0xc4,0x62,0x15,0xdc,0xea + DB 0xc4,0x62,0x0d,0xdc,0xf2 + DB 0xc4,0x62,0x05,0xdc,0xfa + + vpunpckhqdq ymm2,ymm3,ymm3 + vpxor ymm2,ymm2,ymm3 + DB 0xc4,0xc3,0x6d,0x44,0xd0,0x00 + vpxor ymm6,ymm6,ymm2 + + + vmovdqu ymm3,YMMWORD[96+rdx] + vpshufb ymm3,ymm3,ymm0 + + vbroadcasti128 ymm2,XMMWORD[((-64))+r11] + DB 0xc4,0x62,0x1d,0xdc,0xe2 + DB 0xc4,0x62,0x15,0xdc,0xea + DB 0xc4,0x62,0x0d,0xdc,0xf2 + DB 0xc4,0x62,0x05,0xdc,0xfa + + vmovdqu ymm4,YMMWORD[96+rdi] + DB 0xc4,0xe3,0x65,0x44,0xd4,0x00 + vpxor ymm5,ymm5,ymm2 + DB 0xc4,0xe3,0x65,0x44,0xd4,0x11 + vpxor ymm1,ymm1,ymm2 + vpunpckhqdq ymm2,ymm3,ymm3 + vpxor ymm2,ymm2,ymm3 + DB 0xc4,0xc3,0x6d,0x44,0xd0,0x10 + vpxor ymm6,ymm6,ymm2 + + vbroadcasti128 ymm2,XMMWORD[((-48))+r11] + DB 0xc4,0x62,0x1d,0xdc,0xe2 + DB 0xc4,0x62,0x15,0xdc,0xea + DB 0xc4,0x62,0x0d,0xdc,0xf2 + DB 0xc4,0x62,0x05,0xdc,0xfa + + + vpxor ymm6,ymm6,ymm5 + vpxor ymm6,ymm6,ymm1 + + + vbroadcasti128 ymm4,XMMWORD[$L$gfpoly] + DB 0xc4,0xe3,0x5d,0x44,0xd5,0x01 + vpshufd ymm5,ymm5,0x4e + vpxor ymm6,ymm6,ymm5 + vpxor ymm6,ymm6,ymm2 + + vbroadcasti128 ymm2,XMMWORD[((-32))+r11] + DB 0xc4,0x62,0x1d,0xdc,0xe2 + DB 0xc4,0x62,0x15,0xdc,0xea + DB 0xc4,0x62,0x0d,0xdc,0xf2 + DB 0xc4,0x62,0x05,0xdc,0xfa + + + DB 0xc4,0xe3,0x5d,0x44,0xd6,0x01 + vpshufd ymm6,ymm6,0x4e + vpxor ymm1,ymm1,ymm6 + vpxor ymm1,ymm1,ymm2 + + vbroadcasti128 ymm2,XMMWORD[((-16))+r11] + DB 0xc4,0x62,0x1d,0xdc,0xe2 + DB 0xc4,0x62,0x15,0xdc,0xea + DB 0xc4,0x62,0x0d,0xdc,0xf2 + DB 0xc4,0x62,0x05,0xdc,0xfa + + vextracti128 xmm2,ymm1,1 + vpxor xmm1,xmm1,xmm2 + + + sub rdx,-128 + vpxor ymm2,ymm10,YMMWORD[rcx] + vpxor ymm3,ymm10,YMMWORD[32+rcx] + vpxor ymm5,ymm10,YMMWORD[64+rcx] + vpxor ymm6,ymm10,YMMWORD[96+rcx] + DB 0xc4,0x62,0x1d,0xdd,0xe2 + DB 0xc4,0x62,0x15,0xdd,0xeb + DB 0xc4,0x62,0x0d,0xdd,0xf5 + DB 0xc4,0x62,0x05,0xdd,0xfe + vmovdqu YMMWORD[rdx],ymm12 + vmovdqu YMMWORD[32+rdx],ymm13 + vmovdqu YMMWORD[64+rdx],ymm14 + vmovdqu YMMWORD[96+rdx],ymm15 + + sub rcx,-128 + + add r8,-128 + cmp r8,127 + ja NEAR $L$crypt_loop_4x__func1 +$L$ghash_last_ciphertext_4x__func1: + + vmovdqu ymm3,YMMWORD[rdx] + vpshufb ymm3,ymm3,ymm0 + vmovdqu ymm4,YMMWORD[rdi] + vpxor ymm3,ymm3,ymm1 + DB 0xc4,0xe3,0x65,0x44,0xec,0x00 + DB 0xc4,0xe3,0x65,0x44,0xcc,0x11 + vpunpckhqdq ymm2,ymm3,ymm3 + vpxor ymm2,ymm2,ymm3 + DB 0xc4,0xe3,0x6d,0x44,0xf7,0x00 + + vmovdqu ymm3,YMMWORD[32+rdx] + vpshufb ymm3,ymm3,ymm0 + vmovdqu ymm4,YMMWORD[32+rdi] + DB 0xc4,0xe3,0x65,0x44,0xd4,0x00 + vpxor ymm5,ymm5,ymm2 + DB 0xc4,0xe3,0x65,0x44,0xd4,0x11 + vpxor ymm1,ymm1,ymm2 + vpunpckhqdq ymm2,ymm3,ymm3 + vpxor ymm2,ymm2,ymm3 + DB 0xc4,0xe3,0x6d,0x44,0xd7,0x10 + vpxor ymm6,ymm6,ymm2 + + vmovdqu ymm3,YMMWORD[64+rdx] + vpshufb ymm3,ymm3,ymm0 + vmovdqu ymm4,YMMWORD[64+rdi] + DB 0xc4,0xe3,0x65,0x44,0xd4,0x00 + vpxor ymm5,ymm5,ymm2 + DB 0xc4,0xe3,0x65,0x44,0xd4,0x11 + vpxor ymm1,ymm1,ymm2 + vpunpckhqdq ymm2,ymm3,ymm3 + vpxor ymm2,ymm2,ymm3 + DB 0xc4,0xc3,0x6d,0x44,0xd0,0x00 + vpxor ymm6,ymm6,ymm2 + + + vmovdqu ymm3,YMMWORD[96+rdx] + vpshufb ymm3,ymm3,ymm0 + vmovdqu ymm4,YMMWORD[96+rdi] + DB 0xc4,0xe3,0x65,0x44,0xd4,0x00 + vpxor ymm5,ymm5,ymm2 + DB 0xc4,0xe3,0x65,0x44,0xd4,0x11 + vpxor ymm1,ymm1,ymm2 + vpunpckhqdq ymm2,ymm3,ymm3 + vpxor ymm2,ymm2,ymm3 + DB 0xc4,0xc3,0x6d,0x44,0xd0,0x10 + vpxor ymm6,ymm6,ymm2 + + vpxor ymm6,ymm6,ymm5 + vpxor ymm6,ymm6,ymm1 + + + vbroadcasti128 ymm4,XMMWORD[$L$gfpoly] + DB 0xc4,0xe3,0x5d,0x44,0xd5,0x01 + vpshufd ymm5,ymm5,0x4e + vpxor ymm6,ymm6,ymm5 + vpxor ymm6,ymm6,ymm2 + + DB 0xc4,0xe3,0x5d,0x44,0xd6,0x01 + vpshufd ymm6,ymm6,0x4e + vpxor ymm1,ymm1,ymm6 + vpxor ymm1,ymm1,ymm2 + vextracti128 xmm2,ymm1,1 + vpxor xmm1,xmm1,xmm2 + + sub rdx,-128 +$L$crypt_loop_4x_done__func1: + + test r8,r8 + jz NEAR $L$done__func1 + + + + + + lea rsi,[128+rdi] + sub rsi,r8 + + + vpxor xmm5,xmm5,xmm5 + vpxor xmm6,xmm6,xmm6 + vpxor xmm7,xmm7,xmm7 + + cmp r8,64 + jb NEAR $L$lessthan64bytes__func1 + + + vpshufb ymm12,ymm11,ymm0 + vpaddd ymm11,ymm11,YMMWORD[$L$inc_2blocks] + vpshufb ymm13,ymm11,ymm0 + vpaddd ymm11,ymm11,YMMWORD[$L$inc_2blocks] + vpxor ymm12,ymm12,ymm9 + vpxor ymm13,ymm13,ymm9 + lea rax,[16+r9] +$L$vaesenc_loop_tail_1__func1: + vbroadcasti128 ymm2,XMMWORD[rax] + DB 0xc4,0x62,0x1d,0xdc,0xe2 + DB 0xc4,0x62,0x15,0xdc,0xea + add rax,16 + cmp r11,rax + jne NEAR $L$vaesenc_loop_tail_1__func1 + DB 0xc4,0x42,0x1d,0xdd,0xe2 + DB 0xc4,0x42,0x15,0xdd,0xea + + + vmovdqu ymm2,YMMWORD[rcx] + vmovdqu ymm3,YMMWORD[32+rcx] + vpxor ymm12,ymm12,ymm2 + vpxor ymm13,ymm13,ymm3 + vmovdqu YMMWORD[rdx],ymm12 + vmovdqu YMMWORD[32+rdx],ymm13 + + + vpshufb ymm12,ymm12,ymm0 + vpshufb ymm13,ymm13,ymm0 + vpxor ymm12,ymm12,ymm1 + vmovdqu ymm2,YMMWORD[rsi] + vmovdqu ymm3,YMMWORD[32+rsi] + DB 0xc4,0xe3,0x1d,0x44,0xea,0x00 + DB 0xc4,0xe3,0x1d,0x44,0xf2,0x01 + DB 0xc4,0xe3,0x1d,0x44,0xe2,0x10 + vpxor ymm6,ymm6,ymm4 + DB 0xc4,0xe3,0x1d,0x44,0xfa,0x11 + DB 0xc4,0xe3,0x15,0x44,0xe3,0x00 + vpxor ymm5,ymm5,ymm4 + DB 0xc4,0xe3,0x15,0x44,0xe3,0x01 + vpxor ymm6,ymm6,ymm4 + DB 0xc4,0xe3,0x15,0x44,0xe3,0x10 + vpxor ymm6,ymm6,ymm4 + DB 0xc4,0xe3,0x15,0x44,0xe3,0x11 + vpxor ymm7,ymm7,ymm4 + + add rsi,64 + add rcx,64 + add rdx,64 + sub r8,64 + jz NEAR $L$reduce__func1 + + vpxor xmm1,xmm1,xmm1 + + +$L$lessthan64bytes__func1: + vpshufb ymm12,ymm11,ymm0 + vpaddd ymm11,ymm11,YMMWORD[$L$inc_2blocks] + vpshufb ymm13,ymm11,ymm0 + vpxor ymm12,ymm12,ymm9 + vpxor ymm13,ymm13,ymm9 + lea rax,[16+r9] +$L$vaesenc_loop_tail_2__func1: + vbroadcasti128 ymm2,XMMWORD[rax] + DB 0xc4,0x62,0x1d,0xdc,0xe2 + DB 0xc4,0x62,0x15,0xdc,0xea + add rax,16 + cmp r11,rax + jne NEAR $L$vaesenc_loop_tail_2__func1 + DB 0xc4,0x42,0x1d,0xdd,0xe2 + DB 0xc4,0x42,0x15,0xdd,0xea + + + + + cmp r8,32 + jb NEAR $L$xor_one_block__func1 + je NEAR $L$xor_two_blocks__func1 + +$L$xor_three_blocks__func1: + vmovdqu ymm2,YMMWORD[rcx] + vmovdqu xmm3,XMMWORD[32+rcx] + vpxor ymm12,ymm12,ymm2 + vpxor xmm13,xmm13,xmm3 + vmovdqu YMMWORD[rdx],ymm12 + vmovdqu XMMWORD[32+rdx],xmm13 + + vpshufb ymm12,ymm12,ymm0 + vpshufb xmm13,xmm13,xmm0 + vpxor ymm12,ymm12,ymm1 + vmovdqu ymm2,YMMWORD[rsi] + vmovdqu xmm3,XMMWORD[32+rsi] + vpclmulqdq xmm4,xmm13,xmm3,0x00 + vpxor ymm5,ymm5,ymm4 + vpclmulqdq xmm4,xmm13,xmm3,0x01 + vpxor ymm6,ymm6,ymm4 + vpclmulqdq xmm4,xmm13,xmm3,0x10 + vpxor ymm6,ymm6,ymm4 + vpclmulqdq xmm4,xmm13,xmm3,0x11 + vpxor ymm7,ymm7,ymm4 + jmp NEAR $L$ghash_mul_one_vec_unreduced__func1 + +$L$xor_two_blocks__func1: + vmovdqu ymm2,YMMWORD[rcx] + vpxor ymm12,ymm12,ymm2 + vmovdqu YMMWORD[rdx],ymm12 + vpshufb ymm12,ymm12,ymm0 + vpxor ymm12,ymm12,ymm1 + vmovdqu ymm2,YMMWORD[rsi] + jmp NEAR $L$ghash_mul_one_vec_unreduced__func1 + +$L$xor_one_block__func1: + vmovdqu xmm2,XMMWORD[rcx] + vpxor xmm12,xmm12,xmm2 + vmovdqu XMMWORD[rdx],xmm12 + vpshufb xmm12,xmm12,xmm0 + vpxor xmm12,xmm12,xmm1 + vmovdqu xmm2,XMMWORD[rsi] + +$L$ghash_mul_one_vec_unreduced__func1: + DB 0xc4,0xe3,0x1d,0x44,0xe2,0x00 + vpxor ymm5,ymm5,ymm4 + DB 0xc4,0xe3,0x1d,0x44,0xe2,0x01 + vpxor ymm6,ymm6,ymm4 + DB 0xc4,0xe3,0x1d,0x44,0xe2,0x10 + vpxor ymm6,ymm6,ymm4 + DB 0xc4,0xe3,0x1d,0x44,0xe2,0x11 + vpxor ymm7,ymm7,ymm4 + +$L$reduce__func1: + + vbroadcasti128 ymm2,XMMWORD[$L$gfpoly] + DB 0xc4,0xe3,0x6d,0x44,0xdd,0x01 + vpshufd ymm5,ymm5,0x4e + vpxor ymm6,ymm6,ymm5 + vpxor ymm6,ymm6,ymm3 + DB 0xc4,0xe3,0x6d,0x44,0xde,0x01 + vpshufd ymm6,ymm6,0x4e + vpxor ymm7,ymm7,ymm6 + vpxor ymm7,ymm7,ymm3 + vextracti128 xmm1,ymm7,1 + vpxor xmm1,xmm1,xmm7 + +$L$done__func1: + + vpshufb xmm1,xmm1,xmm0 + vmovdqu XMMWORD[r12],xmm1 + + vzeroupper + movdqa xmm6,XMMWORD[rsp] + movdqa xmm7,XMMWORD[16+rsp] + movdqa xmm8,XMMWORD[32+rsp] + movdqa xmm9,XMMWORD[48+rsp] + movdqa xmm10,XMMWORD[64+rsp] + movdqa xmm11,XMMWORD[80+rsp] + movdqa xmm12,XMMWORD[96+rsp] + movdqa xmm13,XMMWORD[112+rsp] + movdqa xmm14,XMMWORD[128+rsp] + movdqa xmm15,XMMWORD[144+rsp] + add rsp,160 + pop r12 + pop rdi + pop rsi + ret +$L$SEH_end_aes_gcm_enc_update_vaes_avx2_17: + + +global aes_gcm_dec_update_vaes_avx2 + +ALIGN 32 +aes_gcm_dec_update_vaes_avx2: + +$L$SEH_begin_aes_gcm_dec_update_vaes_avx2_1: +_CET_ENDBR + push rsi +$L$SEH_prologue_aes_gcm_dec_update_vaes_avx2_2: + push rdi +$L$SEH_prologue_aes_gcm_dec_update_vaes_avx2_3: + push r12 +$L$SEH_prologue_aes_gcm_dec_update_vaes_avx2_4: + + mov rsi,QWORD[64+rsp] + mov rdi,QWORD[72+rsp] + mov r12,QWORD[80+rsp] + sub rsp,160 +$L$SEH_prologue_aes_gcm_dec_update_vaes_avx2_5: + movdqa XMMWORD[rsp],xmm6 +$L$SEH_prologue_aes_gcm_dec_update_vaes_avx2_6: + movdqa XMMWORD[16+rsp],xmm7 +$L$SEH_prologue_aes_gcm_dec_update_vaes_avx2_7: + movdqa XMMWORD[32+rsp],xmm8 +$L$SEH_prologue_aes_gcm_dec_update_vaes_avx2_8: + movdqa XMMWORD[48+rsp],xmm9 +$L$SEH_prologue_aes_gcm_dec_update_vaes_avx2_9: + movdqa XMMWORD[64+rsp],xmm10 +$L$SEH_prologue_aes_gcm_dec_update_vaes_avx2_10: + movdqa XMMWORD[80+rsp],xmm11 +$L$SEH_prologue_aes_gcm_dec_update_vaes_avx2_11: + movdqa XMMWORD[96+rsp],xmm12 +$L$SEH_prologue_aes_gcm_dec_update_vaes_avx2_12: + movdqa XMMWORD[112+rsp],xmm13 +$L$SEH_prologue_aes_gcm_dec_update_vaes_avx2_13: + movdqa XMMWORD[128+rsp],xmm14 +$L$SEH_prologue_aes_gcm_dec_update_vaes_avx2_14: + movdqa XMMWORD[144+rsp],xmm15 +$L$SEH_prologue_aes_gcm_dec_update_vaes_avx2_15: + +$L$SEH_endprologue_aes_gcm_dec_update_vaes_avx2_16: + vbroadcasti128 ymm0,XMMWORD[$L$bswap_mask] + + + + vmovdqu xmm1,XMMWORD[r12] + vpshufb xmm1,xmm1,xmm0 + vbroadcasti128 ymm11,XMMWORD[rsi] + vpshufb ymm11,ymm11,ymm0 + + + + mov r10d,DWORD[240+r9] + lea r10d,[((-20))+r10*4] + + + + + lea r11,[96+r10*4+r9] + vbroadcasti128 ymm9,XMMWORD[r9] + vbroadcasti128 ymm10,XMMWORD[r11] + + + vpaddd ymm11,ymm11,YMMWORD[$L$ctr_pattern] + + + + cmp r8,127 + jbe NEAR $L$crypt_loop_4x_done__func2 + + vmovdqu ymm7,YMMWORD[128+rdi] + vmovdqu ymm8,YMMWORD[((128+32))+rdi] +ALIGN 16 +$L$crypt_loop_4x__func2: + + + + + vmovdqu ymm2,YMMWORD[$L$inc_2blocks] + vpshufb ymm12,ymm11,ymm0 + vpaddd ymm11,ymm11,ymm2 + vpshufb ymm13,ymm11,ymm0 + vpaddd ymm11,ymm11,ymm2 + vpshufb ymm14,ymm11,ymm0 + vpaddd ymm11,ymm11,ymm2 + vpshufb ymm15,ymm11,ymm0 + vpaddd ymm11,ymm11,ymm2 + + + vpxor ymm12,ymm12,ymm9 + vpxor ymm13,ymm13,ymm9 + vpxor ymm14,ymm14,ymm9 + vpxor ymm15,ymm15,ymm9 + + cmp r10d,24 + jl NEAR $L$aes128__func2 + je NEAR $L$aes192__func2 + + vbroadcasti128 ymm2,XMMWORD[((-208))+r11] + DB 0xc4,0x62,0x1d,0xdc,0xe2 + DB 0xc4,0x62,0x15,0xdc,0xea + DB 0xc4,0x62,0x0d,0xdc,0xf2 + DB 0xc4,0x62,0x05,0xdc,0xfa + + vbroadcasti128 ymm2,XMMWORD[((-192))+r11] + DB 0xc4,0x62,0x1d,0xdc,0xe2 + DB 0xc4,0x62,0x15,0xdc,0xea + DB 0xc4,0x62,0x0d,0xdc,0xf2 + DB 0xc4,0x62,0x05,0xdc,0xfa + +$L$aes192__func2: + vbroadcasti128 ymm2,XMMWORD[((-176))+r11] + DB 0xc4,0x62,0x1d,0xdc,0xe2 + DB 0xc4,0x62,0x15,0xdc,0xea + DB 0xc4,0x62,0x0d,0xdc,0xf2 + DB 0xc4,0x62,0x05,0xdc,0xfa + + vbroadcasti128 ymm2,XMMWORD[((-160))+r11] + DB 0xc4,0x62,0x1d,0xdc,0xe2 + DB 0xc4,0x62,0x15,0xdc,0xea + DB 0xc4,0x62,0x0d,0xdc,0xf2 + DB 0xc4,0x62,0x05,0xdc,0xfa + +$L$aes128__func2: + prefetcht0 [512+rcx] + prefetcht0 [((512+64))+rcx] + + vmovdqu ymm3,YMMWORD[rcx] + vpshufb ymm3,ymm3,ymm0 + vmovdqu ymm4,YMMWORD[rdi] + vpxor ymm3,ymm3,ymm1 + DB 0xc4,0xe3,0x65,0x44,0xec,0x00 + DB 0xc4,0xe3,0x65,0x44,0xcc,0x11 + vpunpckhqdq ymm2,ymm3,ymm3 + vpxor ymm2,ymm2,ymm3 + DB 0xc4,0xe3,0x6d,0x44,0xf7,0x00 + + vbroadcasti128 ymm2,XMMWORD[((-144))+r11] + DB 0xc4,0x62,0x1d,0xdc,0xe2 + DB 0xc4,0x62,0x15,0xdc,0xea + DB 0xc4,0x62,0x0d,0xdc,0xf2 + DB 0xc4,0x62,0x05,0xdc,0xfa + + + vbroadcasti128 ymm2,XMMWORD[((-128))+r11] + DB 0xc4,0x62,0x1d,0xdc,0xe2 + DB 0xc4,0x62,0x15,0xdc,0xea + DB 0xc4,0x62,0x0d,0xdc,0xf2 + DB 0xc4,0x62,0x05,0xdc,0xfa + + + vmovdqu ymm3,YMMWORD[32+rcx] + vpshufb ymm3,ymm3,ymm0 + vmovdqu ymm4,YMMWORD[32+rdi] + DB 0xc4,0xe3,0x65,0x44,0xd4,0x00 + vpxor ymm5,ymm5,ymm2 + DB 0xc4,0xe3,0x65,0x44,0xd4,0x11 + vpxor ymm1,ymm1,ymm2 + vpunpckhqdq ymm2,ymm3,ymm3 + vpxor ymm2,ymm2,ymm3 + DB 0xc4,0xe3,0x6d,0x44,0xd7,0x10 + vpxor ymm6,ymm6,ymm2 + + vbroadcasti128 ymm2,XMMWORD[((-112))+r11] + DB 0xc4,0x62,0x1d,0xdc,0xe2 + DB 0xc4,0x62,0x15,0xdc,0xea + DB 0xc4,0x62,0x0d,0xdc,0xf2 + DB 0xc4,0x62,0x05,0xdc,0xfa + + + vmovdqu ymm3,YMMWORD[64+rcx] + vpshufb ymm3,ymm3,ymm0 + vmovdqu ymm4,YMMWORD[64+rdi] + + vbroadcasti128 ymm2,XMMWORD[((-96))+r11] + DB 0xc4,0x62,0x1d,0xdc,0xe2 + DB 0xc4,0x62,0x15,0xdc,0xea + DB 0xc4,0x62,0x0d,0xdc,0xf2 + DB 0xc4,0x62,0x05,0xdc,0xfa + + DB 0xc4,0xe3,0x65,0x44,0xd4,0x00 + vpxor ymm5,ymm5,ymm2 + DB 0xc4,0xe3,0x65,0x44,0xd4,0x11 + vpxor ymm1,ymm1,ymm2 + + vbroadcasti128 ymm2,XMMWORD[((-80))+r11] + DB 0xc4,0x62,0x1d,0xdc,0xe2 + DB 0xc4,0x62,0x15,0xdc,0xea + DB 0xc4,0x62,0x0d,0xdc,0xf2 + DB 0xc4,0x62,0x05,0xdc,0xfa + + vpunpckhqdq ymm2,ymm3,ymm3 + vpxor ymm2,ymm2,ymm3 + DB 0xc4,0xc3,0x6d,0x44,0xd0,0x00 + vpxor ymm6,ymm6,ymm2 + + + vmovdqu ymm3,YMMWORD[96+rcx] + vpshufb ymm3,ymm3,ymm0 + + vbroadcasti128 ymm2,XMMWORD[((-64))+r11] + DB 0xc4,0x62,0x1d,0xdc,0xe2 + DB 0xc4,0x62,0x15,0xdc,0xea + DB 0xc4,0x62,0x0d,0xdc,0xf2 + DB 0xc4,0x62,0x05,0xdc,0xfa + + vmovdqu ymm4,YMMWORD[96+rdi] + DB 0xc4,0xe3,0x65,0x44,0xd4,0x00 + vpxor ymm5,ymm5,ymm2 + DB 0xc4,0xe3,0x65,0x44,0xd4,0x11 + vpxor ymm1,ymm1,ymm2 + vpunpckhqdq ymm2,ymm3,ymm3 + vpxor ymm2,ymm2,ymm3 + DB 0xc4,0xc3,0x6d,0x44,0xd0,0x10 + vpxor ymm6,ymm6,ymm2 + + vbroadcasti128 ymm2,XMMWORD[((-48))+r11] + DB 0xc4,0x62,0x1d,0xdc,0xe2 + DB 0xc4,0x62,0x15,0xdc,0xea + DB 0xc4,0x62,0x0d,0xdc,0xf2 + DB 0xc4,0x62,0x05,0xdc,0xfa + + + vpxor ymm6,ymm6,ymm5 + vpxor ymm6,ymm6,ymm1 + + + vbroadcasti128 ymm4,XMMWORD[$L$gfpoly] + DB 0xc4,0xe3,0x5d,0x44,0xd5,0x01 + vpshufd ymm5,ymm5,0x4e + vpxor ymm6,ymm6,ymm5 + vpxor ymm6,ymm6,ymm2 + + vbroadcasti128 ymm2,XMMWORD[((-32))+r11] + DB 0xc4,0x62,0x1d,0xdc,0xe2 + DB 0xc4,0x62,0x15,0xdc,0xea + DB 0xc4,0x62,0x0d,0xdc,0xf2 + DB 0xc4,0x62,0x05,0xdc,0xfa + + + DB 0xc4,0xe3,0x5d,0x44,0xd6,0x01 + vpshufd ymm6,ymm6,0x4e + vpxor ymm1,ymm1,ymm6 + vpxor ymm1,ymm1,ymm2 + + vbroadcasti128 ymm2,XMMWORD[((-16))+r11] + DB 0xc4,0x62,0x1d,0xdc,0xe2 + DB 0xc4,0x62,0x15,0xdc,0xea + DB 0xc4,0x62,0x0d,0xdc,0xf2 + DB 0xc4,0x62,0x05,0xdc,0xfa + + vextracti128 xmm2,ymm1,1 + vpxor xmm1,xmm1,xmm2 + + + + vpxor ymm2,ymm10,YMMWORD[rcx] + vpxor ymm3,ymm10,YMMWORD[32+rcx] + vpxor ymm5,ymm10,YMMWORD[64+rcx] + vpxor ymm6,ymm10,YMMWORD[96+rcx] + DB 0xc4,0x62,0x1d,0xdd,0xe2 + DB 0xc4,0x62,0x15,0xdd,0xeb + DB 0xc4,0x62,0x0d,0xdd,0xf5 + DB 0xc4,0x62,0x05,0xdd,0xfe + vmovdqu YMMWORD[rdx],ymm12 + vmovdqu YMMWORD[32+rdx],ymm13 + vmovdqu YMMWORD[64+rdx],ymm14 + vmovdqu YMMWORD[96+rdx],ymm15 + + sub rcx,-128 + sub rdx,-128 + add r8,-128 + cmp r8,127 + ja NEAR $L$crypt_loop_4x__func2 +$L$crypt_loop_4x_done__func2: + + test r8,r8 + jz NEAR $L$done__func2 + + + + + + lea rsi,[128+rdi] + sub rsi,r8 + + + vpxor xmm5,xmm5,xmm5 + vpxor xmm6,xmm6,xmm6 + vpxor xmm7,xmm7,xmm7 + + cmp r8,64 + jb NEAR $L$lessthan64bytes__func2 + + + vpshufb ymm12,ymm11,ymm0 + vpaddd ymm11,ymm11,YMMWORD[$L$inc_2blocks] + vpshufb ymm13,ymm11,ymm0 + vpaddd ymm11,ymm11,YMMWORD[$L$inc_2blocks] + vpxor ymm12,ymm12,ymm9 + vpxor ymm13,ymm13,ymm9 + lea rax,[16+r9] +$L$vaesenc_loop_tail_1__func2: + vbroadcasti128 ymm2,XMMWORD[rax] + DB 0xc4,0x62,0x1d,0xdc,0xe2 + DB 0xc4,0x62,0x15,0xdc,0xea + add rax,16 + cmp r11,rax + jne NEAR $L$vaesenc_loop_tail_1__func2 + DB 0xc4,0x42,0x1d,0xdd,0xe2 + DB 0xc4,0x42,0x15,0xdd,0xea + + + vmovdqu ymm2,YMMWORD[rcx] + vmovdqu ymm3,YMMWORD[32+rcx] + vpxor ymm12,ymm12,ymm2 + vpxor ymm13,ymm13,ymm3 + vmovdqu YMMWORD[rdx],ymm12 + vmovdqu YMMWORD[32+rdx],ymm13 + + + vpshufb ymm12,ymm2,ymm0 + vpshufb ymm13,ymm3,ymm0 + vpxor ymm12,ymm12,ymm1 + vmovdqu ymm2,YMMWORD[rsi] + vmovdqu ymm3,YMMWORD[32+rsi] + DB 0xc4,0xe3,0x1d,0x44,0xea,0x00 + DB 0xc4,0xe3,0x1d,0x44,0xf2,0x01 + DB 0xc4,0xe3,0x1d,0x44,0xe2,0x10 + vpxor ymm6,ymm6,ymm4 + DB 0xc4,0xe3,0x1d,0x44,0xfa,0x11 + DB 0xc4,0xe3,0x15,0x44,0xe3,0x00 + vpxor ymm5,ymm5,ymm4 + DB 0xc4,0xe3,0x15,0x44,0xe3,0x01 + vpxor ymm6,ymm6,ymm4 + DB 0xc4,0xe3,0x15,0x44,0xe3,0x10 + vpxor ymm6,ymm6,ymm4 + DB 0xc4,0xe3,0x15,0x44,0xe3,0x11 + vpxor ymm7,ymm7,ymm4 + + add rsi,64 + add rcx,64 + add rdx,64 + sub r8,64 + jz NEAR $L$reduce__func2 + + vpxor xmm1,xmm1,xmm1 + + +$L$lessthan64bytes__func2: + vpshufb ymm12,ymm11,ymm0 + vpaddd ymm11,ymm11,YMMWORD[$L$inc_2blocks] + vpshufb ymm13,ymm11,ymm0 + vpxor ymm12,ymm12,ymm9 + vpxor ymm13,ymm13,ymm9 + lea rax,[16+r9] +$L$vaesenc_loop_tail_2__func2: + vbroadcasti128 ymm2,XMMWORD[rax] + DB 0xc4,0x62,0x1d,0xdc,0xe2 + DB 0xc4,0x62,0x15,0xdc,0xea + add rax,16 + cmp r11,rax + jne NEAR $L$vaesenc_loop_tail_2__func2 + DB 0xc4,0x42,0x1d,0xdd,0xe2 + DB 0xc4,0x42,0x15,0xdd,0xea + + + + + cmp r8,32 + jb NEAR $L$xor_one_block__func2 + je NEAR $L$xor_two_blocks__func2 + +$L$xor_three_blocks__func2: + vmovdqu ymm2,YMMWORD[rcx] + vmovdqu xmm3,XMMWORD[32+rcx] + vpxor ymm12,ymm12,ymm2 + vpxor xmm13,xmm13,xmm3 + vmovdqu YMMWORD[rdx],ymm12 + vmovdqu XMMWORD[32+rdx],xmm13 + + vpshufb ymm12,ymm2,ymm0 + vpshufb xmm13,xmm3,xmm0 + vpxor ymm12,ymm12,ymm1 + vmovdqu ymm2,YMMWORD[rsi] + vmovdqu xmm3,XMMWORD[32+rsi] + vpclmulqdq xmm4,xmm13,xmm3,0x00 + vpxor ymm5,ymm5,ymm4 + vpclmulqdq xmm4,xmm13,xmm3,0x01 + vpxor ymm6,ymm6,ymm4 + vpclmulqdq xmm4,xmm13,xmm3,0x10 + vpxor ymm6,ymm6,ymm4 + vpclmulqdq xmm4,xmm13,xmm3,0x11 + vpxor ymm7,ymm7,ymm4 + jmp NEAR $L$ghash_mul_one_vec_unreduced__func2 + +$L$xor_two_blocks__func2: + vmovdqu ymm2,YMMWORD[rcx] + vpxor ymm12,ymm12,ymm2 + vmovdqu YMMWORD[rdx],ymm12 + vpshufb ymm12,ymm2,ymm0 + vpxor ymm12,ymm12,ymm1 + vmovdqu ymm2,YMMWORD[rsi] + jmp NEAR $L$ghash_mul_one_vec_unreduced__func2 + +$L$xor_one_block__func2: + vmovdqu xmm2,XMMWORD[rcx] + vpxor xmm12,xmm12,xmm2 + vmovdqu XMMWORD[rdx],xmm12 + vpshufb xmm12,xmm2,xmm0 + vpxor xmm12,xmm12,xmm1 + vmovdqu xmm2,XMMWORD[rsi] + +$L$ghash_mul_one_vec_unreduced__func2: + DB 0xc4,0xe3,0x1d,0x44,0xe2,0x00 + vpxor ymm5,ymm5,ymm4 + DB 0xc4,0xe3,0x1d,0x44,0xe2,0x01 + vpxor ymm6,ymm6,ymm4 + DB 0xc4,0xe3,0x1d,0x44,0xe2,0x10 + vpxor ymm6,ymm6,ymm4 + DB 0xc4,0xe3,0x1d,0x44,0xe2,0x11 + vpxor ymm7,ymm7,ymm4 + +$L$reduce__func2: + + vbroadcasti128 ymm2,XMMWORD[$L$gfpoly] + DB 0xc4,0xe3,0x6d,0x44,0xdd,0x01 + vpshufd ymm5,ymm5,0x4e + vpxor ymm6,ymm6,ymm5 + vpxor ymm6,ymm6,ymm3 + DB 0xc4,0xe3,0x6d,0x44,0xde,0x01 + vpshufd ymm6,ymm6,0x4e + vpxor ymm7,ymm7,ymm6 + vpxor ymm7,ymm7,ymm3 + vextracti128 xmm1,ymm7,1 + vpxor xmm1,xmm1,xmm7 + +$L$done__func2: + + vpshufb xmm1,xmm1,xmm0 + vmovdqu XMMWORD[r12],xmm1 + + vzeroupper + movdqa xmm6,XMMWORD[rsp] + movdqa xmm7,XMMWORD[16+rsp] + movdqa xmm8,XMMWORD[32+rsp] + movdqa xmm9,XMMWORD[48+rsp] + movdqa xmm10,XMMWORD[64+rsp] + movdqa xmm11,XMMWORD[80+rsp] + movdqa xmm12,XMMWORD[96+rsp] + movdqa xmm13,XMMWORD[112+rsp] + movdqa xmm14,XMMWORD[128+rsp] + movdqa xmm15,XMMWORD[144+rsp] + add rsp,160 + pop r12 + pop rdi + pop rsi + ret +$L$SEH_end_aes_gcm_dec_update_vaes_avx2_17: + + +section .pdata rdata align=4 +ALIGN 4 + DD $L$SEH_begin_gcm_init_vpclmulqdq_avx2_1 wrt ..imagebase + DD $L$SEH_end_gcm_init_vpclmulqdq_avx2_5 wrt ..imagebase + DD $L$SEH_info_gcm_init_vpclmulqdq_avx2_0 wrt ..imagebase + + DD $L$SEH_begin_gcm_ghash_vpclmulqdq_avx2_1_1 wrt ..imagebase + DD $L$SEH_end_gcm_ghash_vpclmulqdq_avx2_1_8 wrt ..imagebase + DD $L$SEH_info_gcm_ghash_vpclmulqdq_avx2_1_0 wrt ..imagebase + + DD $L$SEH_begin_aes_gcm_enc_update_vaes_avx2_1 wrt ..imagebase + DD $L$SEH_end_aes_gcm_enc_update_vaes_avx2_17 wrt ..imagebase + DD $L$SEH_info_aes_gcm_enc_update_vaes_avx2_0 wrt ..imagebase + + DD $L$SEH_begin_aes_gcm_dec_update_vaes_avx2_1 wrt ..imagebase + DD $L$SEH_end_aes_gcm_dec_update_vaes_avx2_17 wrt ..imagebase + DD $L$SEH_info_aes_gcm_dec_update_vaes_avx2_0 wrt ..imagebase + + +section .xdata rdata align=8 +ALIGN 4 +$L$SEH_info_gcm_init_vpclmulqdq_avx2_0: + DB 1 + DB $L$SEH_endprologue_gcm_init_vpclmulqdq_avx2_4-$L$SEH_begin_gcm_init_vpclmulqdq_avx2_1 + DB 3 + DB 0 + DB $L$SEH_prologue_gcm_init_vpclmulqdq_avx2_3-$L$SEH_begin_gcm_init_vpclmulqdq_avx2_1 + DB 104 + DW 0 + DB $L$SEH_prologue_gcm_init_vpclmulqdq_avx2_2-$L$SEH_begin_gcm_init_vpclmulqdq_avx2_1 + DB 34 + + DW 0 +$L$SEH_info_gcm_ghash_vpclmulqdq_avx2_1_0: + DB 1 + DB $L$SEH_endprologue_gcm_ghash_vpclmulqdq_avx2_1_7-$L$SEH_begin_gcm_ghash_vpclmulqdq_avx2_1_1 + DB 9 + DB 0 + DB $L$SEH_prologue_gcm_ghash_vpclmulqdq_avx2_1_6-$L$SEH_begin_gcm_ghash_vpclmulqdq_avx2_1_1 + DB 152 + DW 3 + DB $L$SEH_prologue_gcm_ghash_vpclmulqdq_avx2_1_5-$L$SEH_begin_gcm_ghash_vpclmulqdq_avx2_1_1 + DB 136 + DW 2 + DB $L$SEH_prologue_gcm_ghash_vpclmulqdq_avx2_1_4-$L$SEH_begin_gcm_ghash_vpclmulqdq_avx2_1_1 + DB 120 + DW 1 + DB $L$SEH_prologue_gcm_ghash_vpclmulqdq_avx2_1_3-$L$SEH_begin_gcm_ghash_vpclmulqdq_avx2_1_1 + DB 104 + DW 0 + DB $L$SEH_prologue_gcm_ghash_vpclmulqdq_avx2_1_2-$L$SEH_begin_gcm_ghash_vpclmulqdq_avx2_1_1 + DB 130 + + DW 0 +$L$SEH_info_aes_gcm_enc_update_vaes_avx2_0: + DB 1 + DB $L$SEH_endprologue_aes_gcm_enc_update_vaes_avx2_16-$L$SEH_begin_aes_gcm_enc_update_vaes_avx2_1 + DB 25 + DB 0 + DB $L$SEH_prologue_aes_gcm_enc_update_vaes_avx2_15-$L$SEH_begin_aes_gcm_enc_update_vaes_avx2_1 + DB 248 + DW 9 + DB $L$SEH_prologue_aes_gcm_enc_update_vaes_avx2_14-$L$SEH_begin_aes_gcm_enc_update_vaes_avx2_1 + DB 232 + DW 8 + DB $L$SEH_prologue_aes_gcm_enc_update_vaes_avx2_13-$L$SEH_begin_aes_gcm_enc_update_vaes_avx2_1 + DB 216 + DW 7 + DB $L$SEH_prologue_aes_gcm_enc_update_vaes_avx2_12-$L$SEH_begin_aes_gcm_enc_update_vaes_avx2_1 + DB 200 + DW 6 + DB $L$SEH_prologue_aes_gcm_enc_update_vaes_avx2_11-$L$SEH_begin_aes_gcm_enc_update_vaes_avx2_1 + DB 184 + DW 5 + DB $L$SEH_prologue_aes_gcm_enc_update_vaes_avx2_10-$L$SEH_begin_aes_gcm_enc_update_vaes_avx2_1 + DB 168 + DW 4 + DB $L$SEH_prologue_aes_gcm_enc_update_vaes_avx2_9-$L$SEH_begin_aes_gcm_enc_update_vaes_avx2_1 + DB 152 + DW 3 + DB $L$SEH_prologue_aes_gcm_enc_update_vaes_avx2_8-$L$SEH_begin_aes_gcm_enc_update_vaes_avx2_1 + DB 136 + DW 2 + DB $L$SEH_prologue_aes_gcm_enc_update_vaes_avx2_7-$L$SEH_begin_aes_gcm_enc_update_vaes_avx2_1 + DB 120 + DW 1 + DB $L$SEH_prologue_aes_gcm_enc_update_vaes_avx2_6-$L$SEH_begin_aes_gcm_enc_update_vaes_avx2_1 + DB 104 + DW 0 + DB $L$SEH_prologue_aes_gcm_enc_update_vaes_avx2_5-$L$SEH_begin_aes_gcm_enc_update_vaes_avx2_1 + DB 1 + DW 20 + DB $L$SEH_prologue_aes_gcm_enc_update_vaes_avx2_4-$L$SEH_begin_aes_gcm_enc_update_vaes_avx2_1 + DB 192 + DB $L$SEH_prologue_aes_gcm_enc_update_vaes_avx2_3-$L$SEH_begin_aes_gcm_enc_update_vaes_avx2_1 + DB 112 + DB $L$SEH_prologue_aes_gcm_enc_update_vaes_avx2_2-$L$SEH_begin_aes_gcm_enc_update_vaes_avx2_1 + DB 96 + + DW 0 +$L$SEH_info_aes_gcm_dec_update_vaes_avx2_0: + DB 1 + DB $L$SEH_endprologue_aes_gcm_dec_update_vaes_avx2_16-$L$SEH_begin_aes_gcm_dec_update_vaes_avx2_1 + DB 25 + DB 0 + DB $L$SEH_prologue_aes_gcm_dec_update_vaes_avx2_15-$L$SEH_begin_aes_gcm_dec_update_vaes_avx2_1 + DB 248 + DW 9 + DB $L$SEH_prologue_aes_gcm_dec_update_vaes_avx2_14-$L$SEH_begin_aes_gcm_dec_update_vaes_avx2_1 + DB 232 + DW 8 + DB $L$SEH_prologue_aes_gcm_dec_update_vaes_avx2_13-$L$SEH_begin_aes_gcm_dec_update_vaes_avx2_1 + DB 216 + DW 7 + DB $L$SEH_prologue_aes_gcm_dec_update_vaes_avx2_12-$L$SEH_begin_aes_gcm_dec_update_vaes_avx2_1 + DB 200 + DW 6 + DB $L$SEH_prologue_aes_gcm_dec_update_vaes_avx2_11-$L$SEH_begin_aes_gcm_dec_update_vaes_avx2_1 + DB 184 + DW 5 + DB $L$SEH_prologue_aes_gcm_dec_update_vaes_avx2_10-$L$SEH_begin_aes_gcm_dec_update_vaes_avx2_1 + DB 168 + DW 4 + DB $L$SEH_prologue_aes_gcm_dec_update_vaes_avx2_9-$L$SEH_begin_aes_gcm_dec_update_vaes_avx2_1 + DB 152 + DW 3 + DB $L$SEH_prologue_aes_gcm_dec_update_vaes_avx2_8-$L$SEH_begin_aes_gcm_dec_update_vaes_avx2_1 + DB 136 + DW 2 + DB $L$SEH_prologue_aes_gcm_dec_update_vaes_avx2_7-$L$SEH_begin_aes_gcm_dec_update_vaes_avx2_1 + DB 120 + DW 1 + DB $L$SEH_prologue_aes_gcm_dec_update_vaes_avx2_6-$L$SEH_begin_aes_gcm_dec_update_vaes_avx2_1 + DB 104 + DW 0 + DB $L$SEH_prologue_aes_gcm_dec_update_vaes_avx2_5-$L$SEH_begin_aes_gcm_dec_update_vaes_avx2_1 + DB 1 + DW 20 + DB $L$SEH_prologue_aes_gcm_dec_update_vaes_avx2_4-$L$SEH_begin_aes_gcm_dec_update_vaes_avx2_1 + DB 192 + DB $L$SEH_prologue_aes_gcm_dec_update_vaes_avx2_3-$L$SEH_begin_aes_gcm_dec_update_vaes_avx2_1 + DB 112 + DB $L$SEH_prologue_aes_gcm_dec_update_vaes_avx2_2-$L$SEH_begin_aes_gcm_dec_update_vaes_avx2_1 + DB 96 + + DW 0 +%else +; Work around https://bugzilla.nasm.us/show_bug.cgi?id=3392738 +ret +%endif diff --git a/http/vendor/ring/pregenerated/aes-gcm-avx2-x86_64-nasm.o b/http/vendor/ring/pregenerated/aes-gcm-avx2-x86_64-nasm.o new file mode 100644 index 0000000..89ecad4 Binary files /dev/null and b/http/vendor/ring/pregenerated/aes-gcm-avx2-x86_64-nasm.o differ diff --git a/http/vendor/ring/pregenerated/aesni-gcm-x86_64-elf.S b/http/vendor/ring/pregenerated/aesni-gcm-x86_64-elf.S new file mode 100644 index 0000000..c547df6 --- /dev/null +++ b/http/vendor/ring/pregenerated/aesni-gcm-x86_64-elf.S @@ -0,0 +1,883 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__) +.text + +.type _aesni_ctr32_ghash_6x,@function +.align 32 +_aesni_ctr32_ghash_6x: +.cfi_startproc + vmovdqu 32(%r11),%xmm2 + subq $6,%rdx + vpxor %xmm4,%xmm4,%xmm4 + vmovdqu 0-128(%rcx),%xmm15 + vpaddb %xmm2,%xmm1,%xmm10 + vpaddb %xmm2,%xmm10,%xmm11 + vpaddb %xmm2,%xmm11,%xmm12 + vpaddb %xmm2,%xmm12,%xmm13 + vpaddb %xmm2,%xmm13,%xmm14 + vpxor %xmm15,%xmm1,%xmm9 + vmovdqu %xmm4,16+8(%rsp) + jmp .Loop6x + +.align 32 +.Loop6x: + addl $100663296,%ebx + jc .Lhandle_ctr32 + vmovdqu 0-32(%r9),%xmm3 + vpaddb %xmm2,%xmm14,%xmm1 + vpxor %xmm15,%xmm10,%xmm10 + vpxor %xmm15,%xmm11,%xmm11 + +.Lresume_ctr32: + vmovdqu %xmm1,(%r8) + vpclmulqdq $0x10,%xmm3,%xmm7,%xmm5 + vpxor %xmm15,%xmm12,%xmm12 + vmovups 16-128(%rcx),%xmm2 + vpclmulqdq $0x01,%xmm3,%xmm7,%xmm6 + + + + + + + + + + + + + + + + + + xorq %r12,%r12 + cmpq %r14,%r15 + + vaesenc %xmm2,%xmm9,%xmm9 + vmovdqu 48+8(%rsp),%xmm0 + vpxor %xmm15,%xmm13,%xmm13 + vpclmulqdq $0x00,%xmm3,%xmm7,%xmm1 + vaesenc %xmm2,%xmm10,%xmm10 + vpxor %xmm15,%xmm14,%xmm14 + setnc %r12b + vpclmulqdq $0x11,%xmm3,%xmm7,%xmm7 + vaesenc %xmm2,%xmm11,%xmm11 + vmovdqu 16-32(%r9),%xmm3 + negq %r12 + vaesenc %xmm2,%xmm12,%xmm12 + vpxor %xmm5,%xmm6,%xmm6 + vpclmulqdq $0x00,%xmm3,%xmm0,%xmm5 + vpxor %xmm4,%xmm8,%xmm8 + vaesenc %xmm2,%xmm13,%xmm13 + vpxor %xmm5,%xmm1,%xmm4 + andq $0x60,%r12 + vmovups 32-128(%rcx),%xmm15 + vpclmulqdq $0x10,%xmm3,%xmm0,%xmm1 + vaesenc %xmm2,%xmm14,%xmm14 + + vpclmulqdq $0x01,%xmm3,%xmm0,%xmm2 + leaq (%r14,%r12,1),%r14 + vaesenc %xmm15,%xmm9,%xmm9 + vpxor 16+8(%rsp),%xmm8,%xmm8 + vpclmulqdq $0x11,%xmm3,%xmm0,%xmm3 + vmovdqu 64+8(%rsp),%xmm0 + vaesenc %xmm15,%xmm10,%xmm10 + movbeq 88(%r14),%r13 + vaesenc %xmm15,%xmm11,%xmm11 + movbeq 80(%r14),%r12 + vaesenc %xmm15,%xmm12,%xmm12 + movq %r13,32+8(%rsp) + vaesenc %xmm15,%xmm13,%xmm13 + movq %r12,40+8(%rsp) + vmovdqu 48-32(%r9),%xmm5 + vaesenc %xmm15,%xmm14,%xmm14 + + vmovups 48-128(%rcx),%xmm15 + vpxor %xmm1,%xmm6,%xmm6 + vpclmulqdq $0x00,%xmm5,%xmm0,%xmm1 + vaesenc %xmm15,%xmm9,%xmm9 + vpxor %xmm2,%xmm6,%xmm6 + vpclmulqdq $0x10,%xmm5,%xmm0,%xmm2 + vaesenc %xmm15,%xmm10,%xmm10 + vpxor %xmm3,%xmm7,%xmm7 + vpclmulqdq $0x01,%xmm5,%xmm0,%xmm3 + vaesenc %xmm15,%xmm11,%xmm11 + vpclmulqdq $0x11,%xmm5,%xmm0,%xmm5 + vmovdqu 80+8(%rsp),%xmm0 + vaesenc %xmm15,%xmm12,%xmm12 + vaesenc %xmm15,%xmm13,%xmm13 + vpxor %xmm1,%xmm4,%xmm4 + vmovdqu 64-32(%r9),%xmm1 + vaesenc %xmm15,%xmm14,%xmm14 + + vmovups 64-128(%rcx),%xmm15 + vpxor %xmm2,%xmm6,%xmm6 + vpclmulqdq $0x00,%xmm1,%xmm0,%xmm2 + vaesenc %xmm15,%xmm9,%xmm9 + vpxor %xmm3,%xmm6,%xmm6 + vpclmulqdq $0x10,%xmm1,%xmm0,%xmm3 + vaesenc %xmm15,%xmm10,%xmm10 + movbeq 72(%r14),%r13 + vpxor %xmm5,%xmm7,%xmm7 + vpclmulqdq $0x01,%xmm1,%xmm0,%xmm5 + vaesenc %xmm15,%xmm11,%xmm11 + movbeq 64(%r14),%r12 + vpclmulqdq $0x11,%xmm1,%xmm0,%xmm1 + vmovdqu 96+8(%rsp),%xmm0 + vaesenc %xmm15,%xmm12,%xmm12 + movq %r13,48+8(%rsp) + vaesenc %xmm15,%xmm13,%xmm13 + movq %r12,56+8(%rsp) + vpxor %xmm2,%xmm4,%xmm4 + vmovdqu 96-32(%r9),%xmm2 + vaesenc %xmm15,%xmm14,%xmm14 + + vmovups 80-128(%rcx),%xmm15 + vpxor %xmm3,%xmm6,%xmm6 + vpclmulqdq $0x00,%xmm2,%xmm0,%xmm3 + vaesenc %xmm15,%xmm9,%xmm9 + vpxor %xmm5,%xmm6,%xmm6 + vpclmulqdq $0x10,%xmm2,%xmm0,%xmm5 + vaesenc %xmm15,%xmm10,%xmm10 + movbeq 56(%r14),%r13 + vpxor %xmm1,%xmm7,%xmm7 + vpclmulqdq $0x01,%xmm2,%xmm0,%xmm1 + vpxor 112+8(%rsp),%xmm8,%xmm8 + vaesenc %xmm15,%xmm11,%xmm11 + movbeq 48(%r14),%r12 + vpclmulqdq $0x11,%xmm2,%xmm0,%xmm2 + vaesenc %xmm15,%xmm12,%xmm12 + movq %r13,64+8(%rsp) + vaesenc %xmm15,%xmm13,%xmm13 + movq %r12,72+8(%rsp) + vpxor %xmm3,%xmm4,%xmm4 + vmovdqu 112-32(%r9),%xmm3 + vaesenc %xmm15,%xmm14,%xmm14 + + vmovups 96-128(%rcx),%xmm15 + vpxor %xmm5,%xmm6,%xmm6 + vpclmulqdq $0x10,%xmm3,%xmm8,%xmm5 + vaesenc %xmm15,%xmm9,%xmm9 + vpxor %xmm1,%xmm6,%xmm6 + vpclmulqdq $0x01,%xmm3,%xmm8,%xmm1 + vaesenc %xmm15,%xmm10,%xmm10 + movbeq 40(%r14),%r13 + vpxor %xmm2,%xmm7,%xmm7 + vpclmulqdq $0x00,%xmm3,%xmm8,%xmm2 + vaesenc %xmm15,%xmm11,%xmm11 + movbeq 32(%r14),%r12 + vpclmulqdq $0x11,%xmm3,%xmm8,%xmm8 + vaesenc %xmm15,%xmm12,%xmm12 + movq %r13,80+8(%rsp) + vaesenc %xmm15,%xmm13,%xmm13 + movq %r12,88+8(%rsp) + vpxor %xmm5,%xmm6,%xmm6 + vaesenc %xmm15,%xmm14,%xmm14 + vpxor %xmm1,%xmm6,%xmm6 + + vmovups 112-128(%rcx),%xmm15 + vpslldq $8,%xmm6,%xmm5 + vpxor %xmm2,%xmm4,%xmm4 + vmovdqu 16(%r11),%xmm3 + + vaesenc %xmm15,%xmm9,%xmm9 + vpxor %xmm8,%xmm7,%xmm7 + vaesenc %xmm15,%xmm10,%xmm10 + vpxor %xmm5,%xmm4,%xmm4 + movbeq 24(%r14),%r13 + vaesenc %xmm15,%xmm11,%xmm11 + movbeq 16(%r14),%r12 + vpalignr $8,%xmm4,%xmm4,%xmm0 + vpclmulqdq $0x10,%xmm3,%xmm4,%xmm4 + movq %r13,96+8(%rsp) + vaesenc %xmm15,%xmm12,%xmm12 + movq %r12,104+8(%rsp) + vaesenc %xmm15,%xmm13,%xmm13 + vmovups 128-128(%rcx),%xmm1 + vaesenc %xmm15,%xmm14,%xmm14 + + vaesenc %xmm1,%xmm9,%xmm9 + vmovups 144-128(%rcx),%xmm15 + vaesenc %xmm1,%xmm10,%xmm10 + vpsrldq $8,%xmm6,%xmm6 + vaesenc %xmm1,%xmm11,%xmm11 + vpxor %xmm6,%xmm7,%xmm7 + vaesenc %xmm1,%xmm12,%xmm12 + vpxor %xmm0,%xmm4,%xmm4 + movbeq 8(%r14),%r13 + vaesenc %xmm1,%xmm13,%xmm13 + movbeq 0(%r14),%r12 + vaesenc %xmm1,%xmm14,%xmm14 + vmovups 160-128(%rcx),%xmm1 + cmpl $11,%r10d + jb .Lenc_tail + + vaesenc %xmm15,%xmm9,%xmm9 + vaesenc %xmm15,%xmm10,%xmm10 + vaesenc %xmm15,%xmm11,%xmm11 + vaesenc %xmm15,%xmm12,%xmm12 + vaesenc %xmm15,%xmm13,%xmm13 + vaesenc %xmm15,%xmm14,%xmm14 + + vaesenc %xmm1,%xmm9,%xmm9 + vaesenc %xmm1,%xmm10,%xmm10 + vaesenc %xmm1,%xmm11,%xmm11 + vaesenc %xmm1,%xmm12,%xmm12 + vaesenc %xmm1,%xmm13,%xmm13 + vmovups 176-128(%rcx),%xmm15 + vaesenc %xmm1,%xmm14,%xmm14 + vmovups 192-128(%rcx),%xmm1 + + + vaesenc %xmm15,%xmm9,%xmm9 + vaesenc %xmm15,%xmm10,%xmm10 + vaesenc %xmm15,%xmm11,%xmm11 + vaesenc %xmm15,%xmm12,%xmm12 + vaesenc %xmm15,%xmm13,%xmm13 + vaesenc %xmm15,%xmm14,%xmm14 + + vaesenc %xmm1,%xmm9,%xmm9 + vaesenc %xmm1,%xmm10,%xmm10 + vaesenc %xmm1,%xmm11,%xmm11 + vaesenc %xmm1,%xmm12,%xmm12 + vaesenc %xmm1,%xmm13,%xmm13 + vmovups 208-128(%rcx),%xmm15 + vaesenc %xmm1,%xmm14,%xmm14 + vmovups 224-128(%rcx),%xmm1 + jmp .Lenc_tail + +.align 32 +.Lhandle_ctr32: + vmovdqu (%r11),%xmm0 + vpshufb %xmm0,%xmm1,%xmm6 + vmovdqu 48(%r11),%xmm5 + vpaddd 64(%r11),%xmm6,%xmm10 + vpaddd %xmm5,%xmm6,%xmm11 + vmovdqu 0-32(%r9),%xmm3 + vpaddd %xmm5,%xmm10,%xmm12 + vpshufb %xmm0,%xmm10,%xmm10 + vpaddd %xmm5,%xmm11,%xmm13 + vpshufb %xmm0,%xmm11,%xmm11 + vpxor %xmm15,%xmm10,%xmm10 + vpaddd %xmm5,%xmm12,%xmm14 + vpshufb %xmm0,%xmm12,%xmm12 + vpxor %xmm15,%xmm11,%xmm11 + vpaddd %xmm5,%xmm13,%xmm1 + vpshufb %xmm0,%xmm13,%xmm13 + vpshufb %xmm0,%xmm14,%xmm14 + vpshufb %xmm0,%xmm1,%xmm1 + jmp .Lresume_ctr32 + +.align 32 +.Lenc_tail: + vaesenc %xmm15,%xmm9,%xmm9 + vmovdqu %xmm7,16+8(%rsp) + vpalignr $8,%xmm4,%xmm4,%xmm8 + vaesenc %xmm15,%xmm10,%xmm10 + vpclmulqdq $0x10,%xmm3,%xmm4,%xmm4 + vpxor 0(%rdi),%xmm1,%xmm2 + vaesenc %xmm15,%xmm11,%xmm11 + vpxor 16(%rdi),%xmm1,%xmm0 + vaesenc %xmm15,%xmm12,%xmm12 + vpxor 32(%rdi),%xmm1,%xmm5 + vaesenc %xmm15,%xmm13,%xmm13 + vpxor 48(%rdi),%xmm1,%xmm6 + vaesenc %xmm15,%xmm14,%xmm14 + vpxor 64(%rdi),%xmm1,%xmm7 + vpxor 80(%rdi),%xmm1,%xmm3 + vmovdqu (%r8),%xmm1 + + vaesenclast %xmm2,%xmm9,%xmm9 + vmovdqu 32(%r11),%xmm2 + vaesenclast %xmm0,%xmm10,%xmm10 + vpaddb %xmm2,%xmm1,%xmm0 + movq %r13,112+8(%rsp) + leaq 96(%rdi),%rdi + + prefetcht0 512(%rdi) + prefetcht0 576(%rdi) + vaesenclast %xmm5,%xmm11,%xmm11 + vpaddb %xmm2,%xmm0,%xmm5 + movq %r12,120+8(%rsp) + leaq 96(%rsi),%rsi + vmovdqu 0-128(%rcx),%xmm15 + vaesenclast %xmm6,%xmm12,%xmm12 + vpaddb %xmm2,%xmm5,%xmm6 + vaesenclast %xmm7,%xmm13,%xmm13 + vpaddb %xmm2,%xmm6,%xmm7 + vaesenclast %xmm3,%xmm14,%xmm14 + vpaddb %xmm2,%xmm7,%xmm3 + + addq $0x60,%rax + subq $0x6,%rdx + jc .L6x_done + + vmovups %xmm9,-96(%rsi) + vpxor %xmm15,%xmm1,%xmm9 + vmovups %xmm10,-80(%rsi) + vmovdqa %xmm0,%xmm10 + vmovups %xmm11,-64(%rsi) + vmovdqa %xmm5,%xmm11 + vmovups %xmm12,-48(%rsi) + vmovdqa %xmm6,%xmm12 + vmovups %xmm13,-32(%rsi) + vmovdqa %xmm7,%xmm13 + vmovups %xmm14,-16(%rsi) + vmovdqa %xmm3,%xmm14 + vmovdqu 32+8(%rsp),%xmm7 + jmp .Loop6x + +.L6x_done: + vpxor 16+8(%rsp),%xmm8,%xmm8 + vpxor %xmm4,%xmm8,%xmm8 + + ret +.cfi_endproc +.size _aesni_ctr32_ghash_6x,.-_aesni_ctr32_ghash_6x +.globl aesni_gcm_decrypt +.hidden aesni_gcm_decrypt +.type aesni_gcm_decrypt,@function +.align 32 +aesni_gcm_decrypt: +.cfi_startproc + +_CET_ENDBR + xorq %rax,%rax + + + + cmpq $0x60,%rdx + jb .Lgcm_dec_abort + + pushq %rbp +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbp,-16 + + movq %rsp,%rbp +.cfi_def_cfa_register %rbp + pushq %rbx +.cfi_offset %rbx,-24 + + pushq %r12 +.cfi_offset %r12,-32 + + pushq %r13 +.cfi_offset %r13,-40 + + pushq %r14 +.cfi_offset %r14,-48 + + pushq %r15 +.cfi_offset %r15,-56 + + vzeroupper + + movq 16(%rbp),%r12 + vmovdqu (%r8),%xmm1 + addq $-128,%rsp + movl 12(%r8),%ebx + leaq .Lbswap_mask(%rip),%r11 + leaq -128(%rcx),%r14 + movq $0xf80,%r15 + vmovdqu (%r12),%xmm8 + andq $-128,%rsp + vmovdqu (%r11),%xmm0 + leaq 128(%rcx),%rcx + leaq 32(%r9),%r9 + movl 240-128(%rcx),%r10d + vpshufb %xmm0,%xmm8,%xmm8 + + andq %r15,%r14 + andq %rsp,%r15 + subq %r14,%r15 + jc .Ldec_no_key_aliasing + cmpq $768,%r15 + jnc .Ldec_no_key_aliasing + subq %r15,%rsp +.Ldec_no_key_aliasing: + + vmovdqu 80(%rdi),%xmm7 + movq %rdi,%r14 + vmovdqu 64(%rdi),%xmm4 + + + + + + + + leaq -192(%rdi,%rdx,1),%r15 + + vmovdqu 48(%rdi),%xmm5 + shrq $4,%rdx + xorq %rax,%rax + vmovdqu 32(%rdi),%xmm6 + vpshufb %xmm0,%xmm7,%xmm7 + vmovdqu 16(%rdi),%xmm2 + vpshufb %xmm0,%xmm4,%xmm4 + vmovdqu (%rdi),%xmm3 + vpshufb %xmm0,%xmm5,%xmm5 + vmovdqu %xmm4,48(%rsp) + vpshufb %xmm0,%xmm6,%xmm6 + vmovdqu %xmm5,64(%rsp) + vpshufb %xmm0,%xmm2,%xmm2 + vmovdqu %xmm6,80(%rsp) + vpshufb %xmm0,%xmm3,%xmm3 + vmovdqu %xmm2,96(%rsp) + vmovdqu %xmm3,112(%rsp) + + call _aesni_ctr32_ghash_6x + + movq 16(%rbp),%r12 + vmovups %xmm9,-96(%rsi) + vmovups %xmm10,-80(%rsi) + vmovups %xmm11,-64(%rsi) + vmovups %xmm12,-48(%rsi) + vmovups %xmm13,-32(%rsi) + vmovups %xmm14,-16(%rsi) + + vpshufb (%r11),%xmm8,%xmm8 + vmovdqu %xmm8,(%r12) + + vzeroupper + leaq -40(%rbp),%rsp +.cfi_def_cfa %rsp, 0x38 + popq %r15 +.cfi_adjust_cfa_offset -8 +.cfi_restore %r15 + popq %r14 +.cfi_adjust_cfa_offset -8 +.cfi_restore %r14 + popq %r13 +.cfi_adjust_cfa_offset -8 +.cfi_restore %r13 + popq %r12 +.cfi_adjust_cfa_offset -8 +.cfi_restore %r12 + popq %rbx +.cfi_adjust_cfa_offset -8 +.cfi_restore %rbx + popq %rbp +.cfi_adjust_cfa_offset -8 +.cfi_restore %rbp +.Lgcm_dec_abort: + ret + +.cfi_endproc +.size aesni_gcm_decrypt,.-aesni_gcm_decrypt +.type _aesni_ctr32_6x,@function +.align 32 +_aesni_ctr32_6x: +.cfi_startproc + vmovdqu 0-128(%rcx),%xmm4 + vmovdqu 32(%r11),%xmm2 + leaq -1(%r10),%r13 + vmovups 16-128(%rcx),%xmm15 + leaq 32-128(%rcx),%r12 + vpxor %xmm4,%xmm1,%xmm9 + addl $100663296,%ebx + jc .Lhandle_ctr32_2 + vpaddb %xmm2,%xmm1,%xmm10 + vpaddb %xmm2,%xmm10,%xmm11 + vpxor %xmm4,%xmm10,%xmm10 + vpaddb %xmm2,%xmm11,%xmm12 + vpxor %xmm4,%xmm11,%xmm11 + vpaddb %xmm2,%xmm12,%xmm13 + vpxor %xmm4,%xmm12,%xmm12 + vpaddb %xmm2,%xmm13,%xmm14 + vpxor %xmm4,%xmm13,%xmm13 + vpaddb %xmm2,%xmm14,%xmm1 + vpxor %xmm4,%xmm14,%xmm14 + jmp .Loop_ctr32 + +.align 16 +.Loop_ctr32: + vaesenc %xmm15,%xmm9,%xmm9 + vaesenc %xmm15,%xmm10,%xmm10 + vaesenc %xmm15,%xmm11,%xmm11 + vaesenc %xmm15,%xmm12,%xmm12 + vaesenc %xmm15,%xmm13,%xmm13 + vaesenc %xmm15,%xmm14,%xmm14 + vmovups (%r12),%xmm15 + leaq 16(%r12),%r12 + decl %r13d + jnz .Loop_ctr32 + + vmovdqu (%r12),%xmm3 + vaesenc %xmm15,%xmm9,%xmm9 + vpxor 0(%rdi),%xmm3,%xmm4 + vaesenc %xmm15,%xmm10,%xmm10 + vpxor 16(%rdi),%xmm3,%xmm5 + vaesenc %xmm15,%xmm11,%xmm11 + vpxor 32(%rdi),%xmm3,%xmm6 + vaesenc %xmm15,%xmm12,%xmm12 + vpxor 48(%rdi),%xmm3,%xmm8 + vaesenc %xmm15,%xmm13,%xmm13 + vpxor 64(%rdi),%xmm3,%xmm2 + vaesenc %xmm15,%xmm14,%xmm14 + vpxor 80(%rdi),%xmm3,%xmm3 + leaq 96(%rdi),%rdi + + vaesenclast %xmm4,%xmm9,%xmm9 + vaesenclast %xmm5,%xmm10,%xmm10 + vaesenclast %xmm6,%xmm11,%xmm11 + vaesenclast %xmm8,%xmm12,%xmm12 + vaesenclast %xmm2,%xmm13,%xmm13 + vaesenclast %xmm3,%xmm14,%xmm14 + vmovups %xmm9,0(%rsi) + vmovups %xmm10,16(%rsi) + vmovups %xmm11,32(%rsi) + vmovups %xmm12,48(%rsi) + vmovups %xmm13,64(%rsi) + vmovups %xmm14,80(%rsi) + leaq 96(%rsi),%rsi + + ret +.align 32 +.Lhandle_ctr32_2: + vpshufb %xmm0,%xmm1,%xmm6 + vmovdqu 48(%r11),%xmm5 + vpaddd 64(%r11),%xmm6,%xmm10 + vpaddd %xmm5,%xmm6,%xmm11 + vpaddd %xmm5,%xmm10,%xmm12 + vpshufb %xmm0,%xmm10,%xmm10 + vpaddd %xmm5,%xmm11,%xmm13 + vpshufb %xmm0,%xmm11,%xmm11 + vpxor %xmm4,%xmm10,%xmm10 + vpaddd %xmm5,%xmm12,%xmm14 + vpshufb %xmm0,%xmm12,%xmm12 + vpxor %xmm4,%xmm11,%xmm11 + vpaddd %xmm5,%xmm13,%xmm1 + vpshufb %xmm0,%xmm13,%xmm13 + vpxor %xmm4,%xmm12,%xmm12 + vpshufb %xmm0,%xmm14,%xmm14 + vpxor %xmm4,%xmm13,%xmm13 + vpshufb %xmm0,%xmm1,%xmm1 + vpxor %xmm4,%xmm14,%xmm14 + jmp .Loop_ctr32 +.cfi_endproc +.size _aesni_ctr32_6x,.-_aesni_ctr32_6x + +.globl aesni_gcm_encrypt +.hidden aesni_gcm_encrypt +.type aesni_gcm_encrypt,@function +.align 32 +aesni_gcm_encrypt: +.cfi_startproc + +_CET_ENDBR +#ifdef BORINGSSL_DISPATCH_TEST +.extern BORINGSSL_function_hit +.hidden BORINGSSL_function_hit + movb $1,BORINGSSL_function_hit+2(%rip) +#endif + xorq %rax,%rax + + + + + cmpq $288,%rdx + jb .Lgcm_enc_abort + + pushq %rbp +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbp,-16 + + movq %rsp,%rbp +.cfi_def_cfa_register %rbp + pushq %rbx +.cfi_offset %rbx,-24 + + pushq %r12 +.cfi_offset %r12,-32 + + pushq %r13 +.cfi_offset %r13,-40 + + pushq %r14 +.cfi_offset %r14,-48 + + pushq %r15 +.cfi_offset %r15,-56 + + vzeroupper + + vmovdqu (%r8),%xmm1 + addq $-128,%rsp + movl 12(%r8),%ebx + leaq .Lbswap_mask(%rip),%r11 + leaq -128(%rcx),%r14 + movq $0xf80,%r15 + leaq 128(%rcx),%rcx + vmovdqu (%r11),%xmm0 + andq $-128,%rsp + movl 240-128(%rcx),%r10d + + andq %r15,%r14 + andq %rsp,%r15 + subq %r14,%r15 + jc .Lenc_no_key_aliasing + cmpq $768,%r15 + jnc .Lenc_no_key_aliasing + subq %r15,%rsp +.Lenc_no_key_aliasing: + + movq %rsi,%r14 + + + + + + + + + leaq -192(%rsi,%rdx,1),%r15 + + shrq $4,%rdx + + call _aesni_ctr32_6x + vpshufb %xmm0,%xmm9,%xmm8 + vpshufb %xmm0,%xmm10,%xmm2 + vmovdqu %xmm8,112(%rsp) + vpshufb %xmm0,%xmm11,%xmm4 + vmovdqu %xmm2,96(%rsp) + vpshufb %xmm0,%xmm12,%xmm5 + vmovdqu %xmm4,80(%rsp) + vpshufb %xmm0,%xmm13,%xmm6 + vmovdqu %xmm5,64(%rsp) + vpshufb %xmm0,%xmm14,%xmm7 + vmovdqu %xmm6,48(%rsp) + + call _aesni_ctr32_6x + + movq 16(%rbp),%r12 + leaq 32(%r9),%r9 + vmovdqu (%r12),%xmm8 + subq $12,%rdx + movq $192,%rax + vpshufb %xmm0,%xmm8,%xmm8 + + call _aesni_ctr32_ghash_6x + vmovdqu 32(%rsp),%xmm7 + vmovdqu (%r11),%xmm0 + vmovdqu 0-32(%r9),%xmm3 + vpunpckhqdq %xmm7,%xmm7,%xmm1 + vmovdqu 32-32(%r9),%xmm15 + vmovups %xmm9,-96(%rsi) + vpshufb %xmm0,%xmm9,%xmm9 + vpxor %xmm7,%xmm1,%xmm1 + vmovups %xmm10,-80(%rsi) + vpshufb %xmm0,%xmm10,%xmm10 + vmovups %xmm11,-64(%rsi) + vpshufb %xmm0,%xmm11,%xmm11 + vmovups %xmm12,-48(%rsi) + vpshufb %xmm0,%xmm12,%xmm12 + vmovups %xmm13,-32(%rsi) + vpshufb %xmm0,%xmm13,%xmm13 + vmovups %xmm14,-16(%rsi) + vpshufb %xmm0,%xmm14,%xmm14 + vmovdqu %xmm9,16(%rsp) + vmovdqu 48(%rsp),%xmm6 + vmovdqu 16-32(%r9),%xmm0 + vpunpckhqdq %xmm6,%xmm6,%xmm2 + vpclmulqdq $0x00,%xmm3,%xmm7,%xmm5 + vpxor %xmm6,%xmm2,%xmm2 + vpclmulqdq $0x11,%xmm3,%xmm7,%xmm7 + vpclmulqdq $0x00,%xmm15,%xmm1,%xmm1 + + vmovdqu 64(%rsp),%xmm9 + vpclmulqdq $0x00,%xmm0,%xmm6,%xmm4 + vmovdqu 48-32(%r9),%xmm3 + vpxor %xmm5,%xmm4,%xmm4 + vpunpckhqdq %xmm9,%xmm9,%xmm5 + vpclmulqdq $0x11,%xmm0,%xmm6,%xmm6 + vpxor %xmm9,%xmm5,%xmm5 + vpxor %xmm7,%xmm6,%xmm6 + vpclmulqdq $0x10,%xmm15,%xmm2,%xmm2 + vmovdqu 80-32(%r9),%xmm15 + vpxor %xmm1,%xmm2,%xmm2 + + vmovdqu 80(%rsp),%xmm1 + vpclmulqdq $0x00,%xmm3,%xmm9,%xmm7 + vmovdqu 64-32(%r9),%xmm0 + vpxor %xmm4,%xmm7,%xmm7 + vpunpckhqdq %xmm1,%xmm1,%xmm4 + vpclmulqdq $0x11,%xmm3,%xmm9,%xmm9 + vpxor %xmm1,%xmm4,%xmm4 + vpxor %xmm6,%xmm9,%xmm9 + vpclmulqdq $0x00,%xmm15,%xmm5,%xmm5 + vpxor %xmm2,%xmm5,%xmm5 + + vmovdqu 96(%rsp),%xmm2 + vpclmulqdq $0x00,%xmm0,%xmm1,%xmm6 + vmovdqu 96-32(%r9),%xmm3 + vpxor %xmm7,%xmm6,%xmm6 + vpunpckhqdq %xmm2,%xmm2,%xmm7 + vpclmulqdq $0x11,%xmm0,%xmm1,%xmm1 + vpxor %xmm2,%xmm7,%xmm7 + vpxor %xmm9,%xmm1,%xmm1 + vpclmulqdq $0x10,%xmm15,%xmm4,%xmm4 + vmovdqu 128-32(%r9),%xmm15 + vpxor %xmm5,%xmm4,%xmm4 + + vpxor 112(%rsp),%xmm8,%xmm8 + vpclmulqdq $0x00,%xmm3,%xmm2,%xmm5 + vmovdqu 112-32(%r9),%xmm0 + vpunpckhqdq %xmm8,%xmm8,%xmm9 + vpxor %xmm6,%xmm5,%xmm5 + vpclmulqdq $0x11,%xmm3,%xmm2,%xmm2 + vpxor %xmm8,%xmm9,%xmm9 + vpxor %xmm1,%xmm2,%xmm2 + vpclmulqdq $0x00,%xmm15,%xmm7,%xmm7 + vpxor %xmm4,%xmm7,%xmm4 + + vpclmulqdq $0x00,%xmm0,%xmm8,%xmm6 + vmovdqu 0-32(%r9),%xmm3 + vpunpckhqdq %xmm14,%xmm14,%xmm1 + vpclmulqdq $0x11,%xmm0,%xmm8,%xmm8 + vpxor %xmm14,%xmm1,%xmm1 + vpxor %xmm5,%xmm6,%xmm5 + vpclmulqdq $0x10,%xmm15,%xmm9,%xmm9 + vmovdqu 32-32(%r9),%xmm15 + vpxor %xmm2,%xmm8,%xmm7 + vpxor %xmm4,%xmm9,%xmm6 + + vmovdqu 16-32(%r9),%xmm0 + vpxor %xmm5,%xmm7,%xmm9 + vpclmulqdq $0x00,%xmm3,%xmm14,%xmm4 + vpxor %xmm9,%xmm6,%xmm6 + vpunpckhqdq %xmm13,%xmm13,%xmm2 + vpclmulqdq $0x11,%xmm3,%xmm14,%xmm14 + vpxor %xmm13,%xmm2,%xmm2 + vpslldq $8,%xmm6,%xmm9 + vpclmulqdq $0x00,%xmm15,%xmm1,%xmm1 + vpxor %xmm9,%xmm5,%xmm8 + vpsrldq $8,%xmm6,%xmm6 + vpxor %xmm6,%xmm7,%xmm7 + + vpclmulqdq $0x00,%xmm0,%xmm13,%xmm5 + vmovdqu 48-32(%r9),%xmm3 + vpxor %xmm4,%xmm5,%xmm5 + vpunpckhqdq %xmm12,%xmm12,%xmm9 + vpclmulqdq $0x11,%xmm0,%xmm13,%xmm13 + vpxor %xmm12,%xmm9,%xmm9 + vpxor %xmm14,%xmm13,%xmm13 + vpalignr $8,%xmm8,%xmm8,%xmm14 + vpclmulqdq $0x10,%xmm15,%xmm2,%xmm2 + vmovdqu 80-32(%r9),%xmm15 + vpxor %xmm1,%xmm2,%xmm2 + + vpclmulqdq $0x00,%xmm3,%xmm12,%xmm4 + vmovdqu 64-32(%r9),%xmm0 + vpxor %xmm5,%xmm4,%xmm4 + vpunpckhqdq %xmm11,%xmm11,%xmm1 + vpclmulqdq $0x11,%xmm3,%xmm12,%xmm12 + vpxor %xmm11,%xmm1,%xmm1 + vpxor %xmm13,%xmm12,%xmm12 + vxorps 16(%rsp),%xmm7,%xmm7 + vpclmulqdq $0x00,%xmm15,%xmm9,%xmm9 + vpxor %xmm2,%xmm9,%xmm9 + + vpclmulqdq $0x10,16(%r11),%xmm8,%xmm8 + vxorps %xmm14,%xmm8,%xmm8 + + vpclmulqdq $0x00,%xmm0,%xmm11,%xmm5 + vmovdqu 96-32(%r9),%xmm3 + vpxor %xmm4,%xmm5,%xmm5 + vpunpckhqdq %xmm10,%xmm10,%xmm2 + vpclmulqdq $0x11,%xmm0,%xmm11,%xmm11 + vpxor %xmm10,%xmm2,%xmm2 + vpalignr $8,%xmm8,%xmm8,%xmm14 + vpxor %xmm12,%xmm11,%xmm11 + vpclmulqdq $0x10,%xmm15,%xmm1,%xmm1 + vmovdqu 128-32(%r9),%xmm15 + vpxor %xmm9,%xmm1,%xmm1 + + vxorps %xmm7,%xmm14,%xmm14 + vpclmulqdq $0x10,16(%r11),%xmm8,%xmm8 + vxorps %xmm14,%xmm8,%xmm8 + + vpclmulqdq $0x00,%xmm3,%xmm10,%xmm4 + vmovdqu 112-32(%r9),%xmm0 + vpxor %xmm5,%xmm4,%xmm4 + vpunpckhqdq %xmm8,%xmm8,%xmm9 + vpclmulqdq $0x11,%xmm3,%xmm10,%xmm10 + vpxor %xmm8,%xmm9,%xmm9 + vpxor %xmm11,%xmm10,%xmm10 + vpclmulqdq $0x00,%xmm15,%xmm2,%xmm2 + vpxor %xmm1,%xmm2,%xmm2 + + vpclmulqdq $0x00,%xmm0,%xmm8,%xmm5 + vpclmulqdq $0x11,%xmm0,%xmm8,%xmm7 + vpxor %xmm4,%xmm5,%xmm5 + vpclmulqdq $0x10,%xmm15,%xmm9,%xmm6 + vpxor %xmm10,%xmm7,%xmm7 + vpxor %xmm2,%xmm6,%xmm6 + + vpxor %xmm5,%xmm7,%xmm4 + vpxor %xmm4,%xmm6,%xmm6 + vpslldq $8,%xmm6,%xmm1 + vmovdqu 16(%r11),%xmm3 + vpsrldq $8,%xmm6,%xmm6 + vpxor %xmm1,%xmm5,%xmm8 + vpxor %xmm6,%xmm7,%xmm7 + + vpalignr $8,%xmm8,%xmm8,%xmm2 + vpclmulqdq $0x10,%xmm3,%xmm8,%xmm8 + vpxor %xmm2,%xmm8,%xmm8 + + vpalignr $8,%xmm8,%xmm8,%xmm2 + vpclmulqdq $0x10,%xmm3,%xmm8,%xmm8 + vpxor %xmm7,%xmm2,%xmm2 + vpxor %xmm2,%xmm8,%xmm8 + movq 16(%rbp),%r12 + vpshufb (%r11),%xmm8,%xmm8 + vmovdqu %xmm8,(%r12) + + vzeroupper + leaq -40(%rbp),%rsp +.cfi_def_cfa %rsp, 0x38 + popq %r15 +.cfi_adjust_cfa_offset -8 +.cfi_restore %r15 + popq %r14 +.cfi_adjust_cfa_offset -8 +.cfi_restore %r14 + popq %r13 +.cfi_adjust_cfa_offset -8 +.cfi_restore %r13 + popq %r12 +.cfi_adjust_cfa_offset -8 +.cfi_restore %r12 + popq %rbx +.cfi_adjust_cfa_offset -8 +.cfi_restore %rbx + popq %rbp +.cfi_adjust_cfa_offset -8 +.cfi_restore %rbp +.Lgcm_enc_abort: + ret + +.cfi_endproc +.size aesni_gcm_encrypt,.-aesni_gcm_encrypt +.section .rodata +.align 64 +.Lbswap_mask: +.byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 +.Lpoly: +.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0xc2 +.Lone_msb: +.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 +.Ltwo_lsb: +.byte 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +.Lone_lsb: +.byte 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +.byte 65,69,83,45,78,73,32,71,67,77,32,109,111,100,117,108,101,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.align 64 +.text +#endif diff --git a/http/vendor/ring/pregenerated/aesni-gcm-x86_64-macosx.S b/http/vendor/ring/pregenerated/aesni-gcm-x86_64-macosx.S new file mode 100644 index 0000000..b9a70cf --- /dev/null +++ b/http/vendor/ring/pregenerated/aesni-gcm-x86_64-macosx.S @@ -0,0 +1,868 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__) +.text + + +.p2align 5 +_aesni_ctr32_ghash_6x: + + vmovdqu 32(%r11),%xmm2 + subq $6,%rdx + vpxor %xmm4,%xmm4,%xmm4 + vmovdqu 0-128(%rcx),%xmm15 + vpaddb %xmm2,%xmm1,%xmm10 + vpaddb %xmm2,%xmm10,%xmm11 + vpaddb %xmm2,%xmm11,%xmm12 + vpaddb %xmm2,%xmm12,%xmm13 + vpaddb %xmm2,%xmm13,%xmm14 + vpxor %xmm15,%xmm1,%xmm9 + vmovdqu %xmm4,16+8(%rsp) + jmp L$oop6x + +.p2align 5 +L$oop6x: + addl $100663296,%ebx + jc L$handle_ctr32 + vmovdqu 0-32(%r9),%xmm3 + vpaddb %xmm2,%xmm14,%xmm1 + vpxor %xmm15,%xmm10,%xmm10 + vpxor %xmm15,%xmm11,%xmm11 + +L$resume_ctr32: + vmovdqu %xmm1,(%r8) + vpclmulqdq $0x10,%xmm3,%xmm7,%xmm5 + vpxor %xmm15,%xmm12,%xmm12 + vmovups 16-128(%rcx),%xmm2 + vpclmulqdq $0x01,%xmm3,%xmm7,%xmm6 + + + + + + + + + + + + + + + + + + xorq %r12,%r12 + cmpq %r14,%r15 + + vaesenc %xmm2,%xmm9,%xmm9 + vmovdqu 48+8(%rsp),%xmm0 + vpxor %xmm15,%xmm13,%xmm13 + vpclmulqdq $0x00,%xmm3,%xmm7,%xmm1 + vaesenc %xmm2,%xmm10,%xmm10 + vpxor %xmm15,%xmm14,%xmm14 + setnc %r12b + vpclmulqdq $0x11,%xmm3,%xmm7,%xmm7 + vaesenc %xmm2,%xmm11,%xmm11 + vmovdqu 16-32(%r9),%xmm3 + negq %r12 + vaesenc %xmm2,%xmm12,%xmm12 + vpxor %xmm5,%xmm6,%xmm6 + vpclmulqdq $0x00,%xmm3,%xmm0,%xmm5 + vpxor %xmm4,%xmm8,%xmm8 + vaesenc %xmm2,%xmm13,%xmm13 + vpxor %xmm5,%xmm1,%xmm4 + andq $0x60,%r12 + vmovups 32-128(%rcx),%xmm15 + vpclmulqdq $0x10,%xmm3,%xmm0,%xmm1 + vaesenc %xmm2,%xmm14,%xmm14 + + vpclmulqdq $0x01,%xmm3,%xmm0,%xmm2 + leaq (%r14,%r12,1),%r14 + vaesenc %xmm15,%xmm9,%xmm9 + vpxor 16+8(%rsp),%xmm8,%xmm8 + vpclmulqdq $0x11,%xmm3,%xmm0,%xmm3 + vmovdqu 64+8(%rsp),%xmm0 + vaesenc %xmm15,%xmm10,%xmm10 + movbeq 88(%r14),%r13 + vaesenc %xmm15,%xmm11,%xmm11 + movbeq 80(%r14),%r12 + vaesenc %xmm15,%xmm12,%xmm12 + movq %r13,32+8(%rsp) + vaesenc %xmm15,%xmm13,%xmm13 + movq %r12,40+8(%rsp) + vmovdqu 48-32(%r9),%xmm5 + vaesenc %xmm15,%xmm14,%xmm14 + + vmovups 48-128(%rcx),%xmm15 + vpxor %xmm1,%xmm6,%xmm6 + vpclmulqdq $0x00,%xmm5,%xmm0,%xmm1 + vaesenc %xmm15,%xmm9,%xmm9 + vpxor %xmm2,%xmm6,%xmm6 + vpclmulqdq $0x10,%xmm5,%xmm0,%xmm2 + vaesenc %xmm15,%xmm10,%xmm10 + vpxor %xmm3,%xmm7,%xmm7 + vpclmulqdq $0x01,%xmm5,%xmm0,%xmm3 + vaesenc %xmm15,%xmm11,%xmm11 + vpclmulqdq $0x11,%xmm5,%xmm0,%xmm5 + vmovdqu 80+8(%rsp),%xmm0 + vaesenc %xmm15,%xmm12,%xmm12 + vaesenc %xmm15,%xmm13,%xmm13 + vpxor %xmm1,%xmm4,%xmm4 + vmovdqu 64-32(%r9),%xmm1 + vaesenc %xmm15,%xmm14,%xmm14 + + vmovups 64-128(%rcx),%xmm15 + vpxor %xmm2,%xmm6,%xmm6 + vpclmulqdq $0x00,%xmm1,%xmm0,%xmm2 + vaesenc %xmm15,%xmm9,%xmm9 + vpxor %xmm3,%xmm6,%xmm6 + vpclmulqdq $0x10,%xmm1,%xmm0,%xmm3 + vaesenc %xmm15,%xmm10,%xmm10 + movbeq 72(%r14),%r13 + vpxor %xmm5,%xmm7,%xmm7 + vpclmulqdq $0x01,%xmm1,%xmm0,%xmm5 + vaesenc %xmm15,%xmm11,%xmm11 + movbeq 64(%r14),%r12 + vpclmulqdq $0x11,%xmm1,%xmm0,%xmm1 + vmovdqu 96+8(%rsp),%xmm0 + vaesenc %xmm15,%xmm12,%xmm12 + movq %r13,48+8(%rsp) + vaesenc %xmm15,%xmm13,%xmm13 + movq %r12,56+8(%rsp) + vpxor %xmm2,%xmm4,%xmm4 + vmovdqu 96-32(%r9),%xmm2 + vaesenc %xmm15,%xmm14,%xmm14 + + vmovups 80-128(%rcx),%xmm15 + vpxor %xmm3,%xmm6,%xmm6 + vpclmulqdq $0x00,%xmm2,%xmm0,%xmm3 + vaesenc %xmm15,%xmm9,%xmm9 + vpxor %xmm5,%xmm6,%xmm6 + vpclmulqdq $0x10,%xmm2,%xmm0,%xmm5 + vaesenc %xmm15,%xmm10,%xmm10 + movbeq 56(%r14),%r13 + vpxor %xmm1,%xmm7,%xmm7 + vpclmulqdq $0x01,%xmm2,%xmm0,%xmm1 + vpxor 112+8(%rsp),%xmm8,%xmm8 + vaesenc %xmm15,%xmm11,%xmm11 + movbeq 48(%r14),%r12 + vpclmulqdq $0x11,%xmm2,%xmm0,%xmm2 + vaesenc %xmm15,%xmm12,%xmm12 + movq %r13,64+8(%rsp) + vaesenc %xmm15,%xmm13,%xmm13 + movq %r12,72+8(%rsp) + vpxor %xmm3,%xmm4,%xmm4 + vmovdqu 112-32(%r9),%xmm3 + vaesenc %xmm15,%xmm14,%xmm14 + + vmovups 96-128(%rcx),%xmm15 + vpxor %xmm5,%xmm6,%xmm6 + vpclmulqdq $0x10,%xmm3,%xmm8,%xmm5 + vaesenc %xmm15,%xmm9,%xmm9 + vpxor %xmm1,%xmm6,%xmm6 + vpclmulqdq $0x01,%xmm3,%xmm8,%xmm1 + vaesenc %xmm15,%xmm10,%xmm10 + movbeq 40(%r14),%r13 + vpxor %xmm2,%xmm7,%xmm7 + vpclmulqdq $0x00,%xmm3,%xmm8,%xmm2 + vaesenc %xmm15,%xmm11,%xmm11 + movbeq 32(%r14),%r12 + vpclmulqdq $0x11,%xmm3,%xmm8,%xmm8 + vaesenc %xmm15,%xmm12,%xmm12 + movq %r13,80+8(%rsp) + vaesenc %xmm15,%xmm13,%xmm13 + movq %r12,88+8(%rsp) + vpxor %xmm5,%xmm6,%xmm6 + vaesenc %xmm15,%xmm14,%xmm14 + vpxor %xmm1,%xmm6,%xmm6 + + vmovups 112-128(%rcx),%xmm15 + vpslldq $8,%xmm6,%xmm5 + vpxor %xmm2,%xmm4,%xmm4 + vmovdqu 16(%r11),%xmm3 + + vaesenc %xmm15,%xmm9,%xmm9 + vpxor %xmm8,%xmm7,%xmm7 + vaesenc %xmm15,%xmm10,%xmm10 + vpxor %xmm5,%xmm4,%xmm4 + movbeq 24(%r14),%r13 + vaesenc %xmm15,%xmm11,%xmm11 + movbeq 16(%r14),%r12 + vpalignr $8,%xmm4,%xmm4,%xmm0 + vpclmulqdq $0x10,%xmm3,%xmm4,%xmm4 + movq %r13,96+8(%rsp) + vaesenc %xmm15,%xmm12,%xmm12 + movq %r12,104+8(%rsp) + vaesenc %xmm15,%xmm13,%xmm13 + vmovups 128-128(%rcx),%xmm1 + vaesenc %xmm15,%xmm14,%xmm14 + + vaesenc %xmm1,%xmm9,%xmm9 + vmovups 144-128(%rcx),%xmm15 + vaesenc %xmm1,%xmm10,%xmm10 + vpsrldq $8,%xmm6,%xmm6 + vaesenc %xmm1,%xmm11,%xmm11 + vpxor %xmm6,%xmm7,%xmm7 + vaesenc %xmm1,%xmm12,%xmm12 + vpxor %xmm0,%xmm4,%xmm4 + movbeq 8(%r14),%r13 + vaesenc %xmm1,%xmm13,%xmm13 + movbeq 0(%r14),%r12 + vaesenc %xmm1,%xmm14,%xmm14 + vmovups 160-128(%rcx),%xmm1 + cmpl $11,%r10d + jb L$enc_tail + + vaesenc %xmm15,%xmm9,%xmm9 + vaesenc %xmm15,%xmm10,%xmm10 + vaesenc %xmm15,%xmm11,%xmm11 + vaesenc %xmm15,%xmm12,%xmm12 + vaesenc %xmm15,%xmm13,%xmm13 + vaesenc %xmm15,%xmm14,%xmm14 + + vaesenc %xmm1,%xmm9,%xmm9 + vaesenc %xmm1,%xmm10,%xmm10 + vaesenc %xmm1,%xmm11,%xmm11 + vaesenc %xmm1,%xmm12,%xmm12 + vaesenc %xmm1,%xmm13,%xmm13 + vmovups 176-128(%rcx),%xmm15 + vaesenc %xmm1,%xmm14,%xmm14 + vmovups 192-128(%rcx),%xmm1 + + + vaesenc %xmm15,%xmm9,%xmm9 + vaesenc %xmm15,%xmm10,%xmm10 + vaesenc %xmm15,%xmm11,%xmm11 + vaesenc %xmm15,%xmm12,%xmm12 + vaesenc %xmm15,%xmm13,%xmm13 + vaesenc %xmm15,%xmm14,%xmm14 + + vaesenc %xmm1,%xmm9,%xmm9 + vaesenc %xmm1,%xmm10,%xmm10 + vaesenc %xmm1,%xmm11,%xmm11 + vaesenc %xmm1,%xmm12,%xmm12 + vaesenc %xmm1,%xmm13,%xmm13 + vmovups 208-128(%rcx),%xmm15 + vaesenc %xmm1,%xmm14,%xmm14 + vmovups 224-128(%rcx),%xmm1 + jmp L$enc_tail + +.p2align 5 +L$handle_ctr32: + vmovdqu (%r11),%xmm0 + vpshufb %xmm0,%xmm1,%xmm6 + vmovdqu 48(%r11),%xmm5 + vpaddd 64(%r11),%xmm6,%xmm10 + vpaddd %xmm5,%xmm6,%xmm11 + vmovdqu 0-32(%r9),%xmm3 + vpaddd %xmm5,%xmm10,%xmm12 + vpshufb %xmm0,%xmm10,%xmm10 + vpaddd %xmm5,%xmm11,%xmm13 + vpshufb %xmm0,%xmm11,%xmm11 + vpxor %xmm15,%xmm10,%xmm10 + vpaddd %xmm5,%xmm12,%xmm14 + vpshufb %xmm0,%xmm12,%xmm12 + vpxor %xmm15,%xmm11,%xmm11 + vpaddd %xmm5,%xmm13,%xmm1 + vpshufb %xmm0,%xmm13,%xmm13 + vpshufb %xmm0,%xmm14,%xmm14 + vpshufb %xmm0,%xmm1,%xmm1 + jmp L$resume_ctr32 + +.p2align 5 +L$enc_tail: + vaesenc %xmm15,%xmm9,%xmm9 + vmovdqu %xmm7,16+8(%rsp) + vpalignr $8,%xmm4,%xmm4,%xmm8 + vaesenc %xmm15,%xmm10,%xmm10 + vpclmulqdq $0x10,%xmm3,%xmm4,%xmm4 + vpxor 0(%rdi),%xmm1,%xmm2 + vaesenc %xmm15,%xmm11,%xmm11 + vpxor 16(%rdi),%xmm1,%xmm0 + vaesenc %xmm15,%xmm12,%xmm12 + vpxor 32(%rdi),%xmm1,%xmm5 + vaesenc %xmm15,%xmm13,%xmm13 + vpxor 48(%rdi),%xmm1,%xmm6 + vaesenc %xmm15,%xmm14,%xmm14 + vpxor 64(%rdi),%xmm1,%xmm7 + vpxor 80(%rdi),%xmm1,%xmm3 + vmovdqu (%r8),%xmm1 + + vaesenclast %xmm2,%xmm9,%xmm9 + vmovdqu 32(%r11),%xmm2 + vaesenclast %xmm0,%xmm10,%xmm10 + vpaddb %xmm2,%xmm1,%xmm0 + movq %r13,112+8(%rsp) + leaq 96(%rdi),%rdi + + prefetcht0 512(%rdi) + prefetcht0 576(%rdi) + vaesenclast %xmm5,%xmm11,%xmm11 + vpaddb %xmm2,%xmm0,%xmm5 + movq %r12,120+8(%rsp) + leaq 96(%rsi),%rsi + vmovdqu 0-128(%rcx),%xmm15 + vaesenclast %xmm6,%xmm12,%xmm12 + vpaddb %xmm2,%xmm5,%xmm6 + vaesenclast %xmm7,%xmm13,%xmm13 + vpaddb %xmm2,%xmm6,%xmm7 + vaesenclast %xmm3,%xmm14,%xmm14 + vpaddb %xmm2,%xmm7,%xmm3 + + addq $0x60,%rax + subq $0x6,%rdx + jc L$6x_done + + vmovups %xmm9,-96(%rsi) + vpxor %xmm15,%xmm1,%xmm9 + vmovups %xmm10,-80(%rsi) + vmovdqa %xmm0,%xmm10 + vmovups %xmm11,-64(%rsi) + vmovdqa %xmm5,%xmm11 + vmovups %xmm12,-48(%rsi) + vmovdqa %xmm6,%xmm12 + vmovups %xmm13,-32(%rsi) + vmovdqa %xmm7,%xmm13 + vmovups %xmm14,-16(%rsi) + vmovdqa %xmm3,%xmm14 + vmovdqu 32+8(%rsp),%xmm7 + jmp L$oop6x + +L$6x_done: + vpxor 16+8(%rsp),%xmm8,%xmm8 + vpxor %xmm4,%xmm8,%xmm8 + + ret + + +.globl _aesni_gcm_decrypt +.private_extern _aesni_gcm_decrypt + +.p2align 5 +_aesni_gcm_decrypt: + + +_CET_ENDBR + xorq %rax,%rax + + + + cmpq $0x60,%rdx + jb L$gcm_dec_abort + + pushq %rbp + + + movq %rsp,%rbp + + pushq %rbx + + + pushq %r12 + + + pushq %r13 + + + pushq %r14 + + + pushq %r15 + + + vzeroupper + + movq 16(%rbp),%r12 + vmovdqu (%r8),%xmm1 + addq $-128,%rsp + movl 12(%r8),%ebx + leaq L$bswap_mask(%rip),%r11 + leaq -128(%rcx),%r14 + movq $0xf80,%r15 + vmovdqu (%r12),%xmm8 + andq $-128,%rsp + vmovdqu (%r11),%xmm0 + leaq 128(%rcx),%rcx + leaq 32(%r9),%r9 + movl 240-128(%rcx),%r10d + vpshufb %xmm0,%xmm8,%xmm8 + + andq %r15,%r14 + andq %rsp,%r15 + subq %r14,%r15 + jc L$dec_no_key_aliasing + cmpq $768,%r15 + jnc L$dec_no_key_aliasing + subq %r15,%rsp +L$dec_no_key_aliasing: + + vmovdqu 80(%rdi),%xmm7 + movq %rdi,%r14 + vmovdqu 64(%rdi),%xmm4 + + + + + + + + leaq -192(%rdi,%rdx,1),%r15 + + vmovdqu 48(%rdi),%xmm5 + shrq $4,%rdx + xorq %rax,%rax + vmovdqu 32(%rdi),%xmm6 + vpshufb %xmm0,%xmm7,%xmm7 + vmovdqu 16(%rdi),%xmm2 + vpshufb %xmm0,%xmm4,%xmm4 + vmovdqu (%rdi),%xmm3 + vpshufb %xmm0,%xmm5,%xmm5 + vmovdqu %xmm4,48(%rsp) + vpshufb %xmm0,%xmm6,%xmm6 + vmovdqu %xmm5,64(%rsp) + vpshufb %xmm0,%xmm2,%xmm2 + vmovdqu %xmm6,80(%rsp) + vpshufb %xmm0,%xmm3,%xmm3 + vmovdqu %xmm2,96(%rsp) + vmovdqu %xmm3,112(%rsp) + + call _aesni_ctr32_ghash_6x + + movq 16(%rbp),%r12 + vmovups %xmm9,-96(%rsi) + vmovups %xmm10,-80(%rsi) + vmovups %xmm11,-64(%rsi) + vmovups %xmm12,-48(%rsi) + vmovups %xmm13,-32(%rsi) + vmovups %xmm14,-16(%rsi) + + vpshufb (%r11),%xmm8,%xmm8 + vmovdqu %xmm8,(%r12) + + vzeroupper + leaq -40(%rbp),%rsp + + popq %r15 + + popq %r14 + + popq %r13 + + popq %r12 + + popq %rbx + + popq %rbp + +L$gcm_dec_abort: + ret + + + + +.p2align 5 +_aesni_ctr32_6x: + + vmovdqu 0-128(%rcx),%xmm4 + vmovdqu 32(%r11),%xmm2 + leaq -1(%r10),%r13 + vmovups 16-128(%rcx),%xmm15 + leaq 32-128(%rcx),%r12 + vpxor %xmm4,%xmm1,%xmm9 + addl $100663296,%ebx + jc L$handle_ctr32_2 + vpaddb %xmm2,%xmm1,%xmm10 + vpaddb %xmm2,%xmm10,%xmm11 + vpxor %xmm4,%xmm10,%xmm10 + vpaddb %xmm2,%xmm11,%xmm12 + vpxor %xmm4,%xmm11,%xmm11 + vpaddb %xmm2,%xmm12,%xmm13 + vpxor %xmm4,%xmm12,%xmm12 + vpaddb %xmm2,%xmm13,%xmm14 + vpxor %xmm4,%xmm13,%xmm13 + vpaddb %xmm2,%xmm14,%xmm1 + vpxor %xmm4,%xmm14,%xmm14 + jmp L$oop_ctr32 + +.p2align 4 +L$oop_ctr32: + vaesenc %xmm15,%xmm9,%xmm9 + vaesenc %xmm15,%xmm10,%xmm10 + vaesenc %xmm15,%xmm11,%xmm11 + vaesenc %xmm15,%xmm12,%xmm12 + vaesenc %xmm15,%xmm13,%xmm13 + vaesenc %xmm15,%xmm14,%xmm14 + vmovups (%r12),%xmm15 + leaq 16(%r12),%r12 + decl %r13d + jnz L$oop_ctr32 + + vmovdqu (%r12),%xmm3 + vaesenc %xmm15,%xmm9,%xmm9 + vpxor 0(%rdi),%xmm3,%xmm4 + vaesenc %xmm15,%xmm10,%xmm10 + vpxor 16(%rdi),%xmm3,%xmm5 + vaesenc %xmm15,%xmm11,%xmm11 + vpxor 32(%rdi),%xmm3,%xmm6 + vaesenc %xmm15,%xmm12,%xmm12 + vpxor 48(%rdi),%xmm3,%xmm8 + vaesenc %xmm15,%xmm13,%xmm13 + vpxor 64(%rdi),%xmm3,%xmm2 + vaesenc %xmm15,%xmm14,%xmm14 + vpxor 80(%rdi),%xmm3,%xmm3 + leaq 96(%rdi),%rdi + + vaesenclast %xmm4,%xmm9,%xmm9 + vaesenclast %xmm5,%xmm10,%xmm10 + vaesenclast %xmm6,%xmm11,%xmm11 + vaesenclast %xmm8,%xmm12,%xmm12 + vaesenclast %xmm2,%xmm13,%xmm13 + vaesenclast %xmm3,%xmm14,%xmm14 + vmovups %xmm9,0(%rsi) + vmovups %xmm10,16(%rsi) + vmovups %xmm11,32(%rsi) + vmovups %xmm12,48(%rsi) + vmovups %xmm13,64(%rsi) + vmovups %xmm14,80(%rsi) + leaq 96(%rsi),%rsi + + ret +.p2align 5 +L$handle_ctr32_2: + vpshufb %xmm0,%xmm1,%xmm6 + vmovdqu 48(%r11),%xmm5 + vpaddd 64(%r11),%xmm6,%xmm10 + vpaddd %xmm5,%xmm6,%xmm11 + vpaddd %xmm5,%xmm10,%xmm12 + vpshufb %xmm0,%xmm10,%xmm10 + vpaddd %xmm5,%xmm11,%xmm13 + vpshufb %xmm0,%xmm11,%xmm11 + vpxor %xmm4,%xmm10,%xmm10 + vpaddd %xmm5,%xmm12,%xmm14 + vpshufb %xmm0,%xmm12,%xmm12 + vpxor %xmm4,%xmm11,%xmm11 + vpaddd %xmm5,%xmm13,%xmm1 + vpshufb %xmm0,%xmm13,%xmm13 + vpxor %xmm4,%xmm12,%xmm12 + vpshufb %xmm0,%xmm14,%xmm14 + vpxor %xmm4,%xmm13,%xmm13 + vpshufb %xmm0,%xmm1,%xmm1 + vpxor %xmm4,%xmm14,%xmm14 + jmp L$oop_ctr32 + + + +.globl _aesni_gcm_encrypt +.private_extern _aesni_gcm_encrypt + +.p2align 5 +_aesni_gcm_encrypt: + + +_CET_ENDBR +#ifdef BORINGSSL_DISPATCH_TEST + + movb $1,_BORINGSSL_function_hit+2(%rip) +#endif + xorq %rax,%rax + + + + + cmpq $288,%rdx + jb L$gcm_enc_abort + + pushq %rbp + + + movq %rsp,%rbp + + pushq %rbx + + + pushq %r12 + + + pushq %r13 + + + pushq %r14 + + + pushq %r15 + + + vzeroupper + + vmovdqu (%r8),%xmm1 + addq $-128,%rsp + movl 12(%r8),%ebx + leaq L$bswap_mask(%rip),%r11 + leaq -128(%rcx),%r14 + movq $0xf80,%r15 + leaq 128(%rcx),%rcx + vmovdqu (%r11),%xmm0 + andq $-128,%rsp + movl 240-128(%rcx),%r10d + + andq %r15,%r14 + andq %rsp,%r15 + subq %r14,%r15 + jc L$enc_no_key_aliasing + cmpq $768,%r15 + jnc L$enc_no_key_aliasing + subq %r15,%rsp +L$enc_no_key_aliasing: + + movq %rsi,%r14 + + + + + + + + + leaq -192(%rsi,%rdx,1),%r15 + + shrq $4,%rdx + + call _aesni_ctr32_6x + vpshufb %xmm0,%xmm9,%xmm8 + vpshufb %xmm0,%xmm10,%xmm2 + vmovdqu %xmm8,112(%rsp) + vpshufb %xmm0,%xmm11,%xmm4 + vmovdqu %xmm2,96(%rsp) + vpshufb %xmm0,%xmm12,%xmm5 + vmovdqu %xmm4,80(%rsp) + vpshufb %xmm0,%xmm13,%xmm6 + vmovdqu %xmm5,64(%rsp) + vpshufb %xmm0,%xmm14,%xmm7 + vmovdqu %xmm6,48(%rsp) + + call _aesni_ctr32_6x + + movq 16(%rbp),%r12 + leaq 32(%r9),%r9 + vmovdqu (%r12),%xmm8 + subq $12,%rdx + movq $192,%rax + vpshufb %xmm0,%xmm8,%xmm8 + + call _aesni_ctr32_ghash_6x + vmovdqu 32(%rsp),%xmm7 + vmovdqu (%r11),%xmm0 + vmovdqu 0-32(%r9),%xmm3 + vpunpckhqdq %xmm7,%xmm7,%xmm1 + vmovdqu 32-32(%r9),%xmm15 + vmovups %xmm9,-96(%rsi) + vpshufb %xmm0,%xmm9,%xmm9 + vpxor %xmm7,%xmm1,%xmm1 + vmovups %xmm10,-80(%rsi) + vpshufb %xmm0,%xmm10,%xmm10 + vmovups %xmm11,-64(%rsi) + vpshufb %xmm0,%xmm11,%xmm11 + vmovups %xmm12,-48(%rsi) + vpshufb %xmm0,%xmm12,%xmm12 + vmovups %xmm13,-32(%rsi) + vpshufb %xmm0,%xmm13,%xmm13 + vmovups %xmm14,-16(%rsi) + vpshufb %xmm0,%xmm14,%xmm14 + vmovdqu %xmm9,16(%rsp) + vmovdqu 48(%rsp),%xmm6 + vmovdqu 16-32(%r9),%xmm0 + vpunpckhqdq %xmm6,%xmm6,%xmm2 + vpclmulqdq $0x00,%xmm3,%xmm7,%xmm5 + vpxor %xmm6,%xmm2,%xmm2 + vpclmulqdq $0x11,%xmm3,%xmm7,%xmm7 + vpclmulqdq $0x00,%xmm15,%xmm1,%xmm1 + + vmovdqu 64(%rsp),%xmm9 + vpclmulqdq $0x00,%xmm0,%xmm6,%xmm4 + vmovdqu 48-32(%r9),%xmm3 + vpxor %xmm5,%xmm4,%xmm4 + vpunpckhqdq %xmm9,%xmm9,%xmm5 + vpclmulqdq $0x11,%xmm0,%xmm6,%xmm6 + vpxor %xmm9,%xmm5,%xmm5 + vpxor %xmm7,%xmm6,%xmm6 + vpclmulqdq $0x10,%xmm15,%xmm2,%xmm2 + vmovdqu 80-32(%r9),%xmm15 + vpxor %xmm1,%xmm2,%xmm2 + + vmovdqu 80(%rsp),%xmm1 + vpclmulqdq $0x00,%xmm3,%xmm9,%xmm7 + vmovdqu 64-32(%r9),%xmm0 + vpxor %xmm4,%xmm7,%xmm7 + vpunpckhqdq %xmm1,%xmm1,%xmm4 + vpclmulqdq $0x11,%xmm3,%xmm9,%xmm9 + vpxor %xmm1,%xmm4,%xmm4 + vpxor %xmm6,%xmm9,%xmm9 + vpclmulqdq $0x00,%xmm15,%xmm5,%xmm5 + vpxor %xmm2,%xmm5,%xmm5 + + vmovdqu 96(%rsp),%xmm2 + vpclmulqdq $0x00,%xmm0,%xmm1,%xmm6 + vmovdqu 96-32(%r9),%xmm3 + vpxor %xmm7,%xmm6,%xmm6 + vpunpckhqdq %xmm2,%xmm2,%xmm7 + vpclmulqdq $0x11,%xmm0,%xmm1,%xmm1 + vpxor %xmm2,%xmm7,%xmm7 + vpxor %xmm9,%xmm1,%xmm1 + vpclmulqdq $0x10,%xmm15,%xmm4,%xmm4 + vmovdqu 128-32(%r9),%xmm15 + vpxor %xmm5,%xmm4,%xmm4 + + vpxor 112(%rsp),%xmm8,%xmm8 + vpclmulqdq $0x00,%xmm3,%xmm2,%xmm5 + vmovdqu 112-32(%r9),%xmm0 + vpunpckhqdq %xmm8,%xmm8,%xmm9 + vpxor %xmm6,%xmm5,%xmm5 + vpclmulqdq $0x11,%xmm3,%xmm2,%xmm2 + vpxor %xmm8,%xmm9,%xmm9 + vpxor %xmm1,%xmm2,%xmm2 + vpclmulqdq $0x00,%xmm15,%xmm7,%xmm7 + vpxor %xmm4,%xmm7,%xmm4 + + vpclmulqdq $0x00,%xmm0,%xmm8,%xmm6 + vmovdqu 0-32(%r9),%xmm3 + vpunpckhqdq %xmm14,%xmm14,%xmm1 + vpclmulqdq $0x11,%xmm0,%xmm8,%xmm8 + vpxor %xmm14,%xmm1,%xmm1 + vpxor %xmm5,%xmm6,%xmm5 + vpclmulqdq $0x10,%xmm15,%xmm9,%xmm9 + vmovdqu 32-32(%r9),%xmm15 + vpxor %xmm2,%xmm8,%xmm7 + vpxor %xmm4,%xmm9,%xmm6 + + vmovdqu 16-32(%r9),%xmm0 + vpxor %xmm5,%xmm7,%xmm9 + vpclmulqdq $0x00,%xmm3,%xmm14,%xmm4 + vpxor %xmm9,%xmm6,%xmm6 + vpunpckhqdq %xmm13,%xmm13,%xmm2 + vpclmulqdq $0x11,%xmm3,%xmm14,%xmm14 + vpxor %xmm13,%xmm2,%xmm2 + vpslldq $8,%xmm6,%xmm9 + vpclmulqdq $0x00,%xmm15,%xmm1,%xmm1 + vpxor %xmm9,%xmm5,%xmm8 + vpsrldq $8,%xmm6,%xmm6 + vpxor %xmm6,%xmm7,%xmm7 + + vpclmulqdq $0x00,%xmm0,%xmm13,%xmm5 + vmovdqu 48-32(%r9),%xmm3 + vpxor %xmm4,%xmm5,%xmm5 + vpunpckhqdq %xmm12,%xmm12,%xmm9 + vpclmulqdq $0x11,%xmm0,%xmm13,%xmm13 + vpxor %xmm12,%xmm9,%xmm9 + vpxor %xmm14,%xmm13,%xmm13 + vpalignr $8,%xmm8,%xmm8,%xmm14 + vpclmulqdq $0x10,%xmm15,%xmm2,%xmm2 + vmovdqu 80-32(%r9),%xmm15 + vpxor %xmm1,%xmm2,%xmm2 + + vpclmulqdq $0x00,%xmm3,%xmm12,%xmm4 + vmovdqu 64-32(%r9),%xmm0 + vpxor %xmm5,%xmm4,%xmm4 + vpunpckhqdq %xmm11,%xmm11,%xmm1 + vpclmulqdq $0x11,%xmm3,%xmm12,%xmm12 + vpxor %xmm11,%xmm1,%xmm1 + vpxor %xmm13,%xmm12,%xmm12 + vxorps 16(%rsp),%xmm7,%xmm7 + vpclmulqdq $0x00,%xmm15,%xmm9,%xmm9 + vpxor %xmm2,%xmm9,%xmm9 + + vpclmulqdq $0x10,16(%r11),%xmm8,%xmm8 + vxorps %xmm14,%xmm8,%xmm8 + + vpclmulqdq $0x00,%xmm0,%xmm11,%xmm5 + vmovdqu 96-32(%r9),%xmm3 + vpxor %xmm4,%xmm5,%xmm5 + vpunpckhqdq %xmm10,%xmm10,%xmm2 + vpclmulqdq $0x11,%xmm0,%xmm11,%xmm11 + vpxor %xmm10,%xmm2,%xmm2 + vpalignr $8,%xmm8,%xmm8,%xmm14 + vpxor %xmm12,%xmm11,%xmm11 + vpclmulqdq $0x10,%xmm15,%xmm1,%xmm1 + vmovdqu 128-32(%r9),%xmm15 + vpxor %xmm9,%xmm1,%xmm1 + + vxorps %xmm7,%xmm14,%xmm14 + vpclmulqdq $0x10,16(%r11),%xmm8,%xmm8 + vxorps %xmm14,%xmm8,%xmm8 + + vpclmulqdq $0x00,%xmm3,%xmm10,%xmm4 + vmovdqu 112-32(%r9),%xmm0 + vpxor %xmm5,%xmm4,%xmm4 + vpunpckhqdq %xmm8,%xmm8,%xmm9 + vpclmulqdq $0x11,%xmm3,%xmm10,%xmm10 + vpxor %xmm8,%xmm9,%xmm9 + vpxor %xmm11,%xmm10,%xmm10 + vpclmulqdq $0x00,%xmm15,%xmm2,%xmm2 + vpxor %xmm1,%xmm2,%xmm2 + + vpclmulqdq $0x00,%xmm0,%xmm8,%xmm5 + vpclmulqdq $0x11,%xmm0,%xmm8,%xmm7 + vpxor %xmm4,%xmm5,%xmm5 + vpclmulqdq $0x10,%xmm15,%xmm9,%xmm6 + vpxor %xmm10,%xmm7,%xmm7 + vpxor %xmm2,%xmm6,%xmm6 + + vpxor %xmm5,%xmm7,%xmm4 + vpxor %xmm4,%xmm6,%xmm6 + vpslldq $8,%xmm6,%xmm1 + vmovdqu 16(%r11),%xmm3 + vpsrldq $8,%xmm6,%xmm6 + vpxor %xmm1,%xmm5,%xmm8 + vpxor %xmm6,%xmm7,%xmm7 + + vpalignr $8,%xmm8,%xmm8,%xmm2 + vpclmulqdq $0x10,%xmm3,%xmm8,%xmm8 + vpxor %xmm2,%xmm8,%xmm8 + + vpalignr $8,%xmm8,%xmm8,%xmm2 + vpclmulqdq $0x10,%xmm3,%xmm8,%xmm8 + vpxor %xmm7,%xmm2,%xmm2 + vpxor %xmm2,%xmm8,%xmm8 + movq 16(%rbp),%r12 + vpshufb (%r11),%xmm8,%xmm8 + vmovdqu %xmm8,(%r12) + + vzeroupper + leaq -40(%rbp),%rsp + + popq %r15 + + popq %r14 + + popq %r13 + + popq %r12 + + popq %rbx + + popq %rbp + +L$gcm_enc_abort: + ret + + + +.section __DATA,__const +.p2align 6 +L$bswap_mask: +.byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 +L$poly: +.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0xc2 +L$one_msb: +.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 +L$two_lsb: +.byte 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +L$one_lsb: +.byte 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +.byte 65,69,83,45,78,73,32,71,67,77,32,109,111,100,117,108,101,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.p2align 6 +.text +#endif diff --git a/http/vendor/ring/pregenerated/aesni-gcm-x86_64-nasm.asm b/http/vendor/ring/pregenerated/aesni-gcm-x86_64-nasm.asm new file mode 100644 index 0000000..f1a7ca8 --- /dev/null +++ b/http/vendor/ring/pregenerated/aesni-gcm-x86_64-nasm.asm @@ -0,0 +1,1104 @@ +; This file is generated from a similarly-named Perl script in the BoringSSL +; source tree. Do not edit by hand. + +%ifidn __OUTPUT_FORMAT__, win64 +default rel +%define XMMWORD +%define YMMWORD +%define ZMMWORD +%define _CET_ENDBR + +%include "ring_core_generated/prefix_symbols_nasm.inc" +section .text code align=64 + + + +ALIGN 32 +_aesni_ctr32_ghash_6x: + + vmovdqu xmm2,XMMWORD[32+r11] + sub r8,6 + vpxor xmm4,xmm4,xmm4 + vmovdqu xmm15,XMMWORD[((0-128))+r9] + vpaddb xmm10,xmm1,xmm2 + vpaddb xmm11,xmm10,xmm2 + vpaddb xmm12,xmm11,xmm2 + vpaddb xmm13,xmm12,xmm2 + vpaddb xmm14,xmm13,xmm2 + vpxor xmm9,xmm1,xmm15 + vmovdqu XMMWORD[(16+8)+rsp],xmm4 + jmp NEAR $L$oop6x + +ALIGN 32 +$L$oop6x: + add ebx,100663296 + jc NEAR $L$handle_ctr32 + vmovdqu xmm3,XMMWORD[((0-32))+rsi] + vpaddb xmm1,xmm14,xmm2 + vpxor xmm10,xmm10,xmm15 + vpxor xmm11,xmm11,xmm15 + +$L$resume_ctr32: + vmovdqu XMMWORD[rdi],xmm1 + vpclmulqdq xmm5,xmm7,xmm3,0x10 + vpxor xmm12,xmm12,xmm15 + vmovups xmm2,XMMWORD[((16-128))+r9] + vpclmulqdq xmm6,xmm7,xmm3,0x01 + + + + + + + + + + + + + + + + + + xor r12,r12 + cmp r15,r14 + + vaesenc xmm9,xmm9,xmm2 + vmovdqu xmm0,XMMWORD[((48+8))+rsp] + vpxor xmm13,xmm13,xmm15 + vpclmulqdq xmm1,xmm7,xmm3,0x00 + vaesenc xmm10,xmm10,xmm2 + vpxor xmm14,xmm14,xmm15 + setnc r12b + vpclmulqdq xmm7,xmm7,xmm3,0x11 + vaesenc xmm11,xmm11,xmm2 + vmovdqu xmm3,XMMWORD[((16-32))+rsi] + neg r12 + vaesenc xmm12,xmm12,xmm2 + vpxor xmm6,xmm6,xmm5 + vpclmulqdq xmm5,xmm0,xmm3,0x00 + vpxor xmm8,xmm8,xmm4 + vaesenc xmm13,xmm13,xmm2 + vpxor xmm4,xmm1,xmm5 + and r12,0x60 + vmovups xmm15,XMMWORD[((32-128))+r9] + vpclmulqdq xmm1,xmm0,xmm3,0x10 + vaesenc xmm14,xmm14,xmm2 + + vpclmulqdq xmm2,xmm0,xmm3,0x01 + lea r14,[r12*1+r14] + vaesenc xmm9,xmm9,xmm15 + vpxor xmm8,xmm8,XMMWORD[((16+8))+rsp] + vpclmulqdq xmm3,xmm0,xmm3,0x11 + vmovdqu xmm0,XMMWORD[((64+8))+rsp] + vaesenc xmm10,xmm10,xmm15 + movbe r13,QWORD[88+r14] + vaesenc xmm11,xmm11,xmm15 + movbe r12,QWORD[80+r14] + vaesenc xmm12,xmm12,xmm15 + mov QWORD[((32+8))+rsp],r13 + vaesenc xmm13,xmm13,xmm15 + mov QWORD[((40+8))+rsp],r12 + vmovdqu xmm5,XMMWORD[((48-32))+rsi] + vaesenc xmm14,xmm14,xmm15 + + vmovups xmm15,XMMWORD[((48-128))+r9] + vpxor xmm6,xmm6,xmm1 + vpclmulqdq xmm1,xmm0,xmm5,0x00 + vaesenc xmm9,xmm9,xmm15 + vpxor xmm6,xmm6,xmm2 + vpclmulqdq xmm2,xmm0,xmm5,0x10 + vaesenc xmm10,xmm10,xmm15 + vpxor xmm7,xmm7,xmm3 + vpclmulqdq xmm3,xmm0,xmm5,0x01 + vaesenc xmm11,xmm11,xmm15 + vpclmulqdq xmm5,xmm0,xmm5,0x11 + vmovdqu xmm0,XMMWORD[((80+8))+rsp] + vaesenc xmm12,xmm12,xmm15 + vaesenc xmm13,xmm13,xmm15 + vpxor xmm4,xmm4,xmm1 + vmovdqu xmm1,XMMWORD[((64-32))+rsi] + vaesenc xmm14,xmm14,xmm15 + + vmovups xmm15,XMMWORD[((64-128))+r9] + vpxor xmm6,xmm6,xmm2 + vpclmulqdq xmm2,xmm0,xmm1,0x00 + vaesenc xmm9,xmm9,xmm15 + vpxor xmm6,xmm6,xmm3 + vpclmulqdq xmm3,xmm0,xmm1,0x10 + vaesenc xmm10,xmm10,xmm15 + movbe r13,QWORD[72+r14] + vpxor xmm7,xmm7,xmm5 + vpclmulqdq xmm5,xmm0,xmm1,0x01 + vaesenc xmm11,xmm11,xmm15 + movbe r12,QWORD[64+r14] + vpclmulqdq xmm1,xmm0,xmm1,0x11 + vmovdqu xmm0,XMMWORD[((96+8))+rsp] + vaesenc xmm12,xmm12,xmm15 + mov QWORD[((48+8))+rsp],r13 + vaesenc xmm13,xmm13,xmm15 + mov QWORD[((56+8))+rsp],r12 + vpxor xmm4,xmm4,xmm2 + vmovdqu xmm2,XMMWORD[((96-32))+rsi] + vaesenc xmm14,xmm14,xmm15 + + vmovups xmm15,XMMWORD[((80-128))+r9] + vpxor xmm6,xmm6,xmm3 + vpclmulqdq xmm3,xmm0,xmm2,0x00 + vaesenc xmm9,xmm9,xmm15 + vpxor xmm6,xmm6,xmm5 + vpclmulqdq xmm5,xmm0,xmm2,0x10 + vaesenc xmm10,xmm10,xmm15 + movbe r13,QWORD[56+r14] + vpxor xmm7,xmm7,xmm1 + vpclmulqdq xmm1,xmm0,xmm2,0x01 + vpxor xmm8,xmm8,XMMWORD[((112+8))+rsp] + vaesenc xmm11,xmm11,xmm15 + movbe r12,QWORD[48+r14] + vpclmulqdq xmm2,xmm0,xmm2,0x11 + vaesenc xmm12,xmm12,xmm15 + mov QWORD[((64+8))+rsp],r13 + vaesenc xmm13,xmm13,xmm15 + mov QWORD[((72+8))+rsp],r12 + vpxor xmm4,xmm4,xmm3 + vmovdqu xmm3,XMMWORD[((112-32))+rsi] + vaesenc xmm14,xmm14,xmm15 + + vmovups xmm15,XMMWORD[((96-128))+r9] + vpxor xmm6,xmm6,xmm5 + vpclmulqdq xmm5,xmm8,xmm3,0x10 + vaesenc xmm9,xmm9,xmm15 + vpxor xmm6,xmm6,xmm1 + vpclmulqdq xmm1,xmm8,xmm3,0x01 + vaesenc xmm10,xmm10,xmm15 + movbe r13,QWORD[40+r14] + vpxor xmm7,xmm7,xmm2 + vpclmulqdq xmm2,xmm8,xmm3,0x00 + vaesenc xmm11,xmm11,xmm15 + movbe r12,QWORD[32+r14] + vpclmulqdq xmm8,xmm8,xmm3,0x11 + vaesenc xmm12,xmm12,xmm15 + mov QWORD[((80+8))+rsp],r13 + vaesenc xmm13,xmm13,xmm15 + mov QWORD[((88+8))+rsp],r12 + vpxor xmm6,xmm6,xmm5 + vaesenc xmm14,xmm14,xmm15 + vpxor xmm6,xmm6,xmm1 + + vmovups xmm15,XMMWORD[((112-128))+r9] + vpslldq xmm5,xmm6,8 + vpxor xmm4,xmm4,xmm2 + vmovdqu xmm3,XMMWORD[16+r11] + + vaesenc xmm9,xmm9,xmm15 + vpxor xmm7,xmm7,xmm8 + vaesenc xmm10,xmm10,xmm15 + vpxor xmm4,xmm4,xmm5 + movbe r13,QWORD[24+r14] + vaesenc xmm11,xmm11,xmm15 + movbe r12,QWORD[16+r14] + vpalignr xmm0,xmm4,xmm4,8 + vpclmulqdq xmm4,xmm4,xmm3,0x10 + mov QWORD[((96+8))+rsp],r13 + vaesenc xmm12,xmm12,xmm15 + mov QWORD[((104+8))+rsp],r12 + vaesenc xmm13,xmm13,xmm15 + vmovups xmm1,XMMWORD[((128-128))+r9] + vaesenc xmm14,xmm14,xmm15 + + vaesenc xmm9,xmm9,xmm1 + vmovups xmm15,XMMWORD[((144-128))+r9] + vaesenc xmm10,xmm10,xmm1 + vpsrldq xmm6,xmm6,8 + vaesenc xmm11,xmm11,xmm1 + vpxor xmm7,xmm7,xmm6 + vaesenc xmm12,xmm12,xmm1 + vpxor xmm4,xmm4,xmm0 + movbe r13,QWORD[8+r14] + vaesenc xmm13,xmm13,xmm1 + movbe r12,QWORD[r14] + vaesenc xmm14,xmm14,xmm1 + vmovups xmm1,XMMWORD[((160-128))+r9] + cmp r10d,11 + jb NEAR $L$enc_tail + + vaesenc xmm9,xmm9,xmm15 + vaesenc xmm10,xmm10,xmm15 + vaesenc xmm11,xmm11,xmm15 + vaesenc xmm12,xmm12,xmm15 + vaesenc xmm13,xmm13,xmm15 + vaesenc xmm14,xmm14,xmm15 + + vaesenc xmm9,xmm9,xmm1 + vaesenc xmm10,xmm10,xmm1 + vaesenc xmm11,xmm11,xmm1 + vaesenc xmm12,xmm12,xmm1 + vaesenc xmm13,xmm13,xmm1 + vmovups xmm15,XMMWORD[((176-128))+r9] + vaesenc xmm14,xmm14,xmm1 + vmovups xmm1,XMMWORD[((192-128))+r9] + + + vaesenc xmm9,xmm9,xmm15 + vaesenc xmm10,xmm10,xmm15 + vaesenc xmm11,xmm11,xmm15 + vaesenc xmm12,xmm12,xmm15 + vaesenc xmm13,xmm13,xmm15 + vaesenc xmm14,xmm14,xmm15 + + vaesenc xmm9,xmm9,xmm1 + vaesenc xmm10,xmm10,xmm1 + vaesenc xmm11,xmm11,xmm1 + vaesenc xmm12,xmm12,xmm1 + vaesenc xmm13,xmm13,xmm1 + vmovups xmm15,XMMWORD[((208-128))+r9] + vaesenc xmm14,xmm14,xmm1 + vmovups xmm1,XMMWORD[((224-128))+r9] + jmp NEAR $L$enc_tail + +ALIGN 32 +$L$handle_ctr32: + vmovdqu xmm0,XMMWORD[r11] + vpshufb xmm6,xmm1,xmm0 + vmovdqu xmm5,XMMWORD[48+r11] + vpaddd xmm10,xmm6,XMMWORD[64+r11] + vpaddd xmm11,xmm6,xmm5 + vmovdqu xmm3,XMMWORD[((0-32))+rsi] + vpaddd xmm12,xmm10,xmm5 + vpshufb xmm10,xmm10,xmm0 + vpaddd xmm13,xmm11,xmm5 + vpshufb xmm11,xmm11,xmm0 + vpxor xmm10,xmm10,xmm15 + vpaddd xmm14,xmm12,xmm5 + vpshufb xmm12,xmm12,xmm0 + vpxor xmm11,xmm11,xmm15 + vpaddd xmm1,xmm13,xmm5 + vpshufb xmm13,xmm13,xmm0 + vpshufb xmm14,xmm14,xmm0 + vpshufb xmm1,xmm1,xmm0 + jmp NEAR $L$resume_ctr32 + +ALIGN 32 +$L$enc_tail: + vaesenc xmm9,xmm9,xmm15 + vmovdqu XMMWORD[(16+8)+rsp],xmm7 + vpalignr xmm8,xmm4,xmm4,8 + vaesenc xmm10,xmm10,xmm15 + vpclmulqdq xmm4,xmm4,xmm3,0x10 + vpxor xmm2,xmm1,XMMWORD[rcx] + vaesenc xmm11,xmm11,xmm15 + vpxor xmm0,xmm1,XMMWORD[16+rcx] + vaesenc xmm12,xmm12,xmm15 + vpxor xmm5,xmm1,XMMWORD[32+rcx] + vaesenc xmm13,xmm13,xmm15 + vpxor xmm6,xmm1,XMMWORD[48+rcx] + vaesenc xmm14,xmm14,xmm15 + vpxor xmm7,xmm1,XMMWORD[64+rcx] + vpxor xmm3,xmm1,XMMWORD[80+rcx] + vmovdqu xmm1,XMMWORD[rdi] + + vaesenclast xmm9,xmm9,xmm2 + vmovdqu xmm2,XMMWORD[32+r11] + vaesenclast xmm10,xmm10,xmm0 + vpaddb xmm0,xmm1,xmm2 + mov QWORD[((112+8))+rsp],r13 + lea rcx,[96+rcx] + + prefetcht0 [512+rcx] + prefetcht0 [576+rcx] + vaesenclast xmm11,xmm11,xmm5 + vpaddb xmm5,xmm0,xmm2 + mov QWORD[((120+8))+rsp],r12 + lea rdx,[96+rdx] + vmovdqu xmm15,XMMWORD[((0-128))+r9] + vaesenclast xmm12,xmm12,xmm6 + vpaddb xmm6,xmm5,xmm2 + vaesenclast xmm13,xmm13,xmm7 + vpaddb xmm7,xmm6,xmm2 + vaesenclast xmm14,xmm14,xmm3 + vpaddb xmm3,xmm7,xmm2 + + add rax,0x60 + sub r8,0x6 + jc NEAR $L$6x_done + + vmovups XMMWORD[(-96)+rdx],xmm9 + vpxor xmm9,xmm1,xmm15 + vmovups XMMWORD[(-80)+rdx],xmm10 + vmovdqa xmm10,xmm0 + vmovups XMMWORD[(-64)+rdx],xmm11 + vmovdqa xmm11,xmm5 + vmovups XMMWORD[(-48)+rdx],xmm12 + vmovdqa xmm12,xmm6 + vmovups XMMWORD[(-32)+rdx],xmm13 + vmovdqa xmm13,xmm7 + vmovups XMMWORD[(-16)+rdx],xmm14 + vmovdqa xmm14,xmm3 + vmovdqu xmm7,XMMWORD[((32+8))+rsp] + jmp NEAR $L$oop6x + +$L$6x_done: + vpxor xmm8,xmm8,XMMWORD[((16+8))+rsp] + vpxor xmm8,xmm8,xmm4 + + ret + + +global aesni_gcm_decrypt + +ALIGN 32 +aesni_gcm_decrypt: + +$L$SEH_begin_aesni_gcm_decrypt_1: +_CET_ENDBR + xor rax,rax + + + + cmp r8,0x60 + jb NEAR $L$gcm_dec_abort + + push rbp + +$L$SEH_prologue_aesni_gcm_decrypt_2: + mov rbp,rsp + + push rbx + +$L$SEH_prologue_aesni_gcm_decrypt_3: + push r12 + +$L$SEH_prologue_aesni_gcm_decrypt_4: + push r13 + +$L$SEH_prologue_aesni_gcm_decrypt_5: + push r14 + +$L$SEH_prologue_aesni_gcm_decrypt_6: + push r15 + +$L$SEH_prologue_aesni_gcm_decrypt_7: + lea rsp,[((-168))+rsp] +$L$SEH_prologue_aesni_gcm_decrypt_8: +$L$SEH_prologue_aesni_gcm_decrypt_9: + + + + mov QWORD[16+rbp],rdi +$L$SEH_prologue_aesni_gcm_decrypt_10: + mov QWORD[24+rbp],rsi +$L$SEH_prologue_aesni_gcm_decrypt_11: + mov rdi,QWORD[48+rbp] + mov rsi,QWORD[56+rbp] + + movaps XMMWORD[(-208)+rbp],xmm6 +$L$SEH_prologue_aesni_gcm_decrypt_12: + movaps XMMWORD[(-192)+rbp],xmm7 +$L$SEH_prologue_aesni_gcm_decrypt_13: + movaps XMMWORD[(-176)+rbp],xmm8 +$L$SEH_prologue_aesni_gcm_decrypt_14: + movaps XMMWORD[(-160)+rbp],xmm9 +$L$SEH_prologue_aesni_gcm_decrypt_15: + movaps XMMWORD[(-144)+rbp],xmm10 +$L$SEH_prologue_aesni_gcm_decrypt_16: + movaps XMMWORD[(-128)+rbp],xmm11 +$L$SEH_prologue_aesni_gcm_decrypt_17: + movaps XMMWORD[(-112)+rbp],xmm12 +$L$SEH_prologue_aesni_gcm_decrypt_18: + movaps XMMWORD[(-96)+rbp],xmm13 +$L$SEH_prologue_aesni_gcm_decrypt_19: + movaps XMMWORD[(-80)+rbp],xmm14 +$L$SEH_prologue_aesni_gcm_decrypt_20: + movaps XMMWORD[(-64)+rbp],xmm15 +$L$SEH_prologue_aesni_gcm_decrypt_21: +$L$SEH_endprologue_aesni_gcm_decrypt_22: + vzeroupper + + mov r12,QWORD[64+rbp] + vmovdqu xmm1,XMMWORD[rdi] + add rsp,-128 + mov ebx,DWORD[12+rdi] + lea r11,[$L$bswap_mask] + lea r14,[((-128))+r9] + mov r15,0xf80 + vmovdqu xmm8,XMMWORD[r12] + and rsp,-128 + vmovdqu xmm0,XMMWORD[r11] + lea r9,[128+r9] + lea rsi,[32+rsi] + mov r10d,DWORD[((240-128))+r9] + vpshufb xmm8,xmm8,xmm0 + + and r14,r15 + and r15,rsp + sub r15,r14 + jc NEAR $L$dec_no_key_aliasing + cmp r15,768 + jnc NEAR $L$dec_no_key_aliasing + sub rsp,r15 +$L$dec_no_key_aliasing: + + vmovdqu xmm7,XMMWORD[80+rcx] + mov r14,rcx + vmovdqu xmm4,XMMWORD[64+rcx] + + + + + + + + lea r15,[((-192))+r8*1+rcx] + + vmovdqu xmm5,XMMWORD[48+rcx] + shr r8,4 + xor rax,rax + vmovdqu xmm6,XMMWORD[32+rcx] + vpshufb xmm7,xmm7,xmm0 + vmovdqu xmm2,XMMWORD[16+rcx] + vpshufb xmm4,xmm4,xmm0 + vmovdqu xmm3,XMMWORD[rcx] + vpshufb xmm5,xmm5,xmm0 + vmovdqu XMMWORD[48+rsp],xmm4 + vpshufb xmm6,xmm6,xmm0 + vmovdqu XMMWORD[64+rsp],xmm5 + vpshufb xmm2,xmm2,xmm0 + vmovdqu XMMWORD[80+rsp],xmm6 + vpshufb xmm3,xmm3,xmm0 + vmovdqu XMMWORD[96+rsp],xmm2 + vmovdqu XMMWORD[112+rsp],xmm3 + + call _aesni_ctr32_ghash_6x + + mov r12,QWORD[64+rbp] + vmovups XMMWORD[(-96)+rdx],xmm9 + vmovups XMMWORD[(-80)+rdx],xmm10 + vmovups XMMWORD[(-64)+rdx],xmm11 + vmovups XMMWORD[(-48)+rdx],xmm12 + vmovups XMMWORD[(-32)+rdx],xmm13 + vmovups XMMWORD[(-16)+rdx],xmm14 + + vpshufb xmm8,xmm8,XMMWORD[r11] + vmovdqu XMMWORD[r12],xmm8 + + vzeroupper + movaps xmm6,XMMWORD[((-208))+rbp] + movaps xmm7,XMMWORD[((-192))+rbp] + movaps xmm8,XMMWORD[((-176))+rbp] + movaps xmm9,XMMWORD[((-160))+rbp] + movaps xmm10,XMMWORD[((-144))+rbp] + movaps xmm11,XMMWORD[((-128))+rbp] + movaps xmm12,XMMWORD[((-112))+rbp] + movaps xmm13,XMMWORD[((-96))+rbp] + movaps xmm14,XMMWORD[((-80))+rbp] + movaps xmm15,XMMWORD[((-64))+rbp] + mov rdi,QWORD[16+rbp] + mov rsi,QWORD[24+rbp] + lea rsp,[((-40))+rbp] + + pop r15 + + pop r14 + + pop r13 + + pop r12 + + pop rbx + + pop rbp + +$L$gcm_dec_abort: + ret +$L$SEH_end_aesni_gcm_decrypt_23: + + + +ALIGN 32 +_aesni_ctr32_6x: + + vmovdqu xmm4,XMMWORD[((0-128))+r9] + vmovdqu xmm2,XMMWORD[32+r11] + lea r13,[((-1))+r10] + vmovups xmm15,XMMWORD[((16-128))+r9] + lea r12,[((32-128))+r9] + vpxor xmm9,xmm1,xmm4 + add ebx,100663296 + jc NEAR $L$handle_ctr32_2 + vpaddb xmm10,xmm1,xmm2 + vpaddb xmm11,xmm10,xmm2 + vpxor xmm10,xmm10,xmm4 + vpaddb xmm12,xmm11,xmm2 + vpxor xmm11,xmm11,xmm4 + vpaddb xmm13,xmm12,xmm2 + vpxor xmm12,xmm12,xmm4 + vpaddb xmm14,xmm13,xmm2 + vpxor xmm13,xmm13,xmm4 + vpaddb xmm1,xmm14,xmm2 + vpxor xmm14,xmm14,xmm4 + jmp NEAR $L$oop_ctr32 + +ALIGN 16 +$L$oop_ctr32: + vaesenc xmm9,xmm9,xmm15 + vaesenc xmm10,xmm10,xmm15 + vaesenc xmm11,xmm11,xmm15 + vaesenc xmm12,xmm12,xmm15 + vaesenc xmm13,xmm13,xmm15 + vaesenc xmm14,xmm14,xmm15 + vmovups xmm15,XMMWORD[r12] + lea r12,[16+r12] + dec r13d + jnz NEAR $L$oop_ctr32 + + vmovdqu xmm3,XMMWORD[r12] + vaesenc xmm9,xmm9,xmm15 + vpxor xmm4,xmm3,XMMWORD[rcx] + vaesenc xmm10,xmm10,xmm15 + vpxor xmm5,xmm3,XMMWORD[16+rcx] + vaesenc xmm11,xmm11,xmm15 + vpxor xmm6,xmm3,XMMWORD[32+rcx] + vaesenc xmm12,xmm12,xmm15 + vpxor xmm8,xmm3,XMMWORD[48+rcx] + vaesenc xmm13,xmm13,xmm15 + vpxor xmm2,xmm3,XMMWORD[64+rcx] + vaesenc xmm14,xmm14,xmm15 + vpxor xmm3,xmm3,XMMWORD[80+rcx] + lea rcx,[96+rcx] + + vaesenclast xmm9,xmm9,xmm4 + vaesenclast xmm10,xmm10,xmm5 + vaesenclast xmm11,xmm11,xmm6 + vaesenclast xmm12,xmm12,xmm8 + vaesenclast xmm13,xmm13,xmm2 + vaesenclast xmm14,xmm14,xmm3 + vmovups XMMWORD[rdx],xmm9 + vmovups XMMWORD[16+rdx],xmm10 + vmovups XMMWORD[32+rdx],xmm11 + vmovups XMMWORD[48+rdx],xmm12 + vmovups XMMWORD[64+rdx],xmm13 + vmovups XMMWORD[80+rdx],xmm14 + lea rdx,[96+rdx] + + ret +ALIGN 32 +$L$handle_ctr32_2: + vpshufb xmm6,xmm1,xmm0 + vmovdqu xmm5,XMMWORD[48+r11] + vpaddd xmm10,xmm6,XMMWORD[64+r11] + vpaddd xmm11,xmm6,xmm5 + vpaddd xmm12,xmm10,xmm5 + vpshufb xmm10,xmm10,xmm0 + vpaddd xmm13,xmm11,xmm5 + vpshufb xmm11,xmm11,xmm0 + vpxor xmm10,xmm10,xmm4 + vpaddd xmm14,xmm12,xmm5 + vpshufb xmm12,xmm12,xmm0 + vpxor xmm11,xmm11,xmm4 + vpaddd xmm1,xmm13,xmm5 + vpshufb xmm13,xmm13,xmm0 + vpxor xmm12,xmm12,xmm4 + vpshufb xmm14,xmm14,xmm0 + vpxor xmm13,xmm13,xmm4 + vpshufb xmm1,xmm1,xmm0 + vpxor xmm14,xmm14,xmm4 + jmp NEAR $L$oop_ctr32 + + + +global aesni_gcm_encrypt + +ALIGN 32 +aesni_gcm_encrypt: + +$L$SEH_begin_aesni_gcm_encrypt_1: +_CET_ENDBR +%ifdef BORINGSSL_DISPATCH_TEST +EXTERN BORINGSSL_function_hit + mov BYTE[((BORINGSSL_function_hit+2))],1 +%endif + xor rax,rax + + + + + cmp r8,0x60*3 + jb NEAR $L$gcm_enc_abort + + push rbp + +$L$SEH_prologue_aesni_gcm_encrypt_2: + mov rbp,rsp + + push rbx + +$L$SEH_prologue_aesni_gcm_encrypt_3: + push r12 + +$L$SEH_prologue_aesni_gcm_encrypt_4: + push r13 + +$L$SEH_prologue_aesni_gcm_encrypt_5: + push r14 + +$L$SEH_prologue_aesni_gcm_encrypt_6: + push r15 + +$L$SEH_prologue_aesni_gcm_encrypt_7: + lea rsp,[((-168))+rsp] +$L$SEH_prologue_aesni_gcm_encrypt_8: +$L$SEH_prologue_aesni_gcm_encrypt_9: + + + + mov QWORD[16+rbp],rdi +$L$SEH_prologue_aesni_gcm_encrypt_10: + mov QWORD[24+rbp],rsi +$L$SEH_prologue_aesni_gcm_encrypt_11: + mov rdi,QWORD[48+rbp] + mov rsi,QWORD[56+rbp] + + movaps XMMWORD[(-208)+rbp],xmm6 +$L$SEH_prologue_aesni_gcm_encrypt_12: + movaps XMMWORD[(-192)+rbp],xmm7 +$L$SEH_prologue_aesni_gcm_encrypt_13: + movaps XMMWORD[(-176)+rbp],xmm8 +$L$SEH_prologue_aesni_gcm_encrypt_14: + movaps XMMWORD[(-160)+rbp],xmm9 +$L$SEH_prologue_aesni_gcm_encrypt_15: + movaps XMMWORD[(-144)+rbp],xmm10 +$L$SEH_prologue_aesni_gcm_encrypt_16: + movaps XMMWORD[(-128)+rbp],xmm11 +$L$SEH_prologue_aesni_gcm_encrypt_17: + movaps XMMWORD[(-112)+rbp],xmm12 +$L$SEH_prologue_aesni_gcm_encrypt_18: + movaps XMMWORD[(-96)+rbp],xmm13 +$L$SEH_prologue_aesni_gcm_encrypt_19: + movaps XMMWORD[(-80)+rbp],xmm14 +$L$SEH_prologue_aesni_gcm_encrypt_20: + movaps XMMWORD[(-64)+rbp],xmm15 +$L$SEH_prologue_aesni_gcm_encrypt_21: +$L$SEH_endprologue_aesni_gcm_encrypt_22: + vzeroupper + + vmovdqu xmm1,XMMWORD[rdi] + add rsp,-128 + mov ebx,DWORD[12+rdi] + lea r11,[$L$bswap_mask] + lea r14,[((-128))+r9] + mov r15,0xf80 + lea r9,[128+r9] + vmovdqu xmm0,XMMWORD[r11] + and rsp,-128 + mov r10d,DWORD[((240-128))+r9] + + and r14,r15 + and r15,rsp + sub r15,r14 + jc NEAR $L$enc_no_key_aliasing + cmp r15,768 + jnc NEAR $L$enc_no_key_aliasing + sub rsp,r15 +$L$enc_no_key_aliasing: + + mov r14,rdx + + + + + + + + + lea r15,[((-192))+r8*1+rdx] + + shr r8,4 + + call _aesni_ctr32_6x + vpshufb xmm8,xmm9,xmm0 + vpshufb xmm2,xmm10,xmm0 + vmovdqu XMMWORD[112+rsp],xmm8 + vpshufb xmm4,xmm11,xmm0 + vmovdqu XMMWORD[96+rsp],xmm2 + vpshufb xmm5,xmm12,xmm0 + vmovdqu XMMWORD[80+rsp],xmm4 + vpshufb xmm6,xmm13,xmm0 + vmovdqu XMMWORD[64+rsp],xmm5 + vpshufb xmm7,xmm14,xmm0 + vmovdqu XMMWORD[48+rsp],xmm6 + + call _aesni_ctr32_6x + + mov r12,QWORD[64+rbp] + lea rsi,[32+rsi] + vmovdqu xmm8,XMMWORD[r12] + sub r8,12 + mov rax,0x60*2 + vpshufb xmm8,xmm8,xmm0 + + call _aesni_ctr32_ghash_6x + vmovdqu xmm7,XMMWORD[32+rsp] + vmovdqu xmm0,XMMWORD[r11] + vmovdqu xmm3,XMMWORD[((0-32))+rsi] + vpunpckhqdq xmm1,xmm7,xmm7 + vmovdqu xmm15,XMMWORD[((32-32))+rsi] + vmovups XMMWORD[(-96)+rdx],xmm9 + vpshufb xmm9,xmm9,xmm0 + vpxor xmm1,xmm1,xmm7 + vmovups XMMWORD[(-80)+rdx],xmm10 + vpshufb xmm10,xmm10,xmm0 + vmovups XMMWORD[(-64)+rdx],xmm11 + vpshufb xmm11,xmm11,xmm0 + vmovups XMMWORD[(-48)+rdx],xmm12 + vpshufb xmm12,xmm12,xmm0 + vmovups XMMWORD[(-32)+rdx],xmm13 + vpshufb xmm13,xmm13,xmm0 + vmovups XMMWORD[(-16)+rdx],xmm14 + vpshufb xmm14,xmm14,xmm0 + vmovdqu XMMWORD[16+rsp],xmm9 + vmovdqu xmm6,XMMWORD[48+rsp] + vmovdqu xmm0,XMMWORD[((16-32))+rsi] + vpunpckhqdq xmm2,xmm6,xmm6 + vpclmulqdq xmm5,xmm7,xmm3,0x00 + vpxor xmm2,xmm2,xmm6 + vpclmulqdq xmm7,xmm7,xmm3,0x11 + vpclmulqdq xmm1,xmm1,xmm15,0x00 + + vmovdqu xmm9,XMMWORD[64+rsp] + vpclmulqdq xmm4,xmm6,xmm0,0x00 + vmovdqu xmm3,XMMWORD[((48-32))+rsi] + vpxor xmm4,xmm4,xmm5 + vpunpckhqdq xmm5,xmm9,xmm9 + vpclmulqdq xmm6,xmm6,xmm0,0x11 + vpxor xmm5,xmm5,xmm9 + vpxor xmm6,xmm6,xmm7 + vpclmulqdq xmm2,xmm2,xmm15,0x10 + vmovdqu xmm15,XMMWORD[((80-32))+rsi] + vpxor xmm2,xmm2,xmm1 + + vmovdqu xmm1,XMMWORD[80+rsp] + vpclmulqdq xmm7,xmm9,xmm3,0x00 + vmovdqu xmm0,XMMWORD[((64-32))+rsi] + vpxor xmm7,xmm7,xmm4 + vpunpckhqdq xmm4,xmm1,xmm1 + vpclmulqdq xmm9,xmm9,xmm3,0x11 + vpxor xmm4,xmm4,xmm1 + vpxor xmm9,xmm9,xmm6 + vpclmulqdq xmm5,xmm5,xmm15,0x00 + vpxor xmm5,xmm5,xmm2 + + vmovdqu xmm2,XMMWORD[96+rsp] + vpclmulqdq xmm6,xmm1,xmm0,0x00 + vmovdqu xmm3,XMMWORD[((96-32))+rsi] + vpxor xmm6,xmm6,xmm7 + vpunpckhqdq xmm7,xmm2,xmm2 + vpclmulqdq xmm1,xmm1,xmm0,0x11 + vpxor xmm7,xmm7,xmm2 + vpxor xmm1,xmm1,xmm9 + vpclmulqdq xmm4,xmm4,xmm15,0x10 + vmovdqu xmm15,XMMWORD[((128-32))+rsi] + vpxor xmm4,xmm4,xmm5 + + vpxor xmm8,xmm8,XMMWORD[112+rsp] + vpclmulqdq xmm5,xmm2,xmm3,0x00 + vmovdqu xmm0,XMMWORD[((112-32))+rsi] + vpunpckhqdq xmm9,xmm8,xmm8 + vpxor xmm5,xmm5,xmm6 + vpclmulqdq xmm2,xmm2,xmm3,0x11 + vpxor xmm9,xmm9,xmm8 + vpxor xmm2,xmm2,xmm1 + vpclmulqdq xmm7,xmm7,xmm15,0x00 + vpxor xmm4,xmm7,xmm4 + + vpclmulqdq xmm6,xmm8,xmm0,0x00 + vmovdqu xmm3,XMMWORD[((0-32))+rsi] + vpunpckhqdq xmm1,xmm14,xmm14 + vpclmulqdq xmm8,xmm8,xmm0,0x11 + vpxor xmm1,xmm1,xmm14 + vpxor xmm5,xmm6,xmm5 + vpclmulqdq xmm9,xmm9,xmm15,0x10 + vmovdqu xmm15,XMMWORD[((32-32))+rsi] + vpxor xmm7,xmm8,xmm2 + vpxor xmm6,xmm9,xmm4 + + vmovdqu xmm0,XMMWORD[((16-32))+rsi] + vpxor xmm9,xmm7,xmm5 + vpclmulqdq xmm4,xmm14,xmm3,0x00 + vpxor xmm6,xmm6,xmm9 + vpunpckhqdq xmm2,xmm13,xmm13 + vpclmulqdq xmm14,xmm14,xmm3,0x11 + vpxor xmm2,xmm2,xmm13 + vpslldq xmm9,xmm6,8 + vpclmulqdq xmm1,xmm1,xmm15,0x00 + vpxor xmm8,xmm5,xmm9 + vpsrldq xmm6,xmm6,8 + vpxor xmm7,xmm7,xmm6 + + vpclmulqdq xmm5,xmm13,xmm0,0x00 + vmovdqu xmm3,XMMWORD[((48-32))+rsi] + vpxor xmm5,xmm5,xmm4 + vpunpckhqdq xmm9,xmm12,xmm12 + vpclmulqdq xmm13,xmm13,xmm0,0x11 + vpxor xmm9,xmm9,xmm12 + vpxor xmm13,xmm13,xmm14 + vpalignr xmm14,xmm8,xmm8,8 + vpclmulqdq xmm2,xmm2,xmm15,0x10 + vmovdqu xmm15,XMMWORD[((80-32))+rsi] + vpxor xmm2,xmm2,xmm1 + + vpclmulqdq xmm4,xmm12,xmm3,0x00 + vmovdqu xmm0,XMMWORD[((64-32))+rsi] + vpxor xmm4,xmm4,xmm5 + vpunpckhqdq xmm1,xmm11,xmm11 + vpclmulqdq xmm12,xmm12,xmm3,0x11 + vpxor xmm1,xmm1,xmm11 + vpxor xmm12,xmm12,xmm13 + vxorps xmm7,xmm7,XMMWORD[16+rsp] + vpclmulqdq xmm9,xmm9,xmm15,0x00 + vpxor xmm9,xmm9,xmm2 + + vpclmulqdq xmm8,xmm8,XMMWORD[16+r11],0x10 + vxorps xmm8,xmm8,xmm14 + + vpclmulqdq xmm5,xmm11,xmm0,0x00 + vmovdqu xmm3,XMMWORD[((96-32))+rsi] + vpxor xmm5,xmm5,xmm4 + vpunpckhqdq xmm2,xmm10,xmm10 + vpclmulqdq xmm11,xmm11,xmm0,0x11 + vpxor xmm2,xmm2,xmm10 + vpalignr xmm14,xmm8,xmm8,8 + vpxor xmm11,xmm11,xmm12 + vpclmulqdq xmm1,xmm1,xmm15,0x10 + vmovdqu xmm15,XMMWORD[((128-32))+rsi] + vpxor xmm1,xmm1,xmm9 + + vxorps xmm14,xmm14,xmm7 + vpclmulqdq xmm8,xmm8,XMMWORD[16+r11],0x10 + vxorps xmm8,xmm8,xmm14 + + vpclmulqdq xmm4,xmm10,xmm3,0x00 + vmovdqu xmm0,XMMWORD[((112-32))+rsi] + vpxor xmm4,xmm4,xmm5 + vpunpckhqdq xmm9,xmm8,xmm8 + vpclmulqdq xmm10,xmm10,xmm3,0x11 + vpxor xmm9,xmm9,xmm8 + vpxor xmm10,xmm10,xmm11 + vpclmulqdq xmm2,xmm2,xmm15,0x00 + vpxor xmm2,xmm2,xmm1 + + vpclmulqdq xmm5,xmm8,xmm0,0x00 + vpclmulqdq xmm7,xmm8,xmm0,0x11 + vpxor xmm5,xmm5,xmm4 + vpclmulqdq xmm6,xmm9,xmm15,0x10 + vpxor xmm7,xmm7,xmm10 + vpxor xmm6,xmm6,xmm2 + + vpxor xmm4,xmm7,xmm5 + vpxor xmm6,xmm6,xmm4 + vpslldq xmm1,xmm6,8 + vmovdqu xmm3,XMMWORD[16+r11] + vpsrldq xmm6,xmm6,8 + vpxor xmm8,xmm5,xmm1 + vpxor xmm7,xmm7,xmm6 + + vpalignr xmm2,xmm8,xmm8,8 + vpclmulqdq xmm8,xmm8,xmm3,0x10 + vpxor xmm8,xmm8,xmm2 + + vpalignr xmm2,xmm8,xmm8,8 + vpclmulqdq xmm8,xmm8,xmm3,0x10 + vpxor xmm2,xmm2,xmm7 + vpxor xmm8,xmm8,xmm2 + mov r12,QWORD[64+rbp] + vpshufb xmm8,xmm8,XMMWORD[r11] + vmovdqu XMMWORD[r12],xmm8 + + vzeroupper + movaps xmm6,XMMWORD[((-208))+rbp] + movaps xmm7,XMMWORD[((-192))+rbp] + movaps xmm8,XMMWORD[((-176))+rbp] + movaps xmm9,XMMWORD[((-160))+rbp] + movaps xmm10,XMMWORD[((-144))+rbp] + movaps xmm11,XMMWORD[((-128))+rbp] + movaps xmm12,XMMWORD[((-112))+rbp] + movaps xmm13,XMMWORD[((-96))+rbp] + movaps xmm14,XMMWORD[((-80))+rbp] + movaps xmm15,XMMWORD[((-64))+rbp] + mov rdi,QWORD[16+rbp] + mov rsi,QWORD[24+rbp] + lea rsp,[((-40))+rbp] + + pop r15 + + pop r14 + + pop r13 + + pop r12 + + pop rbx + + pop rbp + +$L$gcm_enc_abort: + ret +$L$SEH_end_aesni_gcm_encrypt_23: + + +section .rdata rdata align=8 +ALIGN 64 +$L$bswap_mask: + DB 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 +$L$poly: + DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0xc2 +$L$one_msb: + DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 +$L$two_lsb: + DB 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +$L$one_lsb: + DB 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + DB 65,69,83,45,78,73,32,71,67,77,32,109,111,100,117,108 + DB 101,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82 + DB 89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112 + DB 114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +ALIGN 64 +section .text + +section .pdata rdata align=4 +ALIGN 4 + DD $L$SEH_begin_aesni_gcm_decrypt_1 wrt ..imagebase + DD $L$SEH_end_aesni_gcm_decrypt_23 wrt ..imagebase + DD $L$SEH_info_aesni_gcm_decrypt_0 wrt ..imagebase + + DD $L$SEH_begin_aesni_gcm_encrypt_1 wrt ..imagebase + DD $L$SEH_end_aesni_gcm_encrypt_23 wrt ..imagebase + DD $L$SEH_info_aesni_gcm_encrypt_0 wrt ..imagebase + + +section .xdata rdata align=8 +ALIGN 4 +$L$SEH_info_aesni_gcm_decrypt_0: + DB 1 + DB $L$SEH_endprologue_aesni_gcm_decrypt_22-$L$SEH_begin_aesni_gcm_decrypt_1 + DB 33 + DB 213 + DB $L$SEH_prologue_aesni_gcm_decrypt_21-$L$SEH_begin_aesni_gcm_decrypt_1 + DB 248 + DW 9 + DB $L$SEH_prologue_aesni_gcm_decrypt_20-$L$SEH_begin_aesni_gcm_decrypt_1 + DB 232 + DW 8 + DB $L$SEH_prologue_aesni_gcm_decrypt_19-$L$SEH_begin_aesni_gcm_decrypt_1 + DB 216 + DW 7 + DB $L$SEH_prologue_aesni_gcm_decrypt_18-$L$SEH_begin_aesni_gcm_decrypt_1 + DB 200 + DW 6 + DB $L$SEH_prologue_aesni_gcm_decrypt_17-$L$SEH_begin_aesni_gcm_decrypt_1 + DB 184 + DW 5 + DB $L$SEH_prologue_aesni_gcm_decrypt_16-$L$SEH_begin_aesni_gcm_decrypt_1 + DB 168 + DW 4 + DB $L$SEH_prologue_aesni_gcm_decrypt_15-$L$SEH_begin_aesni_gcm_decrypt_1 + DB 152 + DW 3 + DB $L$SEH_prologue_aesni_gcm_decrypt_14-$L$SEH_begin_aesni_gcm_decrypt_1 + DB 136 + DW 2 + DB $L$SEH_prologue_aesni_gcm_decrypt_13-$L$SEH_begin_aesni_gcm_decrypt_1 + DB 120 + DW 1 + DB $L$SEH_prologue_aesni_gcm_decrypt_12-$L$SEH_begin_aesni_gcm_decrypt_1 + DB 104 + DW 0 + DB $L$SEH_prologue_aesni_gcm_decrypt_11-$L$SEH_begin_aesni_gcm_decrypt_1 + DB 100 + DW 29 + DB $L$SEH_prologue_aesni_gcm_decrypt_10-$L$SEH_begin_aesni_gcm_decrypt_1 + DB 116 + DW 28 + DB $L$SEH_prologue_aesni_gcm_decrypt_9-$L$SEH_begin_aesni_gcm_decrypt_1 + DB 3 + DB $L$SEH_prologue_aesni_gcm_decrypt_8-$L$SEH_begin_aesni_gcm_decrypt_1 + DB 1 + DW 21 + DB $L$SEH_prologue_aesni_gcm_decrypt_7-$L$SEH_begin_aesni_gcm_decrypt_1 + DB 240 + DB $L$SEH_prologue_aesni_gcm_decrypt_6-$L$SEH_begin_aesni_gcm_decrypt_1 + DB 224 + DB $L$SEH_prologue_aesni_gcm_decrypt_5-$L$SEH_begin_aesni_gcm_decrypt_1 + DB 208 + DB $L$SEH_prologue_aesni_gcm_decrypt_4-$L$SEH_begin_aesni_gcm_decrypt_1 + DB 192 + DB $L$SEH_prologue_aesni_gcm_decrypt_3-$L$SEH_begin_aesni_gcm_decrypt_1 + DB 48 + DB $L$SEH_prologue_aesni_gcm_decrypt_2-$L$SEH_begin_aesni_gcm_decrypt_1 + DB 80 + + DW 0 +$L$SEH_info_aesni_gcm_encrypt_0: + DB 1 + DB $L$SEH_endprologue_aesni_gcm_encrypt_22-$L$SEH_begin_aesni_gcm_encrypt_1 + DB 33 + DB 213 + DB $L$SEH_prologue_aesni_gcm_encrypt_21-$L$SEH_begin_aesni_gcm_encrypt_1 + DB 248 + DW 9 + DB $L$SEH_prologue_aesni_gcm_encrypt_20-$L$SEH_begin_aesni_gcm_encrypt_1 + DB 232 + DW 8 + DB $L$SEH_prologue_aesni_gcm_encrypt_19-$L$SEH_begin_aesni_gcm_encrypt_1 + DB 216 + DW 7 + DB $L$SEH_prologue_aesni_gcm_encrypt_18-$L$SEH_begin_aesni_gcm_encrypt_1 + DB 200 + DW 6 + DB $L$SEH_prologue_aesni_gcm_encrypt_17-$L$SEH_begin_aesni_gcm_encrypt_1 + DB 184 + DW 5 + DB $L$SEH_prologue_aesni_gcm_encrypt_16-$L$SEH_begin_aesni_gcm_encrypt_1 + DB 168 + DW 4 + DB $L$SEH_prologue_aesni_gcm_encrypt_15-$L$SEH_begin_aesni_gcm_encrypt_1 + DB 152 + DW 3 + DB $L$SEH_prologue_aesni_gcm_encrypt_14-$L$SEH_begin_aesni_gcm_encrypt_1 + DB 136 + DW 2 + DB $L$SEH_prologue_aesni_gcm_encrypt_13-$L$SEH_begin_aesni_gcm_encrypt_1 + DB 120 + DW 1 + DB $L$SEH_prologue_aesni_gcm_encrypt_12-$L$SEH_begin_aesni_gcm_encrypt_1 + DB 104 + DW 0 + DB $L$SEH_prologue_aesni_gcm_encrypt_11-$L$SEH_begin_aesni_gcm_encrypt_1 + DB 100 + DW 29 + DB $L$SEH_prologue_aesni_gcm_encrypt_10-$L$SEH_begin_aesni_gcm_encrypt_1 + DB 116 + DW 28 + DB $L$SEH_prologue_aesni_gcm_encrypt_9-$L$SEH_begin_aesni_gcm_encrypt_1 + DB 3 + DB $L$SEH_prologue_aesni_gcm_encrypt_8-$L$SEH_begin_aesni_gcm_encrypt_1 + DB 1 + DW 21 + DB $L$SEH_prologue_aesni_gcm_encrypt_7-$L$SEH_begin_aesni_gcm_encrypt_1 + DB 240 + DB $L$SEH_prologue_aesni_gcm_encrypt_6-$L$SEH_begin_aesni_gcm_encrypt_1 + DB 224 + DB $L$SEH_prologue_aesni_gcm_encrypt_5-$L$SEH_begin_aesni_gcm_encrypt_1 + DB 208 + DB $L$SEH_prologue_aesni_gcm_encrypt_4-$L$SEH_begin_aesni_gcm_encrypt_1 + DB 192 + DB $L$SEH_prologue_aesni_gcm_encrypt_3-$L$SEH_begin_aesni_gcm_encrypt_1 + DB 48 + DB $L$SEH_prologue_aesni_gcm_encrypt_2-$L$SEH_begin_aesni_gcm_encrypt_1 + DB 80 + + DW 0 +%else +; Work around https://bugzilla.nasm.us/show_bug.cgi?id=3392738 +ret +%endif diff --git a/http/vendor/ring/pregenerated/aesni-gcm-x86_64-nasm.o b/http/vendor/ring/pregenerated/aesni-gcm-x86_64-nasm.o new file mode 100644 index 0000000..4aca940 Binary files /dev/null and b/http/vendor/ring/pregenerated/aesni-gcm-x86_64-nasm.o differ diff --git a/http/vendor/ring/pregenerated/aesni-x86-elf.S b/http/vendor/ring/pregenerated/aesni-x86-elf.S new file mode 100644 index 0000000..20a5cdf --- /dev/null +++ b/http/vendor/ring/pregenerated/aesni-x86-elf.S @@ -0,0 +1,720 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) +.text +#ifdef BORINGSSL_DISPATCH_TEST +#endif +.hidden _aesni_encrypt2 +.type _aesni_encrypt2,@function +.align 16 +_aesni_encrypt2: + movups (%edx),%xmm0 + shll $4,%ecx + movups 16(%edx),%xmm1 + xorps %xmm0,%xmm2 + pxor %xmm0,%xmm3 + movups 32(%edx),%xmm0 + leal 32(%edx,%ecx,1),%edx + negl %ecx + addl $16,%ecx +.L000enc2_loop: +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 + movups (%edx,%ecx,1),%xmm1 + addl $32,%ecx +.byte 102,15,56,220,208 +.byte 102,15,56,220,216 + movups -16(%edx,%ecx,1),%xmm0 + jnz .L000enc2_loop +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 +.byte 102,15,56,221,208 +.byte 102,15,56,221,216 + ret +.size _aesni_encrypt2,.-_aesni_encrypt2 +.hidden _aesni_encrypt3 +.type _aesni_encrypt3,@function +.align 16 +_aesni_encrypt3: + movups (%edx),%xmm0 + shll $4,%ecx + movups 16(%edx),%xmm1 + xorps %xmm0,%xmm2 + pxor %xmm0,%xmm3 + pxor %xmm0,%xmm4 + movups 32(%edx),%xmm0 + leal 32(%edx,%ecx,1),%edx + negl %ecx + addl $16,%ecx +.L001enc3_loop: +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 +.byte 102,15,56,220,225 + movups (%edx,%ecx,1),%xmm1 + addl $32,%ecx +.byte 102,15,56,220,208 +.byte 102,15,56,220,216 +.byte 102,15,56,220,224 + movups -16(%edx,%ecx,1),%xmm0 + jnz .L001enc3_loop +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 +.byte 102,15,56,220,225 +.byte 102,15,56,221,208 +.byte 102,15,56,221,216 +.byte 102,15,56,221,224 + ret +.size _aesni_encrypt3,.-_aesni_encrypt3 +.hidden _aesni_encrypt4 +.type _aesni_encrypt4,@function +.align 16 +_aesni_encrypt4: + movups (%edx),%xmm0 + movups 16(%edx),%xmm1 + shll $4,%ecx + xorps %xmm0,%xmm2 + pxor %xmm0,%xmm3 + pxor %xmm0,%xmm4 + pxor %xmm0,%xmm5 + movups 32(%edx),%xmm0 + leal 32(%edx,%ecx,1),%edx + negl %ecx +.byte 15,31,64,0 + addl $16,%ecx +.L002enc4_loop: +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 +.byte 102,15,56,220,225 +.byte 102,15,56,220,233 + movups (%edx,%ecx,1),%xmm1 + addl $32,%ecx +.byte 102,15,56,220,208 +.byte 102,15,56,220,216 +.byte 102,15,56,220,224 +.byte 102,15,56,220,232 + movups -16(%edx,%ecx,1),%xmm0 + jnz .L002enc4_loop +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 +.byte 102,15,56,220,225 +.byte 102,15,56,220,233 +.byte 102,15,56,221,208 +.byte 102,15,56,221,216 +.byte 102,15,56,221,224 +.byte 102,15,56,221,232 + ret +.size _aesni_encrypt4,.-_aesni_encrypt4 +.hidden _aesni_encrypt6 +.type _aesni_encrypt6,@function +.align 16 +_aesni_encrypt6: + movups (%edx),%xmm0 + shll $4,%ecx + movups 16(%edx),%xmm1 + xorps %xmm0,%xmm2 + pxor %xmm0,%xmm3 + pxor %xmm0,%xmm4 +.byte 102,15,56,220,209 + pxor %xmm0,%xmm5 + pxor %xmm0,%xmm6 +.byte 102,15,56,220,217 + leal 32(%edx,%ecx,1),%edx + negl %ecx +.byte 102,15,56,220,225 + pxor %xmm0,%xmm7 + movups (%edx,%ecx,1),%xmm0 + addl $16,%ecx + jmp .L003_aesni_encrypt6_inner +.align 16 +.L004enc6_loop: +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 +.byte 102,15,56,220,225 +.L003_aesni_encrypt6_inner: +.byte 102,15,56,220,233 +.byte 102,15,56,220,241 +.byte 102,15,56,220,249 +.L_aesni_encrypt6_enter: + movups (%edx,%ecx,1),%xmm1 + addl $32,%ecx +.byte 102,15,56,220,208 +.byte 102,15,56,220,216 +.byte 102,15,56,220,224 +.byte 102,15,56,220,232 +.byte 102,15,56,220,240 +.byte 102,15,56,220,248 + movups -16(%edx,%ecx,1),%xmm0 + jnz .L004enc6_loop +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 +.byte 102,15,56,220,225 +.byte 102,15,56,220,233 +.byte 102,15,56,220,241 +.byte 102,15,56,220,249 +.byte 102,15,56,221,208 +.byte 102,15,56,221,216 +.byte 102,15,56,221,224 +.byte 102,15,56,221,232 +.byte 102,15,56,221,240 +.byte 102,15,56,221,248 + ret +.size _aesni_encrypt6,.-_aesni_encrypt6 +.globl aes_hw_ctr32_encrypt_blocks +.hidden aes_hw_ctr32_encrypt_blocks +.type aes_hw_ctr32_encrypt_blocks,@function +.align 16 +aes_hw_ctr32_encrypt_blocks: +.L_aes_hw_ctr32_encrypt_blocks_begin: + pushl %ebp + pushl %ebx + pushl %esi + pushl %edi +#ifdef BORINGSSL_DISPATCH_TEST + pushl %ebx + pushl %edx + call .L005pic_for_function_hit +.L005pic_for_function_hit: + popl %ebx + leal BORINGSSL_function_hit+0-.L005pic_for_function_hit(%ebx),%ebx + movl $1,%edx + movb %dl,(%ebx) + popl %edx + popl %ebx +#endif + movl 20(%esp),%esi + movl 24(%esp),%edi + movl 28(%esp),%eax + movl 32(%esp),%edx + movl 36(%esp),%ebx + movl %esp,%ebp + subl $88,%esp + andl $-16,%esp + movl %ebp,80(%esp) + cmpl $1,%eax + je .L006ctr32_one_shortcut + movdqu (%ebx),%xmm7 + movl $202182159,(%esp) + movl $134810123,4(%esp) + movl $67438087,8(%esp) + movl $66051,12(%esp) + movl $6,%ecx + xorl %ebp,%ebp + movl %ecx,16(%esp) + movl %ecx,20(%esp) + movl %ecx,24(%esp) + movl %ebp,28(%esp) +.byte 102,15,58,22,251,3 +.byte 102,15,58,34,253,3 + movl 240(%edx),%ecx + bswap %ebx + pxor %xmm0,%xmm0 + pxor %xmm1,%xmm1 + movdqa (%esp),%xmm2 +.byte 102,15,58,34,195,0 + leal 3(%ebx),%ebp +.byte 102,15,58,34,205,0 + incl %ebx +.byte 102,15,58,34,195,1 + incl %ebp +.byte 102,15,58,34,205,1 + incl %ebx +.byte 102,15,58,34,195,2 + incl %ebp +.byte 102,15,58,34,205,2 + movdqa %xmm0,48(%esp) +.byte 102,15,56,0,194 + movdqu (%edx),%xmm6 + movdqa %xmm1,64(%esp) +.byte 102,15,56,0,202 + pshufd $192,%xmm0,%xmm2 + pshufd $128,%xmm0,%xmm3 + cmpl $6,%eax + jb .L007ctr32_tail + pxor %xmm6,%xmm7 + shll $4,%ecx + movl $16,%ebx + movdqa %xmm7,32(%esp) + movl %edx,%ebp + subl %ecx,%ebx + leal 32(%edx,%ecx,1),%edx + subl $6,%eax + jmp .L008ctr32_loop6 +.align 16 +.L008ctr32_loop6: + pshufd $64,%xmm0,%xmm4 + movdqa 32(%esp),%xmm0 + pshufd $192,%xmm1,%xmm5 + pxor %xmm0,%xmm2 + pshufd $128,%xmm1,%xmm6 + pxor %xmm0,%xmm3 + pshufd $64,%xmm1,%xmm7 + movups 16(%ebp),%xmm1 + pxor %xmm0,%xmm4 + pxor %xmm0,%xmm5 +.byte 102,15,56,220,209 + pxor %xmm0,%xmm6 + pxor %xmm0,%xmm7 +.byte 102,15,56,220,217 + movups 32(%ebp),%xmm0 + movl %ebx,%ecx +.byte 102,15,56,220,225 +.byte 102,15,56,220,233 +.byte 102,15,56,220,241 +.byte 102,15,56,220,249 + call .L_aesni_encrypt6_enter + movups (%esi),%xmm1 + movups 16(%esi),%xmm0 + xorps %xmm1,%xmm2 + movups 32(%esi),%xmm1 + xorps %xmm0,%xmm3 + movups %xmm2,(%edi) + movdqa 16(%esp),%xmm0 + xorps %xmm1,%xmm4 + movdqa 64(%esp),%xmm1 + movups %xmm3,16(%edi) + movups %xmm4,32(%edi) + paddd %xmm0,%xmm1 + paddd 48(%esp),%xmm0 + movdqa (%esp),%xmm2 + movups 48(%esi),%xmm3 + movups 64(%esi),%xmm4 + xorps %xmm3,%xmm5 + movups 80(%esi),%xmm3 + leal 96(%esi),%esi + movdqa %xmm0,48(%esp) +.byte 102,15,56,0,194 + xorps %xmm4,%xmm6 + movups %xmm5,48(%edi) + xorps %xmm3,%xmm7 + movdqa %xmm1,64(%esp) +.byte 102,15,56,0,202 + movups %xmm6,64(%edi) + pshufd $192,%xmm0,%xmm2 + movups %xmm7,80(%edi) + leal 96(%edi),%edi + pshufd $128,%xmm0,%xmm3 + subl $6,%eax + jnc .L008ctr32_loop6 + addl $6,%eax + jz .L009ctr32_ret + movdqu (%ebp),%xmm7 + movl %ebp,%edx + pxor 32(%esp),%xmm7 + movl 240(%ebp),%ecx +.L007ctr32_tail: + por %xmm7,%xmm2 + cmpl $2,%eax + jb .L010ctr32_one + pshufd $64,%xmm0,%xmm4 + por %xmm7,%xmm3 + je .L011ctr32_two + pshufd $192,%xmm1,%xmm5 + por %xmm7,%xmm4 + cmpl $4,%eax + jb .L012ctr32_three + pshufd $128,%xmm1,%xmm6 + por %xmm7,%xmm5 + je .L013ctr32_four + por %xmm7,%xmm6 + call _aesni_encrypt6 + movups (%esi),%xmm1 + movups 16(%esi),%xmm0 + xorps %xmm1,%xmm2 + movups 32(%esi),%xmm1 + xorps %xmm0,%xmm3 + movups 48(%esi),%xmm0 + xorps %xmm1,%xmm4 + movups 64(%esi),%xmm1 + xorps %xmm0,%xmm5 + movups %xmm2,(%edi) + xorps %xmm1,%xmm6 + movups %xmm3,16(%edi) + movups %xmm4,32(%edi) + movups %xmm5,48(%edi) + movups %xmm6,64(%edi) + jmp .L009ctr32_ret +.align 16 +.L006ctr32_one_shortcut: + movups (%ebx),%xmm2 + movl 240(%edx),%ecx +.L010ctr32_one: + movups (%edx),%xmm0 + movups 16(%edx),%xmm1 + leal 32(%edx),%edx + xorps %xmm0,%xmm2 +.L014enc1_loop_1: +.byte 102,15,56,220,209 + decl %ecx + movups (%edx),%xmm1 + leal 16(%edx),%edx + jnz .L014enc1_loop_1 +.byte 102,15,56,221,209 + movups (%esi),%xmm6 + xorps %xmm2,%xmm6 + movups %xmm6,(%edi) + jmp .L009ctr32_ret +.align 16 +.L011ctr32_two: + call _aesni_encrypt2 + movups (%esi),%xmm5 + movups 16(%esi),%xmm6 + xorps %xmm5,%xmm2 + xorps %xmm6,%xmm3 + movups %xmm2,(%edi) + movups %xmm3,16(%edi) + jmp .L009ctr32_ret +.align 16 +.L012ctr32_three: + call _aesni_encrypt3 + movups (%esi),%xmm5 + movups 16(%esi),%xmm6 + xorps %xmm5,%xmm2 + movups 32(%esi),%xmm7 + xorps %xmm6,%xmm3 + movups %xmm2,(%edi) + xorps %xmm7,%xmm4 + movups %xmm3,16(%edi) + movups %xmm4,32(%edi) + jmp .L009ctr32_ret +.align 16 +.L013ctr32_four: + call _aesni_encrypt4 + movups (%esi),%xmm6 + movups 16(%esi),%xmm7 + movups 32(%esi),%xmm1 + xorps %xmm6,%xmm2 + movups 48(%esi),%xmm0 + xorps %xmm7,%xmm3 + movups %xmm2,(%edi) + xorps %xmm1,%xmm4 + movups %xmm3,16(%edi) + xorps %xmm0,%xmm5 + movups %xmm4,32(%edi) + movups %xmm5,48(%edi) +.L009ctr32_ret: + pxor %xmm0,%xmm0 + pxor %xmm1,%xmm1 + pxor %xmm2,%xmm2 + pxor %xmm3,%xmm3 + pxor %xmm4,%xmm4 + movdqa %xmm0,32(%esp) + pxor %xmm5,%xmm5 + movdqa %xmm0,48(%esp) + pxor %xmm6,%xmm6 + movdqa %xmm0,64(%esp) + pxor %xmm7,%xmm7 + movl 80(%esp),%esp + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.size aes_hw_ctr32_encrypt_blocks,.-.L_aes_hw_ctr32_encrypt_blocks_begin +.globl aes_hw_set_encrypt_key_base +.hidden aes_hw_set_encrypt_key_base +.type aes_hw_set_encrypt_key_base,@function +.align 16 +aes_hw_set_encrypt_key_base: +.L_aes_hw_set_encrypt_key_base_begin: +#ifdef BORINGSSL_DISPATCH_TEST + pushl %ebx + pushl %edx + call .L015pic_for_function_hit +.L015pic_for_function_hit: + popl %ebx + leal BORINGSSL_function_hit+3-.L015pic_for_function_hit(%ebx),%ebx + movl $1,%edx + movb %dl,(%ebx) + popl %edx + popl %ebx +#endif + movl 4(%esp),%eax + movl 8(%esp),%ecx + movl 12(%esp),%edx + pushl %ebx + call .L016pic +.L016pic: + popl %ebx + leal .Lkey_const-.L016pic(%ebx),%ebx + movups (%eax),%xmm0 + xorps %xmm4,%xmm4 + leal 16(%edx),%edx + cmpl $256,%ecx + je .L01714rounds + cmpl $128,%ecx + jne .L018bad_keybits +.align 16 +.L01910rounds: + movl $9,%ecx + movups %xmm0,-16(%edx) +.byte 102,15,58,223,200,1 + call .L020key_128_cold +.byte 102,15,58,223,200,2 + call .L021key_128 +.byte 102,15,58,223,200,4 + call .L021key_128 +.byte 102,15,58,223,200,8 + call .L021key_128 +.byte 102,15,58,223,200,16 + call .L021key_128 +.byte 102,15,58,223,200,32 + call .L021key_128 +.byte 102,15,58,223,200,64 + call .L021key_128 +.byte 102,15,58,223,200,128 + call .L021key_128 +.byte 102,15,58,223,200,27 + call .L021key_128 +.byte 102,15,58,223,200,54 + call .L021key_128 + movups %xmm0,(%edx) + movl %ecx,80(%edx) + jmp .L022good_key +.align 16 +.L021key_128: + movups %xmm0,(%edx) + leal 16(%edx),%edx +.L020key_128_cold: + shufps $16,%xmm0,%xmm4 + xorps %xmm4,%xmm0 + shufps $140,%xmm0,%xmm4 + xorps %xmm4,%xmm0 + shufps $255,%xmm1,%xmm1 + xorps %xmm1,%xmm0 + ret +.align 16 +.L01714rounds: + movups 16(%eax),%xmm2 + leal 16(%edx),%edx + movl $13,%ecx + movups %xmm0,-32(%edx) + movups %xmm2,-16(%edx) +.byte 102,15,58,223,202,1 + call .L023key_256a_cold +.byte 102,15,58,223,200,1 + call .L024key_256b +.byte 102,15,58,223,202,2 + call .L025key_256a +.byte 102,15,58,223,200,2 + call .L024key_256b +.byte 102,15,58,223,202,4 + call .L025key_256a +.byte 102,15,58,223,200,4 + call .L024key_256b +.byte 102,15,58,223,202,8 + call .L025key_256a +.byte 102,15,58,223,200,8 + call .L024key_256b +.byte 102,15,58,223,202,16 + call .L025key_256a +.byte 102,15,58,223,200,16 + call .L024key_256b +.byte 102,15,58,223,202,32 + call .L025key_256a +.byte 102,15,58,223,200,32 + call .L024key_256b +.byte 102,15,58,223,202,64 + call .L025key_256a + movups %xmm0,(%edx) + movl %ecx,16(%edx) + xorl %eax,%eax + jmp .L022good_key +.align 16 +.L025key_256a: + movups %xmm2,(%edx) + leal 16(%edx),%edx +.L023key_256a_cold: + shufps $16,%xmm0,%xmm4 + xorps %xmm4,%xmm0 + shufps $140,%xmm0,%xmm4 + xorps %xmm4,%xmm0 + shufps $255,%xmm1,%xmm1 + xorps %xmm1,%xmm0 + ret +.align 16 +.L024key_256b: + movups %xmm0,(%edx) + leal 16(%edx),%edx + shufps $16,%xmm2,%xmm4 + xorps %xmm4,%xmm2 + shufps $140,%xmm2,%xmm4 + xorps %xmm4,%xmm2 + shufps $170,%xmm1,%xmm1 + xorps %xmm1,%xmm2 + ret +.L022good_key: + pxor %xmm0,%xmm0 + pxor %xmm1,%xmm1 + pxor %xmm2,%xmm2 + pxor %xmm3,%xmm3 + pxor %xmm4,%xmm4 + pxor %xmm5,%xmm5 + xorl %eax,%eax + popl %ebx + ret +.align 4 +.L018bad_keybits: + pxor %xmm0,%xmm0 + movl $-2,%eax + popl %ebx + ret +.size aes_hw_set_encrypt_key_base,.-.L_aes_hw_set_encrypt_key_base_begin +.globl aes_hw_set_encrypt_key_alt +.hidden aes_hw_set_encrypt_key_alt +.type aes_hw_set_encrypt_key_alt,@function +.align 16 +aes_hw_set_encrypt_key_alt: +.L_aes_hw_set_encrypt_key_alt_begin: +#ifdef BORINGSSL_DISPATCH_TEST + pushl %ebx + pushl %edx + call .L026pic_for_function_hit +.L026pic_for_function_hit: + popl %ebx + leal BORINGSSL_function_hit+3-.L026pic_for_function_hit(%ebx),%ebx + movl $1,%edx + movb %dl,(%ebx) + popl %edx + popl %ebx +#endif + movl 4(%esp),%eax + movl 8(%esp),%ecx + movl 12(%esp),%edx + pushl %ebx + call .L027pic +.L027pic: + popl %ebx + leal .Lkey_const-.L027pic(%ebx),%ebx + movups (%eax),%xmm0 + xorps %xmm4,%xmm4 + leal 16(%edx),%edx + cmpl $256,%ecx + je .L02814rounds_alt + cmpl $128,%ecx + jne .L029bad_keybits +.align 16 +.L03010rounds_alt: + movdqa (%ebx),%xmm5 + movl $8,%ecx + movdqa 32(%ebx),%xmm4 + movdqa %xmm0,%xmm2 + movdqu %xmm0,-16(%edx) +.L031loop_key128: +.byte 102,15,56,0,197 +.byte 102,15,56,221,196 + pslld $1,%xmm4 + leal 16(%edx),%edx + movdqa %xmm2,%xmm3 + pslldq $4,%xmm2 + pxor %xmm2,%xmm3 + pslldq $4,%xmm2 + pxor %xmm2,%xmm3 + pslldq $4,%xmm2 + pxor %xmm3,%xmm2 + pxor %xmm2,%xmm0 + movdqu %xmm0,-16(%edx) + movdqa %xmm0,%xmm2 + decl %ecx + jnz .L031loop_key128 + movdqa 48(%ebx),%xmm4 +.byte 102,15,56,0,197 +.byte 102,15,56,221,196 + pslld $1,%xmm4 + movdqa %xmm2,%xmm3 + pslldq $4,%xmm2 + pxor %xmm2,%xmm3 + pslldq $4,%xmm2 + pxor %xmm2,%xmm3 + pslldq $4,%xmm2 + pxor %xmm3,%xmm2 + pxor %xmm2,%xmm0 + movdqu %xmm0,(%edx) + movdqa %xmm0,%xmm2 +.byte 102,15,56,0,197 +.byte 102,15,56,221,196 + movdqa %xmm2,%xmm3 + pslldq $4,%xmm2 + pxor %xmm2,%xmm3 + pslldq $4,%xmm2 + pxor %xmm2,%xmm3 + pslldq $4,%xmm2 + pxor %xmm3,%xmm2 + pxor %xmm2,%xmm0 + movdqu %xmm0,16(%edx) + movl $9,%ecx + movl %ecx,96(%edx) + jmp .L032good_key +.align 16 +.L02814rounds_alt: + movups 16(%eax),%xmm2 + leal 16(%edx),%edx + movdqa (%ebx),%xmm5 + movdqa 32(%ebx),%xmm4 + movl $7,%ecx + movdqu %xmm0,-32(%edx) + movdqa %xmm2,%xmm1 + movdqu %xmm2,-16(%edx) +.L033loop_key256: +.byte 102,15,56,0,213 +.byte 102,15,56,221,212 + movdqa %xmm0,%xmm3 + pslldq $4,%xmm0 + pxor %xmm0,%xmm3 + pslldq $4,%xmm0 + pxor %xmm0,%xmm3 + pslldq $4,%xmm0 + pxor %xmm3,%xmm0 + pslld $1,%xmm4 + pxor %xmm2,%xmm0 + movdqu %xmm0,(%edx) + decl %ecx + jz .L034done_key256 + pshufd $255,%xmm0,%xmm2 + pxor %xmm3,%xmm3 +.byte 102,15,56,221,211 + movdqa %xmm1,%xmm3 + pslldq $4,%xmm1 + pxor %xmm1,%xmm3 + pslldq $4,%xmm1 + pxor %xmm1,%xmm3 + pslldq $4,%xmm1 + pxor %xmm3,%xmm1 + pxor %xmm1,%xmm2 + movdqu %xmm2,16(%edx) + leal 32(%edx),%edx + movdqa %xmm2,%xmm1 + jmp .L033loop_key256 +.L034done_key256: + movl $13,%ecx + movl %ecx,16(%edx) +.L032good_key: + pxor %xmm0,%xmm0 + pxor %xmm1,%xmm1 + pxor %xmm2,%xmm2 + pxor %xmm3,%xmm3 + pxor %xmm4,%xmm4 + pxor %xmm5,%xmm5 + xorl %eax,%eax + popl %ebx + ret +.align 4 +.L029bad_keybits: + pxor %xmm0,%xmm0 + movl $-2,%eax + popl %ebx + ret +.size aes_hw_set_encrypt_key_alt,.-.L_aes_hw_set_encrypt_key_alt_begin +.align 64 +.Lkey_const: +.long 202313229,202313229,202313229,202313229 +.long 67569157,67569157,67569157,67569157 +.long 1,1,1,1 +.long 27,27,27,27 +.byte 65,69,83,32,102,111,114,32,73,110,116,101,108,32,65,69 +.byte 83,45,78,73,44,32,67,82,89,80,84,79,71,65,77,83 +.byte 32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115 +.byte 115,108,46,111,114,103,62,0 +#endif // !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) diff --git a/http/vendor/ring/pregenerated/aesni-x86-win32n.asm b/http/vendor/ring/pregenerated/aesni-x86-win32n.asm new file mode 100644 index 0000000..b9fe666 --- /dev/null +++ b/http/vendor/ring/pregenerated/aesni-x86-win32n.asm @@ -0,0 +1,709 @@ +; This file is generated from a similarly-named Perl script in the BoringSSL +; source tree. Do not edit by hand. + +%include "ring_core_generated/prefix_symbols_nasm.inc" +%ifidn __OUTPUT_FORMAT__, win32 +%ifidn __OUTPUT_FORMAT__,obj +section code use32 class=code align=64 +%elifidn __OUTPUT_FORMAT__,win32 +$@feat.00 equ 1 +section .text code align=64 +%else +section .text code +%endif +%ifdef BORINGSSL_DISPATCH_TEST +extern _BORINGSSL_function_hit +%endif +align 16 +__aesni_encrypt2: + movups xmm0,[edx] + shl ecx,4 + movups xmm1,[16+edx] + xorps xmm2,xmm0 + pxor xmm3,xmm0 + movups xmm0,[32+edx] + lea edx,[32+ecx*1+edx] + neg ecx + add ecx,16 +L$000enc2_loop: +db 102,15,56,220,209 +db 102,15,56,220,217 + movups xmm1,[ecx*1+edx] + add ecx,32 +db 102,15,56,220,208 +db 102,15,56,220,216 + movups xmm0,[ecx*1+edx-16] + jnz NEAR L$000enc2_loop +db 102,15,56,220,209 +db 102,15,56,220,217 +db 102,15,56,221,208 +db 102,15,56,221,216 + ret +align 16 +__aesni_encrypt3: + movups xmm0,[edx] + shl ecx,4 + movups xmm1,[16+edx] + xorps xmm2,xmm0 + pxor xmm3,xmm0 + pxor xmm4,xmm0 + movups xmm0,[32+edx] + lea edx,[32+ecx*1+edx] + neg ecx + add ecx,16 +L$001enc3_loop: +db 102,15,56,220,209 +db 102,15,56,220,217 +db 102,15,56,220,225 + movups xmm1,[ecx*1+edx] + add ecx,32 +db 102,15,56,220,208 +db 102,15,56,220,216 +db 102,15,56,220,224 + movups xmm0,[ecx*1+edx-16] + jnz NEAR L$001enc3_loop +db 102,15,56,220,209 +db 102,15,56,220,217 +db 102,15,56,220,225 +db 102,15,56,221,208 +db 102,15,56,221,216 +db 102,15,56,221,224 + ret +align 16 +__aesni_encrypt4: + movups xmm0,[edx] + movups xmm1,[16+edx] + shl ecx,4 + xorps xmm2,xmm0 + pxor xmm3,xmm0 + pxor xmm4,xmm0 + pxor xmm5,xmm0 + movups xmm0,[32+edx] + lea edx,[32+ecx*1+edx] + neg ecx +db 15,31,64,0 + add ecx,16 +L$002enc4_loop: +db 102,15,56,220,209 +db 102,15,56,220,217 +db 102,15,56,220,225 +db 102,15,56,220,233 + movups xmm1,[ecx*1+edx] + add ecx,32 +db 102,15,56,220,208 +db 102,15,56,220,216 +db 102,15,56,220,224 +db 102,15,56,220,232 + movups xmm0,[ecx*1+edx-16] + jnz NEAR L$002enc4_loop +db 102,15,56,220,209 +db 102,15,56,220,217 +db 102,15,56,220,225 +db 102,15,56,220,233 +db 102,15,56,221,208 +db 102,15,56,221,216 +db 102,15,56,221,224 +db 102,15,56,221,232 + ret +align 16 +__aesni_encrypt6: + movups xmm0,[edx] + shl ecx,4 + movups xmm1,[16+edx] + xorps xmm2,xmm0 + pxor xmm3,xmm0 + pxor xmm4,xmm0 +db 102,15,56,220,209 + pxor xmm5,xmm0 + pxor xmm6,xmm0 +db 102,15,56,220,217 + lea edx,[32+ecx*1+edx] + neg ecx +db 102,15,56,220,225 + pxor xmm7,xmm0 + movups xmm0,[ecx*1+edx] + add ecx,16 + jmp NEAR L$003_aesni_encrypt6_inner +align 16 +L$004enc6_loop: +db 102,15,56,220,209 +db 102,15,56,220,217 +db 102,15,56,220,225 +L$003_aesni_encrypt6_inner: +db 102,15,56,220,233 +db 102,15,56,220,241 +db 102,15,56,220,249 +L$_aesni_encrypt6_enter: + movups xmm1,[ecx*1+edx] + add ecx,32 +db 102,15,56,220,208 +db 102,15,56,220,216 +db 102,15,56,220,224 +db 102,15,56,220,232 +db 102,15,56,220,240 +db 102,15,56,220,248 + movups xmm0,[ecx*1+edx-16] + jnz NEAR L$004enc6_loop +db 102,15,56,220,209 +db 102,15,56,220,217 +db 102,15,56,220,225 +db 102,15,56,220,233 +db 102,15,56,220,241 +db 102,15,56,220,249 +db 102,15,56,221,208 +db 102,15,56,221,216 +db 102,15,56,221,224 +db 102,15,56,221,232 +db 102,15,56,221,240 +db 102,15,56,221,248 + ret +global _aes_hw_ctr32_encrypt_blocks +align 16 +_aes_hw_ctr32_encrypt_blocks: +L$_aes_hw_ctr32_encrypt_blocks_begin: + push ebp + push ebx + push esi + push edi +%ifdef BORINGSSL_DISPATCH_TEST + push ebx + push edx + call L$005pic_for_function_hit +L$005pic_for_function_hit: + pop ebx + lea ebx,[(_BORINGSSL_function_hit+0-L$005pic_for_function_hit)+ebx] + mov edx,1 + mov BYTE [ebx],dl + pop edx + pop ebx +%endif + mov esi,DWORD [20+esp] + mov edi,DWORD [24+esp] + mov eax,DWORD [28+esp] + mov edx,DWORD [32+esp] + mov ebx,DWORD [36+esp] + mov ebp,esp + sub esp,88 + and esp,-16 + mov DWORD [80+esp],ebp + cmp eax,1 + je NEAR L$006ctr32_one_shortcut + movdqu xmm7,[ebx] + mov DWORD [esp],202182159 + mov DWORD [4+esp],134810123 + mov DWORD [8+esp],67438087 + mov DWORD [12+esp],66051 + mov ecx,6 + xor ebp,ebp + mov DWORD [16+esp],ecx + mov DWORD [20+esp],ecx + mov DWORD [24+esp],ecx + mov DWORD [28+esp],ebp +db 102,15,58,22,251,3 +db 102,15,58,34,253,3 + mov ecx,DWORD [240+edx] + bswap ebx + pxor xmm0,xmm0 + pxor xmm1,xmm1 + movdqa xmm2,[esp] +db 102,15,58,34,195,0 + lea ebp,[3+ebx] +db 102,15,58,34,205,0 + inc ebx +db 102,15,58,34,195,1 + inc ebp +db 102,15,58,34,205,1 + inc ebx +db 102,15,58,34,195,2 + inc ebp +db 102,15,58,34,205,2 + movdqa [48+esp],xmm0 +db 102,15,56,0,194 + movdqu xmm6,[edx] + movdqa [64+esp],xmm1 +db 102,15,56,0,202 + pshufd xmm2,xmm0,192 + pshufd xmm3,xmm0,128 + cmp eax,6 + jb NEAR L$007ctr32_tail + pxor xmm7,xmm6 + shl ecx,4 + mov ebx,16 + movdqa [32+esp],xmm7 + mov ebp,edx + sub ebx,ecx + lea edx,[32+ecx*1+edx] + sub eax,6 + jmp NEAR L$008ctr32_loop6 +align 16 +L$008ctr32_loop6: + pshufd xmm4,xmm0,64 + movdqa xmm0,[32+esp] + pshufd xmm5,xmm1,192 + pxor xmm2,xmm0 + pshufd xmm6,xmm1,128 + pxor xmm3,xmm0 + pshufd xmm7,xmm1,64 + movups xmm1,[16+ebp] + pxor xmm4,xmm0 + pxor xmm5,xmm0 +db 102,15,56,220,209 + pxor xmm6,xmm0 + pxor xmm7,xmm0 +db 102,15,56,220,217 + movups xmm0,[32+ebp] + mov ecx,ebx +db 102,15,56,220,225 +db 102,15,56,220,233 +db 102,15,56,220,241 +db 102,15,56,220,249 + call L$_aesni_encrypt6_enter + movups xmm1,[esi] + movups xmm0,[16+esi] + xorps xmm2,xmm1 + movups xmm1,[32+esi] + xorps xmm3,xmm0 + movups [edi],xmm2 + movdqa xmm0,[16+esp] + xorps xmm4,xmm1 + movdqa xmm1,[64+esp] + movups [16+edi],xmm3 + movups [32+edi],xmm4 + paddd xmm1,xmm0 + paddd xmm0,[48+esp] + movdqa xmm2,[esp] + movups xmm3,[48+esi] + movups xmm4,[64+esi] + xorps xmm5,xmm3 + movups xmm3,[80+esi] + lea esi,[96+esi] + movdqa [48+esp],xmm0 +db 102,15,56,0,194 + xorps xmm6,xmm4 + movups [48+edi],xmm5 + xorps xmm7,xmm3 + movdqa [64+esp],xmm1 +db 102,15,56,0,202 + movups [64+edi],xmm6 + pshufd xmm2,xmm0,192 + movups [80+edi],xmm7 + lea edi,[96+edi] + pshufd xmm3,xmm0,128 + sub eax,6 + jnc NEAR L$008ctr32_loop6 + add eax,6 + jz NEAR L$009ctr32_ret + movdqu xmm7,[ebp] + mov edx,ebp + pxor xmm7,[32+esp] + mov ecx,DWORD [240+ebp] +L$007ctr32_tail: + por xmm2,xmm7 + cmp eax,2 + jb NEAR L$010ctr32_one + pshufd xmm4,xmm0,64 + por xmm3,xmm7 + je NEAR L$011ctr32_two + pshufd xmm5,xmm1,192 + por xmm4,xmm7 + cmp eax,4 + jb NEAR L$012ctr32_three + pshufd xmm6,xmm1,128 + por xmm5,xmm7 + je NEAR L$013ctr32_four + por xmm6,xmm7 + call __aesni_encrypt6 + movups xmm1,[esi] + movups xmm0,[16+esi] + xorps xmm2,xmm1 + movups xmm1,[32+esi] + xorps xmm3,xmm0 + movups xmm0,[48+esi] + xorps xmm4,xmm1 + movups xmm1,[64+esi] + xorps xmm5,xmm0 + movups [edi],xmm2 + xorps xmm6,xmm1 + movups [16+edi],xmm3 + movups [32+edi],xmm4 + movups [48+edi],xmm5 + movups [64+edi],xmm6 + jmp NEAR L$009ctr32_ret +align 16 +L$006ctr32_one_shortcut: + movups xmm2,[ebx] + mov ecx,DWORD [240+edx] +L$010ctr32_one: + movups xmm0,[edx] + movups xmm1,[16+edx] + lea edx,[32+edx] + xorps xmm2,xmm0 +L$014enc1_loop_1: +db 102,15,56,220,209 + dec ecx + movups xmm1,[edx] + lea edx,[16+edx] + jnz NEAR L$014enc1_loop_1 +db 102,15,56,221,209 + movups xmm6,[esi] + xorps xmm6,xmm2 + movups [edi],xmm6 + jmp NEAR L$009ctr32_ret +align 16 +L$011ctr32_two: + call __aesni_encrypt2 + movups xmm5,[esi] + movups xmm6,[16+esi] + xorps xmm2,xmm5 + xorps xmm3,xmm6 + movups [edi],xmm2 + movups [16+edi],xmm3 + jmp NEAR L$009ctr32_ret +align 16 +L$012ctr32_three: + call __aesni_encrypt3 + movups xmm5,[esi] + movups xmm6,[16+esi] + xorps xmm2,xmm5 + movups xmm7,[32+esi] + xorps xmm3,xmm6 + movups [edi],xmm2 + xorps xmm4,xmm7 + movups [16+edi],xmm3 + movups [32+edi],xmm4 + jmp NEAR L$009ctr32_ret +align 16 +L$013ctr32_four: + call __aesni_encrypt4 + movups xmm6,[esi] + movups xmm7,[16+esi] + movups xmm1,[32+esi] + xorps xmm2,xmm6 + movups xmm0,[48+esi] + xorps xmm3,xmm7 + movups [edi],xmm2 + xorps xmm4,xmm1 + movups [16+edi],xmm3 + xorps xmm5,xmm0 + movups [32+edi],xmm4 + movups [48+edi],xmm5 +L$009ctr32_ret: + pxor xmm0,xmm0 + pxor xmm1,xmm1 + pxor xmm2,xmm2 + pxor xmm3,xmm3 + pxor xmm4,xmm4 + movdqa [32+esp],xmm0 + pxor xmm5,xmm5 + movdqa [48+esp],xmm0 + pxor xmm6,xmm6 + movdqa [64+esp],xmm0 + pxor xmm7,xmm7 + mov esp,DWORD [80+esp] + pop edi + pop esi + pop ebx + pop ebp + ret +global _aes_hw_set_encrypt_key_base +align 16 +_aes_hw_set_encrypt_key_base: +L$_aes_hw_set_encrypt_key_base_begin: +%ifdef BORINGSSL_DISPATCH_TEST + push ebx + push edx + call L$015pic_for_function_hit +L$015pic_for_function_hit: + pop ebx + lea ebx,[(_BORINGSSL_function_hit+3-L$015pic_for_function_hit)+ebx] + mov edx,1 + mov BYTE [ebx],dl + pop edx + pop ebx +%endif + mov eax,DWORD [4+esp] + mov ecx,DWORD [8+esp] + mov edx,DWORD [12+esp] + push ebx + call L$016pic +L$016pic: + pop ebx + lea ebx,[(L$key_const-L$016pic)+ebx] + movups xmm0,[eax] + xorps xmm4,xmm4 + lea edx,[16+edx] + cmp ecx,256 + je NEAR L$01714rounds + cmp ecx,128 + jne NEAR L$018bad_keybits +align 16 +L$01910rounds: + mov ecx,9 + movups [edx-16],xmm0 +db 102,15,58,223,200,1 + call L$020key_128_cold +db 102,15,58,223,200,2 + call L$021key_128 +db 102,15,58,223,200,4 + call L$021key_128 +db 102,15,58,223,200,8 + call L$021key_128 +db 102,15,58,223,200,16 + call L$021key_128 +db 102,15,58,223,200,32 + call L$021key_128 +db 102,15,58,223,200,64 + call L$021key_128 +db 102,15,58,223,200,128 + call L$021key_128 +db 102,15,58,223,200,27 + call L$021key_128 +db 102,15,58,223,200,54 + call L$021key_128 + movups [edx],xmm0 + mov DWORD [80+edx],ecx + jmp NEAR L$022good_key +align 16 +L$021key_128: + movups [edx],xmm0 + lea edx,[16+edx] +L$020key_128_cold: + shufps xmm4,xmm0,16 + xorps xmm0,xmm4 + shufps xmm4,xmm0,140 + xorps xmm0,xmm4 + shufps xmm1,xmm1,255 + xorps xmm0,xmm1 + ret +align 16 +L$01714rounds: + movups xmm2,[16+eax] + lea edx,[16+edx] + mov ecx,13 + movups [edx-32],xmm0 + movups [edx-16],xmm2 +db 102,15,58,223,202,1 + call L$023key_256a_cold +db 102,15,58,223,200,1 + call L$024key_256b +db 102,15,58,223,202,2 + call L$025key_256a +db 102,15,58,223,200,2 + call L$024key_256b +db 102,15,58,223,202,4 + call L$025key_256a +db 102,15,58,223,200,4 + call L$024key_256b +db 102,15,58,223,202,8 + call L$025key_256a +db 102,15,58,223,200,8 + call L$024key_256b +db 102,15,58,223,202,16 + call L$025key_256a +db 102,15,58,223,200,16 + call L$024key_256b +db 102,15,58,223,202,32 + call L$025key_256a +db 102,15,58,223,200,32 + call L$024key_256b +db 102,15,58,223,202,64 + call L$025key_256a + movups [edx],xmm0 + mov DWORD [16+edx],ecx + xor eax,eax + jmp NEAR L$022good_key +align 16 +L$025key_256a: + movups [edx],xmm2 + lea edx,[16+edx] +L$023key_256a_cold: + shufps xmm4,xmm0,16 + xorps xmm0,xmm4 + shufps xmm4,xmm0,140 + xorps xmm0,xmm4 + shufps xmm1,xmm1,255 + xorps xmm0,xmm1 + ret +align 16 +L$024key_256b: + movups [edx],xmm0 + lea edx,[16+edx] + shufps xmm4,xmm2,16 + xorps xmm2,xmm4 + shufps xmm4,xmm2,140 + xorps xmm2,xmm4 + shufps xmm1,xmm1,170 + xorps xmm2,xmm1 + ret +L$022good_key: + pxor xmm0,xmm0 + pxor xmm1,xmm1 + pxor xmm2,xmm2 + pxor xmm3,xmm3 + pxor xmm4,xmm4 + pxor xmm5,xmm5 + xor eax,eax + pop ebx + ret +align 4 +L$018bad_keybits: + pxor xmm0,xmm0 + mov eax,-2 + pop ebx + ret +global _aes_hw_set_encrypt_key_alt +align 16 +_aes_hw_set_encrypt_key_alt: +L$_aes_hw_set_encrypt_key_alt_begin: +%ifdef BORINGSSL_DISPATCH_TEST + push ebx + push edx + call L$026pic_for_function_hit +L$026pic_for_function_hit: + pop ebx + lea ebx,[(_BORINGSSL_function_hit+3-L$026pic_for_function_hit)+ebx] + mov edx,1 + mov BYTE [ebx],dl + pop edx + pop ebx +%endif + mov eax,DWORD [4+esp] + mov ecx,DWORD [8+esp] + mov edx,DWORD [12+esp] + push ebx + call L$027pic +L$027pic: + pop ebx + lea ebx,[(L$key_const-L$027pic)+ebx] + movups xmm0,[eax] + xorps xmm4,xmm4 + lea edx,[16+edx] + cmp ecx,256 + je NEAR L$02814rounds_alt + cmp ecx,128 + jne NEAR L$029bad_keybits +align 16 +L$03010rounds_alt: + movdqa xmm5,[ebx] + mov ecx,8 + movdqa xmm4,[32+ebx] + movdqa xmm2,xmm0 + movdqu [edx-16],xmm0 +L$031loop_key128: +db 102,15,56,0,197 +db 102,15,56,221,196 + pslld xmm4,1 + lea edx,[16+edx] + movdqa xmm3,xmm2 + pslldq xmm2,4 + pxor xmm3,xmm2 + pslldq xmm2,4 + pxor xmm3,xmm2 + pslldq xmm2,4 + pxor xmm2,xmm3 + pxor xmm0,xmm2 + movdqu [edx-16],xmm0 + movdqa xmm2,xmm0 + dec ecx + jnz NEAR L$031loop_key128 + movdqa xmm4,[48+ebx] +db 102,15,56,0,197 +db 102,15,56,221,196 + pslld xmm4,1 + movdqa xmm3,xmm2 + pslldq xmm2,4 + pxor xmm3,xmm2 + pslldq xmm2,4 + pxor xmm3,xmm2 + pslldq xmm2,4 + pxor xmm2,xmm3 + pxor xmm0,xmm2 + movdqu [edx],xmm0 + movdqa xmm2,xmm0 +db 102,15,56,0,197 +db 102,15,56,221,196 + movdqa xmm3,xmm2 + pslldq xmm2,4 + pxor xmm3,xmm2 + pslldq xmm2,4 + pxor xmm3,xmm2 + pslldq xmm2,4 + pxor xmm2,xmm3 + pxor xmm0,xmm2 + movdqu [16+edx],xmm0 + mov ecx,9 + mov DWORD [96+edx],ecx + jmp NEAR L$032good_key +align 16 +L$02814rounds_alt: + movups xmm2,[16+eax] + lea edx,[16+edx] + movdqa xmm5,[ebx] + movdqa xmm4,[32+ebx] + mov ecx,7 + movdqu [edx-32],xmm0 + movdqa xmm1,xmm2 + movdqu [edx-16],xmm2 +L$033loop_key256: +db 102,15,56,0,213 +db 102,15,56,221,212 + movdqa xmm3,xmm0 + pslldq xmm0,4 + pxor xmm3,xmm0 + pslldq xmm0,4 + pxor xmm3,xmm0 + pslldq xmm0,4 + pxor xmm0,xmm3 + pslld xmm4,1 + pxor xmm0,xmm2 + movdqu [edx],xmm0 + dec ecx + jz NEAR L$034done_key256 + pshufd xmm2,xmm0,255 + pxor xmm3,xmm3 +db 102,15,56,221,211 + movdqa xmm3,xmm1 + pslldq xmm1,4 + pxor xmm3,xmm1 + pslldq xmm1,4 + pxor xmm3,xmm1 + pslldq xmm1,4 + pxor xmm1,xmm3 + pxor xmm2,xmm1 + movdqu [16+edx],xmm2 + lea edx,[32+edx] + movdqa xmm1,xmm2 + jmp NEAR L$033loop_key256 +L$034done_key256: + mov ecx,13 + mov DWORD [16+edx],ecx +L$032good_key: + pxor xmm0,xmm0 + pxor xmm1,xmm1 + pxor xmm2,xmm2 + pxor xmm3,xmm3 + pxor xmm4,xmm4 + pxor xmm5,xmm5 + xor eax,eax + pop ebx + ret +align 4 +L$029bad_keybits: + pxor xmm0,xmm0 + mov eax,-2 + pop ebx + ret +align 64 +L$key_const: +dd 202313229,202313229,202313229,202313229 +dd 67569157,67569157,67569157,67569157 +dd 1,1,1,1 +dd 27,27,27,27 +db 65,69,83,32,102,111,114,32,73,110,116,101,108,32,65,69 +db 83,45,78,73,44,32,67,82,89,80,84,79,71,65,77,83 +db 32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115 +db 115,108,46,111,114,103,62,0 +%else +; Work around https://bugzilla.nasm.us/show_bug.cgi?id=3392738 +ret +%endif diff --git a/http/vendor/ring/pregenerated/aesni-x86-win32n.o b/http/vendor/ring/pregenerated/aesni-x86-win32n.o new file mode 100644 index 0000000..12f7b0f Binary files /dev/null and b/http/vendor/ring/pregenerated/aesni-x86-win32n.o differ diff --git a/http/vendor/ring/pregenerated/aesni-x86_64-elf.S b/http/vendor/ring/pregenerated/aesni-x86_64-elf.S new file mode 100644 index 0000000..3504d56 --- /dev/null +++ b/http/vendor/ring/pregenerated/aesni-x86_64-elf.S @@ -0,0 +1,1072 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__) +.text +.type _aesni_encrypt2,@function +.align 16 +_aesni_encrypt2: +.cfi_startproc + movups (%rcx),%xmm0 + shll $4,%eax + movups 16(%rcx),%xmm1 + xorps %xmm0,%xmm2 + xorps %xmm0,%xmm3 + movups 32(%rcx),%xmm0 + leaq 32(%rcx,%rax,1),%rcx + negq %rax + addq $16,%rax + +.Lenc_loop2: +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 + movups (%rcx,%rax,1),%xmm1 + addq $32,%rax +.byte 102,15,56,220,208 +.byte 102,15,56,220,216 + movups -16(%rcx,%rax,1),%xmm0 + jnz .Lenc_loop2 + +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 +.byte 102,15,56,221,208 +.byte 102,15,56,221,216 + ret +.cfi_endproc +.size _aesni_encrypt2,.-_aesni_encrypt2 +.type _aesni_encrypt3,@function +.align 16 +_aesni_encrypt3: +.cfi_startproc + movups (%rcx),%xmm0 + shll $4,%eax + movups 16(%rcx),%xmm1 + xorps %xmm0,%xmm2 + xorps %xmm0,%xmm3 + xorps %xmm0,%xmm4 + movups 32(%rcx),%xmm0 + leaq 32(%rcx,%rax,1),%rcx + negq %rax + addq $16,%rax + +.Lenc_loop3: +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 +.byte 102,15,56,220,225 + movups (%rcx,%rax,1),%xmm1 + addq $32,%rax +.byte 102,15,56,220,208 +.byte 102,15,56,220,216 +.byte 102,15,56,220,224 + movups -16(%rcx,%rax,1),%xmm0 + jnz .Lenc_loop3 + +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 +.byte 102,15,56,220,225 +.byte 102,15,56,221,208 +.byte 102,15,56,221,216 +.byte 102,15,56,221,224 + ret +.cfi_endproc +.size _aesni_encrypt3,.-_aesni_encrypt3 +.type _aesni_encrypt4,@function +.align 16 +_aesni_encrypt4: +.cfi_startproc + movups (%rcx),%xmm0 + shll $4,%eax + movups 16(%rcx),%xmm1 + xorps %xmm0,%xmm2 + xorps %xmm0,%xmm3 + xorps %xmm0,%xmm4 + xorps %xmm0,%xmm5 + movups 32(%rcx),%xmm0 + leaq 32(%rcx,%rax,1),%rcx + negq %rax +.byte 0x0f,0x1f,0x00 + addq $16,%rax + +.Lenc_loop4: +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 +.byte 102,15,56,220,225 +.byte 102,15,56,220,233 + movups (%rcx,%rax,1),%xmm1 + addq $32,%rax +.byte 102,15,56,220,208 +.byte 102,15,56,220,216 +.byte 102,15,56,220,224 +.byte 102,15,56,220,232 + movups -16(%rcx,%rax,1),%xmm0 + jnz .Lenc_loop4 + +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 +.byte 102,15,56,220,225 +.byte 102,15,56,220,233 +.byte 102,15,56,221,208 +.byte 102,15,56,221,216 +.byte 102,15,56,221,224 +.byte 102,15,56,221,232 + ret +.cfi_endproc +.size _aesni_encrypt4,.-_aesni_encrypt4 +.type _aesni_encrypt6,@function +.align 16 +_aesni_encrypt6: +.cfi_startproc + movups (%rcx),%xmm0 + shll $4,%eax + movups 16(%rcx),%xmm1 + xorps %xmm0,%xmm2 + pxor %xmm0,%xmm3 + pxor %xmm0,%xmm4 +.byte 102,15,56,220,209 + leaq 32(%rcx,%rax,1),%rcx + negq %rax +.byte 102,15,56,220,217 + pxor %xmm0,%xmm5 + pxor %xmm0,%xmm6 +.byte 102,15,56,220,225 + pxor %xmm0,%xmm7 + movups (%rcx,%rax,1),%xmm0 + addq $16,%rax + jmp .Lenc_loop6_enter +.align 16 +.Lenc_loop6: +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 +.byte 102,15,56,220,225 +.Lenc_loop6_enter: +.byte 102,15,56,220,233 +.byte 102,15,56,220,241 +.byte 102,15,56,220,249 + movups (%rcx,%rax,1),%xmm1 + addq $32,%rax +.byte 102,15,56,220,208 +.byte 102,15,56,220,216 +.byte 102,15,56,220,224 +.byte 102,15,56,220,232 +.byte 102,15,56,220,240 +.byte 102,15,56,220,248 + movups -16(%rcx,%rax,1),%xmm0 + jnz .Lenc_loop6 + +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 +.byte 102,15,56,220,225 +.byte 102,15,56,220,233 +.byte 102,15,56,220,241 +.byte 102,15,56,220,249 +.byte 102,15,56,221,208 +.byte 102,15,56,221,216 +.byte 102,15,56,221,224 +.byte 102,15,56,221,232 +.byte 102,15,56,221,240 +.byte 102,15,56,221,248 + ret +.cfi_endproc +.size _aesni_encrypt6,.-_aesni_encrypt6 +.type _aesni_encrypt8,@function +.align 16 +_aesni_encrypt8: +.cfi_startproc + movups (%rcx),%xmm0 + shll $4,%eax + movups 16(%rcx),%xmm1 + xorps %xmm0,%xmm2 + xorps %xmm0,%xmm3 + pxor %xmm0,%xmm4 + pxor %xmm0,%xmm5 + pxor %xmm0,%xmm6 + leaq 32(%rcx,%rax,1),%rcx + negq %rax +.byte 102,15,56,220,209 + pxor %xmm0,%xmm7 + pxor %xmm0,%xmm8 +.byte 102,15,56,220,217 + pxor %xmm0,%xmm9 + movups (%rcx,%rax,1),%xmm0 + addq $16,%rax + jmp .Lenc_loop8_inner +.align 16 +.Lenc_loop8: +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 +.Lenc_loop8_inner: +.byte 102,15,56,220,225 +.byte 102,15,56,220,233 +.byte 102,15,56,220,241 +.byte 102,15,56,220,249 +.byte 102,68,15,56,220,193 +.byte 102,68,15,56,220,201 +.Lenc_loop8_enter: + movups (%rcx,%rax,1),%xmm1 + addq $32,%rax +.byte 102,15,56,220,208 +.byte 102,15,56,220,216 +.byte 102,15,56,220,224 +.byte 102,15,56,220,232 +.byte 102,15,56,220,240 +.byte 102,15,56,220,248 +.byte 102,68,15,56,220,192 +.byte 102,68,15,56,220,200 + movups -16(%rcx,%rax,1),%xmm0 + jnz .Lenc_loop8 + +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 +.byte 102,15,56,220,225 +.byte 102,15,56,220,233 +.byte 102,15,56,220,241 +.byte 102,15,56,220,249 +.byte 102,68,15,56,220,193 +.byte 102,68,15,56,220,201 +.byte 102,15,56,221,208 +.byte 102,15,56,221,216 +.byte 102,15,56,221,224 +.byte 102,15,56,221,232 +.byte 102,15,56,221,240 +.byte 102,15,56,221,248 +.byte 102,68,15,56,221,192 +.byte 102,68,15,56,221,200 + ret +.cfi_endproc +.size _aesni_encrypt8,.-_aesni_encrypt8 +.globl aes_hw_ctr32_encrypt_blocks +.hidden aes_hw_ctr32_encrypt_blocks +.type aes_hw_ctr32_encrypt_blocks,@function +.align 16 +aes_hw_ctr32_encrypt_blocks: +.cfi_startproc +_CET_ENDBR +#ifdef BORINGSSL_DISPATCH_TEST + movb $1,BORINGSSL_function_hit(%rip) +#endif + cmpq $1,%rdx + jne .Lctr32_bulk + + + + movups (%r8),%xmm2 + movups (%rdi),%xmm3 + movl 240(%rcx),%edx + movups (%rcx),%xmm0 + movups 16(%rcx),%xmm1 + leaq 32(%rcx),%rcx + xorps %xmm0,%xmm2 +.Loop_enc1_1: +.byte 102,15,56,220,209 + decl %edx + movups (%rcx),%xmm1 + leaq 16(%rcx),%rcx + jnz .Loop_enc1_1 +.byte 102,15,56,221,209 + pxor %xmm0,%xmm0 + pxor %xmm1,%xmm1 + xorps %xmm3,%xmm2 + pxor %xmm3,%xmm3 + movups %xmm2,(%rsi) + xorps %xmm2,%xmm2 + jmp .Lctr32_epilogue + +.align 16 +.Lctr32_bulk: + leaq (%rsp),%r11 +.cfi_def_cfa_register %r11 + pushq %rbp +.cfi_offset %rbp,-16 + subq $128,%rsp + andq $-16,%rsp + + + + + movdqu (%r8),%xmm2 + movdqu (%rcx),%xmm0 + movl 12(%r8),%r8d + pxor %xmm0,%xmm2 + movl 12(%rcx),%ebp + movdqa %xmm2,0(%rsp) + bswapl %r8d + movdqa %xmm2,%xmm3 + movdqa %xmm2,%xmm4 + movdqa %xmm2,%xmm5 + movdqa %xmm2,64(%rsp) + movdqa %xmm2,80(%rsp) + movdqa %xmm2,96(%rsp) + movq %rdx,%r10 + movdqa %xmm2,112(%rsp) + + leaq 1(%r8),%rax + leaq 2(%r8),%rdx + bswapl %eax + bswapl %edx + xorl %ebp,%eax + xorl %ebp,%edx +.byte 102,15,58,34,216,3 + leaq 3(%r8),%rax + movdqa %xmm3,16(%rsp) +.byte 102,15,58,34,226,3 + bswapl %eax + movq %r10,%rdx + leaq 4(%r8),%r10 + movdqa %xmm4,32(%rsp) + xorl %ebp,%eax + bswapl %r10d +.byte 102,15,58,34,232,3 + xorl %ebp,%r10d + movdqa %xmm5,48(%rsp) + leaq 5(%r8),%r9 + movl %r10d,64+12(%rsp) + bswapl %r9d + leaq 6(%r8),%r10 + movl 240(%rcx),%eax + xorl %ebp,%r9d + bswapl %r10d + movl %r9d,80+12(%rsp) + xorl %ebp,%r10d + leaq 7(%r8),%r9 + movl %r10d,96+12(%rsp) + bswapl %r9d + xorl %ebp,%r9d + movl %r9d,112+12(%rsp) + + movups 16(%rcx),%xmm1 + + movdqa 64(%rsp),%xmm6 + movdqa 80(%rsp),%xmm7 + + cmpq $8,%rdx + jb .Lctr32_tail + + leaq 128(%rcx),%rcx + subq $8,%rdx + jmp .Lctr32_loop8 + +.align 32 +.Lctr32_loop8: + addl $8,%r8d + movdqa 96(%rsp),%xmm8 +.byte 102,15,56,220,209 + movl %r8d,%r9d + movdqa 112(%rsp),%xmm9 +.byte 102,15,56,220,217 + bswapl %r9d + movups 32-128(%rcx),%xmm0 +.byte 102,15,56,220,225 + xorl %ebp,%r9d + nop +.byte 102,15,56,220,233 + movl %r9d,0+12(%rsp) + leaq 1(%r8),%r9 +.byte 102,15,56,220,241 +.byte 102,15,56,220,249 +.byte 102,68,15,56,220,193 +.byte 102,68,15,56,220,201 + movups 48-128(%rcx),%xmm1 + bswapl %r9d +.byte 102,15,56,220,208 +.byte 102,15,56,220,216 + xorl %ebp,%r9d +.byte 0x66,0x90 +.byte 102,15,56,220,224 +.byte 102,15,56,220,232 + movl %r9d,16+12(%rsp) + leaq 2(%r8),%r9 +.byte 102,15,56,220,240 +.byte 102,15,56,220,248 +.byte 102,68,15,56,220,192 +.byte 102,68,15,56,220,200 + movups 64-128(%rcx),%xmm0 + bswapl %r9d +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 + xorl %ebp,%r9d +.byte 0x66,0x90 +.byte 102,15,56,220,225 +.byte 102,15,56,220,233 + movl %r9d,32+12(%rsp) + leaq 3(%r8),%r9 +.byte 102,15,56,220,241 +.byte 102,15,56,220,249 +.byte 102,68,15,56,220,193 +.byte 102,68,15,56,220,201 + movups 80-128(%rcx),%xmm1 + bswapl %r9d +.byte 102,15,56,220,208 +.byte 102,15,56,220,216 + xorl %ebp,%r9d +.byte 0x66,0x90 +.byte 102,15,56,220,224 +.byte 102,15,56,220,232 + movl %r9d,48+12(%rsp) + leaq 4(%r8),%r9 +.byte 102,15,56,220,240 +.byte 102,15,56,220,248 +.byte 102,68,15,56,220,192 +.byte 102,68,15,56,220,200 + movups 96-128(%rcx),%xmm0 + bswapl %r9d +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 + xorl %ebp,%r9d +.byte 0x66,0x90 +.byte 102,15,56,220,225 +.byte 102,15,56,220,233 + movl %r9d,64+12(%rsp) + leaq 5(%r8),%r9 +.byte 102,15,56,220,241 +.byte 102,15,56,220,249 +.byte 102,68,15,56,220,193 +.byte 102,68,15,56,220,201 + movups 112-128(%rcx),%xmm1 + bswapl %r9d +.byte 102,15,56,220,208 +.byte 102,15,56,220,216 + xorl %ebp,%r9d +.byte 0x66,0x90 +.byte 102,15,56,220,224 +.byte 102,15,56,220,232 + movl %r9d,80+12(%rsp) + leaq 6(%r8),%r9 +.byte 102,15,56,220,240 +.byte 102,15,56,220,248 +.byte 102,68,15,56,220,192 +.byte 102,68,15,56,220,200 + movups 128-128(%rcx),%xmm0 + bswapl %r9d +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 + xorl %ebp,%r9d +.byte 0x66,0x90 +.byte 102,15,56,220,225 +.byte 102,15,56,220,233 + movl %r9d,96+12(%rsp) + leaq 7(%r8),%r9 +.byte 102,15,56,220,241 +.byte 102,15,56,220,249 +.byte 102,68,15,56,220,193 +.byte 102,68,15,56,220,201 + movups 144-128(%rcx),%xmm1 + bswapl %r9d +.byte 102,15,56,220,208 +.byte 102,15,56,220,216 +.byte 102,15,56,220,224 + xorl %ebp,%r9d + movdqu 0(%rdi),%xmm10 +.byte 102,15,56,220,232 + movl %r9d,112+12(%rsp) + cmpl $11,%eax +.byte 102,15,56,220,240 +.byte 102,15,56,220,248 +.byte 102,68,15,56,220,192 +.byte 102,68,15,56,220,200 + movups 160-128(%rcx),%xmm0 + + jb .Lctr32_enc_done + +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 +.byte 102,15,56,220,225 +.byte 102,15,56,220,233 +.byte 102,15,56,220,241 +.byte 102,15,56,220,249 +.byte 102,68,15,56,220,193 +.byte 102,68,15,56,220,201 + movups 176-128(%rcx),%xmm1 + +.byte 102,15,56,220,208 +.byte 102,15,56,220,216 +.byte 102,15,56,220,224 +.byte 102,15,56,220,232 +.byte 102,15,56,220,240 +.byte 102,15,56,220,248 +.byte 102,68,15,56,220,192 +.byte 102,68,15,56,220,200 + movups 192-128(%rcx),%xmm0 + + +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 +.byte 102,15,56,220,225 +.byte 102,15,56,220,233 +.byte 102,15,56,220,241 +.byte 102,15,56,220,249 +.byte 102,68,15,56,220,193 +.byte 102,68,15,56,220,201 + movups 208-128(%rcx),%xmm1 + +.byte 102,15,56,220,208 +.byte 102,15,56,220,216 +.byte 102,15,56,220,224 +.byte 102,15,56,220,232 +.byte 102,15,56,220,240 +.byte 102,15,56,220,248 +.byte 102,68,15,56,220,192 +.byte 102,68,15,56,220,200 + movups 224-128(%rcx),%xmm0 + jmp .Lctr32_enc_done + +.align 16 +.Lctr32_enc_done: + movdqu 16(%rdi),%xmm11 + pxor %xmm0,%xmm10 + movdqu 32(%rdi),%xmm12 + pxor %xmm0,%xmm11 + movdqu 48(%rdi),%xmm13 + pxor %xmm0,%xmm12 + movdqu 64(%rdi),%xmm14 + pxor %xmm0,%xmm13 + movdqu 80(%rdi),%xmm15 + pxor %xmm0,%xmm14 + prefetcht0 448(%rdi) + prefetcht0 512(%rdi) + pxor %xmm0,%xmm15 +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 +.byte 102,15,56,220,225 +.byte 102,15,56,220,233 +.byte 102,15,56,220,241 +.byte 102,15,56,220,249 +.byte 102,68,15,56,220,193 +.byte 102,68,15,56,220,201 + movdqu 96(%rdi),%xmm1 + leaq 128(%rdi),%rdi + +.byte 102,65,15,56,221,210 + pxor %xmm0,%xmm1 + movdqu 112-128(%rdi),%xmm10 +.byte 102,65,15,56,221,219 + pxor %xmm0,%xmm10 + movdqa 0(%rsp),%xmm11 +.byte 102,65,15,56,221,228 +.byte 102,65,15,56,221,237 + movdqa 16(%rsp),%xmm12 + movdqa 32(%rsp),%xmm13 +.byte 102,65,15,56,221,246 +.byte 102,65,15,56,221,255 + movdqa 48(%rsp),%xmm14 + movdqa 64(%rsp),%xmm15 +.byte 102,68,15,56,221,193 + movdqa 80(%rsp),%xmm0 + movups 16-128(%rcx),%xmm1 +.byte 102,69,15,56,221,202 + + movups %xmm2,(%rsi) + movdqa %xmm11,%xmm2 + movups %xmm3,16(%rsi) + movdqa %xmm12,%xmm3 + movups %xmm4,32(%rsi) + movdqa %xmm13,%xmm4 + movups %xmm5,48(%rsi) + movdqa %xmm14,%xmm5 + movups %xmm6,64(%rsi) + movdqa %xmm15,%xmm6 + movups %xmm7,80(%rsi) + movdqa %xmm0,%xmm7 + movups %xmm8,96(%rsi) + movups %xmm9,112(%rsi) + leaq 128(%rsi),%rsi + + subq $8,%rdx + jnc .Lctr32_loop8 + + addq $8,%rdx + jz .Lctr32_done + leaq -128(%rcx),%rcx + +.Lctr32_tail: + + + leaq 16(%rcx),%rcx + cmpq $4,%rdx + jb .Lctr32_loop3 + je .Lctr32_loop4 + + + shll $4,%eax + movdqa 96(%rsp),%xmm8 + pxor %xmm9,%xmm9 + + movups 16(%rcx),%xmm0 +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 + leaq 32-16(%rcx,%rax,1),%rcx + negq %rax +.byte 102,15,56,220,225 + addq $16,%rax + movups (%rdi),%xmm10 +.byte 102,15,56,220,233 +.byte 102,15,56,220,241 + movups 16(%rdi),%xmm11 + movups 32(%rdi),%xmm12 +.byte 102,15,56,220,249 +.byte 102,68,15,56,220,193 + + call .Lenc_loop8_enter + + movdqu 48(%rdi),%xmm13 + pxor %xmm10,%xmm2 + movdqu 64(%rdi),%xmm10 + pxor %xmm11,%xmm3 + movdqu %xmm2,(%rsi) + pxor %xmm12,%xmm4 + movdqu %xmm3,16(%rsi) + pxor %xmm13,%xmm5 + movdqu %xmm4,32(%rsi) + pxor %xmm10,%xmm6 + movdqu %xmm5,48(%rsi) + movdqu %xmm6,64(%rsi) + cmpq $6,%rdx + jb .Lctr32_done + + movups 80(%rdi),%xmm11 + xorps %xmm11,%xmm7 + movups %xmm7,80(%rsi) + je .Lctr32_done + + movups 96(%rdi),%xmm12 + xorps %xmm12,%xmm8 + movups %xmm8,96(%rsi) + jmp .Lctr32_done + +.align 32 +.Lctr32_loop4: +.byte 102,15,56,220,209 + leaq 16(%rcx),%rcx + decl %eax +.byte 102,15,56,220,217 +.byte 102,15,56,220,225 +.byte 102,15,56,220,233 + movups (%rcx),%xmm1 + jnz .Lctr32_loop4 +.byte 102,15,56,221,209 +.byte 102,15,56,221,217 + movups (%rdi),%xmm10 + movups 16(%rdi),%xmm11 +.byte 102,15,56,221,225 +.byte 102,15,56,221,233 + movups 32(%rdi),%xmm12 + movups 48(%rdi),%xmm13 + + xorps %xmm10,%xmm2 + movups %xmm2,(%rsi) + xorps %xmm11,%xmm3 + movups %xmm3,16(%rsi) + pxor %xmm12,%xmm4 + movdqu %xmm4,32(%rsi) + pxor %xmm13,%xmm5 + movdqu %xmm5,48(%rsi) + jmp .Lctr32_done + +.align 32 +.Lctr32_loop3: +.byte 102,15,56,220,209 + leaq 16(%rcx),%rcx + decl %eax +.byte 102,15,56,220,217 +.byte 102,15,56,220,225 + movups (%rcx),%xmm1 + jnz .Lctr32_loop3 +.byte 102,15,56,221,209 +.byte 102,15,56,221,217 +.byte 102,15,56,221,225 + + movups (%rdi),%xmm10 + xorps %xmm10,%xmm2 + movups %xmm2,(%rsi) + cmpq $2,%rdx + jb .Lctr32_done + + movups 16(%rdi),%xmm11 + xorps %xmm11,%xmm3 + movups %xmm3,16(%rsi) + je .Lctr32_done + + movups 32(%rdi),%xmm12 + xorps %xmm12,%xmm4 + movups %xmm4,32(%rsi) + +.Lctr32_done: + xorps %xmm0,%xmm0 + xorl %ebp,%ebp + pxor %xmm1,%xmm1 + pxor %xmm2,%xmm2 + pxor %xmm3,%xmm3 + pxor %xmm4,%xmm4 + pxor %xmm5,%xmm5 + pxor %xmm6,%xmm6 + pxor %xmm7,%xmm7 + movaps %xmm0,0(%rsp) + pxor %xmm8,%xmm8 + movaps %xmm0,16(%rsp) + pxor %xmm9,%xmm9 + movaps %xmm0,32(%rsp) + pxor %xmm10,%xmm10 + movaps %xmm0,48(%rsp) + pxor %xmm11,%xmm11 + movaps %xmm0,64(%rsp) + pxor %xmm12,%xmm12 + movaps %xmm0,80(%rsp) + pxor %xmm13,%xmm13 + movaps %xmm0,96(%rsp) + pxor %xmm14,%xmm14 + movaps %xmm0,112(%rsp) + pxor %xmm15,%xmm15 + movq -8(%r11),%rbp +.cfi_restore %rbp + leaq (%r11),%rsp +.cfi_def_cfa_register %rsp +.Lctr32_epilogue: + ret +.cfi_endproc +.size aes_hw_ctr32_encrypt_blocks,.-aes_hw_ctr32_encrypt_blocks +.globl aes_hw_set_encrypt_key_base +.hidden aes_hw_set_encrypt_key_base +.type aes_hw_set_encrypt_key_base,@function +.align 16 +aes_hw_set_encrypt_key_base: +.cfi_startproc + +_CET_ENDBR +#ifdef BORINGSSL_DISPATCH_TEST + movb $1,BORINGSSL_function_hit+3(%rip) +#endif + subq $8,%rsp +.cfi_adjust_cfa_offset 8 + + + movups (%rdi),%xmm0 + xorps %xmm4,%xmm4 + leaq 16(%rdx),%rax + cmpl $256,%esi + je .L14rounds + + + cmpl $128,%esi + jne .Lbad_keybits + +.L10rounds: + movl $9,%esi + + movups %xmm0,(%rdx) +.byte 102,15,58,223,200,1 + call .Lkey_expansion_128_cold +.byte 102,15,58,223,200,2 + call .Lkey_expansion_128 +.byte 102,15,58,223,200,4 + call .Lkey_expansion_128 +.byte 102,15,58,223,200,8 + call .Lkey_expansion_128 +.byte 102,15,58,223,200,16 + call .Lkey_expansion_128 +.byte 102,15,58,223,200,32 + call .Lkey_expansion_128 +.byte 102,15,58,223,200,64 + call .Lkey_expansion_128 +.byte 102,15,58,223,200,128 + call .Lkey_expansion_128 +.byte 102,15,58,223,200,27 + call .Lkey_expansion_128 +.byte 102,15,58,223,200,54 + call .Lkey_expansion_128 + movups %xmm0,(%rax) + movl %esi,80(%rax) + xorl %eax,%eax + jmp .Lenc_key_ret + + + +.align 16 +.L14rounds: + movups 16(%rdi),%xmm2 + movl $13,%esi + leaq 16(%rax),%rax + + movups %xmm0,(%rdx) + movups %xmm2,16(%rdx) +.byte 102,15,58,223,202,1 + call .Lkey_expansion_256a_cold +.byte 102,15,58,223,200,1 + call .Lkey_expansion_256b +.byte 102,15,58,223,202,2 + call .Lkey_expansion_256a +.byte 102,15,58,223,200,2 + call .Lkey_expansion_256b +.byte 102,15,58,223,202,4 + call .Lkey_expansion_256a +.byte 102,15,58,223,200,4 + call .Lkey_expansion_256b +.byte 102,15,58,223,202,8 + call .Lkey_expansion_256a +.byte 102,15,58,223,200,8 + call .Lkey_expansion_256b +.byte 102,15,58,223,202,16 + call .Lkey_expansion_256a +.byte 102,15,58,223,200,16 + call .Lkey_expansion_256b +.byte 102,15,58,223,202,32 + call .Lkey_expansion_256a +.byte 102,15,58,223,200,32 + call .Lkey_expansion_256b +.byte 102,15,58,223,202,64 + call .Lkey_expansion_256a + movups %xmm0,(%rax) + movl %esi,16(%rax) + xorq %rax,%rax + jmp .Lenc_key_ret + +.align 16 +.Lbad_keybits: + movq $-2,%rax +.Lenc_key_ret: + pxor %xmm0,%xmm0 + pxor %xmm1,%xmm1 + pxor %xmm2,%xmm2 + pxor %xmm3,%xmm3 + pxor %xmm4,%xmm4 + pxor %xmm5,%xmm5 + addq $8,%rsp +.cfi_adjust_cfa_offset -8 + ret +.cfi_endproc + + +.align 16 +.Lkey_expansion_128: +.cfi_startproc + movups %xmm0,(%rax) + leaq 16(%rax),%rax +.Lkey_expansion_128_cold: + shufps $16,%xmm0,%xmm4 + xorps %xmm4,%xmm0 + shufps $140,%xmm0,%xmm4 + xorps %xmm4,%xmm0 + shufps $255,%xmm1,%xmm1 + xorps %xmm1,%xmm0 + ret +.cfi_endproc + +.align 16 +.Lkey_expansion_256a: +.cfi_startproc + movups %xmm2,(%rax) + leaq 16(%rax),%rax +.Lkey_expansion_256a_cold: + shufps $16,%xmm0,%xmm4 + xorps %xmm4,%xmm0 + shufps $140,%xmm0,%xmm4 + xorps %xmm4,%xmm0 + shufps $255,%xmm1,%xmm1 + xorps %xmm1,%xmm0 + ret +.cfi_endproc + +.align 16 +.Lkey_expansion_256b: +.cfi_startproc + movups %xmm0,(%rax) + leaq 16(%rax),%rax + + shufps $16,%xmm2,%xmm4 + xorps %xmm4,%xmm2 + shufps $140,%xmm2,%xmm4 + xorps %xmm4,%xmm2 + shufps $170,%xmm1,%xmm1 + xorps %xmm1,%xmm2 + ret +.cfi_endproc +.size aes_hw_set_encrypt_key_base,.-aes_hw_set_encrypt_key_base + +.globl aes_hw_set_encrypt_key_alt +.hidden aes_hw_set_encrypt_key_alt +.type aes_hw_set_encrypt_key_alt,@function +.align 16 +aes_hw_set_encrypt_key_alt: +.cfi_startproc + +_CET_ENDBR +#ifdef BORINGSSL_DISPATCH_TEST + movb $1,BORINGSSL_function_hit+3(%rip) +#endif + subq $8,%rsp +.cfi_adjust_cfa_offset 8 + + + movups (%rdi),%xmm0 + xorps %xmm4,%xmm4 + leaq 16(%rdx),%rax + cmpl $256,%esi + je .L14rounds_alt + + cmpl $128,%esi + jne .Lbad_keybits_alt + + movl $9,%esi + movdqa .Lkey_rotate(%rip),%xmm5 + movl $8,%r10d + movdqa .Lkey_rcon1(%rip),%xmm4 + movdqa %xmm0,%xmm2 + movdqu %xmm0,(%rdx) + jmp .Loop_key128 + +.align 16 +.Loop_key128: +.byte 102,15,56,0,197 +.byte 102,15,56,221,196 + pslld $1,%xmm4 + leaq 16(%rax),%rax + + movdqa %xmm2,%xmm3 + pslldq $4,%xmm2 + pxor %xmm2,%xmm3 + pslldq $4,%xmm2 + pxor %xmm2,%xmm3 + pslldq $4,%xmm2 + pxor %xmm3,%xmm2 + + pxor %xmm2,%xmm0 + movdqu %xmm0,-16(%rax) + movdqa %xmm0,%xmm2 + + decl %r10d + jnz .Loop_key128 + + movdqa .Lkey_rcon1b(%rip),%xmm4 + +.byte 102,15,56,0,197 +.byte 102,15,56,221,196 + pslld $1,%xmm4 + + movdqa %xmm2,%xmm3 + pslldq $4,%xmm2 + pxor %xmm2,%xmm3 + pslldq $4,%xmm2 + pxor %xmm2,%xmm3 + pslldq $4,%xmm2 + pxor %xmm3,%xmm2 + + pxor %xmm2,%xmm0 + movdqu %xmm0,(%rax) + + movdqa %xmm0,%xmm2 +.byte 102,15,56,0,197 +.byte 102,15,56,221,196 + + movdqa %xmm2,%xmm3 + pslldq $4,%xmm2 + pxor %xmm2,%xmm3 + pslldq $4,%xmm2 + pxor %xmm2,%xmm3 + pslldq $4,%xmm2 + pxor %xmm3,%xmm2 + + pxor %xmm2,%xmm0 + movdqu %xmm0,16(%rax) + + movl %esi,96(%rax) + xorl %eax,%eax + jmp .Lenc_key_ret_alt + + + +.align 16 +.L14rounds_alt: + movups 16(%rdi),%xmm2 + movl $13,%esi + leaq 16(%rax),%rax + movdqa .Lkey_rotate(%rip),%xmm5 + movdqa .Lkey_rcon1(%rip),%xmm4 + movl $7,%r10d + movdqu %xmm0,0(%rdx) + movdqa %xmm2,%xmm1 + movdqu %xmm2,16(%rdx) + jmp .Loop_key256 + +.align 16 +.Loop_key256: +.byte 102,15,56,0,213 +.byte 102,15,56,221,212 + + movdqa %xmm0,%xmm3 + pslldq $4,%xmm0 + pxor %xmm0,%xmm3 + pslldq $4,%xmm0 + pxor %xmm0,%xmm3 + pslldq $4,%xmm0 + pxor %xmm3,%xmm0 + pslld $1,%xmm4 + + pxor %xmm2,%xmm0 + movdqu %xmm0,(%rax) + + decl %r10d + jz .Ldone_key256 + + pshufd $0xff,%xmm0,%xmm2 + pxor %xmm3,%xmm3 +.byte 102,15,56,221,211 + + movdqa %xmm1,%xmm3 + pslldq $4,%xmm1 + pxor %xmm1,%xmm3 + pslldq $4,%xmm1 + pxor %xmm1,%xmm3 + pslldq $4,%xmm1 + pxor %xmm3,%xmm1 + + pxor %xmm1,%xmm2 + movdqu %xmm2,16(%rax) + leaq 32(%rax),%rax + movdqa %xmm2,%xmm1 + + jmp .Loop_key256 + +.Ldone_key256: + movl %esi,16(%rax) + xorl %eax,%eax + jmp .Lenc_key_ret_alt + +.align 16 +.Lbad_keybits_alt: + movq $-2,%rax +.Lenc_key_ret_alt: + pxor %xmm0,%xmm0 + pxor %xmm1,%xmm1 + pxor %xmm2,%xmm2 + pxor %xmm3,%xmm3 + pxor %xmm4,%xmm4 + pxor %xmm5,%xmm5 + addq $8,%rsp +.cfi_adjust_cfa_offset -8 + ret +.cfi_endproc + +.size aes_hw_set_encrypt_key_alt,.-aes_hw_set_encrypt_key_alt +.section .rodata +.align 64 +.Lbswap_mask: +.byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 +.Lincrement32: +.long 6,6,6,0 +.Lincrement64: +.long 1,0,0,0 +.Lincrement1: +.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 +.Lkey_rotate: +.long 0x0c0f0e0d,0x0c0f0e0d,0x0c0f0e0d,0x0c0f0e0d +.Lkey_rotate192: +.long 0x04070605,0x04070605,0x04070605,0x04070605 +.Lkey_rcon1: +.long 1,1,1,1 +.Lkey_rcon1b: +.long 0x1b,0x1b,0x1b,0x1b + +.byte 65,69,83,32,102,111,114,32,73,110,116,101,108,32,65,69,83,45,78,73,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.align 64 +.text +#endif diff --git a/http/vendor/ring/pregenerated/aesni-x86_64-macosx.S b/http/vendor/ring/pregenerated/aesni-x86_64-macosx.S new file mode 100644 index 0000000..5737063 --- /dev/null +++ b/http/vendor/ring/pregenerated/aesni-x86_64-macosx.S @@ -0,0 +1,1072 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__) +.text + +.p2align 4 +_aesni_encrypt2: + + movups (%rcx),%xmm0 + shll $4,%eax + movups 16(%rcx),%xmm1 + xorps %xmm0,%xmm2 + xorps %xmm0,%xmm3 + movups 32(%rcx),%xmm0 + leaq 32(%rcx,%rax,1),%rcx + negq %rax + addq $16,%rax + +L$enc_loop2: +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 + movups (%rcx,%rax,1),%xmm1 + addq $32,%rax +.byte 102,15,56,220,208 +.byte 102,15,56,220,216 + movups -16(%rcx,%rax,1),%xmm0 + jnz L$enc_loop2 + +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 +.byte 102,15,56,221,208 +.byte 102,15,56,221,216 + ret + + + +.p2align 4 +_aesni_encrypt3: + + movups (%rcx),%xmm0 + shll $4,%eax + movups 16(%rcx),%xmm1 + xorps %xmm0,%xmm2 + xorps %xmm0,%xmm3 + xorps %xmm0,%xmm4 + movups 32(%rcx),%xmm0 + leaq 32(%rcx,%rax,1),%rcx + negq %rax + addq $16,%rax + +L$enc_loop3: +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 +.byte 102,15,56,220,225 + movups (%rcx,%rax,1),%xmm1 + addq $32,%rax +.byte 102,15,56,220,208 +.byte 102,15,56,220,216 +.byte 102,15,56,220,224 + movups -16(%rcx,%rax,1),%xmm0 + jnz L$enc_loop3 + +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 +.byte 102,15,56,220,225 +.byte 102,15,56,221,208 +.byte 102,15,56,221,216 +.byte 102,15,56,221,224 + ret + + + +.p2align 4 +_aesni_encrypt4: + + movups (%rcx),%xmm0 + shll $4,%eax + movups 16(%rcx),%xmm1 + xorps %xmm0,%xmm2 + xorps %xmm0,%xmm3 + xorps %xmm0,%xmm4 + xorps %xmm0,%xmm5 + movups 32(%rcx),%xmm0 + leaq 32(%rcx,%rax,1),%rcx + negq %rax +.byte 0x0f,0x1f,0x00 + addq $16,%rax + +L$enc_loop4: +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 +.byte 102,15,56,220,225 +.byte 102,15,56,220,233 + movups (%rcx,%rax,1),%xmm1 + addq $32,%rax +.byte 102,15,56,220,208 +.byte 102,15,56,220,216 +.byte 102,15,56,220,224 +.byte 102,15,56,220,232 + movups -16(%rcx,%rax,1),%xmm0 + jnz L$enc_loop4 + +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 +.byte 102,15,56,220,225 +.byte 102,15,56,220,233 +.byte 102,15,56,221,208 +.byte 102,15,56,221,216 +.byte 102,15,56,221,224 +.byte 102,15,56,221,232 + ret + + + +.p2align 4 +_aesni_encrypt6: + + movups (%rcx),%xmm0 + shll $4,%eax + movups 16(%rcx),%xmm1 + xorps %xmm0,%xmm2 + pxor %xmm0,%xmm3 + pxor %xmm0,%xmm4 +.byte 102,15,56,220,209 + leaq 32(%rcx,%rax,1),%rcx + negq %rax +.byte 102,15,56,220,217 + pxor %xmm0,%xmm5 + pxor %xmm0,%xmm6 +.byte 102,15,56,220,225 + pxor %xmm0,%xmm7 + movups (%rcx,%rax,1),%xmm0 + addq $16,%rax + jmp L$enc_loop6_enter +.p2align 4 +L$enc_loop6: +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 +.byte 102,15,56,220,225 +L$enc_loop6_enter: +.byte 102,15,56,220,233 +.byte 102,15,56,220,241 +.byte 102,15,56,220,249 + movups (%rcx,%rax,1),%xmm1 + addq $32,%rax +.byte 102,15,56,220,208 +.byte 102,15,56,220,216 +.byte 102,15,56,220,224 +.byte 102,15,56,220,232 +.byte 102,15,56,220,240 +.byte 102,15,56,220,248 + movups -16(%rcx,%rax,1),%xmm0 + jnz L$enc_loop6 + +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 +.byte 102,15,56,220,225 +.byte 102,15,56,220,233 +.byte 102,15,56,220,241 +.byte 102,15,56,220,249 +.byte 102,15,56,221,208 +.byte 102,15,56,221,216 +.byte 102,15,56,221,224 +.byte 102,15,56,221,232 +.byte 102,15,56,221,240 +.byte 102,15,56,221,248 + ret + + + +.p2align 4 +_aesni_encrypt8: + + movups (%rcx),%xmm0 + shll $4,%eax + movups 16(%rcx),%xmm1 + xorps %xmm0,%xmm2 + xorps %xmm0,%xmm3 + pxor %xmm0,%xmm4 + pxor %xmm0,%xmm5 + pxor %xmm0,%xmm6 + leaq 32(%rcx,%rax,1),%rcx + negq %rax +.byte 102,15,56,220,209 + pxor %xmm0,%xmm7 + pxor %xmm0,%xmm8 +.byte 102,15,56,220,217 + pxor %xmm0,%xmm9 + movups (%rcx,%rax,1),%xmm0 + addq $16,%rax + jmp L$enc_loop8_inner +.p2align 4 +L$enc_loop8: +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 +L$enc_loop8_inner: +.byte 102,15,56,220,225 +.byte 102,15,56,220,233 +.byte 102,15,56,220,241 +.byte 102,15,56,220,249 +.byte 102,68,15,56,220,193 +.byte 102,68,15,56,220,201 +L$enc_loop8_enter: + movups (%rcx,%rax,1),%xmm1 + addq $32,%rax +.byte 102,15,56,220,208 +.byte 102,15,56,220,216 +.byte 102,15,56,220,224 +.byte 102,15,56,220,232 +.byte 102,15,56,220,240 +.byte 102,15,56,220,248 +.byte 102,68,15,56,220,192 +.byte 102,68,15,56,220,200 + movups -16(%rcx,%rax,1),%xmm0 + jnz L$enc_loop8 + +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 +.byte 102,15,56,220,225 +.byte 102,15,56,220,233 +.byte 102,15,56,220,241 +.byte 102,15,56,220,249 +.byte 102,68,15,56,220,193 +.byte 102,68,15,56,220,201 +.byte 102,15,56,221,208 +.byte 102,15,56,221,216 +.byte 102,15,56,221,224 +.byte 102,15,56,221,232 +.byte 102,15,56,221,240 +.byte 102,15,56,221,248 +.byte 102,68,15,56,221,192 +.byte 102,68,15,56,221,200 + ret + + +.globl _aes_hw_ctr32_encrypt_blocks +.private_extern _aes_hw_ctr32_encrypt_blocks + +.p2align 4 +_aes_hw_ctr32_encrypt_blocks: + +_CET_ENDBR +#ifdef BORINGSSL_DISPATCH_TEST + movb $1,BORINGSSL_function_hit(%rip) +#endif + cmpq $1,%rdx + jne L$ctr32_bulk + + + + movups (%r8),%xmm2 + movups (%rdi),%xmm3 + movl 240(%rcx),%edx + movups (%rcx),%xmm0 + movups 16(%rcx),%xmm1 + leaq 32(%rcx),%rcx + xorps %xmm0,%xmm2 +L$oop_enc1_1: +.byte 102,15,56,220,209 + decl %edx + movups (%rcx),%xmm1 + leaq 16(%rcx),%rcx + jnz L$oop_enc1_1 +.byte 102,15,56,221,209 + pxor %xmm0,%xmm0 + pxor %xmm1,%xmm1 + xorps %xmm3,%xmm2 + pxor %xmm3,%xmm3 + movups %xmm2,(%rsi) + xorps %xmm2,%xmm2 + jmp L$ctr32_epilogue + +.p2align 4 +L$ctr32_bulk: + leaq (%rsp),%r11 + + pushq %rbp + + subq $128,%rsp + andq $-16,%rsp + + + + + movdqu (%r8),%xmm2 + movdqu (%rcx),%xmm0 + movl 12(%r8),%r8d + pxor %xmm0,%xmm2 + movl 12(%rcx),%ebp + movdqa %xmm2,0(%rsp) + bswapl %r8d + movdqa %xmm2,%xmm3 + movdqa %xmm2,%xmm4 + movdqa %xmm2,%xmm5 + movdqa %xmm2,64(%rsp) + movdqa %xmm2,80(%rsp) + movdqa %xmm2,96(%rsp) + movq %rdx,%r10 + movdqa %xmm2,112(%rsp) + + leaq 1(%r8),%rax + leaq 2(%r8),%rdx + bswapl %eax + bswapl %edx + xorl %ebp,%eax + xorl %ebp,%edx +.byte 102,15,58,34,216,3 + leaq 3(%r8),%rax + movdqa %xmm3,16(%rsp) +.byte 102,15,58,34,226,3 + bswapl %eax + movq %r10,%rdx + leaq 4(%r8),%r10 + movdqa %xmm4,32(%rsp) + xorl %ebp,%eax + bswapl %r10d +.byte 102,15,58,34,232,3 + xorl %ebp,%r10d + movdqa %xmm5,48(%rsp) + leaq 5(%r8),%r9 + movl %r10d,64+12(%rsp) + bswapl %r9d + leaq 6(%r8),%r10 + movl 240(%rcx),%eax + xorl %ebp,%r9d + bswapl %r10d + movl %r9d,80+12(%rsp) + xorl %ebp,%r10d + leaq 7(%r8),%r9 + movl %r10d,96+12(%rsp) + bswapl %r9d + xorl %ebp,%r9d + movl %r9d,112+12(%rsp) + + movups 16(%rcx),%xmm1 + + movdqa 64(%rsp),%xmm6 + movdqa 80(%rsp),%xmm7 + + cmpq $8,%rdx + jb L$ctr32_tail + + leaq 128(%rcx),%rcx + subq $8,%rdx + jmp L$ctr32_loop8 + +.p2align 5 +L$ctr32_loop8: + addl $8,%r8d + movdqa 96(%rsp),%xmm8 +.byte 102,15,56,220,209 + movl %r8d,%r9d + movdqa 112(%rsp),%xmm9 +.byte 102,15,56,220,217 + bswapl %r9d + movups 32-128(%rcx),%xmm0 +.byte 102,15,56,220,225 + xorl %ebp,%r9d + nop +.byte 102,15,56,220,233 + movl %r9d,0+12(%rsp) + leaq 1(%r8),%r9 +.byte 102,15,56,220,241 +.byte 102,15,56,220,249 +.byte 102,68,15,56,220,193 +.byte 102,68,15,56,220,201 + movups 48-128(%rcx),%xmm1 + bswapl %r9d +.byte 102,15,56,220,208 +.byte 102,15,56,220,216 + xorl %ebp,%r9d +.byte 0x66,0x90 +.byte 102,15,56,220,224 +.byte 102,15,56,220,232 + movl %r9d,16+12(%rsp) + leaq 2(%r8),%r9 +.byte 102,15,56,220,240 +.byte 102,15,56,220,248 +.byte 102,68,15,56,220,192 +.byte 102,68,15,56,220,200 + movups 64-128(%rcx),%xmm0 + bswapl %r9d +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 + xorl %ebp,%r9d +.byte 0x66,0x90 +.byte 102,15,56,220,225 +.byte 102,15,56,220,233 + movl %r9d,32+12(%rsp) + leaq 3(%r8),%r9 +.byte 102,15,56,220,241 +.byte 102,15,56,220,249 +.byte 102,68,15,56,220,193 +.byte 102,68,15,56,220,201 + movups 80-128(%rcx),%xmm1 + bswapl %r9d +.byte 102,15,56,220,208 +.byte 102,15,56,220,216 + xorl %ebp,%r9d +.byte 0x66,0x90 +.byte 102,15,56,220,224 +.byte 102,15,56,220,232 + movl %r9d,48+12(%rsp) + leaq 4(%r8),%r9 +.byte 102,15,56,220,240 +.byte 102,15,56,220,248 +.byte 102,68,15,56,220,192 +.byte 102,68,15,56,220,200 + movups 96-128(%rcx),%xmm0 + bswapl %r9d +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 + xorl %ebp,%r9d +.byte 0x66,0x90 +.byte 102,15,56,220,225 +.byte 102,15,56,220,233 + movl %r9d,64+12(%rsp) + leaq 5(%r8),%r9 +.byte 102,15,56,220,241 +.byte 102,15,56,220,249 +.byte 102,68,15,56,220,193 +.byte 102,68,15,56,220,201 + movups 112-128(%rcx),%xmm1 + bswapl %r9d +.byte 102,15,56,220,208 +.byte 102,15,56,220,216 + xorl %ebp,%r9d +.byte 0x66,0x90 +.byte 102,15,56,220,224 +.byte 102,15,56,220,232 + movl %r9d,80+12(%rsp) + leaq 6(%r8),%r9 +.byte 102,15,56,220,240 +.byte 102,15,56,220,248 +.byte 102,68,15,56,220,192 +.byte 102,68,15,56,220,200 + movups 128-128(%rcx),%xmm0 + bswapl %r9d +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 + xorl %ebp,%r9d +.byte 0x66,0x90 +.byte 102,15,56,220,225 +.byte 102,15,56,220,233 + movl %r9d,96+12(%rsp) + leaq 7(%r8),%r9 +.byte 102,15,56,220,241 +.byte 102,15,56,220,249 +.byte 102,68,15,56,220,193 +.byte 102,68,15,56,220,201 + movups 144-128(%rcx),%xmm1 + bswapl %r9d +.byte 102,15,56,220,208 +.byte 102,15,56,220,216 +.byte 102,15,56,220,224 + xorl %ebp,%r9d + movdqu 0(%rdi),%xmm10 +.byte 102,15,56,220,232 + movl %r9d,112+12(%rsp) + cmpl $11,%eax +.byte 102,15,56,220,240 +.byte 102,15,56,220,248 +.byte 102,68,15,56,220,192 +.byte 102,68,15,56,220,200 + movups 160-128(%rcx),%xmm0 + + jb L$ctr32_enc_done + +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 +.byte 102,15,56,220,225 +.byte 102,15,56,220,233 +.byte 102,15,56,220,241 +.byte 102,15,56,220,249 +.byte 102,68,15,56,220,193 +.byte 102,68,15,56,220,201 + movups 176-128(%rcx),%xmm1 + +.byte 102,15,56,220,208 +.byte 102,15,56,220,216 +.byte 102,15,56,220,224 +.byte 102,15,56,220,232 +.byte 102,15,56,220,240 +.byte 102,15,56,220,248 +.byte 102,68,15,56,220,192 +.byte 102,68,15,56,220,200 + movups 192-128(%rcx),%xmm0 + + +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 +.byte 102,15,56,220,225 +.byte 102,15,56,220,233 +.byte 102,15,56,220,241 +.byte 102,15,56,220,249 +.byte 102,68,15,56,220,193 +.byte 102,68,15,56,220,201 + movups 208-128(%rcx),%xmm1 + +.byte 102,15,56,220,208 +.byte 102,15,56,220,216 +.byte 102,15,56,220,224 +.byte 102,15,56,220,232 +.byte 102,15,56,220,240 +.byte 102,15,56,220,248 +.byte 102,68,15,56,220,192 +.byte 102,68,15,56,220,200 + movups 224-128(%rcx),%xmm0 + jmp L$ctr32_enc_done + +.p2align 4 +L$ctr32_enc_done: + movdqu 16(%rdi),%xmm11 + pxor %xmm0,%xmm10 + movdqu 32(%rdi),%xmm12 + pxor %xmm0,%xmm11 + movdqu 48(%rdi),%xmm13 + pxor %xmm0,%xmm12 + movdqu 64(%rdi),%xmm14 + pxor %xmm0,%xmm13 + movdqu 80(%rdi),%xmm15 + pxor %xmm0,%xmm14 + prefetcht0 448(%rdi) + prefetcht0 512(%rdi) + pxor %xmm0,%xmm15 +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 +.byte 102,15,56,220,225 +.byte 102,15,56,220,233 +.byte 102,15,56,220,241 +.byte 102,15,56,220,249 +.byte 102,68,15,56,220,193 +.byte 102,68,15,56,220,201 + movdqu 96(%rdi),%xmm1 + leaq 128(%rdi),%rdi + +.byte 102,65,15,56,221,210 + pxor %xmm0,%xmm1 + movdqu 112-128(%rdi),%xmm10 +.byte 102,65,15,56,221,219 + pxor %xmm0,%xmm10 + movdqa 0(%rsp),%xmm11 +.byte 102,65,15,56,221,228 +.byte 102,65,15,56,221,237 + movdqa 16(%rsp),%xmm12 + movdqa 32(%rsp),%xmm13 +.byte 102,65,15,56,221,246 +.byte 102,65,15,56,221,255 + movdqa 48(%rsp),%xmm14 + movdqa 64(%rsp),%xmm15 +.byte 102,68,15,56,221,193 + movdqa 80(%rsp),%xmm0 + movups 16-128(%rcx),%xmm1 +.byte 102,69,15,56,221,202 + + movups %xmm2,(%rsi) + movdqa %xmm11,%xmm2 + movups %xmm3,16(%rsi) + movdqa %xmm12,%xmm3 + movups %xmm4,32(%rsi) + movdqa %xmm13,%xmm4 + movups %xmm5,48(%rsi) + movdqa %xmm14,%xmm5 + movups %xmm6,64(%rsi) + movdqa %xmm15,%xmm6 + movups %xmm7,80(%rsi) + movdqa %xmm0,%xmm7 + movups %xmm8,96(%rsi) + movups %xmm9,112(%rsi) + leaq 128(%rsi),%rsi + + subq $8,%rdx + jnc L$ctr32_loop8 + + addq $8,%rdx + jz L$ctr32_done + leaq -128(%rcx),%rcx + +L$ctr32_tail: + + + leaq 16(%rcx),%rcx + cmpq $4,%rdx + jb L$ctr32_loop3 + je L$ctr32_loop4 + + + shll $4,%eax + movdqa 96(%rsp),%xmm8 + pxor %xmm9,%xmm9 + + movups 16(%rcx),%xmm0 +.byte 102,15,56,220,209 +.byte 102,15,56,220,217 + leaq 32-16(%rcx,%rax,1),%rcx + negq %rax +.byte 102,15,56,220,225 + addq $16,%rax + movups (%rdi),%xmm10 +.byte 102,15,56,220,233 +.byte 102,15,56,220,241 + movups 16(%rdi),%xmm11 + movups 32(%rdi),%xmm12 +.byte 102,15,56,220,249 +.byte 102,68,15,56,220,193 + + call L$enc_loop8_enter + + movdqu 48(%rdi),%xmm13 + pxor %xmm10,%xmm2 + movdqu 64(%rdi),%xmm10 + pxor %xmm11,%xmm3 + movdqu %xmm2,(%rsi) + pxor %xmm12,%xmm4 + movdqu %xmm3,16(%rsi) + pxor %xmm13,%xmm5 + movdqu %xmm4,32(%rsi) + pxor %xmm10,%xmm6 + movdqu %xmm5,48(%rsi) + movdqu %xmm6,64(%rsi) + cmpq $6,%rdx + jb L$ctr32_done + + movups 80(%rdi),%xmm11 + xorps %xmm11,%xmm7 + movups %xmm7,80(%rsi) + je L$ctr32_done + + movups 96(%rdi),%xmm12 + xorps %xmm12,%xmm8 + movups %xmm8,96(%rsi) + jmp L$ctr32_done + +.p2align 5 +L$ctr32_loop4: +.byte 102,15,56,220,209 + leaq 16(%rcx),%rcx + decl %eax +.byte 102,15,56,220,217 +.byte 102,15,56,220,225 +.byte 102,15,56,220,233 + movups (%rcx),%xmm1 + jnz L$ctr32_loop4 +.byte 102,15,56,221,209 +.byte 102,15,56,221,217 + movups (%rdi),%xmm10 + movups 16(%rdi),%xmm11 +.byte 102,15,56,221,225 +.byte 102,15,56,221,233 + movups 32(%rdi),%xmm12 + movups 48(%rdi),%xmm13 + + xorps %xmm10,%xmm2 + movups %xmm2,(%rsi) + xorps %xmm11,%xmm3 + movups %xmm3,16(%rsi) + pxor %xmm12,%xmm4 + movdqu %xmm4,32(%rsi) + pxor %xmm13,%xmm5 + movdqu %xmm5,48(%rsi) + jmp L$ctr32_done + +.p2align 5 +L$ctr32_loop3: +.byte 102,15,56,220,209 + leaq 16(%rcx),%rcx + decl %eax +.byte 102,15,56,220,217 +.byte 102,15,56,220,225 + movups (%rcx),%xmm1 + jnz L$ctr32_loop3 +.byte 102,15,56,221,209 +.byte 102,15,56,221,217 +.byte 102,15,56,221,225 + + movups (%rdi),%xmm10 + xorps %xmm10,%xmm2 + movups %xmm2,(%rsi) + cmpq $2,%rdx + jb L$ctr32_done + + movups 16(%rdi),%xmm11 + xorps %xmm11,%xmm3 + movups %xmm3,16(%rsi) + je L$ctr32_done + + movups 32(%rdi),%xmm12 + xorps %xmm12,%xmm4 + movups %xmm4,32(%rsi) + +L$ctr32_done: + xorps %xmm0,%xmm0 + xorl %ebp,%ebp + pxor %xmm1,%xmm1 + pxor %xmm2,%xmm2 + pxor %xmm3,%xmm3 + pxor %xmm4,%xmm4 + pxor %xmm5,%xmm5 + pxor %xmm6,%xmm6 + pxor %xmm7,%xmm7 + movaps %xmm0,0(%rsp) + pxor %xmm8,%xmm8 + movaps %xmm0,16(%rsp) + pxor %xmm9,%xmm9 + movaps %xmm0,32(%rsp) + pxor %xmm10,%xmm10 + movaps %xmm0,48(%rsp) + pxor %xmm11,%xmm11 + movaps %xmm0,64(%rsp) + pxor %xmm12,%xmm12 + movaps %xmm0,80(%rsp) + pxor %xmm13,%xmm13 + movaps %xmm0,96(%rsp) + pxor %xmm14,%xmm14 + movaps %xmm0,112(%rsp) + pxor %xmm15,%xmm15 + movq -8(%r11),%rbp + + leaq (%r11),%rsp + +L$ctr32_epilogue: + ret + + +.globl _aes_hw_set_encrypt_key_base +.private_extern _aes_hw_set_encrypt_key_base + +.p2align 4 +_aes_hw_set_encrypt_key_base: + + +_CET_ENDBR +#ifdef BORINGSSL_DISPATCH_TEST + movb $1,BORINGSSL_function_hit+3(%rip) +#endif + subq $8,%rsp + + + + movups (%rdi),%xmm0 + xorps %xmm4,%xmm4 + leaq 16(%rdx),%rax + cmpl $256,%esi + je L$14rounds + + + cmpl $128,%esi + jne L$bad_keybits + +L$10rounds: + movl $9,%esi + + movups %xmm0,(%rdx) +.byte 102,15,58,223,200,1 + call L$key_expansion_128_cold +.byte 102,15,58,223,200,2 + call L$key_expansion_128 +.byte 102,15,58,223,200,4 + call L$key_expansion_128 +.byte 102,15,58,223,200,8 + call L$key_expansion_128 +.byte 102,15,58,223,200,16 + call L$key_expansion_128 +.byte 102,15,58,223,200,32 + call L$key_expansion_128 +.byte 102,15,58,223,200,64 + call L$key_expansion_128 +.byte 102,15,58,223,200,128 + call L$key_expansion_128 +.byte 102,15,58,223,200,27 + call L$key_expansion_128 +.byte 102,15,58,223,200,54 + call L$key_expansion_128 + movups %xmm0,(%rax) + movl %esi,80(%rax) + xorl %eax,%eax + jmp L$enc_key_ret + + + +.p2align 4 +L$14rounds: + movups 16(%rdi),%xmm2 + movl $13,%esi + leaq 16(%rax),%rax + + movups %xmm0,(%rdx) + movups %xmm2,16(%rdx) +.byte 102,15,58,223,202,1 + call L$key_expansion_256a_cold +.byte 102,15,58,223,200,1 + call L$key_expansion_256b +.byte 102,15,58,223,202,2 + call L$key_expansion_256a +.byte 102,15,58,223,200,2 + call L$key_expansion_256b +.byte 102,15,58,223,202,4 + call L$key_expansion_256a +.byte 102,15,58,223,200,4 + call L$key_expansion_256b +.byte 102,15,58,223,202,8 + call L$key_expansion_256a +.byte 102,15,58,223,200,8 + call L$key_expansion_256b +.byte 102,15,58,223,202,16 + call L$key_expansion_256a +.byte 102,15,58,223,200,16 + call L$key_expansion_256b +.byte 102,15,58,223,202,32 + call L$key_expansion_256a +.byte 102,15,58,223,200,32 + call L$key_expansion_256b +.byte 102,15,58,223,202,64 + call L$key_expansion_256a + movups %xmm0,(%rax) + movl %esi,16(%rax) + xorq %rax,%rax + jmp L$enc_key_ret + +.p2align 4 +L$bad_keybits: + movq $-2,%rax +L$enc_key_ret: + pxor %xmm0,%xmm0 + pxor %xmm1,%xmm1 + pxor %xmm2,%xmm2 + pxor %xmm3,%xmm3 + pxor %xmm4,%xmm4 + pxor %xmm5,%xmm5 + addq $8,%rsp + + ret + + + +.p2align 4 +L$key_expansion_128: + + movups %xmm0,(%rax) + leaq 16(%rax),%rax +L$key_expansion_128_cold: + shufps $16,%xmm0,%xmm4 + xorps %xmm4,%xmm0 + shufps $140,%xmm0,%xmm4 + xorps %xmm4,%xmm0 + shufps $255,%xmm1,%xmm1 + xorps %xmm1,%xmm0 + ret + + +.p2align 4 +L$key_expansion_256a: + + movups %xmm2,(%rax) + leaq 16(%rax),%rax +L$key_expansion_256a_cold: + shufps $16,%xmm0,%xmm4 + xorps %xmm4,%xmm0 + shufps $140,%xmm0,%xmm4 + xorps %xmm4,%xmm0 + shufps $255,%xmm1,%xmm1 + xorps %xmm1,%xmm0 + ret + + +.p2align 4 +L$key_expansion_256b: + + movups %xmm0,(%rax) + leaq 16(%rax),%rax + + shufps $16,%xmm2,%xmm4 + xorps %xmm4,%xmm2 + shufps $140,%xmm2,%xmm4 + xorps %xmm4,%xmm2 + shufps $170,%xmm1,%xmm1 + xorps %xmm1,%xmm2 + ret + + + +.globl _aes_hw_set_encrypt_key_alt +.private_extern _aes_hw_set_encrypt_key_alt + +.p2align 4 +_aes_hw_set_encrypt_key_alt: + + +_CET_ENDBR +#ifdef BORINGSSL_DISPATCH_TEST + movb $1,BORINGSSL_function_hit+3(%rip) +#endif + subq $8,%rsp + + + + movups (%rdi),%xmm0 + xorps %xmm4,%xmm4 + leaq 16(%rdx),%rax + cmpl $256,%esi + je L$14rounds_alt + + cmpl $128,%esi + jne L$bad_keybits_alt + + movl $9,%esi + movdqa L$key_rotate(%rip),%xmm5 + movl $8,%r10d + movdqa L$key_rcon1(%rip),%xmm4 + movdqa %xmm0,%xmm2 + movdqu %xmm0,(%rdx) + jmp L$oop_key128 + +.p2align 4 +L$oop_key128: +.byte 102,15,56,0,197 +.byte 102,15,56,221,196 + pslld $1,%xmm4 + leaq 16(%rax),%rax + + movdqa %xmm2,%xmm3 + pslldq $4,%xmm2 + pxor %xmm2,%xmm3 + pslldq $4,%xmm2 + pxor %xmm2,%xmm3 + pslldq $4,%xmm2 + pxor %xmm3,%xmm2 + + pxor %xmm2,%xmm0 + movdqu %xmm0,-16(%rax) + movdqa %xmm0,%xmm2 + + decl %r10d + jnz L$oop_key128 + + movdqa L$key_rcon1b(%rip),%xmm4 + +.byte 102,15,56,0,197 +.byte 102,15,56,221,196 + pslld $1,%xmm4 + + movdqa %xmm2,%xmm3 + pslldq $4,%xmm2 + pxor %xmm2,%xmm3 + pslldq $4,%xmm2 + pxor %xmm2,%xmm3 + pslldq $4,%xmm2 + pxor %xmm3,%xmm2 + + pxor %xmm2,%xmm0 + movdqu %xmm0,(%rax) + + movdqa %xmm0,%xmm2 +.byte 102,15,56,0,197 +.byte 102,15,56,221,196 + + movdqa %xmm2,%xmm3 + pslldq $4,%xmm2 + pxor %xmm2,%xmm3 + pslldq $4,%xmm2 + pxor %xmm2,%xmm3 + pslldq $4,%xmm2 + pxor %xmm3,%xmm2 + + pxor %xmm2,%xmm0 + movdqu %xmm0,16(%rax) + + movl %esi,96(%rax) + xorl %eax,%eax + jmp L$enc_key_ret_alt + + + +.p2align 4 +L$14rounds_alt: + movups 16(%rdi),%xmm2 + movl $13,%esi + leaq 16(%rax),%rax + movdqa L$key_rotate(%rip),%xmm5 + movdqa L$key_rcon1(%rip),%xmm4 + movl $7,%r10d + movdqu %xmm0,0(%rdx) + movdqa %xmm2,%xmm1 + movdqu %xmm2,16(%rdx) + jmp L$oop_key256 + +.p2align 4 +L$oop_key256: +.byte 102,15,56,0,213 +.byte 102,15,56,221,212 + + movdqa %xmm0,%xmm3 + pslldq $4,%xmm0 + pxor %xmm0,%xmm3 + pslldq $4,%xmm0 + pxor %xmm0,%xmm3 + pslldq $4,%xmm0 + pxor %xmm3,%xmm0 + pslld $1,%xmm4 + + pxor %xmm2,%xmm0 + movdqu %xmm0,(%rax) + + decl %r10d + jz L$done_key256 + + pshufd $0xff,%xmm0,%xmm2 + pxor %xmm3,%xmm3 +.byte 102,15,56,221,211 + + movdqa %xmm1,%xmm3 + pslldq $4,%xmm1 + pxor %xmm1,%xmm3 + pslldq $4,%xmm1 + pxor %xmm1,%xmm3 + pslldq $4,%xmm1 + pxor %xmm3,%xmm1 + + pxor %xmm1,%xmm2 + movdqu %xmm2,16(%rax) + leaq 32(%rax),%rax + movdqa %xmm2,%xmm1 + + jmp L$oop_key256 + +L$done_key256: + movl %esi,16(%rax) + xorl %eax,%eax + jmp L$enc_key_ret_alt + +.p2align 4 +L$bad_keybits_alt: + movq $-2,%rax +L$enc_key_ret_alt: + pxor %xmm0,%xmm0 + pxor %xmm1,%xmm1 + pxor %xmm2,%xmm2 + pxor %xmm3,%xmm3 + pxor %xmm4,%xmm4 + pxor %xmm5,%xmm5 + addq $8,%rsp + + ret + + + +.section __DATA,__const +.p2align 6 +L$bswap_mask: +.byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 +L$increment32: +.long 6,6,6,0 +L$increment64: +.long 1,0,0,0 +L$increment1: +.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 +L$key_rotate: +.long 0x0c0f0e0d,0x0c0f0e0d,0x0c0f0e0d,0x0c0f0e0d +L$key_rotate192: +.long 0x04070605,0x04070605,0x04070605,0x04070605 +L$key_rcon1: +.long 1,1,1,1 +L$key_rcon1b: +.long 0x1b,0x1b,0x1b,0x1b + +.byte 65,69,83,32,102,111,114,32,73,110,116,101,108,32,65,69,83,45,78,73,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.p2align 6 +.text +#endif diff --git a/http/vendor/ring/pregenerated/aesni-x86_64-nasm.asm b/http/vendor/ring/pregenerated/aesni-x86_64-nasm.asm new file mode 100644 index 0000000..ceeec55 --- /dev/null +++ b/http/vendor/ring/pregenerated/aesni-x86_64-nasm.asm @@ -0,0 +1,1242 @@ +; This file is generated from a similarly-named Perl script in the BoringSSL +; source tree. Do not edit by hand. + +%ifidn __OUTPUT_FORMAT__, win64 +default rel +%define XMMWORD +%define YMMWORD +%define ZMMWORD +%define _CET_ENDBR + +%include "ring_core_generated/prefix_symbols_nasm.inc" +section .text code align=64 + + +ALIGN 16 +_aesni_encrypt2: + + movups xmm0,XMMWORD[rcx] + shl eax,4 + movups xmm1,XMMWORD[16+rcx] + xorps xmm2,xmm0 + xorps xmm3,xmm0 + movups xmm0,XMMWORD[32+rcx] + lea rcx,[32+rax*1+rcx] + neg rax + add rax,16 + +$L$enc_loop2: + DB 102,15,56,220,209 + DB 102,15,56,220,217 + movups xmm1,XMMWORD[rax*1+rcx] + add rax,32 + DB 102,15,56,220,208 + DB 102,15,56,220,216 + movups xmm0,XMMWORD[((-16))+rax*1+rcx] + jnz NEAR $L$enc_loop2 + + DB 102,15,56,220,209 + DB 102,15,56,220,217 + DB 102,15,56,221,208 + DB 102,15,56,221,216 + ret + + + +ALIGN 16 +_aesni_encrypt3: + + movups xmm0,XMMWORD[rcx] + shl eax,4 + movups xmm1,XMMWORD[16+rcx] + xorps xmm2,xmm0 + xorps xmm3,xmm0 + xorps xmm4,xmm0 + movups xmm0,XMMWORD[32+rcx] + lea rcx,[32+rax*1+rcx] + neg rax + add rax,16 + +$L$enc_loop3: + DB 102,15,56,220,209 + DB 102,15,56,220,217 + DB 102,15,56,220,225 + movups xmm1,XMMWORD[rax*1+rcx] + add rax,32 + DB 102,15,56,220,208 + DB 102,15,56,220,216 + DB 102,15,56,220,224 + movups xmm0,XMMWORD[((-16))+rax*1+rcx] + jnz NEAR $L$enc_loop3 + + DB 102,15,56,220,209 + DB 102,15,56,220,217 + DB 102,15,56,220,225 + DB 102,15,56,221,208 + DB 102,15,56,221,216 + DB 102,15,56,221,224 + ret + + + +ALIGN 16 +_aesni_encrypt4: + + movups xmm0,XMMWORD[rcx] + shl eax,4 + movups xmm1,XMMWORD[16+rcx] + xorps xmm2,xmm0 + xorps xmm3,xmm0 + xorps xmm4,xmm0 + xorps xmm5,xmm0 + movups xmm0,XMMWORD[32+rcx] + lea rcx,[32+rax*1+rcx] + neg rax + DB 0x0f,0x1f,0x00 + add rax,16 + +$L$enc_loop4: + DB 102,15,56,220,209 + DB 102,15,56,220,217 + DB 102,15,56,220,225 + DB 102,15,56,220,233 + movups xmm1,XMMWORD[rax*1+rcx] + add rax,32 + DB 102,15,56,220,208 + DB 102,15,56,220,216 + DB 102,15,56,220,224 + DB 102,15,56,220,232 + movups xmm0,XMMWORD[((-16))+rax*1+rcx] + jnz NEAR $L$enc_loop4 + + DB 102,15,56,220,209 + DB 102,15,56,220,217 + DB 102,15,56,220,225 + DB 102,15,56,220,233 + DB 102,15,56,221,208 + DB 102,15,56,221,216 + DB 102,15,56,221,224 + DB 102,15,56,221,232 + ret + + + +ALIGN 16 +_aesni_encrypt6: + + movups xmm0,XMMWORD[rcx] + shl eax,4 + movups xmm1,XMMWORD[16+rcx] + xorps xmm2,xmm0 + pxor xmm3,xmm0 + pxor xmm4,xmm0 + DB 102,15,56,220,209 + lea rcx,[32+rax*1+rcx] + neg rax + DB 102,15,56,220,217 + pxor xmm5,xmm0 + pxor xmm6,xmm0 + DB 102,15,56,220,225 + pxor xmm7,xmm0 + movups xmm0,XMMWORD[rax*1+rcx] + add rax,16 + jmp NEAR $L$enc_loop6_enter +ALIGN 16 +$L$enc_loop6: + DB 102,15,56,220,209 + DB 102,15,56,220,217 + DB 102,15,56,220,225 +$L$enc_loop6_enter: + DB 102,15,56,220,233 + DB 102,15,56,220,241 + DB 102,15,56,220,249 + movups xmm1,XMMWORD[rax*1+rcx] + add rax,32 + DB 102,15,56,220,208 + DB 102,15,56,220,216 + DB 102,15,56,220,224 + DB 102,15,56,220,232 + DB 102,15,56,220,240 + DB 102,15,56,220,248 + movups xmm0,XMMWORD[((-16))+rax*1+rcx] + jnz NEAR $L$enc_loop6 + + DB 102,15,56,220,209 + DB 102,15,56,220,217 + DB 102,15,56,220,225 + DB 102,15,56,220,233 + DB 102,15,56,220,241 + DB 102,15,56,220,249 + DB 102,15,56,221,208 + DB 102,15,56,221,216 + DB 102,15,56,221,224 + DB 102,15,56,221,232 + DB 102,15,56,221,240 + DB 102,15,56,221,248 + ret + + + +ALIGN 16 +_aesni_encrypt8: + + movups xmm0,XMMWORD[rcx] + shl eax,4 + movups xmm1,XMMWORD[16+rcx] + xorps xmm2,xmm0 + xorps xmm3,xmm0 + pxor xmm4,xmm0 + pxor xmm5,xmm0 + pxor xmm6,xmm0 + lea rcx,[32+rax*1+rcx] + neg rax + DB 102,15,56,220,209 + pxor xmm7,xmm0 + pxor xmm8,xmm0 + DB 102,15,56,220,217 + pxor xmm9,xmm0 + movups xmm0,XMMWORD[rax*1+rcx] + add rax,16 + jmp NEAR $L$enc_loop8_inner +ALIGN 16 +$L$enc_loop8: + DB 102,15,56,220,209 + DB 102,15,56,220,217 +$L$enc_loop8_inner: + DB 102,15,56,220,225 + DB 102,15,56,220,233 + DB 102,15,56,220,241 + DB 102,15,56,220,249 + DB 102,68,15,56,220,193 + DB 102,68,15,56,220,201 +$L$enc_loop8_enter: + movups xmm1,XMMWORD[rax*1+rcx] + add rax,32 + DB 102,15,56,220,208 + DB 102,15,56,220,216 + DB 102,15,56,220,224 + DB 102,15,56,220,232 + DB 102,15,56,220,240 + DB 102,15,56,220,248 + DB 102,68,15,56,220,192 + DB 102,68,15,56,220,200 + movups xmm0,XMMWORD[((-16))+rax*1+rcx] + jnz NEAR $L$enc_loop8 + + DB 102,15,56,220,209 + DB 102,15,56,220,217 + DB 102,15,56,220,225 + DB 102,15,56,220,233 + DB 102,15,56,220,241 + DB 102,15,56,220,249 + DB 102,68,15,56,220,193 + DB 102,68,15,56,220,201 + DB 102,15,56,221,208 + DB 102,15,56,221,216 + DB 102,15,56,221,224 + DB 102,15,56,221,232 + DB 102,15,56,221,240 + DB 102,15,56,221,248 + DB 102,68,15,56,221,192 + DB 102,68,15,56,221,200 + ret + + +global aes_hw_ctr32_encrypt_blocks + +ALIGN 16 +aes_hw_ctr32_encrypt_blocks: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_aes_hw_ctr32_encrypt_blocks: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + mov rcx,r9 + mov r8,QWORD[40+rsp] + + + +_CET_ENDBR +%ifdef BORINGSSL_DISPATCH_TEST + mov BYTE[BORINGSSL_function_hit],1 +%endif + cmp rdx,1 + jne NEAR $L$ctr32_bulk + + + + movups xmm2,XMMWORD[r8] + movups xmm3,XMMWORD[rdi] + mov edx,DWORD[240+rcx] + movups xmm0,XMMWORD[rcx] + movups xmm1,XMMWORD[16+rcx] + lea rcx,[32+rcx] + xorps xmm2,xmm0 +$L$oop_enc1_1: + DB 102,15,56,220,209 + dec edx + movups xmm1,XMMWORD[rcx] + lea rcx,[16+rcx] + jnz NEAR $L$oop_enc1_1 + DB 102,15,56,221,209 + pxor xmm0,xmm0 + pxor xmm1,xmm1 + xorps xmm2,xmm3 + pxor xmm3,xmm3 + movups XMMWORD[rsi],xmm2 + xorps xmm2,xmm2 + jmp NEAR $L$ctr32_epilogue + +ALIGN 16 +$L$ctr32_bulk: + lea r11,[rsp] + + push rbp + + sub rsp,288 + and rsp,-16 + movaps XMMWORD[(-168)+r11],xmm6 + movaps XMMWORD[(-152)+r11],xmm7 + movaps XMMWORD[(-136)+r11],xmm8 + movaps XMMWORD[(-120)+r11],xmm9 + movaps XMMWORD[(-104)+r11],xmm10 + movaps XMMWORD[(-88)+r11],xmm11 + movaps XMMWORD[(-72)+r11],xmm12 + movaps XMMWORD[(-56)+r11],xmm13 + movaps XMMWORD[(-40)+r11],xmm14 + movaps XMMWORD[(-24)+r11],xmm15 +$L$ctr32_body: + + + + + movdqu xmm2,XMMWORD[r8] + movdqu xmm0,XMMWORD[rcx] + mov r8d,DWORD[12+r8] + pxor xmm2,xmm0 + mov ebp,DWORD[12+rcx] + movdqa XMMWORD[rsp],xmm2 + bswap r8d + movdqa xmm3,xmm2 + movdqa xmm4,xmm2 + movdqa xmm5,xmm2 + movdqa XMMWORD[64+rsp],xmm2 + movdqa XMMWORD[80+rsp],xmm2 + movdqa XMMWORD[96+rsp],xmm2 + mov r10,rdx + movdqa XMMWORD[112+rsp],xmm2 + + lea rax,[1+r8] + lea rdx,[2+r8] + bswap eax + bswap edx + xor eax,ebp + xor edx,ebp +DB 102,15,58,34,216,3 + lea rax,[3+r8] + movdqa XMMWORD[16+rsp],xmm3 +DB 102,15,58,34,226,3 + bswap eax + mov rdx,r10 + lea r10,[4+r8] + movdqa XMMWORD[32+rsp],xmm4 + xor eax,ebp + bswap r10d +DB 102,15,58,34,232,3 + xor r10d,ebp + movdqa XMMWORD[48+rsp],xmm5 + lea r9,[5+r8] + mov DWORD[((64+12))+rsp],r10d + bswap r9d + lea r10,[6+r8] + mov eax,DWORD[240+rcx] + xor r9d,ebp + bswap r10d + mov DWORD[((80+12))+rsp],r9d + xor r10d,ebp + lea r9,[7+r8] + mov DWORD[((96+12))+rsp],r10d + bswap r9d + xor r9d,ebp + mov DWORD[((112+12))+rsp],r9d + + movups xmm1,XMMWORD[16+rcx] + + movdqa xmm6,XMMWORD[64+rsp] + movdqa xmm7,XMMWORD[80+rsp] + + cmp rdx,8 + jb NEAR $L$ctr32_tail + + lea rcx,[128+rcx] + sub rdx,8 + jmp NEAR $L$ctr32_loop8 + +ALIGN 32 +$L$ctr32_loop8: + add r8d,8 + movdqa xmm8,XMMWORD[96+rsp] + DB 102,15,56,220,209 + mov r9d,r8d + movdqa xmm9,XMMWORD[112+rsp] + DB 102,15,56,220,217 + bswap r9d + movups xmm0,XMMWORD[((32-128))+rcx] + DB 102,15,56,220,225 + xor r9d,ebp + nop + DB 102,15,56,220,233 + mov DWORD[((0+12))+rsp],r9d + lea r9,[1+r8] + DB 102,15,56,220,241 + DB 102,15,56,220,249 + DB 102,68,15,56,220,193 + DB 102,68,15,56,220,201 + movups xmm1,XMMWORD[((48-128))+rcx] + bswap r9d + DB 102,15,56,220,208 + DB 102,15,56,220,216 + xor r9d,ebp + DB 0x66,0x90 + DB 102,15,56,220,224 + DB 102,15,56,220,232 + mov DWORD[((16+12))+rsp],r9d + lea r9,[2+r8] + DB 102,15,56,220,240 + DB 102,15,56,220,248 + DB 102,68,15,56,220,192 + DB 102,68,15,56,220,200 + movups xmm0,XMMWORD[((64-128))+rcx] + bswap r9d + DB 102,15,56,220,209 + DB 102,15,56,220,217 + xor r9d,ebp + DB 0x66,0x90 + DB 102,15,56,220,225 + DB 102,15,56,220,233 + mov DWORD[((32+12))+rsp],r9d + lea r9,[3+r8] + DB 102,15,56,220,241 + DB 102,15,56,220,249 + DB 102,68,15,56,220,193 + DB 102,68,15,56,220,201 + movups xmm1,XMMWORD[((80-128))+rcx] + bswap r9d + DB 102,15,56,220,208 + DB 102,15,56,220,216 + xor r9d,ebp + DB 0x66,0x90 + DB 102,15,56,220,224 + DB 102,15,56,220,232 + mov DWORD[((48+12))+rsp],r9d + lea r9,[4+r8] + DB 102,15,56,220,240 + DB 102,15,56,220,248 + DB 102,68,15,56,220,192 + DB 102,68,15,56,220,200 + movups xmm0,XMMWORD[((96-128))+rcx] + bswap r9d + DB 102,15,56,220,209 + DB 102,15,56,220,217 + xor r9d,ebp + DB 0x66,0x90 + DB 102,15,56,220,225 + DB 102,15,56,220,233 + mov DWORD[((64+12))+rsp],r9d + lea r9,[5+r8] + DB 102,15,56,220,241 + DB 102,15,56,220,249 + DB 102,68,15,56,220,193 + DB 102,68,15,56,220,201 + movups xmm1,XMMWORD[((112-128))+rcx] + bswap r9d + DB 102,15,56,220,208 + DB 102,15,56,220,216 + xor r9d,ebp + DB 0x66,0x90 + DB 102,15,56,220,224 + DB 102,15,56,220,232 + mov DWORD[((80+12))+rsp],r9d + lea r9,[6+r8] + DB 102,15,56,220,240 + DB 102,15,56,220,248 + DB 102,68,15,56,220,192 + DB 102,68,15,56,220,200 + movups xmm0,XMMWORD[((128-128))+rcx] + bswap r9d + DB 102,15,56,220,209 + DB 102,15,56,220,217 + xor r9d,ebp + DB 0x66,0x90 + DB 102,15,56,220,225 + DB 102,15,56,220,233 + mov DWORD[((96+12))+rsp],r9d + lea r9,[7+r8] + DB 102,15,56,220,241 + DB 102,15,56,220,249 + DB 102,68,15,56,220,193 + DB 102,68,15,56,220,201 + movups xmm1,XMMWORD[((144-128))+rcx] + bswap r9d + DB 102,15,56,220,208 + DB 102,15,56,220,216 + DB 102,15,56,220,224 + xor r9d,ebp + movdqu xmm10,XMMWORD[rdi] + DB 102,15,56,220,232 + mov DWORD[((112+12))+rsp],r9d + cmp eax,11 + DB 102,15,56,220,240 + DB 102,15,56,220,248 + DB 102,68,15,56,220,192 + DB 102,68,15,56,220,200 + movups xmm0,XMMWORD[((160-128))+rcx] + + jb NEAR $L$ctr32_enc_done + + DB 102,15,56,220,209 + DB 102,15,56,220,217 + DB 102,15,56,220,225 + DB 102,15,56,220,233 + DB 102,15,56,220,241 + DB 102,15,56,220,249 + DB 102,68,15,56,220,193 + DB 102,68,15,56,220,201 + movups xmm1,XMMWORD[((176-128))+rcx] + + DB 102,15,56,220,208 + DB 102,15,56,220,216 + DB 102,15,56,220,224 + DB 102,15,56,220,232 + DB 102,15,56,220,240 + DB 102,15,56,220,248 + DB 102,68,15,56,220,192 + DB 102,68,15,56,220,200 + movups xmm0,XMMWORD[((192-128))+rcx] + + + DB 102,15,56,220,209 + DB 102,15,56,220,217 + DB 102,15,56,220,225 + DB 102,15,56,220,233 + DB 102,15,56,220,241 + DB 102,15,56,220,249 + DB 102,68,15,56,220,193 + DB 102,68,15,56,220,201 + movups xmm1,XMMWORD[((208-128))+rcx] + + DB 102,15,56,220,208 + DB 102,15,56,220,216 + DB 102,15,56,220,224 + DB 102,15,56,220,232 + DB 102,15,56,220,240 + DB 102,15,56,220,248 + DB 102,68,15,56,220,192 + DB 102,68,15,56,220,200 + movups xmm0,XMMWORD[((224-128))+rcx] + jmp NEAR $L$ctr32_enc_done + +ALIGN 16 +$L$ctr32_enc_done: + movdqu xmm11,XMMWORD[16+rdi] + pxor xmm10,xmm0 + movdqu xmm12,XMMWORD[32+rdi] + pxor xmm11,xmm0 + movdqu xmm13,XMMWORD[48+rdi] + pxor xmm12,xmm0 + movdqu xmm14,XMMWORD[64+rdi] + pxor xmm13,xmm0 + movdqu xmm15,XMMWORD[80+rdi] + pxor xmm14,xmm0 + prefetcht0 [448+rdi] + prefetcht0 [512+rdi] + pxor xmm15,xmm0 + DB 102,15,56,220,209 + DB 102,15,56,220,217 + DB 102,15,56,220,225 + DB 102,15,56,220,233 + DB 102,15,56,220,241 + DB 102,15,56,220,249 + DB 102,68,15,56,220,193 + DB 102,68,15,56,220,201 + movdqu xmm1,XMMWORD[96+rdi] + lea rdi,[128+rdi] + + DB 102,65,15,56,221,210 + pxor xmm1,xmm0 + movdqu xmm10,XMMWORD[((112-128))+rdi] + DB 102,65,15,56,221,219 + pxor xmm10,xmm0 + movdqa xmm11,XMMWORD[rsp] + DB 102,65,15,56,221,228 + DB 102,65,15,56,221,237 + movdqa xmm12,XMMWORD[16+rsp] + movdqa xmm13,XMMWORD[32+rsp] + DB 102,65,15,56,221,246 + DB 102,65,15,56,221,255 + movdqa xmm14,XMMWORD[48+rsp] + movdqa xmm15,XMMWORD[64+rsp] + DB 102,68,15,56,221,193 + movdqa xmm0,XMMWORD[80+rsp] + movups xmm1,XMMWORD[((16-128))+rcx] + DB 102,69,15,56,221,202 + + movups XMMWORD[rsi],xmm2 + movdqa xmm2,xmm11 + movups XMMWORD[16+rsi],xmm3 + movdqa xmm3,xmm12 + movups XMMWORD[32+rsi],xmm4 + movdqa xmm4,xmm13 + movups XMMWORD[48+rsi],xmm5 + movdqa xmm5,xmm14 + movups XMMWORD[64+rsi],xmm6 + movdqa xmm6,xmm15 + movups XMMWORD[80+rsi],xmm7 + movdqa xmm7,xmm0 + movups XMMWORD[96+rsi],xmm8 + movups XMMWORD[112+rsi],xmm9 + lea rsi,[128+rsi] + + sub rdx,8 + jnc NEAR $L$ctr32_loop8 + + add rdx,8 + jz NEAR $L$ctr32_done + lea rcx,[((-128))+rcx] + +$L$ctr32_tail: + + + lea rcx,[16+rcx] + cmp rdx,4 + jb NEAR $L$ctr32_loop3 + je NEAR $L$ctr32_loop4 + + + shl eax,4 + movdqa xmm8,XMMWORD[96+rsp] + pxor xmm9,xmm9 + + movups xmm0,XMMWORD[16+rcx] + DB 102,15,56,220,209 + DB 102,15,56,220,217 + lea rcx,[((32-16))+rax*1+rcx] + neg rax + DB 102,15,56,220,225 + add rax,16 + movups xmm10,XMMWORD[rdi] + DB 102,15,56,220,233 + DB 102,15,56,220,241 + movups xmm11,XMMWORD[16+rdi] + movups xmm12,XMMWORD[32+rdi] + DB 102,15,56,220,249 + DB 102,68,15,56,220,193 + + call $L$enc_loop8_enter + + movdqu xmm13,XMMWORD[48+rdi] + pxor xmm2,xmm10 + movdqu xmm10,XMMWORD[64+rdi] + pxor xmm3,xmm11 + movdqu XMMWORD[rsi],xmm2 + pxor xmm4,xmm12 + movdqu XMMWORD[16+rsi],xmm3 + pxor xmm5,xmm13 + movdqu XMMWORD[32+rsi],xmm4 + pxor xmm6,xmm10 + movdqu XMMWORD[48+rsi],xmm5 + movdqu XMMWORD[64+rsi],xmm6 + cmp rdx,6 + jb NEAR $L$ctr32_done + + movups xmm11,XMMWORD[80+rdi] + xorps xmm7,xmm11 + movups XMMWORD[80+rsi],xmm7 + je NEAR $L$ctr32_done + + movups xmm12,XMMWORD[96+rdi] + xorps xmm8,xmm12 + movups XMMWORD[96+rsi],xmm8 + jmp NEAR $L$ctr32_done + +ALIGN 32 +$L$ctr32_loop4: + DB 102,15,56,220,209 + lea rcx,[16+rcx] + dec eax + DB 102,15,56,220,217 + DB 102,15,56,220,225 + DB 102,15,56,220,233 + movups xmm1,XMMWORD[rcx] + jnz NEAR $L$ctr32_loop4 + DB 102,15,56,221,209 + DB 102,15,56,221,217 + movups xmm10,XMMWORD[rdi] + movups xmm11,XMMWORD[16+rdi] + DB 102,15,56,221,225 + DB 102,15,56,221,233 + movups xmm12,XMMWORD[32+rdi] + movups xmm13,XMMWORD[48+rdi] + + xorps xmm2,xmm10 + movups XMMWORD[rsi],xmm2 + xorps xmm3,xmm11 + movups XMMWORD[16+rsi],xmm3 + pxor xmm4,xmm12 + movdqu XMMWORD[32+rsi],xmm4 + pxor xmm5,xmm13 + movdqu XMMWORD[48+rsi],xmm5 + jmp NEAR $L$ctr32_done + +ALIGN 32 +$L$ctr32_loop3: + DB 102,15,56,220,209 + lea rcx,[16+rcx] + dec eax + DB 102,15,56,220,217 + DB 102,15,56,220,225 + movups xmm1,XMMWORD[rcx] + jnz NEAR $L$ctr32_loop3 + DB 102,15,56,221,209 + DB 102,15,56,221,217 + DB 102,15,56,221,225 + + movups xmm10,XMMWORD[rdi] + xorps xmm2,xmm10 + movups XMMWORD[rsi],xmm2 + cmp rdx,2 + jb NEAR $L$ctr32_done + + movups xmm11,XMMWORD[16+rdi] + xorps xmm3,xmm11 + movups XMMWORD[16+rsi],xmm3 + je NEAR $L$ctr32_done + + movups xmm12,XMMWORD[32+rdi] + xorps xmm4,xmm12 + movups XMMWORD[32+rsi],xmm4 + +$L$ctr32_done: + xorps xmm0,xmm0 + xor ebp,ebp + pxor xmm1,xmm1 + pxor xmm2,xmm2 + pxor xmm3,xmm3 + pxor xmm4,xmm4 + pxor xmm5,xmm5 + movaps xmm6,XMMWORD[((-168))+r11] + movaps XMMWORD[(-168)+r11],xmm0 + movaps xmm7,XMMWORD[((-152))+r11] + movaps XMMWORD[(-152)+r11],xmm0 + movaps xmm8,XMMWORD[((-136))+r11] + movaps XMMWORD[(-136)+r11],xmm0 + movaps xmm9,XMMWORD[((-120))+r11] + movaps XMMWORD[(-120)+r11],xmm0 + movaps xmm10,XMMWORD[((-104))+r11] + movaps XMMWORD[(-104)+r11],xmm0 + movaps xmm11,XMMWORD[((-88))+r11] + movaps XMMWORD[(-88)+r11],xmm0 + movaps xmm12,XMMWORD[((-72))+r11] + movaps XMMWORD[(-72)+r11],xmm0 + movaps xmm13,XMMWORD[((-56))+r11] + movaps XMMWORD[(-56)+r11],xmm0 + movaps xmm14,XMMWORD[((-40))+r11] + movaps XMMWORD[(-40)+r11],xmm0 + movaps xmm15,XMMWORD[((-24))+r11] + movaps XMMWORD[(-24)+r11],xmm0 + movaps XMMWORD[rsp],xmm0 + movaps XMMWORD[16+rsp],xmm0 + movaps XMMWORD[32+rsp],xmm0 + movaps XMMWORD[48+rsp],xmm0 + movaps XMMWORD[64+rsp],xmm0 + movaps XMMWORD[80+rsp],xmm0 + movaps XMMWORD[96+rsp],xmm0 + movaps XMMWORD[112+rsp],xmm0 + mov rbp,QWORD[((-8))+r11] + + lea rsp,[r11] + +$L$ctr32_epilogue: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_aes_hw_ctr32_encrypt_blocks: +global aes_hw_set_encrypt_key_base + +ALIGN 16 +aes_hw_set_encrypt_key_base: + +$L$SEH_begin_aes_hw_set_encrypt_key_base_1: +_CET_ENDBR +%ifdef BORINGSSL_DISPATCH_TEST + mov BYTE[((BORINGSSL_function_hit+3))],1 +%endif + sub rsp,8 + +$L$SEH_prologue_aes_hw_set_encrypt_key_base_2: +$L$SEH_endprologue_aes_hw_set_encrypt_key_base_3: + movups xmm0,XMMWORD[rcx] + xorps xmm4,xmm4 + lea rax,[16+r8] + cmp edx,256 + je NEAR $L$14rounds + + + cmp edx,128 + jne NEAR $L$bad_keybits + +$L$10rounds: + mov edx,9 + + movups XMMWORD[r8],xmm0 + DB 102,15,58,223,200,1 + call $L$key_expansion_128_cold + DB 102,15,58,223,200,2 + call $L$key_expansion_128 + DB 102,15,58,223,200,4 + call $L$key_expansion_128 + DB 102,15,58,223,200,8 + call $L$key_expansion_128 + DB 102,15,58,223,200,16 + call $L$key_expansion_128 + DB 102,15,58,223,200,32 + call $L$key_expansion_128 + DB 102,15,58,223,200,64 + call $L$key_expansion_128 + DB 102,15,58,223,200,128 + call $L$key_expansion_128 + DB 102,15,58,223,200,27 + call $L$key_expansion_128 + DB 102,15,58,223,200,54 + call $L$key_expansion_128 + movups XMMWORD[rax],xmm0 + mov DWORD[80+rax],edx + xor eax,eax + jmp NEAR $L$enc_key_ret + + + +ALIGN 16 +$L$14rounds: + movups xmm2,XMMWORD[16+rcx] + mov edx,13 + lea rax,[16+rax] + + movups XMMWORD[r8],xmm0 + movups XMMWORD[16+r8],xmm2 + DB 102,15,58,223,202,1 + call $L$key_expansion_256a_cold + DB 102,15,58,223,200,1 + call $L$key_expansion_256b + DB 102,15,58,223,202,2 + call $L$key_expansion_256a + DB 102,15,58,223,200,2 + call $L$key_expansion_256b + DB 102,15,58,223,202,4 + call $L$key_expansion_256a + DB 102,15,58,223,200,4 + call $L$key_expansion_256b + DB 102,15,58,223,202,8 + call $L$key_expansion_256a + DB 102,15,58,223,200,8 + call $L$key_expansion_256b + DB 102,15,58,223,202,16 + call $L$key_expansion_256a + DB 102,15,58,223,200,16 + call $L$key_expansion_256b + DB 102,15,58,223,202,32 + call $L$key_expansion_256a + DB 102,15,58,223,200,32 + call $L$key_expansion_256b + DB 102,15,58,223,202,64 + call $L$key_expansion_256a + movups XMMWORD[rax],xmm0 + mov DWORD[16+rax],edx + xor rax,rax + jmp NEAR $L$enc_key_ret + +ALIGN 16 +$L$bad_keybits: + mov rax,-2 +$L$enc_key_ret: + pxor xmm0,xmm0 + pxor xmm1,xmm1 + pxor xmm2,xmm2 + pxor xmm3,xmm3 + pxor xmm4,xmm4 + pxor xmm5,xmm5 + add rsp,8 + + ret + +$L$SEH_end_aes_hw_set_encrypt_key_base_4: + +ALIGN 16 +$L$key_expansion_128: + + movups XMMWORD[rax],xmm0 + lea rax,[16+rax] +$L$key_expansion_128_cold: + shufps xmm4,xmm0,16 + xorps xmm0,xmm4 + shufps xmm4,xmm0,140 + xorps xmm0,xmm4 + shufps xmm1,xmm1,255 + xorps xmm0,xmm1 + ret + + +ALIGN 16 +$L$key_expansion_256a: + + movups XMMWORD[rax],xmm2 + lea rax,[16+rax] +$L$key_expansion_256a_cold: + shufps xmm4,xmm0,16 + xorps xmm0,xmm4 + shufps xmm4,xmm0,140 + xorps xmm0,xmm4 + shufps xmm1,xmm1,255 + xorps xmm0,xmm1 + ret + + +ALIGN 16 +$L$key_expansion_256b: + + movups XMMWORD[rax],xmm0 + lea rax,[16+rax] + + shufps xmm4,xmm2,16 + xorps xmm2,xmm4 + shufps xmm4,xmm2,140 + xorps xmm2,xmm4 + shufps xmm1,xmm1,170 + xorps xmm2,xmm1 + ret + + + +global aes_hw_set_encrypt_key_alt + +ALIGN 16 +aes_hw_set_encrypt_key_alt: + +$L$SEH_begin_aes_hw_set_encrypt_key_alt_1: +_CET_ENDBR +%ifdef BORINGSSL_DISPATCH_TEST + mov BYTE[((BORINGSSL_function_hit+3))],1 +%endif + sub rsp,8 + +$L$SEH_prologue_aes_hw_set_encrypt_key_alt_2: +$L$SEH_endprologue_aes_hw_set_encrypt_key_alt_3: + movups xmm0,XMMWORD[rcx] + xorps xmm4,xmm4 + lea rax,[16+r8] + cmp edx,256 + je NEAR $L$14rounds_alt + + cmp edx,128 + jne NEAR $L$bad_keybits_alt + + mov edx,9 + movdqa xmm5,XMMWORD[$L$key_rotate] + mov r10d,8 + movdqa xmm4,XMMWORD[$L$key_rcon1] + movdqa xmm2,xmm0 + movdqu XMMWORD[r8],xmm0 + jmp NEAR $L$oop_key128 + +ALIGN 16 +$L$oop_key128: +DB 102,15,56,0,197 + DB 102,15,56,221,196 + pslld xmm4,1 + lea rax,[16+rax] + + movdqa xmm3,xmm2 + pslldq xmm2,4 + pxor xmm3,xmm2 + pslldq xmm2,4 + pxor xmm3,xmm2 + pslldq xmm2,4 + pxor xmm2,xmm3 + + pxor xmm0,xmm2 + movdqu XMMWORD[(-16)+rax],xmm0 + movdqa xmm2,xmm0 + + dec r10d + jnz NEAR $L$oop_key128 + + movdqa xmm4,XMMWORD[$L$key_rcon1b] + +DB 102,15,56,0,197 + DB 102,15,56,221,196 + pslld xmm4,1 + + movdqa xmm3,xmm2 + pslldq xmm2,4 + pxor xmm3,xmm2 + pslldq xmm2,4 + pxor xmm3,xmm2 + pslldq xmm2,4 + pxor xmm2,xmm3 + + pxor xmm0,xmm2 + movdqu XMMWORD[rax],xmm0 + + movdqa xmm2,xmm0 +DB 102,15,56,0,197 + DB 102,15,56,221,196 + + movdqa xmm3,xmm2 + pslldq xmm2,4 + pxor xmm3,xmm2 + pslldq xmm2,4 + pxor xmm3,xmm2 + pslldq xmm2,4 + pxor xmm2,xmm3 + + pxor xmm0,xmm2 + movdqu XMMWORD[16+rax],xmm0 + + mov DWORD[96+rax],edx + xor eax,eax + jmp NEAR $L$enc_key_ret_alt + + + +ALIGN 16 +$L$14rounds_alt: + movups xmm2,XMMWORD[16+rcx] + mov edx,13 + lea rax,[16+rax] + movdqa xmm5,XMMWORD[$L$key_rotate] + movdqa xmm4,XMMWORD[$L$key_rcon1] + mov r10d,7 + movdqu XMMWORD[r8],xmm0 + movdqa xmm1,xmm2 + movdqu XMMWORD[16+r8],xmm2 + jmp NEAR $L$oop_key256 + +ALIGN 16 +$L$oop_key256: +DB 102,15,56,0,213 + DB 102,15,56,221,212 + + movdqa xmm3,xmm0 + pslldq xmm0,4 + pxor xmm3,xmm0 + pslldq xmm0,4 + pxor xmm3,xmm0 + pslldq xmm0,4 + pxor xmm0,xmm3 + pslld xmm4,1 + + pxor xmm0,xmm2 + movdqu XMMWORD[rax],xmm0 + + dec r10d + jz NEAR $L$done_key256 + + pshufd xmm2,xmm0,0xff + pxor xmm3,xmm3 + DB 102,15,56,221,211 + + movdqa xmm3,xmm1 + pslldq xmm1,4 + pxor xmm3,xmm1 + pslldq xmm1,4 + pxor xmm3,xmm1 + pslldq xmm1,4 + pxor xmm1,xmm3 + + pxor xmm2,xmm1 + movdqu XMMWORD[16+rax],xmm2 + lea rax,[32+rax] + movdqa xmm1,xmm2 + + jmp NEAR $L$oop_key256 + +$L$done_key256: + mov DWORD[16+rax],edx + xor eax,eax + jmp NEAR $L$enc_key_ret_alt + +ALIGN 16 +$L$bad_keybits_alt: + mov rax,-2 +$L$enc_key_ret_alt: + pxor xmm0,xmm0 + pxor xmm1,xmm1 + pxor xmm2,xmm2 + pxor xmm3,xmm3 + pxor xmm4,xmm4 + pxor xmm5,xmm5 + add rsp,8 + + ret + +$L$SEH_end_aes_hw_set_encrypt_key_alt_4: + +section .rdata rdata align=8 +ALIGN 64 +$L$bswap_mask: + DB 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 +$L$increment32: + DD 6,6,6,0 +$L$increment64: + DD 1,0,0,0 +$L$increment1: + DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 +$L$key_rotate: + DD 0x0c0f0e0d,0x0c0f0e0d,0x0c0f0e0d,0x0c0f0e0d +$L$key_rotate192: + DD 0x04070605,0x04070605,0x04070605,0x04070605 +$L$key_rcon1: + DD 1,1,1,1 +$L$key_rcon1b: + DD 0x1b,0x1b,0x1b,0x1b + + DB 65,69,83,32,102,111,114,32,73,110,116,101,108,32,65,69 + DB 83,45,78,73,44,32,67,82,89,80,84,79,71,65,77,83 + DB 32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115 + DB 115,108,46,111,114,103,62,0 +ALIGN 64 +section .text + +EXTERN __imp_RtlVirtualUnwind + +ALIGN 16 +ctr_xts_se_handler: + push rsi + push rdi + push rbx + push rbp + push r12 + push r13 + push r14 + push r15 + pushfq + sub rsp,64 + + mov rax,QWORD[120+r8] + mov rbx,QWORD[248+r8] + + mov rsi,QWORD[8+r9] + mov r11,QWORD[56+r9] + + mov r10d,DWORD[r11] + lea r10,[r10*1+rsi] + cmp rbx,r10 + jb NEAR $L$common_seh_tail + + mov rax,QWORD[152+r8] + + mov r10d,DWORD[4+r11] + lea r10,[r10*1+rsi] + cmp rbx,r10 + jae NEAR $L$common_seh_tail + + mov rax,QWORD[208+r8] + + lea rsi,[((-168))+rax] + lea rdi,[512+r8] + mov ecx,20 + DD 0xa548f3fc + + mov rbp,QWORD[((-8))+rax] + mov QWORD[160+r8],rbp + + +$L$common_seh_tail: + mov rdi,QWORD[8+rax] + mov rsi,QWORD[16+rax] + mov QWORD[152+r8],rax + mov QWORD[168+r8],rsi + mov QWORD[176+r8],rdi + + mov rdi,QWORD[40+r9] + mov rsi,r8 + mov ecx,154 + DD 0xa548f3fc + + mov rsi,r9 + xor rcx,rcx + mov rdx,QWORD[8+rsi] + mov r8,QWORD[rsi] + mov r9,QWORD[16+rsi] + mov r10,QWORD[40+rsi] + lea r11,[56+rsi] + lea r12,[24+rsi] + mov QWORD[32+rsp],r10 + mov QWORD[40+rsp],r11 + mov QWORD[48+rsp],r12 + mov QWORD[56+rsp],rcx + call QWORD[__imp_RtlVirtualUnwind] + + mov eax,1 + add rsp,64 + popfq + pop r15 + pop r14 + pop r13 + pop r12 + pop rbp + pop rbx + pop rdi + pop rsi + ret + + +section .pdata rdata align=4 +ALIGN 4 + DD $L$SEH_begin_aes_hw_ctr32_encrypt_blocks wrt ..imagebase + DD $L$SEH_end_aes_hw_ctr32_encrypt_blocks wrt ..imagebase + DD $L$SEH_info_ctr32 wrt ..imagebase +section .xdata rdata align=8 +ALIGN 8 +$L$SEH_info_ctr32: + DB 9,0,0,0 + DD ctr_xts_se_handler wrt ..imagebase + DD $L$ctr32_body wrt ..imagebase,$L$ctr32_epilogue wrt ..imagebase +section .pdata +ALIGN 4 + DD $L$SEH_begin_aes_hw_set_encrypt_key_base_1 wrt ..imagebase + DD $L$SEH_end_aes_hw_set_encrypt_key_base_4 wrt ..imagebase + DD $L$SEH_info_aes_hw_set_encrypt_key_base_0 wrt ..imagebase + + DD $L$SEH_begin_aes_hw_set_encrypt_key_alt_1 wrt ..imagebase + DD $L$SEH_end_aes_hw_set_encrypt_key_alt_4 wrt ..imagebase + DD $L$SEH_info_aes_hw_set_encrypt_key_alt_0 wrt ..imagebase + + +section .xdata +ALIGN 4 +$L$SEH_info_aes_hw_set_encrypt_key_base_0: + DB 1 + DB $L$SEH_endprologue_aes_hw_set_encrypt_key_base_3-$L$SEH_begin_aes_hw_set_encrypt_key_base_1 + DB 1 + DB 0 + DB $L$SEH_prologue_aes_hw_set_encrypt_key_base_2-$L$SEH_begin_aes_hw_set_encrypt_key_base_1 + DB 2 + + DW 0 +$L$SEH_info_aes_hw_set_encrypt_key_alt_0: + DB 1 + DB $L$SEH_endprologue_aes_hw_set_encrypt_key_alt_3-$L$SEH_begin_aes_hw_set_encrypt_key_alt_1 + DB 1 + DB 0 + DB $L$SEH_prologue_aes_hw_set_encrypt_key_alt_2-$L$SEH_begin_aes_hw_set_encrypt_key_alt_1 + DB 2 + + DW 0 +%else +; Work around https://bugzilla.nasm.us/show_bug.cgi?id=3392738 +ret +%endif diff --git a/http/vendor/ring/pregenerated/aesni-x86_64-nasm.o b/http/vendor/ring/pregenerated/aesni-x86_64-nasm.o new file mode 100644 index 0000000..f0a1501 Binary files /dev/null and b/http/vendor/ring/pregenerated/aesni-x86_64-nasm.o differ diff --git a/http/vendor/ring/pregenerated/aesv8-armx-ios64.S b/http/vendor/ring/pregenerated/aesv8-armx-ios64.S new file mode 100644 index 0000000..75c626a --- /dev/null +++ b/http/vendor/ring/pregenerated/aesv8-armx-ios64.S @@ -0,0 +1,353 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__APPLE__) +#if __ARM_MAX_ARCH__>=7 +.text + +.section __TEXT,__const +.align 5 +Lrcon: +.long 0x01,0x01,0x01,0x01 +.long 0x0c0f0e0d,0x0c0f0e0d,0x0c0f0e0d,0x0c0f0e0d // rotate-n-splat +.long 0x1b,0x1b,0x1b,0x1b + +.text + +.globl _aes_hw_set_encrypt_key +.private_extern _aes_hw_set_encrypt_key + +.align 5 +_aes_hw_set_encrypt_key: +Lenc_key: + // Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later. + AARCH64_VALID_CALL_TARGET + stp x29,x30,[sp,#-16]! + add x29,sp,#0 + mov x3,#-2 + cmp w1,#128 + b.lt Lenc_key_abort + cmp w1,#256 + b.gt Lenc_key_abort + tst w1,#0x3f + b.ne Lenc_key_abort + + adrp x3,Lrcon@PAGE + add x3,x3,Lrcon@PAGEOFF + cmp w1,#192 + + eor v0.16b,v0.16b,v0.16b + ld1 {v3.16b},[x0],#16 + mov w1,#8 // reuse w1 + ld1 {v1.4s,v2.4s},[x3],#32 + + b.lt Loop128 + // 192-bit key support was removed. + b L256 + +.align 4 +Loop128: + tbl v6.16b,{v3.16b},v2.16b + ext v5.16b,v0.16b,v3.16b,#12 + st1 {v3.4s},[x2],#16 + aese v6.16b,v0.16b + subs w1,w1,#1 + + eor v3.16b,v3.16b,v5.16b + ext v5.16b,v0.16b,v5.16b,#12 + eor v3.16b,v3.16b,v5.16b + ext v5.16b,v0.16b,v5.16b,#12 + eor v6.16b,v6.16b,v1.16b + eor v3.16b,v3.16b,v5.16b + shl v1.16b,v1.16b,#1 + eor v3.16b,v3.16b,v6.16b + b.ne Loop128 + + ld1 {v1.4s},[x3] + + tbl v6.16b,{v3.16b},v2.16b + ext v5.16b,v0.16b,v3.16b,#12 + st1 {v3.4s},[x2],#16 + aese v6.16b,v0.16b + + eor v3.16b,v3.16b,v5.16b + ext v5.16b,v0.16b,v5.16b,#12 + eor v3.16b,v3.16b,v5.16b + ext v5.16b,v0.16b,v5.16b,#12 + eor v6.16b,v6.16b,v1.16b + eor v3.16b,v3.16b,v5.16b + shl v1.16b,v1.16b,#1 + eor v3.16b,v3.16b,v6.16b + + tbl v6.16b,{v3.16b},v2.16b + ext v5.16b,v0.16b,v3.16b,#12 + st1 {v3.4s},[x2],#16 + aese v6.16b,v0.16b + + eor v3.16b,v3.16b,v5.16b + ext v5.16b,v0.16b,v5.16b,#12 + eor v3.16b,v3.16b,v5.16b + ext v5.16b,v0.16b,v5.16b,#12 + eor v6.16b,v6.16b,v1.16b + eor v3.16b,v3.16b,v5.16b + eor v3.16b,v3.16b,v6.16b + st1 {v3.4s},[x2] + add x2,x2,#0x50 + + mov w12,#10 + b Ldone + +// 192-bit key support was removed. + +.align 4 +L256: + ld1 {v4.16b},[x0] + mov w1,#7 + mov w12,#14 + st1 {v3.4s},[x2],#16 + +Loop256: + tbl v6.16b,{v4.16b},v2.16b + ext v5.16b,v0.16b,v3.16b,#12 + st1 {v4.4s},[x2],#16 + aese v6.16b,v0.16b + subs w1,w1,#1 + + eor v3.16b,v3.16b,v5.16b + ext v5.16b,v0.16b,v5.16b,#12 + eor v3.16b,v3.16b,v5.16b + ext v5.16b,v0.16b,v5.16b,#12 + eor v6.16b,v6.16b,v1.16b + eor v3.16b,v3.16b,v5.16b + shl v1.16b,v1.16b,#1 + eor v3.16b,v3.16b,v6.16b + st1 {v3.4s},[x2],#16 + b.eq Ldone + + dup v6.4s,v3.s[3] // just splat + ext v5.16b,v0.16b,v4.16b,#12 + aese v6.16b,v0.16b + + eor v4.16b,v4.16b,v5.16b + ext v5.16b,v0.16b,v5.16b,#12 + eor v4.16b,v4.16b,v5.16b + ext v5.16b,v0.16b,v5.16b,#12 + eor v4.16b,v4.16b,v5.16b + + eor v4.16b,v4.16b,v6.16b + b Loop256 + +Ldone: + str w12,[x2] + mov x3,#0 + +Lenc_key_abort: + mov x0,x3 // return value + ldr x29,[sp],#16 + ret + +.globl _aes_hw_ctr32_encrypt_blocks +.private_extern _aes_hw_ctr32_encrypt_blocks + +.align 5 +_aes_hw_ctr32_encrypt_blocks: + // Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later. + AARCH64_VALID_CALL_TARGET + stp x29,x30,[sp,#-16]! + add x29,sp,#0 + ldr w5,[x3,#240] + + ldr w8, [x4, #12] + ld1 {v0.4s},[x4] + + ld1 {v16.4s,v17.4s},[x3] // load key schedule... + sub w5,w5,#4 + mov x12,#16 + cmp x2,#2 + add x7,x3,x5,lsl#4 // pointer to last 5 round keys + sub w5,w5,#2 + ld1 {v20.4s,v21.4s},[x7],#32 + ld1 {v22.4s,v23.4s},[x7],#32 + ld1 {v7.4s},[x7] + add x7,x3,#32 + mov w6,w5 + csel x12,xzr,x12,lo + + // ARM Cortex-A57 and Cortex-A72 cores running in 32-bit mode are + // affected by silicon errata #1742098 [0] and #1655431 [1], + // respectively, where the second instruction of an aese/aesmc + // instruction pair may execute twice if an interrupt is taken right + // after the first instruction consumes an input register of which a + // single 32-bit lane has been updated the last time it was modified. + // + // This function uses a counter in one 32-bit lane. The vmov lines + // could write to v1.16b and v18.16b directly, but that trips this bugs. + // We write to v6.16b and copy to the final register as a workaround. + // + // [0] ARM-EPM-049219 v23 Cortex-A57 MPCore Software Developers Errata Notice + // [1] ARM-EPM-012079 v11.0 Cortex-A72 MPCore Software Developers Errata Notice +#ifndef __AARCH64EB__ + rev w8, w8 +#endif + add w10, w8, #1 + orr v6.16b,v0.16b,v0.16b + rev w10, w10 + mov v6.s[3],w10 + add w8, w8, #2 + orr v1.16b,v6.16b,v6.16b + b.ls Lctr32_tail + rev w12, w8 + mov v6.s[3],w12 + sub x2,x2,#3 // bias + orr v18.16b,v6.16b,v6.16b + b Loop3x_ctr32 + +.align 4 +Loop3x_ctr32: + aese v0.16b,v16.16b + aesmc v0.16b,v0.16b + aese v1.16b,v16.16b + aesmc v1.16b,v1.16b + aese v18.16b,v16.16b + aesmc v18.16b,v18.16b + ld1 {v16.4s},[x7],#16 + subs w6,w6,#2 + aese v0.16b,v17.16b + aesmc v0.16b,v0.16b + aese v1.16b,v17.16b + aesmc v1.16b,v1.16b + aese v18.16b,v17.16b + aesmc v18.16b,v18.16b + ld1 {v17.4s},[x7],#16 + b.gt Loop3x_ctr32 + + aese v0.16b,v16.16b + aesmc v4.16b,v0.16b + aese v1.16b,v16.16b + aesmc v5.16b,v1.16b + ld1 {v2.16b},[x0],#16 + add w9,w8,#1 + aese v18.16b,v16.16b + aesmc v18.16b,v18.16b + ld1 {v3.16b},[x0],#16 + rev w9,w9 + aese v4.16b,v17.16b + aesmc v4.16b,v4.16b + aese v5.16b,v17.16b + aesmc v5.16b,v5.16b + ld1 {v19.16b},[x0],#16 + mov x7,x3 + aese v18.16b,v17.16b + aesmc v17.16b,v18.16b + aese v4.16b,v20.16b + aesmc v4.16b,v4.16b + aese v5.16b,v20.16b + aesmc v5.16b,v5.16b + eor v2.16b,v2.16b,v7.16b + add w10,w8,#2 + aese v17.16b,v20.16b + aesmc v17.16b,v17.16b + eor v3.16b,v3.16b,v7.16b + add w8,w8,#3 + aese v4.16b,v21.16b + aesmc v4.16b,v4.16b + aese v5.16b,v21.16b + aesmc v5.16b,v5.16b + // Note the logic to update v0.16b, v1.16b, and v1.16b is written to work + // around a bug in ARM Cortex-A57 and Cortex-A72 cores running in + // 32-bit mode. See the comment above. + eor v19.16b,v19.16b,v7.16b + mov v6.s[3], w9 + aese v17.16b,v21.16b + aesmc v17.16b,v17.16b + orr v0.16b,v6.16b,v6.16b + rev w10,w10 + aese v4.16b,v22.16b + aesmc v4.16b,v4.16b + mov v6.s[3], w10 + rev w12,w8 + aese v5.16b,v22.16b + aesmc v5.16b,v5.16b + orr v1.16b,v6.16b,v6.16b + mov v6.s[3], w12 + aese v17.16b,v22.16b + aesmc v17.16b,v17.16b + orr v18.16b,v6.16b,v6.16b + subs x2,x2,#3 + aese v4.16b,v23.16b + aese v5.16b,v23.16b + aese v17.16b,v23.16b + + eor v2.16b,v2.16b,v4.16b + ld1 {v16.4s},[x7],#16 // re-pre-load rndkey[0] + st1 {v2.16b},[x1],#16 + eor v3.16b,v3.16b,v5.16b + mov w6,w5 + st1 {v3.16b},[x1],#16 + eor v19.16b,v19.16b,v17.16b + ld1 {v17.4s},[x7],#16 // re-pre-load rndkey[1] + st1 {v19.16b},[x1],#16 + b.hs Loop3x_ctr32 + + adds x2,x2,#3 + b.eq Lctr32_done + cmp x2,#1 + mov x12,#16 + csel x12,xzr,x12,eq + +Lctr32_tail: + aese v0.16b,v16.16b + aesmc v0.16b,v0.16b + aese v1.16b,v16.16b + aesmc v1.16b,v1.16b + ld1 {v16.4s},[x7],#16 + subs w6,w6,#2 + aese v0.16b,v17.16b + aesmc v0.16b,v0.16b + aese v1.16b,v17.16b + aesmc v1.16b,v1.16b + ld1 {v17.4s},[x7],#16 + b.gt Lctr32_tail + + aese v0.16b,v16.16b + aesmc v0.16b,v0.16b + aese v1.16b,v16.16b + aesmc v1.16b,v1.16b + aese v0.16b,v17.16b + aesmc v0.16b,v0.16b + aese v1.16b,v17.16b + aesmc v1.16b,v1.16b + ld1 {v2.16b},[x0],x12 + aese v0.16b,v20.16b + aesmc v0.16b,v0.16b + aese v1.16b,v20.16b + aesmc v1.16b,v1.16b + ld1 {v3.16b},[x0] + aese v0.16b,v21.16b + aesmc v0.16b,v0.16b + aese v1.16b,v21.16b + aesmc v1.16b,v1.16b + eor v2.16b,v2.16b,v7.16b + aese v0.16b,v22.16b + aesmc v0.16b,v0.16b + aese v1.16b,v22.16b + aesmc v1.16b,v1.16b + eor v3.16b,v3.16b,v7.16b + aese v0.16b,v23.16b + aese v1.16b,v23.16b + + cmp x2,#1 + eor v2.16b,v2.16b,v0.16b + eor v3.16b,v3.16b,v1.16b + st1 {v2.16b},[x1],#16 + b.eq Lctr32_done + st1 {v3.16b},[x1] + +Lctr32_done: + ldr x29,[sp],#16 + ret + +#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__APPLE__) diff --git a/http/vendor/ring/pregenerated/aesv8-armx-linux64.S b/http/vendor/ring/pregenerated/aesv8-armx-linux64.S new file mode 100644 index 0000000..5ed5a72 --- /dev/null +++ b/http/vendor/ring/pregenerated/aesv8-armx-linux64.S @@ -0,0 +1,353 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__ELF__) +#if __ARM_MAX_ARCH__>=7 +.text +.arch armv8-a+crypto +.section .rodata +.align 5 +.Lrcon: +.long 0x01,0x01,0x01,0x01 +.long 0x0c0f0e0d,0x0c0f0e0d,0x0c0f0e0d,0x0c0f0e0d // rotate-n-splat +.long 0x1b,0x1b,0x1b,0x1b + +.text + +.globl aes_hw_set_encrypt_key +.hidden aes_hw_set_encrypt_key +.type aes_hw_set_encrypt_key,%function +.align 5 +aes_hw_set_encrypt_key: +.Lenc_key: + // Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later. + AARCH64_VALID_CALL_TARGET + stp x29,x30,[sp,#-16]! + add x29,sp,#0 + mov x3,#-2 + cmp w1,#128 + b.lt .Lenc_key_abort + cmp w1,#256 + b.gt .Lenc_key_abort + tst w1,#0x3f + b.ne .Lenc_key_abort + + adrp x3,.Lrcon + add x3,x3,:lo12:.Lrcon + cmp w1,#192 + + eor v0.16b,v0.16b,v0.16b + ld1 {v3.16b},[x0],#16 + mov w1,#8 // reuse w1 + ld1 {v1.4s,v2.4s},[x3],#32 + + b.lt .Loop128 + // 192-bit key support was removed. + b .L256 + +.align 4 +.Loop128: + tbl v6.16b,{v3.16b},v2.16b + ext v5.16b,v0.16b,v3.16b,#12 + st1 {v3.4s},[x2],#16 + aese v6.16b,v0.16b + subs w1,w1,#1 + + eor v3.16b,v3.16b,v5.16b + ext v5.16b,v0.16b,v5.16b,#12 + eor v3.16b,v3.16b,v5.16b + ext v5.16b,v0.16b,v5.16b,#12 + eor v6.16b,v6.16b,v1.16b + eor v3.16b,v3.16b,v5.16b + shl v1.16b,v1.16b,#1 + eor v3.16b,v3.16b,v6.16b + b.ne .Loop128 + + ld1 {v1.4s},[x3] + + tbl v6.16b,{v3.16b},v2.16b + ext v5.16b,v0.16b,v3.16b,#12 + st1 {v3.4s},[x2],#16 + aese v6.16b,v0.16b + + eor v3.16b,v3.16b,v5.16b + ext v5.16b,v0.16b,v5.16b,#12 + eor v3.16b,v3.16b,v5.16b + ext v5.16b,v0.16b,v5.16b,#12 + eor v6.16b,v6.16b,v1.16b + eor v3.16b,v3.16b,v5.16b + shl v1.16b,v1.16b,#1 + eor v3.16b,v3.16b,v6.16b + + tbl v6.16b,{v3.16b},v2.16b + ext v5.16b,v0.16b,v3.16b,#12 + st1 {v3.4s},[x2],#16 + aese v6.16b,v0.16b + + eor v3.16b,v3.16b,v5.16b + ext v5.16b,v0.16b,v5.16b,#12 + eor v3.16b,v3.16b,v5.16b + ext v5.16b,v0.16b,v5.16b,#12 + eor v6.16b,v6.16b,v1.16b + eor v3.16b,v3.16b,v5.16b + eor v3.16b,v3.16b,v6.16b + st1 {v3.4s},[x2] + add x2,x2,#0x50 + + mov w12,#10 + b .Ldone + +// 192-bit key support was removed. + +.align 4 +.L256: + ld1 {v4.16b},[x0] + mov w1,#7 + mov w12,#14 + st1 {v3.4s},[x2],#16 + +.Loop256: + tbl v6.16b,{v4.16b},v2.16b + ext v5.16b,v0.16b,v3.16b,#12 + st1 {v4.4s},[x2],#16 + aese v6.16b,v0.16b + subs w1,w1,#1 + + eor v3.16b,v3.16b,v5.16b + ext v5.16b,v0.16b,v5.16b,#12 + eor v3.16b,v3.16b,v5.16b + ext v5.16b,v0.16b,v5.16b,#12 + eor v6.16b,v6.16b,v1.16b + eor v3.16b,v3.16b,v5.16b + shl v1.16b,v1.16b,#1 + eor v3.16b,v3.16b,v6.16b + st1 {v3.4s},[x2],#16 + b.eq .Ldone + + dup v6.4s,v3.s[3] // just splat + ext v5.16b,v0.16b,v4.16b,#12 + aese v6.16b,v0.16b + + eor v4.16b,v4.16b,v5.16b + ext v5.16b,v0.16b,v5.16b,#12 + eor v4.16b,v4.16b,v5.16b + ext v5.16b,v0.16b,v5.16b,#12 + eor v4.16b,v4.16b,v5.16b + + eor v4.16b,v4.16b,v6.16b + b .Loop256 + +.Ldone: + str w12,[x2] + mov x3,#0 + +.Lenc_key_abort: + mov x0,x3 // return value + ldr x29,[sp],#16 + ret +.size aes_hw_set_encrypt_key,.-aes_hw_set_encrypt_key +.globl aes_hw_ctr32_encrypt_blocks +.hidden aes_hw_ctr32_encrypt_blocks +.type aes_hw_ctr32_encrypt_blocks,%function +.align 5 +aes_hw_ctr32_encrypt_blocks: + // Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later. + AARCH64_VALID_CALL_TARGET + stp x29,x30,[sp,#-16]! + add x29,sp,#0 + ldr w5,[x3,#240] + + ldr w8, [x4, #12] + ld1 {v0.4s},[x4] + + ld1 {v16.4s,v17.4s},[x3] // load key schedule... + sub w5,w5,#4 + mov x12,#16 + cmp x2,#2 + add x7,x3,x5,lsl#4 // pointer to last 5 round keys + sub w5,w5,#2 + ld1 {v20.4s,v21.4s},[x7],#32 + ld1 {v22.4s,v23.4s},[x7],#32 + ld1 {v7.4s},[x7] + add x7,x3,#32 + mov w6,w5 + csel x12,xzr,x12,lo + + // ARM Cortex-A57 and Cortex-A72 cores running in 32-bit mode are + // affected by silicon errata #1742098 [0] and #1655431 [1], + // respectively, where the second instruction of an aese/aesmc + // instruction pair may execute twice if an interrupt is taken right + // after the first instruction consumes an input register of which a + // single 32-bit lane has been updated the last time it was modified. + // + // This function uses a counter in one 32-bit lane. The vmov lines + // could write to v1.16b and v18.16b directly, but that trips this bugs. + // We write to v6.16b and copy to the final register as a workaround. + // + // [0] ARM-EPM-049219 v23 Cortex-A57 MPCore Software Developers Errata Notice + // [1] ARM-EPM-012079 v11.0 Cortex-A72 MPCore Software Developers Errata Notice +#ifndef __AARCH64EB__ + rev w8, w8 +#endif + add w10, w8, #1 + orr v6.16b,v0.16b,v0.16b + rev w10, w10 + mov v6.s[3],w10 + add w8, w8, #2 + orr v1.16b,v6.16b,v6.16b + b.ls .Lctr32_tail + rev w12, w8 + mov v6.s[3],w12 + sub x2,x2,#3 // bias + orr v18.16b,v6.16b,v6.16b + b .Loop3x_ctr32 + +.align 4 +.Loop3x_ctr32: + aese v0.16b,v16.16b + aesmc v0.16b,v0.16b + aese v1.16b,v16.16b + aesmc v1.16b,v1.16b + aese v18.16b,v16.16b + aesmc v18.16b,v18.16b + ld1 {v16.4s},[x7],#16 + subs w6,w6,#2 + aese v0.16b,v17.16b + aesmc v0.16b,v0.16b + aese v1.16b,v17.16b + aesmc v1.16b,v1.16b + aese v18.16b,v17.16b + aesmc v18.16b,v18.16b + ld1 {v17.4s},[x7],#16 + b.gt .Loop3x_ctr32 + + aese v0.16b,v16.16b + aesmc v4.16b,v0.16b + aese v1.16b,v16.16b + aesmc v5.16b,v1.16b + ld1 {v2.16b},[x0],#16 + add w9,w8,#1 + aese v18.16b,v16.16b + aesmc v18.16b,v18.16b + ld1 {v3.16b},[x0],#16 + rev w9,w9 + aese v4.16b,v17.16b + aesmc v4.16b,v4.16b + aese v5.16b,v17.16b + aesmc v5.16b,v5.16b + ld1 {v19.16b},[x0],#16 + mov x7,x3 + aese v18.16b,v17.16b + aesmc v17.16b,v18.16b + aese v4.16b,v20.16b + aesmc v4.16b,v4.16b + aese v5.16b,v20.16b + aesmc v5.16b,v5.16b + eor v2.16b,v2.16b,v7.16b + add w10,w8,#2 + aese v17.16b,v20.16b + aesmc v17.16b,v17.16b + eor v3.16b,v3.16b,v7.16b + add w8,w8,#3 + aese v4.16b,v21.16b + aesmc v4.16b,v4.16b + aese v5.16b,v21.16b + aesmc v5.16b,v5.16b + // Note the logic to update v0.16b, v1.16b, and v1.16b is written to work + // around a bug in ARM Cortex-A57 and Cortex-A72 cores running in + // 32-bit mode. See the comment above. + eor v19.16b,v19.16b,v7.16b + mov v6.s[3], w9 + aese v17.16b,v21.16b + aesmc v17.16b,v17.16b + orr v0.16b,v6.16b,v6.16b + rev w10,w10 + aese v4.16b,v22.16b + aesmc v4.16b,v4.16b + mov v6.s[3], w10 + rev w12,w8 + aese v5.16b,v22.16b + aesmc v5.16b,v5.16b + orr v1.16b,v6.16b,v6.16b + mov v6.s[3], w12 + aese v17.16b,v22.16b + aesmc v17.16b,v17.16b + orr v18.16b,v6.16b,v6.16b + subs x2,x2,#3 + aese v4.16b,v23.16b + aese v5.16b,v23.16b + aese v17.16b,v23.16b + + eor v2.16b,v2.16b,v4.16b + ld1 {v16.4s},[x7],#16 // re-pre-load rndkey[0] + st1 {v2.16b},[x1],#16 + eor v3.16b,v3.16b,v5.16b + mov w6,w5 + st1 {v3.16b},[x1],#16 + eor v19.16b,v19.16b,v17.16b + ld1 {v17.4s},[x7],#16 // re-pre-load rndkey[1] + st1 {v19.16b},[x1],#16 + b.hs .Loop3x_ctr32 + + adds x2,x2,#3 + b.eq .Lctr32_done + cmp x2,#1 + mov x12,#16 + csel x12,xzr,x12,eq + +.Lctr32_tail: + aese v0.16b,v16.16b + aesmc v0.16b,v0.16b + aese v1.16b,v16.16b + aesmc v1.16b,v1.16b + ld1 {v16.4s},[x7],#16 + subs w6,w6,#2 + aese v0.16b,v17.16b + aesmc v0.16b,v0.16b + aese v1.16b,v17.16b + aesmc v1.16b,v1.16b + ld1 {v17.4s},[x7],#16 + b.gt .Lctr32_tail + + aese v0.16b,v16.16b + aesmc v0.16b,v0.16b + aese v1.16b,v16.16b + aesmc v1.16b,v1.16b + aese v0.16b,v17.16b + aesmc v0.16b,v0.16b + aese v1.16b,v17.16b + aesmc v1.16b,v1.16b + ld1 {v2.16b},[x0],x12 + aese v0.16b,v20.16b + aesmc v0.16b,v0.16b + aese v1.16b,v20.16b + aesmc v1.16b,v1.16b + ld1 {v3.16b},[x0] + aese v0.16b,v21.16b + aesmc v0.16b,v0.16b + aese v1.16b,v21.16b + aesmc v1.16b,v1.16b + eor v2.16b,v2.16b,v7.16b + aese v0.16b,v22.16b + aesmc v0.16b,v0.16b + aese v1.16b,v22.16b + aesmc v1.16b,v1.16b + eor v3.16b,v3.16b,v7.16b + aese v0.16b,v23.16b + aese v1.16b,v23.16b + + cmp x2,#1 + eor v2.16b,v2.16b,v0.16b + eor v3.16b,v3.16b,v1.16b + st1 {v2.16b},[x1],#16 + b.eq .Lctr32_done + st1 {v3.16b},[x1] + +.Lctr32_done: + ldr x29,[sp],#16 + ret +.size aes_hw_ctr32_encrypt_blocks,.-aes_hw_ctr32_encrypt_blocks +#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__ELF__) diff --git a/http/vendor/ring/pregenerated/aesv8-armx-win64.S b/http/vendor/ring/pregenerated/aesv8-armx-win64.S new file mode 100644 index 0000000..70cc642 --- /dev/null +++ b/http/vendor/ring/pregenerated/aesv8-armx-win64.S @@ -0,0 +1,357 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(_WIN32) +#if __ARM_MAX_ARCH__>=7 +.text +.arch armv8-a+crypto +.section .rodata +.align 5 +Lrcon: +.long 0x01,0x01,0x01,0x01 +.long 0x0c0f0e0d,0x0c0f0e0d,0x0c0f0e0d,0x0c0f0e0d // rotate-n-splat +.long 0x1b,0x1b,0x1b,0x1b + +.text + +.globl aes_hw_set_encrypt_key + +.def aes_hw_set_encrypt_key + .type 32 +.endef +.align 5 +aes_hw_set_encrypt_key: +Lenc_key: + // Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later. + AARCH64_VALID_CALL_TARGET + stp x29,x30,[sp,#-16]! + add x29,sp,#0 + mov x3,#-2 + cmp w1,#128 + b.lt Lenc_key_abort + cmp w1,#256 + b.gt Lenc_key_abort + tst w1,#0x3f + b.ne Lenc_key_abort + + adrp x3,Lrcon + add x3,x3,:lo12:Lrcon + cmp w1,#192 + + eor v0.16b,v0.16b,v0.16b + ld1 {v3.16b},[x0],#16 + mov w1,#8 // reuse w1 + ld1 {v1.4s,v2.4s},[x3],#32 + + b.lt Loop128 + // 192-bit key support was removed. + b L256 + +.align 4 +Loop128: + tbl v6.16b,{v3.16b},v2.16b + ext v5.16b,v0.16b,v3.16b,#12 + st1 {v3.4s},[x2],#16 + aese v6.16b,v0.16b + subs w1,w1,#1 + + eor v3.16b,v3.16b,v5.16b + ext v5.16b,v0.16b,v5.16b,#12 + eor v3.16b,v3.16b,v5.16b + ext v5.16b,v0.16b,v5.16b,#12 + eor v6.16b,v6.16b,v1.16b + eor v3.16b,v3.16b,v5.16b + shl v1.16b,v1.16b,#1 + eor v3.16b,v3.16b,v6.16b + b.ne Loop128 + + ld1 {v1.4s},[x3] + + tbl v6.16b,{v3.16b},v2.16b + ext v5.16b,v0.16b,v3.16b,#12 + st1 {v3.4s},[x2],#16 + aese v6.16b,v0.16b + + eor v3.16b,v3.16b,v5.16b + ext v5.16b,v0.16b,v5.16b,#12 + eor v3.16b,v3.16b,v5.16b + ext v5.16b,v0.16b,v5.16b,#12 + eor v6.16b,v6.16b,v1.16b + eor v3.16b,v3.16b,v5.16b + shl v1.16b,v1.16b,#1 + eor v3.16b,v3.16b,v6.16b + + tbl v6.16b,{v3.16b},v2.16b + ext v5.16b,v0.16b,v3.16b,#12 + st1 {v3.4s},[x2],#16 + aese v6.16b,v0.16b + + eor v3.16b,v3.16b,v5.16b + ext v5.16b,v0.16b,v5.16b,#12 + eor v3.16b,v3.16b,v5.16b + ext v5.16b,v0.16b,v5.16b,#12 + eor v6.16b,v6.16b,v1.16b + eor v3.16b,v3.16b,v5.16b + eor v3.16b,v3.16b,v6.16b + st1 {v3.4s},[x2] + add x2,x2,#0x50 + + mov w12,#10 + b Ldone + +// 192-bit key support was removed. + +.align 4 +L256: + ld1 {v4.16b},[x0] + mov w1,#7 + mov w12,#14 + st1 {v3.4s},[x2],#16 + +Loop256: + tbl v6.16b,{v4.16b},v2.16b + ext v5.16b,v0.16b,v3.16b,#12 + st1 {v4.4s},[x2],#16 + aese v6.16b,v0.16b + subs w1,w1,#1 + + eor v3.16b,v3.16b,v5.16b + ext v5.16b,v0.16b,v5.16b,#12 + eor v3.16b,v3.16b,v5.16b + ext v5.16b,v0.16b,v5.16b,#12 + eor v6.16b,v6.16b,v1.16b + eor v3.16b,v3.16b,v5.16b + shl v1.16b,v1.16b,#1 + eor v3.16b,v3.16b,v6.16b + st1 {v3.4s},[x2],#16 + b.eq Ldone + + dup v6.4s,v3.s[3] // just splat + ext v5.16b,v0.16b,v4.16b,#12 + aese v6.16b,v0.16b + + eor v4.16b,v4.16b,v5.16b + ext v5.16b,v0.16b,v5.16b,#12 + eor v4.16b,v4.16b,v5.16b + ext v5.16b,v0.16b,v5.16b,#12 + eor v4.16b,v4.16b,v5.16b + + eor v4.16b,v4.16b,v6.16b + b Loop256 + +Ldone: + str w12,[x2] + mov x3,#0 + +Lenc_key_abort: + mov x0,x3 // return value + ldr x29,[sp],#16 + ret + +.globl aes_hw_ctr32_encrypt_blocks + +.def aes_hw_ctr32_encrypt_blocks + .type 32 +.endef +.align 5 +aes_hw_ctr32_encrypt_blocks: + // Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later. + AARCH64_VALID_CALL_TARGET + stp x29,x30,[sp,#-16]! + add x29,sp,#0 + ldr w5,[x3,#240] + + ldr w8, [x4, #12] + ld1 {v0.4s},[x4] + + ld1 {v16.4s,v17.4s},[x3] // load key schedule... + sub w5,w5,#4 + mov x12,#16 + cmp x2,#2 + add x7,x3,x5,lsl#4 // pointer to last 5 round keys + sub w5,w5,#2 + ld1 {v20.4s,v21.4s},[x7],#32 + ld1 {v22.4s,v23.4s},[x7],#32 + ld1 {v7.4s},[x7] + add x7,x3,#32 + mov w6,w5 + csel x12,xzr,x12,lo + + // ARM Cortex-A57 and Cortex-A72 cores running in 32-bit mode are + // affected by silicon errata #1742098 [0] and #1655431 [1], + // respectively, where the second instruction of an aese/aesmc + // instruction pair may execute twice if an interrupt is taken right + // after the first instruction consumes an input register of which a + // single 32-bit lane has been updated the last time it was modified. + // + // This function uses a counter in one 32-bit lane. The vmov lines + // could write to v1.16b and v18.16b directly, but that trips this bugs. + // We write to v6.16b and copy to the final register as a workaround. + // + // [0] ARM-EPM-049219 v23 Cortex-A57 MPCore Software Developers Errata Notice + // [1] ARM-EPM-012079 v11.0 Cortex-A72 MPCore Software Developers Errata Notice +#ifndef __AARCH64EB__ + rev w8, w8 +#endif + add w10, w8, #1 + orr v6.16b,v0.16b,v0.16b + rev w10, w10 + mov v6.s[3],w10 + add w8, w8, #2 + orr v1.16b,v6.16b,v6.16b + b.ls Lctr32_tail + rev w12, w8 + mov v6.s[3],w12 + sub x2,x2,#3 // bias + orr v18.16b,v6.16b,v6.16b + b Loop3x_ctr32 + +.align 4 +Loop3x_ctr32: + aese v0.16b,v16.16b + aesmc v0.16b,v0.16b + aese v1.16b,v16.16b + aesmc v1.16b,v1.16b + aese v18.16b,v16.16b + aesmc v18.16b,v18.16b + ld1 {v16.4s},[x7],#16 + subs w6,w6,#2 + aese v0.16b,v17.16b + aesmc v0.16b,v0.16b + aese v1.16b,v17.16b + aesmc v1.16b,v1.16b + aese v18.16b,v17.16b + aesmc v18.16b,v18.16b + ld1 {v17.4s},[x7],#16 + b.gt Loop3x_ctr32 + + aese v0.16b,v16.16b + aesmc v4.16b,v0.16b + aese v1.16b,v16.16b + aesmc v5.16b,v1.16b + ld1 {v2.16b},[x0],#16 + add w9,w8,#1 + aese v18.16b,v16.16b + aesmc v18.16b,v18.16b + ld1 {v3.16b},[x0],#16 + rev w9,w9 + aese v4.16b,v17.16b + aesmc v4.16b,v4.16b + aese v5.16b,v17.16b + aesmc v5.16b,v5.16b + ld1 {v19.16b},[x0],#16 + mov x7,x3 + aese v18.16b,v17.16b + aesmc v17.16b,v18.16b + aese v4.16b,v20.16b + aesmc v4.16b,v4.16b + aese v5.16b,v20.16b + aesmc v5.16b,v5.16b + eor v2.16b,v2.16b,v7.16b + add w10,w8,#2 + aese v17.16b,v20.16b + aesmc v17.16b,v17.16b + eor v3.16b,v3.16b,v7.16b + add w8,w8,#3 + aese v4.16b,v21.16b + aesmc v4.16b,v4.16b + aese v5.16b,v21.16b + aesmc v5.16b,v5.16b + // Note the logic to update v0.16b, v1.16b, and v1.16b is written to work + // around a bug in ARM Cortex-A57 and Cortex-A72 cores running in + // 32-bit mode. See the comment above. + eor v19.16b,v19.16b,v7.16b + mov v6.s[3], w9 + aese v17.16b,v21.16b + aesmc v17.16b,v17.16b + orr v0.16b,v6.16b,v6.16b + rev w10,w10 + aese v4.16b,v22.16b + aesmc v4.16b,v4.16b + mov v6.s[3], w10 + rev w12,w8 + aese v5.16b,v22.16b + aesmc v5.16b,v5.16b + orr v1.16b,v6.16b,v6.16b + mov v6.s[3], w12 + aese v17.16b,v22.16b + aesmc v17.16b,v17.16b + orr v18.16b,v6.16b,v6.16b + subs x2,x2,#3 + aese v4.16b,v23.16b + aese v5.16b,v23.16b + aese v17.16b,v23.16b + + eor v2.16b,v2.16b,v4.16b + ld1 {v16.4s},[x7],#16 // re-pre-load rndkey[0] + st1 {v2.16b},[x1],#16 + eor v3.16b,v3.16b,v5.16b + mov w6,w5 + st1 {v3.16b},[x1],#16 + eor v19.16b,v19.16b,v17.16b + ld1 {v17.4s},[x7],#16 // re-pre-load rndkey[1] + st1 {v19.16b},[x1],#16 + b.hs Loop3x_ctr32 + + adds x2,x2,#3 + b.eq Lctr32_done + cmp x2,#1 + mov x12,#16 + csel x12,xzr,x12,eq + +Lctr32_tail: + aese v0.16b,v16.16b + aesmc v0.16b,v0.16b + aese v1.16b,v16.16b + aesmc v1.16b,v1.16b + ld1 {v16.4s},[x7],#16 + subs w6,w6,#2 + aese v0.16b,v17.16b + aesmc v0.16b,v0.16b + aese v1.16b,v17.16b + aesmc v1.16b,v1.16b + ld1 {v17.4s},[x7],#16 + b.gt Lctr32_tail + + aese v0.16b,v16.16b + aesmc v0.16b,v0.16b + aese v1.16b,v16.16b + aesmc v1.16b,v1.16b + aese v0.16b,v17.16b + aesmc v0.16b,v0.16b + aese v1.16b,v17.16b + aesmc v1.16b,v1.16b + ld1 {v2.16b},[x0],x12 + aese v0.16b,v20.16b + aesmc v0.16b,v0.16b + aese v1.16b,v20.16b + aesmc v1.16b,v1.16b + ld1 {v3.16b},[x0] + aese v0.16b,v21.16b + aesmc v0.16b,v0.16b + aese v1.16b,v21.16b + aesmc v1.16b,v1.16b + eor v2.16b,v2.16b,v7.16b + aese v0.16b,v22.16b + aesmc v0.16b,v0.16b + aese v1.16b,v22.16b + aesmc v1.16b,v1.16b + eor v3.16b,v3.16b,v7.16b + aese v0.16b,v23.16b + aese v1.16b,v23.16b + + cmp x2,#1 + eor v2.16b,v2.16b,v0.16b + eor v3.16b,v3.16b,v1.16b + st1 {v2.16b},[x1],#16 + b.eq Lctr32_done + st1 {v3.16b},[x1] + +Lctr32_done: + ldr x29,[sp],#16 + ret + +#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(_WIN32) diff --git a/http/vendor/ring/pregenerated/aesv8-gcm-armv8-ios64.S b/http/vendor/ring/pregenerated/aesv8-gcm-armv8-ios64.S new file mode 100644 index 0000000..1450b89 --- /dev/null +++ b/http/vendor/ring/pregenerated/aesv8-gcm-armv8-ios64.S @@ -0,0 +1,1554 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__APPLE__) +#if __ARM_MAX_ARCH__ >= 8 + + +.text +.globl _aes_gcm_enc_kernel +.private_extern _aes_gcm_enc_kernel + +.align 4 +_aes_gcm_enc_kernel: + AARCH64_SIGN_LINK_REGISTER + stp x29, x30, [sp, #-128]! + mov x29, sp + stp x19, x20, [sp, #16] + mov x16, x4 + mov x8, x5 + stp x21, x22, [sp, #32] + stp x23, x24, [sp, #48] + stp d8, d9, [sp, #64] + stp d10, d11, [sp, #80] + stp d12, d13, [sp, #96] + stp d14, d15, [sp, #112] + ldr w17, [x8, #240] + add x19, x8, x17, lsl #4 // borrow input_l1 for last key + ldp x13, x14, [x19] // load round N keys + ldr q31, [x19, #-16] // load round N-1 keys + add x4, x0, x1, lsr #3 // end_input_ptr + lsr x5, x1, #3 // byte_len + mov x15, x5 + ldp x10, x11, [x16] // ctr96_b64, ctr96_t32 + ld1 { v0.16b}, [x16] // special case vector load initial counter so we can start first AES block as quickly as possible + sub x5, x5, #1 // byte_len - 1 + ldr q18, [x8, #0] // load rk0 + and x5, x5, #0xffffffffffffffc0 // number of bytes to be processed in main loop (at least 1 byte must be handled by tail) + ldr q25, [x8, #112] // load rk7 + add x5, x5, x0 + lsr x12, x11, #32 + fmov d2, x10 // CTR block 2 + orr w11, w11, w11 + rev w12, w12 // rev_ctr32 + fmov d1, x10 // CTR block 1 + aese v0.16b, v18.16b + aesmc v0.16b, v0.16b // AES block 0 - round 0 + add w12, w12, #1 // increment rev_ctr32 + rev w9, w12 // CTR block 1 + fmov d3, x10 // CTR block 3 + orr x9, x11, x9, lsl #32 // CTR block 1 + add w12, w12, #1 // CTR block 1 + ldr q19, [x8, #16] // load rk1 + fmov v1.d[1], x9 // CTR block 1 + rev w9, w12 // CTR block 2 + add w12, w12, #1 // CTR block 2 + orr x9, x11, x9, lsl #32 // CTR block 2 + ldr q20, [x8, #32] // load rk2 + fmov v2.d[1], x9 // CTR block 2 + rev w9, w12 // CTR block 3 + aese v0.16b, v19.16b + aesmc v0.16b, v0.16b // AES block 0 - round 1 + orr x9, x11, x9, lsl #32 // CTR block 3 + fmov v3.d[1], x9 // CTR block 3 + aese v1.16b, v18.16b + aesmc v1.16b, v1.16b // AES block 1 - round 0 + ldr q21, [x8, #48] // load rk3 + aese v0.16b, v20.16b + aesmc v0.16b, v0.16b // AES block 0 - round 2 + ldr q24, [x8, #96] // load rk6 + aese v2.16b, v18.16b + aesmc v2.16b, v2.16b // AES block 2 - round 0 + ldr q23, [x8, #80] // load rk5 + aese v1.16b, v19.16b + aesmc v1.16b, v1.16b // AES block 1 - round 1 + ldr q14, [x6, #48] // load h3l | h3h + ext v14.16b, v14.16b, v14.16b, #8 + aese v3.16b, v18.16b + aesmc v3.16b, v3.16b // AES block 3 - round 0 + aese v2.16b, v19.16b + aesmc v2.16b, v2.16b // AES block 2 - round 1 + ldr q22, [x8, #64] // load rk4 + aese v1.16b, v20.16b + aesmc v1.16b, v1.16b // AES block 1 - round 2 + ldr q13, [x6, #32] // load h2l | h2h + ext v13.16b, v13.16b, v13.16b, #8 + aese v3.16b, v19.16b + aesmc v3.16b, v3.16b // AES block 3 - round 1 + ldr q30, [x8, #192] // load rk12 + aese v2.16b, v20.16b + aesmc v2.16b, v2.16b // AES block 2 - round 2 + ldr q15, [x6, #80] // load h4l | h4h + ext v15.16b, v15.16b, v15.16b, #8 + aese v1.16b, v21.16b + aesmc v1.16b, v1.16b // AES block 1 - round 3 + ldr q29, [x8, #176] // load rk11 + aese v3.16b, v20.16b + aesmc v3.16b, v3.16b // AES block 3 - round 2 + ldr q26, [x8, #128] // load rk8 + aese v2.16b, v21.16b + aesmc v2.16b, v2.16b // AES block 2 - round 3 + add w12, w12, #1 // CTR block 3 + aese v0.16b, v21.16b + aesmc v0.16b, v0.16b // AES block 0 - round 3 + aese v3.16b, v21.16b + aesmc v3.16b, v3.16b // AES block 3 - round 3 + ld1 { v11.16b}, [x3] + ext v11.16b, v11.16b, v11.16b, #8 + rev64 v11.16b, v11.16b + aese v2.16b, v22.16b + aesmc v2.16b, v2.16b // AES block 2 - round 4 + aese v0.16b, v22.16b + aesmc v0.16b, v0.16b // AES block 0 - round 4 + aese v1.16b, v22.16b + aesmc v1.16b, v1.16b // AES block 1 - round 4 + aese v3.16b, v22.16b + aesmc v3.16b, v3.16b // AES block 3 - round 4 + cmp x17, #12 // setup flags for AES-128/192/256 check + aese v0.16b, v23.16b + aesmc v0.16b, v0.16b // AES block 0 - round 5 + aese v1.16b, v23.16b + aesmc v1.16b, v1.16b // AES block 1 - round 5 + aese v3.16b, v23.16b + aesmc v3.16b, v3.16b // AES block 3 - round 5 + aese v2.16b, v23.16b + aesmc v2.16b, v2.16b // AES block 2 - round 5 + aese v1.16b, v24.16b + aesmc v1.16b, v1.16b // AES block 1 - round 6 + trn2 v17.2d, v14.2d, v15.2d // h4l | h3l + aese v3.16b, v24.16b + aesmc v3.16b, v3.16b // AES block 3 - round 6 + ldr q27, [x8, #144] // load rk9 + aese v0.16b, v24.16b + aesmc v0.16b, v0.16b // AES block 0 - round 6 + ldr q12, [x6] // load h1l | h1h + ext v12.16b, v12.16b, v12.16b, #8 + aese v2.16b, v24.16b + aesmc v2.16b, v2.16b // AES block 2 - round 6 + ldr q28, [x8, #160] // load rk10 + aese v1.16b, v25.16b + aesmc v1.16b, v1.16b // AES block 1 - round 7 + trn1 v9.2d, v14.2d, v15.2d // h4h | h3h + aese v0.16b, v25.16b + aesmc v0.16b, v0.16b // AES block 0 - round 7 + aese v2.16b, v25.16b + aesmc v2.16b, v2.16b // AES block 2 - round 7 + aese v3.16b, v25.16b + aesmc v3.16b, v3.16b // AES block 3 - round 7 + trn2 v16.2d, v12.2d, v13.2d // h2l | h1l + aese v1.16b, v26.16b + aesmc v1.16b, v1.16b // AES block 1 - round 8 + aese v2.16b, v26.16b + aesmc v2.16b, v2.16b // AES block 2 - round 8 + aese v3.16b, v26.16b + aesmc v3.16b, v3.16b // AES block 3 - round 8 + aese v0.16b, v26.16b + aesmc v0.16b, v0.16b // AES block 0 - round 8 + b.lt Lenc_finish_first_blocks // branch if AES-128 + + aese v1.16b, v27.16b + aesmc v1.16b, v1.16b // AES block 1 - round 9 + aese v2.16b, v27.16b + aesmc v2.16b, v2.16b // AES block 2 - round 9 + aese v3.16b, v27.16b + aesmc v3.16b, v3.16b // AES block 3 - round 9 + aese v0.16b, v27.16b + aesmc v0.16b, v0.16b // AES block 0 - round 9 + aese v1.16b, v28.16b + aesmc v1.16b, v1.16b // AES block 1 - round 10 + aese v2.16b, v28.16b + aesmc v2.16b, v2.16b // AES block 2 - round 10 + aese v3.16b, v28.16b + aesmc v3.16b, v3.16b // AES block 3 - round 10 + aese v0.16b, v28.16b + aesmc v0.16b, v0.16b // AES block 0 - round 10 + b.eq Lenc_finish_first_blocks // branch if AES-192 + + aese v1.16b, v29.16b + aesmc v1.16b, v1.16b // AES block 1 - round 11 + aese v2.16b, v29.16b + aesmc v2.16b, v2.16b // AES block 2 - round 11 + aese v0.16b, v29.16b + aesmc v0.16b, v0.16b // AES block 0 - round 11 + aese v3.16b, v29.16b + aesmc v3.16b, v3.16b // AES block 3 - round 11 + aese v1.16b, v30.16b + aesmc v1.16b, v1.16b // AES block 1 - round 12 + aese v2.16b, v30.16b + aesmc v2.16b, v2.16b // AES block 2 - round 12 + aese v0.16b, v30.16b + aesmc v0.16b, v0.16b // AES block 0 - round 12 + aese v3.16b, v30.16b + aesmc v3.16b, v3.16b // AES block 3 - round 12 + +Lenc_finish_first_blocks: + cmp x0, x5 // check if we have <= 4 blocks + eor v17.16b, v17.16b, v9.16b // h4k | h3k + aese v2.16b, v31.16b // AES block 2 - round N-1 + trn1 v8.2d, v12.2d, v13.2d // h2h | h1h + aese v1.16b, v31.16b // AES block 1 - round N-1 + aese v0.16b, v31.16b // AES block 0 - round N-1 + aese v3.16b, v31.16b // AES block 3 - round N-1 + eor v16.16b, v16.16b, v8.16b // h2k | h1k + b.ge Lenc_tail // handle tail + + ldp x19, x20, [x0, #16] // AES block 1 - load plaintext + rev w9, w12 // CTR block 4 + ldp x6, x7, [x0, #0] // AES block 0 - load plaintext + ldp x23, x24, [x0, #48] // AES block 3 - load plaintext + ldp x21, x22, [x0, #32] // AES block 2 - load plaintext + add x0, x0, #64 // AES input_ptr update + eor x19, x19, x13 // AES block 1 - round N low + eor x20, x20, x14 // AES block 1 - round N high + fmov d5, x19 // AES block 1 - mov low + eor x6, x6, x13 // AES block 0 - round N low + eor x7, x7, x14 // AES block 0 - round N high + eor x24, x24, x14 // AES block 3 - round N high + fmov d4, x6 // AES block 0 - mov low + cmp x0, x5 // check if we have <= 8 blocks + fmov v4.d[1], x7 // AES block 0 - mov high + eor x23, x23, x13 // AES block 3 - round N low + eor x21, x21, x13 // AES block 2 - round N low + fmov v5.d[1], x20 // AES block 1 - mov high + fmov d6, x21 // AES block 2 - mov low + add w12, w12, #1 // CTR block 4 + orr x9, x11, x9, lsl #32 // CTR block 4 + fmov d7, x23 // AES block 3 - mov low + eor x22, x22, x14 // AES block 2 - round N high + fmov v6.d[1], x22 // AES block 2 - mov high + eor v4.16b, v4.16b, v0.16b // AES block 0 - result + fmov d0, x10 // CTR block 4 + fmov v0.d[1], x9 // CTR block 4 + rev w9, w12 // CTR block 5 + add w12, w12, #1 // CTR block 5 + eor v5.16b, v5.16b, v1.16b // AES block 1 - result + fmov d1, x10 // CTR block 5 + orr x9, x11, x9, lsl #32 // CTR block 5 + fmov v1.d[1], x9 // CTR block 5 + rev w9, w12 // CTR block 6 + st1 { v4.16b}, [x2], #16 // AES block 0 - store result + fmov v7.d[1], x24 // AES block 3 - mov high + orr x9, x11, x9, lsl #32 // CTR block 6 + eor v6.16b, v6.16b, v2.16b // AES block 2 - result + st1 { v5.16b}, [x2], #16 // AES block 1 - store result + add w12, w12, #1 // CTR block 6 + fmov d2, x10 // CTR block 6 + fmov v2.d[1], x9 // CTR block 6 + st1 { v6.16b}, [x2], #16 // AES block 2 - store result + rev w9, w12 // CTR block 7 + orr x9, x11, x9, lsl #32 // CTR block 7 + eor v7.16b, v7.16b, v3.16b // AES block 3 - result + st1 { v7.16b}, [x2], #16 // AES block 3 - store result + b.ge Lenc_prepretail // do prepretail + +Lenc_main_loop: // main loop start + aese v0.16b, v18.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 0 + rev64 v4.16b, v4.16b // GHASH block 4k (only t0 is free) + aese v1.16b, v18.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 0 + fmov d3, x10 // CTR block 4k+3 + aese v2.16b, v18.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 0 + ext v11.16b, v11.16b, v11.16b, #8 // PRE 0 + aese v0.16b, v19.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 1 + fmov v3.d[1], x9 // CTR block 4k+3 + aese v1.16b, v19.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 1 + ldp x23, x24, [x0, #48] // AES block 4k+7 - load plaintext + aese v2.16b, v19.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 1 + ldp x21, x22, [x0, #32] // AES block 4k+6 - load plaintext + aese v0.16b, v20.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 2 + eor v4.16b, v4.16b, v11.16b // PRE 1 + aese v1.16b, v20.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 2 + aese v3.16b, v18.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 0 + eor x23, x23, x13 // AES block 4k+7 - round N low + aese v0.16b, v21.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 3 + mov d10, v17.d[1] // GHASH block 4k - mid + pmull2 v9.1q, v4.2d, v15.2d // GHASH block 4k - high + eor x22, x22, x14 // AES block 4k+6 - round N high + mov d8, v4.d[1] // GHASH block 4k - mid + aese v3.16b, v19.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 1 + rev64 v5.16b, v5.16b // GHASH block 4k+1 (t0 and t1 free) + aese v0.16b, v22.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 4 + pmull v11.1q, v4.1d, v15.1d // GHASH block 4k - low + eor v8.8b, v8.8b, v4.8b // GHASH block 4k - mid + aese v2.16b, v20.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 2 + aese v0.16b, v23.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 5 + rev64 v7.16b, v7.16b // GHASH block 4k+3 (t0, t1, t2 and t3 free) + pmull2 v4.1q, v5.2d, v14.2d // GHASH block 4k+1 - high + pmull v10.1q, v8.1d, v10.1d // GHASH block 4k - mid + rev64 v6.16b, v6.16b // GHASH block 4k+2 (t0, t1, and t2 free) + pmull v8.1q, v5.1d, v14.1d // GHASH block 4k+1 - low + eor v9.16b, v9.16b, v4.16b // GHASH block 4k+1 - high + mov d4, v5.d[1] // GHASH block 4k+1 - mid + aese v1.16b, v21.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 3 + aese v3.16b, v20.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 2 + eor v11.16b, v11.16b, v8.16b // GHASH block 4k+1 - low + aese v2.16b, v21.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 3 + aese v1.16b, v22.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 4 + mov d8, v6.d[1] // GHASH block 4k+2 - mid + aese v3.16b, v21.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 3 + eor v4.8b, v4.8b, v5.8b // GHASH block 4k+1 - mid + aese v2.16b, v22.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 4 + aese v0.16b, v24.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 6 + eor v8.8b, v8.8b, v6.8b // GHASH block 4k+2 - mid + aese v3.16b, v22.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 4 + pmull v4.1q, v4.1d, v17.1d // GHASH block 4k+1 - mid + aese v0.16b, v25.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 7 + aese v3.16b, v23.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 5 + ins v8.d[1], v8.d[0] // GHASH block 4k+2 - mid + aese v1.16b, v23.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 5 + aese v0.16b, v26.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 8 + aese v2.16b, v23.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 5 + aese v1.16b, v24.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 6 + eor v10.16b, v10.16b, v4.16b // GHASH block 4k+1 - mid + pmull2 v4.1q, v6.2d, v13.2d // GHASH block 4k+2 - high + pmull v5.1q, v6.1d, v13.1d // GHASH block 4k+2 - low + aese v1.16b, v25.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 7 + pmull v6.1q, v7.1d, v12.1d // GHASH block 4k+3 - low + eor v9.16b, v9.16b, v4.16b // GHASH block 4k+2 - high + aese v3.16b, v24.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 6 + ldp x19, x20, [x0, #16] // AES block 4k+5 - load plaintext + aese v1.16b, v26.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 8 + mov d4, v7.d[1] // GHASH block 4k+3 - mid + aese v2.16b, v24.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 6 + eor v11.16b, v11.16b, v5.16b // GHASH block 4k+2 - low + pmull2 v8.1q, v8.2d, v16.2d // GHASH block 4k+2 - mid + pmull2 v5.1q, v7.2d, v12.2d // GHASH block 4k+3 - high + eor v4.8b, v4.8b, v7.8b // GHASH block 4k+3 - mid + aese v2.16b, v25.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 7 + eor x19, x19, x13 // AES block 4k+5 - round N low + aese v2.16b, v26.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 8 + eor v10.16b, v10.16b, v8.16b // GHASH block 4k+2 - mid + aese v3.16b, v25.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 7 + eor x21, x21, x13 // AES block 4k+6 - round N low + aese v3.16b, v26.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 8 + movi v8.8b, #0xc2 + pmull v4.1q, v4.1d, v16.1d // GHASH block 4k+3 - mid + eor v9.16b, v9.16b, v5.16b // GHASH block 4k+3 - high + cmp x17, #12 // setup flags for AES-128/192/256 check + fmov d5, x19 // AES block 4k+5 - mov low + ldp x6, x7, [x0, #0] // AES block 4k+4 - load plaintext + b.lt Lenc_main_loop_continue // branch if AES-128 + + aese v1.16b, v27.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 9 + aese v0.16b, v27.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 9 + aese v2.16b, v27.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 9 + aese v3.16b, v27.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 9 + aese v0.16b, v28.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 10 + aese v1.16b, v28.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 10 + aese v2.16b, v28.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 10 + aese v3.16b, v28.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 10 + b.eq Lenc_main_loop_continue // branch if AES-192 + + aese v0.16b, v29.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 11 + aese v1.16b, v29.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 11 + aese v2.16b, v29.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 11 + aese v3.16b, v29.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 11 + aese v1.16b, v30.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 12 + aese v0.16b, v30.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 12 + aese v2.16b, v30.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 12 + aese v3.16b, v30.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 12 + +Lenc_main_loop_continue: + shl d8, d8, #56 // mod_constant + eor v11.16b, v11.16b, v6.16b // GHASH block 4k+3 - low + eor v10.16b, v10.16b, v4.16b // GHASH block 4k+3 - mid + add w12, w12, #1 // CTR block 4k+3 + eor v4.16b, v11.16b, v9.16b // MODULO - karatsuba tidy up + add x0, x0, #64 // AES input_ptr update + pmull v7.1q, v9.1d, v8.1d // MODULO - top 64b align with mid + rev w9, w12 // CTR block 4k+8 + ext v9.16b, v9.16b, v9.16b, #8 // MODULO - other top alignment + eor x6, x6, x13 // AES block 4k+4 - round N low + eor v10.16b, v10.16b, v4.16b // MODULO - karatsuba tidy up + eor x7, x7, x14 // AES block 4k+4 - round N high + fmov d4, x6 // AES block 4k+4 - mov low + orr x9, x11, x9, lsl #32 // CTR block 4k+8 + eor v7.16b, v9.16b, v7.16b // MODULO - fold into mid + eor x20, x20, x14 // AES block 4k+5 - round N high + eor x24, x24, x14 // AES block 4k+7 - round N high + add w12, w12, #1 // CTR block 4k+8 + aese v0.16b, v31.16b // AES block 4k+4 - round N-1 + fmov v4.d[1], x7 // AES block 4k+4 - mov high + eor v10.16b, v10.16b, v7.16b // MODULO - fold into mid + fmov d7, x23 // AES block 4k+7 - mov low + aese v1.16b, v31.16b // AES block 4k+5 - round N-1 + fmov v5.d[1], x20 // AES block 4k+5 - mov high + fmov d6, x21 // AES block 4k+6 - mov low + cmp x0, x5 // LOOP CONTROL + fmov v6.d[1], x22 // AES block 4k+6 - mov high + pmull v9.1q, v10.1d, v8.1d // MODULO - mid 64b align with low + eor v4.16b, v4.16b, v0.16b // AES block 4k+4 - result + fmov d0, x10 // CTR block 4k+8 + fmov v0.d[1], x9 // CTR block 4k+8 + rev w9, w12 // CTR block 4k+9 + add w12, w12, #1 // CTR block 4k+9 + eor v5.16b, v5.16b, v1.16b // AES block 4k+5 - result + fmov d1, x10 // CTR block 4k+9 + orr x9, x11, x9, lsl #32 // CTR block 4k+9 + fmov v1.d[1], x9 // CTR block 4k+9 + aese v2.16b, v31.16b // AES block 4k+6 - round N-1 + rev w9, w12 // CTR block 4k+10 + st1 { v4.16b}, [x2], #16 // AES block 4k+4 - store result + orr x9, x11, x9, lsl #32 // CTR block 4k+10 + eor v11.16b, v11.16b, v9.16b // MODULO - fold into low + fmov v7.d[1], x24 // AES block 4k+7 - mov high + ext v10.16b, v10.16b, v10.16b, #8 // MODULO - other mid alignment + st1 { v5.16b}, [x2], #16 // AES block 4k+5 - store result + add w12, w12, #1 // CTR block 4k+10 + aese v3.16b, v31.16b // AES block 4k+7 - round N-1 + eor v6.16b, v6.16b, v2.16b // AES block 4k+6 - result + fmov d2, x10 // CTR block 4k+10 + st1 { v6.16b}, [x2], #16 // AES block 4k+6 - store result + fmov v2.d[1], x9 // CTR block 4k+10 + rev w9, w12 // CTR block 4k+11 + eor v11.16b, v11.16b, v10.16b // MODULO - fold into low + orr x9, x11, x9, lsl #32 // CTR block 4k+11 + eor v7.16b, v7.16b, v3.16b // AES block 4k+7 - result + st1 { v7.16b}, [x2], #16 // AES block 4k+7 - store result + b.lt Lenc_main_loop + +Lenc_prepretail: // PREPRETAIL + aese v1.16b, v18.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 0 + rev64 v6.16b, v6.16b // GHASH block 4k+2 (t0, t1, and t2 free) + aese v2.16b, v18.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 0 + fmov d3, x10 // CTR block 4k+3 + aese v0.16b, v18.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 0 + rev64 v4.16b, v4.16b // GHASH block 4k (only t0 is free) + fmov v3.d[1], x9 // CTR block 4k+3 + ext v11.16b, v11.16b, v11.16b, #8 // PRE 0 + aese v2.16b, v19.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 1 + aese v0.16b, v19.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 1 + eor v4.16b, v4.16b, v11.16b // PRE 1 + rev64 v5.16b, v5.16b // GHASH block 4k+1 (t0 and t1 free) + aese v2.16b, v20.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 2 + aese v3.16b, v18.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 0 + mov d10, v17.d[1] // GHASH block 4k - mid + aese v1.16b, v19.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 1 + pmull v11.1q, v4.1d, v15.1d // GHASH block 4k - low + mov d8, v4.d[1] // GHASH block 4k - mid + pmull2 v9.1q, v4.2d, v15.2d // GHASH block 4k - high + aese v2.16b, v21.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 3 + aese v1.16b, v20.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 2 + eor v8.8b, v8.8b, v4.8b // GHASH block 4k - mid + aese v0.16b, v20.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 2 + aese v3.16b, v19.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 1 + aese v1.16b, v21.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 3 + pmull v10.1q, v8.1d, v10.1d // GHASH block 4k - mid + pmull2 v4.1q, v5.2d, v14.2d // GHASH block 4k+1 - high + pmull v8.1q, v5.1d, v14.1d // GHASH block 4k+1 - low + aese v3.16b, v20.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 2 + eor v9.16b, v9.16b, v4.16b // GHASH block 4k+1 - high + mov d4, v5.d[1] // GHASH block 4k+1 - mid + aese v0.16b, v21.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 3 + eor v11.16b, v11.16b, v8.16b // GHASH block 4k+1 - low + aese v3.16b, v21.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 3 + eor v4.8b, v4.8b, v5.8b // GHASH block 4k+1 - mid + mov d8, v6.d[1] // GHASH block 4k+2 - mid + aese v0.16b, v22.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 4 + rev64 v7.16b, v7.16b // GHASH block 4k+3 (t0, t1, t2 and t3 free) + aese v3.16b, v22.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 4 + pmull v4.1q, v4.1d, v17.1d // GHASH block 4k+1 - mid + eor v8.8b, v8.8b, v6.8b // GHASH block 4k+2 - mid + add w12, w12, #1 // CTR block 4k+3 + pmull v5.1q, v6.1d, v13.1d // GHASH block 4k+2 - low + aese v3.16b, v23.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 5 + aese v2.16b, v22.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 4 + eor v10.16b, v10.16b, v4.16b // GHASH block 4k+1 - mid + pmull2 v4.1q, v6.2d, v13.2d // GHASH block 4k+2 - high + eor v11.16b, v11.16b, v5.16b // GHASH block 4k+2 - low + ins v8.d[1], v8.d[0] // GHASH block 4k+2 - mid + aese v2.16b, v23.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 5 + eor v9.16b, v9.16b, v4.16b // GHASH block 4k+2 - high + mov d4, v7.d[1] // GHASH block 4k+3 - mid + aese v1.16b, v22.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 4 + pmull2 v8.1q, v8.2d, v16.2d // GHASH block 4k+2 - mid + eor v4.8b, v4.8b, v7.8b // GHASH block 4k+3 - mid + pmull2 v5.1q, v7.2d, v12.2d // GHASH block 4k+3 - high + aese v1.16b, v23.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 5 + pmull v4.1q, v4.1d, v16.1d // GHASH block 4k+3 - mid + eor v10.16b, v10.16b, v8.16b // GHASH block 4k+2 - mid + aese v0.16b, v23.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 5 + aese v1.16b, v24.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 6 + aese v2.16b, v24.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 6 + aese v0.16b, v24.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 6 + movi v8.8b, #0xc2 + aese v3.16b, v24.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 6 + aese v1.16b, v25.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 7 + eor v9.16b, v9.16b, v5.16b // GHASH block 4k+3 - high + aese v0.16b, v25.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 7 + aese v3.16b, v25.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 7 + shl d8, d8, #56 // mod_constant + aese v1.16b, v26.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 8 + eor v10.16b, v10.16b, v4.16b // GHASH block 4k+3 - mid + pmull v6.1q, v7.1d, v12.1d // GHASH block 4k+3 - low + aese v3.16b, v26.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 8 + cmp x17, #12 // setup flags for AES-128/192/256 check + aese v0.16b, v26.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 8 + eor v11.16b, v11.16b, v6.16b // GHASH block 4k+3 - low + aese v2.16b, v25.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 7 + eor v10.16b, v10.16b, v9.16b // karatsuba tidy up + aese v2.16b, v26.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 8 + pmull v4.1q, v9.1d, v8.1d + ext v9.16b, v9.16b, v9.16b, #8 + eor v10.16b, v10.16b, v11.16b + b.lt Lenc_finish_prepretail // branch if AES-128 + + aese v1.16b, v27.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 9 + aese v3.16b, v27.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 9 + aese v0.16b, v27.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 9 + aese v2.16b, v27.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 9 + aese v3.16b, v28.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 10 + aese v1.16b, v28.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 10 + aese v0.16b, v28.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 10 + aese v2.16b, v28.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 10 + b.eq Lenc_finish_prepretail // branch if AES-192 + + aese v1.16b, v29.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 11 + aese v0.16b, v29.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 11 + aese v3.16b, v29.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 11 + aese v2.16b, v29.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 11 + aese v1.16b, v30.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 12 + aese v0.16b, v30.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 12 + aese v3.16b, v30.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 12 + aese v2.16b, v30.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 12 + +Lenc_finish_prepretail: + eor v10.16b, v10.16b, v4.16b + eor v10.16b, v10.16b, v9.16b + pmull v4.1q, v10.1d, v8.1d + ext v10.16b, v10.16b, v10.16b, #8 + aese v1.16b, v31.16b // AES block 4k+5 - round N-1 + eor v11.16b, v11.16b, v4.16b + aese v3.16b, v31.16b // AES block 4k+7 - round N-1 + aese v0.16b, v31.16b // AES block 4k+4 - round N-1 + aese v2.16b, v31.16b // AES block 4k+6 - round N-1 + eor v11.16b, v11.16b, v10.16b + +Lenc_tail: // TAIL + ext v8.16b, v11.16b, v11.16b, #8 // prepare final partial tag + sub x5, x4, x0 // main_end_input_ptr is number of bytes left to process + ldp x6, x7, [x0], #16 // AES block 4k+4 - load plaintext + eor x6, x6, x13 // AES block 4k+4 - round N low + eor x7, x7, x14 // AES block 4k+4 - round N high + cmp x5, #48 + fmov d4, x6 // AES block 4k+4 - mov low + fmov v4.d[1], x7 // AES block 4k+4 - mov high + eor v5.16b, v4.16b, v0.16b // AES block 4k+4 - result + b.gt Lenc_blocks_more_than_3 + cmp x5, #32 + mov v3.16b, v2.16b + movi v11.8b, #0 + movi v9.8b, #0 + sub w12, w12, #1 + mov v2.16b, v1.16b + movi v10.8b, #0 + b.gt Lenc_blocks_more_than_2 + mov v3.16b, v1.16b + sub w12, w12, #1 + cmp x5, #16 + b.gt Lenc_blocks_more_than_1 + sub w12, w12, #1 + b Lenc_blocks_less_than_1 +Lenc_blocks_more_than_3: // blocks left > 3 + st1 { v5.16b}, [x2], #16 // AES final-3 block - store result + ldp x6, x7, [x0], #16 // AES final-2 block - load input low & high + rev64 v4.16b, v5.16b // GHASH final-3 block + eor x6, x6, x13 // AES final-2 block - round N low + eor v4.16b, v4.16b, v8.16b // feed in partial tag + eor x7, x7, x14 // AES final-2 block - round N high + mov d22, v4.d[1] // GHASH final-3 block - mid + fmov d5, x6 // AES final-2 block - mov low + fmov v5.d[1], x7 // AES final-2 block - mov high + eor v22.8b, v22.8b, v4.8b // GHASH final-3 block - mid + movi v8.8b, #0 // suppress further partial tag feed in + mov d10, v17.d[1] // GHASH final-3 block - mid + pmull v11.1q, v4.1d, v15.1d // GHASH final-3 block - low + pmull2 v9.1q, v4.2d, v15.2d // GHASH final-3 block - high + pmull v10.1q, v22.1d, v10.1d // GHASH final-3 block - mid + eor v5.16b, v5.16b, v1.16b // AES final-2 block - result +Lenc_blocks_more_than_2: // blocks left > 2 + st1 { v5.16b}, [x2], #16 // AES final-2 block - store result + ldp x6, x7, [x0], #16 // AES final-1 block - load input low & high + rev64 v4.16b, v5.16b // GHASH final-2 block + eor x6, x6, x13 // AES final-1 block - round N low + eor v4.16b, v4.16b, v8.16b // feed in partial tag + fmov d5, x6 // AES final-1 block - mov low + eor x7, x7, x14 // AES final-1 block - round N high + fmov v5.d[1], x7 // AES final-1 block - mov high + movi v8.8b, #0 // suppress further partial tag feed in + pmull2 v20.1q, v4.2d, v14.2d // GHASH final-2 block - high + mov d22, v4.d[1] // GHASH final-2 block - mid + pmull v21.1q, v4.1d, v14.1d // GHASH final-2 block - low + eor v22.8b, v22.8b, v4.8b // GHASH final-2 block - mid + eor v5.16b, v5.16b, v2.16b // AES final-1 block - result + eor v9.16b, v9.16b, v20.16b // GHASH final-2 block - high + pmull v22.1q, v22.1d, v17.1d // GHASH final-2 block - mid + eor v11.16b, v11.16b, v21.16b // GHASH final-2 block - low + eor v10.16b, v10.16b, v22.16b // GHASH final-2 block - mid +Lenc_blocks_more_than_1: // blocks left > 1 + st1 { v5.16b}, [x2], #16 // AES final-1 block - store result + rev64 v4.16b, v5.16b // GHASH final-1 block + ldp x6, x7, [x0], #16 // AES final block - load input low & high + eor v4.16b, v4.16b, v8.16b // feed in partial tag + movi v8.8b, #0 // suppress further partial tag feed in + eor x6, x6, x13 // AES final block - round N low + mov d22, v4.d[1] // GHASH final-1 block - mid + pmull2 v20.1q, v4.2d, v13.2d // GHASH final-1 block - high + eor x7, x7, x14 // AES final block - round N high + eor v22.8b, v22.8b, v4.8b // GHASH final-1 block - mid + eor v9.16b, v9.16b, v20.16b // GHASH final-1 block - high + ins v22.d[1], v22.d[0] // GHASH final-1 block - mid + fmov d5, x6 // AES final block - mov low + fmov v5.d[1], x7 // AES final block - mov high + pmull2 v22.1q, v22.2d, v16.2d // GHASH final-1 block - mid + pmull v21.1q, v4.1d, v13.1d // GHASH final-1 block - low + eor v5.16b, v5.16b, v3.16b // AES final block - result + eor v10.16b, v10.16b, v22.16b // GHASH final-1 block - mid + eor v11.16b, v11.16b, v21.16b // GHASH final-1 block - low +Lenc_blocks_less_than_1: // blocks left <= 1 + and x1, x1, #127 // bit_length %= 128 + mvn x13, xzr // rkN_l = 0xffffffffffffffff + sub x1, x1, #128 // bit_length -= 128 + neg x1, x1 // bit_length = 128 - #bits in input (in range [1,128]) + ld1 { v18.16b}, [x2] // load existing bytes where the possibly partial last block is to be stored + mvn x14, xzr // rkN_h = 0xffffffffffffffff + and x1, x1, #127 // bit_length %= 128 + lsr x14, x14, x1 // rkN_h is mask for top 64b of last block + cmp x1, #64 + csel x6, x13, x14, lt + csel x7, x14, xzr, lt + fmov d0, x6 // ctr0b is mask for last block + fmov v0.d[1], x7 + and v5.16b, v5.16b, v0.16b // possibly partial last block has zeroes in highest bits + rev64 v4.16b, v5.16b // GHASH final block + eor v4.16b, v4.16b, v8.16b // feed in partial tag + bif v5.16b, v18.16b, v0.16b // insert existing bytes in top end of result before storing + pmull2 v20.1q, v4.2d, v12.2d // GHASH final block - high + mov d8, v4.d[1] // GHASH final block - mid + rev w9, w12 + pmull v21.1q, v4.1d, v12.1d // GHASH final block - low + eor v9.16b, v9.16b, v20.16b // GHASH final block - high + eor v8.8b, v8.8b, v4.8b // GHASH final block - mid + pmull v8.1q, v8.1d, v16.1d // GHASH final block - mid + eor v11.16b, v11.16b, v21.16b // GHASH final block - low + eor v10.16b, v10.16b, v8.16b // GHASH final block - mid + movi v8.8b, #0xc2 + eor v4.16b, v11.16b, v9.16b // MODULO - karatsuba tidy up + shl d8, d8, #56 // mod_constant + eor v10.16b, v10.16b, v4.16b // MODULO - karatsuba tidy up + pmull v7.1q, v9.1d, v8.1d // MODULO - top 64b align with mid + ext v9.16b, v9.16b, v9.16b, #8 // MODULO - other top alignment + eor v10.16b, v10.16b, v7.16b // MODULO - fold into mid + eor v10.16b, v10.16b, v9.16b // MODULO - fold into mid + pmull v9.1q, v10.1d, v8.1d // MODULO - mid 64b align with low + ext v10.16b, v10.16b, v10.16b, #8 // MODULO - other mid alignment + str w9, [x16, #12] // store the updated counter + st1 { v5.16b}, [x2] // store all 16B + eor v11.16b, v11.16b, v9.16b // MODULO - fold into low + eor v11.16b, v11.16b, v10.16b // MODULO - fold into low + ext v11.16b, v11.16b, v11.16b, #8 + rev64 v11.16b, v11.16b + mov x0, x15 + st1 { v11.16b }, [x3] + ldp x19, x20, [sp, #16] + ldp x21, x22, [sp, #32] + ldp x23, x24, [sp, #48] + ldp d8, d9, [sp, #64] + ldp d10, d11, [sp, #80] + ldp d12, d13, [sp, #96] + ldp d14, d15, [sp, #112] + ldp x29, x30, [sp], #128 + AARCH64_VALIDATE_LINK_REGISTER + ret + +.globl _aes_gcm_dec_kernel +.private_extern _aes_gcm_dec_kernel + +.align 4 +_aes_gcm_dec_kernel: + AARCH64_SIGN_LINK_REGISTER + stp x29, x30, [sp, #-128]! + mov x29, sp + stp x19, x20, [sp, #16] + mov x16, x4 + mov x8, x5 + stp x21, x22, [sp, #32] + stp x23, x24, [sp, #48] + stp d8, d9, [sp, #64] + stp d10, d11, [sp, #80] + stp d12, d13, [sp, #96] + stp d14, d15, [sp, #112] + ldr w17, [x8, #240] + add x19, x8, x17, lsl #4 // borrow input_l1 for last key + ldp x13, x14, [x19] // load round N keys + ldr q31, [x19, #-16] // load round N-1 keys + lsr x5, x1, #3 // byte_len + mov x15, x5 + ldp x10, x11, [x16] // ctr96_b64, ctr96_t32 + ldr q26, [x8, #128] // load rk8 + sub x5, x5, #1 // byte_len - 1 + ldr q25, [x8, #112] // load rk7 + and x5, x5, #0xffffffffffffffc0 // number of bytes to be processed in main loop (at least 1 byte must be handled by tail) + add x4, x0, x1, lsr #3 // end_input_ptr + ldr q24, [x8, #96] // load rk6 + lsr x12, x11, #32 + ldr q23, [x8, #80] // load rk5 + orr w11, w11, w11 + ldr q21, [x8, #48] // load rk3 + add x5, x5, x0 + rev w12, w12 // rev_ctr32 + add w12, w12, #1 // increment rev_ctr32 + fmov d3, x10 // CTR block 3 + rev w9, w12 // CTR block 1 + add w12, w12, #1 // CTR block 1 + fmov d1, x10 // CTR block 1 + orr x9, x11, x9, lsl #32 // CTR block 1 + ld1 { v0.16b}, [x16] // special case vector load initial counter so we can start first AES block as quickly as possible + fmov v1.d[1], x9 // CTR block 1 + rev w9, w12 // CTR block 2 + add w12, w12, #1 // CTR block 2 + fmov d2, x10 // CTR block 2 + orr x9, x11, x9, lsl #32 // CTR block 2 + fmov v2.d[1], x9 // CTR block 2 + rev w9, w12 // CTR block 3 + orr x9, x11, x9, lsl #32 // CTR block 3 + ldr q18, [x8, #0] // load rk0 + fmov v3.d[1], x9 // CTR block 3 + add w12, w12, #1 // CTR block 3 + ldr q22, [x8, #64] // load rk4 + ldr q19, [x8, #16] // load rk1 + aese v0.16b, v18.16b + aesmc v0.16b, v0.16b // AES block 0 - round 0 + ldr q14, [x6, #48] // load h3l | h3h + ext v14.16b, v14.16b, v14.16b, #8 + aese v3.16b, v18.16b + aesmc v3.16b, v3.16b // AES block 3 - round 0 + ldr q15, [x6, #80] // load h4l | h4h + ext v15.16b, v15.16b, v15.16b, #8 + aese v1.16b, v18.16b + aesmc v1.16b, v1.16b // AES block 1 - round 0 + ldr q13, [x6, #32] // load h2l | h2h + ext v13.16b, v13.16b, v13.16b, #8 + aese v2.16b, v18.16b + aesmc v2.16b, v2.16b // AES block 2 - round 0 + ldr q20, [x8, #32] // load rk2 + aese v0.16b, v19.16b + aesmc v0.16b, v0.16b // AES block 0 - round 1 + aese v1.16b, v19.16b + aesmc v1.16b, v1.16b // AES block 1 - round 1 + ld1 { v11.16b}, [x3] + ext v11.16b, v11.16b, v11.16b, #8 + rev64 v11.16b, v11.16b + aese v2.16b, v19.16b + aesmc v2.16b, v2.16b // AES block 2 - round 1 + ldr q27, [x8, #144] // load rk9 + aese v3.16b, v19.16b + aesmc v3.16b, v3.16b // AES block 3 - round 1 + ldr q30, [x8, #192] // load rk12 + aese v0.16b, v20.16b + aesmc v0.16b, v0.16b // AES block 0 - round 2 + ldr q12, [x6] // load h1l | h1h + ext v12.16b, v12.16b, v12.16b, #8 + aese v2.16b, v20.16b + aesmc v2.16b, v2.16b // AES block 2 - round 2 + ldr q28, [x8, #160] // load rk10 + aese v3.16b, v20.16b + aesmc v3.16b, v3.16b // AES block 3 - round 2 + aese v0.16b, v21.16b + aesmc v0.16b, v0.16b // AES block 0 - round 3 + aese v1.16b, v20.16b + aesmc v1.16b, v1.16b // AES block 1 - round 2 + aese v3.16b, v21.16b + aesmc v3.16b, v3.16b // AES block 3 - round 3 + aese v0.16b, v22.16b + aesmc v0.16b, v0.16b // AES block 0 - round 4 + aese v2.16b, v21.16b + aesmc v2.16b, v2.16b // AES block 2 - round 3 + aese v1.16b, v21.16b + aesmc v1.16b, v1.16b // AES block 1 - round 3 + aese v3.16b, v22.16b + aesmc v3.16b, v3.16b // AES block 3 - round 4 + aese v2.16b, v22.16b + aesmc v2.16b, v2.16b // AES block 2 - round 4 + aese v1.16b, v22.16b + aesmc v1.16b, v1.16b // AES block 1 - round 4 + aese v3.16b, v23.16b + aesmc v3.16b, v3.16b // AES block 3 - round 5 + aese v0.16b, v23.16b + aesmc v0.16b, v0.16b // AES block 0 - round 5 + aese v1.16b, v23.16b + aesmc v1.16b, v1.16b // AES block 1 - round 5 + aese v2.16b, v23.16b + aesmc v2.16b, v2.16b // AES block 2 - round 5 + aese v0.16b, v24.16b + aesmc v0.16b, v0.16b // AES block 0 - round 6 + aese v3.16b, v24.16b + aesmc v3.16b, v3.16b // AES block 3 - round 6 + cmp x17, #12 // setup flags for AES-128/192/256 check + aese v1.16b, v24.16b + aesmc v1.16b, v1.16b // AES block 1 - round 6 + aese v2.16b, v24.16b + aesmc v2.16b, v2.16b // AES block 2 - round 6 + aese v0.16b, v25.16b + aesmc v0.16b, v0.16b // AES block 0 - round 7 + aese v1.16b, v25.16b + aesmc v1.16b, v1.16b // AES block 1 - round 7 + aese v3.16b, v25.16b + aesmc v3.16b, v3.16b // AES block 3 - round 7 + aese v0.16b, v26.16b + aesmc v0.16b, v0.16b // AES block 0 - round 8 + aese v2.16b, v25.16b + aesmc v2.16b, v2.16b // AES block 2 - round 7 + aese v3.16b, v26.16b + aesmc v3.16b, v3.16b // AES block 3 - round 8 + aese v1.16b, v26.16b + aesmc v1.16b, v1.16b // AES block 1 - round 8 + ldr q29, [x8, #176] // load rk11 + aese v2.16b, v26.16b + aesmc v2.16b, v2.16b // AES block 2 - round 8 + b.lt Ldec_finish_first_blocks // branch if AES-128 + + aese v0.16b, v27.16b + aesmc v0.16b, v0.16b // AES block 0 - round 9 + aese v1.16b, v27.16b + aesmc v1.16b, v1.16b // AES block 1 - round 9 + aese v3.16b, v27.16b + aesmc v3.16b, v3.16b // AES block 3 - round 9 + aese v2.16b, v27.16b + aesmc v2.16b, v2.16b // AES block 2 - round 9 + aese v0.16b, v28.16b + aesmc v0.16b, v0.16b // AES block 0 - round 10 + aese v1.16b, v28.16b + aesmc v1.16b, v1.16b // AES block 1 - round 10 + aese v3.16b, v28.16b + aesmc v3.16b, v3.16b // AES block 3 - round 10 + aese v2.16b, v28.16b + aesmc v2.16b, v2.16b // AES block 2 - round 10 + b.eq Ldec_finish_first_blocks // branch if AES-192 + + aese v0.16b, v29.16b + aesmc v0.16b, v0.16b // AES block 0 - round 11 + aese v3.16b, v29.16b + aesmc v3.16b, v3.16b // AES block 3 - round 11 + aese v1.16b, v29.16b + aesmc v1.16b, v1.16b // AES block 1 - round 11 + aese v2.16b, v29.16b + aesmc v2.16b, v2.16b // AES block 2 - round 11 + aese v1.16b, v30.16b + aesmc v1.16b, v1.16b // AES block 1 - round 12 + aese v0.16b, v30.16b + aesmc v0.16b, v0.16b // AES block 0 - round 12 + aese v2.16b, v30.16b + aesmc v2.16b, v2.16b // AES block 2 - round 12 + aese v3.16b, v30.16b + aesmc v3.16b, v3.16b // AES block 3 - round 12 + +Ldec_finish_first_blocks: + cmp x0, x5 // check if we have <= 4 blocks + trn1 v9.2d, v14.2d, v15.2d // h4h | h3h + trn2 v17.2d, v14.2d, v15.2d // h4l | h3l + trn1 v8.2d, v12.2d, v13.2d // h2h | h1h + trn2 v16.2d, v12.2d, v13.2d // h2l | h1l + eor v17.16b, v17.16b, v9.16b // h4k | h3k + aese v1.16b, v31.16b // AES block 1 - round N-1 + aese v2.16b, v31.16b // AES block 2 - round N-1 + eor v16.16b, v16.16b, v8.16b // h2k | h1k + aese v3.16b, v31.16b // AES block 3 - round N-1 + aese v0.16b, v31.16b // AES block 0 - round N-1 + b.ge Ldec_tail // handle tail + + ldr q4, [x0, #0] // AES block 0 - load ciphertext + ldr q5, [x0, #16] // AES block 1 - load ciphertext + rev w9, w12 // CTR block 4 + eor v0.16b, v4.16b, v0.16b // AES block 0 - result + eor v1.16b, v5.16b, v1.16b // AES block 1 - result + rev64 v5.16b, v5.16b // GHASH block 1 + ldr q7, [x0, #48] // AES block 3 - load ciphertext + mov x7, v0.d[1] // AES block 0 - mov high + mov x6, v0.d[0] // AES block 0 - mov low + rev64 v4.16b, v4.16b // GHASH block 0 + add w12, w12, #1 // CTR block 4 + fmov d0, x10 // CTR block 4 + orr x9, x11, x9, lsl #32 // CTR block 4 + fmov v0.d[1], x9 // CTR block 4 + rev w9, w12 // CTR block 5 + add w12, w12, #1 // CTR block 5 + mov x19, v1.d[0] // AES block 1 - mov low + orr x9, x11, x9, lsl #32 // CTR block 5 + mov x20, v1.d[1] // AES block 1 - mov high + eor x7, x7, x14 // AES block 0 - round N high + eor x6, x6, x13 // AES block 0 - round N low + stp x6, x7, [x2], #16 // AES block 0 - store result + fmov d1, x10 // CTR block 5 + ldr q6, [x0, #32] // AES block 2 - load ciphertext + add x0, x0, #64 // AES input_ptr update + fmov v1.d[1], x9 // CTR block 5 + rev w9, w12 // CTR block 6 + add w12, w12, #1 // CTR block 6 + eor x19, x19, x13 // AES block 1 - round N low + orr x9, x11, x9, lsl #32 // CTR block 6 + eor x20, x20, x14 // AES block 1 - round N high + stp x19, x20, [x2], #16 // AES block 1 - store result + eor v2.16b, v6.16b, v2.16b // AES block 2 - result + cmp x0, x5 // check if we have <= 8 blocks + b.ge Ldec_prepretail // do prepretail + +Ldec_main_loop: // main loop start + mov x21, v2.d[0] // AES block 4k+2 - mov low + ext v11.16b, v11.16b, v11.16b, #8 // PRE 0 + eor v3.16b, v7.16b, v3.16b // AES block 4k+3 - result + aese v0.16b, v18.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 0 + mov x22, v2.d[1] // AES block 4k+2 - mov high + aese v1.16b, v18.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 0 + fmov d2, x10 // CTR block 4k+6 + fmov v2.d[1], x9 // CTR block 4k+6 + eor v4.16b, v4.16b, v11.16b // PRE 1 + rev w9, w12 // CTR block 4k+7 + aese v0.16b, v19.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 1 + mov x24, v3.d[1] // AES block 4k+3 - mov high + aese v1.16b, v19.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 1 + mov x23, v3.d[0] // AES block 4k+3 - mov low + pmull2 v9.1q, v4.2d, v15.2d // GHASH block 4k - high + mov d8, v4.d[1] // GHASH block 4k - mid + fmov d3, x10 // CTR block 4k+7 + aese v0.16b, v20.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 2 + orr x9, x11, x9, lsl #32 // CTR block 4k+7 + aese v2.16b, v18.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 0 + fmov v3.d[1], x9 // CTR block 4k+7 + aese v1.16b, v20.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 2 + eor v8.8b, v8.8b, v4.8b // GHASH block 4k - mid + aese v0.16b, v21.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 3 + eor x22, x22, x14 // AES block 4k+2 - round N high + aese v2.16b, v19.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 1 + mov d10, v17.d[1] // GHASH block 4k - mid + aese v1.16b, v21.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 3 + rev64 v6.16b, v6.16b // GHASH block 4k+2 + aese v3.16b, v18.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 0 + eor x21, x21, x13 // AES block 4k+2 - round N low + aese v2.16b, v20.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 2 + stp x21, x22, [x2], #16 // AES block 4k+2 - store result + pmull v11.1q, v4.1d, v15.1d // GHASH block 4k - low + pmull2 v4.1q, v5.2d, v14.2d // GHASH block 4k+1 - high + aese v2.16b, v21.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 3 + rev64 v7.16b, v7.16b // GHASH block 4k+3 + pmull v10.1q, v8.1d, v10.1d // GHASH block 4k - mid + eor x23, x23, x13 // AES block 4k+3 - round N low + pmull v8.1q, v5.1d, v14.1d // GHASH block 4k+1 - low + eor x24, x24, x14 // AES block 4k+3 - round N high + eor v9.16b, v9.16b, v4.16b // GHASH block 4k+1 - high + aese v2.16b, v22.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 4 + aese v3.16b, v19.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 1 + mov d4, v5.d[1] // GHASH block 4k+1 - mid + aese v0.16b, v22.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 4 + eor v11.16b, v11.16b, v8.16b // GHASH block 4k+1 - low + aese v2.16b, v23.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 5 + add w12, w12, #1 // CTR block 4k+7 + aese v3.16b, v20.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 2 + mov d8, v6.d[1] // GHASH block 4k+2 - mid + aese v1.16b, v22.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 4 + eor v4.8b, v4.8b, v5.8b // GHASH block 4k+1 - mid + pmull v5.1q, v6.1d, v13.1d // GHASH block 4k+2 - low + aese v3.16b, v21.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 3 + eor v8.8b, v8.8b, v6.8b // GHASH block 4k+2 - mid + aese v1.16b, v23.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 5 + aese v0.16b, v23.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 5 + eor v11.16b, v11.16b, v5.16b // GHASH block 4k+2 - low + pmull v4.1q, v4.1d, v17.1d // GHASH block 4k+1 - mid + rev w9, w12 // CTR block 4k+8 + aese v1.16b, v24.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 6 + ins v8.d[1], v8.d[0] // GHASH block 4k+2 - mid + aese v0.16b, v24.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 6 + add w12, w12, #1 // CTR block 4k+8 + aese v3.16b, v22.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 4 + aese v1.16b, v25.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 7 + eor v10.16b, v10.16b, v4.16b // GHASH block 4k+1 - mid + aese v0.16b, v25.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 7 + pmull2 v4.1q, v6.2d, v13.2d // GHASH block 4k+2 - high + mov d6, v7.d[1] // GHASH block 4k+3 - mid + aese v3.16b, v23.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 5 + pmull2 v8.1q, v8.2d, v16.2d // GHASH block 4k+2 - mid + aese v0.16b, v26.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 8 + eor v9.16b, v9.16b, v4.16b // GHASH block 4k+2 - high + aese v3.16b, v24.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 6 + pmull v4.1q, v7.1d, v12.1d // GHASH block 4k+3 - low + orr x9, x11, x9, lsl #32 // CTR block 4k+8 + eor v10.16b, v10.16b, v8.16b // GHASH block 4k+2 - mid + pmull2 v5.1q, v7.2d, v12.2d // GHASH block 4k+3 - high + cmp x17, #12 // setup flags for AES-128/192/256 check + eor v6.8b, v6.8b, v7.8b // GHASH block 4k+3 - mid + aese v1.16b, v26.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 8 + aese v2.16b, v24.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 6 + eor v9.16b, v9.16b, v5.16b // GHASH block 4k+3 - high + pmull v6.1q, v6.1d, v16.1d // GHASH block 4k+3 - mid + movi v8.8b, #0xc2 + aese v2.16b, v25.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 7 + eor v11.16b, v11.16b, v4.16b // GHASH block 4k+3 - low + aese v3.16b, v25.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 7 + shl d8, d8, #56 // mod_constant + aese v2.16b, v26.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 8 + eor v10.16b, v10.16b, v6.16b // GHASH block 4k+3 - mid + aese v3.16b, v26.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 8 + b.lt Ldec_main_loop_continue // branch if AES-128 + + aese v0.16b, v27.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 9 + aese v2.16b, v27.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 9 + aese v1.16b, v27.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 9 + aese v3.16b, v27.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 9 + aese v0.16b, v28.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 10 + aese v1.16b, v28.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 10 + aese v2.16b, v28.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 10 + aese v3.16b, v28.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 10 + b.eq Ldec_main_loop_continue // branch if AES-192 + + aese v0.16b, v29.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 11 + aese v1.16b, v29.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 11 + aese v2.16b, v29.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 11 + aese v3.16b, v29.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 11 + aese v0.16b, v30.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 12 + aese v1.16b, v30.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 12 + aese v2.16b, v30.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 12 + aese v3.16b, v30.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 12 + +Ldec_main_loop_continue: + pmull v7.1q, v9.1d, v8.1d // MODULO - top 64b align with mid + eor v6.16b, v11.16b, v9.16b // MODULO - karatsuba tidy up + ldr q4, [x0, #0] // AES block 4k+4 - load ciphertext + aese v0.16b, v31.16b // AES block 4k+4 - round N-1 + ext v9.16b, v9.16b, v9.16b, #8 // MODULO - other top alignment + eor v10.16b, v10.16b, v6.16b // MODULO - karatsuba tidy up + ldr q5, [x0, #16] // AES block 4k+5 - load ciphertext + eor v0.16b, v4.16b, v0.16b // AES block 4k+4 - result + stp x23, x24, [x2], #16 // AES block 4k+3 - store result + eor v10.16b, v10.16b, v7.16b // MODULO - fold into mid + ldr q7, [x0, #48] // AES block 4k+7 - load ciphertext + ldr q6, [x0, #32] // AES block 4k+6 - load ciphertext + mov x7, v0.d[1] // AES block 4k+4 - mov high + eor v10.16b, v10.16b, v9.16b // MODULO - fold into mid + aese v1.16b, v31.16b // AES block 4k+5 - round N-1 + add x0, x0, #64 // AES input_ptr update + mov x6, v0.d[0] // AES block 4k+4 - mov low + fmov d0, x10 // CTR block 4k+8 + fmov v0.d[1], x9 // CTR block 4k+8 + pmull v8.1q, v10.1d, v8.1d // MODULO - mid 64b align with low + eor v1.16b, v5.16b, v1.16b // AES block 4k+5 - result + rev w9, w12 // CTR block 4k+9 + aese v2.16b, v31.16b // AES block 4k+6 - round N-1 + orr x9, x11, x9, lsl #32 // CTR block 4k+9 + cmp x0, x5 // LOOP CONTROL + add w12, w12, #1 // CTR block 4k+9 + eor x6, x6, x13 // AES block 4k+4 - round N low + eor x7, x7, x14 // AES block 4k+4 - round N high + mov x20, v1.d[1] // AES block 4k+5 - mov high + eor v2.16b, v6.16b, v2.16b // AES block 4k+6 - result + eor v11.16b, v11.16b, v8.16b // MODULO - fold into low + mov x19, v1.d[0] // AES block 4k+5 - mov low + fmov d1, x10 // CTR block 4k+9 + ext v10.16b, v10.16b, v10.16b, #8 // MODULO - other mid alignment + fmov v1.d[1], x9 // CTR block 4k+9 + rev w9, w12 // CTR block 4k+10 + add w12, w12, #1 // CTR block 4k+10 + aese v3.16b, v31.16b // AES block 4k+7 - round N-1 + orr x9, x11, x9, lsl #32 // CTR block 4k+10 + rev64 v5.16b, v5.16b // GHASH block 4k+5 + eor x20, x20, x14 // AES block 4k+5 - round N high + stp x6, x7, [x2], #16 // AES block 4k+4 - store result + eor x19, x19, x13 // AES block 4k+5 - round N low + stp x19, x20, [x2], #16 // AES block 4k+5 - store result + rev64 v4.16b, v4.16b // GHASH block 4k+4 + eor v11.16b, v11.16b, v10.16b // MODULO - fold into low + b.lt Ldec_main_loop + +Ldec_prepretail: // PREPRETAIL + ext v11.16b, v11.16b, v11.16b, #8 // PRE 0 + mov x21, v2.d[0] // AES block 4k+2 - mov low + eor v3.16b, v7.16b, v3.16b // AES block 4k+3 - result + aese v0.16b, v18.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 0 + mov x22, v2.d[1] // AES block 4k+2 - mov high + aese v1.16b, v18.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 0 + fmov d2, x10 // CTR block 4k+6 + fmov v2.d[1], x9 // CTR block 4k+6 + rev w9, w12 // CTR block 4k+7 + eor v4.16b, v4.16b, v11.16b // PRE 1 + rev64 v6.16b, v6.16b // GHASH block 4k+2 + orr x9, x11, x9, lsl #32 // CTR block 4k+7 + mov x23, v3.d[0] // AES block 4k+3 - mov low + aese v1.16b, v19.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 1 + mov x24, v3.d[1] // AES block 4k+3 - mov high + pmull v11.1q, v4.1d, v15.1d // GHASH block 4k - low + mov d8, v4.d[1] // GHASH block 4k - mid + fmov d3, x10 // CTR block 4k+7 + pmull2 v9.1q, v4.2d, v15.2d // GHASH block 4k - high + fmov v3.d[1], x9 // CTR block 4k+7 + aese v2.16b, v18.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 0 + mov d10, v17.d[1] // GHASH block 4k - mid + aese v0.16b, v19.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 1 + eor v8.8b, v8.8b, v4.8b // GHASH block 4k - mid + pmull2 v4.1q, v5.2d, v14.2d // GHASH block 4k+1 - high + aese v2.16b, v19.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 1 + rev64 v7.16b, v7.16b // GHASH block 4k+3 + aese v3.16b, v18.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 0 + pmull v10.1q, v8.1d, v10.1d // GHASH block 4k - mid + eor v9.16b, v9.16b, v4.16b // GHASH block 4k+1 - high + pmull v8.1q, v5.1d, v14.1d // GHASH block 4k+1 - low + aese v3.16b, v19.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 1 + mov d4, v5.d[1] // GHASH block 4k+1 - mid + aese v0.16b, v20.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 2 + aese v1.16b, v20.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 2 + eor v11.16b, v11.16b, v8.16b // GHASH block 4k+1 - low + aese v2.16b, v20.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 2 + aese v0.16b, v21.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 3 + mov d8, v6.d[1] // GHASH block 4k+2 - mid + aese v3.16b, v20.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 2 + eor v4.8b, v4.8b, v5.8b // GHASH block 4k+1 - mid + pmull v5.1q, v6.1d, v13.1d // GHASH block 4k+2 - low + aese v0.16b, v22.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 4 + aese v3.16b, v21.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 3 + eor v8.8b, v8.8b, v6.8b // GHASH block 4k+2 - mid + pmull v4.1q, v4.1d, v17.1d // GHASH block 4k+1 - mid + aese v0.16b, v23.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 5 + eor v11.16b, v11.16b, v5.16b // GHASH block 4k+2 - low + aese v3.16b, v22.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 4 + pmull2 v5.1q, v7.2d, v12.2d // GHASH block 4k+3 - high + eor v10.16b, v10.16b, v4.16b // GHASH block 4k+1 - mid + pmull2 v4.1q, v6.2d, v13.2d // GHASH block 4k+2 - high + aese v3.16b, v23.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 5 + ins v8.d[1], v8.d[0] // GHASH block 4k+2 - mid + aese v2.16b, v21.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 3 + aese v1.16b, v21.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 3 + eor v9.16b, v9.16b, v4.16b // GHASH block 4k+2 - high + pmull v4.1q, v7.1d, v12.1d // GHASH block 4k+3 - low + aese v2.16b, v22.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 4 + mov d6, v7.d[1] // GHASH block 4k+3 - mid + aese v1.16b, v22.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 4 + pmull2 v8.1q, v8.2d, v16.2d // GHASH block 4k+2 - mid + aese v2.16b, v23.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 5 + eor v6.8b, v6.8b, v7.8b // GHASH block 4k+3 - mid + aese v1.16b, v23.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 5 + aese v3.16b, v24.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 6 + eor v10.16b, v10.16b, v8.16b // GHASH block 4k+2 - mid + aese v2.16b, v24.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 6 + aese v0.16b, v24.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 6 + movi v8.8b, #0xc2 + aese v1.16b, v24.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 6 + eor v11.16b, v11.16b, v4.16b // GHASH block 4k+3 - low + pmull v6.1q, v6.1d, v16.1d // GHASH block 4k+3 - mid + aese v3.16b, v25.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 7 + cmp x17, #12 // setup flags for AES-128/192/256 check + eor v9.16b, v9.16b, v5.16b // GHASH block 4k+3 - high + aese v1.16b, v25.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 7 + aese v0.16b, v25.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 7 + eor v10.16b, v10.16b, v6.16b // GHASH block 4k+3 - mid + aese v3.16b, v26.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 8 + aese v2.16b, v25.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 7 + eor v6.16b, v11.16b, v9.16b // MODULO - karatsuba tidy up + aese v1.16b, v26.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 8 + aese v0.16b, v26.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 8 + shl d8, d8, #56 // mod_constant + aese v2.16b, v26.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 8 + b.lt Ldec_finish_prepretail // branch if AES-128 + + aese v1.16b, v27.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 9 + aese v2.16b, v27.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 9 + aese v3.16b, v27.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 9 + aese v0.16b, v27.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 9 + aese v2.16b, v28.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 10 + aese v3.16b, v28.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 10 + aese v0.16b, v28.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 10 + aese v1.16b, v28.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 10 + b.eq Ldec_finish_prepretail // branch if AES-192 + + aese v2.16b, v29.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 11 + aese v0.16b, v29.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 11 + aese v1.16b, v29.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 11 + aese v2.16b, v30.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 12 + aese v3.16b, v29.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 11 + aese v1.16b, v30.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 12 + aese v0.16b, v30.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 12 + aese v3.16b, v30.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 12 + +Ldec_finish_prepretail: + eor v10.16b, v10.16b, v6.16b // MODULO - karatsuba tidy up + pmull v7.1q, v9.1d, v8.1d // MODULO - top 64b align with mid + ext v9.16b, v9.16b, v9.16b, #8 // MODULO - other top alignment + eor v10.16b, v10.16b, v7.16b // MODULO - fold into mid + eor x22, x22, x14 // AES block 4k+2 - round N high + eor x23, x23, x13 // AES block 4k+3 - round N low + eor v10.16b, v10.16b, v9.16b // MODULO - fold into mid + add w12, w12, #1 // CTR block 4k+7 + eor x21, x21, x13 // AES block 4k+2 - round N low + pmull v8.1q, v10.1d, v8.1d // MODULO - mid 64b align with low + eor x24, x24, x14 // AES block 4k+3 - round N high + stp x21, x22, [x2], #16 // AES block 4k+2 - store result + ext v10.16b, v10.16b, v10.16b, #8 // MODULO - other mid alignment + stp x23, x24, [x2], #16 // AES block 4k+3 - store result + + eor v11.16b, v11.16b, v8.16b // MODULO - fold into low + aese v1.16b, v31.16b // AES block 4k+5 - round N-1 + aese v0.16b, v31.16b // AES block 4k+4 - round N-1 + aese v3.16b, v31.16b // AES block 4k+7 - round N-1 + aese v2.16b, v31.16b // AES block 4k+6 - round N-1 + eor v11.16b, v11.16b, v10.16b // MODULO - fold into low + +Ldec_tail: // TAIL + sub x5, x4, x0 // main_end_input_ptr is number of bytes left to process + ld1 { v5.16b}, [x0], #16 // AES block 4k+4 - load ciphertext + eor v0.16b, v5.16b, v0.16b // AES block 4k+4 - result + mov x6, v0.d[0] // AES block 4k+4 - mov low + mov x7, v0.d[1] // AES block 4k+4 - mov high + ext v8.16b, v11.16b, v11.16b, #8 // prepare final partial tag + cmp x5, #48 + eor x6, x6, x13 // AES block 4k+4 - round N low + eor x7, x7, x14 // AES block 4k+4 - round N high + b.gt Ldec_blocks_more_than_3 + sub w12, w12, #1 + mov v3.16b, v2.16b + movi v10.8b, #0 + movi v11.8b, #0 + cmp x5, #32 + movi v9.8b, #0 + mov v2.16b, v1.16b + b.gt Ldec_blocks_more_than_2 + sub w12, w12, #1 + mov v3.16b, v1.16b + cmp x5, #16 + b.gt Ldec_blocks_more_than_1 + sub w12, w12, #1 + b Ldec_blocks_less_than_1 +Ldec_blocks_more_than_3: // blocks left > 3 + rev64 v4.16b, v5.16b // GHASH final-3 block + ld1 { v5.16b}, [x0], #16 // AES final-2 block - load ciphertext + stp x6, x7, [x2], #16 // AES final-3 block - store result + mov d10, v17.d[1] // GHASH final-3 block - mid + eor v4.16b, v4.16b, v8.16b // feed in partial tag + eor v0.16b, v5.16b, v1.16b // AES final-2 block - result + mov d22, v4.d[1] // GHASH final-3 block - mid + mov x6, v0.d[0] // AES final-2 block - mov low + mov x7, v0.d[1] // AES final-2 block - mov high + eor v22.8b, v22.8b, v4.8b // GHASH final-3 block - mid + movi v8.8b, #0 // suppress further partial tag feed in + pmull2 v9.1q, v4.2d, v15.2d // GHASH final-3 block - high + pmull v10.1q, v22.1d, v10.1d // GHASH final-3 block - mid + eor x6, x6, x13 // AES final-2 block - round N low + pmull v11.1q, v4.1d, v15.1d // GHASH final-3 block - low + eor x7, x7, x14 // AES final-2 block - round N high +Ldec_blocks_more_than_2: // blocks left > 2 + rev64 v4.16b, v5.16b // GHASH final-2 block + ld1 { v5.16b}, [x0], #16 // AES final-1 block - load ciphertext + eor v4.16b, v4.16b, v8.16b // feed in partial tag + stp x6, x7, [x2], #16 // AES final-2 block - store result + eor v0.16b, v5.16b, v2.16b // AES final-1 block - result + mov d22, v4.d[1] // GHASH final-2 block - mid + pmull v21.1q, v4.1d, v14.1d // GHASH final-2 block - low + pmull2 v20.1q, v4.2d, v14.2d // GHASH final-2 block - high + eor v22.8b, v22.8b, v4.8b // GHASH final-2 block - mid + mov x6, v0.d[0] // AES final-1 block - mov low + mov x7, v0.d[1] // AES final-1 block - mov high + eor v11.16b, v11.16b, v21.16b // GHASH final-2 block - low + movi v8.8b, #0 // suppress further partial tag feed in + pmull v22.1q, v22.1d, v17.1d // GHASH final-2 block - mid + eor v9.16b, v9.16b, v20.16b // GHASH final-2 block - high + eor x6, x6, x13 // AES final-1 block - round N low + eor v10.16b, v10.16b, v22.16b // GHASH final-2 block - mid + eor x7, x7, x14 // AES final-1 block - round N high +Ldec_blocks_more_than_1: // blocks left > 1 + stp x6, x7, [x2], #16 // AES final-1 block - store result + rev64 v4.16b, v5.16b // GHASH final-1 block + ld1 { v5.16b}, [x0], #16 // AES final block - load ciphertext + eor v4.16b, v4.16b, v8.16b // feed in partial tag + movi v8.8b, #0 // suppress further partial tag feed in + mov d22, v4.d[1] // GHASH final-1 block - mid + eor v0.16b, v5.16b, v3.16b // AES final block - result + pmull2 v20.1q, v4.2d, v13.2d // GHASH final-1 block - high + eor v22.8b, v22.8b, v4.8b // GHASH final-1 block - mid + pmull v21.1q, v4.1d, v13.1d // GHASH final-1 block - low + mov x6, v0.d[0] // AES final block - mov low + ins v22.d[1], v22.d[0] // GHASH final-1 block - mid + mov x7, v0.d[1] // AES final block - mov high + pmull2 v22.1q, v22.2d, v16.2d // GHASH final-1 block - mid + eor x6, x6, x13 // AES final block - round N low + eor v11.16b, v11.16b, v21.16b // GHASH final-1 block - low + eor v9.16b, v9.16b, v20.16b // GHASH final-1 block - high + eor v10.16b, v10.16b, v22.16b // GHASH final-1 block - mid + eor x7, x7, x14 // AES final block - round N high +Ldec_blocks_less_than_1: // blocks left <= 1 + and x1, x1, #127 // bit_length %= 128 + mvn x14, xzr // rkN_h = 0xffffffffffffffff + sub x1, x1, #128 // bit_length -= 128 + mvn x13, xzr // rkN_l = 0xffffffffffffffff + ldp x4, x5, [x2] // load existing bytes we need to not overwrite + neg x1, x1 // bit_length = 128 - #bits in input (in range [1,128]) + and x1, x1, #127 // bit_length %= 128 + lsr x14, x14, x1 // rkN_h is mask for top 64b of last block + cmp x1, #64 + csel x9, x13, x14, lt + csel x10, x14, xzr, lt + fmov d0, x9 // ctr0b is mask for last block + and x6, x6, x9 + mov v0.d[1], x10 + bic x4, x4, x9 // mask out low existing bytes + rev w9, w12 + bic x5, x5, x10 // mask out high existing bytes + orr x6, x6, x4 + and x7, x7, x10 + orr x7, x7, x5 + and v5.16b, v5.16b, v0.16b // possibly partial last block has zeroes in highest bits + rev64 v4.16b, v5.16b // GHASH final block + eor v4.16b, v4.16b, v8.16b // feed in partial tag + pmull v21.1q, v4.1d, v12.1d // GHASH final block - low + mov d8, v4.d[1] // GHASH final block - mid + eor v8.8b, v8.8b, v4.8b // GHASH final block - mid + pmull2 v20.1q, v4.2d, v12.2d // GHASH final block - high + pmull v8.1q, v8.1d, v16.1d // GHASH final block - mid + eor v9.16b, v9.16b, v20.16b // GHASH final block - high + eor v11.16b, v11.16b, v21.16b // GHASH final block - low + eor v10.16b, v10.16b, v8.16b // GHASH final block - mid + movi v8.8b, #0xc2 + eor v6.16b, v11.16b, v9.16b // MODULO - karatsuba tidy up + shl d8, d8, #56 // mod_constant + eor v10.16b, v10.16b, v6.16b // MODULO - karatsuba tidy up + pmull v7.1q, v9.1d, v8.1d // MODULO - top 64b align with mid + ext v9.16b, v9.16b, v9.16b, #8 // MODULO - other top alignment + eor v10.16b, v10.16b, v7.16b // MODULO - fold into mid + eor v10.16b, v10.16b, v9.16b // MODULO - fold into mid + pmull v8.1q, v10.1d, v8.1d // MODULO - mid 64b align with low + ext v10.16b, v10.16b, v10.16b, #8 // MODULO - other mid alignment + eor v11.16b, v11.16b, v8.16b // MODULO - fold into low + stp x6, x7, [x2] + str w9, [x16, #12] // store the updated counter + eor v11.16b, v11.16b, v10.16b // MODULO - fold into low + ext v11.16b, v11.16b, v11.16b, #8 + rev64 v11.16b, v11.16b + mov x0, x15 + st1 { v11.16b }, [x3] + ldp x19, x20, [sp, #16] + ldp x21, x22, [sp, #32] + ldp x23, x24, [sp, #48] + ldp d8, d9, [sp, #64] + ldp d10, d11, [sp, #80] + ldp d12, d13, [sp, #96] + ldp d14, d15, [sp, #112] + ldp x29, x30, [sp], #128 + AARCH64_VALIDATE_LINK_REGISTER + ret + +#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__APPLE__) diff --git a/http/vendor/ring/pregenerated/aesv8-gcm-armv8-linux64.S b/http/vendor/ring/pregenerated/aesv8-gcm-armv8-linux64.S new file mode 100644 index 0000000..4e87ce7 --- /dev/null +++ b/http/vendor/ring/pregenerated/aesv8-gcm-armv8-linux64.S @@ -0,0 +1,1554 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__ELF__) +#if __ARM_MAX_ARCH__ >= 8 + +.arch armv8-a+crypto +.text +.globl aes_gcm_enc_kernel +.hidden aes_gcm_enc_kernel +.type aes_gcm_enc_kernel,%function +.align 4 +aes_gcm_enc_kernel: + AARCH64_SIGN_LINK_REGISTER + stp x29, x30, [sp, #-128]! + mov x29, sp + stp x19, x20, [sp, #16] + mov x16, x4 + mov x8, x5 + stp x21, x22, [sp, #32] + stp x23, x24, [sp, #48] + stp d8, d9, [sp, #64] + stp d10, d11, [sp, #80] + stp d12, d13, [sp, #96] + stp d14, d15, [sp, #112] + ldr w17, [x8, #240] + add x19, x8, x17, lsl #4 // borrow input_l1 for last key + ldp x13, x14, [x19] // load round N keys + ldr q31, [x19, #-16] // load round N-1 keys + add x4, x0, x1, lsr #3 // end_input_ptr + lsr x5, x1, #3 // byte_len + mov x15, x5 + ldp x10, x11, [x16] // ctr96_b64, ctr96_t32 + ld1 { v0.16b}, [x16] // special case vector load initial counter so we can start first AES block as quickly as possible + sub x5, x5, #1 // byte_len - 1 + ldr q18, [x8, #0] // load rk0 + and x5, x5, #0xffffffffffffffc0 // number of bytes to be processed in main loop (at least 1 byte must be handled by tail) + ldr q25, [x8, #112] // load rk7 + add x5, x5, x0 + lsr x12, x11, #32 + fmov d2, x10 // CTR block 2 + orr w11, w11, w11 + rev w12, w12 // rev_ctr32 + fmov d1, x10 // CTR block 1 + aese v0.16b, v18.16b + aesmc v0.16b, v0.16b // AES block 0 - round 0 + add w12, w12, #1 // increment rev_ctr32 + rev w9, w12 // CTR block 1 + fmov d3, x10 // CTR block 3 + orr x9, x11, x9, lsl #32 // CTR block 1 + add w12, w12, #1 // CTR block 1 + ldr q19, [x8, #16] // load rk1 + fmov v1.d[1], x9 // CTR block 1 + rev w9, w12 // CTR block 2 + add w12, w12, #1 // CTR block 2 + orr x9, x11, x9, lsl #32 // CTR block 2 + ldr q20, [x8, #32] // load rk2 + fmov v2.d[1], x9 // CTR block 2 + rev w9, w12 // CTR block 3 + aese v0.16b, v19.16b + aesmc v0.16b, v0.16b // AES block 0 - round 1 + orr x9, x11, x9, lsl #32 // CTR block 3 + fmov v3.d[1], x9 // CTR block 3 + aese v1.16b, v18.16b + aesmc v1.16b, v1.16b // AES block 1 - round 0 + ldr q21, [x8, #48] // load rk3 + aese v0.16b, v20.16b + aesmc v0.16b, v0.16b // AES block 0 - round 2 + ldr q24, [x8, #96] // load rk6 + aese v2.16b, v18.16b + aesmc v2.16b, v2.16b // AES block 2 - round 0 + ldr q23, [x8, #80] // load rk5 + aese v1.16b, v19.16b + aesmc v1.16b, v1.16b // AES block 1 - round 1 + ldr q14, [x6, #48] // load h3l | h3h + ext v14.16b, v14.16b, v14.16b, #8 + aese v3.16b, v18.16b + aesmc v3.16b, v3.16b // AES block 3 - round 0 + aese v2.16b, v19.16b + aesmc v2.16b, v2.16b // AES block 2 - round 1 + ldr q22, [x8, #64] // load rk4 + aese v1.16b, v20.16b + aesmc v1.16b, v1.16b // AES block 1 - round 2 + ldr q13, [x6, #32] // load h2l | h2h + ext v13.16b, v13.16b, v13.16b, #8 + aese v3.16b, v19.16b + aesmc v3.16b, v3.16b // AES block 3 - round 1 + ldr q30, [x8, #192] // load rk12 + aese v2.16b, v20.16b + aesmc v2.16b, v2.16b // AES block 2 - round 2 + ldr q15, [x6, #80] // load h4l | h4h + ext v15.16b, v15.16b, v15.16b, #8 + aese v1.16b, v21.16b + aesmc v1.16b, v1.16b // AES block 1 - round 3 + ldr q29, [x8, #176] // load rk11 + aese v3.16b, v20.16b + aesmc v3.16b, v3.16b // AES block 3 - round 2 + ldr q26, [x8, #128] // load rk8 + aese v2.16b, v21.16b + aesmc v2.16b, v2.16b // AES block 2 - round 3 + add w12, w12, #1 // CTR block 3 + aese v0.16b, v21.16b + aesmc v0.16b, v0.16b // AES block 0 - round 3 + aese v3.16b, v21.16b + aesmc v3.16b, v3.16b // AES block 3 - round 3 + ld1 { v11.16b}, [x3] + ext v11.16b, v11.16b, v11.16b, #8 + rev64 v11.16b, v11.16b + aese v2.16b, v22.16b + aesmc v2.16b, v2.16b // AES block 2 - round 4 + aese v0.16b, v22.16b + aesmc v0.16b, v0.16b // AES block 0 - round 4 + aese v1.16b, v22.16b + aesmc v1.16b, v1.16b // AES block 1 - round 4 + aese v3.16b, v22.16b + aesmc v3.16b, v3.16b // AES block 3 - round 4 + cmp x17, #12 // setup flags for AES-128/192/256 check + aese v0.16b, v23.16b + aesmc v0.16b, v0.16b // AES block 0 - round 5 + aese v1.16b, v23.16b + aesmc v1.16b, v1.16b // AES block 1 - round 5 + aese v3.16b, v23.16b + aesmc v3.16b, v3.16b // AES block 3 - round 5 + aese v2.16b, v23.16b + aesmc v2.16b, v2.16b // AES block 2 - round 5 + aese v1.16b, v24.16b + aesmc v1.16b, v1.16b // AES block 1 - round 6 + trn2 v17.2d, v14.2d, v15.2d // h4l | h3l + aese v3.16b, v24.16b + aesmc v3.16b, v3.16b // AES block 3 - round 6 + ldr q27, [x8, #144] // load rk9 + aese v0.16b, v24.16b + aesmc v0.16b, v0.16b // AES block 0 - round 6 + ldr q12, [x6] // load h1l | h1h + ext v12.16b, v12.16b, v12.16b, #8 + aese v2.16b, v24.16b + aesmc v2.16b, v2.16b // AES block 2 - round 6 + ldr q28, [x8, #160] // load rk10 + aese v1.16b, v25.16b + aesmc v1.16b, v1.16b // AES block 1 - round 7 + trn1 v9.2d, v14.2d, v15.2d // h4h | h3h + aese v0.16b, v25.16b + aesmc v0.16b, v0.16b // AES block 0 - round 7 + aese v2.16b, v25.16b + aesmc v2.16b, v2.16b // AES block 2 - round 7 + aese v3.16b, v25.16b + aesmc v3.16b, v3.16b // AES block 3 - round 7 + trn2 v16.2d, v12.2d, v13.2d // h2l | h1l + aese v1.16b, v26.16b + aesmc v1.16b, v1.16b // AES block 1 - round 8 + aese v2.16b, v26.16b + aesmc v2.16b, v2.16b // AES block 2 - round 8 + aese v3.16b, v26.16b + aesmc v3.16b, v3.16b // AES block 3 - round 8 + aese v0.16b, v26.16b + aesmc v0.16b, v0.16b // AES block 0 - round 8 + b.lt .Lenc_finish_first_blocks // branch if AES-128 + + aese v1.16b, v27.16b + aesmc v1.16b, v1.16b // AES block 1 - round 9 + aese v2.16b, v27.16b + aesmc v2.16b, v2.16b // AES block 2 - round 9 + aese v3.16b, v27.16b + aesmc v3.16b, v3.16b // AES block 3 - round 9 + aese v0.16b, v27.16b + aesmc v0.16b, v0.16b // AES block 0 - round 9 + aese v1.16b, v28.16b + aesmc v1.16b, v1.16b // AES block 1 - round 10 + aese v2.16b, v28.16b + aesmc v2.16b, v2.16b // AES block 2 - round 10 + aese v3.16b, v28.16b + aesmc v3.16b, v3.16b // AES block 3 - round 10 + aese v0.16b, v28.16b + aesmc v0.16b, v0.16b // AES block 0 - round 10 + b.eq .Lenc_finish_first_blocks // branch if AES-192 + + aese v1.16b, v29.16b + aesmc v1.16b, v1.16b // AES block 1 - round 11 + aese v2.16b, v29.16b + aesmc v2.16b, v2.16b // AES block 2 - round 11 + aese v0.16b, v29.16b + aesmc v0.16b, v0.16b // AES block 0 - round 11 + aese v3.16b, v29.16b + aesmc v3.16b, v3.16b // AES block 3 - round 11 + aese v1.16b, v30.16b + aesmc v1.16b, v1.16b // AES block 1 - round 12 + aese v2.16b, v30.16b + aesmc v2.16b, v2.16b // AES block 2 - round 12 + aese v0.16b, v30.16b + aesmc v0.16b, v0.16b // AES block 0 - round 12 + aese v3.16b, v30.16b + aesmc v3.16b, v3.16b // AES block 3 - round 12 + +.Lenc_finish_first_blocks: + cmp x0, x5 // check if we have <= 4 blocks + eor v17.16b, v17.16b, v9.16b // h4k | h3k + aese v2.16b, v31.16b // AES block 2 - round N-1 + trn1 v8.2d, v12.2d, v13.2d // h2h | h1h + aese v1.16b, v31.16b // AES block 1 - round N-1 + aese v0.16b, v31.16b // AES block 0 - round N-1 + aese v3.16b, v31.16b // AES block 3 - round N-1 + eor v16.16b, v16.16b, v8.16b // h2k | h1k + b.ge .Lenc_tail // handle tail + + ldp x19, x20, [x0, #16] // AES block 1 - load plaintext + rev w9, w12 // CTR block 4 + ldp x6, x7, [x0, #0] // AES block 0 - load plaintext + ldp x23, x24, [x0, #48] // AES block 3 - load plaintext + ldp x21, x22, [x0, #32] // AES block 2 - load plaintext + add x0, x0, #64 // AES input_ptr update + eor x19, x19, x13 // AES block 1 - round N low + eor x20, x20, x14 // AES block 1 - round N high + fmov d5, x19 // AES block 1 - mov low + eor x6, x6, x13 // AES block 0 - round N low + eor x7, x7, x14 // AES block 0 - round N high + eor x24, x24, x14 // AES block 3 - round N high + fmov d4, x6 // AES block 0 - mov low + cmp x0, x5 // check if we have <= 8 blocks + fmov v4.d[1], x7 // AES block 0 - mov high + eor x23, x23, x13 // AES block 3 - round N low + eor x21, x21, x13 // AES block 2 - round N low + fmov v5.d[1], x20 // AES block 1 - mov high + fmov d6, x21 // AES block 2 - mov low + add w12, w12, #1 // CTR block 4 + orr x9, x11, x9, lsl #32 // CTR block 4 + fmov d7, x23 // AES block 3 - mov low + eor x22, x22, x14 // AES block 2 - round N high + fmov v6.d[1], x22 // AES block 2 - mov high + eor v4.16b, v4.16b, v0.16b // AES block 0 - result + fmov d0, x10 // CTR block 4 + fmov v0.d[1], x9 // CTR block 4 + rev w9, w12 // CTR block 5 + add w12, w12, #1 // CTR block 5 + eor v5.16b, v5.16b, v1.16b // AES block 1 - result + fmov d1, x10 // CTR block 5 + orr x9, x11, x9, lsl #32 // CTR block 5 + fmov v1.d[1], x9 // CTR block 5 + rev w9, w12 // CTR block 6 + st1 { v4.16b}, [x2], #16 // AES block 0 - store result + fmov v7.d[1], x24 // AES block 3 - mov high + orr x9, x11, x9, lsl #32 // CTR block 6 + eor v6.16b, v6.16b, v2.16b // AES block 2 - result + st1 { v5.16b}, [x2], #16 // AES block 1 - store result + add w12, w12, #1 // CTR block 6 + fmov d2, x10 // CTR block 6 + fmov v2.d[1], x9 // CTR block 6 + st1 { v6.16b}, [x2], #16 // AES block 2 - store result + rev w9, w12 // CTR block 7 + orr x9, x11, x9, lsl #32 // CTR block 7 + eor v7.16b, v7.16b, v3.16b // AES block 3 - result + st1 { v7.16b}, [x2], #16 // AES block 3 - store result + b.ge .Lenc_prepretail // do prepretail + +.Lenc_main_loop: // main loop start + aese v0.16b, v18.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 0 + rev64 v4.16b, v4.16b // GHASH block 4k (only t0 is free) + aese v1.16b, v18.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 0 + fmov d3, x10 // CTR block 4k+3 + aese v2.16b, v18.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 0 + ext v11.16b, v11.16b, v11.16b, #8 // PRE 0 + aese v0.16b, v19.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 1 + fmov v3.d[1], x9 // CTR block 4k+3 + aese v1.16b, v19.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 1 + ldp x23, x24, [x0, #48] // AES block 4k+7 - load plaintext + aese v2.16b, v19.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 1 + ldp x21, x22, [x0, #32] // AES block 4k+6 - load plaintext + aese v0.16b, v20.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 2 + eor v4.16b, v4.16b, v11.16b // PRE 1 + aese v1.16b, v20.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 2 + aese v3.16b, v18.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 0 + eor x23, x23, x13 // AES block 4k+7 - round N low + aese v0.16b, v21.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 3 + mov d10, v17.d[1] // GHASH block 4k - mid + pmull2 v9.1q, v4.2d, v15.2d // GHASH block 4k - high + eor x22, x22, x14 // AES block 4k+6 - round N high + mov d8, v4.d[1] // GHASH block 4k - mid + aese v3.16b, v19.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 1 + rev64 v5.16b, v5.16b // GHASH block 4k+1 (t0 and t1 free) + aese v0.16b, v22.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 4 + pmull v11.1q, v4.1d, v15.1d // GHASH block 4k - low + eor v8.8b, v8.8b, v4.8b // GHASH block 4k - mid + aese v2.16b, v20.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 2 + aese v0.16b, v23.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 5 + rev64 v7.16b, v7.16b // GHASH block 4k+3 (t0, t1, t2 and t3 free) + pmull2 v4.1q, v5.2d, v14.2d // GHASH block 4k+1 - high + pmull v10.1q, v8.1d, v10.1d // GHASH block 4k - mid + rev64 v6.16b, v6.16b // GHASH block 4k+2 (t0, t1, and t2 free) + pmull v8.1q, v5.1d, v14.1d // GHASH block 4k+1 - low + eor v9.16b, v9.16b, v4.16b // GHASH block 4k+1 - high + mov d4, v5.d[1] // GHASH block 4k+1 - mid + aese v1.16b, v21.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 3 + aese v3.16b, v20.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 2 + eor v11.16b, v11.16b, v8.16b // GHASH block 4k+1 - low + aese v2.16b, v21.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 3 + aese v1.16b, v22.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 4 + mov d8, v6.d[1] // GHASH block 4k+2 - mid + aese v3.16b, v21.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 3 + eor v4.8b, v4.8b, v5.8b // GHASH block 4k+1 - mid + aese v2.16b, v22.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 4 + aese v0.16b, v24.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 6 + eor v8.8b, v8.8b, v6.8b // GHASH block 4k+2 - mid + aese v3.16b, v22.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 4 + pmull v4.1q, v4.1d, v17.1d // GHASH block 4k+1 - mid + aese v0.16b, v25.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 7 + aese v3.16b, v23.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 5 + ins v8.d[1], v8.d[0] // GHASH block 4k+2 - mid + aese v1.16b, v23.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 5 + aese v0.16b, v26.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 8 + aese v2.16b, v23.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 5 + aese v1.16b, v24.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 6 + eor v10.16b, v10.16b, v4.16b // GHASH block 4k+1 - mid + pmull2 v4.1q, v6.2d, v13.2d // GHASH block 4k+2 - high + pmull v5.1q, v6.1d, v13.1d // GHASH block 4k+2 - low + aese v1.16b, v25.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 7 + pmull v6.1q, v7.1d, v12.1d // GHASH block 4k+3 - low + eor v9.16b, v9.16b, v4.16b // GHASH block 4k+2 - high + aese v3.16b, v24.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 6 + ldp x19, x20, [x0, #16] // AES block 4k+5 - load plaintext + aese v1.16b, v26.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 8 + mov d4, v7.d[1] // GHASH block 4k+3 - mid + aese v2.16b, v24.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 6 + eor v11.16b, v11.16b, v5.16b // GHASH block 4k+2 - low + pmull2 v8.1q, v8.2d, v16.2d // GHASH block 4k+2 - mid + pmull2 v5.1q, v7.2d, v12.2d // GHASH block 4k+3 - high + eor v4.8b, v4.8b, v7.8b // GHASH block 4k+3 - mid + aese v2.16b, v25.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 7 + eor x19, x19, x13 // AES block 4k+5 - round N low + aese v2.16b, v26.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 8 + eor v10.16b, v10.16b, v8.16b // GHASH block 4k+2 - mid + aese v3.16b, v25.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 7 + eor x21, x21, x13 // AES block 4k+6 - round N low + aese v3.16b, v26.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 8 + movi v8.8b, #0xc2 + pmull v4.1q, v4.1d, v16.1d // GHASH block 4k+3 - mid + eor v9.16b, v9.16b, v5.16b // GHASH block 4k+3 - high + cmp x17, #12 // setup flags for AES-128/192/256 check + fmov d5, x19 // AES block 4k+5 - mov low + ldp x6, x7, [x0, #0] // AES block 4k+4 - load plaintext + b.lt .Lenc_main_loop_continue // branch if AES-128 + + aese v1.16b, v27.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 9 + aese v0.16b, v27.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 9 + aese v2.16b, v27.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 9 + aese v3.16b, v27.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 9 + aese v0.16b, v28.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 10 + aese v1.16b, v28.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 10 + aese v2.16b, v28.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 10 + aese v3.16b, v28.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 10 + b.eq .Lenc_main_loop_continue // branch if AES-192 + + aese v0.16b, v29.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 11 + aese v1.16b, v29.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 11 + aese v2.16b, v29.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 11 + aese v3.16b, v29.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 11 + aese v1.16b, v30.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 12 + aese v0.16b, v30.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 12 + aese v2.16b, v30.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 12 + aese v3.16b, v30.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 12 + +.Lenc_main_loop_continue: + shl d8, d8, #56 // mod_constant + eor v11.16b, v11.16b, v6.16b // GHASH block 4k+3 - low + eor v10.16b, v10.16b, v4.16b // GHASH block 4k+3 - mid + add w12, w12, #1 // CTR block 4k+3 + eor v4.16b, v11.16b, v9.16b // MODULO - karatsuba tidy up + add x0, x0, #64 // AES input_ptr update + pmull v7.1q, v9.1d, v8.1d // MODULO - top 64b align with mid + rev w9, w12 // CTR block 4k+8 + ext v9.16b, v9.16b, v9.16b, #8 // MODULO - other top alignment + eor x6, x6, x13 // AES block 4k+4 - round N low + eor v10.16b, v10.16b, v4.16b // MODULO - karatsuba tidy up + eor x7, x7, x14 // AES block 4k+4 - round N high + fmov d4, x6 // AES block 4k+4 - mov low + orr x9, x11, x9, lsl #32 // CTR block 4k+8 + eor v7.16b, v9.16b, v7.16b // MODULO - fold into mid + eor x20, x20, x14 // AES block 4k+5 - round N high + eor x24, x24, x14 // AES block 4k+7 - round N high + add w12, w12, #1 // CTR block 4k+8 + aese v0.16b, v31.16b // AES block 4k+4 - round N-1 + fmov v4.d[1], x7 // AES block 4k+4 - mov high + eor v10.16b, v10.16b, v7.16b // MODULO - fold into mid + fmov d7, x23 // AES block 4k+7 - mov low + aese v1.16b, v31.16b // AES block 4k+5 - round N-1 + fmov v5.d[1], x20 // AES block 4k+5 - mov high + fmov d6, x21 // AES block 4k+6 - mov low + cmp x0, x5 // .LOOP CONTROL + fmov v6.d[1], x22 // AES block 4k+6 - mov high + pmull v9.1q, v10.1d, v8.1d // MODULO - mid 64b align with low + eor v4.16b, v4.16b, v0.16b // AES block 4k+4 - result + fmov d0, x10 // CTR block 4k+8 + fmov v0.d[1], x9 // CTR block 4k+8 + rev w9, w12 // CTR block 4k+9 + add w12, w12, #1 // CTR block 4k+9 + eor v5.16b, v5.16b, v1.16b // AES block 4k+5 - result + fmov d1, x10 // CTR block 4k+9 + orr x9, x11, x9, lsl #32 // CTR block 4k+9 + fmov v1.d[1], x9 // CTR block 4k+9 + aese v2.16b, v31.16b // AES block 4k+6 - round N-1 + rev w9, w12 // CTR block 4k+10 + st1 { v4.16b}, [x2], #16 // AES block 4k+4 - store result + orr x9, x11, x9, lsl #32 // CTR block 4k+10 + eor v11.16b, v11.16b, v9.16b // MODULO - fold into low + fmov v7.d[1], x24 // AES block 4k+7 - mov high + ext v10.16b, v10.16b, v10.16b, #8 // MODULO - other mid alignment + st1 { v5.16b}, [x2], #16 // AES block 4k+5 - store result + add w12, w12, #1 // CTR block 4k+10 + aese v3.16b, v31.16b // AES block 4k+7 - round N-1 + eor v6.16b, v6.16b, v2.16b // AES block 4k+6 - result + fmov d2, x10 // CTR block 4k+10 + st1 { v6.16b}, [x2], #16 // AES block 4k+6 - store result + fmov v2.d[1], x9 // CTR block 4k+10 + rev w9, w12 // CTR block 4k+11 + eor v11.16b, v11.16b, v10.16b // MODULO - fold into low + orr x9, x11, x9, lsl #32 // CTR block 4k+11 + eor v7.16b, v7.16b, v3.16b // AES block 4k+7 - result + st1 { v7.16b}, [x2], #16 // AES block 4k+7 - store result + b.lt .Lenc_main_loop + +.Lenc_prepretail: // PREPRETAIL + aese v1.16b, v18.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 0 + rev64 v6.16b, v6.16b // GHASH block 4k+2 (t0, t1, and t2 free) + aese v2.16b, v18.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 0 + fmov d3, x10 // CTR block 4k+3 + aese v0.16b, v18.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 0 + rev64 v4.16b, v4.16b // GHASH block 4k (only t0 is free) + fmov v3.d[1], x9 // CTR block 4k+3 + ext v11.16b, v11.16b, v11.16b, #8 // PRE 0 + aese v2.16b, v19.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 1 + aese v0.16b, v19.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 1 + eor v4.16b, v4.16b, v11.16b // PRE 1 + rev64 v5.16b, v5.16b // GHASH block 4k+1 (t0 and t1 free) + aese v2.16b, v20.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 2 + aese v3.16b, v18.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 0 + mov d10, v17.d[1] // GHASH block 4k - mid + aese v1.16b, v19.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 1 + pmull v11.1q, v4.1d, v15.1d // GHASH block 4k - low + mov d8, v4.d[1] // GHASH block 4k - mid + pmull2 v9.1q, v4.2d, v15.2d // GHASH block 4k - high + aese v2.16b, v21.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 3 + aese v1.16b, v20.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 2 + eor v8.8b, v8.8b, v4.8b // GHASH block 4k - mid + aese v0.16b, v20.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 2 + aese v3.16b, v19.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 1 + aese v1.16b, v21.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 3 + pmull v10.1q, v8.1d, v10.1d // GHASH block 4k - mid + pmull2 v4.1q, v5.2d, v14.2d // GHASH block 4k+1 - high + pmull v8.1q, v5.1d, v14.1d // GHASH block 4k+1 - low + aese v3.16b, v20.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 2 + eor v9.16b, v9.16b, v4.16b // GHASH block 4k+1 - high + mov d4, v5.d[1] // GHASH block 4k+1 - mid + aese v0.16b, v21.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 3 + eor v11.16b, v11.16b, v8.16b // GHASH block 4k+1 - low + aese v3.16b, v21.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 3 + eor v4.8b, v4.8b, v5.8b // GHASH block 4k+1 - mid + mov d8, v6.d[1] // GHASH block 4k+2 - mid + aese v0.16b, v22.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 4 + rev64 v7.16b, v7.16b // GHASH block 4k+3 (t0, t1, t2 and t3 free) + aese v3.16b, v22.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 4 + pmull v4.1q, v4.1d, v17.1d // GHASH block 4k+1 - mid + eor v8.8b, v8.8b, v6.8b // GHASH block 4k+2 - mid + add w12, w12, #1 // CTR block 4k+3 + pmull v5.1q, v6.1d, v13.1d // GHASH block 4k+2 - low + aese v3.16b, v23.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 5 + aese v2.16b, v22.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 4 + eor v10.16b, v10.16b, v4.16b // GHASH block 4k+1 - mid + pmull2 v4.1q, v6.2d, v13.2d // GHASH block 4k+2 - high + eor v11.16b, v11.16b, v5.16b // GHASH block 4k+2 - low + ins v8.d[1], v8.d[0] // GHASH block 4k+2 - mid + aese v2.16b, v23.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 5 + eor v9.16b, v9.16b, v4.16b // GHASH block 4k+2 - high + mov d4, v7.d[1] // GHASH block 4k+3 - mid + aese v1.16b, v22.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 4 + pmull2 v8.1q, v8.2d, v16.2d // GHASH block 4k+2 - mid + eor v4.8b, v4.8b, v7.8b // GHASH block 4k+3 - mid + pmull2 v5.1q, v7.2d, v12.2d // GHASH block 4k+3 - high + aese v1.16b, v23.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 5 + pmull v4.1q, v4.1d, v16.1d // GHASH block 4k+3 - mid + eor v10.16b, v10.16b, v8.16b // GHASH block 4k+2 - mid + aese v0.16b, v23.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 5 + aese v1.16b, v24.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 6 + aese v2.16b, v24.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 6 + aese v0.16b, v24.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 6 + movi v8.8b, #0xc2 + aese v3.16b, v24.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 6 + aese v1.16b, v25.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 7 + eor v9.16b, v9.16b, v5.16b // GHASH block 4k+3 - high + aese v0.16b, v25.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 7 + aese v3.16b, v25.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 7 + shl d8, d8, #56 // mod_constant + aese v1.16b, v26.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 8 + eor v10.16b, v10.16b, v4.16b // GHASH block 4k+3 - mid + pmull v6.1q, v7.1d, v12.1d // GHASH block 4k+3 - low + aese v3.16b, v26.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 8 + cmp x17, #12 // setup flags for AES-128/192/256 check + aese v0.16b, v26.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 8 + eor v11.16b, v11.16b, v6.16b // GHASH block 4k+3 - low + aese v2.16b, v25.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 7 + eor v10.16b, v10.16b, v9.16b // karatsuba tidy up + aese v2.16b, v26.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 8 + pmull v4.1q, v9.1d, v8.1d + ext v9.16b, v9.16b, v9.16b, #8 + eor v10.16b, v10.16b, v11.16b + b.lt .Lenc_finish_prepretail // branch if AES-128 + + aese v1.16b, v27.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 9 + aese v3.16b, v27.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 9 + aese v0.16b, v27.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 9 + aese v2.16b, v27.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 9 + aese v3.16b, v28.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 10 + aese v1.16b, v28.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 10 + aese v0.16b, v28.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 10 + aese v2.16b, v28.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 10 + b.eq .Lenc_finish_prepretail // branch if AES-192 + + aese v1.16b, v29.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 11 + aese v0.16b, v29.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 11 + aese v3.16b, v29.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 11 + aese v2.16b, v29.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 11 + aese v1.16b, v30.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 12 + aese v0.16b, v30.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 12 + aese v3.16b, v30.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 12 + aese v2.16b, v30.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 12 + +.Lenc_finish_prepretail: + eor v10.16b, v10.16b, v4.16b + eor v10.16b, v10.16b, v9.16b + pmull v4.1q, v10.1d, v8.1d + ext v10.16b, v10.16b, v10.16b, #8 + aese v1.16b, v31.16b // AES block 4k+5 - round N-1 + eor v11.16b, v11.16b, v4.16b + aese v3.16b, v31.16b // AES block 4k+7 - round N-1 + aese v0.16b, v31.16b // AES block 4k+4 - round N-1 + aese v2.16b, v31.16b // AES block 4k+6 - round N-1 + eor v11.16b, v11.16b, v10.16b + +.Lenc_tail: // TAIL + ext v8.16b, v11.16b, v11.16b, #8 // prepare final partial tag + sub x5, x4, x0 // main_end_input_ptr is number of bytes left to process + ldp x6, x7, [x0], #16 // AES block 4k+4 - load plaintext + eor x6, x6, x13 // AES block 4k+4 - round N low + eor x7, x7, x14 // AES block 4k+4 - round N high + cmp x5, #48 + fmov d4, x6 // AES block 4k+4 - mov low + fmov v4.d[1], x7 // AES block 4k+4 - mov high + eor v5.16b, v4.16b, v0.16b // AES block 4k+4 - result + b.gt .Lenc_blocks_more_than_3 + cmp x5, #32 + mov v3.16b, v2.16b + movi v11.8b, #0 + movi v9.8b, #0 + sub w12, w12, #1 + mov v2.16b, v1.16b + movi v10.8b, #0 + b.gt .Lenc_blocks_more_than_2 + mov v3.16b, v1.16b + sub w12, w12, #1 + cmp x5, #16 + b.gt .Lenc_blocks_more_than_1 + sub w12, w12, #1 + b .Lenc_blocks_less_than_1 +.Lenc_blocks_more_than_3: // blocks left > 3 + st1 { v5.16b}, [x2], #16 // AES final-3 block - store result + ldp x6, x7, [x0], #16 // AES final-2 block - load input low & high + rev64 v4.16b, v5.16b // GHASH final-3 block + eor x6, x6, x13 // AES final-2 block - round N low + eor v4.16b, v4.16b, v8.16b // feed in partial tag + eor x7, x7, x14 // AES final-2 block - round N high + mov d22, v4.d[1] // GHASH final-3 block - mid + fmov d5, x6 // AES final-2 block - mov low + fmov v5.d[1], x7 // AES final-2 block - mov high + eor v22.8b, v22.8b, v4.8b // GHASH final-3 block - mid + movi v8.8b, #0 // suppress further partial tag feed in + mov d10, v17.d[1] // GHASH final-3 block - mid + pmull v11.1q, v4.1d, v15.1d // GHASH final-3 block - low + pmull2 v9.1q, v4.2d, v15.2d // GHASH final-3 block - high + pmull v10.1q, v22.1d, v10.1d // GHASH final-3 block - mid + eor v5.16b, v5.16b, v1.16b // AES final-2 block - result +.Lenc_blocks_more_than_2: // blocks left > 2 + st1 { v5.16b}, [x2], #16 // AES final-2 block - store result + ldp x6, x7, [x0], #16 // AES final-1 block - load input low & high + rev64 v4.16b, v5.16b // GHASH final-2 block + eor x6, x6, x13 // AES final-1 block - round N low + eor v4.16b, v4.16b, v8.16b // feed in partial tag + fmov d5, x6 // AES final-1 block - mov low + eor x7, x7, x14 // AES final-1 block - round N high + fmov v5.d[1], x7 // AES final-1 block - mov high + movi v8.8b, #0 // suppress further partial tag feed in + pmull2 v20.1q, v4.2d, v14.2d // GHASH final-2 block - high + mov d22, v4.d[1] // GHASH final-2 block - mid + pmull v21.1q, v4.1d, v14.1d // GHASH final-2 block - low + eor v22.8b, v22.8b, v4.8b // GHASH final-2 block - mid + eor v5.16b, v5.16b, v2.16b // AES final-1 block - result + eor v9.16b, v9.16b, v20.16b // GHASH final-2 block - high + pmull v22.1q, v22.1d, v17.1d // GHASH final-2 block - mid + eor v11.16b, v11.16b, v21.16b // GHASH final-2 block - low + eor v10.16b, v10.16b, v22.16b // GHASH final-2 block - mid +.Lenc_blocks_more_than_1: // blocks left > 1 + st1 { v5.16b}, [x2], #16 // AES final-1 block - store result + rev64 v4.16b, v5.16b // GHASH final-1 block + ldp x6, x7, [x0], #16 // AES final block - load input low & high + eor v4.16b, v4.16b, v8.16b // feed in partial tag + movi v8.8b, #0 // suppress further partial tag feed in + eor x6, x6, x13 // AES final block - round N low + mov d22, v4.d[1] // GHASH final-1 block - mid + pmull2 v20.1q, v4.2d, v13.2d // GHASH final-1 block - high + eor x7, x7, x14 // AES final block - round N high + eor v22.8b, v22.8b, v4.8b // GHASH final-1 block - mid + eor v9.16b, v9.16b, v20.16b // GHASH final-1 block - high + ins v22.d[1], v22.d[0] // GHASH final-1 block - mid + fmov d5, x6 // AES final block - mov low + fmov v5.d[1], x7 // AES final block - mov high + pmull2 v22.1q, v22.2d, v16.2d // GHASH final-1 block - mid + pmull v21.1q, v4.1d, v13.1d // GHASH final-1 block - low + eor v5.16b, v5.16b, v3.16b // AES final block - result + eor v10.16b, v10.16b, v22.16b // GHASH final-1 block - mid + eor v11.16b, v11.16b, v21.16b // GHASH final-1 block - low +.Lenc_blocks_less_than_1: // blocks left <= 1 + and x1, x1, #127 // bit_length %= 128 + mvn x13, xzr // rkN_l = 0xffffffffffffffff + sub x1, x1, #128 // bit_length -= 128 + neg x1, x1 // bit_length = 128 - #bits in input (in range [1,128]) + ld1 { v18.16b}, [x2] // load existing bytes where the possibly partial last block is to be stored + mvn x14, xzr // rkN_h = 0xffffffffffffffff + and x1, x1, #127 // bit_length %= 128 + lsr x14, x14, x1 // rkN_h is mask for top 64b of last block + cmp x1, #64 + csel x6, x13, x14, lt + csel x7, x14, xzr, lt + fmov d0, x6 // ctr0b is mask for last block + fmov v0.d[1], x7 + and v5.16b, v5.16b, v0.16b // possibly partial last block has zeroes in highest bits + rev64 v4.16b, v5.16b // GHASH final block + eor v4.16b, v4.16b, v8.16b // feed in partial tag + bif v5.16b, v18.16b, v0.16b // insert existing bytes in top end of result before storing + pmull2 v20.1q, v4.2d, v12.2d // GHASH final block - high + mov d8, v4.d[1] // GHASH final block - mid + rev w9, w12 + pmull v21.1q, v4.1d, v12.1d // GHASH final block - low + eor v9.16b, v9.16b, v20.16b // GHASH final block - high + eor v8.8b, v8.8b, v4.8b // GHASH final block - mid + pmull v8.1q, v8.1d, v16.1d // GHASH final block - mid + eor v11.16b, v11.16b, v21.16b // GHASH final block - low + eor v10.16b, v10.16b, v8.16b // GHASH final block - mid + movi v8.8b, #0xc2 + eor v4.16b, v11.16b, v9.16b // MODULO - karatsuba tidy up + shl d8, d8, #56 // mod_constant + eor v10.16b, v10.16b, v4.16b // MODULO - karatsuba tidy up + pmull v7.1q, v9.1d, v8.1d // MODULO - top 64b align with mid + ext v9.16b, v9.16b, v9.16b, #8 // MODULO - other top alignment + eor v10.16b, v10.16b, v7.16b // MODULO - fold into mid + eor v10.16b, v10.16b, v9.16b // MODULO - fold into mid + pmull v9.1q, v10.1d, v8.1d // MODULO - mid 64b align with low + ext v10.16b, v10.16b, v10.16b, #8 // MODULO - other mid alignment + str w9, [x16, #12] // store the updated counter + st1 { v5.16b}, [x2] // store all 16B + eor v11.16b, v11.16b, v9.16b // MODULO - fold into low + eor v11.16b, v11.16b, v10.16b // MODULO - fold into low + ext v11.16b, v11.16b, v11.16b, #8 + rev64 v11.16b, v11.16b + mov x0, x15 + st1 { v11.16b }, [x3] + ldp x19, x20, [sp, #16] + ldp x21, x22, [sp, #32] + ldp x23, x24, [sp, #48] + ldp d8, d9, [sp, #64] + ldp d10, d11, [sp, #80] + ldp d12, d13, [sp, #96] + ldp d14, d15, [sp, #112] + ldp x29, x30, [sp], #128 + AARCH64_VALIDATE_LINK_REGISTER + ret +.size aes_gcm_enc_kernel,.-aes_gcm_enc_kernel +.globl aes_gcm_dec_kernel +.hidden aes_gcm_dec_kernel +.type aes_gcm_dec_kernel,%function +.align 4 +aes_gcm_dec_kernel: + AARCH64_SIGN_LINK_REGISTER + stp x29, x30, [sp, #-128]! + mov x29, sp + stp x19, x20, [sp, #16] + mov x16, x4 + mov x8, x5 + stp x21, x22, [sp, #32] + stp x23, x24, [sp, #48] + stp d8, d9, [sp, #64] + stp d10, d11, [sp, #80] + stp d12, d13, [sp, #96] + stp d14, d15, [sp, #112] + ldr w17, [x8, #240] + add x19, x8, x17, lsl #4 // borrow input_l1 for last key + ldp x13, x14, [x19] // load round N keys + ldr q31, [x19, #-16] // load round N-1 keys + lsr x5, x1, #3 // byte_len + mov x15, x5 + ldp x10, x11, [x16] // ctr96_b64, ctr96_t32 + ldr q26, [x8, #128] // load rk8 + sub x5, x5, #1 // byte_len - 1 + ldr q25, [x8, #112] // load rk7 + and x5, x5, #0xffffffffffffffc0 // number of bytes to be processed in main loop (at least 1 byte must be handled by tail) + add x4, x0, x1, lsr #3 // end_input_ptr + ldr q24, [x8, #96] // load rk6 + lsr x12, x11, #32 + ldr q23, [x8, #80] // load rk5 + orr w11, w11, w11 + ldr q21, [x8, #48] // load rk3 + add x5, x5, x0 + rev w12, w12 // rev_ctr32 + add w12, w12, #1 // increment rev_ctr32 + fmov d3, x10 // CTR block 3 + rev w9, w12 // CTR block 1 + add w12, w12, #1 // CTR block 1 + fmov d1, x10 // CTR block 1 + orr x9, x11, x9, lsl #32 // CTR block 1 + ld1 { v0.16b}, [x16] // special case vector load initial counter so we can start first AES block as quickly as possible + fmov v1.d[1], x9 // CTR block 1 + rev w9, w12 // CTR block 2 + add w12, w12, #1 // CTR block 2 + fmov d2, x10 // CTR block 2 + orr x9, x11, x9, lsl #32 // CTR block 2 + fmov v2.d[1], x9 // CTR block 2 + rev w9, w12 // CTR block 3 + orr x9, x11, x9, lsl #32 // CTR block 3 + ldr q18, [x8, #0] // load rk0 + fmov v3.d[1], x9 // CTR block 3 + add w12, w12, #1 // CTR block 3 + ldr q22, [x8, #64] // load rk4 + ldr q19, [x8, #16] // load rk1 + aese v0.16b, v18.16b + aesmc v0.16b, v0.16b // AES block 0 - round 0 + ldr q14, [x6, #48] // load h3l | h3h + ext v14.16b, v14.16b, v14.16b, #8 + aese v3.16b, v18.16b + aesmc v3.16b, v3.16b // AES block 3 - round 0 + ldr q15, [x6, #80] // load h4l | h4h + ext v15.16b, v15.16b, v15.16b, #8 + aese v1.16b, v18.16b + aesmc v1.16b, v1.16b // AES block 1 - round 0 + ldr q13, [x6, #32] // load h2l | h2h + ext v13.16b, v13.16b, v13.16b, #8 + aese v2.16b, v18.16b + aesmc v2.16b, v2.16b // AES block 2 - round 0 + ldr q20, [x8, #32] // load rk2 + aese v0.16b, v19.16b + aesmc v0.16b, v0.16b // AES block 0 - round 1 + aese v1.16b, v19.16b + aesmc v1.16b, v1.16b // AES block 1 - round 1 + ld1 { v11.16b}, [x3] + ext v11.16b, v11.16b, v11.16b, #8 + rev64 v11.16b, v11.16b + aese v2.16b, v19.16b + aesmc v2.16b, v2.16b // AES block 2 - round 1 + ldr q27, [x8, #144] // load rk9 + aese v3.16b, v19.16b + aesmc v3.16b, v3.16b // AES block 3 - round 1 + ldr q30, [x8, #192] // load rk12 + aese v0.16b, v20.16b + aesmc v0.16b, v0.16b // AES block 0 - round 2 + ldr q12, [x6] // load h1l | h1h + ext v12.16b, v12.16b, v12.16b, #8 + aese v2.16b, v20.16b + aesmc v2.16b, v2.16b // AES block 2 - round 2 + ldr q28, [x8, #160] // load rk10 + aese v3.16b, v20.16b + aesmc v3.16b, v3.16b // AES block 3 - round 2 + aese v0.16b, v21.16b + aesmc v0.16b, v0.16b // AES block 0 - round 3 + aese v1.16b, v20.16b + aesmc v1.16b, v1.16b // AES block 1 - round 2 + aese v3.16b, v21.16b + aesmc v3.16b, v3.16b // AES block 3 - round 3 + aese v0.16b, v22.16b + aesmc v0.16b, v0.16b // AES block 0 - round 4 + aese v2.16b, v21.16b + aesmc v2.16b, v2.16b // AES block 2 - round 3 + aese v1.16b, v21.16b + aesmc v1.16b, v1.16b // AES block 1 - round 3 + aese v3.16b, v22.16b + aesmc v3.16b, v3.16b // AES block 3 - round 4 + aese v2.16b, v22.16b + aesmc v2.16b, v2.16b // AES block 2 - round 4 + aese v1.16b, v22.16b + aesmc v1.16b, v1.16b // AES block 1 - round 4 + aese v3.16b, v23.16b + aesmc v3.16b, v3.16b // AES block 3 - round 5 + aese v0.16b, v23.16b + aesmc v0.16b, v0.16b // AES block 0 - round 5 + aese v1.16b, v23.16b + aesmc v1.16b, v1.16b // AES block 1 - round 5 + aese v2.16b, v23.16b + aesmc v2.16b, v2.16b // AES block 2 - round 5 + aese v0.16b, v24.16b + aesmc v0.16b, v0.16b // AES block 0 - round 6 + aese v3.16b, v24.16b + aesmc v3.16b, v3.16b // AES block 3 - round 6 + cmp x17, #12 // setup flags for AES-128/192/256 check + aese v1.16b, v24.16b + aesmc v1.16b, v1.16b // AES block 1 - round 6 + aese v2.16b, v24.16b + aesmc v2.16b, v2.16b // AES block 2 - round 6 + aese v0.16b, v25.16b + aesmc v0.16b, v0.16b // AES block 0 - round 7 + aese v1.16b, v25.16b + aesmc v1.16b, v1.16b // AES block 1 - round 7 + aese v3.16b, v25.16b + aesmc v3.16b, v3.16b // AES block 3 - round 7 + aese v0.16b, v26.16b + aesmc v0.16b, v0.16b // AES block 0 - round 8 + aese v2.16b, v25.16b + aesmc v2.16b, v2.16b // AES block 2 - round 7 + aese v3.16b, v26.16b + aesmc v3.16b, v3.16b // AES block 3 - round 8 + aese v1.16b, v26.16b + aesmc v1.16b, v1.16b // AES block 1 - round 8 + ldr q29, [x8, #176] // load rk11 + aese v2.16b, v26.16b + aesmc v2.16b, v2.16b // AES block 2 - round 8 + b.lt .Ldec_finish_first_blocks // branch if AES-128 + + aese v0.16b, v27.16b + aesmc v0.16b, v0.16b // AES block 0 - round 9 + aese v1.16b, v27.16b + aesmc v1.16b, v1.16b // AES block 1 - round 9 + aese v3.16b, v27.16b + aesmc v3.16b, v3.16b // AES block 3 - round 9 + aese v2.16b, v27.16b + aesmc v2.16b, v2.16b // AES block 2 - round 9 + aese v0.16b, v28.16b + aesmc v0.16b, v0.16b // AES block 0 - round 10 + aese v1.16b, v28.16b + aesmc v1.16b, v1.16b // AES block 1 - round 10 + aese v3.16b, v28.16b + aesmc v3.16b, v3.16b // AES block 3 - round 10 + aese v2.16b, v28.16b + aesmc v2.16b, v2.16b // AES block 2 - round 10 + b.eq .Ldec_finish_first_blocks // branch if AES-192 + + aese v0.16b, v29.16b + aesmc v0.16b, v0.16b // AES block 0 - round 11 + aese v3.16b, v29.16b + aesmc v3.16b, v3.16b // AES block 3 - round 11 + aese v1.16b, v29.16b + aesmc v1.16b, v1.16b // AES block 1 - round 11 + aese v2.16b, v29.16b + aesmc v2.16b, v2.16b // AES block 2 - round 11 + aese v1.16b, v30.16b + aesmc v1.16b, v1.16b // AES block 1 - round 12 + aese v0.16b, v30.16b + aesmc v0.16b, v0.16b // AES block 0 - round 12 + aese v2.16b, v30.16b + aesmc v2.16b, v2.16b // AES block 2 - round 12 + aese v3.16b, v30.16b + aesmc v3.16b, v3.16b // AES block 3 - round 12 + +.Ldec_finish_first_blocks: + cmp x0, x5 // check if we have <= 4 blocks + trn1 v9.2d, v14.2d, v15.2d // h4h | h3h + trn2 v17.2d, v14.2d, v15.2d // h4l | h3l + trn1 v8.2d, v12.2d, v13.2d // h2h | h1h + trn2 v16.2d, v12.2d, v13.2d // h2l | h1l + eor v17.16b, v17.16b, v9.16b // h4k | h3k + aese v1.16b, v31.16b // AES block 1 - round N-1 + aese v2.16b, v31.16b // AES block 2 - round N-1 + eor v16.16b, v16.16b, v8.16b // h2k | h1k + aese v3.16b, v31.16b // AES block 3 - round N-1 + aese v0.16b, v31.16b // AES block 0 - round N-1 + b.ge .Ldec_tail // handle tail + + ldr q4, [x0, #0] // AES block 0 - load ciphertext + ldr q5, [x0, #16] // AES block 1 - load ciphertext + rev w9, w12 // CTR block 4 + eor v0.16b, v4.16b, v0.16b // AES block 0 - result + eor v1.16b, v5.16b, v1.16b // AES block 1 - result + rev64 v5.16b, v5.16b // GHASH block 1 + ldr q7, [x0, #48] // AES block 3 - load ciphertext + mov x7, v0.d[1] // AES block 0 - mov high + mov x6, v0.d[0] // AES block 0 - mov low + rev64 v4.16b, v4.16b // GHASH block 0 + add w12, w12, #1 // CTR block 4 + fmov d0, x10 // CTR block 4 + orr x9, x11, x9, lsl #32 // CTR block 4 + fmov v0.d[1], x9 // CTR block 4 + rev w9, w12 // CTR block 5 + add w12, w12, #1 // CTR block 5 + mov x19, v1.d[0] // AES block 1 - mov low + orr x9, x11, x9, lsl #32 // CTR block 5 + mov x20, v1.d[1] // AES block 1 - mov high + eor x7, x7, x14 // AES block 0 - round N high + eor x6, x6, x13 // AES block 0 - round N low + stp x6, x7, [x2], #16 // AES block 0 - store result + fmov d1, x10 // CTR block 5 + ldr q6, [x0, #32] // AES block 2 - load ciphertext + add x0, x0, #64 // AES input_ptr update + fmov v1.d[1], x9 // CTR block 5 + rev w9, w12 // CTR block 6 + add w12, w12, #1 // CTR block 6 + eor x19, x19, x13 // AES block 1 - round N low + orr x9, x11, x9, lsl #32 // CTR block 6 + eor x20, x20, x14 // AES block 1 - round N high + stp x19, x20, [x2], #16 // AES block 1 - store result + eor v2.16b, v6.16b, v2.16b // AES block 2 - result + cmp x0, x5 // check if we have <= 8 blocks + b.ge .Ldec_prepretail // do prepretail + +.Ldec_main_loop: // main loop start + mov x21, v2.d[0] // AES block 4k+2 - mov low + ext v11.16b, v11.16b, v11.16b, #8 // PRE 0 + eor v3.16b, v7.16b, v3.16b // AES block 4k+3 - result + aese v0.16b, v18.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 0 + mov x22, v2.d[1] // AES block 4k+2 - mov high + aese v1.16b, v18.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 0 + fmov d2, x10 // CTR block 4k+6 + fmov v2.d[1], x9 // CTR block 4k+6 + eor v4.16b, v4.16b, v11.16b // PRE 1 + rev w9, w12 // CTR block 4k+7 + aese v0.16b, v19.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 1 + mov x24, v3.d[1] // AES block 4k+3 - mov high + aese v1.16b, v19.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 1 + mov x23, v3.d[0] // AES block 4k+3 - mov low + pmull2 v9.1q, v4.2d, v15.2d // GHASH block 4k - high + mov d8, v4.d[1] // GHASH block 4k - mid + fmov d3, x10 // CTR block 4k+7 + aese v0.16b, v20.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 2 + orr x9, x11, x9, lsl #32 // CTR block 4k+7 + aese v2.16b, v18.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 0 + fmov v3.d[1], x9 // CTR block 4k+7 + aese v1.16b, v20.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 2 + eor v8.8b, v8.8b, v4.8b // GHASH block 4k - mid + aese v0.16b, v21.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 3 + eor x22, x22, x14 // AES block 4k+2 - round N high + aese v2.16b, v19.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 1 + mov d10, v17.d[1] // GHASH block 4k - mid + aese v1.16b, v21.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 3 + rev64 v6.16b, v6.16b // GHASH block 4k+2 + aese v3.16b, v18.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 0 + eor x21, x21, x13 // AES block 4k+2 - round N low + aese v2.16b, v20.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 2 + stp x21, x22, [x2], #16 // AES block 4k+2 - store result + pmull v11.1q, v4.1d, v15.1d // GHASH block 4k - low + pmull2 v4.1q, v5.2d, v14.2d // GHASH block 4k+1 - high + aese v2.16b, v21.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 3 + rev64 v7.16b, v7.16b // GHASH block 4k+3 + pmull v10.1q, v8.1d, v10.1d // GHASH block 4k - mid + eor x23, x23, x13 // AES block 4k+3 - round N low + pmull v8.1q, v5.1d, v14.1d // GHASH block 4k+1 - low + eor x24, x24, x14 // AES block 4k+3 - round N high + eor v9.16b, v9.16b, v4.16b // GHASH block 4k+1 - high + aese v2.16b, v22.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 4 + aese v3.16b, v19.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 1 + mov d4, v5.d[1] // GHASH block 4k+1 - mid + aese v0.16b, v22.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 4 + eor v11.16b, v11.16b, v8.16b // GHASH block 4k+1 - low + aese v2.16b, v23.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 5 + add w12, w12, #1 // CTR block 4k+7 + aese v3.16b, v20.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 2 + mov d8, v6.d[1] // GHASH block 4k+2 - mid + aese v1.16b, v22.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 4 + eor v4.8b, v4.8b, v5.8b // GHASH block 4k+1 - mid + pmull v5.1q, v6.1d, v13.1d // GHASH block 4k+2 - low + aese v3.16b, v21.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 3 + eor v8.8b, v8.8b, v6.8b // GHASH block 4k+2 - mid + aese v1.16b, v23.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 5 + aese v0.16b, v23.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 5 + eor v11.16b, v11.16b, v5.16b // GHASH block 4k+2 - low + pmull v4.1q, v4.1d, v17.1d // GHASH block 4k+1 - mid + rev w9, w12 // CTR block 4k+8 + aese v1.16b, v24.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 6 + ins v8.d[1], v8.d[0] // GHASH block 4k+2 - mid + aese v0.16b, v24.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 6 + add w12, w12, #1 // CTR block 4k+8 + aese v3.16b, v22.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 4 + aese v1.16b, v25.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 7 + eor v10.16b, v10.16b, v4.16b // GHASH block 4k+1 - mid + aese v0.16b, v25.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 7 + pmull2 v4.1q, v6.2d, v13.2d // GHASH block 4k+2 - high + mov d6, v7.d[1] // GHASH block 4k+3 - mid + aese v3.16b, v23.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 5 + pmull2 v8.1q, v8.2d, v16.2d // GHASH block 4k+2 - mid + aese v0.16b, v26.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 8 + eor v9.16b, v9.16b, v4.16b // GHASH block 4k+2 - high + aese v3.16b, v24.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 6 + pmull v4.1q, v7.1d, v12.1d // GHASH block 4k+3 - low + orr x9, x11, x9, lsl #32 // CTR block 4k+8 + eor v10.16b, v10.16b, v8.16b // GHASH block 4k+2 - mid + pmull2 v5.1q, v7.2d, v12.2d // GHASH block 4k+3 - high + cmp x17, #12 // setup flags for AES-128/192/256 check + eor v6.8b, v6.8b, v7.8b // GHASH block 4k+3 - mid + aese v1.16b, v26.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 8 + aese v2.16b, v24.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 6 + eor v9.16b, v9.16b, v5.16b // GHASH block 4k+3 - high + pmull v6.1q, v6.1d, v16.1d // GHASH block 4k+3 - mid + movi v8.8b, #0xc2 + aese v2.16b, v25.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 7 + eor v11.16b, v11.16b, v4.16b // GHASH block 4k+3 - low + aese v3.16b, v25.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 7 + shl d8, d8, #56 // mod_constant + aese v2.16b, v26.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 8 + eor v10.16b, v10.16b, v6.16b // GHASH block 4k+3 - mid + aese v3.16b, v26.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 8 + b.lt .Ldec_main_loop_continue // branch if AES-128 + + aese v0.16b, v27.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 9 + aese v2.16b, v27.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 9 + aese v1.16b, v27.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 9 + aese v3.16b, v27.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 9 + aese v0.16b, v28.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 10 + aese v1.16b, v28.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 10 + aese v2.16b, v28.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 10 + aese v3.16b, v28.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 10 + b.eq .Ldec_main_loop_continue // branch if AES-192 + + aese v0.16b, v29.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 11 + aese v1.16b, v29.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 11 + aese v2.16b, v29.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 11 + aese v3.16b, v29.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 11 + aese v0.16b, v30.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 12 + aese v1.16b, v30.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 12 + aese v2.16b, v30.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 12 + aese v3.16b, v30.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 12 + +.Ldec_main_loop_continue: + pmull v7.1q, v9.1d, v8.1d // MODULO - top 64b align with mid + eor v6.16b, v11.16b, v9.16b // MODULO - karatsuba tidy up + ldr q4, [x0, #0] // AES block 4k+4 - load ciphertext + aese v0.16b, v31.16b // AES block 4k+4 - round N-1 + ext v9.16b, v9.16b, v9.16b, #8 // MODULO - other top alignment + eor v10.16b, v10.16b, v6.16b // MODULO - karatsuba tidy up + ldr q5, [x0, #16] // AES block 4k+5 - load ciphertext + eor v0.16b, v4.16b, v0.16b // AES block 4k+4 - result + stp x23, x24, [x2], #16 // AES block 4k+3 - store result + eor v10.16b, v10.16b, v7.16b // MODULO - fold into mid + ldr q7, [x0, #48] // AES block 4k+7 - load ciphertext + ldr q6, [x0, #32] // AES block 4k+6 - load ciphertext + mov x7, v0.d[1] // AES block 4k+4 - mov high + eor v10.16b, v10.16b, v9.16b // MODULO - fold into mid + aese v1.16b, v31.16b // AES block 4k+5 - round N-1 + add x0, x0, #64 // AES input_ptr update + mov x6, v0.d[0] // AES block 4k+4 - mov low + fmov d0, x10 // CTR block 4k+8 + fmov v0.d[1], x9 // CTR block 4k+8 + pmull v8.1q, v10.1d, v8.1d // MODULO - mid 64b align with low + eor v1.16b, v5.16b, v1.16b // AES block 4k+5 - result + rev w9, w12 // CTR block 4k+9 + aese v2.16b, v31.16b // AES block 4k+6 - round N-1 + orr x9, x11, x9, lsl #32 // CTR block 4k+9 + cmp x0, x5 // .LOOP CONTROL + add w12, w12, #1 // CTR block 4k+9 + eor x6, x6, x13 // AES block 4k+4 - round N low + eor x7, x7, x14 // AES block 4k+4 - round N high + mov x20, v1.d[1] // AES block 4k+5 - mov high + eor v2.16b, v6.16b, v2.16b // AES block 4k+6 - result + eor v11.16b, v11.16b, v8.16b // MODULO - fold into low + mov x19, v1.d[0] // AES block 4k+5 - mov low + fmov d1, x10 // CTR block 4k+9 + ext v10.16b, v10.16b, v10.16b, #8 // MODULO - other mid alignment + fmov v1.d[1], x9 // CTR block 4k+9 + rev w9, w12 // CTR block 4k+10 + add w12, w12, #1 // CTR block 4k+10 + aese v3.16b, v31.16b // AES block 4k+7 - round N-1 + orr x9, x11, x9, lsl #32 // CTR block 4k+10 + rev64 v5.16b, v5.16b // GHASH block 4k+5 + eor x20, x20, x14 // AES block 4k+5 - round N high + stp x6, x7, [x2], #16 // AES block 4k+4 - store result + eor x19, x19, x13 // AES block 4k+5 - round N low + stp x19, x20, [x2], #16 // AES block 4k+5 - store result + rev64 v4.16b, v4.16b // GHASH block 4k+4 + eor v11.16b, v11.16b, v10.16b // MODULO - fold into low + b.lt .Ldec_main_loop + +.Ldec_prepretail: // PREPRETAIL + ext v11.16b, v11.16b, v11.16b, #8 // PRE 0 + mov x21, v2.d[0] // AES block 4k+2 - mov low + eor v3.16b, v7.16b, v3.16b // AES block 4k+3 - result + aese v0.16b, v18.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 0 + mov x22, v2.d[1] // AES block 4k+2 - mov high + aese v1.16b, v18.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 0 + fmov d2, x10 // CTR block 4k+6 + fmov v2.d[1], x9 // CTR block 4k+6 + rev w9, w12 // CTR block 4k+7 + eor v4.16b, v4.16b, v11.16b // PRE 1 + rev64 v6.16b, v6.16b // GHASH block 4k+2 + orr x9, x11, x9, lsl #32 // CTR block 4k+7 + mov x23, v3.d[0] // AES block 4k+3 - mov low + aese v1.16b, v19.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 1 + mov x24, v3.d[1] // AES block 4k+3 - mov high + pmull v11.1q, v4.1d, v15.1d // GHASH block 4k - low + mov d8, v4.d[1] // GHASH block 4k - mid + fmov d3, x10 // CTR block 4k+7 + pmull2 v9.1q, v4.2d, v15.2d // GHASH block 4k - high + fmov v3.d[1], x9 // CTR block 4k+7 + aese v2.16b, v18.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 0 + mov d10, v17.d[1] // GHASH block 4k - mid + aese v0.16b, v19.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 1 + eor v8.8b, v8.8b, v4.8b // GHASH block 4k - mid + pmull2 v4.1q, v5.2d, v14.2d // GHASH block 4k+1 - high + aese v2.16b, v19.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 1 + rev64 v7.16b, v7.16b // GHASH block 4k+3 + aese v3.16b, v18.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 0 + pmull v10.1q, v8.1d, v10.1d // GHASH block 4k - mid + eor v9.16b, v9.16b, v4.16b // GHASH block 4k+1 - high + pmull v8.1q, v5.1d, v14.1d // GHASH block 4k+1 - low + aese v3.16b, v19.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 1 + mov d4, v5.d[1] // GHASH block 4k+1 - mid + aese v0.16b, v20.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 2 + aese v1.16b, v20.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 2 + eor v11.16b, v11.16b, v8.16b // GHASH block 4k+1 - low + aese v2.16b, v20.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 2 + aese v0.16b, v21.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 3 + mov d8, v6.d[1] // GHASH block 4k+2 - mid + aese v3.16b, v20.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 2 + eor v4.8b, v4.8b, v5.8b // GHASH block 4k+1 - mid + pmull v5.1q, v6.1d, v13.1d // GHASH block 4k+2 - low + aese v0.16b, v22.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 4 + aese v3.16b, v21.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 3 + eor v8.8b, v8.8b, v6.8b // GHASH block 4k+2 - mid + pmull v4.1q, v4.1d, v17.1d // GHASH block 4k+1 - mid + aese v0.16b, v23.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 5 + eor v11.16b, v11.16b, v5.16b // GHASH block 4k+2 - low + aese v3.16b, v22.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 4 + pmull2 v5.1q, v7.2d, v12.2d // GHASH block 4k+3 - high + eor v10.16b, v10.16b, v4.16b // GHASH block 4k+1 - mid + pmull2 v4.1q, v6.2d, v13.2d // GHASH block 4k+2 - high + aese v3.16b, v23.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 5 + ins v8.d[1], v8.d[0] // GHASH block 4k+2 - mid + aese v2.16b, v21.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 3 + aese v1.16b, v21.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 3 + eor v9.16b, v9.16b, v4.16b // GHASH block 4k+2 - high + pmull v4.1q, v7.1d, v12.1d // GHASH block 4k+3 - low + aese v2.16b, v22.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 4 + mov d6, v7.d[1] // GHASH block 4k+3 - mid + aese v1.16b, v22.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 4 + pmull2 v8.1q, v8.2d, v16.2d // GHASH block 4k+2 - mid + aese v2.16b, v23.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 5 + eor v6.8b, v6.8b, v7.8b // GHASH block 4k+3 - mid + aese v1.16b, v23.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 5 + aese v3.16b, v24.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 6 + eor v10.16b, v10.16b, v8.16b // GHASH block 4k+2 - mid + aese v2.16b, v24.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 6 + aese v0.16b, v24.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 6 + movi v8.8b, #0xc2 + aese v1.16b, v24.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 6 + eor v11.16b, v11.16b, v4.16b // GHASH block 4k+3 - low + pmull v6.1q, v6.1d, v16.1d // GHASH block 4k+3 - mid + aese v3.16b, v25.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 7 + cmp x17, #12 // setup flags for AES-128/192/256 check + eor v9.16b, v9.16b, v5.16b // GHASH block 4k+3 - high + aese v1.16b, v25.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 7 + aese v0.16b, v25.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 7 + eor v10.16b, v10.16b, v6.16b // GHASH block 4k+3 - mid + aese v3.16b, v26.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 8 + aese v2.16b, v25.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 7 + eor v6.16b, v11.16b, v9.16b // MODULO - karatsuba tidy up + aese v1.16b, v26.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 8 + aese v0.16b, v26.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 8 + shl d8, d8, #56 // mod_constant + aese v2.16b, v26.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 8 + b.lt .Ldec_finish_prepretail // branch if AES-128 + + aese v1.16b, v27.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 9 + aese v2.16b, v27.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 9 + aese v3.16b, v27.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 9 + aese v0.16b, v27.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 9 + aese v2.16b, v28.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 10 + aese v3.16b, v28.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 10 + aese v0.16b, v28.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 10 + aese v1.16b, v28.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 10 + b.eq .Ldec_finish_prepretail // branch if AES-192 + + aese v2.16b, v29.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 11 + aese v0.16b, v29.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 11 + aese v1.16b, v29.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 11 + aese v2.16b, v30.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 12 + aese v3.16b, v29.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 11 + aese v1.16b, v30.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 12 + aese v0.16b, v30.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 12 + aese v3.16b, v30.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 12 + +.Ldec_finish_prepretail: + eor v10.16b, v10.16b, v6.16b // MODULO - karatsuba tidy up + pmull v7.1q, v9.1d, v8.1d // MODULO - top 64b align with mid + ext v9.16b, v9.16b, v9.16b, #8 // MODULO - other top alignment + eor v10.16b, v10.16b, v7.16b // MODULO - fold into mid + eor x22, x22, x14 // AES block 4k+2 - round N high + eor x23, x23, x13 // AES block 4k+3 - round N low + eor v10.16b, v10.16b, v9.16b // MODULO - fold into mid + add w12, w12, #1 // CTR block 4k+7 + eor x21, x21, x13 // AES block 4k+2 - round N low + pmull v8.1q, v10.1d, v8.1d // MODULO - mid 64b align with low + eor x24, x24, x14 // AES block 4k+3 - round N high + stp x21, x22, [x2], #16 // AES block 4k+2 - store result + ext v10.16b, v10.16b, v10.16b, #8 // MODULO - other mid alignment + stp x23, x24, [x2], #16 // AES block 4k+3 - store result + + eor v11.16b, v11.16b, v8.16b // MODULO - fold into low + aese v1.16b, v31.16b // AES block 4k+5 - round N-1 + aese v0.16b, v31.16b // AES block 4k+4 - round N-1 + aese v3.16b, v31.16b // AES block 4k+7 - round N-1 + aese v2.16b, v31.16b // AES block 4k+6 - round N-1 + eor v11.16b, v11.16b, v10.16b // MODULO - fold into low + +.Ldec_tail: // TAIL + sub x5, x4, x0 // main_end_input_ptr is number of bytes left to process + ld1 { v5.16b}, [x0], #16 // AES block 4k+4 - load ciphertext + eor v0.16b, v5.16b, v0.16b // AES block 4k+4 - result + mov x6, v0.d[0] // AES block 4k+4 - mov low + mov x7, v0.d[1] // AES block 4k+4 - mov high + ext v8.16b, v11.16b, v11.16b, #8 // prepare final partial tag + cmp x5, #48 + eor x6, x6, x13 // AES block 4k+4 - round N low + eor x7, x7, x14 // AES block 4k+4 - round N high + b.gt .Ldec_blocks_more_than_3 + sub w12, w12, #1 + mov v3.16b, v2.16b + movi v10.8b, #0 + movi v11.8b, #0 + cmp x5, #32 + movi v9.8b, #0 + mov v2.16b, v1.16b + b.gt .Ldec_blocks_more_than_2 + sub w12, w12, #1 + mov v3.16b, v1.16b + cmp x5, #16 + b.gt .Ldec_blocks_more_than_1 + sub w12, w12, #1 + b .Ldec_blocks_less_than_1 +.Ldec_blocks_more_than_3: // blocks left > 3 + rev64 v4.16b, v5.16b // GHASH final-3 block + ld1 { v5.16b}, [x0], #16 // AES final-2 block - load ciphertext + stp x6, x7, [x2], #16 // AES final-3 block - store result + mov d10, v17.d[1] // GHASH final-3 block - mid + eor v4.16b, v4.16b, v8.16b // feed in partial tag + eor v0.16b, v5.16b, v1.16b // AES final-2 block - result + mov d22, v4.d[1] // GHASH final-3 block - mid + mov x6, v0.d[0] // AES final-2 block - mov low + mov x7, v0.d[1] // AES final-2 block - mov high + eor v22.8b, v22.8b, v4.8b // GHASH final-3 block - mid + movi v8.8b, #0 // suppress further partial tag feed in + pmull2 v9.1q, v4.2d, v15.2d // GHASH final-3 block - high + pmull v10.1q, v22.1d, v10.1d // GHASH final-3 block - mid + eor x6, x6, x13 // AES final-2 block - round N low + pmull v11.1q, v4.1d, v15.1d // GHASH final-3 block - low + eor x7, x7, x14 // AES final-2 block - round N high +.Ldec_blocks_more_than_2: // blocks left > 2 + rev64 v4.16b, v5.16b // GHASH final-2 block + ld1 { v5.16b}, [x0], #16 // AES final-1 block - load ciphertext + eor v4.16b, v4.16b, v8.16b // feed in partial tag + stp x6, x7, [x2], #16 // AES final-2 block - store result + eor v0.16b, v5.16b, v2.16b // AES final-1 block - result + mov d22, v4.d[1] // GHASH final-2 block - mid + pmull v21.1q, v4.1d, v14.1d // GHASH final-2 block - low + pmull2 v20.1q, v4.2d, v14.2d // GHASH final-2 block - high + eor v22.8b, v22.8b, v4.8b // GHASH final-2 block - mid + mov x6, v0.d[0] // AES final-1 block - mov low + mov x7, v0.d[1] // AES final-1 block - mov high + eor v11.16b, v11.16b, v21.16b // GHASH final-2 block - low + movi v8.8b, #0 // suppress further partial tag feed in + pmull v22.1q, v22.1d, v17.1d // GHASH final-2 block - mid + eor v9.16b, v9.16b, v20.16b // GHASH final-2 block - high + eor x6, x6, x13 // AES final-1 block - round N low + eor v10.16b, v10.16b, v22.16b // GHASH final-2 block - mid + eor x7, x7, x14 // AES final-1 block - round N high +.Ldec_blocks_more_than_1: // blocks left > 1 + stp x6, x7, [x2], #16 // AES final-1 block - store result + rev64 v4.16b, v5.16b // GHASH final-1 block + ld1 { v5.16b}, [x0], #16 // AES final block - load ciphertext + eor v4.16b, v4.16b, v8.16b // feed in partial tag + movi v8.8b, #0 // suppress further partial tag feed in + mov d22, v4.d[1] // GHASH final-1 block - mid + eor v0.16b, v5.16b, v3.16b // AES final block - result + pmull2 v20.1q, v4.2d, v13.2d // GHASH final-1 block - high + eor v22.8b, v22.8b, v4.8b // GHASH final-1 block - mid + pmull v21.1q, v4.1d, v13.1d // GHASH final-1 block - low + mov x6, v0.d[0] // AES final block - mov low + ins v22.d[1], v22.d[0] // GHASH final-1 block - mid + mov x7, v0.d[1] // AES final block - mov high + pmull2 v22.1q, v22.2d, v16.2d // GHASH final-1 block - mid + eor x6, x6, x13 // AES final block - round N low + eor v11.16b, v11.16b, v21.16b // GHASH final-1 block - low + eor v9.16b, v9.16b, v20.16b // GHASH final-1 block - high + eor v10.16b, v10.16b, v22.16b // GHASH final-1 block - mid + eor x7, x7, x14 // AES final block - round N high +.Ldec_blocks_less_than_1: // blocks left <= 1 + and x1, x1, #127 // bit_length %= 128 + mvn x14, xzr // rkN_h = 0xffffffffffffffff + sub x1, x1, #128 // bit_length -= 128 + mvn x13, xzr // rkN_l = 0xffffffffffffffff + ldp x4, x5, [x2] // load existing bytes we need to not overwrite + neg x1, x1 // bit_length = 128 - #bits in input (in range [1,128]) + and x1, x1, #127 // bit_length %= 128 + lsr x14, x14, x1 // rkN_h is mask for top 64b of last block + cmp x1, #64 + csel x9, x13, x14, lt + csel x10, x14, xzr, lt + fmov d0, x9 // ctr0b is mask for last block + and x6, x6, x9 + mov v0.d[1], x10 + bic x4, x4, x9 // mask out low existing bytes + rev w9, w12 + bic x5, x5, x10 // mask out high existing bytes + orr x6, x6, x4 + and x7, x7, x10 + orr x7, x7, x5 + and v5.16b, v5.16b, v0.16b // possibly partial last block has zeroes in highest bits + rev64 v4.16b, v5.16b // GHASH final block + eor v4.16b, v4.16b, v8.16b // feed in partial tag + pmull v21.1q, v4.1d, v12.1d // GHASH final block - low + mov d8, v4.d[1] // GHASH final block - mid + eor v8.8b, v8.8b, v4.8b // GHASH final block - mid + pmull2 v20.1q, v4.2d, v12.2d // GHASH final block - high + pmull v8.1q, v8.1d, v16.1d // GHASH final block - mid + eor v9.16b, v9.16b, v20.16b // GHASH final block - high + eor v11.16b, v11.16b, v21.16b // GHASH final block - low + eor v10.16b, v10.16b, v8.16b // GHASH final block - mid + movi v8.8b, #0xc2 + eor v6.16b, v11.16b, v9.16b // MODULO - karatsuba tidy up + shl d8, d8, #56 // mod_constant + eor v10.16b, v10.16b, v6.16b // MODULO - karatsuba tidy up + pmull v7.1q, v9.1d, v8.1d // MODULO - top 64b align with mid + ext v9.16b, v9.16b, v9.16b, #8 // MODULO - other top alignment + eor v10.16b, v10.16b, v7.16b // MODULO - fold into mid + eor v10.16b, v10.16b, v9.16b // MODULO - fold into mid + pmull v8.1q, v10.1d, v8.1d // MODULO - mid 64b align with low + ext v10.16b, v10.16b, v10.16b, #8 // MODULO - other mid alignment + eor v11.16b, v11.16b, v8.16b // MODULO - fold into low + stp x6, x7, [x2] + str w9, [x16, #12] // store the updated counter + eor v11.16b, v11.16b, v10.16b // MODULO - fold into low + ext v11.16b, v11.16b, v11.16b, #8 + rev64 v11.16b, v11.16b + mov x0, x15 + st1 { v11.16b }, [x3] + ldp x19, x20, [sp, #16] + ldp x21, x22, [sp, #32] + ldp x23, x24, [sp, #48] + ldp d8, d9, [sp, #64] + ldp d10, d11, [sp, #80] + ldp d12, d13, [sp, #96] + ldp d14, d15, [sp, #112] + ldp x29, x30, [sp], #128 + AARCH64_VALIDATE_LINK_REGISTER + ret +.size aes_gcm_dec_kernel,.-aes_gcm_dec_kernel +#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__ELF__) diff --git a/http/vendor/ring/pregenerated/aesv8-gcm-armv8-win64.S b/http/vendor/ring/pregenerated/aesv8-gcm-armv8-win64.S new file mode 100644 index 0000000..6f39544 --- /dev/null +++ b/http/vendor/ring/pregenerated/aesv8-gcm-armv8-win64.S @@ -0,0 +1,1558 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(_WIN32) +#if __ARM_MAX_ARCH__ >= 8 + +.arch armv8-a+crypto +.text +.globl aes_gcm_enc_kernel + +.def aes_gcm_enc_kernel + .type 32 +.endef +.align 4 +aes_gcm_enc_kernel: + AARCH64_SIGN_LINK_REGISTER + stp x29, x30, [sp, #-128]! + mov x29, sp + stp x19, x20, [sp, #16] + mov x16, x4 + mov x8, x5 + stp x21, x22, [sp, #32] + stp x23, x24, [sp, #48] + stp d8, d9, [sp, #64] + stp d10, d11, [sp, #80] + stp d12, d13, [sp, #96] + stp d14, d15, [sp, #112] + ldr w17, [x8, #240] + add x19, x8, x17, lsl #4 // borrow input_l1 for last key + ldp x13, x14, [x19] // load round N keys + ldr q31, [x19, #-16] // load round N-1 keys + add x4, x0, x1, lsr #3 // end_input_ptr + lsr x5, x1, #3 // byte_len + mov x15, x5 + ldp x10, x11, [x16] // ctr96_b64, ctr96_t32 + ld1 { v0.16b}, [x16] // special case vector load initial counter so we can start first AES block as quickly as possible + sub x5, x5, #1 // byte_len - 1 + ldr q18, [x8, #0] // load rk0 + and x5, x5, #0xffffffffffffffc0 // number of bytes to be processed in main loop (at least 1 byte must be handled by tail) + ldr q25, [x8, #112] // load rk7 + add x5, x5, x0 + lsr x12, x11, #32 + fmov d2, x10 // CTR block 2 + orr w11, w11, w11 + rev w12, w12 // rev_ctr32 + fmov d1, x10 // CTR block 1 + aese v0.16b, v18.16b + aesmc v0.16b, v0.16b // AES block 0 - round 0 + add w12, w12, #1 // increment rev_ctr32 + rev w9, w12 // CTR block 1 + fmov d3, x10 // CTR block 3 + orr x9, x11, x9, lsl #32 // CTR block 1 + add w12, w12, #1 // CTR block 1 + ldr q19, [x8, #16] // load rk1 + fmov v1.d[1], x9 // CTR block 1 + rev w9, w12 // CTR block 2 + add w12, w12, #1 // CTR block 2 + orr x9, x11, x9, lsl #32 // CTR block 2 + ldr q20, [x8, #32] // load rk2 + fmov v2.d[1], x9 // CTR block 2 + rev w9, w12 // CTR block 3 + aese v0.16b, v19.16b + aesmc v0.16b, v0.16b // AES block 0 - round 1 + orr x9, x11, x9, lsl #32 // CTR block 3 + fmov v3.d[1], x9 // CTR block 3 + aese v1.16b, v18.16b + aesmc v1.16b, v1.16b // AES block 1 - round 0 + ldr q21, [x8, #48] // load rk3 + aese v0.16b, v20.16b + aesmc v0.16b, v0.16b // AES block 0 - round 2 + ldr q24, [x8, #96] // load rk6 + aese v2.16b, v18.16b + aesmc v2.16b, v2.16b // AES block 2 - round 0 + ldr q23, [x8, #80] // load rk5 + aese v1.16b, v19.16b + aesmc v1.16b, v1.16b // AES block 1 - round 1 + ldr q14, [x6, #48] // load h3l | h3h + ext v14.16b, v14.16b, v14.16b, #8 + aese v3.16b, v18.16b + aesmc v3.16b, v3.16b // AES block 3 - round 0 + aese v2.16b, v19.16b + aesmc v2.16b, v2.16b // AES block 2 - round 1 + ldr q22, [x8, #64] // load rk4 + aese v1.16b, v20.16b + aesmc v1.16b, v1.16b // AES block 1 - round 2 + ldr q13, [x6, #32] // load h2l | h2h + ext v13.16b, v13.16b, v13.16b, #8 + aese v3.16b, v19.16b + aesmc v3.16b, v3.16b // AES block 3 - round 1 + ldr q30, [x8, #192] // load rk12 + aese v2.16b, v20.16b + aesmc v2.16b, v2.16b // AES block 2 - round 2 + ldr q15, [x6, #80] // load h4l | h4h + ext v15.16b, v15.16b, v15.16b, #8 + aese v1.16b, v21.16b + aesmc v1.16b, v1.16b // AES block 1 - round 3 + ldr q29, [x8, #176] // load rk11 + aese v3.16b, v20.16b + aesmc v3.16b, v3.16b // AES block 3 - round 2 + ldr q26, [x8, #128] // load rk8 + aese v2.16b, v21.16b + aesmc v2.16b, v2.16b // AES block 2 - round 3 + add w12, w12, #1 // CTR block 3 + aese v0.16b, v21.16b + aesmc v0.16b, v0.16b // AES block 0 - round 3 + aese v3.16b, v21.16b + aesmc v3.16b, v3.16b // AES block 3 - round 3 + ld1 { v11.16b}, [x3] + ext v11.16b, v11.16b, v11.16b, #8 + rev64 v11.16b, v11.16b + aese v2.16b, v22.16b + aesmc v2.16b, v2.16b // AES block 2 - round 4 + aese v0.16b, v22.16b + aesmc v0.16b, v0.16b // AES block 0 - round 4 + aese v1.16b, v22.16b + aesmc v1.16b, v1.16b // AES block 1 - round 4 + aese v3.16b, v22.16b + aesmc v3.16b, v3.16b // AES block 3 - round 4 + cmp x17, #12 // setup flags for AES-128/192/256 check + aese v0.16b, v23.16b + aesmc v0.16b, v0.16b // AES block 0 - round 5 + aese v1.16b, v23.16b + aesmc v1.16b, v1.16b // AES block 1 - round 5 + aese v3.16b, v23.16b + aesmc v3.16b, v3.16b // AES block 3 - round 5 + aese v2.16b, v23.16b + aesmc v2.16b, v2.16b // AES block 2 - round 5 + aese v1.16b, v24.16b + aesmc v1.16b, v1.16b // AES block 1 - round 6 + trn2 v17.2d, v14.2d, v15.2d // h4l | h3l + aese v3.16b, v24.16b + aesmc v3.16b, v3.16b // AES block 3 - round 6 + ldr q27, [x8, #144] // load rk9 + aese v0.16b, v24.16b + aesmc v0.16b, v0.16b // AES block 0 - round 6 + ldr q12, [x6] // load h1l | h1h + ext v12.16b, v12.16b, v12.16b, #8 + aese v2.16b, v24.16b + aesmc v2.16b, v2.16b // AES block 2 - round 6 + ldr q28, [x8, #160] // load rk10 + aese v1.16b, v25.16b + aesmc v1.16b, v1.16b // AES block 1 - round 7 + trn1 v9.2d, v14.2d, v15.2d // h4h | h3h + aese v0.16b, v25.16b + aesmc v0.16b, v0.16b // AES block 0 - round 7 + aese v2.16b, v25.16b + aesmc v2.16b, v2.16b // AES block 2 - round 7 + aese v3.16b, v25.16b + aesmc v3.16b, v3.16b // AES block 3 - round 7 + trn2 v16.2d, v12.2d, v13.2d // h2l | h1l + aese v1.16b, v26.16b + aesmc v1.16b, v1.16b // AES block 1 - round 8 + aese v2.16b, v26.16b + aesmc v2.16b, v2.16b // AES block 2 - round 8 + aese v3.16b, v26.16b + aesmc v3.16b, v3.16b // AES block 3 - round 8 + aese v0.16b, v26.16b + aesmc v0.16b, v0.16b // AES block 0 - round 8 + b.lt Lenc_finish_first_blocks // branch if AES-128 + + aese v1.16b, v27.16b + aesmc v1.16b, v1.16b // AES block 1 - round 9 + aese v2.16b, v27.16b + aesmc v2.16b, v2.16b // AES block 2 - round 9 + aese v3.16b, v27.16b + aesmc v3.16b, v3.16b // AES block 3 - round 9 + aese v0.16b, v27.16b + aesmc v0.16b, v0.16b // AES block 0 - round 9 + aese v1.16b, v28.16b + aesmc v1.16b, v1.16b // AES block 1 - round 10 + aese v2.16b, v28.16b + aesmc v2.16b, v2.16b // AES block 2 - round 10 + aese v3.16b, v28.16b + aesmc v3.16b, v3.16b // AES block 3 - round 10 + aese v0.16b, v28.16b + aesmc v0.16b, v0.16b // AES block 0 - round 10 + b.eq Lenc_finish_first_blocks // branch if AES-192 + + aese v1.16b, v29.16b + aesmc v1.16b, v1.16b // AES block 1 - round 11 + aese v2.16b, v29.16b + aesmc v2.16b, v2.16b // AES block 2 - round 11 + aese v0.16b, v29.16b + aesmc v0.16b, v0.16b // AES block 0 - round 11 + aese v3.16b, v29.16b + aesmc v3.16b, v3.16b // AES block 3 - round 11 + aese v1.16b, v30.16b + aesmc v1.16b, v1.16b // AES block 1 - round 12 + aese v2.16b, v30.16b + aesmc v2.16b, v2.16b // AES block 2 - round 12 + aese v0.16b, v30.16b + aesmc v0.16b, v0.16b // AES block 0 - round 12 + aese v3.16b, v30.16b + aesmc v3.16b, v3.16b // AES block 3 - round 12 + +Lenc_finish_first_blocks: + cmp x0, x5 // check if we have <= 4 blocks + eor v17.16b, v17.16b, v9.16b // h4k | h3k + aese v2.16b, v31.16b // AES block 2 - round N-1 + trn1 v8.2d, v12.2d, v13.2d // h2h | h1h + aese v1.16b, v31.16b // AES block 1 - round N-1 + aese v0.16b, v31.16b // AES block 0 - round N-1 + aese v3.16b, v31.16b // AES block 3 - round N-1 + eor v16.16b, v16.16b, v8.16b // h2k | h1k + b.ge Lenc_tail // handle tail + + ldp x19, x20, [x0, #16] // AES block 1 - load plaintext + rev w9, w12 // CTR block 4 + ldp x6, x7, [x0, #0] // AES block 0 - load plaintext + ldp x23, x24, [x0, #48] // AES block 3 - load plaintext + ldp x21, x22, [x0, #32] // AES block 2 - load plaintext + add x0, x0, #64 // AES input_ptr update + eor x19, x19, x13 // AES block 1 - round N low + eor x20, x20, x14 // AES block 1 - round N high + fmov d5, x19 // AES block 1 - mov low + eor x6, x6, x13 // AES block 0 - round N low + eor x7, x7, x14 // AES block 0 - round N high + eor x24, x24, x14 // AES block 3 - round N high + fmov d4, x6 // AES block 0 - mov low + cmp x0, x5 // check if we have <= 8 blocks + fmov v4.d[1], x7 // AES block 0 - mov high + eor x23, x23, x13 // AES block 3 - round N low + eor x21, x21, x13 // AES block 2 - round N low + fmov v5.d[1], x20 // AES block 1 - mov high + fmov d6, x21 // AES block 2 - mov low + add w12, w12, #1 // CTR block 4 + orr x9, x11, x9, lsl #32 // CTR block 4 + fmov d7, x23 // AES block 3 - mov low + eor x22, x22, x14 // AES block 2 - round N high + fmov v6.d[1], x22 // AES block 2 - mov high + eor v4.16b, v4.16b, v0.16b // AES block 0 - result + fmov d0, x10 // CTR block 4 + fmov v0.d[1], x9 // CTR block 4 + rev w9, w12 // CTR block 5 + add w12, w12, #1 // CTR block 5 + eor v5.16b, v5.16b, v1.16b // AES block 1 - result + fmov d1, x10 // CTR block 5 + orr x9, x11, x9, lsl #32 // CTR block 5 + fmov v1.d[1], x9 // CTR block 5 + rev w9, w12 // CTR block 6 + st1 { v4.16b}, [x2], #16 // AES block 0 - store result + fmov v7.d[1], x24 // AES block 3 - mov high + orr x9, x11, x9, lsl #32 // CTR block 6 + eor v6.16b, v6.16b, v2.16b // AES block 2 - result + st1 { v5.16b}, [x2], #16 // AES block 1 - store result + add w12, w12, #1 // CTR block 6 + fmov d2, x10 // CTR block 6 + fmov v2.d[1], x9 // CTR block 6 + st1 { v6.16b}, [x2], #16 // AES block 2 - store result + rev w9, w12 // CTR block 7 + orr x9, x11, x9, lsl #32 // CTR block 7 + eor v7.16b, v7.16b, v3.16b // AES block 3 - result + st1 { v7.16b}, [x2], #16 // AES block 3 - store result + b.ge Lenc_prepretail // do prepretail + +Lenc_main_loop: // main loop start + aese v0.16b, v18.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 0 + rev64 v4.16b, v4.16b // GHASH block 4k (only t0 is free) + aese v1.16b, v18.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 0 + fmov d3, x10 // CTR block 4k+3 + aese v2.16b, v18.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 0 + ext v11.16b, v11.16b, v11.16b, #8 // PRE 0 + aese v0.16b, v19.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 1 + fmov v3.d[1], x9 // CTR block 4k+3 + aese v1.16b, v19.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 1 + ldp x23, x24, [x0, #48] // AES block 4k+7 - load plaintext + aese v2.16b, v19.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 1 + ldp x21, x22, [x0, #32] // AES block 4k+6 - load plaintext + aese v0.16b, v20.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 2 + eor v4.16b, v4.16b, v11.16b // PRE 1 + aese v1.16b, v20.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 2 + aese v3.16b, v18.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 0 + eor x23, x23, x13 // AES block 4k+7 - round N low + aese v0.16b, v21.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 3 + mov d10, v17.d[1] // GHASH block 4k - mid + pmull2 v9.1q, v4.2d, v15.2d // GHASH block 4k - high + eor x22, x22, x14 // AES block 4k+6 - round N high + mov d8, v4.d[1] // GHASH block 4k - mid + aese v3.16b, v19.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 1 + rev64 v5.16b, v5.16b // GHASH block 4k+1 (t0 and t1 free) + aese v0.16b, v22.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 4 + pmull v11.1q, v4.1d, v15.1d // GHASH block 4k - low + eor v8.8b, v8.8b, v4.8b // GHASH block 4k - mid + aese v2.16b, v20.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 2 + aese v0.16b, v23.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 5 + rev64 v7.16b, v7.16b // GHASH block 4k+3 (t0, t1, t2 and t3 free) + pmull2 v4.1q, v5.2d, v14.2d // GHASH block 4k+1 - high + pmull v10.1q, v8.1d, v10.1d // GHASH block 4k - mid + rev64 v6.16b, v6.16b // GHASH block 4k+2 (t0, t1, and t2 free) + pmull v8.1q, v5.1d, v14.1d // GHASH block 4k+1 - low + eor v9.16b, v9.16b, v4.16b // GHASH block 4k+1 - high + mov d4, v5.d[1] // GHASH block 4k+1 - mid + aese v1.16b, v21.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 3 + aese v3.16b, v20.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 2 + eor v11.16b, v11.16b, v8.16b // GHASH block 4k+1 - low + aese v2.16b, v21.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 3 + aese v1.16b, v22.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 4 + mov d8, v6.d[1] // GHASH block 4k+2 - mid + aese v3.16b, v21.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 3 + eor v4.8b, v4.8b, v5.8b // GHASH block 4k+1 - mid + aese v2.16b, v22.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 4 + aese v0.16b, v24.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 6 + eor v8.8b, v8.8b, v6.8b // GHASH block 4k+2 - mid + aese v3.16b, v22.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 4 + pmull v4.1q, v4.1d, v17.1d // GHASH block 4k+1 - mid + aese v0.16b, v25.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 7 + aese v3.16b, v23.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 5 + ins v8.d[1], v8.d[0] // GHASH block 4k+2 - mid + aese v1.16b, v23.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 5 + aese v0.16b, v26.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 8 + aese v2.16b, v23.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 5 + aese v1.16b, v24.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 6 + eor v10.16b, v10.16b, v4.16b // GHASH block 4k+1 - mid + pmull2 v4.1q, v6.2d, v13.2d // GHASH block 4k+2 - high + pmull v5.1q, v6.1d, v13.1d // GHASH block 4k+2 - low + aese v1.16b, v25.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 7 + pmull v6.1q, v7.1d, v12.1d // GHASH block 4k+3 - low + eor v9.16b, v9.16b, v4.16b // GHASH block 4k+2 - high + aese v3.16b, v24.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 6 + ldp x19, x20, [x0, #16] // AES block 4k+5 - load plaintext + aese v1.16b, v26.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 8 + mov d4, v7.d[1] // GHASH block 4k+3 - mid + aese v2.16b, v24.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 6 + eor v11.16b, v11.16b, v5.16b // GHASH block 4k+2 - low + pmull2 v8.1q, v8.2d, v16.2d // GHASH block 4k+2 - mid + pmull2 v5.1q, v7.2d, v12.2d // GHASH block 4k+3 - high + eor v4.8b, v4.8b, v7.8b // GHASH block 4k+3 - mid + aese v2.16b, v25.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 7 + eor x19, x19, x13 // AES block 4k+5 - round N low + aese v2.16b, v26.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 8 + eor v10.16b, v10.16b, v8.16b // GHASH block 4k+2 - mid + aese v3.16b, v25.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 7 + eor x21, x21, x13 // AES block 4k+6 - round N low + aese v3.16b, v26.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 8 + movi v8.8b, #0xc2 + pmull v4.1q, v4.1d, v16.1d // GHASH block 4k+3 - mid + eor v9.16b, v9.16b, v5.16b // GHASH block 4k+3 - high + cmp x17, #12 // setup flags for AES-128/192/256 check + fmov d5, x19 // AES block 4k+5 - mov low + ldp x6, x7, [x0, #0] // AES block 4k+4 - load plaintext + b.lt Lenc_main_loop_continue // branch if AES-128 + + aese v1.16b, v27.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 9 + aese v0.16b, v27.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 9 + aese v2.16b, v27.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 9 + aese v3.16b, v27.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 9 + aese v0.16b, v28.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 10 + aese v1.16b, v28.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 10 + aese v2.16b, v28.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 10 + aese v3.16b, v28.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 10 + b.eq Lenc_main_loop_continue // branch if AES-192 + + aese v0.16b, v29.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 11 + aese v1.16b, v29.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 11 + aese v2.16b, v29.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 11 + aese v3.16b, v29.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 11 + aese v1.16b, v30.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 12 + aese v0.16b, v30.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 12 + aese v2.16b, v30.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 12 + aese v3.16b, v30.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 12 + +Lenc_main_loop_continue: + shl d8, d8, #56 // mod_constant + eor v11.16b, v11.16b, v6.16b // GHASH block 4k+3 - low + eor v10.16b, v10.16b, v4.16b // GHASH block 4k+3 - mid + add w12, w12, #1 // CTR block 4k+3 + eor v4.16b, v11.16b, v9.16b // MODULO - karatsuba tidy up + add x0, x0, #64 // AES input_ptr update + pmull v7.1q, v9.1d, v8.1d // MODULO - top 64b align with mid + rev w9, w12 // CTR block 4k+8 + ext v9.16b, v9.16b, v9.16b, #8 // MODULO - other top alignment + eor x6, x6, x13 // AES block 4k+4 - round N low + eor v10.16b, v10.16b, v4.16b // MODULO - karatsuba tidy up + eor x7, x7, x14 // AES block 4k+4 - round N high + fmov d4, x6 // AES block 4k+4 - mov low + orr x9, x11, x9, lsl #32 // CTR block 4k+8 + eor v7.16b, v9.16b, v7.16b // MODULO - fold into mid + eor x20, x20, x14 // AES block 4k+5 - round N high + eor x24, x24, x14 // AES block 4k+7 - round N high + add w12, w12, #1 // CTR block 4k+8 + aese v0.16b, v31.16b // AES block 4k+4 - round N-1 + fmov v4.d[1], x7 // AES block 4k+4 - mov high + eor v10.16b, v10.16b, v7.16b // MODULO - fold into mid + fmov d7, x23 // AES block 4k+7 - mov low + aese v1.16b, v31.16b // AES block 4k+5 - round N-1 + fmov v5.d[1], x20 // AES block 4k+5 - mov high + fmov d6, x21 // AES block 4k+6 - mov low + cmp x0, x5 // LOOP CONTROL + fmov v6.d[1], x22 // AES block 4k+6 - mov high + pmull v9.1q, v10.1d, v8.1d // MODULO - mid 64b align with low + eor v4.16b, v4.16b, v0.16b // AES block 4k+4 - result + fmov d0, x10 // CTR block 4k+8 + fmov v0.d[1], x9 // CTR block 4k+8 + rev w9, w12 // CTR block 4k+9 + add w12, w12, #1 // CTR block 4k+9 + eor v5.16b, v5.16b, v1.16b // AES block 4k+5 - result + fmov d1, x10 // CTR block 4k+9 + orr x9, x11, x9, lsl #32 // CTR block 4k+9 + fmov v1.d[1], x9 // CTR block 4k+9 + aese v2.16b, v31.16b // AES block 4k+6 - round N-1 + rev w9, w12 // CTR block 4k+10 + st1 { v4.16b}, [x2], #16 // AES block 4k+4 - store result + orr x9, x11, x9, lsl #32 // CTR block 4k+10 + eor v11.16b, v11.16b, v9.16b // MODULO - fold into low + fmov v7.d[1], x24 // AES block 4k+7 - mov high + ext v10.16b, v10.16b, v10.16b, #8 // MODULO - other mid alignment + st1 { v5.16b}, [x2], #16 // AES block 4k+5 - store result + add w12, w12, #1 // CTR block 4k+10 + aese v3.16b, v31.16b // AES block 4k+7 - round N-1 + eor v6.16b, v6.16b, v2.16b // AES block 4k+6 - result + fmov d2, x10 // CTR block 4k+10 + st1 { v6.16b}, [x2], #16 // AES block 4k+6 - store result + fmov v2.d[1], x9 // CTR block 4k+10 + rev w9, w12 // CTR block 4k+11 + eor v11.16b, v11.16b, v10.16b // MODULO - fold into low + orr x9, x11, x9, lsl #32 // CTR block 4k+11 + eor v7.16b, v7.16b, v3.16b // AES block 4k+7 - result + st1 { v7.16b}, [x2], #16 // AES block 4k+7 - store result + b.lt Lenc_main_loop + +Lenc_prepretail: // PREPRETAIL + aese v1.16b, v18.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 0 + rev64 v6.16b, v6.16b // GHASH block 4k+2 (t0, t1, and t2 free) + aese v2.16b, v18.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 0 + fmov d3, x10 // CTR block 4k+3 + aese v0.16b, v18.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 0 + rev64 v4.16b, v4.16b // GHASH block 4k (only t0 is free) + fmov v3.d[1], x9 // CTR block 4k+3 + ext v11.16b, v11.16b, v11.16b, #8 // PRE 0 + aese v2.16b, v19.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 1 + aese v0.16b, v19.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 1 + eor v4.16b, v4.16b, v11.16b // PRE 1 + rev64 v5.16b, v5.16b // GHASH block 4k+1 (t0 and t1 free) + aese v2.16b, v20.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 2 + aese v3.16b, v18.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 0 + mov d10, v17.d[1] // GHASH block 4k - mid + aese v1.16b, v19.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 1 + pmull v11.1q, v4.1d, v15.1d // GHASH block 4k - low + mov d8, v4.d[1] // GHASH block 4k - mid + pmull2 v9.1q, v4.2d, v15.2d // GHASH block 4k - high + aese v2.16b, v21.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 3 + aese v1.16b, v20.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 2 + eor v8.8b, v8.8b, v4.8b // GHASH block 4k - mid + aese v0.16b, v20.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 2 + aese v3.16b, v19.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 1 + aese v1.16b, v21.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 3 + pmull v10.1q, v8.1d, v10.1d // GHASH block 4k - mid + pmull2 v4.1q, v5.2d, v14.2d // GHASH block 4k+1 - high + pmull v8.1q, v5.1d, v14.1d // GHASH block 4k+1 - low + aese v3.16b, v20.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 2 + eor v9.16b, v9.16b, v4.16b // GHASH block 4k+1 - high + mov d4, v5.d[1] // GHASH block 4k+1 - mid + aese v0.16b, v21.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 3 + eor v11.16b, v11.16b, v8.16b // GHASH block 4k+1 - low + aese v3.16b, v21.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 3 + eor v4.8b, v4.8b, v5.8b // GHASH block 4k+1 - mid + mov d8, v6.d[1] // GHASH block 4k+2 - mid + aese v0.16b, v22.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 4 + rev64 v7.16b, v7.16b // GHASH block 4k+3 (t0, t1, t2 and t3 free) + aese v3.16b, v22.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 4 + pmull v4.1q, v4.1d, v17.1d // GHASH block 4k+1 - mid + eor v8.8b, v8.8b, v6.8b // GHASH block 4k+2 - mid + add w12, w12, #1 // CTR block 4k+3 + pmull v5.1q, v6.1d, v13.1d // GHASH block 4k+2 - low + aese v3.16b, v23.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 5 + aese v2.16b, v22.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 4 + eor v10.16b, v10.16b, v4.16b // GHASH block 4k+1 - mid + pmull2 v4.1q, v6.2d, v13.2d // GHASH block 4k+2 - high + eor v11.16b, v11.16b, v5.16b // GHASH block 4k+2 - low + ins v8.d[1], v8.d[0] // GHASH block 4k+2 - mid + aese v2.16b, v23.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 5 + eor v9.16b, v9.16b, v4.16b // GHASH block 4k+2 - high + mov d4, v7.d[1] // GHASH block 4k+3 - mid + aese v1.16b, v22.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 4 + pmull2 v8.1q, v8.2d, v16.2d // GHASH block 4k+2 - mid + eor v4.8b, v4.8b, v7.8b // GHASH block 4k+3 - mid + pmull2 v5.1q, v7.2d, v12.2d // GHASH block 4k+3 - high + aese v1.16b, v23.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 5 + pmull v4.1q, v4.1d, v16.1d // GHASH block 4k+3 - mid + eor v10.16b, v10.16b, v8.16b // GHASH block 4k+2 - mid + aese v0.16b, v23.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 5 + aese v1.16b, v24.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 6 + aese v2.16b, v24.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 6 + aese v0.16b, v24.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 6 + movi v8.8b, #0xc2 + aese v3.16b, v24.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 6 + aese v1.16b, v25.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 7 + eor v9.16b, v9.16b, v5.16b // GHASH block 4k+3 - high + aese v0.16b, v25.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 7 + aese v3.16b, v25.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 7 + shl d8, d8, #56 // mod_constant + aese v1.16b, v26.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 8 + eor v10.16b, v10.16b, v4.16b // GHASH block 4k+3 - mid + pmull v6.1q, v7.1d, v12.1d // GHASH block 4k+3 - low + aese v3.16b, v26.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 8 + cmp x17, #12 // setup flags for AES-128/192/256 check + aese v0.16b, v26.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 8 + eor v11.16b, v11.16b, v6.16b // GHASH block 4k+3 - low + aese v2.16b, v25.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 7 + eor v10.16b, v10.16b, v9.16b // karatsuba tidy up + aese v2.16b, v26.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 8 + pmull v4.1q, v9.1d, v8.1d + ext v9.16b, v9.16b, v9.16b, #8 + eor v10.16b, v10.16b, v11.16b + b.lt Lenc_finish_prepretail // branch if AES-128 + + aese v1.16b, v27.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 9 + aese v3.16b, v27.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 9 + aese v0.16b, v27.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 9 + aese v2.16b, v27.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 9 + aese v3.16b, v28.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 10 + aese v1.16b, v28.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 10 + aese v0.16b, v28.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 10 + aese v2.16b, v28.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 10 + b.eq Lenc_finish_prepretail // branch if AES-192 + + aese v1.16b, v29.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 11 + aese v0.16b, v29.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 11 + aese v3.16b, v29.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 11 + aese v2.16b, v29.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 11 + aese v1.16b, v30.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 12 + aese v0.16b, v30.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 12 + aese v3.16b, v30.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 12 + aese v2.16b, v30.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 12 + +Lenc_finish_prepretail: + eor v10.16b, v10.16b, v4.16b + eor v10.16b, v10.16b, v9.16b + pmull v4.1q, v10.1d, v8.1d + ext v10.16b, v10.16b, v10.16b, #8 + aese v1.16b, v31.16b // AES block 4k+5 - round N-1 + eor v11.16b, v11.16b, v4.16b + aese v3.16b, v31.16b // AES block 4k+7 - round N-1 + aese v0.16b, v31.16b // AES block 4k+4 - round N-1 + aese v2.16b, v31.16b // AES block 4k+6 - round N-1 + eor v11.16b, v11.16b, v10.16b + +Lenc_tail: // TAIL + ext v8.16b, v11.16b, v11.16b, #8 // prepare final partial tag + sub x5, x4, x0 // main_end_input_ptr is number of bytes left to process + ldp x6, x7, [x0], #16 // AES block 4k+4 - load plaintext + eor x6, x6, x13 // AES block 4k+4 - round N low + eor x7, x7, x14 // AES block 4k+4 - round N high + cmp x5, #48 + fmov d4, x6 // AES block 4k+4 - mov low + fmov v4.d[1], x7 // AES block 4k+4 - mov high + eor v5.16b, v4.16b, v0.16b // AES block 4k+4 - result + b.gt Lenc_blocks_more_than_3 + cmp x5, #32 + mov v3.16b, v2.16b + movi v11.8b, #0 + movi v9.8b, #0 + sub w12, w12, #1 + mov v2.16b, v1.16b + movi v10.8b, #0 + b.gt Lenc_blocks_more_than_2 + mov v3.16b, v1.16b + sub w12, w12, #1 + cmp x5, #16 + b.gt Lenc_blocks_more_than_1 + sub w12, w12, #1 + b Lenc_blocks_less_than_1 +Lenc_blocks_more_than_3: // blocks left > 3 + st1 { v5.16b}, [x2], #16 // AES final-3 block - store result + ldp x6, x7, [x0], #16 // AES final-2 block - load input low & high + rev64 v4.16b, v5.16b // GHASH final-3 block + eor x6, x6, x13 // AES final-2 block - round N low + eor v4.16b, v4.16b, v8.16b // feed in partial tag + eor x7, x7, x14 // AES final-2 block - round N high + mov d22, v4.d[1] // GHASH final-3 block - mid + fmov d5, x6 // AES final-2 block - mov low + fmov v5.d[1], x7 // AES final-2 block - mov high + eor v22.8b, v22.8b, v4.8b // GHASH final-3 block - mid + movi v8.8b, #0 // suppress further partial tag feed in + mov d10, v17.d[1] // GHASH final-3 block - mid + pmull v11.1q, v4.1d, v15.1d // GHASH final-3 block - low + pmull2 v9.1q, v4.2d, v15.2d // GHASH final-3 block - high + pmull v10.1q, v22.1d, v10.1d // GHASH final-3 block - mid + eor v5.16b, v5.16b, v1.16b // AES final-2 block - result +Lenc_blocks_more_than_2: // blocks left > 2 + st1 { v5.16b}, [x2], #16 // AES final-2 block - store result + ldp x6, x7, [x0], #16 // AES final-1 block - load input low & high + rev64 v4.16b, v5.16b // GHASH final-2 block + eor x6, x6, x13 // AES final-1 block - round N low + eor v4.16b, v4.16b, v8.16b // feed in partial tag + fmov d5, x6 // AES final-1 block - mov low + eor x7, x7, x14 // AES final-1 block - round N high + fmov v5.d[1], x7 // AES final-1 block - mov high + movi v8.8b, #0 // suppress further partial tag feed in + pmull2 v20.1q, v4.2d, v14.2d // GHASH final-2 block - high + mov d22, v4.d[1] // GHASH final-2 block - mid + pmull v21.1q, v4.1d, v14.1d // GHASH final-2 block - low + eor v22.8b, v22.8b, v4.8b // GHASH final-2 block - mid + eor v5.16b, v5.16b, v2.16b // AES final-1 block - result + eor v9.16b, v9.16b, v20.16b // GHASH final-2 block - high + pmull v22.1q, v22.1d, v17.1d // GHASH final-2 block - mid + eor v11.16b, v11.16b, v21.16b // GHASH final-2 block - low + eor v10.16b, v10.16b, v22.16b // GHASH final-2 block - mid +Lenc_blocks_more_than_1: // blocks left > 1 + st1 { v5.16b}, [x2], #16 // AES final-1 block - store result + rev64 v4.16b, v5.16b // GHASH final-1 block + ldp x6, x7, [x0], #16 // AES final block - load input low & high + eor v4.16b, v4.16b, v8.16b // feed in partial tag + movi v8.8b, #0 // suppress further partial tag feed in + eor x6, x6, x13 // AES final block - round N low + mov d22, v4.d[1] // GHASH final-1 block - mid + pmull2 v20.1q, v4.2d, v13.2d // GHASH final-1 block - high + eor x7, x7, x14 // AES final block - round N high + eor v22.8b, v22.8b, v4.8b // GHASH final-1 block - mid + eor v9.16b, v9.16b, v20.16b // GHASH final-1 block - high + ins v22.d[1], v22.d[0] // GHASH final-1 block - mid + fmov d5, x6 // AES final block - mov low + fmov v5.d[1], x7 // AES final block - mov high + pmull2 v22.1q, v22.2d, v16.2d // GHASH final-1 block - mid + pmull v21.1q, v4.1d, v13.1d // GHASH final-1 block - low + eor v5.16b, v5.16b, v3.16b // AES final block - result + eor v10.16b, v10.16b, v22.16b // GHASH final-1 block - mid + eor v11.16b, v11.16b, v21.16b // GHASH final-1 block - low +Lenc_blocks_less_than_1: // blocks left <= 1 + and x1, x1, #127 // bit_length %= 128 + mvn x13, xzr // rkN_l = 0xffffffffffffffff + sub x1, x1, #128 // bit_length -= 128 + neg x1, x1 // bit_length = 128 - #bits in input (in range [1,128]) + ld1 { v18.16b}, [x2] // load existing bytes where the possibly partial last block is to be stored + mvn x14, xzr // rkN_h = 0xffffffffffffffff + and x1, x1, #127 // bit_length %= 128 + lsr x14, x14, x1 // rkN_h is mask for top 64b of last block + cmp x1, #64 + csel x6, x13, x14, lt + csel x7, x14, xzr, lt + fmov d0, x6 // ctr0b is mask for last block + fmov v0.d[1], x7 + and v5.16b, v5.16b, v0.16b // possibly partial last block has zeroes in highest bits + rev64 v4.16b, v5.16b // GHASH final block + eor v4.16b, v4.16b, v8.16b // feed in partial tag + bif v5.16b, v18.16b, v0.16b // insert existing bytes in top end of result before storing + pmull2 v20.1q, v4.2d, v12.2d // GHASH final block - high + mov d8, v4.d[1] // GHASH final block - mid + rev w9, w12 + pmull v21.1q, v4.1d, v12.1d // GHASH final block - low + eor v9.16b, v9.16b, v20.16b // GHASH final block - high + eor v8.8b, v8.8b, v4.8b // GHASH final block - mid + pmull v8.1q, v8.1d, v16.1d // GHASH final block - mid + eor v11.16b, v11.16b, v21.16b // GHASH final block - low + eor v10.16b, v10.16b, v8.16b // GHASH final block - mid + movi v8.8b, #0xc2 + eor v4.16b, v11.16b, v9.16b // MODULO - karatsuba tidy up + shl d8, d8, #56 // mod_constant + eor v10.16b, v10.16b, v4.16b // MODULO - karatsuba tidy up + pmull v7.1q, v9.1d, v8.1d // MODULO - top 64b align with mid + ext v9.16b, v9.16b, v9.16b, #8 // MODULO - other top alignment + eor v10.16b, v10.16b, v7.16b // MODULO - fold into mid + eor v10.16b, v10.16b, v9.16b // MODULO - fold into mid + pmull v9.1q, v10.1d, v8.1d // MODULO - mid 64b align with low + ext v10.16b, v10.16b, v10.16b, #8 // MODULO - other mid alignment + str w9, [x16, #12] // store the updated counter + st1 { v5.16b}, [x2] // store all 16B + eor v11.16b, v11.16b, v9.16b // MODULO - fold into low + eor v11.16b, v11.16b, v10.16b // MODULO - fold into low + ext v11.16b, v11.16b, v11.16b, #8 + rev64 v11.16b, v11.16b + mov x0, x15 + st1 { v11.16b }, [x3] + ldp x19, x20, [sp, #16] + ldp x21, x22, [sp, #32] + ldp x23, x24, [sp, #48] + ldp d8, d9, [sp, #64] + ldp d10, d11, [sp, #80] + ldp d12, d13, [sp, #96] + ldp d14, d15, [sp, #112] + ldp x29, x30, [sp], #128 + AARCH64_VALIDATE_LINK_REGISTER + ret + +.globl aes_gcm_dec_kernel + +.def aes_gcm_dec_kernel + .type 32 +.endef +.align 4 +aes_gcm_dec_kernel: + AARCH64_SIGN_LINK_REGISTER + stp x29, x30, [sp, #-128]! + mov x29, sp + stp x19, x20, [sp, #16] + mov x16, x4 + mov x8, x5 + stp x21, x22, [sp, #32] + stp x23, x24, [sp, #48] + stp d8, d9, [sp, #64] + stp d10, d11, [sp, #80] + stp d12, d13, [sp, #96] + stp d14, d15, [sp, #112] + ldr w17, [x8, #240] + add x19, x8, x17, lsl #4 // borrow input_l1 for last key + ldp x13, x14, [x19] // load round N keys + ldr q31, [x19, #-16] // load round N-1 keys + lsr x5, x1, #3 // byte_len + mov x15, x5 + ldp x10, x11, [x16] // ctr96_b64, ctr96_t32 + ldr q26, [x8, #128] // load rk8 + sub x5, x5, #1 // byte_len - 1 + ldr q25, [x8, #112] // load rk7 + and x5, x5, #0xffffffffffffffc0 // number of bytes to be processed in main loop (at least 1 byte must be handled by tail) + add x4, x0, x1, lsr #3 // end_input_ptr + ldr q24, [x8, #96] // load rk6 + lsr x12, x11, #32 + ldr q23, [x8, #80] // load rk5 + orr w11, w11, w11 + ldr q21, [x8, #48] // load rk3 + add x5, x5, x0 + rev w12, w12 // rev_ctr32 + add w12, w12, #1 // increment rev_ctr32 + fmov d3, x10 // CTR block 3 + rev w9, w12 // CTR block 1 + add w12, w12, #1 // CTR block 1 + fmov d1, x10 // CTR block 1 + orr x9, x11, x9, lsl #32 // CTR block 1 + ld1 { v0.16b}, [x16] // special case vector load initial counter so we can start first AES block as quickly as possible + fmov v1.d[1], x9 // CTR block 1 + rev w9, w12 // CTR block 2 + add w12, w12, #1 // CTR block 2 + fmov d2, x10 // CTR block 2 + orr x9, x11, x9, lsl #32 // CTR block 2 + fmov v2.d[1], x9 // CTR block 2 + rev w9, w12 // CTR block 3 + orr x9, x11, x9, lsl #32 // CTR block 3 + ldr q18, [x8, #0] // load rk0 + fmov v3.d[1], x9 // CTR block 3 + add w12, w12, #1 // CTR block 3 + ldr q22, [x8, #64] // load rk4 + ldr q19, [x8, #16] // load rk1 + aese v0.16b, v18.16b + aesmc v0.16b, v0.16b // AES block 0 - round 0 + ldr q14, [x6, #48] // load h3l | h3h + ext v14.16b, v14.16b, v14.16b, #8 + aese v3.16b, v18.16b + aesmc v3.16b, v3.16b // AES block 3 - round 0 + ldr q15, [x6, #80] // load h4l | h4h + ext v15.16b, v15.16b, v15.16b, #8 + aese v1.16b, v18.16b + aesmc v1.16b, v1.16b // AES block 1 - round 0 + ldr q13, [x6, #32] // load h2l | h2h + ext v13.16b, v13.16b, v13.16b, #8 + aese v2.16b, v18.16b + aesmc v2.16b, v2.16b // AES block 2 - round 0 + ldr q20, [x8, #32] // load rk2 + aese v0.16b, v19.16b + aesmc v0.16b, v0.16b // AES block 0 - round 1 + aese v1.16b, v19.16b + aesmc v1.16b, v1.16b // AES block 1 - round 1 + ld1 { v11.16b}, [x3] + ext v11.16b, v11.16b, v11.16b, #8 + rev64 v11.16b, v11.16b + aese v2.16b, v19.16b + aesmc v2.16b, v2.16b // AES block 2 - round 1 + ldr q27, [x8, #144] // load rk9 + aese v3.16b, v19.16b + aesmc v3.16b, v3.16b // AES block 3 - round 1 + ldr q30, [x8, #192] // load rk12 + aese v0.16b, v20.16b + aesmc v0.16b, v0.16b // AES block 0 - round 2 + ldr q12, [x6] // load h1l | h1h + ext v12.16b, v12.16b, v12.16b, #8 + aese v2.16b, v20.16b + aesmc v2.16b, v2.16b // AES block 2 - round 2 + ldr q28, [x8, #160] // load rk10 + aese v3.16b, v20.16b + aesmc v3.16b, v3.16b // AES block 3 - round 2 + aese v0.16b, v21.16b + aesmc v0.16b, v0.16b // AES block 0 - round 3 + aese v1.16b, v20.16b + aesmc v1.16b, v1.16b // AES block 1 - round 2 + aese v3.16b, v21.16b + aesmc v3.16b, v3.16b // AES block 3 - round 3 + aese v0.16b, v22.16b + aesmc v0.16b, v0.16b // AES block 0 - round 4 + aese v2.16b, v21.16b + aesmc v2.16b, v2.16b // AES block 2 - round 3 + aese v1.16b, v21.16b + aesmc v1.16b, v1.16b // AES block 1 - round 3 + aese v3.16b, v22.16b + aesmc v3.16b, v3.16b // AES block 3 - round 4 + aese v2.16b, v22.16b + aesmc v2.16b, v2.16b // AES block 2 - round 4 + aese v1.16b, v22.16b + aesmc v1.16b, v1.16b // AES block 1 - round 4 + aese v3.16b, v23.16b + aesmc v3.16b, v3.16b // AES block 3 - round 5 + aese v0.16b, v23.16b + aesmc v0.16b, v0.16b // AES block 0 - round 5 + aese v1.16b, v23.16b + aesmc v1.16b, v1.16b // AES block 1 - round 5 + aese v2.16b, v23.16b + aesmc v2.16b, v2.16b // AES block 2 - round 5 + aese v0.16b, v24.16b + aesmc v0.16b, v0.16b // AES block 0 - round 6 + aese v3.16b, v24.16b + aesmc v3.16b, v3.16b // AES block 3 - round 6 + cmp x17, #12 // setup flags for AES-128/192/256 check + aese v1.16b, v24.16b + aesmc v1.16b, v1.16b // AES block 1 - round 6 + aese v2.16b, v24.16b + aesmc v2.16b, v2.16b // AES block 2 - round 6 + aese v0.16b, v25.16b + aesmc v0.16b, v0.16b // AES block 0 - round 7 + aese v1.16b, v25.16b + aesmc v1.16b, v1.16b // AES block 1 - round 7 + aese v3.16b, v25.16b + aesmc v3.16b, v3.16b // AES block 3 - round 7 + aese v0.16b, v26.16b + aesmc v0.16b, v0.16b // AES block 0 - round 8 + aese v2.16b, v25.16b + aesmc v2.16b, v2.16b // AES block 2 - round 7 + aese v3.16b, v26.16b + aesmc v3.16b, v3.16b // AES block 3 - round 8 + aese v1.16b, v26.16b + aesmc v1.16b, v1.16b // AES block 1 - round 8 + ldr q29, [x8, #176] // load rk11 + aese v2.16b, v26.16b + aesmc v2.16b, v2.16b // AES block 2 - round 8 + b.lt Ldec_finish_first_blocks // branch if AES-128 + + aese v0.16b, v27.16b + aesmc v0.16b, v0.16b // AES block 0 - round 9 + aese v1.16b, v27.16b + aesmc v1.16b, v1.16b // AES block 1 - round 9 + aese v3.16b, v27.16b + aesmc v3.16b, v3.16b // AES block 3 - round 9 + aese v2.16b, v27.16b + aesmc v2.16b, v2.16b // AES block 2 - round 9 + aese v0.16b, v28.16b + aesmc v0.16b, v0.16b // AES block 0 - round 10 + aese v1.16b, v28.16b + aesmc v1.16b, v1.16b // AES block 1 - round 10 + aese v3.16b, v28.16b + aesmc v3.16b, v3.16b // AES block 3 - round 10 + aese v2.16b, v28.16b + aesmc v2.16b, v2.16b // AES block 2 - round 10 + b.eq Ldec_finish_first_blocks // branch if AES-192 + + aese v0.16b, v29.16b + aesmc v0.16b, v0.16b // AES block 0 - round 11 + aese v3.16b, v29.16b + aesmc v3.16b, v3.16b // AES block 3 - round 11 + aese v1.16b, v29.16b + aesmc v1.16b, v1.16b // AES block 1 - round 11 + aese v2.16b, v29.16b + aesmc v2.16b, v2.16b // AES block 2 - round 11 + aese v1.16b, v30.16b + aesmc v1.16b, v1.16b // AES block 1 - round 12 + aese v0.16b, v30.16b + aesmc v0.16b, v0.16b // AES block 0 - round 12 + aese v2.16b, v30.16b + aesmc v2.16b, v2.16b // AES block 2 - round 12 + aese v3.16b, v30.16b + aesmc v3.16b, v3.16b // AES block 3 - round 12 + +Ldec_finish_first_blocks: + cmp x0, x5 // check if we have <= 4 blocks + trn1 v9.2d, v14.2d, v15.2d // h4h | h3h + trn2 v17.2d, v14.2d, v15.2d // h4l | h3l + trn1 v8.2d, v12.2d, v13.2d // h2h | h1h + trn2 v16.2d, v12.2d, v13.2d // h2l | h1l + eor v17.16b, v17.16b, v9.16b // h4k | h3k + aese v1.16b, v31.16b // AES block 1 - round N-1 + aese v2.16b, v31.16b // AES block 2 - round N-1 + eor v16.16b, v16.16b, v8.16b // h2k | h1k + aese v3.16b, v31.16b // AES block 3 - round N-1 + aese v0.16b, v31.16b // AES block 0 - round N-1 + b.ge Ldec_tail // handle tail + + ldr q4, [x0, #0] // AES block 0 - load ciphertext + ldr q5, [x0, #16] // AES block 1 - load ciphertext + rev w9, w12 // CTR block 4 + eor v0.16b, v4.16b, v0.16b // AES block 0 - result + eor v1.16b, v5.16b, v1.16b // AES block 1 - result + rev64 v5.16b, v5.16b // GHASH block 1 + ldr q7, [x0, #48] // AES block 3 - load ciphertext + mov x7, v0.d[1] // AES block 0 - mov high + mov x6, v0.d[0] // AES block 0 - mov low + rev64 v4.16b, v4.16b // GHASH block 0 + add w12, w12, #1 // CTR block 4 + fmov d0, x10 // CTR block 4 + orr x9, x11, x9, lsl #32 // CTR block 4 + fmov v0.d[1], x9 // CTR block 4 + rev w9, w12 // CTR block 5 + add w12, w12, #1 // CTR block 5 + mov x19, v1.d[0] // AES block 1 - mov low + orr x9, x11, x9, lsl #32 // CTR block 5 + mov x20, v1.d[1] // AES block 1 - mov high + eor x7, x7, x14 // AES block 0 - round N high + eor x6, x6, x13 // AES block 0 - round N low + stp x6, x7, [x2], #16 // AES block 0 - store result + fmov d1, x10 // CTR block 5 + ldr q6, [x0, #32] // AES block 2 - load ciphertext + add x0, x0, #64 // AES input_ptr update + fmov v1.d[1], x9 // CTR block 5 + rev w9, w12 // CTR block 6 + add w12, w12, #1 // CTR block 6 + eor x19, x19, x13 // AES block 1 - round N low + orr x9, x11, x9, lsl #32 // CTR block 6 + eor x20, x20, x14 // AES block 1 - round N high + stp x19, x20, [x2], #16 // AES block 1 - store result + eor v2.16b, v6.16b, v2.16b // AES block 2 - result + cmp x0, x5 // check if we have <= 8 blocks + b.ge Ldec_prepretail // do prepretail + +Ldec_main_loop: // main loop start + mov x21, v2.d[0] // AES block 4k+2 - mov low + ext v11.16b, v11.16b, v11.16b, #8 // PRE 0 + eor v3.16b, v7.16b, v3.16b // AES block 4k+3 - result + aese v0.16b, v18.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 0 + mov x22, v2.d[1] // AES block 4k+2 - mov high + aese v1.16b, v18.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 0 + fmov d2, x10 // CTR block 4k+6 + fmov v2.d[1], x9 // CTR block 4k+6 + eor v4.16b, v4.16b, v11.16b // PRE 1 + rev w9, w12 // CTR block 4k+7 + aese v0.16b, v19.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 1 + mov x24, v3.d[1] // AES block 4k+3 - mov high + aese v1.16b, v19.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 1 + mov x23, v3.d[0] // AES block 4k+3 - mov low + pmull2 v9.1q, v4.2d, v15.2d // GHASH block 4k - high + mov d8, v4.d[1] // GHASH block 4k - mid + fmov d3, x10 // CTR block 4k+7 + aese v0.16b, v20.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 2 + orr x9, x11, x9, lsl #32 // CTR block 4k+7 + aese v2.16b, v18.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 0 + fmov v3.d[1], x9 // CTR block 4k+7 + aese v1.16b, v20.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 2 + eor v8.8b, v8.8b, v4.8b // GHASH block 4k - mid + aese v0.16b, v21.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 3 + eor x22, x22, x14 // AES block 4k+2 - round N high + aese v2.16b, v19.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 1 + mov d10, v17.d[1] // GHASH block 4k - mid + aese v1.16b, v21.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 3 + rev64 v6.16b, v6.16b // GHASH block 4k+2 + aese v3.16b, v18.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 0 + eor x21, x21, x13 // AES block 4k+2 - round N low + aese v2.16b, v20.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 2 + stp x21, x22, [x2], #16 // AES block 4k+2 - store result + pmull v11.1q, v4.1d, v15.1d // GHASH block 4k - low + pmull2 v4.1q, v5.2d, v14.2d // GHASH block 4k+1 - high + aese v2.16b, v21.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 3 + rev64 v7.16b, v7.16b // GHASH block 4k+3 + pmull v10.1q, v8.1d, v10.1d // GHASH block 4k - mid + eor x23, x23, x13 // AES block 4k+3 - round N low + pmull v8.1q, v5.1d, v14.1d // GHASH block 4k+1 - low + eor x24, x24, x14 // AES block 4k+3 - round N high + eor v9.16b, v9.16b, v4.16b // GHASH block 4k+1 - high + aese v2.16b, v22.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 4 + aese v3.16b, v19.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 1 + mov d4, v5.d[1] // GHASH block 4k+1 - mid + aese v0.16b, v22.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 4 + eor v11.16b, v11.16b, v8.16b // GHASH block 4k+1 - low + aese v2.16b, v23.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 5 + add w12, w12, #1 // CTR block 4k+7 + aese v3.16b, v20.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 2 + mov d8, v6.d[1] // GHASH block 4k+2 - mid + aese v1.16b, v22.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 4 + eor v4.8b, v4.8b, v5.8b // GHASH block 4k+1 - mid + pmull v5.1q, v6.1d, v13.1d // GHASH block 4k+2 - low + aese v3.16b, v21.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 3 + eor v8.8b, v8.8b, v6.8b // GHASH block 4k+2 - mid + aese v1.16b, v23.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 5 + aese v0.16b, v23.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 5 + eor v11.16b, v11.16b, v5.16b // GHASH block 4k+2 - low + pmull v4.1q, v4.1d, v17.1d // GHASH block 4k+1 - mid + rev w9, w12 // CTR block 4k+8 + aese v1.16b, v24.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 6 + ins v8.d[1], v8.d[0] // GHASH block 4k+2 - mid + aese v0.16b, v24.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 6 + add w12, w12, #1 // CTR block 4k+8 + aese v3.16b, v22.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 4 + aese v1.16b, v25.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 7 + eor v10.16b, v10.16b, v4.16b // GHASH block 4k+1 - mid + aese v0.16b, v25.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 7 + pmull2 v4.1q, v6.2d, v13.2d // GHASH block 4k+2 - high + mov d6, v7.d[1] // GHASH block 4k+3 - mid + aese v3.16b, v23.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 5 + pmull2 v8.1q, v8.2d, v16.2d // GHASH block 4k+2 - mid + aese v0.16b, v26.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 8 + eor v9.16b, v9.16b, v4.16b // GHASH block 4k+2 - high + aese v3.16b, v24.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 6 + pmull v4.1q, v7.1d, v12.1d // GHASH block 4k+3 - low + orr x9, x11, x9, lsl #32 // CTR block 4k+8 + eor v10.16b, v10.16b, v8.16b // GHASH block 4k+2 - mid + pmull2 v5.1q, v7.2d, v12.2d // GHASH block 4k+3 - high + cmp x17, #12 // setup flags for AES-128/192/256 check + eor v6.8b, v6.8b, v7.8b // GHASH block 4k+3 - mid + aese v1.16b, v26.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 8 + aese v2.16b, v24.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 6 + eor v9.16b, v9.16b, v5.16b // GHASH block 4k+3 - high + pmull v6.1q, v6.1d, v16.1d // GHASH block 4k+3 - mid + movi v8.8b, #0xc2 + aese v2.16b, v25.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 7 + eor v11.16b, v11.16b, v4.16b // GHASH block 4k+3 - low + aese v3.16b, v25.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 7 + shl d8, d8, #56 // mod_constant + aese v2.16b, v26.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 8 + eor v10.16b, v10.16b, v6.16b // GHASH block 4k+3 - mid + aese v3.16b, v26.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 8 + b.lt Ldec_main_loop_continue // branch if AES-128 + + aese v0.16b, v27.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 9 + aese v2.16b, v27.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 9 + aese v1.16b, v27.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 9 + aese v3.16b, v27.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 9 + aese v0.16b, v28.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 10 + aese v1.16b, v28.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 10 + aese v2.16b, v28.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 10 + aese v3.16b, v28.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 10 + b.eq Ldec_main_loop_continue // branch if AES-192 + + aese v0.16b, v29.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 11 + aese v1.16b, v29.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 11 + aese v2.16b, v29.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 11 + aese v3.16b, v29.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 11 + aese v0.16b, v30.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 12 + aese v1.16b, v30.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 12 + aese v2.16b, v30.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 12 + aese v3.16b, v30.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 12 + +Ldec_main_loop_continue: + pmull v7.1q, v9.1d, v8.1d // MODULO - top 64b align with mid + eor v6.16b, v11.16b, v9.16b // MODULO - karatsuba tidy up + ldr q4, [x0, #0] // AES block 4k+4 - load ciphertext + aese v0.16b, v31.16b // AES block 4k+4 - round N-1 + ext v9.16b, v9.16b, v9.16b, #8 // MODULO - other top alignment + eor v10.16b, v10.16b, v6.16b // MODULO - karatsuba tidy up + ldr q5, [x0, #16] // AES block 4k+5 - load ciphertext + eor v0.16b, v4.16b, v0.16b // AES block 4k+4 - result + stp x23, x24, [x2], #16 // AES block 4k+3 - store result + eor v10.16b, v10.16b, v7.16b // MODULO - fold into mid + ldr q7, [x0, #48] // AES block 4k+7 - load ciphertext + ldr q6, [x0, #32] // AES block 4k+6 - load ciphertext + mov x7, v0.d[1] // AES block 4k+4 - mov high + eor v10.16b, v10.16b, v9.16b // MODULO - fold into mid + aese v1.16b, v31.16b // AES block 4k+5 - round N-1 + add x0, x0, #64 // AES input_ptr update + mov x6, v0.d[0] // AES block 4k+4 - mov low + fmov d0, x10 // CTR block 4k+8 + fmov v0.d[1], x9 // CTR block 4k+8 + pmull v8.1q, v10.1d, v8.1d // MODULO - mid 64b align with low + eor v1.16b, v5.16b, v1.16b // AES block 4k+5 - result + rev w9, w12 // CTR block 4k+9 + aese v2.16b, v31.16b // AES block 4k+6 - round N-1 + orr x9, x11, x9, lsl #32 // CTR block 4k+9 + cmp x0, x5 // LOOP CONTROL + add w12, w12, #1 // CTR block 4k+9 + eor x6, x6, x13 // AES block 4k+4 - round N low + eor x7, x7, x14 // AES block 4k+4 - round N high + mov x20, v1.d[1] // AES block 4k+5 - mov high + eor v2.16b, v6.16b, v2.16b // AES block 4k+6 - result + eor v11.16b, v11.16b, v8.16b // MODULO - fold into low + mov x19, v1.d[0] // AES block 4k+5 - mov low + fmov d1, x10 // CTR block 4k+9 + ext v10.16b, v10.16b, v10.16b, #8 // MODULO - other mid alignment + fmov v1.d[1], x9 // CTR block 4k+9 + rev w9, w12 // CTR block 4k+10 + add w12, w12, #1 // CTR block 4k+10 + aese v3.16b, v31.16b // AES block 4k+7 - round N-1 + orr x9, x11, x9, lsl #32 // CTR block 4k+10 + rev64 v5.16b, v5.16b // GHASH block 4k+5 + eor x20, x20, x14 // AES block 4k+5 - round N high + stp x6, x7, [x2], #16 // AES block 4k+4 - store result + eor x19, x19, x13 // AES block 4k+5 - round N low + stp x19, x20, [x2], #16 // AES block 4k+5 - store result + rev64 v4.16b, v4.16b // GHASH block 4k+4 + eor v11.16b, v11.16b, v10.16b // MODULO - fold into low + b.lt Ldec_main_loop + +Ldec_prepretail: // PREPRETAIL + ext v11.16b, v11.16b, v11.16b, #8 // PRE 0 + mov x21, v2.d[0] // AES block 4k+2 - mov low + eor v3.16b, v7.16b, v3.16b // AES block 4k+3 - result + aese v0.16b, v18.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 0 + mov x22, v2.d[1] // AES block 4k+2 - mov high + aese v1.16b, v18.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 0 + fmov d2, x10 // CTR block 4k+6 + fmov v2.d[1], x9 // CTR block 4k+6 + rev w9, w12 // CTR block 4k+7 + eor v4.16b, v4.16b, v11.16b // PRE 1 + rev64 v6.16b, v6.16b // GHASH block 4k+2 + orr x9, x11, x9, lsl #32 // CTR block 4k+7 + mov x23, v3.d[0] // AES block 4k+3 - mov low + aese v1.16b, v19.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 1 + mov x24, v3.d[1] // AES block 4k+3 - mov high + pmull v11.1q, v4.1d, v15.1d // GHASH block 4k - low + mov d8, v4.d[1] // GHASH block 4k - mid + fmov d3, x10 // CTR block 4k+7 + pmull2 v9.1q, v4.2d, v15.2d // GHASH block 4k - high + fmov v3.d[1], x9 // CTR block 4k+7 + aese v2.16b, v18.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 0 + mov d10, v17.d[1] // GHASH block 4k - mid + aese v0.16b, v19.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 1 + eor v8.8b, v8.8b, v4.8b // GHASH block 4k - mid + pmull2 v4.1q, v5.2d, v14.2d // GHASH block 4k+1 - high + aese v2.16b, v19.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 1 + rev64 v7.16b, v7.16b // GHASH block 4k+3 + aese v3.16b, v18.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 0 + pmull v10.1q, v8.1d, v10.1d // GHASH block 4k - mid + eor v9.16b, v9.16b, v4.16b // GHASH block 4k+1 - high + pmull v8.1q, v5.1d, v14.1d // GHASH block 4k+1 - low + aese v3.16b, v19.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 1 + mov d4, v5.d[1] // GHASH block 4k+1 - mid + aese v0.16b, v20.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 2 + aese v1.16b, v20.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 2 + eor v11.16b, v11.16b, v8.16b // GHASH block 4k+1 - low + aese v2.16b, v20.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 2 + aese v0.16b, v21.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 3 + mov d8, v6.d[1] // GHASH block 4k+2 - mid + aese v3.16b, v20.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 2 + eor v4.8b, v4.8b, v5.8b // GHASH block 4k+1 - mid + pmull v5.1q, v6.1d, v13.1d // GHASH block 4k+2 - low + aese v0.16b, v22.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 4 + aese v3.16b, v21.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 3 + eor v8.8b, v8.8b, v6.8b // GHASH block 4k+2 - mid + pmull v4.1q, v4.1d, v17.1d // GHASH block 4k+1 - mid + aese v0.16b, v23.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 5 + eor v11.16b, v11.16b, v5.16b // GHASH block 4k+2 - low + aese v3.16b, v22.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 4 + pmull2 v5.1q, v7.2d, v12.2d // GHASH block 4k+3 - high + eor v10.16b, v10.16b, v4.16b // GHASH block 4k+1 - mid + pmull2 v4.1q, v6.2d, v13.2d // GHASH block 4k+2 - high + aese v3.16b, v23.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 5 + ins v8.d[1], v8.d[0] // GHASH block 4k+2 - mid + aese v2.16b, v21.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 3 + aese v1.16b, v21.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 3 + eor v9.16b, v9.16b, v4.16b // GHASH block 4k+2 - high + pmull v4.1q, v7.1d, v12.1d // GHASH block 4k+3 - low + aese v2.16b, v22.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 4 + mov d6, v7.d[1] // GHASH block 4k+3 - mid + aese v1.16b, v22.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 4 + pmull2 v8.1q, v8.2d, v16.2d // GHASH block 4k+2 - mid + aese v2.16b, v23.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 5 + eor v6.8b, v6.8b, v7.8b // GHASH block 4k+3 - mid + aese v1.16b, v23.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 5 + aese v3.16b, v24.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 6 + eor v10.16b, v10.16b, v8.16b // GHASH block 4k+2 - mid + aese v2.16b, v24.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 6 + aese v0.16b, v24.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 6 + movi v8.8b, #0xc2 + aese v1.16b, v24.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 6 + eor v11.16b, v11.16b, v4.16b // GHASH block 4k+3 - low + pmull v6.1q, v6.1d, v16.1d // GHASH block 4k+3 - mid + aese v3.16b, v25.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 7 + cmp x17, #12 // setup flags for AES-128/192/256 check + eor v9.16b, v9.16b, v5.16b // GHASH block 4k+3 - high + aese v1.16b, v25.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 7 + aese v0.16b, v25.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 7 + eor v10.16b, v10.16b, v6.16b // GHASH block 4k+3 - mid + aese v3.16b, v26.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 8 + aese v2.16b, v25.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 7 + eor v6.16b, v11.16b, v9.16b // MODULO - karatsuba tidy up + aese v1.16b, v26.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 8 + aese v0.16b, v26.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 8 + shl d8, d8, #56 // mod_constant + aese v2.16b, v26.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 8 + b.lt Ldec_finish_prepretail // branch if AES-128 + + aese v1.16b, v27.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 9 + aese v2.16b, v27.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 9 + aese v3.16b, v27.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 9 + aese v0.16b, v27.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 9 + aese v2.16b, v28.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 10 + aese v3.16b, v28.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 10 + aese v0.16b, v28.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 10 + aese v1.16b, v28.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 10 + b.eq Ldec_finish_prepretail // branch if AES-192 + + aese v2.16b, v29.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 11 + aese v0.16b, v29.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 11 + aese v1.16b, v29.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 11 + aese v2.16b, v30.16b + aesmc v2.16b, v2.16b // AES block 4k+6 - round 12 + aese v3.16b, v29.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 11 + aese v1.16b, v30.16b + aesmc v1.16b, v1.16b // AES block 4k+5 - round 12 + aese v0.16b, v30.16b + aesmc v0.16b, v0.16b // AES block 4k+4 - round 12 + aese v3.16b, v30.16b + aesmc v3.16b, v3.16b // AES block 4k+7 - round 12 + +Ldec_finish_prepretail: + eor v10.16b, v10.16b, v6.16b // MODULO - karatsuba tidy up + pmull v7.1q, v9.1d, v8.1d // MODULO - top 64b align with mid + ext v9.16b, v9.16b, v9.16b, #8 // MODULO - other top alignment + eor v10.16b, v10.16b, v7.16b // MODULO - fold into mid + eor x22, x22, x14 // AES block 4k+2 - round N high + eor x23, x23, x13 // AES block 4k+3 - round N low + eor v10.16b, v10.16b, v9.16b // MODULO - fold into mid + add w12, w12, #1 // CTR block 4k+7 + eor x21, x21, x13 // AES block 4k+2 - round N low + pmull v8.1q, v10.1d, v8.1d // MODULO - mid 64b align with low + eor x24, x24, x14 // AES block 4k+3 - round N high + stp x21, x22, [x2], #16 // AES block 4k+2 - store result + ext v10.16b, v10.16b, v10.16b, #8 // MODULO - other mid alignment + stp x23, x24, [x2], #16 // AES block 4k+3 - store result + + eor v11.16b, v11.16b, v8.16b // MODULO - fold into low + aese v1.16b, v31.16b // AES block 4k+5 - round N-1 + aese v0.16b, v31.16b // AES block 4k+4 - round N-1 + aese v3.16b, v31.16b // AES block 4k+7 - round N-1 + aese v2.16b, v31.16b // AES block 4k+6 - round N-1 + eor v11.16b, v11.16b, v10.16b // MODULO - fold into low + +Ldec_tail: // TAIL + sub x5, x4, x0 // main_end_input_ptr is number of bytes left to process + ld1 { v5.16b}, [x0], #16 // AES block 4k+4 - load ciphertext + eor v0.16b, v5.16b, v0.16b // AES block 4k+4 - result + mov x6, v0.d[0] // AES block 4k+4 - mov low + mov x7, v0.d[1] // AES block 4k+4 - mov high + ext v8.16b, v11.16b, v11.16b, #8 // prepare final partial tag + cmp x5, #48 + eor x6, x6, x13 // AES block 4k+4 - round N low + eor x7, x7, x14 // AES block 4k+4 - round N high + b.gt Ldec_blocks_more_than_3 + sub w12, w12, #1 + mov v3.16b, v2.16b + movi v10.8b, #0 + movi v11.8b, #0 + cmp x5, #32 + movi v9.8b, #0 + mov v2.16b, v1.16b + b.gt Ldec_blocks_more_than_2 + sub w12, w12, #1 + mov v3.16b, v1.16b + cmp x5, #16 + b.gt Ldec_blocks_more_than_1 + sub w12, w12, #1 + b Ldec_blocks_less_than_1 +Ldec_blocks_more_than_3: // blocks left > 3 + rev64 v4.16b, v5.16b // GHASH final-3 block + ld1 { v5.16b}, [x0], #16 // AES final-2 block - load ciphertext + stp x6, x7, [x2], #16 // AES final-3 block - store result + mov d10, v17.d[1] // GHASH final-3 block - mid + eor v4.16b, v4.16b, v8.16b // feed in partial tag + eor v0.16b, v5.16b, v1.16b // AES final-2 block - result + mov d22, v4.d[1] // GHASH final-3 block - mid + mov x6, v0.d[0] // AES final-2 block - mov low + mov x7, v0.d[1] // AES final-2 block - mov high + eor v22.8b, v22.8b, v4.8b // GHASH final-3 block - mid + movi v8.8b, #0 // suppress further partial tag feed in + pmull2 v9.1q, v4.2d, v15.2d // GHASH final-3 block - high + pmull v10.1q, v22.1d, v10.1d // GHASH final-3 block - mid + eor x6, x6, x13 // AES final-2 block - round N low + pmull v11.1q, v4.1d, v15.1d // GHASH final-3 block - low + eor x7, x7, x14 // AES final-2 block - round N high +Ldec_blocks_more_than_2: // blocks left > 2 + rev64 v4.16b, v5.16b // GHASH final-2 block + ld1 { v5.16b}, [x0], #16 // AES final-1 block - load ciphertext + eor v4.16b, v4.16b, v8.16b // feed in partial tag + stp x6, x7, [x2], #16 // AES final-2 block - store result + eor v0.16b, v5.16b, v2.16b // AES final-1 block - result + mov d22, v4.d[1] // GHASH final-2 block - mid + pmull v21.1q, v4.1d, v14.1d // GHASH final-2 block - low + pmull2 v20.1q, v4.2d, v14.2d // GHASH final-2 block - high + eor v22.8b, v22.8b, v4.8b // GHASH final-2 block - mid + mov x6, v0.d[0] // AES final-1 block - mov low + mov x7, v0.d[1] // AES final-1 block - mov high + eor v11.16b, v11.16b, v21.16b // GHASH final-2 block - low + movi v8.8b, #0 // suppress further partial tag feed in + pmull v22.1q, v22.1d, v17.1d // GHASH final-2 block - mid + eor v9.16b, v9.16b, v20.16b // GHASH final-2 block - high + eor x6, x6, x13 // AES final-1 block - round N low + eor v10.16b, v10.16b, v22.16b // GHASH final-2 block - mid + eor x7, x7, x14 // AES final-1 block - round N high +Ldec_blocks_more_than_1: // blocks left > 1 + stp x6, x7, [x2], #16 // AES final-1 block - store result + rev64 v4.16b, v5.16b // GHASH final-1 block + ld1 { v5.16b}, [x0], #16 // AES final block - load ciphertext + eor v4.16b, v4.16b, v8.16b // feed in partial tag + movi v8.8b, #0 // suppress further partial tag feed in + mov d22, v4.d[1] // GHASH final-1 block - mid + eor v0.16b, v5.16b, v3.16b // AES final block - result + pmull2 v20.1q, v4.2d, v13.2d // GHASH final-1 block - high + eor v22.8b, v22.8b, v4.8b // GHASH final-1 block - mid + pmull v21.1q, v4.1d, v13.1d // GHASH final-1 block - low + mov x6, v0.d[0] // AES final block - mov low + ins v22.d[1], v22.d[0] // GHASH final-1 block - mid + mov x7, v0.d[1] // AES final block - mov high + pmull2 v22.1q, v22.2d, v16.2d // GHASH final-1 block - mid + eor x6, x6, x13 // AES final block - round N low + eor v11.16b, v11.16b, v21.16b // GHASH final-1 block - low + eor v9.16b, v9.16b, v20.16b // GHASH final-1 block - high + eor v10.16b, v10.16b, v22.16b // GHASH final-1 block - mid + eor x7, x7, x14 // AES final block - round N high +Ldec_blocks_less_than_1: // blocks left <= 1 + and x1, x1, #127 // bit_length %= 128 + mvn x14, xzr // rkN_h = 0xffffffffffffffff + sub x1, x1, #128 // bit_length -= 128 + mvn x13, xzr // rkN_l = 0xffffffffffffffff + ldp x4, x5, [x2] // load existing bytes we need to not overwrite + neg x1, x1 // bit_length = 128 - #bits in input (in range [1,128]) + and x1, x1, #127 // bit_length %= 128 + lsr x14, x14, x1 // rkN_h is mask for top 64b of last block + cmp x1, #64 + csel x9, x13, x14, lt + csel x10, x14, xzr, lt + fmov d0, x9 // ctr0b is mask for last block + and x6, x6, x9 + mov v0.d[1], x10 + bic x4, x4, x9 // mask out low existing bytes + rev w9, w12 + bic x5, x5, x10 // mask out high existing bytes + orr x6, x6, x4 + and x7, x7, x10 + orr x7, x7, x5 + and v5.16b, v5.16b, v0.16b // possibly partial last block has zeroes in highest bits + rev64 v4.16b, v5.16b // GHASH final block + eor v4.16b, v4.16b, v8.16b // feed in partial tag + pmull v21.1q, v4.1d, v12.1d // GHASH final block - low + mov d8, v4.d[1] // GHASH final block - mid + eor v8.8b, v8.8b, v4.8b // GHASH final block - mid + pmull2 v20.1q, v4.2d, v12.2d // GHASH final block - high + pmull v8.1q, v8.1d, v16.1d // GHASH final block - mid + eor v9.16b, v9.16b, v20.16b // GHASH final block - high + eor v11.16b, v11.16b, v21.16b // GHASH final block - low + eor v10.16b, v10.16b, v8.16b // GHASH final block - mid + movi v8.8b, #0xc2 + eor v6.16b, v11.16b, v9.16b // MODULO - karatsuba tidy up + shl d8, d8, #56 // mod_constant + eor v10.16b, v10.16b, v6.16b // MODULO - karatsuba tidy up + pmull v7.1q, v9.1d, v8.1d // MODULO - top 64b align with mid + ext v9.16b, v9.16b, v9.16b, #8 // MODULO - other top alignment + eor v10.16b, v10.16b, v7.16b // MODULO - fold into mid + eor v10.16b, v10.16b, v9.16b // MODULO - fold into mid + pmull v8.1q, v10.1d, v8.1d // MODULO - mid 64b align with low + ext v10.16b, v10.16b, v10.16b, #8 // MODULO - other mid alignment + eor v11.16b, v11.16b, v8.16b // MODULO - fold into low + stp x6, x7, [x2] + str w9, [x16, #12] // store the updated counter + eor v11.16b, v11.16b, v10.16b // MODULO - fold into low + ext v11.16b, v11.16b, v11.16b, #8 + rev64 v11.16b, v11.16b + mov x0, x15 + st1 { v11.16b }, [x3] + ldp x19, x20, [sp, #16] + ldp x21, x22, [sp, #32] + ldp x23, x24, [sp, #48] + ldp d8, d9, [sp, #64] + ldp d10, d11, [sp, #80] + ldp d12, d13, [sp, #96] + ldp d14, d15, [sp, #112] + ldp x29, x30, [sp], #128 + AARCH64_VALIDATE_LINK_REGISTER + ret + +#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(_WIN32) diff --git a/http/vendor/ring/pregenerated/armv4-mont-linux32.S b/http/vendor/ring/pregenerated/armv4-mont-linux32.S new file mode 100644 index 0000000..e1c0055 --- /dev/null +++ b/http/vendor/ring/pregenerated/armv4-mont-linux32.S @@ -0,0 +1,937 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_ARM) && defined(__ELF__) +@ Silence ARMv8 deprecated IT instruction warnings. This file is used by both +@ ARMv7 and ARMv8 processors and does not use ARMv8 instructions. +.arch armv7-a + +.text +#if defined(__thumb2__) +.syntax unified +.thumb +#else +.code 32 +#endif + +.globl bn_mul_mont_nohw +.hidden bn_mul_mont_nohw +.type bn_mul_mont_nohw,%function + +.align 5 +bn_mul_mont_nohw: + ldr ip,[sp,#4] @ load num + stmdb sp!,{r0,r2} @ sp points at argument block + cmp ip,#2 + mov r0,ip @ load num +#ifdef __thumb2__ + ittt lt +#endif + movlt r0,#0 + addlt sp,sp,#2*4 + blt .Labrt + + stmdb sp!,{r4,r5,r6,r7,r8,r9,r10,r11,r12,lr} @ save 10 registers + + mov r0,r0,lsl#2 @ rescale r0 for byte count + sub sp,sp,r0 @ alloca(4*num) + sub sp,sp,#4 @ +extra dword + sub r0,r0,#4 @ "num=num-1" + add r4,r2,r0 @ &bp[num-1] + + add r0,sp,r0 @ r0 to point at &tp[num-1] + ldr r8,[r0,#14*4] @ &n0 + ldr r2,[r2] @ bp[0] + ldr r5,[r1],#4 @ ap[0],ap++ + ldr r6,[r3],#4 @ np[0],np++ + ldr r8,[r8] @ *n0 + str r4,[r0,#15*4] @ save &bp[num] + + umull r10,r11,r5,r2 @ ap[0]*bp[0] + str r8,[r0,#14*4] @ save n0 value + mul r8,r10,r8 @ "tp[0]"*n0 + mov r12,#0 + umlal r10,r12,r6,r8 @ np[0]*n0+"t[0]" + mov r4,sp + +.L1st: + ldr r5,[r1],#4 @ ap[j],ap++ + mov r10,r11 + ldr r6,[r3],#4 @ np[j],np++ + mov r11,#0 + umlal r10,r11,r5,r2 @ ap[j]*bp[0] + mov r14,#0 + umlal r12,r14,r6,r8 @ np[j]*n0 + adds r12,r12,r10 + str r12,[r4],#4 @ tp[j-1]=,tp++ + adc r12,r14,#0 + cmp r4,r0 + bne .L1st + + adds r12,r12,r11 + ldr r4,[r0,#13*4] @ restore bp + mov r14,#0 + ldr r8,[r0,#14*4] @ restore n0 + adc r14,r14,#0 + str r12,[r0] @ tp[num-1]= + mov r7,sp + str r14,[r0,#4] @ tp[num]= + +.Louter: + sub r7,r0,r7 @ "original" r0-1 value + sub r1,r1,r7 @ "rewind" ap to &ap[1] + ldr r2,[r4,#4]! @ *(++bp) + sub r3,r3,r7 @ "rewind" np to &np[1] + ldr r5,[r1,#-4] @ ap[0] + ldr r10,[sp] @ tp[0] + ldr r6,[r3,#-4] @ np[0] + ldr r7,[sp,#4] @ tp[1] + + mov r11,#0 + umlal r10,r11,r5,r2 @ ap[0]*bp[i]+tp[0] + str r4,[r0,#13*4] @ save bp + mul r8,r10,r8 + mov r12,#0 + umlal r10,r12,r6,r8 @ np[0]*n0+"tp[0]" + mov r4,sp + +.Linner: + ldr r5,[r1],#4 @ ap[j],ap++ + adds r10,r11,r7 @ +=tp[j] + ldr r6,[r3],#4 @ np[j],np++ + mov r11,#0 + umlal r10,r11,r5,r2 @ ap[j]*bp[i] + mov r14,#0 + umlal r12,r14,r6,r8 @ np[j]*n0 + adc r11,r11,#0 + ldr r7,[r4,#8] @ tp[j+1] + adds r12,r12,r10 + str r12,[r4],#4 @ tp[j-1]=,tp++ + adc r12,r14,#0 + cmp r4,r0 + bne .Linner + + adds r12,r12,r11 + mov r14,#0 + ldr r4,[r0,#13*4] @ restore bp + adc r14,r14,#0 + ldr r8,[r0,#14*4] @ restore n0 + adds r12,r12,r7 + ldr r7,[r0,#15*4] @ restore &bp[num] + adc r14,r14,#0 + str r12,[r0] @ tp[num-1]= + str r14,[r0,#4] @ tp[num]= + + cmp r4,r7 +#ifdef __thumb2__ + itt ne +#endif + movne r7,sp + bne .Louter + + ldr r2,[r0,#12*4] @ pull rp + mov r5,sp + add r0,r0,#4 @ r0 to point at &tp[num] + sub r5,r0,r5 @ "original" num value + mov r4,sp @ "rewind" r4 + mov r1,r4 @ "borrow" r1 + sub r3,r3,r5 @ "rewind" r3 to &np[0] + + subs r7,r7,r7 @ "clear" carry flag +.Lsub: ldr r7,[r4],#4 + ldr r6,[r3],#4 + sbcs r7,r7,r6 @ tp[j]-np[j] + str r7,[r2],#4 @ rp[j]= + teq r4,r0 @ preserve carry + bne .Lsub + sbcs r14,r14,#0 @ upmost carry + mov r4,sp @ "rewind" r4 + sub r2,r2,r5 @ "rewind" r2 + +.Lcopy: ldr r7,[r4] @ conditional copy + ldr r5,[r2] + str sp,[r4],#4 @ zap tp +#ifdef __thumb2__ + it cc +#endif + movcc r5,r7 + str r5,[r2],#4 + teq r4,r0 @ preserve carry + bne .Lcopy + + mov sp,r0 + add sp,sp,#4 @ skip over tp[num+1] + ldmia sp!,{r4,r5,r6,r7,r8,r9,r10,r11,r12,lr} @ restore registers + add sp,sp,#2*4 @ skip over {r0,r2} + mov r0,#1 +.Labrt: +#if __ARM_ARCH>=5 + bx lr @ bx lr +#else + tst lr,#1 + moveq pc,lr @ be binary compatible with V4, yet +.word 0xe12fff1e @ interoperable with Thumb ISA:-) +#endif +.size bn_mul_mont_nohw,.-bn_mul_mont_nohw +#if __ARM_MAX_ARCH__>=7 +.arch armv7-a +.fpu neon + +.globl bn_mul8x_mont_neon +.hidden bn_mul8x_mont_neon +.type bn_mul8x_mont_neon,%function +.align 5 +bn_mul8x_mont_neon: + mov ip,sp + stmdb sp!,{r4,r5,r6,r7,r8,r9,r10,r11} + vstmdb sp!,{d8,d9,d10,d11,d12,d13,d14,d15} @ ABI specification says so + ldmia ip,{r4,r5} @ load rest of parameter block + mov ip,sp + + cmp r5,#8 + bhi .LNEON_8n + + @ special case for r5==8, everything is in register bank... + + vld1.32 {d28[0]}, [r2,:32]! + veor d8,d8,d8 + sub r7,sp,r5,lsl#4 + vld1.32 {d0,d1,d2,d3}, [r1]! @ can't specify :32 :-( + and r7,r7,#-64 + vld1.32 {d30[0]}, [r4,:32] + mov sp,r7 @ alloca + vzip.16 d28,d8 + + vmull.u32 q6,d28,d0[0] + vmull.u32 q7,d28,d0[1] + vmull.u32 q8,d28,d1[0] + vshl.i64 d29,d13,#16 + vmull.u32 q9,d28,d1[1] + + vadd.u64 d29,d29,d12 + veor d8,d8,d8 + vmul.u32 d29,d29,d30 + + vmull.u32 q10,d28,d2[0] + vld1.32 {d4,d5,d6,d7}, [r3]! + vmull.u32 q11,d28,d2[1] + vmull.u32 q12,d28,d3[0] + vzip.16 d29,d8 + vmull.u32 q13,d28,d3[1] + + vmlal.u32 q6,d29,d4[0] + sub r9,r5,#1 + vmlal.u32 q7,d29,d4[1] + vmlal.u32 q8,d29,d5[0] + vmlal.u32 q9,d29,d5[1] + + vmlal.u32 q10,d29,d6[0] + vmov q5,q6 + vmlal.u32 q11,d29,d6[1] + vmov q6,q7 + vmlal.u32 q12,d29,d7[0] + vmov q7,q8 + vmlal.u32 q13,d29,d7[1] + vmov q8,q9 + vmov q9,q10 + vshr.u64 d10,d10,#16 + vmov q10,q11 + vmov q11,q12 + vadd.u64 d10,d10,d11 + vmov q12,q13 + veor q13,q13 + vshr.u64 d10,d10,#16 + + b .LNEON_outer8 + +.align 4 +.LNEON_outer8: + vld1.32 {d28[0]}, [r2,:32]! + veor d8,d8,d8 + vzip.16 d28,d8 + vadd.u64 d12,d12,d10 + + vmlal.u32 q6,d28,d0[0] + vmlal.u32 q7,d28,d0[1] + vmlal.u32 q8,d28,d1[0] + vshl.i64 d29,d13,#16 + vmlal.u32 q9,d28,d1[1] + + vadd.u64 d29,d29,d12 + veor d8,d8,d8 + subs r9,r9,#1 + vmul.u32 d29,d29,d30 + + vmlal.u32 q10,d28,d2[0] + vmlal.u32 q11,d28,d2[1] + vmlal.u32 q12,d28,d3[0] + vzip.16 d29,d8 + vmlal.u32 q13,d28,d3[1] + + vmlal.u32 q6,d29,d4[0] + vmlal.u32 q7,d29,d4[1] + vmlal.u32 q8,d29,d5[0] + vmlal.u32 q9,d29,d5[1] + + vmlal.u32 q10,d29,d6[0] + vmov q5,q6 + vmlal.u32 q11,d29,d6[1] + vmov q6,q7 + vmlal.u32 q12,d29,d7[0] + vmov q7,q8 + vmlal.u32 q13,d29,d7[1] + vmov q8,q9 + vmov q9,q10 + vshr.u64 d10,d10,#16 + vmov q10,q11 + vmov q11,q12 + vadd.u64 d10,d10,d11 + vmov q12,q13 + veor q13,q13 + vshr.u64 d10,d10,#16 + + bne .LNEON_outer8 + + vadd.u64 d12,d12,d10 + mov r7,sp + vshr.u64 d10,d12,#16 + mov r8,r5 + vadd.u64 d13,d13,d10 + add r6,sp,#96 + vshr.u64 d10,d13,#16 + vzip.16 d12,d13 + + b .LNEON_tail_entry + +.align 4 +.LNEON_8n: + veor q6,q6,q6 + sub r7,sp,#128 + veor q7,q7,q7 + sub r7,r7,r5,lsl#4 + veor q8,q8,q8 + and r7,r7,#-64 + veor q9,q9,q9 + mov sp,r7 @ alloca + veor q10,q10,q10 + add r7,r7,#256 + veor q11,q11,q11 + sub r8,r5,#8 + veor q12,q12,q12 + veor q13,q13,q13 + +.LNEON_8n_init: + vst1.64 {q6,q7},[r7,:256]! + subs r8,r8,#8 + vst1.64 {q8,q9},[r7,:256]! + vst1.64 {q10,q11},[r7,:256]! + vst1.64 {q12,q13},[r7,:256]! + bne .LNEON_8n_init + + add r6,sp,#256 + vld1.32 {d0,d1,d2,d3},[r1]! + add r10,sp,#8 + vld1.32 {d30[0]},[r4,:32] + mov r9,r5 + b .LNEON_8n_outer + +.align 4 +.LNEON_8n_outer: + vld1.32 {d28[0]},[r2,:32]! @ *b++ + veor d8,d8,d8 + vzip.16 d28,d8 + add r7,sp,#128 + vld1.32 {d4,d5,d6,d7},[r3]! + + vmlal.u32 q6,d28,d0[0] + vmlal.u32 q7,d28,d0[1] + veor d8,d8,d8 + vmlal.u32 q8,d28,d1[0] + vshl.i64 d29,d13,#16 + vmlal.u32 q9,d28,d1[1] + vadd.u64 d29,d29,d12 + vmlal.u32 q10,d28,d2[0] + vmul.u32 d29,d29,d30 + vmlal.u32 q11,d28,d2[1] + vst1.32 {d28},[sp,:64] @ put aside smashed b[8*i+0] + vmlal.u32 q12,d28,d3[0] + vzip.16 d29,d8 + vmlal.u32 q13,d28,d3[1] + vld1.32 {d28[0]},[r2,:32]! @ *b++ + vmlal.u32 q6,d29,d4[0] + veor d10,d10,d10 + vmlal.u32 q7,d29,d4[1] + vzip.16 d28,d10 + vmlal.u32 q8,d29,d5[0] + vshr.u64 d12,d12,#16 + vmlal.u32 q9,d29,d5[1] + vmlal.u32 q10,d29,d6[0] + vadd.u64 d12,d12,d13 + vmlal.u32 q11,d29,d6[1] + vshr.u64 d12,d12,#16 + vmlal.u32 q12,d29,d7[0] + vmlal.u32 q13,d29,d7[1] + vadd.u64 d14,d14,d12 + vst1.32 {d29},[r10,:64]! @ put aside smashed m[8*i+0] + vmlal.u32 q7,d28,d0[0] + vld1.64 {q6},[r6,:128]! + vmlal.u32 q8,d28,d0[1] + veor d8,d8,d8 + vmlal.u32 q9,d28,d1[0] + vshl.i64 d29,d15,#16 + vmlal.u32 q10,d28,d1[1] + vadd.u64 d29,d29,d14 + vmlal.u32 q11,d28,d2[0] + vmul.u32 d29,d29,d30 + vmlal.u32 q12,d28,d2[1] + vst1.32 {d28},[r10,:64]! @ put aside smashed b[8*i+1] + vmlal.u32 q13,d28,d3[0] + vzip.16 d29,d8 + vmlal.u32 q6,d28,d3[1] + vld1.32 {d28[0]},[r2,:32]! @ *b++ + vmlal.u32 q7,d29,d4[0] + veor d10,d10,d10 + vmlal.u32 q8,d29,d4[1] + vzip.16 d28,d10 + vmlal.u32 q9,d29,d5[0] + vshr.u64 d14,d14,#16 + vmlal.u32 q10,d29,d5[1] + vmlal.u32 q11,d29,d6[0] + vadd.u64 d14,d14,d15 + vmlal.u32 q12,d29,d6[1] + vshr.u64 d14,d14,#16 + vmlal.u32 q13,d29,d7[0] + vmlal.u32 q6,d29,d7[1] + vadd.u64 d16,d16,d14 + vst1.32 {d29},[r10,:64]! @ put aside smashed m[8*i+1] + vmlal.u32 q8,d28,d0[0] + vld1.64 {q7},[r6,:128]! + vmlal.u32 q9,d28,d0[1] + veor d8,d8,d8 + vmlal.u32 q10,d28,d1[0] + vshl.i64 d29,d17,#16 + vmlal.u32 q11,d28,d1[1] + vadd.u64 d29,d29,d16 + vmlal.u32 q12,d28,d2[0] + vmul.u32 d29,d29,d30 + vmlal.u32 q13,d28,d2[1] + vst1.32 {d28},[r10,:64]! @ put aside smashed b[8*i+2] + vmlal.u32 q6,d28,d3[0] + vzip.16 d29,d8 + vmlal.u32 q7,d28,d3[1] + vld1.32 {d28[0]},[r2,:32]! @ *b++ + vmlal.u32 q8,d29,d4[0] + veor d10,d10,d10 + vmlal.u32 q9,d29,d4[1] + vzip.16 d28,d10 + vmlal.u32 q10,d29,d5[0] + vshr.u64 d16,d16,#16 + vmlal.u32 q11,d29,d5[1] + vmlal.u32 q12,d29,d6[0] + vadd.u64 d16,d16,d17 + vmlal.u32 q13,d29,d6[1] + vshr.u64 d16,d16,#16 + vmlal.u32 q6,d29,d7[0] + vmlal.u32 q7,d29,d7[1] + vadd.u64 d18,d18,d16 + vst1.32 {d29},[r10,:64]! @ put aside smashed m[8*i+2] + vmlal.u32 q9,d28,d0[0] + vld1.64 {q8},[r6,:128]! + vmlal.u32 q10,d28,d0[1] + veor d8,d8,d8 + vmlal.u32 q11,d28,d1[0] + vshl.i64 d29,d19,#16 + vmlal.u32 q12,d28,d1[1] + vadd.u64 d29,d29,d18 + vmlal.u32 q13,d28,d2[0] + vmul.u32 d29,d29,d30 + vmlal.u32 q6,d28,d2[1] + vst1.32 {d28},[r10,:64]! @ put aside smashed b[8*i+3] + vmlal.u32 q7,d28,d3[0] + vzip.16 d29,d8 + vmlal.u32 q8,d28,d3[1] + vld1.32 {d28[0]},[r2,:32]! @ *b++ + vmlal.u32 q9,d29,d4[0] + veor d10,d10,d10 + vmlal.u32 q10,d29,d4[1] + vzip.16 d28,d10 + vmlal.u32 q11,d29,d5[0] + vshr.u64 d18,d18,#16 + vmlal.u32 q12,d29,d5[1] + vmlal.u32 q13,d29,d6[0] + vadd.u64 d18,d18,d19 + vmlal.u32 q6,d29,d6[1] + vshr.u64 d18,d18,#16 + vmlal.u32 q7,d29,d7[0] + vmlal.u32 q8,d29,d7[1] + vadd.u64 d20,d20,d18 + vst1.32 {d29},[r10,:64]! @ put aside smashed m[8*i+3] + vmlal.u32 q10,d28,d0[0] + vld1.64 {q9},[r6,:128]! + vmlal.u32 q11,d28,d0[1] + veor d8,d8,d8 + vmlal.u32 q12,d28,d1[0] + vshl.i64 d29,d21,#16 + vmlal.u32 q13,d28,d1[1] + vadd.u64 d29,d29,d20 + vmlal.u32 q6,d28,d2[0] + vmul.u32 d29,d29,d30 + vmlal.u32 q7,d28,d2[1] + vst1.32 {d28},[r10,:64]! @ put aside smashed b[8*i+4] + vmlal.u32 q8,d28,d3[0] + vzip.16 d29,d8 + vmlal.u32 q9,d28,d3[1] + vld1.32 {d28[0]},[r2,:32]! @ *b++ + vmlal.u32 q10,d29,d4[0] + veor d10,d10,d10 + vmlal.u32 q11,d29,d4[1] + vzip.16 d28,d10 + vmlal.u32 q12,d29,d5[0] + vshr.u64 d20,d20,#16 + vmlal.u32 q13,d29,d5[1] + vmlal.u32 q6,d29,d6[0] + vadd.u64 d20,d20,d21 + vmlal.u32 q7,d29,d6[1] + vshr.u64 d20,d20,#16 + vmlal.u32 q8,d29,d7[0] + vmlal.u32 q9,d29,d7[1] + vadd.u64 d22,d22,d20 + vst1.32 {d29},[r10,:64]! @ put aside smashed m[8*i+4] + vmlal.u32 q11,d28,d0[0] + vld1.64 {q10},[r6,:128]! + vmlal.u32 q12,d28,d0[1] + veor d8,d8,d8 + vmlal.u32 q13,d28,d1[0] + vshl.i64 d29,d23,#16 + vmlal.u32 q6,d28,d1[1] + vadd.u64 d29,d29,d22 + vmlal.u32 q7,d28,d2[0] + vmul.u32 d29,d29,d30 + vmlal.u32 q8,d28,d2[1] + vst1.32 {d28},[r10,:64]! @ put aside smashed b[8*i+5] + vmlal.u32 q9,d28,d3[0] + vzip.16 d29,d8 + vmlal.u32 q10,d28,d3[1] + vld1.32 {d28[0]},[r2,:32]! @ *b++ + vmlal.u32 q11,d29,d4[0] + veor d10,d10,d10 + vmlal.u32 q12,d29,d4[1] + vzip.16 d28,d10 + vmlal.u32 q13,d29,d5[0] + vshr.u64 d22,d22,#16 + vmlal.u32 q6,d29,d5[1] + vmlal.u32 q7,d29,d6[0] + vadd.u64 d22,d22,d23 + vmlal.u32 q8,d29,d6[1] + vshr.u64 d22,d22,#16 + vmlal.u32 q9,d29,d7[0] + vmlal.u32 q10,d29,d7[1] + vadd.u64 d24,d24,d22 + vst1.32 {d29},[r10,:64]! @ put aside smashed m[8*i+5] + vmlal.u32 q12,d28,d0[0] + vld1.64 {q11},[r6,:128]! + vmlal.u32 q13,d28,d0[1] + veor d8,d8,d8 + vmlal.u32 q6,d28,d1[0] + vshl.i64 d29,d25,#16 + vmlal.u32 q7,d28,d1[1] + vadd.u64 d29,d29,d24 + vmlal.u32 q8,d28,d2[0] + vmul.u32 d29,d29,d30 + vmlal.u32 q9,d28,d2[1] + vst1.32 {d28},[r10,:64]! @ put aside smashed b[8*i+6] + vmlal.u32 q10,d28,d3[0] + vzip.16 d29,d8 + vmlal.u32 q11,d28,d3[1] + vld1.32 {d28[0]},[r2,:32]! @ *b++ + vmlal.u32 q12,d29,d4[0] + veor d10,d10,d10 + vmlal.u32 q13,d29,d4[1] + vzip.16 d28,d10 + vmlal.u32 q6,d29,d5[0] + vshr.u64 d24,d24,#16 + vmlal.u32 q7,d29,d5[1] + vmlal.u32 q8,d29,d6[0] + vadd.u64 d24,d24,d25 + vmlal.u32 q9,d29,d6[1] + vshr.u64 d24,d24,#16 + vmlal.u32 q10,d29,d7[0] + vmlal.u32 q11,d29,d7[1] + vadd.u64 d26,d26,d24 + vst1.32 {d29},[r10,:64]! @ put aside smashed m[8*i+6] + vmlal.u32 q13,d28,d0[0] + vld1.64 {q12},[r6,:128]! + vmlal.u32 q6,d28,d0[1] + veor d8,d8,d8 + vmlal.u32 q7,d28,d1[0] + vshl.i64 d29,d27,#16 + vmlal.u32 q8,d28,d1[1] + vadd.u64 d29,d29,d26 + vmlal.u32 q9,d28,d2[0] + vmul.u32 d29,d29,d30 + vmlal.u32 q10,d28,d2[1] + vst1.32 {d28},[r10,:64]! @ put aside smashed b[8*i+7] + vmlal.u32 q11,d28,d3[0] + vzip.16 d29,d8 + vmlal.u32 q12,d28,d3[1] + vld1.32 {d28},[sp,:64] @ pull smashed b[8*i+0] + vmlal.u32 q13,d29,d4[0] + vld1.32 {d0,d1,d2,d3},[r1]! + vmlal.u32 q6,d29,d4[1] + vmlal.u32 q7,d29,d5[0] + vshr.u64 d26,d26,#16 + vmlal.u32 q8,d29,d5[1] + vmlal.u32 q9,d29,d6[0] + vadd.u64 d26,d26,d27 + vmlal.u32 q10,d29,d6[1] + vshr.u64 d26,d26,#16 + vmlal.u32 q11,d29,d7[0] + vmlal.u32 q12,d29,d7[1] + vadd.u64 d12,d12,d26 + vst1.32 {d29},[r10,:64] @ put aside smashed m[8*i+7] + add r10,sp,#8 @ rewind + sub r8,r5,#8 + b .LNEON_8n_inner + +.align 4 +.LNEON_8n_inner: + subs r8,r8,#8 + vmlal.u32 q6,d28,d0[0] + vld1.64 {q13},[r6,:128] + vmlal.u32 q7,d28,d0[1] + vld1.32 {d29},[r10,:64]! @ pull smashed m[8*i+0] + vmlal.u32 q8,d28,d1[0] + vld1.32 {d4,d5,d6,d7},[r3]! + vmlal.u32 q9,d28,d1[1] + it ne + addne r6,r6,#16 @ don't advance in last iteration + vmlal.u32 q10,d28,d2[0] + vmlal.u32 q11,d28,d2[1] + vmlal.u32 q12,d28,d3[0] + vmlal.u32 q13,d28,d3[1] + vld1.32 {d28},[r10,:64]! @ pull smashed b[8*i+1] + vmlal.u32 q6,d29,d4[0] + vmlal.u32 q7,d29,d4[1] + vmlal.u32 q8,d29,d5[0] + vmlal.u32 q9,d29,d5[1] + vmlal.u32 q10,d29,d6[0] + vmlal.u32 q11,d29,d6[1] + vmlal.u32 q12,d29,d7[0] + vmlal.u32 q13,d29,d7[1] + vst1.64 {q6},[r7,:128]! + vmlal.u32 q7,d28,d0[0] + vld1.64 {q6},[r6,:128] + vmlal.u32 q8,d28,d0[1] + vld1.32 {d29},[r10,:64]! @ pull smashed m[8*i+1] + vmlal.u32 q9,d28,d1[0] + it ne + addne r6,r6,#16 @ don't advance in last iteration + vmlal.u32 q10,d28,d1[1] + vmlal.u32 q11,d28,d2[0] + vmlal.u32 q12,d28,d2[1] + vmlal.u32 q13,d28,d3[0] + vmlal.u32 q6,d28,d3[1] + vld1.32 {d28},[r10,:64]! @ pull smashed b[8*i+2] + vmlal.u32 q7,d29,d4[0] + vmlal.u32 q8,d29,d4[1] + vmlal.u32 q9,d29,d5[0] + vmlal.u32 q10,d29,d5[1] + vmlal.u32 q11,d29,d6[0] + vmlal.u32 q12,d29,d6[1] + vmlal.u32 q13,d29,d7[0] + vmlal.u32 q6,d29,d7[1] + vst1.64 {q7},[r7,:128]! + vmlal.u32 q8,d28,d0[0] + vld1.64 {q7},[r6,:128] + vmlal.u32 q9,d28,d0[1] + vld1.32 {d29},[r10,:64]! @ pull smashed m[8*i+2] + vmlal.u32 q10,d28,d1[0] + it ne + addne r6,r6,#16 @ don't advance in last iteration + vmlal.u32 q11,d28,d1[1] + vmlal.u32 q12,d28,d2[0] + vmlal.u32 q13,d28,d2[1] + vmlal.u32 q6,d28,d3[0] + vmlal.u32 q7,d28,d3[1] + vld1.32 {d28},[r10,:64]! @ pull smashed b[8*i+3] + vmlal.u32 q8,d29,d4[0] + vmlal.u32 q9,d29,d4[1] + vmlal.u32 q10,d29,d5[0] + vmlal.u32 q11,d29,d5[1] + vmlal.u32 q12,d29,d6[0] + vmlal.u32 q13,d29,d6[1] + vmlal.u32 q6,d29,d7[0] + vmlal.u32 q7,d29,d7[1] + vst1.64 {q8},[r7,:128]! + vmlal.u32 q9,d28,d0[0] + vld1.64 {q8},[r6,:128] + vmlal.u32 q10,d28,d0[1] + vld1.32 {d29},[r10,:64]! @ pull smashed m[8*i+3] + vmlal.u32 q11,d28,d1[0] + it ne + addne r6,r6,#16 @ don't advance in last iteration + vmlal.u32 q12,d28,d1[1] + vmlal.u32 q13,d28,d2[0] + vmlal.u32 q6,d28,d2[1] + vmlal.u32 q7,d28,d3[0] + vmlal.u32 q8,d28,d3[1] + vld1.32 {d28},[r10,:64]! @ pull smashed b[8*i+4] + vmlal.u32 q9,d29,d4[0] + vmlal.u32 q10,d29,d4[1] + vmlal.u32 q11,d29,d5[0] + vmlal.u32 q12,d29,d5[1] + vmlal.u32 q13,d29,d6[0] + vmlal.u32 q6,d29,d6[1] + vmlal.u32 q7,d29,d7[0] + vmlal.u32 q8,d29,d7[1] + vst1.64 {q9},[r7,:128]! + vmlal.u32 q10,d28,d0[0] + vld1.64 {q9},[r6,:128] + vmlal.u32 q11,d28,d0[1] + vld1.32 {d29},[r10,:64]! @ pull smashed m[8*i+4] + vmlal.u32 q12,d28,d1[0] + it ne + addne r6,r6,#16 @ don't advance in last iteration + vmlal.u32 q13,d28,d1[1] + vmlal.u32 q6,d28,d2[0] + vmlal.u32 q7,d28,d2[1] + vmlal.u32 q8,d28,d3[0] + vmlal.u32 q9,d28,d3[1] + vld1.32 {d28},[r10,:64]! @ pull smashed b[8*i+5] + vmlal.u32 q10,d29,d4[0] + vmlal.u32 q11,d29,d4[1] + vmlal.u32 q12,d29,d5[0] + vmlal.u32 q13,d29,d5[1] + vmlal.u32 q6,d29,d6[0] + vmlal.u32 q7,d29,d6[1] + vmlal.u32 q8,d29,d7[0] + vmlal.u32 q9,d29,d7[1] + vst1.64 {q10},[r7,:128]! + vmlal.u32 q11,d28,d0[0] + vld1.64 {q10},[r6,:128] + vmlal.u32 q12,d28,d0[1] + vld1.32 {d29},[r10,:64]! @ pull smashed m[8*i+5] + vmlal.u32 q13,d28,d1[0] + it ne + addne r6,r6,#16 @ don't advance in last iteration + vmlal.u32 q6,d28,d1[1] + vmlal.u32 q7,d28,d2[0] + vmlal.u32 q8,d28,d2[1] + vmlal.u32 q9,d28,d3[0] + vmlal.u32 q10,d28,d3[1] + vld1.32 {d28},[r10,:64]! @ pull smashed b[8*i+6] + vmlal.u32 q11,d29,d4[0] + vmlal.u32 q12,d29,d4[1] + vmlal.u32 q13,d29,d5[0] + vmlal.u32 q6,d29,d5[1] + vmlal.u32 q7,d29,d6[0] + vmlal.u32 q8,d29,d6[1] + vmlal.u32 q9,d29,d7[0] + vmlal.u32 q10,d29,d7[1] + vst1.64 {q11},[r7,:128]! + vmlal.u32 q12,d28,d0[0] + vld1.64 {q11},[r6,:128] + vmlal.u32 q13,d28,d0[1] + vld1.32 {d29},[r10,:64]! @ pull smashed m[8*i+6] + vmlal.u32 q6,d28,d1[0] + it ne + addne r6,r6,#16 @ don't advance in last iteration + vmlal.u32 q7,d28,d1[1] + vmlal.u32 q8,d28,d2[0] + vmlal.u32 q9,d28,d2[1] + vmlal.u32 q10,d28,d3[0] + vmlal.u32 q11,d28,d3[1] + vld1.32 {d28},[r10,:64]! @ pull smashed b[8*i+7] + vmlal.u32 q12,d29,d4[0] + vmlal.u32 q13,d29,d4[1] + vmlal.u32 q6,d29,d5[0] + vmlal.u32 q7,d29,d5[1] + vmlal.u32 q8,d29,d6[0] + vmlal.u32 q9,d29,d6[1] + vmlal.u32 q10,d29,d7[0] + vmlal.u32 q11,d29,d7[1] + vst1.64 {q12},[r7,:128]! + vmlal.u32 q13,d28,d0[0] + vld1.64 {q12},[r6,:128] + vmlal.u32 q6,d28,d0[1] + vld1.32 {d29},[r10,:64]! @ pull smashed m[8*i+7] + vmlal.u32 q7,d28,d1[0] + it ne + addne r6,r6,#16 @ don't advance in last iteration + vmlal.u32 q8,d28,d1[1] + vmlal.u32 q9,d28,d2[0] + vmlal.u32 q10,d28,d2[1] + vmlal.u32 q11,d28,d3[0] + vmlal.u32 q12,d28,d3[1] + it eq + subeq r1,r1,r5,lsl#2 @ rewind + vmlal.u32 q13,d29,d4[0] + vld1.32 {d28},[sp,:64] @ pull smashed b[8*i+0] + vmlal.u32 q6,d29,d4[1] + vld1.32 {d0,d1,d2,d3},[r1]! + vmlal.u32 q7,d29,d5[0] + add r10,sp,#8 @ rewind + vmlal.u32 q8,d29,d5[1] + vmlal.u32 q9,d29,d6[0] + vmlal.u32 q10,d29,d6[1] + vmlal.u32 q11,d29,d7[0] + vst1.64 {q13},[r7,:128]! + vmlal.u32 q12,d29,d7[1] + + bne .LNEON_8n_inner + add r6,sp,#128 + vst1.64 {q6,q7},[r7,:256]! + veor q2,q2,q2 @ d4-d5 + vst1.64 {q8,q9},[r7,:256]! + veor q3,q3,q3 @ d6-d7 + vst1.64 {q10,q11},[r7,:256]! + vst1.64 {q12},[r7,:128] + + subs r9,r9,#8 + vld1.64 {q6,q7},[r6,:256]! + vld1.64 {q8,q9},[r6,:256]! + vld1.64 {q10,q11},[r6,:256]! + vld1.64 {q12,q13},[r6,:256]! + + itt ne + subne r3,r3,r5,lsl#2 @ rewind + bne .LNEON_8n_outer + + add r7,sp,#128 + vst1.64 {q2,q3}, [sp,:256]! @ start wiping stack frame + vshr.u64 d10,d12,#16 + vst1.64 {q2,q3},[sp,:256]! + vadd.u64 d13,d13,d10 + vst1.64 {q2,q3}, [sp,:256]! + vshr.u64 d10,d13,#16 + vst1.64 {q2,q3}, [sp,:256]! + vzip.16 d12,d13 + + mov r8,r5 + b .LNEON_tail_entry + +.align 4 +.LNEON_tail: + vadd.u64 d12,d12,d10 + vshr.u64 d10,d12,#16 + vld1.64 {q8,q9}, [r6, :256]! + vadd.u64 d13,d13,d10 + vld1.64 {q10,q11}, [r6, :256]! + vshr.u64 d10,d13,#16 + vld1.64 {q12,q13}, [r6, :256]! + vzip.16 d12,d13 + +.LNEON_tail_entry: + vadd.u64 d14,d14,d10 + vst1.32 {d12[0]}, [r7, :32]! + vshr.u64 d10,d14,#16 + vadd.u64 d15,d15,d10 + vshr.u64 d10,d15,#16 + vzip.16 d14,d15 + vadd.u64 d16,d16,d10 + vst1.32 {d14[0]}, [r7, :32]! + vshr.u64 d10,d16,#16 + vadd.u64 d17,d17,d10 + vshr.u64 d10,d17,#16 + vzip.16 d16,d17 + vadd.u64 d18,d18,d10 + vst1.32 {d16[0]}, [r7, :32]! + vshr.u64 d10,d18,#16 + vadd.u64 d19,d19,d10 + vshr.u64 d10,d19,#16 + vzip.16 d18,d19 + vadd.u64 d20,d20,d10 + vst1.32 {d18[0]}, [r7, :32]! + vshr.u64 d10,d20,#16 + vadd.u64 d21,d21,d10 + vshr.u64 d10,d21,#16 + vzip.16 d20,d21 + vadd.u64 d22,d22,d10 + vst1.32 {d20[0]}, [r7, :32]! + vshr.u64 d10,d22,#16 + vadd.u64 d23,d23,d10 + vshr.u64 d10,d23,#16 + vzip.16 d22,d23 + vadd.u64 d24,d24,d10 + vst1.32 {d22[0]}, [r7, :32]! + vshr.u64 d10,d24,#16 + vadd.u64 d25,d25,d10 + vshr.u64 d10,d25,#16 + vzip.16 d24,d25 + vadd.u64 d26,d26,d10 + vst1.32 {d24[0]}, [r7, :32]! + vshr.u64 d10,d26,#16 + vadd.u64 d27,d27,d10 + vshr.u64 d10,d27,#16 + vzip.16 d26,d27 + vld1.64 {q6,q7}, [r6, :256]! + subs r8,r8,#8 + vst1.32 {d26[0]}, [r7, :32]! + bne .LNEON_tail + + vst1.32 {d10[0]}, [r7, :32] @ top-most bit + sub r3,r3,r5,lsl#2 @ rewind r3 + subs r1,sp,#0 @ clear carry flag + add r2,sp,r5,lsl#2 + +.LNEON_sub: + ldmia r1!, {r4,r5,r6,r7} + ldmia r3!, {r8,r9,r10,r11} + sbcs r8, r4,r8 + sbcs r9, r5,r9 + sbcs r10,r6,r10 + sbcs r11,r7,r11 + teq r1,r2 @ preserves carry + stmia r0!, {r8,r9,r10,r11} + bne .LNEON_sub + + ldr r10, [r1] @ load top-most bit + mov r11,sp + veor q0,q0,q0 + sub r11,r2,r11 @ this is num*4 + veor q1,q1,q1 + mov r1,sp + sub r0,r0,r11 @ rewind r0 + mov r3,r2 @ second 3/4th of frame + sbcs r10,r10,#0 @ result is carry flag + +.LNEON_copy_n_zap: + ldmia r1!, {r4,r5,r6,r7} + ldmia r0, {r8,r9,r10,r11} + it cc + movcc r8, r4 + vst1.64 {q0,q1}, [r3,:256]! @ wipe + itt cc + movcc r9, r5 + movcc r10,r6 + vst1.64 {q0,q1}, [r3,:256]! @ wipe + it cc + movcc r11,r7 + ldmia r1, {r4,r5,r6,r7} + stmia r0!, {r8,r9,r10,r11} + sub r1,r1,#16 + ldmia r0, {r8,r9,r10,r11} + it cc + movcc r8, r4 + vst1.64 {q0,q1}, [r1,:256]! @ wipe + itt cc + movcc r9, r5 + movcc r10,r6 + vst1.64 {q0,q1}, [r3,:256]! @ wipe + it cc + movcc r11,r7 + teq r1,r2 @ preserves carry + stmia r0!, {r8,r9,r10,r11} + bne .LNEON_copy_n_zap + + mov sp,ip + vldmia sp!,{d8,d9,d10,d11,d12,d13,d14,d15} + ldmia sp!,{r4,r5,r6,r7,r8,r9,r10,r11} + bx lr @ bx lr +.size bn_mul8x_mont_neon,.-bn_mul8x_mont_neon +#endif +.byte 77,111,110,116,103,111,109,101,114,121,32,109,117,108,116,105,112,108,105,99,97,116,105,111,110,32,102,111,114,32,65,82,77,118,52,47,78,69,79,78,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.align 2 +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_ARM) && defined(__ELF__) diff --git a/http/vendor/ring/pregenerated/armv8-mont-ios64.S b/http/vendor/ring/pregenerated/armv8-mont-ios64.S new file mode 100644 index 0000000..ef7d5b6 --- /dev/null +++ b/http/vendor/ring/pregenerated/armv8-mont-ios64.S @@ -0,0 +1,1416 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__APPLE__) +.text + +.globl _bn_mul_mont_nohw +.private_extern _bn_mul_mont_nohw + +.align 5 +_bn_mul_mont_nohw: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-64]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + + ldr x9,[x2],#8 // bp[0] + sub x22,sp,x5,lsl#3 + ldp x7,x8,[x1],#16 // ap[0..1] + lsl x5,x5,#3 + ldr x4,[x4] // *n0 + and x22,x22,#-16 // ABI says so + ldp x13,x14,[x3],#16 // np[0..1] + + mul x6,x7,x9 // ap[0]*bp[0] + sub x21,x5,#16 // j=num-2 + umulh x7,x7,x9 + mul x10,x8,x9 // ap[1]*bp[0] + umulh x11,x8,x9 + + mul x15,x6,x4 // "tp[0]"*n0 + mov sp,x22 // alloca + + // (*) mul x12,x13,x15 // np[0]*m1 + umulh x13,x13,x15 + mul x16,x14,x15 // np[1]*m1 + // (*) adds x12,x12,x6 // discarded + // (*) As for removal of first multiplication and addition + // instructions. The outcome of first addition is + // guaranteed to be zero, which leaves two computationally + // significant outcomes: it either carries or not. Then + // question is when does it carry? Is there alternative + // way to deduce it? If you follow operations, you can + // observe that condition for carry is quite simple: + // x6 being non-zero. So that carry can be calculated + // by adding -1 to x6. That's what next instruction does. + subs xzr,x6,#1 // (*) + umulh x17,x14,x15 + adc x13,x13,xzr + cbz x21,L1st_skip + +L1st: + ldr x8,[x1],#8 + adds x6,x10,x7 + sub x21,x21,#8 // j-- + adc x7,x11,xzr + + ldr x14,[x3],#8 + adds x12,x16,x13 + mul x10,x8,x9 // ap[j]*bp[0] + adc x13,x17,xzr + umulh x11,x8,x9 + + adds x12,x12,x6 + mul x16,x14,x15 // np[j]*m1 + adc x13,x13,xzr + umulh x17,x14,x15 + str x12,[x22],#8 // tp[j-1] + cbnz x21,L1st + +L1st_skip: + adds x6,x10,x7 + sub x1,x1,x5 // rewind x1 + adc x7,x11,xzr + + adds x12,x16,x13 + sub x3,x3,x5 // rewind x3 + adc x13,x17,xzr + + adds x12,x12,x6 + sub x20,x5,#8 // i=num-1 + adcs x13,x13,x7 + + adc x19,xzr,xzr // upmost overflow bit + stp x12,x13,[x22] + +Louter: + ldr x9,[x2],#8 // bp[i] + ldp x7,x8,[x1],#16 + ldr x23,[sp] // tp[0] + add x22,sp,#8 + + mul x6,x7,x9 // ap[0]*bp[i] + sub x21,x5,#16 // j=num-2 + umulh x7,x7,x9 + ldp x13,x14,[x3],#16 + mul x10,x8,x9 // ap[1]*bp[i] + adds x6,x6,x23 + umulh x11,x8,x9 + adc x7,x7,xzr + + mul x15,x6,x4 + sub x20,x20,#8 // i-- + + // (*) mul x12,x13,x15 // np[0]*m1 + umulh x13,x13,x15 + mul x16,x14,x15 // np[1]*m1 + // (*) adds x12,x12,x6 + subs xzr,x6,#1 // (*) + umulh x17,x14,x15 + cbz x21,Linner_skip + +Linner: + ldr x8,[x1],#8 + adc x13,x13,xzr + ldr x23,[x22],#8 // tp[j] + adds x6,x10,x7 + sub x21,x21,#8 // j-- + adc x7,x11,xzr + + adds x12,x16,x13 + ldr x14,[x3],#8 + adc x13,x17,xzr + + mul x10,x8,x9 // ap[j]*bp[i] + adds x6,x6,x23 + umulh x11,x8,x9 + adc x7,x7,xzr + + mul x16,x14,x15 // np[j]*m1 + adds x12,x12,x6 + umulh x17,x14,x15 + str x12,[x22,#-16] // tp[j-1] + cbnz x21,Linner + +Linner_skip: + ldr x23,[x22],#8 // tp[j] + adc x13,x13,xzr + adds x6,x10,x7 + sub x1,x1,x5 // rewind x1 + adc x7,x11,xzr + + adds x12,x16,x13 + sub x3,x3,x5 // rewind x3 + adcs x13,x17,x19 + adc x19,xzr,xzr + + adds x6,x6,x23 + adc x7,x7,xzr + + adds x12,x12,x6 + adcs x13,x13,x7 + adc x19,x19,xzr // upmost overflow bit + stp x12,x13,[x22,#-16] + + cbnz x20,Louter + + // Final step. We see if result is larger than modulus, and + // if it is, subtract the modulus. But comparison implies + // subtraction. So we subtract modulus, see if it borrowed, + // and conditionally copy original value. + ldr x23,[sp] // tp[0] + add x22,sp,#8 + ldr x14,[x3],#8 // np[0] + subs x21,x5,#8 // j=num-1 and clear borrow + mov x1,x0 +Lsub: + sbcs x8,x23,x14 // tp[j]-np[j] + ldr x23,[x22],#8 + sub x21,x21,#8 // j-- + ldr x14,[x3],#8 + str x8,[x1],#8 // rp[j]=tp[j]-np[j] + cbnz x21,Lsub + + sbcs x8,x23,x14 + sbcs x19,x19,xzr // did it borrow? + str x8,[x1],#8 // rp[num-1] + + ldr x23,[sp] // tp[0] + add x22,sp,#8 + ldr x8,[x0],#8 // rp[0] + sub x5,x5,#8 // num-- + nop +Lcond_copy: + sub x5,x5,#8 // num-- + csel x14,x23,x8,lo // did it borrow? + ldr x23,[x22],#8 + ldr x8,[x0],#8 + str xzr,[x22,#-16] // wipe tp + str x14,[x0,#-16] + cbnz x5,Lcond_copy + + csel x14,x23,x8,lo + str xzr,[x22,#-8] // wipe tp + str x14,[x0,#-8] + + ldp x19,x20,[x29,#16] + mov sp,x29 + ldp x21,x22,[x29,#32] + mov x0,#1 + ldp x23,x24,[x29,#48] + ldr x29,[sp],#64 + AARCH64_VALIDATE_LINK_REGISTER + ret + +.globl _bn_sqr8x_mont +.private_extern _bn_sqr8x_mont + +.align 5 +_bn_sqr8x_mont: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-128]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + stp x27,x28,[sp,#80] + stp x0,x3,[sp,#96] // offload rp and np + + ldp x6,x7,[x1,#8*0] + ldp x8,x9,[x1,#8*2] + ldp x10,x11,[x1,#8*4] + ldp x12,x13,[x1,#8*6] + + sub x2,sp,x5,lsl#4 + lsl x5,x5,#3 + ldr x4,[x4] // *n0 + mov sp,x2 // alloca + sub x27,x5,#8*8 + b Lsqr8x_zero_start + +Lsqr8x_zero: + sub x27,x27,#8*8 + stp xzr,xzr,[x2,#8*0] + stp xzr,xzr,[x2,#8*2] + stp xzr,xzr,[x2,#8*4] + stp xzr,xzr,[x2,#8*6] +Lsqr8x_zero_start: + stp xzr,xzr,[x2,#8*8] + stp xzr,xzr,[x2,#8*10] + stp xzr,xzr,[x2,#8*12] + stp xzr,xzr,[x2,#8*14] + add x2,x2,#8*16 + cbnz x27,Lsqr8x_zero + + add x3,x1,x5 + add x1,x1,#8*8 + mov x19,xzr + mov x20,xzr + mov x21,xzr + mov x22,xzr + mov x23,xzr + mov x24,xzr + mov x25,xzr + mov x26,xzr + mov x2,sp + str x4,[x29,#112] // offload n0 + + // Multiply everything but a[i]*a[i] +.align 4 +Lsqr8x_outer_loop: + // a[1]a[0] (i) + // a[2]a[0] + // a[3]a[0] + // a[4]a[0] + // a[5]a[0] + // a[6]a[0] + // a[7]a[0] + // a[2]a[1] (ii) + // a[3]a[1] + // a[4]a[1] + // a[5]a[1] + // a[6]a[1] + // a[7]a[1] + // a[3]a[2] (iii) + // a[4]a[2] + // a[5]a[2] + // a[6]a[2] + // a[7]a[2] + // a[4]a[3] (iv) + // a[5]a[3] + // a[6]a[3] + // a[7]a[3] + // a[5]a[4] (v) + // a[6]a[4] + // a[7]a[4] + // a[6]a[5] (vi) + // a[7]a[5] + // a[7]a[6] (vii) + + mul x14,x7,x6 // lo(a[1..7]*a[0]) (i) + mul x15,x8,x6 + mul x16,x9,x6 + mul x17,x10,x6 + adds x20,x20,x14 // t[1]+lo(a[1]*a[0]) + mul x14,x11,x6 + adcs x21,x21,x15 + mul x15,x12,x6 + adcs x22,x22,x16 + mul x16,x13,x6 + adcs x23,x23,x17 + umulh x17,x7,x6 // hi(a[1..7]*a[0]) + adcs x24,x24,x14 + umulh x14,x8,x6 + adcs x25,x25,x15 + umulh x15,x9,x6 + adcs x26,x26,x16 + umulh x16,x10,x6 + stp x19,x20,[x2],#8*2 // t[0..1] + adc x19,xzr,xzr // t[8] + adds x21,x21,x17 // t[2]+lo(a[1]*a[0]) + umulh x17,x11,x6 + adcs x22,x22,x14 + umulh x14,x12,x6 + adcs x23,x23,x15 + umulh x15,x13,x6 + adcs x24,x24,x16 + mul x16,x8,x7 // lo(a[2..7]*a[1]) (ii) + adcs x25,x25,x17 + mul x17,x9,x7 + adcs x26,x26,x14 + mul x14,x10,x7 + adc x19,x19,x15 + + mul x15,x11,x7 + adds x22,x22,x16 + mul x16,x12,x7 + adcs x23,x23,x17 + mul x17,x13,x7 + adcs x24,x24,x14 + umulh x14,x8,x7 // hi(a[2..7]*a[1]) + adcs x25,x25,x15 + umulh x15,x9,x7 + adcs x26,x26,x16 + umulh x16,x10,x7 + adcs x19,x19,x17 + umulh x17,x11,x7 + stp x21,x22,[x2],#8*2 // t[2..3] + adc x20,xzr,xzr // t[9] + adds x23,x23,x14 + umulh x14,x12,x7 + adcs x24,x24,x15 + umulh x15,x13,x7 + adcs x25,x25,x16 + mul x16,x9,x8 // lo(a[3..7]*a[2]) (iii) + adcs x26,x26,x17 + mul x17,x10,x8 + adcs x19,x19,x14 + mul x14,x11,x8 + adc x20,x20,x15 + + mul x15,x12,x8 + adds x24,x24,x16 + mul x16,x13,x8 + adcs x25,x25,x17 + umulh x17,x9,x8 // hi(a[3..7]*a[2]) + adcs x26,x26,x14 + umulh x14,x10,x8 + adcs x19,x19,x15 + umulh x15,x11,x8 + adcs x20,x20,x16 + umulh x16,x12,x8 + stp x23,x24,[x2],#8*2 // t[4..5] + adc x21,xzr,xzr // t[10] + adds x25,x25,x17 + umulh x17,x13,x8 + adcs x26,x26,x14 + mul x14,x10,x9 // lo(a[4..7]*a[3]) (iv) + adcs x19,x19,x15 + mul x15,x11,x9 + adcs x20,x20,x16 + mul x16,x12,x9 + adc x21,x21,x17 + + mul x17,x13,x9 + adds x26,x26,x14 + umulh x14,x10,x9 // hi(a[4..7]*a[3]) + adcs x19,x19,x15 + umulh x15,x11,x9 + adcs x20,x20,x16 + umulh x16,x12,x9 + adcs x21,x21,x17 + umulh x17,x13,x9 + stp x25,x26,[x2],#8*2 // t[6..7] + adc x22,xzr,xzr // t[11] + adds x19,x19,x14 + mul x14,x11,x10 // lo(a[5..7]*a[4]) (v) + adcs x20,x20,x15 + mul x15,x12,x10 + adcs x21,x21,x16 + mul x16,x13,x10 + adc x22,x22,x17 + + umulh x17,x11,x10 // hi(a[5..7]*a[4]) + adds x20,x20,x14 + umulh x14,x12,x10 + adcs x21,x21,x15 + umulh x15,x13,x10 + adcs x22,x22,x16 + mul x16,x12,x11 // lo(a[6..7]*a[5]) (vi) + adc x23,xzr,xzr // t[12] + adds x21,x21,x17 + mul x17,x13,x11 + adcs x22,x22,x14 + umulh x14,x12,x11 // hi(a[6..7]*a[5]) + adc x23,x23,x15 + + umulh x15,x13,x11 + adds x22,x22,x16 + mul x16,x13,x12 // lo(a[7]*a[6]) (vii) + adcs x23,x23,x17 + umulh x17,x13,x12 // hi(a[7]*a[6]) + adc x24,xzr,xzr // t[13] + adds x23,x23,x14 + sub x27,x3,x1 // done yet? + adc x24,x24,x15 + + adds x24,x24,x16 + sub x14,x3,x5 // rewinded ap + adc x25,xzr,xzr // t[14] + add x25,x25,x17 + + cbz x27,Lsqr8x_outer_break + + mov x4,x6 + ldp x6,x7,[x2,#8*0] + ldp x8,x9,[x2,#8*2] + ldp x10,x11,[x2,#8*4] + ldp x12,x13,[x2,#8*6] + adds x19,x19,x6 + adcs x20,x20,x7 + ldp x6,x7,[x1,#8*0] + adcs x21,x21,x8 + adcs x22,x22,x9 + ldp x8,x9,[x1,#8*2] + adcs x23,x23,x10 + adcs x24,x24,x11 + ldp x10,x11,[x1,#8*4] + adcs x25,x25,x12 + mov x0,x1 + adcs x26,xzr,x13 + ldp x12,x13,[x1,#8*6] + add x1,x1,#8*8 + //adc x28,xzr,xzr // moved below + mov x27,#-8*8 + + // a[8]a[0] + // a[9]a[0] + // a[a]a[0] + // a[b]a[0] + // a[c]a[0] + // a[d]a[0] + // a[e]a[0] + // a[f]a[0] + // a[8]a[1] + // a[f]a[1]........................ + // a[8]a[2] + // a[f]a[2]........................ + // a[8]a[3] + // a[f]a[3]........................ + // a[8]a[4] + // a[f]a[4]........................ + // a[8]a[5] + // a[f]a[5]........................ + // a[8]a[6] + // a[f]a[6]........................ + // a[8]a[7] + // a[f]a[7]........................ +Lsqr8x_mul: + mul x14,x6,x4 + adc x28,xzr,xzr // carry bit, modulo-scheduled + mul x15,x7,x4 + add x27,x27,#8 + mul x16,x8,x4 + mul x17,x9,x4 + adds x19,x19,x14 + mul x14,x10,x4 + adcs x20,x20,x15 + mul x15,x11,x4 + adcs x21,x21,x16 + mul x16,x12,x4 + adcs x22,x22,x17 + mul x17,x13,x4 + adcs x23,x23,x14 + umulh x14,x6,x4 + adcs x24,x24,x15 + umulh x15,x7,x4 + adcs x25,x25,x16 + umulh x16,x8,x4 + adcs x26,x26,x17 + umulh x17,x9,x4 + adc x28,x28,xzr + str x19,[x2],#8 + adds x19,x20,x14 + umulh x14,x10,x4 + adcs x20,x21,x15 + umulh x15,x11,x4 + adcs x21,x22,x16 + umulh x16,x12,x4 + adcs x22,x23,x17 + umulh x17,x13,x4 + ldr x4,[x0,x27] + adcs x23,x24,x14 + adcs x24,x25,x15 + adcs x25,x26,x16 + adcs x26,x28,x17 + //adc x28,xzr,xzr // moved above + cbnz x27,Lsqr8x_mul + // note that carry flag is guaranteed + // to be zero at this point + cmp x1,x3 // done yet? + b.eq Lsqr8x_break + + ldp x6,x7,[x2,#8*0] + ldp x8,x9,[x2,#8*2] + ldp x10,x11,[x2,#8*4] + ldp x12,x13,[x2,#8*6] + adds x19,x19,x6 + ldr x4,[x0,#-8*8] + adcs x20,x20,x7 + ldp x6,x7,[x1,#8*0] + adcs x21,x21,x8 + adcs x22,x22,x9 + ldp x8,x9,[x1,#8*2] + adcs x23,x23,x10 + adcs x24,x24,x11 + ldp x10,x11,[x1,#8*4] + adcs x25,x25,x12 + mov x27,#-8*8 + adcs x26,x26,x13 + ldp x12,x13,[x1,#8*6] + add x1,x1,#8*8 + //adc x28,xzr,xzr // moved above + b Lsqr8x_mul + +.align 4 +Lsqr8x_break: + ldp x6,x7,[x0,#8*0] + add x1,x0,#8*8 + ldp x8,x9,[x0,#8*2] + sub x14,x3,x1 // is it last iteration? + ldp x10,x11,[x0,#8*4] + sub x15,x2,x14 + ldp x12,x13,[x0,#8*6] + cbz x14,Lsqr8x_outer_loop + + stp x19,x20,[x2,#8*0] + ldp x19,x20,[x15,#8*0] + stp x21,x22,[x2,#8*2] + ldp x21,x22,[x15,#8*2] + stp x23,x24,[x2,#8*4] + ldp x23,x24,[x15,#8*4] + stp x25,x26,[x2,#8*6] + mov x2,x15 + ldp x25,x26,[x15,#8*6] + b Lsqr8x_outer_loop + +.align 4 +Lsqr8x_outer_break: + // Now multiply above result by 2 and add a[n-1]*a[n-1]|...|a[0]*a[0] + ldp x7,x9,[x14,#8*0] // recall that x14 is &a[0] + ldp x15,x16,[sp,#8*1] + ldp x11,x13,[x14,#8*2] + add x1,x14,#8*4 + ldp x17,x14,[sp,#8*3] + + stp x19,x20,[x2,#8*0] + mul x19,x7,x7 + stp x21,x22,[x2,#8*2] + umulh x7,x7,x7 + stp x23,x24,[x2,#8*4] + mul x8,x9,x9 + stp x25,x26,[x2,#8*6] + mov x2,sp + umulh x9,x9,x9 + adds x20,x7,x15,lsl#1 + extr x15,x16,x15,#63 + sub x27,x5,#8*4 + +Lsqr4x_shift_n_add: + adcs x21,x8,x15 + extr x16,x17,x16,#63 + sub x27,x27,#8*4 + adcs x22,x9,x16 + ldp x15,x16,[x2,#8*5] + mul x10,x11,x11 + ldp x7,x9,[x1],#8*2 + umulh x11,x11,x11 + mul x12,x13,x13 + umulh x13,x13,x13 + extr x17,x14,x17,#63 + stp x19,x20,[x2,#8*0] + adcs x23,x10,x17 + extr x14,x15,x14,#63 + stp x21,x22,[x2,#8*2] + adcs x24,x11,x14 + ldp x17,x14,[x2,#8*7] + extr x15,x16,x15,#63 + adcs x25,x12,x15 + extr x16,x17,x16,#63 + adcs x26,x13,x16 + ldp x15,x16,[x2,#8*9] + mul x6,x7,x7 + ldp x11,x13,[x1],#8*2 + umulh x7,x7,x7 + mul x8,x9,x9 + umulh x9,x9,x9 + stp x23,x24,[x2,#8*4] + extr x17,x14,x17,#63 + stp x25,x26,[x2,#8*6] + add x2,x2,#8*8 + adcs x19,x6,x17 + extr x14,x15,x14,#63 + adcs x20,x7,x14 + ldp x17,x14,[x2,#8*3] + extr x15,x16,x15,#63 + cbnz x27,Lsqr4x_shift_n_add + ldp x1,x4,[x29,#104] // pull np and n0 + + adcs x21,x8,x15 + extr x16,x17,x16,#63 + adcs x22,x9,x16 + ldp x15,x16,[x2,#8*5] + mul x10,x11,x11 + umulh x11,x11,x11 + stp x19,x20,[x2,#8*0] + mul x12,x13,x13 + umulh x13,x13,x13 + stp x21,x22,[x2,#8*2] + extr x17,x14,x17,#63 + adcs x23,x10,x17 + extr x14,x15,x14,#63 + ldp x19,x20,[sp,#8*0] + adcs x24,x11,x14 + extr x15,x16,x15,#63 + ldp x6,x7,[x1,#8*0] + adcs x25,x12,x15 + extr x16,xzr,x16,#63 + ldp x8,x9,[x1,#8*2] + adc x26,x13,x16 + ldp x10,x11,[x1,#8*4] + + // Reduce by 512 bits per iteration + mul x28,x4,x19 // t[0]*n0 + ldp x12,x13,[x1,#8*6] + add x3,x1,x5 + ldp x21,x22,[sp,#8*2] + stp x23,x24,[x2,#8*4] + ldp x23,x24,[sp,#8*4] + stp x25,x26,[x2,#8*6] + ldp x25,x26,[sp,#8*6] + add x1,x1,#8*8 + mov x30,xzr // initial top-most carry + mov x2,sp + mov x27,#8 + +Lsqr8x_reduction: + // (*) mul x14,x6,x28 // lo(n[0-7])*lo(t[0]*n0) + mul x15,x7,x28 + sub x27,x27,#1 + mul x16,x8,x28 + str x28,[x2],#8 // put aside t[0]*n0 for tail processing + mul x17,x9,x28 + // (*) adds xzr,x19,x14 + subs xzr,x19,#1 // (*) + mul x14,x10,x28 + adcs x19,x20,x15 + mul x15,x11,x28 + adcs x20,x21,x16 + mul x16,x12,x28 + adcs x21,x22,x17 + mul x17,x13,x28 + adcs x22,x23,x14 + umulh x14,x6,x28 // hi(n[0-7])*lo(t[0]*n0) + adcs x23,x24,x15 + umulh x15,x7,x28 + adcs x24,x25,x16 + umulh x16,x8,x28 + adcs x25,x26,x17 + umulh x17,x9,x28 + adc x26,xzr,xzr + adds x19,x19,x14 + umulh x14,x10,x28 + adcs x20,x20,x15 + umulh x15,x11,x28 + adcs x21,x21,x16 + umulh x16,x12,x28 + adcs x22,x22,x17 + umulh x17,x13,x28 + mul x28,x4,x19 // next t[0]*n0 + adcs x23,x23,x14 + adcs x24,x24,x15 + adcs x25,x25,x16 + adc x26,x26,x17 + cbnz x27,Lsqr8x_reduction + + ldp x14,x15,[x2,#8*0] + ldp x16,x17,[x2,#8*2] + mov x0,x2 + sub x27,x3,x1 // done yet? + adds x19,x19,x14 + adcs x20,x20,x15 + ldp x14,x15,[x2,#8*4] + adcs x21,x21,x16 + adcs x22,x22,x17 + ldp x16,x17,[x2,#8*6] + adcs x23,x23,x14 + adcs x24,x24,x15 + adcs x25,x25,x16 + adcs x26,x26,x17 + //adc x28,xzr,xzr // moved below + cbz x27,Lsqr8x8_post_condition + + ldr x4,[x2,#-8*8] + ldp x6,x7,[x1,#8*0] + ldp x8,x9,[x1,#8*2] + ldp x10,x11,[x1,#8*4] + mov x27,#-8*8 + ldp x12,x13,[x1,#8*6] + add x1,x1,#8*8 + +Lsqr8x_tail: + mul x14,x6,x4 + adc x28,xzr,xzr // carry bit, modulo-scheduled + mul x15,x7,x4 + add x27,x27,#8 + mul x16,x8,x4 + mul x17,x9,x4 + adds x19,x19,x14 + mul x14,x10,x4 + adcs x20,x20,x15 + mul x15,x11,x4 + adcs x21,x21,x16 + mul x16,x12,x4 + adcs x22,x22,x17 + mul x17,x13,x4 + adcs x23,x23,x14 + umulh x14,x6,x4 + adcs x24,x24,x15 + umulh x15,x7,x4 + adcs x25,x25,x16 + umulh x16,x8,x4 + adcs x26,x26,x17 + umulh x17,x9,x4 + adc x28,x28,xzr + str x19,[x2],#8 + adds x19,x20,x14 + umulh x14,x10,x4 + adcs x20,x21,x15 + umulh x15,x11,x4 + adcs x21,x22,x16 + umulh x16,x12,x4 + adcs x22,x23,x17 + umulh x17,x13,x4 + ldr x4,[x0,x27] + adcs x23,x24,x14 + adcs x24,x25,x15 + adcs x25,x26,x16 + adcs x26,x28,x17 + //adc x28,xzr,xzr // moved above + cbnz x27,Lsqr8x_tail + // note that carry flag is guaranteed + // to be zero at this point + ldp x6,x7,[x2,#8*0] + sub x27,x3,x1 // done yet? + sub x16,x3,x5 // rewinded np + ldp x8,x9,[x2,#8*2] + ldp x10,x11,[x2,#8*4] + ldp x12,x13,[x2,#8*6] + cbz x27,Lsqr8x_tail_break + + ldr x4,[x0,#-8*8] + adds x19,x19,x6 + adcs x20,x20,x7 + ldp x6,x7,[x1,#8*0] + adcs x21,x21,x8 + adcs x22,x22,x9 + ldp x8,x9,[x1,#8*2] + adcs x23,x23,x10 + adcs x24,x24,x11 + ldp x10,x11,[x1,#8*4] + adcs x25,x25,x12 + mov x27,#-8*8 + adcs x26,x26,x13 + ldp x12,x13,[x1,#8*6] + add x1,x1,#8*8 + //adc x28,xzr,xzr // moved above + b Lsqr8x_tail + +.align 4 +Lsqr8x_tail_break: + ldr x4,[x29,#112] // pull n0 + add x27,x2,#8*8 // end of current t[num] window + + subs xzr,x30,#1 // "move" top-most carry to carry bit + adcs x14,x19,x6 + adcs x15,x20,x7 + ldp x19,x20,[x0,#8*0] + adcs x21,x21,x8 + ldp x6,x7,[x16,#8*0] // recall that x16 is &n[0] + adcs x22,x22,x9 + ldp x8,x9,[x16,#8*2] + adcs x23,x23,x10 + adcs x24,x24,x11 + ldp x10,x11,[x16,#8*4] + adcs x25,x25,x12 + adcs x26,x26,x13 + ldp x12,x13,[x16,#8*6] + add x1,x16,#8*8 + adc x30,xzr,xzr // top-most carry + mul x28,x4,x19 + stp x14,x15,[x2,#8*0] + stp x21,x22,[x2,#8*2] + ldp x21,x22,[x0,#8*2] + stp x23,x24,[x2,#8*4] + ldp x23,x24,[x0,#8*4] + cmp x27,x29 // did we hit the bottom? + stp x25,x26,[x2,#8*6] + mov x2,x0 // slide the window + ldp x25,x26,[x0,#8*6] + mov x27,#8 + b.ne Lsqr8x_reduction + + // Final step. We see if result is larger than modulus, and + // if it is, subtract the modulus. But comparison implies + // subtraction. So we subtract modulus, see if it borrowed, + // and conditionally copy original value. + ldr x0,[x29,#96] // pull rp + add x2,x2,#8*8 + subs x14,x19,x6 + sbcs x15,x20,x7 + sub x27,x5,#8*8 + mov x3,x0 // x0 copy + +Lsqr8x_sub: + sbcs x16,x21,x8 + ldp x6,x7,[x1,#8*0] + sbcs x17,x22,x9 + stp x14,x15,[x0,#8*0] + sbcs x14,x23,x10 + ldp x8,x9,[x1,#8*2] + sbcs x15,x24,x11 + stp x16,x17,[x0,#8*2] + sbcs x16,x25,x12 + ldp x10,x11,[x1,#8*4] + sbcs x17,x26,x13 + ldp x12,x13,[x1,#8*6] + add x1,x1,#8*8 + ldp x19,x20,[x2,#8*0] + sub x27,x27,#8*8 + ldp x21,x22,[x2,#8*2] + ldp x23,x24,[x2,#8*4] + ldp x25,x26,[x2,#8*6] + add x2,x2,#8*8 + stp x14,x15,[x0,#8*4] + sbcs x14,x19,x6 + stp x16,x17,[x0,#8*6] + add x0,x0,#8*8 + sbcs x15,x20,x7 + cbnz x27,Lsqr8x_sub + + sbcs x16,x21,x8 + mov x2,sp + add x1,sp,x5 + ldp x6,x7,[x3,#8*0] + sbcs x17,x22,x9 + stp x14,x15,[x0,#8*0] + sbcs x14,x23,x10 + ldp x8,x9,[x3,#8*2] + sbcs x15,x24,x11 + stp x16,x17,[x0,#8*2] + sbcs x16,x25,x12 + ldp x19,x20,[x1,#8*0] + sbcs x17,x26,x13 + ldp x21,x22,[x1,#8*2] + sbcs xzr,x30,xzr // did it borrow? + ldr x30,[x29,#8] // pull return address + stp x14,x15,[x0,#8*4] + stp x16,x17,[x0,#8*6] + + sub x27,x5,#8*4 +Lsqr4x_cond_copy: + sub x27,x27,#8*4 + csel x14,x19,x6,lo + stp xzr,xzr,[x2,#8*0] + csel x15,x20,x7,lo + ldp x6,x7,[x3,#8*4] + ldp x19,x20,[x1,#8*4] + csel x16,x21,x8,lo + stp xzr,xzr,[x2,#8*2] + add x2,x2,#8*4 + csel x17,x22,x9,lo + ldp x8,x9,[x3,#8*6] + ldp x21,x22,[x1,#8*6] + add x1,x1,#8*4 + stp x14,x15,[x3,#8*0] + stp x16,x17,[x3,#8*2] + add x3,x3,#8*4 + stp xzr,xzr,[x1,#8*0] + stp xzr,xzr,[x1,#8*2] + cbnz x27,Lsqr4x_cond_copy + + csel x14,x19,x6,lo + stp xzr,xzr,[x2,#8*0] + csel x15,x20,x7,lo + stp xzr,xzr,[x2,#8*2] + csel x16,x21,x8,lo + csel x17,x22,x9,lo + stp x14,x15,[x3,#8*0] + stp x16,x17,[x3,#8*2] + + b Lsqr8x_done + +.align 4 +Lsqr8x8_post_condition: + adc x28,xzr,xzr + ldr x30,[x29,#8] // pull return address + // x19-7,x28 hold result, x6-7 hold modulus + subs x6,x19,x6 + ldr x1,[x29,#96] // pull rp + sbcs x7,x20,x7 + stp xzr,xzr,[sp,#8*0] + sbcs x8,x21,x8 + stp xzr,xzr,[sp,#8*2] + sbcs x9,x22,x9 + stp xzr,xzr,[sp,#8*4] + sbcs x10,x23,x10 + stp xzr,xzr,[sp,#8*6] + sbcs x11,x24,x11 + stp xzr,xzr,[sp,#8*8] + sbcs x12,x25,x12 + stp xzr,xzr,[sp,#8*10] + sbcs x13,x26,x13 + stp xzr,xzr,[sp,#8*12] + sbcs x28,x28,xzr // did it borrow? + stp xzr,xzr,[sp,#8*14] + + // x6-7 hold result-modulus + csel x6,x19,x6,lo + csel x7,x20,x7,lo + csel x8,x21,x8,lo + csel x9,x22,x9,lo + stp x6,x7,[x1,#8*0] + csel x10,x23,x10,lo + csel x11,x24,x11,lo + stp x8,x9,[x1,#8*2] + csel x12,x25,x12,lo + csel x13,x26,x13,lo + stp x10,x11,[x1,#8*4] + stp x12,x13,[x1,#8*6] + +Lsqr8x_done: + ldp x19,x20,[x29,#16] + mov sp,x29 + ldp x21,x22,[x29,#32] + mov x0,#1 + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldr x29,[sp],#128 + // x30 is popped earlier + AARCH64_VALIDATE_LINK_REGISTER + ret + +.globl _bn_mul4x_mont +.private_extern _bn_mul4x_mont + +.align 5 +_bn_mul4x_mont: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-128]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + stp x27,x28,[sp,#80] + + sub x26,sp,x5,lsl#3 + lsl x5,x5,#3 + ldr x4,[x4] // *n0 + sub sp,x26,#8*4 // alloca + + add x10,x2,x5 + add x27,x1,x5 + stp x0,x10,[x29,#96] // offload rp and &b[num] + + ldr x24,[x2,#8*0] // b[0] + ldp x6,x7,[x1,#8*0] // a[0..3] + ldp x8,x9,[x1,#8*2] + add x1,x1,#8*4 + mov x19,xzr + mov x20,xzr + mov x21,xzr + mov x22,xzr + ldp x14,x15,[x3,#8*0] // n[0..3] + ldp x16,x17,[x3,#8*2] + adds x3,x3,#8*4 // clear carry bit + mov x0,xzr + mov x28,#0 + mov x26,sp + +Loop_mul4x_1st_reduction: + mul x10,x6,x24 // lo(a[0..3]*b[0]) + adc x0,x0,xzr // modulo-scheduled + mul x11,x7,x24 + add x28,x28,#8 + mul x12,x8,x24 + and x28,x28,#31 + mul x13,x9,x24 + adds x19,x19,x10 + umulh x10,x6,x24 // hi(a[0..3]*b[0]) + adcs x20,x20,x11 + mul x25,x19,x4 // t[0]*n0 + adcs x21,x21,x12 + umulh x11,x7,x24 + adcs x22,x22,x13 + umulh x12,x8,x24 + adc x23,xzr,xzr + umulh x13,x9,x24 + ldr x24,[x2,x28] // next b[i] (or b[0]) + adds x20,x20,x10 + // (*) mul x10,x14,x25 // lo(n[0..3]*t[0]*n0) + str x25,[x26],#8 // put aside t[0]*n0 for tail processing + adcs x21,x21,x11 + mul x11,x15,x25 + adcs x22,x22,x12 + mul x12,x16,x25 + adc x23,x23,x13 // can't overflow + mul x13,x17,x25 + // (*) adds xzr,x19,x10 + subs xzr,x19,#1 // (*) + umulh x10,x14,x25 // hi(n[0..3]*t[0]*n0) + adcs x19,x20,x11 + umulh x11,x15,x25 + adcs x20,x21,x12 + umulh x12,x16,x25 + adcs x21,x22,x13 + umulh x13,x17,x25 + adcs x22,x23,x0 + adc x0,xzr,xzr + adds x19,x19,x10 + sub x10,x27,x1 + adcs x20,x20,x11 + adcs x21,x21,x12 + adcs x22,x22,x13 + //adc x0,x0,xzr + cbnz x28,Loop_mul4x_1st_reduction + + cbz x10,Lmul4x4_post_condition + + ldp x6,x7,[x1,#8*0] // a[4..7] + ldp x8,x9,[x1,#8*2] + add x1,x1,#8*4 + ldr x25,[sp] // a[0]*n0 + ldp x14,x15,[x3,#8*0] // n[4..7] + ldp x16,x17,[x3,#8*2] + add x3,x3,#8*4 + +Loop_mul4x_1st_tail: + mul x10,x6,x24 // lo(a[4..7]*b[i]) + adc x0,x0,xzr // modulo-scheduled + mul x11,x7,x24 + add x28,x28,#8 + mul x12,x8,x24 + and x28,x28,#31 + mul x13,x9,x24 + adds x19,x19,x10 + umulh x10,x6,x24 // hi(a[4..7]*b[i]) + adcs x20,x20,x11 + umulh x11,x7,x24 + adcs x21,x21,x12 + umulh x12,x8,x24 + adcs x22,x22,x13 + umulh x13,x9,x24 + adc x23,xzr,xzr + ldr x24,[x2,x28] // next b[i] (or b[0]) + adds x20,x20,x10 + mul x10,x14,x25 // lo(n[4..7]*a[0]*n0) + adcs x21,x21,x11 + mul x11,x15,x25 + adcs x22,x22,x12 + mul x12,x16,x25 + adc x23,x23,x13 // can't overflow + mul x13,x17,x25 + adds x19,x19,x10 + umulh x10,x14,x25 // hi(n[4..7]*a[0]*n0) + adcs x20,x20,x11 + umulh x11,x15,x25 + adcs x21,x21,x12 + umulh x12,x16,x25 + adcs x22,x22,x13 + adcs x23,x23,x0 + umulh x13,x17,x25 + adc x0,xzr,xzr + ldr x25,[sp,x28] // next t[0]*n0 + str x19,[x26],#8 // result!!! + adds x19,x20,x10 + sub x10,x27,x1 // done yet? + adcs x20,x21,x11 + adcs x21,x22,x12 + adcs x22,x23,x13 + //adc x0,x0,xzr + cbnz x28,Loop_mul4x_1st_tail + + sub x11,x27,x5 // rewinded x1 + cbz x10,Lmul4x_proceed + + ldp x6,x7,[x1,#8*0] + ldp x8,x9,[x1,#8*2] + add x1,x1,#8*4 + ldp x14,x15,[x3,#8*0] + ldp x16,x17,[x3,#8*2] + add x3,x3,#8*4 + b Loop_mul4x_1st_tail + +.align 5 +Lmul4x_proceed: + ldr x24,[x2,#8*4]! // *++b + adc x30,x0,xzr + ldp x6,x7,[x11,#8*0] // a[0..3] + sub x3,x3,x5 // rewind np + ldp x8,x9,[x11,#8*2] + add x1,x11,#8*4 + + stp x19,x20,[x26,#8*0] // result!!! + ldp x19,x20,[sp,#8*4] // t[0..3] + stp x21,x22,[x26,#8*2] // result!!! + ldp x21,x22,[sp,#8*6] + + ldp x14,x15,[x3,#8*0] // n[0..3] + mov x26,sp + ldp x16,x17,[x3,#8*2] + adds x3,x3,#8*4 // clear carry bit + mov x0,xzr + +.align 4 +Loop_mul4x_reduction: + mul x10,x6,x24 // lo(a[0..3]*b[4]) + adc x0,x0,xzr // modulo-scheduled + mul x11,x7,x24 + add x28,x28,#8 + mul x12,x8,x24 + and x28,x28,#31 + mul x13,x9,x24 + adds x19,x19,x10 + umulh x10,x6,x24 // hi(a[0..3]*b[4]) + adcs x20,x20,x11 + mul x25,x19,x4 // t[0]*n0 + adcs x21,x21,x12 + umulh x11,x7,x24 + adcs x22,x22,x13 + umulh x12,x8,x24 + adc x23,xzr,xzr + umulh x13,x9,x24 + ldr x24,[x2,x28] // next b[i] + adds x20,x20,x10 + // (*) mul x10,x14,x25 + str x25,[x26],#8 // put aside t[0]*n0 for tail processing + adcs x21,x21,x11 + mul x11,x15,x25 // lo(n[0..3]*t[0]*n0 + adcs x22,x22,x12 + mul x12,x16,x25 + adc x23,x23,x13 // can't overflow + mul x13,x17,x25 + // (*) adds xzr,x19,x10 + subs xzr,x19,#1 // (*) + umulh x10,x14,x25 // hi(n[0..3]*t[0]*n0 + adcs x19,x20,x11 + umulh x11,x15,x25 + adcs x20,x21,x12 + umulh x12,x16,x25 + adcs x21,x22,x13 + umulh x13,x17,x25 + adcs x22,x23,x0 + adc x0,xzr,xzr + adds x19,x19,x10 + adcs x20,x20,x11 + adcs x21,x21,x12 + adcs x22,x22,x13 + //adc x0,x0,xzr + cbnz x28,Loop_mul4x_reduction + + adc x0,x0,xzr + ldp x10,x11,[x26,#8*4] // t[4..7] + ldp x12,x13,[x26,#8*6] + ldp x6,x7,[x1,#8*0] // a[4..7] + ldp x8,x9,[x1,#8*2] + add x1,x1,#8*4 + adds x19,x19,x10 + adcs x20,x20,x11 + adcs x21,x21,x12 + adcs x22,x22,x13 + //adc x0,x0,xzr + + ldr x25,[sp] // t[0]*n0 + ldp x14,x15,[x3,#8*0] // n[4..7] + ldp x16,x17,[x3,#8*2] + add x3,x3,#8*4 + +.align 4 +Loop_mul4x_tail: + mul x10,x6,x24 // lo(a[4..7]*b[4]) + adc x0,x0,xzr // modulo-scheduled + mul x11,x7,x24 + add x28,x28,#8 + mul x12,x8,x24 + and x28,x28,#31 + mul x13,x9,x24 + adds x19,x19,x10 + umulh x10,x6,x24 // hi(a[4..7]*b[4]) + adcs x20,x20,x11 + umulh x11,x7,x24 + adcs x21,x21,x12 + umulh x12,x8,x24 + adcs x22,x22,x13 + umulh x13,x9,x24 + adc x23,xzr,xzr + ldr x24,[x2,x28] // next b[i] + adds x20,x20,x10 + mul x10,x14,x25 // lo(n[4..7]*t[0]*n0) + adcs x21,x21,x11 + mul x11,x15,x25 + adcs x22,x22,x12 + mul x12,x16,x25 + adc x23,x23,x13 // can't overflow + mul x13,x17,x25 + adds x19,x19,x10 + umulh x10,x14,x25 // hi(n[4..7]*t[0]*n0) + adcs x20,x20,x11 + umulh x11,x15,x25 + adcs x21,x21,x12 + umulh x12,x16,x25 + adcs x22,x22,x13 + umulh x13,x17,x25 + adcs x23,x23,x0 + ldr x25,[sp,x28] // next a[0]*n0 + adc x0,xzr,xzr + str x19,[x26],#8 // result!!! + adds x19,x20,x10 + sub x10,x27,x1 // done yet? + adcs x20,x21,x11 + adcs x21,x22,x12 + adcs x22,x23,x13 + //adc x0,x0,xzr + cbnz x28,Loop_mul4x_tail + + sub x11,x3,x5 // rewinded np? + adc x0,x0,xzr + cbz x10,Loop_mul4x_break + + ldp x10,x11,[x26,#8*4] + ldp x12,x13,[x26,#8*6] + ldp x6,x7,[x1,#8*0] + ldp x8,x9,[x1,#8*2] + add x1,x1,#8*4 + adds x19,x19,x10 + adcs x20,x20,x11 + adcs x21,x21,x12 + adcs x22,x22,x13 + //adc x0,x0,xzr + ldp x14,x15,[x3,#8*0] + ldp x16,x17,[x3,#8*2] + add x3,x3,#8*4 + b Loop_mul4x_tail + +.align 4 +Loop_mul4x_break: + ldp x12,x13,[x29,#96] // pull rp and &b[num] + adds x19,x19,x30 + add x2,x2,#8*4 // bp++ + adcs x20,x20,xzr + sub x1,x1,x5 // rewind ap + adcs x21,x21,xzr + stp x19,x20,[x26,#8*0] // result!!! + adcs x22,x22,xzr + ldp x19,x20,[sp,#8*4] // t[0..3] + adc x30,x0,xzr + stp x21,x22,[x26,#8*2] // result!!! + cmp x2,x13 // done yet? + ldp x21,x22,[sp,#8*6] + ldp x14,x15,[x11,#8*0] // n[0..3] + ldp x16,x17,[x11,#8*2] + add x3,x11,#8*4 + b.eq Lmul4x_post + + ldr x24,[x2] + ldp x6,x7,[x1,#8*0] // a[0..3] + ldp x8,x9,[x1,#8*2] + adds x1,x1,#8*4 // clear carry bit + mov x0,xzr + mov x26,sp + b Loop_mul4x_reduction + +.align 4 +Lmul4x_post: + // Final step. We see if result is larger than modulus, and + // if it is, subtract the modulus. But comparison implies + // subtraction. So we subtract modulus, see if it borrowed, + // and conditionally copy original value. + mov x0,x12 + mov x27,x12 // x0 copy + subs x10,x19,x14 + add x26,sp,#8*8 + sbcs x11,x20,x15 + sub x28,x5,#8*4 + +Lmul4x_sub: + sbcs x12,x21,x16 + ldp x14,x15,[x3,#8*0] + sub x28,x28,#8*4 + ldp x19,x20,[x26,#8*0] + sbcs x13,x22,x17 + ldp x16,x17,[x3,#8*2] + add x3,x3,#8*4 + ldp x21,x22,[x26,#8*2] + add x26,x26,#8*4 + stp x10,x11,[x0,#8*0] + sbcs x10,x19,x14 + stp x12,x13,[x0,#8*2] + add x0,x0,#8*4 + sbcs x11,x20,x15 + cbnz x28,Lmul4x_sub + + sbcs x12,x21,x16 + mov x26,sp + add x1,sp,#8*4 + ldp x6,x7,[x27,#8*0] + sbcs x13,x22,x17 + stp x10,x11,[x0,#8*0] + ldp x8,x9,[x27,#8*2] + stp x12,x13,[x0,#8*2] + ldp x19,x20,[x1,#8*0] + ldp x21,x22,[x1,#8*2] + sbcs xzr,x30,xzr // did it borrow? + ldr x30,[x29,#8] // pull return address + + sub x28,x5,#8*4 +Lmul4x_cond_copy: + sub x28,x28,#8*4 + csel x10,x19,x6,lo + stp xzr,xzr,[x26,#8*0] + csel x11,x20,x7,lo + ldp x6,x7,[x27,#8*4] + ldp x19,x20,[x1,#8*4] + csel x12,x21,x8,lo + stp xzr,xzr,[x26,#8*2] + add x26,x26,#8*4 + csel x13,x22,x9,lo + ldp x8,x9,[x27,#8*6] + ldp x21,x22,[x1,#8*6] + add x1,x1,#8*4 + stp x10,x11,[x27,#8*0] + stp x12,x13,[x27,#8*2] + add x27,x27,#8*4 + cbnz x28,Lmul4x_cond_copy + + csel x10,x19,x6,lo + stp xzr,xzr,[x26,#8*0] + csel x11,x20,x7,lo + stp xzr,xzr,[x26,#8*2] + csel x12,x21,x8,lo + stp xzr,xzr,[x26,#8*3] + csel x13,x22,x9,lo + stp xzr,xzr,[x26,#8*4] + stp x10,x11,[x27,#8*0] + stp x12,x13,[x27,#8*2] + + b Lmul4x_done + +.align 4 +Lmul4x4_post_condition: + adc x0,x0,xzr + ldr x1,[x29,#96] // pull rp + // x19-3,x0 hold result, x14-7 hold modulus + subs x6,x19,x14 + ldr x30,[x29,#8] // pull return address + sbcs x7,x20,x15 + stp xzr,xzr,[sp,#8*0] + sbcs x8,x21,x16 + stp xzr,xzr,[sp,#8*2] + sbcs x9,x22,x17 + stp xzr,xzr,[sp,#8*4] + sbcs xzr,x0,xzr // did it borrow? + stp xzr,xzr,[sp,#8*6] + + // x6-3 hold result-modulus + csel x6,x19,x6,lo + csel x7,x20,x7,lo + csel x8,x21,x8,lo + csel x9,x22,x9,lo + stp x6,x7,[x1,#8*0] + stp x8,x9,[x1,#8*2] + +Lmul4x_done: + ldp x19,x20,[x29,#16] + mov sp,x29 + ldp x21,x22,[x29,#32] + mov x0,#1 + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldr x29,[sp],#128 + // x30 is popped earlier + AARCH64_VALIDATE_LINK_REGISTER + ret + +.byte 77,111,110,116,103,111,109,101,114,121,32,77,117,108,116,105,112,108,105,99,97,116,105,111,110,32,102,111,114,32,65,82,77,118,56,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.align 2 +.align 4 +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__APPLE__) diff --git a/http/vendor/ring/pregenerated/armv8-mont-linux64.S b/http/vendor/ring/pregenerated/armv8-mont-linux64.S new file mode 100644 index 0000000..4e8a5c2 --- /dev/null +++ b/http/vendor/ring/pregenerated/armv8-mont-linux64.S @@ -0,0 +1,1416 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__ELF__) +.text + +.globl bn_mul_mont_nohw +.hidden bn_mul_mont_nohw +.type bn_mul_mont_nohw,%function +.align 5 +bn_mul_mont_nohw: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-64]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + + ldr x9,[x2],#8 // bp[0] + sub x22,sp,x5,lsl#3 + ldp x7,x8,[x1],#16 // ap[0..1] + lsl x5,x5,#3 + ldr x4,[x4] // *n0 + and x22,x22,#-16 // ABI says so + ldp x13,x14,[x3],#16 // np[0..1] + + mul x6,x7,x9 // ap[0]*bp[0] + sub x21,x5,#16 // j=num-2 + umulh x7,x7,x9 + mul x10,x8,x9 // ap[1]*bp[0] + umulh x11,x8,x9 + + mul x15,x6,x4 // "tp[0]"*n0 + mov sp,x22 // alloca + + // (*) mul x12,x13,x15 // np[0]*m1 + umulh x13,x13,x15 + mul x16,x14,x15 // np[1]*m1 + // (*) adds x12,x12,x6 // discarded + // (*) As for removal of first multiplication and addition + // instructions. The outcome of first addition is + // guaranteed to be zero, which leaves two computationally + // significant outcomes: it either carries or not. Then + // question is when does it carry? Is there alternative + // way to deduce it? If you follow operations, you can + // observe that condition for carry is quite simple: + // x6 being non-zero. So that carry can be calculated + // by adding -1 to x6. That's what next instruction does. + subs xzr,x6,#1 // (*) + umulh x17,x14,x15 + adc x13,x13,xzr + cbz x21,.L1st_skip + +.L1st: + ldr x8,[x1],#8 + adds x6,x10,x7 + sub x21,x21,#8 // j-- + adc x7,x11,xzr + + ldr x14,[x3],#8 + adds x12,x16,x13 + mul x10,x8,x9 // ap[j]*bp[0] + adc x13,x17,xzr + umulh x11,x8,x9 + + adds x12,x12,x6 + mul x16,x14,x15 // np[j]*m1 + adc x13,x13,xzr + umulh x17,x14,x15 + str x12,[x22],#8 // tp[j-1] + cbnz x21,.L1st + +.L1st_skip: + adds x6,x10,x7 + sub x1,x1,x5 // rewind x1 + adc x7,x11,xzr + + adds x12,x16,x13 + sub x3,x3,x5 // rewind x3 + adc x13,x17,xzr + + adds x12,x12,x6 + sub x20,x5,#8 // i=num-1 + adcs x13,x13,x7 + + adc x19,xzr,xzr // upmost overflow bit + stp x12,x13,[x22] + +.Louter: + ldr x9,[x2],#8 // bp[i] + ldp x7,x8,[x1],#16 + ldr x23,[sp] // tp[0] + add x22,sp,#8 + + mul x6,x7,x9 // ap[0]*bp[i] + sub x21,x5,#16 // j=num-2 + umulh x7,x7,x9 + ldp x13,x14,[x3],#16 + mul x10,x8,x9 // ap[1]*bp[i] + adds x6,x6,x23 + umulh x11,x8,x9 + adc x7,x7,xzr + + mul x15,x6,x4 + sub x20,x20,#8 // i-- + + // (*) mul x12,x13,x15 // np[0]*m1 + umulh x13,x13,x15 + mul x16,x14,x15 // np[1]*m1 + // (*) adds x12,x12,x6 + subs xzr,x6,#1 // (*) + umulh x17,x14,x15 + cbz x21,.Linner_skip + +.Linner: + ldr x8,[x1],#8 + adc x13,x13,xzr + ldr x23,[x22],#8 // tp[j] + adds x6,x10,x7 + sub x21,x21,#8 // j-- + adc x7,x11,xzr + + adds x12,x16,x13 + ldr x14,[x3],#8 + adc x13,x17,xzr + + mul x10,x8,x9 // ap[j]*bp[i] + adds x6,x6,x23 + umulh x11,x8,x9 + adc x7,x7,xzr + + mul x16,x14,x15 // np[j]*m1 + adds x12,x12,x6 + umulh x17,x14,x15 + str x12,[x22,#-16] // tp[j-1] + cbnz x21,.Linner + +.Linner_skip: + ldr x23,[x22],#8 // tp[j] + adc x13,x13,xzr + adds x6,x10,x7 + sub x1,x1,x5 // rewind x1 + adc x7,x11,xzr + + adds x12,x16,x13 + sub x3,x3,x5 // rewind x3 + adcs x13,x17,x19 + adc x19,xzr,xzr + + adds x6,x6,x23 + adc x7,x7,xzr + + adds x12,x12,x6 + adcs x13,x13,x7 + adc x19,x19,xzr // upmost overflow bit + stp x12,x13,[x22,#-16] + + cbnz x20,.Louter + + // Final step. We see if result is larger than modulus, and + // if it is, subtract the modulus. But comparison implies + // subtraction. So we subtract modulus, see if it borrowed, + // and conditionally copy original value. + ldr x23,[sp] // tp[0] + add x22,sp,#8 + ldr x14,[x3],#8 // np[0] + subs x21,x5,#8 // j=num-1 and clear borrow + mov x1,x0 +.Lsub: + sbcs x8,x23,x14 // tp[j]-np[j] + ldr x23,[x22],#8 + sub x21,x21,#8 // j-- + ldr x14,[x3],#8 + str x8,[x1],#8 // rp[j]=tp[j]-np[j] + cbnz x21,.Lsub + + sbcs x8,x23,x14 + sbcs x19,x19,xzr // did it borrow? + str x8,[x1],#8 // rp[num-1] + + ldr x23,[sp] // tp[0] + add x22,sp,#8 + ldr x8,[x0],#8 // rp[0] + sub x5,x5,#8 // num-- + nop +.Lcond_copy: + sub x5,x5,#8 // num-- + csel x14,x23,x8,lo // did it borrow? + ldr x23,[x22],#8 + ldr x8,[x0],#8 + str xzr,[x22,#-16] // wipe tp + str x14,[x0,#-16] + cbnz x5,.Lcond_copy + + csel x14,x23,x8,lo + str xzr,[x22,#-8] // wipe tp + str x14,[x0,#-8] + + ldp x19,x20,[x29,#16] + mov sp,x29 + ldp x21,x22,[x29,#32] + mov x0,#1 + ldp x23,x24,[x29,#48] + ldr x29,[sp],#64 + AARCH64_VALIDATE_LINK_REGISTER + ret +.size bn_mul_mont_nohw,.-bn_mul_mont_nohw +.globl bn_sqr8x_mont +.hidden bn_sqr8x_mont +.type bn_sqr8x_mont,%function +.align 5 +bn_sqr8x_mont: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-128]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + stp x27,x28,[sp,#80] + stp x0,x3,[sp,#96] // offload rp and np + + ldp x6,x7,[x1,#8*0] + ldp x8,x9,[x1,#8*2] + ldp x10,x11,[x1,#8*4] + ldp x12,x13,[x1,#8*6] + + sub x2,sp,x5,lsl#4 + lsl x5,x5,#3 + ldr x4,[x4] // *n0 + mov sp,x2 // alloca + sub x27,x5,#8*8 + b .Lsqr8x_zero_start + +.Lsqr8x_zero: + sub x27,x27,#8*8 + stp xzr,xzr,[x2,#8*0] + stp xzr,xzr,[x2,#8*2] + stp xzr,xzr,[x2,#8*4] + stp xzr,xzr,[x2,#8*6] +.Lsqr8x_zero_start: + stp xzr,xzr,[x2,#8*8] + stp xzr,xzr,[x2,#8*10] + stp xzr,xzr,[x2,#8*12] + stp xzr,xzr,[x2,#8*14] + add x2,x2,#8*16 + cbnz x27,.Lsqr8x_zero + + add x3,x1,x5 + add x1,x1,#8*8 + mov x19,xzr + mov x20,xzr + mov x21,xzr + mov x22,xzr + mov x23,xzr + mov x24,xzr + mov x25,xzr + mov x26,xzr + mov x2,sp + str x4,[x29,#112] // offload n0 + + // Multiply everything but a[i]*a[i] +.align 4 +.Lsqr8x_outer_loop: + // a[1]a[0] (i) + // a[2]a[0] + // a[3]a[0] + // a[4]a[0] + // a[5]a[0] + // a[6]a[0] + // a[7]a[0] + // a[2]a[1] (ii) + // a[3]a[1] + // a[4]a[1] + // a[5]a[1] + // a[6]a[1] + // a[7]a[1] + // a[3]a[2] (iii) + // a[4]a[2] + // a[5]a[2] + // a[6]a[2] + // a[7]a[2] + // a[4]a[3] (iv) + // a[5]a[3] + // a[6]a[3] + // a[7]a[3] + // a[5]a[4] (v) + // a[6]a[4] + // a[7]a[4] + // a[6]a[5] (vi) + // a[7]a[5] + // a[7]a[6] (vii) + + mul x14,x7,x6 // lo(a[1..7]*a[0]) (i) + mul x15,x8,x6 + mul x16,x9,x6 + mul x17,x10,x6 + adds x20,x20,x14 // t[1]+lo(a[1]*a[0]) + mul x14,x11,x6 + adcs x21,x21,x15 + mul x15,x12,x6 + adcs x22,x22,x16 + mul x16,x13,x6 + adcs x23,x23,x17 + umulh x17,x7,x6 // hi(a[1..7]*a[0]) + adcs x24,x24,x14 + umulh x14,x8,x6 + adcs x25,x25,x15 + umulh x15,x9,x6 + adcs x26,x26,x16 + umulh x16,x10,x6 + stp x19,x20,[x2],#8*2 // t[0..1] + adc x19,xzr,xzr // t[8] + adds x21,x21,x17 // t[2]+lo(a[1]*a[0]) + umulh x17,x11,x6 + adcs x22,x22,x14 + umulh x14,x12,x6 + adcs x23,x23,x15 + umulh x15,x13,x6 + adcs x24,x24,x16 + mul x16,x8,x7 // lo(a[2..7]*a[1]) (ii) + adcs x25,x25,x17 + mul x17,x9,x7 + adcs x26,x26,x14 + mul x14,x10,x7 + adc x19,x19,x15 + + mul x15,x11,x7 + adds x22,x22,x16 + mul x16,x12,x7 + adcs x23,x23,x17 + mul x17,x13,x7 + adcs x24,x24,x14 + umulh x14,x8,x7 // hi(a[2..7]*a[1]) + adcs x25,x25,x15 + umulh x15,x9,x7 + adcs x26,x26,x16 + umulh x16,x10,x7 + adcs x19,x19,x17 + umulh x17,x11,x7 + stp x21,x22,[x2],#8*2 // t[2..3] + adc x20,xzr,xzr // t[9] + adds x23,x23,x14 + umulh x14,x12,x7 + adcs x24,x24,x15 + umulh x15,x13,x7 + adcs x25,x25,x16 + mul x16,x9,x8 // lo(a[3..7]*a[2]) (iii) + adcs x26,x26,x17 + mul x17,x10,x8 + adcs x19,x19,x14 + mul x14,x11,x8 + adc x20,x20,x15 + + mul x15,x12,x8 + adds x24,x24,x16 + mul x16,x13,x8 + adcs x25,x25,x17 + umulh x17,x9,x8 // hi(a[3..7]*a[2]) + adcs x26,x26,x14 + umulh x14,x10,x8 + adcs x19,x19,x15 + umulh x15,x11,x8 + adcs x20,x20,x16 + umulh x16,x12,x8 + stp x23,x24,[x2],#8*2 // t[4..5] + adc x21,xzr,xzr // t[10] + adds x25,x25,x17 + umulh x17,x13,x8 + adcs x26,x26,x14 + mul x14,x10,x9 // lo(a[4..7]*a[3]) (iv) + adcs x19,x19,x15 + mul x15,x11,x9 + adcs x20,x20,x16 + mul x16,x12,x9 + adc x21,x21,x17 + + mul x17,x13,x9 + adds x26,x26,x14 + umulh x14,x10,x9 // hi(a[4..7]*a[3]) + adcs x19,x19,x15 + umulh x15,x11,x9 + adcs x20,x20,x16 + umulh x16,x12,x9 + adcs x21,x21,x17 + umulh x17,x13,x9 + stp x25,x26,[x2],#8*2 // t[6..7] + adc x22,xzr,xzr // t[11] + adds x19,x19,x14 + mul x14,x11,x10 // lo(a[5..7]*a[4]) (v) + adcs x20,x20,x15 + mul x15,x12,x10 + adcs x21,x21,x16 + mul x16,x13,x10 + adc x22,x22,x17 + + umulh x17,x11,x10 // hi(a[5..7]*a[4]) + adds x20,x20,x14 + umulh x14,x12,x10 + adcs x21,x21,x15 + umulh x15,x13,x10 + adcs x22,x22,x16 + mul x16,x12,x11 // lo(a[6..7]*a[5]) (vi) + adc x23,xzr,xzr // t[12] + adds x21,x21,x17 + mul x17,x13,x11 + adcs x22,x22,x14 + umulh x14,x12,x11 // hi(a[6..7]*a[5]) + adc x23,x23,x15 + + umulh x15,x13,x11 + adds x22,x22,x16 + mul x16,x13,x12 // lo(a[7]*a[6]) (vii) + adcs x23,x23,x17 + umulh x17,x13,x12 // hi(a[7]*a[6]) + adc x24,xzr,xzr // t[13] + adds x23,x23,x14 + sub x27,x3,x1 // done yet? + adc x24,x24,x15 + + adds x24,x24,x16 + sub x14,x3,x5 // rewinded ap + adc x25,xzr,xzr // t[14] + add x25,x25,x17 + + cbz x27,.Lsqr8x_outer_break + + mov x4,x6 + ldp x6,x7,[x2,#8*0] + ldp x8,x9,[x2,#8*2] + ldp x10,x11,[x2,#8*4] + ldp x12,x13,[x2,#8*6] + adds x19,x19,x6 + adcs x20,x20,x7 + ldp x6,x7,[x1,#8*0] + adcs x21,x21,x8 + adcs x22,x22,x9 + ldp x8,x9,[x1,#8*2] + adcs x23,x23,x10 + adcs x24,x24,x11 + ldp x10,x11,[x1,#8*4] + adcs x25,x25,x12 + mov x0,x1 + adcs x26,xzr,x13 + ldp x12,x13,[x1,#8*6] + add x1,x1,#8*8 + //adc x28,xzr,xzr // moved below + mov x27,#-8*8 + + // a[8]a[0] + // a[9]a[0] + // a[a]a[0] + // a[b]a[0] + // a[c]a[0] + // a[d]a[0] + // a[e]a[0] + // a[f]a[0] + // a[8]a[1] + // a[f]a[1]........................ + // a[8]a[2] + // a[f]a[2]........................ + // a[8]a[3] + // a[f]a[3]........................ + // a[8]a[4] + // a[f]a[4]........................ + // a[8]a[5] + // a[f]a[5]........................ + // a[8]a[6] + // a[f]a[6]........................ + // a[8]a[7] + // a[f]a[7]........................ +.Lsqr8x_mul: + mul x14,x6,x4 + adc x28,xzr,xzr // carry bit, modulo-scheduled + mul x15,x7,x4 + add x27,x27,#8 + mul x16,x8,x4 + mul x17,x9,x4 + adds x19,x19,x14 + mul x14,x10,x4 + adcs x20,x20,x15 + mul x15,x11,x4 + adcs x21,x21,x16 + mul x16,x12,x4 + adcs x22,x22,x17 + mul x17,x13,x4 + adcs x23,x23,x14 + umulh x14,x6,x4 + adcs x24,x24,x15 + umulh x15,x7,x4 + adcs x25,x25,x16 + umulh x16,x8,x4 + adcs x26,x26,x17 + umulh x17,x9,x4 + adc x28,x28,xzr + str x19,[x2],#8 + adds x19,x20,x14 + umulh x14,x10,x4 + adcs x20,x21,x15 + umulh x15,x11,x4 + adcs x21,x22,x16 + umulh x16,x12,x4 + adcs x22,x23,x17 + umulh x17,x13,x4 + ldr x4,[x0,x27] + adcs x23,x24,x14 + adcs x24,x25,x15 + adcs x25,x26,x16 + adcs x26,x28,x17 + //adc x28,xzr,xzr // moved above + cbnz x27,.Lsqr8x_mul + // note that carry flag is guaranteed + // to be zero at this point + cmp x1,x3 // done yet? + b.eq .Lsqr8x_break + + ldp x6,x7,[x2,#8*0] + ldp x8,x9,[x2,#8*2] + ldp x10,x11,[x2,#8*4] + ldp x12,x13,[x2,#8*6] + adds x19,x19,x6 + ldr x4,[x0,#-8*8] + adcs x20,x20,x7 + ldp x6,x7,[x1,#8*0] + adcs x21,x21,x8 + adcs x22,x22,x9 + ldp x8,x9,[x1,#8*2] + adcs x23,x23,x10 + adcs x24,x24,x11 + ldp x10,x11,[x1,#8*4] + adcs x25,x25,x12 + mov x27,#-8*8 + adcs x26,x26,x13 + ldp x12,x13,[x1,#8*6] + add x1,x1,#8*8 + //adc x28,xzr,xzr // moved above + b .Lsqr8x_mul + +.align 4 +.Lsqr8x_break: + ldp x6,x7,[x0,#8*0] + add x1,x0,#8*8 + ldp x8,x9,[x0,#8*2] + sub x14,x3,x1 // is it last iteration? + ldp x10,x11,[x0,#8*4] + sub x15,x2,x14 + ldp x12,x13,[x0,#8*6] + cbz x14,.Lsqr8x_outer_loop + + stp x19,x20,[x2,#8*0] + ldp x19,x20,[x15,#8*0] + stp x21,x22,[x2,#8*2] + ldp x21,x22,[x15,#8*2] + stp x23,x24,[x2,#8*4] + ldp x23,x24,[x15,#8*4] + stp x25,x26,[x2,#8*6] + mov x2,x15 + ldp x25,x26,[x15,#8*6] + b .Lsqr8x_outer_loop + +.align 4 +.Lsqr8x_outer_break: + // Now multiply above result by 2 and add a[n-1]*a[n-1]|...|a[0]*a[0] + ldp x7,x9,[x14,#8*0] // recall that x14 is &a[0] + ldp x15,x16,[sp,#8*1] + ldp x11,x13,[x14,#8*2] + add x1,x14,#8*4 + ldp x17,x14,[sp,#8*3] + + stp x19,x20,[x2,#8*0] + mul x19,x7,x7 + stp x21,x22,[x2,#8*2] + umulh x7,x7,x7 + stp x23,x24,[x2,#8*4] + mul x8,x9,x9 + stp x25,x26,[x2,#8*6] + mov x2,sp + umulh x9,x9,x9 + adds x20,x7,x15,lsl#1 + extr x15,x16,x15,#63 + sub x27,x5,#8*4 + +.Lsqr4x_shift_n_add: + adcs x21,x8,x15 + extr x16,x17,x16,#63 + sub x27,x27,#8*4 + adcs x22,x9,x16 + ldp x15,x16,[x2,#8*5] + mul x10,x11,x11 + ldp x7,x9,[x1],#8*2 + umulh x11,x11,x11 + mul x12,x13,x13 + umulh x13,x13,x13 + extr x17,x14,x17,#63 + stp x19,x20,[x2,#8*0] + adcs x23,x10,x17 + extr x14,x15,x14,#63 + stp x21,x22,[x2,#8*2] + adcs x24,x11,x14 + ldp x17,x14,[x2,#8*7] + extr x15,x16,x15,#63 + adcs x25,x12,x15 + extr x16,x17,x16,#63 + adcs x26,x13,x16 + ldp x15,x16,[x2,#8*9] + mul x6,x7,x7 + ldp x11,x13,[x1],#8*2 + umulh x7,x7,x7 + mul x8,x9,x9 + umulh x9,x9,x9 + stp x23,x24,[x2,#8*4] + extr x17,x14,x17,#63 + stp x25,x26,[x2,#8*6] + add x2,x2,#8*8 + adcs x19,x6,x17 + extr x14,x15,x14,#63 + adcs x20,x7,x14 + ldp x17,x14,[x2,#8*3] + extr x15,x16,x15,#63 + cbnz x27,.Lsqr4x_shift_n_add + ldp x1,x4,[x29,#104] // pull np and n0 + + adcs x21,x8,x15 + extr x16,x17,x16,#63 + adcs x22,x9,x16 + ldp x15,x16,[x2,#8*5] + mul x10,x11,x11 + umulh x11,x11,x11 + stp x19,x20,[x2,#8*0] + mul x12,x13,x13 + umulh x13,x13,x13 + stp x21,x22,[x2,#8*2] + extr x17,x14,x17,#63 + adcs x23,x10,x17 + extr x14,x15,x14,#63 + ldp x19,x20,[sp,#8*0] + adcs x24,x11,x14 + extr x15,x16,x15,#63 + ldp x6,x7,[x1,#8*0] + adcs x25,x12,x15 + extr x16,xzr,x16,#63 + ldp x8,x9,[x1,#8*2] + adc x26,x13,x16 + ldp x10,x11,[x1,#8*4] + + // Reduce by 512 bits per iteration + mul x28,x4,x19 // t[0]*n0 + ldp x12,x13,[x1,#8*6] + add x3,x1,x5 + ldp x21,x22,[sp,#8*2] + stp x23,x24,[x2,#8*4] + ldp x23,x24,[sp,#8*4] + stp x25,x26,[x2,#8*6] + ldp x25,x26,[sp,#8*6] + add x1,x1,#8*8 + mov x30,xzr // initial top-most carry + mov x2,sp + mov x27,#8 + +.Lsqr8x_reduction: + // (*) mul x14,x6,x28 // lo(n[0-7])*lo(t[0]*n0) + mul x15,x7,x28 + sub x27,x27,#1 + mul x16,x8,x28 + str x28,[x2],#8 // put aside t[0]*n0 for tail processing + mul x17,x9,x28 + // (*) adds xzr,x19,x14 + subs xzr,x19,#1 // (*) + mul x14,x10,x28 + adcs x19,x20,x15 + mul x15,x11,x28 + adcs x20,x21,x16 + mul x16,x12,x28 + adcs x21,x22,x17 + mul x17,x13,x28 + adcs x22,x23,x14 + umulh x14,x6,x28 // hi(n[0-7])*lo(t[0]*n0) + adcs x23,x24,x15 + umulh x15,x7,x28 + adcs x24,x25,x16 + umulh x16,x8,x28 + adcs x25,x26,x17 + umulh x17,x9,x28 + adc x26,xzr,xzr + adds x19,x19,x14 + umulh x14,x10,x28 + adcs x20,x20,x15 + umulh x15,x11,x28 + adcs x21,x21,x16 + umulh x16,x12,x28 + adcs x22,x22,x17 + umulh x17,x13,x28 + mul x28,x4,x19 // next t[0]*n0 + adcs x23,x23,x14 + adcs x24,x24,x15 + adcs x25,x25,x16 + adc x26,x26,x17 + cbnz x27,.Lsqr8x_reduction + + ldp x14,x15,[x2,#8*0] + ldp x16,x17,[x2,#8*2] + mov x0,x2 + sub x27,x3,x1 // done yet? + adds x19,x19,x14 + adcs x20,x20,x15 + ldp x14,x15,[x2,#8*4] + adcs x21,x21,x16 + adcs x22,x22,x17 + ldp x16,x17,[x2,#8*6] + adcs x23,x23,x14 + adcs x24,x24,x15 + adcs x25,x25,x16 + adcs x26,x26,x17 + //adc x28,xzr,xzr // moved below + cbz x27,.Lsqr8x8_post_condition + + ldr x4,[x2,#-8*8] + ldp x6,x7,[x1,#8*0] + ldp x8,x9,[x1,#8*2] + ldp x10,x11,[x1,#8*4] + mov x27,#-8*8 + ldp x12,x13,[x1,#8*6] + add x1,x1,#8*8 + +.Lsqr8x_tail: + mul x14,x6,x4 + adc x28,xzr,xzr // carry bit, modulo-scheduled + mul x15,x7,x4 + add x27,x27,#8 + mul x16,x8,x4 + mul x17,x9,x4 + adds x19,x19,x14 + mul x14,x10,x4 + adcs x20,x20,x15 + mul x15,x11,x4 + adcs x21,x21,x16 + mul x16,x12,x4 + adcs x22,x22,x17 + mul x17,x13,x4 + adcs x23,x23,x14 + umulh x14,x6,x4 + adcs x24,x24,x15 + umulh x15,x7,x4 + adcs x25,x25,x16 + umulh x16,x8,x4 + adcs x26,x26,x17 + umulh x17,x9,x4 + adc x28,x28,xzr + str x19,[x2],#8 + adds x19,x20,x14 + umulh x14,x10,x4 + adcs x20,x21,x15 + umulh x15,x11,x4 + adcs x21,x22,x16 + umulh x16,x12,x4 + adcs x22,x23,x17 + umulh x17,x13,x4 + ldr x4,[x0,x27] + adcs x23,x24,x14 + adcs x24,x25,x15 + adcs x25,x26,x16 + adcs x26,x28,x17 + //adc x28,xzr,xzr // moved above + cbnz x27,.Lsqr8x_tail + // note that carry flag is guaranteed + // to be zero at this point + ldp x6,x7,[x2,#8*0] + sub x27,x3,x1 // done yet? + sub x16,x3,x5 // rewinded np + ldp x8,x9,[x2,#8*2] + ldp x10,x11,[x2,#8*4] + ldp x12,x13,[x2,#8*6] + cbz x27,.Lsqr8x_tail_break + + ldr x4,[x0,#-8*8] + adds x19,x19,x6 + adcs x20,x20,x7 + ldp x6,x7,[x1,#8*0] + adcs x21,x21,x8 + adcs x22,x22,x9 + ldp x8,x9,[x1,#8*2] + adcs x23,x23,x10 + adcs x24,x24,x11 + ldp x10,x11,[x1,#8*4] + adcs x25,x25,x12 + mov x27,#-8*8 + adcs x26,x26,x13 + ldp x12,x13,[x1,#8*6] + add x1,x1,#8*8 + //adc x28,xzr,xzr // moved above + b .Lsqr8x_tail + +.align 4 +.Lsqr8x_tail_break: + ldr x4,[x29,#112] // pull n0 + add x27,x2,#8*8 // end of current t[num] window + + subs xzr,x30,#1 // "move" top-most carry to carry bit + adcs x14,x19,x6 + adcs x15,x20,x7 + ldp x19,x20,[x0,#8*0] + adcs x21,x21,x8 + ldp x6,x7,[x16,#8*0] // recall that x16 is &n[0] + adcs x22,x22,x9 + ldp x8,x9,[x16,#8*2] + adcs x23,x23,x10 + adcs x24,x24,x11 + ldp x10,x11,[x16,#8*4] + adcs x25,x25,x12 + adcs x26,x26,x13 + ldp x12,x13,[x16,#8*6] + add x1,x16,#8*8 + adc x30,xzr,xzr // top-most carry + mul x28,x4,x19 + stp x14,x15,[x2,#8*0] + stp x21,x22,[x2,#8*2] + ldp x21,x22,[x0,#8*2] + stp x23,x24,[x2,#8*4] + ldp x23,x24,[x0,#8*4] + cmp x27,x29 // did we hit the bottom? + stp x25,x26,[x2,#8*6] + mov x2,x0 // slide the window + ldp x25,x26,[x0,#8*6] + mov x27,#8 + b.ne .Lsqr8x_reduction + + // Final step. We see if result is larger than modulus, and + // if it is, subtract the modulus. But comparison implies + // subtraction. So we subtract modulus, see if it borrowed, + // and conditionally copy original value. + ldr x0,[x29,#96] // pull rp + add x2,x2,#8*8 + subs x14,x19,x6 + sbcs x15,x20,x7 + sub x27,x5,#8*8 + mov x3,x0 // x0 copy + +.Lsqr8x_sub: + sbcs x16,x21,x8 + ldp x6,x7,[x1,#8*0] + sbcs x17,x22,x9 + stp x14,x15,[x0,#8*0] + sbcs x14,x23,x10 + ldp x8,x9,[x1,#8*2] + sbcs x15,x24,x11 + stp x16,x17,[x0,#8*2] + sbcs x16,x25,x12 + ldp x10,x11,[x1,#8*4] + sbcs x17,x26,x13 + ldp x12,x13,[x1,#8*6] + add x1,x1,#8*8 + ldp x19,x20,[x2,#8*0] + sub x27,x27,#8*8 + ldp x21,x22,[x2,#8*2] + ldp x23,x24,[x2,#8*4] + ldp x25,x26,[x2,#8*6] + add x2,x2,#8*8 + stp x14,x15,[x0,#8*4] + sbcs x14,x19,x6 + stp x16,x17,[x0,#8*6] + add x0,x0,#8*8 + sbcs x15,x20,x7 + cbnz x27,.Lsqr8x_sub + + sbcs x16,x21,x8 + mov x2,sp + add x1,sp,x5 + ldp x6,x7,[x3,#8*0] + sbcs x17,x22,x9 + stp x14,x15,[x0,#8*0] + sbcs x14,x23,x10 + ldp x8,x9,[x3,#8*2] + sbcs x15,x24,x11 + stp x16,x17,[x0,#8*2] + sbcs x16,x25,x12 + ldp x19,x20,[x1,#8*0] + sbcs x17,x26,x13 + ldp x21,x22,[x1,#8*2] + sbcs xzr,x30,xzr // did it borrow? + ldr x30,[x29,#8] // pull return address + stp x14,x15,[x0,#8*4] + stp x16,x17,[x0,#8*6] + + sub x27,x5,#8*4 +.Lsqr4x_cond_copy: + sub x27,x27,#8*4 + csel x14,x19,x6,lo + stp xzr,xzr,[x2,#8*0] + csel x15,x20,x7,lo + ldp x6,x7,[x3,#8*4] + ldp x19,x20,[x1,#8*4] + csel x16,x21,x8,lo + stp xzr,xzr,[x2,#8*2] + add x2,x2,#8*4 + csel x17,x22,x9,lo + ldp x8,x9,[x3,#8*6] + ldp x21,x22,[x1,#8*6] + add x1,x1,#8*4 + stp x14,x15,[x3,#8*0] + stp x16,x17,[x3,#8*2] + add x3,x3,#8*4 + stp xzr,xzr,[x1,#8*0] + stp xzr,xzr,[x1,#8*2] + cbnz x27,.Lsqr4x_cond_copy + + csel x14,x19,x6,lo + stp xzr,xzr,[x2,#8*0] + csel x15,x20,x7,lo + stp xzr,xzr,[x2,#8*2] + csel x16,x21,x8,lo + csel x17,x22,x9,lo + stp x14,x15,[x3,#8*0] + stp x16,x17,[x3,#8*2] + + b .Lsqr8x_done + +.align 4 +.Lsqr8x8_post_condition: + adc x28,xzr,xzr + ldr x30,[x29,#8] // pull return address + // x19-7,x28 hold result, x6-7 hold modulus + subs x6,x19,x6 + ldr x1,[x29,#96] // pull rp + sbcs x7,x20,x7 + stp xzr,xzr,[sp,#8*0] + sbcs x8,x21,x8 + stp xzr,xzr,[sp,#8*2] + sbcs x9,x22,x9 + stp xzr,xzr,[sp,#8*4] + sbcs x10,x23,x10 + stp xzr,xzr,[sp,#8*6] + sbcs x11,x24,x11 + stp xzr,xzr,[sp,#8*8] + sbcs x12,x25,x12 + stp xzr,xzr,[sp,#8*10] + sbcs x13,x26,x13 + stp xzr,xzr,[sp,#8*12] + sbcs x28,x28,xzr // did it borrow? + stp xzr,xzr,[sp,#8*14] + + // x6-7 hold result-modulus + csel x6,x19,x6,lo + csel x7,x20,x7,lo + csel x8,x21,x8,lo + csel x9,x22,x9,lo + stp x6,x7,[x1,#8*0] + csel x10,x23,x10,lo + csel x11,x24,x11,lo + stp x8,x9,[x1,#8*2] + csel x12,x25,x12,lo + csel x13,x26,x13,lo + stp x10,x11,[x1,#8*4] + stp x12,x13,[x1,#8*6] + +.Lsqr8x_done: + ldp x19,x20,[x29,#16] + mov sp,x29 + ldp x21,x22,[x29,#32] + mov x0,#1 + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldr x29,[sp],#128 + // x30 is popped earlier + AARCH64_VALIDATE_LINK_REGISTER + ret +.size bn_sqr8x_mont,.-bn_sqr8x_mont +.globl bn_mul4x_mont +.hidden bn_mul4x_mont +.type bn_mul4x_mont,%function +.align 5 +bn_mul4x_mont: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-128]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + stp x27,x28,[sp,#80] + + sub x26,sp,x5,lsl#3 + lsl x5,x5,#3 + ldr x4,[x4] // *n0 + sub sp,x26,#8*4 // alloca + + add x10,x2,x5 + add x27,x1,x5 + stp x0,x10,[x29,#96] // offload rp and &b[num] + + ldr x24,[x2,#8*0] // b[0] + ldp x6,x7,[x1,#8*0] // a[0..3] + ldp x8,x9,[x1,#8*2] + add x1,x1,#8*4 + mov x19,xzr + mov x20,xzr + mov x21,xzr + mov x22,xzr + ldp x14,x15,[x3,#8*0] // n[0..3] + ldp x16,x17,[x3,#8*2] + adds x3,x3,#8*4 // clear carry bit + mov x0,xzr + mov x28,#0 + mov x26,sp + +.Loop_mul4x_1st_reduction: + mul x10,x6,x24 // lo(a[0..3]*b[0]) + adc x0,x0,xzr // modulo-scheduled + mul x11,x7,x24 + add x28,x28,#8 + mul x12,x8,x24 + and x28,x28,#31 + mul x13,x9,x24 + adds x19,x19,x10 + umulh x10,x6,x24 // hi(a[0..3]*b[0]) + adcs x20,x20,x11 + mul x25,x19,x4 // t[0]*n0 + adcs x21,x21,x12 + umulh x11,x7,x24 + adcs x22,x22,x13 + umulh x12,x8,x24 + adc x23,xzr,xzr + umulh x13,x9,x24 + ldr x24,[x2,x28] // next b[i] (or b[0]) + adds x20,x20,x10 + // (*) mul x10,x14,x25 // lo(n[0..3]*t[0]*n0) + str x25,[x26],#8 // put aside t[0]*n0 for tail processing + adcs x21,x21,x11 + mul x11,x15,x25 + adcs x22,x22,x12 + mul x12,x16,x25 + adc x23,x23,x13 // can't overflow + mul x13,x17,x25 + // (*) adds xzr,x19,x10 + subs xzr,x19,#1 // (*) + umulh x10,x14,x25 // hi(n[0..3]*t[0]*n0) + adcs x19,x20,x11 + umulh x11,x15,x25 + adcs x20,x21,x12 + umulh x12,x16,x25 + adcs x21,x22,x13 + umulh x13,x17,x25 + adcs x22,x23,x0 + adc x0,xzr,xzr + adds x19,x19,x10 + sub x10,x27,x1 + adcs x20,x20,x11 + adcs x21,x21,x12 + adcs x22,x22,x13 + //adc x0,x0,xzr + cbnz x28,.Loop_mul4x_1st_reduction + + cbz x10,.Lmul4x4_post_condition + + ldp x6,x7,[x1,#8*0] // a[4..7] + ldp x8,x9,[x1,#8*2] + add x1,x1,#8*4 + ldr x25,[sp] // a[0]*n0 + ldp x14,x15,[x3,#8*0] // n[4..7] + ldp x16,x17,[x3,#8*2] + add x3,x3,#8*4 + +.Loop_mul4x_1st_tail: + mul x10,x6,x24 // lo(a[4..7]*b[i]) + adc x0,x0,xzr // modulo-scheduled + mul x11,x7,x24 + add x28,x28,#8 + mul x12,x8,x24 + and x28,x28,#31 + mul x13,x9,x24 + adds x19,x19,x10 + umulh x10,x6,x24 // hi(a[4..7]*b[i]) + adcs x20,x20,x11 + umulh x11,x7,x24 + adcs x21,x21,x12 + umulh x12,x8,x24 + adcs x22,x22,x13 + umulh x13,x9,x24 + adc x23,xzr,xzr + ldr x24,[x2,x28] // next b[i] (or b[0]) + adds x20,x20,x10 + mul x10,x14,x25 // lo(n[4..7]*a[0]*n0) + adcs x21,x21,x11 + mul x11,x15,x25 + adcs x22,x22,x12 + mul x12,x16,x25 + adc x23,x23,x13 // can't overflow + mul x13,x17,x25 + adds x19,x19,x10 + umulh x10,x14,x25 // hi(n[4..7]*a[0]*n0) + adcs x20,x20,x11 + umulh x11,x15,x25 + adcs x21,x21,x12 + umulh x12,x16,x25 + adcs x22,x22,x13 + adcs x23,x23,x0 + umulh x13,x17,x25 + adc x0,xzr,xzr + ldr x25,[sp,x28] // next t[0]*n0 + str x19,[x26],#8 // result!!! + adds x19,x20,x10 + sub x10,x27,x1 // done yet? + adcs x20,x21,x11 + adcs x21,x22,x12 + adcs x22,x23,x13 + //adc x0,x0,xzr + cbnz x28,.Loop_mul4x_1st_tail + + sub x11,x27,x5 // rewinded x1 + cbz x10,.Lmul4x_proceed + + ldp x6,x7,[x1,#8*0] + ldp x8,x9,[x1,#8*2] + add x1,x1,#8*4 + ldp x14,x15,[x3,#8*0] + ldp x16,x17,[x3,#8*2] + add x3,x3,#8*4 + b .Loop_mul4x_1st_tail + +.align 5 +.Lmul4x_proceed: + ldr x24,[x2,#8*4]! // *++b + adc x30,x0,xzr + ldp x6,x7,[x11,#8*0] // a[0..3] + sub x3,x3,x5 // rewind np + ldp x8,x9,[x11,#8*2] + add x1,x11,#8*4 + + stp x19,x20,[x26,#8*0] // result!!! + ldp x19,x20,[sp,#8*4] // t[0..3] + stp x21,x22,[x26,#8*2] // result!!! + ldp x21,x22,[sp,#8*6] + + ldp x14,x15,[x3,#8*0] // n[0..3] + mov x26,sp + ldp x16,x17,[x3,#8*2] + adds x3,x3,#8*4 // clear carry bit + mov x0,xzr + +.align 4 +.Loop_mul4x_reduction: + mul x10,x6,x24 // lo(a[0..3]*b[4]) + adc x0,x0,xzr // modulo-scheduled + mul x11,x7,x24 + add x28,x28,#8 + mul x12,x8,x24 + and x28,x28,#31 + mul x13,x9,x24 + adds x19,x19,x10 + umulh x10,x6,x24 // hi(a[0..3]*b[4]) + adcs x20,x20,x11 + mul x25,x19,x4 // t[0]*n0 + adcs x21,x21,x12 + umulh x11,x7,x24 + adcs x22,x22,x13 + umulh x12,x8,x24 + adc x23,xzr,xzr + umulh x13,x9,x24 + ldr x24,[x2,x28] // next b[i] + adds x20,x20,x10 + // (*) mul x10,x14,x25 + str x25,[x26],#8 // put aside t[0]*n0 for tail processing + adcs x21,x21,x11 + mul x11,x15,x25 // lo(n[0..3]*t[0]*n0 + adcs x22,x22,x12 + mul x12,x16,x25 + adc x23,x23,x13 // can't overflow + mul x13,x17,x25 + // (*) adds xzr,x19,x10 + subs xzr,x19,#1 // (*) + umulh x10,x14,x25 // hi(n[0..3]*t[0]*n0 + adcs x19,x20,x11 + umulh x11,x15,x25 + adcs x20,x21,x12 + umulh x12,x16,x25 + adcs x21,x22,x13 + umulh x13,x17,x25 + adcs x22,x23,x0 + adc x0,xzr,xzr + adds x19,x19,x10 + adcs x20,x20,x11 + adcs x21,x21,x12 + adcs x22,x22,x13 + //adc x0,x0,xzr + cbnz x28,.Loop_mul4x_reduction + + adc x0,x0,xzr + ldp x10,x11,[x26,#8*4] // t[4..7] + ldp x12,x13,[x26,#8*6] + ldp x6,x7,[x1,#8*0] // a[4..7] + ldp x8,x9,[x1,#8*2] + add x1,x1,#8*4 + adds x19,x19,x10 + adcs x20,x20,x11 + adcs x21,x21,x12 + adcs x22,x22,x13 + //adc x0,x0,xzr + + ldr x25,[sp] // t[0]*n0 + ldp x14,x15,[x3,#8*0] // n[4..7] + ldp x16,x17,[x3,#8*2] + add x3,x3,#8*4 + +.align 4 +.Loop_mul4x_tail: + mul x10,x6,x24 // lo(a[4..7]*b[4]) + adc x0,x0,xzr // modulo-scheduled + mul x11,x7,x24 + add x28,x28,#8 + mul x12,x8,x24 + and x28,x28,#31 + mul x13,x9,x24 + adds x19,x19,x10 + umulh x10,x6,x24 // hi(a[4..7]*b[4]) + adcs x20,x20,x11 + umulh x11,x7,x24 + adcs x21,x21,x12 + umulh x12,x8,x24 + adcs x22,x22,x13 + umulh x13,x9,x24 + adc x23,xzr,xzr + ldr x24,[x2,x28] // next b[i] + adds x20,x20,x10 + mul x10,x14,x25 // lo(n[4..7]*t[0]*n0) + adcs x21,x21,x11 + mul x11,x15,x25 + adcs x22,x22,x12 + mul x12,x16,x25 + adc x23,x23,x13 // can't overflow + mul x13,x17,x25 + adds x19,x19,x10 + umulh x10,x14,x25 // hi(n[4..7]*t[0]*n0) + adcs x20,x20,x11 + umulh x11,x15,x25 + adcs x21,x21,x12 + umulh x12,x16,x25 + adcs x22,x22,x13 + umulh x13,x17,x25 + adcs x23,x23,x0 + ldr x25,[sp,x28] // next a[0]*n0 + adc x0,xzr,xzr + str x19,[x26],#8 // result!!! + adds x19,x20,x10 + sub x10,x27,x1 // done yet? + adcs x20,x21,x11 + adcs x21,x22,x12 + adcs x22,x23,x13 + //adc x0,x0,xzr + cbnz x28,.Loop_mul4x_tail + + sub x11,x3,x5 // rewinded np? + adc x0,x0,xzr + cbz x10,.Loop_mul4x_break + + ldp x10,x11,[x26,#8*4] + ldp x12,x13,[x26,#8*6] + ldp x6,x7,[x1,#8*0] + ldp x8,x9,[x1,#8*2] + add x1,x1,#8*4 + adds x19,x19,x10 + adcs x20,x20,x11 + adcs x21,x21,x12 + adcs x22,x22,x13 + //adc x0,x0,xzr + ldp x14,x15,[x3,#8*0] + ldp x16,x17,[x3,#8*2] + add x3,x3,#8*4 + b .Loop_mul4x_tail + +.align 4 +.Loop_mul4x_break: + ldp x12,x13,[x29,#96] // pull rp and &b[num] + adds x19,x19,x30 + add x2,x2,#8*4 // bp++ + adcs x20,x20,xzr + sub x1,x1,x5 // rewind ap + adcs x21,x21,xzr + stp x19,x20,[x26,#8*0] // result!!! + adcs x22,x22,xzr + ldp x19,x20,[sp,#8*4] // t[0..3] + adc x30,x0,xzr + stp x21,x22,[x26,#8*2] // result!!! + cmp x2,x13 // done yet? + ldp x21,x22,[sp,#8*6] + ldp x14,x15,[x11,#8*0] // n[0..3] + ldp x16,x17,[x11,#8*2] + add x3,x11,#8*4 + b.eq .Lmul4x_post + + ldr x24,[x2] + ldp x6,x7,[x1,#8*0] // a[0..3] + ldp x8,x9,[x1,#8*2] + adds x1,x1,#8*4 // clear carry bit + mov x0,xzr + mov x26,sp + b .Loop_mul4x_reduction + +.align 4 +.Lmul4x_post: + // Final step. We see if result is larger than modulus, and + // if it is, subtract the modulus. But comparison implies + // subtraction. So we subtract modulus, see if it borrowed, + // and conditionally copy original value. + mov x0,x12 + mov x27,x12 // x0 copy + subs x10,x19,x14 + add x26,sp,#8*8 + sbcs x11,x20,x15 + sub x28,x5,#8*4 + +.Lmul4x_sub: + sbcs x12,x21,x16 + ldp x14,x15,[x3,#8*0] + sub x28,x28,#8*4 + ldp x19,x20,[x26,#8*0] + sbcs x13,x22,x17 + ldp x16,x17,[x3,#8*2] + add x3,x3,#8*4 + ldp x21,x22,[x26,#8*2] + add x26,x26,#8*4 + stp x10,x11,[x0,#8*0] + sbcs x10,x19,x14 + stp x12,x13,[x0,#8*2] + add x0,x0,#8*4 + sbcs x11,x20,x15 + cbnz x28,.Lmul4x_sub + + sbcs x12,x21,x16 + mov x26,sp + add x1,sp,#8*4 + ldp x6,x7,[x27,#8*0] + sbcs x13,x22,x17 + stp x10,x11,[x0,#8*0] + ldp x8,x9,[x27,#8*2] + stp x12,x13,[x0,#8*2] + ldp x19,x20,[x1,#8*0] + ldp x21,x22,[x1,#8*2] + sbcs xzr,x30,xzr // did it borrow? + ldr x30,[x29,#8] // pull return address + + sub x28,x5,#8*4 +.Lmul4x_cond_copy: + sub x28,x28,#8*4 + csel x10,x19,x6,lo + stp xzr,xzr,[x26,#8*0] + csel x11,x20,x7,lo + ldp x6,x7,[x27,#8*4] + ldp x19,x20,[x1,#8*4] + csel x12,x21,x8,lo + stp xzr,xzr,[x26,#8*2] + add x26,x26,#8*4 + csel x13,x22,x9,lo + ldp x8,x9,[x27,#8*6] + ldp x21,x22,[x1,#8*6] + add x1,x1,#8*4 + stp x10,x11,[x27,#8*0] + stp x12,x13,[x27,#8*2] + add x27,x27,#8*4 + cbnz x28,.Lmul4x_cond_copy + + csel x10,x19,x6,lo + stp xzr,xzr,[x26,#8*0] + csel x11,x20,x7,lo + stp xzr,xzr,[x26,#8*2] + csel x12,x21,x8,lo + stp xzr,xzr,[x26,#8*3] + csel x13,x22,x9,lo + stp xzr,xzr,[x26,#8*4] + stp x10,x11,[x27,#8*0] + stp x12,x13,[x27,#8*2] + + b .Lmul4x_done + +.align 4 +.Lmul4x4_post_condition: + adc x0,x0,xzr + ldr x1,[x29,#96] // pull rp + // x19-3,x0 hold result, x14-7 hold modulus + subs x6,x19,x14 + ldr x30,[x29,#8] // pull return address + sbcs x7,x20,x15 + stp xzr,xzr,[sp,#8*0] + sbcs x8,x21,x16 + stp xzr,xzr,[sp,#8*2] + sbcs x9,x22,x17 + stp xzr,xzr,[sp,#8*4] + sbcs xzr,x0,xzr // did it borrow? + stp xzr,xzr,[sp,#8*6] + + // x6-3 hold result-modulus + csel x6,x19,x6,lo + csel x7,x20,x7,lo + csel x8,x21,x8,lo + csel x9,x22,x9,lo + stp x6,x7,[x1,#8*0] + stp x8,x9,[x1,#8*2] + +.Lmul4x_done: + ldp x19,x20,[x29,#16] + mov sp,x29 + ldp x21,x22,[x29,#32] + mov x0,#1 + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldr x29,[sp],#128 + // x30 is popped earlier + AARCH64_VALIDATE_LINK_REGISTER + ret +.size bn_mul4x_mont,.-bn_mul4x_mont +.byte 77,111,110,116,103,111,109,101,114,121,32,77,117,108,116,105,112,108,105,99,97,116,105,111,110,32,102,111,114,32,65,82,77,118,56,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.align 2 +.align 4 +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__ELF__) diff --git a/http/vendor/ring/pregenerated/armv8-mont-win64.S b/http/vendor/ring/pregenerated/armv8-mont-win64.S new file mode 100644 index 0000000..b5f2b9e --- /dev/null +++ b/http/vendor/ring/pregenerated/armv8-mont-win64.S @@ -0,0 +1,1422 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(_WIN32) +.text + +.globl bn_mul_mont_nohw + +.def bn_mul_mont_nohw + .type 32 +.endef +.align 5 +bn_mul_mont_nohw: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-64]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + + ldr x9,[x2],#8 // bp[0] + sub x22,sp,x5,lsl#3 + ldp x7,x8,[x1],#16 // ap[0..1] + lsl x5,x5,#3 + ldr x4,[x4] // *n0 + and x22,x22,#-16 // ABI says so + ldp x13,x14,[x3],#16 // np[0..1] + + mul x6,x7,x9 // ap[0]*bp[0] + sub x21,x5,#16 // j=num-2 + umulh x7,x7,x9 + mul x10,x8,x9 // ap[1]*bp[0] + umulh x11,x8,x9 + + mul x15,x6,x4 // "tp[0]"*n0 + mov sp,x22 // alloca + + // (*) mul x12,x13,x15 // np[0]*m1 + umulh x13,x13,x15 + mul x16,x14,x15 // np[1]*m1 + // (*) adds x12,x12,x6 // discarded + // (*) As for removal of first multiplication and addition + // instructions. The outcome of first addition is + // guaranteed to be zero, which leaves two computationally + // significant outcomes: it either carries or not. Then + // question is when does it carry? Is there alternative + // way to deduce it? If you follow operations, you can + // observe that condition for carry is quite simple: + // x6 being non-zero. So that carry can be calculated + // by adding -1 to x6. That's what next instruction does. + subs xzr,x6,#1 // (*) + umulh x17,x14,x15 + adc x13,x13,xzr + cbz x21,L1st_skip + +L1st: + ldr x8,[x1],#8 + adds x6,x10,x7 + sub x21,x21,#8 // j-- + adc x7,x11,xzr + + ldr x14,[x3],#8 + adds x12,x16,x13 + mul x10,x8,x9 // ap[j]*bp[0] + adc x13,x17,xzr + umulh x11,x8,x9 + + adds x12,x12,x6 + mul x16,x14,x15 // np[j]*m1 + adc x13,x13,xzr + umulh x17,x14,x15 + str x12,[x22],#8 // tp[j-1] + cbnz x21,L1st + +L1st_skip: + adds x6,x10,x7 + sub x1,x1,x5 // rewind x1 + adc x7,x11,xzr + + adds x12,x16,x13 + sub x3,x3,x5 // rewind x3 + adc x13,x17,xzr + + adds x12,x12,x6 + sub x20,x5,#8 // i=num-1 + adcs x13,x13,x7 + + adc x19,xzr,xzr // upmost overflow bit + stp x12,x13,[x22] + +Louter: + ldr x9,[x2],#8 // bp[i] + ldp x7,x8,[x1],#16 + ldr x23,[sp] // tp[0] + add x22,sp,#8 + + mul x6,x7,x9 // ap[0]*bp[i] + sub x21,x5,#16 // j=num-2 + umulh x7,x7,x9 + ldp x13,x14,[x3],#16 + mul x10,x8,x9 // ap[1]*bp[i] + adds x6,x6,x23 + umulh x11,x8,x9 + adc x7,x7,xzr + + mul x15,x6,x4 + sub x20,x20,#8 // i-- + + // (*) mul x12,x13,x15 // np[0]*m1 + umulh x13,x13,x15 + mul x16,x14,x15 // np[1]*m1 + // (*) adds x12,x12,x6 + subs xzr,x6,#1 // (*) + umulh x17,x14,x15 + cbz x21,Linner_skip + +Linner: + ldr x8,[x1],#8 + adc x13,x13,xzr + ldr x23,[x22],#8 // tp[j] + adds x6,x10,x7 + sub x21,x21,#8 // j-- + adc x7,x11,xzr + + adds x12,x16,x13 + ldr x14,[x3],#8 + adc x13,x17,xzr + + mul x10,x8,x9 // ap[j]*bp[i] + adds x6,x6,x23 + umulh x11,x8,x9 + adc x7,x7,xzr + + mul x16,x14,x15 // np[j]*m1 + adds x12,x12,x6 + umulh x17,x14,x15 + str x12,[x22,#-16] // tp[j-1] + cbnz x21,Linner + +Linner_skip: + ldr x23,[x22],#8 // tp[j] + adc x13,x13,xzr + adds x6,x10,x7 + sub x1,x1,x5 // rewind x1 + adc x7,x11,xzr + + adds x12,x16,x13 + sub x3,x3,x5 // rewind x3 + adcs x13,x17,x19 + adc x19,xzr,xzr + + adds x6,x6,x23 + adc x7,x7,xzr + + adds x12,x12,x6 + adcs x13,x13,x7 + adc x19,x19,xzr // upmost overflow bit + stp x12,x13,[x22,#-16] + + cbnz x20,Louter + + // Final step. We see if result is larger than modulus, and + // if it is, subtract the modulus. But comparison implies + // subtraction. So we subtract modulus, see if it borrowed, + // and conditionally copy original value. + ldr x23,[sp] // tp[0] + add x22,sp,#8 + ldr x14,[x3],#8 // np[0] + subs x21,x5,#8 // j=num-1 and clear borrow + mov x1,x0 +Lsub: + sbcs x8,x23,x14 // tp[j]-np[j] + ldr x23,[x22],#8 + sub x21,x21,#8 // j-- + ldr x14,[x3],#8 + str x8,[x1],#8 // rp[j]=tp[j]-np[j] + cbnz x21,Lsub + + sbcs x8,x23,x14 + sbcs x19,x19,xzr // did it borrow? + str x8,[x1],#8 // rp[num-1] + + ldr x23,[sp] // tp[0] + add x22,sp,#8 + ldr x8,[x0],#8 // rp[0] + sub x5,x5,#8 // num-- + nop +Lcond_copy: + sub x5,x5,#8 // num-- + csel x14,x23,x8,lo // did it borrow? + ldr x23,[x22],#8 + ldr x8,[x0],#8 + str xzr,[x22,#-16] // wipe tp + str x14,[x0,#-16] + cbnz x5,Lcond_copy + + csel x14,x23,x8,lo + str xzr,[x22,#-8] // wipe tp + str x14,[x0,#-8] + + ldp x19,x20,[x29,#16] + mov sp,x29 + ldp x21,x22,[x29,#32] + mov x0,#1 + ldp x23,x24,[x29,#48] + ldr x29,[sp],#64 + AARCH64_VALIDATE_LINK_REGISTER + ret + +.globl bn_sqr8x_mont + +.def bn_sqr8x_mont + .type 32 +.endef +.align 5 +bn_sqr8x_mont: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-128]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + stp x27,x28,[sp,#80] + stp x0,x3,[sp,#96] // offload rp and np + + ldp x6,x7,[x1,#8*0] + ldp x8,x9,[x1,#8*2] + ldp x10,x11,[x1,#8*4] + ldp x12,x13,[x1,#8*6] + + sub x2,sp,x5,lsl#4 + lsl x5,x5,#3 + ldr x4,[x4] // *n0 + mov sp,x2 // alloca + sub x27,x5,#8*8 + b Lsqr8x_zero_start + +Lsqr8x_zero: + sub x27,x27,#8*8 + stp xzr,xzr,[x2,#8*0] + stp xzr,xzr,[x2,#8*2] + stp xzr,xzr,[x2,#8*4] + stp xzr,xzr,[x2,#8*6] +Lsqr8x_zero_start: + stp xzr,xzr,[x2,#8*8] + stp xzr,xzr,[x2,#8*10] + stp xzr,xzr,[x2,#8*12] + stp xzr,xzr,[x2,#8*14] + add x2,x2,#8*16 + cbnz x27,Lsqr8x_zero + + add x3,x1,x5 + add x1,x1,#8*8 + mov x19,xzr + mov x20,xzr + mov x21,xzr + mov x22,xzr + mov x23,xzr + mov x24,xzr + mov x25,xzr + mov x26,xzr + mov x2,sp + str x4,[x29,#112] // offload n0 + + // Multiply everything but a[i]*a[i] +.align 4 +Lsqr8x_outer_loop: + // a[1]a[0] (i) + // a[2]a[0] + // a[3]a[0] + // a[4]a[0] + // a[5]a[0] + // a[6]a[0] + // a[7]a[0] + // a[2]a[1] (ii) + // a[3]a[1] + // a[4]a[1] + // a[5]a[1] + // a[6]a[1] + // a[7]a[1] + // a[3]a[2] (iii) + // a[4]a[2] + // a[5]a[2] + // a[6]a[2] + // a[7]a[2] + // a[4]a[3] (iv) + // a[5]a[3] + // a[6]a[3] + // a[7]a[3] + // a[5]a[4] (v) + // a[6]a[4] + // a[7]a[4] + // a[6]a[5] (vi) + // a[7]a[5] + // a[7]a[6] (vii) + + mul x14,x7,x6 // lo(a[1..7]*a[0]) (i) + mul x15,x8,x6 + mul x16,x9,x6 + mul x17,x10,x6 + adds x20,x20,x14 // t[1]+lo(a[1]*a[0]) + mul x14,x11,x6 + adcs x21,x21,x15 + mul x15,x12,x6 + adcs x22,x22,x16 + mul x16,x13,x6 + adcs x23,x23,x17 + umulh x17,x7,x6 // hi(a[1..7]*a[0]) + adcs x24,x24,x14 + umulh x14,x8,x6 + adcs x25,x25,x15 + umulh x15,x9,x6 + adcs x26,x26,x16 + umulh x16,x10,x6 + stp x19,x20,[x2],#8*2 // t[0..1] + adc x19,xzr,xzr // t[8] + adds x21,x21,x17 // t[2]+lo(a[1]*a[0]) + umulh x17,x11,x6 + adcs x22,x22,x14 + umulh x14,x12,x6 + adcs x23,x23,x15 + umulh x15,x13,x6 + adcs x24,x24,x16 + mul x16,x8,x7 // lo(a[2..7]*a[1]) (ii) + adcs x25,x25,x17 + mul x17,x9,x7 + adcs x26,x26,x14 + mul x14,x10,x7 + adc x19,x19,x15 + + mul x15,x11,x7 + adds x22,x22,x16 + mul x16,x12,x7 + adcs x23,x23,x17 + mul x17,x13,x7 + adcs x24,x24,x14 + umulh x14,x8,x7 // hi(a[2..7]*a[1]) + adcs x25,x25,x15 + umulh x15,x9,x7 + adcs x26,x26,x16 + umulh x16,x10,x7 + adcs x19,x19,x17 + umulh x17,x11,x7 + stp x21,x22,[x2],#8*2 // t[2..3] + adc x20,xzr,xzr // t[9] + adds x23,x23,x14 + umulh x14,x12,x7 + adcs x24,x24,x15 + umulh x15,x13,x7 + adcs x25,x25,x16 + mul x16,x9,x8 // lo(a[3..7]*a[2]) (iii) + adcs x26,x26,x17 + mul x17,x10,x8 + adcs x19,x19,x14 + mul x14,x11,x8 + adc x20,x20,x15 + + mul x15,x12,x8 + adds x24,x24,x16 + mul x16,x13,x8 + adcs x25,x25,x17 + umulh x17,x9,x8 // hi(a[3..7]*a[2]) + adcs x26,x26,x14 + umulh x14,x10,x8 + adcs x19,x19,x15 + umulh x15,x11,x8 + adcs x20,x20,x16 + umulh x16,x12,x8 + stp x23,x24,[x2],#8*2 // t[4..5] + adc x21,xzr,xzr // t[10] + adds x25,x25,x17 + umulh x17,x13,x8 + adcs x26,x26,x14 + mul x14,x10,x9 // lo(a[4..7]*a[3]) (iv) + adcs x19,x19,x15 + mul x15,x11,x9 + adcs x20,x20,x16 + mul x16,x12,x9 + adc x21,x21,x17 + + mul x17,x13,x9 + adds x26,x26,x14 + umulh x14,x10,x9 // hi(a[4..7]*a[3]) + adcs x19,x19,x15 + umulh x15,x11,x9 + adcs x20,x20,x16 + umulh x16,x12,x9 + adcs x21,x21,x17 + umulh x17,x13,x9 + stp x25,x26,[x2],#8*2 // t[6..7] + adc x22,xzr,xzr // t[11] + adds x19,x19,x14 + mul x14,x11,x10 // lo(a[5..7]*a[4]) (v) + adcs x20,x20,x15 + mul x15,x12,x10 + adcs x21,x21,x16 + mul x16,x13,x10 + adc x22,x22,x17 + + umulh x17,x11,x10 // hi(a[5..7]*a[4]) + adds x20,x20,x14 + umulh x14,x12,x10 + adcs x21,x21,x15 + umulh x15,x13,x10 + adcs x22,x22,x16 + mul x16,x12,x11 // lo(a[6..7]*a[5]) (vi) + adc x23,xzr,xzr // t[12] + adds x21,x21,x17 + mul x17,x13,x11 + adcs x22,x22,x14 + umulh x14,x12,x11 // hi(a[6..7]*a[5]) + adc x23,x23,x15 + + umulh x15,x13,x11 + adds x22,x22,x16 + mul x16,x13,x12 // lo(a[7]*a[6]) (vii) + adcs x23,x23,x17 + umulh x17,x13,x12 // hi(a[7]*a[6]) + adc x24,xzr,xzr // t[13] + adds x23,x23,x14 + sub x27,x3,x1 // done yet? + adc x24,x24,x15 + + adds x24,x24,x16 + sub x14,x3,x5 // rewinded ap + adc x25,xzr,xzr // t[14] + add x25,x25,x17 + + cbz x27,Lsqr8x_outer_break + + mov x4,x6 + ldp x6,x7,[x2,#8*0] + ldp x8,x9,[x2,#8*2] + ldp x10,x11,[x2,#8*4] + ldp x12,x13,[x2,#8*6] + adds x19,x19,x6 + adcs x20,x20,x7 + ldp x6,x7,[x1,#8*0] + adcs x21,x21,x8 + adcs x22,x22,x9 + ldp x8,x9,[x1,#8*2] + adcs x23,x23,x10 + adcs x24,x24,x11 + ldp x10,x11,[x1,#8*4] + adcs x25,x25,x12 + mov x0,x1 + adcs x26,xzr,x13 + ldp x12,x13,[x1,#8*6] + add x1,x1,#8*8 + //adc x28,xzr,xzr // moved below + mov x27,#-8*8 + + // a[8]a[0] + // a[9]a[0] + // a[a]a[0] + // a[b]a[0] + // a[c]a[0] + // a[d]a[0] + // a[e]a[0] + // a[f]a[0] + // a[8]a[1] + // a[f]a[1]........................ + // a[8]a[2] + // a[f]a[2]........................ + // a[8]a[3] + // a[f]a[3]........................ + // a[8]a[4] + // a[f]a[4]........................ + // a[8]a[5] + // a[f]a[5]........................ + // a[8]a[6] + // a[f]a[6]........................ + // a[8]a[7] + // a[f]a[7]........................ +Lsqr8x_mul: + mul x14,x6,x4 + adc x28,xzr,xzr // carry bit, modulo-scheduled + mul x15,x7,x4 + add x27,x27,#8 + mul x16,x8,x4 + mul x17,x9,x4 + adds x19,x19,x14 + mul x14,x10,x4 + adcs x20,x20,x15 + mul x15,x11,x4 + adcs x21,x21,x16 + mul x16,x12,x4 + adcs x22,x22,x17 + mul x17,x13,x4 + adcs x23,x23,x14 + umulh x14,x6,x4 + adcs x24,x24,x15 + umulh x15,x7,x4 + adcs x25,x25,x16 + umulh x16,x8,x4 + adcs x26,x26,x17 + umulh x17,x9,x4 + adc x28,x28,xzr + str x19,[x2],#8 + adds x19,x20,x14 + umulh x14,x10,x4 + adcs x20,x21,x15 + umulh x15,x11,x4 + adcs x21,x22,x16 + umulh x16,x12,x4 + adcs x22,x23,x17 + umulh x17,x13,x4 + ldr x4,[x0,x27] + adcs x23,x24,x14 + adcs x24,x25,x15 + adcs x25,x26,x16 + adcs x26,x28,x17 + //adc x28,xzr,xzr // moved above + cbnz x27,Lsqr8x_mul + // note that carry flag is guaranteed + // to be zero at this point + cmp x1,x3 // done yet? + b.eq Lsqr8x_break + + ldp x6,x7,[x2,#8*0] + ldp x8,x9,[x2,#8*2] + ldp x10,x11,[x2,#8*4] + ldp x12,x13,[x2,#8*6] + adds x19,x19,x6 + ldr x4,[x0,#-8*8] + adcs x20,x20,x7 + ldp x6,x7,[x1,#8*0] + adcs x21,x21,x8 + adcs x22,x22,x9 + ldp x8,x9,[x1,#8*2] + adcs x23,x23,x10 + adcs x24,x24,x11 + ldp x10,x11,[x1,#8*4] + adcs x25,x25,x12 + mov x27,#-8*8 + adcs x26,x26,x13 + ldp x12,x13,[x1,#8*6] + add x1,x1,#8*8 + //adc x28,xzr,xzr // moved above + b Lsqr8x_mul + +.align 4 +Lsqr8x_break: + ldp x6,x7,[x0,#8*0] + add x1,x0,#8*8 + ldp x8,x9,[x0,#8*2] + sub x14,x3,x1 // is it last iteration? + ldp x10,x11,[x0,#8*4] + sub x15,x2,x14 + ldp x12,x13,[x0,#8*6] + cbz x14,Lsqr8x_outer_loop + + stp x19,x20,[x2,#8*0] + ldp x19,x20,[x15,#8*0] + stp x21,x22,[x2,#8*2] + ldp x21,x22,[x15,#8*2] + stp x23,x24,[x2,#8*4] + ldp x23,x24,[x15,#8*4] + stp x25,x26,[x2,#8*6] + mov x2,x15 + ldp x25,x26,[x15,#8*6] + b Lsqr8x_outer_loop + +.align 4 +Lsqr8x_outer_break: + // Now multiply above result by 2 and add a[n-1]*a[n-1]|...|a[0]*a[0] + ldp x7,x9,[x14,#8*0] // recall that x14 is &a[0] + ldp x15,x16,[sp,#8*1] + ldp x11,x13,[x14,#8*2] + add x1,x14,#8*4 + ldp x17,x14,[sp,#8*3] + + stp x19,x20,[x2,#8*0] + mul x19,x7,x7 + stp x21,x22,[x2,#8*2] + umulh x7,x7,x7 + stp x23,x24,[x2,#8*4] + mul x8,x9,x9 + stp x25,x26,[x2,#8*6] + mov x2,sp + umulh x9,x9,x9 + adds x20,x7,x15,lsl#1 + extr x15,x16,x15,#63 + sub x27,x5,#8*4 + +Lsqr4x_shift_n_add: + adcs x21,x8,x15 + extr x16,x17,x16,#63 + sub x27,x27,#8*4 + adcs x22,x9,x16 + ldp x15,x16,[x2,#8*5] + mul x10,x11,x11 + ldp x7,x9,[x1],#8*2 + umulh x11,x11,x11 + mul x12,x13,x13 + umulh x13,x13,x13 + extr x17,x14,x17,#63 + stp x19,x20,[x2,#8*0] + adcs x23,x10,x17 + extr x14,x15,x14,#63 + stp x21,x22,[x2,#8*2] + adcs x24,x11,x14 + ldp x17,x14,[x2,#8*7] + extr x15,x16,x15,#63 + adcs x25,x12,x15 + extr x16,x17,x16,#63 + adcs x26,x13,x16 + ldp x15,x16,[x2,#8*9] + mul x6,x7,x7 + ldp x11,x13,[x1],#8*2 + umulh x7,x7,x7 + mul x8,x9,x9 + umulh x9,x9,x9 + stp x23,x24,[x2,#8*4] + extr x17,x14,x17,#63 + stp x25,x26,[x2,#8*6] + add x2,x2,#8*8 + adcs x19,x6,x17 + extr x14,x15,x14,#63 + adcs x20,x7,x14 + ldp x17,x14,[x2,#8*3] + extr x15,x16,x15,#63 + cbnz x27,Lsqr4x_shift_n_add + ldp x1,x4,[x29,#104] // pull np and n0 + + adcs x21,x8,x15 + extr x16,x17,x16,#63 + adcs x22,x9,x16 + ldp x15,x16,[x2,#8*5] + mul x10,x11,x11 + umulh x11,x11,x11 + stp x19,x20,[x2,#8*0] + mul x12,x13,x13 + umulh x13,x13,x13 + stp x21,x22,[x2,#8*2] + extr x17,x14,x17,#63 + adcs x23,x10,x17 + extr x14,x15,x14,#63 + ldp x19,x20,[sp,#8*0] + adcs x24,x11,x14 + extr x15,x16,x15,#63 + ldp x6,x7,[x1,#8*0] + adcs x25,x12,x15 + extr x16,xzr,x16,#63 + ldp x8,x9,[x1,#8*2] + adc x26,x13,x16 + ldp x10,x11,[x1,#8*4] + + // Reduce by 512 bits per iteration + mul x28,x4,x19 // t[0]*n0 + ldp x12,x13,[x1,#8*6] + add x3,x1,x5 + ldp x21,x22,[sp,#8*2] + stp x23,x24,[x2,#8*4] + ldp x23,x24,[sp,#8*4] + stp x25,x26,[x2,#8*6] + ldp x25,x26,[sp,#8*6] + add x1,x1,#8*8 + mov x30,xzr // initial top-most carry + mov x2,sp + mov x27,#8 + +Lsqr8x_reduction: + // (*) mul x14,x6,x28 // lo(n[0-7])*lo(t[0]*n0) + mul x15,x7,x28 + sub x27,x27,#1 + mul x16,x8,x28 + str x28,[x2],#8 // put aside t[0]*n0 for tail processing + mul x17,x9,x28 + // (*) adds xzr,x19,x14 + subs xzr,x19,#1 // (*) + mul x14,x10,x28 + adcs x19,x20,x15 + mul x15,x11,x28 + adcs x20,x21,x16 + mul x16,x12,x28 + adcs x21,x22,x17 + mul x17,x13,x28 + adcs x22,x23,x14 + umulh x14,x6,x28 // hi(n[0-7])*lo(t[0]*n0) + adcs x23,x24,x15 + umulh x15,x7,x28 + adcs x24,x25,x16 + umulh x16,x8,x28 + adcs x25,x26,x17 + umulh x17,x9,x28 + adc x26,xzr,xzr + adds x19,x19,x14 + umulh x14,x10,x28 + adcs x20,x20,x15 + umulh x15,x11,x28 + adcs x21,x21,x16 + umulh x16,x12,x28 + adcs x22,x22,x17 + umulh x17,x13,x28 + mul x28,x4,x19 // next t[0]*n0 + adcs x23,x23,x14 + adcs x24,x24,x15 + adcs x25,x25,x16 + adc x26,x26,x17 + cbnz x27,Lsqr8x_reduction + + ldp x14,x15,[x2,#8*0] + ldp x16,x17,[x2,#8*2] + mov x0,x2 + sub x27,x3,x1 // done yet? + adds x19,x19,x14 + adcs x20,x20,x15 + ldp x14,x15,[x2,#8*4] + adcs x21,x21,x16 + adcs x22,x22,x17 + ldp x16,x17,[x2,#8*6] + adcs x23,x23,x14 + adcs x24,x24,x15 + adcs x25,x25,x16 + adcs x26,x26,x17 + //adc x28,xzr,xzr // moved below + cbz x27,Lsqr8x8_post_condition + + ldr x4,[x2,#-8*8] + ldp x6,x7,[x1,#8*0] + ldp x8,x9,[x1,#8*2] + ldp x10,x11,[x1,#8*4] + mov x27,#-8*8 + ldp x12,x13,[x1,#8*6] + add x1,x1,#8*8 + +Lsqr8x_tail: + mul x14,x6,x4 + adc x28,xzr,xzr // carry bit, modulo-scheduled + mul x15,x7,x4 + add x27,x27,#8 + mul x16,x8,x4 + mul x17,x9,x4 + adds x19,x19,x14 + mul x14,x10,x4 + adcs x20,x20,x15 + mul x15,x11,x4 + adcs x21,x21,x16 + mul x16,x12,x4 + adcs x22,x22,x17 + mul x17,x13,x4 + adcs x23,x23,x14 + umulh x14,x6,x4 + adcs x24,x24,x15 + umulh x15,x7,x4 + adcs x25,x25,x16 + umulh x16,x8,x4 + adcs x26,x26,x17 + umulh x17,x9,x4 + adc x28,x28,xzr + str x19,[x2],#8 + adds x19,x20,x14 + umulh x14,x10,x4 + adcs x20,x21,x15 + umulh x15,x11,x4 + adcs x21,x22,x16 + umulh x16,x12,x4 + adcs x22,x23,x17 + umulh x17,x13,x4 + ldr x4,[x0,x27] + adcs x23,x24,x14 + adcs x24,x25,x15 + adcs x25,x26,x16 + adcs x26,x28,x17 + //adc x28,xzr,xzr // moved above + cbnz x27,Lsqr8x_tail + // note that carry flag is guaranteed + // to be zero at this point + ldp x6,x7,[x2,#8*0] + sub x27,x3,x1 // done yet? + sub x16,x3,x5 // rewinded np + ldp x8,x9,[x2,#8*2] + ldp x10,x11,[x2,#8*4] + ldp x12,x13,[x2,#8*6] + cbz x27,Lsqr8x_tail_break + + ldr x4,[x0,#-8*8] + adds x19,x19,x6 + adcs x20,x20,x7 + ldp x6,x7,[x1,#8*0] + adcs x21,x21,x8 + adcs x22,x22,x9 + ldp x8,x9,[x1,#8*2] + adcs x23,x23,x10 + adcs x24,x24,x11 + ldp x10,x11,[x1,#8*4] + adcs x25,x25,x12 + mov x27,#-8*8 + adcs x26,x26,x13 + ldp x12,x13,[x1,#8*6] + add x1,x1,#8*8 + //adc x28,xzr,xzr // moved above + b Lsqr8x_tail + +.align 4 +Lsqr8x_tail_break: + ldr x4,[x29,#112] // pull n0 + add x27,x2,#8*8 // end of current t[num] window + + subs xzr,x30,#1 // "move" top-most carry to carry bit + adcs x14,x19,x6 + adcs x15,x20,x7 + ldp x19,x20,[x0,#8*0] + adcs x21,x21,x8 + ldp x6,x7,[x16,#8*0] // recall that x16 is &n[0] + adcs x22,x22,x9 + ldp x8,x9,[x16,#8*2] + adcs x23,x23,x10 + adcs x24,x24,x11 + ldp x10,x11,[x16,#8*4] + adcs x25,x25,x12 + adcs x26,x26,x13 + ldp x12,x13,[x16,#8*6] + add x1,x16,#8*8 + adc x30,xzr,xzr // top-most carry + mul x28,x4,x19 + stp x14,x15,[x2,#8*0] + stp x21,x22,[x2,#8*2] + ldp x21,x22,[x0,#8*2] + stp x23,x24,[x2,#8*4] + ldp x23,x24,[x0,#8*4] + cmp x27,x29 // did we hit the bottom? + stp x25,x26,[x2,#8*6] + mov x2,x0 // slide the window + ldp x25,x26,[x0,#8*6] + mov x27,#8 + b.ne Lsqr8x_reduction + + // Final step. We see if result is larger than modulus, and + // if it is, subtract the modulus. But comparison implies + // subtraction. So we subtract modulus, see if it borrowed, + // and conditionally copy original value. + ldr x0,[x29,#96] // pull rp + add x2,x2,#8*8 + subs x14,x19,x6 + sbcs x15,x20,x7 + sub x27,x5,#8*8 + mov x3,x0 // x0 copy + +Lsqr8x_sub: + sbcs x16,x21,x8 + ldp x6,x7,[x1,#8*0] + sbcs x17,x22,x9 + stp x14,x15,[x0,#8*0] + sbcs x14,x23,x10 + ldp x8,x9,[x1,#8*2] + sbcs x15,x24,x11 + stp x16,x17,[x0,#8*2] + sbcs x16,x25,x12 + ldp x10,x11,[x1,#8*4] + sbcs x17,x26,x13 + ldp x12,x13,[x1,#8*6] + add x1,x1,#8*8 + ldp x19,x20,[x2,#8*0] + sub x27,x27,#8*8 + ldp x21,x22,[x2,#8*2] + ldp x23,x24,[x2,#8*4] + ldp x25,x26,[x2,#8*6] + add x2,x2,#8*8 + stp x14,x15,[x0,#8*4] + sbcs x14,x19,x6 + stp x16,x17,[x0,#8*6] + add x0,x0,#8*8 + sbcs x15,x20,x7 + cbnz x27,Lsqr8x_sub + + sbcs x16,x21,x8 + mov x2,sp + add x1,sp,x5 + ldp x6,x7,[x3,#8*0] + sbcs x17,x22,x9 + stp x14,x15,[x0,#8*0] + sbcs x14,x23,x10 + ldp x8,x9,[x3,#8*2] + sbcs x15,x24,x11 + stp x16,x17,[x0,#8*2] + sbcs x16,x25,x12 + ldp x19,x20,[x1,#8*0] + sbcs x17,x26,x13 + ldp x21,x22,[x1,#8*2] + sbcs xzr,x30,xzr // did it borrow? + ldr x30,[x29,#8] // pull return address + stp x14,x15,[x0,#8*4] + stp x16,x17,[x0,#8*6] + + sub x27,x5,#8*4 +Lsqr4x_cond_copy: + sub x27,x27,#8*4 + csel x14,x19,x6,lo + stp xzr,xzr,[x2,#8*0] + csel x15,x20,x7,lo + ldp x6,x7,[x3,#8*4] + ldp x19,x20,[x1,#8*4] + csel x16,x21,x8,lo + stp xzr,xzr,[x2,#8*2] + add x2,x2,#8*4 + csel x17,x22,x9,lo + ldp x8,x9,[x3,#8*6] + ldp x21,x22,[x1,#8*6] + add x1,x1,#8*4 + stp x14,x15,[x3,#8*0] + stp x16,x17,[x3,#8*2] + add x3,x3,#8*4 + stp xzr,xzr,[x1,#8*0] + stp xzr,xzr,[x1,#8*2] + cbnz x27,Lsqr4x_cond_copy + + csel x14,x19,x6,lo + stp xzr,xzr,[x2,#8*0] + csel x15,x20,x7,lo + stp xzr,xzr,[x2,#8*2] + csel x16,x21,x8,lo + csel x17,x22,x9,lo + stp x14,x15,[x3,#8*0] + stp x16,x17,[x3,#8*2] + + b Lsqr8x_done + +.align 4 +Lsqr8x8_post_condition: + adc x28,xzr,xzr + ldr x30,[x29,#8] // pull return address + // x19-7,x28 hold result, x6-7 hold modulus + subs x6,x19,x6 + ldr x1,[x29,#96] // pull rp + sbcs x7,x20,x7 + stp xzr,xzr,[sp,#8*0] + sbcs x8,x21,x8 + stp xzr,xzr,[sp,#8*2] + sbcs x9,x22,x9 + stp xzr,xzr,[sp,#8*4] + sbcs x10,x23,x10 + stp xzr,xzr,[sp,#8*6] + sbcs x11,x24,x11 + stp xzr,xzr,[sp,#8*8] + sbcs x12,x25,x12 + stp xzr,xzr,[sp,#8*10] + sbcs x13,x26,x13 + stp xzr,xzr,[sp,#8*12] + sbcs x28,x28,xzr // did it borrow? + stp xzr,xzr,[sp,#8*14] + + // x6-7 hold result-modulus + csel x6,x19,x6,lo + csel x7,x20,x7,lo + csel x8,x21,x8,lo + csel x9,x22,x9,lo + stp x6,x7,[x1,#8*0] + csel x10,x23,x10,lo + csel x11,x24,x11,lo + stp x8,x9,[x1,#8*2] + csel x12,x25,x12,lo + csel x13,x26,x13,lo + stp x10,x11,[x1,#8*4] + stp x12,x13,[x1,#8*6] + +Lsqr8x_done: + ldp x19,x20,[x29,#16] + mov sp,x29 + ldp x21,x22,[x29,#32] + mov x0,#1 + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldr x29,[sp],#128 + // x30 is popped earlier + AARCH64_VALIDATE_LINK_REGISTER + ret + +.globl bn_mul4x_mont + +.def bn_mul4x_mont + .type 32 +.endef +.align 5 +bn_mul4x_mont: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-128]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + stp x27,x28,[sp,#80] + + sub x26,sp,x5,lsl#3 + lsl x5,x5,#3 + ldr x4,[x4] // *n0 + sub sp,x26,#8*4 // alloca + + add x10,x2,x5 + add x27,x1,x5 + stp x0,x10,[x29,#96] // offload rp and &b[num] + + ldr x24,[x2,#8*0] // b[0] + ldp x6,x7,[x1,#8*0] // a[0..3] + ldp x8,x9,[x1,#8*2] + add x1,x1,#8*4 + mov x19,xzr + mov x20,xzr + mov x21,xzr + mov x22,xzr + ldp x14,x15,[x3,#8*0] // n[0..3] + ldp x16,x17,[x3,#8*2] + adds x3,x3,#8*4 // clear carry bit + mov x0,xzr + mov x28,#0 + mov x26,sp + +Loop_mul4x_1st_reduction: + mul x10,x6,x24 // lo(a[0..3]*b[0]) + adc x0,x0,xzr // modulo-scheduled + mul x11,x7,x24 + add x28,x28,#8 + mul x12,x8,x24 + and x28,x28,#31 + mul x13,x9,x24 + adds x19,x19,x10 + umulh x10,x6,x24 // hi(a[0..3]*b[0]) + adcs x20,x20,x11 + mul x25,x19,x4 // t[0]*n0 + adcs x21,x21,x12 + umulh x11,x7,x24 + adcs x22,x22,x13 + umulh x12,x8,x24 + adc x23,xzr,xzr + umulh x13,x9,x24 + ldr x24,[x2,x28] // next b[i] (or b[0]) + adds x20,x20,x10 + // (*) mul x10,x14,x25 // lo(n[0..3]*t[0]*n0) + str x25,[x26],#8 // put aside t[0]*n0 for tail processing + adcs x21,x21,x11 + mul x11,x15,x25 + adcs x22,x22,x12 + mul x12,x16,x25 + adc x23,x23,x13 // can't overflow + mul x13,x17,x25 + // (*) adds xzr,x19,x10 + subs xzr,x19,#1 // (*) + umulh x10,x14,x25 // hi(n[0..3]*t[0]*n0) + adcs x19,x20,x11 + umulh x11,x15,x25 + adcs x20,x21,x12 + umulh x12,x16,x25 + adcs x21,x22,x13 + umulh x13,x17,x25 + adcs x22,x23,x0 + adc x0,xzr,xzr + adds x19,x19,x10 + sub x10,x27,x1 + adcs x20,x20,x11 + adcs x21,x21,x12 + adcs x22,x22,x13 + //adc x0,x0,xzr + cbnz x28,Loop_mul4x_1st_reduction + + cbz x10,Lmul4x4_post_condition + + ldp x6,x7,[x1,#8*0] // a[4..7] + ldp x8,x9,[x1,#8*2] + add x1,x1,#8*4 + ldr x25,[sp] // a[0]*n0 + ldp x14,x15,[x3,#8*0] // n[4..7] + ldp x16,x17,[x3,#8*2] + add x3,x3,#8*4 + +Loop_mul4x_1st_tail: + mul x10,x6,x24 // lo(a[4..7]*b[i]) + adc x0,x0,xzr // modulo-scheduled + mul x11,x7,x24 + add x28,x28,#8 + mul x12,x8,x24 + and x28,x28,#31 + mul x13,x9,x24 + adds x19,x19,x10 + umulh x10,x6,x24 // hi(a[4..7]*b[i]) + adcs x20,x20,x11 + umulh x11,x7,x24 + adcs x21,x21,x12 + umulh x12,x8,x24 + adcs x22,x22,x13 + umulh x13,x9,x24 + adc x23,xzr,xzr + ldr x24,[x2,x28] // next b[i] (or b[0]) + adds x20,x20,x10 + mul x10,x14,x25 // lo(n[4..7]*a[0]*n0) + adcs x21,x21,x11 + mul x11,x15,x25 + adcs x22,x22,x12 + mul x12,x16,x25 + adc x23,x23,x13 // can't overflow + mul x13,x17,x25 + adds x19,x19,x10 + umulh x10,x14,x25 // hi(n[4..7]*a[0]*n0) + adcs x20,x20,x11 + umulh x11,x15,x25 + adcs x21,x21,x12 + umulh x12,x16,x25 + adcs x22,x22,x13 + adcs x23,x23,x0 + umulh x13,x17,x25 + adc x0,xzr,xzr + ldr x25,[sp,x28] // next t[0]*n0 + str x19,[x26],#8 // result!!! + adds x19,x20,x10 + sub x10,x27,x1 // done yet? + adcs x20,x21,x11 + adcs x21,x22,x12 + adcs x22,x23,x13 + //adc x0,x0,xzr + cbnz x28,Loop_mul4x_1st_tail + + sub x11,x27,x5 // rewinded x1 + cbz x10,Lmul4x_proceed + + ldp x6,x7,[x1,#8*0] + ldp x8,x9,[x1,#8*2] + add x1,x1,#8*4 + ldp x14,x15,[x3,#8*0] + ldp x16,x17,[x3,#8*2] + add x3,x3,#8*4 + b Loop_mul4x_1st_tail + +.align 5 +Lmul4x_proceed: + ldr x24,[x2,#8*4]! // *++b + adc x30,x0,xzr + ldp x6,x7,[x11,#8*0] // a[0..3] + sub x3,x3,x5 // rewind np + ldp x8,x9,[x11,#8*2] + add x1,x11,#8*4 + + stp x19,x20,[x26,#8*0] // result!!! + ldp x19,x20,[sp,#8*4] // t[0..3] + stp x21,x22,[x26,#8*2] // result!!! + ldp x21,x22,[sp,#8*6] + + ldp x14,x15,[x3,#8*0] // n[0..3] + mov x26,sp + ldp x16,x17,[x3,#8*2] + adds x3,x3,#8*4 // clear carry bit + mov x0,xzr + +.align 4 +Loop_mul4x_reduction: + mul x10,x6,x24 // lo(a[0..3]*b[4]) + adc x0,x0,xzr // modulo-scheduled + mul x11,x7,x24 + add x28,x28,#8 + mul x12,x8,x24 + and x28,x28,#31 + mul x13,x9,x24 + adds x19,x19,x10 + umulh x10,x6,x24 // hi(a[0..3]*b[4]) + adcs x20,x20,x11 + mul x25,x19,x4 // t[0]*n0 + adcs x21,x21,x12 + umulh x11,x7,x24 + adcs x22,x22,x13 + umulh x12,x8,x24 + adc x23,xzr,xzr + umulh x13,x9,x24 + ldr x24,[x2,x28] // next b[i] + adds x20,x20,x10 + // (*) mul x10,x14,x25 + str x25,[x26],#8 // put aside t[0]*n0 for tail processing + adcs x21,x21,x11 + mul x11,x15,x25 // lo(n[0..3]*t[0]*n0 + adcs x22,x22,x12 + mul x12,x16,x25 + adc x23,x23,x13 // can't overflow + mul x13,x17,x25 + // (*) adds xzr,x19,x10 + subs xzr,x19,#1 // (*) + umulh x10,x14,x25 // hi(n[0..3]*t[0]*n0 + adcs x19,x20,x11 + umulh x11,x15,x25 + adcs x20,x21,x12 + umulh x12,x16,x25 + adcs x21,x22,x13 + umulh x13,x17,x25 + adcs x22,x23,x0 + adc x0,xzr,xzr + adds x19,x19,x10 + adcs x20,x20,x11 + adcs x21,x21,x12 + adcs x22,x22,x13 + //adc x0,x0,xzr + cbnz x28,Loop_mul4x_reduction + + adc x0,x0,xzr + ldp x10,x11,[x26,#8*4] // t[4..7] + ldp x12,x13,[x26,#8*6] + ldp x6,x7,[x1,#8*0] // a[4..7] + ldp x8,x9,[x1,#8*2] + add x1,x1,#8*4 + adds x19,x19,x10 + adcs x20,x20,x11 + adcs x21,x21,x12 + adcs x22,x22,x13 + //adc x0,x0,xzr + + ldr x25,[sp] // t[0]*n0 + ldp x14,x15,[x3,#8*0] // n[4..7] + ldp x16,x17,[x3,#8*2] + add x3,x3,#8*4 + +.align 4 +Loop_mul4x_tail: + mul x10,x6,x24 // lo(a[4..7]*b[4]) + adc x0,x0,xzr // modulo-scheduled + mul x11,x7,x24 + add x28,x28,#8 + mul x12,x8,x24 + and x28,x28,#31 + mul x13,x9,x24 + adds x19,x19,x10 + umulh x10,x6,x24 // hi(a[4..7]*b[4]) + adcs x20,x20,x11 + umulh x11,x7,x24 + adcs x21,x21,x12 + umulh x12,x8,x24 + adcs x22,x22,x13 + umulh x13,x9,x24 + adc x23,xzr,xzr + ldr x24,[x2,x28] // next b[i] + adds x20,x20,x10 + mul x10,x14,x25 // lo(n[4..7]*t[0]*n0) + adcs x21,x21,x11 + mul x11,x15,x25 + adcs x22,x22,x12 + mul x12,x16,x25 + adc x23,x23,x13 // can't overflow + mul x13,x17,x25 + adds x19,x19,x10 + umulh x10,x14,x25 // hi(n[4..7]*t[0]*n0) + adcs x20,x20,x11 + umulh x11,x15,x25 + adcs x21,x21,x12 + umulh x12,x16,x25 + adcs x22,x22,x13 + umulh x13,x17,x25 + adcs x23,x23,x0 + ldr x25,[sp,x28] // next a[0]*n0 + adc x0,xzr,xzr + str x19,[x26],#8 // result!!! + adds x19,x20,x10 + sub x10,x27,x1 // done yet? + adcs x20,x21,x11 + adcs x21,x22,x12 + adcs x22,x23,x13 + //adc x0,x0,xzr + cbnz x28,Loop_mul4x_tail + + sub x11,x3,x5 // rewinded np? + adc x0,x0,xzr + cbz x10,Loop_mul4x_break + + ldp x10,x11,[x26,#8*4] + ldp x12,x13,[x26,#8*6] + ldp x6,x7,[x1,#8*0] + ldp x8,x9,[x1,#8*2] + add x1,x1,#8*4 + adds x19,x19,x10 + adcs x20,x20,x11 + adcs x21,x21,x12 + adcs x22,x22,x13 + //adc x0,x0,xzr + ldp x14,x15,[x3,#8*0] + ldp x16,x17,[x3,#8*2] + add x3,x3,#8*4 + b Loop_mul4x_tail + +.align 4 +Loop_mul4x_break: + ldp x12,x13,[x29,#96] // pull rp and &b[num] + adds x19,x19,x30 + add x2,x2,#8*4 // bp++ + adcs x20,x20,xzr + sub x1,x1,x5 // rewind ap + adcs x21,x21,xzr + stp x19,x20,[x26,#8*0] // result!!! + adcs x22,x22,xzr + ldp x19,x20,[sp,#8*4] // t[0..3] + adc x30,x0,xzr + stp x21,x22,[x26,#8*2] // result!!! + cmp x2,x13 // done yet? + ldp x21,x22,[sp,#8*6] + ldp x14,x15,[x11,#8*0] // n[0..3] + ldp x16,x17,[x11,#8*2] + add x3,x11,#8*4 + b.eq Lmul4x_post + + ldr x24,[x2] + ldp x6,x7,[x1,#8*0] // a[0..3] + ldp x8,x9,[x1,#8*2] + adds x1,x1,#8*4 // clear carry bit + mov x0,xzr + mov x26,sp + b Loop_mul4x_reduction + +.align 4 +Lmul4x_post: + // Final step. We see if result is larger than modulus, and + // if it is, subtract the modulus. But comparison implies + // subtraction. So we subtract modulus, see if it borrowed, + // and conditionally copy original value. + mov x0,x12 + mov x27,x12 // x0 copy + subs x10,x19,x14 + add x26,sp,#8*8 + sbcs x11,x20,x15 + sub x28,x5,#8*4 + +Lmul4x_sub: + sbcs x12,x21,x16 + ldp x14,x15,[x3,#8*0] + sub x28,x28,#8*4 + ldp x19,x20,[x26,#8*0] + sbcs x13,x22,x17 + ldp x16,x17,[x3,#8*2] + add x3,x3,#8*4 + ldp x21,x22,[x26,#8*2] + add x26,x26,#8*4 + stp x10,x11,[x0,#8*0] + sbcs x10,x19,x14 + stp x12,x13,[x0,#8*2] + add x0,x0,#8*4 + sbcs x11,x20,x15 + cbnz x28,Lmul4x_sub + + sbcs x12,x21,x16 + mov x26,sp + add x1,sp,#8*4 + ldp x6,x7,[x27,#8*0] + sbcs x13,x22,x17 + stp x10,x11,[x0,#8*0] + ldp x8,x9,[x27,#8*2] + stp x12,x13,[x0,#8*2] + ldp x19,x20,[x1,#8*0] + ldp x21,x22,[x1,#8*2] + sbcs xzr,x30,xzr // did it borrow? + ldr x30,[x29,#8] // pull return address + + sub x28,x5,#8*4 +Lmul4x_cond_copy: + sub x28,x28,#8*4 + csel x10,x19,x6,lo + stp xzr,xzr,[x26,#8*0] + csel x11,x20,x7,lo + ldp x6,x7,[x27,#8*4] + ldp x19,x20,[x1,#8*4] + csel x12,x21,x8,lo + stp xzr,xzr,[x26,#8*2] + add x26,x26,#8*4 + csel x13,x22,x9,lo + ldp x8,x9,[x27,#8*6] + ldp x21,x22,[x1,#8*6] + add x1,x1,#8*4 + stp x10,x11,[x27,#8*0] + stp x12,x13,[x27,#8*2] + add x27,x27,#8*4 + cbnz x28,Lmul4x_cond_copy + + csel x10,x19,x6,lo + stp xzr,xzr,[x26,#8*0] + csel x11,x20,x7,lo + stp xzr,xzr,[x26,#8*2] + csel x12,x21,x8,lo + stp xzr,xzr,[x26,#8*3] + csel x13,x22,x9,lo + stp xzr,xzr,[x26,#8*4] + stp x10,x11,[x27,#8*0] + stp x12,x13,[x27,#8*2] + + b Lmul4x_done + +.align 4 +Lmul4x4_post_condition: + adc x0,x0,xzr + ldr x1,[x29,#96] // pull rp + // x19-3,x0 hold result, x14-7 hold modulus + subs x6,x19,x14 + ldr x30,[x29,#8] // pull return address + sbcs x7,x20,x15 + stp xzr,xzr,[sp,#8*0] + sbcs x8,x21,x16 + stp xzr,xzr,[sp,#8*2] + sbcs x9,x22,x17 + stp xzr,xzr,[sp,#8*4] + sbcs xzr,x0,xzr // did it borrow? + stp xzr,xzr,[sp,#8*6] + + // x6-3 hold result-modulus + csel x6,x19,x6,lo + csel x7,x20,x7,lo + csel x8,x21,x8,lo + csel x9,x22,x9,lo + stp x6,x7,[x1,#8*0] + stp x8,x9,[x1,#8*2] + +Lmul4x_done: + ldp x19,x20,[x29,#16] + mov sp,x29 + ldp x21,x22,[x29,#32] + mov x0,#1 + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldr x29,[sp],#128 + // x30 is popped earlier + AARCH64_VALIDATE_LINK_REGISTER + ret + +.byte 77,111,110,116,103,111,109,101,114,121,32,77,117,108,116,105,112,108,105,99,97,116,105,111,110,32,102,111,114,32,65,82,77,118,56,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.align 2 +.align 4 +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(_WIN32) diff --git a/http/vendor/ring/pregenerated/bsaes-armv7-linux32.S b/http/vendor/ring/pregenerated/bsaes-armv7-linux32.S new file mode 100644 index 0000000..771c2cd --- /dev/null +++ b/http/vendor/ring/pregenerated/bsaes-armv7-linux32.S @@ -0,0 +1,796 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_ARM) && defined(__ELF__) +@ Copyright 2012-2016 The OpenSSL Project Authors. All Rights Reserved. +@ +@ Licensed under the Apache License, Version 2.0 (the "License"); +@ you may not use this file except in compliance with the License. +@ You may obtain a copy of the License at +@ +@ https://www.apache.org/licenses/LICENSE-2.0 +@ +@ Unless required by applicable law or agreed to in writing, software +@ distributed under the License is distributed on an "AS IS" BASIS, +@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@ See the License for the specific language governing permissions and +@ limitations under the License. + + +@ ==================================================================== +@ Written by Andy Polyakov for the OpenSSL +@ project. +@ +@ Specific modes and adaptation for Linux kernel by Ard Biesheuvel +@ of Linaro. +@ ==================================================================== + +@ Bit-sliced AES for ARM NEON +@ +@ February 2012. +@ +@ This implementation is direct adaptation of bsaes-x86_64 module for +@ ARM NEON. Except that this module is endian-neutral [in sense that +@ it can be compiled for either endianness] by courtesy of vld1.8's +@ neutrality. Initial version doesn't implement interface to OpenSSL, +@ only low-level primitives and unsupported entry points, just enough +@ to collect performance results, which for Cortex-A8 core are: +@ +@ encrypt 19.5 cycles per byte processed with 128-bit key +@ decrypt 22.1 cycles per byte processed with 128-bit key +@ key conv. 440 cycles per 128-bit key/0.18 of 8x block +@ +@ Snapdragon S4 encrypts byte in 17.6 cycles and decrypts in 19.7, +@ which is [much] worse than anticipated (for further details see +@ http://www.openssl.org/~appro/Snapdragon-S4.html). +@ +@ Cortex-A15 manages in 14.2/16.1 cycles [when integer-only code +@ manages in 20.0 cycles]. +@ +@ When comparing to x86_64 results keep in mind that NEON unit is +@ [mostly] single-issue and thus can't [fully] benefit from +@ instruction-level parallelism. And when comparing to aes-armv4 +@ results keep in mind key schedule conversion overhead (see +@ bsaes-x86_64.pl for further details)... +@ +@ + +@ April-August 2013 +@ Add CBC, CTR and XTS subroutines and adapt for kernel use; courtesy of Ard. + +#ifndef __KERNEL__ +# define VFP_ABI_PUSH vstmdb sp!,{d8-d15} +# define VFP_ABI_POP vldmia sp!,{d8-d15} +# define VFP_ABI_FRAME 0x40 +#else +# define VFP_ABI_PUSH +# define VFP_ABI_POP +# define VFP_ABI_FRAME 0 +# define BSAES_ASM_EXTENDED_KEY +# define __ARM_MAX_ARCH__ 7 +#endif + +#ifdef __thumb__ +# define adrl adr +#endif + +#if __ARM_MAX_ARCH__>=7 +.arch armv7-a +.fpu neon + +.text +.syntax unified @ ARMv7-capable assembler is expected to handle this +#if defined(__thumb2__) && !defined(__APPLE__) +.thumb +#else +.code 32 +# undef __thumb2__ +#endif + +.type _bsaes_const,%object +.align 6 +_bsaes_const: +.LM0ISR:@ InvShiftRows constants +.quad 0x0a0e0206070b0f03, 0x0004080c0d010509 +.LISR: +.quad 0x0504070602010003, 0x0f0e0d0c080b0a09 +.LISRM0: +.quad 0x01040b0e0205080f, 0x0306090c00070a0d +.LM0SR:@ ShiftRows constants +.quad 0x0a0e02060f03070b, 0x0004080c05090d01 +.LSR: +.quad 0x0504070600030201, 0x0f0e0d0c0a09080b +.LSRM0: +.quad 0x0304090e00050a0f, 0x01060b0c0207080d +.LM0: +.quad 0x02060a0e03070b0f, 0x0004080c0105090d +.LREVM0SR: +.quad 0x090d01050c000408, 0x03070b0f060a0e02 +.byte 66,105,116,45,115,108,105,99,101,100,32,65,69,83,32,102,111,114,32,78,69,79,78,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.align 2 +.align 6 +.size _bsaes_const,.-_bsaes_const + +.type _bsaes_encrypt8,%function +.align 4 +_bsaes_encrypt8: + adr r6,. + vldmia r4!, {q9} @ round 0 key +#if defined(__thumb2__) || defined(__APPLE__) + adr r6,.LM0SR +#else + sub r6,r6,#_bsaes_encrypt8-.LM0SR +#endif + + vldmia r6!, {q8} @ .LM0SR +_bsaes_encrypt8_alt: + veor q10, q0, q9 @ xor with round0 key + veor q11, q1, q9 + vtbl.8 d0, {q10}, d16 + vtbl.8 d1, {q10}, d17 + veor q12, q2, q9 + vtbl.8 d2, {q11}, d16 + vtbl.8 d3, {q11}, d17 + veor q13, q3, q9 + vtbl.8 d4, {q12}, d16 + vtbl.8 d5, {q12}, d17 + veor q14, q4, q9 + vtbl.8 d6, {q13}, d16 + vtbl.8 d7, {q13}, d17 + veor q15, q5, q9 + vtbl.8 d8, {q14}, d16 + vtbl.8 d9, {q14}, d17 + veor q10, q6, q9 + vtbl.8 d10, {q15}, d16 + vtbl.8 d11, {q15}, d17 + veor q11, q7, q9 + vtbl.8 d12, {q10}, d16 + vtbl.8 d13, {q10}, d17 + vtbl.8 d14, {q11}, d16 + vtbl.8 d15, {q11}, d17 +_bsaes_encrypt8_bitslice: + vmov.i8 q8,#0x55 @ compose .LBS0 + vmov.i8 q9,#0x33 @ compose .LBS1 + vshr.u64 q10, q6, #1 + vshr.u64 q11, q4, #1 + veor q10, q10, q7 + veor q11, q11, q5 + vand q10, q10, q8 + vand q11, q11, q8 + veor q7, q7, q10 + vshl.u64 q10, q10, #1 + veor q5, q5, q11 + vshl.u64 q11, q11, #1 + veor q6, q6, q10 + veor q4, q4, q11 + vshr.u64 q10, q2, #1 + vshr.u64 q11, q0, #1 + veor q10, q10, q3 + veor q11, q11, q1 + vand q10, q10, q8 + vand q11, q11, q8 + veor q3, q3, q10 + vshl.u64 q10, q10, #1 + veor q1, q1, q11 + vshl.u64 q11, q11, #1 + veor q2, q2, q10 + veor q0, q0, q11 + vmov.i8 q8,#0x0f @ compose .LBS2 + vshr.u64 q10, q5, #2 + vshr.u64 q11, q4, #2 + veor q10, q10, q7 + veor q11, q11, q6 + vand q10, q10, q9 + vand q11, q11, q9 + veor q7, q7, q10 + vshl.u64 q10, q10, #2 + veor q6, q6, q11 + vshl.u64 q11, q11, #2 + veor q5, q5, q10 + veor q4, q4, q11 + vshr.u64 q10, q1, #2 + vshr.u64 q11, q0, #2 + veor q10, q10, q3 + veor q11, q11, q2 + vand q10, q10, q9 + vand q11, q11, q9 + veor q3, q3, q10 + vshl.u64 q10, q10, #2 + veor q2, q2, q11 + vshl.u64 q11, q11, #2 + veor q1, q1, q10 + veor q0, q0, q11 + vshr.u64 q10, q3, #4 + vshr.u64 q11, q2, #4 + veor q10, q10, q7 + veor q11, q11, q6 + vand q10, q10, q8 + vand q11, q11, q8 + veor q7, q7, q10 + vshl.u64 q10, q10, #4 + veor q6, q6, q11 + vshl.u64 q11, q11, #4 + veor q3, q3, q10 + veor q2, q2, q11 + vshr.u64 q10, q1, #4 + vshr.u64 q11, q0, #4 + veor q10, q10, q5 + veor q11, q11, q4 + vand q10, q10, q8 + vand q11, q11, q8 + veor q5, q5, q10 + vshl.u64 q10, q10, #4 + veor q4, q4, q11 + vshl.u64 q11, q11, #4 + veor q1, q1, q10 + veor q0, q0, q11 + sub r5,r5,#1 + b .Lenc_sbox +.align 4 +.Lenc_loop: + vldmia r4!, {q8,q9,q10,q11} + veor q8, q8, q0 + veor q9, q9, q1 + vtbl.8 d0, {q8}, d24 + vtbl.8 d1, {q8}, d25 + vldmia r4!, {q8} + veor q10, q10, q2 + vtbl.8 d2, {q9}, d24 + vtbl.8 d3, {q9}, d25 + vldmia r4!, {q9} + veor q11, q11, q3 + vtbl.8 d4, {q10}, d24 + vtbl.8 d5, {q10}, d25 + vldmia r4!, {q10} + vtbl.8 d6, {q11}, d24 + vtbl.8 d7, {q11}, d25 + vldmia r4!, {q11} + veor q8, q8, q4 + veor q9, q9, q5 + vtbl.8 d8, {q8}, d24 + vtbl.8 d9, {q8}, d25 + veor q10, q10, q6 + vtbl.8 d10, {q9}, d24 + vtbl.8 d11, {q9}, d25 + veor q11, q11, q7 + vtbl.8 d12, {q10}, d24 + vtbl.8 d13, {q10}, d25 + vtbl.8 d14, {q11}, d24 + vtbl.8 d15, {q11}, d25 +.Lenc_sbox: + veor q2, q2, q1 + veor q5, q5, q6 + veor q3, q3, q0 + veor q6, q6, q2 + veor q5, q5, q0 + + veor q6, q6, q3 + veor q3, q3, q7 + veor q7, q7, q5 + veor q3, q3, q4 + veor q4, q4, q5 + + veor q2, q2, q7 + veor q3, q3, q1 + veor q1, q1, q5 + veor q11, q7, q4 + veor q10, q1, q2 + veor q9, q5, q3 + veor q13, q2, q4 + vmov q8, q10 + veor q12, q6, q0 + + vorr q10, q10, q9 + veor q15, q11, q8 + vand q14, q11, q12 + vorr q11, q11, q12 + veor q12, q12, q9 + vand q8, q8, q9 + veor q9, q3, q0 + vand q15, q15, q12 + vand q13, q13, q9 + veor q9, q7, q1 + veor q12, q5, q6 + veor q11, q11, q13 + veor q10, q10, q13 + vand q13, q9, q12 + vorr q9, q9, q12 + veor q11, q11, q15 + veor q8, q8, q13 + veor q10, q10, q14 + veor q9, q9, q15 + veor q8, q8, q14 + vand q12, q2, q3 + veor q9, q9, q14 + vand q13, q4, q0 + vand q14, q1, q5 + vorr q15, q7, q6 + veor q11, q11, q12 + veor q9, q9, q14 + veor q8, q8, q15 + veor q10, q10, q13 + + @ Inv_GF16 0, 1, 2, 3, s0, s1, s2, s3 + + @ new smaller inversion + + vand q14, q11, q9 + vmov q12, q8 + + veor q13, q10, q14 + veor q15, q8, q14 + veor q14, q8, q14 @ q14=q15 + + vbsl q13, q9, q8 + vbsl q15, q11, q10 + veor q11, q11, q10 + + vbsl q12, q13, q14 + vbsl q8, q14, q13 + + vand q14, q12, q15 + veor q9, q9, q8 + + veor q14, q14, q11 + veor q12, q6, q0 + veor q8, q5, q3 + veor q10, q15, q14 + vand q10, q10, q6 + veor q6, q6, q5 + vand q11, q5, q15 + vand q6, q6, q14 + veor q5, q11, q10 + veor q6, q6, q11 + veor q15, q15, q13 + veor q14, q14, q9 + veor q11, q15, q14 + veor q10, q13, q9 + vand q11, q11, q12 + vand q10, q10, q0 + veor q12, q12, q8 + veor q0, q0, q3 + vand q8, q8, q15 + vand q3, q3, q13 + vand q12, q12, q14 + vand q0, q0, q9 + veor q8, q8, q12 + veor q0, q0, q3 + veor q12, q12, q11 + veor q3, q3, q10 + veor q6, q6, q12 + veor q0, q0, q12 + veor q5, q5, q8 + veor q3, q3, q8 + + veor q12, q7, q4 + veor q8, q1, q2 + veor q11, q15, q14 + veor q10, q13, q9 + vand q11, q11, q12 + vand q10, q10, q4 + veor q12, q12, q8 + veor q4, q4, q2 + vand q8, q8, q15 + vand q2, q2, q13 + vand q12, q12, q14 + vand q4, q4, q9 + veor q8, q8, q12 + veor q4, q4, q2 + veor q12, q12, q11 + veor q2, q2, q10 + veor q15, q15, q13 + veor q14, q14, q9 + veor q10, q15, q14 + vand q10, q10, q7 + veor q7, q7, q1 + vand q11, q1, q15 + vand q7, q7, q14 + veor q1, q11, q10 + veor q7, q7, q11 + veor q7, q7, q12 + veor q4, q4, q12 + veor q1, q1, q8 + veor q2, q2, q8 + veor q7, q7, q0 + veor q1, q1, q6 + veor q6, q6, q0 + veor q4, q4, q7 + veor q0, q0, q1 + + veor q1, q1, q5 + veor q5, q5, q2 + veor q2, q2, q3 + veor q3, q3, q5 + veor q4, q4, q5 + + veor q6, q6, q3 + subs r5,r5,#1 + bcc .Lenc_done + vext.8 q8, q0, q0, #12 @ x0 <<< 32 + vext.8 q9, q1, q1, #12 + veor q0, q0, q8 @ x0 ^ (x0 <<< 32) + vext.8 q10, q4, q4, #12 + veor q1, q1, q9 + vext.8 q11, q6, q6, #12 + veor q4, q4, q10 + vext.8 q12, q3, q3, #12 + veor q6, q6, q11 + vext.8 q13, q7, q7, #12 + veor q3, q3, q12 + vext.8 q14, q2, q2, #12 + veor q7, q7, q13 + vext.8 q15, q5, q5, #12 + veor q2, q2, q14 + + veor q9, q9, q0 + veor q5, q5, q15 + vext.8 q0, q0, q0, #8 @ (x0 ^ (x0 <<< 32)) <<< 64) + veor q10, q10, q1 + veor q8, q8, q5 + veor q9, q9, q5 + vext.8 q1, q1, q1, #8 + veor q13, q13, q3 + veor q0, q0, q8 + veor q14, q14, q7 + veor q1, q1, q9 + vext.8 q8, q3, q3, #8 + veor q12, q12, q6 + vext.8 q9, q7, q7, #8 + veor q15, q15, q2 + vext.8 q3, q6, q6, #8 + veor q11, q11, q4 + vext.8 q7, q5, q5, #8 + veor q12, q12, q5 + vext.8 q6, q2, q2, #8 + veor q11, q11, q5 + vext.8 q2, q4, q4, #8 + veor q5, q9, q13 + veor q4, q8, q12 + veor q3, q3, q11 + veor q7, q7, q15 + veor q6, q6, q14 + @ vmov q4, q8 + veor q2, q2, q10 + @ vmov q5, q9 + vldmia r6, {q12} @ .LSR + ite eq @ Thumb2 thing, samity check in ARM + addeq r6,r6,#0x10 + bne .Lenc_loop + vldmia r6, {q12} @ .LSRM0 + b .Lenc_loop +.align 4 +.Lenc_done: + vmov.i8 q8,#0x55 @ compose .LBS0 + vmov.i8 q9,#0x33 @ compose .LBS1 + vshr.u64 q10, q2, #1 + vshr.u64 q11, q3, #1 + veor q10, q10, q5 + veor q11, q11, q7 + vand q10, q10, q8 + vand q11, q11, q8 + veor q5, q5, q10 + vshl.u64 q10, q10, #1 + veor q7, q7, q11 + vshl.u64 q11, q11, #1 + veor q2, q2, q10 + veor q3, q3, q11 + vshr.u64 q10, q4, #1 + vshr.u64 q11, q0, #1 + veor q10, q10, q6 + veor q11, q11, q1 + vand q10, q10, q8 + vand q11, q11, q8 + veor q6, q6, q10 + vshl.u64 q10, q10, #1 + veor q1, q1, q11 + vshl.u64 q11, q11, #1 + veor q4, q4, q10 + veor q0, q0, q11 + vmov.i8 q8,#0x0f @ compose .LBS2 + vshr.u64 q10, q7, #2 + vshr.u64 q11, q3, #2 + veor q10, q10, q5 + veor q11, q11, q2 + vand q10, q10, q9 + vand q11, q11, q9 + veor q5, q5, q10 + vshl.u64 q10, q10, #2 + veor q2, q2, q11 + vshl.u64 q11, q11, #2 + veor q7, q7, q10 + veor q3, q3, q11 + vshr.u64 q10, q1, #2 + vshr.u64 q11, q0, #2 + veor q10, q10, q6 + veor q11, q11, q4 + vand q10, q10, q9 + vand q11, q11, q9 + veor q6, q6, q10 + vshl.u64 q10, q10, #2 + veor q4, q4, q11 + vshl.u64 q11, q11, #2 + veor q1, q1, q10 + veor q0, q0, q11 + vshr.u64 q10, q6, #4 + vshr.u64 q11, q4, #4 + veor q10, q10, q5 + veor q11, q11, q2 + vand q10, q10, q8 + vand q11, q11, q8 + veor q5, q5, q10 + vshl.u64 q10, q10, #4 + veor q2, q2, q11 + vshl.u64 q11, q11, #4 + veor q6, q6, q10 + veor q4, q4, q11 + vshr.u64 q10, q1, #4 + vshr.u64 q11, q0, #4 + veor q10, q10, q7 + veor q11, q11, q3 + vand q10, q10, q8 + vand q11, q11, q8 + veor q7, q7, q10 + vshl.u64 q10, q10, #4 + veor q3, q3, q11 + vshl.u64 q11, q11, #4 + veor q1, q1, q10 + veor q0, q0, q11 + vldmia r4, {q8} @ last round key + veor q4, q4, q8 + veor q6, q6, q8 + veor q3, q3, q8 + veor q7, q7, q8 + veor q2, q2, q8 + veor q5, q5, q8 + veor q0, q0, q8 + veor q1, q1, q8 + bx lr +.size _bsaes_encrypt8,.-_bsaes_encrypt8 +.type _bsaes_key_convert,%function +.align 4 +_bsaes_key_convert: + adr r6,. + vld1.8 {q7}, [r4]! @ load round 0 key +#if defined(__thumb2__) || defined(__APPLE__) + adr r6,.LM0 +#else + sub r6,r6,#_bsaes_key_convert-.LM0 +#endif + vld1.8 {q15}, [r4]! @ load round 1 key + + vmov.i8 q8, #0x01 @ bit masks + vmov.i8 q9, #0x02 + vmov.i8 q10, #0x04 + vmov.i8 q11, #0x08 + vmov.i8 q12, #0x10 + vmov.i8 q13, #0x20 + vldmia r6, {q14} @ .LM0 + +#ifdef __ARMEL__ + vrev32.8 q7, q7 + vrev32.8 q15, q15 +#endif + sub r5,r5,#1 + vstmia r12!, {q7} @ save round 0 key + b .Lkey_loop + +.align 4 +.Lkey_loop: + vtbl.8 d14,{q15},d28 + vtbl.8 d15,{q15},d29 + vmov.i8 q6, #0x40 + vmov.i8 q15, #0x80 + + vtst.8 q0, q7, q8 + vtst.8 q1, q7, q9 + vtst.8 q2, q7, q10 + vtst.8 q3, q7, q11 + vtst.8 q4, q7, q12 + vtst.8 q5, q7, q13 + vtst.8 q6, q7, q6 + vtst.8 q7, q7, q15 + vld1.8 {q15}, [r4]! @ load next round key + vmvn q0, q0 @ "pnot" + vmvn q1, q1 + vmvn q5, q5 + vmvn q6, q6 +#ifdef __ARMEL__ + vrev32.8 q15, q15 +#endif + subs r5,r5,#1 + vstmia r12!,{q0,q1,q2,q3,q4,q5,q6,q7} @ write bit-sliced round key + bne .Lkey_loop + + vmov.i8 q7,#0x63 @ compose .L63 + @ don't save last round key + bx lr +.size _bsaes_key_convert,.-_bsaes_key_convert +.globl bsaes_ctr32_encrypt_blocks +.hidden bsaes_ctr32_encrypt_blocks +.type bsaes_ctr32_encrypt_blocks,%function +.align 5 +bsaes_ctr32_encrypt_blocks: + @ In OpenSSL, short inputs fall back to aes_nohw_* here. We patch this + @ out to retain a constant-time implementation. + mov ip, sp + stmdb sp!, {r4,r5,r6,r7,r8,r9,r10, lr} + VFP_ABI_PUSH + ldr r8, [ip] @ ctr is 1st arg on the stack + sub sp, sp, #0x10 @ scratch space to carry over the ctr + mov r9, sp @ save sp + + ldr r10, [r3, #240] @ get # of rounds +#ifndef BSAES_ASM_EXTENDED_KEY + @ allocate the key schedule on the stack + sub r12, sp, r10, lsl#7 @ 128 bytes per inner round key + add r12, #96 @ size of bit-sliced key schedule + + @ populate the key schedule + mov r4, r3 @ pass key + mov r5, r10 @ pass # of rounds + mov sp, r12 @ sp is sp + bl _bsaes_key_convert + veor q7,q7,q15 @ fix up last round key + vstmia r12, {q7} @ save last round key + + vld1.8 {q0}, [r8] @ load counter +#ifdef __APPLE__ + mov r8, #:lower16:(.LREVM0SR-.LM0) + add r8, r6, r8 +#else + add r8, r6, #.LREVM0SR-.LM0 @ borrow r8 +#endif + vldmia sp, {q4} @ load round0 key +#else + ldr r12, [r3, #244] + eors r12, #1 + beq 0f + + @ populate the key schedule + str r12, [r3, #244] + mov r4, r3 @ pass key + mov r5, r10 @ pass # of rounds + add r12, r3, #248 @ pass key schedule + bl _bsaes_key_convert + veor q7,q7,q15 @ fix up last round key + vstmia r12, {q7} @ save last round key + +.align 2 + add r12, r3, #248 + vld1.8 {q0}, [r8] @ load counter + adrl r8, .LREVM0SR @ borrow r8 + vldmia r12, {q4} @ load round0 key + sub sp, #0x10 @ place for adjusted round0 key +#endif + + vmov.i32 q8,#1 @ compose 1<<96 + veor q9,q9,q9 + vrev32.8 q0,q0 + vext.8 q8,q9,q8,#4 + vrev32.8 q4,q4 + vadd.u32 q9,q8,q8 @ compose 2<<96 + vstmia sp, {q4} @ save adjusted round0 key + b .Lctr_enc_loop + +.align 4 +.Lctr_enc_loop: + vadd.u32 q10, q8, q9 @ compose 3<<96 + vadd.u32 q1, q0, q8 @ +1 + vadd.u32 q2, q0, q9 @ +2 + vadd.u32 q3, q0, q10 @ +3 + vadd.u32 q4, q1, q10 + vadd.u32 q5, q2, q10 + vadd.u32 q6, q3, q10 + vadd.u32 q7, q4, q10 + vadd.u32 q10, q5, q10 @ next counter + + @ Borrow prologue from _bsaes_encrypt8 to use the opportunity + @ to flip byte order in 32-bit counter + + vldmia sp, {q9} @ load round0 key +#ifndef BSAES_ASM_EXTENDED_KEY + add r4, sp, #0x10 @ pass next round key +#else + add r4, r3, #264 +#endif + vldmia r8, {q8} @ .LREVM0SR + mov r5, r10 @ pass rounds + vstmia r9, {q10} @ save next counter +#ifdef __APPLE__ + mov r6, #:lower16:(.LREVM0SR-.LSR) + sub r6, r8, r6 +#else + sub r6, r8, #.LREVM0SR-.LSR @ pass constants +#endif + + bl _bsaes_encrypt8_alt + + subs r2, r2, #8 + blo .Lctr_enc_loop_done + + vld1.8 {q8,q9}, [r0]! @ load input + vld1.8 {q10,q11}, [r0]! + veor q0, q8 + veor q1, q9 + vld1.8 {q12,q13}, [r0]! + veor q4, q10 + veor q6, q11 + vld1.8 {q14,q15}, [r0]! + veor q3, q12 + vst1.8 {q0,q1}, [r1]! @ write output + veor q7, q13 + veor q2, q14 + vst1.8 {q4}, [r1]! + veor q5, q15 + vst1.8 {q6}, [r1]! + vmov.i32 q8, #1 @ compose 1<<96 + vst1.8 {q3}, [r1]! + veor q9, q9, q9 + vst1.8 {q7}, [r1]! + vext.8 q8, q9, q8, #4 + vst1.8 {q2}, [r1]! + vadd.u32 q9,q8,q8 @ compose 2<<96 + vst1.8 {q5}, [r1]! + vldmia r9, {q0} @ load counter + + bne .Lctr_enc_loop + b .Lctr_enc_done + +.align 4 +.Lctr_enc_loop_done: + add r2, r2, #8 + vld1.8 {q8}, [r0]! @ load input + veor q0, q8 + vst1.8 {q0}, [r1]! @ write output + cmp r2, #2 + blo .Lctr_enc_done + vld1.8 {q9}, [r0]! + veor q1, q9 + vst1.8 {q1}, [r1]! + beq .Lctr_enc_done + vld1.8 {q10}, [r0]! + veor q4, q10 + vst1.8 {q4}, [r1]! + cmp r2, #4 + blo .Lctr_enc_done + vld1.8 {q11}, [r0]! + veor q6, q11 + vst1.8 {q6}, [r1]! + beq .Lctr_enc_done + vld1.8 {q12}, [r0]! + veor q3, q12 + vst1.8 {q3}, [r1]! + cmp r2, #6 + blo .Lctr_enc_done + vld1.8 {q13}, [r0]! + veor q7, q13 + vst1.8 {q7}, [r1]! + beq .Lctr_enc_done + vld1.8 {q14}, [r0] + veor q2, q14 + vst1.8 {q2}, [r1]! + +.Lctr_enc_done: + vmov.i32 q0, #0 + vmov.i32 q1, #0 +#ifndef BSAES_ASM_EXTENDED_KEY +.Lctr_enc_bzero:@ wipe key schedule [if any] + vstmia sp!, {q0,q1} + cmp sp, r9 + bne .Lctr_enc_bzero +#else + vstmia sp, {q0,q1} +#endif + + mov sp, r9 + add sp, #0x10 @ add sp,r9,#0x10 is no good for thumb + VFP_ABI_POP + ldmia sp!, {r4,r5,r6,r7,r8,r9,r10, pc} @ return + + @ OpenSSL contains aes_nohw_* fallback code here. We patch this + @ out to retain a constant-time implementation. +.size bsaes_ctr32_encrypt_blocks,.-bsaes_ctr32_encrypt_blocks +#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_ARM) && defined(__ELF__) diff --git a/http/vendor/ring/pregenerated/chacha-armv4-linux32.S b/http/vendor/ring/pregenerated/chacha-armv4-linux32.S new file mode 100644 index 0000000..f058e58 --- /dev/null +++ b/http/vendor/ring/pregenerated/chacha-armv4-linux32.S @@ -0,0 +1,1449 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_ARM) && defined(__ELF__) +@ Silence ARMv8 deprecated IT instruction warnings. This file is used by both +@ ARMv7 and ARMv8 processors and does not use ARMv8 instructions. +.arch armv7-a + +.text +#if defined(__thumb2__) || defined(__clang__) +.syntax unified +#endif +#if defined(__thumb2__) +.thumb +#else +.code 32 +#endif + +#if defined(__thumb2__) || defined(__clang__) +#define ldrhsb ldrbhs +#endif + +.align 5 +.Lsigma: +.long 0x61707865,0x3320646e,0x79622d32,0x6b206574 @ endian-neutral +.Lone: +.long 1,0,0,0 + +.globl ChaCha20_ctr32_nohw +.hidden ChaCha20_ctr32_nohw +.type ChaCha20_ctr32_nohw,%function +.align 5 +ChaCha20_ctr32_nohw: + ldr r12,[sp,#0] @ pull pointer to counter and nonce + stmdb sp!,{r0,r1,r2,r4-r11,lr} + adr r14,.Lsigma + ldmia r12,{r4,r5,r6,r7} @ load counter and nonce + sub sp,sp,#4*(16) @ off-load area + stmdb sp!,{r4,r5,r6,r7} @ copy counter and nonce + ldmia r3,{r4,r5,r6,r7,r8,r9,r10,r11} @ load key + ldmia r14,{r0,r1,r2,r3} @ load sigma + stmdb sp!,{r4,r5,r6,r7,r8,r9,r10,r11} @ copy key + stmdb sp!,{r0,r1,r2,r3} @ copy sigma + str r10,[sp,#4*(16+10)] @ off-load "rx" + str r11,[sp,#4*(16+11)] @ off-load "rx" + b .Loop_outer_enter + +.align 4 +.Loop_outer: + ldmia sp,{r0,r1,r2,r3,r4,r5,r6,r7,r8,r9} @ load key material + str r11,[sp,#4*(32+2)] @ save len + str r12, [sp,#4*(32+1)] @ save inp + str r14, [sp,#4*(32+0)] @ save out +.Loop_outer_enter: + ldr r11, [sp,#4*(15)] + ldr r12,[sp,#4*(12)] @ modulo-scheduled load + ldr r10, [sp,#4*(13)] + ldr r14,[sp,#4*(14)] + str r11, [sp,#4*(16+15)] + mov r11,#10 + b .Loop + +.align 4 +.Loop: + subs r11,r11,#1 + add r0,r0,r4 + mov r12,r12,ror#16 + add r1,r1,r5 + mov r10,r10,ror#16 + eor r12,r12,r0,ror#16 + eor r10,r10,r1,ror#16 + add r8,r8,r12 + mov r4,r4,ror#20 + add r9,r9,r10 + mov r5,r5,ror#20 + eor r4,r4,r8,ror#20 + eor r5,r5,r9,ror#20 + add r0,r0,r4 + mov r12,r12,ror#24 + add r1,r1,r5 + mov r10,r10,ror#24 + eor r12,r12,r0,ror#24 + eor r10,r10,r1,ror#24 + add r8,r8,r12 + mov r4,r4,ror#25 + add r9,r9,r10 + mov r5,r5,ror#25 + str r10,[sp,#4*(16+13)] + ldr r10,[sp,#4*(16+15)] + eor r4,r4,r8,ror#25 + eor r5,r5,r9,ror#25 + str r8,[sp,#4*(16+8)] + ldr r8,[sp,#4*(16+10)] + add r2,r2,r6 + mov r14,r14,ror#16 + str r9,[sp,#4*(16+9)] + ldr r9,[sp,#4*(16+11)] + add r3,r3,r7 + mov r10,r10,ror#16 + eor r14,r14,r2,ror#16 + eor r10,r10,r3,ror#16 + add r8,r8,r14 + mov r6,r6,ror#20 + add r9,r9,r10 + mov r7,r7,ror#20 + eor r6,r6,r8,ror#20 + eor r7,r7,r9,ror#20 + add r2,r2,r6 + mov r14,r14,ror#24 + add r3,r3,r7 + mov r10,r10,ror#24 + eor r14,r14,r2,ror#24 + eor r10,r10,r3,ror#24 + add r8,r8,r14 + mov r6,r6,ror#25 + add r9,r9,r10 + mov r7,r7,ror#25 + eor r6,r6,r8,ror#25 + eor r7,r7,r9,ror#25 + add r0,r0,r5 + mov r10,r10,ror#16 + add r1,r1,r6 + mov r12,r12,ror#16 + eor r10,r10,r0,ror#16 + eor r12,r12,r1,ror#16 + add r8,r8,r10 + mov r5,r5,ror#20 + add r9,r9,r12 + mov r6,r6,ror#20 + eor r5,r5,r8,ror#20 + eor r6,r6,r9,ror#20 + add r0,r0,r5 + mov r10,r10,ror#24 + add r1,r1,r6 + mov r12,r12,ror#24 + eor r10,r10,r0,ror#24 + eor r12,r12,r1,ror#24 + add r8,r8,r10 + mov r5,r5,ror#25 + str r10,[sp,#4*(16+15)] + ldr r10,[sp,#4*(16+13)] + add r9,r9,r12 + mov r6,r6,ror#25 + eor r5,r5,r8,ror#25 + eor r6,r6,r9,ror#25 + str r8,[sp,#4*(16+10)] + ldr r8,[sp,#4*(16+8)] + add r2,r2,r7 + mov r10,r10,ror#16 + str r9,[sp,#4*(16+11)] + ldr r9,[sp,#4*(16+9)] + add r3,r3,r4 + mov r14,r14,ror#16 + eor r10,r10,r2,ror#16 + eor r14,r14,r3,ror#16 + add r8,r8,r10 + mov r7,r7,ror#20 + add r9,r9,r14 + mov r4,r4,ror#20 + eor r7,r7,r8,ror#20 + eor r4,r4,r9,ror#20 + add r2,r2,r7 + mov r10,r10,ror#24 + add r3,r3,r4 + mov r14,r14,ror#24 + eor r10,r10,r2,ror#24 + eor r14,r14,r3,ror#24 + add r8,r8,r10 + mov r7,r7,ror#25 + add r9,r9,r14 + mov r4,r4,ror#25 + eor r7,r7,r8,ror#25 + eor r4,r4,r9,ror#25 + bne .Loop + + ldr r11,[sp,#4*(32+2)] @ load len + + str r8, [sp,#4*(16+8)] @ modulo-scheduled store + str r9, [sp,#4*(16+9)] + str r12,[sp,#4*(16+12)] + str r10, [sp,#4*(16+13)] + str r14,[sp,#4*(16+14)] + + @ at this point we have first half of 512-bit result in + @ rx and second half at sp+4*(16+8) + + cmp r11,#64 @ done yet? +#ifdef __thumb2__ + itete lo +#endif + addlo r12,sp,#4*(0) @ shortcut or ... + ldrhs r12,[sp,#4*(32+1)] @ ... load inp + addlo r14,sp,#4*(0) @ shortcut or ... + ldrhs r14,[sp,#4*(32+0)] @ ... load out + + ldr r8,[sp,#4*(0)] @ load key material + ldr r9,[sp,#4*(1)] + +#if __ARM_ARCH>=6 || !defined(__ARMEB__) +# if __ARM_ARCH<7 + orr r10,r12,r14 + tst r10,#3 @ are input and output aligned? + ldr r10,[sp,#4*(2)] + bne .Lunaligned + cmp r11,#64 @ restore flags +# else + ldr r10,[sp,#4*(2)] +# endif + ldr r11,[sp,#4*(3)] + + add r0,r0,r8 @ accumulate key material + add r1,r1,r9 +# ifdef __thumb2__ + itt hs +# endif + ldrhs r8,[r12],#16 @ load input + ldrhs r9,[r12,#-12] + + add r2,r2,r10 + add r3,r3,r11 +# ifdef __thumb2__ + itt hs +# endif + ldrhs r10,[r12,#-8] + ldrhs r11,[r12,#-4] +# if __ARM_ARCH>=6 && defined(__ARMEB__) + rev r0,r0 + rev r1,r1 + rev r2,r2 + rev r3,r3 +# endif +# ifdef __thumb2__ + itt hs +# endif + eorhs r0,r0,r8 @ xor with input + eorhs r1,r1,r9 + add r8,sp,#4*(4) + str r0,[r14],#16 @ store output +# ifdef __thumb2__ + itt hs +# endif + eorhs r2,r2,r10 + eorhs r3,r3,r11 + ldmia r8,{r8,r9,r10,r11} @ load key material + str r1,[r14,#-12] + str r2,[r14,#-8] + str r3,[r14,#-4] + + add r4,r4,r8 @ accumulate key material + add r5,r5,r9 +# ifdef __thumb2__ + itt hs +# endif + ldrhs r8,[r12],#16 @ load input + ldrhs r9,[r12,#-12] + add r6,r6,r10 + add r7,r7,r11 +# ifdef __thumb2__ + itt hs +# endif + ldrhs r10,[r12,#-8] + ldrhs r11,[r12,#-4] +# if __ARM_ARCH>=6 && defined(__ARMEB__) + rev r4,r4 + rev r5,r5 + rev r6,r6 + rev r7,r7 +# endif +# ifdef __thumb2__ + itt hs +# endif + eorhs r4,r4,r8 + eorhs r5,r5,r9 + add r8,sp,#4*(8) + str r4,[r14],#16 @ store output +# ifdef __thumb2__ + itt hs +# endif + eorhs r6,r6,r10 + eorhs r7,r7,r11 + str r5,[r14,#-12] + ldmia r8,{r8,r9,r10,r11} @ load key material + str r6,[r14,#-8] + add r0,sp,#4*(16+8) + str r7,[r14,#-4] + + ldmia r0,{r0,r1,r2,r3,r4,r5,r6,r7} @ load second half + + add r0,r0,r8 @ accumulate key material + add r1,r1,r9 +# ifdef __thumb2__ + itt hs +# endif + ldrhs r8,[r12],#16 @ load input + ldrhs r9,[r12,#-12] +# ifdef __thumb2__ + itt hi +# endif + strhi r10,[sp,#4*(16+10)] @ copy "rx" while at it + strhi r11,[sp,#4*(16+11)] @ copy "rx" while at it + add r2,r2,r10 + add r3,r3,r11 +# ifdef __thumb2__ + itt hs +# endif + ldrhs r10,[r12,#-8] + ldrhs r11,[r12,#-4] +# if __ARM_ARCH>=6 && defined(__ARMEB__) + rev r0,r0 + rev r1,r1 + rev r2,r2 + rev r3,r3 +# endif +# ifdef __thumb2__ + itt hs +# endif + eorhs r0,r0,r8 + eorhs r1,r1,r9 + add r8,sp,#4*(12) + str r0,[r14],#16 @ store output +# ifdef __thumb2__ + itt hs +# endif + eorhs r2,r2,r10 + eorhs r3,r3,r11 + str r1,[r14,#-12] + ldmia r8,{r8,r9,r10,r11} @ load key material + str r2,[r14,#-8] + str r3,[r14,#-4] + + add r4,r4,r8 @ accumulate key material + add r5,r5,r9 +# ifdef __thumb2__ + itt hi +# endif + addhi r8,r8,#1 @ next counter value + strhi r8,[sp,#4*(12)] @ save next counter value +# ifdef __thumb2__ + itt hs +# endif + ldrhs r8,[r12],#16 @ load input + ldrhs r9,[r12,#-12] + add r6,r6,r10 + add r7,r7,r11 +# ifdef __thumb2__ + itt hs +# endif + ldrhs r10,[r12,#-8] + ldrhs r11,[r12,#-4] +# if __ARM_ARCH>=6 && defined(__ARMEB__) + rev r4,r4 + rev r5,r5 + rev r6,r6 + rev r7,r7 +# endif +# ifdef __thumb2__ + itt hs +# endif + eorhs r4,r4,r8 + eorhs r5,r5,r9 +# ifdef __thumb2__ + it ne +# endif + ldrne r8,[sp,#4*(32+2)] @ re-load len +# ifdef __thumb2__ + itt hs +# endif + eorhs r6,r6,r10 + eorhs r7,r7,r11 + str r4,[r14],#16 @ store output + str r5,[r14,#-12] +# ifdef __thumb2__ + it hs +# endif + subhs r11,r8,#64 @ len-=64 + str r6,[r14,#-8] + str r7,[r14,#-4] + bhi .Loop_outer + + beq .Ldone +# if __ARM_ARCH<7 + b .Ltail + +.align 4 +.Lunaligned:@ unaligned endian-neutral path + cmp r11,#64 @ restore flags +# endif +#endif +#if __ARM_ARCH<7 + ldr r11,[sp,#4*(3)] + add r0,r0,r8 @ accumulate key material + add r1,r1,r9 + add r2,r2,r10 +# ifdef __thumb2__ + itete lo +# endif + eorlo r8,r8,r8 @ zero or ... + ldrhsb r8,[r12],#16 @ ... load input + eorlo r9,r9,r9 + ldrhsb r9,[r12,#-12] + + add r3,r3,r11 +# ifdef __thumb2__ + itete lo +# endif + eorlo r10,r10,r10 + ldrhsb r10,[r12,#-8] + eorlo r11,r11,r11 + ldrhsb r11,[r12,#-4] + + eor r0,r8,r0 @ xor with input (or zero) + eor r1,r9,r1 +# ifdef __thumb2__ + itt hs +# endif + ldrhsb r8,[r12,#-15] @ load more input + ldrhsb r9,[r12,#-11] + eor r2,r10,r2 + strb r0,[r14],#16 @ store output + eor r3,r11,r3 +# ifdef __thumb2__ + itt hs +# endif + ldrhsb r10,[r12,#-7] + ldrhsb r11,[r12,#-3] + strb r1,[r14,#-12] + eor r0,r8,r0,lsr#8 + strb r2,[r14,#-8] + eor r1,r9,r1,lsr#8 +# ifdef __thumb2__ + itt hs +# endif + ldrhsb r8,[r12,#-14] @ load more input + ldrhsb r9,[r12,#-10] + strb r3,[r14,#-4] + eor r2,r10,r2,lsr#8 + strb r0,[r14,#-15] + eor r3,r11,r3,lsr#8 +# ifdef __thumb2__ + itt hs +# endif + ldrhsb r10,[r12,#-6] + ldrhsb r11,[r12,#-2] + strb r1,[r14,#-11] + eor r0,r8,r0,lsr#8 + strb r2,[r14,#-7] + eor r1,r9,r1,lsr#8 +# ifdef __thumb2__ + itt hs +# endif + ldrhsb r8,[r12,#-13] @ load more input + ldrhsb r9,[r12,#-9] + strb r3,[r14,#-3] + eor r2,r10,r2,lsr#8 + strb r0,[r14,#-14] + eor r3,r11,r3,lsr#8 +# ifdef __thumb2__ + itt hs +# endif + ldrhsb r10,[r12,#-5] + ldrhsb r11,[r12,#-1] + strb r1,[r14,#-10] + strb r2,[r14,#-6] + eor r0,r8,r0,lsr#8 + strb r3,[r14,#-2] + eor r1,r9,r1,lsr#8 + strb r0,[r14,#-13] + eor r2,r10,r2,lsr#8 + strb r1,[r14,#-9] + eor r3,r11,r3,lsr#8 + strb r2,[r14,#-5] + strb r3,[r14,#-1] + add r8,sp,#4*(4+0) + ldmia r8,{r8,r9,r10,r11} @ load key material + add r0,sp,#4*(16+8) + add r4,r4,r8 @ accumulate key material + add r5,r5,r9 + add r6,r6,r10 +# ifdef __thumb2__ + itete lo +# endif + eorlo r8,r8,r8 @ zero or ... + ldrhsb r8,[r12],#16 @ ... load input + eorlo r9,r9,r9 + ldrhsb r9,[r12,#-12] + + add r7,r7,r11 +# ifdef __thumb2__ + itete lo +# endif + eorlo r10,r10,r10 + ldrhsb r10,[r12,#-8] + eorlo r11,r11,r11 + ldrhsb r11,[r12,#-4] + + eor r4,r8,r4 @ xor with input (or zero) + eor r5,r9,r5 +# ifdef __thumb2__ + itt hs +# endif + ldrhsb r8,[r12,#-15] @ load more input + ldrhsb r9,[r12,#-11] + eor r6,r10,r6 + strb r4,[r14],#16 @ store output + eor r7,r11,r7 +# ifdef __thumb2__ + itt hs +# endif + ldrhsb r10,[r12,#-7] + ldrhsb r11,[r12,#-3] + strb r5,[r14,#-12] + eor r4,r8,r4,lsr#8 + strb r6,[r14,#-8] + eor r5,r9,r5,lsr#8 +# ifdef __thumb2__ + itt hs +# endif + ldrhsb r8,[r12,#-14] @ load more input + ldrhsb r9,[r12,#-10] + strb r7,[r14,#-4] + eor r6,r10,r6,lsr#8 + strb r4,[r14,#-15] + eor r7,r11,r7,lsr#8 +# ifdef __thumb2__ + itt hs +# endif + ldrhsb r10,[r12,#-6] + ldrhsb r11,[r12,#-2] + strb r5,[r14,#-11] + eor r4,r8,r4,lsr#8 + strb r6,[r14,#-7] + eor r5,r9,r5,lsr#8 +# ifdef __thumb2__ + itt hs +# endif + ldrhsb r8,[r12,#-13] @ load more input + ldrhsb r9,[r12,#-9] + strb r7,[r14,#-3] + eor r6,r10,r6,lsr#8 + strb r4,[r14,#-14] + eor r7,r11,r7,lsr#8 +# ifdef __thumb2__ + itt hs +# endif + ldrhsb r10,[r12,#-5] + ldrhsb r11,[r12,#-1] + strb r5,[r14,#-10] + strb r6,[r14,#-6] + eor r4,r8,r4,lsr#8 + strb r7,[r14,#-2] + eor r5,r9,r5,lsr#8 + strb r4,[r14,#-13] + eor r6,r10,r6,lsr#8 + strb r5,[r14,#-9] + eor r7,r11,r7,lsr#8 + strb r6,[r14,#-5] + strb r7,[r14,#-1] + add r8,sp,#4*(4+4) + ldmia r8,{r8,r9,r10,r11} @ load key material + ldmia r0,{r0,r1,r2,r3,r4,r5,r6,r7} @ load second half +# ifdef __thumb2__ + itt hi +# endif + strhi r10,[sp,#4*(16+10)] @ copy "rx" + strhi r11,[sp,#4*(16+11)] @ copy "rx" + add r0,r0,r8 @ accumulate key material + add r1,r1,r9 + add r2,r2,r10 +# ifdef __thumb2__ + itete lo +# endif + eorlo r8,r8,r8 @ zero or ... + ldrhsb r8,[r12],#16 @ ... load input + eorlo r9,r9,r9 + ldrhsb r9,[r12,#-12] + + add r3,r3,r11 +# ifdef __thumb2__ + itete lo +# endif + eorlo r10,r10,r10 + ldrhsb r10,[r12,#-8] + eorlo r11,r11,r11 + ldrhsb r11,[r12,#-4] + + eor r0,r8,r0 @ xor with input (or zero) + eor r1,r9,r1 +# ifdef __thumb2__ + itt hs +# endif + ldrhsb r8,[r12,#-15] @ load more input + ldrhsb r9,[r12,#-11] + eor r2,r10,r2 + strb r0,[r14],#16 @ store output + eor r3,r11,r3 +# ifdef __thumb2__ + itt hs +# endif + ldrhsb r10,[r12,#-7] + ldrhsb r11,[r12,#-3] + strb r1,[r14,#-12] + eor r0,r8,r0,lsr#8 + strb r2,[r14,#-8] + eor r1,r9,r1,lsr#8 +# ifdef __thumb2__ + itt hs +# endif + ldrhsb r8,[r12,#-14] @ load more input + ldrhsb r9,[r12,#-10] + strb r3,[r14,#-4] + eor r2,r10,r2,lsr#8 + strb r0,[r14,#-15] + eor r3,r11,r3,lsr#8 +# ifdef __thumb2__ + itt hs +# endif + ldrhsb r10,[r12,#-6] + ldrhsb r11,[r12,#-2] + strb r1,[r14,#-11] + eor r0,r8,r0,lsr#8 + strb r2,[r14,#-7] + eor r1,r9,r1,lsr#8 +# ifdef __thumb2__ + itt hs +# endif + ldrhsb r8,[r12,#-13] @ load more input + ldrhsb r9,[r12,#-9] + strb r3,[r14,#-3] + eor r2,r10,r2,lsr#8 + strb r0,[r14,#-14] + eor r3,r11,r3,lsr#8 +# ifdef __thumb2__ + itt hs +# endif + ldrhsb r10,[r12,#-5] + ldrhsb r11,[r12,#-1] + strb r1,[r14,#-10] + strb r2,[r14,#-6] + eor r0,r8,r0,lsr#8 + strb r3,[r14,#-2] + eor r1,r9,r1,lsr#8 + strb r0,[r14,#-13] + eor r2,r10,r2,lsr#8 + strb r1,[r14,#-9] + eor r3,r11,r3,lsr#8 + strb r2,[r14,#-5] + strb r3,[r14,#-1] + add r8,sp,#4*(4+8) + ldmia r8,{r8,r9,r10,r11} @ load key material + add r4,r4,r8 @ accumulate key material +# ifdef __thumb2__ + itt hi +# endif + addhi r8,r8,#1 @ next counter value + strhi r8,[sp,#4*(12)] @ save next counter value + add r5,r5,r9 + add r6,r6,r10 +# ifdef __thumb2__ + itete lo +# endif + eorlo r8,r8,r8 @ zero or ... + ldrhsb r8,[r12],#16 @ ... load input + eorlo r9,r9,r9 + ldrhsb r9,[r12,#-12] + + add r7,r7,r11 +# ifdef __thumb2__ + itete lo +# endif + eorlo r10,r10,r10 + ldrhsb r10,[r12,#-8] + eorlo r11,r11,r11 + ldrhsb r11,[r12,#-4] + + eor r4,r8,r4 @ xor with input (or zero) + eor r5,r9,r5 +# ifdef __thumb2__ + itt hs +# endif + ldrhsb r8,[r12,#-15] @ load more input + ldrhsb r9,[r12,#-11] + eor r6,r10,r6 + strb r4,[r14],#16 @ store output + eor r7,r11,r7 +# ifdef __thumb2__ + itt hs +# endif + ldrhsb r10,[r12,#-7] + ldrhsb r11,[r12,#-3] + strb r5,[r14,#-12] + eor r4,r8,r4,lsr#8 + strb r6,[r14,#-8] + eor r5,r9,r5,lsr#8 +# ifdef __thumb2__ + itt hs +# endif + ldrhsb r8,[r12,#-14] @ load more input + ldrhsb r9,[r12,#-10] + strb r7,[r14,#-4] + eor r6,r10,r6,lsr#8 + strb r4,[r14,#-15] + eor r7,r11,r7,lsr#8 +# ifdef __thumb2__ + itt hs +# endif + ldrhsb r10,[r12,#-6] + ldrhsb r11,[r12,#-2] + strb r5,[r14,#-11] + eor r4,r8,r4,lsr#8 + strb r6,[r14,#-7] + eor r5,r9,r5,lsr#8 +# ifdef __thumb2__ + itt hs +# endif + ldrhsb r8,[r12,#-13] @ load more input + ldrhsb r9,[r12,#-9] + strb r7,[r14,#-3] + eor r6,r10,r6,lsr#8 + strb r4,[r14,#-14] + eor r7,r11,r7,lsr#8 +# ifdef __thumb2__ + itt hs +# endif + ldrhsb r10,[r12,#-5] + ldrhsb r11,[r12,#-1] + strb r5,[r14,#-10] + strb r6,[r14,#-6] + eor r4,r8,r4,lsr#8 + strb r7,[r14,#-2] + eor r5,r9,r5,lsr#8 + strb r4,[r14,#-13] + eor r6,r10,r6,lsr#8 + strb r5,[r14,#-9] + eor r7,r11,r7,lsr#8 + strb r6,[r14,#-5] + strb r7,[r14,#-1] +# ifdef __thumb2__ + it ne +# endif + ldrne r8,[sp,#4*(32+2)] @ re-load len +# ifdef __thumb2__ + it hs +# endif + subhs r11,r8,#64 @ len-=64 + bhi .Loop_outer + + beq .Ldone +#endif + +.Ltail: + ldr r12,[sp,#4*(32+1)] @ load inp + add r9,sp,#4*(0) + ldr r14,[sp,#4*(32+0)] @ load out + +.Loop_tail: + ldrb r10,[r9],#1 @ read buffer on stack + ldrb r11,[r12],#1 @ read input + subs r8,r8,#1 + eor r11,r11,r10 + strb r11,[r14],#1 @ store output + bne .Loop_tail + +.Ldone: + add sp,sp,#4*(32+3) + ldmia sp!,{r4,r5,r6,r7,r8,r9,r10,r11,pc} +.size ChaCha20_ctr32_nohw,.-ChaCha20_ctr32_nohw +#if __ARM_MAX_ARCH__>=7 +.arch armv7-a +.fpu neon + +.globl ChaCha20_ctr32_neon +.hidden ChaCha20_ctr32_neon +.type ChaCha20_ctr32_neon,%function +.align 5 +ChaCha20_ctr32_neon: + ldr r12,[sp,#0] @ pull pointer to counter and nonce + stmdb sp!,{r0,r1,r2,r4-r11,lr} + adr r14,.Lsigma + vstmdb sp!,{d8,d9,d10,d11,d12,d13,d14,d15} @ ABI spec says so + stmdb sp!,{r0,r1,r2,r3} + + vld1.32 {q1,q2},[r3] @ load key + ldmia r3,{r4,r5,r6,r7,r8,r9,r10,r11} @ load key + + sub sp,sp,#4*(16+16) + vld1.32 {q3},[r12] @ load counter and nonce + add r12,sp,#4*8 + ldmia r14,{r0,r1,r2,r3} @ load sigma + vld1.32 {q0},[r14]! @ load sigma + vld1.32 {q12},[r14] @ one + vst1.32 {q2,q3},[r12] @ copy 1/2key|counter|nonce + vst1.32 {q0,q1},[sp] @ copy sigma|1/2key + + str r10,[sp,#4*(16+10)] @ off-load "rx" + str r11,[sp,#4*(16+11)] @ off-load "rx" + vshl.i32 d26,d24,#1 @ two + vstr d24,[sp,#4*(16+0)] + vshl.i32 d28,d24,#2 @ four + vstr d26,[sp,#4*(16+2)] + vmov q4,q0 + vstr d28,[sp,#4*(16+4)] + vmov q8,q0 + vmov q5,q1 + vmov q9,q1 + b .Loop_neon_enter + +.align 4 +.Loop_neon_outer: + ldmia sp,{r0,r1,r2,r3,r4,r5,r6,r7,r8,r9} @ load key material + cmp r11,#64*2 @ if len<=64*2 + bls .Lbreak_neon @ switch to integer-only + vmov q4,q0 + str r11,[sp,#4*(32+2)] @ save len + vmov q8,q0 + str r12, [sp,#4*(32+1)] @ save inp + vmov q5,q1 + str r14, [sp,#4*(32+0)] @ save out + vmov q9,q1 +.Loop_neon_enter: + ldr r11, [sp,#4*(15)] + vadd.i32 q7,q3,q12 @ counter+1 + ldr r12,[sp,#4*(12)] @ modulo-scheduled load + vmov q6,q2 + ldr r10, [sp,#4*(13)] + vmov q10,q2 + ldr r14,[sp,#4*(14)] + vadd.i32 q11,q7,q12 @ counter+2 + str r11, [sp,#4*(16+15)] + mov r11,#10 + add r12,r12,#3 @ counter+3 + b .Loop_neon + +.align 4 +.Loop_neon: + subs r11,r11,#1 + vadd.i32 q0,q0,q1 + add r0,r0,r4 + vadd.i32 q4,q4,q5 + mov r12,r12,ror#16 + vadd.i32 q8,q8,q9 + add r1,r1,r5 + veor q3,q3,q0 + mov r10,r10,ror#16 + veor q7,q7,q4 + eor r12,r12,r0,ror#16 + veor q11,q11,q8 + eor r10,r10,r1,ror#16 + vrev32.16 q3,q3 + add r8,r8,r12 + vrev32.16 q7,q7 + mov r4,r4,ror#20 + vrev32.16 q11,q11 + add r9,r9,r10 + vadd.i32 q2,q2,q3 + mov r5,r5,ror#20 + vadd.i32 q6,q6,q7 + eor r4,r4,r8,ror#20 + vadd.i32 q10,q10,q11 + eor r5,r5,r9,ror#20 + veor q12,q1,q2 + add r0,r0,r4 + veor q13,q5,q6 + mov r12,r12,ror#24 + veor q14,q9,q10 + add r1,r1,r5 + vshr.u32 q1,q12,#20 + mov r10,r10,ror#24 + vshr.u32 q5,q13,#20 + eor r12,r12,r0,ror#24 + vshr.u32 q9,q14,#20 + eor r10,r10,r1,ror#24 + vsli.32 q1,q12,#12 + add r8,r8,r12 + vsli.32 q5,q13,#12 + mov r4,r4,ror#25 + vsli.32 q9,q14,#12 + add r9,r9,r10 + vadd.i32 q0,q0,q1 + mov r5,r5,ror#25 + vadd.i32 q4,q4,q5 + str r10,[sp,#4*(16+13)] + vadd.i32 q8,q8,q9 + ldr r10,[sp,#4*(16+15)] + veor q12,q3,q0 + eor r4,r4,r8,ror#25 + veor q13,q7,q4 + eor r5,r5,r9,ror#25 + veor q14,q11,q8 + str r8,[sp,#4*(16+8)] + vshr.u32 q3,q12,#24 + ldr r8,[sp,#4*(16+10)] + vshr.u32 q7,q13,#24 + add r2,r2,r6 + vshr.u32 q11,q14,#24 + mov r14,r14,ror#16 + vsli.32 q3,q12,#8 + str r9,[sp,#4*(16+9)] + vsli.32 q7,q13,#8 + ldr r9,[sp,#4*(16+11)] + vsli.32 q11,q14,#8 + add r3,r3,r7 + vadd.i32 q2,q2,q3 + mov r10,r10,ror#16 + vadd.i32 q6,q6,q7 + eor r14,r14,r2,ror#16 + vadd.i32 q10,q10,q11 + eor r10,r10,r3,ror#16 + veor q12,q1,q2 + add r8,r8,r14 + veor q13,q5,q6 + mov r6,r6,ror#20 + veor q14,q9,q10 + add r9,r9,r10 + vshr.u32 q1,q12,#25 + mov r7,r7,ror#20 + vshr.u32 q5,q13,#25 + eor r6,r6,r8,ror#20 + vshr.u32 q9,q14,#25 + eor r7,r7,r9,ror#20 + vsli.32 q1,q12,#7 + add r2,r2,r6 + vsli.32 q5,q13,#7 + mov r14,r14,ror#24 + vsli.32 q9,q14,#7 + add r3,r3,r7 + vext.8 q2,q2,q2,#8 + mov r10,r10,ror#24 + vext.8 q6,q6,q6,#8 + eor r14,r14,r2,ror#24 + vext.8 q10,q10,q10,#8 + eor r10,r10,r3,ror#24 + vext.8 q1,q1,q1,#4 + add r8,r8,r14 + vext.8 q5,q5,q5,#4 + mov r6,r6,ror#25 + vext.8 q9,q9,q9,#4 + add r9,r9,r10 + vext.8 q3,q3,q3,#12 + mov r7,r7,ror#25 + vext.8 q7,q7,q7,#12 + eor r6,r6,r8,ror#25 + vext.8 q11,q11,q11,#12 + eor r7,r7,r9,ror#25 + vadd.i32 q0,q0,q1 + add r0,r0,r5 + vadd.i32 q4,q4,q5 + mov r10,r10,ror#16 + vadd.i32 q8,q8,q9 + add r1,r1,r6 + veor q3,q3,q0 + mov r12,r12,ror#16 + veor q7,q7,q4 + eor r10,r10,r0,ror#16 + veor q11,q11,q8 + eor r12,r12,r1,ror#16 + vrev32.16 q3,q3 + add r8,r8,r10 + vrev32.16 q7,q7 + mov r5,r5,ror#20 + vrev32.16 q11,q11 + add r9,r9,r12 + vadd.i32 q2,q2,q3 + mov r6,r6,ror#20 + vadd.i32 q6,q6,q7 + eor r5,r5,r8,ror#20 + vadd.i32 q10,q10,q11 + eor r6,r6,r9,ror#20 + veor q12,q1,q2 + add r0,r0,r5 + veor q13,q5,q6 + mov r10,r10,ror#24 + veor q14,q9,q10 + add r1,r1,r6 + vshr.u32 q1,q12,#20 + mov r12,r12,ror#24 + vshr.u32 q5,q13,#20 + eor r10,r10,r0,ror#24 + vshr.u32 q9,q14,#20 + eor r12,r12,r1,ror#24 + vsli.32 q1,q12,#12 + add r8,r8,r10 + vsli.32 q5,q13,#12 + mov r5,r5,ror#25 + vsli.32 q9,q14,#12 + str r10,[sp,#4*(16+15)] + vadd.i32 q0,q0,q1 + ldr r10,[sp,#4*(16+13)] + vadd.i32 q4,q4,q5 + add r9,r9,r12 + vadd.i32 q8,q8,q9 + mov r6,r6,ror#25 + veor q12,q3,q0 + eor r5,r5,r8,ror#25 + veor q13,q7,q4 + eor r6,r6,r9,ror#25 + veor q14,q11,q8 + str r8,[sp,#4*(16+10)] + vshr.u32 q3,q12,#24 + ldr r8,[sp,#4*(16+8)] + vshr.u32 q7,q13,#24 + add r2,r2,r7 + vshr.u32 q11,q14,#24 + mov r10,r10,ror#16 + vsli.32 q3,q12,#8 + str r9,[sp,#4*(16+11)] + vsli.32 q7,q13,#8 + ldr r9,[sp,#4*(16+9)] + vsli.32 q11,q14,#8 + add r3,r3,r4 + vadd.i32 q2,q2,q3 + mov r14,r14,ror#16 + vadd.i32 q6,q6,q7 + eor r10,r10,r2,ror#16 + vadd.i32 q10,q10,q11 + eor r14,r14,r3,ror#16 + veor q12,q1,q2 + add r8,r8,r10 + veor q13,q5,q6 + mov r7,r7,ror#20 + veor q14,q9,q10 + add r9,r9,r14 + vshr.u32 q1,q12,#25 + mov r4,r4,ror#20 + vshr.u32 q5,q13,#25 + eor r7,r7,r8,ror#20 + vshr.u32 q9,q14,#25 + eor r4,r4,r9,ror#20 + vsli.32 q1,q12,#7 + add r2,r2,r7 + vsli.32 q5,q13,#7 + mov r10,r10,ror#24 + vsli.32 q9,q14,#7 + add r3,r3,r4 + vext.8 q2,q2,q2,#8 + mov r14,r14,ror#24 + vext.8 q6,q6,q6,#8 + eor r10,r10,r2,ror#24 + vext.8 q10,q10,q10,#8 + eor r14,r14,r3,ror#24 + vext.8 q1,q1,q1,#12 + add r8,r8,r10 + vext.8 q5,q5,q5,#12 + mov r7,r7,ror#25 + vext.8 q9,q9,q9,#12 + add r9,r9,r14 + vext.8 q3,q3,q3,#4 + mov r4,r4,ror#25 + vext.8 q7,q7,q7,#4 + eor r7,r7,r8,ror#25 + vext.8 q11,q11,q11,#4 + eor r4,r4,r9,ror#25 + bne .Loop_neon + + add r11,sp,#32 + vld1.32 {q12,q13},[sp] @ load key material + vld1.32 {q14,q15},[r11] + + ldr r11,[sp,#4*(32+2)] @ load len + + str r8, [sp,#4*(16+8)] @ modulo-scheduled store + str r9, [sp,#4*(16+9)] + str r12,[sp,#4*(16+12)] + str r10, [sp,#4*(16+13)] + str r14,[sp,#4*(16+14)] + + @ at this point we have first half of 512-bit result in + @ rx and second half at sp+4*(16+8) + + ldr r12,[sp,#4*(32+1)] @ load inp + ldr r14,[sp,#4*(32+0)] @ load out + + vadd.i32 q0,q0,q12 @ accumulate key material + vadd.i32 q4,q4,q12 + vadd.i32 q8,q8,q12 + vldr d24,[sp,#4*(16+0)] @ one + + vadd.i32 q1,q1,q13 + vadd.i32 q5,q5,q13 + vadd.i32 q9,q9,q13 + vldr d26,[sp,#4*(16+2)] @ two + + vadd.i32 q2,q2,q14 + vadd.i32 q6,q6,q14 + vadd.i32 q10,q10,q14 + vadd.i32 d14,d14,d24 @ counter+1 + vadd.i32 d22,d22,d26 @ counter+2 + + vadd.i32 q3,q3,q15 + vadd.i32 q7,q7,q15 + vadd.i32 q11,q11,q15 + + cmp r11,#64*4 + blo .Ltail_neon + + vld1.8 {q12,q13},[r12]! @ load input + mov r11,sp + vld1.8 {q14,q15},[r12]! + veor q0,q0,q12 @ xor with input + veor q1,q1,q13 + vld1.8 {q12,q13},[r12]! + veor q2,q2,q14 + veor q3,q3,q15 + vld1.8 {q14,q15},[r12]! + + veor q4,q4,q12 + vst1.8 {q0,q1},[r14]! @ store output + veor q5,q5,q13 + vld1.8 {q12,q13},[r12]! + veor q6,q6,q14 + vst1.8 {q2,q3},[r14]! + veor q7,q7,q15 + vld1.8 {q14,q15},[r12]! + + veor q8,q8,q12 + vld1.32 {q0,q1},[r11]! @ load for next iteration + veor d25,d25,d25 + vldr d24,[sp,#4*(16+4)] @ four + veor q9,q9,q13 + vld1.32 {q2,q3},[r11] + veor q10,q10,q14 + vst1.8 {q4,q5},[r14]! + veor q11,q11,q15 + vst1.8 {q6,q7},[r14]! + + vadd.i32 d6,d6,d24 @ next counter value + vldr d24,[sp,#4*(16+0)] @ one + + ldmia sp,{r8,r9,r10,r11} @ load key material + add r0,r0,r8 @ accumulate key material + ldr r8,[r12],#16 @ load input + vst1.8 {q8,q9},[r14]! + add r1,r1,r9 + ldr r9,[r12,#-12] + vst1.8 {q10,q11},[r14]! + add r2,r2,r10 + ldr r10,[r12,#-8] + add r3,r3,r11 + ldr r11,[r12,#-4] +# ifdef __ARMEB__ + rev r0,r0 + rev r1,r1 + rev r2,r2 + rev r3,r3 +# endif + eor r0,r0,r8 @ xor with input + add r8,sp,#4*(4) + eor r1,r1,r9 + str r0,[r14],#16 @ store output + eor r2,r2,r10 + str r1,[r14,#-12] + eor r3,r3,r11 + ldmia r8,{r8,r9,r10,r11} @ load key material + str r2,[r14,#-8] + str r3,[r14,#-4] + + add r4,r4,r8 @ accumulate key material + ldr r8,[r12],#16 @ load input + add r5,r5,r9 + ldr r9,[r12,#-12] + add r6,r6,r10 + ldr r10,[r12,#-8] + add r7,r7,r11 + ldr r11,[r12,#-4] +# ifdef __ARMEB__ + rev r4,r4 + rev r5,r5 + rev r6,r6 + rev r7,r7 +# endif + eor r4,r4,r8 + add r8,sp,#4*(8) + eor r5,r5,r9 + str r4,[r14],#16 @ store output + eor r6,r6,r10 + str r5,[r14,#-12] + eor r7,r7,r11 + ldmia r8,{r8,r9,r10,r11} @ load key material + str r6,[r14,#-8] + add r0,sp,#4*(16+8) + str r7,[r14,#-4] + + ldmia r0,{r0,r1,r2,r3,r4,r5,r6,r7} @ load second half + + add r0,r0,r8 @ accumulate key material + ldr r8,[r12],#16 @ load input + add r1,r1,r9 + ldr r9,[r12,#-12] +# ifdef __thumb2__ + it hi +# endif + strhi r10,[sp,#4*(16+10)] @ copy "rx" while at it + add r2,r2,r10 + ldr r10,[r12,#-8] +# ifdef __thumb2__ + it hi +# endif + strhi r11,[sp,#4*(16+11)] @ copy "rx" while at it + add r3,r3,r11 + ldr r11,[r12,#-4] +# ifdef __ARMEB__ + rev r0,r0 + rev r1,r1 + rev r2,r2 + rev r3,r3 +# endif + eor r0,r0,r8 + add r8,sp,#4*(12) + eor r1,r1,r9 + str r0,[r14],#16 @ store output + eor r2,r2,r10 + str r1,[r14,#-12] + eor r3,r3,r11 + ldmia r8,{r8,r9,r10,r11} @ load key material + str r2,[r14,#-8] + str r3,[r14,#-4] + + add r4,r4,r8 @ accumulate key material + add r8,r8,#4 @ next counter value + add r5,r5,r9 + str r8,[sp,#4*(12)] @ save next counter value + ldr r8,[r12],#16 @ load input + add r6,r6,r10 + add r4,r4,#3 @ counter+3 + ldr r9,[r12,#-12] + add r7,r7,r11 + ldr r10,[r12,#-8] + ldr r11,[r12,#-4] +# ifdef __ARMEB__ + rev r4,r4 + rev r5,r5 + rev r6,r6 + rev r7,r7 +# endif + eor r4,r4,r8 +# ifdef __thumb2__ + it hi +# endif + ldrhi r8,[sp,#4*(32+2)] @ re-load len + eor r5,r5,r9 + eor r6,r6,r10 + str r4,[r14],#16 @ store output + eor r7,r7,r11 + str r5,[r14,#-12] + sub r11,r8,#64*4 @ len-=64*4 + str r6,[r14,#-8] + str r7,[r14,#-4] + bhi .Loop_neon_outer + + b .Ldone_neon + +.align 4 +.Lbreak_neon: + @ harmonize NEON and integer-only stack frames: load data + @ from NEON frame, but save to integer-only one; distance + @ between the two is 4*(32+4+16-32)=4*(20). + + str r11, [sp,#4*(20+32+2)] @ save len + add r11,sp,#4*(32+4) + str r12, [sp,#4*(20+32+1)] @ save inp + str r14, [sp,#4*(20+32+0)] @ save out + + ldr r12,[sp,#4*(16+10)] + ldr r14,[sp,#4*(16+11)] + vldmia r11,{d8,d9,d10,d11,d12,d13,d14,d15} @ fulfill ABI requirement + str r12,[sp,#4*(20+16+10)] @ copy "rx" + str r14,[sp,#4*(20+16+11)] @ copy "rx" + + ldr r11, [sp,#4*(15)] + ldr r12,[sp,#4*(12)] @ modulo-scheduled load + ldr r10, [sp,#4*(13)] + ldr r14,[sp,#4*(14)] + str r11, [sp,#4*(20+16+15)] + add r11,sp,#4*(20) + vst1.32 {q0,q1},[r11]! @ copy key + add sp,sp,#4*(20) @ switch frame + vst1.32 {q2,q3},[r11] + mov r11,#10 + b .Loop @ go integer-only + +.align 4 +.Ltail_neon: + cmp r11,#64*3 + bhs .L192_or_more_neon + cmp r11,#64*2 + bhs .L128_or_more_neon + cmp r11,#64*1 + bhs .L64_or_more_neon + + add r8,sp,#4*(8) + vst1.8 {q0,q1},[sp] + add r10,sp,#4*(0) + vst1.8 {q2,q3},[r8] + b .Loop_tail_neon + +.align 4 +.L64_or_more_neon: + vld1.8 {q12,q13},[r12]! + vld1.8 {q14,q15},[r12]! + veor q0,q0,q12 + veor q1,q1,q13 + veor q2,q2,q14 + veor q3,q3,q15 + vst1.8 {q0,q1},[r14]! + vst1.8 {q2,q3},[r14]! + + beq .Ldone_neon + + add r8,sp,#4*(8) + vst1.8 {q4,q5},[sp] + add r10,sp,#4*(0) + vst1.8 {q6,q7},[r8] + sub r11,r11,#64*1 @ len-=64*1 + b .Loop_tail_neon + +.align 4 +.L128_or_more_neon: + vld1.8 {q12,q13},[r12]! + vld1.8 {q14,q15},[r12]! + veor q0,q0,q12 + veor q1,q1,q13 + vld1.8 {q12,q13},[r12]! + veor q2,q2,q14 + veor q3,q3,q15 + vld1.8 {q14,q15},[r12]! + + veor q4,q4,q12 + veor q5,q5,q13 + vst1.8 {q0,q1},[r14]! + veor q6,q6,q14 + vst1.8 {q2,q3},[r14]! + veor q7,q7,q15 + vst1.8 {q4,q5},[r14]! + vst1.8 {q6,q7},[r14]! + + beq .Ldone_neon + + add r8,sp,#4*(8) + vst1.8 {q8,q9},[sp] + add r10,sp,#4*(0) + vst1.8 {q10,q11},[r8] + sub r11,r11,#64*2 @ len-=64*2 + b .Loop_tail_neon + +.align 4 +.L192_or_more_neon: + vld1.8 {q12,q13},[r12]! + vld1.8 {q14,q15},[r12]! + veor q0,q0,q12 + veor q1,q1,q13 + vld1.8 {q12,q13},[r12]! + veor q2,q2,q14 + veor q3,q3,q15 + vld1.8 {q14,q15},[r12]! + + veor q4,q4,q12 + veor q5,q5,q13 + vld1.8 {q12,q13},[r12]! + veor q6,q6,q14 + vst1.8 {q0,q1},[r14]! + veor q7,q7,q15 + vld1.8 {q14,q15},[r12]! + + veor q8,q8,q12 + vst1.8 {q2,q3},[r14]! + veor q9,q9,q13 + vst1.8 {q4,q5},[r14]! + veor q10,q10,q14 + vst1.8 {q6,q7},[r14]! + veor q11,q11,q15 + vst1.8 {q8,q9},[r14]! + vst1.8 {q10,q11},[r14]! + + beq .Ldone_neon + + ldmia sp,{r8,r9,r10,r11} @ load key material + add r0,r0,r8 @ accumulate key material + add r8,sp,#4*(4) + add r1,r1,r9 + add r2,r2,r10 + add r3,r3,r11 + ldmia r8,{r8,r9,r10,r11} @ load key material + + add r4,r4,r8 @ accumulate key material + add r8,sp,#4*(8) + add r5,r5,r9 + add r6,r6,r10 + add r7,r7,r11 + ldmia r8,{r8,r9,r10,r11} @ load key material +# ifdef __ARMEB__ + rev r0,r0 + rev r1,r1 + rev r2,r2 + rev r3,r3 + rev r4,r4 + rev r5,r5 + rev r6,r6 + rev r7,r7 +# endif + stmia sp,{r0,r1,r2,r3,r4,r5,r6,r7} + add r0,sp,#4*(16+8) + + ldmia r0,{r0,r1,r2,r3,r4,r5,r6,r7} @ load second half + + add r0,r0,r8 @ accumulate key material + add r8,sp,#4*(12) + add r1,r1,r9 + add r2,r2,r10 + add r3,r3,r11 + ldmia r8,{r8,r9,r10,r11} @ load key material + + add r4,r4,r8 @ accumulate key material + add r8,sp,#4*(8) + add r5,r5,r9 + add r4,r4,#3 @ counter+3 + add r6,r6,r10 + add r7,r7,r11 + ldr r11,[sp,#4*(32+2)] @ re-load len +# ifdef __ARMEB__ + rev r0,r0 + rev r1,r1 + rev r2,r2 + rev r3,r3 + rev r4,r4 + rev r5,r5 + rev r6,r6 + rev r7,r7 +# endif + stmia r8,{r0,r1,r2,r3,r4,r5,r6,r7} + add r10,sp,#4*(0) + sub r11,r11,#64*3 @ len-=64*3 + +.Loop_tail_neon: + ldrb r8,[r10],#1 @ read buffer on stack + ldrb r9,[r12],#1 @ read input + subs r11,r11,#1 + eor r8,r8,r9 + strb r8,[r14],#1 @ store output + bne .Loop_tail_neon + +.Ldone_neon: + add sp,sp,#4*(32+4) + vldmia sp,{d8,d9,d10,d11,d12,d13,d14,d15} + add sp,sp,#4*(16+3) + ldmia sp!,{r4,r5,r6,r7,r8,r9,r10,r11,pc} +.size ChaCha20_ctr32_neon,.-ChaCha20_ctr32_neon +#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_ARM) && defined(__ELF__) diff --git a/http/vendor/ring/pregenerated/chacha-armv8-ios64.S b/http/vendor/ring/pregenerated/chacha-armv8-ios64.S new file mode 100644 index 0000000..322f67e --- /dev/null +++ b/http/vendor/ring/pregenerated/chacha-armv8-ios64.S @@ -0,0 +1,1966 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__APPLE__) +.section __TEXT,__const + +.align 5 +Lsigma: +.quad 0x3320646e61707865,0x6b20657479622d32 // endian-neutral +Lone: +.long 1,0,0,0 +.byte 67,104,97,67,104,97,50,48,32,102,111,114,32,65,82,77,118,56,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.align 2 + +.text + +.globl _ChaCha20_ctr32_nohw +.private_extern _ChaCha20_ctr32_nohw + +.align 5 +_ChaCha20_ctr32_nohw: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-96]! + add x29,sp,#0 + + adrp x5,Lsigma@PAGE + add x5,x5,Lsigma@PAGEOFF + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + stp x27,x28,[sp,#80] + sub sp,sp,#64 + + ldp x22,x23,[x5] // load sigma + ldp x24,x25,[x3] // load key + ldp x26,x27,[x3,#16] + ldp x28,x30,[x4] // load counter +#ifdef __AARCH64EB__ + ror x24,x24,#32 + ror x25,x25,#32 + ror x26,x26,#32 + ror x27,x27,#32 + ror x28,x28,#32 + ror x30,x30,#32 +#endif + +Loop_outer: + mov w5,w22 // unpack key block + lsr x6,x22,#32 + mov w7,w23 + lsr x8,x23,#32 + mov w9,w24 + lsr x10,x24,#32 + mov w11,w25 + lsr x12,x25,#32 + mov w13,w26 + lsr x14,x26,#32 + mov w15,w27 + lsr x16,x27,#32 + mov w17,w28 + lsr x19,x28,#32 + mov w20,w30 + lsr x21,x30,#32 + + mov x4,#10 + subs x2,x2,#64 +Loop: + sub x4,x4,#1 + add w5,w5,w9 + add w6,w6,w10 + add w7,w7,w11 + add w8,w8,w12 + eor w17,w17,w5 + eor w19,w19,w6 + eor w20,w20,w7 + eor w21,w21,w8 + ror w17,w17,#16 + ror w19,w19,#16 + ror w20,w20,#16 + ror w21,w21,#16 + add w13,w13,w17 + add w14,w14,w19 + add w15,w15,w20 + add w16,w16,w21 + eor w9,w9,w13 + eor w10,w10,w14 + eor w11,w11,w15 + eor w12,w12,w16 + ror w9,w9,#20 + ror w10,w10,#20 + ror w11,w11,#20 + ror w12,w12,#20 + add w5,w5,w9 + add w6,w6,w10 + add w7,w7,w11 + add w8,w8,w12 + eor w17,w17,w5 + eor w19,w19,w6 + eor w20,w20,w7 + eor w21,w21,w8 + ror w17,w17,#24 + ror w19,w19,#24 + ror w20,w20,#24 + ror w21,w21,#24 + add w13,w13,w17 + add w14,w14,w19 + add w15,w15,w20 + add w16,w16,w21 + eor w9,w9,w13 + eor w10,w10,w14 + eor w11,w11,w15 + eor w12,w12,w16 + ror w9,w9,#25 + ror w10,w10,#25 + ror w11,w11,#25 + ror w12,w12,#25 + add w5,w5,w10 + add w6,w6,w11 + add w7,w7,w12 + add w8,w8,w9 + eor w21,w21,w5 + eor w17,w17,w6 + eor w19,w19,w7 + eor w20,w20,w8 + ror w21,w21,#16 + ror w17,w17,#16 + ror w19,w19,#16 + ror w20,w20,#16 + add w15,w15,w21 + add w16,w16,w17 + add w13,w13,w19 + add w14,w14,w20 + eor w10,w10,w15 + eor w11,w11,w16 + eor w12,w12,w13 + eor w9,w9,w14 + ror w10,w10,#20 + ror w11,w11,#20 + ror w12,w12,#20 + ror w9,w9,#20 + add w5,w5,w10 + add w6,w6,w11 + add w7,w7,w12 + add w8,w8,w9 + eor w21,w21,w5 + eor w17,w17,w6 + eor w19,w19,w7 + eor w20,w20,w8 + ror w21,w21,#24 + ror w17,w17,#24 + ror w19,w19,#24 + ror w20,w20,#24 + add w15,w15,w21 + add w16,w16,w17 + add w13,w13,w19 + add w14,w14,w20 + eor w10,w10,w15 + eor w11,w11,w16 + eor w12,w12,w13 + eor w9,w9,w14 + ror w10,w10,#25 + ror w11,w11,#25 + ror w12,w12,#25 + ror w9,w9,#25 + cbnz x4,Loop + + add w5,w5,w22 // accumulate key block + add x6,x6,x22,lsr#32 + add w7,w7,w23 + add x8,x8,x23,lsr#32 + add w9,w9,w24 + add x10,x10,x24,lsr#32 + add w11,w11,w25 + add x12,x12,x25,lsr#32 + add w13,w13,w26 + add x14,x14,x26,lsr#32 + add w15,w15,w27 + add x16,x16,x27,lsr#32 + add w17,w17,w28 + add x19,x19,x28,lsr#32 + add w20,w20,w30 + add x21,x21,x30,lsr#32 + + b.lo Ltail + + add x5,x5,x6,lsl#32 // pack + add x7,x7,x8,lsl#32 + ldp x6,x8,[x1,#0] // load input + add x9,x9,x10,lsl#32 + add x11,x11,x12,lsl#32 + ldp x10,x12,[x1,#16] + add x13,x13,x14,lsl#32 + add x15,x15,x16,lsl#32 + ldp x14,x16,[x1,#32] + add x17,x17,x19,lsl#32 + add x20,x20,x21,lsl#32 + ldp x19,x21,[x1,#48] + add x1,x1,#64 +#ifdef __AARCH64EB__ + rev x5,x5 + rev x7,x7 + rev x9,x9 + rev x11,x11 + rev x13,x13 + rev x15,x15 + rev x17,x17 + rev x20,x20 +#endif + eor x5,x5,x6 + eor x7,x7,x8 + eor x9,x9,x10 + eor x11,x11,x12 + eor x13,x13,x14 + eor x15,x15,x16 + eor x17,x17,x19 + eor x20,x20,x21 + + stp x5,x7,[x0,#0] // store output + add x28,x28,#1 // increment counter + stp x9,x11,[x0,#16] + stp x13,x15,[x0,#32] + stp x17,x20,[x0,#48] + add x0,x0,#64 + + b.hi Loop_outer + + ldp x19,x20,[x29,#16] + add sp,sp,#64 + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldp x29,x30,[sp],#96 + AARCH64_VALIDATE_LINK_REGISTER + ret + +.align 4 +Ltail: + add x2,x2,#64 +Less_than_64: + sub x0,x0,#1 + add x1,x1,x2 + add x0,x0,x2 + add x4,sp,x2 + neg x2,x2 + + add x5,x5,x6,lsl#32 // pack + add x7,x7,x8,lsl#32 + add x9,x9,x10,lsl#32 + add x11,x11,x12,lsl#32 + add x13,x13,x14,lsl#32 + add x15,x15,x16,lsl#32 + add x17,x17,x19,lsl#32 + add x20,x20,x21,lsl#32 +#ifdef __AARCH64EB__ + rev x5,x5 + rev x7,x7 + rev x9,x9 + rev x11,x11 + rev x13,x13 + rev x15,x15 + rev x17,x17 + rev x20,x20 +#endif + stp x5,x7,[sp,#0] + stp x9,x11,[sp,#16] + stp x13,x15,[sp,#32] + stp x17,x20,[sp,#48] + +Loop_tail: + ldrb w10,[x1,x2] + ldrb w11,[x4,x2] + add x2,x2,#1 + eor w10,w10,w11 + strb w10,[x0,x2] + cbnz x2,Loop_tail + + stp xzr,xzr,[sp,#0] + stp xzr,xzr,[sp,#16] + stp xzr,xzr,[sp,#32] + stp xzr,xzr,[sp,#48] + + ldp x19,x20,[x29,#16] + add sp,sp,#64 + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldp x29,x30,[sp],#96 + AARCH64_VALIDATE_LINK_REGISTER + ret + + +.globl _ChaCha20_ctr32_neon +.private_extern _ChaCha20_ctr32_neon + +.align 5 +_ChaCha20_ctr32_neon: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-96]! + add x29,sp,#0 + + adrp x5,Lsigma@PAGE + add x5,x5,Lsigma@PAGEOFF + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + stp x27,x28,[sp,#80] + cmp x2,#512 + b.hs L512_or_more_neon + + sub sp,sp,#64 + + ldp x22,x23,[x5] // load sigma + ld1 {v24.4s},[x5],#16 + ldp x24,x25,[x3] // load key + ldp x26,x27,[x3,#16] + ld1 {v25.4s,v26.4s},[x3] + ldp x28,x30,[x4] // load counter + ld1 {v27.4s},[x4] + ld1 {v31.4s},[x5] +#ifdef __AARCH64EB__ + rev64 v24.4s,v24.4s + ror x24,x24,#32 + ror x25,x25,#32 + ror x26,x26,#32 + ror x27,x27,#32 + ror x28,x28,#32 + ror x30,x30,#32 +#endif + add v27.4s,v27.4s,v31.4s // += 1 + add v28.4s,v27.4s,v31.4s + add v29.4s,v28.4s,v31.4s + shl v31.4s,v31.4s,#2 // 1 -> 4 + +Loop_outer_neon: + mov w5,w22 // unpack key block + lsr x6,x22,#32 + mov v0.16b,v24.16b + mov w7,w23 + lsr x8,x23,#32 + mov v4.16b,v24.16b + mov w9,w24 + lsr x10,x24,#32 + mov v16.16b,v24.16b + mov w11,w25 + mov v1.16b,v25.16b + lsr x12,x25,#32 + mov v5.16b,v25.16b + mov w13,w26 + mov v17.16b,v25.16b + lsr x14,x26,#32 + mov v3.16b,v27.16b + mov w15,w27 + mov v7.16b,v28.16b + lsr x16,x27,#32 + mov v19.16b,v29.16b + mov w17,w28 + mov v2.16b,v26.16b + lsr x19,x28,#32 + mov v6.16b,v26.16b + mov w20,w30 + mov v18.16b,v26.16b + lsr x21,x30,#32 + + mov x4,#10 + subs x2,x2,#256 +Loop_neon: + sub x4,x4,#1 + add v0.4s,v0.4s,v1.4s + add w5,w5,w9 + add v4.4s,v4.4s,v5.4s + add w6,w6,w10 + add v16.4s,v16.4s,v17.4s + add w7,w7,w11 + eor v3.16b,v3.16b,v0.16b + add w8,w8,w12 + eor v7.16b,v7.16b,v4.16b + eor w17,w17,w5 + eor v19.16b,v19.16b,v16.16b + eor w19,w19,w6 + rev32 v3.8h,v3.8h + eor w20,w20,w7 + rev32 v7.8h,v7.8h + eor w21,w21,w8 + rev32 v19.8h,v19.8h + ror w17,w17,#16 + add v2.4s,v2.4s,v3.4s + ror w19,w19,#16 + add v6.4s,v6.4s,v7.4s + ror w20,w20,#16 + add v18.4s,v18.4s,v19.4s + ror w21,w21,#16 + eor v20.16b,v1.16b,v2.16b + add w13,w13,w17 + eor v21.16b,v5.16b,v6.16b + add w14,w14,w19 + eor v22.16b,v17.16b,v18.16b + add w15,w15,w20 + ushr v1.4s,v20.4s,#20 + add w16,w16,w21 + ushr v5.4s,v21.4s,#20 + eor w9,w9,w13 + ushr v17.4s,v22.4s,#20 + eor w10,w10,w14 + sli v1.4s,v20.4s,#12 + eor w11,w11,w15 + sli v5.4s,v21.4s,#12 + eor w12,w12,w16 + sli v17.4s,v22.4s,#12 + ror w9,w9,#20 + add v0.4s,v0.4s,v1.4s + ror w10,w10,#20 + add v4.4s,v4.4s,v5.4s + ror w11,w11,#20 + add v16.4s,v16.4s,v17.4s + ror w12,w12,#20 + eor v20.16b,v3.16b,v0.16b + add w5,w5,w9 + eor v21.16b,v7.16b,v4.16b + add w6,w6,w10 + eor v22.16b,v19.16b,v16.16b + add w7,w7,w11 + ushr v3.4s,v20.4s,#24 + add w8,w8,w12 + ushr v7.4s,v21.4s,#24 + eor w17,w17,w5 + ushr v19.4s,v22.4s,#24 + eor w19,w19,w6 + sli v3.4s,v20.4s,#8 + eor w20,w20,w7 + sli v7.4s,v21.4s,#8 + eor w21,w21,w8 + sli v19.4s,v22.4s,#8 + ror w17,w17,#24 + add v2.4s,v2.4s,v3.4s + ror w19,w19,#24 + add v6.4s,v6.4s,v7.4s + ror w20,w20,#24 + add v18.4s,v18.4s,v19.4s + ror w21,w21,#24 + eor v20.16b,v1.16b,v2.16b + add w13,w13,w17 + eor v21.16b,v5.16b,v6.16b + add w14,w14,w19 + eor v22.16b,v17.16b,v18.16b + add w15,w15,w20 + ushr v1.4s,v20.4s,#25 + add w16,w16,w21 + ushr v5.4s,v21.4s,#25 + eor w9,w9,w13 + ushr v17.4s,v22.4s,#25 + eor w10,w10,w14 + sli v1.4s,v20.4s,#7 + eor w11,w11,w15 + sli v5.4s,v21.4s,#7 + eor w12,w12,w16 + sli v17.4s,v22.4s,#7 + ror w9,w9,#25 + ext v2.16b,v2.16b,v2.16b,#8 + ror w10,w10,#25 + ext v6.16b,v6.16b,v6.16b,#8 + ror w11,w11,#25 + ext v18.16b,v18.16b,v18.16b,#8 + ror w12,w12,#25 + ext v3.16b,v3.16b,v3.16b,#12 + ext v7.16b,v7.16b,v7.16b,#12 + ext v19.16b,v19.16b,v19.16b,#12 + ext v1.16b,v1.16b,v1.16b,#4 + ext v5.16b,v5.16b,v5.16b,#4 + ext v17.16b,v17.16b,v17.16b,#4 + add v0.4s,v0.4s,v1.4s + add w5,w5,w10 + add v4.4s,v4.4s,v5.4s + add w6,w6,w11 + add v16.4s,v16.4s,v17.4s + add w7,w7,w12 + eor v3.16b,v3.16b,v0.16b + add w8,w8,w9 + eor v7.16b,v7.16b,v4.16b + eor w21,w21,w5 + eor v19.16b,v19.16b,v16.16b + eor w17,w17,w6 + rev32 v3.8h,v3.8h + eor w19,w19,w7 + rev32 v7.8h,v7.8h + eor w20,w20,w8 + rev32 v19.8h,v19.8h + ror w21,w21,#16 + add v2.4s,v2.4s,v3.4s + ror w17,w17,#16 + add v6.4s,v6.4s,v7.4s + ror w19,w19,#16 + add v18.4s,v18.4s,v19.4s + ror w20,w20,#16 + eor v20.16b,v1.16b,v2.16b + add w15,w15,w21 + eor v21.16b,v5.16b,v6.16b + add w16,w16,w17 + eor v22.16b,v17.16b,v18.16b + add w13,w13,w19 + ushr v1.4s,v20.4s,#20 + add w14,w14,w20 + ushr v5.4s,v21.4s,#20 + eor w10,w10,w15 + ushr v17.4s,v22.4s,#20 + eor w11,w11,w16 + sli v1.4s,v20.4s,#12 + eor w12,w12,w13 + sli v5.4s,v21.4s,#12 + eor w9,w9,w14 + sli v17.4s,v22.4s,#12 + ror w10,w10,#20 + add v0.4s,v0.4s,v1.4s + ror w11,w11,#20 + add v4.4s,v4.4s,v5.4s + ror w12,w12,#20 + add v16.4s,v16.4s,v17.4s + ror w9,w9,#20 + eor v20.16b,v3.16b,v0.16b + add w5,w5,w10 + eor v21.16b,v7.16b,v4.16b + add w6,w6,w11 + eor v22.16b,v19.16b,v16.16b + add w7,w7,w12 + ushr v3.4s,v20.4s,#24 + add w8,w8,w9 + ushr v7.4s,v21.4s,#24 + eor w21,w21,w5 + ushr v19.4s,v22.4s,#24 + eor w17,w17,w6 + sli v3.4s,v20.4s,#8 + eor w19,w19,w7 + sli v7.4s,v21.4s,#8 + eor w20,w20,w8 + sli v19.4s,v22.4s,#8 + ror w21,w21,#24 + add v2.4s,v2.4s,v3.4s + ror w17,w17,#24 + add v6.4s,v6.4s,v7.4s + ror w19,w19,#24 + add v18.4s,v18.4s,v19.4s + ror w20,w20,#24 + eor v20.16b,v1.16b,v2.16b + add w15,w15,w21 + eor v21.16b,v5.16b,v6.16b + add w16,w16,w17 + eor v22.16b,v17.16b,v18.16b + add w13,w13,w19 + ushr v1.4s,v20.4s,#25 + add w14,w14,w20 + ushr v5.4s,v21.4s,#25 + eor w10,w10,w15 + ushr v17.4s,v22.4s,#25 + eor w11,w11,w16 + sli v1.4s,v20.4s,#7 + eor w12,w12,w13 + sli v5.4s,v21.4s,#7 + eor w9,w9,w14 + sli v17.4s,v22.4s,#7 + ror w10,w10,#25 + ext v2.16b,v2.16b,v2.16b,#8 + ror w11,w11,#25 + ext v6.16b,v6.16b,v6.16b,#8 + ror w12,w12,#25 + ext v18.16b,v18.16b,v18.16b,#8 + ror w9,w9,#25 + ext v3.16b,v3.16b,v3.16b,#4 + ext v7.16b,v7.16b,v7.16b,#4 + ext v19.16b,v19.16b,v19.16b,#4 + ext v1.16b,v1.16b,v1.16b,#12 + ext v5.16b,v5.16b,v5.16b,#12 + ext v17.16b,v17.16b,v17.16b,#12 + cbnz x4,Loop_neon + + add w5,w5,w22 // accumulate key block + add v0.4s,v0.4s,v24.4s + add x6,x6,x22,lsr#32 + add v4.4s,v4.4s,v24.4s + add w7,w7,w23 + add v16.4s,v16.4s,v24.4s + add x8,x8,x23,lsr#32 + add v2.4s,v2.4s,v26.4s + add w9,w9,w24 + add v6.4s,v6.4s,v26.4s + add x10,x10,x24,lsr#32 + add v18.4s,v18.4s,v26.4s + add w11,w11,w25 + add v3.4s,v3.4s,v27.4s + add x12,x12,x25,lsr#32 + add w13,w13,w26 + add v7.4s,v7.4s,v28.4s + add x14,x14,x26,lsr#32 + add w15,w15,w27 + add v19.4s,v19.4s,v29.4s + add x16,x16,x27,lsr#32 + add w17,w17,w28 + add v1.4s,v1.4s,v25.4s + add x19,x19,x28,lsr#32 + add w20,w20,w30 + add v5.4s,v5.4s,v25.4s + add x21,x21,x30,lsr#32 + add v17.4s,v17.4s,v25.4s + + b.lo Ltail_neon + + add x5,x5,x6,lsl#32 // pack + add x7,x7,x8,lsl#32 + ldp x6,x8,[x1,#0] // load input + add x9,x9,x10,lsl#32 + add x11,x11,x12,lsl#32 + ldp x10,x12,[x1,#16] + add x13,x13,x14,lsl#32 + add x15,x15,x16,lsl#32 + ldp x14,x16,[x1,#32] + add x17,x17,x19,lsl#32 + add x20,x20,x21,lsl#32 + ldp x19,x21,[x1,#48] + add x1,x1,#64 +#ifdef __AARCH64EB__ + rev x5,x5 + rev x7,x7 + rev x9,x9 + rev x11,x11 + rev x13,x13 + rev x15,x15 + rev x17,x17 + rev x20,x20 +#endif + ld1 {v20.16b,v21.16b,v22.16b,v23.16b},[x1],#64 + eor x5,x5,x6 + eor x7,x7,x8 + eor x9,x9,x10 + eor x11,x11,x12 + eor x13,x13,x14 + eor v0.16b,v0.16b,v20.16b + eor x15,x15,x16 + eor v1.16b,v1.16b,v21.16b + eor x17,x17,x19 + eor v2.16b,v2.16b,v22.16b + eor x20,x20,x21 + eor v3.16b,v3.16b,v23.16b + ld1 {v20.16b,v21.16b,v22.16b,v23.16b},[x1],#64 + + stp x5,x7,[x0,#0] // store output + add x28,x28,#4 // increment counter + stp x9,x11,[x0,#16] + add v27.4s,v27.4s,v31.4s // += 4 + stp x13,x15,[x0,#32] + add v28.4s,v28.4s,v31.4s + stp x17,x20,[x0,#48] + add v29.4s,v29.4s,v31.4s + add x0,x0,#64 + + st1 {v0.16b,v1.16b,v2.16b,v3.16b},[x0],#64 + ld1 {v0.16b,v1.16b,v2.16b,v3.16b},[x1],#64 + + eor v4.16b,v4.16b,v20.16b + eor v5.16b,v5.16b,v21.16b + eor v6.16b,v6.16b,v22.16b + eor v7.16b,v7.16b,v23.16b + st1 {v4.16b,v5.16b,v6.16b,v7.16b},[x0],#64 + + eor v16.16b,v16.16b,v0.16b + eor v17.16b,v17.16b,v1.16b + eor v18.16b,v18.16b,v2.16b + eor v19.16b,v19.16b,v3.16b + st1 {v16.16b,v17.16b,v18.16b,v19.16b},[x0],#64 + + b.hi Loop_outer_neon + + ldp x19,x20,[x29,#16] + add sp,sp,#64 + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldp x29,x30,[sp],#96 + AARCH64_VALIDATE_LINK_REGISTER + ret + +Ltail_neon: + add x2,x2,#256 + cmp x2,#64 + b.lo Less_than_64 + + add x5,x5,x6,lsl#32 // pack + add x7,x7,x8,lsl#32 + ldp x6,x8,[x1,#0] // load input + add x9,x9,x10,lsl#32 + add x11,x11,x12,lsl#32 + ldp x10,x12,[x1,#16] + add x13,x13,x14,lsl#32 + add x15,x15,x16,lsl#32 + ldp x14,x16,[x1,#32] + add x17,x17,x19,lsl#32 + add x20,x20,x21,lsl#32 + ldp x19,x21,[x1,#48] + add x1,x1,#64 +#ifdef __AARCH64EB__ + rev x5,x5 + rev x7,x7 + rev x9,x9 + rev x11,x11 + rev x13,x13 + rev x15,x15 + rev x17,x17 + rev x20,x20 +#endif + eor x5,x5,x6 + eor x7,x7,x8 + eor x9,x9,x10 + eor x11,x11,x12 + eor x13,x13,x14 + eor x15,x15,x16 + eor x17,x17,x19 + eor x20,x20,x21 + + stp x5,x7,[x0,#0] // store output + add x28,x28,#4 // increment counter + stp x9,x11,[x0,#16] + stp x13,x15,[x0,#32] + stp x17,x20,[x0,#48] + add x0,x0,#64 + b.eq Ldone_neon + sub x2,x2,#64 + cmp x2,#64 + b.lo Less_than_128 + + ld1 {v20.16b,v21.16b,v22.16b,v23.16b},[x1],#64 + eor v0.16b,v0.16b,v20.16b + eor v1.16b,v1.16b,v21.16b + eor v2.16b,v2.16b,v22.16b + eor v3.16b,v3.16b,v23.16b + st1 {v0.16b,v1.16b,v2.16b,v3.16b},[x0],#64 + b.eq Ldone_neon + sub x2,x2,#64 + cmp x2,#64 + b.lo Less_than_192 + + ld1 {v20.16b,v21.16b,v22.16b,v23.16b},[x1],#64 + eor v4.16b,v4.16b,v20.16b + eor v5.16b,v5.16b,v21.16b + eor v6.16b,v6.16b,v22.16b + eor v7.16b,v7.16b,v23.16b + st1 {v4.16b,v5.16b,v6.16b,v7.16b},[x0],#64 + b.eq Ldone_neon + sub x2,x2,#64 + + st1 {v16.16b,v17.16b,v18.16b,v19.16b},[sp] + b Last_neon + +Less_than_128: + st1 {v0.16b,v1.16b,v2.16b,v3.16b},[sp] + b Last_neon +Less_than_192: + st1 {v4.16b,v5.16b,v6.16b,v7.16b},[sp] + b Last_neon + +.align 4 +Last_neon: + sub x0,x0,#1 + add x1,x1,x2 + add x0,x0,x2 + add x4,sp,x2 + neg x2,x2 + +Loop_tail_neon: + ldrb w10,[x1,x2] + ldrb w11,[x4,x2] + add x2,x2,#1 + eor w10,w10,w11 + strb w10,[x0,x2] + cbnz x2,Loop_tail_neon + + stp xzr,xzr,[sp,#0] + stp xzr,xzr,[sp,#16] + stp xzr,xzr,[sp,#32] + stp xzr,xzr,[sp,#48] + +Ldone_neon: + ldp x19,x20,[x29,#16] + add sp,sp,#64 + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldp x29,x30,[sp],#96 + AARCH64_VALIDATE_LINK_REGISTER + ret + + +.align 5 +ChaCha20_512_neon: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-96]! + add x29,sp,#0 + + adrp x5,Lsigma@PAGE + add x5,x5,Lsigma@PAGEOFF + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + stp x27,x28,[sp,#80] + +L512_or_more_neon: + sub sp,sp,#128+64 + + ldp x22,x23,[x5] // load sigma + ld1 {v24.4s},[x5],#16 + ldp x24,x25,[x3] // load key + ldp x26,x27,[x3,#16] + ld1 {v25.4s,v26.4s},[x3] + ldp x28,x30,[x4] // load counter + ld1 {v27.4s},[x4] + ld1 {v31.4s},[x5] +#ifdef __AARCH64EB__ + rev64 v24.4s,v24.4s + ror x24,x24,#32 + ror x25,x25,#32 + ror x26,x26,#32 + ror x27,x27,#32 + ror x28,x28,#32 + ror x30,x30,#32 +#endif + add v27.4s,v27.4s,v31.4s // += 1 + stp q24,q25,[sp,#0] // off-load key block, invariant part + add v27.4s,v27.4s,v31.4s // not typo + str q26,[sp,#32] + add v28.4s,v27.4s,v31.4s + add v29.4s,v28.4s,v31.4s + add v30.4s,v29.4s,v31.4s + shl v31.4s,v31.4s,#2 // 1 -> 4 + + stp d8,d9,[sp,#128+0] // meet ABI requirements + stp d10,d11,[sp,#128+16] + stp d12,d13,[sp,#128+32] + stp d14,d15,[sp,#128+48] + + sub x2,x2,#512 // not typo + +Loop_outer_512_neon: + mov v0.16b,v24.16b + mov v4.16b,v24.16b + mov v8.16b,v24.16b + mov v12.16b,v24.16b + mov v16.16b,v24.16b + mov v20.16b,v24.16b + mov v1.16b,v25.16b + mov w5,w22 // unpack key block + mov v5.16b,v25.16b + lsr x6,x22,#32 + mov v9.16b,v25.16b + mov w7,w23 + mov v13.16b,v25.16b + lsr x8,x23,#32 + mov v17.16b,v25.16b + mov w9,w24 + mov v21.16b,v25.16b + lsr x10,x24,#32 + mov v3.16b,v27.16b + mov w11,w25 + mov v7.16b,v28.16b + lsr x12,x25,#32 + mov v11.16b,v29.16b + mov w13,w26 + mov v15.16b,v30.16b + lsr x14,x26,#32 + mov v2.16b,v26.16b + mov w15,w27 + mov v6.16b,v26.16b + lsr x16,x27,#32 + add v19.4s,v3.4s,v31.4s // +4 + mov w17,w28 + add v23.4s,v7.4s,v31.4s // +4 + lsr x19,x28,#32 + mov v10.16b,v26.16b + mov w20,w30 + mov v14.16b,v26.16b + lsr x21,x30,#32 + mov v18.16b,v26.16b + stp q27,q28,[sp,#48] // off-load key block, variable part + mov v22.16b,v26.16b + str q29,[sp,#80] + + mov x4,#5 + subs x2,x2,#512 +Loop_upper_neon: + sub x4,x4,#1 + add v0.4s,v0.4s,v1.4s + add w5,w5,w9 + add v4.4s,v4.4s,v5.4s + add w6,w6,w10 + add v8.4s,v8.4s,v9.4s + add w7,w7,w11 + add v12.4s,v12.4s,v13.4s + add w8,w8,w12 + add v16.4s,v16.4s,v17.4s + eor w17,w17,w5 + add v20.4s,v20.4s,v21.4s + eor w19,w19,w6 + eor v3.16b,v3.16b,v0.16b + eor w20,w20,w7 + eor v7.16b,v7.16b,v4.16b + eor w21,w21,w8 + eor v11.16b,v11.16b,v8.16b + ror w17,w17,#16 + eor v15.16b,v15.16b,v12.16b + ror w19,w19,#16 + eor v19.16b,v19.16b,v16.16b + ror w20,w20,#16 + eor v23.16b,v23.16b,v20.16b + ror w21,w21,#16 + rev32 v3.8h,v3.8h + add w13,w13,w17 + rev32 v7.8h,v7.8h + add w14,w14,w19 + rev32 v11.8h,v11.8h + add w15,w15,w20 + rev32 v15.8h,v15.8h + add w16,w16,w21 + rev32 v19.8h,v19.8h + eor w9,w9,w13 + rev32 v23.8h,v23.8h + eor w10,w10,w14 + add v2.4s,v2.4s,v3.4s + eor w11,w11,w15 + add v6.4s,v6.4s,v7.4s + eor w12,w12,w16 + add v10.4s,v10.4s,v11.4s + ror w9,w9,#20 + add v14.4s,v14.4s,v15.4s + ror w10,w10,#20 + add v18.4s,v18.4s,v19.4s + ror w11,w11,#20 + add v22.4s,v22.4s,v23.4s + ror w12,w12,#20 + eor v24.16b,v1.16b,v2.16b + add w5,w5,w9 + eor v25.16b,v5.16b,v6.16b + add w6,w6,w10 + eor v26.16b,v9.16b,v10.16b + add w7,w7,w11 + eor v27.16b,v13.16b,v14.16b + add w8,w8,w12 + eor v28.16b,v17.16b,v18.16b + eor w17,w17,w5 + eor v29.16b,v21.16b,v22.16b + eor w19,w19,w6 + ushr v1.4s,v24.4s,#20 + eor w20,w20,w7 + ushr v5.4s,v25.4s,#20 + eor w21,w21,w8 + ushr v9.4s,v26.4s,#20 + ror w17,w17,#24 + ushr v13.4s,v27.4s,#20 + ror w19,w19,#24 + ushr v17.4s,v28.4s,#20 + ror w20,w20,#24 + ushr v21.4s,v29.4s,#20 + ror w21,w21,#24 + sli v1.4s,v24.4s,#12 + add w13,w13,w17 + sli v5.4s,v25.4s,#12 + add w14,w14,w19 + sli v9.4s,v26.4s,#12 + add w15,w15,w20 + sli v13.4s,v27.4s,#12 + add w16,w16,w21 + sli v17.4s,v28.4s,#12 + eor w9,w9,w13 + sli v21.4s,v29.4s,#12 + eor w10,w10,w14 + add v0.4s,v0.4s,v1.4s + eor w11,w11,w15 + add v4.4s,v4.4s,v5.4s + eor w12,w12,w16 + add v8.4s,v8.4s,v9.4s + ror w9,w9,#25 + add v12.4s,v12.4s,v13.4s + ror w10,w10,#25 + add v16.4s,v16.4s,v17.4s + ror w11,w11,#25 + add v20.4s,v20.4s,v21.4s + ror w12,w12,#25 + eor v24.16b,v3.16b,v0.16b + add w5,w5,w10 + eor v25.16b,v7.16b,v4.16b + add w6,w6,w11 + eor v26.16b,v11.16b,v8.16b + add w7,w7,w12 + eor v27.16b,v15.16b,v12.16b + add w8,w8,w9 + eor v28.16b,v19.16b,v16.16b + eor w21,w21,w5 + eor v29.16b,v23.16b,v20.16b + eor w17,w17,w6 + ushr v3.4s,v24.4s,#24 + eor w19,w19,w7 + ushr v7.4s,v25.4s,#24 + eor w20,w20,w8 + ushr v11.4s,v26.4s,#24 + ror w21,w21,#16 + ushr v15.4s,v27.4s,#24 + ror w17,w17,#16 + ushr v19.4s,v28.4s,#24 + ror w19,w19,#16 + ushr v23.4s,v29.4s,#24 + ror w20,w20,#16 + sli v3.4s,v24.4s,#8 + add w15,w15,w21 + sli v7.4s,v25.4s,#8 + add w16,w16,w17 + sli v11.4s,v26.4s,#8 + add w13,w13,w19 + sli v15.4s,v27.4s,#8 + add w14,w14,w20 + sli v19.4s,v28.4s,#8 + eor w10,w10,w15 + sli v23.4s,v29.4s,#8 + eor w11,w11,w16 + add v2.4s,v2.4s,v3.4s + eor w12,w12,w13 + add v6.4s,v6.4s,v7.4s + eor w9,w9,w14 + add v10.4s,v10.4s,v11.4s + ror w10,w10,#20 + add v14.4s,v14.4s,v15.4s + ror w11,w11,#20 + add v18.4s,v18.4s,v19.4s + ror w12,w12,#20 + add v22.4s,v22.4s,v23.4s + ror w9,w9,#20 + eor v24.16b,v1.16b,v2.16b + add w5,w5,w10 + eor v25.16b,v5.16b,v6.16b + add w6,w6,w11 + eor v26.16b,v9.16b,v10.16b + add w7,w7,w12 + eor v27.16b,v13.16b,v14.16b + add w8,w8,w9 + eor v28.16b,v17.16b,v18.16b + eor w21,w21,w5 + eor v29.16b,v21.16b,v22.16b + eor w17,w17,w6 + ushr v1.4s,v24.4s,#25 + eor w19,w19,w7 + ushr v5.4s,v25.4s,#25 + eor w20,w20,w8 + ushr v9.4s,v26.4s,#25 + ror w21,w21,#24 + ushr v13.4s,v27.4s,#25 + ror w17,w17,#24 + ushr v17.4s,v28.4s,#25 + ror w19,w19,#24 + ushr v21.4s,v29.4s,#25 + ror w20,w20,#24 + sli v1.4s,v24.4s,#7 + add w15,w15,w21 + sli v5.4s,v25.4s,#7 + add w16,w16,w17 + sli v9.4s,v26.4s,#7 + add w13,w13,w19 + sli v13.4s,v27.4s,#7 + add w14,w14,w20 + sli v17.4s,v28.4s,#7 + eor w10,w10,w15 + sli v21.4s,v29.4s,#7 + eor w11,w11,w16 + ext v2.16b,v2.16b,v2.16b,#8 + eor w12,w12,w13 + ext v6.16b,v6.16b,v6.16b,#8 + eor w9,w9,w14 + ext v10.16b,v10.16b,v10.16b,#8 + ror w10,w10,#25 + ext v14.16b,v14.16b,v14.16b,#8 + ror w11,w11,#25 + ext v18.16b,v18.16b,v18.16b,#8 + ror w12,w12,#25 + ext v22.16b,v22.16b,v22.16b,#8 + ror w9,w9,#25 + ext v3.16b,v3.16b,v3.16b,#12 + ext v7.16b,v7.16b,v7.16b,#12 + ext v11.16b,v11.16b,v11.16b,#12 + ext v15.16b,v15.16b,v15.16b,#12 + ext v19.16b,v19.16b,v19.16b,#12 + ext v23.16b,v23.16b,v23.16b,#12 + ext v1.16b,v1.16b,v1.16b,#4 + ext v5.16b,v5.16b,v5.16b,#4 + ext v9.16b,v9.16b,v9.16b,#4 + ext v13.16b,v13.16b,v13.16b,#4 + ext v17.16b,v17.16b,v17.16b,#4 + ext v21.16b,v21.16b,v21.16b,#4 + add v0.4s,v0.4s,v1.4s + add w5,w5,w9 + add v4.4s,v4.4s,v5.4s + add w6,w6,w10 + add v8.4s,v8.4s,v9.4s + add w7,w7,w11 + add v12.4s,v12.4s,v13.4s + add w8,w8,w12 + add v16.4s,v16.4s,v17.4s + eor w17,w17,w5 + add v20.4s,v20.4s,v21.4s + eor w19,w19,w6 + eor v3.16b,v3.16b,v0.16b + eor w20,w20,w7 + eor v7.16b,v7.16b,v4.16b + eor w21,w21,w8 + eor v11.16b,v11.16b,v8.16b + ror w17,w17,#16 + eor v15.16b,v15.16b,v12.16b + ror w19,w19,#16 + eor v19.16b,v19.16b,v16.16b + ror w20,w20,#16 + eor v23.16b,v23.16b,v20.16b + ror w21,w21,#16 + rev32 v3.8h,v3.8h + add w13,w13,w17 + rev32 v7.8h,v7.8h + add w14,w14,w19 + rev32 v11.8h,v11.8h + add w15,w15,w20 + rev32 v15.8h,v15.8h + add w16,w16,w21 + rev32 v19.8h,v19.8h + eor w9,w9,w13 + rev32 v23.8h,v23.8h + eor w10,w10,w14 + add v2.4s,v2.4s,v3.4s + eor w11,w11,w15 + add v6.4s,v6.4s,v7.4s + eor w12,w12,w16 + add v10.4s,v10.4s,v11.4s + ror w9,w9,#20 + add v14.4s,v14.4s,v15.4s + ror w10,w10,#20 + add v18.4s,v18.4s,v19.4s + ror w11,w11,#20 + add v22.4s,v22.4s,v23.4s + ror w12,w12,#20 + eor v24.16b,v1.16b,v2.16b + add w5,w5,w9 + eor v25.16b,v5.16b,v6.16b + add w6,w6,w10 + eor v26.16b,v9.16b,v10.16b + add w7,w7,w11 + eor v27.16b,v13.16b,v14.16b + add w8,w8,w12 + eor v28.16b,v17.16b,v18.16b + eor w17,w17,w5 + eor v29.16b,v21.16b,v22.16b + eor w19,w19,w6 + ushr v1.4s,v24.4s,#20 + eor w20,w20,w7 + ushr v5.4s,v25.4s,#20 + eor w21,w21,w8 + ushr v9.4s,v26.4s,#20 + ror w17,w17,#24 + ushr v13.4s,v27.4s,#20 + ror w19,w19,#24 + ushr v17.4s,v28.4s,#20 + ror w20,w20,#24 + ushr v21.4s,v29.4s,#20 + ror w21,w21,#24 + sli v1.4s,v24.4s,#12 + add w13,w13,w17 + sli v5.4s,v25.4s,#12 + add w14,w14,w19 + sli v9.4s,v26.4s,#12 + add w15,w15,w20 + sli v13.4s,v27.4s,#12 + add w16,w16,w21 + sli v17.4s,v28.4s,#12 + eor w9,w9,w13 + sli v21.4s,v29.4s,#12 + eor w10,w10,w14 + add v0.4s,v0.4s,v1.4s + eor w11,w11,w15 + add v4.4s,v4.4s,v5.4s + eor w12,w12,w16 + add v8.4s,v8.4s,v9.4s + ror w9,w9,#25 + add v12.4s,v12.4s,v13.4s + ror w10,w10,#25 + add v16.4s,v16.4s,v17.4s + ror w11,w11,#25 + add v20.4s,v20.4s,v21.4s + ror w12,w12,#25 + eor v24.16b,v3.16b,v0.16b + add w5,w5,w10 + eor v25.16b,v7.16b,v4.16b + add w6,w6,w11 + eor v26.16b,v11.16b,v8.16b + add w7,w7,w12 + eor v27.16b,v15.16b,v12.16b + add w8,w8,w9 + eor v28.16b,v19.16b,v16.16b + eor w21,w21,w5 + eor v29.16b,v23.16b,v20.16b + eor w17,w17,w6 + ushr v3.4s,v24.4s,#24 + eor w19,w19,w7 + ushr v7.4s,v25.4s,#24 + eor w20,w20,w8 + ushr v11.4s,v26.4s,#24 + ror w21,w21,#16 + ushr v15.4s,v27.4s,#24 + ror w17,w17,#16 + ushr v19.4s,v28.4s,#24 + ror w19,w19,#16 + ushr v23.4s,v29.4s,#24 + ror w20,w20,#16 + sli v3.4s,v24.4s,#8 + add w15,w15,w21 + sli v7.4s,v25.4s,#8 + add w16,w16,w17 + sli v11.4s,v26.4s,#8 + add w13,w13,w19 + sli v15.4s,v27.4s,#8 + add w14,w14,w20 + sli v19.4s,v28.4s,#8 + eor w10,w10,w15 + sli v23.4s,v29.4s,#8 + eor w11,w11,w16 + add v2.4s,v2.4s,v3.4s + eor w12,w12,w13 + add v6.4s,v6.4s,v7.4s + eor w9,w9,w14 + add v10.4s,v10.4s,v11.4s + ror w10,w10,#20 + add v14.4s,v14.4s,v15.4s + ror w11,w11,#20 + add v18.4s,v18.4s,v19.4s + ror w12,w12,#20 + add v22.4s,v22.4s,v23.4s + ror w9,w9,#20 + eor v24.16b,v1.16b,v2.16b + add w5,w5,w10 + eor v25.16b,v5.16b,v6.16b + add w6,w6,w11 + eor v26.16b,v9.16b,v10.16b + add w7,w7,w12 + eor v27.16b,v13.16b,v14.16b + add w8,w8,w9 + eor v28.16b,v17.16b,v18.16b + eor w21,w21,w5 + eor v29.16b,v21.16b,v22.16b + eor w17,w17,w6 + ushr v1.4s,v24.4s,#25 + eor w19,w19,w7 + ushr v5.4s,v25.4s,#25 + eor w20,w20,w8 + ushr v9.4s,v26.4s,#25 + ror w21,w21,#24 + ushr v13.4s,v27.4s,#25 + ror w17,w17,#24 + ushr v17.4s,v28.4s,#25 + ror w19,w19,#24 + ushr v21.4s,v29.4s,#25 + ror w20,w20,#24 + sli v1.4s,v24.4s,#7 + add w15,w15,w21 + sli v5.4s,v25.4s,#7 + add w16,w16,w17 + sli v9.4s,v26.4s,#7 + add w13,w13,w19 + sli v13.4s,v27.4s,#7 + add w14,w14,w20 + sli v17.4s,v28.4s,#7 + eor w10,w10,w15 + sli v21.4s,v29.4s,#7 + eor w11,w11,w16 + ext v2.16b,v2.16b,v2.16b,#8 + eor w12,w12,w13 + ext v6.16b,v6.16b,v6.16b,#8 + eor w9,w9,w14 + ext v10.16b,v10.16b,v10.16b,#8 + ror w10,w10,#25 + ext v14.16b,v14.16b,v14.16b,#8 + ror w11,w11,#25 + ext v18.16b,v18.16b,v18.16b,#8 + ror w12,w12,#25 + ext v22.16b,v22.16b,v22.16b,#8 + ror w9,w9,#25 + ext v3.16b,v3.16b,v3.16b,#4 + ext v7.16b,v7.16b,v7.16b,#4 + ext v11.16b,v11.16b,v11.16b,#4 + ext v15.16b,v15.16b,v15.16b,#4 + ext v19.16b,v19.16b,v19.16b,#4 + ext v23.16b,v23.16b,v23.16b,#4 + ext v1.16b,v1.16b,v1.16b,#12 + ext v5.16b,v5.16b,v5.16b,#12 + ext v9.16b,v9.16b,v9.16b,#12 + ext v13.16b,v13.16b,v13.16b,#12 + ext v17.16b,v17.16b,v17.16b,#12 + ext v21.16b,v21.16b,v21.16b,#12 + cbnz x4,Loop_upper_neon + + add w5,w5,w22 // accumulate key block + add x6,x6,x22,lsr#32 + add w7,w7,w23 + add x8,x8,x23,lsr#32 + add w9,w9,w24 + add x10,x10,x24,lsr#32 + add w11,w11,w25 + add x12,x12,x25,lsr#32 + add w13,w13,w26 + add x14,x14,x26,lsr#32 + add w15,w15,w27 + add x16,x16,x27,lsr#32 + add w17,w17,w28 + add x19,x19,x28,lsr#32 + add w20,w20,w30 + add x21,x21,x30,lsr#32 + + add x5,x5,x6,lsl#32 // pack + add x7,x7,x8,lsl#32 + ldp x6,x8,[x1,#0] // load input + add x9,x9,x10,lsl#32 + add x11,x11,x12,lsl#32 + ldp x10,x12,[x1,#16] + add x13,x13,x14,lsl#32 + add x15,x15,x16,lsl#32 + ldp x14,x16,[x1,#32] + add x17,x17,x19,lsl#32 + add x20,x20,x21,lsl#32 + ldp x19,x21,[x1,#48] + add x1,x1,#64 +#ifdef __AARCH64EB__ + rev x5,x5 + rev x7,x7 + rev x9,x9 + rev x11,x11 + rev x13,x13 + rev x15,x15 + rev x17,x17 + rev x20,x20 +#endif + eor x5,x5,x6 + eor x7,x7,x8 + eor x9,x9,x10 + eor x11,x11,x12 + eor x13,x13,x14 + eor x15,x15,x16 + eor x17,x17,x19 + eor x20,x20,x21 + + stp x5,x7,[x0,#0] // store output + add x28,x28,#1 // increment counter + mov w5,w22 // unpack key block + lsr x6,x22,#32 + stp x9,x11,[x0,#16] + mov w7,w23 + lsr x8,x23,#32 + stp x13,x15,[x0,#32] + mov w9,w24 + lsr x10,x24,#32 + stp x17,x20,[x0,#48] + add x0,x0,#64 + mov w11,w25 + lsr x12,x25,#32 + mov w13,w26 + lsr x14,x26,#32 + mov w15,w27 + lsr x16,x27,#32 + mov w17,w28 + lsr x19,x28,#32 + mov w20,w30 + lsr x21,x30,#32 + + mov x4,#5 +Loop_lower_neon: + sub x4,x4,#1 + add v0.4s,v0.4s,v1.4s + add w5,w5,w9 + add v4.4s,v4.4s,v5.4s + add w6,w6,w10 + add v8.4s,v8.4s,v9.4s + add w7,w7,w11 + add v12.4s,v12.4s,v13.4s + add w8,w8,w12 + add v16.4s,v16.4s,v17.4s + eor w17,w17,w5 + add v20.4s,v20.4s,v21.4s + eor w19,w19,w6 + eor v3.16b,v3.16b,v0.16b + eor w20,w20,w7 + eor v7.16b,v7.16b,v4.16b + eor w21,w21,w8 + eor v11.16b,v11.16b,v8.16b + ror w17,w17,#16 + eor v15.16b,v15.16b,v12.16b + ror w19,w19,#16 + eor v19.16b,v19.16b,v16.16b + ror w20,w20,#16 + eor v23.16b,v23.16b,v20.16b + ror w21,w21,#16 + rev32 v3.8h,v3.8h + add w13,w13,w17 + rev32 v7.8h,v7.8h + add w14,w14,w19 + rev32 v11.8h,v11.8h + add w15,w15,w20 + rev32 v15.8h,v15.8h + add w16,w16,w21 + rev32 v19.8h,v19.8h + eor w9,w9,w13 + rev32 v23.8h,v23.8h + eor w10,w10,w14 + add v2.4s,v2.4s,v3.4s + eor w11,w11,w15 + add v6.4s,v6.4s,v7.4s + eor w12,w12,w16 + add v10.4s,v10.4s,v11.4s + ror w9,w9,#20 + add v14.4s,v14.4s,v15.4s + ror w10,w10,#20 + add v18.4s,v18.4s,v19.4s + ror w11,w11,#20 + add v22.4s,v22.4s,v23.4s + ror w12,w12,#20 + eor v24.16b,v1.16b,v2.16b + add w5,w5,w9 + eor v25.16b,v5.16b,v6.16b + add w6,w6,w10 + eor v26.16b,v9.16b,v10.16b + add w7,w7,w11 + eor v27.16b,v13.16b,v14.16b + add w8,w8,w12 + eor v28.16b,v17.16b,v18.16b + eor w17,w17,w5 + eor v29.16b,v21.16b,v22.16b + eor w19,w19,w6 + ushr v1.4s,v24.4s,#20 + eor w20,w20,w7 + ushr v5.4s,v25.4s,#20 + eor w21,w21,w8 + ushr v9.4s,v26.4s,#20 + ror w17,w17,#24 + ushr v13.4s,v27.4s,#20 + ror w19,w19,#24 + ushr v17.4s,v28.4s,#20 + ror w20,w20,#24 + ushr v21.4s,v29.4s,#20 + ror w21,w21,#24 + sli v1.4s,v24.4s,#12 + add w13,w13,w17 + sli v5.4s,v25.4s,#12 + add w14,w14,w19 + sli v9.4s,v26.4s,#12 + add w15,w15,w20 + sli v13.4s,v27.4s,#12 + add w16,w16,w21 + sli v17.4s,v28.4s,#12 + eor w9,w9,w13 + sli v21.4s,v29.4s,#12 + eor w10,w10,w14 + add v0.4s,v0.4s,v1.4s + eor w11,w11,w15 + add v4.4s,v4.4s,v5.4s + eor w12,w12,w16 + add v8.4s,v8.4s,v9.4s + ror w9,w9,#25 + add v12.4s,v12.4s,v13.4s + ror w10,w10,#25 + add v16.4s,v16.4s,v17.4s + ror w11,w11,#25 + add v20.4s,v20.4s,v21.4s + ror w12,w12,#25 + eor v24.16b,v3.16b,v0.16b + add w5,w5,w10 + eor v25.16b,v7.16b,v4.16b + add w6,w6,w11 + eor v26.16b,v11.16b,v8.16b + add w7,w7,w12 + eor v27.16b,v15.16b,v12.16b + add w8,w8,w9 + eor v28.16b,v19.16b,v16.16b + eor w21,w21,w5 + eor v29.16b,v23.16b,v20.16b + eor w17,w17,w6 + ushr v3.4s,v24.4s,#24 + eor w19,w19,w7 + ushr v7.4s,v25.4s,#24 + eor w20,w20,w8 + ushr v11.4s,v26.4s,#24 + ror w21,w21,#16 + ushr v15.4s,v27.4s,#24 + ror w17,w17,#16 + ushr v19.4s,v28.4s,#24 + ror w19,w19,#16 + ushr v23.4s,v29.4s,#24 + ror w20,w20,#16 + sli v3.4s,v24.4s,#8 + add w15,w15,w21 + sli v7.4s,v25.4s,#8 + add w16,w16,w17 + sli v11.4s,v26.4s,#8 + add w13,w13,w19 + sli v15.4s,v27.4s,#8 + add w14,w14,w20 + sli v19.4s,v28.4s,#8 + eor w10,w10,w15 + sli v23.4s,v29.4s,#8 + eor w11,w11,w16 + add v2.4s,v2.4s,v3.4s + eor w12,w12,w13 + add v6.4s,v6.4s,v7.4s + eor w9,w9,w14 + add v10.4s,v10.4s,v11.4s + ror w10,w10,#20 + add v14.4s,v14.4s,v15.4s + ror w11,w11,#20 + add v18.4s,v18.4s,v19.4s + ror w12,w12,#20 + add v22.4s,v22.4s,v23.4s + ror w9,w9,#20 + eor v24.16b,v1.16b,v2.16b + add w5,w5,w10 + eor v25.16b,v5.16b,v6.16b + add w6,w6,w11 + eor v26.16b,v9.16b,v10.16b + add w7,w7,w12 + eor v27.16b,v13.16b,v14.16b + add w8,w8,w9 + eor v28.16b,v17.16b,v18.16b + eor w21,w21,w5 + eor v29.16b,v21.16b,v22.16b + eor w17,w17,w6 + ushr v1.4s,v24.4s,#25 + eor w19,w19,w7 + ushr v5.4s,v25.4s,#25 + eor w20,w20,w8 + ushr v9.4s,v26.4s,#25 + ror w21,w21,#24 + ushr v13.4s,v27.4s,#25 + ror w17,w17,#24 + ushr v17.4s,v28.4s,#25 + ror w19,w19,#24 + ushr v21.4s,v29.4s,#25 + ror w20,w20,#24 + sli v1.4s,v24.4s,#7 + add w15,w15,w21 + sli v5.4s,v25.4s,#7 + add w16,w16,w17 + sli v9.4s,v26.4s,#7 + add w13,w13,w19 + sli v13.4s,v27.4s,#7 + add w14,w14,w20 + sli v17.4s,v28.4s,#7 + eor w10,w10,w15 + sli v21.4s,v29.4s,#7 + eor w11,w11,w16 + ext v2.16b,v2.16b,v2.16b,#8 + eor w12,w12,w13 + ext v6.16b,v6.16b,v6.16b,#8 + eor w9,w9,w14 + ext v10.16b,v10.16b,v10.16b,#8 + ror w10,w10,#25 + ext v14.16b,v14.16b,v14.16b,#8 + ror w11,w11,#25 + ext v18.16b,v18.16b,v18.16b,#8 + ror w12,w12,#25 + ext v22.16b,v22.16b,v22.16b,#8 + ror w9,w9,#25 + ext v3.16b,v3.16b,v3.16b,#12 + ext v7.16b,v7.16b,v7.16b,#12 + ext v11.16b,v11.16b,v11.16b,#12 + ext v15.16b,v15.16b,v15.16b,#12 + ext v19.16b,v19.16b,v19.16b,#12 + ext v23.16b,v23.16b,v23.16b,#12 + ext v1.16b,v1.16b,v1.16b,#4 + ext v5.16b,v5.16b,v5.16b,#4 + ext v9.16b,v9.16b,v9.16b,#4 + ext v13.16b,v13.16b,v13.16b,#4 + ext v17.16b,v17.16b,v17.16b,#4 + ext v21.16b,v21.16b,v21.16b,#4 + add v0.4s,v0.4s,v1.4s + add w5,w5,w9 + add v4.4s,v4.4s,v5.4s + add w6,w6,w10 + add v8.4s,v8.4s,v9.4s + add w7,w7,w11 + add v12.4s,v12.4s,v13.4s + add w8,w8,w12 + add v16.4s,v16.4s,v17.4s + eor w17,w17,w5 + add v20.4s,v20.4s,v21.4s + eor w19,w19,w6 + eor v3.16b,v3.16b,v0.16b + eor w20,w20,w7 + eor v7.16b,v7.16b,v4.16b + eor w21,w21,w8 + eor v11.16b,v11.16b,v8.16b + ror w17,w17,#16 + eor v15.16b,v15.16b,v12.16b + ror w19,w19,#16 + eor v19.16b,v19.16b,v16.16b + ror w20,w20,#16 + eor v23.16b,v23.16b,v20.16b + ror w21,w21,#16 + rev32 v3.8h,v3.8h + add w13,w13,w17 + rev32 v7.8h,v7.8h + add w14,w14,w19 + rev32 v11.8h,v11.8h + add w15,w15,w20 + rev32 v15.8h,v15.8h + add w16,w16,w21 + rev32 v19.8h,v19.8h + eor w9,w9,w13 + rev32 v23.8h,v23.8h + eor w10,w10,w14 + add v2.4s,v2.4s,v3.4s + eor w11,w11,w15 + add v6.4s,v6.4s,v7.4s + eor w12,w12,w16 + add v10.4s,v10.4s,v11.4s + ror w9,w9,#20 + add v14.4s,v14.4s,v15.4s + ror w10,w10,#20 + add v18.4s,v18.4s,v19.4s + ror w11,w11,#20 + add v22.4s,v22.4s,v23.4s + ror w12,w12,#20 + eor v24.16b,v1.16b,v2.16b + add w5,w5,w9 + eor v25.16b,v5.16b,v6.16b + add w6,w6,w10 + eor v26.16b,v9.16b,v10.16b + add w7,w7,w11 + eor v27.16b,v13.16b,v14.16b + add w8,w8,w12 + eor v28.16b,v17.16b,v18.16b + eor w17,w17,w5 + eor v29.16b,v21.16b,v22.16b + eor w19,w19,w6 + ushr v1.4s,v24.4s,#20 + eor w20,w20,w7 + ushr v5.4s,v25.4s,#20 + eor w21,w21,w8 + ushr v9.4s,v26.4s,#20 + ror w17,w17,#24 + ushr v13.4s,v27.4s,#20 + ror w19,w19,#24 + ushr v17.4s,v28.4s,#20 + ror w20,w20,#24 + ushr v21.4s,v29.4s,#20 + ror w21,w21,#24 + sli v1.4s,v24.4s,#12 + add w13,w13,w17 + sli v5.4s,v25.4s,#12 + add w14,w14,w19 + sli v9.4s,v26.4s,#12 + add w15,w15,w20 + sli v13.4s,v27.4s,#12 + add w16,w16,w21 + sli v17.4s,v28.4s,#12 + eor w9,w9,w13 + sli v21.4s,v29.4s,#12 + eor w10,w10,w14 + add v0.4s,v0.4s,v1.4s + eor w11,w11,w15 + add v4.4s,v4.4s,v5.4s + eor w12,w12,w16 + add v8.4s,v8.4s,v9.4s + ror w9,w9,#25 + add v12.4s,v12.4s,v13.4s + ror w10,w10,#25 + add v16.4s,v16.4s,v17.4s + ror w11,w11,#25 + add v20.4s,v20.4s,v21.4s + ror w12,w12,#25 + eor v24.16b,v3.16b,v0.16b + add w5,w5,w10 + eor v25.16b,v7.16b,v4.16b + add w6,w6,w11 + eor v26.16b,v11.16b,v8.16b + add w7,w7,w12 + eor v27.16b,v15.16b,v12.16b + add w8,w8,w9 + eor v28.16b,v19.16b,v16.16b + eor w21,w21,w5 + eor v29.16b,v23.16b,v20.16b + eor w17,w17,w6 + ushr v3.4s,v24.4s,#24 + eor w19,w19,w7 + ushr v7.4s,v25.4s,#24 + eor w20,w20,w8 + ushr v11.4s,v26.4s,#24 + ror w21,w21,#16 + ushr v15.4s,v27.4s,#24 + ror w17,w17,#16 + ushr v19.4s,v28.4s,#24 + ror w19,w19,#16 + ushr v23.4s,v29.4s,#24 + ror w20,w20,#16 + sli v3.4s,v24.4s,#8 + add w15,w15,w21 + sli v7.4s,v25.4s,#8 + add w16,w16,w17 + sli v11.4s,v26.4s,#8 + add w13,w13,w19 + sli v15.4s,v27.4s,#8 + add w14,w14,w20 + sli v19.4s,v28.4s,#8 + eor w10,w10,w15 + sli v23.4s,v29.4s,#8 + eor w11,w11,w16 + add v2.4s,v2.4s,v3.4s + eor w12,w12,w13 + add v6.4s,v6.4s,v7.4s + eor w9,w9,w14 + add v10.4s,v10.4s,v11.4s + ror w10,w10,#20 + add v14.4s,v14.4s,v15.4s + ror w11,w11,#20 + add v18.4s,v18.4s,v19.4s + ror w12,w12,#20 + add v22.4s,v22.4s,v23.4s + ror w9,w9,#20 + eor v24.16b,v1.16b,v2.16b + add w5,w5,w10 + eor v25.16b,v5.16b,v6.16b + add w6,w6,w11 + eor v26.16b,v9.16b,v10.16b + add w7,w7,w12 + eor v27.16b,v13.16b,v14.16b + add w8,w8,w9 + eor v28.16b,v17.16b,v18.16b + eor w21,w21,w5 + eor v29.16b,v21.16b,v22.16b + eor w17,w17,w6 + ushr v1.4s,v24.4s,#25 + eor w19,w19,w7 + ushr v5.4s,v25.4s,#25 + eor w20,w20,w8 + ushr v9.4s,v26.4s,#25 + ror w21,w21,#24 + ushr v13.4s,v27.4s,#25 + ror w17,w17,#24 + ushr v17.4s,v28.4s,#25 + ror w19,w19,#24 + ushr v21.4s,v29.4s,#25 + ror w20,w20,#24 + sli v1.4s,v24.4s,#7 + add w15,w15,w21 + sli v5.4s,v25.4s,#7 + add w16,w16,w17 + sli v9.4s,v26.4s,#7 + add w13,w13,w19 + sli v13.4s,v27.4s,#7 + add w14,w14,w20 + sli v17.4s,v28.4s,#7 + eor w10,w10,w15 + sli v21.4s,v29.4s,#7 + eor w11,w11,w16 + ext v2.16b,v2.16b,v2.16b,#8 + eor w12,w12,w13 + ext v6.16b,v6.16b,v6.16b,#8 + eor w9,w9,w14 + ext v10.16b,v10.16b,v10.16b,#8 + ror w10,w10,#25 + ext v14.16b,v14.16b,v14.16b,#8 + ror w11,w11,#25 + ext v18.16b,v18.16b,v18.16b,#8 + ror w12,w12,#25 + ext v22.16b,v22.16b,v22.16b,#8 + ror w9,w9,#25 + ext v3.16b,v3.16b,v3.16b,#4 + ext v7.16b,v7.16b,v7.16b,#4 + ext v11.16b,v11.16b,v11.16b,#4 + ext v15.16b,v15.16b,v15.16b,#4 + ext v19.16b,v19.16b,v19.16b,#4 + ext v23.16b,v23.16b,v23.16b,#4 + ext v1.16b,v1.16b,v1.16b,#12 + ext v5.16b,v5.16b,v5.16b,#12 + ext v9.16b,v9.16b,v9.16b,#12 + ext v13.16b,v13.16b,v13.16b,#12 + ext v17.16b,v17.16b,v17.16b,#12 + ext v21.16b,v21.16b,v21.16b,#12 + cbnz x4,Loop_lower_neon + + add w5,w5,w22 // accumulate key block + ldp q24,q25,[sp,#0] + add x6,x6,x22,lsr#32 + ldp q26,q27,[sp,#32] + add w7,w7,w23 + ldp q28,q29,[sp,#64] + add x8,x8,x23,lsr#32 + add v0.4s,v0.4s,v24.4s + add w9,w9,w24 + add v4.4s,v4.4s,v24.4s + add x10,x10,x24,lsr#32 + add v8.4s,v8.4s,v24.4s + add w11,w11,w25 + add v12.4s,v12.4s,v24.4s + add x12,x12,x25,lsr#32 + add v16.4s,v16.4s,v24.4s + add w13,w13,w26 + add v20.4s,v20.4s,v24.4s + add x14,x14,x26,lsr#32 + add v2.4s,v2.4s,v26.4s + add w15,w15,w27 + add v6.4s,v6.4s,v26.4s + add x16,x16,x27,lsr#32 + add v10.4s,v10.4s,v26.4s + add w17,w17,w28 + add v14.4s,v14.4s,v26.4s + add x19,x19,x28,lsr#32 + add v18.4s,v18.4s,v26.4s + add w20,w20,w30 + add v22.4s,v22.4s,v26.4s + add x21,x21,x30,lsr#32 + add v19.4s,v19.4s,v31.4s // +4 + add x5,x5,x6,lsl#32 // pack + add v23.4s,v23.4s,v31.4s // +4 + add x7,x7,x8,lsl#32 + add v3.4s,v3.4s,v27.4s + ldp x6,x8,[x1,#0] // load input + add v7.4s,v7.4s,v28.4s + add x9,x9,x10,lsl#32 + add v11.4s,v11.4s,v29.4s + add x11,x11,x12,lsl#32 + add v15.4s,v15.4s,v30.4s + ldp x10,x12,[x1,#16] + add v19.4s,v19.4s,v27.4s + add x13,x13,x14,lsl#32 + add v23.4s,v23.4s,v28.4s + add x15,x15,x16,lsl#32 + add v1.4s,v1.4s,v25.4s + ldp x14,x16,[x1,#32] + add v5.4s,v5.4s,v25.4s + add x17,x17,x19,lsl#32 + add v9.4s,v9.4s,v25.4s + add x20,x20,x21,lsl#32 + add v13.4s,v13.4s,v25.4s + ldp x19,x21,[x1,#48] + add v17.4s,v17.4s,v25.4s + add x1,x1,#64 + add v21.4s,v21.4s,v25.4s + +#ifdef __AARCH64EB__ + rev x5,x5 + rev x7,x7 + rev x9,x9 + rev x11,x11 + rev x13,x13 + rev x15,x15 + rev x17,x17 + rev x20,x20 +#endif + ld1 {v24.16b,v25.16b,v26.16b,v27.16b},[x1],#64 + eor x5,x5,x6 + eor x7,x7,x8 + eor x9,x9,x10 + eor x11,x11,x12 + eor x13,x13,x14 + eor v0.16b,v0.16b,v24.16b + eor x15,x15,x16 + eor v1.16b,v1.16b,v25.16b + eor x17,x17,x19 + eor v2.16b,v2.16b,v26.16b + eor x20,x20,x21 + eor v3.16b,v3.16b,v27.16b + ld1 {v24.16b,v25.16b,v26.16b,v27.16b},[x1],#64 + + stp x5,x7,[x0,#0] // store output + add x28,x28,#7 // increment counter + stp x9,x11,[x0,#16] + stp x13,x15,[x0,#32] + stp x17,x20,[x0,#48] + add x0,x0,#64 + st1 {v0.16b,v1.16b,v2.16b,v3.16b},[x0],#64 + + ld1 {v0.16b,v1.16b,v2.16b,v3.16b},[x1],#64 + eor v4.16b,v4.16b,v24.16b + eor v5.16b,v5.16b,v25.16b + eor v6.16b,v6.16b,v26.16b + eor v7.16b,v7.16b,v27.16b + st1 {v4.16b,v5.16b,v6.16b,v7.16b},[x0],#64 + + ld1 {v4.16b,v5.16b,v6.16b,v7.16b},[x1],#64 + eor v8.16b,v8.16b,v0.16b + ldp q24,q25,[sp,#0] + eor v9.16b,v9.16b,v1.16b + ldp q26,q27,[sp,#32] + eor v10.16b,v10.16b,v2.16b + eor v11.16b,v11.16b,v3.16b + st1 {v8.16b,v9.16b,v10.16b,v11.16b},[x0],#64 + + ld1 {v8.16b,v9.16b,v10.16b,v11.16b},[x1],#64 + eor v12.16b,v12.16b,v4.16b + eor v13.16b,v13.16b,v5.16b + eor v14.16b,v14.16b,v6.16b + eor v15.16b,v15.16b,v7.16b + st1 {v12.16b,v13.16b,v14.16b,v15.16b},[x0],#64 + + ld1 {v12.16b,v13.16b,v14.16b,v15.16b},[x1],#64 + eor v16.16b,v16.16b,v8.16b + eor v17.16b,v17.16b,v9.16b + eor v18.16b,v18.16b,v10.16b + eor v19.16b,v19.16b,v11.16b + st1 {v16.16b,v17.16b,v18.16b,v19.16b},[x0],#64 + + shl v0.4s,v31.4s,#1 // 4 -> 8 + eor v20.16b,v20.16b,v12.16b + eor v21.16b,v21.16b,v13.16b + eor v22.16b,v22.16b,v14.16b + eor v23.16b,v23.16b,v15.16b + st1 {v20.16b,v21.16b,v22.16b,v23.16b},[x0],#64 + + add v27.4s,v27.4s,v0.4s // += 8 + add v28.4s,v28.4s,v0.4s + add v29.4s,v29.4s,v0.4s + add v30.4s,v30.4s,v0.4s + + b.hs Loop_outer_512_neon + + adds x2,x2,#512 + ushr v0.4s,v31.4s,#2 // 4 -> 1 + + ldp d8,d9,[sp,#128+0] // meet ABI requirements + ldp d10,d11,[sp,#128+16] + ldp d12,d13,[sp,#128+32] + ldp d14,d15,[sp,#128+48] + + stp q24,q31,[sp,#0] // wipe off-load area + stp q24,q31,[sp,#32] + stp q24,q31,[sp,#64] + + b.eq Ldone_512_neon + + cmp x2,#192 + sub v27.4s,v27.4s,v0.4s // -= 1 + sub v28.4s,v28.4s,v0.4s + sub v29.4s,v29.4s,v0.4s + add sp,sp,#128 + b.hs Loop_outer_neon + + eor v25.16b,v25.16b,v25.16b + eor v26.16b,v26.16b,v26.16b + eor v27.16b,v27.16b,v27.16b + eor v28.16b,v28.16b,v28.16b + eor v29.16b,v29.16b,v29.16b + eor v30.16b,v30.16b,v30.16b + b Loop_outer + +Ldone_512_neon: + ldp x19,x20,[x29,#16] + add sp,sp,#128+64 + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldp x29,x30,[sp],#96 + AARCH64_VALIDATE_LINK_REGISTER + ret + +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__APPLE__) diff --git a/http/vendor/ring/pregenerated/chacha-armv8-linux64.S b/http/vendor/ring/pregenerated/chacha-armv8-linux64.S new file mode 100644 index 0000000..00108f0 --- /dev/null +++ b/http/vendor/ring/pregenerated/chacha-armv8-linux64.S @@ -0,0 +1,1966 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__ELF__) +.section .rodata + +.align 5 +.Lsigma: +.quad 0x3320646e61707865,0x6b20657479622d32 // endian-neutral +.Lone: +.long 1,0,0,0 +.byte 67,104,97,67,104,97,50,48,32,102,111,114,32,65,82,77,118,56,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.align 2 + +.text + +.globl ChaCha20_ctr32_nohw +.hidden ChaCha20_ctr32_nohw +.type ChaCha20_ctr32_nohw,%function +.align 5 +ChaCha20_ctr32_nohw: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-96]! + add x29,sp,#0 + + adrp x5,.Lsigma + add x5,x5,:lo12:.Lsigma + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + stp x27,x28,[sp,#80] + sub sp,sp,#64 + + ldp x22,x23,[x5] // load sigma + ldp x24,x25,[x3] // load key + ldp x26,x27,[x3,#16] + ldp x28,x30,[x4] // load counter +#ifdef __AARCH64EB__ + ror x24,x24,#32 + ror x25,x25,#32 + ror x26,x26,#32 + ror x27,x27,#32 + ror x28,x28,#32 + ror x30,x30,#32 +#endif + +.Loop_outer: + mov w5,w22 // unpack key block + lsr x6,x22,#32 + mov w7,w23 + lsr x8,x23,#32 + mov w9,w24 + lsr x10,x24,#32 + mov w11,w25 + lsr x12,x25,#32 + mov w13,w26 + lsr x14,x26,#32 + mov w15,w27 + lsr x16,x27,#32 + mov w17,w28 + lsr x19,x28,#32 + mov w20,w30 + lsr x21,x30,#32 + + mov x4,#10 + subs x2,x2,#64 +.Loop: + sub x4,x4,#1 + add w5,w5,w9 + add w6,w6,w10 + add w7,w7,w11 + add w8,w8,w12 + eor w17,w17,w5 + eor w19,w19,w6 + eor w20,w20,w7 + eor w21,w21,w8 + ror w17,w17,#16 + ror w19,w19,#16 + ror w20,w20,#16 + ror w21,w21,#16 + add w13,w13,w17 + add w14,w14,w19 + add w15,w15,w20 + add w16,w16,w21 + eor w9,w9,w13 + eor w10,w10,w14 + eor w11,w11,w15 + eor w12,w12,w16 + ror w9,w9,#20 + ror w10,w10,#20 + ror w11,w11,#20 + ror w12,w12,#20 + add w5,w5,w9 + add w6,w6,w10 + add w7,w7,w11 + add w8,w8,w12 + eor w17,w17,w5 + eor w19,w19,w6 + eor w20,w20,w7 + eor w21,w21,w8 + ror w17,w17,#24 + ror w19,w19,#24 + ror w20,w20,#24 + ror w21,w21,#24 + add w13,w13,w17 + add w14,w14,w19 + add w15,w15,w20 + add w16,w16,w21 + eor w9,w9,w13 + eor w10,w10,w14 + eor w11,w11,w15 + eor w12,w12,w16 + ror w9,w9,#25 + ror w10,w10,#25 + ror w11,w11,#25 + ror w12,w12,#25 + add w5,w5,w10 + add w6,w6,w11 + add w7,w7,w12 + add w8,w8,w9 + eor w21,w21,w5 + eor w17,w17,w6 + eor w19,w19,w7 + eor w20,w20,w8 + ror w21,w21,#16 + ror w17,w17,#16 + ror w19,w19,#16 + ror w20,w20,#16 + add w15,w15,w21 + add w16,w16,w17 + add w13,w13,w19 + add w14,w14,w20 + eor w10,w10,w15 + eor w11,w11,w16 + eor w12,w12,w13 + eor w9,w9,w14 + ror w10,w10,#20 + ror w11,w11,#20 + ror w12,w12,#20 + ror w9,w9,#20 + add w5,w5,w10 + add w6,w6,w11 + add w7,w7,w12 + add w8,w8,w9 + eor w21,w21,w5 + eor w17,w17,w6 + eor w19,w19,w7 + eor w20,w20,w8 + ror w21,w21,#24 + ror w17,w17,#24 + ror w19,w19,#24 + ror w20,w20,#24 + add w15,w15,w21 + add w16,w16,w17 + add w13,w13,w19 + add w14,w14,w20 + eor w10,w10,w15 + eor w11,w11,w16 + eor w12,w12,w13 + eor w9,w9,w14 + ror w10,w10,#25 + ror w11,w11,#25 + ror w12,w12,#25 + ror w9,w9,#25 + cbnz x4,.Loop + + add w5,w5,w22 // accumulate key block + add x6,x6,x22,lsr#32 + add w7,w7,w23 + add x8,x8,x23,lsr#32 + add w9,w9,w24 + add x10,x10,x24,lsr#32 + add w11,w11,w25 + add x12,x12,x25,lsr#32 + add w13,w13,w26 + add x14,x14,x26,lsr#32 + add w15,w15,w27 + add x16,x16,x27,lsr#32 + add w17,w17,w28 + add x19,x19,x28,lsr#32 + add w20,w20,w30 + add x21,x21,x30,lsr#32 + + b.lo .Ltail + + add x5,x5,x6,lsl#32 // pack + add x7,x7,x8,lsl#32 + ldp x6,x8,[x1,#0] // load input + add x9,x9,x10,lsl#32 + add x11,x11,x12,lsl#32 + ldp x10,x12,[x1,#16] + add x13,x13,x14,lsl#32 + add x15,x15,x16,lsl#32 + ldp x14,x16,[x1,#32] + add x17,x17,x19,lsl#32 + add x20,x20,x21,lsl#32 + ldp x19,x21,[x1,#48] + add x1,x1,#64 +#ifdef __AARCH64EB__ + rev x5,x5 + rev x7,x7 + rev x9,x9 + rev x11,x11 + rev x13,x13 + rev x15,x15 + rev x17,x17 + rev x20,x20 +#endif + eor x5,x5,x6 + eor x7,x7,x8 + eor x9,x9,x10 + eor x11,x11,x12 + eor x13,x13,x14 + eor x15,x15,x16 + eor x17,x17,x19 + eor x20,x20,x21 + + stp x5,x7,[x0,#0] // store output + add x28,x28,#1 // increment counter + stp x9,x11,[x0,#16] + stp x13,x15,[x0,#32] + stp x17,x20,[x0,#48] + add x0,x0,#64 + + b.hi .Loop_outer + + ldp x19,x20,[x29,#16] + add sp,sp,#64 + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldp x29,x30,[sp],#96 + AARCH64_VALIDATE_LINK_REGISTER + ret + +.align 4 +.Ltail: + add x2,x2,#64 +.Less_than_64: + sub x0,x0,#1 + add x1,x1,x2 + add x0,x0,x2 + add x4,sp,x2 + neg x2,x2 + + add x5,x5,x6,lsl#32 // pack + add x7,x7,x8,lsl#32 + add x9,x9,x10,lsl#32 + add x11,x11,x12,lsl#32 + add x13,x13,x14,lsl#32 + add x15,x15,x16,lsl#32 + add x17,x17,x19,lsl#32 + add x20,x20,x21,lsl#32 +#ifdef __AARCH64EB__ + rev x5,x5 + rev x7,x7 + rev x9,x9 + rev x11,x11 + rev x13,x13 + rev x15,x15 + rev x17,x17 + rev x20,x20 +#endif + stp x5,x7,[sp,#0] + stp x9,x11,[sp,#16] + stp x13,x15,[sp,#32] + stp x17,x20,[sp,#48] + +.Loop_tail: + ldrb w10,[x1,x2] + ldrb w11,[x4,x2] + add x2,x2,#1 + eor w10,w10,w11 + strb w10,[x0,x2] + cbnz x2,.Loop_tail + + stp xzr,xzr,[sp,#0] + stp xzr,xzr,[sp,#16] + stp xzr,xzr,[sp,#32] + stp xzr,xzr,[sp,#48] + + ldp x19,x20,[x29,#16] + add sp,sp,#64 + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldp x29,x30,[sp],#96 + AARCH64_VALIDATE_LINK_REGISTER + ret +.size ChaCha20_ctr32_nohw,.-ChaCha20_ctr32_nohw + +.globl ChaCha20_ctr32_neon +.hidden ChaCha20_ctr32_neon +.type ChaCha20_ctr32_neon,%function +.align 5 +ChaCha20_ctr32_neon: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-96]! + add x29,sp,#0 + + adrp x5,.Lsigma + add x5,x5,:lo12:.Lsigma + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + stp x27,x28,[sp,#80] + cmp x2,#512 + b.hs .L512_or_more_neon + + sub sp,sp,#64 + + ldp x22,x23,[x5] // load sigma + ld1 {v24.4s},[x5],#16 + ldp x24,x25,[x3] // load key + ldp x26,x27,[x3,#16] + ld1 {v25.4s,v26.4s},[x3] + ldp x28,x30,[x4] // load counter + ld1 {v27.4s},[x4] + ld1 {v31.4s},[x5] +#ifdef __AARCH64EB__ + rev64 v24.4s,v24.4s + ror x24,x24,#32 + ror x25,x25,#32 + ror x26,x26,#32 + ror x27,x27,#32 + ror x28,x28,#32 + ror x30,x30,#32 +#endif + add v27.4s,v27.4s,v31.4s // += 1 + add v28.4s,v27.4s,v31.4s + add v29.4s,v28.4s,v31.4s + shl v31.4s,v31.4s,#2 // 1 -> 4 + +.Loop_outer_neon: + mov w5,w22 // unpack key block + lsr x6,x22,#32 + mov v0.16b,v24.16b + mov w7,w23 + lsr x8,x23,#32 + mov v4.16b,v24.16b + mov w9,w24 + lsr x10,x24,#32 + mov v16.16b,v24.16b + mov w11,w25 + mov v1.16b,v25.16b + lsr x12,x25,#32 + mov v5.16b,v25.16b + mov w13,w26 + mov v17.16b,v25.16b + lsr x14,x26,#32 + mov v3.16b,v27.16b + mov w15,w27 + mov v7.16b,v28.16b + lsr x16,x27,#32 + mov v19.16b,v29.16b + mov w17,w28 + mov v2.16b,v26.16b + lsr x19,x28,#32 + mov v6.16b,v26.16b + mov w20,w30 + mov v18.16b,v26.16b + lsr x21,x30,#32 + + mov x4,#10 + subs x2,x2,#256 +.Loop_neon: + sub x4,x4,#1 + add v0.4s,v0.4s,v1.4s + add w5,w5,w9 + add v4.4s,v4.4s,v5.4s + add w6,w6,w10 + add v16.4s,v16.4s,v17.4s + add w7,w7,w11 + eor v3.16b,v3.16b,v0.16b + add w8,w8,w12 + eor v7.16b,v7.16b,v4.16b + eor w17,w17,w5 + eor v19.16b,v19.16b,v16.16b + eor w19,w19,w6 + rev32 v3.8h,v3.8h + eor w20,w20,w7 + rev32 v7.8h,v7.8h + eor w21,w21,w8 + rev32 v19.8h,v19.8h + ror w17,w17,#16 + add v2.4s,v2.4s,v3.4s + ror w19,w19,#16 + add v6.4s,v6.4s,v7.4s + ror w20,w20,#16 + add v18.4s,v18.4s,v19.4s + ror w21,w21,#16 + eor v20.16b,v1.16b,v2.16b + add w13,w13,w17 + eor v21.16b,v5.16b,v6.16b + add w14,w14,w19 + eor v22.16b,v17.16b,v18.16b + add w15,w15,w20 + ushr v1.4s,v20.4s,#20 + add w16,w16,w21 + ushr v5.4s,v21.4s,#20 + eor w9,w9,w13 + ushr v17.4s,v22.4s,#20 + eor w10,w10,w14 + sli v1.4s,v20.4s,#12 + eor w11,w11,w15 + sli v5.4s,v21.4s,#12 + eor w12,w12,w16 + sli v17.4s,v22.4s,#12 + ror w9,w9,#20 + add v0.4s,v0.4s,v1.4s + ror w10,w10,#20 + add v4.4s,v4.4s,v5.4s + ror w11,w11,#20 + add v16.4s,v16.4s,v17.4s + ror w12,w12,#20 + eor v20.16b,v3.16b,v0.16b + add w5,w5,w9 + eor v21.16b,v7.16b,v4.16b + add w6,w6,w10 + eor v22.16b,v19.16b,v16.16b + add w7,w7,w11 + ushr v3.4s,v20.4s,#24 + add w8,w8,w12 + ushr v7.4s,v21.4s,#24 + eor w17,w17,w5 + ushr v19.4s,v22.4s,#24 + eor w19,w19,w6 + sli v3.4s,v20.4s,#8 + eor w20,w20,w7 + sli v7.4s,v21.4s,#8 + eor w21,w21,w8 + sli v19.4s,v22.4s,#8 + ror w17,w17,#24 + add v2.4s,v2.4s,v3.4s + ror w19,w19,#24 + add v6.4s,v6.4s,v7.4s + ror w20,w20,#24 + add v18.4s,v18.4s,v19.4s + ror w21,w21,#24 + eor v20.16b,v1.16b,v2.16b + add w13,w13,w17 + eor v21.16b,v5.16b,v6.16b + add w14,w14,w19 + eor v22.16b,v17.16b,v18.16b + add w15,w15,w20 + ushr v1.4s,v20.4s,#25 + add w16,w16,w21 + ushr v5.4s,v21.4s,#25 + eor w9,w9,w13 + ushr v17.4s,v22.4s,#25 + eor w10,w10,w14 + sli v1.4s,v20.4s,#7 + eor w11,w11,w15 + sli v5.4s,v21.4s,#7 + eor w12,w12,w16 + sli v17.4s,v22.4s,#7 + ror w9,w9,#25 + ext v2.16b,v2.16b,v2.16b,#8 + ror w10,w10,#25 + ext v6.16b,v6.16b,v6.16b,#8 + ror w11,w11,#25 + ext v18.16b,v18.16b,v18.16b,#8 + ror w12,w12,#25 + ext v3.16b,v3.16b,v3.16b,#12 + ext v7.16b,v7.16b,v7.16b,#12 + ext v19.16b,v19.16b,v19.16b,#12 + ext v1.16b,v1.16b,v1.16b,#4 + ext v5.16b,v5.16b,v5.16b,#4 + ext v17.16b,v17.16b,v17.16b,#4 + add v0.4s,v0.4s,v1.4s + add w5,w5,w10 + add v4.4s,v4.4s,v5.4s + add w6,w6,w11 + add v16.4s,v16.4s,v17.4s + add w7,w7,w12 + eor v3.16b,v3.16b,v0.16b + add w8,w8,w9 + eor v7.16b,v7.16b,v4.16b + eor w21,w21,w5 + eor v19.16b,v19.16b,v16.16b + eor w17,w17,w6 + rev32 v3.8h,v3.8h + eor w19,w19,w7 + rev32 v7.8h,v7.8h + eor w20,w20,w8 + rev32 v19.8h,v19.8h + ror w21,w21,#16 + add v2.4s,v2.4s,v3.4s + ror w17,w17,#16 + add v6.4s,v6.4s,v7.4s + ror w19,w19,#16 + add v18.4s,v18.4s,v19.4s + ror w20,w20,#16 + eor v20.16b,v1.16b,v2.16b + add w15,w15,w21 + eor v21.16b,v5.16b,v6.16b + add w16,w16,w17 + eor v22.16b,v17.16b,v18.16b + add w13,w13,w19 + ushr v1.4s,v20.4s,#20 + add w14,w14,w20 + ushr v5.4s,v21.4s,#20 + eor w10,w10,w15 + ushr v17.4s,v22.4s,#20 + eor w11,w11,w16 + sli v1.4s,v20.4s,#12 + eor w12,w12,w13 + sli v5.4s,v21.4s,#12 + eor w9,w9,w14 + sli v17.4s,v22.4s,#12 + ror w10,w10,#20 + add v0.4s,v0.4s,v1.4s + ror w11,w11,#20 + add v4.4s,v4.4s,v5.4s + ror w12,w12,#20 + add v16.4s,v16.4s,v17.4s + ror w9,w9,#20 + eor v20.16b,v3.16b,v0.16b + add w5,w5,w10 + eor v21.16b,v7.16b,v4.16b + add w6,w6,w11 + eor v22.16b,v19.16b,v16.16b + add w7,w7,w12 + ushr v3.4s,v20.4s,#24 + add w8,w8,w9 + ushr v7.4s,v21.4s,#24 + eor w21,w21,w5 + ushr v19.4s,v22.4s,#24 + eor w17,w17,w6 + sli v3.4s,v20.4s,#8 + eor w19,w19,w7 + sli v7.4s,v21.4s,#8 + eor w20,w20,w8 + sli v19.4s,v22.4s,#8 + ror w21,w21,#24 + add v2.4s,v2.4s,v3.4s + ror w17,w17,#24 + add v6.4s,v6.4s,v7.4s + ror w19,w19,#24 + add v18.4s,v18.4s,v19.4s + ror w20,w20,#24 + eor v20.16b,v1.16b,v2.16b + add w15,w15,w21 + eor v21.16b,v5.16b,v6.16b + add w16,w16,w17 + eor v22.16b,v17.16b,v18.16b + add w13,w13,w19 + ushr v1.4s,v20.4s,#25 + add w14,w14,w20 + ushr v5.4s,v21.4s,#25 + eor w10,w10,w15 + ushr v17.4s,v22.4s,#25 + eor w11,w11,w16 + sli v1.4s,v20.4s,#7 + eor w12,w12,w13 + sli v5.4s,v21.4s,#7 + eor w9,w9,w14 + sli v17.4s,v22.4s,#7 + ror w10,w10,#25 + ext v2.16b,v2.16b,v2.16b,#8 + ror w11,w11,#25 + ext v6.16b,v6.16b,v6.16b,#8 + ror w12,w12,#25 + ext v18.16b,v18.16b,v18.16b,#8 + ror w9,w9,#25 + ext v3.16b,v3.16b,v3.16b,#4 + ext v7.16b,v7.16b,v7.16b,#4 + ext v19.16b,v19.16b,v19.16b,#4 + ext v1.16b,v1.16b,v1.16b,#12 + ext v5.16b,v5.16b,v5.16b,#12 + ext v17.16b,v17.16b,v17.16b,#12 + cbnz x4,.Loop_neon + + add w5,w5,w22 // accumulate key block + add v0.4s,v0.4s,v24.4s + add x6,x6,x22,lsr#32 + add v4.4s,v4.4s,v24.4s + add w7,w7,w23 + add v16.4s,v16.4s,v24.4s + add x8,x8,x23,lsr#32 + add v2.4s,v2.4s,v26.4s + add w9,w9,w24 + add v6.4s,v6.4s,v26.4s + add x10,x10,x24,lsr#32 + add v18.4s,v18.4s,v26.4s + add w11,w11,w25 + add v3.4s,v3.4s,v27.4s + add x12,x12,x25,lsr#32 + add w13,w13,w26 + add v7.4s,v7.4s,v28.4s + add x14,x14,x26,lsr#32 + add w15,w15,w27 + add v19.4s,v19.4s,v29.4s + add x16,x16,x27,lsr#32 + add w17,w17,w28 + add v1.4s,v1.4s,v25.4s + add x19,x19,x28,lsr#32 + add w20,w20,w30 + add v5.4s,v5.4s,v25.4s + add x21,x21,x30,lsr#32 + add v17.4s,v17.4s,v25.4s + + b.lo .Ltail_neon + + add x5,x5,x6,lsl#32 // pack + add x7,x7,x8,lsl#32 + ldp x6,x8,[x1,#0] // load input + add x9,x9,x10,lsl#32 + add x11,x11,x12,lsl#32 + ldp x10,x12,[x1,#16] + add x13,x13,x14,lsl#32 + add x15,x15,x16,lsl#32 + ldp x14,x16,[x1,#32] + add x17,x17,x19,lsl#32 + add x20,x20,x21,lsl#32 + ldp x19,x21,[x1,#48] + add x1,x1,#64 +#ifdef __AARCH64EB__ + rev x5,x5 + rev x7,x7 + rev x9,x9 + rev x11,x11 + rev x13,x13 + rev x15,x15 + rev x17,x17 + rev x20,x20 +#endif + ld1 {v20.16b,v21.16b,v22.16b,v23.16b},[x1],#64 + eor x5,x5,x6 + eor x7,x7,x8 + eor x9,x9,x10 + eor x11,x11,x12 + eor x13,x13,x14 + eor v0.16b,v0.16b,v20.16b + eor x15,x15,x16 + eor v1.16b,v1.16b,v21.16b + eor x17,x17,x19 + eor v2.16b,v2.16b,v22.16b + eor x20,x20,x21 + eor v3.16b,v3.16b,v23.16b + ld1 {v20.16b,v21.16b,v22.16b,v23.16b},[x1],#64 + + stp x5,x7,[x0,#0] // store output + add x28,x28,#4 // increment counter + stp x9,x11,[x0,#16] + add v27.4s,v27.4s,v31.4s // += 4 + stp x13,x15,[x0,#32] + add v28.4s,v28.4s,v31.4s + stp x17,x20,[x0,#48] + add v29.4s,v29.4s,v31.4s + add x0,x0,#64 + + st1 {v0.16b,v1.16b,v2.16b,v3.16b},[x0],#64 + ld1 {v0.16b,v1.16b,v2.16b,v3.16b},[x1],#64 + + eor v4.16b,v4.16b,v20.16b + eor v5.16b,v5.16b,v21.16b + eor v6.16b,v6.16b,v22.16b + eor v7.16b,v7.16b,v23.16b + st1 {v4.16b,v5.16b,v6.16b,v7.16b},[x0],#64 + + eor v16.16b,v16.16b,v0.16b + eor v17.16b,v17.16b,v1.16b + eor v18.16b,v18.16b,v2.16b + eor v19.16b,v19.16b,v3.16b + st1 {v16.16b,v17.16b,v18.16b,v19.16b},[x0],#64 + + b.hi .Loop_outer_neon + + ldp x19,x20,[x29,#16] + add sp,sp,#64 + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldp x29,x30,[sp],#96 + AARCH64_VALIDATE_LINK_REGISTER + ret + +.Ltail_neon: + add x2,x2,#256 + cmp x2,#64 + b.lo .Less_than_64 + + add x5,x5,x6,lsl#32 // pack + add x7,x7,x8,lsl#32 + ldp x6,x8,[x1,#0] // load input + add x9,x9,x10,lsl#32 + add x11,x11,x12,lsl#32 + ldp x10,x12,[x1,#16] + add x13,x13,x14,lsl#32 + add x15,x15,x16,lsl#32 + ldp x14,x16,[x1,#32] + add x17,x17,x19,lsl#32 + add x20,x20,x21,lsl#32 + ldp x19,x21,[x1,#48] + add x1,x1,#64 +#ifdef __AARCH64EB__ + rev x5,x5 + rev x7,x7 + rev x9,x9 + rev x11,x11 + rev x13,x13 + rev x15,x15 + rev x17,x17 + rev x20,x20 +#endif + eor x5,x5,x6 + eor x7,x7,x8 + eor x9,x9,x10 + eor x11,x11,x12 + eor x13,x13,x14 + eor x15,x15,x16 + eor x17,x17,x19 + eor x20,x20,x21 + + stp x5,x7,[x0,#0] // store output + add x28,x28,#4 // increment counter + stp x9,x11,[x0,#16] + stp x13,x15,[x0,#32] + stp x17,x20,[x0,#48] + add x0,x0,#64 + b.eq .Ldone_neon + sub x2,x2,#64 + cmp x2,#64 + b.lo .Less_than_128 + + ld1 {v20.16b,v21.16b,v22.16b,v23.16b},[x1],#64 + eor v0.16b,v0.16b,v20.16b + eor v1.16b,v1.16b,v21.16b + eor v2.16b,v2.16b,v22.16b + eor v3.16b,v3.16b,v23.16b + st1 {v0.16b,v1.16b,v2.16b,v3.16b},[x0],#64 + b.eq .Ldone_neon + sub x2,x2,#64 + cmp x2,#64 + b.lo .Less_than_192 + + ld1 {v20.16b,v21.16b,v22.16b,v23.16b},[x1],#64 + eor v4.16b,v4.16b,v20.16b + eor v5.16b,v5.16b,v21.16b + eor v6.16b,v6.16b,v22.16b + eor v7.16b,v7.16b,v23.16b + st1 {v4.16b,v5.16b,v6.16b,v7.16b},[x0],#64 + b.eq .Ldone_neon + sub x2,x2,#64 + + st1 {v16.16b,v17.16b,v18.16b,v19.16b},[sp] + b .Last_neon + +.Less_than_128: + st1 {v0.16b,v1.16b,v2.16b,v3.16b},[sp] + b .Last_neon +.Less_than_192: + st1 {v4.16b,v5.16b,v6.16b,v7.16b},[sp] + b .Last_neon + +.align 4 +.Last_neon: + sub x0,x0,#1 + add x1,x1,x2 + add x0,x0,x2 + add x4,sp,x2 + neg x2,x2 + +.Loop_tail_neon: + ldrb w10,[x1,x2] + ldrb w11,[x4,x2] + add x2,x2,#1 + eor w10,w10,w11 + strb w10,[x0,x2] + cbnz x2,.Loop_tail_neon + + stp xzr,xzr,[sp,#0] + stp xzr,xzr,[sp,#16] + stp xzr,xzr,[sp,#32] + stp xzr,xzr,[sp,#48] + +.Ldone_neon: + ldp x19,x20,[x29,#16] + add sp,sp,#64 + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldp x29,x30,[sp],#96 + AARCH64_VALIDATE_LINK_REGISTER + ret +.size ChaCha20_ctr32_neon,.-ChaCha20_ctr32_neon +.type ChaCha20_512_neon,%function +.align 5 +ChaCha20_512_neon: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-96]! + add x29,sp,#0 + + adrp x5,.Lsigma + add x5,x5,:lo12:.Lsigma + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + stp x27,x28,[sp,#80] + +.L512_or_more_neon: + sub sp,sp,#128+64 + + ldp x22,x23,[x5] // load sigma + ld1 {v24.4s},[x5],#16 + ldp x24,x25,[x3] // load key + ldp x26,x27,[x3,#16] + ld1 {v25.4s,v26.4s},[x3] + ldp x28,x30,[x4] // load counter + ld1 {v27.4s},[x4] + ld1 {v31.4s},[x5] +#ifdef __AARCH64EB__ + rev64 v24.4s,v24.4s + ror x24,x24,#32 + ror x25,x25,#32 + ror x26,x26,#32 + ror x27,x27,#32 + ror x28,x28,#32 + ror x30,x30,#32 +#endif + add v27.4s,v27.4s,v31.4s // += 1 + stp q24,q25,[sp,#0] // off-load key block, invariant part + add v27.4s,v27.4s,v31.4s // not typo + str q26,[sp,#32] + add v28.4s,v27.4s,v31.4s + add v29.4s,v28.4s,v31.4s + add v30.4s,v29.4s,v31.4s + shl v31.4s,v31.4s,#2 // 1 -> 4 + + stp d8,d9,[sp,#128+0] // meet ABI requirements + stp d10,d11,[sp,#128+16] + stp d12,d13,[sp,#128+32] + stp d14,d15,[sp,#128+48] + + sub x2,x2,#512 // not typo + +.Loop_outer_512_neon: + mov v0.16b,v24.16b + mov v4.16b,v24.16b + mov v8.16b,v24.16b + mov v12.16b,v24.16b + mov v16.16b,v24.16b + mov v20.16b,v24.16b + mov v1.16b,v25.16b + mov w5,w22 // unpack key block + mov v5.16b,v25.16b + lsr x6,x22,#32 + mov v9.16b,v25.16b + mov w7,w23 + mov v13.16b,v25.16b + lsr x8,x23,#32 + mov v17.16b,v25.16b + mov w9,w24 + mov v21.16b,v25.16b + lsr x10,x24,#32 + mov v3.16b,v27.16b + mov w11,w25 + mov v7.16b,v28.16b + lsr x12,x25,#32 + mov v11.16b,v29.16b + mov w13,w26 + mov v15.16b,v30.16b + lsr x14,x26,#32 + mov v2.16b,v26.16b + mov w15,w27 + mov v6.16b,v26.16b + lsr x16,x27,#32 + add v19.4s,v3.4s,v31.4s // +4 + mov w17,w28 + add v23.4s,v7.4s,v31.4s // +4 + lsr x19,x28,#32 + mov v10.16b,v26.16b + mov w20,w30 + mov v14.16b,v26.16b + lsr x21,x30,#32 + mov v18.16b,v26.16b + stp q27,q28,[sp,#48] // off-load key block, variable part + mov v22.16b,v26.16b + str q29,[sp,#80] + + mov x4,#5 + subs x2,x2,#512 +.Loop_upper_neon: + sub x4,x4,#1 + add v0.4s,v0.4s,v1.4s + add w5,w5,w9 + add v4.4s,v4.4s,v5.4s + add w6,w6,w10 + add v8.4s,v8.4s,v9.4s + add w7,w7,w11 + add v12.4s,v12.4s,v13.4s + add w8,w8,w12 + add v16.4s,v16.4s,v17.4s + eor w17,w17,w5 + add v20.4s,v20.4s,v21.4s + eor w19,w19,w6 + eor v3.16b,v3.16b,v0.16b + eor w20,w20,w7 + eor v7.16b,v7.16b,v4.16b + eor w21,w21,w8 + eor v11.16b,v11.16b,v8.16b + ror w17,w17,#16 + eor v15.16b,v15.16b,v12.16b + ror w19,w19,#16 + eor v19.16b,v19.16b,v16.16b + ror w20,w20,#16 + eor v23.16b,v23.16b,v20.16b + ror w21,w21,#16 + rev32 v3.8h,v3.8h + add w13,w13,w17 + rev32 v7.8h,v7.8h + add w14,w14,w19 + rev32 v11.8h,v11.8h + add w15,w15,w20 + rev32 v15.8h,v15.8h + add w16,w16,w21 + rev32 v19.8h,v19.8h + eor w9,w9,w13 + rev32 v23.8h,v23.8h + eor w10,w10,w14 + add v2.4s,v2.4s,v3.4s + eor w11,w11,w15 + add v6.4s,v6.4s,v7.4s + eor w12,w12,w16 + add v10.4s,v10.4s,v11.4s + ror w9,w9,#20 + add v14.4s,v14.4s,v15.4s + ror w10,w10,#20 + add v18.4s,v18.4s,v19.4s + ror w11,w11,#20 + add v22.4s,v22.4s,v23.4s + ror w12,w12,#20 + eor v24.16b,v1.16b,v2.16b + add w5,w5,w9 + eor v25.16b,v5.16b,v6.16b + add w6,w6,w10 + eor v26.16b,v9.16b,v10.16b + add w7,w7,w11 + eor v27.16b,v13.16b,v14.16b + add w8,w8,w12 + eor v28.16b,v17.16b,v18.16b + eor w17,w17,w5 + eor v29.16b,v21.16b,v22.16b + eor w19,w19,w6 + ushr v1.4s,v24.4s,#20 + eor w20,w20,w7 + ushr v5.4s,v25.4s,#20 + eor w21,w21,w8 + ushr v9.4s,v26.4s,#20 + ror w17,w17,#24 + ushr v13.4s,v27.4s,#20 + ror w19,w19,#24 + ushr v17.4s,v28.4s,#20 + ror w20,w20,#24 + ushr v21.4s,v29.4s,#20 + ror w21,w21,#24 + sli v1.4s,v24.4s,#12 + add w13,w13,w17 + sli v5.4s,v25.4s,#12 + add w14,w14,w19 + sli v9.4s,v26.4s,#12 + add w15,w15,w20 + sli v13.4s,v27.4s,#12 + add w16,w16,w21 + sli v17.4s,v28.4s,#12 + eor w9,w9,w13 + sli v21.4s,v29.4s,#12 + eor w10,w10,w14 + add v0.4s,v0.4s,v1.4s + eor w11,w11,w15 + add v4.4s,v4.4s,v5.4s + eor w12,w12,w16 + add v8.4s,v8.4s,v9.4s + ror w9,w9,#25 + add v12.4s,v12.4s,v13.4s + ror w10,w10,#25 + add v16.4s,v16.4s,v17.4s + ror w11,w11,#25 + add v20.4s,v20.4s,v21.4s + ror w12,w12,#25 + eor v24.16b,v3.16b,v0.16b + add w5,w5,w10 + eor v25.16b,v7.16b,v4.16b + add w6,w6,w11 + eor v26.16b,v11.16b,v8.16b + add w7,w7,w12 + eor v27.16b,v15.16b,v12.16b + add w8,w8,w9 + eor v28.16b,v19.16b,v16.16b + eor w21,w21,w5 + eor v29.16b,v23.16b,v20.16b + eor w17,w17,w6 + ushr v3.4s,v24.4s,#24 + eor w19,w19,w7 + ushr v7.4s,v25.4s,#24 + eor w20,w20,w8 + ushr v11.4s,v26.4s,#24 + ror w21,w21,#16 + ushr v15.4s,v27.4s,#24 + ror w17,w17,#16 + ushr v19.4s,v28.4s,#24 + ror w19,w19,#16 + ushr v23.4s,v29.4s,#24 + ror w20,w20,#16 + sli v3.4s,v24.4s,#8 + add w15,w15,w21 + sli v7.4s,v25.4s,#8 + add w16,w16,w17 + sli v11.4s,v26.4s,#8 + add w13,w13,w19 + sli v15.4s,v27.4s,#8 + add w14,w14,w20 + sli v19.4s,v28.4s,#8 + eor w10,w10,w15 + sli v23.4s,v29.4s,#8 + eor w11,w11,w16 + add v2.4s,v2.4s,v3.4s + eor w12,w12,w13 + add v6.4s,v6.4s,v7.4s + eor w9,w9,w14 + add v10.4s,v10.4s,v11.4s + ror w10,w10,#20 + add v14.4s,v14.4s,v15.4s + ror w11,w11,#20 + add v18.4s,v18.4s,v19.4s + ror w12,w12,#20 + add v22.4s,v22.4s,v23.4s + ror w9,w9,#20 + eor v24.16b,v1.16b,v2.16b + add w5,w5,w10 + eor v25.16b,v5.16b,v6.16b + add w6,w6,w11 + eor v26.16b,v9.16b,v10.16b + add w7,w7,w12 + eor v27.16b,v13.16b,v14.16b + add w8,w8,w9 + eor v28.16b,v17.16b,v18.16b + eor w21,w21,w5 + eor v29.16b,v21.16b,v22.16b + eor w17,w17,w6 + ushr v1.4s,v24.4s,#25 + eor w19,w19,w7 + ushr v5.4s,v25.4s,#25 + eor w20,w20,w8 + ushr v9.4s,v26.4s,#25 + ror w21,w21,#24 + ushr v13.4s,v27.4s,#25 + ror w17,w17,#24 + ushr v17.4s,v28.4s,#25 + ror w19,w19,#24 + ushr v21.4s,v29.4s,#25 + ror w20,w20,#24 + sli v1.4s,v24.4s,#7 + add w15,w15,w21 + sli v5.4s,v25.4s,#7 + add w16,w16,w17 + sli v9.4s,v26.4s,#7 + add w13,w13,w19 + sli v13.4s,v27.4s,#7 + add w14,w14,w20 + sli v17.4s,v28.4s,#7 + eor w10,w10,w15 + sli v21.4s,v29.4s,#7 + eor w11,w11,w16 + ext v2.16b,v2.16b,v2.16b,#8 + eor w12,w12,w13 + ext v6.16b,v6.16b,v6.16b,#8 + eor w9,w9,w14 + ext v10.16b,v10.16b,v10.16b,#8 + ror w10,w10,#25 + ext v14.16b,v14.16b,v14.16b,#8 + ror w11,w11,#25 + ext v18.16b,v18.16b,v18.16b,#8 + ror w12,w12,#25 + ext v22.16b,v22.16b,v22.16b,#8 + ror w9,w9,#25 + ext v3.16b,v3.16b,v3.16b,#12 + ext v7.16b,v7.16b,v7.16b,#12 + ext v11.16b,v11.16b,v11.16b,#12 + ext v15.16b,v15.16b,v15.16b,#12 + ext v19.16b,v19.16b,v19.16b,#12 + ext v23.16b,v23.16b,v23.16b,#12 + ext v1.16b,v1.16b,v1.16b,#4 + ext v5.16b,v5.16b,v5.16b,#4 + ext v9.16b,v9.16b,v9.16b,#4 + ext v13.16b,v13.16b,v13.16b,#4 + ext v17.16b,v17.16b,v17.16b,#4 + ext v21.16b,v21.16b,v21.16b,#4 + add v0.4s,v0.4s,v1.4s + add w5,w5,w9 + add v4.4s,v4.4s,v5.4s + add w6,w6,w10 + add v8.4s,v8.4s,v9.4s + add w7,w7,w11 + add v12.4s,v12.4s,v13.4s + add w8,w8,w12 + add v16.4s,v16.4s,v17.4s + eor w17,w17,w5 + add v20.4s,v20.4s,v21.4s + eor w19,w19,w6 + eor v3.16b,v3.16b,v0.16b + eor w20,w20,w7 + eor v7.16b,v7.16b,v4.16b + eor w21,w21,w8 + eor v11.16b,v11.16b,v8.16b + ror w17,w17,#16 + eor v15.16b,v15.16b,v12.16b + ror w19,w19,#16 + eor v19.16b,v19.16b,v16.16b + ror w20,w20,#16 + eor v23.16b,v23.16b,v20.16b + ror w21,w21,#16 + rev32 v3.8h,v3.8h + add w13,w13,w17 + rev32 v7.8h,v7.8h + add w14,w14,w19 + rev32 v11.8h,v11.8h + add w15,w15,w20 + rev32 v15.8h,v15.8h + add w16,w16,w21 + rev32 v19.8h,v19.8h + eor w9,w9,w13 + rev32 v23.8h,v23.8h + eor w10,w10,w14 + add v2.4s,v2.4s,v3.4s + eor w11,w11,w15 + add v6.4s,v6.4s,v7.4s + eor w12,w12,w16 + add v10.4s,v10.4s,v11.4s + ror w9,w9,#20 + add v14.4s,v14.4s,v15.4s + ror w10,w10,#20 + add v18.4s,v18.4s,v19.4s + ror w11,w11,#20 + add v22.4s,v22.4s,v23.4s + ror w12,w12,#20 + eor v24.16b,v1.16b,v2.16b + add w5,w5,w9 + eor v25.16b,v5.16b,v6.16b + add w6,w6,w10 + eor v26.16b,v9.16b,v10.16b + add w7,w7,w11 + eor v27.16b,v13.16b,v14.16b + add w8,w8,w12 + eor v28.16b,v17.16b,v18.16b + eor w17,w17,w5 + eor v29.16b,v21.16b,v22.16b + eor w19,w19,w6 + ushr v1.4s,v24.4s,#20 + eor w20,w20,w7 + ushr v5.4s,v25.4s,#20 + eor w21,w21,w8 + ushr v9.4s,v26.4s,#20 + ror w17,w17,#24 + ushr v13.4s,v27.4s,#20 + ror w19,w19,#24 + ushr v17.4s,v28.4s,#20 + ror w20,w20,#24 + ushr v21.4s,v29.4s,#20 + ror w21,w21,#24 + sli v1.4s,v24.4s,#12 + add w13,w13,w17 + sli v5.4s,v25.4s,#12 + add w14,w14,w19 + sli v9.4s,v26.4s,#12 + add w15,w15,w20 + sli v13.4s,v27.4s,#12 + add w16,w16,w21 + sli v17.4s,v28.4s,#12 + eor w9,w9,w13 + sli v21.4s,v29.4s,#12 + eor w10,w10,w14 + add v0.4s,v0.4s,v1.4s + eor w11,w11,w15 + add v4.4s,v4.4s,v5.4s + eor w12,w12,w16 + add v8.4s,v8.4s,v9.4s + ror w9,w9,#25 + add v12.4s,v12.4s,v13.4s + ror w10,w10,#25 + add v16.4s,v16.4s,v17.4s + ror w11,w11,#25 + add v20.4s,v20.4s,v21.4s + ror w12,w12,#25 + eor v24.16b,v3.16b,v0.16b + add w5,w5,w10 + eor v25.16b,v7.16b,v4.16b + add w6,w6,w11 + eor v26.16b,v11.16b,v8.16b + add w7,w7,w12 + eor v27.16b,v15.16b,v12.16b + add w8,w8,w9 + eor v28.16b,v19.16b,v16.16b + eor w21,w21,w5 + eor v29.16b,v23.16b,v20.16b + eor w17,w17,w6 + ushr v3.4s,v24.4s,#24 + eor w19,w19,w7 + ushr v7.4s,v25.4s,#24 + eor w20,w20,w8 + ushr v11.4s,v26.4s,#24 + ror w21,w21,#16 + ushr v15.4s,v27.4s,#24 + ror w17,w17,#16 + ushr v19.4s,v28.4s,#24 + ror w19,w19,#16 + ushr v23.4s,v29.4s,#24 + ror w20,w20,#16 + sli v3.4s,v24.4s,#8 + add w15,w15,w21 + sli v7.4s,v25.4s,#8 + add w16,w16,w17 + sli v11.4s,v26.4s,#8 + add w13,w13,w19 + sli v15.4s,v27.4s,#8 + add w14,w14,w20 + sli v19.4s,v28.4s,#8 + eor w10,w10,w15 + sli v23.4s,v29.4s,#8 + eor w11,w11,w16 + add v2.4s,v2.4s,v3.4s + eor w12,w12,w13 + add v6.4s,v6.4s,v7.4s + eor w9,w9,w14 + add v10.4s,v10.4s,v11.4s + ror w10,w10,#20 + add v14.4s,v14.4s,v15.4s + ror w11,w11,#20 + add v18.4s,v18.4s,v19.4s + ror w12,w12,#20 + add v22.4s,v22.4s,v23.4s + ror w9,w9,#20 + eor v24.16b,v1.16b,v2.16b + add w5,w5,w10 + eor v25.16b,v5.16b,v6.16b + add w6,w6,w11 + eor v26.16b,v9.16b,v10.16b + add w7,w7,w12 + eor v27.16b,v13.16b,v14.16b + add w8,w8,w9 + eor v28.16b,v17.16b,v18.16b + eor w21,w21,w5 + eor v29.16b,v21.16b,v22.16b + eor w17,w17,w6 + ushr v1.4s,v24.4s,#25 + eor w19,w19,w7 + ushr v5.4s,v25.4s,#25 + eor w20,w20,w8 + ushr v9.4s,v26.4s,#25 + ror w21,w21,#24 + ushr v13.4s,v27.4s,#25 + ror w17,w17,#24 + ushr v17.4s,v28.4s,#25 + ror w19,w19,#24 + ushr v21.4s,v29.4s,#25 + ror w20,w20,#24 + sli v1.4s,v24.4s,#7 + add w15,w15,w21 + sli v5.4s,v25.4s,#7 + add w16,w16,w17 + sli v9.4s,v26.4s,#7 + add w13,w13,w19 + sli v13.4s,v27.4s,#7 + add w14,w14,w20 + sli v17.4s,v28.4s,#7 + eor w10,w10,w15 + sli v21.4s,v29.4s,#7 + eor w11,w11,w16 + ext v2.16b,v2.16b,v2.16b,#8 + eor w12,w12,w13 + ext v6.16b,v6.16b,v6.16b,#8 + eor w9,w9,w14 + ext v10.16b,v10.16b,v10.16b,#8 + ror w10,w10,#25 + ext v14.16b,v14.16b,v14.16b,#8 + ror w11,w11,#25 + ext v18.16b,v18.16b,v18.16b,#8 + ror w12,w12,#25 + ext v22.16b,v22.16b,v22.16b,#8 + ror w9,w9,#25 + ext v3.16b,v3.16b,v3.16b,#4 + ext v7.16b,v7.16b,v7.16b,#4 + ext v11.16b,v11.16b,v11.16b,#4 + ext v15.16b,v15.16b,v15.16b,#4 + ext v19.16b,v19.16b,v19.16b,#4 + ext v23.16b,v23.16b,v23.16b,#4 + ext v1.16b,v1.16b,v1.16b,#12 + ext v5.16b,v5.16b,v5.16b,#12 + ext v9.16b,v9.16b,v9.16b,#12 + ext v13.16b,v13.16b,v13.16b,#12 + ext v17.16b,v17.16b,v17.16b,#12 + ext v21.16b,v21.16b,v21.16b,#12 + cbnz x4,.Loop_upper_neon + + add w5,w5,w22 // accumulate key block + add x6,x6,x22,lsr#32 + add w7,w7,w23 + add x8,x8,x23,lsr#32 + add w9,w9,w24 + add x10,x10,x24,lsr#32 + add w11,w11,w25 + add x12,x12,x25,lsr#32 + add w13,w13,w26 + add x14,x14,x26,lsr#32 + add w15,w15,w27 + add x16,x16,x27,lsr#32 + add w17,w17,w28 + add x19,x19,x28,lsr#32 + add w20,w20,w30 + add x21,x21,x30,lsr#32 + + add x5,x5,x6,lsl#32 // pack + add x7,x7,x8,lsl#32 + ldp x6,x8,[x1,#0] // load input + add x9,x9,x10,lsl#32 + add x11,x11,x12,lsl#32 + ldp x10,x12,[x1,#16] + add x13,x13,x14,lsl#32 + add x15,x15,x16,lsl#32 + ldp x14,x16,[x1,#32] + add x17,x17,x19,lsl#32 + add x20,x20,x21,lsl#32 + ldp x19,x21,[x1,#48] + add x1,x1,#64 +#ifdef __AARCH64EB__ + rev x5,x5 + rev x7,x7 + rev x9,x9 + rev x11,x11 + rev x13,x13 + rev x15,x15 + rev x17,x17 + rev x20,x20 +#endif + eor x5,x5,x6 + eor x7,x7,x8 + eor x9,x9,x10 + eor x11,x11,x12 + eor x13,x13,x14 + eor x15,x15,x16 + eor x17,x17,x19 + eor x20,x20,x21 + + stp x5,x7,[x0,#0] // store output + add x28,x28,#1 // increment counter + mov w5,w22 // unpack key block + lsr x6,x22,#32 + stp x9,x11,[x0,#16] + mov w7,w23 + lsr x8,x23,#32 + stp x13,x15,[x0,#32] + mov w9,w24 + lsr x10,x24,#32 + stp x17,x20,[x0,#48] + add x0,x0,#64 + mov w11,w25 + lsr x12,x25,#32 + mov w13,w26 + lsr x14,x26,#32 + mov w15,w27 + lsr x16,x27,#32 + mov w17,w28 + lsr x19,x28,#32 + mov w20,w30 + lsr x21,x30,#32 + + mov x4,#5 +.Loop_lower_neon: + sub x4,x4,#1 + add v0.4s,v0.4s,v1.4s + add w5,w5,w9 + add v4.4s,v4.4s,v5.4s + add w6,w6,w10 + add v8.4s,v8.4s,v9.4s + add w7,w7,w11 + add v12.4s,v12.4s,v13.4s + add w8,w8,w12 + add v16.4s,v16.4s,v17.4s + eor w17,w17,w5 + add v20.4s,v20.4s,v21.4s + eor w19,w19,w6 + eor v3.16b,v3.16b,v0.16b + eor w20,w20,w7 + eor v7.16b,v7.16b,v4.16b + eor w21,w21,w8 + eor v11.16b,v11.16b,v8.16b + ror w17,w17,#16 + eor v15.16b,v15.16b,v12.16b + ror w19,w19,#16 + eor v19.16b,v19.16b,v16.16b + ror w20,w20,#16 + eor v23.16b,v23.16b,v20.16b + ror w21,w21,#16 + rev32 v3.8h,v3.8h + add w13,w13,w17 + rev32 v7.8h,v7.8h + add w14,w14,w19 + rev32 v11.8h,v11.8h + add w15,w15,w20 + rev32 v15.8h,v15.8h + add w16,w16,w21 + rev32 v19.8h,v19.8h + eor w9,w9,w13 + rev32 v23.8h,v23.8h + eor w10,w10,w14 + add v2.4s,v2.4s,v3.4s + eor w11,w11,w15 + add v6.4s,v6.4s,v7.4s + eor w12,w12,w16 + add v10.4s,v10.4s,v11.4s + ror w9,w9,#20 + add v14.4s,v14.4s,v15.4s + ror w10,w10,#20 + add v18.4s,v18.4s,v19.4s + ror w11,w11,#20 + add v22.4s,v22.4s,v23.4s + ror w12,w12,#20 + eor v24.16b,v1.16b,v2.16b + add w5,w5,w9 + eor v25.16b,v5.16b,v6.16b + add w6,w6,w10 + eor v26.16b,v9.16b,v10.16b + add w7,w7,w11 + eor v27.16b,v13.16b,v14.16b + add w8,w8,w12 + eor v28.16b,v17.16b,v18.16b + eor w17,w17,w5 + eor v29.16b,v21.16b,v22.16b + eor w19,w19,w6 + ushr v1.4s,v24.4s,#20 + eor w20,w20,w7 + ushr v5.4s,v25.4s,#20 + eor w21,w21,w8 + ushr v9.4s,v26.4s,#20 + ror w17,w17,#24 + ushr v13.4s,v27.4s,#20 + ror w19,w19,#24 + ushr v17.4s,v28.4s,#20 + ror w20,w20,#24 + ushr v21.4s,v29.4s,#20 + ror w21,w21,#24 + sli v1.4s,v24.4s,#12 + add w13,w13,w17 + sli v5.4s,v25.4s,#12 + add w14,w14,w19 + sli v9.4s,v26.4s,#12 + add w15,w15,w20 + sli v13.4s,v27.4s,#12 + add w16,w16,w21 + sli v17.4s,v28.4s,#12 + eor w9,w9,w13 + sli v21.4s,v29.4s,#12 + eor w10,w10,w14 + add v0.4s,v0.4s,v1.4s + eor w11,w11,w15 + add v4.4s,v4.4s,v5.4s + eor w12,w12,w16 + add v8.4s,v8.4s,v9.4s + ror w9,w9,#25 + add v12.4s,v12.4s,v13.4s + ror w10,w10,#25 + add v16.4s,v16.4s,v17.4s + ror w11,w11,#25 + add v20.4s,v20.4s,v21.4s + ror w12,w12,#25 + eor v24.16b,v3.16b,v0.16b + add w5,w5,w10 + eor v25.16b,v7.16b,v4.16b + add w6,w6,w11 + eor v26.16b,v11.16b,v8.16b + add w7,w7,w12 + eor v27.16b,v15.16b,v12.16b + add w8,w8,w9 + eor v28.16b,v19.16b,v16.16b + eor w21,w21,w5 + eor v29.16b,v23.16b,v20.16b + eor w17,w17,w6 + ushr v3.4s,v24.4s,#24 + eor w19,w19,w7 + ushr v7.4s,v25.4s,#24 + eor w20,w20,w8 + ushr v11.4s,v26.4s,#24 + ror w21,w21,#16 + ushr v15.4s,v27.4s,#24 + ror w17,w17,#16 + ushr v19.4s,v28.4s,#24 + ror w19,w19,#16 + ushr v23.4s,v29.4s,#24 + ror w20,w20,#16 + sli v3.4s,v24.4s,#8 + add w15,w15,w21 + sli v7.4s,v25.4s,#8 + add w16,w16,w17 + sli v11.4s,v26.4s,#8 + add w13,w13,w19 + sli v15.4s,v27.4s,#8 + add w14,w14,w20 + sli v19.4s,v28.4s,#8 + eor w10,w10,w15 + sli v23.4s,v29.4s,#8 + eor w11,w11,w16 + add v2.4s,v2.4s,v3.4s + eor w12,w12,w13 + add v6.4s,v6.4s,v7.4s + eor w9,w9,w14 + add v10.4s,v10.4s,v11.4s + ror w10,w10,#20 + add v14.4s,v14.4s,v15.4s + ror w11,w11,#20 + add v18.4s,v18.4s,v19.4s + ror w12,w12,#20 + add v22.4s,v22.4s,v23.4s + ror w9,w9,#20 + eor v24.16b,v1.16b,v2.16b + add w5,w5,w10 + eor v25.16b,v5.16b,v6.16b + add w6,w6,w11 + eor v26.16b,v9.16b,v10.16b + add w7,w7,w12 + eor v27.16b,v13.16b,v14.16b + add w8,w8,w9 + eor v28.16b,v17.16b,v18.16b + eor w21,w21,w5 + eor v29.16b,v21.16b,v22.16b + eor w17,w17,w6 + ushr v1.4s,v24.4s,#25 + eor w19,w19,w7 + ushr v5.4s,v25.4s,#25 + eor w20,w20,w8 + ushr v9.4s,v26.4s,#25 + ror w21,w21,#24 + ushr v13.4s,v27.4s,#25 + ror w17,w17,#24 + ushr v17.4s,v28.4s,#25 + ror w19,w19,#24 + ushr v21.4s,v29.4s,#25 + ror w20,w20,#24 + sli v1.4s,v24.4s,#7 + add w15,w15,w21 + sli v5.4s,v25.4s,#7 + add w16,w16,w17 + sli v9.4s,v26.4s,#7 + add w13,w13,w19 + sli v13.4s,v27.4s,#7 + add w14,w14,w20 + sli v17.4s,v28.4s,#7 + eor w10,w10,w15 + sli v21.4s,v29.4s,#7 + eor w11,w11,w16 + ext v2.16b,v2.16b,v2.16b,#8 + eor w12,w12,w13 + ext v6.16b,v6.16b,v6.16b,#8 + eor w9,w9,w14 + ext v10.16b,v10.16b,v10.16b,#8 + ror w10,w10,#25 + ext v14.16b,v14.16b,v14.16b,#8 + ror w11,w11,#25 + ext v18.16b,v18.16b,v18.16b,#8 + ror w12,w12,#25 + ext v22.16b,v22.16b,v22.16b,#8 + ror w9,w9,#25 + ext v3.16b,v3.16b,v3.16b,#12 + ext v7.16b,v7.16b,v7.16b,#12 + ext v11.16b,v11.16b,v11.16b,#12 + ext v15.16b,v15.16b,v15.16b,#12 + ext v19.16b,v19.16b,v19.16b,#12 + ext v23.16b,v23.16b,v23.16b,#12 + ext v1.16b,v1.16b,v1.16b,#4 + ext v5.16b,v5.16b,v5.16b,#4 + ext v9.16b,v9.16b,v9.16b,#4 + ext v13.16b,v13.16b,v13.16b,#4 + ext v17.16b,v17.16b,v17.16b,#4 + ext v21.16b,v21.16b,v21.16b,#4 + add v0.4s,v0.4s,v1.4s + add w5,w5,w9 + add v4.4s,v4.4s,v5.4s + add w6,w6,w10 + add v8.4s,v8.4s,v9.4s + add w7,w7,w11 + add v12.4s,v12.4s,v13.4s + add w8,w8,w12 + add v16.4s,v16.4s,v17.4s + eor w17,w17,w5 + add v20.4s,v20.4s,v21.4s + eor w19,w19,w6 + eor v3.16b,v3.16b,v0.16b + eor w20,w20,w7 + eor v7.16b,v7.16b,v4.16b + eor w21,w21,w8 + eor v11.16b,v11.16b,v8.16b + ror w17,w17,#16 + eor v15.16b,v15.16b,v12.16b + ror w19,w19,#16 + eor v19.16b,v19.16b,v16.16b + ror w20,w20,#16 + eor v23.16b,v23.16b,v20.16b + ror w21,w21,#16 + rev32 v3.8h,v3.8h + add w13,w13,w17 + rev32 v7.8h,v7.8h + add w14,w14,w19 + rev32 v11.8h,v11.8h + add w15,w15,w20 + rev32 v15.8h,v15.8h + add w16,w16,w21 + rev32 v19.8h,v19.8h + eor w9,w9,w13 + rev32 v23.8h,v23.8h + eor w10,w10,w14 + add v2.4s,v2.4s,v3.4s + eor w11,w11,w15 + add v6.4s,v6.4s,v7.4s + eor w12,w12,w16 + add v10.4s,v10.4s,v11.4s + ror w9,w9,#20 + add v14.4s,v14.4s,v15.4s + ror w10,w10,#20 + add v18.4s,v18.4s,v19.4s + ror w11,w11,#20 + add v22.4s,v22.4s,v23.4s + ror w12,w12,#20 + eor v24.16b,v1.16b,v2.16b + add w5,w5,w9 + eor v25.16b,v5.16b,v6.16b + add w6,w6,w10 + eor v26.16b,v9.16b,v10.16b + add w7,w7,w11 + eor v27.16b,v13.16b,v14.16b + add w8,w8,w12 + eor v28.16b,v17.16b,v18.16b + eor w17,w17,w5 + eor v29.16b,v21.16b,v22.16b + eor w19,w19,w6 + ushr v1.4s,v24.4s,#20 + eor w20,w20,w7 + ushr v5.4s,v25.4s,#20 + eor w21,w21,w8 + ushr v9.4s,v26.4s,#20 + ror w17,w17,#24 + ushr v13.4s,v27.4s,#20 + ror w19,w19,#24 + ushr v17.4s,v28.4s,#20 + ror w20,w20,#24 + ushr v21.4s,v29.4s,#20 + ror w21,w21,#24 + sli v1.4s,v24.4s,#12 + add w13,w13,w17 + sli v5.4s,v25.4s,#12 + add w14,w14,w19 + sli v9.4s,v26.4s,#12 + add w15,w15,w20 + sli v13.4s,v27.4s,#12 + add w16,w16,w21 + sli v17.4s,v28.4s,#12 + eor w9,w9,w13 + sli v21.4s,v29.4s,#12 + eor w10,w10,w14 + add v0.4s,v0.4s,v1.4s + eor w11,w11,w15 + add v4.4s,v4.4s,v5.4s + eor w12,w12,w16 + add v8.4s,v8.4s,v9.4s + ror w9,w9,#25 + add v12.4s,v12.4s,v13.4s + ror w10,w10,#25 + add v16.4s,v16.4s,v17.4s + ror w11,w11,#25 + add v20.4s,v20.4s,v21.4s + ror w12,w12,#25 + eor v24.16b,v3.16b,v0.16b + add w5,w5,w10 + eor v25.16b,v7.16b,v4.16b + add w6,w6,w11 + eor v26.16b,v11.16b,v8.16b + add w7,w7,w12 + eor v27.16b,v15.16b,v12.16b + add w8,w8,w9 + eor v28.16b,v19.16b,v16.16b + eor w21,w21,w5 + eor v29.16b,v23.16b,v20.16b + eor w17,w17,w6 + ushr v3.4s,v24.4s,#24 + eor w19,w19,w7 + ushr v7.4s,v25.4s,#24 + eor w20,w20,w8 + ushr v11.4s,v26.4s,#24 + ror w21,w21,#16 + ushr v15.4s,v27.4s,#24 + ror w17,w17,#16 + ushr v19.4s,v28.4s,#24 + ror w19,w19,#16 + ushr v23.4s,v29.4s,#24 + ror w20,w20,#16 + sli v3.4s,v24.4s,#8 + add w15,w15,w21 + sli v7.4s,v25.4s,#8 + add w16,w16,w17 + sli v11.4s,v26.4s,#8 + add w13,w13,w19 + sli v15.4s,v27.4s,#8 + add w14,w14,w20 + sli v19.4s,v28.4s,#8 + eor w10,w10,w15 + sli v23.4s,v29.4s,#8 + eor w11,w11,w16 + add v2.4s,v2.4s,v3.4s + eor w12,w12,w13 + add v6.4s,v6.4s,v7.4s + eor w9,w9,w14 + add v10.4s,v10.4s,v11.4s + ror w10,w10,#20 + add v14.4s,v14.4s,v15.4s + ror w11,w11,#20 + add v18.4s,v18.4s,v19.4s + ror w12,w12,#20 + add v22.4s,v22.4s,v23.4s + ror w9,w9,#20 + eor v24.16b,v1.16b,v2.16b + add w5,w5,w10 + eor v25.16b,v5.16b,v6.16b + add w6,w6,w11 + eor v26.16b,v9.16b,v10.16b + add w7,w7,w12 + eor v27.16b,v13.16b,v14.16b + add w8,w8,w9 + eor v28.16b,v17.16b,v18.16b + eor w21,w21,w5 + eor v29.16b,v21.16b,v22.16b + eor w17,w17,w6 + ushr v1.4s,v24.4s,#25 + eor w19,w19,w7 + ushr v5.4s,v25.4s,#25 + eor w20,w20,w8 + ushr v9.4s,v26.4s,#25 + ror w21,w21,#24 + ushr v13.4s,v27.4s,#25 + ror w17,w17,#24 + ushr v17.4s,v28.4s,#25 + ror w19,w19,#24 + ushr v21.4s,v29.4s,#25 + ror w20,w20,#24 + sli v1.4s,v24.4s,#7 + add w15,w15,w21 + sli v5.4s,v25.4s,#7 + add w16,w16,w17 + sli v9.4s,v26.4s,#7 + add w13,w13,w19 + sli v13.4s,v27.4s,#7 + add w14,w14,w20 + sli v17.4s,v28.4s,#7 + eor w10,w10,w15 + sli v21.4s,v29.4s,#7 + eor w11,w11,w16 + ext v2.16b,v2.16b,v2.16b,#8 + eor w12,w12,w13 + ext v6.16b,v6.16b,v6.16b,#8 + eor w9,w9,w14 + ext v10.16b,v10.16b,v10.16b,#8 + ror w10,w10,#25 + ext v14.16b,v14.16b,v14.16b,#8 + ror w11,w11,#25 + ext v18.16b,v18.16b,v18.16b,#8 + ror w12,w12,#25 + ext v22.16b,v22.16b,v22.16b,#8 + ror w9,w9,#25 + ext v3.16b,v3.16b,v3.16b,#4 + ext v7.16b,v7.16b,v7.16b,#4 + ext v11.16b,v11.16b,v11.16b,#4 + ext v15.16b,v15.16b,v15.16b,#4 + ext v19.16b,v19.16b,v19.16b,#4 + ext v23.16b,v23.16b,v23.16b,#4 + ext v1.16b,v1.16b,v1.16b,#12 + ext v5.16b,v5.16b,v5.16b,#12 + ext v9.16b,v9.16b,v9.16b,#12 + ext v13.16b,v13.16b,v13.16b,#12 + ext v17.16b,v17.16b,v17.16b,#12 + ext v21.16b,v21.16b,v21.16b,#12 + cbnz x4,.Loop_lower_neon + + add w5,w5,w22 // accumulate key block + ldp q24,q25,[sp,#0] + add x6,x6,x22,lsr#32 + ldp q26,q27,[sp,#32] + add w7,w7,w23 + ldp q28,q29,[sp,#64] + add x8,x8,x23,lsr#32 + add v0.4s,v0.4s,v24.4s + add w9,w9,w24 + add v4.4s,v4.4s,v24.4s + add x10,x10,x24,lsr#32 + add v8.4s,v8.4s,v24.4s + add w11,w11,w25 + add v12.4s,v12.4s,v24.4s + add x12,x12,x25,lsr#32 + add v16.4s,v16.4s,v24.4s + add w13,w13,w26 + add v20.4s,v20.4s,v24.4s + add x14,x14,x26,lsr#32 + add v2.4s,v2.4s,v26.4s + add w15,w15,w27 + add v6.4s,v6.4s,v26.4s + add x16,x16,x27,lsr#32 + add v10.4s,v10.4s,v26.4s + add w17,w17,w28 + add v14.4s,v14.4s,v26.4s + add x19,x19,x28,lsr#32 + add v18.4s,v18.4s,v26.4s + add w20,w20,w30 + add v22.4s,v22.4s,v26.4s + add x21,x21,x30,lsr#32 + add v19.4s,v19.4s,v31.4s // +4 + add x5,x5,x6,lsl#32 // pack + add v23.4s,v23.4s,v31.4s // +4 + add x7,x7,x8,lsl#32 + add v3.4s,v3.4s,v27.4s + ldp x6,x8,[x1,#0] // load input + add v7.4s,v7.4s,v28.4s + add x9,x9,x10,lsl#32 + add v11.4s,v11.4s,v29.4s + add x11,x11,x12,lsl#32 + add v15.4s,v15.4s,v30.4s + ldp x10,x12,[x1,#16] + add v19.4s,v19.4s,v27.4s + add x13,x13,x14,lsl#32 + add v23.4s,v23.4s,v28.4s + add x15,x15,x16,lsl#32 + add v1.4s,v1.4s,v25.4s + ldp x14,x16,[x1,#32] + add v5.4s,v5.4s,v25.4s + add x17,x17,x19,lsl#32 + add v9.4s,v9.4s,v25.4s + add x20,x20,x21,lsl#32 + add v13.4s,v13.4s,v25.4s + ldp x19,x21,[x1,#48] + add v17.4s,v17.4s,v25.4s + add x1,x1,#64 + add v21.4s,v21.4s,v25.4s + +#ifdef __AARCH64EB__ + rev x5,x5 + rev x7,x7 + rev x9,x9 + rev x11,x11 + rev x13,x13 + rev x15,x15 + rev x17,x17 + rev x20,x20 +#endif + ld1 {v24.16b,v25.16b,v26.16b,v27.16b},[x1],#64 + eor x5,x5,x6 + eor x7,x7,x8 + eor x9,x9,x10 + eor x11,x11,x12 + eor x13,x13,x14 + eor v0.16b,v0.16b,v24.16b + eor x15,x15,x16 + eor v1.16b,v1.16b,v25.16b + eor x17,x17,x19 + eor v2.16b,v2.16b,v26.16b + eor x20,x20,x21 + eor v3.16b,v3.16b,v27.16b + ld1 {v24.16b,v25.16b,v26.16b,v27.16b},[x1],#64 + + stp x5,x7,[x0,#0] // store output + add x28,x28,#7 // increment counter + stp x9,x11,[x0,#16] + stp x13,x15,[x0,#32] + stp x17,x20,[x0,#48] + add x0,x0,#64 + st1 {v0.16b,v1.16b,v2.16b,v3.16b},[x0],#64 + + ld1 {v0.16b,v1.16b,v2.16b,v3.16b},[x1],#64 + eor v4.16b,v4.16b,v24.16b + eor v5.16b,v5.16b,v25.16b + eor v6.16b,v6.16b,v26.16b + eor v7.16b,v7.16b,v27.16b + st1 {v4.16b,v5.16b,v6.16b,v7.16b},[x0],#64 + + ld1 {v4.16b,v5.16b,v6.16b,v7.16b},[x1],#64 + eor v8.16b,v8.16b,v0.16b + ldp q24,q25,[sp,#0] + eor v9.16b,v9.16b,v1.16b + ldp q26,q27,[sp,#32] + eor v10.16b,v10.16b,v2.16b + eor v11.16b,v11.16b,v3.16b + st1 {v8.16b,v9.16b,v10.16b,v11.16b},[x0],#64 + + ld1 {v8.16b,v9.16b,v10.16b,v11.16b},[x1],#64 + eor v12.16b,v12.16b,v4.16b + eor v13.16b,v13.16b,v5.16b + eor v14.16b,v14.16b,v6.16b + eor v15.16b,v15.16b,v7.16b + st1 {v12.16b,v13.16b,v14.16b,v15.16b},[x0],#64 + + ld1 {v12.16b,v13.16b,v14.16b,v15.16b},[x1],#64 + eor v16.16b,v16.16b,v8.16b + eor v17.16b,v17.16b,v9.16b + eor v18.16b,v18.16b,v10.16b + eor v19.16b,v19.16b,v11.16b + st1 {v16.16b,v17.16b,v18.16b,v19.16b},[x0],#64 + + shl v0.4s,v31.4s,#1 // 4 -> 8 + eor v20.16b,v20.16b,v12.16b + eor v21.16b,v21.16b,v13.16b + eor v22.16b,v22.16b,v14.16b + eor v23.16b,v23.16b,v15.16b + st1 {v20.16b,v21.16b,v22.16b,v23.16b},[x0],#64 + + add v27.4s,v27.4s,v0.4s // += 8 + add v28.4s,v28.4s,v0.4s + add v29.4s,v29.4s,v0.4s + add v30.4s,v30.4s,v0.4s + + b.hs .Loop_outer_512_neon + + adds x2,x2,#512 + ushr v0.4s,v31.4s,#2 // 4 -> 1 + + ldp d8,d9,[sp,#128+0] // meet ABI requirements + ldp d10,d11,[sp,#128+16] + ldp d12,d13,[sp,#128+32] + ldp d14,d15,[sp,#128+48] + + stp q24,q31,[sp,#0] // wipe off-load area + stp q24,q31,[sp,#32] + stp q24,q31,[sp,#64] + + b.eq .Ldone_512_neon + + cmp x2,#192 + sub v27.4s,v27.4s,v0.4s // -= 1 + sub v28.4s,v28.4s,v0.4s + sub v29.4s,v29.4s,v0.4s + add sp,sp,#128 + b.hs .Loop_outer_neon + + eor v25.16b,v25.16b,v25.16b + eor v26.16b,v26.16b,v26.16b + eor v27.16b,v27.16b,v27.16b + eor v28.16b,v28.16b,v28.16b + eor v29.16b,v29.16b,v29.16b + eor v30.16b,v30.16b,v30.16b + b .Loop_outer + +.Ldone_512_neon: + ldp x19,x20,[x29,#16] + add sp,sp,#128+64 + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldp x29,x30,[sp],#96 + AARCH64_VALIDATE_LINK_REGISTER + ret +.size ChaCha20_512_neon,.-ChaCha20_512_neon +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__ELF__) diff --git a/http/vendor/ring/pregenerated/chacha-armv8-win64.S b/http/vendor/ring/pregenerated/chacha-armv8-win64.S new file mode 100644 index 0000000..12d0542 --- /dev/null +++ b/http/vendor/ring/pregenerated/chacha-armv8-win64.S @@ -0,0 +1,1972 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(_WIN32) +.section .rodata + +.align 5 +Lsigma: +.quad 0x3320646e61707865,0x6b20657479622d32 // endian-neutral +Lone: +.long 1,0,0,0 +.byte 67,104,97,67,104,97,50,48,32,102,111,114,32,65,82,77,118,56,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.align 2 + +.text + +.globl ChaCha20_ctr32_nohw + +.def ChaCha20_ctr32_nohw + .type 32 +.endef +.align 5 +ChaCha20_ctr32_nohw: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-96]! + add x29,sp,#0 + + adrp x5,Lsigma + add x5,x5,:lo12:Lsigma + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + stp x27,x28,[sp,#80] + sub sp,sp,#64 + + ldp x22,x23,[x5] // load sigma + ldp x24,x25,[x3] // load key + ldp x26,x27,[x3,#16] + ldp x28,x30,[x4] // load counter +#ifdef __AARCH64EB__ + ror x24,x24,#32 + ror x25,x25,#32 + ror x26,x26,#32 + ror x27,x27,#32 + ror x28,x28,#32 + ror x30,x30,#32 +#endif + +Loop_outer: + mov w5,w22 // unpack key block + lsr x6,x22,#32 + mov w7,w23 + lsr x8,x23,#32 + mov w9,w24 + lsr x10,x24,#32 + mov w11,w25 + lsr x12,x25,#32 + mov w13,w26 + lsr x14,x26,#32 + mov w15,w27 + lsr x16,x27,#32 + mov w17,w28 + lsr x19,x28,#32 + mov w20,w30 + lsr x21,x30,#32 + + mov x4,#10 + subs x2,x2,#64 +Loop: + sub x4,x4,#1 + add w5,w5,w9 + add w6,w6,w10 + add w7,w7,w11 + add w8,w8,w12 + eor w17,w17,w5 + eor w19,w19,w6 + eor w20,w20,w7 + eor w21,w21,w8 + ror w17,w17,#16 + ror w19,w19,#16 + ror w20,w20,#16 + ror w21,w21,#16 + add w13,w13,w17 + add w14,w14,w19 + add w15,w15,w20 + add w16,w16,w21 + eor w9,w9,w13 + eor w10,w10,w14 + eor w11,w11,w15 + eor w12,w12,w16 + ror w9,w9,#20 + ror w10,w10,#20 + ror w11,w11,#20 + ror w12,w12,#20 + add w5,w5,w9 + add w6,w6,w10 + add w7,w7,w11 + add w8,w8,w12 + eor w17,w17,w5 + eor w19,w19,w6 + eor w20,w20,w7 + eor w21,w21,w8 + ror w17,w17,#24 + ror w19,w19,#24 + ror w20,w20,#24 + ror w21,w21,#24 + add w13,w13,w17 + add w14,w14,w19 + add w15,w15,w20 + add w16,w16,w21 + eor w9,w9,w13 + eor w10,w10,w14 + eor w11,w11,w15 + eor w12,w12,w16 + ror w9,w9,#25 + ror w10,w10,#25 + ror w11,w11,#25 + ror w12,w12,#25 + add w5,w5,w10 + add w6,w6,w11 + add w7,w7,w12 + add w8,w8,w9 + eor w21,w21,w5 + eor w17,w17,w6 + eor w19,w19,w7 + eor w20,w20,w8 + ror w21,w21,#16 + ror w17,w17,#16 + ror w19,w19,#16 + ror w20,w20,#16 + add w15,w15,w21 + add w16,w16,w17 + add w13,w13,w19 + add w14,w14,w20 + eor w10,w10,w15 + eor w11,w11,w16 + eor w12,w12,w13 + eor w9,w9,w14 + ror w10,w10,#20 + ror w11,w11,#20 + ror w12,w12,#20 + ror w9,w9,#20 + add w5,w5,w10 + add w6,w6,w11 + add w7,w7,w12 + add w8,w8,w9 + eor w21,w21,w5 + eor w17,w17,w6 + eor w19,w19,w7 + eor w20,w20,w8 + ror w21,w21,#24 + ror w17,w17,#24 + ror w19,w19,#24 + ror w20,w20,#24 + add w15,w15,w21 + add w16,w16,w17 + add w13,w13,w19 + add w14,w14,w20 + eor w10,w10,w15 + eor w11,w11,w16 + eor w12,w12,w13 + eor w9,w9,w14 + ror w10,w10,#25 + ror w11,w11,#25 + ror w12,w12,#25 + ror w9,w9,#25 + cbnz x4,Loop + + add w5,w5,w22 // accumulate key block + add x6,x6,x22,lsr#32 + add w7,w7,w23 + add x8,x8,x23,lsr#32 + add w9,w9,w24 + add x10,x10,x24,lsr#32 + add w11,w11,w25 + add x12,x12,x25,lsr#32 + add w13,w13,w26 + add x14,x14,x26,lsr#32 + add w15,w15,w27 + add x16,x16,x27,lsr#32 + add w17,w17,w28 + add x19,x19,x28,lsr#32 + add w20,w20,w30 + add x21,x21,x30,lsr#32 + + b.lo Ltail + + add x5,x5,x6,lsl#32 // pack + add x7,x7,x8,lsl#32 + ldp x6,x8,[x1,#0] // load input + add x9,x9,x10,lsl#32 + add x11,x11,x12,lsl#32 + ldp x10,x12,[x1,#16] + add x13,x13,x14,lsl#32 + add x15,x15,x16,lsl#32 + ldp x14,x16,[x1,#32] + add x17,x17,x19,lsl#32 + add x20,x20,x21,lsl#32 + ldp x19,x21,[x1,#48] + add x1,x1,#64 +#ifdef __AARCH64EB__ + rev x5,x5 + rev x7,x7 + rev x9,x9 + rev x11,x11 + rev x13,x13 + rev x15,x15 + rev x17,x17 + rev x20,x20 +#endif + eor x5,x5,x6 + eor x7,x7,x8 + eor x9,x9,x10 + eor x11,x11,x12 + eor x13,x13,x14 + eor x15,x15,x16 + eor x17,x17,x19 + eor x20,x20,x21 + + stp x5,x7,[x0,#0] // store output + add x28,x28,#1 // increment counter + stp x9,x11,[x0,#16] + stp x13,x15,[x0,#32] + stp x17,x20,[x0,#48] + add x0,x0,#64 + + b.hi Loop_outer + + ldp x19,x20,[x29,#16] + add sp,sp,#64 + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldp x29,x30,[sp],#96 + AARCH64_VALIDATE_LINK_REGISTER + ret + +.align 4 +Ltail: + add x2,x2,#64 +Less_than_64: + sub x0,x0,#1 + add x1,x1,x2 + add x0,x0,x2 + add x4,sp,x2 + neg x2,x2 + + add x5,x5,x6,lsl#32 // pack + add x7,x7,x8,lsl#32 + add x9,x9,x10,lsl#32 + add x11,x11,x12,lsl#32 + add x13,x13,x14,lsl#32 + add x15,x15,x16,lsl#32 + add x17,x17,x19,lsl#32 + add x20,x20,x21,lsl#32 +#ifdef __AARCH64EB__ + rev x5,x5 + rev x7,x7 + rev x9,x9 + rev x11,x11 + rev x13,x13 + rev x15,x15 + rev x17,x17 + rev x20,x20 +#endif + stp x5,x7,[sp,#0] + stp x9,x11,[sp,#16] + stp x13,x15,[sp,#32] + stp x17,x20,[sp,#48] + +Loop_tail: + ldrb w10,[x1,x2] + ldrb w11,[x4,x2] + add x2,x2,#1 + eor w10,w10,w11 + strb w10,[x0,x2] + cbnz x2,Loop_tail + + stp xzr,xzr,[sp,#0] + stp xzr,xzr,[sp,#16] + stp xzr,xzr,[sp,#32] + stp xzr,xzr,[sp,#48] + + ldp x19,x20,[x29,#16] + add sp,sp,#64 + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldp x29,x30,[sp],#96 + AARCH64_VALIDATE_LINK_REGISTER + ret + + +.globl ChaCha20_ctr32_neon + +.def ChaCha20_ctr32_neon + .type 32 +.endef +.align 5 +ChaCha20_ctr32_neon: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-96]! + add x29,sp,#0 + + adrp x5,Lsigma + add x5,x5,:lo12:Lsigma + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + stp x27,x28,[sp,#80] + cmp x2,#512 + b.hs L512_or_more_neon + + sub sp,sp,#64 + + ldp x22,x23,[x5] // load sigma + ld1 {v24.4s},[x5],#16 + ldp x24,x25,[x3] // load key + ldp x26,x27,[x3,#16] + ld1 {v25.4s,v26.4s},[x3] + ldp x28,x30,[x4] // load counter + ld1 {v27.4s},[x4] + ld1 {v31.4s},[x5] +#ifdef __AARCH64EB__ + rev64 v24.4s,v24.4s + ror x24,x24,#32 + ror x25,x25,#32 + ror x26,x26,#32 + ror x27,x27,#32 + ror x28,x28,#32 + ror x30,x30,#32 +#endif + add v27.4s,v27.4s,v31.4s // += 1 + add v28.4s,v27.4s,v31.4s + add v29.4s,v28.4s,v31.4s + shl v31.4s,v31.4s,#2 // 1 -> 4 + +Loop_outer_neon: + mov w5,w22 // unpack key block + lsr x6,x22,#32 + mov v0.16b,v24.16b + mov w7,w23 + lsr x8,x23,#32 + mov v4.16b,v24.16b + mov w9,w24 + lsr x10,x24,#32 + mov v16.16b,v24.16b + mov w11,w25 + mov v1.16b,v25.16b + lsr x12,x25,#32 + mov v5.16b,v25.16b + mov w13,w26 + mov v17.16b,v25.16b + lsr x14,x26,#32 + mov v3.16b,v27.16b + mov w15,w27 + mov v7.16b,v28.16b + lsr x16,x27,#32 + mov v19.16b,v29.16b + mov w17,w28 + mov v2.16b,v26.16b + lsr x19,x28,#32 + mov v6.16b,v26.16b + mov w20,w30 + mov v18.16b,v26.16b + lsr x21,x30,#32 + + mov x4,#10 + subs x2,x2,#256 +Loop_neon: + sub x4,x4,#1 + add v0.4s,v0.4s,v1.4s + add w5,w5,w9 + add v4.4s,v4.4s,v5.4s + add w6,w6,w10 + add v16.4s,v16.4s,v17.4s + add w7,w7,w11 + eor v3.16b,v3.16b,v0.16b + add w8,w8,w12 + eor v7.16b,v7.16b,v4.16b + eor w17,w17,w5 + eor v19.16b,v19.16b,v16.16b + eor w19,w19,w6 + rev32 v3.8h,v3.8h + eor w20,w20,w7 + rev32 v7.8h,v7.8h + eor w21,w21,w8 + rev32 v19.8h,v19.8h + ror w17,w17,#16 + add v2.4s,v2.4s,v3.4s + ror w19,w19,#16 + add v6.4s,v6.4s,v7.4s + ror w20,w20,#16 + add v18.4s,v18.4s,v19.4s + ror w21,w21,#16 + eor v20.16b,v1.16b,v2.16b + add w13,w13,w17 + eor v21.16b,v5.16b,v6.16b + add w14,w14,w19 + eor v22.16b,v17.16b,v18.16b + add w15,w15,w20 + ushr v1.4s,v20.4s,#20 + add w16,w16,w21 + ushr v5.4s,v21.4s,#20 + eor w9,w9,w13 + ushr v17.4s,v22.4s,#20 + eor w10,w10,w14 + sli v1.4s,v20.4s,#12 + eor w11,w11,w15 + sli v5.4s,v21.4s,#12 + eor w12,w12,w16 + sli v17.4s,v22.4s,#12 + ror w9,w9,#20 + add v0.4s,v0.4s,v1.4s + ror w10,w10,#20 + add v4.4s,v4.4s,v5.4s + ror w11,w11,#20 + add v16.4s,v16.4s,v17.4s + ror w12,w12,#20 + eor v20.16b,v3.16b,v0.16b + add w5,w5,w9 + eor v21.16b,v7.16b,v4.16b + add w6,w6,w10 + eor v22.16b,v19.16b,v16.16b + add w7,w7,w11 + ushr v3.4s,v20.4s,#24 + add w8,w8,w12 + ushr v7.4s,v21.4s,#24 + eor w17,w17,w5 + ushr v19.4s,v22.4s,#24 + eor w19,w19,w6 + sli v3.4s,v20.4s,#8 + eor w20,w20,w7 + sli v7.4s,v21.4s,#8 + eor w21,w21,w8 + sli v19.4s,v22.4s,#8 + ror w17,w17,#24 + add v2.4s,v2.4s,v3.4s + ror w19,w19,#24 + add v6.4s,v6.4s,v7.4s + ror w20,w20,#24 + add v18.4s,v18.4s,v19.4s + ror w21,w21,#24 + eor v20.16b,v1.16b,v2.16b + add w13,w13,w17 + eor v21.16b,v5.16b,v6.16b + add w14,w14,w19 + eor v22.16b,v17.16b,v18.16b + add w15,w15,w20 + ushr v1.4s,v20.4s,#25 + add w16,w16,w21 + ushr v5.4s,v21.4s,#25 + eor w9,w9,w13 + ushr v17.4s,v22.4s,#25 + eor w10,w10,w14 + sli v1.4s,v20.4s,#7 + eor w11,w11,w15 + sli v5.4s,v21.4s,#7 + eor w12,w12,w16 + sli v17.4s,v22.4s,#7 + ror w9,w9,#25 + ext v2.16b,v2.16b,v2.16b,#8 + ror w10,w10,#25 + ext v6.16b,v6.16b,v6.16b,#8 + ror w11,w11,#25 + ext v18.16b,v18.16b,v18.16b,#8 + ror w12,w12,#25 + ext v3.16b,v3.16b,v3.16b,#12 + ext v7.16b,v7.16b,v7.16b,#12 + ext v19.16b,v19.16b,v19.16b,#12 + ext v1.16b,v1.16b,v1.16b,#4 + ext v5.16b,v5.16b,v5.16b,#4 + ext v17.16b,v17.16b,v17.16b,#4 + add v0.4s,v0.4s,v1.4s + add w5,w5,w10 + add v4.4s,v4.4s,v5.4s + add w6,w6,w11 + add v16.4s,v16.4s,v17.4s + add w7,w7,w12 + eor v3.16b,v3.16b,v0.16b + add w8,w8,w9 + eor v7.16b,v7.16b,v4.16b + eor w21,w21,w5 + eor v19.16b,v19.16b,v16.16b + eor w17,w17,w6 + rev32 v3.8h,v3.8h + eor w19,w19,w7 + rev32 v7.8h,v7.8h + eor w20,w20,w8 + rev32 v19.8h,v19.8h + ror w21,w21,#16 + add v2.4s,v2.4s,v3.4s + ror w17,w17,#16 + add v6.4s,v6.4s,v7.4s + ror w19,w19,#16 + add v18.4s,v18.4s,v19.4s + ror w20,w20,#16 + eor v20.16b,v1.16b,v2.16b + add w15,w15,w21 + eor v21.16b,v5.16b,v6.16b + add w16,w16,w17 + eor v22.16b,v17.16b,v18.16b + add w13,w13,w19 + ushr v1.4s,v20.4s,#20 + add w14,w14,w20 + ushr v5.4s,v21.4s,#20 + eor w10,w10,w15 + ushr v17.4s,v22.4s,#20 + eor w11,w11,w16 + sli v1.4s,v20.4s,#12 + eor w12,w12,w13 + sli v5.4s,v21.4s,#12 + eor w9,w9,w14 + sli v17.4s,v22.4s,#12 + ror w10,w10,#20 + add v0.4s,v0.4s,v1.4s + ror w11,w11,#20 + add v4.4s,v4.4s,v5.4s + ror w12,w12,#20 + add v16.4s,v16.4s,v17.4s + ror w9,w9,#20 + eor v20.16b,v3.16b,v0.16b + add w5,w5,w10 + eor v21.16b,v7.16b,v4.16b + add w6,w6,w11 + eor v22.16b,v19.16b,v16.16b + add w7,w7,w12 + ushr v3.4s,v20.4s,#24 + add w8,w8,w9 + ushr v7.4s,v21.4s,#24 + eor w21,w21,w5 + ushr v19.4s,v22.4s,#24 + eor w17,w17,w6 + sli v3.4s,v20.4s,#8 + eor w19,w19,w7 + sli v7.4s,v21.4s,#8 + eor w20,w20,w8 + sli v19.4s,v22.4s,#8 + ror w21,w21,#24 + add v2.4s,v2.4s,v3.4s + ror w17,w17,#24 + add v6.4s,v6.4s,v7.4s + ror w19,w19,#24 + add v18.4s,v18.4s,v19.4s + ror w20,w20,#24 + eor v20.16b,v1.16b,v2.16b + add w15,w15,w21 + eor v21.16b,v5.16b,v6.16b + add w16,w16,w17 + eor v22.16b,v17.16b,v18.16b + add w13,w13,w19 + ushr v1.4s,v20.4s,#25 + add w14,w14,w20 + ushr v5.4s,v21.4s,#25 + eor w10,w10,w15 + ushr v17.4s,v22.4s,#25 + eor w11,w11,w16 + sli v1.4s,v20.4s,#7 + eor w12,w12,w13 + sli v5.4s,v21.4s,#7 + eor w9,w9,w14 + sli v17.4s,v22.4s,#7 + ror w10,w10,#25 + ext v2.16b,v2.16b,v2.16b,#8 + ror w11,w11,#25 + ext v6.16b,v6.16b,v6.16b,#8 + ror w12,w12,#25 + ext v18.16b,v18.16b,v18.16b,#8 + ror w9,w9,#25 + ext v3.16b,v3.16b,v3.16b,#4 + ext v7.16b,v7.16b,v7.16b,#4 + ext v19.16b,v19.16b,v19.16b,#4 + ext v1.16b,v1.16b,v1.16b,#12 + ext v5.16b,v5.16b,v5.16b,#12 + ext v17.16b,v17.16b,v17.16b,#12 + cbnz x4,Loop_neon + + add w5,w5,w22 // accumulate key block + add v0.4s,v0.4s,v24.4s + add x6,x6,x22,lsr#32 + add v4.4s,v4.4s,v24.4s + add w7,w7,w23 + add v16.4s,v16.4s,v24.4s + add x8,x8,x23,lsr#32 + add v2.4s,v2.4s,v26.4s + add w9,w9,w24 + add v6.4s,v6.4s,v26.4s + add x10,x10,x24,lsr#32 + add v18.4s,v18.4s,v26.4s + add w11,w11,w25 + add v3.4s,v3.4s,v27.4s + add x12,x12,x25,lsr#32 + add w13,w13,w26 + add v7.4s,v7.4s,v28.4s + add x14,x14,x26,lsr#32 + add w15,w15,w27 + add v19.4s,v19.4s,v29.4s + add x16,x16,x27,lsr#32 + add w17,w17,w28 + add v1.4s,v1.4s,v25.4s + add x19,x19,x28,lsr#32 + add w20,w20,w30 + add v5.4s,v5.4s,v25.4s + add x21,x21,x30,lsr#32 + add v17.4s,v17.4s,v25.4s + + b.lo Ltail_neon + + add x5,x5,x6,lsl#32 // pack + add x7,x7,x8,lsl#32 + ldp x6,x8,[x1,#0] // load input + add x9,x9,x10,lsl#32 + add x11,x11,x12,lsl#32 + ldp x10,x12,[x1,#16] + add x13,x13,x14,lsl#32 + add x15,x15,x16,lsl#32 + ldp x14,x16,[x1,#32] + add x17,x17,x19,lsl#32 + add x20,x20,x21,lsl#32 + ldp x19,x21,[x1,#48] + add x1,x1,#64 +#ifdef __AARCH64EB__ + rev x5,x5 + rev x7,x7 + rev x9,x9 + rev x11,x11 + rev x13,x13 + rev x15,x15 + rev x17,x17 + rev x20,x20 +#endif + ld1 {v20.16b,v21.16b,v22.16b,v23.16b},[x1],#64 + eor x5,x5,x6 + eor x7,x7,x8 + eor x9,x9,x10 + eor x11,x11,x12 + eor x13,x13,x14 + eor v0.16b,v0.16b,v20.16b + eor x15,x15,x16 + eor v1.16b,v1.16b,v21.16b + eor x17,x17,x19 + eor v2.16b,v2.16b,v22.16b + eor x20,x20,x21 + eor v3.16b,v3.16b,v23.16b + ld1 {v20.16b,v21.16b,v22.16b,v23.16b},[x1],#64 + + stp x5,x7,[x0,#0] // store output + add x28,x28,#4 // increment counter + stp x9,x11,[x0,#16] + add v27.4s,v27.4s,v31.4s // += 4 + stp x13,x15,[x0,#32] + add v28.4s,v28.4s,v31.4s + stp x17,x20,[x0,#48] + add v29.4s,v29.4s,v31.4s + add x0,x0,#64 + + st1 {v0.16b,v1.16b,v2.16b,v3.16b},[x0],#64 + ld1 {v0.16b,v1.16b,v2.16b,v3.16b},[x1],#64 + + eor v4.16b,v4.16b,v20.16b + eor v5.16b,v5.16b,v21.16b + eor v6.16b,v6.16b,v22.16b + eor v7.16b,v7.16b,v23.16b + st1 {v4.16b,v5.16b,v6.16b,v7.16b},[x0],#64 + + eor v16.16b,v16.16b,v0.16b + eor v17.16b,v17.16b,v1.16b + eor v18.16b,v18.16b,v2.16b + eor v19.16b,v19.16b,v3.16b + st1 {v16.16b,v17.16b,v18.16b,v19.16b},[x0],#64 + + b.hi Loop_outer_neon + + ldp x19,x20,[x29,#16] + add sp,sp,#64 + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldp x29,x30,[sp],#96 + AARCH64_VALIDATE_LINK_REGISTER + ret + +Ltail_neon: + add x2,x2,#256 + cmp x2,#64 + b.lo Less_than_64 + + add x5,x5,x6,lsl#32 // pack + add x7,x7,x8,lsl#32 + ldp x6,x8,[x1,#0] // load input + add x9,x9,x10,lsl#32 + add x11,x11,x12,lsl#32 + ldp x10,x12,[x1,#16] + add x13,x13,x14,lsl#32 + add x15,x15,x16,lsl#32 + ldp x14,x16,[x1,#32] + add x17,x17,x19,lsl#32 + add x20,x20,x21,lsl#32 + ldp x19,x21,[x1,#48] + add x1,x1,#64 +#ifdef __AARCH64EB__ + rev x5,x5 + rev x7,x7 + rev x9,x9 + rev x11,x11 + rev x13,x13 + rev x15,x15 + rev x17,x17 + rev x20,x20 +#endif + eor x5,x5,x6 + eor x7,x7,x8 + eor x9,x9,x10 + eor x11,x11,x12 + eor x13,x13,x14 + eor x15,x15,x16 + eor x17,x17,x19 + eor x20,x20,x21 + + stp x5,x7,[x0,#0] // store output + add x28,x28,#4 // increment counter + stp x9,x11,[x0,#16] + stp x13,x15,[x0,#32] + stp x17,x20,[x0,#48] + add x0,x0,#64 + b.eq Ldone_neon + sub x2,x2,#64 + cmp x2,#64 + b.lo Less_than_128 + + ld1 {v20.16b,v21.16b,v22.16b,v23.16b},[x1],#64 + eor v0.16b,v0.16b,v20.16b + eor v1.16b,v1.16b,v21.16b + eor v2.16b,v2.16b,v22.16b + eor v3.16b,v3.16b,v23.16b + st1 {v0.16b,v1.16b,v2.16b,v3.16b},[x0],#64 + b.eq Ldone_neon + sub x2,x2,#64 + cmp x2,#64 + b.lo Less_than_192 + + ld1 {v20.16b,v21.16b,v22.16b,v23.16b},[x1],#64 + eor v4.16b,v4.16b,v20.16b + eor v5.16b,v5.16b,v21.16b + eor v6.16b,v6.16b,v22.16b + eor v7.16b,v7.16b,v23.16b + st1 {v4.16b,v5.16b,v6.16b,v7.16b},[x0],#64 + b.eq Ldone_neon + sub x2,x2,#64 + + st1 {v16.16b,v17.16b,v18.16b,v19.16b},[sp] + b Last_neon + +Less_than_128: + st1 {v0.16b,v1.16b,v2.16b,v3.16b},[sp] + b Last_neon +Less_than_192: + st1 {v4.16b,v5.16b,v6.16b,v7.16b},[sp] + b Last_neon + +.align 4 +Last_neon: + sub x0,x0,#1 + add x1,x1,x2 + add x0,x0,x2 + add x4,sp,x2 + neg x2,x2 + +Loop_tail_neon: + ldrb w10,[x1,x2] + ldrb w11,[x4,x2] + add x2,x2,#1 + eor w10,w10,w11 + strb w10,[x0,x2] + cbnz x2,Loop_tail_neon + + stp xzr,xzr,[sp,#0] + stp xzr,xzr,[sp,#16] + stp xzr,xzr,[sp,#32] + stp xzr,xzr,[sp,#48] + +Ldone_neon: + ldp x19,x20,[x29,#16] + add sp,sp,#64 + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldp x29,x30,[sp],#96 + AARCH64_VALIDATE_LINK_REGISTER + ret + +.def ChaCha20_512_neon + .type 32 +.endef +.align 5 +ChaCha20_512_neon: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-96]! + add x29,sp,#0 + + adrp x5,Lsigma + add x5,x5,:lo12:Lsigma + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + stp x27,x28,[sp,#80] + +L512_or_more_neon: + sub sp,sp,#128+64 + + ldp x22,x23,[x5] // load sigma + ld1 {v24.4s},[x5],#16 + ldp x24,x25,[x3] // load key + ldp x26,x27,[x3,#16] + ld1 {v25.4s,v26.4s},[x3] + ldp x28,x30,[x4] // load counter + ld1 {v27.4s},[x4] + ld1 {v31.4s},[x5] +#ifdef __AARCH64EB__ + rev64 v24.4s,v24.4s + ror x24,x24,#32 + ror x25,x25,#32 + ror x26,x26,#32 + ror x27,x27,#32 + ror x28,x28,#32 + ror x30,x30,#32 +#endif + add v27.4s,v27.4s,v31.4s // += 1 + stp q24,q25,[sp,#0] // off-load key block, invariant part + add v27.4s,v27.4s,v31.4s // not typo + str q26,[sp,#32] + add v28.4s,v27.4s,v31.4s + add v29.4s,v28.4s,v31.4s + add v30.4s,v29.4s,v31.4s + shl v31.4s,v31.4s,#2 // 1 -> 4 + + stp d8,d9,[sp,#128+0] // meet ABI requirements + stp d10,d11,[sp,#128+16] + stp d12,d13,[sp,#128+32] + stp d14,d15,[sp,#128+48] + + sub x2,x2,#512 // not typo + +Loop_outer_512_neon: + mov v0.16b,v24.16b + mov v4.16b,v24.16b + mov v8.16b,v24.16b + mov v12.16b,v24.16b + mov v16.16b,v24.16b + mov v20.16b,v24.16b + mov v1.16b,v25.16b + mov w5,w22 // unpack key block + mov v5.16b,v25.16b + lsr x6,x22,#32 + mov v9.16b,v25.16b + mov w7,w23 + mov v13.16b,v25.16b + lsr x8,x23,#32 + mov v17.16b,v25.16b + mov w9,w24 + mov v21.16b,v25.16b + lsr x10,x24,#32 + mov v3.16b,v27.16b + mov w11,w25 + mov v7.16b,v28.16b + lsr x12,x25,#32 + mov v11.16b,v29.16b + mov w13,w26 + mov v15.16b,v30.16b + lsr x14,x26,#32 + mov v2.16b,v26.16b + mov w15,w27 + mov v6.16b,v26.16b + lsr x16,x27,#32 + add v19.4s,v3.4s,v31.4s // +4 + mov w17,w28 + add v23.4s,v7.4s,v31.4s // +4 + lsr x19,x28,#32 + mov v10.16b,v26.16b + mov w20,w30 + mov v14.16b,v26.16b + lsr x21,x30,#32 + mov v18.16b,v26.16b + stp q27,q28,[sp,#48] // off-load key block, variable part + mov v22.16b,v26.16b + str q29,[sp,#80] + + mov x4,#5 + subs x2,x2,#512 +Loop_upper_neon: + sub x4,x4,#1 + add v0.4s,v0.4s,v1.4s + add w5,w5,w9 + add v4.4s,v4.4s,v5.4s + add w6,w6,w10 + add v8.4s,v8.4s,v9.4s + add w7,w7,w11 + add v12.4s,v12.4s,v13.4s + add w8,w8,w12 + add v16.4s,v16.4s,v17.4s + eor w17,w17,w5 + add v20.4s,v20.4s,v21.4s + eor w19,w19,w6 + eor v3.16b,v3.16b,v0.16b + eor w20,w20,w7 + eor v7.16b,v7.16b,v4.16b + eor w21,w21,w8 + eor v11.16b,v11.16b,v8.16b + ror w17,w17,#16 + eor v15.16b,v15.16b,v12.16b + ror w19,w19,#16 + eor v19.16b,v19.16b,v16.16b + ror w20,w20,#16 + eor v23.16b,v23.16b,v20.16b + ror w21,w21,#16 + rev32 v3.8h,v3.8h + add w13,w13,w17 + rev32 v7.8h,v7.8h + add w14,w14,w19 + rev32 v11.8h,v11.8h + add w15,w15,w20 + rev32 v15.8h,v15.8h + add w16,w16,w21 + rev32 v19.8h,v19.8h + eor w9,w9,w13 + rev32 v23.8h,v23.8h + eor w10,w10,w14 + add v2.4s,v2.4s,v3.4s + eor w11,w11,w15 + add v6.4s,v6.4s,v7.4s + eor w12,w12,w16 + add v10.4s,v10.4s,v11.4s + ror w9,w9,#20 + add v14.4s,v14.4s,v15.4s + ror w10,w10,#20 + add v18.4s,v18.4s,v19.4s + ror w11,w11,#20 + add v22.4s,v22.4s,v23.4s + ror w12,w12,#20 + eor v24.16b,v1.16b,v2.16b + add w5,w5,w9 + eor v25.16b,v5.16b,v6.16b + add w6,w6,w10 + eor v26.16b,v9.16b,v10.16b + add w7,w7,w11 + eor v27.16b,v13.16b,v14.16b + add w8,w8,w12 + eor v28.16b,v17.16b,v18.16b + eor w17,w17,w5 + eor v29.16b,v21.16b,v22.16b + eor w19,w19,w6 + ushr v1.4s,v24.4s,#20 + eor w20,w20,w7 + ushr v5.4s,v25.4s,#20 + eor w21,w21,w8 + ushr v9.4s,v26.4s,#20 + ror w17,w17,#24 + ushr v13.4s,v27.4s,#20 + ror w19,w19,#24 + ushr v17.4s,v28.4s,#20 + ror w20,w20,#24 + ushr v21.4s,v29.4s,#20 + ror w21,w21,#24 + sli v1.4s,v24.4s,#12 + add w13,w13,w17 + sli v5.4s,v25.4s,#12 + add w14,w14,w19 + sli v9.4s,v26.4s,#12 + add w15,w15,w20 + sli v13.4s,v27.4s,#12 + add w16,w16,w21 + sli v17.4s,v28.4s,#12 + eor w9,w9,w13 + sli v21.4s,v29.4s,#12 + eor w10,w10,w14 + add v0.4s,v0.4s,v1.4s + eor w11,w11,w15 + add v4.4s,v4.4s,v5.4s + eor w12,w12,w16 + add v8.4s,v8.4s,v9.4s + ror w9,w9,#25 + add v12.4s,v12.4s,v13.4s + ror w10,w10,#25 + add v16.4s,v16.4s,v17.4s + ror w11,w11,#25 + add v20.4s,v20.4s,v21.4s + ror w12,w12,#25 + eor v24.16b,v3.16b,v0.16b + add w5,w5,w10 + eor v25.16b,v7.16b,v4.16b + add w6,w6,w11 + eor v26.16b,v11.16b,v8.16b + add w7,w7,w12 + eor v27.16b,v15.16b,v12.16b + add w8,w8,w9 + eor v28.16b,v19.16b,v16.16b + eor w21,w21,w5 + eor v29.16b,v23.16b,v20.16b + eor w17,w17,w6 + ushr v3.4s,v24.4s,#24 + eor w19,w19,w7 + ushr v7.4s,v25.4s,#24 + eor w20,w20,w8 + ushr v11.4s,v26.4s,#24 + ror w21,w21,#16 + ushr v15.4s,v27.4s,#24 + ror w17,w17,#16 + ushr v19.4s,v28.4s,#24 + ror w19,w19,#16 + ushr v23.4s,v29.4s,#24 + ror w20,w20,#16 + sli v3.4s,v24.4s,#8 + add w15,w15,w21 + sli v7.4s,v25.4s,#8 + add w16,w16,w17 + sli v11.4s,v26.4s,#8 + add w13,w13,w19 + sli v15.4s,v27.4s,#8 + add w14,w14,w20 + sli v19.4s,v28.4s,#8 + eor w10,w10,w15 + sli v23.4s,v29.4s,#8 + eor w11,w11,w16 + add v2.4s,v2.4s,v3.4s + eor w12,w12,w13 + add v6.4s,v6.4s,v7.4s + eor w9,w9,w14 + add v10.4s,v10.4s,v11.4s + ror w10,w10,#20 + add v14.4s,v14.4s,v15.4s + ror w11,w11,#20 + add v18.4s,v18.4s,v19.4s + ror w12,w12,#20 + add v22.4s,v22.4s,v23.4s + ror w9,w9,#20 + eor v24.16b,v1.16b,v2.16b + add w5,w5,w10 + eor v25.16b,v5.16b,v6.16b + add w6,w6,w11 + eor v26.16b,v9.16b,v10.16b + add w7,w7,w12 + eor v27.16b,v13.16b,v14.16b + add w8,w8,w9 + eor v28.16b,v17.16b,v18.16b + eor w21,w21,w5 + eor v29.16b,v21.16b,v22.16b + eor w17,w17,w6 + ushr v1.4s,v24.4s,#25 + eor w19,w19,w7 + ushr v5.4s,v25.4s,#25 + eor w20,w20,w8 + ushr v9.4s,v26.4s,#25 + ror w21,w21,#24 + ushr v13.4s,v27.4s,#25 + ror w17,w17,#24 + ushr v17.4s,v28.4s,#25 + ror w19,w19,#24 + ushr v21.4s,v29.4s,#25 + ror w20,w20,#24 + sli v1.4s,v24.4s,#7 + add w15,w15,w21 + sli v5.4s,v25.4s,#7 + add w16,w16,w17 + sli v9.4s,v26.4s,#7 + add w13,w13,w19 + sli v13.4s,v27.4s,#7 + add w14,w14,w20 + sli v17.4s,v28.4s,#7 + eor w10,w10,w15 + sli v21.4s,v29.4s,#7 + eor w11,w11,w16 + ext v2.16b,v2.16b,v2.16b,#8 + eor w12,w12,w13 + ext v6.16b,v6.16b,v6.16b,#8 + eor w9,w9,w14 + ext v10.16b,v10.16b,v10.16b,#8 + ror w10,w10,#25 + ext v14.16b,v14.16b,v14.16b,#8 + ror w11,w11,#25 + ext v18.16b,v18.16b,v18.16b,#8 + ror w12,w12,#25 + ext v22.16b,v22.16b,v22.16b,#8 + ror w9,w9,#25 + ext v3.16b,v3.16b,v3.16b,#12 + ext v7.16b,v7.16b,v7.16b,#12 + ext v11.16b,v11.16b,v11.16b,#12 + ext v15.16b,v15.16b,v15.16b,#12 + ext v19.16b,v19.16b,v19.16b,#12 + ext v23.16b,v23.16b,v23.16b,#12 + ext v1.16b,v1.16b,v1.16b,#4 + ext v5.16b,v5.16b,v5.16b,#4 + ext v9.16b,v9.16b,v9.16b,#4 + ext v13.16b,v13.16b,v13.16b,#4 + ext v17.16b,v17.16b,v17.16b,#4 + ext v21.16b,v21.16b,v21.16b,#4 + add v0.4s,v0.4s,v1.4s + add w5,w5,w9 + add v4.4s,v4.4s,v5.4s + add w6,w6,w10 + add v8.4s,v8.4s,v9.4s + add w7,w7,w11 + add v12.4s,v12.4s,v13.4s + add w8,w8,w12 + add v16.4s,v16.4s,v17.4s + eor w17,w17,w5 + add v20.4s,v20.4s,v21.4s + eor w19,w19,w6 + eor v3.16b,v3.16b,v0.16b + eor w20,w20,w7 + eor v7.16b,v7.16b,v4.16b + eor w21,w21,w8 + eor v11.16b,v11.16b,v8.16b + ror w17,w17,#16 + eor v15.16b,v15.16b,v12.16b + ror w19,w19,#16 + eor v19.16b,v19.16b,v16.16b + ror w20,w20,#16 + eor v23.16b,v23.16b,v20.16b + ror w21,w21,#16 + rev32 v3.8h,v3.8h + add w13,w13,w17 + rev32 v7.8h,v7.8h + add w14,w14,w19 + rev32 v11.8h,v11.8h + add w15,w15,w20 + rev32 v15.8h,v15.8h + add w16,w16,w21 + rev32 v19.8h,v19.8h + eor w9,w9,w13 + rev32 v23.8h,v23.8h + eor w10,w10,w14 + add v2.4s,v2.4s,v3.4s + eor w11,w11,w15 + add v6.4s,v6.4s,v7.4s + eor w12,w12,w16 + add v10.4s,v10.4s,v11.4s + ror w9,w9,#20 + add v14.4s,v14.4s,v15.4s + ror w10,w10,#20 + add v18.4s,v18.4s,v19.4s + ror w11,w11,#20 + add v22.4s,v22.4s,v23.4s + ror w12,w12,#20 + eor v24.16b,v1.16b,v2.16b + add w5,w5,w9 + eor v25.16b,v5.16b,v6.16b + add w6,w6,w10 + eor v26.16b,v9.16b,v10.16b + add w7,w7,w11 + eor v27.16b,v13.16b,v14.16b + add w8,w8,w12 + eor v28.16b,v17.16b,v18.16b + eor w17,w17,w5 + eor v29.16b,v21.16b,v22.16b + eor w19,w19,w6 + ushr v1.4s,v24.4s,#20 + eor w20,w20,w7 + ushr v5.4s,v25.4s,#20 + eor w21,w21,w8 + ushr v9.4s,v26.4s,#20 + ror w17,w17,#24 + ushr v13.4s,v27.4s,#20 + ror w19,w19,#24 + ushr v17.4s,v28.4s,#20 + ror w20,w20,#24 + ushr v21.4s,v29.4s,#20 + ror w21,w21,#24 + sli v1.4s,v24.4s,#12 + add w13,w13,w17 + sli v5.4s,v25.4s,#12 + add w14,w14,w19 + sli v9.4s,v26.4s,#12 + add w15,w15,w20 + sli v13.4s,v27.4s,#12 + add w16,w16,w21 + sli v17.4s,v28.4s,#12 + eor w9,w9,w13 + sli v21.4s,v29.4s,#12 + eor w10,w10,w14 + add v0.4s,v0.4s,v1.4s + eor w11,w11,w15 + add v4.4s,v4.4s,v5.4s + eor w12,w12,w16 + add v8.4s,v8.4s,v9.4s + ror w9,w9,#25 + add v12.4s,v12.4s,v13.4s + ror w10,w10,#25 + add v16.4s,v16.4s,v17.4s + ror w11,w11,#25 + add v20.4s,v20.4s,v21.4s + ror w12,w12,#25 + eor v24.16b,v3.16b,v0.16b + add w5,w5,w10 + eor v25.16b,v7.16b,v4.16b + add w6,w6,w11 + eor v26.16b,v11.16b,v8.16b + add w7,w7,w12 + eor v27.16b,v15.16b,v12.16b + add w8,w8,w9 + eor v28.16b,v19.16b,v16.16b + eor w21,w21,w5 + eor v29.16b,v23.16b,v20.16b + eor w17,w17,w6 + ushr v3.4s,v24.4s,#24 + eor w19,w19,w7 + ushr v7.4s,v25.4s,#24 + eor w20,w20,w8 + ushr v11.4s,v26.4s,#24 + ror w21,w21,#16 + ushr v15.4s,v27.4s,#24 + ror w17,w17,#16 + ushr v19.4s,v28.4s,#24 + ror w19,w19,#16 + ushr v23.4s,v29.4s,#24 + ror w20,w20,#16 + sli v3.4s,v24.4s,#8 + add w15,w15,w21 + sli v7.4s,v25.4s,#8 + add w16,w16,w17 + sli v11.4s,v26.4s,#8 + add w13,w13,w19 + sli v15.4s,v27.4s,#8 + add w14,w14,w20 + sli v19.4s,v28.4s,#8 + eor w10,w10,w15 + sli v23.4s,v29.4s,#8 + eor w11,w11,w16 + add v2.4s,v2.4s,v3.4s + eor w12,w12,w13 + add v6.4s,v6.4s,v7.4s + eor w9,w9,w14 + add v10.4s,v10.4s,v11.4s + ror w10,w10,#20 + add v14.4s,v14.4s,v15.4s + ror w11,w11,#20 + add v18.4s,v18.4s,v19.4s + ror w12,w12,#20 + add v22.4s,v22.4s,v23.4s + ror w9,w9,#20 + eor v24.16b,v1.16b,v2.16b + add w5,w5,w10 + eor v25.16b,v5.16b,v6.16b + add w6,w6,w11 + eor v26.16b,v9.16b,v10.16b + add w7,w7,w12 + eor v27.16b,v13.16b,v14.16b + add w8,w8,w9 + eor v28.16b,v17.16b,v18.16b + eor w21,w21,w5 + eor v29.16b,v21.16b,v22.16b + eor w17,w17,w6 + ushr v1.4s,v24.4s,#25 + eor w19,w19,w7 + ushr v5.4s,v25.4s,#25 + eor w20,w20,w8 + ushr v9.4s,v26.4s,#25 + ror w21,w21,#24 + ushr v13.4s,v27.4s,#25 + ror w17,w17,#24 + ushr v17.4s,v28.4s,#25 + ror w19,w19,#24 + ushr v21.4s,v29.4s,#25 + ror w20,w20,#24 + sli v1.4s,v24.4s,#7 + add w15,w15,w21 + sli v5.4s,v25.4s,#7 + add w16,w16,w17 + sli v9.4s,v26.4s,#7 + add w13,w13,w19 + sli v13.4s,v27.4s,#7 + add w14,w14,w20 + sli v17.4s,v28.4s,#7 + eor w10,w10,w15 + sli v21.4s,v29.4s,#7 + eor w11,w11,w16 + ext v2.16b,v2.16b,v2.16b,#8 + eor w12,w12,w13 + ext v6.16b,v6.16b,v6.16b,#8 + eor w9,w9,w14 + ext v10.16b,v10.16b,v10.16b,#8 + ror w10,w10,#25 + ext v14.16b,v14.16b,v14.16b,#8 + ror w11,w11,#25 + ext v18.16b,v18.16b,v18.16b,#8 + ror w12,w12,#25 + ext v22.16b,v22.16b,v22.16b,#8 + ror w9,w9,#25 + ext v3.16b,v3.16b,v3.16b,#4 + ext v7.16b,v7.16b,v7.16b,#4 + ext v11.16b,v11.16b,v11.16b,#4 + ext v15.16b,v15.16b,v15.16b,#4 + ext v19.16b,v19.16b,v19.16b,#4 + ext v23.16b,v23.16b,v23.16b,#4 + ext v1.16b,v1.16b,v1.16b,#12 + ext v5.16b,v5.16b,v5.16b,#12 + ext v9.16b,v9.16b,v9.16b,#12 + ext v13.16b,v13.16b,v13.16b,#12 + ext v17.16b,v17.16b,v17.16b,#12 + ext v21.16b,v21.16b,v21.16b,#12 + cbnz x4,Loop_upper_neon + + add w5,w5,w22 // accumulate key block + add x6,x6,x22,lsr#32 + add w7,w7,w23 + add x8,x8,x23,lsr#32 + add w9,w9,w24 + add x10,x10,x24,lsr#32 + add w11,w11,w25 + add x12,x12,x25,lsr#32 + add w13,w13,w26 + add x14,x14,x26,lsr#32 + add w15,w15,w27 + add x16,x16,x27,lsr#32 + add w17,w17,w28 + add x19,x19,x28,lsr#32 + add w20,w20,w30 + add x21,x21,x30,lsr#32 + + add x5,x5,x6,lsl#32 // pack + add x7,x7,x8,lsl#32 + ldp x6,x8,[x1,#0] // load input + add x9,x9,x10,lsl#32 + add x11,x11,x12,lsl#32 + ldp x10,x12,[x1,#16] + add x13,x13,x14,lsl#32 + add x15,x15,x16,lsl#32 + ldp x14,x16,[x1,#32] + add x17,x17,x19,lsl#32 + add x20,x20,x21,lsl#32 + ldp x19,x21,[x1,#48] + add x1,x1,#64 +#ifdef __AARCH64EB__ + rev x5,x5 + rev x7,x7 + rev x9,x9 + rev x11,x11 + rev x13,x13 + rev x15,x15 + rev x17,x17 + rev x20,x20 +#endif + eor x5,x5,x6 + eor x7,x7,x8 + eor x9,x9,x10 + eor x11,x11,x12 + eor x13,x13,x14 + eor x15,x15,x16 + eor x17,x17,x19 + eor x20,x20,x21 + + stp x5,x7,[x0,#0] // store output + add x28,x28,#1 // increment counter + mov w5,w22 // unpack key block + lsr x6,x22,#32 + stp x9,x11,[x0,#16] + mov w7,w23 + lsr x8,x23,#32 + stp x13,x15,[x0,#32] + mov w9,w24 + lsr x10,x24,#32 + stp x17,x20,[x0,#48] + add x0,x0,#64 + mov w11,w25 + lsr x12,x25,#32 + mov w13,w26 + lsr x14,x26,#32 + mov w15,w27 + lsr x16,x27,#32 + mov w17,w28 + lsr x19,x28,#32 + mov w20,w30 + lsr x21,x30,#32 + + mov x4,#5 +Loop_lower_neon: + sub x4,x4,#1 + add v0.4s,v0.4s,v1.4s + add w5,w5,w9 + add v4.4s,v4.4s,v5.4s + add w6,w6,w10 + add v8.4s,v8.4s,v9.4s + add w7,w7,w11 + add v12.4s,v12.4s,v13.4s + add w8,w8,w12 + add v16.4s,v16.4s,v17.4s + eor w17,w17,w5 + add v20.4s,v20.4s,v21.4s + eor w19,w19,w6 + eor v3.16b,v3.16b,v0.16b + eor w20,w20,w7 + eor v7.16b,v7.16b,v4.16b + eor w21,w21,w8 + eor v11.16b,v11.16b,v8.16b + ror w17,w17,#16 + eor v15.16b,v15.16b,v12.16b + ror w19,w19,#16 + eor v19.16b,v19.16b,v16.16b + ror w20,w20,#16 + eor v23.16b,v23.16b,v20.16b + ror w21,w21,#16 + rev32 v3.8h,v3.8h + add w13,w13,w17 + rev32 v7.8h,v7.8h + add w14,w14,w19 + rev32 v11.8h,v11.8h + add w15,w15,w20 + rev32 v15.8h,v15.8h + add w16,w16,w21 + rev32 v19.8h,v19.8h + eor w9,w9,w13 + rev32 v23.8h,v23.8h + eor w10,w10,w14 + add v2.4s,v2.4s,v3.4s + eor w11,w11,w15 + add v6.4s,v6.4s,v7.4s + eor w12,w12,w16 + add v10.4s,v10.4s,v11.4s + ror w9,w9,#20 + add v14.4s,v14.4s,v15.4s + ror w10,w10,#20 + add v18.4s,v18.4s,v19.4s + ror w11,w11,#20 + add v22.4s,v22.4s,v23.4s + ror w12,w12,#20 + eor v24.16b,v1.16b,v2.16b + add w5,w5,w9 + eor v25.16b,v5.16b,v6.16b + add w6,w6,w10 + eor v26.16b,v9.16b,v10.16b + add w7,w7,w11 + eor v27.16b,v13.16b,v14.16b + add w8,w8,w12 + eor v28.16b,v17.16b,v18.16b + eor w17,w17,w5 + eor v29.16b,v21.16b,v22.16b + eor w19,w19,w6 + ushr v1.4s,v24.4s,#20 + eor w20,w20,w7 + ushr v5.4s,v25.4s,#20 + eor w21,w21,w8 + ushr v9.4s,v26.4s,#20 + ror w17,w17,#24 + ushr v13.4s,v27.4s,#20 + ror w19,w19,#24 + ushr v17.4s,v28.4s,#20 + ror w20,w20,#24 + ushr v21.4s,v29.4s,#20 + ror w21,w21,#24 + sli v1.4s,v24.4s,#12 + add w13,w13,w17 + sli v5.4s,v25.4s,#12 + add w14,w14,w19 + sli v9.4s,v26.4s,#12 + add w15,w15,w20 + sli v13.4s,v27.4s,#12 + add w16,w16,w21 + sli v17.4s,v28.4s,#12 + eor w9,w9,w13 + sli v21.4s,v29.4s,#12 + eor w10,w10,w14 + add v0.4s,v0.4s,v1.4s + eor w11,w11,w15 + add v4.4s,v4.4s,v5.4s + eor w12,w12,w16 + add v8.4s,v8.4s,v9.4s + ror w9,w9,#25 + add v12.4s,v12.4s,v13.4s + ror w10,w10,#25 + add v16.4s,v16.4s,v17.4s + ror w11,w11,#25 + add v20.4s,v20.4s,v21.4s + ror w12,w12,#25 + eor v24.16b,v3.16b,v0.16b + add w5,w5,w10 + eor v25.16b,v7.16b,v4.16b + add w6,w6,w11 + eor v26.16b,v11.16b,v8.16b + add w7,w7,w12 + eor v27.16b,v15.16b,v12.16b + add w8,w8,w9 + eor v28.16b,v19.16b,v16.16b + eor w21,w21,w5 + eor v29.16b,v23.16b,v20.16b + eor w17,w17,w6 + ushr v3.4s,v24.4s,#24 + eor w19,w19,w7 + ushr v7.4s,v25.4s,#24 + eor w20,w20,w8 + ushr v11.4s,v26.4s,#24 + ror w21,w21,#16 + ushr v15.4s,v27.4s,#24 + ror w17,w17,#16 + ushr v19.4s,v28.4s,#24 + ror w19,w19,#16 + ushr v23.4s,v29.4s,#24 + ror w20,w20,#16 + sli v3.4s,v24.4s,#8 + add w15,w15,w21 + sli v7.4s,v25.4s,#8 + add w16,w16,w17 + sli v11.4s,v26.4s,#8 + add w13,w13,w19 + sli v15.4s,v27.4s,#8 + add w14,w14,w20 + sli v19.4s,v28.4s,#8 + eor w10,w10,w15 + sli v23.4s,v29.4s,#8 + eor w11,w11,w16 + add v2.4s,v2.4s,v3.4s + eor w12,w12,w13 + add v6.4s,v6.4s,v7.4s + eor w9,w9,w14 + add v10.4s,v10.4s,v11.4s + ror w10,w10,#20 + add v14.4s,v14.4s,v15.4s + ror w11,w11,#20 + add v18.4s,v18.4s,v19.4s + ror w12,w12,#20 + add v22.4s,v22.4s,v23.4s + ror w9,w9,#20 + eor v24.16b,v1.16b,v2.16b + add w5,w5,w10 + eor v25.16b,v5.16b,v6.16b + add w6,w6,w11 + eor v26.16b,v9.16b,v10.16b + add w7,w7,w12 + eor v27.16b,v13.16b,v14.16b + add w8,w8,w9 + eor v28.16b,v17.16b,v18.16b + eor w21,w21,w5 + eor v29.16b,v21.16b,v22.16b + eor w17,w17,w6 + ushr v1.4s,v24.4s,#25 + eor w19,w19,w7 + ushr v5.4s,v25.4s,#25 + eor w20,w20,w8 + ushr v9.4s,v26.4s,#25 + ror w21,w21,#24 + ushr v13.4s,v27.4s,#25 + ror w17,w17,#24 + ushr v17.4s,v28.4s,#25 + ror w19,w19,#24 + ushr v21.4s,v29.4s,#25 + ror w20,w20,#24 + sli v1.4s,v24.4s,#7 + add w15,w15,w21 + sli v5.4s,v25.4s,#7 + add w16,w16,w17 + sli v9.4s,v26.4s,#7 + add w13,w13,w19 + sli v13.4s,v27.4s,#7 + add w14,w14,w20 + sli v17.4s,v28.4s,#7 + eor w10,w10,w15 + sli v21.4s,v29.4s,#7 + eor w11,w11,w16 + ext v2.16b,v2.16b,v2.16b,#8 + eor w12,w12,w13 + ext v6.16b,v6.16b,v6.16b,#8 + eor w9,w9,w14 + ext v10.16b,v10.16b,v10.16b,#8 + ror w10,w10,#25 + ext v14.16b,v14.16b,v14.16b,#8 + ror w11,w11,#25 + ext v18.16b,v18.16b,v18.16b,#8 + ror w12,w12,#25 + ext v22.16b,v22.16b,v22.16b,#8 + ror w9,w9,#25 + ext v3.16b,v3.16b,v3.16b,#12 + ext v7.16b,v7.16b,v7.16b,#12 + ext v11.16b,v11.16b,v11.16b,#12 + ext v15.16b,v15.16b,v15.16b,#12 + ext v19.16b,v19.16b,v19.16b,#12 + ext v23.16b,v23.16b,v23.16b,#12 + ext v1.16b,v1.16b,v1.16b,#4 + ext v5.16b,v5.16b,v5.16b,#4 + ext v9.16b,v9.16b,v9.16b,#4 + ext v13.16b,v13.16b,v13.16b,#4 + ext v17.16b,v17.16b,v17.16b,#4 + ext v21.16b,v21.16b,v21.16b,#4 + add v0.4s,v0.4s,v1.4s + add w5,w5,w9 + add v4.4s,v4.4s,v5.4s + add w6,w6,w10 + add v8.4s,v8.4s,v9.4s + add w7,w7,w11 + add v12.4s,v12.4s,v13.4s + add w8,w8,w12 + add v16.4s,v16.4s,v17.4s + eor w17,w17,w5 + add v20.4s,v20.4s,v21.4s + eor w19,w19,w6 + eor v3.16b,v3.16b,v0.16b + eor w20,w20,w7 + eor v7.16b,v7.16b,v4.16b + eor w21,w21,w8 + eor v11.16b,v11.16b,v8.16b + ror w17,w17,#16 + eor v15.16b,v15.16b,v12.16b + ror w19,w19,#16 + eor v19.16b,v19.16b,v16.16b + ror w20,w20,#16 + eor v23.16b,v23.16b,v20.16b + ror w21,w21,#16 + rev32 v3.8h,v3.8h + add w13,w13,w17 + rev32 v7.8h,v7.8h + add w14,w14,w19 + rev32 v11.8h,v11.8h + add w15,w15,w20 + rev32 v15.8h,v15.8h + add w16,w16,w21 + rev32 v19.8h,v19.8h + eor w9,w9,w13 + rev32 v23.8h,v23.8h + eor w10,w10,w14 + add v2.4s,v2.4s,v3.4s + eor w11,w11,w15 + add v6.4s,v6.4s,v7.4s + eor w12,w12,w16 + add v10.4s,v10.4s,v11.4s + ror w9,w9,#20 + add v14.4s,v14.4s,v15.4s + ror w10,w10,#20 + add v18.4s,v18.4s,v19.4s + ror w11,w11,#20 + add v22.4s,v22.4s,v23.4s + ror w12,w12,#20 + eor v24.16b,v1.16b,v2.16b + add w5,w5,w9 + eor v25.16b,v5.16b,v6.16b + add w6,w6,w10 + eor v26.16b,v9.16b,v10.16b + add w7,w7,w11 + eor v27.16b,v13.16b,v14.16b + add w8,w8,w12 + eor v28.16b,v17.16b,v18.16b + eor w17,w17,w5 + eor v29.16b,v21.16b,v22.16b + eor w19,w19,w6 + ushr v1.4s,v24.4s,#20 + eor w20,w20,w7 + ushr v5.4s,v25.4s,#20 + eor w21,w21,w8 + ushr v9.4s,v26.4s,#20 + ror w17,w17,#24 + ushr v13.4s,v27.4s,#20 + ror w19,w19,#24 + ushr v17.4s,v28.4s,#20 + ror w20,w20,#24 + ushr v21.4s,v29.4s,#20 + ror w21,w21,#24 + sli v1.4s,v24.4s,#12 + add w13,w13,w17 + sli v5.4s,v25.4s,#12 + add w14,w14,w19 + sli v9.4s,v26.4s,#12 + add w15,w15,w20 + sli v13.4s,v27.4s,#12 + add w16,w16,w21 + sli v17.4s,v28.4s,#12 + eor w9,w9,w13 + sli v21.4s,v29.4s,#12 + eor w10,w10,w14 + add v0.4s,v0.4s,v1.4s + eor w11,w11,w15 + add v4.4s,v4.4s,v5.4s + eor w12,w12,w16 + add v8.4s,v8.4s,v9.4s + ror w9,w9,#25 + add v12.4s,v12.4s,v13.4s + ror w10,w10,#25 + add v16.4s,v16.4s,v17.4s + ror w11,w11,#25 + add v20.4s,v20.4s,v21.4s + ror w12,w12,#25 + eor v24.16b,v3.16b,v0.16b + add w5,w5,w10 + eor v25.16b,v7.16b,v4.16b + add w6,w6,w11 + eor v26.16b,v11.16b,v8.16b + add w7,w7,w12 + eor v27.16b,v15.16b,v12.16b + add w8,w8,w9 + eor v28.16b,v19.16b,v16.16b + eor w21,w21,w5 + eor v29.16b,v23.16b,v20.16b + eor w17,w17,w6 + ushr v3.4s,v24.4s,#24 + eor w19,w19,w7 + ushr v7.4s,v25.4s,#24 + eor w20,w20,w8 + ushr v11.4s,v26.4s,#24 + ror w21,w21,#16 + ushr v15.4s,v27.4s,#24 + ror w17,w17,#16 + ushr v19.4s,v28.4s,#24 + ror w19,w19,#16 + ushr v23.4s,v29.4s,#24 + ror w20,w20,#16 + sli v3.4s,v24.4s,#8 + add w15,w15,w21 + sli v7.4s,v25.4s,#8 + add w16,w16,w17 + sli v11.4s,v26.4s,#8 + add w13,w13,w19 + sli v15.4s,v27.4s,#8 + add w14,w14,w20 + sli v19.4s,v28.4s,#8 + eor w10,w10,w15 + sli v23.4s,v29.4s,#8 + eor w11,w11,w16 + add v2.4s,v2.4s,v3.4s + eor w12,w12,w13 + add v6.4s,v6.4s,v7.4s + eor w9,w9,w14 + add v10.4s,v10.4s,v11.4s + ror w10,w10,#20 + add v14.4s,v14.4s,v15.4s + ror w11,w11,#20 + add v18.4s,v18.4s,v19.4s + ror w12,w12,#20 + add v22.4s,v22.4s,v23.4s + ror w9,w9,#20 + eor v24.16b,v1.16b,v2.16b + add w5,w5,w10 + eor v25.16b,v5.16b,v6.16b + add w6,w6,w11 + eor v26.16b,v9.16b,v10.16b + add w7,w7,w12 + eor v27.16b,v13.16b,v14.16b + add w8,w8,w9 + eor v28.16b,v17.16b,v18.16b + eor w21,w21,w5 + eor v29.16b,v21.16b,v22.16b + eor w17,w17,w6 + ushr v1.4s,v24.4s,#25 + eor w19,w19,w7 + ushr v5.4s,v25.4s,#25 + eor w20,w20,w8 + ushr v9.4s,v26.4s,#25 + ror w21,w21,#24 + ushr v13.4s,v27.4s,#25 + ror w17,w17,#24 + ushr v17.4s,v28.4s,#25 + ror w19,w19,#24 + ushr v21.4s,v29.4s,#25 + ror w20,w20,#24 + sli v1.4s,v24.4s,#7 + add w15,w15,w21 + sli v5.4s,v25.4s,#7 + add w16,w16,w17 + sli v9.4s,v26.4s,#7 + add w13,w13,w19 + sli v13.4s,v27.4s,#7 + add w14,w14,w20 + sli v17.4s,v28.4s,#7 + eor w10,w10,w15 + sli v21.4s,v29.4s,#7 + eor w11,w11,w16 + ext v2.16b,v2.16b,v2.16b,#8 + eor w12,w12,w13 + ext v6.16b,v6.16b,v6.16b,#8 + eor w9,w9,w14 + ext v10.16b,v10.16b,v10.16b,#8 + ror w10,w10,#25 + ext v14.16b,v14.16b,v14.16b,#8 + ror w11,w11,#25 + ext v18.16b,v18.16b,v18.16b,#8 + ror w12,w12,#25 + ext v22.16b,v22.16b,v22.16b,#8 + ror w9,w9,#25 + ext v3.16b,v3.16b,v3.16b,#4 + ext v7.16b,v7.16b,v7.16b,#4 + ext v11.16b,v11.16b,v11.16b,#4 + ext v15.16b,v15.16b,v15.16b,#4 + ext v19.16b,v19.16b,v19.16b,#4 + ext v23.16b,v23.16b,v23.16b,#4 + ext v1.16b,v1.16b,v1.16b,#12 + ext v5.16b,v5.16b,v5.16b,#12 + ext v9.16b,v9.16b,v9.16b,#12 + ext v13.16b,v13.16b,v13.16b,#12 + ext v17.16b,v17.16b,v17.16b,#12 + ext v21.16b,v21.16b,v21.16b,#12 + cbnz x4,Loop_lower_neon + + add w5,w5,w22 // accumulate key block + ldp q24,q25,[sp,#0] + add x6,x6,x22,lsr#32 + ldp q26,q27,[sp,#32] + add w7,w7,w23 + ldp q28,q29,[sp,#64] + add x8,x8,x23,lsr#32 + add v0.4s,v0.4s,v24.4s + add w9,w9,w24 + add v4.4s,v4.4s,v24.4s + add x10,x10,x24,lsr#32 + add v8.4s,v8.4s,v24.4s + add w11,w11,w25 + add v12.4s,v12.4s,v24.4s + add x12,x12,x25,lsr#32 + add v16.4s,v16.4s,v24.4s + add w13,w13,w26 + add v20.4s,v20.4s,v24.4s + add x14,x14,x26,lsr#32 + add v2.4s,v2.4s,v26.4s + add w15,w15,w27 + add v6.4s,v6.4s,v26.4s + add x16,x16,x27,lsr#32 + add v10.4s,v10.4s,v26.4s + add w17,w17,w28 + add v14.4s,v14.4s,v26.4s + add x19,x19,x28,lsr#32 + add v18.4s,v18.4s,v26.4s + add w20,w20,w30 + add v22.4s,v22.4s,v26.4s + add x21,x21,x30,lsr#32 + add v19.4s,v19.4s,v31.4s // +4 + add x5,x5,x6,lsl#32 // pack + add v23.4s,v23.4s,v31.4s // +4 + add x7,x7,x8,lsl#32 + add v3.4s,v3.4s,v27.4s + ldp x6,x8,[x1,#0] // load input + add v7.4s,v7.4s,v28.4s + add x9,x9,x10,lsl#32 + add v11.4s,v11.4s,v29.4s + add x11,x11,x12,lsl#32 + add v15.4s,v15.4s,v30.4s + ldp x10,x12,[x1,#16] + add v19.4s,v19.4s,v27.4s + add x13,x13,x14,lsl#32 + add v23.4s,v23.4s,v28.4s + add x15,x15,x16,lsl#32 + add v1.4s,v1.4s,v25.4s + ldp x14,x16,[x1,#32] + add v5.4s,v5.4s,v25.4s + add x17,x17,x19,lsl#32 + add v9.4s,v9.4s,v25.4s + add x20,x20,x21,lsl#32 + add v13.4s,v13.4s,v25.4s + ldp x19,x21,[x1,#48] + add v17.4s,v17.4s,v25.4s + add x1,x1,#64 + add v21.4s,v21.4s,v25.4s + +#ifdef __AARCH64EB__ + rev x5,x5 + rev x7,x7 + rev x9,x9 + rev x11,x11 + rev x13,x13 + rev x15,x15 + rev x17,x17 + rev x20,x20 +#endif + ld1 {v24.16b,v25.16b,v26.16b,v27.16b},[x1],#64 + eor x5,x5,x6 + eor x7,x7,x8 + eor x9,x9,x10 + eor x11,x11,x12 + eor x13,x13,x14 + eor v0.16b,v0.16b,v24.16b + eor x15,x15,x16 + eor v1.16b,v1.16b,v25.16b + eor x17,x17,x19 + eor v2.16b,v2.16b,v26.16b + eor x20,x20,x21 + eor v3.16b,v3.16b,v27.16b + ld1 {v24.16b,v25.16b,v26.16b,v27.16b},[x1],#64 + + stp x5,x7,[x0,#0] // store output + add x28,x28,#7 // increment counter + stp x9,x11,[x0,#16] + stp x13,x15,[x0,#32] + stp x17,x20,[x0,#48] + add x0,x0,#64 + st1 {v0.16b,v1.16b,v2.16b,v3.16b},[x0],#64 + + ld1 {v0.16b,v1.16b,v2.16b,v3.16b},[x1],#64 + eor v4.16b,v4.16b,v24.16b + eor v5.16b,v5.16b,v25.16b + eor v6.16b,v6.16b,v26.16b + eor v7.16b,v7.16b,v27.16b + st1 {v4.16b,v5.16b,v6.16b,v7.16b},[x0],#64 + + ld1 {v4.16b,v5.16b,v6.16b,v7.16b},[x1],#64 + eor v8.16b,v8.16b,v0.16b + ldp q24,q25,[sp,#0] + eor v9.16b,v9.16b,v1.16b + ldp q26,q27,[sp,#32] + eor v10.16b,v10.16b,v2.16b + eor v11.16b,v11.16b,v3.16b + st1 {v8.16b,v9.16b,v10.16b,v11.16b},[x0],#64 + + ld1 {v8.16b,v9.16b,v10.16b,v11.16b},[x1],#64 + eor v12.16b,v12.16b,v4.16b + eor v13.16b,v13.16b,v5.16b + eor v14.16b,v14.16b,v6.16b + eor v15.16b,v15.16b,v7.16b + st1 {v12.16b,v13.16b,v14.16b,v15.16b},[x0],#64 + + ld1 {v12.16b,v13.16b,v14.16b,v15.16b},[x1],#64 + eor v16.16b,v16.16b,v8.16b + eor v17.16b,v17.16b,v9.16b + eor v18.16b,v18.16b,v10.16b + eor v19.16b,v19.16b,v11.16b + st1 {v16.16b,v17.16b,v18.16b,v19.16b},[x0],#64 + + shl v0.4s,v31.4s,#1 // 4 -> 8 + eor v20.16b,v20.16b,v12.16b + eor v21.16b,v21.16b,v13.16b + eor v22.16b,v22.16b,v14.16b + eor v23.16b,v23.16b,v15.16b + st1 {v20.16b,v21.16b,v22.16b,v23.16b},[x0],#64 + + add v27.4s,v27.4s,v0.4s // += 8 + add v28.4s,v28.4s,v0.4s + add v29.4s,v29.4s,v0.4s + add v30.4s,v30.4s,v0.4s + + b.hs Loop_outer_512_neon + + adds x2,x2,#512 + ushr v0.4s,v31.4s,#2 // 4 -> 1 + + ldp d8,d9,[sp,#128+0] // meet ABI requirements + ldp d10,d11,[sp,#128+16] + ldp d12,d13,[sp,#128+32] + ldp d14,d15,[sp,#128+48] + + stp q24,q31,[sp,#0] // wipe off-load area + stp q24,q31,[sp,#32] + stp q24,q31,[sp,#64] + + b.eq Ldone_512_neon + + cmp x2,#192 + sub v27.4s,v27.4s,v0.4s // -= 1 + sub v28.4s,v28.4s,v0.4s + sub v29.4s,v29.4s,v0.4s + add sp,sp,#128 + b.hs Loop_outer_neon + + eor v25.16b,v25.16b,v25.16b + eor v26.16b,v26.16b,v26.16b + eor v27.16b,v27.16b,v27.16b + eor v28.16b,v28.16b,v28.16b + eor v29.16b,v29.16b,v29.16b + eor v30.16b,v30.16b,v30.16b + b Loop_outer + +Ldone_512_neon: + ldp x19,x20,[x29,#16] + add sp,sp,#128+64 + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldp x29,x30,[sp],#96 + AARCH64_VALIDATE_LINK_REGISTER + ret + +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(_WIN32) diff --git a/http/vendor/ring/pregenerated/chacha-x86-elf.S b/http/vendor/ring/pregenerated/chacha-x86-elf.S new file mode 100644 index 0000000..b8b6b63 --- /dev/null +++ b/http/vendor/ring/pregenerated/chacha-x86-elf.S @@ -0,0 +1,601 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) +.text +.globl ChaCha20_ctr32_ssse3 +.hidden ChaCha20_ctr32_ssse3 +.type ChaCha20_ctr32_ssse3,@function +.align 16 +ChaCha20_ctr32_ssse3: +.L_ChaCha20_ctr32_ssse3_begin: + pushl %ebp + pushl %ebx + pushl %esi + pushl %edi + call .Lpic_point +.Lpic_point: + popl %eax + movl 20(%esp),%edi + movl 24(%esp),%esi + movl 28(%esp),%ecx + movl 32(%esp),%edx + movl 36(%esp),%ebx + movl %esp,%ebp + subl $524,%esp + andl $-64,%esp + movl %ebp,512(%esp) + leal .Lssse3_data-.Lpic_point(%eax),%eax + movdqu (%ebx),%xmm3 + cmpl $256,%ecx + jb .L0001x + movl %edx,516(%esp) + movl %ebx,520(%esp) + subl $256,%ecx + leal 384(%esp),%ebp + movdqu (%edx),%xmm7 + pshufd $0,%xmm3,%xmm0 + pshufd $85,%xmm3,%xmm1 + pshufd $170,%xmm3,%xmm2 + pshufd $255,%xmm3,%xmm3 + paddd 48(%eax),%xmm0 + pshufd $0,%xmm7,%xmm4 + pshufd $85,%xmm7,%xmm5 + psubd 64(%eax),%xmm0 + pshufd $170,%xmm7,%xmm6 + pshufd $255,%xmm7,%xmm7 + movdqa %xmm0,64(%ebp) + movdqa %xmm1,80(%ebp) + movdqa %xmm2,96(%ebp) + movdqa %xmm3,112(%ebp) + movdqu 16(%edx),%xmm3 + movdqa %xmm4,-64(%ebp) + movdqa %xmm5,-48(%ebp) + movdqa %xmm6,-32(%ebp) + movdqa %xmm7,-16(%ebp) + movdqa 32(%eax),%xmm7 + leal 128(%esp),%ebx + pshufd $0,%xmm3,%xmm0 + pshufd $85,%xmm3,%xmm1 + pshufd $170,%xmm3,%xmm2 + pshufd $255,%xmm3,%xmm3 + pshufd $0,%xmm7,%xmm4 + pshufd $85,%xmm7,%xmm5 + pshufd $170,%xmm7,%xmm6 + pshufd $255,%xmm7,%xmm7 + movdqa %xmm0,(%ebp) + movdqa %xmm1,16(%ebp) + movdqa %xmm2,32(%ebp) + movdqa %xmm3,48(%ebp) + movdqa %xmm4,-128(%ebp) + movdqa %xmm5,-112(%ebp) + movdqa %xmm6,-96(%ebp) + movdqa %xmm7,-80(%ebp) + leal 128(%esi),%esi + leal 128(%edi),%edi + jmp .L001outer_loop +.align 16 +.L001outer_loop: + movdqa -112(%ebp),%xmm1 + movdqa -96(%ebp),%xmm2 + movdqa -80(%ebp),%xmm3 + movdqa -48(%ebp),%xmm5 + movdqa -32(%ebp),%xmm6 + movdqa -16(%ebp),%xmm7 + movdqa %xmm1,-112(%ebx) + movdqa %xmm2,-96(%ebx) + movdqa %xmm3,-80(%ebx) + movdqa %xmm5,-48(%ebx) + movdqa %xmm6,-32(%ebx) + movdqa %xmm7,-16(%ebx) + movdqa 32(%ebp),%xmm2 + movdqa 48(%ebp),%xmm3 + movdqa 64(%ebp),%xmm4 + movdqa 80(%ebp),%xmm5 + movdqa 96(%ebp),%xmm6 + movdqa 112(%ebp),%xmm7 + paddd 64(%eax),%xmm4 + movdqa %xmm2,32(%ebx) + movdqa %xmm3,48(%ebx) + movdqa %xmm4,64(%ebx) + movdqa %xmm5,80(%ebx) + movdqa %xmm6,96(%ebx) + movdqa %xmm7,112(%ebx) + movdqa %xmm4,64(%ebp) + movdqa -128(%ebp),%xmm0 + movdqa %xmm4,%xmm6 + movdqa -64(%ebp),%xmm3 + movdqa (%ebp),%xmm4 + movdqa 16(%ebp),%xmm5 + movl $10,%edx + nop +.align 16 +.L002loop: + paddd %xmm3,%xmm0 + movdqa %xmm3,%xmm2 + pxor %xmm0,%xmm6 + pshufb (%eax),%xmm6 + paddd %xmm6,%xmm4 + pxor %xmm4,%xmm2 + movdqa -48(%ebx),%xmm3 + movdqa %xmm2,%xmm1 + pslld $12,%xmm2 + psrld $20,%xmm1 + por %xmm1,%xmm2 + movdqa -112(%ebx),%xmm1 + paddd %xmm2,%xmm0 + movdqa 80(%ebx),%xmm7 + pxor %xmm0,%xmm6 + movdqa %xmm0,-128(%ebx) + pshufb 16(%eax),%xmm6 + paddd %xmm6,%xmm4 + movdqa %xmm6,64(%ebx) + pxor %xmm4,%xmm2 + paddd %xmm3,%xmm1 + movdqa %xmm2,%xmm0 + pslld $7,%xmm2 + psrld $25,%xmm0 + pxor %xmm1,%xmm7 + por %xmm0,%xmm2 + movdqa %xmm4,(%ebx) + pshufb (%eax),%xmm7 + movdqa %xmm2,-64(%ebx) + paddd %xmm7,%xmm5 + movdqa 32(%ebx),%xmm4 + pxor %xmm5,%xmm3 + movdqa -32(%ebx),%xmm2 + movdqa %xmm3,%xmm0 + pslld $12,%xmm3 + psrld $20,%xmm0 + por %xmm0,%xmm3 + movdqa -96(%ebx),%xmm0 + paddd %xmm3,%xmm1 + movdqa 96(%ebx),%xmm6 + pxor %xmm1,%xmm7 + movdqa %xmm1,-112(%ebx) + pshufb 16(%eax),%xmm7 + paddd %xmm7,%xmm5 + movdqa %xmm7,80(%ebx) + pxor %xmm5,%xmm3 + paddd %xmm2,%xmm0 + movdqa %xmm3,%xmm1 + pslld $7,%xmm3 + psrld $25,%xmm1 + pxor %xmm0,%xmm6 + por %xmm1,%xmm3 + movdqa %xmm5,16(%ebx) + pshufb (%eax),%xmm6 + movdqa %xmm3,-48(%ebx) + paddd %xmm6,%xmm4 + movdqa 48(%ebx),%xmm5 + pxor %xmm4,%xmm2 + movdqa -16(%ebx),%xmm3 + movdqa %xmm2,%xmm1 + pslld $12,%xmm2 + psrld $20,%xmm1 + por %xmm1,%xmm2 + movdqa -80(%ebx),%xmm1 + paddd %xmm2,%xmm0 + movdqa 112(%ebx),%xmm7 + pxor %xmm0,%xmm6 + movdqa %xmm0,-96(%ebx) + pshufb 16(%eax),%xmm6 + paddd %xmm6,%xmm4 + movdqa %xmm6,96(%ebx) + pxor %xmm4,%xmm2 + paddd %xmm3,%xmm1 + movdqa %xmm2,%xmm0 + pslld $7,%xmm2 + psrld $25,%xmm0 + pxor %xmm1,%xmm7 + por %xmm0,%xmm2 + pshufb (%eax),%xmm7 + movdqa %xmm2,-32(%ebx) + paddd %xmm7,%xmm5 + pxor %xmm5,%xmm3 + movdqa -48(%ebx),%xmm2 + movdqa %xmm3,%xmm0 + pslld $12,%xmm3 + psrld $20,%xmm0 + por %xmm0,%xmm3 + movdqa -128(%ebx),%xmm0 + paddd %xmm3,%xmm1 + pxor %xmm1,%xmm7 + movdqa %xmm1,-80(%ebx) + pshufb 16(%eax),%xmm7 + paddd %xmm7,%xmm5 + movdqa %xmm7,%xmm6 + pxor %xmm5,%xmm3 + paddd %xmm2,%xmm0 + movdqa %xmm3,%xmm1 + pslld $7,%xmm3 + psrld $25,%xmm1 + pxor %xmm0,%xmm6 + por %xmm1,%xmm3 + pshufb (%eax),%xmm6 + movdqa %xmm3,-16(%ebx) + paddd %xmm6,%xmm4 + pxor %xmm4,%xmm2 + movdqa -32(%ebx),%xmm3 + movdqa %xmm2,%xmm1 + pslld $12,%xmm2 + psrld $20,%xmm1 + por %xmm1,%xmm2 + movdqa -112(%ebx),%xmm1 + paddd %xmm2,%xmm0 + movdqa 64(%ebx),%xmm7 + pxor %xmm0,%xmm6 + movdqa %xmm0,-128(%ebx) + pshufb 16(%eax),%xmm6 + paddd %xmm6,%xmm4 + movdqa %xmm6,112(%ebx) + pxor %xmm4,%xmm2 + paddd %xmm3,%xmm1 + movdqa %xmm2,%xmm0 + pslld $7,%xmm2 + psrld $25,%xmm0 + pxor %xmm1,%xmm7 + por %xmm0,%xmm2 + movdqa %xmm4,32(%ebx) + pshufb (%eax),%xmm7 + movdqa %xmm2,-48(%ebx) + paddd %xmm7,%xmm5 + movdqa (%ebx),%xmm4 + pxor %xmm5,%xmm3 + movdqa -16(%ebx),%xmm2 + movdqa %xmm3,%xmm0 + pslld $12,%xmm3 + psrld $20,%xmm0 + por %xmm0,%xmm3 + movdqa -96(%ebx),%xmm0 + paddd %xmm3,%xmm1 + movdqa 80(%ebx),%xmm6 + pxor %xmm1,%xmm7 + movdqa %xmm1,-112(%ebx) + pshufb 16(%eax),%xmm7 + paddd %xmm7,%xmm5 + movdqa %xmm7,64(%ebx) + pxor %xmm5,%xmm3 + paddd %xmm2,%xmm0 + movdqa %xmm3,%xmm1 + pslld $7,%xmm3 + psrld $25,%xmm1 + pxor %xmm0,%xmm6 + por %xmm1,%xmm3 + movdqa %xmm5,48(%ebx) + pshufb (%eax),%xmm6 + movdqa %xmm3,-32(%ebx) + paddd %xmm6,%xmm4 + movdqa 16(%ebx),%xmm5 + pxor %xmm4,%xmm2 + movdqa -64(%ebx),%xmm3 + movdqa %xmm2,%xmm1 + pslld $12,%xmm2 + psrld $20,%xmm1 + por %xmm1,%xmm2 + movdqa -80(%ebx),%xmm1 + paddd %xmm2,%xmm0 + movdqa 96(%ebx),%xmm7 + pxor %xmm0,%xmm6 + movdqa %xmm0,-96(%ebx) + pshufb 16(%eax),%xmm6 + paddd %xmm6,%xmm4 + movdqa %xmm6,80(%ebx) + pxor %xmm4,%xmm2 + paddd %xmm3,%xmm1 + movdqa %xmm2,%xmm0 + pslld $7,%xmm2 + psrld $25,%xmm0 + pxor %xmm1,%xmm7 + por %xmm0,%xmm2 + pshufb (%eax),%xmm7 + movdqa %xmm2,-16(%ebx) + paddd %xmm7,%xmm5 + pxor %xmm5,%xmm3 + movdqa %xmm3,%xmm0 + pslld $12,%xmm3 + psrld $20,%xmm0 + por %xmm0,%xmm3 + movdqa -128(%ebx),%xmm0 + paddd %xmm3,%xmm1 + movdqa 64(%ebx),%xmm6 + pxor %xmm1,%xmm7 + movdqa %xmm1,-80(%ebx) + pshufb 16(%eax),%xmm7 + paddd %xmm7,%xmm5 + movdqa %xmm7,96(%ebx) + pxor %xmm5,%xmm3 + movdqa %xmm3,%xmm1 + pslld $7,%xmm3 + psrld $25,%xmm1 + por %xmm1,%xmm3 + decl %edx + jnz .L002loop + movdqa %xmm3,-64(%ebx) + movdqa %xmm4,(%ebx) + movdqa %xmm5,16(%ebx) + movdqa %xmm6,64(%ebx) + movdqa %xmm7,96(%ebx) + movdqa -112(%ebx),%xmm1 + movdqa -96(%ebx),%xmm2 + movdqa -80(%ebx),%xmm3 + paddd -128(%ebp),%xmm0 + paddd -112(%ebp),%xmm1 + paddd -96(%ebp),%xmm2 + paddd -80(%ebp),%xmm3 + movdqa %xmm0,%xmm6 + punpckldq %xmm1,%xmm0 + movdqa %xmm2,%xmm7 + punpckldq %xmm3,%xmm2 + punpckhdq %xmm1,%xmm6 + punpckhdq %xmm3,%xmm7 + movdqa %xmm0,%xmm1 + punpcklqdq %xmm2,%xmm0 + movdqa %xmm6,%xmm3 + punpcklqdq %xmm7,%xmm6 + punpckhqdq %xmm2,%xmm1 + punpckhqdq %xmm7,%xmm3 + movdqu -128(%esi),%xmm4 + movdqu -64(%esi),%xmm5 + movdqu (%esi),%xmm2 + movdqu 64(%esi),%xmm7 + leal 16(%esi),%esi + pxor %xmm0,%xmm4 + movdqa -64(%ebx),%xmm0 + pxor %xmm1,%xmm5 + movdqa -48(%ebx),%xmm1 + pxor %xmm2,%xmm6 + movdqa -32(%ebx),%xmm2 + pxor %xmm3,%xmm7 + movdqa -16(%ebx),%xmm3 + movdqu %xmm4,-128(%edi) + movdqu %xmm5,-64(%edi) + movdqu %xmm6,(%edi) + movdqu %xmm7,64(%edi) + leal 16(%edi),%edi + paddd -64(%ebp),%xmm0 + paddd -48(%ebp),%xmm1 + paddd -32(%ebp),%xmm2 + paddd -16(%ebp),%xmm3 + movdqa %xmm0,%xmm6 + punpckldq %xmm1,%xmm0 + movdqa %xmm2,%xmm7 + punpckldq %xmm3,%xmm2 + punpckhdq %xmm1,%xmm6 + punpckhdq %xmm3,%xmm7 + movdqa %xmm0,%xmm1 + punpcklqdq %xmm2,%xmm0 + movdqa %xmm6,%xmm3 + punpcklqdq %xmm7,%xmm6 + punpckhqdq %xmm2,%xmm1 + punpckhqdq %xmm7,%xmm3 + movdqu -128(%esi),%xmm4 + movdqu -64(%esi),%xmm5 + movdqu (%esi),%xmm2 + movdqu 64(%esi),%xmm7 + leal 16(%esi),%esi + pxor %xmm0,%xmm4 + movdqa (%ebx),%xmm0 + pxor %xmm1,%xmm5 + movdqa 16(%ebx),%xmm1 + pxor %xmm2,%xmm6 + movdqa 32(%ebx),%xmm2 + pxor %xmm3,%xmm7 + movdqa 48(%ebx),%xmm3 + movdqu %xmm4,-128(%edi) + movdqu %xmm5,-64(%edi) + movdqu %xmm6,(%edi) + movdqu %xmm7,64(%edi) + leal 16(%edi),%edi + paddd (%ebp),%xmm0 + paddd 16(%ebp),%xmm1 + paddd 32(%ebp),%xmm2 + paddd 48(%ebp),%xmm3 + movdqa %xmm0,%xmm6 + punpckldq %xmm1,%xmm0 + movdqa %xmm2,%xmm7 + punpckldq %xmm3,%xmm2 + punpckhdq %xmm1,%xmm6 + punpckhdq %xmm3,%xmm7 + movdqa %xmm0,%xmm1 + punpcklqdq %xmm2,%xmm0 + movdqa %xmm6,%xmm3 + punpcklqdq %xmm7,%xmm6 + punpckhqdq %xmm2,%xmm1 + punpckhqdq %xmm7,%xmm3 + movdqu -128(%esi),%xmm4 + movdqu -64(%esi),%xmm5 + movdqu (%esi),%xmm2 + movdqu 64(%esi),%xmm7 + leal 16(%esi),%esi + pxor %xmm0,%xmm4 + movdqa 64(%ebx),%xmm0 + pxor %xmm1,%xmm5 + movdqa 80(%ebx),%xmm1 + pxor %xmm2,%xmm6 + movdqa 96(%ebx),%xmm2 + pxor %xmm3,%xmm7 + movdqa 112(%ebx),%xmm3 + movdqu %xmm4,-128(%edi) + movdqu %xmm5,-64(%edi) + movdqu %xmm6,(%edi) + movdqu %xmm7,64(%edi) + leal 16(%edi),%edi + paddd 64(%ebp),%xmm0 + paddd 80(%ebp),%xmm1 + paddd 96(%ebp),%xmm2 + paddd 112(%ebp),%xmm3 + movdqa %xmm0,%xmm6 + punpckldq %xmm1,%xmm0 + movdqa %xmm2,%xmm7 + punpckldq %xmm3,%xmm2 + punpckhdq %xmm1,%xmm6 + punpckhdq %xmm3,%xmm7 + movdqa %xmm0,%xmm1 + punpcklqdq %xmm2,%xmm0 + movdqa %xmm6,%xmm3 + punpcklqdq %xmm7,%xmm6 + punpckhqdq %xmm2,%xmm1 + punpckhqdq %xmm7,%xmm3 + movdqu -128(%esi),%xmm4 + movdqu -64(%esi),%xmm5 + movdqu (%esi),%xmm2 + movdqu 64(%esi),%xmm7 + leal 208(%esi),%esi + pxor %xmm0,%xmm4 + pxor %xmm1,%xmm5 + pxor %xmm2,%xmm6 + pxor %xmm3,%xmm7 + movdqu %xmm4,-128(%edi) + movdqu %xmm5,-64(%edi) + movdqu %xmm6,(%edi) + movdqu %xmm7,64(%edi) + leal 208(%edi),%edi + subl $256,%ecx + jnc .L001outer_loop + addl $256,%ecx + jz .L003done + movl 520(%esp),%ebx + leal -128(%esi),%esi + movl 516(%esp),%edx + leal -128(%edi),%edi + movd 64(%ebp),%xmm2 + movdqu (%ebx),%xmm3 + paddd 96(%eax),%xmm2 + pand 112(%eax),%xmm3 + por %xmm2,%xmm3 +.L0001x: + movdqa 32(%eax),%xmm0 + movdqu (%edx),%xmm1 + movdqu 16(%edx),%xmm2 + movdqa (%eax),%xmm6 + movdqa 16(%eax),%xmm7 + movl %ebp,48(%esp) + movdqa %xmm0,(%esp) + movdqa %xmm1,16(%esp) + movdqa %xmm2,32(%esp) + movdqa %xmm3,48(%esp) + movl $10,%edx + jmp .L004loop1x +.align 16 +.L005outer1x: + movdqa 80(%eax),%xmm3 + movdqa (%esp),%xmm0 + movdqa 16(%esp),%xmm1 + movdqa 32(%esp),%xmm2 + paddd 48(%esp),%xmm3 + movl $10,%edx + movdqa %xmm3,48(%esp) + jmp .L004loop1x +.align 16 +.L004loop1x: + paddd %xmm1,%xmm0 + pxor %xmm0,%xmm3 +.byte 102,15,56,0,222 + paddd %xmm3,%xmm2 + pxor %xmm2,%xmm1 + movdqa %xmm1,%xmm4 + psrld $20,%xmm1 + pslld $12,%xmm4 + por %xmm4,%xmm1 + paddd %xmm1,%xmm0 + pxor %xmm0,%xmm3 +.byte 102,15,56,0,223 + paddd %xmm3,%xmm2 + pxor %xmm2,%xmm1 + movdqa %xmm1,%xmm4 + psrld $25,%xmm1 + pslld $7,%xmm4 + por %xmm4,%xmm1 + pshufd $78,%xmm2,%xmm2 + pshufd $57,%xmm1,%xmm1 + pshufd $147,%xmm3,%xmm3 + nop + paddd %xmm1,%xmm0 + pxor %xmm0,%xmm3 +.byte 102,15,56,0,222 + paddd %xmm3,%xmm2 + pxor %xmm2,%xmm1 + movdqa %xmm1,%xmm4 + psrld $20,%xmm1 + pslld $12,%xmm4 + por %xmm4,%xmm1 + paddd %xmm1,%xmm0 + pxor %xmm0,%xmm3 +.byte 102,15,56,0,223 + paddd %xmm3,%xmm2 + pxor %xmm2,%xmm1 + movdqa %xmm1,%xmm4 + psrld $25,%xmm1 + pslld $7,%xmm4 + por %xmm4,%xmm1 + pshufd $78,%xmm2,%xmm2 + pshufd $147,%xmm1,%xmm1 + pshufd $57,%xmm3,%xmm3 + decl %edx + jnz .L004loop1x + paddd (%esp),%xmm0 + paddd 16(%esp),%xmm1 + paddd 32(%esp),%xmm2 + paddd 48(%esp),%xmm3 + cmpl $64,%ecx + jb .L006tail + movdqu (%esi),%xmm4 + movdqu 16(%esi),%xmm5 + pxor %xmm4,%xmm0 + movdqu 32(%esi),%xmm4 + pxor %xmm5,%xmm1 + movdqu 48(%esi),%xmm5 + pxor %xmm4,%xmm2 + pxor %xmm5,%xmm3 + leal 64(%esi),%esi + movdqu %xmm0,(%edi) + movdqu %xmm1,16(%edi) + movdqu %xmm2,32(%edi) + movdqu %xmm3,48(%edi) + leal 64(%edi),%edi + subl $64,%ecx + jnz .L005outer1x + jmp .L003done +.L006tail: + movdqa %xmm0,(%esp) + movdqa %xmm1,16(%esp) + movdqa %xmm2,32(%esp) + movdqa %xmm3,48(%esp) + xorl %eax,%eax + xorl %edx,%edx + xorl %ebp,%ebp +.L007tail_loop: + movb (%esp,%ebp,1),%al + movb (%esi,%ebp,1),%dl + leal 1(%ebp),%ebp + xorb %dl,%al + movb %al,-1(%edi,%ebp,1) + decl %ecx + jnz .L007tail_loop +.L003done: + movl 512(%esp),%esp + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.size ChaCha20_ctr32_ssse3,.-.L_ChaCha20_ctr32_ssse3_begin +.align 64 +.Lssse3_data: +.byte 2,3,0,1,6,7,4,5,10,11,8,9,14,15,12,13 +.byte 3,0,1,2,7,4,5,6,11,8,9,10,15,12,13,14 +.long 1634760805,857760878,2036477234,1797285236 +.long 0,1,2,3 +.long 4,4,4,4 +.long 1,0,0,0 +.long 4,0,0,0 +.long 0,-1,-1,-1 +.align 64 +.byte 67,104,97,67,104,97,50,48,32,102,111,114,32,120,56,54 +.byte 44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32 +.byte 60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111 +.byte 114,103,62,0 +#endif // !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) diff --git a/http/vendor/ring/pregenerated/chacha-x86-win32n.asm b/http/vendor/ring/pregenerated/chacha-x86-win32n.asm new file mode 100644 index 0000000..36e7b34 --- /dev/null +++ b/http/vendor/ring/pregenerated/chacha-x86-win32n.asm @@ -0,0 +1,607 @@ +; This file is generated from a similarly-named Perl script in the BoringSSL +; source tree. Do not edit by hand. + +%include "ring_core_generated/prefix_symbols_nasm.inc" +%ifidn __OUTPUT_FORMAT__, win32 +%ifidn __OUTPUT_FORMAT__,obj +section code use32 class=code align=64 +%elifidn __OUTPUT_FORMAT__,win32 +$@feat.00 equ 1 +section .text code align=64 +%else +section .text code +%endif +global _ChaCha20_ctr32_ssse3 +align 16 +_ChaCha20_ctr32_ssse3: +L$_ChaCha20_ctr32_ssse3_begin: + push ebp + push ebx + push esi + push edi + call L$pic_point +L$pic_point: + pop eax + mov edi,DWORD [20+esp] + mov esi,DWORD [24+esp] + mov ecx,DWORD [28+esp] + mov edx,DWORD [32+esp] + mov ebx,DWORD [36+esp] + mov ebp,esp + sub esp,524 + and esp,-64 + mov DWORD [512+esp],ebp + lea eax,[(L$ssse3_data-L$pic_point)+eax] + movdqu xmm3,[ebx] + cmp ecx,256 + jb NEAR L$0001x + mov DWORD [516+esp],edx + mov DWORD [520+esp],ebx + sub ecx,256 + lea ebp,[384+esp] + movdqu xmm7,[edx] + pshufd xmm0,xmm3,0 + pshufd xmm1,xmm3,85 + pshufd xmm2,xmm3,170 + pshufd xmm3,xmm3,255 + paddd xmm0,[48+eax] + pshufd xmm4,xmm7,0 + pshufd xmm5,xmm7,85 + psubd xmm0,[64+eax] + pshufd xmm6,xmm7,170 + pshufd xmm7,xmm7,255 + movdqa [64+ebp],xmm0 + movdqa [80+ebp],xmm1 + movdqa [96+ebp],xmm2 + movdqa [112+ebp],xmm3 + movdqu xmm3,[16+edx] + movdqa [ebp-64],xmm4 + movdqa [ebp-48],xmm5 + movdqa [ebp-32],xmm6 + movdqa [ebp-16],xmm7 + movdqa xmm7,[32+eax] + lea ebx,[128+esp] + pshufd xmm0,xmm3,0 + pshufd xmm1,xmm3,85 + pshufd xmm2,xmm3,170 + pshufd xmm3,xmm3,255 + pshufd xmm4,xmm7,0 + pshufd xmm5,xmm7,85 + pshufd xmm6,xmm7,170 + pshufd xmm7,xmm7,255 + movdqa [ebp],xmm0 + movdqa [16+ebp],xmm1 + movdqa [32+ebp],xmm2 + movdqa [48+ebp],xmm3 + movdqa [ebp-128],xmm4 + movdqa [ebp-112],xmm5 + movdqa [ebp-96],xmm6 + movdqa [ebp-80],xmm7 + lea esi,[128+esi] + lea edi,[128+edi] + jmp NEAR L$001outer_loop +align 16 +L$001outer_loop: + movdqa xmm1,[ebp-112] + movdqa xmm2,[ebp-96] + movdqa xmm3,[ebp-80] + movdqa xmm5,[ebp-48] + movdqa xmm6,[ebp-32] + movdqa xmm7,[ebp-16] + movdqa [ebx-112],xmm1 + movdqa [ebx-96],xmm2 + movdqa [ebx-80],xmm3 + movdqa [ebx-48],xmm5 + movdqa [ebx-32],xmm6 + movdqa [ebx-16],xmm7 + movdqa xmm2,[32+ebp] + movdqa xmm3,[48+ebp] + movdqa xmm4,[64+ebp] + movdqa xmm5,[80+ebp] + movdqa xmm6,[96+ebp] + movdqa xmm7,[112+ebp] + paddd xmm4,[64+eax] + movdqa [32+ebx],xmm2 + movdqa [48+ebx],xmm3 + movdqa [64+ebx],xmm4 + movdqa [80+ebx],xmm5 + movdqa [96+ebx],xmm6 + movdqa [112+ebx],xmm7 + movdqa [64+ebp],xmm4 + movdqa xmm0,[ebp-128] + movdqa xmm6,xmm4 + movdqa xmm3,[ebp-64] + movdqa xmm4,[ebp] + movdqa xmm5,[16+ebp] + mov edx,10 + nop +align 16 +L$002loop: + paddd xmm0,xmm3 + movdqa xmm2,xmm3 + pxor xmm6,xmm0 + pshufb xmm6,[eax] + paddd xmm4,xmm6 + pxor xmm2,xmm4 + movdqa xmm3,[ebx-48] + movdqa xmm1,xmm2 + pslld xmm2,12 + psrld xmm1,20 + por xmm2,xmm1 + movdqa xmm1,[ebx-112] + paddd xmm0,xmm2 + movdqa xmm7,[80+ebx] + pxor xmm6,xmm0 + movdqa [ebx-128],xmm0 + pshufb xmm6,[16+eax] + paddd xmm4,xmm6 + movdqa [64+ebx],xmm6 + pxor xmm2,xmm4 + paddd xmm1,xmm3 + movdqa xmm0,xmm2 + pslld xmm2,7 + psrld xmm0,25 + pxor xmm7,xmm1 + por xmm2,xmm0 + movdqa [ebx],xmm4 + pshufb xmm7,[eax] + movdqa [ebx-64],xmm2 + paddd xmm5,xmm7 + movdqa xmm4,[32+ebx] + pxor xmm3,xmm5 + movdqa xmm2,[ebx-32] + movdqa xmm0,xmm3 + pslld xmm3,12 + psrld xmm0,20 + por xmm3,xmm0 + movdqa xmm0,[ebx-96] + paddd xmm1,xmm3 + movdqa xmm6,[96+ebx] + pxor xmm7,xmm1 + movdqa [ebx-112],xmm1 + pshufb xmm7,[16+eax] + paddd xmm5,xmm7 + movdqa [80+ebx],xmm7 + pxor xmm3,xmm5 + paddd xmm0,xmm2 + movdqa xmm1,xmm3 + pslld xmm3,7 + psrld xmm1,25 + pxor xmm6,xmm0 + por xmm3,xmm1 + movdqa [16+ebx],xmm5 + pshufb xmm6,[eax] + movdqa [ebx-48],xmm3 + paddd xmm4,xmm6 + movdqa xmm5,[48+ebx] + pxor xmm2,xmm4 + movdqa xmm3,[ebx-16] + movdqa xmm1,xmm2 + pslld xmm2,12 + psrld xmm1,20 + por xmm2,xmm1 + movdqa xmm1,[ebx-80] + paddd xmm0,xmm2 + movdqa xmm7,[112+ebx] + pxor xmm6,xmm0 + movdqa [ebx-96],xmm0 + pshufb xmm6,[16+eax] + paddd xmm4,xmm6 + movdqa [96+ebx],xmm6 + pxor xmm2,xmm4 + paddd xmm1,xmm3 + movdqa xmm0,xmm2 + pslld xmm2,7 + psrld xmm0,25 + pxor xmm7,xmm1 + por xmm2,xmm0 + pshufb xmm7,[eax] + movdqa [ebx-32],xmm2 + paddd xmm5,xmm7 + pxor xmm3,xmm5 + movdqa xmm2,[ebx-48] + movdqa xmm0,xmm3 + pslld xmm3,12 + psrld xmm0,20 + por xmm3,xmm0 + movdqa xmm0,[ebx-128] + paddd xmm1,xmm3 + pxor xmm7,xmm1 + movdqa [ebx-80],xmm1 + pshufb xmm7,[16+eax] + paddd xmm5,xmm7 + movdqa xmm6,xmm7 + pxor xmm3,xmm5 + paddd xmm0,xmm2 + movdqa xmm1,xmm3 + pslld xmm3,7 + psrld xmm1,25 + pxor xmm6,xmm0 + por xmm3,xmm1 + pshufb xmm6,[eax] + movdqa [ebx-16],xmm3 + paddd xmm4,xmm6 + pxor xmm2,xmm4 + movdqa xmm3,[ebx-32] + movdqa xmm1,xmm2 + pslld xmm2,12 + psrld xmm1,20 + por xmm2,xmm1 + movdqa xmm1,[ebx-112] + paddd xmm0,xmm2 + movdqa xmm7,[64+ebx] + pxor xmm6,xmm0 + movdqa [ebx-128],xmm0 + pshufb xmm6,[16+eax] + paddd xmm4,xmm6 + movdqa [112+ebx],xmm6 + pxor xmm2,xmm4 + paddd xmm1,xmm3 + movdqa xmm0,xmm2 + pslld xmm2,7 + psrld xmm0,25 + pxor xmm7,xmm1 + por xmm2,xmm0 + movdqa [32+ebx],xmm4 + pshufb xmm7,[eax] + movdqa [ebx-48],xmm2 + paddd xmm5,xmm7 + movdqa xmm4,[ebx] + pxor xmm3,xmm5 + movdqa xmm2,[ebx-16] + movdqa xmm0,xmm3 + pslld xmm3,12 + psrld xmm0,20 + por xmm3,xmm0 + movdqa xmm0,[ebx-96] + paddd xmm1,xmm3 + movdqa xmm6,[80+ebx] + pxor xmm7,xmm1 + movdqa [ebx-112],xmm1 + pshufb xmm7,[16+eax] + paddd xmm5,xmm7 + movdqa [64+ebx],xmm7 + pxor xmm3,xmm5 + paddd xmm0,xmm2 + movdqa xmm1,xmm3 + pslld xmm3,7 + psrld xmm1,25 + pxor xmm6,xmm0 + por xmm3,xmm1 + movdqa [48+ebx],xmm5 + pshufb xmm6,[eax] + movdqa [ebx-32],xmm3 + paddd xmm4,xmm6 + movdqa xmm5,[16+ebx] + pxor xmm2,xmm4 + movdqa xmm3,[ebx-64] + movdqa xmm1,xmm2 + pslld xmm2,12 + psrld xmm1,20 + por xmm2,xmm1 + movdqa xmm1,[ebx-80] + paddd xmm0,xmm2 + movdqa xmm7,[96+ebx] + pxor xmm6,xmm0 + movdqa [ebx-96],xmm0 + pshufb xmm6,[16+eax] + paddd xmm4,xmm6 + movdqa [80+ebx],xmm6 + pxor xmm2,xmm4 + paddd xmm1,xmm3 + movdqa xmm0,xmm2 + pslld xmm2,7 + psrld xmm0,25 + pxor xmm7,xmm1 + por xmm2,xmm0 + pshufb xmm7,[eax] + movdqa [ebx-16],xmm2 + paddd xmm5,xmm7 + pxor xmm3,xmm5 + movdqa xmm0,xmm3 + pslld xmm3,12 + psrld xmm0,20 + por xmm3,xmm0 + movdqa xmm0,[ebx-128] + paddd xmm1,xmm3 + movdqa xmm6,[64+ebx] + pxor xmm7,xmm1 + movdqa [ebx-80],xmm1 + pshufb xmm7,[16+eax] + paddd xmm5,xmm7 + movdqa [96+ebx],xmm7 + pxor xmm3,xmm5 + movdqa xmm1,xmm3 + pslld xmm3,7 + psrld xmm1,25 + por xmm3,xmm1 + dec edx + jnz NEAR L$002loop + movdqa [ebx-64],xmm3 + movdqa [ebx],xmm4 + movdqa [16+ebx],xmm5 + movdqa [64+ebx],xmm6 + movdqa [96+ebx],xmm7 + movdqa xmm1,[ebx-112] + movdqa xmm2,[ebx-96] + movdqa xmm3,[ebx-80] + paddd xmm0,[ebp-128] + paddd xmm1,[ebp-112] + paddd xmm2,[ebp-96] + paddd xmm3,[ebp-80] + movdqa xmm6,xmm0 + punpckldq xmm0,xmm1 + movdqa xmm7,xmm2 + punpckldq xmm2,xmm3 + punpckhdq xmm6,xmm1 + punpckhdq xmm7,xmm3 + movdqa xmm1,xmm0 + punpcklqdq xmm0,xmm2 + movdqa xmm3,xmm6 + punpcklqdq xmm6,xmm7 + punpckhqdq xmm1,xmm2 + punpckhqdq xmm3,xmm7 + movdqu xmm4,[esi-128] + movdqu xmm5,[esi-64] + movdqu xmm2,[esi] + movdqu xmm7,[64+esi] + lea esi,[16+esi] + pxor xmm4,xmm0 + movdqa xmm0,[ebx-64] + pxor xmm5,xmm1 + movdqa xmm1,[ebx-48] + pxor xmm6,xmm2 + movdqa xmm2,[ebx-32] + pxor xmm7,xmm3 + movdqa xmm3,[ebx-16] + movdqu [edi-128],xmm4 + movdqu [edi-64],xmm5 + movdqu [edi],xmm6 + movdqu [64+edi],xmm7 + lea edi,[16+edi] + paddd xmm0,[ebp-64] + paddd xmm1,[ebp-48] + paddd xmm2,[ebp-32] + paddd xmm3,[ebp-16] + movdqa xmm6,xmm0 + punpckldq xmm0,xmm1 + movdqa xmm7,xmm2 + punpckldq xmm2,xmm3 + punpckhdq xmm6,xmm1 + punpckhdq xmm7,xmm3 + movdqa xmm1,xmm0 + punpcklqdq xmm0,xmm2 + movdqa xmm3,xmm6 + punpcklqdq xmm6,xmm7 + punpckhqdq xmm1,xmm2 + punpckhqdq xmm3,xmm7 + movdqu xmm4,[esi-128] + movdqu xmm5,[esi-64] + movdqu xmm2,[esi] + movdqu xmm7,[64+esi] + lea esi,[16+esi] + pxor xmm4,xmm0 + movdqa xmm0,[ebx] + pxor xmm5,xmm1 + movdqa xmm1,[16+ebx] + pxor xmm6,xmm2 + movdqa xmm2,[32+ebx] + pxor xmm7,xmm3 + movdqa xmm3,[48+ebx] + movdqu [edi-128],xmm4 + movdqu [edi-64],xmm5 + movdqu [edi],xmm6 + movdqu [64+edi],xmm7 + lea edi,[16+edi] + paddd xmm0,[ebp] + paddd xmm1,[16+ebp] + paddd xmm2,[32+ebp] + paddd xmm3,[48+ebp] + movdqa xmm6,xmm0 + punpckldq xmm0,xmm1 + movdqa xmm7,xmm2 + punpckldq xmm2,xmm3 + punpckhdq xmm6,xmm1 + punpckhdq xmm7,xmm3 + movdqa xmm1,xmm0 + punpcklqdq xmm0,xmm2 + movdqa xmm3,xmm6 + punpcklqdq xmm6,xmm7 + punpckhqdq xmm1,xmm2 + punpckhqdq xmm3,xmm7 + movdqu xmm4,[esi-128] + movdqu xmm5,[esi-64] + movdqu xmm2,[esi] + movdqu xmm7,[64+esi] + lea esi,[16+esi] + pxor xmm4,xmm0 + movdqa xmm0,[64+ebx] + pxor xmm5,xmm1 + movdqa xmm1,[80+ebx] + pxor xmm6,xmm2 + movdqa xmm2,[96+ebx] + pxor xmm7,xmm3 + movdqa xmm3,[112+ebx] + movdqu [edi-128],xmm4 + movdqu [edi-64],xmm5 + movdqu [edi],xmm6 + movdqu [64+edi],xmm7 + lea edi,[16+edi] + paddd xmm0,[64+ebp] + paddd xmm1,[80+ebp] + paddd xmm2,[96+ebp] + paddd xmm3,[112+ebp] + movdqa xmm6,xmm0 + punpckldq xmm0,xmm1 + movdqa xmm7,xmm2 + punpckldq xmm2,xmm3 + punpckhdq xmm6,xmm1 + punpckhdq xmm7,xmm3 + movdqa xmm1,xmm0 + punpcklqdq xmm0,xmm2 + movdqa xmm3,xmm6 + punpcklqdq xmm6,xmm7 + punpckhqdq xmm1,xmm2 + punpckhqdq xmm3,xmm7 + movdqu xmm4,[esi-128] + movdqu xmm5,[esi-64] + movdqu xmm2,[esi] + movdqu xmm7,[64+esi] + lea esi,[208+esi] + pxor xmm4,xmm0 + pxor xmm5,xmm1 + pxor xmm6,xmm2 + pxor xmm7,xmm3 + movdqu [edi-128],xmm4 + movdqu [edi-64],xmm5 + movdqu [edi],xmm6 + movdqu [64+edi],xmm7 + lea edi,[208+edi] + sub ecx,256 + jnc NEAR L$001outer_loop + add ecx,256 + jz NEAR L$003done + mov ebx,DWORD [520+esp] + lea esi,[esi-128] + mov edx,DWORD [516+esp] + lea edi,[edi-128] + movd xmm2,DWORD [64+ebp] + movdqu xmm3,[ebx] + paddd xmm2,[96+eax] + pand xmm3,[112+eax] + por xmm3,xmm2 +L$0001x: + movdqa xmm0,[32+eax] + movdqu xmm1,[edx] + movdqu xmm2,[16+edx] + movdqa xmm6,[eax] + movdqa xmm7,[16+eax] + mov DWORD [48+esp],ebp + movdqa [esp],xmm0 + movdqa [16+esp],xmm1 + movdqa [32+esp],xmm2 + movdqa [48+esp],xmm3 + mov edx,10 + jmp NEAR L$004loop1x +align 16 +L$005outer1x: + movdqa xmm3,[80+eax] + movdqa xmm0,[esp] + movdqa xmm1,[16+esp] + movdqa xmm2,[32+esp] + paddd xmm3,[48+esp] + mov edx,10 + movdqa [48+esp],xmm3 + jmp NEAR L$004loop1x +align 16 +L$004loop1x: + paddd xmm0,xmm1 + pxor xmm3,xmm0 +db 102,15,56,0,222 + paddd xmm2,xmm3 + pxor xmm1,xmm2 + movdqa xmm4,xmm1 + psrld xmm1,20 + pslld xmm4,12 + por xmm1,xmm4 + paddd xmm0,xmm1 + pxor xmm3,xmm0 +db 102,15,56,0,223 + paddd xmm2,xmm3 + pxor xmm1,xmm2 + movdqa xmm4,xmm1 + psrld xmm1,25 + pslld xmm4,7 + por xmm1,xmm4 + pshufd xmm2,xmm2,78 + pshufd xmm1,xmm1,57 + pshufd xmm3,xmm3,147 + nop + paddd xmm0,xmm1 + pxor xmm3,xmm0 +db 102,15,56,0,222 + paddd xmm2,xmm3 + pxor xmm1,xmm2 + movdqa xmm4,xmm1 + psrld xmm1,20 + pslld xmm4,12 + por xmm1,xmm4 + paddd xmm0,xmm1 + pxor xmm3,xmm0 +db 102,15,56,0,223 + paddd xmm2,xmm3 + pxor xmm1,xmm2 + movdqa xmm4,xmm1 + psrld xmm1,25 + pslld xmm4,7 + por xmm1,xmm4 + pshufd xmm2,xmm2,78 + pshufd xmm1,xmm1,147 + pshufd xmm3,xmm3,57 + dec edx + jnz NEAR L$004loop1x + paddd xmm0,[esp] + paddd xmm1,[16+esp] + paddd xmm2,[32+esp] + paddd xmm3,[48+esp] + cmp ecx,64 + jb NEAR L$006tail + movdqu xmm4,[esi] + movdqu xmm5,[16+esi] + pxor xmm0,xmm4 + movdqu xmm4,[32+esi] + pxor xmm1,xmm5 + movdqu xmm5,[48+esi] + pxor xmm2,xmm4 + pxor xmm3,xmm5 + lea esi,[64+esi] + movdqu [edi],xmm0 + movdqu [16+edi],xmm1 + movdqu [32+edi],xmm2 + movdqu [48+edi],xmm3 + lea edi,[64+edi] + sub ecx,64 + jnz NEAR L$005outer1x + jmp NEAR L$003done +L$006tail: + movdqa [esp],xmm0 + movdqa [16+esp],xmm1 + movdqa [32+esp],xmm2 + movdqa [48+esp],xmm3 + xor eax,eax + xor edx,edx + xor ebp,ebp +L$007tail_loop: + mov al,BYTE [ebp*1+esp] + mov dl,BYTE [ebp*1+esi] + lea ebp,[1+ebp] + xor al,dl + mov BYTE [ebp*1+edi-1],al + dec ecx + jnz NEAR L$007tail_loop +L$003done: + mov esp,DWORD [512+esp] + pop edi + pop esi + pop ebx + pop ebp + ret +align 64 +L$ssse3_data: +db 2,3,0,1,6,7,4,5,10,11,8,9,14,15,12,13 +db 3,0,1,2,7,4,5,6,11,8,9,10,15,12,13,14 +dd 1634760805,857760878,2036477234,1797285236 +dd 0,1,2,3 +dd 4,4,4,4 +dd 1,0,0,0 +dd 4,0,0,0 +dd 0,-1,-1,-1 +align 64 +db 67,104,97,67,104,97,50,48,32,102,111,114,32,120,56,54 +db 44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32 +db 60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111 +db 114,103,62,0 +%else +; Work around https://bugzilla.nasm.us/show_bug.cgi?id=3392738 +ret +%endif diff --git a/http/vendor/ring/pregenerated/chacha-x86-win32n.o b/http/vendor/ring/pregenerated/chacha-x86-win32n.o new file mode 100644 index 0000000..928f2e4 Binary files /dev/null and b/http/vendor/ring/pregenerated/chacha-x86-win32n.o differ diff --git a/http/vendor/ring/pregenerated/chacha-x86_64-elf.S b/http/vendor/ring/pregenerated/chacha-x86_64-elf.S new file mode 100644 index 0000000..a85ae2b --- /dev/null +++ b/http/vendor/ring/pregenerated/chacha-x86_64-elf.S @@ -0,0 +1,1474 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__) +.text + +.section .rodata +.align 64 +.Lzero: +.long 0,0,0,0 +.Lone: +.long 1,0,0,0 +.Linc: +.long 0,1,2,3 +.Lfour: +.long 4,4,4,4 +.Lincy: +.long 0,2,4,6,1,3,5,7 +.Leight: +.long 8,8,8,8,8,8,8,8 +.Lrot16: +.byte 0x2,0x3,0x0,0x1, 0x6,0x7,0x4,0x5, 0xa,0xb,0x8,0x9, 0xe,0xf,0xc,0xd +.Lrot24: +.byte 0x3,0x0,0x1,0x2, 0x7,0x4,0x5,0x6, 0xb,0x8,0x9,0xa, 0xf,0xc,0xd,0xe +.Lsigma: +.byte 101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107,0 +.align 64 +.Lzeroz: +.long 0,0,0,0, 1,0,0,0, 2,0,0,0, 3,0,0,0 +.Lfourz: +.long 4,0,0,0, 4,0,0,0, 4,0,0,0, 4,0,0,0 +.Lincz: +.long 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 +.Lsixteen: +.long 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16 +.byte 67,104,97,67,104,97,50,48,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.text +.globl ChaCha20_ctr32_nohw +.hidden ChaCha20_ctr32_nohw +.type ChaCha20_ctr32_nohw,@function +.align 64 +ChaCha20_ctr32_nohw: +.cfi_startproc +_CET_ENDBR + pushq %rbx +.cfi_adjust_cfa_offset 8 +.cfi_offset rbx,-16 + pushq %rbp +.cfi_adjust_cfa_offset 8 +.cfi_offset rbp,-24 + pushq %r12 +.cfi_adjust_cfa_offset 8 +.cfi_offset r12,-32 + pushq %r13 +.cfi_adjust_cfa_offset 8 +.cfi_offset r13,-40 + pushq %r14 +.cfi_adjust_cfa_offset 8 +.cfi_offset r14,-48 + pushq %r15 +.cfi_adjust_cfa_offset 8 +.cfi_offset r15,-56 + subq $64+24,%rsp +.cfi_adjust_cfa_offset 88 +.Lctr32_body: + + + movdqu (%rcx),%xmm1 + movdqu 16(%rcx),%xmm2 + movdqu (%r8),%xmm3 + movdqa .Lone(%rip),%xmm4 + + + movdqa %xmm1,16(%rsp) + movdqa %xmm2,32(%rsp) + movdqa %xmm3,48(%rsp) + movq %rdx,%rbp + jmp .Loop_outer + +.align 32 +.Loop_outer: + movl $0x61707865,%eax + movl $0x3320646e,%ebx + movl $0x79622d32,%ecx + movl $0x6b206574,%edx + movl 16(%rsp),%r8d + movl 20(%rsp),%r9d + movl 24(%rsp),%r10d + movl 28(%rsp),%r11d + movd %xmm3,%r12d + movl 52(%rsp),%r13d + movl 56(%rsp),%r14d + movl 60(%rsp),%r15d + + movq %rbp,64+0(%rsp) + movl $10,%ebp + movq %rsi,64+8(%rsp) +.byte 102,72,15,126,214 + movq %rdi,64+16(%rsp) + movq %rsi,%rdi + shrq $32,%rdi + jmp .Loop + +.align 32 +.Loop: + addl %r8d,%eax + xorl %eax,%r12d + roll $16,%r12d + addl %r9d,%ebx + xorl %ebx,%r13d + roll $16,%r13d + addl %r12d,%esi + xorl %esi,%r8d + roll $12,%r8d + addl %r13d,%edi + xorl %edi,%r9d + roll $12,%r9d + addl %r8d,%eax + xorl %eax,%r12d + roll $8,%r12d + addl %r9d,%ebx + xorl %ebx,%r13d + roll $8,%r13d + addl %r12d,%esi + xorl %esi,%r8d + roll $7,%r8d + addl %r13d,%edi + xorl %edi,%r9d + roll $7,%r9d + movl %esi,32(%rsp) + movl %edi,36(%rsp) + movl 40(%rsp),%esi + movl 44(%rsp),%edi + addl %r10d,%ecx + xorl %ecx,%r14d + roll $16,%r14d + addl %r11d,%edx + xorl %edx,%r15d + roll $16,%r15d + addl %r14d,%esi + xorl %esi,%r10d + roll $12,%r10d + addl %r15d,%edi + xorl %edi,%r11d + roll $12,%r11d + addl %r10d,%ecx + xorl %ecx,%r14d + roll $8,%r14d + addl %r11d,%edx + xorl %edx,%r15d + roll $8,%r15d + addl %r14d,%esi + xorl %esi,%r10d + roll $7,%r10d + addl %r15d,%edi + xorl %edi,%r11d + roll $7,%r11d + addl %r9d,%eax + xorl %eax,%r15d + roll $16,%r15d + addl %r10d,%ebx + xorl %ebx,%r12d + roll $16,%r12d + addl %r15d,%esi + xorl %esi,%r9d + roll $12,%r9d + addl %r12d,%edi + xorl %edi,%r10d + roll $12,%r10d + addl %r9d,%eax + xorl %eax,%r15d + roll $8,%r15d + addl %r10d,%ebx + xorl %ebx,%r12d + roll $8,%r12d + addl %r15d,%esi + xorl %esi,%r9d + roll $7,%r9d + addl %r12d,%edi + xorl %edi,%r10d + roll $7,%r10d + movl %esi,40(%rsp) + movl %edi,44(%rsp) + movl 32(%rsp),%esi + movl 36(%rsp),%edi + addl %r11d,%ecx + xorl %ecx,%r13d + roll $16,%r13d + addl %r8d,%edx + xorl %edx,%r14d + roll $16,%r14d + addl %r13d,%esi + xorl %esi,%r11d + roll $12,%r11d + addl %r14d,%edi + xorl %edi,%r8d + roll $12,%r8d + addl %r11d,%ecx + xorl %ecx,%r13d + roll $8,%r13d + addl %r8d,%edx + xorl %edx,%r14d + roll $8,%r14d + addl %r13d,%esi + xorl %esi,%r11d + roll $7,%r11d + addl %r14d,%edi + xorl %edi,%r8d + roll $7,%r8d + decl %ebp + jnz .Loop + movl %edi,36(%rsp) + movl %esi,32(%rsp) + movq 64(%rsp),%rbp + movdqa %xmm2,%xmm1 + movq 64+8(%rsp),%rsi + paddd %xmm4,%xmm3 + movq 64+16(%rsp),%rdi + + addl $0x61707865,%eax + addl $0x3320646e,%ebx + addl $0x79622d32,%ecx + addl $0x6b206574,%edx + addl 16(%rsp),%r8d + addl 20(%rsp),%r9d + addl 24(%rsp),%r10d + addl 28(%rsp),%r11d + addl 48(%rsp),%r12d + addl 52(%rsp),%r13d + addl 56(%rsp),%r14d + addl 60(%rsp),%r15d + paddd 32(%rsp),%xmm1 + + cmpq $64,%rbp + jb .Ltail + + xorl 0(%rsi),%eax + xorl 4(%rsi),%ebx + xorl 8(%rsi),%ecx + xorl 12(%rsi),%edx + xorl 16(%rsi),%r8d + xorl 20(%rsi),%r9d + xorl 24(%rsi),%r10d + xorl 28(%rsi),%r11d + movdqu 32(%rsi),%xmm0 + xorl 48(%rsi),%r12d + xorl 52(%rsi),%r13d + xorl 56(%rsi),%r14d + xorl 60(%rsi),%r15d + leaq 64(%rsi),%rsi + pxor %xmm1,%xmm0 + + movdqa %xmm2,32(%rsp) + movd %xmm3,48(%rsp) + + movl %eax,0(%rdi) + movl %ebx,4(%rdi) + movl %ecx,8(%rdi) + movl %edx,12(%rdi) + movl %r8d,16(%rdi) + movl %r9d,20(%rdi) + movl %r10d,24(%rdi) + movl %r11d,28(%rdi) + movdqu %xmm0,32(%rdi) + movl %r12d,48(%rdi) + movl %r13d,52(%rdi) + movl %r14d,56(%rdi) + movl %r15d,60(%rdi) + leaq 64(%rdi),%rdi + + subq $64,%rbp + jnz .Loop_outer + + jmp .Ldone + +.align 16 +.Ltail: + movl %eax,0(%rsp) + movl %ebx,4(%rsp) + xorq %rbx,%rbx + movl %ecx,8(%rsp) + movl %edx,12(%rsp) + movl %r8d,16(%rsp) + movl %r9d,20(%rsp) + movl %r10d,24(%rsp) + movl %r11d,28(%rsp) + movdqa %xmm1,32(%rsp) + movl %r12d,48(%rsp) + movl %r13d,52(%rsp) + movl %r14d,56(%rsp) + movl %r15d,60(%rsp) + +.Loop_tail: + movzbl (%rsi,%rbx,1),%eax + movzbl (%rsp,%rbx,1),%edx + leaq 1(%rbx),%rbx + xorl %edx,%eax + movb %al,-1(%rdi,%rbx,1) + decq %rbp + jnz .Loop_tail + +.Ldone: + leaq 64+24+48(%rsp),%rsi + movq -48(%rsi),%r15 +.cfi_restore r15 + movq -40(%rsi),%r14 +.cfi_restore r14 + movq -32(%rsi),%r13 +.cfi_restore r13 + movq -24(%rsi),%r12 +.cfi_restore r12 + movq -16(%rsi),%rbp +.cfi_restore rbp + movq -8(%rsi),%rbx +.cfi_restore rbx + leaq (%rsi),%rsp +.cfi_adjust_cfa_offset -136 +.Lno_data: + ret +.cfi_endproc +.size ChaCha20_ctr32_nohw,.-ChaCha20_ctr32_nohw +.globl ChaCha20_ctr32_ssse3_4x +.hidden ChaCha20_ctr32_ssse3_4x +.type ChaCha20_ctr32_ssse3_4x,@function +.align 32 +ChaCha20_ctr32_ssse3_4x: +.cfi_startproc +_CET_ENDBR + movq %rsp,%r9 +.cfi_def_cfa_register r9 + subq $0x140+8,%rsp + movdqa .Lsigma(%rip),%xmm11 + movdqu (%rcx),%xmm15 + movdqu 16(%rcx),%xmm7 + movdqu (%r8),%xmm3 + leaq 256(%rsp),%rcx + leaq .Lrot16(%rip),%r10 + leaq .Lrot24(%rip),%r11 + + pshufd $0x00,%xmm11,%xmm8 + pshufd $0x55,%xmm11,%xmm9 + movdqa %xmm8,64(%rsp) + pshufd $0xaa,%xmm11,%xmm10 + movdqa %xmm9,80(%rsp) + pshufd $0xff,%xmm11,%xmm11 + movdqa %xmm10,96(%rsp) + movdqa %xmm11,112(%rsp) + + pshufd $0x00,%xmm15,%xmm12 + pshufd $0x55,%xmm15,%xmm13 + movdqa %xmm12,128-256(%rcx) + pshufd $0xaa,%xmm15,%xmm14 + movdqa %xmm13,144-256(%rcx) + pshufd $0xff,%xmm15,%xmm15 + movdqa %xmm14,160-256(%rcx) + movdqa %xmm15,176-256(%rcx) + + pshufd $0x00,%xmm7,%xmm4 + pshufd $0x55,%xmm7,%xmm5 + movdqa %xmm4,192-256(%rcx) + pshufd $0xaa,%xmm7,%xmm6 + movdqa %xmm5,208-256(%rcx) + pshufd $0xff,%xmm7,%xmm7 + movdqa %xmm6,224-256(%rcx) + movdqa %xmm7,240-256(%rcx) + + pshufd $0x00,%xmm3,%xmm0 + pshufd $0x55,%xmm3,%xmm1 + paddd .Linc(%rip),%xmm0 + pshufd $0xaa,%xmm3,%xmm2 + movdqa %xmm1,272-256(%rcx) + pshufd $0xff,%xmm3,%xmm3 + movdqa %xmm2,288-256(%rcx) + movdqa %xmm3,304-256(%rcx) + + jmp .Loop_enter4x + +.align 32 +.Loop_outer4x: + movdqa 64(%rsp),%xmm8 + movdqa 80(%rsp),%xmm9 + movdqa 96(%rsp),%xmm10 + movdqa 112(%rsp),%xmm11 + movdqa 128-256(%rcx),%xmm12 + movdqa 144-256(%rcx),%xmm13 + movdqa 160-256(%rcx),%xmm14 + movdqa 176-256(%rcx),%xmm15 + movdqa 192-256(%rcx),%xmm4 + movdqa 208-256(%rcx),%xmm5 + movdqa 224-256(%rcx),%xmm6 + movdqa 240-256(%rcx),%xmm7 + movdqa 256-256(%rcx),%xmm0 + movdqa 272-256(%rcx),%xmm1 + movdqa 288-256(%rcx),%xmm2 + movdqa 304-256(%rcx),%xmm3 + paddd .Lfour(%rip),%xmm0 + +.Loop_enter4x: + movdqa %xmm6,32(%rsp) + movdqa %xmm7,48(%rsp) + movdqa (%r10),%xmm7 + movl $10,%eax + movdqa %xmm0,256-256(%rcx) + jmp .Loop4x + +.align 32 +.Loop4x: + paddd %xmm12,%xmm8 + paddd %xmm13,%xmm9 + pxor %xmm8,%xmm0 + pxor %xmm9,%xmm1 +.byte 102,15,56,0,199 +.byte 102,15,56,0,207 + paddd %xmm0,%xmm4 + paddd %xmm1,%xmm5 + pxor %xmm4,%xmm12 + pxor %xmm5,%xmm13 + movdqa %xmm12,%xmm6 + pslld $12,%xmm12 + psrld $20,%xmm6 + movdqa %xmm13,%xmm7 + pslld $12,%xmm13 + por %xmm6,%xmm12 + psrld $20,%xmm7 + movdqa (%r11),%xmm6 + por %xmm7,%xmm13 + paddd %xmm12,%xmm8 + paddd %xmm13,%xmm9 + pxor %xmm8,%xmm0 + pxor %xmm9,%xmm1 +.byte 102,15,56,0,198 +.byte 102,15,56,0,206 + paddd %xmm0,%xmm4 + paddd %xmm1,%xmm5 + pxor %xmm4,%xmm12 + pxor %xmm5,%xmm13 + movdqa %xmm12,%xmm7 + pslld $7,%xmm12 + psrld $25,%xmm7 + movdqa %xmm13,%xmm6 + pslld $7,%xmm13 + por %xmm7,%xmm12 + psrld $25,%xmm6 + movdqa (%r10),%xmm7 + por %xmm6,%xmm13 + movdqa %xmm4,0(%rsp) + movdqa %xmm5,16(%rsp) + movdqa 32(%rsp),%xmm4 + movdqa 48(%rsp),%xmm5 + paddd %xmm14,%xmm10 + paddd %xmm15,%xmm11 + pxor %xmm10,%xmm2 + pxor %xmm11,%xmm3 +.byte 102,15,56,0,215 +.byte 102,15,56,0,223 + paddd %xmm2,%xmm4 + paddd %xmm3,%xmm5 + pxor %xmm4,%xmm14 + pxor %xmm5,%xmm15 + movdqa %xmm14,%xmm6 + pslld $12,%xmm14 + psrld $20,%xmm6 + movdqa %xmm15,%xmm7 + pslld $12,%xmm15 + por %xmm6,%xmm14 + psrld $20,%xmm7 + movdqa (%r11),%xmm6 + por %xmm7,%xmm15 + paddd %xmm14,%xmm10 + paddd %xmm15,%xmm11 + pxor %xmm10,%xmm2 + pxor %xmm11,%xmm3 +.byte 102,15,56,0,214 +.byte 102,15,56,0,222 + paddd %xmm2,%xmm4 + paddd %xmm3,%xmm5 + pxor %xmm4,%xmm14 + pxor %xmm5,%xmm15 + movdqa %xmm14,%xmm7 + pslld $7,%xmm14 + psrld $25,%xmm7 + movdqa %xmm15,%xmm6 + pslld $7,%xmm15 + por %xmm7,%xmm14 + psrld $25,%xmm6 + movdqa (%r10),%xmm7 + por %xmm6,%xmm15 + paddd %xmm13,%xmm8 + paddd %xmm14,%xmm9 + pxor %xmm8,%xmm3 + pxor %xmm9,%xmm0 +.byte 102,15,56,0,223 +.byte 102,15,56,0,199 + paddd %xmm3,%xmm4 + paddd %xmm0,%xmm5 + pxor %xmm4,%xmm13 + pxor %xmm5,%xmm14 + movdqa %xmm13,%xmm6 + pslld $12,%xmm13 + psrld $20,%xmm6 + movdqa %xmm14,%xmm7 + pslld $12,%xmm14 + por %xmm6,%xmm13 + psrld $20,%xmm7 + movdqa (%r11),%xmm6 + por %xmm7,%xmm14 + paddd %xmm13,%xmm8 + paddd %xmm14,%xmm9 + pxor %xmm8,%xmm3 + pxor %xmm9,%xmm0 +.byte 102,15,56,0,222 +.byte 102,15,56,0,198 + paddd %xmm3,%xmm4 + paddd %xmm0,%xmm5 + pxor %xmm4,%xmm13 + pxor %xmm5,%xmm14 + movdqa %xmm13,%xmm7 + pslld $7,%xmm13 + psrld $25,%xmm7 + movdqa %xmm14,%xmm6 + pslld $7,%xmm14 + por %xmm7,%xmm13 + psrld $25,%xmm6 + movdqa (%r10),%xmm7 + por %xmm6,%xmm14 + movdqa %xmm4,32(%rsp) + movdqa %xmm5,48(%rsp) + movdqa 0(%rsp),%xmm4 + movdqa 16(%rsp),%xmm5 + paddd %xmm15,%xmm10 + paddd %xmm12,%xmm11 + pxor %xmm10,%xmm1 + pxor %xmm11,%xmm2 +.byte 102,15,56,0,207 +.byte 102,15,56,0,215 + paddd %xmm1,%xmm4 + paddd %xmm2,%xmm5 + pxor %xmm4,%xmm15 + pxor %xmm5,%xmm12 + movdqa %xmm15,%xmm6 + pslld $12,%xmm15 + psrld $20,%xmm6 + movdqa %xmm12,%xmm7 + pslld $12,%xmm12 + por %xmm6,%xmm15 + psrld $20,%xmm7 + movdqa (%r11),%xmm6 + por %xmm7,%xmm12 + paddd %xmm15,%xmm10 + paddd %xmm12,%xmm11 + pxor %xmm10,%xmm1 + pxor %xmm11,%xmm2 +.byte 102,15,56,0,206 +.byte 102,15,56,0,214 + paddd %xmm1,%xmm4 + paddd %xmm2,%xmm5 + pxor %xmm4,%xmm15 + pxor %xmm5,%xmm12 + movdqa %xmm15,%xmm7 + pslld $7,%xmm15 + psrld $25,%xmm7 + movdqa %xmm12,%xmm6 + pslld $7,%xmm12 + por %xmm7,%xmm15 + psrld $25,%xmm6 + movdqa (%r10),%xmm7 + por %xmm6,%xmm12 + decl %eax + jnz .Loop4x + + paddd 64(%rsp),%xmm8 + paddd 80(%rsp),%xmm9 + paddd 96(%rsp),%xmm10 + paddd 112(%rsp),%xmm11 + + movdqa %xmm8,%xmm6 + punpckldq %xmm9,%xmm8 + movdqa %xmm10,%xmm7 + punpckldq %xmm11,%xmm10 + punpckhdq %xmm9,%xmm6 + punpckhdq %xmm11,%xmm7 + movdqa %xmm8,%xmm9 + punpcklqdq %xmm10,%xmm8 + movdqa %xmm6,%xmm11 + punpcklqdq %xmm7,%xmm6 + punpckhqdq %xmm10,%xmm9 + punpckhqdq %xmm7,%xmm11 + paddd 128-256(%rcx),%xmm12 + paddd 144-256(%rcx),%xmm13 + paddd 160-256(%rcx),%xmm14 + paddd 176-256(%rcx),%xmm15 + + movdqa %xmm8,0(%rsp) + movdqa %xmm9,16(%rsp) + movdqa 32(%rsp),%xmm8 + movdqa 48(%rsp),%xmm9 + + movdqa %xmm12,%xmm10 + punpckldq %xmm13,%xmm12 + movdqa %xmm14,%xmm7 + punpckldq %xmm15,%xmm14 + punpckhdq %xmm13,%xmm10 + punpckhdq %xmm15,%xmm7 + movdqa %xmm12,%xmm13 + punpcklqdq %xmm14,%xmm12 + movdqa %xmm10,%xmm15 + punpcklqdq %xmm7,%xmm10 + punpckhqdq %xmm14,%xmm13 + punpckhqdq %xmm7,%xmm15 + paddd 192-256(%rcx),%xmm4 + paddd 208-256(%rcx),%xmm5 + paddd 224-256(%rcx),%xmm8 + paddd 240-256(%rcx),%xmm9 + + movdqa %xmm6,32(%rsp) + movdqa %xmm11,48(%rsp) + + movdqa %xmm4,%xmm14 + punpckldq %xmm5,%xmm4 + movdqa %xmm8,%xmm7 + punpckldq %xmm9,%xmm8 + punpckhdq %xmm5,%xmm14 + punpckhdq %xmm9,%xmm7 + movdqa %xmm4,%xmm5 + punpcklqdq %xmm8,%xmm4 + movdqa %xmm14,%xmm9 + punpcklqdq %xmm7,%xmm14 + punpckhqdq %xmm8,%xmm5 + punpckhqdq %xmm7,%xmm9 + paddd 256-256(%rcx),%xmm0 + paddd 272-256(%rcx),%xmm1 + paddd 288-256(%rcx),%xmm2 + paddd 304-256(%rcx),%xmm3 + + movdqa %xmm0,%xmm8 + punpckldq %xmm1,%xmm0 + movdqa %xmm2,%xmm7 + punpckldq %xmm3,%xmm2 + punpckhdq %xmm1,%xmm8 + punpckhdq %xmm3,%xmm7 + movdqa %xmm0,%xmm1 + punpcklqdq %xmm2,%xmm0 + movdqa %xmm8,%xmm3 + punpcklqdq %xmm7,%xmm8 + punpckhqdq %xmm2,%xmm1 + punpckhqdq %xmm7,%xmm3 + cmpq $256,%rdx + jb .Ltail4x + + movdqu 0(%rsi),%xmm6 + movdqu 16(%rsi),%xmm11 + movdqu 32(%rsi),%xmm2 + movdqu 48(%rsi),%xmm7 + pxor 0(%rsp),%xmm6 + pxor %xmm12,%xmm11 + pxor %xmm4,%xmm2 + pxor %xmm0,%xmm7 + + movdqu %xmm6,0(%rdi) + movdqu 64(%rsi),%xmm6 + movdqu %xmm11,16(%rdi) + movdqu 80(%rsi),%xmm11 + movdqu %xmm2,32(%rdi) + movdqu 96(%rsi),%xmm2 + movdqu %xmm7,48(%rdi) + movdqu 112(%rsi),%xmm7 + leaq 128(%rsi),%rsi + pxor 16(%rsp),%xmm6 + pxor %xmm13,%xmm11 + pxor %xmm5,%xmm2 + pxor %xmm1,%xmm7 + + movdqu %xmm6,64(%rdi) + movdqu 0(%rsi),%xmm6 + movdqu %xmm11,80(%rdi) + movdqu 16(%rsi),%xmm11 + movdqu %xmm2,96(%rdi) + movdqu 32(%rsi),%xmm2 + movdqu %xmm7,112(%rdi) + leaq 128(%rdi),%rdi + movdqu 48(%rsi),%xmm7 + pxor 32(%rsp),%xmm6 + pxor %xmm10,%xmm11 + pxor %xmm14,%xmm2 + pxor %xmm8,%xmm7 + + movdqu %xmm6,0(%rdi) + movdqu 64(%rsi),%xmm6 + movdqu %xmm11,16(%rdi) + movdqu 80(%rsi),%xmm11 + movdqu %xmm2,32(%rdi) + movdqu 96(%rsi),%xmm2 + movdqu %xmm7,48(%rdi) + movdqu 112(%rsi),%xmm7 + leaq 128(%rsi),%rsi + pxor 48(%rsp),%xmm6 + pxor %xmm15,%xmm11 + pxor %xmm9,%xmm2 + pxor %xmm3,%xmm7 + movdqu %xmm6,64(%rdi) + movdqu %xmm11,80(%rdi) + movdqu %xmm2,96(%rdi) + movdqu %xmm7,112(%rdi) + leaq 128(%rdi),%rdi + + subq $256,%rdx + jnz .Loop_outer4x + + jmp .Ldone4x + +.Ltail4x: + cmpq $192,%rdx + jae .L192_or_more4x + cmpq $128,%rdx + jae .L128_or_more4x + cmpq $64,%rdx + jae .L64_or_more4x + + + xorq %r10,%r10 + + movdqa %xmm12,16(%rsp) + movdqa %xmm4,32(%rsp) + movdqa %xmm0,48(%rsp) + jmp .Loop_tail4x + +.align 32 +.L64_or_more4x: + movdqu 0(%rsi),%xmm6 + movdqu 16(%rsi),%xmm11 + movdqu 32(%rsi),%xmm2 + movdqu 48(%rsi),%xmm7 + pxor 0(%rsp),%xmm6 + pxor %xmm12,%xmm11 + pxor %xmm4,%xmm2 + pxor %xmm0,%xmm7 + movdqu %xmm6,0(%rdi) + movdqu %xmm11,16(%rdi) + movdqu %xmm2,32(%rdi) + movdqu %xmm7,48(%rdi) + je .Ldone4x + + movdqa 16(%rsp),%xmm6 + leaq 64(%rsi),%rsi + xorq %r10,%r10 + movdqa %xmm6,0(%rsp) + movdqa %xmm13,16(%rsp) + leaq 64(%rdi),%rdi + movdqa %xmm5,32(%rsp) + subq $64,%rdx + movdqa %xmm1,48(%rsp) + jmp .Loop_tail4x + +.align 32 +.L128_or_more4x: + movdqu 0(%rsi),%xmm6 + movdqu 16(%rsi),%xmm11 + movdqu 32(%rsi),%xmm2 + movdqu 48(%rsi),%xmm7 + pxor 0(%rsp),%xmm6 + pxor %xmm12,%xmm11 + pxor %xmm4,%xmm2 + pxor %xmm0,%xmm7 + + movdqu %xmm6,0(%rdi) + movdqu 64(%rsi),%xmm6 + movdqu %xmm11,16(%rdi) + movdqu 80(%rsi),%xmm11 + movdqu %xmm2,32(%rdi) + movdqu 96(%rsi),%xmm2 + movdqu %xmm7,48(%rdi) + movdqu 112(%rsi),%xmm7 + pxor 16(%rsp),%xmm6 + pxor %xmm13,%xmm11 + pxor %xmm5,%xmm2 + pxor %xmm1,%xmm7 + movdqu %xmm6,64(%rdi) + movdqu %xmm11,80(%rdi) + movdqu %xmm2,96(%rdi) + movdqu %xmm7,112(%rdi) + je .Ldone4x + + movdqa 32(%rsp),%xmm6 + leaq 128(%rsi),%rsi + xorq %r10,%r10 + movdqa %xmm6,0(%rsp) + movdqa %xmm10,16(%rsp) + leaq 128(%rdi),%rdi + movdqa %xmm14,32(%rsp) + subq $128,%rdx + movdqa %xmm8,48(%rsp) + jmp .Loop_tail4x + +.align 32 +.L192_or_more4x: + movdqu 0(%rsi),%xmm6 + movdqu 16(%rsi),%xmm11 + movdqu 32(%rsi),%xmm2 + movdqu 48(%rsi),%xmm7 + pxor 0(%rsp),%xmm6 + pxor %xmm12,%xmm11 + pxor %xmm4,%xmm2 + pxor %xmm0,%xmm7 + + movdqu %xmm6,0(%rdi) + movdqu 64(%rsi),%xmm6 + movdqu %xmm11,16(%rdi) + movdqu 80(%rsi),%xmm11 + movdqu %xmm2,32(%rdi) + movdqu 96(%rsi),%xmm2 + movdqu %xmm7,48(%rdi) + movdqu 112(%rsi),%xmm7 + leaq 128(%rsi),%rsi + pxor 16(%rsp),%xmm6 + pxor %xmm13,%xmm11 + pxor %xmm5,%xmm2 + pxor %xmm1,%xmm7 + + movdqu %xmm6,64(%rdi) + movdqu 0(%rsi),%xmm6 + movdqu %xmm11,80(%rdi) + movdqu 16(%rsi),%xmm11 + movdqu %xmm2,96(%rdi) + movdqu 32(%rsi),%xmm2 + movdqu %xmm7,112(%rdi) + leaq 128(%rdi),%rdi + movdqu 48(%rsi),%xmm7 + pxor 32(%rsp),%xmm6 + pxor %xmm10,%xmm11 + pxor %xmm14,%xmm2 + pxor %xmm8,%xmm7 + movdqu %xmm6,0(%rdi) + movdqu %xmm11,16(%rdi) + movdqu %xmm2,32(%rdi) + movdqu %xmm7,48(%rdi) + je .Ldone4x + + movdqa 48(%rsp),%xmm6 + leaq 64(%rsi),%rsi + xorq %r10,%r10 + movdqa %xmm6,0(%rsp) + movdqa %xmm15,16(%rsp) + leaq 64(%rdi),%rdi + movdqa %xmm9,32(%rsp) + subq $192,%rdx + movdqa %xmm3,48(%rsp) + +.Loop_tail4x: + movzbl (%rsi,%r10,1),%eax + movzbl (%rsp,%r10,1),%ecx + leaq 1(%r10),%r10 + xorl %ecx,%eax + movb %al,-1(%rdi,%r10,1) + decq %rdx + jnz .Loop_tail4x + +.Ldone4x: + leaq (%r9),%rsp +.cfi_def_cfa_register rsp +.L4x_epilogue: + ret +.cfi_endproc +.size ChaCha20_ctr32_ssse3_4x,.-ChaCha20_ctr32_ssse3_4x +.globl ChaCha20_ctr32_avx2 +.hidden ChaCha20_ctr32_avx2 +.type ChaCha20_ctr32_avx2,@function +.align 32 +ChaCha20_ctr32_avx2: +.cfi_startproc +_CET_ENDBR + movq %rsp,%r9 +.cfi_def_cfa_register r9 + subq $0x280+8,%rsp + andq $-32,%rsp + vzeroupper + + + + + + + + + + + vbroadcasti128 .Lsigma(%rip),%ymm11 + vbroadcasti128 (%rcx),%ymm3 + vbroadcasti128 16(%rcx),%ymm15 + vbroadcasti128 (%r8),%ymm7 + leaq 256(%rsp),%rcx + leaq 512(%rsp),%rax + leaq .Lrot16(%rip),%r10 + leaq .Lrot24(%rip),%r11 + + vpshufd $0x00,%ymm11,%ymm8 + vpshufd $0x55,%ymm11,%ymm9 + vmovdqa %ymm8,128-256(%rcx) + vpshufd $0xaa,%ymm11,%ymm10 + vmovdqa %ymm9,160-256(%rcx) + vpshufd $0xff,%ymm11,%ymm11 + vmovdqa %ymm10,192-256(%rcx) + vmovdqa %ymm11,224-256(%rcx) + + vpshufd $0x00,%ymm3,%ymm0 + vpshufd $0x55,%ymm3,%ymm1 + vmovdqa %ymm0,256-256(%rcx) + vpshufd $0xaa,%ymm3,%ymm2 + vmovdqa %ymm1,288-256(%rcx) + vpshufd $0xff,%ymm3,%ymm3 + vmovdqa %ymm2,320-256(%rcx) + vmovdqa %ymm3,352-256(%rcx) + + vpshufd $0x00,%ymm15,%ymm12 + vpshufd $0x55,%ymm15,%ymm13 + vmovdqa %ymm12,384-512(%rax) + vpshufd $0xaa,%ymm15,%ymm14 + vmovdqa %ymm13,416-512(%rax) + vpshufd $0xff,%ymm15,%ymm15 + vmovdqa %ymm14,448-512(%rax) + vmovdqa %ymm15,480-512(%rax) + + vpshufd $0x00,%ymm7,%ymm4 + vpshufd $0x55,%ymm7,%ymm5 + vpaddd .Lincy(%rip),%ymm4,%ymm4 + vpshufd $0xaa,%ymm7,%ymm6 + vmovdqa %ymm5,544-512(%rax) + vpshufd $0xff,%ymm7,%ymm7 + vmovdqa %ymm6,576-512(%rax) + vmovdqa %ymm7,608-512(%rax) + + jmp .Loop_enter8x + +.align 32 +.Loop_outer8x: + vmovdqa 128-256(%rcx),%ymm8 + vmovdqa 160-256(%rcx),%ymm9 + vmovdqa 192-256(%rcx),%ymm10 + vmovdqa 224-256(%rcx),%ymm11 + vmovdqa 256-256(%rcx),%ymm0 + vmovdqa 288-256(%rcx),%ymm1 + vmovdqa 320-256(%rcx),%ymm2 + vmovdqa 352-256(%rcx),%ymm3 + vmovdqa 384-512(%rax),%ymm12 + vmovdqa 416-512(%rax),%ymm13 + vmovdqa 448-512(%rax),%ymm14 + vmovdqa 480-512(%rax),%ymm15 + vmovdqa 512-512(%rax),%ymm4 + vmovdqa 544-512(%rax),%ymm5 + vmovdqa 576-512(%rax),%ymm6 + vmovdqa 608-512(%rax),%ymm7 + vpaddd .Leight(%rip),%ymm4,%ymm4 + +.Loop_enter8x: + vmovdqa %ymm14,64(%rsp) + vmovdqa %ymm15,96(%rsp) + vbroadcasti128 (%r10),%ymm15 + vmovdqa %ymm4,512-512(%rax) + movl $10,%eax + jmp .Loop8x + +.align 32 +.Loop8x: + vpaddd %ymm0,%ymm8,%ymm8 + vpxor %ymm4,%ymm8,%ymm4 + vpshufb %ymm15,%ymm4,%ymm4 + vpaddd %ymm1,%ymm9,%ymm9 + vpxor %ymm5,%ymm9,%ymm5 + vpshufb %ymm15,%ymm5,%ymm5 + vpaddd %ymm4,%ymm12,%ymm12 + vpxor %ymm0,%ymm12,%ymm0 + vpslld $12,%ymm0,%ymm14 + vpsrld $20,%ymm0,%ymm0 + vpor %ymm0,%ymm14,%ymm0 + vbroadcasti128 (%r11),%ymm14 + vpaddd %ymm5,%ymm13,%ymm13 + vpxor %ymm1,%ymm13,%ymm1 + vpslld $12,%ymm1,%ymm15 + vpsrld $20,%ymm1,%ymm1 + vpor %ymm1,%ymm15,%ymm1 + vpaddd %ymm0,%ymm8,%ymm8 + vpxor %ymm4,%ymm8,%ymm4 + vpshufb %ymm14,%ymm4,%ymm4 + vpaddd %ymm1,%ymm9,%ymm9 + vpxor %ymm5,%ymm9,%ymm5 + vpshufb %ymm14,%ymm5,%ymm5 + vpaddd %ymm4,%ymm12,%ymm12 + vpxor %ymm0,%ymm12,%ymm0 + vpslld $7,%ymm0,%ymm15 + vpsrld $25,%ymm0,%ymm0 + vpor %ymm0,%ymm15,%ymm0 + vbroadcasti128 (%r10),%ymm15 + vpaddd %ymm5,%ymm13,%ymm13 + vpxor %ymm1,%ymm13,%ymm1 + vpslld $7,%ymm1,%ymm14 + vpsrld $25,%ymm1,%ymm1 + vpor %ymm1,%ymm14,%ymm1 + vmovdqa %ymm12,0(%rsp) + vmovdqa %ymm13,32(%rsp) + vmovdqa 64(%rsp),%ymm12 + vmovdqa 96(%rsp),%ymm13 + vpaddd %ymm2,%ymm10,%ymm10 + vpxor %ymm6,%ymm10,%ymm6 + vpshufb %ymm15,%ymm6,%ymm6 + vpaddd %ymm3,%ymm11,%ymm11 + vpxor %ymm7,%ymm11,%ymm7 + vpshufb %ymm15,%ymm7,%ymm7 + vpaddd %ymm6,%ymm12,%ymm12 + vpxor %ymm2,%ymm12,%ymm2 + vpslld $12,%ymm2,%ymm14 + vpsrld $20,%ymm2,%ymm2 + vpor %ymm2,%ymm14,%ymm2 + vbroadcasti128 (%r11),%ymm14 + vpaddd %ymm7,%ymm13,%ymm13 + vpxor %ymm3,%ymm13,%ymm3 + vpslld $12,%ymm3,%ymm15 + vpsrld $20,%ymm3,%ymm3 + vpor %ymm3,%ymm15,%ymm3 + vpaddd %ymm2,%ymm10,%ymm10 + vpxor %ymm6,%ymm10,%ymm6 + vpshufb %ymm14,%ymm6,%ymm6 + vpaddd %ymm3,%ymm11,%ymm11 + vpxor %ymm7,%ymm11,%ymm7 + vpshufb %ymm14,%ymm7,%ymm7 + vpaddd %ymm6,%ymm12,%ymm12 + vpxor %ymm2,%ymm12,%ymm2 + vpslld $7,%ymm2,%ymm15 + vpsrld $25,%ymm2,%ymm2 + vpor %ymm2,%ymm15,%ymm2 + vbroadcasti128 (%r10),%ymm15 + vpaddd %ymm7,%ymm13,%ymm13 + vpxor %ymm3,%ymm13,%ymm3 + vpslld $7,%ymm3,%ymm14 + vpsrld $25,%ymm3,%ymm3 + vpor %ymm3,%ymm14,%ymm3 + vpaddd %ymm1,%ymm8,%ymm8 + vpxor %ymm7,%ymm8,%ymm7 + vpshufb %ymm15,%ymm7,%ymm7 + vpaddd %ymm2,%ymm9,%ymm9 + vpxor %ymm4,%ymm9,%ymm4 + vpshufb %ymm15,%ymm4,%ymm4 + vpaddd %ymm7,%ymm12,%ymm12 + vpxor %ymm1,%ymm12,%ymm1 + vpslld $12,%ymm1,%ymm14 + vpsrld $20,%ymm1,%ymm1 + vpor %ymm1,%ymm14,%ymm1 + vbroadcasti128 (%r11),%ymm14 + vpaddd %ymm4,%ymm13,%ymm13 + vpxor %ymm2,%ymm13,%ymm2 + vpslld $12,%ymm2,%ymm15 + vpsrld $20,%ymm2,%ymm2 + vpor %ymm2,%ymm15,%ymm2 + vpaddd %ymm1,%ymm8,%ymm8 + vpxor %ymm7,%ymm8,%ymm7 + vpshufb %ymm14,%ymm7,%ymm7 + vpaddd %ymm2,%ymm9,%ymm9 + vpxor %ymm4,%ymm9,%ymm4 + vpshufb %ymm14,%ymm4,%ymm4 + vpaddd %ymm7,%ymm12,%ymm12 + vpxor %ymm1,%ymm12,%ymm1 + vpslld $7,%ymm1,%ymm15 + vpsrld $25,%ymm1,%ymm1 + vpor %ymm1,%ymm15,%ymm1 + vbroadcasti128 (%r10),%ymm15 + vpaddd %ymm4,%ymm13,%ymm13 + vpxor %ymm2,%ymm13,%ymm2 + vpslld $7,%ymm2,%ymm14 + vpsrld $25,%ymm2,%ymm2 + vpor %ymm2,%ymm14,%ymm2 + vmovdqa %ymm12,64(%rsp) + vmovdqa %ymm13,96(%rsp) + vmovdqa 0(%rsp),%ymm12 + vmovdqa 32(%rsp),%ymm13 + vpaddd %ymm3,%ymm10,%ymm10 + vpxor %ymm5,%ymm10,%ymm5 + vpshufb %ymm15,%ymm5,%ymm5 + vpaddd %ymm0,%ymm11,%ymm11 + vpxor %ymm6,%ymm11,%ymm6 + vpshufb %ymm15,%ymm6,%ymm6 + vpaddd %ymm5,%ymm12,%ymm12 + vpxor %ymm3,%ymm12,%ymm3 + vpslld $12,%ymm3,%ymm14 + vpsrld $20,%ymm3,%ymm3 + vpor %ymm3,%ymm14,%ymm3 + vbroadcasti128 (%r11),%ymm14 + vpaddd %ymm6,%ymm13,%ymm13 + vpxor %ymm0,%ymm13,%ymm0 + vpslld $12,%ymm0,%ymm15 + vpsrld $20,%ymm0,%ymm0 + vpor %ymm0,%ymm15,%ymm0 + vpaddd %ymm3,%ymm10,%ymm10 + vpxor %ymm5,%ymm10,%ymm5 + vpshufb %ymm14,%ymm5,%ymm5 + vpaddd %ymm0,%ymm11,%ymm11 + vpxor %ymm6,%ymm11,%ymm6 + vpshufb %ymm14,%ymm6,%ymm6 + vpaddd %ymm5,%ymm12,%ymm12 + vpxor %ymm3,%ymm12,%ymm3 + vpslld $7,%ymm3,%ymm15 + vpsrld $25,%ymm3,%ymm3 + vpor %ymm3,%ymm15,%ymm3 + vbroadcasti128 (%r10),%ymm15 + vpaddd %ymm6,%ymm13,%ymm13 + vpxor %ymm0,%ymm13,%ymm0 + vpslld $7,%ymm0,%ymm14 + vpsrld $25,%ymm0,%ymm0 + vpor %ymm0,%ymm14,%ymm0 + decl %eax + jnz .Loop8x + + leaq 512(%rsp),%rax + vpaddd 128-256(%rcx),%ymm8,%ymm8 + vpaddd 160-256(%rcx),%ymm9,%ymm9 + vpaddd 192-256(%rcx),%ymm10,%ymm10 + vpaddd 224-256(%rcx),%ymm11,%ymm11 + + vpunpckldq %ymm9,%ymm8,%ymm14 + vpunpckldq %ymm11,%ymm10,%ymm15 + vpunpckhdq %ymm9,%ymm8,%ymm8 + vpunpckhdq %ymm11,%ymm10,%ymm10 + vpunpcklqdq %ymm15,%ymm14,%ymm9 + vpunpckhqdq %ymm15,%ymm14,%ymm14 + vpunpcklqdq %ymm10,%ymm8,%ymm11 + vpunpckhqdq %ymm10,%ymm8,%ymm8 + vpaddd 256-256(%rcx),%ymm0,%ymm0 + vpaddd 288-256(%rcx),%ymm1,%ymm1 + vpaddd 320-256(%rcx),%ymm2,%ymm2 + vpaddd 352-256(%rcx),%ymm3,%ymm3 + + vpunpckldq %ymm1,%ymm0,%ymm10 + vpunpckldq %ymm3,%ymm2,%ymm15 + vpunpckhdq %ymm1,%ymm0,%ymm0 + vpunpckhdq %ymm3,%ymm2,%ymm2 + vpunpcklqdq %ymm15,%ymm10,%ymm1 + vpunpckhqdq %ymm15,%ymm10,%ymm10 + vpunpcklqdq %ymm2,%ymm0,%ymm3 + vpunpckhqdq %ymm2,%ymm0,%ymm0 + vperm2i128 $0x20,%ymm1,%ymm9,%ymm15 + vperm2i128 $0x31,%ymm1,%ymm9,%ymm1 + vperm2i128 $0x20,%ymm10,%ymm14,%ymm9 + vperm2i128 $0x31,%ymm10,%ymm14,%ymm10 + vperm2i128 $0x20,%ymm3,%ymm11,%ymm14 + vperm2i128 $0x31,%ymm3,%ymm11,%ymm3 + vperm2i128 $0x20,%ymm0,%ymm8,%ymm11 + vperm2i128 $0x31,%ymm0,%ymm8,%ymm0 + vmovdqa %ymm15,0(%rsp) + vmovdqa %ymm9,32(%rsp) + vmovdqa 64(%rsp),%ymm15 + vmovdqa 96(%rsp),%ymm9 + + vpaddd 384-512(%rax),%ymm12,%ymm12 + vpaddd 416-512(%rax),%ymm13,%ymm13 + vpaddd 448-512(%rax),%ymm15,%ymm15 + vpaddd 480-512(%rax),%ymm9,%ymm9 + + vpunpckldq %ymm13,%ymm12,%ymm2 + vpunpckldq %ymm9,%ymm15,%ymm8 + vpunpckhdq %ymm13,%ymm12,%ymm12 + vpunpckhdq %ymm9,%ymm15,%ymm15 + vpunpcklqdq %ymm8,%ymm2,%ymm13 + vpunpckhqdq %ymm8,%ymm2,%ymm2 + vpunpcklqdq %ymm15,%ymm12,%ymm9 + vpunpckhqdq %ymm15,%ymm12,%ymm12 + vpaddd 512-512(%rax),%ymm4,%ymm4 + vpaddd 544-512(%rax),%ymm5,%ymm5 + vpaddd 576-512(%rax),%ymm6,%ymm6 + vpaddd 608-512(%rax),%ymm7,%ymm7 + + vpunpckldq %ymm5,%ymm4,%ymm15 + vpunpckldq %ymm7,%ymm6,%ymm8 + vpunpckhdq %ymm5,%ymm4,%ymm4 + vpunpckhdq %ymm7,%ymm6,%ymm6 + vpunpcklqdq %ymm8,%ymm15,%ymm5 + vpunpckhqdq %ymm8,%ymm15,%ymm15 + vpunpcklqdq %ymm6,%ymm4,%ymm7 + vpunpckhqdq %ymm6,%ymm4,%ymm4 + vperm2i128 $0x20,%ymm5,%ymm13,%ymm8 + vperm2i128 $0x31,%ymm5,%ymm13,%ymm5 + vperm2i128 $0x20,%ymm15,%ymm2,%ymm13 + vperm2i128 $0x31,%ymm15,%ymm2,%ymm15 + vperm2i128 $0x20,%ymm7,%ymm9,%ymm2 + vperm2i128 $0x31,%ymm7,%ymm9,%ymm7 + vperm2i128 $0x20,%ymm4,%ymm12,%ymm9 + vperm2i128 $0x31,%ymm4,%ymm12,%ymm4 + vmovdqa 0(%rsp),%ymm6 + vmovdqa 32(%rsp),%ymm12 + + cmpq $512,%rdx + jb .Ltail8x + + vpxor 0(%rsi),%ymm6,%ymm6 + vpxor 32(%rsi),%ymm8,%ymm8 + vpxor 64(%rsi),%ymm1,%ymm1 + vpxor 96(%rsi),%ymm5,%ymm5 + leaq 128(%rsi),%rsi + vmovdqu %ymm6,0(%rdi) + vmovdqu %ymm8,32(%rdi) + vmovdqu %ymm1,64(%rdi) + vmovdqu %ymm5,96(%rdi) + leaq 128(%rdi),%rdi + + vpxor 0(%rsi),%ymm12,%ymm12 + vpxor 32(%rsi),%ymm13,%ymm13 + vpxor 64(%rsi),%ymm10,%ymm10 + vpxor 96(%rsi),%ymm15,%ymm15 + leaq 128(%rsi),%rsi + vmovdqu %ymm12,0(%rdi) + vmovdqu %ymm13,32(%rdi) + vmovdqu %ymm10,64(%rdi) + vmovdqu %ymm15,96(%rdi) + leaq 128(%rdi),%rdi + + vpxor 0(%rsi),%ymm14,%ymm14 + vpxor 32(%rsi),%ymm2,%ymm2 + vpxor 64(%rsi),%ymm3,%ymm3 + vpxor 96(%rsi),%ymm7,%ymm7 + leaq 128(%rsi),%rsi + vmovdqu %ymm14,0(%rdi) + vmovdqu %ymm2,32(%rdi) + vmovdqu %ymm3,64(%rdi) + vmovdqu %ymm7,96(%rdi) + leaq 128(%rdi),%rdi + + vpxor 0(%rsi),%ymm11,%ymm11 + vpxor 32(%rsi),%ymm9,%ymm9 + vpxor 64(%rsi),%ymm0,%ymm0 + vpxor 96(%rsi),%ymm4,%ymm4 + leaq 128(%rsi),%rsi + vmovdqu %ymm11,0(%rdi) + vmovdqu %ymm9,32(%rdi) + vmovdqu %ymm0,64(%rdi) + vmovdqu %ymm4,96(%rdi) + leaq 128(%rdi),%rdi + + subq $512,%rdx + jnz .Loop_outer8x + + jmp .Ldone8x + +.Ltail8x: + cmpq $448,%rdx + jae .L448_or_more8x + cmpq $384,%rdx + jae .L384_or_more8x + cmpq $320,%rdx + jae .L320_or_more8x + cmpq $256,%rdx + jae .L256_or_more8x + cmpq $192,%rdx + jae .L192_or_more8x + cmpq $128,%rdx + jae .L128_or_more8x + cmpq $64,%rdx + jae .L64_or_more8x + + xorq %r10,%r10 + vmovdqa %ymm6,0(%rsp) + vmovdqa %ymm8,32(%rsp) + jmp .Loop_tail8x + +.align 32 +.L64_or_more8x: + vpxor 0(%rsi),%ymm6,%ymm6 + vpxor 32(%rsi),%ymm8,%ymm8 + vmovdqu %ymm6,0(%rdi) + vmovdqu %ymm8,32(%rdi) + je .Ldone8x + + leaq 64(%rsi),%rsi + xorq %r10,%r10 + vmovdqa %ymm1,0(%rsp) + leaq 64(%rdi),%rdi + subq $64,%rdx + vmovdqa %ymm5,32(%rsp) + jmp .Loop_tail8x + +.align 32 +.L128_or_more8x: + vpxor 0(%rsi),%ymm6,%ymm6 + vpxor 32(%rsi),%ymm8,%ymm8 + vpxor 64(%rsi),%ymm1,%ymm1 + vpxor 96(%rsi),%ymm5,%ymm5 + vmovdqu %ymm6,0(%rdi) + vmovdqu %ymm8,32(%rdi) + vmovdqu %ymm1,64(%rdi) + vmovdqu %ymm5,96(%rdi) + je .Ldone8x + + leaq 128(%rsi),%rsi + xorq %r10,%r10 + vmovdqa %ymm12,0(%rsp) + leaq 128(%rdi),%rdi + subq $128,%rdx + vmovdqa %ymm13,32(%rsp) + jmp .Loop_tail8x + +.align 32 +.L192_or_more8x: + vpxor 0(%rsi),%ymm6,%ymm6 + vpxor 32(%rsi),%ymm8,%ymm8 + vpxor 64(%rsi),%ymm1,%ymm1 + vpxor 96(%rsi),%ymm5,%ymm5 + vpxor 128(%rsi),%ymm12,%ymm12 + vpxor 160(%rsi),%ymm13,%ymm13 + vmovdqu %ymm6,0(%rdi) + vmovdqu %ymm8,32(%rdi) + vmovdqu %ymm1,64(%rdi) + vmovdqu %ymm5,96(%rdi) + vmovdqu %ymm12,128(%rdi) + vmovdqu %ymm13,160(%rdi) + je .Ldone8x + + leaq 192(%rsi),%rsi + xorq %r10,%r10 + vmovdqa %ymm10,0(%rsp) + leaq 192(%rdi),%rdi + subq $192,%rdx + vmovdqa %ymm15,32(%rsp) + jmp .Loop_tail8x + +.align 32 +.L256_or_more8x: + vpxor 0(%rsi),%ymm6,%ymm6 + vpxor 32(%rsi),%ymm8,%ymm8 + vpxor 64(%rsi),%ymm1,%ymm1 + vpxor 96(%rsi),%ymm5,%ymm5 + vpxor 128(%rsi),%ymm12,%ymm12 + vpxor 160(%rsi),%ymm13,%ymm13 + vpxor 192(%rsi),%ymm10,%ymm10 + vpxor 224(%rsi),%ymm15,%ymm15 + vmovdqu %ymm6,0(%rdi) + vmovdqu %ymm8,32(%rdi) + vmovdqu %ymm1,64(%rdi) + vmovdqu %ymm5,96(%rdi) + vmovdqu %ymm12,128(%rdi) + vmovdqu %ymm13,160(%rdi) + vmovdqu %ymm10,192(%rdi) + vmovdqu %ymm15,224(%rdi) + je .Ldone8x + + leaq 256(%rsi),%rsi + xorq %r10,%r10 + vmovdqa %ymm14,0(%rsp) + leaq 256(%rdi),%rdi + subq $256,%rdx + vmovdqa %ymm2,32(%rsp) + jmp .Loop_tail8x + +.align 32 +.L320_or_more8x: + vpxor 0(%rsi),%ymm6,%ymm6 + vpxor 32(%rsi),%ymm8,%ymm8 + vpxor 64(%rsi),%ymm1,%ymm1 + vpxor 96(%rsi),%ymm5,%ymm5 + vpxor 128(%rsi),%ymm12,%ymm12 + vpxor 160(%rsi),%ymm13,%ymm13 + vpxor 192(%rsi),%ymm10,%ymm10 + vpxor 224(%rsi),%ymm15,%ymm15 + vpxor 256(%rsi),%ymm14,%ymm14 + vpxor 288(%rsi),%ymm2,%ymm2 + vmovdqu %ymm6,0(%rdi) + vmovdqu %ymm8,32(%rdi) + vmovdqu %ymm1,64(%rdi) + vmovdqu %ymm5,96(%rdi) + vmovdqu %ymm12,128(%rdi) + vmovdqu %ymm13,160(%rdi) + vmovdqu %ymm10,192(%rdi) + vmovdqu %ymm15,224(%rdi) + vmovdqu %ymm14,256(%rdi) + vmovdqu %ymm2,288(%rdi) + je .Ldone8x + + leaq 320(%rsi),%rsi + xorq %r10,%r10 + vmovdqa %ymm3,0(%rsp) + leaq 320(%rdi),%rdi + subq $320,%rdx + vmovdqa %ymm7,32(%rsp) + jmp .Loop_tail8x + +.align 32 +.L384_or_more8x: + vpxor 0(%rsi),%ymm6,%ymm6 + vpxor 32(%rsi),%ymm8,%ymm8 + vpxor 64(%rsi),%ymm1,%ymm1 + vpxor 96(%rsi),%ymm5,%ymm5 + vpxor 128(%rsi),%ymm12,%ymm12 + vpxor 160(%rsi),%ymm13,%ymm13 + vpxor 192(%rsi),%ymm10,%ymm10 + vpxor 224(%rsi),%ymm15,%ymm15 + vpxor 256(%rsi),%ymm14,%ymm14 + vpxor 288(%rsi),%ymm2,%ymm2 + vpxor 320(%rsi),%ymm3,%ymm3 + vpxor 352(%rsi),%ymm7,%ymm7 + vmovdqu %ymm6,0(%rdi) + vmovdqu %ymm8,32(%rdi) + vmovdqu %ymm1,64(%rdi) + vmovdqu %ymm5,96(%rdi) + vmovdqu %ymm12,128(%rdi) + vmovdqu %ymm13,160(%rdi) + vmovdqu %ymm10,192(%rdi) + vmovdqu %ymm15,224(%rdi) + vmovdqu %ymm14,256(%rdi) + vmovdqu %ymm2,288(%rdi) + vmovdqu %ymm3,320(%rdi) + vmovdqu %ymm7,352(%rdi) + je .Ldone8x + + leaq 384(%rsi),%rsi + xorq %r10,%r10 + vmovdqa %ymm11,0(%rsp) + leaq 384(%rdi),%rdi + subq $384,%rdx + vmovdqa %ymm9,32(%rsp) + jmp .Loop_tail8x + +.align 32 +.L448_or_more8x: + vpxor 0(%rsi),%ymm6,%ymm6 + vpxor 32(%rsi),%ymm8,%ymm8 + vpxor 64(%rsi),%ymm1,%ymm1 + vpxor 96(%rsi),%ymm5,%ymm5 + vpxor 128(%rsi),%ymm12,%ymm12 + vpxor 160(%rsi),%ymm13,%ymm13 + vpxor 192(%rsi),%ymm10,%ymm10 + vpxor 224(%rsi),%ymm15,%ymm15 + vpxor 256(%rsi),%ymm14,%ymm14 + vpxor 288(%rsi),%ymm2,%ymm2 + vpxor 320(%rsi),%ymm3,%ymm3 + vpxor 352(%rsi),%ymm7,%ymm7 + vpxor 384(%rsi),%ymm11,%ymm11 + vpxor 416(%rsi),%ymm9,%ymm9 + vmovdqu %ymm6,0(%rdi) + vmovdqu %ymm8,32(%rdi) + vmovdqu %ymm1,64(%rdi) + vmovdqu %ymm5,96(%rdi) + vmovdqu %ymm12,128(%rdi) + vmovdqu %ymm13,160(%rdi) + vmovdqu %ymm10,192(%rdi) + vmovdqu %ymm15,224(%rdi) + vmovdqu %ymm14,256(%rdi) + vmovdqu %ymm2,288(%rdi) + vmovdqu %ymm3,320(%rdi) + vmovdqu %ymm7,352(%rdi) + vmovdqu %ymm11,384(%rdi) + vmovdqu %ymm9,416(%rdi) + je .Ldone8x + + leaq 448(%rsi),%rsi + xorq %r10,%r10 + vmovdqa %ymm0,0(%rsp) + leaq 448(%rdi),%rdi + subq $448,%rdx + vmovdqa %ymm4,32(%rsp) + +.Loop_tail8x: + movzbl (%rsi,%r10,1),%eax + movzbl (%rsp,%r10,1),%ecx + leaq 1(%r10),%r10 + xorl %ecx,%eax + movb %al,-1(%rdi,%r10,1) + decq %rdx + jnz .Loop_tail8x + +.Ldone8x: + vzeroall + leaq (%r9),%rsp +.cfi_def_cfa_register rsp +.L8x_epilogue: + ret +.cfi_endproc +.size ChaCha20_ctr32_avx2,.-ChaCha20_ctr32_avx2 +#endif diff --git a/http/vendor/ring/pregenerated/chacha-x86_64-macosx.S b/http/vendor/ring/pregenerated/chacha-x86_64-macosx.S new file mode 100644 index 0000000..60cc871 --- /dev/null +++ b/http/vendor/ring/pregenerated/chacha-x86_64-macosx.S @@ -0,0 +1,1468 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__) +.text + +.section __DATA,__const +.p2align 6 +L$zero: +.long 0,0,0,0 +L$one: +.long 1,0,0,0 +L$inc: +.long 0,1,2,3 +L$four: +.long 4,4,4,4 +L$incy: +.long 0,2,4,6,1,3,5,7 +L$eight: +.long 8,8,8,8,8,8,8,8 +L$rot16: +.byte 0x2,0x3,0x0,0x1, 0x6,0x7,0x4,0x5, 0xa,0xb,0x8,0x9, 0xe,0xf,0xc,0xd +L$rot24: +.byte 0x3,0x0,0x1,0x2, 0x7,0x4,0x5,0x6, 0xb,0x8,0x9,0xa, 0xf,0xc,0xd,0xe +L$sigma: +.byte 101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107,0 +.p2align 6 +L$zeroz: +.long 0,0,0,0, 1,0,0,0, 2,0,0,0, 3,0,0,0 +L$fourz: +.long 4,0,0,0, 4,0,0,0, 4,0,0,0, 4,0,0,0 +L$incz: +.long 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 +L$sixteen: +.long 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16 +.byte 67,104,97,67,104,97,50,48,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.text +.globl _ChaCha20_ctr32_nohw +.private_extern _ChaCha20_ctr32_nohw + +.p2align 6 +_ChaCha20_ctr32_nohw: + +_CET_ENDBR + pushq %rbx + + pushq %rbp + + pushq %r12 + + pushq %r13 + + pushq %r14 + + pushq %r15 + + subq $64+24,%rsp + +L$ctr32_body: + + + movdqu (%rcx),%xmm1 + movdqu 16(%rcx),%xmm2 + movdqu (%r8),%xmm3 + movdqa L$one(%rip),%xmm4 + + + movdqa %xmm1,16(%rsp) + movdqa %xmm2,32(%rsp) + movdqa %xmm3,48(%rsp) + movq %rdx,%rbp + jmp L$oop_outer + +.p2align 5 +L$oop_outer: + movl $0x61707865,%eax + movl $0x3320646e,%ebx + movl $0x79622d32,%ecx + movl $0x6b206574,%edx + movl 16(%rsp),%r8d + movl 20(%rsp),%r9d + movl 24(%rsp),%r10d + movl 28(%rsp),%r11d + movd %xmm3,%r12d + movl 52(%rsp),%r13d + movl 56(%rsp),%r14d + movl 60(%rsp),%r15d + + movq %rbp,64+0(%rsp) + movl $10,%ebp + movq %rsi,64+8(%rsp) +.byte 102,72,15,126,214 + movq %rdi,64+16(%rsp) + movq %rsi,%rdi + shrq $32,%rdi + jmp L$oop + +.p2align 5 +L$oop: + addl %r8d,%eax + xorl %eax,%r12d + roll $16,%r12d + addl %r9d,%ebx + xorl %ebx,%r13d + roll $16,%r13d + addl %r12d,%esi + xorl %esi,%r8d + roll $12,%r8d + addl %r13d,%edi + xorl %edi,%r9d + roll $12,%r9d + addl %r8d,%eax + xorl %eax,%r12d + roll $8,%r12d + addl %r9d,%ebx + xorl %ebx,%r13d + roll $8,%r13d + addl %r12d,%esi + xorl %esi,%r8d + roll $7,%r8d + addl %r13d,%edi + xorl %edi,%r9d + roll $7,%r9d + movl %esi,32(%rsp) + movl %edi,36(%rsp) + movl 40(%rsp),%esi + movl 44(%rsp),%edi + addl %r10d,%ecx + xorl %ecx,%r14d + roll $16,%r14d + addl %r11d,%edx + xorl %edx,%r15d + roll $16,%r15d + addl %r14d,%esi + xorl %esi,%r10d + roll $12,%r10d + addl %r15d,%edi + xorl %edi,%r11d + roll $12,%r11d + addl %r10d,%ecx + xorl %ecx,%r14d + roll $8,%r14d + addl %r11d,%edx + xorl %edx,%r15d + roll $8,%r15d + addl %r14d,%esi + xorl %esi,%r10d + roll $7,%r10d + addl %r15d,%edi + xorl %edi,%r11d + roll $7,%r11d + addl %r9d,%eax + xorl %eax,%r15d + roll $16,%r15d + addl %r10d,%ebx + xorl %ebx,%r12d + roll $16,%r12d + addl %r15d,%esi + xorl %esi,%r9d + roll $12,%r9d + addl %r12d,%edi + xorl %edi,%r10d + roll $12,%r10d + addl %r9d,%eax + xorl %eax,%r15d + roll $8,%r15d + addl %r10d,%ebx + xorl %ebx,%r12d + roll $8,%r12d + addl %r15d,%esi + xorl %esi,%r9d + roll $7,%r9d + addl %r12d,%edi + xorl %edi,%r10d + roll $7,%r10d + movl %esi,40(%rsp) + movl %edi,44(%rsp) + movl 32(%rsp),%esi + movl 36(%rsp),%edi + addl %r11d,%ecx + xorl %ecx,%r13d + roll $16,%r13d + addl %r8d,%edx + xorl %edx,%r14d + roll $16,%r14d + addl %r13d,%esi + xorl %esi,%r11d + roll $12,%r11d + addl %r14d,%edi + xorl %edi,%r8d + roll $12,%r8d + addl %r11d,%ecx + xorl %ecx,%r13d + roll $8,%r13d + addl %r8d,%edx + xorl %edx,%r14d + roll $8,%r14d + addl %r13d,%esi + xorl %esi,%r11d + roll $7,%r11d + addl %r14d,%edi + xorl %edi,%r8d + roll $7,%r8d + decl %ebp + jnz L$oop + movl %edi,36(%rsp) + movl %esi,32(%rsp) + movq 64(%rsp),%rbp + movdqa %xmm2,%xmm1 + movq 64+8(%rsp),%rsi + paddd %xmm4,%xmm3 + movq 64+16(%rsp),%rdi + + addl $0x61707865,%eax + addl $0x3320646e,%ebx + addl $0x79622d32,%ecx + addl $0x6b206574,%edx + addl 16(%rsp),%r8d + addl 20(%rsp),%r9d + addl 24(%rsp),%r10d + addl 28(%rsp),%r11d + addl 48(%rsp),%r12d + addl 52(%rsp),%r13d + addl 56(%rsp),%r14d + addl 60(%rsp),%r15d + paddd 32(%rsp),%xmm1 + + cmpq $64,%rbp + jb L$tail + + xorl 0(%rsi),%eax + xorl 4(%rsi),%ebx + xorl 8(%rsi),%ecx + xorl 12(%rsi),%edx + xorl 16(%rsi),%r8d + xorl 20(%rsi),%r9d + xorl 24(%rsi),%r10d + xorl 28(%rsi),%r11d + movdqu 32(%rsi),%xmm0 + xorl 48(%rsi),%r12d + xorl 52(%rsi),%r13d + xorl 56(%rsi),%r14d + xorl 60(%rsi),%r15d + leaq 64(%rsi),%rsi + pxor %xmm1,%xmm0 + + movdqa %xmm2,32(%rsp) + movd %xmm3,48(%rsp) + + movl %eax,0(%rdi) + movl %ebx,4(%rdi) + movl %ecx,8(%rdi) + movl %edx,12(%rdi) + movl %r8d,16(%rdi) + movl %r9d,20(%rdi) + movl %r10d,24(%rdi) + movl %r11d,28(%rdi) + movdqu %xmm0,32(%rdi) + movl %r12d,48(%rdi) + movl %r13d,52(%rdi) + movl %r14d,56(%rdi) + movl %r15d,60(%rdi) + leaq 64(%rdi),%rdi + + subq $64,%rbp + jnz L$oop_outer + + jmp L$done + +.p2align 4 +L$tail: + movl %eax,0(%rsp) + movl %ebx,4(%rsp) + xorq %rbx,%rbx + movl %ecx,8(%rsp) + movl %edx,12(%rsp) + movl %r8d,16(%rsp) + movl %r9d,20(%rsp) + movl %r10d,24(%rsp) + movl %r11d,28(%rsp) + movdqa %xmm1,32(%rsp) + movl %r12d,48(%rsp) + movl %r13d,52(%rsp) + movl %r14d,56(%rsp) + movl %r15d,60(%rsp) + +L$oop_tail: + movzbl (%rsi,%rbx,1),%eax + movzbl (%rsp,%rbx,1),%edx + leaq 1(%rbx),%rbx + xorl %edx,%eax + movb %al,-1(%rdi,%rbx,1) + decq %rbp + jnz L$oop_tail + +L$done: + leaq 64+24+48(%rsp),%rsi + movq -48(%rsi),%r15 + + movq -40(%rsi),%r14 + + movq -32(%rsi),%r13 + + movq -24(%rsi),%r12 + + movq -16(%rsi),%rbp + + movq -8(%rsi),%rbx + + leaq (%rsi),%rsp + +L$no_data: + ret + + +.globl _ChaCha20_ctr32_ssse3_4x +.private_extern _ChaCha20_ctr32_ssse3_4x + +.p2align 5 +_ChaCha20_ctr32_ssse3_4x: + +_CET_ENDBR + movq %rsp,%r9 + + subq $0x140+8,%rsp + movdqa L$sigma(%rip),%xmm11 + movdqu (%rcx),%xmm15 + movdqu 16(%rcx),%xmm7 + movdqu (%r8),%xmm3 + leaq 256(%rsp),%rcx + leaq L$rot16(%rip),%r10 + leaq L$rot24(%rip),%r11 + + pshufd $0x00,%xmm11,%xmm8 + pshufd $0x55,%xmm11,%xmm9 + movdqa %xmm8,64(%rsp) + pshufd $0xaa,%xmm11,%xmm10 + movdqa %xmm9,80(%rsp) + pshufd $0xff,%xmm11,%xmm11 + movdqa %xmm10,96(%rsp) + movdqa %xmm11,112(%rsp) + + pshufd $0x00,%xmm15,%xmm12 + pshufd $0x55,%xmm15,%xmm13 + movdqa %xmm12,128-256(%rcx) + pshufd $0xaa,%xmm15,%xmm14 + movdqa %xmm13,144-256(%rcx) + pshufd $0xff,%xmm15,%xmm15 + movdqa %xmm14,160-256(%rcx) + movdqa %xmm15,176-256(%rcx) + + pshufd $0x00,%xmm7,%xmm4 + pshufd $0x55,%xmm7,%xmm5 + movdqa %xmm4,192-256(%rcx) + pshufd $0xaa,%xmm7,%xmm6 + movdqa %xmm5,208-256(%rcx) + pshufd $0xff,%xmm7,%xmm7 + movdqa %xmm6,224-256(%rcx) + movdqa %xmm7,240-256(%rcx) + + pshufd $0x00,%xmm3,%xmm0 + pshufd $0x55,%xmm3,%xmm1 + paddd L$inc(%rip),%xmm0 + pshufd $0xaa,%xmm3,%xmm2 + movdqa %xmm1,272-256(%rcx) + pshufd $0xff,%xmm3,%xmm3 + movdqa %xmm2,288-256(%rcx) + movdqa %xmm3,304-256(%rcx) + + jmp L$oop_enter4x + +.p2align 5 +L$oop_outer4x: + movdqa 64(%rsp),%xmm8 + movdqa 80(%rsp),%xmm9 + movdqa 96(%rsp),%xmm10 + movdqa 112(%rsp),%xmm11 + movdqa 128-256(%rcx),%xmm12 + movdqa 144-256(%rcx),%xmm13 + movdqa 160-256(%rcx),%xmm14 + movdqa 176-256(%rcx),%xmm15 + movdqa 192-256(%rcx),%xmm4 + movdqa 208-256(%rcx),%xmm5 + movdqa 224-256(%rcx),%xmm6 + movdqa 240-256(%rcx),%xmm7 + movdqa 256-256(%rcx),%xmm0 + movdqa 272-256(%rcx),%xmm1 + movdqa 288-256(%rcx),%xmm2 + movdqa 304-256(%rcx),%xmm3 + paddd L$four(%rip),%xmm0 + +L$oop_enter4x: + movdqa %xmm6,32(%rsp) + movdqa %xmm7,48(%rsp) + movdqa (%r10),%xmm7 + movl $10,%eax + movdqa %xmm0,256-256(%rcx) + jmp L$oop4x + +.p2align 5 +L$oop4x: + paddd %xmm12,%xmm8 + paddd %xmm13,%xmm9 + pxor %xmm8,%xmm0 + pxor %xmm9,%xmm1 +.byte 102,15,56,0,199 +.byte 102,15,56,0,207 + paddd %xmm0,%xmm4 + paddd %xmm1,%xmm5 + pxor %xmm4,%xmm12 + pxor %xmm5,%xmm13 + movdqa %xmm12,%xmm6 + pslld $12,%xmm12 + psrld $20,%xmm6 + movdqa %xmm13,%xmm7 + pslld $12,%xmm13 + por %xmm6,%xmm12 + psrld $20,%xmm7 + movdqa (%r11),%xmm6 + por %xmm7,%xmm13 + paddd %xmm12,%xmm8 + paddd %xmm13,%xmm9 + pxor %xmm8,%xmm0 + pxor %xmm9,%xmm1 +.byte 102,15,56,0,198 +.byte 102,15,56,0,206 + paddd %xmm0,%xmm4 + paddd %xmm1,%xmm5 + pxor %xmm4,%xmm12 + pxor %xmm5,%xmm13 + movdqa %xmm12,%xmm7 + pslld $7,%xmm12 + psrld $25,%xmm7 + movdqa %xmm13,%xmm6 + pslld $7,%xmm13 + por %xmm7,%xmm12 + psrld $25,%xmm6 + movdqa (%r10),%xmm7 + por %xmm6,%xmm13 + movdqa %xmm4,0(%rsp) + movdqa %xmm5,16(%rsp) + movdqa 32(%rsp),%xmm4 + movdqa 48(%rsp),%xmm5 + paddd %xmm14,%xmm10 + paddd %xmm15,%xmm11 + pxor %xmm10,%xmm2 + pxor %xmm11,%xmm3 +.byte 102,15,56,0,215 +.byte 102,15,56,0,223 + paddd %xmm2,%xmm4 + paddd %xmm3,%xmm5 + pxor %xmm4,%xmm14 + pxor %xmm5,%xmm15 + movdqa %xmm14,%xmm6 + pslld $12,%xmm14 + psrld $20,%xmm6 + movdqa %xmm15,%xmm7 + pslld $12,%xmm15 + por %xmm6,%xmm14 + psrld $20,%xmm7 + movdqa (%r11),%xmm6 + por %xmm7,%xmm15 + paddd %xmm14,%xmm10 + paddd %xmm15,%xmm11 + pxor %xmm10,%xmm2 + pxor %xmm11,%xmm3 +.byte 102,15,56,0,214 +.byte 102,15,56,0,222 + paddd %xmm2,%xmm4 + paddd %xmm3,%xmm5 + pxor %xmm4,%xmm14 + pxor %xmm5,%xmm15 + movdqa %xmm14,%xmm7 + pslld $7,%xmm14 + psrld $25,%xmm7 + movdqa %xmm15,%xmm6 + pslld $7,%xmm15 + por %xmm7,%xmm14 + psrld $25,%xmm6 + movdqa (%r10),%xmm7 + por %xmm6,%xmm15 + paddd %xmm13,%xmm8 + paddd %xmm14,%xmm9 + pxor %xmm8,%xmm3 + pxor %xmm9,%xmm0 +.byte 102,15,56,0,223 +.byte 102,15,56,0,199 + paddd %xmm3,%xmm4 + paddd %xmm0,%xmm5 + pxor %xmm4,%xmm13 + pxor %xmm5,%xmm14 + movdqa %xmm13,%xmm6 + pslld $12,%xmm13 + psrld $20,%xmm6 + movdqa %xmm14,%xmm7 + pslld $12,%xmm14 + por %xmm6,%xmm13 + psrld $20,%xmm7 + movdqa (%r11),%xmm6 + por %xmm7,%xmm14 + paddd %xmm13,%xmm8 + paddd %xmm14,%xmm9 + pxor %xmm8,%xmm3 + pxor %xmm9,%xmm0 +.byte 102,15,56,0,222 +.byte 102,15,56,0,198 + paddd %xmm3,%xmm4 + paddd %xmm0,%xmm5 + pxor %xmm4,%xmm13 + pxor %xmm5,%xmm14 + movdqa %xmm13,%xmm7 + pslld $7,%xmm13 + psrld $25,%xmm7 + movdqa %xmm14,%xmm6 + pslld $7,%xmm14 + por %xmm7,%xmm13 + psrld $25,%xmm6 + movdqa (%r10),%xmm7 + por %xmm6,%xmm14 + movdqa %xmm4,32(%rsp) + movdqa %xmm5,48(%rsp) + movdqa 0(%rsp),%xmm4 + movdqa 16(%rsp),%xmm5 + paddd %xmm15,%xmm10 + paddd %xmm12,%xmm11 + pxor %xmm10,%xmm1 + pxor %xmm11,%xmm2 +.byte 102,15,56,0,207 +.byte 102,15,56,0,215 + paddd %xmm1,%xmm4 + paddd %xmm2,%xmm5 + pxor %xmm4,%xmm15 + pxor %xmm5,%xmm12 + movdqa %xmm15,%xmm6 + pslld $12,%xmm15 + psrld $20,%xmm6 + movdqa %xmm12,%xmm7 + pslld $12,%xmm12 + por %xmm6,%xmm15 + psrld $20,%xmm7 + movdqa (%r11),%xmm6 + por %xmm7,%xmm12 + paddd %xmm15,%xmm10 + paddd %xmm12,%xmm11 + pxor %xmm10,%xmm1 + pxor %xmm11,%xmm2 +.byte 102,15,56,0,206 +.byte 102,15,56,0,214 + paddd %xmm1,%xmm4 + paddd %xmm2,%xmm5 + pxor %xmm4,%xmm15 + pxor %xmm5,%xmm12 + movdqa %xmm15,%xmm7 + pslld $7,%xmm15 + psrld $25,%xmm7 + movdqa %xmm12,%xmm6 + pslld $7,%xmm12 + por %xmm7,%xmm15 + psrld $25,%xmm6 + movdqa (%r10),%xmm7 + por %xmm6,%xmm12 + decl %eax + jnz L$oop4x + + paddd 64(%rsp),%xmm8 + paddd 80(%rsp),%xmm9 + paddd 96(%rsp),%xmm10 + paddd 112(%rsp),%xmm11 + + movdqa %xmm8,%xmm6 + punpckldq %xmm9,%xmm8 + movdqa %xmm10,%xmm7 + punpckldq %xmm11,%xmm10 + punpckhdq %xmm9,%xmm6 + punpckhdq %xmm11,%xmm7 + movdqa %xmm8,%xmm9 + punpcklqdq %xmm10,%xmm8 + movdqa %xmm6,%xmm11 + punpcklqdq %xmm7,%xmm6 + punpckhqdq %xmm10,%xmm9 + punpckhqdq %xmm7,%xmm11 + paddd 128-256(%rcx),%xmm12 + paddd 144-256(%rcx),%xmm13 + paddd 160-256(%rcx),%xmm14 + paddd 176-256(%rcx),%xmm15 + + movdqa %xmm8,0(%rsp) + movdqa %xmm9,16(%rsp) + movdqa 32(%rsp),%xmm8 + movdqa 48(%rsp),%xmm9 + + movdqa %xmm12,%xmm10 + punpckldq %xmm13,%xmm12 + movdqa %xmm14,%xmm7 + punpckldq %xmm15,%xmm14 + punpckhdq %xmm13,%xmm10 + punpckhdq %xmm15,%xmm7 + movdqa %xmm12,%xmm13 + punpcklqdq %xmm14,%xmm12 + movdqa %xmm10,%xmm15 + punpcklqdq %xmm7,%xmm10 + punpckhqdq %xmm14,%xmm13 + punpckhqdq %xmm7,%xmm15 + paddd 192-256(%rcx),%xmm4 + paddd 208-256(%rcx),%xmm5 + paddd 224-256(%rcx),%xmm8 + paddd 240-256(%rcx),%xmm9 + + movdqa %xmm6,32(%rsp) + movdqa %xmm11,48(%rsp) + + movdqa %xmm4,%xmm14 + punpckldq %xmm5,%xmm4 + movdqa %xmm8,%xmm7 + punpckldq %xmm9,%xmm8 + punpckhdq %xmm5,%xmm14 + punpckhdq %xmm9,%xmm7 + movdqa %xmm4,%xmm5 + punpcklqdq %xmm8,%xmm4 + movdqa %xmm14,%xmm9 + punpcklqdq %xmm7,%xmm14 + punpckhqdq %xmm8,%xmm5 + punpckhqdq %xmm7,%xmm9 + paddd 256-256(%rcx),%xmm0 + paddd 272-256(%rcx),%xmm1 + paddd 288-256(%rcx),%xmm2 + paddd 304-256(%rcx),%xmm3 + + movdqa %xmm0,%xmm8 + punpckldq %xmm1,%xmm0 + movdqa %xmm2,%xmm7 + punpckldq %xmm3,%xmm2 + punpckhdq %xmm1,%xmm8 + punpckhdq %xmm3,%xmm7 + movdqa %xmm0,%xmm1 + punpcklqdq %xmm2,%xmm0 + movdqa %xmm8,%xmm3 + punpcklqdq %xmm7,%xmm8 + punpckhqdq %xmm2,%xmm1 + punpckhqdq %xmm7,%xmm3 + cmpq $256,%rdx + jb L$tail4x + + movdqu 0(%rsi),%xmm6 + movdqu 16(%rsi),%xmm11 + movdqu 32(%rsi),%xmm2 + movdqu 48(%rsi),%xmm7 + pxor 0(%rsp),%xmm6 + pxor %xmm12,%xmm11 + pxor %xmm4,%xmm2 + pxor %xmm0,%xmm7 + + movdqu %xmm6,0(%rdi) + movdqu 64(%rsi),%xmm6 + movdqu %xmm11,16(%rdi) + movdqu 80(%rsi),%xmm11 + movdqu %xmm2,32(%rdi) + movdqu 96(%rsi),%xmm2 + movdqu %xmm7,48(%rdi) + movdqu 112(%rsi),%xmm7 + leaq 128(%rsi),%rsi + pxor 16(%rsp),%xmm6 + pxor %xmm13,%xmm11 + pxor %xmm5,%xmm2 + pxor %xmm1,%xmm7 + + movdqu %xmm6,64(%rdi) + movdqu 0(%rsi),%xmm6 + movdqu %xmm11,80(%rdi) + movdqu 16(%rsi),%xmm11 + movdqu %xmm2,96(%rdi) + movdqu 32(%rsi),%xmm2 + movdqu %xmm7,112(%rdi) + leaq 128(%rdi),%rdi + movdqu 48(%rsi),%xmm7 + pxor 32(%rsp),%xmm6 + pxor %xmm10,%xmm11 + pxor %xmm14,%xmm2 + pxor %xmm8,%xmm7 + + movdqu %xmm6,0(%rdi) + movdqu 64(%rsi),%xmm6 + movdqu %xmm11,16(%rdi) + movdqu 80(%rsi),%xmm11 + movdqu %xmm2,32(%rdi) + movdqu 96(%rsi),%xmm2 + movdqu %xmm7,48(%rdi) + movdqu 112(%rsi),%xmm7 + leaq 128(%rsi),%rsi + pxor 48(%rsp),%xmm6 + pxor %xmm15,%xmm11 + pxor %xmm9,%xmm2 + pxor %xmm3,%xmm7 + movdqu %xmm6,64(%rdi) + movdqu %xmm11,80(%rdi) + movdqu %xmm2,96(%rdi) + movdqu %xmm7,112(%rdi) + leaq 128(%rdi),%rdi + + subq $256,%rdx + jnz L$oop_outer4x + + jmp L$done4x + +L$tail4x: + cmpq $192,%rdx + jae L$192_or_more4x + cmpq $128,%rdx + jae L$128_or_more4x + cmpq $64,%rdx + jae L$64_or_more4x + + + xorq %r10,%r10 + + movdqa %xmm12,16(%rsp) + movdqa %xmm4,32(%rsp) + movdqa %xmm0,48(%rsp) + jmp L$oop_tail4x + +.p2align 5 +L$64_or_more4x: + movdqu 0(%rsi),%xmm6 + movdqu 16(%rsi),%xmm11 + movdqu 32(%rsi),%xmm2 + movdqu 48(%rsi),%xmm7 + pxor 0(%rsp),%xmm6 + pxor %xmm12,%xmm11 + pxor %xmm4,%xmm2 + pxor %xmm0,%xmm7 + movdqu %xmm6,0(%rdi) + movdqu %xmm11,16(%rdi) + movdqu %xmm2,32(%rdi) + movdqu %xmm7,48(%rdi) + je L$done4x + + movdqa 16(%rsp),%xmm6 + leaq 64(%rsi),%rsi + xorq %r10,%r10 + movdqa %xmm6,0(%rsp) + movdqa %xmm13,16(%rsp) + leaq 64(%rdi),%rdi + movdqa %xmm5,32(%rsp) + subq $64,%rdx + movdqa %xmm1,48(%rsp) + jmp L$oop_tail4x + +.p2align 5 +L$128_or_more4x: + movdqu 0(%rsi),%xmm6 + movdqu 16(%rsi),%xmm11 + movdqu 32(%rsi),%xmm2 + movdqu 48(%rsi),%xmm7 + pxor 0(%rsp),%xmm6 + pxor %xmm12,%xmm11 + pxor %xmm4,%xmm2 + pxor %xmm0,%xmm7 + + movdqu %xmm6,0(%rdi) + movdqu 64(%rsi),%xmm6 + movdqu %xmm11,16(%rdi) + movdqu 80(%rsi),%xmm11 + movdqu %xmm2,32(%rdi) + movdqu 96(%rsi),%xmm2 + movdqu %xmm7,48(%rdi) + movdqu 112(%rsi),%xmm7 + pxor 16(%rsp),%xmm6 + pxor %xmm13,%xmm11 + pxor %xmm5,%xmm2 + pxor %xmm1,%xmm7 + movdqu %xmm6,64(%rdi) + movdqu %xmm11,80(%rdi) + movdqu %xmm2,96(%rdi) + movdqu %xmm7,112(%rdi) + je L$done4x + + movdqa 32(%rsp),%xmm6 + leaq 128(%rsi),%rsi + xorq %r10,%r10 + movdqa %xmm6,0(%rsp) + movdqa %xmm10,16(%rsp) + leaq 128(%rdi),%rdi + movdqa %xmm14,32(%rsp) + subq $128,%rdx + movdqa %xmm8,48(%rsp) + jmp L$oop_tail4x + +.p2align 5 +L$192_or_more4x: + movdqu 0(%rsi),%xmm6 + movdqu 16(%rsi),%xmm11 + movdqu 32(%rsi),%xmm2 + movdqu 48(%rsi),%xmm7 + pxor 0(%rsp),%xmm6 + pxor %xmm12,%xmm11 + pxor %xmm4,%xmm2 + pxor %xmm0,%xmm7 + + movdqu %xmm6,0(%rdi) + movdqu 64(%rsi),%xmm6 + movdqu %xmm11,16(%rdi) + movdqu 80(%rsi),%xmm11 + movdqu %xmm2,32(%rdi) + movdqu 96(%rsi),%xmm2 + movdqu %xmm7,48(%rdi) + movdqu 112(%rsi),%xmm7 + leaq 128(%rsi),%rsi + pxor 16(%rsp),%xmm6 + pxor %xmm13,%xmm11 + pxor %xmm5,%xmm2 + pxor %xmm1,%xmm7 + + movdqu %xmm6,64(%rdi) + movdqu 0(%rsi),%xmm6 + movdqu %xmm11,80(%rdi) + movdqu 16(%rsi),%xmm11 + movdqu %xmm2,96(%rdi) + movdqu 32(%rsi),%xmm2 + movdqu %xmm7,112(%rdi) + leaq 128(%rdi),%rdi + movdqu 48(%rsi),%xmm7 + pxor 32(%rsp),%xmm6 + pxor %xmm10,%xmm11 + pxor %xmm14,%xmm2 + pxor %xmm8,%xmm7 + movdqu %xmm6,0(%rdi) + movdqu %xmm11,16(%rdi) + movdqu %xmm2,32(%rdi) + movdqu %xmm7,48(%rdi) + je L$done4x + + movdqa 48(%rsp),%xmm6 + leaq 64(%rsi),%rsi + xorq %r10,%r10 + movdqa %xmm6,0(%rsp) + movdqa %xmm15,16(%rsp) + leaq 64(%rdi),%rdi + movdqa %xmm9,32(%rsp) + subq $192,%rdx + movdqa %xmm3,48(%rsp) + +L$oop_tail4x: + movzbl (%rsi,%r10,1),%eax + movzbl (%rsp,%r10,1),%ecx + leaq 1(%r10),%r10 + xorl %ecx,%eax + movb %al,-1(%rdi,%r10,1) + decq %rdx + jnz L$oop_tail4x + +L$done4x: + leaq (%r9),%rsp + +L$4x_epilogue: + ret + + +.globl _ChaCha20_ctr32_avx2 +.private_extern _ChaCha20_ctr32_avx2 + +.p2align 5 +_ChaCha20_ctr32_avx2: + +_CET_ENDBR + movq %rsp,%r9 + + subq $0x280+8,%rsp + andq $-32,%rsp + vzeroupper + + + + + + + + + + + vbroadcasti128 L$sigma(%rip),%ymm11 + vbroadcasti128 (%rcx),%ymm3 + vbroadcasti128 16(%rcx),%ymm15 + vbroadcasti128 (%r8),%ymm7 + leaq 256(%rsp),%rcx + leaq 512(%rsp),%rax + leaq L$rot16(%rip),%r10 + leaq L$rot24(%rip),%r11 + + vpshufd $0x00,%ymm11,%ymm8 + vpshufd $0x55,%ymm11,%ymm9 + vmovdqa %ymm8,128-256(%rcx) + vpshufd $0xaa,%ymm11,%ymm10 + vmovdqa %ymm9,160-256(%rcx) + vpshufd $0xff,%ymm11,%ymm11 + vmovdqa %ymm10,192-256(%rcx) + vmovdqa %ymm11,224-256(%rcx) + + vpshufd $0x00,%ymm3,%ymm0 + vpshufd $0x55,%ymm3,%ymm1 + vmovdqa %ymm0,256-256(%rcx) + vpshufd $0xaa,%ymm3,%ymm2 + vmovdqa %ymm1,288-256(%rcx) + vpshufd $0xff,%ymm3,%ymm3 + vmovdqa %ymm2,320-256(%rcx) + vmovdqa %ymm3,352-256(%rcx) + + vpshufd $0x00,%ymm15,%ymm12 + vpshufd $0x55,%ymm15,%ymm13 + vmovdqa %ymm12,384-512(%rax) + vpshufd $0xaa,%ymm15,%ymm14 + vmovdqa %ymm13,416-512(%rax) + vpshufd $0xff,%ymm15,%ymm15 + vmovdqa %ymm14,448-512(%rax) + vmovdqa %ymm15,480-512(%rax) + + vpshufd $0x00,%ymm7,%ymm4 + vpshufd $0x55,%ymm7,%ymm5 + vpaddd L$incy(%rip),%ymm4,%ymm4 + vpshufd $0xaa,%ymm7,%ymm6 + vmovdqa %ymm5,544-512(%rax) + vpshufd $0xff,%ymm7,%ymm7 + vmovdqa %ymm6,576-512(%rax) + vmovdqa %ymm7,608-512(%rax) + + jmp L$oop_enter8x + +.p2align 5 +L$oop_outer8x: + vmovdqa 128-256(%rcx),%ymm8 + vmovdqa 160-256(%rcx),%ymm9 + vmovdqa 192-256(%rcx),%ymm10 + vmovdqa 224-256(%rcx),%ymm11 + vmovdqa 256-256(%rcx),%ymm0 + vmovdqa 288-256(%rcx),%ymm1 + vmovdqa 320-256(%rcx),%ymm2 + vmovdqa 352-256(%rcx),%ymm3 + vmovdqa 384-512(%rax),%ymm12 + vmovdqa 416-512(%rax),%ymm13 + vmovdqa 448-512(%rax),%ymm14 + vmovdqa 480-512(%rax),%ymm15 + vmovdqa 512-512(%rax),%ymm4 + vmovdqa 544-512(%rax),%ymm5 + vmovdqa 576-512(%rax),%ymm6 + vmovdqa 608-512(%rax),%ymm7 + vpaddd L$eight(%rip),%ymm4,%ymm4 + +L$oop_enter8x: + vmovdqa %ymm14,64(%rsp) + vmovdqa %ymm15,96(%rsp) + vbroadcasti128 (%r10),%ymm15 + vmovdqa %ymm4,512-512(%rax) + movl $10,%eax + jmp L$oop8x + +.p2align 5 +L$oop8x: + vpaddd %ymm0,%ymm8,%ymm8 + vpxor %ymm4,%ymm8,%ymm4 + vpshufb %ymm15,%ymm4,%ymm4 + vpaddd %ymm1,%ymm9,%ymm9 + vpxor %ymm5,%ymm9,%ymm5 + vpshufb %ymm15,%ymm5,%ymm5 + vpaddd %ymm4,%ymm12,%ymm12 + vpxor %ymm0,%ymm12,%ymm0 + vpslld $12,%ymm0,%ymm14 + vpsrld $20,%ymm0,%ymm0 + vpor %ymm0,%ymm14,%ymm0 + vbroadcasti128 (%r11),%ymm14 + vpaddd %ymm5,%ymm13,%ymm13 + vpxor %ymm1,%ymm13,%ymm1 + vpslld $12,%ymm1,%ymm15 + vpsrld $20,%ymm1,%ymm1 + vpor %ymm1,%ymm15,%ymm1 + vpaddd %ymm0,%ymm8,%ymm8 + vpxor %ymm4,%ymm8,%ymm4 + vpshufb %ymm14,%ymm4,%ymm4 + vpaddd %ymm1,%ymm9,%ymm9 + vpxor %ymm5,%ymm9,%ymm5 + vpshufb %ymm14,%ymm5,%ymm5 + vpaddd %ymm4,%ymm12,%ymm12 + vpxor %ymm0,%ymm12,%ymm0 + vpslld $7,%ymm0,%ymm15 + vpsrld $25,%ymm0,%ymm0 + vpor %ymm0,%ymm15,%ymm0 + vbroadcasti128 (%r10),%ymm15 + vpaddd %ymm5,%ymm13,%ymm13 + vpxor %ymm1,%ymm13,%ymm1 + vpslld $7,%ymm1,%ymm14 + vpsrld $25,%ymm1,%ymm1 + vpor %ymm1,%ymm14,%ymm1 + vmovdqa %ymm12,0(%rsp) + vmovdqa %ymm13,32(%rsp) + vmovdqa 64(%rsp),%ymm12 + vmovdqa 96(%rsp),%ymm13 + vpaddd %ymm2,%ymm10,%ymm10 + vpxor %ymm6,%ymm10,%ymm6 + vpshufb %ymm15,%ymm6,%ymm6 + vpaddd %ymm3,%ymm11,%ymm11 + vpxor %ymm7,%ymm11,%ymm7 + vpshufb %ymm15,%ymm7,%ymm7 + vpaddd %ymm6,%ymm12,%ymm12 + vpxor %ymm2,%ymm12,%ymm2 + vpslld $12,%ymm2,%ymm14 + vpsrld $20,%ymm2,%ymm2 + vpor %ymm2,%ymm14,%ymm2 + vbroadcasti128 (%r11),%ymm14 + vpaddd %ymm7,%ymm13,%ymm13 + vpxor %ymm3,%ymm13,%ymm3 + vpslld $12,%ymm3,%ymm15 + vpsrld $20,%ymm3,%ymm3 + vpor %ymm3,%ymm15,%ymm3 + vpaddd %ymm2,%ymm10,%ymm10 + vpxor %ymm6,%ymm10,%ymm6 + vpshufb %ymm14,%ymm6,%ymm6 + vpaddd %ymm3,%ymm11,%ymm11 + vpxor %ymm7,%ymm11,%ymm7 + vpshufb %ymm14,%ymm7,%ymm7 + vpaddd %ymm6,%ymm12,%ymm12 + vpxor %ymm2,%ymm12,%ymm2 + vpslld $7,%ymm2,%ymm15 + vpsrld $25,%ymm2,%ymm2 + vpor %ymm2,%ymm15,%ymm2 + vbroadcasti128 (%r10),%ymm15 + vpaddd %ymm7,%ymm13,%ymm13 + vpxor %ymm3,%ymm13,%ymm3 + vpslld $7,%ymm3,%ymm14 + vpsrld $25,%ymm3,%ymm3 + vpor %ymm3,%ymm14,%ymm3 + vpaddd %ymm1,%ymm8,%ymm8 + vpxor %ymm7,%ymm8,%ymm7 + vpshufb %ymm15,%ymm7,%ymm7 + vpaddd %ymm2,%ymm9,%ymm9 + vpxor %ymm4,%ymm9,%ymm4 + vpshufb %ymm15,%ymm4,%ymm4 + vpaddd %ymm7,%ymm12,%ymm12 + vpxor %ymm1,%ymm12,%ymm1 + vpslld $12,%ymm1,%ymm14 + vpsrld $20,%ymm1,%ymm1 + vpor %ymm1,%ymm14,%ymm1 + vbroadcasti128 (%r11),%ymm14 + vpaddd %ymm4,%ymm13,%ymm13 + vpxor %ymm2,%ymm13,%ymm2 + vpslld $12,%ymm2,%ymm15 + vpsrld $20,%ymm2,%ymm2 + vpor %ymm2,%ymm15,%ymm2 + vpaddd %ymm1,%ymm8,%ymm8 + vpxor %ymm7,%ymm8,%ymm7 + vpshufb %ymm14,%ymm7,%ymm7 + vpaddd %ymm2,%ymm9,%ymm9 + vpxor %ymm4,%ymm9,%ymm4 + vpshufb %ymm14,%ymm4,%ymm4 + vpaddd %ymm7,%ymm12,%ymm12 + vpxor %ymm1,%ymm12,%ymm1 + vpslld $7,%ymm1,%ymm15 + vpsrld $25,%ymm1,%ymm1 + vpor %ymm1,%ymm15,%ymm1 + vbroadcasti128 (%r10),%ymm15 + vpaddd %ymm4,%ymm13,%ymm13 + vpxor %ymm2,%ymm13,%ymm2 + vpslld $7,%ymm2,%ymm14 + vpsrld $25,%ymm2,%ymm2 + vpor %ymm2,%ymm14,%ymm2 + vmovdqa %ymm12,64(%rsp) + vmovdqa %ymm13,96(%rsp) + vmovdqa 0(%rsp),%ymm12 + vmovdqa 32(%rsp),%ymm13 + vpaddd %ymm3,%ymm10,%ymm10 + vpxor %ymm5,%ymm10,%ymm5 + vpshufb %ymm15,%ymm5,%ymm5 + vpaddd %ymm0,%ymm11,%ymm11 + vpxor %ymm6,%ymm11,%ymm6 + vpshufb %ymm15,%ymm6,%ymm6 + vpaddd %ymm5,%ymm12,%ymm12 + vpxor %ymm3,%ymm12,%ymm3 + vpslld $12,%ymm3,%ymm14 + vpsrld $20,%ymm3,%ymm3 + vpor %ymm3,%ymm14,%ymm3 + vbroadcasti128 (%r11),%ymm14 + vpaddd %ymm6,%ymm13,%ymm13 + vpxor %ymm0,%ymm13,%ymm0 + vpslld $12,%ymm0,%ymm15 + vpsrld $20,%ymm0,%ymm0 + vpor %ymm0,%ymm15,%ymm0 + vpaddd %ymm3,%ymm10,%ymm10 + vpxor %ymm5,%ymm10,%ymm5 + vpshufb %ymm14,%ymm5,%ymm5 + vpaddd %ymm0,%ymm11,%ymm11 + vpxor %ymm6,%ymm11,%ymm6 + vpshufb %ymm14,%ymm6,%ymm6 + vpaddd %ymm5,%ymm12,%ymm12 + vpxor %ymm3,%ymm12,%ymm3 + vpslld $7,%ymm3,%ymm15 + vpsrld $25,%ymm3,%ymm3 + vpor %ymm3,%ymm15,%ymm3 + vbroadcasti128 (%r10),%ymm15 + vpaddd %ymm6,%ymm13,%ymm13 + vpxor %ymm0,%ymm13,%ymm0 + vpslld $7,%ymm0,%ymm14 + vpsrld $25,%ymm0,%ymm0 + vpor %ymm0,%ymm14,%ymm0 + decl %eax + jnz L$oop8x + + leaq 512(%rsp),%rax + vpaddd 128-256(%rcx),%ymm8,%ymm8 + vpaddd 160-256(%rcx),%ymm9,%ymm9 + vpaddd 192-256(%rcx),%ymm10,%ymm10 + vpaddd 224-256(%rcx),%ymm11,%ymm11 + + vpunpckldq %ymm9,%ymm8,%ymm14 + vpunpckldq %ymm11,%ymm10,%ymm15 + vpunpckhdq %ymm9,%ymm8,%ymm8 + vpunpckhdq %ymm11,%ymm10,%ymm10 + vpunpcklqdq %ymm15,%ymm14,%ymm9 + vpunpckhqdq %ymm15,%ymm14,%ymm14 + vpunpcklqdq %ymm10,%ymm8,%ymm11 + vpunpckhqdq %ymm10,%ymm8,%ymm8 + vpaddd 256-256(%rcx),%ymm0,%ymm0 + vpaddd 288-256(%rcx),%ymm1,%ymm1 + vpaddd 320-256(%rcx),%ymm2,%ymm2 + vpaddd 352-256(%rcx),%ymm3,%ymm3 + + vpunpckldq %ymm1,%ymm0,%ymm10 + vpunpckldq %ymm3,%ymm2,%ymm15 + vpunpckhdq %ymm1,%ymm0,%ymm0 + vpunpckhdq %ymm3,%ymm2,%ymm2 + vpunpcklqdq %ymm15,%ymm10,%ymm1 + vpunpckhqdq %ymm15,%ymm10,%ymm10 + vpunpcklqdq %ymm2,%ymm0,%ymm3 + vpunpckhqdq %ymm2,%ymm0,%ymm0 + vperm2i128 $0x20,%ymm1,%ymm9,%ymm15 + vperm2i128 $0x31,%ymm1,%ymm9,%ymm1 + vperm2i128 $0x20,%ymm10,%ymm14,%ymm9 + vperm2i128 $0x31,%ymm10,%ymm14,%ymm10 + vperm2i128 $0x20,%ymm3,%ymm11,%ymm14 + vperm2i128 $0x31,%ymm3,%ymm11,%ymm3 + vperm2i128 $0x20,%ymm0,%ymm8,%ymm11 + vperm2i128 $0x31,%ymm0,%ymm8,%ymm0 + vmovdqa %ymm15,0(%rsp) + vmovdqa %ymm9,32(%rsp) + vmovdqa 64(%rsp),%ymm15 + vmovdqa 96(%rsp),%ymm9 + + vpaddd 384-512(%rax),%ymm12,%ymm12 + vpaddd 416-512(%rax),%ymm13,%ymm13 + vpaddd 448-512(%rax),%ymm15,%ymm15 + vpaddd 480-512(%rax),%ymm9,%ymm9 + + vpunpckldq %ymm13,%ymm12,%ymm2 + vpunpckldq %ymm9,%ymm15,%ymm8 + vpunpckhdq %ymm13,%ymm12,%ymm12 + vpunpckhdq %ymm9,%ymm15,%ymm15 + vpunpcklqdq %ymm8,%ymm2,%ymm13 + vpunpckhqdq %ymm8,%ymm2,%ymm2 + vpunpcklqdq %ymm15,%ymm12,%ymm9 + vpunpckhqdq %ymm15,%ymm12,%ymm12 + vpaddd 512-512(%rax),%ymm4,%ymm4 + vpaddd 544-512(%rax),%ymm5,%ymm5 + vpaddd 576-512(%rax),%ymm6,%ymm6 + vpaddd 608-512(%rax),%ymm7,%ymm7 + + vpunpckldq %ymm5,%ymm4,%ymm15 + vpunpckldq %ymm7,%ymm6,%ymm8 + vpunpckhdq %ymm5,%ymm4,%ymm4 + vpunpckhdq %ymm7,%ymm6,%ymm6 + vpunpcklqdq %ymm8,%ymm15,%ymm5 + vpunpckhqdq %ymm8,%ymm15,%ymm15 + vpunpcklqdq %ymm6,%ymm4,%ymm7 + vpunpckhqdq %ymm6,%ymm4,%ymm4 + vperm2i128 $0x20,%ymm5,%ymm13,%ymm8 + vperm2i128 $0x31,%ymm5,%ymm13,%ymm5 + vperm2i128 $0x20,%ymm15,%ymm2,%ymm13 + vperm2i128 $0x31,%ymm15,%ymm2,%ymm15 + vperm2i128 $0x20,%ymm7,%ymm9,%ymm2 + vperm2i128 $0x31,%ymm7,%ymm9,%ymm7 + vperm2i128 $0x20,%ymm4,%ymm12,%ymm9 + vperm2i128 $0x31,%ymm4,%ymm12,%ymm4 + vmovdqa 0(%rsp),%ymm6 + vmovdqa 32(%rsp),%ymm12 + + cmpq $512,%rdx + jb L$tail8x + + vpxor 0(%rsi),%ymm6,%ymm6 + vpxor 32(%rsi),%ymm8,%ymm8 + vpxor 64(%rsi),%ymm1,%ymm1 + vpxor 96(%rsi),%ymm5,%ymm5 + leaq 128(%rsi),%rsi + vmovdqu %ymm6,0(%rdi) + vmovdqu %ymm8,32(%rdi) + vmovdqu %ymm1,64(%rdi) + vmovdqu %ymm5,96(%rdi) + leaq 128(%rdi),%rdi + + vpxor 0(%rsi),%ymm12,%ymm12 + vpxor 32(%rsi),%ymm13,%ymm13 + vpxor 64(%rsi),%ymm10,%ymm10 + vpxor 96(%rsi),%ymm15,%ymm15 + leaq 128(%rsi),%rsi + vmovdqu %ymm12,0(%rdi) + vmovdqu %ymm13,32(%rdi) + vmovdqu %ymm10,64(%rdi) + vmovdqu %ymm15,96(%rdi) + leaq 128(%rdi),%rdi + + vpxor 0(%rsi),%ymm14,%ymm14 + vpxor 32(%rsi),%ymm2,%ymm2 + vpxor 64(%rsi),%ymm3,%ymm3 + vpxor 96(%rsi),%ymm7,%ymm7 + leaq 128(%rsi),%rsi + vmovdqu %ymm14,0(%rdi) + vmovdqu %ymm2,32(%rdi) + vmovdqu %ymm3,64(%rdi) + vmovdqu %ymm7,96(%rdi) + leaq 128(%rdi),%rdi + + vpxor 0(%rsi),%ymm11,%ymm11 + vpxor 32(%rsi),%ymm9,%ymm9 + vpxor 64(%rsi),%ymm0,%ymm0 + vpxor 96(%rsi),%ymm4,%ymm4 + leaq 128(%rsi),%rsi + vmovdqu %ymm11,0(%rdi) + vmovdqu %ymm9,32(%rdi) + vmovdqu %ymm0,64(%rdi) + vmovdqu %ymm4,96(%rdi) + leaq 128(%rdi),%rdi + + subq $512,%rdx + jnz L$oop_outer8x + + jmp L$done8x + +L$tail8x: + cmpq $448,%rdx + jae L$448_or_more8x + cmpq $384,%rdx + jae L$384_or_more8x + cmpq $320,%rdx + jae L$320_or_more8x + cmpq $256,%rdx + jae L$256_or_more8x + cmpq $192,%rdx + jae L$192_or_more8x + cmpq $128,%rdx + jae L$128_or_more8x + cmpq $64,%rdx + jae L$64_or_more8x + + xorq %r10,%r10 + vmovdqa %ymm6,0(%rsp) + vmovdqa %ymm8,32(%rsp) + jmp L$oop_tail8x + +.p2align 5 +L$64_or_more8x: + vpxor 0(%rsi),%ymm6,%ymm6 + vpxor 32(%rsi),%ymm8,%ymm8 + vmovdqu %ymm6,0(%rdi) + vmovdqu %ymm8,32(%rdi) + je L$done8x + + leaq 64(%rsi),%rsi + xorq %r10,%r10 + vmovdqa %ymm1,0(%rsp) + leaq 64(%rdi),%rdi + subq $64,%rdx + vmovdqa %ymm5,32(%rsp) + jmp L$oop_tail8x + +.p2align 5 +L$128_or_more8x: + vpxor 0(%rsi),%ymm6,%ymm6 + vpxor 32(%rsi),%ymm8,%ymm8 + vpxor 64(%rsi),%ymm1,%ymm1 + vpxor 96(%rsi),%ymm5,%ymm5 + vmovdqu %ymm6,0(%rdi) + vmovdqu %ymm8,32(%rdi) + vmovdqu %ymm1,64(%rdi) + vmovdqu %ymm5,96(%rdi) + je L$done8x + + leaq 128(%rsi),%rsi + xorq %r10,%r10 + vmovdqa %ymm12,0(%rsp) + leaq 128(%rdi),%rdi + subq $128,%rdx + vmovdqa %ymm13,32(%rsp) + jmp L$oop_tail8x + +.p2align 5 +L$192_or_more8x: + vpxor 0(%rsi),%ymm6,%ymm6 + vpxor 32(%rsi),%ymm8,%ymm8 + vpxor 64(%rsi),%ymm1,%ymm1 + vpxor 96(%rsi),%ymm5,%ymm5 + vpxor 128(%rsi),%ymm12,%ymm12 + vpxor 160(%rsi),%ymm13,%ymm13 + vmovdqu %ymm6,0(%rdi) + vmovdqu %ymm8,32(%rdi) + vmovdqu %ymm1,64(%rdi) + vmovdqu %ymm5,96(%rdi) + vmovdqu %ymm12,128(%rdi) + vmovdqu %ymm13,160(%rdi) + je L$done8x + + leaq 192(%rsi),%rsi + xorq %r10,%r10 + vmovdqa %ymm10,0(%rsp) + leaq 192(%rdi),%rdi + subq $192,%rdx + vmovdqa %ymm15,32(%rsp) + jmp L$oop_tail8x + +.p2align 5 +L$256_or_more8x: + vpxor 0(%rsi),%ymm6,%ymm6 + vpxor 32(%rsi),%ymm8,%ymm8 + vpxor 64(%rsi),%ymm1,%ymm1 + vpxor 96(%rsi),%ymm5,%ymm5 + vpxor 128(%rsi),%ymm12,%ymm12 + vpxor 160(%rsi),%ymm13,%ymm13 + vpxor 192(%rsi),%ymm10,%ymm10 + vpxor 224(%rsi),%ymm15,%ymm15 + vmovdqu %ymm6,0(%rdi) + vmovdqu %ymm8,32(%rdi) + vmovdqu %ymm1,64(%rdi) + vmovdqu %ymm5,96(%rdi) + vmovdqu %ymm12,128(%rdi) + vmovdqu %ymm13,160(%rdi) + vmovdqu %ymm10,192(%rdi) + vmovdqu %ymm15,224(%rdi) + je L$done8x + + leaq 256(%rsi),%rsi + xorq %r10,%r10 + vmovdqa %ymm14,0(%rsp) + leaq 256(%rdi),%rdi + subq $256,%rdx + vmovdqa %ymm2,32(%rsp) + jmp L$oop_tail8x + +.p2align 5 +L$320_or_more8x: + vpxor 0(%rsi),%ymm6,%ymm6 + vpxor 32(%rsi),%ymm8,%ymm8 + vpxor 64(%rsi),%ymm1,%ymm1 + vpxor 96(%rsi),%ymm5,%ymm5 + vpxor 128(%rsi),%ymm12,%ymm12 + vpxor 160(%rsi),%ymm13,%ymm13 + vpxor 192(%rsi),%ymm10,%ymm10 + vpxor 224(%rsi),%ymm15,%ymm15 + vpxor 256(%rsi),%ymm14,%ymm14 + vpxor 288(%rsi),%ymm2,%ymm2 + vmovdqu %ymm6,0(%rdi) + vmovdqu %ymm8,32(%rdi) + vmovdqu %ymm1,64(%rdi) + vmovdqu %ymm5,96(%rdi) + vmovdqu %ymm12,128(%rdi) + vmovdqu %ymm13,160(%rdi) + vmovdqu %ymm10,192(%rdi) + vmovdqu %ymm15,224(%rdi) + vmovdqu %ymm14,256(%rdi) + vmovdqu %ymm2,288(%rdi) + je L$done8x + + leaq 320(%rsi),%rsi + xorq %r10,%r10 + vmovdqa %ymm3,0(%rsp) + leaq 320(%rdi),%rdi + subq $320,%rdx + vmovdqa %ymm7,32(%rsp) + jmp L$oop_tail8x + +.p2align 5 +L$384_or_more8x: + vpxor 0(%rsi),%ymm6,%ymm6 + vpxor 32(%rsi),%ymm8,%ymm8 + vpxor 64(%rsi),%ymm1,%ymm1 + vpxor 96(%rsi),%ymm5,%ymm5 + vpxor 128(%rsi),%ymm12,%ymm12 + vpxor 160(%rsi),%ymm13,%ymm13 + vpxor 192(%rsi),%ymm10,%ymm10 + vpxor 224(%rsi),%ymm15,%ymm15 + vpxor 256(%rsi),%ymm14,%ymm14 + vpxor 288(%rsi),%ymm2,%ymm2 + vpxor 320(%rsi),%ymm3,%ymm3 + vpxor 352(%rsi),%ymm7,%ymm7 + vmovdqu %ymm6,0(%rdi) + vmovdqu %ymm8,32(%rdi) + vmovdqu %ymm1,64(%rdi) + vmovdqu %ymm5,96(%rdi) + vmovdqu %ymm12,128(%rdi) + vmovdqu %ymm13,160(%rdi) + vmovdqu %ymm10,192(%rdi) + vmovdqu %ymm15,224(%rdi) + vmovdqu %ymm14,256(%rdi) + vmovdqu %ymm2,288(%rdi) + vmovdqu %ymm3,320(%rdi) + vmovdqu %ymm7,352(%rdi) + je L$done8x + + leaq 384(%rsi),%rsi + xorq %r10,%r10 + vmovdqa %ymm11,0(%rsp) + leaq 384(%rdi),%rdi + subq $384,%rdx + vmovdqa %ymm9,32(%rsp) + jmp L$oop_tail8x + +.p2align 5 +L$448_or_more8x: + vpxor 0(%rsi),%ymm6,%ymm6 + vpxor 32(%rsi),%ymm8,%ymm8 + vpxor 64(%rsi),%ymm1,%ymm1 + vpxor 96(%rsi),%ymm5,%ymm5 + vpxor 128(%rsi),%ymm12,%ymm12 + vpxor 160(%rsi),%ymm13,%ymm13 + vpxor 192(%rsi),%ymm10,%ymm10 + vpxor 224(%rsi),%ymm15,%ymm15 + vpxor 256(%rsi),%ymm14,%ymm14 + vpxor 288(%rsi),%ymm2,%ymm2 + vpxor 320(%rsi),%ymm3,%ymm3 + vpxor 352(%rsi),%ymm7,%ymm7 + vpxor 384(%rsi),%ymm11,%ymm11 + vpxor 416(%rsi),%ymm9,%ymm9 + vmovdqu %ymm6,0(%rdi) + vmovdqu %ymm8,32(%rdi) + vmovdqu %ymm1,64(%rdi) + vmovdqu %ymm5,96(%rdi) + vmovdqu %ymm12,128(%rdi) + vmovdqu %ymm13,160(%rdi) + vmovdqu %ymm10,192(%rdi) + vmovdqu %ymm15,224(%rdi) + vmovdqu %ymm14,256(%rdi) + vmovdqu %ymm2,288(%rdi) + vmovdqu %ymm3,320(%rdi) + vmovdqu %ymm7,352(%rdi) + vmovdqu %ymm11,384(%rdi) + vmovdqu %ymm9,416(%rdi) + je L$done8x + + leaq 448(%rsi),%rsi + xorq %r10,%r10 + vmovdqa %ymm0,0(%rsp) + leaq 448(%rdi),%rdi + subq $448,%rdx + vmovdqa %ymm4,32(%rsp) + +L$oop_tail8x: + movzbl (%rsi,%r10,1),%eax + movzbl (%rsp,%r10,1),%ecx + leaq 1(%r10),%r10 + xorl %ecx,%eax + movb %al,-1(%rdi,%r10,1) + decq %rdx + jnz L$oop_tail8x + +L$done8x: + vzeroall + leaq (%r9),%rsp + +L$8x_epilogue: + ret + + +#endif diff --git a/http/vendor/ring/pregenerated/chacha-x86_64-nasm.asm b/http/vendor/ring/pregenerated/chacha-x86_64-nasm.asm new file mode 100644 index 0000000..3a08c95 --- /dev/null +++ b/http/vendor/ring/pregenerated/chacha-x86_64-nasm.asm @@ -0,0 +1,1752 @@ +; This file is generated from a similarly-named Perl script in the BoringSSL +; source tree. Do not edit by hand. + +%ifidn __OUTPUT_FORMAT__, win64 +default rel +%define XMMWORD +%define YMMWORD +%define ZMMWORD +%define _CET_ENDBR + +%include "ring_core_generated/prefix_symbols_nasm.inc" +section .text code align=64 + + +section .rdata rdata align=8 +ALIGN 64 +$L$zero: + DD 0,0,0,0 +$L$one: + DD 1,0,0,0 +$L$inc: + DD 0,1,2,3 +$L$four: + DD 4,4,4,4 +$L$incy: + DD 0,2,4,6,1,3,5,7 +$L$eight: + DD 8,8,8,8,8,8,8,8 +$L$rot16: + DB 0x2,0x3,0x0,0x1,0x6,0x7,0x4,0x5,0xa,0xb,0x8,0x9,0xe,0xf,0xc,0xd +$L$rot24: + DB 0x3,0x0,0x1,0x2,0x7,0x4,0x5,0x6,0xb,0x8,0x9,0xa,0xf,0xc,0xd,0xe +$L$sigma: + DB 101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107 + DB 0 +ALIGN 64 +$L$zeroz: + DD 0,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0 +$L$fourz: + DD 4,0,0,0,4,0,0,0,4,0,0,0,4,0,0,0 +$L$incz: + DD 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 +$L$sixteen: + DD 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16 + DB 67,104,97,67,104,97,50,48,32,102,111,114,32,120,56,54 + DB 95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32 + DB 98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115 + DB 108,46,111,114,103,62,0 +section .text + +global ChaCha20_ctr32_nohw + +ALIGN 64 +ChaCha20_ctr32_nohw: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_ChaCha20_ctr32_nohw: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + mov rcx,r9 + mov r8,QWORD[40+rsp] + + + +_CET_ENDBR + push rbx + + push rbp + + push r12 + + push r13 + + push r14 + + push r15 + + sub rsp,64+24 + +$L$ctr32_body: + + + movdqu xmm1,XMMWORD[rcx] + movdqu xmm2,XMMWORD[16+rcx] + movdqu xmm3,XMMWORD[r8] + movdqa xmm4,XMMWORD[$L$one] + + + movdqa XMMWORD[16+rsp],xmm1 + movdqa XMMWORD[32+rsp],xmm2 + movdqa XMMWORD[48+rsp],xmm3 + mov rbp,rdx + jmp NEAR $L$oop_outer + +ALIGN 32 +$L$oop_outer: + mov eax,0x61707865 + mov ebx,0x3320646e + mov ecx,0x79622d32 + mov edx,0x6b206574 + mov r8d,DWORD[16+rsp] + mov r9d,DWORD[20+rsp] + mov r10d,DWORD[24+rsp] + mov r11d,DWORD[28+rsp] + movd r12d,xmm3 + mov r13d,DWORD[52+rsp] + mov r14d,DWORD[56+rsp] + mov r15d,DWORD[60+rsp] + + mov QWORD[((64+0))+rsp],rbp + mov ebp,10 + mov QWORD[((64+8))+rsp],rsi +DB 102,72,15,126,214 + mov QWORD[((64+16))+rsp],rdi + mov rdi,rsi + shr rdi,32 + jmp NEAR $L$oop + +ALIGN 32 +$L$oop: + add eax,r8d + xor r12d,eax + rol r12d,16 + add ebx,r9d + xor r13d,ebx + rol r13d,16 + add esi,r12d + xor r8d,esi + rol r8d,12 + add edi,r13d + xor r9d,edi + rol r9d,12 + add eax,r8d + xor r12d,eax + rol r12d,8 + add ebx,r9d + xor r13d,ebx + rol r13d,8 + add esi,r12d + xor r8d,esi + rol r8d,7 + add edi,r13d + xor r9d,edi + rol r9d,7 + mov DWORD[32+rsp],esi + mov DWORD[36+rsp],edi + mov esi,DWORD[40+rsp] + mov edi,DWORD[44+rsp] + add ecx,r10d + xor r14d,ecx + rol r14d,16 + add edx,r11d + xor r15d,edx + rol r15d,16 + add esi,r14d + xor r10d,esi + rol r10d,12 + add edi,r15d + xor r11d,edi + rol r11d,12 + add ecx,r10d + xor r14d,ecx + rol r14d,8 + add edx,r11d + xor r15d,edx + rol r15d,8 + add esi,r14d + xor r10d,esi + rol r10d,7 + add edi,r15d + xor r11d,edi + rol r11d,7 + add eax,r9d + xor r15d,eax + rol r15d,16 + add ebx,r10d + xor r12d,ebx + rol r12d,16 + add esi,r15d + xor r9d,esi + rol r9d,12 + add edi,r12d + xor r10d,edi + rol r10d,12 + add eax,r9d + xor r15d,eax + rol r15d,8 + add ebx,r10d + xor r12d,ebx + rol r12d,8 + add esi,r15d + xor r9d,esi + rol r9d,7 + add edi,r12d + xor r10d,edi + rol r10d,7 + mov DWORD[40+rsp],esi + mov DWORD[44+rsp],edi + mov esi,DWORD[32+rsp] + mov edi,DWORD[36+rsp] + add ecx,r11d + xor r13d,ecx + rol r13d,16 + add edx,r8d + xor r14d,edx + rol r14d,16 + add esi,r13d + xor r11d,esi + rol r11d,12 + add edi,r14d + xor r8d,edi + rol r8d,12 + add ecx,r11d + xor r13d,ecx + rol r13d,8 + add edx,r8d + xor r14d,edx + rol r14d,8 + add esi,r13d + xor r11d,esi + rol r11d,7 + add edi,r14d + xor r8d,edi + rol r8d,7 + dec ebp + jnz NEAR $L$oop + mov DWORD[36+rsp],edi + mov DWORD[32+rsp],esi + mov rbp,QWORD[64+rsp] + movdqa xmm1,xmm2 + mov rsi,QWORD[((64+8))+rsp] + paddd xmm3,xmm4 + mov rdi,QWORD[((64+16))+rsp] + + add eax,0x61707865 + add ebx,0x3320646e + add ecx,0x79622d32 + add edx,0x6b206574 + add r8d,DWORD[16+rsp] + add r9d,DWORD[20+rsp] + add r10d,DWORD[24+rsp] + add r11d,DWORD[28+rsp] + add r12d,DWORD[48+rsp] + add r13d,DWORD[52+rsp] + add r14d,DWORD[56+rsp] + add r15d,DWORD[60+rsp] + paddd xmm1,XMMWORD[32+rsp] + + cmp rbp,64 + jb NEAR $L$tail + + xor eax,DWORD[rsi] + xor ebx,DWORD[4+rsi] + xor ecx,DWORD[8+rsi] + xor edx,DWORD[12+rsi] + xor r8d,DWORD[16+rsi] + xor r9d,DWORD[20+rsi] + xor r10d,DWORD[24+rsi] + xor r11d,DWORD[28+rsi] + movdqu xmm0,XMMWORD[32+rsi] + xor r12d,DWORD[48+rsi] + xor r13d,DWORD[52+rsi] + xor r14d,DWORD[56+rsi] + xor r15d,DWORD[60+rsi] + lea rsi,[64+rsi] + pxor xmm0,xmm1 + + movdqa XMMWORD[32+rsp],xmm2 + movd DWORD[48+rsp],xmm3 + + mov DWORD[rdi],eax + mov DWORD[4+rdi],ebx + mov DWORD[8+rdi],ecx + mov DWORD[12+rdi],edx + mov DWORD[16+rdi],r8d + mov DWORD[20+rdi],r9d + mov DWORD[24+rdi],r10d + mov DWORD[28+rdi],r11d + movdqu XMMWORD[32+rdi],xmm0 + mov DWORD[48+rdi],r12d + mov DWORD[52+rdi],r13d + mov DWORD[56+rdi],r14d + mov DWORD[60+rdi],r15d + lea rdi,[64+rdi] + + sub rbp,64 + jnz NEAR $L$oop_outer + + jmp NEAR $L$done + +ALIGN 16 +$L$tail: + mov DWORD[rsp],eax + mov DWORD[4+rsp],ebx + xor rbx,rbx + mov DWORD[8+rsp],ecx + mov DWORD[12+rsp],edx + mov DWORD[16+rsp],r8d + mov DWORD[20+rsp],r9d + mov DWORD[24+rsp],r10d + mov DWORD[28+rsp],r11d + movdqa XMMWORD[32+rsp],xmm1 + mov DWORD[48+rsp],r12d + mov DWORD[52+rsp],r13d + mov DWORD[56+rsp],r14d + mov DWORD[60+rsp],r15d + +$L$oop_tail: + movzx eax,BYTE[rbx*1+rsi] + movzx edx,BYTE[rbx*1+rsp] + lea rbx,[1+rbx] + xor eax,edx + mov BYTE[((-1))+rbx*1+rdi],al + dec rbp + jnz NEAR $L$oop_tail + +$L$done: + lea rsi,[((64+24+48))+rsp] + mov r15,QWORD[((-48))+rsi] + + mov r14,QWORD[((-40))+rsi] + + mov r13,QWORD[((-32))+rsi] + + mov r12,QWORD[((-24))+rsi] + + mov rbp,QWORD[((-16))+rsi] + + mov rbx,QWORD[((-8))+rsi] + + lea rsp,[rsi] + +$L$no_data: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_ChaCha20_ctr32_nohw: +global ChaCha20_ctr32_ssse3_4x + +ALIGN 32 +ChaCha20_ctr32_ssse3_4x: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_ChaCha20_ctr32_ssse3_4x: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + mov rcx,r9 + mov r8,QWORD[40+rsp] + + + +_CET_ENDBR + mov r9,rsp + + sub rsp,0x140+168 + movaps XMMWORD[(-168)+r9],xmm6 + movaps XMMWORD[(-152)+r9],xmm7 + movaps XMMWORD[(-136)+r9],xmm8 + movaps XMMWORD[(-120)+r9],xmm9 + movaps XMMWORD[(-104)+r9],xmm10 + movaps XMMWORD[(-88)+r9],xmm11 + movaps XMMWORD[(-72)+r9],xmm12 + movaps XMMWORD[(-56)+r9],xmm13 + movaps XMMWORD[(-40)+r9],xmm14 + movaps XMMWORD[(-24)+r9],xmm15 +$L$4x_body: + movdqa xmm11,XMMWORD[$L$sigma] + movdqu xmm15,XMMWORD[rcx] + movdqu xmm7,XMMWORD[16+rcx] + movdqu xmm3,XMMWORD[r8] + lea rcx,[256+rsp] + lea r10,[$L$rot16] + lea r11,[$L$rot24] + + pshufd xmm8,xmm11,0x00 + pshufd xmm9,xmm11,0x55 + movdqa XMMWORD[64+rsp],xmm8 + pshufd xmm10,xmm11,0xaa + movdqa XMMWORD[80+rsp],xmm9 + pshufd xmm11,xmm11,0xff + movdqa XMMWORD[96+rsp],xmm10 + movdqa XMMWORD[112+rsp],xmm11 + + pshufd xmm12,xmm15,0x00 + pshufd xmm13,xmm15,0x55 + movdqa XMMWORD[(128-256)+rcx],xmm12 + pshufd xmm14,xmm15,0xaa + movdqa XMMWORD[(144-256)+rcx],xmm13 + pshufd xmm15,xmm15,0xff + movdqa XMMWORD[(160-256)+rcx],xmm14 + movdqa XMMWORD[(176-256)+rcx],xmm15 + + pshufd xmm4,xmm7,0x00 + pshufd xmm5,xmm7,0x55 + movdqa XMMWORD[(192-256)+rcx],xmm4 + pshufd xmm6,xmm7,0xaa + movdqa XMMWORD[(208-256)+rcx],xmm5 + pshufd xmm7,xmm7,0xff + movdqa XMMWORD[(224-256)+rcx],xmm6 + movdqa XMMWORD[(240-256)+rcx],xmm7 + + pshufd xmm0,xmm3,0x00 + pshufd xmm1,xmm3,0x55 + paddd xmm0,XMMWORD[$L$inc] + pshufd xmm2,xmm3,0xaa + movdqa XMMWORD[(272-256)+rcx],xmm1 + pshufd xmm3,xmm3,0xff + movdqa XMMWORD[(288-256)+rcx],xmm2 + movdqa XMMWORD[(304-256)+rcx],xmm3 + + jmp NEAR $L$oop_enter4x + +ALIGN 32 +$L$oop_outer4x: + movdqa xmm8,XMMWORD[64+rsp] + movdqa xmm9,XMMWORD[80+rsp] + movdqa xmm10,XMMWORD[96+rsp] + movdqa xmm11,XMMWORD[112+rsp] + movdqa xmm12,XMMWORD[((128-256))+rcx] + movdqa xmm13,XMMWORD[((144-256))+rcx] + movdqa xmm14,XMMWORD[((160-256))+rcx] + movdqa xmm15,XMMWORD[((176-256))+rcx] + movdqa xmm4,XMMWORD[((192-256))+rcx] + movdqa xmm5,XMMWORD[((208-256))+rcx] + movdqa xmm6,XMMWORD[((224-256))+rcx] + movdqa xmm7,XMMWORD[((240-256))+rcx] + movdqa xmm0,XMMWORD[((256-256))+rcx] + movdqa xmm1,XMMWORD[((272-256))+rcx] + movdqa xmm2,XMMWORD[((288-256))+rcx] + movdqa xmm3,XMMWORD[((304-256))+rcx] + paddd xmm0,XMMWORD[$L$four] + +$L$oop_enter4x: + movdqa XMMWORD[32+rsp],xmm6 + movdqa XMMWORD[48+rsp],xmm7 + movdqa xmm7,XMMWORD[r10] + mov eax,10 + movdqa XMMWORD[(256-256)+rcx],xmm0 + jmp NEAR $L$oop4x + +ALIGN 32 +$L$oop4x: + paddd xmm8,xmm12 + paddd xmm9,xmm13 + pxor xmm0,xmm8 + pxor xmm1,xmm9 +DB 102,15,56,0,199 +DB 102,15,56,0,207 + paddd xmm4,xmm0 + paddd xmm5,xmm1 + pxor xmm12,xmm4 + pxor xmm13,xmm5 + movdqa xmm6,xmm12 + pslld xmm12,12 + psrld xmm6,20 + movdqa xmm7,xmm13 + pslld xmm13,12 + por xmm12,xmm6 + psrld xmm7,20 + movdqa xmm6,XMMWORD[r11] + por xmm13,xmm7 + paddd xmm8,xmm12 + paddd xmm9,xmm13 + pxor xmm0,xmm8 + pxor xmm1,xmm9 +DB 102,15,56,0,198 +DB 102,15,56,0,206 + paddd xmm4,xmm0 + paddd xmm5,xmm1 + pxor xmm12,xmm4 + pxor xmm13,xmm5 + movdqa xmm7,xmm12 + pslld xmm12,7 + psrld xmm7,25 + movdqa xmm6,xmm13 + pslld xmm13,7 + por xmm12,xmm7 + psrld xmm6,25 + movdqa xmm7,XMMWORD[r10] + por xmm13,xmm6 + movdqa XMMWORD[rsp],xmm4 + movdqa XMMWORD[16+rsp],xmm5 + movdqa xmm4,XMMWORD[32+rsp] + movdqa xmm5,XMMWORD[48+rsp] + paddd xmm10,xmm14 + paddd xmm11,xmm15 + pxor xmm2,xmm10 + pxor xmm3,xmm11 +DB 102,15,56,0,215 +DB 102,15,56,0,223 + paddd xmm4,xmm2 + paddd xmm5,xmm3 + pxor xmm14,xmm4 + pxor xmm15,xmm5 + movdqa xmm6,xmm14 + pslld xmm14,12 + psrld xmm6,20 + movdqa xmm7,xmm15 + pslld xmm15,12 + por xmm14,xmm6 + psrld xmm7,20 + movdqa xmm6,XMMWORD[r11] + por xmm15,xmm7 + paddd xmm10,xmm14 + paddd xmm11,xmm15 + pxor xmm2,xmm10 + pxor xmm3,xmm11 +DB 102,15,56,0,214 +DB 102,15,56,0,222 + paddd xmm4,xmm2 + paddd xmm5,xmm3 + pxor xmm14,xmm4 + pxor xmm15,xmm5 + movdqa xmm7,xmm14 + pslld xmm14,7 + psrld xmm7,25 + movdqa xmm6,xmm15 + pslld xmm15,7 + por xmm14,xmm7 + psrld xmm6,25 + movdqa xmm7,XMMWORD[r10] + por xmm15,xmm6 + paddd xmm8,xmm13 + paddd xmm9,xmm14 + pxor xmm3,xmm8 + pxor xmm0,xmm9 +DB 102,15,56,0,223 +DB 102,15,56,0,199 + paddd xmm4,xmm3 + paddd xmm5,xmm0 + pxor xmm13,xmm4 + pxor xmm14,xmm5 + movdqa xmm6,xmm13 + pslld xmm13,12 + psrld xmm6,20 + movdqa xmm7,xmm14 + pslld xmm14,12 + por xmm13,xmm6 + psrld xmm7,20 + movdqa xmm6,XMMWORD[r11] + por xmm14,xmm7 + paddd xmm8,xmm13 + paddd xmm9,xmm14 + pxor xmm3,xmm8 + pxor xmm0,xmm9 +DB 102,15,56,0,222 +DB 102,15,56,0,198 + paddd xmm4,xmm3 + paddd xmm5,xmm0 + pxor xmm13,xmm4 + pxor xmm14,xmm5 + movdqa xmm7,xmm13 + pslld xmm13,7 + psrld xmm7,25 + movdqa xmm6,xmm14 + pslld xmm14,7 + por xmm13,xmm7 + psrld xmm6,25 + movdqa xmm7,XMMWORD[r10] + por xmm14,xmm6 + movdqa XMMWORD[32+rsp],xmm4 + movdqa XMMWORD[48+rsp],xmm5 + movdqa xmm4,XMMWORD[rsp] + movdqa xmm5,XMMWORD[16+rsp] + paddd xmm10,xmm15 + paddd xmm11,xmm12 + pxor xmm1,xmm10 + pxor xmm2,xmm11 +DB 102,15,56,0,207 +DB 102,15,56,0,215 + paddd xmm4,xmm1 + paddd xmm5,xmm2 + pxor xmm15,xmm4 + pxor xmm12,xmm5 + movdqa xmm6,xmm15 + pslld xmm15,12 + psrld xmm6,20 + movdqa xmm7,xmm12 + pslld xmm12,12 + por xmm15,xmm6 + psrld xmm7,20 + movdqa xmm6,XMMWORD[r11] + por xmm12,xmm7 + paddd xmm10,xmm15 + paddd xmm11,xmm12 + pxor xmm1,xmm10 + pxor xmm2,xmm11 +DB 102,15,56,0,206 +DB 102,15,56,0,214 + paddd xmm4,xmm1 + paddd xmm5,xmm2 + pxor xmm15,xmm4 + pxor xmm12,xmm5 + movdqa xmm7,xmm15 + pslld xmm15,7 + psrld xmm7,25 + movdqa xmm6,xmm12 + pslld xmm12,7 + por xmm15,xmm7 + psrld xmm6,25 + movdqa xmm7,XMMWORD[r10] + por xmm12,xmm6 + dec eax + jnz NEAR $L$oop4x + + paddd xmm8,XMMWORD[64+rsp] + paddd xmm9,XMMWORD[80+rsp] + paddd xmm10,XMMWORD[96+rsp] + paddd xmm11,XMMWORD[112+rsp] + + movdqa xmm6,xmm8 + punpckldq xmm8,xmm9 + movdqa xmm7,xmm10 + punpckldq xmm10,xmm11 + punpckhdq xmm6,xmm9 + punpckhdq xmm7,xmm11 + movdqa xmm9,xmm8 + punpcklqdq xmm8,xmm10 + movdqa xmm11,xmm6 + punpcklqdq xmm6,xmm7 + punpckhqdq xmm9,xmm10 + punpckhqdq xmm11,xmm7 + paddd xmm12,XMMWORD[((128-256))+rcx] + paddd xmm13,XMMWORD[((144-256))+rcx] + paddd xmm14,XMMWORD[((160-256))+rcx] + paddd xmm15,XMMWORD[((176-256))+rcx] + + movdqa XMMWORD[rsp],xmm8 + movdqa XMMWORD[16+rsp],xmm9 + movdqa xmm8,XMMWORD[32+rsp] + movdqa xmm9,XMMWORD[48+rsp] + + movdqa xmm10,xmm12 + punpckldq xmm12,xmm13 + movdqa xmm7,xmm14 + punpckldq xmm14,xmm15 + punpckhdq xmm10,xmm13 + punpckhdq xmm7,xmm15 + movdqa xmm13,xmm12 + punpcklqdq xmm12,xmm14 + movdqa xmm15,xmm10 + punpcklqdq xmm10,xmm7 + punpckhqdq xmm13,xmm14 + punpckhqdq xmm15,xmm7 + paddd xmm4,XMMWORD[((192-256))+rcx] + paddd xmm5,XMMWORD[((208-256))+rcx] + paddd xmm8,XMMWORD[((224-256))+rcx] + paddd xmm9,XMMWORD[((240-256))+rcx] + + movdqa XMMWORD[32+rsp],xmm6 + movdqa XMMWORD[48+rsp],xmm11 + + movdqa xmm14,xmm4 + punpckldq xmm4,xmm5 + movdqa xmm7,xmm8 + punpckldq xmm8,xmm9 + punpckhdq xmm14,xmm5 + punpckhdq xmm7,xmm9 + movdqa xmm5,xmm4 + punpcklqdq xmm4,xmm8 + movdqa xmm9,xmm14 + punpcklqdq xmm14,xmm7 + punpckhqdq xmm5,xmm8 + punpckhqdq xmm9,xmm7 + paddd xmm0,XMMWORD[((256-256))+rcx] + paddd xmm1,XMMWORD[((272-256))+rcx] + paddd xmm2,XMMWORD[((288-256))+rcx] + paddd xmm3,XMMWORD[((304-256))+rcx] + + movdqa xmm8,xmm0 + punpckldq xmm0,xmm1 + movdqa xmm7,xmm2 + punpckldq xmm2,xmm3 + punpckhdq xmm8,xmm1 + punpckhdq xmm7,xmm3 + movdqa xmm1,xmm0 + punpcklqdq xmm0,xmm2 + movdqa xmm3,xmm8 + punpcklqdq xmm8,xmm7 + punpckhqdq xmm1,xmm2 + punpckhqdq xmm3,xmm7 + cmp rdx,64*4 + jb NEAR $L$tail4x + + movdqu xmm6,XMMWORD[rsi] + movdqu xmm11,XMMWORD[16+rsi] + movdqu xmm2,XMMWORD[32+rsi] + movdqu xmm7,XMMWORD[48+rsi] + pxor xmm6,XMMWORD[rsp] + pxor xmm11,xmm12 + pxor xmm2,xmm4 + pxor xmm7,xmm0 + + movdqu XMMWORD[rdi],xmm6 + movdqu xmm6,XMMWORD[64+rsi] + movdqu XMMWORD[16+rdi],xmm11 + movdqu xmm11,XMMWORD[80+rsi] + movdqu XMMWORD[32+rdi],xmm2 + movdqu xmm2,XMMWORD[96+rsi] + movdqu XMMWORD[48+rdi],xmm7 + movdqu xmm7,XMMWORD[112+rsi] + lea rsi,[128+rsi] + pxor xmm6,XMMWORD[16+rsp] + pxor xmm11,xmm13 + pxor xmm2,xmm5 + pxor xmm7,xmm1 + + movdqu XMMWORD[64+rdi],xmm6 + movdqu xmm6,XMMWORD[rsi] + movdqu XMMWORD[80+rdi],xmm11 + movdqu xmm11,XMMWORD[16+rsi] + movdqu XMMWORD[96+rdi],xmm2 + movdqu xmm2,XMMWORD[32+rsi] + movdqu XMMWORD[112+rdi],xmm7 + lea rdi,[128+rdi] + movdqu xmm7,XMMWORD[48+rsi] + pxor xmm6,XMMWORD[32+rsp] + pxor xmm11,xmm10 + pxor xmm2,xmm14 + pxor xmm7,xmm8 + + movdqu XMMWORD[rdi],xmm6 + movdqu xmm6,XMMWORD[64+rsi] + movdqu XMMWORD[16+rdi],xmm11 + movdqu xmm11,XMMWORD[80+rsi] + movdqu XMMWORD[32+rdi],xmm2 + movdqu xmm2,XMMWORD[96+rsi] + movdqu XMMWORD[48+rdi],xmm7 + movdqu xmm7,XMMWORD[112+rsi] + lea rsi,[128+rsi] + pxor xmm6,XMMWORD[48+rsp] + pxor xmm11,xmm15 + pxor xmm2,xmm9 + pxor xmm7,xmm3 + movdqu XMMWORD[64+rdi],xmm6 + movdqu XMMWORD[80+rdi],xmm11 + movdqu XMMWORD[96+rdi],xmm2 + movdqu XMMWORD[112+rdi],xmm7 + lea rdi,[128+rdi] + + sub rdx,64*4 + jnz NEAR $L$oop_outer4x + + jmp NEAR $L$done4x + +$L$tail4x: + cmp rdx,192 + jae NEAR $L$192_or_more4x + cmp rdx,128 + jae NEAR $L$128_or_more4x + cmp rdx,64 + jae NEAR $L$64_or_more4x + + + xor r10,r10 + + movdqa XMMWORD[16+rsp],xmm12 + movdqa XMMWORD[32+rsp],xmm4 + movdqa XMMWORD[48+rsp],xmm0 + jmp NEAR $L$oop_tail4x + +ALIGN 32 +$L$64_or_more4x: + movdqu xmm6,XMMWORD[rsi] + movdqu xmm11,XMMWORD[16+rsi] + movdqu xmm2,XMMWORD[32+rsi] + movdqu xmm7,XMMWORD[48+rsi] + pxor xmm6,XMMWORD[rsp] + pxor xmm11,xmm12 + pxor xmm2,xmm4 + pxor xmm7,xmm0 + movdqu XMMWORD[rdi],xmm6 + movdqu XMMWORD[16+rdi],xmm11 + movdqu XMMWORD[32+rdi],xmm2 + movdqu XMMWORD[48+rdi],xmm7 + je NEAR $L$done4x + + movdqa xmm6,XMMWORD[16+rsp] + lea rsi,[64+rsi] + xor r10,r10 + movdqa XMMWORD[rsp],xmm6 + movdqa XMMWORD[16+rsp],xmm13 + lea rdi,[64+rdi] + movdqa XMMWORD[32+rsp],xmm5 + sub rdx,64 + movdqa XMMWORD[48+rsp],xmm1 + jmp NEAR $L$oop_tail4x + +ALIGN 32 +$L$128_or_more4x: + movdqu xmm6,XMMWORD[rsi] + movdqu xmm11,XMMWORD[16+rsi] + movdqu xmm2,XMMWORD[32+rsi] + movdqu xmm7,XMMWORD[48+rsi] + pxor xmm6,XMMWORD[rsp] + pxor xmm11,xmm12 + pxor xmm2,xmm4 + pxor xmm7,xmm0 + + movdqu XMMWORD[rdi],xmm6 + movdqu xmm6,XMMWORD[64+rsi] + movdqu XMMWORD[16+rdi],xmm11 + movdqu xmm11,XMMWORD[80+rsi] + movdqu XMMWORD[32+rdi],xmm2 + movdqu xmm2,XMMWORD[96+rsi] + movdqu XMMWORD[48+rdi],xmm7 + movdqu xmm7,XMMWORD[112+rsi] + pxor xmm6,XMMWORD[16+rsp] + pxor xmm11,xmm13 + pxor xmm2,xmm5 + pxor xmm7,xmm1 + movdqu XMMWORD[64+rdi],xmm6 + movdqu XMMWORD[80+rdi],xmm11 + movdqu XMMWORD[96+rdi],xmm2 + movdqu XMMWORD[112+rdi],xmm7 + je NEAR $L$done4x + + movdqa xmm6,XMMWORD[32+rsp] + lea rsi,[128+rsi] + xor r10,r10 + movdqa XMMWORD[rsp],xmm6 + movdqa XMMWORD[16+rsp],xmm10 + lea rdi,[128+rdi] + movdqa XMMWORD[32+rsp],xmm14 + sub rdx,128 + movdqa XMMWORD[48+rsp],xmm8 + jmp NEAR $L$oop_tail4x + +ALIGN 32 +$L$192_or_more4x: + movdqu xmm6,XMMWORD[rsi] + movdqu xmm11,XMMWORD[16+rsi] + movdqu xmm2,XMMWORD[32+rsi] + movdqu xmm7,XMMWORD[48+rsi] + pxor xmm6,XMMWORD[rsp] + pxor xmm11,xmm12 + pxor xmm2,xmm4 + pxor xmm7,xmm0 + + movdqu XMMWORD[rdi],xmm6 + movdqu xmm6,XMMWORD[64+rsi] + movdqu XMMWORD[16+rdi],xmm11 + movdqu xmm11,XMMWORD[80+rsi] + movdqu XMMWORD[32+rdi],xmm2 + movdqu xmm2,XMMWORD[96+rsi] + movdqu XMMWORD[48+rdi],xmm7 + movdqu xmm7,XMMWORD[112+rsi] + lea rsi,[128+rsi] + pxor xmm6,XMMWORD[16+rsp] + pxor xmm11,xmm13 + pxor xmm2,xmm5 + pxor xmm7,xmm1 + + movdqu XMMWORD[64+rdi],xmm6 + movdqu xmm6,XMMWORD[rsi] + movdqu XMMWORD[80+rdi],xmm11 + movdqu xmm11,XMMWORD[16+rsi] + movdqu XMMWORD[96+rdi],xmm2 + movdqu xmm2,XMMWORD[32+rsi] + movdqu XMMWORD[112+rdi],xmm7 + lea rdi,[128+rdi] + movdqu xmm7,XMMWORD[48+rsi] + pxor xmm6,XMMWORD[32+rsp] + pxor xmm11,xmm10 + pxor xmm2,xmm14 + pxor xmm7,xmm8 + movdqu XMMWORD[rdi],xmm6 + movdqu XMMWORD[16+rdi],xmm11 + movdqu XMMWORD[32+rdi],xmm2 + movdqu XMMWORD[48+rdi],xmm7 + je NEAR $L$done4x + + movdqa xmm6,XMMWORD[48+rsp] + lea rsi,[64+rsi] + xor r10,r10 + movdqa XMMWORD[rsp],xmm6 + movdqa XMMWORD[16+rsp],xmm15 + lea rdi,[64+rdi] + movdqa XMMWORD[32+rsp],xmm9 + sub rdx,192 + movdqa XMMWORD[48+rsp],xmm3 + +$L$oop_tail4x: + movzx eax,BYTE[r10*1+rsi] + movzx ecx,BYTE[r10*1+rsp] + lea r10,[1+r10] + xor eax,ecx + mov BYTE[((-1))+r10*1+rdi],al + dec rdx + jnz NEAR $L$oop_tail4x + +$L$done4x: + movaps xmm6,XMMWORD[((-168))+r9] + movaps xmm7,XMMWORD[((-152))+r9] + movaps xmm8,XMMWORD[((-136))+r9] + movaps xmm9,XMMWORD[((-120))+r9] + movaps xmm10,XMMWORD[((-104))+r9] + movaps xmm11,XMMWORD[((-88))+r9] + movaps xmm12,XMMWORD[((-72))+r9] + movaps xmm13,XMMWORD[((-56))+r9] + movaps xmm14,XMMWORD[((-40))+r9] + movaps xmm15,XMMWORD[((-24))+r9] + lea rsp,[r9] + +$L$4x_epilogue: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_ChaCha20_ctr32_ssse3_4x: +global ChaCha20_ctr32_avx2 + +ALIGN 32 +ChaCha20_ctr32_avx2: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_ChaCha20_ctr32_avx2: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + mov rcx,r9 + mov r8,QWORD[40+rsp] + + + +_CET_ENDBR + mov r9,rsp + + sub rsp,0x280+168 + and rsp,-32 + movaps XMMWORD[(-168)+r9],xmm6 + movaps XMMWORD[(-152)+r9],xmm7 + movaps XMMWORD[(-136)+r9],xmm8 + movaps XMMWORD[(-120)+r9],xmm9 + movaps XMMWORD[(-104)+r9],xmm10 + movaps XMMWORD[(-88)+r9],xmm11 + movaps XMMWORD[(-72)+r9],xmm12 + movaps XMMWORD[(-56)+r9],xmm13 + movaps XMMWORD[(-40)+r9],xmm14 + movaps XMMWORD[(-24)+r9],xmm15 +$L$8x_body: + vzeroupper + + + + + + + + + + + vbroadcasti128 ymm11,XMMWORD[$L$sigma] + vbroadcasti128 ymm3,XMMWORD[rcx] + vbroadcasti128 ymm15,XMMWORD[16+rcx] + vbroadcasti128 ymm7,XMMWORD[r8] + lea rcx,[256+rsp] + lea rax,[512+rsp] + lea r10,[$L$rot16] + lea r11,[$L$rot24] + + vpshufd ymm8,ymm11,0x00 + vpshufd ymm9,ymm11,0x55 + vmovdqa YMMWORD[(128-256)+rcx],ymm8 + vpshufd ymm10,ymm11,0xaa + vmovdqa YMMWORD[(160-256)+rcx],ymm9 + vpshufd ymm11,ymm11,0xff + vmovdqa YMMWORD[(192-256)+rcx],ymm10 + vmovdqa YMMWORD[(224-256)+rcx],ymm11 + + vpshufd ymm0,ymm3,0x00 + vpshufd ymm1,ymm3,0x55 + vmovdqa YMMWORD[(256-256)+rcx],ymm0 + vpshufd ymm2,ymm3,0xaa + vmovdqa YMMWORD[(288-256)+rcx],ymm1 + vpshufd ymm3,ymm3,0xff + vmovdqa YMMWORD[(320-256)+rcx],ymm2 + vmovdqa YMMWORD[(352-256)+rcx],ymm3 + + vpshufd ymm12,ymm15,0x00 + vpshufd ymm13,ymm15,0x55 + vmovdqa YMMWORD[(384-512)+rax],ymm12 + vpshufd ymm14,ymm15,0xaa + vmovdqa YMMWORD[(416-512)+rax],ymm13 + vpshufd ymm15,ymm15,0xff + vmovdqa YMMWORD[(448-512)+rax],ymm14 + vmovdqa YMMWORD[(480-512)+rax],ymm15 + + vpshufd ymm4,ymm7,0x00 + vpshufd ymm5,ymm7,0x55 + vpaddd ymm4,ymm4,YMMWORD[$L$incy] + vpshufd ymm6,ymm7,0xaa + vmovdqa YMMWORD[(544-512)+rax],ymm5 + vpshufd ymm7,ymm7,0xff + vmovdqa YMMWORD[(576-512)+rax],ymm6 + vmovdqa YMMWORD[(608-512)+rax],ymm7 + + jmp NEAR $L$oop_enter8x + +ALIGN 32 +$L$oop_outer8x: + vmovdqa ymm8,YMMWORD[((128-256))+rcx] + vmovdqa ymm9,YMMWORD[((160-256))+rcx] + vmovdqa ymm10,YMMWORD[((192-256))+rcx] + vmovdqa ymm11,YMMWORD[((224-256))+rcx] + vmovdqa ymm0,YMMWORD[((256-256))+rcx] + vmovdqa ymm1,YMMWORD[((288-256))+rcx] + vmovdqa ymm2,YMMWORD[((320-256))+rcx] + vmovdqa ymm3,YMMWORD[((352-256))+rcx] + vmovdqa ymm12,YMMWORD[((384-512))+rax] + vmovdqa ymm13,YMMWORD[((416-512))+rax] + vmovdqa ymm14,YMMWORD[((448-512))+rax] + vmovdqa ymm15,YMMWORD[((480-512))+rax] + vmovdqa ymm4,YMMWORD[((512-512))+rax] + vmovdqa ymm5,YMMWORD[((544-512))+rax] + vmovdqa ymm6,YMMWORD[((576-512))+rax] + vmovdqa ymm7,YMMWORD[((608-512))+rax] + vpaddd ymm4,ymm4,YMMWORD[$L$eight] + +$L$oop_enter8x: + vmovdqa YMMWORD[64+rsp],ymm14 + vmovdqa YMMWORD[96+rsp],ymm15 + vbroadcasti128 ymm15,XMMWORD[r10] + vmovdqa YMMWORD[(512-512)+rax],ymm4 + mov eax,10 + jmp NEAR $L$oop8x + +ALIGN 32 +$L$oop8x: + vpaddd ymm8,ymm8,ymm0 + vpxor ymm4,ymm8,ymm4 + vpshufb ymm4,ymm4,ymm15 + vpaddd ymm9,ymm9,ymm1 + vpxor ymm5,ymm9,ymm5 + vpshufb ymm5,ymm5,ymm15 + vpaddd ymm12,ymm12,ymm4 + vpxor ymm0,ymm12,ymm0 + vpslld ymm14,ymm0,12 + vpsrld ymm0,ymm0,20 + vpor ymm0,ymm14,ymm0 + vbroadcasti128 ymm14,XMMWORD[r11] + vpaddd ymm13,ymm13,ymm5 + vpxor ymm1,ymm13,ymm1 + vpslld ymm15,ymm1,12 + vpsrld ymm1,ymm1,20 + vpor ymm1,ymm15,ymm1 + vpaddd ymm8,ymm8,ymm0 + vpxor ymm4,ymm8,ymm4 + vpshufb ymm4,ymm4,ymm14 + vpaddd ymm9,ymm9,ymm1 + vpxor ymm5,ymm9,ymm5 + vpshufb ymm5,ymm5,ymm14 + vpaddd ymm12,ymm12,ymm4 + vpxor ymm0,ymm12,ymm0 + vpslld ymm15,ymm0,7 + vpsrld ymm0,ymm0,25 + vpor ymm0,ymm15,ymm0 + vbroadcasti128 ymm15,XMMWORD[r10] + vpaddd ymm13,ymm13,ymm5 + vpxor ymm1,ymm13,ymm1 + vpslld ymm14,ymm1,7 + vpsrld ymm1,ymm1,25 + vpor ymm1,ymm14,ymm1 + vmovdqa YMMWORD[rsp],ymm12 + vmovdqa YMMWORD[32+rsp],ymm13 + vmovdqa ymm12,YMMWORD[64+rsp] + vmovdqa ymm13,YMMWORD[96+rsp] + vpaddd ymm10,ymm10,ymm2 + vpxor ymm6,ymm10,ymm6 + vpshufb ymm6,ymm6,ymm15 + vpaddd ymm11,ymm11,ymm3 + vpxor ymm7,ymm11,ymm7 + vpshufb ymm7,ymm7,ymm15 + vpaddd ymm12,ymm12,ymm6 + vpxor ymm2,ymm12,ymm2 + vpslld ymm14,ymm2,12 + vpsrld ymm2,ymm2,20 + vpor ymm2,ymm14,ymm2 + vbroadcasti128 ymm14,XMMWORD[r11] + vpaddd ymm13,ymm13,ymm7 + vpxor ymm3,ymm13,ymm3 + vpslld ymm15,ymm3,12 + vpsrld ymm3,ymm3,20 + vpor ymm3,ymm15,ymm3 + vpaddd ymm10,ymm10,ymm2 + vpxor ymm6,ymm10,ymm6 + vpshufb ymm6,ymm6,ymm14 + vpaddd ymm11,ymm11,ymm3 + vpxor ymm7,ymm11,ymm7 + vpshufb ymm7,ymm7,ymm14 + vpaddd ymm12,ymm12,ymm6 + vpxor ymm2,ymm12,ymm2 + vpslld ymm15,ymm2,7 + vpsrld ymm2,ymm2,25 + vpor ymm2,ymm15,ymm2 + vbroadcasti128 ymm15,XMMWORD[r10] + vpaddd ymm13,ymm13,ymm7 + vpxor ymm3,ymm13,ymm3 + vpslld ymm14,ymm3,7 + vpsrld ymm3,ymm3,25 + vpor ymm3,ymm14,ymm3 + vpaddd ymm8,ymm8,ymm1 + vpxor ymm7,ymm8,ymm7 + vpshufb ymm7,ymm7,ymm15 + vpaddd ymm9,ymm9,ymm2 + vpxor ymm4,ymm9,ymm4 + vpshufb ymm4,ymm4,ymm15 + vpaddd ymm12,ymm12,ymm7 + vpxor ymm1,ymm12,ymm1 + vpslld ymm14,ymm1,12 + vpsrld ymm1,ymm1,20 + vpor ymm1,ymm14,ymm1 + vbroadcasti128 ymm14,XMMWORD[r11] + vpaddd ymm13,ymm13,ymm4 + vpxor ymm2,ymm13,ymm2 + vpslld ymm15,ymm2,12 + vpsrld ymm2,ymm2,20 + vpor ymm2,ymm15,ymm2 + vpaddd ymm8,ymm8,ymm1 + vpxor ymm7,ymm8,ymm7 + vpshufb ymm7,ymm7,ymm14 + vpaddd ymm9,ymm9,ymm2 + vpxor ymm4,ymm9,ymm4 + vpshufb ymm4,ymm4,ymm14 + vpaddd ymm12,ymm12,ymm7 + vpxor ymm1,ymm12,ymm1 + vpslld ymm15,ymm1,7 + vpsrld ymm1,ymm1,25 + vpor ymm1,ymm15,ymm1 + vbroadcasti128 ymm15,XMMWORD[r10] + vpaddd ymm13,ymm13,ymm4 + vpxor ymm2,ymm13,ymm2 + vpslld ymm14,ymm2,7 + vpsrld ymm2,ymm2,25 + vpor ymm2,ymm14,ymm2 + vmovdqa YMMWORD[64+rsp],ymm12 + vmovdqa YMMWORD[96+rsp],ymm13 + vmovdqa ymm12,YMMWORD[rsp] + vmovdqa ymm13,YMMWORD[32+rsp] + vpaddd ymm10,ymm10,ymm3 + vpxor ymm5,ymm10,ymm5 + vpshufb ymm5,ymm5,ymm15 + vpaddd ymm11,ymm11,ymm0 + vpxor ymm6,ymm11,ymm6 + vpshufb ymm6,ymm6,ymm15 + vpaddd ymm12,ymm12,ymm5 + vpxor ymm3,ymm12,ymm3 + vpslld ymm14,ymm3,12 + vpsrld ymm3,ymm3,20 + vpor ymm3,ymm14,ymm3 + vbroadcasti128 ymm14,XMMWORD[r11] + vpaddd ymm13,ymm13,ymm6 + vpxor ymm0,ymm13,ymm0 + vpslld ymm15,ymm0,12 + vpsrld ymm0,ymm0,20 + vpor ymm0,ymm15,ymm0 + vpaddd ymm10,ymm10,ymm3 + vpxor ymm5,ymm10,ymm5 + vpshufb ymm5,ymm5,ymm14 + vpaddd ymm11,ymm11,ymm0 + vpxor ymm6,ymm11,ymm6 + vpshufb ymm6,ymm6,ymm14 + vpaddd ymm12,ymm12,ymm5 + vpxor ymm3,ymm12,ymm3 + vpslld ymm15,ymm3,7 + vpsrld ymm3,ymm3,25 + vpor ymm3,ymm15,ymm3 + vbroadcasti128 ymm15,XMMWORD[r10] + vpaddd ymm13,ymm13,ymm6 + vpxor ymm0,ymm13,ymm0 + vpslld ymm14,ymm0,7 + vpsrld ymm0,ymm0,25 + vpor ymm0,ymm14,ymm0 + dec eax + jnz NEAR $L$oop8x + + lea rax,[512+rsp] + vpaddd ymm8,ymm8,YMMWORD[((128-256))+rcx] + vpaddd ymm9,ymm9,YMMWORD[((160-256))+rcx] + vpaddd ymm10,ymm10,YMMWORD[((192-256))+rcx] + vpaddd ymm11,ymm11,YMMWORD[((224-256))+rcx] + + vpunpckldq ymm14,ymm8,ymm9 + vpunpckldq ymm15,ymm10,ymm11 + vpunpckhdq ymm8,ymm8,ymm9 + vpunpckhdq ymm10,ymm10,ymm11 + vpunpcklqdq ymm9,ymm14,ymm15 + vpunpckhqdq ymm14,ymm14,ymm15 + vpunpcklqdq ymm11,ymm8,ymm10 + vpunpckhqdq ymm8,ymm8,ymm10 + vpaddd ymm0,ymm0,YMMWORD[((256-256))+rcx] + vpaddd ymm1,ymm1,YMMWORD[((288-256))+rcx] + vpaddd ymm2,ymm2,YMMWORD[((320-256))+rcx] + vpaddd ymm3,ymm3,YMMWORD[((352-256))+rcx] + + vpunpckldq ymm10,ymm0,ymm1 + vpunpckldq ymm15,ymm2,ymm3 + vpunpckhdq ymm0,ymm0,ymm1 + vpunpckhdq ymm2,ymm2,ymm3 + vpunpcklqdq ymm1,ymm10,ymm15 + vpunpckhqdq ymm10,ymm10,ymm15 + vpunpcklqdq ymm3,ymm0,ymm2 + vpunpckhqdq ymm0,ymm0,ymm2 + vperm2i128 ymm15,ymm9,ymm1,0x20 + vperm2i128 ymm1,ymm9,ymm1,0x31 + vperm2i128 ymm9,ymm14,ymm10,0x20 + vperm2i128 ymm10,ymm14,ymm10,0x31 + vperm2i128 ymm14,ymm11,ymm3,0x20 + vperm2i128 ymm3,ymm11,ymm3,0x31 + vperm2i128 ymm11,ymm8,ymm0,0x20 + vperm2i128 ymm0,ymm8,ymm0,0x31 + vmovdqa YMMWORD[rsp],ymm15 + vmovdqa YMMWORD[32+rsp],ymm9 + vmovdqa ymm15,YMMWORD[64+rsp] + vmovdqa ymm9,YMMWORD[96+rsp] + + vpaddd ymm12,ymm12,YMMWORD[((384-512))+rax] + vpaddd ymm13,ymm13,YMMWORD[((416-512))+rax] + vpaddd ymm15,ymm15,YMMWORD[((448-512))+rax] + vpaddd ymm9,ymm9,YMMWORD[((480-512))+rax] + + vpunpckldq ymm2,ymm12,ymm13 + vpunpckldq ymm8,ymm15,ymm9 + vpunpckhdq ymm12,ymm12,ymm13 + vpunpckhdq ymm15,ymm15,ymm9 + vpunpcklqdq ymm13,ymm2,ymm8 + vpunpckhqdq ymm2,ymm2,ymm8 + vpunpcklqdq ymm9,ymm12,ymm15 + vpunpckhqdq ymm12,ymm12,ymm15 + vpaddd ymm4,ymm4,YMMWORD[((512-512))+rax] + vpaddd ymm5,ymm5,YMMWORD[((544-512))+rax] + vpaddd ymm6,ymm6,YMMWORD[((576-512))+rax] + vpaddd ymm7,ymm7,YMMWORD[((608-512))+rax] + + vpunpckldq ymm15,ymm4,ymm5 + vpunpckldq ymm8,ymm6,ymm7 + vpunpckhdq ymm4,ymm4,ymm5 + vpunpckhdq ymm6,ymm6,ymm7 + vpunpcklqdq ymm5,ymm15,ymm8 + vpunpckhqdq ymm15,ymm15,ymm8 + vpunpcklqdq ymm7,ymm4,ymm6 + vpunpckhqdq ymm4,ymm4,ymm6 + vperm2i128 ymm8,ymm13,ymm5,0x20 + vperm2i128 ymm5,ymm13,ymm5,0x31 + vperm2i128 ymm13,ymm2,ymm15,0x20 + vperm2i128 ymm15,ymm2,ymm15,0x31 + vperm2i128 ymm2,ymm9,ymm7,0x20 + vperm2i128 ymm7,ymm9,ymm7,0x31 + vperm2i128 ymm9,ymm12,ymm4,0x20 + vperm2i128 ymm4,ymm12,ymm4,0x31 + vmovdqa ymm6,YMMWORD[rsp] + vmovdqa ymm12,YMMWORD[32+rsp] + + cmp rdx,64*8 + jb NEAR $L$tail8x + + vpxor ymm6,ymm6,YMMWORD[rsi] + vpxor ymm8,ymm8,YMMWORD[32+rsi] + vpxor ymm1,ymm1,YMMWORD[64+rsi] + vpxor ymm5,ymm5,YMMWORD[96+rsi] + lea rsi,[128+rsi] + vmovdqu YMMWORD[rdi],ymm6 + vmovdqu YMMWORD[32+rdi],ymm8 + vmovdqu YMMWORD[64+rdi],ymm1 + vmovdqu YMMWORD[96+rdi],ymm5 + lea rdi,[128+rdi] + + vpxor ymm12,ymm12,YMMWORD[rsi] + vpxor ymm13,ymm13,YMMWORD[32+rsi] + vpxor ymm10,ymm10,YMMWORD[64+rsi] + vpxor ymm15,ymm15,YMMWORD[96+rsi] + lea rsi,[128+rsi] + vmovdqu YMMWORD[rdi],ymm12 + vmovdqu YMMWORD[32+rdi],ymm13 + vmovdqu YMMWORD[64+rdi],ymm10 + vmovdqu YMMWORD[96+rdi],ymm15 + lea rdi,[128+rdi] + + vpxor ymm14,ymm14,YMMWORD[rsi] + vpxor ymm2,ymm2,YMMWORD[32+rsi] + vpxor ymm3,ymm3,YMMWORD[64+rsi] + vpxor ymm7,ymm7,YMMWORD[96+rsi] + lea rsi,[128+rsi] + vmovdqu YMMWORD[rdi],ymm14 + vmovdqu YMMWORD[32+rdi],ymm2 + vmovdqu YMMWORD[64+rdi],ymm3 + vmovdqu YMMWORD[96+rdi],ymm7 + lea rdi,[128+rdi] + + vpxor ymm11,ymm11,YMMWORD[rsi] + vpxor ymm9,ymm9,YMMWORD[32+rsi] + vpxor ymm0,ymm0,YMMWORD[64+rsi] + vpxor ymm4,ymm4,YMMWORD[96+rsi] + lea rsi,[128+rsi] + vmovdqu YMMWORD[rdi],ymm11 + vmovdqu YMMWORD[32+rdi],ymm9 + vmovdqu YMMWORD[64+rdi],ymm0 + vmovdqu YMMWORD[96+rdi],ymm4 + lea rdi,[128+rdi] + + sub rdx,64*8 + jnz NEAR $L$oop_outer8x + + jmp NEAR $L$done8x + +$L$tail8x: + cmp rdx,448 + jae NEAR $L$448_or_more8x + cmp rdx,384 + jae NEAR $L$384_or_more8x + cmp rdx,320 + jae NEAR $L$320_or_more8x + cmp rdx,256 + jae NEAR $L$256_or_more8x + cmp rdx,192 + jae NEAR $L$192_or_more8x + cmp rdx,128 + jae NEAR $L$128_or_more8x + cmp rdx,64 + jae NEAR $L$64_or_more8x + + xor r10,r10 + vmovdqa YMMWORD[rsp],ymm6 + vmovdqa YMMWORD[32+rsp],ymm8 + jmp NEAR $L$oop_tail8x + +ALIGN 32 +$L$64_or_more8x: + vpxor ymm6,ymm6,YMMWORD[rsi] + vpxor ymm8,ymm8,YMMWORD[32+rsi] + vmovdqu YMMWORD[rdi],ymm6 + vmovdqu YMMWORD[32+rdi],ymm8 + je NEAR $L$done8x + + lea rsi,[64+rsi] + xor r10,r10 + vmovdqa YMMWORD[rsp],ymm1 + lea rdi,[64+rdi] + sub rdx,64 + vmovdqa YMMWORD[32+rsp],ymm5 + jmp NEAR $L$oop_tail8x + +ALIGN 32 +$L$128_or_more8x: + vpxor ymm6,ymm6,YMMWORD[rsi] + vpxor ymm8,ymm8,YMMWORD[32+rsi] + vpxor ymm1,ymm1,YMMWORD[64+rsi] + vpxor ymm5,ymm5,YMMWORD[96+rsi] + vmovdqu YMMWORD[rdi],ymm6 + vmovdqu YMMWORD[32+rdi],ymm8 + vmovdqu YMMWORD[64+rdi],ymm1 + vmovdqu YMMWORD[96+rdi],ymm5 + je NEAR $L$done8x + + lea rsi,[128+rsi] + xor r10,r10 + vmovdqa YMMWORD[rsp],ymm12 + lea rdi,[128+rdi] + sub rdx,128 + vmovdqa YMMWORD[32+rsp],ymm13 + jmp NEAR $L$oop_tail8x + +ALIGN 32 +$L$192_or_more8x: + vpxor ymm6,ymm6,YMMWORD[rsi] + vpxor ymm8,ymm8,YMMWORD[32+rsi] + vpxor ymm1,ymm1,YMMWORD[64+rsi] + vpxor ymm5,ymm5,YMMWORD[96+rsi] + vpxor ymm12,ymm12,YMMWORD[128+rsi] + vpxor ymm13,ymm13,YMMWORD[160+rsi] + vmovdqu YMMWORD[rdi],ymm6 + vmovdqu YMMWORD[32+rdi],ymm8 + vmovdqu YMMWORD[64+rdi],ymm1 + vmovdqu YMMWORD[96+rdi],ymm5 + vmovdqu YMMWORD[128+rdi],ymm12 + vmovdqu YMMWORD[160+rdi],ymm13 + je NEAR $L$done8x + + lea rsi,[192+rsi] + xor r10,r10 + vmovdqa YMMWORD[rsp],ymm10 + lea rdi,[192+rdi] + sub rdx,192 + vmovdqa YMMWORD[32+rsp],ymm15 + jmp NEAR $L$oop_tail8x + +ALIGN 32 +$L$256_or_more8x: + vpxor ymm6,ymm6,YMMWORD[rsi] + vpxor ymm8,ymm8,YMMWORD[32+rsi] + vpxor ymm1,ymm1,YMMWORD[64+rsi] + vpxor ymm5,ymm5,YMMWORD[96+rsi] + vpxor ymm12,ymm12,YMMWORD[128+rsi] + vpxor ymm13,ymm13,YMMWORD[160+rsi] + vpxor ymm10,ymm10,YMMWORD[192+rsi] + vpxor ymm15,ymm15,YMMWORD[224+rsi] + vmovdqu YMMWORD[rdi],ymm6 + vmovdqu YMMWORD[32+rdi],ymm8 + vmovdqu YMMWORD[64+rdi],ymm1 + vmovdqu YMMWORD[96+rdi],ymm5 + vmovdqu YMMWORD[128+rdi],ymm12 + vmovdqu YMMWORD[160+rdi],ymm13 + vmovdqu YMMWORD[192+rdi],ymm10 + vmovdqu YMMWORD[224+rdi],ymm15 + je NEAR $L$done8x + + lea rsi,[256+rsi] + xor r10,r10 + vmovdqa YMMWORD[rsp],ymm14 + lea rdi,[256+rdi] + sub rdx,256 + vmovdqa YMMWORD[32+rsp],ymm2 + jmp NEAR $L$oop_tail8x + +ALIGN 32 +$L$320_or_more8x: + vpxor ymm6,ymm6,YMMWORD[rsi] + vpxor ymm8,ymm8,YMMWORD[32+rsi] + vpxor ymm1,ymm1,YMMWORD[64+rsi] + vpxor ymm5,ymm5,YMMWORD[96+rsi] + vpxor ymm12,ymm12,YMMWORD[128+rsi] + vpxor ymm13,ymm13,YMMWORD[160+rsi] + vpxor ymm10,ymm10,YMMWORD[192+rsi] + vpxor ymm15,ymm15,YMMWORD[224+rsi] + vpxor ymm14,ymm14,YMMWORD[256+rsi] + vpxor ymm2,ymm2,YMMWORD[288+rsi] + vmovdqu YMMWORD[rdi],ymm6 + vmovdqu YMMWORD[32+rdi],ymm8 + vmovdqu YMMWORD[64+rdi],ymm1 + vmovdqu YMMWORD[96+rdi],ymm5 + vmovdqu YMMWORD[128+rdi],ymm12 + vmovdqu YMMWORD[160+rdi],ymm13 + vmovdqu YMMWORD[192+rdi],ymm10 + vmovdqu YMMWORD[224+rdi],ymm15 + vmovdqu YMMWORD[256+rdi],ymm14 + vmovdqu YMMWORD[288+rdi],ymm2 + je NEAR $L$done8x + + lea rsi,[320+rsi] + xor r10,r10 + vmovdqa YMMWORD[rsp],ymm3 + lea rdi,[320+rdi] + sub rdx,320 + vmovdqa YMMWORD[32+rsp],ymm7 + jmp NEAR $L$oop_tail8x + +ALIGN 32 +$L$384_or_more8x: + vpxor ymm6,ymm6,YMMWORD[rsi] + vpxor ymm8,ymm8,YMMWORD[32+rsi] + vpxor ymm1,ymm1,YMMWORD[64+rsi] + vpxor ymm5,ymm5,YMMWORD[96+rsi] + vpxor ymm12,ymm12,YMMWORD[128+rsi] + vpxor ymm13,ymm13,YMMWORD[160+rsi] + vpxor ymm10,ymm10,YMMWORD[192+rsi] + vpxor ymm15,ymm15,YMMWORD[224+rsi] + vpxor ymm14,ymm14,YMMWORD[256+rsi] + vpxor ymm2,ymm2,YMMWORD[288+rsi] + vpxor ymm3,ymm3,YMMWORD[320+rsi] + vpxor ymm7,ymm7,YMMWORD[352+rsi] + vmovdqu YMMWORD[rdi],ymm6 + vmovdqu YMMWORD[32+rdi],ymm8 + vmovdqu YMMWORD[64+rdi],ymm1 + vmovdqu YMMWORD[96+rdi],ymm5 + vmovdqu YMMWORD[128+rdi],ymm12 + vmovdqu YMMWORD[160+rdi],ymm13 + vmovdqu YMMWORD[192+rdi],ymm10 + vmovdqu YMMWORD[224+rdi],ymm15 + vmovdqu YMMWORD[256+rdi],ymm14 + vmovdqu YMMWORD[288+rdi],ymm2 + vmovdqu YMMWORD[320+rdi],ymm3 + vmovdqu YMMWORD[352+rdi],ymm7 + je NEAR $L$done8x + + lea rsi,[384+rsi] + xor r10,r10 + vmovdqa YMMWORD[rsp],ymm11 + lea rdi,[384+rdi] + sub rdx,384 + vmovdqa YMMWORD[32+rsp],ymm9 + jmp NEAR $L$oop_tail8x + +ALIGN 32 +$L$448_or_more8x: + vpxor ymm6,ymm6,YMMWORD[rsi] + vpxor ymm8,ymm8,YMMWORD[32+rsi] + vpxor ymm1,ymm1,YMMWORD[64+rsi] + vpxor ymm5,ymm5,YMMWORD[96+rsi] + vpxor ymm12,ymm12,YMMWORD[128+rsi] + vpxor ymm13,ymm13,YMMWORD[160+rsi] + vpxor ymm10,ymm10,YMMWORD[192+rsi] + vpxor ymm15,ymm15,YMMWORD[224+rsi] + vpxor ymm14,ymm14,YMMWORD[256+rsi] + vpxor ymm2,ymm2,YMMWORD[288+rsi] + vpxor ymm3,ymm3,YMMWORD[320+rsi] + vpxor ymm7,ymm7,YMMWORD[352+rsi] + vpxor ymm11,ymm11,YMMWORD[384+rsi] + vpxor ymm9,ymm9,YMMWORD[416+rsi] + vmovdqu YMMWORD[rdi],ymm6 + vmovdqu YMMWORD[32+rdi],ymm8 + vmovdqu YMMWORD[64+rdi],ymm1 + vmovdqu YMMWORD[96+rdi],ymm5 + vmovdqu YMMWORD[128+rdi],ymm12 + vmovdqu YMMWORD[160+rdi],ymm13 + vmovdqu YMMWORD[192+rdi],ymm10 + vmovdqu YMMWORD[224+rdi],ymm15 + vmovdqu YMMWORD[256+rdi],ymm14 + vmovdqu YMMWORD[288+rdi],ymm2 + vmovdqu YMMWORD[320+rdi],ymm3 + vmovdqu YMMWORD[352+rdi],ymm7 + vmovdqu YMMWORD[384+rdi],ymm11 + vmovdqu YMMWORD[416+rdi],ymm9 + je NEAR $L$done8x + + lea rsi,[448+rsi] + xor r10,r10 + vmovdqa YMMWORD[rsp],ymm0 + lea rdi,[448+rdi] + sub rdx,448 + vmovdqa YMMWORD[32+rsp],ymm4 + +$L$oop_tail8x: + movzx eax,BYTE[r10*1+rsi] + movzx ecx,BYTE[r10*1+rsp] + lea r10,[1+r10] + xor eax,ecx + mov BYTE[((-1))+r10*1+rdi],al + dec rdx + jnz NEAR $L$oop_tail8x + +$L$done8x: + vzeroall + movaps xmm6,XMMWORD[((-168))+r9] + movaps xmm7,XMMWORD[((-152))+r9] + movaps xmm8,XMMWORD[((-136))+r9] + movaps xmm9,XMMWORD[((-120))+r9] + movaps xmm10,XMMWORD[((-104))+r9] + movaps xmm11,XMMWORD[((-88))+r9] + movaps xmm12,XMMWORD[((-72))+r9] + movaps xmm13,XMMWORD[((-56))+r9] + movaps xmm14,XMMWORD[((-40))+r9] + movaps xmm15,XMMWORD[((-24))+r9] + lea rsp,[r9] + +$L$8x_epilogue: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_ChaCha20_ctr32_avx2: +EXTERN __imp_RtlVirtualUnwind + +ALIGN 16 +se_handler: + push rsi + push rdi + push rbx + push rbp + push r12 + push r13 + push r14 + push r15 + pushfq + sub rsp,64 + + mov rax,QWORD[120+r8] + mov rbx,QWORD[248+r8] + + mov rsi,QWORD[8+r9] + mov r11,QWORD[56+r9] + + lea r10,[$L$ctr32_body] + cmp rbx,r10 + jb NEAR $L$common_seh_tail + + mov rax,QWORD[152+r8] + + lea r10,[$L$no_data] + cmp rbx,r10 + jae NEAR $L$common_seh_tail + + lea rax,[((64+24+48))+rax] + + mov rbx,QWORD[((-8))+rax] + mov rbp,QWORD[((-16))+rax] + mov r12,QWORD[((-24))+rax] + mov r13,QWORD[((-32))+rax] + mov r14,QWORD[((-40))+rax] + mov r15,QWORD[((-48))+rax] + mov QWORD[144+r8],rbx + mov QWORD[160+r8],rbp + mov QWORD[216+r8],r12 + mov QWORD[224+r8],r13 + mov QWORD[232+r8],r14 + mov QWORD[240+r8],r15 + +$L$common_seh_tail: + mov rdi,QWORD[8+rax] + mov rsi,QWORD[16+rax] + mov QWORD[152+r8],rax + mov QWORD[168+r8],rsi + mov QWORD[176+r8],rdi + + mov rdi,QWORD[40+r9] + mov rsi,r8 + mov ecx,154 + DD 0xa548f3fc + + mov rsi,r9 + xor rcx,rcx + mov rdx,QWORD[8+rsi] + mov r8,QWORD[rsi] + mov r9,QWORD[16+rsi] + mov r10,QWORD[40+rsi] + lea r11,[56+rsi] + lea r12,[24+rsi] + mov QWORD[32+rsp],r10 + mov QWORD[40+rsp],r11 + mov QWORD[48+rsp],r12 + mov QWORD[56+rsp],rcx + call QWORD[__imp_RtlVirtualUnwind] + + mov eax,1 + add rsp,64 + popfq + pop r15 + pop r14 + pop r13 + pop r12 + pop rbp + pop rbx + pop rdi + pop rsi + ret + + + +ALIGN 16 +ssse3_handler: + push rsi + push rdi + push rbx + push rbp + push r12 + push r13 + push r14 + push r15 + pushfq + sub rsp,64 + + mov rax,QWORD[120+r8] + mov rbx,QWORD[248+r8] + + mov rsi,QWORD[8+r9] + mov r11,QWORD[56+r9] + + mov r10d,DWORD[r11] + lea r10,[r10*1+rsi] + cmp rbx,r10 + jb NEAR $L$common_seh_tail + + mov rax,QWORD[192+r8] + + mov r10d,DWORD[4+r11] + lea r10,[r10*1+rsi] + cmp rbx,r10 + jae NEAR $L$common_seh_tail + + lea rsi,[((-40))+rax] + lea rdi,[512+r8] + mov ecx,4 + DD 0xa548f3fc + + jmp NEAR $L$common_seh_tail + + + +ALIGN 16 +full_handler: + push rsi + push rdi + push rbx + push rbp + push r12 + push r13 + push r14 + push r15 + pushfq + sub rsp,64 + + mov rax,QWORD[120+r8] + mov rbx,QWORD[248+r8] + + mov rsi,QWORD[8+r9] + mov r11,QWORD[56+r9] + + mov r10d,DWORD[r11] + lea r10,[r10*1+rsi] + cmp rbx,r10 + jb NEAR $L$common_seh_tail + + mov rax,QWORD[192+r8] + + mov r10d,DWORD[4+r11] + lea r10,[r10*1+rsi] + cmp rbx,r10 + jae NEAR $L$common_seh_tail + + lea rsi,[((-168))+rax] + lea rdi,[512+r8] + mov ecx,20 + DD 0xa548f3fc + + jmp NEAR $L$common_seh_tail + + +section .pdata rdata align=4 +ALIGN 4 + DD $L$SEH_begin_ChaCha20_ctr32_nohw wrt ..imagebase + DD $L$SEH_end_ChaCha20_ctr32_nohw wrt ..imagebase + DD $L$SEH_info_ChaCha20_ctr32_nohw wrt ..imagebase + + DD $L$SEH_begin_ChaCha20_ctr32_ssse3_4x wrt ..imagebase + DD $L$SEH_end_ChaCha20_ctr32_ssse3_4x wrt ..imagebase + DD $L$SEH_info_ChaCha20_ctr32_ssse3_4x wrt ..imagebase + DD $L$SEH_begin_ChaCha20_ctr32_avx2 wrt ..imagebase + DD $L$SEH_end_ChaCha20_ctr32_avx2 wrt ..imagebase + DD $L$SEH_info_ChaCha20_ctr32_avx2 wrt ..imagebase +section .xdata rdata align=8 +ALIGN 8 +$L$SEH_info_ChaCha20_ctr32_nohw: + DB 9,0,0,0 + DD se_handler wrt ..imagebase + +$L$SEH_info_ChaCha20_ctr32_ssse3_4x: + DB 9,0,0,0 + DD full_handler wrt ..imagebase + DD $L$4x_body wrt ..imagebase,$L$4x_epilogue wrt ..imagebase +$L$SEH_info_ChaCha20_ctr32_avx2: + DB 9,0,0,0 + DD full_handler wrt ..imagebase + DD $L$8x_body wrt ..imagebase,$L$8x_epilogue wrt ..imagebase +%else +; Work around https://bugzilla.nasm.us/show_bug.cgi?id=3392738 +ret +%endif diff --git a/http/vendor/ring/pregenerated/chacha-x86_64-nasm.o b/http/vendor/ring/pregenerated/chacha-x86_64-nasm.o new file mode 100644 index 0000000..f606b40 Binary files /dev/null and b/http/vendor/ring/pregenerated/chacha-x86_64-nasm.o differ diff --git a/http/vendor/ring/pregenerated/chacha20_poly1305_armv8-ios64.S b/http/vendor/ring/pregenerated/chacha20_poly1305_armv8-ios64.S new file mode 100644 index 0000000..36e0074 --- /dev/null +++ b/http/vendor/ring/pregenerated/chacha20_poly1305_armv8-ios64.S @@ -0,0 +1,3008 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__APPLE__) +.section __TEXT,__const + +.align 7 +Lchacha20_consts: +.byte 'e','x','p','a','n','d',' ','3','2','-','b','y','t','e',' ','k' +Linc: +.long 1,2,3,4 +Lrol8: +.byte 3,0,1,2, 7,4,5,6, 11,8,9,10, 15,12,13,14 +Lclamp: +.quad 0x0FFFFFFC0FFFFFFF, 0x0FFFFFFC0FFFFFFC + +.text + + +.align 6 +Lpoly_hash_ad_internal: +.cfi_startproc + cbnz x4, Lpoly_hash_intro + ret + +Lpoly_hash_intro: + cmp x4, #16 + b.lt Lpoly_hash_ad_tail + ldp x11, x12, [x3], 16 + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + sub x4, x4, #16 + b Lpoly_hash_ad_internal + +Lpoly_hash_ad_tail: + cbz x4, Lpoly_hash_ad_ret + + eor v20.16b, v20.16b, v20.16b // Use T0 to load the AAD + sub x4, x4, #1 + +Lpoly_hash_tail_16_compose: + ext v20.16b, v20.16b, v20.16b, #15 + ldrb w11, [x3, x4] + mov v20.b[0], w11 + subs x4, x4, #1 + b.ge Lpoly_hash_tail_16_compose + mov x11, v20.d[0] + mov x12, v20.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + +Lpoly_hash_ad_ret: + ret +.cfi_endproc + + +///////////////////////////////// +// +// void chacha20_poly1305_seal(uint8_t *pt, uint8_t *ct, size_t len_in, uint8_t *ad, size_t len_ad, union open_data *seal_data); +// +.globl _chacha20_poly1305_seal +.private_extern _chacha20_poly1305_seal + +.align 6 +_chacha20_poly1305_seal: + AARCH64_SIGN_LINK_REGISTER +.cfi_startproc + stp x29, x30, [sp, #-80]! +.cfi_def_cfa_offset 80 +.cfi_offset w30, -72 +.cfi_offset w29, -80 + mov x29, sp + // We probably could do .cfi_def_cfa w29, 80 at this point, but since + // we don't actually use the frame pointer like that, it's probably not + // worth bothering. + stp d8, d9, [sp, #16] + stp d10, d11, [sp, #32] + stp d12, d13, [sp, #48] + stp d14, d15, [sp, #64] +.cfi_offset b15, -8 +.cfi_offset b14, -16 +.cfi_offset b13, -24 +.cfi_offset b12, -32 +.cfi_offset b11, -40 +.cfi_offset b10, -48 +.cfi_offset b9, -56 +.cfi_offset b8, -64 + + adrp x11, Lchacha20_consts@PAGE + add x11, x11, Lchacha20_consts@PAGEOFF + + ld1 {v24.16b - v27.16b}, [x11] // Load the CONSTS, INC, ROL8 and CLAMP values + ld1 {v28.16b - v30.16b}, [x5] + + mov x15, #1 // Prepare the Poly1305 state + mov x8, #0 + mov x9, #0 + mov x10, #0 + + ldr x12, [x5, #56] // The total cipher text length includes extra_in_len + add x12, x12, x2 + mov v31.d[0], x4 // Store the input and aad lengths + mov v31.d[1], x12 + + cmp x2, #128 + b.le Lseal_128 // Optimization for smaller buffers + + // Initially we prepare 5 ChaCha20 blocks. Four to encrypt up to 4 blocks (256 bytes) of plaintext, + // and one for the Poly1305 R and S keys. The first four blocks (A0-A3..D0-D3) are computed vertically, + // the fifth block (A4-D4) horizontally. + ld4r {v0.4s,v1.4s,v2.4s,v3.4s}, [x11] + mov v4.16b, v24.16b + + ld4r {v5.4s,v6.4s,v7.4s,v8.4s}, [x5], #16 + mov v9.16b, v28.16b + + ld4r {v10.4s,v11.4s,v12.4s,v13.4s}, [x5], #16 + mov v14.16b, v29.16b + + ld4r {v15.4s,v16.4s,v17.4s,v18.4s}, [x5] + add v15.4s, v15.4s, v25.4s + mov v19.16b, v30.16b + + sub x5, x5, #32 + + mov x6, #10 + +.align 5 +Lseal_init_rounds: + add v0.4s, v0.4s, v5.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + add v3.4s, v3.4s, v8.4s + add v4.4s, v4.4s, v9.4s + + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + eor v18.16b, v18.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + rev32 v18.8h, v18.8h + rev32 v19.8h, v19.8h + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + add v13.4s, v13.4s, v18.4s + add v14.4s, v14.4s, v19.4s + + eor v5.16b, v5.16b, v10.16b + eor v6.16b, v6.16b, v11.16b + eor v7.16b, v7.16b, v12.16b + eor v8.16b, v8.16b, v13.16b + eor v9.16b, v9.16b, v14.16b + + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + ushr v5.4s, v6.4s, #20 + sli v5.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + ushr v7.4s, v8.4s, #20 + sli v7.4s, v8.4s, #12 + ushr v8.4s, v9.4s, #20 + sli v8.4s, v9.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v5.4s + add v2.4s, v2.4s, v6.4s + add v3.4s, v3.4s, v7.4s + add v4.4s, v4.4s, v8.4s + + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + eor v18.16b, v18.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + tbl v18.16b, {v18.16b}, v26.16b + tbl v19.16b, {v19.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + add v13.4s, v13.4s, v18.4s + add v14.4s, v14.4s, v19.4s + + eor v20.16b, v20.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v6.16b, v6.16b, v12.16b + eor v7.16b, v7.16b, v13.16b + eor v8.16b, v8.16b, v14.16b + + ushr v9.4s, v8.4s, #25 + sli v9.4s, v8.4s, #7 + ushr v8.4s, v7.4s, #25 + sli v8.4s, v7.4s, #7 + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v5.4s, #25 + sli v6.4s, v5.4s, #7 + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + + ext v9.16b, v9.16b, v9.16b, #4 + ext v14.16b, v14.16b, v14.16b, #8 + ext v19.16b, v19.16b, v19.16b, #12 + add v0.4s, v0.4s, v6.4s + add v1.4s, v1.4s, v7.4s + add v2.4s, v2.4s, v8.4s + add v3.4s, v3.4s, v5.4s + add v4.4s, v4.4s, v9.4s + + eor v18.16b, v18.16b, v0.16b + eor v15.16b, v15.16b, v1.16b + eor v16.16b, v16.16b, v2.16b + eor v17.16b, v17.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + rev32 v18.8h, v18.8h + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + rev32 v19.8h, v19.8h + + add v12.4s, v12.4s, v18.4s + add v13.4s, v13.4s, v15.4s + add v10.4s, v10.4s, v16.4s + add v11.4s, v11.4s, v17.4s + add v14.4s, v14.4s, v19.4s + + eor v6.16b, v6.16b, v12.16b + eor v7.16b, v7.16b, v13.16b + eor v8.16b, v8.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v9.16b, v9.16b, v14.16b + + ushr v20.4s, v6.4s, #20 + sli v20.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + ushr v7.4s, v8.4s, #20 + sli v7.4s, v8.4s, #12 + ushr v8.4s, v5.4s, #20 + sli v8.4s, v5.4s, #12 + ushr v5.4s, v9.4s, #20 + sli v5.4s, v9.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + add v3.4s, v3.4s, v8.4s + add v4.4s, v4.4s, v5.4s + + eor v18.16b, v18.16b, v0.16b + eor v15.16b, v15.16b, v1.16b + eor v16.16b, v16.16b, v2.16b + eor v17.16b, v17.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + tbl v18.16b, {v18.16b}, v26.16b + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + tbl v19.16b, {v19.16b}, v26.16b + + add v12.4s, v12.4s, v18.4s + add v13.4s, v13.4s, v15.4s + add v10.4s, v10.4s, v16.4s + add v11.4s, v11.4s, v17.4s + add v14.4s, v14.4s, v19.4s + + eor v20.16b, v20.16b, v12.16b + eor v6.16b, v6.16b, v13.16b + eor v7.16b, v7.16b, v10.16b + eor v8.16b, v8.16b, v11.16b + eor v5.16b, v5.16b, v14.16b + + ushr v9.4s, v5.4s, #25 + sli v9.4s, v5.4s, #7 + ushr v5.4s, v8.4s, #25 + sli v5.4s, v8.4s, #7 + ushr v8.4s, v7.4s, #25 + sli v8.4s, v7.4s, #7 + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v20.4s, #25 + sli v6.4s, v20.4s, #7 + + ext v9.16b, v9.16b, v9.16b, #12 + ext v14.16b, v14.16b, v14.16b, #8 + ext v19.16b, v19.16b, v19.16b, #4 + subs x6, x6, #1 + b.hi Lseal_init_rounds + + add v15.4s, v15.4s, v25.4s + mov x11, #4 + dup v20.4s, w11 + add v25.4s, v25.4s, v20.4s + + zip1 v20.4s, v0.4s, v1.4s + zip2 v21.4s, v0.4s, v1.4s + zip1 v22.4s, v2.4s, v3.4s + zip2 v23.4s, v2.4s, v3.4s + + zip1 v0.2d, v20.2d, v22.2d + zip2 v1.2d, v20.2d, v22.2d + zip1 v2.2d, v21.2d, v23.2d + zip2 v3.2d, v21.2d, v23.2d + + zip1 v20.4s, v5.4s, v6.4s + zip2 v21.4s, v5.4s, v6.4s + zip1 v22.4s, v7.4s, v8.4s + zip2 v23.4s, v7.4s, v8.4s + + zip1 v5.2d, v20.2d, v22.2d + zip2 v6.2d, v20.2d, v22.2d + zip1 v7.2d, v21.2d, v23.2d + zip2 v8.2d, v21.2d, v23.2d + + zip1 v20.4s, v10.4s, v11.4s + zip2 v21.4s, v10.4s, v11.4s + zip1 v22.4s, v12.4s, v13.4s + zip2 v23.4s, v12.4s, v13.4s + + zip1 v10.2d, v20.2d, v22.2d + zip2 v11.2d, v20.2d, v22.2d + zip1 v12.2d, v21.2d, v23.2d + zip2 v13.2d, v21.2d, v23.2d + + zip1 v20.4s, v15.4s, v16.4s + zip2 v21.4s, v15.4s, v16.4s + zip1 v22.4s, v17.4s, v18.4s + zip2 v23.4s, v17.4s, v18.4s + + zip1 v15.2d, v20.2d, v22.2d + zip2 v16.2d, v20.2d, v22.2d + zip1 v17.2d, v21.2d, v23.2d + zip2 v18.2d, v21.2d, v23.2d + + add v4.4s, v4.4s, v24.4s + add v9.4s, v9.4s, v28.4s + and v4.16b, v4.16b, v27.16b + + add v0.4s, v0.4s, v24.4s + add v5.4s, v5.4s, v28.4s + add v10.4s, v10.4s, v29.4s + add v15.4s, v15.4s, v30.4s + + add v1.4s, v1.4s, v24.4s + add v6.4s, v6.4s, v28.4s + add v11.4s, v11.4s, v29.4s + add v16.4s, v16.4s, v30.4s + + add v2.4s, v2.4s, v24.4s + add v7.4s, v7.4s, v28.4s + add v12.4s, v12.4s, v29.4s + add v17.4s, v17.4s, v30.4s + + add v3.4s, v3.4s, v24.4s + add v8.4s, v8.4s, v28.4s + add v13.4s, v13.4s, v29.4s + add v18.4s, v18.4s, v30.4s + + mov x16, v4.d[0] // Move the R key to GPRs + mov x17, v4.d[1] + mov v27.16b, v9.16b // Store the S key + + bl Lpoly_hash_ad_internal + + mov x3, x0 + cmp x2, #256 + b.le Lseal_tail + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v0.16b + eor v21.16b, v21.16b, v5.16b + eor v22.16b, v22.16b, v10.16b + eor v23.16b, v23.16b, v15.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v1.16b + eor v21.16b, v21.16b, v6.16b + eor v22.16b, v22.16b, v11.16b + eor v23.16b, v23.16b, v16.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v2.16b + eor v21.16b, v21.16b, v7.16b + eor v22.16b, v22.16b, v12.16b + eor v23.16b, v23.16b, v17.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v3.16b + eor v21.16b, v21.16b, v8.16b + eor v22.16b, v22.16b, v13.16b + eor v23.16b, v23.16b, v18.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + sub x2, x2, #256 + + mov x6, #4 // In the first run of the loop we need to hash 256 bytes, therefore we hash one block for the first 4 rounds + mov x7, #6 // and two blocks for the remaining 6, for a total of (1 * 4 + 2 * 6) * 16 = 256 + +Lseal_main_loop: + adrp x11, Lchacha20_consts@PAGE + add x11, x11, Lchacha20_consts@PAGEOFF + + ld4r {v0.4s,v1.4s,v2.4s,v3.4s}, [x11] + mov v4.16b, v24.16b + + ld4r {v5.4s,v6.4s,v7.4s,v8.4s}, [x5], #16 + mov v9.16b, v28.16b + + ld4r {v10.4s,v11.4s,v12.4s,v13.4s}, [x5], #16 + mov v14.16b, v29.16b + + ld4r {v15.4s,v16.4s,v17.4s,v18.4s}, [x5] + add v15.4s, v15.4s, v25.4s + mov v19.16b, v30.16b + + eor v20.16b, v20.16b, v20.16b //zero + not v21.16b, v20.16b // -1 + sub v21.4s, v25.4s, v21.4s // Add +1 + ext v20.16b, v21.16b, v20.16b, #12 // Get the last element (counter) + add v19.4s, v19.4s, v20.4s + + sub x5, x5, #32 +.align 5 +Lseal_main_loop_rounds: + add v0.4s, v0.4s, v5.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + add v3.4s, v3.4s, v8.4s + add v4.4s, v4.4s, v9.4s + + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + eor v18.16b, v18.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + rev32 v18.8h, v18.8h + rev32 v19.8h, v19.8h + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + add v13.4s, v13.4s, v18.4s + add v14.4s, v14.4s, v19.4s + + eor v5.16b, v5.16b, v10.16b + eor v6.16b, v6.16b, v11.16b + eor v7.16b, v7.16b, v12.16b + eor v8.16b, v8.16b, v13.16b + eor v9.16b, v9.16b, v14.16b + + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + ushr v5.4s, v6.4s, #20 + sli v5.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + ushr v7.4s, v8.4s, #20 + sli v7.4s, v8.4s, #12 + ushr v8.4s, v9.4s, #20 + sli v8.4s, v9.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v5.4s + add v2.4s, v2.4s, v6.4s + add v3.4s, v3.4s, v7.4s + add v4.4s, v4.4s, v8.4s + + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + eor v18.16b, v18.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + tbl v18.16b, {v18.16b}, v26.16b + tbl v19.16b, {v19.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + add v13.4s, v13.4s, v18.4s + add v14.4s, v14.4s, v19.4s + + eor v20.16b, v20.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v6.16b, v6.16b, v12.16b + eor v7.16b, v7.16b, v13.16b + eor v8.16b, v8.16b, v14.16b + + ushr v9.4s, v8.4s, #25 + sli v9.4s, v8.4s, #7 + ushr v8.4s, v7.4s, #25 + sli v8.4s, v7.4s, #7 + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v5.4s, #25 + sli v6.4s, v5.4s, #7 + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + + ext v9.16b, v9.16b, v9.16b, #4 + ext v14.16b, v14.16b, v14.16b, #8 + ext v19.16b, v19.16b, v19.16b, #12 + ldp x11, x12, [x3], 16 + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + add v0.4s, v0.4s, v6.4s + add v1.4s, v1.4s, v7.4s + add v2.4s, v2.4s, v8.4s + add v3.4s, v3.4s, v5.4s + add v4.4s, v4.4s, v9.4s + + eor v18.16b, v18.16b, v0.16b + eor v15.16b, v15.16b, v1.16b + eor v16.16b, v16.16b, v2.16b + eor v17.16b, v17.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + rev32 v18.8h, v18.8h + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + rev32 v19.8h, v19.8h + + add v12.4s, v12.4s, v18.4s + add v13.4s, v13.4s, v15.4s + add v10.4s, v10.4s, v16.4s + add v11.4s, v11.4s, v17.4s + add v14.4s, v14.4s, v19.4s + + eor v6.16b, v6.16b, v12.16b + eor v7.16b, v7.16b, v13.16b + eor v8.16b, v8.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v9.16b, v9.16b, v14.16b + + ushr v20.4s, v6.4s, #20 + sli v20.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + ushr v7.4s, v8.4s, #20 + sli v7.4s, v8.4s, #12 + ushr v8.4s, v5.4s, #20 + sli v8.4s, v5.4s, #12 + ushr v5.4s, v9.4s, #20 + sli v5.4s, v9.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + add v3.4s, v3.4s, v8.4s + add v4.4s, v4.4s, v5.4s + + eor v18.16b, v18.16b, v0.16b + eor v15.16b, v15.16b, v1.16b + eor v16.16b, v16.16b, v2.16b + eor v17.16b, v17.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + tbl v18.16b, {v18.16b}, v26.16b + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + tbl v19.16b, {v19.16b}, v26.16b + + add v12.4s, v12.4s, v18.4s + add v13.4s, v13.4s, v15.4s + add v10.4s, v10.4s, v16.4s + add v11.4s, v11.4s, v17.4s + add v14.4s, v14.4s, v19.4s + + eor v20.16b, v20.16b, v12.16b + eor v6.16b, v6.16b, v13.16b + eor v7.16b, v7.16b, v10.16b + eor v8.16b, v8.16b, v11.16b + eor v5.16b, v5.16b, v14.16b + + ushr v9.4s, v5.4s, #25 + sli v9.4s, v5.4s, #7 + ushr v5.4s, v8.4s, #25 + sli v5.4s, v8.4s, #7 + ushr v8.4s, v7.4s, #25 + sli v8.4s, v7.4s, #7 + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v20.4s, #25 + sli v6.4s, v20.4s, #7 + + ext v9.16b, v9.16b, v9.16b, #12 + ext v14.16b, v14.16b, v14.16b, #8 + ext v19.16b, v19.16b, v19.16b, #4 + subs x6, x6, #1 + b.ge Lseal_main_loop_rounds + ldp x11, x12, [x3], 16 + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + subs x7, x7, #1 + b.gt Lseal_main_loop_rounds + + eor v20.16b, v20.16b, v20.16b //zero + not v21.16b, v20.16b // -1 + sub v21.4s, v25.4s, v21.4s // Add +1 + ext v20.16b, v21.16b, v20.16b, #12 // Get the last element (counter) + add v19.4s, v19.4s, v20.4s + + add v15.4s, v15.4s, v25.4s + mov x11, #5 + dup v20.4s, w11 + add v25.4s, v25.4s, v20.4s + + zip1 v20.4s, v0.4s, v1.4s + zip2 v21.4s, v0.4s, v1.4s + zip1 v22.4s, v2.4s, v3.4s + zip2 v23.4s, v2.4s, v3.4s + + zip1 v0.2d, v20.2d, v22.2d + zip2 v1.2d, v20.2d, v22.2d + zip1 v2.2d, v21.2d, v23.2d + zip2 v3.2d, v21.2d, v23.2d + + zip1 v20.4s, v5.4s, v6.4s + zip2 v21.4s, v5.4s, v6.4s + zip1 v22.4s, v7.4s, v8.4s + zip2 v23.4s, v7.4s, v8.4s + + zip1 v5.2d, v20.2d, v22.2d + zip2 v6.2d, v20.2d, v22.2d + zip1 v7.2d, v21.2d, v23.2d + zip2 v8.2d, v21.2d, v23.2d + + zip1 v20.4s, v10.4s, v11.4s + zip2 v21.4s, v10.4s, v11.4s + zip1 v22.4s, v12.4s, v13.4s + zip2 v23.4s, v12.4s, v13.4s + + zip1 v10.2d, v20.2d, v22.2d + zip2 v11.2d, v20.2d, v22.2d + zip1 v12.2d, v21.2d, v23.2d + zip2 v13.2d, v21.2d, v23.2d + + zip1 v20.4s, v15.4s, v16.4s + zip2 v21.4s, v15.4s, v16.4s + zip1 v22.4s, v17.4s, v18.4s + zip2 v23.4s, v17.4s, v18.4s + + zip1 v15.2d, v20.2d, v22.2d + zip2 v16.2d, v20.2d, v22.2d + zip1 v17.2d, v21.2d, v23.2d + zip2 v18.2d, v21.2d, v23.2d + + add v0.4s, v0.4s, v24.4s + add v5.4s, v5.4s, v28.4s + add v10.4s, v10.4s, v29.4s + add v15.4s, v15.4s, v30.4s + + add v1.4s, v1.4s, v24.4s + add v6.4s, v6.4s, v28.4s + add v11.4s, v11.4s, v29.4s + add v16.4s, v16.4s, v30.4s + + add v2.4s, v2.4s, v24.4s + add v7.4s, v7.4s, v28.4s + add v12.4s, v12.4s, v29.4s + add v17.4s, v17.4s, v30.4s + + add v3.4s, v3.4s, v24.4s + add v8.4s, v8.4s, v28.4s + add v13.4s, v13.4s, v29.4s + add v18.4s, v18.4s, v30.4s + + add v4.4s, v4.4s, v24.4s + add v9.4s, v9.4s, v28.4s + add v14.4s, v14.4s, v29.4s + add v19.4s, v19.4s, v30.4s + + cmp x2, #320 + b.le Lseal_tail + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v0.16b + eor v21.16b, v21.16b, v5.16b + eor v22.16b, v22.16b, v10.16b + eor v23.16b, v23.16b, v15.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v1.16b + eor v21.16b, v21.16b, v6.16b + eor v22.16b, v22.16b, v11.16b + eor v23.16b, v23.16b, v16.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v2.16b + eor v21.16b, v21.16b, v7.16b + eor v22.16b, v22.16b, v12.16b + eor v23.16b, v23.16b, v17.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v3.16b + eor v21.16b, v21.16b, v8.16b + eor v22.16b, v22.16b, v13.16b + eor v23.16b, v23.16b, v18.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v4.16b + eor v21.16b, v21.16b, v9.16b + eor v22.16b, v22.16b, v14.16b + eor v23.16b, v23.16b, v19.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + sub x2, x2, #320 + + mov x6, #0 + mov x7, #10 // For the remainder of the loop we always hash and encrypt 320 bytes per iteration + + b Lseal_main_loop + +Lseal_tail: + // This part of the function handles the storage and authentication of the last [0,320) bytes + // We assume A0-A4 ... D0-D4 hold at least inl (320 max) bytes of the stream data. + cmp x2, #64 + b.lt Lseal_tail_64 + + // Store and authenticate 64B blocks per iteration + ld1 {v20.16b - v23.16b}, [x1], #64 + + eor v20.16b, v20.16b, v0.16b + eor v21.16b, v21.16b, v5.16b + eor v22.16b, v22.16b, v10.16b + eor v23.16b, v23.16b, v15.16b + mov x11, v20.d[0] + mov x12, v20.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + mov x11, v21.d[0] + mov x12, v21.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + mov x11, v22.d[0] + mov x12, v22.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + mov x11, v23.d[0] + mov x12, v23.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + st1 {v20.16b - v23.16b}, [x0], #64 + sub x2, x2, #64 + + // Shift the state left by 64 bytes for the next iteration of the loop + mov v0.16b, v1.16b + mov v5.16b, v6.16b + mov v10.16b, v11.16b + mov v15.16b, v16.16b + + mov v1.16b, v2.16b + mov v6.16b, v7.16b + mov v11.16b, v12.16b + mov v16.16b, v17.16b + + mov v2.16b, v3.16b + mov v7.16b, v8.16b + mov v12.16b, v13.16b + mov v17.16b, v18.16b + + mov v3.16b, v4.16b + mov v8.16b, v9.16b + mov v13.16b, v14.16b + mov v18.16b, v19.16b + + b Lseal_tail + +Lseal_tail_64: + ldp x3, x4, [x5, #48] // extra_in_len and extra_in_ptr + + // Here we handle the last [0,64) bytes of plaintext + cmp x2, #16 + b.lt Lseal_tail_16 + // Each iteration encrypt and authenticate a 16B block + ld1 {v20.16b}, [x1], #16 + eor v20.16b, v20.16b, v0.16b + mov x11, v20.d[0] + mov x12, v20.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + st1 {v20.16b}, [x0], #16 + + sub x2, x2, #16 + + // Shift the state left by 16 bytes for the next iteration of the loop + mov v0.16b, v5.16b + mov v5.16b, v10.16b + mov v10.16b, v15.16b + + b Lseal_tail_64 + +Lseal_tail_16: + // Here we handle the last [0,16) bytes of ciphertext that require a padded block + cbz x2, Lseal_hash_extra + + eor v20.16b, v20.16b, v20.16b // Use T0 to load the plaintext/extra in + eor v21.16b, v21.16b, v21.16b // Use T1 to generate an AND mask that will only mask the ciphertext bytes + not v22.16b, v20.16b + + mov x6, x2 + add x1, x1, x2 + + cbz x4, Lseal_tail_16_compose // No extra data to pad with, zero padding + + mov x7, #16 // We need to load some extra_in first for padding + sub x7, x7, x2 + cmp x4, x7 + csel x7, x4, x7, lt // Load the minimum of extra_in_len and the amount needed to fill the register + mov x12, x7 + add x3, x3, x7 + sub x4, x4, x7 + +Lseal_tail16_compose_extra_in: + ext v20.16b, v20.16b, v20.16b, #15 + ldrb w11, [x3, #-1]! + mov v20.b[0], w11 + subs x7, x7, #1 + b.gt Lseal_tail16_compose_extra_in + + add x3, x3, x12 + +Lseal_tail_16_compose: + ext v20.16b, v20.16b, v20.16b, #15 + ldrb w11, [x1, #-1]! + mov v20.b[0], w11 + ext v21.16b, v22.16b, v21.16b, #15 + subs x2, x2, #1 + b.gt Lseal_tail_16_compose + + and v0.16b, v0.16b, v21.16b + eor v20.16b, v20.16b, v0.16b + mov v21.16b, v20.16b + +Lseal_tail_16_store: + umov w11, v20.b[0] + strb w11, [x0], #1 + ext v20.16b, v20.16b, v20.16b, #1 + subs x6, x6, #1 + b.gt Lseal_tail_16_store + + // Hash in the final ct block concatenated with extra_in + mov x11, v21.d[0] + mov x12, v21.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + +Lseal_hash_extra: + cbz x4, Lseal_finalize + +Lseal_hash_extra_loop: + cmp x4, #16 + b.lt Lseal_hash_extra_tail + ld1 {v20.16b}, [x3], #16 + mov x11, v20.d[0] + mov x12, v20.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + sub x4, x4, #16 + b Lseal_hash_extra_loop + +Lseal_hash_extra_tail: + cbz x4, Lseal_finalize + eor v20.16b, v20.16b, v20.16b // Use T0 to load the remaining extra ciphertext + add x3, x3, x4 + +Lseal_hash_extra_load: + ext v20.16b, v20.16b, v20.16b, #15 + ldrb w11, [x3, #-1]! + mov v20.b[0], w11 + subs x4, x4, #1 + b.gt Lseal_hash_extra_load + + // Hash in the final padded extra_in blcok + mov x11, v20.d[0] + mov x12, v20.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + +Lseal_finalize: + mov x11, v31.d[0] + mov x12, v31.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + // Final reduction step + sub x12, xzr, x15 + orr x13, xzr, #3 + subs x11, x8, #-5 + sbcs x12, x9, x12 + sbcs x13, x10, x13 + csel x8, x11, x8, cs + csel x9, x12, x9, cs + csel x10, x13, x10, cs + mov x11, v27.d[0] + mov x12, v27.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + + stp x8, x9, [x5] + + ldp d8, d9, [sp, #16] + ldp d10, d11, [sp, #32] + ldp d12, d13, [sp, #48] + ldp d14, d15, [sp, #64] +.cfi_restore b15 +.cfi_restore b14 +.cfi_restore b13 +.cfi_restore b12 +.cfi_restore b11 +.cfi_restore b10 +.cfi_restore b9 +.cfi_restore b8 + ldp x29, x30, [sp], 80 +.cfi_restore w29 +.cfi_restore w30 +.cfi_def_cfa_offset 0 + AARCH64_VALIDATE_LINK_REGISTER + ret + +Lseal_128: + // On some architectures preparing 5 blocks for small buffers is wasteful + eor v25.16b, v25.16b, v25.16b + mov x11, #1 + mov v25.s[0], w11 + mov v0.16b, v24.16b + mov v1.16b, v24.16b + mov v2.16b, v24.16b + mov v5.16b, v28.16b + mov v6.16b, v28.16b + mov v7.16b, v28.16b + mov v10.16b, v29.16b + mov v11.16b, v29.16b + mov v12.16b, v29.16b + mov v17.16b, v30.16b + add v15.4s, v17.4s, v25.4s + add v16.4s, v15.4s, v25.4s + + mov x6, #10 + +Lseal_128_rounds: + add v0.4s, v0.4s, v5.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v5.16b, v5.16b, v10.16b + eor v6.16b, v6.16b, v11.16b + eor v7.16b, v7.16b, v12.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + ushr v5.4s, v6.4s, #20 + sli v5.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v5.4s + add v2.4s, v2.4s, v6.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v20.16b, v20.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v6.16b, v6.16b, v12.16b + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v5.4s, #25 + sli v6.4s, v5.4s, #7 + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + + ext v5.16b, v5.16b, v5.16b, #4 + ext v6.16b, v6.16b, v6.16b, #4 + ext v7.16b, v7.16b, v7.16b, #4 + + ext v10.16b, v10.16b, v10.16b, #8 + ext v11.16b, v11.16b, v11.16b, #8 + ext v12.16b, v12.16b, v12.16b, #8 + + ext v15.16b, v15.16b, v15.16b, #12 + ext v16.16b, v16.16b, v16.16b, #12 + ext v17.16b, v17.16b, v17.16b, #12 + add v0.4s, v0.4s, v5.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v5.16b, v5.16b, v10.16b + eor v6.16b, v6.16b, v11.16b + eor v7.16b, v7.16b, v12.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + ushr v5.4s, v6.4s, #20 + sli v5.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v5.4s + add v2.4s, v2.4s, v6.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v20.16b, v20.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v6.16b, v6.16b, v12.16b + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v5.4s, #25 + sli v6.4s, v5.4s, #7 + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + + ext v5.16b, v5.16b, v5.16b, #12 + ext v6.16b, v6.16b, v6.16b, #12 + ext v7.16b, v7.16b, v7.16b, #12 + + ext v10.16b, v10.16b, v10.16b, #8 + ext v11.16b, v11.16b, v11.16b, #8 + ext v12.16b, v12.16b, v12.16b, #8 + + ext v15.16b, v15.16b, v15.16b, #4 + ext v16.16b, v16.16b, v16.16b, #4 + ext v17.16b, v17.16b, v17.16b, #4 + subs x6, x6, #1 + b.hi Lseal_128_rounds + + add v0.4s, v0.4s, v24.4s + add v1.4s, v1.4s, v24.4s + add v2.4s, v2.4s, v24.4s + + add v5.4s, v5.4s, v28.4s + add v6.4s, v6.4s, v28.4s + add v7.4s, v7.4s, v28.4s + + // Only the first 32 bytes of the third block (counter = 0) are needed, + // so skip updating v12 and v17. + add v10.4s, v10.4s, v29.4s + add v11.4s, v11.4s, v29.4s + + add v30.4s, v30.4s, v25.4s + add v15.4s, v15.4s, v30.4s + add v30.4s, v30.4s, v25.4s + add v16.4s, v16.4s, v30.4s + + and v2.16b, v2.16b, v27.16b + mov x16, v2.d[0] // Move the R key to GPRs + mov x17, v2.d[1] + mov v27.16b, v7.16b // Store the S key + + bl Lpoly_hash_ad_internal + b Lseal_tail +.cfi_endproc + + +///////////////////////////////// +// +// void chacha20_poly1305_open(uint8_t *pt, uint8_t *ct, size_t len_in, uint8_t *ad, size_t len_ad, union open_data *aead_data); +// +.globl _chacha20_poly1305_open +.private_extern _chacha20_poly1305_open + +.align 6 +_chacha20_poly1305_open: + AARCH64_SIGN_LINK_REGISTER +.cfi_startproc + stp x29, x30, [sp, #-80]! +.cfi_def_cfa_offset 80 +.cfi_offset w30, -72 +.cfi_offset w29, -80 + mov x29, sp + // We probably could do .cfi_def_cfa w29, 80 at this point, but since + // we don't actually use the frame pointer like that, it's probably not + // worth bothering. + stp d8, d9, [sp, #16] + stp d10, d11, [sp, #32] + stp d12, d13, [sp, #48] + stp d14, d15, [sp, #64] +.cfi_offset b15, -8 +.cfi_offset b14, -16 +.cfi_offset b13, -24 +.cfi_offset b12, -32 +.cfi_offset b11, -40 +.cfi_offset b10, -48 +.cfi_offset b9, -56 +.cfi_offset b8, -64 + + adrp x11, Lchacha20_consts@PAGE + add x11, x11, Lchacha20_consts@PAGEOFF + + ld1 {v24.16b - v27.16b}, [x11] // Load the CONSTS, INC, ROL8 and CLAMP values + ld1 {v28.16b - v30.16b}, [x5] + + mov x15, #1 // Prepare the Poly1305 state + mov x8, #0 + mov x9, #0 + mov x10, #0 + + mov v31.d[0], x4 // Store the input and aad lengths + mov v31.d[1], x2 + + cmp x2, #128 + b.le Lopen_128 // Optimization for smaller buffers + + // Initially we prepare a single ChaCha20 block for the Poly1305 R and S keys + mov v0.16b, v24.16b + mov v5.16b, v28.16b + mov v10.16b, v29.16b + mov v15.16b, v30.16b + + mov x6, #10 + +.align 5 +Lopen_init_rounds: + add v0.4s, v0.4s, v5.4s + eor v15.16b, v15.16b, v0.16b + rev32 v15.8h, v15.8h + + add v10.4s, v10.4s, v15.4s + eor v5.16b, v5.16b, v10.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + add v0.4s, v0.4s, v20.4s + eor v15.16b, v15.16b, v0.16b + tbl v15.16b, {v15.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + eor v20.16b, v20.16b, v10.16b + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + ext v5.16b, v5.16b, v5.16b, #4 + ext v10.16b, v10.16b, v10.16b, #8 + ext v15.16b, v15.16b, v15.16b, #12 + add v0.4s, v0.4s, v5.4s + eor v15.16b, v15.16b, v0.16b + rev32 v15.8h, v15.8h + + add v10.4s, v10.4s, v15.4s + eor v5.16b, v5.16b, v10.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + add v0.4s, v0.4s, v20.4s + eor v15.16b, v15.16b, v0.16b + tbl v15.16b, {v15.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + eor v20.16b, v20.16b, v10.16b + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + ext v5.16b, v5.16b, v5.16b, #12 + ext v10.16b, v10.16b, v10.16b, #8 + ext v15.16b, v15.16b, v15.16b, #4 + subs x6, x6, #1 + b.hi Lopen_init_rounds + + add v0.4s, v0.4s, v24.4s + add v5.4s, v5.4s, v28.4s + + and v0.16b, v0.16b, v27.16b + mov x16, v0.d[0] // Move the R key to GPRs + mov x17, v0.d[1] + mov v27.16b, v5.16b // Store the S key + + bl Lpoly_hash_ad_internal + +Lopen_ad_done: + mov x3, x1 + +// Each iteration of the loop hash 320 bytes, and prepare stream for 320 bytes +Lopen_main_loop: + + cmp x2, #192 + b.lt Lopen_tail + + adrp x11, Lchacha20_consts@PAGE + add x11, x11, Lchacha20_consts@PAGEOFF + + ld4r {v0.4s,v1.4s,v2.4s,v3.4s}, [x11] + mov v4.16b, v24.16b + + ld4r {v5.4s,v6.4s,v7.4s,v8.4s}, [x5], #16 + mov v9.16b, v28.16b + + ld4r {v10.4s,v11.4s,v12.4s,v13.4s}, [x5], #16 + mov v14.16b, v29.16b + + ld4r {v15.4s,v16.4s,v17.4s,v18.4s}, [x5] + sub x5, x5, #32 + add v15.4s, v15.4s, v25.4s + mov v19.16b, v30.16b + + eor v20.16b, v20.16b, v20.16b //zero + not v21.16b, v20.16b // -1 + sub v21.4s, v25.4s, v21.4s // Add +1 + ext v20.16b, v21.16b, v20.16b, #12 // Get the last element (counter) + add v19.4s, v19.4s, v20.4s + + lsr x4, x2, #4 // How many whole blocks we have to hash, will always be at least 12 + sub x4, x4, #10 + + mov x7, #10 + subs x6, x7, x4 + subs x6, x7, x4 // itr1 can be negative if we have more than 320 bytes to hash + csel x7, x7, x4, le // if itr1 is zero or less, itr2 should be 10 to indicate all 10 rounds are full + + cbz x7, Lopen_main_loop_rounds_short + +.align 5 +Lopen_main_loop_rounds: + ldp x11, x12, [x3], 16 + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most +Lopen_main_loop_rounds_short: + add v0.4s, v0.4s, v5.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + add v3.4s, v3.4s, v8.4s + add v4.4s, v4.4s, v9.4s + + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + eor v18.16b, v18.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + rev32 v18.8h, v18.8h + rev32 v19.8h, v19.8h + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + add v13.4s, v13.4s, v18.4s + add v14.4s, v14.4s, v19.4s + + eor v5.16b, v5.16b, v10.16b + eor v6.16b, v6.16b, v11.16b + eor v7.16b, v7.16b, v12.16b + eor v8.16b, v8.16b, v13.16b + eor v9.16b, v9.16b, v14.16b + + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + ushr v5.4s, v6.4s, #20 + sli v5.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + ushr v7.4s, v8.4s, #20 + sli v7.4s, v8.4s, #12 + ushr v8.4s, v9.4s, #20 + sli v8.4s, v9.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v5.4s + add v2.4s, v2.4s, v6.4s + add v3.4s, v3.4s, v7.4s + add v4.4s, v4.4s, v8.4s + + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + eor v18.16b, v18.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + tbl v18.16b, {v18.16b}, v26.16b + tbl v19.16b, {v19.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + add v13.4s, v13.4s, v18.4s + add v14.4s, v14.4s, v19.4s + + eor v20.16b, v20.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v6.16b, v6.16b, v12.16b + eor v7.16b, v7.16b, v13.16b + eor v8.16b, v8.16b, v14.16b + + ushr v9.4s, v8.4s, #25 + sli v9.4s, v8.4s, #7 + ushr v8.4s, v7.4s, #25 + sli v8.4s, v7.4s, #7 + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v5.4s, #25 + sli v6.4s, v5.4s, #7 + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + + ext v9.16b, v9.16b, v9.16b, #4 + ext v14.16b, v14.16b, v14.16b, #8 + ext v19.16b, v19.16b, v19.16b, #12 + ldp x11, x12, [x3], 16 + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + add v0.4s, v0.4s, v6.4s + add v1.4s, v1.4s, v7.4s + add v2.4s, v2.4s, v8.4s + add v3.4s, v3.4s, v5.4s + add v4.4s, v4.4s, v9.4s + + eor v18.16b, v18.16b, v0.16b + eor v15.16b, v15.16b, v1.16b + eor v16.16b, v16.16b, v2.16b + eor v17.16b, v17.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + rev32 v18.8h, v18.8h + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + rev32 v19.8h, v19.8h + + add v12.4s, v12.4s, v18.4s + add v13.4s, v13.4s, v15.4s + add v10.4s, v10.4s, v16.4s + add v11.4s, v11.4s, v17.4s + add v14.4s, v14.4s, v19.4s + + eor v6.16b, v6.16b, v12.16b + eor v7.16b, v7.16b, v13.16b + eor v8.16b, v8.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v9.16b, v9.16b, v14.16b + + ushr v20.4s, v6.4s, #20 + sli v20.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + ushr v7.4s, v8.4s, #20 + sli v7.4s, v8.4s, #12 + ushr v8.4s, v5.4s, #20 + sli v8.4s, v5.4s, #12 + ushr v5.4s, v9.4s, #20 + sli v5.4s, v9.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + add v3.4s, v3.4s, v8.4s + add v4.4s, v4.4s, v5.4s + + eor v18.16b, v18.16b, v0.16b + eor v15.16b, v15.16b, v1.16b + eor v16.16b, v16.16b, v2.16b + eor v17.16b, v17.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + tbl v18.16b, {v18.16b}, v26.16b + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + tbl v19.16b, {v19.16b}, v26.16b + + add v12.4s, v12.4s, v18.4s + add v13.4s, v13.4s, v15.4s + add v10.4s, v10.4s, v16.4s + add v11.4s, v11.4s, v17.4s + add v14.4s, v14.4s, v19.4s + + eor v20.16b, v20.16b, v12.16b + eor v6.16b, v6.16b, v13.16b + eor v7.16b, v7.16b, v10.16b + eor v8.16b, v8.16b, v11.16b + eor v5.16b, v5.16b, v14.16b + + ushr v9.4s, v5.4s, #25 + sli v9.4s, v5.4s, #7 + ushr v5.4s, v8.4s, #25 + sli v5.4s, v8.4s, #7 + ushr v8.4s, v7.4s, #25 + sli v8.4s, v7.4s, #7 + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v20.4s, #25 + sli v6.4s, v20.4s, #7 + + ext v9.16b, v9.16b, v9.16b, #12 + ext v14.16b, v14.16b, v14.16b, #8 + ext v19.16b, v19.16b, v19.16b, #4 + subs x7, x7, #1 + b.gt Lopen_main_loop_rounds + subs x6, x6, #1 + b.ge Lopen_main_loop_rounds_short + + eor v20.16b, v20.16b, v20.16b //zero + not v21.16b, v20.16b // -1 + sub v21.4s, v25.4s, v21.4s // Add +1 + ext v20.16b, v21.16b, v20.16b, #12 // Get the last element (counter) + add v19.4s, v19.4s, v20.4s + + add v15.4s, v15.4s, v25.4s + mov x11, #5 + dup v20.4s, w11 + add v25.4s, v25.4s, v20.4s + + zip1 v20.4s, v0.4s, v1.4s + zip2 v21.4s, v0.4s, v1.4s + zip1 v22.4s, v2.4s, v3.4s + zip2 v23.4s, v2.4s, v3.4s + + zip1 v0.2d, v20.2d, v22.2d + zip2 v1.2d, v20.2d, v22.2d + zip1 v2.2d, v21.2d, v23.2d + zip2 v3.2d, v21.2d, v23.2d + + zip1 v20.4s, v5.4s, v6.4s + zip2 v21.4s, v5.4s, v6.4s + zip1 v22.4s, v7.4s, v8.4s + zip2 v23.4s, v7.4s, v8.4s + + zip1 v5.2d, v20.2d, v22.2d + zip2 v6.2d, v20.2d, v22.2d + zip1 v7.2d, v21.2d, v23.2d + zip2 v8.2d, v21.2d, v23.2d + + zip1 v20.4s, v10.4s, v11.4s + zip2 v21.4s, v10.4s, v11.4s + zip1 v22.4s, v12.4s, v13.4s + zip2 v23.4s, v12.4s, v13.4s + + zip1 v10.2d, v20.2d, v22.2d + zip2 v11.2d, v20.2d, v22.2d + zip1 v12.2d, v21.2d, v23.2d + zip2 v13.2d, v21.2d, v23.2d + + zip1 v20.4s, v15.4s, v16.4s + zip2 v21.4s, v15.4s, v16.4s + zip1 v22.4s, v17.4s, v18.4s + zip2 v23.4s, v17.4s, v18.4s + + zip1 v15.2d, v20.2d, v22.2d + zip2 v16.2d, v20.2d, v22.2d + zip1 v17.2d, v21.2d, v23.2d + zip2 v18.2d, v21.2d, v23.2d + + add v0.4s, v0.4s, v24.4s + add v5.4s, v5.4s, v28.4s + add v10.4s, v10.4s, v29.4s + add v15.4s, v15.4s, v30.4s + + add v1.4s, v1.4s, v24.4s + add v6.4s, v6.4s, v28.4s + add v11.4s, v11.4s, v29.4s + add v16.4s, v16.4s, v30.4s + + add v2.4s, v2.4s, v24.4s + add v7.4s, v7.4s, v28.4s + add v12.4s, v12.4s, v29.4s + add v17.4s, v17.4s, v30.4s + + add v3.4s, v3.4s, v24.4s + add v8.4s, v8.4s, v28.4s + add v13.4s, v13.4s, v29.4s + add v18.4s, v18.4s, v30.4s + + add v4.4s, v4.4s, v24.4s + add v9.4s, v9.4s, v28.4s + add v14.4s, v14.4s, v29.4s + add v19.4s, v19.4s, v30.4s + + // We can always safely store 192 bytes + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v0.16b + eor v21.16b, v21.16b, v5.16b + eor v22.16b, v22.16b, v10.16b + eor v23.16b, v23.16b, v15.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v1.16b + eor v21.16b, v21.16b, v6.16b + eor v22.16b, v22.16b, v11.16b + eor v23.16b, v23.16b, v16.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v2.16b + eor v21.16b, v21.16b, v7.16b + eor v22.16b, v22.16b, v12.16b + eor v23.16b, v23.16b, v17.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + sub x2, x2, #192 + + mov v0.16b, v3.16b + mov v5.16b, v8.16b + mov v10.16b, v13.16b + mov v15.16b, v18.16b + + cmp x2, #64 + b.lt Lopen_tail_64_store + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v3.16b + eor v21.16b, v21.16b, v8.16b + eor v22.16b, v22.16b, v13.16b + eor v23.16b, v23.16b, v18.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + sub x2, x2, #64 + + mov v0.16b, v4.16b + mov v5.16b, v9.16b + mov v10.16b, v14.16b + mov v15.16b, v19.16b + + cmp x2, #64 + b.lt Lopen_tail_64_store + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v4.16b + eor v21.16b, v21.16b, v9.16b + eor v22.16b, v22.16b, v14.16b + eor v23.16b, v23.16b, v19.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + sub x2, x2, #64 + b Lopen_main_loop + +Lopen_tail: + + cbz x2, Lopen_finalize + + lsr x4, x2, #4 // How many whole blocks we have to hash + + cmp x2, #64 + b.le Lopen_tail_64 + cmp x2, #128 + b.le Lopen_tail_128 + +Lopen_tail_192: + // We need three more blocks + mov v0.16b, v24.16b + mov v1.16b, v24.16b + mov v2.16b, v24.16b + mov v5.16b, v28.16b + mov v6.16b, v28.16b + mov v7.16b, v28.16b + mov v10.16b, v29.16b + mov v11.16b, v29.16b + mov v12.16b, v29.16b + mov v15.16b, v30.16b + mov v16.16b, v30.16b + mov v17.16b, v30.16b + eor v23.16b, v23.16b, v23.16b + eor v21.16b, v21.16b, v21.16b + ins v23.s[0], v25.s[0] + ins v21.d[0], x15 + + add v22.4s, v23.4s, v21.4s + add v21.4s, v22.4s, v21.4s + + add v15.4s, v15.4s, v21.4s + add v16.4s, v16.4s, v23.4s + add v17.4s, v17.4s, v22.4s + + mov x7, #10 + subs x6, x7, x4 // itr1 can be negative if we have more than 160 bytes to hash + csel x7, x7, x4, le // if itr1 is zero or less, itr2 should be 10 to indicate all 10 rounds are hashing + sub x4, x4, x7 + + cbz x7, Lopen_tail_192_rounds_no_hash + +Lopen_tail_192_rounds: + ldp x11, x12, [x3], 16 + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most +Lopen_tail_192_rounds_no_hash: + add v0.4s, v0.4s, v5.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v5.16b, v5.16b, v10.16b + eor v6.16b, v6.16b, v11.16b + eor v7.16b, v7.16b, v12.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + ushr v5.4s, v6.4s, #20 + sli v5.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v5.4s + add v2.4s, v2.4s, v6.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v20.16b, v20.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v6.16b, v6.16b, v12.16b + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v5.4s, #25 + sli v6.4s, v5.4s, #7 + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + + ext v5.16b, v5.16b, v5.16b, #4 + ext v6.16b, v6.16b, v6.16b, #4 + ext v7.16b, v7.16b, v7.16b, #4 + + ext v10.16b, v10.16b, v10.16b, #8 + ext v11.16b, v11.16b, v11.16b, #8 + ext v12.16b, v12.16b, v12.16b, #8 + + ext v15.16b, v15.16b, v15.16b, #12 + ext v16.16b, v16.16b, v16.16b, #12 + ext v17.16b, v17.16b, v17.16b, #12 + add v0.4s, v0.4s, v5.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v5.16b, v5.16b, v10.16b + eor v6.16b, v6.16b, v11.16b + eor v7.16b, v7.16b, v12.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + ushr v5.4s, v6.4s, #20 + sli v5.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v5.4s + add v2.4s, v2.4s, v6.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v20.16b, v20.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v6.16b, v6.16b, v12.16b + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v5.4s, #25 + sli v6.4s, v5.4s, #7 + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + + ext v5.16b, v5.16b, v5.16b, #12 + ext v6.16b, v6.16b, v6.16b, #12 + ext v7.16b, v7.16b, v7.16b, #12 + + ext v10.16b, v10.16b, v10.16b, #8 + ext v11.16b, v11.16b, v11.16b, #8 + ext v12.16b, v12.16b, v12.16b, #8 + + ext v15.16b, v15.16b, v15.16b, #4 + ext v16.16b, v16.16b, v16.16b, #4 + ext v17.16b, v17.16b, v17.16b, #4 + subs x7, x7, #1 + b.gt Lopen_tail_192_rounds + subs x6, x6, #1 + b.ge Lopen_tail_192_rounds_no_hash + + // We hashed 160 bytes at most, may still have 32 bytes left +Lopen_tail_192_hash: + cbz x4, Lopen_tail_192_hash_done + ldp x11, x12, [x3], 16 + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + sub x4, x4, #1 + b Lopen_tail_192_hash + +Lopen_tail_192_hash_done: + + add v0.4s, v0.4s, v24.4s + add v1.4s, v1.4s, v24.4s + add v2.4s, v2.4s, v24.4s + add v5.4s, v5.4s, v28.4s + add v6.4s, v6.4s, v28.4s + add v7.4s, v7.4s, v28.4s + add v10.4s, v10.4s, v29.4s + add v11.4s, v11.4s, v29.4s + add v12.4s, v12.4s, v29.4s + add v15.4s, v15.4s, v30.4s + add v16.4s, v16.4s, v30.4s + add v17.4s, v17.4s, v30.4s + + add v15.4s, v15.4s, v21.4s + add v16.4s, v16.4s, v23.4s + add v17.4s, v17.4s, v22.4s + + ld1 {v20.16b - v23.16b}, [x1], #64 + + eor v20.16b, v20.16b, v1.16b + eor v21.16b, v21.16b, v6.16b + eor v22.16b, v22.16b, v11.16b + eor v23.16b, v23.16b, v16.16b + + st1 {v20.16b - v23.16b}, [x0], #64 + + ld1 {v20.16b - v23.16b}, [x1], #64 + + eor v20.16b, v20.16b, v2.16b + eor v21.16b, v21.16b, v7.16b + eor v22.16b, v22.16b, v12.16b + eor v23.16b, v23.16b, v17.16b + + st1 {v20.16b - v23.16b}, [x0], #64 + + sub x2, x2, #128 + b Lopen_tail_64_store + +Lopen_tail_128: + // We need two more blocks + mov v0.16b, v24.16b + mov v1.16b, v24.16b + mov v5.16b, v28.16b + mov v6.16b, v28.16b + mov v10.16b, v29.16b + mov v11.16b, v29.16b + mov v15.16b, v30.16b + mov v16.16b, v30.16b + eor v23.16b, v23.16b, v23.16b + eor v22.16b, v22.16b, v22.16b + ins v23.s[0], v25.s[0] + ins v22.d[0], x15 + add v22.4s, v22.4s, v23.4s + + add v15.4s, v15.4s, v22.4s + add v16.4s, v16.4s, v23.4s + + mov x6, #10 + sub x6, x6, x4 + +Lopen_tail_128_rounds: + add v0.4s, v0.4s, v5.4s + eor v15.16b, v15.16b, v0.16b + rev32 v15.8h, v15.8h + + add v10.4s, v10.4s, v15.4s + eor v5.16b, v5.16b, v10.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + add v0.4s, v0.4s, v20.4s + eor v15.16b, v15.16b, v0.16b + tbl v15.16b, {v15.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + eor v20.16b, v20.16b, v10.16b + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + ext v5.16b, v5.16b, v5.16b, #4 + ext v10.16b, v10.16b, v10.16b, #8 + ext v15.16b, v15.16b, v15.16b, #12 + add v1.4s, v1.4s, v6.4s + eor v16.16b, v16.16b, v1.16b + rev32 v16.8h, v16.8h + + add v11.4s, v11.4s, v16.4s + eor v6.16b, v6.16b, v11.16b + ushr v20.4s, v6.4s, #20 + sli v20.4s, v6.4s, #12 + add v1.4s, v1.4s, v20.4s + eor v16.16b, v16.16b, v1.16b + tbl v16.16b, {v16.16b}, v26.16b + + add v11.4s, v11.4s, v16.4s + eor v20.16b, v20.16b, v11.16b + ushr v6.4s, v20.4s, #25 + sli v6.4s, v20.4s, #7 + ext v6.16b, v6.16b, v6.16b, #4 + ext v11.16b, v11.16b, v11.16b, #8 + ext v16.16b, v16.16b, v16.16b, #12 + add v0.4s, v0.4s, v5.4s + eor v15.16b, v15.16b, v0.16b + rev32 v15.8h, v15.8h + + add v10.4s, v10.4s, v15.4s + eor v5.16b, v5.16b, v10.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + add v0.4s, v0.4s, v20.4s + eor v15.16b, v15.16b, v0.16b + tbl v15.16b, {v15.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + eor v20.16b, v20.16b, v10.16b + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + ext v5.16b, v5.16b, v5.16b, #12 + ext v10.16b, v10.16b, v10.16b, #8 + ext v15.16b, v15.16b, v15.16b, #4 + add v1.4s, v1.4s, v6.4s + eor v16.16b, v16.16b, v1.16b + rev32 v16.8h, v16.8h + + add v11.4s, v11.4s, v16.4s + eor v6.16b, v6.16b, v11.16b + ushr v20.4s, v6.4s, #20 + sli v20.4s, v6.4s, #12 + add v1.4s, v1.4s, v20.4s + eor v16.16b, v16.16b, v1.16b + tbl v16.16b, {v16.16b}, v26.16b + + add v11.4s, v11.4s, v16.4s + eor v20.16b, v20.16b, v11.16b + ushr v6.4s, v20.4s, #25 + sli v6.4s, v20.4s, #7 + ext v6.16b, v6.16b, v6.16b, #12 + ext v11.16b, v11.16b, v11.16b, #8 + ext v16.16b, v16.16b, v16.16b, #4 + subs x6, x6, #1 + b.gt Lopen_tail_128_rounds + cbz x4, Lopen_tail_128_rounds_done + subs x4, x4, #1 + ldp x11, x12, [x3], 16 + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + b Lopen_tail_128_rounds + +Lopen_tail_128_rounds_done: + add v0.4s, v0.4s, v24.4s + add v1.4s, v1.4s, v24.4s + add v5.4s, v5.4s, v28.4s + add v6.4s, v6.4s, v28.4s + add v10.4s, v10.4s, v29.4s + add v11.4s, v11.4s, v29.4s + add v15.4s, v15.4s, v30.4s + add v16.4s, v16.4s, v30.4s + add v15.4s, v15.4s, v22.4s + add v16.4s, v16.4s, v23.4s + + ld1 {v20.16b - v23.16b}, [x1], #64 + + eor v20.16b, v20.16b, v1.16b + eor v21.16b, v21.16b, v6.16b + eor v22.16b, v22.16b, v11.16b + eor v23.16b, v23.16b, v16.16b + + st1 {v20.16b - v23.16b}, [x0], #64 + sub x2, x2, #64 + + b Lopen_tail_64_store + +Lopen_tail_64: + // We just need a single block + mov v0.16b, v24.16b + mov v5.16b, v28.16b + mov v10.16b, v29.16b + mov v15.16b, v30.16b + eor v23.16b, v23.16b, v23.16b + ins v23.s[0], v25.s[0] + add v15.4s, v15.4s, v23.4s + + mov x6, #10 + sub x6, x6, x4 + +Lopen_tail_64_rounds: + add v0.4s, v0.4s, v5.4s + eor v15.16b, v15.16b, v0.16b + rev32 v15.8h, v15.8h + + add v10.4s, v10.4s, v15.4s + eor v5.16b, v5.16b, v10.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + add v0.4s, v0.4s, v20.4s + eor v15.16b, v15.16b, v0.16b + tbl v15.16b, {v15.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + eor v20.16b, v20.16b, v10.16b + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + ext v5.16b, v5.16b, v5.16b, #4 + ext v10.16b, v10.16b, v10.16b, #8 + ext v15.16b, v15.16b, v15.16b, #12 + add v0.4s, v0.4s, v5.4s + eor v15.16b, v15.16b, v0.16b + rev32 v15.8h, v15.8h + + add v10.4s, v10.4s, v15.4s + eor v5.16b, v5.16b, v10.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + add v0.4s, v0.4s, v20.4s + eor v15.16b, v15.16b, v0.16b + tbl v15.16b, {v15.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + eor v20.16b, v20.16b, v10.16b + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + ext v5.16b, v5.16b, v5.16b, #12 + ext v10.16b, v10.16b, v10.16b, #8 + ext v15.16b, v15.16b, v15.16b, #4 + subs x6, x6, #1 + b.gt Lopen_tail_64_rounds + cbz x4, Lopen_tail_64_rounds_done + subs x4, x4, #1 + ldp x11, x12, [x3], 16 + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + b Lopen_tail_64_rounds + +Lopen_tail_64_rounds_done: + add v0.4s, v0.4s, v24.4s + add v5.4s, v5.4s, v28.4s + add v10.4s, v10.4s, v29.4s + add v15.4s, v15.4s, v30.4s + add v15.4s, v15.4s, v23.4s + +Lopen_tail_64_store: + cmp x2, #16 + b.lt Lopen_tail_16 + + ld1 {v20.16b}, [x1], #16 + eor v20.16b, v20.16b, v0.16b + st1 {v20.16b}, [x0], #16 + mov v0.16b, v5.16b + mov v5.16b, v10.16b + mov v10.16b, v15.16b + sub x2, x2, #16 + b Lopen_tail_64_store + +Lopen_tail_16: + // Here we handle the last [0,16) bytes that require a padded block + cbz x2, Lopen_finalize + + eor v20.16b, v20.16b, v20.16b // Use T0 to load the ciphertext + eor v21.16b, v21.16b, v21.16b // Use T1 to generate an AND mask + not v22.16b, v20.16b + + add x7, x1, x2 + mov x6, x2 + +Lopen_tail_16_compose: + ext v20.16b, v20.16b, v20.16b, #15 + ldrb w11, [x7, #-1]! + mov v20.b[0], w11 + ext v21.16b, v22.16b, v21.16b, #15 + subs x2, x2, #1 + b.gt Lopen_tail_16_compose + + and v20.16b, v20.16b, v21.16b + // Hash in the final padded block + mov x11, v20.d[0] + mov x12, v20.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + eor v20.16b, v20.16b, v0.16b + +Lopen_tail_16_store: + umov w11, v20.b[0] + strb w11, [x0], #1 + ext v20.16b, v20.16b, v20.16b, #1 + subs x6, x6, #1 + b.gt Lopen_tail_16_store + +Lopen_finalize: + mov x11, v31.d[0] + mov x12, v31.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + // Final reduction step + sub x12, xzr, x15 + orr x13, xzr, #3 + subs x11, x8, #-5 + sbcs x12, x9, x12 + sbcs x13, x10, x13 + csel x8, x11, x8, cs + csel x9, x12, x9, cs + csel x10, x13, x10, cs + mov x11, v27.d[0] + mov x12, v27.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + + stp x8, x9, [x5] + + ldp d8, d9, [sp, #16] + ldp d10, d11, [sp, #32] + ldp d12, d13, [sp, #48] + ldp d14, d15, [sp, #64] +.cfi_restore b15 +.cfi_restore b14 +.cfi_restore b13 +.cfi_restore b12 +.cfi_restore b11 +.cfi_restore b10 +.cfi_restore b9 +.cfi_restore b8 + ldp x29, x30, [sp], 80 +.cfi_restore w29 +.cfi_restore w30 +.cfi_def_cfa_offset 0 + AARCH64_VALIDATE_LINK_REGISTER + ret + +Lopen_128: + // On some architectures preparing 5 blocks for small buffers is wasteful + eor v25.16b, v25.16b, v25.16b + mov x11, #1 + mov v25.s[0], w11 + mov v0.16b, v24.16b + mov v1.16b, v24.16b + mov v2.16b, v24.16b + mov v5.16b, v28.16b + mov v6.16b, v28.16b + mov v7.16b, v28.16b + mov v10.16b, v29.16b + mov v11.16b, v29.16b + mov v12.16b, v29.16b + mov v17.16b, v30.16b + add v15.4s, v17.4s, v25.4s + add v16.4s, v15.4s, v25.4s + + mov x6, #10 + +Lopen_128_rounds: + add v0.4s, v0.4s, v5.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v5.16b, v5.16b, v10.16b + eor v6.16b, v6.16b, v11.16b + eor v7.16b, v7.16b, v12.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + ushr v5.4s, v6.4s, #20 + sli v5.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v5.4s + add v2.4s, v2.4s, v6.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v20.16b, v20.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v6.16b, v6.16b, v12.16b + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v5.4s, #25 + sli v6.4s, v5.4s, #7 + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + + ext v5.16b, v5.16b, v5.16b, #4 + ext v6.16b, v6.16b, v6.16b, #4 + ext v7.16b, v7.16b, v7.16b, #4 + + ext v10.16b, v10.16b, v10.16b, #8 + ext v11.16b, v11.16b, v11.16b, #8 + ext v12.16b, v12.16b, v12.16b, #8 + + ext v15.16b, v15.16b, v15.16b, #12 + ext v16.16b, v16.16b, v16.16b, #12 + ext v17.16b, v17.16b, v17.16b, #12 + add v0.4s, v0.4s, v5.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v5.16b, v5.16b, v10.16b + eor v6.16b, v6.16b, v11.16b + eor v7.16b, v7.16b, v12.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + ushr v5.4s, v6.4s, #20 + sli v5.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v5.4s + add v2.4s, v2.4s, v6.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v20.16b, v20.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v6.16b, v6.16b, v12.16b + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v5.4s, #25 + sli v6.4s, v5.4s, #7 + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + + ext v5.16b, v5.16b, v5.16b, #12 + ext v6.16b, v6.16b, v6.16b, #12 + ext v7.16b, v7.16b, v7.16b, #12 + + ext v10.16b, v10.16b, v10.16b, #8 + ext v11.16b, v11.16b, v11.16b, #8 + ext v12.16b, v12.16b, v12.16b, #8 + + ext v15.16b, v15.16b, v15.16b, #4 + ext v16.16b, v16.16b, v16.16b, #4 + ext v17.16b, v17.16b, v17.16b, #4 + subs x6, x6, #1 + b.hi Lopen_128_rounds + + add v0.4s, v0.4s, v24.4s + add v1.4s, v1.4s, v24.4s + add v2.4s, v2.4s, v24.4s + + add v5.4s, v5.4s, v28.4s + add v6.4s, v6.4s, v28.4s + add v7.4s, v7.4s, v28.4s + + add v10.4s, v10.4s, v29.4s + add v11.4s, v11.4s, v29.4s + + add v30.4s, v30.4s, v25.4s + add v15.4s, v15.4s, v30.4s + add v30.4s, v30.4s, v25.4s + add v16.4s, v16.4s, v30.4s + + and v2.16b, v2.16b, v27.16b + mov x16, v2.d[0] // Move the R key to GPRs + mov x17, v2.d[1] + mov v27.16b, v7.16b // Store the S key + + bl Lpoly_hash_ad_internal + +Lopen_128_store: + cmp x2, #64 + b.lt Lopen_128_store_64 + + ld1 {v20.16b - v23.16b}, [x1], #64 + + mov x11, v20.d[0] + mov x12, v20.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + mov x11, v21.d[0] + mov x12, v21.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + mov x11, v22.d[0] + mov x12, v22.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + mov x11, v23.d[0] + mov x12, v23.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + + eor v20.16b, v20.16b, v0.16b + eor v21.16b, v21.16b, v5.16b + eor v22.16b, v22.16b, v10.16b + eor v23.16b, v23.16b, v15.16b + + st1 {v20.16b - v23.16b}, [x0], #64 + + sub x2, x2, #64 + + mov v0.16b, v1.16b + mov v5.16b, v6.16b + mov v10.16b, v11.16b + mov v15.16b, v16.16b + +Lopen_128_store_64: + + lsr x4, x2, #4 + mov x3, x1 + +Lopen_128_hash_64: + cbz x4, Lopen_tail_64_store + ldp x11, x12, [x3], 16 + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + sub x4, x4, #1 + b Lopen_128_hash_64 +.cfi_endproc + +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__APPLE__) diff --git a/http/vendor/ring/pregenerated/chacha20_poly1305_armv8-linux64.S b/http/vendor/ring/pregenerated/chacha20_poly1305_armv8-linux64.S new file mode 100644 index 0000000..611f436 --- /dev/null +++ b/http/vendor/ring/pregenerated/chacha20_poly1305_armv8-linux64.S @@ -0,0 +1,3008 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__ELF__) +.section .rodata + +.align 7 +.Lchacha20_consts: +.byte 'e','x','p','a','n','d',' ','3','2','-','b','y','t','e',' ','k' +.Linc: +.long 1,2,3,4 +.Lrol8: +.byte 3,0,1,2, 7,4,5,6, 11,8,9,10, 15,12,13,14 +.Lclamp: +.quad 0x0FFFFFFC0FFFFFFF, 0x0FFFFFFC0FFFFFFC + +.text + +.type .Lpoly_hash_ad_internal,%function +.align 6 +.Lpoly_hash_ad_internal: +.cfi_startproc + cbnz x4, .Lpoly_hash_intro + ret + +.Lpoly_hash_intro: + cmp x4, #16 + b.lt .Lpoly_hash_ad_tail + ldp x11, x12, [x3], 16 + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + sub x4, x4, #16 + b .Lpoly_hash_ad_internal + +.Lpoly_hash_ad_tail: + cbz x4, .Lpoly_hash_ad_ret + + eor v20.16b, v20.16b, v20.16b // Use T0 to load the AAD + sub x4, x4, #1 + +.Lpoly_hash_tail_16_compose: + ext v20.16b, v20.16b, v20.16b, #15 + ldrb w11, [x3, x4] + mov v20.b[0], w11 + subs x4, x4, #1 + b.ge .Lpoly_hash_tail_16_compose + mov x11, v20.d[0] + mov x12, v20.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + +.Lpoly_hash_ad_ret: + ret +.cfi_endproc +.size .Lpoly_hash_ad_internal, .-.Lpoly_hash_ad_internal + +///////////////////////////////// +// +// void chacha20_poly1305_seal(uint8_t *pt, uint8_t *ct, size_t len_in, uint8_t *ad, size_t len_ad, union open_data *seal_data); +// +.globl chacha20_poly1305_seal +.hidden chacha20_poly1305_seal +.type chacha20_poly1305_seal,%function +.align 6 +chacha20_poly1305_seal: + AARCH64_SIGN_LINK_REGISTER +.cfi_startproc + stp x29, x30, [sp, #-80]! +.cfi_def_cfa_offset 80 +.cfi_offset w30, -72 +.cfi_offset w29, -80 + mov x29, sp + // We probably could do .cfi_def_cfa w29, 80 at this point, but since + // we don't actually use the frame pointer like that, it's probably not + // worth bothering. + stp d8, d9, [sp, #16] + stp d10, d11, [sp, #32] + stp d12, d13, [sp, #48] + stp d14, d15, [sp, #64] +.cfi_offset b15, -8 +.cfi_offset b14, -16 +.cfi_offset b13, -24 +.cfi_offset b12, -32 +.cfi_offset b11, -40 +.cfi_offset b10, -48 +.cfi_offset b9, -56 +.cfi_offset b8, -64 + + adrp x11, .Lchacha20_consts + add x11, x11, :lo12:.Lchacha20_consts + + ld1 {v24.16b - v27.16b}, [x11] // .Load the CONSTS, INC, ROL8 and CLAMP values + ld1 {v28.16b - v30.16b}, [x5] + + mov x15, #1 // Prepare the Poly1305 state + mov x8, #0 + mov x9, #0 + mov x10, #0 + + ldr x12, [x5, #56] // The total cipher text length includes extra_in_len + add x12, x12, x2 + mov v31.d[0], x4 // Store the input and aad lengths + mov v31.d[1], x12 + + cmp x2, #128 + b.le .Lseal_128 // Optimization for smaller buffers + + // Initially we prepare 5 ChaCha20 blocks. Four to encrypt up to 4 blocks (256 bytes) of plaintext, + // and one for the Poly1305 R and S keys. The first four blocks (A0-A3..D0-D3) are computed vertically, + // the fifth block (A4-D4) horizontally. + ld4r {v0.4s,v1.4s,v2.4s,v3.4s}, [x11] + mov v4.16b, v24.16b + + ld4r {v5.4s,v6.4s,v7.4s,v8.4s}, [x5], #16 + mov v9.16b, v28.16b + + ld4r {v10.4s,v11.4s,v12.4s,v13.4s}, [x5], #16 + mov v14.16b, v29.16b + + ld4r {v15.4s,v16.4s,v17.4s,v18.4s}, [x5] + add v15.4s, v15.4s, v25.4s + mov v19.16b, v30.16b + + sub x5, x5, #32 + + mov x6, #10 + +.align 5 +.Lseal_init_rounds: + add v0.4s, v0.4s, v5.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + add v3.4s, v3.4s, v8.4s + add v4.4s, v4.4s, v9.4s + + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + eor v18.16b, v18.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + rev32 v18.8h, v18.8h + rev32 v19.8h, v19.8h + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + add v13.4s, v13.4s, v18.4s + add v14.4s, v14.4s, v19.4s + + eor v5.16b, v5.16b, v10.16b + eor v6.16b, v6.16b, v11.16b + eor v7.16b, v7.16b, v12.16b + eor v8.16b, v8.16b, v13.16b + eor v9.16b, v9.16b, v14.16b + + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + ushr v5.4s, v6.4s, #20 + sli v5.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + ushr v7.4s, v8.4s, #20 + sli v7.4s, v8.4s, #12 + ushr v8.4s, v9.4s, #20 + sli v8.4s, v9.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v5.4s + add v2.4s, v2.4s, v6.4s + add v3.4s, v3.4s, v7.4s + add v4.4s, v4.4s, v8.4s + + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + eor v18.16b, v18.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + tbl v18.16b, {v18.16b}, v26.16b + tbl v19.16b, {v19.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + add v13.4s, v13.4s, v18.4s + add v14.4s, v14.4s, v19.4s + + eor v20.16b, v20.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v6.16b, v6.16b, v12.16b + eor v7.16b, v7.16b, v13.16b + eor v8.16b, v8.16b, v14.16b + + ushr v9.4s, v8.4s, #25 + sli v9.4s, v8.4s, #7 + ushr v8.4s, v7.4s, #25 + sli v8.4s, v7.4s, #7 + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v5.4s, #25 + sli v6.4s, v5.4s, #7 + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + + ext v9.16b, v9.16b, v9.16b, #4 + ext v14.16b, v14.16b, v14.16b, #8 + ext v19.16b, v19.16b, v19.16b, #12 + add v0.4s, v0.4s, v6.4s + add v1.4s, v1.4s, v7.4s + add v2.4s, v2.4s, v8.4s + add v3.4s, v3.4s, v5.4s + add v4.4s, v4.4s, v9.4s + + eor v18.16b, v18.16b, v0.16b + eor v15.16b, v15.16b, v1.16b + eor v16.16b, v16.16b, v2.16b + eor v17.16b, v17.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + rev32 v18.8h, v18.8h + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + rev32 v19.8h, v19.8h + + add v12.4s, v12.4s, v18.4s + add v13.4s, v13.4s, v15.4s + add v10.4s, v10.4s, v16.4s + add v11.4s, v11.4s, v17.4s + add v14.4s, v14.4s, v19.4s + + eor v6.16b, v6.16b, v12.16b + eor v7.16b, v7.16b, v13.16b + eor v8.16b, v8.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v9.16b, v9.16b, v14.16b + + ushr v20.4s, v6.4s, #20 + sli v20.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + ushr v7.4s, v8.4s, #20 + sli v7.4s, v8.4s, #12 + ushr v8.4s, v5.4s, #20 + sli v8.4s, v5.4s, #12 + ushr v5.4s, v9.4s, #20 + sli v5.4s, v9.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + add v3.4s, v3.4s, v8.4s + add v4.4s, v4.4s, v5.4s + + eor v18.16b, v18.16b, v0.16b + eor v15.16b, v15.16b, v1.16b + eor v16.16b, v16.16b, v2.16b + eor v17.16b, v17.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + tbl v18.16b, {v18.16b}, v26.16b + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + tbl v19.16b, {v19.16b}, v26.16b + + add v12.4s, v12.4s, v18.4s + add v13.4s, v13.4s, v15.4s + add v10.4s, v10.4s, v16.4s + add v11.4s, v11.4s, v17.4s + add v14.4s, v14.4s, v19.4s + + eor v20.16b, v20.16b, v12.16b + eor v6.16b, v6.16b, v13.16b + eor v7.16b, v7.16b, v10.16b + eor v8.16b, v8.16b, v11.16b + eor v5.16b, v5.16b, v14.16b + + ushr v9.4s, v5.4s, #25 + sli v9.4s, v5.4s, #7 + ushr v5.4s, v8.4s, #25 + sli v5.4s, v8.4s, #7 + ushr v8.4s, v7.4s, #25 + sli v8.4s, v7.4s, #7 + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v20.4s, #25 + sli v6.4s, v20.4s, #7 + + ext v9.16b, v9.16b, v9.16b, #12 + ext v14.16b, v14.16b, v14.16b, #8 + ext v19.16b, v19.16b, v19.16b, #4 + subs x6, x6, #1 + b.hi .Lseal_init_rounds + + add v15.4s, v15.4s, v25.4s + mov x11, #4 + dup v20.4s, w11 + add v25.4s, v25.4s, v20.4s + + zip1 v20.4s, v0.4s, v1.4s + zip2 v21.4s, v0.4s, v1.4s + zip1 v22.4s, v2.4s, v3.4s + zip2 v23.4s, v2.4s, v3.4s + + zip1 v0.2d, v20.2d, v22.2d + zip2 v1.2d, v20.2d, v22.2d + zip1 v2.2d, v21.2d, v23.2d + zip2 v3.2d, v21.2d, v23.2d + + zip1 v20.4s, v5.4s, v6.4s + zip2 v21.4s, v5.4s, v6.4s + zip1 v22.4s, v7.4s, v8.4s + zip2 v23.4s, v7.4s, v8.4s + + zip1 v5.2d, v20.2d, v22.2d + zip2 v6.2d, v20.2d, v22.2d + zip1 v7.2d, v21.2d, v23.2d + zip2 v8.2d, v21.2d, v23.2d + + zip1 v20.4s, v10.4s, v11.4s + zip2 v21.4s, v10.4s, v11.4s + zip1 v22.4s, v12.4s, v13.4s + zip2 v23.4s, v12.4s, v13.4s + + zip1 v10.2d, v20.2d, v22.2d + zip2 v11.2d, v20.2d, v22.2d + zip1 v12.2d, v21.2d, v23.2d + zip2 v13.2d, v21.2d, v23.2d + + zip1 v20.4s, v15.4s, v16.4s + zip2 v21.4s, v15.4s, v16.4s + zip1 v22.4s, v17.4s, v18.4s + zip2 v23.4s, v17.4s, v18.4s + + zip1 v15.2d, v20.2d, v22.2d + zip2 v16.2d, v20.2d, v22.2d + zip1 v17.2d, v21.2d, v23.2d + zip2 v18.2d, v21.2d, v23.2d + + add v4.4s, v4.4s, v24.4s + add v9.4s, v9.4s, v28.4s + and v4.16b, v4.16b, v27.16b + + add v0.4s, v0.4s, v24.4s + add v5.4s, v5.4s, v28.4s + add v10.4s, v10.4s, v29.4s + add v15.4s, v15.4s, v30.4s + + add v1.4s, v1.4s, v24.4s + add v6.4s, v6.4s, v28.4s + add v11.4s, v11.4s, v29.4s + add v16.4s, v16.4s, v30.4s + + add v2.4s, v2.4s, v24.4s + add v7.4s, v7.4s, v28.4s + add v12.4s, v12.4s, v29.4s + add v17.4s, v17.4s, v30.4s + + add v3.4s, v3.4s, v24.4s + add v8.4s, v8.4s, v28.4s + add v13.4s, v13.4s, v29.4s + add v18.4s, v18.4s, v30.4s + + mov x16, v4.d[0] // Move the R key to GPRs + mov x17, v4.d[1] + mov v27.16b, v9.16b // Store the S key + + bl .Lpoly_hash_ad_internal + + mov x3, x0 + cmp x2, #256 + b.le .Lseal_tail + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v0.16b + eor v21.16b, v21.16b, v5.16b + eor v22.16b, v22.16b, v10.16b + eor v23.16b, v23.16b, v15.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v1.16b + eor v21.16b, v21.16b, v6.16b + eor v22.16b, v22.16b, v11.16b + eor v23.16b, v23.16b, v16.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v2.16b + eor v21.16b, v21.16b, v7.16b + eor v22.16b, v22.16b, v12.16b + eor v23.16b, v23.16b, v17.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v3.16b + eor v21.16b, v21.16b, v8.16b + eor v22.16b, v22.16b, v13.16b + eor v23.16b, v23.16b, v18.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + sub x2, x2, #256 + + mov x6, #4 // In the first run of the loop we need to hash 256 bytes, therefore we hash one block for the first 4 rounds + mov x7, #6 // and two blocks for the remaining 6, for a total of (1 * 4 + 2 * 6) * 16 = 256 + +.Lseal_main_loop: + adrp x11, .Lchacha20_consts + add x11, x11, :lo12:.Lchacha20_consts + + ld4r {v0.4s,v1.4s,v2.4s,v3.4s}, [x11] + mov v4.16b, v24.16b + + ld4r {v5.4s,v6.4s,v7.4s,v8.4s}, [x5], #16 + mov v9.16b, v28.16b + + ld4r {v10.4s,v11.4s,v12.4s,v13.4s}, [x5], #16 + mov v14.16b, v29.16b + + ld4r {v15.4s,v16.4s,v17.4s,v18.4s}, [x5] + add v15.4s, v15.4s, v25.4s + mov v19.16b, v30.16b + + eor v20.16b, v20.16b, v20.16b //zero + not v21.16b, v20.16b // -1 + sub v21.4s, v25.4s, v21.4s // Add +1 + ext v20.16b, v21.16b, v20.16b, #12 // Get the last element (counter) + add v19.4s, v19.4s, v20.4s + + sub x5, x5, #32 +.align 5 +.Lseal_main_loop_rounds: + add v0.4s, v0.4s, v5.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + add v3.4s, v3.4s, v8.4s + add v4.4s, v4.4s, v9.4s + + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + eor v18.16b, v18.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + rev32 v18.8h, v18.8h + rev32 v19.8h, v19.8h + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + add v13.4s, v13.4s, v18.4s + add v14.4s, v14.4s, v19.4s + + eor v5.16b, v5.16b, v10.16b + eor v6.16b, v6.16b, v11.16b + eor v7.16b, v7.16b, v12.16b + eor v8.16b, v8.16b, v13.16b + eor v9.16b, v9.16b, v14.16b + + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + ushr v5.4s, v6.4s, #20 + sli v5.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + ushr v7.4s, v8.4s, #20 + sli v7.4s, v8.4s, #12 + ushr v8.4s, v9.4s, #20 + sli v8.4s, v9.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v5.4s + add v2.4s, v2.4s, v6.4s + add v3.4s, v3.4s, v7.4s + add v4.4s, v4.4s, v8.4s + + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + eor v18.16b, v18.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + tbl v18.16b, {v18.16b}, v26.16b + tbl v19.16b, {v19.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + add v13.4s, v13.4s, v18.4s + add v14.4s, v14.4s, v19.4s + + eor v20.16b, v20.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v6.16b, v6.16b, v12.16b + eor v7.16b, v7.16b, v13.16b + eor v8.16b, v8.16b, v14.16b + + ushr v9.4s, v8.4s, #25 + sli v9.4s, v8.4s, #7 + ushr v8.4s, v7.4s, #25 + sli v8.4s, v7.4s, #7 + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v5.4s, #25 + sli v6.4s, v5.4s, #7 + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + + ext v9.16b, v9.16b, v9.16b, #4 + ext v14.16b, v14.16b, v14.16b, #8 + ext v19.16b, v19.16b, v19.16b, #12 + ldp x11, x12, [x3], 16 + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + add v0.4s, v0.4s, v6.4s + add v1.4s, v1.4s, v7.4s + add v2.4s, v2.4s, v8.4s + add v3.4s, v3.4s, v5.4s + add v4.4s, v4.4s, v9.4s + + eor v18.16b, v18.16b, v0.16b + eor v15.16b, v15.16b, v1.16b + eor v16.16b, v16.16b, v2.16b + eor v17.16b, v17.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + rev32 v18.8h, v18.8h + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + rev32 v19.8h, v19.8h + + add v12.4s, v12.4s, v18.4s + add v13.4s, v13.4s, v15.4s + add v10.4s, v10.4s, v16.4s + add v11.4s, v11.4s, v17.4s + add v14.4s, v14.4s, v19.4s + + eor v6.16b, v6.16b, v12.16b + eor v7.16b, v7.16b, v13.16b + eor v8.16b, v8.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v9.16b, v9.16b, v14.16b + + ushr v20.4s, v6.4s, #20 + sli v20.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + ushr v7.4s, v8.4s, #20 + sli v7.4s, v8.4s, #12 + ushr v8.4s, v5.4s, #20 + sli v8.4s, v5.4s, #12 + ushr v5.4s, v9.4s, #20 + sli v5.4s, v9.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + add v3.4s, v3.4s, v8.4s + add v4.4s, v4.4s, v5.4s + + eor v18.16b, v18.16b, v0.16b + eor v15.16b, v15.16b, v1.16b + eor v16.16b, v16.16b, v2.16b + eor v17.16b, v17.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + tbl v18.16b, {v18.16b}, v26.16b + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + tbl v19.16b, {v19.16b}, v26.16b + + add v12.4s, v12.4s, v18.4s + add v13.4s, v13.4s, v15.4s + add v10.4s, v10.4s, v16.4s + add v11.4s, v11.4s, v17.4s + add v14.4s, v14.4s, v19.4s + + eor v20.16b, v20.16b, v12.16b + eor v6.16b, v6.16b, v13.16b + eor v7.16b, v7.16b, v10.16b + eor v8.16b, v8.16b, v11.16b + eor v5.16b, v5.16b, v14.16b + + ushr v9.4s, v5.4s, #25 + sli v9.4s, v5.4s, #7 + ushr v5.4s, v8.4s, #25 + sli v5.4s, v8.4s, #7 + ushr v8.4s, v7.4s, #25 + sli v8.4s, v7.4s, #7 + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v20.4s, #25 + sli v6.4s, v20.4s, #7 + + ext v9.16b, v9.16b, v9.16b, #12 + ext v14.16b, v14.16b, v14.16b, #8 + ext v19.16b, v19.16b, v19.16b, #4 + subs x6, x6, #1 + b.ge .Lseal_main_loop_rounds + ldp x11, x12, [x3], 16 + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + subs x7, x7, #1 + b.gt .Lseal_main_loop_rounds + + eor v20.16b, v20.16b, v20.16b //zero + not v21.16b, v20.16b // -1 + sub v21.4s, v25.4s, v21.4s // Add +1 + ext v20.16b, v21.16b, v20.16b, #12 // Get the last element (counter) + add v19.4s, v19.4s, v20.4s + + add v15.4s, v15.4s, v25.4s + mov x11, #5 + dup v20.4s, w11 + add v25.4s, v25.4s, v20.4s + + zip1 v20.4s, v0.4s, v1.4s + zip2 v21.4s, v0.4s, v1.4s + zip1 v22.4s, v2.4s, v3.4s + zip2 v23.4s, v2.4s, v3.4s + + zip1 v0.2d, v20.2d, v22.2d + zip2 v1.2d, v20.2d, v22.2d + zip1 v2.2d, v21.2d, v23.2d + zip2 v3.2d, v21.2d, v23.2d + + zip1 v20.4s, v5.4s, v6.4s + zip2 v21.4s, v5.4s, v6.4s + zip1 v22.4s, v7.4s, v8.4s + zip2 v23.4s, v7.4s, v8.4s + + zip1 v5.2d, v20.2d, v22.2d + zip2 v6.2d, v20.2d, v22.2d + zip1 v7.2d, v21.2d, v23.2d + zip2 v8.2d, v21.2d, v23.2d + + zip1 v20.4s, v10.4s, v11.4s + zip2 v21.4s, v10.4s, v11.4s + zip1 v22.4s, v12.4s, v13.4s + zip2 v23.4s, v12.4s, v13.4s + + zip1 v10.2d, v20.2d, v22.2d + zip2 v11.2d, v20.2d, v22.2d + zip1 v12.2d, v21.2d, v23.2d + zip2 v13.2d, v21.2d, v23.2d + + zip1 v20.4s, v15.4s, v16.4s + zip2 v21.4s, v15.4s, v16.4s + zip1 v22.4s, v17.4s, v18.4s + zip2 v23.4s, v17.4s, v18.4s + + zip1 v15.2d, v20.2d, v22.2d + zip2 v16.2d, v20.2d, v22.2d + zip1 v17.2d, v21.2d, v23.2d + zip2 v18.2d, v21.2d, v23.2d + + add v0.4s, v0.4s, v24.4s + add v5.4s, v5.4s, v28.4s + add v10.4s, v10.4s, v29.4s + add v15.4s, v15.4s, v30.4s + + add v1.4s, v1.4s, v24.4s + add v6.4s, v6.4s, v28.4s + add v11.4s, v11.4s, v29.4s + add v16.4s, v16.4s, v30.4s + + add v2.4s, v2.4s, v24.4s + add v7.4s, v7.4s, v28.4s + add v12.4s, v12.4s, v29.4s + add v17.4s, v17.4s, v30.4s + + add v3.4s, v3.4s, v24.4s + add v8.4s, v8.4s, v28.4s + add v13.4s, v13.4s, v29.4s + add v18.4s, v18.4s, v30.4s + + add v4.4s, v4.4s, v24.4s + add v9.4s, v9.4s, v28.4s + add v14.4s, v14.4s, v29.4s + add v19.4s, v19.4s, v30.4s + + cmp x2, #320 + b.le .Lseal_tail + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v0.16b + eor v21.16b, v21.16b, v5.16b + eor v22.16b, v22.16b, v10.16b + eor v23.16b, v23.16b, v15.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v1.16b + eor v21.16b, v21.16b, v6.16b + eor v22.16b, v22.16b, v11.16b + eor v23.16b, v23.16b, v16.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v2.16b + eor v21.16b, v21.16b, v7.16b + eor v22.16b, v22.16b, v12.16b + eor v23.16b, v23.16b, v17.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v3.16b + eor v21.16b, v21.16b, v8.16b + eor v22.16b, v22.16b, v13.16b + eor v23.16b, v23.16b, v18.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v4.16b + eor v21.16b, v21.16b, v9.16b + eor v22.16b, v22.16b, v14.16b + eor v23.16b, v23.16b, v19.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + sub x2, x2, #320 + + mov x6, #0 + mov x7, #10 // For the remainder of the loop we always hash and encrypt 320 bytes per iteration + + b .Lseal_main_loop + +.Lseal_tail: + // This part of the function handles the storage and authentication of the last [0,320) bytes + // We assume A0-A4 ... D0-D4 hold at least inl (320 max) bytes of the stream data. + cmp x2, #64 + b.lt .Lseal_tail_64 + + // Store and authenticate 64B blocks per iteration + ld1 {v20.16b - v23.16b}, [x1], #64 + + eor v20.16b, v20.16b, v0.16b + eor v21.16b, v21.16b, v5.16b + eor v22.16b, v22.16b, v10.16b + eor v23.16b, v23.16b, v15.16b + mov x11, v20.d[0] + mov x12, v20.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + mov x11, v21.d[0] + mov x12, v21.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + mov x11, v22.d[0] + mov x12, v22.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + mov x11, v23.d[0] + mov x12, v23.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + st1 {v20.16b - v23.16b}, [x0], #64 + sub x2, x2, #64 + + // Shift the state left by 64 bytes for the next iteration of the loop + mov v0.16b, v1.16b + mov v5.16b, v6.16b + mov v10.16b, v11.16b + mov v15.16b, v16.16b + + mov v1.16b, v2.16b + mov v6.16b, v7.16b + mov v11.16b, v12.16b + mov v16.16b, v17.16b + + mov v2.16b, v3.16b + mov v7.16b, v8.16b + mov v12.16b, v13.16b + mov v17.16b, v18.16b + + mov v3.16b, v4.16b + mov v8.16b, v9.16b + mov v13.16b, v14.16b + mov v18.16b, v19.16b + + b .Lseal_tail + +.Lseal_tail_64: + ldp x3, x4, [x5, #48] // extra_in_len and extra_in_ptr + + // Here we handle the last [0,64) bytes of plaintext + cmp x2, #16 + b.lt .Lseal_tail_16 + // Each iteration encrypt and authenticate a 16B block + ld1 {v20.16b}, [x1], #16 + eor v20.16b, v20.16b, v0.16b + mov x11, v20.d[0] + mov x12, v20.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + st1 {v20.16b}, [x0], #16 + + sub x2, x2, #16 + + // Shift the state left by 16 bytes for the next iteration of the loop + mov v0.16b, v5.16b + mov v5.16b, v10.16b + mov v10.16b, v15.16b + + b .Lseal_tail_64 + +.Lseal_tail_16: + // Here we handle the last [0,16) bytes of ciphertext that require a padded block + cbz x2, .Lseal_hash_extra + + eor v20.16b, v20.16b, v20.16b // Use T0 to load the plaintext/extra in + eor v21.16b, v21.16b, v21.16b // Use T1 to generate an AND mask that will only mask the ciphertext bytes + not v22.16b, v20.16b + + mov x6, x2 + add x1, x1, x2 + + cbz x4, .Lseal_tail_16_compose // No extra data to pad with, zero padding + + mov x7, #16 // We need to load some extra_in first for padding + sub x7, x7, x2 + cmp x4, x7 + csel x7, x4, x7, lt // .Load the minimum of extra_in_len and the amount needed to fill the register + mov x12, x7 + add x3, x3, x7 + sub x4, x4, x7 + +.Lseal_tail16_compose_extra_in: + ext v20.16b, v20.16b, v20.16b, #15 + ldrb w11, [x3, #-1]! + mov v20.b[0], w11 + subs x7, x7, #1 + b.gt .Lseal_tail16_compose_extra_in + + add x3, x3, x12 + +.Lseal_tail_16_compose: + ext v20.16b, v20.16b, v20.16b, #15 + ldrb w11, [x1, #-1]! + mov v20.b[0], w11 + ext v21.16b, v22.16b, v21.16b, #15 + subs x2, x2, #1 + b.gt .Lseal_tail_16_compose + + and v0.16b, v0.16b, v21.16b + eor v20.16b, v20.16b, v0.16b + mov v21.16b, v20.16b + +.Lseal_tail_16_store: + umov w11, v20.b[0] + strb w11, [x0], #1 + ext v20.16b, v20.16b, v20.16b, #1 + subs x6, x6, #1 + b.gt .Lseal_tail_16_store + + // Hash in the final ct block concatenated with extra_in + mov x11, v21.d[0] + mov x12, v21.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + +.Lseal_hash_extra: + cbz x4, .Lseal_finalize + +.Lseal_hash_extra_loop: + cmp x4, #16 + b.lt .Lseal_hash_extra_tail + ld1 {v20.16b}, [x3], #16 + mov x11, v20.d[0] + mov x12, v20.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + sub x4, x4, #16 + b .Lseal_hash_extra_loop + +.Lseal_hash_extra_tail: + cbz x4, .Lseal_finalize + eor v20.16b, v20.16b, v20.16b // Use T0 to load the remaining extra ciphertext + add x3, x3, x4 + +.Lseal_hash_extra_load: + ext v20.16b, v20.16b, v20.16b, #15 + ldrb w11, [x3, #-1]! + mov v20.b[0], w11 + subs x4, x4, #1 + b.gt .Lseal_hash_extra_load + + // Hash in the final padded extra_in blcok + mov x11, v20.d[0] + mov x12, v20.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + +.Lseal_finalize: + mov x11, v31.d[0] + mov x12, v31.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + // Final reduction step + sub x12, xzr, x15 + orr x13, xzr, #3 + subs x11, x8, #-5 + sbcs x12, x9, x12 + sbcs x13, x10, x13 + csel x8, x11, x8, cs + csel x9, x12, x9, cs + csel x10, x13, x10, cs + mov x11, v27.d[0] + mov x12, v27.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + + stp x8, x9, [x5] + + ldp d8, d9, [sp, #16] + ldp d10, d11, [sp, #32] + ldp d12, d13, [sp, #48] + ldp d14, d15, [sp, #64] +.cfi_restore b15 +.cfi_restore b14 +.cfi_restore b13 +.cfi_restore b12 +.cfi_restore b11 +.cfi_restore b10 +.cfi_restore b9 +.cfi_restore b8 + ldp x29, x30, [sp], 80 +.cfi_restore w29 +.cfi_restore w30 +.cfi_def_cfa_offset 0 + AARCH64_VALIDATE_LINK_REGISTER + ret + +.Lseal_128: + // On some architectures preparing 5 blocks for small buffers is wasteful + eor v25.16b, v25.16b, v25.16b + mov x11, #1 + mov v25.s[0], w11 + mov v0.16b, v24.16b + mov v1.16b, v24.16b + mov v2.16b, v24.16b + mov v5.16b, v28.16b + mov v6.16b, v28.16b + mov v7.16b, v28.16b + mov v10.16b, v29.16b + mov v11.16b, v29.16b + mov v12.16b, v29.16b + mov v17.16b, v30.16b + add v15.4s, v17.4s, v25.4s + add v16.4s, v15.4s, v25.4s + + mov x6, #10 + +.Lseal_128_rounds: + add v0.4s, v0.4s, v5.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v5.16b, v5.16b, v10.16b + eor v6.16b, v6.16b, v11.16b + eor v7.16b, v7.16b, v12.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + ushr v5.4s, v6.4s, #20 + sli v5.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v5.4s + add v2.4s, v2.4s, v6.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v20.16b, v20.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v6.16b, v6.16b, v12.16b + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v5.4s, #25 + sli v6.4s, v5.4s, #7 + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + + ext v5.16b, v5.16b, v5.16b, #4 + ext v6.16b, v6.16b, v6.16b, #4 + ext v7.16b, v7.16b, v7.16b, #4 + + ext v10.16b, v10.16b, v10.16b, #8 + ext v11.16b, v11.16b, v11.16b, #8 + ext v12.16b, v12.16b, v12.16b, #8 + + ext v15.16b, v15.16b, v15.16b, #12 + ext v16.16b, v16.16b, v16.16b, #12 + ext v17.16b, v17.16b, v17.16b, #12 + add v0.4s, v0.4s, v5.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v5.16b, v5.16b, v10.16b + eor v6.16b, v6.16b, v11.16b + eor v7.16b, v7.16b, v12.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + ushr v5.4s, v6.4s, #20 + sli v5.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v5.4s + add v2.4s, v2.4s, v6.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v20.16b, v20.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v6.16b, v6.16b, v12.16b + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v5.4s, #25 + sli v6.4s, v5.4s, #7 + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + + ext v5.16b, v5.16b, v5.16b, #12 + ext v6.16b, v6.16b, v6.16b, #12 + ext v7.16b, v7.16b, v7.16b, #12 + + ext v10.16b, v10.16b, v10.16b, #8 + ext v11.16b, v11.16b, v11.16b, #8 + ext v12.16b, v12.16b, v12.16b, #8 + + ext v15.16b, v15.16b, v15.16b, #4 + ext v16.16b, v16.16b, v16.16b, #4 + ext v17.16b, v17.16b, v17.16b, #4 + subs x6, x6, #1 + b.hi .Lseal_128_rounds + + add v0.4s, v0.4s, v24.4s + add v1.4s, v1.4s, v24.4s + add v2.4s, v2.4s, v24.4s + + add v5.4s, v5.4s, v28.4s + add v6.4s, v6.4s, v28.4s + add v7.4s, v7.4s, v28.4s + + // Only the first 32 bytes of the third block (counter = 0) are needed, + // so skip updating v12 and v17. + add v10.4s, v10.4s, v29.4s + add v11.4s, v11.4s, v29.4s + + add v30.4s, v30.4s, v25.4s + add v15.4s, v15.4s, v30.4s + add v30.4s, v30.4s, v25.4s + add v16.4s, v16.4s, v30.4s + + and v2.16b, v2.16b, v27.16b + mov x16, v2.d[0] // Move the R key to GPRs + mov x17, v2.d[1] + mov v27.16b, v7.16b // Store the S key + + bl .Lpoly_hash_ad_internal + b .Lseal_tail +.cfi_endproc +.size chacha20_poly1305_seal,.-chacha20_poly1305_seal + +///////////////////////////////// +// +// void chacha20_poly1305_open(uint8_t *pt, uint8_t *ct, size_t len_in, uint8_t *ad, size_t len_ad, union open_data *aead_data); +// +.globl chacha20_poly1305_open +.hidden chacha20_poly1305_open +.type chacha20_poly1305_open,%function +.align 6 +chacha20_poly1305_open: + AARCH64_SIGN_LINK_REGISTER +.cfi_startproc + stp x29, x30, [sp, #-80]! +.cfi_def_cfa_offset 80 +.cfi_offset w30, -72 +.cfi_offset w29, -80 + mov x29, sp + // We probably could do .cfi_def_cfa w29, 80 at this point, but since + // we don't actually use the frame pointer like that, it's probably not + // worth bothering. + stp d8, d9, [sp, #16] + stp d10, d11, [sp, #32] + stp d12, d13, [sp, #48] + stp d14, d15, [sp, #64] +.cfi_offset b15, -8 +.cfi_offset b14, -16 +.cfi_offset b13, -24 +.cfi_offset b12, -32 +.cfi_offset b11, -40 +.cfi_offset b10, -48 +.cfi_offset b9, -56 +.cfi_offset b8, -64 + + adrp x11, .Lchacha20_consts + add x11, x11, :lo12:.Lchacha20_consts + + ld1 {v24.16b - v27.16b}, [x11] // .Load the CONSTS, INC, ROL8 and CLAMP values + ld1 {v28.16b - v30.16b}, [x5] + + mov x15, #1 // Prepare the Poly1305 state + mov x8, #0 + mov x9, #0 + mov x10, #0 + + mov v31.d[0], x4 // Store the input and aad lengths + mov v31.d[1], x2 + + cmp x2, #128 + b.le .Lopen_128 // Optimization for smaller buffers + + // Initially we prepare a single ChaCha20 block for the Poly1305 R and S keys + mov v0.16b, v24.16b + mov v5.16b, v28.16b + mov v10.16b, v29.16b + mov v15.16b, v30.16b + + mov x6, #10 + +.align 5 +.Lopen_init_rounds: + add v0.4s, v0.4s, v5.4s + eor v15.16b, v15.16b, v0.16b + rev32 v15.8h, v15.8h + + add v10.4s, v10.4s, v15.4s + eor v5.16b, v5.16b, v10.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + add v0.4s, v0.4s, v20.4s + eor v15.16b, v15.16b, v0.16b + tbl v15.16b, {v15.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + eor v20.16b, v20.16b, v10.16b + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + ext v5.16b, v5.16b, v5.16b, #4 + ext v10.16b, v10.16b, v10.16b, #8 + ext v15.16b, v15.16b, v15.16b, #12 + add v0.4s, v0.4s, v5.4s + eor v15.16b, v15.16b, v0.16b + rev32 v15.8h, v15.8h + + add v10.4s, v10.4s, v15.4s + eor v5.16b, v5.16b, v10.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + add v0.4s, v0.4s, v20.4s + eor v15.16b, v15.16b, v0.16b + tbl v15.16b, {v15.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + eor v20.16b, v20.16b, v10.16b + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + ext v5.16b, v5.16b, v5.16b, #12 + ext v10.16b, v10.16b, v10.16b, #8 + ext v15.16b, v15.16b, v15.16b, #4 + subs x6, x6, #1 + b.hi .Lopen_init_rounds + + add v0.4s, v0.4s, v24.4s + add v5.4s, v5.4s, v28.4s + + and v0.16b, v0.16b, v27.16b + mov x16, v0.d[0] // Move the R key to GPRs + mov x17, v0.d[1] + mov v27.16b, v5.16b // Store the S key + + bl .Lpoly_hash_ad_internal + +.Lopen_ad_done: + mov x3, x1 + +// Each iteration of the loop hash 320 bytes, and prepare stream for 320 bytes +.Lopen_main_loop: + + cmp x2, #192 + b.lt .Lopen_tail + + adrp x11, .Lchacha20_consts + add x11, x11, :lo12:.Lchacha20_consts + + ld4r {v0.4s,v1.4s,v2.4s,v3.4s}, [x11] + mov v4.16b, v24.16b + + ld4r {v5.4s,v6.4s,v7.4s,v8.4s}, [x5], #16 + mov v9.16b, v28.16b + + ld4r {v10.4s,v11.4s,v12.4s,v13.4s}, [x5], #16 + mov v14.16b, v29.16b + + ld4r {v15.4s,v16.4s,v17.4s,v18.4s}, [x5] + sub x5, x5, #32 + add v15.4s, v15.4s, v25.4s + mov v19.16b, v30.16b + + eor v20.16b, v20.16b, v20.16b //zero + not v21.16b, v20.16b // -1 + sub v21.4s, v25.4s, v21.4s // Add +1 + ext v20.16b, v21.16b, v20.16b, #12 // Get the last element (counter) + add v19.4s, v19.4s, v20.4s + + lsr x4, x2, #4 // How many whole blocks we have to hash, will always be at least 12 + sub x4, x4, #10 + + mov x7, #10 + subs x6, x7, x4 + subs x6, x7, x4 // itr1 can be negative if we have more than 320 bytes to hash + csel x7, x7, x4, le // if itr1 is zero or less, itr2 should be 10 to indicate all 10 rounds are full + + cbz x7, .Lopen_main_loop_rounds_short + +.align 5 +.Lopen_main_loop_rounds: + ldp x11, x12, [x3], 16 + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most +.Lopen_main_loop_rounds_short: + add v0.4s, v0.4s, v5.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + add v3.4s, v3.4s, v8.4s + add v4.4s, v4.4s, v9.4s + + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + eor v18.16b, v18.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + rev32 v18.8h, v18.8h + rev32 v19.8h, v19.8h + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + add v13.4s, v13.4s, v18.4s + add v14.4s, v14.4s, v19.4s + + eor v5.16b, v5.16b, v10.16b + eor v6.16b, v6.16b, v11.16b + eor v7.16b, v7.16b, v12.16b + eor v8.16b, v8.16b, v13.16b + eor v9.16b, v9.16b, v14.16b + + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + ushr v5.4s, v6.4s, #20 + sli v5.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + ushr v7.4s, v8.4s, #20 + sli v7.4s, v8.4s, #12 + ushr v8.4s, v9.4s, #20 + sli v8.4s, v9.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v5.4s + add v2.4s, v2.4s, v6.4s + add v3.4s, v3.4s, v7.4s + add v4.4s, v4.4s, v8.4s + + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + eor v18.16b, v18.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + tbl v18.16b, {v18.16b}, v26.16b + tbl v19.16b, {v19.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + add v13.4s, v13.4s, v18.4s + add v14.4s, v14.4s, v19.4s + + eor v20.16b, v20.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v6.16b, v6.16b, v12.16b + eor v7.16b, v7.16b, v13.16b + eor v8.16b, v8.16b, v14.16b + + ushr v9.4s, v8.4s, #25 + sli v9.4s, v8.4s, #7 + ushr v8.4s, v7.4s, #25 + sli v8.4s, v7.4s, #7 + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v5.4s, #25 + sli v6.4s, v5.4s, #7 + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + + ext v9.16b, v9.16b, v9.16b, #4 + ext v14.16b, v14.16b, v14.16b, #8 + ext v19.16b, v19.16b, v19.16b, #12 + ldp x11, x12, [x3], 16 + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + add v0.4s, v0.4s, v6.4s + add v1.4s, v1.4s, v7.4s + add v2.4s, v2.4s, v8.4s + add v3.4s, v3.4s, v5.4s + add v4.4s, v4.4s, v9.4s + + eor v18.16b, v18.16b, v0.16b + eor v15.16b, v15.16b, v1.16b + eor v16.16b, v16.16b, v2.16b + eor v17.16b, v17.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + rev32 v18.8h, v18.8h + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + rev32 v19.8h, v19.8h + + add v12.4s, v12.4s, v18.4s + add v13.4s, v13.4s, v15.4s + add v10.4s, v10.4s, v16.4s + add v11.4s, v11.4s, v17.4s + add v14.4s, v14.4s, v19.4s + + eor v6.16b, v6.16b, v12.16b + eor v7.16b, v7.16b, v13.16b + eor v8.16b, v8.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v9.16b, v9.16b, v14.16b + + ushr v20.4s, v6.4s, #20 + sli v20.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + ushr v7.4s, v8.4s, #20 + sli v7.4s, v8.4s, #12 + ushr v8.4s, v5.4s, #20 + sli v8.4s, v5.4s, #12 + ushr v5.4s, v9.4s, #20 + sli v5.4s, v9.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + add v3.4s, v3.4s, v8.4s + add v4.4s, v4.4s, v5.4s + + eor v18.16b, v18.16b, v0.16b + eor v15.16b, v15.16b, v1.16b + eor v16.16b, v16.16b, v2.16b + eor v17.16b, v17.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + tbl v18.16b, {v18.16b}, v26.16b + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + tbl v19.16b, {v19.16b}, v26.16b + + add v12.4s, v12.4s, v18.4s + add v13.4s, v13.4s, v15.4s + add v10.4s, v10.4s, v16.4s + add v11.4s, v11.4s, v17.4s + add v14.4s, v14.4s, v19.4s + + eor v20.16b, v20.16b, v12.16b + eor v6.16b, v6.16b, v13.16b + eor v7.16b, v7.16b, v10.16b + eor v8.16b, v8.16b, v11.16b + eor v5.16b, v5.16b, v14.16b + + ushr v9.4s, v5.4s, #25 + sli v9.4s, v5.4s, #7 + ushr v5.4s, v8.4s, #25 + sli v5.4s, v8.4s, #7 + ushr v8.4s, v7.4s, #25 + sli v8.4s, v7.4s, #7 + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v20.4s, #25 + sli v6.4s, v20.4s, #7 + + ext v9.16b, v9.16b, v9.16b, #12 + ext v14.16b, v14.16b, v14.16b, #8 + ext v19.16b, v19.16b, v19.16b, #4 + subs x7, x7, #1 + b.gt .Lopen_main_loop_rounds + subs x6, x6, #1 + b.ge .Lopen_main_loop_rounds_short + + eor v20.16b, v20.16b, v20.16b //zero + not v21.16b, v20.16b // -1 + sub v21.4s, v25.4s, v21.4s // Add +1 + ext v20.16b, v21.16b, v20.16b, #12 // Get the last element (counter) + add v19.4s, v19.4s, v20.4s + + add v15.4s, v15.4s, v25.4s + mov x11, #5 + dup v20.4s, w11 + add v25.4s, v25.4s, v20.4s + + zip1 v20.4s, v0.4s, v1.4s + zip2 v21.4s, v0.4s, v1.4s + zip1 v22.4s, v2.4s, v3.4s + zip2 v23.4s, v2.4s, v3.4s + + zip1 v0.2d, v20.2d, v22.2d + zip2 v1.2d, v20.2d, v22.2d + zip1 v2.2d, v21.2d, v23.2d + zip2 v3.2d, v21.2d, v23.2d + + zip1 v20.4s, v5.4s, v6.4s + zip2 v21.4s, v5.4s, v6.4s + zip1 v22.4s, v7.4s, v8.4s + zip2 v23.4s, v7.4s, v8.4s + + zip1 v5.2d, v20.2d, v22.2d + zip2 v6.2d, v20.2d, v22.2d + zip1 v7.2d, v21.2d, v23.2d + zip2 v8.2d, v21.2d, v23.2d + + zip1 v20.4s, v10.4s, v11.4s + zip2 v21.4s, v10.4s, v11.4s + zip1 v22.4s, v12.4s, v13.4s + zip2 v23.4s, v12.4s, v13.4s + + zip1 v10.2d, v20.2d, v22.2d + zip2 v11.2d, v20.2d, v22.2d + zip1 v12.2d, v21.2d, v23.2d + zip2 v13.2d, v21.2d, v23.2d + + zip1 v20.4s, v15.4s, v16.4s + zip2 v21.4s, v15.4s, v16.4s + zip1 v22.4s, v17.4s, v18.4s + zip2 v23.4s, v17.4s, v18.4s + + zip1 v15.2d, v20.2d, v22.2d + zip2 v16.2d, v20.2d, v22.2d + zip1 v17.2d, v21.2d, v23.2d + zip2 v18.2d, v21.2d, v23.2d + + add v0.4s, v0.4s, v24.4s + add v5.4s, v5.4s, v28.4s + add v10.4s, v10.4s, v29.4s + add v15.4s, v15.4s, v30.4s + + add v1.4s, v1.4s, v24.4s + add v6.4s, v6.4s, v28.4s + add v11.4s, v11.4s, v29.4s + add v16.4s, v16.4s, v30.4s + + add v2.4s, v2.4s, v24.4s + add v7.4s, v7.4s, v28.4s + add v12.4s, v12.4s, v29.4s + add v17.4s, v17.4s, v30.4s + + add v3.4s, v3.4s, v24.4s + add v8.4s, v8.4s, v28.4s + add v13.4s, v13.4s, v29.4s + add v18.4s, v18.4s, v30.4s + + add v4.4s, v4.4s, v24.4s + add v9.4s, v9.4s, v28.4s + add v14.4s, v14.4s, v29.4s + add v19.4s, v19.4s, v30.4s + + // We can always safely store 192 bytes + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v0.16b + eor v21.16b, v21.16b, v5.16b + eor v22.16b, v22.16b, v10.16b + eor v23.16b, v23.16b, v15.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v1.16b + eor v21.16b, v21.16b, v6.16b + eor v22.16b, v22.16b, v11.16b + eor v23.16b, v23.16b, v16.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v2.16b + eor v21.16b, v21.16b, v7.16b + eor v22.16b, v22.16b, v12.16b + eor v23.16b, v23.16b, v17.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + sub x2, x2, #192 + + mov v0.16b, v3.16b + mov v5.16b, v8.16b + mov v10.16b, v13.16b + mov v15.16b, v18.16b + + cmp x2, #64 + b.lt .Lopen_tail_64_store + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v3.16b + eor v21.16b, v21.16b, v8.16b + eor v22.16b, v22.16b, v13.16b + eor v23.16b, v23.16b, v18.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + sub x2, x2, #64 + + mov v0.16b, v4.16b + mov v5.16b, v9.16b + mov v10.16b, v14.16b + mov v15.16b, v19.16b + + cmp x2, #64 + b.lt .Lopen_tail_64_store + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v4.16b + eor v21.16b, v21.16b, v9.16b + eor v22.16b, v22.16b, v14.16b + eor v23.16b, v23.16b, v19.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + sub x2, x2, #64 + b .Lopen_main_loop + +.Lopen_tail: + + cbz x2, .Lopen_finalize + + lsr x4, x2, #4 // How many whole blocks we have to hash + + cmp x2, #64 + b.le .Lopen_tail_64 + cmp x2, #128 + b.le .Lopen_tail_128 + +.Lopen_tail_192: + // We need three more blocks + mov v0.16b, v24.16b + mov v1.16b, v24.16b + mov v2.16b, v24.16b + mov v5.16b, v28.16b + mov v6.16b, v28.16b + mov v7.16b, v28.16b + mov v10.16b, v29.16b + mov v11.16b, v29.16b + mov v12.16b, v29.16b + mov v15.16b, v30.16b + mov v16.16b, v30.16b + mov v17.16b, v30.16b + eor v23.16b, v23.16b, v23.16b + eor v21.16b, v21.16b, v21.16b + ins v23.s[0], v25.s[0] + ins v21.d[0], x15 + + add v22.4s, v23.4s, v21.4s + add v21.4s, v22.4s, v21.4s + + add v15.4s, v15.4s, v21.4s + add v16.4s, v16.4s, v23.4s + add v17.4s, v17.4s, v22.4s + + mov x7, #10 + subs x6, x7, x4 // itr1 can be negative if we have more than 160 bytes to hash + csel x7, x7, x4, le // if itr1 is zero or less, itr2 should be 10 to indicate all 10 rounds are hashing + sub x4, x4, x7 + + cbz x7, .Lopen_tail_192_rounds_no_hash + +.Lopen_tail_192_rounds: + ldp x11, x12, [x3], 16 + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most +.Lopen_tail_192_rounds_no_hash: + add v0.4s, v0.4s, v5.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v5.16b, v5.16b, v10.16b + eor v6.16b, v6.16b, v11.16b + eor v7.16b, v7.16b, v12.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + ushr v5.4s, v6.4s, #20 + sli v5.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v5.4s + add v2.4s, v2.4s, v6.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v20.16b, v20.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v6.16b, v6.16b, v12.16b + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v5.4s, #25 + sli v6.4s, v5.4s, #7 + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + + ext v5.16b, v5.16b, v5.16b, #4 + ext v6.16b, v6.16b, v6.16b, #4 + ext v7.16b, v7.16b, v7.16b, #4 + + ext v10.16b, v10.16b, v10.16b, #8 + ext v11.16b, v11.16b, v11.16b, #8 + ext v12.16b, v12.16b, v12.16b, #8 + + ext v15.16b, v15.16b, v15.16b, #12 + ext v16.16b, v16.16b, v16.16b, #12 + ext v17.16b, v17.16b, v17.16b, #12 + add v0.4s, v0.4s, v5.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v5.16b, v5.16b, v10.16b + eor v6.16b, v6.16b, v11.16b + eor v7.16b, v7.16b, v12.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + ushr v5.4s, v6.4s, #20 + sli v5.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v5.4s + add v2.4s, v2.4s, v6.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v20.16b, v20.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v6.16b, v6.16b, v12.16b + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v5.4s, #25 + sli v6.4s, v5.4s, #7 + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + + ext v5.16b, v5.16b, v5.16b, #12 + ext v6.16b, v6.16b, v6.16b, #12 + ext v7.16b, v7.16b, v7.16b, #12 + + ext v10.16b, v10.16b, v10.16b, #8 + ext v11.16b, v11.16b, v11.16b, #8 + ext v12.16b, v12.16b, v12.16b, #8 + + ext v15.16b, v15.16b, v15.16b, #4 + ext v16.16b, v16.16b, v16.16b, #4 + ext v17.16b, v17.16b, v17.16b, #4 + subs x7, x7, #1 + b.gt .Lopen_tail_192_rounds + subs x6, x6, #1 + b.ge .Lopen_tail_192_rounds_no_hash + + // We hashed 160 bytes at most, may still have 32 bytes left +.Lopen_tail_192_hash: + cbz x4, .Lopen_tail_192_hash_done + ldp x11, x12, [x3], 16 + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + sub x4, x4, #1 + b .Lopen_tail_192_hash + +.Lopen_tail_192_hash_done: + + add v0.4s, v0.4s, v24.4s + add v1.4s, v1.4s, v24.4s + add v2.4s, v2.4s, v24.4s + add v5.4s, v5.4s, v28.4s + add v6.4s, v6.4s, v28.4s + add v7.4s, v7.4s, v28.4s + add v10.4s, v10.4s, v29.4s + add v11.4s, v11.4s, v29.4s + add v12.4s, v12.4s, v29.4s + add v15.4s, v15.4s, v30.4s + add v16.4s, v16.4s, v30.4s + add v17.4s, v17.4s, v30.4s + + add v15.4s, v15.4s, v21.4s + add v16.4s, v16.4s, v23.4s + add v17.4s, v17.4s, v22.4s + + ld1 {v20.16b - v23.16b}, [x1], #64 + + eor v20.16b, v20.16b, v1.16b + eor v21.16b, v21.16b, v6.16b + eor v22.16b, v22.16b, v11.16b + eor v23.16b, v23.16b, v16.16b + + st1 {v20.16b - v23.16b}, [x0], #64 + + ld1 {v20.16b - v23.16b}, [x1], #64 + + eor v20.16b, v20.16b, v2.16b + eor v21.16b, v21.16b, v7.16b + eor v22.16b, v22.16b, v12.16b + eor v23.16b, v23.16b, v17.16b + + st1 {v20.16b - v23.16b}, [x0], #64 + + sub x2, x2, #128 + b .Lopen_tail_64_store + +.Lopen_tail_128: + // We need two more blocks + mov v0.16b, v24.16b + mov v1.16b, v24.16b + mov v5.16b, v28.16b + mov v6.16b, v28.16b + mov v10.16b, v29.16b + mov v11.16b, v29.16b + mov v15.16b, v30.16b + mov v16.16b, v30.16b + eor v23.16b, v23.16b, v23.16b + eor v22.16b, v22.16b, v22.16b + ins v23.s[0], v25.s[0] + ins v22.d[0], x15 + add v22.4s, v22.4s, v23.4s + + add v15.4s, v15.4s, v22.4s + add v16.4s, v16.4s, v23.4s + + mov x6, #10 + sub x6, x6, x4 + +.Lopen_tail_128_rounds: + add v0.4s, v0.4s, v5.4s + eor v15.16b, v15.16b, v0.16b + rev32 v15.8h, v15.8h + + add v10.4s, v10.4s, v15.4s + eor v5.16b, v5.16b, v10.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + add v0.4s, v0.4s, v20.4s + eor v15.16b, v15.16b, v0.16b + tbl v15.16b, {v15.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + eor v20.16b, v20.16b, v10.16b + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + ext v5.16b, v5.16b, v5.16b, #4 + ext v10.16b, v10.16b, v10.16b, #8 + ext v15.16b, v15.16b, v15.16b, #12 + add v1.4s, v1.4s, v6.4s + eor v16.16b, v16.16b, v1.16b + rev32 v16.8h, v16.8h + + add v11.4s, v11.4s, v16.4s + eor v6.16b, v6.16b, v11.16b + ushr v20.4s, v6.4s, #20 + sli v20.4s, v6.4s, #12 + add v1.4s, v1.4s, v20.4s + eor v16.16b, v16.16b, v1.16b + tbl v16.16b, {v16.16b}, v26.16b + + add v11.4s, v11.4s, v16.4s + eor v20.16b, v20.16b, v11.16b + ushr v6.4s, v20.4s, #25 + sli v6.4s, v20.4s, #7 + ext v6.16b, v6.16b, v6.16b, #4 + ext v11.16b, v11.16b, v11.16b, #8 + ext v16.16b, v16.16b, v16.16b, #12 + add v0.4s, v0.4s, v5.4s + eor v15.16b, v15.16b, v0.16b + rev32 v15.8h, v15.8h + + add v10.4s, v10.4s, v15.4s + eor v5.16b, v5.16b, v10.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + add v0.4s, v0.4s, v20.4s + eor v15.16b, v15.16b, v0.16b + tbl v15.16b, {v15.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + eor v20.16b, v20.16b, v10.16b + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + ext v5.16b, v5.16b, v5.16b, #12 + ext v10.16b, v10.16b, v10.16b, #8 + ext v15.16b, v15.16b, v15.16b, #4 + add v1.4s, v1.4s, v6.4s + eor v16.16b, v16.16b, v1.16b + rev32 v16.8h, v16.8h + + add v11.4s, v11.4s, v16.4s + eor v6.16b, v6.16b, v11.16b + ushr v20.4s, v6.4s, #20 + sli v20.4s, v6.4s, #12 + add v1.4s, v1.4s, v20.4s + eor v16.16b, v16.16b, v1.16b + tbl v16.16b, {v16.16b}, v26.16b + + add v11.4s, v11.4s, v16.4s + eor v20.16b, v20.16b, v11.16b + ushr v6.4s, v20.4s, #25 + sli v6.4s, v20.4s, #7 + ext v6.16b, v6.16b, v6.16b, #12 + ext v11.16b, v11.16b, v11.16b, #8 + ext v16.16b, v16.16b, v16.16b, #4 + subs x6, x6, #1 + b.gt .Lopen_tail_128_rounds + cbz x4, .Lopen_tail_128_rounds_done + subs x4, x4, #1 + ldp x11, x12, [x3], 16 + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + b .Lopen_tail_128_rounds + +.Lopen_tail_128_rounds_done: + add v0.4s, v0.4s, v24.4s + add v1.4s, v1.4s, v24.4s + add v5.4s, v5.4s, v28.4s + add v6.4s, v6.4s, v28.4s + add v10.4s, v10.4s, v29.4s + add v11.4s, v11.4s, v29.4s + add v15.4s, v15.4s, v30.4s + add v16.4s, v16.4s, v30.4s + add v15.4s, v15.4s, v22.4s + add v16.4s, v16.4s, v23.4s + + ld1 {v20.16b - v23.16b}, [x1], #64 + + eor v20.16b, v20.16b, v1.16b + eor v21.16b, v21.16b, v6.16b + eor v22.16b, v22.16b, v11.16b + eor v23.16b, v23.16b, v16.16b + + st1 {v20.16b - v23.16b}, [x0], #64 + sub x2, x2, #64 + + b .Lopen_tail_64_store + +.Lopen_tail_64: + // We just need a single block + mov v0.16b, v24.16b + mov v5.16b, v28.16b + mov v10.16b, v29.16b + mov v15.16b, v30.16b + eor v23.16b, v23.16b, v23.16b + ins v23.s[0], v25.s[0] + add v15.4s, v15.4s, v23.4s + + mov x6, #10 + sub x6, x6, x4 + +.Lopen_tail_64_rounds: + add v0.4s, v0.4s, v5.4s + eor v15.16b, v15.16b, v0.16b + rev32 v15.8h, v15.8h + + add v10.4s, v10.4s, v15.4s + eor v5.16b, v5.16b, v10.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + add v0.4s, v0.4s, v20.4s + eor v15.16b, v15.16b, v0.16b + tbl v15.16b, {v15.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + eor v20.16b, v20.16b, v10.16b + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + ext v5.16b, v5.16b, v5.16b, #4 + ext v10.16b, v10.16b, v10.16b, #8 + ext v15.16b, v15.16b, v15.16b, #12 + add v0.4s, v0.4s, v5.4s + eor v15.16b, v15.16b, v0.16b + rev32 v15.8h, v15.8h + + add v10.4s, v10.4s, v15.4s + eor v5.16b, v5.16b, v10.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + add v0.4s, v0.4s, v20.4s + eor v15.16b, v15.16b, v0.16b + tbl v15.16b, {v15.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + eor v20.16b, v20.16b, v10.16b + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + ext v5.16b, v5.16b, v5.16b, #12 + ext v10.16b, v10.16b, v10.16b, #8 + ext v15.16b, v15.16b, v15.16b, #4 + subs x6, x6, #1 + b.gt .Lopen_tail_64_rounds + cbz x4, .Lopen_tail_64_rounds_done + subs x4, x4, #1 + ldp x11, x12, [x3], 16 + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + b .Lopen_tail_64_rounds + +.Lopen_tail_64_rounds_done: + add v0.4s, v0.4s, v24.4s + add v5.4s, v5.4s, v28.4s + add v10.4s, v10.4s, v29.4s + add v15.4s, v15.4s, v30.4s + add v15.4s, v15.4s, v23.4s + +.Lopen_tail_64_store: + cmp x2, #16 + b.lt .Lopen_tail_16 + + ld1 {v20.16b}, [x1], #16 + eor v20.16b, v20.16b, v0.16b + st1 {v20.16b}, [x0], #16 + mov v0.16b, v5.16b + mov v5.16b, v10.16b + mov v10.16b, v15.16b + sub x2, x2, #16 + b .Lopen_tail_64_store + +.Lopen_tail_16: + // Here we handle the last [0,16) bytes that require a padded block + cbz x2, .Lopen_finalize + + eor v20.16b, v20.16b, v20.16b // Use T0 to load the ciphertext + eor v21.16b, v21.16b, v21.16b // Use T1 to generate an AND mask + not v22.16b, v20.16b + + add x7, x1, x2 + mov x6, x2 + +.Lopen_tail_16_compose: + ext v20.16b, v20.16b, v20.16b, #15 + ldrb w11, [x7, #-1]! + mov v20.b[0], w11 + ext v21.16b, v22.16b, v21.16b, #15 + subs x2, x2, #1 + b.gt .Lopen_tail_16_compose + + and v20.16b, v20.16b, v21.16b + // Hash in the final padded block + mov x11, v20.d[0] + mov x12, v20.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + eor v20.16b, v20.16b, v0.16b + +.Lopen_tail_16_store: + umov w11, v20.b[0] + strb w11, [x0], #1 + ext v20.16b, v20.16b, v20.16b, #1 + subs x6, x6, #1 + b.gt .Lopen_tail_16_store + +.Lopen_finalize: + mov x11, v31.d[0] + mov x12, v31.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + // Final reduction step + sub x12, xzr, x15 + orr x13, xzr, #3 + subs x11, x8, #-5 + sbcs x12, x9, x12 + sbcs x13, x10, x13 + csel x8, x11, x8, cs + csel x9, x12, x9, cs + csel x10, x13, x10, cs + mov x11, v27.d[0] + mov x12, v27.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + + stp x8, x9, [x5] + + ldp d8, d9, [sp, #16] + ldp d10, d11, [sp, #32] + ldp d12, d13, [sp, #48] + ldp d14, d15, [sp, #64] +.cfi_restore b15 +.cfi_restore b14 +.cfi_restore b13 +.cfi_restore b12 +.cfi_restore b11 +.cfi_restore b10 +.cfi_restore b9 +.cfi_restore b8 + ldp x29, x30, [sp], 80 +.cfi_restore w29 +.cfi_restore w30 +.cfi_def_cfa_offset 0 + AARCH64_VALIDATE_LINK_REGISTER + ret + +.Lopen_128: + // On some architectures preparing 5 blocks for small buffers is wasteful + eor v25.16b, v25.16b, v25.16b + mov x11, #1 + mov v25.s[0], w11 + mov v0.16b, v24.16b + mov v1.16b, v24.16b + mov v2.16b, v24.16b + mov v5.16b, v28.16b + mov v6.16b, v28.16b + mov v7.16b, v28.16b + mov v10.16b, v29.16b + mov v11.16b, v29.16b + mov v12.16b, v29.16b + mov v17.16b, v30.16b + add v15.4s, v17.4s, v25.4s + add v16.4s, v15.4s, v25.4s + + mov x6, #10 + +.Lopen_128_rounds: + add v0.4s, v0.4s, v5.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v5.16b, v5.16b, v10.16b + eor v6.16b, v6.16b, v11.16b + eor v7.16b, v7.16b, v12.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + ushr v5.4s, v6.4s, #20 + sli v5.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v5.4s + add v2.4s, v2.4s, v6.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v20.16b, v20.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v6.16b, v6.16b, v12.16b + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v5.4s, #25 + sli v6.4s, v5.4s, #7 + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + + ext v5.16b, v5.16b, v5.16b, #4 + ext v6.16b, v6.16b, v6.16b, #4 + ext v7.16b, v7.16b, v7.16b, #4 + + ext v10.16b, v10.16b, v10.16b, #8 + ext v11.16b, v11.16b, v11.16b, #8 + ext v12.16b, v12.16b, v12.16b, #8 + + ext v15.16b, v15.16b, v15.16b, #12 + ext v16.16b, v16.16b, v16.16b, #12 + ext v17.16b, v17.16b, v17.16b, #12 + add v0.4s, v0.4s, v5.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v5.16b, v5.16b, v10.16b + eor v6.16b, v6.16b, v11.16b + eor v7.16b, v7.16b, v12.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + ushr v5.4s, v6.4s, #20 + sli v5.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v5.4s + add v2.4s, v2.4s, v6.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v20.16b, v20.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v6.16b, v6.16b, v12.16b + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v5.4s, #25 + sli v6.4s, v5.4s, #7 + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + + ext v5.16b, v5.16b, v5.16b, #12 + ext v6.16b, v6.16b, v6.16b, #12 + ext v7.16b, v7.16b, v7.16b, #12 + + ext v10.16b, v10.16b, v10.16b, #8 + ext v11.16b, v11.16b, v11.16b, #8 + ext v12.16b, v12.16b, v12.16b, #8 + + ext v15.16b, v15.16b, v15.16b, #4 + ext v16.16b, v16.16b, v16.16b, #4 + ext v17.16b, v17.16b, v17.16b, #4 + subs x6, x6, #1 + b.hi .Lopen_128_rounds + + add v0.4s, v0.4s, v24.4s + add v1.4s, v1.4s, v24.4s + add v2.4s, v2.4s, v24.4s + + add v5.4s, v5.4s, v28.4s + add v6.4s, v6.4s, v28.4s + add v7.4s, v7.4s, v28.4s + + add v10.4s, v10.4s, v29.4s + add v11.4s, v11.4s, v29.4s + + add v30.4s, v30.4s, v25.4s + add v15.4s, v15.4s, v30.4s + add v30.4s, v30.4s, v25.4s + add v16.4s, v16.4s, v30.4s + + and v2.16b, v2.16b, v27.16b + mov x16, v2.d[0] // Move the R key to GPRs + mov x17, v2.d[1] + mov v27.16b, v7.16b // Store the S key + + bl .Lpoly_hash_ad_internal + +.Lopen_128_store: + cmp x2, #64 + b.lt .Lopen_128_store_64 + + ld1 {v20.16b - v23.16b}, [x1], #64 + + mov x11, v20.d[0] + mov x12, v20.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + mov x11, v21.d[0] + mov x12, v21.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + mov x11, v22.d[0] + mov x12, v22.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + mov x11, v23.d[0] + mov x12, v23.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + + eor v20.16b, v20.16b, v0.16b + eor v21.16b, v21.16b, v5.16b + eor v22.16b, v22.16b, v10.16b + eor v23.16b, v23.16b, v15.16b + + st1 {v20.16b - v23.16b}, [x0], #64 + + sub x2, x2, #64 + + mov v0.16b, v1.16b + mov v5.16b, v6.16b + mov v10.16b, v11.16b + mov v15.16b, v16.16b + +.Lopen_128_store_64: + + lsr x4, x2, #4 + mov x3, x1 + +.Lopen_128_hash_64: + cbz x4, .Lopen_tail_64_store + ldp x11, x12, [x3], 16 + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + sub x4, x4, #1 + b .Lopen_128_hash_64 +.cfi_endproc +.size chacha20_poly1305_open,.-chacha20_poly1305_open +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__ELF__) diff --git a/http/vendor/ring/pregenerated/chacha20_poly1305_armv8-win64.S b/http/vendor/ring/pregenerated/chacha20_poly1305_armv8-win64.S new file mode 100644 index 0000000..75f34c5 --- /dev/null +++ b/http/vendor/ring/pregenerated/chacha20_poly1305_armv8-win64.S @@ -0,0 +1,3014 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(_WIN32) +.section .rodata + +.align 7 +Lchacha20_consts: +.byte 'e','x','p','a','n','d',' ','3','2','-','b','y','t','e',' ','k' +Linc: +.long 1,2,3,4 +Lrol8: +.byte 3,0,1,2, 7,4,5,6, 11,8,9,10, 15,12,13,14 +Lclamp: +.quad 0x0FFFFFFC0FFFFFFF, 0x0FFFFFFC0FFFFFFC + +.text + +.def Lpoly_hash_ad_internal + .type 32 +.endef +.align 6 +Lpoly_hash_ad_internal: +.cfi_startproc + cbnz x4, Lpoly_hash_intro + ret + +Lpoly_hash_intro: + cmp x4, #16 + b.lt Lpoly_hash_ad_tail + ldp x11, x12, [x3], 16 + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + sub x4, x4, #16 + b Lpoly_hash_ad_internal + +Lpoly_hash_ad_tail: + cbz x4, Lpoly_hash_ad_ret + + eor v20.16b, v20.16b, v20.16b // Use T0 to load the AAD + sub x4, x4, #1 + +Lpoly_hash_tail_16_compose: + ext v20.16b, v20.16b, v20.16b, #15 + ldrb w11, [x3, x4] + mov v20.b[0], w11 + subs x4, x4, #1 + b.ge Lpoly_hash_tail_16_compose + mov x11, v20.d[0] + mov x12, v20.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + +Lpoly_hash_ad_ret: + ret +.cfi_endproc + + +///////////////////////////////// +// +// void chacha20_poly1305_seal(uint8_t *pt, uint8_t *ct, size_t len_in, uint8_t *ad, size_t len_ad, union open_data *seal_data); +// +.globl chacha20_poly1305_seal + +.def chacha20_poly1305_seal + .type 32 +.endef +.align 6 +chacha20_poly1305_seal: + AARCH64_SIGN_LINK_REGISTER +.cfi_startproc + stp x29, x30, [sp, #-80]! +.cfi_def_cfa_offset 80 +.cfi_offset w30, -72 +.cfi_offset w29, -80 + mov x29, sp + // We probably could do .cfi_def_cfa w29, 80 at this point, but since + // we don't actually use the frame pointer like that, it's probably not + // worth bothering. + stp d8, d9, [sp, #16] + stp d10, d11, [sp, #32] + stp d12, d13, [sp, #48] + stp d14, d15, [sp, #64] +.cfi_offset b15, -8 +.cfi_offset b14, -16 +.cfi_offset b13, -24 +.cfi_offset b12, -32 +.cfi_offset b11, -40 +.cfi_offset b10, -48 +.cfi_offset b9, -56 +.cfi_offset b8, -64 + + adrp x11, Lchacha20_consts + add x11, x11, :lo12:Lchacha20_consts + + ld1 {v24.16b - v27.16b}, [x11] // Load the CONSTS, INC, ROL8 and CLAMP values + ld1 {v28.16b - v30.16b}, [x5] + + mov x15, #1 // Prepare the Poly1305 state + mov x8, #0 + mov x9, #0 + mov x10, #0 + + ldr x12, [x5, #56] // The total cipher text length includes extra_in_len + add x12, x12, x2 + mov v31.d[0], x4 // Store the input and aad lengths + mov v31.d[1], x12 + + cmp x2, #128 + b.le Lseal_128 // Optimization for smaller buffers + + // Initially we prepare 5 ChaCha20 blocks. Four to encrypt up to 4 blocks (256 bytes) of plaintext, + // and one for the Poly1305 R and S keys. The first four blocks (A0-A3..D0-D3) are computed vertically, + // the fifth block (A4-D4) horizontally. + ld4r {v0.4s,v1.4s,v2.4s,v3.4s}, [x11] + mov v4.16b, v24.16b + + ld4r {v5.4s,v6.4s,v7.4s,v8.4s}, [x5], #16 + mov v9.16b, v28.16b + + ld4r {v10.4s,v11.4s,v12.4s,v13.4s}, [x5], #16 + mov v14.16b, v29.16b + + ld4r {v15.4s,v16.4s,v17.4s,v18.4s}, [x5] + add v15.4s, v15.4s, v25.4s + mov v19.16b, v30.16b + + sub x5, x5, #32 + + mov x6, #10 + +.align 5 +Lseal_init_rounds: + add v0.4s, v0.4s, v5.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + add v3.4s, v3.4s, v8.4s + add v4.4s, v4.4s, v9.4s + + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + eor v18.16b, v18.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + rev32 v18.8h, v18.8h + rev32 v19.8h, v19.8h + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + add v13.4s, v13.4s, v18.4s + add v14.4s, v14.4s, v19.4s + + eor v5.16b, v5.16b, v10.16b + eor v6.16b, v6.16b, v11.16b + eor v7.16b, v7.16b, v12.16b + eor v8.16b, v8.16b, v13.16b + eor v9.16b, v9.16b, v14.16b + + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + ushr v5.4s, v6.4s, #20 + sli v5.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + ushr v7.4s, v8.4s, #20 + sli v7.4s, v8.4s, #12 + ushr v8.4s, v9.4s, #20 + sli v8.4s, v9.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v5.4s + add v2.4s, v2.4s, v6.4s + add v3.4s, v3.4s, v7.4s + add v4.4s, v4.4s, v8.4s + + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + eor v18.16b, v18.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + tbl v18.16b, {v18.16b}, v26.16b + tbl v19.16b, {v19.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + add v13.4s, v13.4s, v18.4s + add v14.4s, v14.4s, v19.4s + + eor v20.16b, v20.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v6.16b, v6.16b, v12.16b + eor v7.16b, v7.16b, v13.16b + eor v8.16b, v8.16b, v14.16b + + ushr v9.4s, v8.4s, #25 + sli v9.4s, v8.4s, #7 + ushr v8.4s, v7.4s, #25 + sli v8.4s, v7.4s, #7 + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v5.4s, #25 + sli v6.4s, v5.4s, #7 + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + + ext v9.16b, v9.16b, v9.16b, #4 + ext v14.16b, v14.16b, v14.16b, #8 + ext v19.16b, v19.16b, v19.16b, #12 + add v0.4s, v0.4s, v6.4s + add v1.4s, v1.4s, v7.4s + add v2.4s, v2.4s, v8.4s + add v3.4s, v3.4s, v5.4s + add v4.4s, v4.4s, v9.4s + + eor v18.16b, v18.16b, v0.16b + eor v15.16b, v15.16b, v1.16b + eor v16.16b, v16.16b, v2.16b + eor v17.16b, v17.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + rev32 v18.8h, v18.8h + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + rev32 v19.8h, v19.8h + + add v12.4s, v12.4s, v18.4s + add v13.4s, v13.4s, v15.4s + add v10.4s, v10.4s, v16.4s + add v11.4s, v11.4s, v17.4s + add v14.4s, v14.4s, v19.4s + + eor v6.16b, v6.16b, v12.16b + eor v7.16b, v7.16b, v13.16b + eor v8.16b, v8.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v9.16b, v9.16b, v14.16b + + ushr v20.4s, v6.4s, #20 + sli v20.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + ushr v7.4s, v8.4s, #20 + sli v7.4s, v8.4s, #12 + ushr v8.4s, v5.4s, #20 + sli v8.4s, v5.4s, #12 + ushr v5.4s, v9.4s, #20 + sli v5.4s, v9.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + add v3.4s, v3.4s, v8.4s + add v4.4s, v4.4s, v5.4s + + eor v18.16b, v18.16b, v0.16b + eor v15.16b, v15.16b, v1.16b + eor v16.16b, v16.16b, v2.16b + eor v17.16b, v17.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + tbl v18.16b, {v18.16b}, v26.16b + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + tbl v19.16b, {v19.16b}, v26.16b + + add v12.4s, v12.4s, v18.4s + add v13.4s, v13.4s, v15.4s + add v10.4s, v10.4s, v16.4s + add v11.4s, v11.4s, v17.4s + add v14.4s, v14.4s, v19.4s + + eor v20.16b, v20.16b, v12.16b + eor v6.16b, v6.16b, v13.16b + eor v7.16b, v7.16b, v10.16b + eor v8.16b, v8.16b, v11.16b + eor v5.16b, v5.16b, v14.16b + + ushr v9.4s, v5.4s, #25 + sli v9.4s, v5.4s, #7 + ushr v5.4s, v8.4s, #25 + sli v5.4s, v8.4s, #7 + ushr v8.4s, v7.4s, #25 + sli v8.4s, v7.4s, #7 + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v20.4s, #25 + sli v6.4s, v20.4s, #7 + + ext v9.16b, v9.16b, v9.16b, #12 + ext v14.16b, v14.16b, v14.16b, #8 + ext v19.16b, v19.16b, v19.16b, #4 + subs x6, x6, #1 + b.hi Lseal_init_rounds + + add v15.4s, v15.4s, v25.4s + mov x11, #4 + dup v20.4s, w11 + add v25.4s, v25.4s, v20.4s + + zip1 v20.4s, v0.4s, v1.4s + zip2 v21.4s, v0.4s, v1.4s + zip1 v22.4s, v2.4s, v3.4s + zip2 v23.4s, v2.4s, v3.4s + + zip1 v0.2d, v20.2d, v22.2d + zip2 v1.2d, v20.2d, v22.2d + zip1 v2.2d, v21.2d, v23.2d + zip2 v3.2d, v21.2d, v23.2d + + zip1 v20.4s, v5.4s, v6.4s + zip2 v21.4s, v5.4s, v6.4s + zip1 v22.4s, v7.4s, v8.4s + zip2 v23.4s, v7.4s, v8.4s + + zip1 v5.2d, v20.2d, v22.2d + zip2 v6.2d, v20.2d, v22.2d + zip1 v7.2d, v21.2d, v23.2d + zip2 v8.2d, v21.2d, v23.2d + + zip1 v20.4s, v10.4s, v11.4s + zip2 v21.4s, v10.4s, v11.4s + zip1 v22.4s, v12.4s, v13.4s + zip2 v23.4s, v12.4s, v13.4s + + zip1 v10.2d, v20.2d, v22.2d + zip2 v11.2d, v20.2d, v22.2d + zip1 v12.2d, v21.2d, v23.2d + zip2 v13.2d, v21.2d, v23.2d + + zip1 v20.4s, v15.4s, v16.4s + zip2 v21.4s, v15.4s, v16.4s + zip1 v22.4s, v17.4s, v18.4s + zip2 v23.4s, v17.4s, v18.4s + + zip1 v15.2d, v20.2d, v22.2d + zip2 v16.2d, v20.2d, v22.2d + zip1 v17.2d, v21.2d, v23.2d + zip2 v18.2d, v21.2d, v23.2d + + add v4.4s, v4.4s, v24.4s + add v9.4s, v9.4s, v28.4s + and v4.16b, v4.16b, v27.16b + + add v0.4s, v0.4s, v24.4s + add v5.4s, v5.4s, v28.4s + add v10.4s, v10.4s, v29.4s + add v15.4s, v15.4s, v30.4s + + add v1.4s, v1.4s, v24.4s + add v6.4s, v6.4s, v28.4s + add v11.4s, v11.4s, v29.4s + add v16.4s, v16.4s, v30.4s + + add v2.4s, v2.4s, v24.4s + add v7.4s, v7.4s, v28.4s + add v12.4s, v12.4s, v29.4s + add v17.4s, v17.4s, v30.4s + + add v3.4s, v3.4s, v24.4s + add v8.4s, v8.4s, v28.4s + add v13.4s, v13.4s, v29.4s + add v18.4s, v18.4s, v30.4s + + mov x16, v4.d[0] // Move the R key to GPRs + mov x17, v4.d[1] + mov v27.16b, v9.16b // Store the S key + + bl Lpoly_hash_ad_internal + + mov x3, x0 + cmp x2, #256 + b.le Lseal_tail + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v0.16b + eor v21.16b, v21.16b, v5.16b + eor v22.16b, v22.16b, v10.16b + eor v23.16b, v23.16b, v15.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v1.16b + eor v21.16b, v21.16b, v6.16b + eor v22.16b, v22.16b, v11.16b + eor v23.16b, v23.16b, v16.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v2.16b + eor v21.16b, v21.16b, v7.16b + eor v22.16b, v22.16b, v12.16b + eor v23.16b, v23.16b, v17.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v3.16b + eor v21.16b, v21.16b, v8.16b + eor v22.16b, v22.16b, v13.16b + eor v23.16b, v23.16b, v18.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + sub x2, x2, #256 + + mov x6, #4 // In the first run of the loop we need to hash 256 bytes, therefore we hash one block for the first 4 rounds + mov x7, #6 // and two blocks for the remaining 6, for a total of (1 * 4 + 2 * 6) * 16 = 256 + +Lseal_main_loop: + adrp x11, Lchacha20_consts + add x11, x11, :lo12:Lchacha20_consts + + ld4r {v0.4s,v1.4s,v2.4s,v3.4s}, [x11] + mov v4.16b, v24.16b + + ld4r {v5.4s,v6.4s,v7.4s,v8.4s}, [x5], #16 + mov v9.16b, v28.16b + + ld4r {v10.4s,v11.4s,v12.4s,v13.4s}, [x5], #16 + mov v14.16b, v29.16b + + ld4r {v15.4s,v16.4s,v17.4s,v18.4s}, [x5] + add v15.4s, v15.4s, v25.4s + mov v19.16b, v30.16b + + eor v20.16b, v20.16b, v20.16b //zero + not v21.16b, v20.16b // -1 + sub v21.4s, v25.4s, v21.4s // Add +1 + ext v20.16b, v21.16b, v20.16b, #12 // Get the last element (counter) + add v19.4s, v19.4s, v20.4s + + sub x5, x5, #32 +.align 5 +Lseal_main_loop_rounds: + add v0.4s, v0.4s, v5.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + add v3.4s, v3.4s, v8.4s + add v4.4s, v4.4s, v9.4s + + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + eor v18.16b, v18.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + rev32 v18.8h, v18.8h + rev32 v19.8h, v19.8h + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + add v13.4s, v13.4s, v18.4s + add v14.4s, v14.4s, v19.4s + + eor v5.16b, v5.16b, v10.16b + eor v6.16b, v6.16b, v11.16b + eor v7.16b, v7.16b, v12.16b + eor v8.16b, v8.16b, v13.16b + eor v9.16b, v9.16b, v14.16b + + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + ushr v5.4s, v6.4s, #20 + sli v5.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + ushr v7.4s, v8.4s, #20 + sli v7.4s, v8.4s, #12 + ushr v8.4s, v9.4s, #20 + sli v8.4s, v9.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v5.4s + add v2.4s, v2.4s, v6.4s + add v3.4s, v3.4s, v7.4s + add v4.4s, v4.4s, v8.4s + + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + eor v18.16b, v18.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + tbl v18.16b, {v18.16b}, v26.16b + tbl v19.16b, {v19.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + add v13.4s, v13.4s, v18.4s + add v14.4s, v14.4s, v19.4s + + eor v20.16b, v20.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v6.16b, v6.16b, v12.16b + eor v7.16b, v7.16b, v13.16b + eor v8.16b, v8.16b, v14.16b + + ushr v9.4s, v8.4s, #25 + sli v9.4s, v8.4s, #7 + ushr v8.4s, v7.4s, #25 + sli v8.4s, v7.4s, #7 + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v5.4s, #25 + sli v6.4s, v5.4s, #7 + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + + ext v9.16b, v9.16b, v9.16b, #4 + ext v14.16b, v14.16b, v14.16b, #8 + ext v19.16b, v19.16b, v19.16b, #12 + ldp x11, x12, [x3], 16 + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + add v0.4s, v0.4s, v6.4s + add v1.4s, v1.4s, v7.4s + add v2.4s, v2.4s, v8.4s + add v3.4s, v3.4s, v5.4s + add v4.4s, v4.4s, v9.4s + + eor v18.16b, v18.16b, v0.16b + eor v15.16b, v15.16b, v1.16b + eor v16.16b, v16.16b, v2.16b + eor v17.16b, v17.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + rev32 v18.8h, v18.8h + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + rev32 v19.8h, v19.8h + + add v12.4s, v12.4s, v18.4s + add v13.4s, v13.4s, v15.4s + add v10.4s, v10.4s, v16.4s + add v11.4s, v11.4s, v17.4s + add v14.4s, v14.4s, v19.4s + + eor v6.16b, v6.16b, v12.16b + eor v7.16b, v7.16b, v13.16b + eor v8.16b, v8.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v9.16b, v9.16b, v14.16b + + ushr v20.4s, v6.4s, #20 + sli v20.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + ushr v7.4s, v8.4s, #20 + sli v7.4s, v8.4s, #12 + ushr v8.4s, v5.4s, #20 + sli v8.4s, v5.4s, #12 + ushr v5.4s, v9.4s, #20 + sli v5.4s, v9.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + add v3.4s, v3.4s, v8.4s + add v4.4s, v4.4s, v5.4s + + eor v18.16b, v18.16b, v0.16b + eor v15.16b, v15.16b, v1.16b + eor v16.16b, v16.16b, v2.16b + eor v17.16b, v17.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + tbl v18.16b, {v18.16b}, v26.16b + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + tbl v19.16b, {v19.16b}, v26.16b + + add v12.4s, v12.4s, v18.4s + add v13.4s, v13.4s, v15.4s + add v10.4s, v10.4s, v16.4s + add v11.4s, v11.4s, v17.4s + add v14.4s, v14.4s, v19.4s + + eor v20.16b, v20.16b, v12.16b + eor v6.16b, v6.16b, v13.16b + eor v7.16b, v7.16b, v10.16b + eor v8.16b, v8.16b, v11.16b + eor v5.16b, v5.16b, v14.16b + + ushr v9.4s, v5.4s, #25 + sli v9.4s, v5.4s, #7 + ushr v5.4s, v8.4s, #25 + sli v5.4s, v8.4s, #7 + ushr v8.4s, v7.4s, #25 + sli v8.4s, v7.4s, #7 + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v20.4s, #25 + sli v6.4s, v20.4s, #7 + + ext v9.16b, v9.16b, v9.16b, #12 + ext v14.16b, v14.16b, v14.16b, #8 + ext v19.16b, v19.16b, v19.16b, #4 + subs x6, x6, #1 + b.ge Lseal_main_loop_rounds + ldp x11, x12, [x3], 16 + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + subs x7, x7, #1 + b.gt Lseal_main_loop_rounds + + eor v20.16b, v20.16b, v20.16b //zero + not v21.16b, v20.16b // -1 + sub v21.4s, v25.4s, v21.4s // Add +1 + ext v20.16b, v21.16b, v20.16b, #12 // Get the last element (counter) + add v19.4s, v19.4s, v20.4s + + add v15.4s, v15.4s, v25.4s + mov x11, #5 + dup v20.4s, w11 + add v25.4s, v25.4s, v20.4s + + zip1 v20.4s, v0.4s, v1.4s + zip2 v21.4s, v0.4s, v1.4s + zip1 v22.4s, v2.4s, v3.4s + zip2 v23.4s, v2.4s, v3.4s + + zip1 v0.2d, v20.2d, v22.2d + zip2 v1.2d, v20.2d, v22.2d + zip1 v2.2d, v21.2d, v23.2d + zip2 v3.2d, v21.2d, v23.2d + + zip1 v20.4s, v5.4s, v6.4s + zip2 v21.4s, v5.4s, v6.4s + zip1 v22.4s, v7.4s, v8.4s + zip2 v23.4s, v7.4s, v8.4s + + zip1 v5.2d, v20.2d, v22.2d + zip2 v6.2d, v20.2d, v22.2d + zip1 v7.2d, v21.2d, v23.2d + zip2 v8.2d, v21.2d, v23.2d + + zip1 v20.4s, v10.4s, v11.4s + zip2 v21.4s, v10.4s, v11.4s + zip1 v22.4s, v12.4s, v13.4s + zip2 v23.4s, v12.4s, v13.4s + + zip1 v10.2d, v20.2d, v22.2d + zip2 v11.2d, v20.2d, v22.2d + zip1 v12.2d, v21.2d, v23.2d + zip2 v13.2d, v21.2d, v23.2d + + zip1 v20.4s, v15.4s, v16.4s + zip2 v21.4s, v15.4s, v16.4s + zip1 v22.4s, v17.4s, v18.4s + zip2 v23.4s, v17.4s, v18.4s + + zip1 v15.2d, v20.2d, v22.2d + zip2 v16.2d, v20.2d, v22.2d + zip1 v17.2d, v21.2d, v23.2d + zip2 v18.2d, v21.2d, v23.2d + + add v0.4s, v0.4s, v24.4s + add v5.4s, v5.4s, v28.4s + add v10.4s, v10.4s, v29.4s + add v15.4s, v15.4s, v30.4s + + add v1.4s, v1.4s, v24.4s + add v6.4s, v6.4s, v28.4s + add v11.4s, v11.4s, v29.4s + add v16.4s, v16.4s, v30.4s + + add v2.4s, v2.4s, v24.4s + add v7.4s, v7.4s, v28.4s + add v12.4s, v12.4s, v29.4s + add v17.4s, v17.4s, v30.4s + + add v3.4s, v3.4s, v24.4s + add v8.4s, v8.4s, v28.4s + add v13.4s, v13.4s, v29.4s + add v18.4s, v18.4s, v30.4s + + add v4.4s, v4.4s, v24.4s + add v9.4s, v9.4s, v28.4s + add v14.4s, v14.4s, v29.4s + add v19.4s, v19.4s, v30.4s + + cmp x2, #320 + b.le Lseal_tail + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v0.16b + eor v21.16b, v21.16b, v5.16b + eor v22.16b, v22.16b, v10.16b + eor v23.16b, v23.16b, v15.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v1.16b + eor v21.16b, v21.16b, v6.16b + eor v22.16b, v22.16b, v11.16b + eor v23.16b, v23.16b, v16.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v2.16b + eor v21.16b, v21.16b, v7.16b + eor v22.16b, v22.16b, v12.16b + eor v23.16b, v23.16b, v17.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v3.16b + eor v21.16b, v21.16b, v8.16b + eor v22.16b, v22.16b, v13.16b + eor v23.16b, v23.16b, v18.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v4.16b + eor v21.16b, v21.16b, v9.16b + eor v22.16b, v22.16b, v14.16b + eor v23.16b, v23.16b, v19.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + sub x2, x2, #320 + + mov x6, #0 + mov x7, #10 // For the remainder of the loop we always hash and encrypt 320 bytes per iteration + + b Lseal_main_loop + +Lseal_tail: + // This part of the function handles the storage and authentication of the last [0,320) bytes + // We assume A0-A4 ... D0-D4 hold at least inl (320 max) bytes of the stream data. + cmp x2, #64 + b.lt Lseal_tail_64 + + // Store and authenticate 64B blocks per iteration + ld1 {v20.16b - v23.16b}, [x1], #64 + + eor v20.16b, v20.16b, v0.16b + eor v21.16b, v21.16b, v5.16b + eor v22.16b, v22.16b, v10.16b + eor v23.16b, v23.16b, v15.16b + mov x11, v20.d[0] + mov x12, v20.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + mov x11, v21.d[0] + mov x12, v21.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + mov x11, v22.d[0] + mov x12, v22.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + mov x11, v23.d[0] + mov x12, v23.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + st1 {v20.16b - v23.16b}, [x0], #64 + sub x2, x2, #64 + + // Shift the state left by 64 bytes for the next iteration of the loop + mov v0.16b, v1.16b + mov v5.16b, v6.16b + mov v10.16b, v11.16b + mov v15.16b, v16.16b + + mov v1.16b, v2.16b + mov v6.16b, v7.16b + mov v11.16b, v12.16b + mov v16.16b, v17.16b + + mov v2.16b, v3.16b + mov v7.16b, v8.16b + mov v12.16b, v13.16b + mov v17.16b, v18.16b + + mov v3.16b, v4.16b + mov v8.16b, v9.16b + mov v13.16b, v14.16b + mov v18.16b, v19.16b + + b Lseal_tail + +Lseal_tail_64: + ldp x3, x4, [x5, #48] // extra_in_len and extra_in_ptr + + // Here we handle the last [0,64) bytes of plaintext + cmp x2, #16 + b.lt Lseal_tail_16 + // Each iteration encrypt and authenticate a 16B block + ld1 {v20.16b}, [x1], #16 + eor v20.16b, v20.16b, v0.16b + mov x11, v20.d[0] + mov x12, v20.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + st1 {v20.16b}, [x0], #16 + + sub x2, x2, #16 + + // Shift the state left by 16 bytes for the next iteration of the loop + mov v0.16b, v5.16b + mov v5.16b, v10.16b + mov v10.16b, v15.16b + + b Lseal_tail_64 + +Lseal_tail_16: + // Here we handle the last [0,16) bytes of ciphertext that require a padded block + cbz x2, Lseal_hash_extra + + eor v20.16b, v20.16b, v20.16b // Use T0 to load the plaintext/extra in + eor v21.16b, v21.16b, v21.16b // Use T1 to generate an AND mask that will only mask the ciphertext bytes + not v22.16b, v20.16b + + mov x6, x2 + add x1, x1, x2 + + cbz x4, Lseal_tail_16_compose // No extra data to pad with, zero padding + + mov x7, #16 // We need to load some extra_in first for padding + sub x7, x7, x2 + cmp x4, x7 + csel x7, x4, x7, lt // Load the minimum of extra_in_len and the amount needed to fill the register + mov x12, x7 + add x3, x3, x7 + sub x4, x4, x7 + +Lseal_tail16_compose_extra_in: + ext v20.16b, v20.16b, v20.16b, #15 + ldrb w11, [x3, #-1]! + mov v20.b[0], w11 + subs x7, x7, #1 + b.gt Lseal_tail16_compose_extra_in + + add x3, x3, x12 + +Lseal_tail_16_compose: + ext v20.16b, v20.16b, v20.16b, #15 + ldrb w11, [x1, #-1]! + mov v20.b[0], w11 + ext v21.16b, v22.16b, v21.16b, #15 + subs x2, x2, #1 + b.gt Lseal_tail_16_compose + + and v0.16b, v0.16b, v21.16b + eor v20.16b, v20.16b, v0.16b + mov v21.16b, v20.16b + +Lseal_tail_16_store: + umov w11, v20.b[0] + strb w11, [x0], #1 + ext v20.16b, v20.16b, v20.16b, #1 + subs x6, x6, #1 + b.gt Lseal_tail_16_store + + // Hash in the final ct block concatenated with extra_in + mov x11, v21.d[0] + mov x12, v21.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + +Lseal_hash_extra: + cbz x4, Lseal_finalize + +Lseal_hash_extra_loop: + cmp x4, #16 + b.lt Lseal_hash_extra_tail + ld1 {v20.16b}, [x3], #16 + mov x11, v20.d[0] + mov x12, v20.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + sub x4, x4, #16 + b Lseal_hash_extra_loop + +Lseal_hash_extra_tail: + cbz x4, Lseal_finalize + eor v20.16b, v20.16b, v20.16b // Use T0 to load the remaining extra ciphertext + add x3, x3, x4 + +Lseal_hash_extra_load: + ext v20.16b, v20.16b, v20.16b, #15 + ldrb w11, [x3, #-1]! + mov v20.b[0], w11 + subs x4, x4, #1 + b.gt Lseal_hash_extra_load + + // Hash in the final padded extra_in blcok + mov x11, v20.d[0] + mov x12, v20.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + +Lseal_finalize: + mov x11, v31.d[0] + mov x12, v31.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + // Final reduction step + sub x12, xzr, x15 + orr x13, xzr, #3 + subs x11, x8, #-5 + sbcs x12, x9, x12 + sbcs x13, x10, x13 + csel x8, x11, x8, cs + csel x9, x12, x9, cs + csel x10, x13, x10, cs + mov x11, v27.d[0] + mov x12, v27.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + + stp x8, x9, [x5] + + ldp d8, d9, [sp, #16] + ldp d10, d11, [sp, #32] + ldp d12, d13, [sp, #48] + ldp d14, d15, [sp, #64] +.cfi_restore b15 +.cfi_restore b14 +.cfi_restore b13 +.cfi_restore b12 +.cfi_restore b11 +.cfi_restore b10 +.cfi_restore b9 +.cfi_restore b8 + ldp x29, x30, [sp], 80 +.cfi_restore w29 +.cfi_restore w30 +.cfi_def_cfa_offset 0 + AARCH64_VALIDATE_LINK_REGISTER + ret + +Lseal_128: + // On some architectures preparing 5 blocks for small buffers is wasteful + eor v25.16b, v25.16b, v25.16b + mov x11, #1 + mov v25.s[0], w11 + mov v0.16b, v24.16b + mov v1.16b, v24.16b + mov v2.16b, v24.16b + mov v5.16b, v28.16b + mov v6.16b, v28.16b + mov v7.16b, v28.16b + mov v10.16b, v29.16b + mov v11.16b, v29.16b + mov v12.16b, v29.16b + mov v17.16b, v30.16b + add v15.4s, v17.4s, v25.4s + add v16.4s, v15.4s, v25.4s + + mov x6, #10 + +Lseal_128_rounds: + add v0.4s, v0.4s, v5.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v5.16b, v5.16b, v10.16b + eor v6.16b, v6.16b, v11.16b + eor v7.16b, v7.16b, v12.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + ushr v5.4s, v6.4s, #20 + sli v5.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v5.4s + add v2.4s, v2.4s, v6.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v20.16b, v20.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v6.16b, v6.16b, v12.16b + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v5.4s, #25 + sli v6.4s, v5.4s, #7 + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + + ext v5.16b, v5.16b, v5.16b, #4 + ext v6.16b, v6.16b, v6.16b, #4 + ext v7.16b, v7.16b, v7.16b, #4 + + ext v10.16b, v10.16b, v10.16b, #8 + ext v11.16b, v11.16b, v11.16b, #8 + ext v12.16b, v12.16b, v12.16b, #8 + + ext v15.16b, v15.16b, v15.16b, #12 + ext v16.16b, v16.16b, v16.16b, #12 + ext v17.16b, v17.16b, v17.16b, #12 + add v0.4s, v0.4s, v5.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v5.16b, v5.16b, v10.16b + eor v6.16b, v6.16b, v11.16b + eor v7.16b, v7.16b, v12.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + ushr v5.4s, v6.4s, #20 + sli v5.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v5.4s + add v2.4s, v2.4s, v6.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v20.16b, v20.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v6.16b, v6.16b, v12.16b + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v5.4s, #25 + sli v6.4s, v5.4s, #7 + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + + ext v5.16b, v5.16b, v5.16b, #12 + ext v6.16b, v6.16b, v6.16b, #12 + ext v7.16b, v7.16b, v7.16b, #12 + + ext v10.16b, v10.16b, v10.16b, #8 + ext v11.16b, v11.16b, v11.16b, #8 + ext v12.16b, v12.16b, v12.16b, #8 + + ext v15.16b, v15.16b, v15.16b, #4 + ext v16.16b, v16.16b, v16.16b, #4 + ext v17.16b, v17.16b, v17.16b, #4 + subs x6, x6, #1 + b.hi Lseal_128_rounds + + add v0.4s, v0.4s, v24.4s + add v1.4s, v1.4s, v24.4s + add v2.4s, v2.4s, v24.4s + + add v5.4s, v5.4s, v28.4s + add v6.4s, v6.4s, v28.4s + add v7.4s, v7.4s, v28.4s + + // Only the first 32 bytes of the third block (counter = 0) are needed, + // so skip updating v12 and v17. + add v10.4s, v10.4s, v29.4s + add v11.4s, v11.4s, v29.4s + + add v30.4s, v30.4s, v25.4s + add v15.4s, v15.4s, v30.4s + add v30.4s, v30.4s, v25.4s + add v16.4s, v16.4s, v30.4s + + and v2.16b, v2.16b, v27.16b + mov x16, v2.d[0] // Move the R key to GPRs + mov x17, v2.d[1] + mov v27.16b, v7.16b // Store the S key + + bl Lpoly_hash_ad_internal + b Lseal_tail +.cfi_endproc + + +///////////////////////////////// +// +// void chacha20_poly1305_open(uint8_t *pt, uint8_t *ct, size_t len_in, uint8_t *ad, size_t len_ad, union open_data *aead_data); +// +.globl chacha20_poly1305_open + +.def chacha20_poly1305_open + .type 32 +.endef +.align 6 +chacha20_poly1305_open: + AARCH64_SIGN_LINK_REGISTER +.cfi_startproc + stp x29, x30, [sp, #-80]! +.cfi_def_cfa_offset 80 +.cfi_offset w30, -72 +.cfi_offset w29, -80 + mov x29, sp + // We probably could do .cfi_def_cfa w29, 80 at this point, but since + // we don't actually use the frame pointer like that, it's probably not + // worth bothering. + stp d8, d9, [sp, #16] + stp d10, d11, [sp, #32] + stp d12, d13, [sp, #48] + stp d14, d15, [sp, #64] +.cfi_offset b15, -8 +.cfi_offset b14, -16 +.cfi_offset b13, -24 +.cfi_offset b12, -32 +.cfi_offset b11, -40 +.cfi_offset b10, -48 +.cfi_offset b9, -56 +.cfi_offset b8, -64 + + adrp x11, Lchacha20_consts + add x11, x11, :lo12:Lchacha20_consts + + ld1 {v24.16b - v27.16b}, [x11] // Load the CONSTS, INC, ROL8 and CLAMP values + ld1 {v28.16b - v30.16b}, [x5] + + mov x15, #1 // Prepare the Poly1305 state + mov x8, #0 + mov x9, #0 + mov x10, #0 + + mov v31.d[0], x4 // Store the input and aad lengths + mov v31.d[1], x2 + + cmp x2, #128 + b.le Lopen_128 // Optimization for smaller buffers + + // Initially we prepare a single ChaCha20 block for the Poly1305 R and S keys + mov v0.16b, v24.16b + mov v5.16b, v28.16b + mov v10.16b, v29.16b + mov v15.16b, v30.16b + + mov x6, #10 + +.align 5 +Lopen_init_rounds: + add v0.4s, v0.4s, v5.4s + eor v15.16b, v15.16b, v0.16b + rev32 v15.8h, v15.8h + + add v10.4s, v10.4s, v15.4s + eor v5.16b, v5.16b, v10.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + add v0.4s, v0.4s, v20.4s + eor v15.16b, v15.16b, v0.16b + tbl v15.16b, {v15.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + eor v20.16b, v20.16b, v10.16b + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + ext v5.16b, v5.16b, v5.16b, #4 + ext v10.16b, v10.16b, v10.16b, #8 + ext v15.16b, v15.16b, v15.16b, #12 + add v0.4s, v0.4s, v5.4s + eor v15.16b, v15.16b, v0.16b + rev32 v15.8h, v15.8h + + add v10.4s, v10.4s, v15.4s + eor v5.16b, v5.16b, v10.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + add v0.4s, v0.4s, v20.4s + eor v15.16b, v15.16b, v0.16b + tbl v15.16b, {v15.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + eor v20.16b, v20.16b, v10.16b + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + ext v5.16b, v5.16b, v5.16b, #12 + ext v10.16b, v10.16b, v10.16b, #8 + ext v15.16b, v15.16b, v15.16b, #4 + subs x6, x6, #1 + b.hi Lopen_init_rounds + + add v0.4s, v0.4s, v24.4s + add v5.4s, v5.4s, v28.4s + + and v0.16b, v0.16b, v27.16b + mov x16, v0.d[0] // Move the R key to GPRs + mov x17, v0.d[1] + mov v27.16b, v5.16b // Store the S key + + bl Lpoly_hash_ad_internal + +Lopen_ad_done: + mov x3, x1 + +// Each iteration of the loop hash 320 bytes, and prepare stream for 320 bytes +Lopen_main_loop: + + cmp x2, #192 + b.lt Lopen_tail + + adrp x11, Lchacha20_consts + add x11, x11, :lo12:Lchacha20_consts + + ld4r {v0.4s,v1.4s,v2.4s,v3.4s}, [x11] + mov v4.16b, v24.16b + + ld4r {v5.4s,v6.4s,v7.4s,v8.4s}, [x5], #16 + mov v9.16b, v28.16b + + ld4r {v10.4s,v11.4s,v12.4s,v13.4s}, [x5], #16 + mov v14.16b, v29.16b + + ld4r {v15.4s,v16.4s,v17.4s,v18.4s}, [x5] + sub x5, x5, #32 + add v15.4s, v15.4s, v25.4s + mov v19.16b, v30.16b + + eor v20.16b, v20.16b, v20.16b //zero + not v21.16b, v20.16b // -1 + sub v21.4s, v25.4s, v21.4s // Add +1 + ext v20.16b, v21.16b, v20.16b, #12 // Get the last element (counter) + add v19.4s, v19.4s, v20.4s + + lsr x4, x2, #4 // How many whole blocks we have to hash, will always be at least 12 + sub x4, x4, #10 + + mov x7, #10 + subs x6, x7, x4 + subs x6, x7, x4 // itr1 can be negative if we have more than 320 bytes to hash + csel x7, x7, x4, le // if itr1 is zero or less, itr2 should be 10 to indicate all 10 rounds are full + + cbz x7, Lopen_main_loop_rounds_short + +.align 5 +Lopen_main_loop_rounds: + ldp x11, x12, [x3], 16 + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most +Lopen_main_loop_rounds_short: + add v0.4s, v0.4s, v5.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + add v3.4s, v3.4s, v8.4s + add v4.4s, v4.4s, v9.4s + + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + eor v18.16b, v18.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + rev32 v18.8h, v18.8h + rev32 v19.8h, v19.8h + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + add v13.4s, v13.4s, v18.4s + add v14.4s, v14.4s, v19.4s + + eor v5.16b, v5.16b, v10.16b + eor v6.16b, v6.16b, v11.16b + eor v7.16b, v7.16b, v12.16b + eor v8.16b, v8.16b, v13.16b + eor v9.16b, v9.16b, v14.16b + + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + ushr v5.4s, v6.4s, #20 + sli v5.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + ushr v7.4s, v8.4s, #20 + sli v7.4s, v8.4s, #12 + ushr v8.4s, v9.4s, #20 + sli v8.4s, v9.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v5.4s + add v2.4s, v2.4s, v6.4s + add v3.4s, v3.4s, v7.4s + add v4.4s, v4.4s, v8.4s + + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + eor v18.16b, v18.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + tbl v18.16b, {v18.16b}, v26.16b + tbl v19.16b, {v19.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + add v13.4s, v13.4s, v18.4s + add v14.4s, v14.4s, v19.4s + + eor v20.16b, v20.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v6.16b, v6.16b, v12.16b + eor v7.16b, v7.16b, v13.16b + eor v8.16b, v8.16b, v14.16b + + ushr v9.4s, v8.4s, #25 + sli v9.4s, v8.4s, #7 + ushr v8.4s, v7.4s, #25 + sli v8.4s, v7.4s, #7 + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v5.4s, #25 + sli v6.4s, v5.4s, #7 + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + + ext v9.16b, v9.16b, v9.16b, #4 + ext v14.16b, v14.16b, v14.16b, #8 + ext v19.16b, v19.16b, v19.16b, #12 + ldp x11, x12, [x3], 16 + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + add v0.4s, v0.4s, v6.4s + add v1.4s, v1.4s, v7.4s + add v2.4s, v2.4s, v8.4s + add v3.4s, v3.4s, v5.4s + add v4.4s, v4.4s, v9.4s + + eor v18.16b, v18.16b, v0.16b + eor v15.16b, v15.16b, v1.16b + eor v16.16b, v16.16b, v2.16b + eor v17.16b, v17.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + rev32 v18.8h, v18.8h + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + rev32 v19.8h, v19.8h + + add v12.4s, v12.4s, v18.4s + add v13.4s, v13.4s, v15.4s + add v10.4s, v10.4s, v16.4s + add v11.4s, v11.4s, v17.4s + add v14.4s, v14.4s, v19.4s + + eor v6.16b, v6.16b, v12.16b + eor v7.16b, v7.16b, v13.16b + eor v8.16b, v8.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v9.16b, v9.16b, v14.16b + + ushr v20.4s, v6.4s, #20 + sli v20.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + ushr v7.4s, v8.4s, #20 + sli v7.4s, v8.4s, #12 + ushr v8.4s, v5.4s, #20 + sli v8.4s, v5.4s, #12 + ushr v5.4s, v9.4s, #20 + sli v5.4s, v9.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + add v3.4s, v3.4s, v8.4s + add v4.4s, v4.4s, v5.4s + + eor v18.16b, v18.16b, v0.16b + eor v15.16b, v15.16b, v1.16b + eor v16.16b, v16.16b, v2.16b + eor v17.16b, v17.16b, v3.16b + eor v19.16b, v19.16b, v4.16b + + tbl v18.16b, {v18.16b}, v26.16b + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + tbl v19.16b, {v19.16b}, v26.16b + + add v12.4s, v12.4s, v18.4s + add v13.4s, v13.4s, v15.4s + add v10.4s, v10.4s, v16.4s + add v11.4s, v11.4s, v17.4s + add v14.4s, v14.4s, v19.4s + + eor v20.16b, v20.16b, v12.16b + eor v6.16b, v6.16b, v13.16b + eor v7.16b, v7.16b, v10.16b + eor v8.16b, v8.16b, v11.16b + eor v5.16b, v5.16b, v14.16b + + ushr v9.4s, v5.4s, #25 + sli v9.4s, v5.4s, #7 + ushr v5.4s, v8.4s, #25 + sli v5.4s, v8.4s, #7 + ushr v8.4s, v7.4s, #25 + sli v8.4s, v7.4s, #7 + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v20.4s, #25 + sli v6.4s, v20.4s, #7 + + ext v9.16b, v9.16b, v9.16b, #12 + ext v14.16b, v14.16b, v14.16b, #8 + ext v19.16b, v19.16b, v19.16b, #4 + subs x7, x7, #1 + b.gt Lopen_main_loop_rounds + subs x6, x6, #1 + b.ge Lopen_main_loop_rounds_short + + eor v20.16b, v20.16b, v20.16b //zero + not v21.16b, v20.16b // -1 + sub v21.4s, v25.4s, v21.4s // Add +1 + ext v20.16b, v21.16b, v20.16b, #12 // Get the last element (counter) + add v19.4s, v19.4s, v20.4s + + add v15.4s, v15.4s, v25.4s + mov x11, #5 + dup v20.4s, w11 + add v25.4s, v25.4s, v20.4s + + zip1 v20.4s, v0.4s, v1.4s + zip2 v21.4s, v0.4s, v1.4s + zip1 v22.4s, v2.4s, v3.4s + zip2 v23.4s, v2.4s, v3.4s + + zip1 v0.2d, v20.2d, v22.2d + zip2 v1.2d, v20.2d, v22.2d + zip1 v2.2d, v21.2d, v23.2d + zip2 v3.2d, v21.2d, v23.2d + + zip1 v20.4s, v5.4s, v6.4s + zip2 v21.4s, v5.4s, v6.4s + zip1 v22.4s, v7.4s, v8.4s + zip2 v23.4s, v7.4s, v8.4s + + zip1 v5.2d, v20.2d, v22.2d + zip2 v6.2d, v20.2d, v22.2d + zip1 v7.2d, v21.2d, v23.2d + zip2 v8.2d, v21.2d, v23.2d + + zip1 v20.4s, v10.4s, v11.4s + zip2 v21.4s, v10.4s, v11.4s + zip1 v22.4s, v12.4s, v13.4s + zip2 v23.4s, v12.4s, v13.4s + + zip1 v10.2d, v20.2d, v22.2d + zip2 v11.2d, v20.2d, v22.2d + zip1 v12.2d, v21.2d, v23.2d + zip2 v13.2d, v21.2d, v23.2d + + zip1 v20.4s, v15.4s, v16.4s + zip2 v21.4s, v15.4s, v16.4s + zip1 v22.4s, v17.4s, v18.4s + zip2 v23.4s, v17.4s, v18.4s + + zip1 v15.2d, v20.2d, v22.2d + zip2 v16.2d, v20.2d, v22.2d + zip1 v17.2d, v21.2d, v23.2d + zip2 v18.2d, v21.2d, v23.2d + + add v0.4s, v0.4s, v24.4s + add v5.4s, v5.4s, v28.4s + add v10.4s, v10.4s, v29.4s + add v15.4s, v15.4s, v30.4s + + add v1.4s, v1.4s, v24.4s + add v6.4s, v6.4s, v28.4s + add v11.4s, v11.4s, v29.4s + add v16.4s, v16.4s, v30.4s + + add v2.4s, v2.4s, v24.4s + add v7.4s, v7.4s, v28.4s + add v12.4s, v12.4s, v29.4s + add v17.4s, v17.4s, v30.4s + + add v3.4s, v3.4s, v24.4s + add v8.4s, v8.4s, v28.4s + add v13.4s, v13.4s, v29.4s + add v18.4s, v18.4s, v30.4s + + add v4.4s, v4.4s, v24.4s + add v9.4s, v9.4s, v28.4s + add v14.4s, v14.4s, v29.4s + add v19.4s, v19.4s, v30.4s + + // We can always safely store 192 bytes + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v0.16b + eor v21.16b, v21.16b, v5.16b + eor v22.16b, v22.16b, v10.16b + eor v23.16b, v23.16b, v15.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v1.16b + eor v21.16b, v21.16b, v6.16b + eor v22.16b, v22.16b, v11.16b + eor v23.16b, v23.16b, v16.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v2.16b + eor v21.16b, v21.16b, v7.16b + eor v22.16b, v22.16b, v12.16b + eor v23.16b, v23.16b, v17.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + sub x2, x2, #192 + + mov v0.16b, v3.16b + mov v5.16b, v8.16b + mov v10.16b, v13.16b + mov v15.16b, v18.16b + + cmp x2, #64 + b.lt Lopen_tail_64_store + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v3.16b + eor v21.16b, v21.16b, v8.16b + eor v22.16b, v22.16b, v13.16b + eor v23.16b, v23.16b, v18.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + sub x2, x2, #64 + + mov v0.16b, v4.16b + mov v5.16b, v9.16b + mov v10.16b, v14.16b + mov v15.16b, v19.16b + + cmp x2, #64 + b.lt Lopen_tail_64_store + + ld1 {v20.16b - v23.16b}, [x1], #64 + eor v20.16b, v20.16b, v4.16b + eor v21.16b, v21.16b, v9.16b + eor v22.16b, v22.16b, v14.16b + eor v23.16b, v23.16b, v19.16b + st1 {v20.16b - v23.16b}, [x0], #64 + + sub x2, x2, #64 + b Lopen_main_loop + +Lopen_tail: + + cbz x2, Lopen_finalize + + lsr x4, x2, #4 // How many whole blocks we have to hash + + cmp x2, #64 + b.le Lopen_tail_64 + cmp x2, #128 + b.le Lopen_tail_128 + +Lopen_tail_192: + // We need three more blocks + mov v0.16b, v24.16b + mov v1.16b, v24.16b + mov v2.16b, v24.16b + mov v5.16b, v28.16b + mov v6.16b, v28.16b + mov v7.16b, v28.16b + mov v10.16b, v29.16b + mov v11.16b, v29.16b + mov v12.16b, v29.16b + mov v15.16b, v30.16b + mov v16.16b, v30.16b + mov v17.16b, v30.16b + eor v23.16b, v23.16b, v23.16b + eor v21.16b, v21.16b, v21.16b + ins v23.s[0], v25.s[0] + ins v21.d[0], x15 + + add v22.4s, v23.4s, v21.4s + add v21.4s, v22.4s, v21.4s + + add v15.4s, v15.4s, v21.4s + add v16.4s, v16.4s, v23.4s + add v17.4s, v17.4s, v22.4s + + mov x7, #10 + subs x6, x7, x4 // itr1 can be negative if we have more than 160 bytes to hash + csel x7, x7, x4, le // if itr1 is zero or less, itr2 should be 10 to indicate all 10 rounds are hashing + sub x4, x4, x7 + + cbz x7, Lopen_tail_192_rounds_no_hash + +Lopen_tail_192_rounds: + ldp x11, x12, [x3], 16 + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most +Lopen_tail_192_rounds_no_hash: + add v0.4s, v0.4s, v5.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v5.16b, v5.16b, v10.16b + eor v6.16b, v6.16b, v11.16b + eor v7.16b, v7.16b, v12.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + ushr v5.4s, v6.4s, #20 + sli v5.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v5.4s + add v2.4s, v2.4s, v6.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v20.16b, v20.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v6.16b, v6.16b, v12.16b + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v5.4s, #25 + sli v6.4s, v5.4s, #7 + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + + ext v5.16b, v5.16b, v5.16b, #4 + ext v6.16b, v6.16b, v6.16b, #4 + ext v7.16b, v7.16b, v7.16b, #4 + + ext v10.16b, v10.16b, v10.16b, #8 + ext v11.16b, v11.16b, v11.16b, #8 + ext v12.16b, v12.16b, v12.16b, #8 + + ext v15.16b, v15.16b, v15.16b, #12 + ext v16.16b, v16.16b, v16.16b, #12 + ext v17.16b, v17.16b, v17.16b, #12 + add v0.4s, v0.4s, v5.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v5.16b, v5.16b, v10.16b + eor v6.16b, v6.16b, v11.16b + eor v7.16b, v7.16b, v12.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + ushr v5.4s, v6.4s, #20 + sli v5.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v5.4s + add v2.4s, v2.4s, v6.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v20.16b, v20.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v6.16b, v6.16b, v12.16b + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v5.4s, #25 + sli v6.4s, v5.4s, #7 + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + + ext v5.16b, v5.16b, v5.16b, #12 + ext v6.16b, v6.16b, v6.16b, #12 + ext v7.16b, v7.16b, v7.16b, #12 + + ext v10.16b, v10.16b, v10.16b, #8 + ext v11.16b, v11.16b, v11.16b, #8 + ext v12.16b, v12.16b, v12.16b, #8 + + ext v15.16b, v15.16b, v15.16b, #4 + ext v16.16b, v16.16b, v16.16b, #4 + ext v17.16b, v17.16b, v17.16b, #4 + subs x7, x7, #1 + b.gt Lopen_tail_192_rounds + subs x6, x6, #1 + b.ge Lopen_tail_192_rounds_no_hash + + // We hashed 160 bytes at most, may still have 32 bytes left +Lopen_tail_192_hash: + cbz x4, Lopen_tail_192_hash_done + ldp x11, x12, [x3], 16 + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + sub x4, x4, #1 + b Lopen_tail_192_hash + +Lopen_tail_192_hash_done: + + add v0.4s, v0.4s, v24.4s + add v1.4s, v1.4s, v24.4s + add v2.4s, v2.4s, v24.4s + add v5.4s, v5.4s, v28.4s + add v6.4s, v6.4s, v28.4s + add v7.4s, v7.4s, v28.4s + add v10.4s, v10.4s, v29.4s + add v11.4s, v11.4s, v29.4s + add v12.4s, v12.4s, v29.4s + add v15.4s, v15.4s, v30.4s + add v16.4s, v16.4s, v30.4s + add v17.4s, v17.4s, v30.4s + + add v15.4s, v15.4s, v21.4s + add v16.4s, v16.4s, v23.4s + add v17.4s, v17.4s, v22.4s + + ld1 {v20.16b - v23.16b}, [x1], #64 + + eor v20.16b, v20.16b, v1.16b + eor v21.16b, v21.16b, v6.16b + eor v22.16b, v22.16b, v11.16b + eor v23.16b, v23.16b, v16.16b + + st1 {v20.16b - v23.16b}, [x0], #64 + + ld1 {v20.16b - v23.16b}, [x1], #64 + + eor v20.16b, v20.16b, v2.16b + eor v21.16b, v21.16b, v7.16b + eor v22.16b, v22.16b, v12.16b + eor v23.16b, v23.16b, v17.16b + + st1 {v20.16b - v23.16b}, [x0], #64 + + sub x2, x2, #128 + b Lopen_tail_64_store + +Lopen_tail_128: + // We need two more blocks + mov v0.16b, v24.16b + mov v1.16b, v24.16b + mov v5.16b, v28.16b + mov v6.16b, v28.16b + mov v10.16b, v29.16b + mov v11.16b, v29.16b + mov v15.16b, v30.16b + mov v16.16b, v30.16b + eor v23.16b, v23.16b, v23.16b + eor v22.16b, v22.16b, v22.16b + ins v23.s[0], v25.s[0] + ins v22.d[0], x15 + add v22.4s, v22.4s, v23.4s + + add v15.4s, v15.4s, v22.4s + add v16.4s, v16.4s, v23.4s + + mov x6, #10 + sub x6, x6, x4 + +Lopen_tail_128_rounds: + add v0.4s, v0.4s, v5.4s + eor v15.16b, v15.16b, v0.16b + rev32 v15.8h, v15.8h + + add v10.4s, v10.4s, v15.4s + eor v5.16b, v5.16b, v10.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + add v0.4s, v0.4s, v20.4s + eor v15.16b, v15.16b, v0.16b + tbl v15.16b, {v15.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + eor v20.16b, v20.16b, v10.16b + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + ext v5.16b, v5.16b, v5.16b, #4 + ext v10.16b, v10.16b, v10.16b, #8 + ext v15.16b, v15.16b, v15.16b, #12 + add v1.4s, v1.4s, v6.4s + eor v16.16b, v16.16b, v1.16b + rev32 v16.8h, v16.8h + + add v11.4s, v11.4s, v16.4s + eor v6.16b, v6.16b, v11.16b + ushr v20.4s, v6.4s, #20 + sli v20.4s, v6.4s, #12 + add v1.4s, v1.4s, v20.4s + eor v16.16b, v16.16b, v1.16b + tbl v16.16b, {v16.16b}, v26.16b + + add v11.4s, v11.4s, v16.4s + eor v20.16b, v20.16b, v11.16b + ushr v6.4s, v20.4s, #25 + sli v6.4s, v20.4s, #7 + ext v6.16b, v6.16b, v6.16b, #4 + ext v11.16b, v11.16b, v11.16b, #8 + ext v16.16b, v16.16b, v16.16b, #12 + add v0.4s, v0.4s, v5.4s + eor v15.16b, v15.16b, v0.16b + rev32 v15.8h, v15.8h + + add v10.4s, v10.4s, v15.4s + eor v5.16b, v5.16b, v10.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + add v0.4s, v0.4s, v20.4s + eor v15.16b, v15.16b, v0.16b + tbl v15.16b, {v15.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + eor v20.16b, v20.16b, v10.16b + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + ext v5.16b, v5.16b, v5.16b, #12 + ext v10.16b, v10.16b, v10.16b, #8 + ext v15.16b, v15.16b, v15.16b, #4 + add v1.4s, v1.4s, v6.4s + eor v16.16b, v16.16b, v1.16b + rev32 v16.8h, v16.8h + + add v11.4s, v11.4s, v16.4s + eor v6.16b, v6.16b, v11.16b + ushr v20.4s, v6.4s, #20 + sli v20.4s, v6.4s, #12 + add v1.4s, v1.4s, v20.4s + eor v16.16b, v16.16b, v1.16b + tbl v16.16b, {v16.16b}, v26.16b + + add v11.4s, v11.4s, v16.4s + eor v20.16b, v20.16b, v11.16b + ushr v6.4s, v20.4s, #25 + sli v6.4s, v20.4s, #7 + ext v6.16b, v6.16b, v6.16b, #12 + ext v11.16b, v11.16b, v11.16b, #8 + ext v16.16b, v16.16b, v16.16b, #4 + subs x6, x6, #1 + b.gt Lopen_tail_128_rounds + cbz x4, Lopen_tail_128_rounds_done + subs x4, x4, #1 + ldp x11, x12, [x3], 16 + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + b Lopen_tail_128_rounds + +Lopen_tail_128_rounds_done: + add v0.4s, v0.4s, v24.4s + add v1.4s, v1.4s, v24.4s + add v5.4s, v5.4s, v28.4s + add v6.4s, v6.4s, v28.4s + add v10.4s, v10.4s, v29.4s + add v11.4s, v11.4s, v29.4s + add v15.4s, v15.4s, v30.4s + add v16.4s, v16.4s, v30.4s + add v15.4s, v15.4s, v22.4s + add v16.4s, v16.4s, v23.4s + + ld1 {v20.16b - v23.16b}, [x1], #64 + + eor v20.16b, v20.16b, v1.16b + eor v21.16b, v21.16b, v6.16b + eor v22.16b, v22.16b, v11.16b + eor v23.16b, v23.16b, v16.16b + + st1 {v20.16b - v23.16b}, [x0], #64 + sub x2, x2, #64 + + b Lopen_tail_64_store + +Lopen_tail_64: + // We just need a single block + mov v0.16b, v24.16b + mov v5.16b, v28.16b + mov v10.16b, v29.16b + mov v15.16b, v30.16b + eor v23.16b, v23.16b, v23.16b + ins v23.s[0], v25.s[0] + add v15.4s, v15.4s, v23.4s + + mov x6, #10 + sub x6, x6, x4 + +Lopen_tail_64_rounds: + add v0.4s, v0.4s, v5.4s + eor v15.16b, v15.16b, v0.16b + rev32 v15.8h, v15.8h + + add v10.4s, v10.4s, v15.4s + eor v5.16b, v5.16b, v10.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + add v0.4s, v0.4s, v20.4s + eor v15.16b, v15.16b, v0.16b + tbl v15.16b, {v15.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + eor v20.16b, v20.16b, v10.16b + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + ext v5.16b, v5.16b, v5.16b, #4 + ext v10.16b, v10.16b, v10.16b, #8 + ext v15.16b, v15.16b, v15.16b, #12 + add v0.4s, v0.4s, v5.4s + eor v15.16b, v15.16b, v0.16b + rev32 v15.8h, v15.8h + + add v10.4s, v10.4s, v15.4s + eor v5.16b, v5.16b, v10.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + add v0.4s, v0.4s, v20.4s + eor v15.16b, v15.16b, v0.16b + tbl v15.16b, {v15.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + eor v20.16b, v20.16b, v10.16b + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + ext v5.16b, v5.16b, v5.16b, #12 + ext v10.16b, v10.16b, v10.16b, #8 + ext v15.16b, v15.16b, v15.16b, #4 + subs x6, x6, #1 + b.gt Lopen_tail_64_rounds + cbz x4, Lopen_tail_64_rounds_done + subs x4, x4, #1 + ldp x11, x12, [x3], 16 + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + b Lopen_tail_64_rounds + +Lopen_tail_64_rounds_done: + add v0.4s, v0.4s, v24.4s + add v5.4s, v5.4s, v28.4s + add v10.4s, v10.4s, v29.4s + add v15.4s, v15.4s, v30.4s + add v15.4s, v15.4s, v23.4s + +Lopen_tail_64_store: + cmp x2, #16 + b.lt Lopen_tail_16 + + ld1 {v20.16b}, [x1], #16 + eor v20.16b, v20.16b, v0.16b + st1 {v20.16b}, [x0], #16 + mov v0.16b, v5.16b + mov v5.16b, v10.16b + mov v10.16b, v15.16b + sub x2, x2, #16 + b Lopen_tail_64_store + +Lopen_tail_16: + // Here we handle the last [0,16) bytes that require a padded block + cbz x2, Lopen_finalize + + eor v20.16b, v20.16b, v20.16b // Use T0 to load the ciphertext + eor v21.16b, v21.16b, v21.16b // Use T1 to generate an AND mask + not v22.16b, v20.16b + + add x7, x1, x2 + mov x6, x2 + +Lopen_tail_16_compose: + ext v20.16b, v20.16b, v20.16b, #15 + ldrb w11, [x7, #-1]! + mov v20.b[0], w11 + ext v21.16b, v22.16b, v21.16b, #15 + subs x2, x2, #1 + b.gt Lopen_tail_16_compose + + and v20.16b, v20.16b, v21.16b + // Hash in the final padded block + mov x11, v20.d[0] + mov x12, v20.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + eor v20.16b, v20.16b, v0.16b + +Lopen_tail_16_store: + umov w11, v20.b[0] + strb w11, [x0], #1 + ext v20.16b, v20.16b, v20.16b, #1 + subs x6, x6, #1 + b.gt Lopen_tail_16_store + +Lopen_finalize: + mov x11, v31.d[0] + mov x12, v31.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + // Final reduction step + sub x12, xzr, x15 + orr x13, xzr, #3 + subs x11, x8, #-5 + sbcs x12, x9, x12 + sbcs x13, x10, x13 + csel x8, x11, x8, cs + csel x9, x12, x9, cs + csel x10, x13, x10, cs + mov x11, v27.d[0] + mov x12, v27.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + + stp x8, x9, [x5] + + ldp d8, d9, [sp, #16] + ldp d10, d11, [sp, #32] + ldp d12, d13, [sp, #48] + ldp d14, d15, [sp, #64] +.cfi_restore b15 +.cfi_restore b14 +.cfi_restore b13 +.cfi_restore b12 +.cfi_restore b11 +.cfi_restore b10 +.cfi_restore b9 +.cfi_restore b8 + ldp x29, x30, [sp], 80 +.cfi_restore w29 +.cfi_restore w30 +.cfi_def_cfa_offset 0 + AARCH64_VALIDATE_LINK_REGISTER + ret + +Lopen_128: + // On some architectures preparing 5 blocks for small buffers is wasteful + eor v25.16b, v25.16b, v25.16b + mov x11, #1 + mov v25.s[0], w11 + mov v0.16b, v24.16b + mov v1.16b, v24.16b + mov v2.16b, v24.16b + mov v5.16b, v28.16b + mov v6.16b, v28.16b + mov v7.16b, v28.16b + mov v10.16b, v29.16b + mov v11.16b, v29.16b + mov v12.16b, v29.16b + mov v17.16b, v30.16b + add v15.4s, v17.4s, v25.4s + add v16.4s, v15.4s, v25.4s + + mov x6, #10 + +Lopen_128_rounds: + add v0.4s, v0.4s, v5.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v5.16b, v5.16b, v10.16b + eor v6.16b, v6.16b, v11.16b + eor v7.16b, v7.16b, v12.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + ushr v5.4s, v6.4s, #20 + sli v5.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v5.4s + add v2.4s, v2.4s, v6.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v20.16b, v20.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v6.16b, v6.16b, v12.16b + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v5.4s, #25 + sli v6.4s, v5.4s, #7 + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + + ext v5.16b, v5.16b, v5.16b, #4 + ext v6.16b, v6.16b, v6.16b, #4 + ext v7.16b, v7.16b, v7.16b, #4 + + ext v10.16b, v10.16b, v10.16b, #8 + ext v11.16b, v11.16b, v11.16b, #8 + ext v12.16b, v12.16b, v12.16b, #8 + + ext v15.16b, v15.16b, v15.16b, #12 + ext v16.16b, v16.16b, v16.16b, #12 + ext v17.16b, v17.16b, v17.16b, #12 + add v0.4s, v0.4s, v5.4s + add v1.4s, v1.4s, v6.4s + add v2.4s, v2.4s, v7.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + rev32 v15.8h, v15.8h + rev32 v16.8h, v16.8h + rev32 v17.8h, v17.8h + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v5.16b, v5.16b, v10.16b + eor v6.16b, v6.16b, v11.16b + eor v7.16b, v7.16b, v12.16b + ushr v20.4s, v5.4s, #20 + sli v20.4s, v5.4s, #12 + ushr v5.4s, v6.4s, #20 + sli v5.4s, v6.4s, #12 + ushr v6.4s, v7.4s, #20 + sli v6.4s, v7.4s, #12 + + add v0.4s, v0.4s, v20.4s + add v1.4s, v1.4s, v5.4s + add v2.4s, v2.4s, v6.4s + eor v15.16b, v15.16b, v0.16b + eor v16.16b, v16.16b, v1.16b + eor v17.16b, v17.16b, v2.16b + tbl v15.16b, {v15.16b}, v26.16b + tbl v16.16b, {v16.16b}, v26.16b + tbl v17.16b, {v17.16b}, v26.16b + + add v10.4s, v10.4s, v15.4s + add v11.4s, v11.4s, v16.4s + add v12.4s, v12.4s, v17.4s + eor v20.16b, v20.16b, v10.16b + eor v5.16b, v5.16b, v11.16b + eor v6.16b, v6.16b, v12.16b + ushr v7.4s, v6.4s, #25 + sli v7.4s, v6.4s, #7 + ushr v6.4s, v5.4s, #25 + sli v6.4s, v5.4s, #7 + ushr v5.4s, v20.4s, #25 + sli v5.4s, v20.4s, #7 + + ext v5.16b, v5.16b, v5.16b, #12 + ext v6.16b, v6.16b, v6.16b, #12 + ext v7.16b, v7.16b, v7.16b, #12 + + ext v10.16b, v10.16b, v10.16b, #8 + ext v11.16b, v11.16b, v11.16b, #8 + ext v12.16b, v12.16b, v12.16b, #8 + + ext v15.16b, v15.16b, v15.16b, #4 + ext v16.16b, v16.16b, v16.16b, #4 + ext v17.16b, v17.16b, v17.16b, #4 + subs x6, x6, #1 + b.hi Lopen_128_rounds + + add v0.4s, v0.4s, v24.4s + add v1.4s, v1.4s, v24.4s + add v2.4s, v2.4s, v24.4s + + add v5.4s, v5.4s, v28.4s + add v6.4s, v6.4s, v28.4s + add v7.4s, v7.4s, v28.4s + + add v10.4s, v10.4s, v29.4s + add v11.4s, v11.4s, v29.4s + + add v30.4s, v30.4s, v25.4s + add v15.4s, v15.4s, v30.4s + add v30.4s, v30.4s, v25.4s + add v16.4s, v16.4s, v30.4s + + and v2.16b, v2.16b, v27.16b + mov x16, v2.d[0] // Move the R key to GPRs + mov x17, v2.d[1] + mov v27.16b, v7.16b // Store the S key + + bl Lpoly_hash_ad_internal + +Lopen_128_store: + cmp x2, #64 + b.lt Lopen_128_store_64 + + ld1 {v20.16b - v23.16b}, [x1], #64 + + mov x11, v20.d[0] + mov x12, v20.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + mov x11, v21.d[0] + mov x12, v21.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + mov x11, v22.d[0] + mov x12, v22.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + mov x11, v23.d[0] + mov x12, v23.d[1] + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + + eor v20.16b, v20.16b, v0.16b + eor v21.16b, v21.16b, v5.16b + eor v22.16b, v22.16b, v10.16b + eor v23.16b, v23.16b, v15.16b + + st1 {v20.16b - v23.16b}, [x0], #64 + + sub x2, x2, #64 + + mov v0.16b, v1.16b + mov v5.16b, v6.16b + mov v10.16b, v11.16b + mov v15.16b, v16.16b + +Lopen_128_store_64: + + lsr x4, x2, #4 + mov x3, x1 + +Lopen_128_hash_64: + cbz x4, Lopen_tail_64_store + ldp x11, x12, [x3], 16 + adds x8, x8, x11 + adcs x9, x9, x12 + adc x10, x10, x15 + mul x11, x8, x16 // [t2:t1:t0] = [acc2:acc1:acc0] * r0 + umulh x12, x8, x16 + mul x13, x9, x16 + umulh x14, x9, x16 + adds x12, x12, x13 + mul x13, x10, x16 + adc x13, x13, x14 + mul x14, x8, x17 // [t3:t2:t1:t0] = [acc2:acc1:acc0] * [r1:r0] + umulh x8, x8, x17 + adds x12, x12, x14 + mul x14, x9, x17 + umulh x9, x9, x17 + adcs x14, x14, x8 + mul x10, x10, x17 + adc x10, x10, x9 + adds x13, x13, x14 + adc x14, x10, xzr + and x10, x13, #3 // At this point acc2 is 2 bits at most (value of 3) + and x8, x13, #-4 + extr x13, x14, x13, #2 + adds x8, x8, x11 + lsr x11, x14, #2 + adc x9, x14, x11 // No carry out since t0 is 61 bits and t3 is 63 bits + adds x8, x8, x13 + adcs x9, x9, x12 + adc x10, x10, xzr // At this point acc2 has the value of 4 at most + sub x4, x4, #1 + b Lopen_128_hash_64 +.cfi_endproc + +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(_WIN32) diff --git a/http/vendor/ring/pregenerated/chacha20_poly1305_x86_64-elf.S b/http/vendor/ring/pregenerated/chacha20_poly1305_x86_64-elf.S new file mode 100644 index 0000000..499d70c --- /dev/null +++ b/http/vendor/ring/pregenerated/chacha20_poly1305_x86_64-elf.S @@ -0,0 +1,8940 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__) +.section .rodata +.align 64 +chacha20_poly1305_constants: +.Lchacha20_consts: +.byte 'e','x','p','a','n','d',' ','3','2','-','b','y','t','e',' ','k' +.byte 'e','x','p','a','n','d',' ','3','2','-','b','y','t','e',' ','k' +.Lrol8: +.byte 3,0,1,2, 7,4,5,6, 11,8,9,10, 15,12,13,14 +.byte 3,0,1,2, 7,4,5,6, 11,8,9,10, 15,12,13,14 +.Lrol16: +.byte 2,3,0,1, 6,7,4,5, 10,11,8,9, 14,15,12,13 +.byte 2,3,0,1, 6,7,4,5, 10,11,8,9, 14,15,12,13 +.Lavx2_init: +.long 0,0,0,0 +.Lsse_inc: +.long 1,0,0,0 +.Lavx2_inc: +.long 2,0,0,0,2,0,0,0 +.Lclamp: +.quad 0x0FFFFFFC0FFFFFFF, 0x0FFFFFFC0FFFFFFC +.quad 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF +.align 16 +.Land_masks: +.byte 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff +.text + +.type poly_hash_ad_internal,@function +.align 64 +poly_hash_ad_internal: +.cfi_startproc +.cfi_def_cfa rsp, 8 + xorq %r10,%r10 + xorq %r11,%r11 + xorq %r12,%r12 + cmpq $13,%r8 + jne .Lhash_ad_loop +.Lpoly_fast_tls_ad: + + movq (%rcx),%r10 + movq 5(%rcx),%r11 + shrq $24,%r11 + movq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + ret +.Lhash_ad_loop: + + cmpq $16,%r8 + jb .Lhash_ad_tail + addq 0+0(%rcx),%r10 + adcq 8+0(%rcx),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%rcx),%rcx + subq $16,%r8 + jmp .Lhash_ad_loop +.Lhash_ad_tail: + cmpq $0,%r8 + je .Lhash_ad_done + + xorq %r13,%r13 + xorq %r14,%r14 + xorq %r15,%r15 + addq %r8,%rcx +.Lhash_ad_tail_loop: + shldq $8,%r13,%r14 + shlq $8,%r13 + movzbq -1(%rcx),%r15 + xorq %r15,%r13 + decq %rcx + decq %r8 + jne .Lhash_ad_tail_loop + + addq %r13,%r10 + adcq %r14,%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + +.Lhash_ad_done: + ret +.cfi_endproc +.size poly_hash_ad_internal, .-poly_hash_ad_internal + +.globl chacha20_poly1305_open_sse41 +.hidden chacha20_poly1305_open_sse41 +.type chacha20_poly1305_open_sse41,@function +.align 64 +chacha20_poly1305_open_sse41: +.cfi_startproc +_CET_ENDBR + pushq %rbp +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbp,-16 + pushq %rbx +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbx,-24 + pushq %r12 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r12,-32 + pushq %r13 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r13,-40 + pushq %r14 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r14,-48 + pushq %r15 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r15,-56 + + + pushq %r9 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r9,-64 + subq $288 + 0 + 32,%rsp +.cfi_adjust_cfa_offset 288 + 32 + + leaq 32(%rsp),%rbp + andq $-32,%rbp + + movq %rdx,%rbx + movq %r8,0+0+32(%rbp) + movq %rbx,8+0+32(%rbp) + + cmpq $128,%rbx + jbe .Lopen_sse_128 + + movdqa .Lchacha20_consts(%rip),%xmm0 + movdqu 0(%r9),%xmm4 + movdqu 16(%r9),%xmm8 + movdqu 32(%r9),%xmm12 + + movdqa %xmm12,%xmm7 + + movdqa %xmm4,0+48(%rbp) + movdqa %xmm8,0+64(%rbp) + movdqa %xmm12,0+96(%rbp) + movq $10,%r10 +.Lopen_sse_init_rounds: + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,4 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,12 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,12 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,4 + + decq %r10 + jne .Lopen_sse_init_rounds + + paddd .Lchacha20_consts(%rip),%xmm0 + paddd 0+48(%rbp),%xmm4 + + pand .Lclamp(%rip),%xmm0 + movdqa %xmm0,0+0(%rbp) + movdqa %xmm4,0+16(%rbp) + + movq %r8,%r8 + call poly_hash_ad_internal +.Lopen_sse_main_loop: + cmpq $256,%rbx + jb .Lopen_sse_tail + + movdqa .Lchacha20_consts(%rip),%xmm0 + movdqa 0+48(%rbp),%xmm4 + movdqa 0+64(%rbp),%xmm8 + movdqa %xmm0,%xmm1 + movdqa %xmm4,%xmm5 + movdqa %xmm8,%xmm9 + movdqa %xmm0,%xmm2 + movdqa %xmm4,%xmm6 + movdqa %xmm8,%xmm10 + movdqa %xmm0,%xmm3 + movdqa %xmm4,%xmm7 + movdqa %xmm8,%xmm11 + movdqa 0+96(%rbp),%xmm15 + paddd .Lsse_inc(%rip),%xmm15 + movdqa %xmm15,%xmm14 + paddd .Lsse_inc(%rip),%xmm14 + movdqa %xmm14,%xmm13 + paddd .Lsse_inc(%rip),%xmm13 + movdqa %xmm13,%xmm12 + paddd .Lsse_inc(%rip),%xmm12 + movdqa %xmm12,0+96(%rbp) + movdqa %xmm13,0+112(%rbp) + movdqa %xmm14,0+128(%rbp) + movdqa %xmm15,0+144(%rbp) + + + + movq $4,%rcx + movq %rsi,%r8 +.Lopen_sse_main_loop_rounds: + movdqa %xmm8,0+80(%rbp) + movdqa .Lrol16(%rip),%xmm8 + paddd %xmm7,%xmm3 + paddd %xmm6,%xmm2 + paddd %xmm5,%xmm1 + paddd %xmm4,%xmm0 + pxor %xmm3,%xmm15 + pxor %xmm2,%xmm14 + pxor %xmm1,%xmm13 + pxor %xmm0,%xmm12 +.byte 102,69,15,56,0,248 +.byte 102,69,15,56,0,240 +.byte 102,69,15,56,0,232 +.byte 102,69,15,56,0,224 + movdqa 0+80(%rbp),%xmm8 + paddd %xmm15,%xmm11 + paddd %xmm14,%xmm10 + paddd %xmm13,%xmm9 + paddd %xmm12,%xmm8 + pxor %xmm11,%xmm7 + addq 0+0(%r8),%r10 + adcq 8+0(%r8),%r11 + adcq $1,%r12 + + leaq 16(%r8),%r8 + pxor %xmm10,%xmm6 + pxor %xmm9,%xmm5 + pxor %xmm8,%xmm4 + movdqa %xmm8,0+80(%rbp) + movdqa %xmm7,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm7 + pxor %xmm8,%xmm7 + movdqa %xmm6,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm6 + pxor %xmm8,%xmm6 + movdqa %xmm5,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm5 + pxor %xmm8,%xmm5 + movdqa %xmm4,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm4 + pxor %xmm8,%xmm4 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movdqa .Lrol8(%rip),%xmm8 + paddd %xmm7,%xmm3 + paddd %xmm6,%xmm2 + paddd %xmm5,%xmm1 + paddd %xmm4,%xmm0 + pxor %xmm3,%xmm15 + pxor %xmm2,%xmm14 + pxor %xmm1,%xmm13 + pxor %xmm0,%xmm12 +.byte 102,69,15,56,0,248 +.byte 102,69,15,56,0,240 +.byte 102,69,15,56,0,232 +.byte 102,69,15,56,0,224 + movdqa 0+80(%rbp),%xmm8 + paddd %xmm15,%xmm11 + paddd %xmm14,%xmm10 + paddd %xmm13,%xmm9 + paddd %xmm12,%xmm8 + pxor %xmm11,%xmm7 + pxor %xmm10,%xmm6 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + pxor %xmm9,%xmm5 + pxor %xmm8,%xmm4 + movdqa %xmm8,0+80(%rbp) + movdqa %xmm7,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm7 + pxor %xmm8,%xmm7 + movdqa %xmm6,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm6 + pxor %xmm8,%xmm6 + movdqa %xmm5,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm5 + pxor %xmm8,%xmm5 + movdqa %xmm4,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm4 + pxor %xmm8,%xmm4 + movdqa 0+80(%rbp),%xmm8 + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 +.byte 102,15,58,15,255,4 +.byte 102,69,15,58,15,219,8 +.byte 102,69,15,58,15,255,12 +.byte 102,15,58,15,246,4 +.byte 102,69,15,58,15,210,8 +.byte 102,69,15,58,15,246,12 +.byte 102,15,58,15,237,4 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,12 +.byte 102,15,58,15,228,4 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,12 + movdqa %xmm8,0+80(%rbp) + movdqa .Lrol16(%rip),%xmm8 + paddd %xmm7,%xmm3 + paddd %xmm6,%xmm2 + paddd %xmm5,%xmm1 + paddd %xmm4,%xmm0 + pxor %xmm3,%xmm15 + pxor %xmm2,%xmm14 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + pxor %xmm1,%xmm13 + pxor %xmm0,%xmm12 +.byte 102,69,15,56,0,248 +.byte 102,69,15,56,0,240 +.byte 102,69,15,56,0,232 +.byte 102,69,15,56,0,224 + movdqa 0+80(%rbp),%xmm8 + paddd %xmm15,%xmm11 + paddd %xmm14,%xmm10 + paddd %xmm13,%xmm9 + paddd %xmm12,%xmm8 + pxor %xmm11,%xmm7 + pxor %xmm10,%xmm6 + pxor %xmm9,%xmm5 + pxor %xmm8,%xmm4 + movdqa %xmm8,0+80(%rbp) + movdqa %xmm7,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm7 + pxor %xmm8,%xmm7 + movdqa %xmm6,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm6 + pxor %xmm8,%xmm6 + movdqa %xmm5,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm5 + pxor %xmm8,%xmm5 + movdqa %xmm4,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm4 + pxor %xmm8,%xmm4 + movdqa .Lrol8(%rip),%xmm8 + paddd %xmm7,%xmm3 + paddd %xmm6,%xmm2 + paddd %xmm5,%xmm1 + paddd %xmm4,%xmm0 + pxor %xmm3,%xmm15 + pxor %xmm2,%xmm14 + pxor %xmm1,%xmm13 + pxor %xmm0,%xmm12 +.byte 102,69,15,56,0,248 +.byte 102,69,15,56,0,240 +.byte 102,69,15,56,0,232 +.byte 102,69,15,56,0,224 + movdqa 0+80(%rbp),%xmm8 + paddd %xmm15,%xmm11 + paddd %xmm14,%xmm10 + paddd %xmm13,%xmm9 + paddd %xmm12,%xmm8 + pxor %xmm11,%xmm7 + pxor %xmm10,%xmm6 + pxor %xmm9,%xmm5 + pxor %xmm8,%xmm4 + movdqa %xmm8,0+80(%rbp) + movdqa %xmm7,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm7 + pxor %xmm8,%xmm7 + movdqa %xmm6,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm6 + pxor %xmm8,%xmm6 + movdqa %xmm5,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm5 + pxor %xmm8,%xmm5 + movdqa %xmm4,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm4 + pxor %xmm8,%xmm4 + movdqa 0+80(%rbp),%xmm8 +.byte 102,15,58,15,255,12 +.byte 102,69,15,58,15,219,8 +.byte 102,69,15,58,15,255,4 +.byte 102,15,58,15,246,12 +.byte 102,69,15,58,15,210,8 +.byte 102,69,15,58,15,246,4 +.byte 102,15,58,15,237,12 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,4 +.byte 102,15,58,15,228,12 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,4 + + decq %rcx + jge .Lopen_sse_main_loop_rounds + addq 0+0(%r8),%r10 + adcq 8+0(%r8),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%r8),%r8 + cmpq $-6,%rcx + jg .Lopen_sse_main_loop_rounds + paddd .Lchacha20_consts(%rip),%xmm3 + paddd 0+48(%rbp),%xmm7 + paddd 0+64(%rbp),%xmm11 + paddd 0+144(%rbp),%xmm15 + paddd .Lchacha20_consts(%rip),%xmm2 + paddd 0+48(%rbp),%xmm6 + paddd 0+64(%rbp),%xmm10 + paddd 0+128(%rbp),%xmm14 + paddd .Lchacha20_consts(%rip),%xmm1 + paddd 0+48(%rbp),%xmm5 + paddd 0+64(%rbp),%xmm9 + paddd 0+112(%rbp),%xmm13 + paddd .Lchacha20_consts(%rip),%xmm0 + paddd 0+48(%rbp),%xmm4 + paddd 0+64(%rbp),%xmm8 + paddd 0+96(%rbp),%xmm12 + movdqa %xmm12,0+80(%rbp) + movdqu 0 + 0(%rsi),%xmm12 + pxor %xmm3,%xmm12 + movdqu %xmm12,0 + 0(%rdi) + movdqu 16 + 0(%rsi),%xmm12 + pxor %xmm7,%xmm12 + movdqu %xmm12,16 + 0(%rdi) + movdqu 32 + 0(%rsi),%xmm12 + pxor %xmm11,%xmm12 + movdqu %xmm12,32 + 0(%rdi) + movdqu 48 + 0(%rsi),%xmm12 + pxor %xmm15,%xmm12 + movdqu %xmm12,48 + 0(%rdi) + movdqu 0 + 64(%rsi),%xmm3 + movdqu 16 + 64(%rsi),%xmm7 + movdqu 32 + 64(%rsi),%xmm11 + movdqu 48 + 64(%rsi),%xmm15 + pxor %xmm3,%xmm2 + pxor %xmm7,%xmm6 + pxor %xmm11,%xmm10 + pxor %xmm14,%xmm15 + movdqu %xmm2,0 + 64(%rdi) + movdqu %xmm6,16 + 64(%rdi) + movdqu %xmm10,32 + 64(%rdi) + movdqu %xmm15,48 + 64(%rdi) + movdqu 0 + 128(%rsi),%xmm3 + movdqu 16 + 128(%rsi),%xmm7 + movdqu 32 + 128(%rsi),%xmm11 + movdqu 48 + 128(%rsi),%xmm15 + pxor %xmm3,%xmm1 + pxor %xmm7,%xmm5 + pxor %xmm11,%xmm9 + pxor %xmm13,%xmm15 + movdqu %xmm1,0 + 128(%rdi) + movdqu %xmm5,16 + 128(%rdi) + movdqu %xmm9,32 + 128(%rdi) + movdqu %xmm15,48 + 128(%rdi) + movdqu 0 + 192(%rsi),%xmm3 + movdqu 16 + 192(%rsi),%xmm7 + movdqu 32 + 192(%rsi),%xmm11 + movdqu 48 + 192(%rsi),%xmm15 + pxor %xmm3,%xmm0 + pxor %xmm7,%xmm4 + pxor %xmm11,%xmm8 + pxor 0+80(%rbp),%xmm15 + movdqu %xmm0,0 + 192(%rdi) + movdqu %xmm4,16 + 192(%rdi) + movdqu %xmm8,32 + 192(%rdi) + movdqu %xmm15,48 + 192(%rdi) + + leaq 256(%rsi),%rsi + leaq 256(%rdi),%rdi + subq $256,%rbx + jmp .Lopen_sse_main_loop +.Lopen_sse_tail: + + testq %rbx,%rbx + jz .Lopen_sse_finalize + cmpq $192,%rbx + ja .Lopen_sse_tail_256 + cmpq $128,%rbx + ja .Lopen_sse_tail_192 + cmpq $64,%rbx + ja .Lopen_sse_tail_128 + movdqa .Lchacha20_consts(%rip),%xmm0 + movdqa 0+48(%rbp),%xmm4 + movdqa 0+64(%rbp),%xmm8 + movdqa 0+96(%rbp),%xmm12 + paddd .Lsse_inc(%rip),%xmm12 + movdqa %xmm12,0+96(%rbp) + + xorq %r8,%r8 + movq %rbx,%rcx + cmpq $16,%rcx + jb .Lopen_sse_tail_64_rounds +.Lopen_sse_tail_64_rounds_and_x1hash: + addq 0+0(%rsi,%r8,1),%r10 + adcq 8+0(%rsi,%r8,1),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + subq $16,%rcx +.Lopen_sse_tail_64_rounds: + addq $16,%r8 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,4 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,12 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,12 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,4 + + cmpq $16,%rcx + jae .Lopen_sse_tail_64_rounds_and_x1hash + cmpq $160,%r8 + jne .Lopen_sse_tail_64_rounds + paddd .Lchacha20_consts(%rip),%xmm0 + paddd 0+48(%rbp),%xmm4 + paddd 0+64(%rbp),%xmm8 + paddd 0+96(%rbp),%xmm12 + + jmp .Lopen_sse_tail_64_dec_loop + +.Lopen_sse_tail_128: + movdqa .Lchacha20_consts(%rip),%xmm0 + movdqa 0+48(%rbp),%xmm4 + movdqa 0+64(%rbp),%xmm8 + movdqa %xmm0,%xmm1 + movdqa %xmm4,%xmm5 + movdqa %xmm8,%xmm9 + movdqa 0+96(%rbp),%xmm13 + paddd .Lsse_inc(%rip),%xmm13 + movdqa %xmm13,%xmm12 + paddd .Lsse_inc(%rip),%xmm12 + movdqa %xmm12,0+96(%rbp) + movdqa %xmm13,0+112(%rbp) + + movq %rbx,%rcx + andq $-16,%rcx + xorq %r8,%r8 +.Lopen_sse_tail_128_rounds_and_x1hash: + addq 0+0(%rsi,%r8,1),%r10 + adcq 8+0(%rsi,%r8,1),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + +.Lopen_sse_tail_128_rounds: + addq $16,%r8 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,4 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,12 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb .Lrol16(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm5 + pxor %xmm3,%xmm5 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb .Lrol8(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm5 + pxor %xmm3,%xmm5 +.byte 102,15,58,15,237,4 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,12 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,12 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,4 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb .Lrol16(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm5 + pxor %xmm3,%xmm5 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb .Lrol8(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm5 + pxor %xmm3,%xmm5 +.byte 102,15,58,15,237,12 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,4 + + cmpq %rcx,%r8 + jb .Lopen_sse_tail_128_rounds_and_x1hash + cmpq $160,%r8 + jne .Lopen_sse_tail_128_rounds + paddd .Lchacha20_consts(%rip),%xmm1 + paddd 0+48(%rbp),%xmm5 + paddd 0+64(%rbp),%xmm9 + paddd 0+112(%rbp),%xmm13 + paddd .Lchacha20_consts(%rip),%xmm0 + paddd 0+48(%rbp),%xmm4 + paddd 0+64(%rbp),%xmm8 + paddd 0+96(%rbp),%xmm12 + movdqu 0 + 0(%rsi),%xmm3 + movdqu 16 + 0(%rsi),%xmm7 + movdqu 32 + 0(%rsi),%xmm11 + movdqu 48 + 0(%rsi),%xmm15 + pxor %xmm3,%xmm1 + pxor %xmm7,%xmm5 + pxor %xmm11,%xmm9 + pxor %xmm13,%xmm15 + movdqu %xmm1,0 + 0(%rdi) + movdqu %xmm5,16 + 0(%rdi) + movdqu %xmm9,32 + 0(%rdi) + movdqu %xmm15,48 + 0(%rdi) + + subq $64,%rbx + leaq 64(%rsi),%rsi + leaq 64(%rdi),%rdi + jmp .Lopen_sse_tail_64_dec_loop + +.Lopen_sse_tail_192: + movdqa .Lchacha20_consts(%rip),%xmm0 + movdqa 0+48(%rbp),%xmm4 + movdqa 0+64(%rbp),%xmm8 + movdqa %xmm0,%xmm1 + movdqa %xmm4,%xmm5 + movdqa %xmm8,%xmm9 + movdqa %xmm0,%xmm2 + movdqa %xmm4,%xmm6 + movdqa %xmm8,%xmm10 + movdqa 0+96(%rbp),%xmm14 + paddd .Lsse_inc(%rip),%xmm14 + movdqa %xmm14,%xmm13 + paddd .Lsse_inc(%rip),%xmm13 + movdqa %xmm13,%xmm12 + paddd .Lsse_inc(%rip),%xmm12 + movdqa %xmm12,0+96(%rbp) + movdqa %xmm13,0+112(%rbp) + movdqa %xmm14,0+128(%rbp) + + movq %rbx,%rcx + movq $160,%r8 + cmpq $160,%rcx + cmovgq %r8,%rcx + andq $-16,%rcx + xorq %r8,%r8 +.Lopen_sse_tail_192_rounds_and_x1hash: + addq 0+0(%rsi,%r8,1),%r10 + adcq 8+0(%rsi,%r8,1),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + +.Lopen_sse_tail_192_rounds: + addq $16,%r8 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,4 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,12 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb .Lrol16(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm5 + pxor %xmm3,%xmm5 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb .Lrol8(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm5 + pxor %xmm3,%xmm5 +.byte 102,15,58,15,237,4 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,12 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb .Lrol16(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm6 + pxor %xmm3,%xmm6 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb .Lrol8(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm6 + pxor %xmm3,%xmm6 +.byte 102,15,58,15,246,4 +.byte 102,69,15,58,15,210,8 +.byte 102,69,15,58,15,246,12 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,12 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,4 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb .Lrol16(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm5 + pxor %xmm3,%xmm5 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb .Lrol8(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm5 + pxor %xmm3,%xmm5 +.byte 102,15,58,15,237,12 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,4 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb .Lrol16(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm6 + pxor %xmm3,%xmm6 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb .Lrol8(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm6 + pxor %xmm3,%xmm6 +.byte 102,15,58,15,246,12 +.byte 102,69,15,58,15,210,8 +.byte 102,69,15,58,15,246,4 + + cmpq %rcx,%r8 + jb .Lopen_sse_tail_192_rounds_and_x1hash + cmpq $160,%r8 + jne .Lopen_sse_tail_192_rounds + cmpq $176,%rbx + jb .Lopen_sse_tail_192_finish + addq 0+160(%rsi),%r10 + adcq 8+160(%rsi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + cmpq $192,%rbx + jb .Lopen_sse_tail_192_finish + addq 0+176(%rsi),%r10 + adcq 8+176(%rsi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + +.Lopen_sse_tail_192_finish: + paddd .Lchacha20_consts(%rip),%xmm2 + paddd 0+48(%rbp),%xmm6 + paddd 0+64(%rbp),%xmm10 + paddd 0+128(%rbp),%xmm14 + paddd .Lchacha20_consts(%rip),%xmm1 + paddd 0+48(%rbp),%xmm5 + paddd 0+64(%rbp),%xmm9 + paddd 0+112(%rbp),%xmm13 + paddd .Lchacha20_consts(%rip),%xmm0 + paddd 0+48(%rbp),%xmm4 + paddd 0+64(%rbp),%xmm8 + paddd 0+96(%rbp),%xmm12 + movdqu 0 + 0(%rsi),%xmm3 + movdqu 16 + 0(%rsi),%xmm7 + movdqu 32 + 0(%rsi),%xmm11 + movdqu 48 + 0(%rsi),%xmm15 + pxor %xmm3,%xmm2 + pxor %xmm7,%xmm6 + pxor %xmm11,%xmm10 + pxor %xmm14,%xmm15 + movdqu %xmm2,0 + 0(%rdi) + movdqu %xmm6,16 + 0(%rdi) + movdqu %xmm10,32 + 0(%rdi) + movdqu %xmm15,48 + 0(%rdi) + movdqu 0 + 64(%rsi),%xmm3 + movdqu 16 + 64(%rsi),%xmm7 + movdqu 32 + 64(%rsi),%xmm11 + movdqu 48 + 64(%rsi),%xmm15 + pxor %xmm3,%xmm1 + pxor %xmm7,%xmm5 + pxor %xmm11,%xmm9 + pxor %xmm13,%xmm15 + movdqu %xmm1,0 + 64(%rdi) + movdqu %xmm5,16 + 64(%rdi) + movdqu %xmm9,32 + 64(%rdi) + movdqu %xmm15,48 + 64(%rdi) + + subq $128,%rbx + leaq 128(%rsi),%rsi + leaq 128(%rdi),%rdi + jmp .Lopen_sse_tail_64_dec_loop + +.Lopen_sse_tail_256: + movdqa .Lchacha20_consts(%rip),%xmm0 + movdqa 0+48(%rbp),%xmm4 + movdqa 0+64(%rbp),%xmm8 + movdqa %xmm0,%xmm1 + movdqa %xmm4,%xmm5 + movdqa %xmm8,%xmm9 + movdqa %xmm0,%xmm2 + movdqa %xmm4,%xmm6 + movdqa %xmm8,%xmm10 + movdqa %xmm0,%xmm3 + movdqa %xmm4,%xmm7 + movdqa %xmm8,%xmm11 + movdqa 0+96(%rbp),%xmm15 + paddd .Lsse_inc(%rip),%xmm15 + movdqa %xmm15,%xmm14 + paddd .Lsse_inc(%rip),%xmm14 + movdqa %xmm14,%xmm13 + paddd .Lsse_inc(%rip),%xmm13 + movdqa %xmm13,%xmm12 + paddd .Lsse_inc(%rip),%xmm12 + movdqa %xmm12,0+96(%rbp) + movdqa %xmm13,0+112(%rbp) + movdqa %xmm14,0+128(%rbp) + movdqa %xmm15,0+144(%rbp) + + xorq %r8,%r8 +.Lopen_sse_tail_256_rounds_and_x1hash: + addq 0+0(%rsi,%r8,1),%r10 + adcq 8+0(%rsi,%r8,1),%r11 + adcq $1,%r12 + movdqa %xmm11,0+80(%rbp) + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm11 + pslld $12,%xmm11 + psrld $20,%xmm4 + pxor %xmm11,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm11 + pslld $7,%xmm11 + psrld $25,%xmm4 + pxor %xmm11,%xmm4 +.byte 102,15,58,15,228,4 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,12 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb .Lrol16(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm11 + pslld $12,%xmm11 + psrld $20,%xmm5 + pxor %xmm11,%xmm5 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb .Lrol8(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm11 + pslld $7,%xmm11 + psrld $25,%xmm5 + pxor %xmm11,%xmm5 +.byte 102,15,58,15,237,4 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,12 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb .Lrol16(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm11 + pslld $12,%xmm11 + psrld $20,%xmm6 + pxor %xmm11,%xmm6 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb .Lrol8(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm11 + pslld $7,%xmm11 + psrld $25,%xmm6 + pxor %xmm11,%xmm6 +.byte 102,15,58,15,246,4 +.byte 102,69,15,58,15,210,8 +.byte 102,69,15,58,15,246,12 + movdqa 0+80(%rbp),%xmm11 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movdqa %xmm9,0+80(%rbp) + paddd %xmm7,%xmm3 + pxor %xmm3,%xmm15 + pshufb .Lrol16(%rip),%xmm15 + paddd %xmm15,%xmm11 + pxor %xmm11,%xmm7 + movdqa %xmm7,%xmm9 + pslld $12,%xmm9 + psrld $20,%xmm7 + pxor %xmm9,%xmm7 + paddd %xmm7,%xmm3 + pxor %xmm3,%xmm15 + pshufb .Lrol8(%rip),%xmm15 + paddd %xmm15,%xmm11 + pxor %xmm11,%xmm7 + movdqa %xmm7,%xmm9 + pslld $7,%xmm9 + psrld $25,%xmm7 + pxor %xmm9,%xmm7 +.byte 102,15,58,15,255,4 +.byte 102,69,15,58,15,219,8 +.byte 102,69,15,58,15,255,12 + movdqa 0+80(%rbp),%xmm9 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + movdqa %xmm11,0+80(%rbp) + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm11 + pslld $12,%xmm11 + psrld $20,%xmm4 + pxor %xmm11,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm11 + pslld $7,%xmm11 + psrld $25,%xmm4 + pxor %xmm11,%xmm4 +.byte 102,15,58,15,228,12 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,4 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb .Lrol16(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm11 + pslld $12,%xmm11 + psrld $20,%xmm5 + pxor %xmm11,%xmm5 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb .Lrol8(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm11 + pslld $7,%xmm11 + psrld $25,%xmm5 + pxor %xmm11,%xmm5 +.byte 102,15,58,15,237,12 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,4 + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb .Lrol16(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm11 + pslld $12,%xmm11 + psrld $20,%xmm6 + pxor %xmm11,%xmm6 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb .Lrol8(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm11 + pslld $7,%xmm11 + psrld $25,%xmm6 + pxor %xmm11,%xmm6 +.byte 102,15,58,15,246,12 +.byte 102,69,15,58,15,210,8 +.byte 102,69,15,58,15,246,4 + movdqa 0+80(%rbp),%xmm11 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + movdqa %xmm9,0+80(%rbp) + paddd %xmm7,%xmm3 + pxor %xmm3,%xmm15 + pshufb .Lrol16(%rip),%xmm15 + paddd %xmm15,%xmm11 + pxor %xmm11,%xmm7 + movdqa %xmm7,%xmm9 + pslld $12,%xmm9 + psrld $20,%xmm7 + pxor %xmm9,%xmm7 + paddd %xmm7,%xmm3 + pxor %xmm3,%xmm15 + pshufb .Lrol8(%rip),%xmm15 + paddd %xmm15,%xmm11 + pxor %xmm11,%xmm7 + movdqa %xmm7,%xmm9 + pslld $7,%xmm9 + psrld $25,%xmm7 + pxor %xmm9,%xmm7 +.byte 102,15,58,15,255,12 +.byte 102,69,15,58,15,219,8 +.byte 102,69,15,58,15,255,4 + movdqa 0+80(%rbp),%xmm9 + + addq $16,%r8 + cmpq $160,%r8 + jb .Lopen_sse_tail_256_rounds_and_x1hash + + movq %rbx,%rcx + andq $-16,%rcx +.Lopen_sse_tail_256_hash: + addq 0+0(%rsi,%r8,1),%r10 + adcq 8+0(%rsi,%r8,1),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + addq $16,%r8 + cmpq %rcx,%r8 + jb .Lopen_sse_tail_256_hash + paddd .Lchacha20_consts(%rip),%xmm3 + paddd 0+48(%rbp),%xmm7 + paddd 0+64(%rbp),%xmm11 + paddd 0+144(%rbp),%xmm15 + paddd .Lchacha20_consts(%rip),%xmm2 + paddd 0+48(%rbp),%xmm6 + paddd 0+64(%rbp),%xmm10 + paddd 0+128(%rbp),%xmm14 + paddd .Lchacha20_consts(%rip),%xmm1 + paddd 0+48(%rbp),%xmm5 + paddd 0+64(%rbp),%xmm9 + paddd 0+112(%rbp),%xmm13 + paddd .Lchacha20_consts(%rip),%xmm0 + paddd 0+48(%rbp),%xmm4 + paddd 0+64(%rbp),%xmm8 + paddd 0+96(%rbp),%xmm12 + movdqa %xmm12,0+80(%rbp) + movdqu 0 + 0(%rsi),%xmm12 + pxor %xmm3,%xmm12 + movdqu %xmm12,0 + 0(%rdi) + movdqu 16 + 0(%rsi),%xmm12 + pxor %xmm7,%xmm12 + movdqu %xmm12,16 + 0(%rdi) + movdqu 32 + 0(%rsi),%xmm12 + pxor %xmm11,%xmm12 + movdqu %xmm12,32 + 0(%rdi) + movdqu 48 + 0(%rsi),%xmm12 + pxor %xmm15,%xmm12 + movdqu %xmm12,48 + 0(%rdi) + movdqu 0 + 64(%rsi),%xmm3 + movdqu 16 + 64(%rsi),%xmm7 + movdqu 32 + 64(%rsi),%xmm11 + movdqu 48 + 64(%rsi),%xmm15 + pxor %xmm3,%xmm2 + pxor %xmm7,%xmm6 + pxor %xmm11,%xmm10 + pxor %xmm14,%xmm15 + movdqu %xmm2,0 + 64(%rdi) + movdqu %xmm6,16 + 64(%rdi) + movdqu %xmm10,32 + 64(%rdi) + movdqu %xmm15,48 + 64(%rdi) + movdqu 0 + 128(%rsi),%xmm3 + movdqu 16 + 128(%rsi),%xmm7 + movdqu 32 + 128(%rsi),%xmm11 + movdqu 48 + 128(%rsi),%xmm15 + pxor %xmm3,%xmm1 + pxor %xmm7,%xmm5 + pxor %xmm11,%xmm9 + pxor %xmm13,%xmm15 + movdqu %xmm1,0 + 128(%rdi) + movdqu %xmm5,16 + 128(%rdi) + movdqu %xmm9,32 + 128(%rdi) + movdqu %xmm15,48 + 128(%rdi) + + movdqa 0+80(%rbp),%xmm12 + subq $192,%rbx + leaq 192(%rsi),%rsi + leaq 192(%rdi),%rdi + + +.Lopen_sse_tail_64_dec_loop: + cmpq $16,%rbx + jb .Lopen_sse_tail_16_init + subq $16,%rbx + movdqu (%rsi),%xmm3 + pxor %xmm3,%xmm0 + movdqu %xmm0,(%rdi) + leaq 16(%rsi),%rsi + leaq 16(%rdi),%rdi + movdqa %xmm4,%xmm0 + movdqa %xmm8,%xmm4 + movdqa %xmm12,%xmm8 + jmp .Lopen_sse_tail_64_dec_loop +.Lopen_sse_tail_16_init: + movdqa %xmm0,%xmm1 + + +.Lopen_sse_tail_16: + testq %rbx,%rbx + jz .Lopen_sse_finalize + + + + pxor %xmm3,%xmm3 + leaq -1(%rsi,%rbx,1),%rsi + movq %rbx,%r8 +.Lopen_sse_tail_16_compose: + pslldq $1,%xmm3 + pinsrb $0,(%rsi),%xmm3 + subq $1,%rsi + subq $1,%r8 + jnz .Lopen_sse_tail_16_compose + +.byte 102,73,15,126,221 + pextrq $1,%xmm3,%r14 + + pxor %xmm1,%xmm3 + + +.Lopen_sse_tail_16_extract: + pextrb $0,%xmm3,(%rdi) + psrldq $1,%xmm3 + addq $1,%rdi + subq $1,%rbx + jne .Lopen_sse_tail_16_extract + + addq %r13,%r10 + adcq %r14,%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + +.Lopen_sse_finalize: + addq 0+0+32(%rbp),%r10 + adcq 8+0+32(%rbp),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + + movq %r10,%r13 + movq %r11,%r14 + movq %r12,%r15 + subq $-5,%r10 + sbbq $-1,%r11 + sbbq $3,%r12 + cmovcq %r13,%r10 + cmovcq %r14,%r11 + cmovcq %r15,%r12 + + addq 0+0+16(%rbp),%r10 + adcq 8+0+16(%rbp),%r11 + +.cfi_remember_state + addq $288 + 0 + 32,%rsp +.cfi_adjust_cfa_offset -(288 + 32) + + popq %r9 +.cfi_adjust_cfa_offset -8 +.cfi_restore %r9 + movq %r10,(%r9) + movq %r11,8(%r9) + popq %r15 +.cfi_adjust_cfa_offset -8 +.cfi_restore %r15 + popq %r14 +.cfi_adjust_cfa_offset -8 +.cfi_restore %r14 + popq %r13 +.cfi_adjust_cfa_offset -8 +.cfi_restore %r13 + popq %r12 +.cfi_adjust_cfa_offset -8 +.cfi_restore %r12 + popq %rbx +.cfi_adjust_cfa_offset -8 +.cfi_restore %rbx + popq %rbp +.cfi_adjust_cfa_offset -8 +.cfi_restore %rbp + ret + +.Lopen_sse_128: +.cfi_restore_state + movdqu .Lchacha20_consts(%rip),%xmm0 + movdqa %xmm0,%xmm1 + movdqa %xmm0,%xmm2 + movdqu 0(%r9),%xmm4 + movdqa %xmm4,%xmm5 + movdqa %xmm4,%xmm6 + movdqu 16(%r9),%xmm8 + movdqa %xmm8,%xmm9 + movdqa %xmm8,%xmm10 + movdqu 32(%r9),%xmm12 + movdqa %xmm12,%xmm13 + paddd .Lsse_inc(%rip),%xmm13 + movdqa %xmm13,%xmm14 + paddd .Lsse_inc(%rip),%xmm14 + movdqa %xmm4,%xmm7 + movdqa %xmm8,%xmm11 + movdqa %xmm13,%xmm15 + movq $10,%r10 + +.Lopen_sse_128_rounds: + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,4 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,12 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb .Lrol16(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm5 + pxor %xmm3,%xmm5 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb .Lrol8(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm5 + pxor %xmm3,%xmm5 +.byte 102,15,58,15,237,4 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,12 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb .Lrol16(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm6 + pxor %xmm3,%xmm6 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb .Lrol8(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm6 + pxor %xmm3,%xmm6 +.byte 102,15,58,15,246,4 +.byte 102,69,15,58,15,210,8 +.byte 102,69,15,58,15,246,12 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,12 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,4 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb .Lrol16(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm5 + pxor %xmm3,%xmm5 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb .Lrol8(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm5 + pxor %xmm3,%xmm5 +.byte 102,15,58,15,237,12 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,4 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb .Lrol16(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm6 + pxor %xmm3,%xmm6 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb .Lrol8(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm6 + pxor %xmm3,%xmm6 +.byte 102,15,58,15,246,12 +.byte 102,69,15,58,15,210,8 +.byte 102,69,15,58,15,246,4 + + decq %r10 + jnz .Lopen_sse_128_rounds + paddd .Lchacha20_consts(%rip),%xmm0 + paddd .Lchacha20_consts(%rip),%xmm1 + paddd .Lchacha20_consts(%rip),%xmm2 + paddd %xmm7,%xmm4 + paddd %xmm7,%xmm5 + paddd %xmm7,%xmm6 + paddd %xmm11,%xmm9 + paddd %xmm11,%xmm10 + paddd %xmm15,%xmm13 + paddd .Lsse_inc(%rip),%xmm15 + paddd %xmm15,%xmm14 + + pand .Lclamp(%rip),%xmm0 + movdqa %xmm0,0+0(%rbp) + movdqa %xmm4,0+16(%rbp) + + movq %r8,%r8 + call poly_hash_ad_internal +.Lopen_sse_128_xor_hash: + cmpq $16,%rbx + jb .Lopen_sse_tail_16 + subq $16,%rbx + addq 0+0(%rsi),%r10 + adcq 8+0(%rsi),%r11 + adcq $1,%r12 + + + movdqu 0(%rsi),%xmm3 + pxor %xmm3,%xmm1 + movdqu %xmm1,0(%rdi) + leaq 16(%rsi),%rsi + leaq 16(%rdi),%rdi + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + + movdqa %xmm5,%xmm1 + movdqa %xmm9,%xmm5 + movdqa %xmm13,%xmm9 + movdqa %xmm2,%xmm13 + movdqa %xmm6,%xmm2 + movdqa %xmm10,%xmm6 + movdqa %xmm14,%xmm10 + jmp .Lopen_sse_128_xor_hash +.size chacha20_poly1305_open_sse41, .-chacha20_poly1305_open_sse41 +.cfi_endproc + + + + + + + +.globl chacha20_poly1305_seal_sse41 +.hidden chacha20_poly1305_seal_sse41 +.type chacha20_poly1305_seal_sse41,@function +.align 64 +chacha20_poly1305_seal_sse41: +.cfi_startproc +_CET_ENDBR + pushq %rbp +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbp,-16 + pushq %rbx +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbx,-24 + pushq %r12 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r12,-32 + pushq %r13 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r13,-40 + pushq %r14 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r14,-48 + pushq %r15 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r15,-56 + + + pushq %r9 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r9,-64 + subq $288 + 0 + 32,%rsp +.cfi_adjust_cfa_offset 288 + 32 + leaq 32(%rsp),%rbp + andq $-32,%rbp + + movq 56(%r9),%rbx + addq %rdx,%rbx + movq %r8,0+0+32(%rbp) + movq %rbx,8+0+32(%rbp) + movq %rdx,%rbx + + cmpq $128,%rbx + jbe .Lseal_sse_128 + + movdqa .Lchacha20_consts(%rip),%xmm0 + movdqu 0(%r9),%xmm4 + movdqu 16(%r9),%xmm8 + movdqu 32(%r9),%xmm12 + + movdqa %xmm0,%xmm1 + movdqa %xmm0,%xmm2 + movdqa %xmm0,%xmm3 + movdqa %xmm4,%xmm5 + movdqa %xmm4,%xmm6 + movdqa %xmm4,%xmm7 + movdqa %xmm8,%xmm9 + movdqa %xmm8,%xmm10 + movdqa %xmm8,%xmm11 + movdqa %xmm12,%xmm15 + paddd .Lsse_inc(%rip),%xmm12 + movdqa %xmm12,%xmm14 + paddd .Lsse_inc(%rip),%xmm12 + movdqa %xmm12,%xmm13 + paddd .Lsse_inc(%rip),%xmm12 + + movdqa %xmm4,0+48(%rbp) + movdqa %xmm8,0+64(%rbp) + movdqa %xmm12,0+96(%rbp) + movdqa %xmm13,0+112(%rbp) + movdqa %xmm14,0+128(%rbp) + movdqa %xmm15,0+144(%rbp) + movq $10,%r10 +.Lseal_sse_init_rounds: + movdqa %xmm8,0+80(%rbp) + movdqa .Lrol16(%rip),%xmm8 + paddd %xmm7,%xmm3 + paddd %xmm6,%xmm2 + paddd %xmm5,%xmm1 + paddd %xmm4,%xmm0 + pxor %xmm3,%xmm15 + pxor %xmm2,%xmm14 + pxor %xmm1,%xmm13 + pxor %xmm0,%xmm12 +.byte 102,69,15,56,0,248 +.byte 102,69,15,56,0,240 +.byte 102,69,15,56,0,232 +.byte 102,69,15,56,0,224 + movdqa 0+80(%rbp),%xmm8 + paddd %xmm15,%xmm11 + paddd %xmm14,%xmm10 + paddd %xmm13,%xmm9 + paddd %xmm12,%xmm8 + pxor %xmm11,%xmm7 + pxor %xmm10,%xmm6 + pxor %xmm9,%xmm5 + pxor %xmm8,%xmm4 + movdqa %xmm8,0+80(%rbp) + movdqa %xmm7,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm7 + pxor %xmm8,%xmm7 + movdqa %xmm6,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm6 + pxor %xmm8,%xmm6 + movdqa %xmm5,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm5 + pxor %xmm8,%xmm5 + movdqa %xmm4,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm4 + pxor %xmm8,%xmm4 + movdqa .Lrol8(%rip),%xmm8 + paddd %xmm7,%xmm3 + paddd %xmm6,%xmm2 + paddd %xmm5,%xmm1 + paddd %xmm4,%xmm0 + pxor %xmm3,%xmm15 + pxor %xmm2,%xmm14 + pxor %xmm1,%xmm13 + pxor %xmm0,%xmm12 +.byte 102,69,15,56,0,248 +.byte 102,69,15,56,0,240 +.byte 102,69,15,56,0,232 +.byte 102,69,15,56,0,224 + movdqa 0+80(%rbp),%xmm8 + paddd %xmm15,%xmm11 + paddd %xmm14,%xmm10 + paddd %xmm13,%xmm9 + paddd %xmm12,%xmm8 + pxor %xmm11,%xmm7 + pxor %xmm10,%xmm6 + pxor %xmm9,%xmm5 + pxor %xmm8,%xmm4 + movdqa %xmm8,0+80(%rbp) + movdqa %xmm7,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm7 + pxor %xmm8,%xmm7 + movdqa %xmm6,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm6 + pxor %xmm8,%xmm6 + movdqa %xmm5,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm5 + pxor %xmm8,%xmm5 + movdqa %xmm4,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm4 + pxor %xmm8,%xmm4 + movdqa 0+80(%rbp),%xmm8 +.byte 102,15,58,15,255,4 +.byte 102,69,15,58,15,219,8 +.byte 102,69,15,58,15,255,12 +.byte 102,15,58,15,246,4 +.byte 102,69,15,58,15,210,8 +.byte 102,69,15,58,15,246,12 +.byte 102,15,58,15,237,4 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,12 +.byte 102,15,58,15,228,4 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,12 + movdqa %xmm8,0+80(%rbp) + movdqa .Lrol16(%rip),%xmm8 + paddd %xmm7,%xmm3 + paddd %xmm6,%xmm2 + paddd %xmm5,%xmm1 + paddd %xmm4,%xmm0 + pxor %xmm3,%xmm15 + pxor %xmm2,%xmm14 + pxor %xmm1,%xmm13 + pxor %xmm0,%xmm12 +.byte 102,69,15,56,0,248 +.byte 102,69,15,56,0,240 +.byte 102,69,15,56,0,232 +.byte 102,69,15,56,0,224 + movdqa 0+80(%rbp),%xmm8 + paddd %xmm15,%xmm11 + paddd %xmm14,%xmm10 + paddd %xmm13,%xmm9 + paddd %xmm12,%xmm8 + pxor %xmm11,%xmm7 + pxor %xmm10,%xmm6 + pxor %xmm9,%xmm5 + pxor %xmm8,%xmm4 + movdqa %xmm8,0+80(%rbp) + movdqa %xmm7,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm7 + pxor %xmm8,%xmm7 + movdqa %xmm6,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm6 + pxor %xmm8,%xmm6 + movdqa %xmm5,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm5 + pxor %xmm8,%xmm5 + movdqa %xmm4,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm4 + pxor %xmm8,%xmm4 + movdqa .Lrol8(%rip),%xmm8 + paddd %xmm7,%xmm3 + paddd %xmm6,%xmm2 + paddd %xmm5,%xmm1 + paddd %xmm4,%xmm0 + pxor %xmm3,%xmm15 + pxor %xmm2,%xmm14 + pxor %xmm1,%xmm13 + pxor %xmm0,%xmm12 +.byte 102,69,15,56,0,248 +.byte 102,69,15,56,0,240 +.byte 102,69,15,56,0,232 +.byte 102,69,15,56,0,224 + movdqa 0+80(%rbp),%xmm8 + paddd %xmm15,%xmm11 + paddd %xmm14,%xmm10 + paddd %xmm13,%xmm9 + paddd %xmm12,%xmm8 + pxor %xmm11,%xmm7 + pxor %xmm10,%xmm6 + pxor %xmm9,%xmm5 + pxor %xmm8,%xmm4 + movdqa %xmm8,0+80(%rbp) + movdqa %xmm7,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm7 + pxor %xmm8,%xmm7 + movdqa %xmm6,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm6 + pxor %xmm8,%xmm6 + movdqa %xmm5,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm5 + pxor %xmm8,%xmm5 + movdqa %xmm4,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm4 + pxor %xmm8,%xmm4 + movdqa 0+80(%rbp),%xmm8 +.byte 102,15,58,15,255,12 +.byte 102,69,15,58,15,219,8 +.byte 102,69,15,58,15,255,4 +.byte 102,15,58,15,246,12 +.byte 102,69,15,58,15,210,8 +.byte 102,69,15,58,15,246,4 +.byte 102,15,58,15,237,12 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,4 +.byte 102,15,58,15,228,12 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,4 + + decq %r10 + jnz .Lseal_sse_init_rounds + paddd .Lchacha20_consts(%rip),%xmm3 + paddd 0+48(%rbp),%xmm7 + paddd 0+64(%rbp),%xmm11 + paddd 0+144(%rbp),%xmm15 + paddd .Lchacha20_consts(%rip),%xmm2 + paddd 0+48(%rbp),%xmm6 + paddd 0+64(%rbp),%xmm10 + paddd 0+128(%rbp),%xmm14 + paddd .Lchacha20_consts(%rip),%xmm1 + paddd 0+48(%rbp),%xmm5 + paddd 0+64(%rbp),%xmm9 + paddd 0+112(%rbp),%xmm13 + paddd .Lchacha20_consts(%rip),%xmm0 + paddd 0+48(%rbp),%xmm4 + paddd 0+64(%rbp),%xmm8 + paddd 0+96(%rbp),%xmm12 + + + pand .Lclamp(%rip),%xmm3 + movdqa %xmm3,0+0(%rbp) + movdqa %xmm7,0+16(%rbp) + + movq %r8,%r8 + call poly_hash_ad_internal + movdqu 0 + 0(%rsi),%xmm3 + movdqu 16 + 0(%rsi),%xmm7 + movdqu 32 + 0(%rsi),%xmm11 + movdqu 48 + 0(%rsi),%xmm15 + pxor %xmm3,%xmm2 + pxor %xmm7,%xmm6 + pxor %xmm11,%xmm10 + pxor %xmm14,%xmm15 + movdqu %xmm2,0 + 0(%rdi) + movdqu %xmm6,16 + 0(%rdi) + movdqu %xmm10,32 + 0(%rdi) + movdqu %xmm15,48 + 0(%rdi) + movdqu 0 + 64(%rsi),%xmm3 + movdqu 16 + 64(%rsi),%xmm7 + movdqu 32 + 64(%rsi),%xmm11 + movdqu 48 + 64(%rsi),%xmm15 + pxor %xmm3,%xmm1 + pxor %xmm7,%xmm5 + pxor %xmm11,%xmm9 + pxor %xmm13,%xmm15 + movdqu %xmm1,0 + 64(%rdi) + movdqu %xmm5,16 + 64(%rdi) + movdqu %xmm9,32 + 64(%rdi) + movdqu %xmm15,48 + 64(%rdi) + + cmpq $192,%rbx + ja .Lseal_sse_main_init + movq $128,%rcx + subq $128,%rbx + leaq 128(%rsi),%rsi + jmp .Lseal_sse_128_tail_hash +.Lseal_sse_main_init: + movdqu 0 + 128(%rsi),%xmm3 + movdqu 16 + 128(%rsi),%xmm7 + movdqu 32 + 128(%rsi),%xmm11 + movdqu 48 + 128(%rsi),%xmm15 + pxor %xmm3,%xmm0 + pxor %xmm7,%xmm4 + pxor %xmm11,%xmm8 + pxor %xmm12,%xmm15 + movdqu %xmm0,0 + 128(%rdi) + movdqu %xmm4,16 + 128(%rdi) + movdqu %xmm8,32 + 128(%rdi) + movdqu %xmm15,48 + 128(%rdi) + + movq $192,%rcx + subq $192,%rbx + leaq 192(%rsi),%rsi + movq $2,%rcx + movq $8,%r8 + cmpq $64,%rbx + jbe .Lseal_sse_tail_64 + cmpq $128,%rbx + jbe .Lseal_sse_tail_128 + cmpq $192,%rbx + jbe .Lseal_sse_tail_192 + +.Lseal_sse_main_loop: + movdqa .Lchacha20_consts(%rip),%xmm0 + movdqa 0+48(%rbp),%xmm4 + movdqa 0+64(%rbp),%xmm8 + movdqa %xmm0,%xmm1 + movdqa %xmm4,%xmm5 + movdqa %xmm8,%xmm9 + movdqa %xmm0,%xmm2 + movdqa %xmm4,%xmm6 + movdqa %xmm8,%xmm10 + movdqa %xmm0,%xmm3 + movdqa %xmm4,%xmm7 + movdqa %xmm8,%xmm11 + movdqa 0+96(%rbp),%xmm15 + paddd .Lsse_inc(%rip),%xmm15 + movdqa %xmm15,%xmm14 + paddd .Lsse_inc(%rip),%xmm14 + movdqa %xmm14,%xmm13 + paddd .Lsse_inc(%rip),%xmm13 + movdqa %xmm13,%xmm12 + paddd .Lsse_inc(%rip),%xmm12 + movdqa %xmm12,0+96(%rbp) + movdqa %xmm13,0+112(%rbp) + movdqa %xmm14,0+128(%rbp) + movdqa %xmm15,0+144(%rbp) + +.align 32 +.Lseal_sse_main_rounds: + movdqa %xmm8,0+80(%rbp) + movdqa .Lrol16(%rip),%xmm8 + paddd %xmm7,%xmm3 + paddd %xmm6,%xmm2 + paddd %xmm5,%xmm1 + paddd %xmm4,%xmm0 + pxor %xmm3,%xmm15 + pxor %xmm2,%xmm14 + pxor %xmm1,%xmm13 + pxor %xmm0,%xmm12 +.byte 102,69,15,56,0,248 +.byte 102,69,15,56,0,240 +.byte 102,69,15,56,0,232 +.byte 102,69,15,56,0,224 + movdqa 0+80(%rbp),%xmm8 + paddd %xmm15,%xmm11 + paddd %xmm14,%xmm10 + paddd %xmm13,%xmm9 + paddd %xmm12,%xmm8 + pxor %xmm11,%xmm7 + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + pxor %xmm10,%xmm6 + pxor %xmm9,%xmm5 + pxor %xmm8,%xmm4 + movdqa %xmm8,0+80(%rbp) + movdqa %xmm7,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm7 + pxor %xmm8,%xmm7 + movdqa %xmm6,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm6 + pxor %xmm8,%xmm6 + movdqa %xmm5,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm5 + pxor %xmm8,%xmm5 + movdqa %xmm4,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm4 + pxor %xmm8,%xmm4 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movdqa .Lrol8(%rip),%xmm8 + paddd %xmm7,%xmm3 + paddd %xmm6,%xmm2 + paddd %xmm5,%xmm1 + paddd %xmm4,%xmm0 + pxor %xmm3,%xmm15 + pxor %xmm2,%xmm14 + pxor %xmm1,%xmm13 + pxor %xmm0,%xmm12 +.byte 102,69,15,56,0,248 +.byte 102,69,15,56,0,240 +.byte 102,69,15,56,0,232 +.byte 102,69,15,56,0,224 + movdqa 0+80(%rbp),%xmm8 + paddd %xmm15,%xmm11 + paddd %xmm14,%xmm10 + paddd %xmm13,%xmm9 + paddd %xmm12,%xmm8 + pxor %xmm11,%xmm7 + pxor %xmm10,%xmm6 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + pxor %xmm9,%xmm5 + pxor %xmm8,%xmm4 + movdqa %xmm8,0+80(%rbp) + movdqa %xmm7,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm7 + pxor %xmm8,%xmm7 + movdqa %xmm6,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm6 + pxor %xmm8,%xmm6 + movdqa %xmm5,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm5 + pxor %xmm8,%xmm5 + movdqa %xmm4,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm4 + pxor %xmm8,%xmm4 + movdqa 0+80(%rbp),%xmm8 + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 +.byte 102,15,58,15,255,4 +.byte 102,69,15,58,15,219,8 +.byte 102,69,15,58,15,255,12 +.byte 102,15,58,15,246,4 +.byte 102,69,15,58,15,210,8 +.byte 102,69,15,58,15,246,12 +.byte 102,15,58,15,237,4 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,12 +.byte 102,15,58,15,228,4 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,12 + movdqa %xmm8,0+80(%rbp) + movdqa .Lrol16(%rip),%xmm8 + paddd %xmm7,%xmm3 + paddd %xmm6,%xmm2 + paddd %xmm5,%xmm1 + paddd %xmm4,%xmm0 + pxor %xmm3,%xmm15 + pxor %xmm2,%xmm14 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + pxor %xmm1,%xmm13 + pxor %xmm0,%xmm12 +.byte 102,69,15,56,0,248 +.byte 102,69,15,56,0,240 +.byte 102,69,15,56,0,232 +.byte 102,69,15,56,0,224 + movdqa 0+80(%rbp),%xmm8 + paddd %xmm15,%xmm11 + paddd %xmm14,%xmm10 + paddd %xmm13,%xmm9 + paddd %xmm12,%xmm8 + pxor %xmm11,%xmm7 + pxor %xmm10,%xmm6 + pxor %xmm9,%xmm5 + pxor %xmm8,%xmm4 + movdqa %xmm8,0+80(%rbp) + movdqa %xmm7,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm7 + pxor %xmm8,%xmm7 + movdqa %xmm6,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm6 + pxor %xmm8,%xmm6 + movdqa %xmm5,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm5 + pxor %xmm8,%xmm5 + movdqa %xmm4,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm4 + pxor %xmm8,%xmm4 + movdqa .Lrol8(%rip),%xmm8 + paddd %xmm7,%xmm3 + paddd %xmm6,%xmm2 + paddd %xmm5,%xmm1 + paddd %xmm4,%xmm0 + pxor %xmm3,%xmm15 + pxor %xmm2,%xmm14 + pxor %xmm1,%xmm13 + pxor %xmm0,%xmm12 +.byte 102,69,15,56,0,248 +.byte 102,69,15,56,0,240 +.byte 102,69,15,56,0,232 +.byte 102,69,15,56,0,224 + movdqa 0+80(%rbp),%xmm8 + paddd %xmm15,%xmm11 + paddd %xmm14,%xmm10 + paddd %xmm13,%xmm9 + paddd %xmm12,%xmm8 + pxor %xmm11,%xmm7 + pxor %xmm10,%xmm6 + pxor %xmm9,%xmm5 + pxor %xmm8,%xmm4 + movdqa %xmm8,0+80(%rbp) + movdqa %xmm7,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm7 + pxor %xmm8,%xmm7 + movdqa %xmm6,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm6 + pxor %xmm8,%xmm6 + movdqa %xmm5,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm5 + pxor %xmm8,%xmm5 + movdqa %xmm4,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm4 + pxor %xmm8,%xmm4 + movdqa 0+80(%rbp),%xmm8 +.byte 102,15,58,15,255,12 +.byte 102,69,15,58,15,219,8 +.byte 102,69,15,58,15,255,4 +.byte 102,15,58,15,246,12 +.byte 102,69,15,58,15,210,8 +.byte 102,69,15,58,15,246,4 +.byte 102,15,58,15,237,12 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,4 +.byte 102,15,58,15,228,12 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,4 + + leaq 16(%rdi),%rdi + decq %r8 + jge .Lseal_sse_main_rounds + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%rdi),%rdi + decq %rcx + jg .Lseal_sse_main_rounds + paddd .Lchacha20_consts(%rip),%xmm3 + paddd 0+48(%rbp),%xmm7 + paddd 0+64(%rbp),%xmm11 + paddd 0+144(%rbp),%xmm15 + paddd .Lchacha20_consts(%rip),%xmm2 + paddd 0+48(%rbp),%xmm6 + paddd 0+64(%rbp),%xmm10 + paddd 0+128(%rbp),%xmm14 + paddd .Lchacha20_consts(%rip),%xmm1 + paddd 0+48(%rbp),%xmm5 + paddd 0+64(%rbp),%xmm9 + paddd 0+112(%rbp),%xmm13 + paddd .Lchacha20_consts(%rip),%xmm0 + paddd 0+48(%rbp),%xmm4 + paddd 0+64(%rbp),%xmm8 + paddd 0+96(%rbp),%xmm12 + + movdqa %xmm14,0+80(%rbp) + movdqa %xmm14,0+80(%rbp) + movdqu 0 + 0(%rsi),%xmm14 + pxor %xmm3,%xmm14 + movdqu %xmm14,0 + 0(%rdi) + movdqu 16 + 0(%rsi),%xmm14 + pxor %xmm7,%xmm14 + movdqu %xmm14,16 + 0(%rdi) + movdqu 32 + 0(%rsi),%xmm14 + pxor %xmm11,%xmm14 + movdqu %xmm14,32 + 0(%rdi) + movdqu 48 + 0(%rsi),%xmm14 + pxor %xmm15,%xmm14 + movdqu %xmm14,48 + 0(%rdi) + + movdqa 0+80(%rbp),%xmm14 + movdqu 0 + 64(%rsi),%xmm3 + movdqu 16 + 64(%rsi),%xmm7 + movdqu 32 + 64(%rsi),%xmm11 + movdqu 48 + 64(%rsi),%xmm15 + pxor %xmm3,%xmm2 + pxor %xmm7,%xmm6 + pxor %xmm11,%xmm10 + pxor %xmm14,%xmm15 + movdqu %xmm2,0 + 64(%rdi) + movdqu %xmm6,16 + 64(%rdi) + movdqu %xmm10,32 + 64(%rdi) + movdqu %xmm15,48 + 64(%rdi) + movdqu 0 + 128(%rsi),%xmm3 + movdqu 16 + 128(%rsi),%xmm7 + movdqu 32 + 128(%rsi),%xmm11 + movdqu 48 + 128(%rsi),%xmm15 + pxor %xmm3,%xmm1 + pxor %xmm7,%xmm5 + pxor %xmm11,%xmm9 + pxor %xmm13,%xmm15 + movdqu %xmm1,0 + 128(%rdi) + movdqu %xmm5,16 + 128(%rdi) + movdqu %xmm9,32 + 128(%rdi) + movdqu %xmm15,48 + 128(%rdi) + + cmpq $256,%rbx + ja .Lseal_sse_main_loop_xor + + movq $192,%rcx + subq $192,%rbx + leaq 192(%rsi),%rsi + jmp .Lseal_sse_128_tail_hash +.Lseal_sse_main_loop_xor: + movdqu 0 + 192(%rsi),%xmm3 + movdqu 16 + 192(%rsi),%xmm7 + movdqu 32 + 192(%rsi),%xmm11 + movdqu 48 + 192(%rsi),%xmm15 + pxor %xmm3,%xmm0 + pxor %xmm7,%xmm4 + pxor %xmm11,%xmm8 + pxor %xmm12,%xmm15 + movdqu %xmm0,0 + 192(%rdi) + movdqu %xmm4,16 + 192(%rdi) + movdqu %xmm8,32 + 192(%rdi) + movdqu %xmm15,48 + 192(%rdi) + + leaq 256(%rsi),%rsi + subq $256,%rbx + movq $6,%rcx + movq $4,%r8 + cmpq $192,%rbx + jg .Lseal_sse_main_loop + movq %rbx,%rcx + testq %rbx,%rbx + je .Lseal_sse_128_tail_hash + movq $6,%rcx + cmpq $128,%rbx + ja .Lseal_sse_tail_192 + cmpq $64,%rbx + ja .Lseal_sse_tail_128 + +.Lseal_sse_tail_64: + movdqa .Lchacha20_consts(%rip),%xmm0 + movdqa 0+48(%rbp),%xmm4 + movdqa 0+64(%rbp),%xmm8 + movdqa 0+96(%rbp),%xmm12 + paddd .Lsse_inc(%rip),%xmm12 + movdqa %xmm12,0+96(%rbp) + +.Lseal_sse_tail_64_rounds_and_x2hash: + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%rdi),%rdi +.Lseal_sse_tail_64_rounds_and_x1hash: + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,4 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,12 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,12 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,4 + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%rdi),%rdi + decq %rcx + jg .Lseal_sse_tail_64_rounds_and_x2hash + decq %r8 + jge .Lseal_sse_tail_64_rounds_and_x1hash + paddd .Lchacha20_consts(%rip),%xmm0 + paddd 0+48(%rbp),%xmm4 + paddd 0+64(%rbp),%xmm8 + paddd 0+96(%rbp),%xmm12 + + jmp .Lseal_sse_128_tail_xor + +.Lseal_sse_tail_128: + movdqa .Lchacha20_consts(%rip),%xmm0 + movdqa 0+48(%rbp),%xmm4 + movdqa 0+64(%rbp),%xmm8 + movdqa %xmm0,%xmm1 + movdqa %xmm4,%xmm5 + movdqa %xmm8,%xmm9 + movdqa 0+96(%rbp),%xmm13 + paddd .Lsse_inc(%rip),%xmm13 + movdqa %xmm13,%xmm12 + paddd .Lsse_inc(%rip),%xmm12 + movdqa %xmm12,0+96(%rbp) + movdqa %xmm13,0+112(%rbp) + +.Lseal_sse_tail_128_rounds_and_x2hash: + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%rdi),%rdi +.Lseal_sse_tail_128_rounds_and_x1hash: + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,4 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,12 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb .Lrol16(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm5 + pxor %xmm3,%xmm5 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb .Lrol8(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm5 + pxor %xmm3,%xmm5 +.byte 102,15,58,15,237,4 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,12 + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,12 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,4 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb .Lrol16(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm5 + pxor %xmm3,%xmm5 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb .Lrol8(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm5 + pxor %xmm3,%xmm5 +.byte 102,15,58,15,237,12 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,4 + + leaq 16(%rdi),%rdi + decq %rcx + jg .Lseal_sse_tail_128_rounds_and_x2hash + decq %r8 + jge .Lseal_sse_tail_128_rounds_and_x1hash + paddd .Lchacha20_consts(%rip),%xmm1 + paddd 0+48(%rbp),%xmm5 + paddd 0+64(%rbp),%xmm9 + paddd 0+112(%rbp),%xmm13 + paddd .Lchacha20_consts(%rip),%xmm0 + paddd 0+48(%rbp),%xmm4 + paddd 0+64(%rbp),%xmm8 + paddd 0+96(%rbp),%xmm12 + movdqu 0 + 0(%rsi),%xmm3 + movdqu 16 + 0(%rsi),%xmm7 + movdqu 32 + 0(%rsi),%xmm11 + movdqu 48 + 0(%rsi),%xmm15 + pxor %xmm3,%xmm1 + pxor %xmm7,%xmm5 + pxor %xmm11,%xmm9 + pxor %xmm13,%xmm15 + movdqu %xmm1,0 + 0(%rdi) + movdqu %xmm5,16 + 0(%rdi) + movdqu %xmm9,32 + 0(%rdi) + movdqu %xmm15,48 + 0(%rdi) + + movq $64,%rcx + subq $64,%rbx + leaq 64(%rsi),%rsi + jmp .Lseal_sse_128_tail_hash + +.Lseal_sse_tail_192: + movdqa .Lchacha20_consts(%rip),%xmm0 + movdqa 0+48(%rbp),%xmm4 + movdqa 0+64(%rbp),%xmm8 + movdqa %xmm0,%xmm1 + movdqa %xmm4,%xmm5 + movdqa %xmm8,%xmm9 + movdqa %xmm0,%xmm2 + movdqa %xmm4,%xmm6 + movdqa %xmm8,%xmm10 + movdqa 0+96(%rbp),%xmm14 + paddd .Lsse_inc(%rip),%xmm14 + movdqa %xmm14,%xmm13 + paddd .Lsse_inc(%rip),%xmm13 + movdqa %xmm13,%xmm12 + paddd .Lsse_inc(%rip),%xmm12 + movdqa %xmm12,0+96(%rbp) + movdqa %xmm13,0+112(%rbp) + movdqa %xmm14,0+128(%rbp) + +.Lseal_sse_tail_192_rounds_and_x2hash: + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%rdi),%rdi +.Lseal_sse_tail_192_rounds_and_x1hash: + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,4 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,12 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb .Lrol16(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm5 + pxor %xmm3,%xmm5 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb .Lrol8(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm5 + pxor %xmm3,%xmm5 +.byte 102,15,58,15,237,4 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,12 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb .Lrol16(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm6 + pxor %xmm3,%xmm6 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb .Lrol8(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm6 + pxor %xmm3,%xmm6 +.byte 102,15,58,15,246,4 +.byte 102,69,15,58,15,210,8 +.byte 102,69,15,58,15,246,12 + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,12 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,4 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb .Lrol16(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm5 + pxor %xmm3,%xmm5 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb .Lrol8(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm5 + pxor %xmm3,%xmm5 +.byte 102,15,58,15,237,12 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,4 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb .Lrol16(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm6 + pxor %xmm3,%xmm6 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb .Lrol8(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm6 + pxor %xmm3,%xmm6 +.byte 102,15,58,15,246,12 +.byte 102,69,15,58,15,210,8 +.byte 102,69,15,58,15,246,4 + + leaq 16(%rdi),%rdi + decq %rcx + jg .Lseal_sse_tail_192_rounds_and_x2hash + decq %r8 + jge .Lseal_sse_tail_192_rounds_and_x1hash + paddd .Lchacha20_consts(%rip),%xmm2 + paddd 0+48(%rbp),%xmm6 + paddd 0+64(%rbp),%xmm10 + paddd 0+128(%rbp),%xmm14 + paddd .Lchacha20_consts(%rip),%xmm1 + paddd 0+48(%rbp),%xmm5 + paddd 0+64(%rbp),%xmm9 + paddd 0+112(%rbp),%xmm13 + paddd .Lchacha20_consts(%rip),%xmm0 + paddd 0+48(%rbp),%xmm4 + paddd 0+64(%rbp),%xmm8 + paddd 0+96(%rbp),%xmm12 + movdqu 0 + 0(%rsi),%xmm3 + movdqu 16 + 0(%rsi),%xmm7 + movdqu 32 + 0(%rsi),%xmm11 + movdqu 48 + 0(%rsi),%xmm15 + pxor %xmm3,%xmm2 + pxor %xmm7,%xmm6 + pxor %xmm11,%xmm10 + pxor %xmm14,%xmm15 + movdqu %xmm2,0 + 0(%rdi) + movdqu %xmm6,16 + 0(%rdi) + movdqu %xmm10,32 + 0(%rdi) + movdqu %xmm15,48 + 0(%rdi) + movdqu 0 + 64(%rsi),%xmm3 + movdqu 16 + 64(%rsi),%xmm7 + movdqu 32 + 64(%rsi),%xmm11 + movdqu 48 + 64(%rsi),%xmm15 + pxor %xmm3,%xmm1 + pxor %xmm7,%xmm5 + pxor %xmm11,%xmm9 + pxor %xmm13,%xmm15 + movdqu %xmm1,0 + 64(%rdi) + movdqu %xmm5,16 + 64(%rdi) + movdqu %xmm9,32 + 64(%rdi) + movdqu %xmm15,48 + 64(%rdi) + + movq $128,%rcx + subq $128,%rbx + leaq 128(%rsi),%rsi + +.Lseal_sse_128_tail_hash: + cmpq $16,%rcx + jb .Lseal_sse_128_tail_xor + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + subq $16,%rcx + leaq 16(%rdi),%rdi + jmp .Lseal_sse_128_tail_hash + +.Lseal_sse_128_tail_xor: + cmpq $16,%rbx + jb .Lseal_sse_tail_16 + subq $16,%rbx + + movdqu 0(%rsi),%xmm3 + pxor %xmm3,%xmm0 + movdqu %xmm0,0(%rdi) + + addq 0(%rdi),%r10 + adcq 8(%rdi),%r11 + adcq $1,%r12 + leaq 16(%rsi),%rsi + leaq 16(%rdi),%rdi + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + + movdqa %xmm4,%xmm0 + movdqa %xmm8,%xmm4 + movdqa %xmm12,%xmm8 + movdqa %xmm1,%xmm12 + movdqa %xmm5,%xmm1 + movdqa %xmm9,%xmm5 + movdqa %xmm13,%xmm9 + jmp .Lseal_sse_128_tail_xor + +.Lseal_sse_tail_16: + testq %rbx,%rbx + jz .Lprocess_blocks_of_extra_in + + movq %rbx,%r8 + movq %rbx,%rcx + leaq -1(%rsi,%rbx,1),%rsi + pxor %xmm15,%xmm15 +.Lseal_sse_tail_16_compose: + pslldq $1,%xmm15 + pinsrb $0,(%rsi),%xmm15 + leaq -1(%rsi),%rsi + decq %rcx + jne .Lseal_sse_tail_16_compose + + + pxor %xmm0,%xmm15 + + + movq %rbx,%rcx + movdqu %xmm15,%xmm0 +.Lseal_sse_tail_16_extract: + pextrb $0,%xmm0,(%rdi) + psrldq $1,%xmm0 + addq $1,%rdi + subq $1,%rcx + jnz .Lseal_sse_tail_16_extract + + + + + + + + + movq 288 + 0 + 32(%rsp),%r9 + movq 56(%r9),%r14 + movq 48(%r9),%r13 + testq %r14,%r14 + jz .Lprocess_partial_block + + movq $16,%r15 + subq %rbx,%r15 + cmpq %r15,%r14 + + jge .Lload_extra_in + movq %r14,%r15 + +.Lload_extra_in: + + + leaq -1(%r13,%r15,1),%rsi + + + addq %r15,%r13 + subq %r15,%r14 + movq %r13,48(%r9) + movq %r14,56(%r9) + + + + addq %r15,%r8 + + + pxor %xmm11,%xmm11 +.Lload_extra_load_loop: + pslldq $1,%xmm11 + pinsrb $0,(%rsi),%xmm11 + leaq -1(%rsi),%rsi + subq $1,%r15 + jnz .Lload_extra_load_loop + + + + + movq %rbx,%r15 + +.Lload_extra_shift_loop: + pslldq $1,%xmm11 + subq $1,%r15 + jnz .Lload_extra_shift_loop + + + + + leaq .Land_masks(%rip),%r15 + shlq $4,%rbx + pand -16(%r15,%rbx,1),%xmm15 + + + por %xmm11,%xmm15 + + + +.byte 102,77,15,126,253 + pextrq $1,%xmm15,%r14 + addq %r13,%r10 + adcq %r14,%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + +.Lprocess_blocks_of_extra_in: + + movq 288+32+0 (%rsp),%r9 + movq 48(%r9),%rsi + movq 56(%r9),%r8 + movq %r8,%rcx + shrq $4,%r8 + +.Lprocess_extra_hash_loop: + jz process_extra_in_trailer + addq 0+0(%rsi),%r10 + adcq 8+0(%rsi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%rsi),%rsi + subq $1,%r8 + jmp .Lprocess_extra_hash_loop +process_extra_in_trailer: + andq $15,%rcx + movq %rcx,%rbx + jz .Ldo_length_block + leaq -1(%rsi,%rcx,1),%rsi + +.Lprocess_extra_in_trailer_load: + pslldq $1,%xmm15 + pinsrb $0,(%rsi),%xmm15 + leaq -1(%rsi),%rsi + subq $1,%rcx + jnz .Lprocess_extra_in_trailer_load + +.Lprocess_partial_block: + + leaq .Land_masks(%rip),%r15 + shlq $4,%rbx + pand -16(%r15,%rbx,1),%xmm15 +.byte 102,77,15,126,253 + pextrq $1,%xmm15,%r14 + addq %r13,%r10 + adcq %r14,%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + +.Ldo_length_block: + addq 0+0+32(%rbp),%r10 + adcq 8+0+32(%rbp),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + + movq %r10,%r13 + movq %r11,%r14 + movq %r12,%r15 + subq $-5,%r10 + sbbq $-1,%r11 + sbbq $3,%r12 + cmovcq %r13,%r10 + cmovcq %r14,%r11 + cmovcq %r15,%r12 + + addq 0+0+16(%rbp),%r10 + adcq 8+0+16(%rbp),%r11 + +.cfi_remember_state + addq $288 + 0 + 32,%rsp +.cfi_adjust_cfa_offset -(288 + 32) + + popq %r9 +.cfi_adjust_cfa_offset -8 +.cfi_restore %r9 + movq %r10,(%r9) + movq %r11,8(%r9) + popq %r15 +.cfi_adjust_cfa_offset -8 +.cfi_restore %r15 + popq %r14 +.cfi_adjust_cfa_offset -8 +.cfi_restore %r14 + popq %r13 +.cfi_adjust_cfa_offset -8 +.cfi_restore %r13 + popq %r12 +.cfi_adjust_cfa_offset -8 +.cfi_restore %r12 + popq %rbx +.cfi_adjust_cfa_offset -8 +.cfi_restore %rbx + popq %rbp +.cfi_adjust_cfa_offset -8 +.cfi_restore %rbp + ret + +.Lseal_sse_128: +.cfi_restore_state + movdqu .Lchacha20_consts(%rip),%xmm0 + movdqa %xmm0,%xmm1 + movdqa %xmm0,%xmm2 + movdqu 0(%r9),%xmm4 + movdqa %xmm4,%xmm5 + movdqa %xmm4,%xmm6 + movdqu 16(%r9),%xmm8 + movdqa %xmm8,%xmm9 + movdqa %xmm8,%xmm10 + movdqu 32(%r9),%xmm14 + movdqa %xmm14,%xmm12 + paddd .Lsse_inc(%rip),%xmm12 + movdqa %xmm12,%xmm13 + paddd .Lsse_inc(%rip),%xmm13 + movdqa %xmm4,%xmm7 + movdqa %xmm8,%xmm11 + movdqa %xmm12,%xmm15 + movq $10,%r10 + +.Lseal_sse_128_rounds: + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,4 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,12 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb .Lrol16(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm5 + pxor %xmm3,%xmm5 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb .Lrol8(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm5 + pxor %xmm3,%xmm5 +.byte 102,15,58,15,237,4 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,12 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb .Lrol16(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm6 + pxor %xmm3,%xmm6 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb .Lrol8(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm6 + pxor %xmm3,%xmm6 +.byte 102,15,58,15,246,4 +.byte 102,69,15,58,15,210,8 +.byte 102,69,15,58,15,246,12 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb .Lrol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,12 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,4 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb .Lrol16(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm5 + pxor %xmm3,%xmm5 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb .Lrol8(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm5 + pxor %xmm3,%xmm5 +.byte 102,15,58,15,237,12 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,4 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb .Lrol16(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm6 + pxor %xmm3,%xmm6 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb .Lrol8(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm6 + pxor %xmm3,%xmm6 +.byte 102,15,58,15,246,12 +.byte 102,69,15,58,15,210,8 +.byte 102,69,15,58,15,246,4 + + decq %r10 + jnz .Lseal_sse_128_rounds + paddd .Lchacha20_consts(%rip),%xmm0 + paddd .Lchacha20_consts(%rip),%xmm1 + paddd .Lchacha20_consts(%rip),%xmm2 + paddd %xmm7,%xmm4 + paddd %xmm7,%xmm5 + paddd %xmm7,%xmm6 + paddd %xmm11,%xmm8 + paddd %xmm11,%xmm9 + paddd %xmm15,%xmm12 + paddd .Lsse_inc(%rip),%xmm15 + paddd %xmm15,%xmm13 + + pand .Lclamp(%rip),%xmm2 + movdqa %xmm2,0+0(%rbp) + movdqa %xmm6,0+16(%rbp) + + movq %r8,%r8 + call poly_hash_ad_internal + jmp .Lseal_sse_128_tail_xor +.size chacha20_poly1305_seal_sse41, .-chacha20_poly1305_seal_sse41 +.cfi_endproc + + +.globl chacha20_poly1305_open_avx2 +.hidden chacha20_poly1305_open_avx2 +.type chacha20_poly1305_open_avx2,@function +.align 64 +chacha20_poly1305_open_avx2: +.cfi_startproc +_CET_ENDBR + pushq %rbp +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbp,-16 + pushq %rbx +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbx,-24 + pushq %r12 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r12,-32 + pushq %r13 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r13,-40 + pushq %r14 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r14,-48 + pushq %r15 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r15,-56 + + + pushq %r9 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r9,-64 + subq $288 + 0 + 32,%rsp +.cfi_adjust_cfa_offset 288 + 32 + + leaq 32(%rsp),%rbp + andq $-32,%rbp + + movq %rdx,%rbx + movq %r8,0+0+32(%rbp) + movq %rbx,8+0+32(%rbp) + + vzeroupper + vmovdqa .Lchacha20_consts(%rip),%ymm0 + vbroadcasti128 0(%r9),%ymm4 + vbroadcasti128 16(%r9),%ymm8 + vbroadcasti128 32(%r9),%ymm12 + vpaddd .Lavx2_init(%rip),%ymm12,%ymm12 + cmpq $192,%rbx + jbe .Lopen_avx2_192 + cmpq $320,%rbx + jbe .Lopen_avx2_320 + + vmovdqa %ymm4,0+64(%rbp) + vmovdqa %ymm8,0+96(%rbp) + vmovdqa %ymm12,0+160(%rbp) + movq $10,%r10 +.Lopen_avx2_init_rounds: + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $4,%ymm4,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $4,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm4,%ymm4,%ymm4 + + decq %r10 + jne .Lopen_avx2_init_rounds + vpaddd .Lchacha20_consts(%rip),%ymm0,%ymm0 + vpaddd 0+64(%rbp),%ymm4,%ymm4 + vpaddd 0+96(%rbp),%ymm8,%ymm8 + vpaddd 0+160(%rbp),%ymm12,%ymm12 + + vperm2i128 $0x02,%ymm0,%ymm4,%ymm3 + + vpand .Lclamp(%rip),%ymm3,%ymm3 + vmovdqa %ymm3,0+0(%rbp) + + vperm2i128 $0x13,%ymm0,%ymm4,%ymm0 + vperm2i128 $0x13,%ymm8,%ymm12,%ymm4 + + movq %r8,%r8 + call poly_hash_ad_internal + + xorq %rcx,%rcx +.Lopen_avx2_init_hash: + addq 0+0(%rsi,%rcx,1),%r10 + adcq 8+0(%rsi,%rcx,1),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + addq $16,%rcx + cmpq $64,%rcx + jne .Lopen_avx2_init_hash + + vpxor 0(%rsi),%ymm0,%ymm0 + vpxor 32(%rsi),%ymm4,%ymm4 + + vmovdqu %ymm0,0(%rdi) + vmovdqu %ymm4,32(%rdi) + leaq 64(%rsi),%rsi + leaq 64(%rdi),%rdi + subq $64,%rbx +.Lopen_avx2_main_loop: + + cmpq $512,%rbx + jb .Lopen_avx2_main_loop_done + vmovdqa .Lchacha20_consts(%rip),%ymm0 + vmovdqa 0+64(%rbp),%ymm4 + vmovdqa 0+96(%rbp),%ymm8 + vmovdqa %ymm0,%ymm1 + vmovdqa %ymm4,%ymm5 + vmovdqa %ymm8,%ymm9 + vmovdqa %ymm0,%ymm2 + vmovdqa %ymm4,%ymm6 + vmovdqa %ymm8,%ymm10 + vmovdqa %ymm0,%ymm3 + vmovdqa %ymm4,%ymm7 + vmovdqa %ymm8,%ymm11 + vmovdqa .Lavx2_inc(%rip),%ymm12 + vpaddd 0+160(%rbp),%ymm12,%ymm15 + vpaddd %ymm15,%ymm12,%ymm14 + vpaddd %ymm14,%ymm12,%ymm13 + vpaddd %ymm13,%ymm12,%ymm12 + vmovdqa %ymm15,0+256(%rbp) + vmovdqa %ymm14,0+224(%rbp) + vmovdqa %ymm13,0+192(%rbp) + vmovdqa %ymm12,0+160(%rbp) + + xorq %rcx,%rcx +.Lopen_avx2_main_loop_rounds: + addq 0+0(%rsi,%rcx,1),%r10 + adcq 8+0(%rsi,%rcx,1),%r11 + adcq $1,%r12 + vmovdqa %ymm8,0+128(%rbp) + vmovdqa .Lrol16(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $20,%ymm7,%ymm8 + vpslld $32-20,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $20,%ymm6,%ymm8 + vpslld $32-20,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $20,%ymm5,%ymm8 + vpslld $32-20,%ymm5,%ymm5 + addq %rax,%r15 + adcq %rdx,%r9 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $20,%ymm4,%ymm8 + vpslld $32-20,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa .Lrol8(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + addq 0+16(%rsi,%rcx,1),%r10 + adcq 8+16(%rsi,%rcx,1),%r11 + adcq $1,%r12 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $25,%ymm7,%ymm8 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + vpslld $32-25,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $25,%ymm6,%ymm8 + vpslld $32-25,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $25,%ymm5,%ymm8 + vpslld $32-25,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $25,%ymm4,%ymm8 + vpslld $32-25,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa 0+128(%rbp),%ymm8 + vpalignr $4,%ymm7,%ymm7,%ymm7 + vpalignr $8,%ymm11,%ymm11,%ymm11 + vpalignr $12,%ymm15,%ymm15,%ymm15 + vpalignr $4,%ymm6,%ymm6,%ymm6 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $12,%ymm14,%ymm14,%ymm14 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + vpalignr $4,%ymm5,%ymm5,%ymm5 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $12,%ymm13,%ymm13,%ymm13 + vpalignr $4,%ymm4,%ymm4,%ymm4 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vmovdqa %ymm8,0+128(%rbp) + vmovdqa .Lrol16(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + addq %rax,%r15 + adcq %rdx,%r9 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $20,%ymm7,%ymm8 + vpslld $32-20,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $20,%ymm6,%ymm8 + vpslld $32-20,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + addq 0+32(%rsi,%rcx,1),%r10 + adcq 8+32(%rsi,%rcx,1),%r11 + adcq $1,%r12 + + leaq 48(%rcx),%rcx + vpsrld $20,%ymm5,%ymm8 + vpslld $32-20,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $20,%ymm4,%ymm8 + vpslld $32-20,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa .Lrol8(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $25,%ymm7,%ymm8 + vpslld $32-25,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $25,%ymm6,%ymm8 + vpslld $32-25,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + addq %rax,%r15 + adcq %rdx,%r9 + vpsrld $25,%ymm5,%ymm8 + vpslld $32-25,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $25,%ymm4,%ymm8 + vpslld $32-25,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa 0+128(%rbp),%ymm8 + vpalignr $12,%ymm7,%ymm7,%ymm7 + vpalignr $8,%ymm11,%ymm11,%ymm11 + vpalignr $4,%ymm15,%ymm15,%ymm15 + vpalignr $12,%ymm6,%ymm6,%ymm6 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $4,%ymm14,%ymm14,%ymm14 + vpalignr $12,%ymm5,%ymm5,%ymm5 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $4,%ymm13,%ymm13,%ymm13 + vpalignr $12,%ymm4,%ymm4,%ymm4 + vpalignr $8,%ymm8,%ymm8,%ymm8 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + vpalignr $4,%ymm12,%ymm12,%ymm12 + + cmpq $60*8,%rcx + jne .Lopen_avx2_main_loop_rounds + vpaddd .Lchacha20_consts(%rip),%ymm3,%ymm3 + vpaddd 0+64(%rbp),%ymm7,%ymm7 + vpaddd 0+96(%rbp),%ymm11,%ymm11 + vpaddd 0+256(%rbp),%ymm15,%ymm15 + vpaddd .Lchacha20_consts(%rip),%ymm2,%ymm2 + vpaddd 0+64(%rbp),%ymm6,%ymm6 + vpaddd 0+96(%rbp),%ymm10,%ymm10 + vpaddd 0+224(%rbp),%ymm14,%ymm14 + vpaddd .Lchacha20_consts(%rip),%ymm1,%ymm1 + vpaddd 0+64(%rbp),%ymm5,%ymm5 + vpaddd 0+96(%rbp),%ymm9,%ymm9 + vpaddd 0+192(%rbp),%ymm13,%ymm13 + vpaddd .Lchacha20_consts(%rip),%ymm0,%ymm0 + vpaddd 0+64(%rbp),%ymm4,%ymm4 + vpaddd 0+96(%rbp),%ymm8,%ymm8 + vpaddd 0+160(%rbp),%ymm12,%ymm12 + + vmovdqa %ymm0,0+128(%rbp) + addq 0+60*8(%rsi),%r10 + adcq 8+60*8(%rsi),%r11 + adcq $1,%r12 + vperm2i128 $0x02,%ymm3,%ymm7,%ymm0 + vperm2i128 $0x13,%ymm3,%ymm7,%ymm7 + vperm2i128 $0x02,%ymm11,%ymm15,%ymm3 + vperm2i128 $0x13,%ymm11,%ymm15,%ymm11 + vpxor 0+0(%rsi),%ymm0,%ymm0 + vpxor 32+0(%rsi),%ymm3,%ymm3 + vpxor 64+0(%rsi),%ymm7,%ymm7 + vpxor 96+0(%rsi),%ymm11,%ymm11 + vmovdqu %ymm0,0+0(%rdi) + vmovdqu %ymm3,32+0(%rdi) + vmovdqu %ymm7,64+0(%rdi) + vmovdqu %ymm11,96+0(%rdi) + + vmovdqa 0+128(%rbp),%ymm0 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + vperm2i128 $0x02,%ymm2,%ymm6,%ymm3 + vperm2i128 $0x13,%ymm2,%ymm6,%ymm6 + vperm2i128 $0x02,%ymm10,%ymm14,%ymm2 + vperm2i128 $0x13,%ymm10,%ymm14,%ymm10 + vpxor 0+128(%rsi),%ymm3,%ymm3 + vpxor 32+128(%rsi),%ymm2,%ymm2 + vpxor 64+128(%rsi),%ymm6,%ymm6 + vpxor 96+128(%rsi),%ymm10,%ymm10 + vmovdqu %ymm3,0+128(%rdi) + vmovdqu %ymm2,32+128(%rdi) + vmovdqu %ymm6,64+128(%rdi) + vmovdqu %ymm10,96+128(%rdi) + addq 0+60*8+16(%rsi),%r10 + adcq 8+60*8+16(%rsi),%r11 + adcq $1,%r12 + vperm2i128 $0x02,%ymm1,%ymm5,%ymm3 + vperm2i128 $0x13,%ymm1,%ymm5,%ymm5 + vperm2i128 $0x02,%ymm9,%ymm13,%ymm1 + vperm2i128 $0x13,%ymm9,%ymm13,%ymm9 + vpxor 0+256(%rsi),%ymm3,%ymm3 + vpxor 32+256(%rsi),%ymm1,%ymm1 + vpxor 64+256(%rsi),%ymm5,%ymm5 + vpxor 96+256(%rsi),%ymm9,%ymm9 + vmovdqu %ymm3,0+256(%rdi) + vmovdqu %ymm1,32+256(%rdi) + vmovdqu %ymm5,64+256(%rdi) + vmovdqu %ymm9,96+256(%rdi) + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + vperm2i128 $0x02,%ymm0,%ymm4,%ymm3 + vperm2i128 $0x13,%ymm0,%ymm4,%ymm4 + vperm2i128 $0x02,%ymm8,%ymm12,%ymm0 + vperm2i128 $0x13,%ymm8,%ymm12,%ymm8 + vpxor 0+384(%rsi),%ymm3,%ymm3 + vpxor 32+384(%rsi),%ymm0,%ymm0 + vpxor 64+384(%rsi),%ymm4,%ymm4 + vpxor 96+384(%rsi),%ymm8,%ymm8 + vmovdqu %ymm3,0+384(%rdi) + vmovdqu %ymm0,32+384(%rdi) + vmovdqu %ymm4,64+384(%rdi) + vmovdqu %ymm8,96+384(%rdi) + + leaq 512(%rsi),%rsi + leaq 512(%rdi),%rdi + subq $512,%rbx + jmp .Lopen_avx2_main_loop +.Lopen_avx2_main_loop_done: + testq %rbx,%rbx + vzeroupper + je .Lopen_sse_finalize + + cmpq $384,%rbx + ja .Lopen_avx2_tail_512 + cmpq $256,%rbx + ja .Lopen_avx2_tail_384 + cmpq $128,%rbx + ja .Lopen_avx2_tail_256 + vmovdqa .Lchacha20_consts(%rip),%ymm0 + vmovdqa 0+64(%rbp),%ymm4 + vmovdqa 0+96(%rbp),%ymm8 + vmovdqa .Lavx2_inc(%rip),%ymm12 + vpaddd 0+160(%rbp),%ymm12,%ymm12 + vmovdqa %ymm12,0+160(%rbp) + + xorq %r8,%r8 + movq %rbx,%rcx + andq $-16,%rcx + testq %rcx,%rcx + je .Lopen_avx2_tail_128_rounds +.Lopen_avx2_tail_128_rounds_and_x1hash: + addq 0+0(%rsi,%r8,1),%r10 + adcq 8+0(%rsi,%r8,1),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + +.Lopen_avx2_tail_128_rounds: + addq $16,%r8 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $4,%ymm4,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $4,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm4,%ymm4,%ymm4 + + cmpq %rcx,%r8 + jb .Lopen_avx2_tail_128_rounds_and_x1hash + cmpq $160,%r8 + jne .Lopen_avx2_tail_128_rounds + vpaddd .Lchacha20_consts(%rip),%ymm0,%ymm0 + vpaddd 0+64(%rbp),%ymm4,%ymm4 + vpaddd 0+96(%rbp),%ymm8,%ymm8 + vpaddd 0+160(%rbp),%ymm12,%ymm12 + vperm2i128 $0x13,%ymm0,%ymm4,%ymm3 + vperm2i128 $0x02,%ymm0,%ymm4,%ymm0 + vperm2i128 $0x02,%ymm8,%ymm12,%ymm4 + vperm2i128 $0x13,%ymm8,%ymm12,%ymm12 + vmovdqa %ymm3,%ymm8 + + jmp .Lopen_avx2_tail_128_xor + +.Lopen_avx2_tail_256: + vmovdqa .Lchacha20_consts(%rip),%ymm0 + vmovdqa 0+64(%rbp),%ymm4 + vmovdqa 0+96(%rbp),%ymm8 + vmovdqa %ymm0,%ymm1 + vmovdqa %ymm4,%ymm5 + vmovdqa %ymm8,%ymm9 + vmovdqa .Lavx2_inc(%rip),%ymm12 + vpaddd 0+160(%rbp),%ymm12,%ymm13 + vpaddd %ymm13,%ymm12,%ymm12 + vmovdqa %ymm12,0+160(%rbp) + vmovdqa %ymm13,0+192(%rbp) + + movq %rbx,0+128(%rbp) + movq %rbx,%rcx + subq $128,%rcx + shrq $4,%rcx + movq $10,%r8 + cmpq $10,%rcx + cmovgq %r8,%rcx + movq %rsi,%rbx + xorq %r8,%r8 +.Lopen_avx2_tail_256_rounds_and_x1hash: + addq 0+0(%rbx),%r10 + adcq 8+0(%rbx),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + addq %rax,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%rbx),%rbx +.Lopen_avx2_tail_256_rounds: + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $4,%ymm4,%ymm4,%ymm4 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb .Lrol16(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpsrld $20,%ymm5,%ymm3 + vpslld $12,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb .Lrol8(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpslld $7,%ymm5,%ymm3 + vpsrld $25,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpalignr $12,%ymm13,%ymm13,%ymm13 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $4,%ymm5,%ymm5,%ymm5 + + incq %r8 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $4,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm4,%ymm4,%ymm4 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb .Lrol16(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpsrld $20,%ymm5,%ymm3 + vpslld $12,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb .Lrol8(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpslld $7,%ymm5,%ymm3 + vpsrld $25,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpalignr $4,%ymm13,%ymm13,%ymm13 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $12,%ymm5,%ymm5,%ymm5 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb .Lrol16(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpsrld $20,%ymm6,%ymm3 + vpslld $12,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb .Lrol8(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpslld $7,%ymm6,%ymm3 + vpsrld $25,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpalignr $4,%ymm14,%ymm14,%ymm14 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $12,%ymm6,%ymm6,%ymm6 + + cmpq %rcx,%r8 + jb .Lopen_avx2_tail_256_rounds_and_x1hash + cmpq $10,%r8 + jne .Lopen_avx2_tail_256_rounds + movq %rbx,%r8 + subq %rsi,%rbx + movq %rbx,%rcx + movq 0+128(%rbp),%rbx +.Lopen_avx2_tail_256_hash: + addq $16,%rcx + cmpq %rbx,%rcx + jg .Lopen_avx2_tail_256_done + addq 0+0(%r8),%r10 + adcq 8+0(%r8),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + addq %rax,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%r8),%r8 + jmp .Lopen_avx2_tail_256_hash +.Lopen_avx2_tail_256_done: + vpaddd .Lchacha20_consts(%rip),%ymm1,%ymm1 + vpaddd 0+64(%rbp),%ymm5,%ymm5 + vpaddd 0+96(%rbp),%ymm9,%ymm9 + vpaddd 0+192(%rbp),%ymm13,%ymm13 + vpaddd .Lchacha20_consts(%rip),%ymm0,%ymm0 + vpaddd 0+64(%rbp),%ymm4,%ymm4 + vpaddd 0+96(%rbp),%ymm8,%ymm8 + vpaddd 0+160(%rbp),%ymm12,%ymm12 + vperm2i128 $0x02,%ymm1,%ymm5,%ymm3 + vperm2i128 $0x13,%ymm1,%ymm5,%ymm5 + vperm2i128 $0x02,%ymm9,%ymm13,%ymm1 + vperm2i128 $0x13,%ymm9,%ymm13,%ymm9 + vpxor 0+0(%rsi),%ymm3,%ymm3 + vpxor 32+0(%rsi),%ymm1,%ymm1 + vpxor 64+0(%rsi),%ymm5,%ymm5 + vpxor 96+0(%rsi),%ymm9,%ymm9 + vmovdqu %ymm3,0+0(%rdi) + vmovdqu %ymm1,32+0(%rdi) + vmovdqu %ymm5,64+0(%rdi) + vmovdqu %ymm9,96+0(%rdi) + vperm2i128 $0x13,%ymm0,%ymm4,%ymm3 + vperm2i128 $0x02,%ymm0,%ymm4,%ymm0 + vperm2i128 $0x02,%ymm8,%ymm12,%ymm4 + vperm2i128 $0x13,%ymm8,%ymm12,%ymm12 + vmovdqa %ymm3,%ymm8 + + leaq 128(%rsi),%rsi + leaq 128(%rdi),%rdi + subq $128,%rbx + jmp .Lopen_avx2_tail_128_xor + +.Lopen_avx2_tail_384: + vmovdqa .Lchacha20_consts(%rip),%ymm0 + vmovdqa 0+64(%rbp),%ymm4 + vmovdqa 0+96(%rbp),%ymm8 + vmovdqa %ymm0,%ymm1 + vmovdqa %ymm4,%ymm5 + vmovdqa %ymm8,%ymm9 + vmovdqa %ymm0,%ymm2 + vmovdqa %ymm4,%ymm6 + vmovdqa %ymm8,%ymm10 + vmovdqa .Lavx2_inc(%rip),%ymm12 + vpaddd 0+160(%rbp),%ymm12,%ymm14 + vpaddd %ymm14,%ymm12,%ymm13 + vpaddd %ymm13,%ymm12,%ymm12 + vmovdqa %ymm12,0+160(%rbp) + vmovdqa %ymm13,0+192(%rbp) + vmovdqa %ymm14,0+224(%rbp) + + movq %rbx,0+128(%rbp) + movq %rbx,%rcx + subq $256,%rcx + shrq $4,%rcx + addq $6,%rcx + movq $10,%r8 + cmpq $10,%rcx + cmovgq %r8,%rcx + movq %rsi,%rbx + xorq %r8,%r8 +.Lopen_avx2_tail_384_rounds_and_x2hash: + addq 0+0(%rbx),%r10 + adcq 8+0(%rbx),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + addq %rax,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%rbx),%rbx +.Lopen_avx2_tail_384_rounds_and_x1hash: + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb .Lrol16(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpsrld $20,%ymm6,%ymm3 + vpslld $12,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb .Lrol8(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpslld $7,%ymm6,%ymm3 + vpsrld $25,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpalignr $12,%ymm14,%ymm14,%ymm14 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $4,%ymm6,%ymm6,%ymm6 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb .Lrol16(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpsrld $20,%ymm5,%ymm3 + vpslld $12,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb .Lrol8(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpslld $7,%ymm5,%ymm3 + vpsrld $25,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpalignr $12,%ymm13,%ymm13,%ymm13 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $4,%ymm5,%ymm5,%ymm5 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $4,%ymm4,%ymm4,%ymm4 + addq 0+0(%rbx),%r10 + adcq 8+0(%rbx),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%rbx),%rbx + incq %r8 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb .Lrol16(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpsrld $20,%ymm6,%ymm3 + vpslld $12,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb .Lrol8(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpslld $7,%ymm6,%ymm3 + vpsrld $25,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpalignr $4,%ymm14,%ymm14,%ymm14 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $12,%ymm6,%ymm6,%ymm6 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb .Lrol16(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpsrld $20,%ymm5,%ymm3 + vpslld $12,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb .Lrol8(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpslld $7,%ymm5,%ymm3 + vpsrld $25,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpalignr $4,%ymm13,%ymm13,%ymm13 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $12,%ymm5,%ymm5,%ymm5 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $4,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm4,%ymm4,%ymm4 + + cmpq %rcx,%r8 + jb .Lopen_avx2_tail_384_rounds_and_x2hash + cmpq $10,%r8 + jne .Lopen_avx2_tail_384_rounds_and_x1hash + movq %rbx,%r8 + subq %rsi,%rbx + movq %rbx,%rcx + movq 0+128(%rbp),%rbx +.Lopen_avx2_384_tail_hash: + addq $16,%rcx + cmpq %rbx,%rcx + jg .Lopen_avx2_384_tail_done + addq 0+0(%r8),%r10 + adcq 8+0(%r8),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + addq %rax,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%r8),%r8 + jmp .Lopen_avx2_384_tail_hash +.Lopen_avx2_384_tail_done: + vpaddd .Lchacha20_consts(%rip),%ymm2,%ymm2 + vpaddd 0+64(%rbp),%ymm6,%ymm6 + vpaddd 0+96(%rbp),%ymm10,%ymm10 + vpaddd 0+224(%rbp),%ymm14,%ymm14 + vpaddd .Lchacha20_consts(%rip),%ymm1,%ymm1 + vpaddd 0+64(%rbp),%ymm5,%ymm5 + vpaddd 0+96(%rbp),%ymm9,%ymm9 + vpaddd 0+192(%rbp),%ymm13,%ymm13 + vpaddd .Lchacha20_consts(%rip),%ymm0,%ymm0 + vpaddd 0+64(%rbp),%ymm4,%ymm4 + vpaddd 0+96(%rbp),%ymm8,%ymm8 + vpaddd 0+160(%rbp),%ymm12,%ymm12 + vperm2i128 $0x02,%ymm2,%ymm6,%ymm3 + vperm2i128 $0x13,%ymm2,%ymm6,%ymm6 + vperm2i128 $0x02,%ymm10,%ymm14,%ymm2 + vperm2i128 $0x13,%ymm10,%ymm14,%ymm10 + vpxor 0+0(%rsi),%ymm3,%ymm3 + vpxor 32+0(%rsi),%ymm2,%ymm2 + vpxor 64+0(%rsi),%ymm6,%ymm6 + vpxor 96+0(%rsi),%ymm10,%ymm10 + vmovdqu %ymm3,0+0(%rdi) + vmovdqu %ymm2,32+0(%rdi) + vmovdqu %ymm6,64+0(%rdi) + vmovdqu %ymm10,96+0(%rdi) + vperm2i128 $0x02,%ymm1,%ymm5,%ymm3 + vperm2i128 $0x13,%ymm1,%ymm5,%ymm5 + vperm2i128 $0x02,%ymm9,%ymm13,%ymm1 + vperm2i128 $0x13,%ymm9,%ymm13,%ymm9 + vpxor 0+128(%rsi),%ymm3,%ymm3 + vpxor 32+128(%rsi),%ymm1,%ymm1 + vpxor 64+128(%rsi),%ymm5,%ymm5 + vpxor 96+128(%rsi),%ymm9,%ymm9 + vmovdqu %ymm3,0+128(%rdi) + vmovdqu %ymm1,32+128(%rdi) + vmovdqu %ymm5,64+128(%rdi) + vmovdqu %ymm9,96+128(%rdi) + vperm2i128 $0x13,%ymm0,%ymm4,%ymm3 + vperm2i128 $0x02,%ymm0,%ymm4,%ymm0 + vperm2i128 $0x02,%ymm8,%ymm12,%ymm4 + vperm2i128 $0x13,%ymm8,%ymm12,%ymm12 + vmovdqa %ymm3,%ymm8 + + leaq 256(%rsi),%rsi + leaq 256(%rdi),%rdi + subq $256,%rbx + jmp .Lopen_avx2_tail_128_xor + +.Lopen_avx2_tail_512: + vmovdqa .Lchacha20_consts(%rip),%ymm0 + vmovdqa 0+64(%rbp),%ymm4 + vmovdqa 0+96(%rbp),%ymm8 + vmovdqa %ymm0,%ymm1 + vmovdqa %ymm4,%ymm5 + vmovdqa %ymm8,%ymm9 + vmovdqa %ymm0,%ymm2 + vmovdqa %ymm4,%ymm6 + vmovdqa %ymm8,%ymm10 + vmovdqa %ymm0,%ymm3 + vmovdqa %ymm4,%ymm7 + vmovdqa %ymm8,%ymm11 + vmovdqa .Lavx2_inc(%rip),%ymm12 + vpaddd 0+160(%rbp),%ymm12,%ymm15 + vpaddd %ymm15,%ymm12,%ymm14 + vpaddd %ymm14,%ymm12,%ymm13 + vpaddd %ymm13,%ymm12,%ymm12 + vmovdqa %ymm15,0+256(%rbp) + vmovdqa %ymm14,0+224(%rbp) + vmovdqa %ymm13,0+192(%rbp) + vmovdqa %ymm12,0+160(%rbp) + + xorq %rcx,%rcx + movq %rsi,%r8 +.Lopen_avx2_tail_512_rounds_and_x2hash: + addq 0+0(%r8),%r10 + adcq 8+0(%r8),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%r8),%r8 +.Lopen_avx2_tail_512_rounds_and_x1hash: + vmovdqa %ymm8,0+128(%rbp) + vmovdqa .Lrol16(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $20,%ymm7,%ymm8 + vpslld $32-20,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $20,%ymm6,%ymm8 + vpslld $32-20,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $20,%ymm5,%ymm8 + vpslld $32-20,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $20,%ymm4,%ymm8 + vpslld $32-20,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa .Lrol8(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + addq 0+0(%r8),%r10 + adcq 8+0(%r8),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + addq %rax,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $25,%ymm7,%ymm8 + vpslld $32-25,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $25,%ymm6,%ymm8 + vpslld $32-25,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $25,%ymm5,%ymm8 + vpslld $32-25,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $25,%ymm4,%ymm8 + vpslld $32-25,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa 0+128(%rbp),%ymm8 + vpalignr $4,%ymm7,%ymm7,%ymm7 + vpalignr $8,%ymm11,%ymm11,%ymm11 + vpalignr $12,%ymm15,%ymm15,%ymm15 + vpalignr $4,%ymm6,%ymm6,%ymm6 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $12,%ymm14,%ymm14,%ymm14 + vpalignr $4,%ymm5,%ymm5,%ymm5 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $12,%ymm13,%ymm13,%ymm13 + vpalignr $4,%ymm4,%ymm4,%ymm4 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vmovdqa %ymm8,0+128(%rbp) + vmovdqa .Lrol16(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + addq 0+16(%r8),%r10 + adcq 8+16(%r8),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + addq %rax,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 32(%r8),%r8 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $20,%ymm7,%ymm8 + vpslld $32-20,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $20,%ymm6,%ymm8 + vpslld $32-20,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $20,%ymm5,%ymm8 + vpslld $32-20,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $20,%ymm4,%ymm8 + vpslld $32-20,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa .Lrol8(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $25,%ymm7,%ymm8 + vpslld $32-25,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $25,%ymm6,%ymm8 + vpslld $32-25,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $25,%ymm5,%ymm8 + vpslld $32-25,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $25,%ymm4,%ymm8 + vpslld $32-25,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa 0+128(%rbp),%ymm8 + vpalignr $12,%ymm7,%ymm7,%ymm7 + vpalignr $8,%ymm11,%ymm11,%ymm11 + vpalignr $4,%ymm15,%ymm15,%ymm15 + vpalignr $12,%ymm6,%ymm6,%ymm6 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $4,%ymm14,%ymm14,%ymm14 + vpalignr $12,%ymm5,%ymm5,%ymm5 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $4,%ymm13,%ymm13,%ymm13 + vpalignr $12,%ymm4,%ymm4,%ymm4 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $4,%ymm12,%ymm12,%ymm12 + + incq %rcx + cmpq $4,%rcx + jl .Lopen_avx2_tail_512_rounds_and_x2hash + cmpq $10,%rcx + jne .Lopen_avx2_tail_512_rounds_and_x1hash + movq %rbx,%rcx + subq $384,%rcx + andq $-16,%rcx +.Lopen_avx2_tail_512_hash: + testq %rcx,%rcx + je .Lopen_avx2_tail_512_done + addq 0+0(%r8),%r10 + adcq 8+0(%r8),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + addq %rax,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%r8),%r8 + subq $16,%rcx + jmp .Lopen_avx2_tail_512_hash +.Lopen_avx2_tail_512_done: + vpaddd .Lchacha20_consts(%rip),%ymm3,%ymm3 + vpaddd 0+64(%rbp),%ymm7,%ymm7 + vpaddd 0+96(%rbp),%ymm11,%ymm11 + vpaddd 0+256(%rbp),%ymm15,%ymm15 + vpaddd .Lchacha20_consts(%rip),%ymm2,%ymm2 + vpaddd 0+64(%rbp),%ymm6,%ymm6 + vpaddd 0+96(%rbp),%ymm10,%ymm10 + vpaddd 0+224(%rbp),%ymm14,%ymm14 + vpaddd .Lchacha20_consts(%rip),%ymm1,%ymm1 + vpaddd 0+64(%rbp),%ymm5,%ymm5 + vpaddd 0+96(%rbp),%ymm9,%ymm9 + vpaddd 0+192(%rbp),%ymm13,%ymm13 + vpaddd .Lchacha20_consts(%rip),%ymm0,%ymm0 + vpaddd 0+64(%rbp),%ymm4,%ymm4 + vpaddd 0+96(%rbp),%ymm8,%ymm8 + vpaddd 0+160(%rbp),%ymm12,%ymm12 + + vmovdqa %ymm0,0+128(%rbp) + vperm2i128 $0x02,%ymm3,%ymm7,%ymm0 + vperm2i128 $0x13,%ymm3,%ymm7,%ymm7 + vperm2i128 $0x02,%ymm11,%ymm15,%ymm3 + vperm2i128 $0x13,%ymm11,%ymm15,%ymm11 + vpxor 0+0(%rsi),%ymm0,%ymm0 + vpxor 32+0(%rsi),%ymm3,%ymm3 + vpxor 64+0(%rsi),%ymm7,%ymm7 + vpxor 96+0(%rsi),%ymm11,%ymm11 + vmovdqu %ymm0,0+0(%rdi) + vmovdqu %ymm3,32+0(%rdi) + vmovdqu %ymm7,64+0(%rdi) + vmovdqu %ymm11,96+0(%rdi) + + vmovdqa 0+128(%rbp),%ymm0 + vperm2i128 $0x02,%ymm2,%ymm6,%ymm3 + vperm2i128 $0x13,%ymm2,%ymm6,%ymm6 + vperm2i128 $0x02,%ymm10,%ymm14,%ymm2 + vperm2i128 $0x13,%ymm10,%ymm14,%ymm10 + vpxor 0+128(%rsi),%ymm3,%ymm3 + vpxor 32+128(%rsi),%ymm2,%ymm2 + vpxor 64+128(%rsi),%ymm6,%ymm6 + vpxor 96+128(%rsi),%ymm10,%ymm10 + vmovdqu %ymm3,0+128(%rdi) + vmovdqu %ymm2,32+128(%rdi) + vmovdqu %ymm6,64+128(%rdi) + vmovdqu %ymm10,96+128(%rdi) + vperm2i128 $0x02,%ymm1,%ymm5,%ymm3 + vperm2i128 $0x13,%ymm1,%ymm5,%ymm5 + vperm2i128 $0x02,%ymm9,%ymm13,%ymm1 + vperm2i128 $0x13,%ymm9,%ymm13,%ymm9 + vpxor 0+256(%rsi),%ymm3,%ymm3 + vpxor 32+256(%rsi),%ymm1,%ymm1 + vpxor 64+256(%rsi),%ymm5,%ymm5 + vpxor 96+256(%rsi),%ymm9,%ymm9 + vmovdqu %ymm3,0+256(%rdi) + vmovdqu %ymm1,32+256(%rdi) + vmovdqu %ymm5,64+256(%rdi) + vmovdqu %ymm9,96+256(%rdi) + vperm2i128 $0x13,%ymm0,%ymm4,%ymm3 + vperm2i128 $0x02,%ymm0,%ymm4,%ymm0 + vperm2i128 $0x02,%ymm8,%ymm12,%ymm4 + vperm2i128 $0x13,%ymm8,%ymm12,%ymm12 + vmovdqa %ymm3,%ymm8 + + leaq 384(%rsi),%rsi + leaq 384(%rdi),%rdi + subq $384,%rbx +.Lopen_avx2_tail_128_xor: + cmpq $32,%rbx + jb .Lopen_avx2_tail_32_xor + subq $32,%rbx + vpxor (%rsi),%ymm0,%ymm0 + vmovdqu %ymm0,(%rdi) + leaq 32(%rsi),%rsi + leaq 32(%rdi),%rdi + vmovdqa %ymm4,%ymm0 + vmovdqa %ymm8,%ymm4 + vmovdqa %ymm12,%ymm8 + jmp .Lopen_avx2_tail_128_xor +.Lopen_avx2_tail_32_xor: + cmpq $16,%rbx + vmovdqa %xmm0,%xmm1 + jb .Lopen_avx2_exit + subq $16,%rbx + + vpxor (%rsi),%xmm0,%xmm1 + vmovdqu %xmm1,(%rdi) + leaq 16(%rsi),%rsi + leaq 16(%rdi),%rdi + vperm2i128 $0x11,%ymm0,%ymm0,%ymm0 + vmovdqa %xmm0,%xmm1 +.Lopen_avx2_exit: + vzeroupper + jmp .Lopen_sse_tail_16 + +.Lopen_avx2_192: + vmovdqa %ymm0,%ymm1 + vmovdqa %ymm0,%ymm2 + vmovdqa %ymm4,%ymm5 + vmovdqa %ymm4,%ymm6 + vmovdqa %ymm8,%ymm9 + vmovdqa %ymm8,%ymm10 + vpaddd .Lavx2_inc(%rip),%ymm12,%ymm13 + vmovdqa %ymm12,%ymm11 + vmovdqa %ymm13,%ymm15 + movq $10,%r10 +.Lopen_avx2_192_rounds: + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $4,%ymm4,%ymm4,%ymm4 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb .Lrol16(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpsrld $20,%ymm5,%ymm3 + vpslld $12,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb .Lrol8(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpslld $7,%ymm5,%ymm3 + vpsrld $25,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpalignr $12,%ymm13,%ymm13,%ymm13 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $4,%ymm5,%ymm5,%ymm5 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $4,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm4,%ymm4,%ymm4 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb .Lrol16(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpsrld $20,%ymm5,%ymm3 + vpslld $12,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb .Lrol8(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpslld $7,%ymm5,%ymm3 + vpsrld $25,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpalignr $4,%ymm13,%ymm13,%ymm13 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $12,%ymm5,%ymm5,%ymm5 + + decq %r10 + jne .Lopen_avx2_192_rounds + vpaddd %ymm2,%ymm0,%ymm0 + vpaddd %ymm2,%ymm1,%ymm1 + vpaddd %ymm6,%ymm4,%ymm4 + vpaddd %ymm6,%ymm5,%ymm5 + vpaddd %ymm10,%ymm8,%ymm8 + vpaddd %ymm10,%ymm9,%ymm9 + vpaddd %ymm11,%ymm12,%ymm12 + vpaddd %ymm15,%ymm13,%ymm13 + vperm2i128 $0x02,%ymm0,%ymm4,%ymm3 + + vpand .Lclamp(%rip),%ymm3,%ymm3 + vmovdqa %ymm3,0+0(%rbp) + + vperm2i128 $0x13,%ymm0,%ymm4,%ymm0 + vperm2i128 $0x13,%ymm8,%ymm12,%ymm4 + vperm2i128 $0x02,%ymm1,%ymm5,%ymm8 + vperm2i128 $0x02,%ymm9,%ymm13,%ymm12 + vperm2i128 $0x13,%ymm1,%ymm5,%ymm1 + vperm2i128 $0x13,%ymm9,%ymm13,%ymm5 +.Lopen_avx2_short: + movq %r8,%r8 + call poly_hash_ad_internal +.Lopen_avx2_short_hash_and_xor_loop: + cmpq $32,%rbx + jb .Lopen_avx2_short_tail_32 + subq $32,%rbx + addq 0+0(%rsi),%r10 + adcq 8+0(%rsi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + addq 0+16(%rsi),%r10 + adcq 8+16(%rsi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + + vpxor (%rsi),%ymm0,%ymm0 + vmovdqu %ymm0,(%rdi) + leaq 32(%rsi),%rsi + leaq 32(%rdi),%rdi + + vmovdqa %ymm4,%ymm0 + vmovdqa %ymm8,%ymm4 + vmovdqa %ymm12,%ymm8 + vmovdqa %ymm1,%ymm12 + vmovdqa %ymm5,%ymm1 + vmovdqa %ymm9,%ymm5 + vmovdqa %ymm13,%ymm9 + vmovdqa %ymm2,%ymm13 + vmovdqa %ymm6,%ymm2 + jmp .Lopen_avx2_short_hash_and_xor_loop +.Lopen_avx2_short_tail_32: + cmpq $16,%rbx + vmovdqa %xmm0,%xmm1 + jb .Lopen_avx2_short_tail_32_exit + subq $16,%rbx + addq 0+0(%rsi),%r10 + adcq 8+0(%rsi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + vpxor (%rsi),%xmm0,%xmm3 + vmovdqu %xmm3,(%rdi) + leaq 16(%rsi),%rsi + leaq 16(%rdi),%rdi + vextracti128 $1,%ymm0,%xmm1 +.Lopen_avx2_short_tail_32_exit: + vzeroupper + jmp .Lopen_sse_tail_16 + +.Lopen_avx2_320: + vmovdqa %ymm0,%ymm1 + vmovdqa %ymm0,%ymm2 + vmovdqa %ymm4,%ymm5 + vmovdqa %ymm4,%ymm6 + vmovdqa %ymm8,%ymm9 + vmovdqa %ymm8,%ymm10 + vpaddd .Lavx2_inc(%rip),%ymm12,%ymm13 + vpaddd .Lavx2_inc(%rip),%ymm13,%ymm14 + vmovdqa %ymm4,%ymm7 + vmovdqa %ymm8,%ymm11 + vmovdqa %ymm12,0+160(%rbp) + vmovdqa %ymm13,0+192(%rbp) + vmovdqa %ymm14,0+224(%rbp) + movq $10,%r10 +.Lopen_avx2_320_rounds: + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $4,%ymm4,%ymm4,%ymm4 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb .Lrol16(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpsrld $20,%ymm5,%ymm3 + vpslld $12,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb .Lrol8(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpslld $7,%ymm5,%ymm3 + vpsrld $25,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpalignr $12,%ymm13,%ymm13,%ymm13 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $4,%ymm5,%ymm5,%ymm5 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb .Lrol16(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpsrld $20,%ymm6,%ymm3 + vpslld $12,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb .Lrol8(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpslld $7,%ymm6,%ymm3 + vpsrld $25,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpalignr $12,%ymm14,%ymm14,%ymm14 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $4,%ymm6,%ymm6,%ymm6 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $4,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm4,%ymm4,%ymm4 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb .Lrol16(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpsrld $20,%ymm5,%ymm3 + vpslld $12,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb .Lrol8(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpslld $7,%ymm5,%ymm3 + vpsrld $25,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpalignr $4,%ymm13,%ymm13,%ymm13 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $12,%ymm5,%ymm5,%ymm5 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb .Lrol16(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpsrld $20,%ymm6,%ymm3 + vpslld $12,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb .Lrol8(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpslld $7,%ymm6,%ymm3 + vpsrld $25,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpalignr $4,%ymm14,%ymm14,%ymm14 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $12,%ymm6,%ymm6,%ymm6 + + decq %r10 + jne .Lopen_avx2_320_rounds + vpaddd .Lchacha20_consts(%rip),%ymm0,%ymm0 + vpaddd .Lchacha20_consts(%rip),%ymm1,%ymm1 + vpaddd .Lchacha20_consts(%rip),%ymm2,%ymm2 + vpaddd %ymm7,%ymm4,%ymm4 + vpaddd %ymm7,%ymm5,%ymm5 + vpaddd %ymm7,%ymm6,%ymm6 + vpaddd %ymm11,%ymm8,%ymm8 + vpaddd %ymm11,%ymm9,%ymm9 + vpaddd %ymm11,%ymm10,%ymm10 + vpaddd 0+160(%rbp),%ymm12,%ymm12 + vpaddd 0+192(%rbp),%ymm13,%ymm13 + vpaddd 0+224(%rbp),%ymm14,%ymm14 + vperm2i128 $0x02,%ymm0,%ymm4,%ymm3 + + vpand .Lclamp(%rip),%ymm3,%ymm3 + vmovdqa %ymm3,0+0(%rbp) + + vperm2i128 $0x13,%ymm0,%ymm4,%ymm0 + vperm2i128 $0x13,%ymm8,%ymm12,%ymm4 + vperm2i128 $0x02,%ymm1,%ymm5,%ymm8 + vperm2i128 $0x02,%ymm9,%ymm13,%ymm12 + vperm2i128 $0x13,%ymm1,%ymm5,%ymm1 + vperm2i128 $0x13,%ymm9,%ymm13,%ymm5 + vperm2i128 $0x02,%ymm2,%ymm6,%ymm9 + vperm2i128 $0x02,%ymm10,%ymm14,%ymm13 + vperm2i128 $0x13,%ymm2,%ymm6,%ymm2 + vperm2i128 $0x13,%ymm10,%ymm14,%ymm6 + jmp .Lopen_avx2_short +.size chacha20_poly1305_open_avx2, .-chacha20_poly1305_open_avx2 +.cfi_endproc + + +.globl chacha20_poly1305_seal_avx2 +.hidden chacha20_poly1305_seal_avx2 +.type chacha20_poly1305_seal_avx2,@function +.align 64 +chacha20_poly1305_seal_avx2: +.cfi_startproc +_CET_ENDBR + pushq %rbp +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbp,-16 + pushq %rbx +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbx,-24 + pushq %r12 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r12,-32 + pushq %r13 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r13,-40 + pushq %r14 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r14,-48 + pushq %r15 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r15,-56 + + + pushq %r9 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r9,-64 + subq $288 + 0 + 32,%rsp +.cfi_adjust_cfa_offset 288 + 32 + leaq 32(%rsp),%rbp + andq $-32,%rbp + + movq 56(%r9),%rbx + addq %rdx,%rbx + movq %r8,0+0+32(%rbp) + movq %rbx,8+0+32(%rbp) + movq %rdx,%rbx + + vzeroupper + vmovdqa .Lchacha20_consts(%rip),%ymm0 + vbroadcasti128 0(%r9),%ymm4 + vbroadcasti128 16(%r9),%ymm8 + vbroadcasti128 32(%r9),%ymm12 + vpaddd .Lavx2_init(%rip),%ymm12,%ymm12 + cmpq $192,%rbx + jbe .Lseal_avx2_192 + cmpq $320,%rbx + jbe .Lseal_avx2_320 + vmovdqa %ymm0,%ymm1 + vmovdqa %ymm0,%ymm2 + vmovdqa %ymm0,%ymm3 + vmovdqa %ymm4,%ymm5 + vmovdqa %ymm4,%ymm6 + vmovdqa %ymm4,%ymm7 + vmovdqa %ymm4,0+64(%rbp) + vmovdqa %ymm8,%ymm9 + vmovdqa %ymm8,%ymm10 + vmovdqa %ymm8,%ymm11 + vmovdqa %ymm8,0+96(%rbp) + vmovdqa %ymm12,%ymm15 + vpaddd .Lavx2_inc(%rip),%ymm15,%ymm14 + vpaddd .Lavx2_inc(%rip),%ymm14,%ymm13 + vpaddd .Lavx2_inc(%rip),%ymm13,%ymm12 + vmovdqa %ymm12,0+160(%rbp) + vmovdqa %ymm13,0+192(%rbp) + vmovdqa %ymm14,0+224(%rbp) + vmovdqa %ymm15,0+256(%rbp) + movq $10,%r10 +.Lseal_avx2_init_rounds: + vmovdqa %ymm8,0+128(%rbp) + vmovdqa .Lrol16(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $20,%ymm7,%ymm8 + vpslld $32-20,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $20,%ymm6,%ymm8 + vpslld $32-20,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $20,%ymm5,%ymm8 + vpslld $32-20,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $20,%ymm4,%ymm8 + vpslld $32-20,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa .Lrol8(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $25,%ymm7,%ymm8 + vpslld $32-25,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $25,%ymm6,%ymm8 + vpslld $32-25,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $25,%ymm5,%ymm8 + vpslld $32-25,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $25,%ymm4,%ymm8 + vpslld $32-25,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa 0+128(%rbp),%ymm8 + vpalignr $4,%ymm7,%ymm7,%ymm7 + vpalignr $8,%ymm11,%ymm11,%ymm11 + vpalignr $12,%ymm15,%ymm15,%ymm15 + vpalignr $4,%ymm6,%ymm6,%ymm6 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $12,%ymm14,%ymm14,%ymm14 + vpalignr $4,%ymm5,%ymm5,%ymm5 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $12,%ymm13,%ymm13,%ymm13 + vpalignr $4,%ymm4,%ymm4,%ymm4 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vmovdqa %ymm8,0+128(%rbp) + vmovdqa .Lrol16(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $20,%ymm7,%ymm8 + vpslld $32-20,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $20,%ymm6,%ymm8 + vpslld $32-20,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $20,%ymm5,%ymm8 + vpslld $32-20,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $20,%ymm4,%ymm8 + vpslld $32-20,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa .Lrol8(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $25,%ymm7,%ymm8 + vpslld $32-25,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $25,%ymm6,%ymm8 + vpslld $32-25,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $25,%ymm5,%ymm8 + vpslld $32-25,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $25,%ymm4,%ymm8 + vpslld $32-25,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa 0+128(%rbp),%ymm8 + vpalignr $12,%ymm7,%ymm7,%ymm7 + vpalignr $8,%ymm11,%ymm11,%ymm11 + vpalignr $4,%ymm15,%ymm15,%ymm15 + vpalignr $12,%ymm6,%ymm6,%ymm6 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $4,%ymm14,%ymm14,%ymm14 + vpalignr $12,%ymm5,%ymm5,%ymm5 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $4,%ymm13,%ymm13,%ymm13 + vpalignr $12,%ymm4,%ymm4,%ymm4 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $4,%ymm12,%ymm12,%ymm12 + + decq %r10 + jnz .Lseal_avx2_init_rounds + vpaddd .Lchacha20_consts(%rip),%ymm3,%ymm3 + vpaddd 0+64(%rbp),%ymm7,%ymm7 + vpaddd 0+96(%rbp),%ymm11,%ymm11 + vpaddd 0+256(%rbp),%ymm15,%ymm15 + vpaddd .Lchacha20_consts(%rip),%ymm2,%ymm2 + vpaddd 0+64(%rbp),%ymm6,%ymm6 + vpaddd 0+96(%rbp),%ymm10,%ymm10 + vpaddd 0+224(%rbp),%ymm14,%ymm14 + vpaddd .Lchacha20_consts(%rip),%ymm1,%ymm1 + vpaddd 0+64(%rbp),%ymm5,%ymm5 + vpaddd 0+96(%rbp),%ymm9,%ymm9 + vpaddd 0+192(%rbp),%ymm13,%ymm13 + vpaddd .Lchacha20_consts(%rip),%ymm0,%ymm0 + vpaddd 0+64(%rbp),%ymm4,%ymm4 + vpaddd 0+96(%rbp),%ymm8,%ymm8 + vpaddd 0+160(%rbp),%ymm12,%ymm12 + + vperm2i128 $0x13,%ymm11,%ymm15,%ymm11 + vperm2i128 $0x02,%ymm3,%ymm7,%ymm15 + vperm2i128 $0x13,%ymm3,%ymm7,%ymm3 + vpand .Lclamp(%rip),%ymm15,%ymm15 + vmovdqa %ymm15,0+0(%rbp) + movq %r8,%r8 + call poly_hash_ad_internal + + vpxor 0(%rsi),%ymm3,%ymm3 + vpxor 32(%rsi),%ymm11,%ymm11 + vmovdqu %ymm3,0(%rdi) + vmovdqu %ymm11,32(%rdi) + vperm2i128 $0x02,%ymm2,%ymm6,%ymm15 + vperm2i128 $0x13,%ymm2,%ymm6,%ymm6 + vperm2i128 $0x02,%ymm10,%ymm14,%ymm2 + vperm2i128 $0x13,%ymm10,%ymm14,%ymm10 + vpxor 0+64(%rsi),%ymm15,%ymm15 + vpxor 32+64(%rsi),%ymm2,%ymm2 + vpxor 64+64(%rsi),%ymm6,%ymm6 + vpxor 96+64(%rsi),%ymm10,%ymm10 + vmovdqu %ymm15,0+64(%rdi) + vmovdqu %ymm2,32+64(%rdi) + vmovdqu %ymm6,64+64(%rdi) + vmovdqu %ymm10,96+64(%rdi) + vperm2i128 $0x02,%ymm1,%ymm5,%ymm15 + vperm2i128 $0x13,%ymm1,%ymm5,%ymm5 + vperm2i128 $0x02,%ymm9,%ymm13,%ymm1 + vperm2i128 $0x13,%ymm9,%ymm13,%ymm9 + vpxor 0+192(%rsi),%ymm15,%ymm15 + vpxor 32+192(%rsi),%ymm1,%ymm1 + vpxor 64+192(%rsi),%ymm5,%ymm5 + vpxor 96+192(%rsi),%ymm9,%ymm9 + vmovdqu %ymm15,0+192(%rdi) + vmovdqu %ymm1,32+192(%rdi) + vmovdqu %ymm5,64+192(%rdi) + vmovdqu %ymm9,96+192(%rdi) + vperm2i128 $0x13,%ymm0,%ymm4,%ymm15 + vperm2i128 $0x02,%ymm0,%ymm4,%ymm0 + vperm2i128 $0x02,%ymm8,%ymm12,%ymm4 + vperm2i128 $0x13,%ymm8,%ymm12,%ymm12 + vmovdqa %ymm15,%ymm8 + + leaq 320(%rsi),%rsi + subq $320,%rbx + movq $320,%rcx + cmpq $128,%rbx + jbe .Lseal_avx2_short_hash_remainder + vpxor 0(%rsi),%ymm0,%ymm0 + vpxor 32(%rsi),%ymm4,%ymm4 + vpxor 64(%rsi),%ymm8,%ymm8 + vpxor 96(%rsi),%ymm12,%ymm12 + vmovdqu %ymm0,320(%rdi) + vmovdqu %ymm4,352(%rdi) + vmovdqu %ymm8,384(%rdi) + vmovdqu %ymm12,416(%rdi) + leaq 128(%rsi),%rsi + subq $128,%rbx + movq $8,%rcx + movq $2,%r8 + cmpq $128,%rbx + jbe .Lseal_avx2_tail_128 + cmpq $256,%rbx + jbe .Lseal_avx2_tail_256 + cmpq $384,%rbx + jbe .Lseal_avx2_tail_384 + cmpq $512,%rbx + jbe .Lseal_avx2_tail_512 + vmovdqa .Lchacha20_consts(%rip),%ymm0 + vmovdqa 0+64(%rbp),%ymm4 + vmovdqa 0+96(%rbp),%ymm8 + vmovdqa %ymm0,%ymm1 + vmovdqa %ymm4,%ymm5 + vmovdqa %ymm8,%ymm9 + vmovdqa %ymm0,%ymm2 + vmovdqa %ymm4,%ymm6 + vmovdqa %ymm8,%ymm10 + vmovdqa %ymm0,%ymm3 + vmovdqa %ymm4,%ymm7 + vmovdqa %ymm8,%ymm11 + vmovdqa .Lavx2_inc(%rip),%ymm12 + vpaddd 0+160(%rbp),%ymm12,%ymm15 + vpaddd %ymm15,%ymm12,%ymm14 + vpaddd %ymm14,%ymm12,%ymm13 + vpaddd %ymm13,%ymm12,%ymm12 + vmovdqa %ymm15,0+256(%rbp) + vmovdqa %ymm14,0+224(%rbp) + vmovdqa %ymm13,0+192(%rbp) + vmovdqa %ymm12,0+160(%rbp) + vmovdqa %ymm8,0+128(%rbp) + vmovdqa .Lrol16(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $20,%ymm7,%ymm8 + vpslld $32-20,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $20,%ymm6,%ymm8 + vpslld $32-20,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $20,%ymm5,%ymm8 + vpslld $32-20,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $20,%ymm4,%ymm8 + vpslld $32-20,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa .Lrol8(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $25,%ymm7,%ymm8 + vpslld $32-25,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $25,%ymm6,%ymm8 + vpslld $32-25,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $25,%ymm5,%ymm8 + vpslld $32-25,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $25,%ymm4,%ymm8 + vpslld $32-25,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa 0+128(%rbp),%ymm8 + vpalignr $4,%ymm7,%ymm7,%ymm7 + vpalignr $8,%ymm11,%ymm11,%ymm11 + vpalignr $12,%ymm15,%ymm15,%ymm15 + vpalignr $4,%ymm6,%ymm6,%ymm6 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $12,%ymm14,%ymm14,%ymm14 + vpalignr $4,%ymm5,%ymm5,%ymm5 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $12,%ymm13,%ymm13,%ymm13 + vpalignr $4,%ymm4,%ymm4,%ymm4 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vmovdqa %ymm8,0+128(%rbp) + vmovdqa .Lrol16(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $20,%ymm7,%ymm8 + vpslld $32-20,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $20,%ymm6,%ymm8 + vpslld $32-20,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $20,%ymm5,%ymm8 + vpslld $32-20,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $20,%ymm4,%ymm8 + vpslld $32-20,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa .Lrol8(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $25,%ymm7,%ymm8 + vpslld $32-25,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $25,%ymm6,%ymm8 + vpslld $32-25,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $25,%ymm5,%ymm8 + vpslld $32-25,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $25,%ymm4,%ymm8 + vpslld $32-25,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa 0+128(%rbp),%ymm8 + vpalignr $12,%ymm7,%ymm7,%ymm7 + vpalignr $8,%ymm11,%ymm11,%ymm11 + vpalignr $4,%ymm15,%ymm15,%ymm15 + vpalignr $12,%ymm6,%ymm6,%ymm6 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $4,%ymm14,%ymm14,%ymm14 + vpalignr $12,%ymm5,%ymm5,%ymm5 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $4,%ymm13,%ymm13,%ymm13 + vpalignr $12,%ymm4,%ymm4,%ymm4 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $4,%ymm12,%ymm12,%ymm12 + vmovdqa %ymm8,0+128(%rbp) + vmovdqa .Lrol16(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $20,%ymm7,%ymm8 + vpslld $32-20,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $20,%ymm6,%ymm8 + vpslld $32-20,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $20,%ymm5,%ymm8 + vpslld $32-20,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $20,%ymm4,%ymm8 + vpslld $32-20,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa .Lrol8(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + + subq $16,%rdi + movq $9,%rcx + jmp .Lseal_avx2_main_loop_rounds_entry +.align 32 +.Lseal_avx2_main_loop: + vmovdqa .Lchacha20_consts(%rip),%ymm0 + vmovdqa 0+64(%rbp),%ymm4 + vmovdqa 0+96(%rbp),%ymm8 + vmovdqa %ymm0,%ymm1 + vmovdqa %ymm4,%ymm5 + vmovdqa %ymm8,%ymm9 + vmovdqa %ymm0,%ymm2 + vmovdqa %ymm4,%ymm6 + vmovdqa %ymm8,%ymm10 + vmovdqa %ymm0,%ymm3 + vmovdqa %ymm4,%ymm7 + vmovdqa %ymm8,%ymm11 + vmovdqa .Lavx2_inc(%rip),%ymm12 + vpaddd 0+160(%rbp),%ymm12,%ymm15 + vpaddd %ymm15,%ymm12,%ymm14 + vpaddd %ymm14,%ymm12,%ymm13 + vpaddd %ymm13,%ymm12,%ymm12 + vmovdqa %ymm15,0+256(%rbp) + vmovdqa %ymm14,0+224(%rbp) + vmovdqa %ymm13,0+192(%rbp) + vmovdqa %ymm12,0+160(%rbp) + + movq $10,%rcx +.align 32 +.Lseal_avx2_main_loop_rounds: + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + vmovdqa %ymm8,0+128(%rbp) + vmovdqa .Lrol16(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $20,%ymm7,%ymm8 + vpslld $32-20,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $20,%ymm6,%ymm8 + vpslld $32-20,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $20,%ymm5,%ymm8 + vpslld $32-20,%ymm5,%ymm5 + addq %rax,%r15 + adcq %rdx,%r9 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $20,%ymm4,%ymm8 + vpslld $32-20,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa .Lrol8(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + +.Lseal_avx2_main_loop_rounds_entry: + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + addq 0+16(%rdi),%r10 + adcq 8+16(%rdi),%r11 + adcq $1,%r12 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $25,%ymm7,%ymm8 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + vpslld $32-25,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $25,%ymm6,%ymm8 + vpslld $32-25,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $25,%ymm5,%ymm8 + vpslld $32-25,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $25,%ymm4,%ymm8 + vpslld $32-25,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa 0+128(%rbp),%ymm8 + vpalignr $4,%ymm7,%ymm7,%ymm7 + vpalignr $8,%ymm11,%ymm11,%ymm11 + vpalignr $12,%ymm15,%ymm15,%ymm15 + vpalignr $4,%ymm6,%ymm6,%ymm6 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $12,%ymm14,%ymm14,%ymm14 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + vpalignr $4,%ymm5,%ymm5,%ymm5 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $12,%ymm13,%ymm13,%ymm13 + vpalignr $4,%ymm4,%ymm4,%ymm4 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vmovdqa %ymm8,0+128(%rbp) + vmovdqa .Lrol16(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + addq %rax,%r15 + adcq %rdx,%r9 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $20,%ymm7,%ymm8 + vpslld $32-20,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $20,%ymm6,%ymm8 + vpslld $32-20,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + addq 0+32(%rdi),%r10 + adcq 8+32(%rdi),%r11 + adcq $1,%r12 + + leaq 48(%rdi),%rdi + vpsrld $20,%ymm5,%ymm8 + vpslld $32-20,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $20,%ymm4,%ymm8 + vpslld $32-20,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa .Lrol8(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $25,%ymm7,%ymm8 + vpslld $32-25,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $25,%ymm6,%ymm8 + vpslld $32-25,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + addq %rax,%r15 + adcq %rdx,%r9 + vpsrld $25,%ymm5,%ymm8 + vpslld $32-25,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $25,%ymm4,%ymm8 + vpslld $32-25,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa 0+128(%rbp),%ymm8 + vpalignr $12,%ymm7,%ymm7,%ymm7 + vpalignr $8,%ymm11,%ymm11,%ymm11 + vpalignr $4,%ymm15,%ymm15,%ymm15 + vpalignr $12,%ymm6,%ymm6,%ymm6 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $4,%ymm14,%ymm14,%ymm14 + vpalignr $12,%ymm5,%ymm5,%ymm5 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $4,%ymm13,%ymm13,%ymm13 + vpalignr $12,%ymm4,%ymm4,%ymm4 + vpalignr $8,%ymm8,%ymm8,%ymm8 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + vpalignr $4,%ymm12,%ymm12,%ymm12 + + decq %rcx + jne .Lseal_avx2_main_loop_rounds + vpaddd .Lchacha20_consts(%rip),%ymm3,%ymm3 + vpaddd 0+64(%rbp),%ymm7,%ymm7 + vpaddd 0+96(%rbp),%ymm11,%ymm11 + vpaddd 0+256(%rbp),%ymm15,%ymm15 + vpaddd .Lchacha20_consts(%rip),%ymm2,%ymm2 + vpaddd 0+64(%rbp),%ymm6,%ymm6 + vpaddd 0+96(%rbp),%ymm10,%ymm10 + vpaddd 0+224(%rbp),%ymm14,%ymm14 + vpaddd .Lchacha20_consts(%rip),%ymm1,%ymm1 + vpaddd 0+64(%rbp),%ymm5,%ymm5 + vpaddd 0+96(%rbp),%ymm9,%ymm9 + vpaddd 0+192(%rbp),%ymm13,%ymm13 + vpaddd .Lchacha20_consts(%rip),%ymm0,%ymm0 + vpaddd 0+64(%rbp),%ymm4,%ymm4 + vpaddd 0+96(%rbp),%ymm8,%ymm8 + vpaddd 0+160(%rbp),%ymm12,%ymm12 + + vmovdqa %ymm0,0+128(%rbp) + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + addq %rax,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + addq 0+16(%rdi),%r10 + adcq 8+16(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + addq %rax,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 32(%rdi),%rdi + vperm2i128 $0x02,%ymm3,%ymm7,%ymm0 + vperm2i128 $0x13,%ymm3,%ymm7,%ymm7 + vperm2i128 $0x02,%ymm11,%ymm15,%ymm3 + vperm2i128 $0x13,%ymm11,%ymm15,%ymm11 + vpxor 0+0(%rsi),%ymm0,%ymm0 + vpxor 32+0(%rsi),%ymm3,%ymm3 + vpxor 64+0(%rsi),%ymm7,%ymm7 + vpxor 96+0(%rsi),%ymm11,%ymm11 + vmovdqu %ymm0,0+0(%rdi) + vmovdqu %ymm3,32+0(%rdi) + vmovdqu %ymm7,64+0(%rdi) + vmovdqu %ymm11,96+0(%rdi) + + vmovdqa 0+128(%rbp),%ymm0 + vperm2i128 $0x02,%ymm2,%ymm6,%ymm3 + vperm2i128 $0x13,%ymm2,%ymm6,%ymm6 + vperm2i128 $0x02,%ymm10,%ymm14,%ymm2 + vperm2i128 $0x13,%ymm10,%ymm14,%ymm10 + vpxor 0+128(%rsi),%ymm3,%ymm3 + vpxor 32+128(%rsi),%ymm2,%ymm2 + vpxor 64+128(%rsi),%ymm6,%ymm6 + vpxor 96+128(%rsi),%ymm10,%ymm10 + vmovdqu %ymm3,0+128(%rdi) + vmovdqu %ymm2,32+128(%rdi) + vmovdqu %ymm6,64+128(%rdi) + vmovdqu %ymm10,96+128(%rdi) + vperm2i128 $0x02,%ymm1,%ymm5,%ymm3 + vperm2i128 $0x13,%ymm1,%ymm5,%ymm5 + vperm2i128 $0x02,%ymm9,%ymm13,%ymm1 + vperm2i128 $0x13,%ymm9,%ymm13,%ymm9 + vpxor 0+256(%rsi),%ymm3,%ymm3 + vpxor 32+256(%rsi),%ymm1,%ymm1 + vpxor 64+256(%rsi),%ymm5,%ymm5 + vpxor 96+256(%rsi),%ymm9,%ymm9 + vmovdqu %ymm3,0+256(%rdi) + vmovdqu %ymm1,32+256(%rdi) + vmovdqu %ymm5,64+256(%rdi) + vmovdqu %ymm9,96+256(%rdi) + vperm2i128 $0x02,%ymm0,%ymm4,%ymm3 + vperm2i128 $0x13,%ymm0,%ymm4,%ymm4 + vperm2i128 $0x02,%ymm8,%ymm12,%ymm0 + vperm2i128 $0x13,%ymm8,%ymm12,%ymm8 + vpxor 0+384(%rsi),%ymm3,%ymm3 + vpxor 32+384(%rsi),%ymm0,%ymm0 + vpxor 64+384(%rsi),%ymm4,%ymm4 + vpxor 96+384(%rsi),%ymm8,%ymm8 + vmovdqu %ymm3,0+384(%rdi) + vmovdqu %ymm0,32+384(%rdi) + vmovdqu %ymm4,64+384(%rdi) + vmovdqu %ymm8,96+384(%rdi) + + leaq 512(%rsi),%rsi + subq $512,%rbx + cmpq $512,%rbx + jg .Lseal_avx2_main_loop + + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + addq %rax,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + addq 0+16(%rdi),%r10 + adcq 8+16(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + addq %rax,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 32(%rdi),%rdi + movq $10,%rcx + xorq %r8,%r8 + + cmpq $384,%rbx + ja .Lseal_avx2_tail_512 + cmpq $256,%rbx + ja .Lseal_avx2_tail_384 + cmpq $128,%rbx + ja .Lseal_avx2_tail_256 + +.Lseal_avx2_tail_128: + vmovdqa .Lchacha20_consts(%rip),%ymm0 + vmovdqa 0+64(%rbp),%ymm4 + vmovdqa 0+96(%rbp),%ymm8 + vmovdqa .Lavx2_inc(%rip),%ymm12 + vpaddd 0+160(%rbp),%ymm12,%ymm12 + vmovdqa %ymm12,0+160(%rbp) + +.Lseal_avx2_tail_128_rounds_and_3xhash: + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + addq %rax,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%rdi),%rdi +.Lseal_avx2_tail_128_rounds_and_2xhash: + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $4,%ymm4,%ymm4,%ymm4 + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + addq %rax,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $4,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm4,%ymm4,%ymm4 + addq 0+16(%rdi),%r10 + adcq 8+16(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + addq %rax,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 32(%rdi),%rdi + decq %rcx + jg .Lseal_avx2_tail_128_rounds_and_3xhash + decq %r8 + jge .Lseal_avx2_tail_128_rounds_and_2xhash + vpaddd .Lchacha20_consts(%rip),%ymm0,%ymm0 + vpaddd 0+64(%rbp),%ymm4,%ymm4 + vpaddd 0+96(%rbp),%ymm8,%ymm8 + vpaddd 0+160(%rbp),%ymm12,%ymm12 + vperm2i128 $0x13,%ymm0,%ymm4,%ymm3 + vperm2i128 $0x02,%ymm0,%ymm4,%ymm0 + vperm2i128 $0x02,%ymm8,%ymm12,%ymm4 + vperm2i128 $0x13,%ymm8,%ymm12,%ymm12 + vmovdqa %ymm3,%ymm8 + + jmp .Lseal_avx2_short_loop + +.Lseal_avx2_tail_256: + vmovdqa .Lchacha20_consts(%rip),%ymm0 + vmovdqa 0+64(%rbp),%ymm4 + vmovdqa 0+96(%rbp),%ymm8 + vmovdqa %ymm0,%ymm1 + vmovdqa %ymm4,%ymm5 + vmovdqa %ymm8,%ymm9 + vmovdqa .Lavx2_inc(%rip),%ymm12 + vpaddd 0+160(%rbp),%ymm12,%ymm13 + vpaddd %ymm13,%ymm12,%ymm12 + vmovdqa %ymm12,0+160(%rbp) + vmovdqa %ymm13,0+192(%rbp) + +.Lseal_avx2_tail_256_rounds_and_3xhash: + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%rdi),%rdi +.Lseal_avx2_tail_256_rounds_and_2xhash: + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $4,%ymm4,%ymm4,%ymm4 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb .Lrol16(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpsrld $20,%ymm5,%ymm3 + vpslld $12,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb .Lrol8(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpslld $7,%ymm5,%ymm3 + vpsrld $25,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpalignr $12,%ymm13,%ymm13,%ymm13 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $4,%ymm5,%ymm5,%ymm5 + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $4,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm4,%ymm4,%ymm4 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb .Lrol16(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpsrld $20,%ymm5,%ymm3 + vpslld $12,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb .Lrol8(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpslld $7,%ymm5,%ymm3 + vpsrld $25,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpalignr $4,%ymm13,%ymm13,%ymm13 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $12,%ymm5,%ymm5,%ymm5 + addq 0+16(%rdi),%r10 + adcq 8+16(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 32(%rdi),%rdi + decq %rcx + jg .Lseal_avx2_tail_256_rounds_and_3xhash + decq %r8 + jge .Lseal_avx2_tail_256_rounds_and_2xhash + vpaddd .Lchacha20_consts(%rip),%ymm1,%ymm1 + vpaddd 0+64(%rbp),%ymm5,%ymm5 + vpaddd 0+96(%rbp),%ymm9,%ymm9 + vpaddd 0+192(%rbp),%ymm13,%ymm13 + vpaddd .Lchacha20_consts(%rip),%ymm0,%ymm0 + vpaddd 0+64(%rbp),%ymm4,%ymm4 + vpaddd 0+96(%rbp),%ymm8,%ymm8 + vpaddd 0+160(%rbp),%ymm12,%ymm12 + vperm2i128 $0x02,%ymm1,%ymm5,%ymm3 + vperm2i128 $0x13,%ymm1,%ymm5,%ymm5 + vperm2i128 $0x02,%ymm9,%ymm13,%ymm1 + vperm2i128 $0x13,%ymm9,%ymm13,%ymm9 + vpxor 0+0(%rsi),%ymm3,%ymm3 + vpxor 32+0(%rsi),%ymm1,%ymm1 + vpxor 64+0(%rsi),%ymm5,%ymm5 + vpxor 96+0(%rsi),%ymm9,%ymm9 + vmovdqu %ymm3,0+0(%rdi) + vmovdqu %ymm1,32+0(%rdi) + vmovdqu %ymm5,64+0(%rdi) + vmovdqu %ymm9,96+0(%rdi) + vperm2i128 $0x13,%ymm0,%ymm4,%ymm3 + vperm2i128 $0x02,%ymm0,%ymm4,%ymm0 + vperm2i128 $0x02,%ymm8,%ymm12,%ymm4 + vperm2i128 $0x13,%ymm8,%ymm12,%ymm12 + vmovdqa %ymm3,%ymm8 + + movq $128,%rcx + leaq 128(%rsi),%rsi + subq $128,%rbx + jmp .Lseal_avx2_short_hash_remainder + +.Lseal_avx2_tail_384: + vmovdqa .Lchacha20_consts(%rip),%ymm0 + vmovdqa 0+64(%rbp),%ymm4 + vmovdqa 0+96(%rbp),%ymm8 + vmovdqa %ymm0,%ymm1 + vmovdqa %ymm4,%ymm5 + vmovdqa %ymm8,%ymm9 + vmovdqa %ymm0,%ymm2 + vmovdqa %ymm4,%ymm6 + vmovdqa %ymm8,%ymm10 + vmovdqa .Lavx2_inc(%rip),%ymm12 + vpaddd 0+160(%rbp),%ymm12,%ymm14 + vpaddd %ymm14,%ymm12,%ymm13 + vpaddd %ymm13,%ymm12,%ymm12 + vmovdqa %ymm12,0+160(%rbp) + vmovdqa %ymm13,0+192(%rbp) + vmovdqa %ymm14,0+224(%rbp) + +.Lseal_avx2_tail_384_rounds_and_3xhash: + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%rdi),%rdi +.Lseal_avx2_tail_384_rounds_and_2xhash: + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $4,%ymm4,%ymm4,%ymm4 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb .Lrol16(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpsrld $20,%ymm5,%ymm3 + vpslld $12,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb .Lrol8(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpslld $7,%ymm5,%ymm3 + vpsrld $25,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpalignr $12,%ymm13,%ymm13,%ymm13 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $4,%ymm5,%ymm5,%ymm5 + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb .Lrol16(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpsrld $20,%ymm6,%ymm3 + vpslld $12,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb .Lrol8(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpslld $7,%ymm6,%ymm3 + vpsrld $25,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpalignr $12,%ymm14,%ymm14,%ymm14 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $4,%ymm6,%ymm6,%ymm6 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $4,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm4,%ymm4,%ymm4 + addq 0+16(%rdi),%r10 + adcq 8+16(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb .Lrol16(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpsrld $20,%ymm5,%ymm3 + vpslld $12,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb .Lrol8(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpslld $7,%ymm5,%ymm3 + vpsrld $25,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpalignr $4,%ymm13,%ymm13,%ymm13 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $12,%ymm5,%ymm5,%ymm5 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb .Lrol16(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpsrld $20,%ymm6,%ymm3 + vpslld $12,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb .Lrol8(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpslld $7,%ymm6,%ymm3 + vpsrld $25,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpalignr $4,%ymm14,%ymm14,%ymm14 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $12,%ymm6,%ymm6,%ymm6 + + leaq 32(%rdi),%rdi + decq %rcx + jg .Lseal_avx2_tail_384_rounds_and_3xhash + decq %r8 + jge .Lseal_avx2_tail_384_rounds_and_2xhash + vpaddd .Lchacha20_consts(%rip),%ymm2,%ymm2 + vpaddd 0+64(%rbp),%ymm6,%ymm6 + vpaddd 0+96(%rbp),%ymm10,%ymm10 + vpaddd 0+224(%rbp),%ymm14,%ymm14 + vpaddd .Lchacha20_consts(%rip),%ymm1,%ymm1 + vpaddd 0+64(%rbp),%ymm5,%ymm5 + vpaddd 0+96(%rbp),%ymm9,%ymm9 + vpaddd 0+192(%rbp),%ymm13,%ymm13 + vpaddd .Lchacha20_consts(%rip),%ymm0,%ymm0 + vpaddd 0+64(%rbp),%ymm4,%ymm4 + vpaddd 0+96(%rbp),%ymm8,%ymm8 + vpaddd 0+160(%rbp),%ymm12,%ymm12 + vperm2i128 $0x02,%ymm2,%ymm6,%ymm3 + vperm2i128 $0x13,%ymm2,%ymm6,%ymm6 + vperm2i128 $0x02,%ymm10,%ymm14,%ymm2 + vperm2i128 $0x13,%ymm10,%ymm14,%ymm10 + vpxor 0+0(%rsi),%ymm3,%ymm3 + vpxor 32+0(%rsi),%ymm2,%ymm2 + vpxor 64+0(%rsi),%ymm6,%ymm6 + vpxor 96+0(%rsi),%ymm10,%ymm10 + vmovdqu %ymm3,0+0(%rdi) + vmovdqu %ymm2,32+0(%rdi) + vmovdqu %ymm6,64+0(%rdi) + vmovdqu %ymm10,96+0(%rdi) + vperm2i128 $0x02,%ymm1,%ymm5,%ymm3 + vperm2i128 $0x13,%ymm1,%ymm5,%ymm5 + vperm2i128 $0x02,%ymm9,%ymm13,%ymm1 + vperm2i128 $0x13,%ymm9,%ymm13,%ymm9 + vpxor 0+128(%rsi),%ymm3,%ymm3 + vpxor 32+128(%rsi),%ymm1,%ymm1 + vpxor 64+128(%rsi),%ymm5,%ymm5 + vpxor 96+128(%rsi),%ymm9,%ymm9 + vmovdqu %ymm3,0+128(%rdi) + vmovdqu %ymm1,32+128(%rdi) + vmovdqu %ymm5,64+128(%rdi) + vmovdqu %ymm9,96+128(%rdi) + vperm2i128 $0x13,%ymm0,%ymm4,%ymm3 + vperm2i128 $0x02,%ymm0,%ymm4,%ymm0 + vperm2i128 $0x02,%ymm8,%ymm12,%ymm4 + vperm2i128 $0x13,%ymm8,%ymm12,%ymm12 + vmovdqa %ymm3,%ymm8 + + movq $256,%rcx + leaq 256(%rsi),%rsi + subq $256,%rbx + jmp .Lseal_avx2_short_hash_remainder + +.Lseal_avx2_tail_512: + vmovdqa .Lchacha20_consts(%rip),%ymm0 + vmovdqa 0+64(%rbp),%ymm4 + vmovdqa 0+96(%rbp),%ymm8 + vmovdqa %ymm0,%ymm1 + vmovdqa %ymm4,%ymm5 + vmovdqa %ymm8,%ymm9 + vmovdqa %ymm0,%ymm2 + vmovdqa %ymm4,%ymm6 + vmovdqa %ymm8,%ymm10 + vmovdqa %ymm0,%ymm3 + vmovdqa %ymm4,%ymm7 + vmovdqa %ymm8,%ymm11 + vmovdqa .Lavx2_inc(%rip),%ymm12 + vpaddd 0+160(%rbp),%ymm12,%ymm15 + vpaddd %ymm15,%ymm12,%ymm14 + vpaddd %ymm14,%ymm12,%ymm13 + vpaddd %ymm13,%ymm12,%ymm12 + vmovdqa %ymm15,0+256(%rbp) + vmovdqa %ymm14,0+224(%rbp) + vmovdqa %ymm13,0+192(%rbp) + vmovdqa %ymm12,0+160(%rbp) + +.Lseal_avx2_tail_512_rounds_and_3xhash: + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + addq %rax,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%rdi),%rdi +.Lseal_avx2_tail_512_rounds_and_2xhash: + vmovdqa %ymm8,0+128(%rbp) + vmovdqa .Lrol16(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $20,%ymm7,%ymm8 + vpslld $32-20,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $20,%ymm6,%ymm8 + vpslld $32-20,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $20,%ymm5,%ymm8 + vpslld $32-20,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $20,%ymm4,%ymm8 + vpslld $32-20,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa .Lrol8(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $25,%ymm7,%ymm8 + vpslld $32-25,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + vpsrld $25,%ymm6,%ymm8 + vpslld $32-25,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $25,%ymm5,%ymm8 + vpslld $32-25,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $25,%ymm4,%ymm8 + vpslld $32-25,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa 0+128(%rbp),%ymm8 + vpalignr $4,%ymm7,%ymm7,%ymm7 + vpalignr $8,%ymm11,%ymm11,%ymm11 + vpalignr $12,%ymm15,%ymm15,%ymm15 + vpalignr $4,%ymm6,%ymm6,%ymm6 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $12,%ymm14,%ymm14,%ymm14 + vpalignr $4,%ymm5,%ymm5,%ymm5 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $12,%ymm13,%ymm13,%ymm13 + vpalignr $4,%ymm4,%ymm4,%ymm4 + addq %rax,%r15 + adcq %rdx,%r9 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vmovdqa %ymm8,0+128(%rbp) + vmovdqa .Lrol16(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $20,%ymm7,%ymm8 + vpslld $32-20,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $20,%ymm6,%ymm8 + vpslld $32-20,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $20,%ymm5,%ymm8 + vpslld $32-20,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $20,%ymm4,%ymm8 + vpslld $32-20,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa .Lrol8(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + addq 0+16(%rdi),%r10 + adcq 8+16(%rdi),%r11 + adcq $1,%r12 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $25,%ymm7,%ymm8 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + vpslld $32-25,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $25,%ymm6,%ymm8 + vpslld $32-25,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $25,%ymm5,%ymm8 + vpslld $32-25,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $25,%ymm4,%ymm8 + vpslld $32-25,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa 0+128(%rbp),%ymm8 + vpalignr $12,%ymm7,%ymm7,%ymm7 + vpalignr $8,%ymm11,%ymm11,%ymm11 + vpalignr $4,%ymm15,%ymm15,%ymm15 + vpalignr $12,%ymm6,%ymm6,%ymm6 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $4,%ymm14,%ymm14,%ymm14 + vpalignr $12,%ymm5,%ymm5,%ymm5 + vpalignr $8,%ymm9,%ymm9,%ymm9 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + vpalignr $4,%ymm13,%ymm13,%ymm13 + vpalignr $12,%ymm4,%ymm4,%ymm4 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $4,%ymm12,%ymm12,%ymm12 + + + + + + + + + + + + + + + + + addq %rax,%r15 + adcq %rdx,%r9 + + + + + + + + + + + + + + + + + + + + + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 32(%rdi),%rdi + decq %rcx + jg .Lseal_avx2_tail_512_rounds_and_3xhash + decq %r8 + jge .Lseal_avx2_tail_512_rounds_and_2xhash + vpaddd .Lchacha20_consts(%rip),%ymm3,%ymm3 + vpaddd 0+64(%rbp),%ymm7,%ymm7 + vpaddd 0+96(%rbp),%ymm11,%ymm11 + vpaddd 0+256(%rbp),%ymm15,%ymm15 + vpaddd .Lchacha20_consts(%rip),%ymm2,%ymm2 + vpaddd 0+64(%rbp),%ymm6,%ymm6 + vpaddd 0+96(%rbp),%ymm10,%ymm10 + vpaddd 0+224(%rbp),%ymm14,%ymm14 + vpaddd .Lchacha20_consts(%rip),%ymm1,%ymm1 + vpaddd 0+64(%rbp),%ymm5,%ymm5 + vpaddd 0+96(%rbp),%ymm9,%ymm9 + vpaddd 0+192(%rbp),%ymm13,%ymm13 + vpaddd .Lchacha20_consts(%rip),%ymm0,%ymm0 + vpaddd 0+64(%rbp),%ymm4,%ymm4 + vpaddd 0+96(%rbp),%ymm8,%ymm8 + vpaddd 0+160(%rbp),%ymm12,%ymm12 + + vmovdqa %ymm0,0+128(%rbp) + vperm2i128 $0x02,%ymm3,%ymm7,%ymm0 + vperm2i128 $0x13,%ymm3,%ymm7,%ymm7 + vperm2i128 $0x02,%ymm11,%ymm15,%ymm3 + vperm2i128 $0x13,%ymm11,%ymm15,%ymm11 + vpxor 0+0(%rsi),%ymm0,%ymm0 + vpxor 32+0(%rsi),%ymm3,%ymm3 + vpxor 64+0(%rsi),%ymm7,%ymm7 + vpxor 96+0(%rsi),%ymm11,%ymm11 + vmovdqu %ymm0,0+0(%rdi) + vmovdqu %ymm3,32+0(%rdi) + vmovdqu %ymm7,64+0(%rdi) + vmovdqu %ymm11,96+0(%rdi) + + vmovdqa 0+128(%rbp),%ymm0 + vperm2i128 $0x02,%ymm2,%ymm6,%ymm3 + vperm2i128 $0x13,%ymm2,%ymm6,%ymm6 + vperm2i128 $0x02,%ymm10,%ymm14,%ymm2 + vperm2i128 $0x13,%ymm10,%ymm14,%ymm10 + vpxor 0+128(%rsi),%ymm3,%ymm3 + vpxor 32+128(%rsi),%ymm2,%ymm2 + vpxor 64+128(%rsi),%ymm6,%ymm6 + vpxor 96+128(%rsi),%ymm10,%ymm10 + vmovdqu %ymm3,0+128(%rdi) + vmovdqu %ymm2,32+128(%rdi) + vmovdqu %ymm6,64+128(%rdi) + vmovdqu %ymm10,96+128(%rdi) + vperm2i128 $0x02,%ymm1,%ymm5,%ymm3 + vperm2i128 $0x13,%ymm1,%ymm5,%ymm5 + vperm2i128 $0x02,%ymm9,%ymm13,%ymm1 + vperm2i128 $0x13,%ymm9,%ymm13,%ymm9 + vpxor 0+256(%rsi),%ymm3,%ymm3 + vpxor 32+256(%rsi),%ymm1,%ymm1 + vpxor 64+256(%rsi),%ymm5,%ymm5 + vpxor 96+256(%rsi),%ymm9,%ymm9 + vmovdqu %ymm3,0+256(%rdi) + vmovdqu %ymm1,32+256(%rdi) + vmovdqu %ymm5,64+256(%rdi) + vmovdqu %ymm9,96+256(%rdi) + vperm2i128 $0x13,%ymm0,%ymm4,%ymm3 + vperm2i128 $0x02,%ymm0,%ymm4,%ymm0 + vperm2i128 $0x02,%ymm8,%ymm12,%ymm4 + vperm2i128 $0x13,%ymm8,%ymm12,%ymm12 + vmovdqa %ymm3,%ymm8 + + movq $384,%rcx + leaq 384(%rsi),%rsi + subq $384,%rbx + jmp .Lseal_avx2_short_hash_remainder + +.Lseal_avx2_320: + vmovdqa %ymm0,%ymm1 + vmovdqa %ymm0,%ymm2 + vmovdqa %ymm4,%ymm5 + vmovdqa %ymm4,%ymm6 + vmovdqa %ymm8,%ymm9 + vmovdqa %ymm8,%ymm10 + vpaddd .Lavx2_inc(%rip),%ymm12,%ymm13 + vpaddd .Lavx2_inc(%rip),%ymm13,%ymm14 + vmovdqa %ymm4,%ymm7 + vmovdqa %ymm8,%ymm11 + vmovdqa %ymm12,0+160(%rbp) + vmovdqa %ymm13,0+192(%rbp) + vmovdqa %ymm14,0+224(%rbp) + movq $10,%r10 +.Lseal_avx2_320_rounds: + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $4,%ymm4,%ymm4,%ymm4 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb .Lrol16(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpsrld $20,%ymm5,%ymm3 + vpslld $12,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb .Lrol8(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpslld $7,%ymm5,%ymm3 + vpsrld $25,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpalignr $12,%ymm13,%ymm13,%ymm13 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $4,%ymm5,%ymm5,%ymm5 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb .Lrol16(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpsrld $20,%ymm6,%ymm3 + vpslld $12,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb .Lrol8(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpslld $7,%ymm6,%ymm3 + vpsrld $25,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpalignr $12,%ymm14,%ymm14,%ymm14 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $4,%ymm6,%ymm6,%ymm6 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $4,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm4,%ymm4,%ymm4 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb .Lrol16(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpsrld $20,%ymm5,%ymm3 + vpslld $12,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb .Lrol8(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpslld $7,%ymm5,%ymm3 + vpsrld $25,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpalignr $4,%ymm13,%ymm13,%ymm13 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $12,%ymm5,%ymm5,%ymm5 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb .Lrol16(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpsrld $20,%ymm6,%ymm3 + vpslld $12,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb .Lrol8(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpslld $7,%ymm6,%ymm3 + vpsrld $25,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpalignr $4,%ymm14,%ymm14,%ymm14 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $12,%ymm6,%ymm6,%ymm6 + + decq %r10 + jne .Lseal_avx2_320_rounds + vpaddd .Lchacha20_consts(%rip),%ymm0,%ymm0 + vpaddd .Lchacha20_consts(%rip),%ymm1,%ymm1 + vpaddd .Lchacha20_consts(%rip),%ymm2,%ymm2 + vpaddd %ymm7,%ymm4,%ymm4 + vpaddd %ymm7,%ymm5,%ymm5 + vpaddd %ymm7,%ymm6,%ymm6 + vpaddd %ymm11,%ymm8,%ymm8 + vpaddd %ymm11,%ymm9,%ymm9 + vpaddd %ymm11,%ymm10,%ymm10 + vpaddd 0+160(%rbp),%ymm12,%ymm12 + vpaddd 0+192(%rbp),%ymm13,%ymm13 + vpaddd 0+224(%rbp),%ymm14,%ymm14 + vperm2i128 $0x02,%ymm0,%ymm4,%ymm3 + + vpand .Lclamp(%rip),%ymm3,%ymm3 + vmovdqa %ymm3,0+0(%rbp) + + vperm2i128 $0x13,%ymm0,%ymm4,%ymm0 + vperm2i128 $0x13,%ymm8,%ymm12,%ymm4 + vperm2i128 $0x02,%ymm1,%ymm5,%ymm8 + vperm2i128 $0x02,%ymm9,%ymm13,%ymm12 + vperm2i128 $0x13,%ymm1,%ymm5,%ymm1 + vperm2i128 $0x13,%ymm9,%ymm13,%ymm5 + vperm2i128 $0x02,%ymm2,%ymm6,%ymm9 + vperm2i128 $0x02,%ymm10,%ymm14,%ymm13 + vperm2i128 $0x13,%ymm2,%ymm6,%ymm2 + vperm2i128 $0x13,%ymm10,%ymm14,%ymm6 + jmp .Lseal_avx2_short + +.Lseal_avx2_192: + vmovdqa %ymm0,%ymm1 + vmovdqa %ymm0,%ymm2 + vmovdqa %ymm4,%ymm5 + vmovdqa %ymm4,%ymm6 + vmovdqa %ymm8,%ymm9 + vmovdqa %ymm8,%ymm10 + vpaddd .Lavx2_inc(%rip),%ymm12,%ymm13 + vmovdqa %ymm12,%ymm11 + vmovdqa %ymm13,%ymm15 + movq $10,%r10 +.Lseal_avx2_192_rounds: + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $4,%ymm4,%ymm4,%ymm4 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb .Lrol16(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpsrld $20,%ymm5,%ymm3 + vpslld $12,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb .Lrol8(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpslld $7,%ymm5,%ymm3 + vpsrld $25,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpalignr $12,%ymm13,%ymm13,%ymm13 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $4,%ymm5,%ymm5,%ymm5 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb .Lrol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $4,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm4,%ymm4,%ymm4 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb .Lrol16(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpsrld $20,%ymm5,%ymm3 + vpslld $12,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb .Lrol8(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpslld $7,%ymm5,%ymm3 + vpsrld $25,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpalignr $4,%ymm13,%ymm13,%ymm13 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $12,%ymm5,%ymm5,%ymm5 + + decq %r10 + jne .Lseal_avx2_192_rounds + vpaddd %ymm2,%ymm0,%ymm0 + vpaddd %ymm2,%ymm1,%ymm1 + vpaddd %ymm6,%ymm4,%ymm4 + vpaddd %ymm6,%ymm5,%ymm5 + vpaddd %ymm10,%ymm8,%ymm8 + vpaddd %ymm10,%ymm9,%ymm9 + vpaddd %ymm11,%ymm12,%ymm12 + vpaddd %ymm15,%ymm13,%ymm13 + vperm2i128 $0x02,%ymm0,%ymm4,%ymm3 + + vpand .Lclamp(%rip),%ymm3,%ymm3 + vmovdqa %ymm3,0+0(%rbp) + + vperm2i128 $0x13,%ymm0,%ymm4,%ymm0 + vperm2i128 $0x13,%ymm8,%ymm12,%ymm4 + vperm2i128 $0x02,%ymm1,%ymm5,%ymm8 + vperm2i128 $0x02,%ymm9,%ymm13,%ymm12 + vperm2i128 $0x13,%ymm1,%ymm5,%ymm1 + vperm2i128 $0x13,%ymm9,%ymm13,%ymm5 +.Lseal_avx2_short: + movq %r8,%r8 + call poly_hash_ad_internal + xorq %rcx,%rcx +.Lseal_avx2_short_hash_remainder: + cmpq $16,%rcx + jb .Lseal_avx2_short_loop + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + subq $16,%rcx + addq $16,%rdi + jmp .Lseal_avx2_short_hash_remainder +.Lseal_avx2_short_loop: + cmpq $32,%rbx + jb .Lseal_avx2_short_tail + subq $32,%rbx + + vpxor (%rsi),%ymm0,%ymm0 + vmovdqu %ymm0,(%rdi) + leaq 32(%rsi),%rsi + + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + addq 0+16(%rdi),%r10 + adcq 8+16(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 32(%rdi),%rdi + + vmovdqa %ymm4,%ymm0 + vmovdqa %ymm8,%ymm4 + vmovdqa %ymm12,%ymm8 + vmovdqa %ymm1,%ymm12 + vmovdqa %ymm5,%ymm1 + vmovdqa %ymm9,%ymm5 + vmovdqa %ymm13,%ymm9 + vmovdqa %ymm2,%ymm13 + vmovdqa %ymm6,%ymm2 + jmp .Lseal_avx2_short_loop +.Lseal_avx2_short_tail: + cmpq $16,%rbx + jb .Lseal_avx2_exit + subq $16,%rbx + vpxor (%rsi),%xmm0,%xmm3 + vmovdqu %xmm3,(%rdi) + leaq 16(%rsi),%rsi + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%rdi),%rdi + vextracti128 $1,%ymm0,%xmm0 +.Lseal_avx2_exit: + vzeroupper + jmp .Lseal_sse_tail_16 +.cfi_endproc +.size chacha20_poly1305_seal_avx2, .-chacha20_poly1305_seal_avx2 +#endif diff --git a/http/vendor/ring/pregenerated/chacha20_poly1305_x86_64-macosx.S b/http/vendor/ring/pregenerated/chacha20_poly1305_x86_64-macosx.S new file mode 100644 index 0000000..d8040dd --- /dev/null +++ b/http/vendor/ring/pregenerated/chacha20_poly1305_x86_64-macosx.S @@ -0,0 +1,8898 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__) +.section __DATA,__const +.p2align 6 +chacha20_poly1305_constants: +L$chacha20_consts: +.byte 'e','x','p','a','n','d',' ','3','2','-','b','y','t','e',' ','k' +.byte 'e','x','p','a','n','d',' ','3','2','-','b','y','t','e',' ','k' +L$rol8: +.byte 3,0,1,2, 7,4,5,6, 11,8,9,10, 15,12,13,14 +.byte 3,0,1,2, 7,4,5,6, 11,8,9,10, 15,12,13,14 +L$rol16: +.byte 2,3,0,1, 6,7,4,5, 10,11,8,9, 14,15,12,13 +.byte 2,3,0,1, 6,7,4,5, 10,11,8,9, 14,15,12,13 +L$avx2_init: +.long 0,0,0,0 +L$sse_inc: +.long 1,0,0,0 +L$avx2_inc: +.long 2,0,0,0,2,0,0,0 +L$clamp: +.quad 0x0FFFFFFC0FFFFFFF, 0x0FFFFFFC0FFFFFFC +.quad 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF +.p2align 4 +L$and_masks: +.byte 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00 +.byte 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff +.text + + +.p2align 6 +poly_hash_ad_internal: + + + xorq %r10,%r10 + xorq %r11,%r11 + xorq %r12,%r12 + cmpq $13,%r8 + jne L$hash_ad_loop +L$poly_fast_tls_ad: + + movq (%rcx),%r10 + movq 5(%rcx),%r11 + shrq $24,%r11 + movq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + ret +L$hash_ad_loop: + + cmpq $16,%r8 + jb L$hash_ad_tail + addq 0+0(%rcx),%r10 + adcq 8+0(%rcx),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%rcx),%rcx + subq $16,%r8 + jmp L$hash_ad_loop +L$hash_ad_tail: + cmpq $0,%r8 + je L$hash_ad_done + + xorq %r13,%r13 + xorq %r14,%r14 + xorq %r15,%r15 + addq %r8,%rcx +L$hash_ad_tail_loop: + shldq $8,%r13,%r14 + shlq $8,%r13 + movzbq -1(%rcx),%r15 + xorq %r15,%r13 + decq %rcx + decq %r8 + jne L$hash_ad_tail_loop + + addq %r13,%r10 + adcq %r14,%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + +L$hash_ad_done: + ret + + + +.globl _chacha20_poly1305_open_sse41 +.private_extern _chacha20_poly1305_open_sse41 + +.p2align 6 +_chacha20_poly1305_open_sse41: + +_CET_ENDBR + pushq %rbp + + pushq %rbx + + pushq %r12 + + pushq %r13 + + pushq %r14 + + pushq %r15 + + + + pushq %r9 + + subq $288 + 0 + 32,%rsp + + + leaq 32(%rsp),%rbp + andq $-32,%rbp + + movq %rdx,%rbx + movq %r8,0+0+32(%rbp) + movq %rbx,8+0+32(%rbp) + + cmpq $128,%rbx + jbe L$open_sse_128 + + movdqa L$chacha20_consts(%rip),%xmm0 + movdqu 0(%r9),%xmm4 + movdqu 16(%r9),%xmm8 + movdqu 32(%r9),%xmm12 + + movdqa %xmm12,%xmm7 + + movdqa %xmm4,0+48(%rbp) + movdqa %xmm8,0+64(%rbp) + movdqa %xmm12,0+96(%rbp) + movq $10,%r10 +L$open_sse_init_rounds: + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,4 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,12 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,12 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,4 + + decq %r10 + jne L$open_sse_init_rounds + + paddd L$chacha20_consts(%rip),%xmm0 + paddd 0+48(%rbp),%xmm4 + + pand L$clamp(%rip),%xmm0 + movdqa %xmm0,0+0(%rbp) + movdqa %xmm4,0+16(%rbp) + + movq %r8,%r8 + call poly_hash_ad_internal +L$open_sse_main_loop: + cmpq $256,%rbx + jb L$open_sse_tail + + movdqa L$chacha20_consts(%rip),%xmm0 + movdqa 0+48(%rbp),%xmm4 + movdqa 0+64(%rbp),%xmm8 + movdqa %xmm0,%xmm1 + movdqa %xmm4,%xmm5 + movdqa %xmm8,%xmm9 + movdqa %xmm0,%xmm2 + movdqa %xmm4,%xmm6 + movdqa %xmm8,%xmm10 + movdqa %xmm0,%xmm3 + movdqa %xmm4,%xmm7 + movdqa %xmm8,%xmm11 + movdqa 0+96(%rbp),%xmm15 + paddd L$sse_inc(%rip),%xmm15 + movdqa %xmm15,%xmm14 + paddd L$sse_inc(%rip),%xmm14 + movdqa %xmm14,%xmm13 + paddd L$sse_inc(%rip),%xmm13 + movdqa %xmm13,%xmm12 + paddd L$sse_inc(%rip),%xmm12 + movdqa %xmm12,0+96(%rbp) + movdqa %xmm13,0+112(%rbp) + movdqa %xmm14,0+128(%rbp) + movdqa %xmm15,0+144(%rbp) + + + + movq $4,%rcx + movq %rsi,%r8 +L$open_sse_main_loop_rounds: + movdqa %xmm8,0+80(%rbp) + movdqa L$rol16(%rip),%xmm8 + paddd %xmm7,%xmm3 + paddd %xmm6,%xmm2 + paddd %xmm5,%xmm1 + paddd %xmm4,%xmm0 + pxor %xmm3,%xmm15 + pxor %xmm2,%xmm14 + pxor %xmm1,%xmm13 + pxor %xmm0,%xmm12 +.byte 102,69,15,56,0,248 +.byte 102,69,15,56,0,240 +.byte 102,69,15,56,0,232 +.byte 102,69,15,56,0,224 + movdqa 0+80(%rbp),%xmm8 + paddd %xmm15,%xmm11 + paddd %xmm14,%xmm10 + paddd %xmm13,%xmm9 + paddd %xmm12,%xmm8 + pxor %xmm11,%xmm7 + addq 0+0(%r8),%r10 + adcq 8+0(%r8),%r11 + adcq $1,%r12 + + leaq 16(%r8),%r8 + pxor %xmm10,%xmm6 + pxor %xmm9,%xmm5 + pxor %xmm8,%xmm4 + movdqa %xmm8,0+80(%rbp) + movdqa %xmm7,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm7 + pxor %xmm8,%xmm7 + movdqa %xmm6,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm6 + pxor %xmm8,%xmm6 + movdqa %xmm5,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm5 + pxor %xmm8,%xmm5 + movdqa %xmm4,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm4 + pxor %xmm8,%xmm4 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movdqa L$rol8(%rip),%xmm8 + paddd %xmm7,%xmm3 + paddd %xmm6,%xmm2 + paddd %xmm5,%xmm1 + paddd %xmm4,%xmm0 + pxor %xmm3,%xmm15 + pxor %xmm2,%xmm14 + pxor %xmm1,%xmm13 + pxor %xmm0,%xmm12 +.byte 102,69,15,56,0,248 +.byte 102,69,15,56,0,240 +.byte 102,69,15,56,0,232 +.byte 102,69,15,56,0,224 + movdqa 0+80(%rbp),%xmm8 + paddd %xmm15,%xmm11 + paddd %xmm14,%xmm10 + paddd %xmm13,%xmm9 + paddd %xmm12,%xmm8 + pxor %xmm11,%xmm7 + pxor %xmm10,%xmm6 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + pxor %xmm9,%xmm5 + pxor %xmm8,%xmm4 + movdqa %xmm8,0+80(%rbp) + movdqa %xmm7,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm7 + pxor %xmm8,%xmm7 + movdqa %xmm6,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm6 + pxor %xmm8,%xmm6 + movdqa %xmm5,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm5 + pxor %xmm8,%xmm5 + movdqa %xmm4,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm4 + pxor %xmm8,%xmm4 + movdqa 0+80(%rbp),%xmm8 + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 +.byte 102,15,58,15,255,4 +.byte 102,69,15,58,15,219,8 +.byte 102,69,15,58,15,255,12 +.byte 102,15,58,15,246,4 +.byte 102,69,15,58,15,210,8 +.byte 102,69,15,58,15,246,12 +.byte 102,15,58,15,237,4 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,12 +.byte 102,15,58,15,228,4 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,12 + movdqa %xmm8,0+80(%rbp) + movdqa L$rol16(%rip),%xmm8 + paddd %xmm7,%xmm3 + paddd %xmm6,%xmm2 + paddd %xmm5,%xmm1 + paddd %xmm4,%xmm0 + pxor %xmm3,%xmm15 + pxor %xmm2,%xmm14 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + pxor %xmm1,%xmm13 + pxor %xmm0,%xmm12 +.byte 102,69,15,56,0,248 +.byte 102,69,15,56,0,240 +.byte 102,69,15,56,0,232 +.byte 102,69,15,56,0,224 + movdqa 0+80(%rbp),%xmm8 + paddd %xmm15,%xmm11 + paddd %xmm14,%xmm10 + paddd %xmm13,%xmm9 + paddd %xmm12,%xmm8 + pxor %xmm11,%xmm7 + pxor %xmm10,%xmm6 + pxor %xmm9,%xmm5 + pxor %xmm8,%xmm4 + movdqa %xmm8,0+80(%rbp) + movdqa %xmm7,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm7 + pxor %xmm8,%xmm7 + movdqa %xmm6,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm6 + pxor %xmm8,%xmm6 + movdqa %xmm5,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm5 + pxor %xmm8,%xmm5 + movdqa %xmm4,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm4 + pxor %xmm8,%xmm4 + movdqa L$rol8(%rip),%xmm8 + paddd %xmm7,%xmm3 + paddd %xmm6,%xmm2 + paddd %xmm5,%xmm1 + paddd %xmm4,%xmm0 + pxor %xmm3,%xmm15 + pxor %xmm2,%xmm14 + pxor %xmm1,%xmm13 + pxor %xmm0,%xmm12 +.byte 102,69,15,56,0,248 +.byte 102,69,15,56,0,240 +.byte 102,69,15,56,0,232 +.byte 102,69,15,56,0,224 + movdqa 0+80(%rbp),%xmm8 + paddd %xmm15,%xmm11 + paddd %xmm14,%xmm10 + paddd %xmm13,%xmm9 + paddd %xmm12,%xmm8 + pxor %xmm11,%xmm7 + pxor %xmm10,%xmm6 + pxor %xmm9,%xmm5 + pxor %xmm8,%xmm4 + movdqa %xmm8,0+80(%rbp) + movdqa %xmm7,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm7 + pxor %xmm8,%xmm7 + movdqa %xmm6,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm6 + pxor %xmm8,%xmm6 + movdqa %xmm5,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm5 + pxor %xmm8,%xmm5 + movdqa %xmm4,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm4 + pxor %xmm8,%xmm4 + movdqa 0+80(%rbp),%xmm8 +.byte 102,15,58,15,255,12 +.byte 102,69,15,58,15,219,8 +.byte 102,69,15,58,15,255,4 +.byte 102,15,58,15,246,12 +.byte 102,69,15,58,15,210,8 +.byte 102,69,15,58,15,246,4 +.byte 102,15,58,15,237,12 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,4 +.byte 102,15,58,15,228,12 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,4 + + decq %rcx + jge L$open_sse_main_loop_rounds + addq 0+0(%r8),%r10 + adcq 8+0(%r8),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%r8),%r8 + cmpq $-6,%rcx + jg L$open_sse_main_loop_rounds + paddd L$chacha20_consts(%rip),%xmm3 + paddd 0+48(%rbp),%xmm7 + paddd 0+64(%rbp),%xmm11 + paddd 0+144(%rbp),%xmm15 + paddd L$chacha20_consts(%rip),%xmm2 + paddd 0+48(%rbp),%xmm6 + paddd 0+64(%rbp),%xmm10 + paddd 0+128(%rbp),%xmm14 + paddd L$chacha20_consts(%rip),%xmm1 + paddd 0+48(%rbp),%xmm5 + paddd 0+64(%rbp),%xmm9 + paddd 0+112(%rbp),%xmm13 + paddd L$chacha20_consts(%rip),%xmm0 + paddd 0+48(%rbp),%xmm4 + paddd 0+64(%rbp),%xmm8 + paddd 0+96(%rbp),%xmm12 + movdqa %xmm12,0+80(%rbp) + movdqu 0 + 0(%rsi),%xmm12 + pxor %xmm3,%xmm12 + movdqu %xmm12,0 + 0(%rdi) + movdqu 16 + 0(%rsi),%xmm12 + pxor %xmm7,%xmm12 + movdqu %xmm12,16 + 0(%rdi) + movdqu 32 + 0(%rsi),%xmm12 + pxor %xmm11,%xmm12 + movdqu %xmm12,32 + 0(%rdi) + movdqu 48 + 0(%rsi),%xmm12 + pxor %xmm15,%xmm12 + movdqu %xmm12,48 + 0(%rdi) + movdqu 0 + 64(%rsi),%xmm3 + movdqu 16 + 64(%rsi),%xmm7 + movdqu 32 + 64(%rsi),%xmm11 + movdqu 48 + 64(%rsi),%xmm15 + pxor %xmm3,%xmm2 + pxor %xmm7,%xmm6 + pxor %xmm11,%xmm10 + pxor %xmm14,%xmm15 + movdqu %xmm2,0 + 64(%rdi) + movdqu %xmm6,16 + 64(%rdi) + movdqu %xmm10,32 + 64(%rdi) + movdqu %xmm15,48 + 64(%rdi) + movdqu 0 + 128(%rsi),%xmm3 + movdqu 16 + 128(%rsi),%xmm7 + movdqu 32 + 128(%rsi),%xmm11 + movdqu 48 + 128(%rsi),%xmm15 + pxor %xmm3,%xmm1 + pxor %xmm7,%xmm5 + pxor %xmm11,%xmm9 + pxor %xmm13,%xmm15 + movdqu %xmm1,0 + 128(%rdi) + movdqu %xmm5,16 + 128(%rdi) + movdqu %xmm9,32 + 128(%rdi) + movdqu %xmm15,48 + 128(%rdi) + movdqu 0 + 192(%rsi),%xmm3 + movdqu 16 + 192(%rsi),%xmm7 + movdqu 32 + 192(%rsi),%xmm11 + movdqu 48 + 192(%rsi),%xmm15 + pxor %xmm3,%xmm0 + pxor %xmm7,%xmm4 + pxor %xmm11,%xmm8 + pxor 0+80(%rbp),%xmm15 + movdqu %xmm0,0 + 192(%rdi) + movdqu %xmm4,16 + 192(%rdi) + movdqu %xmm8,32 + 192(%rdi) + movdqu %xmm15,48 + 192(%rdi) + + leaq 256(%rsi),%rsi + leaq 256(%rdi),%rdi + subq $256,%rbx + jmp L$open_sse_main_loop +L$open_sse_tail: + + testq %rbx,%rbx + jz L$open_sse_finalize + cmpq $192,%rbx + ja L$open_sse_tail_256 + cmpq $128,%rbx + ja L$open_sse_tail_192 + cmpq $64,%rbx + ja L$open_sse_tail_128 + movdqa L$chacha20_consts(%rip),%xmm0 + movdqa 0+48(%rbp),%xmm4 + movdqa 0+64(%rbp),%xmm8 + movdqa 0+96(%rbp),%xmm12 + paddd L$sse_inc(%rip),%xmm12 + movdqa %xmm12,0+96(%rbp) + + xorq %r8,%r8 + movq %rbx,%rcx + cmpq $16,%rcx + jb L$open_sse_tail_64_rounds +L$open_sse_tail_64_rounds_and_x1hash: + addq 0+0(%rsi,%r8,1),%r10 + adcq 8+0(%rsi,%r8,1),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + subq $16,%rcx +L$open_sse_tail_64_rounds: + addq $16,%r8 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,4 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,12 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,12 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,4 + + cmpq $16,%rcx + jae L$open_sse_tail_64_rounds_and_x1hash + cmpq $160,%r8 + jne L$open_sse_tail_64_rounds + paddd L$chacha20_consts(%rip),%xmm0 + paddd 0+48(%rbp),%xmm4 + paddd 0+64(%rbp),%xmm8 + paddd 0+96(%rbp),%xmm12 + + jmp L$open_sse_tail_64_dec_loop + +L$open_sse_tail_128: + movdqa L$chacha20_consts(%rip),%xmm0 + movdqa 0+48(%rbp),%xmm4 + movdqa 0+64(%rbp),%xmm8 + movdqa %xmm0,%xmm1 + movdqa %xmm4,%xmm5 + movdqa %xmm8,%xmm9 + movdqa 0+96(%rbp),%xmm13 + paddd L$sse_inc(%rip),%xmm13 + movdqa %xmm13,%xmm12 + paddd L$sse_inc(%rip),%xmm12 + movdqa %xmm12,0+96(%rbp) + movdqa %xmm13,0+112(%rbp) + + movq %rbx,%rcx + andq $-16,%rcx + xorq %r8,%r8 +L$open_sse_tail_128_rounds_and_x1hash: + addq 0+0(%rsi,%r8,1),%r10 + adcq 8+0(%rsi,%r8,1),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + +L$open_sse_tail_128_rounds: + addq $16,%r8 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,4 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,12 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb L$rol16(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm5 + pxor %xmm3,%xmm5 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb L$rol8(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm5 + pxor %xmm3,%xmm5 +.byte 102,15,58,15,237,4 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,12 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,12 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,4 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb L$rol16(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm5 + pxor %xmm3,%xmm5 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb L$rol8(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm5 + pxor %xmm3,%xmm5 +.byte 102,15,58,15,237,12 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,4 + + cmpq %rcx,%r8 + jb L$open_sse_tail_128_rounds_and_x1hash + cmpq $160,%r8 + jne L$open_sse_tail_128_rounds + paddd L$chacha20_consts(%rip),%xmm1 + paddd 0+48(%rbp),%xmm5 + paddd 0+64(%rbp),%xmm9 + paddd 0+112(%rbp),%xmm13 + paddd L$chacha20_consts(%rip),%xmm0 + paddd 0+48(%rbp),%xmm4 + paddd 0+64(%rbp),%xmm8 + paddd 0+96(%rbp),%xmm12 + movdqu 0 + 0(%rsi),%xmm3 + movdqu 16 + 0(%rsi),%xmm7 + movdqu 32 + 0(%rsi),%xmm11 + movdqu 48 + 0(%rsi),%xmm15 + pxor %xmm3,%xmm1 + pxor %xmm7,%xmm5 + pxor %xmm11,%xmm9 + pxor %xmm13,%xmm15 + movdqu %xmm1,0 + 0(%rdi) + movdqu %xmm5,16 + 0(%rdi) + movdqu %xmm9,32 + 0(%rdi) + movdqu %xmm15,48 + 0(%rdi) + + subq $64,%rbx + leaq 64(%rsi),%rsi + leaq 64(%rdi),%rdi + jmp L$open_sse_tail_64_dec_loop + +L$open_sse_tail_192: + movdqa L$chacha20_consts(%rip),%xmm0 + movdqa 0+48(%rbp),%xmm4 + movdqa 0+64(%rbp),%xmm8 + movdqa %xmm0,%xmm1 + movdqa %xmm4,%xmm5 + movdqa %xmm8,%xmm9 + movdqa %xmm0,%xmm2 + movdqa %xmm4,%xmm6 + movdqa %xmm8,%xmm10 + movdqa 0+96(%rbp),%xmm14 + paddd L$sse_inc(%rip),%xmm14 + movdqa %xmm14,%xmm13 + paddd L$sse_inc(%rip),%xmm13 + movdqa %xmm13,%xmm12 + paddd L$sse_inc(%rip),%xmm12 + movdqa %xmm12,0+96(%rbp) + movdqa %xmm13,0+112(%rbp) + movdqa %xmm14,0+128(%rbp) + + movq %rbx,%rcx + movq $160,%r8 + cmpq $160,%rcx + cmovgq %r8,%rcx + andq $-16,%rcx + xorq %r8,%r8 +L$open_sse_tail_192_rounds_and_x1hash: + addq 0+0(%rsi,%r8,1),%r10 + adcq 8+0(%rsi,%r8,1),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + +L$open_sse_tail_192_rounds: + addq $16,%r8 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,4 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,12 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb L$rol16(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm5 + pxor %xmm3,%xmm5 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb L$rol8(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm5 + pxor %xmm3,%xmm5 +.byte 102,15,58,15,237,4 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,12 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb L$rol16(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm6 + pxor %xmm3,%xmm6 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb L$rol8(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm6 + pxor %xmm3,%xmm6 +.byte 102,15,58,15,246,4 +.byte 102,69,15,58,15,210,8 +.byte 102,69,15,58,15,246,12 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,12 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,4 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb L$rol16(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm5 + pxor %xmm3,%xmm5 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb L$rol8(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm5 + pxor %xmm3,%xmm5 +.byte 102,15,58,15,237,12 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,4 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb L$rol16(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm6 + pxor %xmm3,%xmm6 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb L$rol8(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm6 + pxor %xmm3,%xmm6 +.byte 102,15,58,15,246,12 +.byte 102,69,15,58,15,210,8 +.byte 102,69,15,58,15,246,4 + + cmpq %rcx,%r8 + jb L$open_sse_tail_192_rounds_and_x1hash + cmpq $160,%r8 + jne L$open_sse_tail_192_rounds + cmpq $176,%rbx + jb L$open_sse_tail_192_finish + addq 0+160(%rsi),%r10 + adcq 8+160(%rsi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + cmpq $192,%rbx + jb L$open_sse_tail_192_finish + addq 0+176(%rsi),%r10 + adcq 8+176(%rsi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + +L$open_sse_tail_192_finish: + paddd L$chacha20_consts(%rip),%xmm2 + paddd 0+48(%rbp),%xmm6 + paddd 0+64(%rbp),%xmm10 + paddd 0+128(%rbp),%xmm14 + paddd L$chacha20_consts(%rip),%xmm1 + paddd 0+48(%rbp),%xmm5 + paddd 0+64(%rbp),%xmm9 + paddd 0+112(%rbp),%xmm13 + paddd L$chacha20_consts(%rip),%xmm0 + paddd 0+48(%rbp),%xmm4 + paddd 0+64(%rbp),%xmm8 + paddd 0+96(%rbp),%xmm12 + movdqu 0 + 0(%rsi),%xmm3 + movdqu 16 + 0(%rsi),%xmm7 + movdqu 32 + 0(%rsi),%xmm11 + movdqu 48 + 0(%rsi),%xmm15 + pxor %xmm3,%xmm2 + pxor %xmm7,%xmm6 + pxor %xmm11,%xmm10 + pxor %xmm14,%xmm15 + movdqu %xmm2,0 + 0(%rdi) + movdqu %xmm6,16 + 0(%rdi) + movdqu %xmm10,32 + 0(%rdi) + movdqu %xmm15,48 + 0(%rdi) + movdqu 0 + 64(%rsi),%xmm3 + movdqu 16 + 64(%rsi),%xmm7 + movdqu 32 + 64(%rsi),%xmm11 + movdqu 48 + 64(%rsi),%xmm15 + pxor %xmm3,%xmm1 + pxor %xmm7,%xmm5 + pxor %xmm11,%xmm9 + pxor %xmm13,%xmm15 + movdqu %xmm1,0 + 64(%rdi) + movdqu %xmm5,16 + 64(%rdi) + movdqu %xmm9,32 + 64(%rdi) + movdqu %xmm15,48 + 64(%rdi) + + subq $128,%rbx + leaq 128(%rsi),%rsi + leaq 128(%rdi),%rdi + jmp L$open_sse_tail_64_dec_loop + +L$open_sse_tail_256: + movdqa L$chacha20_consts(%rip),%xmm0 + movdqa 0+48(%rbp),%xmm4 + movdqa 0+64(%rbp),%xmm8 + movdqa %xmm0,%xmm1 + movdqa %xmm4,%xmm5 + movdqa %xmm8,%xmm9 + movdqa %xmm0,%xmm2 + movdqa %xmm4,%xmm6 + movdqa %xmm8,%xmm10 + movdqa %xmm0,%xmm3 + movdqa %xmm4,%xmm7 + movdqa %xmm8,%xmm11 + movdqa 0+96(%rbp),%xmm15 + paddd L$sse_inc(%rip),%xmm15 + movdqa %xmm15,%xmm14 + paddd L$sse_inc(%rip),%xmm14 + movdqa %xmm14,%xmm13 + paddd L$sse_inc(%rip),%xmm13 + movdqa %xmm13,%xmm12 + paddd L$sse_inc(%rip),%xmm12 + movdqa %xmm12,0+96(%rbp) + movdqa %xmm13,0+112(%rbp) + movdqa %xmm14,0+128(%rbp) + movdqa %xmm15,0+144(%rbp) + + xorq %r8,%r8 +L$open_sse_tail_256_rounds_and_x1hash: + addq 0+0(%rsi,%r8,1),%r10 + adcq 8+0(%rsi,%r8,1),%r11 + adcq $1,%r12 + movdqa %xmm11,0+80(%rbp) + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm11 + pslld $12,%xmm11 + psrld $20,%xmm4 + pxor %xmm11,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm11 + pslld $7,%xmm11 + psrld $25,%xmm4 + pxor %xmm11,%xmm4 +.byte 102,15,58,15,228,4 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,12 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb L$rol16(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm11 + pslld $12,%xmm11 + psrld $20,%xmm5 + pxor %xmm11,%xmm5 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb L$rol8(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm11 + pslld $7,%xmm11 + psrld $25,%xmm5 + pxor %xmm11,%xmm5 +.byte 102,15,58,15,237,4 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,12 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb L$rol16(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm11 + pslld $12,%xmm11 + psrld $20,%xmm6 + pxor %xmm11,%xmm6 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb L$rol8(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm11 + pslld $7,%xmm11 + psrld $25,%xmm6 + pxor %xmm11,%xmm6 +.byte 102,15,58,15,246,4 +.byte 102,69,15,58,15,210,8 +.byte 102,69,15,58,15,246,12 + movdqa 0+80(%rbp),%xmm11 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movdqa %xmm9,0+80(%rbp) + paddd %xmm7,%xmm3 + pxor %xmm3,%xmm15 + pshufb L$rol16(%rip),%xmm15 + paddd %xmm15,%xmm11 + pxor %xmm11,%xmm7 + movdqa %xmm7,%xmm9 + pslld $12,%xmm9 + psrld $20,%xmm7 + pxor %xmm9,%xmm7 + paddd %xmm7,%xmm3 + pxor %xmm3,%xmm15 + pshufb L$rol8(%rip),%xmm15 + paddd %xmm15,%xmm11 + pxor %xmm11,%xmm7 + movdqa %xmm7,%xmm9 + pslld $7,%xmm9 + psrld $25,%xmm7 + pxor %xmm9,%xmm7 +.byte 102,15,58,15,255,4 +.byte 102,69,15,58,15,219,8 +.byte 102,69,15,58,15,255,12 + movdqa 0+80(%rbp),%xmm9 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + movdqa %xmm11,0+80(%rbp) + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm11 + pslld $12,%xmm11 + psrld $20,%xmm4 + pxor %xmm11,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm11 + pslld $7,%xmm11 + psrld $25,%xmm4 + pxor %xmm11,%xmm4 +.byte 102,15,58,15,228,12 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,4 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb L$rol16(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm11 + pslld $12,%xmm11 + psrld $20,%xmm5 + pxor %xmm11,%xmm5 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb L$rol8(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm11 + pslld $7,%xmm11 + psrld $25,%xmm5 + pxor %xmm11,%xmm5 +.byte 102,15,58,15,237,12 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,4 + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb L$rol16(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm11 + pslld $12,%xmm11 + psrld $20,%xmm6 + pxor %xmm11,%xmm6 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb L$rol8(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm11 + pslld $7,%xmm11 + psrld $25,%xmm6 + pxor %xmm11,%xmm6 +.byte 102,15,58,15,246,12 +.byte 102,69,15,58,15,210,8 +.byte 102,69,15,58,15,246,4 + movdqa 0+80(%rbp),%xmm11 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + movdqa %xmm9,0+80(%rbp) + paddd %xmm7,%xmm3 + pxor %xmm3,%xmm15 + pshufb L$rol16(%rip),%xmm15 + paddd %xmm15,%xmm11 + pxor %xmm11,%xmm7 + movdqa %xmm7,%xmm9 + pslld $12,%xmm9 + psrld $20,%xmm7 + pxor %xmm9,%xmm7 + paddd %xmm7,%xmm3 + pxor %xmm3,%xmm15 + pshufb L$rol8(%rip),%xmm15 + paddd %xmm15,%xmm11 + pxor %xmm11,%xmm7 + movdqa %xmm7,%xmm9 + pslld $7,%xmm9 + psrld $25,%xmm7 + pxor %xmm9,%xmm7 +.byte 102,15,58,15,255,12 +.byte 102,69,15,58,15,219,8 +.byte 102,69,15,58,15,255,4 + movdqa 0+80(%rbp),%xmm9 + + addq $16,%r8 + cmpq $160,%r8 + jb L$open_sse_tail_256_rounds_and_x1hash + + movq %rbx,%rcx + andq $-16,%rcx +L$open_sse_tail_256_hash: + addq 0+0(%rsi,%r8,1),%r10 + adcq 8+0(%rsi,%r8,1),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + addq $16,%r8 + cmpq %rcx,%r8 + jb L$open_sse_tail_256_hash + paddd L$chacha20_consts(%rip),%xmm3 + paddd 0+48(%rbp),%xmm7 + paddd 0+64(%rbp),%xmm11 + paddd 0+144(%rbp),%xmm15 + paddd L$chacha20_consts(%rip),%xmm2 + paddd 0+48(%rbp),%xmm6 + paddd 0+64(%rbp),%xmm10 + paddd 0+128(%rbp),%xmm14 + paddd L$chacha20_consts(%rip),%xmm1 + paddd 0+48(%rbp),%xmm5 + paddd 0+64(%rbp),%xmm9 + paddd 0+112(%rbp),%xmm13 + paddd L$chacha20_consts(%rip),%xmm0 + paddd 0+48(%rbp),%xmm4 + paddd 0+64(%rbp),%xmm8 + paddd 0+96(%rbp),%xmm12 + movdqa %xmm12,0+80(%rbp) + movdqu 0 + 0(%rsi),%xmm12 + pxor %xmm3,%xmm12 + movdqu %xmm12,0 + 0(%rdi) + movdqu 16 + 0(%rsi),%xmm12 + pxor %xmm7,%xmm12 + movdqu %xmm12,16 + 0(%rdi) + movdqu 32 + 0(%rsi),%xmm12 + pxor %xmm11,%xmm12 + movdqu %xmm12,32 + 0(%rdi) + movdqu 48 + 0(%rsi),%xmm12 + pxor %xmm15,%xmm12 + movdqu %xmm12,48 + 0(%rdi) + movdqu 0 + 64(%rsi),%xmm3 + movdqu 16 + 64(%rsi),%xmm7 + movdqu 32 + 64(%rsi),%xmm11 + movdqu 48 + 64(%rsi),%xmm15 + pxor %xmm3,%xmm2 + pxor %xmm7,%xmm6 + pxor %xmm11,%xmm10 + pxor %xmm14,%xmm15 + movdqu %xmm2,0 + 64(%rdi) + movdqu %xmm6,16 + 64(%rdi) + movdqu %xmm10,32 + 64(%rdi) + movdqu %xmm15,48 + 64(%rdi) + movdqu 0 + 128(%rsi),%xmm3 + movdqu 16 + 128(%rsi),%xmm7 + movdqu 32 + 128(%rsi),%xmm11 + movdqu 48 + 128(%rsi),%xmm15 + pxor %xmm3,%xmm1 + pxor %xmm7,%xmm5 + pxor %xmm11,%xmm9 + pxor %xmm13,%xmm15 + movdqu %xmm1,0 + 128(%rdi) + movdqu %xmm5,16 + 128(%rdi) + movdqu %xmm9,32 + 128(%rdi) + movdqu %xmm15,48 + 128(%rdi) + + movdqa 0+80(%rbp),%xmm12 + subq $192,%rbx + leaq 192(%rsi),%rsi + leaq 192(%rdi),%rdi + + +L$open_sse_tail_64_dec_loop: + cmpq $16,%rbx + jb L$open_sse_tail_16_init + subq $16,%rbx + movdqu (%rsi),%xmm3 + pxor %xmm3,%xmm0 + movdqu %xmm0,(%rdi) + leaq 16(%rsi),%rsi + leaq 16(%rdi),%rdi + movdqa %xmm4,%xmm0 + movdqa %xmm8,%xmm4 + movdqa %xmm12,%xmm8 + jmp L$open_sse_tail_64_dec_loop +L$open_sse_tail_16_init: + movdqa %xmm0,%xmm1 + + +L$open_sse_tail_16: + testq %rbx,%rbx + jz L$open_sse_finalize + + + + pxor %xmm3,%xmm3 + leaq -1(%rsi,%rbx,1),%rsi + movq %rbx,%r8 +L$open_sse_tail_16_compose: + pslldq $1,%xmm3 + pinsrb $0,(%rsi),%xmm3 + subq $1,%rsi + subq $1,%r8 + jnz L$open_sse_tail_16_compose + +.byte 102,73,15,126,221 + pextrq $1,%xmm3,%r14 + + pxor %xmm1,%xmm3 + + +L$open_sse_tail_16_extract: + pextrb $0,%xmm3,(%rdi) + psrldq $1,%xmm3 + addq $1,%rdi + subq $1,%rbx + jne L$open_sse_tail_16_extract + + addq %r13,%r10 + adcq %r14,%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + +L$open_sse_finalize: + addq 0+0+32(%rbp),%r10 + adcq 8+0+32(%rbp),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + + movq %r10,%r13 + movq %r11,%r14 + movq %r12,%r15 + subq $-5,%r10 + sbbq $-1,%r11 + sbbq $3,%r12 + cmovcq %r13,%r10 + cmovcq %r14,%r11 + cmovcq %r15,%r12 + + addq 0+0+16(%rbp),%r10 + adcq 8+0+16(%rbp),%r11 + + + addq $288 + 0 + 32,%rsp + + + popq %r9 + + movq %r10,(%r9) + movq %r11,8(%r9) + popq %r15 + + popq %r14 + + popq %r13 + + popq %r12 + + popq %rbx + + popq %rbp + + ret + +L$open_sse_128: + + movdqu L$chacha20_consts(%rip),%xmm0 + movdqa %xmm0,%xmm1 + movdqa %xmm0,%xmm2 + movdqu 0(%r9),%xmm4 + movdqa %xmm4,%xmm5 + movdqa %xmm4,%xmm6 + movdqu 16(%r9),%xmm8 + movdqa %xmm8,%xmm9 + movdqa %xmm8,%xmm10 + movdqu 32(%r9),%xmm12 + movdqa %xmm12,%xmm13 + paddd L$sse_inc(%rip),%xmm13 + movdqa %xmm13,%xmm14 + paddd L$sse_inc(%rip),%xmm14 + movdqa %xmm4,%xmm7 + movdqa %xmm8,%xmm11 + movdqa %xmm13,%xmm15 + movq $10,%r10 + +L$open_sse_128_rounds: + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,4 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,12 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb L$rol16(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm5 + pxor %xmm3,%xmm5 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb L$rol8(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm5 + pxor %xmm3,%xmm5 +.byte 102,15,58,15,237,4 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,12 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb L$rol16(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm6 + pxor %xmm3,%xmm6 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb L$rol8(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm6 + pxor %xmm3,%xmm6 +.byte 102,15,58,15,246,4 +.byte 102,69,15,58,15,210,8 +.byte 102,69,15,58,15,246,12 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,12 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,4 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb L$rol16(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm5 + pxor %xmm3,%xmm5 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb L$rol8(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm5 + pxor %xmm3,%xmm5 +.byte 102,15,58,15,237,12 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,4 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb L$rol16(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm6 + pxor %xmm3,%xmm6 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb L$rol8(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm6 + pxor %xmm3,%xmm6 +.byte 102,15,58,15,246,12 +.byte 102,69,15,58,15,210,8 +.byte 102,69,15,58,15,246,4 + + decq %r10 + jnz L$open_sse_128_rounds + paddd L$chacha20_consts(%rip),%xmm0 + paddd L$chacha20_consts(%rip),%xmm1 + paddd L$chacha20_consts(%rip),%xmm2 + paddd %xmm7,%xmm4 + paddd %xmm7,%xmm5 + paddd %xmm7,%xmm6 + paddd %xmm11,%xmm9 + paddd %xmm11,%xmm10 + paddd %xmm15,%xmm13 + paddd L$sse_inc(%rip),%xmm15 + paddd %xmm15,%xmm14 + + pand L$clamp(%rip),%xmm0 + movdqa %xmm0,0+0(%rbp) + movdqa %xmm4,0+16(%rbp) + + movq %r8,%r8 + call poly_hash_ad_internal +L$open_sse_128_xor_hash: + cmpq $16,%rbx + jb L$open_sse_tail_16 + subq $16,%rbx + addq 0+0(%rsi),%r10 + adcq 8+0(%rsi),%r11 + adcq $1,%r12 + + + movdqu 0(%rsi),%xmm3 + pxor %xmm3,%xmm1 + movdqu %xmm1,0(%rdi) + leaq 16(%rsi),%rsi + leaq 16(%rdi),%rdi + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + + movdqa %xmm5,%xmm1 + movdqa %xmm9,%xmm5 + movdqa %xmm13,%xmm9 + movdqa %xmm2,%xmm13 + movdqa %xmm6,%xmm2 + movdqa %xmm10,%xmm6 + movdqa %xmm14,%xmm10 + jmp L$open_sse_128_xor_hash + + + + + + + + + +.globl _chacha20_poly1305_seal_sse41 +.private_extern _chacha20_poly1305_seal_sse41 + +.p2align 6 +_chacha20_poly1305_seal_sse41: + +_CET_ENDBR + pushq %rbp + + pushq %rbx + + pushq %r12 + + pushq %r13 + + pushq %r14 + + pushq %r15 + + + + pushq %r9 + + subq $288 + 0 + 32,%rsp + + leaq 32(%rsp),%rbp + andq $-32,%rbp + + movq 56(%r9),%rbx + addq %rdx,%rbx + movq %r8,0+0+32(%rbp) + movq %rbx,8+0+32(%rbp) + movq %rdx,%rbx + + cmpq $128,%rbx + jbe L$seal_sse_128 + + movdqa L$chacha20_consts(%rip),%xmm0 + movdqu 0(%r9),%xmm4 + movdqu 16(%r9),%xmm8 + movdqu 32(%r9),%xmm12 + + movdqa %xmm0,%xmm1 + movdqa %xmm0,%xmm2 + movdqa %xmm0,%xmm3 + movdqa %xmm4,%xmm5 + movdqa %xmm4,%xmm6 + movdqa %xmm4,%xmm7 + movdqa %xmm8,%xmm9 + movdqa %xmm8,%xmm10 + movdqa %xmm8,%xmm11 + movdqa %xmm12,%xmm15 + paddd L$sse_inc(%rip),%xmm12 + movdqa %xmm12,%xmm14 + paddd L$sse_inc(%rip),%xmm12 + movdqa %xmm12,%xmm13 + paddd L$sse_inc(%rip),%xmm12 + + movdqa %xmm4,0+48(%rbp) + movdqa %xmm8,0+64(%rbp) + movdqa %xmm12,0+96(%rbp) + movdqa %xmm13,0+112(%rbp) + movdqa %xmm14,0+128(%rbp) + movdqa %xmm15,0+144(%rbp) + movq $10,%r10 +L$seal_sse_init_rounds: + movdqa %xmm8,0+80(%rbp) + movdqa L$rol16(%rip),%xmm8 + paddd %xmm7,%xmm3 + paddd %xmm6,%xmm2 + paddd %xmm5,%xmm1 + paddd %xmm4,%xmm0 + pxor %xmm3,%xmm15 + pxor %xmm2,%xmm14 + pxor %xmm1,%xmm13 + pxor %xmm0,%xmm12 +.byte 102,69,15,56,0,248 +.byte 102,69,15,56,0,240 +.byte 102,69,15,56,0,232 +.byte 102,69,15,56,0,224 + movdqa 0+80(%rbp),%xmm8 + paddd %xmm15,%xmm11 + paddd %xmm14,%xmm10 + paddd %xmm13,%xmm9 + paddd %xmm12,%xmm8 + pxor %xmm11,%xmm7 + pxor %xmm10,%xmm6 + pxor %xmm9,%xmm5 + pxor %xmm8,%xmm4 + movdqa %xmm8,0+80(%rbp) + movdqa %xmm7,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm7 + pxor %xmm8,%xmm7 + movdqa %xmm6,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm6 + pxor %xmm8,%xmm6 + movdqa %xmm5,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm5 + pxor %xmm8,%xmm5 + movdqa %xmm4,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm4 + pxor %xmm8,%xmm4 + movdqa L$rol8(%rip),%xmm8 + paddd %xmm7,%xmm3 + paddd %xmm6,%xmm2 + paddd %xmm5,%xmm1 + paddd %xmm4,%xmm0 + pxor %xmm3,%xmm15 + pxor %xmm2,%xmm14 + pxor %xmm1,%xmm13 + pxor %xmm0,%xmm12 +.byte 102,69,15,56,0,248 +.byte 102,69,15,56,0,240 +.byte 102,69,15,56,0,232 +.byte 102,69,15,56,0,224 + movdqa 0+80(%rbp),%xmm8 + paddd %xmm15,%xmm11 + paddd %xmm14,%xmm10 + paddd %xmm13,%xmm9 + paddd %xmm12,%xmm8 + pxor %xmm11,%xmm7 + pxor %xmm10,%xmm6 + pxor %xmm9,%xmm5 + pxor %xmm8,%xmm4 + movdqa %xmm8,0+80(%rbp) + movdqa %xmm7,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm7 + pxor %xmm8,%xmm7 + movdqa %xmm6,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm6 + pxor %xmm8,%xmm6 + movdqa %xmm5,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm5 + pxor %xmm8,%xmm5 + movdqa %xmm4,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm4 + pxor %xmm8,%xmm4 + movdqa 0+80(%rbp),%xmm8 +.byte 102,15,58,15,255,4 +.byte 102,69,15,58,15,219,8 +.byte 102,69,15,58,15,255,12 +.byte 102,15,58,15,246,4 +.byte 102,69,15,58,15,210,8 +.byte 102,69,15,58,15,246,12 +.byte 102,15,58,15,237,4 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,12 +.byte 102,15,58,15,228,4 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,12 + movdqa %xmm8,0+80(%rbp) + movdqa L$rol16(%rip),%xmm8 + paddd %xmm7,%xmm3 + paddd %xmm6,%xmm2 + paddd %xmm5,%xmm1 + paddd %xmm4,%xmm0 + pxor %xmm3,%xmm15 + pxor %xmm2,%xmm14 + pxor %xmm1,%xmm13 + pxor %xmm0,%xmm12 +.byte 102,69,15,56,0,248 +.byte 102,69,15,56,0,240 +.byte 102,69,15,56,0,232 +.byte 102,69,15,56,0,224 + movdqa 0+80(%rbp),%xmm8 + paddd %xmm15,%xmm11 + paddd %xmm14,%xmm10 + paddd %xmm13,%xmm9 + paddd %xmm12,%xmm8 + pxor %xmm11,%xmm7 + pxor %xmm10,%xmm6 + pxor %xmm9,%xmm5 + pxor %xmm8,%xmm4 + movdqa %xmm8,0+80(%rbp) + movdqa %xmm7,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm7 + pxor %xmm8,%xmm7 + movdqa %xmm6,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm6 + pxor %xmm8,%xmm6 + movdqa %xmm5,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm5 + pxor %xmm8,%xmm5 + movdqa %xmm4,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm4 + pxor %xmm8,%xmm4 + movdqa L$rol8(%rip),%xmm8 + paddd %xmm7,%xmm3 + paddd %xmm6,%xmm2 + paddd %xmm5,%xmm1 + paddd %xmm4,%xmm0 + pxor %xmm3,%xmm15 + pxor %xmm2,%xmm14 + pxor %xmm1,%xmm13 + pxor %xmm0,%xmm12 +.byte 102,69,15,56,0,248 +.byte 102,69,15,56,0,240 +.byte 102,69,15,56,0,232 +.byte 102,69,15,56,0,224 + movdqa 0+80(%rbp),%xmm8 + paddd %xmm15,%xmm11 + paddd %xmm14,%xmm10 + paddd %xmm13,%xmm9 + paddd %xmm12,%xmm8 + pxor %xmm11,%xmm7 + pxor %xmm10,%xmm6 + pxor %xmm9,%xmm5 + pxor %xmm8,%xmm4 + movdqa %xmm8,0+80(%rbp) + movdqa %xmm7,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm7 + pxor %xmm8,%xmm7 + movdqa %xmm6,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm6 + pxor %xmm8,%xmm6 + movdqa %xmm5,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm5 + pxor %xmm8,%xmm5 + movdqa %xmm4,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm4 + pxor %xmm8,%xmm4 + movdqa 0+80(%rbp),%xmm8 +.byte 102,15,58,15,255,12 +.byte 102,69,15,58,15,219,8 +.byte 102,69,15,58,15,255,4 +.byte 102,15,58,15,246,12 +.byte 102,69,15,58,15,210,8 +.byte 102,69,15,58,15,246,4 +.byte 102,15,58,15,237,12 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,4 +.byte 102,15,58,15,228,12 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,4 + + decq %r10 + jnz L$seal_sse_init_rounds + paddd L$chacha20_consts(%rip),%xmm3 + paddd 0+48(%rbp),%xmm7 + paddd 0+64(%rbp),%xmm11 + paddd 0+144(%rbp),%xmm15 + paddd L$chacha20_consts(%rip),%xmm2 + paddd 0+48(%rbp),%xmm6 + paddd 0+64(%rbp),%xmm10 + paddd 0+128(%rbp),%xmm14 + paddd L$chacha20_consts(%rip),%xmm1 + paddd 0+48(%rbp),%xmm5 + paddd 0+64(%rbp),%xmm9 + paddd 0+112(%rbp),%xmm13 + paddd L$chacha20_consts(%rip),%xmm0 + paddd 0+48(%rbp),%xmm4 + paddd 0+64(%rbp),%xmm8 + paddd 0+96(%rbp),%xmm12 + + + pand L$clamp(%rip),%xmm3 + movdqa %xmm3,0+0(%rbp) + movdqa %xmm7,0+16(%rbp) + + movq %r8,%r8 + call poly_hash_ad_internal + movdqu 0 + 0(%rsi),%xmm3 + movdqu 16 + 0(%rsi),%xmm7 + movdqu 32 + 0(%rsi),%xmm11 + movdqu 48 + 0(%rsi),%xmm15 + pxor %xmm3,%xmm2 + pxor %xmm7,%xmm6 + pxor %xmm11,%xmm10 + pxor %xmm14,%xmm15 + movdqu %xmm2,0 + 0(%rdi) + movdqu %xmm6,16 + 0(%rdi) + movdqu %xmm10,32 + 0(%rdi) + movdqu %xmm15,48 + 0(%rdi) + movdqu 0 + 64(%rsi),%xmm3 + movdqu 16 + 64(%rsi),%xmm7 + movdqu 32 + 64(%rsi),%xmm11 + movdqu 48 + 64(%rsi),%xmm15 + pxor %xmm3,%xmm1 + pxor %xmm7,%xmm5 + pxor %xmm11,%xmm9 + pxor %xmm13,%xmm15 + movdqu %xmm1,0 + 64(%rdi) + movdqu %xmm5,16 + 64(%rdi) + movdqu %xmm9,32 + 64(%rdi) + movdqu %xmm15,48 + 64(%rdi) + + cmpq $192,%rbx + ja L$seal_sse_main_init + movq $128,%rcx + subq $128,%rbx + leaq 128(%rsi),%rsi + jmp L$seal_sse_128_tail_hash +L$seal_sse_main_init: + movdqu 0 + 128(%rsi),%xmm3 + movdqu 16 + 128(%rsi),%xmm7 + movdqu 32 + 128(%rsi),%xmm11 + movdqu 48 + 128(%rsi),%xmm15 + pxor %xmm3,%xmm0 + pxor %xmm7,%xmm4 + pxor %xmm11,%xmm8 + pxor %xmm12,%xmm15 + movdqu %xmm0,0 + 128(%rdi) + movdqu %xmm4,16 + 128(%rdi) + movdqu %xmm8,32 + 128(%rdi) + movdqu %xmm15,48 + 128(%rdi) + + movq $192,%rcx + subq $192,%rbx + leaq 192(%rsi),%rsi + movq $2,%rcx + movq $8,%r8 + cmpq $64,%rbx + jbe L$seal_sse_tail_64 + cmpq $128,%rbx + jbe L$seal_sse_tail_128 + cmpq $192,%rbx + jbe L$seal_sse_tail_192 + +L$seal_sse_main_loop: + movdqa L$chacha20_consts(%rip),%xmm0 + movdqa 0+48(%rbp),%xmm4 + movdqa 0+64(%rbp),%xmm8 + movdqa %xmm0,%xmm1 + movdqa %xmm4,%xmm5 + movdqa %xmm8,%xmm9 + movdqa %xmm0,%xmm2 + movdqa %xmm4,%xmm6 + movdqa %xmm8,%xmm10 + movdqa %xmm0,%xmm3 + movdqa %xmm4,%xmm7 + movdqa %xmm8,%xmm11 + movdqa 0+96(%rbp),%xmm15 + paddd L$sse_inc(%rip),%xmm15 + movdqa %xmm15,%xmm14 + paddd L$sse_inc(%rip),%xmm14 + movdqa %xmm14,%xmm13 + paddd L$sse_inc(%rip),%xmm13 + movdqa %xmm13,%xmm12 + paddd L$sse_inc(%rip),%xmm12 + movdqa %xmm12,0+96(%rbp) + movdqa %xmm13,0+112(%rbp) + movdqa %xmm14,0+128(%rbp) + movdqa %xmm15,0+144(%rbp) + +.p2align 5 +L$seal_sse_main_rounds: + movdqa %xmm8,0+80(%rbp) + movdqa L$rol16(%rip),%xmm8 + paddd %xmm7,%xmm3 + paddd %xmm6,%xmm2 + paddd %xmm5,%xmm1 + paddd %xmm4,%xmm0 + pxor %xmm3,%xmm15 + pxor %xmm2,%xmm14 + pxor %xmm1,%xmm13 + pxor %xmm0,%xmm12 +.byte 102,69,15,56,0,248 +.byte 102,69,15,56,0,240 +.byte 102,69,15,56,0,232 +.byte 102,69,15,56,0,224 + movdqa 0+80(%rbp),%xmm8 + paddd %xmm15,%xmm11 + paddd %xmm14,%xmm10 + paddd %xmm13,%xmm9 + paddd %xmm12,%xmm8 + pxor %xmm11,%xmm7 + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + pxor %xmm10,%xmm6 + pxor %xmm9,%xmm5 + pxor %xmm8,%xmm4 + movdqa %xmm8,0+80(%rbp) + movdqa %xmm7,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm7 + pxor %xmm8,%xmm7 + movdqa %xmm6,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm6 + pxor %xmm8,%xmm6 + movdqa %xmm5,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm5 + pxor %xmm8,%xmm5 + movdqa %xmm4,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm4 + pxor %xmm8,%xmm4 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movdqa L$rol8(%rip),%xmm8 + paddd %xmm7,%xmm3 + paddd %xmm6,%xmm2 + paddd %xmm5,%xmm1 + paddd %xmm4,%xmm0 + pxor %xmm3,%xmm15 + pxor %xmm2,%xmm14 + pxor %xmm1,%xmm13 + pxor %xmm0,%xmm12 +.byte 102,69,15,56,0,248 +.byte 102,69,15,56,0,240 +.byte 102,69,15,56,0,232 +.byte 102,69,15,56,0,224 + movdqa 0+80(%rbp),%xmm8 + paddd %xmm15,%xmm11 + paddd %xmm14,%xmm10 + paddd %xmm13,%xmm9 + paddd %xmm12,%xmm8 + pxor %xmm11,%xmm7 + pxor %xmm10,%xmm6 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + pxor %xmm9,%xmm5 + pxor %xmm8,%xmm4 + movdqa %xmm8,0+80(%rbp) + movdqa %xmm7,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm7 + pxor %xmm8,%xmm7 + movdqa %xmm6,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm6 + pxor %xmm8,%xmm6 + movdqa %xmm5,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm5 + pxor %xmm8,%xmm5 + movdqa %xmm4,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm4 + pxor %xmm8,%xmm4 + movdqa 0+80(%rbp),%xmm8 + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 +.byte 102,15,58,15,255,4 +.byte 102,69,15,58,15,219,8 +.byte 102,69,15,58,15,255,12 +.byte 102,15,58,15,246,4 +.byte 102,69,15,58,15,210,8 +.byte 102,69,15,58,15,246,12 +.byte 102,15,58,15,237,4 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,12 +.byte 102,15,58,15,228,4 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,12 + movdqa %xmm8,0+80(%rbp) + movdqa L$rol16(%rip),%xmm8 + paddd %xmm7,%xmm3 + paddd %xmm6,%xmm2 + paddd %xmm5,%xmm1 + paddd %xmm4,%xmm0 + pxor %xmm3,%xmm15 + pxor %xmm2,%xmm14 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + pxor %xmm1,%xmm13 + pxor %xmm0,%xmm12 +.byte 102,69,15,56,0,248 +.byte 102,69,15,56,0,240 +.byte 102,69,15,56,0,232 +.byte 102,69,15,56,0,224 + movdqa 0+80(%rbp),%xmm8 + paddd %xmm15,%xmm11 + paddd %xmm14,%xmm10 + paddd %xmm13,%xmm9 + paddd %xmm12,%xmm8 + pxor %xmm11,%xmm7 + pxor %xmm10,%xmm6 + pxor %xmm9,%xmm5 + pxor %xmm8,%xmm4 + movdqa %xmm8,0+80(%rbp) + movdqa %xmm7,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm7 + pxor %xmm8,%xmm7 + movdqa %xmm6,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm6 + pxor %xmm8,%xmm6 + movdqa %xmm5,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm5 + pxor %xmm8,%xmm5 + movdqa %xmm4,%xmm8 + psrld $20,%xmm8 + pslld $32-20,%xmm4 + pxor %xmm8,%xmm4 + movdqa L$rol8(%rip),%xmm8 + paddd %xmm7,%xmm3 + paddd %xmm6,%xmm2 + paddd %xmm5,%xmm1 + paddd %xmm4,%xmm0 + pxor %xmm3,%xmm15 + pxor %xmm2,%xmm14 + pxor %xmm1,%xmm13 + pxor %xmm0,%xmm12 +.byte 102,69,15,56,0,248 +.byte 102,69,15,56,0,240 +.byte 102,69,15,56,0,232 +.byte 102,69,15,56,0,224 + movdqa 0+80(%rbp),%xmm8 + paddd %xmm15,%xmm11 + paddd %xmm14,%xmm10 + paddd %xmm13,%xmm9 + paddd %xmm12,%xmm8 + pxor %xmm11,%xmm7 + pxor %xmm10,%xmm6 + pxor %xmm9,%xmm5 + pxor %xmm8,%xmm4 + movdqa %xmm8,0+80(%rbp) + movdqa %xmm7,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm7 + pxor %xmm8,%xmm7 + movdqa %xmm6,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm6 + pxor %xmm8,%xmm6 + movdqa %xmm5,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm5 + pxor %xmm8,%xmm5 + movdqa %xmm4,%xmm8 + psrld $25,%xmm8 + pslld $32-25,%xmm4 + pxor %xmm8,%xmm4 + movdqa 0+80(%rbp),%xmm8 +.byte 102,15,58,15,255,12 +.byte 102,69,15,58,15,219,8 +.byte 102,69,15,58,15,255,4 +.byte 102,15,58,15,246,12 +.byte 102,69,15,58,15,210,8 +.byte 102,69,15,58,15,246,4 +.byte 102,15,58,15,237,12 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,4 +.byte 102,15,58,15,228,12 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,4 + + leaq 16(%rdi),%rdi + decq %r8 + jge L$seal_sse_main_rounds + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%rdi),%rdi + decq %rcx + jg L$seal_sse_main_rounds + paddd L$chacha20_consts(%rip),%xmm3 + paddd 0+48(%rbp),%xmm7 + paddd 0+64(%rbp),%xmm11 + paddd 0+144(%rbp),%xmm15 + paddd L$chacha20_consts(%rip),%xmm2 + paddd 0+48(%rbp),%xmm6 + paddd 0+64(%rbp),%xmm10 + paddd 0+128(%rbp),%xmm14 + paddd L$chacha20_consts(%rip),%xmm1 + paddd 0+48(%rbp),%xmm5 + paddd 0+64(%rbp),%xmm9 + paddd 0+112(%rbp),%xmm13 + paddd L$chacha20_consts(%rip),%xmm0 + paddd 0+48(%rbp),%xmm4 + paddd 0+64(%rbp),%xmm8 + paddd 0+96(%rbp),%xmm12 + + movdqa %xmm14,0+80(%rbp) + movdqa %xmm14,0+80(%rbp) + movdqu 0 + 0(%rsi),%xmm14 + pxor %xmm3,%xmm14 + movdqu %xmm14,0 + 0(%rdi) + movdqu 16 + 0(%rsi),%xmm14 + pxor %xmm7,%xmm14 + movdqu %xmm14,16 + 0(%rdi) + movdqu 32 + 0(%rsi),%xmm14 + pxor %xmm11,%xmm14 + movdqu %xmm14,32 + 0(%rdi) + movdqu 48 + 0(%rsi),%xmm14 + pxor %xmm15,%xmm14 + movdqu %xmm14,48 + 0(%rdi) + + movdqa 0+80(%rbp),%xmm14 + movdqu 0 + 64(%rsi),%xmm3 + movdqu 16 + 64(%rsi),%xmm7 + movdqu 32 + 64(%rsi),%xmm11 + movdqu 48 + 64(%rsi),%xmm15 + pxor %xmm3,%xmm2 + pxor %xmm7,%xmm6 + pxor %xmm11,%xmm10 + pxor %xmm14,%xmm15 + movdqu %xmm2,0 + 64(%rdi) + movdqu %xmm6,16 + 64(%rdi) + movdqu %xmm10,32 + 64(%rdi) + movdqu %xmm15,48 + 64(%rdi) + movdqu 0 + 128(%rsi),%xmm3 + movdqu 16 + 128(%rsi),%xmm7 + movdqu 32 + 128(%rsi),%xmm11 + movdqu 48 + 128(%rsi),%xmm15 + pxor %xmm3,%xmm1 + pxor %xmm7,%xmm5 + pxor %xmm11,%xmm9 + pxor %xmm13,%xmm15 + movdqu %xmm1,0 + 128(%rdi) + movdqu %xmm5,16 + 128(%rdi) + movdqu %xmm9,32 + 128(%rdi) + movdqu %xmm15,48 + 128(%rdi) + + cmpq $256,%rbx + ja L$seal_sse_main_loop_xor + + movq $192,%rcx + subq $192,%rbx + leaq 192(%rsi),%rsi + jmp L$seal_sse_128_tail_hash +L$seal_sse_main_loop_xor: + movdqu 0 + 192(%rsi),%xmm3 + movdqu 16 + 192(%rsi),%xmm7 + movdqu 32 + 192(%rsi),%xmm11 + movdqu 48 + 192(%rsi),%xmm15 + pxor %xmm3,%xmm0 + pxor %xmm7,%xmm4 + pxor %xmm11,%xmm8 + pxor %xmm12,%xmm15 + movdqu %xmm0,0 + 192(%rdi) + movdqu %xmm4,16 + 192(%rdi) + movdqu %xmm8,32 + 192(%rdi) + movdqu %xmm15,48 + 192(%rdi) + + leaq 256(%rsi),%rsi + subq $256,%rbx + movq $6,%rcx + movq $4,%r8 + cmpq $192,%rbx + jg L$seal_sse_main_loop + movq %rbx,%rcx + testq %rbx,%rbx + je L$seal_sse_128_tail_hash + movq $6,%rcx + cmpq $128,%rbx + ja L$seal_sse_tail_192 + cmpq $64,%rbx + ja L$seal_sse_tail_128 + +L$seal_sse_tail_64: + movdqa L$chacha20_consts(%rip),%xmm0 + movdqa 0+48(%rbp),%xmm4 + movdqa 0+64(%rbp),%xmm8 + movdqa 0+96(%rbp),%xmm12 + paddd L$sse_inc(%rip),%xmm12 + movdqa %xmm12,0+96(%rbp) + +L$seal_sse_tail_64_rounds_and_x2hash: + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%rdi),%rdi +L$seal_sse_tail_64_rounds_and_x1hash: + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,4 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,12 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,12 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,4 + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%rdi),%rdi + decq %rcx + jg L$seal_sse_tail_64_rounds_and_x2hash + decq %r8 + jge L$seal_sse_tail_64_rounds_and_x1hash + paddd L$chacha20_consts(%rip),%xmm0 + paddd 0+48(%rbp),%xmm4 + paddd 0+64(%rbp),%xmm8 + paddd 0+96(%rbp),%xmm12 + + jmp L$seal_sse_128_tail_xor + +L$seal_sse_tail_128: + movdqa L$chacha20_consts(%rip),%xmm0 + movdqa 0+48(%rbp),%xmm4 + movdqa 0+64(%rbp),%xmm8 + movdqa %xmm0,%xmm1 + movdqa %xmm4,%xmm5 + movdqa %xmm8,%xmm9 + movdqa 0+96(%rbp),%xmm13 + paddd L$sse_inc(%rip),%xmm13 + movdqa %xmm13,%xmm12 + paddd L$sse_inc(%rip),%xmm12 + movdqa %xmm12,0+96(%rbp) + movdqa %xmm13,0+112(%rbp) + +L$seal_sse_tail_128_rounds_and_x2hash: + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%rdi),%rdi +L$seal_sse_tail_128_rounds_and_x1hash: + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,4 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,12 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb L$rol16(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm5 + pxor %xmm3,%xmm5 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb L$rol8(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm5 + pxor %xmm3,%xmm5 +.byte 102,15,58,15,237,4 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,12 + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,12 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,4 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb L$rol16(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm5 + pxor %xmm3,%xmm5 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb L$rol8(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm5 + pxor %xmm3,%xmm5 +.byte 102,15,58,15,237,12 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,4 + + leaq 16(%rdi),%rdi + decq %rcx + jg L$seal_sse_tail_128_rounds_and_x2hash + decq %r8 + jge L$seal_sse_tail_128_rounds_and_x1hash + paddd L$chacha20_consts(%rip),%xmm1 + paddd 0+48(%rbp),%xmm5 + paddd 0+64(%rbp),%xmm9 + paddd 0+112(%rbp),%xmm13 + paddd L$chacha20_consts(%rip),%xmm0 + paddd 0+48(%rbp),%xmm4 + paddd 0+64(%rbp),%xmm8 + paddd 0+96(%rbp),%xmm12 + movdqu 0 + 0(%rsi),%xmm3 + movdqu 16 + 0(%rsi),%xmm7 + movdqu 32 + 0(%rsi),%xmm11 + movdqu 48 + 0(%rsi),%xmm15 + pxor %xmm3,%xmm1 + pxor %xmm7,%xmm5 + pxor %xmm11,%xmm9 + pxor %xmm13,%xmm15 + movdqu %xmm1,0 + 0(%rdi) + movdqu %xmm5,16 + 0(%rdi) + movdqu %xmm9,32 + 0(%rdi) + movdqu %xmm15,48 + 0(%rdi) + + movq $64,%rcx + subq $64,%rbx + leaq 64(%rsi),%rsi + jmp L$seal_sse_128_tail_hash + +L$seal_sse_tail_192: + movdqa L$chacha20_consts(%rip),%xmm0 + movdqa 0+48(%rbp),%xmm4 + movdqa 0+64(%rbp),%xmm8 + movdqa %xmm0,%xmm1 + movdqa %xmm4,%xmm5 + movdqa %xmm8,%xmm9 + movdqa %xmm0,%xmm2 + movdqa %xmm4,%xmm6 + movdqa %xmm8,%xmm10 + movdqa 0+96(%rbp),%xmm14 + paddd L$sse_inc(%rip),%xmm14 + movdqa %xmm14,%xmm13 + paddd L$sse_inc(%rip),%xmm13 + movdqa %xmm13,%xmm12 + paddd L$sse_inc(%rip),%xmm12 + movdqa %xmm12,0+96(%rbp) + movdqa %xmm13,0+112(%rbp) + movdqa %xmm14,0+128(%rbp) + +L$seal_sse_tail_192_rounds_and_x2hash: + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%rdi),%rdi +L$seal_sse_tail_192_rounds_and_x1hash: + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,4 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,12 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb L$rol16(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm5 + pxor %xmm3,%xmm5 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb L$rol8(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm5 + pxor %xmm3,%xmm5 +.byte 102,15,58,15,237,4 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,12 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb L$rol16(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm6 + pxor %xmm3,%xmm6 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb L$rol8(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm6 + pxor %xmm3,%xmm6 +.byte 102,15,58,15,246,4 +.byte 102,69,15,58,15,210,8 +.byte 102,69,15,58,15,246,12 + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,12 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,4 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb L$rol16(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm5 + pxor %xmm3,%xmm5 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb L$rol8(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm5 + pxor %xmm3,%xmm5 +.byte 102,15,58,15,237,12 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,4 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb L$rol16(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm6 + pxor %xmm3,%xmm6 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb L$rol8(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm6 + pxor %xmm3,%xmm6 +.byte 102,15,58,15,246,12 +.byte 102,69,15,58,15,210,8 +.byte 102,69,15,58,15,246,4 + + leaq 16(%rdi),%rdi + decq %rcx + jg L$seal_sse_tail_192_rounds_and_x2hash + decq %r8 + jge L$seal_sse_tail_192_rounds_and_x1hash + paddd L$chacha20_consts(%rip),%xmm2 + paddd 0+48(%rbp),%xmm6 + paddd 0+64(%rbp),%xmm10 + paddd 0+128(%rbp),%xmm14 + paddd L$chacha20_consts(%rip),%xmm1 + paddd 0+48(%rbp),%xmm5 + paddd 0+64(%rbp),%xmm9 + paddd 0+112(%rbp),%xmm13 + paddd L$chacha20_consts(%rip),%xmm0 + paddd 0+48(%rbp),%xmm4 + paddd 0+64(%rbp),%xmm8 + paddd 0+96(%rbp),%xmm12 + movdqu 0 + 0(%rsi),%xmm3 + movdqu 16 + 0(%rsi),%xmm7 + movdqu 32 + 0(%rsi),%xmm11 + movdqu 48 + 0(%rsi),%xmm15 + pxor %xmm3,%xmm2 + pxor %xmm7,%xmm6 + pxor %xmm11,%xmm10 + pxor %xmm14,%xmm15 + movdqu %xmm2,0 + 0(%rdi) + movdqu %xmm6,16 + 0(%rdi) + movdqu %xmm10,32 + 0(%rdi) + movdqu %xmm15,48 + 0(%rdi) + movdqu 0 + 64(%rsi),%xmm3 + movdqu 16 + 64(%rsi),%xmm7 + movdqu 32 + 64(%rsi),%xmm11 + movdqu 48 + 64(%rsi),%xmm15 + pxor %xmm3,%xmm1 + pxor %xmm7,%xmm5 + pxor %xmm11,%xmm9 + pxor %xmm13,%xmm15 + movdqu %xmm1,0 + 64(%rdi) + movdqu %xmm5,16 + 64(%rdi) + movdqu %xmm9,32 + 64(%rdi) + movdqu %xmm15,48 + 64(%rdi) + + movq $128,%rcx + subq $128,%rbx + leaq 128(%rsi),%rsi + +L$seal_sse_128_tail_hash: + cmpq $16,%rcx + jb L$seal_sse_128_tail_xor + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + subq $16,%rcx + leaq 16(%rdi),%rdi + jmp L$seal_sse_128_tail_hash + +L$seal_sse_128_tail_xor: + cmpq $16,%rbx + jb L$seal_sse_tail_16 + subq $16,%rbx + + movdqu 0(%rsi),%xmm3 + pxor %xmm3,%xmm0 + movdqu %xmm0,0(%rdi) + + addq 0(%rdi),%r10 + adcq 8(%rdi),%r11 + adcq $1,%r12 + leaq 16(%rsi),%rsi + leaq 16(%rdi),%rdi + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + + movdqa %xmm4,%xmm0 + movdqa %xmm8,%xmm4 + movdqa %xmm12,%xmm8 + movdqa %xmm1,%xmm12 + movdqa %xmm5,%xmm1 + movdqa %xmm9,%xmm5 + movdqa %xmm13,%xmm9 + jmp L$seal_sse_128_tail_xor + +L$seal_sse_tail_16: + testq %rbx,%rbx + jz L$process_blocks_of_extra_in + + movq %rbx,%r8 + movq %rbx,%rcx + leaq -1(%rsi,%rbx,1),%rsi + pxor %xmm15,%xmm15 +L$seal_sse_tail_16_compose: + pslldq $1,%xmm15 + pinsrb $0,(%rsi),%xmm15 + leaq -1(%rsi),%rsi + decq %rcx + jne L$seal_sse_tail_16_compose + + + pxor %xmm0,%xmm15 + + + movq %rbx,%rcx + movdqu %xmm15,%xmm0 +L$seal_sse_tail_16_extract: + pextrb $0,%xmm0,(%rdi) + psrldq $1,%xmm0 + addq $1,%rdi + subq $1,%rcx + jnz L$seal_sse_tail_16_extract + + + + + + + + + movq 288 + 0 + 32(%rsp),%r9 + movq 56(%r9),%r14 + movq 48(%r9),%r13 + testq %r14,%r14 + jz L$process_partial_block + + movq $16,%r15 + subq %rbx,%r15 + cmpq %r15,%r14 + + jge L$load_extra_in + movq %r14,%r15 + +L$load_extra_in: + + + leaq -1(%r13,%r15,1),%rsi + + + addq %r15,%r13 + subq %r15,%r14 + movq %r13,48(%r9) + movq %r14,56(%r9) + + + + addq %r15,%r8 + + + pxor %xmm11,%xmm11 +L$load_extra_load_loop: + pslldq $1,%xmm11 + pinsrb $0,(%rsi),%xmm11 + leaq -1(%rsi),%rsi + subq $1,%r15 + jnz L$load_extra_load_loop + + + + + movq %rbx,%r15 + +L$load_extra_shift_loop: + pslldq $1,%xmm11 + subq $1,%r15 + jnz L$load_extra_shift_loop + + + + + leaq L$and_masks(%rip),%r15 + shlq $4,%rbx + pand -16(%r15,%rbx,1),%xmm15 + + + por %xmm11,%xmm15 + + + +.byte 102,77,15,126,253 + pextrq $1,%xmm15,%r14 + addq %r13,%r10 + adcq %r14,%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + +L$process_blocks_of_extra_in: + + movq 288+32+0 (%rsp),%r9 + movq 48(%r9),%rsi + movq 56(%r9),%r8 + movq %r8,%rcx + shrq $4,%r8 + +L$process_extra_hash_loop: + jz process_extra_in_trailer + addq 0+0(%rsi),%r10 + adcq 8+0(%rsi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%rsi),%rsi + subq $1,%r8 + jmp L$process_extra_hash_loop +process_extra_in_trailer: + andq $15,%rcx + movq %rcx,%rbx + jz L$do_length_block + leaq -1(%rsi,%rcx,1),%rsi + +L$process_extra_in_trailer_load: + pslldq $1,%xmm15 + pinsrb $0,(%rsi),%xmm15 + leaq -1(%rsi),%rsi + subq $1,%rcx + jnz L$process_extra_in_trailer_load + +L$process_partial_block: + + leaq L$and_masks(%rip),%r15 + shlq $4,%rbx + pand -16(%r15,%rbx,1),%xmm15 +.byte 102,77,15,126,253 + pextrq $1,%xmm15,%r14 + addq %r13,%r10 + adcq %r14,%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + +L$do_length_block: + addq 0+0+32(%rbp),%r10 + adcq 8+0+32(%rbp),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + + movq %r10,%r13 + movq %r11,%r14 + movq %r12,%r15 + subq $-5,%r10 + sbbq $-1,%r11 + sbbq $3,%r12 + cmovcq %r13,%r10 + cmovcq %r14,%r11 + cmovcq %r15,%r12 + + addq 0+0+16(%rbp),%r10 + adcq 8+0+16(%rbp),%r11 + + + addq $288 + 0 + 32,%rsp + + + popq %r9 + + movq %r10,(%r9) + movq %r11,8(%r9) + popq %r15 + + popq %r14 + + popq %r13 + + popq %r12 + + popq %rbx + + popq %rbp + + ret + +L$seal_sse_128: + + movdqu L$chacha20_consts(%rip),%xmm0 + movdqa %xmm0,%xmm1 + movdqa %xmm0,%xmm2 + movdqu 0(%r9),%xmm4 + movdqa %xmm4,%xmm5 + movdqa %xmm4,%xmm6 + movdqu 16(%r9),%xmm8 + movdqa %xmm8,%xmm9 + movdqa %xmm8,%xmm10 + movdqu 32(%r9),%xmm14 + movdqa %xmm14,%xmm12 + paddd L$sse_inc(%rip),%xmm12 + movdqa %xmm12,%xmm13 + paddd L$sse_inc(%rip),%xmm13 + movdqa %xmm4,%xmm7 + movdqa %xmm8,%xmm11 + movdqa %xmm12,%xmm15 + movq $10,%r10 + +L$seal_sse_128_rounds: + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,4 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,12 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb L$rol16(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm5 + pxor %xmm3,%xmm5 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb L$rol8(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm5 + pxor %xmm3,%xmm5 +.byte 102,15,58,15,237,4 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,12 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb L$rol16(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm6 + pxor %xmm3,%xmm6 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb L$rol8(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm6 + pxor %xmm3,%xmm6 +.byte 102,15,58,15,246,4 +.byte 102,69,15,58,15,210,8 +.byte 102,69,15,58,15,246,12 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol16(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm4 + pxor %xmm3,%xmm4 + paddd %xmm4,%xmm0 + pxor %xmm0,%xmm12 + pshufb L$rol8(%rip),%xmm12 + paddd %xmm12,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,15,228,12 +.byte 102,69,15,58,15,192,8 +.byte 102,69,15,58,15,228,4 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb L$rol16(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm5 + pxor %xmm3,%xmm5 + paddd %xmm5,%xmm1 + pxor %xmm1,%xmm13 + pshufb L$rol8(%rip),%xmm13 + paddd %xmm13,%xmm9 + pxor %xmm9,%xmm5 + movdqa %xmm5,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm5 + pxor %xmm3,%xmm5 +.byte 102,15,58,15,237,12 +.byte 102,69,15,58,15,201,8 +.byte 102,69,15,58,15,237,4 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb L$rol16(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm3 + pslld $12,%xmm3 + psrld $20,%xmm6 + pxor %xmm3,%xmm6 + paddd %xmm6,%xmm2 + pxor %xmm2,%xmm14 + pshufb L$rol8(%rip),%xmm14 + paddd %xmm14,%xmm10 + pxor %xmm10,%xmm6 + movdqa %xmm6,%xmm3 + pslld $7,%xmm3 + psrld $25,%xmm6 + pxor %xmm3,%xmm6 +.byte 102,15,58,15,246,12 +.byte 102,69,15,58,15,210,8 +.byte 102,69,15,58,15,246,4 + + decq %r10 + jnz L$seal_sse_128_rounds + paddd L$chacha20_consts(%rip),%xmm0 + paddd L$chacha20_consts(%rip),%xmm1 + paddd L$chacha20_consts(%rip),%xmm2 + paddd %xmm7,%xmm4 + paddd %xmm7,%xmm5 + paddd %xmm7,%xmm6 + paddd %xmm11,%xmm8 + paddd %xmm11,%xmm9 + paddd %xmm15,%xmm12 + paddd L$sse_inc(%rip),%xmm15 + paddd %xmm15,%xmm13 + + pand L$clamp(%rip),%xmm2 + movdqa %xmm2,0+0(%rbp) + movdqa %xmm6,0+16(%rbp) + + movq %r8,%r8 + call poly_hash_ad_internal + jmp L$seal_sse_128_tail_xor + + + + +.globl _chacha20_poly1305_open_avx2 +.private_extern _chacha20_poly1305_open_avx2 + +.p2align 6 +_chacha20_poly1305_open_avx2: + +_CET_ENDBR + pushq %rbp + + pushq %rbx + + pushq %r12 + + pushq %r13 + + pushq %r14 + + pushq %r15 + + + + pushq %r9 + + subq $288 + 0 + 32,%rsp + + + leaq 32(%rsp),%rbp + andq $-32,%rbp + + movq %rdx,%rbx + movq %r8,0+0+32(%rbp) + movq %rbx,8+0+32(%rbp) + + vzeroupper + vmovdqa L$chacha20_consts(%rip),%ymm0 + vbroadcasti128 0(%r9),%ymm4 + vbroadcasti128 16(%r9),%ymm8 + vbroadcasti128 32(%r9),%ymm12 + vpaddd L$avx2_init(%rip),%ymm12,%ymm12 + cmpq $192,%rbx + jbe L$open_avx2_192 + cmpq $320,%rbx + jbe L$open_avx2_320 + + vmovdqa %ymm4,0+64(%rbp) + vmovdqa %ymm8,0+96(%rbp) + vmovdqa %ymm12,0+160(%rbp) + movq $10,%r10 +L$open_avx2_init_rounds: + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $4,%ymm4,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $4,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm4,%ymm4,%ymm4 + + decq %r10 + jne L$open_avx2_init_rounds + vpaddd L$chacha20_consts(%rip),%ymm0,%ymm0 + vpaddd 0+64(%rbp),%ymm4,%ymm4 + vpaddd 0+96(%rbp),%ymm8,%ymm8 + vpaddd 0+160(%rbp),%ymm12,%ymm12 + + vperm2i128 $0x02,%ymm0,%ymm4,%ymm3 + + vpand L$clamp(%rip),%ymm3,%ymm3 + vmovdqa %ymm3,0+0(%rbp) + + vperm2i128 $0x13,%ymm0,%ymm4,%ymm0 + vperm2i128 $0x13,%ymm8,%ymm12,%ymm4 + + movq %r8,%r8 + call poly_hash_ad_internal + + xorq %rcx,%rcx +L$open_avx2_init_hash: + addq 0+0(%rsi,%rcx,1),%r10 + adcq 8+0(%rsi,%rcx,1),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + addq $16,%rcx + cmpq $64,%rcx + jne L$open_avx2_init_hash + + vpxor 0(%rsi),%ymm0,%ymm0 + vpxor 32(%rsi),%ymm4,%ymm4 + + vmovdqu %ymm0,0(%rdi) + vmovdqu %ymm4,32(%rdi) + leaq 64(%rsi),%rsi + leaq 64(%rdi),%rdi + subq $64,%rbx +L$open_avx2_main_loop: + + cmpq $512,%rbx + jb L$open_avx2_main_loop_done + vmovdqa L$chacha20_consts(%rip),%ymm0 + vmovdqa 0+64(%rbp),%ymm4 + vmovdqa 0+96(%rbp),%ymm8 + vmovdqa %ymm0,%ymm1 + vmovdqa %ymm4,%ymm5 + vmovdqa %ymm8,%ymm9 + vmovdqa %ymm0,%ymm2 + vmovdqa %ymm4,%ymm6 + vmovdqa %ymm8,%ymm10 + vmovdqa %ymm0,%ymm3 + vmovdqa %ymm4,%ymm7 + vmovdqa %ymm8,%ymm11 + vmovdqa L$avx2_inc(%rip),%ymm12 + vpaddd 0+160(%rbp),%ymm12,%ymm15 + vpaddd %ymm15,%ymm12,%ymm14 + vpaddd %ymm14,%ymm12,%ymm13 + vpaddd %ymm13,%ymm12,%ymm12 + vmovdqa %ymm15,0+256(%rbp) + vmovdqa %ymm14,0+224(%rbp) + vmovdqa %ymm13,0+192(%rbp) + vmovdqa %ymm12,0+160(%rbp) + + xorq %rcx,%rcx +L$open_avx2_main_loop_rounds: + addq 0+0(%rsi,%rcx,1),%r10 + adcq 8+0(%rsi,%rcx,1),%r11 + adcq $1,%r12 + vmovdqa %ymm8,0+128(%rbp) + vmovdqa L$rol16(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $20,%ymm7,%ymm8 + vpslld $32-20,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $20,%ymm6,%ymm8 + vpslld $32-20,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $20,%ymm5,%ymm8 + vpslld $32-20,%ymm5,%ymm5 + addq %rax,%r15 + adcq %rdx,%r9 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $20,%ymm4,%ymm8 + vpslld $32-20,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa L$rol8(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + addq 0+16(%rsi,%rcx,1),%r10 + adcq 8+16(%rsi,%rcx,1),%r11 + adcq $1,%r12 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $25,%ymm7,%ymm8 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + vpslld $32-25,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $25,%ymm6,%ymm8 + vpslld $32-25,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $25,%ymm5,%ymm8 + vpslld $32-25,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $25,%ymm4,%ymm8 + vpslld $32-25,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa 0+128(%rbp),%ymm8 + vpalignr $4,%ymm7,%ymm7,%ymm7 + vpalignr $8,%ymm11,%ymm11,%ymm11 + vpalignr $12,%ymm15,%ymm15,%ymm15 + vpalignr $4,%ymm6,%ymm6,%ymm6 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $12,%ymm14,%ymm14,%ymm14 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + vpalignr $4,%ymm5,%ymm5,%ymm5 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $12,%ymm13,%ymm13,%ymm13 + vpalignr $4,%ymm4,%ymm4,%ymm4 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vmovdqa %ymm8,0+128(%rbp) + vmovdqa L$rol16(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + addq %rax,%r15 + adcq %rdx,%r9 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $20,%ymm7,%ymm8 + vpslld $32-20,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $20,%ymm6,%ymm8 + vpslld $32-20,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + addq 0+32(%rsi,%rcx,1),%r10 + adcq 8+32(%rsi,%rcx,1),%r11 + adcq $1,%r12 + + leaq 48(%rcx),%rcx + vpsrld $20,%ymm5,%ymm8 + vpslld $32-20,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $20,%ymm4,%ymm8 + vpslld $32-20,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa L$rol8(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $25,%ymm7,%ymm8 + vpslld $32-25,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $25,%ymm6,%ymm8 + vpslld $32-25,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + addq %rax,%r15 + adcq %rdx,%r9 + vpsrld $25,%ymm5,%ymm8 + vpslld $32-25,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $25,%ymm4,%ymm8 + vpslld $32-25,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa 0+128(%rbp),%ymm8 + vpalignr $12,%ymm7,%ymm7,%ymm7 + vpalignr $8,%ymm11,%ymm11,%ymm11 + vpalignr $4,%ymm15,%ymm15,%ymm15 + vpalignr $12,%ymm6,%ymm6,%ymm6 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $4,%ymm14,%ymm14,%ymm14 + vpalignr $12,%ymm5,%ymm5,%ymm5 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $4,%ymm13,%ymm13,%ymm13 + vpalignr $12,%ymm4,%ymm4,%ymm4 + vpalignr $8,%ymm8,%ymm8,%ymm8 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + vpalignr $4,%ymm12,%ymm12,%ymm12 + + cmpq $60*8,%rcx + jne L$open_avx2_main_loop_rounds + vpaddd L$chacha20_consts(%rip),%ymm3,%ymm3 + vpaddd 0+64(%rbp),%ymm7,%ymm7 + vpaddd 0+96(%rbp),%ymm11,%ymm11 + vpaddd 0+256(%rbp),%ymm15,%ymm15 + vpaddd L$chacha20_consts(%rip),%ymm2,%ymm2 + vpaddd 0+64(%rbp),%ymm6,%ymm6 + vpaddd 0+96(%rbp),%ymm10,%ymm10 + vpaddd 0+224(%rbp),%ymm14,%ymm14 + vpaddd L$chacha20_consts(%rip),%ymm1,%ymm1 + vpaddd 0+64(%rbp),%ymm5,%ymm5 + vpaddd 0+96(%rbp),%ymm9,%ymm9 + vpaddd 0+192(%rbp),%ymm13,%ymm13 + vpaddd L$chacha20_consts(%rip),%ymm0,%ymm0 + vpaddd 0+64(%rbp),%ymm4,%ymm4 + vpaddd 0+96(%rbp),%ymm8,%ymm8 + vpaddd 0+160(%rbp),%ymm12,%ymm12 + + vmovdqa %ymm0,0+128(%rbp) + addq 0+60*8(%rsi),%r10 + adcq 8+60*8(%rsi),%r11 + adcq $1,%r12 + vperm2i128 $0x02,%ymm3,%ymm7,%ymm0 + vperm2i128 $0x13,%ymm3,%ymm7,%ymm7 + vperm2i128 $0x02,%ymm11,%ymm15,%ymm3 + vperm2i128 $0x13,%ymm11,%ymm15,%ymm11 + vpxor 0+0(%rsi),%ymm0,%ymm0 + vpxor 32+0(%rsi),%ymm3,%ymm3 + vpxor 64+0(%rsi),%ymm7,%ymm7 + vpxor 96+0(%rsi),%ymm11,%ymm11 + vmovdqu %ymm0,0+0(%rdi) + vmovdqu %ymm3,32+0(%rdi) + vmovdqu %ymm7,64+0(%rdi) + vmovdqu %ymm11,96+0(%rdi) + + vmovdqa 0+128(%rbp),%ymm0 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + vperm2i128 $0x02,%ymm2,%ymm6,%ymm3 + vperm2i128 $0x13,%ymm2,%ymm6,%ymm6 + vperm2i128 $0x02,%ymm10,%ymm14,%ymm2 + vperm2i128 $0x13,%ymm10,%ymm14,%ymm10 + vpxor 0+128(%rsi),%ymm3,%ymm3 + vpxor 32+128(%rsi),%ymm2,%ymm2 + vpxor 64+128(%rsi),%ymm6,%ymm6 + vpxor 96+128(%rsi),%ymm10,%ymm10 + vmovdqu %ymm3,0+128(%rdi) + vmovdqu %ymm2,32+128(%rdi) + vmovdqu %ymm6,64+128(%rdi) + vmovdqu %ymm10,96+128(%rdi) + addq 0+60*8+16(%rsi),%r10 + adcq 8+60*8+16(%rsi),%r11 + adcq $1,%r12 + vperm2i128 $0x02,%ymm1,%ymm5,%ymm3 + vperm2i128 $0x13,%ymm1,%ymm5,%ymm5 + vperm2i128 $0x02,%ymm9,%ymm13,%ymm1 + vperm2i128 $0x13,%ymm9,%ymm13,%ymm9 + vpxor 0+256(%rsi),%ymm3,%ymm3 + vpxor 32+256(%rsi),%ymm1,%ymm1 + vpxor 64+256(%rsi),%ymm5,%ymm5 + vpxor 96+256(%rsi),%ymm9,%ymm9 + vmovdqu %ymm3,0+256(%rdi) + vmovdqu %ymm1,32+256(%rdi) + vmovdqu %ymm5,64+256(%rdi) + vmovdqu %ymm9,96+256(%rdi) + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + vperm2i128 $0x02,%ymm0,%ymm4,%ymm3 + vperm2i128 $0x13,%ymm0,%ymm4,%ymm4 + vperm2i128 $0x02,%ymm8,%ymm12,%ymm0 + vperm2i128 $0x13,%ymm8,%ymm12,%ymm8 + vpxor 0+384(%rsi),%ymm3,%ymm3 + vpxor 32+384(%rsi),%ymm0,%ymm0 + vpxor 64+384(%rsi),%ymm4,%ymm4 + vpxor 96+384(%rsi),%ymm8,%ymm8 + vmovdqu %ymm3,0+384(%rdi) + vmovdqu %ymm0,32+384(%rdi) + vmovdqu %ymm4,64+384(%rdi) + vmovdqu %ymm8,96+384(%rdi) + + leaq 512(%rsi),%rsi + leaq 512(%rdi),%rdi + subq $512,%rbx + jmp L$open_avx2_main_loop +L$open_avx2_main_loop_done: + testq %rbx,%rbx + vzeroupper + je L$open_sse_finalize + + cmpq $384,%rbx + ja L$open_avx2_tail_512 + cmpq $256,%rbx + ja L$open_avx2_tail_384 + cmpq $128,%rbx + ja L$open_avx2_tail_256 + vmovdqa L$chacha20_consts(%rip),%ymm0 + vmovdqa 0+64(%rbp),%ymm4 + vmovdqa 0+96(%rbp),%ymm8 + vmovdqa L$avx2_inc(%rip),%ymm12 + vpaddd 0+160(%rbp),%ymm12,%ymm12 + vmovdqa %ymm12,0+160(%rbp) + + xorq %r8,%r8 + movq %rbx,%rcx + andq $-16,%rcx + testq %rcx,%rcx + je L$open_avx2_tail_128_rounds +L$open_avx2_tail_128_rounds_and_x1hash: + addq 0+0(%rsi,%r8,1),%r10 + adcq 8+0(%rsi,%r8,1),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + +L$open_avx2_tail_128_rounds: + addq $16,%r8 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $4,%ymm4,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $4,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm4,%ymm4,%ymm4 + + cmpq %rcx,%r8 + jb L$open_avx2_tail_128_rounds_and_x1hash + cmpq $160,%r8 + jne L$open_avx2_tail_128_rounds + vpaddd L$chacha20_consts(%rip),%ymm0,%ymm0 + vpaddd 0+64(%rbp),%ymm4,%ymm4 + vpaddd 0+96(%rbp),%ymm8,%ymm8 + vpaddd 0+160(%rbp),%ymm12,%ymm12 + vperm2i128 $0x13,%ymm0,%ymm4,%ymm3 + vperm2i128 $0x02,%ymm0,%ymm4,%ymm0 + vperm2i128 $0x02,%ymm8,%ymm12,%ymm4 + vperm2i128 $0x13,%ymm8,%ymm12,%ymm12 + vmovdqa %ymm3,%ymm8 + + jmp L$open_avx2_tail_128_xor + +L$open_avx2_tail_256: + vmovdqa L$chacha20_consts(%rip),%ymm0 + vmovdqa 0+64(%rbp),%ymm4 + vmovdqa 0+96(%rbp),%ymm8 + vmovdqa %ymm0,%ymm1 + vmovdqa %ymm4,%ymm5 + vmovdqa %ymm8,%ymm9 + vmovdqa L$avx2_inc(%rip),%ymm12 + vpaddd 0+160(%rbp),%ymm12,%ymm13 + vpaddd %ymm13,%ymm12,%ymm12 + vmovdqa %ymm12,0+160(%rbp) + vmovdqa %ymm13,0+192(%rbp) + + movq %rbx,0+128(%rbp) + movq %rbx,%rcx + subq $128,%rcx + shrq $4,%rcx + movq $10,%r8 + cmpq $10,%rcx + cmovgq %r8,%rcx + movq %rsi,%rbx + xorq %r8,%r8 +L$open_avx2_tail_256_rounds_and_x1hash: + addq 0+0(%rbx),%r10 + adcq 8+0(%rbx),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + addq %rax,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%rbx),%rbx +L$open_avx2_tail_256_rounds: + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $4,%ymm4,%ymm4,%ymm4 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb L$rol16(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpsrld $20,%ymm5,%ymm3 + vpslld $12,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb L$rol8(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpslld $7,%ymm5,%ymm3 + vpsrld $25,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpalignr $12,%ymm13,%ymm13,%ymm13 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $4,%ymm5,%ymm5,%ymm5 + + incq %r8 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $4,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm4,%ymm4,%ymm4 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb L$rol16(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpsrld $20,%ymm5,%ymm3 + vpslld $12,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb L$rol8(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpslld $7,%ymm5,%ymm3 + vpsrld $25,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpalignr $4,%ymm13,%ymm13,%ymm13 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $12,%ymm5,%ymm5,%ymm5 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb L$rol16(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpsrld $20,%ymm6,%ymm3 + vpslld $12,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb L$rol8(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpslld $7,%ymm6,%ymm3 + vpsrld $25,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpalignr $4,%ymm14,%ymm14,%ymm14 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $12,%ymm6,%ymm6,%ymm6 + + cmpq %rcx,%r8 + jb L$open_avx2_tail_256_rounds_and_x1hash + cmpq $10,%r8 + jne L$open_avx2_tail_256_rounds + movq %rbx,%r8 + subq %rsi,%rbx + movq %rbx,%rcx + movq 0+128(%rbp),%rbx +L$open_avx2_tail_256_hash: + addq $16,%rcx + cmpq %rbx,%rcx + jg L$open_avx2_tail_256_done + addq 0+0(%r8),%r10 + adcq 8+0(%r8),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + addq %rax,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%r8),%r8 + jmp L$open_avx2_tail_256_hash +L$open_avx2_tail_256_done: + vpaddd L$chacha20_consts(%rip),%ymm1,%ymm1 + vpaddd 0+64(%rbp),%ymm5,%ymm5 + vpaddd 0+96(%rbp),%ymm9,%ymm9 + vpaddd 0+192(%rbp),%ymm13,%ymm13 + vpaddd L$chacha20_consts(%rip),%ymm0,%ymm0 + vpaddd 0+64(%rbp),%ymm4,%ymm4 + vpaddd 0+96(%rbp),%ymm8,%ymm8 + vpaddd 0+160(%rbp),%ymm12,%ymm12 + vperm2i128 $0x02,%ymm1,%ymm5,%ymm3 + vperm2i128 $0x13,%ymm1,%ymm5,%ymm5 + vperm2i128 $0x02,%ymm9,%ymm13,%ymm1 + vperm2i128 $0x13,%ymm9,%ymm13,%ymm9 + vpxor 0+0(%rsi),%ymm3,%ymm3 + vpxor 32+0(%rsi),%ymm1,%ymm1 + vpxor 64+0(%rsi),%ymm5,%ymm5 + vpxor 96+0(%rsi),%ymm9,%ymm9 + vmovdqu %ymm3,0+0(%rdi) + vmovdqu %ymm1,32+0(%rdi) + vmovdqu %ymm5,64+0(%rdi) + vmovdqu %ymm9,96+0(%rdi) + vperm2i128 $0x13,%ymm0,%ymm4,%ymm3 + vperm2i128 $0x02,%ymm0,%ymm4,%ymm0 + vperm2i128 $0x02,%ymm8,%ymm12,%ymm4 + vperm2i128 $0x13,%ymm8,%ymm12,%ymm12 + vmovdqa %ymm3,%ymm8 + + leaq 128(%rsi),%rsi + leaq 128(%rdi),%rdi + subq $128,%rbx + jmp L$open_avx2_tail_128_xor + +L$open_avx2_tail_384: + vmovdqa L$chacha20_consts(%rip),%ymm0 + vmovdqa 0+64(%rbp),%ymm4 + vmovdqa 0+96(%rbp),%ymm8 + vmovdqa %ymm0,%ymm1 + vmovdqa %ymm4,%ymm5 + vmovdqa %ymm8,%ymm9 + vmovdqa %ymm0,%ymm2 + vmovdqa %ymm4,%ymm6 + vmovdqa %ymm8,%ymm10 + vmovdqa L$avx2_inc(%rip),%ymm12 + vpaddd 0+160(%rbp),%ymm12,%ymm14 + vpaddd %ymm14,%ymm12,%ymm13 + vpaddd %ymm13,%ymm12,%ymm12 + vmovdqa %ymm12,0+160(%rbp) + vmovdqa %ymm13,0+192(%rbp) + vmovdqa %ymm14,0+224(%rbp) + + movq %rbx,0+128(%rbp) + movq %rbx,%rcx + subq $256,%rcx + shrq $4,%rcx + addq $6,%rcx + movq $10,%r8 + cmpq $10,%rcx + cmovgq %r8,%rcx + movq %rsi,%rbx + xorq %r8,%r8 +L$open_avx2_tail_384_rounds_and_x2hash: + addq 0+0(%rbx),%r10 + adcq 8+0(%rbx),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + addq %rax,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%rbx),%rbx +L$open_avx2_tail_384_rounds_and_x1hash: + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb L$rol16(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpsrld $20,%ymm6,%ymm3 + vpslld $12,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb L$rol8(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpslld $7,%ymm6,%ymm3 + vpsrld $25,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpalignr $12,%ymm14,%ymm14,%ymm14 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $4,%ymm6,%ymm6,%ymm6 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb L$rol16(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpsrld $20,%ymm5,%ymm3 + vpslld $12,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb L$rol8(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpslld $7,%ymm5,%ymm3 + vpsrld $25,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpalignr $12,%ymm13,%ymm13,%ymm13 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $4,%ymm5,%ymm5,%ymm5 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $4,%ymm4,%ymm4,%ymm4 + addq 0+0(%rbx),%r10 + adcq 8+0(%rbx),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%rbx),%rbx + incq %r8 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb L$rol16(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpsrld $20,%ymm6,%ymm3 + vpslld $12,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb L$rol8(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpslld $7,%ymm6,%ymm3 + vpsrld $25,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpalignr $4,%ymm14,%ymm14,%ymm14 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $12,%ymm6,%ymm6,%ymm6 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb L$rol16(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpsrld $20,%ymm5,%ymm3 + vpslld $12,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb L$rol8(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpslld $7,%ymm5,%ymm3 + vpsrld $25,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpalignr $4,%ymm13,%ymm13,%ymm13 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $12,%ymm5,%ymm5,%ymm5 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $4,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm4,%ymm4,%ymm4 + + cmpq %rcx,%r8 + jb L$open_avx2_tail_384_rounds_and_x2hash + cmpq $10,%r8 + jne L$open_avx2_tail_384_rounds_and_x1hash + movq %rbx,%r8 + subq %rsi,%rbx + movq %rbx,%rcx + movq 0+128(%rbp),%rbx +L$open_avx2_384_tail_hash: + addq $16,%rcx + cmpq %rbx,%rcx + jg L$open_avx2_384_tail_done + addq 0+0(%r8),%r10 + adcq 8+0(%r8),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + addq %rax,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%r8),%r8 + jmp L$open_avx2_384_tail_hash +L$open_avx2_384_tail_done: + vpaddd L$chacha20_consts(%rip),%ymm2,%ymm2 + vpaddd 0+64(%rbp),%ymm6,%ymm6 + vpaddd 0+96(%rbp),%ymm10,%ymm10 + vpaddd 0+224(%rbp),%ymm14,%ymm14 + vpaddd L$chacha20_consts(%rip),%ymm1,%ymm1 + vpaddd 0+64(%rbp),%ymm5,%ymm5 + vpaddd 0+96(%rbp),%ymm9,%ymm9 + vpaddd 0+192(%rbp),%ymm13,%ymm13 + vpaddd L$chacha20_consts(%rip),%ymm0,%ymm0 + vpaddd 0+64(%rbp),%ymm4,%ymm4 + vpaddd 0+96(%rbp),%ymm8,%ymm8 + vpaddd 0+160(%rbp),%ymm12,%ymm12 + vperm2i128 $0x02,%ymm2,%ymm6,%ymm3 + vperm2i128 $0x13,%ymm2,%ymm6,%ymm6 + vperm2i128 $0x02,%ymm10,%ymm14,%ymm2 + vperm2i128 $0x13,%ymm10,%ymm14,%ymm10 + vpxor 0+0(%rsi),%ymm3,%ymm3 + vpxor 32+0(%rsi),%ymm2,%ymm2 + vpxor 64+0(%rsi),%ymm6,%ymm6 + vpxor 96+0(%rsi),%ymm10,%ymm10 + vmovdqu %ymm3,0+0(%rdi) + vmovdqu %ymm2,32+0(%rdi) + vmovdqu %ymm6,64+0(%rdi) + vmovdqu %ymm10,96+0(%rdi) + vperm2i128 $0x02,%ymm1,%ymm5,%ymm3 + vperm2i128 $0x13,%ymm1,%ymm5,%ymm5 + vperm2i128 $0x02,%ymm9,%ymm13,%ymm1 + vperm2i128 $0x13,%ymm9,%ymm13,%ymm9 + vpxor 0+128(%rsi),%ymm3,%ymm3 + vpxor 32+128(%rsi),%ymm1,%ymm1 + vpxor 64+128(%rsi),%ymm5,%ymm5 + vpxor 96+128(%rsi),%ymm9,%ymm9 + vmovdqu %ymm3,0+128(%rdi) + vmovdqu %ymm1,32+128(%rdi) + vmovdqu %ymm5,64+128(%rdi) + vmovdqu %ymm9,96+128(%rdi) + vperm2i128 $0x13,%ymm0,%ymm4,%ymm3 + vperm2i128 $0x02,%ymm0,%ymm4,%ymm0 + vperm2i128 $0x02,%ymm8,%ymm12,%ymm4 + vperm2i128 $0x13,%ymm8,%ymm12,%ymm12 + vmovdqa %ymm3,%ymm8 + + leaq 256(%rsi),%rsi + leaq 256(%rdi),%rdi + subq $256,%rbx + jmp L$open_avx2_tail_128_xor + +L$open_avx2_tail_512: + vmovdqa L$chacha20_consts(%rip),%ymm0 + vmovdqa 0+64(%rbp),%ymm4 + vmovdqa 0+96(%rbp),%ymm8 + vmovdqa %ymm0,%ymm1 + vmovdqa %ymm4,%ymm5 + vmovdqa %ymm8,%ymm9 + vmovdqa %ymm0,%ymm2 + vmovdqa %ymm4,%ymm6 + vmovdqa %ymm8,%ymm10 + vmovdqa %ymm0,%ymm3 + vmovdqa %ymm4,%ymm7 + vmovdqa %ymm8,%ymm11 + vmovdqa L$avx2_inc(%rip),%ymm12 + vpaddd 0+160(%rbp),%ymm12,%ymm15 + vpaddd %ymm15,%ymm12,%ymm14 + vpaddd %ymm14,%ymm12,%ymm13 + vpaddd %ymm13,%ymm12,%ymm12 + vmovdqa %ymm15,0+256(%rbp) + vmovdqa %ymm14,0+224(%rbp) + vmovdqa %ymm13,0+192(%rbp) + vmovdqa %ymm12,0+160(%rbp) + + xorq %rcx,%rcx + movq %rsi,%r8 +L$open_avx2_tail_512_rounds_and_x2hash: + addq 0+0(%r8),%r10 + adcq 8+0(%r8),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%r8),%r8 +L$open_avx2_tail_512_rounds_and_x1hash: + vmovdqa %ymm8,0+128(%rbp) + vmovdqa L$rol16(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $20,%ymm7,%ymm8 + vpslld $32-20,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $20,%ymm6,%ymm8 + vpslld $32-20,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $20,%ymm5,%ymm8 + vpslld $32-20,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $20,%ymm4,%ymm8 + vpslld $32-20,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa L$rol8(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + addq 0+0(%r8),%r10 + adcq 8+0(%r8),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + addq %rax,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $25,%ymm7,%ymm8 + vpslld $32-25,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $25,%ymm6,%ymm8 + vpslld $32-25,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $25,%ymm5,%ymm8 + vpslld $32-25,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $25,%ymm4,%ymm8 + vpslld $32-25,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa 0+128(%rbp),%ymm8 + vpalignr $4,%ymm7,%ymm7,%ymm7 + vpalignr $8,%ymm11,%ymm11,%ymm11 + vpalignr $12,%ymm15,%ymm15,%ymm15 + vpalignr $4,%ymm6,%ymm6,%ymm6 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $12,%ymm14,%ymm14,%ymm14 + vpalignr $4,%ymm5,%ymm5,%ymm5 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $12,%ymm13,%ymm13,%ymm13 + vpalignr $4,%ymm4,%ymm4,%ymm4 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vmovdqa %ymm8,0+128(%rbp) + vmovdqa L$rol16(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + addq 0+16(%r8),%r10 + adcq 8+16(%r8),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + addq %rax,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 32(%r8),%r8 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $20,%ymm7,%ymm8 + vpslld $32-20,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $20,%ymm6,%ymm8 + vpslld $32-20,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $20,%ymm5,%ymm8 + vpslld $32-20,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $20,%ymm4,%ymm8 + vpslld $32-20,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa L$rol8(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $25,%ymm7,%ymm8 + vpslld $32-25,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $25,%ymm6,%ymm8 + vpslld $32-25,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $25,%ymm5,%ymm8 + vpslld $32-25,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $25,%ymm4,%ymm8 + vpslld $32-25,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa 0+128(%rbp),%ymm8 + vpalignr $12,%ymm7,%ymm7,%ymm7 + vpalignr $8,%ymm11,%ymm11,%ymm11 + vpalignr $4,%ymm15,%ymm15,%ymm15 + vpalignr $12,%ymm6,%ymm6,%ymm6 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $4,%ymm14,%ymm14,%ymm14 + vpalignr $12,%ymm5,%ymm5,%ymm5 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $4,%ymm13,%ymm13,%ymm13 + vpalignr $12,%ymm4,%ymm4,%ymm4 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $4,%ymm12,%ymm12,%ymm12 + + incq %rcx + cmpq $4,%rcx + jl L$open_avx2_tail_512_rounds_and_x2hash + cmpq $10,%rcx + jne L$open_avx2_tail_512_rounds_and_x1hash + movq %rbx,%rcx + subq $384,%rcx + andq $-16,%rcx +L$open_avx2_tail_512_hash: + testq %rcx,%rcx + je L$open_avx2_tail_512_done + addq 0+0(%r8),%r10 + adcq 8+0(%r8),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + addq %rax,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%r8),%r8 + subq $16,%rcx + jmp L$open_avx2_tail_512_hash +L$open_avx2_tail_512_done: + vpaddd L$chacha20_consts(%rip),%ymm3,%ymm3 + vpaddd 0+64(%rbp),%ymm7,%ymm7 + vpaddd 0+96(%rbp),%ymm11,%ymm11 + vpaddd 0+256(%rbp),%ymm15,%ymm15 + vpaddd L$chacha20_consts(%rip),%ymm2,%ymm2 + vpaddd 0+64(%rbp),%ymm6,%ymm6 + vpaddd 0+96(%rbp),%ymm10,%ymm10 + vpaddd 0+224(%rbp),%ymm14,%ymm14 + vpaddd L$chacha20_consts(%rip),%ymm1,%ymm1 + vpaddd 0+64(%rbp),%ymm5,%ymm5 + vpaddd 0+96(%rbp),%ymm9,%ymm9 + vpaddd 0+192(%rbp),%ymm13,%ymm13 + vpaddd L$chacha20_consts(%rip),%ymm0,%ymm0 + vpaddd 0+64(%rbp),%ymm4,%ymm4 + vpaddd 0+96(%rbp),%ymm8,%ymm8 + vpaddd 0+160(%rbp),%ymm12,%ymm12 + + vmovdqa %ymm0,0+128(%rbp) + vperm2i128 $0x02,%ymm3,%ymm7,%ymm0 + vperm2i128 $0x13,%ymm3,%ymm7,%ymm7 + vperm2i128 $0x02,%ymm11,%ymm15,%ymm3 + vperm2i128 $0x13,%ymm11,%ymm15,%ymm11 + vpxor 0+0(%rsi),%ymm0,%ymm0 + vpxor 32+0(%rsi),%ymm3,%ymm3 + vpxor 64+0(%rsi),%ymm7,%ymm7 + vpxor 96+0(%rsi),%ymm11,%ymm11 + vmovdqu %ymm0,0+0(%rdi) + vmovdqu %ymm3,32+0(%rdi) + vmovdqu %ymm7,64+0(%rdi) + vmovdqu %ymm11,96+0(%rdi) + + vmovdqa 0+128(%rbp),%ymm0 + vperm2i128 $0x02,%ymm2,%ymm6,%ymm3 + vperm2i128 $0x13,%ymm2,%ymm6,%ymm6 + vperm2i128 $0x02,%ymm10,%ymm14,%ymm2 + vperm2i128 $0x13,%ymm10,%ymm14,%ymm10 + vpxor 0+128(%rsi),%ymm3,%ymm3 + vpxor 32+128(%rsi),%ymm2,%ymm2 + vpxor 64+128(%rsi),%ymm6,%ymm6 + vpxor 96+128(%rsi),%ymm10,%ymm10 + vmovdqu %ymm3,0+128(%rdi) + vmovdqu %ymm2,32+128(%rdi) + vmovdqu %ymm6,64+128(%rdi) + vmovdqu %ymm10,96+128(%rdi) + vperm2i128 $0x02,%ymm1,%ymm5,%ymm3 + vperm2i128 $0x13,%ymm1,%ymm5,%ymm5 + vperm2i128 $0x02,%ymm9,%ymm13,%ymm1 + vperm2i128 $0x13,%ymm9,%ymm13,%ymm9 + vpxor 0+256(%rsi),%ymm3,%ymm3 + vpxor 32+256(%rsi),%ymm1,%ymm1 + vpxor 64+256(%rsi),%ymm5,%ymm5 + vpxor 96+256(%rsi),%ymm9,%ymm9 + vmovdqu %ymm3,0+256(%rdi) + vmovdqu %ymm1,32+256(%rdi) + vmovdqu %ymm5,64+256(%rdi) + vmovdqu %ymm9,96+256(%rdi) + vperm2i128 $0x13,%ymm0,%ymm4,%ymm3 + vperm2i128 $0x02,%ymm0,%ymm4,%ymm0 + vperm2i128 $0x02,%ymm8,%ymm12,%ymm4 + vperm2i128 $0x13,%ymm8,%ymm12,%ymm12 + vmovdqa %ymm3,%ymm8 + + leaq 384(%rsi),%rsi + leaq 384(%rdi),%rdi + subq $384,%rbx +L$open_avx2_tail_128_xor: + cmpq $32,%rbx + jb L$open_avx2_tail_32_xor + subq $32,%rbx + vpxor (%rsi),%ymm0,%ymm0 + vmovdqu %ymm0,(%rdi) + leaq 32(%rsi),%rsi + leaq 32(%rdi),%rdi + vmovdqa %ymm4,%ymm0 + vmovdqa %ymm8,%ymm4 + vmovdqa %ymm12,%ymm8 + jmp L$open_avx2_tail_128_xor +L$open_avx2_tail_32_xor: + cmpq $16,%rbx + vmovdqa %xmm0,%xmm1 + jb L$open_avx2_exit + subq $16,%rbx + + vpxor (%rsi),%xmm0,%xmm1 + vmovdqu %xmm1,(%rdi) + leaq 16(%rsi),%rsi + leaq 16(%rdi),%rdi + vperm2i128 $0x11,%ymm0,%ymm0,%ymm0 + vmovdqa %xmm0,%xmm1 +L$open_avx2_exit: + vzeroupper + jmp L$open_sse_tail_16 + +L$open_avx2_192: + vmovdqa %ymm0,%ymm1 + vmovdqa %ymm0,%ymm2 + vmovdqa %ymm4,%ymm5 + vmovdqa %ymm4,%ymm6 + vmovdqa %ymm8,%ymm9 + vmovdqa %ymm8,%ymm10 + vpaddd L$avx2_inc(%rip),%ymm12,%ymm13 + vmovdqa %ymm12,%ymm11 + vmovdqa %ymm13,%ymm15 + movq $10,%r10 +L$open_avx2_192_rounds: + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $4,%ymm4,%ymm4,%ymm4 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb L$rol16(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpsrld $20,%ymm5,%ymm3 + vpslld $12,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb L$rol8(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpslld $7,%ymm5,%ymm3 + vpsrld $25,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpalignr $12,%ymm13,%ymm13,%ymm13 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $4,%ymm5,%ymm5,%ymm5 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $4,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm4,%ymm4,%ymm4 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb L$rol16(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpsrld $20,%ymm5,%ymm3 + vpslld $12,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb L$rol8(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpslld $7,%ymm5,%ymm3 + vpsrld $25,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpalignr $4,%ymm13,%ymm13,%ymm13 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $12,%ymm5,%ymm5,%ymm5 + + decq %r10 + jne L$open_avx2_192_rounds + vpaddd %ymm2,%ymm0,%ymm0 + vpaddd %ymm2,%ymm1,%ymm1 + vpaddd %ymm6,%ymm4,%ymm4 + vpaddd %ymm6,%ymm5,%ymm5 + vpaddd %ymm10,%ymm8,%ymm8 + vpaddd %ymm10,%ymm9,%ymm9 + vpaddd %ymm11,%ymm12,%ymm12 + vpaddd %ymm15,%ymm13,%ymm13 + vperm2i128 $0x02,%ymm0,%ymm4,%ymm3 + + vpand L$clamp(%rip),%ymm3,%ymm3 + vmovdqa %ymm3,0+0(%rbp) + + vperm2i128 $0x13,%ymm0,%ymm4,%ymm0 + vperm2i128 $0x13,%ymm8,%ymm12,%ymm4 + vperm2i128 $0x02,%ymm1,%ymm5,%ymm8 + vperm2i128 $0x02,%ymm9,%ymm13,%ymm12 + vperm2i128 $0x13,%ymm1,%ymm5,%ymm1 + vperm2i128 $0x13,%ymm9,%ymm13,%ymm5 +L$open_avx2_short: + movq %r8,%r8 + call poly_hash_ad_internal +L$open_avx2_short_hash_and_xor_loop: + cmpq $32,%rbx + jb L$open_avx2_short_tail_32 + subq $32,%rbx + addq 0+0(%rsi),%r10 + adcq 8+0(%rsi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + addq 0+16(%rsi),%r10 + adcq 8+16(%rsi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + + vpxor (%rsi),%ymm0,%ymm0 + vmovdqu %ymm0,(%rdi) + leaq 32(%rsi),%rsi + leaq 32(%rdi),%rdi + + vmovdqa %ymm4,%ymm0 + vmovdqa %ymm8,%ymm4 + vmovdqa %ymm12,%ymm8 + vmovdqa %ymm1,%ymm12 + vmovdqa %ymm5,%ymm1 + vmovdqa %ymm9,%ymm5 + vmovdqa %ymm13,%ymm9 + vmovdqa %ymm2,%ymm13 + vmovdqa %ymm6,%ymm2 + jmp L$open_avx2_short_hash_and_xor_loop +L$open_avx2_short_tail_32: + cmpq $16,%rbx + vmovdqa %xmm0,%xmm1 + jb L$open_avx2_short_tail_32_exit + subq $16,%rbx + addq 0+0(%rsi),%r10 + adcq 8+0(%rsi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + vpxor (%rsi),%xmm0,%xmm3 + vmovdqu %xmm3,(%rdi) + leaq 16(%rsi),%rsi + leaq 16(%rdi),%rdi + vextracti128 $1,%ymm0,%xmm1 +L$open_avx2_short_tail_32_exit: + vzeroupper + jmp L$open_sse_tail_16 + +L$open_avx2_320: + vmovdqa %ymm0,%ymm1 + vmovdqa %ymm0,%ymm2 + vmovdqa %ymm4,%ymm5 + vmovdqa %ymm4,%ymm6 + vmovdqa %ymm8,%ymm9 + vmovdqa %ymm8,%ymm10 + vpaddd L$avx2_inc(%rip),%ymm12,%ymm13 + vpaddd L$avx2_inc(%rip),%ymm13,%ymm14 + vmovdqa %ymm4,%ymm7 + vmovdqa %ymm8,%ymm11 + vmovdqa %ymm12,0+160(%rbp) + vmovdqa %ymm13,0+192(%rbp) + vmovdqa %ymm14,0+224(%rbp) + movq $10,%r10 +L$open_avx2_320_rounds: + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $4,%ymm4,%ymm4,%ymm4 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb L$rol16(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpsrld $20,%ymm5,%ymm3 + vpslld $12,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb L$rol8(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpslld $7,%ymm5,%ymm3 + vpsrld $25,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpalignr $12,%ymm13,%ymm13,%ymm13 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $4,%ymm5,%ymm5,%ymm5 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb L$rol16(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpsrld $20,%ymm6,%ymm3 + vpslld $12,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb L$rol8(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpslld $7,%ymm6,%ymm3 + vpsrld $25,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpalignr $12,%ymm14,%ymm14,%ymm14 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $4,%ymm6,%ymm6,%ymm6 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $4,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm4,%ymm4,%ymm4 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb L$rol16(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpsrld $20,%ymm5,%ymm3 + vpslld $12,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb L$rol8(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpslld $7,%ymm5,%ymm3 + vpsrld $25,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpalignr $4,%ymm13,%ymm13,%ymm13 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $12,%ymm5,%ymm5,%ymm5 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb L$rol16(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpsrld $20,%ymm6,%ymm3 + vpslld $12,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb L$rol8(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpslld $7,%ymm6,%ymm3 + vpsrld $25,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpalignr $4,%ymm14,%ymm14,%ymm14 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $12,%ymm6,%ymm6,%ymm6 + + decq %r10 + jne L$open_avx2_320_rounds + vpaddd L$chacha20_consts(%rip),%ymm0,%ymm0 + vpaddd L$chacha20_consts(%rip),%ymm1,%ymm1 + vpaddd L$chacha20_consts(%rip),%ymm2,%ymm2 + vpaddd %ymm7,%ymm4,%ymm4 + vpaddd %ymm7,%ymm5,%ymm5 + vpaddd %ymm7,%ymm6,%ymm6 + vpaddd %ymm11,%ymm8,%ymm8 + vpaddd %ymm11,%ymm9,%ymm9 + vpaddd %ymm11,%ymm10,%ymm10 + vpaddd 0+160(%rbp),%ymm12,%ymm12 + vpaddd 0+192(%rbp),%ymm13,%ymm13 + vpaddd 0+224(%rbp),%ymm14,%ymm14 + vperm2i128 $0x02,%ymm0,%ymm4,%ymm3 + + vpand L$clamp(%rip),%ymm3,%ymm3 + vmovdqa %ymm3,0+0(%rbp) + + vperm2i128 $0x13,%ymm0,%ymm4,%ymm0 + vperm2i128 $0x13,%ymm8,%ymm12,%ymm4 + vperm2i128 $0x02,%ymm1,%ymm5,%ymm8 + vperm2i128 $0x02,%ymm9,%ymm13,%ymm12 + vperm2i128 $0x13,%ymm1,%ymm5,%ymm1 + vperm2i128 $0x13,%ymm9,%ymm13,%ymm5 + vperm2i128 $0x02,%ymm2,%ymm6,%ymm9 + vperm2i128 $0x02,%ymm10,%ymm14,%ymm13 + vperm2i128 $0x13,%ymm2,%ymm6,%ymm2 + vperm2i128 $0x13,%ymm10,%ymm14,%ymm6 + jmp L$open_avx2_short + + + + +.globl _chacha20_poly1305_seal_avx2 +.private_extern _chacha20_poly1305_seal_avx2 + +.p2align 6 +_chacha20_poly1305_seal_avx2: + +_CET_ENDBR + pushq %rbp + + pushq %rbx + + pushq %r12 + + pushq %r13 + + pushq %r14 + + pushq %r15 + + + + pushq %r9 + + subq $288 + 0 + 32,%rsp + + leaq 32(%rsp),%rbp + andq $-32,%rbp + + movq 56(%r9),%rbx + addq %rdx,%rbx + movq %r8,0+0+32(%rbp) + movq %rbx,8+0+32(%rbp) + movq %rdx,%rbx + + vzeroupper + vmovdqa L$chacha20_consts(%rip),%ymm0 + vbroadcasti128 0(%r9),%ymm4 + vbroadcasti128 16(%r9),%ymm8 + vbroadcasti128 32(%r9),%ymm12 + vpaddd L$avx2_init(%rip),%ymm12,%ymm12 + cmpq $192,%rbx + jbe L$seal_avx2_192 + cmpq $320,%rbx + jbe L$seal_avx2_320 + vmovdqa %ymm0,%ymm1 + vmovdqa %ymm0,%ymm2 + vmovdqa %ymm0,%ymm3 + vmovdqa %ymm4,%ymm5 + vmovdqa %ymm4,%ymm6 + vmovdqa %ymm4,%ymm7 + vmovdqa %ymm4,0+64(%rbp) + vmovdqa %ymm8,%ymm9 + vmovdqa %ymm8,%ymm10 + vmovdqa %ymm8,%ymm11 + vmovdqa %ymm8,0+96(%rbp) + vmovdqa %ymm12,%ymm15 + vpaddd L$avx2_inc(%rip),%ymm15,%ymm14 + vpaddd L$avx2_inc(%rip),%ymm14,%ymm13 + vpaddd L$avx2_inc(%rip),%ymm13,%ymm12 + vmovdqa %ymm12,0+160(%rbp) + vmovdqa %ymm13,0+192(%rbp) + vmovdqa %ymm14,0+224(%rbp) + vmovdqa %ymm15,0+256(%rbp) + movq $10,%r10 +L$seal_avx2_init_rounds: + vmovdqa %ymm8,0+128(%rbp) + vmovdqa L$rol16(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $20,%ymm7,%ymm8 + vpslld $32-20,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $20,%ymm6,%ymm8 + vpslld $32-20,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $20,%ymm5,%ymm8 + vpslld $32-20,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $20,%ymm4,%ymm8 + vpslld $32-20,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa L$rol8(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $25,%ymm7,%ymm8 + vpslld $32-25,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $25,%ymm6,%ymm8 + vpslld $32-25,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $25,%ymm5,%ymm8 + vpslld $32-25,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $25,%ymm4,%ymm8 + vpslld $32-25,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa 0+128(%rbp),%ymm8 + vpalignr $4,%ymm7,%ymm7,%ymm7 + vpalignr $8,%ymm11,%ymm11,%ymm11 + vpalignr $12,%ymm15,%ymm15,%ymm15 + vpalignr $4,%ymm6,%ymm6,%ymm6 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $12,%ymm14,%ymm14,%ymm14 + vpalignr $4,%ymm5,%ymm5,%ymm5 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $12,%ymm13,%ymm13,%ymm13 + vpalignr $4,%ymm4,%ymm4,%ymm4 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vmovdqa %ymm8,0+128(%rbp) + vmovdqa L$rol16(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $20,%ymm7,%ymm8 + vpslld $32-20,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $20,%ymm6,%ymm8 + vpslld $32-20,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $20,%ymm5,%ymm8 + vpslld $32-20,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $20,%ymm4,%ymm8 + vpslld $32-20,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa L$rol8(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $25,%ymm7,%ymm8 + vpslld $32-25,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $25,%ymm6,%ymm8 + vpslld $32-25,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $25,%ymm5,%ymm8 + vpslld $32-25,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $25,%ymm4,%ymm8 + vpslld $32-25,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa 0+128(%rbp),%ymm8 + vpalignr $12,%ymm7,%ymm7,%ymm7 + vpalignr $8,%ymm11,%ymm11,%ymm11 + vpalignr $4,%ymm15,%ymm15,%ymm15 + vpalignr $12,%ymm6,%ymm6,%ymm6 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $4,%ymm14,%ymm14,%ymm14 + vpalignr $12,%ymm5,%ymm5,%ymm5 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $4,%ymm13,%ymm13,%ymm13 + vpalignr $12,%ymm4,%ymm4,%ymm4 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $4,%ymm12,%ymm12,%ymm12 + + decq %r10 + jnz L$seal_avx2_init_rounds + vpaddd L$chacha20_consts(%rip),%ymm3,%ymm3 + vpaddd 0+64(%rbp),%ymm7,%ymm7 + vpaddd 0+96(%rbp),%ymm11,%ymm11 + vpaddd 0+256(%rbp),%ymm15,%ymm15 + vpaddd L$chacha20_consts(%rip),%ymm2,%ymm2 + vpaddd 0+64(%rbp),%ymm6,%ymm6 + vpaddd 0+96(%rbp),%ymm10,%ymm10 + vpaddd 0+224(%rbp),%ymm14,%ymm14 + vpaddd L$chacha20_consts(%rip),%ymm1,%ymm1 + vpaddd 0+64(%rbp),%ymm5,%ymm5 + vpaddd 0+96(%rbp),%ymm9,%ymm9 + vpaddd 0+192(%rbp),%ymm13,%ymm13 + vpaddd L$chacha20_consts(%rip),%ymm0,%ymm0 + vpaddd 0+64(%rbp),%ymm4,%ymm4 + vpaddd 0+96(%rbp),%ymm8,%ymm8 + vpaddd 0+160(%rbp),%ymm12,%ymm12 + + vperm2i128 $0x13,%ymm11,%ymm15,%ymm11 + vperm2i128 $0x02,%ymm3,%ymm7,%ymm15 + vperm2i128 $0x13,%ymm3,%ymm7,%ymm3 + vpand L$clamp(%rip),%ymm15,%ymm15 + vmovdqa %ymm15,0+0(%rbp) + movq %r8,%r8 + call poly_hash_ad_internal + + vpxor 0(%rsi),%ymm3,%ymm3 + vpxor 32(%rsi),%ymm11,%ymm11 + vmovdqu %ymm3,0(%rdi) + vmovdqu %ymm11,32(%rdi) + vperm2i128 $0x02,%ymm2,%ymm6,%ymm15 + vperm2i128 $0x13,%ymm2,%ymm6,%ymm6 + vperm2i128 $0x02,%ymm10,%ymm14,%ymm2 + vperm2i128 $0x13,%ymm10,%ymm14,%ymm10 + vpxor 0+64(%rsi),%ymm15,%ymm15 + vpxor 32+64(%rsi),%ymm2,%ymm2 + vpxor 64+64(%rsi),%ymm6,%ymm6 + vpxor 96+64(%rsi),%ymm10,%ymm10 + vmovdqu %ymm15,0+64(%rdi) + vmovdqu %ymm2,32+64(%rdi) + vmovdqu %ymm6,64+64(%rdi) + vmovdqu %ymm10,96+64(%rdi) + vperm2i128 $0x02,%ymm1,%ymm5,%ymm15 + vperm2i128 $0x13,%ymm1,%ymm5,%ymm5 + vperm2i128 $0x02,%ymm9,%ymm13,%ymm1 + vperm2i128 $0x13,%ymm9,%ymm13,%ymm9 + vpxor 0+192(%rsi),%ymm15,%ymm15 + vpxor 32+192(%rsi),%ymm1,%ymm1 + vpxor 64+192(%rsi),%ymm5,%ymm5 + vpxor 96+192(%rsi),%ymm9,%ymm9 + vmovdqu %ymm15,0+192(%rdi) + vmovdqu %ymm1,32+192(%rdi) + vmovdqu %ymm5,64+192(%rdi) + vmovdqu %ymm9,96+192(%rdi) + vperm2i128 $0x13,%ymm0,%ymm4,%ymm15 + vperm2i128 $0x02,%ymm0,%ymm4,%ymm0 + vperm2i128 $0x02,%ymm8,%ymm12,%ymm4 + vperm2i128 $0x13,%ymm8,%ymm12,%ymm12 + vmovdqa %ymm15,%ymm8 + + leaq 320(%rsi),%rsi + subq $320,%rbx + movq $320,%rcx + cmpq $128,%rbx + jbe L$seal_avx2_short_hash_remainder + vpxor 0(%rsi),%ymm0,%ymm0 + vpxor 32(%rsi),%ymm4,%ymm4 + vpxor 64(%rsi),%ymm8,%ymm8 + vpxor 96(%rsi),%ymm12,%ymm12 + vmovdqu %ymm0,320(%rdi) + vmovdqu %ymm4,352(%rdi) + vmovdqu %ymm8,384(%rdi) + vmovdqu %ymm12,416(%rdi) + leaq 128(%rsi),%rsi + subq $128,%rbx + movq $8,%rcx + movq $2,%r8 + cmpq $128,%rbx + jbe L$seal_avx2_tail_128 + cmpq $256,%rbx + jbe L$seal_avx2_tail_256 + cmpq $384,%rbx + jbe L$seal_avx2_tail_384 + cmpq $512,%rbx + jbe L$seal_avx2_tail_512 + vmovdqa L$chacha20_consts(%rip),%ymm0 + vmovdqa 0+64(%rbp),%ymm4 + vmovdqa 0+96(%rbp),%ymm8 + vmovdqa %ymm0,%ymm1 + vmovdqa %ymm4,%ymm5 + vmovdqa %ymm8,%ymm9 + vmovdqa %ymm0,%ymm2 + vmovdqa %ymm4,%ymm6 + vmovdqa %ymm8,%ymm10 + vmovdqa %ymm0,%ymm3 + vmovdqa %ymm4,%ymm7 + vmovdqa %ymm8,%ymm11 + vmovdqa L$avx2_inc(%rip),%ymm12 + vpaddd 0+160(%rbp),%ymm12,%ymm15 + vpaddd %ymm15,%ymm12,%ymm14 + vpaddd %ymm14,%ymm12,%ymm13 + vpaddd %ymm13,%ymm12,%ymm12 + vmovdqa %ymm15,0+256(%rbp) + vmovdqa %ymm14,0+224(%rbp) + vmovdqa %ymm13,0+192(%rbp) + vmovdqa %ymm12,0+160(%rbp) + vmovdqa %ymm8,0+128(%rbp) + vmovdqa L$rol16(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $20,%ymm7,%ymm8 + vpslld $32-20,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $20,%ymm6,%ymm8 + vpslld $32-20,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $20,%ymm5,%ymm8 + vpslld $32-20,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $20,%ymm4,%ymm8 + vpslld $32-20,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa L$rol8(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $25,%ymm7,%ymm8 + vpslld $32-25,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $25,%ymm6,%ymm8 + vpslld $32-25,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $25,%ymm5,%ymm8 + vpslld $32-25,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $25,%ymm4,%ymm8 + vpslld $32-25,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa 0+128(%rbp),%ymm8 + vpalignr $4,%ymm7,%ymm7,%ymm7 + vpalignr $8,%ymm11,%ymm11,%ymm11 + vpalignr $12,%ymm15,%ymm15,%ymm15 + vpalignr $4,%ymm6,%ymm6,%ymm6 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $12,%ymm14,%ymm14,%ymm14 + vpalignr $4,%ymm5,%ymm5,%ymm5 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $12,%ymm13,%ymm13,%ymm13 + vpalignr $4,%ymm4,%ymm4,%ymm4 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vmovdqa %ymm8,0+128(%rbp) + vmovdqa L$rol16(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $20,%ymm7,%ymm8 + vpslld $32-20,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $20,%ymm6,%ymm8 + vpslld $32-20,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $20,%ymm5,%ymm8 + vpslld $32-20,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $20,%ymm4,%ymm8 + vpslld $32-20,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa L$rol8(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $25,%ymm7,%ymm8 + vpslld $32-25,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $25,%ymm6,%ymm8 + vpslld $32-25,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $25,%ymm5,%ymm8 + vpslld $32-25,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $25,%ymm4,%ymm8 + vpslld $32-25,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa 0+128(%rbp),%ymm8 + vpalignr $12,%ymm7,%ymm7,%ymm7 + vpalignr $8,%ymm11,%ymm11,%ymm11 + vpalignr $4,%ymm15,%ymm15,%ymm15 + vpalignr $12,%ymm6,%ymm6,%ymm6 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $4,%ymm14,%ymm14,%ymm14 + vpalignr $12,%ymm5,%ymm5,%ymm5 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $4,%ymm13,%ymm13,%ymm13 + vpalignr $12,%ymm4,%ymm4,%ymm4 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $4,%ymm12,%ymm12,%ymm12 + vmovdqa %ymm8,0+128(%rbp) + vmovdqa L$rol16(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $20,%ymm7,%ymm8 + vpslld $32-20,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $20,%ymm6,%ymm8 + vpslld $32-20,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $20,%ymm5,%ymm8 + vpslld $32-20,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $20,%ymm4,%ymm8 + vpslld $32-20,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa L$rol8(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + + subq $16,%rdi + movq $9,%rcx + jmp L$seal_avx2_main_loop_rounds_entry +.p2align 5 +L$seal_avx2_main_loop: + vmovdqa L$chacha20_consts(%rip),%ymm0 + vmovdqa 0+64(%rbp),%ymm4 + vmovdqa 0+96(%rbp),%ymm8 + vmovdqa %ymm0,%ymm1 + vmovdqa %ymm4,%ymm5 + vmovdqa %ymm8,%ymm9 + vmovdqa %ymm0,%ymm2 + vmovdqa %ymm4,%ymm6 + vmovdqa %ymm8,%ymm10 + vmovdqa %ymm0,%ymm3 + vmovdqa %ymm4,%ymm7 + vmovdqa %ymm8,%ymm11 + vmovdqa L$avx2_inc(%rip),%ymm12 + vpaddd 0+160(%rbp),%ymm12,%ymm15 + vpaddd %ymm15,%ymm12,%ymm14 + vpaddd %ymm14,%ymm12,%ymm13 + vpaddd %ymm13,%ymm12,%ymm12 + vmovdqa %ymm15,0+256(%rbp) + vmovdqa %ymm14,0+224(%rbp) + vmovdqa %ymm13,0+192(%rbp) + vmovdqa %ymm12,0+160(%rbp) + + movq $10,%rcx +.p2align 5 +L$seal_avx2_main_loop_rounds: + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + vmovdqa %ymm8,0+128(%rbp) + vmovdqa L$rol16(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $20,%ymm7,%ymm8 + vpslld $32-20,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $20,%ymm6,%ymm8 + vpslld $32-20,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $20,%ymm5,%ymm8 + vpslld $32-20,%ymm5,%ymm5 + addq %rax,%r15 + adcq %rdx,%r9 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $20,%ymm4,%ymm8 + vpslld $32-20,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa L$rol8(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + +L$seal_avx2_main_loop_rounds_entry: + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + addq 0+16(%rdi),%r10 + adcq 8+16(%rdi),%r11 + adcq $1,%r12 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $25,%ymm7,%ymm8 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + vpslld $32-25,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $25,%ymm6,%ymm8 + vpslld $32-25,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $25,%ymm5,%ymm8 + vpslld $32-25,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $25,%ymm4,%ymm8 + vpslld $32-25,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa 0+128(%rbp),%ymm8 + vpalignr $4,%ymm7,%ymm7,%ymm7 + vpalignr $8,%ymm11,%ymm11,%ymm11 + vpalignr $12,%ymm15,%ymm15,%ymm15 + vpalignr $4,%ymm6,%ymm6,%ymm6 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $12,%ymm14,%ymm14,%ymm14 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + vpalignr $4,%ymm5,%ymm5,%ymm5 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $12,%ymm13,%ymm13,%ymm13 + vpalignr $4,%ymm4,%ymm4,%ymm4 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vmovdqa %ymm8,0+128(%rbp) + vmovdqa L$rol16(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + addq %rax,%r15 + adcq %rdx,%r9 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $20,%ymm7,%ymm8 + vpslld $32-20,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $20,%ymm6,%ymm8 + vpslld $32-20,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + addq 0+32(%rdi),%r10 + adcq 8+32(%rdi),%r11 + adcq $1,%r12 + + leaq 48(%rdi),%rdi + vpsrld $20,%ymm5,%ymm8 + vpslld $32-20,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $20,%ymm4,%ymm8 + vpslld $32-20,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa L$rol8(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $25,%ymm7,%ymm8 + vpslld $32-25,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $25,%ymm6,%ymm8 + vpslld $32-25,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + addq %rax,%r15 + adcq %rdx,%r9 + vpsrld $25,%ymm5,%ymm8 + vpslld $32-25,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $25,%ymm4,%ymm8 + vpslld $32-25,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa 0+128(%rbp),%ymm8 + vpalignr $12,%ymm7,%ymm7,%ymm7 + vpalignr $8,%ymm11,%ymm11,%ymm11 + vpalignr $4,%ymm15,%ymm15,%ymm15 + vpalignr $12,%ymm6,%ymm6,%ymm6 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $4,%ymm14,%ymm14,%ymm14 + vpalignr $12,%ymm5,%ymm5,%ymm5 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $4,%ymm13,%ymm13,%ymm13 + vpalignr $12,%ymm4,%ymm4,%ymm4 + vpalignr $8,%ymm8,%ymm8,%ymm8 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + vpalignr $4,%ymm12,%ymm12,%ymm12 + + decq %rcx + jne L$seal_avx2_main_loop_rounds + vpaddd L$chacha20_consts(%rip),%ymm3,%ymm3 + vpaddd 0+64(%rbp),%ymm7,%ymm7 + vpaddd 0+96(%rbp),%ymm11,%ymm11 + vpaddd 0+256(%rbp),%ymm15,%ymm15 + vpaddd L$chacha20_consts(%rip),%ymm2,%ymm2 + vpaddd 0+64(%rbp),%ymm6,%ymm6 + vpaddd 0+96(%rbp),%ymm10,%ymm10 + vpaddd 0+224(%rbp),%ymm14,%ymm14 + vpaddd L$chacha20_consts(%rip),%ymm1,%ymm1 + vpaddd 0+64(%rbp),%ymm5,%ymm5 + vpaddd 0+96(%rbp),%ymm9,%ymm9 + vpaddd 0+192(%rbp),%ymm13,%ymm13 + vpaddd L$chacha20_consts(%rip),%ymm0,%ymm0 + vpaddd 0+64(%rbp),%ymm4,%ymm4 + vpaddd 0+96(%rbp),%ymm8,%ymm8 + vpaddd 0+160(%rbp),%ymm12,%ymm12 + + vmovdqa %ymm0,0+128(%rbp) + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + addq %rax,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + addq 0+16(%rdi),%r10 + adcq 8+16(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + addq %rax,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 32(%rdi),%rdi + vperm2i128 $0x02,%ymm3,%ymm7,%ymm0 + vperm2i128 $0x13,%ymm3,%ymm7,%ymm7 + vperm2i128 $0x02,%ymm11,%ymm15,%ymm3 + vperm2i128 $0x13,%ymm11,%ymm15,%ymm11 + vpxor 0+0(%rsi),%ymm0,%ymm0 + vpxor 32+0(%rsi),%ymm3,%ymm3 + vpxor 64+0(%rsi),%ymm7,%ymm7 + vpxor 96+0(%rsi),%ymm11,%ymm11 + vmovdqu %ymm0,0+0(%rdi) + vmovdqu %ymm3,32+0(%rdi) + vmovdqu %ymm7,64+0(%rdi) + vmovdqu %ymm11,96+0(%rdi) + + vmovdqa 0+128(%rbp),%ymm0 + vperm2i128 $0x02,%ymm2,%ymm6,%ymm3 + vperm2i128 $0x13,%ymm2,%ymm6,%ymm6 + vperm2i128 $0x02,%ymm10,%ymm14,%ymm2 + vperm2i128 $0x13,%ymm10,%ymm14,%ymm10 + vpxor 0+128(%rsi),%ymm3,%ymm3 + vpxor 32+128(%rsi),%ymm2,%ymm2 + vpxor 64+128(%rsi),%ymm6,%ymm6 + vpxor 96+128(%rsi),%ymm10,%ymm10 + vmovdqu %ymm3,0+128(%rdi) + vmovdqu %ymm2,32+128(%rdi) + vmovdqu %ymm6,64+128(%rdi) + vmovdqu %ymm10,96+128(%rdi) + vperm2i128 $0x02,%ymm1,%ymm5,%ymm3 + vperm2i128 $0x13,%ymm1,%ymm5,%ymm5 + vperm2i128 $0x02,%ymm9,%ymm13,%ymm1 + vperm2i128 $0x13,%ymm9,%ymm13,%ymm9 + vpxor 0+256(%rsi),%ymm3,%ymm3 + vpxor 32+256(%rsi),%ymm1,%ymm1 + vpxor 64+256(%rsi),%ymm5,%ymm5 + vpxor 96+256(%rsi),%ymm9,%ymm9 + vmovdqu %ymm3,0+256(%rdi) + vmovdqu %ymm1,32+256(%rdi) + vmovdqu %ymm5,64+256(%rdi) + vmovdqu %ymm9,96+256(%rdi) + vperm2i128 $0x02,%ymm0,%ymm4,%ymm3 + vperm2i128 $0x13,%ymm0,%ymm4,%ymm4 + vperm2i128 $0x02,%ymm8,%ymm12,%ymm0 + vperm2i128 $0x13,%ymm8,%ymm12,%ymm8 + vpxor 0+384(%rsi),%ymm3,%ymm3 + vpxor 32+384(%rsi),%ymm0,%ymm0 + vpxor 64+384(%rsi),%ymm4,%ymm4 + vpxor 96+384(%rsi),%ymm8,%ymm8 + vmovdqu %ymm3,0+384(%rdi) + vmovdqu %ymm0,32+384(%rdi) + vmovdqu %ymm4,64+384(%rdi) + vmovdqu %ymm8,96+384(%rdi) + + leaq 512(%rsi),%rsi + subq $512,%rbx + cmpq $512,%rbx + jg L$seal_avx2_main_loop + + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + addq %rax,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + addq 0+16(%rdi),%r10 + adcq 8+16(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + addq %rax,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 32(%rdi),%rdi + movq $10,%rcx + xorq %r8,%r8 + + cmpq $384,%rbx + ja L$seal_avx2_tail_512 + cmpq $256,%rbx + ja L$seal_avx2_tail_384 + cmpq $128,%rbx + ja L$seal_avx2_tail_256 + +L$seal_avx2_tail_128: + vmovdqa L$chacha20_consts(%rip),%ymm0 + vmovdqa 0+64(%rbp),%ymm4 + vmovdqa 0+96(%rbp),%ymm8 + vmovdqa L$avx2_inc(%rip),%ymm12 + vpaddd 0+160(%rbp),%ymm12,%ymm12 + vmovdqa %ymm12,0+160(%rbp) + +L$seal_avx2_tail_128_rounds_and_3xhash: + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + addq %rax,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%rdi),%rdi +L$seal_avx2_tail_128_rounds_and_2xhash: + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $4,%ymm4,%ymm4,%ymm4 + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + addq %rax,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $4,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm4,%ymm4,%ymm4 + addq 0+16(%rdi),%r10 + adcq 8+16(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + addq %rax,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 32(%rdi),%rdi + decq %rcx + jg L$seal_avx2_tail_128_rounds_and_3xhash + decq %r8 + jge L$seal_avx2_tail_128_rounds_and_2xhash + vpaddd L$chacha20_consts(%rip),%ymm0,%ymm0 + vpaddd 0+64(%rbp),%ymm4,%ymm4 + vpaddd 0+96(%rbp),%ymm8,%ymm8 + vpaddd 0+160(%rbp),%ymm12,%ymm12 + vperm2i128 $0x13,%ymm0,%ymm4,%ymm3 + vperm2i128 $0x02,%ymm0,%ymm4,%ymm0 + vperm2i128 $0x02,%ymm8,%ymm12,%ymm4 + vperm2i128 $0x13,%ymm8,%ymm12,%ymm12 + vmovdqa %ymm3,%ymm8 + + jmp L$seal_avx2_short_loop + +L$seal_avx2_tail_256: + vmovdqa L$chacha20_consts(%rip),%ymm0 + vmovdqa 0+64(%rbp),%ymm4 + vmovdqa 0+96(%rbp),%ymm8 + vmovdqa %ymm0,%ymm1 + vmovdqa %ymm4,%ymm5 + vmovdqa %ymm8,%ymm9 + vmovdqa L$avx2_inc(%rip),%ymm12 + vpaddd 0+160(%rbp),%ymm12,%ymm13 + vpaddd %ymm13,%ymm12,%ymm12 + vmovdqa %ymm12,0+160(%rbp) + vmovdqa %ymm13,0+192(%rbp) + +L$seal_avx2_tail_256_rounds_and_3xhash: + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%rdi),%rdi +L$seal_avx2_tail_256_rounds_and_2xhash: + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $4,%ymm4,%ymm4,%ymm4 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb L$rol16(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpsrld $20,%ymm5,%ymm3 + vpslld $12,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb L$rol8(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpslld $7,%ymm5,%ymm3 + vpsrld $25,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpalignr $12,%ymm13,%ymm13,%ymm13 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $4,%ymm5,%ymm5,%ymm5 + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $4,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm4,%ymm4,%ymm4 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb L$rol16(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpsrld $20,%ymm5,%ymm3 + vpslld $12,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb L$rol8(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpslld $7,%ymm5,%ymm3 + vpsrld $25,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpalignr $4,%ymm13,%ymm13,%ymm13 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $12,%ymm5,%ymm5,%ymm5 + addq 0+16(%rdi),%r10 + adcq 8+16(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 32(%rdi),%rdi + decq %rcx + jg L$seal_avx2_tail_256_rounds_and_3xhash + decq %r8 + jge L$seal_avx2_tail_256_rounds_and_2xhash + vpaddd L$chacha20_consts(%rip),%ymm1,%ymm1 + vpaddd 0+64(%rbp),%ymm5,%ymm5 + vpaddd 0+96(%rbp),%ymm9,%ymm9 + vpaddd 0+192(%rbp),%ymm13,%ymm13 + vpaddd L$chacha20_consts(%rip),%ymm0,%ymm0 + vpaddd 0+64(%rbp),%ymm4,%ymm4 + vpaddd 0+96(%rbp),%ymm8,%ymm8 + vpaddd 0+160(%rbp),%ymm12,%ymm12 + vperm2i128 $0x02,%ymm1,%ymm5,%ymm3 + vperm2i128 $0x13,%ymm1,%ymm5,%ymm5 + vperm2i128 $0x02,%ymm9,%ymm13,%ymm1 + vperm2i128 $0x13,%ymm9,%ymm13,%ymm9 + vpxor 0+0(%rsi),%ymm3,%ymm3 + vpxor 32+0(%rsi),%ymm1,%ymm1 + vpxor 64+0(%rsi),%ymm5,%ymm5 + vpxor 96+0(%rsi),%ymm9,%ymm9 + vmovdqu %ymm3,0+0(%rdi) + vmovdqu %ymm1,32+0(%rdi) + vmovdqu %ymm5,64+0(%rdi) + vmovdqu %ymm9,96+0(%rdi) + vperm2i128 $0x13,%ymm0,%ymm4,%ymm3 + vperm2i128 $0x02,%ymm0,%ymm4,%ymm0 + vperm2i128 $0x02,%ymm8,%ymm12,%ymm4 + vperm2i128 $0x13,%ymm8,%ymm12,%ymm12 + vmovdqa %ymm3,%ymm8 + + movq $128,%rcx + leaq 128(%rsi),%rsi + subq $128,%rbx + jmp L$seal_avx2_short_hash_remainder + +L$seal_avx2_tail_384: + vmovdqa L$chacha20_consts(%rip),%ymm0 + vmovdqa 0+64(%rbp),%ymm4 + vmovdqa 0+96(%rbp),%ymm8 + vmovdqa %ymm0,%ymm1 + vmovdqa %ymm4,%ymm5 + vmovdqa %ymm8,%ymm9 + vmovdqa %ymm0,%ymm2 + vmovdqa %ymm4,%ymm6 + vmovdqa %ymm8,%ymm10 + vmovdqa L$avx2_inc(%rip),%ymm12 + vpaddd 0+160(%rbp),%ymm12,%ymm14 + vpaddd %ymm14,%ymm12,%ymm13 + vpaddd %ymm13,%ymm12,%ymm12 + vmovdqa %ymm12,0+160(%rbp) + vmovdqa %ymm13,0+192(%rbp) + vmovdqa %ymm14,0+224(%rbp) + +L$seal_avx2_tail_384_rounds_and_3xhash: + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%rdi),%rdi +L$seal_avx2_tail_384_rounds_and_2xhash: + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $4,%ymm4,%ymm4,%ymm4 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb L$rol16(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpsrld $20,%ymm5,%ymm3 + vpslld $12,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb L$rol8(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpslld $7,%ymm5,%ymm3 + vpsrld $25,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpalignr $12,%ymm13,%ymm13,%ymm13 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $4,%ymm5,%ymm5,%ymm5 + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb L$rol16(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpsrld $20,%ymm6,%ymm3 + vpslld $12,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb L$rol8(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpslld $7,%ymm6,%ymm3 + vpsrld $25,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpalignr $12,%ymm14,%ymm14,%ymm14 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $4,%ymm6,%ymm6,%ymm6 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $4,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm4,%ymm4,%ymm4 + addq 0+16(%rdi),%r10 + adcq 8+16(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb L$rol16(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpsrld $20,%ymm5,%ymm3 + vpslld $12,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb L$rol8(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpslld $7,%ymm5,%ymm3 + vpsrld $25,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpalignr $4,%ymm13,%ymm13,%ymm13 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $12,%ymm5,%ymm5,%ymm5 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb L$rol16(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpsrld $20,%ymm6,%ymm3 + vpslld $12,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb L$rol8(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpslld $7,%ymm6,%ymm3 + vpsrld $25,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpalignr $4,%ymm14,%ymm14,%ymm14 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $12,%ymm6,%ymm6,%ymm6 + + leaq 32(%rdi),%rdi + decq %rcx + jg L$seal_avx2_tail_384_rounds_and_3xhash + decq %r8 + jge L$seal_avx2_tail_384_rounds_and_2xhash + vpaddd L$chacha20_consts(%rip),%ymm2,%ymm2 + vpaddd 0+64(%rbp),%ymm6,%ymm6 + vpaddd 0+96(%rbp),%ymm10,%ymm10 + vpaddd 0+224(%rbp),%ymm14,%ymm14 + vpaddd L$chacha20_consts(%rip),%ymm1,%ymm1 + vpaddd 0+64(%rbp),%ymm5,%ymm5 + vpaddd 0+96(%rbp),%ymm9,%ymm9 + vpaddd 0+192(%rbp),%ymm13,%ymm13 + vpaddd L$chacha20_consts(%rip),%ymm0,%ymm0 + vpaddd 0+64(%rbp),%ymm4,%ymm4 + vpaddd 0+96(%rbp),%ymm8,%ymm8 + vpaddd 0+160(%rbp),%ymm12,%ymm12 + vperm2i128 $0x02,%ymm2,%ymm6,%ymm3 + vperm2i128 $0x13,%ymm2,%ymm6,%ymm6 + vperm2i128 $0x02,%ymm10,%ymm14,%ymm2 + vperm2i128 $0x13,%ymm10,%ymm14,%ymm10 + vpxor 0+0(%rsi),%ymm3,%ymm3 + vpxor 32+0(%rsi),%ymm2,%ymm2 + vpxor 64+0(%rsi),%ymm6,%ymm6 + vpxor 96+0(%rsi),%ymm10,%ymm10 + vmovdqu %ymm3,0+0(%rdi) + vmovdqu %ymm2,32+0(%rdi) + vmovdqu %ymm6,64+0(%rdi) + vmovdqu %ymm10,96+0(%rdi) + vperm2i128 $0x02,%ymm1,%ymm5,%ymm3 + vperm2i128 $0x13,%ymm1,%ymm5,%ymm5 + vperm2i128 $0x02,%ymm9,%ymm13,%ymm1 + vperm2i128 $0x13,%ymm9,%ymm13,%ymm9 + vpxor 0+128(%rsi),%ymm3,%ymm3 + vpxor 32+128(%rsi),%ymm1,%ymm1 + vpxor 64+128(%rsi),%ymm5,%ymm5 + vpxor 96+128(%rsi),%ymm9,%ymm9 + vmovdqu %ymm3,0+128(%rdi) + vmovdqu %ymm1,32+128(%rdi) + vmovdqu %ymm5,64+128(%rdi) + vmovdqu %ymm9,96+128(%rdi) + vperm2i128 $0x13,%ymm0,%ymm4,%ymm3 + vperm2i128 $0x02,%ymm0,%ymm4,%ymm0 + vperm2i128 $0x02,%ymm8,%ymm12,%ymm4 + vperm2i128 $0x13,%ymm8,%ymm12,%ymm12 + vmovdqa %ymm3,%ymm8 + + movq $256,%rcx + leaq 256(%rsi),%rsi + subq $256,%rbx + jmp L$seal_avx2_short_hash_remainder + +L$seal_avx2_tail_512: + vmovdqa L$chacha20_consts(%rip),%ymm0 + vmovdqa 0+64(%rbp),%ymm4 + vmovdqa 0+96(%rbp),%ymm8 + vmovdqa %ymm0,%ymm1 + vmovdqa %ymm4,%ymm5 + vmovdqa %ymm8,%ymm9 + vmovdqa %ymm0,%ymm2 + vmovdqa %ymm4,%ymm6 + vmovdqa %ymm8,%ymm10 + vmovdqa %ymm0,%ymm3 + vmovdqa %ymm4,%ymm7 + vmovdqa %ymm8,%ymm11 + vmovdqa L$avx2_inc(%rip),%ymm12 + vpaddd 0+160(%rbp),%ymm12,%ymm15 + vpaddd %ymm15,%ymm12,%ymm14 + vpaddd %ymm14,%ymm12,%ymm13 + vpaddd %ymm13,%ymm12,%ymm12 + vmovdqa %ymm15,0+256(%rbp) + vmovdqa %ymm14,0+224(%rbp) + vmovdqa %ymm13,0+192(%rbp) + vmovdqa %ymm12,0+160(%rbp) + +L$seal_avx2_tail_512_rounds_and_3xhash: + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + addq %rax,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%rdi),%rdi +L$seal_avx2_tail_512_rounds_and_2xhash: + vmovdqa %ymm8,0+128(%rbp) + vmovdqa L$rol16(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $20,%ymm7,%ymm8 + vpslld $32-20,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $20,%ymm6,%ymm8 + vpslld $32-20,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $20,%ymm5,%ymm8 + vpslld $32-20,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $20,%ymm4,%ymm8 + vpslld $32-20,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa L$rol8(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $25,%ymm7,%ymm8 + vpslld $32-25,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + vpsrld $25,%ymm6,%ymm8 + vpslld $32-25,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $25,%ymm5,%ymm8 + vpslld $32-25,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $25,%ymm4,%ymm8 + vpslld $32-25,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa 0+128(%rbp),%ymm8 + vpalignr $4,%ymm7,%ymm7,%ymm7 + vpalignr $8,%ymm11,%ymm11,%ymm11 + vpalignr $12,%ymm15,%ymm15,%ymm15 + vpalignr $4,%ymm6,%ymm6,%ymm6 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $12,%ymm14,%ymm14,%ymm14 + vpalignr $4,%ymm5,%ymm5,%ymm5 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $12,%ymm13,%ymm13,%ymm13 + vpalignr $4,%ymm4,%ymm4,%ymm4 + addq %rax,%r15 + adcq %rdx,%r9 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vmovdqa %ymm8,0+128(%rbp) + vmovdqa L$rol16(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $20,%ymm7,%ymm8 + vpslld $32-20,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $20,%ymm6,%ymm8 + vpslld $32-20,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $20,%ymm5,%ymm8 + vpslld $32-20,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $20,%ymm4,%ymm8 + vpslld $32-20,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa L$rol8(%rip),%ymm8 + vpaddd %ymm7,%ymm3,%ymm3 + vpaddd %ymm6,%ymm2,%ymm2 + addq 0+16(%rdi),%r10 + adcq 8+16(%rdi),%r11 + adcq $1,%r12 + vpaddd %ymm5,%ymm1,%ymm1 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm3,%ymm15,%ymm15 + vpxor %ymm2,%ymm14,%ymm14 + vpxor %ymm1,%ymm13,%ymm13 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb %ymm8,%ymm15,%ymm15 + vpshufb %ymm8,%ymm14,%ymm14 + vpshufb %ymm8,%ymm13,%ymm13 + vpshufb %ymm8,%ymm12,%ymm12 + vpaddd %ymm15,%ymm11,%ymm11 + vpaddd %ymm14,%ymm10,%ymm10 + vpaddd %ymm13,%ymm9,%ymm9 + vpaddd 0+128(%rbp),%ymm12,%ymm8 + vpxor %ymm11,%ymm7,%ymm7 + vpxor %ymm10,%ymm6,%ymm6 + vpxor %ymm9,%ymm5,%ymm5 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa %ymm8,0+128(%rbp) + vpsrld $25,%ymm7,%ymm8 + movq 0+0+0(%rbp),%rdx + movq %rdx,%r15 + mulxq %r10,%r13,%r14 + mulxq %r11,%rax,%rdx + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + vpslld $32-25,%ymm7,%ymm7 + vpxor %ymm8,%ymm7,%ymm7 + vpsrld $25,%ymm6,%ymm8 + vpslld $32-25,%ymm6,%ymm6 + vpxor %ymm8,%ymm6,%ymm6 + vpsrld $25,%ymm5,%ymm8 + vpslld $32-25,%ymm5,%ymm5 + vpxor %ymm8,%ymm5,%ymm5 + vpsrld $25,%ymm4,%ymm8 + vpslld $32-25,%ymm4,%ymm4 + vpxor %ymm8,%ymm4,%ymm4 + vmovdqa 0+128(%rbp),%ymm8 + vpalignr $12,%ymm7,%ymm7,%ymm7 + vpalignr $8,%ymm11,%ymm11,%ymm11 + vpalignr $4,%ymm15,%ymm15,%ymm15 + vpalignr $12,%ymm6,%ymm6,%ymm6 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $4,%ymm14,%ymm14,%ymm14 + vpalignr $12,%ymm5,%ymm5,%ymm5 + vpalignr $8,%ymm9,%ymm9,%ymm9 + movq 8+0+0(%rbp),%rdx + mulxq %r10,%r10,%rax + addq %r10,%r14 + mulxq %r11,%r11,%r9 + adcq %r11,%r15 + adcq $0,%r9 + imulq %r12,%rdx + vpalignr $4,%ymm13,%ymm13,%ymm13 + vpalignr $12,%ymm4,%ymm4,%ymm4 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $4,%ymm12,%ymm12,%ymm12 + + + + + + + + + + + + + + + + + addq %rax,%r15 + adcq %rdx,%r9 + + + + + + + + + + + + + + + + + + + + + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 32(%rdi),%rdi + decq %rcx + jg L$seal_avx2_tail_512_rounds_and_3xhash + decq %r8 + jge L$seal_avx2_tail_512_rounds_and_2xhash + vpaddd L$chacha20_consts(%rip),%ymm3,%ymm3 + vpaddd 0+64(%rbp),%ymm7,%ymm7 + vpaddd 0+96(%rbp),%ymm11,%ymm11 + vpaddd 0+256(%rbp),%ymm15,%ymm15 + vpaddd L$chacha20_consts(%rip),%ymm2,%ymm2 + vpaddd 0+64(%rbp),%ymm6,%ymm6 + vpaddd 0+96(%rbp),%ymm10,%ymm10 + vpaddd 0+224(%rbp),%ymm14,%ymm14 + vpaddd L$chacha20_consts(%rip),%ymm1,%ymm1 + vpaddd 0+64(%rbp),%ymm5,%ymm5 + vpaddd 0+96(%rbp),%ymm9,%ymm9 + vpaddd 0+192(%rbp),%ymm13,%ymm13 + vpaddd L$chacha20_consts(%rip),%ymm0,%ymm0 + vpaddd 0+64(%rbp),%ymm4,%ymm4 + vpaddd 0+96(%rbp),%ymm8,%ymm8 + vpaddd 0+160(%rbp),%ymm12,%ymm12 + + vmovdqa %ymm0,0+128(%rbp) + vperm2i128 $0x02,%ymm3,%ymm7,%ymm0 + vperm2i128 $0x13,%ymm3,%ymm7,%ymm7 + vperm2i128 $0x02,%ymm11,%ymm15,%ymm3 + vperm2i128 $0x13,%ymm11,%ymm15,%ymm11 + vpxor 0+0(%rsi),%ymm0,%ymm0 + vpxor 32+0(%rsi),%ymm3,%ymm3 + vpxor 64+0(%rsi),%ymm7,%ymm7 + vpxor 96+0(%rsi),%ymm11,%ymm11 + vmovdqu %ymm0,0+0(%rdi) + vmovdqu %ymm3,32+0(%rdi) + vmovdqu %ymm7,64+0(%rdi) + vmovdqu %ymm11,96+0(%rdi) + + vmovdqa 0+128(%rbp),%ymm0 + vperm2i128 $0x02,%ymm2,%ymm6,%ymm3 + vperm2i128 $0x13,%ymm2,%ymm6,%ymm6 + vperm2i128 $0x02,%ymm10,%ymm14,%ymm2 + vperm2i128 $0x13,%ymm10,%ymm14,%ymm10 + vpxor 0+128(%rsi),%ymm3,%ymm3 + vpxor 32+128(%rsi),%ymm2,%ymm2 + vpxor 64+128(%rsi),%ymm6,%ymm6 + vpxor 96+128(%rsi),%ymm10,%ymm10 + vmovdqu %ymm3,0+128(%rdi) + vmovdqu %ymm2,32+128(%rdi) + vmovdqu %ymm6,64+128(%rdi) + vmovdqu %ymm10,96+128(%rdi) + vperm2i128 $0x02,%ymm1,%ymm5,%ymm3 + vperm2i128 $0x13,%ymm1,%ymm5,%ymm5 + vperm2i128 $0x02,%ymm9,%ymm13,%ymm1 + vperm2i128 $0x13,%ymm9,%ymm13,%ymm9 + vpxor 0+256(%rsi),%ymm3,%ymm3 + vpxor 32+256(%rsi),%ymm1,%ymm1 + vpxor 64+256(%rsi),%ymm5,%ymm5 + vpxor 96+256(%rsi),%ymm9,%ymm9 + vmovdqu %ymm3,0+256(%rdi) + vmovdqu %ymm1,32+256(%rdi) + vmovdqu %ymm5,64+256(%rdi) + vmovdqu %ymm9,96+256(%rdi) + vperm2i128 $0x13,%ymm0,%ymm4,%ymm3 + vperm2i128 $0x02,%ymm0,%ymm4,%ymm0 + vperm2i128 $0x02,%ymm8,%ymm12,%ymm4 + vperm2i128 $0x13,%ymm8,%ymm12,%ymm12 + vmovdqa %ymm3,%ymm8 + + movq $384,%rcx + leaq 384(%rsi),%rsi + subq $384,%rbx + jmp L$seal_avx2_short_hash_remainder + +L$seal_avx2_320: + vmovdqa %ymm0,%ymm1 + vmovdqa %ymm0,%ymm2 + vmovdqa %ymm4,%ymm5 + vmovdqa %ymm4,%ymm6 + vmovdqa %ymm8,%ymm9 + vmovdqa %ymm8,%ymm10 + vpaddd L$avx2_inc(%rip),%ymm12,%ymm13 + vpaddd L$avx2_inc(%rip),%ymm13,%ymm14 + vmovdqa %ymm4,%ymm7 + vmovdqa %ymm8,%ymm11 + vmovdqa %ymm12,0+160(%rbp) + vmovdqa %ymm13,0+192(%rbp) + vmovdqa %ymm14,0+224(%rbp) + movq $10,%r10 +L$seal_avx2_320_rounds: + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $4,%ymm4,%ymm4,%ymm4 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb L$rol16(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpsrld $20,%ymm5,%ymm3 + vpslld $12,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb L$rol8(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpslld $7,%ymm5,%ymm3 + vpsrld $25,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpalignr $12,%ymm13,%ymm13,%ymm13 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $4,%ymm5,%ymm5,%ymm5 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb L$rol16(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpsrld $20,%ymm6,%ymm3 + vpslld $12,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb L$rol8(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpslld $7,%ymm6,%ymm3 + vpsrld $25,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpalignr $12,%ymm14,%ymm14,%ymm14 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $4,%ymm6,%ymm6,%ymm6 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $4,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm4,%ymm4,%ymm4 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb L$rol16(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpsrld $20,%ymm5,%ymm3 + vpslld $12,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb L$rol8(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpslld $7,%ymm5,%ymm3 + vpsrld $25,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpalignr $4,%ymm13,%ymm13,%ymm13 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $12,%ymm5,%ymm5,%ymm5 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb L$rol16(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpsrld $20,%ymm6,%ymm3 + vpslld $12,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpaddd %ymm6,%ymm2,%ymm2 + vpxor %ymm2,%ymm14,%ymm14 + vpshufb L$rol8(%rip),%ymm14,%ymm14 + vpaddd %ymm14,%ymm10,%ymm10 + vpxor %ymm10,%ymm6,%ymm6 + vpslld $7,%ymm6,%ymm3 + vpsrld $25,%ymm6,%ymm6 + vpxor %ymm3,%ymm6,%ymm6 + vpalignr $4,%ymm14,%ymm14,%ymm14 + vpalignr $8,%ymm10,%ymm10,%ymm10 + vpalignr $12,%ymm6,%ymm6,%ymm6 + + decq %r10 + jne L$seal_avx2_320_rounds + vpaddd L$chacha20_consts(%rip),%ymm0,%ymm0 + vpaddd L$chacha20_consts(%rip),%ymm1,%ymm1 + vpaddd L$chacha20_consts(%rip),%ymm2,%ymm2 + vpaddd %ymm7,%ymm4,%ymm4 + vpaddd %ymm7,%ymm5,%ymm5 + vpaddd %ymm7,%ymm6,%ymm6 + vpaddd %ymm11,%ymm8,%ymm8 + vpaddd %ymm11,%ymm9,%ymm9 + vpaddd %ymm11,%ymm10,%ymm10 + vpaddd 0+160(%rbp),%ymm12,%ymm12 + vpaddd 0+192(%rbp),%ymm13,%ymm13 + vpaddd 0+224(%rbp),%ymm14,%ymm14 + vperm2i128 $0x02,%ymm0,%ymm4,%ymm3 + + vpand L$clamp(%rip),%ymm3,%ymm3 + vmovdqa %ymm3,0+0(%rbp) + + vperm2i128 $0x13,%ymm0,%ymm4,%ymm0 + vperm2i128 $0x13,%ymm8,%ymm12,%ymm4 + vperm2i128 $0x02,%ymm1,%ymm5,%ymm8 + vperm2i128 $0x02,%ymm9,%ymm13,%ymm12 + vperm2i128 $0x13,%ymm1,%ymm5,%ymm1 + vperm2i128 $0x13,%ymm9,%ymm13,%ymm5 + vperm2i128 $0x02,%ymm2,%ymm6,%ymm9 + vperm2i128 $0x02,%ymm10,%ymm14,%ymm13 + vperm2i128 $0x13,%ymm2,%ymm6,%ymm2 + vperm2i128 $0x13,%ymm10,%ymm14,%ymm6 + jmp L$seal_avx2_short + +L$seal_avx2_192: + vmovdqa %ymm0,%ymm1 + vmovdqa %ymm0,%ymm2 + vmovdqa %ymm4,%ymm5 + vmovdqa %ymm4,%ymm6 + vmovdqa %ymm8,%ymm9 + vmovdqa %ymm8,%ymm10 + vpaddd L$avx2_inc(%rip),%ymm12,%ymm13 + vmovdqa %ymm12,%ymm11 + vmovdqa %ymm13,%ymm15 + movq $10,%r10 +L$seal_avx2_192_rounds: + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $12,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $4,%ymm4,%ymm4,%ymm4 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb L$rol16(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpsrld $20,%ymm5,%ymm3 + vpslld $12,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb L$rol8(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpslld $7,%ymm5,%ymm3 + vpsrld $25,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpalignr $12,%ymm13,%ymm13,%ymm13 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $4,%ymm5,%ymm5,%ymm5 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol16(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpsrld $20,%ymm4,%ymm3 + vpslld $12,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpaddd %ymm4,%ymm0,%ymm0 + vpxor %ymm0,%ymm12,%ymm12 + vpshufb L$rol8(%rip),%ymm12,%ymm12 + vpaddd %ymm12,%ymm8,%ymm8 + vpxor %ymm8,%ymm4,%ymm4 + vpslld $7,%ymm4,%ymm3 + vpsrld $25,%ymm4,%ymm4 + vpxor %ymm3,%ymm4,%ymm4 + vpalignr $4,%ymm12,%ymm12,%ymm12 + vpalignr $8,%ymm8,%ymm8,%ymm8 + vpalignr $12,%ymm4,%ymm4,%ymm4 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb L$rol16(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpsrld $20,%ymm5,%ymm3 + vpslld $12,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpaddd %ymm5,%ymm1,%ymm1 + vpxor %ymm1,%ymm13,%ymm13 + vpshufb L$rol8(%rip),%ymm13,%ymm13 + vpaddd %ymm13,%ymm9,%ymm9 + vpxor %ymm9,%ymm5,%ymm5 + vpslld $7,%ymm5,%ymm3 + vpsrld $25,%ymm5,%ymm5 + vpxor %ymm3,%ymm5,%ymm5 + vpalignr $4,%ymm13,%ymm13,%ymm13 + vpalignr $8,%ymm9,%ymm9,%ymm9 + vpalignr $12,%ymm5,%ymm5,%ymm5 + + decq %r10 + jne L$seal_avx2_192_rounds + vpaddd %ymm2,%ymm0,%ymm0 + vpaddd %ymm2,%ymm1,%ymm1 + vpaddd %ymm6,%ymm4,%ymm4 + vpaddd %ymm6,%ymm5,%ymm5 + vpaddd %ymm10,%ymm8,%ymm8 + vpaddd %ymm10,%ymm9,%ymm9 + vpaddd %ymm11,%ymm12,%ymm12 + vpaddd %ymm15,%ymm13,%ymm13 + vperm2i128 $0x02,%ymm0,%ymm4,%ymm3 + + vpand L$clamp(%rip),%ymm3,%ymm3 + vmovdqa %ymm3,0+0(%rbp) + + vperm2i128 $0x13,%ymm0,%ymm4,%ymm0 + vperm2i128 $0x13,%ymm8,%ymm12,%ymm4 + vperm2i128 $0x02,%ymm1,%ymm5,%ymm8 + vperm2i128 $0x02,%ymm9,%ymm13,%ymm12 + vperm2i128 $0x13,%ymm1,%ymm5,%ymm1 + vperm2i128 $0x13,%ymm9,%ymm13,%ymm5 +L$seal_avx2_short: + movq %r8,%r8 + call poly_hash_ad_internal + xorq %rcx,%rcx +L$seal_avx2_short_hash_remainder: + cmpq $16,%rcx + jb L$seal_avx2_short_loop + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + subq $16,%rcx + addq $16,%rdi + jmp L$seal_avx2_short_hash_remainder +L$seal_avx2_short_loop: + cmpq $32,%rbx + jb L$seal_avx2_short_tail + subq $32,%rbx + + vpxor (%rsi),%ymm0,%ymm0 + vmovdqu %ymm0,(%rdi) + leaq 32(%rsi),%rsi + + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + addq 0+16(%rdi),%r10 + adcq 8+16(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 32(%rdi),%rdi + + vmovdqa %ymm4,%ymm0 + vmovdqa %ymm8,%ymm4 + vmovdqa %ymm12,%ymm8 + vmovdqa %ymm1,%ymm12 + vmovdqa %ymm5,%ymm1 + vmovdqa %ymm9,%ymm5 + vmovdqa %ymm13,%ymm9 + vmovdqa %ymm2,%ymm13 + vmovdqa %ymm6,%ymm2 + jmp L$seal_avx2_short_loop +L$seal_avx2_short_tail: + cmpq $16,%rbx + jb L$seal_avx2_exit + subq $16,%rbx + vpxor (%rsi),%xmm0,%xmm3 + vmovdqu %xmm3,(%rdi) + leaq 16(%rsi),%rsi + addq 0+0(%rdi),%r10 + adcq 8+0(%rdi),%r11 + adcq $1,%r12 + movq 0+0+0(%rbp),%rax + movq %rax,%r15 + mulq %r10 + movq %rax,%r13 + movq %rdx,%r14 + movq 0+0+0(%rbp),%rax + mulq %r11 + imulq %r12,%r15 + addq %rax,%r14 + adcq %rdx,%r15 + movq 8+0+0(%rbp),%rax + movq %rax,%r9 + mulq %r10 + addq %rax,%r14 + adcq $0,%rdx + movq %rdx,%r10 + movq 8+0+0(%rbp),%rax + mulq %r11 + addq %rax,%r15 + adcq $0,%rdx + imulq %r12,%r9 + addq %r10,%r15 + adcq %rdx,%r9 + movq %r13,%r10 + movq %r14,%r11 + movq %r15,%r12 + andq $3,%r12 + movq %r15,%r13 + andq $-4,%r13 + movq %r9,%r14 + shrdq $2,%r9,%r15 + shrq $2,%r9 + addq %r13,%r15 + adcq %r14,%r9 + addq %r15,%r10 + adcq %r9,%r11 + adcq $0,%r12 + + leaq 16(%rdi),%rdi + vextracti128 $1,%ymm0,%xmm0 +L$seal_avx2_exit: + vzeroupper + jmp L$seal_sse_tail_16 + + +#endif diff --git a/http/vendor/ring/pregenerated/chacha20_poly1305_x86_64-nasm.asm b/http/vendor/ring/pregenerated/chacha20_poly1305_x86_64-nasm.asm new file mode 100644 index 0000000..127dbe3 --- /dev/null +++ b/http/vendor/ring/pregenerated/chacha20_poly1305_x86_64-nasm.asm @@ -0,0 +1,9021 @@ +; This file is generated from a similarly-named Perl script in the BoringSSL +; source tree. Do not edit by hand. + +%ifidn __OUTPUT_FORMAT__, win64 +default rel +%define XMMWORD +%define YMMWORD +%define ZMMWORD +%define _CET_ENDBR + +%include "ring_core_generated/prefix_symbols_nasm.inc" +section .rdata rdata align=8 +ALIGN 64 +chacha20_poly1305_constants: +$L$chacha20_consts: + DB 'e','x','p','a','n','d',' ','3','2','-','b','y','t','e',' ','k' + DB 'e','x','p','a','n','d',' ','3','2','-','b','y','t','e',' ','k' +$L$rol8: + DB 3,0,1,2,7,4,5,6,11,8,9,10,15,12,13,14 + DB 3,0,1,2,7,4,5,6,11,8,9,10,15,12,13,14 +$L$rol16: + DB 2,3,0,1,6,7,4,5,10,11,8,9,14,15,12,13 + DB 2,3,0,1,6,7,4,5,10,11,8,9,14,15,12,13 +$L$avx2_init: + DD 0,0,0,0 +$L$sse_inc: + DD 1,0,0,0 +$L$avx2_inc: + DD 2,0,0,0,2,0,0,0 +$L$clamp: + DQ 0x0FFFFFFC0FFFFFFF,0x0FFFFFFC0FFFFFFC + DQ 0xFFFFFFFFFFFFFFFF,0xFFFFFFFFFFFFFFFF +ALIGN 16 +$L$and_masks: + DB 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + DB 0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + DB 0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + DB 0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + DB 0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + DB 0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + DB 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + DB 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + DB 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00 + DB 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00 + DB 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00 + DB 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00 + DB 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00 + DB 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00 + DB 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00 + DB 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff +section .text code align=64 + + + +ALIGN 64 +poly_hash_ad_internal: + + + xor r10,r10 + xor r11,r11 + xor r12,r12 + cmp r8,13 + jne NEAR $L$hash_ad_loop +$L$poly_fast_tls_ad: + + mov r10,QWORD[rcx] + mov r11,QWORD[5+rcx] + shr r11,24 + mov r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + ret +$L$hash_ad_loop: + + cmp r8,16 + jb NEAR $L$hash_ad_tail + add r10,QWORD[((0+0))+rcx] + adc r11,QWORD[((8+0))+rcx] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + lea rcx,[16+rcx] + sub r8,16 + jmp NEAR $L$hash_ad_loop +$L$hash_ad_tail: + cmp r8,0 + je NEAR $L$hash_ad_done + + xor r13,r13 + xor r14,r14 + xor r15,r15 + add rcx,r8 +$L$hash_ad_tail_loop: + shld r14,r13,8 + shl r13,8 + movzx r15,BYTE[((-1))+rcx] + xor r13,r15 + dec rcx + dec r8 + jne NEAR $L$hash_ad_tail_loop + + add r10,r13 + adc r11,r14 + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + +$L$hash_ad_done: + ret + + + +global chacha20_poly1305_open_sse41 + +ALIGN 64 +chacha20_poly1305_open_sse41: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_chacha20_poly1305_open_sse41: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + mov rcx,r9 + mov r8,QWORD[40+rsp] + mov r9,QWORD[48+rsp] + + + +_CET_ENDBR + push rbp + + push rbx + + push r12 + + push r13 + + push r14 + + push r15 + + + + push r9 + + sub rsp,288 + 160 + 32 + + + lea rbp,[32+rsp] + and rbp,-32 + + movaps XMMWORD[(0+0)+rbp],xmm6 + movaps XMMWORD[(16+0)+rbp],xmm7 + movaps XMMWORD[(32+0)+rbp],xmm8 + movaps XMMWORD[(48+0)+rbp],xmm9 + movaps XMMWORD[(64+0)+rbp],xmm10 + movaps XMMWORD[(80+0)+rbp],xmm11 + movaps XMMWORD[(96+0)+rbp],xmm12 + movaps XMMWORD[(112+0)+rbp],xmm13 + movaps XMMWORD[(128+0)+rbp],xmm14 + movaps XMMWORD[(144+0)+rbp],xmm15 + + mov rbx,rdx + mov QWORD[((0+160+32))+rbp],r8 + mov QWORD[((8+160+32))+rbp],rbx + + cmp rbx,128 + jbe NEAR $L$open_sse_128 + + movdqa xmm0,XMMWORD[$L$chacha20_consts] + movdqu xmm4,XMMWORD[r9] + movdqu xmm8,XMMWORD[16+r9] + movdqu xmm12,XMMWORD[32+r9] + + movdqa xmm7,xmm12 + + movdqa XMMWORD[(160+48)+rbp],xmm4 + movdqa XMMWORD[(160+64)+rbp],xmm8 + movdqa XMMWORD[(160+96)+rbp],xmm12 + mov r10,10 +$L$open_sse_init_rounds: + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol16] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,12 + psrld xmm4,20 + pxor xmm4,xmm3 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol8] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,7 + psrld xmm4,25 + pxor xmm4,xmm3 +DB 102,15,58,15,228,4 +DB 102,69,15,58,15,192,8 +DB 102,69,15,58,15,228,12 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol16] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,12 + psrld xmm4,20 + pxor xmm4,xmm3 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol8] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,7 + psrld xmm4,25 + pxor xmm4,xmm3 +DB 102,15,58,15,228,12 +DB 102,69,15,58,15,192,8 +DB 102,69,15,58,15,228,4 + + dec r10 + jne NEAR $L$open_sse_init_rounds + + paddd xmm0,XMMWORD[$L$chacha20_consts] + paddd xmm4,XMMWORD[((160+48))+rbp] + + pand xmm0,XMMWORD[$L$clamp] + movdqa XMMWORD[(160+0)+rbp],xmm0 + movdqa XMMWORD[(160+16)+rbp],xmm4 + + mov r8,r8 + call poly_hash_ad_internal +$L$open_sse_main_loop: + cmp rbx,16*16 + jb NEAR $L$open_sse_tail + + movdqa xmm0,XMMWORD[$L$chacha20_consts] + movdqa xmm4,XMMWORD[((160+48))+rbp] + movdqa xmm8,XMMWORD[((160+64))+rbp] + movdqa xmm1,xmm0 + movdqa xmm5,xmm4 + movdqa xmm9,xmm8 + movdqa xmm2,xmm0 + movdqa xmm6,xmm4 + movdqa xmm10,xmm8 + movdqa xmm3,xmm0 + movdqa xmm7,xmm4 + movdqa xmm11,xmm8 + movdqa xmm15,XMMWORD[((160+96))+rbp] + paddd xmm15,XMMWORD[$L$sse_inc] + movdqa xmm14,xmm15 + paddd xmm14,XMMWORD[$L$sse_inc] + movdqa xmm13,xmm14 + paddd xmm13,XMMWORD[$L$sse_inc] + movdqa xmm12,xmm13 + paddd xmm12,XMMWORD[$L$sse_inc] + movdqa XMMWORD[(160+96)+rbp],xmm12 + movdqa XMMWORD[(160+112)+rbp],xmm13 + movdqa XMMWORD[(160+128)+rbp],xmm14 + movdqa XMMWORD[(160+144)+rbp],xmm15 + + + + mov rcx,4 + mov r8,rsi +$L$open_sse_main_loop_rounds: + movdqa XMMWORD[(160+80)+rbp],xmm8 + movdqa xmm8,XMMWORD[$L$rol16] + paddd xmm3,xmm7 + paddd xmm2,xmm6 + paddd xmm1,xmm5 + paddd xmm0,xmm4 + pxor xmm15,xmm3 + pxor xmm14,xmm2 + pxor xmm13,xmm1 + pxor xmm12,xmm0 +DB 102,69,15,56,0,248 +DB 102,69,15,56,0,240 +DB 102,69,15,56,0,232 +DB 102,69,15,56,0,224 + movdqa xmm8,XMMWORD[((160+80))+rbp] + paddd xmm11,xmm15 + paddd xmm10,xmm14 + paddd xmm9,xmm13 + paddd xmm8,xmm12 + pxor xmm7,xmm11 + add r10,QWORD[((0+0))+r8] + adc r11,QWORD[((8+0))+r8] + adc r12,1 + + lea r8,[16+r8] + pxor xmm6,xmm10 + pxor xmm5,xmm9 + pxor xmm4,xmm8 + movdqa XMMWORD[(160+80)+rbp],xmm8 + movdqa xmm8,xmm7 + psrld xmm8,20 + pslld xmm7,32-20 + pxor xmm7,xmm8 + movdqa xmm8,xmm6 + psrld xmm8,20 + pslld xmm6,32-20 + pxor xmm6,xmm8 + movdqa xmm8,xmm5 + psrld xmm8,20 + pslld xmm5,32-20 + pxor xmm5,xmm8 + movdqa xmm8,xmm4 + psrld xmm8,20 + pslld xmm4,32-20 + pxor xmm4,xmm8 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + movdqa xmm8,XMMWORD[$L$rol8] + paddd xmm3,xmm7 + paddd xmm2,xmm6 + paddd xmm1,xmm5 + paddd xmm0,xmm4 + pxor xmm15,xmm3 + pxor xmm14,xmm2 + pxor xmm13,xmm1 + pxor xmm12,xmm0 +DB 102,69,15,56,0,248 +DB 102,69,15,56,0,240 +DB 102,69,15,56,0,232 +DB 102,69,15,56,0,224 + movdqa xmm8,XMMWORD[((160+80))+rbp] + paddd xmm11,xmm15 + paddd xmm10,xmm14 + paddd xmm9,xmm13 + paddd xmm8,xmm12 + pxor xmm7,xmm11 + pxor xmm6,xmm10 + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + pxor xmm5,xmm9 + pxor xmm4,xmm8 + movdqa XMMWORD[(160+80)+rbp],xmm8 + movdqa xmm8,xmm7 + psrld xmm8,25 + pslld xmm7,32-25 + pxor xmm7,xmm8 + movdqa xmm8,xmm6 + psrld xmm8,25 + pslld xmm6,32-25 + pxor xmm6,xmm8 + movdqa xmm8,xmm5 + psrld xmm8,25 + pslld xmm5,32-25 + pxor xmm5,xmm8 + movdqa xmm8,xmm4 + psrld xmm8,25 + pslld xmm4,32-25 + pxor xmm4,xmm8 + movdqa xmm8,XMMWORD[((160+80))+rbp] + imul r9,r12 + add r15,r10 + adc r9,rdx +DB 102,15,58,15,255,4 +DB 102,69,15,58,15,219,8 +DB 102,69,15,58,15,255,12 +DB 102,15,58,15,246,4 +DB 102,69,15,58,15,210,8 +DB 102,69,15,58,15,246,12 +DB 102,15,58,15,237,4 +DB 102,69,15,58,15,201,8 +DB 102,69,15,58,15,237,12 +DB 102,15,58,15,228,4 +DB 102,69,15,58,15,192,8 +DB 102,69,15,58,15,228,12 + movdqa XMMWORD[(160+80)+rbp],xmm8 + movdqa xmm8,XMMWORD[$L$rol16] + paddd xmm3,xmm7 + paddd xmm2,xmm6 + paddd xmm1,xmm5 + paddd xmm0,xmm4 + pxor xmm15,xmm3 + pxor xmm14,xmm2 + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + pxor xmm13,xmm1 + pxor xmm12,xmm0 +DB 102,69,15,56,0,248 +DB 102,69,15,56,0,240 +DB 102,69,15,56,0,232 +DB 102,69,15,56,0,224 + movdqa xmm8,XMMWORD[((160+80))+rbp] + paddd xmm11,xmm15 + paddd xmm10,xmm14 + paddd xmm9,xmm13 + paddd xmm8,xmm12 + pxor xmm7,xmm11 + pxor xmm6,xmm10 + pxor xmm5,xmm9 + pxor xmm4,xmm8 + movdqa XMMWORD[(160+80)+rbp],xmm8 + movdqa xmm8,xmm7 + psrld xmm8,20 + pslld xmm7,32-20 + pxor xmm7,xmm8 + movdqa xmm8,xmm6 + psrld xmm8,20 + pslld xmm6,32-20 + pxor xmm6,xmm8 + movdqa xmm8,xmm5 + psrld xmm8,20 + pslld xmm5,32-20 + pxor xmm5,xmm8 + movdqa xmm8,xmm4 + psrld xmm8,20 + pslld xmm4,32-20 + pxor xmm4,xmm8 + movdqa xmm8,XMMWORD[$L$rol8] + paddd xmm3,xmm7 + paddd xmm2,xmm6 + paddd xmm1,xmm5 + paddd xmm0,xmm4 + pxor xmm15,xmm3 + pxor xmm14,xmm2 + pxor xmm13,xmm1 + pxor xmm12,xmm0 +DB 102,69,15,56,0,248 +DB 102,69,15,56,0,240 +DB 102,69,15,56,0,232 +DB 102,69,15,56,0,224 + movdqa xmm8,XMMWORD[((160+80))+rbp] + paddd xmm11,xmm15 + paddd xmm10,xmm14 + paddd xmm9,xmm13 + paddd xmm8,xmm12 + pxor xmm7,xmm11 + pxor xmm6,xmm10 + pxor xmm5,xmm9 + pxor xmm4,xmm8 + movdqa XMMWORD[(160+80)+rbp],xmm8 + movdqa xmm8,xmm7 + psrld xmm8,25 + pslld xmm7,32-25 + pxor xmm7,xmm8 + movdqa xmm8,xmm6 + psrld xmm8,25 + pslld xmm6,32-25 + pxor xmm6,xmm8 + movdqa xmm8,xmm5 + psrld xmm8,25 + pslld xmm5,32-25 + pxor xmm5,xmm8 + movdqa xmm8,xmm4 + psrld xmm8,25 + pslld xmm4,32-25 + pxor xmm4,xmm8 + movdqa xmm8,XMMWORD[((160+80))+rbp] +DB 102,15,58,15,255,12 +DB 102,69,15,58,15,219,8 +DB 102,69,15,58,15,255,4 +DB 102,15,58,15,246,12 +DB 102,69,15,58,15,210,8 +DB 102,69,15,58,15,246,4 +DB 102,15,58,15,237,12 +DB 102,69,15,58,15,201,8 +DB 102,69,15,58,15,237,4 +DB 102,15,58,15,228,12 +DB 102,69,15,58,15,192,8 +DB 102,69,15,58,15,228,4 + + dec rcx + jge NEAR $L$open_sse_main_loop_rounds + add r10,QWORD[((0+0))+r8] + adc r11,QWORD[((8+0))+r8] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + lea r8,[16+r8] + cmp rcx,-6 + jg NEAR $L$open_sse_main_loop_rounds + paddd xmm3,XMMWORD[$L$chacha20_consts] + paddd xmm7,XMMWORD[((160+48))+rbp] + paddd xmm11,XMMWORD[((160+64))+rbp] + paddd xmm15,XMMWORD[((160+144))+rbp] + paddd xmm2,XMMWORD[$L$chacha20_consts] + paddd xmm6,XMMWORD[((160+48))+rbp] + paddd xmm10,XMMWORD[((160+64))+rbp] + paddd xmm14,XMMWORD[((160+128))+rbp] + paddd xmm1,XMMWORD[$L$chacha20_consts] + paddd xmm5,XMMWORD[((160+48))+rbp] + paddd xmm9,XMMWORD[((160+64))+rbp] + paddd xmm13,XMMWORD[((160+112))+rbp] + paddd xmm0,XMMWORD[$L$chacha20_consts] + paddd xmm4,XMMWORD[((160+48))+rbp] + paddd xmm8,XMMWORD[((160+64))+rbp] + paddd xmm12,XMMWORD[((160+96))+rbp] + movdqa XMMWORD[(160+80)+rbp],xmm12 + movdqu xmm12,XMMWORD[((0 + 0))+rsi] + pxor xmm12,xmm3 + movdqu XMMWORD[(0 + 0)+rdi],xmm12 + movdqu xmm12,XMMWORD[((16 + 0))+rsi] + pxor xmm12,xmm7 + movdqu XMMWORD[(16 + 0)+rdi],xmm12 + movdqu xmm12,XMMWORD[((32 + 0))+rsi] + pxor xmm12,xmm11 + movdqu XMMWORD[(32 + 0)+rdi],xmm12 + movdqu xmm12,XMMWORD[((48 + 0))+rsi] + pxor xmm12,xmm15 + movdqu XMMWORD[(48 + 0)+rdi],xmm12 + movdqu xmm3,XMMWORD[((0 + 64))+rsi] + movdqu xmm7,XMMWORD[((16 + 64))+rsi] + movdqu xmm11,XMMWORD[((32 + 64))+rsi] + movdqu xmm15,XMMWORD[((48 + 64))+rsi] + pxor xmm2,xmm3 + pxor xmm6,xmm7 + pxor xmm10,xmm11 + pxor xmm15,xmm14 + movdqu XMMWORD[(0 + 64)+rdi],xmm2 + movdqu XMMWORD[(16 + 64)+rdi],xmm6 + movdqu XMMWORD[(32 + 64)+rdi],xmm10 + movdqu XMMWORD[(48 + 64)+rdi],xmm15 + movdqu xmm3,XMMWORD[((0 + 128))+rsi] + movdqu xmm7,XMMWORD[((16 + 128))+rsi] + movdqu xmm11,XMMWORD[((32 + 128))+rsi] + movdqu xmm15,XMMWORD[((48 + 128))+rsi] + pxor xmm1,xmm3 + pxor xmm5,xmm7 + pxor xmm9,xmm11 + pxor xmm15,xmm13 + movdqu XMMWORD[(0 + 128)+rdi],xmm1 + movdqu XMMWORD[(16 + 128)+rdi],xmm5 + movdqu XMMWORD[(32 + 128)+rdi],xmm9 + movdqu XMMWORD[(48 + 128)+rdi],xmm15 + movdqu xmm3,XMMWORD[((0 + 192))+rsi] + movdqu xmm7,XMMWORD[((16 + 192))+rsi] + movdqu xmm11,XMMWORD[((32 + 192))+rsi] + movdqu xmm15,XMMWORD[((48 + 192))+rsi] + pxor xmm0,xmm3 + pxor xmm4,xmm7 + pxor xmm8,xmm11 + pxor xmm15,XMMWORD[((160+80))+rbp] + movdqu XMMWORD[(0 + 192)+rdi],xmm0 + movdqu XMMWORD[(16 + 192)+rdi],xmm4 + movdqu XMMWORD[(32 + 192)+rdi],xmm8 + movdqu XMMWORD[(48 + 192)+rdi],xmm15 + + lea rsi,[256+rsi] + lea rdi,[256+rdi] + sub rbx,16*16 + jmp NEAR $L$open_sse_main_loop +$L$open_sse_tail: + + test rbx,rbx + jz NEAR $L$open_sse_finalize + cmp rbx,12*16 + ja NEAR $L$open_sse_tail_256 + cmp rbx,8*16 + ja NEAR $L$open_sse_tail_192 + cmp rbx,4*16 + ja NEAR $L$open_sse_tail_128 + movdqa xmm0,XMMWORD[$L$chacha20_consts] + movdqa xmm4,XMMWORD[((160+48))+rbp] + movdqa xmm8,XMMWORD[((160+64))+rbp] + movdqa xmm12,XMMWORD[((160+96))+rbp] + paddd xmm12,XMMWORD[$L$sse_inc] + movdqa XMMWORD[(160+96)+rbp],xmm12 + + xor r8,r8 + mov rcx,rbx + cmp rcx,16 + jb NEAR $L$open_sse_tail_64_rounds +$L$open_sse_tail_64_rounds_and_x1hash: + add r10,QWORD[((0+0))+r8*1+rsi] + adc r11,QWORD[((8+0))+r8*1+rsi] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + sub rcx,16 +$L$open_sse_tail_64_rounds: + add r8,16 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol16] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,12 + psrld xmm4,20 + pxor xmm4,xmm3 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol8] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,7 + psrld xmm4,25 + pxor xmm4,xmm3 +DB 102,15,58,15,228,4 +DB 102,69,15,58,15,192,8 +DB 102,69,15,58,15,228,12 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol16] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,12 + psrld xmm4,20 + pxor xmm4,xmm3 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol8] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,7 + psrld xmm4,25 + pxor xmm4,xmm3 +DB 102,15,58,15,228,12 +DB 102,69,15,58,15,192,8 +DB 102,69,15,58,15,228,4 + + cmp rcx,16 + jae NEAR $L$open_sse_tail_64_rounds_and_x1hash + cmp r8,10*16 + jne NEAR $L$open_sse_tail_64_rounds + paddd xmm0,XMMWORD[$L$chacha20_consts] + paddd xmm4,XMMWORD[((160+48))+rbp] + paddd xmm8,XMMWORD[((160+64))+rbp] + paddd xmm12,XMMWORD[((160+96))+rbp] + + jmp NEAR $L$open_sse_tail_64_dec_loop + +$L$open_sse_tail_128: + movdqa xmm0,XMMWORD[$L$chacha20_consts] + movdqa xmm4,XMMWORD[((160+48))+rbp] + movdqa xmm8,XMMWORD[((160+64))+rbp] + movdqa xmm1,xmm0 + movdqa xmm5,xmm4 + movdqa xmm9,xmm8 + movdqa xmm13,XMMWORD[((160+96))+rbp] + paddd xmm13,XMMWORD[$L$sse_inc] + movdqa xmm12,xmm13 + paddd xmm12,XMMWORD[$L$sse_inc] + movdqa XMMWORD[(160+96)+rbp],xmm12 + movdqa XMMWORD[(160+112)+rbp],xmm13 + + mov rcx,rbx + and rcx,-16 + xor r8,r8 +$L$open_sse_tail_128_rounds_and_x1hash: + add r10,QWORD[((0+0))+r8*1+rsi] + adc r11,QWORD[((8+0))+r8*1+rsi] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + +$L$open_sse_tail_128_rounds: + add r8,16 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol16] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,12 + psrld xmm4,20 + pxor xmm4,xmm3 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol8] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,7 + psrld xmm4,25 + pxor xmm4,xmm3 +DB 102,15,58,15,228,4 +DB 102,69,15,58,15,192,8 +DB 102,69,15,58,15,228,12 + paddd xmm1,xmm5 + pxor xmm13,xmm1 + pshufb xmm13,XMMWORD[$L$rol16] + paddd xmm9,xmm13 + pxor xmm5,xmm9 + movdqa xmm3,xmm5 + pslld xmm3,12 + psrld xmm5,20 + pxor xmm5,xmm3 + paddd xmm1,xmm5 + pxor xmm13,xmm1 + pshufb xmm13,XMMWORD[$L$rol8] + paddd xmm9,xmm13 + pxor xmm5,xmm9 + movdqa xmm3,xmm5 + pslld xmm3,7 + psrld xmm5,25 + pxor xmm5,xmm3 +DB 102,15,58,15,237,4 +DB 102,69,15,58,15,201,8 +DB 102,69,15,58,15,237,12 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol16] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,12 + psrld xmm4,20 + pxor xmm4,xmm3 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol8] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,7 + psrld xmm4,25 + pxor xmm4,xmm3 +DB 102,15,58,15,228,12 +DB 102,69,15,58,15,192,8 +DB 102,69,15,58,15,228,4 + paddd xmm1,xmm5 + pxor xmm13,xmm1 + pshufb xmm13,XMMWORD[$L$rol16] + paddd xmm9,xmm13 + pxor xmm5,xmm9 + movdqa xmm3,xmm5 + pslld xmm3,12 + psrld xmm5,20 + pxor xmm5,xmm3 + paddd xmm1,xmm5 + pxor xmm13,xmm1 + pshufb xmm13,XMMWORD[$L$rol8] + paddd xmm9,xmm13 + pxor xmm5,xmm9 + movdqa xmm3,xmm5 + pslld xmm3,7 + psrld xmm5,25 + pxor xmm5,xmm3 +DB 102,15,58,15,237,12 +DB 102,69,15,58,15,201,8 +DB 102,69,15,58,15,237,4 + + cmp r8,rcx + jb NEAR $L$open_sse_tail_128_rounds_and_x1hash + cmp r8,10*16 + jne NEAR $L$open_sse_tail_128_rounds + paddd xmm1,XMMWORD[$L$chacha20_consts] + paddd xmm5,XMMWORD[((160+48))+rbp] + paddd xmm9,XMMWORD[((160+64))+rbp] + paddd xmm13,XMMWORD[((160+112))+rbp] + paddd xmm0,XMMWORD[$L$chacha20_consts] + paddd xmm4,XMMWORD[((160+48))+rbp] + paddd xmm8,XMMWORD[((160+64))+rbp] + paddd xmm12,XMMWORD[((160+96))+rbp] + movdqu xmm3,XMMWORD[((0 + 0))+rsi] + movdqu xmm7,XMMWORD[((16 + 0))+rsi] + movdqu xmm11,XMMWORD[((32 + 0))+rsi] + movdqu xmm15,XMMWORD[((48 + 0))+rsi] + pxor xmm1,xmm3 + pxor xmm5,xmm7 + pxor xmm9,xmm11 + pxor xmm15,xmm13 + movdqu XMMWORD[(0 + 0)+rdi],xmm1 + movdqu XMMWORD[(16 + 0)+rdi],xmm5 + movdqu XMMWORD[(32 + 0)+rdi],xmm9 + movdqu XMMWORD[(48 + 0)+rdi],xmm15 + + sub rbx,4*16 + lea rsi,[64+rsi] + lea rdi,[64+rdi] + jmp NEAR $L$open_sse_tail_64_dec_loop + +$L$open_sse_tail_192: + movdqa xmm0,XMMWORD[$L$chacha20_consts] + movdqa xmm4,XMMWORD[((160+48))+rbp] + movdqa xmm8,XMMWORD[((160+64))+rbp] + movdqa xmm1,xmm0 + movdqa xmm5,xmm4 + movdqa xmm9,xmm8 + movdqa xmm2,xmm0 + movdqa xmm6,xmm4 + movdqa xmm10,xmm8 + movdqa xmm14,XMMWORD[((160+96))+rbp] + paddd xmm14,XMMWORD[$L$sse_inc] + movdqa xmm13,xmm14 + paddd xmm13,XMMWORD[$L$sse_inc] + movdqa xmm12,xmm13 + paddd xmm12,XMMWORD[$L$sse_inc] + movdqa XMMWORD[(160+96)+rbp],xmm12 + movdqa XMMWORD[(160+112)+rbp],xmm13 + movdqa XMMWORD[(160+128)+rbp],xmm14 + + mov rcx,rbx + mov r8,10*16 + cmp rcx,10*16 + cmovg rcx,r8 + and rcx,-16 + xor r8,r8 +$L$open_sse_tail_192_rounds_and_x1hash: + add r10,QWORD[((0+0))+r8*1+rsi] + adc r11,QWORD[((8+0))+r8*1+rsi] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + +$L$open_sse_tail_192_rounds: + add r8,16 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol16] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,12 + psrld xmm4,20 + pxor xmm4,xmm3 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol8] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,7 + psrld xmm4,25 + pxor xmm4,xmm3 +DB 102,15,58,15,228,4 +DB 102,69,15,58,15,192,8 +DB 102,69,15,58,15,228,12 + paddd xmm1,xmm5 + pxor xmm13,xmm1 + pshufb xmm13,XMMWORD[$L$rol16] + paddd xmm9,xmm13 + pxor xmm5,xmm9 + movdqa xmm3,xmm5 + pslld xmm3,12 + psrld xmm5,20 + pxor xmm5,xmm3 + paddd xmm1,xmm5 + pxor xmm13,xmm1 + pshufb xmm13,XMMWORD[$L$rol8] + paddd xmm9,xmm13 + pxor xmm5,xmm9 + movdqa xmm3,xmm5 + pslld xmm3,7 + psrld xmm5,25 + pxor xmm5,xmm3 +DB 102,15,58,15,237,4 +DB 102,69,15,58,15,201,8 +DB 102,69,15,58,15,237,12 + paddd xmm2,xmm6 + pxor xmm14,xmm2 + pshufb xmm14,XMMWORD[$L$rol16] + paddd xmm10,xmm14 + pxor xmm6,xmm10 + movdqa xmm3,xmm6 + pslld xmm3,12 + psrld xmm6,20 + pxor xmm6,xmm3 + paddd xmm2,xmm6 + pxor xmm14,xmm2 + pshufb xmm14,XMMWORD[$L$rol8] + paddd xmm10,xmm14 + pxor xmm6,xmm10 + movdqa xmm3,xmm6 + pslld xmm3,7 + psrld xmm6,25 + pxor xmm6,xmm3 +DB 102,15,58,15,246,4 +DB 102,69,15,58,15,210,8 +DB 102,69,15,58,15,246,12 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol16] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,12 + psrld xmm4,20 + pxor xmm4,xmm3 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol8] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,7 + psrld xmm4,25 + pxor xmm4,xmm3 +DB 102,15,58,15,228,12 +DB 102,69,15,58,15,192,8 +DB 102,69,15,58,15,228,4 + paddd xmm1,xmm5 + pxor xmm13,xmm1 + pshufb xmm13,XMMWORD[$L$rol16] + paddd xmm9,xmm13 + pxor xmm5,xmm9 + movdqa xmm3,xmm5 + pslld xmm3,12 + psrld xmm5,20 + pxor xmm5,xmm3 + paddd xmm1,xmm5 + pxor xmm13,xmm1 + pshufb xmm13,XMMWORD[$L$rol8] + paddd xmm9,xmm13 + pxor xmm5,xmm9 + movdqa xmm3,xmm5 + pslld xmm3,7 + psrld xmm5,25 + pxor xmm5,xmm3 +DB 102,15,58,15,237,12 +DB 102,69,15,58,15,201,8 +DB 102,69,15,58,15,237,4 + paddd xmm2,xmm6 + pxor xmm14,xmm2 + pshufb xmm14,XMMWORD[$L$rol16] + paddd xmm10,xmm14 + pxor xmm6,xmm10 + movdqa xmm3,xmm6 + pslld xmm3,12 + psrld xmm6,20 + pxor xmm6,xmm3 + paddd xmm2,xmm6 + pxor xmm14,xmm2 + pshufb xmm14,XMMWORD[$L$rol8] + paddd xmm10,xmm14 + pxor xmm6,xmm10 + movdqa xmm3,xmm6 + pslld xmm3,7 + psrld xmm6,25 + pxor xmm6,xmm3 +DB 102,15,58,15,246,12 +DB 102,69,15,58,15,210,8 +DB 102,69,15,58,15,246,4 + + cmp r8,rcx + jb NEAR $L$open_sse_tail_192_rounds_and_x1hash + cmp r8,10*16 + jne NEAR $L$open_sse_tail_192_rounds + cmp rbx,11*16 + jb NEAR $L$open_sse_tail_192_finish + add r10,QWORD[((0+160))+rsi] + adc r11,QWORD[((8+160))+rsi] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + cmp rbx,12*16 + jb NEAR $L$open_sse_tail_192_finish + add r10,QWORD[((0+176))+rsi] + adc r11,QWORD[((8+176))+rsi] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + +$L$open_sse_tail_192_finish: + paddd xmm2,XMMWORD[$L$chacha20_consts] + paddd xmm6,XMMWORD[((160+48))+rbp] + paddd xmm10,XMMWORD[((160+64))+rbp] + paddd xmm14,XMMWORD[((160+128))+rbp] + paddd xmm1,XMMWORD[$L$chacha20_consts] + paddd xmm5,XMMWORD[((160+48))+rbp] + paddd xmm9,XMMWORD[((160+64))+rbp] + paddd xmm13,XMMWORD[((160+112))+rbp] + paddd xmm0,XMMWORD[$L$chacha20_consts] + paddd xmm4,XMMWORD[((160+48))+rbp] + paddd xmm8,XMMWORD[((160+64))+rbp] + paddd xmm12,XMMWORD[((160+96))+rbp] + movdqu xmm3,XMMWORD[((0 + 0))+rsi] + movdqu xmm7,XMMWORD[((16 + 0))+rsi] + movdqu xmm11,XMMWORD[((32 + 0))+rsi] + movdqu xmm15,XMMWORD[((48 + 0))+rsi] + pxor xmm2,xmm3 + pxor xmm6,xmm7 + pxor xmm10,xmm11 + pxor xmm15,xmm14 + movdqu XMMWORD[(0 + 0)+rdi],xmm2 + movdqu XMMWORD[(16 + 0)+rdi],xmm6 + movdqu XMMWORD[(32 + 0)+rdi],xmm10 + movdqu XMMWORD[(48 + 0)+rdi],xmm15 + movdqu xmm3,XMMWORD[((0 + 64))+rsi] + movdqu xmm7,XMMWORD[((16 + 64))+rsi] + movdqu xmm11,XMMWORD[((32 + 64))+rsi] + movdqu xmm15,XMMWORD[((48 + 64))+rsi] + pxor xmm1,xmm3 + pxor xmm5,xmm7 + pxor xmm9,xmm11 + pxor xmm15,xmm13 + movdqu XMMWORD[(0 + 64)+rdi],xmm1 + movdqu XMMWORD[(16 + 64)+rdi],xmm5 + movdqu XMMWORD[(32 + 64)+rdi],xmm9 + movdqu XMMWORD[(48 + 64)+rdi],xmm15 + + sub rbx,8*16 + lea rsi,[128+rsi] + lea rdi,[128+rdi] + jmp NEAR $L$open_sse_tail_64_dec_loop + +$L$open_sse_tail_256: + movdqa xmm0,XMMWORD[$L$chacha20_consts] + movdqa xmm4,XMMWORD[((160+48))+rbp] + movdqa xmm8,XMMWORD[((160+64))+rbp] + movdqa xmm1,xmm0 + movdqa xmm5,xmm4 + movdqa xmm9,xmm8 + movdqa xmm2,xmm0 + movdqa xmm6,xmm4 + movdqa xmm10,xmm8 + movdqa xmm3,xmm0 + movdqa xmm7,xmm4 + movdqa xmm11,xmm8 + movdqa xmm15,XMMWORD[((160+96))+rbp] + paddd xmm15,XMMWORD[$L$sse_inc] + movdqa xmm14,xmm15 + paddd xmm14,XMMWORD[$L$sse_inc] + movdqa xmm13,xmm14 + paddd xmm13,XMMWORD[$L$sse_inc] + movdqa xmm12,xmm13 + paddd xmm12,XMMWORD[$L$sse_inc] + movdqa XMMWORD[(160+96)+rbp],xmm12 + movdqa XMMWORD[(160+112)+rbp],xmm13 + movdqa XMMWORD[(160+128)+rbp],xmm14 + movdqa XMMWORD[(160+144)+rbp],xmm15 + + xor r8,r8 +$L$open_sse_tail_256_rounds_and_x1hash: + add r10,QWORD[((0+0))+r8*1+rsi] + adc r11,QWORD[((8+0))+r8*1+rsi] + adc r12,1 + movdqa XMMWORD[(160+80)+rbp],xmm11 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol16] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm11,xmm4 + pslld xmm11,12 + psrld xmm4,20 + pxor xmm4,xmm11 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol8] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm11,xmm4 + pslld xmm11,7 + psrld xmm4,25 + pxor xmm4,xmm11 +DB 102,15,58,15,228,4 +DB 102,69,15,58,15,192,8 +DB 102,69,15,58,15,228,12 + paddd xmm1,xmm5 + pxor xmm13,xmm1 + pshufb xmm13,XMMWORD[$L$rol16] + paddd xmm9,xmm13 + pxor xmm5,xmm9 + movdqa xmm11,xmm5 + pslld xmm11,12 + psrld xmm5,20 + pxor xmm5,xmm11 + paddd xmm1,xmm5 + pxor xmm13,xmm1 + pshufb xmm13,XMMWORD[$L$rol8] + paddd xmm9,xmm13 + pxor xmm5,xmm9 + movdqa xmm11,xmm5 + pslld xmm11,7 + psrld xmm5,25 + pxor xmm5,xmm11 +DB 102,15,58,15,237,4 +DB 102,69,15,58,15,201,8 +DB 102,69,15,58,15,237,12 + paddd xmm2,xmm6 + pxor xmm14,xmm2 + pshufb xmm14,XMMWORD[$L$rol16] + paddd xmm10,xmm14 + pxor xmm6,xmm10 + movdqa xmm11,xmm6 + pslld xmm11,12 + psrld xmm6,20 + pxor xmm6,xmm11 + paddd xmm2,xmm6 + pxor xmm14,xmm2 + pshufb xmm14,XMMWORD[$L$rol8] + paddd xmm10,xmm14 + pxor xmm6,xmm10 + movdqa xmm11,xmm6 + pslld xmm11,7 + psrld xmm6,25 + pxor xmm6,xmm11 +DB 102,15,58,15,246,4 +DB 102,69,15,58,15,210,8 +DB 102,69,15,58,15,246,12 + movdqa xmm11,XMMWORD[((160+80))+rbp] + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + movdqa XMMWORD[(160+80)+rbp],xmm9 + paddd xmm3,xmm7 + pxor xmm15,xmm3 + pshufb xmm15,XMMWORD[$L$rol16] + paddd xmm11,xmm15 + pxor xmm7,xmm11 + movdqa xmm9,xmm7 + pslld xmm9,12 + psrld xmm7,20 + pxor xmm7,xmm9 + paddd xmm3,xmm7 + pxor xmm15,xmm3 + pshufb xmm15,XMMWORD[$L$rol8] + paddd xmm11,xmm15 + pxor xmm7,xmm11 + movdqa xmm9,xmm7 + pslld xmm9,7 + psrld xmm7,25 + pxor xmm7,xmm9 +DB 102,15,58,15,255,4 +DB 102,69,15,58,15,219,8 +DB 102,69,15,58,15,255,12 + movdqa xmm9,XMMWORD[((160+80))+rbp] + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + movdqa XMMWORD[(160+80)+rbp],xmm11 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol16] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm11,xmm4 + pslld xmm11,12 + psrld xmm4,20 + pxor xmm4,xmm11 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol8] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm11,xmm4 + pslld xmm11,7 + psrld xmm4,25 + pxor xmm4,xmm11 +DB 102,15,58,15,228,12 +DB 102,69,15,58,15,192,8 +DB 102,69,15,58,15,228,4 + paddd xmm1,xmm5 + pxor xmm13,xmm1 + pshufb xmm13,XMMWORD[$L$rol16] + paddd xmm9,xmm13 + pxor xmm5,xmm9 + movdqa xmm11,xmm5 + pslld xmm11,12 + psrld xmm5,20 + pxor xmm5,xmm11 + paddd xmm1,xmm5 + pxor xmm13,xmm1 + pshufb xmm13,XMMWORD[$L$rol8] + paddd xmm9,xmm13 + pxor xmm5,xmm9 + movdqa xmm11,xmm5 + pslld xmm11,7 + psrld xmm5,25 + pxor xmm5,xmm11 +DB 102,15,58,15,237,12 +DB 102,69,15,58,15,201,8 +DB 102,69,15,58,15,237,4 + imul r9,r12 + add r15,r10 + adc r9,rdx + paddd xmm2,xmm6 + pxor xmm14,xmm2 + pshufb xmm14,XMMWORD[$L$rol16] + paddd xmm10,xmm14 + pxor xmm6,xmm10 + movdqa xmm11,xmm6 + pslld xmm11,12 + psrld xmm6,20 + pxor xmm6,xmm11 + paddd xmm2,xmm6 + pxor xmm14,xmm2 + pshufb xmm14,XMMWORD[$L$rol8] + paddd xmm10,xmm14 + pxor xmm6,xmm10 + movdqa xmm11,xmm6 + pslld xmm11,7 + psrld xmm6,25 + pxor xmm6,xmm11 +DB 102,15,58,15,246,12 +DB 102,69,15,58,15,210,8 +DB 102,69,15,58,15,246,4 + movdqa xmm11,XMMWORD[((160+80))+rbp] + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + movdqa XMMWORD[(160+80)+rbp],xmm9 + paddd xmm3,xmm7 + pxor xmm15,xmm3 + pshufb xmm15,XMMWORD[$L$rol16] + paddd xmm11,xmm15 + pxor xmm7,xmm11 + movdqa xmm9,xmm7 + pslld xmm9,12 + psrld xmm7,20 + pxor xmm7,xmm9 + paddd xmm3,xmm7 + pxor xmm15,xmm3 + pshufb xmm15,XMMWORD[$L$rol8] + paddd xmm11,xmm15 + pxor xmm7,xmm11 + movdqa xmm9,xmm7 + pslld xmm9,7 + psrld xmm7,25 + pxor xmm7,xmm9 +DB 102,15,58,15,255,12 +DB 102,69,15,58,15,219,8 +DB 102,69,15,58,15,255,4 + movdqa xmm9,XMMWORD[((160+80))+rbp] + + add r8,16 + cmp r8,10*16 + jb NEAR $L$open_sse_tail_256_rounds_and_x1hash + + mov rcx,rbx + and rcx,-16 +$L$open_sse_tail_256_hash: + add r10,QWORD[((0+0))+r8*1+rsi] + adc r11,QWORD[((8+0))+r8*1+rsi] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + add r8,16 + cmp r8,rcx + jb NEAR $L$open_sse_tail_256_hash + paddd xmm3,XMMWORD[$L$chacha20_consts] + paddd xmm7,XMMWORD[((160+48))+rbp] + paddd xmm11,XMMWORD[((160+64))+rbp] + paddd xmm15,XMMWORD[((160+144))+rbp] + paddd xmm2,XMMWORD[$L$chacha20_consts] + paddd xmm6,XMMWORD[((160+48))+rbp] + paddd xmm10,XMMWORD[((160+64))+rbp] + paddd xmm14,XMMWORD[((160+128))+rbp] + paddd xmm1,XMMWORD[$L$chacha20_consts] + paddd xmm5,XMMWORD[((160+48))+rbp] + paddd xmm9,XMMWORD[((160+64))+rbp] + paddd xmm13,XMMWORD[((160+112))+rbp] + paddd xmm0,XMMWORD[$L$chacha20_consts] + paddd xmm4,XMMWORD[((160+48))+rbp] + paddd xmm8,XMMWORD[((160+64))+rbp] + paddd xmm12,XMMWORD[((160+96))+rbp] + movdqa XMMWORD[(160+80)+rbp],xmm12 + movdqu xmm12,XMMWORD[((0 + 0))+rsi] + pxor xmm12,xmm3 + movdqu XMMWORD[(0 + 0)+rdi],xmm12 + movdqu xmm12,XMMWORD[((16 + 0))+rsi] + pxor xmm12,xmm7 + movdqu XMMWORD[(16 + 0)+rdi],xmm12 + movdqu xmm12,XMMWORD[((32 + 0))+rsi] + pxor xmm12,xmm11 + movdqu XMMWORD[(32 + 0)+rdi],xmm12 + movdqu xmm12,XMMWORD[((48 + 0))+rsi] + pxor xmm12,xmm15 + movdqu XMMWORD[(48 + 0)+rdi],xmm12 + movdqu xmm3,XMMWORD[((0 + 64))+rsi] + movdqu xmm7,XMMWORD[((16 + 64))+rsi] + movdqu xmm11,XMMWORD[((32 + 64))+rsi] + movdqu xmm15,XMMWORD[((48 + 64))+rsi] + pxor xmm2,xmm3 + pxor xmm6,xmm7 + pxor xmm10,xmm11 + pxor xmm15,xmm14 + movdqu XMMWORD[(0 + 64)+rdi],xmm2 + movdqu XMMWORD[(16 + 64)+rdi],xmm6 + movdqu XMMWORD[(32 + 64)+rdi],xmm10 + movdqu XMMWORD[(48 + 64)+rdi],xmm15 + movdqu xmm3,XMMWORD[((0 + 128))+rsi] + movdqu xmm7,XMMWORD[((16 + 128))+rsi] + movdqu xmm11,XMMWORD[((32 + 128))+rsi] + movdqu xmm15,XMMWORD[((48 + 128))+rsi] + pxor xmm1,xmm3 + pxor xmm5,xmm7 + pxor xmm9,xmm11 + pxor xmm15,xmm13 + movdqu XMMWORD[(0 + 128)+rdi],xmm1 + movdqu XMMWORD[(16 + 128)+rdi],xmm5 + movdqu XMMWORD[(32 + 128)+rdi],xmm9 + movdqu XMMWORD[(48 + 128)+rdi],xmm15 + + movdqa xmm12,XMMWORD[((160+80))+rbp] + sub rbx,12*16 + lea rsi,[192+rsi] + lea rdi,[192+rdi] + + +$L$open_sse_tail_64_dec_loop: + cmp rbx,16 + jb NEAR $L$open_sse_tail_16_init + sub rbx,16 + movdqu xmm3,XMMWORD[rsi] + pxor xmm0,xmm3 + movdqu XMMWORD[rdi],xmm0 + lea rsi,[16+rsi] + lea rdi,[16+rdi] + movdqa xmm0,xmm4 + movdqa xmm4,xmm8 + movdqa xmm8,xmm12 + jmp NEAR $L$open_sse_tail_64_dec_loop +$L$open_sse_tail_16_init: + movdqa xmm1,xmm0 + + +$L$open_sse_tail_16: + test rbx,rbx + jz NEAR $L$open_sse_finalize + + + + pxor xmm3,xmm3 + lea rsi,[((-1))+rbx*1+rsi] + mov r8,rbx +$L$open_sse_tail_16_compose: + pslldq xmm3,1 + pinsrb xmm3,BYTE[rsi],0 + sub rsi,1 + sub r8,1 + jnz NEAR $L$open_sse_tail_16_compose + +DB 102,73,15,126,221 + pextrq r14,xmm3,1 + + pxor xmm3,xmm1 + + +$L$open_sse_tail_16_extract: + pextrb XMMWORD[rdi],xmm3,0 + psrldq xmm3,1 + add rdi,1 + sub rbx,1 + jne NEAR $L$open_sse_tail_16_extract + + add r10,r13 + adc r11,r14 + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + +$L$open_sse_finalize: + add r10,QWORD[((0+160+32))+rbp] + adc r11,QWORD[((8+160+32))+rbp] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + + mov r13,r10 + mov r14,r11 + mov r15,r12 + sub r10,-5 + sbb r11,-1 + sbb r12,3 + cmovc r10,r13 + cmovc r11,r14 + cmovc r12,r15 + + add r10,QWORD[((0+160+16))+rbp] + adc r11,QWORD[((8+160+16))+rbp] + + movaps xmm6,XMMWORD[((0+0))+rbp] + movaps xmm7,XMMWORD[((16+0))+rbp] + movaps xmm8,XMMWORD[((32+0))+rbp] + movaps xmm9,XMMWORD[((48+0))+rbp] + movaps xmm10,XMMWORD[((64+0))+rbp] + movaps xmm11,XMMWORD[((80+0))+rbp] + movaps xmm12,XMMWORD[((96+0))+rbp] + movaps xmm13,XMMWORD[((112+0))+rbp] + movaps xmm14,XMMWORD[((128+0))+rbp] + movaps xmm15,XMMWORD[((144+0))+rbp] + + + add rsp,288 + 160 + 32 + + + pop r9 + + mov QWORD[r9],r10 + mov QWORD[8+r9],r11 + pop r15 + + pop r14 + + pop r13 + + pop r12 + + pop rbx + + pop rbp + + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$open_sse_128: + + movdqu xmm0,XMMWORD[$L$chacha20_consts] + movdqa xmm1,xmm0 + movdqa xmm2,xmm0 + movdqu xmm4,XMMWORD[r9] + movdqa xmm5,xmm4 + movdqa xmm6,xmm4 + movdqu xmm8,XMMWORD[16+r9] + movdqa xmm9,xmm8 + movdqa xmm10,xmm8 + movdqu xmm12,XMMWORD[32+r9] + movdqa xmm13,xmm12 + paddd xmm13,XMMWORD[$L$sse_inc] + movdqa xmm14,xmm13 + paddd xmm14,XMMWORD[$L$sse_inc] + movdqa xmm7,xmm4 + movdqa xmm11,xmm8 + movdqa xmm15,xmm13 + mov r10,10 + +$L$open_sse_128_rounds: + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol16] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,12 + psrld xmm4,20 + pxor xmm4,xmm3 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol8] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,7 + psrld xmm4,25 + pxor xmm4,xmm3 +DB 102,15,58,15,228,4 +DB 102,69,15,58,15,192,8 +DB 102,69,15,58,15,228,12 + paddd xmm1,xmm5 + pxor xmm13,xmm1 + pshufb xmm13,XMMWORD[$L$rol16] + paddd xmm9,xmm13 + pxor xmm5,xmm9 + movdqa xmm3,xmm5 + pslld xmm3,12 + psrld xmm5,20 + pxor xmm5,xmm3 + paddd xmm1,xmm5 + pxor xmm13,xmm1 + pshufb xmm13,XMMWORD[$L$rol8] + paddd xmm9,xmm13 + pxor xmm5,xmm9 + movdqa xmm3,xmm5 + pslld xmm3,7 + psrld xmm5,25 + pxor xmm5,xmm3 +DB 102,15,58,15,237,4 +DB 102,69,15,58,15,201,8 +DB 102,69,15,58,15,237,12 + paddd xmm2,xmm6 + pxor xmm14,xmm2 + pshufb xmm14,XMMWORD[$L$rol16] + paddd xmm10,xmm14 + pxor xmm6,xmm10 + movdqa xmm3,xmm6 + pslld xmm3,12 + psrld xmm6,20 + pxor xmm6,xmm3 + paddd xmm2,xmm6 + pxor xmm14,xmm2 + pshufb xmm14,XMMWORD[$L$rol8] + paddd xmm10,xmm14 + pxor xmm6,xmm10 + movdqa xmm3,xmm6 + pslld xmm3,7 + psrld xmm6,25 + pxor xmm6,xmm3 +DB 102,15,58,15,246,4 +DB 102,69,15,58,15,210,8 +DB 102,69,15,58,15,246,12 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol16] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,12 + psrld xmm4,20 + pxor xmm4,xmm3 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol8] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,7 + psrld xmm4,25 + pxor xmm4,xmm3 +DB 102,15,58,15,228,12 +DB 102,69,15,58,15,192,8 +DB 102,69,15,58,15,228,4 + paddd xmm1,xmm5 + pxor xmm13,xmm1 + pshufb xmm13,XMMWORD[$L$rol16] + paddd xmm9,xmm13 + pxor xmm5,xmm9 + movdqa xmm3,xmm5 + pslld xmm3,12 + psrld xmm5,20 + pxor xmm5,xmm3 + paddd xmm1,xmm5 + pxor xmm13,xmm1 + pshufb xmm13,XMMWORD[$L$rol8] + paddd xmm9,xmm13 + pxor xmm5,xmm9 + movdqa xmm3,xmm5 + pslld xmm3,7 + psrld xmm5,25 + pxor xmm5,xmm3 +DB 102,15,58,15,237,12 +DB 102,69,15,58,15,201,8 +DB 102,69,15,58,15,237,4 + paddd xmm2,xmm6 + pxor xmm14,xmm2 + pshufb xmm14,XMMWORD[$L$rol16] + paddd xmm10,xmm14 + pxor xmm6,xmm10 + movdqa xmm3,xmm6 + pslld xmm3,12 + psrld xmm6,20 + pxor xmm6,xmm3 + paddd xmm2,xmm6 + pxor xmm14,xmm2 + pshufb xmm14,XMMWORD[$L$rol8] + paddd xmm10,xmm14 + pxor xmm6,xmm10 + movdqa xmm3,xmm6 + pslld xmm3,7 + psrld xmm6,25 + pxor xmm6,xmm3 +DB 102,15,58,15,246,12 +DB 102,69,15,58,15,210,8 +DB 102,69,15,58,15,246,4 + + dec r10 + jnz NEAR $L$open_sse_128_rounds + paddd xmm0,XMMWORD[$L$chacha20_consts] + paddd xmm1,XMMWORD[$L$chacha20_consts] + paddd xmm2,XMMWORD[$L$chacha20_consts] + paddd xmm4,xmm7 + paddd xmm5,xmm7 + paddd xmm6,xmm7 + paddd xmm9,xmm11 + paddd xmm10,xmm11 + paddd xmm13,xmm15 + paddd xmm15,XMMWORD[$L$sse_inc] + paddd xmm14,xmm15 + + pand xmm0,XMMWORD[$L$clamp] + movdqa XMMWORD[(160+0)+rbp],xmm0 + movdqa XMMWORD[(160+16)+rbp],xmm4 + + mov r8,r8 + call poly_hash_ad_internal +$L$open_sse_128_xor_hash: + cmp rbx,16 + jb NEAR $L$open_sse_tail_16 + sub rbx,16 + add r10,QWORD[((0+0))+rsi] + adc r11,QWORD[((8+0))+rsi] + adc r12,1 + + + movdqu xmm3,XMMWORD[rsi] + pxor xmm1,xmm3 + movdqu XMMWORD[rdi],xmm1 + lea rsi,[16+rsi] + lea rdi,[16+rdi] + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + + movdqa xmm1,xmm5 + movdqa xmm5,xmm9 + movdqa xmm9,xmm13 + movdqa xmm13,xmm2 + movdqa xmm2,xmm6 + movdqa xmm6,xmm10 + movdqa xmm10,xmm14 + jmp NEAR $L$open_sse_128_xor_hash +$L$SEH_end_chacha20_poly1305_open_sse41: + + + + + + + + +global chacha20_poly1305_seal_sse41 + +ALIGN 64 +chacha20_poly1305_seal_sse41: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_chacha20_poly1305_seal_sse41: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + mov rcx,r9 + mov r8,QWORD[40+rsp] + mov r9,QWORD[48+rsp] + + + +_CET_ENDBR + push rbp + + push rbx + + push r12 + + push r13 + + push r14 + + push r15 + + + + push r9 + + sub rsp,288 + 160 + 32 + + lea rbp,[32+rsp] + and rbp,-32 + + movaps XMMWORD[(0+0)+rbp],xmm6 + movaps XMMWORD[(16+0)+rbp],xmm7 + movaps XMMWORD[(32+0)+rbp],xmm8 + movaps XMMWORD[(48+0)+rbp],xmm9 + movaps XMMWORD[(64+0)+rbp],xmm10 + movaps XMMWORD[(80+0)+rbp],xmm11 + movaps XMMWORD[(96+0)+rbp],xmm12 + movaps XMMWORD[(112+0)+rbp],xmm13 + movaps XMMWORD[(128+0)+rbp],xmm14 + movaps XMMWORD[(144+0)+rbp],xmm15 + + mov rbx,QWORD[56+r9] + add rbx,rdx + mov QWORD[((0+160+32))+rbp],r8 + mov QWORD[((8+160+32))+rbp],rbx + mov rbx,rdx + + cmp rbx,128 + jbe NEAR $L$seal_sse_128 + + movdqa xmm0,XMMWORD[$L$chacha20_consts] + movdqu xmm4,XMMWORD[r9] + movdqu xmm8,XMMWORD[16+r9] + movdqu xmm12,XMMWORD[32+r9] + + movdqa xmm1,xmm0 + movdqa xmm2,xmm0 + movdqa xmm3,xmm0 + movdqa xmm5,xmm4 + movdqa xmm6,xmm4 + movdqa xmm7,xmm4 + movdqa xmm9,xmm8 + movdqa xmm10,xmm8 + movdqa xmm11,xmm8 + movdqa xmm15,xmm12 + paddd xmm12,XMMWORD[$L$sse_inc] + movdqa xmm14,xmm12 + paddd xmm12,XMMWORD[$L$sse_inc] + movdqa xmm13,xmm12 + paddd xmm12,XMMWORD[$L$sse_inc] + + movdqa XMMWORD[(160+48)+rbp],xmm4 + movdqa XMMWORD[(160+64)+rbp],xmm8 + movdqa XMMWORD[(160+96)+rbp],xmm12 + movdqa XMMWORD[(160+112)+rbp],xmm13 + movdqa XMMWORD[(160+128)+rbp],xmm14 + movdqa XMMWORD[(160+144)+rbp],xmm15 + mov r10,10 +$L$seal_sse_init_rounds: + movdqa XMMWORD[(160+80)+rbp],xmm8 + movdqa xmm8,XMMWORD[$L$rol16] + paddd xmm3,xmm7 + paddd xmm2,xmm6 + paddd xmm1,xmm5 + paddd xmm0,xmm4 + pxor xmm15,xmm3 + pxor xmm14,xmm2 + pxor xmm13,xmm1 + pxor xmm12,xmm0 +DB 102,69,15,56,0,248 +DB 102,69,15,56,0,240 +DB 102,69,15,56,0,232 +DB 102,69,15,56,0,224 + movdqa xmm8,XMMWORD[((160+80))+rbp] + paddd xmm11,xmm15 + paddd xmm10,xmm14 + paddd xmm9,xmm13 + paddd xmm8,xmm12 + pxor xmm7,xmm11 + pxor xmm6,xmm10 + pxor xmm5,xmm9 + pxor xmm4,xmm8 + movdqa XMMWORD[(160+80)+rbp],xmm8 + movdqa xmm8,xmm7 + psrld xmm8,20 + pslld xmm7,32-20 + pxor xmm7,xmm8 + movdqa xmm8,xmm6 + psrld xmm8,20 + pslld xmm6,32-20 + pxor xmm6,xmm8 + movdqa xmm8,xmm5 + psrld xmm8,20 + pslld xmm5,32-20 + pxor xmm5,xmm8 + movdqa xmm8,xmm4 + psrld xmm8,20 + pslld xmm4,32-20 + pxor xmm4,xmm8 + movdqa xmm8,XMMWORD[$L$rol8] + paddd xmm3,xmm7 + paddd xmm2,xmm6 + paddd xmm1,xmm5 + paddd xmm0,xmm4 + pxor xmm15,xmm3 + pxor xmm14,xmm2 + pxor xmm13,xmm1 + pxor xmm12,xmm0 +DB 102,69,15,56,0,248 +DB 102,69,15,56,0,240 +DB 102,69,15,56,0,232 +DB 102,69,15,56,0,224 + movdqa xmm8,XMMWORD[((160+80))+rbp] + paddd xmm11,xmm15 + paddd xmm10,xmm14 + paddd xmm9,xmm13 + paddd xmm8,xmm12 + pxor xmm7,xmm11 + pxor xmm6,xmm10 + pxor xmm5,xmm9 + pxor xmm4,xmm8 + movdqa XMMWORD[(160+80)+rbp],xmm8 + movdqa xmm8,xmm7 + psrld xmm8,25 + pslld xmm7,32-25 + pxor xmm7,xmm8 + movdqa xmm8,xmm6 + psrld xmm8,25 + pslld xmm6,32-25 + pxor xmm6,xmm8 + movdqa xmm8,xmm5 + psrld xmm8,25 + pslld xmm5,32-25 + pxor xmm5,xmm8 + movdqa xmm8,xmm4 + psrld xmm8,25 + pslld xmm4,32-25 + pxor xmm4,xmm8 + movdqa xmm8,XMMWORD[((160+80))+rbp] +DB 102,15,58,15,255,4 +DB 102,69,15,58,15,219,8 +DB 102,69,15,58,15,255,12 +DB 102,15,58,15,246,4 +DB 102,69,15,58,15,210,8 +DB 102,69,15,58,15,246,12 +DB 102,15,58,15,237,4 +DB 102,69,15,58,15,201,8 +DB 102,69,15,58,15,237,12 +DB 102,15,58,15,228,4 +DB 102,69,15,58,15,192,8 +DB 102,69,15,58,15,228,12 + movdqa XMMWORD[(160+80)+rbp],xmm8 + movdqa xmm8,XMMWORD[$L$rol16] + paddd xmm3,xmm7 + paddd xmm2,xmm6 + paddd xmm1,xmm5 + paddd xmm0,xmm4 + pxor xmm15,xmm3 + pxor xmm14,xmm2 + pxor xmm13,xmm1 + pxor xmm12,xmm0 +DB 102,69,15,56,0,248 +DB 102,69,15,56,0,240 +DB 102,69,15,56,0,232 +DB 102,69,15,56,0,224 + movdqa xmm8,XMMWORD[((160+80))+rbp] + paddd xmm11,xmm15 + paddd xmm10,xmm14 + paddd xmm9,xmm13 + paddd xmm8,xmm12 + pxor xmm7,xmm11 + pxor xmm6,xmm10 + pxor xmm5,xmm9 + pxor xmm4,xmm8 + movdqa XMMWORD[(160+80)+rbp],xmm8 + movdqa xmm8,xmm7 + psrld xmm8,20 + pslld xmm7,32-20 + pxor xmm7,xmm8 + movdqa xmm8,xmm6 + psrld xmm8,20 + pslld xmm6,32-20 + pxor xmm6,xmm8 + movdqa xmm8,xmm5 + psrld xmm8,20 + pslld xmm5,32-20 + pxor xmm5,xmm8 + movdqa xmm8,xmm4 + psrld xmm8,20 + pslld xmm4,32-20 + pxor xmm4,xmm8 + movdqa xmm8,XMMWORD[$L$rol8] + paddd xmm3,xmm7 + paddd xmm2,xmm6 + paddd xmm1,xmm5 + paddd xmm0,xmm4 + pxor xmm15,xmm3 + pxor xmm14,xmm2 + pxor xmm13,xmm1 + pxor xmm12,xmm0 +DB 102,69,15,56,0,248 +DB 102,69,15,56,0,240 +DB 102,69,15,56,0,232 +DB 102,69,15,56,0,224 + movdqa xmm8,XMMWORD[((160+80))+rbp] + paddd xmm11,xmm15 + paddd xmm10,xmm14 + paddd xmm9,xmm13 + paddd xmm8,xmm12 + pxor xmm7,xmm11 + pxor xmm6,xmm10 + pxor xmm5,xmm9 + pxor xmm4,xmm8 + movdqa XMMWORD[(160+80)+rbp],xmm8 + movdqa xmm8,xmm7 + psrld xmm8,25 + pslld xmm7,32-25 + pxor xmm7,xmm8 + movdqa xmm8,xmm6 + psrld xmm8,25 + pslld xmm6,32-25 + pxor xmm6,xmm8 + movdqa xmm8,xmm5 + psrld xmm8,25 + pslld xmm5,32-25 + pxor xmm5,xmm8 + movdqa xmm8,xmm4 + psrld xmm8,25 + pslld xmm4,32-25 + pxor xmm4,xmm8 + movdqa xmm8,XMMWORD[((160+80))+rbp] +DB 102,15,58,15,255,12 +DB 102,69,15,58,15,219,8 +DB 102,69,15,58,15,255,4 +DB 102,15,58,15,246,12 +DB 102,69,15,58,15,210,8 +DB 102,69,15,58,15,246,4 +DB 102,15,58,15,237,12 +DB 102,69,15,58,15,201,8 +DB 102,69,15,58,15,237,4 +DB 102,15,58,15,228,12 +DB 102,69,15,58,15,192,8 +DB 102,69,15,58,15,228,4 + + dec r10 + jnz NEAR $L$seal_sse_init_rounds + paddd xmm3,XMMWORD[$L$chacha20_consts] + paddd xmm7,XMMWORD[((160+48))+rbp] + paddd xmm11,XMMWORD[((160+64))+rbp] + paddd xmm15,XMMWORD[((160+144))+rbp] + paddd xmm2,XMMWORD[$L$chacha20_consts] + paddd xmm6,XMMWORD[((160+48))+rbp] + paddd xmm10,XMMWORD[((160+64))+rbp] + paddd xmm14,XMMWORD[((160+128))+rbp] + paddd xmm1,XMMWORD[$L$chacha20_consts] + paddd xmm5,XMMWORD[((160+48))+rbp] + paddd xmm9,XMMWORD[((160+64))+rbp] + paddd xmm13,XMMWORD[((160+112))+rbp] + paddd xmm0,XMMWORD[$L$chacha20_consts] + paddd xmm4,XMMWORD[((160+48))+rbp] + paddd xmm8,XMMWORD[((160+64))+rbp] + paddd xmm12,XMMWORD[((160+96))+rbp] + + + pand xmm3,XMMWORD[$L$clamp] + movdqa XMMWORD[(160+0)+rbp],xmm3 + movdqa XMMWORD[(160+16)+rbp],xmm7 + + mov r8,r8 + call poly_hash_ad_internal + movdqu xmm3,XMMWORD[((0 + 0))+rsi] + movdqu xmm7,XMMWORD[((16 + 0))+rsi] + movdqu xmm11,XMMWORD[((32 + 0))+rsi] + movdqu xmm15,XMMWORD[((48 + 0))+rsi] + pxor xmm2,xmm3 + pxor xmm6,xmm7 + pxor xmm10,xmm11 + pxor xmm15,xmm14 + movdqu XMMWORD[(0 + 0)+rdi],xmm2 + movdqu XMMWORD[(16 + 0)+rdi],xmm6 + movdqu XMMWORD[(32 + 0)+rdi],xmm10 + movdqu XMMWORD[(48 + 0)+rdi],xmm15 + movdqu xmm3,XMMWORD[((0 + 64))+rsi] + movdqu xmm7,XMMWORD[((16 + 64))+rsi] + movdqu xmm11,XMMWORD[((32 + 64))+rsi] + movdqu xmm15,XMMWORD[((48 + 64))+rsi] + pxor xmm1,xmm3 + pxor xmm5,xmm7 + pxor xmm9,xmm11 + pxor xmm15,xmm13 + movdqu XMMWORD[(0 + 64)+rdi],xmm1 + movdqu XMMWORD[(16 + 64)+rdi],xmm5 + movdqu XMMWORD[(32 + 64)+rdi],xmm9 + movdqu XMMWORD[(48 + 64)+rdi],xmm15 + + cmp rbx,12*16 + ja NEAR $L$seal_sse_main_init + mov rcx,8*16 + sub rbx,8*16 + lea rsi,[128+rsi] + jmp NEAR $L$seal_sse_128_tail_hash +$L$seal_sse_main_init: + movdqu xmm3,XMMWORD[((0 + 128))+rsi] + movdqu xmm7,XMMWORD[((16 + 128))+rsi] + movdqu xmm11,XMMWORD[((32 + 128))+rsi] + movdqu xmm15,XMMWORD[((48 + 128))+rsi] + pxor xmm0,xmm3 + pxor xmm4,xmm7 + pxor xmm8,xmm11 + pxor xmm15,xmm12 + movdqu XMMWORD[(0 + 128)+rdi],xmm0 + movdqu XMMWORD[(16 + 128)+rdi],xmm4 + movdqu XMMWORD[(32 + 128)+rdi],xmm8 + movdqu XMMWORD[(48 + 128)+rdi],xmm15 + + mov rcx,12*16 + sub rbx,12*16 + lea rsi,[192+rsi] + mov rcx,2 + mov r8,8 + cmp rbx,4*16 + jbe NEAR $L$seal_sse_tail_64 + cmp rbx,8*16 + jbe NEAR $L$seal_sse_tail_128 + cmp rbx,12*16 + jbe NEAR $L$seal_sse_tail_192 + +$L$seal_sse_main_loop: + movdqa xmm0,XMMWORD[$L$chacha20_consts] + movdqa xmm4,XMMWORD[((160+48))+rbp] + movdqa xmm8,XMMWORD[((160+64))+rbp] + movdqa xmm1,xmm0 + movdqa xmm5,xmm4 + movdqa xmm9,xmm8 + movdqa xmm2,xmm0 + movdqa xmm6,xmm4 + movdqa xmm10,xmm8 + movdqa xmm3,xmm0 + movdqa xmm7,xmm4 + movdqa xmm11,xmm8 + movdqa xmm15,XMMWORD[((160+96))+rbp] + paddd xmm15,XMMWORD[$L$sse_inc] + movdqa xmm14,xmm15 + paddd xmm14,XMMWORD[$L$sse_inc] + movdqa xmm13,xmm14 + paddd xmm13,XMMWORD[$L$sse_inc] + movdqa xmm12,xmm13 + paddd xmm12,XMMWORD[$L$sse_inc] + movdqa XMMWORD[(160+96)+rbp],xmm12 + movdqa XMMWORD[(160+112)+rbp],xmm13 + movdqa XMMWORD[(160+128)+rbp],xmm14 + movdqa XMMWORD[(160+144)+rbp],xmm15 + +ALIGN 32 +$L$seal_sse_main_rounds: + movdqa XMMWORD[(160+80)+rbp],xmm8 + movdqa xmm8,XMMWORD[$L$rol16] + paddd xmm3,xmm7 + paddd xmm2,xmm6 + paddd xmm1,xmm5 + paddd xmm0,xmm4 + pxor xmm15,xmm3 + pxor xmm14,xmm2 + pxor xmm13,xmm1 + pxor xmm12,xmm0 +DB 102,69,15,56,0,248 +DB 102,69,15,56,0,240 +DB 102,69,15,56,0,232 +DB 102,69,15,56,0,224 + movdqa xmm8,XMMWORD[((160+80))+rbp] + paddd xmm11,xmm15 + paddd xmm10,xmm14 + paddd xmm9,xmm13 + paddd xmm8,xmm12 + pxor xmm7,xmm11 + add r10,QWORD[((0+0))+rdi] + adc r11,QWORD[((8+0))+rdi] + adc r12,1 + pxor xmm6,xmm10 + pxor xmm5,xmm9 + pxor xmm4,xmm8 + movdqa XMMWORD[(160+80)+rbp],xmm8 + movdqa xmm8,xmm7 + psrld xmm8,20 + pslld xmm7,32-20 + pxor xmm7,xmm8 + movdqa xmm8,xmm6 + psrld xmm8,20 + pslld xmm6,32-20 + pxor xmm6,xmm8 + movdqa xmm8,xmm5 + psrld xmm8,20 + pslld xmm5,32-20 + pxor xmm5,xmm8 + movdqa xmm8,xmm4 + psrld xmm8,20 + pslld xmm4,32-20 + pxor xmm4,xmm8 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + movdqa xmm8,XMMWORD[$L$rol8] + paddd xmm3,xmm7 + paddd xmm2,xmm6 + paddd xmm1,xmm5 + paddd xmm0,xmm4 + pxor xmm15,xmm3 + pxor xmm14,xmm2 + pxor xmm13,xmm1 + pxor xmm12,xmm0 +DB 102,69,15,56,0,248 +DB 102,69,15,56,0,240 +DB 102,69,15,56,0,232 +DB 102,69,15,56,0,224 + movdqa xmm8,XMMWORD[((160+80))+rbp] + paddd xmm11,xmm15 + paddd xmm10,xmm14 + paddd xmm9,xmm13 + paddd xmm8,xmm12 + pxor xmm7,xmm11 + pxor xmm6,xmm10 + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + pxor xmm5,xmm9 + pxor xmm4,xmm8 + movdqa XMMWORD[(160+80)+rbp],xmm8 + movdqa xmm8,xmm7 + psrld xmm8,25 + pslld xmm7,32-25 + pxor xmm7,xmm8 + movdqa xmm8,xmm6 + psrld xmm8,25 + pslld xmm6,32-25 + pxor xmm6,xmm8 + movdqa xmm8,xmm5 + psrld xmm8,25 + pslld xmm5,32-25 + pxor xmm5,xmm8 + movdqa xmm8,xmm4 + psrld xmm8,25 + pslld xmm4,32-25 + pxor xmm4,xmm8 + movdqa xmm8,XMMWORD[((160+80))+rbp] + imul r9,r12 + add r15,r10 + adc r9,rdx +DB 102,15,58,15,255,4 +DB 102,69,15,58,15,219,8 +DB 102,69,15,58,15,255,12 +DB 102,15,58,15,246,4 +DB 102,69,15,58,15,210,8 +DB 102,69,15,58,15,246,12 +DB 102,15,58,15,237,4 +DB 102,69,15,58,15,201,8 +DB 102,69,15,58,15,237,12 +DB 102,15,58,15,228,4 +DB 102,69,15,58,15,192,8 +DB 102,69,15,58,15,228,12 + movdqa XMMWORD[(160+80)+rbp],xmm8 + movdqa xmm8,XMMWORD[$L$rol16] + paddd xmm3,xmm7 + paddd xmm2,xmm6 + paddd xmm1,xmm5 + paddd xmm0,xmm4 + pxor xmm15,xmm3 + pxor xmm14,xmm2 + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + pxor xmm13,xmm1 + pxor xmm12,xmm0 +DB 102,69,15,56,0,248 +DB 102,69,15,56,0,240 +DB 102,69,15,56,0,232 +DB 102,69,15,56,0,224 + movdqa xmm8,XMMWORD[((160+80))+rbp] + paddd xmm11,xmm15 + paddd xmm10,xmm14 + paddd xmm9,xmm13 + paddd xmm8,xmm12 + pxor xmm7,xmm11 + pxor xmm6,xmm10 + pxor xmm5,xmm9 + pxor xmm4,xmm8 + movdqa XMMWORD[(160+80)+rbp],xmm8 + movdqa xmm8,xmm7 + psrld xmm8,20 + pslld xmm7,32-20 + pxor xmm7,xmm8 + movdqa xmm8,xmm6 + psrld xmm8,20 + pslld xmm6,32-20 + pxor xmm6,xmm8 + movdqa xmm8,xmm5 + psrld xmm8,20 + pslld xmm5,32-20 + pxor xmm5,xmm8 + movdqa xmm8,xmm4 + psrld xmm8,20 + pslld xmm4,32-20 + pxor xmm4,xmm8 + movdqa xmm8,XMMWORD[$L$rol8] + paddd xmm3,xmm7 + paddd xmm2,xmm6 + paddd xmm1,xmm5 + paddd xmm0,xmm4 + pxor xmm15,xmm3 + pxor xmm14,xmm2 + pxor xmm13,xmm1 + pxor xmm12,xmm0 +DB 102,69,15,56,0,248 +DB 102,69,15,56,0,240 +DB 102,69,15,56,0,232 +DB 102,69,15,56,0,224 + movdqa xmm8,XMMWORD[((160+80))+rbp] + paddd xmm11,xmm15 + paddd xmm10,xmm14 + paddd xmm9,xmm13 + paddd xmm8,xmm12 + pxor xmm7,xmm11 + pxor xmm6,xmm10 + pxor xmm5,xmm9 + pxor xmm4,xmm8 + movdqa XMMWORD[(160+80)+rbp],xmm8 + movdqa xmm8,xmm7 + psrld xmm8,25 + pslld xmm7,32-25 + pxor xmm7,xmm8 + movdqa xmm8,xmm6 + psrld xmm8,25 + pslld xmm6,32-25 + pxor xmm6,xmm8 + movdqa xmm8,xmm5 + psrld xmm8,25 + pslld xmm5,32-25 + pxor xmm5,xmm8 + movdqa xmm8,xmm4 + psrld xmm8,25 + pslld xmm4,32-25 + pxor xmm4,xmm8 + movdqa xmm8,XMMWORD[((160+80))+rbp] +DB 102,15,58,15,255,12 +DB 102,69,15,58,15,219,8 +DB 102,69,15,58,15,255,4 +DB 102,15,58,15,246,12 +DB 102,69,15,58,15,210,8 +DB 102,69,15,58,15,246,4 +DB 102,15,58,15,237,12 +DB 102,69,15,58,15,201,8 +DB 102,69,15,58,15,237,4 +DB 102,15,58,15,228,12 +DB 102,69,15,58,15,192,8 +DB 102,69,15,58,15,228,4 + + lea rdi,[16+rdi] + dec r8 + jge NEAR $L$seal_sse_main_rounds + add r10,QWORD[((0+0))+rdi] + adc r11,QWORD[((8+0))+rdi] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + lea rdi,[16+rdi] + dec rcx + jg NEAR $L$seal_sse_main_rounds + paddd xmm3,XMMWORD[$L$chacha20_consts] + paddd xmm7,XMMWORD[((160+48))+rbp] + paddd xmm11,XMMWORD[((160+64))+rbp] + paddd xmm15,XMMWORD[((160+144))+rbp] + paddd xmm2,XMMWORD[$L$chacha20_consts] + paddd xmm6,XMMWORD[((160+48))+rbp] + paddd xmm10,XMMWORD[((160+64))+rbp] + paddd xmm14,XMMWORD[((160+128))+rbp] + paddd xmm1,XMMWORD[$L$chacha20_consts] + paddd xmm5,XMMWORD[((160+48))+rbp] + paddd xmm9,XMMWORD[((160+64))+rbp] + paddd xmm13,XMMWORD[((160+112))+rbp] + paddd xmm0,XMMWORD[$L$chacha20_consts] + paddd xmm4,XMMWORD[((160+48))+rbp] + paddd xmm8,XMMWORD[((160+64))+rbp] + paddd xmm12,XMMWORD[((160+96))+rbp] + + movdqa XMMWORD[(160+80)+rbp],xmm14 + movdqa XMMWORD[(160+80)+rbp],xmm14 + movdqu xmm14,XMMWORD[((0 + 0))+rsi] + pxor xmm14,xmm3 + movdqu XMMWORD[(0 + 0)+rdi],xmm14 + movdqu xmm14,XMMWORD[((16 + 0))+rsi] + pxor xmm14,xmm7 + movdqu XMMWORD[(16 + 0)+rdi],xmm14 + movdqu xmm14,XMMWORD[((32 + 0))+rsi] + pxor xmm14,xmm11 + movdqu XMMWORD[(32 + 0)+rdi],xmm14 + movdqu xmm14,XMMWORD[((48 + 0))+rsi] + pxor xmm14,xmm15 + movdqu XMMWORD[(48 + 0)+rdi],xmm14 + + movdqa xmm14,XMMWORD[((160+80))+rbp] + movdqu xmm3,XMMWORD[((0 + 64))+rsi] + movdqu xmm7,XMMWORD[((16 + 64))+rsi] + movdqu xmm11,XMMWORD[((32 + 64))+rsi] + movdqu xmm15,XMMWORD[((48 + 64))+rsi] + pxor xmm2,xmm3 + pxor xmm6,xmm7 + pxor xmm10,xmm11 + pxor xmm15,xmm14 + movdqu XMMWORD[(0 + 64)+rdi],xmm2 + movdqu XMMWORD[(16 + 64)+rdi],xmm6 + movdqu XMMWORD[(32 + 64)+rdi],xmm10 + movdqu XMMWORD[(48 + 64)+rdi],xmm15 + movdqu xmm3,XMMWORD[((0 + 128))+rsi] + movdqu xmm7,XMMWORD[((16 + 128))+rsi] + movdqu xmm11,XMMWORD[((32 + 128))+rsi] + movdqu xmm15,XMMWORD[((48 + 128))+rsi] + pxor xmm1,xmm3 + pxor xmm5,xmm7 + pxor xmm9,xmm11 + pxor xmm15,xmm13 + movdqu XMMWORD[(0 + 128)+rdi],xmm1 + movdqu XMMWORD[(16 + 128)+rdi],xmm5 + movdqu XMMWORD[(32 + 128)+rdi],xmm9 + movdqu XMMWORD[(48 + 128)+rdi],xmm15 + + cmp rbx,16*16 + ja NEAR $L$seal_sse_main_loop_xor + + mov rcx,12*16 + sub rbx,12*16 + lea rsi,[192+rsi] + jmp NEAR $L$seal_sse_128_tail_hash +$L$seal_sse_main_loop_xor: + movdqu xmm3,XMMWORD[((0 + 192))+rsi] + movdqu xmm7,XMMWORD[((16 + 192))+rsi] + movdqu xmm11,XMMWORD[((32 + 192))+rsi] + movdqu xmm15,XMMWORD[((48 + 192))+rsi] + pxor xmm0,xmm3 + pxor xmm4,xmm7 + pxor xmm8,xmm11 + pxor xmm15,xmm12 + movdqu XMMWORD[(0 + 192)+rdi],xmm0 + movdqu XMMWORD[(16 + 192)+rdi],xmm4 + movdqu XMMWORD[(32 + 192)+rdi],xmm8 + movdqu XMMWORD[(48 + 192)+rdi],xmm15 + + lea rsi,[256+rsi] + sub rbx,16*16 + mov rcx,6 + mov r8,4 + cmp rbx,12*16 + jg NEAR $L$seal_sse_main_loop + mov rcx,rbx + test rbx,rbx + je NEAR $L$seal_sse_128_tail_hash + mov rcx,6 + cmp rbx,8*16 + ja NEAR $L$seal_sse_tail_192 + cmp rbx,4*16 + ja NEAR $L$seal_sse_tail_128 + +$L$seal_sse_tail_64: + movdqa xmm0,XMMWORD[$L$chacha20_consts] + movdqa xmm4,XMMWORD[((160+48))+rbp] + movdqa xmm8,XMMWORD[((160+64))+rbp] + movdqa xmm12,XMMWORD[((160+96))+rbp] + paddd xmm12,XMMWORD[$L$sse_inc] + movdqa XMMWORD[(160+96)+rbp],xmm12 + +$L$seal_sse_tail_64_rounds_and_x2hash: + add r10,QWORD[((0+0))+rdi] + adc r11,QWORD[((8+0))+rdi] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + lea rdi,[16+rdi] +$L$seal_sse_tail_64_rounds_and_x1hash: + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol16] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,12 + psrld xmm4,20 + pxor xmm4,xmm3 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol8] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,7 + psrld xmm4,25 + pxor xmm4,xmm3 +DB 102,15,58,15,228,4 +DB 102,69,15,58,15,192,8 +DB 102,69,15,58,15,228,12 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol16] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,12 + psrld xmm4,20 + pxor xmm4,xmm3 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol8] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,7 + psrld xmm4,25 + pxor xmm4,xmm3 +DB 102,15,58,15,228,12 +DB 102,69,15,58,15,192,8 +DB 102,69,15,58,15,228,4 + add r10,QWORD[((0+0))+rdi] + adc r11,QWORD[((8+0))+rdi] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + lea rdi,[16+rdi] + dec rcx + jg NEAR $L$seal_sse_tail_64_rounds_and_x2hash + dec r8 + jge NEAR $L$seal_sse_tail_64_rounds_and_x1hash + paddd xmm0,XMMWORD[$L$chacha20_consts] + paddd xmm4,XMMWORD[((160+48))+rbp] + paddd xmm8,XMMWORD[((160+64))+rbp] + paddd xmm12,XMMWORD[((160+96))+rbp] + + jmp NEAR $L$seal_sse_128_tail_xor + +$L$seal_sse_tail_128: + movdqa xmm0,XMMWORD[$L$chacha20_consts] + movdqa xmm4,XMMWORD[((160+48))+rbp] + movdqa xmm8,XMMWORD[((160+64))+rbp] + movdqa xmm1,xmm0 + movdqa xmm5,xmm4 + movdqa xmm9,xmm8 + movdqa xmm13,XMMWORD[((160+96))+rbp] + paddd xmm13,XMMWORD[$L$sse_inc] + movdqa xmm12,xmm13 + paddd xmm12,XMMWORD[$L$sse_inc] + movdqa XMMWORD[(160+96)+rbp],xmm12 + movdqa XMMWORD[(160+112)+rbp],xmm13 + +$L$seal_sse_tail_128_rounds_and_x2hash: + add r10,QWORD[((0+0))+rdi] + adc r11,QWORD[((8+0))+rdi] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + lea rdi,[16+rdi] +$L$seal_sse_tail_128_rounds_and_x1hash: + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol16] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,12 + psrld xmm4,20 + pxor xmm4,xmm3 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol8] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,7 + psrld xmm4,25 + pxor xmm4,xmm3 +DB 102,15,58,15,228,4 +DB 102,69,15,58,15,192,8 +DB 102,69,15,58,15,228,12 + paddd xmm1,xmm5 + pxor xmm13,xmm1 + pshufb xmm13,XMMWORD[$L$rol16] + paddd xmm9,xmm13 + pxor xmm5,xmm9 + movdqa xmm3,xmm5 + pslld xmm3,12 + psrld xmm5,20 + pxor xmm5,xmm3 + paddd xmm1,xmm5 + pxor xmm13,xmm1 + pshufb xmm13,XMMWORD[$L$rol8] + paddd xmm9,xmm13 + pxor xmm5,xmm9 + movdqa xmm3,xmm5 + pslld xmm3,7 + psrld xmm5,25 + pxor xmm5,xmm3 +DB 102,15,58,15,237,4 +DB 102,69,15,58,15,201,8 +DB 102,69,15,58,15,237,12 + add r10,QWORD[((0+0))+rdi] + adc r11,QWORD[((8+0))+rdi] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol16] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,12 + psrld xmm4,20 + pxor xmm4,xmm3 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol8] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,7 + psrld xmm4,25 + pxor xmm4,xmm3 +DB 102,15,58,15,228,12 +DB 102,69,15,58,15,192,8 +DB 102,69,15,58,15,228,4 + paddd xmm1,xmm5 + pxor xmm13,xmm1 + pshufb xmm13,XMMWORD[$L$rol16] + paddd xmm9,xmm13 + pxor xmm5,xmm9 + movdqa xmm3,xmm5 + pslld xmm3,12 + psrld xmm5,20 + pxor xmm5,xmm3 + paddd xmm1,xmm5 + pxor xmm13,xmm1 + pshufb xmm13,XMMWORD[$L$rol8] + paddd xmm9,xmm13 + pxor xmm5,xmm9 + movdqa xmm3,xmm5 + pslld xmm3,7 + psrld xmm5,25 + pxor xmm5,xmm3 +DB 102,15,58,15,237,12 +DB 102,69,15,58,15,201,8 +DB 102,69,15,58,15,237,4 + + lea rdi,[16+rdi] + dec rcx + jg NEAR $L$seal_sse_tail_128_rounds_and_x2hash + dec r8 + jge NEAR $L$seal_sse_tail_128_rounds_and_x1hash + paddd xmm1,XMMWORD[$L$chacha20_consts] + paddd xmm5,XMMWORD[((160+48))+rbp] + paddd xmm9,XMMWORD[((160+64))+rbp] + paddd xmm13,XMMWORD[((160+112))+rbp] + paddd xmm0,XMMWORD[$L$chacha20_consts] + paddd xmm4,XMMWORD[((160+48))+rbp] + paddd xmm8,XMMWORD[((160+64))+rbp] + paddd xmm12,XMMWORD[((160+96))+rbp] + movdqu xmm3,XMMWORD[((0 + 0))+rsi] + movdqu xmm7,XMMWORD[((16 + 0))+rsi] + movdqu xmm11,XMMWORD[((32 + 0))+rsi] + movdqu xmm15,XMMWORD[((48 + 0))+rsi] + pxor xmm1,xmm3 + pxor xmm5,xmm7 + pxor xmm9,xmm11 + pxor xmm15,xmm13 + movdqu XMMWORD[(0 + 0)+rdi],xmm1 + movdqu XMMWORD[(16 + 0)+rdi],xmm5 + movdqu XMMWORD[(32 + 0)+rdi],xmm9 + movdqu XMMWORD[(48 + 0)+rdi],xmm15 + + mov rcx,4*16 + sub rbx,4*16 + lea rsi,[64+rsi] + jmp NEAR $L$seal_sse_128_tail_hash + +$L$seal_sse_tail_192: + movdqa xmm0,XMMWORD[$L$chacha20_consts] + movdqa xmm4,XMMWORD[((160+48))+rbp] + movdqa xmm8,XMMWORD[((160+64))+rbp] + movdqa xmm1,xmm0 + movdqa xmm5,xmm4 + movdqa xmm9,xmm8 + movdqa xmm2,xmm0 + movdqa xmm6,xmm4 + movdqa xmm10,xmm8 + movdqa xmm14,XMMWORD[((160+96))+rbp] + paddd xmm14,XMMWORD[$L$sse_inc] + movdqa xmm13,xmm14 + paddd xmm13,XMMWORD[$L$sse_inc] + movdqa xmm12,xmm13 + paddd xmm12,XMMWORD[$L$sse_inc] + movdqa XMMWORD[(160+96)+rbp],xmm12 + movdqa XMMWORD[(160+112)+rbp],xmm13 + movdqa XMMWORD[(160+128)+rbp],xmm14 + +$L$seal_sse_tail_192_rounds_and_x2hash: + add r10,QWORD[((0+0))+rdi] + adc r11,QWORD[((8+0))+rdi] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + lea rdi,[16+rdi] +$L$seal_sse_tail_192_rounds_and_x1hash: + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol16] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,12 + psrld xmm4,20 + pxor xmm4,xmm3 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol8] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,7 + psrld xmm4,25 + pxor xmm4,xmm3 +DB 102,15,58,15,228,4 +DB 102,69,15,58,15,192,8 +DB 102,69,15,58,15,228,12 + paddd xmm1,xmm5 + pxor xmm13,xmm1 + pshufb xmm13,XMMWORD[$L$rol16] + paddd xmm9,xmm13 + pxor xmm5,xmm9 + movdqa xmm3,xmm5 + pslld xmm3,12 + psrld xmm5,20 + pxor xmm5,xmm3 + paddd xmm1,xmm5 + pxor xmm13,xmm1 + pshufb xmm13,XMMWORD[$L$rol8] + paddd xmm9,xmm13 + pxor xmm5,xmm9 + movdqa xmm3,xmm5 + pslld xmm3,7 + psrld xmm5,25 + pxor xmm5,xmm3 +DB 102,15,58,15,237,4 +DB 102,69,15,58,15,201,8 +DB 102,69,15,58,15,237,12 + paddd xmm2,xmm6 + pxor xmm14,xmm2 + pshufb xmm14,XMMWORD[$L$rol16] + paddd xmm10,xmm14 + pxor xmm6,xmm10 + movdqa xmm3,xmm6 + pslld xmm3,12 + psrld xmm6,20 + pxor xmm6,xmm3 + paddd xmm2,xmm6 + pxor xmm14,xmm2 + pshufb xmm14,XMMWORD[$L$rol8] + paddd xmm10,xmm14 + pxor xmm6,xmm10 + movdqa xmm3,xmm6 + pslld xmm3,7 + psrld xmm6,25 + pxor xmm6,xmm3 +DB 102,15,58,15,246,4 +DB 102,69,15,58,15,210,8 +DB 102,69,15,58,15,246,12 + add r10,QWORD[((0+0))+rdi] + adc r11,QWORD[((8+0))+rdi] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol16] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,12 + psrld xmm4,20 + pxor xmm4,xmm3 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol8] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,7 + psrld xmm4,25 + pxor xmm4,xmm3 +DB 102,15,58,15,228,12 +DB 102,69,15,58,15,192,8 +DB 102,69,15,58,15,228,4 + paddd xmm1,xmm5 + pxor xmm13,xmm1 + pshufb xmm13,XMMWORD[$L$rol16] + paddd xmm9,xmm13 + pxor xmm5,xmm9 + movdqa xmm3,xmm5 + pslld xmm3,12 + psrld xmm5,20 + pxor xmm5,xmm3 + paddd xmm1,xmm5 + pxor xmm13,xmm1 + pshufb xmm13,XMMWORD[$L$rol8] + paddd xmm9,xmm13 + pxor xmm5,xmm9 + movdqa xmm3,xmm5 + pslld xmm3,7 + psrld xmm5,25 + pxor xmm5,xmm3 +DB 102,15,58,15,237,12 +DB 102,69,15,58,15,201,8 +DB 102,69,15,58,15,237,4 + paddd xmm2,xmm6 + pxor xmm14,xmm2 + pshufb xmm14,XMMWORD[$L$rol16] + paddd xmm10,xmm14 + pxor xmm6,xmm10 + movdqa xmm3,xmm6 + pslld xmm3,12 + psrld xmm6,20 + pxor xmm6,xmm3 + paddd xmm2,xmm6 + pxor xmm14,xmm2 + pshufb xmm14,XMMWORD[$L$rol8] + paddd xmm10,xmm14 + pxor xmm6,xmm10 + movdqa xmm3,xmm6 + pslld xmm3,7 + psrld xmm6,25 + pxor xmm6,xmm3 +DB 102,15,58,15,246,12 +DB 102,69,15,58,15,210,8 +DB 102,69,15,58,15,246,4 + + lea rdi,[16+rdi] + dec rcx + jg NEAR $L$seal_sse_tail_192_rounds_and_x2hash + dec r8 + jge NEAR $L$seal_sse_tail_192_rounds_and_x1hash + paddd xmm2,XMMWORD[$L$chacha20_consts] + paddd xmm6,XMMWORD[((160+48))+rbp] + paddd xmm10,XMMWORD[((160+64))+rbp] + paddd xmm14,XMMWORD[((160+128))+rbp] + paddd xmm1,XMMWORD[$L$chacha20_consts] + paddd xmm5,XMMWORD[((160+48))+rbp] + paddd xmm9,XMMWORD[((160+64))+rbp] + paddd xmm13,XMMWORD[((160+112))+rbp] + paddd xmm0,XMMWORD[$L$chacha20_consts] + paddd xmm4,XMMWORD[((160+48))+rbp] + paddd xmm8,XMMWORD[((160+64))+rbp] + paddd xmm12,XMMWORD[((160+96))+rbp] + movdqu xmm3,XMMWORD[((0 + 0))+rsi] + movdqu xmm7,XMMWORD[((16 + 0))+rsi] + movdqu xmm11,XMMWORD[((32 + 0))+rsi] + movdqu xmm15,XMMWORD[((48 + 0))+rsi] + pxor xmm2,xmm3 + pxor xmm6,xmm7 + pxor xmm10,xmm11 + pxor xmm15,xmm14 + movdqu XMMWORD[(0 + 0)+rdi],xmm2 + movdqu XMMWORD[(16 + 0)+rdi],xmm6 + movdqu XMMWORD[(32 + 0)+rdi],xmm10 + movdqu XMMWORD[(48 + 0)+rdi],xmm15 + movdqu xmm3,XMMWORD[((0 + 64))+rsi] + movdqu xmm7,XMMWORD[((16 + 64))+rsi] + movdqu xmm11,XMMWORD[((32 + 64))+rsi] + movdqu xmm15,XMMWORD[((48 + 64))+rsi] + pxor xmm1,xmm3 + pxor xmm5,xmm7 + pxor xmm9,xmm11 + pxor xmm15,xmm13 + movdqu XMMWORD[(0 + 64)+rdi],xmm1 + movdqu XMMWORD[(16 + 64)+rdi],xmm5 + movdqu XMMWORD[(32 + 64)+rdi],xmm9 + movdqu XMMWORD[(48 + 64)+rdi],xmm15 + + mov rcx,8*16 + sub rbx,8*16 + lea rsi,[128+rsi] + +$L$seal_sse_128_tail_hash: + cmp rcx,16 + jb NEAR $L$seal_sse_128_tail_xor + add r10,QWORD[((0+0))+rdi] + adc r11,QWORD[((8+0))+rdi] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + sub rcx,16 + lea rdi,[16+rdi] + jmp NEAR $L$seal_sse_128_tail_hash + +$L$seal_sse_128_tail_xor: + cmp rbx,16 + jb NEAR $L$seal_sse_tail_16 + sub rbx,16 + + movdqu xmm3,XMMWORD[rsi] + pxor xmm0,xmm3 + movdqu XMMWORD[rdi],xmm0 + + add r10,QWORD[rdi] + adc r11,QWORD[8+rdi] + adc r12,1 + lea rsi,[16+rsi] + lea rdi,[16+rdi] + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + + movdqa xmm0,xmm4 + movdqa xmm4,xmm8 + movdqa xmm8,xmm12 + movdqa xmm12,xmm1 + movdqa xmm1,xmm5 + movdqa xmm5,xmm9 + movdqa xmm9,xmm13 + jmp NEAR $L$seal_sse_128_tail_xor + +$L$seal_sse_tail_16: + test rbx,rbx + jz NEAR $L$process_blocks_of_extra_in + + mov r8,rbx + mov rcx,rbx + lea rsi,[((-1))+rbx*1+rsi] + pxor xmm15,xmm15 +$L$seal_sse_tail_16_compose: + pslldq xmm15,1 + pinsrb xmm15,BYTE[rsi],0 + lea rsi,[((-1))+rsi] + dec rcx + jne NEAR $L$seal_sse_tail_16_compose + + + pxor xmm15,xmm0 + + + mov rcx,rbx + movdqu xmm0,xmm15 +$L$seal_sse_tail_16_extract: + pextrb XMMWORD[rdi],xmm0,0 + psrldq xmm0,1 + add rdi,1 + sub rcx,1 + jnz NEAR $L$seal_sse_tail_16_extract + + + + + + + + + mov r9,QWORD[((288 + 160 + 32))+rsp] + mov r14,QWORD[56+r9] + mov r13,QWORD[48+r9] + test r14,r14 + jz NEAR $L$process_partial_block + + mov r15,16 + sub r15,rbx + cmp r14,r15 + + jge NEAR $L$load_extra_in + mov r15,r14 + +$L$load_extra_in: + + + lea rsi,[((-1))+r15*1+r13] + + + add r13,r15 + sub r14,r15 + mov QWORD[48+r9],r13 + mov QWORD[56+r9],r14 + + + + add r8,r15 + + + pxor xmm11,xmm11 +$L$load_extra_load_loop: + pslldq xmm11,1 + pinsrb xmm11,BYTE[rsi],0 + lea rsi,[((-1))+rsi] + sub r15,1 + jnz NEAR $L$load_extra_load_loop + + + + + mov r15,rbx + +$L$load_extra_shift_loop: + pslldq xmm11,1 + sub r15,1 + jnz NEAR $L$load_extra_shift_loop + + + + + lea r15,[$L$and_masks] + shl rbx,4 + pand xmm15,XMMWORD[((-16))+rbx*1+r15] + + + por xmm15,xmm11 + + + +DB 102,77,15,126,253 + pextrq r14,xmm15,1 + add r10,r13 + adc r11,r14 + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + +$L$process_blocks_of_extra_in: + + mov r9,QWORD[((288+32+160 ))+rsp] + mov rsi,QWORD[48+r9] + mov r8,QWORD[56+r9] + mov rcx,r8 + shr r8,4 + +$L$process_extra_hash_loop: + jz NEAR process_extra_in_trailer + add r10,QWORD[((0+0))+rsi] + adc r11,QWORD[((8+0))+rsi] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + lea rsi,[16+rsi] + sub r8,1 + jmp NEAR $L$process_extra_hash_loop +process_extra_in_trailer: + and rcx,15 + mov rbx,rcx + jz NEAR $L$do_length_block + lea rsi,[((-1))+rcx*1+rsi] + +$L$process_extra_in_trailer_load: + pslldq xmm15,1 + pinsrb xmm15,BYTE[rsi],0 + lea rsi,[((-1))+rsi] + sub rcx,1 + jnz NEAR $L$process_extra_in_trailer_load + +$L$process_partial_block: + + lea r15,[$L$and_masks] + shl rbx,4 + pand xmm15,XMMWORD[((-16))+rbx*1+r15] +DB 102,77,15,126,253 + pextrq r14,xmm15,1 + add r10,r13 + adc r11,r14 + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + +$L$do_length_block: + add r10,QWORD[((0+160+32))+rbp] + adc r11,QWORD[((8+160+32))+rbp] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + + mov r13,r10 + mov r14,r11 + mov r15,r12 + sub r10,-5 + sbb r11,-1 + sbb r12,3 + cmovc r10,r13 + cmovc r11,r14 + cmovc r12,r15 + + add r10,QWORD[((0+160+16))+rbp] + adc r11,QWORD[((8+160+16))+rbp] + + movaps xmm6,XMMWORD[((0+0))+rbp] + movaps xmm7,XMMWORD[((16+0))+rbp] + movaps xmm8,XMMWORD[((32+0))+rbp] + movaps xmm9,XMMWORD[((48+0))+rbp] + movaps xmm10,XMMWORD[((64+0))+rbp] + movaps xmm11,XMMWORD[((80+0))+rbp] + movaps xmm12,XMMWORD[((96+0))+rbp] + movaps xmm13,XMMWORD[((112+0))+rbp] + movaps xmm14,XMMWORD[((128+0))+rbp] + movaps xmm15,XMMWORD[((144+0))+rbp] + + + add rsp,288 + 160 + 32 + + + pop r9 + + mov QWORD[r9],r10 + mov QWORD[8+r9],r11 + pop r15 + + pop r14 + + pop r13 + + pop r12 + + pop rbx + + pop rbp + + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$seal_sse_128: + + movdqu xmm0,XMMWORD[$L$chacha20_consts] + movdqa xmm1,xmm0 + movdqa xmm2,xmm0 + movdqu xmm4,XMMWORD[r9] + movdqa xmm5,xmm4 + movdqa xmm6,xmm4 + movdqu xmm8,XMMWORD[16+r9] + movdqa xmm9,xmm8 + movdqa xmm10,xmm8 + movdqu xmm14,XMMWORD[32+r9] + movdqa xmm12,xmm14 + paddd xmm12,XMMWORD[$L$sse_inc] + movdqa xmm13,xmm12 + paddd xmm13,XMMWORD[$L$sse_inc] + movdqa xmm7,xmm4 + movdqa xmm11,xmm8 + movdqa xmm15,xmm12 + mov r10,10 + +$L$seal_sse_128_rounds: + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol16] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,12 + psrld xmm4,20 + pxor xmm4,xmm3 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol8] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,7 + psrld xmm4,25 + pxor xmm4,xmm3 +DB 102,15,58,15,228,4 +DB 102,69,15,58,15,192,8 +DB 102,69,15,58,15,228,12 + paddd xmm1,xmm5 + pxor xmm13,xmm1 + pshufb xmm13,XMMWORD[$L$rol16] + paddd xmm9,xmm13 + pxor xmm5,xmm9 + movdqa xmm3,xmm5 + pslld xmm3,12 + psrld xmm5,20 + pxor xmm5,xmm3 + paddd xmm1,xmm5 + pxor xmm13,xmm1 + pshufb xmm13,XMMWORD[$L$rol8] + paddd xmm9,xmm13 + pxor xmm5,xmm9 + movdqa xmm3,xmm5 + pslld xmm3,7 + psrld xmm5,25 + pxor xmm5,xmm3 +DB 102,15,58,15,237,4 +DB 102,69,15,58,15,201,8 +DB 102,69,15,58,15,237,12 + paddd xmm2,xmm6 + pxor xmm14,xmm2 + pshufb xmm14,XMMWORD[$L$rol16] + paddd xmm10,xmm14 + pxor xmm6,xmm10 + movdqa xmm3,xmm6 + pslld xmm3,12 + psrld xmm6,20 + pxor xmm6,xmm3 + paddd xmm2,xmm6 + pxor xmm14,xmm2 + pshufb xmm14,XMMWORD[$L$rol8] + paddd xmm10,xmm14 + pxor xmm6,xmm10 + movdqa xmm3,xmm6 + pslld xmm3,7 + psrld xmm6,25 + pxor xmm6,xmm3 +DB 102,15,58,15,246,4 +DB 102,69,15,58,15,210,8 +DB 102,69,15,58,15,246,12 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol16] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,12 + psrld xmm4,20 + pxor xmm4,xmm3 + paddd xmm0,xmm4 + pxor xmm12,xmm0 + pshufb xmm12,XMMWORD[$L$rol8] + paddd xmm8,xmm12 + pxor xmm4,xmm8 + movdqa xmm3,xmm4 + pslld xmm3,7 + psrld xmm4,25 + pxor xmm4,xmm3 +DB 102,15,58,15,228,12 +DB 102,69,15,58,15,192,8 +DB 102,69,15,58,15,228,4 + paddd xmm1,xmm5 + pxor xmm13,xmm1 + pshufb xmm13,XMMWORD[$L$rol16] + paddd xmm9,xmm13 + pxor xmm5,xmm9 + movdqa xmm3,xmm5 + pslld xmm3,12 + psrld xmm5,20 + pxor xmm5,xmm3 + paddd xmm1,xmm5 + pxor xmm13,xmm1 + pshufb xmm13,XMMWORD[$L$rol8] + paddd xmm9,xmm13 + pxor xmm5,xmm9 + movdqa xmm3,xmm5 + pslld xmm3,7 + psrld xmm5,25 + pxor xmm5,xmm3 +DB 102,15,58,15,237,12 +DB 102,69,15,58,15,201,8 +DB 102,69,15,58,15,237,4 + paddd xmm2,xmm6 + pxor xmm14,xmm2 + pshufb xmm14,XMMWORD[$L$rol16] + paddd xmm10,xmm14 + pxor xmm6,xmm10 + movdqa xmm3,xmm6 + pslld xmm3,12 + psrld xmm6,20 + pxor xmm6,xmm3 + paddd xmm2,xmm6 + pxor xmm14,xmm2 + pshufb xmm14,XMMWORD[$L$rol8] + paddd xmm10,xmm14 + pxor xmm6,xmm10 + movdqa xmm3,xmm6 + pslld xmm3,7 + psrld xmm6,25 + pxor xmm6,xmm3 +DB 102,15,58,15,246,12 +DB 102,69,15,58,15,210,8 +DB 102,69,15,58,15,246,4 + + dec r10 + jnz NEAR $L$seal_sse_128_rounds + paddd xmm0,XMMWORD[$L$chacha20_consts] + paddd xmm1,XMMWORD[$L$chacha20_consts] + paddd xmm2,XMMWORD[$L$chacha20_consts] + paddd xmm4,xmm7 + paddd xmm5,xmm7 + paddd xmm6,xmm7 + paddd xmm8,xmm11 + paddd xmm9,xmm11 + paddd xmm12,xmm15 + paddd xmm15,XMMWORD[$L$sse_inc] + paddd xmm13,xmm15 + + pand xmm2,XMMWORD[$L$clamp] + movdqa XMMWORD[(160+0)+rbp],xmm2 + movdqa XMMWORD[(160+16)+rbp],xmm6 + + mov r8,r8 + call poly_hash_ad_internal + jmp NEAR $L$seal_sse_128_tail_xor +$L$SEH_end_chacha20_poly1305_seal_sse41: + + + +global chacha20_poly1305_open_avx2 + +ALIGN 64 +chacha20_poly1305_open_avx2: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_chacha20_poly1305_open_avx2: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + mov rcx,r9 + mov r8,QWORD[40+rsp] + mov r9,QWORD[48+rsp] + + + +_CET_ENDBR + push rbp + + push rbx + + push r12 + + push r13 + + push r14 + + push r15 + + + + push r9 + + sub rsp,288 + 160 + 32 + + + lea rbp,[32+rsp] + and rbp,-32 + + movaps XMMWORD[(0+0)+rbp],xmm6 + movaps XMMWORD[(16+0)+rbp],xmm7 + movaps XMMWORD[(32+0)+rbp],xmm8 + movaps XMMWORD[(48+0)+rbp],xmm9 + movaps XMMWORD[(64+0)+rbp],xmm10 + movaps XMMWORD[(80+0)+rbp],xmm11 + movaps XMMWORD[(96+0)+rbp],xmm12 + movaps XMMWORD[(112+0)+rbp],xmm13 + movaps XMMWORD[(128+0)+rbp],xmm14 + movaps XMMWORD[(144+0)+rbp],xmm15 + + mov rbx,rdx + mov QWORD[((0+160+32))+rbp],r8 + mov QWORD[((8+160+32))+rbp],rbx + + vzeroupper + vmovdqa ymm0,YMMWORD[$L$chacha20_consts] + vbroadcasti128 ymm4,XMMWORD[r9] + vbroadcasti128 ymm8,XMMWORD[16+r9] + vbroadcasti128 ymm12,XMMWORD[32+r9] + vpaddd ymm12,ymm12,YMMWORD[$L$avx2_init] + cmp rbx,6*32 + jbe NEAR $L$open_avx2_192 + cmp rbx,10*32 + jbe NEAR $L$open_avx2_320 + + vmovdqa YMMWORD[(160+64)+rbp],ymm4 + vmovdqa YMMWORD[(160+96)+rbp],ymm8 + vmovdqa YMMWORD[(160+160)+rbp],ymm12 + mov r10,10 +$L$open_avx2_init_rounds: + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol16] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpsrld ymm3,ymm4,20 + vpslld ymm4,ymm4,12 + vpxor ymm4,ymm4,ymm3 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol8] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpslld ymm3,ymm4,7 + vpsrld ymm4,ymm4,25 + vpxor ymm4,ymm4,ymm3 + vpalignr ymm12,ymm12,ymm12,12 + vpalignr ymm8,ymm8,ymm8,8 + vpalignr ymm4,ymm4,ymm4,4 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol16] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpsrld ymm3,ymm4,20 + vpslld ymm4,ymm4,12 + vpxor ymm4,ymm4,ymm3 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol8] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpslld ymm3,ymm4,7 + vpsrld ymm4,ymm4,25 + vpxor ymm4,ymm4,ymm3 + vpalignr ymm12,ymm12,ymm12,4 + vpalignr ymm8,ymm8,ymm8,8 + vpalignr ymm4,ymm4,ymm4,12 + + dec r10 + jne NEAR $L$open_avx2_init_rounds + vpaddd ymm0,ymm0,YMMWORD[$L$chacha20_consts] + vpaddd ymm4,ymm4,YMMWORD[((160+64))+rbp] + vpaddd ymm8,ymm8,YMMWORD[((160+96))+rbp] + vpaddd ymm12,ymm12,YMMWORD[((160+160))+rbp] + + vperm2i128 ymm3,ymm4,ymm0,0x02 + + vpand ymm3,ymm3,YMMWORD[$L$clamp] + vmovdqa YMMWORD[(160+0)+rbp],ymm3 + + vperm2i128 ymm0,ymm4,ymm0,0x13 + vperm2i128 ymm4,ymm12,ymm8,0x13 + + mov r8,r8 + call poly_hash_ad_internal + + xor rcx,rcx +$L$open_avx2_init_hash: + add r10,QWORD[((0+0))+rcx*1+rsi] + adc r11,QWORD[((8+0))+rcx*1+rsi] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + add rcx,16 + cmp rcx,2*32 + jne NEAR $L$open_avx2_init_hash + + vpxor ymm0,ymm0,YMMWORD[rsi] + vpxor ymm4,ymm4,YMMWORD[32+rsi] + + vmovdqu YMMWORD[rdi],ymm0 + vmovdqu YMMWORD[32+rdi],ymm4 + lea rsi,[64+rsi] + lea rdi,[64+rdi] + sub rbx,2*32 +$L$open_avx2_main_loop: + + cmp rbx,16*32 + jb NEAR $L$open_avx2_main_loop_done + vmovdqa ymm0,YMMWORD[$L$chacha20_consts] + vmovdqa ymm4,YMMWORD[((160+64))+rbp] + vmovdqa ymm8,YMMWORD[((160+96))+rbp] + vmovdqa ymm1,ymm0 + vmovdqa ymm5,ymm4 + vmovdqa ymm9,ymm8 + vmovdqa ymm2,ymm0 + vmovdqa ymm6,ymm4 + vmovdqa ymm10,ymm8 + vmovdqa ymm3,ymm0 + vmovdqa ymm7,ymm4 + vmovdqa ymm11,ymm8 + vmovdqa ymm12,YMMWORD[$L$avx2_inc] + vpaddd ymm15,ymm12,YMMWORD[((160+160))+rbp] + vpaddd ymm14,ymm12,ymm15 + vpaddd ymm13,ymm12,ymm14 + vpaddd ymm12,ymm12,ymm13 + vmovdqa YMMWORD[(160+256)+rbp],ymm15 + vmovdqa YMMWORD[(160+224)+rbp],ymm14 + vmovdqa YMMWORD[(160+192)+rbp],ymm13 + vmovdqa YMMWORD[(160+160)+rbp],ymm12 + + xor rcx,rcx +$L$open_avx2_main_loop_rounds: + add r10,QWORD[((0+0))+rcx*1+rsi] + adc r11,QWORD[((8+0))+rcx*1+rsi] + adc r12,1 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vmovdqa ymm8,YMMWORD[$L$rol16] + vpaddd ymm3,ymm3,ymm7 + vpaddd ymm2,ymm2,ymm6 + vpaddd ymm1,ymm1,ymm5 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm15,ymm15,ymm3 + vpxor ymm14,ymm14,ymm2 + vpxor ymm13,ymm13,ymm1 + vpxor ymm12,ymm12,ymm0 + mov rdx,QWORD[((0+160+0))+rbp] + mov r15,rdx + mulx r14,r13,r10 + mulx rdx,rax,r11 + imul r15,r12 + add r14,rax + adc r15,rdx + vpshufb ymm15,ymm15,ymm8 + vpshufb ymm14,ymm14,ymm8 + vpshufb ymm13,ymm13,ymm8 + vpshufb ymm12,ymm12,ymm8 + vpaddd ymm11,ymm11,ymm15 + vpaddd ymm10,ymm10,ymm14 + vpaddd ymm9,ymm9,ymm13 + vpaddd ymm8,ymm12,YMMWORD[((160+128))+rbp] + vpxor ymm7,ymm7,ymm11 + mov rdx,QWORD[((8+160+0))+rbp] + mulx rax,r10,r10 + add r14,r10 + mulx r9,r11,r11 + adc r15,r11 + adc r9,0 + imul rdx,r12 + vpxor ymm6,ymm6,ymm10 + vpxor ymm5,ymm5,ymm9 + vpxor ymm4,ymm4,ymm8 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vpsrld ymm8,ymm7,20 + vpslld ymm7,ymm7,32-20 + vpxor ymm7,ymm7,ymm8 + vpsrld ymm8,ymm6,20 + vpslld ymm6,ymm6,32-20 + vpxor ymm6,ymm6,ymm8 + vpsrld ymm8,ymm5,20 + vpslld ymm5,ymm5,32-20 + add r15,rax + adc r9,rdx + vpxor ymm5,ymm5,ymm8 + vpsrld ymm8,ymm4,20 + vpslld ymm4,ymm4,32-20 + vpxor ymm4,ymm4,ymm8 + vmovdqa ymm8,YMMWORD[$L$rol8] + vpaddd ymm3,ymm3,ymm7 + vpaddd ymm2,ymm2,ymm6 + vpaddd ymm1,ymm1,ymm5 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm15,ymm15,ymm3 + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + vpxor ymm14,ymm14,ymm2 + vpxor ymm13,ymm13,ymm1 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm15,ymm15,ymm8 + vpshufb ymm14,ymm14,ymm8 + vpshufb ymm13,ymm13,ymm8 + vpshufb ymm12,ymm12,ymm8 + vpaddd ymm11,ymm11,ymm15 + vpaddd ymm10,ymm10,ymm14 + add r10,QWORD[((0+16))+rcx*1+rsi] + adc r11,QWORD[((8+16))+rcx*1+rsi] + adc r12,1 + vpaddd ymm9,ymm9,ymm13 + vpaddd ymm8,ymm12,YMMWORD[((160+128))+rbp] + vpxor ymm7,ymm7,ymm11 + vpxor ymm6,ymm6,ymm10 + vpxor ymm5,ymm5,ymm9 + vpxor ymm4,ymm4,ymm8 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vpsrld ymm8,ymm7,25 + mov rdx,QWORD[((0+160+0))+rbp] + mov r15,rdx + mulx r14,r13,r10 + mulx rdx,rax,r11 + imul r15,r12 + add r14,rax + adc r15,rdx + vpslld ymm7,ymm7,32-25 + vpxor ymm7,ymm7,ymm8 + vpsrld ymm8,ymm6,25 + vpslld ymm6,ymm6,32-25 + vpxor ymm6,ymm6,ymm8 + vpsrld ymm8,ymm5,25 + vpslld ymm5,ymm5,32-25 + vpxor ymm5,ymm5,ymm8 + vpsrld ymm8,ymm4,25 + vpslld ymm4,ymm4,32-25 + vpxor ymm4,ymm4,ymm8 + vmovdqa ymm8,YMMWORD[((160+128))+rbp] + vpalignr ymm7,ymm7,ymm7,4 + vpalignr ymm11,ymm11,ymm11,8 + vpalignr ymm15,ymm15,ymm15,12 + vpalignr ymm6,ymm6,ymm6,4 + vpalignr ymm10,ymm10,ymm10,8 + vpalignr ymm14,ymm14,ymm14,12 + mov rdx,QWORD[((8+160+0))+rbp] + mulx rax,r10,r10 + add r14,r10 + mulx r9,r11,r11 + adc r15,r11 + adc r9,0 + imul rdx,r12 + vpalignr ymm5,ymm5,ymm5,4 + vpalignr ymm9,ymm9,ymm9,8 + vpalignr ymm13,ymm13,ymm13,12 + vpalignr ymm4,ymm4,ymm4,4 + vpalignr ymm8,ymm8,ymm8,8 + vpalignr ymm12,ymm12,ymm12,12 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vmovdqa ymm8,YMMWORD[$L$rol16] + vpaddd ymm3,ymm3,ymm7 + vpaddd ymm2,ymm2,ymm6 + vpaddd ymm1,ymm1,ymm5 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm15,ymm15,ymm3 + vpxor ymm14,ymm14,ymm2 + vpxor ymm13,ymm13,ymm1 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm15,ymm15,ymm8 + vpshufb ymm14,ymm14,ymm8 + add r15,rax + adc r9,rdx + vpshufb ymm13,ymm13,ymm8 + vpshufb ymm12,ymm12,ymm8 + vpaddd ymm11,ymm11,ymm15 + vpaddd ymm10,ymm10,ymm14 + vpaddd ymm9,ymm9,ymm13 + vpaddd ymm8,ymm12,YMMWORD[((160+128))+rbp] + vpxor ymm7,ymm7,ymm11 + vpxor ymm6,ymm6,ymm10 + vpxor ymm5,ymm5,ymm9 + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + vpxor ymm4,ymm4,ymm8 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vpsrld ymm8,ymm7,20 + vpslld ymm7,ymm7,32-20 + vpxor ymm7,ymm7,ymm8 + vpsrld ymm8,ymm6,20 + vpslld ymm6,ymm6,32-20 + vpxor ymm6,ymm6,ymm8 + add r10,QWORD[((0+32))+rcx*1+rsi] + adc r11,QWORD[((8+32))+rcx*1+rsi] + adc r12,1 + + lea rcx,[48+rcx] + vpsrld ymm8,ymm5,20 + vpslld ymm5,ymm5,32-20 + vpxor ymm5,ymm5,ymm8 + vpsrld ymm8,ymm4,20 + vpslld ymm4,ymm4,32-20 + vpxor ymm4,ymm4,ymm8 + vmovdqa ymm8,YMMWORD[$L$rol8] + vpaddd ymm3,ymm3,ymm7 + vpaddd ymm2,ymm2,ymm6 + vpaddd ymm1,ymm1,ymm5 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm15,ymm15,ymm3 + vpxor ymm14,ymm14,ymm2 + vpxor ymm13,ymm13,ymm1 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm15,ymm15,ymm8 + vpshufb ymm14,ymm14,ymm8 + vpshufb ymm13,ymm13,ymm8 + mov rdx,QWORD[((0+160+0))+rbp] + mov r15,rdx + mulx r14,r13,r10 + mulx rdx,rax,r11 + imul r15,r12 + add r14,rax + adc r15,rdx + vpshufb ymm12,ymm12,ymm8 + vpaddd ymm11,ymm11,ymm15 + vpaddd ymm10,ymm10,ymm14 + vpaddd ymm9,ymm9,ymm13 + vpaddd ymm8,ymm12,YMMWORD[((160+128))+rbp] + vpxor ymm7,ymm7,ymm11 + vpxor ymm6,ymm6,ymm10 + vpxor ymm5,ymm5,ymm9 + mov rdx,QWORD[((8+160+0))+rbp] + mulx rax,r10,r10 + add r14,r10 + mulx r9,r11,r11 + adc r15,r11 + adc r9,0 + imul rdx,r12 + vpxor ymm4,ymm4,ymm8 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vpsrld ymm8,ymm7,25 + vpslld ymm7,ymm7,32-25 + vpxor ymm7,ymm7,ymm8 + vpsrld ymm8,ymm6,25 + vpslld ymm6,ymm6,32-25 + vpxor ymm6,ymm6,ymm8 + add r15,rax + adc r9,rdx + vpsrld ymm8,ymm5,25 + vpslld ymm5,ymm5,32-25 + vpxor ymm5,ymm5,ymm8 + vpsrld ymm8,ymm4,25 + vpslld ymm4,ymm4,32-25 + vpxor ymm4,ymm4,ymm8 + vmovdqa ymm8,YMMWORD[((160+128))+rbp] + vpalignr ymm7,ymm7,ymm7,12 + vpalignr ymm11,ymm11,ymm11,8 + vpalignr ymm15,ymm15,ymm15,4 + vpalignr ymm6,ymm6,ymm6,12 + vpalignr ymm10,ymm10,ymm10,8 + vpalignr ymm14,ymm14,ymm14,4 + vpalignr ymm5,ymm5,ymm5,12 + vpalignr ymm9,ymm9,ymm9,8 + vpalignr ymm13,ymm13,ymm13,4 + vpalignr ymm4,ymm4,ymm4,12 + vpalignr ymm8,ymm8,ymm8,8 + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + vpalignr ymm12,ymm12,ymm12,4 + + cmp rcx,10*6*8 + jne NEAR $L$open_avx2_main_loop_rounds + vpaddd ymm3,ymm3,YMMWORD[$L$chacha20_consts] + vpaddd ymm7,ymm7,YMMWORD[((160+64))+rbp] + vpaddd ymm11,ymm11,YMMWORD[((160+96))+rbp] + vpaddd ymm15,ymm15,YMMWORD[((160+256))+rbp] + vpaddd ymm2,ymm2,YMMWORD[$L$chacha20_consts] + vpaddd ymm6,ymm6,YMMWORD[((160+64))+rbp] + vpaddd ymm10,ymm10,YMMWORD[((160+96))+rbp] + vpaddd ymm14,ymm14,YMMWORD[((160+224))+rbp] + vpaddd ymm1,ymm1,YMMWORD[$L$chacha20_consts] + vpaddd ymm5,ymm5,YMMWORD[((160+64))+rbp] + vpaddd ymm9,ymm9,YMMWORD[((160+96))+rbp] + vpaddd ymm13,ymm13,YMMWORD[((160+192))+rbp] + vpaddd ymm0,ymm0,YMMWORD[$L$chacha20_consts] + vpaddd ymm4,ymm4,YMMWORD[((160+64))+rbp] + vpaddd ymm8,ymm8,YMMWORD[((160+96))+rbp] + vpaddd ymm12,ymm12,YMMWORD[((160+160))+rbp] + + vmovdqa YMMWORD[(160+128)+rbp],ymm0 + add r10,QWORD[((0+480))+rsi] + adc r11,QWORD[((8+480))+rsi] + adc r12,1 + vperm2i128 ymm0,ymm7,ymm3,0x02 + vperm2i128 ymm7,ymm7,ymm3,0x13 + vperm2i128 ymm3,ymm15,ymm11,0x02 + vperm2i128 ymm11,ymm15,ymm11,0x13 + vpxor ymm0,ymm0,YMMWORD[((0+0))+rsi] + vpxor ymm3,ymm3,YMMWORD[((32+0))+rsi] + vpxor ymm7,ymm7,YMMWORD[((64+0))+rsi] + vpxor ymm11,ymm11,YMMWORD[((96+0))+rsi] + vmovdqu YMMWORD[(0+0)+rdi],ymm0 + vmovdqu YMMWORD[(32+0)+rdi],ymm3 + vmovdqu YMMWORD[(64+0)+rdi],ymm7 + vmovdqu YMMWORD[(96+0)+rdi],ymm11 + + vmovdqa ymm0,YMMWORD[((160+128))+rbp] + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + vperm2i128 ymm3,ymm6,ymm2,0x02 + vperm2i128 ymm6,ymm6,ymm2,0x13 + vperm2i128 ymm2,ymm14,ymm10,0x02 + vperm2i128 ymm10,ymm14,ymm10,0x13 + vpxor ymm3,ymm3,YMMWORD[((0+128))+rsi] + vpxor ymm2,ymm2,YMMWORD[((32+128))+rsi] + vpxor ymm6,ymm6,YMMWORD[((64+128))+rsi] + vpxor ymm10,ymm10,YMMWORD[((96+128))+rsi] + vmovdqu YMMWORD[(0+128)+rdi],ymm3 + vmovdqu YMMWORD[(32+128)+rdi],ymm2 + vmovdqu YMMWORD[(64+128)+rdi],ymm6 + vmovdqu YMMWORD[(96+128)+rdi],ymm10 + add r10,QWORD[((0+480+16))+rsi] + adc r11,QWORD[((8+480+16))+rsi] + adc r12,1 + vperm2i128 ymm3,ymm5,ymm1,0x02 + vperm2i128 ymm5,ymm5,ymm1,0x13 + vperm2i128 ymm1,ymm13,ymm9,0x02 + vperm2i128 ymm9,ymm13,ymm9,0x13 + vpxor ymm3,ymm3,YMMWORD[((0+256))+rsi] + vpxor ymm1,ymm1,YMMWORD[((32+256))+rsi] + vpxor ymm5,ymm5,YMMWORD[((64+256))+rsi] + vpxor ymm9,ymm9,YMMWORD[((96+256))+rsi] + vmovdqu YMMWORD[(0+256)+rdi],ymm3 + vmovdqu YMMWORD[(32+256)+rdi],ymm1 + vmovdqu YMMWORD[(64+256)+rdi],ymm5 + vmovdqu YMMWORD[(96+256)+rdi],ymm9 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + vperm2i128 ymm3,ymm4,ymm0,0x02 + vperm2i128 ymm4,ymm4,ymm0,0x13 + vperm2i128 ymm0,ymm12,ymm8,0x02 + vperm2i128 ymm8,ymm12,ymm8,0x13 + vpxor ymm3,ymm3,YMMWORD[((0+384))+rsi] + vpxor ymm0,ymm0,YMMWORD[((32+384))+rsi] + vpxor ymm4,ymm4,YMMWORD[((64+384))+rsi] + vpxor ymm8,ymm8,YMMWORD[((96+384))+rsi] + vmovdqu YMMWORD[(0+384)+rdi],ymm3 + vmovdqu YMMWORD[(32+384)+rdi],ymm0 + vmovdqu YMMWORD[(64+384)+rdi],ymm4 + vmovdqu YMMWORD[(96+384)+rdi],ymm8 + + lea rsi,[512+rsi] + lea rdi,[512+rdi] + sub rbx,16*32 + jmp NEAR $L$open_avx2_main_loop +$L$open_avx2_main_loop_done: + test rbx,rbx + vzeroupper + je NEAR $L$open_sse_finalize + + cmp rbx,12*32 + ja NEAR $L$open_avx2_tail_512 + cmp rbx,8*32 + ja NEAR $L$open_avx2_tail_384 + cmp rbx,4*32 + ja NEAR $L$open_avx2_tail_256 + vmovdqa ymm0,YMMWORD[$L$chacha20_consts] + vmovdqa ymm4,YMMWORD[((160+64))+rbp] + vmovdqa ymm8,YMMWORD[((160+96))+rbp] + vmovdqa ymm12,YMMWORD[$L$avx2_inc] + vpaddd ymm12,ymm12,YMMWORD[((160+160))+rbp] + vmovdqa YMMWORD[(160+160)+rbp],ymm12 + + xor r8,r8 + mov rcx,rbx + and rcx,-16 + test rcx,rcx + je NEAR $L$open_avx2_tail_128_rounds +$L$open_avx2_tail_128_rounds_and_x1hash: + add r10,QWORD[((0+0))+r8*1+rsi] + adc r11,QWORD[((8+0))+r8*1+rsi] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + +$L$open_avx2_tail_128_rounds: + add r8,16 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol16] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpsrld ymm3,ymm4,20 + vpslld ymm4,ymm4,12 + vpxor ymm4,ymm4,ymm3 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol8] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpslld ymm3,ymm4,7 + vpsrld ymm4,ymm4,25 + vpxor ymm4,ymm4,ymm3 + vpalignr ymm12,ymm12,ymm12,12 + vpalignr ymm8,ymm8,ymm8,8 + vpalignr ymm4,ymm4,ymm4,4 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol16] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpsrld ymm3,ymm4,20 + vpslld ymm4,ymm4,12 + vpxor ymm4,ymm4,ymm3 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol8] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpslld ymm3,ymm4,7 + vpsrld ymm4,ymm4,25 + vpxor ymm4,ymm4,ymm3 + vpalignr ymm12,ymm12,ymm12,4 + vpalignr ymm8,ymm8,ymm8,8 + vpalignr ymm4,ymm4,ymm4,12 + + cmp r8,rcx + jb NEAR $L$open_avx2_tail_128_rounds_and_x1hash + cmp r8,160 + jne NEAR $L$open_avx2_tail_128_rounds + vpaddd ymm0,ymm0,YMMWORD[$L$chacha20_consts] + vpaddd ymm4,ymm4,YMMWORD[((160+64))+rbp] + vpaddd ymm8,ymm8,YMMWORD[((160+96))+rbp] + vpaddd ymm12,ymm12,YMMWORD[((160+160))+rbp] + vperm2i128 ymm3,ymm4,ymm0,0x13 + vperm2i128 ymm0,ymm4,ymm0,0x02 + vperm2i128 ymm4,ymm12,ymm8,0x02 + vperm2i128 ymm12,ymm12,ymm8,0x13 + vmovdqa ymm8,ymm3 + + jmp NEAR $L$open_avx2_tail_128_xor + +$L$open_avx2_tail_256: + vmovdqa ymm0,YMMWORD[$L$chacha20_consts] + vmovdqa ymm4,YMMWORD[((160+64))+rbp] + vmovdqa ymm8,YMMWORD[((160+96))+rbp] + vmovdqa ymm1,ymm0 + vmovdqa ymm5,ymm4 + vmovdqa ymm9,ymm8 + vmovdqa ymm12,YMMWORD[$L$avx2_inc] + vpaddd ymm13,ymm12,YMMWORD[((160+160))+rbp] + vpaddd ymm12,ymm12,ymm13 + vmovdqa YMMWORD[(160+160)+rbp],ymm12 + vmovdqa YMMWORD[(160+192)+rbp],ymm13 + + mov QWORD[((160+128))+rbp],rbx + mov rcx,rbx + sub rcx,4*32 + shr rcx,4 + mov r8,10 + cmp rcx,10 + cmovg rcx,r8 + mov rbx,rsi + xor r8,r8 +$L$open_avx2_tail_256_rounds_and_x1hash: + add r10,QWORD[((0+0))+rbx] + adc r11,QWORD[((8+0))+rbx] + adc r12,1 + mov rdx,QWORD[((0+160+0))+rbp] + mov r15,rdx + mulx r14,r13,r10 + mulx rdx,rax,r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rdx,QWORD[((8+160+0))+rbp] + mulx rax,r10,r10 + add r14,r10 + mulx r9,r11,r11 + adc r15,r11 + adc r9,0 + imul rdx,r12 + add r15,rax + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + lea rbx,[16+rbx] +$L$open_avx2_tail_256_rounds: + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol16] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpsrld ymm3,ymm4,20 + vpslld ymm4,ymm4,12 + vpxor ymm4,ymm4,ymm3 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol8] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpslld ymm3,ymm4,7 + vpsrld ymm4,ymm4,25 + vpxor ymm4,ymm4,ymm3 + vpalignr ymm12,ymm12,ymm12,12 + vpalignr ymm8,ymm8,ymm8,8 + vpalignr ymm4,ymm4,ymm4,4 + vpaddd ymm1,ymm1,ymm5 + vpxor ymm13,ymm13,ymm1 + vpshufb ymm13,ymm13,YMMWORD[$L$rol16] + vpaddd ymm9,ymm9,ymm13 + vpxor ymm5,ymm5,ymm9 + vpsrld ymm3,ymm5,20 + vpslld ymm5,ymm5,12 + vpxor ymm5,ymm5,ymm3 + vpaddd ymm1,ymm1,ymm5 + vpxor ymm13,ymm13,ymm1 + vpshufb ymm13,ymm13,YMMWORD[$L$rol8] + vpaddd ymm9,ymm9,ymm13 + vpxor ymm5,ymm5,ymm9 + vpslld ymm3,ymm5,7 + vpsrld ymm5,ymm5,25 + vpxor ymm5,ymm5,ymm3 + vpalignr ymm13,ymm13,ymm13,12 + vpalignr ymm9,ymm9,ymm9,8 + vpalignr ymm5,ymm5,ymm5,4 + + inc r8 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol16] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpsrld ymm3,ymm4,20 + vpslld ymm4,ymm4,12 + vpxor ymm4,ymm4,ymm3 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol8] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpslld ymm3,ymm4,7 + vpsrld ymm4,ymm4,25 + vpxor ymm4,ymm4,ymm3 + vpalignr ymm12,ymm12,ymm12,4 + vpalignr ymm8,ymm8,ymm8,8 + vpalignr ymm4,ymm4,ymm4,12 + vpaddd ymm1,ymm1,ymm5 + vpxor ymm13,ymm13,ymm1 + vpshufb ymm13,ymm13,YMMWORD[$L$rol16] + vpaddd ymm9,ymm9,ymm13 + vpxor ymm5,ymm5,ymm9 + vpsrld ymm3,ymm5,20 + vpslld ymm5,ymm5,12 + vpxor ymm5,ymm5,ymm3 + vpaddd ymm1,ymm1,ymm5 + vpxor ymm13,ymm13,ymm1 + vpshufb ymm13,ymm13,YMMWORD[$L$rol8] + vpaddd ymm9,ymm9,ymm13 + vpxor ymm5,ymm5,ymm9 + vpslld ymm3,ymm5,7 + vpsrld ymm5,ymm5,25 + vpxor ymm5,ymm5,ymm3 + vpalignr ymm13,ymm13,ymm13,4 + vpalignr ymm9,ymm9,ymm9,8 + vpalignr ymm5,ymm5,ymm5,12 + vpaddd ymm2,ymm2,ymm6 + vpxor ymm14,ymm14,ymm2 + vpshufb ymm14,ymm14,YMMWORD[$L$rol16] + vpaddd ymm10,ymm10,ymm14 + vpxor ymm6,ymm6,ymm10 + vpsrld ymm3,ymm6,20 + vpslld ymm6,ymm6,12 + vpxor ymm6,ymm6,ymm3 + vpaddd ymm2,ymm2,ymm6 + vpxor ymm14,ymm14,ymm2 + vpshufb ymm14,ymm14,YMMWORD[$L$rol8] + vpaddd ymm10,ymm10,ymm14 + vpxor ymm6,ymm6,ymm10 + vpslld ymm3,ymm6,7 + vpsrld ymm6,ymm6,25 + vpxor ymm6,ymm6,ymm3 + vpalignr ymm14,ymm14,ymm14,4 + vpalignr ymm10,ymm10,ymm10,8 + vpalignr ymm6,ymm6,ymm6,12 + + cmp r8,rcx + jb NEAR $L$open_avx2_tail_256_rounds_and_x1hash + cmp r8,10 + jne NEAR $L$open_avx2_tail_256_rounds + mov r8,rbx + sub rbx,rsi + mov rcx,rbx + mov rbx,QWORD[((160+128))+rbp] +$L$open_avx2_tail_256_hash: + add rcx,16 + cmp rcx,rbx + jg NEAR $L$open_avx2_tail_256_done + add r10,QWORD[((0+0))+r8] + adc r11,QWORD[((8+0))+r8] + adc r12,1 + mov rdx,QWORD[((0+160+0))+rbp] + mov r15,rdx + mulx r14,r13,r10 + mulx rdx,rax,r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rdx,QWORD[((8+160+0))+rbp] + mulx rax,r10,r10 + add r14,r10 + mulx r9,r11,r11 + adc r15,r11 + adc r9,0 + imul rdx,r12 + add r15,rax + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + lea r8,[16+r8] + jmp NEAR $L$open_avx2_tail_256_hash +$L$open_avx2_tail_256_done: + vpaddd ymm1,ymm1,YMMWORD[$L$chacha20_consts] + vpaddd ymm5,ymm5,YMMWORD[((160+64))+rbp] + vpaddd ymm9,ymm9,YMMWORD[((160+96))+rbp] + vpaddd ymm13,ymm13,YMMWORD[((160+192))+rbp] + vpaddd ymm0,ymm0,YMMWORD[$L$chacha20_consts] + vpaddd ymm4,ymm4,YMMWORD[((160+64))+rbp] + vpaddd ymm8,ymm8,YMMWORD[((160+96))+rbp] + vpaddd ymm12,ymm12,YMMWORD[((160+160))+rbp] + vperm2i128 ymm3,ymm5,ymm1,0x02 + vperm2i128 ymm5,ymm5,ymm1,0x13 + vperm2i128 ymm1,ymm13,ymm9,0x02 + vperm2i128 ymm9,ymm13,ymm9,0x13 + vpxor ymm3,ymm3,YMMWORD[((0+0))+rsi] + vpxor ymm1,ymm1,YMMWORD[((32+0))+rsi] + vpxor ymm5,ymm5,YMMWORD[((64+0))+rsi] + vpxor ymm9,ymm9,YMMWORD[((96+0))+rsi] + vmovdqu YMMWORD[(0+0)+rdi],ymm3 + vmovdqu YMMWORD[(32+0)+rdi],ymm1 + vmovdqu YMMWORD[(64+0)+rdi],ymm5 + vmovdqu YMMWORD[(96+0)+rdi],ymm9 + vperm2i128 ymm3,ymm4,ymm0,0x13 + vperm2i128 ymm0,ymm4,ymm0,0x02 + vperm2i128 ymm4,ymm12,ymm8,0x02 + vperm2i128 ymm12,ymm12,ymm8,0x13 + vmovdqa ymm8,ymm3 + + lea rsi,[128+rsi] + lea rdi,[128+rdi] + sub rbx,4*32 + jmp NEAR $L$open_avx2_tail_128_xor + +$L$open_avx2_tail_384: + vmovdqa ymm0,YMMWORD[$L$chacha20_consts] + vmovdqa ymm4,YMMWORD[((160+64))+rbp] + vmovdqa ymm8,YMMWORD[((160+96))+rbp] + vmovdqa ymm1,ymm0 + vmovdqa ymm5,ymm4 + vmovdqa ymm9,ymm8 + vmovdqa ymm2,ymm0 + vmovdqa ymm6,ymm4 + vmovdqa ymm10,ymm8 + vmovdqa ymm12,YMMWORD[$L$avx2_inc] + vpaddd ymm14,ymm12,YMMWORD[((160+160))+rbp] + vpaddd ymm13,ymm12,ymm14 + vpaddd ymm12,ymm12,ymm13 + vmovdqa YMMWORD[(160+160)+rbp],ymm12 + vmovdqa YMMWORD[(160+192)+rbp],ymm13 + vmovdqa YMMWORD[(160+224)+rbp],ymm14 + + mov QWORD[((160+128))+rbp],rbx + mov rcx,rbx + sub rcx,8*32 + shr rcx,4 + add rcx,6 + mov r8,10 + cmp rcx,10 + cmovg rcx,r8 + mov rbx,rsi + xor r8,r8 +$L$open_avx2_tail_384_rounds_and_x2hash: + add r10,QWORD[((0+0))+rbx] + adc r11,QWORD[((8+0))+rbx] + adc r12,1 + mov rdx,QWORD[((0+160+0))+rbp] + mov r15,rdx + mulx r14,r13,r10 + mulx rdx,rax,r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rdx,QWORD[((8+160+0))+rbp] + mulx rax,r10,r10 + add r14,r10 + mulx r9,r11,r11 + adc r15,r11 + adc r9,0 + imul rdx,r12 + add r15,rax + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + lea rbx,[16+rbx] +$L$open_avx2_tail_384_rounds_and_x1hash: + vpaddd ymm2,ymm2,ymm6 + vpxor ymm14,ymm14,ymm2 + vpshufb ymm14,ymm14,YMMWORD[$L$rol16] + vpaddd ymm10,ymm10,ymm14 + vpxor ymm6,ymm6,ymm10 + vpsrld ymm3,ymm6,20 + vpslld ymm6,ymm6,12 + vpxor ymm6,ymm6,ymm3 + vpaddd ymm2,ymm2,ymm6 + vpxor ymm14,ymm14,ymm2 + vpshufb ymm14,ymm14,YMMWORD[$L$rol8] + vpaddd ymm10,ymm10,ymm14 + vpxor ymm6,ymm6,ymm10 + vpslld ymm3,ymm6,7 + vpsrld ymm6,ymm6,25 + vpxor ymm6,ymm6,ymm3 + vpalignr ymm14,ymm14,ymm14,12 + vpalignr ymm10,ymm10,ymm10,8 + vpalignr ymm6,ymm6,ymm6,4 + vpaddd ymm1,ymm1,ymm5 + vpxor ymm13,ymm13,ymm1 + vpshufb ymm13,ymm13,YMMWORD[$L$rol16] + vpaddd ymm9,ymm9,ymm13 + vpxor ymm5,ymm5,ymm9 + vpsrld ymm3,ymm5,20 + vpslld ymm5,ymm5,12 + vpxor ymm5,ymm5,ymm3 + vpaddd ymm1,ymm1,ymm5 + vpxor ymm13,ymm13,ymm1 + vpshufb ymm13,ymm13,YMMWORD[$L$rol8] + vpaddd ymm9,ymm9,ymm13 + vpxor ymm5,ymm5,ymm9 + vpslld ymm3,ymm5,7 + vpsrld ymm5,ymm5,25 + vpxor ymm5,ymm5,ymm3 + vpalignr ymm13,ymm13,ymm13,12 + vpalignr ymm9,ymm9,ymm9,8 + vpalignr ymm5,ymm5,ymm5,4 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol16] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpsrld ymm3,ymm4,20 + vpslld ymm4,ymm4,12 + vpxor ymm4,ymm4,ymm3 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol8] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpslld ymm3,ymm4,7 + vpsrld ymm4,ymm4,25 + vpxor ymm4,ymm4,ymm3 + vpalignr ymm12,ymm12,ymm12,12 + vpalignr ymm8,ymm8,ymm8,8 + vpalignr ymm4,ymm4,ymm4,4 + add r10,QWORD[((0+0))+rbx] + adc r11,QWORD[((8+0))+rbx] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + lea rbx,[16+rbx] + inc r8 + vpaddd ymm2,ymm2,ymm6 + vpxor ymm14,ymm14,ymm2 + vpshufb ymm14,ymm14,YMMWORD[$L$rol16] + vpaddd ymm10,ymm10,ymm14 + vpxor ymm6,ymm6,ymm10 + vpsrld ymm3,ymm6,20 + vpslld ymm6,ymm6,12 + vpxor ymm6,ymm6,ymm3 + vpaddd ymm2,ymm2,ymm6 + vpxor ymm14,ymm14,ymm2 + vpshufb ymm14,ymm14,YMMWORD[$L$rol8] + vpaddd ymm10,ymm10,ymm14 + vpxor ymm6,ymm6,ymm10 + vpslld ymm3,ymm6,7 + vpsrld ymm6,ymm6,25 + vpxor ymm6,ymm6,ymm3 + vpalignr ymm14,ymm14,ymm14,4 + vpalignr ymm10,ymm10,ymm10,8 + vpalignr ymm6,ymm6,ymm6,12 + vpaddd ymm1,ymm1,ymm5 + vpxor ymm13,ymm13,ymm1 + vpshufb ymm13,ymm13,YMMWORD[$L$rol16] + vpaddd ymm9,ymm9,ymm13 + vpxor ymm5,ymm5,ymm9 + vpsrld ymm3,ymm5,20 + vpslld ymm5,ymm5,12 + vpxor ymm5,ymm5,ymm3 + vpaddd ymm1,ymm1,ymm5 + vpxor ymm13,ymm13,ymm1 + vpshufb ymm13,ymm13,YMMWORD[$L$rol8] + vpaddd ymm9,ymm9,ymm13 + vpxor ymm5,ymm5,ymm9 + vpslld ymm3,ymm5,7 + vpsrld ymm5,ymm5,25 + vpxor ymm5,ymm5,ymm3 + vpalignr ymm13,ymm13,ymm13,4 + vpalignr ymm9,ymm9,ymm9,8 + vpalignr ymm5,ymm5,ymm5,12 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol16] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpsrld ymm3,ymm4,20 + vpslld ymm4,ymm4,12 + vpxor ymm4,ymm4,ymm3 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol8] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpslld ymm3,ymm4,7 + vpsrld ymm4,ymm4,25 + vpxor ymm4,ymm4,ymm3 + vpalignr ymm12,ymm12,ymm12,4 + vpalignr ymm8,ymm8,ymm8,8 + vpalignr ymm4,ymm4,ymm4,12 + + cmp r8,rcx + jb NEAR $L$open_avx2_tail_384_rounds_and_x2hash + cmp r8,10 + jne NEAR $L$open_avx2_tail_384_rounds_and_x1hash + mov r8,rbx + sub rbx,rsi + mov rcx,rbx + mov rbx,QWORD[((160+128))+rbp] +$L$open_avx2_384_tail_hash: + add rcx,16 + cmp rcx,rbx + jg NEAR $L$open_avx2_384_tail_done + add r10,QWORD[((0+0))+r8] + adc r11,QWORD[((8+0))+r8] + adc r12,1 + mov rdx,QWORD[((0+160+0))+rbp] + mov r15,rdx + mulx r14,r13,r10 + mulx rdx,rax,r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rdx,QWORD[((8+160+0))+rbp] + mulx rax,r10,r10 + add r14,r10 + mulx r9,r11,r11 + adc r15,r11 + adc r9,0 + imul rdx,r12 + add r15,rax + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + lea r8,[16+r8] + jmp NEAR $L$open_avx2_384_tail_hash +$L$open_avx2_384_tail_done: + vpaddd ymm2,ymm2,YMMWORD[$L$chacha20_consts] + vpaddd ymm6,ymm6,YMMWORD[((160+64))+rbp] + vpaddd ymm10,ymm10,YMMWORD[((160+96))+rbp] + vpaddd ymm14,ymm14,YMMWORD[((160+224))+rbp] + vpaddd ymm1,ymm1,YMMWORD[$L$chacha20_consts] + vpaddd ymm5,ymm5,YMMWORD[((160+64))+rbp] + vpaddd ymm9,ymm9,YMMWORD[((160+96))+rbp] + vpaddd ymm13,ymm13,YMMWORD[((160+192))+rbp] + vpaddd ymm0,ymm0,YMMWORD[$L$chacha20_consts] + vpaddd ymm4,ymm4,YMMWORD[((160+64))+rbp] + vpaddd ymm8,ymm8,YMMWORD[((160+96))+rbp] + vpaddd ymm12,ymm12,YMMWORD[((160+160))+rbp] + vperm2i128 ymm3,ymm6,ymm2,0x02 + vperm2i128 ymm6,ymm6,ymm2,0x13 + vperm2i128 ymm2,ymm14,ymm10,0x02 + vperm2i128 ymm10,ymm14,ymm10,0x13 + vpxor ymm3,ymm3,YMMWORD[((0+0))+rsi] + vpxor ymm2,ymm2,YMMWORD[((32+0))+rsi] + vpxor ymm6,ymm6,YMMWORD[((64+0))+rsi] + vpxor ymm10,ymm10,YMMWORD[((96+0))+rsi] + vmovdqu YMMWORD[(0+0)+rdi],ymm3 + vmovdqu YMMWORD[(32+0)+rdi],ymm2 + vmovdqu YMMWORD[(64+0)+rdi],ymm6 + vmovdqu YMMWORD[(96+0)+rdi],ymm10 + vperm2i128 ymm3,ymm5,ymm1,0x02 + vperm2i128 ymm5,ymm5,ymm1,0x13 + vperm2i128 ymm1,ymm13,ymm9,0x02 + vperm2i128 ymm9,ymm13,ymm9,0x13 + vpxor ymm3,ymm3,YMMWORD[((0+128))+rsi] + vpxor ymm1,ymm1,YMMWORD[((32+128))+rsi] + vpxor ymm5,ymm5,YMMWORD[((64+128))+rsi] + vpxor ymm9,ymm9,YMMWORD[((96+128))+rsi] + vmovdqu YMMWORD[(0+128)+rdi],ymm3 + vmovdqu YMMWORD[(32+128)+rdi],ymm1 + vmovdqu YMMWORD[(64+128)+rdi],ymm5 + vmovdqu YMMWORD[(96+128)+rdi],ymm9 + vperm2i128 ymm3,ymm4,ymm0,0x13 + vperm2i128 ymm0,ymm4,ymm0,0x02 + vperm2i128 ymm4,ymm12,ymm8,0x02 + vperm2i128 ymm12,ymm12,ymm8,0x13 + vmovdqa ymm8,ymm3 + + lea rsi,[256+rsi] + lea rdi,[256+rdi] + sub rbx,8*32 + jmp NEAR $L$open_avx2_tail_128_xor + +$L$open_avx2_tail_512: + vmovdqa ymm0,YMMWORD[$L$chacha20_consts] + vmovdqa ymm4,YMMWORD[((160+64))+rbp] + vmovdqa ymm8,YMMWORD[((160+96))+rbp] + vmovdqa ymm1,ymm0 + vmovdqa ymm5,ymm4 + vmovdqa ymm9,ymm8 + vmovdqa ymm2,ymm0 + vmovdqa ymm6,ymm4 + vmovdqa ymm10,ymm8 + vmovdqa ymm3,ymm0 + vmovdqa ymm7,ymm4 + vmovdqa ymm11,ymm8 + vmovdqa ymm12,YMMWORD[$L$avx2_inc] + vpaddd ymm15,ymm12,YMMWORD[((160+160))+rbp] + vpaddd ymm14,ymm12,ymm15 + vpaddd ymm13,ymm12,ymm14 + vpaddd ymm12,ymm12,ymm13 + vmovdqa YMMWORD[(160+256)+rbp],ymm15 + vmovdqa YMMWORD[(160+224)+rbp],ymm14 + vmovdqa YMMWORD[(160+192)+rbp],ymm13 + vmovdqa YMMWORD[(160+160)+rbp],ymm12 + + xor rcx,rcx + mov r8,rsi +$L$open_avx2_tail_512_rounds_and_x2hash: + add r10,QWORD[((0+0))+r8] + adc r11,QWORD[((8+0))+r8] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + lea r8,[16+r8] +$L$open_avx2_tail_512_rounds_and_x1hash: + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vmovdqa ymm8,YMMWORD[$L$rol16] + vpaddd ymm3,ymm3,ymm7 + vpaddd ymm2,ymm2,ymm6 + vpaddd ymm1,ymm1,ymm5 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm15,ymm15,ymm3 + vpxor ymm14,ymm14,ymm2 + vpxor ymm13,ymm13,ymm1 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm15,ymm15,ymm8 + vpshufb ymm14,ymm14,ymm8 + vpshufb ymm13,ymm13,ymm8 + vpshufb ymm12,ymm12,ymm8 + vpaddd ymm11,ymm11,ymm15 + vpaddd ymm10,ymm10,ymm14 + vpaddd ymm9,ymm9,ymm13 + vpaddd ymm8,ymm12,YMMWORD[((160+128))+rbp] + vpxor ymm7,ymm7,ymm11 + vpxor ymm6,ymm6,ymm10 + vpxor ymm5,ymm5,ymm9 + vpxor ymm4,ymm4,ymm8 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vpsrld ymm8,ymm7,20 + vpslld ymm7,ymm7,32-20 + vpxor ymm7,ymm7,ymm8 + vpsrld ymm8,ymm6,20 + vpslld ymm6,ymm6,32-20 + vpxor ymm6,ymm6,ymm8 + vpsrld ymm8,ymm5,20 + vpslld ymm5,ymm5,32-20 + vpxor ymm5,ymm5,ymm8 + vpsrld ymm8,ymm4,20 + vpslld ymm4,ymm4,32-20 + vpxor ymm4,ymm4,ymm8 + vmovdqa ymm8,YMMWORD[$L$rol8] + vpaddd ymm3,ymm3,ymm7 + add r10,QWORD[((0+0))+r8] + adc r11,QWORD[((8+0))+r8] + adc r12,1 + mov rdx,QWORD[((0+160+0))+rbp] + mov r15,rdx + mulx r14,r13,r10 + mulx rdx,rax,r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rdx,QWORD[((8+160+0))+rbp] + mulx rax,r10,r10 + add r14,r10 + mulx r9,r11,r11 + adc r15,r11 + adc r9,0 + imul rdx,r12 + add r15,rax + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + vpaddd ymm2,ymm2,ymm6 + vpaddd ymm1,ymm1,ymm5 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm15,ymm15,ymm3 + vpxor ymm14,ymm14,ymm2 + vpxor ymm13,ymm13,ymm1 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm15,ymm15,ymm8 + vpshufb ymm14,ymm14,ymm8 + vpshufb ymm13,ymm13,ymm8 + vpshufb ymm12,ymm12,ymm8 + vpaddd ymm11,ymm11,ymm15 + vpaddd ymm10,ymm10,ymm14 + vpaddd ymm9,ymm9,ymm13 + vpaddd ymm8,ymm12,YMMWORD[((160+128))+rbp] + vpxor ymm7,ymm7,ymm11 + vpxor ymm6,ymm6,ymm10 + vpxor ymm5,ymm5,ymm9 + vpxor ymm4,ymm4,ymm8 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vpsrld ymm8,ymm7,25 + vpslld ymm7,ymm7,32-25 + vpxor ymm7,ymm7,ymm8 + vpsrld ymm8,ymm6,25 + vpslld ymm6,ymm6,32-25 + vpxor ymm6,ymm6,ymm8 + vpsrld ymm8,ymm5,25 + vpslld ymm5,ymm5,32-25 + vpxor ymm5,ymm5,ymm8 + vpsrld ymm8,ymm4,25 + vpslld ymm4,ymm4,32-25 + vpxor ymm4,ymm4,ymm8 + vmovdqa ymm8,YMMWORD[((160+128))+rbp] + vpalignr ymm7,ymm7,ymm7,4 + vpalignr ymm11,ymm11,ymm11,8 + vpalignr ymm15,ymm15,ymm15,12 + vpalignr ymm6,ymm6,ymm6,4 + vpalignr ymm10,ymm10,ymm10,8 + vpalignr ymm14,ymm14,ymm14,12 + vpalignr ymm5,ymm5,ymm5,4 + vpalignr ymm9,ymm9,ymm9,8 + vpalignr ymm13,ymm13,ymm13,12 + vpalignr ymm4,ymm4,ymm4,4 + vpalignr ymm8,ymm8,ymm8,8 + vpalignr ymm12,ymm12,ymm12,12 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vmovdqa ymm8,YMMWORD[$L$rol16] + vpaddd ymm3,ymm3,ymm7 + add r10,QWORD[((0+16))+r8] + adc r11,QWORD[((8+16))+r8] + adc r12,1 + mov rdx,QWORD[((0+160+0))+rbp] + mov r15,rdx + mulx r14,r13,r10 + mulx rdx,rax,r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rdx,QWORD[((8+160+0))+rbp] + mulx rax,r10,r10 + add r14,r10 + mulx r9,r11,r11 + adc r15,r11 + adc r9,0 + imul rdx,r12 + add r15,rax + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + lea r8,[32+r8] + vpaddd ymm2,ymm2,ymm6 + vpaddd ymm1,ymm1,ymm5 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm15,ymm15,ymm3 + vpxor ymm14,ymm14,ymm2 + vpxor ymm13,ymm13,ymm1 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm15,ymm15,ymm8 + vpshufb ymm14,ymm14,ymm8 + vpshufb ymm13,ymm13,ymm8 + vpshufb ymm12,ymm12,ymm8 + vpaddd ymm11,ymm11,ymm15 + vpaddd ymm10,ymm10,ymm14 + vpaddd ymm9,ymm9,ymm13 + vpaddd ymm8,ymm12,YMMWORD[((160+128))+rbp] + vpxor ymm7,ymm7,ymm11 + vpxor ymm6,ymm6,ymm10 + vpxor ymm5,ymm5,ymm9 + vpxor ymm4,ymm4,ymm8 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vpsrld ymm8,ymm7,20 + vpslld ymm7,ymm7,32-20 + vpxor ymm7,ymm7,ymm8 + vpsrld ymm8,ymm6,20 + vpslld ymm6,ymm6,32-20 + vpxor ymm6,ymm6,ymm8 + vpsrld ymm8,ymm5,20 + vpslld ymm5,ymm5,32-20 + vpxor ymm5,ymm5,ymm8 + vpsrld ymm8,ymm4,20 + vpslld ymm4,ymm4,32-20 + vpxor ymm4,ymm4,ymm8 + vmovdqa ymm8,YMMWORD[$L$rol8] + vpaddd ymm3,ymm3,ymm7 + vpaddd ymm2,ymm2,ymm6 + vpaddd ymm1,ymm1,ymm5 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm15,ymm15,ymm3 + vpxor ymm14,ymm14,ymm2 + vpxor ymm13,ymm13,ymm1 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm15,ymm15,ymm8 + vpshufb ymm14,ymm14,ymm8 + vpshufb ymm13,ymm13,ymm8 + vpshufb ymm12,ymm12,ymm8 + vpaddd ymm11,ymm11,ymm15 + vpaddd ymm10,ymm10,ymm14 + vpaddd ymm9,ymm9,ymm13 + vpaddd ymm8,ymm12,YMMWORD[((160+128))+rbp] + vpxor ymm7,ymm7,ymm11 + vpxor ymm6,ymm6,ymm10 + vpxor ymm5,ymm5,ymm9 + vpxor ymm4,ymm4,ymm8 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vpsrld ymm8,ymm7,25 + vpslld ymm7,ymm7,32-25 + vpxor ymm7,ymm7,ymm8 + vpsrld ymm8,ymm6,25 + vpslld ymm6,ymm6,32-25 + vpxor ymm6,ymm6,ymm8 + vpsrld ymm8,ymm5,25 + vpslld ymm5,ymm5,32-25 + vpxor ymm5,ymm5,ymm8 + vpsrld ymm8,ymm4,25 + vpslld ymm4,ymm4,32-25 + vpxor ymm4,ymm4,ymm8 + vmovdqa ymm8,YMMWORD[((160+128))+rbp] + vpalignr ymm7,ymm7,ymm7,12 + vpalignr ymm11,ymm11,ymm11,8 + vpalignr ymm15,ymm15,ymm15,4 + vpalignr ymm6,ymm6,ymm6,12 + vpalignr ymm10,ymm10,ymm10,8 + vpalignr ymm14,ymm14,ymm14,4 + vpalignr ymm5,ymm5,ymm5,12 + vpalignr ymm9,ymm9,ymm9,8 + vpalignr ymm13,ymm13,ymm13,4 + vpalignr ymm4,ymm4,ymm4,12 + vpalignr ymm8,ymm8,ymm8,8 + vpalignr ymm12,ymm12,ymm12,4 + + inc rcx + cmp rcx,4 + jl NEAR $L$open_avx2_tail_512_rounds_and_x2hash + cmp rcx,10 + jne NEAR $L$open_avx2_tail_512_rounds_and_x1hash + mov rcx,rbx + sub rcx,12*32 + and rcx,-16 +$L$open_avx2_tail_512_hash: + test rcx,rcx + je NEAR $L$open_avx2_tail_512_done + add r10,QWORD[((0+0))+r8] + adc r11,QWORD[((8+0))+r8] + adc r12,1 + mov rdx,QWORD[((0+160+0))+rbp] + mov r15,rdx + mulx r14,r13,r10 + mulx rdx,rax,r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rdx,QWORD[((8+160+0))+rbp] + mulx rax,r10,r10 + add r14,r10 + mulx r9,r11,r11 + adc r15,r11 + adc r9,0 + imul rdx,r12 + add r15,rax + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + lea r8,[16+r8] + sub rcx,2*8 + jmp NEAR $L$open_avx2_tail_512_hash +$L$open_avx2_tail_512_done: + vpaddd ymm3,ymm3,YMMWORD[$L$chacha20_consts] + vpaddd ymm7,ymm7,YMMWORD[((160+64))+rbp] + vpaddd ymm11,ymm11,YMMWORD[((160+96))+rbp] + vpaddd ymm15,ymm15,YMMWORD[((160+256))+rbp] + vpaddd ymm2,ymm2,YMMWORD[$L$chacha20_consts] + vpaddd ymm6,ymm6,YMMWORD[((160+64))+rbp] + vpaddd ymm10,ymm10,YMMWORD[((160+96))+rbp] + vpaddd ymm14,ymm14,YMMWORD[((160+224))+rbp] + vpaddd ymm1,ymm1,YMMWORD[$L$chacha20_consts] + vpaddd ymm5,ymm5,YMMWORD[((160+64))+rbp] + vpaddd ymm9,ymm9,YMMWORD[((160+96))+rbp] + vpaddd ymm13,ymm13,YMMWORD[((160+192))+rbp] + vpaddd ymm0,ymm0,YMMWORD[$L$chacha20_consts] + vpaddd ymm4,ymm4,YMMWORD[((160+64))+rbp] + vpaddd ymm8,ymm8,YMMWORD[((160+96))+rbp] + vpaddd ymm12,ymm12,YMMWORD[((160+160))+rbp] + + vmovdqa YMMWORD[(160+128)+rbp],ymm0 + vperm2i128 ymm0,ymm7,ymm3,0x02 + vperm2i128 ymm7,ymm7,ymm3,0x13 + vperm2i128 ymm3,ymm15,ymm11,0x02 + vperm2i128 ymm11,ymm15,ymm11,0x13 + vpxor ymm0,ymm0,YMMWORD[((0+0))+rsi] + vpxor ymm3,ymm3,YMMWORD[((32+0))+rsi] + vpxor ymm7,ymm7,YMMWORD[((64+0))+rsi] + vpxor ymm11,ymm11,YMMWORD[((96+0))+rsi] + vmovdqu YMMWORD[(0+0)+rdi],ymm0 + vmovdqu YMMWORD[(32+0)+rdi],ymm3 + vmovdqu YMMWORD[(64+0)+rdi],ymm7 + vmovdqu YMMWORD[(96+0)+rdi],ymm11 + + vmovdqa ymm0,YMMWORD[((160+128))+rbp] + vperm2i128 ymm3,ymm6,ymm2,0x02 + vperm2i128 ymm6,ymm6,ymm2,0x13 + vperm2i128 ymm2,ymm14,ymm10,0x02 + vperm2i128 ymm10,ymm14,ymm10,0x13 + vpxor ymm3,ymm3,YMMWORD[((0+128))+rsi] + vpxor ymm2,ymm2,YMMWORD[((32+128))+rsi] + vpxor ymm6,ymm6,YMMWORD[((64+128))+rsi] + vpxor ymm10,ymm10,YMMWORD[((96+128))+rsi] + vmovdqu YMMWORD[(0+128)+rdi],ymm3 + vmovdqu YMMWORD[(32+128)+rdi],ymm2 + vmovdqu YMMWORD[(64+128)+rdi],ymm6 + vmovdqu YMMWORD[(96+128)+rdi],ymm10 + vperm2i128 ymm3,ymm5,ymm1,0x02 + vperm2i128 ymm5,ymm5,ymm1,0x13 + vperm2i128 ymm1,ymm13,ymm9,0x02 + vperm2i128 ymm9,ymm13,ymm9,0x13 + vpxor ymm3,ymm3,YMMWORD[((0+256))+rsi] + vpxor ymm1,ymm1,YMMWORD[((32+256))+rsi] + vpxor ymm5,ymm5,YMMWORD[((64+256))+rsi] + vpxor ymm9,ymm9,YMMWORD[((96+256))+rsi] + vmovdqu YMMWORD[(0+256)+rdi],ymm3 + vmovdqu YMMWORD[(32+256)+rdi],ymm1 + vmovdqu YMMWORD[(64+256)+rdi],ymm5 + vmovdqu YMMWORD[(96+256)+rdi],ymm9 + vperm2i128 ymm3,ymm4,ymm0,0x13 + vperm2i128 ymm0,ymm4,ymm0,0x02 + vperm2i128 ymm4,ymm12,ymm8,0x02 + vperm2i128 ymm12,ymm12,ymm8,0x13 + vmovdqa ymm8,ymm3 + + lea rsi,[384+rsi] + lea rdi,[384+rdi] + sub rbx,12*32 +$L$open_avx2_tail_128_xor: + cmp rbx,32 + jb NEAR $L$open_avx2_tail_32_xor + sub rbx,32 + vpxor ymm0,ymm0,YMMWORD[rsi] + vmovdqu YMMWORD[rdi],ymm0 + lea rsi,[32+rsi] + lea rdi,[32+rdi] + vmovdqa ymm0,ymm4 + vmovdqa ymm4,ymm8 + vmovdqa ymm8,ymm12 + jmp NEAR $L$open_avx2_tail_128_xor +$L$open_avx2_tail_32_xor: + cmp rbx,16 + vmovdqa xmm1,xmm0 + jb NEAR $L$open_avx2_exit + sub rbx,16 + + vpxor xmm1,xmm0,XMMWORD[rsi] + vmovdqu XMMWORD[rdi],xmm1 + lea rsi,[16+rsi] + lea rdi,[16+rdi] + vperm2i128 ymm0,ymm0,ymm0,0x11 + vmovdqa xmm1,xmm0 +$L$open_avx2_exit: + vzeroupper + jmp NEAR $L$open_sse_tail_16 + +$L$open_avx2_192: + vmovdqa ymm1,ymm0 + vmovdqa ymm2,ymm0 + vmovdqa ymm5,ymm4 + vmovdqa ymm6,ymm4 + vmovdqa ymm9,ymm8 + vmovdqa ymm10,ymm8 + vpaddd ymm13,ymm12,YMMWORD[$L$avx2_inc] + vmovdqa ymm11,ymm12 + vmovdqa ymm15,ymm13 + mov r10,10 +$L$open_avx2_192_rounds: + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol16] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpsrld ymm3,ymm4,20 + vpslld ymm4,ymm4,12 + vpxor ymm4,ymm4,ymm3 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol8] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpslld ymm3,ymm4,7 + vpsrld ymm4,ymm4,25 + vpxor ymm4,ymm4,ymm3 + vpalignr ymm12,ymm12,ymm12,12 + vpalignr ymm8,ymm8,ymm8,8 + vpalignr ymm4,ymm4,ymm4,4 + vpaddd ymm1,ymm1,ymm5 + vpxor ymm13,ymm13,ymm1 + vpshufb ymm13,ymm13,YMMWORD[$L$rol16] + vpaddd ymm9,ymm9,ymm13 + vpxor ymm5,ymm5,ymm9 + vpsrld ymm3,ymm5,20 + vpslld ymm5,ymm5,12 + vpxor ymm5,ymm5,ymm3 + vpaddd ymm1,ymm1,ymm5 + vpxor ymm13,ymm13,ymm1 + vpshufb ymm13,ymm13,YMMWORD[$L$rol8] + vpaddd ymm9,ymm9,ymm13 + vpxor ymm5,ymm5,ymm9 + vpslld ymm3,ymm5,7 + vpsrld ymm5,ymm5,25 + vpxor ymm5,ymm5,ymm3 + vpalignr ymm13,ymm13,ymm13,12 + vpalignr ymm9,ymm9,ymm9,8 + vpalignr ymm5,ymm5,ymm5,4 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol16] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpsrld ymm3,ymm4,20 + vpslld ymm4,ymm4,12 + vpxor ymm4,ymm4,ymm3 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol8] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpslld ymm3,ymm4,7 + vpsrld ymm4,ymm4,25 + vpxor ymm4,ymm4,ymm3 + vpalignr ymm12,ymm12,ymm12,4 + vpalignr ymm8,ymm8,ymm8,8 + vpalignr ymm4,ymm4,ymm4,12 + vpaddd ymm1,ymm1,ymm5 + vpxor ymm13,ymm13,ymm1 + vpshufb ymm13,ymm13,YMMWORD[$L$rol16] + vpaddd ymm9,ymm9,ymm13 + vpxor ymm5,ymm5,ymm9 + vpsrld ymm3,ymm5,20 + vpslld ymm5,ymm5,12 + vpxor ymm5,ymm5,ymm3 + vpaddd ymm1,ymm1,ymm5 + vpxor ymm13,ymm13,ymm1 + vpshufb ymm13,ymm13,YMMWORD[$L$rol8] + vpaddd ymm9,ymm9,ymm13 + vpxor ymm5,ymm5,ymm9 + vpslld ymm3,ymm5,7 + vpsrld ymm5,ymm5,25 + vpxor ymm5,ymm5,ymm3 + vpalignr ymm13,ymm13,ymm13,4 + vpalignr ymm9,ymm9,ymm9,8 + vpalignr ymm5,ymm5,ymm5,12 + + dec r10 + jne NEAR $L$open_avx2_192_rounds + vpaddd ymm0,ymm0,ymm2 + vpaddd ymm1,ymm1,ymm2 + vpaddd ymm4,ymm4,ymm6 + vpaddd ymm5,ymm5,ymm6 + vpaddd ymm8,ymm8,ymm10 + vpaddd ymm9,ymm9,ymm10 + vpaddd ymm12,ymm12,ymm11 + vpaddd ymm13,ymm13,ymm15 + vperm2i128 ymm3,ymm4,ymm0,0x02 + + vpand ymm3,ymm3,YMMWORD[$L$clamp] + vmovdqa YMMWORD[(160+0)+rbp],ymm3 + + vperm2i128 ymm0,ymm4,ymm0,0x13 + vperm2i128 ymm4,ymm12,ymm8,0x13 + vperm2i128 ymm8,ymm5,ymm1,0x02 + vperm2i128 ymm12,ymm13,ymm9,0x02 + vperm2i128 ymm1,ymm5,ymm1,0x13 + vperm2i128 ymm5,ymm13,ymm9,0x13 +$L$open_avx2_short: + mov r8,r8 + call poly_hash_ad_internal +$L$open_avx2_short_hash_and_xor_loop: + cmp rbx,32 + jb NEAR $L$open_avx2_short_tail_32 + sub rbx,32 + add r10,QWORD[((0+0))+rsi] + adc r11,QWORD[((8+0))+rsi] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + add r10,QWORD[((0+16))+rsi] + adc r11,QWORD[((8+16))+rsi] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + + vpxor ymm0,ymm0,YMMWORD[rsi] + vmovdqu YMMWORD[rdi],ymm0 + lea rsi,[32+rsi] + lea rdi,[32+rdi] + + vmovdqa ymm0,ymm4 + vmovdqa ymm4,ymm8 + vmovdqa ymm8,ymm12 + vmovdqa ymm12,ymm1 + vmovdqa ymm1,ymm5 + vmovdqa ymm5,ymm9 + vmovdqa ymm9,ymm13 + vmovdqa ymm13,ymm2 + vmovdqa ymm2,ymm6 + jmp NEAR $L$open_avx2_short_hash_and_xor_loop +$L$open_avx2_short_tail_32: + cmp rbx,16 + vmovdqa xmm1,xmm0 + jb NEAR $L$open_avx2_short_tail_32_exit + sub rbx,16 + add r10,QWORD[((0+0))+rsi] + adc r11,QWORD[((8+0))+rsi] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + vpxor xmm3,xmm0,XMMWORD[rsi] + vmovdqu XMMWORD[rdi],xmm3 + lea rsi,[16+rsi] + lea rdi,[16+rdi] + vextracti128 xmm1,ymm0,1 +$L$open_avx2_short_tail_32_exit: + vzeroupper + jmp NEAR $L$open_sse_tail_16 + +$L$open_avx2_320: + vmovdqa ymm1,ymm0 + vmovdqa ymm2,ymm0 + vmovdqa ymm5,ymm4 + vmovdqa ymm6,ymm4 + vmovdqa ymm9,ymm8 + vmovdqa ymm10,ymm8 + vpaddd ymm13,ymm12,YMMWORD[$L$avx2_inc] + vpaddd ymm14,ymm13,YMMWORD[$L$avx2_inc] + vmovdqa ymm7,ymm4 + vmovdqa ymm11,ymm8 + vmovdqa YMMWORD[(160+160)+rbp],ymm12 + vmovdqa YMMWORD[(160+192)+rbp],ymm13 + vmovdqa YMMWORD[(160+224)+rbp],ymm14 + mov r10,10 +$L$open_avx2_320_rounds: + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol16] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpsrld ymm3,ymm4,20 + vpslld ymm4,ymm4,12 + vpxor ymm4,ymm4,ymm3 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol8] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpslld ymm3,ymm4,7 + vpsrld ymm4,ymm4,25 + vpxor ymm4,ymm4,ymm3 + vpalignr ymm12,ymm12,ymm12,12 + vpalignr ymm8,ymm8,ymm8,8 + vpalignr ymm4,ymm4,ymm4,4 + vpaddd ymm1,ymm1,ymm5 + vpxor ymm13,ymm13,ymm1 + vpshufb ymm13,ymm13,YMMWORD[$L$rol16] + vpaddd ymm9,ymm9,ymm13 + vpxor ymm5,ymm5,ymm9 + vpsrld ymm3,ymm5,20 + vpslld ymm5,ymm5,12 + vpxor ymm5,ymm5,ymm3 + vpaddd ymm1,ymm1,ymm5 + vpxor ymm13,ymm13,ymm1 + vpshufb ymm13,ymm13,YMMWORD[$L$rol8] + vpaddd ymm9,ymm9,ymm13 + vpxor ymm5,ymm5,ymm9 + vpslld ymm3,ymm5,7 + vpsrld ymm5,ymm5,25 + vpxor ymm5,ymm5,ymm3 + vpalignr ymm13,ymm13,ymm13,12 + vpalignr ymm9,ymm9,ymm9,8 + vpalignr ymm5,ymm5,ymm5,4 + vpaddd ymm2,ymm2,ymm6 + vpxor ymm14,ymm14,ymm2 + vpshufb ymm14,ymm14,YMMWORD[$L$rol16] + vpaddd ymm10,ymm10,ymm14 + vpxor ymm6,ymm6,ymm10 + vpsrld ymm3,ymm6,20 + vpslld ymm6,ymm6,12 + vpxor ymm6,ymm6,ymm3 + vpaddd ymm2,ymm2,ymm6 + vpxor ymm14,ymm14,ymm2 + vpshufb ymm14,ymm14,YMMWORD[$L$rol8] + vpaddd ymm10,ymm10,ymm14 + vpxor ymm6,ymm6,ymm10 + vpslld ymm3,ymm6,7 + vpsrld ymm6,ymm6,25 + vpxor ymm6,ymm6,ymm3 + vpalignr ymm14,ymm14,ymm14,12 + vpalignr ymm10,ymm10,ymm10,8 + vpalignr ymm6,ymm6,ymm6,4 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol16] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpsrld ymm3,ymm4,20 + vpslld ymm4,ymm4,12 + vpxor ymm4,ymm4,ymm3 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol8] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpslld ymm3,ymm4,7 + vpsrld ymm4,ymm4,25 + vpxor ymm4,ymm4,ymm3 + vpalignr ymm12,ymm12,ymm12,4 + vpalignr ymm8,ymm8,ymm8,8 + vpalignr ymm4,ymm4,ymm4,12 + vpaddd ymm1,ymm1,ymm5 + vpxor ymm13,ymm13,ymm1 + vpshufb ymm13,ymm13,YMMWORD[$L$rol16] + vpaddd ymm9,ymm9,ymm13 + vpxor ymm5,ymm5,ymm9 + vpsrld ymm3,ymm5,20 + vpslld ymm5,ymm5,12 + vpxor ymm5,ymm5,ymm3 + vpaddd ymm1,ymm1,ymm5 + vpxor ymm13,ymm13,ymm1 + vpshufb ymm13,ymm13,YMMWORD[$L$rol8] + vpaddd ymm9,ymm9,ymm13 + vpxor ymm5,ymm5,ymm9 + vpslld ymm3,ymm5,7 + vpsrld ymm5,ymm5,25 + vpxor ymm5,ymm5,ymm3 + vpalignr ymm13,ymm13,ymm13,4 + vpalignr ymm9,ymm9,ymm9,8 + vpalignr ymm5,ymm5,ymm5,12 + vpaddd ymm2,ymm2,ymm6 + vpxor ymm14,ymm14,ymm2 + vpshufb ymm14,ymm14,YMMWORD[$L$rol16] + vpaddd ymm10,ymm10,ymm14 + vpxor ymm6,ymm6,ymm10 + vpsrld ymm3,ymm6,20 + vpslld ymm6,ymm6,12 + vpxor ymm6,ymm6,ymm3 + vpaddd ymm2,ymm2,ymm6 + vpxor ymm14,ymm14,ymm2 + vpshufb ymm14,ymm14,YMMWORD[$L$rol8] + vpaddd ymm10,ymm10,ymm14 + vpxor ymm6,ymm6,ymm10 + vpslld ymm3,ymm6,7 + vpsrld ymm6,ymm6,25 + vpxor ymm6,ymm6,ymm3 + vpalignr ymm14,ymm14,ymm14,4 + vpalignr ymm10,ymm10,ymm10,8 + vpalignr ymm6,ymm6,ymm6,12 + + dec r10 + jne NEAR $L$open_avx2_320_rounds + vpaddd ymm0,ymm0,YMMWORD[$L$chacha20_consts] + vpaddd ymm1,ymm1,YMMWORD[$L$chacha20_consts] + vpaddd ymm2,ymm2,YMMWORD[$L$chacha20_consts] + vpaddd ymm4,ymm4,ymm7 + vpaddd ymm5,ymm5,ymm7 + vpaddd ymm6,ymm6,ymm7 + vpaddd ymm8,ymm8,ymm11 + vpaddd ymm9,ymm9,ymm11 + vpaddd ymm10,ymm10,ymm11 + vpaddd ymm12,ymm12,YMMWORD[((160+160))+rbp] + vpaddd ymm13,ymm13,YMMWORD[((160+192))+rbp] + vpaddd ymm14,ymm14,YMMWORD[((160+224))+rbp] + vperm2i128 ymm3,ymm4,ymm0,0x02 + + vpand ymm3,ymm3,YMMWORD[$L$clamp] + vmovdqa YMMWORD[(160+0)+rbp],ymm3 + + vperm2i128 ymm0,ymm4,ymm0,0x13 + vperm2i128 ymm4,ymm12,ymm8,0x13 + vperm2i128 ymm8,ymm5,ymm1,0x02 + vperm2i128 ymm12,ymm13,ymm9,0x02 + vperm2i128 ymm1,ymm5,ymm1,0x13 + vperm2i128 ymm5,ymm13,ymm9,0x13 + vperm2i128 ymm9,ymm6,ymm2,0x02 + vperm2i128 ymm13,ymm14,ymm10,0x02 + vperm2i128 ymm2,ymm6,ymm2,0x13 + vperm2i128 ymm6,ymm14,ymm10,0x13 + jmp NEAR $L$open_avx2_short +$L$SEH_end_chacha20_poly1305_open_avx2: + + + +global chacha20_poly1305_seal_avx2 + +ALIGN 64 +chacha20_poly1305_seal_avx2: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_chacha20_poly1305_seal_avx2: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + mov rcx,r9 + mov r8,QWORD[40+rsp] + mov r9,QWORD[48+rsp] + + + +_CET_ENDBR + push rbp + + push rbx + + push r12 + + push r13 + + push r14 + + push r15 + + + + push r9 + + sub rsp,288 + 160 + 32 + + lea rbp,[32+rsp] + and rbp,-32 + + movaps XMMWORD[(0+0)+rbp],xmm6 + movaps XMMWORD[(16+0)+rbp],xmm7 + movaps XMMWORD[(32+0)+rbp],xmm8 + movaps XMMWORD[(48+0)+rbp],xmm9 + movaps XMMWORD[(64+0)+rbp],xmm10 + movaps XMMWORD[(80+0)+rbp],xmm11 + movaps XMMWORD[(96+0)+rbp],xmm12 + movaps XMMWORD[(112+0)+rbp],xmm13 + movaps XMMWORD[(128+0)+rbp],xmm14 + movaps XMMWORD[(144+0)+rbp],xmm15 + + mov rbx,QWORD[56+r9] + add rbx,rdx + mov QWORD[((0+160+32))+rbp],r8 + mov QWORD[((8+160+32))+rbp],rbx + mov rbx,rdx + + vzeroupper + vmovdqa ymm0,YMMWORD[$L$chacha20_consts] + vbroadcasti128 ymm4,XMMWORD[r9] + vbroadcasti128 ymm8,XMMWORD[16+r9] + vbroadcasti128 ymm12,XMMWORD[32+r9] + vpaddd ymm12,ymm12,YMMWORD[$L$avx2_init] + cmp rbx,6*32 + jbe NEAR $L$seal_avx2_192 + cmp rbx,10*32 + jbe NEAR $L$seal_avx2_320 + vmovdqa ymm1,ymm0 + vmovdqa ymm2,ymm0 + vmovdqa ymm3,ymm0 + vmovdqa ymm5,ymm4 + vmovdqa ymm6,ymm4 + vmovdqa ymm7,ymm4 + vmovdqa YMMWORD[(160+64)+rbp],ymm4 + vmovdqa ymm9,ymm8 + vmovdqa ymm10,ymm8 + vmovdqa ymm11,ymm8 + vmovdqa YMMWORD[(160+96)+rbp],ymm8 + vmovdqa ymm15,ymm12 + vpaddd ymm14,ymm15,YMMWORD[$L$avx2_inc] + vpaddd ymm13,ymm14,YMMWORD[$L$avx2_inc] + vpaddd ymm12,ymm13,YMMWORD[$L$avx2_inc] + vmovdqa YMMWORD[(160+160)+rbp],ymm12 + vmovdqa YMMWORD[(160+192)+rbp],ymm13 + vmovdqa YMMWORD[(160+224)+rbp],ymm14 + vmovdqa YMMWORD[(160+256)+rbp],ymm15 + mov r10,10 +$L$seal_avx2_init_rounds: + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vmovdqa ymm8,YMMWORD[$L$rol16] + vpaddd ymm3,ymm3,ymm7 + vpaddd ymm2,ymm2,ymm6 + vpaddd ymm1,ymm1,ymm5 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm15,ymm15,ymm3 + vpxor ymm14,ymm14,ymm2 + vpxor ymm13,ymm13,ymm1 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm15,ymm15,ymm8 + vpshufb ymm14,ymm14,ymm8 + vpshufb ymm13,ymm13,ymm8 + vpshufb ymm12,ymm12,ymm8 + vpaddd ymm11,ymm11,ymm15 + vpaddd ymm10,ymm10,ymm14 + vpaddd ymm9,ymm9,ymm13 + vpaddd ymm8,ymm12,YMMWORD[((160+128))+rbp] + vpxor ymm7,ymm7,ymm11 + vpxor ymm6,ymm6,ymm10 + vpxor ymm5,ymm5,ymm9 + vpxor ymm4,ymm4,ymm8 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vpsrld ymm8,ymm7,20 + vpslld ymm7,ymm7,32-20 + vpxor ymm7,ymm7,ymm8 + vpsrld ymm8,ymm6,20 + vpslld ymm6,ymm6,32-20 + vpxor ymm6,ymm6,ymm8 + vpsrld ymm8,ymm5,20 + vpslld ymm5,ymm5,32-20 + vpxor ymm5,ymm5,ymm8 + vpsrld ymm8,ymm4,20 + vpslld ymm4,ymm4,32-20 + vpxor ymm4,ymm4,ymm8 + vmovdqa ymm8,YMMWORD[$L$rol8] + vpaddd ymm3,ymm3,ymm7 + vpaddd ymm2,ymm2,ymm6 + vpaddd ymm1,ymm1,ymm5 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm15,ymm15,ymm3 + vpxor ymm14,ymm14,ymm2 + vpxor ymm13,ymm13,ymm1 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm15,ymm15,ymm8 + vpshufb ymm14,ymm14,ymm8 + vpshufb ymm13,ymm13,ymm8 + vpshufb ymm12,ymm12,ymm8 + vpaddd ymm11,ymm11,ymm15 + vpaddd ymm10,ymm10,ymm14 + vpaddd ymm9,ymm9,ymm13 + vpaddd ymm8,ymm12,YMMWORD[((160+128))+rbp] + vpxor ymm7,ymm7,ymm11 + vpxor ymm6,ymm6,ymm10 + vpxor ymm5,ymm5,ymm9 + vpxor ymm4,ymm4,ymm8 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vpsrld ymm8,ymm7,25 + vpslld ymm7,ymm7,32-25 + vpxor ymm7,ymm7,ymm8 + vpsrld ymm8,ymm6,25 + vpslld ymm6,ymm6,32-25 + vpxor ymm6,ymm6,ymm8 + vpsrld ymm8,ymm5,25 + vpslld ymm5,ymm5,32-25 + vpxor ymm5,ymm5,ymm8 + vpsrld ymm8,ymm4,25 + vpslld ymm4,ymm4,32-25 + vpxor ymm4,ymm4,ymm8 + vmovdqa ymm8,YMMWORD[((160+128))+rbp] + vpalignr ymm7,ymm7,ymm7,4 + vpalignr ymm11,ymm11,ymm11,8 + vpalignr ymm15,ymm15,ymm15,12 + vpalignr ymm6,ymm6,ymm6,4 + vpalignr ymm10,ymm10,ymm10,8 + vpalignr ymm14,ymm14,ymm14,12 + vpalignr ymm5,ymm5,ymm5,4 + vpalignr ymm9,ymm9,ymm9,8 + vpalignr ymm13,ymm13,ymm13,12 + vpalignr ymm4,ymm4,ymm4,4 + vpalignr ymm8,ymm8,ymm8,8 + vpalignr ymm12,ymm12,ymm12,12 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vmovdqa ymm8,YMMWORD[$L$rol16] + vpaddd ymm3,ymm3,ymm7 + vpaddd ymm2,ymm2,ymm6 + vpaddd ymm1,ymm1,ymm5 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm15,ymm15,ymm3 + vpxor ymm14,ymm14,ymm2 + vpxor ymm13,ymm13,ymm1 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm15,ymm15,ymm8 + vpshufb ymm14,ymm14,ymm8 + vpshufb ymm13,ymm13,ymm8 + vpshufb ymm12,ymm12,ymm8 + vpaddd ymm11,ymm11,ymm15 + vpaddd ymm10,ymm10,ymm14 + vpaddd ymm9,ymm9,ymm13 + vpaddd ymm8,ymm12,YMMWORD[((160+128))+rbp] + vpxor ymm7,ymm7,ymm11 + vpxor ymm6,ymm6,ymm10 + vpxor ymm5,ymm5,ymm9 + vpxor ymm4,ymm4,ymm8 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vpsrld ymm8,ymm7,20 + vpslld ymm7,ymm7,32-20 + vpxor ymm7,ymm7,ymm8 + vpsrld ymm8,ymm6,20 + vpslld ymm6,ymm6,32-20 + vpxor ymm6,ymm6,ymm8 + vpsrld ymm8,ymm5,20 + vpslld ymm5,ymm5,32-20 + vpxor ymm5,ymm5,ymm8 + vpsrld ymm8,ymm4,20 + vpslld ymm4,ymm4,32-20 + vpxor ymm4,ymm4,ymm8 + vmovdqa ymm8,YMMWORD[$L$rol8] + vpaddd ymm3,ymm3,ymm7 + vpaddd ymm2,ymm2,ymm6 + vpaddd ymm1,ymm1,ymm5 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm15,ymm15,ymm3 + vpxor ymm14,ymm14,ymm2 + vpxor ymm13,ymm13,ymm1 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm15,ymm15,ymm8 + vpshufb ymm14,ymm14,ymm8 + vpshufb ymm13,ymm13,ymm8 + vpshufb ymm12,ymm12,ymm8 + vpaddd ymm11,ymm11,ymm15 + vpaddd ymm10,ymm10,ymm14 + vpaddd ymm9,ymm9,ymm13 + vpaddd ymm8,ymm12,YMMWORD[((160+128))+rbp] + vpxor ymm7,ymm7,ymm11 + vpxor ymm6,ymm6,ymm10 + vpxor ymm5,ymm5,ymm9 + vpxor ymm4,ymm4,ymm8 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vpsrld ymm8,ymm7,25 + vpslld ymm7,ymm7,32-25 + vpxor ymm7,ymm7,ymm8 + vpsrld ymm8,ymm6,25 + vpslld ymm6,ymm6,32-25 + vpxor ymm6,ymm6,ymm8 + vpsrld ymm8,ymm5,25 + vpslld ymm5,ymm5,32-25 + vpxor ymm5,ymm5,ymm8 + vpsrld ymm8,ymm4,25 + vpslld ymm4,ymm4,32-25 + vpxor ymm4,ymm4,ymm8 + vmovdqa ymm8,YMMWORD[((160+128))+rbp] + vpalignr ymm7,ymm7,ymm7,12 + vpalignr ymm11,ymm11,ymm11,8 + vpalignr ymm15,ymm15,ymm15,4 + vpalignr ymm6,ymm6,ymm6,12 + vpalignr ymm10,ymm10,ymm10,8 + vpalignr ymm14,ymm14,ymm14,4 + vpalignr ymm5,ymm5,ymm5,12 + vpalignr ymm9,ymm9,ymm9,8 + vpalignr ymm13,ymm13,ymm13,4 + vpalignr ymm4,ymm4,ymm4,12 + vpalignr ymm8,ymm8,ymm8,8 + vpalignr ymm12,ymm12,ymm12,4 + + dec r10 + jnz NEAR $L$seal_avx2_init_rounds + vpaddd ymm3,ymm3,YMMWORD[$L$chacha20_consts] + vpaddd ymm7,ymm7,YMMWORD[((160+64))+rbp] + vpaddd ymm11,ymm11,YMMWORD[((160+96))+rbp] + vpaddd ymm15,ymm15,YMMWORD[((160+256))+rbp] + vpaddd ymm2,ymm2,YMMWORD[$L$chacha20_consts] + vpaddd ymm6,ymm6,YMMWORD[((160+64))+rbp] + vpaddd ymm10,ymm10,YMMWORD[((160+96))+rbp] + vpaddd ymm14,ymm14,YMMWORD[((160+224))+rbp] + vpaddd ymm1,ymm1,YMMWORD[$L$chacha20_consts] + vpaddd ymm5,ymm5,YMMWORD[((160+64))+rbp] + vpaddd ymm9,ymm9,YMMWORD[((160+96))+rbp] + vpaddd ymm13,ymm13,YMMWORD[((160+192))+rbp] + vpaddd ymm0,ymm0,YMMWORD[$L$chacha20_consts] + vpaddd ymm4,ymm4,YMMWORD[((160+64))+rbp] + vpaddd ymm8,ymm8,YMMWORD[((160+96))+rbp] + vpaddd ymm12,ymm12,YMMWORD[((160+160))+rbp] + + vperm2i128 ymm11,ymm15,ymm11,0x13 + vperm2i128 ymm15,ymm7,ymm3,0x02 + vperm2i128 ymm3,ymm7,ymm3,0x13 + vpand ymm15,ymm15,YMMWORD[$L$clamp] + vmovdqa YMMWORD[(160+0)+rbp],ymm15 + mov r8,r8 + call poly_hash_ad_internal + + vpxor ymm3,ymm3,YMMWORD[rsi] + vpxor ymm11,ymm11,YMMWORD[32+rsi] + vmovdqu YMMWORD[rdi],ymm3 + vmovdqu YMMWORD[32+rdi],ymm11 + vperm2i128 ymm15,ymm6,ymm2,0x02 + vperm2i128 ymm6,ymm6,ymm2,0x13 + vperm2i128 ymm2,ymm14,ymm10,0x02 + vperm2i128 ymm10,ymm14,ymm10,0x13 + vpxor ymm15,ymm15,YMMWORD[((0+64))+rsi] + vpxor ymm2,ymm2,YMMWORD[((32+64))+rsi] + vpxor ymm6,ymm6,YMMWORD[((64+64))+rsi] + vpxor ymm10,ymm10,YMMWORD[((96+64))+rsi] + vmovdqu YMMWORD[(0+64)+rdi],ymm15 + vmovdqu YMMWORD[(32+64)+rdi],ymm2 + vmovdqu YMMWORD[(64+64)+rdi],ymm6 + vmovdqu YMMWORD[(96+64)+rdi],ymm10 + vperm2i128 ymm15,ymm5,ymm1,0x02 + vperm2i128 ymm5,ymm5,ymm1,0x13 + vperm2i128 ymm1,ymm13,ymm9,0x02 + vperm2i128 ymm9,ymm13,ymm9,0x13 + vpxor ymm15,ymm15,YMMWORD[((0+192))+rsi] + vpxor ymm1,ymm1,YMMWORD[((32+192))+rsi] + vpxor ymm5,ymm5,YMMWORD[((64+192))+rsi] + vpxor ymm9,ymm9,YMMWORD[((96+192))+rsi] + vmovdqu YMMWORD[(0+192)+rdi],ymm15 + vmovdqu YMMWORD[(32+192)+rdi],ymm1 + vmovdqu YMMWORD[(64+192)+rdi],ymm5 + vmovdqu YMMWORD[(96+192)+rdi],ymm9 + vperm2i128 ymm15,ymm4,ymm0,0x13 + vperm2i128 ymm0,ymm4,ymm0,0x02 + vperm2i128 ymm4,ymm12,ymm8,0x02 + vperm2i128 ymm12,ymm12,ymm8,0x13 + vmovdqa ymm8,ymm15 + + lea rsi,[320+rsi] + sub rbx,10*32 + mov rcx,10*32 + cmp rbx,4*32 + jbe NEAR $L$seal_avx2_short_hash_remainder + vpxor ymm0,ymm0,YMMWORD[rsi] + vpxor ymm4,ymm4,YMMWORD[32+rsi] + vpxor ymm8,ymm8,YMMWORD[64+rsi] + vpxor ymm12,ymm12,YMMWORD[96+rsi] + vmovdqu YMMWORD[320+rdi],ymm0 + vmovdqu YMMWORD[352+rdi],ymm4 + vmovdqu YMMWORD[384+rdi],ymm8 + vmovdqu YMMWORD[416+rdi],ymm12 + lea rsi,[128+rsi] + sub rbx,4*32 + mov rcx,8 + mov r8,2 + cmp rbx,4*32 + jbe NEAR $L$seal_avx2_tail_128 + cmp rbx,8*32 + jbe NEAR $L$seal_avx2_tail_256 + cmp rbx,12*32 + jbe NEAR $L$seal_avx2_tail_384 + cmp rbx,16*32 + jbe NEAR $L$seal_avx2_tail_512 + vmovdqa ymm0,YMMWORD[$L$chacha20_consts] + vmovdqa ymm4,YMMWORD[((160+64))+rbp] + vmovdqa ymm8,YMMWORD[((160+96))+rbp] + vmovdqa ymm1,ymm0 + vmovdqa ymm5,ymm4 + vmovdqa ymm9,ymm8 + vmovdqa ymm2,ymm0 + vmovdqa ymm6,ymm4 + vmovdqa ymm10,ymm8 + vmovdqa ymm3,ymm0 + vmovdqa ymm7,ymm4 + vmovdqa ymm11,ymm8 + vmovdqa ymm12,YMMWORD[$L$avx2_inc] + vpaddd ymm15,ymm12,YMMWORD[((160+160))+rbp] + vpaddd ymm14,ymm12,ymm15 + vpaddd ymm13,ymm12,ymm14 + vpaddd ymm12,ymm12,ymm13 + vmovdqa YMMWORD[(160+256)+rbp],ymm15 + vmovdqa YMMWORD[(160+224)+rbp],ymm14 + vmovdqa YMMWORD[(160+192)+rbp],ymm13 + vmovdqa YMMWORD[(160+160)+rbp],ymm12 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vmovdqa ymm8,YMMWORD[$L$rol16] + vpaddd ymm3,ymm3,ymm7 + vpaddd ymm2,ymm2,ymm6 + vpaddd ymm1,ymm1,ymm5 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm15,ymm15,ymm3 + vpxor ymm14,ymm14,ymm2 + vpxor ymm13,ymm13,ymm1 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm15,ymm15,ymm8 + vpshufb ymm14,ymm14,ymm8 + vpshufb ymm13,ymm13,ymm8 + vpshufb ymm12,ymm12,ymm8 + vpaddd ymm11,ymm11,ymm15 + vpaddd ymm10,ymm10,ymm14 + vpaddd ymm9,ymm9,ymm13 + vpaddd ymm8,ymm12,YMMWORD[((160+128))+rbp] + vpxor ymm7,ymm7,ymm11 + vpxor ymm6,ymm6,ymm10 + vpxor ymm5,ymm5,ymm9 + vpxor ymm4,ymm4,ymm8 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vpsrld ymm8,ymm7,20 + vpslld ymm7,ymm7,32-20 + vpxor ymm7,ymm7,ymm8 + vpsrld ymm8,ymm6,20 + vpslld ymm6,ymm6,32-20 + vpxor ymm6,ymm6,ymm8 + vpsrld ymm8,ymm5,20 + vpslld ymm5,ymm5,32-20 + vpxor ymm5,ymm5,ymm8 + vpsrld ymm8,ymm4,20 + vpslld ymm4,ymm4,32-20 + vpxor ymm4,ymm4,ymm8 + vmovdqa ymm8,YMMWORD[$L$rol8] + vpaddd ymm3,ymm3,ymm7 + vpaddd ymm2,ymm2,ymm6 + vpaddd ymm1,ymm1,ymm5 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm15,ymm15,ymm3 + vpxor ymm14,ymm14,ymm2 + vpxor ymm13,ymm13,ymm1 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm15,ymm15,ymm8 + vpshufb ymm14,ymm14,ymm8 + vpshufb ymm13,ymm13,ymm8 + vpshufb ymm12,ymm12,ymm8 + vpaddd ymm11,ymm11,ymm15 + vpaddd ymm10,ymm10,ymm14 + vpaddd ymm9,ymm9,ymm13 + vpaddd ymm8,ymm12,YMMWORD[((160+128))+rbp] + vpxor ymm7,ymm7,ymm11 + vpxor ymm6,ymm6,ymm10 + vpxor ymm5,ymm5,ymm9 + vpxor ymm4,ymm4,ymm8 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vpsrld ymm8,ymm7,25 + vpslld ymm7,ymm7,32-25 + vpxor ymm7,ymm7,ymm8 + vpsrld ymm8,ymm6,25 + vpslld ymm6,ymm6,32-25 + vpxor ymm6,ymm6,ymm8 + vpsrld ymm8,ymm5,25 + vpslld ymm5,ymm5,32-25 + vpxor ymm5,ymm5,ymm8 + vpsrld ymm8,ymm4,25 + vpslld ymm4,ymm4,32-25 + vpxor ymm4,ymm4,ymm8 + vmovdqa ymm8,YMMWORD[((160+128))+rbp] + vpalignr ymm7,ymm7,ymm7,4 + vpalignr ymm11,ymm11,ymm11,8 + vpalignr ymm15,ymm15,ymm15,12 + vpalignr ymm6,ymm6,ymm6,4 + vpalignr ymm10,ymm10,ymm10,8 + vpalignr ymm14,ymm14,ymm14,12 + vpalignr ymm5,ymm5,ymm5,4 + vpalignr ymm9,ymm9,ymm9,8 + vpalignr ymm13,ymm13,ymm13,12 + vpalignr ymm4,ymm4,ymm4,4 + vpalignr ymm8,ymm8,ymm8,8 + vpalignr ymm12,ymm12,ymm12,12 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vmovdqa ymm8,YMMWORD[$L$rol16] + vpaddd ymm3,ymm3,ymm7 + vpaddd ymm2,ymm2,ymm6 + vpaddd ymm1,ymm1,ymm5 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm15,ymm15,ymm3 + vpxor ymm14,ymm14,ymm2 + vpxor ymm13,ymm13,ymm1 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm15,ymm15,ymm8 + vpshufb ymm14,ymm14,ymm8 + vpshufb ymm13,ymm13,ymm8 + vpshufb ymm12,ymm12,ymm8 + vpaddd ymm11,ymm11,ymm15 + vpaddd ymm10,ymm10,ymm14 + vpaddd ymm9,ymm9,ymm13 + vpaddd ymm8,ymm12,YMMWORD[((160+128))+rbp] + vpxor ymm7,ymm7,ymm11 + vpxor ymm6,ymm6,ymm10 + vpxor ymm5,ymm5,ymm9 + vpxor ymm4,ymm4,ymm8 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vpsrld ymm8,ymm7,20 + vpslld ymm7,ymm7,32-20 + vpxor ymm7,ymm7,ymm8 + vpsrld ymm8,ymm6,20 + vpslld ymm6,ymm6,32-20 + vpxor ymm6,ymm6,ymm8 + vpsrld ymm8,ymm5,20 + vpslld ymm5,ymm5,32-20 + vpxor ymm5,ymm5,ymm8 + vpsrld ymm8,ymm4,20 + vpslld ymm4,ymm4,32-20 + vpxor ymm4,ymm4,ymm8 + vmovdqa ymm8,YMMWORD[$L$rol8] + vpaddd ymm3,ymm3,ymm7 + vpaddd ymm2,ymm2,ymm6 + vpaddd ymm1,ymm1,ymm5 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm15,ymm15,ymm3 + vpxor ymm14,ymm14,ymm2 + vpxor ymm13,ymm13,ymm1 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm15,ymm15,ymm8 + vpshufb ymm14,ymm14,ymm8 + vpshufb ymm13,ymm13,ymm8 + vpshufb ymm12,ymm12,ymm8 + vpaddd ymm11,ymm11,ymm15 + vpaddd ymm10,ymm10,ymm14 + vpaddd ymm9,ymm9,ymm13 + vpaddd ymm8,ymm12,YMMWORD[((160+128))+rbp] + vpxor ymm7,ymm7,ymm11 + vpxor ymm6,ymm6,ymm10 + vpxor ymm5,ymm5,ymm9 + vpxor ymm4,ymm4,ymm8 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vpsrld ymm8,ymm7,25 + vpslld ymm7,ymm7,32-25 + vpxor ymm7,ymm7,ymm8 + vpsrld ymm8,ymm6,25 + vpslld ymm6,ymm6,32-25 + vpxor ymm6,ymm6,ymm8 + vpsrld ymm8,ymm5,25 + vpslld ymm5,ymm5,32-25 + vpxor ymm5,ymm5,ymm8 + vpsrld ymm8,ymm4,25 + vpslld ymm4,ymm4,32-25 + vpxor ymm4,ymm4,ymm8 + vmovdqa ymm8,YMMWORD[((160+128))+rbp] + vpalignr ymm7,ymm7,ymm7,12 + vpalignr ymm11,ymm11,ymm11,8 + vpalignr ymm15,ymm15,ymm15,4 + vpalignr ymm6,ymm6,ymm6,12 + vpalignr ymm10,ymm10,ymm10,8 + vpalignr ymm14,ymm14,ymm14,4 + vpalignr ymm5,ymm5,ymm5,12 + vpalignr ymm9,ymm9,ymm9,8 + vpalignr ymm13,ymm13,ymm13,4 + vpalignr ymm4,ymm4,ymm4,12 + vpalignr ymm8,ymm8,ymm8,8 + vpalignr ymm12,ymm12,ymm12,4 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vmovdqa ymm8,YMMWORD[$L$rol16] + vpaddd ymm3,ymm3,ymm7 + vpaddd ymm2,ymm2,ymm6 + vpaddd ymm1,ymm1,ymm5 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm15,ymm15,ymm3 + vpxor ymm14,ymm14,ymm2 + vpxor ymm13,ymm13,ymm1 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm15,ymm15,ymm8 + vpshufb ymm14,ymm14,ymm8 + vpshufb ymm13,ymm13,ymm8 + vpshufb ymm12,ymm12,ymm8 + vpaddd ymm11,ymm11,ymm15 + vpaddd ymm10,ymm10,ymm14 + vpaddd ymm9,ymm9,ymm13 + vpaddd ymm8,ymm12,YMMWORD[((160+128))+rbp] + vpxor ymm7,ymm7,ymm11 + vpxor ymm6,ymm6,ymm10 + vpxor ymm5,ymm5,ymm9 + vpxor ymm4,ymm4,ymm8 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vpsrld ymm8,ymm7,20 + vpslld ymm7,ymm7,32-20 + vpxor ymm7,ymm7,ymm8 + vpsrld ymm8,ymm6,20 + vpslld ymm6,ymm6,32-20 + vpxor ymm6,ymm6,ymm8 + vpsrld ymm8,ymm5,20 + vpslld ymm5,ymm5,32-20 + vpxor ymm5,ymm5,ymm8 + vpsrld ymm8,ymm4,20 + vpslld ymm4,ymm4,32-20 + vpxor ymm4,ymm4,ymm8 + vmovdqa ymm8,YMMWORD[$L$rol8] + vpaddd ymm3,ymm3,ymm7 + vpaddd ymm2,ymm2,ymm6 + vpaddd ymm1,ymm1,ymm5 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm15,ymm15,ymm3 + + sub rdi,16 + mov rcx,9 + jmp NEAR $L$seal_avx2_main_loop_rounds_entry +ALIGN 32 +$L$seal_avx2_main_loop: + vmovdqa ymm0,YMMWORD[$L$chacha20_consts] + vmovdqa ymm4,YMMWORD[((160+64))+rbp] + vmovdqa ymm8,YMMWORD[((160+96))+rbp] + vmovdqa ymm1,ymm0 + vmovdqa ymm5,ymm4 + vmovdqa ymm9,ymm8 + vmovdqa ymm2,ymm0 + vmovdqa ymm6,ymm4 + vmovdqa ymm10,ymm8 + vmovdqa ymm3,ymm0 + vmovdqa ymm7,ymm4 + vmovdqa ymm11,ymm8 + vmovdqa ymm12,YMMWORD[$L$avx2_inc] + vpaddd ymm15,ymm12,YMMWORD[((160+160))+rbp] + vpaddd ymm14,ymm12,ymm15 + vpaddd ymm13,ymm12,ymm14 + vpaddd ymm12,ymm12,ymm13 + vmovdqa YMMWORD[(160+256)+rbp],ymm15 + vmovdqa YMMWORD[(160+224)+rbp],ymm14 + vmovdqa YMMWORD[(160+192)+rbp],ymm13 + vmovdqa YMMWORD[(160+160)+rbp],ymm12 + + mov rcx,10 +ALIGN 32 +$L$seal_avx2_main_loop_rounds: + add r10,QWORD[((0+0))+rdi] + adc r11,QWORD[((8+0))+rdi] + adc r12,1 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vmovdqa ymm8,YMMWORD[$L$rol16] + vpaddd ymm3,ymm3,ymm7 + vpaddd ymm2,ymm2,ymm6 + vpaddd ymm1,ymm1,ymm5 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm15,ymm15,ymm3 + vpxor ymm14,ymm14,ymm2 + vpxor ymm13,ymm13,ymm1 + vpxor ymm12,ymm12,ymm0 + mov rdx,QWORD[((0+160+0))+rbp] + mov r15,rdx + mulx r14,r13,r10 + mulx rdx,rax,r11 + imul r15,r12 + add r14,rax + adc r15,rdx + vpshufb ymm15,ymm15,ymm8 + vpshufb ymm14,ymm14,ymm8 + vpshufb ymm13,ymm13,ymm8 + vpshufb ymm12,ymm12,ymm8 + vpaddd ymm11,ymm11,ymm15 + vpaddd ymm10,ymm10,ymm14 + vpaddd ymm9,ymm9,ymm13 + vpaddd ymm8,ymm12,YMMWORD[((160+128))+rbp] + vpxor ymm7,ymm7,ymm11 + mov rdx,QWORD[((8+160+0))+rbp] + mulx rax,r10,r10 + add r14,r10 + mulx r9,r11,r11 + adc r15,r11 + adc r9,0 + imul rdx,r12 + vpxor ymm6,ymm6,ymm10 + vpxor ymm5,ymm5,ymm9 + vpxor ymm4,ymm4,ymm8 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vpsrld ymm8,ymm7,20 + vpslld ymm7,ymm7,32-20 + vpxor ymm7,ymm7,ymm8 + vpsrld ymm8,ymm6,20 + vpslld ymm6,ymm6,32-20 + vpxor ymm6,ymm6,ymm8 + vpsrld ymm8,ymm5,20 + vpslld ymm5,ymm5,32-20 + add r15,rax + adc r9,rdx + vpxor ymm5,ymm5,ymm8 + vpsrld ymm8,ymm4,20 + vpslld ymm4,ymm4,32-20 + vpxor ymm4,ymm4,ymm8 + vmovdqa ymm8,YMMWORD[$L$rol8] + vpaddd ymm3,ymm3,ymm7 + vpaddd ymm2,ymm2,ymm6 + vpaddd ymm1,ymm1,ymm5 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm15,ymm15,ymm3 + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + +$L$seal_avx2_main_loop_rounds_entry: + vpxor ymm14,ymm14,ymm2 + vpxor ymm13,ymm13,ymm1 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm15,ymm15,ymm8 + vpshufb ymm14,ymm14,ymm8 + vpshufb ymm13,ymm13,ymm8 + vpshufb ymm12,ymm12,ymm8 + vpaddd ymm11,ymm11,ymm15 + vpaddd ymm10,ymm10,ymm14 + add r10,QWORD[((0+16))+rdi] + adc r11,QWORD[((8+16))+rdi] + adc r12,1 + vpaddd ymm9,ymm9,ymm13 + vpaddd ymm8,ymm12,YMMWORD[((160+128))+rbp] + vpxor ymm7,ymm7,ymm11 + vpxor ymm6,ymm6,ymm10 + vpxor ymm5,ymm5,ymm9 + vpxor ymm4,ymm4,ymm8 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vpsrld ymm8,ymm7,25 + mov rdx,QWORD[((0+160+0))+rbp] + mov r15,rdx + mulx r14,r13,r10 + mulx rdx,rax,r11 + imul r15,r12 + add r14,rax + adc r15,rdx + vpslld ymm7,ymm7,32-25 + vpxor ymm7,ymm7,ymm8 + vpsrld ymm8,ymm6,25 + vpslld ymm6,ymm6,32-25 + vpxor ymm6,ymm6,ymm8 + vpsrld ymm8,ymm5,25 + vpslld ymm5,ymm5,32-25 + vpxor ymm5,ymm5,ymm8 + vpsrld ymm8,ymm4,25 + vpslld ymm4,ymm4,32-25 + vpxor ymm4,ymm4,ymm8 + vmovdqa ymm8,YMMWORD[((160+128))+rbp] + vpalignr ymm7,ymm7,ymm7,4 + vpalignr ymm11,ymm11,ymm11,8 + vpalignr ymm15,ymm15,ymm15,12 + vpalignr ymm6,ymm6,ymm6,4 + vpalignr ymm10,ymm10,ymm10,8 + vpalignr ymm14,ymm14,ymm14,12 + mov rdx,QWORD[((8+160+0))+rbp] + mulx rax,r10,r10 + add r14,r10 + mulx r9,r11,r11 + adc r15,r11 + adc r9,0 + imul rdx,r12 + vpalignr ymm5,ymm5,ymm5,4 + vpalignr ymm9,ymm9,ymm9,8 + vpalignr ymm13,ymm13,ymm13,12 + vpalignr ymm4,ymm4,ymm4,4 + vpalignr ymm8,ymm8,ymm8,8 + vpalignr ymm12,ymm12,ymm12,12 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vmovdqa ymm8,YMMWORD[$L$rol16] + vpaddd ymm3,ymm3,ymm7 + vpaddd ymm2,ymm2,ymm6 + vpaddd ymm1,ymm1,ymm5 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm15,ymm15,ymm3 + vpxor ymm14,ymm14,ymm2 + vpxor ymm13,ymm13,ymm1 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm15,ymm15,ymm8 + vpshufb ymm14,ymm14,ymm8 + add r15,rax + adc r9,rdx + vpshufb ymm13,ymm13,ymm8 + vpshufb ymm12,ymm12,ymm8 + vpaddd ymm11,ymm11,ymm15 + vpaddd ymm10,ymm10,ymm14 + vpaddd ymm9,ymm9,ymm13 + vpaddd ymm8,ymm12,YMMWORD[((160+128))+rbp] + vpxor ymm7,ymm7,ymm11 + vpxor ymm6,ymm6,ymm10 + vpxor ymm5,ymm5,ymm9 + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + vpxor ymm4,ymm4,ymm8 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vpsrld ymm8,ymm7,20 + vpslld ymm7,ymm7,32-20 + vpxor ymm7,ymm7,ymm8 + vpsrld ymm8,ymm6,20 + vpslld ymm6,ymm6,32-20 + vpxor ymm6,ymm6,ymm8 + add r10,QWORD[((0+32))+rdi] + adc r11,QWORD[((8+32))+rdi] + adc r12,1 + + lea rdi,[48+rdi] + vpsrld ymm8,ymm5,20 + vpslld ymm5,ymm5,32-20 + vpxor ymm5,ymm5,ymm8 + vpsrld ymm8,ymm4,20 + vpslld ymm4,ymm4,32-20 + vpxor ymm4,ymm4,ymm8 + vmovdqa ymm8,YMMWORD[$L$rol8] + vpaddd ymm3,ymm3,ymm7 + vpaddd ymm2,ymm2,ymm6 + vpaddd ymm1,ymm1,ymm5 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm15,ymm15,ymm3 + vpxor ymm14,ymm14,ymm2 + vpxor ymm13,ymm13,ymm1 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm15,ymm15,ymm8 + vpshufb ymm14,ymm14,ymm8 + vpshufb ymm13,ymm13,ymm8 + mov rdx,QWORD[((0+160+0))+rbp] + mov r15,rdx + mulx r14,r13,r10 + mulx rdx,rax,r11 + imul r15,r12 + add r14,rax + adc r15,rdx + vpshufb ymm12,ymm12,ymm8 + vpaddd ymm11,ymm11,ymm15 + vpaddd ymm10,ymm10,ymm14 + vpaddd ymm9,ymm9,ymm13 + vpaddd ymm8,ymm12,YMMWORD[((160+128))+rbp] + vpxor ymm7,ymm7,ymm11 + vpxor ymm6,ymm6,ymm10 + vpxor ymm5,ymm5,ymm9 + mov rdx,QWORD[((8+160+0))+rbp] + mulx rax,r10,r10 + add r14,r10 + mulx r9,r11,r11 + adc r15,r11 + adc r9,0 + imul rdx,r12 + vpxor ymm4,ymm4,ymm8 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vpsrld ymm8,ymm7,25 + vpslld ymm7,ymm7,32-25 + vpxor ymm7,ymm7,ymm8 + vpsrld ymm8,ymm6,25 + vpslld ymm6,ymm6,32-25 + vpxor ymm6,ymm6,ymm8 + add r15,rax + adc r9,rdx + vpsrld ymm8,ymm5,25 + vpslld ymm5,ymm5,32-25 + vpxor ymm5,ymm5,ymm8 + vpsrld ymm8,ymm4,25 + vpslld ymm4,ymm4,32-25 + vpxor ymm4,ymm4,ymm8 + vmovdqa ymm8,YMMWORD[((160+128))+rbp] + vpalignr ymm7,ymm7,ymm7,12 + vpalignr ymm11,ymm11,ymm11,8 + vpalignr ymm15,ymm15,ymm15,4 + vpalignr ymm6,ymm6,ymm6,12 + vpalignr ymm10,ymm10,ymm10,8 + vpalignr ymm14,ymm14,ymm14,4 + vpalignr ymm5,ymm5,ymm5,12 + vpalignr ymm9,ymm9,ymm9,8 + vpalignr ymm13,ymm13,ymm13,4 + vpalignr ymm4,ymm4,ymm4,12 + vpalignr ymm8,ymm8,ymm8,8 + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + vpalignr ymm12,ymm12,ymm12,4 + + dec rcx + jne NEAR $L$seal_avx2_main_loop_rounds + vpaddd ymm3,ymm3,YMMWORD[$L$chacha20_consts] + vpaddd ymm7,ymm7,YMMWORD[((160+64))+rbp] + vpaddd ymm11,ymm11,YMMWORD[((160+96))+rbp] + vpaddd ymm15,ymm15,YMMWORD[((160+256))+rbp] + vpaddd ymm2,ymm2,YMMWORD[$L$chacha20_consts] + vpaddd ymm6,ymm6,YMMWORD[((160+64))+rbp] + vpaddd ymm10,ymm10,YMMWORD[((160+96))+rbp] + vpaddd ymm14,ymm14,YMMWORD[((160+224))+rbp] + vpaddd ymm1,ymm1,YMMWORD[$L$chacha20_consts] + vpaddd ymm5,ymm5,YMMWORD[((160+64))+rbp] + vpaddd ymm9,ymm9,YMMWORD[((160+96))+rbp] + vpaddd ymm13,ymm13,YMMWORD[((160+192))+rbp] + vpaddd ymm0,ymm0,YMMWORD[$L$chacha20_consts] + vpaddd ymm4,ymm4,YMMWORD[((160+64))+rbp] + vpaddd ymm8,ymm8,YMMWORD[((160+96))+rbp] + vpaddd ymm12,ymm12,YMMWORD[((160+160))+rbp] + + vmovdqa YMMWORD[(160+128)+rbp],ymm0 + add r10,QWORD[((0+0))+rdi] + adc r11,QWORD[((8+0))+rdi] + adc r12,1 + mov rdx,QWORD[((0+160+0))+rbp] + mov r15,rdx + mulx r14,r13,r10 + mulx rdx,rax,r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rdx,QWORD[((8+160+0))+rbp] + mulx rax,r10,r10 + add r14,r10 + mulx r9,r11,r11 + adc r15,r11 + adc r9,0 + imul rdx,r12 + add r15,rax + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + add r10,QWORD[((0+16))+rdi] + adc r11,QWORD[((8+16))+rdi] + adc r12,1 + mov rdx,QWORD[((0+160+0))+rbp] + mov r15,rdx + mulx r14,r13,r10 + mulx rdx,rax,r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rdx,QWORD[((8+160+0))+rbp] + mulx rax,r10,r10 + add r14,r10 + mulx r9,r11,r11 + adc r15,r11 + adc r9,0 + imul rdx,r12 + add r15,rax + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + lea rdi,[32+rdi] + vperm2i128 ymm0,ymm7,ymm3,0x02 + vperm2i128 ymm7,ymm7,ymm3,0x13 + vperm2i128 ymm3,ymm15,ymm11,0x02 + vperm2i128 ymm11,ymm15,ymm11,0x13 + vpxor ymm0,ymm0,YMMWORD[((0+0))+rsi] + vpxor ymm3,ymm3,YMMWORD[((32+0))+rsi] + vpxor ymm7,ymm7,YMMWORD[((64+0))+rsi] + vpxor ymm11,ymm11,YMMWORD[((96+0))+rsi] + vmovdqu YMMWORD[(0+0)+rdi],ymm0 + vmovdqu YMMWORD[(32+0)+rdi],ymm3 + vmovdqu YMMWORD[(64+0)+rdi],ymm7 + vmovdqu YMMWORD[(96+0)+rdi],ymm11 + + vmovdqa ymm0,YMMWORD[((160+128))+rbp] + vperm2i128 ymm3,ymm6,ymm2,0x02 + vperm2i128 ymm6,ymm6,ymm2,0x13 + vperm2i128 ymm2,ymm14,ymm10,0x02 + vperm2i128 ymm10,ymm14,ymm10,0x13 + vpxor ymm3,ymm3,YMMWORD[((0+128))+rsi] + vpxor ymm2,ymm2,YMMWORD[((32+128))+rsi] + vpxor ymm6,ymm6,YMMWORD[((64+128))+rsi] + vpxor ymm10,ymm10,YMMWORD[((96+128))+rsi] + vmovdqu YMMWORD[(0+128)+rdi],ymm3 + vmovdqu YMMWORD[(32+128)+rdi],ymm2 + vmovdqu YMMWORD[(64+128)+rdi],ymm6 + vmovdqu YMMWORD[(96+128)+rdi],ymm10 + vperm2i128 ymm3,ymm5,ymm1,0x02 + vperm2i128 ymm5,ymm5,ymm1,0x13 + vperm2i128 ymm1,ymm13,ymm9,0x02 + vperm2i128 ymm9,ymm13,ymm9,0x13 + vpxor ymm3,ymm3,YMMWORD[((0+256))+rsi] + vpxor ymm1,ymm1,YMMWORD[((32+256))+rsi] + vpxor ymm5,ymm5,YMMWORD[((64+256))+rsi] + vpxor ymm9,ymm9,YMMWORD[((96+256))+rsi] + vmovdqu YMMWORD[(0+256)+rdi],ymm3 + vmovdqu YMMWORD[(32+256)+rdi],ymm1 + vmovdqu YMMWORD[(64+256)+rdi],ymm5 + vmovdqu YMMWORD[(96+256)+rdi],ymm9 + vperm2i128 ymm3,ymm4,ymm0,0x02 + vperm2i128 ymm4,ymm4,ymm0,0x13 + vperm2i128 ymm0,ymm12,ymm8,0x02 + vperm2i128 ymm8,ymm12,ymm8,0x13 + vpxor ymm3,ymm3,YMMWORD[((0+384))+rsi] + vpxor ymm0,ymm0,YMMWORD[((32+384))+rsi] + vpxor ymm4,ymm4,YMMWORD[((64+384))+rsi] + vpxor ymm8,ymm8,YMMWORD[((96+384))+rsi] + vmovdqu YMMWORD[(0+384)+rdi],ymm3 + vmovdqu YMMWORD[(32+384)+rdi],ymm0 + vmovdqu YMMWORD[(64+384)+rdi],ymm4 + vmovdqu YMMWORD[(96+384)+rdi],ymm8 + + lea rsi,[512+rsi] + sub rbx,16*32 + cmp rbx,16*32 + jg NEAR $L$seal_avx2_main_loop + + add r10,QWORD[((0+0))+rdi] + adc r11,QWORD[((8+0))+rdi] + adc r12,1 + mov rdx,QWORD[((0+160+0))+rbp] + mov r15,rdx + mulx r14,r13,r10 + mulx rdx,rax,r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rdx,QWORD[((8+160+0))+rbp] + mulx rax,r10,r10 + add r14,r10 + mulx r9,r11,r11 + adc r15,r11 + adc r9,0 + imul rdx,r12 + add r15,rax + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + add r10,QWORD[((0+16))+rdi] + adc r11,QWORD[((8+16))+rdi] + adc r12,1 + mov rdx,QWORD[((0+160+0))+rbp] + mov r15,rdx + mulx r14,r13,r10 + mulx rdx,rax,r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rdx,QWORD[((8+160+0))+rbp] + mulx rax,r10,r10 + add r14,r10 + mulx r9,r11,r11 + adc r15,r11 + adc r9,0 + imul rdx,r12 + add r15,rax + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + lea rdi,[32+rdi] + mov rcx,10 + xor r8,r8 + + cmp rbx,12*32 + ja NEAR $L$seal_avx2_tail_512 + cmp rbx,8*32 + ja NEAR $L$seal_avx2_tail_384 + cmp rbx,4*32 + ja NEAR $L$seal_avx2_tail_256 + +$L$seal_avx2_tail_128: + vmovdqa ymm0,YMMWORD[$L$chacha20_consts] + vmovdqa ymm4,YMMWORD[((160+64))+rbp] + vmovdqa ymm8,YMMWORD[((160+96))+rbp] + vmovdqa ymm12,YMMWORD[$L$avx2_inc] + vpaddd ymm12,ymm12,YMMWORD[((160+160))+rbp] + vmovdqa YMMWORD[(160+160)+rbp],ymm12 + +$L$seal_avx2_tail_128_rounds_and_3xhash: + add r10,QWORD[((0+0))+rdi] + adc r11,QWORD[((8+0))+rdi] + adc r12,1 + mov rdx,QWORD[((0+160+0))+rbp] + mov r15,rdx + mulx r14,r13,r10 + mulx rdx,rax,r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rdx,QWORD[((8+160+0))+rbp] + mulx rax,r10,r10 + add r14,r10 + mulx r9,r11,r11 + adc r15,r11 + adc r9,0 + imul rdx,r12 + add r15,rax + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + lea rdi,[16+rdi] +$L$seal_avx2_tail_128_rounds_and_2xhash: + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol16] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpsrld ymm3,ymm4,20 + vpslld ymm4,ymm4,12 + vpxor ymm4,ymm4,ymm3 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol8] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpslld ymm3,ymm4,7 + vpsrld ymm4,ymm4,25 + vpxor ymm4,ymm4,ymm3 + vpalignr ymm12,ymm12,ymm12,12 + vpalignr ymm8,ymm8,ymm8,8 + vpalignr ymm4,ymm4,ymm4,4 + add r10,QWORD[((0+0))+rdi] + adc r11,QWORD[((8+0))+rdi] + adc r12,1 + mov rdx,QWORD[((0+160+0))+rbp] + mov r15,rdx + mulx r14,r13,r10 + mulx rdx,rax,r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rdx,QWORD[((8+160+0))+rbp] + mulx rax,r10,r10 + add r14,r10 + mulx r9,r11,r11 + adc r15,r11 + adc r9,0 + imul rdx,r12 + add r15,rax + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol16] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpsrld ymm3,ymm4,20 + vpslld ymm4,ymm4,12 + vpxor ymm4,ymm4,ymm3 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol8] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpslld ymm3,ymm4,7 + vpsrld ymm4,ymm4,25 + vpxor ymm4,ymm4,ymm3 + vpalignr ymm12,ymm12,ymm12,4 + vpalignr ymm8,ymm8,ymm8,8 + vpalignr ymm4,ymm4,ymm4,12 + add r10,QWORD[((0+16))+rdi] + adc r11,QWORD[((8+16))+rdi] + adc r12,1 + mov rdx,QWORD[((0+160+0))+rbp] + mov r15,rdx + mulx r14,r13,r10 + mulx rdx,rax,r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rdx,QWORD[((8+160+0))+rbp] + mulx rax,r10,r10 + add r14,r10 + mulx r9,r11,r11 + adc r15,r11 + adc r9,0 + imul rdx,r12 + add r15,rax + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + lea rdi,[32+rdi] + dec rcx + jg NEAR $L$seal_avx2_tail_128_rounds_and_3xhash + dec r8 + jge NEAR $L$seal_avx2_tail_128_rounds_and_2xhash + vpaddd ymm0,ymm0,YMMWORD[$L$chacha20_consts] + vpaddd ymm4,ymm4,YMMWORD[((160+64))+rbp] + vpaddd ymm8,ymm8,YMMWORD[((160+96))+rbp] + vpaddd ymm12,ymm12,YMMWORD[((160+160))+rbp] + vperm2i128 ymm3,ymm4,ymm0,0x13 + vperm2i128 ymm0,ymm4,ymm0,0x02 + vperm2i128 ymm4,ymm12,ymm8,0x02 + vperm2i128 ymm12,ymm12,ymm8,0x13 + vmovdqa ymm8,ymm3 + + jmp NEAR $L$seal_avx2_short_loop + +$L$seal_avx2_tail_256: + vmovdqa ymm0,YMMWORD[$L$chacha20_consts] + vmovdqa ymm4,YMMWORD[((160+64))+rbp] + vmovdqa ymm8,YMMWORD[((160+96))+rbp] + vmovdqa ymm1,ymm0 + vmovdqa ymm5,ymm4 + vmovdqa ymm9,ymm8 + vmovdqa ymm12,YMMWORD[$L$avx2_inc] + vpaddd ymm13,ymm12,YMMWORD[((160+160))+rbp] + vpaddd ymm12,ymm12,ymm13 + vmovdqa YMMWORD[(160+160)+rbp],ymm12 + vmovdqa YMMWORD[(160+192)+rbp],ymm13 + +$L$seal_avx2_tail_256_rounds_and_3xhash: + add r10,QWORD[((0+0))+rdi] + adc r11,QWORD[((8+0))+rdi] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + lea rdi,[16+rdi] +$L$seal_avx2_tail_256_rounds_and_2xhash: + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol16] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpsrld ymm3,ymm4,20 + vpslld ymm4,ymm4,12 + vpxor ymm4,ymm4,ymm3 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol8] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpslld ymm3,ymm4,7 + vpsrld ymm4,ymm4,25 + vpxor ymm4,ymm4,ymm3 + vpalignr ymm12,ymm12,ymm12,12 + vpalignr ymm8,ymm8,ymm8,8 + vpalignr ymm4,ymm4,ymm4,4 + vpaddd ymm1,ymm1,ymm5 + vpxor ymm13,ymm13,ymm1 + vpshufb ymm13,ymm13,YMMWORD[$L$rol16] + vpaddd ymm9,ymm9,ymm13 + vpxor ymm5,ymm5,ymm9 + vpsrld ymm3,ymm5,20 + vpslld ymm5,ymm5,12 + vpxor ymm5,ymm5,ymm3 + vpaddd ymm1,ymm1,ymm5 + vpxor ymm13,ymm13,ymm1 + vpshufb ymm13,ymm13,YMMWORD[$L$rol8] + vpaddd ymm9,ymm9,ymm13 + vpxor ymm5,ymm5,ymm9 + vpslld ymm3,ymm5,7 + vpsrld ymm5,ymm5,25 + vpxor ymm5,ymm5,ymm3 + vpalignr ymm13,ymm13,ymm13,12 + vpalignr ymm9,ymm9,ymm9,8 + vpalignr ymm5,ymm5,ymm5,4 + add r10,QWORD[((0+0))+rdi] + adc r11,QWORD[((8+0))+rdi] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol16] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpsrld ymm3,ymm4,20 + vpslld ymm4,ymm4,12 + vpxor ymm4,ymm4,ymm3 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol8] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpslld ymm3,ymm4,7 + vpsrld ymm4,ymm4,25 + vpxor ymm4,ymm4,ymm3 + vpalignr ymm12,ymm12,ymm12,4 + vpalignr ymm8,ymm8,ymm8,8 + vpalignr ymm4,ymm4,ymm4,12 + vpaddd ymm1,ymm1,ymm5 + vpxor ymm13,ymm13,ymm1 + vpshufb ymm13,ymm13,YMMWORD[$L$rol16] + vpaddd ymm9,ymm9,ymm13 + vpxor ymm5,ymm5,ymm9 + vpsrld ymm3,ymm5,20 + vpslld ymm5,ymm5,12 + vpxor ymm5,ymm5,ymm3 + vpaddd ymm1,ymm1,ymm5 + vpxor ymm13,ymm13,ymm1 + vpshufb ymm13,ymm13,YMMWORD[$L$rol8] + vpaddd ymm9,ymm9,ymm13 + vpxor ymm5,ymm5,ymm9 + vpslld ymm3,ymm5,7 + vpsrld ymm5,ymm5,25 + vpxor ymm5,ymm5,ymm3 + vpalignr ymm13,ymm13,ymm13,4 + vpalignr ymm9,ymm9,ymm9,8 + vpalignr ymm5,ymm5,ymm5,12 + add r10,QWORD[((0+16))+rdi] + adc r11,QWORD[((8+16))+rdi] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + lea rdi,[32+rdi] + dec rcx + jg NEAR $L$seal_avx2_tail_256_rounds_and_3xhash + dec r8 + jge NEAR $L$seal_avx2_tail_256_rounds_and_2xhash + vpaddd ymm1,ymm1,YMMWORD[$L$chacha20_consts] + vpaddd ymm5,ymm5,YMMWORD[((160+64))+rbp] + vpaddd ymm9,ymm9,YMMWORD[((160+96))+rbp] + vpaddd ymm13,ymm13,YMMWORD[((160+192))+rbp] + vpaddd ymm0,ymm0,YMMWORD[$L$chacha20_consts] + vpaddd ymm4,ymm4,YMMWORD[((160+64))+rbp] + vpaddd ymm8,ymm8,YMMWORD[((160+96))+rbp] + vpaddd ymm12,ymm12,YMMWORD[((160+160))+rbp] + vperm2i128 ymm3,ymm5,ymm1,0x02 + vperm2i128 ymm5,ymm5,ymm1,0x13 + vperm2i128 ymm1,ymm13,ymm9,0x02 + vperm2i128 ymm9,ymm13,ymm9,0x13 + vpxor ymm3,ymm3,YMMWORD[((0+0))+rsi] + vpxor ymm1,ymm1,YMMWORD[((32+0))+rsi] + vpxor ymm5,ymm5,YMMWORD[((64+0))+rsi] + vpxor ymm9,ymm9,YMMWORD[((96+0))+rsi] + vmovdqu YMMWORD[(0+0)+rdi],ymm3 + vmovdqu YMMWORD[(32+0)+rdi],ymm1 + vmovdqu YMMWORD[(64+0)+rdi],ymm5 + vmovdqu YMMWORD[(96+0)+rdi],ymm9 + vperm2i128 ymm3,ymm4,ymm0,0x13 + vperm2i128 ymm0,ymm4,ymm0,0x02 + vperm2i128 ymm4,ymm12,ymm8,0x02 + vperm2i128 ymm12,ymm12,ymm8,0x13 + vmovdqa ymm8,ymm3 + + mov rcx,4*32 + lea rsi,[128+rsi] + sub rbx,4*32 + jmp NEAR $L$seal_avx2_short_hash_remainder + +$L$seal_avx2_tail_384: + vmovdqa ymm0,YMMWORD[$L$chacha20_consts] + vmovdqa ymm4,YMMWORD[((160+64))+rbp] + vmovdqa ymm8,YMMWORD[((160+96))+rbp] + vmovdqa ymm1,ymm0 + vmovdqa ymm5,ymm4 + vmovdqa ymm9,ymm8 + vmovdqa ymm2,ymm0 + vmovdqa ymm6,ymm4 + vmovdqa ymm10,ymm8 + vmovdqa ymm12,YMMWORD[$L$avx2_inc] + vpaddd ymm14,ymm12,YMMWORD[((160+160))+rbp] + vpaddd ymm13,ymm12,ymm14 + vpaddd ymm12,ymm12,ymm13 + vmovdqa YMMWORD[(160+160)+rbp],ymm12 + vmovdqa YMMWORD[(160+192)+rbp],ymm13 + vmovdqa YMMWORD[(160+224)+rbp],ymm14 + +$L$seal_avx2_tail_384_rounds_and_3xhash: + add r10,QWORD[((0+0))+rdi] + adc r11,QWORD[((8+0))+rdi] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + lea rdi,[16+rdi] +$L$seal_avx2_tail_384_rounds_and_2xhash: + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol16] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpsrld ymm3,ymm4,20 + vpslld ymm4,ymm4,12 + vpxor ymm4,ymm4,ymm3 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol8] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpslld ymm3,ymm4,7 + vpsrld ymm4,ymm4,25 + vpxor ymm4,ymm4,ymm3 + vpalignr ymm12,ymm12,ymm12,12 + vpalignr ymm8,ymm8,ymm8,8 + vpalignr ymm4,ymm4,ymm4,4 + vpaddd ymm1,ymm1,ymm5 + vpxor ymm13,ymm13,ymm1 + vpshufb ymm13,ymm13,YMMWORD[$L$rol16] + vpaddd ymm9,ymm9,ymm13 + vpxor ymm5,ymm5,ymm9 + vpsrld ymm3,ymm5,20 + vpslld ymm5,ymm5,12 + vpxor ymm5,ymm5,ymm3 + vpaddd ymm1,ymm1,ymm5 + vpxor ymm13,ymm13,ymm1 + vpshufb ymm13,ymm13,YMMWORD[$L$rol8] + vpaddd ymm9,ymm9,ymm13 + vpxor ymm5,ymm5,ymm9 + vpslld ymm3,ymm5,7 + vpsrld ymm5,ymm5,25 + vpxor ymm5,ymm5,ymm3 + vpalignr ymm13,ymm13,ymm13,12 + vpalignr ymm9,ymm9,ymm9,8 + vpalignr ymm5,ymm5,ymm5,4 + add r10,QWORD[((0+0))+rdi] + adc r11,QWORD[((8+0))+rdi] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + vpaddd ymm2,ymm2,ymm6 + vpxor ymm14,ymm14,ymm2 + vpshufb ymm14,ymm14,YMMWORD[$L$rol16] + vpaddd ymm10,ymm10,ymm14 + vpxor ymm6,ymm6,ymm10 + vpsrld ymm3,ymm6,20 + vpslld ymm6,ymm6,12 + vpxor ymm6,ymm6,ymm3 + vpaddd ymm2,ymm2,ymm6 + vpxor ymm14,ymm14,ymm2 + vpshufb ymm14,ymm14,YMMWORD[$L$rol8] + vpaddd ymm10,ymm10,ymm14 + vpxor ymm6,ymm6,ymm10 + vpslld ymm3,ymm6,7 + vpsrld ymm6,ymm6,25 + vpxor ymm6,ymm6,ymm3 + vpalignr ymm14,ymm14,ymm14,12 + vpalignr ymm10,ymm10,ymm10,8 + vpalignr ymm6,ymm6,ymm6,4 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol16] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpsrld ymm3,ymm4,20 + vpslld ymm4,ymm4,12 + vpxor ymm4,ymm4,ymm3 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol8] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpslld ymm3,ymm4,7 + vpsrld ymm4,ymm4,25 + vpxor ymm4,ymm4,ymm3 + vpalignr ymm12,ymm12,ymm12,4 + vpalignr ymm8,ymm8,ymm8,8 + vpalignr ymm4,ymm4,ymm4,12 + add r10,QWORD[((0+16))+rdi] + adc r11,QWORD[((8+16))+rdi] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + vpaddd ymm1,ymm1,ymm5 + vpxor ymm13,ymm13,ymm1 + vpshufb ymm13,ymm13,YMMWORD[$L$rol16] + vpaddd ymm9,ymm9,ymm13 + vpxor ymm5,ymm5,ymm9 + vpsrld ymm3,ymm5,20 + vpslld ymm5,ymm5,12 + vpxor ymm5,ymm5,ymm3 + vpaddd ymm1,ymm1,ymm5 + vpxor ymm13,ymm13,ymm1 + vpshufb ymm13,ymm13,YMMWORD[$L$rol8] + vpaddd ymm9,ymm9,ymm13 + vpxor ymm5,ymm5,ymm9 + vpslld ymm3,ymm5,7 + vpsrld ymm5,ymm5,25 + vpxor ymm5,ymm5,ymm3 + vpalignr ymm13,ymm13,ymm13,4 + vpalignr ymm9,ymm9,ymm9,8 + vpalignr ymm5,ymm5,ymm5,12 + vpaddd ymm2,ymm2,ymm6 + vpxor ymm14,ymm14,ymm2 + vpshufb ymm14,ymm14,YMMWORD[$L$rol16] + vpaddd ymm10,ymm10,ymm14 + vpxor ymm6,ymm6,ymm10 + vpsrld ymm3,ymm6,20 + vpslld ymm6,ymm6,12 + vpxor ymm6,ymm6,ymm3 + vpaddd ymm2,ymm2,ymm6 + vpxor ymm14,ymm14,ymm2 + vpshufb ymm14,ymm14,YMMWORD[$L$rol8] + vpaddd ymm10,ymm10,ymm14 + vpxor ymm6,ymm6,ymm10 + vpslld ymm3,ymm6,7 + vpsrld ymm6,ymm6,25 + vpxor ymm6,ymm6,ymm3 + vpalignr ymm14,ymm14,ymm14,4 + vpalignr ymm10,ymm10,ymm10,8 + vpalignr ymm6,ymm6,ymm6,12 + + lea rdi,[32+rdi] + dec rcx + jg NEAR $L$seal_avx2_tail_384_rounds_and_3xhash + dec r8 + jge NEAR $L$seal_avx2_tail_384_rounds_and_2xhash + vpaddd ymm2,ymm2,YMMWORD[$L$chacha20_consts] + vpaddd ymm6,ymm6,YMMWORD[((160+64))+rbp] + vpaddd ymm10,ymm10,YMMWORD[((160+96))+rbp] + vpaddd ymm14,ymm14,YMMWORD[((160+224))+rbp] + vpaddd ymm1,ymm1,YMMWORD[$L$chacha20_consts] + vpaddd ymm5,ymm5,YMMWORD[((160+64))+rbp] + vpaddd ymm9,ymm9,YMMWORD[((160+96))+rbp] + vpaddd ymm13,ymm13,YMMWORD[((160+192))+rbp] + vpaddd ymm0,ymm0,YMMWORD[$L$chacha20_consts] + vpaddd ymm4,ymm4,YMMWORD[((160+64))+rbp] + vpaddd ymm8,ymm8,YMMWORD[((160+96))+rbp] + vpaddd ymm12,ymm12,YMMWORD[((160+160))+rbp] + vperm2i128 ymm3,ymm6,ymm2,0x02 + vperm2i128 ymm6,ymm6,ymm2,0x13 + vperm2i128 ymm2,ymm14,ymm10,0x02 + vperm2i128 ymm10,ymm14,ymm10,0x13 + vpxor ymm3,ymm3,YMMWORD[((0+0))+rsi] + vpxor ymm2,ymm2,YMMWORD[((32+0))+rsi] + vpxor ymm6,ymm6,YMMWORD[((64+0))+rsi] + vpxor ymm10,ymm10,YMMWORD[((96+0))+rsi] + vmovdqu YMMWORD[(0+0)+rdi],ymm3 + vmovdqu YMMWORD[(32+0)+rdi],ymm2 + vmovdqu YMMWORD[(64+0)+rdi],ymm6 + vmovdqu YMMWORD[(96+0)+rdi],ymm10 + vperm2i128 ymm3,ymm5,ymm1,0x02 + vperm2i128 ymm5,ymm5,ymm1,0x13 + vperm2i128 ymm1,ymm13,ymm9,0x02 + vperm2i128 ymm9,ymm13,ymm9,0x13 + vpxor ymm3,ymm3,YMMWORD[((0+128))+rsi] + vpxor ymm1,ymm1,YMMWORD[((32+128))+rsi] + vpxor ymm5,ymm5,YMMWORD[((64+128))+rsi] + vpxor ymm9,ymm9,YMMWORD[((96+128))+rsi] + vmovdqu YMMWORD[(0+128)+rdi],ymm3 + vmovdqu YMMWORD[(32+128)+rdi],ymm1 + vmovdqu YMMWORD[(64+128)+rdi],ymm5 + vmovdqu YMMWORD[(96+128)+rdi],ymm9 + vperm2i128 ymm3,ymm4,ymm0,0x13 + vperm2i128 ymm0,ymm4,ymm0,0x02 + vperm2i128 ymm4,ymm12,ymm8,0x02 + vperm2i128 ymm12,ymm12,ymm8,0x13 + vmovdqa ymm8,ymm3 + + mov rcx,8*32 + lea rsi,[256+rsi] + sub rbx,8*32 + jmp NEAR $L$seal_avx2_short_hash_remainder + +$L$seal_avx2_tail_512: + vmovdqa ymm0,YMMWORD[$L$chacha20_consts] + vmovdqa ymm4,YMMWORD[((160+64))+rbp] + vmovdqa ymm8,YMMWORD[((160+96))+rbp] + vmovdqa ymm1,ymm0 + vmovdqa ymm5,ymm4 + vmovdqa ymm9,ymm8 + vmovdqa ymm2,ymm0 + vmovdqa ymm6,ymm4 + vmovdqa ymm10,ymm8 + vmovdqa ymm3,ymm0 + vmovdqa ymm7,ymm4 + vmovdqa ymm11,ymm8 + vmovdqa ymm12,YMMWORD[$L$avx2_inc] + vpaddd ymm15,ymm12,YMMWORD[((160+160))+rbp] + vpaddd ymm14,ymm12,ymm15 + vpaddd ymm13,ymm12,ymm14 + vpaddd ymm12,ymm12,ymm13 + vmovdqa YMMWORD[(160+256)+rbp],ymm15 + vmovdqa YMMWORD[(160+224)+rbp],ymm14 + vmovdqa YMMWORD[(160+192)+rbp],ymm13 + vmovdqa YMMWORD[(160+160)+rbp],ymm12 + +$L$seal_avx2_tail_512_rounds_and_3xhash: + add r10,QWORD[((0+0))+rdi] + adc r11,QWORD[((8+0))+rdi] + adc r12,1 + mov rdx,QWORD[((0+160+0))+rbp] + mov r15,rdx + mulx r14,r13,r10 + mulx rdx,rax,r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rdx,QWORD[((8+160+0))+rbp] + mulx rax,r10,r10 + add r14,r10 + mulx r9,r11,r11 + adc r15,r11 + adc r9,0 + imul rdx,r12 + add r15,rax + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + lea rdi,[16+rdi] +$L$seal_avx2_tail_512_rounds_and_2xhash: + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vmovdqa ymm8,YMMWORD[$L$rol16] + vpaddd ymm3,ymm3,ymm7 + vpaddd ymm2,ymm2,ymm6 + vpaddd ymm1,ymm1,ymm5 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm15,ymm15,ymm3 + vpxor ymm14,ymm14,ymm2 + vpxor ymm13,ymm13,ymm1 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm15,ymm15,ymm8 + vpshufb ymm14,ymm14,ymm8 + vpshufb ymm13,ymm13,ymm8 + vpshufb ymm12,ymm12,ymm8 + vpaddd ymm11,ymm11,ymm15 + vpaddd ymm10,ymm10,ymm14 + vpaddd ymm9,ymm9,ymm13 + vpaddd ymm8,ymm12,YMMWORD[((160+128))+rbp] + vpxor ymm7,ymm7,ymm11 + vpxor ymm6,ymm6,ymm10 + add r10,QWORD[((0+0))+rdi] + adc r11,QWORD[((8+0))+rdi] + adc r12,1 + vpxor ymm5,ymm5,ymm9 + vpxor ymm4,ymm4,ymm8 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vpsrld ymm8,ymm7,20 + vpslld ymm7,ymm7,32-20 + vpxor ymm7,ymm7,ymm8 + vpsrld ymm8,ymm6,20 + vpslld ymm6,ymm6,32-20 + vpxor ymm6,ymm6,ymm8 + vpsrld ymm8,ymm5,20 + vpslld ymm5,ymm5,32-20 + vpxor ymm5,ymm5,ymm8 + vpsrld ymm8,ymm4,20 + vpslld ymm4,ymm4,32-20 + vpxor ymm4,ymm4,ymm8 + vmovdqa ymm8,YMMWORD[$L$rol8] + vpaddd ymm3,ymm3,ymm7 + vpaddd ymm2,ymm2,ymm6 + vpaddd ymm1,ymm1,ymm5 + vpaddd ymm0,ymm0,ymm4 + mov rdx,QWORD[((0+160+0))+rbp] + mov r15,rdx + mulx r14,r13,r10 + mulx rdx,rax,r11 + imul r15,r12 + add r14,rax + adc r15,rdx + vpxor ymm15,ymm15,ymm3 + vpxor ymm14,ymm14,ymm2 + vpxor ymm13,ymm13,ymm1 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm15,ymm15,ymm8 + vpshufb ymm14,ymm14,ymm8 + vpshufb ymm13,ymm13,ymm8 + vpshufb ymm12,ymm12,ymm8 + vpaddd ymm11,ymm11,ymm15 + vpaddd ymm10,ymm10,ymm14 + vpaddd ymm9,ymm9,ymm13 + vpaddd ymm8,ymm12,YMMWORD[((160+128))+rbp] + vpxor ymm7,ymm7,ymm11 + vpxor ymm6,ymm6,ymm10 + vpxor ymm5,ymm5,ymm9 + vpxor ymm4,ymm4,ymm8 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vpsrld ymm8,ymm7,25 + vpslld ymm7,ymm7,32-25 + vpxor ymm7,ymm7,ymm8 + mov rdx,QWORD[((8+160+0))+rbp] + mulx rax,r10,r10 + add r14,r10 + mulx r9,r11,r11 + adc r15,r11 + adc r9,0 + imul rdx,r12 + vpsrld ymm8,ymm6,25 + vpslld ymm6,ymm6,32-25 + vpxor ymm6,ymm6,ymm8 + vpsrld ymm8,ymm5,25 + vpslld ymm5,ymm5,32-25 + vpxor ymm5,ymm5,ymm8 + vpsrld ymm8,ymm4,25 + vpslld ymm4,ymm4,32-25 + vpxor ymm4,ymm4,ymm8 + vmovdqa ymm8,YMMWORD[((160+128))+rbp] + vpalignr ymm7,ymm7,ymm7,4 + vpalignr ymm11,ymm11,ymm11,8 + vpalignr ymm15,ymm15,ymm15,12 + vpalignr ymm6,ymm6,ymm6,4 + vpalignr ymm10,ymm10,ymm10,8 + vpalignr ymm14,ymm14,ymm14,12 + vpalignr ymm5,ymm5,ymm5,4 + vpalignr ymm9,ymm9,ymm9,8 + vpalignr ymm13,ymm13,ymm13,12 + vpalignr ymm4,ymm4,ymm4,4 + add r15,rax + adc r9,rdx + vpalignr ymm8,ymm8,ymm8,8 + vpalignr ymm12,ymm12,ymm12,12 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vmovdqa ymm8,YMMWORD[$L$rol16] + vpaddd ymm3,ymm3,ymm7 + vpaddd ymm2,ymm2,ymm6 + vpaddd ymm1,ymm1,ymm5 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm15,ymm15,ymm3 + vpxor ymm14,ymm14,ymm2 + vpxor ymm13,ymm13,ymm1 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm15,ymm15,ymm8 + vpshufb ymm14,ymm14,ymm8 + vpshufb ymm13,ymm13,ymm8 + vpshufb ymm12,ymm12,ymm8 + vpaddd ymm11,ymm11,ymm15 + vpaddd ymm10,ymm10,ymm14 + vpaddd ymm9,ymm9,ymm13 + vpaddd ymm8,ymm12,YMMWORD[((160+128))+rbp] + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + vpxor ymm7,ymm7,ymm11 + vpxor ymm6,ymm6,ymm10 + vpxor ymm5,ymm5,ymm9 + vpxor ymm4,ymm4,ymm8 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vpsrld ymm8,ymm7,20 + vpslld ymm7,ymm7,32-20 + vpxor ymm7,ymm7,ymm8 + vpsrld ymm8,ymm6,20 + vpslld ymm6,ymm6,32-20 + vpxor ymm6,ymm6,ymm8 + vpsrld ymm8,ymm5,20 + vpslld ymm5,ymm5,32-20 + vpxor ymm5,ymm5,ymm8 + vpsrld ymm8,ymm4,20 + vpslld ymm4,ymm4,32-20 + vpxor ymm4,ymm4,ymm8 + vmovdqa ymm8,YMMWORD[$L$rol8] + vpaddd ymm3,ymm3,ymm7 + vpaddd ymm2,ymm2,ymm6 + add r10,QWORD[((0+16))+rdi] + adc r11,QWORD[((8+16))+rdi] + adc r12,1 + vpaddd ymm1,ymm1,ymm5 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm15,ymm15,ymm3 + vpxor ymm14,ymm14,ymm2 + vpxor ymm13,ymm13,ymm1 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm15,ymm15,ymm8 + vpshufb ymm14,ymm14,ymm8 + vpshufb ymm13,ymm13,ymm8 + vpshufb ymm12,ymm12,ymm8 + vpaddd ymm11,ymm11,ymm15 + vpaddd ymm10,ymm10,ymm14 + vpaddd ymm9,ymm9,ymm13 + vpaddd ymm8,ymm12,YMMWORD[((160+128))+rbp] + vpxor ymm7,ymm7,ymm11 + vpxor ymm6,ymm6,ymm10 + vpxor ymm5,ymm5,ymm9 + vpxor ymm4,ymm4,ymm8 + vmovdqa YMMWORD[(160+128)+rbp],ymm8 + vpsrld ymm8,ymm7,25 + mov rdx,QWORD[((0+160+0))+rbp] + mov r15,rdx + mulx r14,r13,r10 + mulx rdx,rax,r11 + imul r15,r12 + add r14,rax + adc r15,rdx + vpslld ymm7,ymm7,32-25 + vpxor ymm7,ymm7,ymm8 + vpsrld ymm8,ymm6,25 + vpslld ymm6,ymm6,32-25 + vpxor ymm6,ymm6,ymm8 + vpsrld ymm8,ymm5,25 + vpslld ymm5,ymm5,32-25 + vpxor ymm5,ymm5,ymm8 + vpsrld ymm8,ymm4,25 + vpslld ymm4,ymm4,32-25 + vpxor ymm4,ymm4,ymm8 + vmovdqa ymm8,YMMWORD[((160+128))+rbp] + vpalignr ymm7,ymm7,ymm7,12 + vpalignr ymm11,ymm11,ymm11,8 + vpalignr ymm15,ymm15,ymm15,4 + vpalignr ymm6,ymm6,ymm6,12 + vpalignr ymm10,ymm10,ymm10,8 + vpalignr ymm14,ymm14,ymm14,4 + vpalignr ymm5,ymm5,ymm5,12 + vpalignr ymm9,ymm9,ymm9,8 + mov rdx,QWORD[((8+160+0))+rbp] + mulx rax,r10,r10 + add r14,r10 + mulx r9,r11,r11 + adc r15,r11 + adc r9,0 + imul rdx,r12 + vpalignr ymm13,ymm13,ymm13,4 + vpalignr ymm4,ymm4,ymm4,12 + vpalignr ymm8,ymm8,ymm8,8 + vpalignr ymm12,ymm12,ymm12,4 + + + + + + + + + + + + + + + + + add r15,rax + adc r9,rdx + + + + + + + + + + + + + + + + + + + + + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + lea rdi,[32+rdi] + dec rcx + jg NEAR $L$seal_avx2_tail_512_rounds_and_3xhash + dec r8 + jge NEAR $L$seal_avx2_tail_512_rounds_and_2xhash + vpaddd ymm3,ymm3,YMMWORD[$L$chacha20_consts] + vpaddd ymm7,ymm7,YMMWORD[((160+64))+rbp] + vpaddd ymm11,ymm11,YMMWORD[((160+96))+rbp] + vpaddd ymm15,ymm15,YMMWORD[((160+256))+rbp] + vpaddd ymm2,ymm2,YMMWORD[$L$chacha20_consts] + vpaddd ymm6,ymm6,YMMWORD[((160+64))+rbp] + vpaddd ymm10,ymm10,YMMWORD[((160+96))+rbp] + vpaddd ymm14,ymm14,YMMWORD[((160+224))+rbp] + vpaddd ymm1,ymm1,YMMWORD[$L$chacha20_consts] + vpaddd ymm5,ymm5,YMMWORD[((160+64))+rbp] + vpaddd ymm9,ymm9,YMMWORD[((160+96))+rbp] + vpaddd ymm13,ymm13,YMMWORD[((160+192))+rbp] + vpaddd ymm0,ymm0,YMMWORD[$L$chacha20_consts] + vpaddd ymm4,ymm4,YMMWORD[((160+64))+rbp] + vpaddd ymm8,ymm8,YMMWORD[((160+96))+rbp] + vpaddd ymm12,ymm12,YMMWORD[((160+160))+rbp] + + vmovdqa YMMWORD[(160+128)+rbp],ymm0 + vperm2i128 ymm0,ymm7,ymm3,0x02 + vperm2i128 ymm7,ymm7,ymm3,0x13 + vperm2i128 ymm3,ymm15,ymm11,0x02 + vperm2i128 ymm11,ymm15,ymm11,0x13 + vpxor ymm0,ymm0,YMMWORD[((0+0))+rsi] + vpxor ymm3,ymm3,YMMWORD[((32+0))+rsi] + vpxor ymm7,ymm7,YMMWORD[((64+0))+rsi] + vpxor ymm11,ymm11,YMMWORD[((96+0))+rsi] + vmovdqu YMMWORD[(0+0)+rdi],ymm0 + vmovdqu YMMWORD[(32+0)+rdi],ymm3 + vmovdqu YMMWORD[(64+0)+rdi],ymm7 + vmovdqu YMMWORD[(96+0)+rdi],ymm11 + + vmovdqa ymm0,YMMWORD[((160+128))+rbp] + vperm2i128 ymm3,ymm6,ymm2,0x02 + vperm2i128 ymm6,ymm6,ymm2,0x13 + vperm2i128 ymm2,ymm14,ymm10,0x02 + vperm2i128 ymm10,ymm14,ymm10,0x13 + vpxor ymm3,ymm3,YMMWORD[((0+128))+rsi] + vpxor ymm2,ymm2,YMMWORD[((32+128))+rsi] + vpxor ymm6,ymm6,YMMWORD[((64+128))+rsi] + vpxor ymm10,ymm10,YMMWORD[((96+128))+rsi] + vmovdqu YMMWORD[(0+128)+rdi],ymm3 + vmovdqu YMMWORD[(32+128)+rdi],ymm2 + vmovdqu YMMWORD[(64+128)+rdi],ymm6 + vmovdqu YMMWORD[(96+128)+rdi],ymm10 + vperm2i128 ymm3,ymm5,ymm1,0x02 + vperm2i128 ymm5,ymm5,ymm1,0x13 + vperm2i128 ymm1,ymm13,ymm9,0x02 + vperm2i128 ymm9,ymm13,ymm9,0x13 + vpxor ymm3,ymm3,YMMWORD[((0+256))+rsi] + vpxor ymm1,ymm1,YMMWORD[((32+256))+rsi] + vpxor ymm5,ymm5,YMMWORD[((64+256))+rsi] + vpxor ymm9,ymm9,YMMWORD[((96+256))+rsi] + vmovdqu YMMWORD[(0+256)+rdi],ymm3 + vmovdqu YMMWORD[(32+256)+rdi],ymm1 + vmovdqu YMMWORD[(64+256)+rdi],ymm5 + vmovdqu YMMWORD[(96+256)+rdi],ymm9 + vperm2i128 ymm3,ymm4,ymm0,0x13 + vperm2i128 ymm0,ymm4,ymm0,0x02 + vperm2i128 ymm4,ymm12,ymm8,0x02 + vperm2i128 ymm12,ymm12,ymm8,0x13 + vmovdqa ymm8,ymm3 + + mov rcx,12*32 + lea rsi,[384+rsi] + sub rbx,12*32 + jmp NEAR $L$seal_avx2_short_hash_remainder + +$L$seal_avx2_320: + vmovdqa ymm1,ymm0 + vmovdqa ymm2,ymm0 + vmovdqa ymm5,ymm4 + vmovdqa ymm6,ymm4 + vmovdqa ymm9,ymm8 + vmovdqa ymm10,ymm8 + vpaddd ymm13,ymm12,YMMWORD[$L$avx2_inc] + vpaddd ymm14,ymm13,YMMWORD[$L$avx2_inc] + vmovdqa ymm7,ymm4 + vmovdqa ymm11,ymm8 + vmovdqa YMMWORD[(160+160)+rbp],ymm12 + vmovdqa YMMWORD[(160+192)+rbp],ymm13 + vmovdqa YMMWORD[(160+224)+rbp],ymm14 + mov r10,10 +$L$seal_avx2_320_rounds: + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol16] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpsrld ymm3,ymm4,20 + vpslld ymm4,ymm4,12 + vpxor ymm4,ymm4,ymm3 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol8] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpslld ymm3,ymm4,7 + vpsrld ymm4,ymm4,25 + vpxor ymm4,ymm4,ymm3 + vpalignr ymm12,ymm12,ymm12,12 + vpalignr ymm8,ymm8,ymm8,8 + vpalignr ymm4,ymm4,ymm4,4 + vpaddd ymm1,ymm1,ymm5 + vpxor ymm13,ymm13,ymm1 + vpshufb ymm13,ymm13,YMMWORD[$L$rol16] + vpaddd ymm9,ymm9,ymm13 + vpxor ymm5,ymm5,ymm9 + vpsrld ymm3,ymm5,20 + vpslld ymm5,ymm5,12 + vpxor ymm5,ymm5,ymm3 + vpaddd ymm1,ymm1,ymm5 + vpxor ymm13,ymm13,ymm1 + vpshufb ymm13,ymm13,YMMWORD[$L$rol8] + vpaddd ymm9,ymm9,ymm13 + vpxor ymm5,ymm5,ymm9 + vpslld ymm3,ymm5,7 + vpsrld ymm5,ymm5,25 + vpxor ymm5,ymm5,ymm3 + vpalignr ymm13,ymm13,ymm13,12 + vpalignr ymm9,ymm9,ymm9,8 + vpalignr ymm5,ymm5,ymm5,4 + vpaddd ymm2,ymm2,ymm6 + vpxor ymm14,ymm14,ymm2 + vpshufb ymm14,ymm14,YMMWORD[$L$rol16] + vpaddd ymm10,ymm10,ymm14 + vpxor ymm6,ymm6,ymm10 + vpsrld ymm3,ymm6,20 + vpslld ymm6,ymm6,12 + vpxor ymm6,ymm6,ymm3 + vpaddd ymm2,ymm2,ymm6 + vpxor ymm14,ymm14,ymm2 + vpshufb ymm14,ymm14,YMMWORD[$L$rol8] + vpaddd ymm10,ymm10,ymm14 + vpxor ymm6,ymm6,ymm10 + vpslld ymm3,ymm6,7 + vpsrld ymm6,ymm6,25 + vpxor ymm6,ymm6,ymm3 + vpalignr ymm14,ymm14,ymm14,12 + vpalignr ymm10,ymm10,ymm10,8 + vpalignr ymm6,ymm6,ymm6,4 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol16] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpsrld ymm3,ymm4,20 + vpslld ymm4,ymm4,12 + vpxor ymm4,ymm4,ymm3 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol8] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpslld ymm3,ymm4,7 + vpsrld ymm4,ymm4,25 + vpxor ymm4,ymm4,ymm3 + vpalignr ymm12,ymm12,ymm12,4 + vpalignr ymm8,ymm8,ymm8,8 + vpalignr ymm4,ymm4,ymm4,12 + vpaddd ymm1,ymm1,ymm5 + vpxor ymm13,ymm13,ymm1 + vpshufb ymm13,ymm13,YMMWORD[$L$rol16] + vpaddd ymm9,ymm9,ymm13 + vpxor ymm5,ymm5,ymm9 + vpsrld ymm3,ymm5,20 + vpslld ymm5,ymm5,12 + vpxor ymm5,ymm5,ymm3 + vpaddd ymm1,ymm1,ymm5 + vpxor ymm13,ymm13,ymm1 + vpshufb ymm13,ymm13,YMMWORD[$L$rol8] + vpaddd ymm9,ymm9,ymm13 + vpxor ymm5,ymm5,ymm9 + vpslld ymm3,ymm5,7 + vpsrld ymm5,ymm5,25 + vpxor ymm5,ymm5,ymm3 + vpalignr ymm13,ymm13,ymm13,4 + vpalignr ymm9,ymm9,ymm9,8 + vpalignr ymm5,ymm5,ymm5,12 + vpaddd ymm2,ymm2,ymm6 + vpxor ymm14,ymm14,ymm2 + vpshufb ymm14,ymm14,YMMWORD[$L$rol16] + vpaddd ymm10,ymm10,ymm14 + vpxor ymm6,ymm6,ymm10 + vpsrld ymm3,ymm6,20 + vpslld ymm6,ymm6,12 + vpxor ymm6,ymm6,ymm3 + vpaddd ymm2,ymm2,ymm6 + vpxor ymm14,ymm14,ymm2 + vpshufb ymm14,ymm14,YMMWORD[$L$rol8] + vpaddd ymm10,ymm10,ymm14 + vpxor ymm6,ymm6,ymm10 + vpslld ymm3,ymm6,7 + vpsrld ymm6,ymm6,25 + vpxor ymm6,ymm6,ymm3 + vpalignr ymm14,ymm14,ymm14,4 + vpalignr ymm10,ymm10,ymm10,8 + vpalignr ymm6,ymm6,ymm6,12 + + dec r10 + jne NEAR $L$seal_avx2_320_rounds + vpaddd ymm0,ymm0,YMMWORD[$L$chacha20_consts] + vpaddd ymm1,ymm1,YMMWORD[$L$chacha20_consts] + vpaddd ymm2,ymm2,YMMWORD[$L$chacha20_consts] + vpaddd ymm4,ymm4,ymm7 + vpaddd ymm5,ymm5,ymm7 + vpaddd ymm6,ymm6,ymm7 + vpaddd ymm8,ymm8,ymm11 + vpaddd ymm9,ymm9,ymm11 + vpaddd ymm10,ymm10,ymm11 + vpaddd ymm12,ymm12,YMMWORD[((160+160))+rbp] + vpaddd ymm13,ymm13,YMMWORD[((160+192))+rbp] + vpaddd ymm14,ymm14,YMMWORD[((160+224))+rbp] + vperm2i128 ymm3,ymm4,ymm0,0x02 + + vpand ymm3,ymm3,YMMWORD[$L$clamp] + vmovdqa YMMWORD[(160+0)+rbp],ymm3 + + vperm2i128 ymm0,ymm4,ymm0,0x13 + vperm2i128 ymm4,ymm12,ymm8,0x13 + vperm2i128 ymm8,ymm5,ymm1,0x02 + vperm2i128 ymm12,ymm13,ymm9,0x02 + vperm2i128 ymm1,ymm5,ymm1,0x13 + vperm2i128 ymm5,ymm13,ymm9,0x13 + vperm2i128 ymm9,ymm6,ymm2,0x02 + vperm2i128 ymm13,ymm14,ymm10,0x02 + vperm2i128 ymm2,ymm6,ymm2,0x13 + vperm2i128 ymm6,ymm14,ymm10,0x13 + jmp NEAR $L$seal_avx2_short + +$L$seal_avx2_192: + vmovdqa ymm1,ymm0 + vmovdqa ymm2,ymm0 + vmovdqa ymm5,ymm4 + vmovdqa ymm6,ymm4 + vmovdqa ymm9,ymm8 + vmovdqa ymm10,ymm8 + vpaddd ymm13,ymm12,YMMWORD[$L$avx2_inc] + vmovdqa ymm11,ymm12 + vmovdqa ymm15,ymm13 + mov r10,10 +$L$seal_avx2_192_rounds: + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol16] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpsrld ymm3,ymm4,20 + vpslld ymm4,ymm4,12 + vpxor ymm4,ymm4,ymm3 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol8] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpslld ymm3,ymm4,7 + vpsrld ymm4,ymm4,25 + vpxor ymm4,ymm4,ymm3 + vpalignr ymm12,ymm12,ymm12,12 + vpalignr ymm8,ymm8,ymm8,8 + vpalignr ymm4,ymm4,ymm4,4 + vpaddd ymm1,ymm1,ymm5 + vpxor ymm13,ymm13,ymm1 + vpshufb ymm13,ymm13,YMMWORD[$L$rol16] + vpaddd ymm9,ymm9,ymm13 + vpxor ymm5,ymm5,ymm9 + vpsrld ymm3,ymm5,20 + vpslld ymm5,ymm5,12 + vpxor ymm5,ymm5,ymm3 + vpaddd ymm1,ymm1,ymm5 + vpxor ymm13,ymm13,ymm1 + vpshufb ymm13,ymm13,YMMWORD[$L$rol8] + vpaddd ymm9,ymm9,ymm13 + vpxor ymm5,ymm5,ymm9 + vpslld ymm3,ymm5,7 + vpsrld ymm5,ymm5,25 + vpxor ymm5,ymm5,ymm3 + vpalignr ymm13,ymm13,ymm13,12 + vpalignr ymm9,ymm9,ymm9,8 + vpalignr ymm5,ymm5,ymm5,4 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol16] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpsrld ymm3,ymm4,20 + vpslld ymm4,ymm4,12 + vpxor ymm4,ymm4,ymm3 + vpaddd ymm0,ymm0,ymm4 + vpxor ymm12,ymm12,ymm0 + vpshufb ymm12,ymm12,YMMWORD[$L$rol8] + vpaddd ymm8,ymm8,ymm12 + vpxor ymm4,ymm4,ymm8 + vpslld ymm3,ymm4,7 + vpsrld ymm4,ymm4,25 + vpxor ymm4,ymm4,ymm3 + vpalignr ymm12,ymm12,ymm12,4 + vpalignr ymm8,ymm8,ymm8,8 + vpalignr ymm4,ymm4,ymm4,12 + vpaddd ymm1,ymm1,ymm5 + vpxor ymm13,ymm13,ymm1 + vpshufb ymm13,ymm13,YMMWORD[$L$rol16] + vpaddd ymm9,ymm9,ymm13 + vpxor ymm5,ymm5,ymm9 + vpsrld ymm3,ymm5,20 + vpslld ymm5,ymm5,12 + vpxor ymm5,ymm5,ymm3 + vpaddd ymm1,ymm1,ymm5 + vpxor ymm13,ymm13,ymm1 + vpshufb ymm13,ymm13,YMMWORD[$L$rol8] + vpaddd ymm9,ymm9,ymm13 + vpxor ymm5,ymm5,ymm9 + vpslld ymm3,ymm5,7 + vpsrld ymm5,ymm5,25 + vpxor ymm5,ymm5,ymm3 + vpalignr ymm13,ymm13,ymm13,4 + vpalignr ymm9,ymm9,ymm9,8 + vpalignr ymm5,ymm5,ymm5,12 + + dec r10 + jne NEAR $L$seal_avx2_192_rounds + vpaddd ymm0,ymm0,ymm2 + vpaddd ymm1,ymm1,ymm2 + vpaddd ymm4,ymm4,ymm6 + vpaddd ymm5,ymm5,ymm6 + vpaddd ymm8,ymm8,ymm10 + vpaddd ymm9,ymm9,ymm10 + vpaddd ymm12,ymm12,ymm11 + vpaddd ymm13,ymm13,ymm15 + vperm2i128 ymm3,ymm4,ymm0,0x02 + + vpand ymm3,ymm3,YMMWORD[$L$clamp] + vmovdqa YMMWORD[(160+0)+rbp],ymm3 + + vperm2i128 ymm0,ymm4,ymm0,0x13 + vperm2i128 ymm4,ymm12,ymm8,0x13 + vperm2i128 ymm8,ymm5,ymm1,0x02 + vperm2i128 ymm12,ymm13,ymm9,0x02 + vperm2i128 ymm1,ymm5,ymm1,0x13 + vperm2i128 ymm5,ymm13,ymm9,0x13 +$L$seal_avx2_short: + mov r8,r8 + call poly_hash_ad_internal + xor rcx,rcx +$L$seal_avx2_short_hash_remainder: + cmp rcx,16 + jb NEAR $L$seal_avx2_short_loop + add r10,QWORD[((0+0))+rdi] + adc r11,QWORD[((8+0))+rdi] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + sub rcx,16 + add rdi,16 + jmp NEAR $L$seal_avx2_short_hash_remainder +$L$seal_avx2_short_loop: + cmp rbx,32 + jb NEAR $L$seal_avx2_short_tail + sub rbx,32 + + vpxor ymm0,ymm0,YMMWORD[rsi] + vmovdqu YMMWORD[rdi],ymm0 + lea rsi,[32+rsi] + + add r10,QWORD[((0+0))+rdi] + adc r11,QWORD[((8+0))+rdi] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + add r10,QWORD[((0+16))+rdi] + adc r11,QWORD[((8+16))+rdi] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + lea rdi,[32+rdi] + + vmovdqa ymm0,ymm4 + vmovdqa ymm4,ymm8 + vmovdqa ymm8,ymm12 + vmovdqa ymm12,ymm1 + vmovdqa ymm1,ymm5 + vmovdqa ymm5,ymm9 + vmovdqa ymm9,ymm13 + vmovdqa ymm13,ymm2 + vmovdqa ymm2,ymm6 + jmp NEAR $L$seal_avx2_short_loop +$L$seal_avx2_short_tail: + cmp rbx,16 + jb NEAR $L$seal_avx2_exit + sub rbx,16 + vpxor xmm3,xmm0,XMMWORD[rsi] + vmovdqu XMMWORD[rdi],xmm3 + lea rsi,[16+rsi] + add r10,QWORD[((0+0))+rdi] + adc r11,QWORD[((8+0))+rdi] + adc r12,1 + mov rax,QWORD[((0+160+0))+rbp] + mov r15,rax + mul r10 + mov r13,rax + mov r14,rdx + mov rax,QWORD[((0+160+0))+rbp] + mul r11 + imul r15,r12 + add r14,rax + adc r15,rdx + mov rax,QWORD[((8+160+0))+rbp] + mov r9,rax + mul r10 + add r14,rax + adc rdx,0 + mov r10,rdx + mov rax,QWORD[((8+160+0))+rbp] + mul r11 + add r15,rax + adc rdx,0 + imul r9,r12 + add r15,r10 + adc r9,rdx + mov r10,r13 + mov r11,r14 + mov r12,r15 + and r12,3 + mov r13,r15 + and r13,-4 + mov r14,r9 + shrd r15,r9,2 + shr r9,2 + add r15,r13 + adc r9,r14 + add r10,r15 + adc r11,r9 + adc r12,0 + + lea rdi,[16+rdi] + vextracti128 xmm0,ymm0,1 +$L$seal_avx2_exit: + vzeroupper + jmp NEAR $L$seal_sse_tail_16 + +$L$SEH_end_chacha20_poly1305_seal_avx2: +%else +; Work around https://bugzilla.nasm.us/show_bug.cgi?id=3392738 +ret +%endif diff --git a/http/vendor/ring/pregenerated/chacha20_poly1305_x86_64-nasm.o b/http/vendor/ring/pregenerated/chacha20_poly1305_x86_64-nasm.o new file mode 100644 index 0000000..08c6c5d Binary files /dev/null and b/http/vendor/ring/pregenerated/chacha20_poly1305_x86_64-nasm.o differ diff --git a/http/vendor/ring/pregenerated/ghash-armv4-linux32.S b/http/vendor/ring/pregenerated/ghash-armv4-linux32.S new file mode 100644 index 0000000..1209e5e --- /dev/null +++ b/http/vendor/ring/pregenerated/ghash-armv4-linux32.S @@ -0,0 +1,242 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_ARM) && defined(__ELF__) +@ Silence ARMv8 deprecated IT instruction warnings. This file is used by both +@ ARMv7 and ARMv8 processors and does not use ARMv8 instructions. (ARMv8 PMULL +@ instructions are in aesv8-armx.pl.) +.arch armv7-a + +.text +#if defined(__thumb2__) || defined(__clang__) +.syntax unified +#define ldrplb ldrbpl +#define ldrneb ldrbne +#endif +#if defined(__thumb2__) +.thumb +#else +.code 32 +#endif +#if __ARM_MAX_ARCH__>=7 +.arch armv7-a +.fpu neon + +.globl gcm_init_neon +.hidden gcm_init_neon +.type gcm_init_neon,%function +.align 4 +gcm_init_neon: + vld1.64 d7,[r1]! @ load H + vmov.i8 q8,#0xe1 + vld1.64 d6,[r1] + vshl.i64 d17,#57 + vshr.u64 d16,#63 @ t0=0xc2....01 + vdup.8 q9,d7[7] + vshr.u64 d26,d6,#63 + vshr.s8 q9,#7 @ broadcast carry bit + vshl.i64 q3,q3,#1 + vand q8,q8,q9 + vorr d7,d26 @ H<<<=1 + veor q3,q3,q8 @ twisted H + vstmia r0,{q3} + + bx lr @ bx lr +.size gcm_init_neon,.-gcm_init_neon + +.globl gcm_gmult_neon +.hidden gcm_gmult_neon +.type gcm_gmult_neon,%function +.align 4 +gcm_gmult_neon: + vld1.64 d7,[r0]! @ load Xi + vld1.64 d6,[r0]! + vmov.i64 d29,#0x0000ffffffffffff + vldmia r1,{d26,d27} @ load twisted H + vmov.i64 d30,#0x00000000ffffffff +#ifdef __ARMEL__ + vrev64.8 q3,q3 +#endif + vmov.i64 d31,#0x000000000000ffff + veor d28,d26,d27 @ Karatsuba pre-processing + mov r3,#16 + b .Lgmult_neon +.size gcm_gmult_neon,.-gcm_gmult_neon + +.globl gcm_ghash_neon +.hidden gcm_ghash_neon +.type gcm_ghash_neon,%function +.align 4 +gcm_ghash_neon: + vld1.64 d1,[r0]! @ load Xi + vld1.64 d0,[r0]! + vmov.i64 d29,#0x0000ffffffffffff + vldmia r1,{d26,d27} @ load twisted H + vmov.i64 d30,#0x00000000ffffffff +#ifdef __ARMEL__ + vrev64.8 q0,q0 +#endif + vmov.i64 d31,#0x000000000000ffff + veor d28,d26,d27 @ Karatsuba pre-processing + +.Loop_neon: + vld1.64 d7,[r2]! @ load inp + vld1.64 d6,[r2]! +#ifdef __ARMEL__ + vrev64.8 q3,q3 +#endif + veor q3,q0 @ inp^=Xi +.Lgmult_neon: + vext.8 d16, d26, d26, #1 @ A1 + vmull.p8 q8, d16, d6 @ F = A1*B + vext.8 d0, d6, d6, #1 @ B1 + vmull.p8 q0, d26, d0 @ E = A*B1 + vext.8 d18, d26, d26, #2 @ A2 + vmull.p8 q9, d18, d6 @ H = A2*B + vext.8 d22, d6, d6, #2 @ B2 + vmull.p8 q11, d26, d22 @ G = A*B2 + vext.8 d20, d26, d26, #3 @ A3 + veor q8, q8, q0 @ L = E + F + vmull.p8 q10, d20, d6 @ J = A3*B + vext.8 d0, d6, d6, #3 @ B3 + veor q9, q9, q11 @ M = G + H + vmull.p8 q0, d26, d0 @ I = A*B3 + veor d16, d16, d17 @ t0 = (L) (P0 + P1) << 8 + vand d17, d17, d29 + vext.8 d22, d6, d6, #4 @ B4 + veor d18, d18, d19 @ t1 = (M) (P2 + P3) << 16 + vand d19, d19, d30 + vmull.p8 q11, d26, d22 @ K = A*B4 + veor q10, q10, q0 @ N = I + J + veor d16, d16, d17 + veor d18, d18, d19 + veor d20, d20, d21 @ t2 = (N) (P4 + P5) << 24 + vand d21, d21, d31 + vext.8 q8, q8, q8, #15 + veor d22, d22, d23 @ t3 = (K) (P6 + P7) << 32 + vmov.i64 d23, #0 + vext.8 q9, q9, q9, #14 + veor d20, d20, d21 + vmull.p8 q0, d26, d6 @ D = A*B + vext.8 q11, q11, q11, #12 + vext.8 q10, q10, q10, #13 + veor q8, q8, q9 + veor q10, q10, q11 + veor q0, q0, q8 + veor q0, q0, q10 + veor d6,d6,d7 @ Karatsuba pre-processing + vext.8 d16, d28, d28, #1 @ A1 + vmull.p8 q8, d16, d6 @ F = A1*B + vext.8 d2, d6, d6, #1 @ B1 + vmull.p8 q1, d28, d2 @ E = A*B1 + vext.8 d18, d28, d28, #2 @ A2 + vmull.p8 q9, d18, d6 @ H = A2*B + vext.8 d22, d6, d6, #2 @ B2 + vmull.p8 q11, d28, d22 @ G = A*B2 + vext.8 d20, d28, d28, #3 @ A3 + veor q8, q8, q1 @ L = E + F + vmull.p8 q10, d20, d6 @ J = A3*B + vext.8 d2, d6, d6, #3 @ B3 + veor q9, q9, q11 @ M = G + H + vmull.p8 q1, d28, d2 @ I = A*B3 + veor d16, d16, d17 @ t0 = (L) (P0 + P1) << 8 + vand d17, d17, d29 + vext.8 d22, d6, d6, #4 @ B4 + veor d18, d18, d19 @ t1 = (M) (P2 + P3) << 16 + vand d19, d19, d30 + vmull.p8 q11, d28, d22 @ K = A*B4 + veor q10, q10, q1 @ N = I + J + veor d16, d16, d17 + veor d18, d18, d19 + veor d20, d20, d21 @ t2 = (N) (P4 + P5) << 24 + vand d21, d21, d31 + vext.8 q8, q8, q8, #15 + veor d22, d22, d23 @ t3 = (K) (P6 + P7) << 32 + vmov.i64 d23, #0 + vext.8 q9, q9, q9, #14 + veor d20, d20, d21 + vmull.p8 q1, d28, d6 @ D = A*B + vext.8 q11, q11, q11, #12 + vext.8 q10, q10, q10, #13 + veor q8, q8, q9 + veor q10, q10, q11 + veor q1, q1, q8 + veor q1, q1, q10 + vext.8 d16, d27, d27, #1 @ A1 + vmull.p8 q8, d16, d7 @ F = A1*B + vext.8 d4, d7, d7, #1 @ B1 + vmull.p8 q2, d27, d4 @ E = A*B1 + vext.8 d18, d27, d27, #2 @ A2 + vmull.p8 q9, d18, d7 @ H = A2*B + vext.8 d22, d7, d7, #2 @ B2 + vmull.p8 q11, d27, d22 @ G = A*B2 + vext.8 d20, d27, d27, #3 @ A3 + veor q8, q8, q2 @ L = E + F + vmull.p8 q10, d20, d7 @ J = A3*B + vext.8 d4, d7, d7, #3 @ B3 + veor q9, q9, q11 @ M = G + H + vmull.p8 q2, d27, d4 @ I = A*B3 + veor d16, d16, d17 @ t0 = (L) (P0 + P1) << 8 + vand d17, d17, d29 + vext.8 d22, d7, d7, #4 @ B4 + veor d18, d18, d19 @ t1 = (M) (P2 + P3) << 16 + vand d19, d19, d30 + vmull.p8 q11, d27, d22 @ K = A*B4 + veor q10, q10, q2 @ N = I + J + veor d16, d16, d17 + veor d18, d18, d19 + veor d20, d20, d21 @ t2 = (N) (P4 + P5) << 24 + vand d21, d21, d31 + vext.8 q8, q8, q8, #15 + veor d22, d22, d23 @ t3 = (K) (P6 + P7) << 32 + vmov.i64 d23, #0 + vext.8 q9, q9, q9, #14 + veor d20, d20, d21 + vmull.p8 q2, d27, d7 @ D = A*B + vext.8 q11, q11, q11, #12 + vext.8 q10, q10, q10, #13 + veor q8, q8, q9 + veor q10, q10, q11 + veor q2, q2, q8 + veor q2, q2, q10 + veor q1,q1,q0 @ Karatsuba post-processing + veor q1,q1,q2 + veor d1,d1,d2 + veor d4,d4,d3 @ Xh|Xl - 256-bit result + + @ equivalent of reduction_avx from ghash-x86_64.pl + vshl.i64 q9,q0,#57 @ 1st phase + vshl.i64 q10,q0,#62 + veor q10,q10,q9 @ + vshl.i64 q9,q0,#63 + veor q10, q10, q9 @ + veor d1,d1,d20 @ + veor d4,d4,d21 + + vshr.u64 q10,q0,#1 @ 2nd phase + veor q2,q2,q0 + veor q0,q0,q10 @ + vshr.u64 q10,q10,#6 + vshr.u64 q0,q0,#1 @ + veor q0,q0,q2 @ + veor q0,q0,q10 @ + + subs r3,#16 + bne .Loop_neon + +#ifdef __ARMEL__ + vrev64.8 q0,q0 +#endif + sub r0,#16 + vst1.64 d1,[r0]! @ write out Xi + vst1.64 d0,[r0] + + bx lr @ bx lr +.size gcm_ghash_neon,.-gcm_ghash_neon +#endif +.byte 71,72,65,83,72,32,102,111,114,32,65,82,77,118,52,47,78,69,79,78,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.align 2 +.align 2 +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_ARM) && defined(__ELF__) diff --git a/http/vendor/ring/pregenerated/ghash-neon-armv8-ios64.S b/http/vendor/ring/pregenerated/ghash-neon-armv8-ios64.S new file mode 100644 index 0000000..790cf2f --- /dev/null +++ b/http/vendor/ring/pregenerated/ghash-neon-armv8-ios64.S @@ -0,0 +1,333 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__APPLE__) +.text + +.globl _gcm_init_neon +.private_extern _gcm_init_neon + +.align 4 +_gcm_init_neon: + AARCH64_VALID_CALL_TARGET + // This function is adapted from gcm_init_v8. xC2 is t3. + ld1 {v17.2d}, [x1] // load H + movi v19.16b, #0xe1 + shl v19.2d, v19.2d, #57 // 0xc2.0 + ext v3.16b, v17.16b, v17.16b, #8 + ushr v18.2d, v19.2d, #63 + dup v17.4s, v17.s[1] + ext v16.16b, v18.16b, v19.16b, #8 // t0=0xc2....01 + ushr v18.2d, v3.2d, #63 + sshr v17.4s, v17.4s, #31 // broadcast carry bit + and v18.16b, v18.16b, v16.16b + shl v3.2d, v3.2d, #1 + ext v18.16b, v18.16b, v18.16b, #8 + and v16.16b, v16.16b, v17.16b + orr v3.16b, v3.16b, v18.16b // H<<<=1 + eor v5.16b, v3.16b, v16.16b // twisted H + st1 {v5.2d}, [x0] // store Htable[0] + ret + + +.globl _gcm_gmult_neon +.private_extern _gcm_gmult_neon + +.align 4 +_gcm_gmult_neon: + AARCH64_VALID_CALL_TARGET + ld1 {v3.16b}, [x0] // load Xi + ld1 {v5.1d}, [x1], #8 // load twisted H + ld1 {v6.1d}, [x1] + adrp x9, Lmasks@PAGE // load constants + add x9, x9, Lmasks@PAGEOFF + ld1 {v24.2d, v25.2d}, [x9] + rev64 v3.16b, v3.16b // byteswap Xi + ext v3.16b, v3.16b, v3.16b, #8 + eor v7.8b, v5.8b, v6.8b // Karatsuba pre-processing + + mov x3, #16 + b Lgmult_neon + + +.globl _gcm_ghash_neon +.private_extern _gcm_ghash_neon + +.align 4 +_gcm_ghash_neon: + AARCH64_VALID_CALL_TARGET + ld1 {v0.16b}, [x0] // load Xi + ld1 {v5.1d}, [x1], #8 // load twisted H + ld1 {v6.1d}, [x1] + adrp x9, Lmasks@PAGE // load constants + add x9, x9, Lmasks@PAGEOFF + ld1 {v24.2d, v25.2d}, [x9] + rev64 v0.16b, v0.16b // byteswap Xi + ext v0.16b, v0.16b, v0.16b, #8 + eor v7.8b, v5.8b, v6.8b // Karatsuba pre-processing + +Loop_neon: + ld1 {v3.16b}, [x2], #16 // load inp + rev64 v3.16b, v3.16b // byteswap inp + ext v3.16b, v3.16b, v3.16b, #8 + eor v3.16b, v3.16b, v0.16b // inp ^= Xi + +Lgmult_neon: + // Split the input into v3 and v4. (The upper halves are unused, + // so it is okay to leave them alone.) + ins v4.d[0], v3.d[1] + ext v16.8b, v5.8b, v5.8b, #1 // A1 + pmull v16.8h, v16.8b, v3.8b // F = A1*B + ext v0.8b, v3.8b, v3.8b, #1 // B1 + pmull v0.8h, v5.8b, v0.8b // E = A*B1 + ext v17.8b, v5.8b, v5.8b, #2 // A2 + pmull v17.8h, v17.8b, v3.8b // H = A2*B + ext v19.8b, v3.8b, v3.8b, #2 // B2 + pmull v19.8h, v5.8b, v19.8b // G = A*B2 + ext v18.8b, v5.8b, v5.8b, #3 // A3 + eor v16.16b, v16.16b, v0.16b // L = E + F + pmull v18.8h, v18.8b, v3.8b // J = A3*B + ext v0.8b, v3.8b, v3.8b, #3 // B3 + eor v17.16b, v17.16b, v19.16b // M = G + H + pmull v0.8h, v5.8b, v0.8b // I = A*B3 + + // Here we diverge from the 32-bit version. It computes the following + // (instructions reordered for clarity): + // + // veor $t0#lo, $t0#lo, $t0#hi @ t0 = P0 + P1 (L) + // vand $t0#hi, $t0#hi, $k48 + // veor $t0#lo, $t0#lo, $t0#hi + // + // veor $t1#lo, $t1#lo, $t1#hi @ t1 = P2 + P3 (M) + // vand $t1#hi, $t1#hi, $k32 + // veor $t1#lo, $t1#lo, $t1#hi + // + // veor $t2#lo, $t2#lo, $t2#hi @ t2 = P4 + P5 (N) + // vand $t2#hi, $t2#hi, $k16 + // veor $t2#lo, $t2#lo, $t2#hi + // + // veor $t3#lo, $t3#lo, $t3#hi @ t3 = P6 + P7 (K) + // vmov.i64 $t3#hi, #0 + // + // $kN is a mask with the bottom N bits set. AArch64 cannot compute on + // upper halves of SIMD registers, so we must split each half into + // separate registers. To compensate, we pair computations up and + // parallelize. + + ext v19.8b, v3.8b, v3.8b, #4 // B4 + eor v18.16b, v18.16b, v0.16b // N = I + J + pmull v19.8h, v5.8b, v19.8b // K = A*B4 + + // This can probably be scheduled more efficiently. For now, we just + // pair up independent instructions. + zip1 v20.2d, v16.2d, v17.2d + zip1 v22.2d, v18.2d, v19.2d + zip2 v21.2d, v16.2d, v17.2d + zip2 v23.2d, v18.2d, v19.2d + eor v20.16b, v20.16b, v21.16b + eor v22.16b, v22.16b, v23.16b + and v21.16b, v21.16b, v24.16b + and v23.16b, v23.16b, v25.16b + eor v20.16b, v20.16b, v21.16b + eor v22.16b, v22.16b, v23.16b + zip1 v16.2d, v20.2d, v21.2d + zip1 v18.2d, v22.2d, v23.2d + zip2 v17.2d, v20.2d, v21.2d + zip2 v19.2d, v22.2d, v23.2d + + ext v16.16b, v16.16b, v16.16b, #15 // t0 = t0 << 8 + ext v17.16b, v17.16b, v17.16b, #14 // t1 = t1 << 16 + pmull v0.8h, v5.8b, v3.8b // D = A*B + ext v19.16b, v19.16b, v19.16b, #12 // t3 = t3 << 32 + ext v18.16b, v18.16b, v18.16b, #13 // t2 = t2 << 24 + eor v16.16b, v16.16b, v17.16b + eor v18.16b, v18.16b, v19.16b + eor v0.16b, v0.16b, v16.16b + eor v0.16b, v0.16b, v18.16b + eor v3.8b, v3.8b, v4.8b // Karatsuba pre-processing + ext v16.8b, v7.8b, v7.8b, #1 // A1 + pmull v16.8h, v16.8b, v3.8b // F = A1*B + ext v1.8b, v3.8b, v3.8b, #1 // B1 + pmull v1.8h, v7.8b, v1.8b // E = A*B1 + ext v17.8b, v7.8b, v7.8b, #2 // A2 + pmull v17.8h, v17.8b, v3.8b // H = A2*B + ext v19.8b, v3.8b, v3.8b, #2 // B2 + pmull v19.8h, v7.8b, v19.8b // G = A*B2 + ext v18.8b, v7.8b, v7.8b, #3 // A3 + eor v16.16b, v16.16b, v1.16b // L = E + F + pmull v18.8h, v18.8b, v3.8b // J = A3*B + ext v1.8b, v3.8b, v3.8b, #3 // B3 + eor v17.16b, v17.16b, v19.16b // M = G + H + pmull v1.8h, v7.8b, v1.8b // I = A*B3 + + // Here we diverge from the 32-bit version. It computes the following + // (instructions reordered for clarity): + // + // veor $t0#lo, $t0#lo, $t0#hi @ t0 = P0 + P1 (L) + // vand $t0#hi, $t0#hi, $k48 + // veor $t0#lo, $t0#lo, $t0#hi + // + // veor $t1#lo, $t1#lo, $t1#hi @ t1 = P2 + P3 (M) + // vand $t1#hi, $t1#hi, $k32 + // veor $t1#lo, $t1#lo, $t1#hi + // + // veor $t2#lo, $t2#lo, $t2#hi @ t2 = P4 + P5 (N) + // vand $t2#hi, $t2#hi, $k16 + // veor $t2#lo, $t2#lo, $t2#hi + // + // veor $t3#lo, $t3#lo, $t3#hi @ t3 = P6 + P7 (K) + // vmov.i64 $t3#hi, #0 + // + // $kN is a mask with the bottom N bits set. AArch64 cannot compute on + // upper halves of SIMD registers, so we must split each half into + // separate registers. To compensate, we pair computations up and + // parallelize. + + ext v19.8b, v3.8b, v3.8b, #4 // B4 + eor v18.16b, v18.16b, v1.16b // N = I + J + pmull v19.8h, v7.8b, v19.8b // K = A*B4 + + // This can probably be scheduled more efficiently. For now, we just + // pair up independent instructions. + zip1 v20.2d, v16.2d, v17.2d + zip1 v22.2d, v18.2d, v19.2d + zip2 v21.2d, v16.2d, v17.2d + zip2 v23.2d, v18.2d, v19.2d + eor v20.16b, v20.16b, v21.16b + eor v22.16b, v22.16b, v23.16b + and v21.16b, v21.16b, v24.16b + and v23.16b, v23.16b, v25.16b + eor v20.16b, v20.16b, v21.16b + eor v22.16b, v22.16b, v23.16b + zip1 v16.2d, v20.2d, v21.2d + zip1 v18.2d, v22.2d, v23.2d + zip2 v17.2d, v20.2d, v21.2d + zip2 v19.2d, v22.2d, v23.2d + + ext v16.16b, v16.16b, v16.16b, #15 // t0 = t0 << 8 + ext v17.16b, v17.16b, v17.16b, #14 // t1 = t1 << 16 + pmull v1.8h, v7.8b, v3.8b // D = A*B + ext v19.16b, v19.16b, v19.16b, #12 // t3 = t3 << 32 + ext v18.16b, v18.16b, v18.16b, #13 // t2 = t2 << 24 + eor v16.16b, v16.16b, v17.16b + eor v18.16b, v18.16b, v19.16b + eor v1.16b, v1.16b, v16.16b + eor v1.16b, v1.16b, v18.16b + ext v16.8b, v6.8b, v6.8b, #1 // A1 + pmull v16.8h, v16.8b, v4.8b // F = A1*B + ext v2.8b, v4.8b, v4.8b, #1 // B1 + pmull v2.8h, v6.8b, v2.8b // E = A*B1 + ext v17.8b, v6.8b, v6.8b, #2 // A2 + pmull v17.8h, v17.8b, v4.8b // H = A2*B + ext v19.8b, v4.8b, v4.8b, #2 // B2 + pmull v19.8h, v6.8b, v19.8b // G = A*B2 + ext v18.8b, v6.8b, v6.8b, #3 // A3 + eor v16.16b, v16.16b, v2.16b // L = E + F + pmull v18.8h, v18.8b, v4.8b // J = A3*B + ext v2.8b, v4.8b, v4.8b, #3 // B3 + eor v17.16b, v17.16b, v19.16b // M = G + H + pmull v2.8h, v6.8b, v2.8b // I = A*B3 + + // Here we diverge from the 32-bit version. It computes the following + // (instructions reordered for clarity): + // + // veor $t0#lo, $t0#lo, $t0#hi @ t0 = P0 + P1 (L) + // vand $t0#hi, $t0#hi, $k48 + // veor $t0#lo, $t0#lo, $t0#hi + // + // veor $t1#lo, $t1#lo, $t1#hi @ t1 = P2 + P3 (M) + // vand $t1#hi, $t1#hi, $k32 + // veor $t1#lo, $t1#lo, $t1#hi + // + // veor $t2#lo, $t2#lo, $t2#hi @ t2 = P4 + P5 (N) + // vand $t2#hi, $t2#hi, $k16 + // veor $t2#lo, $t2#lo, $t2#hi + // + // veor $t3#lo, $t3#lo, $t3#hi @ t3 = P6 + P7 (K) + // vmov.i64 $t3#hi, #0 + // + // $kN is a mask with the bottom N bits set. AArch64 cannot compute on + // upper halves of SIMD registers, so we must split each half into + // separate registers. To compensate, we pair computations up and + // parallelize. + + ext v19.8b, v4.8b, v4.8b, #4 // B4 + eor v18.16b, v18.16b, v2.16b // N = I + J + pmull v19.8h, v6.8b, v19.8b // K = A*B4 + + // This can probably be scheduled more efficiently. For now, we just + // pair up independent instructions. + zip1 v20.2d, v16.2d, v17.2d + zip1 v22.2d, v18.2d, v19.2d + zip2 v21.2d, v16.2d, v17.2d + zip2 v23.2d, v18.2d, v19.2d + eor v20.16b, v20.16b, v21.16b + eor v22.16b, v22.16b, v23.16b + and v21.16b, v21.16b, v24.16b + and v23.16b, v23.16b, v25.16b + eor v20.16b, v20.16b, v21.16b + eor v22.16b, v22.16b, v23.16b + zip1 v16.2d, v20.2d, v21.2d + zip1 v18.2d, v22.2d, v23.2d + zip2 v17.2d, v20.2d, v21.2d + zip2 v19.2d, v22.2d, v23.2d + + ext v16.16b, v16.16b, v16.16b, #15 // t0 = t0 << 8 + ext v17.16b, v17.16b, v17.16b, #14 // t1 = t1 << 16 + pmull v2.8h, v6.8b, v4.8b // D = A*B + ext v19.16b, v19.16b, v19.16b, #12 // t3 = t3 << 32 + ext v18.16b, v18.16b, v18.16b, #13 // t2 = t2 << 24 + eor v16.16b, v16.16b, v17.16b + eor v18.16b, v18.16b, v19.16b + eor v2.16b, v2.16b, v16.16b + eor v2.16b, v2.16b, v18.16b + ext v16.16b, v0.16b, v2.16b, #8 + eor v1.16b, v1.16b, v0.16b // Karatsuba post-processing + eor v1.16b, v1.16b, v2.16b + eor v1.16b, v1.16b, v16.16b // Xm overlaps Xh.lo and Xl.hi + ins v0.d[1], v1.d[0] // Xh|Xl - 256-bit result + // This is a no-op due to the ins instruction below. + // ins v2.d[0], v1.d[1] + + // equivalent of reduction_avx from ghash-x86_64.pl + shl v17.2d, v0.2d, #57 // 1st phase + shl v18.2d, v0.2d, #62 + eor v18.16b, v18.16b, v17.16b // + shl v17.2d, v0.2d, #63 + eor v18.16b, v18.16b, v17.16b // + // Note Xm contains {Xl.d[1], Xh.d[0]}. + eor v18.16b, v18.16b, v1.16b + ins v0.d[1], v18.d[0] // Xl.d[1] ^= t2.d[0] + ins v2.d[0], v18.d[1] // Xh.d[0] ^= t2.d[1] + + ushr v18.2d, v0.2d, #1 // 2nd phase + eor v2.16b, v2.16b,v0.16b + eor v0.16b, v0.16b,v18.16b // + ushr v18.2d, v18.2d, #6 + ushr v0.2d, v0.2d, #1 // + eor v0.16b, v0.16b, v2.16b // + eor v0.16b, v0.16b, v18.16b // + + subs x3, x3, #16 + bne Loop_neon + + rev64 v0.16b, v0.16b // byteswap Xi and write + ext v0.16b, v0.16b, v0.16b, #8 + st1 {v0.16b}, [x0] + + ret + + +.section __TEXT,__const +.align 4 +Lmasks: +.quad 0x0000ffffffffffff // k48 +.quad 0x00000000ffffffff // k32 +.quad 0x000000000000ffff // k16 +.quad 0x0000000000000000 // k0 +.byte 71,72,65,83,72,32,102,111,114,32,65,82,77,118,56,44,32,100,101,114,105,118,101,100,32,102,114,111,109,32,65,82,77,118,52,32,118,101,114,115,105,111,110,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.align 2 +.align 2 +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__APPLE__) diff --git a/http/vendor/ring/pregenerated/ghash-neon-armv8-linux64.S b/http/vendor/ring/pregenerated/ghash-neon-armv8-linux64.S new file mode 100644 index 0000000..7ddf782 --- /dev/null +++ b/http/vendor/ring/pregenerated/ghash-neon-armv8-linux64.S @@ -0,0 +1,333 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__ELF__) +.text + +.globl gcm_init_neon +.hidden gcm_init_neon +.type gcm_init_neon,%function +.align 4 +gcm_init_neon: + AARCH64_VALID_CALL_TARGET + // This function is adapted from gcm_init_v8. xC2 is t3. + ld1 {v17.2d}, [x1] // load H + movi v19.16b, #0xe1 + shl v19.2d, v19.2d, #57 // 0xc2.0 + ext v3.16b, v17.16b, v17.16b, #8 + ushr v18.2d, v19.2d, #63 + dup v17.4s, v17.s[1] + ext v16.16b, v18.16b, v19.16b, #8 // t0=0xc2....01 + ushr v18.2d, v3.2d, #63 + sshr v17.4s, v17.4s, #31 // broadcast carry bit + and v18.16b, v18.16b, v16.16b + shl v3.2d, v3.2d, #1 + ext v18.16b, v18.16b, v18.16b, #8 + and v16.16b, v16.16b, v17.16b + orr v3.16b, v3.16b, v18.16b // H<<<=1 + eor v5.16b, v3.16b, v16.16b // twisted H + st1 {v5.2d}, [x0] // store Htable[0] + ret +.size gcm_init_neon,.-gcm_init_neon + +.globl gcm_gmult_neon +.hidden gcm_gmult_neon +.type gcm_gmult_neon,%function +.align 4 +gcm_gmult_neon: + AARCH64_VALID_CALL_TARGET + ld1 {v3.16b}, [x0] // load Xi + ld1 {v5.1d}, [x1], #8 // load twisted H + ld1 {v6.1d}, [x1] + adrp x9, .Lmasks // load constants + add x9, x9, :lo12:.Lmasks + ld1 {v24.2d, v25.2d}, [x9] + rev64 v3.16b, v3.16b // byteswap Xi + ext v3.16b, v3.16b, v3.16b, #8 + eor v7.8b, v5.8b, v6.8b // Karatsuba pre-processing + + mov x3, #16 + b .Lgmult_neon +.size gcm_gmult_neon,.-gcm_gmult_neon + +.globl gcm_ghash_neon +.hidden gcm_ghash_neon +.type gcm_ghash_neon,%function +.align 4 +gcm_ghash_neon: + AARCH64_VALID_CALL_TARGET + ld1 {v0.16b}, [x0] // load Xi + ld1 {v5.1d}, [x1], #8 // load twisted H + ld1 {v6.1d}, [x1] + adrp x9, .Lmasks // load constants + add x9, x9, :lo12:.Lmasks + ld1 {v24.2d, v25.2d}, [x9] + rev64 v0.16b, v0.16b // byteswap Xi + ext v0.16b, v0.16b, v0.16b, #8 + eor v7.8b, v5.8b, v6.8b // Karatsuba pre-processing + +.Loop_neon: + ld1 {v3.16b}, [x2], #16 // load inp + rev64 v3.16b, v3.16b // byteswap inp + ext v3.16b, v3.16b, v3.16b, #8 + eor v3.16b, v3.16b, v0.16b // inp ^= Xi + +.Lgmult_neon: + // Split the input into v3 and v4. (The upper halves are unused, + // so it is okay to leave them alone.) + ins v4.d[0], v3.d[1] + ext v16.8b, v5.8b, v5.8b, #1 // A1 + pmull v16.8h, v16.8b, v3.8b // F = A1*B + ext v0.8b, v3.8b, v3.8b, #1 // B1 + pmull v0.8h, v5.8b, v0.8b // E = A*B1 + ext v17.8b, v5.8b, v5.8b, #2 // A2 + pmull v17.8h, v17.8b, v3.8b // H = A2*B + ext v19.8b, v3.8b, v3.8b, #2 // B2 + pmull v19.8h, v5.8b, v19.8b // G = A*B2 + ext v18.8b, v5.8b, v5.8b, #3 // A3 + eor v16.16b, v16.16b, v0.16b // L = E + F + pmull v18.8h, v18.8b, v3.8b // J = A3*B + ext v0.8b, v3.8b, v3.8b, #3 // B3 + eor v17.16b, v17.16b, v19.16b // M = G + H + pmull v0.8h, v5.8b, v0.8b // I = A*B3 + + // Here we diverge from the 32-bit version. It computes the following + // (instructions reordered for clarity): + // + // veor $t0#lo, $t0#lo, $t0#hi @ t0 = P0 + P1 (L) + // vand $t0#hi, $t0#hi, $k48 + // veor $t0#lo, $t0#lo, $t0#hi + // + // veor $t1#lo, $t1#lo, $t1#hi @ t1 = P2 + P3 (M) + // vand $t1#hi, $t1#hi, $k32 + // veor $t1#lo, $t1#lo, $t1#hi + // + // veor $t2#lo, $t2#lo, $t2#hi @ t2 = P4 + P5 (N) + // vand $t2#hi, $t2#hi, $k16 + // veor $t2#lo, $t2#lo, $t2#hi + // + // veor $t3#lo, $t3#lo, $t3#hi @ t3 = P6 + P7 (K) + // vmov.i64 $t3#hi, #0 + // + // $kN is a mask with the bottom N bits set. AArch64 cannot compute on + // upper halves of SIMD registers, so we must split each half into + // separate registers. To compensate, we pair computations up and + // parallelize. + + ext v19.8b, v3.8b, v3.8b, #4 // B4 + eor v18.16b, v18.16b, v0.16b // N = I + J + pmull v19.8h, v5.8b, v19.8b // K = A*B4 + + // This can probably be scheduled more efficiently. For now, we just + // pair up independent instructions. + zip1 v20.2d, v16.2d, v17.2d + zip1 v22.2d, v18.2d, v19.2d + zip2 v21.2d, v16.2d, v17.2d + zip2 v23.2d, v18.2d, v19.2d + eor v20.16b, v20.16b, v21.16b + eor v22.16b, v22.16b, v23.16b + and v21.16b, v21.16b, v24.16b + and v23.16b, v23.16b, v25.16b + eor v20.16b, v20.16b, v21.16b + eor v22.16b, v22.16b, v23.16b + zip1 v16.2d, v20.2d, v21.2d + zip1 v18.2d, v22.2d, v23.2d + zip2 v17.2d, v20.2d, v21.2d + zip2 v19.2d, v22.2d, v23.2d + + ext v16.16b, v16.16b, v16.16b, #15 // t0 = t0 << 8 + ext v17.16b, v17.16b, v17.16b, #14 // t1 = t1 << 16 + pmull v0.8h, v5.8b, v3.8b // D = A*B + ext v19.16b, v19.16b, v19.16b, #12 // t3 = t3 << 32 + ext v18.16b, v18.16b, v18.16b, #13 // t2 = t2 << 24 + eor v16.16b, v16.16b, v17.16b + eor v18.16b, v18.16b, v19.16b + eor v0.16b, v0.16b, v16.16b + eor v0.16b, v0.16b, v18.16b + eor v3.8b, v3.8b, v4.8b // Karatsuba pre-processing + ext v16.8b, v7.8b, v7.8b, #1 // A1 + pmull v16.8h, v16.8b, v3.8b // F = A1*B + ext v1.8b, v3.8b, v3.8b, #1 // B1 + pmull v1.8h, v7.8b, v1.8b // E = A*B1 + ext v17.8b, v7.8b, v7.8b, #2 // A2 + pmull v17.8h, v17.8b, v3.8b // H = A2*B + ext v19.8b, v3.8b, v3.8b, #2 // B2 + pmull v19.8h, v7.8b, v19.8b // G = A*B2 + ext v18.8b, v7.8b, v7.8b, #3 // A3 + eor v16.16b, v16.16b, v1.16b // L = E + F + pmull v18.8h, v18.8b, v3.8b // J = A3*B + ext v1.8b, v3.8b, v3.8b, #3 // B3 + eor v17.16b, v17.16b, v19.16b // M = G + H + pmull v1.8h, v7.8b, v1.8b // I = A*B3 + + // Here we diverge from the 32-bit version. It computes the following + // (instructions reordered for clarity): + // + // veor $t0#lo, $t0#lo, $t0#hi @ t0 = P0 + P1 (L) + // vand $t0#hi, $t0#hi, $k48 + // veor $t0#lo, $t0#lo, $t0#hi + // + // veor $t1#lo, $t1#lo, $t1#hi @ t1 = P2 + P3 (M) + // vand $t1#hi, $t1#hi, $k32 + // veor $t1#lo, $t1#lo, $t1#hi + // + // veor $t2#lo, $t2#lo, $t2#hi @ t2 = P4 + P5 (N) + // vand $t2#hi, $t2#hi, $k16 + // veor $t2#lo, $t2#lo, $t2#hi + // + // veor $t3#lo, $t3#lo, $t3#hi @ t3 = P6 + P7 (K) + // vmov.i64 $t3#hi, #0 + // + // $kN is a mask with the bottom N bits set. AArch64 cannot compute on + // upper halves of SIMD registers, so we must split each half into + // separate registers. To compensate, we pair computations up and + // parallelize. + + ext v19.8b, v3.8b, v3.8b, #4 // B4 + eor v18.16b, v18.16b, v1.16b // N = I + J + pmull v19.8h, v7.8b, v19.8b // K = A*B4 + + // This can probably be scheduled more efficiently. For now, we just + // pair up independent instructions. + zip1 v20.2d, v16.2d, v17.2d + zip1 v22.2d, v18.2d, v19.2d + zip2 v21.2d, v16.2d, v17.2d + zip2 v23.2d, v18.2d, v19.2d + eor v20.16b, v20.16b, v21.16b + eor v22.16b, v22.16b, v23.16b + and v21.16b, v21.16b, v24.16b + and v23.16b, v23.16b, v25.16b + eor v20.16b, v20.16b, v21.16b + eor v22.16b, v22.16b, v23.16b + zip1 v16.2d, v20.2d, v21.2d + zip1 v18.2d, v22.2d, v23.2d + zip2 v17.2d, v20.2d, v21.2d + zip2 v19.2d, v22.2d, v23.2d + + ext v16.16b, v16.16b, v16.16b, #15 // t0 = t0 << 8 + ext v17.16b, v17.16b, v17.16b, #14 // t1 = t1 << 16 + pmull v1.8h, v7.8b, v3.8b // D = A*B + ext v19.16b, v19.16b, v19.16b, #12 // t3 = t3 << 32 + ext v18.16b, v18.16b, v18.16b, #13 // t2 = t2 << 24 + eor v16.16b, v16.16b, v17.16b + eor v18.16b, v18.16b, v19.16b + eor v1.16b, v1.16b, v16.16b + eor v1.16b, v1.16b, v18.16b + ext v16.8b, v6.8b, v6.8b, #1 // A1 + pmull v16.8h, v16.8b, v4.8b // F = A1*B + ext v2.8b, v4.8b, v4.8b, #1 // B1 + pmull v2.8h, v6.8b, v2.8b // E = A*B1 + ext v17.8b, v6.8b, v6.8b, #2 // A2 + pmull v17.8h, v17.8b, v4.8b // H = A2*B + ext v19.8b, v4.8b, v4.8b, #2 // B2 + pmull v19.8h, v6.8b, v19.8b // G = A*B2 + ext v18.8b, v6.8b, v6.8b, #3 // A3 + eor v16.16b, v16.16b, v2.16b // L = E + F + pmull v18.8h, v18.8b, v4.8b // J = A3*B + ext v2.8b, v4.8b, v4.8b, #3 // B3 + eor v17.16b, v17.16b, v19.16b // M = G + H + pmull v2.8h, v6.8b, v2.8b // I = A*B3 + + // Here we diverge from the 32-bit version. It computes the following + // (instructions reordered for clarity): + // + // veor $t0#lo, $t0#lo, $t0#hi @ t0 = P0 + P1 (L) + // vand $t0#hi, $t0#hi, $k48 + // veor $t0#lo, $t0#lo, $t0#hi + // + // veor $t1#lo, $t1#lo, $t1#hi @ t1 = P2 + P3 (M) + // vand $t1#hi, $t1#hi, $k32 + // veor $t1#lo, $t1#lo, $t1#hi + // + // veor $t2#lo, $t2#lo, $t2#hi @ t2 = P4 + P5 (N) + // vand $t2#hi, $t2#hi, $k16 + // veor $t2#lo, $t2#lo, $t2#hi + // + // veor $t3#lo, $t3#lo, $t3#hi @ t3 = P6 + P7 (K) + // vmov.i64 $t3#hi, #0 + // + // $kN is a mask with the bottom N bits set. AArch64 cannot compute on + // upper halves of SIMD registers, so we must split each half into + // separate registers. To compensate, we pair computations up and + // parallelize. + + ext v19.8b, v4.8b, v4.8b, #4 // B4 + eor v18.16b, v18.16b, v2.16b // N = I + J + pmull v19.8h, v6.8b, v19.8b // K = A*B4 + + // This can probably be scheduled more efficiently. For now, we just + // pair up independent instructions. + zip1 v20.2d, v16.2d, v17.2d + zip1 v22.2d, v18.2d, v19.2d + zip2 v21.2d, v16.2d, v17.2d + zip2 v23.2d, v18.2d, v19.2d + eor v20.16b, v20.16b, v21.16b + eor v22.16b, v22.16b, v23.16b + and v21.16b, v21.16b, v24.16b + and v23.16b, v23.16b, v25.16b + eor v20.16b, v20.16b, v21.16b + eor v22.16b, v22.16b, v23.16b + zip1 v16.2d, v20.2d, v21.2d + zip1 v18.2d, v22.2d, v23.2d + zip2 v17.2d, v20.2d, v21.2d + zip2 v19.2d, v22.2d, v23.2d + + ext v16.16b, v16.16b, v16.16b, #15 // t0 = t0 << 8 + ext v17.16b, v17.16b, v17.16b, #14 // t1 = t1 << 16 + pmull v2.8h, v6.8b, v4.8b // D = A*B + ext v19.16b, v19.16b, v19.16b, #12 // t3 = t3 << 32 + ext v18.16b, v18.16b, v18.16b, #13 // t2 = t2 << 24 + eor v16.16b, v16.16b, v17.16b + eor v18.16b, v18.16b, v19.16b + eor v2.16b, v2.16b, v16.16b + eor v2.16b, v2.16b, v18.16b + ext v16.16b, v0.16b, v2.16b, #8 + eor v1.16b, v1.16b, v0.16b // Karatsuba post-processing + eor v1.16b, v1.16b, v2.16b + eor v1.16b, v1.16b, v16.16b // Xm overlaps Xh.lo and Xl.hi + ins v0.d[1], v1.d[0] // Xh|Xl - 256-bit result + // This is a no-op due to the ins instruction below. + // ins v2.d[0], v1.d[1] + + // equivalent of reduction_avx from ghash-x86_64.pl + shl v17.2d, v0.2d, #57 // 1st phase + shl v18.2d, v0.2d, #62 + eor v18.16b, v18.16b, v17.16b // + shl v17.2d, v0.2d, #63 + eor v18.16b, v18.16b, v17.16b // + // Note Xm contains {Xl.d[1], Xh.d[0]}. + eor v18.16b, v18.16b, v1.16b + ins v0.d[1], v18.d[0] // Xl.d[1] ^= t2.d[0] + ins v2.d[0], v18.d[1] // Xh.d[0] ^= t2.d[1] + + ushr v18.2d, v0.2d, #1 // 2nd phase + eor v2.16b, v2.16b,v0.16b + eor v0.16b, v0.16b,v18.16b // + ushr v18.2d, v18.2d, #6 + ushr v0.2d, v0.2d, #1 // + eor v0.16b, v0.16b, v2.16b // + eor v0.16b, v0.16b, v18.16b // + + subs x3, x3, #16 + bne .Loop_neon + + rev64 v0.16b, v0.16b // byteswap Xi and write + ext v0.16b, v0.16b, v0.16b, #8 + st1 {v0.16b}, [x0] + + ret +.size gcm_ghash_neon,.-gcm_ghash_neon + +.section .rodata +.align 4 +.Lmasks: +.quad 0x0000ffffffffffff // k48 +.quad 0x00000000ffffffff // k32 +.quad 0x000000000000ffff // k16 +.quad 0x0000000000000000 // k0 +.byte 71,72,65,83,72,32,102,111,114,32,65,82,77,118,56,44,32,100,101,114,105,118,101,100,32,102,114,111,109,32,65,82,77,118,52,32,118,101,114,115,105,111,110,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.align 2 +.align 2 +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__ELF__) diff --git a/http/vendor/ring/pregenerated/ghash-neon-armv8-win64.S b/http/vendor/ring/pregenerated/ghash-neon-armv8-win64.S new file mode 100644 index 0000000..db3d424 --- /dev/null +++ b/http/vendor/ring/pregenerated/ghash-neon-armv8-win64.S @@ -0,0 +1,339 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(_WIN32) +.text + +.globl gcm_init_neon + +.def gcm_init_neon + .type 32 +.endef +.align 4 +gcm_init_neon: + AARCH64_VALID_CALL_TARGET + // This function is adapted from gcm_init_v8. xC2 is t3. + ld1 {v17.2d}, [x1] // load H + movi v19.16b, #0xe1 + shl v19.2d, v19.2d, #57 // 0xc2.0 + ext v3.16b, v17.16b, v17.16b, #8 + ushr v18.2d, v19.2d, #63 + dup v17.4s, v17.s[1] + ext v16.16b, v18.16b, v19.16b, #8 // t0=0xc2....01 + ushr v18.2d, v3.2d, #63 + sshr v17.4s, v17.4s, #31 // broadcast carry bit + and v18.16b, v18.16b, v16.16b + shl v3.2d, v3.2d, #1 + ext v18.16b, v18.16b, v18.16b, #8 + and v16.16b, v16.16b, v17.16b + orr v3.16b, v3.16b, v18.16b // H<<<=1 + eor v5.16b, v3.16b, v16.16b // twisted H + st1 {v5.2d}, [x0] // store Htable[0] + ret + + +.globl gcm_gmult_neon + +.def gcm_gmult_neon + .type 32 +.endef +.align 4 +gcm_gmult_neon: + AARCH64_VALID_CALL_TARGET + ld1 {v3.16b}, [x0] // load Xi + ld1 {v5.1d}, [x1], #8 // load twisted H + ld1 {v6.1d}, [x1] + adrp x9, Lmasks // load constants + add x9, x9, :lo12:Lmasks + ld1 {v24.2d, v25.2d}, [x9] + rev64 v3.16b, v3.16b // byteswap Xi + ext v3.16b, v3.16b, v3.16b, #8 + eor v7.8b, v5.8b, v6.8b // Karatsuba pre-processing + + mov x3, #16 + b Lgmult_neon + + +.globl gcm_ghash_neon + +.def gcm_ghash_neon + .type 32 +.endef +.align 4 +gcm_ghash_neon: + AARCH64_VALID_CALL_TARGET + ld1 {v0.16b}, [x0] // load Xi + ld1 {v5.1d}, [x1], #8 // load twisted H + ld1 {v6.1d}, [x1] + adrp x9, Lmasks // load constants + add x9, x9, :lo12:Lmasks + ld1 {v24.2d, v25.2d}, [x9] + rev64 v0.16b, v0.16b // byteswap Xi + ext v0.16b, v0.16b, v0.16b, #8 + eor v7.8b, v5.8b, v6.8b // Karatsuba pre-processing + +Loop_neon: + ld1 {v3.16b}, [x2], #16 // load inp + rev64 v3.16b, v3.16b // byteswap inp + ext v3.16b, v3.16b, v3.16b, #8 + eor v3.16b, v3.16b, v0.16b // inp ^= Xi + +Lgmult_neon: + // Split the input into v3 and v4. (The upper halves are unused, + // so it is okay to leave them alone.) + ins v4.d[0], v3.d[1] + ext v16.8b, v5.8b, v5.8b, #1 // A1 + pmull v16.8h, v16.8b, v3.8b // F = A1*B + ext v0.8b, v3.8b, v3.8b, #1 // B1 + pmull v0.8h, v5.8b, v0.8b // E = A*B1 + ext v17.8b, v5.8b, v5.8b, #2 // A2 + pmull v17.8h, v17.8b, v3.8b // H = A2*B + ext v19.8b, v3.8b, v3.8b, #2 // B2 + pmull v19.8h, v5.8b, v19.8b // G = A*B2 + ext v18.8b, v5.8b, v5.8b, #3 // A3 + eor v16.16b, v16.16b, v0.16b // L = E + F + pmull v18.8h, v18.8b, v3.8b // J = A3*B + ext v0.8b, v3.8b, v3.8b, #3 // B3 + eor v17.16b, v17.16b, v19.16b // M = G + H + pmull v0.8h, v5.8b, v0.8b // I = A*B3 + + // Here we diverge from the 32-bit version. It computes the following + // (instructions reordered for clarity): + // + // veor $t0#lo, $t0#lo, $t0#hi @ t0 = P0 + P1 (L) + // vand $t0#hi, $t0#hi, $k48 + // veor $t0#lo, $t0#lo, $t0#hi + // + // veor $t1#lo, $t1#lo, $t1#hi @ t1 = P2 + P3 (M) + // vand $t1#hi, $t1#hi, $k32 + // veor $t1#lo, $t1#lo, $t1#hi + // + // veor $t2#lo, $t2#lo, $t2#hi @ t2 = P4 + P5 (N) + // vand $t2#hi, $t2#hi, $k16 + // veor $t2#lo, $t2#lo, $t2#hi + // + // veor $t3#lo, $t3#lo, $t3#hi @ t3 = P6 + P7 (K) + // vmov.i64 $t3#hi, #0 + // + // $kN is a mask with the bottom N bits set. AArch64 cannot compute on + // upper halves of SIMD registers, so we must split each half into + // separate registers. To compensate, we pair computations up and + // parallelize. + + ext v19.8b, v3.8b, v3.8b, #4 // B4 + eor v18.16b, v18.16b, v0.16b // N = I + J + pmull v19.8h, v5.8b, v19.8b // K = A*B4 + + // This can probably be scheduled more efficiently. For now, we just + // pair up independent instructions. + zip1 v20.2d, v16.2d, v17.2d + zip1 v22.2d, v18.2d, v19.2d + zip2 v21.2d, v16.2d, v17.2d + zip2 v23.2d, v18.2d, v19.2d + eor v20.16b, v20.16b, v21.16b + eor v22.16b, v22.16b, v23.16b + and v21.16b, v21.16b, v24.16b + and v23.16b, v23.16b, v25.16b + eor v20.16b, v20.16b, v21.16b + eor v22.16b, v22.16b, v23.16b + zip1 v16.2d, v20.2d, v21.2d + zip1 v18.2d, v22.2d, v23.2d + zip2 v17.2d, v20.2d, v21.2d + zip2 v19.2d, v22.2d, v23.2d + + ext v16.16b, v16.16b, v16.16b, #15 // t0 = t0 << 8 + ext v17.16b, v17.16b, v17.16b, #14 // t1 = t1 << 16 + pmull v0.8h, v5.8b, v3.8b // D = A*B + ext v19.16b, v19.16b, v19.16b, #12 // t3 = t3 << 32 + ext v18.16b, v18.16b, v18.16b, #13 // t2 = t2 << 24 + eor v16.16b, v16.16b, v17.16b + eor v18.16b, v18.16b, v19.16b + eor v0.16b, v0.16b, v16.16b + eor v0.16b, v0.16b, v18.16b + eor v3.8b, v3.8b, v4.8b // Karatsuba pre-processing + ext v16.8b, v7.8b, v7.8b, #1 // A1 + pmull v16.8h, v16.8b, v3.8b // F = A1*B + ext v1.8b, v3.8b, v3.8b, #1 // B1 + pmull v1.8h, v7.8b, v1.8b // E = A*B1 + ext v17.8b, v7.8b, v7.8b, #2 // A2 + pmull v17.8h, v17.8b, v3.8b // H = A2*B + ext v19.8b, v3.8b, v3.8b, #2 // B2 + pmull v19.8h, v7.8b, v19.8b // G = A*B2 + ext v18.8b, v7.8b, v7.8b, #3 // A3 + eor v16.16b, v16.16b, v1.16b // L = E + F + pmull v18.8h, v18.8b, v3.8b // J = A3*B + ext v1.8b, v3.8b, v3.8b, #3 // B3 + eor v17.16b, v17.16b, v19.16b // M = G + H + pmull v1.8h, v7.8b, v1.8b // I = A*B3 + + // Here we diverge from the 32-bit version. It computes the following + // (instructions reordered for clarity): + // + // veor $t0#lo, $t0#lo, $t0#hi @ t0 = P0 + P1 (L) + // vand $t0#hi, $t0#hi, $k48 + // veor $t0#lo, $t0#lo, $t0#hi + // + // veor $t1#lo, $t1#lo, $t1#hi @ t1 = P2 + P3 (M) + // vand $t1#hi, $t1#hi, $k32 + // veor $t1#lo, $t1#lo, $t1#hi + // + // veor $t2#lo, $t2#lo, $t2#hi @ t2 = P4 + P5 (N) + // vand $t2#hi, $t2#hi, $k16 + // veor $t2#lo, $t2#lo, $t2#hi + // + // veor $t3#lo, $t3#lo, $t3#hi @ t3 = P6 + P7 (K) + // vmov.i64 $t3#hi, #0 + // + // $kN is a mask with the bottom N bits set. AArch64 cannot compute on + // upper halves of SIMD registers, so we must split each half into + // separate registers. To compensate, we pair computations up and + // parallelize. + + ext v19.8b, v3.8b, v3.8b, #4 // B4 + eor v18.16b, v18.16b, v1.16b // N = I + J + pmull v19.8h, v7.8b, v19.8b // K = A*B4 + + // This can probably be scheduled more efficiently. For now, we just + // pair up independent instructions. + zip1 v20.2d, v16.2d, v17.2d + zip1 v22.2d, v18.2d, v19.2d + zip2 v21.2d, v16.2d, v17.2d + zip2 v23.2d, v18.2d, v19.2d + eor v20.16b, v20.16b, v21.16b + eor v22.16b, v22.16b, v23.16b + and v21.16b, v21.16b, v24.16b + and v23.16b, v23.16b, v25.16b + eor v20.16b, v20.16b, v21.16b + eor v22.16b, v22.16b, v23.16b + zip1 v16.2d, v20.2d, v21.2d + zip1 v18.2d, v22.2d, v23.2d + zip2 v17.2d, v20.2d, v21.2d + zip2 v19.2d, v22.2d, v23.2d + + ext v16.16b, v16.16b, v16.16b, #15 // t0 = t0 << 8 + ext v17.16b, v17.16b, v17.16b, #14 // t1 = t1 << 16 + pmull v1.8h, v7.8b, v3.8b // D = A*B + ext v19.16b, v19.16b, v19.16b, #12 // t3 = t3 << 32 + ext v18.16b, v18.16b, v18.16b, #13 // t2 = t2 << 24 + eor v16.16b, v16.16b, v17.16b + eor v18.16b, v18.16b, v19.16b + eor v1.16b, v1.16b, v16.16b + eor v1.16b, v1.16b, v18.16b + ext v16.8b, v6.8b, v6.8b, #1 // A1 + pmull v16.8h, v16.8b, v4.8b // F = A1*B + ext v2.8b, v4.8b, v4.8b, #1 // B1 + pmull v2.8h, v6.8b, v2.8b // E = A*B1 + ext v17.8b, v6.8b, v6.8b, #2 // A2 + pmull v17.8h, v17.8b, v4.8b // H = A2*B + ext v19.8b, v4.8b, v4.8b, #2 // B2 + pmull v19.8h, v6.8b, v19.8b // G = A*B2 + ext v18.8b, v6.8b, v6.8b, #3 // A3 + eor v16.16b, v16.16b, v2.16b // L = E + F + pmull v18.8h, v18.8b, v4.8b // J = A3*B + ext v2.8b, v4.8b, v4.8b, #3 // B3 + eor v17.16b, v17.16b, v19.16b // M = G + H + pmull v2.8h, v6.8b, v2.8b // I = A*B3 + + // Here we diverge from the 32-bit version. It computes the following + // (instructions reordered for clarity): + // + // veor $t0#lo, $t0#lo, $t0#hi @ t0 = P0 + P1 (L) + // vand $t0#hi, $t0#hi, $k48 + // veor $t0#lo, $t0#lo, $t0#hi + // + // veor $t1#lo, $t1#lo, $t1#hi @ t1 = P2 + P3 (M) + // vand $t1#hi, $t1#hi, $k32 + // veor $t1#lo, $t1#lo, $t1#hi + // + // veor $t2#lo, $t2#lo, $t2#hi @ t2 = P4 + P5 (N) + // vand $t2#hi, $t2#hi, $k16 + // veor $t2#lo, $t2#lo, $t2#hi + // + // veor $t3#lo, $t3#lo, $t3#hi @ t3 = P6 + P7 (K) + // vmov.i64 $t3#hi, #0 + // + // $kN is a mask with the bottom N bits set. AArch64 cannot compute on + // upper halves of SIMD registers, so we must split each half into + // separate registers. To compensate, we pair computations up and + // parallelize. + + ext v19.8b, v4.8b, v4.8b, #4 // B4 + eor v18.16b, v18.16b, v2.16b // N = I + J + pmull v19.8h, v6.8b, v19.8b // K = A*B4 + + // This can probably be scheduled more efficiently. For now, we just + // pair up independent instructions. + zip1 v20.2d, v16.2d, v17.2d + zip1 v22.2d, v18.2d, v19.2d + zip2 v21.2d, v16.2d, v17.2d + zip2 v23.2d, v18.2d, v19.2d + eor v20.16b, v20.16b, v21.16b + eor v22.16b, v22.16b, v23.16b + and v21.16b, v21.16b, v24.16b + and v23.16b, v23.16b, v25.16b + eor v20.16b, v20.16b, v21.16b + eor v22.16b, v22.16b, v23.16b + zip1 v16.2d, v20.2d, v21.2d + zip1 v18.2d, v22.2d, v23.2d + zip2 v17.2d, v20.2d, v21.2d + zip2 v19.2d, v22.2d, v23.2d + + ext v16.16b, v16.16b, v16.16b, #15 // t0 = t0 << 8 + ext v17.16b, v17.16b, v17.16b, #14 // t1 = t1 << 16 + pmull v2.8h, v6.8b, v4.8b // D = A*B + ext v19.16b, v19.16b, v19.16b, #12 // t3 = t3 << 32 + ext v18.16b, v18.16b, v18.16b, #13 // t2 = t2 << 24 + eor v16.16b, v16.16b, v17.16b + eor v18.16b, v18.16b, v19.16b + eor v2.16b, v2.16b, v16.16b + eor v2.16b, v2.16b, v18.16b + ext v16.16b, v0.16b, v2.16b, #8 + eor v1.16b, v1.16b, v0.16b // Karatsuba post-processing + eor v1.16b, v1.16b, v2.16b + eor v1.16b, v1.16b, v16.16b // Xm overlaps Xh.lo and Xl.hi + ins v0.d[1], v1.d[0] // Xh|Xl - 256-bit result + // This is a no-op due to the ins instruction below. + // ins v2.d[0], v1.d[1] + + // equivalent of reduction_avx from ghash-x86_64.pl + shl v17.2d, v0.2d, #57 // 1st phase + shl v18.2d, v0.2d, #62 + eor v18.16b, v18.16b, v17.16b // + shl v17.2d, v0.2d, #63 + eor v18.16b, v18.16b, v17.16b // + // Note Xm contains {Xl.d[1], Xh.d[0]}. + eor v18.16b, v18.16b, v1.16b + ins v0.d[1], v18.d[0] // Xl.d[1] ^= t2.d[0] + ins v2.d[0], v18.d[1] // Xh.d[0] ^= t2.d[1] + + ushr v18.2d, v0.2d, #1 // 2nd phase + eor v2.16b, v2.16b,v0.16b + eor v0.16b, v0.16b,v18.16b // + ushr v18.2d, v18.2d, #6 + ushr v0.2d, v0.2d, #1 // + eor v0.16b, v0.16b, v2.16b // + eor v0.16b, v0.16b, v18.16b // + + subs x3, x3, #16 + bne Loop_neon + + rev64 v0.16b, v0.16b // byteswap Xi and write + ext v0.16b, v0.16b, v0.16b, #8 + st1 {v0.16b}, [x0] + + ret + + +.section .rodata +.align 4 +Lmasks: +.quad 0x0000ffffffffffff // k48 +.quad 0x00000000ffffffff // k32 +.quad 0x000000000000ffff // k16 +.quad 0x0000000000000000 // k0 +.byte 71,72,65,83,72,32,102,111,114,32,65,82,77,118,56,44,32,100,101,114,105,118,101,100,32,102,114,111,109,32,65,82,77,118,52,32,118,101,114,115,105,111,110,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.align 2 +.align 2 +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(_WIN32) diff --git a/http/vendor/ring/pregenerated/ghash-x86-elf.S b/http/vendor/ring/pregenerated/ghash-x86-elf.S new file mode 100644 index 0000000..6c1753d --- /dev/null +++ b/http/vendor/ring/pregenerated/ghash-x86-elf.S @@ -0,0 +1,274 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) +.text +.globl gcm_init_clmul +.hidden gcm_init_clmul +.type gcm_init_clmul,@function +.align 16 +gcm_init_clmul: +.L_gcm_init_clmul_begin: + movl 4(%esp),%edx + movl 8(%esp),%eax + call .L000pic +.L000pic: + popl %ecx + leal .Lbswap-.L000pic(%ecx),%ecx + movdqu (%eax),%xmm2 + pshufd $78,%xmm2,%xmm2 + pshufd $255,%xmm2,%xmm4 + movdqa %xmm2,%xmm3 + psllq $1,%xmm2 + pxor %xmm5,%xmm5 + psrlq $63,%xmm3 + pcmpgtd %xmm4,%xmm5 + pslldq $8,%xmm3 + por %xmm3,%xmm2 + pand 16(%ecx),%xmm5 + pxor %xmm5,%xmm2 + movdqa %xmm2,%xmm0 + movdqa %xmm0,%xmm1 + pshufd $78,%xmm0,%xmm3 + pshufd $78,%xmm2,%xmm4 + pxor %xmm0,%xmm3 + pxor %xmm2,%xmm4 +.byte 102,15,58,68,194,0 +.byte 102,15,58,68,202,17 +.byte 102,15,58,68,220,0 + xorps %xmm0,%xmm3 + xorps %xmm1,%xmm3 + movdqa %xmm3,%xmm4 + psrldq $8,%xmm3 + pslldq $8,%xmm4 + pxor %xmm3,%xmm1 + pxor %xmm4,%xmm0 + movdqa %xmm0,%xmm4 + movdqa %xmm0,%xmm3 + psllq $5,%xmm0 + pxor %xmm0,%xmm3 + psllq $1,%xmm0 + pxor %xmm3,%xmm0 + psllq $57,%xmm0 + movdqa %xmm0,%xmm3 + pslldq $8,%xmm0 + psrldq $8,%xmm3 + pxor %xmm4,%xmm0 + pxor %xmm3,%xmm1 + movdqa %xmm0,%xmm4 + psrlq $1,%xmm0 + pxor %xmm4,%xmm1 + pxor %xmm0,%xmm4 + psrlq $5,%xmm0 + pxor %xmm4,%xmm0 + psrlq $1,%xmm0 + pxor %xmm1,%xmm0 + pshufd $78,%xmm2,%xmm3 + pshufd $78,%xmm0,%xmm4 + pxor %xmm2,%xmm3 + movdqu %xmm2,(%edx) + pxor %xmm0,%xmm4 + movdqu %xmm0,16(%edx) +.byte 102,15,58,15,227,8 + movdqu %xmm4,32(%edx) + ret +.size gcm_init_clmul,.-.L_gcm_init_clmul_begin +.globl gcm_ghash_clmul +.hidden gcm_ghash_clmul +.type gcm_ghash_clmul,@function +.align 16 +gcm_ghash_clmul: +.L_gcm_ghash_clmul_begin: + pushl %ebp + pushl %ebx + pushl %esi + pushl %edi + movl 20(%esp),%eax + movl 24(%esp),%edx + movl 28(%esp),%esi + movl 32(%esp),%ebx + call .L001pic +.L001pic: + popl %ecx + leal .Lbswap-.L001pic(%ecx),%ecx + movdqu (%eax),%xmm0 + movdqa (%ecx),%xmm5 + movdqu (%edx),%xmm2 +.byte 102,15,56,0,197 + subl $16,%ebx + jz .L002odd_tail + movdqu (%esi),%xmm3 + movdqu 16(%esi),%xmm6 +.byte 102,15,56,0,221 +.byte 102,15,56,0,245 + movdqu 32(%edx),%xmm5 + pxor %xmm3,%xmm0 + pshufd $78,%xmm6,%xmm3 + movdqa %xmm6,%xmm7 + pxor %xmm6,%xmm3 + leal 32(%esi),%esi +.byte 102,15,58,68,242,0 +.byte 102,15,58,68,250,17 +.byte 102,15,58,68,221,0 + movups 16(%edx),%xmm2 + nop + subl $32,%ebx + jbe .L003even_tail + jmp .L004mod_loop +.align 32 +.L004mod_loop: + pshufd $78,%xmm0,%xmm4 + movdqa %xmm0,%xmm1 + pxor %xmm0,%xmm4 + nop +.byte 102,15,58,68,194,0 +.byte 102,15,58,68,202,17 +.byte 102,15,58,68,229,16 + movups (%edx),%xmm2 + xorps %xmm6,%xmm0 + movdqa (%ecx),%xmm5 + xorps %xmm7,%xmm1 + movdqu (%esi),%xmm7 + pxor %xmm0,%xmm3 + movdqu 16(%esi),%xmm6 + pxor %xmm1,%xmm3 +.byte 102,15,56,0,253 + pxor %xmm3,%xmm4 + movdqa %xmm4,%xmm3 + psrldq $8,%xmm4 + pslldq $8,%xmm3 + pxor %xmm4,%xmm1 + pxor %xmm3,%xmm0 +.byte 102,15,56,0,245 + pxor %xmm7,%xmm1 + movdqa %xmm6,%xmm7 + movdqa %xmm0,%xmm4 + movdqa %xmm0,%xmm3 + psllq $5,%xmm0 + pxor %xmm0,%xmm3 + psllq $1,%xmm0 + pxor %xmm3,%xmm0 +.byte 102,15,58,68,242,0 + movups 32(%edx),%xmm5 + psllq $57,%xmm0 + movdqa %xmm0,%xmm3 + pslldq $8,%xmm0 + psrldq $8,%xmm3 + pxor %xmm4,%xmm0 + pxor %xmm3,%xmm1 + pshufd $78,%xmm7,%xmm3 + movdqa %xmm0,%xmm4 + psrlq $1,%xmm0 + pxor %xmm7,%xmm3 + pxor %xmm4,%xmm1 +.byte 102,15,58,68,250,17 + movups 16(%edx),%xmm2 + pxor %xmm0,%xmm4 + psrlq $5,%xmm0 + pxor %xmm4,%xmm0 + psrlq $1,%xmm0 + pxor %xmm1,%xmm0 +.byte 102,15,58,68,221,0 + leal 32(%esi),%esi + subl $32,%ebx + ja .L004mod_loop +.L003even_tail: + pshufd $78,%xmm0,%xmm4 + movdqa %xmm0,%xmm1 + pxor %xmm0,%xmm4 +.byte 102,15,58,68,194,0 +.byte 102,15,58,68,202,17 +.byte 102,15,58,68,229,16 + movdqa (%ecx),%xmm5 + xorps %xmm6,%xmm0 + xorps %xmm7,%xmm1 + pxor %xmm0,%xmm3 + pxor %xmm1,%xmm3 + pxor %xmm3,%xmm4 + movdqa %xmm4,%xmm3 + psrldq $8,%xmm4 + pslldq $8,%xmm3 + pxor %xmm4,%xmm1 + pxor %xmm3,%xmm0 + movdqa %xmm0,%xmm4 + movdqa %xmm0,%xmm3 + psllq $5,%xmm0 + pxor %xmm0,%xmm3 + psllq $1,%xmm0 + pxor %xmm3,%xmm0 + psllq $57,%xmm0 + movdqa %xmm0,%xmm3 + pslldq $8,%xmm0 + psrldq $8,%xmm3 + pxor %xmm4,%xmm0 + pxor %xmm3,%xmm1 + movdqa %xmm0,%xmm4 + psrlq $1,%xmm0 + pxor %xmm4,%xmm1 + pxor %xmm0,%xmm4 + psrlq $5,%xmm0 + pxor %xmm4,%xmm0 + psrlq $1,%xmm0 + pxor %xmm1,%xmm0 + testl %ebx,%ebx + jnz .L005done + movups (%edx),%xmm2 +.L002odd_tail: + movdqu (%esi),%xmm3 +.byte 102,15,56,0,221 + pxor %xmm3,%xmm0 + movdqa %xmm0,%xmm1 + pshufd $78,%xmm0,%xmm3 + pshufd $78,%xmm2,%xmm4 + pxor %xmm0,%xmm3 + pxor %xmm2,%xmm4 +.byte 102,15,58,68,194,0 +.byte 102,15,58,68,202,17 +.byte 102,15,58,68,220,0 + xorps %xmm0,%xmm3 + xorps %xmm1,%xmm3 + movdqa %xmm3,%xmm4 + psrldq $8,%xmm3 + pslldq $8,%xmm4 + pxor %xmm3,%xmm1 + pxor %xmm4,%xmm0 + movdqa %xmm0,%xmm4 + movdqa %xmm0,%xmm3 + psllq $5,%xmm0 + pxor %xmm0,%xmm3 + psllq $1,%xmm0 + pxor %xmm3,%xmm0 + psllq $57,%xmm0 + movdqa %xmm0,%xmm3 + pslldq $8,%xmm0 + psrldq $8,%xmm3 + pxor %xmm4,%xmm0 + pxor %xmm3,%xmm1 + movdqa %xmm0,%xmm4 + psrlq $1,%xmm0 + pxor %xmm4,%xmm1 + pxor %xmm0,%xmm4 + psrlq $5,%xmm0 + pxor %xmm4,%xmm0 + psrlq $1,%xmm0 + pxor %xmm1,%xmm0 +.L005done: +.byte 102,15,56,0,197 + movdqu %xmm0,(%eax) + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.size gcm_ghash_clmul,.-.L_gcm_ghash_clmul_begin +.align 64 +.Lbswap: +.byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 +.byte 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,194 +.byte 71,72,65,83,72,32,102,111,114,32,120,56,54,44,32,67 +.byte 82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112 +.byte 112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62 +.byte 0 +#endif // !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) diff --git a/http/vendor/ring/pregenerated/ghash-x86-win32n.asm b/http/vendor/ring/pregenerated/ghash-x86-win32n.asm new file mode 100644 index 0000000..5b1cd80 --- /dev/null +++ b/http/vendor/ring/pregenerated/ghash-x86-win32n.asm @@ -0,0 +1,277 @@ +; This file is generated from a similarly-named Perl script in the BoringSSL +; source tree. Do not edit by hand. + +%include "ring_core_generated/prefix_symbols_nasm.inc" +%ifidn __OUTPUT_FORMAT__, win32 +%ifidn __OUTPUT_FORMAT__,obj +section code use32 class=code align=64 +%elifidn __OUTPUT_FORMAT__,win32 +$@feat.00 equ 1 +section .text code align=64 +%else +section .text code +%endif +global _gcm_init_clmul +align 16 +_gcm_init_clmul: +L$_gcm_init_clmul_begin: + mov edx,DWORD [4+esp] + mov eax,DWORD [8+esp] + call L$000pic +L$000pic: + pop ecx + lea ecx,[(L$bswap-L$000pic)+ecx] + movdqu xmm2,[eax] + pshufd xmm2,xmm2,78 + pshufd xmm4,xmm2,255 + movdqa xmm3,xmm2 + psllq xmm2,1 + pxor xmm5,xmm5 + psrlq xmm3,63 + pcmpgtd xmm5,xmm4 + pslldq xmm3,8 + por xmm2,xmm3 + pand xmm5,[16+ecx] + pxor xmm2,xmm5 + movdqa xmm0,xmm2 + movdqa xmm1,xmm0 + pshufd xmm3,xmm0,78 + pshufd xmm4,xmm2,78 + pxor xmm3,xmm0 + pxor xmm4,xmm2 +db 102,15,58,68,194,0 +db 102,15,58,68,202,17 +db 102,15,58,68,220,0 + xorps xmm3,xmm0 + xorps xmm3,xmm1 + movdqa xmm4,xmm3 + psrldq xmm3,8 + pslldq xmm4,8 + pxor xmm1,xmm3 + pxor xmm0,xmm4 + movdqa xmm4,xmm0 + movdqa xmm3,xmm0 + psllq xmm0,5 + pxor xmm3,xmm0 + psllq xmm0,1 + pxor xmm0,xmm3 + psllq xmm0,57 + movdqa xmm3,xmm0 + pslldq xmm0,8 + psrldq xmm3,8 + pxor xmm0,xmm4 + pxor xmm1,xmm3 + movdqa xmm4,xmm0 + psrlq xmm0,1 + pxor xmm1,xmm4 + pxor xmm4,xmm0 + psrlq xmm0,5 + pxor xmm0,xmm4 + psrlq xmm0,1 + pxor xmm0,xmm1 + pshufd xmm3,xmm2,78 + pshufd xmm4,xmm0,78 + pxor xmm3,xmm2 + movdqu [edx],xmm2 + pxor xmm4,xmm0 + movdqu [16+edx],xmm0 +db 102,15,58,15,227,8 + movdqu [32+edx],xmm4 + ret +global _gcm_ghash_clmul +align 16 +_gcm_ghash_clmul: +L$_gcm_ghash_clmul_begin: + push ebp + push ebx + push esi + push edi + mov eax,DWORD [20+esp] + mov edx,DWORD [24+esp] + mov esi,DWORD [28+esp] + mov ebx,DWORD [32+esp] + call L$001pic +L$001pic: + pop ecx + lea ecx,[(L$bswap-L$001pic)+ecx] + movdqu xmm0,[eax] + movdqa xmm5,[ecx] + movdqu xmm2,[edx] +db 102,15,56,0,197 + sub ebx,16 + jz NEAR L$002odd_tail + movdqu xmm3,[esi] + movdqu xmm6,[16+esi] +db 102,15,56,0,221 +db 102,15,56,0,245 + movdqu xmm5,[32+edx] + pxor xmm0,xmm3 + pshufd xmm3,xmm6,78 + movdqa xmm7,xmm6 + pxor xmm3,xmm6 + lea esi,[32+esi] +db 102,15,58,68,242,0 +db 102,15,58,68,250,17 +db 102,15,58,68,221,0 + movups xmm2,[16+edx] + nop + sub ebx,32 + jbe NEAR L$003even_tail + jmp NEAR L$004mod_loop +align 32 +L$004mod_loop: + pshufd xmm4,xmm0,78 + movdqa xmm1,xmm0 + pxor xmm4,xmm0 + nop +db 102,15,58,68,194,0 +db 102,15,58,68,202,17 +db 102,15,58,68,229,16 + movups xmm2,[edx] + xorps xmm0,xmm6 + movdqa xmm5,[ecx] + xorps xmm1,xmm7 + movdqu xmm7,[esi] + pxor xmm3,xmm0 + movdqu xmm6,[16+esi] + pxor xmm3,xmm1 +db 102,15,56,0,253 + pxor xmm4,xmm3 + movdqa xmm3,xmm4 + psrldq xmm4,8 + pslldq xmm3,8 + pxor xmm1,xmm4 + pxor xmm0,xmm3 +db 102,15,56,0,245 + pxor xmm1,xmm7 + movdqa xmm7,xmm6 + movdqa xmm4,xmm0 + movdqa xmm3,xmm0 + psllq xmm0,5 + pxor xmm3,xmm0 + psllq xmm0,1 + pxor xmm0,xmm3 +db 102,15,58,68,242,0 + movups xmm5,[32+edx] + psllq xmm0,57 + movdqa xmm3,xmm0 + pslldq xmm0,8 + psrldq xmm3,8 + pxor xmm0,xmm4 + pxor xmm1,xmm3 + pshufd xmm3,xmm7,78 + movdqa xmm4,xmm0 + psrlq xmm0,1 + pxor xmm3,xmm7 + pxor xmm1,xmm4 +db 102,15,58,68,250,17 + movups xmm2,[16+edx] + pxor xmm4,xmm0 + psrlq xmm0,5 + pxor xmm0,xmm4 + psrlq xmm0,1 + pxor xmm0,xmm1 +db 102,15,58,68,221,0 + lea esi,[32+esi] + sub ebx,32 + ja NEAR L$004mod_loop +L$003even_tail: + pshufd xmm4,xmm0,78 + movdqa xmm1,xmm0 + pxor xmm4,xmm0 +db 102,15,58,68,194,0 +db 102,15,58,68,202,17 +db 102,15,58,68,229,16 + movdqa xmm5,[ecx] + xorps xmm0,xmm6 + xorps xmm1,xmm7 + pxor xmm3,xmm0 + pxor xmm3,xmm1 + pxor xmm4,xmm3 + movdqa xmm3,xmm4 + psrldq xmm4,8 + pslldq xmm3,8 + pxor xmm1,xmm4 + pxor xmm0,xmm3 + movdqa xmm4,xmm0 + movdqa xmm3,xmm0 + psllq xmm0,5 + pxor xmm3,xmm0 + psllq xmm0,1 + pxor xmm0,xmm3 + psllq xmm0,57 + movdqa xmm3,xmm0 + pslldq xmm0,8 + psrldq xmm3,8 + pxor xmm0,xmm4 + pxor xmm1,xmm3 + movdqa xmm4,xmm0 + psrlq xmm0,1 + pxor xmm1,xmm4 + pxor xmm4,xmm0 + psrlq xmm0,5 + pxor xmm0,xmm4 + psrlq xmm0,1 + pxor xmm0,xmm1 + test ebx,ebx + jnz NEAR L$005done + movups xmm2,[edx] +L$002odd_tail: + movdqu xmm3,[esi] +db 102,15,56,0,221 + pxor xmm0,xmm3 + movdqa xmm1,xmm0 + pshufd xmm3,xmm0,78 + pshufd xmm4,xmm2,78 + pxor xmm3,xmm0 + pxor xmm4,xmm2 +db 102,15,58,68,194,0 +db 102,15,58,68,202,17 +db 102,15,58,68,220,0 + xorps xmm3,xmm0 + xorps xmm3,xmm1 + movdqa xmm4,xmm3 + psrldq xmm3,8 + pslldq xmm4,8 + pxor xmm1,xmm3 + pxor xmm0,xmm4 + movdqa xmm4,xmm0 + movdqa xmm3,xmm0 + psllq xmm0,5 + pxor xmm3,xmm0 + psllq xmm0,1 + pxor xmm0,xmm3 + psllq xmm0,57 + movdqa xmm3,xmm0 + pslldq xmm0,8 + psrldq xmm3,8 + pxor xmm0,xmm4 + pxor xmm1,xmm3 + movdqa xmm4,xmm0 + psrlq xmm0,1 + pxor xmm1,xmm4 + pxor xmm4,xmm0 + psrlq xmm0,5 + pxor xmm0,xmm4 + psrlq xmm0,1 + pxor xmm0,xmm1 +L$005done: +db 102,15,56,0,197 + movdqu [eax],xmm0 + pop edi + pop esi + pop ebx + pop ebp + ret +align 64 +L$bswap: +db 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 +db 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,194 +db 71,72,65,83,72,32,102,111,114,32,120,56,54,44,32,67 +db 82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112 +db 112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62 +db 0 +%else +; Work around https://bugzilla.nasm.us/show_bug.cgi?id=3392738 +ret +%endif diff --git a/http/vendor/ring/pregenerated/ghash-x86-win32n.o b/http/vendor/ring/pregenerated/ghash-x86-win32n.o new file mode 100644 index 0000000..f78a0eb Binary files /dev/null and b/http/vendor/ring/pregenerated/ghash-x86-win32n.o differ diff --git a/http/vendor/ring/pregenerated/ghash-x86_64-elf.S b/http/vendor/ring/pregenerated/ghash-x86_64-elf.S new file mode 100644 index 0000000..4c957b4 --- /dev/null +++ b/http/vendor/ring/pregenerated/ghash-x86_64-elf.S @@ -0,0 +1,1062 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__) +.text +.globl gcm_init_clmul +.hidden gcm_init_clmul +.type gcm_init_clmul,@function +.align 16 +gcm_init_clmul: +.cfi_startproc + +_CET_ENDBR +.L_init_clmul: + movdqu (%rsi),%xmm2 + pshufd $78,%xmm2,%xmm2 + + + pshufd $255,%xmm2,%xmm4 + movdqa %xmm2,%xmm3 + psllq $1,%xmm2 + pxor %xmm5,%xmm5 + psrlq $63,%xmm3 + pcmpgtd %xmm4,%xmm5 + pslldq $8,%xmm3 + por %xmm3,%xmm2 + + + pand .L0x1c2_polynomial(%rip),%xmm5 + pxor %xmm5,%xmm2 + + + pshufd $78,%xmm2,%xmm6 + movdqa %xmm2,%xmm0 + pxor %xmm2,%xmm6 + movdqa %xmm0,%xmm1 + pshufd $78,%xmm0,%xmm3 + pxor %xmm0,%xmm3 +.byte 102,15,58,68,194,0 +.byte 102,15,58,68,202,17 +.byte 102,15,58,68,222,0 + pxor %xmm0,%xmm3 + pxor %xmm1,%xmm3 + + movdqa %xmm3,%xmm4 + psrldq $8,%xmm3 + pslldq $8,%xmm4 + pxor %xmm3,%xmm1 + pxor %xmm4,%xmm0 + + movdqa %xmm0,%xmm4 + movdqa %xmm0,%xmm3 + psllq $5,%xmm0 + pxor %xmm0,%xmm3 + psllq $1,%xmm0 + pxor %xmm3,%xmm0 + psllq $57,%xmm0 + movdqa %xmm0,%xmm3 + pslldq $8,%xmm0 + psrldq $8,%xmm3 + pxor %xmm4,%xmm0 + pxor %xmm3,%xmm1 + + + movdqa %xmm0,%xmm4 + psrlq $1,%xmm0 + pxor %xmm4,%xmm1 + pxor %xmm0,%xmm4 + psrlq $5,%xmm0 + pxor %xmm4,%xmm0 + psrlq $1,%xmm0 + pxor %xmm1,%xmm0 + pshufd $78,%xmm2,%xmm3 + pshufd $78,%xmm0,%xmm4 + pxor %xmm2,%xmm3 + movdqu %xmm2,0(%rdi) + pxor %xmm0,%xmm4 + movdqu %xmm0,16(%rdi) +.byte 102,15,58,15,227,8 + movdqu %xmm4,32(%rdi) + movdqa %xmm0,%xmm1 + pshufd $78,%xmm0,%xmm3 + pxor %xmm0,%xmm3 +.byte 102,15,58,68,194,0 +.byte 102,15,58,68,202,17 +.byte 102,15,58,68,222,0 + pxor %xmm0,%xmm3 + pxor %xmm1,%xmm3 + + movdqa %xmm3,%xmm4 + psrldq $8,%xmm3 + pslldq $8,%xmm4 + pxor %xmm3,%xmm1 + pxor %xmm4,%xmm0 + + movdqa %xmm0,%xmm4 + movdqa %xmm0,%xmm3 + psllq $5,%xmm0 + pxor %xmm0,%xmm3 + psllq $1,%xmm0 + pxor %xmm3,%xmm0 + psllq $57,%xmm0 + movdqa %xmm0,%xmm3 + pslldq $8,%xmm0 + psrldq $8,%xmm3 + pxor %xmm4,%xmm0 + pxor %xmm3,%xmm1 + + + movdqa %xmm0,%xmm4 + psrlq $1,%xmm0 + pxor %xmm4,%xmm1 + pxor %xmm0,%xmm4 + psrlq $5,%xmm0 + pxor %xmm4,%xmm0 + psrlq $1,%xmm0 + pxor %xmm1,%xmm0 + movdqa %xmm0,%xmm5 + movdqa %xmm0,%xmm1 + pshufd $78,%xmm0,%xmm3 + pxor %xmm0,%xmm3 +.byte 102,15,58,68,194,0 +.byte 102,15,58,68,202,17 +.byte 102,15,58,68,222,0 + pxor %xmm0,%xmm3 + pxor %xmm1,%xmm3 + + movdqa %xmm3,%xmm4 + psrldq $8,%xmm3 + pslldq $8,%xmm4 + pxor %xmm3,%xmm1 + pxor %xmm4,%xmm0 + + movdqa %xmm0,%xmm4 + movdqa %xmm0,%xmm3 + psllq $5,%xmm0 + pxor %xmm0,%xmm3 + psllq $1,%xmm0 + pxor %xmm3,%xmm0 + psllq $57,%xmm0 + movdqa %xmm0,%xmm3 + pslldq $8,%xmm0 + psrldq $8,%xmm3 + pxor %xmm4,%xmm0 + pxor %xmm3,%xmm1 + + + movdqa %xmm0,%xmm4 + psrlq $1,%xmm0 + pxor %xmm4,%xmm1 + pxor %xmm0,%xmm4 + psrlq $5,%xmm0 + pxor %xmm4,%xmm0 + psrlq $1,%xmm0 + pxor %xmm1,%xmm0 + pshufd $78,%xmm5,%xmm3 + pshufd $78,%xmm0,%xmm4 + pxor %xmm5,%xmm3 + movdqu %xmm5,48(%rdi) + pxor %xmm0,%xmm4 + movdqu %xmm0,64(%rdi) +.byte 102,15,58,15,227,8 + movdqu %xmm4,80(%rdi) + ret +.cfi_endproc + +.size gcm_init_clmul,.-gcm_init_clmul +.globl gcm_ghash_clmul +.hidden gcm_ghash_clmul +.type gcm_ghash_clmul,@function +.align 32 +gcm_ghash_clmul: +.cfi_startproc + +_CET_ENDBR +.L_ghash_clmul: + movdqa .Lbswap_mask(%rip),%xmm10 + + movdqu (%rdi),%xmm0 + movdqu (%rsi),%xmm2 + movdqu 32(%rsi),%xmm7 +.byte 102,65,15,56,0,194 + + subq $0x10,%rcx + jz .Lodd_tail + + movdqu 16(%rsi),%xmm6 + cmpq $0x30,%rcx + jb .Lskip4x + + subq $0x30,%rcx + movq $0xA040608020C0E000,%rax + movdqu 48(%rsi),%xmm14 + movdqu 64(%rsi),%xmm15 + + + + + movdqu 48(%rdx),%xmm3 + movdqu 32(%rdx),%xmm11 +.byte 102,65,15,56,0,218 +.byte 102,69,15,56,0,218 + movdqa %xmm3,%xmm5 + pshufd $78,%xmm3,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,68,218,0 +.byte 102,15,58,68,234,17 +.byte 102,15,58,68,231,0 + + movdqa %xmm11,%xmm13 + pshufd $78,%xmm11,%xmm12 + pxor %xmm11,%xmm12 +.byte 102,68,15,58,68,222,0 +.byte 102,68,15,58,68,238,17 +.byte 102,68,15,58,68,231,16 + xorps %xmm11,%xmm3 + xorps %xmm13,%xmm5 + movups 80(%rsi),%xmm7 + xorps %xmm12,%xmm4 + + movdqu 16(%rdx),%xmm11 + movdqu 0(%rdx),%xmm8 +.byte 102,69,15,56,0,218 +.byte 102,69,15,56,0,194 + movdqa %xmm11,%xmm13 + pshufd $78,%xmm11,%xmm12 + pxor %xmm8,%xmm0 + pxor %xmm11,%xmm12 +.byte 102,69,15,58,68,222,0 + movdqa %xmm0,%xmm1 + pshufd $78,%xmm0,%xmm8 + pxor %xmm0,%xmm8 +.byte 102,69,15,58,68,238,17 +.byte 102,68,15,58,68,231,0 + xorps %xmm11,%xmm3 + xorps %xmm13,%xmm5 + + leaq 64(%rdx),%rdx + subq $0x40,%rcx + jc .Ltail4x + + jmp .Lmod4_loop +.align 32 +.Lmod4_loop: +.byte 102,65,15,58,68,199,0 + xorps %xmm12,%xmm4 + movdqu 48(%rdx),%xmm11 +.byte 102,69,15,56,0,218 +.byte 102,65,15,58,68,207,17 + xorps %xmm3,%xmm0 + movdqu 32(%rdx),%xmm3 + movdqa %xmm11,%xmm13 +.byte 102,68,15,58,68,199,16 + pshufd $78,%xmm11,%xmm12 + xorps %xmm5,%xmm1 + pxor %xmm11,%xmm12 +.byte 102,65,15,56,0,218 + movups 32(%rsi),%xmm7 + xorps %xmm4,%xmm8 +.byte 102,68,15,58,68,218,0 + pshufd $78,%xmm3,%xmm4 + + pxor %xmm0,%xmm8 + movdqa %xmm3,%xmm5 + pxor %xmm1,%xmm8 + pxor %xmm3,%xmm4 + movdqa %xmm8,%xmm9 +.byte 102,68,15,58,68,234,17 + pslldq $8,%xmm8 + psrldq $8,%xmm9 + pxor %xmm8,%xmm0 + movdqa .L7_mask(%rip),%xmm8 + pxor %xmm9,%xmm1 +.byte 102,76,15,110,200 + + pand %xmm0,%xmm8 +.byte 102,69,15,56,0,200 + pxor %xmm0,%xmm9 +.byte 102,68,15,58,68,231,0 + psllq $57,%xmm9 + movdqa %xmm9,%xmm8 + pslldq $8,%xmm9 +.byte 102,15,58,68,222,0 + psrldq $8,%xmm8 + pxor %xmm9,%xmm0 + pxor %xmm8,%xmm1 + movdqu 0(%rdx),%xmm8 + + movdqa %xmm0,%xmm9 + psrlq $1,%xmm0 +.byte 102,15,58,68,238,17 + xorps %xmm11,%xmm3 + movdqu 16(%rdx),%xmm11 +.byte 102,69,15,56,0,218 +.byte 102,15,58,68,231,16 + xorps %xmm13,%xmm5 + movups 80(%rsi),%xmm7 +.byte 102,69,15,56,0,194 + pxor %xmm9,%xmm1 + pxor %xmm0,%xmm9 + psrlq $5,%xmm0 + + movdqa %xmm11,%xmm13 + pxor %xmm12,%xmm4 + pshufd $78,%xmm11,%xmm12 + pxor %xmm9,%xmm0 + pxor %xmm8,%xmm1 + pxor %xmm11,%xmm12 +.byte 102,69,15,58,68,222,0 + psrlq $1,%xmm0 + pxor %xmm1,%xmm0 + movdqa %xmm0,%xmm1 +.byte 102,69,15,58,68,238,17 + xorps %xmm11,%xmm3 + pshufd $78,%xmm0,%xmm8 + pxor %xmm0,%xmm8 + +.byte 102,68,15,58,68,231,0 + xorps %xmm13,%xmm5 + + leaq 64(%rdx),%rdx + subq $0x40,%rcx + jnc .Lmod4_loop + +.Ltail4x: +.byte 102,65,15,58,68,199,0 +.byte 102,65,15,58,68,207,17 +.byte 102,68,15,58,68,199,16 + xorps %xmm12,%xmm4 + xorps %xmm3,%xmm0 + xorps %xmm5,%xmm1 + pxor %xmm0,%xmm1 + pxor %xmm4,%xmm8 + + pxor %xmm1,%xmm8 + pxor %xmm0,%xmm1 + + movdqa %xmm8,%xmm9 + psrldq $8,%xmm8 + pslldq $8,%xmm9 + pxor %xmm8,%xmm1 + pxor %xmm9,%xmm0 + + movdqa %xmm0,%xmm4 + movdqa %xmm0,%xmm3 + psllq $5,%xmm0 + pxor %xmm0,%xmm3 + psllq $1,%xmm0 + pxor %xmm3,%xmm0 + psllq $57,%xmm0 + movdqa %xmm0,%xmm3 + pslldq $8,%xmm0 + psrldq $8,%xmm3 + pxor %xmm4,%xmm0 + pxor %xmm3,%xmm1 + + + movdqa %xmm0,%xmm4 + psrlq $1,%xmm0 + pxor %xmm4,%xmm1 + pxor %xmm0,%xmm4 + psrlq $5,%xmm0 + pxor %xmm4,%xmm0 + psrlq $1,%xmm0 + pxor %xmm1,%xmm0 + addq $0x40,%rcx + jz .Ldone + movdqu 32(%rsi),%xmm7 + subq $0x10,%rcx + jz .Lodd_tail +.Lskip4x: + + + + + + movdqu (%rdx),%xmm8 + movdqu 16(%rdx),%xmm3 +.byte 102,69,15,56,0,194 +.byte 102,65,15,56,0,218 + pxor %xmm8,%xmm0 + + movdqa %xmm3,%xmm5 + pshufd $78,%xmm3,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,68,218,0 +.byte 102,15,58,68,234,17 +.byte 102,15,58,68,231,0 + + leaq 32(%rdx),%rdx + nop + subq $0x20,%rcx + jbe .Leven_tail + nop + jmp .Lmod_loop + +.align 32 +.Lmod_loop: + movdqa %xmm0,%xmm1 + movdqa %xmm4,%xmm8 + pshufd $78,%xmm0,%xmm4 + pxor %xmm0,%xmm4 + +.byte 102,15,58,68,198,0 +.byte 102,15,58,68,206,17 +.byte 102,15,58,68,231,16 + + pxor %xmm3,%xmm0 + pxor %xmm5,%xmm1 + movdqu (%rdx),%xmm9 + pxor %xmm0,%xmm8 +.byte 102,69,15,56,0,202 + movdqu 16(%rdx),%xmm3 + + pxor %xmm1,%xmm8 + pxor %xmm9,%xmm1 + pxor %xmm8,%xmm4 +.byte 102,65,15,56,0,218 + movdqa %xmm4,%xmm8 + psrldq $8,%xmm8 + pslldq $8,%xmm4 + pxor %xmm8,%xmm1 + pxor %xmm4,%xmm0 + + movdqa %xmm3,%xmm5 + + movdqa %xmm0,%xmm9 + movdqa %xmm0,%xmm8 + psllq $5,%xmm0 + pxor %xmm0,%xmm8 +.byte 102,15,58,68,218,0 + psllq $1,%xmm0 + pxor %xmm8,%xmm0 + psllq $57,%xmm0 + movdqa %xmm0,%xmm8 + pslldq $8,%xmm0 + psrldq $8,%xmm8 + pxor %xmm9,%xmm0 + pshufd $78,%xmm5,%xmm4 + pxor %xmm8,%xmm1 + pxor %xmm5,%xmm4 + + movdqa %xmm0,%xmm9 + psrlq $1,%xmm0 +.byte 102,15,58,68,234,17 + pxor %xmm9,%xmm1 + pxor %xmm0,%xmm9 + psrlq $5,%xmm0 + pxor %xmm9,%xmm0 + leaq 32(%rdx),%rdx + psrlq $1,%xmm0 +.byte 102,15,58,68,231,0 + pxor %xmm1,%xmm0 + + subq $0x20,%rcx + ja .Lmod_loop + +.Leven_tail: + movdqa %xmm0,%xmm1 + movdqa %xmm4,%xmm8 + pshufd $78,%xmm0,%xmm4 + pxor %xmm0,%xmm4 + +.byte 102,15,58,68,198,0 +.byte 102,15,58,68,206,17 +.byte 102,15,58,68,231,16 + + pxor %xmm3,%xmm0 + pxor %xmm5,%xmm1 + pxor %xmm0,%xmm8 + pxor %xmm1,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm8 + psrldq $8,%xmm8 + pslldq $8,%xmm4 + pxor %xmm8,%xmm1 + pxor %xmm4,%xmm0 + + movdqa %xmm0,%xmm4 + movdqa %xmm0,%xmm3 + psllq $5,%xmm0 + pxor %xmm0,%xmm3 + psllq $1,%xmm0 + pxor %xmm3,%xmm0 + psllq $57,%xmm0 + movdqa %xmm0,%xmm3 + pslldq $8,%xmm0 + psrldq $8,%xmm3 + pxor %xmm4,%xmm0 + pxor %xmm3,%xmm1 + + + movdqa %xmm0,%xmm4 + psrlq $1,%xmm0 + pxor %xmm4,%xmm1 + pxor %xmm0,%xmm4 + psrlq $5,%xmm0 + pxor %xmm4,%xmm0 + psrlq $1,%xmm0 + pxor %xmm1,%xmm0 + testq %rcx,%rcx + jnz .Ldone + +.Lodd_tail: + movdqu (%rdx),%xmm8 +.byte 102,69,15,56,0,194 + pxor %xmm8,%xmm0 + movdqa %xmm0,%xmm1 + pshufd $78,%xmm0,%xmm3 + pxor %xmm0,%xmm3 +.byte 102,15,58,68,194,0 +.byte 102,15,58,68,202,17 +.byte 102,15,58,68,223,0 + pxor %xmm0,%xmm3 + pxor %xmm1,%xmm3 + + movdqa %xmm3,%xmm4 + psrldq $8,%xmm3 + pslldq $8,%xmm4 + pxor %xmm3,%xmm1 + pxor %xmm4,%xmm0 + + movdqa %xmm0,%xmm4 + movdqa %xmm0,%xmm3 + psllq $5,%xmm0 + pxor %xmm0,%xmm3 + psllq $1,%xmm0 + pxor %xmm3,%xmm0 + psllq $57,%xmm0 + movdqa %xmm0,%xmm3 + pslldq $8,%xmm0 + psrldq $8,%xmm3 + pxor %xmm4,%xmm0 + pxor %xmm3,%xmm1 + + + movdqa %xmm0,%xmm4 + psrlq $1,%xmm0 + pxor %xmm4,%xmm1 + pxor %xmm0,%xmm4 + psrlq $5,%xmm0 + pxor %xmm4,%xmm0 + psrlq $1,%xmm0 + pxor %xmm1,%xmm0 +.Ldone: +.byte 102,65,15,56,0,194 + movdqu %xmm0,(%rdi) + ret +.cfi_endproc + +.size gcm_ghash_clmul,.-gcm_ghash_clmul +.globl gcm_init_avx +.hidden gcm_init_avx +.type gcm_init_avx,@function +.align 32 +gcm_init_avx: +.cfi_startproc + +_CET_ENDBR + vzeroupper + + vmovdqu (%rsi),%xmm2 + vpshufd $78,%xmm2,%xmm2 + + + vpshufd $255,%xmm2,%xmm4 + vpsrlq $63,%xmm2,%xmm3 + vpsllq $1,%xmm2,%xmm2 + vpxor %xmm5,%xmm5,%xmm5 + vpcmpgtd %xmm4,%xmm5,%xmm5 + vpslldq $8,%xmm3,%xmm3 + vpor %xmm3,%xmm2,%xmm2 + + + vpand .L0x1c2_polynomial(%rip),%xmm5,%xmm5 + vpxor %xmm5,%xmm2,%xmm2 + + vpunpckhqdq %xmm2,%xmm2,%xmm6 + vmovdqa %xmm2,%xmm0 + vpxor %xmm2,%xmm6,%xmm6 + movq $4,%r10 + jmp .Linit_start_avx +.align 32 +.Linit_loop_avx: + vpalignr $8,%xmm3,%xmm4,%xmm5 + vmovdqu %xmm5,-16(%rdi) + vpunpckhqdq %xmm0,%xmm0,%xmm3 + vpxor %xmm0,%xmm3,%xmm3 + vpclmulqdq $0x11,%xmm2,%xmm0,%xmm1 + vpclmulqdq $0x00,%xmm2,%xmm0,%xmm0 + vpclmulqdq $0x00,%xmm6,%xmm3,%xmm3 + vpxor %xmm0,%xmm1,%xmm4 + vpxor %xmm4,%xmm3,%xmm3 + + vpslldq $8,%xmm3,%xmm4 + vpsrldq $8,%xmm3,%xmm3 + vpxor %xmm4,%xmm0,%xmm0 + vpxor %xmm3,%xmm1,%xmm1 + vpsllq $57,%xmm0,%xmm3 + vpsllq $62,%xmm0,%xmm4 + vpxor %xmm3,%xmm4,%xmm4 + vpsllq $63,%xmm0,%xmm3 + vpxor %xmm3,%xmm4,%xmm4 + vpslldq $8,%xmm4,%xmm3 + vpsrldq $8,%xmm4,%xmm4 + vpxor %xmm3,%xmm0,%xmm0 + vpxor %xmm4,%xmm1,%xmm1 + + vpsrlq $1,%xmm0,%xmm4 + vpxor %xmm0,%xmm1,%xmm1 + vpxor %xmm4,%xmm0,%xmm0 + vpsrlq $5,%xmm4,%xmm4 + vpxor %xmm4,%xmm0,%xmm0 + vpsrlq $1,%xmm0,%xmm0 + vpxor %xmm1,%xmm0,%xmm0 +.Linit_start_avx: + vmovdqa %xmm0,%xmm5 + vpunpckhqdq %xmm0,%xmm0,%xmm3 + vpxor %xmm0,%xmm3,%xmm3 + vpclmulqdq $0x11,%xmm2,%xmm0,%xmm1 + vpclmulqdq $0x00,%xmm2,%xmm0,%xmm0 + vpclmulqdq $0x00,%xmm6,%xmm3,%xmm3 + vpxor %xmm0,%xmm1,%xmm4 + vpxor %xmm4,%xmm3,%xmm3 + + vpslldq $8,%xmm3,%xmm4 + vpsrldq $8,%xmm3,%xmm3 + vpxor %xmm4,%xmm0,%xmm0 + vpxor %xmm3,%xmm1,%xmm1 + vpsllq $57,%xmm0,%xmm3 + vpsllq $62,%xmm0,%xmm4 + vpxor %xmm3,%xmm4,%xmm4 + vpsllq $63,%xmm0,%xmm3 + vpxor %xmm3,%xmm4,%xmm4 + vpslldq $8,%xmm4,%xmm3 + vpsrldq $8,%xmm4,%xmm4 + vpxor %xmm3,%xmm0,%xmm0 + vpxor %xmm4,%xmm1,%xmm1 + + vpsrlq $1,%xmm0,%xmm4 + vpxor %xmm0,%xmm1,%xmm1 + vpxor %xmm4,%xmm0,%xmm0 + vpsrlq $5,%xmm4,%xmm4 + vpxor %xmm4,%xmm0,%xmm0 + vpsrlq $1,%xmm0,%xmm0 + vpxor %xmm1,%xmm0,%xmm0 + vpshufd $78,%xmm5,%xmm3 + vpshufd $78,%xmm0,%xmm4 + vpxor %xmm5,%xmm3,%xmm3 + vmovdqu %xmm5,0(%rdi) + vpxor %xmm0,%xmm4,%xmm4 + vmovdqu %xmm0,16(%rdi) + leaq 48(%rdi),%rdi + subq $1,%r10 + jnz .Linit_loop_avx + + vpalignr $8,%xmm4,%xmm3,%xmm5 + vmovdqu %xmm5,-16(%rdi) + + vzeroupper + ret + +.cfi_endproc +.size gcm_init_avx,.-gcm_init_avx +.globl gcm_ghash_avx +.hidden gcm_ghash_avx +.type gcm_ghash_avx,@function +.align 32 +gcm_ghash_avx: +.cfi_startproc + +_CET_ENDBR + vzeroupper + + vmovdqu (%rdi),%xmm10 + leaq .L0x1c2_polynomial(%rip),%r10 + leaq 64(%rsi),%rsi + vmovdqu .Lbswap_mask(%rip),%xmm13 + vpshufb %xmm13,%xmm10,%xmm10 + cmpq $0x80,%rcx + jb .Lshort_avx + subq $0x80,%rcx + + vmovdqu 112(%rdx),%xmm14 + vmovdqu 0-64(%rsi),%xmm6 + vpshufb %xmm13,%xmm14,%xmm14 + vmovdqu 32-64(%rsi),%xmm7 + + vpunpckhqdq %xmm14,%xmm14,%xmm9 + vmovdqu 96(%rdx),%xmm15 + vpclmulqdq $0x00,%xmm6,%xmm14,%xmm0 + vpxor %xmm14,%xmm9,%xmm9 + vpshufb %xmm13,%xmm15,%xmm15 + vpclmulqdq $0x11,%xmm6,%xmm14,%xmm1 + vmovdqu 16-64(%rsi),%xmm6 + vpunpckhqdq %xmm15,%xmm15,%xmm8 + vmovdqu 80(%rdx),%xmm14 + vpclmulqdq $0x00,%xmm7,%xmm9,%xmm2 + vpxor %xmm15,%xmm8,%xmm8 + + vpshufb %xmm13,%xmm14,%xmm14 + vpclmulqdq $0x00,%xmm6,%xmm15,%xmm3 + vpunpckhqdq %xmm14,%xmm14,%xmm9 + vpclmulqdq $0x11,%xmm6,%xmm15,%xmm4 + vmovdqu 48-64(%rsi),%xmm6 + vpxor %xmm14,%xmm9,%xmm9 + vmovdqu 64(%rdx),%xmm15 + vpclmulqdq $0x10,%xmm7,%xmm8,%xmm5 + vmovdqu 80-64(%rsi),%xmm7 + + vpshufb %xmm13,%xmm15,%xmm15 + vpxor %xmm0,%xmm3,%xmm3 + vpclmulqdq $0x00,%xmm6,%xmm14,%xmm0 + vpxor %xmm1,%xmm4,%xmm4 + vpunpckhqdq %xmm15,%xmm15,%xmm8 + vpclmulqdq $0x11,%xmm6,%xmm14,%xmm1 + vmovdqu 64-64(%rsi),%xmm6 + vpxor %xmm2,%xmm5,%xmm5 + vpclmulqdq $0x00,%xmm7,%xmm9,%xmm2 + vpxor %xmm15,%xmm8,%xmm8 + + vmovdqu 48(%rdx),%xmm14 + vpxor %xmm3,%xmm0,%xmm0 + vpclmulqdq $0x00,%xmm6,%xmm15,%xmm3 + vpxor %xmm4,%xmm1,%xmm1 + vpshufb %xmm13,%xmm14,%xmm14 + vpclmulqdq $0x11,%xmm6,%xmm15,%xmm4 + vmovdqu 96-64(%rsi),%xmm6 + vpxor %xmm5,%xmm2,%xmm2 + vpunpckhqdq %xmm14,%xmm14,%xmm9 + vpclmulqdq $0x10,%xmm7,%xmm8,%xmm5 + vmovdqu 128-64(%rsi),%xmm7 + vpxor %xmm14,%xmm9,%xmm9 + + vmovdqu 32(%rdx),%xmm15 + vpxor %xmm0,%xmm3,%xmm3 + vpclmulqdq $0x00,%xmm6,%xmm14,%xmm0 + vpxor %xmm1,%xmm4,%xmm4 + vpshufb %xmm13,%xmm15,%xmm15 + vpclmulqdq $0x11,%xmm6,%xmm14,%xmm1 + vmovdqu 112-64(%rsi),%xmm6 + vpxor %xmm2,%xmm5,%xmm5 + vpunpckhqdq %xmm15,%xmm15,%xmm8 + vpclmulqdq $0x00,%xmm7,%xmm9,%xmm2 + vpxor %xmm15,%xmm8,%xmm8 + + vmovdqu 16(%rdx),%xmm14 + vpxor %xmm3,%xmm0,%xmm0 + vpclmulqdq $0x00,%xmm6,%xmm15,%xmm3 + vpxor %xmm4,%xmm1,%xmm1 + vpshufb %xmm13,%xmm14,%xmm14 + vpclmulqdq $0x11,%xmm6,%xmm15,%xmm4 + vmovdqu 144-64(%rsi),%xmm6 + vpxor %xmm5,%xmm2,%xmm2 + vpunpckhqdq %xmm14,%xmm14,%xmm9 + vpclmulqdq $0x10,%xmm7,%xmm8,%xmm5 + vmovdqu 176-64(%rsi),%xmm7 + vpxor %xmm14,%xmm9,%xmm9 + + vmovdqu (%rdx),%xmm15 + vpxor %xmm0,%xmm3,%xmm3 + vpclmulqdq $0x00,%xmm6,%xmm14,%xmm0 + vpxor %xmm1,%xmm4,%xmm4 + vpshufb %xmm13,%xmm15,%xmm15 + vpclmulqdq $0x11,%xmm6,%xmm14,%xmm1 + vmovdqu 160-64(%rsi),%xmm6 + vpxor %xmm2,%xmm5,%xmm5 + vpclmulqdq $0x10,%xmm7,%xmm9,%xmm2 + + leaq 128(%rdx),%rdx + cmpq $0x80,%rcx + jb .Ltail_avx + + vpxor %xmm10,%xmm15,%xmm15 + subq $0x80,%rcx + jmp .Loop8x_avx + +.align 32 +.Loop8x_avx: + vpunpckhqdq %xmm15,%xmm15,%xmm8 + vmovdqu 112(%rdx),%xmm14 + vpxor %xmm0,%xmm3,%xmm3 + vpxor %xmm15,%xmm8,%xmm8 + vpclmulqdq $0x00,%xmm6,%xmm15,%xmm10 + vpshufb %xmm13,%xmm14,%xmm14 + vpxor %xmm1,%xmm4,%xmm4 + vpclmulqdq $0x11,%xmm6,%xmm15,%xmm11 + vmovdqu 0-64(%rsi),%xmm6 + vpunpckhqdq %xmm14,%xmm14,%xmm9 + vpxor %xmm2,%xmm5,%xmm5 + vpclmulqdq $0x00,%xmm7,%xmm8,%xmm12 + vmovdqu 32-64(%rsi),%xmm7 + vpxor %xmm14,%xmm9,%xmm9 + + vmovdqu 96(%rdx),%xmm15 + vpclmulqdq $0x00,%xmm6,%xmm14,%xmm0 + vpxor %xmm3,%xmm10,%xmm10 + vpshufb %xmm13,%xmm15,%xmm15 + vpclmulqdq $0x11,%xmm6,%xmm14,%xmm1 + vxorps %xmm4,%xmm11,%xmm11 + vmovdqu 16-64(%rsi),%xmm6 + vpunpckhqdq %xmm15,%xmm15,%xmm8 + vpclmulqdq $0x00,%xmm7,%xmm9,%xmm2 + vpxor %xmm5,%xmm12,%xmm12 + vxorps %xmm15,%xmm8,%xmm8 + + vmovdqu 80(%rdx),%xmm14 + vpxor %xmm10,%xmm12,%xmm12 + vpclmulqdq $0x00,%xmm6,%xmm15,%xmm3 + vpxor %xmm11,%xmm12,%xmm12 + vpslldq $8,%xmm12,%xmm9 + vpxor %xmm0,%xmm3,%xmm3 + vpclmulqdq $0x11,%xmm6,%xmm15,%xmm4 + vpsrldq $8,%xmm12,%xmm12 + vpxor %xmm9,%xmm10,%xmm10 + vmovdqu 48-64(%rsi),%xmm6 + vpshufb %xmm13,%xmm14,%xmm14 + vxorps %xmm12,%xmm11,%xmm11 + vpxor %xmm1,%xmm4,%xmm4 + vpunpckhqdq %xmm14,%xmm14,%xmm9 + vpclmulqdq $0x10,%xmm7,%xmm8,%xmm5 + vmovdqu 80-64(%rsi),%xmm7 + vpxor %xmm14,%xmm9,%xmm9 + vpxor %xmm2,%xmm5,%xmm5 + + vmovdqu 64(%rdx),%xmm15 + vpalignr $8,%xmm10,%xmm10,%xmm12 + vpclmulqdq $0x00,%xmm6,%xmm14,%xmm0 + vpshufb %xmm13,%xmm15,%xmm15 + vpxor %xmm3,%xmm0,%xmm0 + vpclmulqdq $0x11,%xmm6,%xmm14,%xmm1 + vmovdqu 64-64(%rsi),%xmm6 + vpunpckhqdq %xmm15,%xmm15,%xmm8 + vpxor %xmm4,%xmm1,%xmm1 + vpclmulqdq $0x00,%xmm7,%xmm9,%xmm2 + vxorps %xmm15,%xmm8,%xmm8 + vpxor %xmm5,%xmm2,%xmm2 + + vmovdqu 48(%rdx),%xmm14 + vpclmulqdq $0x10,(%r10),%xmm10,%xmm10 + vpclmulqdq $0x00,%xmm6,%xmm15,%xmm3 + vpshufb %xmm13,%xmm14,%xmm14 + vpxor %xmm0,%xmm3,%xmm3 + vpclmulqdq $0x11,%xmm6,%xmm15,%xmm4 + vmovdqu 96-64(%rsi),%xmm6 + vpunpckhqdq %xmm14,%xmm14,%xmm9 + vpxor %xmm1,%xmm4,%xmm4 + vpclmulqdq $0x10,%xmm7,%xmm8,%xmm5 + vmovdqu 128-64(%rsi),%xmm7 + vpxor %xmm14,%xmm9,%xmm9 + vpxor %xmm2,%xmm5,%xmm5 + + vmovdqu 32(%rdx),%xmm15 + vpclmulqdq $0x00,%xmm6,%xmm14,%xmm0 + vpshufb %xmm13,%xmm15,%xmm15 + vpxor %xmm3,%xmm0,%xmm0 + vpclmulqdq $0x11,%xmm6,%xmm14,%xmm1 + vmovdqu 112-64(%rsi),%xmm6 + vpunpckhqdq %xmm15,%xmm15,%xmm8 + vpxor %xmm4,%xmm1,%xmm1 + vpclmulqdq $0x00,%xmm7,%xmm9,%xmm2 + vpxor %xmm15,%xmm8,%xmm8 + vpxor %xmm5,%xmm2,%xmm2 + vxorps %xmm12,%xmm10,%xmm10 + + vmovdqu 16(%rdx),%xmm14 + vpalignr $8,%xmm10,%xmm10,%xmm12 + vpclmulqdq $0x00,%xmm6,%xmm15,%xmm3 + vpshufb %xmm13,%xmm14,%xmm14 + vpxor %xmm0,%xmm3,%xmm3 + vpclmulqdq $0x11,%xmm6,%xmm15,%xmm4 + vmovdqu 144-64(%rsi),%xmm6 + vpclmulqdq $0x10,(%r10),%xmm10,%xmm10 + vxorps %xmm11,%xmm12,%xmm12 + vpunpckhqdq %xmm14,%xmm14,%xmm9 + vpxor %xmm1,%xmm4,%xmm4 + vpclmulqdq $0x10,%xmm7,%xmm8,%xmm5 + vmovdqu 176-64(%rsi),%xmm7 + vpxor %xmm14,%xmm9,%xmm9 + vpxor %xmm2,%xmm5,%xmm5 + + vmovdqu (%rdx),%xmm15 + vpclmulqdq $0x00,%xmm6,%xmm14,%xmm0 + vpshufb %xmm13,%xmm15,%xmm15 + vpclmulqdq $0x11,%xmm6,%xmm14,%xmm1 + vmovdqu 160-64(%rsi),%xmm6 + vpxor %xmm12,%xmm15,%xmm15 + vpclmulqdq $0x10,%xmm7,%xmm9,%xmm2 + vpxor %xmm10,%xmm15,%xmm15 + + leaq 128(%rdx),%rdx + subq $0x80,%rcx + jnc .Loop8x_avx + + addq $0x80,%rcx + jmp .Ltail_no_xor_avx + +.align 32 +.Lshort_avx: + vmovdqu -16(%rdx,%rcx,1),%xmm14 + leaq (%rdx,%rcx,1),%rdx + vmovdqu 0-64(%rsi),%xmm6 + vmovdqu 32-64(%rsi),%xmm7 + vpshufb %xmm13,%xmm14,%xmm15 + + vmovdqa %xmm0,%xmm3 + vmovdqa %xmm1,%xmm4 + vmovdqa %xmm2,%xmm5 + subq $0x10,%rcx + jz .Ltail_avx + + vpunpckhqdq %xmm15,%xmm15,%xmm8 + vpxor %xmm0,%xmm3,%xmm3 + vpclmulqdq $0x00,%xmm6,%xmm15,%xmm0 + vpxor %xmm15,%xmm8,%xmm8 + vmovdqu -32(%rdx),%xmm14 + vpxor %xmm1,%xmm4,%xmm4 + vpclmulqdq $0x11,%xmm6,%xmm15,%xmm1 + vmovdqu 16-64(%rsi),%xmm6 + vpshufb %xmm13,%xmm14,%xmm15 + vpxor %xmm2,%xmm5,%xmm5 + vpclmulqdq $0x00,%xmm7,%xmm8,%xmm2 + vpsrldq $8,%xmm7,%xmm7 + subq $0x10,%rcx + jz .Ltail_avx + + vpunpckhqdq %xmm15,%xmm15,%xmm8 + vpxor %xmm0,%xmm3,%xmm3 + vpclmulqdq $0x00,%xmm6,%xmm15,%xmm0 + vpxor %xmm15,%xmm8,%xmm8 + vmovdqu -48(%rdx),%xmm14 + vpxor %xmm1,%xmm4,%xmm4 + vpclmulqdq $0x11,%xmm6,%xmm15,%xmm1 + vmovdqu 48-64(%rsi),%xmm6 + vpshufb %xmm13,%xmm14,%xmm15 + vpxor %xmm2,%xmm5,%xmm5 + vpclmulqdq $0x00,%xmm7,%xmm8,%xmm2 + vmovdqu 80-64(%rsi),%xmm7 + subq $0x10,%rcx + jz .Ltail_avx + + vpunpckhqdq %xmm15,%xmm15,%xmm8 + vpxor %xmm0,%xmm3,%xmm3 + vpclmulqdq $0x00,%xmm6,%xmm15,%xmm0 + vpxor %xmm15,%xmm8,%xmm8 + vmovdqu -64(%rdx),%xmm14 + vpxor %xmm1,%xmm4,%xmm4 + vpclmulqdq $0x11,%xmm6,%xmm15,%xmm1 + vmovdqu 64-64(%rsi),%xmm6 + vpshufb %xmm13,%xmm14,%xmm15 + vpxor %xmm2,%xmm5,%xmm5 + vpclmulqdq $0x00,%xmm7,%xmm8,%xmm2 + vpsrldq $8,%xmm7,%xmm7 + subq $0x10,%rcx + jz .Ltail_avx + + vpunpckhqdq %xmm15,%xmm15,%xmm8 + vpxor %xmm0,%xmm3,%xmm3 + vpclmulqdq $0x00,%xmm6,%xmm15,%xmm0 + vpxor %xmm15,%xmm8,%xmm8 + vmovdqu -80(%rdx),%xmm14 + vpxor %xmm1,%xmm4,%xmm4 + vpclmulqdq $0x11,%xmm6,%xmm15,%xmm1 + vmovdqu 96-64(%rsi),%xmm6 + vpshufb %xmm13,%xmm14,%xmm15 + vpxor %xmm2,%xmm5,%xmm5 + vpclmulqdq $0x00,%xmm7,%xmm8,%xmm2 + vmovdqu 128-64(%rsi),%xmm7 + subq $0x10,%rcx + jz .Ltail_avx + + vpunpckhqdq %xmm15,%xmm15,%xmm8 + vpxor %xmm0,%xmm3,%xmm3 + vpclmulqdq $0x00,%xmm6,%xmm15,%xmm0 + vpxor %xmm15,%xmm8,%xmm8 + vmovdqu -96(%rdx),%xmm14 + vpxor %xmm1,%xmm4,%xmm4 + vpclmulqdq $0x11,%xmm6,%xmm15,%xmm1 + vmovdqu 112-64(%rsi),%xmm6 + vpshufb %xmm13,%xmm14,%xmm15 + vpxor %xmm2,%xmm5,%xmm5 + vpclmulqdq $0x00,%xmm7,%xmm8,%xmm2 + vpsrldq $8,%xmm7,%xmm7 + subq $0x10,%rcx + jz .Ltail_avx + + vpunpckhqdq %xmm15,%xmm15,%xmm8 + vpxor %xmm0,%xmm3,%xmm3 + vpclmulqdq $0x00,%xmm6,%xmm15,%xmm0 + vpxor %xmm15,%xmm8,%xmm8 + vmovdqu -112(%rdx),%xmm14 + vpxor %xmm1,%xmm4,%xmm4 + vpclmulqdq $0x11,%xmm6,%xmm15,%xmm1 + vmovdqu 144-64(%rsi),%xmm6 + vpshufb %xmm13,%xmm14,%xmm15 + vpxor %xmm2,%xmm5,%xmm5 + vpclmulqdq $0x00,%xmm7,%xmm8,%xmm2 + vmovq 184-64(%rsi),%xmm7 + subq $0x10,%rcx + jmp .Ltail_avx + +.align 32 +.Ltail_avx: + vpxor %xmm10,%xmm15,%xmm15 +.Ltail_no_xor_avx: + vpunpckhqdq %xmm15,%xmm15,%xmm8 + vpxor %xmm0,%xmm3,%xmm3 + vpclmulqdq $0x00,%xmm6,%xmm15,%xmm0 + vpxor %xmm15,%xmm8,%xmm8 + vpxor %xmm1,%xmm4,%xmm4 + vpclmulqdq $0x11,%xmm6,%xmm15,%xmm1 + vpxor %xmm2,%xmm5,%xmm5 + vpclmulqdq $0x00,%xmm7,%xmm8,%xmm2 + + vmovdqu (%r10),%xmm12 + + vpxor %xmm0,%xmm3,%xmm10 + vpxor %xmm1,%xmm4,%xmm11 + vpxor %xmm2,%xmm5,%xmm5 + + vpxor %xmm10,%xmm5,%xmm5 + vpxor %xmm11,%xmm5,%xmm5 + vpslldq $8,%xmm5,%xmm9 + vpsrldq $8,%xmm5,%xmm5 + vpxor %xmm9,%xmm10,%xmm10 + vpxor %xmm5,%xmm11,%xmm11 + + vpclmulqdq $0x10,%xmm12,%xmm10,%xmm9 + vpalignr $8,%xmm10,%xmm10,%xmm10 + vpxor %xmm9,%xmm10,%xmm10 + + vpclmulqdq $0x10,%xmm12,%xmm10,%xmm9 + vpalignr $8,%xmm10,%xmm10,%xmm10 + vpxor %xmm11,%xmm10,%xmm10 + vpxor %xmm9,%xmm10,%xmm10 + + cmpq $0,%rcx + jne .Lshort_avx + + vpshufb %xmm13,%xmm10,%xmm10 + vmovdqu %xmm10,(%rdi) + vzeroupper + ret +.cfi_endproc + +.size gcm_ghash_avx,.-gcm_ghash_avx +.section .rodata +.align 64 +.Lbswap_mask: +.byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 +.L0x1c2_polynomial: +.byte 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0xc2 +.L7_mask: +.long 7,0,7,0 +.align 64 + +.byte 71,72,65,83,72,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.align 64 +.text +#endif diff --git a/http/vendor/ring/pregenerated/ghash-x86_64-macosx.S b/http/vendor/ring/pregenerated/ghash-x86_64-macosx.S new file mode 100644 index 0000000..dc9786a --- /dev/null +++ b/http/vendor/ring/pregenerated/ghash-x86_64-macosx.S @@ -0,0 +1,1062 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__) +.text +.globl _gcm_init_clmul +.private_extern _gcm_init_clmul + +.p2align 4 +_gcm_init_clmul: + + +_CET_ENDBR +L$_init_clmul: + movdqu (%rsi),%xmm2 + pshufd $78,%xmm2,%xmm2 + + + pshufd $255,%xmm2,%xmm4 + movdqa %xmm2,%xmm3 + psllq $1,%xmm2 + pxor %xmm5,%xmm5 + psrlq $63,%xmm3 + pcmpgtd %xmm4,%xmm5 + pslldq $8,%xmm3 + por %xmm3,%xmm2 + + + pand L$0x1c2_polynomial(%rip),%xmm5 + pxor %xmm5,%xmm2 + + + pshufd $78,%xmm2,%xmm6 + movdqa %xmm2,%xmm0 + pxor %xmm2,%xmm6 + movdqa %xmm0,%xmm1 + pshufd $78,%xmm0,%xmm3 + pxor %xmm0,%xmm3 +.byte 102,15,58,68,194,0 +.byte 102,15,58,68,202,17 +.byte 102,15,58,68,222,0 + pxor %xmm0,%xmm3 + pxor %xmm1,%xmm3 + + movdqa %xmm3,%xmm4 + psrldq $8,%xmm3 + pslldq $8,%xmm4 + pxor %xmm3,%xmm1 + pxor %xmm4,%xmm0 + + movdqa %xmm0,%xmm4 + movdqa %xmm0,%xmm3 + psllq $5,%xmm0 + pxor %xmm0,%xmm3 + psllq $1,%xmm0 + pxor %xmm3,%xmm0 + psllq $57,%xmm0 + movdqa %xmm0,%xmm3 + pslldq $8,%xmm0 + psrldq $8,%xmm3 + pxor %xmm4,%xmm0 + pxor %xmm3,%xmm1 + + + movdqa %xmm0,%xmm4 + psrlq $1,%xmm0 + pxor %xmm4,%xmm1 + pxor %xmm0,%xmm4 + psrlq $5,%xmm0 + pxor %xmm4,%xmm0 + psrlq $1,%xmm0 + pxor %xmm1,%xmm0 + pshufd $78,%xmm2,%xmm3 + pshufd $78,%xmm0,%xmm4 + pxor %xmm2,%xmm3 + movdqu %xmm2,0(%rdi) + pxor %xmm0,%xmm4 + movdqu %xmm0,16(%rdi) +.byte 102,15,58,15,227,8 + movdqu %xmm4,32(%rdi) + movdqa %xmm0,%xmm1 + pshufd $78,%xmm0,%xmm3 + pxor %xmm0,%xmm3 +.byte 102,15,58,68,194,0 +.byte 102,15,58,68,202,17 +.byte 102,15,58,68,222,0 + pxor %xmm0,%xmm3 + pxor %xmm1,%xmm3 + + movdqa %xmm3,%xmm4 + psrldq $8,%xmm3 + pslldq $8,%xmm4 + pxor %xmm3,%xmm1 + pxor %xmm4,%xmm0 + + movdqa %xmm0,%xmm4 + movdqa %xmm0,%xmm3 + psllq $5,%xmm0 + pxor %xmm0,%xmm3 + psllq $1,%xmm0 + pxor %xmm3,%xmm0 + psllq $57,%xmm0 + movdqa %xmm0,%xmm3 + pslldq $8,%xmm0 + psrldq $8,%xmm3 + pxor %xmm4,%xmm0 + pxor %xmm3,%xmm1 + + + movdqa %xmm0,%xmm4 + psrlq $1,%xmm0 + pxor %xmm4,%xmm1 + pxor %xmm0,%xmm4 + psrlq $5,%xmm0 + pxor %xmm4,%xmm0 + psrlq $1,%xmm0 + pxor %xmm1,%xmm0 + movdqa %xmm0,%xmm5 + movdqa %xmm0,%xmm1 + pshufd $78,%xmm0,%xmm3 + pxor %xmm0,%xmm3 +.byte 102,15,58,68,194,0 +.byte 102,15,58,68,202,17 +.byte 102,15,58,68,222,0 + pxor %xmm0,%xmm3 + pxor %xmm1,%xmm3 + + movdqa %xmm3,%xmm4 + psrldq $8,%xmm3 + pslldq $8,%xmm4 + pxor %xmm3,%xmm1 + pxor %xmm4,%xmm0 + + movdqa %xmm0,%xmm4 + movdqa %xmm0,%xmm3 + psllq $5,%xmm0 + pxor %xmm0,%xmm3 + psllq $1,%xmm0 + pxor %xmm3,%xmm0 + psllq $57,%xmm0 + movdqa %xmm0,%xmm3 + pslldq $8,%xmm0 + psrldq $8,%xmm3 + pxor %xmm4,%xmm0 + pxor %xmm3,%xmm1 + + + movdqa %xmm0,%xmm4 + psrlq $1,%xmm0 + pxor %xmm4,%xmm1 + pxor %xmm0,%xmm4 + psrlq $5,%xmm0 + pxor %xmm4,%xmm0 + psrlq $1,%xmm0 + pxor %xmm1,%xmm0 + pshufd $78,%xmm5,%xmm3 + pshufd $78,%xmm0,%xmm4 + pxor %xmm5,%xmm3 + movdqu %xmm5,48(%rdi) + pxor %xmm0,%xmm4 + movdqu %xmm0,64(%rdi) +.byte 102,15,58,15,227,8 + movdqu %xmm4,80(%rdi) + ret + + + +.globl _gcm_ghash_clmul +.private_extern _gcm_ghash_clmul + +.p2align 5 +_gcm_ghash_clmul: + + +_CET_ENDBR +L$_ghash_clmul: + movdqa L$bswap_mask(%rip),%xmm10 + + movdqu (%rdi),%xmm0 + movdqu (%rsi),%xmm2 + movdqu 32(%rsi),%xmm7 +.byte 102,65,15,56,0,194 + + subq $0x10,%rcx + jz L$odd_tail + + movdqu 16(%rsi),%xmm6 + cmpq $0x30,%rcx + jb L$skip4x + + subq $0x30,%rcx + movq $0xA040608020C0E000,%rax + movdqu 48(%rsi),%xmm14 + movdqu 64(%rsi),%xmm15 + + + + + movdqu 48(%rdx),%xmm3 + movdqu 32(%rdx),%xmm11 +.byte 102,65,15,56,0,218 +.byte 102,69,15,56,0,218 + movdqa %xmm3,%xmm5 + pshufd $78,%xmm3,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,68,218,0 +.byte 102,15,58,68,234,17 +.byte 102,15,58,68,231,0 + + movdqa %xmm11,%xmm13 + pshufd $78,%xmm11,%xmm12 + pxor %xmm11,%xmm12 +.byte 102,68,15,58,68,222,0 +.byte 102,68,15,58,68,238,17 +.byte 102,68,15,58,68,231,16 + xorps %xmm11,%xmm3 + xorps %xmm13,%xmm5 + movups 80(%rsi),%xmm7 + xorps %xmm12,%xmm4 + + movdqu 16(%rdx),%xmm11 + movdqu 0(%rdx),%xmm8 +.byte 102,69,15,56,0,218 +.byte 102,69,15,56,0,194 + movdqa %xmm11,%xmm13 + pshufd $78,%xmm11,%xmm12 + pxor %xmm8,%xmm0 + pxor %xmm11,%xmm12 +.byte 102,69,15,58,68,222,0 + movdqa %xmm0,%xmm1 + pshufd $78,%xmm0,%xmm8 + pxor %xmm0,%xmm8 +.byte 102,69,15,58,68,238,17 +.byte 102,68,15,58,68,231,0 + xorps %xmm11,%xmm3 + xorps %xmm13,%xmm5 + + leaq 64(%rdx),%rdx + subq $0x40,%rcx + jc L$tail4x + + jmp L$mod4_loop +.p2align 5 +L$mod4_loop: +.byte 102,65,15,58,68,199,0 + xorps %xmm12,%xmm4 + movdqu 48(%rdx),%xmm11 +.byte 102,69,15,56,0,218 +.byte 102,65,15,58,68,207,17 + xorps %xmm3,%xmm0 + movdqu 32(%rdx),%xmm3 + movdqa %xmm11,%xmm13 +.byte 102,68,15,58,68,199,16 + pshufd $78,%xmm11,%xmm12 + xorps %xmm5,%xmm1 + pxor %xmm11,%xmm12 +.byte 102,65,15,56,0,218 + movups 32(%rsi),%xmm7 + xorps %xmm4,%xmm8 +.byte 102,68,15,58,68,218,0 + pshufd $78,%xmm3,%xmm4 + + pxor %xmm0,%xmm8 + movdqa %xmm3,%xmm5 + pxor %xmm1,%xmm8 + pxor %xmm3,%xmm4 + movdqa %xmm8,%xmm9 +.byte 102,68,15,58,68,234,17 + pslldq $8,%xmm8 + psrldq $8,%xmm9 + pxor %xmm8,%xmm0 + movdqa L$7_mask(%rip),%xmm8 + pxor %xmm9,%xmm1 +.byte 102,76,15,110,200 + + pand %xmm0,%xmm8 +.byte 102,69,15,56,0,200 + pxor %xmm0,%xmm9 +.byte 102,68,15,58,68,231,0 + psllq $57,%xmm9 + movdqa %xmm9,%xmm8 + pslldq $8,%xmm9 +.byte 102,15,58,68,222,0 + psrldq $8,%xmm8 + pxor %xmm9,%xmm0 + pxor %xmm8,%xmm1 + movdqu 0(%rdx),%xmm8 + + movdqa %xmm0,%xmm9 + psrlq $1,%xmm0 +.byte 102,15,58,68,238,17 + xorps %xmm11,%xmm3 + movdqu 16(%rdx),%xmm11 +.byte 102,69,15,56,0,218 +.byte 102,15,58,68,231,16 + xorps %xmm13,%xmm5 + movups 80(%rsi),%xmm7 +.byte 102,69,15,56,0,194 + pxor %xmm9,%xmm1 + pxor %xmm0,%xmm9 + psrlq $5,%xmm0 + + movdqa %xmm11,%xmm13 + pxor %xmm12,%xmm4 + pshufd $78,%xmm11,%xmm12 + pxor %xmm9,%xmm0 + pxor %xmm8,%xmm1 + pxor %xmm11,%xmm12 +.byte 102,69,15,58,68,222,0 + psrlq $1,%xmm0 + pxor %xmm1,%xmm0 + movdqa %xmm0,%xmm1 +.byte 102,69,15,58,68,238,17 + xorps %xmm11,%xmm3 + pshufd $78,%xmm0,%xmm8 + pxor %xmm0,%xmm8 + +.byte 102,68,15,58,68,231,0 + xorps %xmm13,%xmm5 + + leaq 64(%rdx),%rdx + subq $0x40,%rcx + jnc L$mod4_loop + +L$tail4x: +.byte 102,65,15,58,68,199,0 +.byte 102,65,15,58,68,207,17 +.byte 102,68,15,58,68,199,16 + xorps %xmm12,%xmm4 + xorps %xmm3,%xmm0 + xorps %xmm5,%xmm1 + pxor %xmm0,%xmm1 + pxor %xmm4,%xmm8 + + pxor %xmm1,%xmm8 + pxor %xmm0,%xmm1 + + movdqa %xmm8,%xmm9 + psrldq $8,%xmm8 + pslldq $8,%xmm9 + pxor %xmm8,%xmm1 + pxor %xmm9,%xmm0 + + movdqa %xmm0,%xmm4 + movdqa %xmm0,%xmm3 + psllq $5,%xmm0 + pxor %xmm0,%xmm3 + psllq $1,%xmm0 + pxor %xmm3,%xmm0 + psllq $57,%xmm0 + movdqa %xmm0,%xmm3 + pslldq $8,%xmm0 + psrldq $8,%xmm3 + pxor %xmm4,%xmm0 + pxor %xmm3,%xmm1 + + + movdqa %xmm0,%xmm4 + psrlq $1,%xmm0 + pxor %xmm4,%xmm1 + pxor %xmm0,%xmm4 + psrlq $5,%xmm0 + pxor %xmm4,%xmm0 + psrlq $1,%xmm0 + pxor %xmm1,%xmm0 + addq $0x40,%rcx + jz L$done + movdqu 32(%rsi),%xmm7 + subq $0x10,%rcx + jz L$odd_tail +L$skip4x: + + + + + + movdqu (%rdx),%xmm8 + movdqu 16(%rdx),%xmm3 +.byte 102,69,15,56,0,194 +.byte 102,65,15,56,0,218 + pxor %xmm8,%xmm0 + + movdqa %xmm3,%xmm5 + pshufd $78,%xmm3,%xmm4 + pxor %xmm3,%xmm4 +.byte 102,15,58,68,218,0 +.byte 102,15,58,68,234,17 +.byte 102,15,58,68,231,0 + + leaq 32(%rdx),%rdx + nop + subq $0x20,%rcx + jbe L$even_tail + nop + jmp L$mod_loop + +.p2align 5 +L$mod_loop: + movdqa %xmm0,%xmm1 + movdqa %xmm4,%xmm8 + pshufd $78,%xmm0,%xmm4 + pxor %xmm0,%xmm4 + +.byte 102,15,58,68,198,0 +.byte 102,15,58,68,206,17 +.byte 102,15,58,68,231,16 + + pxor %xmm3,%xmm0 + pxor %xmm5,%xmm1 + movdqu (%rdx),%xmm9 + pxor %xmm0,%xmm8 +.byte 102,69,15,56,0,202 + movdqu 16(%rdx),%xmm3 + + pxor %xmm1,%xmm8 + pxor %xmm9,%xmm1 + pxor %xmm8,%xmm4 +.byte 102,65,15,56,0,218 + movdqa %xmm4,%xmm8 + psrldq $8,%xmm8 + pslldq $8,%xmm4 + pxor %xmm8,%xmm1 + pxor %xmm4,%xmm0 + + movdqa %xmm3,%xmm5 + + movdqa %xmm0,%xmm9 + movdqa %xmm0,%xmm8 + psllq $5,%xmm0 + pxor %xmm0,%xmm8 +.byte 102,15,58,68,218,0 + psllq $1,%xmm0 + pxor %xmm8,%xmm0 + psllq $57,%xmm0 + movdqa %xmm0,%xmm8 + pslldq $8,%xmm0 + psrldq $8,%xmm8 + pxor %xmm9,%xmm0 + pshufd $78,%xmm5,%xmm4 + pxor %xmm8,%xmm1 + pxor %xmm5,%xmm4 + + movdqa %xmm0,%xmm9 + psrlq $1,%xmm0 +.byte 102,15,58,68,234,17 + pxor %xmm9,%xmm1 + pxor %xmm0,%xmm9 + psrlq $5,%xmm0 + pxor %xmm9,%xmm0 + leaq 32(%rdx),%rdx + psrlq $1,%xmm0 +.byte 102,15,58,68,231,0 + pxor %xmm1,%xmm0 + + subq $0x20,%rcx + ja L$mod_loop + +L$even_tail: + movdqa %xmm0,%xmm1 + movdqa %xmm4,%xmm8 + pshufd $78,%xmm0,%xmm4 + pxor %xmm0,%xmm4 + +.byte 102,15,58,68,198,0 +.byte 102,15,58,68,206,17 +.byte 102,15,58,68,231,16 + + pxor %xmm3,%xmm0 + pxor %xmm5,%xmm1 + pxor %xmm0,%xmm8 + pxor %xmm1,%xmm8 + pxor %xmm8,%xmm4 + movdqa %xmm4,%xmm8 + psrldq $8,%xmm8 + pslldq $8,%xmm4 + pxor %xmm8,%xmm1 + pxor %xmm4,%xmm0 + + movdqa %xmm0,%xmm4 + movdqa %xmm0,%xmm3 + psllq $5,%xmm0 + pxor %xmm0,%xmm3 + psllq $1,%xmm0 + pxor %xmm3,%xmm0 + psllq $57,%xmm0 + movdqa %xmm0,%xmm3 + pslldq $8,%xmm0 + psrldq $8,%xmm3 + pxor %xmm4,%xmm0 + pxor %xmm3,%xmm1 + + + movdqa %xmm0,%xmm4 + psrlq $1,%xmm0 + pxor %xmm4,%xmm1 + pxor %xmm0,%xmm4 + psrlq $5,%xmm0 + pxor %xmm4,%xmm0 + psrlq $1,%xmm0 + pxor %xmm1,%xmm0 + testq %rcx,%rcx + jnz L$done + +L$odd_tail: + movdqu (%rdx),%xmm8 +.byte 102,69,15,56,0,194 + pxor %xmm8,%xmm0 + movdqa %xmm0,%xmm1 + pshufd $78,%xmm0,%xmm3 + pxor %xmm0,%xmm3 +.byte 102,15,58,68,194,0 +.byte 102,15,58,68,202,17 +.byte 102,15,58,68,223,0 + pxor %xmm0,%xmm3 + pxor %xmm1,%xmm3 + + movdqa %xmm3,%xmm4 + psrldq $8,%xmm3 + pslldq $8,%xmm4 + pxor %xmm3,%xmm1 + pxor %xmm4,%xmm0 + + movdqa %xmm0,%xmm4 + movdqa %xmm0,%xmm3 + psllq $5,%xmm0 + pxor %xmm0,%xmm3 + psllq $1,%xmm0 + pxor %xmm3,%xmm0 + psllq $57,%xmm0 + movdqa %xmm0,%xmm3 + pslldq $8,%xmm0 + psrldq $8,%xmm3 + pxor %xmm4,%xmm0 + pxor %xmm3,%xmm1 + + + movdqa %xmm0,%xmm4 + psrlq $1,%xmm0 + pxor %xmm4,%xmm1 + pxor %xmm0,%xmm4 + psrlq $5,%xmm0 + pxor %xmm4,%xmm0 + psrlq $1,%xmm0 + pxor %xmm1,%xmm0 +L$done: +.byte 102,65,15,56,0,194 + movdqu %xmm0,(%rdi) + ret + + + +.globl _gcm_init_avx +.private_extern _gcm_init_avx + +.p2align 5 +_gcm_init_avx: + + +_CET_ENDBR + vzeroupper + + vmovdqu (%rsi),%xmm2 + vpshufd $78,%xmm2,%xmm2 + + + vpshufd $255,%xmm2,%xmm4 + vpsrlq $63,%xmm2,%xmm3 + vpsllq $1,%xmm2,%xmm2 + vpxor %xmm5,%xmm5,%xmm5 + vpcmpgtd %xmm4,%xmm5,%xmm5 + vpslldq $8,%xmm3,%xmm3 + vpor %xmm3,%xmm2,%xmm2 + + + vpand L$0x1c2_polynomial(%rip),%xmm5,%xmm5 + vpxor %xmm5,%xmm2,%xmm2 + + vpunpckhqdq %xmm2,%xmm2,%xmm6 + vmovdqa %xmm2,%xmm0 + vpxor %xmm2,%xmm6,%xmm6 + movq $4,%r10 + jmp L$init_start_avx +.p2align 5 +L$init_loop_avx: + vpalignr $8,%xmm3,%xmm4,%xmm5 + vmovdqu %xmm5,-16(%rdi) + vpunpckhqdq %xmm0,%xmm0,%xmm3 + vpxor %xmm0,%xmm3,%xmm3 + vpclmulqdq $0x11,%xmm2,%xmm0,%xmm1 + vpclmulqdq $0x00,%xmm2,%xmm0,%xmm0 + vpclmulqdq $0x00,%xmm6,%xmm3,%xmm3 + vpxor %xmm0,%xmm1,%xmm4 + vpxor %xmm4,%xmm3,%xmm3 + + vpslldq $8,%xmm3,%xmm4 + vpsrldq $8,%xmm3,%xmm3 + vpxor %xmm4,%xmm0,%xmm0 + vpxor %xmm3,%xmm1,%xmm1 + vpsllq $57,%xmm0,%xmm3 + vpsllq $62,%xmm0,%xmm4 + vpxor %xmm3,%xmm4,%xmm4 + vpsllq $63,%xmm0,%xmm3 + vpxor %xmm3,%xmm4,%xmm4 + vpslldq $8,%xmm4,%xmm3 + vpsrldq $8,%xmm4,%xmm4 + vpxor %xmm3,%xmm0,%xmm0 + vpxor %xmm4,%xmm1,%xmm1 + + vpsrlq $1,%xmm0,%xmm4 + vpxor %xmm0,%xmm1,%xmm1 + vpxor %xmm4,%xmm0,%xmm0 + vpsrlq $5,%xmm4,%xmm4 + vpxor %xmm4,%xmm0,%xmm0 + vpsrlq $1,%xmm0,%xmm0 + vpxor %xmm1,%xmm0,%xmm0 +L$init_start_avx: + vmovdqa %xmm0,%xmm5 + vpunpckhqdq %xmm0,%xmm0,%xmm3 + vpxor %xmm0,%xmm3,%xmm3 + vpclmulqdq $0x11,%xmm2,%xmm0,%xmm1 + vpclmulqdq $0x00,%xmm2,%xmm0,%xmm0 + vpclmulqdq $0x00,%xmm6,%xmm3,%xmm3 + vpxor %xmm0,%xmm1,%xmm4 + vpxor %xmm4,%xmm3,%xmm3 + + vpslldq $8,%xmm3,%xmm4 + vpsrldq $8,%xmm3,%xmm3 + vpxor %xmm4,%xmm0,%xmm0 + vpxor %xmm3,%xmm1,%xmm1 + vpsllq $57,%xmm0,%xmm3 + vpsllq $62,%xmm0,%xmm4 + vpxor %xmm3,%xmm4,%xmm4 + vpsllq $63,%xmm0,%xmm3 + vpxor %xmm3,%xmm4,%xmm4 + vpslldq $8,%xmm4,%xmm3 + vpsrldq $8,%xmm4,%xmm4 + vpxor %xmm3,%xmm0,%xmm0 + vpxor %xmm4,%xmm1,%xmm1 + + vpsrlq $1,%xmm0,%xmm4 + vpxor %xmm0,%xmm1,%xmm1 + vpxor %xmm4,%xmm0,%xmm0 + vpsrlq $5,%xmm4,%xmm4 + vpxor %xmm4,%xmm0,%xmm0 + vpsrlq $1,%xmm0,%xmm0 + vpxor %xmm1,%xmm0,%xmm0 + vpshufd $78,%xmm5,%xmm3 + vpshufd $78,%xmm0,%xmm4 + vpxor %xmm5,%xmm3,%xmm3 + vmovdqu %xmm5,0(%rdi) + vpxor %xmm0,%xmm4,%xmm4 + vmovdqu %xmm0,16(%rdi) + leaq 48(%rdi),%rdi + subq $1,%r10 + jnz L$init_loop_avx + + vpalignr $8,%xmm4,%xmm3,%xmm5 + vmovdqu %xmm5,-16(%rdi) + + vzeroupper + ret + + + +.globl _gcm_ghash_avx +.private_extern _gcm_ghash_avx + +.p2align 5 +_gcm_ghash_avx: + + +_CET_ENDBR + vzeroupper + + vmovdqu (%rdi),%xmm10 + leaq L$0x1c2_polynomial(%rip),%r10 + leaq 64(%rsi),%rsi + vmovdqu L$bswap_mask(%rip),%xmm13 + vpshufb %xmm13,%xmm10,%xmm10 + cmpq $0x80,%rcx + jb L$short_avx + subq $0x80,%rcx + + vmovdqu 112(%rdx),%xmm14 + vmovdqu 0-64(%rsi),%xmm6 + vpshufb %xmm13,%xmm14,%xmm14 + vmovdqu 32-64(%rsi),%xmm7 + + vpunpckhqdq %xmm14,%xmm14,%xmm9 + vmovdqu 96(%rdx),%xmm15 + vpclmulqdq $0x00,%xmm6,%xmm14,%xmm0 + vpxor %xmm14,%xmm9,%xmm9 + vpshufb %xmm13,%xmm15,%xmm15 + vpclmulqdq $0x11,%xmm6,%xmm14,%xmm1 + vmovdqu 16-64(%rsi),%xmm6 + vpunpckhqdq %xmm15,%xmm15,%xmm8 + vmovdqu 80(%rdx),%xmm14 + vpclmulqdq $0x00,%xmm7,%xmm9,%xmm2 + vpxor %xmm15,%xmm8,%xmm8 + + vpshufb %xmm13,%xmm14,%xmm14 + vpclmulqdq $0x00,%xmm6,%xmm15,%xmm3 + vpunpckhqdq %xmm14,%xmm14,%xmm9 + vpclmulqdq $0x11,%xmm6,%xmm15,%xmm4 + vmovdqu 48-64(%rsi),%xmm6 + vpxor %xmm14,%xmm9,%xmm9 + vmovdqu 64(%rdx),%xmm15 + vpclmulqdq $0x10,%xmm7,%xmm8,%xmm5 + vmovdqu 80-64(%rsi),%xmm7 + + vpshufb %xmm13,%xmm15,%xmm15 + vpxor %xmm0,%xmm3,%xmm3 + vpclmulqdq $0x00,%xmm6,%xmm14,%xmm0 + vpxor %xmm1,%xmm4,%xmm4 + vpunpckhqdq %xmm15,%xmm15,%xmm8 + vpclmulqdq $0x11,%xmm6,%xmm14,%xmm1 + vmovdqu 64-64(%rsi),%xmm6 + vpxor %xmm2,%xmm5,%xmm5 + vpclmulqdq $0x00,%xmm7,%xmm9,%xmm2 + vpxor %xmm15,%xmm8,%xmm8 + + vmovdqu 48(%rdx),%xmm14 + vpxor %xmm3,%xmm0,%xmm0 + vpclmulqdq $0x00,%xmm6,%xmm15,%xmm3 + vpxor %xmm4,%xmm1,%xmm1 + vpshufb %xmm13,%xmm14,%xmm14 + vpclmulqdq $0x11,%xmm6,%xmm15,%xmm4 + vmovdqu 96-64(%rsi),%xmm6 + vpxor %xmm5,%xmm2,%xmm2 + vpunpckhqdq %xmm14,%xmm14,%xmm9 + vpclmulqdq $0x10,%xmm7,%xmm8,%xmm5 + vmovdqu 128-64(%rsi),%xmm7 + vpxor %xmm14,%xmm9,%xmm9 + + vmovdqu 32(%rdx),%xmm15 + vpxor %xmm0,%xmm3,%xmm3 + vpclmulqdq $0x00,%xmm6,%xmm14,%xmm0 + vpxor %xmm1,%xmm4,%xmm4 + vpshufb %xmm13,%xmm15,%xmm15 + vpclmulqdq $0x11,%xmm6,%xmm14,%xmm1 + vmovdqu 112-64(%rsi),%xmm6 + vpxor %xmm2,%xmm5,%xmm5 + vpunpckhqdq %xmm15,%xmm15,%xmm8 + vpclmulqdq $0x00,%xmm7,%xmm9,%xmm2 + vpxor %xmm15,%xmm8,%xmm8 + + vmovdqu 16(%rdx),%xmm14 + vpxor %xmm3,%xmm0,%xmm0 + vpclmulqdq $0x00,%xmm6,%xmm15,%xmm3 + vpxor %xmm4,%xmm1,%xmm1 + vpshufb %xmm13,%xmm14,%xmm14 + vpclmulqdq $0x11,%xmm6,%xmm15,%xmm4 + vmovdqu 144-64(%rsi),%xmm6 + vpxor %xmm5,%xmm2,%xmm2 + vpunpckhqdq %xmm14,%xmm14,%xmm9 + vpclmulqdq $0x10,%xmm7,%xmm8,%xmm5 + vmovdqu 176-64(%rsi),%xmm7 + vpxor %xmm14,%xmm9,%xmm9 + + vmovdqu (%rdx),%xmm15 + vpxor %xmm0,%xmm3,%xmm3 + vpclmulqdq $0x00,%xmm6,%xmm14,%xmm0 + vpxor %xmm1,%xmm4,%xmm4 + vpshufb %xmm13,%xmm15,%xmm15 + vpclmulqdq $0x11,%xmm6,%xmm14,%xmm1 + vmovdqu 160-64(%rsi),%xmm6 + vpxor %xmm2,%xmm5,%xmm5 + vpclmulqdq $0x10,%xmm7,%xmm9,%xmm2 + + leaq 128(%rdx),%rdx + cmpq $0x80,%rcx + jb L$tail_avx + + vpxor %xmm10,%xmm15,%xmm15 + subq $0x80,%rcx + jmp L$oop8x_avx + +.p2align 5 +L$oop8x_avx: + vpunpckhqdq %xmm15,%xmm15,%xmm8 + vmovdqu 112(%rdx),%xmm14 + vpxor %xmm0,%xmm3,%xmm3 + vpxor %xmm15,%xmm8,%xmm8 + vpclmulqdq $0x00,%xmm6,%xmm15,%xmm10 + vpshufb %xmm13,%xmm14,%xmm14 + vpxor %xmm1,%xmm4,%xmm4 + vpclmulqdq $0x11,%xmm6,%xmm15,%xmm11 + vmovdqu 0-64(%rsi),%xmm6 + vpunpckhqdq %xmm14,%xmm14,%xmm9 + vpxor %xmm2,%xmm5,%xmm5 + vpclmulqdq $0x00,%xmm7,%xmm8,%xmm12 + vmovdqu 32-64(%rsi),%xmm7 + vpxor %xmm14,%xmm9,%xmm9 + + vmovdqu 96(%rdx),%xmm15 + vpclmulqdq $0x00,%xmm6,%xmm14,%xmm0 + vpxor %xmm3,%xmm10,%xmm10 + vpshufb %xmm13,%xmm15,%xmm15 + vpclmulqdq $0x11,%xmm6,%xmm14,%xmm1 + vxorps %xmm4,%xmm11,%xmm11 + vmovdqu 16-64(%rsi),%xmm6 + vpunpckhqdq %xmm15,%xmm15,%xmm8 + vpclmulqdq $0x00,%xmm7,%xmm9,%xmm2 + vpxor %xmm5,%xmm12,%xmm12 + vxorps %xmm15,%xmm8,%xmm8 + + vmovdqu 80(%rdx),%xmm14 + vpxor %xmm10,%xmm12,%xmm12 + vpclmulqdq $0x00,%xmm6,%xmm15,%xmm3 + vpxor %xmm11,%xmm12,%xmm12 + vpslldq $8,%xmm12,%xmm9 + vpxor %xmm0,%xmm3,%xmm3 + vpclmulqdq $0x11,%xmm6,%xmm15,%xmm4 + vpsrldq $8,%xmm12,%xmm12 + vpxor %xmm9,%xmm10,%xmm10 + vmovdqu 48-64(%rsi),%xmm6 + vpshufb %xmm13,%xmm14,%xmm14 + vxorps %xmm12,%xmm11,%xmm11 + vpxor %xmm1,%xmm4,%xmm4 + vpunpckhqdq %xmm14,%xmm14,%xmm9 + vpclmulqdq $0x10,%xmm7,%xmm8,%xmm5 + vmovdqu 80-64(%rsi),%xmm7 + vpxor %xmm14,%xmm9,%xmm9 + vpxor %xmm2,%xmm5,%xmm5 + + vmovdqu 64(%rdx),%xmm15 + vpalignr $8,%xmm10,%xmm10,%xmm12 + vpclmulqdq $0x00,%xmm6,%xmm14,%xmm0 + vpshufb %xmm13,%xmm15,%xmm15 + vpxor %xmm3,%xmm0,%xmm0 + vpclmulqdq $0x11,%xmm6,%xmm14,%xmm1 + vmovdqu 64-64(%rsi),%xmm6 + vpunpckhqdq %xmm15,%xmm15,%xmm8 + vpxor %xmm4,%xmm1,%xmm1 + vpclmulqdq $0x00,%xmm7,%xmm9,%xmm2 + vxorps %xmm15,%xmm8,%xmm8 + vpxor %xmm5,%xmm2,%xmm2 + + vmovdqu 48(%rdx),%xmm14 + vpclmulqdq $0x10,(%r10),%xmm10,%xmm10 + vpclmulqdq $0x00,%xmm6,%xmm15,%xmm3 + vpshufb %xmm13,%xmm14,%xmm14 + vpxor %xmm0,%xmm3,%xmm3 + vpclmulqdq $0x11,%xmm6,%xmm15,%xmm4 + vmovdqu 96-64(%rsi),%xmm6 + vpunpckhqdq %xmm14,%xmm14,%xmm9 + vpxor %xmm1,%xmm4,%xmm4 + vpclmulqdq $0x10,%xmm7,%xmm8,%xmm5 + vmovdqu 128-64(%rsi),%xmm7 + vpxor %xmm14,%xmm9,%xmm9 + vpxor %xmm2,%xmm5,%xmm5 + + vmovdqu 32(%rdx),%xmm15 + vpclmulqdq $0x00,%xmm6,%xmm14,%xmm0 + vpshufb %xmm13,%xmm15,%xmm15 + vpxor %xmm3,%xmm0,%xmm0 + vpclmulqdq $0x11,%xmm6,%xmm14,%xmm1 + vmovdqu 112-64(%rsi),%xmm6 + vpunpckhqdq %xmm15,%xmm15,%xmm8 + vpxor %xmm4,%xmm1,%xmm1 + vpclmulqdq $0x00,%xmm7,%xmm9,%xmm2 + vpxor %xmm15,%xmm8,%xmm8 + vpxor %xmm5,%xmm2,%xmm2 + vxorps %xmm12,%xmm10,%xmm10 + + vmovdqu 16(%rdx),%xmm14 + vpalignr $8,%xmm10,%xmm10,%xmm12 + vpclmulqdq $0x00,%xmm6,%xmm15,%xmm3 + vpshufb %xmm13,%xmm14,%xmm14 + vpxor %xmm0,%xmm3,%xmm3 + vpclmulqdq $0x11,%xmm6,%xmm15,%xmm4 + vmovdqu 144-64(%rsi),%xmm6 + vpclmulqdq $0x10,(%r10),%xmm10,%xmm10 + vxorps %xmm11,%xmm12,%xmm12 + vpunpckhqdq %xmm14,%xmm14,%xmm9 + vpxor %xmm1,%xmm4,%xmm4 + vpclmulqdq $0x10,%xmm7,%xmm8,%xmm5 + vmovdqu 176-64(%rsi),%xmm7 + vpxor %xmm14,%xmm9,%xmm9 + vpxor %xmm2,%xmm5,%xmm5 + + vmovdqu (%rdx),%xmm15 + vpclmulqdq $0x00,%xmm6,%xmm14,%xmm0 + vpshufb %xmm13,%xmm15,%xmm15 + vpclmulqdq $0x11,%xmm6,%xmm14,%xmm1 + vmovdqu 160-64(%rsi),%xmm6 + vpxor %xmm12,%xmm15,%xmm15 + vpclmulqdq $0x10,%xmm7,%xmm9,%xmm2 + vpxor %xmm10,%xmm15,%xmm15 + + leaq 128(%rdx),%rdx + subq $0x80,%rcx + jnc L$oop8x_avx + + addq $0x80,%rcx + jmp L$tail_no_xor_avx + +.p2align 5 +L$short_avx: + vmovdqu -16(%rdx,%rcx,1),%xmm14 + leaq (%rdx,%rcx,1),%rdx + vmovdqu 0-64(%rsi),%xmm6 + vmovdqu 32-64(%rsi),%xmm7 + vpshufb %xmm13,%xmm14,%xmm15 + + vmovdqa %xmm0,%xmm3 + vmovdqa %xmm1,%xmm4 + vmovdqa %xmm2,%xmm5 + subq $0x10,%rcx + jz L$tail_avx + + vpunpckhqdq %xmm15,%xmm15,%xmm8 + vpxor %xmm0,%xmm3,%xmm3 + vpclmulqdq $0x00,%xmm6,%xmm15,%xmm0 + vpxor %xmm15,%xmm8,%xmm8 + vmovdqu -32(%rdx),%xmm14 + vpxor %xmm1,%xmm4,%xmm4 + vpclmulqdq $0x11,%xmm6,%xmm15,%xmm1 + vmovdqu 16-64(%rsi),%xmm6 + vpshufb %xmm13,%xmm14,%xmm15 + vpxor %xmm2,%xmm5,%xmm5 + vpclmulqdq $0x00,%xmm7,%xmm8,%xmm2 + vpsrldq $8,%xmm7,%xmm7 + subq $0x10,%rcx + jz L$tail_avx + + vpunpckhqdq %xmm15,%xmm15,%xmm8 + vpxor %xmm0,%xmm3,%xmm3 + vpclmulqdq $0x00,%xmm6,%xmm15,%xmm0 + vpxor %xmm15,%xmm8,%xmm8 + vmovdqu -48(%rdx),%xmm14 + vpxor %xmm1,%xmm4,%xmm4 + vpclmulqdq $0x11,%xmm6,%xmm15,%xmm1 + vmovdqu 48-64(%rsi),%xmm6 + vpshufb %xmm13,%xmm14,%xmm15 + vpxor %xmm2,%xmm5,%xmm5 + vpclmulqdq $0x00,%xmm7,%xmm8,%xmm2 + vmovdqu 80-64(%rsi),%xmm7 + subq $0x10,%rcx + jz L$tail_avx + + vpunpckhqdq %xmm15,%xmm15,%xmm8 + vpxor %xmm0,%xmm3,%xmm3 + vpclmulqdq $0x00,%xmm6,%xmm15,%xmm0 + vpxor %xmm15,%xmm8,%xmm8 + vmovdqu -64(%rdx),%xmm14 + vpxor %xmm1,%xmm4,%xmm4 + vpclmulqdq $0x11,%xmm6,%xmm15,%xmm1 + vmovdqu 64-64(%rsi),%xmm6 + vpshufb %xmm13,%xmm14,%xmm15 + vpxor %xmm2,%xmm5,%xmm5 + vpclmulqdq $0x00,%xmm7,%xmm8,%xmm2 + vpsrldq $8,%xmm7,%xmm7 + subq $0x10,%rcx + jz L$tail_avx + + vpunpckhqdq %xmm15,%xmm15,%xmm8 + vpxor %xmm0,%xmm3,%xmm3 + vpclmulqdq $0x00,%xmm6,%xmm15,%xmm0 + vpxor %xmm15,%xmm8,%xmm8 + vmovdqu -80(%rdx),%xmm14 + vpxor %xmm1,%xmm4,%xmm4 + vpclmulqdq $0x11,%xmm6,%xmm15,%xmm1 + vmovdqu 96-64(%rsi),%xmm6 + vpshufb %xmm13,%xmm14,%xmm15 + vpxor %xmm2,%xmm5,%xmm5 + vpclmulqdq $0x00,%xmm7,%xmm8,%xmm2 + vmovdqu 128-64(%rsi),%xmm7 + subq $0x10,%rcx + jz L$tail_avx + + vpunpckhqdq %xmm15,%xmm15,%xmm8 + vpxor %xmm0,%xmm3,%xmm3 + vpclmulqdq $0x00,%xmm6,%xmm15,%xmm0 + vpxor %xmm15,%xmm8,%xmm8 + vmovdqu -96(%rdx),%xmm14 + vpxor %xmm1,%xmm4,%xmm4 + vpclmulqdq $0x11,%xmm6,%xmm15,%xmm1 + vmovdqu 112-64(%rsi),%xmm6 + vpshufb %xmm13,%xmm14,%xmm15 + vpxor %xmm2,%xmm5,%xmm5 + vpclmulqdq $0x00,%xmm7,%xmm8,%xmm2 + vpsrldq $8,%xmm7,%xmm7 + subq $0x10,%rcx + jz L$tail_avx + + vpunpckhqdq %xmm15,%xmm15,%xmm8 + vpxor %xmm0,%xmm3,%xmm3 + vpclmulqdq $0x00,%xmm6,%xmm15,%xmm0 + vpxor %xmm15,%xmm8,%xmm8 + vmovdqu -112(%rdx),%xmm14 + vpxor %xmm1,%xmm4,%xmm4 + vpclmulqdq $0x11,%xmm6,%xmm15,%xmm1 + vmovdqu 144-64(%rsi),%xmm6 + vpshufb %xmm13,%xmm14,%xmm15 + vpxor %xmm2,%xmm5,%xmm5 + vpclmulqdq $0x00,%xmm7,%xmm8,%xmm2 + vmovq 184-64(%rsi),%xmm7 + subq $0x10,%rcx + jmp L$tail_avx + +.p2align 5 +L$tail_avx: + vpxor %xmm10,%xmm15,%xmm15 +L$tail_no_xor_avx: + vpunpckhqdq %xmm15,%xmm15,%xmm8 + vpxor %xmm0,%xmm3,%xmm3 + vpclmulqdq $0x00,%xmm6,%xmm15,%xmm0 + vpxor %xmm15,%xmm8,%xmm8 + vpxor %xmm1,%xmm4,%xmm4 + vpclmulqdq $0x11,%xmm6,%xmm15,%xmm1 + vpxor %xmm2,%xmm5,%xmm5 + vpclmulqdq $0x00,%xmm7,%xmm8,%xmm2 + + vmovdqu (%r10),%xmm12 + + vpxor %xmm0,%xmm3,%xmm10 + vpxor %xmm1,%xmm4,%xmm11 + vpxor %xmm2,%xmm5,%xmm5 + + vpxor %xmm10,%xmm5,%xmm5 + vpxor %xmm11,%xmm5,%xmm5 + vpslldq $8,%xmm5,%xmm9 + vpsrldq $8,%xmm5,%xmm5 + vpxor %xmm9,%xmm10,%xmm10 + vpxor %xmm5,%xmm11,%xmm11 + + vpclmulqdq $0x10,%xmm12,%xmm10,%xmm9 + vpalignr $8,%xmm10,%xmm10,%xmm10 + vpxor %xmm9,%xmm10,%xmm10 + + vpclmulqdq $0x10,%xmm12,%xmm10,%xmm9 + vpalignr $8,%xmm10,%xmm10,%xmm10 + vpxor %xmm11,%xmm10,%xmm10 + vpxor %xmm9,%xmm10,%xmm10 + + cmpq $0,%rcx + jne L$short_avx + + vpshufb %xmm13,%xmm10,%xmm10 + vmovdqu %xmm10,(%rdi) + vzeroupper + ret + + + +.section __DATA,__const +.p2align 6 +L$bswap_mask: +.byte 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 +L$0x1c2_polynomial: +.byte 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0xc2 +L$7_mask: +.long 7,0,7,0 +.p2align 6 + +.byte 71,72,65,83,72,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.p2align 6 +.text +#endif diff --git a/http/vendor/ring/pregenerated/ghash-x86_64-nasm.asm b/http/vendor/ring/pregenerated/ghash-x86_64-nasm.asm new file mode 100644 index 0000000..eb04eed --- /dev/null +++ b/http/vendor/ring/pregenerated/ghash-x86_64-nasm.asm @@ -0,0 +1,1277 @@ +; This file is generated from a similarly-named Perl script in the BoringSSL +; source tree. Do not edit by hand. + +%ifidn __OUTPUT_FORMAT__, win64 +default rel +%define XMMWORD +%define YMMWORD +%define ZMMWORD +%define _CET_ENDBR + +%include "ring_core_generated/prefix_symbols_nasm.inc" +section .text code align=64 + +global gcm_init_clmul + +ALIGN 16 +gcm_init_clmul: + +$L$SEH_begin_gcm_init_clmul_1: +_CET_ENDBR +$L$_init_clmul: + sub rsp,0x18 +$L$SEH_prologue_gcm_init_clmul_2: + movaps XMMWORD[rsp],xmm6 +$L$SEH_prologue_gcm_init_clmul_3: +$L$SEH_endprologue_gcm_init_clmul_4: + movdqu xmm2,XMMWORD[rdx] + pshufd xmm2,xmm2,78 + + + pshufd xmm4,xmm2,255 + movdqa xmm3,xmm2 + psllq xmm2,1 + pxor xmm5,xmm5 + psrlq xmm3,63 + pcmpgtd xmm5,xmm4 + pslldq xmm3,8 + por xmm2,xmm3 + + + pand xmm5,XMMWORD[$L$0x1c2_polynomial] + pxor xmm2,xmm5 + + + pshufd xmm6,xmm2,78 + movdqa xmm0,xmm2 + pxor xmm6,xmm2 + movdqa xmm1,xmm0 + pshufd xmm3,xmm0,78 + pxor xmm3,xmm0 +DB 102,15,58,68,194,0 +DB 102,15,58,68,202,17 +DB 102,15,58,68,222,0 + pxor xmm3,xmm0 + pxor xmm3,xmm1 + + movdqa xmm4,xmm3 + psrldq xmm3,8 + pslldq xmm4,8 + pxor xmm1,xmm3 + pxor xmm0,xmm4 + + movdqa xmm4,xmm0 + movdqa xmm3,xmm0 + psllq xmm0,5 + pxor xmm3,xmm0 + psllq xmm0,1 + pxor xmm0,xmm3 + psllq xmm0,57 + movdqa xmm3,xmm0 + pslldq xmm0,8 + psrldq xmm3,8 + pxor xmm0,xmm4 + pxor xmm1,xmm3 + + + movdqa xmm4,xmm0 + psrlq xmm0,1 + pxor xmm1,xmm4 + pxor xmm4,xmm0 + psrlq xmm0,5 + pxor xmm0,xmm4 + psrlq xmm0,1 + pxor xmm0,xmm1 + pshufd xmm3,xmm2,78 + pshufd xmm4,xmm0,78 + pxor xmm3,xmm2 + movdqu XMMWORD[rcx],xmm2 + pxor xmm4,xmm0 + movdqu XMMWORD[16+rcx],xmm0 +DB 102,15,58,15,227,8 + movdqu XMMWORD[32+rcx],xmm4 + movdqa xmm1,xmm0 + pshufd xmm3,xmm0,78 + pxor xmm3,xmm0 +DB 102,15,58,68,194,0 +DB 102,15,58,68,202,17 +DB 102,15,58,68,222,0 + pxor xmm3,xmm0 + pxor xmm3,xmm1 + + movdqa xmm4,xmm3 + psrldq xmm3,8 + pslldq xmm4,8 + pxor xmm1,xmm3 + pxor xmm0,xmm4 + + movdqa xmm4,xmm0 + movdqa xmm3,xmm0 + psllq xmm0,5 + pxor xmm3,xmm0 + psllq xmm0,1 + pxor xmm0,xmm3 + psllq xmm0,57 + movdqa xmm3,xmm0 + pslldq xmm0,8 + psrldq xmm3,8 + pxor xmm0,xmm4 + pxor xmm1,xmm3 + + + movdqa xmm4,xmm0 + psrlq xmm0,1 + pxor xmm1,xmm4 + pxor xmm4,xmm0 + psrlq xmm0,5 + pxor xmm0,xmm4 + psrlq xmm0,1 + pxor xmm0,xmm1 + movdqa xmm5,xmm0 + movdqa xmm1,xmm0 + pshufd xmm3,xmm0,78 + pxor xmm3,xmm0 +DB 102,15,58,68,194,0 +DB 102,15,58,68,202,17 +DB 102,15,58,68,222,0 + pxor xmm3,xmm0 + pxor xmm3,xmm1 + + movdqa xmm4,xmm3 + psrldq xmm3,8 + pslldq xmm4,8 + pxor xmm1,xmm3 + pxor xmm0,xmm4 + + movdqa xmm4,xmm0 + movdqa xmm3,xmm0 + psllq xmm0,5 + pxor xmm3,xmm0 + psllq xmm0,1 + pxor xmm0,xmm3 + psllq xmm0,57 + movdqa xmm3,xmm0 + pslldq xmm0,8 + psrldq xmm3,8 + pxor xmm0,xmm4 + pxor xmm1,xmm3 + + + movdqa xmm4,xmm0 + psrlq xmm0,1 + pxor xmm1,xmm4 + pxor xmm4,xmm0 + psrlq xmm0,5 + pxor xmm0,xmm4 + psrlq xmm0,1 + pxor xmm0,xmm1 + pshufd xmm3,xmm5,78 + pshufd xmm4,xmm0,78 + pxor xmm3,xmm5 + movdqu XMMWORD[48+rcx],xmm5 + pxor xmm4,xmm0 + movdqu XMMWORD[64+rcx],xmm0 +DB 102,15,58,15,227,8 + movdqu XMMWORD[80+rcx],xmm4 + movaps xmm6,XMMWORD[rsp] + lea rsp,[24+rsp] + ret + +$L$SEH_end_gcm_init_clmul_5: + +global gcm_ghash_clmul + +ALIGN 32 +gcm_ghash_clmul: + +$L$SEH_begin_gcm_ghash_clmul_1: +_CET_ENDBR +$L$_ghash_clmul: + lea rax,[((-136))+rsp] + lea rsp,[((-32))+rax] +$L$SEH_prologue_gcm_ghash_clmul_2: + movaps XMMWORD[(-32)+rax],xmm6 +$L$SEH_prologue_gcm_ghash_clmul_3: + movaps XMMWORD[(-16)+rax],xmm7 +$L$SEH_prologue_gcm_ghash_clmul_4: + movaps XMMWORD[rax],xmm8 +$L$SEH_prologue_gcm_ghash_clmul_5: + movaps XMMWORD[16+rax],xmm9 +$L$SEH_prologue_gcm_ghash_clmul_6: + movaps XMMWORD[32+rax],xmm10 +$L$SEH_prologue_gcm_ghash_clmul_7: + movaps XMMWORD[48+rax],xmm11 +$L$SEH_prologue_gcm_ghash_clmul_8: + movaps XMMWORD[64+rax],xmm12 +$L$SEH_prologue_gcm_ghash_clmul_9: + movaps XMMWORD[80+rax],xmm13 +$L$SEH_prologue_gcm_ghash_clmul_10: + movaps XMMWORD[96+rax],xmm14 +$L$SEH_prologue_gcm_ghash_clmul_11: + movaps XMMWORD[112+rax],xmm15 +$L$SEH_prologue_gcm_ghash_clmul_12: +$L$SEH_endprologue_gcm_ghash_clmul_13: + movdqa xmm10,XMMWORD[$L$bswap_mask] + + movdqu xmm0,XMMWORD[rcx] + movdqu xmm2,XMMWORD[rdx] + movdqu xmm7,XMMWORD[32+rdx] +DB 102,65,15,56,0,194 + + sub r9,0x10 + jz NEAR $L$odd_tail + + movdqu xmm6,XMMWORD[16+rdx] + cmp r9,0x30 + jb NEAR $L$skip4x + + sub r9,0x30 + mov rax,0xA040608020C0E000 + movdqu xmm14,XMMWORD[48+rdx] + movdqu xmm15,XMMWORD[64+rdx] + + + + + movdqu xmm3,XMMWORD[48+r8] + movdqu xmm11,XMMWORD[32+r8] +DB 102,65,15,56,0,218 +DB 102,69,15,56,0,218 + movdqa xmm5,xmm3 + pshufd xmm4,xmm3,78 + pxor xmm4,xmm3 +DB 102,15,58,68,218,0 +DB 102,15,58,68,234,17 +DB 102,15,58,68,231,0 + + movdqa xmm13,xmm11 + pshufd xmm12,xmm11,78 + pxor xmm12,xmm11 +DB 102,68,15,58,68,222,0 +DB 102,68,15,58,68,238,17 +DB 102,68,15,58,68,231,16 + xorps xmm3,xmm11 + xorps xmm5,xmm13 + movups xmm7,XMMWORD[80+rdx] + xorps xmm4,xmm12 + + movdqu xmm11,XMMWORD[16+r8] + movdqu xmm8,XMMWORD[r8] +DB 102,69,15,56,0,218 +DB 102,69,15,56,0,194 + movdqa xmm13,xmm11 + pshufd xmm12,xmm11,78 + pxor xmm0,xmm8 + pxor xmm12,xmm11 +DB 102,69,15,58,68,222,0 + movdqa xmm1,xmm0 + pshufd xmm8,xmm0,78 + pxor xmm8,xmm0 +DB 102,69,15,58,68,238,17 +DB 102,68,15,58,68,231,0 + xorps xmm3,xmm11 + xorps xmm5,xmm13 + + lea r8,[64+r8] + sub r9,0x40 + jc NEAR $L$tail4x + + jmp NEAR $L$mod4_loop +ALIGN 32 +$L$mod4_loop: +DB 102,65,15,58,68,199,0 + xorps xmm4,xmm12 + movdqu xmm11,XMMWORD[48+r8] +DB 102,69,15,56,0,218 +DB 102,65,15,58,68,207,17 + xorps xmm0,xmm3 + movdqu xmm3,XMMWORD[32+r8] + movdqa xmm13,xmm11 +DB 102,68,15,58,68,199,16 + pshufd xmm12,xmm11,78 + xorps xmm1,xmm5 + pxor xmm12,xmm11 +DB 102,65,15,56,0,218 + movups xmm7,XMMWORD[32+rdx] + xorps xmm8,xmm4 +DB 102,68,15,58,68,218,0 + pshufd xmm4,xmm3,78 + + pxor xmm8,xmm0 + movdqa xmm5,xmm3 + pxor xmm8,xmm1 + pxor xmm4,xmm3 + movdqa xmm9,xmm8 +DB 102,68,15,58,68,234,17 + pslldq xmm8,8 + psrldq xmm9,8 + pxor xmm0,xmm8 + movdqa xmm8,XMMWORD[$L$7_mask] + pxor xmm1,xmm9 +DB 102,76,15,110,200 + + pand xmm8,xmm0 +DB 102,69,15,56,0,200 + pxor xmm9,xmm0 +DB 102,68,15,58,68,231,0 + psllq xmm9,57 + movdqa xmm8,xmm9 + pslldq xmm9,8 +DB 102,15,58,68,222,0 + psrldq xmm8,8 + pxor xmm0,xmm9 + pxor xmm1,xmm8 + movdqu xmm8,XMMWORD[r8] + + movdqa xmm9,xmm0 + psrlq xmm0,1 +DB 102,15,58,68,238,17 + xorps xmm3,xmm11 + movdqu xmm11,XMMWORD[16+r8] +DB 102,69,15,56,0,218 +DB 102,15,58,68,231,16 + xorps xmm5,xmm13 + movups xmm7,XMMWORD[80+rdx] +DB 102,69,15,56,0,194 + pxor xmm1,xmm9 + pxor xmm9,xmm0 + psrlq xmm0,5 + + movdqa xmm13,xmm11 + pxor xmm4,xmm12 + pshufd xmm12,xmm11,78 + pxor xmm0,xmm9 + pxor xmm1,xmm8 + pxor xmm12,xmm11 +DB 102,69,15,58,68,222,0 + psrlq xmm0,1 + pxor xmm0,xmm1 + movdqa xmm1,xmm0 +DB 102,69,15,58,68,238,17 + xorps xmm3,xmm11 + pshufd xmm8,xmm0,78 + pxor xmm8,xmm0 + +DB 102,68,15,58,68,231,0 + xorps xmm5,xmm13 + + lea r8,[64+r8] + sub r9,0x40 + jnc NEAR $L$mod4_loop + +$L$tail4x: +DB 102,65,15,58,68,199,0 +DB 102,65,15,58,68,207,17 +DB 102,68,15,58,68,199,16 + xorps xmm4,xmm12 + xorps xmm0,xmm3 + xorps xmm1,xmm5 + pxor xmm1,xmm0 + pxor xmm8,xmm4 + + pxor xmm8,xmm1 + pxor xmm1,xmm0 + + movdqa xmm9,xmm8 + psrldq xmm8,8 + pslldq xmm9,8 + pxor xmm1,xmm8 + pxor xmm0,xmm9 + + movdqa xmm4,xmm0 + movdqa xmm3,xmm0 + psllq xmm0,5 + pxor xmm3,xmm0 + psllq xmm0,1 + pxor xmm0,xmm3 + psllq xmm0,57 + movdqa xmm3,xmm0 + pslldq xmm0,8 + psrldq xmm3,8 + pxor xmm0,xmm4 + pxor xmm1,xmm3 + + + movdqa xmm4,xmm0 + psrlq xmm0,1 + pxor xmm1,xmm4 + pxor xmm4,xmm0 + psrlq xmm0,5 + pxor xmm0,xmm4 + psrlq xmm0,1 + pxor xmm0,xmm1 + add r9,0x40 + jz NEAR $L$done + movdqu xmm7,XMMWORD[32+rdx] + sub r9,0x10 + jz NEAR $L$odd_tail +$L$skip4x: + + + + + + movdqu xmm8,XMMWORD[r8] + movdqu xmm3,XMMWORD[16+r8] +DB 102,69,15,56,0,194 +DB 102,65,15,56,0,218 + pxor xmm0,xmm8 + + movdqa xmm5,xmm3 + pshufd xmm4,xmm3,78 + pxor xmm4,xmm3 +DB 102,15,58,68,218,0 +DB 102,15,58,68,234,17 +DB 102,15,58,68,231,0 + + lea r8,[32+r8] + nop + sub r9,0x20 + jbe NEAR $L$even_tail + nop + jmp NEAR $L$mod_loop + +ALIGN 32 +$L$mod_loop: + movdqa xmm1,xmm0 + movdqa xmm8,xmm4 + pshufd xmm4,xmm0,78 + pxor xmm4,xmm0 + +DB 102,15,58,68,198,0 +DB 102,15,58,68,206,17 +DB 102,15,58,68,231,16 + + pxor xmm0,xmm3 + pxor xmm1,xmm5 + movdqu xmm9,XMMWORD[r8] + pxor xmm8,xmm0 +DB 102,69,15,56,0,202 + movdqu xmm3,XMMWORD[16+r8] + + pxor xmm8,xmm1 + pxor xmm1,xmm9 + pxor xmm4,xmm8 +DB 102,65,15,56,0,218 + movdqa xmm8,xmm4 + psrldq xmm8,8 + pslldq xmm4,8 + pxor xmm1,xmm8 + pxor xmm0,xmm4 + + movdqa xmm5,xmm3 + + movdqa xmm9,xmm0 + movdqa xmm8,xmm0 + psllq xmm0,5 + pxor xmm8,xmm0 +DB 102,15,58,68,218,0 + psllq xmm0,1 + pxor xmm0,xmm8 + psllq xmm0,57 + movdqa xmm8,xmm0 + pslldq xmm0,8 + psrldq xmm8,8 + pxor xmm0,xmm9 + pshufd xmm4,xmm5,78 + pxor xmm1,xmm8 + pxor xmm4,xmm5 + + movdqa xmm9,xmm0 + psrlq xmm0,1 +DB 102,15,58,68,234,17 + pxor xmm1,xmm9 + pxor xmm9,xmm0 + psrlq xmm0,5 + pxor xmm0,xmm9 + lea r8,[32+r8] + psrlq xmm0,1 +DB 102,15,58,68,231,0 + pxor xmm0,xmm1 + + sub r9,0x20 + ja NEAR $L$mod_loop + +$L$even_tail: + movdqa xmm1,xmm0 + movdqa xmm8,xmm4 + pshufd xmm4,xmm0,78 + pxor xmm4,xmm0 + +DB 102,15,58,68,198,0 +DB 102,15,58,68,206,17 +DB 102,15,58,68,231,16 + + pxor xmm0,xmm3 + pxor xmm1,xmm5 + pxor xmm8,xmm0 + pxor xmm8,xmm1 + pxor xmm4,xmm8 + movdqa xmm8,xmm4 + psrldq xmm8,8 + pslldq xmm4,8 + pxor xmm1,xmm8 + pxor xmm0,xmm4 + + movdqa xmm4,xmm0 + movdqa xmm3,xmm0 + psllq xmm0,5 + pxor xmm3,xmm0 + psllq xmm0,1 + pxor xmm0,xmm3 + psllq xmm0,57 + movdqa xmm3,xmm0 + pslldq xmm0,8 + psrldq xmm3,8 + pxor xmm0,xmm4 + pxor xmm1,xmm3 + + + movdqa xmm4,xmm0 + psrlq xmm0,1 + pxor xmm1,xmm4 + pxor xmm4,xmm0 + psrlq xmm0,5 + pxor xmm0,xmm4 + psrlq xmm0,1 + pxor xmm0,xmm1 + test r9,r9 + jnz NEAR $L$done + +$L$odd_tail: + movdqu xmm8,XMMWORD[r8] +DB 102,69,15,56,0,194 + pxor xmm0,xmm8 + movdqa xmm1,xmm0 + pshufd xmm3,xmm0,78 + pxor xmm3,xmm0 +DB 102,15,58,68,194,0 +DB 102,15,58,68,202,17 +DB 102,15,58,68,223,0 + pxor xmm3,xmm0 + pxor xmm3,xmm1 + + movdqa xmm4,xmm3 + psrldq xmm3,8 + pslldq xmm4,8 + pxor xmm1,xmm3 + pxor xmm0,xmm4 + + movdqa xmm4,xmm0 + movdqa xmm3,xmm0 + psllq xmm0,5 + pxor xmm3,xmm0 + psllq xmm0,1 + pxor xmm0,xmm3 + psllq xmm0,57 + movdqa xmm3,xmm0 + pslldq xmm0,8 + psrldq xmm3,8 + pxor xmm0,xmm4 + pxor xmm1,xmm3 + + + movdqa xmm4,xmm0 + psrlq xmm0,1 + pxor xmm1,xmm4 + pxor xmm4,xmm0 + psrlq xmm0,5 + pxor xmm0,xmm4 + psrlq xmm0,1 + pxor xmm0,xmm1 +$L$done: +DB 102,65,15,56,0,194 + movdqu XMMWORD[rcx],xmm0 + movaps xmm6,XMMWORD[rsp] + movaps xmm7,XMMWORD[16+rsp] + movaps xmm8,XMMWORD[32+rsp] + movaps xmm9,XMMWORD[48+rsp] + movaps xmm10,XMMWORD[64+rsp] + movaps xmm11,XMMWORD[80+rsp] + movaps xmm12,XMMWORD[96+rsp] + movaps xmm13,XMMWORD[112+rsp] + movaps xmm14,XMMWORD[128+rsp] + movaps xmm15,XMMWORD[144+rsp] + lea rsp,[168+rsp] + ret + +$L$SEH_end_gcm_ghash_clmul_14: + +global gcm_init_avx + +ALIGN 32 +gcm_init_avx: + +$L$SEH_begin_gcm_init_avx_1: +_CET_ENDBR + sub rsp,0x18 +$L$SEH_prologue_gcm_init_avx_2: + movaps XMMWORD[rsp],xmm6 +$L$SEH_prologue_gcm_init_avx_3: +$L$SEH_endprologue_gcm_init_avx_4: + vzeroupper + + vmovdqu xmm2,XMMWORD[rdx] + vpshufd xmm2,xmm2,78 + + + vpshufd xmm4,xmm2,255 + vpsrlq xmm3,xmm2,63 + vpsllq xmm2,xmm2,1 + vpxor xmm5,xmm5,xmm5 + vpcmpgtd xmm5,xmm5,xmm4 + vpslldq xmm3,xmm3,8 + vpor xmm2,xmm2,xmm3 + + + vpand xmm5,xmm5,XMMWORD[$L$0x1c2_polynomial] + vpxor xmm2,xmm2,xmm5 + + vpunpckhqdq xmm6,xmm2,xmm2 + vmovdqa xmm0,xmm2 + vpxor xmm6,xmm6,xmm2 + mov r10,4 + jmp NEAR $L$init_start_avx +ALIGN 32 +$L$init_loop_avx: + vpalignr xmm5,xmm4,xmm3,8 + vmovdqu XMMWORD[(-16)+rcx],xmm5 + vpunpckhqdq xmm3,xmm0,xmm0 + vpxor xmm3,xmm3,xmm0 + vpclmulqdq xmm1,xmm0,xmm2,0x11 + vpclmulqdq xmm0,xmm0,xmm2,0x00 + vpclmulqdq xmm3,xmm3,xmm6,0x00 + vpxor xmm4,xmm1,xmm0 + vpxor xmm3,xmm3,xmm4 + + vpslldq xmm4,xmm3,8 + vpsrldq xmm3,xmm3,8 + vpxor xmm0,xmm0,xmm4 + vpxor xmm1,xmm1,xmm3 + vpsllq xmm3,xmm0,57 + vpsllq xmm4,xmm0,62 + vpxor xmm4,xmm4,xmm3 + vpsllq xmm3,xmm0,63 + vpxor xmm4,xmm4,xmm3 + vpslldq xmm3,xmm4,8 + vpsrldq xmm4,xmm4,8 + vpxor xmm0,xmm0,xmm3 + vpxor xmm1,xmm1,xmm4 + + vpsrlq xmm4,xmm0,1 + vpxor xmm1,xmm1,xmm0 + vpxor xmm0,xmm0,xmm4 + vpsrlq xmm4,xmm4,5 + vpxor xmm0,xmm0,xmm4 + vpsrlq xmm0,xmm0,1 + vpxor xmm0,xmm0,xmm1 +$L$init_start_avx: + vmovdqa xmm5,xmm0 + vpunpckhqdq xmm3,xmm0,xmm0 + vpxor xmm3,xmm3,xmm0 + vpclmulqdq xmm1,xmm0,xmm2,0x11 + vpclmulqdq xmm0,xmm0,xmm2,0x00 + vpclmulqdq xmm3,xmm3,xmm6,0x00 + vpxor xmm4,xmm1,xmm0 + vpxor xmm3,xmm3,xmm4 + + vpslldq xmm4,xmm3,8 + vpsrldq xmm3,xmm3,8 + vpxor xmm0,xmm0,xmm4 + vpxor xmm1,xmm1,xmm3 + vpsllq xmm3,xmm0,57 + vpsllq xmm4,xmm0,62 + vpxor xmm4,xmm4,xmm3 + vpsllq xmm3,xmm0,63 + vpxor xmm4,xmm4,xmm3 + vpslldq xmm3,xmm4,8 + vpsrldq xmm4,xmm4,8 + vpxor xmm0,xmm0,xmm3 + vpxor xmm1,xmm1,xmm4 + + vpsrlq xmm4,xmm0,1 + vpxor xmm1,xmm1,xmm0 + vpxor xmm0,xmm0,xmm4 + vpsrlq xmm4,xmm4,5 + vpxor xmm0,xmm0,xmm4 + vpsrlq xmm0,xmm0,1 + vpxor xmm0,xmm0,xmm1 + vpshufd xmm3,xmm5,78 + vpshufd xmm4,xmm0,78 + vpxor xmm3,xmm3,xmm5 + vmovdqu XMMWORD[rcx],xmm5 + vpxor xmm4,xmm4,xmm0 + vmovdqu XMMWORD[16+rcx],xmm0 + lea rcx,[48+rcx] + sub r10,1 + jnz NEAR $L$init_loop_avx + + vpalignr xmm5,xmm3,xmm4,8 + vmovdqu XMMWORD[(-16)+rcx],xmm5 + + vzeroupper + movaps xmm6,XMMWORD[rsp] + lea rsp,[24+rsp] + ret +$L$SEH_end_gcm_init_avx_5: + + +global gcm_ghash_avx + +ALIGN 32 +gcm_ghash_avx: + +$L$SEH_begin_gcm_ghash_avx_1: +_CET_ENDBR + lea rax,[((-136))+rsp] + lea rsp,[((-32))+rax] +$L$SEH_prologue_gcm_ghash_avx_2: + movaps XMMWORD[(-32)+rax],xmm6 +$L$SEH_prologue_gcm_ghash_avx_3: + movaps XMMWORD[(-16)+rax],xmm7 +$L$SEH_prologue_gcm_ghash_avx_4: + movaps XMMWORD[rax],xmm8 +$L$SEH_prologue_gcm_ghash_avx_5: + movaps XMMWORD[16+rax],xmm9 +$L$SEH_prologue_gcm_ghash_avx_6: + movaps XMMWORD[32+rax],xmm10 +$L$SEH_prologue_gcm_ghash_avx_7: + movaps XMMWORD[48+rax],xmm11 +$L$SEH_prologue_gcm_ghash_avx_8: + movaps XMMWORD[64+rax],xmm12 +$L$SEH_prologue_gcm_ghash_avx_9: + movaps XMMWORD[80+rax],xmm13 +$L$SEH_prologue_gcm_ghash_avx_10: + movaps XMMWORD[96+rax],xmm14 +$L$SEH_prologue_gcm_ghash_avx_11: + movaps XMMWORD[112+rax],xmm15 +$L$SEH_prologue_gcm_ghash_avx_12: +$L$SEH_endprologue_gcm_ghash_avx_13: + vzeroupper + + vmovdqu xmm10,XMMWORD[rcx] + lea r10,[$L$0x1c2_polynomial] + lea rdx,[64+rdx] + vmovdqu xmm13,XMMWORD[$L$bswap_mask] + vpshufb xmm10,xmm10,xmm13 + cmp r9,0x80 + jb NEAR $L$short_avx + sub r9,0x80 + + vmovdqu xmm14,XMMWORD[112+r8] + vmovdqu xmm6,XMMWORD[((0-64))+rdx] + vpshufb xmm14,xmm14,xmm13 + vmovdqu xmm7,XMMWORD[((32-64))+rdx] + + vpunpckhqdq xmm9,xmm14,xmm14 + vmovdqu xmm15,XMMWORD[96+r8] + vpclmulqdq xmm0,xmm14,xmm6,0x00 + vpxor xmm9,xmm9,xmm14 + vpshufb xmm15,xmm15,xmm13 + vpclmulqdq xmm1,xmm14,xmm6,0x11 + vmovdqu xmm6,XMMWORD[((16-64))+rdx] + vpunpckhqdq xmm8,xmm15,xmm15 + vmovdqu xmm14,XMMWORD[80+r8] + vpclmulqdq xmm2,xmm9,xmm7,0x00 + vpxor xmm8,xmm8,xmm15 + + vpshufb xmm14,xmm14,xmm13 + vpclmulqdq xmm3,xmm15,xmm6,0x00 + vpunpckhqdq xmm9,xmm14,xmm14 + vpclmulqdq xmm4,xmm15,xmm6,0x11 + vmovdqu xmm6,XMMWORD[((48-64))+rdx] + vpxor xmm9,xmm9,xmm14 + vmovdqu xmm15,XMMWORD[64+r8] + vpclmulqdq xmm5,xmm8,xmm7,0x10 + vmovdqu xmm7,XMMWORD[((80-64))+rdx] + + vpshufb xmm15,xmm15,xmm13 + vpxor xmm3,xmm3,xmm0 + vpclmulqdq xmm0,xmm14,xmm6,0x00 + vpxor xmm4,xmm4,xmm1 + vpunpckhqdq xmm8,xmm15,xmm15 + vpclmulqdq xmm1,xmm14,xmm6,0x11 + vmovdqu xmm6,XMMWORD[((64-64))+rdx] + vpxor xmm5,xmm5,xmm2 + vpclmulqdq xmm2,xmm9,xmm7,0x00 + vpxor xmm8,xmm8,xmm15 + + vmovdqu xmm14,XMMWORD[48+r8] + vpxor xmm0,xmm0,xmm3 + vpclmulqdq xmm3,xmm15,xmm6,0x00 + vpxor xmm1,xmm1,xmm4 + vpshufb xmm14,xmm14,xmm13 + vpclmulqdq xmm4,xmm15,xmm6,0x11 + vmovdqu xmm6,XMMWORD[((96-64))+rdx] + vpxor xmm2,xmm2,xmm5 + vpunpckhqdq xmm9,xmm14,xmm14 + vpclmulqdq xmm5,xmm8,xmm7,0x10 + vmovdqu xmm7,XMMWORD[((128-64))+rdx] + vpxor xmm9,xmm9,xmm14 + + vmovdqu xmm15,XMMWORD[32+r8] + vpxor xmm3,xmm3,xmm0 + vpclmulqdq xmm0,xmm14,xmm6,0x00 + vpxor xmm4,xmm4,xmm1 + vpshufb xmm15,xmm15,xmm13 + vpclmulqdq xmm1,xmm14,xmm6,0x11 + vmovdqu xmm6,XMMWORD[((112-64))+rdx] + vpxor xmm5,xmm5,xmm2 + vpunpckhqdq xmm8,xmm15,xmm15 + vpclmulqdq xmm2,xmm9,xmm7,0x00 + vpxor xmm8,xmm8,xmm15 + + vmovdqu xmm14,XMMWORD[16+r8] + vpxor xmm0,xmm0,xmm3 + vpclmulqdq xmm3,xmm15,xmm6,0x00 + vpxor xmm1,xmm1,xmm4 + vpshufb xmm14,xmm14,xmm13 + vpclmulqdq xmm4,xmm15,xmm6,0x11 + vmovdqu xmm6,XMMWORD[((144-64))+rdx] + vpxor xmm2,xmm2,xmm5 + vpunpckhqdq xmm9,xmm14,xmm14 + vpclmulqdq xmm5,xmm8,xmm7,0x10 + vmovdqu xmm7,XMMWORD[((176-64))+rdx] + vpxor xmm9,xmm9,xmm14 + + vmovdqu xmm15,XMMWORD[r8] + vpxor xmm3,xmm3,xmm0 + vpclmulqdq xmm0,xmm14,xmm6,0x00 + vpxor xmm4,xmm4,xmm1 + vpshufb xmm15,xmm15,xmm13 + vpclmulqdq xmm1,xmm14,xmm6,0x11 + vmovdqu xmm6,XMMWORD[((160-64))+rdx] + vpxor xmm5,xmm5,xmm2 + vpclmulqdq xmm2,xmm9,xmm7,0x10 + + lea r8,[128+r8] + cmp r9,0x80 + jb NEAR $L$tail_avx + + vpxor xmm15,xmm15,xmm10 + sub r9,0x80 + jmp NEAR $L$oop8x_avx + +ALIGN 32 +$L$oop8x_avx: + vpunpckhqdq xmm8,xmm15,xmm15 + vmovdqu xmm14,XMMWORD[112+r8] + vpxor xmm3,xmm3,xmm0 + vpxor xmm8,xmm8,xmm15 + vpclmulqdq xmm10,xmm15,xmm6,0x00 + vpshufb xmm14,xmm14,xmm13 + vpxor xmm4,xmm4,xmm1 + vpclmulqdq xmm11,xmm15,xmm6,0x11 + vmovdqu xmm6,XMMWORD[((0-64))+rdx] + vpunpckhqdq xmm9,xmm14,xmm14 + vpxor xmm5,xmm5,xmm2 + vpclmulqdq xmm12,xmm8,xmm7,0x00 + vmovdqu xmm7,XMMWORD[((32-64))+rdx] + vpxor xmm9,xmm9,xmm14 + + vmovdqu xmm15,XMMWORD[96+r8] + vpclmulqdq xmm0,xmm14,xmm6,0x00 + vpxor xmm10,xmm10,xmm3 + vpshufb xmm15,xmm15,xmm13 + vpclmulqdq xmm1,xmm14,xmm6,0x11 + vxorps xmm11,xmm11,xmm4 + vmovdqu xmm6,XMMWORD[((16-64))+rdx] + vpunpckhqdq xmm8,xmm15,xmm15 + vpclmulqdq xmm2,xmm9,xmm7,0x00 + vpxor xmm12,xmm12,xmm5 + vxorps xmm8,xmm8,xmm15 + + vmovdqu xmm14,XMMWORD[80+r8] + vpxor xmm12,xmm12,xmm10 + vpclmulqdq xmm3,xmm15,xmm6,0x00 + vpxor xmm12,xmm12,xmm11 + vpslldq xmm9,xmm12,8 + vpxor xmm3,xmm3,xmm0 + vpclmulqdq xmm4,xmm15,xmm6,0x11 + vpsrldq xmm12,xmm12,8 + vpxor xmm10,xmm10,xmm9 + vmovdqu xmm6,XMMWORD[((48-64))+rdx] + vpshufb xmm14,xmm14,xmm13 + vxorps xmm11,xmm11,xmm12 + vpxor xmm4,xmm4,xmm1 + vpunpckhqdq xmm9,xmm14,xmm14 + vpclmulqdq xmm5,xmm8,xmm7,0x10 + vmovdqu xmm7,XMMWORD[((80-64))+rdx] + vpxor xmm9,xmm9,xmm14 + vpxor xmm5,xmm5,xmm2 + + vmovdqu xmm15,XMMWORD[64+r8] + vpalignr xmm12,xmm10,xmm10,8 + vpclmulqdq xmm0,xmm14,xmm6,0x00 + vpshufb xmm15,xmm15,xmm13 + vpxor xmm0,xmm0,xmm3 + vpclmulqdq xmm1,xmm14,xmm6,0x11 + vmovdqu xmm6,XMMWORD[((64-64))+rdx] + vpunpckhqdq xmm8,xmm15,xmm15 + vpxor xmm1,xmm1,xmm4 + vpclmulqdq xmm2,xmm9,xmm7,0x00 + vxorps xmm8,xmm8,xmm15 + vpxor xmm2,xmm2,xmm5 + + vmovdqu xmm14,XMMWORD[48+r8] + vpclmulqdq xmm10,xmm10,XMMWORD[r10],0x10 + vpclmulqdq xmm3,xmm15,xmm6,0x00 + vpshufb xmm14,xmm14,xmm13 + vpxor xmm3,xmm3,xmm0 + vpclmulqdq xmm4,xmm15,xmm6,0x11 + vmovdqu xmm6,XMMWORD[((96-64))+rdx] + vpunpckhqdq xmm9,xmm14,xmm14 + vpxor xmm4,xmm4,xmm1 + vpclmulqdq xmm5,xmm8,xmm7,0x10 + vmovdqu xmm7,XMMWORD[((128-64))+rdx] + vpxor xmm9,xmm9,xmm14 + vpxor xmm5,xmm5,xmm2 + + vmovdqu xmm15,XMMWORD[32+r8] + vpclmulqdq xmm0,xmm14,xmm6,0x00 + vpshufb xmm15,xmm15,xmm13 + vpxor xmm0,xmm0,xmm3 + vpclmulqdq xmm1,xmm14,xmm6,0x11 + vmovdqu xmm6,XMMWORD[((112-64))+rdx] + vpunpckhqdq xmm8,xmm15,xmm15 + vpxor xmm1,xmm1,xmm4 + vpclmulqdq xmm2,xmm9,xmm7,0x00 + vpxor xmm8,xmm8,xmm15 + vpxor xmm2,xmm2,xmm5 + vxorps xmm10,xmm10,xmm12 + + vmovdqu xmm14,XMMWORD[16+r8] + vpalignr xmm12,xmm10,xmm10,8 + vpclmulqdq xmm3,xmm15,xmm6,0x00 + vpshufb xmm14,xmm14,xmm13 + vpxor xmm3,xmm3,xmm0 + vpclmulqdq xmm4,xmm15,xmm6,0x11 + vmovdqu xmm6,XMMWORD[((144-64))+rdx] + vpclmulqdq xmm10,xmm10,XMMWORD[r10],0x10 + vxorps xmm12,xmm12,xmm11 + vpunpckhqdq xmm9,xmm14,xmm14 + vpxor xmm4,xmm4,xmm1 + vpclmulqdq xmm5,xmm8,xmm7,0x10 + vmovdqu xmm7,XMMWORD[((176-64))+rdx] + vpxor xmm9,xmm9,xmm14 + vpxor xmm5,xmm5,xmm2 + + vmovdqu xmm15,XMMWORD[r8] + vpclmulqdq xmm0,xmm14,xmm6,0x00 + vpshufb xmm15,xmm15,xmm13 + vpclmulqdq xmm1,xmm14,xmm6,0x11 + vmovdqu xmm6,XMMWORD[((160-64))+rdx] + vpxor xmm15,xmm15,xmm12 + vpclmulqdq xmm2,xmm9,xmm7,0x10 + vpxor xmm15,xmm15,xmm10 + + lea r8,[128+r8] + sub r9,0x80 + jnc NEAR $L$oop8x_avx + + add r9,0x80 + jmp NEAR $L$tail_no_xor_avx + +ALIGN 32 +$L$short_avx: + vmovdqu xmm14,XMMWORD[((-16))+r9*1+r8] + lea r8,[r9*1+r8] + vmovdqu xmm6,XMMWORD[((0-64))+rdx] + vmovdqu xmm7,XMMWORD[((32-64))+rdx] + vpshufb xmm15,xmm14,xmm13 + + vmovdqa xmm3,xmm0 + vmovdqa xmm4,xmm1 + vmovdqa xmm5,xmm2 + sub r9,0x10 + jz NEAR $L$tail_avx + + vpunpckhqdq xmm8,xmm15,xmm15 + vpxor xmm3,xmm3,xmm0 + vpclmulqdq xmm0,xmm15,xmm6,0x00 + vpxor xmm8,xmm8,xmm15 + vmovdqu xmm14,XMMWORD[((-32))+r8] + vpxor xmm4,xmm4,xmm1 + vpclmulqdq xmm1,xmm15,xmm6,0x11 + vmovdqu xmm6,XMMWORD[((16-64))+rdx] + vpshufb xmm15,xmm14,xmm13 + vpxor xmm5,xmm5,xmm2 + vpclmulqdq xmm2,xmm8,xmm7,0x00 + vpsrldq xmm7,xmm7,8 + sub r9,0x10 + jz NEAR $L$tail_avx + + vpunpckhqdq xmm8,xmm15,xmm15 + vpxor xmm3,xmm3,xmm0 + vpclmulqdq xmm0,xmm15,xmm6,0x00 + vpxor xmm8,xmm8,xmm15 + vmovdqu xmm14,XMMWORD[((-48))+r8] + vpxor xmm4,xmm4,xmm1 + vpclmulqdq xmm1,xmm15,xmm6,0x11 + vmovdqu xmm6,XMMWORD[((48-64))+rdx] + vpshufb xmm15,xmm14,xmm13 + vpxor xmm5,xmm5,xmm2 + vpclmulqdq xmm2,xmm8,xmm7,0x00 + vmovdqu xmm7,XMMWORD[((80-64))+rdx] + sub r9,0x10 + jz NEAR $L$tail_avx + + vpunpckhqdq xmm8,xmm15,xmm15 + vpxor xmm3,xmm3,xmm0 + vpclmulqdq xmm0,xmm15,xmm6,0x00 + vpxor xmm8,xmm8,xmm15 + vmovdqu xmm14,XMMWORD[((-64))+r8] + vpxor xmm4,xmm4,xmm1 + vpclmulqdq xmm1,xmm15,xmm6,0x11 + vmovdqu xmm6,XMMWORD[((64-64))+rdx] + vpshufb xmm15,xmm14,xmm13 + vpxor xmm5,xmm5,xmm2 + vpclmulqdq xmm2,xmm8,xmm7,0x00 + vpsrldq xmm7,xmm7,8 + sub r9,0x10 + jz NEAR $L$tail_avx + + vpunpckhqdq xmm8,xmm15,xmm15 + vpxor xmm3,xmm3,xmm0 + vpclmulqdq xmm0,xmm15,xmm6,0x00 + vpxor xmm8,xmm8,xmm15 + vmovdqu xmm14,XMMWORD[((-80))+r8] + vpxor xmm4,xmm4,xmm1 + vpclmulqdq xmm1,xmm15,xmm6,0x11 + vmovdqu xmm6,XMMWORD[((96-64))+rdx] + vpshufb xmm15,xmm14,xmm13 + vpxor xmm5,xmm5,xmm2 + vpclmulqdq xmm2,xmm8,xmm7,0x00 + vmovdqu xmm7,XMMWORD[((128-64))+rdx] + sub r9,0x10 + jz NEAR $L$tail_avx + + vpunpckhqdq xmm8,xmm15,xmm15 + vpxor xmm3,xmm3,xmm0 + vpclmulqdq xmm0,xmm15,xmm6,0x00 + vpxor xmm8,xmm8,xmm15 + vmovdqu xmm14,XMMWORD[((-96))+r8] + vpxor xmm4,xmm4,xmm1 + vpclmulqdq xmm1,xmm15,xmm6,0x11 + vmovdqu xmm6,XMMWORD[((112-64))+rdx] + vpshufb xmm15,xmm14,xmm13 + vpxor xmm5,xmm5,xmm2 + vpclmulqdq xmm2,xmm8,xmm7,0x00 + vpsrldq xmm7,xmm7,8 + sub r9,0x10 + jz NEAR $L$tail_avx + + vpunpckhqdq xmm8,xmm15,xmm15 + vpxor xmm3,xmm3,xmm0 + vpclmulqdq xmm0,xmm15,xmm6,0x00 + vpxor xmm8,xmm8,xmm15 + vmovdqu xmm14,XMMWORD[((-112))+r8] + vpxor xmm4,xmm4,xmm1 + vpclmulqdq xmm1,xmm15,xmm6,0x11 + vmovdqu xmm6,XMMWORD[((144-64))+rdx] + vpshufb xmm15,xmm14,xmm13 + vpxor xmm5,xmm5,xmm2 + vpclmulqdq xmm2,xmm8,xmm7,0x00 + vmovq xmm7,QWORD[((184-64))+rdx] + sub r9,0x10 + jmp NEAR $L$tail_avx + +ALIGN 32 +$L$tail_avx: + vpxor xmm15,xmm15,xmm10 +$L$tail_no_xor_avx: + vpunpckhqdq xmm8,xmm15,xmm15 + vpxor xmm3,xmm3,xmm0 + vpclmulqdq xmm0,xmm15,xmm6,0x00 + vpxor xmm8,xmm8,xmm15 + vpxor xmm4,xmm4,xmm1 + vpclmulqdq xmm1,xmm15,xmm6,0x11 + vpxor xmm5,xmm5,xmm2 + vpclmulqdq xmm2,xmm8,xmm7,0x00 + + vmovdqu xmm12,XMMWORD[r10] + + vpxor xmm10,xmm3,xmm0 + vpxor xmm11,xmm4,xmm1 + vpxor xmm5,xmm5,xmm2 + + vpxor xmm5,xmm5,xmm10 + vpxor xmm5,xmm5,xmm11 + vpslldq xmm9,xmm5,8 + vpsrldq xmm5,xmm5,8 + vpxor xmm10,xmm10,xmm9 + vpxor xmm11,xmm11,xmm5 + + vpclmulqdq xmm9,xmm10,xmm12,0x10 + vpalignr xmm10,xmm10,xmm10,8 + vpxor xmm10,xmm10,xmm9 + + vpclmulqdq xmm9,xmm10,xmm12,0x10 + vpalignr xmm10,xmm10,xmm10,8 + vpxor xmm10,xmm10,xmm11 + vpxor xmm10,xmm10,xmm9 + + cmp r9,0 + jne NEAR $L$short_avx + + vpshufb xmm10,xmm10,xmm13 + vmovdqu XMMWORD[rcx],xmm10 + vzeroupper + movaps xmm6,XMMWORD[rsp] + movaps xmm7,XMMWORD[16+rsp] + movaps xmm8,XMMWORD[32+rsp] + movaps xmm9,XMMWORD[48+rsp] + movaps xmm10,XMMWORD[64+rsp] + movaps xmm11,XMMWORD[80+rsp] + movaps xmm12,XMMWORD[96+rsp] + movaps xmm13,XMMWORD[112+rsp] + movaps xmm14,XMMWORD[128+rsp] + movaps xmm15,XMMWORD[144+rsp] + lea rsp,[168+rsp] + ret + +$L$SEH_end_gcm_ghash_avx_14: + +section .rdata rdata align=8 +ALIGN 64 +$L$bswap_mask: + DB 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 +$L$0x1c2_polynomial: + DB 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0xc2 +$L$7_mask: + DD 7,0,7,0 +ALIGN 64 + + DB 71,72,65,83,72,32,102,111,114,32,120,56,54,95,54,52 + DB 44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32 + DB 60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111 + DB 114,103,62,0 +ALIGN 64 +section .text + +section .pdata rdata align=4 +ALIGN 4 + DD $L$SEH_begin_gcm_init_clmul_1 wrt ..imagebase + DD $L$SEH_end_gcm_init_clmul_5 wrt ..imagebase + DD $L$SEH_info_gcm_init_clmul_0 wrt ..imagebase + + DD $L$SEH_begin_gcm_ghash_clmul_1 wrt ..imagebase + DD $L$SEH_end_gcm_ghash_clmul_14 wrt ..imagebase + DD $L$SEH_info_gcm_ghash_clmul_0 wrt ..imagebase + + DD $L$SEH_begin_gcm_init_avx_1 wrt ..imagebase + DD $L$SEH_end_gcm_init_avx_5 wrt ..imagebase + DD $L$SEH_info_gcm_init_avx_0 wrt ..imagebase + + DD $L$SEH_begin_gcm_ghash_avx_1 wrt ..imagebase + DD $L$SEH_end_gcm_ghash_avx_14 wrt ..imagebase + DD $L$SEH_info_gcm_ghash_avx_0 wrt ..imagebase + + +section .xdata rdata align=8 +ALIGN 4 +$L$SEH_info_gcm_init_clmul_0: + DB 1 + DB $L$SEH_endprologue_gcm_init_clmul_4-$L$SEH_begin_gcm_init_clmul_1 + DB 3 + DB 0 + DB $L$SEH_prologue_gcm_init_clmul_3-$L$SEH_begin_gcm_init_clmul_1 + DB 104 + DW 0 + DB $L$SEH_prologue_gcm_init_clmul_2-$L$SEH_begin_gcm_init_clmul_1 + DB 34 + + DW 0 +$L$SEH_info_gcm_ghash_clmul_0: + DB 1 + DB $L$SEH_endprologue_gcm_ghash_clmul_13-$L$SEH_begin_gcm_ghash_clmul_1 + DB 22 + DB 0 + DB $L$SEH_prologue_gcm_ghash_clmul_12-$L$SEH_begin_gcm_ghash_clmul_1 + DB 248 + DW 9 + DB $L$SEH_prologue_gcm_ghash_clmul_11-$L$SEH_begin_gcm_ghash_clmul_1 + DB 232 + DW 8 + DB $L$SEH_prologue_gcm_ghash_clmul_10-$L$SEH_begin_gcm_ghash_clmul_1 + DB 216 + DW 7 + DB $L$SEH_prologue_gcm_ghash_clmul_9-$L$SEH_begin_gcm_ghash_clmul_1 + DB 200 + DW 6 + DB $L$SEH_prologue_gcm_ghash_clmul_8-$L$SEH_begin_gcm_ghash_clmul_1 + DB 184 + DW 5 + DB $L$SEH_prologue_gcm_ghash_clmul_7-$L$SEH_begin_gcm_ghash_clmul_1 + DB 168 + DW 4 + DB $L$SEH_prologue_gcm_ghash_clmul_6-$L$SEH_begin_gcm_ghash_clmul_1 + DB 152 + DW 3 + DB $L$SEH_prologue_gcm_ghash_clmul_5-$L$SEH_begin_gcm_ghash_clmul_1 + DB 136 + DW 2 + DB $L$SEH_prologue_gcm_ghash_clmul_4-$L$SEH_begin_gcm_ghash_clmul_1 + DB 120 + DW 1 + DB $L$SEH_prologue_gcm_ghash_clmul_3-$L$SEH_begin_gcm_ghash_clmul_1 + DB 104 + DW 0 + DB $L$SEH_prologue_gcm_ghash_clmul_2-$L$SEH_begin_gcm_ghash_clmul_1 + DB 1 + DW 21 + +$L$SEH_info_gcm_init_avx_0: + DB 1 + DB $L$SEH_endprologue_gcm_init_avx_4-$L$SEH_begin_gcm_init_avx_1 + DB 3 + DB 0 + DB $L$SEH_prologue_gcm_init_avx_3-$L$SEH_begin_gcm_init_avx_1 + DB 104 + DW 0 + DB $L$SEH_prologue_gcm_init_avx_2-$L$SEH_begin_gcm_init_avx_1 + DB 34 + + DW 0 +$L$SEH_info_gcm_ghash_avx_0: + DB 1 + DB $L$SEH_endprologue_gcm_ghash_avx_13-$L$SEH_begin_gcm_ghash_avx_1 + DB 22 + DB 0 + DB $L$SEH_prologue_gcm_ghash_avx_12-$L$SEH_begin_gcm_ghash_avx_1 + DB 248 + DW 9 + DB $L$SEH_prologue_gcm_ghash_avx_11-$L$SEH_begin_gcm_ghash_avx_1 + DB 232 + DW 8 + DB $L$SEH_prologue_gcm_ghash_avx_10-$L$SEH_begin_gcm_ghash_avx_1 + DB 216 + DW 7 + DB $L$SEH_prologue_gcm_ghash_avx_9-$L$SEH_begin_gcm_ghash_avx_1 + DB 200 + DW 6 + DB $L$SEH_prologue_gcm_ghash_avx_8-$L$SEH_begin_gcm_ghash_avx_1 + DB 184 + DW 5 + DB $L$SEH_prologue_gcm_ghash_avx_7-$L$SEH_begin_gcm_ghash_avx_1 + DB 168 + DW 4 + DB $L$SEH_prologue_gcm_ghash_avx_6-$L$SEH_begin_gcm_ghash_avx_1 + DB 152 + DW 3 + DB $L$SEH_prologue_gcm_ghash_avx_5-$L$SEH_begin_gcm_ghash_avx_1 + DB 136 + DW 2 + DB $L$SEH_prologue_gcm_ghash_avx_4-$L$SEH_begin_gcm_ghash_avx_1 + DB 120 + DW 1 + DB $L$SEH_prologue_gcm_ghash_avx_3-$L$SEH_begin_gcm_ghash_avx_1 + DB 104 + DW 0 + DB $L$SEH_prologue_gcm_ghash_avx_2-$L$SEH_begin_gcm_ghash_avx_1 + DB 1 + DW 21 +%else +; Work around https://bugzilla.nasm.us/show_bug.cgi?id=3392738 +ret +%endif diff --git a/http/vendor/ring/pregenerated/ghash-x86_64-nasm.o b/http/vendor/ring/pregenerated/ghash-x86_64-nasm.o new file mode 100644 index 0000000..2908f94 Binary files /dev/null and b/http/vendor/ring/pregenerated/ghash-x86_64-nasm.o differ diff --git a/http/vendor/ring/pregenerated/ghashv8-armx-ios64.S b/http/vendor/ring/pregenerated/ghashv8-armx-ios64.S new file mode 100644 index 0000000..0747a5f --- /dev/null +++ b/http/vendor/ring/pregenerated/ghashv8-armx-ios64.S @@ -0,0 +1,149 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__APPLE__) +#if __ARM_MAX_ARCH__>=7 +.text + +.globl _gcm_init_clmul +.private_extern _gcm_init_clmul + +.align 4 +_gcm_init_clmul: + AARCH64_VALID_CALL_TARGET + ld1 {v17.2d},[x1] //load input H + movi v19.16b,#0xe1 + shl v19.2d,v19.2d,#57 //0xc2.0 + ext v3.16b,v17.16b,v17.16b,#8 + ushr v18.2d,v19.2d,#63 + dup v17.4s,v17.s[1] + ext v16.16b,v18.16b,v19.16b,#8 //t0=0xc2....01 + ushr v18.2d,v3.2d,#63 + sshr v17.4s,v17.4s,#31 //broadcast carry bit + and v18.16b,v18.16b,v16.16b + shl v3.2d,v3.2d,#1 + ext v18.16b,v18.16b,v18.16b,#8 + and v16.16b,v16.16b,v17.16b + orr v3.16b,v3.16b,v18.16b //H<<<=1 + eor v20.16b,v3.16b,v16.16b //twisted H + st1 {v20.2d},[x0],#16 //store Htable[0] + + //calculate H^2 + ext v16.16b,v20.16b,v20.16b,#8 //Karatsuba pre-processing + pmull v0.1q,v20.1d,v20.1d + eor v16.16b,v16.16b,v20.16b + pmull2 v2.1q,v20.2d,v20.2d + pmull v1.1q,v16.1d,v16.1d + + ext v17.16b,v0.16b,v2.16b,#8 //Karatsuba post-processing + eor v18.16b,v0.16b,v2.16b + eor v1.16b,v1.16b,v17.16b + eor v1.16b,v1.16b,v18.16b + pmull v18.1q,v0.1d,v19.1d //1st phase + + ins v2.d[0],v1.d[1] + ins v1.d[1],v0.d[0] + eor v0.16b,v1.16b,v18.16b + + ext v18.16b,v0.16b,v0.16b,#8 //2nd phase + pmull v0.1q,v0.1d,v19.1d + eor v18.16b,v18.16b,v2.16b + eor v22.16b,v0.16b,v18.16b + + ext v17.16b,v22.16b,v22.16b,#8 //Karatsuba pre-processing + eor v17.16b,v17.16b,v22.16b + ext v21.16b,v16.16b,v17.16b,#8 //pack Karatsuba pre-processed + st1 {v21.2d,v22.2d},[x0],#32 //store Htable[1..2] + //calculate H^3 and H^4 + pmull v0.1q,v20.1d, v22.1d + pmull v5.1q,v22.1d,v22.1d + pmull2 v2.1q,v20.2d, v22.2d + pmull2 v7.1q,v22.2d,v22.2d + pmull v1.1q,v16.1d,v17.1d + pmull v6.1q,v17.1d,v17.1d + + ext v16.16b,v0.16b,v2.16b,#8 //Karatsuba post-processing + ext v17.16b,v5.16b,v7.16b,#8 + eor v18.16b,v0.16b,v2.16b + eor v1.16b,v1.16b,v16.16b + eor v4.16b,v5.16b,v7.16b + eor v6.16b,v6.16b,v17.16b + eor v1.16b,v1.16b,v18.16b + pmull v18.1q,v0.1d,v19.1d //1st phase + eor v6.16b,v6.16b,v4.16b + pmull v4.1q,v5.1d,v19.1d + + ins v2.d[0],v1.d[1] + ins v7.d[0],v6.d[1] + ins v1.d[1],v0.d[0] + ins v6.d[1],v5.d[0] + eor v0.16b,v1.16b,v18.16b + eor v5.16b,v6.16b,v4.16b + + ext v18.16b,v0.16b,v0.16b,#8 //2nd phase + ext v4.16b,v5.16b,v5.16b,#8 + pmull v0.1q,v0.1d,v19.1d + pmull v5.1q,v5.1d,v19.1d + eor v18.16b,v18.16b,v2.16b + eor v4.16b,v4.16b,v7.16b + eor v20.16b, v0.16b,v18.16b //H^3 + eor v22.16b,v5.16b,v4.16b //H^4 + + ext v16.16b,v20.16b, v20.16b,#8 //Karatsuba pre-processing + ext v17.16b,v22.16b,v22.16b,#8 + eor v16.16b,v16.16b,v20.16b + eor v17.16b,v17.16b,v22.16b + ext v21.16b,v16.16b,v17.16b,#8 //pack Karatsuba pre-processed + st1 {v20.2d,v21.2d,v22.2d},[x0] //store Htable[3..5] + ret + +.globl _gcm_gmult_clmul +.private_extern _gcm_gmult_clmul + +.align 4 +_gcm_gmult_clmul: + AARCH64_VALID_CALL_TARGET + ld1 {v17.2d},[x0] //load Xi + movi v19.16b,#0xe1 + ld1 {v20.2d,v21.2d},[x1] //load twisted H, ... + shl v19.2d,v19.2d,#57 +#ifndef __AARCH64EB__ + rev64 v17.16b,v17.16b +#endif + ext v3.16b,v17.16b,v17.16b,#8 + + pmull v0.1q,v20.1d,v3.1d //H.lo·Xi.lo + eor v17.16b,v17.16b,v3.16b //Karatsuba pre-processing + pmull2 v2.1q,v20.2d,v3.2d //H.hi·Xi.hi + pmull v1.1q,v21.1d,v17.1d //(H.lo+H.hi)·(Xi.lo+Xi.hi) + + ext v17.16b,v0.16b,v2.16b,#8 //Karatsuba post-processing + eor v18.16b,v0.16b,v2.16b + eor v1.16b,v1.16b,v17.16b + eor v1.16b,v1.16b,v18.16b + pmull v18.1q,v0.1d,v19.1d //1st phase of reduction + + ins v2.d[0],v1.d[1] + ins v1.d[1],v0.d[0] + eor v0.16b,v1.16b,v18.16b + + ext v18.16b,v0.16b,v0.16b,#8 //2nd phase of reduction + pmull v0.1q,v0.1d,v19.1d + eor v18.16b,v18.16b,v2.16b + eor v0.16b,v0.16b,v18.16b + +#ifndef __AARCH64EB__ + rev64 v0.16b,v0.16b +#endif + ext v0.16b,v0.16b,v0.16b,#8 + st1 {v0.2d},[x0] //write out Xi + + ret + +.byte 71,72,65,83,72,32,102,111,114,32,65,82,77,118,56,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.align 2 +.align 2 +#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__APPLE__) diff --git a/http/vendor/ring/pregenerated/ghashv8-armx-linux64.S b/http/vendor/ring/pregenerated/ghashv8-armx-linux64.S new file mode 100644 index 0000000..4e811b7 --- /dev/null +++ b/http/vendor/ring/pregenerated/ghashv8-armx-linux64.S @@ -0,0 +1,149 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__ELF__) +#if __ARM_MAX_ARCH__>=7 +.text +.arch armv8-a+crypto +.globl gcm_init_clmul +.hidden gcm_init_clmul +.type gcm_init_clmul,%function +.align 4 +gcm_init_clmul: + AARCH64_VALID_CALL_TARGET + ld1 {v17.2d},[x1] //load input H + movi v19.16b,#0xe1 + shl v19.2d,v19.2d,#57 //0xc2.0 + ext v3.16b,v17.16b,v17.16b,#8 + ushr v18.2d,v19.2d,#63 + dup v17.4s,v17.s[1] + ext v16.16b,v18.16b,v19.16b,#8 //t0=0xc2....01 + ushr v18.2d,v3.2d,#63 + sshr v17.4s,v17.4s,#31 //broadcast carry bit + and v18.16b,v18.16b,v16.16b + shl v3.2d,v3.2d,#1 + ext v18.16b,v18.16b,v18.16b,#8 + and v16.16b,v16.16b,v17.16b + orr v3.16b,v3.16b,v18.16b //H<<<=1 + eor v20.16b,v3.16b,v16.16b //twisted H + st1 {v20.2d},[x0],#16 //store Htable[0] + + //calculate H^2 + ext v16.16b,v20.16b,v20.16b,#8 //Karatsuba pre-processing + pmull v0.1q,v20.1d,v20.1d + eor v16.16b,v16.16b,v20.16b + pmull2 v2.1q,v20.2d,v20.2d + pmull v1.1q,v16.1d,v16.1d + + ext v17.16b,v0.16b,v2.16b,#8 //Karatsuba post-processing + eor v18.16b,v0.16b,v2.16b + eor v1.16b,v1.16b,v17.16b + eor v1.16b,v1.16b,v18.16b + pmull v18.1q,v0.1d,v19.1d //1st phase + + ins v2.d[0],v1.d[1] + ins v1.d[1],v0.d[0] + eor v0.16b,v1.16b,v18.16b + + ext v18.16b,v0.16b,v0.16b,#8 //2nd phase + pmull v0.1q,v0.1d,v19.1d + eor v18.16b,v18.16b,v2.16b + eor v22.16b,v0.16b,v18.16b + + ext v17.16b,v22.16b,v22.16b,#8 //Karatsuba pre-processing + eor v17.16b,v17.16b,v22.16b + ext v21.16b,v16.16b,v17.16b,#8 //pack Karatsuba pre-processed + st1 {v21.2d,v22.2d},[x0],#32 //store Htable[1..2] + //calculate H^3 and H^4 + pmull v0.1q,v20.1d, v22.1d + pmull v5.1q,v22.1d,v22.1d + pmull2 v2.1q,v20.2d, v22.2d + pmull2 v7.1q,v22.2d,v22.2d + pmull v1.1q,v16.1d,v17.1d + pmull v6.1q,v17.1d,v17.1d + + ext v16.16b,v0.16b,v2.16b,#8 //Karatsuba post-processing + ext v17.16b,v5.16b,v7.16b,#8 + eor v18.16b,v0.16b,v2.16b + eor v1.16b,v1.16b,v16.16b + eor v4.16b,v5.16b,v7.16b + eor v6.16b,v6.16b,v17.16b + eor v1.16b,v1.16b,v18.16b + pmull v18.1q,v0.1d,v19.1d //1st phase + eor v6.16b,v6.16b,v4.16b + pmull v4.1q,v5.1d,v19.1d + + ins v2.d[0],v1.d[1] + ins v7.d[0],v6.d[1] + ins v1.d[1],v0.d[0] + ins v6.d[1],v5.d[0] + eor v0.16b,v1.16b,v18.16b + eor v5.16b,v6.16b,v4.16b + + ext v18.16b,v0.16b,v0.16b,#8 //2nd phase + ext v4.16b,v5.16b,v5.16b,#8 + pmull v0.1q,v0.1d,v19.1d + pmull v5.1q,v5.1d,v19.1d + eor v18.16b,v18.16b,v2.16b + eor v4.16b,v4.16b,v7.16b + eor v20.16b, v0.16b,v18.16b //H^3 + eor v22.16b,v5.16b,v4.16b //H^4 + + ext v16.16b,v20.16b, v20.16b,#8 //Karatsuba pre-processing + ext v17.16b,v22.16b,v22.16b,#8 + eor v16.16b,v16.16b,v20.16b + eor v17.16b,v17.16b,v22.16b + ext v21.16b,v16.16b,v17.16b,#8 //pack Karatsuba pre-processed + st1 {v20.2d,v21.2d,v22.2d},[x0] //store Htable[3..5] + ret +.size gcm_init_clmul,.-gcm_init_clmul +.globl gcm_gmult_clmul +.hidden gcm_gmult_clmul +.type gcm_gmult_clmul,%function +.align 4 +gcm_gmult_clmul: + AARCH64_VALID_CALL_TARGET + ld1 {v17.2d},[x0] //load Xi + movi v19.16b,#0xe1 + ld1 {v20.2d,v21.2d},[x1] //load twisted H, ... + shl v19.2d,v19.2d,#57 +#ifndef __AARCH64EB__ + rev64 v17.16b,v17.16b +#endif + ext v3.16b,v17.16b,v17.16b,#8 + + pmull v0.1q,v20.1d,v3.1d //H.lo·Xi.lo + eor v17.16b,v17.16b,v3.16b //Karatsuba pre-processing + pmull2 v2.1q,v20.2d,v3.2d //H.hi·Xi.hi + pmull v1.1q,v21.1d,v17.1d //(H.lo+H.hi)·(Xi.lo+Xi.hi) + + ext v17.16b,v0.16b,v2.16b,#8 //Karatsuba post-processing + eor v18.16b,v0.16b,v2.16b + eor v1.16b,v1.16b,v17.16b + eor v1.16b,v1.16b,v18.16b + pmull v18.1q,v0.1d,v19.1d //1st phase of reduction + + ins v2.d[0],v1.d[1] + ins v1.d[1],v0.d[0] + eor v0.16b,v1.16b,v18.16b + + ext v18.16b,v0.16b,v0.16b,#8 //2nd phase of reduction + pmull v0.1q,v0.1d,v19.1d + eor v18.16b,v18.16b,v2.16b + eor v0.16b,v0.16b,v18.16b + +#ifndef __AARCH64EB__ + rev64 v0.16b,v0.16b +#endif + ext v0.16b,v0.16b,v0.16b,#8 + st1 {v0.2d},[x0] //write out Xi + + ret +.size gcm_gmult_clmul,.-gcm_gmult_clmul +.byte 71,72,65,83,72,32,102,111,114,32,65,82,77,118,56,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.align 2 +.align 2 +#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__ELF__) diff --git a/http/vendor/ring/pregenerated/ghashv8-armx-win64.S b/http/vendor/ring/pregenerated/ghashv8-armx-win64.S new file mode 100644 index 0000000..86386ac --- /dev/null +++ b/http/vendor/ring/pregenerated/ghashv8-armx-win64.S @@ -0,0 +1,153 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(_WIN32) +#if __ARM_MAX_ARCH__>=7 +.text +.arch armv8-a+crypto +.globl gcm_init_clmul + +.def gcm_init_clmul + .type 32 +.endef +.align 4 +gcm_init_clmul: + AARCH64_VALID_CALL_TARGET + ld1 {v17.2d},[x1] //load input H + movi v19.16b,#0xe1 + shl v19.2d,v19.2d,#57 //0xc2.0 + ext v3.16b,v17.16b,v17.16b,#8 + ushr v18.2d,v19.2d,#63 + dup v17.4s,v17.s[1] + ext v16.16b,v18.16b,v19.16b,#8 //t0=0xc2....01 + ushr v18.2d,v3.2d,#63 + sshr v17.4s,v17.4s,#31 //broadcast carry bit + and v18.16b,v18.16b,v16.16b + shl v3.2d,v3.2d,#1 + ext v18.16b,v18.16b,v18.16b,#8 + and v16.16b,v16.16b,v17.16b + orr v3.16b,v3.16b,v18.16b //H<<<=1 + eor v20.16b,v3.16b,v16.16b //twisted H + st1 {v20.2d},[x0],#16 //store Htable[0] + + //calculate H^2 + ext v16.16b,v20.16b,v20.16b,#8 //Karatsuba pre-processing + pmull v0.1q,v20.1d,v20.1d + eor v16.16b,v16.16b,v20.16b + pmull2 v2.1q,v20.2d,v20.2d + pmull v1.1q,v16.1d,v16.1d + + ext v17.16b,v0.16b,v2.16b,#8 //Karatsuba post-processing + eor v18.16b,v0.16b,v2.16b + eor v1.16b,v1.16b,v17.16b + eor v1.16b,v1.16b,v18.16b + pmull v18.1q,v0.1d,v19.1d //1st phase + + ins v2.d[0],v1.d[1] + ins v1.d[1],v0.d[0] + eor v0.16b,v1.16b,v18.16b + + ext v18.16b,v0.16b,v0.16b,#8 //2nd phase + pmull v0.1q,v0.1d,v19.1d + eor v18.16b,v18.16b,v2.16b + eor v22.16b,v0.16b,v18.16b + + ext v17.16b,v22.16b,v22.16b,#8 //Karatsuba pre-processing + eor v17.16b,v17.16b,v22.16b + ext v21.16b,v16.16b,v17.16b,#8 //pack Karatsuba pre-processed + st1 {v21.2d,v22.2d},[x0],#32 //store Htable[1..2] + //calculate H^3 and H^4 + pmull v0.1q,v20.1d, v22.1d + pmull v5.1q,v22.1d,v22.1d + pmull2 v2.1q,v20.2d, v22.2d + pmull2 v7.1q,v22.2d,v22.2d + pmull v1.1q,v16.1d,v17.1d + pmull v6.1q,v17.1d,v17.1d + + ext v16.16b,v0.16b,v2.16b,#8 //Karatsuba post-processing + ext v17.16b,v5.16b,v7.16b,#8 + eor v18.16b,v0.16b,v2.16b + eor v1.16b,v1.16b,v16.16b + eor v4.16b,v5.16b,v7.16b + eor v6.16b,v6.16b,v17.16b + eor v1.16b,v1.16b,v18.16b + pmull v18.1q,v0.1d,v19.1d //1st phase + eor v6.16b,v6.16b,v4.16b + pmull v4.1q,v5.1d,v19.1d + + ins v2.d[0],v1.d[1] + ins v7.d[0],v6.d[1] + ins v1.d[1],v0.d[0] + ins v6.d[1],v5.d[0] + eor v0.16b,v1.16b,v18.16b + eor v5.16b,v6.16b,v4.16b + + ext v18.16b,v0.16b,v0.16b,#8 //2nd phase + ext v4.16b,v5.16b,v5.16b,#8 + pmull v0.1q,v0.1d,v19.1d + pmull v5.1q,v5.1d,v19.1d + eor v18.16b,v18.16b,v2.16b + eor v4.16b,v4.16b,v7.16b + eor v20.16b, v0.16b,v18.16b //H^3 + eor v22.16b,v5.16b,v4.16b //H^4 + + ext v16.16b,v20.16b, v20.16b,#8 //Karatsuba pre-processing + ext v17.16b,v22.16b,v22.16b,#8 + eor v16.16b,v16.16b,v20.16b + eor v17.16b,v17.16b,v22.16b + ext v21.16b,v16.16b,v17.16b,#8 //pack Karatsuba pre-processed + st1 {v20.2d,v21.2d,v22.2d},[x0] //store Htable[3..5] + ret + +.globl gcm_gmult_clmul + +.def gcm_gmult_clmul + .type 32 +.endef +.align 4 +gcm_gmult_clmul: + AARCH64_VALID_CALL_TARGET + ld1 {v17.2d},[x0] //load Xi + movi v19.16b,#0xe1 + ld1 {v20.2d,v21.2d},[x1] //load twisted H, ... + shl v19.2d,v19.2d,#57 +#ifndef __AARCH64EB__ + rev64 v17.16b,v17.16b +#endif + ext v3.16b,v17.16b,v17.16b,#8 + + pmull v0.1q,v20.1d,v3.1d //H.lo·Xi.lo + eor v17.16b,v17.16b,v3.16b //Karatsuba pre-processing + pmull2 v2.1q,v20.2d,v3.2d //H.hi·Xi.hi + pmull v1.1q,v21.1d,v17.1d //(H.lo+H.hi)·(Xi.lo+Xi.hi) + + ext v17.16b,v0.16b,v2.16b,#8 //Karatsuba post-processing + eor v18.16b,v0.16b,v2.16b + eor v1.16b,v1.16b,v17.16b + eor v1.16b,v1.16b,v18.16b + pmull v18.1q,v0.1d,v19.1d //1st phase of reduction + + ins v2.d[0],v1.d[1] + ins v1.d[1],v0.d[0] + eor v0.16b,v1.16b,v18.16b + + ext v18.16b,v0.16b,v0.16b,#8 //2nd phase of reduction + pmull v0.1q,v0.1d,v19.1d + eor v18.16b,v18.16b,v2.16b + eor v0.16b,v0.16b,v18.16b + +#ifndef __AARCH64EB__ + rev64 v0.16b,v0.16b +#endif + ext v0.16b,v0.16b,v0.16b,#8 + st1 {v0.2d},[x0] //write out Xi + + ret + +.byte 71,72,65,83,72,32,102,111,114,32,65,82,77,118,56,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.align 2 +.align 2 +#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(_WIN32) diff --git a/http/vendor/ring/pregenerated/p256-armv8-asm-ios64.S b/http/vendor/ring/pregenerated/p256-armv8-asm-ios64.S new file mode 100644 index 0000000..88355ca --- /dev/null +++ b/http/vendor/ring/pregenerated/p256-armv8-asm-ios64.S @@ -0,0 +1,1608 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__APPLE__) +.section __TEXT,__const +.align 5 +Lpoly: +.quad 0xffffffffffffffff,0x00000000ffffffff,0x0000000000000000,0xffffffff00000001 +LRR: // 2^512 mod P precomputed for NIST P256 polynomial +.quad 0x0000000000000003,0xfffffffbffffffff,0xfffffffffffffffe,0x00000004fffffffd +Lone_mont: +.quad 0x0000000000000001,0xffffffff00000000,0xffffffffffffffff,0x00000000fffffffe +Lone: +.quad 1,0,0,0 +Lord: +.quad 0xf3b9cac2fc632551,0xbce6faada7179e84,0xffffffffffffffff,0xffffffff00000000 +LordK: +.quad 0xccd1c8aaee00bc4f +.byte 69,67,80,95,78,73,83,84,90,50,53,54,32,102,111,114,32,65,82,77,118,56,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.align 2 +.text + +// void ecp_nistz256_mul_mont(BN_ULONG x0[4],const BN_ULONG x1[4], +// const BN_ULONG x2[4]); +.globl _ecp_nistz256_mul_mont +.private_extern _ecp_nistz256_mul_mont + +.align 4 +_ecp_nistz256_mul_mont: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-32]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + + ldr x3,[x2] // bp[0] + ldp x4,x5,[x1] + ldp x6,x7,[x1,#16] + adrp x13,Lpoly@PAGE + add x13,x13,Lpoly@PAGEOFF + ldr x12,[x13,#8] + ldr x13,[x13,#24] + + bl __ecp_nistz256_mul_mont + + ldp x19,x20,[sp,#16] + ldp x29,x30,[sp],#32 + AARCH64_VALIDATE_LINK_REGISTER + ret + + +// void ecp_nistz256_sqr_mont(BN_ULONG x0[4],const BN_ULONG x1[4]); +.globl _ecp_nistz256_sqr_mont +.private_extern _ecp_nistz256_sqr_mont + +.align 4 +_ecp_nistz256_sqr_mont: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-32]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + + ldp x4,x5,[x1] + ldp x6,x7,[x1,#16] + adrp x13,Lpoly@PAGE + add x13,x13,Lpoly@PAGEOFF + ldr x12,[x13,#8] + ldr x13,[x13,#24] + + bl __ecp_nistz256_sqr_mont + + ldp x19,x20,[sp,#16] + ldp x29,x30,[sp],#32 + AARCH64_VALIDATE_LINK_REGISTER + ret + + +// void ecp_nistz256_neg(BN_ULONG x0[4],const BN_ULONG x1[4]); +.globl _ecp_nistz256_neg +.private_extern _ecp_nistz256_neg + +.align 4 +_ecp_nistz256_neg: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-16]! + add x29,sp,#0 + + mov x2,x1 + mov x14,xzr // a = 0 + mov x15,xzr + mov x16,xzr + mov x17,xzr + adrp x13,Lpoly@PAGE + add x13,x13,Lpoly@PAGEOFF + ldr x12,[x13,#8] + ldr x13,[x13,#24] + + bl __ecp_nistz256_sub_from + + ldp x29,x30,[sp],#16 + AARCH64_VALIDATE_LINK_REGISTER + ret + + +// note that __ecp_nistz256_mul_mont expects a[0-3] input pre-loaded +// to x4-x7 and b[0] - to x3 + +.align 4 +__ecp_nistz256_mul_mont: + mul x14,x4,x3 // a[0]*b[0] + umulh x8,x4,x3 + + mul x15,x5,x3 // a[1]*b[0] + umulh x9,x5,x3 + + mul x16,x6,x3 // a[2]*b[0] + umulh x10,x6,x3 + + mul x17,x7,x3 // a[3]*b[0] + umulh x11,x7,x3 + ldr x3,[x2,#8] // b[1] + + adds x15,x15,x8 // accumulate high parts of multiplication + lsl x8,x14,#32 + adcs x16,x16,x9 + lsr x9,x14,#32 + adcs x17,x17,x10 + adc x19,xzr,x11 + mov x20,xzr + subs x10,x14,x8 // "*0xffff0001" + sbc x11,x14,x9 + adds x14,x15,x8 // +=acc[0]<<96 and omit acc[0] + mul x8,x4,x3 // lo(a[0]*b[i]) + adcs x15,x16,x9 + mul x9,x5,x3 // lo(a[1]*b[i]) + adcs x16,x17,x10 // +=acc[0]*0xffff0001 + mul x10,x6,x3 // lo(a[2]*b[i]) + adcs x17,x19,x11 + mul x11,x7,x3 // lo(a[3]*b[i]) + adc x19,x20,xzr + + adds x14,x14,x8 // accumulate low parts of multiplication + umulh x8,x4,x3 // hi(a[0]*b[i]) + adcs x15,x15,x9 + umulh x9,x5,x3 // hi(a[1]*b[i]) + adcs x16,x16,x10 + umulh x10,x6,x3 // hi(a[2]*b[i]) + adcs x17,x17,x11 + umulh x11,x7,x3 // hi(a[3]*b[i]) + adc x19,x19,xzr + ldr x3,[x2,#8*(1+1)] // b[1+1] + adds x15,x15,x8 // accumulate high parts of multiplication + lsl x8,x14,#32 + adcs x16,x16,x9 + lsr x9,x14,#32 + adcs x17,x17,x10 + adcs x19,x19,x11 + adc x20,xzr,xzr + subs x10,x14,x8 // "*0xffff0001" + sbc x11,x14,x9 + adds x14,x15,x8 // +=acc[0]<<96 and omit acc[0] + mul x8,x4,x3 // lo(a[0]*b[i]) + adcs x15,x16,x9 + mul x9,x5,x3 // lo(a[1]*b[i]) + adcs x16,x17,x10 // +=acc[0]*0xffff0001 + mul x10,x6,x3 // lo(a[2]*b[i]) + adcs x17,x19,x11 + mul x11,x7,x3 // lo(a[3]*b[i]) + adc x19,x20,xzr + + adds x14,x14,x8 // accumulate low parts of multiplication + umulh x8,x4,x3 // hi(a[0]*b[i]) + adcs x15,x15,x9 + umulh x9,x5,x3 // hi(a[1]*b[i]) + adcs x16,x16,x10 + umulh x10,x6,x3 // hi(a[2]*b[i]) + adcs x17,x17,x11 + umulh x11,x7,x3 // hi(a[3]*b[i]) + adc x19,x19,xzr + ldr x3,[x2,#8*(2+1)] // b[2+1] + adds x15,x15,x8 // accumulate high parts of multiplication + lsl x8,x14,#32 + adcs x16,x16,x9 + lsr x9,x14,#32 + adcs x17,x17,x10 + adcs x19,x19,x11 + adc x20,xzr,xzr + subs x10,x14,x8 // "*0xffff0001" + sbc x11,x14,x9 + adds x14,x15,x8 // +=acc[0]<<96 and omit acc[0] + mul x8,x4,x3 // lo(a[0]*b[i]) + adcs x15,x16,x9 + mul x9,x5,x3 // lo(a[1]*b[i]) + adcs x16,x17,x10 // +=acc[0]*0xffff0001 + mul x10,x6,x3 // lo(a[2]*b[i]) + adcs x17,x19,x11 + mul x11,x7,x3 // lo(a[3]*b[i]) + adc x19,x20,xzr + + adds x14,x14,x8 // accumulate low parts of multiplication + umulh x8,x4,x3 // hi(a[0]*b[i]) + adcs x15,x15,x9 + umulh x9,x5,x3 // hi(a[1]*b[i]) + adcs x16,x16,x10 + umulh x10,x6,x3 // hi(a[2]*b[i]) + adcs x17,x17,x11 + umulh x11,x7,x3 // hi(a[3]*b[i]) + adc x19,x19,xzr + adds x15,x15,x8 // accumulate high parts of multiplication + lsl x8,x14,#32 + adcs x16,x16,x9 + lsr x9,x14,#32 + adcs x17,x17,x10 + adcs x19,x19,x11 + adc x20,xzr,xzr + // last reduction + subs x10,x14,x8 // "*0xffff0001" + sbc x11,x14,x9 + adds x14,x15,x8 // +=acc[0]<<96 and omit acc[0] + adcs x15,x16,x9 + adcs x16,x17,x10 // +=acc[0]*0xffff0001 + adcs x17,x19,x11 + adc x19,x20,xzr + + adds x8,x14,#1 // subs x8,x14,#-1 // tmp = ret-modulus + sbcs x9,x15,x12 + sbcs x10,x16,xzr + sbcs x11,x17,x13 + sbcs xzr,x19,xzr // did it borrow? + + csel x14,x14,x8,lo // ret = borrow ? ret : ret-modulus + csel x15,x15,x9,lo + csel x16,x16,x10,lo + stp x14,x15,[x0] + csel x17,x17,x11,lo + stp x16,x17,[x0,#16] + + ret + + +// note that __ecp_nistz256_sqr_mont expects a[0-3] input pre-loaded +// to x4-x7 + +.align 4 +__ecp_nistz256_sqr_mont: + // | | | | | |a1*a0| | + // | | | | |a2*a0| | | + // | |a3*a2|a3*a0| | | | + // | | | |a2*a1| | | | + // | | |a3*a1| | | | | + // *| | | | | | | | 2| + // +|a3*a3|a2*a2|a1*a1|a0*a0| + // |--+--+--+--+--+--+--+--| + // |A7|A6|A5|A4|A3|A2|A1|A0|, where Ax is , i.e. follow + // + // "can't overflow" below mark carrying into high part of + // multiplication result, which can't overflow, because it + // can never be all ones. + + mul x15,x5,x4 // a[1]*a[0] + umulh x9,x5,x4 + mul x16,x6,x4 // a[2]*a[0] + umulh x10,x6,x4 + mul x17,x7,x4 // a[3]*a[0] + umulh x19,x7,x4 + + adds x16,x16,x9 // accumulate high parts of multiplication + mul x8,x6,x5 // a[2]*a[1] + umulh x9,x6,x5 + adcs x17,x17,x10 + mul x10,x7,x5 // a[3]*a[1] + umulh x11,x7,x5 + adc x19,x19,xzr // can't overflow + + mul x20,x7,x6 // a[3]*a[2] + umulh x1,x7,x6 + + adds x9,x9,x10 // accumulate high parts of multiplication + mul x14,x4,x4 // a[0]*a[0] + adc x10,x11,xzr // can't overflow + + adds x17,x17,x8 // accumulate low parts of multiplication + umulh x4,x4,x4 + adcs x19,x19,x9 + mul x9,x5,x5 // a[1]*a[1] + adcs x20,x20,x10 + umulh x5,x5,x5 + adc x1,x1,xzr // can't overflow + + adds x15,x15,x15 // acc[1-6]*=2 + mul x10,x6,x6 // a[2]*a[2] + adcs x16,x16,x16 + umulh x6,x6,x6 + adcs x17,x17,x17 + mul x11,x7,x7 // a[3]*a[3] + adcs x19,x19,x19 + umulh x7,x7,x7 + adcs x20,x20,x20 + adcs x1,x1,x1 + adc x2,xzr,xzr + + adds x15,x15,x4 // +a[i]*a[i] + adcs x16,x16,x9 + adcs x17,x17,x5 + adcs x19,x19,x10 + adcs x20,x20,x6 + lsl x8,x14,#32 + adcs x1,x1,x11 + lsr x9,x14,#32 + adc x2,x2,x7 + subs x10,x14,x8 // "*0xffff0001" + sbc x11,x14,x9 + adds x14,x15,x8 // +=acc[0]<<96 and omit acc[0] + adcs x15,x16,x9 + lsl x8,x14,#32 + adcs x16,x17,x10 // +=acc[0]*0xffff0001 + lsr x9,x14,#32 + adc x17,x11,xzr // can't overflow + subs x10,x14,x8 // "*0xffff0001" + sbc x11,x14,x9 + adds x14,x15,x8 // +=acc[0]<<96 and omit acc[0] + adcs x15,x16,x9 + lsl x8,x14,#32 + adcs x16,x17,x10 // +=acc[0]*0xffff0001 + lsr x9,x14,#32 + adc x17,x11,xzr // can't overflow + subs x10,x14,x8 // "*0xffff0001" + sbc x11,x14,x9 + adds x14,x15,x8 // +=acc[0]<<96 and omit acc[0] + adcs x15,x16,x9 + lsl x8,x14,#32 + adcs x16,x17,x10 // +=acc[0]*0xffff0001 + lsr x9,x14,#32 + adc x17,x11,xzr // can't overflow + subs x10,x14,x8 // "*0xffff0001" + sbc x11,x14,x9 + adds x14,x15,x8 // +=acc[0]<<96 and omit acc[0] + adcs x15,x16,x9 + adcs x16,x17,x10 // +=acc[0]*0xffff0001 + adc x17,x11,xzr // can't overflow + + adds x14,x14,x19 // accumulate upper half + adcs x15,x15,x20 + adcs x16,x16,x1 + adcs x17,x17,x2 + adc x19,xzr,xzr + + adds x8,x14,#1 // subs x8,x14,#-1 // tmp = ret-modulus + sbcs x9,x15,x12 + sbcs x10,x16,xzr + sbcs x11,x17,x13 + sbcs xzr,x19,xzr // did it borrow? + + csel x14,x14,x8,lo // ret = borrow ? ret : ret-modulus + csel x15,x15,x9,lo + csel x16,x16,x10,lo + stp x14,x15,[x0] + csel x17,x17,x11,lo + stp x16,x17,[x0,#16] + + ret + + +// Note that __ecp_nistz256_add_to expects both input vectors pre-loaded to +// x4-x7 and x8-x11. This is done because it's used in multiple +// contexts, e.g. in multiplication by 2 and 3... + +.align 4 +__ecp_nistz256_add_to: + adds x14,x14,x8 // ret = a+b + adcs x15,x15,x9 + adcs x16,x16,x10 + adcs x17,x17,x11 + adc x1,xzr,xzr // zap x1 + + adds x8,x14,#1 // subs x8,x4,#-1 // tmp = ret-modulus + sbcs x9,x15,x12 + sbcs x10,x16,xzr + sbcs x11,x17,x13 + sbcs xzr,x1,xzr // did subtraction borrow? + + csel x14,x14,x8,lo // ret = borrow ? ret : ret-modulus + csel x15,x15,x9,lo + csel x16,x16,x10,lo + stp x14,x15,[x0] + csel x17,x17,x11,lo + stp x16,x17,[x0,#16] + + ret + + + +.align 4 +__ecp_nistz256_sub_from: + ldp x8,x9,[x2] + ldp x10,x11,[x2,#16] + subs x14,x14,x8 // ret = a-b + sbcs x15,x15,x9 + sbcs x16,x16,x10 + sbcs x17,x17,x11 + sbc x1,xzr,xzr // zap x1 + + subs x8,x14,#1 // adds x8,x4,#-1 // tmp = ret+modulus + adcs x9,x15,x12 + adcs x10,x16,xzr + adc x11,x17,x13 + cmp x1,xzr // did subtraction borrow? + + csel x14,x14,x8,eq // ret = borrow ? ret+modulus : ret + csel x15,x15,x9,eq + csel x16,x16,x10,eq + stp x14,x15,[x0] + csel x17,x17,x11,eq + stp x16,x17,[x0,#16] + + ret + + + +.align 4 +__ecp_nistz256_sub_morf: + ldp x8,x9,[x2] + ldp x10,x11,[x2,#16] + subs x14,x8,x14 // ret = b-a + sbcs x15,x9,x15 + sbcs x16,x10,x16 + sbcs x17,x11,x17 + sbc x1,xzr,xzr // zap x1 + + subs x8,x14,#1 // adds x8,x4,#-1 // tmp = ret+modulus + adcs x9,x15,x12 + adcs x10,x16,xzr + adc x11,x17,x13 + cmp x1,xzr // did subtraction borrow? + + csel x14,x14,x8,eq // ret = borrow ? ret+modulus : ret + csel x15,x15,x9,eq + csel x16,x16,x10,eq + stp x14,x15,[x0] + csel x17,x17,x11,eq + stp x16,x17,[x0,#16] + + ret + + + +.align 4 +__ecp_nistz256_div_by_2: + subs x8,x14,#1 // adds x8,x4,#-1 // tmp = a+modulus + adcs x9,x15,x12 + adcs x10,x16,xzr + adcs x11,x17,x13 + adc x1,xzr,xzr // zap x1 + tst x14,#1 // is a even? + + csel x14,x14,x8,eq // ret = even ? a : a+modulus + csel x15,x15,x9,eq + csel x16,x16,x10,eq + csel x17,x17,x11,eq + csel x1,xzr,x1,eq + + lsr x14,x14,#1 // ret >>= 1 + orr x14,x14,x15,lsl#63 + lsr x15,x15,#1 + orr x15,x15,x16,lsl#63 + lsr x16,x16,#1 + orr x16,x16,x17,lsl#63 + lsr x17,x17,#1 + stp x14,x15,[x0] + orr x17,x17,x1,lsl#63 + stp x16,x17,[x0,#16] + + ret + +.globl _ecp_nistz256_point_double +.private_extern _ecp_nistz256_point_double + +.align 5 +_ecp_nistz256_point_double: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-96]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + sub sp,sp,#32*4 + +Ldouble_shortcut: + ldp x14,x15,[x1,#32] + mov x21,x0 + ldp x16,x17,[x1,#48] + mov x22,x1 + adrp x13,Lpoly@PAGE + add x13,x13,Lpoly@PAGEOFF + ldr x12,[x13,#8] + mov x8,x14 + ldr x13,[x13,#24] + mov x9,x15 + ldp x4,x5,[x22,#64] // forward load for p256_sqr_mont + mov x10,x16 + mov x11,x17 + ldp x6,x7,[x22,#64+16] + add x0,sp,#0 + bl __ecp_nistz256_add_to // p256_mul_by_2(S, in_y); + + add x0,sp,#64 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(Zsqr, in_z); + + ldp x8,x9,[x22] + ldp x10,x11,[x22,#16] + mov x4,x14 // put Zsqr aside for p256_sub + mov x5,x15 + mov x6,x16 + mov x7,x17 + add x0,sp,#32 + bl __ecp_nistz256_add_to // p256_add(M, Zsqr, in_x); + + add x2,x22,#0 + mov x14,x4 // restore Zsqr + mov x15,x5 + ldp x4,x5,[sp,#0] // forward load for p256_sqr_mont + mov x16,x6 + mov x17,x7 + ldp x6,x7,[sp,#0+16] + add x0,sp,#64 + bl __ecp_nistz256_sub_morf // p256_sub(Zsqr, in_x, Zsqr); + + add x0,sp,#0 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(S, S); + + ldr x3,[x22,#32] + ldp x4,x5,[x22,#64] + ldp x6,x7,[x22,#64+16] + add x2,x22,#32 + add x0,sp,#96 + bl __ecp_nistz256_mul_mont // p256_mul_mont(tmp0, in_z, in_y); + + mov x8,x14 + mov x9,x15 + ldp x4,x5,[sp,#0] // forward load for p256_sqr_mont + mov x10,x16 + mov x11,x17 + ldp x6,x7,[sp,#0+16] + add x0,x21,#64 + bl __ecp_nistz256_add_to // p256_mul_by_2(res_z, tmp0); + + add x0,sp,#96 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(tmp0, S); + + ldr x3,[sp,#64] // forward load for p256_mul_mont + ldp x4,x5,[sp,#32] + ldp x6,x7,[sp,#32+16] + add x0,x21,#32 + bl __ecp_nistz256_div_by_2 // p256_div_by_2(res_y, tmp0); + + add x2,sp,#64 + add x0,sp,#32 + bl __ecp_nistz256_mul_mont // p256_mul_mont(M, M, Zsqr); + + mov x8,x14 // duplicate M + mov x9,x15 + mov x10,x16 + mov x11,x17 + mov x4,x14 // put M aside + mov x5,x15 + mov x6,x16 + mov x7,x17 + add x0,sp,#32 + bl __ecp_nistz256_add_to + mov x8,x4 // restore M + mov x9,x5 + ldr x3,[x22] // forward load for p256_mul_mont + mov x10,x6 + ldp x4,x5,[sp,#0] + mov x11,x7 + ldp x6,x7,[sp,#0+16] + bl __ecp_nistz256_add_to // p256_mul_by_3(M, M); + + add x2,x22,#0 + add x0,sp,#0 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S, S, in_x); + + mov x8,x14 + mov x9,x15 + ldp x4,x5,[sp,#32] // forward load for p256_sqr_mont + mov x10,x16 + mov x11,x17 + ldp x6,x7,[sp,#32+16] + add x0,sp,#96 + bl __ecp_nistz256_add_to // p256_mul_by_2(tmp0, S); + + add x0,x21,#0 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(res_x, M); + + add x2,sp,#96 + bl __ecp_nistz256_sub_from // p256_sub(res_x, res_x, tmp0); + + add x2,sp,#0 + add x0,sp,#0 + bl __ecp_nistz256_sub_morf // p256_sub(S, S, res_x); + + ldr x3,[sp,#32] + mov x4,x14 // copy S + mov x5,x15 + mov x6,x16 + mov x7,x17 + add x2,sp,#32 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S, S, M); + + add x2,x21,#32 + add x0,x21,#32 + bl __ecp_nistz256_sub_from // p256_sub(res_y, S, res_y); + + add sp,x29,#0 // destroy frame + ldp x19,x20,[x29,#16] + ldp x21,x22,[x29,#32] + ldp x29,x30,[sp],#96 + AARCH64_VALIDATE_LINK_REGISTER + ret + +.globl _ecp_nistz256_point_add +.private_extern _ecp_nistz256_point_add + +.align 5 +_ecp_nistz256_point_add: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-96]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + stp x27,x28,[sp,#80] + sub sp,sp,#32*12 + + ldp x4,x5,[x2,#64] // in2_z + ldp x6,x7,[x2,#64+16] + mov x21,x0 + mov x22,x1 + mov x23,x2 + adrp x13,Lpoly@PAGE + add x13,x13,Lpoly@PAGEOFF + ldr x12,[x13,#8] + ldr x13,[x13,#24] + orr x8,x4,x5 + orr x10,x6,x7 + orr x25,x8,x10 + cmp x25,#0 + csetm x25,ne // ~in2infty + add x0,sp,#192 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(Z2sqr, in2_z); + + ldp x4,x5,[x22,#64] // in1_z + ldp x6,x7,[x22,#64+16] + orr x8,x4,x5 + orr x10,x6,x7 + orr x24,x8,x10 + cmp x24,#0 + csetm x24,ne // ~in1infty + add x0,sp,#128 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(Z1sqr, in1_z); + + ldr x3,[x23,#64] + ldp x4,x5,[sp,#192] + ldp x6,x7,[sp,#192+16] + add x2,x23,#64 + add x0,sp,#320 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S1, Z2sqr, in2_z); + + ldr x3,[x22,#64] + ldp x4,x5,[sp,#128] + ldp x6,x7,[sp,#128+16] + add x2,x22,#64 + add x0,sp,#352 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S2, Z1sqr, in1_z); + + ldr x3,[x22,#32] + ldp x4,x5,[sp,#320] + ldp x6,x7,[sp,#320+16] + add x2,x22,#32 + add x0,sp,#320 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S1, S1, in1_y); + + ldr x3,[x23,#32] + ldp x4,x5,[sp,#352] + ldp x6,x7,[sp,#352+16] + add x2,x23,#32 + add x0,sp,#352 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S2, S2, in2_y); + + add x2,sp,#320 + ldr x3,[sp,#192] // forward load for p256_mul_mont + ldp x4,x5,[x22] + ldp x6,x7,[x22,#16] + add x0,sp,#160 + bl __ecp_nistz256_sub_from // p256_sub(R, S2, S1); + + orr x14,x14,x15 // see if result is zero + orr x16,x16,x17 + orr x26,x14,x16 // ~is_equal(S1,S2) + + add x2,sp,#192 + add x0,sp,#256 + bl __ecp_nistz256_mul_mont // p256_mul_mont(U1, in1_x, Z2sqr); + + ldr x3,[sp,#128] + ldp x4,x5,[x23] + ldp x6,x7,[x23,#16] + add x2,sp,#128 + add x0,sp,#288 + bl __ecp_nistz256_mul_mont // p256_mul_mont(U2, in2_x, Z1sqr); + + add x2,sp,#256 + ldp x4,x5,[sp,#160] // forward load for p256_sqr_mont + ldp x6,x7,[sp,#160+16] + add x0,sp,#96 + bl __ecp_nistz256_sub_from // p256_sub(H, U2, U1); + + orr x14,x14,x15 // see if result is zero + orr x16,x16,x17 + orr x14,x14,x16 // ~is_equal(U1,U2) + + mvn x27,x24 // -1/0 -> 0/-1 + mvn x28,x25 // -1/0 -> 0/-1 + orr x14,x14,x27 + orr x14,x14,x28 + orr x14,x14,x26 + cbnz x14,Ladd_proceed // if(~is_equal(U1,U2) | in1infty | in2infty | ~is_equal(S1,S2)) + +Ladd_double: + mov x1,x22 + mov x0,x21 + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + add sp,sp,#256 // #256 is from #32*(12-4). difference in stack frames + b Ldouble_shortcut + +.align 4 +Ladd_proceed: + add x0,sp,#192 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(Rsqr, R); + + ldr x3,[x22,#64] + ldp x4,x5,[sp,#96] + ldp x6,x7,[sp,#96+16] + add x2,x22,#64 + add x0,sp,#64 + bl __ecp_nistz256_mul_mont // p256_mul_mont(res_z, H, in1_z); + + ldp x4,x5,[sp,#96] + ldp x6,x7,[sp,#96+16] + add x0,sp,#128 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(Hsqr, H); + + ldr x3,[x23,#64] + ldp x4,x5,[sp,#64] + ldp x6,x7,[sp,#64+16] + add x2,x23,#64 + add x0,sp,#64 + bl __ecp_nistz256_mul_mont // p256_mul_mont(res_z, res_z, in2_z); + + ldr x3,[sp,#96] + ldp x4,x5,[sp,#128] + ldp x6,x7,[sp,#128+16] + add x2,sp,#96 + add x0,sp,#224 + bl __ecp_nistz256_mul_mont // p256_mul_mont(Hcub, Hsqr, H); + + ldr x3,[sp,#128] + ldp x4,x5,[sp,#256] + ldp x6,x7,[sp,#256+16] + add x2,sp,#128 + add x0,sp,#288 + bl __ecp_nistz256_mul_mont // p256_mul_mont(U2, U1, Hsqr); + + mov x8,x14 + mov x9,x15 + mov x10,x16 + mov x11,x17 + add x0,sp,#128 + bl __ecp_nistz256_add_to // p256_mul_by_2(Hsqr, U2); + + add x2,sp,#192 + add x0,sp,#0 + bl __ecp_nistz256_sub_morf // p256_sub(res_x, Rsqr, Hsqr); + + add x2,sp,#224 + bl __ecp_nistz256_sub_from // p256_sub(res_x, res_x, Hcub); + + add x2,sp,#288 + ldr x3,[sp,#224] // forward load for p256_mul_mont + ldp x4,x5,[sp,#320] + ldp x6,x7,[sp,#320+16] + add x0,sp,#32 + bl __ecp_nistz256_sub_morf // p256_sub(res_y, U2, res_x); + + add x2,sp,#224 + add x0,sp,#352 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S2, S1, Hcub); + + ldr x3,[sp,#160] + ldp x4,x5,[sp,#32] + ldp x6,x7,[sp,#32+16] + add x2,sp,#160 + add x0,sp,#32 + bl __ecp_nistz256_mul_mont // p256_mul_mont(res_y, res_y, R); + + add x2,sp,#352 + bl __ecp_nistz256_sub_from // p256_sub(res_y, res_y, S2); + + ldp x4,x5,[sp,#0] // res + ldp x6,x7,[sp,#0+16] + ldp x8,x9,[x23] // in2 + ldp x10,x11,[x23,#16] + ldp x14,x15,[x22,#0] // in1 + cmp x24,#0 // ~, remember? + ldp x16,x17,[x22,#0+16] + csel x8,x4,x8,ne + csel x9,x5,x9,ne + ldp x4,x5,[sp,#0+0+32] // res + csel x10,x6,x10,ne + csel x11,x7,x11,ne + cmp x25,#0 // ~, remember? + ldp x6,x7,[sp,#0+0+48] + csel x14,x8,x14,ne + csel x15,x9,x15,ne + ldp x8,x9,[x23,#0+32] // in2 + csel x16,x10,x16,ne + csel x17,x11,x17,ne + ldp x10,x11,[x23,#0+48] + stp x14,x15,[x21,#0] + stp x16,x17,[x21,#0+16] + ldp x14,x15,[x22,#32] // in1 + cmp x24,#0 // ~, remember? + ldp x16,x17,[x22,#32+16] + csel x8,x4,x8,ne + csel x9,x5,x9,ne + ldp x4,x5,[sp,#0+32+32] // res + csel x10,x6,x10,ne + csel x11,x7,x11,ne + cmp x25,#0 // ~, remember? + ldp x6,x7,[sp,#0+32+48] + csel x14,x8,x14,ne + csel x15,x9,x15,ne + ldp x8,x9,[x23,#32+32] // in2 + csel x16,x10,x16,ne + csel x17,x11,x17,ne + ldp x10,x11,[x23,#32+48] + stp x14,x15,[x21,#32] + stp x16,x17,[x21,#32+16] + ldp x14,x15,[x22,#64] // in1 + cmp x24,#0 // ~, remember? + ldp x16,x17,[x22,#64+16] + csel x8,x4,x8,ne + csel x9,x5,x9,ne + csel x10,x6,x10,ne + csel x11,x7,x11,ne + cmp x25,#0 // ~, remember? + csel x14,x8,x14,ne + csel x15,x9,x15,ne + csel x16,x10,x16,ne + csel x17,x11,x17,ne + stp x14,x15,[x21,#64] + stp x16,x17,[x21,#64+16] + +Ladd_done: + add sp,x29,#0 // destroy frame + ldp x19,x20,[x29,#16] + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldp x29,x30,[sp],#96 + AARCH64_VALIDATE_LINK_REGISTER + ret + +.globl _ecp_nistz256_point_add_affine +.private_extern _ecp_nistz256_point_add_affine + +.align 5 +_ecp_nistz256_point_add_affine: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-80]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + sub sp,sp,#32*10 + + mov x21,x0 + mov x22,x1 + mov x23,x2 + adrp x13,Lpoly@PAGE + add x13,x13,Lpoly@PAGEOFF + ldr x12,[x13,#8] + ldr x13,[x13,#24] + + ldp x4,x5,[x1,#64] // in1_z + ldp x6,x7,[x1,#64+16] + orr x8,x4,x5 + orr x10,x6,x7 + orr x24,x8,x10 + cmp x24,#0 + csetm x24,ne // ~in1infty + + ldp x14,x15,[x2] // in2_x + ldp x16,x17,[x2,#16] + ldp x8,x9,[x2,#32] // in2_y + ldp x10,x11,[x2,#48] + orr x14,x14,x15 + orr x16,x16,x17 + orr x8,x8,x9 + orr x10,x10,x11 + orr x14,x14,x16 + orr x8,x8,x10 + orr x25,x14,x8 + cmp x25,#0 + csetm x25,ne // ~in2infty + + add x0,sp,#128 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(Z1sqr, in1_z); + + mov x4,x14 + mov x5,x15 + mov x6,x16 + mov x7,x17 + ldr x3,[x23] + add x2,x23,#0 + add x0,sp,#96 + bl __ecp_nistz256_mul_mont // p256_mul_mont(U2, Z1sqr, in2_x); + + add x2,x22,#0 + ldr x3,[x22,#64] // forward load for p256_mul_mont + ldp x4,x5,[sp,#128] + ldp x6,x7,[sp,#128+16] + add x0,sp,#160 + bl __ecp_nistz256_sub_from // p256_sub(H, U2, in1_x); + + add x2,x22,#64 + add x0,sp,#128 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S2, Z1sqr, in1_z); + + ldr x3,[x22,#64] + ldp x4,x5,[sp,#160] + ldp x6,x7,[sp,#160+16] + add x2,x22,#64 + add x0,sp,#64 + bl __ecp_nistz256_mul_mont // p256_mul_mont(res_z, H, in1_z); + + ldr x3,[x23,#32] + ldp x4,x5,[sp,#128] + ldp x6,x7,[sp,#128+16] + add x2,x23,#32 + add x0,sp,#128 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S2, S2, in2_y); + + add x2,x22,#32 + ldp x4,x5,[sp,#160] // forward load for p256_sqr_mont + ldp x6,x7,[sp,#160+16] + add x0,sp,#192 + bl __ecp_nistz256_sub_from // p256_sub(R, S2, in1_y); + + add x0,sp,#224 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(Hsqr, H); + + ldp x4,x5,[sp,#192] + ldp x6,x7,[sp,#192+16] + add x0,sp,#288 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(Rsqr, R); + + ldr x3,[sp,#160] + ldp x4,x5,[sp,#224] + ldp x6,x7,[sp,#224+16] + add x2,sp,#160 + add x0,sp,#256 + bl __ecp_nistz256_mul_mont // p256_mul_mont(Hcub, Hsqr, H); + + ldr x3,[x22] + ldp x4,x5,[sp,#224] + ldp x6,x7,[sp,#224+16] + add x2,x22,#0 + add x0,sp,#96 + bl __ecp_nistz256_mul_mont // p256_mul_mont(U2, in1_x, Hsqr); + + mov x8,x14 + mov x9,x15 + mov x10,x16 + mov x11,x17 + add x0,sp,#224 + bl __ecp_nistz256_add_to // p256_mul_by_2(Hsqr, U2); + + add x2,sp,#288 + add x0,sp,#0 + bl __ecp_nistz256_sub_morf // p256_sub(res_x, Rsqr, Hsqr); + + add x2,sp,#256 + bl __ecp_nistz256_sub_from // p256_sub(res_x, res_x, Hcub); + + add x2,sp,#96 + ldr x3,[x22,#32] // forward load for p256_mul_mont + ldp x4,x5,[sp,#256] + ldp x6,x7,[sp,#256+16] + add x0,sp,#32 + bl __ecp_nistz256_sub_morf // p256_sub(res_y, U2, res_x); + + add x2,x22,#32 + add x0,sp,#128 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S2, in1_y, Hcub); + + ldr x3,[sp,#192] + ldp x4,x5,[sp,#32] + ldp x6,x7,[sp,#32+16] + add x2,sp,#192 + add x0,sp,#32 + bl __ecp_nistz256_mul_mont // p256_mul_mont(res_y, res_y, R); + + add x2,sp,#128 + bl __ecp_nistz256_sub_from // p256_sub(res_y, res_y, S2); + + ldp x4,x5,[sp,#0] // res + ldp x6,x7,[sp,#0+16] + ldp x8,x9,[x23] // in2 + ldp x10,x11,[x23,#16] + ldp x14,x15,[x22,#0] // in1 + cmp x24,#0 // ~, remember? + ldp x16,x17,[x22,#0+16] + csel x8,x4,x8,ne + csel x9,x5,x9,ne + ldp x4,x5,[sp,#0+0+32] // res + csel x10,x6,x10,ne + csel x11,x7,x11,ne + cmp x25,#0 // ~, remember? + ldp x6,x7,[sp,#0+0+48] + csel x14,x8,x14,ne + csel x15,x9,x15,ne + ldp x8,x9,[x23,#0+32] // in2 + csel x16,x10,x16,ne + csel x17,x11,x17,ne + ldp x10,x11,[x23,#0+48] + stp x14,x15,[x21,#0] + stp x16,x17,[x21,#0+16] + adrp x23,Lone_mont@PAGE-64 + add x23,x23,Lone_mont@PAGEOFF-64 + ldp x14,x15,[x22,#32] // in1 + cmp x24,#0 // ~, remember? + ldp x16,x17,[x22,#32+16] + csel x8,x4,x8,ne + csel x9,x5,x9,ne + ldp x4,x5,[sp,#0+32+32] // res + csel x10,x6,x10,ne + csel x11,x7,x11,ne + cmp x25,#0 // ~, remember? + ldp x6,x7,[sp,#0+32+48] + csel x14,x8,x14,ne + csel x15,x9,x15,ne + ldp x8,x9,[x23,#32+32] // in2 + csel x16,x10,x16,ne + csel x17,x11,x17,ne + ldp x10,x11,[x23,#32+48] + stp x14,x15,[x21,#32] + stp x16,x17,[x21,#32+16] + ldp x14,x15,[x22,#64] // in1 + cmp x24,#0 // ~, remember? + ldp x16,x17,[x22,#64+16] + csel x8,x4,x8,ne + csel x9,x5,x9,ne + csel x10,x6,x10,ne + csel x11,x7,x11,ne + cmp x25,#0 // ~, remember? + csel x14,x8,x14,ne + csel x15,x9,x15,ne + csel x16,x10,x16,ne + csel x17,x11,x17,ne + stp x14,x15,[x21,#64] + stp x16,x17,[x21,#64+16] + + add sp,x29,#0 // destroy frame + ldp x19,x20,[x29,#16] + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x29,x30,[sp],#80 + AARCH64_VALIDATE_LINK_REGISTER + ret + +//////////////////////////////////////////////////////////////////////// +// void ecp_nistz256_ord_mul_mont(uint64_t res[4], uint64_t a[4], +// uint64_t b[4]); +.globl _ecp_nistz256_ord_mul_mont +.private_extern _ecp_nistz256_ord_mul_mont + +.align 4 +_ecp_nistz256_ord_mul_mont: + AARCH64_VALID_CALL_TARGET + // Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later. + stp x29,x30,[sp,#-64]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + + adrp x23,Lord@PAGE + add x23,x23,Lord@PAGEOFF + ldr x3,[x2] // bp[0] + ldp x4,x5,[x1] + ldp x6,x7,[x1,#16] + + ldp x12,x13,[x23,#0] + ldp x21,x22,[x23,#16] + ldr x23,[x23,#32] + + mul x14,x4,x3 // a[0]*b[0] + umulh x8,x4,x3 + + mul x15,x5,x3 // a[1]*b[0] + umulh x9,x5,x3 + + mul x16,x6,x3 // a[2]*b[0] + umulh x10,x6,x3 + + mul x17,x7,x3 // a[3]*b[0] + umulh x19,x7,x3 + + mul x24,x14,x23 + + adds x15,x15,x8 // accumulate high parts of multiplication + adcs x16,x16,x9 + adcs x17,x17,x10 + adc x19,x19,xzr + mov x20,xzr + ldr x3,[x2,#8*1] // b[i] + + lsl x8,x24,#32 + subs x16,x16,x24 + lsr x9,x24,#32 + sbcs x17,x17,x8 + sbcs x19,x19,x9 + sbc x20,x20,xzr + + subs xzr,x14,#1 + umulh x9,x12,x24 + mul x10,x13,x24 + umulh x11,x13,x24 + + adcs x10,x10,x9 + mul x8,x4,x3 + adc x11,x11,xzr + mul x9,x5,x3 + + adds x14,x15,x10 + mul x10,x6,x3 + adcs x15,x16,x11 + mul x11,x7,x3 + adcs x16,x17,x24 + adcs x17,x19,x24 + adc x19,x20,xzr + + adds x14,x14,x8 // accumulate low parts + umulh x8,x4,x3 + adcs x15,x15,x9 + umulh x9,x5,x3 + adcs x16,x16,x10 + umulh x10,x6,x3 + adcs x17,x17,x11 + umulh x11,x7,x3 + adc x19,x19,xzr + mul x24,x14,x23 + adds x15,x15,x8 // accumulate high parts + adcs x16,x16,x9 + adcs x17,x17,x10 + adcs x19,x19,x11 + adc x20,xzr,xzr + ldr x3,[x2,#8*2] // b[i] + + lsl x8,x24,#32 + subs x16,x16,x24 + lsr x9,x24,#32 + sbcs x17,x17,x8 + sbcs x19,x19,x9 + sbc x20,x20,xzr + + subs xzr,x14,#1 + umulh x9,x12,x24 + mul x10,x13,x24 + umulh x11,x13,x24 + + adcs x10,x10,x9 + mul x8,x4,x3 + adc x11,x11,xzr + mul x9,x5,x3 + + adds x14,x15,x10 + mul x10,x6,x3 + adcs x15,x16,x11 + mul x11,x7,x3 + adcs x16,x17,x24 + adcs x17,x19,x24 + adc x19,x20,xzr + + adds x14,x14,x8 // accumulate low parts + umulh x8,x4,x3 + adcs x15,x15,x9 + umulh x9,x5,x3 + adcs x16,x16,x10 + umulh x10,x6,x3 + adcs x17,x17,x11 + umulh x11,x7,x3 + adc x19,x19,xzr + mul x24,x14,x23 + adds x15,x15,x8 // accumulate high parts + adcs x16,x16,x9 + adcs x17,x17,x10 + adcs x19,x19,x11 + adc x20,xzr,xzr + ldr x3,[x2,#8*3] // b[i] + + lsl x8,x24,#32 + subs x16,x16,x24 + lsr x9,x24,#32 + sbcs x17,x17,x8 + sbcs x19,x19,x9 + sbc x20,x20,xzr + + subs xzr,x14,#1 + umulh x9,x12,x24 + mul x10,x13,x24 + umulh x11,x13,x24 + + adcs x10,x10,x9 + mul x8,x4,x3 + adc x11,x11,xzr + mul x9,x5,x3 + + adds x14,x15,x10 + mul x10,x6,x3 + adcs x15,x16,x11 + mul x11,x7,x3 + adcs x16,x17,x24 + adcs x17,x19,x24 + adc x19,x20,xzr + + adds x14,x14,x8 // accumulate low parts + umulh x8,x4,x3 + adcs x15,x15,x9 + umulh x9,x5,x3 + adcs x16,x16,x10 + umulh x10,x6,x3 + adcs x17,x17,x11 + umulh x11,x7,x3 + adc x19,x19,xzr + mul x24,x14,x23 + adds x15,x15,x8 // accumulate high parts + adcs x16,x16,x9 + adcs x17,x17,x10 + adcs x19,x19,x11 + adc x20,xzr,xzr + lsl x8,x24,#32 // last reduction + subs x16,x16,x24 + lsr x9,x24,#32 + sbcs x17,x17,x8 + sbcs x19,x19,x9 + sbc x20,x20,xzr + + subs xzr,x14,#1 + umulh x9,x12,x24 + mul x10,x13,x24 + umulh x11,x13,x24 + + adcs x10,x10,x9 + adc x11,x11,xzr + + adds x14,x15,x10 + adcs x15,x16,x11 + adcs x16,x17,x24 + adcs x17,x19,x24 + adc x19,x20,xzr + + subs x8,x14,x12 // ret -= modulus + sbcs x9,x15,x13 + sbcs x10,x16,x21 + sbcs x11,x17,x22 + sbcs xzr,x19,xzr + + csel x14,x14,x8,lo // ret = borrow ? ret : ret-modulus + csel x15,x15,x9,lo + csel x16,x16,x10,lo + stp x14,x15,[x0] + csel x17,x17,x11,lo + stp x16,x17,[x0,#16] + + ldp x19,x20,[sp,#16] + ldp x21,x22,[sp,#32] + ldp x23,x24,[sp,#48] + ldr x29,[sp],#64 + ret + + +//////////////////////////////////////////////////////////////////////// +// void ecp_nistz256_ord_sqr_mont(uint64_t res[4], uint64_t a[4], +// uint64_t rep); +.globl _ecp_nistz256_ord_sqr_mont +.private_extern _ecp_nistz256_ord_sqr_mont + +.align 4 +_ecp_nistz256_ord_sqr_mont: + AARCH64_VALID_CALL_TARGET + // Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later. + stp x29,x30,[sp,#-64]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + + adrp x23,Lord@PAGE + add x23,x23,Lord@PAGEOFF + ldp x4,x5,[x1] + ldp x6,x7,[x1,#16] + + ldp x12,x13,[x23,#0] + ldp x21,x22,[x23,#16] + ldr x23,[x23,#32] + b Loop_ord_sqr + +.align 4 +Loop_ord_sqr: + sub x2,x2,#1 + //////////////////////////////////////////////////////////////// + // | | | | | |a1*a0| | + // | | | | |a2*a0| | | + // | |a3*a2|a3*a0| | | | + // | | | |a2*a1| | | | + // | | |a3*a1| | | | | + // *| | | | | | | | 2| + // +|a3*a3|a2*a2|a1*a1|a0*a0| + // |--+--+--+--+--+--+--+--| + // |A7|A6|A5|A4|A3|A2|A1|A0|, where Ax is , i.e. follow + // + // "can't overflow" below mark carrying into high part of + // multiplication result, which can't overflow, because it + // can never be all ones. + + mul x15,x5,x4 // a[1]*a[0] + umulh x9,x5,x4 + mul x16,x6,x4 // a[2]*a[0] + umulh x10,x6,x4 + mul x17,x7,x4 // a[3]*a[0] + umulh x19,x7,x4 + + adds x16,x16,x9 // accumulate high parts of multiplication + mul x8,x6,x5 // a[2]*a[1] + umulh x9,x6,x5 + adcs x17,x17,x10 + mul x10,x7,x5 // a[3]*a[1] + umulh x11,x7,x5 + adc x19,x19,xzr // can't overflow + + mul x20,x7,x6 // a[3]*a[2] + umulh x1,x7,x6 + + adds x9,x9,x10 // accumulate high parts of multiplication + mul x14,x4,x4 // a[0]*a[0] + adc x10,x11,xzr // can't overflow + + adds x17,x17,x8 // accumulate low parts of multiplication + umulh x4,x4,x4 + adcs x19,x19,x9 + mul x9,x5,x5 // a[1]*a[1] + adcs x20,x20,x10 + umulh x5,x5,x5 + adc x1,x1,xzr // can't overflow + + adds x15,x15,x15 // acc[1-6]*=2 + mul x10,x6,x6 // a[2]*a[2] + adcs x16,x16,x16 + umulh x6,x6,x6 + adcs x17,x17,x17 + mul x11,x7,x7 // a[3]*a[3] + adcs x19,x19,x19 + umulh x7,x7,x7 + adcs x20,x20,x20 + adcs x1,x1,x1 + adc x3,xzr,xzr + + adds x15,x15,x4 // +a[i]*a[i] + mul x24,x14,x23 + adcs x16,x16,x9 + adcs x17,x17,x5 + adcs x19,x19,x10 + adcs x20,x20,x6 + adcs x1,x1,x11 + adc x3,x3,x7 + subs xzr,x14,#1 + umulh x9,x12,x24 + mul x10,x13,x24 + umulh x11,x13,x24 + + adcs x10,x10,x9 + adc x11,x11,xzr + + adds x14,x15,x10 + adcs x15,x16,x11 + adcs x16,x17,x24 + adc x17,xzr,x24 // can't overflow + mul x11,x14,x23 + lsl x8,x24,#32 + subs x15,x15,x24 + lsr x9,x24,#32 + sbcs x16,x16,x8 + sbc x17,x17,x9 // can't borrow + subs xzr,x14,#1 + umulh x9,x12,x11 + mul x10,x13,x11 + umulh x24,x13,x11 + + adcs x10,x10,x9 + adc x24,x24,xzr + + adds x14,x15,x10 + adcs x15,x16,x24 + adcs x16,x17,x11 + adc x17,xzr,x11 // can't overflow + mul x24,x14,x23 + lsl x8,x11,#32 + subs x15,x15,x11 + lsr x9,x11,#32 + sbcs x16,x16,x8 + sbc x17,x17,x9 // can't borrow + subs xzr,x14,#1 + umulh x9,x12,x24 + mul x10,x13,x24 + umulh x11,x13,x24 + + adcs x10,x10,x9 + adc x11,x11,xzr + + adds x14,x15,x10 + adcs x15,x16,x11 + adcs x16,x17,x24 + adc x17,xzr,x24 // can't overflow + mul x11,x14,x23 + lsl x8,x24,#32 + subs x15,x15,x24 + lsr x9,x24,#32 + sbcs x16,x16,x8 + sbc x17,x17,x9 // can't borrow + subs xzr,x14,#1 + umulh x9,x12,x11 + mul x10,x13,x11 + umulh x24,x13,x11 + + adcs x10,x10,x9 + adc x24,x24,xzr + + adds x14,x15,x10 + adcs x15,x16,x24 + adcs x16,x17,x11 + adc x17,xzr,x11 // can't overflow + lsl x8,x11,#32 + subs x15,x15,x11 + lsr x9,x11,#32 + sbcs x16,x16,x8 + sbc x17,x17,x9 // can't borrow + adds x14,x14,x19 // accumulate upper half + adcs x15,x15,x20 + adcs x16,x16,x1 + adcs x17,x17,x3 + adc x19,xzr,xzr + + subs x8,x14,x12 // ret -= modulus + sbcs x9,x15,x13 + sbcs x10,x16,x21 + sbcs x11,x17,x22 + sbcs xzr,x19,xzr + + csel x4,x14,x8,lo // ret = borrow ? ret : ret-modulus + csel x5,x15,x9,lo + csel x6,x16,x10,lo + csel x7,x17,x11,lo + + cbnz x2,Loop_ord_sqr + + stp x4,x5,[x0] + stp x6,x7,[x0,#16] + + ldp x19,x20,[sp,#16] + ldp x21,x22,[sp,#32] + ldp x23,x24,[sp,#48] + ldr x29,[sp],#64 + ret + +//////////////////////////////////////////////////////////////////////// +// void ecp_nistz256_select_w5(uint64_t *val, uint64_t *in_t, int index); +.globl _ecp_nistz256_select_w5 +.private_extern _ecp_nistz256_select_w5 + +.align 4 +_ecp_nistz256_select_w5: + AARCH64_VALID_CALL_TARGET + + // x10 := x0 + // w9 := 0; loop counter and incremented internal index + mov x10, x0 + mov w9, #0 + + // [v16-v21] := 0 + movi v16.16b, #0 + movi v17.16b, #0 + movi v18.16b, #0 + movi v19.16b, #0 + movi v20.16b, #0 + movi v21.16b, #0 + +Lselect_w5_loop: + // Loop 16 times. + + // Increment index (loop counter); tested at the end of the loop + add w9, w9, #1 + + // [v22-v27] := Load a (3*256-bit = 6*128-bit) table entry starting at x1 + // and advance x1 to point to the next entry + ld1 {v22.2d, v23.2d, v24.2d, v25.2d}, [x1],#64 + + // x11 := (w9 == w2)? All 1s : All 0s + cmp w9, w2 + csetm x11, eq + + // continue loading ... + ld1 {v26.2d, v27.2d}, [x1],#32 + + // duplicate mask_64 into Mask (all 0s or all 1s) + dup v3.2d, x11 + + // [v16-v19] := (Mask == all 1s)? [v22-v25] : [v16-v19] + // i.e., values in output registers will remain the same if w9 != w2 + bit v16.16b, v22.16b, v3.16b + bit v17.16b, v23.16b, v3.16b + + bit v18.16b, v24.16b, v3.16b + bit v19.16b, v25.16b, v3.16b + + bit v20.16b, v26.16b, v3.16b + bit v21.16b, v27.16b, v3.16b + + // If bit #4 is not 0 (i.e. idx_ctr < 16) loop back + tbz w9, #4, Lselect_w5_loop + + // Write [v16-v21] to memory at the output pointer + st1 {v16.2d, v17.2d, v18.2d, v19.2d}, [x10],#64 + st1 {v20.2d, v21.2d}, [x10] + + ret + + + +//////////////////////////////////////////////////////////////////////// +// void ecp_nistz256_select_w7(uint64_t *val, uint64_t *in_t, int index); +.globl _ecp_nistz256_select_w7 +.private_extern _ecp_nistz256_select_w7 + +.align 4 +_ecp_nistz256_select_w7: + AARCH64_VALID_CALL_TARGET + + // w9 := 0; loop counter and incremented internal index + mov w9, #0 + + // [v16-v21] := 0 + movi v16.16b, #0 + movi v17.16b, #0 + movi v18.16b, #0 + movi v19.16b, #0 + +Lselect_w7_loop: + // Loop 64 times. + + // Increment index (loop counter); tested at the end of the loop + add w9, w9, #1 + + // [v22-v25] := Load a (2*256-bit = 4*128-bit) table entry starting at x1 + // and advance x1 to point to the next entry + ld1 {v22.2d, v23.2d, v24.2d, v25.2d}, [x1],#64 + + // x11 := (w9 == w2)? All 1s : All 0s + cmp w9, w2 + csetm x11, eq + + // duplicate mask_64 into Mask (all 0s or all 1s) + dup v3.2d, x11 + + // [v16-v19] := (Mask == all 1s)? [v22-v25] : [v16-v19] + // i.e., values in output registers will remain the same if w9 != w2 + bit v16.16b, v22.16b, v3.16b + bit v17.16b, v23.16b, v3.16b + + bit v18.16b, v24.16b, v3.16b + bit v19.16b, v25.16b, v3.16b + + // If bit #6 is not 0 (i.e. idx_ctr < 64) loop back + tbz w9, #6, Lselect_w7_loop + + // Write [v16-v19] to memory at the output pointer + st1 {v16.2d, v17.2d, v18.2d, v19.2d}, [x0] + + ret + +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__APPLE__) diff --git a/http/vendor/ring/pregenerated/p256-armv8-asm-linux64.S b/http/vendor/ring/pregenerated/p256-armv8-asm-linux64.S new file mode 100644 index 0000000..e9a8c52 --- /dev/null +++ b/http/vendor/ring/pregenerated/p256-armv8-asm-linux64.S @@ -0,0 +1,1608 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__ELF__) +.section .rodata +.align 5 +.Lpoly: +.quad 0xffffffffffffffff,0x00000000ffffffff,0x0000000000000000,0xffffffff00000001 +.LRR: // 2^512 mod P precomputed for NIST P256 polynomial +.quad 0x0000000000000003,0xfffffffbffffffff,0xfffffffffffffffe,0x00000004fffffffd +.Lone_mont: +.quad 0x0000000000000001,0xffffffff00000000,0xffffffffffffffff,0x00000000fffffffe +.Lone: +.quad 1,0,0,0 +.Lord: +.quad 0xf3b9cac2fc632551,0xbce6faada7179e84,0xffffffffffffffff,0xffffffff00000000 +.LordK: +.quad 0xccd1c8aaee00bc4f +.byte 69,67,80,95,78,73,83,84,90,50,53,54,32,102,111,114,32,65,82,77,118,56,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.align 2 +.text + +// void ecp_nistz256_mul_mont(BN_ULONG x0[4],const BN_ULONG x1[4], +// const BN_ULONG x2[4]); +.globl ecp_nistz256_mul_mont +.hidden ecp_nistz256_mul_mont +.type ecp_nistz256_mul_mont,%function +.align 4 +ecp_nistz256_mul_mont: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-32]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + + ldr x3,[x2] // bp[0] + ldp x4,x5,[x1] + ldp x6,x7,[x1,#16] + adrp x13,.Lpoly + add x13,x13,:lo12:.Lpoly + ldr x12,[x13,#8] + ldr x13,[x13,#24] + + bl __ecp_nistz256_mul_mont + + ldp x19,x20,[sp,#16] + ldp x29,x30,[sp],#32 + AARCH64_VALIDATE_LINK_REGISTER + ret +.size ecp_nistz256_mul_mont,.-ecp_nistz256_mul_mont + +// void ecp_nistz256_sqr_mont(BN_ULONG x0[4],const BN_ULONG x1[4]); +.globl ecp_nistz256_sqr_mont +.hidden ecp_nistz256_sqr_mont +.type ecp_nistz256_sqr_mont,%function +.align 4 +ecp_nistz256_sqr_mont: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-32]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + + ldp x4,x5,[x1] + ldp x6,x7,[x1,#16] + adrp x13,.Lpoly + add x13,x13,:lo12:.Lpoly + ldr x12,[x13,#8] + ldr x13,[x13,#24] + + bl __ecp_nistz256_sqr_mont + + ldp x19,x20,[sp,#16] + ldp x29,x30,[sp],#32 + AARCH64_VALIDATE_LINK_REGISTER + ret +.size ecp_nistz256_sqr_mont,.-ecp_nistz256_sqr_mont + +// void ecp_nistz256_neg(BN_ULONG x0[4],const BN_ULONG x1[4]); +.globl ecp_nistz256_neg +.hidden ecp_nistz256_neg +.type ecp_nistz256_neg,%function +.align 4 +ecp_nistz256_neg: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-16]! + add x29,sp,#0 + + mov x2,x1 + mov x14,xzr // a = 0 + mov x15,xzr + mov x16,xzr + mov x17,xzr + adrp x13,.Lpoly + add x13,x13,:lo12:.Lpoly + ldr x12,[x13,#8] + ldr x13,[x13,#24] + + bl __ecp_nistz256_sub_from + + ldp x29,x30,[sp],#16 + AARCH64_VALIDATE_LINK_REGISTER + ret +.size ecp_nistz256_neg,.-ecp_nistz256_neg + +// note that __ecp_nistz256_mul_mont expects a[0-3] input pre-loaded +// to x4-x7 and b[0] - to x3 +.type __ecp_nistz256_mul_mont,%function +.align 4 +__ecp_nistz256_mul_mont: + mul x14,x4,x3 // a[0]*b[0] + umulh x8,x4,x3 + + mul x15,x5,x3 // a[1]*b[0] + umulh x9,x5,x3 + + mul x16,x6,x3 // a[2]*b[0] + umulh x10,x6,x3 + + mul x17,x7,x3 // a[3]*b[0] + umulh x11,x7,x3 + ldr x3,[x2,#8] // b[1] + + adds x15,x15,x8 // accumulate high parts of multiplication + lsl x8,x14,#32 + adcs x16,x16,x9 + lsr x9,x14,#32 + adcs x17,x17,x10 + adc x19,xzr,x11 + mov x20,xzr + subs x10,x14,x8 // "*0xffff0001" + sbc x11,x14,x9 + adds x14,x15,x8 // +=acc[0]<<96 and omit acc[0] + mul x8,x4,x3 // lo(a[0]*b[i]) + adcs x15,x16,x9 + mul x9,x5,x3 // lo(a[1]*b[i]) + adcs x16,x17,x10 // +=acc[0]*0xffff0001 + mul x10,x6,x3 // lo(a[2]*b[i]) + adcs x17,x19,x11 + mul x11,x7,x3 // lo(a[3]*b[i]) + adc x19,x20,xzr + + adds x14,x14,x8 // accumulate low parts of multiplication + umulh x8,x4,x3 // hi(a[0]*b[i]) + adcs x15,x15,x9 + umulh x9,x5,x3 // hi(a[1]*b[i]) + adcs x16,x16,x10 + umulh x10,x6,x3 // hi(a[2]*b[i]) + adcs x17,x17,x11 + umulh x11,x7,x3 // hi(a[3]*b[i]) + adc x19,x19,xzr + ldr x3,[x2,#8*(1+1)] // b[1+1] + adds x15,x15,x8 // accumulate high parts of multiplication + lsl x8,x14,#32 + adcs x16,x16,x9 + lsr x9,x14,#32 + adcs x17,x17,x10 + adcs x19,x19,x11 + adc x20,xzr,xzr + subs x10,x14,x8 // "*0xffff0001" + sbc x11,x14,x9 + adds x14,x15,x8 // +=acc[0]<<96 and omit acc[0] + mul x8,x4,x3 // lo(a[0]*b[i]) + adcs x15,x16,x9 + mul x9,x5,x3 // lo(a[1]*b[i]) + adcs x16,x17,x10 // +=acc[0]*0xffff0001 + mul x10,x6,x3 // lo(a[2]*b[i]) + adcs x17,x19,x11 + mul x11,x7,x3 // lo(a[3]*b[i]) + adc x19,x20,xzr + + adds x14,x14,x8 // accumulate low parts of multiplication + umulh x8,x4,x3 // hi(a[0]*b[i]) + adcs x15,x15,x9 + umulh x9,x5,x3 // hi(a[1]*b[i]) + adcs x16,x16,x10 + umulh x10,x6,x3 // hi(a[2]*b[i]) + adcs x17,x17,x11 + umulh x11,x7,x3 // hi(a[3]*b[i]) + adc x19,x19,xzr + ldr x3,[x2,#8*(2+1)] // b[2+1] + adds x15,x15,x8 // accumulate high parts of multiplication + lsl x8,x14,#32 + adcs x16,x16,x9 + lsr x9,x14,#32 + adcs x17,x17,x10 + adcs x19,x19,x11 + adc x20,xzr,xzr + subs x10,x14,x8 // "*0xffff0001" + sbc x11,x14,x9 + adds x14,x15,x8 // +=acc[0]<<96 and omit acc[0] + mul x8,x4,x3 // lo(a[0]*b[i]) + adcs x15,x16,x9 + mul x9,x5,x3 // lo(a[1]*b[i]) + adcs x16,x17,x10 // +=acc[0]*0xffff0001 + mul x10,x6,x3 // lo(a[2]*b[i]) + adcs x17,x19,x11 + mul x11,x7,x3 // lo(a[3]*b[i]) + adc x19,x20,xzr + + adds x14,x14,x8 // accumulate low parts of multiplication + umulh x8,x4,x3 // hi(a[0]*b[i]) + adcs x15,x15,x9 + umulh x9,x5,x3 // hi(a[1]*b[i]) + adcs x16,x16,x10 + umulh x10,x6,x3 // hi(a[2]*b[i]) + adcs x17,x17,x11 + umulh x11,x7,x3 // hi(a[3]*b[i]) + adc x19,x19,xzr + adds x15,x15,x8 // accumulate high parts of multiplication + lsl x8,x14,#32 + adcs x16,x16,x9 + lsr x9,x14,#32 + adcs x17,x17,x10 + adcs x19,x19,x11 + adc x20,xzr,xzr + // last reduction + subs x10,x14,x8 // "*0xffff0001" + sbc x11,x14,x9 + adds x14,x15,x8 // +=acc[0]<<96 and omit acc[0] + adcs x15,x16,x9 + adcs x16,x17,x10 // +=acc[0]*0xffff0001 + adcs x17,x19,x11 + adc x19,x20,xzr + + adds x8,x14,#1 // subs x8,x14,#-1 // tmp = ret-modulus + sbcs x9,x15,x12 + sbcs x10,x16,xzr + sbcs x11,x17,x13 + sbcs xzr,x19,xzr // did it borrow? + + csel x14,x14,x8,lo // ret = borrow ? ret : ret-modulus + csel x15,x15,x9,lo + csel x16,x16,x10,lo + stp x14,x15,[x0] + csel x17,x17,x11,lo + stp x16,x17,[x0,#16] + + ret +.size __ecp_nistz256_mul_mont,.-__ecp_nistz256_mul_mont + +// note that __ecp_nistz256_sqr_mont expects a[0-3] input pre-loaded +// to x4-x7 +.type __ecp_nistz256_sqr_mont,%function +.align 4 +__ecp_nistz256_sqr_mont: + // | | | | | |a1*a0| | + // | | | | |a2*a0| | | + // | |a3*a2|a3*a0| | | | + // | | | |a2*a1| | | | + // | | |a3*a1| | | | | + // *| | | | | | | | 2| + // +|a3*a3|a2*a2|a1*a1|a0*a0| + // |--+--+--+--+--+--+--+--| + // |A7|A6|A5|A4|A3|A2|A1|A0|, where Ax is , i.e. follow + // + // "can't overflow" below mark carrying into high part of + // multiplication result, which can't overflow, because it + // can never be all ones. + + mul x15,x5,x4 // a[1]*a[0] + umulh x9,x5,x4 + mul x16,x6,x4 // a[2]*a[0] + umulh x10,x6,x4 + mul x17,x7,x4 // a[3]*a[0] + umulh x19,x7,x4 + + adds x16,x16,x9 // accumulate high parts of multiplication + mul x8,x6,x5 // a[2]*a[1] + umulh x9,x6,x5 + adcs x17,x17,x10 + mul x10,x7,x5 // a[3]*a[1] + umulh x11,x7,x5 + adc x19,x19,xzr // can't overflow + + mul x20,x7,x6 // a[3]*a[2] + umulh x1,x7,x6 + + adds x9,x9,x10 // accumulate high parts of multiplication + mul x14,x4,x4 // a[0]*a[0] + adc x10,x11,xzr // can't overflow + + adds x17,x17,x8 // accumulate low parts of multiplication + umulh x4,x4,x4 + adcs x19,x19,x9 + mul x9,x5,x5 // a[1]*a[1] + adcs x20,x20,x10 + umulh x5,x5,x5 + adc x1,x1,xzr // can't overflow + + adds x15,x15,x15 // acc[1-6]*=2 + mul x10,x6,x6 // a[2]*a[2] + adcs x16,x16,x16 + umulh x6,x6,x6 + adcs x17,x17,x17 + mul x11,x7,x7 // a[3]*a[3] + adcs x19,x19,x19 + umulh x7,x7,x7 + adcs x20,x20,x20 + adcs x1,x1,x1 + adc x2,xzr,xzr + + adds x15,x15,x4 // +a[i]*a[i] + adcs x16,x16,x9 + adcs x17,x17,x5 + adcs x19,x19,x10 + adcs x20,x20,x6 + lsl x8,x14,#32 + adcs x1,x1,x11 + lsr x9,x14,#32 + adc x2,x2,x7 + subs x10,x14,x8 // "*0xffff0001" + sbc x11,x14,x9 + adds x14,x15,x8 // +=acc[0]<<96 and omit acc[0] + adcs x15,x16,x9 + lsl x8,x14,#32 + adcs x16,x17,x10 // +=acc[0]*0xffff0001 + lsr x9,x14,#32 + adc x17,x11,xzr // can't overflow + subs x10,x14,x8 // "*0xffff0001" + sbc x11,x14,x9 + adds x14,x15,x8 // +=acc[0]<<96 and omit acc[0] + adcs x15,x16,x9 + lsl x8,x14,#32 + adcs x16,x17,x10 // +=acc[0]*0xffff0001 + lsr x9,x14,#32 + adc x17,x11,xzr // can't overflow + subs x10,x14,x8 // "*0xffff0001" + sbc x11,x14,x9 + adds x14,x15,x8 // +=acc[0]<<96 and omit acc[0] + adcs x15,x16,x9 + lsl x8,x14,#32 + adcs x16,x17,x10 // +=acc[0]*0xffff0001 + lsr x9,x14,#32 + adc x17,x11,xzr // can't overflow + subs x10,x14,x8 // "*0xffff0001" + sbc x11,x14,x9 + adds x14,x15,x8 // +=acc[0]<<96 and omit acc[0] + adcs x15,x16,x9 + adcs x16,x17,x10 // +=acc[0]*0xffff0001 + adc x17,x11,xzr // can't overflow + + adds x14,x14,x19 // accumulate upper half + adcs x15,x15,x20 + adcs x16,x16,x1 + adcs x17,x17,x2 + adc x19,xzr,xzr + + adds x8,x14,#1 // subs x8,x14,#-1 // tmp = ret-modulus + sbcs x9,x15,x12 + sbcs x10,x16,xzr + sbcs x11,x17,x13 + sbcs xzr,x19,xzr // did it borrow? + + csel x14,x14,x8,lo // ret = borrow ? ret : ret-modulus + csel x15,x15,x9,lo + csel x16,x16,x10,lo + stp x14,x15,[x0] + csel x17,x17,x11,lo + stp x16,x17,[x0,#16] + + ret +.size __ecp_nistz256_sqr_mont,.-__ecp_nistz256_sqr_mont + +// Note that __ecp_nistz256_add_to expects both input vectors pre-loaded to +// x4-x7 and x8-x11. This is done because it's used in multiple +// contexts, e.g. in multiplication by 2 and 3... +.type __ecp_nistz256_add_to,%function +.align 4 +__ecp_nistz256_add_to: + adds x14,x14,x8 // ret = a+b + adcs x15,x15,x9 + adcs x16,x16,x10 + adcs x17,x17,x11 + adc x1,xzr,xzr // zap x1 + + adds x8,x14,#1 // subs x8,x4,#-1 // tmp = ret-modulus + sbcs x9,x15,x12 + sbcs x10,x16,xzr + sbcs x11,x17,x13 + sbcs xzr,x1,xzr // did subtraction borrow? + + csel x14,x14,x8,lo // ret = borrow ? ret : ret-modulus + csel x15,x15,x9,lo + csel x16,x16,x10,lo + stp x14,x15,[x0] + csel x17,x17,x11,lo + stp x16,x17,[x0,#16] + + ret +.size __ecp_nistz256_add_to,.-__ecp_nistz256_add_to + +.type __ecp_nistz256_sub_from,%function +.align 4 +__ecp_nistz256_sub_from: + ldp x8,x9,[x2] + ldp x10,x11,[x2,#16] + subs x14,x14,x8 // ret = a-b + sbcs x15,x15,x9 + sbcs x16,x16,x10 + sbcs x17,x17,x11 + sbc x1,xzr,xzr // zap x1 + + subs x8,x14,#1 // adds x8,x4,#-1 // tmp = ret+modulus + adcs x9,x15,x12 + adcs x10,x16,xzr + adc x11,x17,x13 + cmp x1,xzr // did subtraction borrow? + + csel x14,x14,x8,eq // ret = borrow ? ret+modulus : ret + csel x15,x15,x9,eq + csel x16,x16,x10,eq + stp x14,x15,[x0] + csel x17,x17,x11,eq + stp x16,x17,[x0,#16] + + ret +.size __ecp_nistz256_sub_from,.-__ecp_nistz256_sub_from + +.type __ecp_nistz256_sub_morf,%function +.align 4 +__ecp_nistz256_sub_morf: + ldp x8,x9,[x2] + ldp x10,x11,[x2,#16] + subs x14,x8,x14 // ret = b-a + sbcs x15,x9,x15 + sbcs x16,x10,x16 + sbcs x17,x11,x17 + sbc x1,xzr,xzr // zap x1 + + subs x8,x14,#1 // adds x8,x4,#-1 // tmp = ret+modulus + adcs x9,x15,x12 + adcs x10,x16,xzr + adc x11,x17,x13 + cmp x1,xzr // did subtraction borrow? + + csel x14,x14,x8,eq // ret = borrow ? ret+modulus : ret + csel x15,x15,x9,eq + csel x16,x16,x10,eq + stp x14,x15,[x0] + csel x17,x17,x11,eq + stp x16,x17,[x0,#16] + + ret +.size __ecp_nistz256_sub_morf,.-__ecp_nistz256_sub_morf + +.type __ecp_nistz256_div_by_2,%function +.align 4 +__ecp_nistz256_div_by_2: + subs x8,x14,#1 // adds x8,x4,#-1 // tmp = a+modulus + adcs x9,x15,x12 + adcs x10,x16,xzr + adcs x11,x17,x13 + adc x1,xzr,xzr // zap x1 + tst x14,#1 // is a even? + + csel x14,x14,x8,eq // ret = even ? a : a+modulus + csel x15,x15,x9,eq + csel x16,x16,x10,eq + csel x17,x17,x11,eq + csel x1,xzr,x1,eq + + lsr x14,x14,#1 // ret >>= 1 + orr x14,x14,x15,lsl#63 + lsr x15,x15,#1 + orr x15,x15,x16,lsl#63 + lsr x16,x16,#1 + orr x16,x16,x17,lsl#63 + lsr x17,x17,#1 + stp x14,x15,[x0] + orr x17,x17,x1,lsl#63 + stp x16,x17,[x0,#16] + + ret +.size __ecp_nistz256_div_by_2,.-__ecp_nistz256_div_by_2 +.globl ecp_nistz256_point_double +.hidden ecp_nistz256_point_double +.type ecp_nistz256_point_double,%function +.align 5 +ecp_nistz256_point_double: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-96]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + sub sp,sp,#32*4 + +.Ldouble_shortcut: + ldp x14,x15,[x1,#32] + mov x21,x0 + ldp x16,x17,[x1,#48] + mov x22,x1 + adrp x13,.Lpoly + add x13,x13,:lo12:.Lpoly + ldr x12,[x13,#8] + mov x8,x14 + ldr x13,[x13,#24] + mov x9,x15 + ldp x4,x5,[x22,#64] // forward load for p256_sqr_mont + mov x10,x16 + mov x11,x17 + ldp x6,x7,[x22,#64+16] + add x0,sp,#0 + bl __ecp_nistz256_add_to // p256_mul_by_2(S, in_y); + + add x0,sp,#64 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(Zsqr, in_z); + + ldp x8,x9,[x22] + ldp x10,x11,[x22,#16] + mov x4,x14 // put Zsqr aside for p256_sub + mov x5,x15 + mov x6,x16 + mov x7,x17 + add x0,sp,#32 + bl __ecp_nistz256_add_to // p256_add(M, Zsqr, in_x); + + add x2,x22,#0 + mov x14,x4 // restore Zsqr + mov x15,x5 + ldp x4,x5,[sp,#0] // forward load for p256_sqr_mont + mov x16,x6 + mov x17,x7 + ldp x6,x7,[sp,#0+16] + add x0,sp,#64 + bl __ecp_nistz256_sub_morf // p256_sub(Zsqr, in_x, Zsqr); + + add x0,sp,#0 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(S, S); + + ldr x3,[x22,#32] + ldp x4,x5,[x22,#64] + ldp x6,x7,[x22,#64+16] + add x2,x22,#32 + add x0,sp,#96 + bl __ecp_nistz256_mul_mont // p256_mul_mont(tmp0, in_z, in_y); + + mov x8,x14 + mov x9,x15 + ldp x4,x5,[sp,#0] // forward load for p256_sqr_mont + mov x10,x16 + mov x11,x17 + ldp x6,x7,[sp,#0+16] + add x0,x21,#64 + bl __ecp_nistz256_add_to // p256_mul_by_2(res_z, tmp0); + + add x0,sp,#96 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(tmp0, S); + + ldr x3,[sp,#64] // forward load for p256_mul_mont + ldp x4,x5,[sp,#32] + ldp x6,x7,[sp,#32+16] + add x0,x21,#32 + bl __ecp_nistz256_div_by_2 // p256_div_by_2(res_y, tmp0); + + add x2,sp,#64 + add x0,sp,#32 + bl __ecp_nistz256_mul_mont // p256_mul_mont(M, M, Zsqr); + + mov x8,x14 // duplicate M + mov x9,x15 + mov x10,x16 + mov x11,x17 + mov x4,x14 // put M aside + mov x5,x15 + mov x6,x16 + mov x7,x17 + add x0,sp,#32 + bl __ecp_nistz256_add_to + mov x8,x4 // restore M + mov x9,x5 + ldr x3,[x22] // forward load for p256_mul_mont + mov x10,x6 + ldp x4,x5,[sp,#0] + mov x11,x7 + ldp x6,x7,[sp,#0+16] + bl __ecp_nistz256_add_to // p256_mul_by_3(M, M); + + add x2,x22,#0 + add x0,sp,#0 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S, S, in_x); + + mov x8,x14 + mov x9,x15 + ldp x4,x5,[sp,#32] // forward load for p256_sqr_mont + mov x10,x16 + mov x11,x17 + ldp x6,x7,[sp,#32+16] + add x0,sp,#96 + bl __ecp_nistz256_add_to // p256_mul_by_2(tmp0, S); + + add x0,x21,#0 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(res_x, M); + + add x2,sp,#96 + bl __ecp_nistz256_sub_from // p256_sub(res_x, res_x, tmp0); + + add x2,sp,#0 + add x0,sp,#0 + bl __ecp_nistz256_sub_morf // p256_sub(S, S, res_x); + + ldr x3,[sp,#32] + mov x4,x14 // copy S + mov x5,x15 + mov x6,x16 + mov x7,x17 + add x2,sp,#32 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S, S, M); + + add x2,x21,#32 + add x0,x21,#32 + bl __ecp_nistz256_sub_from // p256_sub(res_y, S, res_y); + + add sp,x29,#0 // destroy frame + ldp x19,x20,[x29,#16] + ldp x21,x22,[x29,#32] + ldp x29,x30,[sp],#96 + AARCH64_VALIDATE_LINK_REGISTER + ret +.size ecp_nistz256_point_double,.-ecp_nistz256_point_double +.globl ecp_nistz256_point_add +.hidden ecp_nistz256_point_add +.type ecp_nistz256_point_add,%function +.align 5 +ecp_nistz256_point_add: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-96]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + stp x27,x28,[sp,#80] + sub sp,sp,#32*12 + + ldp x4,x5,[x2,#64] // in2_z + ldp x6,x7,[x2,#64+16] + mov x21,x0 + mov x22,x1 + mov x23,x2 + adrp x13,.Lpoly + add x13,x13,:lo12:.Lpoly + ldr x12,[x13,#8] + ldr x13,[x13,#24] + orr x8,x4,x5 + orr x10,x6,x7 + orr x25,x8,x10 + cmp x25,#0 + csetm x25,ne // ~in2infty + add x0,sp,#192 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(Z2sqr, in2_z); + + ldp x4,x5,[x22,#64] // in1_z + ldp x6,x7,[x22,#64+16] + orr x8,x4,x5 + orr x10,x6,x7 + orr x24,x8,x10 + cmp x24,#0 + csetm x24,ne // ~in1infty + add x0,sp,#128 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(Z1sqr, in1_z); + + ldr x3,[x23,#64] + ldp x4,x5,[sp,#192] + ldp x6,x7,[sp,#192+16] + add x2,x23,#64 + add x0,sp,#320 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S1, Z2sqr, in2_z); + + ldr x3,[x22,#64] + ldp x4,x5,[sp,#128] + ldp x6,x7,[sp,#128+16] + add x2,x22,#64 + add x0,sp,#352 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S2, Z1sqr, in1_z); + + ldr x3,[x22,#32] + ldp x4,x5,[sp,#320] + ldp x6,x7,[sp,#320+16] + add x2,x22,#32 + add x0,sp,#320 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S1, S1, in1_y); + + ldr x3,[x23,#32] + ldp x4,x5,[sp,#352] + ldp x6,x7,[sp,#352+16] + add x2,x23,#32 + add x0,sp,#352 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S2, S2, in2_y); + + add x2,sp,#320 + ldr x3,[sp,#192] // forward load for p256_mul_mont + ldp x4,x5,[x22] + ldp x6,x7,[x22,#16] + add x0,sp,#160 + bl __ecp_nistz256_sub_from // p256_sub(R, S2, S1); + + orr x14,x14,x15 // see if result is zero + orr x16,x16,x17 + orr x26,x14,x16 // ~is_equal(S1,S2) + + add x2,sp,#192 + add x0,sp,#256 + bl __ecp_nistz256_mul_mont // p256_mul_mont(U1, in1_x, Z2sqr); + + ldr x3,[sp,#128] + ldp x4,x5,[x23] + ldp x6,x7,[x23,#16] + add x2,sp,#128 + add x0,sp,#288 + bl __ecp_nistz256_mul_mont // p256_mul_mont(U2, in2_x, Z1sqr); + + add x2,sp,#256 + ldp x4,x5,[sp,#160] // forward load for p256_sqr_mont + ldp x6,x7,[sp,#160+16] + add x0,sp,#96 + bl __ecp_nistz256_sub_from // p256_sub(H, U2, U1); + + orr x14,x14,x15 // see if result is zero + orr x16,x16,x17 + orr x14,x14,x16 // ~is_equal(U1,U2) + + mvn x27,x24 // -1/0 -> 0/-1 + mvn x28,x25 // -1/0 -> 0/-1 + orr x14,x14,x27 + orr x14,x14,x28 + orr x14,x14,x26 + cbnz x14,.Ladd_proceed // if(~is_equal(U1,U2) | in1infty | in2infty | ~is_equal(S1,S2)) + +.Ladd_double: + mov x1,x22 + mov x0,x21 + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + add sp,sp,#256 // #256 is from #32*(12-4). difference in stack frames + b .Ldouble_shortcut + +.align 4 +.Ladd_proceed: + add x0,sp,#192 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(Rsqr, R); + + ldr x3,[x22,#64] + ldp x4,x5,[sp,#96] + ldp x6,x7,[sp,#96+16] + add x2,x22,#64 + add x0,sp,#64 + bl __ecp_nistz256_mul_mont // p256_mul_mont(res_z, H, in1_z); + + ldp x4,x5,[sp,#96] + ldp x6,x7,[sp,#96+16] + add x0,sp,#128 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(Hsqr, H); + + ldr x3,[x23,#64] + ldp x4,x5,[sp,#64] + ldp x6,x7,[sp,#64+16] + add x2,x23,#64 + add x0,sp,#64 + bl __ecp_nistz256_mul_mont // p256_mul_mont(res_z, res_z, in2_z); + + ldr x3,[sp,#96] + ldp x4,x5,[sp,#128] + ldp x6,x7,[sp,#128+16] + add x2,sp,#96 + add x0,sp,#224 + bl __ecp_nistz256_mul_mont // p256_mul_mont(Hcub, Hsqr, H); + + ldr x3,[sp,#128] + ldp x4,x5,[sp,#256] + ldp x6,x7,[sp,#256+16] + add x2,sp,#128 + add x0,sp,#288 + bl __ecp_nistz256_mul_mont // p256_mul_mont(U2, U1, Hsqr); + + mov x8,x14 + mov x9,x15 + mov x10,x16 + mov x11,x17 + add x0,sp,#128 + bl __ecp_nistz256_add_to // p256_mul_by_2(Hsqr, U2); + + add x2,sp,#192 + add x0,sp,#0 + bl __ecp_nistz256_sub_morf // p256_sub(res_x, Rsqr, Hsqr); + + add x2,sp,#224 + bl __ecp_nistz256_sub_from // p256_sub(res_x, res_x, Hcub); + + add x2,sp,#288 + ldr x3,[sp,#224] // forward load for p256_mul_mont + ldp x4,x5,[sp,#320] + ldp x6,x7,[sp,#320+16] + add x0,sp,#32 + bl __ecp_nistz256_sub_morf // p256_sub(res_y, U2, res_x); + + add x2,sp,#224 + add x0,sp,#352 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S2, S1, Hcub); + + ldr x3,[sp,#160] + ldp x4,x5,[sp,#32] + ldp x6,x7,[sp,#32+16] + add x2,sp,#160 + add x0,sp,#32 + bl __ecp_nistz256_mul_mont // p256_mul_mont(res_y, res_y, R); + + add x2,sp,#352 + bl __ecp_nistz256_sub_from // p256_sub(res_y, res_y, S2); + + ldp x4,x5,[sp,#0] // res + ldp x6,x7,[sp,#0+16] + ldp x8,x9,[x23] // in2 + ldp x10,x11,[x23,#16] + ldp x14,x15,[x22,#0] // in1 + cmp x24,#0 // ~, remember? + ldp x16,x17,[x22,#0+16] + csel x8,x4,x8,ne + csel x9,x5,x9,ne + ldp x4,x5,[sp,#0+0+32] // res + csel x10,x6,x10,ne + csel x11,x7,x11,ne + cmp x25,#0 // ~, remember? + ldp x6,x7,[sp,#0+0+48] + csel x14,x8,x14,ne + csel x15,x9,x15,ne + ldp x8,x9,[x23,#0+32] // in2 + csel x16,x10,x16,ne + csel x17,x11,x17,ne + ldp x10,x11,[x23,#0+48] + stp x14,x15,[x21,#0] + stp x16,x17,[x21,#0+16] + ldp x14,x15,[x22,#32] // in1 + cmp x24,#0 // ~, remember? + ldp x16,x17,[x22,#32+16] + csel x8,x4,x8,ne + csel x9,x5,x9,ne + ldp x4,x5,[sp,#0+32+32] // res + csel x10,x6,x10,ne + csel x11,x7,x11,ne + cmp x25,#0 // ~, remember? + ldp x6,x7,[sp,#0+32+48] + csel x14,x8,x14,ne + csel x15,x9,x15,ne + ldp x8,x9,[x23,#32+32] // in2 + csel x16,x10,x16,ne + csel x17,x11,x17,ne + ldp x10,x11,[x23,#32+48] + stp x14,x15,[x21,#32] + stp x16,x17,[x21,#32+16] + ldp x14,x15,[x22,#64] // in1 + cmp x24,#0 // ~, remember? + ldp x16,x17,[x22,#64+16] + csel x8,x4,x8,ne + csel x9,x5,x9,ne + csel x10,x6,x10,ne + csel x11,x7,x11,ne + cmp x25,#0 // ~, remember? + csel x14,x8,x14,ne + csel x15,x9,x15,ne + csel x16,x10,x16,ne + csel x17,x11,x17,ne + stp x14,x15,[x21,#64] + stp x16,x17,[x21,#64+16] + +.Ladd_done: + add sp,x29,#0 // destroy frame + ldp x19,x20,[x29,#16] + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldp x29,x30,[sp],#96 + AARCH64_VALIDATE_LINK_REGISTER + ret +.size ecp_nistz256_point_add,.-ecp_nistz256_point_add +.globl ecp_nistz256_point_add_affine +.hidden ecp_nistz256_point_add_affine +.type ecp_nistz256_point_add_affine,%function +.align 5 +ecp_nistz256_point_add_affine: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-80]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + sub sp,sp,#32*10 + + mov x21,x0 + mov x22,x1 + mov x23,x2 + adrp x13,.Lpoly + add x13,x13,:lo12:.Lpoly + ldr x12,[x13,#8] + ldr x13,[x13,#24] + + ldp x4,x5,[x1,#64] // in1_z + ldp x6,x7,[x1,#64+16] + orr x8,x4,x5 + orr x10,x6,x7 + orr x24,x8,x10 + cmp x24,#0 + csetm x24,ne // ~in1infty + + ldp x14,x15,[x2] // in2_x + ldp x16,x17,[x2,#16] + ldp x8,x9,[x2,#32] // in2_y + ldp x10,x11,[x2,#48] + orr x14,x14,x15 + orr x16,x16,x17 + orr x8,x8,x9 + orr x10,x10,x11 + orr x14,x14,x16 + orr x8,x8,x10 + orr x25,x14,x8 + cmp x25,#0 + csetm x25,ne // ~in2infty + + add x0,sp,#128 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(Z1sqr, in1_z); + + mov x4,x14 + mov x5,x15 + mov x6,x16 + mov x7,x17 + ldr x3,[x23] + add x2,x23,#0 + add x0,sp,#96 + bl __ecp_nistz256_mul_mont // p256_mul_mont(U2, Z1sqr, in2_x); + + add x2,x22,#0 + ldr x3,[x22,#64] // forward load for p256_mul_mont + ldp x4,x5,[sp,#128] + ldp x6,x7,[sp,#128+16] + add x0,sp,#160 + bl __ecp_nistz256_sub_from // p256_sub(H, U2, in1_x); + + add x2,x22,#64 + add x0,sp,#128 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S2, Z1sqr, in1_z); + + ldr x3,[x22,#64] + ldp x4,x5,[sp,#160] + ldp x6,x7,[sp,#160+16] + add x2,x22,#64 + add x0,sp,#64 + bl __ecp_nistz256_mul_mont // p256_mul_mont(res_z, H, in1_z); + + ldr x3,[x23,#32] + ldp x4,x5,[sp,#128] + ldp x6,x7,[sp,#128+16] + add x2,x23,#32 + add x0,sp,#128 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S2, S2, in2_y); + + add x2,x22,#32 + ldp x4,x5,[sp,#160] // forward load for p256_sqr_mont + ldp x6,x7,[sp,#160+16] + add x0,sp,#192 + bl __ecp_nistz256_sub_from // p256_sub(R, S2, in1_y); + + add x0,sp,#224 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(Hsqr, H); + + ldp x4,x5,[sp,#192] + ldp x6,x7,[sp,#192+16] + add x0,sp,#288 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(Rsqr, R); + + ldr x3,[sp,#160] + ldp x4,x5,[sp,#224] + ldp x6,x7,[sp,#224+16] + add x2,sp,#160 + add x0,sp,#256 + bl __ecp_nistz256_mul_mont // p256_mul_mont(Hcub, Hsqr, H); + + ldr x3,[x22] + ldp x4,x5,[sp,#224] + ldp x6,x7,[sp,#224+16] + add x2,x22,#0 + add x0,sp,#96 + bl __ecp_nistz256_mul_mont // p256_mul_mont(U2, in1_x, Hsqr); + + mov x8,x14 + mov x9,x15 + mov x10,x16 + mov x11,x17 + add x0,sp,#224 + bl __ecp_nistz256_add_to // p256_mul_by_2(Hsqr, U2); + + add x2,sp,#288 + add x0,sp,#0 + bl __ecp_nistz256_sub_morf // p256_sub(res_x, Rsqr, Hsqr); + + add x2,sp,#256 + bl __ecp_nistz256_sub_from // p256_sub(res_x, res_x, Hcub); + + add x2,sp,#96 + ldr x3,[x22,#32] // forward load for p256_mul_mont + ldp x4,x5,[sp,#256] + ldp x6,x7,[sp,#256+16] + add x0,sp,#32 + bl __ecp_nistz256_sub_morf // p256_sub(res_y, U2, res_x); + + add x2,x22,#32 + add x0,sp,#128 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S2, in1_y, Hcub); + + ldr x3,[sp,#192] + ldp x4,x5,[sp,#32] + ldp x6,x7,[sp,#32+16] + add x2,sp,#192 + add x0,sp,#32 + bl __ecp_nistz256_mul_mont // p256_mul_mont(res_y, res_y, R); + + add x2,sp,#128 + bl __ecp_nistz256_sub_from // p256_sub(res_y, res_y, S2); + + ldp x4,x5,[sp,#0] // res + ldp x6,x7,[sp,#0+16] + ldp x8,x9,[x23] // in2 + ldp x10,x11,[x23,#16] + ldp x14,x15,[x22,#0] // in1 + cmp x24,#0 // ~, remember? + ldp x16,x17,[x22,#0+16] + csel x8,x4,x8,ne + csel x9,x5,x9,ne + ldp x4,x5,[sp,#0+0+32] // res + csel x10,x6,x10,ne + csel x11,x7,x11,ne + cmp x25,#0 // ~, remember? + ldp x6,x7,[sp,#0+0+48] + csel x14,x8,x14,ne + csel x15,x9,x15,ne + ldp x8,x9,[x23,#0+32] // in2 + csel x16,x10,x16,ne + csel x17,x11,x17,ne + ldp x10,x11,[x23,#0+48] + stp x14,x15,[x21,#0] + stp x16,x17,[x21,#0+16] + adrp x23,.Lone_mont-64 + add x23,x23,:lo12:.Lone_mont-64 + ldp x14,x15,[x22,#32] // in1 + cmp x24,#0 // ~, remember? + ldp x16,x17,[x22,#32+16] + csel x8,x4,x8,ne + csel x9,x5,x9,ne + ldp x4,x5,[sp,#0+32+32] // res + csel x10,x6,x10,ne + csel x11,x7,x11,ne + cmp x25,#0 // ~, remember? + ldp x6,x7,[sp,#0+32+48] + csel x14,x8,x14,ne + csel x15,x9,x15,ne + ldp x8,x9,[x23,#32+32] // in2 + csel x16,x10,x16,ne + csel x17,x11,x17,ne + ldp x10,x11,[x23,#32+48] + stp x14,x15,[x21,#32] + stp x16,x17,[x21,#32+16] + ldp x14,x15,[x22,#64] // in1 + cmp x24,#0 // ~, remember? + ldp x16,x17,[x22,#64+16] + csel x8,x4,x8,ne + csel x9,x5,x9,ne + csel x10,x6,x10,ne + csel x11,x7,x11,ne + cmp x25,#0 // ~, remember? + csel x14,x8,x14,ne + csel x15,x9,x15,ne + csel x16,x10,x16,ne + csel x17,x11,x17,ne + stp x14,x15,[x21,#64] + stp x16,x17,[x21,#64+16] + + add sp,x29,#0 // destroy frame + ldp x19,x20,[x29,#16] + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x29,x30,[sp],#80 + AARCH64_VALIDATE_LINK_REGISTER + ret +.size ecp_nistz256_point_add_affine,.-ecp_nistz256_point_add_affine +//////////////////////////////////////////////////////////////////////// +// void ecp_nistz256_ord_mul_mont(uint64_t res[4], uint64_t a[4], +// uint64_t b[4]); +.globl ecp_nistz256_ord_mul_mont +.hidden ecp_nistz256_ord_mul_mont +.type ecp_nistz256_ord_mul_mont,%function +.align 4 +ecp_nistz256_ord_mul_mont: + AARCH64_VALID_CALL_TARGET + // Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later. + stp x29,x30,[sp,#-64]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + + adrp x23,.Lord + add x23,x23,:lo12:.Lord + ldr x3,[x2] // bp[0] + ldp x4,x5,[x1] + ldp x6,x7,[x1,#16] + + ldp x12,x13,[x23,#0] + ldp x21,x22,[x23,#16] + ldr x23,[x23,#32] + + mul x14,x4,x3 // a[0]*b[0] + umulh x8,x4,x3 + + mul x15,x5,x3 // a[1]*b[0] + umulh x9,x5,x3 + + mul x16,x6,x3 // a[2]*b[0] + umulh x10,x6,x3 + + mul x17,x7,x3 // a[3]*b[0] + umulh x19,x7,x3 + + mul x24,x14,x23 + + adds x15,x15,x8 // accumulate high parts of multiplication + adcs x16,x16,x9 + adcs x17,x17,x10 + adc x19,x19,xzr + mov x20,xzr + ldr x3,[x2,#8*1] // b[i] + + lsl x8,x24,#32 + subs x16,x16,x24 + lsr x9,x24,#32 + sbcs x17,x17,x8 + sbcs x19,x19,x9 + sbc x20,x20,xzr + + subs xzr,x14,#1 + umulh x9,x12,x24 + mul x10,x13,x24 + umulh x11,x13,x24 + + adcs x10,x10,x9 + mul x8,x4,x3 + adc x11,x11,xzr + mul x9,x5,x3 + + adds x14,x15,x10 + mul x10,x6,x3 + adcs x15,x16,x11 + mul x11,x7,x3 + adcs x16,x17,x24 + adcs x17,x19,x24 + adc x19,x20,xzr + + adds x14,x14,x8 // accumulate low parts + umulh x8,x4,x3 + adcs x15,x15,x9 + umulh x9,x5,x3 + adcs x16,x16,x10 + umulh x10,x6,x3 + adcs x17,x17,x11 + umulh x11,x7,x3 + adc x19,x19,xzr + mul x24,x14,x23 + adds x15,x15,x8 // accumulate high parts + adcs x16,x16,x9 + adcs x17,x17,x10 + adcs x19,x19,x11 + adc x20,xzr,xzr + ldr x3,[x2,#8*2] // b[i] + + lsl x8,x24,#32 + subs x16,x16,x24 + lsr x9,x24,#32 + sbcs x17,x17,x8 + sbcs x19,x19,x9 + sbc x20,x20,xzr + + subs xzr,x14,#1 + umulh x9,x12,x24 + mul x10,x13,x24 + umulh x11,x13,x24 + + adcs x10,x10,x9 + mul x8,x4,x3 + adc x11,x11,xzr + mul x9,x5,x3 + + adds x14,x15,x10 + mul x10,x6,x3 + adcs x15,x16,x11 + mul x11,x7,x3 + adcs x16,x17,x24 + adcs x17,x19,x24 + adc x19,x20,xzr + + adds x14,x14,x8 // accumulate low parts + umulh x8,x4,x3 + adcs x15,x15,x9 + umulh x9,x5,x3 + adcs x16,x16,x10 + umulh x10,x6,x3 + adcs x17,x17,x11 + umulh x11,x7,x3 + adc x19,x19,xzr + mul x24,x14,x23 + adds x15,x15,x8 // accumulate high parts + adcs x16,x16,x9 + adcs x17,x17,x10 + adcs x19,x19,x11 + adc x20,xzr,xzr + ldr x3,[x2,#8*3] // b[i] + + lsl x8,x24,#32 + subs x16,x16,x24 + lsr x9,x24,#32 + sbcs x17,x17,x8 + sbcs x19,x19,x9 + sbc x20,x20,xzr + + subs xzr,x14,#1 + umulh x9,x12,x24 + mul x10,x13,x24 + umulh x11,x13,x24 + + adcs x10,x10,x9 + mul x8,x4,x3 + adc x11,x11,xzr + mul x9,x5,x3 + + adds x14,x15,x10 + mul x10,x6,x3 + adcs x15,x16,x11 + mul x11,x7,x3 + adcs x16,x17,x24 + adcs x17,x19,x24 + adc x19,x20,xzr + + adds x14,x14,x8 // accumulate low parts + umulh x8,x4,x3 + adcs x15,x15,x9 + umulh x9,x5,x3 + adcs x16,x16,x10 + umulh x10,x6,x3 + adcs x17,x17,x11 + umulh x11,x7,x3 + adc x19,x19,xzr + mul x24,x14,x23 + adds x15,x15,x8 // accumulate high parts + adcs x16,x16,x9 + adcs x17,x17,x10 + adcs x19,x19,x11 + adc x20,xzr,xzr + lsl x8,x24,#32 // last reduction + subs x16,x16,x24 + lsr x9,x24,#32 + sbcs x17,x17,x8 + sbcs x19,x19,x9 + sbc x20,x20,xzr + + subs xzr,x14,#1 + umulh x9,x12,x24 + mul x10,x13,x24 + umulh x11,x13,x24 + + adcs x10,x10,x9 + adc x11,x11,xzr + + adds x14,x15,x10 + adcs x15,x16,x11 + adcs x16,x17,x24 + adcs x17,x19,x24 + adc x19,x20,xzr + + subs x8,x14,x12 // ret -= modulus + sbcs x9,x15,x13 + sbcs x10,x16,x21 + sbcs x11,x17,x22 + sbcs xzr,x19,xzr + + csel x14,x14,x8,lo // ret = borrow ? ret : ret-modulus + csel x15,x15,x9,lo + csel x16,x16,x10,lo + stp x14,x15,[x0] + csel x17,x17,x11,lo + stp x16,x17,[x0,#16] + + ldp x19,x20,[sp,#16] + ldp x21,x22,[sp,#32] + ldp x23,x24,[sp,#48] + ldr x29,[sp],#64 + ret +.size ecp_nistz256_ord_mul_mont,.-ecp_nistz256_ord_mul_mont + +//////////////////////////////////////////////////////////////////////// +// void ecp_nistz256_ord_sqr_mont(uint64_t res[4], uint64_t a[4], +// uint64_t rep); +.globl ecp_nistz256_ord_sqr_mont +.hidden ecp_nistz256_ord_sqr_mont +.type ecp_nistz256_ord_sqr_mont,%function +.align 4 +ecp_nistz256_ord_sqr_mont: + AARCH64_VALID_CALL_TARGET + // Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later. + stp x29,x30,[sp,#-64]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + + adrp x23,.Lord + add x23,x23,:lo12:.Lord + ldp x4,x5,[x1] + ldp x6,x7,[x1,#16] + + ldp x12,x13,[x23,#0] + ldp x21,x22,[x23,#16] + ldr x23,[x23,#32] + b .Loop_ord_sqr + +.align 4 +.Loop_ord_sqr: + sub x2,x2,#1 + //////////////////////////////////////////////////////////////// + // | | | | | |a1*a0| | + // | | | | |a2*a0| | | + // | |a3*a2|a3*a0| | | | + // | | | |a2*a1| | | | + // | | |a3*a1| | | | | + // *| | | | | | | | 2| + // +|a3*a3|a2*a2|a1*a1|a0*a0| + // |--+--+--+--+--+--+--+--| + // |A7|A6|A5|A4|A3|A2|A1|A0|, where Ax is , i.e. follow + // + // "can't overflow" below mark carrying into high part of + // multiplication result, which can't overflow, because it + // can never be all ones. + + mul x15,x5,x4 // a[1]*a[0] + umulh x9,x5,x4 + mul x16,x6,x4 // a[2]*a[0] + umulh x10,x6,x4 + mul x17,x7,x4 // a[3]*a[0] + umulh x19,x7,x4 + + adds x16,x16,x9 // accumulate high parts of multiplication + mul x8,x6,x5 // a[2]*a[1] + umulh x9,x6,x5 + adcs x17,x17,x10 + mul x10,x7,x5 // a[3]*a[1] + umulh x11,x7,x5 + adc x19,x19,xzr // can't overflow + + mul x20,x7,x6 // a[3]*a[2] + umulh x1,x7,x6 + + adds x9,x9,x10 // accumulate high parts of multiplication + mul x14,x4,x4 // a[0]*a[0] + adc x10,x11,xzr // can't overflow + + adds x17,x17,x8 // accumulate low parts of multiplication + umulh x4,x4,x4 + adcs x19,x19,x9 + mul x9,x5,x5 // a[1]*a[1] + adcs x20,x20,x10 + umulh x5,x5,x5 + adc x1,x1,xzr // can't overflow + + adds x15,x15,x15 // acc[1-6]*=2 + mul x10,x6,x6 // a[2]*a[2] + adcs x16,x16,x16 + umulh x6,x6,x6 + adcs x17,x17,x17 + mul x11,x7,x7 // a[3]*a[3] + adcs x19,x19,x19 + umulh x7,x7,x7 + adcs x20,x20,x20 + adcs x1,x1,x1 + adc x3,xzr,xzr + + adds x15,x15,x4 // +a[i]*a[i] + mul x24,x14,x23 + adcs x16,x16,x9 + adcs x17,x17,x5 + adcs x19,x19,x10 + adcs x20,x20,x6 + adcs x1,x1,x11 + adc x3,x3,x7 + subs xzr,x14,#1 + umulh x9,x12,x24 + mul x10,x13,x24 + umulh x11,x13,x24 + + adcs x10,x10,x9 + adc x11,x11,xzr + + adds x14,x15,x10 + adcs x15,x16,x11 + adcs x16,x17,x24 + adc x17,xzr,x24 // can't overflow + mul x11,x14,x23 + lsl x8,x24,#32 + subs x15,x15,x24 + lsr x9,x24,#32 + sbcs x16,x16,x8 + sbc x17,x17,x9 // can't borrow + subs xzr,x14,#1 + umulh x9,x12,x11 + mul x10,x13,x11 + umulh x24,x13,x11 + + adcs x10,x10,x9 + adc x24,x24,xzr + + adds x14,x15,x10 + adcs x15,x16,x24 + adcs x16,x17,x11 + adc x17,xzr,x11 // can't overflow + mul x24,x14,x23 + lsl x8,x11,#32 + subs x15,x15,x11 + lsr x9,x11,#32 + sbcs x16,x16,x8 + sbc x17,x17,x9 // can't borrow + subs xzr,x14,#1 + umulh x9,x12,x24 + mul x10,x13,x24 + umulh x11,x13,x24 + + adcs x10,x10,x9 + adc x11,x11,xzr + + adds x14,x15,x10 + adcs x15,x16,x11 + adcs x16,x17,x24 + adc x17,xzr,x24 // can't overflow + mul x11,x14,x23 + lsl x8,x24,#32 + subs x15,x15,x24 + lsr x9,x24,#32 + sbcs x16,x16,x8 + sbc x17,x17,x9 // can't borrow + subs xzr,x14,#1 + umulh x9,x12,x11 + mul x10,x13,x11 + umulh x24,x13,x11 + + adcs x10,x10,x9 + adc x24,x24,xzr + + adds x14,x15,x10 + adcs x15,x16,x24 + adcs x16,x17,x11 + adc x17,xzr,x11 // can't overflow + lsl x8,x11,#32 + subs x15,x15,x11 + lsr x9,x11,#32 + sbcs x16,x16,x8 + sbc x17,x17,x9 // can't borrow + adds x14,x14,x19 // accumulate upper half + adcs x15,x15,x20 + adcs x16,x16,x1 + adcs x17,x17,x3 + adc x19,xzr,xzr + + subs x8,x14,x12 // ret -= modulus + sbcs x9,x15,x13 + sbcs x10,x16,x21 + sbcs x11,x17,x22 + sbcs xzr,x19,xzr + + csel x4,x14,x8,lo // ret = borrow ? ret : ret-modulus + csel x5,x15,x9,lo + csel x6,x16,x10,lo + csel x7,x17,x11,lo + + cbnz x2,.Loop_ord_sqr + + stp x4,x5,[x0] + stp x6,x7,[x0,#16] + + ldp x19,x20,[sp,#16] + ldp x21,x22,[sp,#32] + ldp x23,x24,[sp,#48] + ldr x29,[sp],#64 + ret +.size ecp_nistz256_ord_sqr_mont,.-ecp_nistz256_ord_sqr_mont +//////////////////////////////////////////////////////////////////////// +// void ecp_nistz256_select_w5(uint64_t *val, uint64_t *in_t, int index); +.globl ecp_nistz256_select_w5 +.hidden ecp_nistz256_select_w5 +.type ecp_nistz256_select_w5,%function +.align 4 +ecp_nistz256_select_w5: + AARCH64_VALID_CALL_TARGET + + // x10 := x0 + // w9 := 0; loop counter and incremented internal index + mov x10, x0 + mov w9, #0 + + // [v16-v21] := 0 + movi v16.16b, #0 + movi v17.16b, #0 + movi v18.16b, #0 + movi v19.16b, #0 + movi v20.16b, #0 + movi v21.16b, #0 + +.Lselect_w5_loop: + // Loop 16 times. + + // Increment index (loop counter); tested at the end of the loop + add w9, w9, #1 + + // [v22-v27] := Load a (3*256-bit = 6*128-bit) table entry starting at x1 + // and advance x1 to point to the next entry + ld1 {v22.2d, v23.2d, v24.2d, v25.2d}, [x1],#64 + + // x11 := (w9 == w2)? All 1s : All 0s + cmp w9, w2 + csetm x11, eq + + // continue loading ... + ld1 {v26.2d, v27.2d}, [x1],#32 + + // duplicate mask_64 into Mask (all 0s or all 1s) + dup v3.2d, x11 + + // [v16-v19] := (Mask == all 1s)? [v22-v25] : [v16-v19] + // i.e., values in output registers will remain the same if w9 != w2 + bit v16.16b, v22.16b, v3.16b + bit v17.16b, v23.16b, v3.16b + + bit v18.16b, v24.16b, v3.16b + bit v19.16b, v25.16b, v3.16b + + bit v20.16b, v26.16b, v3.16b + bit v21.16b, v27.16b, v3.16b + + // If bit #4 is not 0 (i.e. idx_ctr < 16) loop back + tbz w9, #4, .Lselect_w5_loop + + // Write [v16-v21] to memory at the output pointer + st1 {v16.2d, v17.2d, v18.2d, v19.2d}, [x10],#64 + st1 {v20.2d, v21.2d}, [x10] + + ret +.size ecp_nistz256_select_w5,.-ecp_nistz256_select_w5 + + +//////////////////////////////////////////////////////////////////////// +// void ecp_nistz256_select_w7(uint64_t *val, uint64_t *in_t, int index); +.globl ecp_nistz256_select_w7 +.hidden ecp_nistz256_select_w7 +.type ecp_nistz256_select_w7,%function +.align 4 +ecp_nistz256_select_w7: + AARCH64_VALID_CALL_TARGET + + // w9 := 0; loop counter and incremented internal index + mov w9, #0 + + // [v16-v21] := 0 + movi v16.16b, #0 + movi v17.16b, #0 + movi v18.16b, #0 + movi v19.16b, #0 + +.Lselect_w7_loop: + // Loop 64 times. + + // Increment index (loop counter); tested at the end of the loop + add w9, w9, #1 + + // [v22-v25] := Load a (2*256-bit = 4*128-bit) table entry starting at x1 + // and advance x1 to point to the next entry + ld1 {v22.2d, v23.2d, v24.2d, v25.2d}, [x1],#64 + + // x11 := (w9 == w2)? All 1s : All 0s + cmp w9, w2 + csetm x11, eq + + // duplicate mask_64 into Mask (all 0s or all 1s) + dup v3.2d, x11 + + // [v16-v19] := (Mask == all 1s)? [v22-v25] : [v16-v19] + // i.e., values in output registers will remain the same if w9 != w2 + bit v16.16b, v22.16b, v3.16b + bit v17.16b, v23.16b, v3.16b + + bit v18.16b, v24.16b, v3.16b + bit v19.16b, v25.16b, v3.16b + + // If bit #6 is not 0 (i.e. idx_ctr < 64) loop back + tbz w9, #6, .Lselect_w7_loop + + // Write [v16-v19] to memory at the output pointer + st1 {v16.2d, v17.2d, v18.2d, v19.2d}, [x0] + + ret +.size ecp_nistz256_select_w7,.-ecp_nistz256_select_w7 +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__ELF__) diff --git a/http/vendor/ring/pregenerated/p256-armv8-asm-win64.S b/http/vendor/ring/pregenerated/p256-armv8-asm-win64.S new file mode 100644 index 0000000..efc4581 --- /dev/null +++ b/http/vendor/ring/pregenerated/p256-armv8-asm-win64.S @@ -0,0 +1,1640 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(_WIN32) +.section .rodata +.align 5 +Lpoly: +.quad 0xffffffffffffffff,0x00000000ffffffff,0x0000000000000000,0xffffffff00000001 +LRR: // 2^512 mod P precomputed for NIST P256 polynomial +.quad 0x0000000000000003,0xfffffffbffffffff,0xfffffffffffffffe,0x00000004fffffffd +Lone_mont: +.quad 0x0000000000000001,0xffffffff00000000,0xffffffffffffffff,0x00000000fffffffe +Lone: +.quad 1,0,0,0 +Lord: +.quad 0xf3b9cac2fc632551,0xbce6faada7179e84,0xffffffffffffffff,0xffffffff00000000 +LordK: +.quad 0xccd1c8aaee00bc4f +.byte 69,67,80,95,78,73,83,84,90,50,53,54,32,102,111,114,32,65,82,77,118,56,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.align 2 +.text + +// void ecp_nistz256_mul_mont(BN_ULONG x0[4],const BN_ULONG x1[4], +// const BN_ULONG x2[4]); +.globl ecp_nistz256_mul_mont + +.def ecp_nistz256_mul_mont + .type 32 +.endef +.align 4 +ecp_nistz256_mul_mont: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-32]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + + ldr x3,[x2] // bp[0] + ldp x4,x5,[x1] + ldp x6,x7,[x1,#16] + adrp x13,Lpoly + add x13,x13,:lo12:Lpoly + ldr x12,[x13,#8] + ldr x13,[x13,#24] + + bl __ecp_nistz256_mul_mont + + ldp x19,x20,[sp,#16] + ldp x29,x30,[sp],#32 + AARCH64_VALIDATE_LINK_REGISTER + ret + + +// void ecp_nistz256_sqr_mont(BN_ULONG x0[4],const BN_ULONG x1[4]); +.globl ecp_nistz256_sqr_mont + +.def ecp_nistz256_sqr_mont + .type 32 +.endef +.align 4 +ecp_nistz256_sqr_mont: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-32]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + + ldp x4,x5,[x1] + ldp x6,x7,[x1,#16] + adrp x13,Lpoly + add x13,x13,:lo12:Lpoly + ldr x12,[x13,#8] + ldr x13,[x13,#24] + + bl __ecp_nistz256_sqr_mont + + ldp x19,x20,[sp,#16] + ldp x29,x30,[sp],#32 + AARCH64_VALIDATE_LINK_REGISTER + ret + + +// void ecp_nistz256_neg(BN_ULONG x0[4],const BN_ULONG x1[4]); +.globl ecp_nistz256_neg + +.def ecp_nistz256_neg + .type 32 +.endef +.align 4 +ecp_nistz256_neg: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-16]! + add x29,sp,#0 + + mov x2,x1 + mov x14,xzr // a = 0 + mov x15,xzr + mov x16,xzr + mov x17,xzr + adrp x13,Lpoly + add x13,x13,:lo12:Lpoly + ldr x12,[x13,#8] + ldr x13,[x13,#24] + + bl __ecp_nistz256_sub_from + + ldp x29,x30,[sp],#16 + AARCH64_VALIDATE_LINK_REGISTER + ret + + +// note that __ecp_nistz256_mul_mont expects a[0-3] input pre-loaded +// to x4-x7 and b[0] - to x3 +.def __ecp_nistz256_mul_mont + .type 32 +.endef +.align 4 +__ecp_nistz256_mul_mont: + mul x14,x4,x3 // a[0]*b[0] + umulh x8,x4,x3 + + mul x15,x5,x3 // a[1]*b[0] + umulh x9,x5,x3 + + mul x16,x6,x3 // a[2]*b[0] + umulh x10,x6,x3 + + mul x17,x7,x3 // a[3]*b[0] + umulh x11,x7,x3 + ldr x3,[x2,#8] // b[1] + + adds x15,x15,x8 // accumulate high parts of multiplication + lsl x8,x14,#32 + adcs x16,x16,x9 + lsr x9,x14,#32 + adcs x17,x17,x10 + adc x19,xzr,x11 + mov x20,xzr + subs x10,x14,x8 // "*0xffff0001" + sbc x11,x14,x9 + adds x14,x15,x8 // +=acc[0]<<96 and omit acc[0] + mul x8,x4,x3 // lo(a[0]*b[i]) + adcs x15,x16,x9 + mul x9,x5,x3 // lo(a[1]*b[i]) + adcs x16,x17,x10 // +=acc[0]*0xffff0001 + mul x10,x6,x3 // lo(a[2]*b[i]) + adcs x17,x19,x11 + mul x11,x7,x3 // lo(a[3]*b[i]) + adc x19,x20,xzr + + adds x14,x14,x8 // accumulate low parts of multiplication + umulh x8,x4,x3 // hi(a[0]*b[i]) + adcs x15,x15,x9 + umulh x9,x5,x3 // hi(a[1]*b[i]) + adcs x16,x16,x10 + umulh x10,x6,x3 // hi(a[2]*b[i]) + adcs x17,x17,x11 + umulh x11,x7,x3 // hi(a[3]*b[i]) + adc x19,x19,xzr + ldr x3,[x2,#8*(1+1)] // b[1+1] + adds x15,x15,x8 // accumulate high parts of multiplication + lsl x8,x14,#32 + adcs x16,x16,x9 + lsr x9,x14,#32 + adcs x17,x17,x10 + adcs x19,x19,x11 + adc x20,xzr,xzr + subs x10,x14,x8 // "*0xffff0001" + sbc x11,x14,x9 + adds x14,x15,x8 // +=acc[0]<<96 and omit acc[0] + mul x8,x4,x3 // lo(a[0]*b[i]) + adcs x15,x16,x9 + mul x9,x5,x3 // lo(a[1]*b[i]) + adcs x16,x17,x10 // +=acc[0]*0xffff0001 + mul x10,x6,x3 // lo(a[2]*b[i]) + adcs x17,x19,x11 + mul x11,x7,x3 // lo(a[3]*b[i]) + adc x19,x20,xzr + + adds x14,x14,x8 // accumulate low parts of multiplication + umulh x8,x4,x3 // hi(a[0]*b[i]) + adcs x15,x15,x9 + umulh x9,x5,x3 // hi(a[1]*b[i]) + adcs x16,x16,x10 + umulh x10,x6,x3 // hi(a[2]*b[i]) + adcs x17,x17,x11 + umulh x11,x7,x3 // hi(a[3]*b[i]) + adc x19,x19,xzr + ldr x3,[x2,#8*(2+1)] // b[2+1] + adds x15,x15,x8 // accumulate high parts of multiplication + lsl x8,x14,#32 + adcs x16,x16,x9 + lsr x9,x14,#32 + adcs x17,x17,x10 + adcs x19,x19,x11 + adc x20,xzr,xzr + subs x10,x14,x8 // "*0xffff0001" + sbc x11,x14,x9 + adds x14,x15,x8 // +=acc[0]<<96 and omit acc[0] + mul x8,x4,x3 // lo(a[0]*b[i]) + adcs x15,x16,x9 + mul x9,x5,x3 // lo(a[1]*b[i]) + adcs x16,x17,x10 // +=acc[0]*0xffff0001 + mul x10,x6,x3 // lo(a[2]*b[i]) + adcs x17,x19,x11 + mul x11,x7,x3 // lo(a[3]*b[i]) + adc x19,x20,xzr + + adds x14,x14,x8 // accumulate low parts of multiplication + umulh x8,x4,x3 // hi(a[0]*b[i]) + adcs x15,x15,x9 + umulh x9,x5,x3 // hi(a[1]*b[i]) + adcs x16,x16,x10 + umulh x10,x6,x3 // hi(a[2]*b[i]) + adcs x17,x17,x11 + umulh x11,x7,x3 // hi(a[3]*b[i]) + adc x19,x19,xzr + adds x15,x15,x8 // accumulate high parts of multiplication + lsl x8,x14,#32 + adcs x16,x16,x9 + lsr x9,x14,#32 + adcs x17,x17,x10 + adcs x19,x19,x11 + adc x20,xzr,xzr + // last reduction + subs x10,x14,x8 // "*0xffff0001" + sbc x11,x14,x9 + adds x14,x15,x8 // +=acc[0]<<96 and omit acc[0] + adcs x15,x16,x9 + adcs x16,x17,x10 // +=acc[0]*0xffff0001 + adcs x17,x19,x11 + adc x19,x20,xzr + + adds x8,x14,#1 // subs x8,x14,#-1 // tmp = ret-modulus + sbcs x9,x15,x12 + sbcs x10,x16,xzr + sbcs x11,x17,x13 + sbcs xzr,x19,xzr // did it borrow? + + csel x14,x14,x8,lo // ret = borrow ? ret : ret-modulus + csel x15,x15,x9,lo + csel x16,x16,x10,lo + stp x14,x15,[x0] + csel x17,x17,x11,lo + stp x16,x17,[x0,#16] + + ret + + +// note that __ecp_nistz256_sqr_mont expects a[0-3] input pre-loaded +// to x4-x7 +.def __ecp_nistz256_sqr_mont + .type 32 +.endef +.align 4 +__ecp_nistz256_sqr_mont: + // | | | | | |a1*a0| | + // | | | | |a2*a0| | | + // | |a3*a2|a3*a0| | | | + // | | | |a2*a1| | | | + // | | |a3*a1| | | | | + // *| | | | | | | | 2| + // +|a3*a3|a2*a2|a1*a1|a0*a0| + // |--+--+--+--+--+--+--+--| + // |A7|A6|A5|A4|A3|A2|A1|A0|, where Ax is , i.e. follow + // + // "can't overflow" below mark carrying into high part of + // multiplication result, which can't overflow, because it + // can never be all ones. + + mul x15,x5,x4 // a[1]*a[0] + umulh x9,x5,x4 + mul x16,x6,x4 // a[2]*a[0] + umulh x10,x6,x4 + mul x17,x7,x4 // a[3]*a[0] + umulh x19,x7,x4 + + adds x16,x16,x9 // accumulate high parts of multiplication + mul x8,x6,x5 // a[2]*a[1] + umulh x9,x6,x5 + adcs x17,x17,x10 + mul x10,x7,x5 // a[3]*a[1] + umulh x11,x7,x5 + adc x19,x19,xzr // can't overflow + + mul x20,x7,x6 // a[3]*a[2] + umulh x1,x7,x6 + + adds x9,x9,x10 // accumulate high parts of multiplication + mul x14,x4,x4 // a[0]*a[0] + adc x10,x11,xzr // can't overflow + + adds x17,x17,x8 // accumulate low parts of multiplication + umulh x4,x4,x4 + adcs x19,x19,x9 + mul x9,x5,x5 // a[1]*a[1] + adcs x20,x20,x10 + umulh x5,x5,x5 + adc x1,x1,xzr // can't overflow + + adds x15,x15,x15 // acc[1-6]*=2 + mul x10,x6,x6 // a[2]*a[2] + adcs x16,x16,x16 + umulh x6,x6,x6 + adcs x17,x17,x17 + mul x11,x7,x7 // a[3]*a[3] + adcs x19,x19,x19 + umulh x7,x7,x7 + adcs x20,x20,x20 + adcs x1,x1,x1 + adc x2,xzr,xzr + + adds x15,x15,x4 // +a[i]*a[i] + adcs x16,x16,x9 + adcs x17,x17,x5 + adcs x19,x19,x10 + adcs x20,x20,x6 + lsl x8,x14,#32 + adcs x1,x1,x11 + lsr x9,x14,#32 + adc x2,x2,x7 + subs x10,x14,x8 // "*0xffff0001" + sbc x11,x14,x9 + adds x14,x15,x8 // +=acc[0]<<96 and omit acc[0] + adcs x15,x16,x9 + lsl x8,x14,#32 + adcs x16,x17,x10 // +=acc[0]*0xffff0001 + lsr x9,x14,#32 + adc x17,x11,xzr // can't overflow + subs x10,x14,x8 // "*0xffff0001" + sbc x11,x14,x9 + adds x14,x15,x8 // +=acc[0]<<96 and omit acc[0] + adcs x15,x16,x9 + lsl x8,x14,#32 + adcs x16,x17,x10 // +=acc[0]*0xffff0001 + lsr x9,x14,#32 + adc x17,x11,xzr // can't overflow + subs x10,x14,x8 // "*0xffff0001" + sbc x11,x14,x9 + adds x14,x15,x8 // +=acc[0]<<96 and omit acc[0] + adcs x15,x16,x9 + lsl x8,x14,#32 + adcs x16,x17,x10 // +=acc[0]*0xffff0001 + lsr x9,x14,#32 + adc x17,x11,xzr // can't overflow + subs x10,x14,x8 // "*0xffff0001" + sbc x11,x14,x9 + adds x14,x15,x8 // +=acc[0]<<96 and omit acc[0] + adcs x15,x16,x9 + adcs x16,x17,x10 // +=acc[0]*0xffff0001 + adc x17,x11,xzr // can't overflow + + adds x14,x14,x19 // accumulate upper half + adcs x15,x15,x20 + adcs x16,x16,x1 + adcs x17,x17,x2 + adc x19,xzr,xzr + + adds x8,x14,#1 // subs x8,x14,#-1 // tmp = ret-modulus + sbcs x9,x15,x12 + sbcs x10,x16,xzr + sbcs x11,x17,x13 + sbcs xzr,x19,xzr // did it borrow? + + csel x14,x14,x8,lo // ret = borrow ? ret : ret-modulus + csel x15,x15,x9,lo + csel x16,x16,x10,lo + stp x14,x15,[x0] + csel x17,x17,x11,lo + stp x16,x17,[x0,#16] + + ret + + +// Note that __ecp_nistz256_add_to expects both input vectors pre-loaded to +// x4-x7 and x8-x11. This is done because it's used in multiple +// contexts, e.g. in multiplication by 2 and 3... +.def __ecp_nistz256_add_to + .type 32 +.endef +.align 4 +__ecp_nistz256_add_to: + adds x14,x14,x8 // ret = a+b + adcs x15,x15,x9 + adcs x16,x16,x10 + adcs x17,x17,x11 + adc x1,xzr,xzr // zap x1 + + adds x8,x14,#1 // subs x8,x4,#-1 // tmp = ret-modulus + sbcs x9,x15,x12 + sbcs x10,x16,xzr + sbcs x11,x17,x13 + sbcs xzr,x1,xzr // did subtraction borrow? + + csel x14,x14,x8,lo // ret = borrow ? ret : ret-modulus + csel x15,x15,x9,lo + csel x16,x16,x10,lo + stp x14,x15,[x0] + csel x17,x17,x11,lo + stp x16,x17,[x0,#16] + + ret + + +.def __ecp_nistz256_sub_from + .type 32 +.endef +.align 4 +__ecp_nistz256_sub_from: + ldp x8,x9,[x2] + ldp x10,x11,[x2,#16] + subs x14,x14,x8 // ret = a-b + sbcs x15,x15,x9 + sbcs x16,x16,x10 + sbcs x17,x17,x11 + sbc x1,xzr,xzr // zap x1 + + subs x8,x14,#1 // adds x8,x4,#-1 // tmp = ret+modulus + adcs x9,x15,x12 + adcs x10,x16,xzr + adc x11,x17,x13 + cmp x1,xzr // did subtraction borrow? + + csel x14,x14,x8,eq // ret = borrow ? ret+modulus : ret + csel x15,x15,x9,eq + csel x16,x16,x10,eq + stp x14,x15,[x0] + csel x17,x17,x11,eq + stp x16,x17,[x0,#16] + + ret + + +.def __ecp_nistz256_sub_morf + .type 32 +.endef +.align 4 +__ecp_nistz256_sub_morf: + ldp x8,x9,[x2] + ldp x10,x11,[x2,#16] + subs x14,x8,x14 // ret = b-a + sbcs x15,x9,x15 + sbcs x16,x10,x16 + sbcs x17,x11,x17 + sbc x1,xzr,xzr // zap x1 + + subs x8,x14,#1 // adds x8,x4,#-1 // tmp = ret+modulus + adcs x9,x15,x12 + adcs x10,x16,xzr + adc x11,x17,x13 + cmp x1,xzr // did subtraction borrow? + + csel x14,x14,x8,eq // ret = borrow ? ret+modulus : ret + csel x15,x15,x9,eq + csel x16,x16,x10,eq + stp x14,x15,[x0] + csel x17,x17,x11,eq + stp x16,x17,[x0,#16] + + ret + + +.def __ecp_nistz256_div_by_2 + .type 32 +.endef +.align 4 +__ecp_nistz256_div_by_2: + subs x8,x14,#1 // adds x8,x4,#-1 // tmp = a+modulus + adcs x9,x15,x12 + adcs x10,x16,xzr + adcs x11,x17,x13 + adc x1,xzr,xzr // zap x1 + tst x14,#1 // is a even? + + csel x14,x14,x8,eq // ret = even ? a : a+modulus + csel x15,x15,x9,eq + csel x16,x16,x10,eq + csel x17,x17,x11,eq + csel x1,xzr,x1,eq + + lsr x14,x14,#1 // ret >>= 1 + orr x14,x14,x15,lsl#63 + lsr x15,x15,#1 + orr x15,x15,x16,lsl#63 + lsr x16,x16,#1 + orr x16,x16,x17,lsl#63 + lsr x17,x17,#1 + stp x14,x15,[x0] + orr x17,x17,x1,lsl#63 + stp x16,x17,[x0,#16] + + ret + +.globl ecp_nistz256_point_double + +.def ecp_nistz256_point_double + .type 32 +.endef +.align 5 +ecp_nistz256_point_double: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-96]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + sub sp,sp,#32*4 + +Ldouble_shortcut: + ldp x14,x15,[x1,#32] + mov x21,x0 + ldp x16,x17,[x1,#48] + mov x22,x1 + adrp x13,Lpoly + add x13,x13,:lo12:Lpoly + ldr x12,[x13,#8] + mov x8,x14 + ldr x13,[x13,#24] + mov x9,x15 + ldp x4,x5,[x22,#64] // forward load for p256_sqr_mont + mov x10,x16 + mov x11,x17 + ldp x6,x7,[x22,#64+16] + add x0,sp,#0 + bl __ecp_nistz256_add_to // p256_mul_by_2(S, in_y); + + add x0,sp,#64 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(Zsqr, in_z); + + ldp x8,x9,[x22] + ldp x10,x11,[x22,#16] + mov x4,x14 // put Zsqr aside for p256_sub + mov x5,x15 + mov x6,x16 + mov x7,x17 + add x0,sp,#32 + bl __ecp_nistz256_add_to // p256_add(M, Zsqr, in_x); + + add x2,x22,#0 + mov x14,x4 // restore Zsqr + mov x15,x5 + ldp x4,x5,[sp,#0] // forward load for p256_sqr_mont + mov x16,x6 + mov x17,x7 + ldp x6,x7,[sp,#0+16] + add x0,sp,#64 + bl __ecp_nistz256_sub_morf // p256_sub(Zsqr, in_x, Zsqr); + + add x0,sp,#0 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(S, S); + + ldr x3,[x22,#32] + ldp x4,x5,[x22,#64] + ldp x6,x7,[x22,#64+16] + add x2,x22,#32 + add x0,sp,#96 + bl __ecp_nistz256_mul_mont // p256_mul_mont(tmp0, in_z, in_y); + + mov x8,x14 + mov x9,x15 + ldp x4,x5,[sp,#0] // forward load for p256_sqr_mont + mov x10,x16 + mov x11,x17 + ldp x6,x7,[sp,#0+16] + add x0,x21,#64 + bl __ecp_nistz256_add_to // p256_mul_by_2(res_z, tmp0); + + add x0,sp,#96 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(tmp0, S); + + ldr x3,[sp,#64] // forward load for p256_mul_mont + ldp x4,x5,[sp,#32] + ldp x6,x7,[sp,#32+16] + add x0,x21,#32 + bl __ecp_nistz256_div_by_2 // p256_div_by_2(res_y, tmp0); + + add x2,sp,#64 + add x0,sp,#32 + bl __ecp_nistz256_mul_mont // p256_mul_mont(M, M, Zsqr); + + mov x8,x14 // duplicate M + mov x9,x15 + mov x10,x16 + mov x11,x17 + mov x4,x14 // put M aside + mov x5,x15 + mov x6,x16 + mov x7,x17 + add x0,sp,#32 + bl __ecp_nistz256_add_to + mov x8,x4 // restore M + mov x9,x5 + ldr x3,[x22] // forward load for p256_mul_mont + mov x10,x6 + ldp x4,x5,[sp,#0] + mov x11,x7 + ldp x6,x7,[sp,#0+16] + bl __ecp_nistz256_add_to // p256_mul_by_3(M, M); + + add x2,x22,#0 + add x0,sp,#0 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S, S, in_x); + + mov x8,x14 + mov x9,x15 + ldp x4,x5,[sp,#32] // forward load for p256_sqr_mont + mov x10,x16 + mov x11,x17 + ldp x6,x7,[sp,#32+16] + add x0,sp,#96 + bl __ecp_nistz256_add_to // p256_mul_by_2(tmp0, S); + + add x0,x21,#0 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(res_x, M); + + add x2,sp,#96 + bl __ecp_nistz256_sub_from // p256_sub(res_x, res_x, tmp0); + + add x2,sp,#0 + add x0,sp,#0 + bl __ecp_nistz256_sub_morf // p256_sub(S, S, res_x); + + ldr x3,[sp,#32] + mov x4,x14 // copy S + mov x5,x15 + mov x6,x16 + mov x7,x17 + add x2,sp,#32 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S, S, M); + + add x2,x21,#32 + add x0,x21,#32 + bl __ecp_nistz256_sub_from // p256_sub(res_y, S, res_y); + + add sp,x29,#0 // destroy frame + ldp x19,x20,[x29,#16] + ldp x21,x22,[x29,#32] + ldp x29,x30,[sp],#96 + AARCH64_VALIDATE_LINK_REGISTER + ret + +.globl ecp_nistz256_point_add + +.def ecp_nistz256_point_add + .type 32 +.endef +.align 5 +ecp_nistz256_point_add: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-96]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + stp x27,x28,[sp,#80] + sub sp,sp,#32*12 + + ldp x4,x5,[x2,#64] // in2_z + ldp x6,x7,[x2,#64+16] + mov x21,x0 + mov x22,x1 + mov x23,x2 + adrp x13,Lpoly + add x13,x13,:lo12:Lpoly + ldr x12,[x13,#8] + ldr x13,[x13,#24] + orr x8,x4,x5 + orr x10,x6,x7 + orr x25,x8,x10 + cmp x25,#0 + csetm x25,ne // ~in2infty + add x0,sp,#192 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(Z2sqr, in2_z); + + ldp x4,x5,[x22,#64] // in1_z + ldp x6,x7,[x22,#64+16] + orr x8,x4,x5 + orr x10,x6,x7 + orr x24,x8,x10 + cmp x24,#0 + csetm x24,ne // ~in1infty + add x0,sp,#128 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(Z1sqr, in1_z); + + ldr x3,[x23,#64] + ldp x4,x5,[sp,#192] + ldp x6,x7,[sp,#192+16] + add x2,x23,#64 + add x0,sp,#320 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S1, Z2sqr, in2_z); + + ldr x3,[x22,#64] + ldp x4,x5,[sp,#128] + ldp x6,x7,[sp,#128+16] + add x2,x22,#64 + add x0,sp,#352 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S2, Z1sqr, in1_z); + + ldr x3,[x22,#32] + ldp x4,x5,[sp,#320] + ldp x6,x7,[sp,#320+16] + add x2,x22,#32 + add x0,sp,#320 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S1, S1, in1_y); + + ldr x3,[x23,#32] + ldp x4,x5,[sp,#352] + ldp x6,x7,[sp,#352+16] + add x2,x23,#32 + add x0,sp,#352 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S2, S2, in2_y); + + add x2,sp,#320 + ldr x3,[sp,#192] // forward load for p256_mul_mont + ldp x4,x5,[x22] + ldp x6,x7,[x22,#16] + add x0,sp,#160 + bl __ecp_nistz256_sub_from // p256_sub(R, S2, S1); + + orr x14,x14,x15 // see if result is zero + orr x16,x16,x17 + orr x26,x14,x16 // ~is_equal(S1,S2) + + add x2,sp,#192 + add x0,sp,#256 + bl __ecp_nistz256_mul_mont // p256_mul_mont(U1, in1_x, Z2sqr); + + ldr x3,[sp,#128] + ldp x4,x5,[x23] + ldp x6,x7,[x23,#16] + add x2,sp,#128 + add x0,sp,#288 + bl __ecp_nistz256_mul_mont // p256_mul_mont(U2, in2_x, Z1sqr); + + add x2,sp,#256 + ldp x4,x5,[sp,#160] // forward load for p256_sqr_mont + ldp x6,x7,[sp,#160+16] + add x0,sp,#96 + bl __ecp_nistz256_sub_from // p256_sub(H, U2, U1); + + orr x14,x14,x15 // see if result is zero + orr x16,x16,x17 + orr x14,x14,x16 // ~is_equal(U1,U2) + + mvn x27,x24 // -1/0 -> 0/-1 + mvn x28,x25 // -1/0 -> 0/-1 + orr x14,x14,x27 + orr x14,x14,x28 + orr x14,x14,x26 + cbnz x14,Ladd_proceed // if(~is_equal(U1,U2) | in1infty | in2infty | ~is_equal(S1,S2)) + +Ladd_double: + mov x1,x22 + mov x0,x21 + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + add sp,sp,#256 // #256 is from #32*(12-4). difference in stack frames + b Ldouble_shortcut + +.align 4 +Ladd_proceed: + add x0,sp,#192 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(Rsqr, R); + + ldr x3,[x22,#64] + ldp x4,x5,[sp,#96] + ldp x6,x7,[sp,#96+16] + add x2,x22,#64 + add x0,sp,#64 + bl __ecp_nistz256_mul_mont // p256_mul_mont(res_z, H, in1_z); + + ldp x4,x5,[sp,#96] + ldp x6,x7,[sp,#96+16] + add x0,sp,#128 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(Hsqr, H); + + ldr x3,[x23,#64] + ldp x4,x5,[sp,#64] + ldp x6,x7,[sp,#64+16] + add x2,x23,#64 + add x0,sp,#64 + bl __ecp_nistz256_mul_mont // p256_mul_mont(res_z, res_z, in2_z); + + ldr x3,[sp,#96] + ldp x4,x5,[sp,#128] + ldp x6,x7,[sp,#128+16] + add x2,sp,#96 + add x0,sp,#224 + bl __ecp_nistz256_mul_mont // p256_mul_mont(Hcub, Hsqr, H); + + ldr x3,[sp,#128] + ldp x4,x5,[sp,#256] + ldp x6,x7,[sp,#256+16] + add x2,sp,#128 + add x0,sp,#288 + bl __ecp_nistz256_mul_mont // p256_mul_mont(U2, U1, Hsqr); + + mov x8,x14 + mov x9,x15 + mov x10,x16 + mov x11,x17 + add x0,sp,#128 + bl __ecp_nistz256_add_to // p256_mul_by_2(Hsqr, U2); + + add x2,sp,#192 + add x0,sp,#0 + bl __ecp_nistz256_sub_morf // p256_sub(res_x, Rsqr, Hsqr); + + add x2,sp,#224 + bl __ecp_nistz256_sub_from // p256_sub(res_x, res_x, Hcub); + + add x2,sp,#288 + ldr x3,[sp,#224] // forward load for p256_mul_mont + ldp x4,x5,[sp,#320] + ldp x6,x7,[sp,#320+16] + add x0,sp,#32 + bl __ecp_nistz256_sub_morf // p256_sub(res_y, U2, res_x); + + add x2,sp,#224 + add x0,sp,#352 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S2, S1, Hcub); + + ldr x3,[sp,#160] + ldp x4,x5,[sp,#32] + ldp x6,x7,[sp,#32+16] + add x2,sp,#160 + add x0,sp,#32 + bl __ecp_nistz256_mul_mont // p256_mul_mont(res_y, res_y, R); + + add x2,sp,#352 + bl __ecp_nistz256_sub_from // p256_sub(res_y, res_y, S2); + + ldp x4,x5,[sp,#0] // res + ldp x6,x7,[sp,#0+16] + ldp x8,x9,[x23] // in2 + ldp x10,x11,[x23,#16] + ldp x14,x15,[x22,#0] // in1 + cmp x24,#0 // ~, remember? + ldp x16,x17,[x22,#0+16] + csel x8,x4,x8,ne + csel x9,x5,x9,ne + ldp x4,x5,[sp,#0+0+32] // res + csel x10,x6,x10,ne + csel x11,x7,x11,ne + cmp x25,#0 // ~, remember? + ldp x6,x7,[sp,#0+0+48] + csel x14,x8,x14,ne + csel x15,x9,x15,ne + ldp x8,x9,[x23,#0+32] // in2 + csel x16,x10,x16,ne + csel x17,x11,x17,ne + ldp x10,x11,[x23,#0+48] + stp x14,x15,[x21,#0] + stp x16,x17,[x21,#0+16] + ldp x14,x15,[x22,#32] // in1 + cmp x24,#0 // ~, remember? + ldp x16,x17,[x22,#32+16] + csel x8,x4,x8,ne + csel x9,x5,x9,ne + ldp x4,x5,[sp,#0+32+32] // res + csel x10,x6,x10,ne + csel x11,x7,x11,ne + cmp x25,#0 // ~, remember? + ldp x6,x7,[sp,#0+32+48] + csel x14,x8,x14,ne + csel x15,x9,x15,ne + ldp x8,x9,[x23,#32+32] // in2 + csel x16,x10,x16,ne + csel x17,x11,x17,ne + ldp x10,x11,[x23,#32+48] + stp x14,x15,[x21,#32] + stp x16,x17,[x21,#32+16] + ldp x14,x15,[x22,#64] // in1 + cmp x24,#0 // ~, remember? + ldp x16,x17,[x22,#64+16] + csel x8,x4,x8,ne + csel x9,x5,x9,ne + csel x10,x6,x10,ne + csel x11,x7,x11,ne + cmp x25,#0 // ~, remember? + csel x14,x8,x14,ne + csel x15,x9,x15,ne + csel x16,x10,x16,ne + csel x17,x11,x17,ne + stp x14,x15,[x21,#64] + stp x16,x17,[x21,#64+16] + +Ladd_done: + add sp,x29,#0 // destroy frame + ldp x19,x20,[x29,#16] + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldp x29,x30,[sp],#96 + AARCH64_VALIDATE_LINK_REGISTER + ret + +.globl ecp_nistz256_point_add_affine + +.def ecp_nistz256_point_add_affine + .type 32 +.endef +.align 5 +ecp_nistz256_point_add_affine: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-80]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + sub sp,sp,#32*10 + + mov x21,x0 + mov x22,x1 + mov x23,x2 + adrp x13,Lpoly + add x13,x13,:lo12:Lpoly + ldr x12,[x13,#8] + ldr x13,[x13,#24] + + ldp x4,x5,[x1,#64] // in1_z + ldp x6,x7,[x1,#64+16] + orr x8,x4,x5 + orr x10,x6,x7 + orr x24,x8,x10 + cmp x24,#0 + csetm x24,ne // ~in1infty + + ldp x14,x15,[x2] // in2_x + ldp x16,x17,[x2,#16] + ldp x8,x9,[x2,#32] // in2_y + ldp x10,x11,[x2,#48] + orr x14,x14,x15 + orr x16,x16,x17 + orr x8,x8,x9 + orr x10,x10,x11 + orr x14,x14,x16 + orr x8,x8,x10 + orr x25,x14,x8 + cmp x25,#0 + csetm x25,ne // ~in2infty + + add x0,sp,#128 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(Z1sqr, in1_z); + + mov x4,x14 + mov x5,x15 + mov x6,x16 + mov x7,x17 + ldr x3,[x23] + add x2,x23,#0 + add x0,sp,#96 + bl __ecp_nistz256_mul_mont // p256_mul_mont(U2, Z1sqr, in2_x); + + add x2,x22,#0 + ldr x3,[x22,#64] // forward load for p256_mul_mont + ldp x4,x5,[sp,#128] + ldp x6,x7,[sp,#128+16] + add x0,sp,#160 + bl __ecp_nistz256_sub_from // p256_sub(H, U2, in1_x); + + add x2,x22,#64 + add x0,sp,#128 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S2, Z1sqr, in1_z); + + ldr x3,[x22,#64] + ldp x4,x5,[sp,#160] + ldp x6,x7,[sp,#160+16] + add x2,x22,#64 + add x0,sp,#64 + bl __ecp_nistz256_mul_mont // p256_mul_mont(res_z, H, in1_z); + + ldr x3,[x23,#32] + ldp x4,x5,[sp,#128] + ldp x6,x7,[sp,#128+16] + add x2,x23,#32 + add x0,sp,#128 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S2, S2, in2_y); + + add x2,x22,#32 + ldp x4,x5,[sp,#160] // forward load for p256_sqr_mont + ldp x6,x7,[sp,#160+16] + add x0,sp,#192 + bl __ecp_nistz256_sub_from // p256_sub(R, S2, in1_y); + + add x0,sp,#224 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(Hsqr, H); + + ldp x4,x5,[sp,#192] + ldp x6,x7,[sp,#192+16] + add x0,sp,#288 + bl __ecp_nistz256_sqr_mont // p256_sqr_mont(Rsqr, R); + + ldr x3,[sp,#160] + ldp x4,x5,[sp,#224] + ldp x6,x7,[sp,#224+16] + add x2,sp,#160 + add x0,sp,#256 + bl __ecp_nistz256_mul_mont // p256_mul_mont(Hcub, Hsqr, H); + + ldr x3,[x22] + ldp x4,x5,[sp,#224] + ldp x6,x7,[sp,#224+16] + add x2,x22,#0 + add x0,sp,#96 + bl __ecp_nistz256_mul_mont // p256_mul_mont(U2, in1_x, Hsqr); + + mov x8,x14 + mov x9,x15 + mov x10,x16 + mov x11,x17 + add x0,sp,#224 + bl __ecp_nistz256_add_to // p256_mul_by_2(Hsqr, U2); + + add x2,sp,#288 + add x0,sp,#0 + bl __ecp_nistz256_sub_morf // p256_sub(res_x, Rsqr, Hsqr); + + add x2,sp,#256 + bl __ecp_nistz256_sub_from // p256_sub(res_x, res_x, Hcub); + + add x2,sp,#96 + ldr x3,[x22,#32] // forward load for p256_mul_mont + ldp x4,x5,[sp,#256] + ldp x6,x7,[sp,#256+16] + add x0,sp,#32 + bl __ecp_nistz256_sub_morf // p256_sub(res_y, U2, res_x); + + add x2,x22,#32 + add x0,sp,#128 + bl __ecp_nistz256_mul_mont // p256_mul_mont(S2, in1_y, Hcub); + + ldr x3,[sp,#192] + ldp x4,x5,[sp,#32] + ldp x6,x7,[sp,#32+16] + add x2,sp,#192 + add x0,sp,#32 + bl __ecp_nistz256_mul_mont // p256_mul_mont(res_y, res_y, R); + + add x2,sp,#128 + bl __ecp_nistz256_sub_from // p256_sub(res_y, res_y, S2); + + ldp x4,x5,[sp,#0] // res + ldp x6,x7,[sp,#0+16] + ldp x8,x9,[x23] // in2 + ldp x10,x11,[x23,#16] + ldp x14,x15,[x22,#0] // in1 + cmp x24,#0 // ~, remember? + ldp x16,x17,[x22,#0+16] + csel x8,x4,x8,ne + csel x9,x5,x9,ne + ldp x4,x5,[sp,#0+0+32] // res + csel x10,x6,x10,ne + csel x11,x7,x11,ne + cmp x25,#0 // ~, remember? + ldp x6,x7,[sp,#0+0+48] + csel x14,x8,x14,ne + csel x15,x9,x15,ne + ldp x8,x9,[x23,#0+32] // in2 + csel x16,x10,x16,ne + csel x17,x11,x17,ne + ldp x10,x11,[x23,#0+48] + stp x14,x15,[x21,#0] + stp x16,x17,[x21,#0+16] + adrp x23,Lone_mont-64 + add x23,x23,:lo12:Lone_mont-64 + ldp x14,x15,[x22,#32] // in1 + cmp x24,#0 // ~, remember? + ldp x16,x17,[x22,#32+16] + csel x8,x4,x8,ne + csel x9,x5,x9,ne + ldp x4,x5,[sp,#0+32+32] // res + csel x10,x6,x10,ne + csel x11,x7,x11,ne + cmp x25,#0 // ~, remember? + ldp x6,x7,[sp,#0+32+48] + csel x14,x8,x14,ne + csel x15,x9,x15,ne + ldp x8,x9,[x23,#32+32] // in2 + csel x16,x10,x16,ne + csel x17,x11,x17,ne + ldp x10,x11,[x23,#32+48] + stp x14,x15,[x21,#32] + stp x16,x17,[x21,#32+16] + ldp x14,x15,[x22,#64] // in1 + cmp x24,#0 // ~, remember? + ldp x16,x17,[x22,#64+16] + csel x8,x4,x8,ne + csel x9,x5,x9,ne + csel x10,x6,x10,ne + csel x11,x7,x11,ne + cmp x25,#0 // ~, remember? + csel x14,x8,x14,ne + csel x15,x9,x15,ne + csel x16,x10,x16,ne + csel x17,x11,x17,ne + stp x14,x15,[x21,#64] + stp x16,x17,[x21,#64+16] + + add sp,x29,#0 // destroy frame + ldp x19,x20,[x29,#16] + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x29,x30,[sp],#80 + AARCH64_VALIDATE_LINK_REGISTER + ret + +//////////////////////////////////////////////////////////////////////// +// void ecp_nistz256_ord_mul_mont(uint64_t res[4], uint64_t a[4], +// uint64_t b[4]); +.globl ecp_nistz256_ord_mul_mont + +.def ecp_nistz256_ord_mul_mont + .type 32 +.endef +.align 4 +ecp_nistz256_ord_mul_mont: + AARCH64_VALID_CALL_TARGET + // Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later. + stp x29,x30,[sp,#-64]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + + adrp x23,Lord + add x23,x23,:lo12:Lord + ldr x3,[x2] // bp[0] + ldp x4,x5,[x1] + ldp x6,x7,[x1,#16] + + ldp x12,x13,[x23,#0] + ldp x21,x22,[x23,#16] + ldr x23,[x23,#32] + + mul x14,x4,x3 // a[0]*b[0] + umulh x8,x4,x3 + + mul x15,x5,x3 // a[1]*b[0] + umulh x9,x5,x3 + + mul x16,x6,x3 // a[2]*b[0] + umulh x10,x6,x3 + + mul x17,x7,x3 // a[3]*b[0] + umulh x19,x7,x3 + + mul x24,x14,x23 + + adds x15,x15,x8 // accumulate high parts of multiplication + adcs x16,x16,x9 + adcs x17,x17,x10 + adc x19,x19,xzr + mov x20,xzr + ldr x3,[x2,#8*1] // b[i] + + lsl x8,x24,#32 + subs x16,x16,x24 + lsr x9,x24,#32 + sbcs x17,x17,x8 + sbcs x19,x19,x9 + sbc x20,x20,xzr + + subs xzr,x14,#1 + umulh x9,x12,x24 + mul x10,x13,x24 + umulh x11,x13,x24 + + adcs x10,x10,x9 + mul x8,x4,x3 + adc x11,x11,xzr + mul x9,x5,x3 + + adds x14,x15,x10 + mul x10,x6,x3 + adcs x15,x16,x11 + mul x11,x7,x3 + adcs x16,x17,x24 + adcs x17,x19,x24 + adc x19,x20,xzr + + adds x14,x14,x8 // accumulate low parts + umulh x8,x4,x3 + adcs x15,x15,x9 + umulh x9,x5,x3 + adcs x16,x16,x10 + umulh x10,x6,x3 + adcs x17,x17,x11 + umulh x11,x7,x3 + adc x19,x19,xzr + mul x24,x14,x23 + adds x15,x15,x8 // accumulate high parts + adcs x16,x16,x9 + adcs x17,x17,x10 + adcs x19,x19,x11 + adc x20,xzr,xzr + ldr x3,[x2,#8*2] // b[i] + + lsl x8,x24,#32 + subs x16,x16,x24 + lsr x9,x24,#32 + sbcs x17,x17,x8 + sbcs x19,x19,x9 + sbc x20,x20,xzr + + subs xzr,x14,#1 + umulh x9,x12,x24 + mul x10,x13,x24 + umulh x11,x13,x24 + + adcs x10,x10,x9 + mul x8,x4,x3 + adc x11,x11,xzr + mul x9,x5,x3 + + adds x14,x15,x10 + mul x10,x6,x3 + adcs x15,x16,x11 + mul x11,x7,x3 + adcs x16,x17,x24 + adcs x17,x19,x24 + adc x19,x20,xzr + + adds x14,x14,x8 // accumulate low parts + umulh x8,x4,x3 + adcs x15,x15,x9 + umulh x9,x5,x3 + adcs x16,x16,x10 + umulh x10,x6,x3 + adcs x17,x17,x11 + umulh x11,x7,x3 + adc x19,x19,xzr + mul x24,x14,x23 + adds x15,x15,x8 // accumulate high parts + adcs x16,x16,x9 + adcs x17,x17,x10 + adcs x19,x19,x11 + adc x20,xzr,xzr + ldr x3,[x2,#8*3] // b[i] + + lsl x8,x24,#32 + subs x16,x16,x24 + lsr x9,x24,#32 + sbcs x17,x17,x8 + sbcs x19,x19,x9 + sbc x20,x20,xzr + + subs xzr,x14,#1 + umulh x9,x12,x24 + mul x10,x13,x24 + umulh x11,x13,x24 + + adcs x10,x10,x9 + mul x8,x4,x3 + adc x11,x11,xzr + mul x9,x5,x3 + + adds x14,x15,x10 + mul x10,x6,x3 + adcs x15,x16,x11 + mul x11,x7,x3 + adcs x16,x17,x24 + adcs x17,x19,x24 + adc x19,x20,xzr + + adds x14,x14,x8 // accumulate low parts + umulh x8,x4,x3 + adcs x15,x15,x9 + umulh x9,x5,x3 + adcs x16,x16,x10 + umulh x10,x6,x3 + adcs x17,x17,x11 + umulh x11,x7,x3 + adc x19,x19,xzr + mul x24,x14,x23 + adds x15,x15,x8 // accumulate high parts + adcs x16,x16,x9 + adcs x17,x17,x10 + adcs x19,x19,x11 + adc x20,xzr,xzr + lsl x8,x24,#32 // last reduction + subs x16,x16,x24 + lsr x9,x24,#32 + sbcs x17,x17,x8 + sbcs x19,x19,x9 + sbc x20,x20,xzr + + subs xzr,x14,#1 + umulh x9,x12,x24 + mul x10,x13,x24 + umulh x11,x13,x24 + + adcs x10,x10,x9 + adc x11,x11,xzr + + adds x14,x15,x10 + adcs x15,x16,x11 + adcs x16,x17,x24 + adcs x17,x19,x24 + adc x19,x20,xzr + + subs x8,x14,x12 // ret -= modulus + sbcs x9,x15,x13 + sbcs x10,x16,x21 + sbcs x11,x17,x22 + sbcs xzr,x19,xzr + + csel x14,x14,x8,lo // ret = borrow ? ret : ret-modulus + csel x15,x15,x9,lo + csel x16,x16,x10,lo + stp x14,x15,[x0] + csel x17,x17,x11,lo + stp x16,x17,[x0,#16] + + ldp x19,x20,[sp,#16] + ldp x21,x22,[sp,#32] + ldp x23,x24,[sp,#48] + ldr x29,[sp],#64 + ret + + +//////////////////////////////////////////////////////////////////////// +// void ecp_nistz256_ord_sqr_mont(uint64_t res[4], uint64_t a[4], +// uint64_t rep); +.globl ecp_nistz256_ord_sqr_mont + +.def ecp_nistz256_ord_sqr_mont + .type 32 +.endef +.align 4 +ecp_nistz256_ord_sqr_mont: + AARCH64_VALID_CALL_TARGET + // Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later. + stp x29,x30,[sp,#-64]! + add x29,sp,#0 + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + + adrp x23,Lord + add x23,x23,:lo12:Lord + ldp x4,x5,[x1] + ldp x6,x7,[x1,#16] + + ldp x12,x13,[x23,#0] + ldp x21,x22,[x23,#16] + ldr x23,[x23,#32] + b Loop_ord_sqr + +.align 4 +Loop_ord_sqr: + sub x2,x2,#1 + //////////////////////////////////////////////////////////////// + // | | | | | |a1*a0| | + // | | | | |a2*a0| | | + // | |a3*a2|a3*a0| | | | + // | | | |a2*a1| | | | + // | | |a3*a1| | | | | + // *| | | | | | | | 2| + // +|a3*a3|a2*a2|a1*a1|a0*a0| + // |--+--+--+--+--+--+--+--| + // |A7|A6|A5|A4|A3|A2|A1|A0|, where Ax is , i.e. follow + // + // "can't overflow" below mark carrying into high part of + // multiplication result, which can't overflow, because it + // can never be all ones. + + mul x15,x5,x4 // a[1]*a[0] + umulh x9,x5,x4 + mul x16,x6,x4 // a[2]*a[0] + umulh x10,x6,x4 + mul x17,x7,x4 // a[3]*a[0] + umulh x19,x7,x4 + + adds x16,x16,x9 // accumulate high parts of multiplication + mul x8,x6,x5 // a[2]*a[1] + umulh x9,x6,x5 + adcs x17,x17,x10 + mul x10,x7,x5 // a[3]*a[1] + umulh x11,x7,x5 + adc x19,x19,xzr // can't overflow + + mul x20,x7,x6 // a[3]*a[2] + umulh x1,x7,x6 + + adds x9,x9,x10 // accumulate high parts of multiplication + mul x14,x4,x4 // a[0]*a[0] + adc x10,x11,xzr // can't overflow + + adds x17,x17,x8 // accumulate low parts of multiplication + umulh x4,x4,x4 + adcs x19,x19,x9 + mul x9,x5,x5 // a[1]*a[1] + adcs x20,x20,x10 + umulh x5,x5,x5 + adc x1,x1,xzr // can't overflow + + adds x15,x15,x15 // acc[1-6]*=2 + mul x10,x6,x6 // a[2]*a[2] + adcs x16,x16,x16 + umulh x6,x6,x6 + adcs x17,x17,x17 + mul x11,x7,x7 // a[3]*a[3] + adcs x19,x19,x19 + umulh x7,x7,x7 + adcs x20,x20,x20 + adcs x1,x1,x1 + adc x3,xzr,xzr + + adds x15,x15,x4 // +a[i]*a[i] + mul x24,x14,x23 + adcs x16,x16,x9 + adcs x17,x17,x5 + adcs x19,x19,x10 + adcs x20,x20,x6 + adcs x1,x1,x11 + adc x3,x3,x7 + subs xzr,x14,#1 + umulh x9,x12,x24 + mul x10,x13,x24 + umulh x11,x13,x24 + + adcs x10,x10,x9 + adc x11,x11,xzr + + adds x14,x15,x10 + adcs x15,x16,x11 + adcs x16,x17,x24 + adc x17,xzr,x24 // can't overflow + mul x11,x14,x23 + lsl x8,x24,#32 + subs x15,x15,x24 + lsr x9,x24,#32 + sbcs x16,x16,x8 + sbc x17,x17,x9 // can't borrow + subs xzr,x14,#1 + umulh x9,x12,x11 + mul x10,x13,x11 + umulh x24,x13,x11 + + adcs x10,x10,x9 + adc x24,x24,xzr + + adds x14,x15,x10 + adcs x15,x16,x24 + adcs x16,x17,x11 + adc x17,xzr,x11 // can't overflow + mul x24,x14,x23 + lsl x8,x11,#32 + subs x15,x15,x11 + lsr x9,x11,#32 + sbcs x16,x16,x8 + sbc x17,x17,x9 // can't borrow + subs xzr,x14,#1 + umulh x9,x12,x24 + mul x10,x13,x24 + umulh x11,x13,x24 + + adcs x10,x10,x9 + adc x11,x11,xzr + + adds x14,x15,x10 + adcs x15,x16,x11 + adcs x16,x17,x24 + adc x17,xzr,x24 // can't overflow + mul x11,x14,x23 + lsl x8,x24,#32 + subs x15,x15,x24 + lsr x9,x24,#32 + sbcs x16,x16,x8 + sbc x17,x17,x9 // can't borrow + subs xzr,x14,#1 + umulh x9,x12,x11 + mul x10,x13,x11 + umulh x24,x13,x11 + + adcs x10,x10,x9 + adc x24,x24,xzr + + adds x14,x15,x10 + adcs x15,x16,x24 + adcs x16,x17,x11 + adc x17,xzr,x11 // can't overflow + lsl x8,x11,#32 + subs x15,x15,x11 + lsr x9,x11,#32 + sbcs x16,x16,x8 + sbc x17,x17,x9 // can't borrow + adds x14,x14,x19 // accumulate upper half + adcs x15,x15,x20 + adcs x16,x16,x1 + adcs x17,x17,x3 + adc x19,xzr,xzr + + subs x8,x14,x12 // ret -= modulus + sbcs x9,x15,x13 + sbcs x10,x16,x21 + sbcs x11,x17,x22 + sbcs xzr,x19,xzr + + csel x4,x14,x8,lo // ret = borrow ? ret : ret-modulus + csel x5,x15,x9,lo + csel x6,x16,x10,lo + csel x7,x17,x11,lo + + cbnz x2,Loop_ord_sqr + + stp x4,x5,[x0] + stp x6,x7,[x0,#16] + + ldp x19,x20,[sp,#16] + ldp x21,x22,[sp,#32] + ldp x23,x24,[sp,#48] + ldr x29,[sp],#64 + ret + +//////////////////////////////////////////////////////////////////////// +// void ecp_nistz256_select_w5(uint64_t *val, uint64_t *in_t, int index); +.globl ecp_nistz256_select_w5 + +.def ecp_nistz256_select_w5 + .type 32 +.endef +.align 4 +ecp_nistz256_select_w5: + AARCH64_VALID_CALL_TARGET + + // x10 := x0 + // w9 := 0; loop counter and incremented internal index + mov x10, x0 + mov w9, #0 + + // [v16-v21] := 0 + movi v16.16b, #0 + movi v17.16b, #0 + movi v18.16b, #0 + movi v19.16b, #0 + movi v20.16b, #0 + movi v21.16b, #0 + +Lselect_w5_loop: + // Loop 16 times. + + // Increment index (loop counter); tested at the end of the loop + add w9, w9, #1 + + // [v22-v27] := Load a (3*256-bit = 6*128-bit) table entry starting at x1 + // and advance x1 to point to the next entry + ld1 {v22.2d, v23.2d, v24.2d, v25.2d}, [x1],#64 + + // x11 := (w9 == w2)? All 1s : All 0s + cmp w9, w2 + csetm x11, eq + + // continue loading ... + ld1 {v26.2d, v27.2d}, [x1],#32 + + // duplicate mask_64 into Mask (all 0s or all 1s) + dup v3.2d, x11 + + // [v16-v19] := (Mask == all 1s)? [v22-v25] : [v16-v19] + // i.e., values in output registers will remain the same if w9 != w2 + bit v16.16b, v22.16b, v3.16b + bit v17.16b, v23.16b, v3.16b + + bit v18.16b, v24.16b, v3.16b + bit v19.16b, v25.16b, v3.16b + + bit v20.16b, v26.16b, v3.16b + bit v21.16b, v27.16b, v3.16b + + // If bit #4 is not 0 (i.e. idx_ctr < 16) loop back + tbz w9, #4, Lselect_w5_loop + + // Write [v16-v21] to memory at the output pointer + st1 {v16.2d, v17.2d, v18.2d, v19.2d}, [x10],#64 + st1 {v20.2d, v21.2d}, [x10] + + ret + + + +//////////////////////////////////////////////////////////////////////// +// void ecp_nistz256_select_w7(uint64_t *val, uint64_t *in_t, int index); +.globl ecp_nistz256_select_w7 + +.def ecp_nistz256_select_w7 + .type 32 +.endef +.align 4 +ecp_nistz256_select_w7: + AARCH64_VALID_CALL_TARGET + + // w9 := 0; loop counter and incremented internal index + mov w9, #0 + + // [v16-v21] := 0 + movi v16.16b, #0 + movi v17.16b, #0 + movi v18.16b, #0 + movi v19.16b, #0 + +Lselect_w7_loop: + // Loop 64 times. + + // Increment index (loop counter); tested at the end of the loop + add w9, w9, #1 + + // [v22-v25] := Load a (2*256-bit = 4*128-bit) table entry starting at x1 + // and advance x1 to point to the next entry + ld1 {v22.2d, v23.2d, v24.2d, v25.2d}, [x1],#64 + + // x11 := (w9 == w2)? All 1s : All 0s + cmp w9, w2 + csetm x11, eq + + // duplicate mask_64 into Mask (all 0s or all 1s) + dup v3.2d, x11 + + // [v16-v19] := (Mask == all 1s)? [v22-v25] : [v16-v19] + // i.e., values in output registers will remain the same if w9 != w2 + bit v16.16b, v22.16b, v3.16b + bit v17.16b, v23.16b, v3.16b + + bit v18.16b, v24.16b, v3.16b + bit v19.16b, v25.16b, v3.16b + + // If bit #6 is not 0 (i.e. idx_ctr < 64) loop back + tbz w9, #6, Lselect_w7_loop + + // Write [v16-v19] to memory at the output pointer + st1 {v16.2d, v17.2d, v18.2d, v19.2d}, [x0] + + ret + +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(_WIN32) diff --git a/http/vendor/ring/pregenerated/p256-x86_64-asm-elf.S b/http/vendor/ring/pregenerated/p256-x86_64-asm-elf.S new file mode 100644 index 0000000..deeec07 --- /dev/null +++ b/http/vendor/ring/pregenerated/p256-x86_64-asm-elf.S @@ -0,0 +1,4599 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__) +.text + + +.section .rodata +.align 64 +.Lpoly: +.quad 0xffffffffffffffff, 0x00000000ffffffff, 0x0000000000000000, 0xffffffff00000001 + +.LOne: +.long 1,1,1,1,1,1,1,1 +.LTwo: +.long 2,2,2,2,2,2,2,2 +.LThree: +.long 3,3,3,3,3,3,3,3 +.LONE_mont: +.quad 0x0000000000000001, 0xffffffff00000000, 0xffffffffffffffff, 0x00000000fffffffe + + +.Lord: +.quad 0xf3b9cac2fc632551, 0xbce6faada7179e84, 0xffffffffffffffff, 0xffffffff00000000 +.LordK: +.quad 0xccd1c8aaee00bc4f +.text + + + +.globl ecp_nistz256_neg +.hidden ecp_nistz256_neg +.type ecp_nistz256_neg,@function +.align 32 +ecp_nistz256_neg: +.cfi_startproc +_CET_ENDBR + pushq %r12 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r12,-16 + pushq %r13 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r13,-24 +.Lneg_body: + + xorq %r8,%r8 + xorq %r9,%r9 + xorq %r10,%r10 + xorq %r11,%r11 + xorq %r13,%r13 + + subq 0(%rsi),%r8 + sbbq 8(%rsi),%r9 + sbbq 16(%rsi),%r10 + movq %r8,%rax + sbbq 24(%rsi),%r11 + leaq .Lpoly(%rip),%rsi + movq %r9,%rdx + sbbq $0,%r13 + + addq 0(%rsi),%r8 + movq %r10,%rcx + adcq 8(%rsi),%r9 + adcq 16(%rsi),%r10 + movq %r11,%r12 + adcq 24(%rsi),%r11 + testq %r13,%r13 + + cmovzq %rax,%r8 + cmovzq %rdx,%r9 + movq %r8,0(%rdi) + cmovzq %rcx,%r10 + movq %r9,8(%rdi) + cmovzq %r12,%r11 + movq %r10,16(%rdi) + movq %r11,24(%rdi) + + movq 0(%rsp),%r13 +.cfi_restore %r13 + movq 8(%rsp),%r12 +.cfi_restore %r12 + leaq 16(%rsp),%rsp +.cfi_adjust_cfa_offset -16 +.Lneg_epilogue: + ret +.cfi_endproc +.size ecp_nistz256_neg,.-ecp_nistz256_neg + + + + + + +.globl ecp_nistz256_ord_mul_mont_nohw +.hidden ecp_nistz256_ord_mul_mont_nohw +.type ecp_nistz256_ord_mul_mont_nohw,@function +.align 32 +ecp_nistz256_ord_mul_mont_nohw: +.cfi_startproc +_CET_ENDBR + pushq %rbp +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbp,-16 + pushq %rbx +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbx,-24 + pushq %r12 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r12,-32 + pushq %r13 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r13,-40 + pushq %r14 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r14,-48 + pushq %r15 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r15,-56 +.Lord_mul_body: + + movq 0(%rdx),%rax + movq %rdx,%rbx + leaq .Lord(%rip),%r14 + movq .LordK(%rip),%r15 + + + movq %rax,%rcx + mulq 0(%rsi) + movq %rax,%r8 + movq %rcx,%rax + movq %rdx,%r9 + + mulq 8(%rsi) + addq %rax,%r9 + movq %rcx,%rax + adcq $0,%rdx + movq %rdx,%r10 + + mulq 16(%rsi) + addq %rax,%r10 + movq %rcx,%rax + adcq $0,%rdx + + movq %r8,%r13 + imulq %r15,%r8 + + movq %rdx,%r11 + mulq 24(%rsi) + addq %rax,%r11 + movq %r8,%rax + adcq $0,%rdx + movq %rdx,%r12 + + + mulq 0(%r14) + movq %r8,%rbp + addq %rax,%r13 + movq %r8,%rax + adcq $0,%rdx + movq %rdx,%rcx + + subq %r8,%r10 + sbbq $0,%r8 + + mulq 8(%r14) + addq %rcx,%r9 + adcq $0,%rdx + addq %rax,%r9 + movq %rbp,%rax + adcq %rdx,%r10 + movq %rbp,%rdx + adcq $0,%r8 + + shlq $32,%rax + shrq $32,%rdx + subq %rax,%r11 + movq 8(%rbx),%rax + sbbq %rdx,%rbp + + addq %r8,%r11 + adcq %rbp,%r12 + adcq $0,%r13 + + + movq %rax,%rcx + mulq 0(%rsi) + addq %rax,%r9 + movq %rcx,%rax + adcq $0,%rdx + movq %rdx,%rbp + + mulq 8(%rsi) + addq %rbp,%r10 + adcq $0,%rdx + addq %rax,%r10 + movq %rcx,%rax + adcq $0,%rdx + movq %rdx,%rbp + + mulq 16(%rsi) + addq %rbp,%r11 + adcq $0,%rdx + addq %rax,%r11 + movq %rcx,%rax + adcq $0,%rdx + + movq %r9,%rcx + imulq %r15,%r9 + + movq %rdx,%rbp + mulq 24(%rsi) + addq %rbp,%r12 + adcq $0,%rdx + xorq %r8,%r8 + addq %rax,%r12 + movq %r9,%rax + adcq %rdx,%r13 + adcq $0,%r8 + + + mulq 0(%r14) + movq %r9,%rbp + addq %rax,%rcx + movq %r9,%rax + adcq %rdx,%rcx + + subq %r9,%r11 + sbbq $0,%r9 + + mulq 8(%r14) + addq %rcx,%r10 + adcq $0,%rdx + addq %rax,%r10 + movq %rbp,%rax + adcq %rdx,%r11 + movq %rbp,%rdx + adcq $0,%r9 + + shlq $32,%rax + shrq $32,%rdx + subq %rax,%r12 + movq 16(%rbx),%rax + sbbq %rdx,%rbp + + addq %r9,%r12 + adcq %rbp,%r13 + adcq $0,%r8 + + + movq %rax,%rcx + mulq 0(%rsi) + addq %rax,%r10 + movq %rcx,%rax + adcq $0,%rdx + movq %rdx,%rbp + + mulq 8(%rsi) + addq %rbp,%r11 + adcq $0,%rdx + addq %rax,%r11 + movq %rcx,%rax + adcq $0,%rdx + movq %rdx,%rbp + + mulq 16(%rsi) + addq %rbp,%r12 + adcq $0,%rdx + addq %rax,%r12 + movq %rcx,%rax + adcq $0,%rdx + + movq %r10,%rcx + imulq %r15,%r10 + + movq %rdx,%rbp + mulq 24(%rsi) + addq %rbp,%r13 + adcq $0,%rdx + xorq %r9,%r9 + addq %rax,%r13 + movq %r10,%rax + adcq %rdx,%r8 + adcq $0,%r9 + + + mulq 0(%r14) + movq %r10,%rbp + addq %rax,%rcx + movq %r10,%rax + adcq %rdx,%rcx + + subq %r10,%r12 + sbbq $0,%r10 + + mulq 8(%r14) + addq %rcx,%r11 + adcq $0,%rdx + addq %rax,%r11 + movq %rbp,%rax + adcq %rdx,%r12 + movq %rbp,%rdx + adcq $0,%r10 + + shlq $32,%rax + shrq $32,%rdx + subq %rax,%r13 + movq 24(%rbx),%rax + sbbq %rdx,%rbp + + addq %r10,%r13 + adcq %rbp,%r8 + adcq $0,%r9 + + + movq %rax,%rcx + mulq 0(%rsi) + addq %rax,%r11 + movq %rcx,%rax + adcq $0,%rdx + movq %rdx,%rbp + + mulq 8(%rsi) + addq %rbp,%r12 + adcq $0,%rdx + addq %rax,%r12 + movq %rcx,%rax + adcq $0,%rdx + movq %rdx,%rbp + + mulq 16(%rsi) + addq %rbp,%r13 + adcq $0,%rdx + addq %rax,%r13 + movq %rcx,%rax + adcq $0,%rdx + + movq %r11,%rcx + imulq %r15,%r11 + + movq %rdx,%rbp + mulq 24(%rsi) + addq %rbp,%r8 + adcq $0,%rdx + xorq %r10,%r10 + addq %rax,%r8 + movq %r11,%rax + adcq %rdx,%r9 + adcq $0,%r10 + + + mulq 0(%r14) + movq %r11,%rbp + addq %rax,%rcx + movq %r11,%rax + adcq %rdx,%rcx + + subq %r11,%r13 + sbbq $0,%r11 + + mulq 8(%r14) + addq %rcx,%r12 + adcq $0,%rdx + addq %rax,%r12 + movq %rbp,%rax + adcq %rdx,%r13 + movq %rbp,%rdx + adcq $0,%r11 + + shlq $32,%rax + shrq $32,%rdx + subq %rax,%r8 + sbbq %rdx,%rbp + + addq %r11,%r8 + adcq %rbp,%r9 + adcq $0,%r10 + + + movq %r12,%rsi + subq 0(%r14),%r12 + movq %r13,%r11 + sbbq 8(%r14),%r13 + movq %r8,%rcx + sbbq 16(%r14),%r8 + movq %r9,%rbp + sbbq 24(%r14),%r9 + sbbq $0,%r10 + + cmovcq %rsi,%r12 + cmovcq %r11,%r13 + cmovcq %rcx,%r8 + cmovcq %rbp,%r9 + + movq %r12,0(%rdi) + movq %r13,8(%rdi) + movq %r8,16(%rdi) + movq %r9,24(%rdi) + + movq 0(%rsp),%r15 +.cfi_restore %r15 + movq 8(%rsp),%r14 +.cfi_restore %r14 + movq 16(%rsp),%r13 +.cfi_restore %r13 + movq 24(%rsp),%r12 +.cfi_restore %r12 + movq 32(%rsp),%rbx +.cfi_restore %rbx + movq 40(%rsp),%rbp +.cfi_restore %rbp + leaq 48(%rsp),%rsp +.cfi_adjust_cfa_offset -48 +.Lord_mul_epilogue: + ret +.cfi_endproc +.size ecp_nistz256_ord_mul_mont_nohw,.-ecp_nistz256_ord_mul_mont_nohw + + + + + + + +.globl ecp_nistz256_ord_sqr_mont_nohw +.hidden ecp_nistz256_ord_sqr_mont_nohw +.type ecp_nistz256_ord_sqr_mont_nohw,@function +.align 32 +ecp_nistz256_ord_sqr_mont_nohw: +.cfi_startproc +_CET_ENDBR + pushq %rbp +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbp,-16 + pushq %rbx +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbx,-24 + pushq %r12 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r12,-32 + pushq %r13 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r13,-40 + pushq %r14 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r14,-48 + pushq %r15 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r15,-56 +.Lord_sqr_body: + + movq 0(%rsi),%r8 + movq 8(%rsi),%rax + movq 16(%rsi),%r14 + movq 24(%rsi),%r15 + leaq .Lord(%rip),%rsi + movq %rdx,%rbx + jmp .Loop_ord_sqr + +.align 32 +.Loop_ord_sqr: + + movq %rax,%rbp + mulq %r8 + movq %rax,%r9 +.byte 102,72,15,110,205 + movq %r14,%rax + movq %rdx,%r10 + + mulq %r8 + addq %rax,%r10 + movq %r15,%rax +.byte 102,73,15,110,214 + adcq $0,%rdx + movq %rdx,%r11 + + mulq %r8 + addq %rax,%r11 + movq %r15,%rax +.byte 102,73,15,110,223 + adcq $0,%rdx + movq %rdx,%r12 + + + mulq %r14 + movq %rax,%r13 + movq %r14,%rax + movq %rdx,%r14 + + + mulq %rbp + addq %rax,%r11 + movq %r15,%rax + adcq $0,%rdx + movq %rdx,%r15 + + mulq %rbp + addq %rax,%r12 + adcq $0,%rdx + + addq %r15,%r12 + adcq %rdx,%r13 + adcq $0,%r14 + + + xorq %r15,%r15 + movq %r8,%rax + addq %r9,%r9 + adcq %r10,%r10 + adcq %r11,%r11 + adcq %r12,%r12 + adcq %r13,%r13 + adcq %r14,%r14 + adcq $0,%r15 + + + mulq %rax + movq %rax,%r8 +.byte 102,72,15,126,200 + movq %rdx,%rbp + + mulq %rax + addq %rbp,%r9 + adcq %rax,%r10 +.byte 102,72,15,126,208 + adcq $0,%rdx + movq %rdx,%rbp + + mulq %rax + addq %rbp,%r11 + adcq %rax,%r12 +.byte 102,72,15,126,216 + adcq $0,%rdx + movq %rdx,%rbp + + movq %r8,%rcx + imulq 32(%rsi),%r8 + + mulq %rax + addq %rbp,%r13 + adcq %rax,%r14 + movq 0(%rsi),%rax + adcq %rdx,%r15 + + + mulq %r8 + movq %r8,%rbp + addq %rax,%rcx + movq 8(%rsi),%rax + adcq %rdx,%rcx + + subq %r8,%r10 + sbbq $0,%rbp + + mulq %r8 + addq %rcx,%r9 + adcq $0,%rdx + addq %rax,%r9 + movq %r8,%rax + adcq %rdx,%r10 + movq %r8,%rdx + adcq $0,%rbp + + movq %r9,%rcx + imulq 32(%rsi),%r9 + + shlq $32,%rax + shrq $32,%rdx + subq %rax,%r11 + movq 0(%rsi),%rax + sbbq %rdx,%r8 + + addq %rbp,%r11 + adcq $0,%r8 + + + mulq %r9 + movq %r9,%rbp + addq %rax,%rcx + movq 8(%rsi),%rax + adcq %rdx,%rcx + + subq %r9,%r11 + sbbq $0,%rbp + + mulq %r9 + addq %rcx,%r10 + adcq $0,%rdx + addq %rax,%r10 + movq %r9,%rax + adcq %rdx,%r11 + movq %r9,%rdx + adcq $0,%rbp + + movq %r10,%rcx + imulq 32(%rsi),%r10 + + shlq $32,%rax + shrq $32,%rdx + subq %rax,%r8 + movq 0(%rsi),%rax + sbbq %rdx,%r9 + + addq %rbp,%r8 + adcq $0,%r9 + + + mulq %r10 + movq %r10,%rbp + addq %rax,%rcx + movq 8(%rsi),%rax + adcq %rdx,%rcx + + subq %r10,%r8 + sbbq $0,%rbp + + mulq %r10 + addq %rcx,%r11 + adcq $0,%rdx + addq %rax,%r11 + movq %r10,%rax + adcq %rdx,%r8 + movq %r10,%rdx + adcq $0,%rbp + + movq %r11,%rcx + imulq 32(%rsi),%r11 + + shlq $32,%rax + shrq $32,%rdx + subq %rax,%r9 + movq 0(%rsi),%rax + sbbq %rdx,%r10 + + addq %rbp,%r9 + adcq $0,%r10 + + + mulq %r11 + movq %r11,%rbp + addq %rax,%rcx + movq 8(%rsi),%rax + adcq %rdx,%rcx + + subq %r11,%r9 + sbbq $0,%rbp + + mulq %r11 + addq %rcx,%r8 + adcq $0,%rdx + addq %rax,%r8 + movq %r11,%rax + adcq %rdx,%r9 + movq %r11,%rdx + adcq $0,%rbp + + shlq $32,%rax + shrq $32,%rdx + subq %rax,%r10 + sbbq %rdx,%r11 + + addq %rbp,%r10 + adcq $0,%r11 + + + xorq %rdx,%rdx + addq %r12,%r8 + adcq %r13,%r9 + movq %r8,%r12 + adcq %r14,%r10 + adcq %r15,%r11 + movq %r9,%rax + adcq $0,%rdx + + + subq 0(%rsi),%r8 + movq %r10,%r14 + sbbq 8(%rsi),%r9 + sbbq 16(%rsi),%r10 + movq %r11,%r15 + sbbq 24(%rsi),%r11 + sbbq $0,%rdx + + cmovcq %r12,%r8 + cmovncq %r9,%rax + cmovncq %r10,%r14 + cmovncq %r11,%r15 + + decq %rbx + jnz .Loop_ord_sqr + + movq %r8,0(%rdi) + movq %rax,8(%rdi) + pxor %xmm1,%xmm1 + movq %r14,16(%rdi) + pxor %xmm2,%xmm2 + movq %r15,24(%rdi) + pxor %xmm3,%xmm3 + + movq 0(%rsp),%r15 +.cfi_restore %r15 + movq 8(%rsp),%r14 +.cfi_restore %r14 + movq 16(%rsp),%r13 +.cfi_restore %r13 + movq 24(%rsp),%r12 +.cfi_restore %r12 + movq 32(%rsp),%rbx +.cfi_restore %rbx + movq 40(%rsp),%rbp +.cfi_restore %rbp + leaq 48(%rsp),%rsp +.cfi_adjust_cfa_offset -48 +.Lord_sqr_epilogue: + ret +.cfi_endproc +.size ecp_nistz256_ord_sqr_mont_nohw,.-ecp_nistz256_ord_sqr_mont_nohw + +.globl ecp_nistz256_ord_mul_mont_adx +.hidden ecp_nistz256_ord_mul_mont_adx +.type ecp_nistz256_ord_mul_mont_adx,@function +.align 32 +ecp_nistz256_ord_mul_mont_adx: +.cfi_startproc +.Lecp_nistz256_ord_mul_mont_adx: +_CET_ENDBR + pushq %rbp +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbp,-16 + pushq %rbx +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbx,-24 + pushq %r12 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r12,-32 + pushq %r13 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r13,-40 + pushq %r14 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r14,-48 + pushq %r15 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r15,-56 +.Lord_mulx_body: + + movq %rdx,%rbx + movq 0(%rdx),%rdx + movq 0(%rsi),%r9 + movq 8(%rsi),%r10 + movq 16(%rsi),%r11 + movq 24(%rsi),%r12 + leaq -128(%rsi),%rsi + leaq .Lord-128(%rip),%r14 + movq .LordK(%rip),%r15 + + + mulxq %r9,%r8,%r9 + mulxq %r10,%rcx,%r10 + mulxq %r11,%rbp,%r11 + addq %rcx,%r9 + mulxq %r12,%rcx,%r12 + movq %r8,%rdx + mulxq %r15,%rdx,%rax + adcq %rbp,%r10 + adcq %rcx,%r11 + adcq $0,%r12 + + + xorq %r13,%r13 + mulxq 0+128(%r14),%rcx,%rbp + adcxq %rcx,%r8 + adoxq %rbp,%r9 + + mulxq 8+128(%r14),%rcx,%rbp + adcxq %rcx,%r9 + adoxq %rbp,%r10 + + mulxq 16+128(%r14),%rcx,%rbp + adcxq %rcx,%r10 + adoxq %rbp,%r11 + + mulxq 24+128(%r14),%rcx,%rbp + movq 8(%rbx),%rdx + adcxq %rcx,%r11 + adoxq %rbp,%r12 + adcxq %r8,%r12 + adoxq %r8,%r13 + adcq $0,%r13 + + + mulxq 0+128(%rsi),%rcx,%rbp + adcxq %rcx,%r9 + adoxq %rbp,%r10 + + mulxq 8+128(%rsi),%rcx,%rbp + adcxq %rcx,%r10 + adoxq %rbp,%r11 + + mulxq 16+128(%rsi),%rcx,%rbp + adcxq %rcx,%r11 + adoxq %rbp,%r12 + + mulxq 24+128(%rsi),%rcx,%rbp + movq %r9,%rdx + mulxq %r15,%rdx,%rax + adcxq %rcx,%r12 + adoxq %rbp,%r13 + + adcxq %r8,%r13 + adoxq %r8,%r8 + adcq $0,%r8 + + + mulxq 0+128(%r14),%rcx,%rbp + adcxq %rcx,%r9 + adoxq %rbp,%r10 + + mulxq 8+128(%r14),%rcx,%rbp + adcxq %rcx,%r10 + adoxq %rbp,%r11 + + mulxq 16+128(%r14),%rcx,%rbp + adcxq %rcx,%r11 + adoxq %rbp,%r12 + + mulxq 24+128(%r14),%rcx,%rbp + movq 16(%rbx),%rdx + adcxq %rcx,%r12 + adoxq %rbp,%r13 + adcxq %r9,%r13 + adoxq %r9,%r8 + adcq $0,%r8 + + + mulxq 0+128(%rsi),%rcx,%rbp + adcxq %rcx,%r10 + adoxq %rbp,%r11 + + mulxq 8+128(%rsi),%rcx,%rbp + adcxq %rcx,%r11 + adoxq %rbp,%r12 + + mulxq 16+128(%rsi),%rcx,%rbp + adcxq %rcx,%r12 + adoxq %rbp,%r13 + + mulxq 24+128(%rsi),%rcx,%rbp + movq %r10,%rdx + mulxq %r15,%rdx,%rax + adcxq %rcx,%r13 + adoxq %rbp,%r8 + + adcxq %r9,%r8 + adoxq %r9,%r9 + adcq $0,%r9 + + + mulxq 0+128(%r14),%rcx,%rbp + adcxq %rcx,%r10 + adoxq %rbp,%r11 + + mulxq 8+128(%r14),%rcx,%rbp + adcxq %rcx,%r11 + adoxq %rbp,%r12 + + mulxq 16+128(%r14),%rcx,%rbp + adcxq %rcx,%r12 + adoxq %rbp,%r13 + + mulxq 24+128(%r14),%rcx,%rbp + movq 24(%rbx),%rdx + adcxq %rcx,%r13 + adoxq %rbp,%r8 + adcxq %r10,%r8 + adoxq %r10,%r9 + adcq $0,%r9 + + + mulxq 0+128(%rsi),%rcx,%rbp + adcxq %rcx,%r11 + adoxq %rbp,%r12 + + mulxq 8+128(%rsi),%rcx,%rbp + adcxq %rcx,%r12 + adoxq %rbp,%r13 + + mulxq 16+128(%rsi),%rcx,%rbp + adcxq %rcx,%r13 + adoxq %rbp,%r8 + + mulxq 24+128(%rsi),%rcx,%rbp + movq %r11,%rdx + mulxq %r15,%rdx,%rax + adcxq %rcx,%r8 + adoxq %rbp,%r9 + + adcxq %r10,%r9 + adoxq %r10,%r10 + adcq $0,%r10 + + + mulxq 0+128(%r14),%rcx,%rbp + adcxq %rcx,%r11 + adoxq %rbp,%r12 + + mulxq 8+128(%r14),%rcx,%rbp + adcxq %rcx,%r12 + adoxq %rbp,%r13 + + mulxq 16+128(%r14),%rcx,%rbp + adcxq %rcx,%r13 + adoxq %rbp,%r8 + + mulxq 24+128(%r14),%rcx,%rbp + leaq 128(%r14),%r14 + movq %r12,%rbx + adcxq %rcx,%r8 + adoxq %rbp,%r9 + movq %r13,%rdx + adcxq %r11,%r9 + adoxq %r11,%r10 + adcq $0,%r10 + + + + movq %r8,%rcx + subq 0(%r14),%r12 + sbbq 8(%r14),%r13 + sbbq 16(%r14),%r8 + movq %r9,%rbp + sbbq 24(%r14),%r9 + sbbq $0,%r10 + + cmovcq %rbx,%r12 + cmovcq %rdx,%r13 + cmovcq %rcx,%r8 + cmovcq %rbp,%r9 + + movq %r12,0(%rdi) + movq %r13,8(%rdi) + movq %r8,16(%rdi) + movq %r9,24(%rdi) + + movq 0(%rsp),%r15 +.cfi_restore %r15 + movq 8(%rsp),%r14 +.cfi_restore %r14 + movq 16(%rsp),%r13 +.cfi_restore %r13 + movq 24(%rsp),%r12 +.cfi_restore %r12 + movq 32(%rsp),%rbx +.cfi_restore %rbx + movq 40(%rsp),%rbp +.cfi_restore %rbp + leaq 48(%rsp),%rsp +.cfi_adjust_cfa_offset -48 +.Lord_mulx_epilogue: + ret +.cfi_endproc +.size ecp_nistz256_ord_mul_mont_adx,.-ecp_nistz256_ord_mul_mont_adx + +.globl ecp_nistz256_ord_sqr_mont_adx +.hidden ecp_nistz256_ord_sqr_mont_adx +.type ecp_nistz256_ord_sqr_mont_adx,@function +.align 32 +ecp_nistz256_ord_sqr_mont_adx: +.cfi_startproc +_CET_ENDBR +.Lecp_nistz256_ord_sqr_mont_adx: + pushq %rbp +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbp,-16 + pushq %rbx +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbx,-24 + pushq %r12 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r12,-32 + pushq %r13 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r13,-40 + pushq %r14 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r14,-48 + pushq %r15 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r15,-56 +.Lord_sqrx_body: + + movq %rdx,%rbx + movq 0(%rsi),%rdx + movq 8(%rsi),%r14 + movq 16(%rsi),%r15 + movq 24(%rsi),%r8 + leaq .Lord(%rip),%rsi + jmp .Loop_ord_sqrx + +.align 32 +.Loop_ord_sqrx: + mulxq %r14,%r9,%r10 + mulxq %r15,%rcx,%r11 + movq %rdx,%rax +.byte 102,73,15,110,206 + mulxq %r8,%rbp,%r12 + movq %r14,%rdx + addq %rcx,%r10 +.byte 102,73,15,110,215 + adcq %rbp,%r11 + adcq $0,%r12 + xorq %r13,%r13 + + mulxq %r15,%rcx,%rbp + adcxq %rcx,%r11 + adoxq %rbp,%r12 + + mulxq %r8,%rcx,%rbp + movq %r15,%rdx + adcxq %rcx,%r12 + adoxq %rbp,%r13 + adcq $0,%r13 + + mulxq %r8,%rcx,%r14 + movq %rax,%rdx +.byte 102,73,15,110,216 + xorq %r15,%r15 + adcxq %r9,%r9 + adoxq %rcx,%r13 + adcxq %r10,%r10 + adoxq %r15,%r14 + + + mulxq %rdx,%r8,%rbp +.byte 102,72,15,126,202 + adcxq %r11,%r11 + adoxq %rbp,%r9 + adcxq %r12,%r12 + mulxq %rdx,%rcx,%rax +.byte 102,72,15,126,210 + adcxq %r13,%r13 + adoxq %rcx,%r10 + adcxq %r14,%r14 + mulxq %rdx,%rcx,%rbp +.byte 0x67 +.byte 102,72,15,126,218 + adoxq %rax,%r11 + adcxq %r15,%r15 + adoxq %rcx,%r12 + adoxq %rbp,%r13 + mulxq %rdx,%rcx,%rax + adoxq %rcx,%r14 + adoxq %rax,%r15 + + + movq %r8,%rdx + mulxq 32(%rsi),%rdx,%rcx + + xorq %rax,%rax + mulxq 0(%rsi),%rcx,%rbp + adcxq %rcx,%r8 + adoxq %rbp,%r9 + mulxq 8(%rsi),%rcx,%rbp + adcxq %rcx,%r9 + adoxq %rbp,%r10 + mulxq 16(%rsi),%rcx,%rbp + adcxq %rcx,%r10 + adoxq %rbp,%r11 + mulxq 24(%rsi),%rcx,%rbp + adcxq %rcx,%r11 + adoxq %rbp,%r8 + adcxq %rax,%r8 + + + movq %r9,%rdx + mulxq 32(%rsi),%rdx,%rcx + + mulxq 0(%rsi),%rcx,%rbp + adoxq %rcx,%r9 + adcxq %rbp,%r10 + mulxq 8(%rsi),%rcx,%rbp + adoxq %rcx,%r10 + adcxq %rbp,%r11 + mulxq 16(%rsi),%rcx,%rbp + adoxq %rcx,%r11 + adcxq %rbp,%r8 + mulxq 24(%rsi),%rcx,%rbp + adoxq %rcx,%r8 + adcxq %rbp,%r9 + adoxq %rax,%r9 + + + movq %r10,%rdx + mulxq 32(%rsi),%rdx,%rcx + + mulxq 0(%rsi),%rcx,%rbp + adcxq %rcx,%r10 + adoxq %rbp,%r11 + mulxq 8(%rsi),%rcx,%rbp + adcxq %rcx,%r11 + adoxq %rbp,%r8 + mulxq 16(%rsi),%rcx,%rbp + adcxq %rcx,%r8 + adoxq %rbp,%r9 + mulxq 24(%rsi),%rcx,%rbp + adcxq %rcx,%r9 + adoxq %rbp,%r10 + adcxq %rax,%r10 + + + movq %r11,%rdx + mulxq 32(%rsi),%rdx,%rcx + + mulxq 0(%rsi),%rcx,%rbp + adoxq %rcx,%r11 + adcxq %rbp,%r8 + mulxq 8(%rsi),%rcx,%rbp + adoxq %rcx,%r8 + adcxq %rbp,%r9 + mulxq 16(%rsi),%rcx,%rbp + adoxq %rcx,%r9 + adcxq %rbp,%r10 + mulxq 24(%rsi),%rcx,%rbp + adoxq %rcx,%r10 + adcxq %rbp,%r11 + adoxq %rax,%r11 + + + addq %r8,%r12 + adcq %r13,%r9 + movq %r12,%rdx + adcq %r14,%r10 + adcq %r15,%r11 + movq %r9,%r14 + adcq $0,%rax + + + subq 0(%rsi),%r12 + movq %r10,%r15 + sbbq 8(%rsi),%r9 + sbbq 16(%rsi),%r10 + movq %r11,%r8 + sbbq 24(%rsi),%r11 + sbbq $0,%rax + + cmovncq %r12,%rdx + cmovncq %r9,%r14 + cmovncq %r10,%r15 + cmovncq %r11,%r8 + + decq %rbx + jnz .Loop_ord_sqrx + + movq %rdx,0(%rdi) + movq %r14,8(%rdi) + pxor %xmm1,%xmm1 + movq %r15,16(%rdi) + pxor %xmm2,%xmm2 + movq %r8,24(%rdi) + pxor %xmm3,%xmm3 + + movq 0(%rsp),%r15 +.cfi_restore %r15 + movq 8(%rsp),%r14 +.cfi_restore %r14 + movq 16(%rsp),%r13 +.cfi_restore %r13 + movq 24(%rsp),%r12 +.cfi_restore %r12 + movq 32(%rsp),%rbx +.cfi_restore %rbx + movq 40(%rsp),%rbp +.cfi_restore %rbp + leaq 48(%rsp),%rsp +.cfi_adjust_cfa_offset -48 +.Lord_sqrx_epilogue: + ret +.cfi_endproc +.size ecp_nistz256_ord_sqr_mont_adx,.-ecp_nistz256_ord_sqr_mont_adx + + + + + + +.globl ecp_nistz256_mul_mont_nohw +.hidden ecp_nistz256_mul_mont_nohw +.type ecp_nistz256_mul_mont_nohw,@function +.align 32 +ecp_nistz256_mul_mont_nohw: +.cfi_startproc +_CET_ENDBR + pushq %rbp +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbp,-16 + pushq %rbx +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbx,-24 + pushq %r12 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r12,-32 + pushq %r13 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r13,-40 + pushq %r14 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r14,-48 + pushq %r15 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r15,-56 +.Lmul_body: + movq %rdx,%rbx + movq 0(%rdx),%rax + movq 0(%rsi),%r9 + movq 8(%rsi),%r10 + movq 16(%rsi),%r11 + movq 24(%rsi),%r12 + + call __ecp_nistz256_mul_montq + + movq 0(%rsp),%r15 +.cfi_restore %r15 + movq 8(%rsp),%r14 +.cfi_restore %r14 + movq 16(%rsp),%r13 +.cfi_restore %r13 + movq 24(%rsp),%r12 +.cfi_restore %r12 + movq 32(%rsp),%rbx +.cfi_restore %rbx + movq 40(%rsp),%rbp +.cfi_restore %rbp + leaq 48(%rsp),%rsp +.cfi_adjust_cfa_offset -48 +.Lmul_epilogue: + ret +.cfi_endproc +.size ecp_nistz256_mul_mont_nohw,.-ecp_nistz256_mul_mont_nohw + +.type __ecp_nistz256_mul_montq,@function +.align 32 +__ecp_nistz256_mul_montq: +.cfi_startproc + + + movq %rax,%rbp + mulq %r9 + movq .Lpoly+8(%rip),%r14 + movq %rax,%r8 + movq %rbp,%rax + movq %rdx,%r9 + + mulq %r10 + movq .Lpoly+24(%rip),%r15 + addq %rax,%r9 + movq %rbp,%rax + adcq $0,%rdx + movq %rdx,%r10 + + mulq %r11 + addq %rax,%r10 + movq %rbp,%rax + adcq $0,%rdx + movq %rdx,%r11 + + mulq %r12 + addq %rax,%r11 + movq %r8,%rax + adcq $0,%rdx + xorq %r13,%r13 + movq %rdx,%r12 + + + + + + + + + + + movq %r8,%rbp + shlq $32,%r8 + mulq %r15 + shrq $32,%rbp + addq %r8,%r9 + adcq %rbp,%r10 + adcq %rax,%r11 + movq 8(%rbx),%rax + adcq %rdx,%r12 + adcq $0,%r13 + xorq %r8,%r8 + + + + movq %rax,%rbp + mulq 0(%rsi) + addq %rax,%r9 + movq %rbp,%rax + adcq $0,%rdx + movq %rdx,%rcx + + mulq 8(%rsi) + addq %rcx,%r10 + adcq $0,%rdx + addq %rax,%r10 + movq %rbp,%rax + adcq $0,%rdx + movq %rdx,%rcx + + mulq 16(%rsi) + addq %rcx,%r11 + adcq $0,%rdx + addq %rax,%r11 + movq %rbp,%rax + adcq $0,%rdx + movq %rdx,%rcx + + mulq 24(%rsi) + addq %rcx,%r12 + adcq $0,%rdx + addq %rax,%r12 + movq %r9,%rax + adcq %rdx,%r13 + adcq $0,%r8 + + + + movq %r9,%rbp + shlq $32,%r9 + mulq %r15 + shrq $32,%rbp + addq %r9,%r10 + adcq %rbp,%r11 + adcq %rax,%r12 + movq 16(%rbx),%rax + adcq %rdx,%r13 + adcq $0,%r8 + xorq %r9,%r9 + + + + movq %rax,%rbp + mulq 0(%rsi) + addq %rax,%r10 + movq %rbp,%rax + adcq $0,%rdx + movq %rdx,%rcx + + mulq 8(%rsi) + addq %rcx,%r11 + adcq $0,%rdx + addq %rax,%r11 + movq %rbp,%rax + adcq $0,%rdx + movq %rdx,%rcx + + mulq 16(%rsi) + addq %rcx,%r12 + adcq $0,%rdx + addq %rax,%r12 + movq %rbp,%rax + adcq $0,%rdx + movq %rdx,%rcx + + mulq 24(%rsi) + addq %rcx,%r13 + adcq $0,%rdx + addq %rax,%r13 + movq %r10,%rax + adcq %rdx,%r8 + adcq $0,%r9 + + + + movq %r10,%rbp + shlq $32,%r10 + mulq %r15 + shrq $32,%rbp + addq %r10,%r11 + adcq %rbp,%r12 + adcq %rax,%r13 + movq 24(%rbx),%rax + adcq %rdx,%r8 + adcq $0,%r9 + xorq %r10,%r10 + + + + movq %rax,%rbp + mulq 0(%rsi) + addq %rax,%r11 + movq %rbp,%rax + adcq $0,%rdx + movq %rdx,%rcx + + mulq 8(%rsi) + addq %rcx,%r12 + adcq $0,%rdx + addq %rax,%r12 + movq %rbp,%rax + adcq $0,%rdx + movq %rdx,%rcx + + mulq 16(%rsi) + addq %rcx,%r13 + adcq $0,%rdx + addq %rax,%r13 + movq %rbp,%rax + adcq $0,%rdx + movq %rdx,%rcx + + mulq 24(%rsi) + addq %rcx,%r8 + adcq $0,%rdx + addq %rax,%r8 + movq %r11,%rax + adcq %rdx,%r9 + adcq $0,%r10 + + + + movq %r11,%rbp + shlq $32,%r11 + mulq %r15 + shrq $32,%rbp + addq %r11,%r12 + adcq %rbp,%r13 + movq %r12,%rcx + adcq %rax,%r8 + adcq %rdx,%r9 + movq %r13,%rbp + adcq $0,%r10 + + + + subq $-1,%r12 + movq %r8,%rbx + sbbq %r14,%r13 + sbbq $0,%r8 + movq %r9,%rdx + sbbq %r15,%r9 + sbbq $0,%r10 + + cmovcq %rcx,%r12 + cmovcq %rbp,%r13 + movq %r12,0(%rdi) + cmovcq %rbx,%r8 + movq %r13,8(%rdi) + cmovcq %rdx,%r9 + movq %r8,16(%rdi) + movq %r9,24(%rdi) + + ret +.cfi_endproc +.size __ecp_nistz256_mul_montq,.-__ecp_nistz256_mul_montq + + + + + + + + +.globl ecp_nistz256_sqr_mont_nohw +.hidden ecp_nistz256_sqr_mont_nohw +.type ecp_nistz256_sqr_mont_nohw,@function +.align 32 +ecp_nistz256_sqr_mont_nohw: +.cfi_startproc +_CET_ENDBR + pushq %rbp +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbp,-16 + pushq %rbx +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbx,-24 + pushq %r12 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r12,-32 + pushq %r13 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r13,-40 + pushq %r14 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r14,-48 + pushq %r15 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r15,-56 +.Lsqr_body: + movq 0(%rsi),%rax + movq 8(%rsi),%r14 + movq 16(%rsi),%r15 + movq 24(%rsi),%r8 + + call __ecp_nistz256_sqr_montq + + movq 0(%rsp),%r15 +.cfi_restore %r15 + movq 8(%rsp),%r14 +.cfi_restore %r14 + movq 16(%rsp),%r13 +.cfi_restore %r13 + movq 24(%rsp),%r12 +.cfi_restore %r12 + movq 32(%rsp),%rbx +.cfi_restore %rbx + movq 40(%rsp),%rbp +.cfi_restore %rbp + leaq 48(%rsp),%rsp +.cfi_adjust_cfa_offset -48 +.Lsqr_epilogue: + ret +.cfi_endproc +.size ecp_nistz256_sqr_mont_nohw,.-ecp_nistz256_sqr_mont_nohw + +.type __ecp_nistz256_sqr_montq,@function +.align 32 +__ecp_nistz256_sqr_montq: +.cfi_startproc + movq %rax,%r13 + mulq %r14 + movq %rax,%r9 + movq %r15,%rax + movq %rdx,%r10 + + mulq %r13 + addq %rax,%r10 + movq %r8,%rax + adcq $0,%rdx + movq %rdx,%r11 + + mulq %r13 + addq %rax,%r11 + movq %r15,%rax + adcq $0,%rdx + movq %rdx,%r12 + + + mulq %r14 + addq %rax,%r11 + movq %r8,%rax + adcq $0,%rdx + movq %rdx,%rbp + + mulq %r14 + addq %rax,%r12 + movq %r8,%rax + adcq $0,%rdx + addq %rbp,%r12 + movq %rdx,%r13 + adcq $0,%r13 + + + mulq %r15 + xorq %r15,%r15 + addq %rax,%r13 + movq 0(%rsi),%rax + movq %rdx,%r14 + adcq $0,%r14 + + addq %r9,%r9 + adcq %r10,%r10 + adcq %r11,%r11 + adcq %r12,%r12 + adcq %r13,%r13 + adcq %r14,%r14 + adcq $0,%r15 + + mulq %rax + movq %rax,%r8 + movq 8(%rsi),%rax + movq %rdx,%rcx + + mulq %rax + addq %rcx,%r9 + adcq %rax,%r10 + movq 16(%rsi),%rax + adcq $0,%rdx + movq %rdx,%rcx + + mulq %rax + addq %rcx,%r11 + adcq %rax,%r12 + movq 24(%rsi),%rax + adcq $0,%rdx + movq %rdx,%rcx + + mulq %rax + addq %rcx,%r13 + adcq %rax,%r14 + movq %r8,%rax + adcq %rdx,%r15 + + movq .Lpoly+8(%rip),%rsi + movq .Lpoly+24(%rip),%rbp + + + + + movq %r8,%rcx + shlq $32,%r8 + mulq %rbp + shrq $32,%rcx + addq %r8,%r9 + adcq %rcx,%r10 + adcq %rax,%r11 + movq %r9,%rax + adcq $0,%rdx + + + + movq %r9,%rcx + shlq $32,%r9 + movq %rdx,%r8 + mulq %rbp + shrq $32,%rcx + addq %r9,%r10 + adcq %rcx,%r11 + adcq %rax,%r8 + movq %r10,%rax + adcq $0,%rdx + + + + movq %r10,%rcx + shlq $32,%r10 + movq %rdx,%r9 + mulq %rbp + shrq $32,%rcx + addq %r10,%r11 + adcq %rcx,%r8 + adcq %rax,%r9 + movq %r11,%rax + adcq $0,%rdx + + + + movq %r11,%rcx + shlq $32,%r11 + movq %rdx,%r10 + mulq %rbp + shrq $32,%rcx + addq %r11,%r8 + adcq %rcx,%r9 + adcq %rax,%r10 + adcq $0,%rdx + xorq %r11,%r11 + + + + addq %r8,%r12 + adcq %r9,%r13 + movq %r12,%r8 + adcq %r10,%r14 + adcq %rdx,%r15 + movq %r13,%r9 + adcq $0,%r11 + + subq $-1,%r12 + movq %r14,%r10 + sbbq %rsi,%r13 + sbbq $0,%r14 + movq %r15,%rcx + sbbq %rbp,%r15 + sbbq $0,%r11 + + cmovcq %r8,%r12 + cmovcq %r9,%r13 + movq %r12,0(%rdi) + cmovcq %r10,%r14 + movq %r13,8(%rdi) + cmovcq %rcx,%r15 + movq %r14,16(%rdi) + movq %r15,24(%rdi) + + ret +.cfi_endproc +.size __ecp_nistz256_sqr_montq,.-__ecp_nistz256_sqr_montq +.globl ecp_nistz256_mul_mont_adx +.hidden ecp_nistz256_mul_mont_adx +.type ecp_nistz256_mul_mont_adx,@function +.align 32 +ecp_nistz256_mul_mont_adx: +.cfi_startproc +_CET_ENDBR + pushq %rbp +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbp,-16 + pushq %rbx +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbx,-24 + pushq %r12 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r12,-32 + pushq %r13 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r13,-40 + pushq %r14 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r14,-48 + pushq %r15 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r15,-56 +.Lmulx_body: + movq %rdx,%rbx + movq 0(%rdx),%rdx + movq 0(%rsi),%r9 + movq 8(%rsi),%r10 + movq 16(%rsi),%r11 + movq 24(%rsi),%r12 + leaq -128(%rsi),%rsi + + call __ecp_nistz256_mul_montx + + movq 0(%rsp),%r15 +.cfi_restore %r15 + movq 8(%rsp),%r14 +.cfi_restore %r14 + movq 16(%rsp),%r13 +.cfi_restore %r13 + movq 24(%rsp),%r12 +.cfi_restore %r12 + movq 32(%rsp),%rbx +.cfi_restore %rbx + movq 40(%rsp),%rbp +.cfi_restore %rbp + leaq 48(%rsp),%rsp +.cfi_adjust_cfa_offset -48 +.Lmulx_epilogue: + ret +.cfi_endproc +.size ecp_nistz256_mul_mont_adx,.-ecp_nistz256_mul_mont_adx + +.type __ecp_nistz256_mul_montx,@function +.align 32 +__ecp_nistz256_mul_montx: +.cfi_startproc + + + mulxq %r9,%r8,%r9 + mulxq %r10,%rcx,%r10 + movq $32,%r14 + xorq %r13,%r13 + mulxq %r11,%rbp,%r11 + movq .Lpoly+24(%rip),%r15 + adcq %rcx,%r9 + mulxq %r12,%rcx,%r12 + movq %r8,%rdx + adcq %rbp,%r10 + shlxq %r14,%r8,%rbp + adcq %rcx,%r11 + shrxq %r14,%r8,%rcx + adcq $0,%r12 + + + + addq %rbp,%r9 + adcq %rcx,%r10 + + mulxq %r15,%rcx,%rbp + movq 8(%rbx),%rdx + adcq %rcx,%r11 + adcq %rbp,%r12 + adcq $0,%r13 + xorq %r8,%r8 + + + + mulxq 0+128(%rsi),%rcx,%rbp + adcxq %rcx,%r9 + adoxq %rbp,%r10 + + mulxq 8+128(%rsi),%rcx,%rbp + adcxq %rcx,%r10 + adoxq %rbp,%r11 + + mulxq 16+128(%rsi),%rcx,%rbp + adcxq %rcx,%r11 + adoxq %rbp,%r12 + + mulxq 24+128(%rsi),%rcx,%rbp + movq %r9,%rdx + adcxq %rcx,%r12 + shlxq %r14,%r9,%rcx + adoxq %rbp,%r13 + shrxq %r14,%r9,%rbp + + adcxq %r8,%r13 + adoxq %r8,%r8 + adcq $0,%r8 + + + + addq %rcx,%r10 + adcq %rbp,%r11 + + mulxq %r15,%rcx,%rbp + movq 16(%rbx),%rdx + adcq %rcx,%r12 + adcq %rbp,%r13 + adcq $0,%r8 + xorq %r9,%r9 + + + + mulxq 0+128(%rsi),%rcx,%rbp + adcxq %rcx,%r10 + adoxq %rbp,%r11 + + mulxq 8+128(%rsi),%rcx,%rbp + adcxq %rcx,%r11 + adoxq %rbp,%r12 + + mulxq 16+128(%rsi),%rcx,%rbp + adcxq %rcx,%r12 + adoxq %rbp,%r13 + + mulxq 24+128(%rsi),%rcx,%rbp + movq %r10,%rdx + adcxq %rcx,%r13 + shlxq %r14,%r10,%rcx + adoxq %rbp,%r8 + shrxq %r14,%r10,%rbp + + adcxq %r9,%r8 + adoxq %r9,%r9 + adcq $0,%r9 + + + + addq %rcx,%r11 + adcq %rbp,%r12 + + mulxq %r15,%rcx,%rbp + movq 24(%rbx),%rdx + adcq %rcx,%r13 + adcq %rbp,%r8 + adcq $0,%r9 + xorq %r10,%r10 + + + + mulxq 0+128(%rsi),%rcx,%rbp + adcxq %rcx,%r11 + adoxq %rbp,%r12 + + mulxq 8+128(%rsi),%rcx,%rbp + adcxq %rcx,%r12 + adoxq %rbp,%r13 + + mulxq 16+128(%rsi),%rcx,%rbp + adcxq %rcx,%r13 + adoxq %rbp,%r8 + + mulxq 24+128(%rsi),%rcx,%rbp + movq %r11,%rdx + adcxq %rcx,%r8 + shlxq %r14,%r11,%rcx + adoxq %rbp,%r9 + shrxq %r14,%r11,%rbp + + adcxq %r10,%r9 + adoxq %r10,%r10 + adcq $0,%r10 + + + + addq %rcx,%r12 + adcq %rbp,%r13 + + mulxq %r15,%rcx,%rbp + movq %r12,%rbx + movq .Lpoly+8(%rip),%r14 + adcq %rcx,%r8 + movq %r13,%rdx + adcq %rbp,%r9 + adcq $0,%r10 + + + + xorl %eax,%eax + movq %r8,%rcx + sbbq $-1,%r12 + sbbq %r14,%r13 + sbbq $0,%r8 + movq %r9,%rbp + sbbq %r15,%r9 + sbbq $0,%r10 + + cmovcq %rbx,%r12 + cmovcq %rdx,%r13 + movq %r12,0(%rdi) + cmovcq %rcx,%r8 + movq %r13,8(%rdi) + cmovcq %rbp,%r9 + movq %r8,16(%rdi) + movq %r9,24(%rdi) + + ret +.cfi_endproc +.size __ecp_nistz256_mul_montx,.-__ecp_nistz256_mul_montx + +.globl ecp_nistz256_sqr_mont_adx +.hidden ecp_nistz256_sqr_mont_adx +.type ecp_nistz256_sqr_mont_adx,@function +.align 32 +ecp_nistz256_sqr_mont_adx: +.cfi_startproc +_CET_ENDBR + pushq %rbp +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbp,-16 + pushq %rbx +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbx,-24 + pushq %r12 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r12,-32 + pushq %r13 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r13,-40 + pushq %r14 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r14,-48 + pushq %r15 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r15,-56 +.Lsqrx_body: + movq 0(%rsi),%rdx + movq 8(%rsi),%r14 + movq 16(%rsi),%r15 + movq 24(%rsi),%r8 + leaq -128(%rsi),%rsi + + call __ecp_nistz256_sqr_montx + + movq 0(%rsp),%r15 +.cfi_restore %r15 + movq 8(%rsp),%r14 +.cfi_restore %r14 + movq 16(%rsp),%r13 +.cfi_restore %r13 + movq 24(%rsp),%r12 +.cfi_restore %r12 + movq 32(%rsp),%rbx +.cfi_restore %rbx + movq 40(%rsp),%rbp +.cfi_restore %rbp + leaq 48(%rsp),%rsp +.cfi_adjust_cfa_offset -48 +.Lsqrx_epilogue: + ret +.cfi_endproc +.size ecp_nistz256_sqr_mont_adx,.-ecp_nistz256_sqr_mont_adx + +.type __ecp_nistz256_sqr_montx,@function +.align 32 +__ecp_nistz256_sqr_montx: +.cfi_startproc + mulxq %r14,%r9,%r10 + mulxq %r15,%rcx,%r11 + xorl %eax,%eax + adcq %rcx,%r10 + mulxq %r8,%rbp,%r12 + movq %r14,%rdx + adcq %rbp,%r11 + adcq $0,%r12 + xorq %r13,%r13 + + + mulxq %r15,%rcx,%rbp + adcxq %rcx,%r11 + adoxq %rbp,%r12 + + mulxq %r8,%rcx,%rbp + movq %r15,%rdx + adcxq %rcx,%r12 + adoxq %rbp,%r13 + adcq $0,%r13 + + + mulxq %r8,%rcx,%r14 + movq 0+128(%rsi),%rdx + xorq %r15,%r15 + adcxq %r9,%r9 + adoxq %rcx,%r13 + adcxq %r10,%r10 + adoxq %r15,%r14 + + mulxq %rdx,%r8,%rbp + movq 8+128(%rsi),%rdx + adcxq %r11,%r11 + adoxq %rbp,%r9 + adcxq %r12,%r12 + mulxq %rdx,%rcx,%rax + movq 16+128(%rsi),%rdx + adcxq %r13,%r13 + adoxq %rcx,%r10 + adcxq %r14,%r14 +.byte 0x67 + mulxq %rdx,%rcx,%rbp + movq 24+128(%rsi),%rdx + adoxq %rax,%r11 + adcxq %r15,%r15 + adoxq %rcx,%r12 + movq $32,%rsi + adoxq %rbp,%r13 +.byte 0x67,0x67 + mulxq %rdx,%rcx,%rax + movq .Lpoly+24(%rip),%rdx + adoxq %rcx,%r14 + shlxq %rsi,%r8,%rcx + adoxq %rax,%r15 + shrxq %rsi,%r8,%rax + movq %rdx,%rbp + + + addq %rcx,%r9 + adcq %rax,%r10 + + mulxq %r8,%rcx,%r8 + adcq %rcx,%r11 + shlxq %rsi,%r9,%rcx + adcq $0,%r8 + shrxq %rsi,%r9,%rax + + + addq %rcx,%r10 + adcq %rax,%r11 + + mulxq %r9,%rcx,%r9 + adcq %rcx,%r8 + shlxq %rsi,%r10,%rcx + adcq $0,%r9 + shrxq %rsi,%r10,%rax + + + addq %rcx,%r11 + adcq %rax,%r8 + + mulxq %r10,%rcx,%r10 + adcq %rcx,%r9 + shlxq %rsi,%r11,%rcx + adcq $0,%r10 + shrxq %rsi,%r11,%rax + + + addq %rcx,%r8 + adcq %rax,%r9 + + mulxq %r11,%rcx,%r11 + adcq %rcx,%r10 + adcq $0,%r11 + + xorq %rdx,%rdx + addq %r8,%r12 + movq .Lpoly+8(%rip),%rsi + adcq %r9,%r13 + movq %r12,%r8 + adcq %r10,%r14 + adcq %r11,%r15 + movq %r13,%r9 + adcq $0,%rdx + + subq $-1,%r12 + movq %r14,%r10 + sbbq %rsi,%r13 + sbbq $0,%r14 + movq %r15,%r11 + sbbq %rbp,%r15 + sbbq $0,%rdx + + cmovcq %r8,%r12 + cmovcq %r9,%r13 + movq %r12,0(%rdi) + cmovcq %r10,%r14 + movq %r13,8(%rdi) + cmovcq %r11,%r15 + movq %r14,16(%rdi) + movq %r15,24(%rdi) + + ret +.cfi_endproc +.size __ecp_nistz256_sqr_montx,.-__ecp_nistz256_sqr_montx + + +.globl ecp_nistz256_select_w5_nohw +.hidden ecp_nistz256_select_w5_nohw +.type ecp_nistz256_select_w5_nohw,@function +.align 32 +ecp_nistz256_select_w5_nohw: +.cfi_startproc +_CET_ENDBR + movdqa .LOne(%rip),%xmm0 + movd %edx,%xmm1 + + pxor %xmm2,%xmm2 + pxor %xmm3,%xmm3 + pxor %xmm4,%xmm4 + pxor %xmm5,%xmm5 + pxor %xmm6,%xmm6 + pxor %xmm7,%xmm7 + + movdqa %xmm0,%xmm8 + pshufd $0,%xmm1,%xmm1 + + movq $16,%rax +.Lselect_loop_sse_w5: + + movdqa %xmm8,%xmm15 + paddd %xmm0,%xmm8 + pcmpeqd %xmm1,%xmm15 + + movdqa 0(%rsi),%xmm9 + movdqa 16(%rsi),%xmm10 + movdqa 32(%rsi),%xmm11 + movdqa 48(%rsi),%xmm12 + movdqa 64(%rsi),%xmm13 + movdqa 80(%rsi),%xmm14 + leaq 96(%rsi),%rsi + + pand %xmm15,%xmm9 + pand %xmm15,%xmm10 + por %xmm9,%xmm2 + pand %xmm15,%xmm11 + por %xmm10,%xmm3 + pand %xmm15,%xmm12 + por %xmm11,%xmm4 + pand %xmm15,%xmm13 + por %xmm12,%xmm5 + pand %xmm15,%xmm14 + por %xmm13,%xmm6 + por %xmm14,%xmm7 + + decq %rax + jnz .Lselect_loop_sse_w5 + + movdqu %xmm2,0(%rdi) + movdqu %xmm3,16(%rdi) + movdqu %xmm4,32(%rdi) + movdqu %xmm5,48(%rdi) + movdqu %xmm6,64(%rdi) + movdqu %xmm7,80(%rdi) + ret +.cfi_endproc +.LSEH_end_ecp_nistz256_select_w5_nohw: +.size ecp_nistz256_select_w5_nohw,.-ecp_nistz256_select_w5_nohw + + + +.globl ecp_nistz256_select_w7_nohw +.hidden ecp_nistz256_select_w7_nohw +.type ecp_nistz256_select_w7_nohw,@function +.align 32 +ecp_nistz256_select_w7_nohw: +.cfi_startproc +_CET_ENDBR + movdqa .LOne(%rip),%xmm8 + movd %edx,%xmm1 + + pxor %xmm2,%xmm2 + pxor %xmm3,%xmm3 + pxor %xmm4,%xmm4 + pxor %xmm5,%xmm5 + + movdqa %xmm8,%xmm0 + pshufd $0,%xmm1,%xmm1 + movq $64,%rax + +.Lselect_loop_sse_w7: + movdqa %xmm8,%xmm15 + paddd %xmm0,%xmm8 + movdqa 0(%rsi),%xmm9 + movdqa 16(%rsi),%xmm10 + pcmpeqd %xmm1,%xmm15 + movdqa 32(%rsi),%xmm11 + movdqa 48(%rsi),%xmm12 + leaq 64(%rsi),%rsi + + pand %xmm15,%xmm9 + pand %xmm15,%xmm10 + por %xmm9,%xmm2 + pand %xmm15,%xmm11 + por %xmm10,%xmm3 + pand %xmm15,%xmm12 + por %xmm11,%xmm4 + prefetcht0 255(%rsi) + por %xmm12,%xmm5 + + decq %rax + jnz .Lselect_loop_sse_w7 + + movdqu %xmm2,0(%rdi) + movdqu %xmm3,16(%rdi) + movdqu %xmm4,32(%rdi) + movdqu %xmm5,48(%rdi) + ret +.cfi_endproc +.LSEH_end_ecp_nistz256_select_w7_nohw: +.size ecp_nistz256_select_w7_nohw,.-ecp_nistz256_select_w7_nohw + + +.globl ecp_nistz256_select_w5_avx2 +.hidden ecp_nistz256_select_w5_avx2 +.type ecp_nistz256_select_w5_avx2,@function +.align 32 +ecp_nistz256_select_w5_avx2: +.cfi_startproc +_CET_ENDBR + vzeroupper + vmovdqa .LTwo(%rip),%ymm0 + + vpxor %ymm2,%ymm2,%ymm2 + vpxor %ymm3,%ymm3,%ymm3 + vpxor %ymm4,%ymm4,%ymm4 + + vmovdqa .LOne(%rip),%ymm5 + vmovdqa .LTwo(%rip),%ymm10 + + vmovd %edx,%xmm1 + vpermd %ymm1,%ymm2,%ymm1 + + movq $8,%rax +.Lselect_loop_avx2_w5: + + vmovdqa 0(%rsi),%ymm6 + vmovdqa 32(%rsi),%ymm7 + vmovdqa 64(%rsi),%ymm8 + + vmovdqa 96(%rsi),%ymm11 + vmovdqa 128(%rsi),%ymm12 + vmovdqa 160(%rsi),%ymm13 + + vpcmpeqd %ymm1,%ymm5,%ymm9 + vpcmpeqd %ymm1,%ymm10,%ymm14 + + vpaddd %ymm0,%ymm5,%ymm5 + vpaddd %ymm0,%ymm10,%ymm10 + leaq 192(%rsi),%rsi + + vpand %ymm9,%ymm6,%ymm6 + vpand %ymm9,%ymm7,%ymm7 + vpand %ymm9,%ymm8,%ymm8 + vpand %ymm14,%ymm11,%ymm11 + vpand %ymm14,%ymm12,%ymm12 + vpand %ymm14,%ymm13,%ymm13 + + vpxor %ymm6,%ymm2,%ymm2 + vpxor %ymm7,%ymm3,%ymm3 + vpxor %ymm8,%ymm4,%ymm4 + vpxor %ymm11,%ymm2,%ymm2 + vpxor %ymm12,%ymm3,%ymm3 + vpxor %ymm13,%ymm4,%ymm4 + + decq %rax + jnz .Lselect_loop_avx2_w5 + + vmovdqu %ymm2,0(%rdi) + vmovdqu %ymm3,32(%rdi) + vmovdqu %ymm4,64(%rdi) + vzeroupper + ret +.cfi_endproc +.LSEH_end_ecp_nistz256_select_w5_avx2: +.size ecp_nistz256_select_w5_avx2,.-ecp_nistz256_select_w5_avx2 + + + +.globl ecp_nistz256_select_w7_avx2 +.hidden ecp_nistz256_select_w7_avx2 +.type ecp_nistz256_select_w7_avx2,@function +.align 32 +ecp_nistz256_select_w7_avx2: +.cfi_startproc +_CET_ENDBR + vzeroupper + vmovdqa .LThree(%rip),%ymm0 + + vpxor %ymm2,%ymm2,%ymm2 + vpxor %ymm3,%ymm3,%ymm3 + + vmovdqa .LOne(%rip),%ymm4 + vmovdqa .LTwo(%rip),%ymm8 + vmovdqa .LThree(%rip),%ymm12 + + vmovd %edx,%xmm1 + vpermd %ymm1,%ymm2,%ymm1 + + + movq $21,%rax +.Lselect_loop_avx2_w7: + + vmovdqa 0(%rsi),%ymm5 + vmovdqa 32(%rsi),%ymm6 + + vmovdqa 64(%rsi),%ymm9 + vmovdqa 96(%rsi),%ymm10 + + vmovdqa 128(%rsi),%ymm13 + vmovdqa 160(%rsi),%ymm14 + + vpcmpeqd %ymm1,%ymm4,%ymm7 + vpcmpeqd %ymm1,%ymm8,%ymm11 + vpcmpeqd %ymm1,%ymm12,%ymm15 + + vpaddd %ymm0,%ymm4,%ymm4 + vpaddd %ymm0,%ymm8,%ymm8 + vpaddd %ymm0,%ymm12,%ymm12 + leaq 192(%rsi),%rsi + + vpand %ymm7,%ymm5,%ymm5 + vpand %ymm7,%ymm6,%ymm6 + vpand %ymm11,%ymm9,%ymm9 + vpand %ymm11,%ymm10,%ymm10 + vpand %ymm15,%ymm13,%ymm13 + vpand %ymm15,%ymm14,%ymm14 + + vpxor %ymm5,%ymm2,%ymm2 + vpxor %ymm6,%ymm3,%ymm3 + vpxor %ymm9,%ymm2,%ymm2 + vpxor %ymm10,%ymm3,%ymm3 + vpxor %ymm13,%ymm2,%ymm2 + vpxor %ymm14,%ymm3,%ymm3 + + decq %rax + jnz .Lselect_loop_avx2_w7 + + + vmovdqa 0(%rsi),%ymm5 + vmovdqa 32(%rsi),%ymm6 + + vpcmpeqd %ymm1,%ymm4,%ymm7 + + vpand %ymm7,%ymm5,%ymm5 + vpand %ymm7,%ymm6,%ymm6 + + vpxor %ymm5,%ymm2,%ymm2 + vpxor %ymm6,%ymm3,%ymm3 + + vmovdqu %ymm2,0(%rdi) + vmovdqu %ymm3,32(%rdi) + vzeroupper + ret +.cfi_endproc +.LSEH_end_ecp_nistz256_select_w7_avx2: +.size ecp_nistz256_select_w7_avx2,.-ecp_nistz256_select_w7_avx2 +.type __ecp_nistz256_add_toq,@function +.align 32 +__ecp_nistz256_add_toq: +.cfi_startproc + xorq %r11,%r11 + addq 0(%rbx),%r12 + adcq 8(%rbx),%r13 + movq %r12,%rax + adcq 16(%rbx),%r8 + adcq 24(%rbx),%r9 + movq %r13,%rbp + adcq $0,%r11 + + subq $-1,%r12 + movq %r8,%rcx + sbbq %r14,%r13 + sbbq $0,%r8 + movq %r9,%r10 + sbbq %r15,%r9 + sbbq $0,%r11 + + cmovcq %rax,%r12 + cmovcq %rbp,%r13 + movq %r12,0(%rdi) + cmovcq %rcx,%r8 + movq %r13,8(%rdi) + cmovcq %r10,%r9 + movq %r8,16(%rdi) + movq %r9,24(%rdi) + + ret +.cfi_endproc +.size __ecp_nistz256_add_toq,.-__ecp_nistz256_add_toq + +.type __ecp_nistz256_sub_fromq,@function +.align 32 +__ecp_nistz256_sub_fromq: +.cfi_startproc + subq 0(%rbx),%r12 + sbbq 8(%rbx),%r13 + movq %r12,%rax + sbbq 16(%rbx),%r8 + sbbq 24(%rbx),%r9 + movq %r13,%rbp + sbbq %r11,%r11 + + addq $-1,%r12 + movq %r8,%rcx + adcq %r14,%r13 + adcq $0,%r8 + movq %r9,%r10 + adcq %r15,%r9 + testq %r11,%r11 + + cmovzq %rax,%r12 + cmovzq %rbp,%r13 + movq %r12,0(%rdi) + cmovzq %rcx,%r8 + movq %r13,8(%rdi) + cmovzq %r10,%r9 + movq %r8,16(%rdi) + movq %r9,24(%rdi) + + ret +.cfi_endproc +.size __ecp_nistz256_sub_fromq,.-__ecp_nistz256_sub_fromq + +.type __ecp_nistz256_subq,@function +.align 32 +__ecp_nistz256_subq: +.cfi_startproc + subq %r12,%rax + sbbq %r13,%rbp + movq %rax,%r12 + sbbq %r8,%rcx + sbbq %r9,%r10 + movq %rbp,%r13 + sbbq %r11,%r11 + + addq $-1,%rax + movq %rcx,%r8 + adcq %r14,%rbp + adcq $0,%rcx + movq %r10,%r9 + adcq %r15,%r10 + testq %r11,%r11 + + cmovnzq %rax,%r12 + cmovnzq %rbp,%r13 + cmovnzq %rcx,%r8 + cmovnzq %r10,%r9 + + ret +.cfi_endproc +.size __ecp_nistz256_subq,.-__ecp_nistz256_subq + +.type __ecp_nistz256_mul_by_2q,@function +.align 32 +__ecp_nistz256_mul_by_2q: +.cfi_startproc + xorq %r11,%r11 + addq %r12,%r12 + adcq %r13,%r13 + movq %r12,%rax + adcq %r8,%r8 + adcq %r9,%r9 + movq %r13,%rbp + adcq $0,%r11 + + subq $-1,%r12 + movq %r8,%rcx + sbbq %r14,%r13 + sbbq $0,%r8 + movq %r9,%r10 + sbbq %r15,%r9 + sbbq $0,%r11 + + cmovcq %rax,%r12 + cmovcq %rbp,%r13 + movq %r12,0(%rdi) + cmovcq %rcx,%r8 + movq %r13,8(%rdi) + cmovcq %r10,%r9 + movq %r8,16(%rdi) + movq %r9,24(%rdi) + + ret +.cfi_endproc +.size __ecp_nistz256_mul_by_2q,.-__ecp_nistz256_mul_by_2q +.globl ecp_nistz256_point_double_nohw +.hidden ecp_nistz256_point_double_nohw +.type ecp_nistz256_point_double_nohw,@function +.align 32 +ecp_nistz256_point_double_nohw: +.cfi_startproc +_CET_ENDBR + pushq %rbp +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbp,-16 + pushq %rbx +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbx,-24 + pushq %r12 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r12,-32 + pushq %r13 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r13,-40 + pushq %r14 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r14,-48 + pushq %r15 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r15,-56 + subq $160+8,%rsp +.cfi_adjust_cfa_offset 32*5+8 +.Lpoint_doubleq_body: + +.Lpoint_double_shortcutq: + movdqu 0(%rsi),%xmm0 + movq %rsi,%rbx + movdqu 16(%rsi),%xmm1 + movq 32+0(%rsi),%r12 + movq 32+8(%rsi),%r13 + movq 32+16(%rsi),%r8 + movq 32+24(%rsi),%r9 + movq .Lpoly+8(%rip),%r14 + movq .Lpoly+24(%rip),%r15 + movdqa %xmm0,96(%rsp) + movdqa %xmm1,96+16(%rsp) + leaq 32(%rdi),%r10 + leaq 64(%rdi),%r11 +.byte 102,72,15,110,199 +.byte 102,73,15,110,202 +.byte 102,73,15,110,211 + + leaq 0(%rsp),%rdi + call __ecp_nistz256_mul_by_2q + + movq 64+0(%rsi),%rax + movq 64+8(%rsi),%r14 + movq 64+16(%rsi),%r15 + movq 64+24(%rsi),%r8 + leaq 64-0(%rsi),%rsi + leaq 64(%rsp),%rdi + call __ecp_nistz256_sqr_montq + + movq 0+0(%rsp),%rax + movq 8+0(%rsp),%r14 + leaq 0+0(%rsp),%rsi + movq 16+0(%rsp),%r15 + movq 24+0(%rsp),%r8 + leaq 0(%rsp),%rdi + call __ecp_nistz256_sqr_montq + + movq 32(%rbx),%rax + movq 64+0(%rbx),%r9 + movq 64+8(%rbx),%r10 + movq 64+16(%rbx),%r11 + movq 64+24(%rbx),%r12 + leaq 64-0(%rbx),%rsi + leaq 32(%rbx),%rbx +.byte 102,72,15,126,215 + call __ecp_nistz256_mul_montq + call __ecp_nistz256_mul_by_2q + + movq 96+0(%rsp),%r12 + movq 96+8(%rsp),%r13 + leaq 64(%rsp),%rbx + movq 96+16(%rsp),%r8 + movq 96+24(%rsp),%r9 + leaq 32(%rsp),%rdi + call __ecp_nistz256_add_toq + + movq 96+0(%rsp),%r12 + movq 96+8(%rsp),%r13 + leaq 64(%rsp),%rbx + movq 96+16(%rsp),%r8 + movq 96+24(%rsp),%r9 + leaq 64(%rsp),%rdi + call __ecp_nistz256_sub_fromq + + movq 0+0(%rsp),%rax + movq 8+0(%rsp),%r14 + leaq 0+0(%rsp),%rsi + movq 16+0(%rsp),%r15 + movq 24+0(%rsp),%r8 +.byte 102,72,15,126,207 + call __ecp_nistz256_sqr_montq + xorq %r9,%r9 + movq %r12,%rax + addq $-1,%r12 + movq %r13,%r10 + adcq %rsi,%r13 + movq %r14,%rcx + adcq $0,%r14 + movq %r15,%r8 + adcq %rbp,%r15 + adcq $0,%r9 + xorq %rsi,%rsi + testq $1,%rax + + cmovzq %rax,%r12 + cmovzq %r10,%r13 + cmovzq %rcx,%r14 + cmovzq %r8,%r15 + cmovzq %rsi,%r9 + + movq %r13,%rax + shrq $1,%r12 + shlq $63,%rax + movq %r14,%r10 + shrq $1,%r13 + orq %rax,%r12 + shlq $63,%r10 + movq %r15,%rcx + shrq $1,%r14 + orq %r10,%r13 + shlq $63,%rcx + movq %r12,0(%rdi) + shrq $1,%r15 + movq %r13,8(%rdi) + shlq $63,%r9 + orq %rcx,%r14 + orq %r9,%r15 + movq %r14,16(%rdi) + movq %r15,24(%rdi) + movq 64(%rsp),%rax + leaq 64(%rsp),%rbx + movq 0+32(%rsp),%r9 + movq 8+32(%rsp),%r10 + leaq 0+32(%rsp),%rsi + movq 16+32(%rsp),%r11 + movq 24+32(%rsp),%r12 + leaq 32(%rsp),%rdi + call __ecp_nistz256_mul_montq + + leaq 128(%rsp),%rdi + call __ecp_nistz256_mul_by_2q + + leaq 32(%rsp),%rbx + leaq 32(%rsp),%rdi + call __ecp_nistz256_add_toq + + movq 96(%rsp),%rax + leaq 96(%rsp),%rbx + movq 0+0(%rsp),%r9 + movq 8+0(%rsp),%r10 + leaq 0+0(%rsp),%rsi + movq 16+0(%rsp),%r11 + movq 24+0(%rsp),%r12 + leaq 0(%rsp),%rdi + call __ecp_nistz256_mul_montq + + leaq 128(%rsp),%rdi + call __ecp_nistz256_mul_by_2q + + movq 0+32(%rsp),%rax + movq 8+32(%rsp),%r14 + leaq 0+32(%rsp),%rsi + movq 16+32(%rsp),%r15 + movq 24+32(%rsp),%r8 +.byte 102,72,15,126,199 + call __ecp_nistz256_sqr_montq + + leaq 128(%rsp),%rbx + movq %r14,%r8 + movq %r15,%r9 + movq %rsi,%r14 + movq %rbp,%r15 + call __ecp_nistz256_sub_fromq + + movq 0+0(%rsp),%rax + movq 0+8(%rsp),%rbp + movq 0+16(%rsp),%rcx + movq 0+24(%rsp),%r10 + leaq 0(%rsp),%rdi + call __ecp_nistz256_subq + + movq 32(%rsp),%rax + leaq 32(%rsp),%rbx + movq %r12,%r14 + xorl %ecx,%ecx + movq %r12,0+0(%rsp) + movq %r13,%r10 + movq %r13,0+8(%rsp) + cmovzq %r8,%r11 + movq %r8,0+16(%rsp) + leaq 0-0(%rsp),%rsi + cmovzq %r9,%r12 + movq %r9,0+24(%rsp) + movq %r14,%r9 + leaq 0(%rsp),%rdi + call __ecp_nistz256_mul_montq + +.byte 102,72,15,126,203 +.byte 102,72,15,126,207 + call __ecp_nistz256_sub_fromq + + leaq 160+56(%rsp),%rsi +.cfi_def_cfa %rsi,8 + movq -48(%rsi),%r15 +.cfi_restore %r15 + movq -40(%rsi),%r14 +.cfi_restore %r14 + movq -32(%rsi),%r13 +.cfi_restore %r13 + movq -24(%rsi),%r12 +.cfi_restore %r12 + movq -16(%rsi),%rbx +.cfi_restore %rbx + movq -8(%rsi),%rbp +.cfi_restore %rbp + leaq (%rsi),%rsp +.cfi_def_cfa_register %rsp +.Lpoint_doubleq_epilogue: + ret +.cfi_endproc +.size ecp_nistz256_point_double_nohw,.-ecp_nistz256_point_double_nohw +.globl ecp_nistz256_point_add_nohw +.hidden ecp_nistz256_point_add_nohw +.type ecp_nistz256_point_add_nohw,@function +.align 32 +ecp_nistz256_point_add_nohw: +.cfi_startproc +_CET_ENDBR + pushq %rbp +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbp,-16 + pushq %rbx +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbx,-24 + pushq %r12 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r12,-32 + pushq %r13 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r13,-40 + pushq %r14 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r14,-48 + pushq %r15 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r15,-56 + subq $576+8,%rsp +.cfi_adjust_cfa_offset 32*18+8 +.Lpoint_addq_body: + + movdqu 0(%rsi),%xmm0 + movdqu 16(%rsi),%xmm1 + movdqu 32(%rsi),%xmm2 + movdqu 48(%rsi),%xmm3 + movdqu 64(%rsi),%xmm4 + movdqu 80(%rsi),%xmm5 + movq %rsi,%rbx + movq %rdx,%rsi + movdqa %xmm0,384(%rsp) + movdqa %xmm1,384+16(%rsp) + movdqa %xmm2,416(%rsp) + movdqa %xmm3,416+16(%rsp) + movdqa %xmm4,448(%rsp) + movdqa %xmm5,448+16(%rsp) + por %xmm4,%xmm5 + + movdqu 0(%rsi),%xmm0 + pshufd $0xb1,%xmm5,%xmm3 + movdqu 16(%rsi),%xmm1 + movdqu 32(%rsi),%xmm2 + por %xmm3,%xmm5 + movdqu 48(%rsi),%xmm3 + movq 64+0(%rsi),%rax + movq 64+8(%rsi),%r14 + movq 64+16(%rsi),%r15 + movq 64+24(%rsi),%r8 + movdqa %xmm0,480(%rsp) + pshufd $0x1e,%xmm5,%xmm4 + movdqa %xmm1,480+16(%rsp) + movdqu 64(%rsi),%xmm0 + movdqu 80(%rsi),%xmm1 + movdqa %xmm2,512(%rsp) + movdqa %xmm3,512+16(%rsp) + por %xmm4,%xmm5 + pxor %xmm4,%xmm4 + por %xmm0,%xmm1 +.byte 102,72,15,110,199 + + leaq 64-0(%rsi),%rsi + movq %rax,544+0(%rsp) + movq %r14,544+8(%rsp) + movq %r15,544+16(%rsp) + movq %r8,544+24(%rsp) + leaq 96(%rsp),%rdi + call __ecp_nistz256_sqr_montq + + pcmpeqd %xmm4,%xmm5 + pshufd $0xb1,%xmm1,%xmm4 + por %xmm1,%xmm4 + pshufd $0,%xmm5,%xmm5 + pshufd $0x1e,%xmm4,%xmm3 + por %xmm3,%xmm4 + pxor %xmm3,%xmm3 + pcmpeqd %xmm3,%xmm4 + pshufd $0,%xmm4,%xmm4 + movq 64+0(%rbx),%rax + movq 64+8(%rbx),%r14 + movq 64+16(%rbx),%r15 + movq 64+24(%rbx),%r8 +.byte 102,72,15,110,203 + + leaq 64-0(%rbx),%rsi + leaq 32(%rsp),%rdi + call __ecp_nistz256_sqr_montq + + movq 544(%rsp),%rax + leaq 544(%rsp),%rbx + movq 0+96(%rsp),%r9 + movq 8+96(%rsp),%r10 + leaq 0+96(%rsp),%rsi + movq 16+96(%rsp),%r11 + movq 24+96(%rsp),%r12 + leaq 224(%rsp),%rdi + call __ecp_nistz256_mul_montq + + movq 448(%rsp),%rax + leaq 448(%rsp),%rbx + movq 0+32(%rsp),%r9 + movq 8+32(%rsp),%r10 + leaq 0+32(%rsp),%rsi + movq 16+32(%rsp),%r11 + movq 24+32(%rsp),%r12 + leaq 256(%rsp),%rdi + call __ecp_nistz256_mul_montq + + movq 416(%rsp),%rax + leaq 416(%rsp),%rbx + movq 0+224(%rsp),%r9 + movq 8+224(%rsp),%r10 + leaq 0+224(%rsp),%rsi + movq 16+224(%rsp),%r11 + movq 24+224(%rsp),%r12 + leaq 224(%rsp),%rdi + call __ecp_nistz256_mul_montq + + movq 512(%rsp),%rax + leaq 512(%rsp),%rbx + movq 0+256(%rsp),%r9 + movq 8+256(%rsp),%r10 + leaq 0+256(%rsp),%rsi + movq 16+256(%rsp),%r11 + movq 24+256(%rsp),%r12 + leaq 256(%rsp),%rdi + call __ecp_nistz256_mul_montq + + leaq 224(%rsp),%rbx + leaq 64(%rsp),%rdi + call __ecp_nistz256_sub_fromq + + orq %r13,%r12 + movdqa %xmm4,%xmm2 + orq %r8,%r12 + orq %r9,%r12 + por %xmm5,%xmm2 +.byte 102,73,15,110,220 + + movq 384(%rsp),%rax + leaq 384(%rsp),%rbx + movq 0+96(%rsp),%r9 + movq 8+96(%rsp),%r10 + leaq 0+96(%rsp),%rsi + movq 16+96(%rsp),%r11 + movq 24+96(%rsp),%r12 + leaq 160(%rsp),%rdi + call __ecp_nistz256_mul_montq + + movq 480(%rsp),%rax + leaq 480(%rsp),%rbx + movq 0+32(%rsp),%r9 + movq 8+32(%rsp),%r10 + leaq 0+32(%rsp),%rsi + movq 16+32(%rsp),%r11 + movq 24+32(%rsp),%r12 + leaq 192(%rsp),%rdi + call __ecp_nistz256_mul_montq + + leaq 160(%rsp),%rbx + leaq 0(%rsp),%rdi + call __ecp_nistz256_sub_fromq + + orq %r13,%r12 + orq %r8,%r12 + orq %r9,%r12 + +.byte 102,73,15,126,208 +.byte 102,73,15,126,217 + orq %r8,%r12 +.byte 0x3e + jnz .Ladd_proceedq + + + + testq %r9,%r9 + jz .Ladd_doubleq + + + + + + +.byte 102,72,15,126,199 + pxor %xmm0,%xmm0 + movdqu %xmm0,0(%rdi) + movdqu %xmm0,16(%rdi) + movdqu %xmm0,32(%rdi) + movdqu %xmm0,48(%rdi) + movdqu %xmm0,64(%rdi) + movdqu %xmm0,80(%rdi) + jmp .Ladd_doneq + +.align 32 +.Ladd_doubleq: +.byte 102,72,15,126,206 +.byte 102,72,15,126,199 + addq $416,%rsp +.cfi_adjust_cfa_offset -416 + jmp .Lpoint_double_shortcutq +.cfi_adjust_cfa_offset 416 + +.align 32 +.Ladd_proceedq: + movq 0+64(%rsp),%rax + movq 8+64(%rsp),%r14 + leaq 0+64(%rsp),%rsi + movq 16+64(%rsp),%r15 + movq 24+64(%rsp),%r8 + leaq 96(%rsp),%rdi + call __ecp_nistz256_sqr_montq + + movq 448(%rsp),%rax + leaq 448(%rsp),%rbx + movq 0+0(%rsp),%r9 + movq 8+0(%rsp),%r10 + leaq 0+0(%rsp),%rsi + movq 16+0(%rsp),%r11 + movq 24+0(%rsp),%r12 + leaq 352(%rsp),%rdi + call __ecp_nistz256_mul_montq + + movq 0+0(%rsp),%rax + movq 8+0(%rsp),%r14 + leaq 0+0(%rsp),%rsi + movq 16+0(%rsp),%r15 + movq 24+0(%rsp),%r8 + leaq 32(%rsp),%rdi + call __ecp_nistz256_sqr_montq + + movq 544(%rsp),%rax + leaq 544(%rsp),%rbx + movq 0+352(%rsp),%r9 + movq 8+352(%rsp),%r10 + leaq 0+352(%rsp),%rsi + movq 16+352(%rsp),%r11 + movq 24+352(%rsp),%r12 + leaq 352(%rsp),%rdi + call __ecp_nistz256_mul_montq + + movq 0(%rsp),%rax + leaq 0(%rsp),%rbx + movq 0+32(%rsp),%r9 + movq 8+32(%rsp),%r10 + leaq 0+32(%rsp),%rsi + movq 16+32(%rsp),%r11 + movq 24+32(%rsp),%r12 + leaq 128(%rsp),%rdi + call __ecp_nistz256_mul_montq + + movq 160(%rsp),%rax + leaq 160(%rsp),%rbx + movq 0+32(%rsp),%r9 + movq 8+32(%rsp),%r10 + leaq 0+32(%rsp),%rsi + movq 16+32(%rsp),%r11 + movq 24+32(%rsp),%r12 + leaq 192(%rsp),%rdi + call __ecp_nistz256_mul_montq + + + + + xorq %r11,%r11 + addq %r12,%r12 + leaq 96(%rsp),%rsi + adcq %r13,%r13 + movq %r12,%rax + adcq %r8,%r8 + adcq %r9,%r9 + movq %r13,%rbp + adcq $0,%r11 + + subq $-1,%r12 + movq %r8,%rcx + sbbq %r14,%r13 + sbbq $0,%r8 + movq %r9,%r10 + sbbq %r15,%r9 + sbbq $0,%r11 + + cmovcq %rax,%r12 + movq 0(%rsi),%rax + cmovcq %rbp,%r13 + movq 8(%rsi),%rbp + cmovcq %rcx,%r8 + movq 16(%rsi),%rcx + cmovcq %r10,%r9 + movq 24(%rsi),%r10 + + call __ecp_nistz256_subq + + leaq 128(%rsp),%rbx + leaq 288(%rsp),%rdi + call __ecp_nistz256_sub_fromq + + movq 192+0(%rsp),%rax + movq 192+8(%rsp),%rbp + movq 192+16(%rsp),%rcx + movq 192+24(%rsp),%r10 + leaq 320(%rsp),%rdi + + call __ecp_nistz256_subq + + movq %r12,0(%rdi) + movq %r13,8(%rdi) + movq %r8,16(%rdi) + movq %r9,24(%rdi) + movq 128(%rsp),%rax + leaq 128(%rsp),%rbx + movq 0+224(%rsp),%r9 + movq 8+224(%rsp),%r10 + leaq 0+224(%rsp),%rsi + movq 16+224(%rsp),%r11 + movq 24+224(%rsp),%r12 + leaq 256(%rsp),%rdi + call __ecp_nistz256_mul_montq + + movq 320(%rsp),%rax + leaq 320(%rsp),%rbx + movq 0+64(%rsp),%r9 + movq 8+64(%rsp),%r10 + leaq 0+64(%rsp),%rsi + movq 16+64(%rsp),%r11 + movq 24+64(%rsp),%r12 + leaq 320(%rsp),%rdi + call __ecp_nistz256_mul_montq + + leaq 256(%rsp),%rbx + leaq 320(%rsp),%rdi + call __ecp_nistz256_sub_fromq + +.byte 102,72,15,126,199 + + movdqa %xmm5,%xmm0 + movdqa %xmm5,%xmm1 + pandn 352(%rsp),%xmm0 + movdqa %xmm5,%xmm2 + pandn 352+16(%rsp),%xmm1 + movdqa %xmm5,%xmm3 + pand 544(%rsp),%xmm2 + pand 544+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + + movdqa %xmm4,%xmm0 + movdqa %xmm4,%xmm1 + pandn %xmm2,%xmm0 + movdqa %xmm4,%xmm2 + pandn %xmm3,%xmm1 + movdqa %xmm4,%xmm3 + pand 448(%rsp),%xmm2 + pand 448+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + movdqu %xmm2,64(%rdi) + movdqu %xmm3,80(%rdi) + + movdqa %xmm5,%xmm0 + movdqa %xmm5,%xmm1 + pandn 288(%rsp),%xmm0 + movdqa %xmm5,%xmm2 + pandn 288+16(%rsp),%xmm1 + movdqa %xmm5,%xmm3 + pand 480(%rsp),%xmm2 + pand 480+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + + movdqa %xmm4,%xmm0 + movdqa %xmm4,%xmm1 + pandn %xmm2,%xmm0 + movdqa %xmm4,%xmm2 + pandn %xmm3,%xmm1 + movdqa %xmm4,%xmm3 + pand 384(%rsp),%xmm2 + pand 384+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + movdqu %xmm2,0(%rdi) + movdqu %xmm3,16(%rdi) + + movdqa %xmm5,%xmm0 + movdqa %xmm5,%xmm1 + pandn 320(%rsp),%xmm0 + movdqa %xmm5,%xmm2 + pandn 320+16(%rsp),%xmm1 + movdqa %xmm5,%xmm3 + pand 512(%rsp),%xmm2 + pand 512+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + + movdqa %xmm4,%xmm0 + movdqa %xmm4,%xmm1 + pandn %xmm2,%xmm0 + movdqa %xmm4,%xmm2 + pandn %xmm3,%xmm1 + movdqa %xmm4,%xmm3 + pand 416(%rsp),%xmm2 + pand 416+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + movdqu %xmm2,32(%rdi) + movdqu %xmm3,48(%rdi) + +.Ladd_doneq: + leaq 576+56(%rsp),%rsi +.cfi_def_cfa %rsi,8 + movq -48(%rsi),%r15 +.cfi_restore %r15 + movq -40(%rsi),%r14 +.cfi_restore %r14 + movq -32(%rsi),%r13 +.cfi_restore %r13 + movq -24(%rsi),%r12 +.cfi_restore %r12 + movq -16(%rsi),%rbx +.cfi_restore %rbx + movq -8(%rsi),%rbp +.cfi_restore %rbp + leaq (%rsi),%rsp +.cfi_def_cfa_register %rsp +.Lpoint_addq_epilogue: + ret +.cfi_endproc +.size ecp_nistz256_point_add_nohw,.-ecp_nistz256_point_add_nohw +.globl ecp_nistz256_point_add_affine_nohw +.hidden ecp_nistz256_point_add_affine_nohw +.type ecp_nistz256_point_add_affine_nohw,@function +.align 32 +ecp_nistz256_point_add_affine_nohw: +.cfi_startproc +_CET_ENDBR + pushq %rbp +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbp,-16 + pushq %rbx +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbx,-24 + pushq %r12 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r12,-32 + pushq %r13 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r13,-40 + pushq %r14 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r14,-48 + pushq %r15 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r15,-56 + subq $480+8,%rsp +.cfi_adjust_cfa_offset 32*15+8 +.Ladd_affineq_body: + + movdqu 0(%rsi),%xmm0 + movq %rdx,%rbx + movdqu 16(%rsi),%xmm1 + movdqu 32(%rsi),%xmm2 + movdqu 48(%rsi),%xmm3 + movdqu 64(%rsi),%xmm4 + movdqu 80(%rsi),%xmm5 + movq 64+0(%rsi),%rax + movq 64+8(%rsi),%r14 + movq 64+16(%rsi),%r15 + movq 64+24(%rsi),%r8 + movdqa %xmm0,320(%rsp) + movdqa %xmm1,320+16(%rsp) + movdqa %xmm2,352(%rsp) + movdqa %xmm3,352+16(%rsp) + movdqa %xmm4,384(%rsp) + movdqa %xmm5,384+16(%rsp) + por %xmm4,%xmm5 + + movdqu 0(%rbx),%xmm0 + pshufd $0xb1,%xmm5,%xmm3 + movdqu 16(%rbx),%xmm1 + movdqu 32(%rbx),%xmm2 + por %xmm3,%xmm5 + movdqu 48(%rbx),%xmm3 + movdqa %xmm0,416(%rsp) + pshufd $0x1e,%xmm5,%xmm4 + movdqa %xmm1,416+16(%rsp) + por %xmm0,%xmm1 +.byte 102,72,15,110,199 + movdqa %xmm2,448(%rsp) + movdqa %xmm3,448+16(%rsp) + por %xmm2,%xmm3 + por %xmm4,%xmm5 + pxor %xmm4,%xmm4 + por %xmm1,%xmm3 + + leaq 64-0(%rsi),%rsi + leaq 32(%rsp),%rdi + call __ecp_nistz256_sqr_montq + + pcmpeqd %xmm4,%xmm5 + pshufd $0xb1,%xmm3,%xmm4 + movq 0(%rbx),%rax + + movq %r12,%r9 + por %xmm3,%xmm4 + pshufd $0,%xmm5,%xmm5 + pshufd $0x1e,%xmm4,%xmm3 + movq %r13,%r10 + por %xmm3,%xmm4 + pxor %xmm3,%xmm3 + movq %r14,%r11 + pcmpeqd %xmm3,%xmm4 + pshufd $0,%xmm4,%xmm4 + + leaq 32-0(%rsp),%rsi + movq %r15,%r12 + leaq 0(%rsp),%rdi + call __ecp_nistz256_mul_montq + + leaq 320(%rsp),%rbx + leaq 64(%rsp),%rdi + call __ecp_nistz256_sub_fromq + + movq 384(%rsp),%rax + leaq 384(%rsp),%rbx + movq 0+32(%rsp),%r9 + movq 8+32(%rsp),%r10 + leaq 0+32(%rsp),%rsi + movq 16+32(%rsp),%r11 + movq 24+32(%rsp),%r12 + leaq 32(%rsp),%rdi + call __ecp_nistz256_mul_montq + + movq 384(%rsp),%rax + leaq 384(%rsp),%rbx + movq 0+64(%rsp),%r9 + movq 8+64(%rsp),%r10 + leaq 0+64(%rsp),%rsi + movq 16+64(%rsp),%r11 + movq 24+64(%rsp),%r12 + leaq 288(%rsp),%rdi + call __ecp_nistz256_mul_montq + + movq 448(%rsp),%rax + leaq 448(%rsp),%rbx + movq 0+32(%rsp),%r9 + movq 8+32(%rsp),%r10 + leaq 0+32(%rsp),%rsi + movq 16+32(%rsp),%r11 + movq 24+32(%rsp),%r12 + leaq 32(%rsp),%rdi + call __ecp_nistz256_mul_montq + + leaq 352(%rsp),%rbx + leaq 96(%rsp),%rdi + call __ecp_nistz256_sub_fromq + + movq 0+64(%rsp),%rax + movq 8+64(%rsp),%r14 + leaq 0+64(%rsp),%rsi + movq 16+64(%rsp),%r15 + movq 24+64(%rsp),%r8 + leaq 128(%rsp),%rdi + call __ecp_nistz256_sqr_montq + + movq 0+96(%rsp),%rax + movq 8+96(%rsp),%r14 + leaq 0+96(%rsp),%rsi + movq 16+96(%rsp),%r15 + movq 24+96(%rsp),%r8 + leaq 192(%rsp),%rdi + call __ecp_nistz256_sqr_montq + + movq 128(%rsp),%rax + leaq 128(%rsp),%rbx + movq 0+64(%rsp),%r9 + movq 8+64(%rsp),%r10 + leaq 0+64(%rsp),%rsi + movq 16+64(%rsp),%r11 + movq 24+64(%rsp),%r12 + leaq 160(%rsp),%rdi + call __ecp_nistz256_mul_montq + + movq 320(%rsp),%rax + leaq 320(%rsp),%rbx + movq 0+128(%rsp),%r9 + movq 8+128(%rsp),%r10 + leaq 0+128(%rsp),%rsi + movq 16+128(%rsp),%r11 + movq 24+128(%rsp),%r12 + leaq 0(%rsp),%rdi + call __ecp_nistz256_mul_montq + + + + + xorq %r11,%r11 + addq %r12,%r12 + leaq 192(%rsp),%rsi + adcq %r13,%r13 + movq %r12,%rax + adcq %r8,%r8 + adcq %r9,%r9 + movq %r13,%rbp + adcq $0,%r11 + + subq $-1,%r12 + movq %r8,%rcx + sbbq %r14,%r13 + sbbq $0,%r8 + movq %r9,%r10 + sbbq %r15,%r9 + sbbq $0,%r11 + + cmovcq %rax,%r12 + movq 0(%rsi),%rax + cmovcq %rbp,%r13 + movq 8(%rsi),%rbp + cmovcq %rcx,%r8 + movq 16(%rsi),%rcx + cmovcq %r10,%r9 + movq 24(%rsi),%r10 + + call __ecp_nistz256_subq + + leaq 160(%rsp),%rbx + leaq 224(%rsp),%rdi + call __ecp_nistz256_sub_fromq + + movq 0+0(%rsp),%rax + movq 0+8(%rsp),%rbp + movq 0+16(%rsp),%rcx + movq 0+24(%rsp),%r10 + leaq 64(%rsp),%rdi + + call __ecp_nistz256_subq + + movq %r12,0(%rdi) + movq %r13,8(%rdi) + movq %r8,16(%rdi) + movq %r9,24(%rdi) + movq 352(%rsp),%rax + leaq 352(%rsp),%rbx + movq 0+160(%rsp),%r9 + movq 8+160(%rsp),%r10 + leaq 0+160(%rsp),%rsi + movq 16+160(%rsp),%r11 + movq 24+160(%rsp),%r12 + leaq 32(%rsp),%rdi + call __ecp_nistz256_mul_montq + + movq 96(%rsp),%rax + leaq 96(%rsp),%rbx + movq 0+64(%rsp),%r9 + movq 8+64(%rsp),%r10 + leaq 0+64(%rsp),%rsi + movq 16+64(%rsp),%r11 + movq 24+64(%rsp),%r12 + leaq 64(%rsp),%rdi + call __ecp_nistz256_mul_montq + + leaq 32(%rsp),%rbx + leaq 256(%rsp),%rdi + call __ecp_nistz256_sub_fromq + +.byte 102,72,15,126,199 + + movdqa %xmm5,%xmm0 + movdqa %xmm5,%xmm1 + pandn 288(%rsp),%xmm0 + movdqa %xmm5,%xmm2 + pandn 288+16(%rsp),%xmm1 + movdqa %xmm5,%xmm3 + pand .LONE_mont(%rip),%xmm2 + pand .LONE_mont+16(%rip),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + + movdqa %xmm4,%xmm0 + movdqa %xmm4,%xmm1 + pandn %xmm2,%xmm0 + movdqa %xmm4,%xmm2 + pandn %xmm3,%xmm1 + movdqa %xmm4,%xmm3 + pand 384(%rsp),%xmm2 + pand 384+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + movdqu %xmm2,64(%rdi) + movdqu %xmm3,80(%rdi) + + movdqa %xmm5,%xmm0 + movdqa %xmm5,%xmm1 + pandn 224(%rsp),%xmm0 + movdqa %xmm5,%xmm2 + pandn 224+16(%rsp),%xmm1 + movdqa %xmm5,%xmm3 + pand 416(%rsp),%xmm2 + pand 416+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + + movdqa %xmm4,%xmm0 + movdqa %xmm4,%xmm1 + pandn %xmm2,%xmm0 + movdqa %xmm4,%xmm2 + pandn %xmm3,%xmm1 + movdqa %xmm4,%xmm3 + pand 320(%rsp),%xmm2 + pand 320+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + movdqu %xmm2,0(%rdi) + movdqu %xmm3,16(%rdi) + + movdqa %xmm5,%xmm0 + movdqa %xmm5,%xmm1 + pandn 256(%rsp),%xmm0 + movdqa %xmm5,%xmm2 + pandn 256+16(%rsp),%xmm1 + movdqa %xmm5,%xmm3 + pand 448(%rsp),%xmm2 + pand 448+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + + movdqa %xmm4,%xmm0 + movdqa %xmm4,%xmm1 + pandn %xmm2,%xmm0 + movdqa %xmm4,%xmm2 + pandn %xmm3,%xmm1 + movdqa %xmm4,%xmm3 + pand 352(%rsp),%xmm2 + pand 352+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + movdqu %xmm2,32(%rdi) + movdqu %xmm3,48(%rdi) + + leaq 480+56(%rsp),%rsi +.cfi_def_cfa %rsi,8 + movq -48(%rsi),%r15 +.cfi_restore %r15 + movq -40(%rsi),%r14 +.cfi_restore %r14 + movq -32(%rsi),%r13 +.cfi_restore %r13 + movq -24(%rsi),%r12 +.cfi_restore %r12 + movq -16(%rsi),%rbx +.cfi_restore %rbx + movq -8(%rsi),%rbp +.cfi_restore %rbp + leaq (%rsi),%rsp +.cfi_def_cfa_register %rsp +.Ladd_affineq_epilogue: + ret +.cfi_endproc +.size ecp_nistz256_point_add_affine_nohw,.-ecp_nistz256_point_add_affine_nohw +.type __ecp_nistz256_add_tox,@function +.align 32 +__ecp_nistz256_add_tox: +.cfi_startproc + xorq %r11,%r11 + adcq 0(%rbx),%r12 + adcq 8(%rbx),%r13 + movq %r12,%rax + adcq 16(%rbx),%r8 + adcq 24(%rbx),%r9 + movq %r13,%rbp + adcq $0,%r11 + + xorq %r10,%r10 + sbbq $-1,%r12 + movq %r8,%rcx + sbbq %r14,%r13 + sbbq $0,%r8 + movq %r9,%r10 + sbbq %r15,%r9 + sbbq $0,%r11 + + cmovcq %rax,%r12 + cmovcq %rbp,%r13 + movq %r12,0(%rdi) + cmovcq %rcx,%r8 + movq %r13,8(%rdi) + cmovcq %r10,%r9 + movq %r8,16(%rdi) + movq %r9,24(%rdi) + + ret +.cfi_endproc +.size __ecp_nistz256_add_tox,.-__ecp_nistz256_add_tox + +.type __ecp_nistz256_sub_fromx,@function +.align 32 +__ecp_nistz256_sub_fromx: +.cfi_startproc + xorq %r11,%r11 + sbbq 0(%rbx),%r12 + sbbq 8(%rbx),%r13 + movq %r12,%rax + sbbq 16(%rbx),%r8 + sbbq 24(%rbx),%r9 + movq %r13,%rbp + sbbq $0,%r11 + + xorq %r10,%r10 + adcq $-1,%r12 + movq %r8,%rcx + adcq %r14,%r13 + adcq $0,%r8 + movq %r9,%r10 + adcq %r15,%r9 + + btq $0,%r11 + cmovncq %rax,%r12 + cmovncq %rbp,%r13 + movq %r12,0(%rdi) + cmovncq %rcx,%r8 + movq %r13,8(%rdi) + cmovncq %r10,%r9 + movq %r8,16(%rdi) + movq %r9,24(%rdi) + + ret +.cfi_endproc +.size __ecp_nistz256_sub_fromx,.-__ecp_nistz256_sub_fromx + +.type __ecp_nistz256_subx,@function +.align 32 +__ecp_nistz256_subx: +.cfi_startproc + xorq %r11,%r11 + sbbq %r12,%rax + sbbq %r13,%rbp + movq %rax,%r12 + sbbq %r8,%rcx + sbbq %r9,%r10 + movq %rbp,%r13 + sbbq $0,%r11 + + xorq %r9,%r9 + adcq $-1,%rax + movq %rcx,%r8 + adcq %r14,%rbp + adcq $0,%rcx + movq %r10,%r9 + adcq %r15,%r10 + + btq $0,%r11 + cmovcq %rax,%r12 + cmovcq %rbp,%r13 + cmovcq %rcx,%r8 + cmovcq %r10,%r9 + + ret +.cfi_endproc +.size __ecp_nistz256_subx,.-__ecp_nistz256_subx + +.type __ecp_nistz256_mul_by_2x,@function +.align 32 +__ecp_nistz256_mul_by_2x: +.cfi_startproc + xorq %r11,%r11 + adcq %r12,%r12 + adcq %r13,%r13 + movq %r12,%rax + adcq %r8,%r8 + adcq %r9,%r9 + movq %r13,%rbp + adcq $0,%r11 + + xorq %r10,%r10 + sbbq $-1,%r12 + movq %r8,%rcx + sbbq %r14,%r13 + sbbq $0,%r8 + movq %r9,%r10 + sbbq %r15,%r9 + sbbq $0,%r11 + + cmovcq %rax,%r12 + cmovcq %rbp,%r13 + movq %r12,0(%rdi) + cmovcq %rcx,%r8 + movq %r13,8(%rdi) + cmovcq %r10,%r9 + movq %r8,16(%rdi) + movq %r9,24(%rdi) + + ret +.cfi_endproc +.size __ecp_nistz256_mul_by_2x,.-__ecp_nistz256_mul_by_2x +.globl ecp_nistz256_point_double_adx +.hidden ecp_nistz256_point_double_adx +.type ecp_nistz256_point_double_adx,@function +.align 32 +ecp_nistz256_point_double_adx: +.cfi_startproc +_CET_ENDBR + pushq %rbp +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbp,-16 + pushq %rbx +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbx,-24 + pushq %r12 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r12,-32 + pushq %r13 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r13,-40 + pushq %r14 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r14,-48 + pushq %r15 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r15,-56 + subq $160+8,%rsp +.cfi_adjust_cfa_offset 32*5+8 +.Lpoint_doublex_body: + +.Lpoint_double_shortcutx: + movdqu 0(%rsi),%xmm0 + movq %rsi,%rbx + movdqu 16(%rsi),%xmm1 + movq 32+0(%rsi),%r12 + movq 32+8(%rsi),%r13 + movq 32+16(%rsi),%r8 + movq 32+24(%rsi),%r9 + movq .Lpoly+8(%rip),%r14 + movq .Lpoly+24(%rip),%r15 + movdqa %xmm0,96(%rsp) + movdqa %xmm1,96+16(%rsp) + leaq 32(%rdi),%r10 + leaq 64(%rdi),%r11 +.byte 102,72,15,110,199 +.byte 102,73,15,110,202 +.byte 102,73,15,110,211 + + leaq 0(%rsp),%rdi + call __ecp_nistz256_mul_by_2x + + movq 64+0(%rsi),%rdx + movq 64+8(%rsi),%r14 + movq 64+16(%rsi),%r15 + movq 64+24(%rsi),%r8 + leaq 64-128(%rsi),%rsi + leaq 64(%rsp),%rdi + call __ecp_nistz256_sqr_montx + + movq 0+0(%rsp),%rdx + movq 8+0(%rsp),%r14 + leaq -128+0(%rsp),%rsi + movq 16+0(%rsp),%r15 + movq 24+0(%rsp),%r8 + leaq 0(%rsp),%rdi + call __ecp_nistz256_sqr_montx + + movq 32(%rbx),%rdx + movq 64+0(%rbx),%r9 + movq 64+8(%rbx),%r10 + movq 64+16(%rbx),%r11 + movq 64+24(%rbx),%r12 + leaq 64-128(%rbx),%rsi + leaq 32(%rbx),%rbx +.byte 102,72,15,126,215 + call __ecp_nistz256_mul_montx + call __ecp_nistz256_mul_by_2x + + movq 96+0(%rsp),%r12 + movq 96+8(%rsp),%r13 + leaq 64(%rsp),%rbx + movq 96+16(%rsp),%r8 + movq 96+24(%rsp),%r9 + leaq 32(%rsp),%rdi + call __ecp_nistz256_add_tox + + movq 96+0(%rsp),%r12 + movq 96+8(%rsp),%r13 + leaq 64(%rsp),%rbx + movq 96+16(%rsp),%r8 + movq 96+24(%rsp),%r9 + leaq 64(%rsp),%rdi + call __ecp_nistz256_sub_fromx + + movq 0+0(%rsp),%rdx + movq 8+0(%rsp),%r14 + leaq -128+0(%rsp),%rsi + movq 16+0(%rsp),%r15 + movq 24+0(%rsp),%r8 +.byte 102,72,15,126,207 + call __ecp_nistz256_sqr_montx + xorq %r9,%r9 + movq %r12,%rax + addq $-1,%r12 + movq %r13,%r10 + adcq %rsi,%r13 + movq %r14,%rcx + adcq $0,%r14 + movq %r15,%r8 + adcq %rbp,%r15 + adcq $0,%r9 + xorq %rsi,%rsi + testq $1,%rax + + cmovzq %rax,%r12 + cmovzq %r10,%r13 + cmovzq %rcx,%r14 + cmovzq %r8,%r15 + cmovzq %rsi,%r9 + + movq %r13,%rax + shrq $1,%r12 + shlq $63,%rax + movq %r14,%r10 + shrq $1,%r13 + orq %rax,%r12 + shlq $63,%r10 + movq %r15,%rcx + shrq $1,%r14 + orq %r10,%r13 + shlq $63,%rcx + movq %r12,0(%rdi) + shrq $1,%r15 + movq %r13,8(%rdi) + shlq $63,%r9 + orq %rcx,%r14 + orq %r9,%r15 + movq %r14,16(%rdi) + movq %r15,24(%rdi) + movq 64(%rsp),%rdx + leaq 64(%rsp),%rbx + movq 0+32(%rsp),%r9 + movq 8+32(%rsp),%r10 + leaq -128+32(%rsp),%rsi + movq 16+32(%rsp),%r11 + movq 24+32(%rsp),%r12 + leaq 32(%rsp),%rdi + call __ecp_nistz256_mul_montx + + leaq 128(%rsp),%rdi + call __ecp_nistz256_mul_by_2x + + leaq 32(%rsp),%rbx + leaq 32(%rsp),%rdi + call __ecp_nistz256_add_tox + + movq 96(%rsp),%rdx + leaq 96(%rsp),%rbx + movq 0+0(%rsp),%r9 + movq 8+0(%rsp),%r10 + leaq -128+0(%rsp),%rsi + movq 16+0(%rsp),%r11 + movq 24+0(%rsp),%r12 + leaq 0(%rsp),%rdi + call __ecp_nistz256_mul_montx + + leaq 128(%rsp),%rdi + call __ecp_nistz256_mul_by_2x + + movq 0+32(%rsp),%rdx + movq 8+32(%rsp),%r14 + leaq -128+32(%rsp),%rsi + movq 16+32(%rsp),%r15 + movq 24+32(%rsp),%r8 +.byte 102,72,15,126,199 + call __ecp_nistz256_sqr_montx + + leaq 128(%rsp),%rbx + movq %r14,%r8 + movq %r15,%r9 + movq %rsi,%r14 + movq %rbp,%r15 + call __ecp_nistz256_sub_fromx + + movq 0+0(%rsp),%rax + movq 0+8(%rsp),%rbp + movq 0+16(%rsp),%rcx + movq 0+24(%rsp),%r10 + leaq 0(%rsp),%rdi + call __ecp_nistz256_subx + + movq 32(%rsp),%rdx + leaq 32(%rsp),%rbx + movq %r12,%r14 + xorl %ecx,%ecx + movq %r12,0+0(%rsp) + movq %r13,%r10 + movq %r13,0+8(%rsp) + cmovzq %r8,%r11 + movq %r8,0+16(%rsp) + leaq 0-128(%rsp),%rsi + cmovzq %r9,%r12 + movq %r9,0+24(%rsp) + movq %r14,%r9 + leaq 0(%rsp),%rdi + call __ecp_nistz256_mul_montx + +.byte 102,72,15,126,203 +.byte 102,72,15,126,207 + call __ecp_nistz256_sub_fromx + + leaq 160+56(%rsp),%rsi +.cfi_def_cfa %rsi,8 + movq -48(%rsi),%r15 +.cfi_restore %r15 + movq -40(%rsi),%r14 +.cfi_restore %r14 + movq -32(%rsi),%r13 +.cfi_restore %r13 + movq -24(%rsi),%r12 +.cfi_restore %r12 + movq -16(%rsi),%rbx +.cfi_restore %rbx + movq -8(%rsi),%rbp +.cfi_restore %rbp + leaq (%rsi),%rsp +.cfi_def_cfa_register %rsp +.Lpoint_doublex_epilogue: + ret +.cfi_endproc +.size ecp_nistz256_point_double_adx,.-ecp_nistz256_point_double_adx +.globl ecp_nistz256_point_add_adx +.hidden ecp_nistz256_point_add_adx +.type ecp_nistz256_point_add_adx,@function +.align 32 +ecp_nistz256_point_add_adx: +.cfi_startproc +_CET_ENDBR + pushq %rbp +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbp,-16 + pushq %rbx +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbx,-24 + pushq %r12 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r12,-32 + pushq %r13 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r13,-40 + pushq %r14 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r14,-48 + pushq %r15 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r15,-56 + subq $576+8,%rsp +.cfi_adjust_cfa_offset 32*18+8 +.Lpoint_addx_body: + + movdqu 0(%rsi),%xmm0 + movdqu 16(%rsi),%xmm1 + movdqu 32(%rsi),%xmm2 + movdqu 48(%rsi),%xmm3 + movdqu 64(%rsi),%xmm4 + movdqu 80(%rsi),%xmm5 + movq %rsi,%rbx + movq %rdx,%rsi + movdqa %xmm0,384(%rsp) + movdqa %xmm1,384+16(%rsp) + movdqa %xmm2,416(%rsp) + movdqa %xmm3,416+16(%rsp) + movdqa %xmm4,448(%rsp) + movdqa %xmm5,448+16(%rsp) + por %xmm4,%xmm5 + + movdqu 0(%rsi),%xmm0 + pshufd $0xb1,%xmm5,%xmm3 + movdqu 16(%rsi),%xmm1 + movdqu 32(%rsi),%xmm2 + por %xmm3,%xmm5 + movdqu 48(%rsi),%xmm3 + movq 64+0(%rsi),%rdx + movq 64+8(%rsi),%r14 + movq 64+16(%rsi),%r15 + movq 64+24(%rsi),%r8 + movdqa %xmm0,480(%rsp) + pshufd $0x1e,%xmm5,%xmm4 + movdqa %xmm1,480+16(%rsp) + movdqu 64(%rsi),%xmm0 + movdqu 80(%rsi),%xmm1 + movdqa %xmm2,512(%rsp) + movdqa %xmm3,512+16(%rsp) + por %xmm4,%xmm5 + pxor %xmm4,%xmm4 + por %xmm0,%xmm1 +.byte 102,72,15,110,199 + + leaq 64-128(%rsi),%rsi + movq %rdx,544+0(%rsp) + movq %r14,544+8(%rsp) + movq %r15,544+16(%rsp) + movq %r8,544+24(%rsp) + leaq 96(%rsp),%rdi + call __ecp_nistz256_sqr_montx + + pcmpeqd %xmm4,%xmm5 + pshufd $0xb1,%xmm1,%xmm4 + por %xmm1,%xmm4 + pshufd $0,%xmm5,%xmm5 + pshufd $0x1e,%xmm4,%xmm3 + por %xmm3,%xmm4 + pxor %xmm3,%xmm3 + pcmpeqd %xmm3,%xmm4 + pshufd $0,%xmm4,%xmm4 + movq 64+0(%rbx),%rdx + movq 64+8(%rbx),%r14 + movq 64+16(%rbx),%r15 + movq 64+24(%rbx),%r8 +.byte 102,72,15,110,203 + + leaq 64-128(%rbx),%rsi + leaq 32(%rsp),%rdi + call __ecp_nistz256_sqr_montx + + movq 544(%rsp),%rdx + leaq 544(%rsp),%rbx + movq 0+96(%rsp),%r9 + movq 8+96(%rsp),%r10 + leaq -128+96(%rsp),%rsi + movq 16+96(%rsp),%r11 + movq 24+96(%rsp),%r12 + leaq 224(%rsp),%rdi + call __ecp_nistz256_mul_montx + + movq 448(%rsp),%rdx + leaq 448(%rsp),%rbx + movq 0+32(%rsp),%r9 + movq 8+32(%rsp),%r10 + leaq -128+32(%rsp),%rsi + movq 16+32(%rsp),%r11 + movq 24+32(%rsp),%r12 + leaq 256(%rsp),%rdi + call __ecp_nistz256_mul_montx + + movq 416(%rsp),%rdx + leaq 416(%rsp),%rbx + movq 0+224(%rsp),%r9 + movq 8+224(%rsp),%r10 + leaq -128+224(%rsp),%rsi + movq 16+224(%rsp),%r11 + movq 24+224(%rsp),%r12 + leaq 224(%rsp),%rdi + call __ecp_nistz256_mul_montx + + movq 512(%rsp),%rdx + leaq 512(%rsp),%rbx + movq 0+256(%rsp),%r9 + movq 8+256(%rsp),%r10 + leaq -128+256(%rsp),%rsi + movq 16+256(%rsp),%r11 + movq 24+256(%rsp),%r12 + leaq 256(%rsp),%rdi + call __ecp_nistz256_mul_montx + + leaq 224(%rsp),%rbx + leaq 64(%rsp),%rdi + call __ecp_nistz256_sub_fromx + + orq %r13,%r12 + movdqa %xmm4,%xmm2 + orq %r8,%r12 + orq %r9,%r12 + por %xmm5,%xmm2 +.byte 102,73,15,110,220 + + movq 384(%rsp),%rdx + leaq 384(%rsp),%rbx + movq 0+96(%rsp),%r9 + movq 8+96(%rsp),%r10 + leaq -128+96(%rsp),%rsi + movq 16+96(%rsp),%r11 + movq 24+96(%rsp),%r12 + leaq 160(%rsp),%rdi + call __ecp_nistz256_mul_montx + + movq 480(%rsp),%rdx + leaq 480(%rsp),%rbx + movq 0+32(%rsp),%r9 + movq 8+32(%rsp),%r10 + leaq -128+32(%rsp),%rsi + movq 16+32(%rsp),%r11 + movq 24+32(%rsp),%r12 + leaq 192(%rsp),%rdi + call __ecp_nistz256_mul_montx + + leaq 160(%rsp),%rbx + leaq 0(%rsp),%rdi + call __ecp_nistz256_sub_fromx + + orq %r13,%r12 + orq %r8,%r12 + orq %r9,%r12 + +.byte 102,73,15,126,208 +.byte 102,73,15,126,217 + orq %r8,%r12 +.byte 0x3e + jnz .Ladd_proceedx + + + + testq %r9,%r9 + jz .Ladd_doublex + + + + + + +.byte 102,72,15,126,199 + pxor %xmm0,%xmm0 + movdqu %xmm0,0(%rdi) + movdqu %xmm0,16(%rdi) + movdqu %xmm0,32(%rdi) + movdqu %xmm0,48(%rdi) + movdqu %xmm0,64(%rdi) + movdqu %xmm0,80(%rdi) + jmp .Ladd_donex + +.align 32 +.Ladd_doublex: +.byte 102,72,15,126,206 +.byte 102,72,15,126,199 + addq $416,%rsp +.cfi_adjust_cfa_offset -416 + jmp .Lpoint_double_shortcutx +.cfi_adjust_cfa_offset 416 + +.align 32 +.Ladd_proceedx: + movq 0+64(%rsp),%rdx + movq 8+64(%rsp),%r14 + leaq -128+64(%rsp),%rsi + movq 16+64(%rsp),%r15 + movq 24+64(%rsp),%r8 + leaq 96(%rsp),%rdi + call __ecp_nistz256_sqr_montx + + movq 448(%rsp),%rdx + leaq 448(%rsp),%rbx + movq 0+0(%rsp),%r9 + movq 8+0(%rsp),%r10 + leaq -128+0(%rsp),%rsi + movq 16+0(%rsp),%r11 + movq 24+0(%rsp),%r12 + leaq 352(%rsp),%rdi + call __ecp_nistz256_mul_montx + + movq 0+0(%rsp),%rdx + movq 8+0(%rsp),%r14 + leaq -128+0(%rsp),%rsi + movq 16+0(%rsp),%r15 + movq 24+0(%rsp),%r8 + leaq 32(%rsp),%rdi + call __ecp_nistz256_sqr_montx + + movq 544(%rsp),%rdx + leaq 544(%rsp),%rbx + movq 0+352(%rsp),%r9 + movq 8+352(%rsp),%r10 + leaq -128+352(%rsp),%rsi + movq 16+352(%rsp),%r11 + movq 24+352(%rsp),%r12 + leaq 352(%rsp),%rdi + call __ecp_nistz256_mul_montx + + movq 0(%rsp),%rdx + leaq 0(%rsp),%rbx + movq 0+32(%rsp),%r9 + movq 8+32(%rsp),%r10 + leaq -128+32(%rsp),%rsi + movq 16+32(%rsp),%r11 + movq 24+32(%rsp),%r12 + leaq 128(%rsp),%rdi + call __ecp_nistz256_mul_montx + + movq 160(%rsp),%rdx + leaq 160(%rsp),%rbx + movq 0+32(%rsp),%r9 + movq 8+32(%rsp),%r10 + leaq -128+32(%rsp),%rsi + movq 16+32(%rsp),%r11 + movq 24+32(%rsp),%r12 + leaq 192(%rsp),%rdi + call __ecp_nistz256_mul_montx + + + + + xorq %r11,%r11 + addq %r12,%r12 + leaq 96(%rsp),%rsi + adcq %r13,%r13 + movq %r12,%rax + adcq %r8,%r8 + adcq %r9,%r9 + movq %r13,%rbp + adcq $0,%r11 + + subq $-1,%r12 + movq %r8,%rcx + sbbq %r14,%r13 + sbbq $0,%r8 + movq %r9,%r10 + sbbq %r15,%r9 + sbbq $0,%r11 + + cmovcq %rax,%r12 + movq 0(%rsi),%rax + cmovcq %rbp,%r13 + movq 8(%rsi),%rbp + cmovcq %rcx,%r8 + movq 16(%rsi),%rcx + cmovcq %r10,%r9 + movq 24(%rsi),%r10 + + call __ecp_nistz256_subx + + leaq 128(%rsp),%rbx + leaq 288(%rsp),%rdi + call __ecp_nistz256_sub_fromx + + movq 192+0(%rsp),%rax + movq 192+8(%rsp),%rbp + movq 192+16(%rsp),%rcx + movq 192+24(%rsp),%r10 + leaq 320(%rsp),%rdi + + call __ecp_nistz256_subx + + movq %r12,0(%rdi) + movq %r13,8(%rdi) + movq %r8,16(%rdi) + movq %r9,24(%rdi) + movq 128(%rsp),%rdx + leaq 128(%rsp),%rbx + movq 0+224(%rsp),%r9 + movq 8+224(%rsp),%r10 + leaq -128+224(%rsp),%rsi + movq 16+224(%rsp),%r11 + movq 24+224(%rsp),%r12 + leaq 256(%rsp),%rdi + call __ecp_nistz256_mul_montx + + movq 320(%rsp),%rdx + leaq 320(%rsp),%rbx + movq 0+64(%rsp),%r9 + movq 8+64(%rsp),%r10 + leaq -128+64(%rsp),%rsi + movq 16+64(%rsp),%r11 + movq 24+64(%rsp),%r12 + leaq 320(%rsp),%rdi + call __ecp_nistz256_mul_montx + + leaq 256(%rsp),%rbx + leaq 320(%rsp),%rdi + call __ecp_nistz256_sub_fromx + +.byte 102,72,15,126,199 + + movdqa %xmm5,%xmm0 + movdqa %xmm5,%xmm1 + pandn 352(%rsp),%xmm0 + movdqa %xmm5,%xmm2 + pandn 352+16(%rsp),%xmm1 + movdqa %xmm5,%xmm3 + pand 544(%rsp),%xmm2 + pand 544+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + + movdqa %xmm4,%xmm0 + movdqa %xmm4,%xmm1 + pandn %xmm2,%xmm0 + movdqa %xmm4,%xmm2 + pandn %xmm3,%xmm1 + movdqa %xmm4,%xmm3 + pand 448(%rsp),%xmm2 + pand 448+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + movdqu %xmm2,64(%rdi) + movdqu %xmm3,80(%rdi) + + movdqa %xmm5,%xmm0 + movdqa %xmm5,%xmm1 + pandn 288(%rsp),%xmm0 + movdqa %xmm5,%xmm2 + pandn 288+16(%rsp),%xmm1 + movdqa %xmm5,%xmm3 + pand 480(%rsp),%xmm2 + pand 480+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + + movdqa %xmm4,%xmm0 + movdqa %xmm4,%xmm1 + pandn %xmm2,%xmm0 + movdqa %xmm4,%xmm2 + pandn %xmm3,%xmm1 + movdqa %xmm4,%xmm3 + pand 384(%rsp),%xmm2 + pand 384+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + movdqu %xmm2,0(%rdi) + movdqu %xmm3,16(%rdi) + + movdqa %xmm5,%xmm0 + movdqa %xmm5,%xmm1 + pandn 320(%rsp),%xmm0 + movdqa %xmm5,%xmm2 + pandn 320+16(%rsp),%xmm1 + movdqa %xmm5,%xmm3 + pand 512(%rsp),%xmm2 + pand 512+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + + movdqa %xmm4,%xmm0 + movdqa %xmm4,%xmm1 + pandn %xmm2,%xmm0 + movdqa %xmm4,%xmm2 + pandn %xmm3,%xmm1 + movdqa %xmm4,%xmm3 + pand 416(%rsp),%xmm2 + pand 416+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + movdqu %xmm2,32(%rdi) + movdqu %xmm3,48(%rdi) + +.Ladd_donex: + leaq 576+56(%rsp),%rsi +.cfi_def_cfa %rsi,8 + movq -48(%rsi),%r15 +.cfi_restore %r15 + movq -40(%rsi),%r14 +.cfi_restore %r14 + movq -32(%rsi),%r13 +.cfi_restore %r13 + movq -24(%rsi),%r12 +.cfi_restore %r12 + movq -16(%rsi),%rbx +.cfi_restore %rbx + movq -8(%rsi),%rbp +.cfi_restore %rbp + leaq (%rsi),%rsp +.cfi_def_cfa_register %rsp +.Lpoint_addx_epilogue: + ret +.cfi_endproc +.size ecp_nistz256_point_add_adx,.-ecp_nistz256_point_add_adx +.globl ecp_nistz256_point_add_affine_adx +.hidden ecp_nistz256_point_add_affine_adx +.type ecp_nistz256_point_add_affine_adx,@function +.align 32 +ecp_nistz256_point_add_affine_adx: +.cfi_startproc +_CET_ENDBR + pushq %rbp +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbp,-16 + pushq %rbx +.cfi_adjust_cfa_offset 8 +.cfi_offset %rbx,-24 + pushq %r12 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r12,-32 + pushq %r13 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r13,-40 + pushq %r14 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r14,-48 + pushq %r15 +.cfi_adjust_cfa_offset 8 +.cfi_offset %r15,-56 + subq $480+8,%rsp +.cfi_adjust_cfa_offset 32*15+8 +.Ladd_affinex_body: + + movdqu 0(%rsi),%xmm0 + movq %rdx,%rbx + movdqu 16(%rsi),%xmm1 + movdqu 32(%rsi),%xmm2 + movdqu 48(%rsi),%xmm3 + movdqu 64(%rsi),%xmm4 + movdqu 80(%rsi),%xmm5 + movq 64+0(%rsi),%rdx + movq 64+8(%rsi),%r14 + movq 64+16(%rsi),%r15 + movq 64+24(%rsi),%r8 + movdqa %xmm0,320(%rsp) + movdqa %xmm1,320+16(%rsp) + movdqa %xmm2,352(%rsp) + movdqa %xmm3,352+16(%rsp) + movdqa %xmm4,384(%rsp) + movdqa %xmm5,384+16(%rsp) + por %xmm4,%xmm5 + + movdqu 0(%rbx),%xmm0 + pshufd $0xb1,%xmm5,%xmm3 + movdqu 16(%rbx),%xmm1 + movdqu 32(%rbx),%xmm2 + por %xmm3,%xmm5 + movdqu 48(%rbx),%xmm3 + movdqa %xmm0,416(%rsp) + pshufd $0x1e,%xmm5,%xmm4 + movdqa %xmm1,416+16(%rsp) + por %xmm0,%xmm1 +.byte 102,72,15,110,199 + movdqa %xmm2,448(%rsp) + movdqa %xmm3,448+16(%rsp) + por %xmm2,%xmm3 + por %xmm4,%xmm5 + pxor %xmm4,%xmm4 + por %xmm1,%xmm3 + + leaq 64-128(%rsi),%rsi + leaq 32(%rsp),%rdi + call __ecp_nistz256_sqr_montx + + pcmpeqd %xmm4,%xmm5 + pshufd $0xb1,%xmm3,%xmm4 + movq 0(%rbx),%rdx + + movq %r12,%r9 + por %xmm3,%xmm4 + pshufd $0,%xmm5,%xmm5 + pshufd $0x1e,%xmm4,%xmm3 + movq %r13,%r10 + por %xmm3,%xmm4 + pxor %xmm3,%xmm3 + movq %r14,%r11 + pcmpeqd %xmm3,%xmm4 + pshufd $0,%xmm4,%xmm4 + + leaq 32-128(%rsp),%rsi + movq %r15,%r12 + leaq 0(%rsp),%rdi + call __ecp_nistz256_mul_montx + + leaq 320(%rsp),%rbx + leaq 64(%rsp),%rdi + call __ecp_nistz256_sub_fromx + + movq 384(%rsp),%rdx + leaq 384(%rsp),%rbx + movq 0+32(%rsp),%r9 + movq 8+32(%rsp),%r10 + leaq -128+32(%rsp),%rsi + movq 16+32(%rsp),%r11 + movq 24+32(%rsp),%r12 + leaq 32(%rsp),%rdi + call __ecp_nistz256_mul_montx + + movq 384(%rsp),%rdx + leaq 384(%rsp),%rbx + movq 0+64(%rsp),%r9 + movq 8+64(%rsp),%r10 + leaq -128+64(%rsp),%rsi + movq 16+64(%rsp),%r11 + movq 24+64(%rsp),%r12 + leaq 288(%rsp),%rdi + call __ecp_nistz256_mul_montx + + movq 448(%rsp),%rdx + leaq 448(%rsp),%rbx + movq 0+32(%rsp),%r9 + movq 8+32(%rsp),%r10 + leaq -128+32(%rsp),%rsi + movq 16+32(%rsp),%r11 + movq 24+32(%rsp),%r12 + leaq 32(%rsp),%rdi + call __ecp_nistz256_mul_montx + + leaq 352(%rsp),%rbx + leaq 96(%rsp),%rdi + call __ecp_nistz256_sub_fromx + + movq 0+64(%rsp),%rdx + movq 8+64(%rsp),%r14 + leaq -128+64(%rsp),%rsi + movq 16+64(%rsp),%r15 + movq 24+64(%rsp),%r8 + leaq 128(%rsp),%rdi + call __ecp_nistz256_sqr_montx + + movq 0+96(%rsp),%rdx + movq 8+96(%rsp),%r14 + leaq -128+96(%rsp),%rsi + movq 16+96(%rsp),%r15 + movq 24+96(%rsp),%r8 + leaq 192(%rsp),%rdi + call __ecp_nistz256_sqr_montx + + movq 128(%rsp),%rdx + leaq 128(%rsp),%rbx + movq 0+64(%rsp),%r9 + movq 8+64(%rsp),%r10 + leaq -128+64(%rsp),%rsi + movq 16+64(%rsp),%r11 + movq 24+64(%rsp),%r12 + leaq 160(%rsp),%rdi + call __ecp_nistz256_mul_montx + + movq 320(%rsp),%rdx + leaq 320(%rsp),%rbx + movq 0+128(%rsp),%r9 + movq 8+128(%rsp),%r10 + leaq -128+128(%rsp),%rsi + movq 16+128(%rsp),%r11 + movq 24+128(%rsp),%r12 + leaq 0(%rsp),%rdi + call __ecp_nistz256_mul_montx + + + + + xorq %r11,%r11 + addq %r12,%r12 + leaq 192(%rsp),%rsi + adcq %r13,%r13 + movq %r12,%rax + adcq %r8,%r8 + adcq %r9,%r9 + movq %r13,%rbp + adcq $0,%r11 + + subq $-1,%r12 + movq %r8,%rcx + sbbq %r14,%r13 + sbbq $0,%r8 + movq %r9,%r10 + sbbq %r15,%r9 + sbbq $0,%r11 + + cmovcq %rax,%r12 + movq 0(%rsi),%rax + cmovcq %rbp,%r13 + movq 8(%rsi),%rbp + cmovcq %rcx,%r8 + movq 16(%rsi),%rcx + cmovcq %r10,%r9 + movq 24(%rsi),%r10 + + call __ecp_nistz256_subx + + leaq 160(%rsp),%rbx + leaq 224(%rsp),%rdi + call __ecp_nistz256_sub_fromx + + movq 0+0(%rsp),%rax + movq 0+8(%rsp),%rbp + movq 0+16(%rsp),%rcx + movq 0+24(%rsp),%r10 + leaq 64(%rsp),%rdi + + call __ecp_nistz256_subx + + movq %r12,0(%rdi) + movq %r13,8(%rdi) + movq %r8,16(%rdi) + movq %r9,24(%rdi) + movq 352(%rsp),%rdx + leaq 352(%rsp),%rbx + movq 0+160(%rsp),%r9 + movq 8+160(%rsp),%r10 + leaq -128+160(%rsp),%rsi + movq 16+160(%rsp),%r11 + movq 24+160(%rsp),%r12 + leaq 32(%rsp),%rdi + call __ecp_nistz256_mul_montx + + movq 96(%rsp),%rdx + leaq 96(%rsp),%rbx + movq 0+64(%rsp),%r9 + movq 8+64(%rsp),%r10 + leaq -128+64(%rsp),%rsi + movq 16+64(%rsp),%r11 + movq 24+64(%rsp),%r12 + leaq 64(%rsp),%rdi + call __ecp_nistz256_mul_montx + + leaq 32(%rsp),%rbx + leaq 256(%rsp),%rdi + call __ecp_nistz256_sub_fromx + +.byte 102,72,15,126,199 + + movdqa %xmm5,%xmm0 + movdqa %xmm5,%xmm1 + pandn 288(%rsp),%xmm0 + movdqa %xmm5,%xmm2 + pandn 288+16(%rsp),%xmm1 + movdqa %xmm5,%xmm3 + pand .LONE_mont(%rip),%xmm2 + pand .LONE_mont+16(%rip),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + + movdqa %xmm4,%xmm0 + movdqa %xmm4,%xmm1 + pandn %xmm2,%xmm0 + movdqa %xmm4,%xmm2 + pandn %xmm3,%xmm1 + movdqa %xmm4,%xmm3 + pand 384(%rsp),%xmm2 + pand 384+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + movdqu %xmm2,64(%rdi) + movdqu %xmm3,80(%rdi) + + movdqa %xmm5,%xmm0 + movdqa %xmm5,%xmm1 + pandn 224(%rsp),%xmm0 + movdqa %xmm5,%xmm2 + pandn 224+16(%rsp),%xmm1 + movdqa %xmm5,%xmm3 + pand 416(%rsp),%xmm2 + pand 416+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + + movdqa %xmm4,%xmm0 + movdqa %xmm4,%xmm1 + pandn %xmm2,%xmm0 + movdqa %xmm4,%xmm2 + pandn %xmm3,%xmm1 + movdqa %xmm4,%xmm3 + pand 320(%rsp),%xmm2 + pand 320+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + movdqu %xmm2,0(%rdi) + movdqu %xmm3,16(%rdi) + + movdqa %xmm5,%xmm0 + movdqa %xmm5,%xmm1 + pandn 256(%rsp),%xmm0 + movdqa %xmm5,%xmm2 + pandn 256+16(%rsp),%xmm1 + movdqa %xmm5,%xmm3 + pand 448(%rsp),%xmm2 + pand 448+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + + movdqa %xmm4,%xmm0 + movdqa %xmm4,%xmm1 + pandn %xmm2,%xmm0 + movdqa %xmm4,%xmm2 + pandn %xmm3,%xmm1 + movdqa %xmm4,%xmm3 + pand 352(%rsp),%xmm2 + pand 352+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + movdqu %xmm2,32(%rdi) + movdqu %xmm3,48(%rdi) + + leaq 480+56(%rsp),%rsi +.cfi_def_cfa %rsi,8 + movq -48(%rsi),%r15 +.cfi_restore %r15 + movq -40(%rsi),%r14 +.cfi_restore %r14 + movq -32(%rsi),%r13 +.cfi_restore %r13 + movq -24(%rsi),%r12 +.cfi_restore %r12 + movq -16(%rsi),%rbx +.cfi_restore %rbx + movq -8(%rsi),%rbp +.cfi_restore %rbp + leaq (%rsi),%rsp +.cfi_def_cfa_register %rsp +.Ladd_affinex_epilogue: + ret +.cfi_endproc +.size ecp_nistz256_point_add_affine_adx,.-ecp_nistz256_point_add_affine_adx +#endif diff --git a/http/vendor/ring/pregenerated/p256-x86_64-asm-macosx.S b/http/vendor/ring/pregenerated/p256-x86_64-asm-macosx.S new file mode 100644 index 0000000..035c37f --- /dev/null +++ b/http/vendor/ring/pregenerated/p256-x86_64-asm-macosx.S @@ -0,0 +1,4513 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__) +.text + + +.section __DATA,__const +.p2align 6 +L$poly: +.quad 0xffffffffffffffff, 0x00000000ffffffff, 0x0000000000000000, 0xffffffff00000001 + +L$One: +.long 1,1,1,1,1,1,1,1 +L$Two: +.long 2,2,2,2,2,2,2,2 +L$Three: +.long 3,3,3,3,3,3,3,3 +L$ONE_mont: +.quad 0x0000000000000001, 0xffffffff00000000, 0xffffffffffffffff, 0x00000000fffffffe + + +L$ord: +.quad 0xf3b9cac2fc632551, 0xbce6faada7179e84, 0xffffffffffffffff, 0xffffffff00000000 +L$ordK: +.quad 0xccd1c8aaee00bc4f +.text + + + +.globl _ecp_nistz256_neg +.private_extern _ecp_nistz256_neg + +.p2align 5 +_ecp_nistz256_neg: + +_CET_ENDBR + pushq %r12 + + pushq %r13 + +L$neg_body: + + xorq %r8,%r8 + xorq %r9,%r9 + xorq %r10,%r10 + xorq %r11,%r11 + xorq %r13,%r13 + + subq 0(%rsi),%r8 + sbbq 8(%rsi),%r9 + sbbq 16(%rsi),%r10 + movq %r8,%rax + sbbq 24(%rsi),%r11 + leaq L$poly(%rip),%rsi + movq %r9,%rdx + sbbq $0,%r13 + + addq 0(%rsi),%r8 + movq %r10,%rcx + adcq 8(%rsi),%r9 + adcq 16(%rsi),%r10 + movq %r11,%r12 + adcq 24(%rsi),%r11 + testq %r13,%r13 + + cmovzq %rax,%r8 + cmovzq %rdx,%r9 + movq %r8,0(%rdi) + cmovzq %rcx,%r10 + movq %r9,8(%rdi) + cmovzq %r12,%r11 + movq %r10,16(%rdi) + movq %r11,24(%rdi) + + movq 0(%rsp),%r13 + + movq 8(%rsp),%r12 + + leaq 16(%rsp),%rsp + +L$neg_epilogue: + ret + + + + + + + + +.globl _ecp_nistz256_ord_mul_mont_nohw +.private_extern _ecp_nistz256_ord_mul_mont_nohw + +.p2align 5 +_ecp_nistz256_ord_mul_mont_nohw: + +_CET_ENDBR + pushq %rbp + + pushq %rbx + + pushq %r12 + + pushq %r13 + + pushq %r14 + + pushq %r15 + +L$ord_mul_body: + + movq 0(%rdx),%rax + movq %rdx,%rbx + leaq L$ord(%rip),%r14 + movq L$ordK(%rip),%r15 + + + movq %rax,%rcx + mulq 0(%rsi) + movq %rax,%r8 + movq %rcx,%rax + movq %rdx,%r9 + + mulq 8(%rsi) + addq %rax,%r9 + movq %rcx,%rax + adcq $0,%rdx + movq %rdx,%r10 + + mulq 16(%rsi) + addq %rax,%r10 + movq %rcx,%rax + adcq $0,%rdx + + movq %r8,%r13 + imulq %r15,%r8 + + movq %rdx,%r11 + mulq 24(%rsi) + addq %rax,%r11 + movq %r8,%rax + adcq $0,%rdx + movq %rdx,%r12 + + + mulq 0(%r14) + movq %r8,%rbp + addq %rax,%r13 + movq %r8,%rax + adcq $0,%rdx + movq %rdx,%rcx + + subq %r8,%r10 + sbbq $0,%r8 + + mulq 8(%r14) + addq %rcx,%r9 + adcq $0,%rdx + addq %rax,%r9 + movq %rbp,%rax + adcq %rdx,%r10 + movq %rbp,%rdx + adcq $0,%r8 + + shlq $32,%rax + shrq $32,%rdx + subq %rax,%r11 + movq 8(%rbx),%rax + sbbq %rdx,%rbp + + addq %r8,%r11 + adcq %rbp,%r12 + adcq $0,%r13 + + + movq %rax,%rcx + mulq 0(%rsi) + addq %rax,%r9 + movq %rcx,%rax + adcq $0,%rdx + movq %rdx,%rbp + + mulq 8(%rsi) + addq %rbp,%r10 + adcq $0,%rdx + addq %rax,%r10 + movq %rcx,%rax + adcq $0,%rdx + movq %rdx,%rbp + + mulq 16(%rsi) + addq %rbp,%r11 + adcq $0,%rdx + addq %rax,%r11 + movq %rcx,%rax + adcq $0,%rdx + + movq %r9,%rcx + imulq %r15,%r9 + + movq %rdx,%rbp + mulq 24(%rsi) + addq %rbp,%r12 + adcq $0,%rdx + xorq %r8,%r8 + addq %rax,%r12 + movq %r9,%rax + adcq %rdx,%r13 + adcq $0,%r8 + + + mulq 0(%r14) + movq %r9,%rbp + addq %rax,%rcx + movq %r9,%rax + adcq %rdx,%rcx + + subq %r9,%r11 + sbbq $0,%r9 + + mulq 8(%r14) + addq %rcx,%r10 + adcq $0,%rdx + addq %rax,%r10 + movq %rbp,%rax + adcq %rdx,%r11 + movq %rbp,%rdx + adcq $0,%r9 + + shlq $32,%rax + shrq $32,%rdx + subq %rax,%r12 + movq 16(%rbx),%rax + sbbq %rdx,%rbp + + addq %r9,%r12 + adcq %rbp,%r13 + adcq $0,%r8 + + + movq %rax,%rcx + mulq 0(%rsi) + addq %rax,%r10 + movq %rcx,%rax + adcq $0,%rdx + movq %rdx,%rbp + + mulq 8(%rsi) + addq %rbp,%r11 + adcq $0,%rdx + addq %rax,%r11 + movq %rcx,%rax + adcq $0,%rdx + movq %rdx,%rbp + + mulq 16(%rsi) + addq %rbp,%r12 + adcq $0,%rdx + addq %rax,%r12 + movq %rcx,%rax + adcq $0,%rdx + + movq %r10,%rcx + imulq %r15,%r10 + + movq %rdx,%rbp + mulq 24(%rsi) + addq %rbp,%r13 + adcq $0,%rdx + xorq %r9,%r9 + addq %rax,%r13 + movq %r10,%rax + adcq %rdx,%r8 + adcq $0,%r9 + + + mulq 0(%r14) + movq %r10,%rbp + addq %rax,%rcx + movq %r10,%rax + adcq %rdx,%rcx + + subq %r10,%r12 + sbbq $0,%r10 + + mulq 8(%r14) + addq %rcx,%r11 + adcq $0,%rdx + addq %rax,%r11 + movq %rbp,%rax + adcq %rdx,%r12 + movq %rbp,%rdx + adcq $0,%r10 + + shlq $32,%rax + shrq $32,%rdx + subq %rax,%r13 + movq 24(%rbx),%rax + sbbq %rdx,%rbp + + addq %r10,%r13 + adcq %rbp,%r8 + adcq $0,%r9 + + + movq %rax,%rcx + mulq 0(%rsi) + addq %rax,%r11 + movq %rcx,%rax + adcq $0,%rdx + movq %rdx,%rbp + + mulq 8(%rsi) + addq %rbp,%r12 + adcq $0,%rdx + addq %rax,%r12 + movq %rcx,%rax + adcq $0,%rdx + movq %rdx,%rbp + + mulq 16(%rsi) + addq %rbp,%r13 + adcq $0,%rdx + addq %rax,%r13 + movq %rcx,%rax + adcq $0,%rdx + + movq %r11,%rcx + imulq %r15,%r11 + + movq %rdx,%rbp + mulq 24(%rsi) + addq %rbp,%r8 + adcq $0,%rdx + xorq %r10,%r10 + addq %rax,%r8 + movq %r11,%rax + adcq %rdx,%r9 + adcq $0,%r10 + + + mulq 0(%r14) + movq %r11,%rbp + addq %rax,%rcx + movq %r11,%rax + adcq %rdx,%rcx + + subq %r11,%r13 + sbbq $0,%r11 + + mulq 8(%r14) + addq %rcx,%r12 + adcq $0,%rdx + addq %rax,%r12 + movq %rbp,%rax + adcq %rdx,%r13 + movq %rbp,%rdx + adcq $0,%r11 + + shlq $32,%rax + shrq $32,%rdx + subq %rax,%r8 + sbbq %rdx,%rbp + + addq %r11,%r8 + adcq %rbp,%r9 + adcq $0,%r10 + + + movq %r12,%rsi + subq 0(%r14),%r12 + movq %r13,%r11 + sbbq 8(%r14),%r13 + movq %r8,%rcx + sbbq 16(%r14),%r8 + movq %r9,%rbp + sbbq 24(%r14),%r9 + sbbq $0,%r10 + + cmovcq %rsi,%r12 + cmovcq %r11,%r13 + cmovcq %rcx,%r8 + cmovcq %rbp,%r9 + + movq %r12,0(%rdi) + movq %r13,8(%rdi) + movq %r8,16(%rdi) + movq %r9,24(%rdi) + + movq 0(%rsp),%r15 + + movq 8(%rsp),%r14 + + movq 16(%rsp),%r13 + + movq 24(%rsp),%r12 + + movq 32(%rsp),%rbx + + movq 40(%rsp),%rbp + + leaq 48(%rsp),%rsp + +L$ord_mul_epilogue: + ret + + + + + + + + + +.globl _ecp_nistz256_ord_sqr_mont_nohw +.private_extern _ecp_nistz256_ord_sqr_mont_nohw + +.p2align 5 +_ecp_nistz256_ord_sqr_mont_nohw: + +_CET_ENDBR + pushq %rbp + + pushq %rbx + + pushq %r12 + + pushq %r13 + + pushq %r14 + + pushq %r15 + +L$ord_sqr_body: + + movq 0(%rsi),%r8 + movq 8(%rsi),%rax + movq 16(%rsi),%r14 + movq 24(%rsi),%r15 + leaq L$ord(%rip),%rsi + movq %rdx,%rbx + jmp L$oop_ord_sqr + +.p2align 5 +L$oop_ord_sqr: + + movq %rax,%rbp + mulq %r8 + movq %rax,%r9 +.byte 102,72,15,110,205 + movq %r14,%rax + movq %rdx,%r10 + + mulq %r8 + addq %rax,%r10 + movq %r15,%rax +.byte 102,73,15,110,214 + adcq $0,%rdx + movq %rdx,%r11 + + mulq %r8 + addq %rax,%r11 + movq %r15,%rax +.byte 102,73,15,110,223 + adcq $0,%rdx + movq %rdx,%r12 + + + mulq %r14 + movq %rax,%r13 + movq %r14,%rax + movq %rdx,%r14 + + + mulq %rbp + addq %rax,%r11 + movq %r15,%rax + adcq $0,%rdx + movq %rdx,%r15 + + mulq %rbp + addq %rax,%r12 + adcq $0,%rdx + + addq %r15,%r12 + adcq %rdx,%r13 + adcq $0,%r14 + + + xorq %r15,%r15 + movq %r8,%rax + addq %r9,%r9 + adcq %r10,%r10 + adcq %r11,%r11 + adcq %r12,%r12 + adcq %r13,%r13 + adcq %r14,%r14 + adcq $0,%r15 + + + mulq %rax + movq %rax,%r8 +.byte 102,72,15,126,200 + movq %rdx,%rbp + + mulq %rax + addq %rbp,%r9 + adcq %rax,%r10 +.byte 102,72,15,126,208 + adcq $0,%rdx + movq %rdx,%rbp + + mulq %rax + addq %rbp,%r11 + adcq %rax,%r12 +.byte 102,72,15,126,216 + adcq $0,%rdx + movq %rdx,%rbp + + movq %r8,%rcx + imulq 32(%rsi),%r8 + + mulq %rax + addq %rbp,%r13 + adcq %rax,%r14 + movq 0(%rsi),%rax + adcq %rdx,%r15 + + + mulq %r8 + movq %r8,%rbp + addq %rax,%rcx + movq 8(%rsi),%rax + adcq %rdx,%rcx + + subq %r8,%r10 + sbbq $0,%rbp + + mulq %r8 + addq %rcx,%r9 + adcq $0,%rdx + addq %rax,%r9 + movq %r8,%rax + adcq %rdx,%r10 + movq %r8,%rdx + adcq $0,%rbp + + movq %r9,%rcx + imulq 32(%rsi),%r9 + + shlq $32,%rax + shrq $32,%rdx + subq %rax,%r11 + movq 0(%rsi),%rax + sbbq %rdx,%r8 + + addq %rbp,%r11 + adcq $0,%r8 + + + mulq %r9 + movq %r9,%rbp + addq %rax,%rcx + movq 8(%rsi),%rax + adcq %rdx,%rcx + + subq %r9,%r11 + sbbq $0,%rbp + + mulq %r9 + addq %rcx,%r10 + adcq $0,%rdx + addq %rax,%r10 + movq %r9,%rax + adcq %rdx,%r11 + movq %r9,%rdx + adcq $0,%rbp + + movq %r10,%rcx + imulq 32(%rsi),%r10 + + shlq $32,%rax + shrq $32,%rdx + subq %rax,%r8 + movq 0(%rsi),%rax + sbbq %rdx,%r9 + + addq %rbp,%r8 + adcq $0,%r9 + + + mulq %r10 + movq %r10,%rbp + addq %rax,%rcx + movq 8(%rsi),%rax + adcq %rdx,%rcx + + subq %r10,%r8 + sbbq $0,%rbp + + mulq %r10 + addq %rcx,%r11 + adcq $0,%rdx + addq %rax,%r11 + movq %r10,%rax + adcq %rdx,%r8 + movq %r10,%rdx + adcq $0,%rbp + + movq %r11,%rcx + imulq 32(%rsi),%r11 + + shlq $32,%rax + shrq $32,%rdx + subq %rax,%r9 + movq 0(%rsi),%rax + sbbq %rdx,%r10 + + addq %rbp,%r9 + adcq $0,%r10 + + + mulq %r11 + movq %r11,%rbp + addq %rax,%rcx + movq 8(%rsi),%rax + adcq %rdx,%rcx + + subq %r11,%r9 + sbbq $0,%rbp + + mulq %r11 + addq %rcx,%r8 + adcq $0,%rdx + addq %rax,%r8 + movq %r11,%rax + adcq %rdx,%r9 + movq %r11,%rdx + adcq $0,%rbp + + shlq $32,%rax + shrq $32,%rdx + subq %rax,%r10 + sbbq %rdx,%r11 + + addq %rbp,%r10 + adcq $0,%r11 + + + xorq %rdx,%rdx + addq %r12,%r8 + adcq %r13,%r9 + movq %r8,%r12 + adcq %r14,%r10 + adcq %r15,%r11 + movq %r9,%rax + adcq $0,%rdx + + + subq 0(%rsi),%r8 + movq %r10,%r14 + sbbq 8(%rsi),%r9 + sbbq 16(%rsi),%r10 + movq %r11,%r15 + sbbq 24(%rsi),%r11 + sbbq $0,%rdx + + cmovcq %r12,%r8 + cmovncq %r9,%rax + cmovncq %r10,%r14 + cmovncq %r11,%r15 + + decq %rbx + jnz L$oop_ord_sqr + + movq %r8,0(%rdi) + movq %rax,8(%rdi) + pxor %xmm1,%xmm1 + movq %r14,16(%rdi) + pxor %xmm2,%xmm2 + movq %r15,24(%rdi) + pxor %xmm3,%xmm3 + + movq 0(%rsp),%r15 + + movq 8(%rsp),%r14 + + movq 16(%rsp),%r13 + + movq 24(%rsp),%r12 + + movq 32(%rsp),%rbx + + movq 40(%rsp),%rbp + + leaq 48(%rsp),%rsp + +L$ord_sqr_epilogue: + ret + + + +.globl _ecp_nistz256_ord_mul_mont_adx +.private_extern _ecp_nistz256_ord_mul_mont_adx + +.p2align 5 +_ecp_nistz256_ord_mul_mont_adx: + +L$ecp_nistz256_ord_mul_mont_adx: +_CET_ENDBR + pushq %rbp + + pushq %rbx + + pushq %r12 + + pushq %r13 + + pushq %r14 + + pushq %r15 + +L$ord_mulx_body: + + movq %rdx,%rbx + movq 0(%rdx),%rdx + movq 0(%rsi),%r9 + movq 8(%rsi),%r10 + movq 16(%rsi),%r11 + movq 24(%rsi),%r12 + leaq -128(%rsi),%rsi + leaq L$ord-128(%rip),%r14 + movq L$ordK(%rip),%r15 + + + mulxq %r9,%r8,%r9 + mulxq %r10,%rcx,%r10 + mulxq %r11,%rbp,%r11 + addq %rcx,%r9 + mulxq %r12,%rcx,%r12 + movq %r8,%rdx + mulxq %r15,%rdx,%rax + adcq %rbp,%r10 + adcq %rcx,%r11 + adcq $0,%r12 + + + xorq %r13,%r13 + mulxq 0+128(%r14),%rcx,%rbp + adcxq %rcx,%r8 + adoxq %rbp,%r9 + + mulxq 8+128(%r14),%rcx,%rbp + adcxq %rcx,%r9 + adoxq %rbp,%r10 + + mulxq 16+128(%r14),%rcx,%rbp + adcxq %rcx,%r10 + adoxq %rbp,%r11 + + mulxq 24+128(%r14),%rcx,%rbp + movq 8(%rbx),%rdx + adcxq %rcx,%r11 + adoxq %rbp,%r12 + adcxq %r8,%r12 + adoxq %r8,%r13 + adcq $0,%r13 + + + mulxq 0+128(%rsi),%rcx,%rbp + adcxq %rcx,%r9 + adoxq %rbp,%r10 + + mulxq 8+128(%rsi),%rcx,%rbp + adcxq %rcx,%r10 + adoxq %rbp,%r11 + + mulxq 16+128(%rsi),%rcx,%rbp + adcxq %rcx,%r11 + adoxq %rbp,%r12 + + mulxq 24+128(%rsi),%rcx,%rbp + movq %r9,%rdx + mulxq %r15,%rdx,%rax + adcxq %rcx,%r12 + adoxq %rbp,%r13 + + adcxq %r8,%r13 + adoxq %r8,%r8 + adcq $0,%r8 + + + mulxq 0+128(%r14),%rcx,%rbp + adcxq %rcx,%r9 + adoxq %rbp,%r10 + + mulxq 8+128(%r14),%rcx,%rbp + adcxq %rcx,%r10 + adoxq %rbp,%r11 + + mulxq 16+128(%r14),%rcx,%rbp + adcxq %rcx,%r11 + adoxq %rbp,%r12 + + mulxq 24+128(%r14),%rcx,%rbp + movq 16(%rbx),%rdx + adcxq %rcx,%r12 + adoxq %rbp,%r13 + adcxq %r9,%r13 + adoxq %r9,%r8 + adcq $0,%r8 + + + mulxq 0+128(%rsi),%rcx,%rbp + adcxq %rcx,%r10 + adoxq %rbp,%r11 + + mulxq 8+128(%rsi),%rcx,%rbp + adcxq %rcx,%r11 + adoxq %rbp,%r12 + + mulxq 16+128(%rsi),%rcx,%rbp + adcxq %rcx,%r12 + adoxq %rbp,%r13 + + mulxq 24+128(%rsi),%rcx,%rbp + movq %r10,%rdx + mulxq %r15,%rdx,%rax + adcxq %rcx,%r13 + adoxq %rbp,%r8 + + adcxq %r9,%r8 + adoxq %r9,%r9 + adcq $0,%r9 + + + mulxq 0+128(%r14),%rcx,%rbp + adcxq %rcx,%r10 + adoxq %rbp,%r11 + + mulxq 8+128(%r14),%rcx,%rbp + adcxq %rcx,%r11 + adoxq %rbp,%r12 + + mulxq 16+128(%r14),%rcx,%rbp + adcxq %rcx,%r12 + adoxq %rbp,%r13 + + mulxq 24+128(%r14),%rcx,%rbp + movq 24(%rbx),%rdx + adcxq %rcx,%r13 + adoxq %rbp,%r8 + adcxq %r10,%r8 + adoxq %r10,%r9 + adcq $0,%r9 + + + mulxq 0+128(%rsi),%rcx,%rbp + adcxq %rcx,%r11 + adoxq %rbp,%r12 + + mulxq 8+128(%rsi),%rcx,%rbp + adcxq %rcx,%r12 + adoxq %rbp,%r13 + + mulxq 16+128(%rsi),%rcx,%rbp + adcxq %rcx,%r13 + adoxq %rbp,%r8 + + mulxq 24+128(%rsi),%rcx,%rbp + movq %r11,%rdx + mulxq %r15,%rdx,%rax + adcxq %rcx,%r8 + adoxq %rbp,%r9 + + adcxq %r10,%r9 + adoxq %r10,%r10 + adcq $0,%r10 + + + mulxq 0+128(%r14),%rcx,%rbp + adcxq %rcx,%r11 + adoxq %rbp,%r12 + + mulxq 8+128(%r14),%rcx,%rbp + adcxq %rcx,%r12 + adoxq %rbp,%r13 + + mulxq 16+128(%r14),%rcx,%rbp + adcxq %rcx,%r13 + adoxq %rbp,%r8 + + mulxq 24+128(%r14),%rcx,%rbp + leaq 128(%r14),%r14 + movq %r12,%rbx + adcxq %rcx,%r8 + adoxq %rbp,%r9 + movq %r13,%rdx + adcxq %r11,%r9 + adoxq %r11,%r10 + adcq $0,%r10 + + + + movq %r8,%rcx + subq 0(%r14),%r12 + sbbq 8(%r14),%r13 + sbbq 16(%r14),%r8 + movq %r9,%rbp + sbbq 24(%r14),%r9 + sbbq $0,%r10 + + cmovcq %rbx,%r12 + cmovcq %rdx,%r13 + cmovcq %rcx,%r8 + cmovcq %rbp,%r9 + + movq %r12,0(%rdi) + movq %r13,8(%rdi) + movq %r8,16(%rdi) + movq %r9,24(%rdi) + + movq 0(%rsp),%r15 + + movq 8(%rsp),%r14 + + movq 16(%rsp),%r13 + + movq 24(%rsp),%r12 + + movq 32(%rsp),%rbx + + movq 40(%rsp),%rbp + + leaq 48(%rsp),%rsp + +L$ord_mulx_epilogue: + ret + + + +.globl _ecp_nistz256_ord_sqr_mont_adx +.private_extern _ecp_nistz256_ord_sqr_mont_adx + +.p2align 5 +_ecp_nistz256_ord_sqr_mont_adx: + +_CET_ENDBR +L$ecp_nistz256_ord_sqr_mont_adx: + pushq %rbp + + pushq %rbx + + pushq %r12 + + pushq %r13 + + pushq %r14 + + pushq %r15 + +L$ord_sqrx_body: + + movq %rdx,%rbx + movq 0(%rsi),%rdx + movq 8(%rsi),%r14 + movq 16(%rsi),%r15 + movq 24(%rsi),%r8 + leaq L$ord(%rip),%rsi + jmp L$oop_ord_sqrx + +.p2align 5 +L$oop_ord_sqrx: + mulxq %r14,%r9,%r10 + mulxq %r15,%rcx,%r11 + movq %rdx,%rax +.byte 102,73,15,110,206 + mulxq %r8,%rbp,%r12 + movq %r14,%rdx + addq %rcx,%r10 +.byte 102,73,15,110,215 + adcq %rbp,%r11 + adcq $0,%r12 + xorq %r13,%r13 + + mulxq %r15,%rcx,%rbp + adcxq %rcx,%r11 + adoxq %rbp,%r12 + + mulxq %r8,%rcx,%rbp + movq %r15,%rdx + adcxq %rcx,%r12 + adoxq %rbp,%r13 + adcq $0,%r13 + + mulxq %r8,%rcx,%r14 + movq %rax,%rdx +.byte 102,73,15,110,216 + xorq %r15,%r15 + adcxq %r9,%r9 + adoxq %rcx,%r13 + adcxq %r10,%r10 + adoxq %r15,%r14 + + + mulxq %rdx,%r8,%rbp +.byte 102,72,15,126,202 + adcxq %r11,%r11 + adoxq %rbp,%r9 + adcxq %r12,%r12 + mulxq %rdx,%rcx,%rax +.byte 102,72,15,126,210 + adcxq %r13,%r13 + adoxq %rcx,%r10 + adcxq %r14,%r14 + mulxq %rdx,%rcx,%rbp +.byte 0x67 +.byte 102,72,15,126,218 + adoxq %rax,%r11 + adcxq %r15,%r15 + adoxq %rcx,%r12 + adoxq %rbp,%r13 + mulxq %rdx,%rcx,%rax + adoxq %rcx,%r14 + adoxq %rax,%r15 + + + movq %r8,%rdx + mulxq 32(%rsi),%rdx,%rcx + + xorq %rax,%rax + mulxq 0(%rsi),%rcx,%rbp + adcxq %rcx,%r8 + adoxq %rbp,%r9 + mulxq 8(%rsi),%rcx,%rbp + adcxq %rcx,%r9 + adoxq %rbp,%r10 + mulxq 16(%rsi),%rcx,%rbp + adcxq %rcx,%r10 + adoxq %rbp,%r11 + mulxq 24(%rsi),%rcx,%rbp + adcxq %rcx,%r11 + adoxq %rbp,%r8 + adcxq %rax,%r8 + + + movq %r9,%rdx + mulxq 32(%rsi),%rdx,%rcx + + mulxq 0(%rsi),%rcx,%rbp + adoxq %rcx,%r9 + adcxq %rbp,%r10 + mulxq 8(%rsi),%rcx,%rbp + adoxq %rcx,%r10 + adcxq %rbp,%r11 + mulxq 16(%rsi),%rcx,%rbp + adoxq %rcx,%r11 + adcxq %rbp,%r8 + mulxq 24(%rsi),%rcx,%rbp + adoxq %rcx,%r8 + adcxq %rbp,%r9 + adoxq %rax,%r9 + + + movq %r10,%rdx + mulxq 32(%rsi),%rdx,%rcx + + mulxq 0(%rsi),%rcx,%rbp + adcxq %rcx,%r10 + adoxq %rbp,%r11 + mulxq 8(%rsi),%rcx,%rbp + adcxq %rcx,%r11 + adoxq %rbp,%r8 + mulxq 16(%rsi),%rcx,%rbp + adcxq %rcx,%r8 + adoxq %rbp,%r9 + mulxq 24(%rsi),%rcx,%rbp + adcxq %rcx,%r9 + adoxq %rbp,%r10 + adcxq %rax,%r10 + + + movq %r11,%rdx + mulxq 32(%rsi),%rdx,%rcx + + mulxq 0(%rsi),%rcx,%rbp + adoxq %rcx,%r11 + adcxq %rbp,%r8 + mulxq 8(%rsi),%rcx,%rbp + adoxq %rcx,%r8 + adcxq %rbp,%r9 + mulxq 16(%rsi),%rcx,%rbp + adoxq %rcx,%r9 + adcxq %rbp,%r10 + mulxq 24(%rsi),%rcx,%rbp + adoxq %rcx,%r10 + adcxq %rbp,%r11 + adoxq %rax,%r11 + + + addq %r8,%r12 + adcq %r13,%r9 + movq %r12,%rdx + adcq %r14,%r10 + adcq %r15,%r11 + movq %r9,%r14 + adcq $0,%rax + + + subq 0(%rsi),%r12 + movq %r10,%r15 + sbbq 8(%rsi),%r9 + sbbq 16(%rsi),%r10 + movq %r11,%r8 + sbbq 24(%rsi),%r11 + sbbq $0,%rax + + cmovncq %r12,%rdx + cmovncq %r9,%r14 + cmovncq %r10,%r15 + cmovncq %r11,%r8 + + decq %rbx + jnz L$oop_ord_sqrx + + movq %rdx,0(%rdi) + movq %r14,8(%rdi) + pxor %xmm1,%xmm1 + movq %r15,16(%rdi) + pxor %xmm2,%xmm2 + movq %r8,24(%rdi) + pxor %xmm3,%xmm3 + + movq 0(%rsp),%r15 + + movq 8(%rsp),%r14 + + movq 16(%rsp),%r13 + + movq 24(%rsp),%r12 + + movq 32(%rsp),%rbx + + movq 40(%rsp),%rbp + + leaq 48(%rsp),%rsp + +L$ord_sqrx_epilogue: + ret + + + + + + + + +.globl _ecp_nistz256_mul_mont_nohw +.private_extern _ecp_nistz256_mul_mont_nohw + +.p2align 5 +_ecp_nistz256_mul_mont_nohw: + +_CET_ENDBR + pushq %rbp + + pushq %rbx + + pushq %r12 + + pushq %r13 + + pushq %r14 + + pushq %r15 + +L$mul_body: + movq %rdx,%rbx + movq 0(%rdx),%rax + movq 0(%rsi),%r9 + movq 8(%rsi),%r10 + movq 16(%rsi),%r11 + movq 24(%rsi),%r12 + + call __ecp_nistz256_mul_montq + + movq 0(%rsp),%r15 + + movq 8(%rsp),%r14 + + movq 16(%rsp),%r13 + + movq 24(%rsp),%r12 + + movq 32(%rsp),%rbx + + movq 40(%rsp),%rbp + + leaq 48(%rsp),%rsp + +L$mul_epilogue: + ret + + + + +.p2align 5 +__ecp_nistz256_mul_montq: + + + + movq %rax,%rbp + mulq %r9 + movq L$poly+8(%rip),%r14 + movq %rax,%r8 + movq %rbp,%rax + movq %rdx,%r9 + + mulq %r10 + movq L$poly+24(%rip),%r15 + addq %rax,%r9 + movq %rbp,%rax + adcq $0,%rdx + movq %rdx,%r10 + + mulq %r11 + addq %rax,%r10 + movq %rbp,%rax + adcq $0,%rdx + movq %rdx,%r11 + + mulq %r12 + addq %rax,%r11 + movq %r8,%rax + adcq $0,%rdx + xorq %r13,%r13 + movq %rdx,%r12 + + + + + + + + + + + movq %r8,%rbp + shlq $32,%r8 + mulq %r15 + shrq $32,%rbp + addq %r8,%r9 + adcq %rbp,%r10 + adcq %rax,%r11 + movq 8(%rbx),%rax + adcq %rdx,%r12 + adcq $0,%r13 + xorq %r8,%r8 + + + + movq %rax,%rbp + mulq 0(%rsi) + addq %rax,%r9 + movq %rbp,%rax + adcq $0,%rdx + movq %rdx,%rcx + + mulq 8(%rsi) + addq %rcx,%r10 + adcq $0,%rdx + addq %rax,%r10 + movq %rbp,%rax + adcq $0,%rdx + movq %rdx,%rcx + + mulq 16(%rsi) + addq %rcx,%r11 + adcq $0,%rdx + addq %rax,%r11 + movq %rbp,%rax + adcq $0,%rdx + movq %rdx,%rcx + + mulq 24(%rsi) + addq %rcx,%r12 + adcq $0,%rdx + addq %rax,%r12 + movq %r9,%rax + adcq %rdx,%r13 + adcq $0,%r8 + + + + movq %r9,%rbp + shlq $32,%r9 + mulq %r15 + shrq $32,%rbp + addq %r9,%r10 + adcq %rbp,%r11 + adcq %rax,%r12 + movq 16(%rbx),%rax + adcq %rdx,%r13 + adcq $0,%r8 + xorq %r9,%r9 + + + + movq %rax,%rbp + mulq 0(%rsi) + addq %rax,%r10 + movq %rbp,%rax + adcq $0,%rdx + movq %rdx,%rcx + + mulq 8(%rsi) + addq %rcx,%r11 + adcq $0,%rdx + addq %rax,%r11 + movq %rbp,%rax + adcq $0,%rdx + movq %rdx,%rcx + + mulq 16(%rsi) + addq %rcx,%r12 + adcq $0,%rdx + addq %rax,%r12 + movq %rbp,%rax + adcq $0,%rdx + movq %rdx,%rcx + + mulq 24(%rsi) + addq %rcx,%r13 + adcq $0,%rdx + addq %rax,%r13 + movq %r10,%rax + adcq %rdx,%r8 + adcq $0,%r9 + + + + movq %r10,%rbp + shlq $32,%r10 + mulq %r15 + shrq $32,%rbp + addq %r10,%r11 + adcq %rbp,%r12 + adcq %rax,%r13 + movq 24(%rbx),%rax + adcq %rdx,%r8 + adcq $0,%r9 + xorq %r10,%r10 + + + + movq %rax,%rbp + mulq 0(%rsi) + addq %rax,%r11 + movq %rbp,%rax + adcq $0,%rdx + movq %rdx,%rcx + + mulq 8(%rsi) + addq %rcx,%r12 + adcq $0,%rdx + addq %rax,%r12 + movq %rbp,%rax + adcq $0,%rdx + movq %rdx,%rcx + + mulq 16(%rsi) + addq %rcx,%r13 + adcq $0,%rdx + addq %rax,%r13 + movq %rbp,%rax + adcq $0,%rdx + movq %rdx,%rcx + + mulq 24(%rsi) + addq %rcx,%r8 + adcq $0,%rdx + addq %rax,%r8 + movq %r11,%rax + adcq %rdx,%r9 + adcq $0,%r10 + + + + movq %r11,%rbp + shlq $32,%r11 + mulq %r15 + shrq $32,%rbp + addq %r11,%r12 + adcq %rbp,%r13 + movq %r12,%rcx + adcq %rax,%r8 + adcq %rdx,%r9 + movq %r13,%rbp + adcq $0,%r10 + + + + subq $-1,%r12 + movq %r8,%rbx + sbbq %r14,%r13 + sbbq $0,%r8 + movq %r9,%rdx + sbbq %r15,%r9 + sbbq $0,%r10 + + cmovcq %rcx,%r12 + cmovcq %rbp,%r13 + movq %r12,0(%rdi) + cmovcq %rbx,%r8 + movq %r13,8(%rdi) + cmovcq %rdx,%r9 + movq %r8,16(%rdi) + movq %r9,24(%rdi) + + ret + + + + + + + + + + +.globl _ecp_nistz256_sqr_mont_nohw +.private_extern _ecp_nistz256_sqr_mont_nohw + +.p2align 5 +_ecp_nistz256_sqr_mont_nohw: + +_CET_ENDBR + pushq %rbp + + pushq %rbx + + pushq %r12 + + pushq %r13 + + pushq %r14 + + pushq %r15 + +L$sqr_body: + movq 0(%rsi),%rax + movq 8(%rsi),%r14 + movq 16(%rsi),%r15 + movq 24(%rsi),%r8 + + call __ecp_nistz256_sqr_montq + + movq 0(%rsp),%r15 + + movq 8(%rsp),%r14 + + movq 16(%rsp),%r13 + + movq 24(%rsp),%r12 + + movq 32(%rsp),%rbx + + movq 40(%rsp),%rbp + + leaq 48(%rsp),%rsp + +L$sqr_epilogue: + ret + + + + +.p2align 5 +__ecp_nistz256_sqr_montq: + + movq %rax,%r13 + mulq %r14 + movq %rax,%r9 + movq %r15,%rax + movq %rdx,%r10 + + mulq %r13 + addq %rax,%r10 + movq %r8,%rax + adcq $0,%rdx + movq %rdx,%r11 + + mulq %r13 + addq %rax,%r11 + movq %r15,%rax + adcq $0,%rdx + movq %rdx,%r12 + + + mulq %r14 + addq %rax,%r11 + movq %r8,%rax + adcq $0,%rdx + movq %rdx,%rbp + + mulq %r14 + addq %rax,%r12 + movq %r8,%rax + adcq $0,%rdx + addq %rbp,%r12 + movq %rdx,%r13 + adcq $0,%r13 + + + mulq %r15 + xorq %r15,%r15 + addq %rax,%r13 + movq 0(%rsi),%rax + movq %rdx,%r14 + adcq $0,%r14 + + addq %r9,%r9 + adcq %r10,%r10 + adcq %r11,%r11 + adcq %r12,%r12 + adcq %r13,%r13 + adcq %r14,%r14 + adcq $0,%r15 + + mulq %rax + movq %rax,%r8 + movq 8(%rsi),%rax + movq %rdx,%rcx + + mulq %rax + addq %rcx,%r9 + adcq %rax,%r10 + movq 16(%rsi),%rax + adcq $0,%rdx + movq %rdx,%rcx + + mulq %rax + addq %rcx,%r11 + adcq %rax,%r12 + movq 24(%rsi),%rax + adcq $0,%rdx + movq %rdx,%rcx + + mulq %rax + addq %rcx,%r13 + adcq %rax,%r14 + movq %r8,%rax + adcq %rdx,%r15 + + movq L$poly+8(%rip),%rsi + movq L$poly+24(%rip),%rbp + + + + + movq %r8,%rcx + shlq $32,%r8 + mulq %rbp + shrq $32,%rcx + addq %r8,%r9 + adcq %rcx,%r10 + adcq %rax,%r11 + movq %r9,%rax + adcq $0,%rdx + + + + movq %r9,%rcx + shlq $32,%r9 + movq %rdx,%r8 + mulq %rbp + shrq $32,%rcx + addq %r9,%r10 + adcq %rcx,%r11 + adcq %rax,%r8 + movq %r10,%rax + adcq $0,%rdx + + + + movq %r10,%rcx + shlq $32,%r10 + movq %rdx,%r9 + mulq %rbp + shrq $32,%rcx + addq %r10,%r11 + adcq %rcx,%r8 + adcq %rax,%r9 + movq %r11,%rax + adcq $0,%rdx + + + + movq %r11,%rcx + shlq $32,%r11 + movq %rdx,%r10 + mulq %rbp + shrq $32,%rcx + addq %r11,%r8 + adcq %rcx,%r9 + adcq %rax,%r10 + adcq $0,%rdx + xorq %r11,%r11 + + + + addq %r8,%r12 + adcq %r9,%r13 + movq %r12,%r8 + adcq %r10,%r14 + adcq %rdx,%r15 + movq %r13,%r9 + adcq $0,%r11 + + subq $-1,%r12 + movq %r14,%r10 + sbbq %rsi,%r13 + sbbq $0,%r14 + movq %r15,%rcx + sbbq %rbp,%r15 + sbbq $0,%r11 + + cmovcq %r8,%r12 + cmovcq %r9,%r13 + movq %r12,0(%rdi) + cmovcq %r10,%r14 + movq %r13,8(%rdi) + cmovcq %rcx,%r15 + movq %r14,16(%rdi) + movq %r15,24(%rdi) + + ret + + +.globl _ecp_nistz256_mul_mont_adx +.private_extern _ecp_nistz256_mul_mont_adx + +.p2align 5 +_ecp_nistz256_mul_mont_adx: + +_CET_ENDBR + pushq %rbp + + pushq %rbx + + pushq %r12 + + pushq %r13 + + pushq %r14 + + pushq %r15 + +L$mulx_body: + movq %rdx,%rbx + movq 0(%rdx),%rdx + movq 0(%rsi),%r9 + movq 8(%rsi),%r10 + movq 16(%rsi),%r11 + movq 24(%rsi),%r12 + leaq -128(%rsi),%rsi + + call __ecp_nistz256_mul_montx + + movq 0(%rsp),%r15 + + movq 8(%rsp),%r14 + + movq 16(%rsp),%r13 + + movq 24(%rsp),%r12 + + movq 32(%rsp),%rbx + + movq 40(%rsp),%rbp + + leaq 48(%rsp),%rsp + +L$mulx_epilogue: + ret + + + + +.p2align 5 +__ecp_nistz256_mul_montx: + + + + mulxq %r9,%r8,%r9 + mulxq %r10,%rcx,%r10 + movq $32,%r14 + xorq %r13,%r13 + mulxq %r11,%rbp,%r11 + movq L$poly+24(%rip),%r15 + adcq %rcx,%r9 + mulxq %r12,%rcx,%r12 + movq %r8,%rdx + adcq %rbp,%r10 + shlxq %r14,%r8,%rbp + adcq %rcx,%r11 + shrxq %r14,%r8,%rcx + adcq $0,%r12 + + + + addq %rbp,%r9 + adcq %rcx,%r10 + + mulxq %r15,%rcx,%rbp + movq 8(%rbx),%rdx + adcq %rcx,%r11 + adcq %rbp,%r12 + adcq $0,%r13 + xorq %r8,%r8 + + + + mulxq 0+128(%rsi),%rcx,%rbp + adcxq %rcx,%r9 + adoxq %rbp,%r10 + + mulxq 8+128(%rsi),%rcx,%rbp + adcxq %rcx,%r10 + adoxq %rbp,%r11 + + mulxq 16+128(%rsi),%rcx,%rbp + adcxq %rcx,%r11 + adoxq %rbp,%r12 + + mulxq 24+128(%rsi),%rcx,%rbp + movq %r9,%rdx + adcxq %rcx,%r12 + shlxq %r14,%r9,%rcx + adoxq %rbp,%r13 + shrxq %r14,%r9,%rbp + + adcxq %r8,%r13 + adoxq %r8,%r8 + adcq $0,%r8 + + + + addq %rcx,%r10 + adcq %rbp,%r11 + + mulxq %r15,%rcx,%rbp + movq 16(%rbx),%rdx + adcq %rcx,%r12 + adcq %rbp,%r13 + adcq $0,%r8 + xorq %r9,%r9 + + + + mulxq 0+128(%rsi),%rcx,%rbp + adcxq %rcx,%r10 + adoxq %rbp,%r11 + + mulxq 8+128(%rsi),%rcx,%rbp + adcxq %rcx,%r11 + adoxq %rbp,%r12 + + mulxq 16+128(%rsi),%rcx,%rbp + adcxq %rcx,%r12 + adoxq %rbp,%r13 + + mulxq 24+128(%rsi),%rcx,%rbp + movq %r10,%rdx + adcxq %rcx,%r13 + shlxq %r14,%r10,%rcx + adoxq %rbp,%r8 + shrxq %r14,%r10,%rbp + + adcxq %r9,%r8 + adoxq %r9,%r9 + adcq $0,%r9 + + + + addq %rcx,%r11 + adcq %rbp,%r12 + + mulxq %r15,%rcx,%rbp + movq 24(%rbx),%rdx + adcq %rcx,%r13 + adcq %rbp,%r8 + adcq $0,%r9 + xorq %r10,%r10 + + + + mulxq 0+128(%rsi),%rcx,%rbp + adcxq %rcx,%r11 + adoxq %rbp,%r12 + + mulxq 8+128(%rsi),%rcx,%rbp + adcxq %rcx,%r12 + adoxq %rbp,%r13 + + mulxq 16+128(%rsi),%rcx,%rbp + adcxq %rcx,%r13 + adoxq %rbp,%r8 + + mulxq 24+128(%rsi),%rcx,%rbp + movq %r11,%rdx + adcxq %rcx,%r8 + shlxq %r14,%r11,%rcx + adoxq %rbp,%r9 + shrxq %r14,%r11,%rbp + + adcxq %r10,%r9 + adoxq %r10,%r10 + adcq $0,%r10 + + + + addq %rcx,%r12 + adcq %rbp,%r13 + + mulxq %r15,%rcx,%rbp + movq %r12,%rbx + movq L$poly+8(%rip),%r14 + adcq %rcx,%r8 + movq %r13,%rdx + adcq %rbp,%r9 + adcq $0,%r10 + + + + xorl %eax,%eax + movq %r8,%rcx + sbbq $-1,%r12 + sbbq %r14,%r13 + sbbq $0,%r8 + movq %r9,%rbp + sbbq %r15,%r9 + sbbq $0,%r10 + + cmovcq %rbx,%r12 + cmovcq %rdx,%r13 + movq %r12,0(%rdi) + cmovcq %rcx,%r8 + movq %r13,8(%rdi) + cmovcq %rbp,%r9 + movq %r8,16(%rdi) + movq %r9,24(%rdi) + + ret + + + +.globl _ecp_nistz256_sqr_mont_adx +.private_extern _ecp_nistz256_sqr_mont_adx + +.p2align 5 +_ecp_nistz256_sqr_mont_adx: + +_CET_ENDBR + pushq %rbp + + pushq %rbx + + pushq %r12 + + pushq %r13 + + pushq %r14 + + pushq %r15 + +L$sqrx_body: + movq 0(%rsi),%rdx + movq 8(%rsi),%r14 + movq 16(%rsi),%r15 + movq 24(%rsi),%r8 + leaq -128(%rsi),%rsi + + call __ecp_nistz256_sqr_montx + + movq 0(%rsp),%r15 + + movq 8(%rsp),%r14 + + movq 16(%rsp),%r13 + + movq 24(%rsp),%r12 + + movq 32(%rsp),%rbx + + movq 40(%rsp),%rbp + + leaq 48(%rsp),%rsp + +L$sqrx_epilogue: + ret + + + + +.p2align 5 +__ecp_nistz256_sqr_montx: + + mulxq %r14,%r9,%r10 + mulxq %r15,%rcx,%r11 + xorl %eax,%eax + adcq %rcx,%r10 + mulxq %r8,%rbp,%r12 + movq %r14,%rdx + adcq %rbp,%r11 + adcq $0,%r12 + xorq %r13,%r13 + + + mulxq %r15,%rcx,%rbp + adcxq %rcx,%r11 + adoxq %rbp,%r12 + + mulxq %r8,%rcx,%rbp + movq %r15,%rdx + adcxq %rcx,%r12 + adoxq %rbp,%r13 + adcq $0,%r13 + + + mulxq %r8,%rcx,%r14 + movq 0+128(%rsi),%rdx + xorq %r15,%r15 + adcxq %r9,%r9 + adoxq %rcx,%r13 + adcxq %r10,%r10 + adoxq %r15,%r14 + + mulxq %rdx,%r8,%rbp + movq 8+128(%rsi),%rdx + adcxq %r11,%r11 + adoxq %rbp,%r9 + adcxq %r12,%r12 + mulxq %rdx,%rcx,%rax + movq 16+128(%rsi),%rdx + adcxq %r13,%r13 + adoxq %rcx,%r10 + adcxq %r14,%r14 +.byte 0x67 + mulxq %rdx,%rcx,%rbp + movq 24+128(%rsi),%rdx + adoxq %rax,%r11 + adcxq %r15,%r15 + adoxq %rcx,%r12 + movq $32,%rsi + adoxq %rbp,%r13 +.byte 0x67,0x67 + mulxq %rdx,%rcx,%rax + movq L$poly+24(%rip),%rdx + adoxq %rcx,%r14 + shlxq %rsi,%r8,%rcx + adoxq %rax,%r15 + shrxq %rsi,%r8,%rax + movq %rdx,%rbp + + + addq %rcx,%r9 + adcq %rax,%r10 + + mulxq %r8,%rcx,%r8 + adcq %rcx,%r11 + shlxq %rsi,%r9,%rcx + adcq $0,%r8 + shrxq %rsi,%r9,%rax + + + addq %rcx,%r10 + adcq %rax,%r11 + + mulxq %r9,%rcx,%r9 + adcq %rcx,%r8 + shlxq %rsi,%r10,%rcx + adcq $0,%r9 + shrxq %rsi,%r10,%rax + + + addq %rcx,%r11 + adcq %rax,%r8 + + mulxq %r10,%rcx,%r10 + adcq %rcx,%r9 + shlxq %rsi,%r11,%rcx + adcq $0,%r10 + shrxq %rsi,%r11,%rax + + + addq %rcx,%r8 + adcq %rax,%r9 + + mulxq %r11,%rcx,%r11 + adcq %rcx,%r10 + adcq $0,%r11 + + xorq %rdx,%rdx + addq %r8,%r12 + movq L$poly+8(%rip),%rsi + adcq %r9,%r13 + movq %r12,%r8 + adcq %r10,%r14 + adcq %r11,%r15 + movq %r13,%r9 + adcq $0,%rdx + + subq $-1,%r12 + movq %r14,%r10 + sbbq %rsi,%r13 + sbbq $0,%r14 + movq %r15,%r11 + sbbq %rbp,%r15 + sbbq $0,%rdx + + cmovcq %r8,%r12 + cmovcq %r9,%r13 + movq %r12,0(%rdi) + cmovcq %r10,%r14 + movq %r13,8(%rdi) + cmovcq %r11,%r15 + movq %r14,16(%rdi) + movq %r15,24(%rdi) + + ret + + + + +.globl _ecp_nistz256_select_w5_nohw +.private_extern _ecp_nistz256_select_w5_nohw + +.p2align 5 +_ecp_nistz256_select_w5_nohw: + +_CET_ENDBR + movdqa L$One(%rip),%xmm0 + movd %edx,%xmm1 + + pxor %xmm2,%xmm2 + pxor %xmm3,%xmm3 + pxor %xmm4,%xmm4 + pxor %xmm5,%xmm5 + pxor %xmm6,%xmm6 + pxor %xmm7,%xmm7 + + movdqa %xmm0,%xmm8 + pshufd $0,%xmm1,%xmm1 + + movq $16,%rax +L$select_loop_sse_w5: + + movdqa %xmm8,%xmm15 + paddd %xmm0,%xmm8 + pcmpeqd %xmm1,%xmm15 + + movdqa 0(%rsi),%xmm9 + movdqa 16(%rsi),%xmm10 + movdqa 32(%rsi),%xmm11 + movdqa 48(%rsi),%xmm12 + movdqa 64(%rsi),%xmm13 + movdqa 80(%rsi),%xmm14 + leaq 96(%rsi),%rsi + + pand %xmm15,%xmm9 + pand %xmm15,%xmm10 + por %xmm9,%xmm2 + pand %xmm15,%xmm11 + por %xmm10,%xmm3 + pand %xmm15,%xmm12 + por %xmm11,%xmm4 + pand %xmm15,%xmm13 + por %xmm12,%xmm5 + pand %xmm15,%xmm14 + por %xmm13,%xmm6 + por %xmm14,%xmm7 + + decq %rax + jnz L$select_loop_sse_w5 + + movdqu %xmm2,0(%rdi) + movdqu %xmm3,16(%rdi) + movdqu %xmm4,32(%rdi) + movdqu %xmm5,48(%rdi) + movdqu %xmm6,64(%rdi) + movdqu %xmm7,80(%rdi) + ret + +L$SEH_end_ecp_nistz256_select_w5_nohw: + + + + +.globl _ecp_nistz256_select_w7_nohw +.private_extern _ecp_nistz256_select_w7_nohw + +.p2align 5 +_ecp_nistz256_select_w7_nohw: + +_CET_ENDBR + movdqa L$One(%rip),%xmm8 + movd %edx,%xmm1 + + pxor %xmm2,%xmm2 + pxor %xmm3,%xmm3 + pxor %xmm4,%xmm4 + pxor %xmm5,%xmm5 + + movdqa %xmm8,%xmm0 + pshufd $0,%xmm1,%xmm1 + movq $64,%rax + +L$select_loop_sse_w7: + movdqa %xmm8,%xmm15 + paddd %xmm0,%xmm8 + movdqa 0(%rsi),%xmm9 + movdqa 16(%rsi),%xmm10 + pcmpeqd %xmm1,%xmm15 + movdqa 32(%rsi),%xmm11 + movdqa 48(%rsi),%xmm12 + leaq 64(%rsi),%rsi + + pand %xmm15,%xmm9 + pand %xmm15,%xmm10 + por %xmm9,%xmm2 + pand %xmm15,%xmm11 + por %xmm10,%xmm3 + pand %xmm15,%xmm12 + por %xmm11,%xmm4 + prefetcht0 255(%rsi) + por %xmm12,%xmm5 + + decq %rax + jnz L$select_loop_sse_w7 + + movdqu %xmm2,0(%rdi) + movdqu %xmm3,16(%rdi) + movdqu %xmm4,32(%rdi) + movdqu %xmm5,48(%rdi) + ret + +L$SEH_end_ecp_nistz256_select_w7_nohw: + + + +.globl _ecp_nistz256_select_w5_avx2 +.private_extern _ecp_nistz256_select_w5_avx2 + +.p2align 5 +_ecp_nistz256_select_w5_avx2: + +_CET_ENDBR + vzeroupper + vmovdqa L$Two(%rip),%ymm0 + + vpxor %ymm2,%ymm2,%ymm2 + vpxor %ymm3,%ymm3,%ymm3 + vpxor %ymm4,%ymm4,%ymm4 + + vmovdqa L$One(%rip),%ymm5 + vmovdqa L$Two(%rip),%ymm10 + + vmovd %edx,%xmm1 + vpermd %ymm1,%ymm2,%ymm1 + + movq $8,%rax +L$select_loop_avx2_w5: + + vmovdqa 0(%rsi),%ymm6 + vmovdqa 32(%rsi),%ymm7 + vmovdqa 64(%rsi),%ymm8 + + vmovdqa 96(%rsi),%ymm11 + vmovdqa 128(%rsi),%ymm12 + vmovdqa 160(%rsi),%ymm13 + + vpcmpeqd %ymm1,%ymm5,%ymm9 + vpcmpeqd %ymm1,%ymm10,%ymm14 + + vpaddd %ymm0,%ymm5,%ymm5 + vpaddd %ymm0,%ymm10,%ymm10 + leaq 192(%rsi),%rsi + + vpand %ymm9,%ymm6,%ymm6 + vpand %ymm9,%ymm7,%ymm7 + vpand %ymm9,%ymm8,%ymm8 + vpand %ymm14,%ymm11,%ymm11 + vpand %ymm14,%ymm12,%ymm12 + vpand %ymm14,%ymm13,%ymm13 + + vpxor %ymm6,%ymm2,%ymm2 + vpxor %ymm7,%ymm3,%ymm3 + vpxor %ymm8,%ymm4,%ymm4 + vpxor %ymm11,%ymm2,%ymm2 + vpxor %ymm12,%ymm3,%ymm3 + vpxor %ymm13,%ymm4,%ymm4 + + decq %rax + jnz L$select_loop_avx2_w5 + + vmovdqu %ymm2,0(%rdi) + vmovdqu %ymm3,32(%rdi) + vmovdqu %ymm4,64(%rdi) + vzeroupper + ret + +L$SEH_end_ecp_nistz256_select_w5_avx2: + + + + +.globl _ecp_nistz256_select_w7_avx2 +.private_extern _ecp_nistz256_select_w7_avx2 + +.p2align 5 +_ecp_nistz256_select_w7_avx2: + +_CET_ENDBR + vzeroupper + vmovdqa L$Three(%rip),%ymm0 + + vpxor %ymm2,%ymm2,%ymm2 + vpxor %ymm3,%ymm3,%ymm3 + + vmovdqa L$One(%rip),%ymm4 + vmovdqa L$Two(%rip),%ymm8 + vmovdqa L$Three(%rip),%ymm12 + + vmovd %edx,%xmm1 + vpermd %ymm1,%ymm2,%ymm1 + + + movq $21,%rax +L$select_loop_avx2_w7: + + vmovdqa 0(%rsi),%ymm5 + vmovdqa 32(%rsi),%ymm6 + + vmovdqa 64(%rsi),%ymm9 + vmovdqa 96(%rsi),%ymm10 + + vmovdqa 128(%rsi),%ymm13 + vmovdqa 160(%rsi),%ymm14 + + vpcmpeqd %ymm1,%ymm4,%ymm7 + vpcmpeqd %ymm1,%ymm8,%ymm11 + vpcmpeqd %ymm1,%ymm12,%ymm15 + + vpaddd %ymm0,%ymm4,%ymm4 + vpaddd %ymm0,%ymm8,%ymm8 + vpaddd %ymm0,%ymm12,%ymm12 + leaq 192(%rsi),%rsi + + vpand %ymm7,%ymm5,%ymm5 + vpand %ymm7,%ymm6,%ymm6 + vpand %ymm11,%ymm9,%ymm9 + vpand %ymm11,%ymm10,%ymm10 + vpand %ymm15,%ymm13,%ymm13 + vpand %ymm15,%ymm14,%ymm14 + + vpxor %ymm5,%ymm2,%ymm2 + vpxor %ymm6,%ymm3,%ymm3 + vpxor %ymm9,%ymm2,%ymm2 + vpxor %ymm10,%ymm3,%ymm3 + vpxor %ymm13,%ymm2,%ymm2 + vpxor %ymm14,%ymm3,%ymm3 + + decq %rax + jnz L$select_loop_avx2_w7 + + + vmovdqa 0(%rsi),%ymm5 + vmovdqa 32(%rsi),%ymm6 + + vpcmpeqd %ymm1,%ymm4,%ymm7 + + vpand %ymm7,%ymm5,%ymm5 + vpand %ymm7,%ymm6,%ymm6 + + vpxor %ymm5,%ymm2,%ymm2 + vpxor %ymm6,%ymm3,%ymm3 + + vmovdqu %ymm2,0(%rdi) + vmovdqu %ymm3,32(%rdi) + vzeroupper + ret + +L$SEH_end_ecp_nistz256_select_w7_avx2: + + +.p2align 5 +__ecp_nistz256_add_toq: + + xorq %r11,%r11 + addq 0(%rbx),%r12 + adcq 8(%rbx),%r13 + movq %r12,%rax + adcq 16(%rbx),%r8 + adcq 24(%rbx),%r9 + movq %r13,%rbp + adcq $0,%r11 + + subq $-1,%r12 + movq %r8,%rcx + sbbq %r14,%r13 + sbbq $0,%r8 + movq %r9,%r10 + sbbq %r15,%r9 + sbbq $0,%r11 + + cmovcq %rax,%r12 + cmovcq %rbp,%r13 + movq %r12,0(%rdi) + cmovcq %rcx,%r8 + movq %r13,8(%rdi) + cmovcq %r10,%r9 + movq %r8,16(%rdi) + movq %r9,24(%rdi) + + ret + + + + +.p2align 5 +__ecp_nistz256_sub_fromq: + + subq 0(%rbx),%r12 + sbbq 8(%rbx),%r13 + movq %r12,%rax + sbbq 16(%rbx),%r8 + sbbq 24(%rbx),%r9 + movq %r13,%rbp + sbbq %r11,%r11 + + addq $-1,%r12 + movq %r8,%rcx + adcq %r14,%r13 + adcq $0,%r8 + movq %r9,%r10 + adcq %r15,%r9 + testq %r11,%r11 + + cmovzq %rax,%r12 + cmovzq %rbp,%r13 + movq %r12,0(%rdi) + cmovzq %rcx,%r8 + movq %r13,8(%rdi) + cmovzq %r10,%r9 + movq %r8,16(%rdi) + movq %r9,24(%rdi) + + ret + + + + +.p2align 5 +__ecp_nistz256_subq: + + subq %r12,%rax + sbbq %r13,%rbp + movq %rax,%r12 + sbbq %r8,%rcx + sbbq %r9,%r10 + movq %rbp,%r13 + sbbq %r11,%r11 + + addq $-1,%rax + movq %rcx,%r8 + adcq %r14,%rbp + adcq $0,%rcx + movq %r10,%r9 + adcq %r15,%r10 + testq %r11,%r11 + + cmovnzq %rax,%r12 + cmovnzq %rbp,%r13 + cmovnzq %rcx,%r8 + cmovnzq %r10,%r9 + + ret + + + + +.p2align 5 +__ecp_nistz256_mul_by_2q: + + xorq %r11,%r11 + addq %r12,%r12 + adcq %r13,%r13 + movq %r12,%rax + adcq %r8,%r8 + adcq %r9,%r9 + movq %r13,%rbp + adcq $0,%r11 + + subq $-1,%r12 + movq %r8,%rcx + sbbq %r14,%r13 + sbbq $0,%r8 + movq %r9,%r10 + sbbq %r15,%r9 + sbbq $0,%r11 + + cmovcq %rax,%r12 + cmovcq %rbp,%r13 + movq %r12,0(%rdi) + cmovcq %rcx,%r8 + movq %r13,8(%rdi) + cmovcq %r10,%r9 + movq %r8,16(%rdi) + movq %r9,24(%rdi) + + ret + + +.globl _ecp_nistz256_point_double_nohw +.private_extern _ecp_nistz256_point_double_nohw + +.p2align 5 +_ecp_nistz256_point_double_nohw: + +_CET_ENDBR + pushq %rbp + + pushq %rbx + + pushq %r12 + + pushq %r13 + + pushq %r14 + + pushq %r15 + + subq $160+8,%rsp + +L$point_doubleq_body: + +L$point_double_shortcutq: + movdqu 0(%rsi),%xmm0 + movq %rsi,%rbx + movdqu 16(%rsi),%xmm1 + movq 32+0(%rsi),%r12 + movq 32+8(%rsi),%r13 + movq 32+16(%rsi),%r8 + movq 32+24(%rsi),%r9 + movq L$poly+8(%rip),%r14 + movq L$poly+24(%rip),%r15 + movdqa %xmm0,96(%rsp) + movdqa %xmm1,96+16(%rsp) + leaq 32(%rdi),%r10 + leaq 64(%rdi),%r11 +.byte 102,72,15,110,199 +.byte 102,73,15,110,202 +.byte 102,73,15,110,211 + + leaq 0(%rsp),%rdi + call __ecp_nistz256_mul_by_2q + + movq 64+0(%rsi),%rax + movq 64+8(%rsi),%r14 + movq 64+16(%rsi),%r15 + movq 64+24(%rsi),%r8 + leaq 64-0(%rsi),%rsi + leaq 64(%rsp),%rdi + call __ecp_nistz256_sqr_montq + + movq 0+0(%rsp),%rax + movq 8+0(%rsp),%r14 + leaq 0+0(%rsp),%rsi + movq 16+0(%rsp),%r15 + movq 24+0(%rsp),%r8 + leaq 0(%rsp),%rdi + call __ecp_nistz256_sqr_montq + + movq 32(%rbx),%rax + movq 64+0(%rbx),%r9 + movq 64+8(%rbx),%r10 + movq 64+16(%rbx),%r11 + movq 64+24(%rbx),%r12 + leaq 64-0(%rbx),%rsi + leaq 32(%rbx),%rbx +.byte 102,72,15,126,215 + call __ecp_nistz256_mul_montq + call __ecp_nistz256_mul_by_2q + + movq 96+0(%rsp),%r12 + movq 96+8(%rsp),%r13 + leaq 64(%rsp),%rbx + movq 96+16(%rsp),%r8 + movq 96+24(%rsp),%r9 + leaq 32(%rsp),%rdi + call __ecp_nistz256_add_toq + + movq 96+0(%rsp),%r12 + movq 96+8(%rsp),%r13 + leaq 64(%rsp),%rbx + movq 96+16(%rsp),%r8 + movq 96+24(%rsp),%r9 + leaq 64(%rsp),%rdi + call __ecp_nistz256_sub_fromq + + movq 0+0(%rsp),%rax + movq 8+0(%rsp),%r14 + leaq 0+0(%rsp),%rsi + movq 16+0(%rsp),%r15 + movq 24+0(%rsp),%r8 +.byte 102,72,15,126,207 + call __ecp_nistz256_sqr_montq + xorq %r9,%r9 + movq %r12,%rax + addq $-1,%r12 + movq %r13,%r10 + adcq %rsi,%r13 + movq %r14,%rcx + adcq $0,%r14 + movq %r15,%r8 + adcq %rbp,%r15 + adcq $0,%r9 + xorq %rsi,%rsi + testq $1,%rax + + cmovzq %rax,%r12 + cmovzq %r10,%r13 + cmovzq %rcx,%r14 + cmovzq %r8,%r15 + cmovzq %rsi,%r9 + + movq %r13,%rax + shrq $1,%r12 + shlq $63,%rax + movq %r14,%r10 + shrq $1,%r13 + orq %rax,%r12 + shlq $63,%r10 + movq %r15,%rcx + shrq $1,%r14 + orq %r10,%r13 + shlq $63,%rcx + movq %r12,0(%rdi) + shrq $1,%r15 + movq %r13,8(%rdi) + shlq $63,%r9 + orq %rcx,%r14 + orq %r9,%r15 + movq %r14,16(%rdi) + movq %r15,24(%rdi) + movq 64(%rsp),%rax + leaq 64(%rsp),%rbx + movq 0+32(%rsp),%r9 + movq 8+32(%rsp),%r10 + leaq 0+32(%rsp),%rsi + movq 16+32(%rsp),%r11 + movq 24+32(%rsp),%r12 + leaq 32(%rsp),%rdi + call __ecp_nistz256_mul_montq + + leaq 128(%rsp),%rdi + call __ecp_nistz256_mul_by_2q + + leaq 32(%rsp),%rbx + leaq 32(%rsp),%rdi + call __ecp_nistz256_add_toq + + movq 96(%rsp),%rax + leaq 96(%rsp),%rbx + movq 0+0(%rsp),%r9 + movq 8+0(%rsp),%r10 + leaq 0+0(%rsp),%rsi + movq 16+0(%rsp),%r11 + movq 24+0(%rsp),%r12 + leaq 0(%rsp),%rdi + call __ecp_nistz256_mul_montq + + leaq 128(%rsp),%rdi + call __ecp_nistz256_mul_by_2q + + movq 0+32(%rsp),%rax + movq 8+32(%rsp),%r14 + leaq 0+32(%rsp),%rsi + movq 16+32(%rsp),%r15 + movq 24+32(%rsp),%r8 +.byte 102,72,15,126,199 + call __ecp_nistz256_sqr_montq + + leaq 128(%rsp),%rbx + movq %r14,%r8 + movq %r15,%r9 + movq %rsi,%r14 + movq %rbp,%r15 + call __ecp_nistz256_sub_fromq + + movq 0+0(%rsp),%rax + movq 0+8(%rsp),%rbp + movq 0+16(%rsp),%rcx + movq 0+24(%rsp),%r10 + leaq 0(%rsp),%rdi + call __ecp_nistz256_subq + + movq 32(%rsp),%rax + leaq 32(%rsp),%rbx + movq %r12,%r14 + xorl %ecx,%ecx + movq %r12,0+0(%rsp) + movq %r13,%r10 + movq %r13,0+8(%rsp) + cmovzq %r8,%r11 + movq %r8,0+16(%rsp) + leaq 0-0(%rsp),%rsi + cmovzq %r9,%r12 + movq %r9,0+24(%rsp) + movq %r14,%r9 + leaq 0(%rsp),%rdi + call __ecp_nistz256_mul_montq + +.byte 102,72,15,126,203 +.byte 102,72,15,126,207 + call __ecp_nistz256_sub_fromq + + leaq 160+56(%rsp),%rsi + + movq -48(%rsi),%r15 + + movq -40(%rsi),%r14 + + movq -32(%rsi),%r13 + + movq -24(%rsi),%r12 + + movq -16(%rsi),%rbx + + movq -8(%rsi),%rbp + + leaq (%rsi),%rsp + +L$point_doubleq_epilogue: + ret + + +.globl _ecp_nistz256_point_add_nohw +.private_extern _ecp_nistz256_point_add_nohw + +.p2align 5 +_ecp_nistz256_point_add_nohw: + +_CET_ENDBR + pushq %rbp + + pushq %rbx + + pushq %r12 + + pushq %r13 + + pushq %r14 + + pushq %r15 + + subq $576+8,%rsp + +L$point_addq_body: + + movdqu 0(%rsi),%xmm0 + movdqu 16(%rsi),%xmm1 + movdqu 32(%rsi),%xmm2 + movdqu 48(%rsi),%xmm3 + movdqu 64(%rsi),%xmm4 + movdqu 80(%rsi),%xmm5 + movq %rsi,%rbx + movq %rdx,%rsi + movdqa %xmm0,384(%rsp) + movdqa %xmm1,384+16(%rsp) + movdqa %xmm2,416(%rsp) + movdqa %xmm3,416+16(%rsp) + movdqa %xmm4,448(%rsp) + movdqa %xmm5,448+16(%rsp) + por %xmm4,%xmm5 + + movdqu 0(%rsi),%xmm0 + pshufd $0xb1,%xmm5,%xmm3 + movdqu 16(%rsi),%xmm1 + movdqu 32(%rsi),%xmm2 + por %xmm3,%xmm5 + movdqu 48(%rsi),%xmm3 + movq 64+0(%rsi),%rax + movq 64+8(%rsi),%r14 + movq 64+16(%rsi),%r15 + movq 64+24(%rsi),%r8 + movdqa %xmm0,480(%rsp) + pshufd $0x1e,%xmm5,%xmm4 + movdqa %xmm1,480+16(%rsp) + movdqu 64(%rsi),%xmm0 + movdqu 80(%rsi),%xmm1 + movdqa %xmm2,512(%rsp) + movdqa %xmm3,512+16(%rsp) + por %xmm4,%xmm5 + pxor %xmm4,%xmm4 + por %xmm0,%xmm1 +.byte 102,72,15,110,199 + + leaq 64-0(%rsi),%rsi + movq %rax,544+0(%rsp) + movq %r14,544+8(%rsp) + movq %r15,544+16(%rsp) + movq %r8,544+24(%rsp) + leaq 96(%rsp),%rdi + call __ecp_nistz256_sqr_montq + + pcmpeqd %xmm4,%xmm5 + pshufd $0xb1,%xmm1,%xmm4 + por %xmm1,%xmm4 + pshufd $0,%xmm5,%xmm5 + pshufd $0x1e,%xmm4,%xmm3 + por %xmm3,%xmm4 + pxor %xmm3,%xmm3 + pcmpeqd %xmm3,%xmm4 + pshufd $0,%xmm4,%xmm4 + movq 64+0(%rbx),%rax + movq 64+8(%rbx),%r14 + movq 64+16(%rbx),%r15 + movq 64+24(%rbx),%r8 +.byte 102,72,15,110,203 + + leaq 64-0(%rbx),%rsi + leaq 32(%rsp),%rdi + call __ecp_nistz256_sqr_montq + + movq 544(%rsp),%rax + leaq 544(%rsp),%rbx + movq 0+96(%rsp),%r9 + movq 8+96(%rsp),%r10 + leaq 0+96(%rsp),%rsi + movq 16+96(%rsp),%r11 + movq 24+96(%rsp),%r12 + leaq 224(%rsp),%rdi + call __ecp_nistz256_mul_montq + + movq 448(%rsp),%rax + leaq 448(%rsp),%rbx + movq 0+32(%rsp),%r9 + movq 8+32(%rsp),%r10 + leaq 0+32(%rsp),%rsi + movq 16+32(%rsp),%r11 + movq 24+32(%rsp),%r12 + leaq 256(%rsp),%rdi + call __ecp_nistz256_mul_montq + + movq 416(%rsp),%rax + leaq 416(%rsp),%rbx + movq 0+224(%rsp),%r9 + movq 8+224(%rsp),%r10 + leaq 0+224(%rsp),%rsi + movq 16+224(%rsp),%r11 + movq 24+224(%rsp),%r12 + leaq 224(%rsp),%rdi + call __ecp_nistz256_mul_montq + + movq 512(%rsp),%rax + leaq 512(%rsp),%rbx + movq 0+256(%rsp),%r9 + movq 8+256(%rsp),%r10 + leaq 0+256(%rsp),%rsi + movq 16+256(%rsp),%r11 + movq 24+256(%rsp),%r12 + leaq 256(%rsp),%rdi + call __ecp_nistz256_mul_montq + + leaq 224(%rsp),%rbx + leaq 64(%rsp),%rdi + call __ecp_nistz256_sub_fromq + + orq %r13,%r12 + movdqa %xmm4,%xmm2 + orq %r8,%r12 + orq %r9,%r12 + por %xmm5,%xmm2 +.byte 102,73,15,110,220 + + movq 384(%rsp),%rax + leaq 384(%rsp),%rbx + movq 0+96(%rsp),%r9 + movq 8+96(%rsp),%r10 + leaq 0+96(%rsp),%rsi + movq 16+96(%rsp),%r11 + movq 24+96(%rsp),%r12 + leaq 160(%rsp),%rdi + call __ecp_nistz256_mul_montq + + movq 480(%rsp),%rax + leaq 480(%rsp),%rbx + movq 0+32(%rsp),%r9 + movq 8+32(%rsp),%r10 + leaq 0+32(%rsp),%rsi + movq 16+32(%rsp),%r11 + movq 24+32(%rsp),%r12 + leaq 192(%rsp),%rdi + call __ecp_nistz256_mul_montq + + leaq 160(%rsp),%rbx + leaq 0(%rsp),%rdi + call __ecp_nistz256_sub_fromq + + orq %r13,%r12 + orq %r8,%r12 + orq %r9,%r12 + +.byte 102,73,15,126,208 +.byte 102,73,15,126,217 + orq %r8,%r12 +.byte 0x3e + jnz L$add_proceedq + + + + testq %r9,%r9 + jz L$add_doubleq + + + + + + +.byte 102,72,15,126,199 + pxor %xmm0,%xmm0 + movdqu %xmm0,0(%rdi) + movdqu %xmm0,16(%rdi) + movdqu %xmm0,32(%rdi) + movdqu %xmm0,48(%rdi) + movdqu %xmm0,64(%rdi) + movdqu %xmm0,80(%rdi) + jmp L$add_doneq + +.p2align 5 +L$add_doubleq: +.byte 102,72,15,126,206 +.byte 102,72,15,126,199 + addq $416,%rsp + + jmp L$point_double_shortcutq + + +.p2align 5 +L$add_proceedq: + movq 0+64(%rsp),%rax + movq 8+64(%rsp),%r14 + leaq 0+64(%rsp),%rsi + movq 16+64(%rsp),%r15 + movq 24+64(%rsp),%r8 + leaq 96(%rsp),%rdi + call __ecp_nistz256_sqr_montq + + movq 448(%rsp),%rax + leaq 448(%rsp),%rbx + movq 0+0(%rsp),%r9 + movq 8+0(%rsp),%r10 + leaq 0+0(%rsp),%rsi + movq 16+0(%rsp),%r11 + movq 24+0(%rsp),%r12 + leaq 352(%rsp),%rdi + call __ecp_nistz256_mul_montq + + movq 0+0(%rsp),%rax + movq 8+0(%rsp),%r14 + leaq 0+0(%rsp),%rsi + movq 16+0(%rsp),%r15 + movq 24+0(%rsp),%r8 + leaq 32(%rsp),%rdi + call __ecp_nistz256_sqr_montq + + movq 544(%rsp),%rax + leaq 544(%rsp),%rbx + movq 0+352(%rsp),%r9 + movq 8+352(%rsp),%r10 + leaq 0+352(%rsp),%rsi + movq 16+352(%rsp),%r11 + movq 24+352(%rsp),%r12 + leaq 352(%rsp),%rdi + call __ecp_nistz256_mul_montq + + movq 0(%rsp),%rax + leaq 0(%rsp),%rbx + movq 0+32(%rsp),%r9 + movq 8+32(%rsp),%r10 + leaq 0+32(%rsp),%rsi + movq 16+32(%rsp),%r11 + movq 24+32(%rsp),%r12 + leaq 128(%rsp),%rdi + call __ecp_nistz256_mul_montq + + movq 160(%rsp),%rax + leaq 160(%rsp),%rbx + movq 0+32(%rsp),%r9 + movq 8+32(%rsp),%r10 + leaq 0+32(%rsp),%rsi + movq 16+32(%rsp),%r11 + movq 24+32(%rsp),%r12 + leaq 192(%rsp),%rdi + call __ecp_nistz256_mul_montq + + + + + xorq %r11,%r11 + addq %r12,%r12 + leaq 96(%rsp),%rsi + adcq %r13,%r13 + movq %r12,%rax + adcq %r8,%r8 + adcq %r9,%r9 + movq %r13,%rbp + adcq $0,%r11 + + subq $-1,%r12 + movq %r8,%rcx + sbbq %r14,%r13 + sbbq $0,%r8 + movq %r9,%r10 + sbbq %r15,%r9 + sbbq $0,%r11 + + cmovcq %rax,%r12 + movq 0(%rsi),%rax + cmovcq %rbp,%r13 + movq 8(%rsi),%rbp + cmovcq %rcx,%r8 + movq 16(%rsi),%rcx + cmovcq %r10,%r9 + movq 24(%rsi),%r10 + + call __ecp_nistz256_subq + + leaq 128(%rsp),%rbx + leaq 288(%rsp),%rdi + call __ecp_nistz256_sub_fromq + + movq 192+0(%rsp),%rax + movq 192+8(%rsp),%rbp + movq 192+16(%rsp),%rcx + movq 192+24(%rsp),%r10 + leaq 320(%rsp),%rdi + + call __ecp_nistz256_subq + + movq %r12,0(%rdi) + movq %r13,8(%rdi) + movq %r8,16(%rdi) + movq %r9,24(%rdi) + movq 128(%rsp),%rax + leaq 128(%rsp),%rbx + movq 0+224(%rsp),%r9 + movq 8+224(%rsp),%r10 + leaq 0+224(%rsp),%rsi + movq 16+224(%rsp),%r11 + movq 24+224(%rsp),%r12 + leaq 256(%rsp),%rdi + call __ecp_nistz256_mul_montq + + movq 320(%rsp),%rax + leaq 320(%rsp),%rbx + movq 0+64(%rsp),%r9 + movq 8+64(%rsp),%r10 + leaq 0+64(%rsp),%rsi + movq 16+64(%rsp),%r11 + movq 24+64(%rsp),%r12 + leaq 320(%rsp),%rdi + call __ecp_nistz256_mul_montq + + leaq 256(%rsp),%rbx + leaq 320(%rsp),%rdi + call __ecp_nistz256_sub_fromq + +.byte 102,72,15,126,199 + + movdqa %xmm5,%xmm0 + movdqa %xmm5,%xmm1 + pandn 352(%rsp),%xmm0 + movdqa %xmm5,%xmm2 + pandn 352+16(%rsp),%xmm1 + movdqa %xmm5,%xmm3 + pand 544(%rsp),%xmm2 + pand 544+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + + movdqa %xmm4,%xmm0 + movdqa %xmm4,%xmm1 + pandn %xmm2,%xmm0 + movdqa %xmm4,%xmm2 + pandn %xmm3,%xmm1 + movdqa %xmm4,%xmm3 + pand 448(%rsp),%xmm2 + pand 448+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + movdqu %xmm2,64(%rdi) + movdqu %xmm3,80(%rdi) + + movdqa %xmm5,%xmm0 + movdqa %xmm5,%xmm1 + pandn 288(%rsp),%xmm0 + movdqa %xmm5,%xmm2 + pandn 288+16(%rsp),%xmm1 + movdqa %xmm5,%xmm3 + pand 480(%rsp),%xmm2 + pand 480+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + + movdqa %xmm4,%xmm0 + movdqa %xmm4,%xmm1 + pandn %xmm2,%xmm0 + movdqa %xmm4,%xmm2 + pandn %xmm3,%xmm1 + movdqa %xmm4,%xmm3 + pand 384(%rsp),%xmm2 + pand 384+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + movdqu %xmm2,0(%rdi) + movdqu %xmm3,16(%rdi) + + movdqa %xmm5,%xmm0 + movdqa %xmm5,%xmm1 + pandn 320(%rsp),%xmm0 + movdqa %xmm5,%xmm2 + pandn 320+16(%rsp),%xmm1 + movdqa %xmm5,%xmm3 + pand 512(%rsp),%xmm2 + pand 512+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + + movdqa %xmm4,%xmm0 + movdqa %xmm4,%xmm1 + pandn %xmm2,%xmm0 + movdqa %xmm4,%xmm2 + pandn %xmm3,%xmm1 + movdqa %xmm4,%xmm3 + pand 416(%rsp),%xmm2 + pand 416+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + movdqu %xmm2,32(%rdi) + movdqu %xmm3,48(%rdi) + +L$add_doneq: + leaq 576+56(%rsp),%rsi + + movq -48(%rsi),%r15 + + movq -40(%rsi),%r14 + + movq -32(%rsi),%r13 + + movq -24(%rsi),%r12 + + movq -16(%rsi),%rbx + + movq -8(%rsi),%rbp + + leaq (%rsi),%rsp + +L$point_addq_epilogue: + ret + + +.globl _ecp_nistz256_point_add_affine_nohw +.private_extern _ecp_nistz256_point_add_affine_nohw + +.p2align 5 +_ecp_nistz256_point_add_affine_nohw: + +_CET_ENDBR + pushq %rbp + + pushq %rbx + + pushq %r12 + + pushq %r13 + + pushq %r14 + + pushq %r15 + + subq $480+8,%rsp + +L$add_affineq_body: + + movdqu 0(%rsi),%xmm0 + movq %rdx,%rbx + movdqu 16(%rsi),%xmm1 + movdqu 32(%rsi),%xmm2 + movdqu 48(%rsi),%xmm3 + movdqu 64(%rsi),%xmm4 + movdqu 80(%rsi),%xmm5 + movq 64+0(%rsi),%rax + movq 64+8(%rsi),%r14 + movq 64+16(%rsi),%r15 + movq 64+24(%rsi),%r8 + movdqa %xmm0,320(%rsp) + movdqa %xmm1,320+16(%rsp) + movdqa %xmm2,352(%rsp) + movdqa %xmm3,352+16(%rsp) + movdqa %xmm4,384(%rsp) + movdqa %xmm5,384+16(%rsp) + por %xmm4,%xmm5 + + movdqu 0(%rbx),%xmm0 + pshufd $0xb1,%xmm5,%xmm3 + movdqu 16(%rbx),%xmm1 + movdqu 32(%rbx),%xmm2 + por %xmm3,%xmm5 + movdqu 48(%rbx),%xmm3 + movdqa %xmm0,416(%rsp) + pshufd $0x1e,%xmm5,%xmm4 + movdqa %xmm1,416+16(%rsp) + por %xmm0,%xmm1 +.byte 102,72,15,110,199 + movdqa %xmm2,448(%rsp) + movdqa %xmm3,448+16(%rsp) + por %xmm2,%xmm3 + por %xmm4,%xmm5 + pxor %xmm4,%xmm4 + por %xmm1,%xmm3 + + leaq 64-0(%rsi),%rsi + leaq 32(%rsp),%rdi + call __ecp_nistz256_sqr_montq + + pcmpeqd %xmm4,%xmm5 + pshufd $0xb1,%xmm3,%xmm4 + movq 0(%rbx),%rax + + movq %r12,%r9 + por %xmm3,%xmm4 + pshufd $0,%xmm5,%xmm5 + pshufd $0x1e,%xmm4,%xmm3 + movq %r13,%r10 + por %xmm3,%xmm4 + pxor %xmm3,%xmm3 + movq %r14,%r11 + pcmpeqd %xmm3,%xmm4 + pshufd $0,%xmm4,%xmm4 + + leaq 32-0(%rsp),%rsi + movq %r15,%r12 + leaq 0(%rsp),%rdi + call __ecp_nistz256_mul_montq + + leaq 320(%rsp),%rbx + leaq 64(%rsp),%rdi + call __ecp_nistz256_sub_fromq + + movq 384(%rsp),%rax + leaq 384(%rsp),%rbx + movq 0+32(%rsp),%r9 + movq 8+32(%rsp),%r10 + leaq 0+32(%rsp),%rsi + movq 16+32(%rsp),%r11 + movq 24+32(%rsp),%r12 + leaq 32(%rsp),%rdi + call __ecp_nistz256_mul_montq + + movq 384(%rsp),%rax + leaq 384(%rsp),%rbx + movq 0+64(%rsp),%r9 + movq 8+64(%rsp),%r10 + leaq 0+64(%rsp),%rsi + movq 16+64(%rsp),%r11 + movq 24+64(%rsp),%r12 + leaq 288(%rsp),%rdi + call __ecp_nistz256_mul_montq + + movq 448(%rsp),%rax + leaq 448(%rsp),%rbx + movq 0+32(%rsp),%r9 + movq 8+32(%rsp),%r10 + leaq 0+32(%rsp),%rsi + movq 16+32(%rsp),%r11 + movq 24+32(%rsp),%r12 + leaq 32(%rsp),%rdi + call __ecp_nistz256_mul_montq + + leaq 352(%rsp),%rbx + leaq 96(%rsp),%rdi + call __ecp_nistz256_sub_fromq + + movq 0+64(%rsp),%rax + movq 8+64(%rsp),%r14 + leaq 0+64(%rsp),%rsi + movq 16+64(%rsp),%r15 + movq 24+64(%rsp),%r8 + leaq 128(%rsp),%rdi + call __ecp_nistz256_sqr_montq + + movq 0+96(%rsp),%rax + movq 8+96(%rsp),%r14 + leaq 0+96(%rsp),%rsi + movq 16+96(%rsp),%r15 + movq 24+96(%rsp),%r8 + leaq 192(%rsp),%rdi + call __ecp_nistz256_sqr_montq + + movq 128(%rsp),%rax + leaq 128(%rsp),%rbx + movq 0+64(%rsp),%r9 + movq 8+64(%rsp),%r10 + leaq 0+64(%rsp),%rsi + movq 16+64(%rsp),%r11 + movq 24+64(%rsp),%r12 + leaq 160(%rsp),%rdi + call __ecp_nistz256_mul_montq + + movq 320(%rsp),%rax + leaq 320(%rsp),%rbx + movq 0+128(%rsp),%r9 + movq 8+128(%rsp),%r10 + leaq 0+128(%rsp),%rsi + movq 16+128(%rsp),%r11 + movq 24+128(%rsp),%r12 + leaq 0(%rsp),%rdi + call __ecp_nistz256_mul_montq + + + + + xorq %r11,%r11 + addq %r12,%r12 + leaq 192(%rsp),%rsi + adcq %r13,%r13 + movq %r12,%rax + adcq %r8,%r8 + adcq %r9,%r9 + movq %r13,%rbp + adcq $0,%r11 + + subq $-1,%r12 + movq %r8,%rcx + sbbq %r14,%r13 + sbbq $0,%r8 + movq %r9,%r10 + sbbq %r15,%r9 + sbbq $0,%r11 + + cmovcq %rax,%r12 + movq 0(%rsi),%rax + cmovcq %rbp,%r13 + movq 8(%rsi),%rbp + cmovcq %rcx,%r8 + movq 16(%rsi),%rcx + cmovcq %r10,%r9 + movq 24(%rsi),%r10 + + call __ecp_nistz256_subq + + leaq 160(%rsp),%rbx + leaq 224(%rsp),%rdi + call __ecp_nistz256_sub_fromq + + movq 0+0(%rsp),%rax + movq 0+8(%rsp),%rbp + movq 0+16(%rsp),%rcx + movq 0+24(%rsp),%r10 + leaq 64(%rsp),%rdi + + call __ecp_nistz256_subq + + movq %r12,0(%rdi) + movq %r13,8(%rdi) + movq %r8,16(%rdi) + movq %r9,24(%rdi) + movq 352(%rsp),%rax + leaq 352(%rsp),%rbx + movq 0+160(%rsp),%r9 + movq 8+160(%rsp),%r10 + leaq 0+160(%rsp),%rsi + movq 16+160(%rsp),%r11 + movq 24+160(%rsp),%r12 + leaq 32(%rsp),%rdi + call __ecp_nistz256_mul_montq + + movq 96(%rsp),%rax + leaq 96(%rsp),%rbx + movq 0+64(%rsp),%r9 + movq 8+64(%rsp),%r10 + leaq 0+64(%rsp),%rsi + movq 16+64(%rsp),%r11 + movq 24+64(%rsp),%r12 + leaq 64(%rsp),%rdi + call __ecp_nistz256_mul_montq + + leaq 32(%rsp),%rbx + leaq 256(%rsp),%rdi + call __ecp_nistz256_sub_fromq + +.byte 102,72,15,126,199 + + movdqa %xmm5,%xmm0 + movdqa %xmm5,%xmm1 + pandn 288(%rsp),%xmm0 + movdqa %xmm5,%xmm2 + pandn 288+16(%rsp),%xmm1 + movdqa %xmm5,%xmm3 + pand L$ONE_mont(%rip),%xmm2 + pand L$ONE_mont+16(%rip),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + + movdqa %xmm4,%xmm0 + movdqa %xmm4,%xmm1 + pandn %xmm2,%xmm0 + movdqa %xmm4,%xmm2 + pandn %xmm3,%xmm1 + movdqa %xmm4,%xmm3 + pand 384(%rsp),%xmm2 + pand 384+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + movdqu %xmm2,64(%rdi) + movdqu %xmm3,80(%rdi) + + movdqa %xmm5,%xmm0 + movdqa %xmm5,%xmm1 + pandn 224(%rsp),%xmm0 + movdqa %xmm5,%xmm2 + pandn 224+16(%rsp),%xmm1 + movdqa %xmm5,%xmm3 + pand 416(%rsp),%xmm2 + pand 416+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + + movdqa %xmm4,%xmm0 + movdqa %xmm4,%xmm1 + pandn %xmm2,%xmm0 + movdqa %xmm4,%xmm2 + pandn %xmm3,%xmm1 + movdqa %xmm4,%xmm3 + pand 320(%rsp),%xmm2 + pand 320+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + movdqu %xmm2,0(%rdi) + movdqu %xmm3,16(%rdi) + + movdqa %xmm5,%xmm0 + movdqa %xmm5,%xmm1 + pandn 256(%rsp),%xmm0 + movdqa %xmm5,%xmm2 + pandn 256+16(%rsp),%xmm1 + movdqa %xmm5,%xmm3 + pand 448(%rsp),%xmm2 + pand 448+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + + movdqa %xmm4,%xmm0 + movdqa %xmm4,%xmm1 + pandn %xmm2,%xmm0 + movdqa %xmm4,%xmm2 + pandn %xmm3,%xmm1 + movdqa %xmm4,%xmm3 + pand 352(%rsp),%xmm2 + pand 352+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + movdqu %xmm2,32(%rdi) + movdqu %xmm3,48(%rdi) + + leaq 480+56(%rsp),%rsi + + movq -48(%rsi),%r15 + + movq -40(%rsi),%r14 + + movq -32(%rsi),%r13 + + movq -24(%rsi),%r12 + + movq -16(%rsi),%rbx + + movq -8(%rsi),%rbp + + leaq (%rsi),%rsp + +L$add_affineq_epilogue: + ret + + + +.p2align 5 +__ecp_nistz256_add_tox: + + xorq %r11,%r11 + adcq 0(%rbx),%r12 + adcq 8(%rbx),%r13 + movq %r12,%rax + adcq 16(%rbx),%r8 + adcq 24(%rbx),%r9 + movq %r13,%rbp + adcq $0,%r11 + + xorq %r10,%r10 + sbbq $-1,%r12 + movq %r8,%rcx + sbbq %r14,%r13 + sbbq $0,%r8 + movq %r9,%r10 + sbbq %r15,%r9 + sbbq $0,%r11 + + cmovcq %rax,%r12 + cmovcq %rbp,%r13 + movq %r12,0(%rdi) + cmovcq %rcx,%r8 + movq %r13,8(%rdi) + cmovcq %r10,%r9 + movq %r8,16(%rdi) + movq %r9,24(%rdi) + + ret + + + + +.p2align 5 +__ecp_nistz256_sub_fromx: + + xorq %r11,%r11 + sbbq 0(%rbx),%r12 + sbbq 8(%rbx),%r13 + movq %r12,%rax + sbbq 16(%rbx),%r8 + sbbq 24(%rbx),%r9 + movq %r13,%rbp + sbbq $0,%r11 + + xorq %r10,%r10 + adcq $-1,%r12 + movq %r8,%rcx + adcq %r14,%r13 + adcq $0,%r8 + movq %r9,%r10 + adcq %r15,%r9 + + btq $0,%r11 + cmovncq %rax,%r12 + cmovncq %rbp,%r13 + movq %r12,0(%rdi) + cmovncq %rcx,%r8 + movq %r13,8(%rdi) + cmovncq %r10,%r9 + movq %r8,16(%rdi) + movq %r9,24(%rdi) + + ret + + + + +.p2align 5 +__ecp_nistz256_subx: + + xorq %r11,%r11 + sbbq %r12,%rax + sbbq %r13,%rbp + movq %rax,%r12 + sbbq %r8,%rcx + sbbq %r9,%r10 + movq %rbp,%r13 + sbbq $0,%r11 + + xorq %r9,%r9 + adcq $-1,%rax + movq %rcx,%r8 + adcq %r14,%rbp + adcq $0,%rcx + movq %r10,%r9 + adcq %r15,%r10 + + btq $0,%r11 + cmovcq %rax,%r12 + cmovcq %rbp,%r13 + cmovcq %rcx,%r8 + cmovcq %r10,%r9 + + ret + + + + +.p2align 5 +__ecp_nistz256_mul_by_2x: + + xorq %r11,%r11 + adcq %r12,%r12 + adcq %r13,%r13 + movq %r12,%rax + adcq %r8,%r8 + adcq %r9,%r9 + movq %r13,%rbp + adcq $0,%r11 + + xorq %r10,%r10 + sbbq $-1,%r12 + movq %r8,%rcx + sbbq %r14,%r13 + sbbq $0,%r8 + movq %r9,%r10 + sbbq %r15,%r9 + sbbq $0,%r11 + + cmovcq %rax,%r12 + cmovcq %rbp,%r13 + movq %r12,0(%rdi) + cmovcq %rcx,%r8 + movq %r13,8(%rdi) + cmovcq %r10,%r9 + movq %r8,16(%rdi) + movq %r9,24(%rdi) + + ret + + +.globl _ecp_nistz256_point_double_adx +.private_extern _ecp_nistz256_point_double_adx + +.p2align 5 +_ecp_nistz256_point_double_adx: + +_CET_ENDBR + pushq %rbp + + pushq %rbx + + pushq %r12 + + pushq %r13 + + pushq %r14 + + pushq %r15 + + subq $160+8,%rsp + +L$point_doublex_body: + +L$point_double_shortcutx: + movdqu 0(%rsi),%xmm0 + movq %rsi,%rbx + movdqu 16(%rsi),%xmm1 + movq 32+0(%rsi),%r12 + movq 32+8(%rsi),%r13 + movq 32+16(%rsi),%r8 + movq 32+24(%rsi),%r9 + movq L$poly+8(%rip),%r14 + movq L$poly+24(%rip),%r15 + movdqa %xmm0,96(%rsp) + movdqa %xmm1,96+16(%rsp) + leaq 32(%rdi),%r10 + leaq 64(%rdi),%r11 +.byte 102,72,15,110,199 +.byte 102,73,15,110,202 +.byte 102,73,15,110,211 + + leaq 0(%rsp),%rdi + call __ecp_nistz256_mul_by_2x + + movq 64+0(%rsi),%rdx + movq 64+8(%rsi),%r14 + movq 64+16(%rsi),%r15 + movq 64+24(%rsi),%r8 + leaq 64-128(%rsi),%rsi + leaq 64(%rsp),%rdi + call __ecp_nistz256_sqr_montx + + movq 0+0(%rsp),%rdx + movq 8+0(%rsp),%r14 + leaq -128+0(%rsp),%rsi + movq 16+0(%rsp),%r15 + movq 24+0(%rsp),%r8 + leaq 0(%rsp),%rdi + call __ecp_nistz256_sqr_montx + + movq 32(%rbx),%rdx + movq 64+0(%rbx),%r9 + movq 64+8(%rbx),%r10 + movq 64+16(%rbx),%r11 + movq 64+24(%rbx),%r12 + leaq 64-128(%rbx),%rsi + leaq 32(%rbx),%rbx +.byte 102,72,15,126,215 + call __ecp_nistz256_mul_montx + call __ecp_nistz256_mul_by_2x + + movq 96+0(%rsp),%r12 + movq 96+8(%rsp),%r13 + leaq 64(%rsp),%rbx + movq 96+16(%rsp),%r8 + movq 96+24(%rsp),%r9 + leaq 32(%rsp),%rdi + call __ecp_nistz256_add_tox + + movq 96+0(%rsp),%r12 + movq 96+8(%rsp),%r13 + leaq 64(%rsp),%rbx + movq 96+16(%rsp),%r8 + movq 96+24(%rsp),%r9 + leaq 64(%rsp),%rdi + call __ecp_nistz256_sub_fromx + + movq 0+0(%rsp),%rdx + movq 8+0(%rsp),%r14 + leaq -128+0(%rsp),%rsi + movq 16+0(%rsp),%r15 + movq 24+0(%rsp),%r8 +.byte 102,72,15,126,207 + call __ecp_nistz256_sqr_montx + xorq %r9,%r9 + movq %r12,%rax + addq $-1,%r12 + movq %r13,%r10 + adcq %rsi,%r13 + movq %r14,%rcx + adcq $0,%r14 + movq %r15,%r8 + adcq %rbp,%r15 + adcq $0,%r9 + xorq %rsi,%rsi + testq $1,%rax + + cmovzq %rax,%r12 + cmovzq %r10,%r13 + cmovzq %rcx,%r14 + cmovzq %r8,%r15 + cmovzq %rsi,%r9 + + movq %r13,%rax + shrq $1,%r12 + shlq $63,%rax + movq %r14,%r10 + shrq $1,%r13 + orq %rax,%r12 + shlq $63,%r10 + movq %r15,%rcx + shrq $1,%r14 + orq %r10,%r13 + shlq $63,%rcx + movq %r12,0(%rdi) + shrq $1,%r15 + movq %r13,8(%rdi) + shlq $63,%r9 + orq %rcx,%r14 + orq %r9,%r15 + movq %r14,16(%rdi) + movq %r15,24(%rdi) + movq 64(%rsp),%rdx + leaq 64(%rsp),%rbx + movq 0+32(%rsp),%r9 + movq 8+32(%rsp),%r10 + leaq -128+32(%rsp),%rsi + movq 16+32(%rsp),%r11 + movq 24+32(%rsp),%r12 + leaq 32(%rsp),%rdi + call __ecp_nistz256_mul_montx + + leaq 128(%rsp),%rdi + call __ecp_nistz256_mul_by_2x + + leaq 32(%rsp),%rbx + leaq 32(%rsp),%rdi + call __ecp_nistz256_add_tox + + movq 96(%rsp),%rdx + leaq 96(%rsp),%rbx + movq 0+0(%rsp),%r9 + movq 8+0(%rsp),%r10 + leaq -128+0(%rsp),%rsi + movq 16+0(%rsp),%r11 + movq 24+0(%rsp),%r12 + leaq 0(%rsp),%rdi + call __ecp_nistz256_mul_montx + + leaq 128(%rsp),%rdi + call __ecp_nistz256_mul_by_2x + + movq 0+32(%rsp),%rdx + movq 8+32(%rsp),%r14 + leaq -128+32(%rsp),%rsi + movq 16+32(%rsp),%r15 + movq 24+32(%rsp),%r8 +.byte 102,72,15,126,199 + call __ecp_nistz256_sqr_montx + + leaq 128(%rsp),%rbx + movq %r14,%r8 + movq %r15,%r9 + movq %rsi,%r14 + movq %rbp,%r15 + call __ecp_nistz256_sub_fromx + + movq 0+0(%rsp),%rax + movq 0+8(%rsp),%rbp + movq 0+16(%rsp),%rcx + movq 0+24(%rsp),%r10 + leaq 0(%rsp),%rdi + call __ecp_nistz256_subx + + movq 32(%rsp),%rdx + leaq 32(%rsp),%rbx + movq %r12,%r14 + xorl %ecx,%ecx + movq %r12,0+0(%rsp) + movq %r13,%r10 + movq %r13,0+8(%rsp) + cmovzq %r8,%r11 + movq %r8,0+16(%rsp) + leaq 0-128(%rsp),%rsi + cmovzq %r9,%r12 + movq %r9,0+24(%rsp) + movq %r14,%r9 + leaq 0(%rsp),%rdi + call __ecp_nistz256_mul_montx + +.byte 102,72,15,126,203 +.byte 102,72,15,126,207 + call __ecp_nistz256_sub_fromx + + leaq 160+56(%rsp),%rsi + + movq -48(%rsi),%r15 + + movq -40(%rsi),%r14 + + movq -32(%rsi),%r13 + + movq -24(%rsi),%r12 + + movq -16(%rsi),%rbx + + movq -8(%rsi),%rbp + + leaq (%rsi),%rsp + +L$point_doublex_epilogue: + ret + + +.globl _ecp_nistz256_point_add_adx +.private_extern _ecp_nistz256_point_add_adx + +.p2align 5 +_ecp_nistz256_point_add_adx: + +_CET_ENDBR + pushq %rbp + + pushq %rbx + + pushq %r12 + + pushq %r13 + + pushq %r14 + + pushq %r15 + + subq $576+8,%rsp + +L$point_addx_body: + + movdqu 0(%rsi),%xmm0 + movdqu 16(%rsi),%xmm1 + movdqu 32(%rsi),%xmm2 + movdqu 48(%rsi),%xmm3 + movdqu 64(%rsi),%xmm4 + movdqu 80(%rsi),%xmm5 + movq %rsi,%rbx + movq %rdx,%rsi + movdqa %xmm0,384(%rsp) + movdqa %xmm1,384+16(%rsp) + movdqa %xmm2,416(%rsp) + movdqa %xmm3,416+16(%rsp) + movdqa %xmm4,448(%rsp) + movdqa %xmm5,448+16(%rsp) + por %xmm4,%xmm5 + + movdqu 0(%rsi),%xmm0 + pshufd $0xb1,%xmm5,%xmm3 + movdqu 16(%rsi),%xmm1 + movdqu 32(%rsi),%xmm2 + por %xmm3,%xmm5 + movdqu 48(%rsi),%xmm3 + movq 64+0(%rsi),%rdx + movq 64+8(%rsi),%r14 + movq 64+16(%rsi),%r15 + movq 64+24(%rsi),%r8 + movdqa %xmm0,480(%rsp) + pshufd $0x1e,%xmm5,%xmm4 + movdqa %xmm1,480+16(%rsp) + movdqu 64(%rsi),%xmm0 + movdqu 80(%rsi),%xmm1 + movdqa %xmm2,512(%rsp) + movdqa %xmm3,512+16(%rsp) + por %xmm4,%xmm5 + pxor %xmm4,%xmm4 + por %xmm0,%xmm1 +.byte 102,72,15,110,199 + + leaq 64-128(%rsi),%rsi + movq %rdx,544+0(%rsp) + movq %r14,544+8(%rsp) + movq %r15,544+16(%rsp) + movq %r8,544+24(%rsp) + leaq 96(%rsp),%rdi + call __ecp_nistz256_sqr_montx + + pcmpeqd %xmm4,%xmm5 + pshufd $0xb1,%xmm1,%xmm4 + por %xmm1,%xmm4 + pshufd $0,%xmm5,%xmm5 + pshufd $0x1e,%xmm4,%xmm3 + por %xmm3,%xmm4 + pxor %xmm3,%xmm3 + pcmpeqd %xmm3,%xmm4 + pshufd $0,%xmm4,%xmm4 + movq 64+0(%rbx),%rdx + movq 64+8(%rbx),%r14 + movq 64+16(%rbx),%r15 + movq 64+24(%rbx),%r8 +.byte 102,72,15,110,203 + + leaq 64-128(%rbx),%rsi + leaq 32(%rsp),%rdi + call __ecp_nistz256_sqr_montx + + movq 544(%rsp),%rdx + leaq 544(%rsp),%rbx + movq 0+96(%rsp),%r9 + movq 8+96(%rsp),%r10 + leaq -128+96(%rsp),%rsi + movq 16+96(%rsp),%r11 + movq 24+96(%rsp),%r12 + leaq 224(%rsp),%rdi + call __ecp_nistz256_mul_montx + + movq 448(%rsp),%rdx + leaq 448(%rsp),%rbx + movq 0+32(%rsp),%r9 + movq 8+32(%rsp),%r10 + leaq -128+32(%rsp),%rsi + movq 16+32(%rsp),%r11 + movq 24+32(%rsp),%r12 + leaq 256(%rsp),%rdi + call __ecp_nistz256_mul_montx + + movq 416(%rsp),%rdx + leaq 416(%rsp),%rbx + movq 0+224(%rsp),%r9 + movq 8+224(%rsp),%r10 + leaq -128+224(%rsp),%rsi + movq 16+224(%rsp),%r11 + movq 24+224(%rsp),%r12 + leaq 224(%rsp),%rdi + call __ecp_nistz256_mul_montx + + movq 512(%rsp),%rdx + leaq 512(%rsp),%rbx + movq 0+256(%rsp),%r9 + movq 8+256(%rsp),%r10 + leaq -128+256(%rsp),%rsi + movq 16+256(%rsp),%r11 + movq 24+256(%rsp),%r12 + leaq 256(%rsp),%rdi + call __ecp_nistz256_mul_montx + + leaq 224(%rsp),%rbx + leaq 64(%rsp),%rdi + call __ecp_nistz256_sub_fromx + + orq %r13,%r12 + movdqa %xmm4,%xmm2 + orq %r8,%r12 + orq %r9,%r12 + por %xmm5,%xmm2 +.byte 102,73,15,110,220 + + movq 384(%rsp),%rdx + leaq 384(%rsp),%rbx + movq 0+96(%rsp),%r9 + movq 8+96(%rsp),%r10 + leaq -128+96(%rsp),%rsi + movq 16+96(%rsp),%r11 + movq 24+96(%rsp),%r12 + leaq 160(%rsp),%rdi + call __ecp_nistz256_mul_montx + + movq 480(%rsp),%rdx + leaq 480(%rsp),%rbx + movq 0+32(%rsp),%r9 + movq 8+32(%rsp),%r10 + leaq -128+32(%rsp),%rsi + movq 16+32(%rsp),%r11 + movq 24+32(%rsp),%r12 + leaq 192(%rsp),%rdi + call __ecp_nistz256_mul_montx + + leaq 160(%rsp),%rbx + leaq 0(%rsp),%rdi + call __ecp_nistz256_sub_fromx + + orq %r13,%r12 + orq %r8,%r12 + orq %r9,%r12 + +.byte 102,73,15,126,208 +.byte 102,73,15,126,217 + orq %r8,%r12 +.byte 0x3e + jnz L$add_proceedx + + + + testq %r9,%r9 + jz L$add_doublex + + + + + + +.byte 102,72,15,126,199 + pxor %xmm0,%xmm0 + movdqu %xmm0,0(%rdi) + movdqu %xmm0,16(%rdi) + movdqu %xmm0,32(%rdi) + movdqu %xmm0,48(%rdi) + movdqu %xmm0,64(%rdi) + movdqu %xmm0,80(%rdi) + jmp L$add_donex + +.p2align 5 +L$add_doublex: +.byte 102,72,15,126,206 +.byte 102,72,15,126,199 + addq $416,%rsp + + jmp L$point_double_shortcutx + + +.p2align 5 +L$add_proceedx: + movq 0+64(%rsp),%rdx + movq 8+64(%rsp),%r14 + leaq -128+64(%rsp),%rsi + movq 16+64(%rsp),%r15 + movq 24+64(%rsp),%r8 + leaq 96(%rsp),%rdi + call __ecp_nistz256_sqr_montx + + movq 448(%rsp),%rdx + leaq 448(%rsp),%rbx + movq 0+0(%rsp),%r9 + movq 8+0(%rsp),%r10 + leaq -128+0(%rsp),%rsi + movq 16+0(%rsp),%r11 + movq 24+0(%rsp),%r12 + leaq 352(%rsp),%rdi + call __ecp_nistz256_mul_montx + + movq 0+0(%rsp),%rdx + movq 8+0(%rsp),%r14 + leaq -128+0(%rsp),%rsi + movq 16+0(%rsp),%r15 + movq 24+0(%rsp),%r8 + leaq 32(%rsp),%rdi + call __ecp_nistz256_sqr_montx + + movq 544(%rsp),%rdx + leaq 544(%rsp),%rbx + movq 0+352(%rsp),%r9 + movq 8+352(%rsp),%r10 + leaq -128+352(%rsp),%rsi + movq 16+352(%rsp),%r11 + movq 24+352(%rsp),%r12 + leaq 352(%rsp),%rdi + call __ecp_nistz256_mul_montx + + movq 0(%rsp),%rdx + leaq 0(%rsp),%rbx + movq 0+32(%rsp),%r9 + movq 8+32(%rsp),%r10 + leaq -128+32(%rsp),%rsi + movq 16+32(%rsp),%r11 + movq 24+32(%rsp),%r12 + leaq 128(%rsp),%rdi + call __ecp_nistz256_mul_montx + + movq 160(%rsp),%rdx + leaq 160(%rsp),%rbx + movq 0+32(%rsp),%r9 + movq 8+32(%rsp),%r10 + leaq -128+32(%rsp),%rsi + movq 16+32(%rsp),%r11 + movq 24+32(%rsp),%r12 + leaq 192(%rsp),%rdi + call __ecp_nistz256_mul_montx + + + + + xorq %r11,%r11 + addq %r12,%r12 + leaq 96(%rsp),%rsi + adcq %r13,%r13 + movq %r12,%rax + adcq %r8,%r8 + adcq %r9,%r9 + movq %r13,%rbp + adcq $0,%r11 + + subq $-1,%r12 + movq %r8,%rcx + sbbq %r14,%r13 + sbbq $0,%r8 + movq %r9,%r10 + sbbq %r15,%r9 + sbbq $0,%r11 + + cmovcq %rax,%r12 + movq 0(%rsi),%rax + cmovcq %rbp,%r13 + movq 8(%rsi),%rbp + cmovcq %rcx,%r8 + movq 16(%rsi),%rcx + cmovcq %r10,%r9 + movq 24(%rsi),%r10 + + call __ecp_nistz256_subx + + leaq 128(%rsp),%rbx + leaq 288(%rsp),%rdi + call __ecp_nistz256_sub_fromx + + movq 192+0(%rsp),%rax + movq 192+8(%rsp),%rbp + movq 192+16(%rsp),%rcx + movq 192+24(%rsp),%r10 + leaq 320(%rsp),%rdi + + call __ecp_nistz256_subx + + movq %r12,0(%rdi) + movq %r13,8(%rdi) + movq %r8,16(%rdi) + movq %r9,24(%rdi) + movq 128(%rsp),%rdx + leaq 128(%rsp),%rbx + movq 0+224(%rsp),%r9 + movq 8+224(%rsp),%r10 + leaq -128+224(%rsp),%rsi + movq 16+224(%rsp),%r11 + movq 24+224(%rsp),%r12 + leaq 256(%rsp),%rdi + call __ecp_nistz256_mul_montx + + movq 320(%rsp),%rdx + leaq 320(%rsp),%rbx + movq 0+64(%rsp),%r9 + movq 8+64(%rsp),%r10 + leaq -128+64(%rsp),%rsi + movq 16+64(%rsp),%r11 + movq 24+64(%rsp),%r12 + leaq 320(%rsp),%rdi + call __ecp_nistz256_mul_montx + + leaq 256(%rsp),%rbx + leaq 320(%rsp),%rdi + call __ecp_nistz256_sub_fromx + +.byte 102,72,15,126,199 + + movdqa %xmm5,%xmm0 + movdqa %xmm5,%xmm1 + pandn 352(%rsp),%xmm0 + movdqa %xmm5,%xmm2 + pandn 352+16(%rsp),%xmm1 + movdqa %xmm5,%xmm3 + pand 544(%rsp),%xmm2 + pand 544+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + + movdqa %xmm4,%xmm0 + movdqa %xmm4,%xmm1 + pandn %xmm2,%xmm0 + movdqa %xmm4,%xmm2 + pandn %xmm3,%xmm1 + movdqa %xmm4,%xmm3 + pand 448(%rsp),%xmm2 + pand 448+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + movdqu %xmm2,64(%rdi) + movdqu %xmm3,80(%rdi) + + movdqa %xmm5,%xmm0 + movdqa %xmm5,%xmm1 + pandn 288(%rsp),%xmm0 + movdqa %xmm5,%xmm2 + pandn 288+16(%rsp),%xmm1 + movdqa %xmm5,%xmm3 + pand 480(%rsp),%xmm2 + pand 480+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + + movdqa %xmm4,%xmm0 + movdqa %xmm4,%xmm1 + pandn %xmm2,%xmm0 + movdqa %xmm4,%xmm2 + pandn %xmm3,%xmm1 + movdqa %xmm4,%xmm3 + pand 384(%rsp),%xmm2 + pand 384+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + movdqu %xmm2,0(%rdi) + movdqu %xmm3,16(%rdi) + + movdqa %xmm5,%xmm0 + movdqa %xmm5,%xmm1 + pandn 320(%rsp),%xmm0 + movdqa %xmm5,%xmm2 + pandn 320+16(%rsp),%xmm1 + movdqa %xmm5,%xmm3 + pand 512(%rsp),%xmm2 + pand 512+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + + movdqa %xmm4,%xmm0 + movdqa %xmm4,%xmm1 + pandn %xmm2,%xmm0 + movdqa %xmm4,%xmm2 + pandn %xmm3,%xmm1 + movdqa %xmm4,%xmm3 + pand 416(%rsp),%xmm2 + pand 416+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + movdqu %xmm2,32(%rdi) + movdqu %xmm3,48(%rdi) + +L$add_donex: + leaq 576+56(%rsp),%rsi + + movq -48(%rsi),%r15 + + movq -40(%rsi),%r14 + + movq -32(%rsi),%r13 + + movq -24(%rsi),%r12 + + movq -16(%rsi),%rbx + + movq -8(%rsi),%rbp + + leaq (%rsi),%rsp + +L$point_addx_epilogue: + ret + + +.globl _ecp_nistz256_point_add_affine_adx +.private_extern _ecp_nistz256_point_add_affine_adx + +.p2align 5 +_ecp_nistz256_point_add_affine_adx: + +_CET_ENDBR + pushq %rbp + + pushq %rbx + + pushq %r12 + + pushq %r13 + + pushq %r14 + + pushq %r15 + + subq $480+8,%rsp + +L$add_affinex_body: + + movdqu 0(%rsi),%xmm0 + movq %rdx,%rbx + movdqu 16(%rsi),%xmm1 + movdqu 32(%rsi),%xmm2 + movdqu 48(%rsi),%xmm3 + movdqu 64(%rsi),%xmm4 + movdqu 80(%rsi),%xmm5 + movq 64+0(%rsi),%rdx + movq 64+8(%rsi),%r14 + movq 64+16(%rsi),%r15 + movq 64+24(%rsi),%r8 + movdqa %xmm0,320(%rsp) + movdqa %xmm1,320+16(%rsp) + movdqa %xmm2,352(%rsp) + movdqa %xmm3,352+16(%rsp) + movdqa %xmm4,384(%rsp) + movdqa %xmm5,384+16(%rsp) + por %xmm4,%xmm5 + + movdqu 0(%rbx),%xmm0 + pshufd $0xb1,%xmm5,%xmm3 + movdqu 16(%rbx),%xmm1 + movdqu 32(%rbx),%xmm2 + por %xmm3,%xmm5 + movdqu 48(%rbx),%xmm3 + movdqa %xmm0,416(%rsp) + pshufd $0x1e,%xmm5,%xmm4 + movdqa %xmm1,416+16(%rsp) + por %xmm0,%xmm1 +.byte 102,72,15,110,199 + movdqa %xmm2,448(%rsp) + movdqa %xmm3,448+16(%rsp) + por %xmm2,%xmm3 + por %xmm4,%xmm5 + pxor %xmm4,%xmm4 + por %xmm1,%xmm3 + + leaq 64-128(%rsi),%rsi + leaq 32(%rsp),%rdi + call __ecp_nistz256_sqr_montx + + pcmpeqd %xmm4,%xmm5 + pshufd $0xb1,%xmm3,%xmm4 + movq 0(%rbx),%rdx + + movq %r12,%r9 + por %xmm3,%xmm4 + pshufd $0,%xmm5,%xmm5 + pshufd $0x1e,%xmm4,%xmm3 + movq %r13,%r10 + por %xmm3,%xmm4 + pxor %xmm3,%xmm3 + movq %r14,%r11 + pcmpeqd %xmm3,%xmm4 + pshufd $0,%xmm4,%xmm4 + + leaq 32-128(%rsp),%rsi + movq %r15,%r12 + leaq 0(%rsp),%rdi + call __ecp_nistz256_mul_montx + + leaq 320(%rsp),%rbx + leaq 64(%rsp),%rdi + call __ecp_nistz256_sub_fromx + + movq 384(%rsp),%rdx + leaq 384(%rsp),%rbx + movq 0+32(%rsp),%r9 + movq 8+32(%rsp),%r10 + leaq -128+32(%rsp),%rsi + movq 16+32(%rsp),%r11 + movq 24+32(%rsp),%r12 + leaq 32(%rsp),%rdi + call __ecp_nistz256_mul_montx + + movq 384(%rsp),%rdx + leaq 384(%rsp),%rbx + movq 0+64(%rsp),%r9 + movq 8+64(%rsp),%r10 + leaq -128+64(%rsp),%rsi + movq 16+64(%rsp),%r11 + movq 24+64(%rsp),%r12 + leaq 288(%rsp),%rdi + call __ecp_nistz256_mul_montx + + movq 448(%rsp),%rdx + leaq 448(%rsp),%rbx + movq 0+32(%rsp),%r9 + movq 8+32(%rsp),%r10 + leaq -128+32(%rsp),%rsi + movq 16+32(%rsp),%r11 + movq 24+32(%rsp),%r12 + leaq 32(%rsp),%rdi + call __ecp_nistz256_mul_montx + + leaq 352(%rsp),%rbx + leaq 96(%rsp),%rdi + call __ecp_nistz256_sub_fromx + + movq 0+64(%rsp),%rdx + movq 8+64(%rsp),%r14 + leaq -128+64(%rsp),%rsi + movq 16+64(%rsp),%r15 + movq 24+64(%rsp),%r8 + leaq 128(%rsp),%rdi + call __ecp_nistz256_sqr_montx + + movq 0+96(%rsp),%rdx + movq 8+96(%rsp),%r14 + leaq -128+96(%rsp),%rsi + movq 16+96(%rsp),%r15 + movq 24+96(%rsp),%r8 + leaq 192(%rsp),%rdi + call __ecp_nistz256_sqr_montx + + movq 128(%rsp),%rdx + leaq 128(%rsp),%rbx + movq 0+64(%rsp),%r9 + movq 8+64(%rsp),%r10 + leaq -128+64(%rsp),%rsi + movq 16+64(%rsp),%r11 + movq 24+64(%rsp),%r12 + leaq 160(%rsp),%rdi + call __ecp_nistz256_mul_montx + + movq 320(%rsp),%rdx + leaq 320(%rsp),%rbx + movq 0+128(%rsp),%r9 + movq 8+128(%rsp),%r10 + leaq -128+128(%rsp),%rsi + movq 16+128(%rsp),%r11 + movq 24+128(%rsp),%r12 + leaq 0(%rsp),%rdi + call __ecp_nistz256_mul_montx + + + + + xorq %r11,%r11 + addq %r12,%r12 + leaq 192(%rsp),%rsi + adcq %r13,%r13 + movq %r12,%rax + adcq %r8,%r8 + adcq %r9,%r9 + movq %r13,%rbp + adcq $0,%r11 + + subq $-1,%r12 + movq %r8,%rcx + sbbq %r14,%r13 + sbbq $0,%r8 + movq %r9,%r10 + sbbq %r15,%r9 + sbbq $0,%r11 + + cmovcq %rax,%r12 + movq 0(%rsi),%rax + cmovcq %rbp,%r13 + movq 8(%rsi),%rbp + cmovcq %rcx,%r8 + movq 16(%rsi),%rcx + cmovcq %r10,%r9 + movq 24(%rsi),%r10 + + call __ecp_nistz256_subx + + leaq 160(%rsp),%rbx + leaq 224(%rsp),%rdi + call __ecp_nistz256_sub_fromx + + movq 0+0(%rsp),%rax + movq 0+8(%rsp),%rbp + movq 0+16(%rsp),%rcx + movq 0+24(%rsp),%r10 + leaq 64(%rsp),%rdi + + call __ecp_nistz256_subx + + movq %r12,0(%rdi) + movq %r13,8(%rdi) + movq %r8,16(%rdi) + movq %r9,24(%rdi) + movq 352(%rsp),%rdx + leaq 352(%rsp),%rbx + movq 0+160(%rsp),%r9 + movq 8+160(%rsp),%r10 + leaq -128+160(%rsp),%rsi + movq 16+160(%rsp),%r11 + movq 24+160(%rsp),%r12 + leaq 32(%rsp),%rdi + call __ecp_nistz256_mul_montx + + movq 96(%rsp),%rdx + leaq 96(%rsp),%rbx + movq 0+64(%rsp),%r9 + movq 8+64(%rsp),%r10 + leaq -128+64(%rsp),%rsi + movq 16+64(%rsp),%r11 + movq 24+64(%rsp),%r12 + leaq 64(%rsp),%rdi + call __ecp_nistz256_mul_montx + + leaq 32(%rsp),%rbx + leaq 256(%rsp),%rdi + call __ecp_nistz256_sub_fromx + +.byte 102,72,15,126,199 + + movdqa %xmm5,%xmm0 + movdqa %xmm5,%xmm1 + pandn 288(%rsp),%xmm0 + movdqa %xmm5,%xmm2 + pandn 288+16(%rsp),%xmm1 + movdqa %xmm5,%xmm3 + pand L$ONE_mont(%rip),%xmm2 + pand L$ONE_mont+16(%rip),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + + movdqa %xmm4,%xmm0 + movdqa %xmm4,%xmm1 + pandn %xmm2,%xmm0 + movdqa %xmm4,%xmm2 + pandn %xmm3,%xmm1 + movdqa %xmm4,%xmm3 + pand 384(%rsp),%xmm2 + pand 384+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + movdqu %xmm2,64(%rdi) + movdqu %xmm3,80(%rdi) + + movdqa %xmm5,%xmm0 + movdqa %xmm5,%xmm1 + pandn 224(%rsp),%xmm0 + movdqa %xmm5,%xmm2 + pandn 224+16(%rsp),%xmm1 + movdqa %xmm5,%xmm3 + pand 416(%rsp),%xmm2 + pand 416+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + + movdqa %xmm4,%xmm0 + movdqa %xmm4,%xmm1 + pandn %xmm2,%xmm0 + movdqa %xmm4,%xmm2 + pandn %xmm3,%xmm1 + movdqa %xmm4,%xmm3 + pand 320(%rsp),%xmm2 + pand 320+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + movdqu %xmm2,0(%rdi) + movdqu %xmm3,16(%rdi) + + movdqa %xmm5,%xmm0 + movdqa %xmm5,%xmm1 + pandn 256(%rsp),%xmm0 + movdqa %xmm5,%xmm2 + pandn 256+16(%rsp),%xmm1 + movdqa %xmm5,%xmm3 + pand 448(%rsp),%xmm2 + pand 448+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + + movdqa %xmm4,%xmm0 + movdqa %xmm4,%xmm1 + pandn %xmm2,%xmm0 + movdqa %xmm4,%xmm2 + pandn %xmm3,%xmm1 + movdqa %xmm4,%xmm3 + pand 352(%rsp),%xmm2 + pand 352+16(%rsp),%xmm3 + por %xmm0,%xmm2 + por %xmm1,%xmm3 + movdqu %xmm2,32(%rdi) + movdqu %xmm3,48(%rdi) + + leaq 480+56(%rsp),%rsi + + movq -48(%rsi),%r15 + + movq -40(%rsi),%r14 + + movq -32(%rsi),%r13 + + movq -24(%rsi),%r12 + + movq -16(%rsi),%rbx + + movq -8(%rsi),%rbp + + leaq (%rsi),%rsp + +L$add_affinex_epilogue: + ret + + +#endif diff --git a/http/vendor/ring/pregenerated/p256-x86_64-asm-nasm.asm b/http/vendor/ring/pregenerated/p256-x86_64-asm-nasm.asm new file mode 100644 index 0000000..e837575 --- /dev/null +++ b/http/vendor/ring/pregenerated/p256-x86_64-asm-nasm.asm @@ -0,0 +1,5071 @@ +; This file is generated from a similarly-named Perl script in the BoringSSL +; source tree. Do not edit by hand. + +%ifidn __OUTPUT_FORMAT__, win64 +default rel +%define XMMWORD +%define YMMWORD +%define ZMMWORD +%define _CET_ENDBR + +%include "ring_core_generated/prefix_symbols_nasm.inc" +section .text code align=64 + + + +section .rdata rdata align=8 +ALIGN 64 +$L$poly: + DQ 0xffffffffffffffff,0x00000000ffffffff,0x0000000000000000,0xffffffff00000001 + +$L$One: + DD 1,1,1,1,1,1,1,1 +$L$Two: + DD 2,2,2,2,2,2,2,2 +$L$Three: + DD 3,3,3,3,3,3,3,3 +$L$ONE_mont: + DQ 0x0000000000000001,0xffffffff00000000,0xffffffffffffffff,0x00000000fffffffe + + +$L$ord: + DQ 0xf3b9cac2fc632551,0xbce6faada7179e84,0xffffffffffffffff,0xffffffff00000000 +$L$ordK: + DQ 0xccd1c8aaee00bc4f +section .text + + + + +global ecp_nistz256_neg + +ALIGN 32 +ecp_nistz256_neg: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_ecp_nistz256_neg: + mov rdi,rcx + mov rsi,rdx + + + +_CET_ENDBR + push r12 + + push r13 + +$L$neg_body: + + xor r8,r8 + xor r9,r9 + xor r10,r10 + xor r11,r11 + xor r13,r13 + + sub r8,QWORD[rsi] + sbb r9,QWORD[8+rsi] + sbb r10,QWORD[16+rsi] + mov rax,r8 + sbb r11,QWORD[24+rsi] + lea rsi,[$L$poly] + mov rdx,r9 + sbb r13,0 + + add r8,QWORD[rsi] + mov rcx,r10 + adc r9,QWORD[8+rsi] + adc r10,QWORD[16+rsi] + mov r12,r11 + adc r11,QWORD[24+rsi] + test r13,r13 + + cmovz r8,rax + cmovz r9,rdx + mov QWORD[rdi],r8 + cmovz r10,rcx + mov QWORD[8+rdi],r9 + cmovz r11,r12 + mov QWORD[16+rdi],r10 + mov QWORD[24+rdi],r11 + + mov r13,QWORD[rsp] + + mov r12,QWORD[8+rsp] + + lea rsp,[16+rsp] + +$L$neg_epilogue: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_ecp_nistz256_neg: + + + + + + +global ecp_nistz256_ord_mul_mont_nohw + +ALIGN 32 +ecp_nistz256_ord_mul_mont_nohw: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_ecp_nistz256_ord_mul_mont_nohw: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + + + +_CET_ENDBR + push rbp + + push rbx + + push r12 + + push r13 + + push r14 + + push r15 + +$L$ord_mul_body: + + mov rax,QWORD[rdx] + mov rbx,rdx + lea r14,[$L$ord] + mov r15,QWORD[$L$ordK] + + + mov rcx,rax + mul QWORD[rsi] + mov r8,rax + mov rax,rcx + mov r9,rdx + + mul QWORD[8+rsi] + add r9,rax + mov rax,rcx + adc rdx,0 + mov r10,rdx + + mul QWORD[16+rsi] + add r10,rax + mov rax,rcx + adc rdx,0 + + mov r13,r8 + imul r8,r15 + + mov r11,rdx + mul QWORD[24+rsi] + add r11,rax + mov rax,r8 + adc rdx,0 + mov r12,rdx + + + mul QWORD[r14] + mov rbp,r8 + add r13,rax + mov rax,r8 + adc rdx,0 + mov rcx,rdx + + sub r10,r8 + sbb r8,0 + + mul QWORD[8+r14] + add r9,rcx + adc rdx,0 + add r9,rax + mov rax,rbp + adc r10,rdx + mov rdx,rbp + adc r8,0 + + shl rax,32 + shr rdx,32 + sub r11,rax + mov rax,QWORD[8+rbx] + sbb rbp,rdx + + add r11,r8 + adc r12,rbp + adc r13,0 + + + mov rcx,rax + mul QWORD[rsi] + add r9,rax + mov rax,rcx + adc rdx,0 + mov rbp,rdx + + mul QWORD[8+rsi] + add r10,rbp + adc rdx,0 + add r10,rax + mov rax,rcx + adc rdx,0 + mov rbp,rdx + + mul QWORD[16+rsi] + add r11,rbp + adc rdx,0 + add r11,rax + mov rax,rcx + adc rdx,0 + + mov rcx,r9 + imul r9,r15 + + mov rbp,rdx + mul QWORD[24+rsi] + add r12,rbp + adc rdx,0 + xor r8,r8 + add r12,rax + mov rax,r9 + adc r13,rdx + adc r8,0 + + + mul QWORD[r14] + mov rbp,r9 + add rcx,rax + mov rax,r9 + adc rcx,rdx + + sub r11,r9 + sbb r9,0 + + mul QWORD[8+r14] + add r10,rcx + adc rdx,0 + add r10,rax + mov rax,rbp + adc r11,rdx + mov rdx,rbp + adc r9,0 + + shl rax,32 + shr rdx,32 + sub r12,rax + mov rax,QWORD[16+rbx] + sbb rbp,rdx + + add r12,r9 + adc r13,rbp + adc r8,0 + + + mov rcx,rax + mul QWORD[rsi] + add r10,rax + mov rax,rcx + adc rdx,0 + mov rbp,rdx + + mul QWORD[8+rsi] + add r11,rbp + adc rdx,0 + add r11,rax + mov rax,rcx + adc rdx,0 + mov rbp,rdx + + mul QWORD[16+rsi] + add r12,rbp + adc rdx,0 + add r12,rax + mov rax,rcx + adc rdx,0 + + mov rcx,r10 + imul r10,r15 + + mov rbp,rdx + mul QWORD[24+rsi] + add r13,rbp + adc rdx,0 + xor r9,r9 + add r13,rax + mov rax,r10 + adc r8,rdx + adc r9,0 + + + mul QWORD[r14] + mov rbp,r10 + add rcx,rax + mov rax,r10 + adc rcx,rdx + + sub r12,r10 + sbb r10,0 + + mul QWORD[8+r14] + add r11,rcx + adc rdx,0 + add r11,rax + mov rax,rbp + adc r12,rdx + mov rdx,rbp + adc r10,0 + + shl rax,32 + shr rdx,32 + sub r13,rax + mov rax,QWORD[24+rbx] + sbb rbp,rdx + + add r13,r10 + adc r8,rbp + adc r9,0 + + + mov rcx,rax + mul QWORD[rsi] + add r11,rax + mov rax,rcx + adc rdx,0 + mov rbp,rdx + + mul QWORD[8+rsi] + add r12,rbp + adc rdx,0 + add r12,rax + mov rax,rcx + adc rdx,0 + mov rbp,rdx + + mul QWORD[16+rsi] + add r13,rbp + adc rdx,0 + add r13,rax + mov rax,rcx + adc rdx,0 + + mov rcx,r11 + imul r11,r15 + + mov rbp,rdx + mul QWORD[24+rsi] + add r8,rbp + adc rdx,0 + xor r10,r10 + add r8,rax + mov rax,r11 + adc r9,rdx + adc r10,0 + + + mul QWORD[r14] + mov rbp,r11 + add rcx,rax + mov rax,r11 + adc rcx,rdx + + sub r13,r11 + sbb r11,0 + + mul QWORD[8+r14] + add r12,rcx + adc rdx,0 + add r12,rax + mov rax,rbp + adc r13,rdx + mov rdx,rbp + adc r11,0 + + shl rax,32 + shr rdx,32 + sub r8,rax + sbb rbp,rdx + + add r8,r11 + adc r9,rbp + adc r10,0 + + + mov rsi,r12 + sub r12,QWORD[r14] + mov r11,r13 + sbb r13,QWORD[8+r14] + mov rcx,r8 + sbb r8,QWORD[16+r14] + mov rbp,r9 + sbb r9,QWORD[24+r14] + sbb r10,0 + + cmovc r12,rsi + cmovc r13,r11 + cmovc r8,rcx + cmovc r9,rbp + + mov QWORD[rdi],r12 + mov QWORD[8+rdi],r13 + mov QWORD[16+rdi],r8 + mov QWORD[24+rdi],r9 + + mov r15,QWORD[rsp] + + mov r14,QWORD[8+rsp] + + mov r13,QWORD[16+rsp] + + mov r12,QWORD[24+rsp] + + mov rbx,QWORD[32+rsp] + + mov rbp,QWORD[40+rsp] + + lea rsp,[48+rsp] + +$L$ord_mul_epilogue: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_ecp_nistz256_ord_mul_mont_nohw: + + + + + + + +global ecp_nistz256_ord_sqr_mont_nohw + +ALIGN 32 +ecp_nistz256_ord_sqr_mont_nohw: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_ecp_nistz256_ord_sqr_mont_nohw: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + + + +_CET_ENDBR + push rbp + + push rbx + + push r12 + + push r13 + + push r14 + + push r15 + +$L$ord_sqr_body: + + mov r8,QWORD[rsi] + mov rax,QWORD[8+rsi] + mov r14,QWORD[16+rsi] + mov r15,QWORD[24+rsi] + lea rsi,[$L$ord] + mov rbx,rdx + jmp NEAR $L$oop_ord_sqr + +ALIGN 32 +$L$oop_ord_sqr: + + mov rbp,rax + mul r8 + mov r9,rax +DB 102,72,15,110,205 + mov rax,r14 + mov r10,rdx + + mul r8 + add r10,rax + mov rax,r15 +DB 102,73,15,110,214 + adc rdx,0 + mov r11,rdx + + mul r8 + add r11,rax + mov rax,r15 +DB 102,73,15,110,223 + adc rdx,0 + mov r12,rdx + + + mul r14 + mov r13,rax + mov rax,r14 + mov r14,rdx + + + mul rbp + add r11,rax + mov rax,r15 + adc rdx,0 + mov r15,rdx + + mul rbp + add r12,rax + adc rdx,0 + + add r12,r15 + adc r13,rdx + adc r14,0 + + + xor r15,r15 + mov rax,r8 + add r9,r9 + adc r10,r10 + adc r11,r11 + adc r12,r12 + adc r13,r13 + adc r14,r14 + adc r15,0 + + + mul rax + mov r8,rax +DB 102,72,15,126,200 + mov rbp,rdx + + mul rax + add r9,rbp + adc r10,rax +DB 102,72,15,126,208 + adc rdx,0 + mov rbp,rdx + + mul rax + add r11,rbp + adc r12,rax +DB 102,72,15,126,216 + adc rdx,0 + mov rbp,rdx + + mov rcx,r8 + imul r8,QWORD[32+rsi] + + mul rax + add r13,rbp + adc r14,rax + mov rax,QWORD[rsi] + adc r15,rdx + + + mul r8 + mov rbp,r8 + add rcx,rax + mov rax,QWORD[8+rsi] + adc rcx,rdx + + sub r10,r8 + sbb rbp,0 + + mul r8 + add r9,rcx + adc rdx,0 + add r9,rax + mov rax,r8 + adc r10,rdx + mov rdx,r8 + adc rbp,0 + + mov rcx,r9 + imul r9,QWORD[32+rsi] + + shl rax,32 + shr rdx,32 + sub r11,rax + mov rax,QWORD[rsi] + sbb r8,rdx + + add r11,rbp + adc r8,0 + + + mul r9 + mov rbp,r9 + add rcx,rax + mov rax,QWORD[8+rsi] + adc rcx,rdx + + sub r11,r9 + sbb rbp,0 + + mul r9 + add r10,rcx + adc rdx,0 + add r10,rax + mov rax,r9 + adc r11,rdx + mov rdx,r9 + adc rbp,0 + + mov rcx,r10 + imul r10,QWORD[32+rsi] + + shl rax,32 + shr rdx,32 + sub r8,rax + mov rax,QWORD[rsi] + sbb r9,rdx + + add r8,rbp + adc r9,0 + + + mul r10 + mov rbp,r10 + add rcx,rax + mov rax,QWORD[8+rsi] + adc rcx,rdx + + sub r8,r10 + sbb rbp,0 + + mul r10 + add r11,rcx + adc rdx,0 + add r11,rax + mov rax,r10 + adc r8,rdx + mov rdx,r10 + adc rbp,0 + + mov rcx,r11 + imul r11,QWORD[32+rsi] + + shl rax,32 + shr rdx,32 + sub r9,rax + mov rax,QWORD[rsi] + sbb r10,rdx + + add r9,rbp + adc r10,0 + + + mul r11 + mov rbp,r11 + add rcx,rax + mov rax,QWORD[8+rsi] + adc rcx,rdx + + sub r9,r11 + sbb rbp,0 + + mul r11 + add r8,rcx + adc rdx,0 + add r8,rax + mov rax,r11 + adc r9,rdx + mov rdx,r11 + adc rbp,0 + + shl rax,32 + shr rdx,32 + sub r10,rax + sbb r11,rdx + + add r10,rbp + adc r11,0 + + + xor rdx,rdx + add r8,r12 + adc r9,r13 + mov r12,r8 + adc r10,r14 + adc r11,r15 + mov rax,r9 + adc rdx,0 + + + sub r8,QWORD[rsi] + mov r14,r10 + sbb r9,QWORD[8+rsi] + sbb r10,QWORD[16+rsi] + mov r15,r11 + sbb r11,QWORD[24+rsi] + sbb rdx,0 + + cmovc r8,r12 + cmovnc rax,r9 + cmovnc r14,r10 + cmovnc r15,r11 + + dec rbx + jnz NEAR $L$oop_ord_sqr + + mov QWORD[rdi],r8 + mov QWORD[8+rdi],rax + pxor xmm1,xmm1 + mov QWORD[16+rdi],r14 + pxor xmm2,xmm2 + mov QWORD[24+rdi],r15 + pxor xmm3,xmm3 + + mov r15,QWORD[rsp] + + mov r14,QWORD[8+rsp] + + mov r13,QWORD[16+rsp] + + mov r12,QWORD[24+rsp] + + mov rbx,QWORD[32+rsp] + + mov rbp,QWORD[40+rsp] + + lea rsp,[48+rsp] + +$L$ord_sqr_epilogue: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_ecp_nistz256_ord_sqr_mont_nohw: + +global ecp_nistz256_ord_mul_mont_adx + +ALIGN 32 +ecp_nistz256_ord_mul_mont_adx: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_ecp_nistz256_ord_mul_mont_adx: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + + + +$L$ecp_nistz256_ord_mul_mont_adx: +_CET_ENDBR + push rbp + + push rbx + + push r12 + + push r13 + + push r14 + + push r15 + +$L$ord_mulx_body: + + mov rbx,rdx + mov rdx,QWORD[rdx] + mov r9,QWORD[rsi] + mov r10,QWORD[8+rsi] + mov r11,QWORD[16+rsi] + mov r12,QWORD[24+rsi] + lea rsi,[((-128))+rsi] + lea r14,[(($L$ord-128))] + mov r15,QWORD[$L$ordK] + + + mulx r9,r8,r9 + mulx r10,rcx,r10 + mulx r11,rbp,r11 + add r9,rcx + mulx r12,rcx,r12 + mov rdx,r8 + mulx rax,rdx,r15 + adc r10,rbp + adc r11,rcx + adc r12,0 + + + xor r13,r13 + mulx rbp,rcx,QWORD[((0+128))+r14] + adcx r8,rcx + adox r9,rbp + + mulx rbp,rcx,QWORD[((8+128))+r14] + adcx r9,rcx + adox r10,rbp + + mulx rbp,rcx,QWORD[((16+128))+r14] + adcx r10,rcx + adox r11,rbp + + mulx rbp,rcx,QWORD[((24+128))+r14] + mov rdx,QWORD[8+rbx] + adcx r11,rcx + adox r12,rbp + adcx r12,r8 + adox r13,r8 + adc r13,0 + + + mulx rbp,rcx,QWORD[((0+128))+rsi] + adcx r9,rcx + adox r10,rbp + + mulx rbp,rcx,QWORD[((8+128))+rsi] + adcx r10,rcx + adox r11,rbp + + mulx rbp,rcx,QWORD[((16+128))+rsi] + adcx r11,rcx + adox r12,rbp + + mulx rbp,rcx,QWORD[((24+128))+rsi] + mov rdx,r9 + mulx rax,rdx,r15 + adcx r12,rcx + adox r13,rbp + + adcx r13,r8 + adox r8,r8 + adc r8,0 + + + mulx rbp,rcx,QWORD[((0+128))+r14] + adcx r9,rcx + adox r10,rbp + + mulx rbp,rcx,QWORD[((8+128))+r14] + adcx r10,rcx + adox r11,rbp + + mulx rbp,rcx,QWORD[((16+128))+r14] + adcx r11,rcx + adox r12,rbp + + mulx rbp,rcx,QWORD[((24+128))+r14] + mov rdx,QWORD[16+rbx] + adcx r12,rcx + adox r13,rbp + adcx r13,r9 + adox r8,r9 + adc r8,0 + + + mulx rbp,rcx,QWORD[((0+128))+rsi] + adcx r10,rcx + adox r11,rbp + + mulx rbp,rcx,QWORD[((8+128))+rsi] + adcx r11,rcx + adox r12,rbp + + mulx rbp,rcx,QWORD[((16+128))+rsi] + adcx r12,rcx + adox r13,rbp + + mulx rbp,rcx,QWORD[((24+128))+rsi] + mov rdx,r10 + mulx rax,rdx,r15 + adcx r13,rcx + adox r8,rbp + + adcx r8,r9 + adox r9,r9 + adc r9,0 + + + mulx rbp,rcx,QWORD[((0+128))+r14] + adcx r10,rcx + adox r11,rbp + + mulx rbp,rcx,QWORD[((8+128))+r14] + adcx r11,rcx + adox r12,rbp + + mulx rbp,rcx,QWORD[((16+128))+r14] + adcx r12,rcx + adox r13,rbp + + mulx rbp,rcx,QWORD[((24+128))+r14] + mov rdx,QWORD[24+rbx] + adcx r13,rcx + adox r8,rbp + adcx r8,r10 + adox r9,r10 + adc r9,0 + + + mulx rbp,rcx,QWORD[((0+128))+rsi] + adcx r11,rcx + adox r12,rbp + + mulx rbp,rcx,QWORD[((8+128))+rsi] + adcx r12,rcx + adox r13,rbp + + mulx rbp,rcx,QWORD[((16+128))+rsi] + adcx r13,rcx + adox r8,rbp + + mulx rbp,rcx,QWORD[((24+128))+rsi] + mov rdx,r11 + mulx rax,rdx,r15 + adcx r8,rcx + adox r9,rbp + + adcx r9,r10 + adox r10,r10 + adc r10,0 + + + mulx rbp,rcx,QWORD[((0+128))+r14] + adcx r11,rcx + adox r12,rbp + + mulx rbp,rcx,QWORD[((8+128))+r14] + adcx r12,rcx + adox r13,rbp + + mulx rbp,rcx,QWORD[((16+128))+r14] + adcx r13,rcx + adox r8,rbp + + mulx rbp,rcx,QWORD[((24+128))+r14] + lea r14,[128+r14] + mov rbx,r12 + adcx r8,rcx + adox r9,rbp + mov rdx,r13 + adcx r9,r11 + adox r10,r11 + adc r10,0 + + + + mov rcx,r8 + sub r12,QWORD[r14] + sbb r13,QWORD[8+r14] + sbb r8,QWORD[16+r14] + mov rbp,r9 + sbb r9,QWORD[24+r14] + sbb r10,0 + + cmovc r12,rbx + cmovc r13,rdx + cmovc r8,rcx + cmovc r9,rbp + + mov QWORD[rdi],r12 + mov QWORD[8+rdi],r13 + mov QWORD[16+rdi],r8 + mov QWORD[24+rdi],r9 + + mov r15,QWORD[rsp] + + mov r14,QWORD[8+rsp] + + mov r13,QWORD[16+rsp] + + mov r12,QWORD[24+rsp] + + mov rbx,QWORD[32+rsp] + + mov rbp,QWORD[40+rsp] + + lea rsp,[48+rsp] + +$L$ord_mulx_epilogue: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_ecp_nistz256_ord_mul_mont_adx: + +global ecp_nistz256_ord_sqr_mont_adx + +ALIGN 32 +ecp_nistz256_ord_sqr_mont_adx: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_ecp_nistz256_ord_sqr_mont_adx: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + + + +_CET_ENDBR +$L$ecp_nistz256_ord_sqr_mont_adx: + push rbp + + push rbx + + push r12 + + push r13 + + push r14 + + push r15 + +$L$ord_sqrx_body: + + mov rbx,rdx + mov rdx,QWORD[rsi] + mov r14,QWORD[8+rsi] + mov r15,QWORD[16+rsi] + mov r8,QWORD[24+rsi] + lea rsi,[$L$ord] + jmp NEAR $L$oop_ord_sqrx + +ALIGN 32 +$L$oop_ord_sqrx: + mulx r10,r9,r14 + mulx r11,rcx,r15 + mov rax,rdx +DB 102,73,15,110,206 + mulx r12,rbp,r8 + mov rdx,r14 + add r10,rcx +DB 102,73,15,110,215 + adc r11,rbp + adc r12,0 + xor r13,r13 + + mulx rbp,rcx,r15 + adcx r11,rcx + adox r12,rbp + + mulx rbp,rcx,r8 + mov rdx,r15 + adcx r12,rcx + adox r13,rbp + adc r13,0 + + mulx r14,rcx,r8 + mov rdx,rax +DB 102,73,15,110,216 + xor r15,r15 + adcx r9,r9 + adox r13,rcx + adcx r10,r10 + adox r14,r15 + + + mulx rbp,r8,rdx +DB 102,72,15,126,202 + adcx r11,r11 + adox r9,rbp + adcx r12,r12 + mulx rax,rcx,rdx +DB 102,72,15,126,210 + adcx r13,r13 + adox r10,rcx + adcx r14,r14 + mulx rbp,rcx,rdx + DB 0x67 +DB 102,72,15,126,218 + adox r11,rax + adcx r15,r15 + adox r12,rcx + adox r13,rbp + mulx rax,rcx,rdx + adox r14,rcx + adox r15,rax + + + mov rdx,r8 + mulx rcx,rdx,QWORD[32+rsi] + + xor rax,rax + mulx rbp,rcx,QWORD[rsi] + adcx r8,rcx + adox r9,rbp + mulx rbp,rcx,QWORD[8+rsi] + adcx r9,rcx + adox r10,rbp + mulx rbp,rcx,QWORD[16+rsi] + adcx r10,rcx + adox r11,rbp + mulx rbp,rcx,QWORD[24+rsi] + adcx r11,rcx + adox r8,rbp + adcx r8,rax + + + mov rdx,r9 + mulx rcx,rdx,QWORD[32+rsi] + + mulx rbp,rcx,QWORD[rsi] + adox r9,rcx + adcx r10,rbp + mulx rbp,rcx,QWORD[8+rsi] + adox r10,rcx + adcx r11,rbp + mulx rbp,rcx,QWORD[16+rsi] + adox r11,rcx + adcx r8,rbp + mulx rbp,rcx,QWORD[24+rsi] + adox r8,rcx + adcx r9,rbp + adox r9,rax + + + mov rdx,r10 + mulx rcx,rdx,QWORD[32+rsi] + + mulx rbp,rcx,QWORD[rsi] + adcx r10,rcx + adox r11,rbp + mulx rbp,rcx,QWORD[8+rsi] + adcx r11,rcx + adox r8,rbp + mulx rbp,rcx,QWORD[16+rsi] + adcx r8,rcx + adox r9,rbp + mulx rbp,rcx,QWORD[24+rsi] + adcx r9,rcx + adox r10,rbp + adcx r10,rax + + + mov rdx,r11 + mulx rcx,rdx,QWORD[32+rsi] + + mulx rbp,rcx,QWORD[rsi] + adox r11,rcx + adcx r8,rbp + mulx rbp,rcx,QWORD[8+rsi] + adox r8,rcx + adcx r9,rbp + mulx rbp,rcx,QWORD[16+rsi] + adox r9,rcx + adcx r10,rbp + mulx rbp,rcx,QWORD[24+rsi] + adox r10,rcx + adcx r11,rbp + adox r11,rax + + + add r12,r8 + adc r9,r13 + mov rdx,r12 + adc r10,r14 + adc r11,r15 + mov r14,r9 + adc rax,0 + + + sub r12,QWORD[rsi] + mov r15,r10 + sbb r9,QWORD[8+rsi] + sbb r10,QWORD[16+rsi] + mov r8,r11 + sbb r11,QWORD[24+rsi] + sbb rax,0 + + cmovnc rdx,r12 + cmovnc r14,r9 + cmovnc r15,r10 + cmovnc r8,r11 + + dec rbx + jnz NEAR $L$oop_ord_sqrx + + mov QWORD[rdi],rdx + mov QWORD[8+rdi],r14 + pxor xmm1,xmm1 + mov QWORD[16+rdi],r15 + pxor xmm2,xmm2 + mov QWORD[24+rdi],r8 + pxor xmm3,xmm3 + + mov r15,QWORD[rsp] + + mov r14,QWORD[8+rsp] + + mov r13,QWORD[16+rsp] + + mov r12,QWORD[24+rsp] + + mov rbx,QWORD[32+rsp] + + mov rbp,QWORD[40+rsp] + + lea rsp,[48+rsp] + +$L$ord_sqrx_epilogue: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_ecp_nistz256_ord_sqr_mont_adx: + + + + + + +global ecp_nistz256_mul_mont_nohw + +ALIGN 32 +ecp_nistz256_mul_mont_nohw: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_ecp_nistz256_mul_mont_nohw: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + + + +_CET_ENDBR + push rbp + + push rbx + + push r12 + + push r13 + + push r14 + + push r15 + +$L$mul_body: + mov rbx,rdx + mov rax,QWORD[rdx] + mov r9,QWORD[rsi] + mov r10,QWORD[8+rsi] + mov r11,QWORD[16+rsi] + mov r12,QWORD[24+rsi] + + call __ecp_nistz256_mul_montq + + mov r15,QWORD[rsp] + + mov r14,QWORD[8+rsp] + + mov r13,QWORD[16+rsp] + + mov r12,QWORD[24+rsp] + + mov rbx,QWORD[32+rsp] + + mov rbp,QWORD[40+rsp] + + lea rsp,[48+rsp] + +$L$mul_epilogue: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_ecp_nistz256_mul_mont_nohw: + + +ALIGN 32 +__ecp_nistz256_mul_montq: + + + + mov rbp,rax + mul r9 + mov r14,QWORD[(($L$poly+8))] + mov r8,rax + mov rax,rbp + mov r9,rdx + + mul r10 + mov r15,QWORD[(($L$poly+24))] + add r9,rax + mov rax,rbp + adc rdx,0 + mov r10,rdx + + mul r11 + add r10,rax + mov rax,rbp + adc rdx,0 + mov r11,rdx + + mul r12 + add r11,rax + mov rax,r8 + adc rdx,0 + xor r13,r13 + mov r12,rdx + + + + + + + + + + + mov rbp,r8 + shl r8,32 + mul r15 + shr rbp,32 + add r9,r8 + adc r10,rbp + adc r11,rax + mov rax,QWORD[8+rbx] + adc r12,rdx + adc r13,0 + xor r8,r8 + + + + mov rbp,rax + mul QWORD[rsi] + add r9,rax + mov rax,rbp + adc rdx,0 + mov rcx,rdx + + mul QWORD[8+rsi] + add r10,rcx + adc rdx,0 + add r10,rax + mov rax,rbp + adc rdx,0 + mov rcx,rdx + + mul QWORD[16+rsi] + add r11,rcx + adc rdx,0 + add r11,rax + mov rax,rbp + adc rdx,0 + mov rcx,rdx + + mul QWORD[24+rsi] + add r12,rcx + adc rdx,0 + add r12,rax + mov rax,r9 + adc r13,rdx + adc r8,0 + + + + mov rbp,r9 + shl r9,32 + mul r15 + shr rbp,32 + add r10,r9 + adc r11,rbp + adc r12,rax + mov rax,QWORD[16+rbx] + adc r13,rdx + adc r8,0 + xor r9,r9 + + + + mov rbp,rax + mul QWORD[rsi] + add r10,rax + mov rax,rbp + adc rdx,0 + mov rcx,rdx + + mul QWORD[8+rsi] + add r11,rcx + adc rdx,0 + add r11,rax + mov rax,rbp + adc rdx,0 + mov rcx,rdx + + mul QWORD[16+rsi] + add r12,rcx + adc rdx,0 + add r12,rax + mov rax,rbp + adc rdx,0 + mov rcx,rdx + + mul QWORD[24+rsi] + add r13,rcx + adc rdx,0 + add r13,rax + mov rax,r10 + adc r8,rdx + adc r9,0 + + + + mov rbp,r10 + shl r10,32 + mul r15 + shr rbp,32 + add r11,r10 + adc r12,rbp + adc r13,rax + mov rax,QWORD[24+rbx] + adc r8,rdx + adc r9,0 + xor r10,r10 + + + + mov rbp,rax + mul QWORD[rsi] + add r11,rax + mov rax,rbp + adc rdx,0 + mov rcx,rdx + + mul QWORD[8+rsi] + add r12,rcx + adc rdx,0 + add r12,rax + mov rax,rbp + adc rdx,0 + mov rcx,rdx + + mul QWORD[16+rsi] + add r13,rcx + adc rdx,0 + add r13,rax + mov rax,rbp + adc rdx,0 + mov rcx,rdx + + mul QWORD[24+rsi] + add r8,rcx + adc rdx,0 + add r8,rax + mov rax,r11 + adc r9,rdx + adc r10,0 + + + + mov rbp,r11 + shl r11,32 + mul r15 + shr rbp,32 + add r12,r11 + adc r13,rbp + mov rcx,r12 + adc r8,rax + adc r9,rdx + mov rbp,r13 + adc r10,0 + + + + sub r12,-1 + mov rbx,r8 + sbb r13,r14 + sbb r8,0 + mov rdx,r9 + sbb r9,r15 + sbb r10,0 + + cmovc r12,rcx + cmovc r13,rbp + mov QWORD[rdi],r12 + cmovc r8,rbx + mov QWORD[8+rdi],r13 + cmovc r9,rdx + mov QWORD[16+rdi],r8 + mov QWORD[24+rdi],r9 + + ret + + + + + + + + + + +global ecp_nistz256_sqr_mont_nohw + +ALIGN 32 +ecp_nistz256_sqr_mont_nohw: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_ecp_nistz256_sqr_mont_nohw: + mov rdi,rcx + mov rsi,rdx + + + +_CET_ENDBR + push rbp + + push rbx + + push r12 + + push r13 + + push r14 + + push r15 + +$L$sqr_body: + mov rax,QWORD[rsi] + mov r14,QWORD[8+rsi] + mov r15,QWORD[16+rsi] + mov r8,QWORD[24+rsi] + + call __ecp_nistz256_sqr_montq + + mov r15,QWORD[rsp] + + mov r14,QWORD[8+rsp] + + mov r13,QWORD[16+rsp] + + mov r12,QWORD[24+rsp] + + mov rbx,QWORD[32+rsp] + + mov rbp,QWORD[40+rsp] + + lea rsp,[48+rsp] + +$L$sqr_epilogue: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_ecp_nistz256_sqr_mont_nohw: + + +ALIGN 32 +__ecp_nistz256_sqr_montq: + + mov r13,rax + mul r14 + mov r9,rax + mov rax,r15 + mov r10,rdx + + mul r13 + add r10,rax + mov rax,r8 + adc rdx,0 + mov r11,rdx + + mul r13 + add r11,rax + mov rax,r15 + adc rdx,0 + mov r12,rdx + + + mul r14 + add r11,rax + mov rax,r8 + adc rdx,0 + mov rbp,rdx + + mul r14 + add r12,rax + mov rax,r8 + adc rdx,0 + add r12,rbp + mov r13,rdx + adc r13,0 + + + mul r15 + xor r15,r15 + add r13,rax + mov rax,QWORD[rsi] + mov r14,rdx + adc r14,0 + + add r9,r9 + adc r10,r10 + adc r11,r11 + adc r12,r12 + adc r13,r13 + adc r14,r14 + adc r15,0 + + mul rax + mov r8,rax + mov rax,QWORD[8+rsi] + mov rcx,rdx + + mul rax + add r9,rcx + adc r10,rax + mov rax,QWORD[16+rsi] + adc rdx,0 + mov rcx,rdx + + mul rax + add r11,rcx + adc r12,rax + mov rax,QWORD[24+rsi] + adc rdx,0 + mov rcx,rdx + + mul rax + add r13,rcx + adc r14,rax + mov rax,r8 + adc r15,rdx + + mov rsi,QWORD[(($L$poly+8))] + mov rbp,QWORD[(($L$poly+24))] + + + + + mov rcx,r8 + shl r8,32 + mul rbp + shr rcx,32 + add r9,r8 + adc r10,rcx + adc r11,rax + mov rax,r9 + adc rdx,0 + + + + mov rcx,r9 + shl r9,32 + mov r8,rdx + mul rbp + shr rcx,32 + add r10,r9 + adc r11,rcx + adc r8,rax + mov rax,r10 + adc rdx,0 + + + + mov rcx,r10 + shl r10,32 + mov r9,rdx + mul rbp + shr rcx,32 + add r11,r10 + adc r8,rcx + adc r9,rax + mov rax,r11 + adc rdx,0 + + + + mov rcx,r11 + shl r11,32 + mov r10,rdx + mul rbp + shr rcx,32 + add r8,r11 + adc r9,rcx + adc r10,rax + adc rdx,0 + xor r11,r11 + + + + add r12,r8 + adc r13,r9 + mov r8,r12 + adc r14,r10 + adc r15,rdx + mov r9,r13 + adc r11,0 + + sub r12,-1 + mov r10,r14 + sbb r13,rsi + sbb r14,0 + mov rcx,r15 + sbb r15,rbp + sbb r11,0 + + cmovc r12,r8 + cmovc r13,r9 + mov QWORD[rdi],r12 + cmovc r14,r10 + mov QWORD[8+rdi],r13 + cmovc r15,rcx + mov QWORD[16+rdi],r14 + mov QWORD[24+rdi],r15 + + ret + + +global ecp_nistz256_mul_mont_adx + +ALIGN 32 +ecp_nistz256_mul_mont_adx: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_ecp_nistz256_mul_mont_adx: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + + + +_CET_ENDBR + push rbp + + push rbx + + push r12 + + push r13 + + push r14 + + push r15 + +$L$mulx_body: + mov rbx,rdx + mov rdx,QWORD[rdx] + mov r9,QWORD[rsi] + mov r10,QWORD[8+rsi] + mov r11,QWORD[16+rsi] + mov r12,QWORD[24+rsi] + lea rsi,[((-128))+rsi] + + call __ecp_nistz256_mul_montx + + mov r15,QWORD[rsp] + + mov r14,QWORD[8+rsp] + + mov r13,QWORD[16+rsp] + + mov r12,QWORD[24+rsp] + + mov rbx,QWORD[32+rsp] + + mov rbp,QWORD[40+rsp] + + lea rsp,[48+rsp] + +$L$mulx_epilogue: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_ecp_nistz256_mul_mont_adx: + + +ALIGN 32 +__ecp_nistz256_mul_montx: + + + + mulx r9,r8,r9 + mulx r10,rcx,r10 + mov r14,32 + xor r13,r13 + mulx r11,rbp,r11 + mov r15,QWORD[(($L$poly+24))] + adc r9,rcx + mulx r12,rcx,r12 + mov rdx,r8 + adc r10,rbp + shlx rbp,r8,r14 + adc r11,rcx + shrx rcx,r8,r14 + adc r12,0 + + + + add r9,rbp + adc r10,rcx + + mulx rbp,rcx,r15 + mov rdx,QWORD[8+rbx] + adc r11,rcx + adc r12,rbp + adc r13,0 + xor r8,r8 + + + + mulx rbp,rcx,QWORD[((0+128))+rsi] + adcx r9,rcx + adox r10,rbp + + mulx rbp,rcx,QWORD[((8+128))+rsi] + adcx r10,rcx + adox r11,rbp + + mulx rbp,rcx,QWORD[((16+128))+rsi] + adcx r11,rcx + adox r12,rbp + + mulx rbp,rcx,QWORD[((24+128))+rsi] + mov rdx,r9 + adcx r12,rcx + shlx rcx,r9,r14 + adox r13,rbp + shrx rbp,r9,r14 + + adcx r13,r8 + adox r8,r8 + adc r8,0 + + + + add r10,rcx + adc r11,rbp + + mulx rbp,rcx,r15 + mov rdx,QWORD[16+rbx] + adc r12,rcx + adc r13,rbp + adc r8,0 + xor r9,r9 + + + + mulx rbp,rcx,QWORD[((0+128))+rsi] + adcx r10,rcx + adox r11,rbp + + mulx rbp,rcx,QWORD[((8+128))+rsi] + adcx r11,rcx + adox r12,rbp + + mulx rbp,rcx,QWORD[((16+128))+rsi] + adcx r12,rcx + adox r13,rbp + + mulx rbp,rcx,QWORD[((24+128))+rsi] + mov rdx,r10 + adcx r13,rcx + shlx rcx,r10,r14 + adox r8,rbp + shrx rbp,r10,r14 + + adcx r8,r9 + adox r9,r9 + adc r9,0 + + + + add r11,rcx + adc r12,rbp + + mulx rbp,rcx,r15 + mov rdx,QWORD[24+rbx] + adc r13,rcx + adc r8,rbp + adc r9,0 + xor r10,r10 + + + + mulx rbp,rcx,QWORD[((0+128))+rsi] + adcx r11,rcx + adox r12,rbp + + mulx rbp,rcx,QWORD[((8+128))+rsi] + adcx r12,rcx + adox r13,rbp + + mulx rbp,rcx,QWORD[((16+128))+rsi] + adcx r13,rcx + adox r8,rbp + + mulx rbp,rcx,QWORD[((24+128))+rsi] + mov rdx,r11 + adcx r8,rcx + shlx rcx,r11,r14 + adox r9,rbp + shrx rbp,r11,r14 + + adcx r9,r10 + adox r10,r10 + adc r10,0 + + + + add r12,rcx + adc r13,rbp + + mulx rbp,rcx,r15 + mov rbx,r12 + mov r14,QWORD[(($L$poly+8))] + adc r8,rcx + mov rdx,r13 + adc r9,rbp + adc r10,0 + + + + xor eax,eax + mov rcx,r8 + sbb r12,-1 + sbb r13,r14 + sbb r8,0 + mov rbp,r9 + sbb r9,r15 + sbb r10,0 + + cmovc r12,rbx + cmovc r13,rdx + mov QWORD[rdi],r12 + cmovc r8,rcx + mov QWORD[8+rdi],r13 + cmovc r9,rbp + mov QWORD[16+rdi],r8 + mov QWORD[24+rdi],r9 + + ret + + + +global ecp_nistz256_sqr_mont_adx + +ALIGN 32 +ecp_nistz256_sqr_mont_adx: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_ecp_nistz256_sqr_mont_adx: + mov rdi,rcx + mov rsi,rdx + + + +_CET_ENDBR + push rbp + + push rbx + + push r12 + + push r13 + + push r14 + + push r15 + +$L$sqrx_body: + mov rdx,QWORD[rsi] + mov r14,QWORD[8+rsi] + mov r15,QWORD[16+rsi] + mov r8,QWORD[24+rsi] + lea rsi,[((-128))+rsi] + + call __ecp_nistz256_sqr_montx + + mov r15,QWORD[rsp] + + mov r14,QWORD[8+rsp] + + mov r13,QWORD[16+rsp] + + mov r12,QWORD[24+rsp] + + mov rbx,QWORD[32+rsp] + + mov rbp,QWORD[40+rsp] + + lea rsp,[48+rsp] + +$L$sqrx_epilogue: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_ecp_nistz256_sqr_mont_adx: + + +ALIGN 32 +__ecp_nistz256_sqr_montx: + + mulx r10,r9,r14 + mulx r11,rcx,r15 + xor eax,eax + adc r10,rcx + mulx r12,rbp,r8 + mov rdx,r14 + adc r11,rbp + adc r12,0 + xor r13,r13 + + + mulx rbp,rcx,r15 + adcx r11,rcx + adox r12,rbp + + mulx rbp,rcx,r8 + mov rdx,r15 + adcx r12,rcx + adox r13,rbp + adc r13,0 + + + mulx r14,rcx,r8 + mov rdx,QWORD[((0+128))+rsi] + xor r15,r15 + adcx r9,r9 + adox r13,rcx + adcx r10,r10 + adox r14,r15 + + mulx rbp,r8,rdx + mov rdx,QWORD[((8+128))+rsi] + adcx r11,r11 + adox r9,rbp + adcx r12,r12 + mulx rax,rcx,rdx + mov rdx,QWORD[((16+128))+rsi] + adcx r13,r13 + adox r10,rcx + adcx r14,r14 + DB 0x67 + mulx rbp,rcx,rdx + mov rdx,QWORD[((24+128))+rsi] + adox r11,rax + adcx r15,r15 + adox r12,rcx + mov rsi,32 + adox r13,rbp + DB 0x67,0x67 + mulx rax,rcx,rdx + mov rdx,QWORD[(($L$poly+24))] + adox r14,rcx + shlx rcx,r8,rsi + adox r15,rax + shrx rax,r8,rsi + mov rbp,rdx + + + add r9,rcx + adc r10,rax + + mulx r8,rcx,r8 + adc r11,rcx + shlx rcx,r9,rsi + adc r8,0 + shrx rax,r9,rsi + + + add r10,rcx + adc r11,rax + + mulx r9,rcx,r9 + adc r8,rcx + shlx rcx,r10,rsi + adc r9,0 + shrx rax,r10,rsi + + + add r11,rcx + adc r8,rax + + mulx r10,rcx,r10 + adc r9,rcx + shlx rcx,r11,rsi + adc r10,0 + shrx rax,r11,rsi + + + add r8,rcx + adc r9,rax + + mulx r11,rcx,r11 + adc r10,rcx + adc r11,0 + + xor rdx,rdx + add r12,r8 + mov rsi,QWORD[(($L$poly+8))] + adc r13,r9 + mov r8,r12 + adc r14,r10 + adc r15,r11 + mov r9,r13 + adc rdx,0 + + sub r12,-1 + mov r10,r14 + sbb r13,rsi + sbb r14,0 + mov r11,r15 + sbb r15,rbp + sbb rdx,0 + + cmovc r12,r8 + cmovc r13,r9 + mov QWORD[rdi],r12 + cmovc r14,r10 + mov QWORD[8+rdi],r13 + cmovc r15,r11 + mov QWORD[16+rdi],r14 + mov QWORD[24+rdi],r15 + + ret + + + + +global ecp_nistz256_select_w5_nohw + +ALIGN 32 +ecp_nistz256_select_w5_nohw: + +_CET_ENDBR + lea rax,[((-136))+rsp] +$L$SEH_begin_ecp_nistz256_select_w5_nohw: + DB 0x48,0x8d,0x60,0xe0 + DB 0x0f,0x29,0x70,0xe0 + DB 0x0f,0x29,0x78,0xf0 + DB 0x44,0x0f,0x29,0x00 + DB 0x44,0x0f,0x29,0x48,0x10 + DB 0x44,0x0f,0x29,0x50,0x20 + DB 0x44,0x0f,0x29,0x58,0x30 + DB 0x44,0x0f,0x29,0x60,0x40 + DB 0x44,0x0f,0x29,0x68,0x50 + DB 0x44,0x0f,0x29,0x70,0x60 + DB 0x44,0x0f,0x29,0x78,0x70 + movdqa xmm0,XMMWORD[$L$One] + movd xmm1,r8d + + pxor xmm2,xmm2 + pxor xmm3,xmm3 + pxor xmm4,xmm4 + pxor xmm5,xmm5 + pxor xmm6,xmm6 + pxor xmm7,xmm7 + + movdqa xmm8,xmm0 + pshufd xmm1,xmm1,0 + + mov rax,16 +$L$select_loop_sse_w5: + + movdqa xmm15,xmm8 + paddd xmm8,xmm0 + pcmpeqd xmm15,xmm1 + + movdqa xmm9,XMMWORD[rdx] + movdqa xmm10,XMMWORD[16+rdx] + movdqa xmm11,XMMWORD[32+rdx] + movdqa xmm12,XMMWORD[48+rdx] + movdqa xmm13,XMMWORD[64+rdx] + movdqa xmm14,XMMWORD[80+rdx] + lea rdx,[96+rdx] + + pand xmm9,xmm15 + pand xmm10,xmm15 + por xmm2,xmm9 + pand xmm11,xmm15 + por xmm3,xmm10 + pand xmm12,xmm15 + por xmm4,xmm11 + pand xmm13,xmm15 + por xmm5,xmm12 + pand xmm14,xmm15 + por xmm6,xmm13 + por xmm7,xmm14 + + dec rax + jnz NEAR $L$select_loop_sse_w5 + + movdqu XMMWORD[rcx],xmm2 + movdqu XMMWORD[16+rcx],xmm3 + movdqu XMMWORD[32+rcx],xmm4 + movdqu XMMWORD[48+rcx],xmm5 + movdqu XMMWORD[64+rcx],xmm6 + movdqu XMMWORD[80+rcx],xmm7 + movaps xmm6,XMMWORD[rsp] + movaps xmm7,XMMWORD[16+rsp] + movaps xmm8,XMMWORD[32+rsp] + movaps xmm9,XMMWORD[48+rsp] + movaps xmm10,XMMWORD[64+rsp] + movaps xmm11,XMMWORD[80+rsp] + movaps xmm12,XMMWORD[96+rsp] + movaps xmm13,XMMWORD[112+rsp] + movaps xmm14,XMMWORD[128+rsp] + movaps xmm15,XMMWORD[144+rsp] + lea rsp,[168+rsp] + ret + +$L$SEH_end_ecp_nistz256_select_w5_nohw: + + + + +global ecp_nistz256_select_w7_nohw + +ALIGN 32 +ecp_nistz256_select_w7_nohw: + +_CET_ENDBR + lea rax,[((-136))+rsp] +$L$SEH_begin_ecp_nistz256_select_w7_nohw: + DB 0x48,0x8d,0x60,0xe0 + DB 0x0f,0x29,0x70,0xe0 + DB 0x0f,0x29,0x78,0xf0 + DB 0x44,0x0f,0x29,0x00 + DB 0x44,0x0f,0x29,0x48,0x10 + DB 0x44,0x0f,0x29,0x50,0x20 + DB 0x44,0x0f,0x29,0x58,0x30 + DB 0x44,0x0f,0x29,0x60,0x40 + DB 0x44,0x0f,0x29,0x68,0x50 + DB 0x44,0x0f,0x29,0x70,0x60 + DB 0x44,0x0f,0x29,0x78,0x70 + movdqa xmm8,XMMWORD[$L$One] + movd xmm1,r8d + + pxor xmm2,xmm2 + pxor xmm3,xmm3 + pxor xmm4,xmm4 + pxor xmm5,xmm5 + + movdqa xmm0,xmm8 + pshufd xmm1,xmm1,0 + mov rax,64 + +$L$select_loop_sse_w7: + movdqa xmm15,xmm8 + paddd xmm8,xmm0 + movdqa xmm9,XMMWORD[rdx] + movdqa xmm10,XMMWORD[16+rdx] + pcmpeqd xmm15,xmm1 + movdqa xmm11,XMMWORD[32+rdx] + movdqa xmm12,XMMWORD[48+rdx] + lea rdx,[64+rdx] + + pand xmm9,xmm15 + pand xmm10,xmm15 + por xmm2,xmm9 + pand xmm11,xmm15 + por xmm3,xmm10 + pand xmm12,xmm15 + por xmm4,xmm11 + prefetcht0 [255+rdx] + por xmm5,xmm12 + + dec rax + jnz NEAR $L$select_loop_sse_w7 + + movdqu XMMWORD[rcx],xmm2 + movdqu XMMWORD[16+rcx],xmm3 + movdqu XMMWORD[32+rcx],xmm4 + movdqu XMMWORD[48+rcx],xmm5 + movaps xmm6,XMMWORD[rsp] + movaps xmm7,XMMWORD[16+rsp] + movaps xmm8,XMMWORD[32+rsp] + movaps xmm9,XMMWORD[48+rsp] + movaps xmm10,XMMWORD[64+rsp] + movaps xmm11,XMMWORD[80+rsp] + movaps xmm12,XMMWORD[96+rsp] + movaps xmm13,XMMWORD[112+rsp] + movaps xmm14,XMMWORD[128+rsp] + movaps xmm15,XMMWORD[144+rsp] + lea rsp,[168+rsp] + ret + +$L$SEH_end_ecp_nistz256_select_w7_nohw: + + + +global ecp_nistz256_select_w5_avx2 + +ALIGN 32 +ecp_nistz256_select_w5_avx2: + +_CET_ENDBR + vzeroupper + lea rax,[((-136))+rsp] + mov r11,rsp +$L$SEH_begin_ecp_nistz256_select_w5_avx2: + DB 0x48,0x8d,0x60,0xe0 + DB 0xc5,0xf8,0x29,0x70,0xe0 + DB 0xc5,0xf8,0x29,0x78,0xf0 + DB 0xc5,0x78,0x29,0x40,0x00 + DB 0xc5,0x78,0x29,0x48,0x10 + DB 0xc5,0x78,0x29,0x50,0x20 + DB 0xc5,0x78,0x29,0x58,0x30 + DB 0xc5,0x78,0x29,0x60,0x40 + DB 0xc5,0x78,0x29,0x68,0x50 + DB 0xc5,0x78,0x29,0x70,0x60 + DB 0xc5,0x78,0x29,0x78,0x70 + vmovdqa ymm0,YMMWORD[$L$Two] + + vpxor ymm2,ymm2,ymm2 + vpxor ymm3,ymm3,ymm3 + vpxor ymm4,ymm4,ymm4 + + vmovdqa ymm5,YMMWORD[$L$One] + vmovdqa ymm10,YMMWORD[$L$Two] + + vmovd xmm1,r8d + vpermd ymm1,ymm2,ymm1 + + mov rax,8 +$L$select_loop_avx2_w5: + + vmovdqa ymm6,YMMWORD[rdx] + vmovdqa ymm7,YMMWORD[32+rdx] + vmovdqa ymm8,YMMWORD[64+rdx] + + vmovdqa ymm11,YMMWORD[96+rdx] + vmovdqa ymm12,YMMWORD[128+rdx] + vmovdqa ymm13,YMMWORD[160+rdx] + + vpcmpeqd ymm9,ymm5,ymm1 + vpcmpeqd ymm14,ymm10,ymm1 + + vpaddd ymm5,ymm5,ymm0 + vpaddd ymm10,ymm10,ymm0 + lea rdx,[192+rdx] + + vpand ymm6,ymm6,ymm9 + vpand ymm7,ymm7,ymm9 + vpand ymm8,ymm8,ymm9 + vpand ymm11,ymm11,ymm14 + vpand ymm12,ymm12,ymm14 + vpand ymm13,ymm13,ymm14 + + vpxor ymm2,ymm2,ymm6 + vpxor ymm3,ymm3,ymm7 + vpxor ymm4,ymm4,ymm8 + vpxor ymm2,ymm2,ymm11 + vpxor ymm3,ymm3,ymm12 + vpxor ymm4,ymm4,ymm13 + + dec rax + jnz NEAR $L$select_loop_avx2_w5 + + vmovdqu YMMWORD[rcx],ymm2 + vmovdqu YMMWORD[32+rcx],ymm3 + vmovdqu YMMWORD[64+rcx],ymm4 + vzeroupper + movaps xmm6,XMMWORD[rsp] + movaps xmm7,XMMWORD[16+rsp] + movaps xmm8,XMMWORD[32+rsp] + movaps xmm9,XMMWORD[48+rsp] + movaps xmm10,XMMWORD[64+rsp] + movaps xmm11,XMMWORD[80+rsp] + movaps xmm12,XMMWORD[96+rsp] + movaps xmm13,XMMWORD[112+rsp] + movaps xmm14,XMMWORD[128+rsp] + movaps xmm15,XMMWORD[144+rsp] + lea rsp,[r11] + ret + +$L$SEH_end_ecp_nistz256_select_w5_avx2: + + + + +global ecp_nistz256_select_w7_avx2 + +ALIGN 32 +ecp_nistz256_select_w7_avx2: + +_CET_ENDBR + vzeroupper + mov r11,rsp + lea rax,[((-136))+rsp] +$L$SEH_begin_ecp_nistz256_select_w7_avx2: + DB 0x48,0x8d,0x60,0xe0 + DB 0xc5,0xf8,0x29,0x70,0xe0 + DB 0xc5,0xf8,0x29,0x78,0xf0 + DB 0xc5,0x78,0x29,0x40,0x00 + DB 0xc5,0x78,0x29,0x48,0x10 + DB 0xc5,0x78,0x29,0x50,0x20 + DB 0xc5,0x78,0x29,0x58,0x30 + DB 0xc5,0x78,0x29,0x60,0x40 + DB 0xc5,0x78,0x29,0x68,0x50 + DB 0xc5,0x78,0x29,0x70,0x60 + DB 0xc5,0x78,0x29,0x78,0x70 + vmovdqa ymm0,YMMWORD[$L$Three] + + vpxor ymm2,ymm2,ymm2 + vpxor ymm3,ymm3,ymm3 + + vmovdqa ymm4,YMMWORD[$L$One] + vmovdqa ymm8,YMMWORD[$L$Two] + vmovdqa ymm12,YMMWORD[$L$Three] + + vmovd xmm1,r8d + vpermd ymm1,ymm2,ymm1 + + + mov rax,21 +$L$select_loop_avx2_w7: + + vmovdqa ymm5,YMMWORD[rdx] + vmovdqa ymm6,YMMWORD[32+rdx] + + vmovdqa ymm9,YMMWORD[64+rdx] + vmovdqa ymm10,YMMWORD[96+rdx] + + vmovdqa ymm13,YMMWORD[128+rdx] + vmovdqa ymm14,YMMWORD[160+rdx] + + vpcmpeqd ymm7,ymm4,ymm1 + vpcmpeqd ymm11,ymm8,ymm1 + vpcmpeqd ymm15,ymm12,ymm1 + + vpaddd ymm4,ymm4,ymm0 + vpaddd ymm8,ymm8,ymm0 + vpaddd ymm12,ymm12,ymm0 + lea rdx,[192+rdx] + + vpand ymm5,ymm5,ymm7 + vpand ymm6,ymm6,ymm7 + vpand ymm9,ymm9,ymm11 + vpand ymm10,ymm10,ymm11 + vpand ymm13,ymm13,ymm15 + vpand ymm14,ymm14,ymm15 + + vpxor ymm2,ymm2,ymm5 + vpxor ymm3,ymm3,ymm6 + vpxor ymm2,ymm2,ymm9 + vpxor ymm3,ymm3,ymm10 + vpxor ymm2,ymm2,ymm13 + vpxor ymm3,ymm3,ymm14 + + dec rax + jnz NEAR $L$select_loop_avx2_w7 + + + vmovdqa ymm5,YMMWORD[rdx] + vmovdqa ymm6,YMMWORD[32+rdx] + + vpcmpeqd ymm7,ymm4,ymm1 + + vpand ymm5,ymm5,ymm7 + vpand ymm6,ymm6,ymm7 + + vpxor ymm2,ymm2,ymm5 + vpxor ymm3,ymm3,ymm6 + + vmovdqu YMMWORD[rcx],ymm2 + vmovdqu YMMWORD[32+rcx],ymm3 + vzeroupper + movaps xmm6,XMMWORD[rsp] + movaps xmm7,XMMWORD[16+rsp] + movaps xmm8,XMMWORD[32+rsp] + movaps xmm9,XMMWORD[48+rsp] + movaps xmm10,XMMWORD[64+rsp] + movaps xmm11,XMMWORD[80+rsp] + movaps xmm12,XMMWORD[96+rsp] + movaps xmm13,XMMWORD[112+rsp] + movaps xmm14,XMMWORD[128+rsp] + movaps xmm15,XMMWORD[144+rsp] + lea rsp,[r11] + ret + +$L$SEH_end_ecp_nistz256_select_w7_avx2: + + +ALIGN 32 +__ecp_nistz256_add_toq: + + xor r11,r11 + add r12,QWORD[rbx] + adc r13,QWORD[8+rbx] + mov rax,r12 + adc r8,QWORD[16+rbx] + adc r9,QWORD[24+rbx] + mov rbp,r13 + adc r11,0 + + sub r12,-1 + mov rcx,r8 + sbb r13,r14 + sbb r8,0 + mov r10,r9 + sbb r9,r15 + sbb r11,0 + + cmovc r12,rax + cmovc r13,rbp + mov QWORD[rdi],r12 + cmovc r8,rcx + mov QWORD[8+rdi],r13 + cmovc r9,r10 + mov QWORD[16+rdi],r8 + mov QWORD[24+rdi],r9 + + ret + + + + +ALIGN 32 +__ecp_nistz256_sub_fromq: + + sub r12,QWORD[rbx] + sbb r13,QWORD[8+rbx] + mov rax,r12 + sbb r8,QWORD[16+rbx] + sbb r9,QWORD[24+rbx] + mov rbp,r13 + sbb r11,r11 + + add r12,-1 + mov rcx,r8 + adc r13,r14 + adc r8,0 + mov r10,r9 + adc r9,r15 + test r11,r11 + + cmovz r12,rax + cmovz r13,rbp + mov QWORD[rdi],r12 + cmovz r8,rcx + mov QWORD[8+rdi],r13 + cmovz r9,r10 + mov QWORD[16+rdi],r8 + mov QWORD[24+rdi],r9 + + ret + + + + +ALIGN 32 +__ecp_nistz256_subq: + + sub rax,r12 + sbb rbp,r13 + mov r12,rax + sbb rcx,r8 + sbb r10,r9 + mov r13,rbp + sbb r11,r11 + + add rax,-1 + mov r8,rcx + adc rbp,r14 + adc rcx,0 + mov r9,r10 + adc r10,r15 + test r11,r11 + + cmovnz r12,rax + cmovnz r13,rbp + cmovnz r8,rcx + cmovnz r9,r10 + + ret + + + + +ALIGN 32 +__ecp_nistz256_mul_by_2q: + + xor r11,r11 + add r12,r12 + adc r13,r13 + mov rax,r12 + adc r8,r8 + adc r9,r9 + mov rbp,r13 + adc r11,0 + + sub r12,-1 + mov rcx,r8 + sbb r13,r14 + sbb r8,0 + mov r10,r9 + sbb r9,r15 + sbb r11,0 + + cmovc r12,rax + cmovc r13,rbp + mov QWORD[rdi],r12 + cmovc r8,rcx + mov QWORD[8+rdi],r13 + cmovc r9,r10 + mov QWORD[16+rdi],r8 + mov QWORD[24+rdi],r9 + + ret + + +global ecp_nistz256_point_double_nohw + +ALIGN 32 +ecp_nistz256_point_double_nohw: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_ecp_nistz256_point_double_nohw: + mov rdi,rcx + mov rsi,rdx + + + +_CET_ENDBR + push rbp + + push rbx + + push r12 + + push r13 + + push r14 + + push r15 + + sub rsp,32*5+8 + +$L$point_doubleq_body: + +$L$point_double_shortcutq: + movdqu xmm0,XMMWORD[rsi] + mov rbx,rsi + movdqu xmm1,XMMWORD[16+rsi] + mov r12,QWORD[((32+0))+rsi] + mov r13,QWORD[((32+8))+rsi] + mov r8,QWORD[((32+16))+rsi] + mov r9,QWORD[((32+24))+rsi] + mov r14,QWORD[(($L$poly+8))] + mov r15,QWORD[(($L$poly+24))] + movdqa XMMWORD[96+rsp],xmm0 + movdqa XMMWORD[(96+16)+rsp],xmm1 + lea r10,[32+rdi] + lea r11,[64+rdi] +DB 102,72,15,110,199 +DB 102,73,15,110,202 +DB 102,73,15,110,211 + + lea rdi,[rsp] + call __ecp_nistz256_mul_by_2q + + mov rax,QWORD[((64+0))+rsi] + mov r14,QWORD[((64+8))+rsi] + mov r15,QWORD[((64+16))+rsi] + mov r8,QWORD[((64+24))+rsi] + lea rsi,[((64-0))+rsi] + lea rdi,[64+rsp] + call __ecp_nistz256_sqr_montq + + mov rax,QWORD[((0+0))+rsp] + mov r14,QWORD[((8+0))+rsp] + lea rsi,[((0+0))+rsp] + mov r15,QWORD[((16+0))+rsp] + mov r8,QWORD[((24+0))+rsp] + lea rdi,[rsp] + call __ecp_nistz256_sqr_montq + + mov rax,QWORD[32+rbx] + mov r9,QWORD[((64+0))+rbx] + mov r10,QWORD[((64+8))+rbx] + mov r11,QWORD[((64+16))+rbx] + mov r12,QWORD[((64+24))+rbx] + lea rsi,[((64-0))+rbx] + lea rbx,[32+rbx] +DB 102,72,15,126,215 + call __ecp_nistz256_mul_montq + call __ecp_nistz256_mul_by_2q + + mov r12,QWORD[((96+0))+rsp] + mov r13,QWORD[((96+8))+rsp] + lea rbx,[64+rsp] + mov r8,QWORD[((96+16))+rsp] + mov r9,QWORD[((96+24))+rsp] + lea rdi,[32+rsp] + call __ecp_nistz256_add_toq + + mov r12,QWORD[((96+0))+rsp] + mov r13,QWORD[((96+8))+rsp] + lea rbx,[64+rsp] + mov r8,QWORD[((96+16))+rsp] + mov r9,QWORD[((96+24))+rsp] + lea rdi,[64+rsp] + call __ecp_nistz256_sub_fromq + + mov rax,QWORD[((0+0))+rsp] + mov r14,QWORD[((8+0))+rsp] + lea rsi,[((0+0))+rsp] + mov r15,QWORD[((16+0))+rsp] + mov r8,QWORD[((24+0))+rsp] +DB 102,72,15,126,207 + call __ecp_nistz256_sqr_montq + xor r9,r9 + mov rax,r12 + add r12,-1 + mov r10,r13 + adc r13,rsi + mov rcx,r14 + adc r14,0 + mov r8,r15 + adc r15,rbp + adc r9,0 + xor rsi,rsi + test rax,1 + + cmovz r12,rax + cmovz r13,r10 + cmovz r14,rcx + cmovz r15,r8 + cmovz r9,rsi + + mov rax,r13 + shr r12,1 + shl rax,63 + mov r10,r14 + shr r13,1 + or r12,rax + shl r10,63 + mov rcx,r15 + shr r14,1 + or r13,r10 + shl rcx,63 + mov QWORD[rdi],r12 + shr r15,1 + mov QWORD[8+rdi],r13 + shl r9,63 + or r14,rcx + or r15,r9 + mov QWORD[16+rdi],r14 + mov QWORD[24+rdi],r15 + mov rax,QWORD[64+rsp] + lea rbx,[64+rsp] + mov r9,QWORD[((0+32))+rsp] + mov r10,QWORD[((8+32))+rsp] + lea rsi,[((0+32))+rsp] + mov r11,QWORD[((16+32))+rsp] + mov r12,QWORD[((24+32))+rsp] + lea rdi,[32+rsp] + call __ecp_nistz256_mul_montq + + lea rdi,[128+rsp] + call __ecp_nistz256_mul_by_2q + + lea rbx,[32+rsp] + lea rdi,[32+rsp] + call __ecp_nistz256_add_toq + + mov rax,QWORD[96+rsp] + lea rbx,[96+rsp] + mov r9,QWORD[((0+0))+rsp] + mov r10,QWORD[((8+0))+rsp] + lea rsi,[((0+0))+rsp] + mov r11,QWORD[((16+0))+rsp] + mov r12,QWORD[((24+0))+rsp] + lea rdi,[rsp] + call __ecp_nistz256_mul_montq + + lea rdi,[128+rsp] + call __ecp_nistz256_mul_by_2q + + mov rax,QWORD[((0+32))+rsp] + mov r14,QWORD[((8+32))+rsp] + lea rsi,[((0+32))+rsp] + mov r15,QWORD[((16+32))+rsp] + mov r8,QWORD[((24+32))+rsp] +DB 102,72,15,126,199 + call __ecp_nistz256_sqr_montq + + lea rbx,[128+rsp] + mov r8,r14 + mov r9,r15 + mov r14,rsi + mov r15,rbp + call __ecp_nistz256_sub_fromq + + mov rax,QWORD[((0+0))+rsp] + mov rbp,QWORD[((0+8))+rsp] + mov rcx,QWORD[((0+16))+rsp] + mov r10,QWORD[((0+24))+rsp] + lea rdi,[rsp] + call __ecp_nistz256_subq + + mov rax,QWORD[32+rsp] + lea rbx,[32+rsp] + mov r14,r12 + xor ecx,ecx + mov QWORD[((0+0))+rsp],r12 + mov r10,r13 + mov QWORD[((0+8))+rsp],r13 + cmovz r11,r8 + mov QWORD[((0+16))+rsp],r8 + lea rsi,[((0-0))+rsp] + cmovz r12,r9 + mov QWORD[((0+24))+rsp],r9 + mov r9,r14 + lea rdi,[rsp] + call __ecp_nistz256_mul_montq + +DB 102,72,15,126,203 +DB 102,72,15,126,207 + call __ecp_nistz256_sub_fromq + + lea rsi,[((160+56))+rsp] + + mov r15,QWORD[((-48))+rsi] + + mov r14,QWORD[((-40))+rsi] + + mov r13,QWORD[((-32))+rsi] + + mov r12,QWORD[((-24))+rsi] + + mov rbx,QWORD[((-16))+rsi] + + mov rbp,QWORD[((-8))+rsi] + + lea rsp,[rsi] + +$L$point_doubleq_epilogue: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_ecp_nistz256_point_double_nohw: +global ecp_nistz256_point_add_nohw + +ALIGN 32 +ecp_nistz256_point_add_nohw: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_ecp_nistz256_point_add_nohw: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + + + +_CET_ENDBR + push rbp + + push rbx + + push r12 + + push r13 + + push r14 + + push r15 + + sub rsp,32*18+8 + +$L$point_addq_body: + + movdqu xmm0,XMMWORD[rsi] + movdqu xmm1,XMMWORD[16+rsi] + movdqu xmm2,XMMWORD[32+rsi] + movdqu xmm3,XMMWORD[48+rsi] + movdqu xmm4,XMMWORD[64+rsi] + movdqu xmm5,XMMWORD[80+rsi] + mov rbx,rsi + mov rsi,rdx + movdqa XMMWORD[384+rsp],xmm0 + movdqa XMMWORD[(384+16)+rsp],xmm1 + movdqa XMMWORD[416+rsp],xmm2 + movdqa XMMWORD[(416+16)+rsp],xmm3 + movdqa XMMWORD[448+rsp],xmm4 + movdqa XMMWORD[(448+16)+rsp],xmm5 + por xmm5,xmm4 + + movdqu xmm0,XMMWORD[rsi] + pshufd xmm3,xmm5,0xb1 + movdqu xmm1,XMMWORD[16+rsi] + movdqu xmm2,XMMWORD[32+rsi] + por xmm5,xmm3 + movdqu xmm3,XMMWORD[48+rsi] + mov rax,QWORD[((64+0))+rsi] + mov r14,QWORD[((64+8))+rsi] + mov r15,QWORD[((64+16))+rsi] + mov r8,QWORD[((64+24))+rsi] + movdqa XMMWORD[480+rsp],xmm0 + pshufd xmm4,xmm5,0x1e + movdqa XMMWORD[(480+16)+rsp],xmm1 + movdqu xmm0,XMMWORD[64+rsi] + movdqu xmm1,XMMWORD[80+rsi] + movdqa XMMWORD[512+rsp],xmm2 + movdqa XMMWORD[(512+16)+rsp],xmm3 + por xmm5,xmm4 + pxor xmm4,xmm4 + por xmm1,xmm0 +DB 102,72,15,110,199 + + lea rsi,[((64-0))+rsi] + mov QWORD[((544+0))+rsp],rax + mov QWORD[((544+8))+rsp],r14 + mov QWORD[((544+16))+rsp],r15 + mov QWORD[((544+24))+rsp],r8 + lea rdi,[96+rsp] + call __ecp_nistz256_sqr_montq + + pcmpeqd xmm5,xmm4 + pshufd xmm4,xmm1,0xb1 + por xmm4,xmm1 + pshufd xmm5,xmm5,0 + pshufd xmm3,xmm4,0x1e + por xmm4,xmm3 + pxor xmm3,xmm3 + pcmpeqd xmm4,xmm3 + pshufd xmm4,xmm4,0 + mov rax,QWORD[((64+0))+rbx] + mov r14,QWORD[((64+8))+rbx] + mov r15,QWORD[((64+16))+rbx] + mov r8,QWORD[((64+24))+rbx] +DB 102,72,15,110,203 + + lea rsi,[((64-0))+rbx] + lea rdi,[32+rsp] + call __ecp_nistz256_sqr_montq + + mov rax,QWORD[544+rsp] + lea rbx,[544+rsp] + mov r9,QWORD[((0+96))+rsp] + mov r10,QWORD[((8+96))+rsp] + lea rsi,[((0+96))+rsp] + mov r11,QWORD[((16+96))+rsp] + mov r12,QWORD[((24+96))+rsp] + lea rdi,[224+rsp] + call __ecp_nistz256_mul_montq + + mov rax,QWORD[448+rsp] + lea rbx,[448+rsp] + mov r9,QWORD[((0+32))+rsp] + mov r10,QWORD[((8+32))+rsp] + lea rsi,[((0+32))+rsp] + mov r11,QWORD[((16+32))+rsp] + mov r12,QWORD[((24+32))+rsp] + lea rdi,[256+rsp] + call __ecp_nistz256_mul_montq + + mov rax,QWORD[416+rsp] + lea rbx,[416+rsp] + mov r9,QWORD[((0+224))+rsp] + mov r10,QWORD[((8+224))+rsp] + lea rsi,[((0+224))+rsp] + mov r11,QWORD[((16+224))+rsp] + mov r12,QWORD[((24+224))+rsp] + lea rdi,[224+rsp] + call __ecp_nistz256_mul_montq + + mov rax,QWORD[512+rsp] + lea rbx,[512+rsp] + mov r9,QWORD[((0+256))+rsp] + mov r10,QWORD[((8+256))+rsp] + lea rsi,[((0+256))+rsp] + mov r11,QWORD[((16+256))+rsp] + mov r12,QWORD[((24+256))+rsp] + lea rdi,[256+rsp] + call __ecp_nistz256_mul_montq + + lea rbx,[224+rsp] + lea rdi,[64+rsp] + call __ecp_nistz256_sub_fromq + + or r12,r13 + movdqa xmm2,xmm4 + or r12,r8 + or r12,r9 + por xmm2,xmm5 +DB 102,73,15,110,220 + + mov rax,QWORD[384+rsp] + lea rbx,[384+rsp] + mov r9,QWORD[((0+96))+rsp] + mov r10,QWORD[((8+96))+rsp] + lea rsi,[((0+96))+rsp] + mov r11,QWORD[((16+96))+rsp] + mov r12,QWORD[((24+96))+rsp] + lea rdi,[160+rsp] + call __ecp_nistz256_mul_montq + + mov rax,QWORD[480+rsp] + lea rbx,[480+rsp] + mov r9,QWORD[((0+32))+rsp] + mov r10,QWORD[((8+32))+rsp] + lea rsi,[((0+32))+rsp] + mov r11,QWORD[((16+32))+rsp] + mov r12,QWORD[((24+32))+rsp] + lea rdi,[192+rsp] + call __ecp_nistz256_mul_montq + + lea rbx,[160+rsp] + lea rdi,[rsp] + call __ecp_nistz256_sub_fromq + + or r12,r13 + or r12,r8 + or r12,r9 + +DB 102,73,15,126,208 +DB 102,73,15,126,217 + or r12,r8 + DB 0x3e + jnz NEAR $L$add_proceedq + + + + test r9,r9 + jz NEAR $L$add_doubleq + + + + + + +DB 102,72,15,126,199 + pxor xmm0,xmm0 + movdqu XMMWORD[rdi],xmm0 + movdqu XMMWORD[16+rdi],xmm0 + movdqu XMMWORD[32+rdi],xmm0 + movdqu XMMWORD[48+rdi],xmm0 + movdqu XMMWORD[64+rdi],xmm0 + movdqu XMMWORD[80+rdi],xmm0 + jmp NEAR $L$add_doneq + +ALIGN 32 +$L$add_doubleq: +DB 102,72,15,126,206 +DB 102,72,15,126,199 + add rsp,416 + + jmp NEAR $L$point_double_shortcutq + + +ALIGN 32 +$L$add_proceedq: + mov rax,QWORD[((0+64))+rsp] + mov r14,QWORD[((8+64))+rsp] + lea rsi,[((0+64))+rsp] + mov r15,QWORD[((16+64))+rsp] + mov r8,QWORD[((24+64))+rsp] + lea rdi,[96+rsp] + call __ecp_nistz256_sqr_montq + + mov rax,QWORD[448+rsp] + lea rbx,[448+rsp] + mov r9,QWORD[((0+0))+rsp] + mov r10,QWORD[((8+0))+rsp] + lea rsi,[((0+0))+rsp] + mov r11,QWORD[((16+0))+rsp] + mov r12,QWORD[((24+0))+rsp] + lea rdi,[352+rsp] + call __ecp_nistz256_mul_montq + + mov rax,QWORD[((0+0))+rsp] + mov r14,QWORD[((8+0))+rsp] + lea rsi,[((0+0))+rsp] + mov r15,QWORD[((16+0))+rsp] + mov r8,QWORD[((24+0))+rsp] + lea rdi,[32+rsp] + call __ecp_nistz256_sqr_montq + + mov rax,QWORD[544+rsp] + lea rbx,[544+rsp] + mov r9,QWORD[((0+352))+rsp] + mov r10,QWORD[((8+352))+rsp] + lea rsi,[((0+352))+rsp] + mov r11,QWORD[((16+352))+rsp] + mov r12,QWORD[((24+352))+rsp] + lea rdi,[352+rsp] + call __ecp_nistz256_mul_montq + + mov rax,QWORD[rsp] + lea rbx,[rsp] + mov r9,QWORD[((0+32))+rsp] + mov r10,QWORD[((8+32))+rsp] + lea rsi,[((0+32))+rsp] + mov r11,QWORD[((16+32))+rsp] + mov r12,QWORD[((24+32))+rsp] + lea rdi,[128+rsp] + call __ecp_nistz256_mul_montq + + mov rax,QWORD[160+rsp] + lea rbx,[160+rsp] + mov r9,QWORD[((0+32))+rsp] + mov r10,QWORD[((8+32))+rsp] + lea rsi,[((0+32))+rsp] + mov r11,QWORD[((16+32))+rsp] + mov r12,QWORD[((24+32))+rsp] + lea rdi,[192+rsp] + call __ecp_nistz256_mul_montq + + + + + xor r11,r11 + add r12,r12 + lea rsi,[96+rsp] + adc r13,r13 + mov rax,r12 + adc r8,r8 + adc r9,r9 + mov rbp,r13 + adc r11,0 + + sub r12,-1 + mov rcx,r8 + sbb r13,r14 + sbb r8,0 + mov r10,r9 + sbb r9,r15 + sbb r11,0 + + cmovc r12,rax + mov rax,QWORD[rsi] + cmovc r13,rbp + mov rbp,QWORD[8+rsi] + cmovc r8,rcx + mov rcx,QWORD[16+rsi] + cmovc r9,r10 + mov r10,QWORD[24+rsi] + + call __ecp_nistz256_subq + + lea rbx,[128+rsp] + lea rdi,[288+rsp] + call __ecp_nistz256_sub_fromq + + mov rax,QWORD[((192+0))+rsp] + mov rbp,QWORD[((192+8))+rsp] + mov rcx,QWORD[((192+16))+rsp] + mov r10,QWORD[((192+24))+rsp] + lea rdi,[320+rsp] + + call __ecp_nistz256_subq + + mov QWORD[rdi],r12 + mov QWORD[8+rdi],r13 + mov QWORD[16+rdi],r8 + mov QWORD[24+rdi],r9 + mov rax,QWORD[128+rsp] + lea rbx,[128+rsp] + mov r9,QWORD[((0+224))+rsp] + mov r10,QWORD[((8+224))+rsp] + lea rsi,[((0+224))+rsp] + mov r11,QWORD[((16+224))+rsp] + mov r12,QWORD[((24+224))+rsp] + lea rdi,[256+rsp] + call __ecp_nistz256_mul_montq + + mov rax,QWORD[320+rsp] + lea rbx,[320+rsp] + mov r9,QWORD[((0+64))+rsp] + mov r10,QWORD[((8+64))+rsp] + lea rsi,[((0+64))+rsp] + mov r11,QWORD[((16+64))+rsp] + mov r12,QWORD[((24+64))+rsp] + lea rdi,[320+rsp] + call __ecp_nistz256_mul_montq + + lea rbx,[256+rsp] + lea rdi,[320+rsp] + call __ecp_nistz256_sub_fromq + +DB 102,72,15,126,199 + + movdqa xmm0,xmm5 + movdqa xmm1,xmm5 + pandn xmm0,XMMWORD[352+rsp] + movdqa xmm2,xmm5 + pandn xmm1,XMMWORD[((352+16))+rsp] + movdqa xmm3,xmm5 + pand xmm2,XMMWORD[544+rsp] + pand xmm3,XMMWORD[((544+16))+rsp] + por xmm2,xmm0 + por xmm3,xmm1 + + movdqa xmm0,xmm4 + movdqa xmm1,xmm4 + pandn xmm0,xmm2 + movdqa xmm2,xmm4 + pandn xmm1,xmm3 + movdqa xmm3,xmm4 + pand xmm2,XMMWORD[448+rsp] + pand xmm3,XMMWORD[((448+16))+rsp] + por xmm2,xmm0 + por xmm3,xmm1 + movdqu XMMWORD[64+rdi],xmm2 + movdqu XMMWORD[80+rdi],xmm3 + + movdqa xmm0,xmm5 + movdqa xmm1,xmm5 + pandn xmm0,XMMWORD[288+rsp] + movdqa xmm2,xmm5 + pandn xmm1,XMMWORD[((288+16))+rsp] + movdqa xmm3,xmm5 + pand xmm2,XMMWORD[480+rsp] + pand xmm3,XMMWORD[((480+16))+rsp] + por xmm2,xmm0 + por xmm3,xmm1 + + movdqa xmm0,xmm4 + movdqa xmm1,xmm4 + pandn xmm0,xmm2 + movdqa xmm2,xmm4 + pandn xmm1,xmm3 + movdqa xmm3,xmm4 + pand xmm2,XMMWORD[384+rsp] + pand xmm3,XMMWORD[((384+16))+rsp] + por xmm2,xmm0 + por xmm3,xmm1 + movdqu XMMWORD[rdi],xmm2 + movdqu XMMWORD[16+rdi],xmm3 + + movdqa xmm0,xmm5 + movdqa xmm1,xmm5 + pandn xmm0,XMMWORD[320+rsp] + movdqa xmm2,xmm5 + pandn xmm1,XMMWORD[((320+16))+rsp] + movdqa xmm3,xmm5 + pand xmm2,XMMWORD[512+rsp] + pand xmm3,XMMWORD[((512+16))+rsp] + por xmm2,xmm0 + por xmm3,xmm1 + + movdqa xmm0,xmm4 + movdqa xmm1,xmm4 + pandn xmm0,xmm2 + movdqa xmm2,xmm4 + pandn xmm1,xmm3 + movdqa xmm3,xmm4 + pand xmm2,XMMWORD[416+rsp] + pand xmm3,XMMWORD[((416+16))+rsp] + por xmm2,xmm0 + por xmm3,xmm1 + movdqu XMMWORD[32+rdi],xmm2 + movdqu XMMWORD[48+rdi],xmm3 + +$L$add_doneq: + lea rsi,[((576+56))+rsp] + + mov r15,QWORD[((-48))+rsi] + + mov r14,QWORD[((-40))+rsi] + + mov r13,QWORD[((-32))+rsi] + + mov r12,QWORD[((-24))+rsi] + + mov rbx,QWORD[((-16))+rsi] + + mov rbp,QWORD[((-8))+rsi] + + lea rsp,[rsi] + +$L$point_addq_epilogue: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_ecp_nistz256_point_add_nohw: +global ecp_nistz256_point_add_affine_nohw + +ALIGN 32 +ecp_nistz256_point_add_affine_nohw: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_ecp_nistz256_point_add_affine_nohw: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + + + +_CET_ENDBR + push rbp + + push rbx + + push r12 + + push r13 + + push r14 + + push r15 + + sub rsp,32*15+8 + +$L$add_affineq_body: + + movdqu xmm0,XMMWORD[rsi] + mov rbx,rdx + movdqu xmm1,XMMWORD[16+rsi] + movdqu xmm2,XMMWORD[32+rsi] + movdqu xmm3,XMMWORD[48+rsi] + movdqu xmm4,XMMWORD[64+rsi] + movdqu xmm5,XMMWORD[80+rsi] + mov rax,QWORD[((64+0))+rsi] + mov r14,QWORD[((64+8))+rsi] + mov r15,QWORD[((64+16))+rsi] + mov r8,QWORD[((64+24))+rsi] + movdqa XMMWORD[320+rsp],xmm0 + movdqa XMMWORD[(320+16)+rsp],xmm1 + movdqa XMMWORD[352+rsp],xmm2 + movdqa XMMWORD[(352+16)+rsp],xmm3 + movdqa XMMWORD[384+rsp],xmm4 + movdqa XMMWORD[(384+16)+rsp],xmm5 + por xmm5,xmm4 + + movdqu xmm0,XMMWORD[rbx] + pshufd xmm3,xmm5,0xb1 + movdqu xmm1,XMMWORD[16+rbx] + movdqu xmm2,XMMWORD[32+rbx] + por xmm5,xmm3 + movdqu xmm3,XMMWORD[48+rbx] + movdqa XMMWORD[416+rsp],xmm0 + pshufd xmm4,xmm5,0x1e + movdqa XMMWORD[(416+16)+rsp],xmm1 + por xmm1,xmm0 +DB 102,72,15,110,199 + movdqa XMMWORD[448+rsp],xmm2 + movdqa XMMWORD[(448+16)+rsp],xmm3 + por xmm3,xmm2 + por xmm5,xmm4 + pxor xmm4,xmm4 + por xmm3,xmm1 + + lea rsi,[((64-0))+rsi] + lea rdi,[32+rsp] + call __ecp_nistz256_sqr_montq + + pcmpeqd xmm5,xmm4 + pshufd xmm4,xmm3,0xb1 + mov rax,QWORD[rbx] + + mov r9,r12 + por xmm4,xmm3 + pshufd xmm5,xmm5,0 + pshufd xmm3,xmm4,0x1e + mov r10,r13 + por xmm4,xmm3 + pxor xmm3,xmm3 + mov r11,r14 + pcmpeqd xmm4,xmm3 + pshufd xmm4,xmm4,0 + + lea rsi,[((32-0))+rsp] + mov r12,r15 + lea rdi,[rsp] + call __ecp_nistz256_mul_montq + + lea rbx,[320+rsp] + lea rdi,[64+rsp] + call __ecp_nistz256_sub_fromq + + mov rax,QWORD[384+rsp] + lea rbx,[384+rsp] + mov r9,QWORD[((0+32))+rsp] + mov r10,QWORD[((8+32))+rsp] + lea rsi,[((0+32))+rsp] + mov r11,QWORD[((16+32))+rsp] + mov r12,QWORD[((24+32))+rsp] + lea rdi,[32+rsp] + call __ecp_nistz256_mul_montq + + mov rax,QWORD[384+rsp] + lea rbx,[384+rsp] + mov r9,QWORD[((0+64))+rsp] + mov r10,QWORD[((8+64))+rsp] + lea rsi,[((0+64))+rsp] + mov r11,QWORD[((16+64))+rsp] + mov r12,QWORD[((24+64))+rsp] + lea rdi,[288+rsp] + call __ecp_nistz256_mul_montq + + mov rax,QWORD[448+rsp] + lea rbx,[448+rsp] + mov r9,QWORD[((0+32))+rsp] + mov r10,QWORD[((8+32))+rsp] + lea rsi,[((0+32))+rsp] + mov r11,QWORD[((16+32))+rsp] + mov r12,QWORD[((24+32))+rsp] + lea rdi,[32+rsp] + call __ecp_nistz256_mul_montq + + lea rbx,[352+rsp] + lea rdi,[96+rsp] + call __ecp_nistz256_sub_fromq + + mov rax,QWORD[((0+64))+rsp] + mov r14,QWORD[((8+64))+rsp] + lea rsi,[((0+64))+rsp] + mov r15,QWORD[((16+64))+rsp] + mov r8,QWORD[((24+64))+rsp] + lea rdi,[128+rsp] + call __ecp_nistz256_sqr_montq + + mov rax,QWORD[((0+96))+rsp] + mov r14,QWORD[((8+96))+rsp] + lea rsi,[((0+96))+rsp] + mov r15,QWORD[((16+96))+rsp] + mov r8,QWORD[((24+96))+rsp] + lea rdi,[192+rsp] + call __ecp_nistz256_sqr_montq + + mov rax,QWORD[128+rsp] + lea rbx,[128+rsp] + mov r9,QWORD[((0+64))+rsp] + mov r10,QWORD[((8+64))+rsp] + lea rsi,[((0+64))+rsp] + mov r11,QWORD[((16+64))+rsp] + mov r12,QWORD[((24+64))+rsp] + lea rdi,[160+rsp] + call __ecp_nistz256_mul_montq + + mov rax,QWORD[320+rsp] + lea rbx,[320+rsp] + mov r9,QWORD[((0+128))+rsp] + mov r10,QWORD[((8+128))+rsp] + lea rsi,[((0+128))+rsp] + mov r11,QWORD[((16+128))+rsp] + mov r12,QWORD[((24+128))+rsp] + lea rdi,[rsp] + call __ecp_nistz256_mul_montq + + + + + xor r11,r11 + add r12,r12 + lea rsi,[192+rsp] + adc r13,r13 + mov rax,r12 + adc r8,r8 + adc r9,r9 + mov rbp,r13 + adc r11,0 + + sub r12,-1 + mov rcx,r8 + sbb r13,r14 + sbb r8,0 + mov r10,r9 + sbb r9,r15 + sbb r11,0 + + cmovc r12,rax + mov rax,QWORD[rsi] + cmovc r13,rbp + mov rbp,QWORD[8+rsi] + cmovc r8,rcx + mov rcx,QWORD[16+rsi] + cmovc r9,r10 + mov r10,QWORD[24+rsi] + + call __ecp_nistz256_subq + + lea rbx,[160+rsp] + lea rdi,[224+rsp] + call __ecp_nistz256_sub_fromq + + mov rax,QWORD[((0+0))+rsp] + mov rbp,QWORD[((0+8))+rsp] + mov rcx,QWORD[((0+16))+rsp] + mov r10,QWORD[((0+24))+rsp] + lea rdi,[64+rsp] + + call __ecp_nistz256_subq + + mov QWORD[rdi],r12 + mov QWORD[8+rdi],r13 + mov QWORD[16+rdi],r8 + mov QWORD[24+rdi],r9 + mov rax,QWORD[352+rsp] + lea rbx,[352+rsp] + mov r9,QWORD[((0+160))+rsp] + mov r10,QWORD[((8+160))+rsp] + lea rsi,[((0+160))+rsp] + mov r11,QWORD[((16+160))+rsp] + mov r12,QWORD[((24+160))+rsp] + lea rdi,[32+rsp] + call __ecp_nistz256_mul_montq + + mov rax,QWORD[96+rsp] + lea rbx,[96+rsp] + mov r9,QWORD[((0+64))+rsp] + mov r10,QWORD[((8+64))+rsp] + lea rsi,[((0+64))+rsp] + mov r11,QWORD[((16+64))+rsp] + mov r12,QWORD[((24+64))+rsp] + lea rdi,[64+rsp] + call __ecp_nistz256_mul_montq + + lea rbx,[32+rsp] + lea rdi,[256+rsp] + call __ecp_nistz256_sub_fromq + +DB 102,72,15,126,199 + + movdqa xmm0,xmm5 + movdqa xmm1,xmm5 + pandn xmm0,XMMWORD[288+rsp] + movdqa xmm2,xmm5 + pandn xmm1,XMMWORD[((288+16))+rsp] + movdqa xmm3,xmm5 + pand xmm2,XMMWORD[$L$ONE_mont] + pand xmm3,XMMWORD[(($L$ONE_mont+16))] + por xmm2,xmm0 + por xmm3,xmm1 + + movdqa xmm0,xmm4 + movdqa xmm1,xmm4 + pandn xmm0,xmm2 + movdqa xmm2,xmm4 + pandn xmm1,xmm3 + movdqa xmm3,xmm4 + pand xmm2,XMMWORD[384+rsp] + pand xmm3,XMMWORD[((384+16))+rsp] + por xmm2,xmm0 + por xmm3,xmm1 + movdqu XMMWORD[64+rdi],xmm2 + movdqu XMMWORD[80+rdi],xmm3 + + movdqa xmm0,xmm5 + movdqa xmm1,xmm5 + pandn xmm0,XMMWORD[224+rsp] + movdqa xmm2,xmm5 + pandn xmm1,XMMWORD[((224+16))+rsp] + movdqa xmm3,xmm5 + pand xmm2,XMMWORD[416+rsp] + pand xmm3,XMMWORD[((416+16))+rsp] + por xmm2,xmm0 + por xmm3,xmm1 + + movdqa xmm0,xmm4 + movdqa xmm1,xmm4 + pandn xmm0,xmm2 + movdqa xmm2,xmm4 + pandn xmm1,xmm3 + movdqa xmm3,xmm4 + pand xmm2,XMMWORD[320+rsp] + pand xmm3,XMMWORD[((320+16))+rsp] + por xmm2,xmm0 + por xmm3,xmm1 + movdqu XMMWORD[rdi],xmm2 + movdqu XMMWORD[16+rdi],xmm3 + + movdqa xmm0,xmm5 + movdqa xmm1,xmm5 + pandn xmm0,XMMWORD[256+rsp] + movdqa xmm2,xmm5 + pandn xmm1,XMMWORD[((256+16))+rsp] + movdqa xmm3,xmm5 + pand xmm2,XMMWORD[448+rsp] + pand xmm3,XMMWORD[((448+16))+rsp] + por xmm2,xmm0 + por xmm3,xmm1 + + movdqa xmm0,xmm4 + movdqa xmm1,xmm4 + pandn xmm0,xmm2 + movdqa xmm2,xmm4 + pandn xmm1,xmm3 + movdqa xmm3,xmm4 + pand xmm2,XMMWORD[352+rsp] + pand xmm3,XMMWORD[((352+16))+rsp] + por xmm2,xmm0 + por xmm3,xmm1 + movdqu XMMWORD[32+rdi],xmm2 + movdqu XMMWORD[48+rdi],xmm3 + + lea rsi,[((480+56))+rsp] + + mov r15,QWORD[((-48))+rsi] + + mov r14,QWORD[((-40))+rsi] + + mov r13,QWORD[((-32))+rsi] + + mov r12,QWORD[((-24))+rsi] + + mov rbx,QWORD[((-16))+rsi] + + mov rbp,QWORD[((-8))+rsi] + + lea rsp,[rsi] + +$L$add_affineq_epilogue: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_ecp_nistz256_point_add_affine_nohw: + +ALIGN 32 +__ecp_nistz256_add_tox: + + xor r11,r11 + adc r12,QWORD[rbx] + adc r13,QWORD[8+rbx] + mov rax,r12 + adc r8,QWORD[16+rbx] + adc r9,QWORD[24+rbx] + mov rbp,r13 + adc r11,0 + + xor r10,r10 + sbb r12,-1 + mov rcx,r8 + sbb r13,r14 + sbb r8,0 + mov r10,r9 + sbb r9,r15 + sbb r11,0 + + cmovc r12,rax + cmovc r13,rbp + mov QWORD[rdi],r12 + cmovc r8,rcx + mov QWORD[8+rdi],r13 + cmovc r9,r10 + mov QWORD[16+rdi],r8 + mov QWORD[24+rdi],r9 + + ret + + + + +ALIGN 32 +__ecp_nistz256_sub_fromx: + + xor r11,r11 + sbb r12,QWORD[rbx] + sbb r13,QWORD[8+rbx] + mov rax,r12 + sbb r8,QWORD[16+rbx] + sbb r9,QWORD[24+rbx] + mov rbp,r13 + sbb r11,0 + + xor r10,r10 + adc r12,-1 + mov rcx,r8 + adc r13,r14 + adc r8,0 + mov r10,r9 + adc r9,r15 + + bt r11,0 + cmovnc r12,rax + cmovnc r13,rbp + mov QWORD[rdi],r12 + cmovnc r8,rcx + mov QWORD[8+rdi],r13 + cmovnc r9,r10 + mov QWORD[16+rdi],r8 + mov QWORD[24+rdi],r9 + + ret + + + + +ALIGN 32 +__ecp_nistz256_subx: + + xor r11,r11 + sbb rax,r12 + sbb rbp,r13 + mov r12,rax + sbb rcx,r8 + sbb r10,r9 + mov r13,rbp + sbb r11,0 + + xor r9,r9 + adc rax,-1 + mov r8,rcx + adc rbp,r14 + adc rcx,0 + mov r9,r10 + adc r10,r15 + + bt r11,0 + cmovc r12,rax + cmovc r13,rbp + cmovc r8,rcx + cmovc r9,r10 + + ret + + + + +ALIGN 32 +__ecp_nistz256_mul_by_2x: + + xor r11,r11 + adc r12,r12 + adc r13,r13 + mov rax,r12 + adc r8,r8 + adc r9,r9 + mov rbp,r13 + adc r11,0 + + xor r10,r10 + sbb r12,-1 + mov rcx,r8 + sbb r13,r14 + sbb r8,0 + mov r10,r9 + sbb r9,r15 + sbb r11,0 + + cmovc r12,rax + cmovc r13,rbp + mov QWORD[rdi],r12 + cmovc r8,rcx + mov QWORD[8+rdi],r13 + cmovc r9,r10 + mov QWORD[16+rdi],r8 + mov QWORD[24+rdi],r9 + + ret + + +global ecp_nistz256_point_double_adx + +ALIGN 32 +ecp_nistz256_point_double_adx: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_ecp_nistz256_point_double_adx: + mov rdi,rcx + mov rsi,rdx + + + +_CET_ENDBR + push rbp + + push rbx + + push r12 + + push r13 + + push r14 + + push r15 + + sub rsp,32*5+8 + +$L$point_doublex_body: + +$L$point_double_shortcutx: + movdqu xmm0,XMMWORD[rsi] + mov rbx,rsi + movdqu xmm1,XMMWORD[16+rsi] + mov r12,QWORD[((32+0))+rsi] + mov r13,QWORD[((32+8))+rsi] + mov r8,QWORD[((32+16))+rsi] + mov r9,QWORD[((32+24))+rsi] + mov r14,QWORD[(($L$poly+8))] + mov r15,QWORD[(($L$poly+24))] + movdqa XMMWORD[96+rsp],xmm0 + movdqa XMMWORD[(96+16)+rsp],xmm1 + lea r10,[32+rdi] + lea r11,[64+rdi] +DB 102,72,15,110,199 +DB 102,73,15,110,202 +DB 102,73,15,110,211 + + lea rdi,[rsp] + call __ecp_nistz256_mul_by_2x + + mov rdx,QWORD[((64+0))+rsi] + mov r14,QWORD[((64+8))+rsi] + mov r15,QWORD[((64+16))+rsi] + mov r8,QWORD[((64+24))+rsi] + lea rsi,[((64-128))+rsi] + lea rdi,[64+rsp] + call __ecp_nistz256_sqr_montx + + mov rdx,QWORD[((0+0))+rsp] + mov r14,QWORD[((8+0))+rsp] + lea rsi,[((-128+0))+rsp] + mov r15,QWORD[((16+0))+rsp] + mov r8,QWORD[((24+0))+rsp] + lea rdi,[rsp] + call __ecp_nistz256_sqr_montx + + mov rdx,QWORD[32+rbx] + mov r9,QWORD[((64+0))+rbx] + mov r10,QWORD[((64+8))+rbx] + mov r11,QWORD[((64+16))+rbx] + mov r12,QWORD[((64+24))+rbx] + lea rsi,[((64-128))+rbx] + lea rbx,[32+rbx] +DB 102,72,15,126,215 + call __ecp_nistz256_mul_montx + call __ecp_nistz256_mul_by_2x + + mov r12,QWORD[((96+0))+rsp] + mov r13,QWORD[((96+8))+rsp] + lea rbx,[64+rsp] + mov r8,QWORD[((96+16))+rsp] + mov r9,QWORD[((96+24))+rsp] + lea rdi,[32+rsp] + call __ecp_nistz256_add_tox + + mov r12,QWORD[((96+0))+rsp] + mov r13,QWORD[((96+8))+rsp] + lea rbx,[64+rsp] + mov r8,QWORD[((96+16))+rsp] + mov r9,QWORD[((96+24))+rsp] + lea rdi,[64+rsp] + call __ecp_nistz256_sub_fromx + + mov rdx,QWORD[((0+0))+rsp] + mov r14,QWORD[((8+0))+rsp] + lea rsi,[((-128+0))+rsp] + mov r15,QWORD[((16+0))+rsp] + mov r8,QWORD[((24+0))+rsp] +DB 102,72,15,126,207 + call __ecp_nistz256_sqr_montx + xor r9,r9 + mov rax,r12 + add r12,-1 + mov r10,r13 + adc r13,rsi + mov rcx,r14 + adc r14,0 + mov r8,r15 + adc r15,rbp + adc r9,0 + xor rsi,rsi + test rax,1 + + cmovz r12,rax + cmovz r13,r10 + cmovz r14,rcx + cmovz r15,r8 + cmovz r9,rsi + + mov rax,r13 + shr r12,1 + shl rax,63 + mov r10,r14 + shr r13,1 + or r12,rax + shl r10,63 + mov rcx,r15 + shr r14,1 + or r13,r10 + shl rcx,63 + mov QWORD[rdi],r12 + shr r15,1 + mov QWORD[8+rdi],r13 + shl r9,63 + or r14,rcx + or r15,r9 + mov QWORD[16+rdi],r14 + mov QWORD[24+rdi],r15 + mov rdx,QWORD[64+rsp] + lea rbx,[64+rsp] + mov r9,QWORD[((0+32))+rsp] + mov r10,QWORD[((8+32))+rsp] + lea rsi,[((-128+32))+rsp] + mov r11,QWORD[((16+32))+rsp] + mov r12,QWORD[((24+32))+rsp] + lea rdi,[32+rsp] + call __ecp_nistz256_mul_montx + + lea rdi,[128+rsp] + call __ecp_nistz256_mul_by_2x + + lea rbx,[32+rsp] + lea rdi,[32+rsp] + call __ecp_nistz256_add_tox + + mov rdx,QWORD[96+rsp] + lea rbx,[96+rsp] + mov r9,QWORD[((0+0))+rsp] + mov r10,QWORD[((8+0))+rsp] + lea rsi,[((-128+0))+rsp] + mov r11,QWORD[((16+0))+rsp] + mov r12,QWORD[((24+0))+rsp] + lea rdi,[rsp] + call __ecp_nistz256_mul_montx + + lea rdi,[128+rsp] + call __ecp_nistz256_mul_by_2x + + mov rdx,QWORD[((0+32))+rsp] + mov r14,QWORD[((8+32))+rsp] + lea rsi,[((-128+32))+rsp] + mov r15,QWORD[((16+32))+rsp] + mov r8,QWORD[((24+32))+rsp] +DB 102,72,15,126,199 + call __ecp_nistz256_sqr_montx + + lea rbx,[128+rsp] + mov r8,r14 + mov r9,r15 + mov r14,rsi + mov r15,rbp + call __ecp_nistz256_sub_fromx + + mov rax,QWORD[((0+0))+rsp] + mov rbp,QWORD[((0+8))+rsp] + mov rcx,QWORD[((0+16))+rsp] + mov r10,QWORD[((0+24))+rsp] + lea rdi,[rsp] + call __ecp_nistz256_subx + + mov rdx,QWORD[32+rsp] + lea rbx,[32+rsp] + mov r14,r12 + xor ecx,ecx + mov QWORD[((0+0))+rsp],r12 + mov r10,r13 + mov QWORD[((0+8))+rsp],r13 + cmovz r11,r8 + mov QWORD[((0+16))+rsp],r8 + lea rsi,[((0-128))+rsp] + cmovz r12,r9 + mov QWORD[((0+24))+rsp],r9 + mov r9,r14 + lea rdi,[rsp] + call __ecp_nistz256_mul_montx + +DB 102,72,15,126,203 +DB 102,72,15,126,207 + call __ecp_nistz256_sub_fromx + + lea rsi,[((160+56))+rsp] + + mov r15,QWORD[((-48))+rsi] + + mov r14,QWORD[((-40))+rsi] + + mov r13,QWORD[((-32))+rsi] + + mov r12,QWORD[((-24))+rsi] + + mov rbx,QWORD[((-16))+rsi] + + mov rbp,QWORD[((-8))+rsi] + + lea rsp,[rsi] + +$L$point_doublex_epilogue: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_ecp_nistz256_point_double_adx: +global ecp_nistz256_point_add_adx + +ALIGN 32 +ecp_nistz256_point_add_adx: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_ecp_nistz256_point_add_adx: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + + + +_CET_ENDBR + push rbp + + push rbx + + push r12 + + push r13 + + push r14 + + push r15 + + sub rsp,32*18+8 + +$L$point_addx_body: + + movdqu xmm0,XMMWORD[rsi] + movdqu xmm1,XMMWORD[16+rsi] + movdqu xmm2,XMMWORD[32+rsi] + movdqu xmm3,XMMWORD[48+rsi] + movdqu xmm4,XMMWORD[64+rsi] + movdqu xmm5,XMMWORD[80+rsi] + mov rbx,rsi + mov rsi,rdx + movdqa XMMWORD[384+rsp],xmm0 + movdqa XMMWORD[(384+16)+rsp],xmm1 + movdqa XMMWORD[416+rsp],xmm2 + movdqa XMMWORD[(416+16)+rsp],xmm3 + movdqa XMMWORD[448+rsp],xmm4 + movdqa XMMWORD[(448+16)+rsp],xmm5 + por xmm5,xmm4 + + movdqu xmm0,XMMWORD[rsi] + pshufd xmm3,xmm5,0xb1 + movdqu xmm1,XMMWORD[16+rsi] + movdqu xmm2,XMMWORD[32+rsi] + por xmm5,xmm3 + movdqu xmm3,XMMWORD[48+rsi] + mov rdx,QWORD[((64+0))+rsi] + mov r14,QWORD[((64+8))+rsi] + mov r15,QWORD[((64+16))+rsi] + mov r8,QWORD[((64+24))+rsi] + movdqa XMMWORD[480+rsp],xmm0 + pshufd xmm4,xmm5,0x1e + movdqa XMMWORD[(480+16)+rsp],xmm1 + movdqu xmm0,XMMWORD[64+rsi] + movdqu xmm1,XMMWORD[80+rsi] + movdqa XMMWORD[512+rsp],xmm2 + movdqa XMMWORD[(512+16)+rsp],xmm3 + por xmm5,xmm4 + pxor xmm4,xmm4 + por xmm1,xmm0 +DB 102,72,15,110,199 + + lea rsi,[((64-128))+rsi] + mov QWORD[((544+0))+rsp],rdx + mov QWORD[((544+8))+rsp],r14 + mov QWORD[((544+16))+rsp],r15 + mov QWORD[((544+24))+rsp],r8 + lea rdi,[96+rsp] + call __ecp_nistz256_sqr_montx + + pcmpeqd xmm5,xmm4 + pshufd xmm4,xmm1,0xb1 + por xmm4,xmm1 + pshufd xmm5,xmm5,0 + pshufd xmm3,xmm4,0x1e + por xmm4,xmm3 + pxor xmm3,xmm3 + pcmpeqd xmm4,xmm3 + pshufd xmm4,xmm4,0 + mov rdx,QWORD[((64+0))+rbx] + mov r14,QWORD[((64+8))+rbx] + mov r15,QWORD[((64+16))+rbx] + mov r8,QWORD[((64+24))+rbx] +DB 102,72,15,110,203 + + lea rsi,[((64-128))+rbx] + lea rdi,[32+rsp] + call __ecp_nistz256_sqr_montx + + mov rdx,QWORD[544+rsp] + lea rbx,[544+rsp] + mov r9,QWORD[((0+96))+rsp] + mov r10,QWORD[((8+96))+rsp] + lea rsi,[((-128+96))+rsp] + mov r11,QWORD[((16+96))+rsp] + mov r12,QWORD[((24+96))+rsp] + lea rdi,[224+rsp] + call __ecp_nistz256_mul_montx + + mov rdx,QWORD[448+rsp] + lea rbx,[448+rsp] + mov r9,QWORD[((0+32))+rsp] + mov r10,QWORD[((8+32))+rsp] + lea rsi,[((-128+32))+rsp] + mov r11,QWORD[((16+32))+rsp] + mov r12,QWORD[((24+32))+rsp] + lea rdi,[256+rsp] + call __ecp_nistz256_mul_montx + + mov rdx,QWORD[416+rsp] + lea rbx,[416+rsp] + mov r9,QWORD[((0+224))+rsp] + mov r10,QWORD[((8+224))+rsp] + lea rsi,[((-128+224))+rsp] + mov r11,QWORD[((16+224))+rsp] + mov r12,QWORD[((24+224))+rsp] + lea rdi,[224+rsp] + call __ecp_nistz256_mul_montx + + mov rdx,QWORD[512+rsp] + lea rbx,[512+rsp] + mov r9,QWORD[((0+256))+rsp] + mov r10,QWORD[((8+256))+rsp] + lea rsi,[((-128+256))+rsp] + mov r11,QWORD[((16+256))+rsp] + mov r12,QWORD[((24+256))+rsp] + lea rdi,[256+rsp] + call __ecp_nistz256_mul_montx + + lea rbx,[224+rsp] + lea rdi,[64+rsp] + call __ecp_nistz256_sub_fromx + + or r12,r13 + movdqa xmm2,xmm4 + or r12,r8 + or r12,r9 + por xmm2,xmm5 +DB 102,73,15,110,220 + + mov rdx,QWORD[384+rsp] + lea rbx,[384+rsp] + mov r9,QWORD[((0+96))+rsp] + mov r10,QWORD[((8+96))+rsp] + lea rsi,[((-128+96))+rsp] + mov r11,QWORD[((16+96))+rsp] + mov r12,QWORD[((24+96))+rsp] + lea rdi,[160+rsp] + call __ecp_nistz256_mul_montx + + mov rdx,QWORD[480+rsp] + lea rbx,[480+rsp] + mov r9,QWORD[((0+32))+rsp] + mov r10,QWORD[((8+32))+rsp] + lea rsi,[((-128+32))+rsp] + mov r11,QWORD[((16+32))+rsp] + mov r12,QWORD[((24+32))+rsp] + lea rdi,[192+rsp] + call __ecp_nistz256_mul_montx + + lea rbx,[160+rsp] + lea rdi,[rsp] + call __ecp_nistz256_sub_fromx + + or r12,r13 + or r12,r8 + or r12,r9 + +DB 102,73,15,126,208 +DB 102,73,15,126,217 + or r12,r8 + DB 0x3e + jnz NEAR $L$add_proceedx + + + + test r9,r9 + jz NEAR $L$add_doublex + + + + + + +DB 102,72,15,126,199 + pxor xmm0,xmm0 + movdqu XMMWORD[rdi],xmm0 + movdqu XMMWORD[16+rdi],xmm0 + movdqu XMMWORD[32+rdi],xmm0 + movdqu XMMWORD[48+rdi],xmm0 + movdqu XMMWORD[64+rdi],xmm0 + movdqu XMMWORD[80+rdi],xmm0 + jmp NEAR $L$add_donex + +ALIGN 32 +$L$add_doublex: +DB 102,72,15,126,206 +DB 102,72,15,126,199 + add rsp,416 + + jmp NEAR $L$point_double_shortcutx + + +ALIGN 32 +$L$add_proceedx: + mov rdx,QWORD[((0+64))+rsp] + mov r14,QWORD[((8+64))+rsp] + lea rsi,[((-128+64))+rsp] + mov r15,QWORD[((16+64))+rsp] + mov r8,QWORD[((24+64))+rsp] + lea rdi,[96+rsp] + call __ecp_nistz256_sqr_montx + + mov rdx,QWORD[448+rsp] + lea rbx,[448+rsp] + mov r9,QWORD[((0+0))+rsp] + mov r10,QWORD[((8+0))+rsp] + lea rsi,[((-128+0))+rsp] + mov r11,QWORD[((16+0))+rsp] + mov r12,QWORD[((24+0))+rsp] + lea rdi,[352+rsp] + call __ecp_nistz256_mul_montx + + mov rdx,QWORD[((0+0))+rsp] + mov r14,QWORD[((8+0))+rsp] + lea rsi,[((-128+0))+rsp] + mov r15,QWORD[((16+0))+rsp] + mov r8,QWORD[((24+0))+rsp] + lea rdi,[32+rsp] + call __ecp_nistz256_sqr_montx + + mov rdx,QWORD[544+rsp] + lea rbx,[544+rsp] + mov r9,QWORD[((0+352))+rsp] + mov r10,QWORD[((8+352))+rsp] + lea rsi,[((-128+352))+rsp] + mov r11,QWORD[((16+352))+rsp] + mov r12,QWORD[((24+352))+rsp] + lea rdi,[352+rsp] + call __ecp_nistz256_mul_montx + + mov rdx,QWORD[rsp] + lea rbx,[rsp] + mov r9,QWORD[((0+32))+rsp] + mov r10,QWORD[((8+32))+rsp] + lea rsi,[((-128+32))+rsp] + mov r11,QWORD[((16+32))+rsp] + mov r12,QWORD[((24+32))+rsp] + lea rdi,[128+rsp] + call __ecp_nistz256_mul_montx + + mov rdx,QWORD[160+rsp] + lea rbx,[160+rsp] + mov r9,QWORD[((0+32))+rsp] + mov r10,QWORD[((8+32))+rsp] + lea rsi,[((-128+32))+rsp] + mov r11,QWORD[((16+32))+rsp] + mov r12,QWORD[((24+32))+rsp] + lea rdi,[192+rsp] + call __ecp_nistz256_mul_montx + + + + + xor r11,r11 + add r12,r12 + lea rsi,[96+rsp] + adc r13,r13 + mov rax,r12 + adc r8,r8 + adc r9,r9 + mov rbp,r13 + adc r11,0 + + sub r12,-1 + mov rcx,r8 + sbb r13,r14 + sbb r8,0 + mov r10,r9 + sbb r9,r15 + sbb r11,0 + + cmovc r12,rax + mov rax,QWORD[rsi] + cmovc r13,rbp + mov rbp,QWORD[8+rsi] + cmovc r8,rcx + mov rcx,QWORD[16+rsi] + cmovc r9,r10 + mov r10,QWORD[24+rsi] + + call __ecp_nistz256_subx + + lea rbx,[128+rsp] + lea rdi,[288+rsp] + call __ecp_nistz256_sub_fromx + + mov rax,QWORD[((192+0))+rsp] + mov rbp,QWORD[((192+8))+rsp] + mov rcx,QWORD[((192+16))+rsp] + mov r10,QWORD[((192+24))+rsp] + lea rdi,[320+rsp] + + call __ecp_nistz256_subx + + mov QWORD[rdi],r12 + mov QWORD[8+rdi],r13 + mov QWORD[16+rdi],r8 + mov QWORD[24+rdi],r9 + mov rdx,QWORD[128+rsp] + lea rbx,[128+rsp] + mov r9,QWORD[((0+224))+rsp] + mov r10,QWORD[((8+224))+rsp] + lea rsi,[((-128+224))+rsp] + mov r11,QWORD[((16+224))+rsp] + mov r12,QWORD[((24+224))+rsp] + lea rdi,[256+rsp] + call __ecp_nistz256_mul_montx + + mov rdx,QWORD[320+rsp] + lea rbx,[320+rsp] + mov r9,QWORD[((0+64))+rsp] + mov r10,QWORD[((8+64))+rsp] + lea rsi,[((-128+64))+rsp] + mov r11,QWORD[((16+64))+rsp] + mov r12,QWORD[((24+64))+rsp] + lea rdi,[320+rsp] + call __ecp_nistz256_mul_montx + + lea rbx,[256+rsp] + lea rdi,[320+rsp] + call __ecp_nistz256_sub_fromx + +DB 102,72,15,126,199 + + movdqa xmm0,xmm5 + movdqa xmm1,xmm5 + pandn xmm0,XMMWORD[352+rsp] + movdqa xmm2,xmm5 + pandn xmm1,XMMWORD[((352+16))+rsp] + movdqa xmm3,xmm5 + pand xmm2,XMMWORD[544+rsp] + pand xmm3,XMMWORD[((544+16))+rsp] + por xmm2,xmm0 + por xmm3,xmm1 + + movdqa xmm0,xmm4 + movdqa xmm1,xmm4 + pandn xmm0,xmm2 + movdqa xmm2,xmm4 + pandn xmm1,xmm3 + movdqa xmm3,xmm4 + pand xmm2,XMMWORD[448+rsp] + pand xmm3,XMMWORD[((448+16))+rsp] + por xmm2,xmm0 + por xmm3,xmm1 + movdqu XMMWORD[64+rdi],xmm2 + movdqu XMMWORD[80+rdi],xmm3 + + movdqa xmm0,xmm5 + movdqa xmm1,xmm5 + pandn xmm0,XMMWORD[288+rsp] + movdqa xmm2,xmm5 + pandn xmm1,XMMWORD[((288+16))+rsp] + movdqa xmm3,xmm5 + pand xmm2,XMMWORD[480+rsp] + pand xmm3,XMMWORD[((480+16))+rsp] + por xmm2,xmm0 + por xmm3,xmm1 + + movdqa xmm0,xmm4 + movdqa xmm1,xmm4 + pandn xmm0,xmm2 + movdqa xmm2,xmm4 + pandn xmm1,xmm3 + movdqa xmm3,xmm4 + pand xmm2,XMMWORD[384+rsp] + pand xmm3,XMMWORD[((384+16))+rsp] + por xmm2,xmm0 + por xmm3,xmm1 + movdqu XMMWORD[rdi],xmm2 + movdqu XMMWORD[16+rdi],xmm3 + + movdqa xmm0,xmm5 + movdqa xmm1,xmm5 + pandn xmm0,XMMWORD[320+rsp] + movdqa xmm2,xmm5 + pandn xmm1,XMMWORD[((320+16))+rsp] + movdqa xmm3,xmm5 + pand xmm2,XMMWORD[512+rsp] + pand xmm3,XMMWORD[((512+16))+rsp] + por xmm2,xmm0 + por xmm3,xmm1 + + movdqa xmm0,xmm4 + movdqa xmm1,xmm4 + pandn xmm0,xmm2 + movdqa xmm2,xmm4 + pandn xmm1,xmm3 + movdqa xmm3,xmm4 + pand xmm2,XMMWORD[416+rsp] + pand xmm3,XMMWORD[((416+16))+rsp] + por xmm2,xmm0 + por xmm3,xmm1 + movdqu XMMWORD[32+rdi],xmm2 + movdqu XMMWORD[48+rdi],xmm3 + +$L$add_donex: + lea rsi,[((576+56))+rsp] + + mov r15,QWORD[((-48))+rsi] + + mov r14,QWORD[((-40))+rsi] + + mov r13,QWORD[((-32))+rsi] + + mov r12,QWORD[((-24))+rsi] + + mov rbx,QWORD[((-16))+rsi] + + mov rbp,QWORD[((-8))+rsi] + + lea rsp,[rsi] + +$L$point_addx_epilogue: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_ecp_nistz256_point_add_adx: +global ecp_nistz256_point_add_affine_adx + +ALIGN 32 +ecp_nistz256_point_add_affine_adx: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_ecp_nistz256_point_add_affine_adx: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + + + +_CET_ENDBR + push rbp + + push rbx + + push r12 + + push r13 + + push r14 + + push r15 + + sub rsp,32*15+8 + +$L$add_affinex_body: + + movdqu xmm0,XMMWORD[rsi] + mov rbx,rdx + movdqu xmm1,XMMWORD[16+rsi] + movdqu xmm2,XMMWORD[32+rsi] + movdqu xmm3,XMMWORD[48+rsi] + movdqu xmm4,XMMWORD[64+rsi] + movdqu xmm5,XMMWORD[80+rsi] + mov rdx,QWORD[((64+0))+rsi] + mov r14,QWORD[((64+8))+rsi] + mov r15,QWORD[((64+16))+rsi] + mov r8,QWORD[((64+24))+rsi] + movdqa XMMWORD[320+rsp],xmm0 + movdqa XMMWORD[(320+16)+rsp],xmm1 + movdqa XMMWORD[352+rsp],xmm2 + movdqa XMMWORD[(352+16)+rsp],xmm3 + movdqa XMMWORD[384+rsp],xmm4 + movdqa XMMWORD[(384+16)+rsp],xmm5 + por xmm5,xmm4 + + movdqu xmm0,XMMWORD[rbx] + pshufd xmm3,xmm5,0xb1 + movdqu xmm1,XMMWORD[16+rbx] + movdqu xmm2,XMMWORD[32+rbx] + por xmm5,xmm3 + movdqu xmm3,XMMWORD[48+rbx] + movdqa XMMWORD[416+rsp],xmm0 + pshufd xmm4,xmm5,0x1e + movdqa XMMWORD[(416+16)+rsp],xmm1 + por xmm1,xmm0 +DB 102,72,15,110,199 + movdqa XMMWORD[448+rsp],xmm2 + movdqa XMMWORD[(448+16)+rsp],xmm3 + por xmm3,xmm2 + por xmm5,xmm4 + pxor xmm4,xmm4 + por xmm3,xmm1 + + lea rsi,[((64-128))+rsi] + lea rdi,[32+rsp] + call __ecp_nistz256_sqr_montx + + pcmpeqd xmm5,xmm4 + pshufd xmm4,xmm3,0xb1 + mov rdx,QWORD[rbx] + + mov r9,r12 + por xmm4,xmm3 + pshufd xmm5,xmm5,0 + pshufd xmm3,xmm4,0x1e + mov r10,r13 + por xmm4,xmm3 + pxor xmm3,xmm3 + mov r11,r14 + pcmpeqd xmm4,xmm3 + pshufd xmm4,xmm4,0 + + lea rsi,[((32-128))+rsp] + mov r12,r15 + lea rdi,[rsp] + call __ecp_nistz256_mul_montx + + lea rbx,[320+rsp] + lea rdi,[64+rsp] + call __ecp_nistz256_sub_fromx + + mov rdx,QWORD[384+rsp] + lea rbx,[384+rsp] + mov r9,QWORD[((0+32))+rsp] + mov r10,QWORD[((8+32))+rsp] + lea rsi,[((-128+32))+rsp] + mov r11,QWORD[((16+32))+rsp] + mov r12,QWORD[((24+32))+rsp] + lea rdi,[32+rsp] + call __ecp_nistz256_mul_montx + + mov rdx,QWORD[384+rsp] + lea rbx,[384+rsp] + mov r9,QWORD[((0+64))+rsp] + mov r10,QWORD[((8+64))+rsp] + lea rsi,[((-128+64))+rsp] + mov r11,QWORD[((16+64))+rsp] + mov r12,QWORD[((24+64))+rsp] + lea rdi,[288+rsp] + call __ecp_nistz256_mul_montx + + mov rdx,QWORD[448+rsp] + lea rbx,[448+rsp] + mov r9,QWORD[((0+32))+rsp] + mov r10,QWORD[((8+32))+rsp] + lea rsi,[((-128+32))+rsp] + mov r11,QWORD[((16+32))+rsp] + mov r12,QWORD[((24+32))+rsp] + lea rdi,[32+rsp] + call __ecp_nistz256_mul_montx + + lea rbx,[352+rsp] + lea rdi,[96+rsp] + call __ecp_nistz256_sub_fromx + + mov rdx,QWORD[((0+64))+rsp] + mov r14,QWORD[((8+64))+rsp] + lea rsi,[((-128+64))+rsp] + mov r15,QWORD[((16+64))+rsp] + mov r8,QWORD[((24+64))+rsp] + lea rdi,[128+rsp] + call __ecp_nistz256_sqr_montx + + mov rdx,QWORD[((0+96))+rsp] + mov r14,QWORD[((8+96))+rsp] + lea rsi,[((-128+96))+rsp] + mov r15,QWORD[((16+96))+rsp] + mov r8,QWORD[((24+96))+rsp] + lea rdi,[192+rsp] + call __ecp_nistz256_sqr_montx + + mov rdx,QWORD[128+rsp] + lea rbx,[128+rsp] + mov r9,QWORD[((0+64))+rsp] + mov r10,QWORD[((8+64))+rsp] + lea rsi,[((-128+64))+rsp] + mov r11,QWORD[((16+64))+rsp] + mov r12,QWORD[((24+64))+rsp] + lea rdi,[160+rsp] + call __ecp_nistz256_mul_montx + + mov rdx,QWORD[320+rsp] + lea rbx,[320+rsp] + mov r9,QWORD[((0+128))+rsp] + mov r10,QWORD[((8+128))+rsp] + lea rsi,[((-128+128))+rsp] + mov r11,QWORD[((16+128))+rsp] + mov r12,QWORD[((24+128))+rsp] + lea rdi,[rsp] + call __ecp_nistz256_mul_montx + + + + + xor r11,r11 + add r12,r12 + lea rsi,[192+rsp] + adc r13,r13 + mov rax,r12 + adc r8,r8 + adc r9,r9 + mov rbp,r13 + adc r11,0 + + sub r12,-1 + mov rcx,r8 + sbb r13,r14 + sbb r8,0 + mov r10,r9 + sbb r9,r15 + sbb r11,0 + + cmovc r12,rax + mov rax,QWORD[rsi] + cmovc r13,rbp + mov rbp,QWORD[8+rsi] + cmovc r8,rcx + mov rcx,QWORD[16+rsi] + cmovc r9,r10 + mov r10,QWORD[24+rsi] + + call __ecp_nistz256_subx + + lea rbx,[160+rsp] + lea rdi,[224+rsp] + call __ecp_nistz256_sub_fromx + + mov rax,QWORD[((0+0))+rsp] + mov rbp,QWORD[((0+8))+rsp] + mov rcx,QWORD[((0+16))+rsp] + mov r10,QWORD[((0+24))+rsp] + lea rdi,[64+rsp] + + call __ecp_nistz256_subx + + mov QWORD[rdi],r12 + mov QWORD[8+rdi],r13 + mov QWORD[16+rdi],r8 + mov QWORD[24+rdi],r9 + mov rdx,QWORD[352+rsp] + lea rbx,[352+rsp] + mov r9,QWORD[((0+160))+rsp] + mov r10,QWORD[((8+160))+rsp] + lea rsi,[((-128+160))+rsp] + mov r11,QWORD[((16+160))+rsp] + mov r12,QWORD[((24+160))+rsp] + lea rdi,[32+rsp] + call __ecp_nistz256_mul_montx + + mov rdx,QWORD[96+rsp] + lea rbx,[96+rsp] + mov r9,QWORD[((0+64))+rsp] + mov r10,QWORD[((8+64))+rsp] + lea rsi,[((-128+64))+rsp] + mov r11,QWORD[((16+64))+rsp] + mov r12,QWORD[((24+64))+rsp] + lea rdi,[64+rsp] + call __ecp_nistz256_mul_montx + + lea rbx,[32+rsp] + lea rdi,[256+rsp] + call __ecp_nistz256_sub_fromx + +DB 102,72,15,126,199 + + movdqa xmm0,xmm5 + movdqa xmm1,xmm5 + pandn xmm0,XMMWORD[288+rsp] + movdqa xmm2,xmm5 + pandn xmm1,XMMWORD[((288+16))+rsp] + movdqa xmm3,xmm5 + pand xmm2,XMMWORD[$L$ONE_mont] + pand xmm3,XMMWORD[(($L$ONE_mont+16))] + por xmm2,xmm0 + por xmm3,xmm1 + + movdqa xmm0,xmm4 + movdqa xmm1,xmm4 + pandn xmm0,xmm2 + movdqa xmm2,xmm4 + pandn xmm1,xmm3 + movdqa xmm3,xmm4 + pand xmm2,XMMWORD[384+rsp] + pand xmm3,XMMWORD[((384+16))+rsp] + por xmm2,xmm0 + por xmm3,xmm1 + movdqu XMMWORD[64+rdi],xmm2 + movdqu XMMWORD[80+rdi],xmm3 + + movdqa xmm0,xmm5 + movdqa xmm1,xmm5 + pandn xmm0,XMMWORD[224+rsp] + movdqa xmm2,xmm5 + pandn xmm1,XMMWORD[((224+16))+rsp] + movdqa xmm3,xmm5 + pand xmm2,XMMWORD[416+rsp] + pand xmm3,XMMWORD[((416+16))+rsp] + por xmm2,xmm0 + por xmm3,xmm1 + + movdqa xmm0,xmm4 + movdqa xmm1,xmm4 + pandn xmm0,xmm2 + movdqa xmm2,xmm4 + pandn xmm1,xmm3 + movdqa xmm3,xmm4 + pand xmm2,XMMWORD[320+rsp] + pand xmm3,XMMWORD[((320+16))+rsp] + por xmm2,xmm0 + por xmm3,xmm1 + movdqu XMMWORD[rdi],xmm2 + movdqu XMMWORD[16+rdi],xmm3 + + movdqa xmm0,xmm5 + movdqa xmm1,xmm5 + pandn xmm0,XMMWORD[256+rsp] + movdqa xmm2,xmm5 + pandn xmm1,XMMWORD[((256+16))+rsp] + movdqa xmm3,xmm5 + pand xmm2,XMMWORD[448+rsp] + pand xmm3,XMMWORD[((448+16))+rsp] + por xmm2,xmm0 + por xmm3,xmm1 + + movdqa xmm0,xmm4 + movdqa xmm1,xmm4 + pandn xmm0,xmm2 + movdqa xmm2,xmm4 + pandn xmm1,xmm3 + movdqa xmm3,xmm4 + pand xmm2,XMMWORD[352+rsp] + pand xmm3,XMMWORD[((352+16))+rsp] + por xmm2,xmm0 + por xmm3,xmm1 + movdqu XMMWORD[32+rdi],xmm2 + movdqu XMMWORD[48+rdi],xmm3 + + lea rsi,[((480+56))+rsp] + + mov r15,QWORD[((-48))+rsi] + + mov r14,QWORD[((-40))+rsi] + + mov r13,QWORD[((-32))+rsi] + + mov r12,QWORD[((-24))+rsi] + + mov rbx,QWORD[((-16))+rsi] + + mov rbp,QWORD[((-8))+rsi] + + lea rsp,[rsi] + +$L$add_affinex_epilogue: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_ecp_nistz256_point_add_affine_adx: +EXTERN __imp_RtlVirtualUnwind + + +ALIGN 16 +short_handler: + push rsi + push rdi + push rbx + push rbp + push r12 + push r13 + push r14 + push r15 + pushfq + sub rsp,64 + + mov rax,QWORD[120+r8] + mov rbx,QWORD[248+r8] + + mov rsi,QWORD[8+r9] + mov r11,QWORD[56+r9] + + mov r10d,DWORD[r11] + lea r10,[r10*1+rsi] + cmp rbx,r10 + jb NEAR $L$common_seh_tail + + mov rax,QWORD[152+r8] + + mov r10d,DWORD[4+r11] + lea r10,[r10*1+rsi] + cmp rbx,r10 + jae NEAR $L$common_seh_tail + + lea rax,[16+rax] + + mov r12,QWORD[((-8))+rax] + mov r13,QWORD[((-16))+rax] + mov QWORD[216+r8],r12 + mov QWORD[224+r8],r13 + + jmp NEAR $L$common_seh_tail + + + +ALIGN 16 +full_handler: + push rsi + push rdi + push rbx + push rbp + push r12 + push r13 + push r14 + push r15 + pushfq + sub rsp,64 + + mov rax,QWORD[120+r8] + mov rbx,QWORD[248+r8] + + mov rsi,QWORD[8+r9] + mov r11,QWORD[56+r9] + + mov r10d,DWORD[r11] + lea r10,[r10*1+rsi] + cmp rbx,r10 + jb NEAR $L$common_seh_tail + + mov rax,QWORD[152+r8] + + mov r10d,DWORD[4+r11] + lea r10,[r10*1+rsi] + cmp rbx,r10 + jae NEAR $L$common_seh_tail + + mov r10d,DWORD[8+r11] + lea rax,[r10*1+rax] + + mov rbp,QWORD[((-8))+rax] + mov rbx,QWORD[((-16))+rax] + mov r12,QWORD[((-24))+rax] + mov r13,QWORD[((-32))+rax] + mov r14,QWORD[((-40))+rax] + mov r15,QWORD[((-48))+rax] + mov QWORD[144+r8],rbx + mov QWORD[160+r8],rbp + mov QWORD[216+r8],r12 + mov QWORD[224+r8],r13 + mov QWORD[232+r8],r14 + mov QWORD[240+r8],r15 + +$L$common_seh_tail: + mov rdi,QWORD[8+rax] + mov rsi,QWORD[16+rax] + mov QWORD[152+r8],rax + mov QWORD[168+r8],rsi + mov QWORD[176+r8],rdi + + mov rdi,QWORD[40+r9] + mov rsi,r8 + mov ecx,154 + DD 0xa548f3fc + + mov rsi,r9 + xor rcx,rcx + mov rdx,QWORD[8+rsi] + mov r8,QWORD[rsi] + mov r9,QWORD[16+rsi] + mov r10,QWORD[40+rsi] + lea r11,[56+rsi] + lea r12,[24+rsi] + mov QWORD[32+rsp],r10 + mov QWORD[40+rsp],r11 + mov QWORD[48+rsp],r12 + mov QWORD[56+rsp],rcx + call QWORD[__imp_RtlVirtualUnwind] + + mov eax,1 + add rsp,64 + popfq + pop r15 + pop r14 + pop r13 + pop r12 + pop rbp + pop rbx + pop rdi + pop rsi + ret + + +section .pdata rdata align=4 +ALIGN 4 + DD $L$SEH_begin_ecp_nistz256_neg wrt ..imagebase + DD $L$SEH_end_ecp_nistz256_neg wrt ..imagebase + DD $L$SEH_info_ecp_nistz256_neg wrt ..imagebase + + DD $L$SEH_begin_ecp_nistz256_ord_mul_mont_nohw wrt ..imagebase + DD $L$SEH_end_ecp_nistz256_ord_mul_mont_nohw wrt ..imagebase + DD $L$SEH_info_ecp_nistz256_ord_mul_mont_nohw wrt ..imagebase + + DD $L$SEH_begin_ecp_nistz256_ord_sqr_mont_nohw wrt ..imagebase + DD $L$SEH_end_ecp_nistz256_ord_sqr_mont_nohw wrt ..imagebase + DD $L$SEH_info_ecp_nistz256_ord_sqr_mont_nohw wrt ..imagebase + DD $L$SEH_begin_ecp_nistz256_ord_mul_mont_adx wrt ..imagebase + DD $L$SEH_end_ecp_nistz256_ord_mul_mont_adx wrt ..imagebase + DD $L$SEH_info_ecp_nistz256_ord_mul_mont_adx wrt ..imagebase + + DD $L$SEH_begin_ecp_nistz256_ord_sqr_mont_adx wrt ..imagebase + DD $L$SEH_end_ecp_nistz256_ord_sqr_mont_adx wrt ..imagebase + DD $L$SEH_info_ecp_nistz256_ord_sqr_mont_adx wrt ..imagebase + DD $L$SEH_begin_ecp_nistz256_mul_mont_nohw wrt ..imagebase + DD $L$SEH_end_ecp_nistz256_mul_mont_nohw wrt ..imagebase + DD $L$SEH_info_ecp_nistz256_mul_mont_nohw wrt ..imagebase + + DD $L$SEH_begin_ecp_nistz256_sqr_mont_nohw wrt ..imagebase + DD $L$SEH_end_ecp_nistz256_sqr_mont_nohw wrt ..imagebase + DD $L$SEH_info_ecp_nistz256_sqr_mont_nohw wrt ..imagebase + DD $L$SEH_begin_ecp_nistz256_mul_mont_adx wrt ..imagebase + DD $L$SEH_end_ecp_nistz256_mul_mont_adx wrt ..imagebase + DD $L$SEH_info_ecp_nistz256_mul_mont_adx wrt ..imagebase + + DD $L$SEH_begin_ecp_nistz256_sqr_mont_adx wrt ..imagebase + DD $L$SEH_end_ecp_nistz256_sqr_mont_adx wrt ..imagebase + DD $L$SEH_info_ecp_nistz256_sqr_mont_adx wrt ..imagebase + DD $L$SEH_begin_ecp_nistz256_select_w5_nohw wrt ..imagebase + DD $L$SEH_end_ecp_nistz256_select_w5_nohw wrt ..imagebase + DD $L$SEH_info_ecp_nistz256_select_wX_nohw wrt ..imagebase + + DD $L$SEH_begin_ecp_nistz256_select_w7_nohw wrt ..imagebase + DD $L$SEH_end_ecp_nistz256_select_w7_nohw wrt ..imagebase + DD $L$SEH_info_ecp_nistz256_select_wX_nohw wrt ..imagebase + DD $L$SEH_begin_ecp_nistz256_select_w5_avx2 wrt ..imagebase + DD $L$SEH_end_ecp_nistz256_select_w5_avx2 wrt ..imagebase + DD $L$SEH_info_ecp_nistz256_select_wX_avx2 wrt ..imagebase + + DD $L$SEH_begin_ecp_nistz256_select_w7_avx2 wrt ..imagebase + DD $L$SEH_end_ecp_nistz256_select_w7_avx2 wrt ..imagebase + DD $L$SEH_info_ecp_nistz256_select_wX_avx2 wrt ..imagebase + DD $L$SEH_begin_ecp_nistz256_point_double_nohw wrt ..imagebase + DD $L$SEH_end_ecp_nistz256_point_double_nohw wrt ..imagebase + DD $L$SEH_info_ecp_nistz256_point_double_nohw wrt ..imagebase + + DD $L$SEH_begin_ecp_nistz256_point_add_nohw wrt ..imagebase + DD $L$SEH_end_ecp_nistz256_point_add_nohw wrt ..imagebase + DD $L$SEH_info_ecp_nistz256_point_add_nohw wrt ..imagebase + + DD $L$SEH_begin_ecp_nistz256_point_add_affine_nohw wrt ..imagebase + DD $L$SEH_end_ecp_nistz256_point_add_affine_nohw wrt ..imagebase + DD $L$SEH_info_ecp_nistz256_point_add_affine_nohw wrt ..imagebase + DD $L$SEH_begin_ecp_nistz256_point_double_adx wrt ..imagebase + DD $L$SEH_end_ecp_nistz256_point_double_adx wrt ..imagebase + DD $L$SEH_info_ecp_nistz256_point_double_adx wrt ..imagebase + + DD $L$SEH_begin_ecp_nistz256_point_add_adx wrt ..imagebase + DD $L$SEH_end_ecp_nistz256_point_add_adx wrt ..imagebase + DD $L$SEH_info_ecp_nistz256_point_add_adx wrt ..imagebase + + DD $L$SEH_begin_ecp_nistz256_point_add_affine_adx wrt ..imagebase + DD $L$SEH_end_ecp_nistz256_point_add_affine_adx wrt ..imagebase + DD $L$SEH_info_ecp_nistz256_point_add_affine_adx wrt ..imagebase + +section .xdata rdata align=8 +ALIGN 8 +$L$SEH_info_ecp_nistz256_neg: + DB 9,0,0,0 + DD short_handler wrt ..imagebase + DD $L$neg_body wrt ..imagebase,$L$neg_epilogue wrt ..imagebase +$L$SEH_info_ecp_nistz256_ord_mul_mont_nohw: + DB 9,0,0,0 + DD full_handler wrt ..imagebase + DD $L$ord_mul_body wrt ..imagebase,$L$ord_mul_epilogue wrt ..imagebase + DD 48,0 +$L$SEH_info_ecp_nistz256_ord_sqr_mont_nohw: + DB 9,0,0,0 + DD full_handler wrt ..imagebase + DD $L$ord_sqr_body wrt ..imagebase,$L$ord_sqr_epilogue wrt ..imagebase + DD 48,0 +$L$SEH_info_ecp_nistz256_ord_mul_mont_adx: + DB 9,0,0,0 + DD full_handler wrt ..imagebase + DD $L$ord_mulx_body wrt ..imagebase,$L$ord_mulx_epilogue wrt ..imagebase + DD 48,0 +$L$SEH_info_ecp_nistz256_ord_sqr_mont_adx: + DB 9,0,0,0 + DD full_handler wrt ..imagebase + DD $L$ord_sqrx_body wrt ..imagebase,$L$ord_sqrx_epilogue wrt ..imagebase + DD 48,0 +$L$SEH_info_ecp_nistz256_mul_mont_nohw: + DB 9,0,0,0 + DD full_handler wrt ..imagebase + DD $L$mul_body wrt ..imagebase,$L$mul_epilogue wrt ..imagebase + DD 48,0 +$L$SEH_info_ecp_nistz256_sqr_mont_nohw: + DB 9,0,0,0 + DD full_handler wrt ..imagebase + DD $L$sqr_body wrt ..imagebase,$L$sqr_epilogue wrt ..imagebase + DD 48,0 +$L$SEH_info_ecp_nistz256_mul_mont_adx: + DB 9,0,0,0 + DD full_handler wrt ..imagebase + DD $L$mulx_body wrt ..imagebase,$L$mulx_epilogue wrt ..imagebase + DD 48,0 +$L$SEH_info_ecp_nistz256_sqr_mont_adx: + DB 9,0,0,0 + DD full_handler wrt ..imagebase + DD $L$sqrx_body wrt ..imagebase,$L$sqrx_epilogue wrt ..imagebase + DD 48,0 +$L$SEH_info_ecp_nistz256_select_wX_nohw: + DB 0x01,0x33,0x16,0x00 + DB 0x33,0xf8,0x09,0x00 + DB 0x2e,0xe8,0x08,0x00 + DB 0x29,0xd8,0x07,0x00 + DB 0x24,0xc8,0x06,0x00 + DB 0x1f,0xb8,0x05,0x00 + DB 0x1a,0xa8,0x04,0x00 + DB 0x15,0x98,0x03,0x00 + DB 0x10,0x88,0x02,0x00 + DB 0x0c,0x78,0x01,0x00 + DB 0x08,0x68,0x00,0x00 + DB 0x04,0x01,0x15,0x00 +ALIGN 8 +$L$SEH_info_ecp_nistz256_select_wX_avx2: + DB 0x01,0x36,0x17,0x0b + DB 0x36,0xf8,0x09,0x00 + DB 0x31,0xe8,0x08,0x00 + DB 0x2c,0xd8,0x07,0x00 + DB 0x27,0xc8,0x06,0x00 + DB 0x22,0xb8,0x05,0x00 + DB 0x1d,0xa8,0x04,0x00 + DB 0x18,0x98,0x03,0x00 + DB 0x13,0x88,0x02,0x00 + DB 0x0e,0x78,0x01,0x00 + DB 0x09,0x68,0x00,0x00 + DB 0x04,0x01,0x15,0x00 + DB 0x00,0xb3,0x00,0x00 +ALIGN 8 +$L$SEH_info_ecp_nistz256_point_double_nohw: + DB 9,0,0,0 + DD full_handler wrt ..imagebase + DD $L$point_doubleq_body wrt ..imagebase,$L$point_doubleq_epilogue wrt ..imagebase + DD 32*5+56,0 +$L$SEH_info_ecp_nistz256_point_add_nohw: + DB 9,0,0,0 + DD full_handler wrt ..imagebase + DD $L$point_addq_body wrt ..imagebase,$L$point_addq_epilogue wrt ..imagebase + DD 32*18+56,0 +$L$SEH_info_ecp_nistz256_point_add_affine_nohw: + DB 9,0,0,0 + DD full_handler wrt ..imagebase + DD $L$add_affineq_body wrt ..imagebase,$L$add_affineq_epilogue wrt ..imagebase + DD 32*15+56,0 +ALIGN 8 +$L$SEH_info_ecp_nistz256_point_double_adx: + DB 9,0,0,0 + DD full_handler wrt ..imagebase + DD $L$point_doublex_body wrt ..imagebase,$L$point_doublex_epilogue wrt ..imagebase + DD 32*5+56,0 +$L$SEH_info_ecp_nistz256_point_add_adx: + DB 9,0,0,0 + DD full_handler wrt ..imagebase + DD $L$point_addx_body wrt ..imagebase,$L$point_addx_epilogue wrt ..imagebase + DD 32*18+56,0 +$L$SEH_info_ecp_nistz256_point_add_affine_adx: + DB 9,0,0,0 + DD full_handler wrt ..imagebase + DD $L$add_affinex_body wrt ..imagebase,$L$add_affinex_epilogue wrt ..imagebase + DD 32*15+56,0 +%else +; Work around https://bugzilla.nasm.us/show_bug.cgi?id=3392738 +ret +%endif diff --git a/http/vendor/ring/pregenerated/p256-x86_64-asm-nasm.o b/http/vendor/ring/pregenerated/p256-x86_64-asm-nasm.o new file mode 100644 index 0000000..7c7647e Binary files /dev/null and b/http/vendor/ring/pregenerated/p256-x86_64-asm-nasm.o differ diff --git a/http/vendor/ring/pregenerated/ring_core_generated/prefix_symbols.h b/http/vendor/ring/pregenerated/ring_core_generated/prefix_symbols.h new file mode 100644 index 0000000..da4b6fa --- /dev/null +++ b/http/vendor/ring/pregenerated/ring_core_generated/prefix_symbols.h @@ -0,0 +1,168 @@ + +#ifndef ring_core_generated_PREFIX_SYMBOLS_H +#define ring_core_generated_PREFIX_SYMBOLS_H + +#define ecp_nistz256_point_double p256_point_double +#define ecp_nistz256_point_add p256_point_add +#define ecp_nistz256_point_add_affine p256_point_add_affine +#define ecp_nistz256_ord_mul_mont p256_scalar_mul_mont +#define ecp_nistz256_ord_sqr_mont p256_scalar_sqr_rep_mont +#define ecp_nistz256_mul_mont p256_mul_mont +#define ecp_nistz256_sqr_mont p256_sqr_mont +#define adx_bmi2_available ring_core_0_17_14__adx_bmi2_available +#define avx2_available ring_core_0_17_14__avx2_available +#define CRYPTO_memcmp ring_core_0_17_14__CRYPTO_memcmp +#define CRYPTO_poly1305_finish ring_core_0_17_14__CRYPTO_poly1305_finish +#define CRYPTO_poly1305_finish_neon ring_core_0_17_14__CRYPTO_poly1305_finish_neon +#define CRYPTO_poly1305_init ring_core_0_17_14__CRYPTO_poly1305_init +#define CRYPTO_poly1305_init_neon ring_core_0_17_14__CRYPTO_poly1305_init_neon +#define CRYPTO_poly1305_update ring_core_0_17_14__CRYPTO_poly1305_update +#define CRYPTO_poly1305_update_neon ring_core_0_17_14__CRYPTO_poly1305_update_neon +#define ChaCha20_ctr32 ring_core_0_17_14__ChaCha20_ctr32 +#define ChaCha20_ctr32_avx2 ring_core_0_17_14__ChaCha20_ctr32_avx2 +#define ChaCha20_ctr32_neon ring_core_0_17_14__ChaCha20_ctr32_neon +#define ChaCha20_ctr32_nohw ring_core_0_17_14__ChaCha20_ctr32_nohw +#define ChaCha20_ctr32_ssse3 ring_core_0_17_14__ChaCha20_ctr32_ssse3 +#define ChaCha20_ctr32_ssse3_4x ring_core_0_17_14__ChaCha20_ctr32_ssse3_4x +#define LIMB_is_zero ring_core_0_17_14__LIMB_is_zero +#define LIMBS_add_mod ring_core_0_17_14__LIMBS_add_mod +#define LIMBS_are_zero ring_core_0_17_14__LIMBS_are_zero +#define LIMBS_equal ring_core_0_17_14__LIMBS_equal +#define LIMBS_less_than ring_core_0_17_14__LIMBS_less_than +#define LIMBS_reduce_once ring_core_0_17_14__LIMBS_reduce_once +#define LIMBS_select_512_32 ring_core_0_17_14__LIMBS_select_512_32 +#define LIMBS_shl_mod ring_core_0_17_14__LIMBS_shl_mod +#define LIMBS_sub_mod ring_core_0_17_14__LIMBS_sub_mod +#define LIMBS_window5_split_window ring_core_0_17_14__LIMBS_window5_split_window +#define LIMBS_window5_unsplit_window ring_core_0_17_14__LIMBS_window5_unsplit_window +#define LIMB_shr ring_core_0_17_14__LIMB_shr +#define OPENSSL_cpuid_setup ring_core_0_17_14__OPENSSL_cpuid_setup +#define aes_gcm_dec_kernel ring_core_0_17_14__aes_gcm_dec_kernel +#define aes_gcm_dec_update_vaes_avx2 ring_core_0_17_14__aes_gcm_dec_update_vaes_avx2 +#define aes_gcm_enc_kernel ring_core_0_17_14__aes_gcm_enc_kernel +#define aes_gcm_enc_update_vaes_avx2 ring_core_0_17_14__aes_gcm_enc_update_vaes_avx2 +#define aes_hw_ctr32_encrypt_blocks ring_core_0_17_14__aes_hw_ctr32_encrypt_blocks +#define aes_hw_set_encrypt_key ring_core_0_17_14__aes_hw_set_encrypt_key +#define aes_hw_set_encrypt_key_alt ring_core_0_17_14__aes_hw_set_encrypt_key_alt +#define aes_hw_set_encrypt_key_base ring_core_0_17_14__aes_hw_set_encrypt_key_base +#define aes_nohw_ctr32_encrypt_blocks ring_core_0_17_14__aes_nohw_ctr32_encrypt_blocks +#define aes_nohw_encrypt ring_core_0_17_14__aes_nohw_encrypt +#define aes_nohw_set_encrypt_key ring_core_0_17_14__aes_nohw_set_encrypt_key +#define aesni_gcm_decrypt ring_core_0_17_14__aesni_gcm_decrypt +#define aesni_gcm_encrypt ring_core_0_17_14__aesni_gcm_encrypt +#define bn_from_montgomery_in_place ring_core_0_17_14__bn_from_montgomery_in_place +#define bn_gather5 ring_core_0_17_14__bn_gather5 +#define bn_mul_mont ring_core_0_17_14__bn_mul_mont +#define bn_mul_mont_nohw ring_core_0_17_14__bn_mul_mont_nohw +#define bn_mul4x_mont ring_core_0_17_14__bn_mul4x_mont +#define bn_mulx4x_mont ring_core_0_17_14__bn_mulx4x_mont +#define bn_mul8x_mont_neon ring_core_0_17_14__bn_mul8x_mont_neon +#define bn_mul4x_mont_gather5 ring_core_0_17_14__bn_mul4x_mont_gather5 +#define bn_mulx4x_mont_gather5 ring_core_0_17_14__bn_mulx4x_mont_gather5 +#define bn_neg_inv_mod_r_u64 ring_core_0_17_14__bn_neg_inv_mod_r_u64 +#define bn_power5_nohw ring_core_0_17_14__bn_power5_nohw +#define bn_powerx5 ring_core_0_17_14__bn_powerx5 +#define bn_scatter5 ring_core_0_17_14__bn_scatter5 +#define bn_sqr8x_internal ring_core_0_17_14__bn_sqr8x_internal +#define bn_sqr8x_mont ring_core_0_17_14__bn_sqr8x_mont +#define bn_sqrx8x_internal ring_core_0_17_14__bn_sqrx8x_internal +#define bsaes_ctr32_encrypt_blocks ring_core_0_17_14__bsaes_ctr32_encrypt_blocks +#define bssl_constant_time_test_conditional_memcpy ring_core_0_17_14__bssl_constant_time_test_conditional_memcpy +#define bssl_constant_time_test_conditional_memxor ring_core_0_17_14__bssl_constant_time_test_conditional_memxor +#define bssl_constant_time_test_main ring_core_0_17_14__bssl_constant_time_test_main +#define chacha20_poly1305_open ring_core_0_17_14__chacha20_poly1305_open +#define chacha20_poly1305_open_avx2 ring_core_0_17_14__chacha20_poly1305_open_avx2 +#define chacha20_poly1305_open_sse41 ring_core_0_17_14__chacha20_poly1305_open_sse41 +#define chacha20_poly1305_seal ring_core_0_17_14__chacha20_poly1305_seal +#define chacha20_poly1305_seal_avx2 ring_core_0_17_14__chacha20_poly1305_seal_avx2 +#define chacha20_poly1305_seal_sse41 ring_core_0_17_14__chacha20_poly1305_seal_sse41 +#define ecp_nistz256_mul_mont_adx ring_core_0_17_14__ecp_nistz256_mul_mont_adx +#define ecp_nistz256_mul_mont_nohw ring_core_0_17_14__ecp_nistz256_mul_mont_nohw +#define ecp_nistz256_ord_mul_mont_adx ring_core_0_17_14__ecp_nistz256_ord_mul_mont_adx +#define ecp_nistz256_ord_mul_mont_nohw ring_core_0_17_14__ecp_nistz256_ord_mul_mont_nohw +#define ecp_nistz256_ord_sqr_mont_adx ring_core_0_17_14__ecp_nistz256_ord_sqr_mont_adx +#define ecp_nistz256_ord_sqr_mont_nohw ring_core_0_17_14__ecp_nistz256_ord_sqr_mont_nohw +#define ecp_nistz256_point_add_adx ring_core_0_17_14__ecp_nistz256_point_add_adx +#define ecp_nistz256_point_add_nohw ring_core_0_17_14__ecp_nistz256_point_add_nohw +#define ecp_nistz256_point_add_affine_adx ring_core_0_17_14__ecp_nistz256_point_add_affine_adx +#define ecp_nistz256_point_add_affine_nohw ring_core_0_17_14__ecp_nistz256_point_add_affine_nohw +#define ecp_nistz256_point_double_adx ring_core_0_17_14__ecp_nistz256_point_double_adx +#define ecp_nistz256_point_double_nohw ring_core_0_17_14__ecp_nistz256_point_double_nohw +#define ecp_nistz256_select_w5_avx2 ring_core_0_17_14__ecp_nistz256_select_w5_avx2 +#define ecp_nistz256_select_w5_nohw ring_core_0_17_14__ecp_nistz256_select_w5_nohw +#define ecp_nistz256_select_w7_avx2 ring_core_0_17_14__ecp_nistz256_select_w7_avx2 +#define ecp_nistz256_select_w7_nohw ring_core_0_17_14__ecp_nistz256_select_w7_nohw +#define ecp_nistz256_sqr_mont_adx ring_core_0_17_14__ecp_nistz256_sqr_mont_adx +#define ecp_nistz256_sqr_mont_nohw ring_core_0_17_14__ecp_nistz256_sqr_mont_nohw +#define fiat_curve25519_adx_mul ring_core_0_17_14__fiat_curve25519_adx_mul +#define fiat_curve25519_adx_square ring_core_0_17_14__fiat_curve25519_adx_square +#define gcm_ghash_avx ring_core_0_17_14__gcm_ghash_avx +#define gcm_ghash_clmul ring_core_0_17_14__gcm_ghash_clmul +#define gcm_ghash_neon ring_core_0_17_14__gcm_ghash_neon +#define gcm_ghash_vpclmulqdq_avx2_1 ring_core_0_17_14__gcm_ghash_vpclmulqdq_avx2_1 +#define gcm_gmult_clmul ring_core_0_17_14__gcm_gmult_clmul +#define gcm_gmult_neon ring_core_0_17_14__gcm_gmult_neon +#define gcm_init_avx ring_core_0_17_14__gcm_init_avx +#define gcm_init_clmul ring_core_0_17_14__gcm_init_clmul +#define gcm_init_neon ring_core_0_17_14__gcm_init_neon +#define gcm_init_vpclmulqdq_avx2 ring_core_0_17_14__gcm_init_vpclmulqdq_avx2 +#define k25519Precomp ring_core_0_17_14__k25519Precomp +#define limbs_mul_add_limb ring_core_0_17_14__limbs_mul_add_limb +#define little_endian_bytes_from_scalar ring_core_0_17_14__little_endian_bytes_from_scalar +#define ecp_nistz256_neg ring_core_0_17_14__ecp_nistz256_neg +#define ecp_nistz256_select_w5 ring_core_0_17_14__ecp_nistz256_select_w5 +#define ecp_nistz256_select_w7 ring_core_0_17_14__ecp_nistz256_select_w7 +#define neon_available ring_core_0_17_14__neon_available +#define p256_mul_mont ring_core_0_17_14__p256_mul_mont +#define p256_point_add ring_core_0_17_14__p256_point_add +#define p256_point_add_affine ring_core_0_17_14__p256_point_add_affine +#define p256_point_double ring_core_0_17_14__p256_point_double +#define p256_point_mul ring_core_0_17_14__p256_point_mul +#define p256_point_mul_base ring_core_0_17_14__p256_point_mul_base +#define p256_point_mul_base_vartime ring_core_0_17_14__p256_point_mul_base_vartime +#define p256_scalar_mul_mont ring_core_0_17_14__p256_scalar_mul_mont +#define p256_scalar_sqr_rep_mont ring_core_0_17_14__p256_scalar_sqr_rep_mont +#define p256_sqr_mont ring_core_0_17_14__p256_sqr_mont +#define p384_elem_div_by_2 ring_core_0_17_14__p384_elem_div_by_2 +#define p384_elem_mul_mont ring_core_0_17_14__p384_elem_mul_mont +#define p384_elem_neg ring_core_0_17_14__p384_elem_neg +#define p384_elem_sub ring_core_0_17_14__p384_elem_sub +#define p384_point_add ring_core_0_17_14__p384_point_add +#define p384_point_double ring_core_0_17_14__p384_point_double +#define p384_point_mul ring_core_0_17_14__p384_point_mul +#define p384_scalar_mul_mont ring_core_0_17_14__p384_scalar_mul_mont +#define openssl_poly1305_neon2_addmulmod ring_core_0_17_14__openssl_poly1305_neon2_addmulmod +#define openssl_poly1305_neon2_blocks ring_core_0_17_14__openssl_poly1305_neon2_blocks +#define sha256_block_data_order ring_core_0_17_14__sha256_block_data_order +#define sha256_block_data_order_avx ring_core_0_17_14__sha256_block_data_order_avx +#define sha256_block_data_order_ssse3 ring_core_0_17_14__sha256_block_data_order_ssse3 +#define sha256_block_data_order_hw ring_core_0_17_14__sha256_block_data_order_hw +#define sha256_block_data_order_neon ring_core_0_17_14__sha256_block_data_order_neon +#define sha256_block_data_order_nohw ring_core_0_17_14__sha256_block_data_order_nohw +#define sha512_block_data_order ring_core_0_17_14__sha512_block_data_order +#define sha512_block_data_order_avx ring_core_0_17_14__sha512_block_data_order_avx +#define sha512_block_data_order_hw ring_core_0_17_14__sha512_block_data_order_hw +#define sha512_block_data_order_neon ring_core_0_17_14__sha512_block_data_order_neon +#define sha512_block_data_order_nohw ring_core_0_17_14__sha512_block_data_order_nohw +#define vpaes_ctr32_encrypt_blocks ring_core_0_17_14__vpaes_ctr32_encrypt_blocks +#define vpaes_encrypt ring_core_0_17_14__vpaes_encrypt +#define vpaes_encrypt_key_to_bsaes ring_core_0_17_14__vpaes_encrypt_key_to_bsaes +#define vpaes_set_encrypt_key ring_core_0_17_14__vpaes_set_encrypt_key +#define x25519_NEON ring_core_0_17_14__x25519_NEON +#define x25519_fe_invert ring_core_0_17_14__x25519_fe_invert +#define x25519_fe_isnegative ring_core_0_17_14__x25519_fe_isnegative +#define x25519_fe_mul_ttt ring_core_0_17_14__x25519_fe_mul_ttt +#define x25519_fe_neg ring_core_0_17_14__x25519_fe_neg +#define x25519_fe_tobytes ring_core_0_17_14__x25519_fe_tobytes +#define x25519_ge_double_scalarmult_vartime ring_core_0_17_14__x25519_ge_double_scalarmult_vartime +#define x25519_ge_frombytes_vartime ring_core_0_17_14__x25519_ge_frombytes_vartime +#define x25519_ge_scalarmult_base ring_core_0_17_14__x25519_ge_scalarmult_base +#define x25519_ge_scalarmult_base_adx ring_core_0_17_14__x25519_ge_scalarmult_base_adx +#define x25519_public_from_private_generic_masked ring_core_0_17_14__x25519_public_from_private_generic_masked +#define x25519_sc_mask ring_core_0_17_14__x25519_sc_mask +#define x25519_sc_muladd ring_core_0_17_14__x25519_sc_muladd +#define x25519_sc_reduce ring_core_0_17_14__x25519_sc_reduce +#define x25519_scalar_mult_adx ring_core_0_17_14__x25519_scalar_mult_adx +#define x25519_scalar_mult_generic_masked ring_core_0_17_14__x25519_scalar_mult_generic_masked + +#endif diff --git a/http/vendor/ring/pregenerated/ring_core_generated/prefix_symbols_asm.h b/http/vendor/ring/pregenerated/ring_core_generated/prefix_symbols_asm.h new file mode 100644 index 0000000..5db19eb --- /dev/null +++ b/http/vendor/ring/pregenerated/ring_core_generated/prefix_symbols_asm.h @@ -0,0 +1,334 @@ + +#ifndef ring_core_generated_PREFIX_SYMBOLS_ASM_H +#define ring_core_generated_PREFIX_SYMBOLS_ASM_H + +#if defined(__APPLE__) +#define _ecp_nistz256_point_double _p256_point_double +#define _ecp_nistz256_point_add _p256_point_add +#define _ecp_nistz256_point_add_affine _p256_point_add_affine +#define _ecp_nistz256_ord_mul_mont _p256_scalar_mul_mont +#define _ecp_nistz256_ord_sqr_mont _p256_scalar_sqr_rep_mont +#define _ecp_nistz256_mul_mont _p256_mul_mont +#define _ecp_nistz256_sqr_mont _p256_sqr_mont +#define _adx_bmi2_available _ring_core_0_17_14__adx_bmi2_available +#define _avx2_available _ring_core_0_17_14__avx2_available +#define _CRYPTO_memcmp _ring_core_0_17_14__CRYPTO_memcmp +#define _CRYPTO_poly1305_finish _ring_core_0_17_14__CRYPTO_poly1305_finish +#define _CRYPTO_poly1305_finish_neon _ring_core_0_17_14__CRYPTO_poly1305_finish_neon +#define _CRYPTO_poly1305_init _ring_core_0_17_14__CRYPTO_poly1305_init +#define _CRYPTO_poly1305_init_neon _ring_core_0_17_14__CRYPTO_poly1305_init_neon +#define _CRYPTO_poly1305_update _ring_core_0_17_14__CRYPTO_poly1305_update +#define _CRYPTO_poly1305_update_neon _ring_core_0_17_14__CRYPTO_poly1305_update_neon +#define _ChaCha20_ctr32 _ring_core_0_17_14__ChaCha20_ctr32 +#define _ChaCha20_ctr32_avx2 _ring_core_0_17_14__ChaCha20_ctr32_avx2 +#define _ChaCha20_ctr32_neon _ring_core_0_17_14__ChaCha20_ctr32_neon +#define _ChaCha20_ctr32_nohw _ring_core_0_17_14__ChaCha20_ctr32_nohw +#define _ChaCha20_ctr32_ssse3 _ring_core_0_17_14__ChaCha20_ctr32_ssse3 +#define _ChaCha20_ctr32_ssse3_4x _ring_core_0_17_14__ChaCha20_ctr32_ssse3_4x +#define _LIMB_is_zero _ring_core_0_17_14__LIMB_is_zero +#define _LIMBS_add_mod _ring_core_0_17_14__LIMBS_add_mod +#define _LIMBS_are_zero _ring_core_0_17_14__LIMBS_are_zero +#define _LIMBS_equal _ring_core_0_17_14__LIMBS_equal +#define _LIMBS_less_than _ring_core_0_17_14__LIMBS_less_than +#define _LIMBS_reduce_once _ring_core_0_17_14__LIMBS_reduce_once +#define _LIMBS_select_512_32 _ring_core_0_17_14__LIMBS_select_512_32 +#define _LIMBS_shl_mod _ring_core_0_17_14__LIMBS_shl_mod +#define _LIMBS_sub_mod _ring_core_0_17_14__LIMBS_sub_mod +#define _LIMBS_window5_split_window _ring_core_0_17_14__LIMBS_window5_split_window +#define _LIMBS_window5_unsplit_window _ring_core_0_17_14__LIMBS_window5_unsplit_window +#define _LIMB_shr _ring_core_0_17_14__LIMB_shr +#define _OPENSSL_cpuid_setup _ring_core_0_17_14__OPENSSL_cpuid_setup +#define _aes_gcm_dec_kernel _ring_core_0_17_14__aes_gcm_dec_kernel +#define _aes_gcm_dec_update_vaes_avx2 _ring_core_0_17_14__aes_gcm_dec_update_vaes_avx2 +#define _aes_gcm_enc_kernel _ring_core_0_17_14__aes_gcm_enc_kernel +#define _aes_gcm_enc_update_vaes_avx2 _ring_core_0_17_14__aes_gcm_enc_update_vaes_avx2 +#define _aes_hw_ctr32_encrypt_blocks _ring_core_0_17_14__aes_hw_ctr32_encrypt_blocks +#define _aes_hw_set_encrypt_key _ring_core_0_17_14__aes_hw_set_encrypt_key +#define _aes_hw_set_encrypt_key_alt _ring_core_0_17_14__aes_hw_set_encrypt_key_alt +#define _aes_hw_set_encrypt_key_base _ring_core_0_17_14__aes_hw_set_encrypt_key_base +#define _aes_nohw_ctr32_encrypt_blocks _ring_core_0_17_14__aes_nohw_ctr32_encrypt_blocks +#define _aes_nohw_encrypt _ring_core_0_17_14__aes_nohw_encrypt +#define _aes_nohw_set_encrypt_key _ring_core_0_17_14__aes_nohw_set_encrypt_key +#define _aesni_gcm_decrypt _ring_core_0_17_14__aesni_gcm_decrypt +#define _aesni_gcm_encrypt _ring_core_0_17_14__aesni_gcm_encrypt +#define _bn_from_montgomery_in_place _ring_core_0_17_14__bn_from_montgomery_in_place +#define _bn_gather5 _ring_core_0_17_14__bn_gather5 +#define _bn_mul_mont _ring_core_0_17_14__bn_mul_mont +#define _bn_mul_mont_nohw _ring_core_0_17_14__bn_mul_mont_nohw +#define _bn_mul4x_mont _ring_core_0_17_14__bn_mul4x_mont +#define _bn_mulx4x_mont _ring_core_0_17_14__bn_mulx4x_mont +#define _bn_mul8x_mont_neon _ring_core_0_17_14__bn_mul8x_mont_neon +#define _bn_mul4x_mont_gather5 _ring_core_0_17_14__bn_mul4x_mont_gather5 +#define _bn_mulx4x_mont_gather5 _ring_core_0_17_14__bn_mulx4x_mont_gather5 +#define _bn_neg_inv_mod_r_u64 _ring_core_0_17_14__bn_neg_inv_mod_r_u64 +#define _bn_power5_nohw _ring_core_0_17_14__bn_power5_nohw +#define _bn_powerx5 _ring_core_0_17_14__bn_powerx5 +#define _bn_scatter5 _ring_core_0_17_14__bn_scatter5 +#define _bn_sqr8x_internal _ring_core_0_17_14__bn_sqr8x_internal +#define _bn_sqr8x_mont _ring_core_0_17_14__bn_sqr8x_mont +#define _bn_sqrx8x_internal _ring_core_0_17_14__bn_sqrx8x_internal +#define _bsaes_ctr32_encrypt_blocks _ring_core_0_17_14__bsaes_ctr32_encrypt_blocks +#define _bssl_constant_time_test_conditional_memcpy _ring_core_0_17_14__bssl_constant_time_test_conditional_memcpy +#define _bssl_constant_time_test_conditional_memxor _ring_core_0_17_14__bssl_constant_time_test_conditional_memxor +#define _bssl_constant_time_test_main _ring_core_0_17_14__bssl_constant_time_test_main +#define _chacha20_poly1305_open _ring_core_0_17_14__chacha20_poly1305_open +#define _chacha20_poly1305_open_avx2 _ring_core_0_17_14__chacha20_poly1305_open_avx2 +#define _chacha20_poly1305_open_sse41 _ring_core_0_17_14__chacha20_poly1305_open_sse41 +#define _chacha20_poly1305_seal _ring_core_0_17_14__chacha20_poly1305_seal +#define _chacha20_poly1305_seal_avx2 _ring_core_0_17_14__chacha20_poly1305_seal_avx2 +#define _chacha20_poly1305_seal_sse41 _ring_core_0_17_14__chacha20_poly1305_seal_sse41 +#define _ecp_nistz256_mul_mont_adx _ring_core_0_17_14__ecp_nistz256_mul_mont_adx +#define _ecp_nistz256_mul_mont_nohw _ring_core_0_17_14__ecp_nistz256_mul_mont_nohw +#define _ecp_nistz256_ord_mul_mont_adx _ring_core_0_17_14__ecp_nistz256_ord_mul_mont_adx +#define _ecp_nistz256_ord_mul_mont_nohw _ring_core_0_17_14__ecp_nistz256_ord_mul_mont_nohw +#define _ecp_nistz256_ord_sqr_mont_adx _ring_core_0_17_14__ecp_nistz256_ord_sqr_mont_adx +#define _ecp_nistz256_ord_sqr_mont_nohw _ring_core_0_17_14__ecp_nistz256_ord_sqr_mont_nohw +#define _ecp_nistz256_point_add_adx _ring_core_0_17_14__ecp_nistz256_point_add_adx +#define _ecp_nistz256_point_add_nohw _ring_core_0_17_14__ecp_nistz256_point_add_nohw +#define _ecp_nistz256_point_add_affine_adx _ring_core_0_17_14__ecp_nistz256_point_add_affine_adx +#define _ecp_nistz256_point_add_affine_nohw _ring_core_0_17_14__ecp_nistz256_point_add_affine_nohw +#define _ecp_nistz256_point_double_adx _ring_core_0_17_14__ecp_nistz256_point_double_adx +#define _ecp_nistz256_point_double_nohw _ring_core_0_17_14__ecp_nistz256_point_double_nohw +#define _ecp_nistz256_select_w5_avx2 _ring_core_0_17_14__ecp_nistz256_select_w5_avx2 +#define _ecp_nistz256_select_w5_nohw _ring_core_0_17_14__ecp_nistz256_select_w5_nohw +#define _ecp_nistz256_select_w7_avx2 _ring_core_0_17_14__ecp_nistz256_select_w7_avx2 +#define _ecp_nistz256_select_w7_nohw _ring_core_0_17_14__ecp_nistz256_select_w7_nohw +#define _ecp_nistz256_sqr_mont_adx _ring_core_0_17_14__ecp_nistz256_sqr_mont_adx +#define _ecp_nistz256_sqr_mont_nohw _ring_core_0_17_14__ecp_nistz256_sqr_mont_nohw +#define _fiat_curve25519_adx_mul _ring_core_0_17_14__fiat_curve25519_adx_mul +#define _fiat_curve25519_adx_square _ring_core_0_17_14__fiat_curve25519_adx_square +#define _gcm_ghash_avx _ring_core_0_17_14__gcm_ghash_avx +#define _gcm_ghash_clmul _ring_core_0_17_14__gcm_ghash_clmul +#define _gcm_ghash_neon _ring_core_0_17_14__gcm_ghash_neon +#define _gcm_ghash_vpclmulqdq_avx2_1 _ring_core_0_17_14__gcm_ghash_vpclmulqdq_avx2_1 +#define _gcm_gmult_clmul _ring_core_0_17_14__gcm_gmult_clmul +#define _gcm_gmult_neon _ring_core_0_17_14__gcm_gmult_neon +#define _gcm_init_avx _ring_core_0_17_14__gcm_init_avx +#define _gcm_init_clmul _ring_core_0_17_14__gcm_init_clmul +#define _gcm_init_neon _ring_core_0_17_14__gcm_init_neon +#define _gcm_init_vpclmulqdq_avx2 _ring_core_0_17_14__gcm_init_vpclmulqdq_avx2 +#define _k25519Precomp _ring_core_0_17_14__k25519Precomp +#define _limbs_mul_add_limb _ring_core_0_17_14__limbs_mul_add_limb +#define _little_endian_bytes_from_scalar _ring_core_0_17_14__little_endian_bytes_from_scalar +#define _ecp_nistz256_neg _ring_core_0_17_14__ecp_nistz256_neg +#define _ecp_nistz256_select_w5 _ring_core_0_17_14__ecp_nistz256_select_w5 +#define _ecp_nistz256_select_w7 _ring_core_0_17_14__ecp_nistz256_select_w7 +#define _neon_available _ring_core_0_17_14__neon_available +#define _p256_mul_mont _ring_core_0_17_14__p256_mul_mont +#define _p256_point_add _ring_core_0_17_14__p256_point_add +#define _p256_point_add_affine _ring_core_0_17_14__p256_point_add_affine +#define _p256_point_double _ring_core_0_17_14__p256_point_double +#define _p256_point_mul _ring_core_0_17_14__p256_point_mul +#define _p256_point_mul_base _ring_core_0_17_14__p256_point_mul_base +#define _p256_point_mul_base_vartime _ring_core_0_17_14__p256_point_mul_base_vartime +#define _p256_scalar_mul_mont _ring_core_0_17_14__p256_scalar_mul_mont +#define _p256_scalar_sqr_rep_mont _ring_core_0_17_14__p256_scalar_sqr_rep_mont +#define _p256_sqr_mont _ring_core_0_17_14__p256_sqr_mont +#define _p384_elem_div_by_2 _ring_core_0_17_14__p384_elem_div_by_2 +#define _p384_elem_mul_mont _ring_core_0_17_14__p384_elem_mul_mont +#define _p384_elem_neg _ring_core_0_17_14__p384_elem_neg +#define _p384_elem_sub _ring_core_0_17_14__p384_elem_sub +#define _p384_point_add _ring_core_0_17_14__p384_point_add +#define _p384_point_double _ring_core_0_17_14__p384_point_double +#define _p384_point_mul _ring_core_0_17_14__p384_point_mul +#define _p384_scalar_mul_mont _ring_core_0_17_14__p384_scalar_mul_mont +#define _openssl_poly1305_neon2_addmulmod _ring_core_0_17_14__openssl_poly1305_neon2_addmulmod +#define _openssl_poly1305_neon2_blocks _ring_core_0_17_14__openssl_poly1305_neon2_blocks +#define _sha256_block_data_order _ring_core_0_17_14__sha256_block_data_order +#define _sha256_block_data_order_avx _ring_core_0_17_14__sha256_block_data_order_avx +#define _sha256_block_data_order_ssse3 _ring_core_0_17_14__sha256_block_data_order_ssse3 +#define _sha256_block_data_order_hw _ring_core_0_17_14__sha256_block_data_order_hw +#define _sha256_block_data_order_neon _ring_core_0_17_14__sha256_block_data_order_neon +#define _sha256_block_data_order_nohw _ring_core_0_17_14__sha256_block_data_order_nohw +#define _sha512_block_data_order _ring_core_0_17_14__sha512_block_data_order +#define _sha512_block_data_order_avx _ring_core_0_17_14__sha512_block_data_order_avx +#define _sha512_block_data_order_hw _ring_core_0_17_14__sha512_block_data_order_hw +#define _sha512_block_data_order_neon _ring_core_0_17_14__sha512_block_data_order_neon +#define _sha512_block_data_order_nohw _ring_core_0_17_14__sha512_block_data_order_nohw +#define _vpaes_ctr32_encrypt_blocks _ring_core_0_17_14__vpaes_ctr32_encrypt_blocks +#define _vpaes_encrypt _ring_core_0_17_14__vpaes_encrypt +#define _vpaes_encrypt_key_to_bsaes _ring_core_0_17_14__vpaes_encrypt_key_to_bsaes +#define _vpaes_set_encrypt_key _ring_core_0_17_14__vpaes_set_encrypt_key +#define _x25519_NEON _ring_core_0_17_14__x25519_NEON +#define _x25519_fe_invert _ring_core_0_17_14__x25519_fe_invert +#define _x25519_fe_isnegative _ring_core_0_17_14__x25519_fe_isnegative +#define _x25519_fe_mul_ttt _ring_core_0_17_14__x25519_fe_mul_ttt +#define _x25519_fe_neg _ring_core_0_17_14__x25519_fe_neg +#define _x25519_fe_tobytes _ring_core_0_17_14__x25519_fe_tobytes +#define _x25519_ge_double_scalarmult_vartime _ring_core_0_17_14__x25519_ge_double_scalarmult_vartime +#define _x25519_ge_frombytes_vartime _ring_core_0_17_14__x25519_ge_frombytes_vartime +#define _x25519_ge_scalarmult_base _ring_core_0_17_14__x25519_ge_scalarmult_base +#define _x25519_ge_scalarmult_base_adx _ring_core_0_17_14__x25519_ge_scalarmult_base_adx +#define _x25519_public_from_private_generic_masked _ring_core_0_17_14__x25519_public_from_private_generic_masked +#define _x25519_sc_mask _ring_core_0_17_14__x25519_sc_mask +#define _x25519_sc_muladd _ring_core_0_17_14__x25519_sc_muladd +#define _x25519_sc_reduce _ring_core_0_17_14__x25519_sc_reduce +#define _x25519_scalar_mult_adx _ring_core_0_17_14__x25519_scalar_mult_adx +#define _x25519_scalar_mult_generic_masked _ring_core_0_17_14__x25519_scalar_mult_generic_masked + +#else +#define ecp_nistz256_point_double p256_point_double +#define ecp_nistz256_point_add p256_point_add +#define ecp_nistz256_point_add_affine p256_point_add_affine +#define ecp_nistz256_ord_mul_mont p256_scalar_mul_mont +#define ecp_nistz256_ord_sqr_mont p256_scalar_sqr_rep_mont +#define ecp_nistz256_mul_mont p256_mul_mont +#define ecp_nistz256_sqr_mont p256_sqr_mont +#define adx_bmi2_available ring_core_0_17_14__adx_bmi2_available +#define avx2_available ring_core_0_17_14__avx2_available +#define CRYPTO_memcmp ring_core_0_17_14__CRYPTO_memcmp +#define CRYPTO_poly1305_finish ring_core_0_17_14__CRYPTO_poly1305_finish +#define CRYPTO_poly1305_finish_neon ring_core_0_17_14__CRYPTO_poly1305_finish_neon +#define CRYPTO_poly1305_init ring_core_0_17_14__CRYPTO_poly1305_init +#define CRYPTO_poly1305_init_neon ring_core_0_17_14__CRYPTO_poly1305_init_neon +#define CRYPTO_poly1305_update ring_core_0_17_14__CRYPTO_poly1305_update +#define CRYPTO_poly1305_update_neon ring_core_0_17_14__CRYPTO_poly1305_update_neon +#define ChaCha20_ctr32 ring_core_0_17_14__ChaCha20_ctr32 +#define ChaCha20_ctr32_avx2 ring_core_0_17_14__ChaCha20_ctr32_avx2 +#define ChaCha20_ctr32_neon ring_core_0_17_14__ChaCha20_ctr32_neon +#define ChaCha20_ctr32_nohw ring_core_0_17_14__ChaCha20_ctr32_nohw +#define ChaCha20_ctr32_ssse3 ring_core_0_17_14__ChaCha20_ctr32_ssse3 +#define ChaCha20_ctr32_ssse3_4x ring_core_0_17_14__ChaCha20_ctr32_ssse3_4x +#define LIMB_is_zero ring_core_0_17_14__LIMB_is_zero +#define LIMBS_add_mod ring_core_0_17_14__LIMBS_add_mod +#define LIMBS_are_zero ring_core_0_17_14__LIMBS_are_zero +#define LIMBS_equal ring_core_0_17_14__LIMBS_equal +#define LIMBS_less_than ring_core_0_17_14__LIMBS_less_than +#define LIMBS_reduce_once ring_core_0_17_14__LIMBS_reduce_once +#define LIMBS_select_512_32 ring_core_0_17_14__LIMBS_select_512_32 +#define LIMBS_shl_mod ring_core_0_17_14__LIMBS_shl_mod +#define LIMBS_sub_mod ring_core_0_17_14__LIMBS_sub_mod +#define LIMBS_window5_split_window ring_core_0_17_14__LIMBS_window5_split_window +#define LIMBS_window5_unsplit_window ring_core_0_17_14__LIMBS_window5_unsplit_window +#define LIMB_shr ring_core_0_17_14__LIMB_shr +#define OPENSSL_cpuid_setup ring_core_0_17_14__OPENSSL_cpuid_setup +#define aes_gcm_dec_kernel ring_core_0_17_14__aes_gcm_dec_kernel +#define aes_gcm_dec_update_vaes_avx2 ring_core_0_17_14__aes_gcm_dec_update_vaes_avx2 +#define aes_gcm_enc_kernel ring_core_0_17_14__aes_gcm_enc_kernel +#define aes_gcm_enc_update_vaes_avx2 ring_core_0_17_14__aes_gcm_enc_update_vaes_avx2 +#define aes_hw_ctr32_encrypt_blocks ring_core_0_17_14__aes_hw_ctr32_encrypt_blocks +#define aes_hw_set_encrypt_key ring_core_0_17_14__aes_hw_set_encrypt_key +#define aes_hw_set_encrypt_key_alt ring_core_0_17_14__aes_hw_set_encrypt_key_alt +#define aes_hw_set_encrypt_key_base ring_core_0_17_14__aes_hw_set_encrypt_key_base +#define aes_nohw_ctr32_encrypt_blocks ring_core_0_17_14__aes_nohw_ctr32_encrypt_blocks +#define aes_nohw_encrypt ring_core_0_17_14__aes_nohw_encrypt +#define aes_nohw_set_encrypt_key ring_core_0_17_14__aes_nohw_set_encrypt_key +#define aesni_gcm_decrypt ring_core_0_17_14__aesni_gcm_decrypt +#define aesni_gcm_encrypt ring_core_0_17_14__aesni_gcm_encrypt +#define bn_from_montgomery_in_place ring_core_0_17_14__bn_from_montgomery_in_place +#define bn_gather5 ring_core_0_17_14__bn_gather5 +#define bn_mul_mont ring_core_0_17_14__bn_mul_mont +#define bn_mul_mont_nohw ring_core_0_17_14__bn_mul_mont_nohw +#define bn_mul4x_mont ring_core_0_17_14__bn_mul4x_mont +#define bn_mulx4x_mont ring_core_0_17_14__bn_mulx4x_mont +#define bn_mul8x_mont_neon ring_core_0_17_14__bn_mul8x_mont_neon +#define bn_mul4x_mont_gather5 ring_core_0_17_14__bn_mul4x_mont_gather5 +#define bn_mulx4x_mont_gather5 ring_core_0_17_14__bn_mulx4x_mont_gather5 +#define bn_neg_inv_mod_r_u64 ring_core_0_17_14__bn_neg_inv_mod_r_u64 +#define bn_power5_nohw ring_core_0_17_14__bn_power5_nohw +#define bn_powerx5 ring_core_0_17_14__bn_powerx5 +#define bn_scatter5 ring_core_0_17_14__bn_scatter5 +#define bn_sqr8x_internal ring_core_0_17_14__bn_sqr8x_internal +#define bn_sqr8x_mont ring_core_0_17_14__bn_sqr8x_mont +#define bn_sqrx8x_internal ring_core_0_17_14__bn_sqrx8x_internal +#define bsaes_ctr32_encrypt_blocks ring_core_0_17_14__bsaes_ctr32_encrypt_blocks +#define bssl_constant_time_test_conditional_memcpy ring_core_0_17_14__bssl_constant_time_test_conditional_memcpy +#define bssl_constant_time_test_conditional_memxor ring_core_0_17_14__bssl_constant_time_test_conditional_memxor +#define bssl_constant_time_test_main ring_core_0_17_14__bssl_constant_time_test_main +#define chacha20_poly1305_open ring_core_0_17_14__chacha20_poly1305_open +#define chacha20_poly1305_open_avx2 ring_core_0_17_14__chacha20_poly1305_open_avx2 +#define chacha20_poly1305_open_sse41 ring_core_0_17_14__chacha20_poly1305_open_sse41 +#define chacha20_poly1305_seal ring_core_0_17_14__chacha20_poly1305_seal +#define chacha20_poly1305_seal_avx2 ring_core_0_17_14__chacha20_poly1305_seal_avx2 +#define chacha20_poly1305_seal_sse41 ring_core_0_17_14__chacha20_poly1305_seal_sse41 +#define ecp_nistz256_mul_mont_adx ring_core_0_17_14__ecp_nistz256_mul_mont_adx +#define ecp_nistz256_mul_mont_nohw ring_core_0_17_14__ecp_nistz256_mul_mont_nohw +#define ecp_nistz256_ord_mul_mont_adx ring_core_0_17_14__ecp_nistz256_ord_mul_mont_adx +#define ecp_nistz256_ord_mul_mont_nohw ring_core_0_17_14__ecp_nistz256_ord_mul_mont_nohw +#define ecp_nistz256_ord_sqr_mont_adx ring_core_0_17_14__ecp_nistz256_ord_sqr_mont_adx +#define ecp_nistz256_ord_sqr_mont_nohw ring_core_0_17_14__ecp_nistz256_ord_sqr_mont_nohw +#define ecp_nistz256_point_add_adx ring_core_0_17_14__ecp_nistz256_point_add_adx +#define ecp_nistz256_point_add_nohw ring_core_0_17_14__ecp_nistz256_point_add_nohw +#define ecp_nistz256_point_add_affine_adx ring_core_0_17_14__ecp_nistz256_point_add_affine_adx +#define ecp_nistz256_point_add_affine_nohw ring_core_0_17_14__ecp_nistz256_point_add_affine_nohw +#define ecp_nistz256_point_double_adx ring_core_0_17_14__ecp_nistz256_point_double_adx +#define ecp_nistz256_point_double_nohw ring_core_0_17_14__ecp_nistz256_point_double_nohw +#define ecp_nistz256_select_w5_avx2 ring_core_0_17_14__ecp_nistz256_select_w5_avx2 +#define ecp_nistz256_select_w5_nohw ring_core_0_17_14__ecp_nistz256_select_w5_nohw +#define ecp_nistz256_select_w7_avx2 ring_core_0_17_14__ecp_nistz256_select_w7_avx2 +#define ecp_nistz256_select_w7_nohw ring_core_0_17_14__ecp_nistz256_select_w7_nohw +#define ecp_nistz256_sqr_mont_adx ring_core_0_17_14__ecp_nistz256_sqr_mont_adx +#define ecp_nistz256_sqr_mont_nohw ring_core_0_17_14__ecp_nistz256_sqr_mont_nohw +#define fiat_curve25519_adx_mul ring_core_0_17_14__fiat_curve25519_adx_mul +#define fiat_curve25519_adx_square ring_core_0_17_14__fiat_curve25519_adx_square +#define gcm_ghash_avx ring_core_0_17_14__gcm_ghash_avx +#define gcm_ghash_clmul ring_core_0_17_14__gcm_ghash_clmul +#define gcm_ghash_neon ring_core_0_17_14__gcm_ghash_neon +#define gcm_ghash_vpclmulqdq_avx2_1 ring_core_0_17_14__gcm_ghash_vpclmulqdq_avx2_1 +#define gcm_gmult_clmul ring_core_0_17_14__gcm_gmult_clmul +#define gcm_gmult_neon ring_core_0_17_14__gcm_gmult_neon +#define gcm_init_avx ring_core_0_17_14__gcm_init_avx +#define gcm_init_clmul ring_core_0_17_14__gcm_init_clmul +#define gcm_init_neon ring_core_0_17_14__gcm_init_neon +#define gcm_init_vpclmulqdq_avx2 ring_core_0_17_14__gcm_init_vpclmulqdq_avx2 +#define k25519Precomp ring_core_0_17_14__k25519Precomp +#define limbs_mul_add_limb ring_core_0_17_14__limbs_mul_add_limb +#define little_endian_bytes_from_scalar ring_core_0_17_14__little_endian_bytes_from_scalar +#define ecp_nistz256_neg ring_core_0_17_14__ecp_nistz256_neg +#define ecp_nistz256_select_w5 ring_core_0_17_14__ecp_nistz256_select_w5 +#define ecp_nistz256_select_w7 ring_core_0_17_14__ecp_nistz256_select_w7 +#define neon_available ring_core_0_17_14__neon_available +#define p256_mul_mont ring_core_0_17_14__p256_mul_mont +#define p256_point_add ring_core_0_17_14__p256_point_add +#define p256_point_add_affine ring_core_0_17_14__p256_point_add_affine +#define p256_point_double ring_core_0_17_14__p256_point_double +#define p256_point_mul ring_core_0_17_14__p256_point_mul +#define p256_point_mul_base ring_core_0_17_14__p256_point_mul_base +#define p256_point_mul_base_vartime ring_core_0_17_14__p256_point_mul_base_vartime +#define p256_scalar_mul_mont ring_core_0_17_14__p256_scalar_mul_mont +#define p256_scalar_sqr_rep_mont ring_core_0_17_14__p256_scalar_sqr_rep_mont +#define p256_sqr_mont ring_core_0_17_14__p256_sqr_mont +#define p384_elem_div_by_2 ring_core_0_17_14__p384_elem_div_by_2 +#define p384_elem_mul_mont ring_core_0_17_14__p384_elem_mul_mont +#define p384_elem_neg ring_core_0_17_14__p384_elem_neg +#define p384_elem_sub ring_core_0_17_14__p384_elem_sub +#define p384_point_add ring_core_0_17_14__p384_point_add +#define p384_point_double ring_core_0_17_14__p384_point_double +#define p384_point_mul ring_core_0_17_14__p384_point_mul +#define p384_scalar_mul_mont ring_core_0_17_14__p384_scalar_mul_mont +#define openssl_poly1305_neon2_addmulmod ring_core_0_17_14__openssl_poly1305_neon2_addmulmod +#define openssl_poly1305_neon2_blocks ring_core_0_17_14__openssl_poly1305_neon2_blocks +#define sha256_block_data_order ring_core_0_17_14__sha256_block_data_order +#define sha256_block_data_order_avx ring_core_0_17_14__sha256_block_data_order_avx +#define sha256_block_data_order_ssse3 ring_core_0_17_14__sha256_block_data_order_ssse3 +#define sha256_block_data_order_hw ring_core_0_17_14__sha256_block_data_order_hw +#define sha256_block_data_order_neon ring_core_0_17_14__sha256_block_data_order_neon +#define sha256_block_data_order_nohw ring_core_0_17_14__sha256_block_data_order_nohw +#define sha512_block_data_order ring_core_0_17_14__sha512_block_data_order +#define sha512_block_data_order_avx ring_core_0_17_14__sha512_block_data_order_avx +#define sha512_block_data_order_hw ring_core_0_17_14__sha512_block_data_order_hw +#define sha512_block_data_order_neon ring_core_0_17_14__sha512_block_data_order_neon +#define sha512_block_data_order_nohw ring_core_0_17_14__sha512_block_data_order_nohw +#define vpaes_ctr32_encrypt_blocks ring_core_0_17_14__vpaes_ctr32_encrypt_blocks +#define vpaes_encrypt ring_core_0_17_14__vpaes_encrypt +#define vpaes_encrypt_key_to_bsaes ring_core_0_17_14__vpaes_encrypt_key_to_bsaes +#define vpaes_set_encrypt_key ring_core_0_17_14__vpaes_set_encrypt_key +#define x25519_NEON ring_core_0_17_14__x25519_NEON +#define x25519_fe_invert ring_core_0_17_14__x25519_fe_invert +#define x25519_fe_isnegative ring_core_0_17_14__x25519_fe_isnegative +#define x25519_fe_mul_ttt ring_core_0_17_14__x25519_fe_mul_ttt +#define x25519_fe_neg ring_core_0_17_14__x25519_fe_neg +#define x25519_fe_tobytes ring_core_0_17_14__x25519_fe_tobytes +#define x25519_ge_double_scalarmult_vartime ring_core_0_17_14__x25519_ge_double_scalarmult_vartime +#define x25519_ge_frombytes_vartime ring_core_0_17_14__x25519_ge_frombytes_vartime +#define x25519_ge_scalarmult_base ring_core_0_17_14__x25519_ge_scalarmult_base +#define x25519_ge_scalarmult_base_adx ring_core_0_17_14__x25519_ge_scalarmult_base_adx +#define x25519_public_from_private_generic_masked ring_core_0_17_14__x25519_public_from_private_generic_masked +#define x25519_sc_mask ring_core_0_17_14__x25519_sc_mask +#define x25519_sc_muladd ring_core_0_17_14__x25519_sc_muladd +#define x25519_sc_reduce ring_core_0_17_14__x25519_sc_reduce +#define x25519_scalar_mult_adx ring_core_0_17_14__x25519_scalar_mult_adx +#define x25519_scalar_mult_generic_masked ring_core_0_17_14__x25519_scalar_mult_generic_masked + +#endif +#endif diff --git a/http/vendor/ring/pregenerated/ring_core_generated/prefix_symbols_nasm.inc b/http/vendor/ring/pregenerated/ring_core_generated/prefix_symbols_nasm.inc new file mode 100644 index 0000000..900abb0 --- /dev/null +++ b/http/vendor/ring/pregenerated/ring_core_generated/prefix_symbols_nasm.inc @@ -0,0 +1,334 @@ + +%ifndef ring_core_generated_PREFIX_SYMBOLS_NASM_INC +%define ring_core_generated_PREFIX_SYMBOLS_NASM_INC + +%ifidn __OUTPUT_FORMAT__,win32 +%define _ecp_nistz256_point_double _p256_point_double +%define _ecp_nistz256_point_add _p256_point_add +%define _ecp_nistz256_point_add_affine _p256_point_add_affine +%define _ecp_nistz256_ord_mul_mont _p256_scalar_mul_mont +%define _ecp_nistz256_ord_sqr_mont _p256_scalar_sqr_rep_mont +%define _ecp_nistz256_mul_mont _p256_mul_mont +%define _ecp_nistz256_sqr_mont _p256_sqr_mont +%define _adx_bmi2_available _ring_core_0_17_14__adx_bmi2_available +%define _avx2_available _ring_core_0_17_14__avx2_available +%define _CRYPTO_memcmp _ring_core_0_17_14__CRYPTO_memcmp +%define _CRYPTO_poly1305_finish _ring_core_0_17_14__CRYPTO_poly1305_finish +%define _CRYPTO_poly1305_finish_neon _ring_core_0_17_14__CRYPTO_poly1305_finish_neon +%define _CRYPTO_poly1305_init _ring_core_0_17_14__CRYPTO_poly1305_init +%define _CRYPTO_poly1305_init_neon _ring_core_0_17_14__CRYPTO_poly1305_init_neon +%define _CRYPTO_poly1305_update _ring_core_0_17_14__CRYPTO_poly1305_update +%define _CRYPTO_poly1305_update_neon _ring_core_0_17_14__CRYPTO_poly1305_update_neon +%define _ChaCha20_ctr32 _ring_core_0_17_14__ChaCha20_ctr32 +%define _ChaCha20_ctr32_avx2 _ring_core_0_17_14__ChaCha20_ctr32_avx2 +%define _ChaCha20_ctr32_neon _ring_core_0_17_14__ChaCha20_ctr32_neon +%define _ChaCha20_ctr32_nohw _ring_core_0_17_14__ChaCha20_ctr32_nohw +%define _ChaCha20_ctr32_ssse3 _ring_core_0_17_14__ChaCha20_ctr32_ssse3 +%define _ChaCha20_ctr32_ssse3_4x _ring_core_0_17_14__ChaCha20_ctr32_ssse3_4x +%define _LIMB_is_zero _ring_core_0_17_14__LIMB_is_zero +%define _LIMBS_add_mod _ring_core_0_17_14__LIMBS_add_mod +%define _LIMBS_are_zero _ring_core_0_17_14__LIMBS_are_zero +%define _LIMBS_equal _ring_core_0_17_14__LIMBS_equal +%define _LIMBS_less_than _ring_core_0_17_14__LIMBS_less_than +%define _LIMBS_reduce_once _ring_core_0_17_14__LIMBS_reduce_once +%define _LIMBS_select_512_32 _ring_core_0_17_14__LIMBS_select_512_32 +%define _LIMBS_shl_mod _ring_core_0_17_14__LIMBS_shl_mod +%define _LIMBS_sub_mod _ring_core_0_17_14__LIMBS_sub_mod +%define _LIMBS_window5_split_window _ring_core_0_17_14__LIMBS_window5_split_window +%define _LIMBS_window5_unsplit_window _ring_core_0_17_14__LIMBS_window5_unsplit_window +%define _LIMB_shr _ring_core_0_17_14__LIMB_shr +%define _OPENSSL_cpuid_setup _ring_core_0_17_14__OPENSSL_cpuid_setup +%define _aes_gcm_dec_kernel _ring_core_0_17_14__aes_gcm_dec_kernel +%define _aes_gcm_dec_update_vaes_avx2 _ring_core_0_17_14__aes_gcm_dec_update_vaes_avx2 +%define _aes_gcm_enc_kernel _ring_core_0_17_14__aes_gcm_enc_kernel +%define _aes_gcm_enc_update_vaes_avx2 _ring_core_0_17_14__aes_gcm_enc_update_vaes_avx2 +%define _aes_hw_ctr32_encrypt_blocks _ring_core_0_17_14__aes_hw_ctr32_encrypt_blocks +%define _aes_hw_set_encrypt_key _ring_core_0_17_14__aes_hw_set_encrypt_key +%define _aes_hw_set_encrypt_key_alt _ring_core_0_17_14__aes_hw_set_encrypt_key_alt +%define _aes_hw_set_encrypt_key_base _ring_core_0_17_14__aes_hw_set_encrypt_key_base +%define _aes_nohw_ctr32_encrypt_blocks _ring_core_0_17_14__aes_nohw_ctr32_encrypt_blocks +%define _aes_nohw_encrypt _ring_core_0_17_14__aes_nohw_encrypt +%define _aes_nohw_set_encrypt_key _ring_core_0_17_14__aes_nohw_set_encrypt_key +%define _aesni_gcm_decrypt _ring_core_0_17_14__aesni_gcm_decrypt +%define _aesni_gcm_encrypt _ring_core_0_17_14__aesni_gcm_encrypt +%define _bn_from_montgomery_in_place _ring_core_0_17_14__bn_from_montgomery_in_place +%define _bn_gather5 _ring_core_0_17_14__bn_gather5 +%define _bn_mul_mont _ring_core_0_17_14__bn_mul_mont +%define _bn_mul_mont_nohw _ring_core_0_17_14__bn_mul_mont_nohw +%define _bn_mul4x_mont _ring_core_0_17_14__bn_mul4x_mont +%define _bn_mulx4x_mont _ring_core_0_17_14__bn_mulx4x_mont +%define _bn_mul8x_mont_neon _ring_core_0_17_14__bn_mul8x_mont_neon +%define _bn_mul4x_mont_gather5 _ring_core_0_17_14__bn_mul4x_mont_gather5 +%define _bn_mulx4x_mont_gather5 _ring_core_0_17_14__bn_mulx4x_mont_gather5 +%define _bn_neg_inv_mod_r_u64 _ring_core_0_17_14__bn_neg_inv_mod_r_u64 +%define _bn_power5_nohw _ring_core_0_17_14__bn_power5_nohw +%define _bn_powerx5 _ring_core_0_17_14__bn_powerx5 +%define _bn_scatter5 _ring_core_0_17_14__bn_scatter5 +%define _bn_sqr8x_internal _ring_core_0_17_14__bn_sqr8x_internal +%define _bn_sqr8x_mont _ring_core_0_17_14__bn_sqr8x_mont +%define _bn_sqrx8x_internal _ring_core_0_17_14__bn_sqrx8x_internal +%define _bsaes_ctr32_encrypt_blocks _ring_core_0_17_14__bsaes_ctr32_encrypt_blocks +%define _bssl_constant_time_test_conditional_memcpy _ring_core_0_17_14__bssl_constant_time_test_conditional_memcpy +%define _bssl_constant_time_test_conditional_memxor _ring_core_0_17_14__bssl_constant_time_test_conditional_memxor +%define _bssl_constant_time_test_main _ring_core_0_17_14__bssl_constant_time_test_main +%define _chacha20_poly1305_open _ring_core_0_17_14__chacha20_poly1305_open +%define _chacha20_poly1305_open_avx2 _ring_core_0_17_14__chacha20_poly1305_open_avx2 +%define _chacha20_poly1305_open_sse41 _ring_core_0_17_14__chacha20_poly1305_open_sse41 +%define _chacha20_poly1305_seal _ring_core_0_17_14__chacha20_poly1305_seal +%define _chacha20_poly1305_seal_avx2 _ring_core_0_17_14__chacha20_poly1305_seal_avx2 +%define _chacha20_poly1305_seal_sse41 _ring_core_0_17_14__chacha20_poly1305_seal_sse41 +%define _ecp_nistz256_mul_mont_adx _ring_core_0_17_14__ecp_nistz256_mul_mont_adx +%define _ecp_nistz256_mul_mont_nohw _ring_core_0_17_14__ecp_nistz256_mul_mont_nohw +%define _ecp_nistz256_ord_mul_mont_adx _ring_core_0_17_14__ecp_nistz256_ord_mul_mont_adx +%define _ecp_nistz256_ord_mul_mont_nohw _ring_core_0_17_14__ecp_nistz256_ord_mul_mont_nohw +%define _ecp_nistz256_ord_sqr_mont_adx _ring_core_0_17_14__ecp_nistz256_ord_sqr_mont_adx +%define _ecp_nistz256_ord_sqr_mont_nohw _ring_core_0_17_14__ecp_nistz256_ord_sqr_mont_nohw +%define _ecp_nistz256_point_add_adx _ring_core_0_17_14__ecp_nistz256_point_add_adx +%define _ecp_nistz256_point_add_nohw _ring_core_0_17_14__ecp_nistz256_point_add_nohw +%define _ecp_nistz256_point_add_affine_adx _ring_core_0_17_14__ecp_nistz256_point_add_affine_adx +%define _ecp_nistz256_point_add_affine_nohw _ring_core_0_17_14__ecp_nistz256_point_add_affine_nohw +%define _ecp_nistz256_point_double_adx _ring_core_0_17_14__ecp_nistz256_point_double_adx +%define _ecp_nistz256_point_double_nohw _ring_core_0_17_14__ecp_nistz256_point_double_nohw +%define _ecp_nistz256_select_w5_avx2 _ring_core_0_17_14__ecp_nistz256_select_w5_avx2 +%define _ecp_nistz256_select_w5_nohw _ring_core_0_17_14__ecp_nistz256_select_w5_nohw +%define _ecp_nistz256_select_w7_avx2 _ring_core_0_17_14__ecp_nistz256_select_w7_avx2 +%define _ecp_nistz256_select_w7_nohw _ring_core_0_17_14__ecp_nistz256_select_w7_nohw +%define _ecp_nistz256_sqr_mont_adx _ring_core_0_17_14__ecp_nistz256_sqr_mont_adx +%define _ecp_nistz256_sqr_mont_nohw _ring_core_0_17_14__ecp_nistz256_sqr_mont_nohw +%define _fiat_curve25519_adx_mul _ring_core_0_17_14__fiat_curve25519_adx_mul +%define _fiat_curve25519_adx_square _ring_core_0_17_14__fiat_curve25519_adx_square +%define _gcm_ghash_avx _ring_core_0_17_14__gcm_ghash_avx +%define _gcm_ghash_clmul _ring_core_0_17_14__gcm_ghash_clmul +%define _gcm_ghash_neon _ring_core_0_17_14__gcm_ghash_neon +%define _gcm_ghash_vpclmulqdq_avx2_1 _ring_core_0_17_14__gcm_ghash_vpclmulqdq_avx2_1 +%define _gcm_gmult_clmul _ring_core_0_17_14__gcm_gmult_clmul +%define _gcm_gmult_neon _ring_core_0_17_14__gcm_gmult_neon +%define _gcm_init_avx _ring_core_0_17_14__gcm_init_avx +%define _gcm_init_clmul _ring_core_0_17_14__gcm_init_clmul +%define _gcm_init_neon _ring_core_0_17_14__gcm_init_neon +%define _gcm_init_vpclmulqdq_avx2 _ring_core_0_17_14__gcm_init_vpclmulqdq_avx2 +%define _k25519Precomp _ring_core_0_17_14__k25519Precomp +%define _limbs_mul_add_limb _ring_core_0_17_14__limbs_mul_add_limb +%define _little_endian_bytes_from_scalar _ring_core_0_17_14__little_endian_bytes_from_scalar +%define _ecp_nistz256_neg _ring_core_0_17_14__ecp_nistz256_neg +%define _ecp_nistz256_select_w5 _ring_core_0_17_14__ecp_nistz256_select_w5 +%define _ecp_nistz256_select_w7 _ring_core_0_17_14__ecp_nistz256_select_w7 +%define _neon_available _ring_core_0_17_14__neon_available +%define _p256_mul_mont _ring_core_0_17_14__p256_mul_mont +%define _p256_point_add _ring_core_0_17_14__p256_point_add +%define _p256_point_add_affine _ring_core_0_17_14__p256_point_add_affine +%define _p256_point_double _ring_core_0_17_14__p256_point_double +%define _p256_point_mul _ring_core_0_17_14__p256_point_mul +%define _p256_point_mul_base _ring_core_0_17_14__p256_point_mul_base +%define _p256_point_mul_base_vartime _ring_core_0_17_14__p256_point_mul_base_vartime +%define _p256_scalar_mul_mont _ring_core_0_17_14__p256_scalar_mul_mont +%define _p256_scalar_sqr_rep_mont _ring_core_0_17_14__p256_scalar_sqr_rep_mont +%define _p256_sqr_mont _ring_core_0_17_14__p256_sqr_mont +%define _p384_elem_div_by_2 _ring_core_0_17_14__p384_elem_div_by_2 +%define _p384_elem_mul_mont _ring_core_0_17_14__p384_elem_mul_mont +%define _p384_elem_neg _ring_core_0_17_14__p384_elem_neg +%define _p384_elem_sub _ring_core_0_17_14__p384_elem_sub +%define _p384_point_add _ring_core_0_17_14__p384_point_add +%define _p384_point_double _ring_core_0_17_14__p384_point_double +%define _p384_point_mul _ring_core_0_17_14__p384_point_mul +%define _p384_scalar_mul_mont _ring_core_0_17_14__p384_scalar_mul_mont +%define _openssl_poly1305_neon2_addmulmod _ring_core_0_17_14__openssl_poly1305_neon2_addmulmod +%define _openssl_poly1305_neon2_blocks _ring_core_0_17_14__openssl_poly1305_neon2_blocks +%define _sha256_block_data_order _ring_core_0_17_14__sha256_block_data_order +%define _sha256_block_data_order_avx _ring_core_0_17_14__sha256_block_data_order_avx +%define _sha256_block_data_order_ssse3 _ring_core_0_17_14__sha256_block_data_order_ssse3 +%define _sha256_block_data_order_hw _ring_core_0_17_14__sha256_block_data_order_hw +%define _sha256_block_data_order_neon _ring_core_0_17_14__sha256_block_data_order_neon +%define _sha256_block_data_order_nohw _ring_core_0_17_14__sha256_block_data_order_nohw +%define _sha512_block_data_order _ring_core_0_17_14__sha512_block_data_order +%define _sha512_block_data_order_avx _ring_core_0_17_14__sha512_block_data_order_avx +%define _sha512_block_data_order_hw _ring_core_0_17_14__sha512_block_data_order_hw +%define _sha512_block_data_order_neon _ring_core_0_17_14__sha512_block_data_order_neon +%define _sha512_block_data_order_nohw _ring_core_0_17_14__sha512_block_data_order_nohw +%define _vpaes_ctr32_encrypt_blocks _ring_core_0_17_14__vpaes_ctr32_encrypt_blocks +%define _vpaes_encrypt _ring_core_0_17_14__vpaes_encrypt +%define _vpaes_encrypt_key_to_bsaes _ring_core_0_17_14__vpaes_encrypt_key_to_bsaes +%define _vpaes_set_encrypt_key _ring_core_0_17_14__vpaes_set_encrypt_key +%define _x25519_NEON _ring_core_0_17_14__x25519_NEON +%define _x25519_fe_invert _ring_core_0_17_14__x25519_fe_invert +%define _x25519_fe_isnegative _ring_core_0_17_14__x25519_fe_isnegative +%define _x25519_fe_mul_ttt _ring_core_0_17_14__x25519_fe_mul_ttt +%define _x25519_fe_neg _ring_core_0_17_14__x25519_fe_neg +%define _x25519_fe_tobytes _ring_core_0_17_14__x25519_fe_tobytes +%define _x25519_ge_double_scalarmult_vartime _ring_core_0_17_14__x25519_ge_double_scalarmult_vartime +%define _x25519_ge_frombytes_vartime _ring_core_0_17_14__x25519_ge_frombytes_vartime +%define _x25519_ge_scalarmult_base _ring_core_0_17_14__x25519_ge_scalarmult_base +%define _x25519_ge_scalarmult_base_adx _ring_core_0_17_14__x25519_ge_scalarmult_base_adx +%define _x25519_public_from_private_generic_masked _ring_core_0_17_14__x25519_public_from_private_generic_masked +%define _x25519_sc_mask _ring_core_0_17_14__x25519_sc_mask +%define _x25519_sc_muladd _ring_core_0_17_14__x25519_sc_muladd +%define _x25519_sc_reduce _ring_core_0_17_14__x25519_sc_reduce +%define _x25519_scalar_mult_adx _ring_core_0_17_14__x25519_scalar_mult_adx +%define _x25519_scalar_mult_generic_masked _ring_core_0_17_14__x25519_scalar_mult_generic_masked + +%else +%define ecp_nistz256_point_double p256_point_double +%define ecp_nistz256_point_add p256_point_add +%define ecp_nistz256_point_add_affine p256_point_add_affine +%define ecp_nistz256_ord_mul_mont p256_scalar_mul_mont +%define ecp_nistz256_ord_sqr_mont p256_scalar_sqr_rep_mont +%define ecp_nistz256_mul_mont p256_mul_mont +%define ecp_nistz256_sqr_mont p256_sqr_mont +%define adx_bmi2_available ring_core_0_17_14__adx_bmi2_available +%define avx2_available ring_core_0_17_14__avx2_available +%define CRYPTO_memcmp ring_core_0_17_14__CRYPTO_memcmp +%define CRYPTO_poly1305_finish ring_core_0_17_14__CRYPTO_poly1305_finish +%define CRYPTO_poly1305_finish_neon ring_core_0_17_14__CRYPTO_poly1305_finish_neon +%define CRYPTO_poly1305_init ring_core_0_17_14__CRYPTO_poly1305_init +%define CRYPTO_poly1305_init_neon ring_core_0_17_14__CRYPTO_poly1305_init_neon +%define CRYPTO_poly1305_update ring_core_0_17_14__CRYPTO_poly1305_update +%define CRYPTO_poly1305_update_neon ring_core_0_17_14__CRYPTO_poly1305_update_neon +%define ChaCha20_ctr32 ring_core_0_17_14__ChaCha20_ctr32 +%define ChaCha20_ctr32_avx2 ring_core_0_17_14__ChaCha20_ctr32_avx2 +%define ChaCha20_ctr32_neon ring_core_0_17_14__ChaCha20_ctr32_neon +%define ChaCha20_ctr32_nohw ring_core_0_17_14__ChaCha20_ctr32_nohw +%define ChaCha20_ctr32_ssse3 ring_core_0_17_14__ChaCha20_ctr32_ssse3 +%define ChaCha20_ctr32_ssse3_4x ring_core_0_17_14__ChaCha20_ctr32_ssse3_4x +%define LIMB_is_zero ring_core_0_17_14__LIMB_is_zero +%define LIMBS_add_mod ring_core_0_17_14__LIMBS_add_mod +%define LIMBS_are_zero ring_core_0_17_14__LIMBS_are_zero +%define LIMBS_equal ring_core_0_17_14__LIMBS_equal +%define LIMBS_less_than ring_core_0_17_14__LIMBS_less_than +%define LIMBS_reduce_once ring_core_0_17_14__LIMBS_reduce_once +%define LIMBS_select_512_32 ring_core_0_17_14__LIMBS_select_512_32 +%define LIMBS_shl_mod ring_core_0_17_14__LIMBS_shl_mod +%define LIMBS_sub_mod ring_core_0_17_14__LIMBS_sub_mod +%define LIMBS_window5_split_window ring_core_0_17_14__LIMBS_window5_split_window +%define LIMBS_window5_unsplit_window ring_core_0_17_14__LIMBS_window5_unsplit_window +%define LIMB_shr ring_core_0_17_14__LIMB_shr +%define OPENSSL_cpuid_setup ring_core_0_17_14__OPENSSL_cpuid_setup +%define aes_gcm_dec_kernel ring_core_0_17_14__aes_gcm_dec_kernel +%define aes_gcm_dec_update_vaes_avx2 ring_core_0_17_14__aes_gcm_dec_update_vaes_avx2 +%define aes_gcm_enc_kernel ring_core_0_17_14__aes_gcm_enc_kernel +%define aes_gcm_enc_update_vaes_avx2 ring_core_0_17_14__aes_gcm_enc_update_vaes_avx2 +%define aes_hw_ctr32_encrypt_blocks ring_core_0_17_14__aes_hw_ctr32_encrypt_blocks +%define aes_hw_set_encrypt_key ring_core_0_17_14__aes_hw_set_encrypt_key +%define aes_hw_set_encrypt_key_alt ring_core_0_17_14__aes_hw_set_encrypt_key_alt +%define aes_hw_set_encrypt_key_base ring_core_0_17_14__aes_hw_set_encrypt_key_base +%define aes_nohw_ctr32_encrypt_blocks ring_core_0_17_14__aes_nohw_ctr32_encrypt_blocks +%define aes_nohw_encrypt ring_core_0_17_14__aes_nohw_encrypt +%define aes_nohw_set_encrypt_key ring_core_0_17_14__aes_nohw_set_encrypt_key +%define aesni_gcm_decrypt ring_core_0_17_14__aesni_gcm_decrypt +%define aesni_gcm_encrypt ring_core_0_17_14__aesni_gcm_encrypt +%define bn_from_montgomery_in_place ring_core_0_17_14__bn_from_montgomery_in_place +%define bn_gather5 ring_core_0_17_14__bn_gather5 +%define bn_mul_mont ring_core_0_17_14__bn_mul_mont +%define bn_mul_mont_nohw ring_core_0_17_14__bn_mul_mont_nohw +%define bn_mul4x_mont ring_core_0_17_14__bn_mul4x_mont +%define bn_mulx4x_mont ring_core_0_17_14__bn_mulx4x_mont +%define bn_mul8x_mont_neon ring_core_0_17_14__bn_mul8x_mont_neon +%define bn_mul4x_mont_gather5 ring_core_0_17_14__bn_mul4x_mont_gather5 +%define bn_mulx4x_mont_gather5 ring_core_0_17_14__bn_mulx4x_mont_gather5 +%define bn_neg_inv_mod_r_u64 ring_core_0_17_14__bn_neg_inv_mod_r_u64 +%define bn_power5_nohw ring_core_0_17_14__bn_power5_nohw +%define bn_powerx5 ring_core_0_17_14__bn_powerx5 +%define bn_scatter5 ring_core_0_17_14__bn_scatter5 +%define bn_sqr8x_internal ring_core_0_17_14__bn_sqr8x_internal +%define bn_sqr8x_mont ring_core_0_17_14__bn_sqr8x_mont +%define bn_sqrx8x_internal ring_core_0_17_14__bn_sqrx8x_internal +%define bsaes_ctr32_encrypt_blocks ring_core_0_17_14__bsaes_ctr32_encrypt_blocks +%define bssl_constant_time_test_conditional_memcpy ring_core_0_17_14__bssl_constant_time_test_conditional_memcpy +%define bssl_constant_time_test_conditional_memxor ring_core_0_17_14__bssl_constant_time_test_conditional_memxor +%define bssl_constant_time_test_main ring_core_0_17_14__bssl_constant_time_test_main +%define chacha20_poly1305_open ring_core_0_17_14__chacha20_poly1305_open +%define chacha20_poly1305_open_avx2 ring_core_0_17_14__chacha20_poly1305_open_avx2 +%define chacha20_poly1305_open_sse41 ring_core_0_17_14__chacha20_poly1305_open_sse41 +%define chacha20_poly1305_seal ring_core_0_17_14__chacha20_poly1305_seal +%define chacha20_poly1305_seal_avx2 ring_core_0_17_14__chacha20_poly1305_seal_avx2 +%define chacha20_poly1305_seal_sse41 ring_core_0_17_14__chacha20_poly1305_seal_sse41 +%define ecp_nistz256_mul_mont_adx ring_core_0_17_14__ecp_nistz256_mul_mont_adx +%define ecp_nistz256_mul_mont_nohw ring_core_0_17_14__ecp_nistz256_mul_mont_nohw +%define ecp_nistz256_ord_mul_mont_adx ring_core_0_17_14__ecp_nistz256_ord_mul_mont_adx +%define ecp_nistz256_ord_mul_mont_nohw ring_core_0_17_14__ecp_nistz256_ord_mul_mont_nohw +%define ecp_nistz256_ord_sqr_mont_adx ring_core_0_17_14__ecp_nistz256_ord_sqr_mont_adx +%define ecp_nistz256_ord_sqr_mont_nohw ring_core_0_17_14__ecp_nistz256_ord_sqr_mont_nohw +%define ecp_nistz256_point_add_adx ring_core_0_17_14__ecp_nistz256_point_add_adx +%define ecp_nistz256_point_add_nohw ring_core_0_17_14__ecp_nistz256_point_add_nohw +%define ecp_nistz256_point_add_affine_adx ring_core_0_17_14__ecp_nistz256_point_add_affine_adx +%define ecp_nistz256_point_add_affine_nohw ring_core_0_17_14__ecp_nistz256_point_add_affine_nohw +%define ecp_nistz256_point_double_adx ring_core_0_17_14__ecp_nistz256_point_double_adx +%define ecp_nistz256_point_double_nohw ring_core_0_17_14__ecp_nistz256_point_double_nohw +%define ecp_nistz256_select_w5_avx2 ring_core_0_17_14__ecp_nistz256_select_w5_avx2 +%define ecp_nistz256_select_w5_nohw ring_core_0_17_14__ecp_nistz256_select_w5_nohw +%define ecp_nistz256_select_w7_avx2 ring_core_0_17_14__ecp_nistz256_select_w7_avx2 +%define ecp_nistz256_select_w7_nohw ring_core_0_17_14__ecp_nistz256_select_w7_nohw +%define ecp_nistz256_sqr_mont_adx ring_core_0_17_14__ecp_nistz256_sqr_mont_adx +%define ecp_nistz256_sqr_mont_nohw ring_core_0_17_14__ecp_nistz256_sqr_mont_nohw +%define fiat_curve25519_adx_mul ring_core_0_17_14__fiat_curve25519_adx_mul +%define fiat_curve25519_adx_square ring_core_0_17_14__fiat_curve25519_adx_square +%define gcm_ghash_avx ring_core_0_17_14__gcm_ghash_avx +%define gcm_ghash_clmul ring_core_0_17_14__gcm_ghash_clmul +%define gcm_ghash_neon ring_core_0_17_14__gcm_ghash_neon +%define gcm_ghash_vpclmulqdq_avx2_1 ring_core_0_17_14__gcm_ghash_vpclmulqdq_avx2_1 +%define gcm_gmult_clmul ring_core_0_17_14__gcm_gmult_clmul +%define gcm_gmult_neon ring_core_0_17_14__gcm_gmult_neon +%define gcm_init_avx ring_core_0_17_14__gcm_init_avx +%define gcm_init_clmul ring_core_0_17_14__gcm_init_clmul +%define gcm_init_neon ring_core_0_17_14__gcm_init_neon +%define gcm_init_vpclmulqdq_avx2 ring_core_0_17_14__gcm_init_vpclmulqdq_avx2 +%define k25519Precomp ring_core_0_17_14__k25519Precomp +%define limbs_mul_add_limb ring_core_0_17_14__limbs_mul_add_limb +%define little_endian_bytes_from_scalar ring_core_0_17_14__little_endian_bytes_from_scalar +%define ecp_nistz256_neg ring_core_0_17_14__ecp_nistz256_neg +%define ecp_nistz256_select_w5 ring_core_0_17_14__ecp_nistz256_select_w5 +%define ecp_nistz256_select_w7 ring_core_0_17_14__ecp_nistz256_select_w7 +%define neon_available ring_core_0_17_14__neon_available +%define p256_mul_mont ring_core_0_17_14__p256_mul_mont +%define p256_point_add ring_core_0_17_14__p256_point_add +%define p256_point_add_affine ring_core_0_17_14__p256_point_add_affine +%define p256_point_double ring_core_0_17_14__p256_point_double +%define p256_point_mul ring_core_0_17_14__p256_point_mul +%define p256_point_mul_base ring_core_0_17_14__p256_point_mul_base +%define p256_point_mul_base_vartime ring_core_0_17_14__p256_point_mul_base_vartime +%define p256_scalar_mul_mont ring_core_0_17_14__p256_scalar_mul_mont +%define p256_scalar_sqr_rep_mont ring_core_0_17_14__p256_scalar_sqr_rep_mont +%define p256_sqr_mont ring_core_0_17_14__p256_sqr_mont +%define p384_elem_div_by_2 ring_core_0_17_14__p384_elem_div_by_2 +%define p384_elem_mul_mont ring_core_0_17_14__p384_elem_mul_mont +%define p384_elem_neg ring_core_0_17_14__p384_elem_neg +%define p384_elem_sub ring_core_0_17_14__p384_elem_sub +%define p384_point_add ring_core_0_17_14__p384_point_add +%define p384_point_double ring_core_0_17_14__p384_point_double +%define p384_point_mul ring_core_0_17_14__p384_point_mul +%define p384_scalar_mul_mont ring_core_0_17_14__p384_scalar_mul_mont +%define openssl_poly1305_neon2_addmulmod ring_core_0_17_14__openssl_poly1305_neon2_addmulmod +%define openssl_poly1305_neon2_blocks ring_core_0_17_14__openssl_poly1305_neon2_blocks +%define sha256_block_data_order ring_core_0_17_14__sha256_block_data_order +%define sha256_block_data_order_avx ring_core_0_17_14__sha256_block_data_order_avx +%define sha256_block_data_order_ssse3 ring_core_0_17_14__sha256_block_data_order_ssse3 +%define sha256_block_data_order_hw ring_core_0_17_14__sha256_block_data_order_hw +%define sha256_block_data_order_neon ring_core_0_17_14__sha256_block_data_order_neon +%define sha256_block_data_order_nohw ring_core_0_17_14__sha256_block_data_order_nohw +%define sha512_block_data_order ring_core_0_17_14__sha512_block_data_order +%define sha512_block_data_order_avx ring_core_0_17_14__sha512_block_data_order_avx +%define sha512_block_data_order_hw ring_core_0_17_14__sha512_block_data_order_hw +%define sha512_block_data_order_neon ring_core_0_17_14__sha512_block_data_order_neon +%define sha512_block_data_order_nohw ring_core_0_17_14__sha512_block_data_order_nohw +%define vpaes_ctr32_encrypt_blocks ring_core_0_17_14__vpaes_ctr32_encrypt_blocks +%define vpaes_encrypt ring_core_0_17_14__vpaes_encrypt +%define vpaes_encrypt_key_to_bsaes ring_core_0_17_14__vpaes_encrypt_key_to_bsaes +%define vpaes_set_encrypt_key ring_core_0_17_14__vpaes_set_encrypt_key +%define x25519_NEON ring_core_0_17_14__x25519_NEON +%define x25519_fe_invert ring_core_0_17_14__x25519_fe_invert +%define x25519_fe_isnegative ring_core_0_17_14__x25519_fe_isnegative +%define x25519_fe_mul_ttt ring_core_0_17_14__x25519_fe_mul_ttt +%define x25519_fe_neg ring_core_0_17_14__x25519_fe_neg +%define x25519_fe_tobytes ring_core_0_17_14__x25519_fe_tobytes +%define x25519_ge_double_scalarmult_vartime ring_core_0_17_14__x25519_ge_double_scalarmult_vartime +%define x25519_ge_frombytes_vartime ring_core_0_17_14__x25519_ge_frombytes_vartime +%define x25519_ge_scalarmult_base ring_core_0_17_14__x25519_ge_scalarmult_base +%define x25519_ge_scalarmult_base_adx ring_core_0_17_14__x25519_ge_scalarmult_base_adx +%define x25519_public_from_private_generic_masked ring_core_0_17_14__x25519_public_from_private_generic_masked +%define x25519_sc_mask ring_core_0_17_14__x25519_sc_mask +%define x25519_sc_muladd ring_core_0_17_14__x25519_sc_muladd +%define x25519_sc_reduce ring_core_0_17_14__x25519_sc_reduce +%define x25519_scalar_mult_adx ring_core_0_17_14__x25519_scalar_mult_adx +%define x25519_scalar_mult_generic_masked ring_core_0_17_14__x25519_scalar_mult_generic_masked + +%endif +%endif diff --git a/http/vendor/ring/pregenerated/sha256-armv4-linux32.S b/http/vendor/ring/pregenerated/sha256-armv4-linux32.S new file mode 100644 index 0000000..b8b3335 --- /dev/null +++ b/http/vendor/ring/pregenerated/sha256-armv4-linux32.S @@ -0,0 +1,2678 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_ARM) && defined(__ELF__) +@ Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved. +@ +@ Licensed under the Apache License, Version 2.0 (the "License"); +@ you may not use this file except in compliance with the License. +@ You may obtain a copy of the License at +@ +@ https://www.apache.org/licenses/LICENSE-2.0 +@ +@ Unless required by applicable law or agreed to in writing, software +@ distributed under the License is distributed on an "AS IS" BASIS, +@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@ See the License for the specific language governing permissions and +@ limitations under the License. + + +@ ==================================================================== +@ Written by Andy Polyakov for the OpenSSL +@ project. +@ ==================================================================== + +@ SHA256 block procedure for ARMv4. May 2007. + +@ Performance is ~2x better than gcc 3.4 generated code and in "abso- +@ lute" terms is ~2250 cycles per 64-byte block or ~35 cycles per +@ byte [on single-issue Xscale PXA250 core]. + +@ July 2010. +@ +@ Rescheduling for dual-issue pipeline resulted in 22% improvement on +@ Cortex A8 core and ~20 cycles per processed byte. + +@ February 2011. +@ +@ Profiler-assisted and platform-specific optimization resulted in 16% +@ improvement on Cortex A8 core and ~15.4 cycles per processed byte. + +@ September 2013. +@ +@ Add NEON implementation. On Cortex A8 it was measured to process one +@ byte in 12.5 cycles or 23% faster than integer-only code. Snapdragon +@ S4 does it in 12.5 cycles too, but it's 50% faster than integer-only +@ code (meaning that latter performs sub-optimally, nothing was done +@ about it). + +@ May 2014. +@ +@ Add ARMv8 code path performing at 2.0 cpb on Apple A7. + +#ifdef __KERNEL__ +# define __ARM_ARCH __LINUX_ARM_ARCH__ +# define __ARM_MAX_ARCH__ 7 +#endif + +@ Silence ARMv8 deprecated IT instruction warnings. This file is used by both +@ ARMv7 and ARMv8 processors. It does have ARMv8-only code, but those +@ instructions are manually-encoded. (See unsha256.) +.arch armv7-a + +.text +#if defined(__thumb2__) +.syntax unified +.thumb +#else +.code 32 +#endif + +.type K256,%object +.align 5 +K256: +.word 0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5 +.word 0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5 +.word 0xd807aa98,0x12835b01,0x243185be,0x550c7dc3 +.word 0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174 +.word 0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc +.word 0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da +.word 0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7 +.word 0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967 +.word 0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13 +.word 0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85 +.word 0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3 +.word 0xd192e819,0xd6990624,0xf40e3585,0x106aa070 +.word 0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5 +.word 0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3 +.word 0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208 +.word 0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2 +.size K256,.-K256 +.word 0 @ terminator +.align 5 + +.globl sha256_block_data_order_nohw +.hidden sha256_block_data_order_nohw +.type sha256_block_data_order_nohw,%function +sha256_block_data_order_nohw: + add r2,r1,r2,lsl#6 @ len to point at the end of inp + stmdb sp!,{r0,r1,r2,r4-r11,lr} + ldmia r0,{r4,r5,r6,r7,r8,r9,r10,r11} + adr r14,K256 + sub sp,sp,#16*4 @ alloca(X[16]) +.Loop: +# if __ARM_ARCH>=7 + ldr r2,[r1],#4 +# else + ldrb r2,[r1,#3] +# endif + eor r3,r5,r6 @ magic + eor r12,r12,r12 +#if __ARM_ARCH>=7 + @ ldr r2,[r1],#4 @ 0 +# if 0==15 + str r1,[sp,#17*4] @ make room for r1 +# endif + eor r0,r8,r8,ror#5 + add r4,r4,r12 @ h+=Maj(a,b,c) from the past + eor r0,r0,r8,ror#19 @ Sigma1(e) +# ifndef __ARMEB__ + rev r2,r2 +# endif +#else + @ ldrb r2,[r1,#3] @ 0 + add r4,r4,r12 @ h+=Maj(a,b,c) from the past + ldrb r12,[r1,#2] + ldrb r0,[r1,#1] + orr r2,r2,r12,lsl#8 + ldrb r12,[r1],#4 + orr r2,r2,r0,lsl#16 +# if 0==15 + str r1,[sp,#17*4] @ make room for r1 +# endif + eor r0,r8,r8,ror#5 + orr r2,r2,r12,lsl#24 + eor r0,r0,r8,ror#19 @ Sigma1(e) +#endif + ldr r12,[r14],#4 @ *K256++ + add r11,r11,r2 @ h+=X[i] + str r2,[sp,#0*4] + eor r2,r9,r10 + add r11,r11,r0,ror#6 @ h+=Sigma1(e) + and r2,r2,r8 + add r11,r11,r12 @ h+=K256[i] + eor r2,r2,r10 @ Ch(e,f,g) + eor r0,r4,r4,ror#11 + add r11,r11,r2 @ h+=Ch(e,f,g) +#if 0==31 + and r12,r12,#0xff + cmp r12,#0xf2 @ done? +#endif +#if 0<15 +# if __ARM_ARCH>=7 + ldr r2,[r1],#4 @ prefetch +# else + ldrb r2,[r1,#3] +# endif + eor r12,r4,r5 @ a^b, b^c in next round +#else + ldr r2,[sp,#2*4] @ from future BODY_16_xx + eor r12,r4,r5 @ a^b, b^c in next round + ldr r1,[sp,#15*4] @ from future BODY_16_xx +#endif + eor r0,r0,r4,ror#20 @ Sigma0(a) + and r3,r3,r12 @ (b^c)&=(a^b) + add r7,r7,r11 @ d+=h + eor r3,r3,r5 @ Maj(a,b,c) + add r11,r11,r0,ror#2 @ h+=Sigma0(a) + @ add r11,r11,r3 @ h+=Maj(a,b,c) +#if __ARM_ARCH>=7 + @ ldr r2,[r1],#4 @ 1 +# if 1==15 + str r1,[sp,#17*4] @ make room for r1 +# endif + eor r0,r7,r7,ror#5 + add r11,r11,r3 @ h+=Maj(a,b,c) from the past + eor r0,r0,r7,ror#19 @ Sigma1(e) +# ifndef __ARMEB__ + rev r2,r2 +# endif +#else + @ ldrb r2,[r1,#3] @ 1 + add r11,r11,r3 @ h+=Maj(a,b,c) from the past + ldrb r3,[r1,#2] + ldrb r0,[r1,#1] + orr r2,r2,r3,lsl#8 + ldrb r3,[r1],#4 + orr r2,r2,r0,lsl#16 +# if 1==15 + str r1,[sp,#17*4] @ make room for r1 +# endif + eor r0,r7,r7,ror#5 + orr r2,r2,r3,lsl#24 + eor r0,r0,r7,ror#19 @ Sigma1(e) +#endif + ldr r3,[r14],#4 @ *K256++ + add r10,r10,r2 @ h+=X[i] + str r2,[sp,#1*4] + eor r2,r8,r9 + add r10,r10,r0,ror#6 @ h+=Sigma1(e) + and r2,r2,r7 + add r10,r10,r3 @ h+=K256[i] + eor r2,r2,r9 @ Ch(e,f,g) + eor r0,r11,r11,ror#11 + add r10,r10,r2 @ h+=Ch(e,f,g) +#if 1==31 + and r3,r3,#0xff + cmp r3,#0xf2 @ done? +#endif +#if 1<15 +# if __ARM_ARCH>=7 + ldr r2,[r1],#4 @ prefetch +# else + ldrb r2,[r1,#3] +# endif + eor r3,r11,r4 @ a^b, b^c in next round +#else + ldr r2,[sp,#3*4] @ from future BODY_16_xx + eor r3,r11,r4 @ a^b, b^c in next round + ldr r1,[sp,#0*4] @ from future BODY_16_xx +#endif + eor r0,r0,r11,ror#20 @ Sigma0(a) + and r12,r12,r3 @ (b^c)&=(a^b) + add r6,r6,r10 @ d+=h + eor r12,r12,r4 @ Maj(a,b,c) + add r10,r10,r0,ror#2 @ h+=Sigma0(a) + @ add r10,r10,r12 @ h+=Maj(a,b,c) +#if __ARM_ARCH>=7 + @ ldr r2,[r1],#4 @ 2 +# if 2==15 + str r1,[sp,#17*4] @ make room for r1 +# endif + eor r0,r6,r6,ror#5 + add r10,r10,r12 @ h+=Maj(a,b,c) from the past + eor r0,r0,r6,ror#19 @ Sigma1(e) +# ifndef __ARMEB__ + rev r2,r2 +# endif +#else + @ ldrb r2,[r1,#3] @ 2 + add r10,r10,r12 @ h+=Maj(a,b,c) from the past + ldrb r12,[r1,#2] + ldrb r0,[r1,#1] + orr r2,r2,r12,lsl#8 + ldrb r12,[r1],#4 + orr r2,r2,r0,lsl#16 +# if 2==15 + str r1,[sp,#17*4] @ make room for r1 +# endif + eor r0,r6,r6,ror#5 + orr r2,r2,r12,lsl#24 + eor r0,r0,r6,ror#19 @ Sigma1(e) +#endif + ldr r12,[r14],#4 @ *K256++ + add r9,r9,r2 @ h+=X[i] + str r2,[sp,#2*4] + eor r2,r7,r8 + add r9,r9,r0,ror#6 @ h+=Sigma1(e) + and r2,r2,r6 + add r9,r9,r12 @ h+=K256[i] + eor r2,r2,r8 @ Ch(e,f,g) + eor r0,r10,r10,ror#11 + add r9,r9,r2 @ h+=Ch(e,f,g) +#if 2==31 + and r12,r12,#0xff + cmp r12,#0xf2 @ done? +#endif +#if 2<15 +# if __ARM_ARCH>=7 + ldr r2,[r1],#4 @ prefetch +# else + ldrb r2,[r1,#3] +# endif + eor r12,r10,r11 @ a^b, b^c in next round +#else + ldr r2,[sp,#4*4] @ from future BODY_16_xx + eor r12,r10,r11 @ a^b, b^c in next round + ldr r1,[sp,#1*4] @ from future BODY_16_xx +#endif + eor r0,r0,r10,ror#20 @ Sigma0(a) + and r3,r3,r12 @ (b^c)&=(a^b) + add r5,r5,r9 @ d+=h + eor r3,r3,r11 @ Maj(a,b,c) + add r9,r9,r0,ror#2 @ h+=Sigma0(a) + @ add r9,r9,r3 @ h+=Maj(a,b,c) +#if __ARM_ARCH>=7 + @ ldr r2,[r1],#4 @ 3 +# if 3==15 + str r1,[sp,#17*4] @ make room for r1 +# endif + eor r0,r5,r5,ror#5 + add r9,r9,r3 @ h+=Maj(a,b,c) from the past + eor r0,r0,r5,ror#19 @ Sigma1(e) +# ifndef __ARMEB__ + rev r2,r2 +# endif +#else + @ ldrb r2,[r1,#3] @ 3 + add r9,r9,r3 @ h+=Maj(a,b,c) from the past + ldrb r3,[r1,#2] + ldrb r0,[r1,#1] + orr r2,r2,r3,lsl#8 + ldrb r3,[r1],#4 + orr r2,r2,r0,lsl#16 +# if 3==15 + str r1,[sp,#17*4] @ make room for r1 +# endif + eor r0,r5,r5,ror#5 + orr r2,r2,r3,lsl#24 + eor r0,r0,r5,ror#19 @ Sigma1(e) +#endif + ldr r3,[r14],#4 @ *K256++ + add r8,r8,r2 @ h+=X[i] + str r2,[sp,#3*4] + eor r2,r6,r7 + add r8,r8,r0,ror#6 @ h+=Sigma1(e) + and r2,r2,r5 + add r8,r8,r3 @ h+=K256[i] + eor r2,r2,r7 @ Ch(e,f,g) + eor r0,r9,r9,ror#11 + add r8,r8,r2 @ h+=Ch(e,f,g) +#if 3==31 + and r3,r3,#0xff + cmp r3,#0xf2 @ done? +#endif +#if 3<15 +# if __ARM_ARCH>=7 + ldr r2,[r1],#4 @ prefetch +# else + ldrb r2,[r1,#3] +# endif + eor r3,r9,r10 @ a^b, b^c in next round +#else + ldr r2,[sp,#5*4] @ from future BODY_16_xx + eor r3,r9,r10 @ a^b, b^c in next round + ldr r1,[sp,#2*4] @ from future BODY_16_xx +#endif + eor r0,r0,r9,ror#20 @ Sigma0(a) + and r12,r12,r3 @ (b^c)&=(a^b) + add r4,r4,r8 @ d+=h + eor r12,r12,r10 @ Maj(a,b,c) + add r8,r8,r0,ror#2 @ h+=Sigma0(a) + @ add r8,r8,r12 @ h+=Maj(a,b,c) +#if __ARM_ARCH>=7 + @ ldr r2,[r1],#4 @ 4 +# if 4==15 + str r1,[sp,#17*4] @ make room for r1 +# endif + eor r0,r4,r4,ror#5 + add r8,r8,r12 @ h+=Maj(a,b,c) from the past + eor r0,r0,r4,ror#19 @ Sigma1(e) +# ifndef __ARMEB__ + rev r2,r2 +# endif +#else + @ ldrb r2,[r1,#3] @ 4 + add r8,r8,r12 @ h+=Maj(a,b,c) from the past + ldrb r12,[r1,#2] + ldrb r0,[r1,#1] + orr r2,r2,r12,lsl#8 + ldrb r12,[r1],#4 + orr r2,r2,r0,lsl#16 +# if 4==15 + str r1,[sp,#17*4] @ make room for r1 +# endif + eor r0,r4,r4,ror#5 + orr r2,r2,r12,lsl#24 + eor r0,r0,r4,ror#19 @ Sigma1(e) +#endif + ldr r12,[r14],#4 @ *K256++ + add r7,r7,r2 @ h+=X[i] + str r2,[sp,#4*4] + eor r2,r5,r6 + add r7,r7,r0,ror#6 @ h+=Sigma1(e) + and r2,r2,r4 + add r7,r7,r12 @ h+=K256[i] + eor r2,r2,r6 @ Ch(e,f,g) + eor r0,r8,r8,ror#11 + add r7,r7,r2 @ h+=Ch(e,f,g) +#if 4==31 + and r12,r12,#0xff + cmp r12,#0xf2 @ done? +#endif +#if 4<15 +# if __ARM_ARCH>=7 + ldr r2,[r1],#4 @ prefetch +# else + ldrb r2,[r1,#3] +# endif + eor r12,r8,r9 @ a^b, b^c in next round +#else + ldr r2,[sp,#6*4] @ from future BODY_16_xx + eor r12,r8,r9 @ a^b, b^c in next round + ldr r1,[sp,#3*4] @ from future BODY_16_xx +#endif + eor r0,r0,r8,ror#20 @ Sigma0(a) + and r3,r3,r12 @ (b^c)&=(a^b) + add r11,r11,r7 @ d+=h + eor r3,r3,r9 @ Maj(a,b,c) + add r7,r7,r0,ror#2 @ h+=Sigma0(a) + @ add r7,r7,r3 @ h+=Maj(a,b,c) +#if __ARM_ARCH>=7 + @ ldr r2,[r1],#4 @ 5 +# if 5==15 + str r1,[sp,#17*4] @ make room for r1 +# endif + eor r0,r11,r11,ror#5 + add r7,r7,r3 @ h+=Maj(a,b,c) from the past + eor r0,r0,r11,ror#19 @ Sigma1(e) +# ifndef __ARMEB__ + rev r2,r2 +# endif +#else + @ ldrb r2,[r1,#3] @ 5 + add r7,r7,r3 @ h+=Maj(a,b,c) from the past + ldrb r3,[r1,#2] + ldrb r0,[r1,#1] + orr r2,r2,r3,lsl#8 + ldrb r3,[r1],#4 + orr r2,r2,r0,lsl#16 +# if 5==15 + str r1,[sp,#17*4] @ make room for r1 +# endif + eor r0,r11,r11,ror#5 + orr r2,r2,r3,lsl#24 + eor r0,r0,r11,ror#19 @ Sigma1(e) +#endif + ldr r3,[r14],#4 @ *K256++ + add r6,r6,r2 @ h+=X[i] + str r2,[sp,#5*4] + eor r2,r4,r5 + add r6,r6,r0,ror#6 @ h+=Sigma1(e) + and r2,r2,r11 + add r6,r6,r3 @ h+=K256[i] + eor r2,r2,r5 @ Ch(e,f,g) + eor r0,r7,r7,ror#11 + add r6,r6,r2 @ h+=Ch(e,f,g) +#if 5==31 + and r3,r3,#0xff + cmp r3,#0xf2 @ done? +#endif +#if 5<15 +# if __ARM_ARCH>=7 + ldr r2,[r1],#4 @ prefetch +# else + ldrb r2,[r1,#3] +# endif + eor r3,r7,r8 @ a^b, b^c in next round +#else + ldr r2,[sp,#7*4] @ from future BODY_16_xx + eor r3,r7,r8 @ a^b, b^c in next round + ldr r1,[sp,#4*4] @ from future BODY_16_xx +#endif + eor r0,r0,r7,ror#20 @ Sigma0(a) + and r12,r12,r3 @ (b^c)&=(a^b) + add r10,r10,r6 @ d+=h + eor r12,r12,r8 @ Maj(a,b,c) + add r6,r6,r0,ror#2 @ h+=Sigma0(a) + @ add r6,r6,r12 @ h+=Maj(a,b,c) +#if __ARM_ARCH>=7 + @ ldr r2,[r1],#4 @ 6 +# if 6==15 + str r1,[sp,#17*4] @ make room for r1 +# endif + eor r0,r10,r10,ror#5 + add r6,r6,r12 @ h+=Maj(a,b,c) from the past + eor r0,r0,r10,ror#19 @ Sigma1(e) +# ifndef __ARMEB__ + rev r2,r2 +# endif +#else + @ ldrb r2,[r1,#3] @ 6 + add r6,r6,r12 @ h+=Maj(a,b,c) from the past + ldrb r12,[r1,#2] + ldrb r0,[r1,#1] + orr r2,r2,r12,lsl#8 + ldrb r12,[r1],#4 + orr r2,r2,r0,lsl#16 +# if 6==15 + str r1,[sp,#17*4] @ make room for r1 +# endif + eor r0,r10,r10,ror#5 + orr r2,r2,r12,lsl#24 + eor r0,r0,r10,ror#19 @ Sigma1(e) +#endif + ldr r12,[r14],#4 @ *K256++ + add r5,r5,r2 @ h+=X[i] + str r2,[sp,#6*4] + eor r2,r11,r4 + add r5,r5,r0,ror#6 @ h+=Sigma1(e) + and r2,r2,r10 + add r5,r5,r12 @ h+=K256[i] + eor r2,r2,r4 @ Ch(e,f,g) + eor r0,r6,r6,ror#11 + add r5,r5,r2 @ h+=Ch(e,f,g) +#if 6==31 + and r12,r12,#0xff + cmp r12,#0xf2 @ done? +#endif +#if 6<15 +# if __ARM_ARCH>=7 + ldr r2,[r1],#4 @ prefetch +# else + ldrb r2,[r1,#3] +# endif + eor r12,r6,r7 @ a^b, b^c in next round +#else + ldr r2,[sp,#8*4] @ from future BODY_16_xx + eor r12,r6,r7 @ a^b, b^c in next round + ldr r1,[sp,#5*4] @ from future BODY_16_xx +#endif + eor r0,r0,r6,ror#20 @ Sigma0(a) + and r3,r3,r12 @ (b^c)&=(a^b) + add r9,r9,r5 @ d+=h + eor r3,r3,r7 @ Maj(a,b,c) + add r5,r5,r0,ror#2 @ h+=Sigma0(a) + @ add r5,r5,r3 @ h+=Maj(a,b,c) +#if __ARM_ARCH>=7 + @ ldr r2,[r1],#4 @ 7 +# if 7==15 + str r1,[sp,#17*4] @ make room for r1 +# endif + eor r0,r9,r9,ror#5 + add r5,r5,r3 @ h+=Maj(a,b,c) from the past + eor r0,r0,r9,ror#19 @ Sigma1(e) +# ifndef __ARMEB__ + rev r2,r2 +# endif +#else + @ ldrb r2,[r1,#3] @ 7 + add r5,r5,r3 @ h+=Maj(a,b,c) from the past + ldrb r3,[r1,#2] + ldrb r0,[r1,#1] + orr r2,r2,r3,lsl#8 + ldrb r3,[r1],#4 + orr r2,r2,r0,lsl#16 +# if 7==15 + str r1,[sp,#17*4] @ make room for r1 +# endif + eor r0,r9,r9,ror#5 + orr r2,r2,r3,lsl#24 + eor r0,r0,r9,ror#19 @ Sigma1(e) +#endif + ldr r3,[r14],#4 @ *K256++ + add r4,r4,r2 @ h+=X[i] + str r2,[sp,#7*4] + eor r2,r10,r11 + add r4,r4,r0,ror#6 @ h+=Sigma1(e) + and r2,r2,r9 + add r4,r4,r3 @ h+=K256[i] + eor r2,r2,r11 @ Ch(e,f,g) + eor r0,r5,r5,ror#11 + add r4,r4,r2 @ h+=Ch(e,f,g) +#if 7==31 + and r3,r3,#0xff + cmp r3,#0xf2 @ done? +#endif +#if 7<15 +# if __ARM_ARCH>=7 + ldr r2,[r1],#4 @ prefetch +# else + ldrb r2,[r1,#3] +# endif + eor r3,r5,r6 @ a^b, b^c in next round +#else + ldr r2,[sp,#9*4] @ from future BODY_16_xx + eor r3,r5,r6 @ a^b, b^c in next round + ldr r1,[sp,#6*4] @ from future BODY_16_xx +#endif + eor r0,r0,r5,ror#20 @ Sigma0(a) + and r12,r12,r3 @ (b^c)&=(a^b) + add r8,r8,r4 @ d+=h + eor r12,r12,r6 @ Maj(a,b,c) + add r4,r4,r0,ror#2 @ h+=Sigma0(a) + @ add r4,r4,r12 @ h+=Maj(a,b,c) +#if __ARM_ARCH>=7 + @ ldr r2,[r1],#4 @ 8 +# if 8==15 + str r1,[sp,#17*4] @ make room for r1 +# endif + eor r0,r8,r8,ror#5 + add r4,r4,r12 @ h+=Maj(a,b,c) from the past + eor r0,r0,r8,ror#19 @ Sigma1(e) +# ifndef __ARMEB__ + rev r2,r2 +# endif +#else + @ ldrb r2,[r1,#3] @ 8 + add r4,r4,r12 @ h+=Maj(a,b,c) from the past + ldrb r12,[r1,#2] + ldrb r0,[r1,#1] + orr r2,r2,r12,lsl#8 + ldrb r12,[r1],#4 + orr r2,r2,r0,lsl#16 +# if 8==15 + str r1,[sp,#17*4] @ make room for r1 +# endif + eor r0,r8,r8,ror#5 + orr r2,r2,r12,lsl#24 + eor r0,r0,r8,ror#19 @ Sigma1(e) +#endif + ldr r12,[r14],#4 @ *K256++ + add r11,r11,r2 @ h+=X[i] + str r2,[sp,#8*4] + eor r2,r9,r10 + add r11,r11,r0,ror#6 @ h+=Sigma1(e) + and r2,r2,r8 + add r11,r11,r12 @ h+=K256[i] + eor r2,r2,r10 @ Ch(e,f,g) + eor r0,r4,r4,ror#11 + add r11,r11,r2 @ h+=Ch(e,f,g) +#if 8==31 + and r12,r12,#0xff + cmp r12,#0xf2 @ done? +#endif +#if 8<15 +# if __ARM_ARCH>=7 + ldr r2,[r1],#4 @ prefetch +# else + ldrb r2,[r1,#3] +# endif + eor r12,r4,r5 @ a^b, b^c in next round +#else + ldr r2,[sp,#10*4] @ from future BODY_16_xx + eor r12,r4,r5 @ a^b, b^c in next round + ldr r1,[sp,#7*4] @ from future BODY_16_xx +#endif + eor r0,r0,r4,ror#20 @ Sigma0(a) + and r3,r3,r12 @ (b^c)&=(a^b) + add r7,r7,r11 @ d+=h + eor r3,r3,r5 @ Maj(a,b,c) + add r11,r11,r0,ror#2 @ h+=Sigma0(a) + @ add r11,r11,r3 @ h+=Maj(a,b,c) +#if __ARM_ARCH>=7 + @ ldr r2,[r1],#4 @ 9 +# if 9==15 + str r1,[sp,#17*4] @ make room for r1 +# endif + eor r0,r7,r7,ror#5 + add r11,r11,r3 @ h+=Maj(a,b,c) from the past + eor r0,r0,r7,ror#19 @ Sigma1(e) +# ifndef __ARMEB__ + rev r2,r2 +# endif +#else + @ ldrb r2,[r1,#3] @ 9 + add r11,r11,r3 @ h+=Maj(a,b,c) from the past + ldrb r3,[r1,#2] + ldrb r0,[r1,#1] + orr r2,r2,r3,lsl#8 + ldrb r3,[r1],#4 + orr r2,r2,r0,lsl#16 +# if 9==15 + str r1,[sp,#17*4] @ make room for r1 +# endif + eor r0,r7,r7,ror#5 + orr r2,r2,r3,lsl#24 + eor r0,r0,r7,ror#19 @ Sigma1(e) +#endif + ldr r3,[r14],#4 @ *K256++ + add r10,r10,r2 @ h+=X[i] + str r2,[sp,#9*4] + eor r2,r8,r9 + add r10,r10,r0,ror#6 @ h+=Sigma1(e) + and r2,r2,r7 + add r10,r10,r3 @ h+=K256[i] + eor r2,r2,r9 @ Ch(e,f,g) + eor r0,r11,r11,ror#11 + add r10,r10,r2 @ h+=Ch(e,f,g) +#if 9==31 + and r3,r3,#0xff + cmp r3,#0xf2 @ done? +#endif +#if 9<15 +# if __ARM_ARCH>=7 + ldr r2,[r1],#4 @ prefetch +# else + ldrb r2,[r1,#3] +# endif + eor r3,r11,r4 @ a^b, b^c in next round +#else + ldr r2,[sp,#11*4] @ from future BODY_16_xx + eor r3,r11,r4 @ a^b, b^c in next round + ldr r1,[sp,#8*4] @ from future BODY_16_xx +#endif + eor r0,r0,r11,ror#20 @ Sigma0(a) + and r12,r12,r3 @ (b^c)&=(a^b) + add r6,r6,r10 @ d+=h + eor r12,r12,r4 @ Maj(a,b,c) + add r10,r10,r0,ror#2 @ h+=Sigma0(a) + @ add r10,r10,r12 @ h+=Maj(a,b,c) +#if __ARM_ARCH>=7 + @ ldr r2,[r1],#4 @ 10 +# if 10==15 + str r1,[sp,#17*4] @ make room for r1 +# endif + eor r0,r6,r6,ror#5 + add r10,r10,r12 @ h+=Maj(a,b,c) from the past + eor r0,r0,r6,ror#19 @ Sigma1(e) +# ifndef __ARMEB__ + rev r2,r2 +# endif +#else + @ ldrb r2,[r1,#3] @ 10 + add r10,r10,r12 @ h+=Maj(a,b,c) from the past + ldrb r12,[r1,#2] + ldrb r0,[r1,#1] + orr r2,r2,r12,lsl#8 + ldrb r12,[r1],#4 + orr r2,r2,r0,lsl#16 +# if 10==15 + str r1,[sp,#17*4] @ make room for r1 +# endif + eor r0,r6,r6,ror#5 + orr r2,r2,r12,lsl#24 + eor r0,r0,r6,ror#19 @ Sigma1(e) +#endif + ldr r12,[r14],#4 @ *K256++ + add r9,r9,r2 @ h+=X[i] + str r2,[sp,#10*4] + eor r2,r7,r8 + add r9,r9,r0,ror#6 @ h+=Sigma1(e) + and r2,r2,r6 + add r9,r9,r12 @ h+=K256[i] + eor r2,r2,r8 @ Ch(e,f,g) + eor r0,r10,r10,ror#11 + add r9,r9,r2 @ h+=Ch(e,f,g) +#if 10==31 + and r12,r12,#0xff + cmp r12,#0xf2 @ done? +#endif +#if 10<15 +# if __ARM_ARCH>=7 + ldr r2,[r1],#4 @ prefetch +# else + ldrb r2,[r1,#3] +# endif + eor r12,r10,r11 @ a^b, b^c in next round +#else + ldr r2,[sp,#12*4] @ from future BODY_16_xx + eor r12,r10,r11 @ a^b, b^c in next round + ldr r1,[sp,#9*4] @ from future BODY_16_xx +#endif + eor r0,r0,r10,ror#20 @ Sigma0(a) + and r3,r3,r12 @ (b^c)&=(a^b) + add r5,r5,r9 @ d+=h + eor r3,r3,r11 @ Maj(a,b,c) + add r9,r9,r0,ror#2 @ h+=Sigma0(a) + @ add r9,r9,r3 @ h+=Maj(a,b,c) +#if __ARM_ARCH>=7 + @ ldr r2,[r1],#4 @ 11 +# if 11==15 + str r1,[sp,#17*4] @ make room for r1 +# endif + eor r0,r5,r5,ror#5 + add r9,r9,r3 @ h+=Maj(a,b,c) from the past + eor r0,r0,r5,ror#19 @ Sigma1(e) +# ifndef __ARMEB__ + rev r2,r2 +# endif +#else + @ ldrb r2,[r1,#3] @ 11 + add r9,r9,r3 @ h+=Maj(a,b,c) from the past + ldrb r3,[r1,#2] + ldrb r0,[r1,#1] + orr r2,r2,r3,lsl#8 + ldrb r3,[r1],#4 + orr r2,r2,r0,lsl#16 +# if 11==15 + str r1,[sp,#17*4] @ make room for r1 +# endif + eor r0,r5,r5,ror#5 + orr r2,r2,r3,lsl#24 + eor r0,r0,r5,ror#19 @ Sigma1(e) +#endif + ldr r3,[r14],#4 @ *K256++ + add r8,r8,r2 @ h+=X[i] + str r2,[sp,#11*4] + eor r2,r6,r7 + add r8,r8,r0,ror#6 @ h+=Sigma1(e) + and r2,r2,r5 + add r8,r8,r3 @ h+=K256[i] + eor r2,r2,r7 @ Ch(e,f,g) + eor r0,r9,r9,ror#11 + add r8,r8,r2 @ h+=Ch(e,f,g) +#if 11==31 + and r3,r3,#0xff + cmp r3,#0xf2 @ done? +#endif +#if 11<15 +# if __ARM_ARCH>=7 + ldr r2,[r1],#4 @ prefetch +# else + ldrb r2,[r1,#3] +# endif + eor r3,r9,r10 @ a^b, b^c in next round +#else + ldr r2,[sp,#13*4] @ from future BODY_16_xx + eor r3,r9,r10 @ a^b, b^c in next round + ldr r1,[sp,#10*4] @ from future BODY_16_xx +#endif + eor r0,r0,r9,ror#20 @ Sigma0(a) + and r12,r12,r3 @ (b^c)&=(a^b) + add r4,r4,r8 @ d+=h + eor r12,r12,r10 @ Maj(a,b,c) + add r8,r8,r0,ror#2 @ h+=Sigma0(a) + @ add r8,r8,r12 @ h+=Maj(a,b,c) +#if __ARM_ARCH>=7 + @ ldr r2,[r1],#4 @ 12 +# if 12==15 + str r1,[sp,#17*4] @ make room for r1 +# endif + eor r0,r4,r4,ror#5 + add r8,r8,r12 @ h+=Maj(a,b,c) from the past + eor r0,r0,r4,ror#19 @ Sigma1(e) +# ifndef __ARMEB__ + rev r2,r2 +# endif +#else + @ ldrb r2,[r1,#3] @ 12 + add r8,r8,r12 @ h+=Maj(a,b,c) from the past + ldrb r12,[r1,#2] + ldrb r0,[r1,#1] + orr r2,r2,r12,lsl#8 + ldrb r12,[r1],#4 + orr r2,r2,r0,lsl#16 +# if 12==15 + str r1,[sp,#17*4] @ make room for r1 +# endif + eor r0,r4,r4,ror#5 + orr r2,r2,r12,lsl#24 + eor r0,r0,r4,ror#19 @ Sigma1(e) +#endif + ldr r12,[r14],#4 @ *K256++ + add r7,r7,r2 @ h+=X[i] + str r2,[sp,#12*4] + eor r2,r5,r6 + add r7,r7,r0,ror#6 @ h+=Sigma1(e) + and r2,r2,r4 + add r7,r7,r12 @ h+=K256[i] + eor r2,r2,r6 @ Ch(e,f,g) + eor r0,r8,r8,ror#11 + add r7,r7,r2 @ h+=Ch(e,f,g) +#if 12==31 + and r12,r12,#0xff + cmp r12,#0xf2 @ done? +#endif +#if 12<15 +# if __ARM_ARCH>=7 + ldr r2,[r1],#4 @ prefetch +# else + ldrb r2,[r1,#3] +# endif + eor r12,r8,r9 @ a^b, b^c in next round +#else + ldr r2,[sp,#14*4] @ from future BODY_16_xx + eor r12,r8,r9 @ a^b, b^c in next round + ldr r1,[sp,#11*4] @ from future BODY_16_xx +#endif + eor r0,r0,r8,ror#20 @ Sigma0(a) + and r3,r3,r12 @ (b^c)&=(a^b) + add r11,r11,r7 @ d+=h + eor r3,r3,r9 @ Maj(a,b,c) + add r7,r7,r0,ror#2 @ h+=Sigma0(a) + @ add r7,r7,r3 @ h+=Maj(a,b,c) +#if __ARM_ARCH>=7 + @ ldr r2,[r1],#4 @ 13 +# if 13==15 + str r1,[sp,#17*4] @ make room for r1 +# endif + eor r0,r11,r11,ror#5 + add r7,r7,r3 @ h+=Maj(a,b,c) from the past + eor r0,r0,r11,ror#19 @ Sigma1(e) +# ifndef __ARMEB__ + rev r2,r2 +# endif +#else + @ ldrb r2,[r1,#3] @ 13 + add r7,r7,r3 @ h+=Maj(a,b,c) from the past + ldrb r3,[r1,#2] + ldrb r0,[r1,#1] + orr r2,r2,r3,lsl#8 + ldrb r3,[r1],#4 + orr r2,r2,r0,lsl#16 +# if 13==15 + str r1,[sp,#17*4] @ make room for r1 +# endif + eor r0,r11,r11,ror#5 + orr r2,r2,r3,lsl#24 + eor r0,r0,r11,ror#19 @ Sigma1(e) +#endif + ldr r3,[r14],#4 @ *K256++ + add r6,r6,r2 @ h+=X[i] + str r2,[sp,#13*4] + eor r2,r4,r5 + add r6,r6,r0,ror#6 @ h+=Sigma1(e) + and r2,r2,r11 + add r6,r6,r3 @ h+=K256[i] + eor r2,r2,r5 @ Ch(e,f,g) + eor r0,r7,r7,ror#11 + add r6,r6,r2 @ h+=Ch(e,f,g) +#if 13==31 + and r3,r3,#0xff + cmp r3,#0xf2 @ done? +#endif +#if 13<15 +# if __ARM_ARCH>=7 + ldr r2,[r1],#4 @ prefetch +# else + ldrb r2,[r1,#3] +# endif + eor r3,r7,r8 @ a^b, b^c in next round +#else + ldr r2,[sp,#15*4] @ from future BODY_16_xx + eor r3,r7,r8 @ a^b, b^c in next round + ldr r1,[sp,#12*4] @ from future BODY_16_xx +#endif + eor r0,r0,r7,ror#20 @ Sigma0(a) + and r12,r12,r3 @ (b^c)&=(a^b) + add r10,r10,r6 @ d+=h + eor r12,r12,r8 @ Maj(a,b,c) + add r6,r6,r0,ror#2 @ h+=Sigma0(a) + @ add r6,r6,r12 @ h+=Maj(a,b,c) +#if __ARM_ARCH>=7 + @ ldr r2,[r1],#4 @ 14 +# if 14==15 + str r1,[sp,#17*4] @ make room for r1 +# endif + eor r0,r10,r10,ror#5 + add r6,r6,r12 @ h+=Maj(a,b,c) from the past + eor r0,r0,r10,ror#19 @ Sigma1(e) +# ifndef __ARMEB__ + rev r2,r2 +# endif +#else + @ ldrb r2,[r1,#3] @ 14 + add r6,r6,r12 @ h+=Maj(a,b,c) from the past + ldrb r12,[r1,#2] + ldrb r0,[r1,#1] + orr r2,r2,r12,lsl#8 + ldrb r12,[r1],#4 + orr r2,r2,r0,lsl#16 +# if 14==15 + str r1,[sp,#17*4] @ make room for r1 +# endif + eor r0,r10,r10,ror#5 + orr r2,r2,r12,lsl#24 + eor r0,r0,r10,ror#19 @ Sigma1(e) +#endif + ldr r12,[r14],#4 @ *K256++ + add r5,r5,r2 @ h+=X[i] + str r2,[sp,#14*4] + eor r2,r11,r4 + add r5,r5,r0,ror#6 @ h+=Sigma1(e) + and r2,r2,r10 + add r5,r5,r12 @ h+=K256[i] + eor r2,r2,r4 @ Ch(e,f,g) + eor r0,r6,r6,ror#11 + add r5,r5,r2 @ h+=Ch(e,f,g) +#if 14==31 + and r12,r12,#0xff + cmp r12,#0xf2 @ done? +#endif +#if 14<15 +# if __ARM_ARCH>=7 + ldr r2,[r1],#4 @ prefetch +# else + ldrb r2,[r1,#3] +# endif + eor r12,r6,r7 @ a^b, b^c in next round +#else + ldr r2,[sp,#0*4] @ from future BODY_16_xx + eor r12,r6,r7 @ a^b, b^c in next round + ldr r1,[sp,#13*4] @ from future BODY_16_xx +#endif + eor r0,r0,r6,ror#20 @ Sigma0(a) + and r3,r3,r12 @ (b^c)&=(a^b) + add r9,r9,r5 @ d+=h + eor r3,r3,r7 @ Maj(a,b,c) + add r5,r5,r0,ror#2 @ h+=Sigma0(a) + @ add r5,r5,r3 @ h+=Maj(a,b,c) +#if __ARM_ARCH>=7 + @ ldr r2,[r1],#4 @ 15 +# if 15==15 + str r1,[sp,#17*4] @ make room for r1 +# endif + eor r0,r9,r9,ror#5 + add r5,r5,r3 @ h+=Maj(a,b,c) from the past + eor r0,r0,r9,ror#19 @ Sigma1(e) +# ifndef __ARMEB__ + rev r2,r2 +# endif +#else + @ ldrb r2,[r1,#3] @ 15 + add r5,r5,r3 @ h+=Maj(a,b,c) from the past + ldrb r3,[r1,#2] + ldrb r0,[r1,#1] + orr r2,r2,r3,lsl#8 + ldrb r3,[r1],#4 + orr r2,r2,r0,lsl#16 +# if 15==15 + str r1,[sp,#17*4] @ make room for r1 +# endif + eor r0,r9,r9,ror#5 + orr r2,r2,r3,lsl#24 + eor r0,r0,r9,ror#19 @ Sigma1(e) +#endif + ldr r3,[r14],#4 @ *K256++ + add r4,r4,r2 @ h+=X[i] + str r2,[sp,#15*4] + eor r2,r10,r11 + add r4,r4,r0,ror#6 @ h+=Sigma1(e) + and r2,r2,r9 + add r4,r4,r3 @ h+=K256[i] + eor r2,r2,r11 @ Ch(e,f,g) + eor r0,r5,r5,ror#11 + add r4,r4,r2 @ h+=Ch(e,f,g) +#if 15==31 + and r3,r3,#0xff + cmp r3,#0xf2 @ done? +#endif +#if 15<15 +# if __ARM_ARCH>=7 + ldr r2,[r1],#4 @ prefetch +# else + ldrb r2,[r1,#3] +# endif + eor r3,r5,r6 @ a^b, b^c in next round +#else + ldr r2,[sp,#1*4] @ from future BODY_16_xx + eor r3,r5,r6 @ a^b, b^c in next round + ldr r1,[sp,#14*4] @ from future BODY_16_xx +#endif + eor r0,r0,r5,ror#20 @ Sigma0(a) + and r12,r12,r3 @ (b^c)&=(a^b) + add r8,r8,r4 @ d+=h + eor r12,r12,r6 @ Maj(a,b,c) + add r4,r4,r0,ror#2 @ h+=Sigma0(a) + @ add r4,r4,r12 @ h+=Maj(a,b,c) +.Lrounds_16_xx: + @ ldr r2,[sp,#1*4] @ 16 + @ ldr r1,[sp,#14*4] + mov r0,r2,ror#7 + add r4,r4,r12 @ h+=Maj(a,b,c) from the past + mov r12,r1,ror#17 + eor r0,r0,r2,ror#18 + eor r12,r12,r1,ror#19 + eor r0,r0,r2,lsr#3 @ sigma0(X[i+1]) + ldr r2,[sp,#0*4] + eor r12,r12,r1,lsr#10 @ sigma1(X[i+14]) + ldr r1,[sp,#9*4] + + add r12,r12,r0 + eor r0,r8,r8,ror#5 @ from BODY_00_15 + add r2,r2,r12 + eor r0,r0,r8,ror#19 @ Sigma1(e) + add r2,r2,r1 @ X[i] + ldr r12,[r14],#4 @ *K256++ + add r11,r11,r2 @ h+=X[i] + str r2,[sp,#0*4] + eor r2,r9,r10 + add r11,r11,r0,ror#6 @ h+=Sigma1(e) + and r2,r2,r8 + add r11,r11,r12 @ h+=K256[i] + eor r2,r2,r10 @ Ch(e,f,g) + eor r0,r4,r4,ror#11 + add r11,r11,r2 @ h+=Ch(e,f,g) +#if 16==31 + and r12,r12,#0xff + cmp r12,#0xf2 @ done? +#endif +#if 16<15 +# if __ARM_ARCH>=7 + ldr r2,[r1],#4 @ prefetch +# else + ldrb r2,[r1,#3] +# endif + eor r12,r4,r5 @ a^b, b^c in next round +#else + ldr r2,[sp,#2*4] @ from future BODY_16_xx + eor r12,r4,r5 @ a^b, b^c in next round + ldr r1,[sp,#15*4] @ from future BODY_16_xx +#endif + eor r0,r0,r4,ror#20 @ Sigma0(a) + and r3,r3,r12 @ (b^c)&=(a^b) + add r7,r7,r11 @ d+=h + eor r3,r3,r5 @ Maj(a,b,c) + add r11,r11,r0,ror#2 @ h+=Sigma0(a) + @ add r11,r11,r3 @ h+=Maj(a,b,c) + @ ldr r2,[sp,#2*4] @ 17 + @ ldr r1,[sp,#15*4] + mov r0,r2,ror#7 + add r11,r11,r3 @ h+=Maj(a,b,c) from the past + mov r3,r1,ror#17 + eor r0,r0,r2,ror#18 + eor r3,r3,r1,ror#19 + eor r0,r0,r2,lsr#3 @ sigma0(X[i+1]) + ldr r2,[sp,#1*4] + eor r3,r3,r1,lsr#10 @ sigma1(X[i+14]) + ldr r1,[sp,#10*4] + + add r3,r3,r0 + eor r0,r7,r7,ror#5 @ from BODY_00_15 + add r2,r2,r3 + eor r0,r0,r7,ror#19 @ Sigma1(e) + add r2,r2,r1 @ X[i] + ldr r3,[r14],#4 @ *K256++ + add r10,r10,r2 @ h+=X[i] + str r2,[sp,#1*4] + eor r2,r8,r9 + add r10,r10,r0,ror#6 @ h+=Sigma1(e) + and r2,r2,r7 + add r10,r10,r3 @ h+=K256[i] + eor r2,r2,r9 @ Ch(e,f,g) + eor r0,r11,r11,ror#11 + add r10,r10,r2 @ h+=Ch(e,f,g) +#if 17==31 + and r3,r3,#0xff + cmp r3,#0xf2 @ done? +#endif +#if 17<15 +# if __ARM_ARCH>=7 + ldr r2,[r1],#4 @ prefetch +# else + ldrb r2,[r1,#3] +# endif + eor r3,r11,r4 @ a^b, b^c in next round +#else + ldr r2,[sp,#3*4] @ from future BODY_16_xx + eor r3,r11,r4 @ a^b, b^c in next round + ldr r1,[sp,#0*4] @ from future BODY_16_xx +#endif + eor r0,r0,r11,ror#20 @ Sigma0(a) + and r12,r12,r3 @ (b^c)&=(a^b) + add r6,r6,r10 @ d+=h + eor r12,r12,r4 @ Maj(a,b,c) + add r10,r10,r0,ror#2 @ h+=Sigma0(a) + @ add r10,r10,r12 @ h+=Maj(a,b,c) + @ ldr r2,[sp,#3*4] @ 18 + @ ldr r1,[sp,#0*4] + mov r0,r2,ror#7 + add r10,r10,r12 @ h+=Maj(a,b,c) from the past + mov r12,r1,ror#17 + eor r0,r0,r2,ror#18 + eor r12,r12,r1,ror#19 + eor r0,r0,r2,lsr#3 @ sigma0(X[i+1]) + ldr r2,[sp,#2*4] + eor r12,r12,r1,lsr#10 @ sigma1(X[i+14]) + ldr r1,[sp,#11*4] + + add r12,r12,r0 + eor r0,r6,r6,ror#5 @ from BODY_00_15 + add r2,r2,r12 + eor r0,r0,r6,ror#19 @ Sigma1(e) + add r2,r2,r1 @ X[i] + ldr r12,[r14],#4 @ *K256++ + add r9,r9,r2 @ h+=X[i] + str r2,[sp,#2*4] + eor r2,r7,r8 + add r9,r9,r0,ror#6 @ h+=Sigma1(e) + and r2,r2,r6 + add r9,r9,r12 @ h+=K256[i] + eor r2,r2,r8 @ Ch(e,f,g) + eor r0,r10,r10,ror#11 + add r9,r9,r2 @ h+=Ch(e,f,g) +#if 18==31 + and r12,r12,#0xff + cmp r12,#0xf2 @ done? +#endif +#if 18<15 +# if __ARM_ARCH>=7 + ldr r2,[r1],#4 @ prefetch +# else + ldrb r2,[r1,#3] +# endif + eor r12,r10,r11 @ a^b, b^c in next round +#else + ldr r2,[sp,#4*4] @ from future BODY_16_xx + eor r12,r10,r11 @ a^b, b^c in next round + ldr r1,[sp,#1*4] @ from future BODY_16_xx +#endif + eor r0,r0,r10,ror#20 @ Sigma0(a) + and r3,r3,r12 @ (b^c)&=(a^b) + add r5,r5,r9 @ d+=h + eor r3,r3,r11 @ Maj(a,b,c) + add r9,r9,r0,ror#2 @ h+=Sigma0(a) + @ add r9,r9,r3 @ h+=Maj(a,b,c) + @ ldr r2,[sp,#4*4] @ 19 + @ ldr r1,[sp,#1*4] + mov r0,r2,ror#7 + add r9,r9,r3 @ h+=Maj(a,b,c) from the past + mov r3,r1,ror#17 + eor r0,r0,r2,ror#18 + eor r3,r3,r1,ror#19 + eor r0,r0,r2,lsr#3 @ sigma0(X[i+1]) + ldr r2,[sp,#3*4] + eor r3,r3,r1,lsr#10 @ sigma1(X[i+14]) + ldr r1,[sp,#12*4] + + add r3,r3,r0 + eor r0,r5,r5,ror#5 @ from BODY_00_15 + add r2,r2,r3 + eor r0,r0,r5,ror#19 @ Sigma1(e) + add r2,r2,r1 @ X[i] + ldr r3,[r14],#4 @ *K256++ + add r8,r8,r2 @ h+=X[i] + str r2,[sp,#3*4] + eor r2,r6,r7 + add r8,r8,r0,ror#6 @ h+=Sigma1(e) + and r2,r2,r5 + add r8,r8,r3 @ h+=K256[i] + eor r2,r2,r7 @ Ch(e,f,g) + eor r0,r9,r9,ror#11 + add r8,r8,r2 @ h+=Ch(e,f,g) +#if 19==31 + and r3,r3,#0xff + cmp r3,#0xf2 @ done? +#endif +#if 19<15 +# if __ARM_ARCH>=7 + ldr r2,[r1],#4 @ prefetch +# else + ldrb r2,[r1,#3] +# endif + eor r3,r9,r10 @ a^b, b^c in next round +#else + ldr r2,[sp,#5*4] @ from future BODY_16_xx + eor r3,r9,r10 @ a^b, b^c in next round + ldr r1,[sp,#2*4] @ from future BODY_16_xx +#endif + eor r0,r0,r9,ror#20 @ Sigma0(a) + and r12,r12,r3 @ (b^c)&=(a^b) + add r4,r4,r8 @ d+=h + eor r12,r12,r10 @ Maj(a,b,c) + add r8,r8,r0,ror#2 @ h+=Sigma0(a) + @ add r8,r8,r12 @ h+=Maj(a,b,c) + @ ldr r2,[sp,#5*4] @ 20 + @ ldr r1,[sp,#2*4] + mov r0,r2,ror#7 + add r8,r8,r12 @ h+=Maj(a,b,c) from the past + mov r12,r1,ror#17 + eor r0,r0,r2,ror#18 + eor r12,r12,r1,ror#19 + eor r0,r0,r2,lsr#3 @ sigma0(X[i+1]) + ldr r2,[sp,#4*4] + eor r12,r12,r1,lsr#10 @ sigma1(X[i+14]) + ldr r1,[sp,#13*4] + + add r12,r12,r0 + eor r0,r4,r4,ror#5 @ from BODY_00_15 + add r2,r2,r12 + eor r0,r0,r4,ror#19 @ Sigma1(e) + add r2,r2,r1 @ X[i] + ldr r12,[r14],#4 @ *K256++ + add r7,r7,r2 @ h+=X[i] + str r2,[sp,#4*4] + eor r2,r5,r6 + add r7,r7,r0,ror#6 @ h+=Sigma1(e) + and r2,r2,r4 + add r7,r7,r12 @ h+=K256[i] + eor r2,r2,r6 @ Ch(e,f,g) + eor r0,r8,r8,ror#11 + add r7,r7,r2 @ h+=Ch(e,f,g) +#if 20==31 + and r12,r12,#0xff + cmp r12,#0xf2 @ done? +#endif +#if 20<15 +# if __ARM_ARCH>=7 + ldr r2,[r1],#4 @ prefetch +# else + ldrb r2,[r1,#3] +# endif + eor r12,r8,r9 @ a^b, b^c in next round +#else + ldr r2,[sp,#6*4] @ from future BODY_16_xx + eor r12,r8,r9 @ a^b, b^c in next round + ldr r1,[sp,#3*4] @ from future BODY_16_xx +#endif + eor r0,r0,r8,ror#20 @ Sigma0(a) + and r3,r3,r12 @ (b^c)&=(a^b) + add r11,r11,r7 @ d+=h + eor r3,r3,r9 @ Maj(a,b,c) + add r7,r7,r0,ror#2 @ h+=Sigma0(a) + @ add r7,r7,r3 @ h+=Maj(a,b,c) + @ ldr r2,[sp,#6*4] @ 21 + @ ldr r1,[sp,#3*4] + mov r0,r2,ror#7 + add r7,r7,r3 @ h+=Maj(a,b,c) from the past + mov r3,r1,ror#17 + eor r0,r0,r2,ror#18 + eor r3,r3,r1,ror#19 + eor r0,r0,r2,lsr#3 @ sigma0(X[i+1]) + ldr r2,[sp,#5*4] + eor r3,r3,r1,lsr#10 @ sigma1(X[i+14]) + ldr r1,[sp,#14*4] + + add r3,r3,r0 + eor r0,r11,r11,ror#5 @ from BODY_00_15 + add r2,r2,r3 + eor r0,r0,r11,ror#19 @ Sigma1(e) + add r2,r2,r1 @ X[i] + ldr r3,[r14],#4 @ *K256++ + add r6,r6,r2 @ h+=X[i] + str r2,[sp,#5*4] + eor r2,r4,r5 + add r6,r6,r0,ror#6 @ h+=Sigma1(e) + and r2,r2,r11 + add r6,r6,r3 @ h+=K256[i] + eor r2,r2,r5 @ Ch(e,f,g) + eor r0,r7,r7,ror#11 + add r6,r6,r2 @ h+=Ch(e,f,g) +#if 21==31 + and r3,r3,#0xff + cmp r3,#0xf2 @ done? +#endif +#if 21<15 +# if __ARM_ARCH>=7 + ldr r2,[r1],#4 @ prefetch +# else + ldrb r2,[r1,#3] +# endif + eor r3,r7,r8 @ a^b, b^c in next round +#else + ldr r2,[sp,#7*4] @ from future BODY_16_xx + eor r3,r7,r8 @ a^b, b^c in next round + ldr r1,[sp,#4*4] @ from future BODY_16_xx +#endif + eor r0,r0,r7,ror#20 @ Sigma0(a) + and r12,r12,r3 @ (b^c)&=(a^b) + add r10,r10,r6 @ d+=h + eor r12,r12,r8 @ Maj(a,b,c) + add r6,r6,r0,ror#2 @ h+=Sigma0(a) + @ add r6,r6,r12 @ h+=Maj(a,b,c) + @ ldr r2,[sp,#7*4] @ 22 + @ ldr r1,[sp,#4*4] + mov r0,r2,ror#7 + add r6,r6,r12 @ h+=Maj(a,b,c) from the past + mov r12,r1,ror#17 + eor r0,r0,r2,ror#18 + eor r12,r12,r1,ror#19 + eor r0,r0,r2,lsr#3 @ sigma0(X[i+1]) + ldr r2,[sp,#6*4] + eor r12,r12,r1,lsr#10 @ sigma1(X[i+14]) + ldr r1,[sp,#15*4] + + add r12,r12,r0 + eor r0,r10,r10,ror#5 @ from BODY_00_15 + add r2,r2,r12 + eor r0,r0,r10,ror#19 @ Sigma1(e) + add r2,r2,r1 @ X[i] + ldr r12,[r14],#4 @ *K256++ + add r5,r5,r2 @ h+=X[i] + str r2,[sp,#6*4] + eor r2,r11,r4 + add r5,r5,r0,ror#6 @ h+=Sigma1(e) + and r2,r2,r10 + add r5,r5,r12 @ h+=K256[i] + eor r2,r2,r4 @ Ch(e,f,g) + eor r0,r6,r6,ror#11 + add r5,r5,r2 @ h+=Ch(e,f,g) +#if 22==31 + and r12,r12,#0xff + cmp r12,#0xf2 @ done? +#endif +#if 22<15 +# if __ARM_ARCH>=7 + ldr r2,[r1],#4 @ prefetch +# else + ldrb r2,[r1,#3] +# endif + eor r12,r6,r7 @ a^b, b^c in next round +#else + ldr r2,[sp,#8*4] @ from future BODY_16_xx + eor r12,r6,r7 @ a^b, b^c in next round + ldr r1,[sp,#5*4] @ from future BODY_16_xx +#endif + eor r0,r0,r6,ror#20 @ Sigma0(a) + and r3,r3,r12 @ (b^c)&=(a^b) + add r9,r9,r5 @ d+=h + eor r3,r3,r7 @ Maj(a,b,c) + add r5,r5,r0,ror#2 @ h+=Sigma0(a) + @ add r5,r5,r3 @ h+=Maj(a,b,c) + @ ldr r2,[sp,#8*4] @ 23 + @ ldr r1,[sp,#5*4] + mov r0,r2,ror#7 + add r5,r5,r3 @ h+=Maj(a,b,c) from the past + mov r3,r1,ror#17 + eor r0,r0,r2,ror#18 + eor r3,r3,r1,ror#19 + eor r0,r0,r2,lsr#3 @ sigma0(X[i+1]) + ldr r2,[sp,#7*4] + eor r3,r3,r1,lsr#10 @ sigma1(X[i+14]) + ldr r1,[sp,#0*4] + + add r3,r3,r0 + eor r0,r9,r9,ror#5 @ from BODY_00_15 + add r2,r2,r3 + eor r0,r0,r9,ror#19 @ Sigma1(e) + add r2,r2,r1 @ X[i] + ldr r3,[r14],#4 @ *K256++ + add r4,r4,r2 @ h+=X[i] + str r2,[sp,#7*4] + eor r2,r10,r11 + add r4,r4,r0,ror#6 @ h+=Sigma1(e) + and r2,r2,r9 + add r4,r4,r3 @ h+=K256[i] + eor r2,r2,r11 @ Ch(e,f,g) + eor r0,r5,r5,ror#11 + add r4,r4,r2 @ h+=Ch(e,f,g) +#if 23==31 + and r3,r3,#0xff + cmp r3,#0xf2 @ done? +#endif +#if 23<15 +# if __ARM_ARCH>=7 + ldr r2,[r1],#4 @ prefetch +# else + ldrb r2,[r1,#3] +# endif + eor r3,r5,r6 @ a^b, b^c in next round +#else + ldr r2,[sp,#9*4] @ from future BODY_16_xx + eor r3,r5,r6 @ a^b, b^c in next round + ldr r1,[sp,#6*4] @ from future BODY_16_xx +#endif + eor r0,r0,r5,ror#20 @ Sigma0(a) + and r12,r12,r3 @ (b^c)&=(a^b) + add r8,r8,r4 @ d+=h + eor r12,r12,r6 @ Maj(a,b,c) + add r4,r4,r0,ror#2 @ h+=Sigma0(a) + @ add r4,r4,r12 @ h+=Maj(a,b,c) + @ ldr r2,[sp,#9*4] @ 24 + @ ldr r1,[sp,#6*4] + mov r0,r2,ror#7 + add r4,r4,r12 @ h+=Maj(a,b,c) from the past + mov r12,r1,ror#17 + eor r0,r0,r2,ror#18 + eor r12,r12,r1,ror#19 + eor r0,r0,r2,lsr#3 @ sigma0(X[i+1]) + ldr r2,[sp,#8*4] + eor r12,r12,r1,lsr#10 @ sigma1(X[i+14]) + ldr r1,[sp,#1*4] + + add r12,r12,r0 + eor r0,r8,r8,ror#5 @ from BODY_00_15 + add r2,r2,r12 + eor r0,r0,r8,ror#19 @ Sigma1(e) + add r2,r2,r1 @ X[i] + ldr r12,[r14],#4 @ *K256++ + add r11,r11,r2 @ h+=X[i] + str r2,[sp,#8*4] + eor r2,r9,r10 + add r11,r11,r0,ror#6 @ h+=Sigma1(e) + and r2,r2,r8 + add r11,r11,r12 @ h+=K256[i] + eor r2,r2,r10 @ Ch(e,f,g) + eor r0,r4,r4,ror#11 + add r11,r11,r2 @ h+=Ch(e,f,g) +#if 24==31 + and r12,r12,#0xff + cmp r12,#0xf2 @ done? +#endif +#if 24<15 +# if __ARM_ARCH>=7 + ldr r2,[r1],#4 @ prefetch +# else + ldrb r2,[r1,#3] +# endif + eor r12,r4,r5 @ a^b, b^c in next round +#else + ldr r2,[sp,#10*4] @ from future BODY_16_xx + eor r12,r4,r5 @ a^b, b^c in next round + ldr r1,[sp,#7*4] @ from future BODY_16_xx +#endif + eor r0,r0,r4,ror#20 @ Sigma0(a) + and r3,r3,r12 @ (b^c)&=(a^b) + add r7,r7,r11 @ d+=h + eor r3,r3,r5 @ Maj(a,b,c) + add r11,r11,r0,ror#2 @ h+=Sigma0(a) + @ add r11,r11,r3 @ h+=Maj(a,b,c) + @ ldr r2,[sp,#10*4] @ 25 + @ ldr r1,[sp,#7*4] + mov r0,r2,ror#7 + add r11,r11,r3 @ h+=Maj(a,b,c) from the past + mov r3,r1,ror#17 + eor r0,r0,r2,ror#18 + eor r3,r3,r1,ror#19 + eor r0,r0,r2,lsr#3 @ sigma0(X[i+1]) + ldr r2,[sp,#9*4] + eor r3,r3,r1,lsr#10 @ sigma1(X[i+14]) + ldr r1,[sp,#2*4] + + add r3,r3,r0 + eor r0,r7,r7,ror#5 @ from BODY_00_15 + add r2,r2,r3 + eor r0,r0,r7,ror#19 @ Sigma1(e) + add r2,r2,r1 @ X[i] + ldr r3,[r14],#4 @ *K256++ + add r10,r10,r2 @ h+=X[i] + str r2,[sp,#9*4] + eor r2,r8,r9 + add r10,r10,r0,ror#6 @ h+=Sigma1(e) + and r2,r2,r7 + add r10,r10,r3 @ h+=K256[i] + eor r2,r2,r9 @ Ch(e,f,g) + eor r0,r11,r11,ror#11 + add r10,r10,r2 @ h+=Ch(e,f,g) +#if 25==31 + and r3,r3,#0xff + cmp r3,#0xf2 @ done? +#endif +#if 25<15 +# if __ARM_ARCH>=7 + ldr r2,[r1],#4 @ prefetch +# else + ldrb r2,[r1,#3] +# endif + eor r3,r11,r4 @ a^b, b^c in next round +#else + ldr r2,[sp,#11*4] @ from future BODY_16_xx + eor r3,r11,r4 @ a^b, b^c in next round + ldr r1,[sp,#8*4] @ from future BODY_16_xx +#endif + eor r0,r0,r11,ror#20 @ Sigma0(a) + and r12,r12,r3 @ (b^c)&=(a^b) + add r6,r6,r10 @ d+=h + eor r12,r12,r4 @ Maj(a,b,c) + add r10,r10,r0,ror#2 @ h+=Sigma0(a) + @ add r10,r10,r12 @ h+=Maj(a,b,c) + @ ldr r2,[sp,#11*4] @ 26 + @ ldr r1,[sp,#8*4] + mov r0,r2,ror#7 + add r10,r10,r12 @ h+=Maj(a,b,c) from the past + mov r12,r1,ror#17 + eor r0,r0,r2,ror#18 + eor r12,r12,r1,ror#19 + eor r0,r0,r2,lsr#3 @ sigma0(X[i+1]) + ldr r2,[sp,#10*4] + eor r12,r12,r1,lsr#10 @ sigma1(X[i+14]) + ldr r1,[sp,#3*4] + + add r12,r12,r0 + eor r0,r6,r6,ror#5 @ from BODY_00_15 + add r2,r2,r12 + eor r0,r0,r6,ror#19 @ Sigma1(e) + add r2,r2,r1 @ X[i] + ldr r12,[r14],#4 @ *K256++ + add r9,r9,r2 @ h+=X[i] + str r2,[sp,#10*4] + eor r2,r7,r8 + add r9,r9,r0,ror#6 @ h+=Sigma1(e) + and r2,r2,r6 + add r9,r9,r12 @ h+=K256[i] + eor r2,r2,r8 @ Ch(e,f,g) + eor r0,r10,r10,ror#11 + add r9,r9,r2 @ h+=Ch(e,f,g) +#if 26==31 + and r12,r12,#0xff + cmp r12,#0xf2 @ done? +#endif +#if 26<15 +# if __ARM_ARCH>=7 + ldr r2,[r1],#4 @ prefetch +# else + ldrb r2,[r1,#3] +# endif + eor r12,r10,r11 @ a^b, b^c in next round +#else + ldr r2,[sp,#12*4] @ from future BODY_16_xx + eor r12,r10,r11 @ a^b, b^c in next round + ldr r1,[sp,#9*4] @ from future BODY_16_xx +#endif + eor r0,r0,r10,ror#20 @ Sigma0(a) + and r3,r3,r12 @ (b^c)&=(a^b) + add r5,r5,r9 @ d+=h + eor r3,r3,r11 @ Maj(a,b,c) + add r9,r9,r0,ror#2 @ h+=Sigma0(a) + @ add r9,r9,r3 @ h+=Maj(a,b,c) + @ ldr r2,[sp,#12*4] @ 27 + @ ldr r1,[sp,#9*4] + mov r0,r2,ror#7 + add r9,r9,r3 @ h+=Maj(a,b,c) from the past + mov r3,r1,ror#17 + eor r0,r0,r2,ror#18 + eor r3,r3,r1,ror#19 + eor r0,r0,r2,lsr#3 @ sigma0(X[i+1]) + ldr r2,[sp,#11*4] + eor r3,r3,r1,lsr#10 @ sigma1(X[i+14]) + ldr r1,[sp,#4*4] + + add r3,r3,r0 + eor r0,r5,r5,ror#5 @ from BODY_00_15 + add r2,r2,r3 + eor r0,r0,r5,ror#19 @ Sigma1(e) + add r2,r2,r1 @ X[i] + ldr r3,[r14],#4 @ *K256++ + add r8,r8,r2 @ h+=X[i] + str r2,[sp,#11*4] + eor r2,r6,r7 + add r8,r8,r0,ror#6 @ h+=Sigma1(e) + and r2,r2,r5 + add r8,r8,r3 @ h+=K256[i] + eor r2,r2,r7 @ Ch(e,f,g) + eor r0,r9,r9,ror#11 + add r8,r8,r2 @ h+=Ch(e,f,g) +#if 27==31 + and r3,r3,#0xff + cmp r3,#0xf2 @ done? +#endif +#if 27<15 +# if __ARM_ARCH>=7 + ldr r2,[r1],#4 @ prefetch +# else + ldrb r2,[r1,#3] +# endif + eor r3,r9,r10 @ a^b, b^c in next round +#else + ldr r2,[sp,#13*4] @ from future BODY_16_xx + eor r3,r9,r10 @ a^b, b^c in next round + ldr r1,[sp,#10*4] @ from future BODY_16_xx +#endif + eor r0,r0,r9,ror#20 @ Sigma0(a) + and r12,r12,r3 @ (b^c)&=(a^b) + add r4,r4,r8 @ d+=h + eor r12,r12,r10 @ Maj(a,b,c) + add r8,r8,r0,ror#2 @ h+=Sigma0(a) + @ add r8,r8,r12 @ h+=Maj(a,b,c) + @ ldr r2,[sp,#13*4] @ 28 + @ ldr r1,[sp,#10*4] + mov r0,r2,ror#7 + add r8,r8,r12 @ h+=Maj(a,b,c) from the past + mov r12,r1,ror#17 + eor r0,r0,r2,ror#18 + eor r12,r12,r1,ror#19 + eor r0,r0,r2,lsr#3 @ sigma0(X[i+1]) + ldr r2,[sp,#12*4] + eor r12,r12,r1,lsr#10 @ sigma1(X[i+14]) + ldr r1,[sp,#5*4] + + add r12,r12,r0 + eor r0,r4,r4,ror#5 @ from BODY_00_15 + add r2,r2,r12 + eor r0,r0,r4,ror#19 @ Sigma1(e) + add r2,r2,r1 @ X[i] + ldr r12,[r14],#4 @ *K256++ + add r7,r7,r2 @ h+=X[i] + str r2,[sp,#12*4] + eor r2,r5,r6 + add r7,r7,r0,ror#6 @ h+=Sigma1(e) + and r2,r2,r4 + add r7,r7,r12 @ h+=K256[i] + eor r2,r2,r6 @ Ch(e,f,g) + eor r0,r8,r8,ror#11 + add r7,r7,r2 @ h+=Ch(e,f,g) +#if 28==31 + and r12,r12,#0xff + cmp r12,#0xf2 @ done? +#endif +#if 28<15 +# if __ARM_ARCH>=7 + ldr r2,[r1],#4 @ prefetch +# else + ldrb r2,[r1,#3] +# endif + eor r12,r8,r9 @ a^b, b^c in next round +#else + ldr r2,[sp,#14*4] @ from future BODY_16_xx + eor r12,r8,r9 @ a^b, b^c in next round + ldr r1,[sp,#11*4] @ from future BODY_16_xx +#endif + eor r0,r0,r8,ror#20 @ Sigma0(a) + and r3,r3,r12 @ (b^c)&=(a^b) + add r11,r11,r7 @ d+=h + eor r3,r3,r9 @ Maj(a,b,c) + add r7,r7,r0,ror#2 @ h+=Sigma0(a) + @ add r7,r7,r3 @ h+=Maj(a,b,c) + @ ldr r2,[sp,#14*4] @ 29 + @ ldr r1,[sp,#11*4] + mov r0,r2,ror#7 + add r7,r7,r3 @ h+=Maj(a,b,c) from the past + mov r3,r1,ror#17 + eor r0,r0,r2,ror#18 + eor r3,r3,r1,ror#19 + eor r0,r0,r2,lsr#3 @ sigma0(X[i+1]) + ldr r2,[sp,#13*4] + eor r3,r3,r1,lsr#10 @ sigma1(X[i+14]) + ldr r1,[sp,#6*4] + + add r3,r3,r0 + eor r0,r11,r11,ror#5 @ from BODY_00_15 + add r2,r2,r3 + eor r0,r0,r11,ror#19 @ Sigma1(e) + add r2,r2,r1 @ X[i] + ldr r3,[r14],#4 @ *K256++ + add r6,r6,r2 @ h+=X[i] + str r2,[sp,#13*4] + eor r2,r4,r5 + add r6,r6,r0,ror#6 @ h+=Sigma1(e) + and r2,r2,r11 + add r6,r6,r3 @ h+=K256[i] + eor r2,r2,r5 @ Ch(e,f,g) + eor r0,r7,r7,ror#11 + add r6,r6,r2 @ h+=Ch(e,f,g) +#if 29==31 + and r3,r3,#0xff + cmp r3,#0xf2 @ done? +#endif +#if 29<15 +# if __ARM_ARCH>=7 + ldr r2,[r1],#4 @ prefetch +# else + ldrb r2,[r1,#3] +# endif + eor r3,r7,r8 @ a^b, b^c in next round +#else + ldr r2,[sp,#15*4] @ from future BODY_16_xx + eor r3,r7,r8 @ a^b, b^c in next round + ldr r1,[sp,#12*4] @ from future BODY_16_xx +#endif + eor r0,r0,r7,ror#20 @ Sigma0(a) + and r12,r12,r3 @ (b^c)&=(a^b) + add r10,r10,r6 @ d+=h + eor r12,r12,r8 @ Maj(a,b,c) + add r6,r6,r0,ror#2 @ h+=Sigma0(a) + @ add r6,r6,r12 @ h+=Maj(a,b,c) + @ ldr r2,[sp,#15*4] @ 30 + @ ldr r1,[sp,#12*4] + mov r0,r2,ror#7 + add r6,r6,r12 @ h+=Maj(a,b,c) from the past + mov r12,r1,ror#17 + eor r0,r0,r2,ror#18 + eor r12,r12,r1,ror#19 + eor r0,r0,r2,lsr#3 @ sigma0(X[i+1]) + ldr r2,[sp,#14*4] + eor r12,r12,r1,lsr#10 @ sigma1(X[i+14]) + ldr r1,[sp,#7*4] + + add r12,r12,r0 + eor r0,r10,r10,ror#5 @ from BODY_00_15 + add r2,r2,r12 + eor r0,r0,r10,ror#19 @ Sigma1(e) + add r2,r2,r1 @ X[i] + ldr r12,[r14],#4 @ *K256++ + add r5,r5,r2 @ h+=X[i] + str r2,[sp,#14*4] + eor r2,r11,r4 + add r5,r5,r0,ror#6 @ h+=Sigma1(e) + and r2,r2,r10 + add r5,r5,r12 @ h+=K256[i] + eor r2,r2,r4 @ Ch(e,f,g) + eor r0,r6,r6,ror#11 + add r5,r5,r2 @ h+=Ch(e,f,g) +#if 30==31 + and r12,r12,#0xff + cmp r12,#0xf2 @ done? +#endif +#if 30<15 +# if __ARM_ARCH>=7 + ldr r2,[r1],#4 @ prefetch +# else + ldrb r2,[r1,#3] +# endif + eor r12,r6,r7 @ a^b, b^c in next round +#else + ldr r2,[sp,#0*4] @ from future BODY_16_xx + eor r12,r6,r7 @ a^b, b^c in next round + ldr r1,[sp,#13*4] @ from future BODY_16_xx +#endif + eor r0,r0,r6,ror#20 @ Sigma0(a) + and r3,r3,r12 @ (b^c)&=(a^b) + add r9,r9,r5 @ d+=h + eor r3,r3,r7 @ Maj(a,b,c) + add r5,r5,r0,ror#2 @ h+=Sigma0(a) + @ add r5,r5,r3 @ h+=Maj(a,b,c) + @ ldr r2,[sp,#0*4] @ 31 + @ ldr r1,[sp,#13*4] + mov r0,r2,ror#7 + add r5,r5,r3 @ h+=Maj(a,b,c) from the past + mov r3,r1,ror#17 + eor r0,r0,r2,ror#18 + eor r3,r3,r1,ror#19 + eor r0,r0,r2,lsr#3 @ sigma0(X[i+1]) + ldr r2,[sp,#15*4] + eor r3,r3,r1,lsr#10 @ sigma1(X[i+14]) + ldr r1,[sp,#8*4] + + add r3,r3,r0 + eor r0,r9,r9,ror#5 @ from BODY_00_15 + add r2,r2,r3 + eor r0,r0,r9,ror#19 @ Sigma1(e) + add r2,r2,r1 @ X[i] + ldr r3,[r14],#4 @ *K256++ + add r4,r4,r2 @ h+=X[i] + str r2,[sp,#15*4] + eor r2,r10,r11 + add r4,r4,r0,ror#6 @ h+=Sigma1(e) + and r2,r2,r9 + add r4,r4,r3 @ h+=K256[i] + eor r2,r2,r11 @ Ch(e,f,g) + eor r0,r5,r5,ror#11 + add r4,r4,r2 @ h+=Ch(e,f,g) +#if 31==31 + and r3,r3,#0xff + cmp r3,#0xf2 @ done? +#endif +#if 31<15 +# if __ARM_ARCH>=7 + ldr r2,[r1],#4 @ prefetch +# else + ldrb r2,[r1,#3] +# endif + eor r3,r5,r6 @ a^b, b^c in next round +#else + ldr r2,[sp,#1*4] @ from future BODY_16_xx + eor r3,r5,r6 @ a^b, b^c in next round + ldr r1,[sp,#14*4] @ from future BODY_16_xx +#endif + eor r0,r0,r5,ror#20 @ Sigma0(a) + and r12,r12,r3 @ (b^c)&=(a^b) + add r8,r8,r4 @ d+=h + eor r12,r12,r6 @ Maj(a,b,c) + add r4,r4,r0,ror#2 @ h+=Sigma0(a) + @ add r4,r4,r12 @ h+=Maj(a,b,c) +#if __ARM_ARCH>=7 + ite eq @ Thumb2 thing, sanity check in ARM +#endif + ldreq r3,[sp,#16*4] @ pull ctx + bne .Lrounds_16_xx + + add r4,r4,r12 @ h+=Maj(a,b,c) from the past + ldr r0,[r3,#0] + ldr r2,[r3,#4] + ldr r12,[r3,#8] + add r4,r4,r0 + ldr r0,[r3,#12] + add r5,r5,r2 + ldr r2,[r3,#16] + add r6,r6,r12 + ldr r12,[r3,#20] + add r7,r7,r0 + ldr r0,[r3,#24] + add r8,r8,r2 + ldr r2,[r3,#28] + add r9,r9,r12 + ldr r1,[sp,#17*4] @ pull inp + ldr r12,[sp,#18*4] @ pull inp+len + add r10,r10,r0 + add r11,r11,r2 + stmia r3,{r4,r5,r6,r7,r8,r9,r10,r11} + cmp r1,r12 + sub r14,r14,#256 @ rewind Ktbl + bne .Loop + + add sp,sp,#19*4 @ destroy frame +#if __ARM_ARCH>=5 + ldmia sp!,{r4,r5,r6,r7,r8,r9,r10,r11,pc} +#else + ldmia sp!,{r4,r5,r6,r7,r8,r9,r10,r11,lr} + tst lr,#1 + moveq pc,lr @ be binary compatible with V4, yet +.word 0xe12fff1e @ interoperable with Thumb ISA:-) +#endif +.size sha256_block_data_order_nohw,.-sha256_block_data_order_nohw +#if __ARM_MAX_ARCH__>=7 +.arch armv7-a +.fpu neon + +.LK256_shortcut_neon: +@ PC is 8 bytes ahead in Arm mode and 4 bytes ahead in Thumb mode. +#if defined(__thumb2__) +.word K256-(.LK256_add_neon+4) +#else +.word K256-(.LK256_add_neon+8) +#endif + +.globl sha256_block_data_order_neon +.hidden sha256_block_data_order_neon +.type sha256_block_data_order_neon,%function +.align 5 +.skip 16 +sha256_block_data_order_neon: + stmdb sp!,{r4,r5,r6,r7,r8,r9,r10,r11,r12,lr} + + sub r11,sp,#16*4+16 + + @ K256 is just at the boundary of being easily referenced by an ADR from + @ this function. In Arm mode, when building with __ARM_ARCH=6, it does + @ not fit. By moving code around, we could make it fit, but this is too + @ fragile. For simplicity, just load the offset from + @ .LK256_shortcut_neon. + @ + @ TODO(davidben): adrl would avoid a load, but clang-assembler does not + @ support it. We might be able to emulate it with a macro, but Android's + @ did not work when I tried it. + @ https://android.googlesource.com/platform/ndk/+/refs/heads/main/docs/ClangMigration.md#arm + ldr r14,.LK256_shortcut_neon +.LK256_add_neon: + add r14,pc,r14 + + bic r11,r11,#15 @ align for 128-bit stores + mov r12,sp + mov sp,r11 @ alloca + add r2,r1,r2,lsl#6 @ len to point at the end of inp + + vld1.8 {q0},[r1]! + vld1.8 {q1},[r1]! + vld1.8 {q2},[r1]! + vld1.8 {q3},[r1]! + vld1.32 {q8},[r14,:128]! + vld1.32 {q9},[r14,:128]! + vld1.32 {q10},[r14,:128]! + vld1.32 {q11},[r14,:128]! + vrev32.8 q0,q0 @ yes, even on + str r0,[sp,#64] + vrev32.8 q1,q1 @ big-endian + str r1,[sp,#68] + mov r1,sp + vrev32.8 q2,q2 + str r2,[sp,#72] + vrev32.8 q3,q3 + str r12,[sp,#76] @ save original sp + vadd.i32 q8,q8,q0 + vadd.i32 q9,q9,q1 + vst1.32 {q8},[r1,:128]! + vadd.i32 q10,q10,q2 + vst1.32 {q9},[r1,:128]! + vadd.i32 q11,q11,q3 + vst1.32 {q10},[r1,:128]! + vst1.32 {q11},[r1,:128]! + + ldmia r0,{r4,r5,r6,r7,r8,r9,r10,r11} + sub r1,r1,#64 + ldr r2,[sp,#0] + eor r12,r12,r12 + eor r3,r5,r6 + b .L_00_48 + +.align 4 +.L_00_48: + vext.8 q8,q0,q1,#4 + add r11,r11,r2 + eor r2,r9,r10 + eor r0,r8,r8,ror#5 + vext.8 q9,q2,q3,#4 + add r4,r4,r12 + and r2,r2,r8 + eor r12,r0,r8,ror#19 + vshr.u32 q10,q8,#7 + eor r0,r4,r4,ror#11 + eor r2,r2,r10 + vadd.i32 q0,q0,q9 + add r11,r11,r12,ror#6 + eor r12,r4,r5 + vshr.u32 q9,q8,#3 + eor r0,r0,r4,ror#20 + add r11,r11,r2 + vsli.32 q10,q8,#25 + ldr r2,[sp,#4] + and r3,r3,r12 + vshr.u32 q11,q8,#18 + add r7,r7,r11 + add r11,r11,r0,ror#2 + eor r3,r3,r5 + veor q9,q9,q10 + add r10,r10,r2 + vsli.32 q11,q8,#14 + eor r2,r8,r9 + eor r0,r7,r7,ror#5 + vshr.u32 d24,d7,#17 + add r11,r11,r3 + and r2,r2,r7 + veor q9,q9,q11 + eor r3,r0,r7,ror#19 + eor r0,r11,r11,ror#11 + vsli.32 d24,d7,#15 + eor r2,r2,r9 + add r10,r10,r3,ror#6 + vshr.u32 d25,d7,#10 + eor r3,r11,r4 + eor r0,r0,r11,ror#20 + vadd.i32 q0,q0,q9 + add r10,r10,r2 + ldr r2,[sp,#8] + veor d25,d25,d24 + and r12,r12,r3 + add r6,r6,r10 + vshr.u32 d24,d7,#19 + add r10,r10,r0,ror#2 + eor r12,r12,r4 + vsli.32 d24,d7,#13 + add r9,r9,r2 + eor r2,r7,r8 + veor d25,d25,d24 + eor r0,r6,r6,ror#5 + add r10,r10,r12 + vadd.i32 d0,d0,d25 + and r2,r2,r6 + eor r12,r0,r6,ror#19 + vshr.u32 d24,d0,#17 + eor r0,r10,r10,ror#11 + eor r2,r2,r8 + vsli.32 d24,d0,#15 + add r9,r9,r12,ror#6 + eor r12,r10,r11 + vshr.u32 d25,d0,#10 + eor r0,r0,r10,ror#20 + add r9,r9,r2 + veor d25,d25,d24 + ldr r2,[sp,#12] + and r3,r3,r12 + vshr.u32 d24,d0,#19 + add r5,r5,r9 + add r9,r9,r0,ror#2 + eor r3,r3,r11 + vld1.32 {q8},[r14,:128]! + add r8,r8,r2 + vsli.32 d24,d0,#13 + eor r2,r6,r7 + eor r0,r5,r5,ror#5 + veor d25,d25,d24 + add r9,r9,r3 + and r2,r2,r5 + vadd.i32 d1,d1,d25 + eor r3,r0,r5,ror#19 + eor r0,r9,r9,ror#11 + vadd.i32 q8,q8,q0 + eor r2,r2,r7 + add r8,r8,r3,ror#6 + eor r3,r9,r10 + eor r0,r0,r9,ror#20 + add r8,r8,r2 + ldr r2,[sp,#16] + and r12,r12,r3 + add r4,r4,r8 + vst1.32 {q8},[r1,:128]! + add r8,r8,r0,ror#2 + eor r12,r12,r10 + vext.8 q8,q1,q2,#4 + add r7,r7,r2 + eor r2,r5,r6 + eor r0,r4,r4,ror#5 + vext.8 q9,q3,q0,#4 + add r8,r8,r12 + and r2,r2,r4 + eor r12,r0,r4,ror#19 + vshr.u32 q10,q8,#7 + eor r0,r8,r8,ror#11 + eor r2,r2,r6 + vadd.i32 q1,q1,q9 + add r7,r7,r12,ror#6 + eor r12,r8,r9 + vshr.u32 q9,q8,#3 + eor r0,r0,r8,ror#20 + add r7,r7,r2 + vsli.32 q10,q8,#25 + ldr r2,[sp,#20] + and r3,r3,r12 + vshr.u32 q11,q8,#18 + add r11,r11,r7 + add r7,r7,r0,ror#2 + eor r3,r3,r9 + veor q9,q9,q10 + add r6,r6,r2 + vsli.32 q11,q8,#14 + eor r2,r4,r5 + eor r0,r11,r11,ror#5 + vshr.u32 d24,d1,#17 + add r7,r7,r3 + and r2,r2,r11 + veor q9,q9,q11 + eor r3,r0,r11,ror#19 + eor r0,r7,r7,ror#11 + vsli.32 d24,d1,#15 + eor r2,r2,r5 + add r6,r6,r3,ror#6 + vshr.u32 d25,d1,#10 + eor r3,r7,r8 + eor r0,r0,r7,ror#20 + vadd.i32 q1,q1,q9 + add r6,r6,r2 + ldr r2,[sp,#24] + veor d25,d25,d24 + and r12,r12,r3 + add r10,r10,r6 + vshr.u32 d24,d1,#19 + add r6,r6,r0,ror#2 + eor r12,r12,r8 + vsli.32 d24,d1,#13 + add r5,r5,r2 + eor r2,r11,r4 + veor d25,d25,d24 + eor r0,r10,r10,ror#5 + add r6,r6,r12 + vadd.i32 d2,d2,d25 + and r2,r2,r10 + eor r12,r0,r10,ror#19 + vshr.u32 d24,d2,#17 + eor r0,r6,r6,ror#11 + eor r2,r2,r4 + vsli.32 d24,d2,#15 + add r5,r5,r12,ror#6 + eor r12,r6,r7 + vshr.u32 d25,d2,#10 + eor r0,r0,r6,ror#20 + add r5,r5,r2 + veor d25,d25,d24 + ldr r2,[sp,#28] + and r3,r3,r12 + vshr.u32 d24,d2,#19 + add r9,r9,r5 + add r5,r5,r0,ror#2 + eor r3,r3,r7 + vld1.32 {q8},[r14,:128]! + add r4,r4,r2 + vsli.32 d24,d2,#13 + eor r2,r10,r11 + eor r0,r9,r9,ror#5 + veor d25,d25,d24 + add r5,r5,r3 + and r2,r2,r9 + vadd.i32 d3,d3,d25 + eor r3,r0,r9,ror#19 + eor r0,r5,r5,ror#11 + vadd.i32 q8,q8,q1 + eor r2,r2,r11 + add r4,r4,r3,ror#6 + eor r3,r5,r6 + eor r0,r0,r5,ror#20 + add r4,r4,r2 + ldr r2,[sp,#32] + and r12,r12,r3 + add r8,r8,r4 + vst1.32 {q8},[r1,:128]! + add r4,r4,r0,ror#2 + eor r12,r12,r6 + vext.8 q8,q2,q3,#4 + add r11,r11,r2 + eor r2,r9,r10 + eor r0,r8,r8,ror#5 + vext.8 q9,q0,q1,#4 + add r4,r4,r12 + and r2,r2,r8 + eor r12,r0,r8,ror#19 + vshr.u32 q10,q8,#7 + eor r0,r4,r4,ror#11 + eor r2,r2,r10 + vadd.i32 q2,q2,q9 + add r11,r11,r12,ror#6 + eor r12,r4,r5 + vshr.u32 q9,q8,#3 + eor r0,r0,r4,ror#20 + add r11,r11,r2 + vsli.32 q10,q8,#25 + ldr r2,[sp,#36] + and r3,r3,r12 + vshr.u32 q11,q8,#18 + add r7,r7,r11 + add r11,r11,r0,ror#2 + eor r3,r3,r5 + veor q9,q9,q10 + add r10,r10,r2 + vsli.32 q11,q8,#14 + eor r2,r8,r9 + eor r0,r7,r7,ror#5 + vshr.u32 d24,d3,#17 + add r11,r11,r3 + and r2,r2,r7 + veor q9,q9,q11 + eor r3,r0,r7,ror#19 + eor r0,r11,r11,ror#11 + vsli.32 d24,d3,#15 + eor r2,r2,r9 + add r10,r10,r3,ror#6 + vshr.u32 d25,d3,#10 + eor r3,r11,r4 + eor r0,r0,r11,ror#20 + vadd.i32 q2,q2,q9 + add r10,r10,r2 + ldr r2,[sp,#40] + veor d25,d25,d24 + and r12,r12,r3 + add r6,r6,r10 + vshr.u32 d24,d3,#19 + add r10,r10,r0,ror#2 + eor r12,r12,r4 + vsli.32 d24,d3,#13 + add r9,r9,r2 + eor r2,r7,r8 + veor d25,d25,d24 + eor r0,r6,r6,ror#5 + add r10,r10,r12 + vadd.i32 d4,d4,d25 + and r2,r2,r6 + eor r12,r0,r6,ror#19 + vshr.u32 d24,d4,#17 + eor r0,r10,r10,ror#11 + eor r2,r2,r8 + vsli.32 d24,d4,#15 + add r9,r9,r12,ror#6 + eor r12,r10,r11 + vshr.u32 d25,d4,#10 + eor r0,r0,r10,ror#20 + add r9,r9,r2 + veor d25,d25,d24 + ldr r2,[sp,#44] + and r3,r3,r12 + vshr.u32 d24,d4,#19 + add r5,r5,r9 + add r9,r9,r0,ror#2 + eor r3,r3,r11 + vld1.32 {q8},[r14,:128]! + add r8,r8,r2 + vsli.32 d24,d4,#13 + eor r2,r6,r7 + eor r0,r5,r5,ror#5 + veor d25,d25,d24 + add r9,r9,r3 + and r2,r2,r5 + vadd.i32 d5,d5,d25 + eor r3,r0,r5,ror#19 + eor r0,r9,r9,ror#11 + vadd.i32 q8,q8,q2 + eor r2,r2,r7 + add r8,r8,r3,ror#6 + eor r3,r9,r10 + eor r0,r0,r9,ror#20 + add r8,r8,r2 + ldr r2,[sp,#48] + and r12,r12,r3 + add r4,r4,r8 + vst1.32 {q8},[r1,:128]! + add r8,r8,r0,ror#2 + eor r12,r12,r10 + vext.8 q8,q3,q0,#4 + add r7,r7,r2 + eor r2,r5,r6 + eor r0,r4,r4,ror#5 + vext.8 q9,q1,q2,#4 + add r8,r8,r12 + and r2,r2,r4 + eor r12,r0,r4,ror#19 + vshr.u32 q10,q8,#7 + eor r0,r8,r8,ror#11 + eor r2,r2,r6 + vadd.i32 q3,q3,q9 + add r7,r7,r12,ror#6 + eor r12,r8,r9 + vshr.u32 q9,q8,#3 + eor r0,r0,r8,ror#20 + add r7,r7,r2 + vsli.32 q10,q8,#25 + ldr r2,[sp,#52] + and r3,r3,r12 + vshr.u32 q11,q8,#18 + add r11,r11,r7 + add r7,r7,r0,ror#2 + eor r3,r3,r9 + veor q9,q9,q10 + add r6,r6,r2 + vsli.32 q11,q8,#14 + eor r2,r4,r5 + eor r0,r11,r11,ror#5 + vshr.u32 d24,d5,#17 + add r7,r7,r3 + and r2,r2,r11 + veor q9,q9,q11 + eor r3,r0,r11,ror#19 + eor r0,r7,r7,ror#11 + vsli.32 d24,d5,#15 + eor r2,r2,r5 + add r6,r6,r3,ror#6 + vshr.u32 d25,d5,#10 + eor r3,r7,r8 + eor r0,r0,r7,ror#20 + vadd.i32 q3,q3,q9 + add r6,r6,r2 + ldr r2,[sp,#56] + veor d25,d25,d24 + and r12,r12,r3 + add r10,r10,r6 + vshr.u32 d24,d5,#19 + add r6,r6,r0,ror#2 + eor r12,r12,r8 + vsli.32 d24,d5,#13 + add r5,r5,r2 + eor r2,r11,r4 + veor d25,d25,d24 + eor r0,r10,r10,ror#5 + add r6,r6,r12 + vadd.i32 d6,d6,d25 + and r2,r2,r10 + eor r12,r0,r10,ror#19 + vshr.u32 d24,d6,#17 + eor r0,r6,r6,ror#11 + eor r2,r2,r4 + vsli.32 d24,d6,#15 + add r5,r5,r12,ror#6 + eor r12,r6,r7 + vshr.u32 d25,d6,#10 + eor r0,r0,r6,ror#20 + add r5,r5,r2 + veor d25,d25,d24 + ldr r2,[sp,#60] + and r3,r3,r12 + vshr.u32 d24,d6,#19 + add r9,r9,r5 + add r5,r5,r0,ror#2 + eor r3,r3,r7 + vld1.32 {q8},[r14,:128]! + add r4,r4,r2 + vsli.32 d24,d6,#13 + eor r2,r10,r11 + eor r0,r9,r9,ror#5 + veor d25,d25,d24 + add r5,r5,r3 + and r2,r2,r9 + vadd.i32 d7,d7,d25 + eor r3,r0,r9,ror#19 + eor r0,r5,r5,ror#11 + vadd.i32 q8,q8,q3 + eor r2,r2,r11 + add r4,r4,r3,ror#6 + eor r3,r5,r6 + eor r0,r0,r5,ror#20 + add r4,r4,r2 + ldr r2,[r14] + and r12,r12,r3 + add r8,r8,r4 + vst1.32 {q8},[r1,:128]! + add r4,r4,r0,ror#2 + eor r12,r12,r6 + teq r2,#0 @ check for K256 terminator + ldr r2,[sp,#0] + sub r1,r1,#64 + bne .L_00_48 + + ldr r1,[sp,#68] + ldr r0,[sp,#72] + sub r14,r14,#256 @ rewind r14 + teq r1,r0 + it eq + subeq r1,r1,#64 @ avoid SEGV + vld1.8 {q0},[r1]! @ load next input block + vld1.8 {q1},[r1]! + vld1.8 {q2},[r1]! + vld1.8 {q3},[r1]! + it ne + strne r1,[sp,#68] + mov r1,sp + add r11,r11,r2 + eor r2,r9,r10 + eor r0,r8,r8,ror#5 + add r4,r4,r12 + vld1.32 {q8},[r14,:128]! + and r2,r2,r8 + eor r12,r0,r8,ror#19 + eor r0,r4,r4,ror#11 + eor r2,r2,r10 + vrev32.8 q0,q0 + add r11,r11,r12,ror#6 + eor r12,r4,r5 + eor r0,r0,r4,ror#20 + add r11,r11,r2 + vadd.i32 q8,q8,q0 + ldr r2,[sp,#4] + and r3,r3,r12 + add r7,r7,r11 + add r11,r11,r0,ror#2 + eor r3,r3,r5 + add r10,r10,r2 + eor r2,r8,r9 + eor r0,r7,r7,ror#5 + add r11,r11,r3 + and r2,r2,r7 + eor r3,r0,r7,ror#19 + eor r0,r11,r11,ror#11 + eor r2,r2,r9 + add r10,r10,r3,ror#6 + eor r3,r11,r4 + eor r0,r0,r11,ror#20 + add r10,r10,r2 + ldr r2,[sp,#8] + and r12,r12,r3 + add r6,r6,r10 + add r10,r10,r0,ror#2 + eor r12,r12,r4 + add r9,r9,r2 + eor r2,r7,r8 + eor r0,r6,r6,ror#5 + add r10,r10,r12 + and r2,r2,r6 + eor r12,r0,r6,ror#19 + eor r0,r10,r10,ror#11 + eor r2,r2,r8 + add r9,r9,r12,ror#6 + eor r12,r10,r11 + eor r0,r0,r10,ror#20 + add r9,r9,r2 + ldr r2,[sp,#12] + and r3,r3,r12 + add r5,r5,r9 + add r9,r9,r0,ror#2 + eor r3,r3,r11 + add r8,r8,r2 + eor r2,r6,r7 + eor r0,r5,r5,ror#5 + add r9,r9,r3 + and r2,r2,r5 + eor r3,r0,r5,ror#19 + eor r0,r9,r9,ror#11 + eor r2,r2,r7 + add r8,r8,r3,ror#6 + eor r3,r9,r10 + eor r0,r0,r9,ror#20 + add r8,r8,r2 + ldr r2,[sp,#16] + and r12,r12,r3 + add r4,r4,r8 + add r8,r8,r0,ror#2 + eor r12,r12,r10 + vst1.32 {q8},[r1,:128]! + add r7,r7,r2 + eor r2,r5,r6 + eor r0,r4,r4,ror#5 + add r8,r8,r12 + vld1.32 {q8},[r14,:128]! + and r2,r2,r4 + eor r12,r0,r4,ror#19 + eor r0,r8,r8,ror#11 + eor r2,r2,r6 + vrev32.8 q1,q1 + add r7,r7,r12,ror#6 + eor r12,r8,r9 + eor r0,r0,r8,ror#20 + add r7,r7,r2 + vadd.i32 q8,q8,q1 + ldr r2,[sp,#20] + and r3,r3,r12 + add r11,r11,r7 + add r7,r7,r0,ror#2 + eor r3,r3,r9 + add r6,r6,r2 + eor r2,r4,r5 + eor r0,r11,r11,ror#5 + add r7,r7,r3 + and r2,r2,r11 + eor r3,r0,r11,ror#19 + eor r0,r7,r7,ror#11 + eor r2,r2,r5 + add r6,r6,r3,ror#6 + eor r3,r7,r8 + eor r0,r0,r7,ror#20 + add r6,r6,r2 + ldr r2,[sp,#24] + and r12,r12,r3 + add r10,r10,r6 + add r6,r6,r0,ror#2 + eor r12,r12,r8 + add r5,r5,r2 + eor r2,r11,r4 + eor r0,r10,r10,ror#5 + add r6,r6,r12 + and r2,r2,r10 + eor r12,r0,r10,ror#19 + eor r0,r6,r6,ror#11 + eor r2,r2,r4 + add r5,r5,r12,ror#6 + eor r12,r6,r7 + eor r0,r0,r6,ror#20 + add r5,r5,r2 + ldr r2,[sp,#28] + and r3,r3,r12 + add r9,r9,r5 + add r5,r5,r0,ror#2 + eor r3,r3,r7 + add r4,r4,r2 + eor r2,r10,r11 + eor r0,r9,r9,ror#5 + add r5,r5,r3 + and r2,r2,r9 + eor r3,r0,r9,ror#19 + eor r0,r5,r5,ror#11 + eor r2,r2,r11 + add r4,r4,r3,ror#6 + eor r3,r5,r6 + eor r0,r0,r5,ror#20 + add r4,r4,r2 + ldr r2,[sp,#32] + and r12,r12,r3 + add r8,r8,r4 + add r4,r4,r0,ror#2 + eor r12,r12,r6 + vst1.32 {q8},[r1,:128]! + add r11,r11,r2 + eor r2,r9,r10 + eor r0,r8,r8,ror#5 + add r4,r4,r12 + vld1.32 {q8},[r14,:128]! + and r2,r2,r8 + eor r12,r0,r8,ror#19 + eor r0,r4,r4,ror#11 + eor r2,r2,r10 + vrev32.8 q2,q2 + add r11,r11,r12,ror#6 + eor r12,r4,r5 + eor r0,r0,r4,ror#20 + add r11,r11,r2 + vadd.i32 q8,q8,q2 + ldr r2,[sp,#36] + and r3,r3,r12 + add r7,r7,r11 + add r11,r11,r0,ror#2 + eor r3,r3,r5 + add r10,r10,r2 + eor r2,r8,r9 + eor r0,r7,r7,ror#5 + add r11,r11,r3 + and r2,r2,r7 + eor r3,r0,r7,ror#19 + eor r0,r11,r11,ror#11 + eor r2,r2,r9 + add r10,r10,r3,ror#6 + eor r3,r11,r4 + eor r0,r0,r11,ror#20 + add r10,r10,r2 + ldr r2,[sp,#40] + and r12,r12,r3 + add r6,r6,r10 + add r10,r10,r0,ror#2 + eor r12,r12,r4 + add r9,r9,r2 + eor r2,r7,r8 + eor r0,r6,r6,ror#5 + add r10,r10,r12 + and r2,r2,r6 + eor r12,r0,r6,ror#19 + eor r0,r10,r10,ror#11 + eor r2,r2,r8 + add r9,r9,r12,ror#6 + eor r12,r10,r11 + eor r0,r0,r10,ror#20 + add r9,r9,r2 + ldr r2,[sp,#44] + and r3,r3,r12 + add r5,r5,r9 + add r9,r9,r0,ror#2 + eor r3,r3,r11 + add r8,r8,r2 + eor r2,r6,r7 + eor r0,r5,r5,ror#5 + add r9,r9,r3 + and r2,r2,r5 + eor r3,r0,r5,ror#19 + eor r0,r9,r9,ror#11 + eor r2,r2,r7 + add r8,r8,r3,ror#6 + eor r3,r9,r10 + eor r0,r0,r9,ror#20 + add r8,r8,r2 + ldr r2,[sp,#48] + and r12,r12,r3 + add r4,r4,r8 + add r8,r8,r0,ror#2 + eor r12,r12,r10 + vst1.32 {q8},[r1,:128]! + add r7,r7,r2 + eor r2,r5,r6 + eor r0,r4,r4,ror#5 + add r8,r8,r12 + vld1.32 {q8},[r14,:128]! + and r2,r2,r4 + eor r12,r0,r4,ror#19 + eor r0,r8,r8,ror#11 + eor r2,r2,r6 + vrev32.8 q3,q3 + add r7,r7,r12,ror#6 + eor r12,r8,r9 + eor r0,r0,r8,ror#20 + add r7,r7,r2 + vadd.i32 q8,q8,q3 + ldr r2,[sp,#52] + and r3,r3,r12 + add r11,r11,r7 + add r7,r7,r0,ror#2 + eor r3,r3,r9 + add r6,r6,r2 + eor r2,r4,r5 + eor r0,r11,r11,ror#5 + add r7,r7,r3 + and r2,r2,r11 + eor r3,r0,r11,ror#19 + eor r0,r7,r7,ror#11 + eor r2,r2,r5 + add r6,r6,r3,ror#6 + eor r3,r7,r8 + eor r0,r0,r7,ror#20 + add r6,r6,r2 + ldr r2,[sp,#56] + and r12,r12,r3 + add r10,r10,r6 + add r6,r6,r0,ror#2 + eor r12,r12,r8 + add r5,r5,r2 + eor r2,r11,r4 + eor r0,r10,r10,ror#5 + add r6,r6,r12 + and r2,r2,r10 + eor r12,r0,r10,ror#19 + eor r0,r6,r6,ror#11 + eor r2,r2,r4 + add r5,r5,r12,ror#6 + eor r12,r6,r7 + eor r0,r0,r6,ror#20 + add r5,r5,r2 + ldr r2,[sp,#60] + and r3,r3,r12 + add r9,r9,r5 + add r5,r5,r0,ror#2 + eor r3,r3,r7 + add r4,r4,r2 + eor r2,r10,r11 + eor r0,r9,r9,ror#5 + add r5,r5,r3 + and r2,r2,r9 + eor r3,r0,r9,ror#19 + eor r0,r5,r5,ror#11 + eor r2,r2,r11 + add r4,r4,r3,ror#6 + eor r3,r5,r6 + eor r0,r0,r5,ror#20 + add r4,r4,r2 + ldr r2,[sp,#64] + and r12,r12,r3 + add r8,r8,r4 + add r4,r4,r0,ror#2 + eor r12,r12,r6 + vst1.32 {q8},[r1,:128]! + ldr r0,[r2,#0] + add r4,r4,r12 @ h+=Maj(a,b,c) from the past + ldr r12,[r2,#4] + ldr r3,[r2,#8] + ldr r1,[r2,#12] + add r4,r4,r0 @ accumulate + ldr r0,[r2,#16] + add r5,r5,r12 + ldr r12,[r2,#20] + add r6,r6,r3 + ldr r3,[r2,#24] + add r7,r7,r1 + ldr r1,[r2,#28] + add r8,r8,r0 + str r4,[r2],#4 + add r9,r9,r12 + str r5,[r2],#4 + add r10,r10,r3 + str r6,[r2],#4 + add r11,r11,r1 + str r7,[r2],#4 + stmia r2,{r8,r9,r10,r11} + + ittte ne + movne r1,sp + ldrne r2,[sp,#0] + eorne r12,r12,r12 + ldreq sp,[sp,#76] @ restore original sp + itt ne + eorne r3,r5,r6 + bne .L_00_48 + + ldmia sp!,{r4,r5,r6,r7,r8,r9,r10,r11,r12,pc} +.size sha256_block_data_order_neon,.-sha256_block_data_order_neon +#endif +.byte 83,72,65,50,53,54,32,98,108,111,99,107,32,116,114,97,110,115,102,111,114,109,32,102,111,114,32,65,82,77,118,52,47,78,69,79,78,47,65,82,77,118,56,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.align 2 +.align 2 +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_ARM) && defined(__ELF__) diff --git a/http/vendor/ring/pregenerated/sha256-armv8-ios64.S b/http/vendor/ring/pregenerated/sha256-armv8-ios64.S new file mode 100644 index 0000000..8ecafb4 --- /dev/null +++ b/http/vendor/ring/pregenerated/sha256-armv8-ios64.S @@ -0,0 +1,1195 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__APPLE__) +// Copyright 2014-2020 The OpenSSL Project Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// ==================================================================== +// Written by Andy Polyakov for the OpenSSL +// project. +// ==================================================================== +// +// SHA256/512 for ARMv8. +// +// Performance in cycles per processed byte and improvement coefficient +// over code generated with "default" compiler: +// +// SHA256-hw SHA256(*) SHA512 +// Apple A7 1.97 10.5 (+33%) 6.73 (-1%(**)) +// Cortex-A53 2.38 15.5 (+115%) 10.0 (+150%(***)) +// Cortex-A57 2.31 11.6 (+86%) 7.51 (+260%(***)) +// Denver 2.01 10.5 (+26%) 6.70 (+8%) +// X-Gene 20.0 (+100%) 12.8 (+300%(***)) +// Mongoose 2.36 13.0 (+50%) 8.36 (+33%) +// Kryo 1.92 17.4 (+30%) 11.2 (+8%) +// +// (*) Software SHA256 results are of lesser relevance, presented +// mostly for informational purposes. +// (**) The result is a trade-off: it's possible to improve it by +// 10% (or by 1 cycle per round), but at the cost of 20% loss +// on Cortex-A53 (or by 4 cycles per round). +// (***) Super-impressive coefficients over gcc-generated code are +// indication of some compiler "pathology", most notably code +// generated with -mgeneral-regs-only is significantly faster +// and the gap is only 40-90%. + +#ifndef __KERNEL__ +#endif + +.text + +.globl _sha256_block_data_order_nohw +.private_extern _sha256_block_data_order_nohw + +.align 6 +_sha256_block_data_order_nohw: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-128]! + add x29,sp,#0 + + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + stp x27,x28,[sp,#80] + sub sp,sp,#4*4 + + ldp w20,w21,[x0] // load context + ldp w22,w23,[x0,#2*4] + ldp w24,w25,[x0,#4*4] + add x2,x1,x2,lsl#6 // end of input + ldp w26,w27,[x0,#6*4] + adrp x30,LK256@PAGE + add x30,x30,LK256@PAGEOFF + stp x0,x2,[x29,#96] + +Loop: + ldp w3,w4,[x1],#2*4 + ldr w19,[x30],#4 // *K++ + eor w28,w21,w22 // magic seed + str x1,[x29,#112] +#ifndef __AARCH64EB__ + rev w3,w3 // 0 +#endif + ror w16,w24,#6 + add w27,w27,w19 // h+=K[i] + eor w6,w24,w24,ror#14 + and w17,w25,w24 + bic w19,w26,w24 + add w27,w27,w3 // h+=X[i] + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w20,w21 // a^b, b^c in next round + eor w16,w16,w6,ror#11 // Sigma1(e) + ror w6,w20,#2 + add w27,w27,w17 // h+=Ch(e,f,g) + eor w17,w20,w20,ror#9 + add w27,w27,w16 // h+=Sigma1(e) + and w28,w28,w19 // (b^c)&=(a^b) + add w23,w23,w27 // d+=h + eor w28,w28,w21 // Maj(a,b,c) + eor w17,w6,w17,ror#13 // Sigma0(a) + add w27,w27,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + //add w27,w27,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w4,w4 // 1 +#endif + ldp w5,w6,[x1],#2*4 + add w27,w27,w17 // h+=Sigma0(a) + ror w16,w23,#6 + add w26,w26,w28 // h+=K[i] + eor w7,w23,w23,ror#14 + and w17,w24,w23 + bic w28,w25,w23 + add w26,w26,w4 // h+=X[i] + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w27,w20 // a^b, b^c in next round + eor w16,w16,w7,ror#11 // Sigma1(e) + ror w7,w27,#2 + add w26,w26,w17 // h+=Ch(e,f,g) + eor w17,w27,w27,ror#9 + add w26,w26,w16 // h+=Sigma1(e) + and w19,w19,w28 // (b^c)&=(a^b) + add w22,w22,w26 // d+=h + eor w19,w19,w20 // Maj(a,b,c) + eor w17,w7,w17,ror#13 // Sigma0(a) + add w26,w26,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + //add w26,w26,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w5,w5 // 2 +#endif + add w26,w26,w17 // h+=Sigma0(a) + ror w16,w22,#6 + add w25,w25,w19 // h+=K[i] + eor w8,w22,w22,ror#14 + and w17,w23,w22 + bic w19,w24,w22 + add w25,w25,w5 // h+=X[i] + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w26,w27 // a^b, b^c in next round + eor w16,w16,w8,ror#11 // Sigma1(e) + ror w8,w26,#2 + add w25,w25,w17 // h+=Ch(e,f,g) + eor w17,w26,w26,ror#9 + add w25,w25,w16 // h+=Sigma1(e) + and w28,w28,w19 // (b^c)&=(a^b) + add w21,w21,w25 // d+=h + eor w28,w28,w27 // Maj(a,b,c) + eor w17,w8,w17,ror#13 // Sigma0(a) + add w25,w25,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + //add w25,w25,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w6,w6 // 3 +#endif + ldp w7,w8,[x1],#2*4 + add w25,w25,w17 // h+=Sigma0(a) + ror w16,w21,#6 + add w24,w24,w28 // h+=K[i] + eor w9,w21,w21,ror#14 + and w17,w22,w21 + bic w28,w23,w21 + add w24,w24,w6 // h+=X[i] + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w25,w26 // a^b, b^c in next round + eor w16,w16,w9,ror#11 // Sigma1(e) + ror w9,w25,#2 + add w24,w24,w17 // h+=Ch(e,f,g) + eor w17,w25,w25,ror#9 + add w24,w24,w16 // h+=Sigma1(e) + and w19,w19,w28 // (b^c)&=(a^b) + add w20,w20,w24 // d+=h + eor w19,w19,w26 // Maj(a,b,c) + eor w17,w9,w17,ror#13 // Sigma0(a) + add w24,w24,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + //add w24,w24,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w7,w7 // 4 +#endif + add w24,w24,w17 // h+=Sigma0(a) + ror w16,w20,#6 + add w23,w23,w19 // h+=K[i] + eor w10,w20,w20,ror#14 + and w17,w21,w20 + bic w19,w22,w20 + add w23,w23,w7 // h+=X[i] + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w24,w25 // a^b, b^c in next round + eor w16,w16,w10,ror#11 // Sigma1(e) + ror w10,w24,#2 + add w23,w23,w17 // h+=Ch(e,f,g) + eor w17,w24,w24,ror#9 + add w23,w23,w16 // h+=Sigma1(e) + and w28,w28,w19 // (b^c)&=(a^b) + add w27,w27,w23 // d+=h + eor w28,w28,w25 // Maj(a,b,c) + eor w17,w10,w17,ror#13 // Sigma0(a) + add w23,w23,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + //add w23,w23,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w8,w8 // 5 +#endif + ldp w9,w10,[x1],#2*4 + add w23,w23,w17 // h+=Sigma0(a) + ror w16,w27,#6 + add w22,w22,w28 // h+=K[i] + eor w11,w27,w27,ror#14 + and w17,w20,w27 + bic w28,w21,w27 + add w22,w22,w8 // h+=X[i] + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w23,w24 // a^b, b^c in next round + eor w16,w16,w11,ror#11 // Sigma1(e) + ror w11,w23,#2 + add w22,w22,w17 // h+=Ch(e,f,g) + eor w17,w23,w23,ror#9 + add w22,w22,w16 // h+=Sigma1(e) + and w19,w19,w28 // (b^c)&=(a^b) + add w26,w26,w22 // d+=h + eor w19,w19,w24 // Maj(a,b,c) + eor w17,w11,w17,ror#13 // Sigma0(a) + add w22,w22,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + //add w22,w22,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w9,w9 // 6 +#endif + add w22,w22,w17 // h+=Sigma0(a) + ror w16,w26,#6 + add w21,w21,w19 // h+=K[i] + eor w12,w26,w26,ror#14 + and w17,w27,w26 + bic w19,w20,w26 + add w21,w21,w9 // h+=X[i] + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w22,w23 // a^b, b^c in next round + eor w16,w16,w12,ror#11 // Sigma1(e) + ror w12,w22,#2 + add w21,w21,w17 // h+=Ch(e,f,g) + eor w17,w22,w22,ror#9 + add w21,w21,w16 // h+=Sigma1(e) + and w28,w28,w19 // (b^c)&=(a^b) + add w25,w25,w21 // d+=h + eor w28,w28,w23 // Maj(a,b,c) + eor w17,w12,w17,ror#13 // Sigma0(a) + add w21,w21,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + //add w21,w21,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w10,w10 // 7 +#endif + ldp w11,w12,[x1],#2*4 + add w21,w21,w17 // h+=Sigma0(a) + ror w16,w25,#6 + add w20,w20,w28 // h+=K[i] + eor w13,w25,w25,ror#14 + and w17,w26,w25 + bic w28,w27,w25 + add w20,w20,w10 // h+=X[i] + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w21,w22 // a^b, b^c in next round + eor w16,w16,w13,ror#11 // Sigma1(e) + ror w13,w21,#2 + add w20,w20,w17 // h+=Ch(e,f,g) + eor w17,w21,w21,ror#9 + add w20,w20,w16 // h+=Sigma1(e) + and w19,w19,w28 // (b^c)&=(a^b) + add w24,w24,w20 // d+=h + eor w19,w19,w22 // Maj(a,b,c) + eor w17,w13,w17,ror#13 // Sigma0(a) + add w20,w20,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + //add w20,w20,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w11,w11 // 8 +#endif + add w20,w20,w17 // h+=Sigma0(a) + ror w16,w24,#6 + add w27,w27,w19 // h+=K[i] + eor w14,w24,w24,ror#14 + and w17,w25,w24 + bic w19,w26,w24 + add w27,w27,w11 // h+=X[i] + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w20,w21 // a^b, b^c in next round + eor w16,w16,w14,ror#11 // Sigma1(e) + ror w14,w20,#2 + add w27,w27,w17 // h+=Ch(e,f,g) + eor w17,w20,w20,ror#9 + add w27,w27,w16 // h+=Sigma1(e) + and w28,w28,w19 // (b^c)&=(a^b) + add w23,w23,w27 // d+=h + eor w28,w28,w21 // Maj(a,b,c) + eor w17,w14,w17,ror#13 // Sigma0(a) + add w27,w27,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + //add w27,w27,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w12,w12 // 9 +#endif + ldp w13,w14,[x1],#2*4 + add w27,w27,w17 // h+=Sigma0(a) + ror w16,w23,#6 + add w26,w26,w28 // h+=K[i] + eor w15,w23,w23,ror#14 + and w17,w24,w23 + bic w28,w25,w23 + add w26,w26,w12 // h+=X[i] + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w27,w20 // a^b, b^c in next round + eor w16,w16,w15,ror#11 // Sigma1(e) + ror w15,w27,#2 + add w26,w26,w17 // h+=Ch(e,f,g) + eor w17,w27,w27,ror#9 + add w26,w26,w16 // h+=Sigma1(e) + and w19,w19,w28 // (b^c)&=(a^b) + add w22,w22,w26 // d+=h + eor w19,w19,w20 // Maj(a,b,c) + eor w17,w15,w17,ror#13 // Sigma0(a) + add w26,w26,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + //add w26,w26,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w13,w13 // 10 +#endif + add w26,w26,w17 // h+=Sigma0(a) + ror w16,w22,#6 + add w25,w25,w19 // h+=K[i] + eor w0,w22,w22,ror#14 + and w17,w23,w22 + bic w19,w24,w22 + add w25,w25,w13 // h+=X[i] + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w26,w27 // a^b, b^c in next round + eor w16,w16,w0,ror#11 // Sigma1(e) + ror w0,w26,#2 + add w25,w25,w17 // h+=Ch(e,f,g) + eor w17,w26,w26,ror#9 + add w25,w25,w16 // h+=Sigma1(e) + and w28,w28,w19 // (b^c)&=(a^b) + add w21,w21,w25 // d+=h + eor w28,w28,w27 // Maj(a,b,c) + eor w17,w0,w17,ror#13 // Sigma0(a) + add w25,w25,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + //add w25,w25,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w14,w14 // 11 +#endif + ldp w15,w0,[x1],#2*4 + add w25,w25,w17 // h+=Sigma0(a) + str w6,[sp,#12] + ror w16,w21,#6 + add w24,w24,w28 // h+=K[i] + eor w6,w21,w21,ror#14 + and w17,w22,w21 + bic w28,w23,w21 + add w24,w24,w14 // h+=X[i] + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w25,w26 // a^b, b^c in next round + eor w16,w16,w6,ror#11 // Sigma1(e) + ror w6,w25,#2 + add w24,w24,w17 // h+=Ch(e,f,g) + eor w17,w25,w25,ror#9 + add w24,w24,w16 // h+=Sigma1(e) + and w19,w19,w28 // (b^c)&=(a^b) + add w20,w20,w24 // d+=h + eor w19,w19,w26 // Maj(a,b,c) + eor w17,w6,w17,ror#13 // Sigma0(a) + add w24,w24,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + //add w24,w24,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w15,w15 // 12 +#endif + add w24,w24,w17 // h+=Sigma0(a) + str w7,[sp,#0] + ror w16,w20,#6 + add w23,w23,w19 // h+=K[i] + eor w7,w20,w20,ror#14 + and w17,w21,w20 + bic w19,w22,w20 + add w23,w23,w15 // h+=X[i] + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w24,w25 // a^b, b^c in next round + eor w16,w16,w7,ror#11 // Sigma1(e) + ror w7,w24,#2 + add w23,w23,w17 // h+=Ch(e,f,g) + eor w17,w24,w24,ror#9 + add w23,w23,w16 // h+=Sigma1(e) + and w28,w28,w19 // (b^c)&=(a^b) + add w27,w27,w23 // d+=h + eor w28,w28,w25 // Maj(a,b,c) + eor w17,w7,w17,ror#13 // Sigma0(a) + add w23,w23,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + //add w23,w23,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w0,w0 // 13 +#endif + ldp w1,w2,[x1] + add w23,w23,w17 // h+=Sigma0(a) + str w8,[sp,#4] + ror w16,w27,#6 + add w22,w22,w28 // h+=K[i] + eor w8,w27,w27,ror#14 + and w17,w20,w27 + bic w28,w21,w27 + add w22,w22,w0 // h+=X[i] + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w23,w24 // a^b, b^c in next round + eor w16,w16,w8,ror#11 // Sigma1(e) + ror w8,w23,#2 + add w22,w22,w17 // h+=Ch(e,f,g) + eor w17,w23,w23,ror#9 + add w22,w22,w16 // h+=Sigma1(e) + and w19,w19,w28 // (b^c)&=(a^b) + add w26,w26,w22 // d+=h + eor w19,w19,w24 // Maj(a,b,c) + eor w17,w8,w17,ror#13 // Sigma0(a) + add w22,w22,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + //add w22,w22,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w1,w1 // 14 +#endif + ldr w6,[sp,#12] + add w22,w22,w17 // h+=Sigma0(a) + str w9,[sp,#8] + ror w16,w26,#6 + add w21,w21,w19 // h+=K[i] + eor w9,w26,w26,ror#14 + and w17,w27,w26 + bic w19,w20,w26 + add w21,w21,w1 // h+=X[i] + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w22,w23 // a^b, b^c in next round + eor w16,w16,w9,ror#11 // Sigma1(e) + ror w9,w22,#2 + add w21,w21,w17 // h+=Ch(e,f,g) + eor w17,w22,w22,ror#9 + add w21,w21,w16 // h+=Sigma1(e) + and w28,w28,w19 // (b^c)&=(a^b) + add w25,w25,w21 // d+=h + eor w28,w28,w23 // Maj(a,b,c) + eor w17,w9,w17,ror#13 // Sigma0(a) + add w21,w21,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + //add w21,w21,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w2,w2 // 15 +#endif + ldr w7,[sp,#0] + add w21,w21,w17 // h+=Sigma0(a) + str w10,[sp,#12] + ror w16,w25,#6 + add w20,w20,w28 // h+=K[i] + ror w9,w4,#7 + and w17,w26,w25 + ror w8,w1,#17 + bic w28,w27,w25 + ror w10,w21,#2 + add w20,w20,w2 // h+=X[i] + eor w16,w16,w25,ror#11 + eor w9,w9,w4,ror#18 + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w21,w22 // a^b, b^c in next round + eor w16,w16,w25,ror#25 // Sigma1(e) + eor w10,w10,w21,ror#13 + add w20,w20,w17 // h+=Ch(e,f,g) + and w19,w19,w28 // (b^c)&=(a^b) + eor w8,w8,w1,ror#19 + eor w9,w9,w4,lsr#3 // sigma0(X[i+1]) + add w20,w20,w16 // h+=Sigma1(e) + eor w19,w19,w22 // Maj(a,b,c) + eor w17,w10,w21,ror#22 // Sigma0(a) + eor w8,w8,w1,lsr#10 // sigma1(X[i+14]) + add w3,w3,w12 + add w24,w24,w20 // d+=h + add w20,w20,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + add w3,w3,w9 + add w20,w20,w17 // h+=Sigma0(a) + add w3,w3,w8 +Loop_16_xx: + ldr w8,[sp,#4] + str w11,[sp,#0] + ror w16,w24,#6 + add w27,w27,w19 // h+=K[i] + ror w10,w5,#7 + and w17,w25,w24 + ror w9,w2,#17 + bic w19,w26,w24 + ror w11,w20,#2 + add w27,w27,w3 // h+=X[i] + eor w16,w16,w24,ror#11 + eor w10,w10,w5,ror#18 + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w20,w21 // a^b, b^c in next round + eor w16,w16,w24,ror#25 // Sigma1(e) + eor w11,w11,w20,ror#13 + add w27,w27,w17 // h+=Ch(e,f,g) + and w28,w28,w19 // (b^c)&=(a^b) + eor w9,w9,w2,ror#19 + eor w10,w10,w5,lsr#3 // sigma0(X[i+1]) + add w27,w27,w16 // h+=Sigma1(e) + eor w28,w28,w21 // Maj(a,b,c) + eor w17,w11,w20,ror#22 // Sigma0(a) + eor w9,w9,w2,lsr#10 // sigma1(X[i+14]) + add w4,w4,w13 + add w23,w23,w27 // d+=h + add w27,w27,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + add w4,w4,w10 + add w27,w27,w17 // h+=Sigma0(a) + add w4,w4,w9 + ldr w9,[sp,#8] + str w12,[sp,#4] + ror w16,w23,#6 + add w26,w26,w28 // h+=K[i] + ror w11,w6,#7 + and w17,w24,w23 + ror w10,w3,#17 + bic w28,w25,w23 + ror w12,w27,#2 + add w26,w26,w4 // h+=X[i] + eor w16,w16,w23,ror#11 + eor w11,w11,w6,ror#18 + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w27,w20 // a^b, b^c in next round + eor w16,w16,w23,ror#25 // Sigma1(e) + eor w12,w12,w27,ror#13 + add w26,w26,w17 // h+=Ch(e,f,g) + and w19,w19,w28 // (b^c)&=(a^b) + eor w10,w10,w3,ror#19 + eor w11,w11,w6,lsr#3 // sigma0(X[i+1]) + add w26,w26,w16 // h+=Sigma1(e) + eor w19,w19,w20 // Maj(a,b,c) + eor w17,w12,w27,ror#22 // Sigma0(a) + eor w10,w10,w3,lsr#10 // sigma1(X[i+14]) + add w5,w5,w14 + add w22,w22,w26 // d+=h + add w26,w26,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + add w5,w5,w11 + add w26,w26,w17 // h+=Sigma0(a) + add w5,w5,w10 + ldr w10,[sp,#12] + str w13,[sp,#8] + ror w16,w22,#6 + add w25,w25,w19 // h+=K[i] + ror w12,w7,#7 + and w17,w23,w22 + ror w11,w4,#17 + bic w19,w24,w22 + ror w13,w26,#2 + add w25,w25,w5 // h+=X[i] + eor w16,w16,w22,ror#11 + eor w12,w12,w7,ror#18 + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w26,w27 // a^b, b^c in next round + eor w16,w16,w22,ror#25 // Sigma1(e) + eor w13,w13,w26,ror#13 + add w25,w25,w17 // h+=Ch(e,f,g) + and w28,w28,w19 // (b^c)&=(a^b) + eor w11,w11,w4,ror#19 + eor w12,w12,w7,lsr#3 // sigma0(X[i+1]) + add w25,w25,w16 // h+=Sigma1(e) + eor w28,w28,w27 // Maj(a,b,c) + eor w17,w13,w26,ror#22 // Sigma0(a) + eor w11,w11,w4,lsr#10 // sigma1(X[i+14]) + add w6,w6,w15 + add w21,w21,w25 // d+=h + add w25,w25,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + add w6,w6,w12 + add w25,w25,w17 // h+=Sigma0(a) + add w6,w6,w11 + ldr w11,[sp,#0] + str w14,[sp,#12] + ror w16,w21,#6 + add w24,w24,w28 // h+=K[i] + ror w13,w8,#7 + and w17,w22,w21 + ror w12,w5,#17 + bic w28,w23,w21 + ror w14,w25,#2 + add w24,w24,w6 // h+=X[i] + eor w16,w16,w21,ror#11 + eor w13,w13,w8,ror#18 + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w25,w26 // a^b, b^c in next round + eor w16,w16,w21,ror#25 // Sigma1(e) + eor w14,w14,w25,ror#13 + add w24,w24,w17 // h+=Ch(e,f,g) + and w19,w19,w28 // (b^c)&=(a^b) + eor w12,w12,w5,ror#19 + eor w13,w13,w8,lsr#3 // sigma0(X[i+1]) + add w24,w24,w16 // h+=Sigma1(e) + eor w19,w19,w26 // Maj(a,b,c) + eor w17,w14,w25,ror#22 // Sigma0(a) + eor w12,w12,w5,lsr#10 // sigma1(X[i+14]) + add w7,w7,w0 + add w20,w20,w24 // d+=h + add w24,w24,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + add w7,w7,w13 + add w24,w24,w17 // h+=Sigma0(a) + add w7,w7,w12 + ldr w12,[sp,#4] + str w15,[sp,#0] + ror w16,w20,#6 + add w23,w23,w19 // h+=K[i] + ror w14,w9,#7 + and w17,w21,w20 + ror w13,w6,#17 + bic w19,w22,w20 + ror w15,w24,#2 + add w23,w23,w7 // h+=X[i] + eor w16,w16,w20,ror#11 + eor w14,w14,w9,ror#18 + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w24,w25 // a^b, b^c in next round + eor w16,w16,w20,ror#25 // Sigma1(e) + eor w15,w15,w24,ror#13 + add w23,w23,w17 // h+=Ch(e,f,g) + and w28,w28,w19 // (b^c)&=(a^b) + eor w13,w13,w6,ror#19 + eor w14,w14,w9,lsr#3 // sigma0(X[i+1]) + add w23,w23,w16 // h+=Sigma1(e) + eor w28,w28,w25 // Maj(a,b,c) + eor w17,w15,w24,ror#22 // Sigma0(a) + eor w13,w13,w6,lsr#10 // sigma1(X[i+14]) + add w8,w8,w1 + add w27,w27,w23 // d+=h + add w23,w23,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + add w8,w8,w14 + add w23,w23,w17 // h+=Sigma0(a) + add w8,w8,w13 + ldr w13,[sp,#8] + str w0,[sp,#4] + ror w16,w27,#6 + add w22,w22,w28 // h+=K[i] + ror w15,w10,#7 + and w17,w20,w27 + ror w14,w7,#17 + bic w28,w21,w27 + ror w0,w23,#2 + add w22,w22,w8 // h+=X[i] + eor w16,w16,w27,ror#11 + eor w15,w15,w10,ror#18 + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w23,w24 // a^b, b^c in next round + eor w16,w16,w27,ror#25 // Sigma1(e) + eor w0,w0,w23,ror#13 + add w22,w22,w17 // h+=Ch(e,f,g) + and w19,w19,w28 // (b^c)&=(a^b) + eor w14,w14,w7,ror#19 + eor w15,w15,w10,lsr#3 // sigma0(X[i+1]) + add w22,w22,w16 // h+=Sigma1(e) + eor w19,w19,w24 // Maj(a,b,c) + eor w17,w0,w23,ror#22 // Sigma0(a) + eor w14,w14,w7,lsr#10 // sigma1(X[i+14]) + add w9,w9,w2 + add w26,w26,w22 // d+=h + add w22,w22,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + add w9,w9,w15 + add w22,w22,w17 // h+=Sigma0(a) + add w9,w9,w14 + ldr w14,[sp,#12] + str w1,[sp,#8] + ror w16,w26,#6 + add w21,w21,w19 // h+=K[i] + ror w0,w11,#7 + and w17,w27,w26 + ror w15,w8,#17 + bic w19,w20,w26 + ror w1,w22,#2 + add w21,w21,w9 // h+=X[i] + eor w16,w16,w26,ror#11 + eor w0,w0,w11,ror#18 + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w22,w23 // a^b, b^c in next round + eor w16,w16,w26,ror#25 // Sigma1(e) + eor w1,w1,w22,ror#13 + add w21,w21,w17 // h+=Ch(e,f,g) + and w28,w28,w19 // (b^c)&=(a^b) + eor w15,w15,w8,ror#19 + eor w0,w0,w11,lsr#3 // sigma0(X[i+1]) + add w21,w21,w16 // h+=Sigma1(e) + eor w28,w28,w23 // Maj(a,b,c) + eor w17,w1,w22,ror#22 // Sigma0(a) + eor w15,w15,w8,lsr#10 // sigma1(X[i+14]) + add w10,w10,w3 + add w25,w25,w21 // d+=h + add w21,w21,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + add w10,w10,w0 + add w21,w21,w17 // h+=Sigma0(a) + add w10,w10,w15 + ldr w15,[sp,#0] + str w2,[sp,#12] + ror w16,w25,#6 + add w20,w20,w28 // h+=K[i] + ror w1,w12,#7 + and w17,w26,w25 + ror w0,w9,#17 + bic w28,w27,w25 + ror w2,w21,#2 + add w20,w20,w10 // h+=X[i] + eor w16,w16,w25,ror#11 + eor w1,w1,w12,ror#18 + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w21,w22 // a^b, b^c in next round + eor w16,w16,w25,ror#25 // Sigma1(e) + eor w2,w2,w21,ror#13 + add w20,w20,w17 // h+=Ch(e,f,g) + and w19,w19,w28 // (b^c)&=(a^b) + eor w0,w0,w9,ror#19 + eor w1,w1,w12,lsr#3 // sigma0(X[i+1]) + add w20,w20,w16 // h+=Sigma1(e) + eor w19,w19,w22 // Maj(a,b,c) + eor w17,w2,w21,ror#22 // Sigma0(a) + eor w0,w0,w9,lsr#10 // sigma1(X[i+14]) + add w11,w11,w4 + add w24,w24,w20 // d+=h + add w20,w20,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + add w11,w11,w1 + add w20,w20,w17 // h+=Sigma0(a) + add w11,w11,w0 + ldr w0,[sp,#4] + str w3,[sp,#0] + ror w16,w24,#6 + add w27,w27,w19 // h+=K[i] + ror w2,w13,#7 + and w17,w25,w24 + ror w1,w10,#17 + bic w19,w26,w24 + ror w3,w20,#2 + add w27,w27,w11 // h+=X[i] + eor w16,w16,w24,ror#11 + eor w2,w2,w13,ror#18 + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w20,w21 // a^b, b^c in next round + eor w16,w16,w24,ror#25 // Sigma1(e) + eor w3,w3,w20,ror#13 + add w27,w27,w17 // h+=Ch(e,f,g) + and w28,w28,w19 // (b^c)&=(a^b) + eor w1,w1,w10,ror#19 + eor w2,w2,w13,lsr#3 // sigma0(X[i+1]) + add w27,w27,w16 // h+=Sigma1(e) + eor w28,w28,w21 // Maj(a,b,c) + eor w17,w3,w20,ror#22 // Sigma0(a) + eor w1,w1,w10,lsr#10 // sigma1(X[i+14]) + add w12,w12,w5 + add w23,w23,w27 // d+=h + add w27,w27,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + add w12,w12,w2 + add w27,w27,w17 // h+=Sigma0(a) + add w12,w12,w1 + ldr w1,[sp,#8] + str w4,[sp,#4] + ror w16,w23,#6 + add w26,w26,w28 // h+=K[i] + ror w3,w14,#7 + and w17,w24,w23 + ror w2,w11,#17 + bic w28,w25,w23 + ror w4,w27,#2 + add w26,w26,w12 // h+=X[i] + eor w16,w16,w23,ror#11 + eor w3,w3,w14,ror#18 + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w27,w20 // a^b, b^c in next round + eor w16,w16,w23,ror#25 // Sigma1(e) + eor w4,w4,w27,ror#13 + add w26,w26,w17 // h+=Ch(e,f,g) + and w19,w19,w28 // (b^c)&=(a^b) + eor w2,w2,w11,ror#19 + eor w3,w3,w14,lsr#3 // sigma0(X[i+1]) + add w26,w26,w16 // h+=Sigma1(e) + eor w19,w19,w20 // Maj(a,b,c) + eor w17,w4,w27,ror#22 // Sigma0(a) + eor w2,w2,w11,lsr#10 // sigma1(X[i+14]) + add w13,w13,w6 + add w22,w22,w26 // d+=h + add w26,w26,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + add w13,w13,w3 + add w26,w26,w17 // h+=Sigma0(a) + add w13,w13,w2 + ldr w2,[sp,#12] + str w5,[sp,#8] + ror w16,w22,#6 + add w25,w25,w19 // h+=K[i] + ror w4,w15,#7 + and w17,w23,w22 + ror w3,w12,#17 + bic w19,w24,w22 + ror w5,w26,#2 + add w25,w25,w13 // h+=X[i] + eor w16,w16,w22,ror#11 + eor w4,w4,w15,ror#18 + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w26,w27 // a^b, b^c in next round + eor w16,w16,w22,ror#25 // Sigma1(e) + eor w5,w5,w26,ror#13 + add w25,w25,w17 // h+=Ch(e,f,g) + and w28,w28,w19 // (b^c)&=(a^b) + eor w3,w3,w12,ror#19 + eor w4,w4,w15,lsr#3 // sigma0(X[i+1]) + add w25,w25,w16 // h+=Sigma1(e) + eor w28,w28,w27 // Maj(a,b,c) + eor w17,w5,w26,ror#22 // Sigma0(a) + eor w3,w3,w12,lsr#10 // sigma1(X[i+14]) + add w14,w14,w7 + add w21,w21,w25 // d+=h + add w25,w25,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + add w14,w14,w4 + add w25,w25,w17 // h+=Sigma0(a) + add w14,w14,w3 + ldr w3,[sp,#0] + str w6,[sp,#12] + ror w16,w21,#6 + add w24,w24,w28 // h+=K[i] + ror w5,w0,#7 + and w17,w22,w21 + ror w4,w13,#17 + bic w28,w23,w21 + ror w6,w25,#2 + add w24,w24,w14 // h+=X[i] + eor w16,w16,w21,ror#11 + eor w5,w5,w0,ror#18 + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w25,w26 // a^b, b^c in next round + eor w16,w16,w21,ror#25 // Sigma1(e) + eor w6,w6,w25,ror#13 + add w24,w24,w17 // h+=Ch(e,f,g) + and w19,w19,w28 // (b^c)&=(a^b) + eor w4,w4,w13,ror#19 + eor w5,w5,w0,lsr#3 // sigma0(X[i+1]) + add w24,w24,w16 // h+=Sigma1(e) + eor w19,w19,w26 // Maj(a,b,c) + eor w17,w6,w25,ror#22 // Sigma0(a) + eor w4,w4,w13,lsr#10 // sigma1(X[i+14]) + add w15,w15,w8 + add w20,w20,w24 // d+=h + add w24,w24,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + add w15,w15,w5 + add w24,w24,w17 // h+=Sigma0(a) + add w15,w15,w4 + ldr w4,[sp,#4] + str w7,[sp,#0] + ror w16,w20,#6 + add w23,w23,w19 // h+=K[i] + ror w6,w1,#7 + and w17,w21,w20 + ror w5,w14,#17 + bic w19,w22,w20 + ror w7,w24,#2 + add w23,w23,w15 // h+=X[i] + eor w16,w16,w20,ror#11 + eor w6,w6,w1,ror#18 + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w24,w25 // a^b, b^c in next round + eor w16,w16,w20,ror#25 // Sigma1(e) + eor w7,w7,w24,ror#13 + add w23,w23,w17 // h+=Ch(e,f,g) + and w28,w28,w19 // (b^c)&=(a^b) + eor w5,w5,w14,ror#19 + eor w6,w6,w1,lsr#3 // sigma0(X[i+1]) + add w23,w23,w16 // h+=Sigma1(e) + eor w28,w28,w25 // Maj(a,b,c) + eor w17,w7,w24,ror#22 // Sigma0(a) + eor w5,w5,w14,lsr#10 // sigma1(X[i+14]) + add w0,w0,w9 + add w27,w27,w23 // d+=h + add w23,w23,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + add w0,w0,w6 + add w23,w23,w17 // h+=Sigma0(a) + add w0,w0,w5 + ldr w5,[sp,#8] + str w8,[sp,#4] + ror w16,w27,#6 + add w22,w22,w28 // h+=K[i] + ror w7,w2,#7 + and w17,w20,w27 + ror w6,w15,#17 + bic w28,w21,w27 + ror w8,w23,#2 + add w22,w22,w0 // h+=X[i] + eor w16,w16,w27,ror#11 + eor w7,w7,w2,ror#18 + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w23,w24 // a^b, b^c in next round + eor w16,w16,w27,ror#25 // Sigma1(e) + eor w8,w8,w23,ror#13 + add w22,w22,w17 // h+=Ch(e,f,g) + and w19,w19,w28 // (b^c)&=(a^b) + eor w6,w6,w15,ror#19 + eor w7,w7,w2,lsr#3 // sigma0(X[i+1]) + add w22,w22,w16 // h+=Sigma1(e) + eor w19,w19,w24 // Maj(a,b,c) + eor w17,w8,w23,ror#22 // Sigma0(a) + eor w6,w6,w15,lsr#10 // sigma1(X[i+14]) + add w1,w1,w10 + add w26,w26,w22 // d+=h + add w22,w22,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + add w1,w1,w7 + add w22,w22,w17 // h+=Sigma0(a) + add w1,w1,w6 + ldr w6,[sp,#12] + str w9,[sp,#8] + ror w16,w26,#6 + add w21,w21,w19 // h+=K[i] + ror w8,w3,#7 + and w17,w27,w26 + ror w7,w0,#17 + bic w19,w20,w26 + ror w9,w22,#2 + add w21,w21,w1 // h+=X[i] + eor w16,w16,w26,ror#11 + eor w8,w8,w3,ror#18 + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w22,w23 // a^b, b^c in next round + eor w16,w16,w26,ror#25 // Sigma1(e) + eor w9,w9,w22,ror#13 + add w21,w21,w17 // h+=Ch(e,f,g) + and w28,w28,w19 // (b^c)&=(a^b) + eor w7,w7,w0,ror#19 + eor w8,w8,w3,lsr#3 // sigma0(X[i+1]) + add w21,w21,w16 // h+=Sigma1(e) + eor w28,w28,w23 // Maj(a,b,c) + eor w17,w9,w22,ror#22 // Sigma0(a) + eor w7,w7,w0,lsr#10 // sigma1(X[i+14]) + add w2,w2,w11 + add w25,w25,w21 // d+=h + add w21,w21,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + add w2,w2,w8 + add w21,w21,w17 // h+=Sigma0(a) + add w2,w2,w7 + ldr w7,[sp,#0] + str w10,[sp,#12] + ror w16,w25,#6 + add w20,w20,w28 // h+=K[i] + ror w9,w4,#7 + and w17,w26,w25 + ror w8,w1,#17 + bic w28,w27,w25 + ror w10,w21,#2 + add w20,w20,w2 // h+=X[i] + eor w16,w16,w25,ror#11 + eor w9,w9,w4,ror#18 + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w21,w22 // a^b, b^c in next round + eor w16,w16,w25,ror#25 // Sigma1(e) + eor w10,w10,w21,ror#13 + add w20,w20,w17 // h+=Ch(e,f,g) + and w19,w19,w28 // (b^c)&=(a^b) + eor w8,w8,w1,ror#19 + eor w9,w9,w4,lsr#3 // sigma0(X[i+1]) + add w20,w20,w16 // h+=Sigma1(e) + eor w19,w19,w22 // Maj(a,b,c) + eor w17,w10,w21,ror#22 // Sigma0(a) + eor w8,w8,w1,lsr#10 // sigma1(X[i+14]) + add w3,w3,w12 + add w24,w24,w20 // d+=h + add w20,w20,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + add w3,w3,w9 + add w20,w20,w17 // h+=Sigma0(a) + add w3,w3,w8 + cbnz w19,Loop_16_xx + + ldp x0,x2,[x29,#96] + ldr x1,[x29,#112] + sub x30,x30,#260 // rewind + + ldp w3,w4,[x0] + ldp w5,w6,[x0,#2*4] + add x1,x1,#14*4 // advance input pointer + ldp w7,w8,[x0,#4*4] + add w20,w20,w3 + ldp w9,w10,[x0,#6*4] + add w21,w21,w4 + add w22,w22,w5 + add w23,w23,w6 + stp w20,w21,[x0] + add w24,w24,w7 + add w25,w25,w8 + stp w22,w23,[x0,#2*4] + add w26,w26,w9 + add w27,w27,w10 + cmp x1,x2 + stp w24,w25,[x0,#4*4] + stp w26,w27,[x0,#6*4] + b.ne Loop + + ldp x19,x20,[x29,#16] + add sp,sp,#4*4 + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldp x29,x30,[sp],#128 + AARCH64_VALIDATE_LINK_REGISTER + ret + + +.section __TEXT,__const +.align 6 + +LK256: +.long 0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5 +.long 0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5 +.long 0xd807aa98,0x12835b01,0x243185be,0x550c7dc3 +.long 0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174 +.long 0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc +.long 0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da +.long 0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7 +.long 0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967 +.long 0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13 +.long 0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85 +.long 0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3 +.long 0xd192e819,0xd6990624,0xf40e3585,0x106aa070 +.long 0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5 +.long 0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3 +.long 0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208 +.long 0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2 +.long 0 //terminator + +.byte 83,72,65,50,53,54,32,98,108,111,99,107,32,116,114,97,110,115,102,111,114,109,32,102,111,114,32,65,82,77,118,56,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.align 2 +.align 2 +.text +#ifndef __KERNEL__ +.globl _sha256_block_data_order_hw +.private_extern _sha256_block_data_order_hw + +.align 6 +_sha256_block_data_order_hw: + // Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later. + AARCH64_VALID_CALL_TARGET + stp x29,x30,[sp,#-16]! + add x29,sp,#0 + + ld1 {v0.4s,v1.4s},[x0] + adrp x3,LK256@PAGE + add x3,x3,LK256@PAGEOFF + +Loop_hw: + ld1 {v4.16b,v5.16b,v6.16b,v7.16b},[x1],#64 + sub x2,x2,#1 + ld1 {v16.4s},[x3],#16 + rev32 v4.16b,v4.16b + rev32 v5.16b,v5.16b + rev32 v6.16b,v6.16b + rev32 v7.16b,v7.16b + orr v18.16b,v0.16b,v0.16b // offload + orr v19.16b,v1.16b,v1.16b + ld1 {v17.4s},[x3],#16 + add v16.4s,v16.4s,v4.4s +.long 0x5e2828a4 //sha256su0 v4.16b,v5.16b + orr v2.16b,v0.16b,v0.16b +.long 0x5e104020 //sha256h v0.16b,v1.16b,v16.4s +.long 0x5e105041 //sha256h2 v1.16b,v2.16b,v16.4s +.long 0x5e0760c4 //sha256su1 v4.16b,v6.16b,v7.16b + ld1 {v16.4s},[x3],#16 + add v17.4s,v17.4s,v5.4s +.long 0x5e2828c5 //sha256su0 v5.16b,v6.16b + orr v2.16b,v0.16b,v0.16b +.long 0x5e114020 //sha256h v0.16b,v1.16b,v17.4s +.long 0x5e115041 //sha256h2 v1.16b,v2.16b,v17.4s +.long 0x5e0460e5 //sha256su1 v5.16b,v7.16b,v4.16b + ld1 {v17.4s},[x3],#16 + add v16.4s,v16.4s,v6.4s +.long 0x5e2828e6 //sha256su0 v6.16b,v7.16b + orr v2.16b,v0.16b,v0.16b +.long 0x5e104020 //sha256h v0.16b,v1.16b,v16.4s +.long 0x5e105041 //sha256h2 v1.16b,v2.16b,v16.4s +.long 0x5e056086 //sha256su1 v6.16b,v4.16b,v5.16b + ld1 {v16.4s},[x3],#16 + add v17.4s,v17.4s,v7.4s +.long 0x5e282887 //sha256su0 v7.16b,v4.16b + orr v2.16b,v0.16b,v0.16b +.long 0x5e114020 //sha256h v0.16b,v1.16b,v17.4s +.long 0x5e115041 //sha256h2 v1.16b,v2.16b,v17.4s +.long 0x5e0660a7 //sha256su1 v7.16b,v5.16b,v6.16b + ld1 {v17.4s},[x3],#16 + add v16.4s,v16.4s,v4.4s +.long 0x5e2828a4 //sha256su0 v4.16b,v5.16b + orr v2.16b,v0.16b,v0.16b +.long 0x5e104020 //sha256h v0.16b,v1.16b,v16.4s +.long 0x5e105041 //sha256h2 v1.16b,v2.16b,v16.4s +.long 0x5e0760c4 //sha256su1 v4.16b,v6.16b,v7.16b + ld1 {v16.4s},[x3],#16 + add v17.4s,v17.4s,v5.4s +.long 0x5e2828c5 //sha256su0 v5.16b,v6.16b + orr v2.16b,v0.16b,v0.16b +.long 0x5e114020 //sha256h v0.16b,v1.16b,v17.4s +.long 0x5e115041 //sha256h2 v1.16b,v2.16b,v17.4s +.long 0x5e0460e5 //sha256su1 v5.16b,v7.16b,v4.16b + ld1 {v17.4s},[x3],#16 + add v16.4s,v16.4s,v6.4s +.long 0x5e2828e6 //sha256su0 v6.16b,v7.16b + orr v2.16b,v0.16b,v0.16b +.long 0x5e104020 //sha256h v0.16b,v1.16b,v16.4s +.long 0x5e105041 //sha256h2 v1.16b,v2.16b,v16.4s +.long 0x5e056086 //sha256su1 v6.16b,v4.16b,v5.16b + ld1 {v16.4s},[x3],#16 + add v17.4s,v17.4s,v7.4s +.long 0x5e282887 //sha256su0 v7.16b,v4.16b + orr v2.16b,v0.16b,v0.16b +.long 0x5e114020 //sha256h v0.16b,v1.16b,v17.4s +.long 0x5e115041 //sha256h2 v1.16b,v2.16b,v17.4s +.long 0x5e0660a7 //sha256su1 v7.16b,v5.16b,v6.16b + ld1 {v17.4s},[x3],#16 + add v16.4s,v16.4s,v4.4s +.long 0x5e2828a4 //sha256su0 v4.16b,v5.16b + orr v2.16b,v0.16b,v0.16b +.long 0x5e104020 //sha256h v0.16b,v1.16b,v16.4s +.long 0x5e105041 //sha256h2 v1.16b,v2.16b,v16.4s +.long 0x5e0760c4 //sha256su1 v4.16b,v6.16b,v7.16b + ld1 {v16.4s},[x3],#16 + add v17.4s,v17.4s,v5.4s +.long 0x5e2828c5 //sha256su0 v5.16b,v6.16b + orr v2.16b,v0.16b,v0.16b +.long 0x5e114020 //sha256h v0.16b,v1.16b,v17.4s +.long 0x5e115041 //sha256h2 v1.16b,v2.16b,v17.4s +.long 0x5e0460e5 //sha256su1 v5.16b,v7.16b,v4.16b + ld1 {v17.4s},[x3],#16 + add v16.4s,v16.4s,v6.4s +.long 0x5e2828e6 //sha256su0 v6.16b,v7.16b + orr v2.16b,v0.16b,v0.16b +.long 0x5e104020 //sha256h v0.16b,v1.16b,v16.4s +.long 0x5e105041 //sha256h2 v1.16b,v2.16b,v16.4s +.long 0x5e056086 //sha256su1 v6.16b,v4.16b,v5.16b + ld1 {v16.4s},[x3],#16 + add v17.4s,v17.4s,v7.4s +.long 0x5e282887 //sha256su0 v7.16b,v4.16b + orr v2.16b,v0.16b,v0.16b +.long 0x5e114020 //sha256h v0.16b,v1.16b,v17.4s +.long 0x5e115041 //sha256h2 v1.16b,v2.16b,v17.4s +.long 0x5e0660a7 //sha256su1 v7.16b,v5.16b,v6.16b + ld1 {v17.4s},[x3],#16 + add v16.4s,v16.4s,v4.4s + orr v2.16b,v0.16b,v0.16b +.long 0x5e104020 //sha256h v0.16b,v1.16b,v16.4s +.long 0x5e105041 //sha256h2 v1.16b,v2.16b,v16.4s + + ld1 {v16.4s},[x3],#16 + add v17.4s,v17.4s,v5.4s + orr v2.16b,v0.16b,v0.16b +.long 0x5e114020 //sha256h v0.16b,v1.16b,v17.4s +.long 0x5e115041 //sha256h2 v1.16b,v2.16b,v17.4s + + ld1 {v17.4s},[x3] + add v16.4s,v16.4s,v6.4s + sub x3,x3,#64*4-16 // rewind + orr v2.16b,v0.16b,v0.16b +.long 0x5e104020 //sha256h v0.16b,v1.16b,v16.4s +.long 0x5e105041 //sha256h2 v1.16b,v2.16b,v16.4s + + add v17.4s,v17.4s,v7.4s + orr v2.16b,v0.16b,v0.16b +.long 0x5e114020 //sha256h v0.16b,v1.16b,v17.4s +.long 0x5e115041 //sha256h2 v1.16b,v2.16b,v17.4s + + add v0.4s,v0.4s,v18.4s + add v1.4s,v1.4s,v19.4s + + cbnz x2,Loop_hw + + st1 {v0.4s,v1.4s},[x0] + + ldr x29,[sp],#16 + ret + +#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__APPLE__) diff --git a/http/vendor/ring/pregenerated/sha256-armv8-linux64.S b/http/vendor/ring/pregenerated/sha256-armv8-linux64.S new file mode 100644 index 0000000..94c0682 --- /dev/null +++ b/http/vendor/ring/pregenerated/sha256-armv8-linux64.S @@ -0,0 +1,1195 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__ELF__) +// Copyright 2014-2020 The OpenSSL Project Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// ==================================================================== +// Written by Andy Polyakov for the OpenSSL +// project. +// ==================================================================== +// +// SHA256/512 for ARMv8. +// +// Performance in cycles per processed byte and improvement coefficient +// over code generated with "default" compiler: +// +// SHA256-hw SHA256(*) SHA512 +// Apple A7 1.97 10.5 (+33%) 6.73 (-1%(**)) +// Cortex-A53 2.38 15.5 (+115%) 10.0 (+150%(***)) +// Cortex-A57 2.31 11.6 (+86%) 7.51 (+260%(***)) +// Denver 2.01 10.5 (+26%) 6.70 (+8%) +// X-Gene 20.0 (+100%) 12.8 (+300%(***)) +// Mongoose 2.36 13.0 (+50%) 8.36 (+33%) +// Kryo 1.92 17.4 (+30%) 11.2 (+8%) +// +// (*) Software SHA256 results are of lesser relevance, presented +// mostly for informational purposes. +// (**) The result is a trade-off: it's possible to improve it by +// 10% (or by 1 cycle per round), but at the cost of 20% loss +// on Cortex-A53 (or by 4 cycles per round). +// (***) Super-impressive coefficients over gcc-generated code are +// indication of some compiler "pathology", most notably code +// generated with -mgeneral-regs-only is significantly faster +// and the gap is only 40-90%. + +#ifndef __KERNEL__ +#endif + +.text + +.globl sha256_block_data_order_nohw +.hidden sha256_block_data_order_nohw +.type sha256_block_data_order_nohw,%function +.align 6 +sha256_block_data_order_nohw: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-128]! + add x29,sp,#0 + + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + stp x27,x28,[sp,#80] + sub sp,sp,#4*4 + + ldp w20,w21,[x0] // load context + ldp w22,w23,[x0,#2*4] + ldp w24,w25,[x0,#4*4] + add x2,x1,x2,lsl#6 // end of input + ldp w26,w27,[x0,#6*4] + adrp x30,.LK256 + add x30,x30,:lo12:.LK256 + stp x0,x2,[x29,#96] + +.Loop: + ldp w3,w4,[x1],#2*4 + ldr w19,[x30],#4 // *K++ + eor w28,w21,w22 // magic seed + str x1,[x29,#112] +#ifndef __AARCH64EB__ + rev w3,w3 // 0 +#endif + ror w16,w24,#6 + add w27,w27,w19 // h+=K[i] + eor w6,w24,w24,ror#14 + and w17,w25,w24 + bic w19,w26,w24 + add w27,w27,w3 // h+=X[i] + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w20,w21 // a^b, b^c in next round + eor w16,w16,w6,ror#11 // Sigma1(e) + ror w6,w20,#2 + add w27,w27,w17 // h+=Ch(e,f,g) + eor w17,w20,w20,ror#9 + add w27,w27,w16 // h+=Sigma1(e) + and w28,w28,w19 // (b^c)&=(a^b) + add w23,w23,w27 // d+=h + eor w28,w28,w21 // Maj(a,b,c) + eor w17,w6,w17,ror#13 // Sigma0(a) + add w27,w27,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + //add w27,w27,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w4,w4 // 1 +#endif + ldp w5,w6,[x1],#2*4 + add w27,w27,w17 // h+=Sigma0(a) + ror w16,w23,#6 + add w26,w26,w28 // h+=K[i] + eor w7,w23,w23,ror#14 + and w17,w24,w23 + bic w28,w25,w23 + add w26,w26,w4 // h+=X[i] + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w27,w20 // a^b, b^c in next round + eor w16,w16,w7,ror#11 // Sigma1(e) + ror w7,w27,#2 + add w26,w26,w17 // h+=Ch(e,f,g) + eor w17,w27,w27,ror#9 + add w26,w26,w16 // h+=Sigma1(e) + and w19,w19,w28 // (b^c)&=(a^b) + add w22,w22,w26 // d+=h + eor w19,w19,w20 // Maj(a,b,c) + eor w17,w7,w17,ror#13 // Sigma0(a) + add w26,w26,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + //add w26,w26,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w5,w5 // 2 +#endif + add w26,w26,w17 // h+=Sigma0(a) + ror w16,w22,#6 + add w25,w25,w19 // h+=K[i] + eor w8,w22,w22,ror#14 + and w17,w23,w22 + bic w19,w24,w22 + add w25,w25,w5 // h+=X[i] + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w26,w27 // a^b, b^c in next round + eor w16,w16,w8,ror#11 // Sigma1(e) + ror w8,w26,#2 + add w25,w25,w17 // h+=Ch(e,f,g) + eor w17,w26,w26,ror#9 + add w25,w25,w16 // h+=Sigma1(e) + and w28,w28,w19 // (b^c)&=(a^b) + add w21,w21,w25 // d+=h + eor w28,w28,w27 // Maj(a,b,c) + eor w17,w8,w17,ror#13 // Sigma0(a) + add w25,w25,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + //add w25,w25,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w6,w6 // 3 +#endif + ldp w7,w8,[x1],#2*4 + add w25,w25,w17 // h+=Sigma0(a) + ror w16,w21,#6 + add w24,w24,w28 // h+=K[i] + eor w9,w21,w21,ror#14 + and w17,w22,w21 + bic w28,w23,w21 + add w24,w24,w6 // h+=X[i] + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w25,w26 // a^b, b^c in next round + eor w16,w16,w9,ror#11 // Sigma1(e) + ror w9,w25,#2 + add w24,w24,w17 // h+=Ch(e,f,g) + eor w17,w25,w25,ror#9 + add w24,w24,w16 // h+=Sigma1(e) + and w19,w19,w28 // (b^c)&=(a^b) + add w20,w20,w24 // d+=h + eor w19,w19,w26 // Maj(a,b,c) + eor w17,w9,w17,ror#13 // Sigma0(a) + add w24,w24,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + //add w24,w24,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w7,w7 // 4 +#endif + add w24,w24,w17 // h+=Sigma0(a) + ror w16,w20,#6 + add w23,w23,w19 // h+=K[i] + eor w10,w20,w20,ror#14 + and w17,w21,w20 + bic w19,w22,w20 + add w23,w23,w7 // h+=X[i] + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w24,w25 // a^b, b^c in next round + eor w16,w16,w10,ror#11 // Sigma1(e) + ror w10,w24,#2 + add w23,w23,w17 // h+=Ch(e,f,g) + eor w17,w24,w24,ror#9 + add w23,w23,w16 // h+=Sigma1(e) + and w28,w28,w19 // (b^c)&=(a^b) + add w27,w27,w23 // d+=h + eor w28,w28,w25 // Maj(a,b,c) + eor w17,w10,w17,ror#13 // Sigma0(a) + add w23,w23,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + //add w23,w23,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w8,w8 // 5 +#endif + ldp w9,w10,[x1],#2*4 + add w23,w23,w17 // h+=Sigma0(a) + ror w16,w27,#6 + add w22,w22,w28 // h+=K[i] + eor w11,w27,w27,ror#14 + and w17,w20,w27 + bic w28,w21,w27 + add w22,w22,w8 // h+=X[i] + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w23,w24 // a^b, b^c in next round + eor w16,w16,w11,ror#11 // Sigma1(e) + ror w11,w23,#2 + add w22,w22,w17 // h+=Ch(e,f,g) + eor w17,w23,w23,ror#9 + add w22,w22,w16 // h+=Sigma1(e) + and w19,w19,w28 // (b^c)&=(a^b) + add w26,w26,w22 // d+=h + eor w19,w19,w24 // Maj(a,b,c) + eor w17,w11,w17,ror#13 // Sigma0(a) + add w22,w22,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + //add w22,w22,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w9,w9 // 6 +#endif + add w22,w22,w17 // h+=Sigma0(a) + ror w16,w26,#6 + add w21,w21,w19 // h+=K[i] + eor w12,w26,w26,ror#14 + and w17,w27,w26 + bic w19,w20,w26 + add w21,w21,w9 // h+=X[i] + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w22,w23 // a^b, b^c in next round + eor w16,w16,w12,ror#11 // Sigma1(e) + ror w12,w22,#2 + add w21,w21,w17 // h+=Ch(e,f,g) + eor w17,w22,w22,ror#9 + add w21,w21,w16 // h+=Sigma1(e) + and w28,w28,w19 // (b^c)&=(a^b) + add w25,w25,w21 // d+=h + eor w28,w28,w23 // Maj(a,b,c) + eor w17,w12,w17,ror#13 // Sigma0(a) + add w21,w21,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + //add w21,w21,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w10,w10 // 7 +#endif + ldp w11,w12,[x1],#2*4 + add w21,w21,w17 // h+=Sigma0(a) + ror w16,w25,#6 + add w20,w20,w28 // h+=K[i] + eor w13,w25,w25,ror#14 + and w17,w26,w25 + bic w28,w27,w25 + add w20,w20,w10 // h+=X[i] + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w21,w22 // a^b, b^c in next round + eor w16,w16,w13,ror#11 // Sigma1(e) + ror w13,w21,#2 + add w20,w20,w17 // h+=Ch(e,f,g) + eor w17,w21,w21,ror#9 + add w20,w20,w16 // h+=Sigma1(e) + and w19,w19,w28 // (b^c)&=(a^b) + add w24,w24,w20 // d+=h + eor w19,w19,w22 // Maj(a,b,c) + eor w17,w13,w17,ror#13 // Sigma0(a) + add w20,w20,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + //add w20,w20,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w11,w11 // 8 +#endif + add w20,w20,w17 // h+=Sigma0(a) + ror w16,w24,#6 + add w27,w27,w19 // h+=K[i] + eor w14,w24,w24,ror#14 + and w17,w25,w24 + bic w19,w26,w24 + add w27,w27,w11 // h+=X[i] + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w20,w21 // a^b, b^c in next round + eor w16,w16,w14,ror#11 // Sigma1(e) + ror w14,w20,#2 + add w27,w27,w17 // h+=Ch(e,f,g) + eor w17,w20,w20,ror#9 + add w27,w27,w16 // h+=Sigma1(e) + and w28,w28,w19 // (b^c)&=(a^b) + add w23,w23,w27 // d+=h + eor w28,w28,w21 // Maj(a,b,c) + eor w17,w14,w17,ror#13 // Sigma0(a) + add w27,w27,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + //add w27,w27,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w12,w12 // 9 +#endif + ldp w13,w14,[x1],#2*4 + add w27,w27,w17 // h+=Sigma0(a) + ror w16,w23,#6 + add w26,w26,w28 // h+=K[i] + eor w15,w23,w23,ror#14 + and w17,w24,w23 + bic w28,w25,w23 + add w26,w26,w12 // h+=X[i] + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w27,w20 // a^b, b^c in next round + eor w16,w16,w15,ror#11 // Sigma1(e) + ror w15,w27,#2 + add w26,w26,w17 // h+=Ch(e,f,g) + eor w17,w27,w27,ror#9 + add w26,w26,w16 // h+=Sigma1(e) + and w19,w19,w28 // (b^c)&=(a^b) + add w22,w22,w26 // d+=h + eor w19,w19,w20 // Maj(a,b,c) + eor w17,w15,w17,ror#13 // Sigma0(a) + add w26,w26,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + //add w26,w26,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w13,w13 // 10 +#endif + add w26,w26,w17 // h+=Sigma0(a) + ror w16,w22,#6 + add w25,w25,w19 // h+=K[i] + eor w0,w22,w22,ror#14 + and w17,w23,w22 + bic w19,w24,w22 + add w25,w25,w13 // h+=X[i] + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w26,w27 // a^b, b^c in next round + eor w16,w16,w0,ror#11 // Sigma1(e) + ror w0,w26,#2 + add w25,w25,w17 // h+=Ch(e,f,g) + eor w17,w26,w26,ror#9 + add w25,w25,w16 // h+=Sigma1(e) + and w28,w28,w19 // (b^c)&=(a^b) + add w21,w21,w25 // d+=h + eor w28,w28,w27 // Maj(a,b,c) + eor w17,w0,w17,ror#13 // Sigma0(a) + add w25,w25,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + //add w25,w25,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w14,w14 // 11 +#endif + ldp w15,w0,[x1],#2*4 + add w25,w25,w17 // h+=Sigma0(a) + str w6,[sp,#12] + ror w16,w21,#6 + add w24,w24,w28 // h+=K[i] + eor w6,w21,w21,ror#14 + and w17,w22,w21 + bic w28,w23,w21 + add w24,w24,w14 // h+=X[i] + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w25,w26 // a^b, b^c in next round + eor w16,w16,w6,ror#11 // Sigma1(e) + ror w6,w25,#2 + add w24,w24,w17 // h+=Ch(e,f,g) + eor w17,w25,w25,ror#9 + add w24,w24,w16 // h+=Sigma1(e) + and w19,w19,w28 // (b^c)&=(a^b) + add w20,w20,w24 // d+=h + eor w19,w19,w26 // Maj(a,b,c) + eor w17,w6,w17,ror#13 // Sigma0(a) + add w24,w24,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + //add w24,w24,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w15,w15 // 12 +#endif + add w24,w24,w17 // h+=Sigma0(a) + str w7,[sp,#0] + ror w16,w20,#6 + add w23,w23,w19 // h+=K[i] + eor w7,w20,w20,ror#14 + and w17,w21,w20 + bic w19,w22,w20 + add w23,w23,w15 // h+=X[i] + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w24,w25 // a^b, b^c in next round + eor w16,w16,w7,ror#11 // Sigma1(e) + ror w7,w24,#2 + add w23,w23,w17 // h+=Ch(e,f,g) + eor w17,w24,w24,ror#9 + add w23,w23,w16 // h+=Sigma1(e) + and w28,w28,w19 // (b^c)&=(a^b) + add w27,w27,w23 // d+=h + eor w28,w28,w25 // Maj(a,b,c) + eor w17,w7,w17,ror#13 // Sigma0(a) + add w23,w23,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + //add w23,w23,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w0,w0 // 13 +#endif + ldp w1,w2,[x1] + add w23,w23,w17 // h+=Sigma0(a) + str w8,[sp,#4] + ror w16,w27,#6 + add w22,w22,w28 // h+=K[i] + eor w8,w27,w27,ror#14 + and w17,w20,w27 + bic w28,w21,w27 + add w22,w22,w0 // h+=X[i] + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w23,w24 // a^b, b^c in next round + eor w16,w16,w8,ror#11 // Sigma1(e) + ror w8,w23,#2 + add w22,w22,w17 // h+=Ch(e,f,g) + eor w17,w23,w23,ror#9 + add w22,w22,w16 // h+=Sigma1(e) + and w19,w19,w28 // (b^c)&=(a^b) + add w26,w26,w22 // d+=h + eor w19,w19,w24 // Maj(a,b,c) + eor w17,w8,w17,ror#13 // Sigma0(a) + add w22,w22,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + //add w22,w22,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w1,w1 // 14 +#endif + ldr w6,[sp,#12] + add w22,w22,w17 // h+=Sigma0(a) + str w9,[sp,#8] + ror w16,w26,#6 + add w21,w21,w19 // h+=K[i] + eor w9,w26,w26,ror#14 + and w17,w27,w26 + bic w19,w20,w26 + add w21,w21,w1 // h+=X[i] + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w22,w23 // a^b, b^c in next round + eor w16,w16,w9,ror#11 // Sigma1(e) + ror w9,w22,#2 + add w21,w21,w17 // h+=Ch(e,f,g) + eor w17,w22,w22,ror#9 + add w21,w21,w16 // h+=Sigma1(e) + and w28,w28,w19 // (b^c)&=(a^b) + add w25,w25,w21 // d+=h + eor w28,w28,w23 // Maj(a,b,c) + eor w17,w9,w17,ror#13 // Sigma0(a) + add w21,w21,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + //add w21,w21,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w2,w2 // 15 +#endif + ldr w7,[sp,#0] + add w21,w21,w17 // h+=Sigma0(a) + str w10,[sp,#12] + ror w16,w25,#6 + add w20,w20,w28 // h+=K[i] + ror w9,w4,#7 + and w17,w26,w25 + ror w8,w1,#17 + bic w28,w27,w25 + ror w10,w21,#2 + add w20,w20,w2 // h+=X[i] + eor w16,w16,w25,ror#11 + eor w9,w9,w4,ror#18 + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w21,w22 // a^b, b^c in next round + eor w16,w16,w25,ror#25 // Sigma1(e) + eor w10,w10,w21,ror#13 + add w20,w20,w17 // h+=Ch(e,f,g) + and w19,w19,w28 // (b^c)&=(a^b) + eor w8,w8,w1,ror#19 + eor w9,w9,w4,lsr#3 // sigma0(X[i+1]) + add w20,w20,w16 // h+=Sigma1(e) + eor w19,w19,w22 // Maj(a,b,c) + eor w17,w10,w21,ror#22 // Sigma0(a) + eor w8,w8,w1,lsr#10 // sigma1(X[i+14]) + add w3,w3,w12 + add w24,w24,w20 // d+=h + add w20,w20,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + add w3,w3,w9 + add w20,w20,w17 // h+=Sigma0(a) + add w3,w3,w8 +.Loop_16_xx: + ldr w8,[sp,#4] + str w11,[sp,#0] + ror w16,w24,#6 + add w27,w27,w19 // h+=K[i] + ror w10,w5,#7 + and w17,w25,w24 + ror w9,w2,#17 + bic w19,w26,w24 + ror w11,w20,#2 + add w27,w27,w3 // h+=X[i] + eor w16,w16,w24,ror#11 + eor w10,w10,w5,ror#18 + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w20,w21 // a^b, b^c in next round + eor w16,w16,w24,ror#25 // Sigma1(e) + eor w11,w11,w20,ror#13 + add w27,w27,w17 // h+=Ch(e,f,g) + and w28,w28,w19 // (b^c)&=(a^b) + eor w9,w9,w2,ror#19 + eor w10,w10,w5,lsr#3 // sigma0(X[i+1]) + add w27,w27,w16 // h+=Sigma1(e) + eor w28,w28,w21 // Maj(a,b,c) + eor w17,w11,w20,ror#22 // Sigma0(a) + eor w9,w9,w2,lsr#10 // sigma1(X[i+14]) + add w4,w4,w13 + add w23,w23,w27 // d+=h + add w27,w27,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + add w4,w4,w10 + add w27,w27,w17 // h+=Sigma0(a) + add w4,w4,w9 + ldr w9,[sp,#8] + str w12,[sp,#4] + ror w16,w23,#6 + add w26,w26,w28 // h+=K[i] + ror w11,w6,#7 + and w17,w24,w23 + ror w10,w3,#17 + bic w28,w25,w23 + ror w12,w27,#2 + add w26,w26,w4 // h+=X[i] + eor w16,w16,w23,ror#11 + eor w11,w11,w6,ror#18 + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w27,w20 // a^b, b^c in next round + eor w16,w16,w23,ror#25 // Sigma1(e) + eor w12,w12,w27,ror#13 + add w26,w26,w17 // h+=Ch(e,f,g) + and w19,w19,w28 // (b^c)&=(a^b) + eor w10,w10,w3,ror#19 + eor w11,w11,w6,lsr#3 // sigma0(X[i+1]) + add w26,w26,w16 // h+=Sigma1(e) + eor w19,w19,w20 // Maj(a,b,c) + eor w17,w12,w27,ror#22 // Sigma0(a) + eor w10,w10,w3,lsr#10 // sigma1(X[i+14]) + add w5,w5,w14 + add w22,w22,w26 // d+=h + add w26,w26,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + add w5,w5,w11 + add w26,w26,w17 // h+=Sigma0(a) + add w5,w5,w10 + ldr w10,[sp,#12] + str w13,[sp,#8] + ror w16,w22,#6 + add w25,w25,w19 // h+=K[i] + ror w12,w7,#7 + and w17,w23,w22 + ror w11,w4,#17 + bic w19,w24,w22 + ror w13,w26,#2 + add w25,w25,w5 // h+=X[i] + eor w16,w16,w22,ror#11 + eor w12,w12,w7,ror#18 + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w26,w27 // a^b, b^c in next round + eor w16,w16,w22,ror#25 // Sigma1(e) + eor w13,w13,w26,ror#13 + add w25,w25,w17 // h+=Ch(e,f,g) + and w28,w28,w19 // (b^c)&=(a^b) + eor w11,w11,w4,ror#19 + eor w12,w12,w7,lsr#3 // sigma0(X[i+1]) + add w25,w25,w16 // h+=Sigma1(e) + eor w28,w28,w27 // Maj(a,b,c) + eor w17,w13,w26,ror#22 // Sigma0(a) + eor w11,w11,w4,lsr#10 // sigma1(X[i+14]) + add w6,w6,w15 + add w21,w21,w25 // d+=h + add w25,w25,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + add w6,w6,w12 + add w25,w25,w17 // h+=Sigma0(a) + add w6,w6,w11 + ldr w11,[sp,#0] + str w14,[sp,#12] + ror w16,w21,#6 + add w24,w24,w28 // h+=K[i] + ror w13,w8,#7 + and w17,w22,w21 + ror w12,w5,#17 + bic w28,w23,w21 + ror w14,w25,#2 + add w24,w24,w6 // h+=X[i] + eor w16,w16,w21,ror#11 + eor w13,w13,w8,ror#18 + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w25,w26 // a^b, b^c in next round + eor w16,w16,w21,ror#25 // Sigma1(e) + eor w14,w14,w25,ror#13 + add w24,w24,w17 // h+=Ch(e,f,g) + and w19,w19,w28 // (b^c)&=(a^b) + eor w12,w12,w5,ror#19 + eor w13,w13,w8,lsr#3 // sigma0(X[i+1]) + add w24,w24,w16 // h+=Sigma1(e) + eor w19,w19,w26 // Maj(a,b,c) + eor w17,w14,w25,ror#22 // Sigma0(a) + eor w12,w12,w5,lsr#10 // sigma1(X[i+14]) + add w7,w7,w0 + add w20,w20,w24 // d+=h + add w24,w24,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + add w7,w7,w13 + add w24,w24,w17 // h+=Sigma0(a) + add w7,w7,w12 + ldr w12,[sp,#4] + str w15,[sp,#0] + ror w16,w20,#6 + add w23,w23,w19 // h+=K[i] + ror w14,w9,#7 + and w17,w21,w20 + ror w13,w6,#17 + bic w19,w22,w20 + ror w15,w24,#2 + add w23,w23,w7 // h+=X[i] + eor w16,w16,w20,ror#11 + eor w14,w14,w9,ror#18 + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w24,w25 // a^b, b^c in next round + eor w16,w16,w20,ror#25 // Sigma1(e) + eor w15,w15,w24,ror#13 + add w23,w23,w17 // h+=Ch(e,f,g) + and w28,w28,w19 // (b^c)&=(a^b) + eor w13,w13,w6,ror#19 + eor w14,w14,w9,lsr#3 // sigma0(X[i+1]) + add w23,w23,w16 // h+=Sigma1(e) + eor w28,w28,w25 // Maj(a,b,c) + eor w17,w15,w24,ror#22 // Sigma0(a) + eor w13,w13,w6,lsr#10 // sigma1(X[i+14]) + add w8,w8,w1 + add w27,w27,w23 // d+=h + add w23,w23,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + add w8,w8,w14 + add w23,w23,w17 // h+=Sigma0(a) + add w8,w8,w13 + ldr w13,[sp,#8] + str w0,[sp,#4] + ror w16,w27,#6 + add w22,w22,w28 // h+=K[i] + ror w15,w10,#7 + and w17,w20,w27 + ror w14,w7,#17 + bic w28,w21,w27 + ror w0,w23,#2 + add w22,w22,w8 // h+=X[i] + eor w16,w16,w27,ror#11 + eor w15,w15,w10,ror#18 + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w23,w24 // a^b, b^c in next round + eor w16,w16,w27,ror#25 // Sigma1(e) + eor w0,w0,w23,ror#13 + add w22,w22,w17 // h+=Ch(e,f,g) + and w19,w19,w28 // (b^c)&=(a^b) + eor w14,w14,w7,ror#19 + eor w15,w15,w10,lsr#3 // sigma0(X[i+1]) + add w22,w22,w16 // h+=Sigma1(e) + eor w19,w19,w24 // Maj(a,b,c) + eor w17,w0,w23,ror#22 // Sigma0(a) + eor w14,w14,w7,lsr#10 // sigma1(X[i+14]) + add w9,w9,w2 + add w26,w26,w22 // d+=h + add w22,w22,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + add w9,w9,w15 + add w22,w22,w17 // h+=Sigma0(a) + add w9,w9,w14 + ldr w14,[sp,#12] + str w1,[sp,#8] + ror w16,w26,#6 + add w21,w21,w19 // h+=K[i] + ror w0,w11,#7 + and w17,w27,w26 + ror w15,w8,#17 + bic w19,w20,w26 + ror w1,w22,#2 + add w21,w21,w9 // h+=X[i] + eor w16,w16,w26,ror#11 + eor w0,w0,w11,ror#18 + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w22,w23 // a^b, b^c in next round + eor w16,w16,w26,ror#25 // Sigma1(e) + eor w1,w1,w22,ror#13 + add w21,w21,w17 // h+=Ch(e,f,g) + and w28,w28,w19 // (b^c)&=(a^b) + eor w15,w15,w8,ror#19 + eor w0,w0,w11,lsr#3 // sigma0(X[i+1]) + add w21,w21,w16 // h+=Sigma1(e) + eor w28,w28,w23 // Maj(a,b,c) + eor w17,w1,w22,ror#22 // Sigma0(a) + eor w15,w15,w8,lsr#10 // sigma1(X[i+14]) + add w10,w10,w3 + add w25,w25,w21 // d+=h + add w21,w21,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + add w10,w10,w0 + add w21,w21,w17 // h+=Sigma0(a) + add w10,w10,w15 + ldr w15,[sp,#0] + str w2,[sp,#12] + ror w16,w25,#6 + add w20,w20,w28 // h+=K[i] + ror w1,w12,#7 + and w17,w26,w25 + ror w0,w9,#17 + bic w28,w27,w25 + ror w2,w21,#2 + add w20,w20,w10 // h+=X[i] + eor w16,w16,w25,ror#11 + eor w1,w1,w12,ror#18 + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w21,w22 // a^b, b^c in next round + eor w16,w16,w25,ror#25 // Sigma1(e) + eor w2,w2,w21,ror#13 + add w20,w20,w17 // h+=Ch(e,f,g) + and w19,w19,w28 // (b^c)&=(a^b) + eor w0,w0,w9,ror#19 + eor w1,w1,w12,lsr#3 // sigma0(X[i+1]) + add w20,w20,w16 // h+=Sigma1(e) + eor w19,w19,w22 // Maj(a,b,c) + eor w17,w2,w21,ror#22 // Sigma0(a) + eor w0,w0,w9,lsr#10 // sigma1(X[i+14]) + add w11,w11,w4 + add w24,w24,w20 // d+=h + add w20,w20,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + add w11,w11,w1 + add w20,w20,w17 // h+=Sigma0(a) + add w11,w11,w0 + ldr w0,[sp,#4] + str w3,[sp,#0] + ror w16,w24,#6 + add w27,w27,w19 // h+=K[i] + ror w2,w13,#7 + and w17,w25,w24 + ror w1,w10,#17 + bic w19,w26,w24 + ror w3,w20,#2 + add w27,w27,w11 // h+=X[i] + eor w16,w16,w24,ror#11 + eor w2,w2,w13,ror#18 + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w20,w21 // a^b, b^c in next round + eor w16,w16,w24,ror#25 // Sigma1(e) + eor w3,w3,w20,ror#13 + add w27,w27,w17 // h+=Ch(e,f,g) + and w28,w28,w19 // (b^c)&=(a^b) + eor w1,w1,w10,ror#19 + eor w2,w2,w13,lsr#3 // sigma0(X[i+1]) + add w27,w27,w16 // h+=Sigma1(e) + eor w28,w28,w21 // Maj(a,b,c) + eor w17,w3,w20,ror#22 // Sigma0(a) + eor w1,w1,w10,lsr#10 // sigma1(X[i+14]) + add w12,w12,w5 + add w23,w23,w27 // d+=h + add w27,w27,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + add w12,w12,w2 + add w27,w27,w17 // h+=Sigma0(a) + add w12,w12,w1 + ldr w1,[sp,#8] + str w4,[sp,#4] + ror w16,w23,#6 + add w26,w26,w28 // h+=K[i] + ror w3,w14,#7 + and w17,w24,w23 + ror w2,w11,#17 + bic w28,w25,w23 + ror w4,w27,#2 + add w26,w26,w12 // h+=X[i] + eor w16,w16,w23,ror#11 + eor w3,w3,w14,ror#18 + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w27,w20 // a^b, b^c in next round + eor w16,w16,w23,ror#25 // Sigma1(e) + eor w4,w4,w27,ror#13 + add w26,w26,w17 // h+=Ch(e,f,g) + and w19,w19,w28 // (b^c)&=(a^b) + eor w2,w2,w11,ror#19 + eor w3,w3,w14,lsr#3 // sigma0(X[i+1]) + add w26,w26,w16 // h+=Sigma1(e) + eor w19,w19,w20 // Maj(a,b,c) + eor w17,w4,w27,ror#22 // Sigma0(a) + eor w2,w2,w11,lsr#10 // sigma1(X[i+14]) + add w13,w13,w6 + add w22,w22,w26 // d+=h + add w26,w26,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + add w13,w13,w3 + add w26,w26,w17 // h+=Sigma0(a) + add w13,w13,w2 + ldr w2,[sp,#12] + str w5,[sp,#8] + ror w16,w22,#6 + add w25,w25,w19 // h+=K[i] + ror w4,w15,#7 + and w17,w23,w22 + ror w3,w12,#17 + bic w19,w24,w22 + ror w5,w26,#2 + add w25,w25,w13 // h+=X[i] + eor w16,w16,w22,ror#11 + eor w4,w4,w15,ror#18 + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w26,w27 // a^b, b^c in next round + eor w16,w16,w22,ror#25 // Sigma1(e) + eor w5,w5,w26,ror#13 + add w25,w25,w17 // h+=Ch(e,f,g) + and w28,w28,w19 // (b^c)&=(a^b) + eor w3,w3,w12,ror#19 + eor w4,w4,w15,lsr#3 // sigma0(X[i+1]) + add w25,w25,w16 // h+=Sigma1(e) + eor w28,w28,w27 // Maj(a,b,c) + eor w17,w5,w26,ror#22 // Sigma0(a) + eor w3,w3,w12,lsr#10 // sigma1(X[i+14]) + add w14,w14,w7 + add w21,w21,w25 // d+=h + add w25,w25,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + add w14,w14,w4 + add w25,w25,w17 // h+=Sigma0(a) + add w14,w14,w3 + ldr w3,[sp,#0] + str w6,[sp,#12] + ror w16,w21,#6 + add w24,w24,w28 // h+=K[i] + ror w5,w0,#7 + and w17,w22,w21 + ror w4,w13,#17 + bic w28,w23,w21 + ror w6,w25,#2 + add w24,w24,w14 // h+=X[i] + eor w16,w16,w21,ror#11 + eor w5,w5,w0,ror#18 + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w25,w26 // a^b, b^c in next round + eor w16,w16,w21,ror#25 // Sigma1(e) + eor w6,w6,w25,ror#13 + add w24,w24,w17 // h+=Ch(e,f,g) + and w19,w19,w28 // (b^c)&=(a^b) + eor w4,w4,w13,ror#19 + eor w5,w5,w0,lsr#3 // sigma0(X[i+1]) + add w24,w24,w16 // h+=Sigma1(e) + eor w19,w19,w26 // Maj(a,b,c) + eor w17,w6,w25,ror#22 // Sigma0(a) + eor w4,w4,w13,lsr#10 // sigma1(X[i+14]) + add w15,w15,w8 + add w20,w20,w24 // d+=h + add w24,w24,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + add w15,w15,w5 + add w24,w24,w17 // h+=Sigma0(a) + add w15,w15,w4 + ldr w4,[sp,#4] + str w7,[sp,#0] + ror w16,w20,#6 + add w23,w23,w19 // h+=K[i] + ror w6,w1,#7 + and w17,w21,w20 + ror w5,w14,#17 + bic w19,w22,w20 + ror w7,w24,#2 + add w23,w23,w15 // h+=X[i] + eor w16,w16,w20,ror#11 + eor w6,w6,w1,ror#18 + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w24,w25 // a^b, b^c in next round + eor w16,w16,w20,ror#25 // Sigma1(e) + eor w7,w7,w24,ror#13 + add w23,w23,w17 // h+=Ch(e,f,g) + and w28,w28,w19 // (b^c)&=(a^b) + eor w5,w5,w14,ror#19 + eor w6,w6,w1,lsr#3 // sigma0(X[i+1]) + add w23,w23,w16 // h+=Sigma1(e) + eor w28,w28,w25 // Maj(a,b,c) + eor w17,w7,w24,ror#22 // Sigma0(a) + eor w5,w5,w14,lsr#10 // sigma1(X[i+14]) + add w0,w0,w9 + add w27,w27,w23 // d+=h + add w23,w23,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + add w0,w0,w6 + add w23,w23,w17 // h+=Sigma0(a) + add w0,w0,w5 + ldr w5,[sp,#8] + str w8,[sp,#4] + ror w16,w27,#6 + add w22,w22,w28 // h+=K[i] + ror w7,w2,#7 + and w17,w20,w27 + ror w6,w15,#17 + bic w28,w21,w27 + ror w8,w23,#2 + add w22,w22,w0 // h+=X[i] + eor w16,w16,w27,ror#11 + eor w7,w7,w2,ror#18 + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w23,w24 // a^b, b^c in next round + eor w16,w16,w27,ror#25 // Sigma1(e) + eor w8,w8,w23,ror#13 + add w22,w22,w17 // h+=Ch(e,f,g) + and w19,w19,w28 // (b^c)&=(a^b) + eor w6,w6,w15,ror#19 + eor w7,w7,w2,lsr#3 // sigma0(X[i+1]) + add w22,w22,w16 // h+=Sigma1(e) + eor w19,w19,w24 // Maj(a,b,c) + eor w17,w8,w23,ror#22 // Sigma0(a) + eor w6,w6,w15,lsr#10 // sigma1(X[i+14]) + add w1,w1,w10 + add w26,w26,w22 // d+=h + add w22,w22,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + add w1,w1,w7 + add w22,w22,w17 // h+=Sigma0(a) + add w1,w1,w6 + ldr w6,[sp,#12] + str w9,[sp,#8] + ror w16,w26,#6 + add w21,w21,w19 // h+=K[i] + ror w8,w3,#7 + and w17,w27,w26 + ror w7,w0,#17 + bic w19,w20,w26 + ror w9,w22,#2 + add w21,w21,w1 // h+=X[i] + eor w16,w16,w26,ror#11 + eor w8,w8,w3,ror#18 + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w22,w23 // a^b, b^c in next round + eor w16,w16,w26,ror#25 // Sigma1(e) + eor w9,w9,w22,ror#13 + add w21,w21,w17 // h+=Ch(e,f,g) + and w28,w28,w19 // (b^c)&=(a^b) + eor w7,w7,w0,ror#19 + eor w8,w8,w3,lsr#3 // sigma0(X[i+1]) + add w21,w21,w16 // h+=Sigma1(e) + eor w28,w28,w23 // Maj(a,b,c) + eor w17,w9,w22,ror#22 // Sigma0(a) + eor w7,w7,w0,lsr#10 // sigma1(X[i+14]) + add w2,w2,w11 + add w25,w25,w21 // d+=h + add w21,w21,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + add w2,w2,w8 + add w21,w21,w17 // h+=Sigma0(a) + add w2,w2,w7 + ldr w7,[sp,#0] + str w10,[sp,#12] + ror w16,w25,#6 + add w20,w20,w28 // h+=K[i] + ror w9,w4,#7 + and w17,w26,w25 + ror w8,w1,#17 + bic w28,w27,w25 + ror w10,w21,#2 + add w20,w20,w2 // h+=X[i] + eor w16,w16,w25,ror#11 + eor w9,w9,w4,ror#18 + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w21,w22 // a^b, b^c in next round + eor w16,w16,w25,ror#25 // Sigma1(e) + eor w10,w10,w21,ror#13 + add w20,w20,w17 // h+=Ch(e,f,g) + and w19,w19,w28 // (b^c)&=(a^b) + eor w8,w8,w1,ror#19 + eor w9,w9,w4,lsr#3 // sigma0(X[i+1]) + add w20,w20,w16 // h+=Sigma1(e) + eor w19,w19,w22 // Maj(a,b,c) + eor w17,w10,w21,ror#22 // Sigma0(a) + eor w8,w8,w1,lsr#10 // sigma1(X[i+14]) + add w3,w3,w12 + add w24,w24,w20 // d+=h + add w20,w20,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + add w3,w3,w9 + add w20,w20,w17 // h+=Sigma0(a) + add w3,w3,w8 + cbnz w19,.Loop_16_xx + + ldp x0,x2,[x29,#96] + ldr x1,[x29,#112] + sub x30,x30,#260 // rewind + + ldp w3,w4,[x0] + ldp w5,w6,[x0,#2*4] + add x1,x1,#14*4 // advance input pointer + ldp w7,w8,[x0,#4*4] + add w20,w20,w3 + ldp w9,w10,[x0,#6*4] + add w21,w21,w4 + add w22,w22,w5 + add w23,w23,w6 + stp w20,w21,[x0] + add w24,w24,w7 + add w25,w25,w8 + stp w22,w23,[x0,#2*4] + add w26,w26,w9 + add w27,w27,w10 + cmp x1,x2 + stp w24,w25,[x0,#4*4] + stp w26,w27,[x0,#6*4] + b.ne .Loop + + ldp x19,x20,[x29,#16] + add sp,sp,#4*4 + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldp x29,x30,[sp],#128 + AARCH64_VALIDATE_LINK_REGISTER + ret +.size sha256_block_data_order_nohw,.-sha256_block_data_order_nohw + +.section .rodata +.align 6 +.type .LK256,%object +.LK256: +.long 0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5 +.long 0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5 +.long 0xd807aa98,0x12835b01,0x243185be,0x550c7dc3 +.long 0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174 +.long 0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc +.long 0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da +.long 0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7 +.long 0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967 +.long 0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13 +.long 0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85 +.long 0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3 +.long 0xd192e819,0xd6990624,0xf40e3585,0x106aa070 +.long 0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5 +.long 0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3 +.long 0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208 +.long 0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2 +.long 0 //terminator +.size .LK256,.-.LK256 +.byte 83,72,65,50,53,54,32,98,108,111,99,107,32,116,114,97,110,115,102,111,114,109,32,102,111,114,32,65,82,77,118,56,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.align 2 +.align 2 +.text +#ifndef __KERNEL__ +.globl sha256_block_data_order_hw +.hidden sha256_block_data_order_hw +.type sha256_block_data_order_hw,%function +.align 6 +sha256_block_data_order_hw: + // Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later. + AARCH64_VALID_CALL_TARGET + stp x29,x30,[sp,#-16]! + add x29,sp,#0 + + ld1 {v0.4s,v1.4s},[x0] + adrp x3,.LK256 + add x3,x3,:lo12:.LK256 + +.Loop_hw: + ld1 {v4.16b,v5.16b,v6.16b,v7.16b},[x1],#64 + sub x2,x2,#1 + ld1 {v16.4s},[x3],#16 + rev32 v4.16b,v4.16b + rev32 v5.16b,v5.16b + rev32 v6.16b,v6.16b + rev32 v7.16b,v7.16b + orr v18.16b,v0.16b,v0.16b // offload + orr v19.16b,v1.16b,v1.16b + ld1 {v17.4s},[x3],#16 + add v16.4s,v16.4s,v4.4s +.inst 0x5e2828a4 //sha256su0 v4.16b,v5.16b + orr v2.16b,v0.16b,v0.16b +.inst 0x5e104020 //sha256h v0.16b,v1.16b,v16.4s +.inst 0x5e105041 //sha256h2 v1.16b,v2.16b,v16.4s +.inst 0x5e0760c4 //sha256su1 v4.16b,v6.16b,v7.16b + ld1 {v16.4s},[x3],#16 + add v17.4s,v17.4s,v5.4s +.inst 0x5e2828c5 //sha256su0 v5.16b,v6.16b + orr v2.16b,v0.16b,v0.16b +.inst 0x5e114020 //sha256h v0.16b,v1.16b,v17.4s +.inst 0x5e115041 //sha256h2 v1.16b,v2.16b,v17.4s +.inst 0x5e0460e5 //sha256su1 v5.16b,v7.16b,v4.16b + ld1 {v17.4s},[x3],#16 + add v16.4s,v16.4s,v6.4s +.inst 0x5e2828e6 //sha256su0 v6.16b,v7.16b + orr v2.16b,v0.16b,v0.16b +.inst 0x5e104020 //sha256h v0.16b,v1.16b,v16.4s +.inst 0x5e105041 //sha256h2 v1.16b,v2.16b,v16.4s +.inst 0x5e056086 //sha256su1 v6.16b,v4.16b,v5.16b + ld1 {v16.4s},[x3],#16 + add v17.4s,v17.4s,v7.4s +.inst 0x5e282887 //sha256su0 v7.16b,v4.16b + orr v2.16b,v0.16b,v0.16b +.inst 0x5e114020 //sha256h v0.16b,v1.16b,v17.4s +.inst 0x5e115041 //sha256h2 v1.16b,v2.16b,v17.4s +.inst 0x5e0660a7 //sha256su1 v7.16b,v5.16b,v6.16b + ld1 {v17.4s},[x3],#16 + add v16.4s,v16.4s,v4.4s +.inst 0x5e2828a4 //sha256su0 v4.16b,v5.16b + orr v2.16b,v0.16b,v0.16b +.inst 0x5e104020 //sha256h v0.16b,v1.16b,v16.4s +.inst 0x5e105041 //sha256h2 v1.16b,v2.16b,v16.4s +.inst 0x5e0760c4 //sha256su1 v4.16b,v6.16b,v7.16b + ld1 {v16.4s},[x3],#16 + add v17.4s,v17.4s,v5.4s +.inst 0x5e2828c5 //sha256su0 v5.16b,v6.16b + orr v2.16b,v0.16b,v0.16b +.inst 0x5e114020 //sha256h v0.16b,v1.16b,v17.4s +.inst 0x5e115041 //sha256h2 v1.16b,v2.16b,v17.4s +.inst 0x5e0460e5 //sha256su1 v5.16b,v7.16b,v4.16b + ld1 {v17.4s},[x3],#16 + add v16.4s,v16.4s,v6.4s +.inst 0x5e2828e6 //sha256su0 v6.16b,v7.16b + orr v2.16b,v0.16b,v0.16b +.inst 0x5e104020 //sha256h v0.16b,v1.16b,v16.4s +.inst 0x5e105041 //sha256h2 v1.16b,v2.16b,v16.4s +.inst 0x5e056086 //sha256su1 v6.16b,v4.16b,v5.16b + ld1 {v16.4s},[x3],#16 + add v17.4s,v17.4s,v7.4s +.inst 0x5e282887 //sha256su0 v7.16b,v4.16b + orr v2.16b,v0.16b,v0.16b +.inst 0x5e114020 //sha256h v0.16b,v1.16b,v17.4s +.inst 0x5e115041 //sha256h2 v1.16b,v2.16b,v17.4s +.inst 0x5e0660a7 //sha256su1 v7.16b,v5.16b,v6.16b + ld1 {v17.4s},[x3],#16 + add v16.4s,v16.4s,v4.4s +.inst 0x5e2828a4 //sha256su0 v4.16b,v5.16b + orr v2.16b,v0.16b,v0.16b +.inst 0x5e104020 //sha256h v0.16b,v1.16b,v16.4s +.inst 0x5e105041 //sha256h2 v1.16b,v2.16b,v16.4s +.inst 0x5e0760c4 //sha256su1 v4.16b,v6.16b,v7.16b + ld1 {v16.4s},[x3],#16 + add v17.4s,v17.4s,v5.4s +.inst 0x5e2828c5 //sha256su0 v5.16b,v6.16b + orr v2.16b,v0.16b,v0.16b +.inst 0x5e114020 //sha256h v0.16b,v1.16b,v17.4s +.inst 0x5e115041 //sha256h2 v1.16b,v2.16b,v17.4s +.inst 0x5e0460e5 //sha256su1 v5.16b,v7.16b,v4.16b + ld1 {v17.4s},[x3],#16 + add v16.4s,v16.4s,v6.4s +.inst 0x5e2828e6 //sha256su0 v6.16b,v7.16b + orr v2.16b,v0.16b,v0.16b +.inst 0x5e104020 //sha256h v0.16b,v1.16b,v16.4s +.inst 0x5e105041 //sha256h2 v1.16b,v2.16b,v16.4s +.inst 0x5e056086 //sha256su1 v6.16b,v4.16b,v5.16b + ld1 {v16.4s},[x3],#16 + add v17.4s,v17.4s,v7.4s +.inst 0x5e282887 //sha256su0 v7.16b,v4.16b + orr v2.16b,v0.16b,v0.16b +.inst 0x5e114020 //sha256h v0.16b,v1.16b,v17.4s +.inst 0x5e115041 //sha256h2 v1.16b,v2.16b,v17.4s +.inst 0x5e0660a7 //sha256su1 v7.16b,v5.16b,v6.16b + ld1 {v17.4s},[x3],#16 + add v16.4s,v16.4s,v4.4s + orr v2.16b,v0.16b,v0.16b +.inst 0x5e104020 //sha256h v0.16b,v1.16b,v16.4s +.inst 0x5e105041 //sha256h2 v1.16b,v2.16b,v16.4s + + ld1 {v16.4s},[x3],#16 + add v17.4s,v17.4s,v5.4s + orr v2.16b,v0.16b,v0.16b +.inst 0x5e114020 //sha256h v0.16b,v1.16b,v17.4s +.inst 0x5e115041 //sha256h2 v1.16b,v2.16b,v17.4s + + ld1 {v17.4s},[x3] + add v16.4s,v16.4s,v6.4s + sub x3,x3,#64*4-16 // rewind + orr v2.16b,v0.16b,v0.16b +.inst 0x5e104020 //sha256h v0.16b,v1.16b,v16.4s +.inst 0x5e105041 //sha256h2 v1.16b,v2.16b,v16.4s + + add v17.4s,v17.4s,v7.4s + orr v2.16b,v0.16b,v0.16b +.inst 0x5e114020 //sha256h v0.16b,v1.16b,v17.4s +.inst 0x5e115041 //sha256h2 v1.16b,v2.16b,v17.4s + + add v0.4s,v0.4s,v18.4s + add v1.4s,v1.4s,v19.4s + + cbnz x2,.Loop_hw + + st1 {v0.4s,v1.4s},[x0] + + ldr x29,[sp],#16 + ret +.size sha256_block_data_order_hw,.-sha256_block_data_order_hw +#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__ELF__) diff --git a/http/vendor/ring/pregenerated/sha256-armv8-win64.S b/http/vendor/ring/pregenerated/sha256-armv8-win64.S new file mode 100644 index 0000000..3049ef3 --- /dev/null +++ b/http/vendor/ring/pregenerated/sha256-armv8-win64.S @@ -0,0 +1,1199 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(_WIN32) +// Copyright 2014-2020 The OpenSSL Project Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// ==================================================================== +// Written by Andy Polyakov for the OpenSSL +// project. +// ==================================================================== +// +// SHA256/512 for ARMv8. +// +// Performance in cycles per processed byte and improvement coefficient +// over code generated with "default" compiler: +// +// SHA256-hw SHA256(*) SHA512 +// Apple A7 1.97 10.5 (+33%) 6.73 (-1%(**)) +// Cortex-A53 2.38 15.5 (+115%) 10.0 (+150%(***)) +// Cortex-A57 2.31 11.6 (+86%) 7.51 (+260%(***)) +// Denver 2.01 10.5 (+26%) 6.70 (+8%) +// X-Gene 20.0 (+100%) 12.8 (+300%(***)) +// Mongoose 2.36 13.0 (+50%) 8.36 (+33%) +// Kryo 1.92 17.4 (+30%) 11.2 (+8%) +// +// (*) Software SHA256 results are of lesser relevance, presented +// mostly for informational purposes. +// (**) The result is a trade-off: it's possible to improve it by +// 10% (or by 1 cycle per round), but at the cost of 20% loss +// on Cortex-A53 (or by 4 cycles per round). +// (***) Super-impressive coefficients over gcc-generated code are +// indication of some compiler "pathology", most notably code +// generated with -mgeneral-regs-only is significantly faster +// and the gap is only 40-90%. + +#ifndef __KERNEL__ +#endif + +.text + +.globl sha256_block_data_order_nohw + +.def sha256_block_data_order_nohw + .type 32 +.endef +.align 6 +sha256_block_data_order_nohw: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-128]! + add x29,sp,#0 + + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + stp x27,x28,[sp,#80] + sub sp,sp,#4*4 + + ldp w20,w21,[x0] // load context + ldp w22,w23,[x0,#2*4] + ldp w24,w25,[x0,#4*4] + add x2,x1,x2,lsl#6 // end of input + ldp w26,w27,[x0,#6*4] + adrp x30,LK256 + add x30,x30,:lo12:LK256 + stp x0,x2,[x29,#96] + +Loop: + ldp w3,w4,[x1],#2*4 + ldr w19,[x30],#4 // *K++ + eor w28,w21,w22 // magic seed + str x1,[x29,#112] +#ifndef __AARCH64EB__ + rev w3,w3 // 0 +#endif + ror w16,w24,#6 + add w27,w27,w19 // h+=K[i] + eor w6,w24,w24,ror#14 + and w17,w25,w24 + bic w19,w26,w24 + add w27,w27,w3 // h+=X[i] + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w20,w21 // a^b, b^c in next round + eor w16,w16,w6,ror#11 // Sigma1(e) + ror w6,w20,#2 + add w27,w27,w17 // h+=Ch(e,f,g) + eor w17,w20,w20,ror#9 + add w27,w27,w16 // h+=Sigma1(e) + and w28,w28,w19 // (b^c)&=(a^b) + add w23,w23,w27 // d+=h + eor w28,w28,w21 // Maj(a,b,c) + eor w17,w6,w17,ror#13 // Sigma0(a) + add w27,w27,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + //add w27,w27,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w4,w4 // 1 +#endif + ldp w5,w6,[x1],#2*4 + add w27,w27,w17 // h+=Sigma0(a) + ror w16,w23,#6 + add w26,w26,w28 // h+=K[i] + eor w7,w23,w23,ror#14 + and w17,w24,w23 + bic w28,w25,w23 + add w26,w26,w4 // h+=X[i] + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w27,w20 // a^b, b^c in next round + eor w16,w16,w7,ror#11 // Sigma1(e) + ror w7,w27,#2 + add w26,w26,w17 // h+=Ch(e,f,g) + eor w17,w27,w27,ror#9 + add w26,w26,w16 // h+=Sigma1(e) + and w19,w19,w28 // (b^c)&=(a^b) + add w22,w22,w26 // d+=h + eor w19,w19,w20 // Maj(a,b,c) + eor w17,w7,w17,ror#13 // Sigma0(a) + add w26,w26,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + //add w26,w26,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w5,w5 // 2 +#endif + add w26,w26,w17 // h+=Sigma0(a) + ror w16,w22,#6 + add w25,w25,w19 // h+=K[i] + eor w8,w22,w22,ror#14 + and w17,w23,w22 + bic w19,w24,w22 + add w25,w25,w5 // h+=X[i] + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w26,w27 // a^b, b^c in next round + eor w16,w16,w8,ror#11 // Sigma1(e) + ror w8,w26,#2 + add w25,w25,w17 // h+=Ch(e,f,g) + eor w17,w26,w26,ror#9 + add w25,w25,w16 // h+=Sigma1(e) + and w28,w28,w19 // (b^c)&=(a^b) + add w21,w21,w25 // d+=h + eor w28,w28,w27 // Maj(a,b,c) + eor w17,w8,w17,ror#13 // Sigma0(a) + add w25,w25,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + //add w25,w25,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w6,w6 // 3 +#endif + ldp w7,w8,[x1],#2*4 + add w25,w25,w17 // h+=Sigma0(a) + ror w16,w21,#6 + add w24,w24,w28 // h+=K[i] + eor w9,w21,w21,ror#14 + and w17,w22,w21 + bic w28,w23,w21 + add w24,w24,w6 // h+=X[i] + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w25,w26 // a^b, b^c in next round + eor w16,w16,w9,ror#11 // Sigma1(e) + ror w9,w25,#2 + add w24,w24,w17 // h+=Ch(e,f,g) + eor w17,w25,w25,ror#9 + add w24,w24,w16 // h+=Sigma1(e) + and w19,w19,w28 // (b^c)&=(a^b) + add w20,w20,w24 // d+=h + eor w19,w19,w26 // Maj(a,b,c) + eor w17,w9,w17,ror#13 // Sigma0(a) + add w24,w24,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + //add w24,w24,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w7,w7 // 4 +#endif + add w24,w24,w17 // h+=Sigma0(a) + ror w16,w20,#6 + add w23,w23,w19 // h+=K[i] + eor w10,w20,w20,ror#14 + and w17,w21,w20 + bic w19,w22,w20 + add w23,w23,w7 // h+=X[i] + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w24,w25 // a^b, b^c in next round + eor w16,w16,w10,ror#11 // Sigma1(e) + ror w10,w24,#2 + add w23,w23,w17 // h+=Ch(e,f,g) + eor w17,w24,w24,ror#9 + add w23,w23,w16 // h+=Sigma1(e) + and w28,w28,w19 // (b^c)&=(a^b) + add w27,w27,w23 // d+=h + eor w28,w28,w25 // Maj(a,b,c) + eor w17,w10,w17,ror#13 // Sigma0(a) + add w23,w23,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + //add w23,w23,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w8,w8 // 5 +#endif + ldp w9,w10,[x1],#2*4 + add w23,w23,w17 // h+=Sigma0(a) + ror w16,w27,#6 + add w22,w22,w28 // h+=K[i] + eor w11,w27,w27,ror#14 + and w17,w20,w27 + bic w28,w21,w27 + add w22,w22,w8 // h+=X[i] + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w23,w24 // a^b, b^c in next round + eor w16,w16,w11,ror#11 // Sigma1(e) + ror w11,w23,#2 + add w22,w22,w17 // h+=Ch(e,f,g) + eor w17,w23,w23,ror#9 + add w22,w22,w16 // h+=Sigma1(e) + and w19,w19,w28 // (b^c)&=(a^b) + add w26,w26,w22 // d+=h + eor w19,w19,w24 // Maj(a,b,c) + eor w17,w11,w17,ror#13 // Sigma0(a) + add w22,w22,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + //add w22,w22,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w9,w9 // 6 +#endif + add w22,w22,w17 // h+=Sigma0(a) + ror w16,w26,#6 + add w21,w21,w19 // h+=K[i] + eor w12,w26,w26,ror#14 + and w17,w27,w26 + bic w19,w20,w26 + add w21,w21,w9 // h+=X[i] + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w22,w23 // a^b, b^c in next round + eor w16,w16,w12,ror#11 // Sigma1(e) + ror w12,w22,#2 + add w21,w21,w17 // h+=Ch(e,f,g) + eor w17,w22,w22,ror#9 + add w21,w21,w16 // h+=Sigma1(e) + and w28,w28,w19 // (b^c)&=(a^b) + add w25,w25,w21 // d+=h + eor w28,w28,w23 // Maj(a,b,c) + eor w17,w12,w17,ror#13 // Sigma0(a) + add w21,w21,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + //add w21,w21,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w10,w10 // 7 +#endif + ldp w11,w12,[x1],#2*4 + add w21,w21,w17 // h+=Sigma0(a) + ror w16,w25,#6 + add w20,w20,w28 // h+=K[i] + eor w13,w25,w25,ror#14 + and w17,w26,w25 + bic w28,w27,w25 + add w20,w20,w10 // h+=X[i] + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w21,w22 // a^b, b^c in next round + eor w16,w16,w13,ror#11 // Sigma1(e) + ror w13,w21,#2 + add w20,w20,w17 // h+=Ch(e,f,g) + eor w17,w21,w21,ror#9 + add w20,w20,w16 // h+=Sigma1(e) + and w19,w19,w28 // (b^c)&=(a^b) + add w24,w24,w20 // d+=h + eor w19,w19,w22 // Maj(a,b,c) + eor w17,w13,w17,ror#13 // Sigma0(a) + add w20,w20,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + //add w20,w20,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w11,w11 // 8 +#endif + add w20,w20,w17 // h+=Sigma0(a) + ror w16,w24,#6 + add w27,w27,w19 // h+=K[i] + eor w14,w24,w24,ror#14 + and w17,w25,w24 + bic w19,w26,w24 + add w27,w27,w11 // h+=X[i] + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w20,w21 // a^b, b^c in next round + eor w16,w16,w14,ror#11 // Sigma1(e) + ror w14,w20,#2 + add w27,w27,w17 // h+=Ch(e,f,g) + eor w17,w20,w20,ror#9 + add w27,w27,w16 // h+=Sigma1(e) + and w28,w28,w19 // (b^c)&=(a^b) + add w23,w23,w27 // d+=h + eor w28,w28,w21 // Maj(a,b,c) + eor w17,w14,w17,ror#13 // Sigma0(a) + add w27,w27,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + //add w27,w27,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w12,w12 // 9 +#endif + ldp w13,w14,[x1],#2*4 + add w27,w27,w17 // h+=Sigma0(a) + ror w16,w23,#6 + add w26,w26,w28 // h+=K[i] + eor w15,w23,w23,ror#14 + and w17,w24,w23 + bic w28,w25,w23 + add w26,w26,w12 // h+=X[i] + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w27,w20 // a^b, b^c in next round + eor w16,w16,w15,ror#11 // Sigma1(e) + ror w15,w27,#2 + add w26,w26,w17 // h+=Ch(e,f,g) + eor w17,w27,w27,ror#9 + add w26,w26,w16 // h+=Sigma1(e) + and w19,w19,w28 // (b^c)&=(a^b) + add w22,w22,w26 // d+=h + eor w19,w19,w20 // Maj(a,b,c) + eor w17,w15,w17,ror#13 // Sigma0(a) + add w26,w26,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + //add w26,w26,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w13,w13 // 10 +#endif + add w26,w26,w17 // h+=Sigma0(a) + ror w16,w22,#6 + add w25,w25,w19 // h+=K[i] + eor w0,w22,w22,ror#14 + and w17,w23,w22 + bic w19,w24,w22 + add w25,w25,w13 // h+=X[i] + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w26,w27 // a^b, b^c in next round + eor w16,w16,w0,ror#11 // Sigma1(e) + ror w0,w26,#2 + add w25,w25,w17 // h+=Ch(e,f,g) + eor w17,w26,w26,ror#9 + add w25,w25,w16 // h+=Sigma1(e) + and w28,w28,w19 // (b^c)&=(a^b) + add w21,w21,w25 // d+=h + eor w28,w28,w27 // Maj(a,b,c) + eor w17,w0,w17,ror#13 // Sigma0(a) + add w25,w25,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + //add w25,w25,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w14,w14 // 11 +#endif + ldp w15,w0,[x1],#2*4 + add w25,w25,w17 // h+=Sigma0(a) + str w6,[sp,#12] + ror w16,w21,#6 + add w24,w24,w28 // h+=K[i] + eor w6,w21,w21,ror#14 + and w17,w22,w21 + bic w28,w23,w21 + add w24,w24,w14 // h+=X[i] + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w25,w26 // a^b, b^c in next round + eor w16,w16,w6,ror#11 // Sigma1(e) + ror w6,w25,#2 + add w24,w24,w17 // h+=Ch(e,f,g) + eor w17,w25,w25,ror#9 + add w24,w24,w16 // h+=Sigma1(e) + and w19,w19,w28 // (b^c)&=(a^b) + add w20,w20,w24 // d+=h + eor w19,w19,w26 // Maj(a,b,c) + eor w17,w6,w17,ror#13 // Sigma0(a) + add w24,w24,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + //add w24,w24,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w15,w15 // 12 +#endif + add w24,w24,w17 // h+=Sigma0(a) + str w7,[sp,#0] + ror w16,w20,#6 + add w23,w23,w19 // h+=K[i] + eor w7,w20,w20,ror#14 + and w17,w21,w20 + bic w19,w22,w20 + add w23,w23,w15 // h+=X[i] + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w24,w25 // a^b, b^c in next round + eor w16,w16,w7,ror#11 // Sigma1(e) + ror w7,w24,#2 + add w23,w23,w17 // h+=Ch(e,f,g) + eor w17,w24,w24,ror#9 + add w23,w23,w16 // h+=Sigma1(e) + and w28,w28,w19 // (b^c)&=(a^b) + add w27,w27,w23 // d+=h + eor w28,w28,w25 // Maj(a,b,c) + eor w17,w7,w17,ror#13 // Sigma0(a) + add w23,w23,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + //add w23,w23,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w0,w0 // 13 +#endif + ldp w1,w2,[x1] + add w23,w23,w17 // h+=Sigma0(a) + str w8,[sp,#4] + ror w16,w27,#6 + add w22,w22,w28 // h+=K[i] + eor w8,w27,w27,ror#14 + and w17,w20,w27 + bic w28,w21,w27 + add w22,w22,w0 // h+=X[i] + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w23,w24 // a^b, b^c in next round + eor w16,w16,w8,ror#11 // Sigma1(e) + ror w8,w23,#2 + add w22,w22,w17 // h+=Ch(e,f,g) + eor w17,w23,w23,ror#9 + add w22,w22,w16 // h+=Sigma1(e) + and w19,w19,w28 // (b^c)&=(a^b) + add w26,w26,w22 // d+=h + eor w19,w19,w24 // Maj(a,b,c) + eor w17,w8,w17,ror#13 // Sigma0(a) + add w22,w22,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + //add w22,w22,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w1,w1 // 14 +#endif + ldr w6,[sp,#12] + add w22,w22,w17 // h+=Sigma0(a) + str w9,[sp,#8] + ror w16,w26,#6 + add w21,w21,w19 // h+=K[i] + eor w9,w26,w26,ror#14 + and w17,w27,w26 + bic w19,w20,w26 + add w21,w21,w1 // h+=X[i] + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w22,w23 // a^b, b^c in next round + eor w16,w16,w9,ror#11 // Sigma1(e) + ror w9,w22,#2 + add w21,w21,w17 // h+=Ch(e,f,g) + eor w17,w22,w22,ror#9 + add w21,w21,w16 // h+=Sigma1(e) + and w28,w28,w19 // (b^c)&=(a^b) + add w25,w25,w21 // d+=h + eor w28,w28,w23 // Maj(a,b,c) + eor w17,w9,w17,ror#13 // Sigma0(a) + add w21,w21,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + //add w21,w21,w17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev w2,w2 // 15 +#endif + ldr w7,[sp,#0] + add w21,w21,w17 // h+=Sigma0(a) + str w10,[sp,#12] + ror w16,w25,#6 + add w20,w20,w28 // h+=K[i] + ror w9,w4,#7 + and w17,w26,w25 + ror w8,w1,#17 + bic w28,w27,w25 + ror w10,w21,#2 + add w20,w20,w2 // h+=X[i] + eor w16,w16,w25,ror#11 + eor w9,w9,w4,ror#18 + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w21,w22 // a^b, b^c in next round + eor w16,w16,w25,ror#25 // Sigma1(e) + eor w10,w10,w21,ror#13 + add w20,w20,w17 // h+=Ch(e,f,g) + and w19,w19,w28 // (b^c)&=(a^b) + eor w8,w8,w1,ror#19 + eor w9,w9,w4,lsr#3 // sigma0(X[i+1]) + add w20,w20,w16 // h+=Sigma1(e) + eor w19,w19,w22 // Maj(a,b,c) + eor w17,w10,w21,ror#22 // Sigma0(a) + eor w8,w8,w1,lsr#10 // sigma1(X[i+14]) + add w3,w3,w12 + add w24,w24,w20 // d+=h + add w20,w20,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + add w3,w3,w9 + add w20,w20,w17 // h+=Sigma0(a) + add w3,w3,w8 +Loop_16_xx: + ldr w8,[sp,#4] + str w11,[sp,#0] + ror w16,w24,#6 + add w27,w27,w19 // h+=K[i] + ror w10,w5,#7 + and w17,w25,w24 + ror w9,w2,#17 + bic w19,w26,w24 + ror w11,w20,#2 + add w27,w27,w3 // h+=X[i] + eor w16,w16,w24,ror#11 + eor w10,w10,w5,ror#18 + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w20,w21 // a^b, b^c in next round + eor w16,w16,w24,ror#25 // Sigma1(e) + eor w11,w11,w20,ror#13 + add w27,w27,w17 // h+=Ch(e,f,g) + and w28,w28,w19 // (b^c)&=(a^b) + eor w9,w9,w2,ror#19 + eor w10,w10,w5,lsr#3 // sigma0(X[i+1]) + add w27,w27,w16 // h+=Sigma1(e) + eor w28,w28,w21 // Maj(a,b,c) + eor w17,w11,w20,ror#22 // Sigma0(a) + eor w9,w9,w2,lsr#10 // sigma1(X[i+14]) + add w4,w4,w13 + add w23,w23,w27 // d+=h + add w27,w27,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + add w4,w4,w10 + add w27,w27,w17 // h+=Sigma0(a) + add w4,w4,w9 + ldr w9,[sp,#8] + str w12,[sp,#4] + ror w16,w23,#6 + add w26,w26,w28 // h+=K[i] + ror w11,w6,#7 + and w17,w24,w23 + ror w10,w3,#17 + bic w28,w25,w23 + ror w12,w27,#2 + add w26,w26,w4 // h+=X[i] + eor w16,w16,w23,ror#11 + eor w11,w11,w6,ror#18 + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w27,w20 // a^b, b^c in next round + eor w16,w16,w23,ror#25 // Sigma1(e) + eor w12,w12,w27,ror#13 + add w26,w26,w17 // h+=Ch(e,f,g) + and w19,w19,w28 // (b^c)&=(a^b) + eor w10,w10,w3,ror#19 + eor w11,w11,w6,lsr#3 // sigma0(X[i+1]) + add w26,w26,w16 // h+=Sigma1(e) + eor w19,w19,w20 // Maj(a,b,c) + eor w17,w12,w27,ror#22 // Sigma0(a) + eor w10,w10,w3,lsr#10 // sigma1(X[i+14]) + add w5,w5,w14 + add w22,w22,w26 // d+=h + add w26,w26,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + add w5,w5,w11 + add w26,w26,w17 // h+=Sigma0(a) + add w5,w5,w10 + ldr w10,[sp,#12] + str w13,[sp,#8] + ror w16,w22,#6 + add w25,w25,w19 // h+=K[i] + ror w12,w7,#7 + and w17,w23,w22 + ror w11,w4,#17 + bic w19,w24,w22 + ror w13,w26,#2 + add w25,w25,w5 // h+=X[i] + eor w16,w16,w22,ror#11 + eor w12,w12,w7,ror#18 + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w26,w27 // a^b, b^c in next round + eor w16,w16,w22,ror#25 // Sigma1(e) + eor w13,w13,w26,ror#13 + add w25,w25,w17 // h+=Ch(e,f,g) + and w28,w28,w19 // (b^c)&=(a^b) + eor w11,w11,w4,ror#19 + eor w12,w12,w7,lsr#3 // sigma0(X[i+1]) + add w25,w25,w16 // h+=Sigma1(e) + eor w28,w28,w27 // Maj(a,b,c) + eor w17,w13,w26,ror#22 // Sigma0(a) + eor w11,w11,w4,lsr#10 // sigma1(X[i+14]) + add w6,w6,w15 + add w21,w21,w25 // d+=h + add w25,w25,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + add w6,w6,w12 + add w25,w25,w17 // h+=Sigma0(a) + add w6,w6,w11 + ldr w11,[sp,#0] + str w14,[sp,#12] + ror w16,w21,#6 + add w24,w24,w28 // h+=K[i] + ror w13,w8,#7 + and w17,w22,w21 + ror w12,w5,#17 + bic w28,w23,w21 + ror w14,w25,#2 + add w24,w24,w6 // h+=X[i] + eor w16,w16,w21,ror#11 + eor w13,w13,w8,ror#18 + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w25,w26 // a^b, b^c in next round + eor w16,w16,w21,ror#25 // Sigma1(e) + eor w14,w14,w25,ror#13 + add w24,w24,w17 // h+=Ch(e,f,g) + and w19,w19,w28 // (b^c)&=(a^b) + eor w12,w12,w5,ror#19 + eor w13,w13,w8,lsr#3 // sigma0(X[i+1]) + add w24,w24,w16 // h+=Sigma1(e) + eor w19,w19,w26 // Maj(a,b,c) + eor w17,w14,w25,ror#22 // Sigma0(a) + eor w12,w12,w5,lsr#10 // sigma1(X[i+14]) + add w7,w7,w0 + add w20,w20,w24 // d+=h + add w24,w24,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + add w7,w7,w13 + add w24,w24,w17 // h+=Sigma0(a) + add w7,w7,w12 + ldr w12,[sp,#4] + str w15,[sp,#0] + ror w16,w20,#6 + add w23,w23,w19 // h+=K[i] + ror w14,w9,#7 + and w17,w21,w20 + ror w13,w6,#17 + bic w19,w22,w20 + ror w15,w24,#2 + add w23,w23,w7 // h+=X[i] + eor w16,w16,w20,ror#11 + eor w14,w14,w9,ror#18 + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w24,w25 // a^b, b^c in next round + eor w16,w16,w20,ror#25 // Sigma1(e) + eor w15,w15,w24,ror#13 + add w23,w23,w17 // h+=Ch(e,f,g) + and w28,w28,w19 // (b^c)&=(a^b) + eor w13,w13,w6,ror#19 + eor w14,w14,w9,lsr#3 // sigma0(X[i+1]) + add w23,w23,w16 // h+=Sigma1(e) + eor w28,w28,w25 // Maj(a,b,c) + eor w17,w15,w24,ror#22 // Sigma0(a) + eor w13,w13,w6,lsr#10 // sigma1(X[i+14]) + add w8,w8,w1 + add w27,w27,w23 // d+=h + add w23,w23,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + add w8,w8,w14 + add w23,w23,w17 // h+=Sigma0(a) + add w8,w8,w13 + ldr w13,[sp,#8] + str w0,[sp,#4] + ror w16,w27,#6 + add w22,w22,w28 // h+=K[i] + ror w15,w10,#7 + and w17,w20,w27 + ror w14,w7,#17 + bic w28,w21,w27 + ror w0,w23,#2 + add w22,w22,w8 // h+=X[i] + eor w16,w16,w27,ror#11 + eor w15,w15,w10,ror#18 + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w23,w24 // a^b, b^c in next round + eor w16,w16,w27,ror#25 // Sigma1(e) + eor w0,w0,w23,ror#13 + add w22,w22,w17 // h+=Ch(e,f,g) + and w19,w19,w28 // (b^c)&=(a^b) + eor w14,w14,w7,ror#19 + eor w15,w15,w10,lsr#3 // sigma0(X[i+1]) + add w22,w22,w16 // h+=Sigma1(e) + eor w19,w19,w24 // Maj(a,b,c) + eor w17,w0,w23,ror#22 // Sigma0(a) + eor w14,w14,w7,lsr#10 // sigma1(X[i+14]) + add w9,w9,w2 + add w26,w26,w22 // d+=h + add w22,w22,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + add w9,w9,w15 + add w22,w22,w17 // h+=Sigma0(a) + add w9,w9,w14 + ldr w14,[sp,#12] + str w1,[sp,#8] + ror w16,w26,#6 + add w21,w21,w19 // h+=K[i] + ror w0,w11,#7 + and w17,w27,w26 + ror w15,w8,#17 + bic w19,w20,w26 + ror w1,w22,#2 + add w21,w21,w9 // h+=X[i] + eor w16,w16,w26,ror#11 + eor w0,w0,w11,ror#18 + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w22,w23 // a^b, b^c in next round + eor w16,w16,w26,ror#25 // Sigma1(e) + eor w1,w1,w22,ror#13 + add w21,w21,w17 // h+=Ch(e,f,g) + and w28,w28,w19 // (b^c)&=(a^b) + eor w15,w15,w8,ror#19 + eor w0,w0,w11,lsr#3 // sigma0(X[i+1]) + add w21,w21,w16 // h+=Sigma1(e) + eor w28,w28,w23 // Maj(a,b,c) + eor w17,w1,w22,ror#22 // Sigma0(a) + eor w15,w15,w8,lsr#10 // sigma1(X[i+14]) + add w10,w10,w3 + add w25,w25,w21 // d+=h + add w21,w21,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + add w10,w10,w0 + add w21,w21,w17 // h+=Sigma0(a) + add w10,w10,w15 + ldr w15,[sp,#0] + str w2,[sp,#12] + ror w16,w25,#6 + add w20,w20,w28 // h+=K[i] + ror w1,w12,#7 + and w17,w26,w25 + ror w0,w9,#17 + bic w28,w27,w25 + ror w2,w21,#2 + add w20,w20,w10 // h+=X[i] + eor w16,w16,w25,ror#11 + eor w1,w1,w12,ror#18 + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w21,w22 // a^b, b^c in next round + eor w16,w16,w25,ror#25 // Sigma1(e) + eor w2,w2,w21,ror#13 + add w20,w20,w17 // h+=Ch(e,f,g) + and w19,w19,w28 // (b^c)&=(a^b) + eor w0,w0,w9,ror#19 + eor w1,w1,w12,lsr#3 // sigma0(X[i+1]) + add w20,w20,w16 // h+=Sigma1(e) + eor w19,w19,w22 // Maj(a,b,c) + eor w17,w2,w21,ror#22 // Sigma0(a) + eor w0,w0,w9,lsr#10 // sigma1(X[i+14]) + add w11,w11,w4 + add w24,w24,w20 // d+=h + add w20,w20,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + add w11,w11,w1 + add w20,w20,w17 // h+=Sigma0(a) + add w11,w11,w0 + ldr w0,[sp,#4] + str w3,[sp,#0] + ror w16,w24,#6 + add w27,w27,w19 // h+=K[i] + ror w2,w13,#7 + and w17,w25,w24 + ror w1,w10,#17 + bic w19,w26,w24 + ror w3,w20,#2 + add w27,w27,w11 // h+=X[i] + eor w16,w16,w24,ror#11 + eor w2,w2,w13,ror#18 + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w20,w21 // a^b, b^c in next round + eor w16,w16,w24,ror#25 // Sigma1(e) + eor w3,w3,w20,ror#13 + add w27,w27,w17 // h+=Ch(e,f,g) + and w28,w28,w19 // (b^c)&=(a^b) + eor w1,w1,w10,ror#19 + eor w2,w2,w13,lsr#3 // sigma0(X[i+1]) + add w27,w27,w16 // h+=Sigma1(e) + eor w28,w28,w21 // Maj(a,b,c) + eor w17,w3,w20,ror#22 // Sigma0(a) + eor w1,w1,w10,lsr#10 // sigma1(X[i+14]) + add w12,w12,w5 + add w23,w23,w27 // d+=h + add w27,w27,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + add w12,w12,w2 + add w27,w27,w17 // h+=Sigma0(a) + add w12,w12,w1 + ldr w1,[sp,#8] + str w4,[sp,#4] + ror w16,w23,#6 + add w26,w26,w28 // h+=K[i] + ror w3,w14,#7 + and w17,w24,w23 + ror w2,w11,#17 + bic w28,w25,w23 + ror w4,w27,#2 + add w26,w26,w12 // h+=X[i] + eor w16,w16,w23,ror#11 + eor w3,w3,w14,ror#18 + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w27,w20 // a^b, b^c in next round + eor w16,w16,w23,ror#25 // Sigma1(e) + eor w4,w4,w27,ror#13 + add w26,w26,w17 // h+=Ch(e,f,g) + and w19,w19,w28 // (b^c)&=(a^b) + eor w2,w2,w11,ror#19 + eor w3,w3,w14,lsr#3 // sigma0(X[i+1]) + add w26,w26,w16 // h+=Sigma1(e) + eor w19,w19,w20 // Maj(a,b,c) + eor w17,w4,w27,ror#22 // Sigma0(a) + eor w2,w2,w11,lsr#10 // sigma1(X[i+14]) + add w13,w13,w6 + add w22,w22,w26 // d+=h + add w26,w26,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + add w13,w13,w3 + add w26,w26,w17 // h+=Sigma0(a) + add w13,w13,w2 + ldr w2,[sp,#12] + str w5,[sp,#8] + ror w16,w22,#6 + add w25,w25,w19 // h+=K[i] + ror w4,w15,#7 + and w17,w23,w22 + ror w3,w12,#17 + bic w19,w24,w22 + ror w5,w26,#2 + add w25,w25,w13 // h+=X[i] + eor w16,w16,w22,ror#11 + eor w4,w4,w15,ror#18 + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w26,w27 // a^b, b^c in next round + eor w16,w16,w22,ror#25 // Sigma1(e) + eor w5,w5,w26,ror#13 + add w25,w25,w17 // h+=Ch(e,f,g) + and w28,w28,w19 // (b^c)&=(a^b) + eor w3,w3,w12,ror#19 + eor w4,w4,w15,lsr#3 // sigma0(X[i+1]) + add w25,w25,w16 // h+=Sigma1(e) + eor w28,w28,w27 // Maj(a,b,c) + eor w17,w5,w26,ror#22 // Sigma0(a) + eor w3,w3,w12,lsr#10 // sigma1(X[i+14]) + add w14,w14,w7 + add w21,w21,w25 // d+=h + add w25,w25,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + add w14,w14,w4 + add w25,w25,w17 // h+=Sigma0(a) + add w14,w14,w3 + ldr w3,[sp,#0] + str w6,[sp,#12] + ror w16,w21,#6 + add w24,w24,w28 // h+=K[i] + ror w5,w0,#7 + and w17,w22,w21 + ror w4,w13,#17 + bic w28,w23,w21 + ror w6,w25,#2 + add w24,w24,w14 // h+=X[i] + eor w16,w16,w21,ror#11 + eor w5,w5,w0,ror#18 + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w25,w26 // a^b, b^c in next round + eor w16,w16,w21,ror#25 // Sigma1(e) + eor w6,w6,w25,ror#13 + add w24,w24,w17 // h+=Ch(e,f,g) + and w19,w19,w28 // (b^c)&=(a^b) + eor w4,w4,w13,ror#19 + eor w5,w5,w0,lsr#3 // sigma0(X[i+1]) + add w24,w24,w16 // h+=Sigma1(e) + eor w19,w19,w26 // Maj(a,b,c) + eor w17,w6,w25,ror#22 // Sigma0(a) + eor w4,w4,w13,lsr#10 // sigma1(X[i+14]) + add w15,w15,w8 + add w20,w20,w24 // d+=h + add w24,w24,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + add w15,w15,w5 + add w24,w24,w17 // h+=Sigma0(a) + add w15,w15,w4 + ldr w4,[sp,#4] + str w7,[sp,#0] + ror w16,w20,#6 + add w23,w23,w19 // h+=K[i] + ror w6,w1,#7 + and w17,w21,w20 + ror w5,w14,#17 + bic w19,w22,w20 + ror w7,w24,#2 + add w23,w23,w15 // h+=X[i] + eor w16,w16,w20,ror#11 + eor w6,w6,w1,ror#18 + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w24,w25 // a^b, b^c in next round + eor w16,w16,w20,ror#25 // Sigma1(e) + eor w7,w7,w24,ror#13 + add w23,w23,w17 // h+=Ch(e,f,g) + and w28,w28,w19 // (b^c)&=(a^b) + eor w5,w5,w14,ror#19 + eor w6,w6,w1,lsr#3 // sigma0(X[i+1]) + add w23,w23,w16 // h+=Sigma1(e) + eor w28,w28,w25 // Maj(a,b,c) + eor w17,w7,w24,ror#22 // Sigma0(a) + eor w5,w5,w14,lsr#10 // sigma1(X[i+14]) + add w0,w0,w9 + add w27,w27,w23 // d+=h + add w23,w23,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + add w0,w0,w6 + add w23,w23,w17 // h+=Sigma0(a) + add w0,w0,w5 + ldr w5,[sp,#8] + str w8,[sp,#4] + ror w16,w27,#6 + add w22,w22,w28 // h+=K[i] + ror w7,w2,#7 + and w17,w20,w27 + ror w6,w15,#17 + bic w28,w21,w27 + ror w8,w23,#2 + add w22,w22,w0 // h+=X[i] + eor w16,w16,w27,ror#11 + eor w7,w7,w2,ror#18 + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w23,w24 // a^b, b^c in next round + eor w16,w16,w27,ror#25 // Sigma1(e) + eor w8,w8,w23,ror#13 + add w22,w22,w17 // h+=Ch(e,f,g) + and w19,w19,w28 // (b^c)&=(a^b) + eor w6,w6,w15,ror#19 + eor w7,w7,w2,lsr#3 // sigma0(X[i+1]) + add w22,w22,w16 // h+=Sigma1(e) + eor w19,w19,w24 // Maj(a,b,c) + eor w17,w8,w23,ror#22 // Sigma0(a) + eor w6,w6,w15,lsr#10 // sigma1(X[i+14]) + add w1,w1,w10 + add w26,w26,w22 // d+=h + add w22,w22,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + add w1,w1,w7 + add w22,w22,w17 // h+=Sigma0(a) + add w1,w1,w6 + ldr w6,[sp,#12] + str w9,[sp,#8] + ror w16,w26,#6 + add w21,w21,w19 // h+=K[i] + ror w8,w3,#7 + and w17,w27,w26 + ror w7,w0,#17 + bic w19,w20,w26 + ror w9,w22,#2 + add w21,w21,w1 // h+=X[i] + eor w16,w16,w26,ror#11 + eor w8,w8,w3,ror#18 + orr w17,w17,w19 // Ch(e,f,g) + eor w19,w22,w23 // a^b, b^c in next round + eor w16,w16,w26,ror#25 // Sigma1(e) + eor w9,w9,w22,ror#13 + add w21,w21,w17 // h+=Ch(e,f,g) + and w28,w28,w19 // (b^c)&=(a^b) + eor w7,w7,w0,ror#19 + eor w8,w8,w3,lsr#3 // sigma0(X[i+1]) + add w21,w21,w16 // h+=Sigma1(e) + eor w28,w28,w23 // Maj(a,b,c) + eor w17,w9,w22,ror#22 // Sigma0(a) + eor w7,w7,w0,lsr#10 // sigma1(X[i+14]) + add w2,w2,w11 + add w25,w25,w21 // d+=h + add w21,w21,w28 // h+=Maj(a,b,c) + ldr w28,[x30],#4 // *K++, w19 in next round + add w2,w2,w8 + add w21,w21,w17 // h+=Sigma0(a) + add w2,w2,w7 + ldr w7,[sp,#0] + str w10,[sp,#12] + ror w16,w25,#6 + add w20,w20,w28 // h+=K[i] + ror w9,w4,#7 + and w17,w26,w25 + ror w8,w1,#17 + bic w28,w27,w25 + ror w10,w21,#2 + add w20,w20,w2 // h+=X[i] + eor w16,w16,w25,ror#11 + eor w9,w9,w4,ror#18 + orr w17,w17,w28 // Ch(e,f,g) + eor w28,w21,w22 // a^b, b^c in next round + eor w16,w16,w25,ror#25 // Sigma1(e) + eor w10,w10,w21,ror#13 + add w20,w20,w17 // h+=Ch(e,f,g) + and w19,w19,w28 // (b^c)&=(a^b) + eor w8,w8,w1,ror#19 + eor w9,w9,w4,lsr#3 // sigma0(X[i+1]) + add w20,w20,w16 // h+=Sigma1(e) + eor w19,w19,w22 // Maj(a,b,c) + eor w17,w10,w21,ror#22 // Sigma0(a) + eor w8,w8,w1,lsr#10 // sigma1(X[i+14]) + add w3,w3,w12 + add w24,w24,w20 // d+=h + add w20,w20,w19 // h+=Maj(a,b,c) + ldr w19,[x30],#4 // *K++, w28 in next round + add w3,w3,w9 + add w20,w20,w17 // h+=Sigma0(a) + add w3,w3,w8 + cbnz w19,Loop_16_xx + + ldp x0,x2,[x29,#96] + ldr x1,[x29,#112] + sub x30,x30,#260 // rewind + + ldp w3,w4,[x0] + ldp w5,w6,[x0,#2*4] + add x1,x1,#14*4 // advance input pointer + ldp w7,w8,[x0,#4*4] + add w20,w20,w3 + ldp w9,w10,[x0,#6*4] + add w21,w21,w4 + add w22,w22,w5 + add w23,w23,w6 + stp w20,w21,[x0] + add w24,w24,w7 + add w25,w25,w8 + stp w22,w23,[x0,#2*4] + add w26,w26,w9 + add w27,w27,w10 + cmp x1,x2 + stp w24,w25,[x0,#4*4] + stp w26,w27,[x0,#6*4] + b.ne Loop + + ldp x19,x20,[x29,#16] + add sp,sp,#4*4 + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldp x29,x30,[sp],#128 + AARCH64_VALIDATE_LINK_REGISTER + ret + + +.section .rodata +.align 6 + +LK256: +.long 0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5 +.long 0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5 +.long 0xd807aa98,0x12835b01,0x243185be,0x550c7dc3 +.long 0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174 +.long 0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc +.long 0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da +.long 0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7 +.long 0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967 +.long 0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13 +.long 0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85 +.long 0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3 +.long 0xd192e819,0xd6990624,0xf40e3585,0x106aa070 +.long 0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5 +.long 0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3 +.long 0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208 +.long 0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2 +.long 0 //terminator + +.byte 83,72,65,50,53,54,32,98,108,111,99,107,32,116,114,97,110,115,102,111,114,109,32,102,111,114,32,65,82,77,118,56,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.align 2 +.align 2 +.text +#ifndef __KERNEL__ +.globl sha256_block_data_order_hw + +.def sha256_block_data_order_hw + .type 32 +.endef +.align 6 +sha256_block_data_order_hw: + // Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later. + AARCH64_VALID_CALL_TARGET + stp x29,x30,[sp,#-16]! + add x29,sp,#0 + + ld1 {v0.4s,v1.4s},[x0] + adrp x3,LK256 + add x3,x3,:lo12:LK256 + +Loop_hw: + ld1 {v4.16b,v5.16b,v6.16b,v7.16b},[x1],#64 + sub x2,x2,#1 + ld1 {v16.4s},[x3],#16 + rev32 v4.16b,v4.16b + rev32 v5.16b,v5.16b + rev32 v6.16b,v6.16b + rev32 v7.16b,v7.16b + orr v18.16b,v0.16b,v0.16b // offload + orr v19.16b,v1.16b,v1.16b + ld1 {v17.4s},[x3],#16 + add v16.4s,v16.4s,v4.4s +.long 0x5e2828a4 //sha256su0 v4.16b,v5.16b + orr v2.16b,v0.16b,v0.16b +.long 0x5e104020 //sha256h v0.16b,v1.16b,v16.4s +.long 0x5e105041 //sha256h2 v1.16b,v2.16b,v16.4s +.long 0x5e0760c4 //sha256su1 v4.16b,v6.16b,v7.16b + ld1 {v16.4s},[x3],#16 + add v17.4s,v17.4s,v5.4s +.long 0x5e2828c5 //sha256su0 v5.16b,v6.16b + orr v2.16b,v0.16b,v0.16b +.long 0x5e114020 //sha256h v0.16b,v1.16b,v17.4s +.long 0x5e115041 //sha256h2 v1.16b,v2.16b,v17.4s +.long 0x5e0460e5 //sha256su1 v5.16b,v7.16b,v4.16b + ld1 {v17.4s},[x3],#16 + add v16.4s,v16.4s,v6.4s +.long 0x5e2828e6 //sha256su0 v6.16b,v7.16b + orr v2.16b,v0.16b,v0.16b +.long 0x5e104020 //sha256h v0.16b,v1.16b,v16.4s +.long 0x5e105041 //sha256h2 v1.16b,v2.16b,v16.4s +.long 0x5e056086 //sha256su1 v6.16b,v4.16b,v5.16b + ld1 {v16.4s},[x3],#16 + add v17.4s,v17.4s,v7.4s +.long 0x5e282887 //sha256su0 v7.16b,v4.16b + orr v2.16b,v0.16b,v0.16b +.long 0x5e114020 //sha256h v0.16b,v1.16b,v17.4s +.long 0x5e115041 //sha256h2 v1.16b,v2.16b,v17.4s +.long 0x5e0660a7 //sha256su1 v7.16b,v5.16b,v6.16b + ld1 {v17.4s},[x3],#16 + add v16.4s,v16.4s,v4.4s +.long 0x5e2828a4 //sha256su0 v4.16b,v5.16b + orr v2.16b,v0.16b,v0.16b +.long 0x5e104020 //sha256h v0.16b,v1.16b,v16.4s +.long 0x5e105041 //sha256h2 v1.16b,v2.16b,v16.4s +.long 0x5e0760c4 //sha256su1 v4.16b,v6.16b,v7.16b + ld1 {v16.4s},[x3],#16 + add v17.4s,v17.4s,v5.4s +.long 0x5e2828c5 //sha256su0 v5.16b,v6.16b + orr v2.16b,v0.16b,v0.16b +.long 0x5e114020 //sha256h v0.16b,v1.16b,v17.4s +.long 0x5e115041 //sha256h2 v1.16b,v2.16b,v17.4s +.long 0x5e0460e5 //sha256su1 v5.16b,v7.16b,v4.16b + ld1 {v17.4s},[x3],#16 + add v16.4s,v16.4s,v6.4s +.long 0x5e2828e6 //sha256su0 v6.16b,v7.16b + orr v2.16b,v0.16b,v0.16b +.long 0x5e104020 //sha256h v0.16b,v1.16b,v16.4s +.long 0x5e105041 //sha256h2 v1.16b,v2.16b,v16.4s +.long 0x5e056086 //sha256su1 v6.16b,v4.16b,v5.16b + ld1 {v16.4s},[x3],#16 + add v17.4s,v17.4s,v7.4s +.long 0x5e282887 //sha256su0 v7.16b,v4.16b + orr v2.16b,v0.16b,v0.16b +.long 0x5e114020 //sha256h v0.16b,v1.16b,v17.4s +.long 0x5e115041 //sha256h2 v1.16b,v2.16b,v17.4s +.long 0x5e0660a7 //sha256su1 v7.16b,v5.16b,v6.16b + ld1 {v17.4s},[x3],#16 + add v16.4s,v16.4s,v4.4s +.long 0x5e2828a4 //sha256su0 v4.16b,v5.16b + orr v2.16b,v0.16b,v0.16b +.long 0x5e104020 //sha256h v0.16b,v1.16b,v16.4s +.long 0x5e105041 //sha256h2 v1.16b,v2.16b,v16.4s +.long 0x5e0760c4 //sha256su1 v4.16b,v6.16b,v7.16b + ld1 {v16.4s},[x3],#16 + add v17.4s,v17.4s,v5.4s +.long 0x5e2828c5 //sha256su0 v5.16b,v6.16b + orr v2.16b,v0.16b,v0.16b +.long 0x5e114020 //sha256h v0.16b,v1.16b,v17.4s +.long 0x5e115041 //sha256h2 v1.16b,v2.16b,v17.4s +.long 0x5e0460e5 //sha256su1 v5.16b,v7.16b,v4.16b + ld1 {v17.4s},[x3],#16 + add v16.4s,v16.4s,v6.4s +.long 0x5e2828e6 //sha256su0 v6.16b,v7.16b + orr v2.16b,v0.16b,v0.16b +.long 0x5e104020 //sha256h v0.16b,v1.16b,v16.4s +.long 0x5e105041 //sha256h2 v1.16b,v2.16b,v16.4s +.long 0x5e056086 //sha256su1 v6.16b,v4.16b,v5.16b + ld1 {v16.4s},[x3],#16 + add v17.4s,v17.4s,v7.4s +.long 0x5e282887 //sha256su0 v7.16b,v4.16b + orr v2.16b,v0.16b,v0.16b +.long 0x5e114020 //sha256h v0.16b,v1.16b,v17.4s +.long 0x5e115041 //sha256h2 v1.16b,v2.16b,v17.4s +.long 0x5e0660a7 //sha256su1 v7.16b,v5.16b,v6.16b + ld1 {v17.4s},[x3],#16 + add v16.4s,v16.4s,v4.4s + orr v2.16b,v0.16b,v0.16b +.long 0x5e104020 //sha256h v0.16b,v1.16b,v16.4s +.long 0x5e105041 //sha256h2 v1.16b,v2.16b,v16.4s + + ld1 {v16.4s},[x3],#16 + add v17.4s,v17.4s,v5.4s + orr v2.16b,v0.16b,v0.16b +.long 0x5e114020 //sha256h v0.16b,v1.16b,v17.4s +.long 0x5e115041 //sha256h2 v1.16b,v2.16b,v17.4s + + ld1 {v17.4s},[x3] + add v16.4s,v16.4s,v6.4s + sub x3,x3,#64*4-16 // rewind + orr v2.16b,v0.16b,v0.16b +.long 0x5e104020 //sha256h v0.16b,v1.16b,v16.4s +.long 0x5e105041 //sha256h2 v1.16b,v2.16b,v16.4s + + add v17.4s,v17.4s,v7.4s + orr v2.16b,v0.16b,v0.16b +.long 0x5e114020 //sha256h v0.16b,v1.16b,v17.4s +.long 0x5e115041 //sha256h2 v1.16b,v2.16b,v17.4s + + add v0.4s,v0.4s,v18.4s + add v1.4s,v1.4s,v19.4s + + cbnz x2,Loop_hw + + st1 {v0.4s,v1.4s},[x0] + + ldr x29,[sp],#16 + ret + +#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(_WIN32) diff --git a/http/vendor/ring/pregenerated/sha256-x86_64-elf.S b/http/vendor/ring/pregenerated/sha256-x86_64-elf.S new file mode 100644 index 0000000..c800f8e --- /dev/null +++ b/http/vendor/ring/pregenerated/sha256-x86_64-elf.S @@ -0,0 +1,4170 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__) +.text + +.globl sha256_block_data_order_nohw +.hidden sha256_block_data_order_nohw +.type sha256_block_data_order_nohw,@function +.align 16 +sha256_block_data_order_nohw: +.cfi_startproc +_CET_ENDBR + movq %rsp,%rax +.cfi_def_cfa_register %rax + pushq %rbx +.cfi_offset %rbx,-16 + pushq %rbp +.cfi_offset %rbp,-24 + pushq %r12 +.cfi_offset %r12,-32 + pushq %r13 +.cfi_offset %r13,-40 + pushq %r14 +.cfi_offset %r14,-48 + pushq %r15 +.cfi_offset %r15,-56 + shlq $4,%rdx + subq $64+32,%rsp + leaq (%rsi,%rdx,4),%rdx + andq $-64,%rsp + movq %rdi,64+0(%rsp) + movq %rsi,64+8(%rsp) + movq %rdx,64+16(%rsp) + movq %rax,88(%rsp) +.cfi_escape 0x0f,0x06,0x77,0xd8,0x00,0x06,0x23,0x08 +.Lprologue: + + movl 0(%rdi),%eax + movl 4(%rdi),%ebx + movl 8(%rdi),%ecx + movl 12(%rdi),%edx + movl 16(%rdi),%r8d + movl 20(%rdi),%r9d + movl 24(%rdi),%r10d + movl 28(%rdi),%r11d + jmp .Lloop + +.align 16 +.Lloop: + movl %ebx,%edi + leaq K256(%rip),%rbp + xorl %ecx,%edi + movl 0(%rsi),%r12d + movl %r8d,%r13d + movl %eax,%r14d + bswapl %r12d + rorl $14,%r13d + movl %r9d,%r15d + + xorl %r8d,%r13d + rorl $9,%r14d + xorl %r10d,%r15d + + movl %r12d,0(%rsp) + xorl %eax,%r14d + andl %r8d,%r15d + + rorl $5,%r13d + addl %r11d,%r12d + xorl %r10d,%r15d + + rorl $11,%r14d + xorl %r8d,%r13d + addl %r15d,%r12d + + movl %eax,%r15d + addl (%rbp),%r12d + xorl %eax,%r14d + + xorl %ebx,%r15d + rorl $6,%r13d + movl %ebx,%r11d + + andl %r15d,%edi + rorl $2,%r14d + addl %r13d,%r12d + + xorl %edi,%r11d + addl %r12d,%edx + addl %r12d,%r11d + + leaq 4(%rbp),%rbp + addl %r14d,%r11d + movl 4(%rsi),%r12d + movl %edx,%r13d + movl %r11d,%r14d + bswapl %r12d + rorl $14,%r13d + movl %r8d,%edi + + xorl %edx,%r13d + rorl $9,%r14d + xorl %r9d,%edi + + movl %r12d,4(%rsp) + xorl %r11d,%r14d + andl %edx,%edi + + rorl $5,%r13d + addl %r10d,%r12d + xorl %r9d,%edi + + rorl $11,%r14d + xorl %edx,%r13d + addl %edi,%r12d + + movl %r11d,%edi + addl (%rbp),%r12d + xorl %r11d,%r14d + + xorl %eax,%edi + rorl $6,%r13d + movl %eax,%r10d + + andl %edi,%r15d + rorl $2,%r14d + addl %r13d,%r12d + + xorl %r15d,%r10d + addl %r12d,%ecx + addl %r12d,%r10d + + leaq 4(%rbp),%rbp + addl %r14d,%r10d + movl 8(%rsi),%r12d + movl %ecx,%r13d + movl %r10d,%r14d + bswapl %r12d + rorl $14,%r13d + movl %edx,%r15d + + xorl %ecx,%r13d + rorl $9,%r14d + xorl %r8d,%r15d + + movl %r12d,8(%rsp) + xorl %r10d,%r14d + andl %ecx,%r15d + + rorl $5,%r13d + addl %r9d,%r12d + xorl %r8d,%r15d + + rorl $11,%r14d + xorl %ecx,%r13d + addl %r15d,%r12d + + movl %r10d,%r15d + addl (%rbp),%r12d + xorl %r10d,%r14d + + xorl %r11d,%r15d + rorl $6,%r13d + movl %r11d,%r9d + + andl %r15d,%edi + rorl $2,%r14d + addl %r13d,%r12d + + xorl %edi,%r9d + addl %r12d,%ebx + addl %r12d,%r9d + + leaq 4(%rbp),%rbp + addl %r14d,%r9d + movl 12(%rsi),%r12d + movl %ebx,%r13d + movl %r9d,%r14d + bswapl %r12d + rorl $14,%r13d + movl %ecx,%edi + + xorl %ebx,%r13d + rorl $9,%r14d + xorl %edx,%edi + + movl %r12d,12(%rsp) + xorl %r9d,%r14d + andl %ebx,%edi + + rorl $5,%r13d + addl %r8d,%r12d + xorl %edx,%edi + + rorl $11,%r14d + xorl %ebx,%r13d + addl %edi,%r12d + + movl %r9d,%edi + addl (%rbp),%r12d + xorl %r9d,%r14d + + xorl %r10d,%edi + rorl $6,%r13d + movl %r10d,%r8d + + andl %edi,%r15d + rorl $2,%r14d + addl %r13d,%r12d + + xorl %r15d,%r8d + addl %r12d,%eax + addl %r12d,%r8d + + leaq 20(%rbp),%rbp + addl %r14d,%r8d + movl 16(%rsi),%r12d + movl %eax,%r13d + movl %r8d,%r14d + bswapl %r12d + rorl $14,%r13d + movl %ebx,%r15d + + xorl %eax,%r13d + rorl $9,%r14d + xorl %ecx,%r15d + + movl %r12d,16(%rsp) + xorl %r8d,%r14d + andl %eax,%r15d + + rorl $5,%r13d + addl %edx,%r12d + xorl %ecx,%r15d + + rorl $11,%r14d + xorl %eax,%r13d + addl %r15d,%r12d + + movl %r8d,%r15d + addl (%rbp),%r12d + xorl %r8d,%r14d + + xorl %r9d,%r15d + rorl $6,%r13d + movl %r9d,%edx + + andl %r15d,%edi + rorl $2,%r14d + addl %r13d,%r12d + + xorl %edi,%edx + addl %r12d,%r11d + addl %r12d,%edx + + leaq 4(%rbp),%rbp + addl %r14d,%edx + movl 20(%rsi),%r12d + movl %r11d,%r13d + movl %edx,%r14d + bswapl %r12d + rorl $14,%r13d + movl %eax,%edi + + xorl %r11d,%r13d + rorl $9,%r14d + xorl %ebx,%edi + + movl %r12d,20(%rsp) + xorl %edx,%r14d + andl %r11d,%edi + + rorl $5,%r13d + addl %ecx,%r12d + xorl %ebx,%edi + + rorl $11,%r14d + xorl %r11d,%r13d + addl %edi,%r12d + + movl %edx,%edi + addl (%rbp),%r12d + xorl %edx,%r14d + + xorl %r8d,%edi + rorl $6,%r13d + movl %r8d,%ecx + + andl %edi,%r15d + rorl $2,%r14d + addl %r13d,%r12d + + xorl %r15d,%ecx + addl %r12d,%r10d + addl %r12d,%ecx + + leaq 4(%rbp),%rbp + addl %r14d,%ecx + movl 24(%rsi),%r12d + movl %r10d,%r13d + movl %ecx,%r14d + bswapl %r12d + rorl $14,%r13d + movl %r11d,%r15d + + xorl %r10d,%r13d + rorl $9,%r14d + xorl %eax,%r15d + + movl %r12d,24(%rsp) + xorl %ecx,%r14d + andl %r10d,%r15d + + rorl $5,%r13d + addl %ebx,%r12d + xorl %eax,%r15d + + rorl $11,%r14d + xorl %r10d,%r13d + addl %r15d,%r12d + + movl %ecx,%r15d + addl (%rbp),%r12d + xorl %ecx,%r14d + + xorl %edx,%r15d + rorl $6,%r13d + movl %edx,%ebx + + andl %r15d,%edi + rorl $2,%r14d + addl %r13d,%r12d + + xorl %edi,%ebx + addl %r12d,%r9d + addl %r12d,%ebx + + leaq 4(%rbp),%rbp + addl %r14d,%ebx + movl 28(%rsi),%r12d + movl %r9d,%r13d + movl %ebx,%r14d + bswapl %r12d + rorl $14,%r13d + movl %r10d,%edi + + xorl %r9d,%r13d + rorl $9,%r14d + xorl %r11d,%edi + + movl %r12d,28(%rsp) + xorl %ebx,%r14d + andl %r9d,%edi + + rorl $5,%r13d + addl %eax,%r12d + xorl %r11d,%edi + + rorl $11,%r14d + xorl %r9d,%r13d + addl %edi,%r12d + + movl %ebx,%edi + addl (%rbp),%r12d + xorl %ebx,%r14d + + xorl %ecx,%edi + rorl $6,%r13d + movl %ecx,%eax + + andl %edi,%r15d + rorl $2,%r14d + addl %r13d,%r12d + + xorl %r15d,%eax + addl %r12d,%r8d + addl %r12d,%eax + + leaq 20(%rbp),%rbp + addl %r14d,%eax + movl 32(%rsi),%r12d + movl %r8d,%r13d + movl %eax,%r14d + bswapl %r12d + rorl $14,%r13d + movl %r9d,%r15d + + xorl %r8d,%r13d + rorl $9,%r14d + xorl %r10d,%r15d + + movl %r12d,32(%rsp) + xorl %eax,%r14d + andl %r8d,%r15d + + rorl $5,%r13d + addl %r11d,%r12d + xorl %r10d,%r15d + + rorl $11,%r14d + xorl %r8d,%r13d + addl %r15d,%r12d + + movl %eax,%r15d + addl (%rbp),%r12d + xorl %eax,%r14d + + xorl %ebx,%r15d + rorl $6,%r13d + movl %ebx,%r11d + + andl %r15d,%edi + rorl $2,%r14d + addl %r13d,%r12d + + xorl %edi,%r11d + addl %r12d,%edx + addl %r12d,%r11d + + leaq 4(%rbp),%rbp + addl %r14d,%r11d + movl 36(%rsi),%r12d + movl %edx,%r13d + movl %r11d,%r14d + bswapl %r12d + rorl $14,%r13d + movl %r8d,%edi + + xorl %edx,%r13d + rorl $9,%r14d + xorl %r9d,%edi + + movl %r12d,36(%rsp) + xorl %r11d,%r14d + andl %edx,%edi + + rorl $5,%r13d + addl %r10d,%r12d + xorl %r9d,%edi + + rorl $11,%r14d + xorl %edx,%r13d + addl %edi,%r12d + + movl %r11d,%edi + addl (%rbp),%r12d + xorl %r11d,%r14d + + xorl %eax,%edi + rorl $6,%r13d + movl %eax,%r10d + + andl %edi,%r15d + rorl $2,%r14d + addl %r13d,%r12d + + xorl %r15d,%r10d + addl %r12d,%ecx + addl %r12d,%r10d + + leaq 4(%rbp),%rbp + addl %r14d,%r10d + movl 40(%rsi),%r12d + movl %ecx,%r13d + movl %r10d,%r14d + bswapl %r12d + rorl $14,%r13d + movl %edx,%r15d + + xorl %ecx,%r13d + rorl $9,%r14d + xorl %r8d,%r15d + + movl %r12d,40(%rsp) + xorl %r10d,%r14d + andl %ecx,%r15d + + rorl $5,%r13d + addl %r9d,%r12d + xorl %r8d,%r15d + + rorl $11,%r14d + xorl %ecx,%r13d + addl %r15d,%r12d + + movl %r10d,%r15d + addl (%rbp),%r12d + xorl %r10d,%r14d + + xorl %r11d,%r15d + rorl $6,%r13d + movl %r11d,%r9d + + andl %r15d,%edi + rorl $2,%r14d + addl %r13d,%r12d + + xorl %edi,%r9d + addl %r12d,%ebx + addl %r12d,%r9d + + leaq 4(%rbp),%rbp + addl %r14d,%r9d + movl 44(%rsi),%r12d + movl %ebx,%r13d + movl %r9d,%r14d + bswapl %r12d + rorl $14,%r13d + movl %ecx,%edi + + xorl %ebx,%r13d + rorl $9,%r14d + xorl %edx,%edi + + movl %r12d,44(%rsp) + xorl %r9d,%r14d + andl %ebx,%edi + + rorl $5,%r13d + addl %r8d,%r12d + xorl %edx,%edi + + rorl $11,%r14d + xorl %ebx,%r13d + addl %edi,%r12d + + movl %r9d,%edi + addl (%rbp),%r12d + xorl %r9d,%r14d + + xorl %r10d,%edi + rorl $6,%r13d + movl %r10d,%r8d + + andl %edi,%r15d + rorl $2,%r14d + addl %r13d,%r12d + + xorl %r15d,%r8d + addl %r12d,%eax + addl %r12d,%r8d + + leaq 20(%rbp),%rbp + addl %r14d,%r8d + movl 48(%rsi),%r12d + movl %eax,%r13d + movl %r8d,%r14d + bswapl %r12d + rorl $14,%r13d + movl %ebx,%r15d + + xorl %eax,%r13d + rorl $9,%r14d + xorl %ecx,%r15d + + movl %r12d,48(%rsp) + xorl %r8d,%r14d + andl %eax,%r15d + + rorl $5,%r13d + addl %edx,%r12d + xorl %ecx,%r15d + + rorl $11,%r14d + xorl %eax,%r13d + addl %r15d,%r12d + + movl %r8d,%r15d + addl (%rbp),%r12d + xorl %r8d,%r14d + + xorl %r9d,%r15d + rorl $6,%r13d + movl %r9d,%edx + + andl %r15d,%edi + rorl $2,%r14d + addl %r13d,%r12d + + xorl %edi,%edx + addl %r12d,%r11d + addl %r12d,%edx + + leaq 4(%rbp),%rbp + addl %r14d,%edx + movl 52(%rsi),%r12d + movl %r11d,%r13d + movl %edx,%r14d + bswapl %r12d + rorl $14,%r13d + movl %eax,%edi + + xorl %r11d,%r13d + rorl $9,%r14d + xorl %ebx,%edi + + movl %r12d,52(%rsp) + xorl %edx,%r14d + andl %r11d,%edi + + rorl $5,%r13d + addl %ecx,%r12d + xorl %ebx,%edi + + rorl $11,%r14d + xorl %r11d,%r13d + addl %edi,%r12d + + movl %edx,%edi + addl (%rbp),%r12d + xorl %edx,%r14d + + xorl %r8d,%edi + rorl $6,%r13d + movl %r8d,%ecx + + andl %edi,%r15d + rorl $2,%r14d + addl %r13d,%r12d + + xorl %r15d,%ecx + addl %r12d,%r10d + addl %r12d,%ecx + + leaq 4(%rbp),%rbp + addl %r14d,%ecx + movl 56(%rsi),%r12d + movl %r10d,%r13d + movl %ecx,%r14d + bswapl %r12d + rorl $14,%r13d + movl %r11d,%r15d + + xorl %r10d,%r13d + rorl $9,%r14d + xorl %eax,%r15d + + movl %r12d,56(%rsp) + xorl %ecx,%r14d + andl %r10d,%r15d + + rorl $5,%r13d + addl %ebx,%r12d + xorl %eax,%r15d + + rorl $11,%r14d + xorl %r10d,%r13d + addl %r15d,%r12d + + movl %ecx,%r15d + addl (%rbp),%r12d + xorl %ecx,%r14d + + xorl %edx,%r15d + rorl $6,%r13d + movl %edx,%ebx + + andl %r15d,%edi + rorl $2,%r14d + addl %r13d,%r12d + + xorl %edi,%ebx + addl %r12d,%r9d + addl %r12d,%ebx + + leaq 4(%rbp),%rbp + addl %r14d,%ebx + movl 60(%rsi),%r12d + movl %r9d,%r13d + movl %ebx,%r14d + bswapl %r12d + rorl $14,%r13d + movl %r10d,%edi + + xorl %r9d,%r13d + rorl $9,%r14d + xorl %r11d,%edi + + movl %r12d,60(%rsp) + xorl %ebx,%r14d + andl %r9d,%edi + + rorl $5,%r13d + addl %eax,%r12d + xorl %r11d,%edi + + rorl $11,%r14d + xorl %r9d,%r13d + addl %edi,%r12d + + movl %ebx,%edi + addl (%rbp),%r12d + xorl %ebx,%r14d + + xorl %ecx,%edi + rorl $6,%r13d + movl %ecx,%eax + + andl %edi,%r15d + rorl $2,%r14d + addl %r13d,%r12d + + xorl %r15d,%eax + addl %r12d,%r8d + addl %r12d,%eax + + leaq 20(%rbp),%rbp + jmp .Lrounds_16_xx +.align 16 +.Lrounds_16_xx: + movl 4(%rsp),%r13d + movl 56(%rsp),%r15d + + movl %r13d,%r12d + rorl $11,%r13d + addl %r14d,%eax + movl %r15d,%r14d + rorl $2,%r15d + + xorl %r12d,%r13d + shrl $3,%r12d + rorl $7,%r13d + xorl %r14d,%r15d + shrl $10,%r14d + + rorl $17,%r15d + xorl %r13d,%r12d + xorl %r14d,%r15d + addl 36(%rsp),%r12d + + addl 0(%rsp),%r12d + movl %r8d,%r13d + addl %r15d,%r12d + movl %eax,%r14d + rorl $14,%r13d + movl %r9d,%r15d + + xorl %r8d,%r13d + rorl $9,%r14d + xorl %r10d,%r15d + + movl %r12d,0(%rsp) + xorl %eax,%r14d + andl %r8d,%r15d + + rorl $5,%r13d + addl %r11d,%r12d + xorl %r10d,%r15d + + rorl $11,%r14d + xorl %r8d,%r13d + addl %r15d,%r12d + + movl %eax,%r15d + addl (%rbp),%r12d + xorl %eax,%r14d + + xorl %ebx,%r15d + rorl $6,%r13d + movl %ebx,%r11d + + andl %r15d,%edi + rorl $2,%r14d + addl %r13d,%r12d + + xorl %edi,%r11d + addl %r12d,%edx + addl %r12d,%r11d + + leaq 4(%rbp),%rbp + movl 8(%rsp),%r13d + movl 60(%rsp),%edi + + movl %r13d,%r12d + rorl $11,%r13d + addl %r14d,%r11d + movl %edi,%r14d + rorl $2,%edi + + xorl %r12d,%r13d + shrl $3,%r12d + rorl $7,%r13d + xorl %r14d,%edi + shrl $10,%r14d + + rorl $17,%edi + xorl %r13d,%r12d + xorl %r14d,%edi + addl 40(%rsp),%r12d + + addl 4(%rsp),%r12d + movl %edx,%r13d + addl %edi,%r12d + movl %r11d,%r14d + rorl $14,%r13d + movl %r8d,%edi + + xorl %edx,%r13d + rorl $9,%r14d + xorl %r9d,%edi + + movl %r12d,4(%rsp) + xorl %r11d,%r14d + andl %edx,%edi + + rorl $5,%r13d + addl %r10d,%r12d + xorl %r9d,%edi + + rorl $11,%r14d + xorl %edx,%r13d + addl %edi,%r12d + + movl %r11d,%edi + addl (%rbp),%r12d + xorl %r11d,%r14d + + xorl %eax,%edi + rorl $6,%r13d + movl %eax,%r10d + + andl %edi,%r15d + rorl $2,%r14d + addl %r13d,%r12d + + xorl %r15d,%r10d + addl %r12d,%ecx + addl %r12d,%r10d + + leaq 4(%rbp),%rbp + movl 12(%rsp),%r13d + movl 0(%rsp),%r15d + + movl %r13d,%r12d + rorl $11,%r13d + addl %r14d,%r10d + movl %r15d,%r14d + rorl $2,%r15d + + xorl %r12d,%r13d + shrl $3,%r12d + rorl $7,%r13d + xorl %r14d,%r15d + shrl $10,%r14d + + rorl $17,%r15d + xorl %r13d,%r12d + xorl %r14d,%r15d + addl 44(%rsp),%r12d + + addl 8(%rsp),%r12d + movl %ecx,%r13d + addl %r15d,%r12d + movl %r10d,%r14d + rorl $14,%r13d + movl %edx,%r15d + + xorl %ecx,%r13d + rorl $9,%r14d + xorl %r8d,%r15d + + movl %r12d,8(%rsp) + xorl %r10d,%r14d + andl %ecx,%r15d + + rorl $5,%r13d + addl %r9d,%r12d + xorl %r8d,%r15d + + rorl $11,%r14d + xorl %ecx,%r13d + addl %r15d,%r12d + + movl %r10d,%r15d + addl (%rbp),%r12d + xorl %r10d,%r14d + + xorl %r11d,%r15d + rorl $6,%r13d + movl %r11d,%r9d + + andl %r15d,%edi + rorl $2,%r14d + addl %r13d,%r12d + + xorl %edi,%r9d + addl %r12d,%ebx + addl %r12d,%r9d + + leaq 4(%rbp),%rbp + movl 16(%rsp),%r13d + movl 4(%rsp),%edi + + movl %r13d,%r12d + rorl $11,%r13d + addl %r14d,%r9d + movl %edi,%r14d + rorl $2,%edi + + xorl %r12d,%r13d + shrl $3,%r12d + rorl $7,%r13d + xorl %r14d,%edi + shrl $10,%r14d + + rorl $17,%edi + xorl %r13d,%r12d + xorl %r14d,%edi + addl 48(%rsp),%r12d + + addl 12(%rsp),%r12d + movl %ebx,%r13d + addl %edi,%r12d + movl %r9d,%r14d + rorl $14,%r13d + movl %ecx,%edi + + xorl %ebx,%r13d + rorl $9,%r14d + xorl %edx,%edi + + movl %r12d,12(%rsp) + xorl %r9d,%r14d + andl %ebx,%edi + + rorl $5,%r13d + addl %r8d,%r12d + xorl %edx,%edi + + rorl $11,%r14d + xorl %ebx,%r13d + addl %edi,%r12d + + movl %r9d,%edi + addl (%rbp),%r12d + xorl %r9d,%r14d + + xorl %r10d,%edi + rorl $6,%r13d + movl %r10d,%r8d + + andl %edi,%r15d + rorl $2,%r14d + addl %r13d,%r12d + + xorl %r15d,%r8d + addl %r12d,%eax + addl %r12d,%r8d + + leaq 20(%rbp),%rbp + movl 20(%rsp),%r13d + movl 8(%rsp),%r15d + + movl %r13d,%r12d + rorl $11,%r13d + addl %r14d,%r8d + movl %r15d,%r14d + rorl $2,%r15d + + xorl %r12d,%r13d + shrl $3,%r12d + rorl $7,%r13d + xorl %r14d,%r15d + shrl $10,%r14d + + rorl $17,%r15d + xorl %r13d,%r12d + xorl %r14d,%r15d + addl 52(%rsp),%r12d + + addl 16(%rsp),%r12d + movl %eax,%r13d + addl %r15d,%r12d + movl %r8d,%r14d + rorl $14,%r13d + movl %ebx,%r15d + + xorl %eax,%r13d + rorl $9,%r14d + xorl %ecx,%r15d + + movl %r12d,16(%rsp) + xorl %r8d,%r14d + andl %eax,%r15d + + rorl $5,%r13d + addl %edx,%r12d + xorl %ecx,%r15d + + rorl $11,%r14d + xorl %eax,%r13d + addl %r15d,%r12d + + movl %r8d,%r15d + addl (%rbp),%r12d + xorl %r8d,%r14d + + xorl %r9d,%r15d + rorl $6,%r13d + movl %r9d,%edx + + andl %r15d,%edi + rorl $2,%r14d + addl %r13d,%r12d + + xorl %edi,%edx + addl %r12d,%r11d + addl %r12d,%edx + + leaq 4(%rbp),%rbp + movl 24(%rsp),%r13d + movl 12(%rsp),%edi + + movl %r13d,%r12d + rorl $11,%r13d + addl %r14d,%edx + movl %edi,%r14d + rorl $2,%edi + + xorl %r12d,%r13d + shrl $3,%r12d + rorl $7,%r13d + xorl %r14d,%edi + shrl $10,%r14d + + rorl $17,%edi + xorl %r13d,%r12d + xorl %r14d,%edi + addl 56(%rsp),%r12d + + addl 20(%rsp),%r12d + movl %r11d,%r13d + addl %edi,%r12d + movl %edx,%r14d + rorl $14,%r13d + movl %eax,%edi + + xorl %r11d,%r13d + rorl $9,%r14d + xorl %ebx,%edi + + movl %r12d,20(%rsp) + xorl %edx,%r14d + andl %r11d,%edi + + rorl $5,%r13d + addl %ecx,%r12d + xorl %ebx,%edi + + rorl $11,%r14d + xorl %r11d,%r13d + addl %edi,%r12d + + movl %edx,%edi + addl (%rbp),%r12d + xorl %edx,%r14d + + xorl %r8d,%edi + rorl $6,%r13d + movl %r8d,%ecx + + andl %edi,%r15d + rorl $2,%r14d + addl %r13d,%r12d + + xorl %r15d,%ecx + addl %r12d,%r10d + addl %r12d,%ecx + + leaq 4(%rbp),%rbp + movl 28(%rsp),%r13d + movl 16(%rsp),%r15d + + movl %r13d,%r12d + rorl $11,%r13d + addl %r14d,%ecx + movl %r15d,%r14d + rorl $2,%r15d + + xorl %r12d,%r13d + shrl $3,%r12d + rorl $7,%r13d + xorl %r14d,%r15d + shrl $10,%r14d + + rorl $17,%r15d + xorl %r13d,%r12d + xorl %r14d,%r15d + addl 60(%rsp),%r12d + + addl 24(%rsp),%r12d + movl %r10d,%r13d + addl %r15d,%r12d + movl %ecx,%r14d + rorl $14,%r13d + movl %r11d,%r15d + + xorl %r10d,%r13d + rorl $9,%r14d + xorl %eax,%r15d + + movl %r12d,24(%rsp) + xorl %ecx,%r14d + andl %r10d,%r15d + + rorl $5,%r13d + addl %ebx,%r12d + xorl %eax,%r15d + + rorl $11,%r14d + xorl %r10d,%r13d + addl %r15d,%r12d + + movl %ecx,%r15d + addl (%rbp),%r12d + xorl %ecx,%r14d + + xorl %edx,%r15d + rorl $6,%r13d + movl %edx,%ebx + + andl %r15d,%edi + rorl $2,%r14d + addl %r13d,%r12d + + xorl %edi,%ebx + addl %r12d,%r9d + addl %r12d,%ebx + + leaq 4(%rbp),%rbp + movl 32(%rsp),%r13d + movl 20(%rsp),%edi + + movl %r13d,%r12d + rorl $11,%r13d + addl %r14d,%ebx + movl %edi,%r14d + rorl $2,%edi + + xorl %r12d,%r13d + shrl $3,%r12d + rorl $7,%r13d + xorl %r14d,%edi + shrl $10,%r14d + + rorl $17,%edi + xorl %r13d,%r12d + xorl %r14d,%edi + addl 0(%rsp),%r12d + + addl 28(%rsp),%r12d + movl %r9d,%r13d + addl %edi,%r12d + movl %ebx,%r14d + rorl $14,%r13d + movl %r10d,%edi + + xorl %r9d,%r13d + rorl $9,%r14d + xorl %r11d,%edi + + movl %r12d,28(%rsp) + xorl %ebx,%r14d + andl %r9d,%edi + + rorl $5,%r13d + addl %eax,%r12d + xorl %r11d,%edi + + rorl $11,%r14d + xorl %r9d,%r13d + addl %edi,%r12d + + movl %ebx,%edi + addl (%rbp),%r12d + xorl %ebx,%r14d + + xorl %ecx,%edi + rorl $6,%r13d + movl %ecx,%eax + + andl %edi,%r15d + rorl $2,%r14d + addl %r13d,%r12d + + xorl %r15d,%eax + addl %r12d,%r8d + addl %r12d,%eax + + leaq 20(%rbp),%rbp + movl 36(%rsp),%r13d + movl 24(%rsp),%r15d + + movl %r13d,%r12d + rorl $11,%r13d + addl %r14d,%eax + movl %r15d,%r14d + rorl $2,%r15d + + xorl %r12d,%r13d + shrl $3,%r12d + rorl $7,%r13d + xorl %r14d,%r15d + shrl $10,%r14d + + rorl $17,%r15d + xorl %r13d,%r12d + xorl %r14d,%r15d + addl 4(%rsp),%r12d + + addl 32(%rsp),%r12d + movl %r8d,%r13d + addl %r15d,%r12d + movl %eax,%r14d + rorl $14,%r13d + movl %r9d,%r15d + + xorl %r8d,%r13d + rorl $9,%r14d + xorl %r10d,%r15d + + movl %r12d,32(%rsp) + xorl %eax,%r14d + andl %r8d,%r15d + + rorl $5,%r13d + addl %r11d,%r12d + xorl %r10d,%r15d + + rorl $11,%r14d + xorl %r8d,%r13d + addl %r15d,%r12d + + movl %eax,%r15d + addl (%rbp),%r12d + xorl %eax,%r14d + + xorl %ebx,%r15d + rorl $6,%r13d + movl %ebx,%r11d + + andl %r15d,%edi + rorl $2,%r14d + addl %r13d,%r12d + + xorl %edi,%r11d + addl %r12d,%edx + addl %r12d,%r11d + + leaq 4(%rbp),%rbp + movl 40(%rsp),%r13d + movl 28(%rsp),%edi + + movl %r13d,%r12d + rorl $11,%r13d + addl %r14d,%r11d + movl %edi,%r14d + rorl $2,%edi + + xorl %r12d,%r13d + shrl $3,%r12d + rorl $7,%r13d + xorl %r14d,%edi + shrl $10,%r14d + + rorl $17,%edi + xorl %r13d,%r12d + xorl %r14d,%edi + addl 8(%rsp),%r12d + + addl 36(%rsp),%r12d + movl %edx,%r13d + addl %edi,%r12d + movl %r11d,%r14d + rorl $14,%r13d + movl %r8d,%edi + + xorl %edx,%r13d + rorl $9,%r14d + xorl %r9d,%edi + + movl %r12d,36(%rsp) + xorl %r11d,%r14d + andl %edx,%edi + + rorl $5,%r13d + addl %r10d,%r12d + xorl %r9d,%edi + + rorl $11,%r14d + xorl %edx,%r13d + addl %edi,%r12d + + movl %r11d,%edi + addl (%rbp),%r12d + xorl %r11d,%r14d + + xorl %eax,%edi + rorl $6,%r13d + movl %eax,%r10d + + andl %edi,%r15d + rorl $2,%r14d + addl %r13d,%r12d + + xorl %r15d,%r10d + addl %r12d,%ecx + addl %r12d,%r10d + + leaq 4(%rbp),%rbp + movl 44(%rsp),%r13d + movl 32(%rsp),%r15d + + movl %r13d,%r12d + rorl $11,%r13d + addl %r14d,%r10d + movl %r15d,%r14d + rorl $2,%r15d + + xorl %r12d,%r13d + shrl $3,%r12d + rorl $7,%r13d + xorl %r14d,%r15d + shrl $10,%r14d + + rorl $17,%r15d + xorl %r13d,%r12d + xorl %r14d,%r15d + addl 12(%rsp),%r12d + + addl 40(%rsp),%r12d + movl %ecx,%r13d + addl %r15d,%r12d + movl %r10d,%r14d + rorl $14,%r13d + movl %edx,%r15d + + xorl %ecx,%r13d + rorl $9,%r14d + xorl %r8d,%r15d + + movl %r12d,40(%rsp) + xorl %r10d,%r14d + andl %ecx,%r15d + + rorl $5,%r13d + addl %r9d,%r12d + xorl %r8d,%r15d + + rorl $11,%r14d + xorl %ecx,%r13d + addl %r15d,%r12d + + movl %r10d,%r15d + addl (%rbp),%r12d + xorl %r10d,%r14d + + xorl %r11d,%r15d + rorl $6,%r13d + movl %r11d,%r9d + + andl %r15d,%edi + rorl $2,%r14d + addl %r13d,%r12d + + xorl %edi,%r9d + addl %r12d,%ebx + addl %r12d,%r9d + + leaq 4(%rbp),%rbp + movl 48(%rsp),%r13d + movl 36(%rsp),%edi + + movl %r13d,%r12d + rorl $11,%r13d + addl %r14d,%r9d + movl %edi,%r14d + rorl $2,%edi + + xorl %r12d,%r13d + shrl $3,%r12d + rorl $7,%r13d + xorl %r14d,%edi + shrl $10,%r14d + + rorl $17,%edi + xorl %r13d,%r12d + xorl %r14d,%edi + addl 16(%rsp),%r12d + + addl 44(%rsp),%r12d + movl %ebx,%r13d + addl %edi,%r12d + movl %r9d,%r14d + rorl $14,%r13d + movl %ecx,%edi + + xorl %ebx,%r13d + rorl $9,%r14d + xorl %edx,%edi + + movl %r12d,44(%rsp) + xorl %r9d,%r14d + andl %ebx,%edi + + rorl $5,%r13d + addl %r8d,%r12d + xorl %edx,%edi + + rorl $11,%r14d + xorl %ebx,%r13d + addl %edi,%r12d + + movl %r9d,%edi + addl (%rbp),%r12d + xorl %r9d,%r14d + + xorl %r10d,%edi + rorl $6,%r13d + movl %r10d,%r8d + + andl %edi,%r15d + rorl $2,%r14d + addl %r13d,%r12d + + xorl %r15d,%r8d + addl %r12d,%eax + addl %r12d,%r8d + + leaq 20(%rbp),%rbp + movl 52(%rsp),%r13d + movl 40(%rsp),%r15d + + movl %r13d,%r12d + rorl $11,%r13d + addl %r14d,%r8d + movl %r15d,%r14d + rorl $2,%r15d + + xorl %r12d,%r13d + shrl $3,%r12d + rorl $7,%r13d + xorl %r14d,%r15d + shrl $10,%r14d + + rorl $17,%r15d + xorl %r13d,%r12d + xorl %r14d,%r15d + addl 20(%rsp),%r12d + + addl 48(%rsp),%r12d + movl %eax,%r13d + addl %r15d,%r12d + movl %r8d,%r14d + rorl $14,%r13d + movl %ebx,%r15d + + xorl %eax,%r13d + rorl $9,%r14d + xorl %ecx,%r15d + + movl %r12d,48(%rsp) + xorl %r8d,%r14d + andl %eax,%r15d + + rorl $5,%r13d + addl %edx,%r12d + xorl %ecx,%r15d + + rorl $11,%r14d + xorl %eax,%r13d + addl %r15d,%r12d + + movl %r8d,%r15d + addl (%rbp),%r12d + xorl %r8d,%r14d + + xorl %r9d,%r15d + rorl $6,%r13d + movl %r9d,%edx + + andl %r15d,%edi + rorl $2,%r14d + addl %r13d,%r12d + + xorl %edi,%edx + addl %r12d,%r11d + addl %r12d,%edx + + leaq 4(%rbp),%rbp + movl 56(%rsp),%r13d + movl 44(%rsp),%edi + + movl %r13d,%r12d + rorl $11,%r13d + addl %r14d,%edx + movl %edi,%r14d + rorl $2,%edi + + xorl %r12d,%r13d + shrl $3,%r12d + rorl $7,%r13d + xorl %r14d,%edi + shrl $10,%r14d + + rorl $17,%edi + xorl %r13d,%r12d + xorl %r14d,%edi + addl 24(%rsp),%r12d + + addl 52(%rsp),%r12d + movl %r11d,%r13d + addl %edi,%r12d + movl %edx,%r14d + rorl $14,%r13d + movl %eax,%edi + + xorl %r11d,%r13d + rorl $9,%r14d + xorl %ebx,%edi + + movl %r12d,52(%rsp) + xorl %edx,%r14d + andl %r11d,%edi + + rorl $5,%r13d + addl %ecx,%r12d + xorl %ebx,%edi + + rorl $11,%r14d + xorl %r11d,%r13d + addl %edi,%r12d + + movl %edx,%edi + addl (%rbp),%r12d + xorl %edx,%r14d + + xorl %r8d,%edi + rorl $6,%r13d + movl %r8d,%ecx + + andl %edi,%r15d + rorl $2,%r14d + addl %r13d,%r12d + + xorl %r15d,%ecx + addl %r12d,%r10d + addl %r12d,%ecx + + leaq 4(%rbp),%rbp + movl 60(%rsp),%r13d + movl 48(%rsp),%r15d + + movl %r13d,%r12d + rorl $11,%r13d + addl %r14d,%ecx + movl %r15d,%r14d + rorl $2,%r15d + + xorl %r12d,%r13d + shrl $3,%r12d + rorl $7,%r13d + xorl %r14d,%r15d + shrl $10,%r14d + + rorl $17,%r15d + xorl %r13d,%r12d + xorl %r14d,%r15d + addl 28(%rsp),%r12d + + addl 56(%rsp),%r12d + movl %r10d,%r13d + addl %r15d,%r12d + movl %ecx,%r14d + rorl $14,%r13d + movl %r11d,%r15d + + xorl %r10d,%r13d + rorl $9,%r14d + xorl %eax,%r15d + + movl %r12d,56(%rsp) + xorl %ecx,%r14d + andl %r10d,%r15d + + rorl $5,%r13d + addl %ebx,%r12d + xorl %eax,%r15d + + rorl $11,%r14d + xorl %r10d,%r13d + addl %r15d,%r12d + + movl %ecx,%r15d + addl (%rbp),%r12d + xorl %ecx,%r14d + + xorl %edx,%r15d + rorl $6,%r13d + movl %edx,%ebx + + andl %r15d,%edi + rorl $2,%r14d + addl %r13d,%r12d + + xorl %edi,%ebx + addl %r12d,%r9d + addl %r12d,%ebx + + leaq 4(%rbp),%rbp + movl 0(%rsp),%r13d + movl 52(%rsp),%edi + + movl %r13d,%r12d + rorl $11,%r13d + addl %r14d,%ebx + movl %edi,%r14d + rorl $2,%edi + + xorl %r12d,%r13d + shrl $3,%r12d + rorl $7,%r13d + xorl %r14d,%edi + shrl $10,%r14d + + rorl $17,%edi + xorl %r13d,%r12d + xorl %r14d,%edi + addl 32(%rsp),%r12d + + addl 60(%rsp),%r12d + movl %r9d,%r13d + addl %edi,%r12d + movl %ebx,%r14d + rorl $14,%r13d + movl %r10d,%edi + + xorl %r9d,%r13d + rorl $9,%r14d + xorl %r11d,%edi + + movl %r12d,60(%rsp) + xorl %ebx,%r14d + andl %r9d,%edi + + rorl $5,%r13d + addl %eax,%r12d + xorl %r11d,%edi + + rorl $11,%r14d + xorl %r9d,%r13d + addl %edi,%r12d + + movl %ebx,%edi + addl (%rbp),%r12d + xorl %ebx,%r14d + + xorl %ecx,%edi + rorl $6,%r13d + movl %ecx,%eax + + andl %edi,%r15d + rorl $2,%r14d + addl %r13d,%r12d + + xorl %r15d,%eax + addl %r12d,%r8d + addl %r12d,%eax + + leaq 20(%rbp),%rbp + cmpb $0,3(%rbp) + jnz .Lrounds_16_xx + + movq 64+0(%rsp),%rdi + addl %r14d,%eax + leaq 64(%rsi),%rsi + + addl 0(%rdi),%eax + addl 4(%rdi),%ebx + addl 8(%rdi),%ecx + addl 12(%rdi),%edx + addl 16(%rdi),%r8d + addl 20(%rdi),%r9d + addl 24(%rdi),%r10d + addl 28(%rdi),%r11d + + cmpq 64+16(%rsp),%rsi + + movl %eax,0(%rdi) + movl %ebx,4(%rdi) + movl %ecx,8(%rdi) + movl %edx,12(%rdi) + movl %r8d,16(%rdi) + movl %r9d,20(%rdi) + movl %r10d,24(%rdi) + movl %r11d,28(%rdi) + jb .Lloop + + movq 88(%rsp),%rsi +.cfi_def_cfa %rsi,8 + movq -48(%rsi),%r15 +.cfi_restore %r15 + movq -40(%rsi),%r14 +.cfi_restore %r14 + movq -32(%rsi),%r13 +.cfi_restore %r13 + movq -24(%rsi),%r12 +.cfi_restore %r12 + movq -16(%rsi),%rbp +.cfi_restore %rbp + movq -8(%rsi),%rbx +.cfi_restore %rbx + leaq (%rsi),%rsp +.cfi_def_cfa_register %rsp +.Lepilogue: + ret +.cfi_endproc +.size sha256_block_data_order_nohw,.-sha256_block_data_order_nohw +.section .rodata +.align 64 +.type K256,@object +K256: +.long 0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5 +.long 0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5 +.long 0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5 +.long 0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5 +.long 0xd807aa98,0x12835b01,0x243185be,0x550c7dc3 +.long 0xd807aa98,0x12835b01,0x243185be,0x550c7dc3 +.long 0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174 +.long 0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174 +.long 0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc +.long 0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc +.long 0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da +.long 0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da +.long 0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7 +.long 0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7 +.long 0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967 +.long 0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967 +.long 0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13 +.long 0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13 +.long 0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85 +.long 0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85 +.long 0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3 +.long 0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3 +.long 0xd192e819,0xd6990624,0xf40e3585,0x106aa070 +.long 0xd192e819,0xd6990624,0xf40e3585,0x106aa070 +.long 0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5 +.long 0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5 +.long 0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3 +.long 0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3 +.long 0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208 +.long 0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208 +.long 0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2 +.long 0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2 + +.long 0x00010203,0x04050607,0x08090a0b,0x0c0d0e0f +.long 0x00010203,0x04050607,0x08090a0b,0x0c0d0e0f +.long 0x03020100,0x0b0a0908,0xffffffff,0xffffffff +.long 0x03020100,0x0b0a0908,0xffffffff,0xffffffff +.long 0xffffffff,0xffffffff,0x03020100,0x0b0a0908 +.long 0xffffffff,0xffffffff,0x03020100,0x0b0a0908 +.byte 83,72,65,50,53,54,32,98,108,111,99,107,32,116,114,97,110,115,102,111,114,109,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.text +.globl sha256_block_data_order_hw +.hidden sha256_block_data_order_hw +.type sha256_block_data_order_hw,@function +.align 64 +sha256_block_data_order_hw: +.cfi_startproc +_CET_ENDBR + leaq K256+128(%rip),%rcx + movdqu (%rdi),%xmm1 + movdqu 16(%rdi),%xmm2 + movdqa 512-128(%rcx),%xmm7 + + pshufd $0x1b,%xmm1,%xmm0 + pshufd $0xb1,%xmm1,%xmm1 + pshufd $0x1b,%xmm2,%xmm2 + movdqa %xmm7,%xmm8 +.byte 102,15,58,15,202,8 + punpcklqdq %xmm0,%xmm2 + jmp .Loop_shaext + +.align 16 +.Loop_shaext: + movdqu (%rsi),%xmm3 + movdqu 16(%rsi),%xmm4 + movdqu 32(%rsi),%xmm5 +.byte 102,15,56,0,223 + movdqu 48(%rsi),%xmm6 + + movdqa 0-128(%rcx),%xmm0 + paddd %xmm3,%xmm0 +.byte 102,15,56,0,231 + movdqa %xmm2,%xmm10 +.byte 15,56,203,209 + pshufd $0x0e,%xmm0,%xmm0 + nop + movdqa %xmm1,%xmm9 +.byte 15,56,203,202 + + movdqa 32-128(%rcx),%xmm0 + paddd %xmm4,%xmm0 +.byte 102,15,56,0,239 +.byte 15,56,203,209 + pshufd $0x0e,%xmm0,%xmm0 + leaq 64(%rsi),%rsi +.byte 15,56,204,220 +.byte 15,56,203,202 + + movdqa 64-128(%rcx),%xmm0 + paddd %xmm5,%xmm0 +.byte 102,15,56,0,247 +.byte 15,56,203,209 + pshufd $0x0e,%xmm0,%xmm0 + movdqa %xmm6,%xmm7 +.byte 102,15,58,15,253,4 + nop + paddd %xmm7,%xmm3 +.byte 15,56,204,229 +.byte 15,56,203,202 + + movdqa 96-128(%rcx),%xmm0 + paddd %xmm6,%xmm0 +.byte 15,56,205,222 +.byte 15,56,203,209 + pshufd $0x0e,%xmm0,%xmm0 + movdqa %xmm3,%xmm7 +.byte 102,15,58,15,254,4 + nop + paddd %xmm7,%xmm4 +.byte 15,56,204,238 +.byte 15,56,203,202 + movdqa 128-128(%rcx),%xmm0 + paddd %xmm3,%xmm0 +.byte 15,56,205,227 +.byte 15,56,203,209 + pshufd $0x0e,%xmm0,%xmm0 + movdqa %xmm4,%xmm7 +.byte 102,15,58,15,251,4 + nop + paddd %xmm7,%xmm5 +.byte 15,56,204,243 +.byte 15,56,203,202 + movdqa 160-128(%rcx),%xmm0 + paddd %xmm4,%xmm0 +.byte 15,56,205,236 +.byte 15,56,203,209 + pshufd $0x0e,%xmm0,%xmm0 + movdqa %xmm5,%xmm7 +.byte 102,15,58,15,252,4 + nop + paddd %xmm7,%xmm6 +.byte 15,56,204,220 +.byte 15,56,203,202 + movdqa 192-128(%rcx),%xmm0 + paddd %xmm5,%xmm0 +.byte 15,56,205,245 +.byte 15,56,203,209 + pshufd $0x0e,%xmm0,%xmm0 + movdqa %xmm6,%xmm7 +.byte 102,15,58,15,253,4 + nop + paddd %xmm7,%xmm3 +.byte 15,56,204,229 +.byte 15,56,203,202 + movdqa 224-128(%rcx),%xmm0 + paddd %xmm6,%xmm0 +.byte 15,56,205,222 +.byte 15,56,203,209 + pshufd $0x0e,%xmm0,%xmm0 + movdqa %xmm3,%xmm7 +.byte 102,15,58,15,254,4 + nop + paddd %xmm7,%xmm4 +.byte 15,56,204,238 +.byte 15,56,203,202 + movdqa 256-128(%rcx),%xmm0 + paddd %xmm3,%xmm0 +.byte 15,56,205,227 +.byte 15,56,203,209 + pshufd $0x0e,%xmm0,%xmm0 + movdqa %xmm4,%xmm7 +.byte 102,15,58,15,251,4 + nop + paddd %xmm7,%xmm5 +.byte 15,56,204,243 +.byte 15,56,203,202 + movdqa 288-128(%rcx),%xmm0 + paddd %xmm4,%xmm0 +.byte 15,56,205,236 +.byte 15,56,203,209 + pshufd $0x0e,%xmm0,%xmm0 + movdqa %xmm5,%xmm7 +.byte 102,15,58,15,252,4 + nop + paddd %xmm7,%xmm6 +.byte 15,56,204,220 +.byte 15,56,203,202 + movdqa 320-128(%rcx),%xmm0 + paddd %xmm5,%xmm0 +.byte 15,56,205,245 +.byte 15,56,203,209 + pshufd $0x0e,%xmm0,%xmm0 + movdqa %xmm6,%xmm7 +.byte 102,15,58,15,253,4 + nop + paddd %xmm7,%xmm3 +.byte 15,56,204,229 +.byte 15,56,203,202 + movdqa 352-128(%rcx),%xmm0 + paddd %xmm6,%xmm0 +.byte 15,56,205,222 +.byte 15,56,203,209 + pshufd $0x0e,%xmm0,%xmm0 + movdqa %xmm3,%xmm7 +.byte 102,15,58,15,254,4 + nop + paddd %xmm7,%xmm4 +.byte 15,56,204,238 +.byte 15,56,203,202 + movdqa 384-128(%rcx),%xmm0 + paddd %xmm3,%xmm0 +.byte 15,56,205,227 +.byte 15,56,203,209 + pshufd $0x0e,%xmm0,%xmm0 + movdqa %xmm4,%xmm7 +.byte 102,15,58,15,251,4 + nop + paddd %xmm7,%xmm5 +.byte 15,56,204,243 +.byte 15,56,203,202 + movdqa 416-128(%rcx),%xmm0 + paddd %xmm4,%xmm0 +.byte 15,56,205,236 +.byte 15,56,203,209 + pshufd $0x0e,%xmm0,%xmm0 + movdqa %xmm5,%xmm7 +.byte 102,15,58,15,252,4 +.byte 15,56,203,202 + paddd %xmm7,%xmm6 + + movdqa 448-128(%rcx),%xmm0 + paddd %xmm5,%xmm0 +.byte 15,56,203,209 + pshufd $0x0e,%xmm0,%xmm0 +.byte 15,56,205,245 + movdqa %xmm8,%xmm7 +.byte 15,56,203,202 + + movdqa 480-128(%rcx),%xmm0 + paddd %xmm6,%xmm0 + nop +.byte 15,56,203,209 + pshufd $0x0e,%xmm0,%xmm0 + decq %rdx + nop +.byte 15,56,203,202 + + paddd %xmm10,%xmm2 + paddd %xmm9,%xmm1 + jnz .Loop_shaext + + pshufd $0xb1,%xmm2,%xmm2 + pshufd $0x1b,%xmm1,%xmm7 + pshufd $0xb1,%xmm1,%xmm1 + punpckhqdq %xmm2,%xmm1 +.byte 102,15,58,15,215,8 + + movdqu %xmm1,(%rdi) + movdqu %xmm2,16(%rdi) + ret +.cfi_endproc +.size sha256_block_data_order_hw,.-sha256_block_data_order_hw +.globl sha256_block_data_order_ssse3 +.hidden sha256_block_data_order_ssse3 +.type sha256_block_data_order_ssse3,@function +.align 64 +sha256_block_data_order_ssse3: +.cfi_startproc +_CET_ENDBR + movq %rsp,%rax +.cfi_def_cfa_register %rax + pushq %rbx +.cfi_offset %rbx,-16 + pushq %rbp +.cfi_offset %rbp,-24 + pushq %r12 +.cfi_offset %r12,-32 + pushq %r13 +.cfi_offset %r13,-40 + pushq %r14 +.cfi_offset %r14,-48 + pushq %r15 +.cfi_offset %r15,-56 + shlq $4,%rdx + subq $96,%rsp + leaq (%rsi,%rdx,4),%rdx + andq $-64,%rsp + movq %rdi,64+0(%rsp) + movq %rsi,64+8(%rsp) + movq %rdx,64+16(%rsp) + movq %rax,88(%rsp) +.cfi_escape 0x0f,0x06,0x77,0xd8,0x00,0x06,0x23,0x08 +.Lprologue_ssse3: + + movl 0(%rdi),%eax + movl 4(%rdi),%ebx + movl 8(%rdi),%ecx + movl 12(%rdi),%edx + movl 16(%rdi),%r8d + movl 20(%rdi),%r9d + movl 24(%rdi),%r10d + movl 28(%rdi),%r11d + + + jmp .Lloop_ssse3 +.align 16 +.Lloop_ssse3: + movdqa K256+512(%rip),%xmm7 + movdqu 0(%rsi),%xmm0 + movdqu 16(%rsi),%xmm1 + movdqu 32(%rsi),%xmm2 +.byte 102,15,56,0,199 + movdqu 48(%rsi),%xmm3 + leaq K256(%rip),%rbp +.byte 102,15,56,0,207 + movdqa 0(%rbp),%xmm4 + movdqa 32(%rbp),%xmm5 +.byte 102,15,56,0,215 + paddd %xmm0,%xmm4 + movdqa 64(%rbp),%xmm6 +.byte 102,15,56,0,223 + movdqa 96(%rbp),%xmm7 + paddd %xmm1,%xmm5 + paddd %xmm2,%xmm6 + paddd %xmm3,%xmm7 + movdqa %xmm4,0(%rsp) + movl %eax,%r14d + movdqa %xmm5,16(%rsp) + movl %ebx,%edi + movdqa %xmm6,32(%rsp) + xorl %ecx,%edi + movdqa %xmm7,48(%rsp) + movl %r8d,%r13d + jmp .Lssse3_00_47 + +.align 16 +.Lssse3_00_47: + subq $-128,%rbp + rorl $14,%r13d + movdqa %xmm1,%xmm4 + movl %r14d,%eax + movl %r9d,%r12d + movdqa %xmm3,%xmm7 + rorl $9,%r14d + xorl %r8d,%r13d + xorl %r10d,%r12d + rorl $5,%r13d + xorl %eax,%r14d +.byte 102,15,58,15,224,4 + andl %r8d,%r12d + xorl %r8d,%r13d +.byte 102,15,58,15,250,4 + addl 0(%rsp),%r11d + movl %eax,%r15d + xorl %r10d,%r12d + rorl $11,%r14d + movdqa %xmm4,%xmm5 + xorl %ebx,%r15d + addl %r12d,%r11d + movdqa %xmm4,%xmm6 + rorl $6,%r13d + andl %r15d,%edi + psrld $3,%xmm4 + xorl %eax,%r14d + addl %r13d,%r11d + xorl %ebx,%edi + paddd %xmm7,%xmm0 + rorl $2,%r14d + addl %r11d,%edx + psrld $7,%xmm6 + addl %edi,%r11d + movl %edx,%r13d + pshufd $250,%xmm3,%xmm7 + addl %r11d,%r14d + rorl $14,%r13d + pslld $14,%xmm5 + movl %r14d,%r11d + movl %r8d,%r12d + pxor %xmm6,%xmm4 + rorl $9,%r14d + xorl %edx,%r13d + xorl %r9d,%r12d + rorl $5,%r13d + psrld $11,%xmm6 + xorl %r11d,%r14d + pxor %xmm5,%xmm4 + andl %edx,%r12d + xorl %edx,%r13d + pslld $11,%xmm5 + addl 4(%rsp),%r10d + movl %r11d,%edi + pxor %xmm6,%xmm4 + xorl %r9d,%r12d + rorl $11,%r14d + movdqa %xmm7,%xmm6 + xorl %eax,%edi + addl %r12d,%r10d + pxor %xmm5,%xmm4 + rorl $6,%r13d + andl %edi,%r15d + xorl %r11d,%r14d + psrld $10,%xmm7 + addl %r13d,%r10d + xorl %eax,%r15d + paddd %xmm4,%xmm0 + rorl $2,%r14d + addl %r10d,%ecx + psrlq $17,%xmm6 + addl %r15d,%r10d + movl %ecx,%r13d + addl %r10d,%r14d + pxor %xmm6,%xmm7 + rorl $14,%r13d + movl %r14d,%r10d + movl %edx,%r12d + rorl $9,%r14d + psrlq $2,%xmm6 + xorl %ecx,%r13d + xorl %r8d,%r12d + pxor %xmm6,%xmm7 + rorl $5,%r13d + xorl %r10d,%r14d + andl %ecx,%r12d + pshufd $128,%xmm7,%xmm7 + xorl %ecx,%r13d + addl 8(%rsp),%r9d + movl %r10d,%r15d + psrldq $8,%xmm7 + xorl %r8d,%r12d + rorl $11,%r14d + xorl %r11d,%r15d + addl %r12d,%r9d + rorl $6,%r13d + paddd %xmm7,%xmm0 + andl %r15d,%edi + xorl %r10d,%r14d + addl %r13d,%r9d + pshufd $80,%xmm0,%xmm7 + xorl %r11d,%edi + rorl $2,%r14d + addl %r9d,%ebx + movdqa %xmm7,%xmm6 + addl %edi,%r9d + movl %ebx,%r13d + psrld $10,%xmm7 + addl %r9d,%r14d + rorl $14,%r13d + psrlq $17,%xmm6 + movl %r14d,%r9d + movl %ecx,%r12d + pxor %xmm6,%xmm7 + rorl $9,%r14d + xorl %ebx,%r13d + xorl %edx,%r12d + rorl $5,%r13d + xorl %r9d,%r14d + psrlq $2,%xmm6 + andl %ebx,%r12d + xorl %ebx,%r13d + addl 12(%rsp),%r8d + pxor %xmm6,%xmm7 + movl %r9d,%edi + xorl %edx,%r12d + rorl $11,%r14d + pshufd $8,%xmm7,%xmm7 + xorl %r10d,%edi + addl %r12d,%r8d + movdqa 0(%rbp),%xmm6 + rorl $6,%r13d + andl %edi,%r15d + pslldq $8,%xmm7 + xorl %r9d,%r14d + addl %r13d,%r8d + xorl %r10d,%r15d + paddd %xmm7,%xmm0 + rorl $2,%r14d + addl %r8d,%eax + addl %r15d,%r8d + paddd %xmm0,%xmm6 + movl %eax,%r13d + addl %r8d,%r14d + movdqa %xmm6,0(%rsp) + rorl $14,%r13d + movdqa %xmm2,%xmm4 + movl %r14d,%r8d + movl %ebx,%r12d + movdqa %xmm0,%xmm7 + rorl $9,%r14d + xorl %eax,%r13d + xorl %ecx,%r12d + rorl $5,%r13d + xorl %r8d,%r14d +.byte 102,15,58,15,225,4 + andl %eax,%r12d + xorl %eax,%r13d +.byte 102,15,58,15,251,4 + addl 16(%rsp),%edx + movl %r8d,%r15d + xorl %ecx,%r12d + rorl $11,%r14d + movdqa %xmm4,%xmm5 + xorl %r9d,%r15d + addl %r12d,%edx + movdqa %xmm4,%xmm6 + rorl $6,%r13d + andl %r15d,%edi + psrld $3,%xmm4 + xorl %r8d,%r14d + addl %r13d,%edx + xorl %r9d,%edi + paddd %xmm7,%xmm1 + rorl $2,%r14d + addl %edx,%r11d + psrld $7,%xmm6 + addl %edi,%edx + movl %r11d,%r13d + pshufd $250,%xmm0,%xmm7 + addl %edx,%r14d + rorl $14,%r13d + pslld $14,%xmm5 + movl %r14d,%edx + movl %eax,%r12d + pxor %xmm6,%xmm4 + rorl $9,%r14d + xorl %r11d,%r13d + xorl %ebx,%r12d + rorl $5,%r13d + psrld $11,%xmm6 + xorl %edx,%r14d + pxor %xmm5,%xmm4 + andl %r11d,%r12d + xorl %r11d,%r13d + pslld $11,%xmm5 + addl 20(%rsp),%ecx + movl %edx,%edi + pxor %xmm6,%xmm4 + xorl %ebx,%r12d + rorl $11,%r14d + movdqa %xmm7,%xmm6 + xorl %r8d,%edi + addl %r12d,%ecx + pxor %xmm5,%xmm4 + rorl $6,%r13d + andl %edi,%r15d + xorl %edx,%r14d + psrld $10,%xmm7 + addl %r13d,%ecx + xorl %r8d,%r15d + paddd %xmm4,%xmm1 + rorl $2,%r14d + addl %ecx,%r10d + psrlq $17,%xmm6 + addl %r15d,%ecx + movl %r10d,%r13d + addl %ecx,%r14d + pxor %xmm6,%xmm7 + rorl $14,%r13d + movl %r14d,%ecx + movl %r11d,%r12d + rorl $9,%r14d + psrlq $2,%xmm6 + xorl %r10d,%r13d + xorl %eax,%r12d + pxor %xmm6,%xmm7 + rorl $5,%r13d + xorl %ecx,%r14d + andl %r10d,%r12d + pshufd $128,%xmm7,%xmm7 + xorl %r10d,%r13d + addl 24(%rsp),%ebx + movl %ecx,%r15d + psrldq $8,%xmm7 + xorl %eax,%r12d + rorl $11,%r14d + xorl %edx,%r15d + addl %r12d,%ebx + rorl $6,%r13d + paddd %xmm7,%xmm1 + andl %r15d,%edi + xorl %ecx,%r14d + addl %r13d,%ebx + pshufd $80,%xmm1,%xmm7 + xorl %edx,%edi + rorl $2,%r14d + addl %ebx,%r9d + movdqa %xmm7,%xmm6 + addl %edi,%ebx + movl %r9d,%r13d + psrld $10,%xmm7 + addl %ebx,%r14d + rorl $14,%r13d + psrlq $17,%xmm6 + movl %r14d,%ebx + movl %r10d,%r12d + pxor %xmm6,%xmm7 + rorl $9,%r14d + xorl %r9d,%r13d + xorl %r11d,%r12d + rorl $5,%r13d + xorl %ebx,%r14d + psrlq $2,%xmm6 + andl %r9d,%r12d + xorl %r9d,%r13d + addl 28(%rsp),%eax + pxor %xmm6,%xmm7 + movl %ebx,%edi + xorl %r11d,%r12d + rorl $11,%r14d + pshufd $8,%xmm7,%xmm7 + xorl %ecx,%edi + addl %r12d,%eax + movdqa 32(%rbp),%xmm6 + rorl $6,%r13d + andl %edi,%r15d + pslldq $8,%xmm7 + xorl %ebx,%r14d + addl %r13d,%eax + xorl %ecx,%r15d + paddd %xmm7,%xmm1 + rorl $2,%r14d + addl %eax,%r8d + addl %r15d,%eax + paddd %xmm1,%xmm6 + movl %r8d,%r13d + addl %eax,%r14d + movdqa %xmm6,16(%rsp) + rorl $14,%r13d + movdqa %xmm3,%xmm4 + movl %r14d,%eax + movl %r9d,%r12d + movdqa %xmm1,%xmm7 + rorl $9,%r14d + xorl %r8d,%r13d + xorl %r10d,%r12d + rorl $5,%r13d + xorl %eax,%r14d +.byte 102,15,58,15,226,4 + andl %r8d,%r12d + xorl %r8d,%r13d +.byte 102,15,58,15,248,4 + addl 32(%rsp),%r11d + movl %eax,%r15d + xorl %r10d,%r12d + rorl $11,%r14d + movdqa %xmm4,%xmm5 + xorl %ebx,%r15d + addl %r12d,%r11d + movdqa %xmm4,%xmm6 + rorl $6,%r13d + andl %r15d,%edi + psrld $3,%xmm4 + xorl %eax,%r14d + addl %r13d,%r11d + xorl %ebx,%edi + paddd %xmm7,%xmm2 + rorl $2,%r14d + addl %r11d,%edx + psrld $7,%xmm6 + addl %edi,%r11d + movl %edx,%r13d + pshufd $250,%xmm1,%xmm7 + addl %r11d,%r14d + rorl $14,%r13d + pslld $14,%xmm5 + movl %r14d,%r11d + movl %r8d,%r12d + pxor %xmm6,%xmm4 + rorl $9,%r14d + xorl %edx,%r13d + xorl %r9d,%r12d + rorl $5,%r13d + psrld $11,%xmm6 + xorl %r11d,%r14d + pxor %xmm5,%xmm4 + andl %edx,%r12d + xorl %edx,%r13d + pslld $11,%xmm5 + addl 36(%rsp),%r10d + movl %r11d,%edi + pxor %xmm6,%xmm4 + xorl %r9d,%r12d + rorl $11,%r14d + movdqa %xmm7,%xmm6 + xorl %eax,%edi + addl %r12d,%r10d + pxor %xmm5,%xmm4 + rorl $6,%r13d + andl %edi,%r15d + xorl %r11d,%r14d + psrld $10,%xmm7 + addl %r13d,%r10d + xorl %eax,%r15d + paddd %xmm4,%xmm2 + rorl $2,%r14d + addl %r10d,%ecx + psrlq $17,%xmm6 + addl %r15d,%r10d + movl %ecx,%r13d + addl %r10d,%r14d + pxor %xmm6,%xmm7 + rorl $14,%r13d + movl %r14d,%r10d + movl %edx,%r12d + rorl $9,%r14d + psrlq $2,%xmm6 + xorl %ecx,%r13d + xorl %r8d,%r12d + pxor %xmm6,%xmm7 + rorl $5,%r13d + xorl %r10d,%r14d + andl %ecx,%r12d + pshufd $128,%xmm7,%xmm7 + xorl %ecx,%r13d + addl 40(%rsp),%r9d + movl %r10d,%r15d + psrldq $8,%xmm7 + xorl %r8d,%r12d + rorl $11,%r14d + xorl %r11d,%r15d + addl %r12d,%r9d + rorl $6,%r13d + paddd %xmm7,%xmm2 + andl %r15d,%edi + xorl %r10d,%r14d + addl %r13d,%r9d + pshufd $80,%xmm2,%xmm7 + xorl %r11d,%edi + rorl $2,%r14d + addl %r9d,%ebx + movdqa %xmm7,%xmm6 + addl %edi,%r9d + movl %ebx,%r13d + psrld $10,%xmm7 + addl %r9d,%r14d + rorl $14,%r13d + psrlq $17,%xmm6 + movl %r14d,%r9d + movl %ecx,%r12d + pxor %xmm6,%xmm7 + rorl $9,%r14d + xorl %ebx,%r13d + xorl %edx,%r12d + rorl $5,%r13d + xorl %r9d,%r14d + psrlq $2,%xmm6 + andl %ebx,%r12d + xorl %ebx,%r13d + addl 44(%rsp),%r8d + pxor %xmm6,%xmm7 + movl %r9d,%edi + xorl %edx,%r12d + rorl $11,%r14d + pshufd $8,%xmm7,%xmm7 + xorl %r10d,%edi + addl %r12d,%r8d + movdqa 64(%rbp),%xmm6 + rorl $6,%r13d + andl %edi,%r15d + pslldq $8,%xmm7 + xorl %r9d,%r14d + addl %r13d,%r8d + xorl %r10d,%r15d + paddd %xmm7,%xmm2 + rorl $2,%r14d + addl %r8d,%eax + addl %r15d,%r8d + paddd %xmm2,%xmm6 + movl %eax,%r13d + addl %r8d,%r14d + movdqa %xmm6,32(%rsp) + rorl $14,%r13d + movdqa %xmm0,%xmm4 + movl %r14d,%r8d + movl %ebx,%r12d + movdqa %xmm2,%xmm7 + rorl $9,%r14d + xorl %eax,%r13d + xorl %ecx,%r12d + rorl $5,%r13d + xorl %r8d,%r14d +.byte 102,15,58,15,227,4 + andl %eax,%r12d + xorl %eax,%r13d +.byte 102,15,58,15,249,4 + addl 48(%rsp),%edx + movl %r8d,%r15d + xorl %ecx,%r12d + rorl $11,%r14d + movdqa %xmm4,%xmm5 + xorl %r9d,%r15d + addl %r12d,%edx + movdqa %xmm4,%xmm6 + rorl $6,%r13d + andl %r15d,%edi + psrld $3,%xmm4 + xorl %r8d,%r14d + addl %r13d,%edx + xorl %r9d,%edi + paddd %xmm7,%xmm3 + rorl $2,%r14d + addl %edx,%r11d + psrld $7,%xmm6 + addl %edi,%edx + movl %r11d,%r13d + pshufd $250,%xmm2,%xmm7 + addl %edx,%r14d + rorl $14,%r13d + pslld $14,%xmm5 + movl %r14d,%edx + movl %eax,%r12d + pxor %xmm6,%xmm4 + rorl $9,%r14d + xorl %r11d,%r13d + xorl %ebx,%r12d + rorl $5,%r13d + psrld $11,%xmm6 + xorl %edx,%r14d + pxor %xmm5,%xmm4 + andl %r11d,%r12d + xorl %r11d,%r13d + pslld $11,%xmm5 + addl 52(%rsp),%ecx + movl %edx,%edi + pxor %xmm6,%xmm4 + xorl %ebx,%r12d + rorl $11,%r14d + movdqa %xmm7,%xmm6 + xorl %r8d,%edi + addl %r12d,%ecx + pxor %xmm5,%xmm4 + rorl $6,%r13d + andl %edi,%r15d + xorl %edx,%r14d + psrld $10,%xmm7 + addl %r13d,%ecx + xorl %r8d,%r15d + paddd %xmm4,%xmm3 + rorl $2,%r14d + addl %ecx,%r10d + psrlq $17,%xmm6 + addl %r15d,%ecx + movl %r10d,%r13d + addl %ecx,%r14d + pxor %xmm6,%xmm7 + rorl $14,%r13d + movl %r14d,%ecx + movl %r11d,%r12d + rorl $9,%r14d + psrlq $2,%xmm6 + xorl %r10d,%r13d + xorl %eax,%r12d + pxor %xmm6,%xmm7 + rorl $5,%r13d + xorl %ecx,%r14d + andl %r10d,%r12d + pshufd $128,%xmm7,%xmm7 + xorl %r10d,%r13d + addl 56(%rsp),%ebx + movl %ecx,%r15d + psrldq $8,%xmm7 + xorl %eax,%r12d + rorl $11,%r14d + xorl %edx,%r15d + addl %r12d,%ebx + rorl $6,%r13d + paddd %xmm7,%xmm3 + andl %r15d,%edi + xorl %ecx,%r14d + addl %r13d,%ebx + pshufd $80,%xmm3,%xmm7 + xorl %edx,%edi + rorl $2,%r14d + addl %ebx,%r9d + movdqa %xmm7,%xmm6 + addl %edi,%ebx + movl %r9d,%r13d + psrld $10,%xmm7 + addl %ebx,%r14d + rorl $14,%r13d + psrlq $17,%xmm6 + movl %r14d,%ebx + movl %r10d,%r12d + pxor %xmm6,%xmm7 + rorl $9,%r14d + xorl %r9d,%r13d + xorl %r11d,%r12d + rorl $5,%r13d + xorl %ebx,%r14d + psrlq $2,%xmm6 + andl %r9d,%r12d + xorl %r9d,%r13d + addl 60(%rsp),%eax + pxor %xmm6,%xmm7 + movl %ebx,%edi + xorl %r11d,%r12d + rorl $11,%r14d + pshufd $8,%xmm7,%xmm7 + xorl %ecx,%edi + addl %r12d,%eax + movdqa 96(%rbp),%xmm6 + rorl $6,%r13d + andl %edi,%r15d + pslldq $8,%xmm7 + xorl %ebx,%r14d + addl %r13d,%eax + xorl %ecx,%r15d + paddd %xmm7,%xmm3 + rorl $2,%r14d + addl %eax,%r8d + addl %r15d,%eax + paddd %xmm3,%xmm6 + movl %r8d,%r13d + addl %eax,%r14d + movdqa %xmm6,48(%rsp) + cmpb $0,131(%rbp) + jne .Lssse3_00_47 + rorl $14,%r13d + movl %r14d,%eax + movl %r9d,%r12d + rorl $9,%r14d + xorl %r8d,%r13d + xorl %r10d,%r12d + rorl $5,%r13d + xorl %eax,%r14d + andl %r8d,%r12d + xorl %r8d,%r13d + addl 0(%rsp),%r11d + movl %eax,%r15d + xorl %r10d,%r12d + rorl $11,%r14d + xorl %ebx,%r15d + addl %r12d,%r11d + rorl $6,%r13d + andl %r15d,%edi + xorl %eax,%r14d + addl %r13d,%r11d + xorl %ebx,%edi + rorl $2,%r14d + addl %r11d,%edx + addl %edi,%r11d + movl %edx,%r13d + addl %r11d,%r14d + rorl $14,%r13d + movl %r14d,%r11d + movl %r8d,%r12d + rorl $9,%r14d + xorl %edx,%r13d + xorl %r9d,%r12d + rorl $5,%r13d + xorl %r11d,%r14d + andl %edx,%r12d + xorl %edx,%r13d + addl 4(%rsp),%r10d + movl %r11d,%edi + xorl %r9d,%r12d + rorl $11,%r14d + xorl %eax,%edi + addl %r12d,%r10d + rorl $6,%r13d + andl %edi,%r15d + xorl %r11d,%r14d + addl %r13d,%r10d + xorl %eax,%r15d + rorl $2,%r14d + addl %r10d,%ecx + addl %r15d,%r10d + movl %ecx,%r13d + addl %r10d,%r14d + rorl $14,%r13d + movl %r14d,%r10d + movl %edx,%r12d + rorl $9,%r14d + xorl %ecx,%r13d + xorl %r8d,%r12d + rorl $5,%r13d + xorl %r10d,%r14d + andl %ecx,%r12d + xorl %ecx,%r13d + addl 8(%rsp),%r9d + movl %r10d,%r15d + xorl %r8d,%r12d + rorl $11,%r14d + xorl %r11d,%r15d + addl %r12d,%r9d + rorl $6,%r13d + andl %r15d,%edi + xorl %r10d,%r14d + addl %r13d,%r9d + xorl %r11d,%edi + rorl $2,%r14d + addl %r9d,%ebx + addl %edi,%r9d + movl %ebx,%r13d + addl %r9d,%r14d + rorl $14,%r13d + movl %r14d,%r9d + movl %ecx,%r12d + rorl $9,%r14d + xorl %ebx,%r13d + xorl %edx,%r12d + rorl $5,%r13d + xorl %r9d,%r14d + andl %ebx,%r12d + xorl %ebx,%r13d + addl 12(%rsp),%r8d + movl %r9d,%edi + xorl %edx,%r12d + rorl $11,%r14d + xorl %r10d,%edi + addl %r12d,%r8d + rorl $6,%r13d + andl %edi,%r15d + xorl %r9d,%r14d + addl %r13d,%r8d + xorl %r10d,%r15d + rorl $2,%r14d + addl %r8d,%eax + addl %r15d,%r8d + movl %eax,%r13d + addl %r8d,%r14d + rorl $14,%r13d + movl %r14d,%r8d + movl %ebx,%r12d + rorl $9,%r14d + xorl %eax,%r13d + xorl %ecx,%r12d + rorl $5,%r13d + xorl %r8d,%r14d + andl %eax,%r12d + xorl %eax,%r13d + addl 16(%rsp),%edx + movl %r8d,%r15d + xorl %ecx,%r12d + rorl $11,%r14d + xorl %r9d,%r15d + addl %r12d,%edx + rorl $6,%r13d + andl %r15d,%edi + xorl %r8d,%r14d + addl %r13d,%edx + xorl %r9d,%edi + rorl $2,%r14d + addl %edx,%r11d + addl %edi,%edx + movl %r11d,%r13d + addl %edx,%r14d + rorl $14,%r13d + movl %r14d,%edx + movl %eax,%r12d + rorl $9,%r14d + xorl %r11d,%r13d + xorl %ebx,%r12d + rorl $5,%r13d + xorl %edx,%r14d + andl %r11d,%r12d + xorl %r11d,%r13d + addl 20(%rsp),%ecx + movl %edx,%edi + xorl %ebx,%r12d + rorl $11,%r14d + xorl %r8d,%edi + addl %r12d,%ecx + rorl $6,%r13d + andl %edi,%r15d + xorl %edx,%r14d + addl %r13d,%ecx + xorl %r8d,%r15d + rorl $2,%r14d + addl %ecx,%r10d + addl %r15d,%ecx + movl %r10d,%r13d + addl %ecx,%r14d + rorl $14,%r13d + movl %r14d,%ecx + movl %r11d,%r12d + rorl $9,%r14d + xorl %r10d,%r13d + xorl %eax,%r12d + rorl $5,%r13d + xorl %ecx,%r14d + andl %r10d,%r12d + xorl %r10d,%r13d + addl 24(%rsp),%ebx + movl %ecx,%r15d + xorl %eax,%r12d + rorl $11,%r14d + xorl %edx,%r15d + addl %r12d,%ebx + rorl $6,%r13d + andl %r15d,%edi + xorl %ecx,%r14d + addl %r13d,%ebx + xorl %edx,%edi + rorl $2,%r14d + addl %ebx,%r9d + addl %edi,%ebx + movl %r9d,%r13d + addl %ebx,%r14d + rorl $14,%r13d + movl %r14d,%ebx + movl %r10d,%r12d + rorl $9,%r14d + xorl %r9d,%r13d + xorl %r11d,%r12d + rorl $5,%r13d + xorl %ebx,%r14d + andl %r9d,%r12d + xorl %r9d,%r13d + addl 28(%rsp),%eax + movl %ebx,%edi + xorl %r11d,%r12d + rorl $11,%r14d + xorl %ecx,%edi + addl %r12d,%eax + rorl $6,%r13d + andl %edi,%r15d + xorl %ebx,%r14d + addl %r13d,%eax + xorl %ecx,%r15d + rorl $2,%r14d + addl %eax,%r8d + addl %r15d,%eax + movl %r8d,%r13d + addl %eax,%r14d + rorl $14,%r13d + movl %r14d,%eax + movl %r9d,%r12d + rorl $9,%r14d + xorl %r8d,%r13d + xorl %r10d,%r12d + rorl $5,%r13d + xorl %eax,%r14d + andl %r8d,%r12d + xorl %r8d,%r13d + addl 32(%rsp),%r11d + movl %eax,%r15d + xorl %r10d,%r12d + rorl $11,%r14d + xorl %ebx,%r15d + addl %r12d,%r11d + rorl $6,%r13d + andl %r15d,%edi + xorl %eax,%r14d + addl %r13d,%r11d + xorl %ebx,%edi + rorl $2,%r14d + addl %r11d,%edx + addl %edi,%r11d + movl %edx,%r13d + addl %r11d,%r14d + rorl $14,%r13d + movl %r14d,%r11d + movl %r8d,%r12d + rorl $9,%r14d + xorl %edx,%r13d + xorl %r9d,%r12d + rorl $5,%r13d + xorl %r11d,%r14d + andl %edx,%r12d + xorl %edx,%r13d + addl 36(%rsp),%r10d + movl %r11d,%edi + xorl %r9d,%r12d + rorl $11,%r14d + xorl %eax,%edi + addl %r12d,%r10d + rorl $6,%r13d + andl %edi,%r15d + xorl %r11d,%r14d + addl %r13d,%r10d + xorl %eax,%r15d + rorl $2,%r14d + addl %r10d,%ecx + addl %r15d,%r10d + movl %ecx,%r13d + addl %r10d,%r14d + rorl $14,%r13d + movl %r14d,%r10d + movl %edx,%r12d + rorl $9,%r14d + xorl %ecx,%r13d + xorl %r8d,%r12d + rorl $5,%r13d + xorl %r10d,%r14d + andl %ecx,%r12d + xorl %ecx,%r13d + addl 40(%rsp),%r9d + movl %r10d,%r15d + xorl %r8d,%r12d + rorl $11,%r14d + xorl %r11d,%r15d + addl %r12d,%r9d + rorl $6,%r13d + andl %r15d,%edi + xorl %r10d,%r14d + addl %r13d,%r9d + xorl %r11d,%edi + rorl $2,%r14d + addl %r9d,%ebx + addl %edi,%r9d + movl %ebx,%r13d + addl %r9d,%r14d + rorl $14,%r13d + movl %r14d,%r9d + movl %ecx,%r12d + rorl $9,%r14d + xorl %ebx,%r13d + xorl %edx,%r12d + rorl $5,%r13d + xorl %r9d,%r14d + andl %ebx,%r12d + xorl %ebx,%r13d + addl 44(%rsp),%r8d + movl %r9d,%edi + xorl %edx,%r12d + rorl $11,%r14d + xorl %r10d,%edi + addl %r12d,%r8d + rorl $6,%r13d + andl %edi,%r15d + xorl %r9d,%r14d + addl %r13d,%r8d + xorl %r10d,%r15d + rorl $2,%r14d + addl %r8d,%eax + addl %r15d,%r8d + movl %eax,%r13d + addl %r8d,%r14d + rorl $14,%r13d + movl %r14d,%r8d + movl %ebx,%r12d + rorl $9,%r14d + xorl %eax,%r13d + xorl %ecx,%r12d + rorl $5,%r13d + xorl %r8d,%r14d + andl %eax,%r12d + xorl %eax,%r13d + addl 48(%rsp),%edx + movl %r8d,%r15d + xorl %ecx,%r12d + rorl $11,%r14d + xorl %r9d,%r15d + addl %r12d,%edx + rorl $6,%r13d + andl %r15d,%edi + xorl %r8d,%r14d + addl %r13d,%edx + xorl %r9d,%edi + rorl $2,%r14d + addl %edx,%r11d + addl %edi,%edx + movl %r11d,%r13d + addl %edx,%r14d + rorl $14,%r13d + movl %r14d,%edx + movl %eax,%r12d + rorl $9,%r14d + xorl %r11d,%r13d + xorl %ebx,%r12d + rorl $5,%r13d + xorl %edx,%r14d + andl %r11d,%r12d + xorl %r11d,%r13d + addl 52(%rsp),%ecx + movl %edx,%edi + xorl %ebx,%r12d + rorl $11,%r14d + xorl %r8d,%edi + addl %r12d,%ecx + rorl $6,%r13d + andl %edi,%r15d + xorl %edx,%r14d + addl %r13d,%ecx + xorl %r8d,%r15d + rorl $2,%r14d + addl %ecx,%r10d + addl %r15d,%ecx + movl %r10d,%r13d + addl %ecx,%r14d + rorl $14,%r13d + movl %r14d,%ecx + movl %r11d,%r12d + rorl $9,%r14d + xorl %r10d,%r13d + xorl %eax,%r12d + rorl $5,%r13d + xorl %ecx,%r14d + andl %r10d,%r12d + xorl %r10d,%r13d + addl 56(%rsp),%ebx + movl %ecx,%r15d + xorl %eax,%r12d + rorl $11,%r14d + xorl %edx,%r15d + addl %r12d,%ebx + rorl $6,%r13d + andl %r15d,%edi + xorl %ecx,%r14d + addl %r13d,%ebx + xorl %edx,%edi + rorl $2,%r14d + addl %ebx,%r9d + addl %edi,%ebx + movl %r9d,%r13d + addl %ebx,%r14d + rorl $14,%r13d + movl %r14d,%ebx + movl %r10d,%r12d + rorl $9,%r14d + xorl %r9d,%r13d + xorl %r11d,%r12d + rorl $5,%r13d + xorl %ebx,%r14d + andl %r9d,%r12d + xorl %r9d,%r13d + addl 60(%rsp),%eax + movl %ebx,%edi + xorl %r11d,%r12d + rorl $11,%r14d + xorl %ecx,%edi + addl %r12d,%eax + rorl $6,%r13d + andl %edi,%r15d + xorl %ebx,%r14d + addl %r13d,%eax + xorl %ecx,%r15d + rorl $2,%r14d + addl %eax,%r8d + addl %r15d,%eax + movl %r8d,%r13d + addl %eax,%r14d + movq 64+0(%rsp),%rdi + movl %r14d,%eax + + addl 0(%rdi),%eax + leaq 64(%rsi),%rsi + addl 4(%rdi),%ebx + addl 8(%rdi),%ecx + addl 12(%rdi),%edx + addl 16(%rdi),%r8d + addl 20(%rdi),%r9d + addl 24(%rdi),%r10d + addl 28(%rdi),%r11d + + cmpq 64+16(%rsp),%rsi + + movl %eax,0(%rdi) + movl %ebx,4(%rdi) + movl %ecx,8(%rdi) + movl %edx,12(%rdi) + movl %r8d,16(%rdi) + movl %r9d,20(%rdi) + movl %r10d,24(%rdi) + movl %r11d,28(%rdi) + jb .Lloop_ssse3 + + movq 88(%rsp),%rsi +.cfi_def_cfa %rsi,8 + movq -48(%rsi),%r15 +.cfi_restore %r15 + movq -40(%rsi),%r14 +.cfi_restore %r14 + movq -32(%rsi),%r13 +.cfi_restore %r13 + movq -24(%rsi),%r12 +.cfi_restore %r12 + movq -16(%rsi),%rbp +.cfi_restore %rbp + movq -8(%rsi),%rbx +.cfi_restore %rbx + leaq (%rsi),%rsp +.cfi_def_cfa_register %rsp +.Lepilogue_ssse3: + ret +.cfi_endproc +.size sha256_block_data_order_ssse3,.-sha256_block_data_order_ssse3 +.globl sha256_block_data_order_avx +.hidden sha256_block_data_order_avx +.type sha256_block_data_order_avx,@function +.align 64 +sha256_block_data_order_avx: +.cfi_startproc +_CET_ENDBR + movq %rsp,%rax +.cfi_def_cfa_register %rax + pushq %rbx +.cfi_offset %rbx,-16 + pushq %rbp +.cfi_offset %rbp,-24 + pushq %r12 +.cfi_offset %r12,-32 + pushq %r13 +.cfi_offset %r13,-40 + pushq %r14 +.cfi_offset %r14,-48 + pushq %r15 +.cfi_offset %r15,-56 + shlq $4,%rdx + subq $96,%rsp + leaq (%rsi,%rdx,4),%rdx + andq $-64,%rsp + movq %rdi,64+0(%rsp) + movq %rsi,64+8(%rsp) + movq %rdx,64+16(%rsp) + movq %rax,88(%rsp) +.cfi_escape 0x0f,0x06,0x77,0xd8,0x00,0x06,0x23,0x08 +.Lprologue_avx: + + vzeroupper + movl 0(%rdi),%eax + movl 4(%rdi),%ebx + movl 8(%rdi),%ecx + movl 12(%rdi),%edx + movl 16(%rdi),%r8d + movl 20(%rdi),%r9d + movl 24(%rdi),%r10d + movl 28(%rdi),%r11d + vmovdqa K256+512+32(%rip),%xmm8 + vmovdqa K256+512+64(%rip),%xmm9 + jmp .Lloop_avx +.align 16 +.Lloop_avx: + vmovdqa K256+512(%rip),%xmm7 + vmovdqu 0(%rsi),%xmm0 + vmovdqu 16(%rsi),%xmm1 + vmovdqu 32(%rsi),%xmm2 + vmovdqu 48(%rsi),%xmm3 + vpshufb %xmm7,%xmm0,%xmm0 + leaq K256(%rip),%rbp + vpshufb %xmm7,%xmm1,%xmm1 + vpshufb %xmm7,%xmm2,%xmm2 + vpaddd 0(%rbp),%xmm0,%xmm4 + vpshufb %xmm7,%xmm3,%xmm3 + vpaddd 32(%rbp),%xmm1,%xmm5 + vpaddd 64(%rbp),%xmm2,%xmm6 + vpaddd 96(%rbp),%xmm3,%xmm7 + vmovdqa %xmm4,0(%rsp) + movl %eax,%r14d + vmovdqa %xmm5,16(%rsp) + movl %ebx,%edi + vmovdqa %xmm6,32(%rsp) + xorl %ecx,%edi + vmovdqa %xmm7,48(%rsp) + movl %r8d,%r13d + jmp .Lavx_00_47 + +.align 16 +.Lavx_00_47: + subq $-128,%rbp + vpalignr $4,%xmm0,%xmm1,%xmm4 + shrdl $14,%r13d,%r13d + movl %r14d,%eax + movl %r9d,%r12d + vpalignr $4,%xmm2,%xmm3,%xmm7 + shrdl $9,%r14d,%r14d + xorl %r8d,%r13d + xorl %r10d,%r12d + vpsrld $7,%xmm4,%xmm6 + shrdl $5,%r13d,%r13d + xorl %eax,%r14d + andl %r8d,%r12d + vpaddd %xmm7,%xmm0,%xmm0 + xorl %r8d,%r13d + addl 0(%rsp),%r11d + movl %eax,%r15d + vpsrld $3,%xmm4,%xmm7 + xorl %r10d,%r12d + shrdl $11,%r14d,%r14d + xorl %ebx,%r15d + vpslld $14,%xmm4,%xmm5 + addl %r12d,%r11d + shrdl $6,%r13d,%r13d + andl %r15d,%edi + vpxor %xmm6,%xmm7,%xmm4 + xorl %eax,%r14d + addl %r13d,%r11d + xorl %ebx,%edi + vpshufd $250,%xmm3,%xmm7 + shrdl $2,%r14d,%r14d + addl %r11d,%edx + addl %edi,%r11d + vpsrld $11,%xmm6,%xmm6 + movl %edx,%r13d + addl %r11d,%r14d + shrdl $14,%r13d,%r13d + vpxor %xmm5,%xmm4,%xmm4 + movl %r14d,%r11d + movl %r8d,%r12d + shrdl $9,%r14d,%r14d + vpslld $11,%xmm5,%xmm5 + xorl %edx,%r13d + xorl %r9d,%r12d + shrdl $5,%r13d,%r13d + vpxor %xmm6,%xmm4,%xmm4 + xorl %r11d,%r14d + andl %edx,%r12d + xorl %edx,%r13d + vpsrld $10,%xmm7,%xmm6 + addl 4(%rsp),%r10d + movl %r11d,%edi + xorl %r9d,%r12d + vpxor %xmm5,%xmm4,%xmm4 + shrdl $11,%r14d,%r14d + xorl %eax,%edi + addl %r12d,%r10d + vpsrlq $17,%xmm7,%xmm7 + shrdl $6,%r13d,%r13d + andl %edi,%r15d + xorl %r11d,%r14d + vpaddd %xmm4,%xmm0,%xmm0 + addl %r13d,%r10d + xorl %eax,%r15d + shrdl $2,%r14d,%r14d + vpxor %xmm7,%xmm6,%xmm6 + addl %r10d,%ecx + addl %r15d,%r10d + movl %ecx,%r13d + vpsrlq $2,%xmm7,%xmm7 + addl %r10d,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%r10d + vpxor %xmm7,%xmm6,%xmm6 + movl %edx,%r12d + shrdl $9,%r14d,%r14d + xorl %ecx,%r13d + vpshufb %xmm8,%xmm6,%xmm6 + xorl %r8d,%r12d + shrdl $5,%r13d,%r13d + xorl %r10d,%r14d + vpaddd %xmm6,%xmm0,%xmm0 + andl %ecx,%r12d + xorl %ecx,%r13d + addl 8(%rsp),%r9d + vpshufd $80,%xmm0,%xmm7 + movl %r10d,%r15d + xorl %r8d,%r12d + shrdl $11,%r14d,%r14d + vpsrld $10,%xmm7,%xmm6 + xorl %r11d,%r15d + addl %r12d,%r9d + shrdl $6,%r13d,%r13d + vpsrlq $17,%xmm7,%xmm7 + andl %r15d,%edi + xorl %r10d,%r14d + addl %r13d,%r9d + vpxor %xmm7,%xmm6,%xmm6 + xorl %r11d,%edi + shrdl $2,%r14d,%r14d + addl %r9d,%ebx + vpsrlq $2,%xmm7,%xmm7 + addl %edi,%r9d + movl %ebx,%r13d + addl %r9d,%r14d + vpxor %xmm7,%xmm6,%xmm6 + shrdl $14,%r13d,%r13d + movl %r14d,%r9d + movl %ecx,%r12d + vpshufb %xmm9,%xmm6,%xmm6 + shrdl $9,%r14d,%r14d + xorl %ebx,%r13d + xorl %edx,%r12d + vpaddd %xmm6,%xmm0,%xmm0 + shrdl $5,%r13d,%r13d + xorl %r9d,%r14d + andl %ebx,%r12d + vpaddd 0(%rbp),%xmm0,%xmm6 + xorl %ebx,%r13d + addl 12(%rsp),%r8d + movl %r9d,%edi + xorl %edx,%r12d + shrdl $11,%r14d,%r14d + xorl %r10d,%edi + addl %r12d,%r8d + shrdl $6,%r13d,%r13d + andl %edi,%r15d + xorl %r9d,%r14d + addl %r13d,%r8d + xorl %r10d,%r15d + shrdl $2,%r14d,%r14d + addl %r8d,%eax + addl %r15d,%r8d + movl %eax,%r13d + addl %r8d,%r14d + vmovdqa %xmm6,0(%rsp) + vpalignr $4,%xmm1,%xmm2,%xmm4 + shrdl $14,%r13d,%r13d + movl %r14d,%r8d + movl %ebx,%r12d + vpalignr $4,%xmm3,%xmm0,%xmm7 + shrdl $9,%r14d,%r14d + xorl %eax,%r13d + xorl %ecx,%r12d + vpsrld $7,%xmm4,%xmm6 + shrdl $5,%r13d,%r13d + xorl %r8d,%r14d + andl %eax,%r12d + vpaddd %xmm7,%xmm1,%xmm1 + xorl %eax,%r13d + addl 16(%rsp),%edx + movl %r8d,%r15d + vpsrld $3,%xmm4,%xmm7 + xorl %ecx,%r12d + shrdl $11,%r14d,%r14d + xorl %r9d,%r15d + vpslld $14,%xmm4,%xmm5 + addl %r12d,%edx + shrdl $6,%r13d,%r13d + andl %r15d,%edi + vpxor %xmm6,%xmm7,%xmm4 + xorl %r8d,%r14d + addl %r13d,%edx + xorl %r9d,%edi + vpshufd $250,%xmm0,%xmm7 + shrdl $2,%r14d,%r14d + addl %edx,%r11d + addl %edi,%edx + vpsrld $11,%xmm6,%xmm6 + movl %r11d,%r13d + addl %edx,%r14d + shrdl $14,%r13d,%r13d + vpxor %xmm5,%xmm4,%xmm4 + movl %r14d,%edx + movl %eax,%r12d + shrdl $9,%r14d,%r14d + vpslld $11,%xmm5,%xmm5 + xorl %r11d,%r13d + xorl %ebx,%r12d + shrdl $5,%r13d,%r13d + vpxor %xmm6,%xmm4,%xmm4 + xorl %edx,%r14d + andl %r11d,%r12d + xorl %r11d,%r13d + vpsrld $10,%xmm7,%xmm6 + addl 20(%rsp),%ecx + movl %edx,%edi + xorl %ebx,%r12d + vpxor %xmm5,%xmm4,%xmm4 + shrdl $11,%r14d,%r14d + xorl %r8d,%edi + addl %r12d,%ecx + vpsrlq $17,%xmm7,%xmm7 + shrdl $6,%r13d,%r13d + andl %edi,%r15d + xorl %edx,%r14d + vpaddd %xmm4,%xmm1,%xmm1 + addl %r13d,%ecx + xorl %r8d,%r15d + shrdl $2,%r14d,%r14d + vpxor %xmm7,%xmm6,%xmm6 + addl %ecx,%r10d + addl %r15d,%ecx + movl %r10d,%r13d + vpsrlq $2,%xmm7,%xmm7 + addl %ecx,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%ecx + vpxor %xmm7,%xmm6,%xmm6 + movl %r11d,%r12d + shrdl $9,%r14d,%r14d + xorl %r10d,%r13d + vpshufb %xmm8,%xmm6,%xmm6 + xorl %eax,%r12d + shrdl $5,%r13d,%r13d + xorl %ecx,%r14d + vpaddd %xmm6,%xmm1,%xmm1 + andl %r10d,%r12d + xorl %r10d,%r13d + addl 24(%rsp),%ebx + vpshufd $80,%xmm1,%xmm7 + movl %ecx,%r15d + xorl %eax,%r12d + shrdl $11,%r14d,%r14d + vpsrld $10,%xmm7,%xmm6 + xorl %edx,%r15d + addl %r12d,%ebx + shrdl $6,%r13d,%r13d + vpsrlq $17,%xmm7,%xmm7 + andl %r15d,%edi + xorl %ecx,%r14d + addl %r13d,%ebx + vpxor %xmm7,%xmm6,%xmm6 + xorl %edx,%edi + shrdl $2,%r14d,%r14d + addl %ebx,%r9d + vpsrlq $2,%xmm7,%xmm7 + addl %edi,%ebx + movl %r9d,%r13d + addl %ebx,%r14d + vpxor %xmm7,%xmm6,%xmm6 + shrdl $14,%r13d,%r13d + movl %r14d,%ebx + movl %r10d,%r12d + vpshufb %xmm9,%xmm6,%xmm6 + shrdl $9,%r14d,%r14d + xorl %r9d,%r13d + xorl %r11d,%r12d + vpaddd %xmm6,%xmm1,%xmm1 + shrdl $5,%r13d,%r13d + xorl %ebx,%r14d + andl %r9d,%r12d + vpaddd 32(%rbp),%xmm1,%xmm6 + xorl %r9d,%r13d + addl 28(%rsp),%eax + movl %ebx,%edi + xorl %r11d,%r12d + shrdl $11,%r14d,%r14d + xorl %ecx,%edi + addl %r12d,%eax + shrdl $6,%r13d,%r13d + andl %edi,%r15d + xorl %ebx,%r14d + addl %r13d,%eax + xorl %ecx,%r15d + shrdl $2,%r14d,%r14d + addl %eax,%r8d + addl %r15d,%eax + movl %r8d,%r13d + addl %eax,%r14d + vmovdqa %xmm6,16(%rsp) + vpalignr $4,%xmm2,%xmm3,%xmm4 + shrdl $14,%r13d,%r13d + movl %r14d,%eax + movl %r9d,%r12d + vpalignr $4,%xmm0,%xmm1,%xmm7 + shrdl $9,%r14d,%r14d + xorl %r8d,%r13d + xorl %r10d,%r12d + vpsrld $7,%xmm4,%xmm6 + shrdl $5,%r13d,%r13d + xorl %eax,%r14d + andl %r8d,%r12d + vpaddd %xmm7,%xmm2,%xmm2 + xorl %r8d,%r13d + addl 32(%rsp),%r11d + movl %eax,%r15d + vpsrld $3,%xmm4,%xmm7 + xorl %r10d,%r12d + shrdl $11,%r14d,%r14d + xorl %ebx,%r15d + vpslld $14,%xmm4,%xmm5 + addl %r12d,%r11d + shrdl $6,%r13d,%r13d + andl %r15d,%edi + vpxor %xmm6,%xmm7,%xmm4 + xorl %eax,%r14d + addl %r13d,%r11d + xorl %ebx,%edi + vpshufd $250,%xmm1,%xmm7 + shrdl $2,%r14d,%r14d + addl %r11d,%edx + addl %edi,%r11d + vpsrld $11,%xmm6,%xmm6 + movl %edx,%r13d + addl %r11d,%r14d + shrdl $14,%r13d,%r13d + vpxor %xmm5,%xmm4,%xmm4 + movl %r14d,%r11d + movl %r8d,%r12d + shrdl $9,%r14d,%r14d + vpslld $11,%xmm5,%xmm5 + xorl %edx,%r13d + xorl %r9d,%r12d + shrdl $5,%r13d,%r13d + vpxor %xmm6,%xmm4,%xmm4 + xorl %r11d,%r14d + andl %edx,%r12d + xorl %edx,%r13d + vpsrld $10,%xmm7,%xmm6 + addl 36(%rsp),%r10d + movl %r11d,%edi + xorl %r9d,%r12d + vpxor %xmm5,%xmm4,%xmm4 + shrdl $11,%r14d,%r14d + xorl %eax,%edi + addl %r12d,%r10d + vpsrlq $17,%xmm7,%xmm7 + shrdl $6,%r13d,%r13d + andl %edi,%r15d + xorl %r11d,%r14d + vpaddd %xmm4,%xmm2,%xmm2 + addl %r13d,%r10d + xorl %eax,%r15d + shrdl $2,%r14d,%r14d + vpxor %xmm7,%xmm6,%xmm6 + addl %r10d,%ecx + addl %r15d,%r10d + movl %ecx,%r13d + vpsrlq $2,%xmm7,%xmm7 + addl %r10d,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%r10d + vpxor %xmm7,%xmm6,%xmm6 + movl %edx,%r12d + shrdl $9,%r14d,%r14d + xorl %ecx,%r13d + vpshufb %xmm8,%xmm6,%xmm6 + xorl %r8d,%r12d + shrdl $5,%r13d,%r13d + xorl %r10d,%r14d + vpaddd %xmm6,%xmm2,%xmm2 + andl %ecx,%r12d + xorl %ecx,%r13d + addl 40(%rsp),%r9d + vpshufd $80,%xmm2,%xmm7 + movl %r10d,%r15d + xorl %r8d,%r12d + shrdl $11,%r14d,%r14d + vpsrld $10,%xmm7,%xmm6 + xorl %r11d,%r15d + addl %r12d,%r9d + shrdl $6,%r13d,%r13d + vpsrlq $17,%xmm7,%xmm7 + andl %r15d,%edi + xorl %r10d,%r14d + addl %r13d,%r9d + vpxor %xmm7,%xmm6,%xmm6 + xorl %r11d,%edi + shrdl $2,%r14d,%r14d + addl %r9d,%ebx + vpsrlq $2,%xmm7,%xmm7 + addl %edi,%r9d + movl %ebx,%r13d + addl %r9d,%r14d + vpxor %xmm7,%xmm6,%xmm6 + shrdl $14,%r13d,%r13d + movl %r14d,%r9d + movl %ecx,%r12d + vpshufb %xmm9,%xmm6,%xmm6 + shrdl $9,%r14d,%r14d + xorl %ebx,%r13d + xorl %edx,%r12d + vpaddd %xmm6,%xmm2,%xmm2 + shrdl $5,%r13d,%r13d + xorl %r9d,%r14d + andl %ebx,%r12d + vpaddd 64(%rbp),%xmm2,%xmm6 + xorl %ebx,%r13d + addl 44(%rsp),%r8d + movl %r9d,%edi + xorl %edx,%r12d + shrdl $11,%r14d,%r14d + xorl %r10d,%edi + addl %r12d,%r8d + shrdl $6,%r13d,%r13d + andl %edi,%r15d + xorl %r9d,%r14d + addl %r13d,%r8d + xorl %r10d,%r15d + shrdl $2,%r14d,%r14d + addl %r8d,%eax + addl %r15d,%r8d + movl %eax,%r13d + addl %r8d,%r14d + vmovdqa %xmm6,32(%rsp) + vpalignr $4,%xmm3,%xmm0,%xmm4 + shrdl $14,%r13d,%r13d + movl %r14d,%r8d + movl %ebx,%r12d + vpalignr $4,%xmm1,%xmm2,%xmm7 + shrdl $9,%r14d,%r14d + xorl %eax,%r13d + xorl %ecx,%r12d + vpsrld $7,%xmm4,%xmm6 + shrdl $5,%r13d,%r13d + xorl %r8d,%r14d + andl %eax,%r12d + vpaddd %xmm7,%xmm3,%xmm3 + xorl %eax,%r13d + addl 48(%rsp),%edx + movl %r8d,%r15d + vpsrld $3,%xmm4,%xmm7 + xorl %ecx,%r12d + shrdl $11,%r14d,%r14d + xorl %r9d,%r15d + vpslld $14,%xmm4,%xmm5 + addl %r12d,%edx + shrdl $6,%r13d,%r13d + andl %r15d,%edi + vpxor %xmm6,%xmm7,%xmm4 + xorl %r8d,%r14d + addl %r13d,%edx + xorl %r9d,%edi + vpshufd $250,%xmm2,%xmm7 + shrdl $2,%r14d,%r14d + addl %edx,%r11d + addl %edi,%edx + vpsrld $11,%xmm6,%xmm6 + movl %r11d,%r13d + addl %edx,%r14d + shrdl $14,%r13d,%r13d + vpxor %xmm5,%xmm4,%xmm4 + movl %r14d,%edx + movl %eax,%r12d + shrdl $9,%r14d,%r14d + vpslld $11,%xmm5,%xmm5 + xorl %r11d,%r13d + xorl %ebx,%r12d + shrdl $5,%r13d,%r13d + vpxor %xmm6,%xmm4,%xmm4 + xorl %edx,%r14d + andl %r11d,%r12d + xorl %r11d,%r13d + vpsrld $10,%xmm7,%xmm6 + addl 52(%rsp),%ecx + movl %edx,%edi + xorl %ebx,%r12d + vpxor %xmm5,%xmm4,%xmm4 + shrdl $11,%r14d,%r14d + xorl %r8d,%edi + addl %r12d,%ecx + vpsrlq $17,%xmm7,%xmm7 + shrdl $6,%r13d,%r13d + andl %edi,%r15d + xorl %edx,%r14d + vpaddd %xmm4,%xmm3,%xmm3 + addl %r13d,%ecx + xorl %r8d,%r15d + shrdl $2,%r14d,%r14d + vpxor %xmm7,%xmm6,%xmm6 + addl %ecx,%r10d + addl %r15d,%ecx + movl %r10d,%r13d + vpsrlq $2,%xmm7,%xmm7 + addl %ecx,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%ecx + vpxor %xmm7,%xmm6,%xmm6 + movl %r11d,%r12d + shrdl $9,%r14d,%r14d + xorl %r10d,%r13d + vpshufb %xmm8,%xmm6,%xmm6 + xorl %eax,%r12d + shrdl $5,%r13d,%r13d + xorl %ecx,%r14d + vpaddd %xmm6,%xmm3,%xmm3 + andl %r10d,%r12d + xorl %r10d,%r13d + addl 56(%rsp),%ebx + vpshufd $80,%xmm3,%xmm7 + movl %ecx,%r15d + xorl %eax,%r12d + shrdl $11,%r14d,%r14d + vpsrld $10,%xmm7,%xmm6 + xorl %edx,%r15d + addl %r12d,%ebx + shrdl $6,%r13d,%r13d + vpsrlq $17,%xmm7,%xmm7 + andl %r15d,%edi + xorl %ecx,%r14d + addl %r13d,%ebx + vpxor %xmm7,%xmm6,%xmm6 + xorl %edx,%edi + shrdl $2,%r14d,%r14d + addl %ebx,%r9d + vpsrlq $2,%xmm7,%xmm7 + addl %edi,%ebx + movl %r9d,%r13d + addl %ebx,%r14d + vpxor %xmm7,%xmm6,%xmm6 + shrdl $14,%r13d,%r13d + movl %r14d,%ebx + movl %r10d,%r12d + vpshufb %xmm9,%xmm6,%xmm6 + shrdl $9,%r14d,%r14d + xorl %r9d,%r13d + xorl %r11d,%r12d + vpaddd %xmm6,%xmm3,%xmm3 + shrdl $5,%r13d,%r13d + xorl %ebx,%r14d + andl %r9d,%r12d + vpaddd 96(%rbp),%xmm3,%xmm6 + xorl %r9d,%r13d + addl 60(%rsp),%eax + movl %ebx,%edi + xorl %r11d,%r12d + shrdl $11,%r14d,%r14d + xorl %ecx,%edi + addl %r12d,%eax + shrdl $6,%r13d,%r13d + andl %edi,%r15d + xorl %ebx,%r14d + addl %r13d,%eax + xorl %ecx,%r15d + shrdl $2,%r14d,%r14d + addl %eax,%r8d + addl %r15d,%eax + movl %r8d,%r13d + addl %eax,%r14d + vmovdqa %xmm6,48(%rsp) + cmpb $0,131(%rbp) + jne .Lavx_00_47 + shrdl $14,%r13d,%r13d + movl %r14d,%eax + movl %r9d,%r12d + shrdl $9,%r14d,%r14d + xorl %r8d,%r13d + xorl %r10d,%r12d + shrdl $5,%r13d,%r13d + xorl %eax,%r14d + andl %r8d,%r12d + xorl %r8d,%r13d + addl 0(%rsp),%r11d + movl %eax,%r15d + xorl %r10d,%r12d + shrdl $11,%r14d,%r14d + xorl %ebx,%r15d + addl %r12d,%r11d + shrdl $6,%r13d,%r13d + andl %r15d,%edi + xorl %eax,%r14d + addl %r13d,%r11d + xorl %ebx,%edi + shrdl $2,%r14d,%r14d + addl %r11d,%edx + addl %edi,%r11d + movl %edx,%r13d + addl %r11d,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%r11d + movl %r8d,%r12d + shrdl $9,%r14d,%r14d + xorl %edx,%r13d + xorl %r9d,%r12d + shrdl $5,%r13d,%r13d + xorl %r11d,%r14d + andl %edx,%r12d + xorl %edx,%r13d + addl 4(%rsp),%r10d + movl %r11d,%edi + xorl %r9d,%r12d + shrdl $11,%r14d,%r14d + xorl %eax,%edi + addl %r12d,%r10d + shrdl $6,%r13d,%r13d + andl %edi,%r15d + xorl %r11d,%r14d + addl %r13d,%r10d + xorl %eax,%r15d + shrdl $2,%r14d,%r14d + addl %r10d,%ecx + addl %r15d,%r10d + movl %ecx,%r13d + addl %r10d,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%r10d + movl %edx,%r12d + shrdl $9,%r14d,%r14d + xorl %ecx,%r13d + xorl %r8d,%r12d + shrdl $5,%r13d,%r13d + xorl %r10d,%r14d + andl %ecx,%r12d + xorl %ecx,%r13d + addl 8(%rsp),%r9d + movl %r10d,%r15d + xorl %r8d,%r12d + shrdl $11,%r14d,%r14d + xorl %r11d,%r15d + addl %r12d,%r9d + shrdl $6,%r13d,%r13d + andl %r15d,%edi + xorl %r10d,%r14d + addl %r13d,%r9d + xorl %r11d,%edi + shrdl $2,%r14d,%r14d + addl %r9d,%ebx + addl %edi,%r9d + movl %ebx,%r13d + addl %r9d,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%r9d + movl %ecx,%r12d + shrdl $9,%r14d,%r14d + xorl %ebx,%r13d + xorl %edx,%r12d + shrdl $5,%r13d,%r13d + xorl %r9d,%r14d + andl %ebx,%r12d + xorl %ebx,%r13d + addl 12(%rsp),%r8d + movl %r9d,%edi + xorl %edx,%r12d + shrdl $11,%r14d,%r14d + xorl %r10d,%edi + addl %r12d,%r8d + shrdl $6,%r13d,%r13d + andl %edi,%r15d + xorl %r9d,%r14d + addl %r13d,%r8d + xorl %r10d,%r15d + shrdl $2,%r14d,%r14d + addl %r8d,%eax + addl %r15d,%r8d + movl %eax,%r13d + addl %r8d,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%r8d + movl %ebx,%r12d + shrdl $9,%r14d,%r14d + xorl %eax,%r13d + xorl %ecx,%r12d + shrdl $5,%r13d,%r13d + xorl %r8d,%r14d + andl %eax,%r12d + xorl %eax,%r13d + addl 16(%rsp),%edx + movl %r8d,%r15d + xorl %ecx,%r12d + shrdl $11,%r14d,%r14d + xorl %r9d,%r15d + addl %r12d,%edx + shrdl $6,%r13d,%r13d + andl %r15d,%edi + xorl %r8d,%r14d + addl %r13d,%edx + xorl %r9d,%edi + shrdl $2,%r14d,%r14d + addl %edx,%r11d + addl %edi,%edx + movl %r11d,%r13d + addl %edx,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%edx + movl %eax,%r12d + shrdl $9,%r14d,%r14d + xorl %r11d,%r13d + xorl %ebx,%r12d + shrdl $5,%r13d,%r13d + xorl %edx,%r14d + andl %r11d,%r12d + xorl %r11d,%r13d + addl 20(%rsp),%ecx + movl %edx,%edi + xorl %ebx,%r12d + shrdl $11,%r14d,%r14d + xorl %r8d,%edi + addl %r12d,%ecx + shrdl $6,%r13d,%r13d + andl %edi,%r15d + xorl %edx,%r14d + addl %r13d,%ecx + xorl %r8d,%r15d + shrdl $2,%r14d,%r14d + addl %ecx,%r10d + addl %r15d,%ecx + movl %r10d,%r13d + addl %ecx,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%ecx + movl %r11d,%r12d + shrdl $9,%r14d,%r14d + xorl %r10d,%r13d + xorl %eax,%r12d + shrdl $5,%r13d,%r13d + xorl %ecx,%r14d + andl %r10d,%r12d + xorl %r10d,%r13d + addl 24(%rsp),%ebx + movl %ecx,%r15d + xorl %eax,%r12d + shrdl $11,%r14d,%r14d + xorl %edx,%r15d + addl %r12d,%ebx + shrdl $6,%r13d,%r13d + andl %r15d,%edi + xorl %ecx,%r14d + addl %r13d,%ebx + xorl %edx,%edi + shrdl $2,%r14d,%r14d + addl %ebx,%r9d + addl %edi,%ebx + movl %r9d,%r13d + addl %ebx,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%ebx + movl %r10d,%r12d + shrdl $9,%r14d,%r14d + xorl %r9d,%r13d + xorl %r11d,%r12d + shrdl $5,%r13d,%r13d + xorl %ebx,%r14d + andl %r9d,%r12d + xorl %r9d,%r13d + addl 28(%rsp),%eax + movl %ebx,%edi + xorl %r11d,%r12d + shrdl $11,%r14d,%r14d + xorl %ecx,%edi + addl %r12d,%eax + shrdl $6,%r13d,%r13d + andl %edi,%r15d + xorl %ebx,%r14d + addl %r13d,%eax + xorl %ecx,%r15d + shrdl $2,%r14d,%r14d + addl %eax,%r8d + addl %r15d,%eax + movl %r8d,%r13d + addl %eax,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%eax + movl %r9d,%r12d + shrdl $9,%r14d,%r14d + xorl %r8d,%r13d + xorl %r10d,%r12d + shrdl $5,%r13d,%r13d + xorl %eax,%r14d + andl %r8d,%r12d + xorl %r8d,%r13d + addl 32(%rsp),%r11d + movl %eax,%r15d + xorl %r10d,%r12d + shrdl $11,%r14d,%r14d + xorl %ebx,%r15d + addl %r12d,%r11d + shrdl $6,%r13d,%r13d + andl %r15d,%edi + xorl %eax,%r14d + addl %r13d,%r11d + xorl %ebx,%edi + shrdl $2,%r14d,%r14d + addl %r11d,%edx + addl %edi,%r11d + movl %edx,%r13d + addl %r11d,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%r11d + movl %r8d,%r12d + shrdl $9,%r14d,%r14d + xorl %edx,%r13d + xorl %r9d,%r12d + shrdl $5,%r13d,%r13d + xorl %r11d,%r14d + andl %edx,%r12d + xorl %edx,%r13d + addl 36(%rsp),%r10d + movl %r11d,%edi + xorl %r9d,%r12d + shrdl $11,%r14d,%r14d + xorl %eax,%edi + addl %r12d,%r10d + shrdl $6,%r13d,%r13d + andl %edi,%r15d + xorl %r11d,%r14d + addl %r13d,%r10d + xorl %eax,%r15d + shrdl $2,%r14d,%r14d + addl %r10d,%ecx + addl %r15d,%r10d + movl %ecx,%r13d + addl %r10d,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%r10d + movl %edx,%r12d + shrdl $9,%r14d,%r14d + xorl %ecx,%r13d + xorl %r8d,%r12d + shrdl $5,%r13d,%r13d + xorl %r10d,%r14d + andl %ecx,%r12d + xorl %ecx,%r13d + addl 40(%rsp),%r9d + movl %r10d,%r15d + xorl %r8d,%r12d + shrdl $11,%r14d,%r14d + xorl %r11d,%r15d + addl %r12d,%r9d + shrdl $6,%r13d,%r13d + andl %r15d,%edi + xorl %r10d,%r14d + addl %r13d,%r9d + xorl %r11d,%edi + shrdl $2,%r14d,%r14d + addl %r9d,%ebx + addl %edi,%r9d + movl %ebx,%r13d + addl %r9d,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%r9d + movl %ecx,%r12d + shrdl $9,%r14d,%r14d + xorl %ebx,%r13d + xorl %edx,%r12d + shrdl $5,%r13d,%r13d + xorl %r9d,%r14d + andl %ebx,%r12d + xorl %ebx,%r13d + addl 44(%rsp),%r8d + movl %r9d,%edi + xorl %edx,%r12d + shrdl $11,%r14d,%r14d + xorl %r10d,%edi + addl %r12d,%r8d + shrdl $6,%r13d,%r13d + andl %edi,%r15d + xorl %r9d,%r14d + addl %r13d,%r8d + xorl %r10d,%r15d + shrdl $2,%r14d,%r14d + addl %r8d,%eax + addl %r15d,%r8d + movl %eax,%r13d + addl %r8d,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%r8d + movl %ebx,%r12d + shrdl $9,%r14d,%r14d + xorl %eax,%r13d + xorl %ecx,%r12d + shrdl $5,%r13d,%r13d + xorl %r8d,%r14d + andl %eax,%r12d + xorl %eax,%r13d + addl 48(%rsp),%edx + movl %r8d,%r15d + xorl %ecx,%r12d + shrdl $11,%r14d,%r14d + xorl %r9d,%r15d + addl %r12d,%edx + shrdl $6,%r13d,%r13d + andl %r15d,%edi + xorl %r8d,%r14d + addl %r13d,%edx + xorl %r9d,%edi + shrdl $2,%r14d,%r14d + addl %edx,%r11d + addl %edi,%edx + movl %r11d,%r13d + addl %edx,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%edx + movl %eax,%r12d + shrdl $9,%r14d,%r14d + xorl %r11d,%r13d + xorl %ebx,%r12d + shrdl $5,%r13d,%r13d + xorl %edx,%r14d + andl %r11d,%r12d + xorl %r11d,%r13d + addl 52(%rsp),%ecx + movl %edx,%edi + xorl %ebx,%r12d + shrdl $11,%r14d,%r14d + xorl %r8d,%edi + addl %r12d,%ecx + shrdl $6,%r13d,%r13d + andl %edi,%r15d + xorl %edx,%r14d + addl %r13d,%ecx + xorl %r8d,%r15d + shrdl $2,%r14d,%r14d + addl %ecx,%r10d + addl %r15d,%ecx + movl %r10d,%r13d + addl %ecx,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%ecx + movl %r11d,%r12d + shrdl $9,%r14d,%r14d + xorl %r10d,%r13d + xorl %eax,%r12d + shrdl $5,%r13d,%r13d + xorl %ecx,%r14d + andl %r10d,%r12d + xorl %r10d,%r13d + addl 56(%rsp),%ebx + movl %ecx,%r15d + xorl %eax,%r12d + shrdl $11,%r14d,%r14d + xorl %edx,%r15d + addl %r12d,%ebx + shrdl $6,%r13d,%r13d + andl %r15d,%edi + xorl %ecx,%r14d + addl %r13d,%ebx + xorl %edx,%edi + shrdl $2,%r14d,%r14d + addl %ebx,%r9d + addl %edi,%ebx + movl %r9d,%r13d + addl %ebx,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%ebx + movl %r10d,%r12d + shrdl $9,%r14d,%r14d + xorl %r9d,%r13d + xorl %r11d,%r12d + shrdl $5,%r13d,%r13d + xorl %ebx,%r14d + andl %r9d,%r12d + xorl %r9d,%r13d + addl 60(%rsp),%eax + movl %ebx,%edi + xorl %r11d,%r12d + shrdl $11,%r14d,%r14d + xorl %ecx,%edi + addl %r12d,%eax + shrdl $6,%r13d,%r13d + andl %edi,%r15d + xorl %ebx,%r14d + addl %r13d,%eax + xorl %ecx,%r15d + shrdl $2,%r14d,%r14d + addl %eax,%r8d + addl %r15d,%eax + movl %r8d,%r13d + addl %eax,%r14d + movq 64+0(%rsp),%rdi + movl %r14d,%eax + + addl 0(%rdi),%eax + leaq 64(%rsi),%rsi + addl 4(%rdi),%ebx + addl 8(%rdi),%ecx + addl 12(%rdi),%edx + addl 16(%rdi),%r8d + addl 20(%rdi),%r9d + addl 24(%rdi),%r10d + addl 28(%rdi),%r11d + + cmpq 64+16(%rsp),%rsi + + movl %eax,0(%rdi) + movl %ebx,4(%rdi) + movl %ecx,8(%rdi) + movl %edx,12(%rdi) + movl %r8d,16(%rdi) + movl %r9d,20(%rdi) + movl %r10d,24(%rdi) + movl %r11d,28(%rdi) + jb .Lloop_avx + + movq 88(%rsp),%rsi +.cfi_def_cfa %rsi,8 + vzeroupper + movq -48(%rsi),%r15 +.cfi_restore %r15 + movq -40(%rsi),%r14 +.cfi_restore %r14 + movq -32(%rsi),%r13 +.cfi_restore %r13 + movq -24(%rsi),%r12 +.cfi_restore %r12 + movq -16(%rsi),%rbp +.cfi_restore %rbp + movq -8(%rsi),%rbx +.cfi_restore %rbx + leaq (%rsi),%rsp +.cfi_def_cfa_register %rsp +.Lepilogue_avx: + ret +.cfi_endproc +.size sha256_block_data_order_avx,.-sha256_block_data_order_avx +#endif diff --git a/http/vendor/ring/pregenerated/sha256-x86_64-macosx.S b/http/vendor/ring/pregenerated/sha256-x86_64-macosx.S new file mode 100644 index 0000000..fe5d347 --- /dev/null +++ b/http/vendor/ring/pregenerated/sha256-x86_64-macosx.S @@ -0,0 +1,4170 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__) +.text + +.globl _sha256_block_data_order_nohw +.private_extern _sha256_block_data_order_nohw + +.p2align 4 +_sha256_block_data_order_nohw: + +_CET_ENDBR + movq %rsp,%rax + + pushq %rbx + + pushq %rbp + + pushq %r12 + + pushq %r13 + + pushq %r14 + + pushq %r15 + + shlq $4,%rdx + subq $64+32,%rsp + leaq (%rsi,%rdx,4),%rdx + andq $-64,%rsp + movq %rdi,64+0(%rsp) + movq %rsi,64+8(%rsp) + movq %rdx,64+16(%rsp) + movq %rax,88(%rsp) + +L$prologue: + + movl 0(%rdi),%eax + movl 4(%rdi),%ebx + movl 8(%rdi),%ecx + movl 12(%rdi),%edx + movl 16(%rdi),%r8d + movl 20(%rdi),%r9d + movl 24(%rdi),%r10d + movl 28(%rdi),%r11d + jmp L$loop + +.p2align 4 +L$loop: + movl %ebx,%edi + leaq K256(%rip),%rbp + xorl %ecx,%edi + movl 0(%rsi),%r12d + movl %r8d,%r13d + movl %eax,%r14d + bswapl %r12d + rorl $14,%r13d + movl %r9d,%r15d + + xorl %r8d,%r13d + rorl $9,%r14d + xorl %r10d,%r15d + + movl %r12d,0(%rsp) + xorl %eax,%r14d + andl %r8d,%r15d + + rorl $5,%r13d + addl %r11d,%r12d + xorl %r10d,%r15d + + rorl $11,%r14d + xorl %r8d,%r13d + addl %r15d,%r12d + + movl %eax,%r15d + addl (%rbp),%r12d + xorl %eax,%r14d + + xorl %ebx,%r15d + rorl $6,%r13d + movl %ebx,%r11d + + andl %r15d,%edi + rorl $2,%r14d + addl %r13d,%r12d + + xorl %edi,%r11d + addl %r12d,%edx + addl %r12d,%r11d + + leaq 4(%rbp),%rbp + addl %r14d,%r11d + movl 4(%rsi),%r12d + movl %edx,%r13d + movl %r11d,%r14d + bswapl %r12d + rorl $14,%r13d + movl %r8d,%edi + + xorl %edx,%r13d + rorl $9,%r14d + xorl %r9d,%edi + + movl %r12d,4(%rsp) + xorl %r11d,%r14d + andl %edx,%edi + + rorl $5,%r13d + addl %r10d,%r12d + xorl %r9d,%edi + + rorl $11,%r14d + xorl %edx,%r13d + addl %edi,%r12d + + movl %r11d,%edi + addl (%rbp),%r12d + xorl %r11d,%r14d + + xorl %eax,%edi + rorl $6,%r13d + movl %eax,%r10d + + andl %edi,%r15d + rorl $2,%r14d + addl %r13d,%r12d + + xorl %r15d,%r10d + addl %r12d,%ecx + addl %r12d,%r10d + + leaq 4(%rbp),%rbp + addl %r14d,%r10d + movl 8(%rsi),%r12d + movl %ecx,%r13d + movl %r10d,%r14d + bswapl %r12d + rorl $14,%r13d + movl %edx,%r15d + + xorl %ecx,%r13d + rorl $9,%r14d + xorl %r8d,%r15d + + movl %r12d,8(%rsp) + xorl %r10d,%r14d + andl %ecx,%r15d + + rorl $5,%r13d + addl %r9d,%r12d + xorl %r8d,%r15d + + rorl $11,%r14d + xorl %ecx,%r13d + addl %r15d,%r12d + + movl %r10d,%r15d + addl (%rbp),%r12d + xorl %r10d,%r14d + + xorl %r11d,%r15d + rorl $6,%r13d + movl %r11d,%r9d + + andl %r15d,%edi + rorl $2,%r14d + addl %r13d,%r12d + + xorl %edi,%r9d + addl %r12d,%ebx + addl %r12d,%r9d + + leaq 4(%rbp),%rbp + addl %r14d,%r9d + movl 12(%rsi),%r12d + movl %ebx,%r13d + movl %r9d,%r14d + bswapl %r12d + rorl $14,%r13d + movl %ecx,%edi + + xorl %ebx,%r13d + rorl $9,%r14d + xorl %edx,%edi + + movl %r12d,12(%rsp) + xorl %r9d,%r14d + andl %ebx,%edi + + rorl $5,%r13d + addl %r8d,%r12d + xorl %edx,%edi + + rorl $11,%r14d + xorl %ebx,%r13d + addl %edi,%r12d + + movl %r9d,%edi + addl (%rbp),%r12d + xorl %r9d,%r14d + + xorl %r10d,%edi + rorl $6,%r13d + movl %r10d,%r8d + + andl %edi,%r15d + rorl $2,%r14d + addl %r13d,%r12d + + xorl %r15d,%r8d + addl %r12d,%eax + addl %r12d,%r8d + + leaq 20(%rbp),%rbp + addl %r14d,%r8d + movl 16(%rsi),%r12d + movl %eax,%r13d + movl %r8d,%r14d + bswapl %r12d + rorl $14,%r13d + movl %ebx,%r15d + + xorl %eax,%r13d + rorl $9,%r14d + xorl %ecx,%r15d + + movl %r12d,16(%rsp) + xorl %r8d,%r14d + andl %eax,%r15d + + rorl $5,%r13d + addl %edx,%r12d + xorl %ecx,%r15d + + rorl $11,%r14d + xorl %eax,%r13d + addl %r15d,%r12d + + movl %r8d,%r15d + addl (%rbp),%r12d + xorl %r8d,%r14d + + xorl %r9d,%r15d + rorl $6,%r13d + movl %r9d,%edx + + andl %r15d,%edi + rorl $2,%r14d + addl %r13d,%r12d + + xorl %edi,%edx + addl %r12d,%r11d + addl %r12d,%edx + + leaq 4(%rbp),%rbp + addl %r14d,%edx + movl 20(%rsi),%r12d + movl %r11d,%r13d + movl %edx,%r14d + bswapl %r12d + rorl $14,%r13d + movl %eax,%edi + + xorl %r11d,%r13d + rorl $9,%r14d + xorl %ebx,%edi + + movl %r12d,20(%rsp) + xorl %edx,%r14d + andl %r11d,%edi + + rorl $5,%r13d + addl %ecx,%r12d + xorl %ebx,%edi + + rorl $11,%r14d + xorl %r11d,%r13d + addl %edi,%r12d + + movl %edx,%edi + addl (%rbp),%r12d + xorl %edx,%r14d + + xorl %r8d,%edi + rorl $6,%r13d + movl %r8d,%ecx + + andl %edi,%r15d + rorl $2,%r14d + addl %r13d,%r12d + + xorl %r15d,%ecx + addl %r12d,%r10d + addl %r12d,%ecx + + leaq 4(%rbp),%rbp + addl %r14d,%ecx + movl 24(%rsi),%r12d + movl %r10d,%r13d + movl %ecx,%r14d + bswapl %r12d + rorl $14,%r13d + movl %r11d,%r15d + + xorl %r10d,%r13d + rorl $9,%r14d + xorl %eax,%r15d + + movl %r12d,24(%rsp) + xorl %ecx,%r14d + andl %r10d,%r15d + + rorl $5,%r13d + addl %ebx,%r12d + xorl %eax,%r15d + + rorl $11,%r14d + xorl %r10d,%r13d + addl %r15d,%r12d + + movl %ecx,%r15d + addl (%rbp),%r12d + xorl %ecx,%r14d + + xorl %edx,%r15d + rorl $6,%r13d + movl %edx,%ebx + + andl %r15d,%edi + rorl $2,%r14d + addl %r13d,%r12d + + xorl %edi,%ebx + addl %r12d,%r9d + addl %r12d,%ebx + + leaq 4(%rbp),%rbp + addl %r14d,%ebx + movl 28(%rsi),%r12d + movl %r9d,%r13d + movl %ebx,%r14d + bswapl %r12d + rorl $14,%r13d + movl %r10d,%edi + + xorl %r9d,%r13d + rorl $9,%r14d + xorl %r11d,%edi + + movl %r12d,28(%rsp) + xorl %ebx,%r14d + andl %r9d,%edi + + rorl $5,%r13d + addl %eax,%r12d + xorl %r11d,%edi + + rorl $11,%r14d + xorl %r9d,%r13d + addl %edi,%r12d + + movl %ebx,%edi + addl (%rbp),%r12d + xorl %ebx,%r14d + + xorl %ecx,%edi + rorl $6,%r13d + movl %ecx,%eax + + andl %edi,%r15d + rorl $2,%r14d + addl %r13d,%r12d + + xorl %r15d,%eax + addl %r12d,%r8d + addl %r12d,%eax + + leaq 20(%rbp),%rbp + addl %r14d,%eax + movl 32(%rsi),%r12d + movl %r8d,%r13d + movl %eax,%r14d + bswapl %r12d + rorl $14,%r13d + movl %r9d,%r15d + + xorl %r8d,%r13d + rorl $9,%r14d + xorl %r10d,%r15d + + movl %r12d,32(%rsp) + xorl %eax,%r14d + andl %r8d,%r15d + + rorl $5,%r13d + addl %r11d,%r12d + xorl %r10d,%r15d + + rorl $11,%r14d + xorl %r8d,%r13d + addl %r15d,%r12d + + movl %eax,%r15d + addl (%rbp),%r12d + xorl %eax,%r14d + + xorl %ebx,%r15d + rorl $6,%r13d + movl %ebx,%r11d + + andl %r15d,%edi + rorl $2,%r14d + addl %r13d,%r12d + + xorl %edi,%r11d + addl %r12d,%edx + addl %r12d,%r11d + + leaq 4(%rbp),%rbp + addl %r14d,%r11d + movl 36(%rsi),%r12d + movl %edx,%r13d + movl %r11d,%r14d + bswapl %r12d + rorl $14,%r13d + movl %r8d,%edi + + xorl %edx,%r13d + rorl $9,%r14d + xorl %r9d,%edi + + movl %r12d,36(%rsp) + xorl %r11d,%r14d + andl %edx,%edi + + rorl $5,%r13d + addl %r10d,%r12d + xorl %r9d,%edi + + rorl $11,%r14d + xorl %edx,%r13d + addl %edi,%r12d + + movl %r11d,%edi + addl (%rbp),%r12d + xorl %r11d,%r14d + + xorl %eax,%edi + rorl $6,%r13d + movl %eax,%r10d + + andl %edi,%r15d + rorl $2,%r14d + addl %r13d,%r12d + + xorl %r15d,%r10d + addl %r12d,%ecx + addl %r12d,%r10d + + leaq 4(%rbp),%rbp + addl %r14d,%r10d + movl 40(%rsi),%r12d + movl %ecx,%r13d + movl %r10d,%r14d + bswapl %r12d + rorl $14,%r13d + movl %edx,%r15d + + xorl %ecx,%r13d + rorl $9,%r14d + xorl %r8d,%r15d + + movl %r12d,40(%rsp) + xorl %r10d,%r14d + andl %ecx,%r15d + + rorl $5,%r13d + addl %r9d,%r12d + xorl %r8d,%r15d + + rorl $11,%r14d + xorl %ecx,%r13d + addl %r15d,%r12d + + movl %r10d,%r15d + addl (%rbp),%r12d + xorl %r10d,%r14d + + xorl %r11d,%r15d + rorl $6,%r13d + movl %r11d,%r9d + + andl %r15d,%edi + rorl $2,%r14d + addl %r13d,%r12d + + xorl %edi,%r9d + addl %r12d,%ebx + addl %r12d,%r9d + + leaq 4(%rbp),%rbp + addl %r14d,%r9d + movl 44(%rsi),%r12d + movl %ebx,%r13d + movl %r9d,%r14d + bswapl %r12d + rorl $14,%r13d + movl %ecx,%edi + + xorl %ebx,%r13d + rorl $9,%r14d + xorl %edx,%edi + + movl %r12d,44(%rsp) + xorl %r9d,%r14d + andl %ebx,%edi + + rorl $5,%r13d + addl %r8d,%r12d + xorl %edx,%edi + + rorl $11,%r14d + xorl %ebx,%r13d + addl %edi,%r12d + + movl %r9d,%edi + addl (%rbp),%r12d + xorl %r9d,%r14d + + xorl %r10d,%edi + rorl $6,%r13d + movl %r10d,%r8d + + andl %edi,%r15d + rorl $2,%r14d + addl %r13d,%r12d + + xorl %r15d,%r8d + addl %r12d,%eax + addl %r12d,%r8d + + leaq 20(%rbp),%rbp + addl %r14d,%r8d + movl 48(%rsi),%r12d + movl %eax,%r13d + movl %r8d,%r14d + bswapl %r12d + rorl $14,%r13d + movl %ebx,%r15d + + xorl %eax,%r13d + rorl $9,%r14d + xorl %ecx,%r15d + + movl %r12d,48(%rsp) + xorl %r8d,%r14d + andl %eax,%r15d + + rorl $5,%r13d + addl %edx,%r12d + xorl %ecx,%r15d + + rorl $11,%r14d + xorl %eax,%r13d + addl %r15d,%r12d + + movl %r8d,%r15d + addl (%rbp),%r12d + xorl %r8d,%r14d + + xorl %r9d,%r15d + rorl $6,%r13d + movl %r9d,%edx + + andl %r15d,%edi + rorl $2,%r14d + addl %r13d,%r12d + + xorl %edi,%edx + addl %r12d,%r11d + addl %r12d,%edx + + leaq 4(%rbp),%rbp + addl %r14d,%edx + movl 52(%rsi),%r12d + movl %r11d,%r13d + movl %edx,%r14d + bswapl %r12d + rorl $14,%r13d + movl %eax,%edi + + xorl %r11d,%r13d + rorl $9,%r14d + xorl %ebx,%edi + + movl %r12d,52(%rsp) + xorl %edx,%r14d + andl %r11d,%edi + + rorl $5,%r13d + addl %ecx,%r12d + xorl %ebx,%edi + + rorl $11,%r14d + xorl %r11d,%r13d + addl %edi,%r12d + + movl %edx,%edi + addl (%rbp),%r12d + xorl %edx,%r14d + + xorl %r8d,%edi + rorl $6,%r13d + movl %r8d,%ecx + + andl %edi,%r15d + rorl $2,%r14d + addl %r13d,%r12d + + xorl %r15d,%ecx + addl %r12d,%r10d + addl %r12d,%ecx + + leaq 4(%rbp),%rbp + addl %r14d,%ecx + movl 56(%rsi),%r12d + movl %r10d,%r13d + movl %ecx,%r14d + bswapl %r12d + rorl $14,%r13d + movl %r11d,%r15d + + xorl %r10d,%r13d + rorl $9,%r14d + xorl %eax,%r15d + + movl %r12d,56(%rsp) + xorl %ecx,%r14d + andl %r10d,%r15d + + rorl $5,%r13d + addl %ebx,%r12d + xorl %eax,%r15d + + rorl $11,%r14d + xorl %r10d,%r13d + addl %r15d,%r12d + + movl %ecx,%r15d + addl (%rbp),%r12d + xorl %ecx,%r14d + + xorl %edx,%r15d + rorl $6,%r13d + movl %edx,%ebx + + andl %r15d,%edi + rorl $2,%r14d + addl %r13d,%r12d + + xorl %edi,%ebx + addl %r12d,%r9d + addl %r12d,%ebx + + leaq 4(%rbp),%rbp + addl %r14d,%ebx + movl 60(%rsi),%r12d + movl %r9d,%r13d + movl %ebx,%r14d + bswapl %r12d + rorl $14,%r13d + movl %r10d,%edi + + xorl %r9d,%r13d + rorl $9,%r14d + xorl %r11d,%edi + + movl %r12d,60(%rsp) + xorl %ebx,%r14d + andl %r9d,%edi + + rorl $5,%r13d + addl %eax,%r12d + xorl %r11d,%edi + + rorl $11,%r14d + xorl %r9d,%r13d + addl %edi,%r12d + + movl %ebx,%edi + addl (%rbp),%r12d + xorl %ebx,%r14d + + xorl %ecx,%edi + rorl $6,%r13d + movl %ecx,%eax + + andl %edi,%r15d + rorl $2,%r14d + addl %r13d,%r12d + + xorl %r15d,%eax + addl %r12d,%r8d + addl %r12d,%eax + + leaq 20(%rbp),%rbp + jmp L$rounds_16_xx +.p2align 4 +L$rounds_16_xx: + movl 4(%rsp),%r13d + movl 56(%rsp),%r15d + + movl %r13d,%r12d + rorl $11,%r13d + addl %r14d,%eax + movl %r15d,%r14d + rorl $2,%r15d + + xorl %r12d,%r13d + shrl $3,%r12d + rorl $7,%r13d + xorl %r14d,%r15d + shrl $10,%r14d + + rorl $17,%r15d + xorl %r13d,%r12d + xorl %r14d,%r15d + addl 36(%rsp),%r12d + + addl 0(%rsp),%r12d + movl %r8d,%r13d + addl %r15d,%r12d + movl %eax,%r14d + rorl $14,%r13d + movl %r9d,%r15d + + xorl %r8d,%r13d + rorl $9,%r14d + xorl %r10d,%r15d + + movl %r12d,0(%rsp) + xorl %eax,%r14d + andl %r8d,%r15d + + rorl $5,%r13d + addl %r11d,%r12d + xorl %r10d,%r15d + + rorl $11,%r14d + xorl %r8d,%r13d + addl %r15d,%r12d + + movl %eax,%r15d + addl (%rbp),%r12d + xorl %eax,%r14d + + xorl %ebx,%r15d + rorl $6,%r13d + movl %ebx,%r11d + + andl %r15d,%edi + rorl $2,%r14d + addl %r13d,%r12d + + xorl %edi,%r11d + addl %r12d,%edx + addl %r12d,%r11d + + leaq 4(%rbp),%rbp + movl 8(%rsp),%r13d + movl 60(%rsp),%edi + + movl %r13d,%r12d + rorl $11,%r13d + addl %r14d,%r11d + movl %edi,%r14d + rorl $2,%edi + + xorl %r12d,%r13d + shrl $3,%r12d + rorl $7,%r13d + xorl %r14d,%edi + shrl $10,%r14d + + rorl $17,%edi + xorl %r13d,%r12d + xorl %r14d,%edi + addl 40(%rsp),%r12d + + addl 4(%rsp),%r12d + movl %edx,%r13d + addl %edi,%r12d + movl %r11d,%r14d + rorl $14,%r13d + movl %r8d,%edi + + xorl %edx,%r13d + rorl $9,%r14d + xorl %r9d,%edi + + movl %r12d,4(%rsp) + xorl %r11d,%r14d + andl %edx,%edi + + rorl $5,%r13d + addl %r10d,%r12d + xorl %r9d,%edi + + rorl $11,%r14d + xorl %edx,%r13d + addl %edi,%r12d + + movl %r11d,%edi + addl (%rbp),%r12d + xorl %r11d,%r14d + + xorl %eax,%edi + rorl $6,%r13d + movl %eax,%r10d + + andl %edi,%r15d + rorl $2,%r14d + addl %r13d,%r12d + + xorl %r15d,%r10d + addl %r12d,%ecx + addl %r12d,%r10d + + leaq 4(%rbp),%rbp + movl 12(%rsp),%r13d + movl 0(%rsp),%r15d + + movl %r13d,%r12d + rorl $11,%r13d + addl %r14d,%r10d + movl %r15d,%r14d + rorl $2,%r15d + + xorl %r12d,%r13d + shrl $3,%r12d + rorl $7,%r13d + xorl %r14d,%r15d + shrl $10,%r14d + + rorl $17,%r15d + xorl %r13d,%r12d + xorl %r14d,%r15d + addl 44(%rsp),%r12d + + addl 8(%rsp),%r12d + movl %ecx,%r13d + addl %r15d,%r12d + movl %r10d,%r14d + rorl $14,%r13d + movl %edx,%r15d + + xorl %ecx,%r13d + rorl $9,%r14d + xorl %r8d,%r15d + + movl %r12d,8(%rsp) + xorl %r10d,%r14d + andl %ecx,%r15d + + rorl $5,%r13d + addl %r9d,%r12d + xorl %r8d,%r15d + + rorl $11,%r14d + xorl %ecx,%r13d + addl %r15d,%r12d + + movl %r10d,%r15d + addl (%rbp),%r12d + xorl %r10d,%r14d + + xorl %r11d,%r15d + rorl $6,%r13d + movl %r11d,%r9d + + andl %r15d,%edi + rorl $2,%r14d + addl %r13d,%r12d + + xorl %edi,%r9d + addl %r12d,%ebx + addl %r12d,%r9d + + leaq 4(%rbp),%rbp + movl 16(%rsp),%r13d + movl 4(%rsp),%edi + + movl %r13d,%r12d + rorl $11,%r13d + addl %r14d,%r9d + movl %edi,%r14d + rorl $2,%edi + + xorl %r12d,%r13d + shrl $3,%r12d + rorl $7,%r13d + xorl %r14d,%edi + shrl $10,%r14d + + rorl $17,%edi + xorl %r13d,%r12d + xorl %r14d,%edi + addl 48(%rsp),%r12d + + addl 12(%rsp),%r12d + movl %ebx,%r13d + addl %edi,%r12d + movl %r9d,%r14d + rorl $14,%r13d + movl %ecx,%edi + + xorl %ebx,%r13d + rorl $9,%r14d + xorl %edx,%edi + + movl %r12d,12(%rsp) + xorl %r9d,%r14d + andl %ebx,%edi + + rorl $5,%r13d + addl %r8d,%r12d + xorl %edx,%edi + + rorl $11,%r14d + xorl %ebx,%r13d + addl %edi,%r12d + + movl %r9d,%edi + addl (%rbp),%r12d + xorl %r9d,%r14d + + xorl %r10d,%edi + rorl $6,%r13d + movl %r10d,%r8d + + andl %edi,%r15d + rorl $2,%r14d + addl %r13d,%r12d + + xorl %r15d,%r8d + addl %r12d,%eax + addl %r12d,%r8d + + leaq 20(%rbp),%rbp + movl 20(%rsp),%r13d + movl 8(%rsp),%r15d + + movl %r13d,%r12d + rorl $11,%r13d + addl %r14d,%r8d + movl %r15d,%r14d + rorl $2,%r15d + + xorl %r12d,%r13d + shrl $3,%r12d + rorl $7,%r13d + xorl %r14d,%r15d + shrl $10,%r14d + + rorl $17,%r15d + xorl %r13d,%r12d + xorl %r14d,%r15d + addl 52(%rsp),%r12d + + addl 16(%rsp),%r12d + movl %eax,%r13d + addl %r15d,%r12d + movl %r8d,%r14d + rorl $14,%r13d + movl %ebx,%r15d + + xorl %eax,%r13d + rorl $9,%r14d + xorl %ecx,%r15d + + movl %r12d,16(%rsp) + xorl %r8d,%r14d + andl %eax,%r15d + + rorl $5,%r13d + addl %edx,%r12d + xorl %ecx,%r15d + + rorl $11,%r14d + xorl %eax,%r13d + addl %r15d,%r12d + + movl %r8d,%r15d + addl (%rbp),%r12d + xorl %r8d,%r14d + + xorl %r9d,%r15d + rorl $6,%r13d + movl %r9d,%edx + + andl %r15d,%edi + rorl $2,%r14d + addl %r13d,%r12d + + xorl %edi,%edx + addl %r12d,%r11d + addl %r12d,%edx + + leaq 4(%rbp),%rbp + movl 24(%rsp),%r13d + movl 12(%rsp),%edi + + movl %r13d,%r12d + rorl $11,%r13d + addl %r14d,%edx + movl %edi,%r14d + rorl $2,%edi + + xorl %r12d,%r13d + shrl $3,%r12d + rorl $7,%r13d + xorl %r14d,%edi + shrl $10,%r14d + + rorl $17,%edi + xorl %r13d,%r12d + xorl %r14d,%edi + addl 56(%rsp),%r12d + + addl 20(%rsp),%r12d + movl %r11d,%r13d + addl %edi,%r12d + movl %edx,%r14d + rorl $14,%r13d + movl %eax,%edi + + xorl %r11d,%r13d + rorl $9,%r14d + xorl %ebx,%edi + + movl %r12d,20(%rsp) + xorl %edx,%r14d + andl %r11d,%edi + + rorl $5,%r13d + addl %ecx,%r12d + xorl %ebx,%edi + + rorl $11,%r14d + xorl %r11d,%r13d + addl %edi,%r12d + + movl %edx,%edi + addl (%rbp),%r12d + xorl %edx,%r14d + + xorl %r8d,%edi + rorl $6,%r13d + movl %r8d,%ecx + + andl %edi,%r15d + rorl $2,%r14d + addl %r13d,%r12d + + xorl %r15d,%ecx + addl %r12d,%r10d + addl %r12d,%ecx + + leaq 4(%rbp),%rbp + movl 28(%rsp),%r13d + movl 16(%rsp),%r15d + + movl %r13d,%r12d + rorl $11,%r13d + addl %r14d,%ecx + movl %r15d,%r14d + rorl $2,%r15d + + xorl %r12d,%r13d + shrl $3,%r12d + rorl $7,%r13d + xorl %r14d,%r15d + shrl $10,%r14d + + rorl $17,%r15d + xorl %r13d,%r12d + xorl %r14d,%r15d + addl 60(%rsp),%r12d + + addl 24(%rsp),%r12d + movl %r10d,%r13d + addl %r15d,%r12d + movl %ecx,%r14d + rorl $14,%r13d + movl %r11d,%r15d + + xorl %r10d,%r13d + rorl $9,%r14d + xorl %eax,%r15d + + movl %r12d,24(%rsp) + xorl %ecx,%r14d + andl %r10d,%r15d + + rorl $5,%r13d + addl %ebx,%r12d + xorl %eax,%r15d + + rorl $11,%r14d + xorl %r10d,%r13d + addl %r15d,%r12d + + movl %ecx,%r15d + addl (%rbp),%r12d + xorl %ecx,%r14d + + xorl %edx,%r15d + rorl $6,%r13d + movl %edx,%ebx + + andl %r15d,%edi + rorl $2,%r14d + addl %r13d,%r12d + + xorl %edi,%ebx + addl %r12d,%r9d + addl %r12d,%ebx + + leaq 4(%rbp),%rbp + movl 32(%rsp),%r13d + movl 20(%rsp),%edi + + movl %r13d,%r12d + rorl $11,%r13d + addl %r14d,%ebx + movl %edi,%r14d + rorl $2,%edi + + xorl %r12d,%r13d + shrl $3,%r12d + rorl $7,%r13d + xorl %r14d,%edi + shrl $10,%r14d + + rorl $17,%edi + xorl %r13d,%r12d + xorl %r14d,%edi + addl 0(%rsp),%r12d + + addl 28(%rsp),%r12d + movl %r9d,%r13d + addl %edi,%r12d + movl %ebx,%r14d + rorl $14,%r13d + movl %r10d,%edi + + xorl %r9d,%r13d + rorl $9,%r14d + xorl %r11d,%edi + + movl %r12d,28(%rsp) + xorl %ebx,%r14d + andl %r9d,%edi + + rorl $5,%r13d + addl %eax,%r12d + xorl %r11d,%edi + + rorl $11,%r14d + xorl %r9d,%r13d + addl %edi,%r12d + + movl %ebx,%edi + addl (%rbp),%r12d + xorl %ebx,%r14d + + xorl %ecx,%edi + rorl $6,%r13d + movl %ecx,%eax + + andl %edi,%r15d + rorl $2,%r14d + addl %r13d,%r12d + + xorl %r15d,%eax + addl %r12d,%r8d + addl %r12d,%eax + + leaq 20(%rbp),%rbp + movl 36(%rsp),%r13d + movl 24(%rsp),%r15d + + movl %r13d,%r12d + rorl $11,%r13d + addl %r14d,%eax + movl %r15d,%r14d + rorl $2,%r15d + + xorl %r12d,%r13d + shrl $3,%r12d + rorl $7,%r13d + xorl %r14d,%r15d + shrl $10,%r14d + + rorl $17,%r15d + xorl %r13d,%r12d + xorl %r14d,%r15d + addl 4(%rsp),%r12d + + addl 32(%rsp),%r12d + movl %r8d,%r13d + addl %r15d,%r12d + movl %eax,%r14d + rorl $14,%r13d + movl %r9d,%r15d + + xorl %r8d,%r13d + rorl $9,%r14d + xorl %r10d,%r15d + + movl %r12d,32(%rsp) + xorl %eax,%r14d + andl %r8d,%r15d + + rorl $5,%r13d + addl %r11d,%r12d + xorl %r10d,%r15d + + rorl $11,%r14d + xorl %r8d,%r13d + addl %r15d,%r12d + + movl %eax,%r15d + addl (%rbp),%r12d + xorl %eax,%r14d + + xorl %ebx,%r15d + rorl $6,%r13d + movl %ebx,%r11d + + andl %r15d,%edi + rorl $2,%r14d + addl %r13d,%r12d + + xorl %edi,%r11d + addl %r12d,%edx + addl %r12d,%r11d + + leaq 4(%rbp),%rbp + movl 40(%rsp),%r13d + movl 28(%rsp),%edi + + movl %r13d,%r12d + rorl $11,%r13d + addl %r14d,%r11d + movl %edi,%r14d + rorl $2,%edi + + xorl %r12d,%r13d + shrl $3,%r12d + rorl $7,%r13d + xorl %r14d,%edi + shrl $10,%r14d + + rorl $17,%edi + xorl %r13d,%r12d + xorl %r14d,%edi + addl 8(%rsp),%r12d + + addl 36(%rsp),%r12d + movl %edx,%r13d + addl %edi,%r12d + movl %r11d,%r14d + rorl $14,%r13d + movl %r8d,%edi + + xorl %edx,%r13d + rorl $9,%r14d + xorl %r9d,%edi + + movl %r12d,36(%rsp) + xorl %r11d,%r14d + andl %edx,%edi + + rorl $5,%r13d + addl %r10d,%r12d + xorl %r9d,%edi + + rorl $11,%r14d + xorl %edx,%r13d + addl %edi,%r12d + + movl %r11d,%edi + addl (%rbp),%r12d + xorl %r11d,%r14d + + xorl %eax,%edi + rorl $6,%r13d + movl %eax,%r10d + + andl %edi,%r15d + rorl $2,%r14d + addl %r13d,%r12d + + xorl %r15d,%r10d + addl %r12d,%ecx + addl %r12d,%r10d + + leaq 4(%rbp),%rbp + movl 44(%rsp),%r13d + movl 32(%rsp),%r15d + + movl %r13d,%r12d + rorl $11,%r13d + addl %r14d,%r10d + movl %r15d,%r14d + rorl $2,%r15d + + xorl %r12d,%r13d + shrl $3,%r12d + rorl $7,%r13d + xorl %r14d,%r15d + shrl $10,%r14d + + rorl $17,%r15d + xorl %r13d,%r12d + xorl %r14d,%r15d + addl 12(%rsp),%r12d + + addl 40(%rsp),%r12d + movl %ecx,%r13d + addl %r15d,%r12d + movl %r10d,%r14d + rorl $14,%r13d + movl %edx,%r15d + + xorl %ecx,%r13d + rorl $9,%r14d + xorl %r8d,%r15d + + movl %r12d,40(%rsp) + xorl %r10d,%r14d + andl %ecx,%r15d + + rorl $5,%r13d + addl %r9d,%r12d + xorl %r8d,%r15d + + rorl $11,%r14d + xorl %ecx,%r13d + addl %r15d,%r12d + + movl %r10d,%r15d + addl (%rbp),%r12d + xorl %r10d,%r14d + + xorl %r11d,%r15d + rorl $6,%r13d + movl %r11d,%r9d + + andl %r15d,%edi + rorl $2,%r14d + addl %r13d,%r12d + + xorl %edi,%r9d + addl %r12d,%ebx + addl %r12d,%r9d + + leaq 4(%rbp),%rbp + movl 48(%rsp),%r13d + movl 36(%rsp),%edi + + movl %r13d,%r12d + rorl $11,%r13d + addl %r14d,%r9d + movl %edi,%r14d + rorl $2,%edi + + xorl %r12d,%r13d + shrl $3,%r12d + rorl $7,%r13d + xorl %r14d,%edi + shrl $10,%r14d + + rorl $17,%edi + xorl %r13d,%r12d + xorl %r14d,%edi + addl 16(%rsp),%r12d + + addl 44(%rsp),%r12d + movl %ebx,%r13d + addl %edi,%r12d + movl %r9d,%r14d + rorl $14,%r13d + movl %ecx,%edi + + xorl %ebx,%r13d + rorl $9,%r14d + xorl %edx,%edi + + movl %r12d,44(%rsp) + xorl %r9d,%r14d + andl %ebx,%edi + + rorl $5,%r13d + addl %r8d,%r12d + xorl %edx,%edi + + rorl $11,%r14d + xorl %ebx,%r13d + addl %edi,%r12d + + movl %r9d,%edi + addl (%rbp),%r12d + xorl %r9d,%r14d + + xorl %r10d,%edi + rorl $6,%r13d + movl %r10d,%r8d + + andl %edi,%r15d + rorl $2,%r14d + addl %r13d,%r12d + + xorl %r15d,%r8d + addl %r12d,%eax + addl %r12d,%r8d + + leaq 20(%rbp),%rbp + movl 52(%rsp),%r13d + movl 40(%rsp),%r15d + + movl %r13d,%r12d + rorl $11,%r13d + addl %r14d,%r8d + movl %r15d,%r14d + rorl $2,%r15d + + xorl %r12d,%r13d + shrl $3,%r12d + rorl $7,%r13d + xorl %r14d,%r15d + shrl $10,%r14d + + rorl $17,%r15d + xorl %r13d,%r12d + xorl %r14d,%r15d + addl 20(%rsp),%r12d + + addl 48(%rsp),%r12d + movl %eax,%r13d + addl %r15d,%r12d + movl %r8d,%r14d + rorl $14,%r13d + movl %ebx,%r15d + + xorl %eax,%r13d + rorl $9,%r14d + xorl %ecx,%r15d + + movl %r12d,48(%rsp) + xorl %r8d,%r14d + andl %eax,%r15d + + rorl $5,%r13d + addl %edx,%r12d + xorl %ecx,%r15d + + rorl $11,%r14d + xorl %eax,%r13d + addl %r15d,%r12d + + movl %r8d,%r15d + addl (%rbp),%r12d + xorl %r8d,%r14d + + xorl %r9d,%r15d + rorl $6,%r13d + movl %r9d,%edx + + andl %r15d,%edi + rorl $2,%r14d + addl %r13d,%r12d + + xorl %edi,%edx + addl %r12d,%r11d + addl %r12d,%edx + + leaq 4(%rbp),%rbp + movl 56(%rsp),%r13d + movl 44(%rsp),%edi + + movl %r13d,%r12d + rorl $11,%r13d + addl %r14d,%edx + movl %edi,%r14d + rorl $2,%edi + + xorl %r12d,%r13d + shrl $3,%r12d + rorl $7,%r13d + xorl %r14d,%edi + shrl $10,%r14d + + rorl $17,%edi + xorl %r13d,%r12d + xorl %r14d,%edi + addl 24(%rsp),%r12d + + addl 52(%rsp),%r12d + movl %r11d,%r13d + addl %edi,%r12d + movl %edx,%r14d + rorl $14,%r13d + movl %eax,%edi + + xorl %r11d,%r13d + rorl $9,%r14d + xorl %ebx,%edi + + movl %r12d,52(%rsp) + xorl %edx,%r14d + andl %r11d,%edi + + rorl $5,%r13d + addl %ecx,%r12d + xorl %ebx,%edi + + rorl $11,%r14d + xorl %r11d,%r13d + addl %edi,%r12d + + movl %edx,%edi + addl (%rbp),%r12d + xorl %edx,%r14d + + xorl %r8d,%edi + rorl $6,%r13d + movl %r8d,%ecx + + andl %edi,%r15d + rorl $2,%r14d + addl %r13d,%r12d + + xorl %r15d,%ecx + addl %r12d,%r10d + addl %r12d,%ecx + + leaq 4(%rbp),%rbp + movl 60(%rsp),%r13d + movl 48(%rsp),%r15d + + movl %r13d,%r12d + rorl $11,%r13d + addl %r14d,%ecx + movl %r15d,%r14d + rorl $2,%r15d + + xorl %r12d,%r13d + shrl $3,%r12d + rorl $7,%r13d + xorl %r14d,%r15d + shrl $10,%r14d + + rorl $17,%r15d + xorl %r13d,%r12d + xorl %r14d,%r15d + addl 28(%rsp),%r12d + + addl 56(%rsp),%r12d + movl %r10d,%r13d + addl %r15d,%r12d + movl %ecx,%r14d + rorl $14,%r13d + movl %r11d,%r15d + + xorl %r10d,%r13d + rorl $9,%r14d + xorl %eax,%r15d + + movl %r12d,56(%rsp) + xorl %ecx,%r14d + andl %r10d,%r15d + + rorl $5,%r13d + addl %ebx,%r12d + xorl %eax,%r15d + + rorl $11,%r14d + xorl %r10d,%r13d + addl %r15d,%r12d + + movl %ecx,%r15d + addl (%rbp),%r12d + xorl %ecx,%r14d + + xorl %edx,%r15d + rorl $6,%r13d + movl %edx,%ebx + + andl %r15d,%edi + rorl $2,%r14d + addl %r13d,%r12d + + xorl %edi,%ebx + addl %r12d,%r9d + addl %r12d,%ebx + + leaq 4(%rbp),%rbp + movl 0(%rsp),%r13d + movl 52(%rsp),%edi + + movl %r13d,%r12d + rorl $11,%r13d + addl %r14d,%ebx + movl %edi,%r14d + rorl $2,%edi + + xorl %r12d,%r13d + shrl $3,%r12d + rorl $7,%r13d + xorl %r14d,%edi + shrl $10,%r14d + + rorl $17,%edi + xorl %r13d,%r12d + xorl %r14d,%edi + addl 32(%rsp),%r12d + + addl 60(%rsp),%r12d + movl %r9d,%r13d + addl %edi,%r12d + movl %ebx,%r14d + rorl $14,%r13d + movl %r10d,%edi + + xorl %r9d,%r13d + rorl $9,%r14d + xorl %r11d,%edi + + movl %r12d,60(%rsp) + xorl %ebx,%r14d + andl %r9d,%edi + + rorl $5,%r13d + addl %eax,%r12d + xorl %r11d,%edi + + rorl $11,%r14d + xorl %r9d,%r13d + addl %edi,%r12d + + movl %ebx,%edi + addl (%rbp),%r12d + xorl %ebx,%r14d + + xorl %ecx,%edi + rorl $6,%r13d + movl %ecx,%eax + + andl %edi,%r15d + rorl $2,%r14d + addl %r13d,%r12d + + xorl %r15d,%eax + addl %r12d,%r8d + addl %r12d,%eax + + leaq 20(%rbp),%rbp + cmpb $0,3(%rbp) + jnz L$rounds_16_xx + + movq 64+0(%rsp),%rdi + addl %r14d,%eax + leaq 64(%rsi),%rsi + + addl 0(%rdi),%eax + addl 4(%rdi),%ebx + addl 8(%rdi),%ecx + addl 12(%rdi),%edx + addl 16(%rdi),%r8d + addl 20(%rdi),%r9d + addl 24(%rdi),%r10d + addl 28(%rdi),%r11d + + cmpq 64+16(%rsp),%rsi + + movl %eax,0(%rdi) + movl %ebx,4(%rdi) + movl %ecx,8(%rdi) + movl %edx,12(%rdi) + movl %r8d,16(%rdi) + movl %r9d,20(%rdi) + movl %r10d,24(%rdi) + movl %r11d,28(%rdi) + jb L$loop + + movq 88(%rsp),%rsi + + movq -48(%rsi),%r15 + + movq -40(%rsi),%r14 + + movq -32(%rsi),%r13 + + movq -24(%rsi),%r12 + + movq -16(%rsi),%rbp + + movq -8(%rsi),%rbx + + leaq (%rsi),%rsp + +L$epilogue: + ret + + +.section __DATA,__const +.p2align 6 + +K256: +.long 0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5 +.long 0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5 +.long 0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5 +.long 0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5 +.long 0xd807aa98,0x12835b01,0x243185be,0x550c7dc3 +.long 0xd807aa98,0x12835b01,0x243185be,0x550c7dc3 +.long 0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174 +.long 0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174 +.long 0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc +.long 0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc +.long 0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da +.long 0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da +.long 0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7 +.long 0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7 +.long 0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967 +.long 0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967 +.long 0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13 +.long 0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13 +.long 0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85 +.long 0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85 +.long 0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3 +.long 0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3 +.long 0xd192e819,0xd6990624,0xf40e3585,0x106aa070 +.long 0xd192e819,0xd6990624,0xf40e3585,0x106aa070 +.long 0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5 +.long 0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5 +.long 0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3 +.long 0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3 +.long 0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208 +.long 0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208 +.long 0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2 +.long 0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2 + +.long 0x00010203,0x04050607,0x08090a0b,0x0c0d0e0f +.long 0x00010203,0x04050607,0x08090a0b,0x0c0d0e0f +.long 0x03020100,0x0b0a0908,0xffffffff,0xffffffff +.long 0x03020100,0x0b0a0908,0xffffffff,0xffffffff +.long 0xffffffff,0xffffffff,0x03020100,0x0b0a0908 +.long 0xffffffff,0xffffffff,0x03020100,0x0b0a0908 +.byte 83,72,65,50,53,54,32,98,108,111,99,107,32,116,114,97,110,115,102,111,114,109,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.text +.globl _sha256_block_data_order_hw +.private_extern _sha256_block_data_order_hw + +.p2align 6 +_sha256_block_data_order_hw: + +_CET_ENDBR + leaq K256+128(%rip),%rcx + movdqu (%rdi),%xmm1 + movdqu 16(%rdi),%xmm2 + movdqa 512-128(%rcx),%xmm7 + + pshufd $0x1b,%xmm1,%xmm0 + pshufd $0xb1,%xmm1,%xmm1 + pshufd $0x1b,%xmm2,%xmm2 + movdqa %xmm7,%xmm8 +.byte 102,15,58,15,202,8 + punpcklqdq %xmm0,%xmm2 + jmp L$oop_shaext + +.p2align 4 +L$oop_shaext: + movdqu (%rsi),%xmm3 + movdqu 16(%rsi),%xmm4 + movdqu 32(%rsi),%xmm5 +.byte 102,15,56,0,223 + movdqu 48(%rsi),%xmm6 + + movdqa 0-128(%rcx),%xmm0 + paddd %xmm3,%xmm0 +.byte 102,15,56,0,231 + movdqa %xmm2,%xmm10 +.byte 15,56,203,209 + pshufd $0x0e,%xmm0,%xmm0 + nop + movdqa %xmm1,%xmm9 +.byte 15,56,203,202 + + movdqa 32-128(%rcx),%xmm0 + paddd %xmm4,%xmm0 +.byte 102,15,56,0,239 +.byte 15,56,203,209 + pshufd $0x0e,%xmm0,%xmm0 + leaq 64(%rsi),%rsi +.byte 15,56,204,220 +.byte 15,56,203,202 + + movdqa 64-128(%rcx),%xmm0 + paddd %xmm5,%xmm0 +.byte 102,15,56,0,247 +.byte 15,56,203,209 + pshufd $0x0e,%xmm0,%xmm0 + movdqa %xmm6,%xmm7 +.byte 102,15,58,15,253,4 + nop + paddd %xmm7,%xmm3 +.byte 15,56,204,229 +.byte 15,56,203,202 + + movdqa 96-128(%rcx),%xmm0 + paddd %xmm6,%xmm0 +.byte 15,56,205,222 +.byte 15,56,203,209 + pshufd $0x0e,%xmm0,%xmm0 + movdqa %xmm3,%xmm7 +.byte 102,15,58,15,254,4 + nop + paddd %xmm7,%xmm4 +.byte 15,56,204,238 +.byte 15,56,203,202 + movdqa 128-128(%rcx),%xmm0 + paddd %xmm3,%xmm0 +.byte 15,56,205,227 +.byte 15,56,203,209 + pshufd $0x0e,%xmm0,%xmm0 + movdqa %xmm4,%xmm7 +.byte 102,15,58,15,251,4 + nop + paddd %xmm7,%xmm5 +.byte 15,56,204,243 +.byte 15,56,203,202 + movdqa 160-128(%rcx),%xmm0 + paddd %xmm4,%xmm0 +.byte 15,56,205,236 +.byte 15,56,203,209 + pshufd $0x0e,%xmm0,%xmm0 + movdqa %xmm5,%xmm7 +.byte 102,15,58,15,252,4 + nop + paddd %xmm7,%xmm6 +.byte 15,56,204,220 +.byte 15,56,203,202 + movdqa 192-128(%rcx),%xmm0 + paddd %xmm5,%xmm0 +.byte 15,56,205,245 +.byte 15,56,203,209 + pshufd $0x0e,%xmm0,%xmm0 + movdqa %xmm6,%xmm7 +.byte 102,15,58,15,253,4 + nop + paddd %xmm7,%xmm3 +.byte 15,56,204,229 +.byte 15,56,203,202 + movdqa 224-128(%rcx),%xmm0 + paddd %xmm6,%xmm0 +.byte 15,56,205,222 +.byte 15,56,203,209 + pshufd $0x0e,%xmm0,%xmm0 + movdqa %xmm3,%xmm7 +.byte 102,15,58,15,254,4 + nop + paddd %xmm7,%xmm4 +.byte 15,56,204,238 +.byte 15,56,203,202 + movdqa 256-128(%rcx),%xmm0 + paddd %xmm3,%xmm0 +.byte 15,56,205,227 +.byte 15,56,203,209 + pshufd $0x0e,%xmm0,%xmm0 + movdqa %xmm4,%xmm7 +.byte 102,15,58,15,251,4 + nop + paddd %xmm7,%xmm5 +.byte 15,56,204,243 +.byte 15,56,203,202 + movdqa 288-128(%rcx),%xmm0 + paddd %xmm4,%xmm0 +.byte 15,56,205,236 +.byte 15,56,203,209 + pshufd $0x0e,%xmm0,%xmm0 + movdqa %xmm5,%xmm7 +.byte 102,15,58,15,252,4 + nop + paddd %xmm7,%xmm6 +.byte 15,56,204,220 +.byte 15,56,203,202 + movdqa 320-128(%rcx),%xmm0 + paddd %xmm5,%xmm0 +.byte 15,56,205,245 +.byte 15,56,203,209 + pshufd $0x0e,%xmm0,%xmm0 + movdqa %xmm6,%xmm7 +.byte 102,15,58,15,253,4 + nop + paddd %xmm7,%xmm3 +.byte 15,56,204,229 +.byte 15,56,203,202 + movdqa 352-128(%rcx),%xmm0 + paddd %xmm6,%xmm0 +.byte 15,56,205,222 +.byte 15,56,203,209 + pshufd $0x0e,%xmm0,%xmm0 + movdqa %xmm3,%xmm7 +.byte 102,15,58,15,254,4 + nop + paddd %xmm7,%xmm4 +.byte 15,56,204,238 +.byte 15,56,203,202 + movdqa 384-128(%rcx),%xmm0 + paddd %xmm3,%xmm0 +.byte 15,56,205,227 +.byte 15,56,203,209 + pshufd $0x0e,%xmm0,%xmm0 + movdqa %xmm4,%xmm7 +.byte 102,15,58,15,251,4 + nop + paddd %xmm7,%xmm5 +.byte 15,56,204,243 +.byte 15,56,203,202 + movdqa 416-128(%rcx),%xmm0 + paddd %xmm4,%xmm0 +.byte 15,56,205,236 +.byte 15,56,203,209 + pshufd $0x0e,%xmm0,%xmm0 + movdqa %xmm5,%xmm7 +.byte 102,15,58,15,252,4 +.byte 15,56,203,202 + paddd %xmm7,%xmm6 + + movdqa 448-128(%rcx),%xmm0 + paddd %xmm5,%xmm0 +.byte 15,56,203,209 + pshufd $0x0e,%xmm0,%xmm0 +.byte 15,56,205,245 + movdqa %xmm8,%xmm7 +.byte 15,56,203,202 + + movdqa 480-128(%rcx),%xmm0 + paddd %xmm6,%xmm0 + nop +.byte 15,56,203,209 + pshufd $0x0e,%xmm0,%xmm0 + decq %rdx + nop +.byte 15,56,203,202 + + paddd %xmm10,%xmm2 + paddd %xmm9,%xmm1 + jnz L$oop_shaext + + pshufd $0xb1,%xmm2,%xmm2 + pshufd $0x1b,%xmm1,%xmm7 + pshufd $0xb1,%xmm1,%xmm1 + punpckhqdq %xmm2,%xmm1 +.byte 102,15,58,15,215,8 + + movdqu %xmm1,(%rdi) + movdqu %xmm2,16(%rdi) + ret + + +.globl _sha256_block_data_order_ssse3 +.private_extern _sha256_block_data_order_ssse3 + +.p2align 6 +_sha256_block_data_order_ssse3: + +_CET_ENDBR + movq %rsp,%rax + + pushq %rbx + + pushq %rbp + + pushq %r12 + + pushq %r13 + + pushq %r14 + + pushq %r15 + + shlq $4,%rdx + subq $96,%rsp + leaq (%rsi,%rdx,4),%rdx + andq $-64,%rsp + movq %rdi,64+0(%rsp) + movq %rsi,64+8(%rsp) + movq %rdx,64+16(%rsp) + movq %rax,88(%rsp) + +L$prologue_ssse3: + + movl 0(%rdi),%eax + movl 4(%rdi),%ebx + movl 8(%rdi),%ecx + movl 12(%rdi),%edx + movl 16(%rdi),%r8d + movl 20(%rdi),%r9d + movl 24(%rdi),%r10d + movl 28(%rdi),%r11d + + + jmp L$loop_ssse3 +.p2align 4 +L$loop_ssse3: + movdqa K256+512(%rip),%xmm7 + movdqu 0(%rsi),%xmm0 + movdqu 16(%rsi),%xmm1 + movdqu 32(%rsi),%xmm2 +.byte 102,15,56,0,199 + movdqu 48(%rsi),%xmm3 + leaq K256(%rip),%rbp +.byte 102,15,56,0,207 + movdqa 0(%rbp),%xmm4 + movdqa 32(%rbp),%xmm5 +.byte 102,15,56,0,215 + paddd %xmm0,%xmm4 + movdqa 64(%rbp),%xmm6 +.byte 102,15,56,0,223 + movdqa 96(%rbp),%xmm7 + paddd %xmm1,%xmm5 + paddd %xmm2,%xmm6 + paddd %xmm3,%xmm7 + movdqa %xmm4,0(%rsp) + movl %eax,%r14d + movdqa %xmm5,16(%rsp) + movl %ebx,%edi + movdqa %xmm6,32(%rsp) + xorl %ecx,%edi + movdqa %xmm7,48(%rsp) + movl %r8d,%r13d + jmp L$ssse3_00_47 + +.p2align 4 +L$ssse3_00_47: + subq $-128,%rbp + rorl $14,%r13d + movdqa %xmm1,%xmm4 + movl %r14d,%eax + movl %r9d,%r12d + movdqa %xmm3,%xmm7 + rorl $9,%r14d + xorl %r8d,%r13d + xorl %r10d,%r12d + rorl $5,%r13d + xorl %eax,%r14d +.byte 102,15,58,15,224,4 + andl %r8d,%r12d + xorl %r8d,%r13d +.byte 102,15,58,15,250,4 + addl 0(%rsp),%r11d + movl %eax,%r15d + xorl %r10d,%r12d + rorl $11,%r14d + movdqa %xmm4,%xmm5 + xorl %ebx,%r15d + addl %r12d,%r11d + movdqa %xmm4,%xmm6 + rorl $6,%r13d + andl %r15d,%edi + psrld $3,%xmm4 + xorl %eax,%r14d + addl %r13d,%r11d + xorl %ebx,%edi + paddd %xmm7,%xmm0 + rorl $2,%r14d + addl %r11d,%edx + psrld $7,%xmm6 + addl %edi,%r11d + movl %edx,%r13d + pshufd $250,%xmm3,%xmm7 + addl %r11d,%r14d + rorl $14,%r13d + pslld $14,%xmm5 + movl %r14d,%r11d + movl %r8d,%r12d + pxor %xmm6,%xmm4 + rorl $9,%r14d + xorl %edx,%r13d + xorl %r9d,%r12d + rorl $5,%r13d + psrld $11,%xmm6 + xorl %r11d,%r14d + pxor %xmm5,%xmm4 + andl %edx,%r12d + xorl %edx,%r13d + pslld $11,%xmm5 + addl 4(%rsp),%r10d + movl %r11d,%edi + pxor %xmm6,%xmm4 + xorl %r9d,%r12d + rorl $11,%r14d + movdqa %xmm7,%xmm6 + xorl %eax,%edi + addl %r12d,%r10d + pxor %xmm5,%xmm4 + rorl $6,%r13d + andl %edi,%r15d + xorl %r11d,%r14d + psrld $10,%xmm7 + addl %r13d,%r10d + xorl %eax,%r15d + paddd %xmm4,%xmm0 + rorl $2,%r14d + addl %r10d,%ecx + psrlq $17,%xmm6 + addl %r15d,%r10d + movl %ecx,%r13d + addl %r10d,%r14d + pxor %xmm6,%xmm7 + rorl $14,%r13d + movl %r14d,%r10d + movl %edx,%r12d + rorl $9,%r14d + psrlq $2,%xmm6 + xorl %ecx,%r13d + xorl %r8d,%r12d + pxor %xmm6,%xmm7 + rorl $5,%r13d + xorl %r10d,%r14d + andl %ecx,%r12d + pshufd $128,%xmm7,%xmm7 + xorl %ecx,%r13d + addl 8(%rsp),%r9d + movl %r10d,%r15d + psrldq $8,%xmm7 + xorl %r8d,%r12d + rorl $11,%r14d + xorl %r11d,%r15d + addl %r12d,%r9d + rorl $6,%r13d + paddd %xmm7,%xmm0 + andl %r15d,%edi + xorl %r10d,%r14d + addl %r13d,%r9d + pshufd $80,%xmm0,%xmm7 + xorl %r11d,%edi + rorl $2,%r14d + addl %r9d,%ebx + movdqa %xmm7,%xmm6 + addl %edi,%r9d + movl %ebx,%r13d + psrld $10,%xmm7 + addl %r9d,%r14d + rorl $14,%r13d + psrlq $17,%xmm6 + movl %r14d,%r9d + movl %ecx,%r12d + pxor %xmm6,%xmm7 + rorl $9,%r14d + xorl %ebx,%r13d + xorl %edx,%r12d + rorl $5,%r13d + xorl %r9d,%r14d + psrlq $2,%xmm6 + andl %ebx,%r12d + xorl %ebx,%r13d + addl 12(%rsp),%r8d + pxor %xmm6,%xmm7 + movl %r9d,%edi + xorl %edx,%r12d + rorl $11,%r14d + pshufd $8,%xmm7,%xmm7 + xorl %r10d,%edi + addl %r12d,%r8d + movdqa 0(%rbp),%xmm6 + rorl $6,%r13d + andl %edi,%r15d + pslldq $8,%xmm7 + xorl %r9d,%r14d + addl %r13d,%r8d + xorl %r10d,%r15d + paddd %xmm7,%xmm0 + rorl $2,%r14d + addl %r8d,%eax + addl %r15d,%r8d + paddd %xmm0,%xmm6 + movl %eax,%r13d + addl %r8d,%r14d + movdqa %xmm6,0(%rsp) + rorl $14,%r13d + movdqa %xmm2,%xmm4 + movl %r14d,%r8d + movl %ebx,%r12d + movdqa %xmm0,%xmm7 + rorl $9,%r14d + xorl %eax,%r13d + xorl %ecx,%r12d + rorl $5,%r13d + xorl %r8d,%r14d +.byte 102,15,58,15,225,4 + andl %eax,%r12d + xorl %eax,%r13d +.byte 102,15,58,15,251,4 + addl 16(%rsp),%edx + movl %r8d,%r15d + xorl %ecx,%r12d + rorl $11,%r14d + movdqa %xmm4,%xmm5 + xorl %r9d,%r15d + addl %r12d,%edx + movdqa %xmm4,%xmm6 + rorl $6,%r13d + andl %r15d,%edi + psrld $3,%xmm4 + xorl %r8d,%r14d + addl %r13d,%edx + xorl %r9d,%edi + paddd %xmm7,%xmm1 + rorl $2,%r14d + addl %edx,%r11d + psrld $7,%xmm6 + addl %edi,%edx + movl %r11d,%r13d + pshufd $250,%xmm0,%xmm7 + addl %edx,%r14d + rorl $14,%r13d + pslld $14,%xmm5 + movl %r14d,%edx + movl %eax,%r12d + pxor %xmm6,%xmm4 + rorl $9,%r14d + xorl %r11d,%r13d + xorl %ebx,%r12d + rorl $5,%r13d + psrld $11,%xmm6 + xorl %edx,%r14d + pxor %xmm5,%xmm4 + andl %r11d,%r12d + xorl %r11d,%r13d + pslld $11,%xmm5 + addl 20(%rsp),%ecx + movl %edx,%edi + pxor %xmm6,%xmm4 + xorl %ebx,%r12d + rorl $11,%r14d + movdqa %xmm7,%xmm6 + xorl %r8d,%edi + addl %r12d,%ecx + pxor %xmm5,%xmm4 + rorl $6,%r13d + andl %edi,%r15d + xorl %edx,%r14d + psrld $10,%xmm7 + addl %r13d,%ecx + xorl %r8d,%r15d + paddd %xmm4,%xmm1 + rorl $2,%r14d + addl %ecx,%r10d + psrlq $17,%xmm6 + addl %r15d,%ecx + movl %r10d,%r13d + addl %ecx,%r14d + pxor %xmm6,%xmm7 + rorl $14,%r13d + movl %r14d,%ecx + movl %r11d,%r12d + rorl $9,%r14d + psrlq $2,%xmm6 + xorl %r10d,%r13d + xorl %eax,%r12d + pxor %xmm6,%xmm7 + rorl $5,%r13d + xorl %ecx,%r14d + andl %r10d,%r12d + pshufd $128,%xmm7,%xmm7 + xorl %r10d,%r13d + addl 24(%rsp),%ebx + movl %ecx,%r15d + psrldq $8,%xmm7 + xorl %eax,%r12d + rorl $11,%r14d + xorl %edx,%r15d + addl %r12d,%ebx + rorl $6,%r13d + paddd %xmm7,%xmm1 + andl %r15d,%edi + xorl %ecx,%r14d + addl %r13d,%ebx + pshufd $80,%xmm1,%xmm7 + xorl %edx,%edi + rorl $2,%r14d + addl %ebx,%r9d + movdqa %xmm7,%xmm6 + addl %edi,%ebx + movl %r9d,%r13d + psrld $10,%xmm7 + addl %ebx,%r14d + rorl $14,%r13d + psrlq $17,%xmm6 + movl %r14d,%ebx + movl %r10d,%r12d + pxor %xmm6,%xmm7 + rorl $9,%r14d + xorl %r9d,%r13d + xorl %r11d,%r12d + rorl $5,%r13d + xorl %ebx,%r14d + psrlq $2,%xmm6 + andl %r9d,%r12d + xorl %r9d,%r13d + addl 28(%rsp),%eax + pxor %xmm6,%xmm7 + movl %ebx,%edi + xorl %r11d,%r12d + rorl $11,%r14d + pshufd $8,%xmm7,%xmm7 + xorl %ecx,%edi + addl %r12d,%eax + movdqa 32(%rbp),%xmm6 + rorl $6,%r13d + andl %edi,%r15d + pslldq $8,%xmm7 + xorl %ebx,%r14d + addl %r13d,%eax + xorl %ecx,%r15d + paddd %xmm7,%xmm1 + rorl $2,%r14d + addl %eax,%r8d + addl %r15d,%eax + paddd %xmm1,%xmm6 + movl %r8d,%r13d + addl %eax,%r14d + movdqa %xmm6,16(%rsp) + rorl $14,%r13d + movdqa %xmm3,%xmm4 + movl %r14d,%eax + movl %r9d,%r12d + movdqa %xmm1,%xmm7 + rorl $9,%r14d + xorl %r8d,%r13d + xorl %r10d,%r12d + rorl $5,%r13d + xorl %eax,%r14d +.byte 102,15,58,15,226,4 + andl %r8d,%r12d + xorl %r8d,%r13d +.byte 102,15,58,15,248,4 + addl 32(%rsp),%r11d + movl %eax,%r15d + xorl %r10d,%r12d + rorl $11,%r14d + movdqa %xmm4,%xmm5 + xorl %ebx,%r15d + addl %r12d,%r11d + movdqa %xmm4,%xmm6 + rorl $6,%r13d + andl %r15d,%edi + psrld $3,%xmm4 + xorl %eax,%r14d + addl %r13d,%r11d + xorl %ebx,%edi + paddd %xmm7,%xmm2 + rorl $2,%r14d + addl %r11d,%edx + psrld $7,%xmm6 + addl %edi,%r11d + movl %edx,%r13d + pshufd $250,%xmm1,%xmm7 + addl %r11d,%r14d + rorl $14,%r13d + pslld $14,%xmm5 + movl %r14d,%r11d + movl %r8d,%r12d + pxor %xmm6,%xmm4 + rorl $9,%r14d + xorl %edx,%r13d + xorl %r9d,%r12d + rorl $5,%r13d + psrld $11,%xmm6 + xorl %r11d,%r14d + pxor %xmm5,%xmm4 + andl %edx,%r12d + xorl %edx,%r13d + pslld $11,%xmm5 + addl 36(%rsp),%r10d + movl %r11d,%edi + pxor %xmm6,%xmm4 + xorl %r9d,%r12d + rorl $11,%r14d + movdqa %xmm7,%xmm6 + xorl %eax,%edi + addl %r12d,%r10d + pxor %xmm5,%xmm4 + rorl $6,%r13d + andl %edi,%r15d + xorl %r11d,%r14d + psrld $10,%xmm7 + addl %r13d,%r10d + xorl %eax,%r15d + paddd %xmm4,%xmm2 + rorl $2,%r14d + addl %r10d,%ecx + psrlq $17,%xmm6 + addl %r15d,%r10d + movl %ecx,%r13d + addl %r10d,%r14d + pxor %xmm6,%xmm7 + rorl $14,%r13d + movl %r14d,%r10d + movl %edx,%r12d + rorl $9,%r14d + psrlq $2,%xmm6 + xorl %ecx,%r13d + xorl %r8d,%r12d + pxor %xmm6,%xmm7 + rorl $5,%r13d + xorl %r10d,%r14d + andl %ecx,%r12d + pshufd $128,%xmm7,%xmm7 + xorl %ecx,%r13d + addl 40(%rsp),%r9d + movl %r10d,%r15d + psrldq $8,%xmm7 + xorl %r8d,%r12d + rorl $11,%r14d + xorl %r11d,%r15d + addl %r12d,%r9d + rorl $6,%r13d + paddd %xmm7,%xmm2 + andl %r15d,%edi + xorl %r10d,%r14d + addl %r13d,%r9d + pshufd $80,%xmm2,%xmm7 + xorl %r11d,%edi + rorl $2,%r14d + addl %r9d,%ebx + movdqa %xmm7,%xmm6 + addl %edi,%r9d + movl %ebx,%r13d + psrld $10,%xmm7 + addl %r9d,%r14d + rorl $14,%r13d + psrlq $17,%xmm6 + movl %r14d,%r9d + movl %ecx,%r12d + pxor %xmm6,%xmm7 + rorl $9,%r14d + xorl %ebx,%r13d + xorl %edx,%r12d + rorl $5,%r13d + xorl %r9d,%r14d + psrlq $2,%xmm6 + andl %ebx,%r12d + xorl %ebx,%r13d + addl 44(%rsp),%r8d + pxor %xmm6,%xmm7 + movl %r9d,%edi + xorl %edx,%r12d + rorl $11,%r14d + pshufd $8,%xmm7,%xmm7 + xorl %r10d,%edi + addl %r12d,%r8d + movdqa 64(%rbp),%xmm6 + rorl $6,%r13d + andl %edi,%r15d + pslldq $8,%xmm7 + xorl %r9d,%r14d + addl %r13d,%r8d + xorl %r10d,%r15d + paddd %xmm7,%xmm2 + rorl $2,%r14d + addl %r8d,%eax + addl %r15d,%r8d + paddd %xmm2,%xmm6 + movl %eax,%r13d + addl %r8d,%r14d + movdqa %xmm6,32(%rsp) + rorl $14,%r13d + movdqa %xmm0,%xmm4 + movl %r14d,%r8d + movl %ebx,%r12d + movdqa %xmm2,%xmm7 + rorl $9,%r14d + xorl %eax,%r13d + xorl %ecx,%r12d + rorl $5,%r13d + xorl %r8d,%r14d +.byte 102,15,58,15,227,4 + andl %eax,%r12d + xorl %eax,%r13d +.byte 102,15,58,15,249,4 + addl 48(%rsp),%edx + movl %r8d,%r15d + xorl %ecx,%r12d + rorl $11,%r14d + movdqa %xmm4,%xmm5 + xorl %r9d,%r15d + addl %r12d,%edx + movdqa %xmm4,%xmm6 + rorl $6,%r13d + andl %r15d,%edi + psrld $3,%xmm4 + xorl %r8d,%r14d + addl %r13d,%edx + xorl %r9d,%edi + paddd %xmm7,%xmm3 + rorl $2,%r14d + addl %edx,%r11d + psrld $7,%xmm6 + addl %edi,%edx + movl %r11d,%r13d + pshufd $250,%xmm2,%xmm7 + addl %edx,%r14d + rorl $14,%r13d + pslld $14,%xmm5 + movl %r14d,%edx + movl %eax,%r12d + pxor %xmm6,%xmm4 + rorl $9,%r14d + xorl %r11d,%r13d + xorl %ebx,%r12d + rorl $5,%r13d + psrld $11,%xmm6 + xorl %edx,%r14d + pxor %xmm5,%xmm4 + andl %r11d,%r12d + xorl %r11d,%r13d + pslld $11,%xmm5 + addl 52(%rsp),%ecx + movl %edx,%edi + pxor %xmm6,%xmm4 + xorl %ebx,%r12d + rorl $11,%r14d + movdqa %xmm7,%xmm6 + xorl %r8d,%edi + addl %r12d,%ecx + pxor %xmm5,%xmm4 + rorl $6,%r13d + andl %edi,%r15d + xorl %edx,%r14d + psrld $10,%xmm7 + addl %r13d,%ecx + xorl %r8d,%r15d + paddd %xmm4,%xmm3 + rorl $2,%r14d + addl %ecx,%r10d + psrlq $17,%xmm6 + addl %r15d,%ecx + movl %r10d,%r13d + addl %ecx,%r14d + pxor %xmm6,%xmm7 + rorl $14,%r13d + movl %r14d,%ecx + movl %r11d,%r12d + rorl $9,%r14d + psrlq $2,%xmm6 + xorl %r10d,%r13d + xorl %eax,%r12d + pxor %xmm6,%xmm7 + rorl $5,%r13d + xorl %ecx,%r14d + andl %r10d,%r12d + pshufd $128,%xmm7,%xmm7 + xorl %r10d,%r13d + addl 56(%rsp),%ebx + movl %ecx,%r15d + psrldq $8,%xmm7 + xorl %eax,%r12d + rorl $11,%r14d + xorl %edx,%r15d + addl %r12d,%ebx + rorl $6,%r13d + paddd %xmm7,%xmm3 + andl %r15d,%edi + xorl %ecx,%r14d + addl %r13d,%ebx + pshufd $80,%xmm3,%xmm7 + xorl %edx,%edi + rorl $2,%r14d + addl %ebx,%r9d + movdqa %xmm7,%xmm6 + addl %edi,%ebx + movl %r9d,%r13d + psrld $10,%xmm7 + addl %ebx,%r14d + rorl $14,%r13d + psrlq $17,%xmm6 + movl %r14d,%ebx + movl %r10d,%r12d + pxor %xmm6,%xmm7 + rorl $9,%r14d + xorl %r9d,%r13d + xorl %r11d,%r12d + rorl $5,%r13d + xorl %ebx,%r14d + psrlq $2,%xmm6 + andl %r9d,%r12d + xorl %r9d,%r13d + addl 60(%rsp),%eax + pxor %xmm6,%xmm7 + movl %ebx,%edi + xorl %r11d,%r12d + rorl $11,%r14d + pshufd $8,%xmm7,%xmm7 + xorl %ecx,%edi + addl %r12d,%eax + movdqa 96(%rbp),%xmm6 + rorl $6,%r13d + andl %edi,%r15d + pslldq $8,%xmm7 + xorl %ebx,%r14d + addl %r13d,%eax + xorl %ecx,%r15d + paddd %xmm7,%xmm3 + rorl $2,%r14d + addl %eax,%r8d + addl %r15d,%eax + paddd %xmm3,%xmm6 + movl %r8d,%r13d + addl %eax,%r14d + movdqa %xmm6,48(%rsp) + cmpb $0,131(%rbp) + jne L$ssse3_00_47 + rorl $14,%r13d + movl %r14d,%eax + movl %r9d,%r12d + rorl $9,%r14d + xorl %r8d,%r13d + xorl %r10d,%r12d + rorl $5,%r13d + xorl %eax,%r14d + andl %r8d,%r12d + xorl %r8d,%r13d + addl 0(%rsp),%r11d + movl %eax,%r15d + xorl %r10d,%r12d + rorl $11,%r14d + xorl %ebx,%r15d + addl %r12d,%r11d + rorl $6,%r13d + andl %r15d,%edi + xorl %eax,%r14d + addl %r13d,%r11d + xorl %ebx,%edi + rorl $2,%r14d + addl %r11d,%edx + addl %edi,%r11d + movl %edx,%r13d + addl %r11d,%r14d + rorl $14,%r13d + movl %r14d,%r11d + movl %r8d,%r12d + rorl $9,%r14d + xorl %edx,%r13d + xorl %r9d,%r12d + rorl $5,%r13d + xorl %r11d,%r14d + andl %edx,%r12d + xorl %edx,%r13d + addl 4(%rsp),%r10d + movl %r11d,%edi + xorl %r9d,%r12d + rorl $11,%r14d + xorl %eax,%edi + addl %r12d,%r10d + rorl $6,%r13d + andl %edi,%r15d + xorl %r11d,%r14d + addl %r13d,%r10d + xorl %eax,%r15d + rorl $2,%r14d + addl %r10d,%ecx + addl %r15d,%r10d + movl %ecx,%r13d + addl %r10d,%r14d + rorl $14,%r13d + movl %r14d,%r10d + movl %edx,%r12d + rorl $9,%r14d + xorl %ecx,%r13d + xorl %r8d,%r12d + rorl $5,%r13d + xorl %r10d,%r14d + andl %ecx,%r12d + xorl %ecx,%r13d + addl 8(%rsp),%r9d + movl %r10d,%r15d + xorl %r8d,%r12d + rorl $11,%r14d + xorl %r11d,%r15d + addl %r12d,%r9d + rorl $6,%r13d + andl %r15d,%edi + xorl %r10d,%r14d + addl %r13d,%r9d + xorl %r11d,%edi + rorl $2,%r14d + addl %r9d,%ebx + addl %edi,%r9d + movl %ebx,%r13d + addl %r9d,%r14d + rorl $14,%r13d + movl %r14d,%r9d + movl %ecx,%r12d + rorl $9,%r14d + xorl %ebx,%r13d + xorl %edx,%r12d + rorl $5,%r13d + xorl %r9d,%r14d + andl %ebx,%r12d + xorl %ebx,%r13d + addl 12(%rsp),%r8d + movl %r9d,%edi + xorl %edx,%r12d + rorl $11,%r14d + xorl %r10d,%edi + addl %r12d,%r8d + rorl $6,%r13d + andl %edi,%r15d + xorl %r9d,%r14d + addl %r13d,%r8d + xorl %r10d,%r15d + rorl $2,%r14d + addl %r8d,%eax + addl %r15d,%r8d + movl %eax,%r13d + addl %r8d,%r14d + rorl $14,%r13d + movl %r14d,%r8d + movl %ebx,%r12d + rorl $9,%r14d + xorl %eax,%r13d + xorl %ecx,%r12d + rorl $5,%r13d + xorl %r8d,%r14d + andl %eax,%r12d + xorl %eax,%r13d + addl 16(%rsp),%edx + movl %r8d,%r15d + xorl %ecx,%r12d + rorl $11,%r14d + xorl %r9d,%r15d + addl %r12d,%edx + rorl $6,%r13d + andl %r15d,%edi + xorl %r8d,%r14d + addl %r13d,%edx + xorl %r9d,%edi + rorl $2,%r14d + addl %edx,%r11d + addl %edi,%edx + movl %r11d,%r13d + addl %edx,%r14d + rorl $14,%r13d + movl %r14d,%edx + movl %eax,%r12d + rorl $9,%r14d + xorl %r11d,%r13d + xorl %ebx,%r12d + rorl $5,%r13d + xorl %edx,%r14d + andl %r11d,%r12d + xorl %r11d,%r13d + addl 20(%rsp),%ecx + movl %edx,%edi + xorl %ebx,%r12d + rorl $11,%r14d + xorl %r8d,%edi + addl %r12d,%ecx + rorl $6,%r13d + andl %edi,%r15d + xorl %edx,%r14d + addl %r13d,%ecx + xorl %r8d,%r15d + rorl $2,%r14d + addl %ecx,%r10d + addl %r15d,%ecx + movl %r10d,%r13d + addl %ecx,%r14d + rorl $14,%r13d + movl %r14d,%ecx + movl %r11d,%r12d + rorl $9,%r14d + xorl %r10d,%r13d + xorl %eax,%r12d + rorl $5,%r13d + xorl %ecx,%r14d + andl %r10d,%r12d + xorl %r10d,%r13d + addl 24(%rsp),%ebx + movl %ecx,%r15d + xorl %eax,%r12d + rorl $11,%r14d + xorl %edx,%r15d + addl %r12d,%ebx + rorl $6,%r13d + andl %r15d,%edi + xorl %ecx,%r14d + addl %r13d,%ebx + xorl %edx,%edi + rorl $2,%r14d + addl %ebx,%r9d + addl %edi,%ebx + movl %r9d,%r13d + addl %ebx,%r14d + rorl $14,%r13d + movl %r14d,%ebx + movl %r10d,%r12d + rorl $9,%r14d + xorl %r9d,%r13d + xorl %r11d,%r12d + rorl $5,%r13d + xorl %ebx,%r14d + andl %r9d,%r12d + xorl %r9d,%r13d + addl 28(%rsp),%eax + movl %ebx,%edi + xorl %r11d,%r12d + rorl $11,%r14d + xorl %ecx,%edi + addl %r12d,%eax + rorl $6,%r13d + andl %edi,%r15d + xorl %ebx,%r14d + addl %r13d,%eax + xorl %ecx,%r15d + rorl $2,%r14d + addl %eax,%r8d + addl %r15d,%eax + movl %r8d,%r13d + addl %eax,%r14d + rorl $14,%r13d + movl %r14d,%eax + movl %r9d,%r12d + rorl $9,%r14d + xorl %r8d,%r13d + xorl %r10d,%r12d + rorl $5,%r13d + xorl %eax,%r14d + andl %r8d,%r12d + xorl %r8d,%r13d + addl 32(%rsp),%r11d + movl %eax,%r15d + xorl %r10d,%r12d + rorl $11,%r14d + xorl %ebx,%r15d + addl %r12d,%r11d + rorl $6,%r13d + andl %r15d,%edi + xorl %eax,%r14d + addl %r13d,%r11d + xorl %ebx,%edi + rorl $2,%r14d + addl %r11d,%edx + addl %edi,%r11d + movl %edx,%r13d + addl %r11d,%r14d + rorl $14,%r13d + movl %r14d,%r11d + movl %r8d,%r12d + rorl $9,%r14d + xorl %edx,%r13d + xorl %r9d,%r12d + rorl $5,%r13d + xorl %r11d,%r14d + andl %edx,%r12d + xorl %edx,%r13d + addl 36(%rsp),%r10d + movl %r11d,%edi + xorl %r9d,%r12d + rorl $11,%r14d + xorl %eax,%edi + addl %r12d,%r10d + rorl $6,%r13d + andl %edi,%r15d + xorl %r11d,%r14d + addl %r13d,%r10d + xorl %eax,%r15d + rorl $2,%r14d + addl %r10d,%ecx + addl %r15d,%r10d + movl %ecx,%r13d + addl %r10d,%r14d + rorl $14,%r13d + movl %r14d,%r10d + movl %edx,%r12d + rorl $9,%r14d + xorl %ecx,%r13d + xorl %r8d,%r12d + rorl $5,%r13d + xorl %r10d,%r14d + andl %ecx,%r12d + xorl %ecx,%r13d + addl 40(%rsp),%r9d + movl %r10d,%r15d + xorl %r8d,%r12d + rorl $11,%r14d + xorl %r11d,%r15d + addl %r12d,%r9d + rorl $6,%r13d + andl %r15d,%edi + xorl %r10d,%r14d + addl %r13d,%r9d + xorl %r11d,%edi + rorl $2,%r14d + addl %r9d,%ebx + addl %edi,%r9d + movl %ebx,%r13d + addl %r9d,%r14d + rorl $14,%r13d + movl %r14d,%r9d + movl %ecx,%r12d + rorl $9,%r14d + xorl %ebx,%r13d + xorl %edx,%r12d + rorl $5,%r13d + xorl %r9d,%r14d + andl %ebx,%r12d + xorl %ebx,%r13d + addl 44(%rsp),%r8d + movl %r9d,%edi + xorl %edx,%r12d + rorl $11,%r14d + xorl %r10d,%edi + addl %r12d,%r8d + rorl $6,%r13d + andl %edi,%r15d + xorl %r9d,%r14d + addl %r13d,%r8d + xorl %r10d,%r15d + rorl $2,%r14d + addl %r8d,%eax + addl %r15d,%r8d + movl %eax,%r13d + addl %r8d,%r14d + rorl $14,%r13d + movl %r14d,%r8d + movl %ebx,%r12d + rorl $9,%r14d + xorl %eax,%r13d + xorl %ecx,%r12d + rorl $5,%r13d + xorl %r8d,%r14d + andl %eax,%r12d + xorl %eax,%r13d + addl 48(%rsp),%edx + movl %r8d,%r15d + xorl %ecx,%r12d + rorl $11,%r14d + xorl %r9d,%r15d + addl %r12d,%edx + rorl $6,%r13d + andl %r15d,%edi + xorl %r8d,%r14d + addl %r13d,%edx + xorl %r9d,%edi + rorl $2,%r14d + addl %edx,%r11d + addl %edi,%edx + movl %r11d,%r13d + addl %edx,%r14d + rorl $14,%r13d + movl %r14d,%edx + movl %eax,%r12d + rorl $9,%r14d + xorl %r11d,%r13d + xorl %ebx,%r12d + rorl $5,%r13d + xorl %edx,%r14d + andl %r11d,%r12d + xorl %r11d,%r13d + addl 52(%rsp),%ecx + movl %edx,%edi + xorl %ebx,%r12d + rorl $11,%r14d + xorl %r8d,%edi + addl %r12d,%ecx + rorl $6,%r13d + andl %edi,%r15d + xorl %edx,%r14d + addl %r13d,%ecx + xorl %r8d,%r15d + rorl $2,%r14d + addl %ecx,%r10d + addl %r15d,%ecx + movl %r10d,%r13d + addl %ecx,%r14d + rorl $14,%r13d + movl %r14d,%ecx + movl %r11d,%r12d + rorl $9,%r14d + xorl %r10d,%r13d + xorl %eax,%r12d + rorl $5,%r13d + xorl %ecx,%r14d + andl %r10d,%r12d + xorl %r10d,%r13d + addl 56(%rsp),%ebx + movl %ecx,%r15d + xorl %eax,%r12d + rorl $11,%r14d + xorl %edx,%r15d + addl %r12d,%ebx + rorl $6,%r13d + andl %r15d,%edi + xorl %ecx,%r14d + addl %r13d,%ebx + xorl %edx,%edi + rorl $2,%r14d + addl %ebx,%r9d + addl %edi,%ebx + movl %r9d,%r13d + addl %ebx,%r14d + rorl $14,%r13d + movl %r14d,%ebx + movl %r10d,%r12d + rorl $9,%r14d + xorl %r9d,%r13d + xorl %r11d,%r12d + rorl $5,%r13d + xorl %ebx,%r14d + andl %r9d,%r12d + xorl %r9d,%r13d + addl 60(%rsp),%eax + movl %ebx,%edi + xorl %r11d,%r12d + rorl $11,%r14d + xorl %ecx,%edi + addl %r12d,%eax + rorl $6,%r13d + andl %edi,%r15d + xorl %ebx,%r14d + addl %r13d,%eax + xorl %ecx,%r15d + rorl $2,%r14d + addl %eax,%r8d + addl %r15d,%eax + movl %r8d,%r13d + addl %eax,%r14d + movq 64+0(%rsp),%rdi + movl %r14d,%eax + + addl 0(%rdi),%eax + leaq 64(%rsi),%rsi + addl 4(%rdi),%ebx + addl 8(%rdi),%ecx + addl 12(%rdi),%edx + addl 16(%rdi),%r8d + addl 20(%rdi),%r9d + addl 24(%rdi),%r10d + addl 28(%rdi),%r11d + + cmpq 64+16(%rsp),%rsi + + movl %eax,0(%rdi) + movl %ebx,4(%rdi) + movl %ecx,8(%rdi) + movl %edx,12(%rdi) + movl %r8d,16(%rdi) + movl %r9d,20(%rdi) + movl %r10d,24(%rdi) + movl %r11d,28(%rdi) + jb L$loop_ssse3 + + movq 88(%rsp),%rsi + + movq -48(%rsi),%r15 + + movq -40(%rsi),%r14 + + movq -32(%rsi),%r13 + + movq -24(%rsi),%r12 + + movq -16(%rsi),%rbp + + movq -8(%rsi),%rbx + + leaq (%rsi),%rsp + +L$epilogue_ssse3: + ret + + +.globl _sha256_block_data_order_avx +.private_extern _sha256_block_data_order_avx + +.p2align 6 +_sha256_block_data_order_avx: + +_CET_ENDBR + movq %rsp,%rax + + pushq %rbx + + pushq %rbp + + pushq %r12 + + pushq %r13 + + pushq %r14 + + pushq %r15 + + shlq $4,%rdx + subq $96,%rsp + leaq (%rsi,%rdx,4),%rdx + andq $-64,%rsp + movq %rdi,64+0(%rsp) + movq %rsi,64+8(%rsp) + movq %rdx,64+16(%rsp) + movq %rax,88(%rsp) + +L$prologue_avx: + + vzeroupper + movl 0(%rdi),%eax + movl 4(%rdi),%ebx + movl 8(%rdi),%ecx + movl 12(%rdi),%edx + movl 16(%rdi),%r8d + movl 20(%rdi),%r9d + movl 24(%rdi),%r10d + movl 28(%rdi),%r11d + vmovdqa K256+512+32(%rip),%xmm8 + vmovdqa K256+512+64(%rip),%xmm9 + jmp L$loop_avx +.p2align 4 +L$loop_avx: + vmovdqa K256+512(%rip),%xmm7 + vmovdqu 0(%rsi),%xmm0 + vmovdqu 16(%rsi),%xmm1 + vmovdqu 32(%rsi),%xmm2 + vmovdqu 48(%rsi),%xmm3 + vpshufb %xmm7,%xmm0,%xmm0 + leaq K256(%rip),%rbp + vpshufb %xmm7,%xmm1,%xmm1 + vpshufb %xmm7,%xmm2,%xmm2 + vpaddd 0(%rbp),%xmm0,%xmm4 + vpshufb %xmm7,%xmm3,%xmm3 + vpaddd 32(%rbp),%xmm1,%xmm5 + vpaddd 64(%rbp),%xmm2,%xmm6 + vpaddd 96(%rbp),%xmm3,%xmm7 + vmovdqa %xmm4,0(%rsp) + movl %eax,%r14d + vmovdqa %xmm5,16(%rsp) + movl %ebx,%edi + vmovdqa %xmm6,32(%rsp) + xorl %ecx,%edi + vmovdqa %xmm7,48(%rsp) + movl %r8d,%r13d + jmp L$avx_00_47 + +.p2align 4 +L$avx_00_47: + subq $-128,%rbp + vpalignr $4,%xmm0,%xmm1,%xmm4 + shrdl $14,%r13d,%r13d + movl %r14d,%eax + movl %r9d,%r12d + vpalignr $4,%xmm2,%xmm3,%xmm7 + shrdl $9,%r14d,%r14d + xorl %r8d,%r13d + xorl %r10d,%r12d + vpsrld $7,%xmm4,%xmm6 + shrdl $5,%r13d,%r13d + xorl %eax,%r14d + andl %r8d,%r12d + vpaddd %xmm7,%xmm0,%xmm0 + xorl %r8d,%r13d + addl 0(%rsp),%r11d + movl %eax,%r15d + vpsrld $3,%xmm4,%xmm7 + xorl %r10d,%r12d + shrdl $11,%r14d,%r14d + xorl %ebx,%r15d + vpslld $14,%xmm4,%xmm5 + addl %r12d,%r11d + shrdl $6,%r13d,%r13d + andl %r15d,%edi + vpxor %xmm6,%xmm7,%xmm4 + xorl %eax,%r14d + addl %r13d,%r11d + xorl %ebx,%edi + vpshufd $250,%xmm3,%xmm7 + shrdl $2,%r14d,%r14d + addl %r11d,%edx + addl %edi,%r11d + vpsrld $11,%xmm6,%xmm6 + movl %edx,%r13d + addl %r11d,%r14d + shrdl $14,%r13d,%r13d + vpxor %xmm5,%xmm4,%xmm4 + movl %r14d,%r11d + movl %r8d,%r12d + shrdl $9,%r14d,%r14d + vpslld $11,%xmm5,%xmm5 + xorl %edx,%r13d + xorl %r9d,%r12d + shrdl $5,%r13d,%r13d + vpxor %xmm6,%xmm4,%xmm4 + xorl %r11d,%r14d + andl %edx,%r12d + xorl %edx,%r13d + vpsrld $10,%xmm7,%xmm6 + addl 4(%rsp),%r10d + movl %r11d,%edi + xorl %r9d,%r12d + vpxor %xmm5,%xmm4,%xmm4 + shrdl $11,%r14d,%r14d + xorl %eax,%edi + addl %r12d,%r10d + vpsrlq $17,%xmm7,%xmm7 + shrdl $6,%r13d,%r13d + andl %edi,%r15d + xorl %r11d,%r14d + vpaddd %xmm4,%xmm0,%xmm0 + addl %r13d,%r10d + xorl %eax,%r15d + shrdl $2,%r14d,%r14d + vpxor %xmm7,%xmm6,%xmm6 + addl %r10d,%ecx + addl %r15d,%r10d + movl %ecx,%r13d + vpsrlq $2,%xmm7,%xmm7 + addl %r10d,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%r10d + vpxor %xmm7,%xmm6,%xmm6 + movl %edx,%r12d + shrdl $9,%r14d,%r14d + xorl %ecx,%r13d + vpshufb %xmm8,%xmm6,%xmm6 + xorl %r8d,%r12d + shrdl $5,%r13d,%r13d + xorl %r10d,%r14d + vpaddd %xmm6,%xmm0,%xmm0 + andl %ecx,%r12d + xorl %ecx,%r13d + addl 8(%rsp),%r9d + vpshufd $80,%xmm0,%xmm7 + movl %r10d,%r15d + xorl %r8d,%r12d + shrdl $11,%r14d,%r14d + vpsrld $10,%xmm7,%xmm6 + xorl %r11d,%r15d + addl %r12d,%r9d + shrdl $6,%r13d,%r13d + vpsrlq $17,%xmm7,%xmm7 + andl %r15d,%edi + xorl %r10d,%r14d + addl %r13d,%r9d + vpxor %xmm7,%xmm6,%xmm6 + xorl %r11d,%edi + shrdl $2,%r14d,%r14d + addl %r9d,%ebx + vpsrlq $2,%xmm7,%xmm7 + addl %edi,%r9d + movl %ebx,%r13d + addl %r9d,%r14d + vpxor %xmm7,%xmm6,%xmm6 + shrdl $14,%r13d,%r13d + movl %r14d,%r9d + movl %ecx,%r12d + vpshufb %xmm9,%xmm6,%xmm6 + shrdl $9,%r14d,%r14d + xorl %ebx,%r13d + xorl %edx,%r12d + vpaddd %xmm6,%xmm0,%xmm0 + shrdl $5,%r13d,%r13d + xorl %r9d,%r14d + andl %ebx,%r12d + vpaddd 0(%rbp),%xmm0,%xmm6 + xorl %ebx,%r13d + addl 12(%rsp),%r8d + movl %r9d,%edi + xorl %edx,%r12d + shrdl $11,%r14d,%r14d + xorl %r10d,%edi + addl %r12d,%r8d + shrdl $6,%r13d,%r13d + andl %edi,%r15d + xorl %r9d,%r14d + addl %r13d,%r8d + xorl %r10d,%r15d + shrdl $2,%r14d,%r14d + addl %r8d,%eax + addl %r15d,%r8d + movl %eax,%r13d + addl %r8d,%r14d + vmovdqa %xmm6,0(%rsp) + vpalignr $4,%xmm1,%xmm2,%xmm4 + shrdl $14,%r13d,%r13d + movl %r14d,%r8d + movl %ebx,%r12d + vpalignr $4,%xmm3,%xmm0,%xmm7 + shrdl $9,%r14d,%r14d + xorl %eax,%r13d + xorl %ecx,%r12d + vpsrld $7,%xmm4,%xmm6 + shrdl $5,%r13d,%r13d + xorl %r8d,%r14d + andl %eax,%r12d + vpaddd %xmm7,%xmm1,%xmm1 + xorl %eax,%r13d + addl 16(%rsp),%edx + movl %r8d,%r15d + vpsrld $3,%xmm4,%xmm7 + xorl %ecx,%r12d + shrdl $11,%r14d,%r14d + xorl %r9d,%r15d + vpslld $14,%xmm4,%xmm5 + addl %r12d,%edx + shrdl $6,%r13d,%r13d + andl %r15d,%edi + vpxor %xmm6,%xmm7,%xmm4 + xorl %r8d,%r14d + addl %r13d,%edx + xorl %r9d,%edi + vpshufd $250,%xmm0,%xmm7 + shrdl $2,%r14d,%r14d + addl %edx,%r11d + addl %edi,%edx + vpsrld $11,%xmm6,%xmm6 + movl %r11d,%r13d + addl %edx,%r14d + shrdl $14,%r13d,%r13d + vpxor %xmm5,%xmm4,%xmm4 + movl %r14d,%edx + movl %eax,%r12d + shrdl $9,%r14d,%r14d + vpslld $11,%xmm5,%xmm5 + xorl %r11d,%r13d + xorl %ebx,%r12d + shrdl $5,%r13d,%r13d + vpxor %xmm6,%xmm4,%xmm4 + xorl %edx,%r14d + andl %r11d,%r12d + xorl %r11d,%r13d + vpsrld $10,%xmm7,%xmm6 + addl 20(%rsp),%ecx + movl %edx,%edi + xorl %ebx,%r12d + vpxor %xmm5,%xmm4,%xmm4 + shrdl $11,%r14d,%r14d + xorl %r8d,%edi + addl %r12d,%ecx + vpsrlq $17,%xmm7,%xmm7 + shrdl $6,%r13d,%r13d + andl %edi,%r15d + xorl %edx,%r14d + vpaddd %xmm4,%xmm1,%xmm1 + addl %r13d,%ecx + xorl %r8d,%r15d + shrdl $2,%r14d,%r14d + vpxor %xmm7,%xmm6,%xmm6 + addl %ecx,%r10d + addl %r15d,%ecx + movl %r10d,%r13d + vpsrlq $2,%xmm7,%xmm7 + addl %ecx,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%ecx + vpxor %xmm7,%xmm6,%xmm6 + movl %r11d,%r12d + shrdl $9,%r14d,%r14d + xorl %r10d,%r13d + vpshufb %xmm8,%xmm6,%xmm6 + xorl %eax,%r12d + shrdl $5,%r13d,%r13d + xorl %ecx,%r14d + vpaddd %xmm6,%xmm1,%xmm1 + andl %r10d,%r12d + xorl %r10d,%r13d + addl 24(%rsp),%ebx + vpshufd $80,%xmm1,%xmm7 + movl %ecx,%r15d + xorl %eax,%r12d + shrdl $11,%r14d,%r14d + vpsrld $10,%xmm7,%xmm6 + xorl %edx,%r15d + addl %r12d,%ebx + shrdl $6,%r13d,%r13d + vpsrlq $17,%xmm7,%xmm7 + andl %r15d,%edi + xorl %ecx,%r14d + addl %r13d,%ebx + vpxor %xmm7,%xmm6,%xmm6 + xorl %edx,%edi + shrdl $2,%r14d,%r14d + addl %ebx,%r9d + vpsrlq $2,%xmm7,%xmm7 + addl %edi,%ebx + movl %r9d,%r13d + addl %ebx,%r14d + vpxor %xmm7,%xmm6,%xmm6 + shrdl $14,%r13d,%r13d + movl %r14d,%ebx + movl %r10d,%r12d + vpshufb %xmm9,%xmm6,%xmm6 + shrdl $9,%r14d,%r14d + xorl %r9d,%r13d + xorl %r11d,%r12d + vpaddd %xmm6,%xmm1,%xmm1 + shrdl $5,%r13d,%r13d + xorl %ebx,%r14d + andl %r9d,%r12d + vpaddd 32(%rbp),%xmm1,%xmm6 + xorl %r9d,%r13d + addl 28(%rsp),%eax + movl %ebx,%edi + xorl %r11d,%r12d + shrdl $11,%r14d,%r14d + xorl %ecx,%edi + addl %r12d,%eax + shrdl $6,%r13d,%r13d + andl %edi,%r15d + xorl %ebx,%r14d + addl %r13d,%eax + xorl %ecx,%r15d + shrdl $2,%r14d,%r14d + addl %eax,%r8d + addl %r15d,%eax + movl %r8d,%r13d + addl %eax,%r14d + vmovdqa %xmm6,16(%rsp) + vpalignr $4,%xmm2,%xmm3,%xmm4 + shrdl $14,%r13d,%r13d + movl %r14d,%eax + movl %r9d,%r12d + vpalignr $4,%xmm0,%xmm1,%xmm7 + shrdl $9,%r14d,%r14d + xorl %r8d,%r13d + xorl %r10d,%r12d + vpsrld $7,%xmm4,%xmm6 + shrdl $5,%r13d,%r13d + xorl %eax,%r14d + andl %r8d,%r12d + vpaddd %xmm7,%xmm2,%xmm2 + xorl %r8d,%r13d + addl 32(%rsp),%r11d + movl %eax,%r15d + vpsrld $3,%xmm4,%xmm7 + xorl %r10d,%r12d + shrdl $11,%r14d,%r14d + xorl %ebx,%r15d + vpslld $14,%xmm4,%xmm5 + addl %r12d,%r11d + shrdl $6,%r13d,%r13d + andl %r15d,%edi + vpxor %xmm6,%xmm7,%xmm4 + xorl %eax,%r14d + addl %r13d,%r11d + xorl %ebx,%edi + vpshufd $250,%xmm1,%xmm7 + shrdl $2,%r14d,%r14d + addl %r11d,%edx + addl %edi,%r11d + vpsrld $11,%xmm6,%xmm6 + movl %edx,%r13d + addl %r11d,%r14d + shrdl $14,%r13d,%r13d + vpxor %xmm5,%xmm4,%xmm4 + movl %r14d,%r11d + movl %r8d,%r12d + shrdl $9,%r14d,%r14d + vpslld $11,%xmm5,%xmm5 + xorl %edx,%r13d + xorl %r9d,%r12d + shrdl $5,%r13d,%r13d + vpxor %xmm6,%xmm4,%xmm4 + xorl %r11d,%r14d + andl %edx,%r12d + xorl %edx,%r13d + vpsrld $10,%xmm7,%xmm6 + addl 36(%rsp),%r10d + movl %r11d,%edi + xorl %r9d,%r12d + vpxor %xmm5,%xmm4,%xmm4 + shrdl $11,%r14d,%r14d + xorl %eax,%edi + addl %r12d,%r10d + vpsrlq $17,%xmm7,%xmm7 + shrdl $6,%r13d,%r13d + andl %edi,%r15d + xorl %r11d,%r14d + vpaddd %xmm4,%xmm2,%xmm2 + addl %r13d,%r10d + xorl %eax,%r15d + shrdl $2,%r14d,%r14d + vpxor %xmm7,%xmm6,%xmm6 + addl %r10d,%ecx + addl %r15d,%r10d + movl %ecx,%r13d + vpsrlq $2,%xmm7,%xmm7 + addl %r10d,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%r10d + vpxor %xmm7,%xmm6,%xmm6 + movl %edx,%r12d + shrdl $9,%r14d,%r14d + xorl %ecx,%r13d + vpshufb %xmm8,%xmm6,%xmm6 + xorl %r8d,%r12d + shrdl $5,%r13d,%r13d + xorl %r10d,%r14d + vpaddd %xmm6,%xmm2,%xmm2 + andl %ecx,%r12d + xorl %ecx,%r13d + addl 40(%rsp),%r9d + vpshufd $80,%xmm2,%xmm7 + movl %r10d,%r15d + xorl %r8d,%r12d + shrdl $11,%r14d,%r14d + vpsrld $10,%xmm7,%xmm6 + xorl %r11d,%r15d + addl %r12d,%r9d + shrdl $6,%r13d,%r13d + vpsrlq $17,%xmm7,%xmm7 + andl %r15d,%edi + xorl %r10d,%r14d + addl %r13d,%r9d + vpxor %xmm7,%xmm6,%xmm6 + xorl %r11d,%edi + shrdl $2,%r14d,%r14d + addl %r9d,%ebx + vpsrlq $2,%xmm7,%xmm7 + addl %edi,%r9d + movl %ebx,%r13d + addl %r9d,%r14d + vpxor %xmm7,%xmm6,%xmm6 + shrdl $14,%r13d,%r13d + movl %r14d,%r9d + movl %ecx,%r12d + vpshufb %xmm9,%xmm6,%xmm6 + shrdl $9,%r14d,%r14d + xorl %ebx,%r13d + xorl %edx,%r12d + vpaddd %xmm6,%xmm2,%xmm2 + shrdl $5,%r13d,%r13d + xorl %r9d,%r14d + andl %ebx,%r12d + vpaddd 64(%rbp),%xmm2,%xmm6 + xorl %ebx,%r13d + addl 44(%rsp),%r8d + movl %r9d,%edi + xorl %edx,%r12d + shrdl $11,%r14d,%r14d + xorl %r10d,%edi + addl %r12d,%r8d + shrdl $6,%r13d,%r13d + andl %edi,%r15d + xorl %r9d,%r14d + addl %r13d,%r8d + xorl %r10d,%r15d + shrdl $2,%r14d,%r14d + addl %r8d,%eax + addl %r15d,%r8d + movl %eax,%r13d + addl %r8d,%r14d + vmovdqa %xmm6,32(%rsp) + vpalignr $4,%xmm3,%xmm0,%xmm4 + shrdl $14,%r13d,%r13d + movl %r14d,%r8d + movl %ebx,%r12d + vpalignr $4,%xmm1,%xmm2,%xmm7 + shrdl $9,%r14d,%r14d + xorl %eax,%r13d + xorl %ecx,%r12d + vpsrld $7,%xmm4,%xmm6 + shrdl $5,%r13d,%r13d + xorl %r8d,%r14d + andl %eax,%r12d + vpaddd %xmm7,%xmm3,%xmm3 + xorl %eax,%r13d + addl 48(%rsp),%edx + movl %r8d,%r15d + vpsrld $3,%xmm4,%xmm7 + xorl %ecx,%r12d + shrdl $11,%r14d,%r14d + xorl %r9d,%r15d + vpslld $14,%xmm4,%xmm5 + addl %r12d,%edx + shrdl $6,%r13d,%r13d + andl %r15d,%edi + vpxor %xmm6,%xmm7,%xmm4 + xorl %r8d,%r14d + addl %r13d,%edx + xorl %r9d,%edi + vpshufd $250,%xmm2,%xmm7 + shrdl $2,%r14d,%r14d + addl %edx,%r11d + addl %edi,%edx + vpsrld $11,%xmm6,%xmm6 + movl %r11d,%r13d + addl %edx,%r14d + shrdl $14,%r13d,%r13d + vpxor %xmm5,%xmm4,%xmm4 + movl %r14d,%edx + movl %eax,%r12d + shrdl $9,%r14d,%r14d + vpslld $11,%xmm5,%xmm5 + xorl %r11d,%r13d + xorl %ebx,%r12d + shrdl $5,%r13d,%r13d + vpxor %xmm6,%xmm4,%xmm4 + xorl %edx,%r14d + andl %r11d,%r12d + xorl %r11d,%r13d + vpsrld $10,%xmm7,%xmm6 + addl 52(%rsp),%ecx + movl %edx,%edi + xorl %ebx,%r12d + vpxor %xmm5,%xmm4,%xmm4 + shrdl $11,%r14d,%r14d + xorl %r8d,%edi + addl %r12d,%ecx + vpsrlq $17,%xmm7,%xmm7 + shrdl $6,%r13d,%r13d + andl %edi,%r15d + xorl %edx,%r14d + vpaddd %xmm4,%xmm3,%xmm3 + addl %r13d,%ecx + xorl %r8d,%r15d + shrdl $2,%r14d,%r14d + vpxor %xmm7,%xmm6,%xmm6 + addl %ecx,%r10d + addl %r15d,%ecx + movl %r10d,%r13d + vpsrlq $2,%xmm7,%xmm7 + addl %ecx,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%ecx + vpxor %xmm7,%xmm6,%xmm6 + movl %r11d,%r12d + shrdl $9,%r14d,%r14d + xorl %r10d,%r13d + vpshufb %xmm8,%xmm6,%xmm6 + xorl %eax,%r12d + shrdl $5,%r13d,%r13d + xorl %ecx,%r14d + vpaddd %xmm6,%xmm3,%xmm3 + andl %r10d,%r12d + xorl %r10d,%r13d + addl 56(%rsp),%ebx + vpshufd $80,%xmm3,%xmm7 + movl %ecx,%r15d + xorl %eax,%r12d + shrdl $11,%r14d,%r14d + vpsrld $10,%xmm7,%xmm6 + xorl %edx,%r15d + addl %r12d,%ebx + shrdl $6,%r13d,%r13d + vpsrlq $17,%xmm7,%xmm7 + andl %r15d,%edi + xorl %ecx,%r14d + addl %r13d,%ebx + vpxor %xmm7,%xmm6,%xmm6 + xorl %edx,%edi + shrdl $2,%r14d,%r14d + addl %ebx,%r9d + vpsrlq $2,%xmm7,%xmm7 + addl %edi,%ebx + movl %r9d,%r13d + addl %ebx,%r14d + vpxor %xmm7,%xmm6,%xmm6 + shrdl $14,%r13d,%r13d + movl %r14d,%ebx + movl %r10d,%r12d + vpshufb %xmm9,%xmm6,%xmm6 + shrdl $9,%r14d,%r14d + xorl %r9d,%r13d + xorl %r11d,%r12d + vpaddd %xmm6,%xmm3,%xmm3 + shrdl $5,%r13d,%r13d + xorl %ebx,%r14d + andl %r9d,%r12d + vpaddd 96(%rbp),%xmm3,%xmm6 + xorl %r9d,%r13d + addl 60(%rsp),%eax + movl %ebx,%edi + xorl %r11d,%r12d + shrdl $11,%r14d,%r14d + xorl %ecx,%edi + addl %r12d,%eax + shrdl $6,%r13d,%r13d + andl %edi,%r15d + xorl %ebx,%r14d + addl %r13d,%eax + xorl %ecx,%r15d + shrdl $2,%r14d,%r14d + addl %eax,%r8d + addl %r15d,%eax + movl %r8d,%r13d + addl %eax,%r14d + vmovdqa %xmm6,48(%rsp) + cmpb $0,131(%rbp) + jne L$avx_00_47 + shrdl $14,%r13d,%r13d + movl %r14d,%eax + movl %r9d,%r12d + shrdl $9,%r14d,%r14d + xorl %r8d,%r13d + xorl %r10d,%r12d + shrdl $5,%r13d,%r13d + xorl %eax,%r14d + andl %r8d,%r12d + xorl %r8d,%r13d + addl 0(%rsp),%r11d + movl %eax,%r15d + xorl %r10d,%r12d + shrdl $11,%r14d,%r14d + xorl %ebx,%r15d + addl %r12d,%r11d + shrdl $6,%r13d,%r13d + andl %r15d,%edi + xorl %eax,%r14d + addl %r13d,%r11d + xorl %ebx,%edi + shrdl $2,%r14d,%r14d + addl %r11d,%edx + addl %edi,%r11d + movl %edx,%r13d + addl %r11d,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%r11d + movl %r8d,%r12d + shrdl $9,%r14d,%r14d + xorl %edx,%r13d + xorl %r9d,%r12d + shrdl $5,%r13d,%r13d + xorl %r11d,%r14d + andl %edx,%r12d + xorl %edx,%r13d + addl 4(%rsp),%r10d + movl %r11d,%edi + xorl %r9d,%r12d + shrdl $11,%r14d,%r14d + xorl %eax,%edi + addl %r12d,%r10d + shrdl $6,%r13d,%r13d + andl %edi,%r15d + xorl %r11d,%r14d + addl %r13d,%r10d + xorl %eax,%r15d + shrdl $2,%r14d,%r14d + addl %r10d,%ecx + addl %r15d,%r10d + movl %ecx,%r13d + addl %r10d,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%r10d + movl %edx,%r12d + shrdl $9,%r14d,%r14d + xorl %ecx,%r13d + xorl %r8d,%r12d + shrdl $5,%r13d,%r13d + xorl %r10d,%r14d + andl %ecx,%r12d + xorl %ecx,%r13d + addl 8(%rsp),%r9d + movl %r10d,%r15d + xorl %r8d,%r12d + shrdl $11,%r14d,%r14d + xorl %r11d,%r15d + addl %r12d,%r9d + shrdl $6,%r13d,%r13d + andl %r15d,%edi + xorl %r10d,%r14d + addl %r13d,%r9d + xorl %r11d,%edi + shrdl $2,%r14d,%r14d + addl %r9d,%ebx + addl %edi,%r9d + movl %ebx,%r13d + addl %r9d,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%r9d + movl %ecx,%r12d + shrdl $9,%r14d,%r14d + xorl %ebx,%r13d + xorl %edx,%r12d + shrdl $5,%r13d,%r13d + xorl %r9d,%r14d + andl %ebx,%r12d + xorl %ebx,%r13d + addl 12(%rsp),%r8d + movl %r9d,%edi + xorl %edx,%r12d + shrdl $11,%r14d,%r14d + xorl %r10d,%edi + addl %r12d,%r8d + shrdl $6,%r13d,%r13d + andl %edi,%r15d + xorl %r9d,%r14d + addl %r13d,%r8d + xorl %r10d,%r15d + shrdl $2,%r14d,%r14d + addl %r8d,%eax + addl %r15d,%r8d + movl %eax,%r13d + addl %r8d,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%r8d + movl %ebx,%r12d + shrdl $9,%r14d,%r14d + xorl %eax,%r13d + xorl %ecx,%r12d + shrdl $5,%r13d,%r13d + xorl %r8d,%r14d + andl %eax,%r12d + xorl %eax,%r13d + addl 16(%rsp),%edx + movl %r8d,%r15d + xorl %ecx,%r12d + shrdl $11,%r14d,%r14d + xorl %r9d,%r15d + addl %r12d,%edx + shrdl $6,%r13d,%r13d + andl %r15d,%edi + xorl %r8d,%r14d + addl %r13d,%edx + xorl %r9d,%edi + shrdl $2,%r14d,%r14d + addl %edx,%r11d + addl %edi,%edx + movl %r11d,%r13d + addl %edx,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%edx + movl %eax,%r12d + shrdl $9,%r14d,%r14d + xorl %r11d,%r13d + xorl %ebx,%r12d + shrdl $5,%r13d,%r13d + xorl %edx,%r14d + andl %r11d,%r12d + xorl %r11d,%r13d + addl 20(%rsp),%ecx + movl %edx,%edi + xorl %ebx,%r12d + shrdl $11,%r14d,%r14d + xorl %r8d,%edi + addl %r12d,%ecx + shrdl $6,%r13d,%r13d + andl %edi,%r15d + xorl %edx,%r14d + addl %r13d,%ecx + xorl %r8d,%r15d + shrdl $2,%r14d,%r14d + addl %ecx,%r10d + addl %r15d,%ecx + movl %r10d,%r13d + addl %ecx,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%ecx + movl %r11d,%r12d + shrdl $9,%r14d,%r14d + xorl %r10d,%r13d + xorl %eax,%r12d + shrdl $5,%r13d,%r13d + xorl %ecx,%r14d + andl %r10d,%r12d + xorl %r10d,%r13d + addl 24(%rsp),%ebx + movl %ecx,%r15d + xorl %eax,%r12d + shrdl $11,%r14d,%r14d + xorl %edx,%r15d + addl %r12d,%ebx + shrdl $6,%r13d,%r13d + andl %r15d,%edi + xorl %ecx,%r14d + addl %r13d,%ebx + xorl %edx,%edi + shrdl $2,%r14d,%r14d + addl %ebx,%r9d + addl %edi,%ebx + movl %r9d,%r13d + addl %ebx,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%ebx + movl %r10d,%r12d + shrdl $9,%r14d,%r14d + xorl %r9d,%r13d + xorl %r11d,%r12d + shrdl $5,%r13d,%r13d + xorl %ebx,%r14d + andl %r9d,%r12d + xorl %r9d,%r13d + addl 28(%rsp),%eax + movl %ebx,%edi + xorl %r11d,%r12d + shrdl $11,%r14d,%r14d + xorl %ecx,%edi + addl %r12d,%eax + shrdl $6,%r13d,%r13d + andl %edi,%r15d + xorl %ebx,%r14d + addl %r13d,%eax + xorl %ecx,%r15d + shrdl $2,%r14d,%r14d + addl %eax,%r8d + addl %r15d,%eax + movl %r8d,%r13d + addl %eax,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%eax + movl %r9d,%r12d + shrdl $9,%r14d,%r14d + xorl %r8d,%r13d + xorl %r10d,%r12d + shrdl $5,%r13d,%r13d + xorl %eax,%r14d + andl %r8d,%r12d + xorl %r8d,%r13d + addl 32(%rsp),%r11d + movl %eax,%r15d + xorl %r10d,%r12d + shrdl $11,%r14d,%r14d + xorl %ebx,%r15d + addl %r12d,%r11d + shrdl $6,%r13d,%r13d + andl %r15d,%edi + xorl %eax,%r14d + addl %r13d,%r11d + xorl %ebx,%edi + shrdl $2,%r14d,%r14d + addl %r11d,%edx + addl %edi,%r11d + movl %edx,%r13d + addl %r11d,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%r11d + movl %r8d,%r12d + shrdl $9,%r14d,%r14d + xorl %edx,%r13d + xorl %r9d,%r12d + shrdl $5,%r13d,%r13d + xorl %r11d,%r14d + andl %edx,%r12d + xorl %edx,%r13d + addl 36(%rsp),%r10d + movl %r11d,%edi + xorl %r9d,%r12d + shrdl $11,%r14d,%r14d + xorl %eax,%edi + addl %r12d,%r10d + shrdl $6,%r13d,%r13d + andl %edi,%r15d + xorl %r11d,%r14d + addl %r13d,%r10d + xorl %eax,%r15d + shrdl $2,%r14d,%r14d + addl %r10d,%ecx + addl %r15d,%r10d + movl %ecx,%r13d + addl %r10d,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%r10d + movl %edx,%r12d + shrdl $9,%r14d,%r14d + xorl %ecx,%r13d + xorl %r8d,%r12d + shrdl $5,%r13d,%r13d + xorl %r10d,%r14d + andl %ecx,%r12d + xorl %ecx,%r13d + addl 40(%rsp),%r9d + movl %r10d,%r15d + xorl %r8d,%r12d + shrdl $11,%r14d,%r14d + xorl %r11d,%r15d + addl %r12d,%r9d + shrdl $6,%r13d,%r13d + andl %r15d,%edi + xorl %r10d,%r14d + addl %r13d,%r9d + xorl %r11d,%edi + shrdl $2,%r14d,%r14d + addl %r9d,%ebx + addl %edi,%r9d + movl %ebx,%r13d + addl %r9d,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%r9d + movl %ecx,%r12d + shrdl $9,%r14d,%r14d + xorl %ebx,%r13d + xorl %edx,%r12d + shrdl $5,%r13d,%r13d + xorl %r9d,%r14d + andl %ebx,%r12d + xorl %ebx,%r13d + addl 44(%rsp),%r8d + movl %r9d,%edi + xorl %edx,%r12d + shrdl $11,%r14d,%r14d + xorl %r10d,%edi + addl %r12d,%r8d + shrdl $6,%r13d,%r13d + andl %edi,%r15d + xorl %r9d,%r14d + addl %r13d,%r8d + xorl %r10d,%r15d + shrdl $2,%r14d,%r14d + addl %r8d,%eax + addl %r15d,%r8d + movl %eax,%r13d + addl %r8d,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%r8d + movl %ebx,%r12d + shrdl $9,%r14d,%r14d + xorl %eax,%r13d + xorl %ecx,%r12d + shrdl $5,%r13d,%r13d + xorl %r8d,%r14d + andl %eax,%r12d + xorl %eax,%r13d + addl 48(%rsp),%edx + movl %r8d,%r15d + xorl %ecx,%r12d + shrdl $11,%r14d,%r14d + xorl %r9d,%r15d + addl %r12d,%edx + shrdl $6,%r13d,%r13d + andl %r15d,%edi + xorl %r8d,%r14d + addl %r13d,%edx + xorl %r9d,%edi + shrdl $2,%r14d,%r14d + addl %edx,%r11d + addl %edi,%edx + movl %r11d,%r13d + addl %edx,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%edx + movl %eax,%r12d + shrdl $9,%r14d,%r14d + xorl %r11d,%r13d + xorl %ebx,%r12d + shrdl $5,%r13d,%r13d + xorl %edx,%r14d + andl %r11d,%r12d + xorl %r11d,%r13d + addl 52(%rsp),%ecx + movl %edx,%edi + xorl %ebx,%r12d + shrdl $11,%r14d,%r14d + xorl %r8d,%edi + addl %r12d,%ecx + shrdl $6,%r13d,%r13d + andl %edi,%r15d + xorl %edx,%r14d + addl %r13d,%ecx + xorl %r8d,%r15d + shrdl $2,%r14d,%r14d + addl %ecx,%r10d + addl %r15d,%ecx + movl %r10d,%r13d + addl %ecx,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%ecx + movl %r11d,%r12d + shrdl $9,%r14d,%r14d + xorl %r10d,%r13d + xorl %eax,%r12d + shrdl $5,%r13d,%r13d + xorl %ecx,%r14d + andl %r10d,%r12d + xorl %r10d,%r13d + addl 56(%rsp),%ebx + movl %ecx,%r15d + xorl %eax,%r12d + shrdl $11,%r14d,%r14d + xorl %edx,%r15d + addl %r12d,%ebx + shrdl $6,%r13d,%r13d + andl %r15d,%edi + xorl %ecx,%r14d + addl %r13d,%ebx + xorl %edx,%edi + shrdl $2,%r14d,%r14d + addl %ebx,%r9d + addl %edi,%ebx + movl %r9d,%r13d + addl %ebx,%r14d + shrdl $14,%r13d,%r13d + movl %r14d,%ebx + movl %r10d,%r12d + shrdl $9,%r14d,%r14d + xorl %r9d,%r13d + xorl %r11d,%r12d + shrdl $5,%r13d,%r13d + xorl %ebx,%r14d + andl %r9d,%r12d + xorl %r9d,%r13d + addl 60(%rsp),%eax + movl %ebx,%edi + xorl %r11d,%r12d + shrdl $11,%r14d,%r14d + xorl %ecx,%edi + addl %r12d,%eax + shrdl $6,%r13d,%r13d + andl %edi,%r15d + xorl %ebx,%r14d + addl %r13d,%eax + xorl %ecx,%r15d + shrdl $2,%r14d,%r14d + addl %eax,%r8d + addl %r15d,%eax + movl %r8d,%r13d + addl %eax,%r14d + movq 64+0(%rsp),%rdi + movl %r14d,%eax + + addl 0(%rdi),%eax + leaq 64(%rsi),%rsi + addl 4(%rdi),%ebx + addl 8(%rdi),%ecx + addl 12(%rdi),%edx + addl 16(%rdi),%r8d + addl 20(%rdi),%r9d + addl 24(%rdi),%r10d + addl 28(%rdi),%r11d + + cmpq 64+16(%rsp),%rsi + + movl %eax,0(%rdi) + movl %ebx,4(%rdi) + movl %ecx,8(%rdi) + movl %edx,12(%rdi) + movl %r8d,16(%rdi) + movl %r9d,20(%rdi) + movl %r10d,24(%rdi) + movl %r11d,28(%rdi) + jb L$loop_avx + + movq 88(%rsp),%rsi + + vzeroupper + movq -48(%rsi),%r15 + + movq -40(%rsi),%r14 + + movq -32(%rsi),%r13 + + movq -24(%rsi),%r12 + + movq -16(%rsi),%rbp + + movq -8(%rsi),%rbx + + leaq (%rsi),%rsp + +L$epilogue_avx: + ret + + +#endif diff --git a/http/vendor/ring/pregenerated/sha256-x86_64-nasm.asm b/http/vendor/ring/pregenerated/sha256-x86_64-nasm.asm new file mode 100644 index 0000000..ba0da61 --- /dev/null +++ b/http/vendor/ring/pregenerated/sha256-x86_64-nasm.asm @@ -0,0 +1,4413 @@ +; This file is generated from a similarly-named Perl script in the BoringSSL +; source tree. Do not edit by hand. + +%ifidn __OUTPUT_FORMAT__, win64 +default rel +%define XMMWORD +%define YMMWORD +%define ZMMWORD +%define _CET_ENDBR + +%include "ring_core_generated/prefix_symbols_nasm.inc" +section .text code align=64 + + +global sha256_block_data_order_nohw + +ALIGN 16 +sha256_block_data_order_nohw: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_sha256_block_data_order_nohw: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + + + +_CET_ENDBR + mov rax,rsp + + push rbx + + push rbp + + push r12 + + push r13 + + push r14 + + push r15 + + shl rdx,4 + sub rsp,16*4+4*8 + lea rdx,[rdx*4+rsi] + and rsp,-64 + mov QWORD[((64+0))+rsp],rdi + mov QWORD[((64+8))+rsp],rsi + mov QWORD[((64+16))+rsp],rdx + mov QWORD[88+rsp],rax + +$L$prologue: + + mov eax,DWORD[rdi] + mov ebx,DWORD[4+rdi] + mov ecx,DWORD[8+rdi] + mov edx,DWORD[12+rdi] + mov r8d,DWORD[16+rdi] + mov r9d,DWORD[20+rdi] + mov r10d,DWORD[24+rdi] + mov r11d,DWORD[28+rdi] + jmp NEAR $L$loop + +ALIGN 16 +$L$loop: + mov edi,ebx + lea rbp,[K256] + xor edi,ecx + mov r12d,DWORD[rsi] + mov r13d,r8d + mov r14d,eax + bswap r12d + ror r13d,14 + mov r15d,r9d + + xor r13d,r8d + ror r14d,9 + xor r15d,r10d + + mov DWORD[rsp],r12d + xor r14d,eax + and r15d,r8d + + ror r13d,5 + add r12d,r11d + xor r15d,r10d + + ror r14d,11 + xor r13d,r8d + add r12d,r15d + + mov r15d,eax + add r12d,DWORD[rbp] + xor r14d,eax + + xor r15d,ebx + ror r13d,6 + mov r11d,ebx + + and edi,r15d + ror r14d,2 + add r12d,r13d + + xor r11d,edi + add edx,r12d + add r11d,r12d + + lea rbp,[4+rbp] + add r11d,r14d + mov r12d,DWORD[4+rsi] + mov r13d,edx + mov r14d,r11d + bswap r12d + ror r13d,14 + mov edi,r8d + + xor r13d,edx + ror r14d,9 + xor edi,r9d + + mov DWORD[4+rsp],r12d + xor r14d,r11d + and edi,edx + + ror r13d,5 + add r12d,r10d + xor edi,r9d + + ror r14d,11 + xor r13d,edx + add r12d,edi + + mov edi,r11d + add r12d,DWORD[rbp] + xor r14d,r11d + + xor edi,eax + ror r13d,6 + mov r10d,eax + + and r15d,edi + ror r14d,2 + add r12d,r13d + + xor r10d,r15d + add ecx,r12d + add r10d,r12d + + lea rbp,[4+rbp] + add r10d,r14d + mov r12d,DWORD[8+rsi] + mov r13d,ecx + mov r14d,r10d + bswap r12d + ror r13d,14 + mov r15d,edx + + xor r13d,ecx + ror r14d,9 + xor r15d,r8d + + mov DWORD[8+rsp],r12d + xor r14d,r10d + and r15d,ecx + + ror r13d,5 + add r12d,r9d + xor r15d,r8d + + ror r14d,11 + xor r13d,ecx + add r12d,r15d + + mov r15d,r10d + add r12d,DWORD[rbp] + xor r14d,r10d + + xor r15d,r11d + ror r13d,6 + mov r9d,r11d + + and edi,r15d + ror r14d,2 + add r12d,r13d + + xor r9d,edi + add ebx,r12d + add r9d,r12d + + lea rbp,[4+rbp] + add r9d,r14d + mov r12d,DWORD[12+rsi] + mov r13d,ebx + mov r14d,r9d + bswap r12d + ror r13d,14 + mov edi,ecx + + xor r13d,ebx + ror r14d,9 + xor edi,edx + + mov DWORD[12+rsp],r12d + xor r14d,r9d + and edi,ebx + + ror r13d,5 + add r12d,r8d + xor edi,edx + + ror r14d,11 + xor r13d,ebx + add r12d,edi + + mov edi,r9d + add r12d,DWORD[rbp] + xor r14d,r9d + + xor edi,r10d + ror r13d,6 + mov r8d,r10d + + and r15d,edi + ror r14d,2 + add r12d,r13d + + xor r8d,r15d + add eax,r12d + add r8d,r12d + + lea rbp,[20+rbp] + add r8d,r14d + mov r12d,DWORD[16+rsi] + mov r13d,eax + mov r14d,r8d + bswap r12d + ror r13d,14 + mov r15d,ebx + + xor r13d,eax + ror r14d,9 + xor r15d,ecx + + mov DWORD[16+rsp],r12d + xor r14d,r8d + and r15d,eax + + ror r13d,5 + add r12d,edx + xor r15d,ecx + + ror r14d,11 + xor r13d,eax + add r12d,r15d + + mov r15d,r8d + add r12d,DWORD[rbp] + xor r14d,r8d + + xor r15d,r9d + ror r13d,6 + mov edx,r9d + + and edi,r15d + ror r14d,2 + add r12d,r13d + + xor edx,edi + add r11d,r12d + add edx,r12d + + lea rbp,[4+rbp] + add edx,r14d + mov r12d,DWORD[20+rsi] + mov r13d,r11d + mov r14d,edx + bswap r12d + ror r13d,14 + mov edi,eax + + xor r13d,r11d + ror r14d,9 + xor edi,ebx + + mov DWORD[20+rsp],r12d + xor r14d,edx + and edi,r11d + + ror r13d,5 + add r12d,ecx + xor edi,ebx + + ror r14d,11 + xor r13d,r11d + add r12d,edi + + mov edi,edx + add r12d,DWORD[rbp] + xor r14d,edx + + xor edi,r8d + ror r13d,6 + mov ecx,r8d + + and r15d,edi + ror r14d,2 + add r12d,r13d + + xor ecx,r15d + add r10d,r12d + add ecx,r12d + + lea rbp,[4+rbp] + add ecx,r14d + mov r12d,DWORD[24+rsi] + mov r13d,r10d + mov r14d,ecx + bswap r12d + ror r13d,14 + mov r15d,r11d + + xor r13d,r10d + ror r14d,9 + xor r15d,eax + + mov DWORD[24+rsp],r12d + xor r14d,ecx + and r15d,r10d + + ror r13d,5 + add r12d,ebx + xor r15d,eax + + ror r14d,11 + xor r13d,r10d + add r12d,r15d + + mov r15d,ecx + add r12d,DWORD[rbp] + xor r14d,ecx + + xor r15d,edx + ror r13d,6 + mov ebx,edx + + and edi,r15d + ror r14d,2 + add r12d,r13d + + xor ebx,edi + add r9d,r12d + add ebx,r12d + + lea rbp,[4+rbp] + add ebx,r14d + mov r12d,DWORD[28+rsi] + mov r13d,r9d + mov r14d,ebx + bswap r12d + ror r13d,14 + mov edi,r10d + + xor r13d,r9d + ror r14d,9 + xor edi,r11d + + mov DWORD[28+rsp],r12d + xor r14d,ebx + and edi,r9d + + ror r13d,5 + add r12d,eax + xor edi,r11d + + ror r14d,11 + xor r13d,r9d + add r12d,edi + + mov edi,ebx + add r12d,DWORD[rbp] + xor r14d,ebx + + xor edi,ecx + ror r13d,6 + mov eax,ecx + + and r15d,edi + ror r14d,2 + add r12d,r13d + + xor eax,r15d + add r8d,r12d + add eax,r12d + + lea rbp,[20+rbp] + add eax,r14d + mov r12d,DWORD[32+rsi] + mov r13d,r8d + mov r14d,eax + bswap r12d + ror r13d,14 + mov r15d,r9d + + xor r13d,r8d + ror r14d,9 + xor r15d,r10d + + mov DWORD[32+rsp],r12d + xor r14d,eax + and r15d,r8d + + ror r13d,5 + add r12d,r11d + xor r15d,r10d + + ror r14d,11 + xor r13d,r8d + add r12d,r15d + + mov r15d,eax + add r12d,DWORD[rbp] + xor r14d,eax + + xor r15d,ebx + ror r13d,6 + mov r11d,ebx + + and edi,r15d + ror r14d,2 + add r12d,r13d + + xor r11d,edi + add edx,r12d + add r11d,r12d + + lea rbp,[4+rbp] + add r11d,r14d + mov r12d,DWORD[36+rsi] + mov r13d,edx + mov r14d,r11d + bswap r12d + ror r13d,14 + mov edi,r8d + + xor r13d,edx + ror r14d,9 + xor edi,r9d + + mov DWORD[36+rsp],r12d + xor r14d,r11d + and edi,edx + + ror r13d,5 + add r12d,r10d + xor edi,r9d + + ror r14d,11 + xor r13d,edx + add r12d,edi + + mov edi,r11d + add r12d,DWORD[rbp] + xor r14d,r11d + + xor edi,eax + ror r13d,6 + mov r10d,eax + + and r15d,edi + ror r14d,2 + add r12d,r13d + + xor r10d,r15d + add ecx,r12d + add r10d,r12d + + lea rbp,[4+rbp] + add r10d,r14d + mov r12d,DWORD[40+rsi] + mov r13d,ecx + mov r14d,r10d + bswap r12d + ror r13d,14 + mov r15d,edx + + xor r13d,ecx + ror r14d,9 + xor r15d,r8d + + mov DWORD[40+rsp],r12d + xor r14d,r10d + and r15d,ecx + + ror r13d,5 + add r12d,r9d + xor r15d,r8d + + ror r14d,11 + xor r13d,ecx + add r12d,r15d + + mov r15d,r10d + add r12d,DWORD[rbp] + xor r14d,r10d + + xor r15d,r11d + ror r13d,6 + mov r9d,r11d + + and edi,r15d + ror r14d,2 + add r12d,r13d + + xor r9d,edi + add ebx,r12d + add r9d,r12d + + lea rbp,[4+rbp] + add r9d,r14d + mov r12d,DWORD[44+rsi] + mov r13d,ebx + mov r14d,r9d + bswap r12d + ror r13d,14 + mov edi,ecx + + xor r13d,ebx + ror r14d,9 + xor edi,edx + + mov DWORD[44+rsp],r12d + xor r14d,r9d + and edi,ebx + + ror r13d,5 + add r12d,r8d + xor edi,edx + + ror r14d,11 + xor r13d,ebx + add r12d,edi + + mov edi,r9d + add r12d,DWORD[rbp] + xor r14d,r9d + + xor edi,r10d + ror r13d,6 + mov r8d,r10d + + and r15d,edi + ror r14d,2 + add r12d,r13d + + xor r8d,r15d + add eax,r12d + add r8d,r12d + + lea rbp,[20+rbp] + add r8d,r14d + mov r12d,DWORD[48+rsi] + mov r13d,eax + mov r14d,r8d + bswap r12d + ror r13d,14 + mov r15d,ebx + + xor r13d,eax + ror r14d,9 + xor r15d,ecx + + mov DWORD[48+rsp],r12d + xor r14d,r8d + and r15d,eax + + ror r13d,5 + add r12d,edx + xor r15d,ecx + + ror r14d,11 + xor r13d,eax + add r12d,r15d + + mov r15d,r8d + add r12d,DWORD[rbp] + xor r14d,r8d + + xor r15d,r9d + ror r13d,6 + mov edx,r9d + + and edi,r15d + ror r14d,2 + add r12d,r13d + + xor edx,edi + add r11d,r12d + add edx,r12d + + lea rbp,[4+rbp] + add edx,r14d + mov r12d,DWORD[52+rsi] + mov r13d,r11d + mov r14d,edx + bswap r12d + ror r13d,14 + mov edi,eax + + xor r13d,r11d + ror r14d,9 + xor edi,ebx + + mov DWORD[52+rsp],r12d + xor r14d,edx + and edi,r11d + + ror r13d,5 + add r12d,ecx + xor edi,ebx + + ror r14d,11 + xor r13d,r11d + add r12d,edi + + mov edi,edx + add r12d,DWORD[rbp] + xor r14d,edx + + xor edi,r8d + ror r13d,6 + mov ecx,r8d + + and r15d,edi + ror r14d,2 + add r12d,r13d + + xor ecx,r15d + add r10d,r12d + add ecx,r12d + + lea rbp,[4+rbp] + add ecx,r14d + mov r12d,DWORD[56+rsi] + mov r13d,r10d + mov r14d,ecx + bswap r12d + ror r13d,14 + mov r15d,r11d + + xor r13d,r10d + ror r14d,9 + xor r15d,eax + + mov DWORD[56+rsp],r12d + xor r14d,ecx + and r15d,r10d + + ror r13d,5 + add r12d,ebx + xor r15d,eax + + ror r14d,11 + xor r13d,r10d + add r12d,r15d + + mov r15d,ecx + add r12d,DWORD[rbp] + xor r14d,ecx + + xor r15d,edx + ror r13d,6 + mov ebx,edx + + and edi,r15d + ror r14d,2 + add r12d,r13d + + xor ebx,edi + add r9d,r12d + add ebx,r12d + + lea rbp,[4+rbp] + add ebx,r14d + mov r12d,DWORD[60+rsi] + mov r13d,r9d + mov r14d,ebx + bswap r12d + ror r13d,14 + mov edi,r10d + + xor r13d,r9d + ror r14d,9 + xor edi,r11d + + mov DWORD[60+rsp],r12d + xor r14d,ebx + and edi,r9d + + ror r13d,5 + add r12d,eax + xor edi,r11d + + ror r14d,11 + xor r13d,r9d + add r12d,edi + + mov edi,ebx + add r12d,DWORD[rbp] + xor r14d,ebx + + xor edi,ecx + ror r13d,6 + mov eax,ecx + + and r15d,edi + ror r14d,2 + add r12d,r13d + + xor eax,r15d + add r8d,r12d + add eax,r12d + + lea rbp,[20+rbp] + jmp NEAR $L$rounds_16_xx +ALIGN 16 +$L$rounds_16_xx: + mov r13d,DWORD[4+rsp] + mov r15d,DWORD[56+rsp] + + mov r12d,r13d + ror r13d,11 + add eax,r14d + mov r14d,r15d + ror r15d,2 + + xor r13d,r12d + shr r12d,3 + ror r13d,7 + xor r15d,r14d + shr r14d,10 + + ror r15d,17 + xor r12d,r13d + xor r15d,r14d + add r12d,DWORD[36+rsp] + + add r12d,DWORD[rsp] + mov r13d,r8d + add r12d,r15d + mov r14d,eax + ror r13d,14 + mov r15d,r9d + + xor r13d,r8d + ror r14d,9 + xor r15d,r10d + + mov DWORD[rsp],r12d + xor r14d,eax + and r15d,r8d + + ror r13d,5 + add r12d,r11d + xor r15d,r10d + + ror r14d,11 + xor r13d,r8d + add r12d,r15d + + mov r15d,eax + add r12d,DWORD[rbp] + xor r14d,eax + + xor r15d,ebx + ror r13d,6 + mov r11d,ebx + + and edi,r15d + ror r14d,2 + add r12d,r13d + + xor r11d,edi + add edx,r12d + add r11d,r12d + + lea rbp,[4+rbp] + mov r13d,DWORD[8+rsp] + mov edi,DWORD[60+rsp] + + mov r12d,r13d + ror r13d,11 + add r11d,r14d + mov r14d,edi + ror edi,2 + + xor r13d,r12d + shr r12d,3 + ror r13d,7 + xor edi,r14d + shr r14d,10 + + ror edi,17 + xor r12d,r13d + xor edi,r14d + add r12d,DWORD[40+rsp] + + add r12d,DWORD[4+rsp] + mov r13d,edx + add r12d,edi + mov r14d,r11d + ror r13d,14 + mov edi,r8d + + xor r13d,edx + ror r14d,9 + xor edi,r9d + + mov DWORD[4+rsp],r12d + xor r14d,r11d + and edi,edx + + ror r13d,5 + add r12d,r10d + xor edi,r9d + + ror r14d,11 + xor r13d,edx + add r12d,edi + + mov edi,r11d + add r12d,DWORD[rbp] + xor r14d,r11d + + xor edi,eax + ror r13d,6 + mov r10d,eax + + and r15d,edi + ror r14d,2 + add r12d,r13d + + xor r10d,r15d + add ecx,r12d + add r10d,r12d + + lea rbp,[4+rbp] + mov r13d,DWORD[12+rsp] + mov r15d,DWORD[rsp] + + mov r12d,r13d + ror r13d,11 + add r10d,r14d + mov r14d,r15d + ror r15d,2 + + xor r13d,r12d + shr r12d,3 + ror r13d,7 + xor r15d,r14d + shr r14d,10 + + ror r15d,17 + xor r12d,r13d + xor r15d,r14d + add r12d,DWORD[44+rsp] + + add r12d,DWORD[8+rsp] + mov r13d,ecx + add r12d,r15d + mov r14d,r10d + ror r13d,14 + mov r15d,edx + + xor r13d,ecx + ror r14d,9 + xor r15d,r8d + + mov DWORD[8+rsp],r12d + xor r14d,r10d + and r15d,ecx + + ror r13d,5 + add r12d,r9d + xor r15d,r8d + + ror r14d,11 + xor r13d,ecx + add r12d,r15d + + mov r15d,r10d + add r12d,DWORD[rbp] + xor r14d,r10d + + xor r15d,r11d + ror r13d,6 + mov r9d,r11d + + and edi,r15d + ror r14d,2 + add r12d,r13d + + xor r9d,edi + add ebx,r12d + add r9d,r12d + + lea rbp,[4+rbp] + mov r13d,DWORD[16+rsp] + mov edi,DWORD[4+rsp] + + mov r12d,r13d + ror r13d,11 + add r9d,r14d + mov r14d,edi + ror edi,2 + + xor r13d,r12d + shr r12d,3 + ror r13d,7 + xor edi,r14d + shr r14d,10 + + ror edi,17 + xor r12d,r13d + xor edi,r14d + add r12d,DWORD[48+rsp] + + add r12d,DWORD[12+rsp] + mov r13d,ebx + add r12d,edi + mov r14d,r9d + ror r13d,14 + mov edi,ecx + + xor r13d,ebx + ror r14d,9 + xor edi,edx + + mov DWORD[12+rsp],r12d + xor r14d,r9d + and edi,ebx + + ror r13d,5 + add r12d,r8d + xor edi,edx + + ror r14d,11 + xor r13d,ebx + add r12d,edi + + mov edi,r9d + add r12d,DWORD[rbp] + xor r14d,r9d + + xor edi,r10d + ror r13d,6 + mov r8d,r10d + + and r15d,edi + ror r14d,2 + add r12d,r13d + + xor r8d,r15d + add eax,r12d + add r8d,r12d + + lea rbp,[20+rbp] + mov r13d,DWORD[20+rsp] + mov r15d,DWORD[8+rsp] + + mov r12d,r13d + ror r13d,11 + add r8d,r14d + mov r14d,r15d + ror r15d,2 + + xor r13d,r12d + shr r12d,3 + ror r13d,7 + xor r15d,r14d + shr r14d,10 + + ror r15d,17 + xor r12d,r13d + xor r15d,r14d + add r12d,DWORD[52+rsp] + + add r12d,DWORD[16+rsp] + mov r13d,eax + add r12d,r15d + mov r14d,r8d + ror r13d,14 + mov r15d,ebx + + xor r13d,eax + ror r14d,9 + xor r15d,ecx + + mov DWORD[16+rsp],r12d + xor r14d,r8d + and r15d,eax + + ror r13d,5 + add r12d,edx + xor r15d,ecx + + ror r14d,11 + xor r13d,eax + add r12d,r15d + + mov r15d,r8d + add r12d,DWORD[rbp] + xor r14d,r8d + + xor r15d,r9d + ror r13d,6 + mov edx,r9d + + and edi,r15d + ror r14d,2 + add r12d,r13d + + xor edx,edi + add r11d,r12d + add edx,r12d + + lea rbp,[4+rbp] + mov r13d,DWORD[24+rsp] + mov edi,DWORD[12+rsp] + + mov r12d,r13d + ror r13d,11 + add edx,r14d + mov r14d,edi + ror edi,2 + + xor r13d,r12d + shr r12d,3 + ror r13d,7 + xor edi,r14d + shr r14d,10 + + ror edi,17 + xor r12d,r13d + xor edi,r14d + add r12d,DWORD[56+rsp] + + add r12d,DWORD[20+rsp] + mov r13d,r11d + add r12d,edi + mov r14d,edx + ror r13d,14 + mov edi,eax + + xor r13d,r11d + ror r14d,9 + xor edi,ebx + + mov DWORD[20+rsp],r12d + xor r14d,edx + and edi,r11d + + ror r13d,5 + add r12d,ecx + xor edi,ebx + + ror r14d,11 + xor r13d,r11d + add r12d,edi + + mov edi,edx + add r12d,DWORD[rbp] + xor r14d,edx + + xor edi,r8d + ror r13d,6 + mov ecx,r8d + + and r15d,edi + ror r14d,2 + add r12d,r13d + + xor ecx,r15d + add r10d,r12d + add ecx,r12d + + lea rbp,[4+rbp] + mov r13d,DWORD[28+rsp] + mov r15d,DWORD[16+rsp] + + mov r12d,r13d + ror r13d,11 + add ecx,r14d + mov r14d,r15d + ror r15d,2 + + xor r13d,r12d + shr r12d,3 + ror r13d,7 + xor r15d,r14d + shr r14d,10 + + ror r15d,17 + xor r12d,r13d + xor r15d,r14d + add r12d,DWORD[60+rsp] + + add r12d,DWORD[24+rsp] + mov r13d,r10d + add r12d,r15d + mov r14d,ecx + ror r13d,14 + mov r15d,r11d + + xor r13d,r10d + ror r14d,9 + xor r15d,eax + + mov DWORD[24+rsp],r12d + xor r14d,ecx + and r15d,r10d + + ror r13d,5 + add r12d,ebx + xor r15d,eax + + ror r14d,11 + xor r13d,r10d + add r12d,r15d + + mov r15d,ecx + add r12d,DWORD[rbp] + xor r14d,ecx + + xor r15d,edx + ror r13d,6 + mov ebx,edx + + and edi,r15d + ror r14d,2 + add r12d,r13d + + xor ebx,edi + add r9d,r12d + add ebx,r12d + + lea rbp,[4+rbp] + mov r13d,DWORD[32+rsp] + mov edi,DWORD[20+rsp] + + mov r12d,r13d + ror r13d,11 + add ebx,r14d + mov r14d,edi + ror edi,2 + + xor r13d,r12d + shr r12d,3 + ror r13d,7 + xor edi,r14d + shr r14d,10 + + ror edi,17 + xor r12d,r13d + xor edi,r14d + add r12d,DWORD[rsp] + + add r12d,DWORD[28+rsp] + mov r13d,r9d + add r12d,edi + mov r14d,ebx + ror r13d,14 + mov edi,r10d + + xor r13d,r9d + ror r14d,9 + xor edi,r11d + + mov DWORD[28+rsp],r12d + xor r14d,ebx + and edi,r9d + + ror r13d,5 + add r12d,eax + xor edi,r11d + + ror r14d,11 + xor r13d,r9d + add r12d,edi + + mov edi,ebx + add r12d,DWORD[rbp] + xor r14d,ebx + + xor edi,ecx + ror r13d,6 + mov eax,ecx + + and r15d,edi + ror r14d,2 + add r12d,r13d + + xor eax,r15d + add r8d,r12d + add eax,r12d + + lea rbp,[20+rbp] + mov r13d,DWORD[36+rsp] + mov r15d,DWORD[24+rsp] + + mov r12d,r13d + ror r13d,11 + add eax,r14d + mov r14d,r15d + ror r15d,2 + + xor r13d,r12d + shr r12d,3 + ror r13d,7 + xor r15d,r14d + shr r14d,10 + + ror r15d,17 + xor r12d,r13d + xor r15d,r14d + add r12d,DWORD[4+rsp] + + add r12d,DWORD[32+rsp] + mov r13d,r8d + add r12d,r15d + mov r14d,eax + ror r13d,14 + mov r15d,r9d + + xor r13d,r8d + ror r14d,9 + xor r15d,r10d + + mov DWORD[32+rsp],r12d + xor r14d,eax + and r15d,r8d + + ror r13d,5 + add r12d,r11d + xor r15d,r10d + + ror r14d,11 + xor r13d,r8d + add r12d,r15d + + mov r15d,eax + add r12d,DWORD[rbp] + xor r14d,eax + + xor r15d,ebx + ror r13d,6 + mov r11d,ebx + + and edi,r15d + ror r14d,2 + add r12d,r13d + + xor r11d,edi + add edx,r12d + add r11d,r12d + + lea rbp,[4+rbp] + mov r13d,DWORD[40+rsp] + mov edi,DWORD[28+rsp] + + mov r12d,r13d + ror r13d,11 + add r11d,r14d + mov r14d,edi + ror edi,2 + + xor r13d,r12d + shr r12d,3 + ror r13d,7 + xor edi,r14d + shr r14d,10 + + ror edi,17 + xor r12d,r13d + xor edi,r14d + add r12d,DWORD[8+rsp] + + add r12d,DWORD[36+rsp] + mov r13d,edx + add r12d,edi + mov r14d,r11d + ror r13d,14 + mov edi,r8d + + xor r13d,edx + ror r14d,9 + xor edi,r9d + + mov DWORD[36+rsp],r12d + xor r14d,r11d + and edi,edx + + ror r13d,5 + add r12d,r10d + xor edi,r9d + + ror r14d,11 + xor r13d,edx + add r12d,edi + + mov edi,r11d + add r12d,DWORD[rbp] + xor r14d,r11d + + xor edi,eax + ror r13d,6 + mov r10d,eax + + and r15d,edi + ror r14d,2 + add r12d,r13d + + xor r10d,r15d + add ecx,r12d + add r10d,r12d + + lea rbp,[4+rbp] + mov r13d,DWORD[44+rsp] + mov r15d,DWORD[32+rsp] + + mov r12d,r13d + ror r13d,11 + add r10d,r14d + mov r14d,r15d + ror r15d,2 + + xor r13d,r12d + shr r12d,3 + ror r13d,7 + xor r15d,r14d + shr r14d,10 + + ror r15d,17 + xor r12d,r13d + xor r15d,r14d + add r12d,DWORD[12+rsp] + + add r12d,DWORD[40+rsp] + mov r13d,ecx + add r12d,r15d + mov r14d,r10d + ror r13d,14 + mov r15d,edx + + xor r13d,ecx + ror r14d,9 + xor r15d,r8d + + mov DWORD[40+rsp],r12d + xor r14d,r10d + and r15d,ecx + + ror r13d,5 + add r12d,r9d + xor r15d,r8d + + ror r14d,11 + xor r13d,ecx + add r12d,r15d + + mov r15d,r10d + add r12d,DWORD[rbp] + xor r14d,r10d + + xor r15d,r11d + ror r13d,6 + mov r9d,r11d + + and edi,r15d + ror r14d,2 + add r12d,r13d + + xor r9d,edi + add ebx,r12d + add r9d,r12d + + lea rbp,[4+rbp] + mov r13d,DWORD[48+rsp] + mov edi,DWORD[36+rsp] + + mov r12d,r13d + ror r13d,11 + add r9d,r14d + mov r14d,edi + ror edi,2 + + xor r13d,r12d + shr r12d,3 + ror r13d,7 + xor edi,r14d + shr r14d,10 + + ror edi,17 + xor r12d,r13d + xor edi,r14d + add r12d,DWORD[16+rsp] + + add r12d,DWORD[44+rsp] + mov r13d,ebx + add r12d,edi + mov r14d,r9d + ror r13d,14 + mov edi,ecx + + xor r13d,ebx + ror r14d,9 + xor edi,edx + + mov DWORD[44+rsp],r12d + xor r14d,r9d + and edi,ebx + + ror r13d,5 + add r12d,r8d + xor edi,edx + + ror r14d,11 + xor r13d,ebx + add r12d,edi + + mov edi,r9d + add r12d,DWORD[rbp] + xor r14d,r9d + + xor edi,r10d + ror r13d,6 + mov r8d,r10d + + and r15d,edi + ror r14d,2 + add r12d,r13d + + xor r8d,r15d + add eax,r12d + add r8d,r12d + + lea rbp,[20+rbp] + mov r13d,DWORD[52+rsp] + mov r15d,DWORD[40+rsp] + + mov r12d,r13d + ror r13d,11 + add r8d,r14d + mov r14d,r15d + ror r15d,2 + + xor r13d,r12d + shr r12d,3 + ror r13d,7 + xor r15d,r14d + shr r14d,10 + + ror r15d,17 + xor r12d,r13d + xor r15d,r14d + add r12d,DWORD[20+rsp] + + add r12d,DWORD[48+rsp] + mov r13d,eax + add r12d,r15d + mov r14d,r8d + ror r13d,14 + mov r15d,ebx + + xor r13d,eax + ror r14d,9 + xor r15d,ecx + + mov DWORD[48+rsp],r12d + xor r14d,r8d + and r15d,eax + + ror r13d,5 + add r12d,edx + xor r15d,ecx + + ror r14d,11 + xor r13d,eax + add r12d,r15d + + mov r15d,r8d + add r12d,DWORD[rbp] + xor r14d,r8d + + xor r15d,r9d + ror r13d,6 + mov edx,r9d + + and edi,r15d + ror r14d,2 + add r12d,r13d + + xor edx,edi + add r11d,r12d + add edx,r12d + + lea rbp,[4+rbp] + mov r13d,DWORD[56+rsp] + mov edi,DWORD[44+rsp] + + mov r12d,r13d + ror r13d,11 + add edx,r14d + mov r14d,edi + ror edi,2 + + xor r13d,r12d + shr r12d,3 + ror r13d,7 + xor edi,r14d + shr r14d,10 + + ror edi,17 + xor r12d,r13d + xor edi,r14d + add r12d,DWORD[24+rsp] + + add r12d,DWORD[52+rsp] + mov r13d,r11d + add r12d,edi + mov r14d,edx + ror r13d,14 + mov edi,eax + + xor r13d,r11d + ror r14d,9 + xor edi,ebx + + mov DWORD[52+rsp],r12d + xor r14d,edx + and edi,r11d + + ror r13d,5 + add r12d,ecx + xor edi,ebx + + ror r14d,11 + xor r13d,r11d + add r12d,edi + + mov edi,edx + add r12d,DWORD[rbp] + xor r14d,edx + + xor edi,r8d + ror r13d,6 + mov ecx,r8d + + and r15d,edi + ror r14d,2 + add r12d,r13d + + xor ecx,r15d + add r10d,r12d + add ecx,r12d + + lea rbp,[4+rbp] + mov r13d,DWORD[60+rsp] + mov r15d,DWORD[48+rsp] + + mov r12d,r13d + ror r13d,11 + add ecx,r14d + mov r14d,r15d + ror r15d,2 + + xor r13d,r12d + shr r12d,3 + ror r13d,7 + xor r15d,r14d + shr r14d,10 + + ror r15d,17 + xor r12d,r13d + xor r15d,r14d + add r12d,DWORD[28+rsp] + + add r12d,DWORD[56+rsp] + mov r13d,r10d + add r12d,r15d + mov r14d,ecx + ror r13d,14 + mov r15d,r11d + + xor r13d,r10d + ror r14d,9 + xor r15d,eax + + mov DWORD[56+rsp],r12d + xor r14d,ecx + and r15d,r10d + + ror r13d,5 + add r12d,ebx + xor r15d,eax + + ror r14d,11 + xor r13d,r10d + add r12d,r15d + + mov r15d,ecx + add r12d,DWORD[rbp] + xor r14d,ecx + + xor r15d,edx + ror r13d,6 + mov ebx,edx + + and edi,r15d + ror r14d,2 + add r12d,r13d + + xor ebx,edi + add r9d,r12d + add ebx,r12d + + lea rbp,[4+rbp] + mov r13d,DWORD[rsp] + mov edi,DWORD[52+rsp] + + mov r12d,r13d + ror r13d,11 + add ebx,r14d + mov r14d,edi + ror edi,2 + + xor r13d,r12d + shr r12d,3 + ror r13d,7 + xor edi,r14d + shr r14d,10 + + ror edi,17 + xor r12d,r13d + xor edi,r14d + add r12d,DWORD[32+rsp] + + add r12d,DWORD[60+rsp] + mov r13d,r9d + add r12d,edi + mov r14d,ebx + ror r13d,14 + mov edi,r10d + + xor r13d,r9d + ror r14d,9 + xor edi,r11d + + mov DWORD[60+rsp],r12d + xor r14d,ebx + and edi,r9d + + ror r13d,5 + add r12d,eax + xor edi,r11d + + ror r14d,11 + xor r13d,r9d + add r12d,edi + + mov edi,ebx + add r12d,DWORD[rbp] + xor r14d,ebx + + xor edi,ecx + ror r13d,6 + mov eax,ecx + + and r15d,edi + ror r14d,2 + add r12d,r13d + + xor eax,r15d + add r8d,r12d + add eax,r12d + + lea rbp,[20+rbp] + cmp BYTE[3+rbp],0 + jnz NEAR $L$rounds_16_xx + + mov rdi,QWORD[((64+0))+rsp] + add eax,r14d + lea rsi,[64+rsi] + + add eax,DWORD[rdi] + add ebx,DWORD[4+rdi] + add ecx,DWORD[8+rdi] + add edx,DWORD[12+rdi] + add r8d,DWORD[16+rdi] + add r9d,DWORD[20+rdi] + add r10d,DWORD[24+rdi] + add r11d,DWORD[28+rdi] + + cmp rsi,QWORD[((64+16))+rsp] + + mov DWORD[rdi],eax + mov DWORD[4+rdi],ebx + mov DWORD[8+rdi],ecx + mov DWORD[12+rdi],edx + mov DWORD[16+rdi],r8d + mov DWORD[20+rdi],r9d + mov DWORD[24+rdi],r10d + mov DWORD[28+rdi],r11d + jb NEAR $L$loop + + mov rsi,QWORD[88+rsp] + + mov r15,QWORD[((-48))+rsi] + + mov r14,QWORD[((-40))+rsi] + + mov r13,QWORD[((-32))+rsi] + + mov r12,QWORD[((-24))+rsi] + + mov rbp,QWORD[((-16))+rsi] + + mov rbx,QWORD[((-8))+rsi] + + lea rsp,[rsi] + +$L$epilogue: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_sha256_block_data_order_nohw: +section .rdata rdata align=8 +ALIGN 64 + +K256: + DD 0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5 + DD 0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5 + DD 0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5 + DD 0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5 + DD 0xd807aa98,0x12835b01,0x243185be,0x550c7dc3 + DD 0xd807aa98,0x12835b01,0x243185be,0x550c7dc3 + DD 0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174 + DD 0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174 + DD 0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc + DD 0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc + DD 0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da + DD 0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da + DD 0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7 + DD 0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7 + DD 0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967 + DD 0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967 + DD 0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13 + DD 0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13 + DD 0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85 + DD 0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85 + DD 0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3 + DD 0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3 + DD 0xd192e819,0xd6990624,0xf40e3585,0x106aa070 + DD 0xd192e819,0xd6990624,0xf40e3585,0x106aa070 + DD 0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5 + DD 0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5 + DD 0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3 + DD 0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3 + DD 0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208 + DD 0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208 + DD 0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2 + DD 0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2 + + DD 0x00010203,0x04050607,0x08090a0b,0x0c0d0e0f + DD 0x00010203,0x04050607,0x08090a0b,0x0c0d0e0f + DD 0x03020100,0x0b0a0908,0xffffffff,0xffffffff + DD 0x03020100,0x0b0a0908,0xffffffff,0xffffffff + DD 0xffffffff,0xffffffff,0x03020100,0x0b0a0908 + DD 0xffffffff,0xffffffff,0x03020100,0x0b0a0908 + DB 83,72,65,50,53,54,32,98,108,111,99,107,32,116,114,97 + DB 110,115,102,111,114,109,32,102,111,114,32,120,56,54,95,54 + DB 52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121 + DB 32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46 + DB 111,114,103,62,0 +section .text + +global sha256_block_data_order_hw + +ALIGN 64 +sha256_block_data_order_hw: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_sha256_block_data_order_hw: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + + + +_CET_ENDBR + lea rsp,[((-88))+rsp] + movaps XMMWORD[(-8-80)+rax],xmm6 + movaps XMMWORD[(-8-64)+rax],xmm7 + movaps XMMWORD[(-8-48)+rax],xmm8 + movaps XMMWORD[(-8-32)+rax],xmm9 + movaps XMMWORD[(-8-16)+rax],xmm10 +$L$prologue_shaext: + lea rcx,[((K256+128))] + movdqu xmm1,XMMWORD[rdi] + movdqu xmm2,XMMWORD[16+rdi] + movdqa xmm7,XMMWORD[((512-128))+rcx] + + pshufd xmm0,xmm1,0x1b + pshufd xmm1,xmm1,0xb1 + pshufd xmm2,xmm2,0x1b + movdqa xmm8,xmm7 +DB 102,15,58,15,202,8 + punpcklqdq xmm2,xmm0 + jmp NEAR $L$oop_shaext + +ALIGN 16 +$L$oop_shaext: + movdqu xmm3,XMMWORD[rsi] + movdqu xmm4,XMMWORD[16+rsi] + movdqu xmm5,XMMWORD[32+rsi] +DB 102,15,56,0,223 + movdqu xmm6,XMMWORD[48+rsi] + + movdqa xmm0,XMMWORD[((0-128))+rcx] + paddd xmm0,xmm3 +DB 102,15,56,0,231 + movdqa xmm10,xmm2 + DB 15,56,203,209 + pshufd xmm0,xmm0,0x0e + nop + movdqa xmm9,xmm1 + DB 15,56,203,202 + + movdqa xmm0,XMMWORD[((32-128))+rcx] + paddd xmm0,xmm4 +DB 102,15,56,0,239 + DB 15,56,203,209 + pshufd xmm0,xmm0,0x0e + lea rsi,[64+rsi] + DB 15,56,204,220 + DB 15,56,203,202 + + movdqa xmm0,XMMWORD[((64-128))+rcx] + paddd xmm0,xmm5 +DB 102,15,56,0,247 + DB 15,56,203,209 + pshufd xmm0,xmm0,0x0e + movdqa xmm7,xmm6 +DB 102,15,58,15,253,4 + nop + paddd xmm3,xmm7 + DB 15,56,204,229 + DB 15,56,203,202 + + movdqa xmm0,XMMWORD[((96-128))+rcx] + paddd xmm0,xmm6 + DB 15,56,205,222 + DB 15,56,203,209 + pshufd xmm0,xmm0,0x0e + movdqa xmm7,xmm3 +DB 102,15,58,15,254,4 + nop + paddd xmm4,xmm7 + DB 15,56,204,238 + DB 15,56,203,202 + movdqa xmm0,XMMWORD[((128-128))+rcx] + paddd xmm0,xmm3 + DB 15,56,205,227 + DB 15,56,203,209 + pshufd xmm0,xmm0,0x0e + movdqa xmm7,xmm4 +DB 102,15,58,15,251,4 + nop + paddd xmm5,xmm7 + DB 15,56,204,243 + DB 15,56,203,202 + movdqa xmm0,XMMWORD[((160-128))+rcx] + paddd xmm0,xmm4 + DB 15,56,205,236 + DB 15,56,203,209 + pshufd xmm0,xmm0,0x0e + movdqa xmm7,xmm5 +DB 102,15,58,15,252,4 + nop + paddd xmm6,xmm7 + DB 15,56,204,220 + DB 15,56,203,202 + movdqa xmm0,XMMWORD[((192-128))+rcx] + paddd xmm0,xmm5 + DB 15,56,205,245 + DB 15,56,203,209 + pshufd xmm0,xmm0,0x0e + movdqa xmm7,xmm6 +DB 102,15,58,15,253,4 + nop + paddd xmm3,xmm7 + DB 15,56,204,229 + DB 15,56,203,202 + movdqa xmm0,XMMWORD[((224-128))+rcx] + paddd xmm0,xmm6 + DB 15,56,205,222 + DB 15,56,203,209 + pshufd xmm0,xmm0,0x0e + movdqa xmm7,xmm3 +DB 102,15,58,15,254,4 + nop + paddd xmm4,xmm7 + DB 15,56,204,238 + DB 15,56,203,202 + movdqa xmm0,XMMWORD[((256-128))+rcx] + paddd xmm0,xmm3 + DB 15,56,205,227 + DB 15,56,203,209 + pshufd xmm0,xmm0,0x0e + movdqa xmm7,xmm4 +DB 102,15,58,15,251,4 + nop + paddd xmm5,xmm7 + DB 15,56,204,243 + DB 15,56,203,202 + movdqa xmm0,XMMWORD[((288-128))+rcx] + paddd xmm0,xmm4 + DB 15,56,205,236 + DB 15,56,203,209 + pshufd xmm0,xmm0,0x0e + movdqa xmm7,xmm5 +DB 102,15,58,15,252,4 + nop + paddd xmm6,xmm7 + DB 15,56,204,220 + DB 15,56,203,202 + movdqa xmm0,XMMWORD[((320-128))+rcx] + paddd xmm0,xmm5 + DB 15,56,205,245 + DB 15,56,203,209 + pshufd xmm0,xmm0,0x0e + movdqa xmm7,xmm6 +DB 102,15,58,15,253,4 + nop + paddd xmm3,xmm7 + DB 15,56,204,229 + DB 15,56,203,202 + movdqa xmm0,XMMWORD[((352-128))+rcx] + paddd xmm0,xmm6 + DB 15,56,205,222 + DB 15,56,203,209 + pshufd xmm0,xmm0,0x0e + movdqa xmm7,xmm3 +DB 102,15,58,15,254,4 + nop + paddd xmm4,xmm7 + DB 15,56,204,238 + DB 15,56,203,202 + movdqa xmm0,XMMWORD[((384-128))+rcx] + paddd xmm0,xmm3 + DB 15,56,205,227 + DB 15,56,203,209 + pshufd xmm0,xmm0,0x0e + movdqa xmm7,xmm4 +DB 102,15,58,15,251,4 + nop + paddd xmm5,xmm7 + DB 15,56,204,243 + DB 15,56,203,202 + movdqa xmm0,XMMWORD[((416-128))+rcx] + paddd xmm0,xmm4 + DB 15,56,205,236 + DB 15,56,203,209 + pshufd xmm0,xmm0,0x0e + movdqa xmm7,xmm5 +DB 102,15,58,15,252,4 + DB 15,56,203,202 + paddd xmm6,xmm7 + + movdqa xmm0,XMMWORD[((448-128))+rcx] + paddd xmm0,xmm5 + DB 15,56,203,209 + pshufd xmm0,xmm0,0x0e + DB 15,56,205,245 + movdqa xmm7,xmm8 + DB 15,56,203,202 + + movdqa xmm0,XMMWORD[((480-128))+rcx] + paddd xmm0,xmm6 + nop + DB 15,56,203,209 + pshufd xmm0,xmm0,0x0e + dec rdx + nop + DB 15,56,203,202 + + paddd xmm2,xmm10 + paddd xmm1,xmm9 + jnz NEAR $L$oop_shaext + + pshufd xmm2,xmm2,0xb1 + pshufd xmm7,xmm1,0x1b + pshufd xmm1,xmm1,0xb1 + punpckhqdq xmm1,xmm2 +DB 102,15,58,15,215,8 + + movdqu XMMWORD[rdi],xmm1 + movdqu XMMWORD[16+rdi],xmm2 + movaps xmm6,XMMWORD[((-8-80))+rax] + movaps xmm7,XMMWORD[((-8-64))+rax] + movaps xmm8,XMMWORD[((-8-48))+rax] + movaps xmm9,XMMWORD[((-8-32))+rax] + movaps xmm10,XMMWORD[((-8-16))+rax] + mov rsp,rax +$L$epilogue_shaext: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_sha256_block_data_order_hw: +global sha256_block_data_order_ssse3 + +ALIGN 64 +sha256_block_data_order_ssse3: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_sha256_block_data_order_ssse3: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + + + +_CET_ENDBR + mov rax,rsp + + push rbx + + push rbp + + push r12 + + push r13 + + push r14 + + push r15 + + shl rdx,4 + sub rsp,160 + lea rdx,[rdx*4+rsi] + and rsp,-64 + mov QWORD[((64+0))+rsp],rdi + mov QWORD[((64+8))+rsp],rsi + mov QWORD[((64+16))+rsp],rdx + mov QWORD[88+rsp],rax + + movaps XMMWORD[(64+32)+rsp],xmm6 + movaps XMMWORD[(64+48)+rsp],xmm7 + movaps XMMWORD[(64+64)+rsp],xmm8 + movaps XMMWORD[(64+80)+rsp],xmm9 +$L$prologue_ssse3: + + mov eax,DWORD[rdi] + mov ebx,DWORD[4+rdi] + mov ecx,DWORD[8+rdi] + mov edx,DWORD[12+rdi] + mov r8d,DWORD[16+rdi] + mov r9d,DWORD[20+rdi] + mov r10d,DWORD[24+rdi] + mov r11d,DWORD[28+rdi] + + + jmp NEAR $L$loop_ssse3 +ALIGN 16 +$L$loop_ssse3: + movdqa xmm7,XMMWORD[((K256+512))] + movdqu xmm0,XMMWORD[rsi] + movdqu xmm1,XMMWORD[16+rsi] + movdqu xmm2,XMMWORD[32+rsi] +DB 102,15,56,0,199 + movdqu xmm3,XMMWORD[48+rsi] + lea rbp,[K256] +DB 102,15,56,0,207 + movdqa xmm4,XMMWORD[rbp] + movdqa xmm5,XMMWORD[32+rbp] +DB 102,15,56,0,215 + paddd xmm4,xmm0 + movdqa xmm6,XMMWORD[64+rbp] +DB 102,15,56,0,223 + movdqa xmm7,XMMWORD[96+rbp] + paddd xmm5,xmm1 + paddd xmm6,xmm2 + paddd xmm7,xmm3 + movdqa XMMWORD[rsp],xmm4 + mov r14d,eax + movdqa XMMWORD[16+rsp],xmm5 + mov edi,ebx + movdqa XMMWORD[32+rsp],xmm6 + xor edi,ecx + movdqa XMMWORD[48+rsp],xmm7 + mov r13d,r8d + jmp NEAR $L$ssse3_00_47 + +ALIGN 16 +$L$ssse3_00_47: + sub rbp,-128 + ror r13d,14 + movdqa xmm4,xmm1 + mov eax,r14d + mov r12d,r9d + movdqa xmm7,xmm3 + ror r14d,9 + xor r13d,r8d + xor r12d,r10d + ror r13d,5 + xor r14d,eax +DB 102,15,58,15,224,4 + and r12d,r8d + xor r13d,r8d +DB 102,15,58,15,250,4 + add r11d,DWORD[rsp] + mov r15d,eax + xor r12d,r10d + ror r14d,11 + movdqa xmm5,xmm4 + xor r15d,ebx + add r11d,r12d + movdqa xmm6,xmm4 + ror r13d,6 + and edi,r15d + psrld xmm4,3 + xor r14d,eax + add r11d,r13d + xor edi,ebx + paddd xmm0,xmm7 + ror r14d,2 + add edx,r11d + psrld xmm6,7 + add r11d,edi + mov r13d,edx + pshufd xmm7,xmm3,250 + add r14d,r11d + ror r13d,14 + pslld xmm5,14 + mov r11d,r14d + mov r12d,r8d + pxor xmm4,xmm6 + ror r14d,9 + xor r13d,edx + xor r12d,r9d + ror r13d,5 + psrld xmm6,11 + xor r14d,r11d + pxor xmm4,xmm5 + and r12d,edx + xor r13d,edx + pslld xmm5,11 + add r10d,DWORD[4+rsp] + mov edi,r11d + pxor xmm4,xmm6 + xor r12d,r9d + ror r14d,11 + movdqa xmm6,xmm7 + xor edi,eax + add r10d,r12d + pxor xmm4,xmm5 + ror r13d,6 + and r15d,edi + xor r14d,r11d + psrld xmm7,10 + add r10d,r13d + xor r15d,eax + paddd xmm0,xmm4 + ror r14d,2 + add ecx,r10d + psrlq xmm6,17 + add r10d,r15d + mov r13d,ecx + add r14d,r10d + pxor xmm7,xmm6 + ror r13d,14 + mov r10d,r14d + mov r12d,edx + ror r14d,9 + psrlq xmm6,2 + xor r13d,ecx + xor r12d,r8d + pxor xmm7,xmm6 + ror r13d,5 + xor r14d,r10d + and r12d,ecx + pshufd xmm7,xmm7,128 + xor r13d,ecx + add r9d,DWORD[8+rsp] + mov r15d,r10d + psrldq xmm7,8 + xor r12d,r8d + ror r14d,11 + xor r15d,r11d + add r9d,r12d + ror r13d,6 + paddd xmm0,xmm7 + and edi,r15d + xor r14d,r10d + add r9d,r13d + pshufd xmm7,xmm0,80 + xor edi,r11d + ror r14d,2 + add ebx,r9d + movdqa xmm6,xmm7 + add r9d,edi + mov r13d,ebx + psrld xmm7,10 + add r14d,r9d + ror r13d,14 + psrlq xmm6,17 + mov r9d,r14d + mov r12d,ecx + pxor xmm7,xmm6 + ror r14d,9 + xor r13d,ebx + xor r12d,edx + ror r13d,5 + xor r14d,r9d + psrlq xmm6,2 + and r12d,ebx + xor r13d,ebx + add r8d,DWORD[12+rsp] + pxor xmm7,xmm6 + mov edi,r9d + xor r12d,edx + ror r14d,11 + pshufd xmm7,xmm7,8 + xor edi,r10d + add r8d,r12d + movdqa xmm6,XMMWORD[rbp] + ror r13d,6 + and r15d,edi + pslldq xmm7,8 + xor r14d,r9d + add r8d,r13d + xor r15d,r10d + paddd xmm0,xmm7 + ror r14d,2 + add eax,r8d + add r8d,r15d + paddd xmm6,xmm0 + mov r13d,eax + add r14d,r8d + movdqa XMMWORD[rsp],xmm6 + ror r13d,14 + movdqa xmm4,xmm2 + mov r8d,r14d + mov r12d,ebx + movdqa xmm7,xmm0 + ror r14d,9 + xor r13d,eax + xor r12d,ecx + ror r13d,5 + xor r14d,r8d +DB 102,15,58,15,225,4 + and r12d,eax + xor r13d,eax +DB 102,15,58,15,251,4 + add edx,DWORD[16+rsp] + mov r15d,r8d + xor r12d,ecx + ror r14d,11 + movdqa xmm5,xmm4 + xor r15d,r9d + add edx,r12d + movdqa xmm6,xmm4 + ror r13d,6 + and edi,r15d + psrld xmm4,3 + xor r14d,r8d + add edx,r13d + xor edi,r9d + paddd xmm1,xmm7 + ror r14d,2 + add r11d,edx + psrld xmm6,7 + add edx,edi + mov r13d,r11d + pshufd xmm7,xmm0,250 + add r14d,edx + ror r13d,14 + pslld xmm5,14 + mov edx,r14d + mov r12d,eax + pxor xmm4,xmm6 + ror r14d,9 + xor r13d,r11d + xor r12d,ebx + ror r13d,5 + psrld xmm6,11 + xor r14d,edx + pxor xmm4,xmm5 + and r12d,r11d + xor r13d,r11d + pslld xmm5,11 + add ecx,DWORD[20+rsp] + mov edi,edx + pxor xmm4,xmm6 + xor r12d,ebx + ror r14d,11 + movdqa xmm6,xmm7 + xor edi,r8d + add ecx,r12d + pxor xmm4,xmm5 + ror r13d,6 + and r15d,edi + xor r14d,edx + psrld xmm7,10 + add ecx,r13d + xor r15d,r8d + paddd xmm1,xmm4 + ror r14d,2 + add r10d,ecx + psrlq xmm6,17 + add ecx,r15d + mov r13d,r10d + add r14d,ecx + pxor xmm7,xmm6 + ror r13d,14 + mov ecx,r14d + mov r12d,r11d + ror r14d,9 + psrlq xmm6,2 + xor r13d,r10d + xor r12d,eax + pxor xmm7,xmm6 + ror r13d,5 + xor r14d,ecx + and r12d,r10d + pshufd xmm7,xmm7,128 + xor r13d,r10d + add ebx,DWORD[24+rsp] + mov r15d,ecx + psrldq xmm7,8 + xor r12d,eax + ror r14d,11 + xor r15d,edx + add ebx,r12d + ror r13d,6 + paddd xmm1,xmm7 + and edi,r15d + xor r14d,ecx + add ebx,r13d + pshufd xmm7,xmm1,80 + xor edi,edx + ror r14d,2 + add r9d,ebx + movdqa xmm6,xmm7 + add ebx,edi + mov r13d,r9d + psrld xmm7,10 + add r14d,ebx + ror r13d,14 + psrlq xmm6,17 + mov ebx,r14d + mov r12d,r10d + pxor xmm7,xmm6 + ror r14d,9 + xor r13d,r9d + xor r12d,r11d + ror r13d,5 + xor r14d,ebx + psrlq xmm6,2 + and r12d,r9d + xor r13d,r9d + add eax,DWORD[28+rsp] + pxor xmm7,xmm6 + mov edi,ebx + xor r12d,r11d + ror r14d,11 + pshufd xmm7,xmm7,8 + xor edi,ecx + add eax,r12d + movdqa xmm6,XMMWORD[32+rbp] + ror r13d,6 + and r15d,edi + pslldq xmm7,8 + xor r14d,ebx + add eax,r13d + xor r15d,ecx + paddd xmm1,xmm7 + ror r14d,2 + add r8d,eax + add eax,r15d + paddd xmm6,xmm1 + mov r13d,r8d + add r14d,eax + movdqa XMMWORD[16+rsp],xmm6 + ror r13d,14 + movdqa xmm4,xmm3 + mov eax,r14d + mov r12d,r9d + movdqa xmm7,xmm1 + ror r14d,9 + xor r13d,r8d + xor r12d,r10d + ror r13d,5 + xor r14d,eax +DB 102,15,58,15,226,4 + and r12d,r8d + xor r13d,r8d +DB 102,15,58,15,248,4 + add r11d,DWORD[32+rsp] + mov r15d,eax + xor r12d,r10d + ror r14d,11 + movdqa xmm5,xmm4 + xor r15d,ebx + add r11d,r12d + movdqa xmm6,xmm4 + ror r13d,6 + and edi,r15d + psrld xmm4,3 + xor r14d,eax + add r11d,r13d + xor edi,ebx + paddd xmm2,xmm7 + ror r14d,2 + add edx,r11d + psrld xmm6,7 + add r11d,edi + mov r13d,edx + pshufd xmm7,xmm1,250 + add r14d,r11d + ror r13d,14 + pslld xmm5,14 + mov r11d,r14d + mov r12d,r8d + pxor xmm4,xmm6 + ror r14d,9 + xor r13d,edx + xor r12d,r9d + ror r13d,5 + psrld xmm6,11 + xor r14d,r11d + pxor xmm4,xmm5 + and r12d,edx + xor r13d,edx + pslld xmm5,11 + add r10d,DWORD[36+rsp] + mov edi,r11d + pxor xmm4,xmm6 + xor r12d,r9d + ror r14d,11 + movdqa xmm6,xmm7 + xor edi,eax + add r10d,r12d + pxor xmm4,xmm5 + ror r13d,6 + and r15d,edi + xor r14d,r11d + psrld xmm7,10 + add r10d,r13d + xor r15d,eax + paddd xmm2,xmm4 + ror r14d,2 + add ecx,r10d + psrlq xmm6,17 + add r10d,r15d + mov r13d,ecx + add r14d,r10d + pxor xmm7,xmm6 + ror r13d,14 + mov r10d,r14d + mov r12d,edx + ror r14d,9 + psrlq xmm6,2 + xor r13d,ecx + xor r12d,r8d + pxor xmm7,xmm6 + ror r13d,5 + xor r14d,r10d + and r12d,ecx + pshufd xmm7,xmm7,128 + xor r13d,ecx + add r9d,DWORD[40+rsp] + mov r15d,r10d + psrldq xmm7,8 + xor r12d,r8d + ror r14d,11 + xor r15d,r11d + add r9d,r12d + ror r13d,6 + paddd xmm2,xmm7 + and edi,r15d + xor r14d,r10d + add r9d,r13d + pshufd xmm7,xmm2,80 + xor edi,r11d + ror r14d,2 + add ebx,r9d + movdqa xmm6,xmm7 + add r9d,edi + mov r13d,ebx + psrld xmm7,10 + add r14d,r9d + ror r13d,14 + psrlq xmm6,17 + mov r9d,r14d + mov r12d,ecx + pxor xmm7,xmm6 + ror r14d,9 + xor r13d,ebx + xor r12d,edx + ror r13d,5 + xor r14d,r9d + psrlq xmm6,2 + and r12d,ebx + xor r13d,ebx + add r8d,DWORD[44+rsp] + pxor xmm7,xmm6 + mov edi,r9d + xor r12d,edx + ror r14d,11 + pshufd xmm7,xmm7,8 + xor edi,r10d + add r8d,r12d + movdqa xmm6,XMMWORD[64+rbp] + ror r13d,6 + and r15d,edi + pslldq xmm7,8 + xor r14d,r9d + add r8d,r13d + xor r15d,r10d + paddd xmm2,xmm7 + ror r14d,2 + add eax,r8d + add r8d,r15d + paddd xmm6,xmm2 + mov r13d,eax + add r14d,r8d + movdqa XMMWORD[32+rsp],xmm6 + ror r13d,14 + movdqa xmm4,xmm0 + mov r8d,r14d + mov r12d,ebx + movdqa xmm7,xmm2 + ror r14d,9 + xor r13d,eax + xor r12d,ecx + ror r13d,5 + xor r14d,r8d +DB 102,15,58,15,227,4 + and r12d,eax + xor r13d,eax +DB 102,15,58,15,249,4 + add edx,DWORD[48+rsp] + mov r15d,r8d + xor r12d,ecx + ror r14d,11 + movdqa xmm5,xmm4 + xor r15d,r9d + add edx,r12d + movdqa xmm6,xmm4 + ror r13d,6 + and edi,r15d + psrld xmm4,3 + xor r14d,r8d + add edx,r13d + xor edi,r9d + paddd xmm3,xmm7 + ror r14d,2 + add r11d,edx + psrld xmm6,7 + add edx,edi + mov r13d,r11d + pshufd xmm7,xmm2,250 + add r14d,edx + ror r13d,14 + pslld xmm5,14 + mov edx,r14d + mov r12d,eax + pxor xmm4,xmm6 + ror r14d,9 + xor r13d,r11d + xor r12d,ebx + ror r13d,5 + psrld xmm6,11 + xor r14d,edx + pxor xmm4,xmm5 + and r12d,r11d + xor r13d,r11d + pslld xmm5,11 + add ecx,DWORD[52+rsp] + mov edi,edx + pxor xmm4,xmm6 + xor r12d,ebx + ror r14d,11 + movdqa xmm6,xmm7 + xor edi,r8d + add ecx,r12d + pxor xmm4,xmm5 + ror r13d,6 + and r15d,edi + xor r14d,edx + psrld xmm7,10 + add ecx,r13d + xor r15d,r8d + paddd xmm3,xmm4 + ror r14d,2 + add r10d,ecx + psrlq xmm6,17 + add ecx,r15d + mov r13d,r10d + add r14d,ecx + pxor xmm7,xmm6 + ror r13d,14 + mov ecx,r14d + mov r12d,r11d + ror r14d,9 + psrlq xmm6,2 + xor r13d,r10d + xor r12d,eax + pxor xmm7,xmm6 + ror r13d,5 + xor r14d,ecx + and r12d,r10d + pshufd xmm7,xmm7,128 + xor r13d,r10d + add ebx,DWORD[56+rsp] + mov r15d,ecx + psrldq xmm7,8 + xor r12d,eax + ror r14d,11 + xor r15d,edx + add ebx,r12d + ror r13d,6 + paddd xmm3,xmm7 + and edi,r15d + xor r14d,ecx + add ebx,r13d + pshufd xmm7,xmm3,80 + xor edi,edx + ror r14d,2 + add r9d,ebx + movdqa xmm6,xmm7 + add ebx,edi + mov r13d,r9d + psrld xmm7,10 + add r14d,ebx + ror r13d,14 + psrlq xmm6,17 + mov ebx,r14d + mov r12d,r10d + pxor xmm7,xmm6 + ror r14d,9 + xor r13d,r9d + xor r12d,r11d + ror r13d,5 + xor r14d,ebx + psrlq xmm6,2 + and r12d,r9d + xor r13d,r9d + add eax,DWORD[60+rsp] + pxor xmm7,xmm6 + mov edi,ebx + xor r12d,r11d + ror r14d,11 + pshufd xmm7,xmm7,8 + xor edi,ecx + add eax,r12d + movdqa xmm6,XMMWORD[96+rbp] + ror r13d,6 + and r15d,edi + pslldq xmm7,8 + xor r14d,ebx + add eax,r13d + xor r15d,ecx + paddd xmm3,xmm7 + ror r14d,2 + add r8d,eax + add eax,r15d + paddd xmm6,xmm3 + mov r13d,r8d + add r14d,eax + movdqa XMMWORD[48+rsp],xmm6 + cmp BYTE[131+rbp],0 + jne NEAR $L$ssse3_00_47 + ror r13d,14 + mov eax,r14d + mov r12d,r9d + ror r14d,9 + xor r13d,r8d + xor r12d,r10d + ror r13d,5 + xor r14d,eax + and r12d,r8d + xor r13d,r8d + add r11d,DWORD[rsp] + mov r15d,eax + xor r12d,r10d + ror r14d,11 + xor r15d,ebx + add r11d,r12d + ror r13d,6 + and edi,r15d + xor r14d,eax + add r11d,r13d + xor edi,ebx + ror r14d,2 + add edx,r11d + add r11d,edi + mov r13d,edx + add r14d,r11d + ror r13d,14 + mov r11d,r14d + mov r12d,r8d + ror r14d,9 + xor r13d,edx + xor r12d,r9d + ror r13d,5 + xor r14d,r11d + and r12d,edx + xor r13d,edx + add r10d,DWORD[4+rsp] + mov edi,r11d + xor r12d,r9d + ror r14d,11 + xor edi,eax + add r10d,r12d + ror r13d,6 + and r15d,edi + xor r14d,r11d + add r10d,r13d + xor r15d,eax + ror r14d,2 + add ecx,r10d + add r10d,r15d + mov r13d,ecx + add r14d,r10d + ror r13d,14 + mov r10d,r14d + mov r12d,edx + ror r14d,9 + xor r13d,ecx + xor r12d,r8d + ror r13d,5 + xor r14d,r10d + and r12d,ecx + xor r13d,ecx + add r9d,DWORD[8+rsp] + mov r15d,r10d + xor r12d,r8d + ror r14d,11 + xor r15d,r11d + add r9d,r12d + ror r13d,6 + and edi,r15d + xor r14d,r10d + add r9d,r13d + xor edi,r11d + ror r14d,2 + add ebx,r9d + add r9d,edi + mov r13d,ebx + add r14d,r9d + ror r13d,14 + mov r9d,r14d + mov r12d,ecx + ror r14d,9 + xor r13d,ebx + xor r12d,edx + ror r13d,5 + xor r14d,r9d + and r12d,ebx + xor r13d,ebx + add r8d,DWORD[12+rsp] + mov edi,r9d + xor r12d,edx + ror r14d,11 + xor edi,r10d + add r8d,r12d + ror r13d,6 + and r15d,edi + xor r14d,r9d + add r8d,r13d + xor r15d,r10d + ror r14d,2 + add eax,r8d + add r8d,r15d + mov r13d,eax + add r14d,r8d + ror r13d,14 + mov r8d,r14d + mov r12d,ebx + ror r14d,9 + xor r13d,eax + xor r12d,ecx + ror r13d,5 + xor r14d,r8d + and r12d,eax + xor r13d,eax + add edx,DWORD[16+rsp] + mov r15d,r8d + xor r12d,ecx + ror r14d,11 + xor r15d,r9d + add edx,r12d + ror r13d,6 + and edi,r15d + xor r14d,r8d + add edx,r13d + xor edi,r9d + ror r14d,2 + add r11d,edx + add edx,edi + mov r13d,r11d + add r14d,edx + ror r13d,14 + mov edx,r14d + mov r12d,eax + ror r14d,9 + xor r13d,r11d + xor r12d,ebx + ror r13d,5 + xor r14d,edx + and r12d,r11d + xor r13d,r11d + add ecx,DWORD[20+rsp] + mov edi,edx + xor r12d,ebx + ror r14d,11 + xor edi,r8d + add ecx,r12d + ror r13d,6 + and r15d,edi + xor r14d,edx + add ecx,r13d + xor r15d,r8d + ror r14d,2 + add r10d,ecx + add ecx,r15d + mov r13d,r10d + add r14d,ecx + ror r13d,14 + mov ecx,r14d + mov r12d,r11d + ror r14d,9 + xor r13d,r10d + xor r12d,eax + ror r13d,5 + xor r14d,ecx + and r12d,r10d + xor r13d,r10d + add ebx,DWORD[24+rsp] + mov r15d,ecx + xor r12d,eax + ror r14d,11 + xor r15d,edx + add ebx,r12d + ror r13d,6 + and edi,r15d + xor r14d,ecx + add ebx,r13d + xor edi,edx + ror r14d,2 + add r9d,ebx + add ebx,edi + mov r13d,r9d + add r14d,ebx + ror r13d,14 + mov ebx,r14d + mov r12d,r10d + ror r14d,9 + xor r13d,r9d + xor r12d,r11d + ror r13d,5 + xor r14d,ebx + and r12d,r9d + xor r13d,r9d + add eax,DWORD[28+rsp] + mov edi,ebx + xor r12d,r11d + ror r14d,11 + xor edi,ecx + add eax,r12d + ror r13d,6 + and r15d,edi + xor r14d,ebx + add eax,r13d + xor r15d,ecx + ror r14d,2 + add r8d,eax + add eax,r15d + mov r13d,r8d + add r14d,eax + ror r13d,14 + mov eax,r14d + mov r12d,r9d + ror r14d,9 + xor r13d,r8d + xor r12d,r10d + ror r13d,5 + xor r14d,eax + and r12d,r8d + xor r13d,r8d + add r11d,DWORD[32+rsp] + mov r15d,eax + xor r12d,r10d + ror r14d,11 + xor r15d,ebx + add r11d,r12d + ror r13d,6 + and edi,r15d + xor r14d,eax + add r11d,r13d + xor edi,ebx + ror r14d,2 + add edx,r11d + add r11d,edi + mov r13d,edx + add r14d,r11d + ror r13d,14 + mov r11d,r14d + mov r12d,r8d + ror r14d,9 + xor r13d,edx + xor r12d,r9d + ror r13d,5 + xor r14d,r11d + and r12d,edx + xor r13d,edx + add r10d,DWORD[36+rsp] + mov edi,r11d + xor r12d,r9d + ror r14d,11 + xor edi,eax + add r10d,r12d + ror r13d,6 + and r15d,edi + xor r14d,r11d + add r10d,r13d + xor r15d,eax + ror r14d,2 + add ecx,r10d + add r10d,r15d + mov r13d,ecx + add r14d,r10d + ror r13d,14 + mov r10d,r14d + mov r12d,edx + ror r14d,9 + xor r13d,ecx + xor r12d,r8d + ror r13d,5 + xor r14d,r10d + and r12d,ecx + xor r13d,ecx + add r9d,DWORD[40+rsp] + mov r15d,r10d + xor r12d,r8d + ror r14d,11 + xor r15d,r11d + add r9d,r12d + ror r13d,6 + and edi,r15d + xor r14d,r10d + add r9d,r13d + xor edi,r11d + ror r14d,2 + add ebx,r9d + add r9d,edi + mov r13d,ebx + add r14d,r9d + ror r13d,14 + mov r9d,r14d + mov r12d,ecx + ror r14d,9 + xor r13d,ebx + xor r12d,edx + ror r13d,5 + xor r14d,r9d + and r12d,ebx + xor r13d,ebx + add r8d,DWORD[44+rsp] + mov edi,r9d + xor r12d,edx + ror r14d,11 + xor edi,r10d + add r8d,r12d + ror r13d,6 + and r15d,edi + xor r14d,r9d + add r8d,r13d + xor r15d,r10d + ror r14d,2 + add eax,r8d + add r8d,r15d + mov r13d,eax + add r14d,r8d + ror r13d,14 + mov r8d,r14d + mov r12d,ebx + ror r14d,9 + xor r13d,eax + xor r12d,ecx + ror r13d,5 + xor r14d,r8d + and r12d,eax + xor r13d,eax + add edx,DWORD[48+rsp] + mov r15d,r8d + xor r12d,ecx + ror r14d,11 + xor r15d,r9d + add edx,r12d + ror r13d,6 + and edi,r15d + xor r14d,r8d + add edx,r13d + xor edi,r9d + ror r14d,2 + add r11d,edx + add edx,edi + mov r13d,r11d + add r14d,edx + ror r13d,14 + mov edx,r14d + mov r12d,eax + ror r14d,9 + xor r13d,r11d + xor r12d,ebx + ror r13d,5 + xor r14d,edx + and r12d,r11d + xor r13d,r11d + add ecx,DWORD[52+rsp] + mov edi,edx + xor r12d,ebx + ror r14d,11 + xor edi,r8d + add ecx,r12d + ror r13d,6 + and r15d,edi + xor r14d,edx + add ecx,r13d + xor r15d,r8d + ror r14d,2 + add r10d,ecx + add ecx,r15d + mov r13d,r10d + add r14d,ecx + ror r13d,14 + mov ecx,r14d + mov r12d,r11d + ror r14d,9 + xor r13d,r10d + xor r12d,eax + ror r13d,5 + xor r14d,ecx + and r12d,r10d + xor r13d,r10d + add ebx,DWORD[56+rsp] + mov r15d,ecx + xor r12d,eax + ror r14d,11 + xor r15d,edx + add ebx,r12d + ror r13d,6 + and edi,r15d + xor r14d,ecx + add ebx,r13d + xor edi,edx + ror r14d,2 + add r9d,ebx + add ebx,edi + mov r13d,r9d + add r14d,ebx + ror r13d,14 + mov ebx,r14d + mov r12d,r10d + ror r14d,9 + xor r13d,r9d + xor r12d,r11d + ror r13d,5 + xor r14d,ebx + and r12d,r9d + xor r13d,r9d + add eax,DWORD[60+rsp] + mov edi,ebx + xor r12d,r11d + ror r14d,11 + xor edi,ecx + add eax,r12d + ror r13d,6 + and r15d,edi + xor r14d,ebx + add eax,r13d + xor r15d,ecx + ror r14d,2 + add r8d,eax + add eax,r15d + mov r13d,r8d + add r14d,eax + mov rdi,QWORD[((64+0))+rsp] + mov eax,r14d + + add eax,DWORD[rdi] + lea rsi,[64+rsi] + add ebx,DWORD[4+rdi] + add ecx,DWORD[8+rdi] + add edx,DWORD[12+rdi] + add r8d,DWORD[16+rdi] + add r9d,DWORD[20+rdi] + add r10d,DWORD[24+rdi] + add r11d,DWORD[28+rdi] + + cmp rsi,QWORD[((64+16))+rsp] + + mov DWORD[rdi],eax + mov DWORD[4+rdi],ebx + mov DWORD[8+rdi],ecx + mov DWORD[12+rdi],edx + mov DWORD[16+rdi],r8d + mov DWORD[20+rdi],r9d + mov DWORD[24+rdi],r10d + mov DWORD[28+rdi],r11d + jb NEAR $L$loop_ssse3 + + mov rsi,QWORD[88+rsp] + + movaps xmm6,XMMWORD[((64+32))+rsp] + movaps xmm7,XMMWORD[((64+48))+rsp] + movaps xmm8,XMMWORD[((64+64))+rsp] + movaps xmm9,XMMWORD[((64+80))+rsp] + mov r15,QWORD[((-48))+rsi] + + mov r14,QWORD[((-40))+rsi] + + mov r13,QWORD[((-32))+rsi] + + mov r12,QWORD[((-24))+rsi] + + mov rbp,QWORD[((-16))+rsi] + + mov rbx,QWORD[((-8))+rsi] + + lea rsp,[rsi] + +$L$epilogue_ssse3: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_sha256_block_data_order_ssse3: +global sha256_block_data_order_avx + +ALIGN 64 +sha256_block_data_order_avx: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_sha256_block_data_order_avx: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + + + +_CET_ENDBR + mov rax,rsp + + push rbx + + push rbp + + push r12 + + push r13 + + push r14 + + push r15 + + shl rdx,4 + sub rsp,160 + lea rdx,[rdx*4+rsi] + and rsp,-64 + mov QWORD[((64+0))+rsp],rdi + mov QWORD[((64+8))+rsp],rsi + mov QWORD[((64+16))+rsp],rdx + mov QWORD[88+rsp],rax + + movaps XMMWORD[(64+32)+rsp],xmm6 + movaps XMMWORD[(64+48)+rsp],xmm7 + movaps XMMWORD[(64+64)+rsp],xmm8 + movaps XMMWORD[(64+80)+rsp],xmm9 +$L$prologue_avx: + + vzeroupper + mov eax,DWORD[rdi] + mov ebx,DWORD[4+rdi] + mov ecx,DWORD[8+rdi] + mov edx,DWORD[12+rdi] + mov r8d,DWORD[16+rdi] + mov r9d,DWORD[20+rdi] + mov r10d,DWORD[24+rdi] + mov r11d,DWORD[28+rdi] + vmovdqa xmm8,XMMWORD[((K256+512+32))] + vmovdqa xmm9,XMMWORD[((K256+512+64))] + jmp NEAR $L$loop_avx +ALIGN 16 +$L$loop_avx: + vmovdqa xmm7,XMMWORD[((K256+512))] + vmovdqu xmm0,XMMWORD[rsi] + vmovdqu xmm1,XMMWORD[16+rsi] + vmovdqu xmm2,XMMWORD[32+rsi] + vmovdqu xmm3,XMMWORD[48+rsi] + vpshufb xmm0,xmm0,xmm7 + lea rbp,[K256] + vpshufb xmm1,xmm1,xmm7 + vpshufb xmm2,xmm2,xmm7 + vpaddd xmm4,xmm0,XMMWORD[rbp] + vpshufb xmm3,xmm3,xmm7 + vpaddd xmm5,xmm1,XMMWORD[32+rbp] + vpaddd xmm6,xmm2,XMMWORD[64+rbp] + vpaddd xmm7,xmm3,XMMWORD[96+rbp] + vmovdqa XMMWORD[rsp],xmm4 + mov r14d,eax + vmovdqa XMMWORD[16+rsp],xmm5 + mov edi,ebx + vmovdqa XMMWORD[32+rsp],xmm6 + xor edi,ecx + vmovdqa XMMWORD[48+rsp],xmm7 + mov r13d,r8d + jmp NEAR $L$avx_00_47 + +ALIGN 16 +$L$avx_00_47: + sub rbp,-128 + vpalignr xmm4,xmm1,xmm0,4 + shrd r13d,r13d,14 + mov eax,r14d + mov r12d,r9d + vpalignr xmm7,xmm3,xmm2,4 + shrd r14d,r14d,9 + xor r13d,r8d + xor r12d,r10d + vpsrld xmm6,xmm4,7 + shrd r13d,r13d,5 + xor r14d,eax + and r12d,r8d + vpaddd xmm0,xmm0,xmm7 + xor r13d,r8d + add r11d,DWORD[rsp] + mov r15d,eax + vpsrld xmm7,xmm4,3 + xor r12d,r10d + shrd r14d,r14d,11 + xor r15d,ebx + vpslld xmm5,xmm4,14 + add r11d,r12d + shrd r13d,r13d,6 + and edi,r15d + vpxor xmm4,xmm7,xmm6 + xor r14d,eax + add r11d,r13d + xor edi,ebx + vpshufd xmm7,xmm3,250 + shrd r14d,r14d,2 + add edx,r11d + add r11d,edi + vpsrld xmm6,xmm6,11 + mov r13d,edx + add r14d,r11d + shrd r13d,r13d,14 + vpxor xmm4,xmm4,xmm5 + mov r11d,r14d + mov r12d,r8d + shrd r14d,r14d,9 + vpslld xmm5,xmm5,11 + xor r13d,edx + xor r12d,r9d + shrd r13d,r13d,5 + vpxor xmm4,xmm4,xmm6 + xor r14d,r11d + and r12d,edx + xor r13d,edx + vpsrld xmm6,xmm7,10 + add r10d,DWORD[4+rsp] + mov edi,r11d + xor r12d,r9d + vpxor xmm4,xmm4,xmm5 + shrd r14d,r14d,11 + xor edi,eax + add r10d,r12d + vpsrlq xmm7,xmm7,17 + shrd r13d,r13d,6 + and r15d,edi + xor r14d,r11d + vpaddd xmm0,xmm0,xmm4 + add r10d,r13d + xor r15d,eax + shrd r14d,r14d,2 + vpxor xmm6,xmm6,xmm7 + add ecx,r10d + add r10d,r15d + mov r13d,ecx + vpsrlq xmm7,xmm7,2 + add r14d,r10d + shrd r13d,r13d,14 + mov r10d,r14d + vpxor xmm6,xmm6,xmm7 + mov r12d,edx + shrd r14d,r14d,9 + xor r13d,ecx + vpshufb xmm6,xmm6,xmm8 + xor r12d,r8d + shrd r13d,r13d,5 + xor r14d,r10d + vpaddd xmm0,xmm0,xmm6 + and r12d,ecx + xor r13d,ecx + add r9d,DWORD[8+rsp] + vpshufd xmm7,xmm0,80 + mov r15d,r10d + xor r12d,r8d + shrd r14d,r14d,11 + vpsrld xmm6,xmm7,10 + xor r15d,r11d + add r9d,r12d + shrd r13d,r13d,6 + vpsrlq xmm7,xmm7,17 + and edi,r15d + xor r14d,r10d + add r9d,r13d + vpxor xmm6,xmm6,xmm7 + xor edi,r11d + shrd r14d,r14d,2 + add ebx,r9d + vpsrlq xmm7,xmm7,2 + add r9d,edi + mov r13d,ebx + add r14d,r9d + vpxor xmm6,xmm6,xmm7 + shrd r13d,r13d,14 + mov r9d,r14d + mov r12d,ecx + vpshufb xmm6,xmm6,xmm9 + shrd r14d,r14d,9 + xor r13d,ebx + xor r12d,edx + vpaddd xmm0,xmm0,xmm6 + shrd r13d,r13d,5 + xor r14d,r9d + and r12d,ebx + vpaddd xmm6,xmm0,XMMWORD[rbp] + xor r13d,ebx + add r8d,DWORD[12+rsp] + mov edi,r9d + xor r12d,edx + shrd r14d,r14d,11 + xor edi,r10d + add r8d,r12d + shrd r13d,r13d,6 + and r15d,edi + xor r14d,r9d + add r8d,r13d + xor r15d,r10d + shrd r14d,r14d,2 + add eax,r8d + add r8d,r15d + mov r13d,eax + add r14d,r8d + vmovdqa XMMWORD[rsp],xmm6 + vpalignr xmm4,xmm2,xmm1,4 + shrd r13d,r13d,14 + mov r8d,r14d + mov r12d,ebx + vpalignr xmm7,xmm0,xmm3,4 + shrd r14d,r14d,9 + xor r13d,eax + xor r12d,ecx + vpsrld xmm6,xmm4,7 + shrd r13d,r13d,5 + xor r14d,r8d + and r12d,eax + vpaddd xmm1,xmm1,xmm7 + xor r13d,eax + add edx,DWORD[16+rsp] + mov r15d,r8d + vpsrld xmm7,xmm4,3 + xor r12d,ecx + shrd r14d,r14d,11 + xor r15d,r9d + vpslld xmm5,xmm4,14 + add edx,r12d + shrd r13d,r13d,6 + and edi,r15d + vpxor xmm4,xmm7,xmm6 + xor r14d,r8d + add edx,r13d + xor edi,r9d + vpshufd xmm7,xmm0,250 + shrd r14d,r14d,2 + add r11d,edx + add edx,edi + vpsrld xmm6,xmm6,11 + mov r13d,r11d + add r14d,edx + shrd r13d,r13d,14 + vpxor xmm4,xmm4,xmm5 + mov edx,r14d + mov r12d,eax + shrd r14d,r14d,9 + vpslld xmm5,xmm5,11 + xor r13d,r11d + xor r12d,ebx + shrd r13d,r13d,5 + vpxor xmm4,xmm4,xmm6 + xor r14d,edx + and r12d,r11d + xor r13d,r11d + vpsrld xmm6,xmm7,10 + add ecx,DWORD[20+rsp] + mov edi,edx + xor r12d,ebx + vpxor xmm4,xmm4,xmm5 + shrd r14d,r14d,11 + xor edi,r8d + add ecx,r12d + vpsrlq xmm7,xmm7,17 + shrd r13d,r13d,6 + and r15d,edi + xor r14d,edx + vpaddd xmm1,xmm1,xmm4 + add ecx,r13d + xor r15d,r8d + shrd r14d,r14d,2 + vpxor xmm6,xmm6,xmm7 + add r10d,ecx + add ecx,r15d + mov r13d,r10d + vpsrlq xmm7,xmm7,2 + add r14d,ecx + shrd r13d,r13d,14 + mov ecx,r14d + vpxor xmm6,xmm6,xmm7 + mov r12d,r11d + shrd r14d,r14d,9 + xor r13d,r10d + vpshufb xmm6,xmm6,xmm8 + xor r12d,eax + shrd r13d,r13d,5 + xor r14d,ecx + vpaddd xmm1,xmm1,xmm6 + and r12d,r10d + xor r13d,r10d + add ebx,DWORD[24+rsp] + vpshufd xmm7,xmm1,80 + mov r15d,ecx + xor r12d,eax + shrd r14d,r14d,11 + vpsrld xmm6,xmm7,10 + xor r15d,edx + add ebx,r12d + shrd r13d,r13d,6 + vpsrlq xmm7,xmm7,17 + and edi,r15d + xor r14d,ecx + add ebx,r13d + vpxor xmm6,xmm6,xmm7 + xor edi,edx + shrd r14d,r14d,2 + add r9d,ebx + vpsrlq xmm7,xmm7,2 + add ebx,edi + mov r13d,r9d + add r14d,ebx + vpxor xmm6,xmm6,xmm7 + shrd r13d,r13d,14 + mov ebx,r14d + mov r12d,r10d + vpshufb xmm6,xmm6,xmm9 + shrd r14d,r14d,9 + xor r13d,r9d + xor r12d,r11d + vpaddd xmm1,xmm1,xmm6 + shrd r13d,r13d,5 + xor r14d,ebx + and r12d,r9d + vpaddd xmm6,xmm1,XMMWORD[32+rbp] + xor r13d,r9d + add eax,DWORD[28+rsp] + mov edi,ebx + xor r12d,r11d + shrd r14d,r14d,11 + xor edi,ecx + add eax,r12d + shrd r13d,r13d,6 + and r15d,edi + xor r14d,ebx + add eax,r13d + xor r15d,ecx + shrd r14d,r14d,2 + add r8d,eax + add eax,r15d + mov r13d,r8d + add r14d,eax + vmovdqa XMMWORD[16+rsp],xmm6 + vpalignr xmm4,xmm3,xmm2,4 + shrd r13d,r13d,14 + mov eax,r14d + mov r12d,r9d + vpalignr xmm7,xmm1,xmm0,4 + shrd r14d,r14d,9 + xor r13d,r8d + xor r12d,r10d + vpsrld xmm6,xmm4,7 + shrd r13d,r13d,5 + xor r14d,eax + and r12d,r8d + vpaddd xmm2,xmm2,xmm7 + xor r13d,r8d + add r11d,DWORD[32+rsp] + mov r15d,eax + vpsrld xmm7,xmm4,3 + xor r12d,r10d + shrd r14d,r14d,11 + xor r15d,ebx + vpslld xmm5,xmm4,14 + add r11d,r12d + shrd r13d,r13d,6 + and edi,r15d + vpxor xmm4,xmm7,xmm6 + xor r14d,eax + add r11d,r13d + xor edi,ebx + vpshufd xmm7,xmm1,250 + shrd r14d,r14d,2 + add edx,r11d + add r11d,edi + vpsrld xmm6,xmm6,11 + mov r13d,edx + add r14d,r11d + shrd r13d,r13d,14 + vpxor xmm4,xmm4,xmm5 + mov r11d,r14d + mov r12d,r8d + shrd r14d,r14d,9 + vpslld xmm5,xmm5,11 + xor r13d,edx + xor r12d,r9d + shrd r13d,r13d,5 + vpxor xmm4,xmm4,xmm6 + xor r14d,r11d + and r12d,edx + xor r13d,edx + vpsrld xmm6,xmm7,10 + add r10d,DWORD[36+rsp] + mov edi,r11d + xor r12d,r9d + vpxor xmm4,xmm4,xmm5 + shrd r14d,r14d,11 + xor edi,eax + add r10d,r12d + vpsrlq xmm7,xmm7,17 + shrd r13d,r13d,6 + and r15d,edi + xor r14d,r11d + vpaddd xmm2,xmm2,xmm4 + add r10d,r13d + xor r15d,eax + shrd r14d,r14d,2 + vpxor xmm6,xmm6,xmm7 + add ecx,r10d + add r10d,r15d + mov r13d,ecx + vpsrlq xmm7,xmm7,2 + add r14d,r10d + shrd r13d,r13d,14 + mov r10d,r14d + vpxor xmm6,xmm6,xmm7 + mov r12d,edx + shrd r14d,r14d,9 + xor r13d,ecx + vpshufb xmm6,xmm6,xmm8 + xor r12d,r8d + shrd r13d,r13d,5 + xor r14d,r10d + vpaddd xmm2,xmm2,xmm6 + and r12d,ecx + xor r13d,ecx + add r9d,DWORD[40+rsp] + vpshufd xmm7,xmm2,80 + mov r15d,r10d + xor r12d,r8d + shrd r14d,r14d,11 + vpsrld xmm6,xmm7,10 + xor r15d,r11d + add r9d,r12d + shrd r13d,r13d,6 + vpsrlq xmm7,xmm7,17 + and edi,r15d + xor r14d,r10d + add r9d,r13d + vpxor xmm6,xmm6,xmm7 + xor edi,r11d + shrd r14d,r14d,2 + add ebx,r9d + vpsrlq xmm7,xmm7,2 + add r9d,edi + mov r13d,ebx + add r14d,r9d + vpxor xmm6,xmm6,xmm7 + shrd r13d,r13d,14 + mov r9d,r14d + mov r12d,ecx + vpshufb xmm6,xmm6,xmm9 + shrd r14d,r14d,9 + xor r13d,ebx + xor r12d,edx + vpaddd xmm2,xmm2,xmm6 + shrd r13d,r13d,5 + xor r14d,r9d + and r12d,ebx + vpaddd xmm6,xmm2,XMMWORD[64+rbp] + xor r13d,ebx + add r8d,DWORD[44+rsp] + mov edi,r9d + xor r12d,edx + shrd r14d,r14d,11 + xor edi,r10d + add r8d,r12d + shrd r13d,r13d,6 + and r15d,edi + xor r14d,r9d + add r8d,r13d + xor r15d,r10d + shrd r14d,r14d,2 + add eax,r8d + add r8d,r15d + mov r13d,eax + add r14d,r8d + vmovdqa XMMWORD[32+rsp],xmm6 + vpalignr xmm4,xmm0,xmm3,4 + shrd r13d,r13d,14 + mov r8d,r14d + mov r12d,ebx + vpalignr xmm7,xmm2,xmm1,4 + shrd r14d,r14d,9 + xor r13d,eax + xor r12d,ecx + vpsrld xmm6,xmm4,7 + shrd r13d,r13d,5 + xor r14d,r8d + and r12d,eax + vpaddd xmm3,xmm3,xmm7 + xor r13d,eax + add edx,DWORD[48+rsp] + mov r15d,r8d + vpsrld xmm7,xmm4,3 + xor r12d,ecx + shrd r14d,r14d,11 + xor r15d,r9d + vpslld xmm5,xmm4,14 + add edx,r12d + shrd r13d,r13d,6 + and edi,r15d + vpxor xmm4,xmm7,xmm6 + xor r14d,r8d + add edx,r13d + xor edi,r9d + vpshufd xmm7,xmm2,250 + shrd r14d,r14d,2 + add r11d,edx + add edx,edi + vpsrld xmm6,xmm6,11 + mov r13d,r11d + add r14d,edx + shrd r13d,r13d,14 + vpxor xmm4,xmm4,xmm5 + mov edx,r14d + mov r12d,eax + shrd r14d,r14d,9 + vpslld xmm5,xmm5,11 + xor r13d,r11d + xor r12d,ebx + shrd r13d,r13d,5 + vpxor xmm4,xmm4,xmm6 + xor r14d,edx + and r12d,r11d + xor r13d,r11d + vpsrld xmm6,xmm7,10 + add ecx,DWORD[52+rsp] + mov edi,edx + xor r12d,ebx + vpxor xmm4,xmm4,xmm5 + shrd r14d,r14d,11 + xor edi,r8d + add ecx,r12d + vpsrlq xmm7,xmm7,17 + shrd r13d,r13d,6 + and r15d,edi + xor r14d,edx + vpaddd xmm3,xmm3,xmm4 + add ecx,r13d + xor r15d,r8d + shrd r14d,r14d,2 + vpxor xmm6,xmm6,xmm7 + add r10d,ecx + add ecx,r15d + mov r13d,r10d + vpsrlq xmm7,xmm7,2 + add r14d,ecx + shrd r13d,r13d,14 + mov ecx,r14d + vpxor xmm6,xmm6,xmm7 + mov r12d,r11d + shrd r14d,r14d,9 + xor r13d,r10d + vpshufb xmm6,xmm6,xmm8 + xor r12d,eax + shrd r13d,r13d,5 + xor r14d,ecx + vpaddd xmm3,xmm3,xmm6 + and r12d,r10d + xor r13d,r10d + add ebx,DWORD[56+rsp] + vpshufd xmm7,xmm3,80 + mov r15d,ecx + xor r12d,eax + shrd r14d,r14d,11 + vpsrld xmm6,xmm7,10 + xor r15d,edx + add ebx,r12d + shrd r13d,r13d,6 + vpsrlq xmm7,xmm7,17 + and edi,r15d + xor r14d,ecx + add ebx,r13d + vpxor xmm6,xmm6,xmm7 + xor edi,edx + shrd r14d,r14d,2 + add r9d,ebx + vpsrlq xmm7,xmm7,2 + add ebx,edi + mov r13d,r9d + add r14d,ebx + vpxor xmm6,xmm6,xmm7 + shrd r13d,r13d,14 + mov ebx,r14d + mov r12d,r10d + vpshufb xmm6,xmm6,xmm9 + shrd r14d,r14d,9 + xor r13d,r9d + xor r12d,r11d + vpaddd xmm3,xmm3,xmm6 + shrd r13d,r13d,5 + xor r14d,ebx + and r12d,r9d + vpaddd xmm6,xmm3,XMMWORD[96+rbp] + xor r13d,r9d + add eax,DWORD[60+rsp] + mov edi,ebx + xor r12d,r11d + shrd r14d,r14d,11 + xor edi,ecx + add eax,r12d + shrd r13d,r13d,6 + and r15d,edi + xor r14d,ebx + add eax,r13d + xor r15d,ecx + shrd r14d,r14d,2 + add r8d,eax + add eax,r15d + mov r13d,r8d + add r14d,eax + vmovdqa XMMWORD[48+rsp],xmm6 + cmp BYTE[131+rbp],0 + jne NEAR $L$avx_00_47 + shrd r13d,r13d,14 + mov eax,r14d + mov r12d,r9d + shrd r14d,r14d,9 + xor r13d,r8d + xor r12d,r10d + shrd r13d,r13d,5 + xor r14d,eax + and r12d,r8d + xor r13d,r8d + add r11d,DWORD[rsp] + mov r15d,eax + xor r12d,r10d + shrd r14d,r14d,11 + xor r15d,ebx + add r11d,r12d + shrd r13d,r13d,6 + and edi,r15d + xor r14d,eax + add r11d,r13d + xor edi,ebx + shrd r14d,r14d,2 + add edx,r11d + add r11d,edi + mov r13d,edx + add r14d,r11d + shrd r13d,r13d,14 + mov r11d,r14d + mov r12d,r8d + shrd r14d,r14d,9 + xor r13d,edx + xor r12d,r9d + shrd r13d,r13d,5 + xor r14d,r11d + and r12d,edx + xor r13d,edx + add r10d,DWORD[4+rsp] + mov edi,r11d + xor r12d,r9d + shrd r14d,r14d,11 + xor edi,eax + add r10d,r12d + shrd r13d,r13d,6 + and r15d,edi + xor r14d,r11d + add r10d,r13d + xor r15d,eax + shrd r14d,r14d,2 + add ecx,r10d + add r10d,r15d + mov r13d,ecx + add r14d,r10d + shrd r13d,r13d,14 + mov r10d,r14d + mov r12d,edx + shrd r14d,r14d,9 + xor r13d,ecx + xor r12d,r8d + shrd r13d,r13d,5 + xor r14d,r10d + and r12d,ecx + xor r13d,ecx + add r9d,DWORD[8+rsp] + mov r15d,r10d + xor r12d,r8d + shrd r14d,r14d,11 + xor r15d,r11d + add r9d,r12d + shrd r13d,r13d,6 + and edi,r15d + xor r14d,r10d + add r9d,r13d + xor edi,r11d + shrd r14d,r14d,2 + add ebx,r9d + add r9d,edi + mov r13d,ebx + add r14d,r9d + shrd r13d,r13d,14 + mov r9d,r14d + mov r12d,ecx + shrd r14d,r14d,9 + xor r13d,ebx + xor r12d,edx + shrd r13d,r13d,5 + xor r14d,r9d + and r12d,ebx + xor r13d,ebx + add r8d,DWORD[12+rsp] + mov edi,r9d + xor r12d,edx + shrd r14d,r14d,11 + xor edi,r10d + add r8d,r12d + shrd r13d,r13d,6 + and r15d,edi + xor r14d,r9d + add r8d,r13d + xor r15d,r10d + shrd r14d,r14d,2 + add eax,r8d + add r8d,r15d + mov r13d,eax + add r14d,r8d + shrd r13d,r13d,14 + mov r8d,r14d + mov r12d,ebx + shrd r14d,r14d,9 + xor r13d,eax + xor r12d,ecx + shrd r13d,r13d,5 + xor r14d,r8d + and r12d,eax + xor r13d,eax + add edx,DWORD[16+rsp] + mov r15d,r8d + xor r12d,ecx + shrd r14d,r14d,11 + xor r15d,r9d + add edx,r12d + shrd r13d,r13d,6 + and edi,r15d + xor r14d,r8d + add edx,r13d + xor edi,r9d + shrd r14d,r14d,2 + add r11d,edx + add edx,edi + mov r13d,r11d + add r14d,edx + shrd r13d,r13d,14 + mov edx,r14d + mov r12d,eax + shrd r14d,r14d,9 + xor r13d,r11d + xor r12d,ebx + shrd r13d,r13d,5 + xor r14d,edx + and r12d,r11d + xor r13d,r11d + add ecx,DWORD[20+rsp] + mov edi,edx + xor r12d,ebx + shrd r14d,r14d,11 + xor edi,r8d + add ecx,r12d + shrd r13d,r13d,6 + and r15d,edi + xor r14d,edx + add ecx,r13d + xor r15d,r8d + shrd r14d,r14d,2 + add r10d,ecx + add ecx,r15d + mov r13d,r10d + add r14d,ecx + shrd r13d,r13d,14 + mov ecx,r14d + mov r12d,r11d + shrd r14d,r14d,9 + xor r13d,r10d + xor r12d,eax + shrd r13d,r13d,5 + xor r14d,ecx + and r12d,r10d + xor r13d,r10d + add ebx,DWORD[24+rsp] + mov r15d,ecx + xor r12d,eax + shrd r14d,r14d,11 + xor r15d,edx + add ebx,r12d + shrd r13d,r13d,6 + and edi,r15d + xor r14d,ecx + add ebx,r13d + xor edi,edx + shrd r14d,r14d,2 + add r9d,ebx + add ebx,edi + mov r13d,r9d + add r14d,ebx + shrd r13d,r13d,14 + mov ebx,r14d + mov r12d,r10d + shrd r14d,r14d,9 + xor r13d,r9d + xor r12d,r11d + shrd r13d,r13d,5 + xor r14d,ebx + and r12d,r9d + xor r13d,r9d + add eax,DWORD[28+rsp] + mov edi,ebx + xor r12d,r11d + shrd r14d,r14d,11 + xor edi,ecx + add eax,r12d + shrd r13d,r13d,6 + and r15d,edi + xor r14d,ebx + add eax,r13d + xor r15d,ecx + shrd r14d,r14d,2 + add r8d,eax + add eax,r15d + mov r13d,r8d + add r14d,eax + shrd r13d,r13d,14 + mov eax,r14d + mov r12d,r9d + shrd r14d,r14d,9 + xor r13d,r8d + xor r12d,r10d + shrd r13d,r13d,5 + xor r14d,eax + and r12d,r8d + xor r13d,r8d + add r11d,DWORD[32+rsp] + mov r15d,eax + xor r12d,r10d + shrd r14d,r14d,11 + xor r15d,ebx + add r11d,r12d + shrd r13d,r13d,6 + and edi,r15d + xor r14d,eax + add r11d,r13d + xor edi,ebx + shrd r14d,r14d,2 + add edx,r11d + add r11d,edi + mov r13d,edx + add r14d,r11d + shrd r13d,r13d,14 + mov r11d,r14d + mov r12d,r8d + shrd r14d,r14d,9 + xor r13d,edx + xor r12d,r9d + shrd r13d,r13d,5 + xor r14d,r11d + and r12d,edx + xor r13d,edx + add r10d,DWORD[36+rsp] + mov edi,r11d + xor r12d,r9d + shrd r14d,r14d,11 + xor edi,eax + add r10d,r12d + shrd r13d,r13d,6 + and r15d,edi + xor r14d,r11d + add r10d,r13d + xor r15d,eax + shrd r14d,r14d,2 + add ecx,r10d + add r10d,r15d + mov r13d,ecx + add r14d,r10d + shrd r13d,r13d,14 + mov r10d,r14d + mov r12d,edx + shrd r14d,r14d,9 + xor r13d,ecx + xor r12d,r8d + shrd r13d,r13d,5 + xor r14d,r10d + and r12d,ecx + xor r13d,ecx + add r9d,DWORD[40+rsp] + mov r15d,r10d + xor r12d,r8d + shrd r14d,r14d,11 + xor r15d,r11d + add r9d,r12d + shrd r13d,r13d,6 + and edi,r15d + xor r14d,r10d + add r9d,r13d + xor edi,r11d + shrd r14d,r14d,2 + add ebx,r9d + add r9d,edi + mov r13d,ebx + add r14d,r9d + shrd r13d,r13d,14 + mov r9d,r14d + mov r12d,ecx + shrd r14d,r14d,9 + xor r13d,ebx + xor r12d,edx + shrd r13d,r13d,5 + xor r14d,r9d + and r12d,ebx + xor r13d,ebx + add r8d,DWORD[44+rsp] + mov edi,r9d + xor r12d,edx + shrd r14d,r14d,11 + xor edi,r10d + add r8d,r12d + shrd r13d,r13d,6 + and r15d,edi + xor r14d,r9d + add r8d,r13d + xor r15d,r10d + shrd r14d,r14d,2 + add eax,r8d + add r8d,r15d + mov r13d,eax + add r14d,r8d + shrd r13d,r13d,14 + mov r8d,r14d + mov r12d,ebx + shrd r14d,r14d,9 + xor r13d,eax + xor r12d,ecx + shrd r13d,r13d,5 + xor r14d,r8d + and r12d,eax + xor r13d,eax + add edx,DWORD[48+rsp] + mov r15d,r8d + xor r12d,ecx + shrd r14d,r14d,11 + xor r15d,r9d + add edx,r12d + shrd r13d,r13d,6 + and edi,r15d + xor r14d,r8d + add edx,r13d + xor edi,r9d + shrd r14d,r14d,2 + add r11d,edx + add edx,edi + mov r13d,r11d + add r14d,edx + shrd r13d,r13d,14 + mov edx,r14d + mov r12d,eax + shrd r14d,r14d,9 + xor r13d,r11d + xor r12d,ebx + shrd r13d,r13d,5 + xor r14d,edx + and r12d,r11d + xor r13d,r11d + add ecx,DWORD[52+rsp] + mov edi,edx + xor r12d,ebx + shrd r14d,r14d,11 + xor edi,r8d + add ecx,r12d + shrd r13d,r13d,6 + and r15d,edi + xor r14d,edx + add ecx,r13d + xor r15d,r8d + shrd r14d,r14d,2 + add r10d,ecx + add ecx,r15d + mov r13d,r10d + add r14d,ecx + shrd r13d,r13d,14 + mov ecx,r14d + mov r12d,r11d + shrd r14d,r14d,9 + xor r13d,r10d + xor r12d,eax + shrd r13d,r13d,5 + xor r14d,ecx + and r12d,r10d + xor r13d,r10d + add ebx,DWORD[56+rsp] + mov r15d,ecx + xor r12d,eax + shrd r14d,r14d,11 + xor r15d,edx + add ebx,r12d + shrd r13d,r13d,6 + and edi,r15d + xor r14d,ecx + add ebx,r13d + xor edi,edx + shrd r14d,r14d,2 + add r9d,ebx + add ebx,edi + mov r13d,r9d + add r14d,ebx + shrd r13d,r13d,14 + mov ebx,r14d + mov r12d,r10d + shrd r14d,r14d,9 + xor r13d,r9d + xor r12d,r11d + shrd r13d,r13d,5 + xor r14d,ebx + and r12d,r9d + xor r13d,r9d + add eax,DWORD[60+rsp] + mov edi,ebx + xor r12d,r11d + shrd r14d,r14d,11 + xor edi,ecx + add eax,r12d + shrd r13d,r13d,6 + and r15d,edi + xor r14d,ebx + add eax,r13d + xor r15d,ecx + shrd r14d,r14d,2 + add r8d,eax + add eax,r15d + mov r13d,r8d + add r14d,eax + mov rdi,QWORD[((64+0))+rsp] + mov eax,r14d + + add eax,DWORD[rdi] + lea rsi,[64+rsi] + add ebx,DWORD[4+rdi] + add ecx,DWORD[8+rdi] + add edx,DWORD[12+rdi] + add r8d,DWORD[16+rdi] + add r9d,DWORD[20+rdi] + add r10d,DWORD[24+rdi] + add r11d,DWORD[28+rdi] + + cmp rsi,QWORD[((64+16))+rsp] + + mov DWORD[rdi],eax + mov DWORD[4+rdi],ebx + mov DWORD[8+rdi],ecx + mov DWORD[12+rdi],edx + mov DWORD[16+rdi],r8d + mov DWORD[20+rdi],r9d + mov DWORD[24+rdi],r10d + mov DWORD[28+rdi],r11d + jb NEAR $L$loop_avx + + mov rsi,QWORD[88+rsp] + + vzeroupper + movaps xmm6,XMMWORD[((64+32))+rsp] + movaps xmm7,XMMWORD[((64+48))+rsp] + movaps xmm8,XMMWORD[((64+64))+rsp] + movaps xmm9,XMMWORD[((64+80))+rsp] + mov r15,QWORD[((-48))+rsi] + + mov r14,QWORD[((-40))+rsi] + + mov r13,QWORD[((-32))+rsi] + + mov r12,QWORD[((-24))+rsi] + + mov rbp,QWORD[((-16))+rsi] + + mov rbx,QWORD[((-8))+rsi] + + lea rsp,[rsi] + +$L$epilogue_avx: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_sha256_block_data_order_avx: +EXTERN __imp_RtlVirtualUnwind + +ALIGN 16 +se_handler: + push rsi + push rdi + push rbx + push rbp + push r12 + push r13 + push r14 + push r15 + pushfq + sub rsp,64 + + mov rax,QWORD[120+r8] + mov rbx,QWORD[248+r8] + + mov rsi,QWORD[8+r9] + mov r11,QWORD[56+r9] + + mov r10d,DWORD[r11] + lea r10,[r10*1+rsi] + cmp rbx,r10 + jb NEAR $L$in_prologue + + mov rax,QWORD[152+r8] + + mov r10d,DWORD[4+r11] + lea r10,[r10*1+rsi] + cmp rbx,r10 + jae NEAR $L$in_prologue + mov rsi,rax + mov rax,QWORD[((64+24))+rax] + + mov rbx,QWORD[((-8))+rax] + mov rbp,QWORD[((-16))+rax] + mov r12,QWORD[((-24))+rax] + mov r13,QWORD[((-32))+rax] + mov r14,QWORD[((-40))+rax] + mov r15,QWORD[((-48))+rax] + mov QWORD[144+r8],rbx + mov QWORD[160+r8],rbp + mov QWORD[216+r8],r12 + mov QWORD[224+r8],r13 + mov QWORD[232+r8],r14 + mov QWORD[240+r8],r15 + + lea r10,[$L$epilogue] + cmp rbx,r10 + jb NEAR $L$in_prologue + + lea rsi,[((64+32))+rsi] + lea rdi,[512+r8] + mov ecx,8 + DD 0xa548f3fc + +$L$in_prologue: + mov rdi,QWORD[8+rax] + mov rsi,QWORD[16+rax] + mov QWORD[152+r8],rax + mov QWORD[168+r8],rsi + mov QWORD[176+r8],rdi + + mov rdi,QWORD[40+r9] + mov rsi,r8 + mov ecx,154 + DD 0xa548f3fc + + mov rsi,r9 + xor rcx,rcx + mov rdx,QWORD[8+rsi] + mov r8,QWORD[rsi] + mov r9,QWORD[16+rsi] + mov r10,QWORD[40+rsi] + lea r11,[56+rsi] + lea r12,[24+rsi] + mov QWORD[32+rsp],r10 + mov QWORD[40+rsp],r11 + mov QWORD[48+rsp],r12 + mov QWORD[56+rsp],rcx + call QWORD[__imp_RtlVirtualUnwind] + + mov eax,1 + add rsp,64 + popfq + pop r15 + pop r14 + pop r13 + pop r12 + pop rbp + pop rbx + pop rdi + pop rsi + ret + + +ALIGN 16 +shaext_handler: + push rsi + push rdi + push rbx + push rbp + push r12 + push r13 + push r14 + push r15 + pushfq + sub rsp,64 + + mov rax,QWORD[120+r8] + mov rbx,QWORD[248+r8] + + lea r10,[$L$prologue_shaext] + cmp rbx,r10 + jb NEAR $L$in_prologue + + lea r10,[$L$epilogue_shaext] + cmp rbx,r10 + jae NEAR $L$in_prologue + + lea rsi,[((-8-80))+rax] + lea rdi,[512+r8] + mov ecx,10 + DD 0xa548f3fc + + jmp NEAR $L$in_prologue + +section .pdata rdata align=4 +ALIGN 4 + DD $L$SEH_begin_sha256_block_data_order_nohw wrt ..imagebase + DD $L$SEH_end_sha256_block_data_order_nohw wrt ..imagebase + DD $L$SEH_info_sha256_block_data_order_nohw wrt ..imagebase + DD $L$SEH_begin_sha256_block_data_order_hw wrt ..imagebase + DD $L$SEH_end_sha256_block_data_order_hw wrt ..imagebase + DD $L$SEH_info_sha256_block_data_order_hw wrt ..imagebase + DD $L$SEH_begin_sha256_block_data_order_ssse3 wrt ..imagebase + DD $L$SEH_end_sha256_block_data_order_ssse3 wrt ..imagebase + DD $L$SEH_info_sha256_block_data_order_ssse3 wrt ..imagebase + DD $L$SEH_begin_sha256_block_data_order_avx wrt ..imagebase + DD $L$SEH_end_sha256_block_data_order_avx wrt ..imagebase + DD $L$SEH_info_sha256_block_data_order_avx wrt ..imagebase +section .xdata rdata align=8 +ALIGN 8 +$L$SEH_info_sha256_block_data_order_nohw: + DB 9,0,0,0 + DD se_handler wrt ..imagebase + DD $L$prologue wrt ..imagebase,$L$epilogue wrt ..imagebase +$L$SEH_info_sha256_block_data_order_hw: + DB 9,0,0,0 + DD shaext_handler wrt ..imagebase +$L$SEH_info_sha256_block_data_order_ssse3: + DB 9,0,0,0 + DD se_handler wrt ..imagebase + DD $L$prologue_ssse3 wrt ..imagebase,$L$epilogue_ssse3 wrt ..imagebase +$L$SEH_info_sha256_block_data_order_avx: + DB 9,0,0,0 + DD se_handler wrt ..imagebase + DD $L$prologue_avx wrt ..imagebase,$L$epilogue_avx wrt ..imagebase +%else +; Work around https://bugzilla.nasm.us/show_bug.cgi?id=3392738 +ret +%endif diff --git a/http/vendor/ring/pregenerated/sha256-x86_64-nasm.o b/http/vendor/ring/pregenerated/sha256-x86_64-nasm.o new file mode 100644 index 0000000..fcd5723 Binary files /dev/null and b/http/vendor/ring/pregenerated/sha256-x86_64-nasm.o differ diff --git a/http/vendor/ring/pregenerated/sha512-armv4-linux32.S b/http/vendor/ring/pregenerated/sha512-armv4-linux32.S new file mode 100644 index 0000000..9150b0f --- /dev/null +++ b/http/vendor/ring/pregenerated/sha512-armv4-linux32.S @@ -0,0 +1,1857 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_ARM) && defined(__ELF__) +@ Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved. +@ +@ Licensed under the Apache License, Version 2.0 (the "License"); +@ you may not use this file except in compliance with the License. +@ You may obtain a copy of the License at +@ +@ https://www.apache.org/licenses/LICENSE-2.0 +@ +@ Unless required by applicable law or agreed to in writing, software +@ distributed under the License is distributed on an "AS IS" BASIS, +@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@ See the License for the specific language governing permissions and +@ limitations under the License. + + +@ ==================================================================== +@ Written by Andy Polyakov for the OpenSSL +@ project. +@ ==================================================================== + +@ SHA512 block procedure for ARMv4. September 2007. + +@ This code is ~4.5 (four and a half) times faster than code generated +@ by gcc 3.4 and it spends ~72 clock cycles per byte [on single-issue +@ Xscale PXA250 core]. +@ +@ July 2010. +@ +@ Rescheduling for dual-issue pipeline resulted in 6% improvement on +@ Cortex A8 core and ~40 cycles per processed byte. + +@ February 2011. +@ +@ Profiler-assisted and platform-specific optimization resulted in 7% +@ improvement on Coxtex A8 core and ~38 cycles per byte. + +@ March 2011. +@ +@ Add NEON implementation. On Cortex A8 it was measured to process +@ one byte in 23.3 cycles or ~60% faster than integer-only code. + +@ August 2012. +@ +@ Improve NEON performance by 12% on Snapdragon S4. In absolute +@ terms it's 22.6 cycles per byte, which is disappointing result. +@ Technical writers asserted that 3-way S4 pipeline can sustain +@ multiple NEON instructions per cycle, but dual NEON issue could +@ not be observed, see http://www.openssl.org/~appro/Snapdragon-S4.html +@ for further details. On side note Cortex-A15 processes one byte in +@ 16 cycles. + +@ Byte order [in]dependence. ========================================= +@ +@ Originally caller was expected to maintain specific *dword* order in +@ h[0-7], namely with most significant dword at *lower* address, which +@ was reflected in below two parameters as 0 and 4. Now caller is +@ expected to maintain native byte order for whole 64-bit values. +#ifndef __KERNEL__ +# define VFP_ABI_PUSH vstmdb sp!,{d8-d15} +# define VFP_ABI_POP vldmia sp!,{d8-d15} +#else +# define __ARM_MAX_ARCH__ 7 +# define VFP_ABI_PUSH +# define VFP_ABI_POP +#endif + +@ Silence ARMv8 deprecated IT instruction warnings. This file is used by both +@ ARMv7 and ARMv8 processors and does not use ARMv8 instructions. +.arch armv7-a + +#ifdef __ARMEL__ +# define LO 0 +# define HI 4 +# define WORD64(hi0,lo0,hi1,lo1) .word lo0,hi0, lo1,hi1 +#else +# define HI 0 +# define LO 4 +# define WORD64(hi0,lo0,hi1,lo1) .word hi0,lo0, hi1,lo1 +#endif + +.text +#if defined(__thumb2__) +.syntax unified +.thumb +# define adrl adr +#else +.code 32 +#endif + +.type K512,%object +.align 5 +K512: + WORD64(0x428a2f98,0xd728ae22, 0x71374491,0x23ef65cd) + WORD64(0xb5c0fbcf,0xec4d3b2f, 0xe9b5dba5,0x8189dbbc) + WORD64(0x3956c25b,0xf348b538, 0x59f111f1,0xb605d019) + WORD64(0x923f82a4,0xaf194f9b, 0xab1c5ed5,0xda6d8118) + WORD64(0xd807aa98,0xa3030242, 0x12835b01,0x45706fbe) + WORD64(0x243185be,0x4ee4b28c, 0x550c7dc3,0xd5ffb4e2) + WORD64(0x72be5d74,0xf27b896f, 0x80deb1fe,0x3b1696b1) + WORD64(0x9bdc06a7,0x25c71235, 0xc19bf174,0xcf692694) + WORD64(0xe49b69c1,0x9ef14ad2, 0xefbe4786,0x384f25e3) + WORD64(0x0fc19dc6,0x8b8cd5b5, 0x240ca1cc,0x77ac9c65) + WORD64(0x2de92c6f,0x592b0275, 0x4a7484aa,0x6ea6e483) + WORD64(0x5cb0a9dc,0xbd41fbd4, 0x76f988da,0x831153b5) + WORD64(0x983e5152,0xee66dfab, 0xa831c66d,0x2db43210) + WORD64(0xb00327c8,0x98fb213f, 0xbf597fc7,0xbeef0ee4) + WORD64(0xc6e00bf3,0x3da88fc2, 0xd5a79147,0x930aa725) + WORD64(0x06ca6351,0xe003826f, 0x14292967,0x0a0e6e70) + WORD64(0x27b70a85,0x46d22ffc, 0x2e1b2138,0x5c26c926) + WORD64(0x4d2c6dfc,0x5ac42aed, 0x53380d13,0x9d95b3df) + WORD64(0x650a7354,0x8baf63de, 0x766a0abb,0x3c77b2a8) + WORD64(0x81c2c92e,0x47edaee6, 0x92722c85,0x1482353b) + WORD64(0xa2bfe8a1,0x4cf10364, 0xa81a664b,0xbc423001) + WORD64(0xc24b8b70,0xd0f89791, 0xc76c51a3,0x0654be30) + WORD64(0xd192e819,0xd6ef5218, 0xd6990624,0x5565a910) + WORD64(0xf40e3585,0x5771202a, 0x106aa070,0x32bbd1b8) + WORD64(0x19a4c116,0xb8d2d0c8, 0x1e376c08,0x5141ab53) + WORD64(0x2748774c,0xdf8eeb99, 0x34b0bcb5,0xe19b48a8) + WORD64(0x391c0cb3,0xc5c95a63, 0x4ed8aa4a,0xe3418acb) + WORD64(0x5b9cca4f,0x7763e373, 0x682e6ff3,0xd6b2b8a3) + WORD64(0x748f82ee,0x5defb2fc, 0x78a5636f,0x43172f60) + WORD64(0x84c87814,0xa1f0ab72, 0x8cc70208,0x1a6439ec) + WORD64(0x90befffa,0x23631e28, 0xa4506ceb,0xde82bde9) + WORD64(0xbef9a3f7,0xb2c67915, 0xc67178f2,0xe372532b) + WORD64(0xca273ece,0xea26619c, 0xd186b8c7,0x21c0c207) + WORD64(0xeada7dd6,0xcde0eb1e, 0xf57d4f7f,0xee6ed178) + WORD64(0x06f067aa,0x72176fba, 0x0a637dc5,0xa2c898a6) + WORD64(0x113f9804,0xbef90dae, 0x1b710b35,0x131c471b) + WORD64(0x28db77f5,0x23047d84, 0x32caab7b,0x40c72493) + WORD64(0x3c9ebe0a,0x15c9bebc, 0x431d67c4,0x9c100d4c) + WORD64(0x4cc5d4be,0xcb3e42b6, 0x597f299c,0xfc657e2a) + WORD64(0x5fcb6fab,0x3ad6faec, 0x6c44198c,0x4a475817) +.size K512,.-K512 + +.globl sha512_block_data_order_nohw +.hidden sha512_block_data_order_nohw +.type sha512_block_data_order_nohw,%function +sha512_block_data_order_nohw: + add r2,r1,r2,lsl#7 @ len to point at the end of inp + stmdb sp!,{r4,r5,r6,r7,r8,r9,r10,r11,r12,lr} + adr r14,K512 + sub sp,sp,#9*8 + + ldr r7,[r0,#32+LO] + ldr r8,[r0,#32+HI] + ldr r9, [r0,#48+LO] + ldr r10, [r0,#48+HI] + ldr r11, [r0,#56+LO] + ldr r12, [r0,#56+HI] +.Loop: + str r9, [sp,#48+0] + str r10, [sp,#48+4] + str r11, [sp,#56+0] + str r12, [sp,#56+4] + ldr r5,[r0,#0+LO] + ldr r6,[r0,#0+HI] + ldr r3,[r0,#8+LO] + ldr r4,[r0,#8+HI] + ldr r9, [r0,#16+LO] + ldr r10, [r0,#16+HI] + ldr r11, [r0,#24+LO] + ldr r12, [r0,#24+HI] + str r3,[sp,#8+0] + str r4,[sp,#8+4] + str r9, [sp,#16+0] + str r10, [sp,#16+4] + str r11, [sp,#24+0] + str r12, [sp,#24+4] + ldr r3,[r0,#40+LO] + ldr r4,[r0,#40+HI] + str r3,[sp,#40+0] + str r4,[sp,#40+4] + +.L00_15: +#if __ARM_ARCH<7 + ldrb r3,[r1,#7] + ldrb r9, [r1,#6] + ldrb r10, [r1,#5] + ldrb r11, [r1,#4] + ldrb r4,[r1,#3] + ldrb r12, [r1,#2] + orr r3,r3,r9,lsl#8 + ldrb r9, [r1,#1] + orr r3,r3,r10,lsl#16 + ldrb r10, [r1],#8 + orr r3,r3,r11,lsl#24 + orr r4,r4,r12,lsl#8 + orr r4,r4,r9,lsl#16 + orr r4,r4,r10,lsl#24 +#else + ldr r3,[r1,#4] + ldr r4,[r1],#8 +#ifdef __ARMEL__ + rev r3,r3 + rev r4,r4 +#endif +#endif + @ Sigma1(x) (ROTR((x),14) ^ ROTR((x),18) ^ ROTR((x),41)) + @ LO lo>>14^hi<<18 ^ lo>>18^hi<<14 ^ hi>>9^lo<<23 + @ HI hi>>14^lo<<18 ^ hi>>18^lo<<14 ^ lo>>9^hi<<23 + mov r9,r7,lsr#14 + str r3,[sp,#64+0] + mov r10,r8,lsr#14 + str r4,[sp,#64+4] + eor r9,r9,r8,lsl#18 + ldr r11,[sp,#56+0] @ h.lo + eor r10,r10,r7,lsl#18 + ldr r12,[sp,#56+4] @ h.hi + eor r9,r9,r7,lsr#18 + eor r10,r10,r8,lsr#18 + eor r9,r9,r8,lsl#14 + eor r10,r10,r7,lsl#14 + eor r9,r9,r8,lsr#9 + eor r10,r10,r7,lsr#9 + eor r9,r9,r7,lsl#23 + eor r10,r10,r8,lsl#23 @ Sigma1(e) + adds r3,r3,r9 + ldr r9,[sp,#40+0] @ f.lo + adc r4,r4,r10 @ T += Sigma1(e) + ldr r10,[sp,#40+4] @ f.hi + adds r3,r3,r11 + ldr r11,[sp,#48+0] @ g.lo + adc r4,r4,r12 @ T += h + ldr r12,[sp,#48+4] @ g.hi + + eor r9,r9,r11 + str r7,[sp,#32+0] + eor r10,r10,r12 + str r8,[sp,#32+4] + and r9,r9,r7 + str r5,[sp,#0+0] + and r10,r10,r8 + str r6,[sp,#0+4] + eor r9,r9,r11 + ldr r11,[r14,#LO] @ K[i].lo + eor r10,r10,r12 @ Ch(e,f,g) + ldr r12,[r14,#HI] @ K[i].hi + + adds r3,r3,r9 + ldr r7,[sp,#24+0] @ d.lo + adc r4,r4,r10 @ T += Ch(e,f,g) + ldr r8,[sp,#24+4] @ d.hi + adds r3,r3,r11 + and r9,r11,#0xff + adc r4,r4,r12 @ T += K[i] + adds r7,r7,r3 + ldr r11,[sp,#8+0] @ b.lo + adc r8,r8,r4 @ d += T + teq r9,#148 + + ldr r12,[sp,#16+0] @ c.lo +#if __ARM_ARCH>=7 + it eq @ Thumb2 thing, sanity check in ARM +#endif + orreq r14,r14,#1 + @ Sigma0(x) (ROTR((x),28) ^ ROTR((x),34) ^ ROTR((x),39)) + @ LO lo>>28^hi<<4 ^ hi>>2^lo<<30 ^ hi>>7^lo<<25 + @ HI hi>>28^lo<<4 ^ lo>>2^hi<<30 ^ lo>>7^hi<<25 + mov r9,r5,lsr#28 + mov r10,r6,lsr#28 + eor r9,r9,r6,lsl#4 + eor r10,r10,r5,lsl#4 + eor r9,r9,r6,lsr#2 + eor r10,r10,r5,lsr#2 + eor r9,r9,r5,lsl#30 + eor r10,r10,r6,lsl#30 + eor r9,r9,r6,lsr#7 + eor r10,r10,r5,lsr#7 + eor r9,r9,r5,lsl#25 + eor r10,r10,r6,lsl#25 @ Sigma0(a) + adds r3,r3,r9 + and r9,r5,r11 + adc r4,r4,r10 @ T += Sigma0(a) + + ldr r10,[sp,#8+4] @ b.hi + orr r5,r5,r11 + ldr r11,[sp,#16+4] @ c.hi + and r5,r5,r12 + and r12,r6,r10 + orr r6,r6,r10 + orr r5,r5,r9 @ Maj(a,b,c).lo + and r6,r6,r11 + adds r5,r5,r3 + orr r6,r6,r12 @ Maj(a,b,c).hi + sub sp,sp,#8 + adc r6,r6,r4 @ h += T + tst r14,#1 + add r14,r14,#8 + tst r14,#1 + beq .L00_15 + ldr r9,[sp,#184+0] + ldr r10,[sp,#184+4] + bic r14,r14,#1 +.L16_79: + @ sigma0(x) (ROTR((x),1) ^ ROTR((x),8) ^ ((x)>>7)) + @ LO lo>>1^hi<<31 ^ lo>>8^hi<<24 ^ lo>>7^hi<<25 + @ HI hi>>1^lo<<31 ^ hi>>8^lo<<24 ^ hi>>7 + mov r3,r9,lsr#1 + ldr r11,[sp,#80+0] + mov r4,r10,lsr#1 + ldr r12,[sp,#80+4] + eor r3,r3,r10,lsl#31 + eor r4,r4,r9,lsl#31 + eor r3,r3,r9,lsr#8 + eor r4,r4,r10,lsr#8 + eor r3,r3,r10,lsl#24 + eor r4,r4,r9,lsl#24 + eor r3,r3,r9,lsr#7 + eor r4,r4,r10,lsr#7 + eor r3,r3,r10,lsl#25 + + @ sigma1(x) (ROTR((x),19) ^ ROTR((x),61) ^ ((x)>>6)) + @ LO lo>>19^hi<<13 ^ hi>>29^lo<<3 ^ lo>>6^hi<<26 + @ HI hi>>19^lo<<13 ^ lo>>29^hi<<3 ^ hi>>6 + mov r9,r11,lsr#19 + mov r10,r12,lsr#19 + eor r9,r9,r12,lsl#13 + eor r10,r10,r11,lsl#13 + eor r9,r9,r12,lsr#29 + eor r10,r10,r11,lsr#29 + eor r9,r9,r11,lsl#3 + eor r10,r10,r12,lsl#3 + eor r9,r9,r11,lsr#6 + eor r10,r10,r12,lsr#6 + ldr r11,[sp,#120+0] + eor r9,r9,r12,lsl#26 + + ldr r12,[sp,#120+4] + adds r3,r3,r9 + ldr r9,[sp,#192+0] + adc r4,r4,r10 + + ldr r10,[sp,#192+4] + adds r3,r3,r11 + adc r4,r4,r12 + adds r3,r3,r9 + adc r4,r4,r10 + @ Sigma1(x) (ROTR((x),14) ^ ROTR((x),18) ^ ROTR((x),41)) + @ LO lo>>14^hi<<18 ^ lo>>18^hi<<14 ^ hi>>9^lo<<23 + @ HI hi>>14^lo<<18 ^ hi>>18^lo<<14 ^ lo>>9^hi<<23 + mov r9,r7,lsr#14 + str r3,[sp,#64+0] + mov r10,r8,lsr#14 + str r4,[sp,#64+4] + eor r9,r9,r8,lsl#18 + ldr r11,[sp,#56+0] @ h.lo + eor r10,r10,r7,lsl#18 + ldr r12,[sp,#56+4] @ h.hi + eor r9,r9,r7,lsr#18 + eor r10,r10,r8,lsr#18 + eor r9,r9,r8,lsl#14 + eor r10,r10,r7,lsl#14 + eor r9,r9,r8,lsr#9 + eor r10,r10,r7,lsr#9 + eor r9,r9,r7,lsl#23 + eor r10,r10,r8,lsl#23 @ Sigma1(e) + adds r3,r3,r9 + ldr r9,[sp,#40+0] @ f.lo + adc r4,r4,r10 @ T += Sigma1(e) + ldr r10,[sp,#40+4] @ f.hi + adds r3,r3,r11 + ldr r11,[sp,#48+0] @ g.lo + adc r4,r4,r12 @ T += h + ldr r12,[sp,#48+4] @ g.hi + + eor r9,r9,r11 + str r7,[sp,#32+0] + eor r10,r10,r12 + str r8,[sp,#32+4] + and r9,r9,r7 + str r5,[sp,#0+0] + and r10,r10,r8 + str r6,[sp,#0+4] + eor r9,r9,r11 + ldr r11,[r14,#LO] @ K[i].lo + eor r10,r10,r12 @ Ch(e,f,g) + ldr r12,[r14,#HI] @ K[i].hi + + adds r3,r3,r9 + ldr r7,[sp,#24+0] @ d.lo + adc r4,r4,r10 @ T += Ch(e,f,g) + ldr r8,[sp,#24+4] @ d.hi + adds r3,r3,r11 + and r9,r11,#0xff + adc r4,r4,r12 @ T += K[i] + adds r7,r7,r3 + ldr r11,[sp,#8+0] @ b.lo + adc r8,r8,r4 @ d += T + teq r9,#23 + + ldr r12,[sp,#16+0] @ c.lo +#if __ARM_ARCH>=7 + it eq @ Thumb2 thing, sanity check in ARM +#endif + orreq r14,r14,#1 + @ Sigma0(x) (ROTR((x),28) ^ ROTR((x),34) ^ ROTR((x),39)) + @ LO lo>>28^hi<<4 ^ hi>>2^lo<<30 ^ hi>>7^lo<<25 + @ HI hi>>28^lo<<4 ^ lo>>2^hi<<30 ^ lo>>7^hi<<25 + mov r9,r5,lsr#28 + mov r10,r6,lsr#28 + eor r9,r9,r6,lsl#4 + eor r10,r10,r5,lsl#4 + eor r9,r9,r6,lsr#2 + eor r10,r10,r5,lsr#2 + eor r9,r9,r5,lsl#30 + eor r10,r10,r6,lsl#30 + eor r9,r9,r6,lsr#7 + eor r10,r10,r5,lsr#7 + eor r9,r9,r5,lsl#25 + eor r10,r10,r6,lsl#25 @ Sigma0(a) + adds r3,r3,r9 + and r9,r5,r11 + adc r4,r4,r10 @ T += Sigma0(a) + + ldr r10,[sp,#8+4] @ b.hi + orr r5,r5,r11 + ldr r11,[sp,#16+4] @ c.hi + and r5,r5,r12 + and r12,r6,r10 + orr r6,r6,r10 + orr r5,r5,r9 @ Maj(a,b,c).lo + and r6,r6,r11 + adds r5,r5,r3 + orr r6,r6,r12 @ Maj(a,b,c).hi + sub sp,sp,#8 + adc r6,r6,r4 @ h += T + tst r14,#1 + add r14,r14,#8 +#if __ARM_ARCH>=7 + ittt eq @ Thumb2 thing, sanity check in ARM +#endif + ldreq r9,[sp,#184+0] + ldreq r10,[sp,#184+4] + beq .L16_79 + bic r14,r14,#1 + + ldr r3,[sp,#8+0] + ldr r4,[sp,#8+4] + ldr r9, [r0,#0+LO] + ldr r10, [r0,#0+HI] + ldr r11, [r0,#8+LO] + ldr r12, [r0,#8+HI] + adds r9,r5,r9 + str r9, [r0,#0+LO] + adc r10,r6,r10 + str r10, [r0,#0+HI] + adds r11,r3,r11 + str r11, [r0,#8+LO] + adc r12,r4,r12 + str r12, [r0,#8+HI] + + ldr r5,[sp,#16+0] + ldr r6,[sp,#16+4] + ldr r3,[sp,#24+0] + ldr r4,[sp,#24+4] + ldr r9, [r0,#16+LO] + ldr r10, [r0,#16+HI] + ldr r11, [r0,#24+LO] + ldr r12, [r0,#24+HI] + adds r9,r5,r9 + str r9, [r0,#16+LO] + adc r10,r6,r10 + str r10, [r0,#16+HI] + adds r11,r3,r11 + str r11, [r0,#24+LO] + adc r12,r4,r12 + str r12, [r0,#24+HI] + + ldr r3,[sp,#40+0] + ldr r4,[sp,#40+4] + ldr r9, [r0,#32+LO] + ldr r10, [r0,#32+HI] + ldr r11, [r0,#40+LO] + ldr r12, [r0,#40+HI] + adds r7,r7,r9 + str r7,[r0,#32+LO] + adc r8,r8,r10 + str r8,[r0,#32+HI] + adds r11,r3,r11 + str r11, [r0,#40+LO] + adc r12,r4,r12 + str r12, [r0,#40+HI] + + ldr r5,[sp,#48+0] + ldr r6,[sp,#48+4] + ldr r3,[sp,#56+0] + ldr r4,[sp,#56+4] + ldr r9, [r0,#48+LO] + ldr r10, [r0,#48+HI] + ldr r11, [r0,#56+LO] + ldr r12, [r0,#56+HI] + adds r9,r5,r9 + str r9, [r0,#48+LO] + adc r10,r6,r10 + str r10, [r0,#48+HI] + adds r11,r3,r11 + str r11, [r0,#56+LO] + adc r12,r4,r12 + str r12, [r0,#56+HI] + + add sp,sp,#640 + sub r14,r14,#640 + + teq r1,r2 + bne .Loop + + add sp,sp,#8*9 @ destroy frame +#if __ARM_ARCH>=5 + ldmia sp!,{r4,r5,r6,r7,r8,r9,r10,r11,r12,pc} +#else + ldmia sp!,{r4,r5,r6,r7,r8,r9,r10,r11,r12,lr} + tst lr,#1 + moveq pc,lr @ be binary compatible with V4, yet +.word 0xe12fff1e @ interoperable with Thumb ISA:-) +#endif +.size sha512_block_data_order_nohw,.-sha512_block_data_order_nohw +#if __ARM_MAX_ARCH__>=7 +.arch armv7-a +.fpu neon + +.globl sha512_block_data_order_neon +.hidden sha512_block_data_order_neon +.type sha512_block_data_order_neon,%function +.align 4 +sha512_block_data_order_neon: + dmb @ errata #451034 on early Cortex A8 + add r2,r1,r2,lsl#7 @ len to point at the end of inp + adr r3,K512 + VFP_ABI_PUSH + vldmia r0,{d16,d17,d18,d19,d20,d21,d22,d23} @ load context +.Loop_neon: + vshr.u64 d24,d20,#14 @ 0 +#if 0<16 + vld1.64 {d0},[r1]! @ handles unaligned +#endif + vshr.u64 d25,d20,#18 +#if 0>0 + vadd.i64 d16,d30 @ h+=Maj from the past +#endif + vshr.u64 d26,d20,#41 + vld1.64 {d28},[r3,:64]! @ K[i++] + vsli.64 d24,d20,#50 + vsli.64 d25,d20,#46 + vmov d29,d20 + vsli.64 d26,d20,#23 +#if 0<16 && defined(__ARMEL__) + vrev64.8 d0,d0 +#endif + veor d25,d24 + vbsl d29,d21,d22 @ Ch(e,f,g) + vshr.u64 d24,d16,#28 + veor d26,d25 @ Sigma1(e) + vadd.i64 d27,d29,d23 + vshr.u64 d25,d16,#34 + vsli.64 d24,d16,#36 + vadd.i64 d27,d26 + vshr.u64 d26,d16,#39 + vadd.i64 d28,d0 + vsli.64 d25,d16,#30 + veor d30,d16,d17 + vsli.64 d26,d16,#25 + veor d23,d24,d25 + vadd.i64 d27,d28 + vbsl d30,d18,d17 @ Maj(a,b,c) + veor d23,d26 @ Sigma0(a) + vadd.i64 d19,d27 + vadd.i64 d30,d27 + @ vadd.i64 d23,d30 + vshr.u64 d24,d19,#14 @ 1 +#if 1<16 + vld1.64 {d1},[r1]! @ handles unaligned +#endif + vshr.u64 d25,d19,#18 +#if 1>0 + vadd.i64 d23,d30 @ h+=Maj from the past +#endif + vshr.u64 d26,d19,#41 + vld1.64 {d28},[r3,:64]! @ K[i++] + vsli.64 d24,d19,#50 + vsli.64 d25,d19,#46 + vmov d29,d19 + vsli.64 d26,d19,#23 +#if 1<16 && defined(__ARMEL__) + vrev64.8 d1,d1 +#endif + veor d25,d24 + vbsl d29,d20,d21 @ Ch(e,f,g) + vshr.u64 d24,d23,#28 + veor d26,d25 @ Sigma1(e) + vadd.i64 d27,d29,d22 + vshr.u64 d25,d23,#34 + vsli.64 d24,d23,#36 + vadd.i64 d27,d26 + vshr.u64 d26,d23,#39 + vadd.i64 d28,d1 + vsli.64 d25,d23,#30 + veor d30,d23,d16 + vsli.64 d26,d23,#25 + veor d22,d24,d25 + vadd.i64 d27,d28 + vbsl d30,d17,d16 @ Maj(a,b,c) + veor d22,d26 @ Sigma0(a) + vadd.i64 d18,d27 + vadd.i64 d30,d27 + @ vadd.i64 d22,d30 + vshr.u64 d24,d18,#14 @ 2 +#if 2<16 + vld1.64 {d2},[r1]! @ handles unaligned +#endif + vshr.u64 d25,d18,#18 +#if 2>0 + vadd.i64 d22,d30 @ h+=Maj from the past +#endif + vshr.u64 d26,d18,#41 + vld1.64 {d28},[r3,:64]! @ K[i++] + vsli.64 d24,d18,#50 + vsli.64 d25,d18,#46 + vmov d29,d18 + vsli.64 d26,d18,#23 +#if 2<16 && defined(__ARMEL__) + vrev64.8 d2,d2 +#endif + veor d25,d24 + vbsl d29,d19,d20 @ Ch(e,f,g) + vshr.u64 d24,d22,#28 + veor d26,d25 @ Sigma1(e) + vadd.i64 d27,d29,d21 + vshr.u64 d25,d22,#34 + vsli.64 d24,d22,#36 + vadd.i64 d27,d26 + vshr.u64 d26,d22,#39 + vadd.i64 d28,d2 + vsli.64 d25,d22,#30 + veor d30,d22,d23 + vsli.64 d26,d22,#25 + veor d21,d24,d25 + vadd.i64 d27,d28 + vbsl d30,d16,d23 @ Maj(a,b,c) + veor d21,d26 @ Sigma0(a) + vadd.i64 d17,d27 + vadd.i64 d30,d27 + @ vadd.i64 d21,d30 + vshr.u64 d24,d17,#14 @ 3 +#if 3<16 + vld1.64 {d3},[r1]! @ handles unaligned +#endif + vshr.u64 d25,d17,#18 +#if 3>0 + vadd.i64 d21,d30 @ h+=Maj from the past +#endif + vshr.u64 d26,d17,#41 + vld1.64 {d28},[r3,:64]! @ K[i++] + vsli.64 d24,d17,#50 + vsli.64 d25,d17,#46 + vmov d29,d17 + vsli.64 d26,d17,#23 +#if 3<16 && defined(__ARMEL__) + vrev64.8 d3,d3 +#endif + veor d25,d24 + vbsl d29,d18,d19 @ Ch(e,f,g) + vshr.u64 d24,d21,#28 + veor d26,d25 @ Sigma1(e) + vadd.i64 d27,d29,d20 + vshr.u64 d25,d21,#34 + vsli.64 d24,d21,#36 + vadd.i64 d27,d26 + vshr.u64 d26,d21,#39 + vadd.i64 d28,d3 + vsli.64 d25,d21,#30 + veor d30,d21,d22 + vsli.64 d26,d21,#25 + veor d20,d24,d25 + vadd.i64 d27,d28 + vbsl d30,d23,d22 @ Maj(a,b,c) + veor d20,d26 @ Sigma0(a) + vadd.i64 d16,d27 + vadd.i64 d30,d27 + @ vadd.i64 d20,d30 + vshr.u64 d24,d16,#14 @ 4 +#if 4<16 + vld1.64 {d4},[r1]! @ handles unaligned +#endif + vshr.u64 d25,d16,#18 +#if 4>0 + vadd.i64 d20,d30 @ h+=Maj from the past +#endif + vshr.u64 d26,d16,#41 + vld1.64 {d28},[r3,:64]! @ K[i++] + vsli.64 d24,d16,#50 + vsli.64 d25,d16,#46 + vmov d29,d16 + vsli.64 d26,d16,#23 +#if 4<16 && defined(__ARMEL__) + vrev64.8 d4,d4 +#endif + veor d25,d24 + vbsl d29,d17,d18 @ Ch(e,f,g) + vshr.u64 d24,d20,#28 + veor d26,d25 @ Sigma1(e) + vadd.i64 d27,d29,d19 + vshr.u64 d25,d20,#34 + vsli.64 d24,d20,#36 + vadd.i64 d27,d26 + vshr.u64 d26,d20,#39 + vadd.i64 d28,d4 + vsli.64 d25,d20,#30 + veor d30,d20,d21 + vsli.64 d26,d20,#25 + veor d19,d24,d25 + vadd.i64 d27,d28 + vbsl d30,d22,d21 @ Maj(a,b,c) + veor d19,d26 @ Sigma0(a) + vadd.i64 d23,d27 + vadd.i64 d30,d27 + @ vadd.i64 d19,d30 + vshr.u64 d24,d23,#14 @ 5 +#if 5<16 + vld1.64 {d5},[r1]! @ handles unaligned +#endif + vshr.u64 d25,d23,#18 +#if 5>0 + vadd.i64 d19,d30 @ h+=Maj from the past +#endif + vshr.u64 d26,d23,#41 + vld1.64 {d28},[r3,:64]! @ K[i++] + vsli.64 d24,d23,#50 + vsli.64 d25,d23,#46 + vmov d29,d23 + vsli.64 d26,d23,#23 +#if 5<16 && defined(__ARMEL__) + vrev64.8 d5,d5 +#endif + veor d25,d24 + vbsl d29,d16,d17 @ Ch(e,f,g) + vshr.u64 d24,d19,#28 + veor d26,d25 @ Sigma1(e) + vadd.i64 d27,d29,d18 + vshr.u64 d25,d19,#34 + vsli.64 d24,d19,#36 + vadd.i64 d27,d26 + vshr.u64 d26,d19,#39 + vadd.i64 d28,d5 + vsli.64 d25,d19,#30 + veor d30,d19,d20 + vsli.64 d26,d19,#25 + veor d18,d24,d25 + vadd.i64 d27,d28 + vbsl d30,d21,d20 @ Maj(a,b,c) + veor d18,d26 @ Sigma0(a) + vadd.i64 d22,d27 + vadd.i64 d30,d27 + @ vadd.i64 d18,d30 + vshr.u64 d24,d22,#14 @ 6 +#if 6<16 + vld1.64 {d6},[r1]! @ handles unaligned +#endif + vshr.u64 d25,d22,#18 +#if 6>0 + vadd.i64 d18,d30 @ h+=Maj from the past +#endif + vshr.u64 d26,d22,#41 + vld1.64 {d28},[r3,:64]! @ K[i++] + vsli.64 d24,d22,#50 + vsli.64 d25,d22,#46 + vmov d29,d22 + vsli.64 d26,d22,#23 +#if 6<16 && defined(__ARMEL__) + vrev64.8 d6,d6 +#endif + veor d25,d24 + vbsl d29,d23,d16 @ Ch(e,f,g) + vshr.u64 d24,d18,#28 + veor d26,d25 @ Sigma1(e) + vadd.i64 d27,d29,d17 + vshr.u64 d25,d18,#34 + vsli.64 d24,d18,#36 + vadd.i64 d27,d26 + vshr.u64 d26,d18,#39 + vadd.i64 d28,d6 + vsli.64 d25,d18,#30 + veor d30,d18,d19 + vsli.64 d26,d18,#25 + veor d17,d24,d25 + vadd.i64 d27,d28 + vbsl d30,d20,d19 @ Maj(a,b,c) + veor d17,d26 @ Sigma0(a) + vadd.i64 d21,d27 + vadd.i64 d30,d27 + @ vadd.i64 d17,d30 + vshr.u64 d24,d21,#14 @ 7 +#if 7<16 + vld1.64 {d7},[r1]! @ handles unaligned +#endif + vshr.u64 d25,d21,#18 +#if 7>0 + vadd.i64 d17,d30 @ h+=Maj from the past +#endif + vshr.u64 d26,d21,#41 + vld1.64 {d28},[r3,:64]! @ K[i++] + vsli.64 d24,d21,#50 + vsli.64 d25,d21,#46 + vmov d29,d21 + vsli.64 d26,d21,#23 +#if 7<16 && defined(__ARMEL__) + vrev64.8 d7,d7 +#endif + veor d25,d24 + vbsl d29,d22,d23 @ Ch(e,f,g) + vshr.u64 d24,d17,#28 + veor d26,d25 @ Sigma1(e) + vadd.i64 d27,d29,d16 + vshr.u64 d25,d17,#34 + vsli.64 d24,d17,#36 + vadd.i64 d27,d26 + vshr.u64 d26,d17,#39 + vadd.i64 d28,d7 + vsli.64 d25,d17,#30 + veor d30,d17,d18 + vsli.64 d26,d17,#25 + veor d16,d24,d25 + vadd.i64 d27,d28 + vbsl d30,d19,d18 @ Maj(a,b,c) + veor d16,d26 @ Sigma0(a) + vadd.i64 d20,d27 + vadd.i64 d30,d27 + @ vadd.i64 d16,d30 + vshr.u64 d24,d20,#14 @ 8 +#if 8<16 + vld1.64 {d8},[r1]! @ handles unaligned +#endif + vshr.u64 d25,d20,#18 +#if 8>0 + vadd.i64 d16,d30 @ h+=Maj from the past +#endif + vshr.u64 d26,d20,#41 + vld1.64 {d28},[r3,:64]! @ K[i++] + vsli.64 d24,d20,#50 + vsli.64 d25,d20,#46 + vmov d29,d20 + vsli.64 d26,d20,#23 +#if 8<16 && defined(__ARMEL__) + vrev64.8 d8,d8 +#endif + veor d25,d24 + vbsl d29,d21,d22 @ Ch(e,f,g) + vshr.u64 d24,d16,#28 + veor d26,d25 @ Sigma1(e) + vadd.i64 d27,d29,d23 + vshr.u64 d25,d16,#34 + vsli.64 d24,d16,#36 + vadd.i64 d27,d26 + vshr.u64 d26,d16,#39 + vadd.i64 d28,d8 + vsli.64 d25,d16,#30 + veor d30,d16,d17 + vsli.64 d26,d16,#25 + veor d23,d24,d25 + vadd.i64 d27,d28 + vbsl d30,d18,d17 @ Maj(a,b,c) + veor d23,d26 @ Sigma0(a) + vadd.i64 d19,d27 + vadd.i64 d30,d27 + @ vadd.i64 d23,d30 + vshr.u64 d24,d19,#14 @ 9 +#if 9<16 + vld1.64 {d9},[r1]! @ handles unaligned +#endif + vshr.u64 d25,d19,#18 +#if 9>0 + vadd.i64 d23,d30 @ h+=Maj from the past +#endif + vshr.u64 d26,d19,#41 + vld1.64 {d28},[r3,:64]! @ K[i++] + vsli.64 d24,d19,#50 + vsli.64 d25,d19,#46 + vmov d29,d19 + vsli.64 d26,d19,#23 +#if 9<16 && defined(__ARMEL__) + vrev64.8 d9,d9 +#endif + veor d25,d24 + vbsl d29,d20,d21 @ Ch(e,f,g) + vshr.u64 d24,d23,#28 + veor d26,d25 @ Sigma1(e) + vadd.i64 d27,d29,d22 + vshr.u64 d25,d23,#34 + vsli.64 d24,d23,#36 + vadd.i64 d27,d26 + vshr.u64 d26,d23,#39 + vadd.i64 d28,d9 + vsli.64 d25,d23,#30 + veor d30,d23,d16 + vsli.64 d26,d23,#25 + veor d22,d24,d25 + vadd.i64 d27,d28 + vbsl d30,d17,d16 @ Maj(a,b,c) + veor d22,d26 @ Sigma0(a) + vadd.i64 d18,d27 + vadd.i64 d30,d27 + @ vadd.i64 d22,d30 + vshr.u64 d24,d18,#14 @ 10 +#if 10<16 + vld1.64 {d10},[r1]! @ handles unaligned +#endif + vshr.u64 d25,d18,#18 +#if 10>0 + vadd.i64 d22,d30 @ h+=Maj from the past +#endif + vshr.u64 d26,d18,#41 + vld1.64 {d28},[r3,:64]! @ K[i++] + vsli.64 d24,d18,#50 + vsli.64 d25,d18,#46 + vmov d29,d18 + vsli.64 d26,d18,#23 +#if 10<16 && defined(__ARMEL__) + vrev64.8 d10,d10 +#endif + veor d25,d24 + vbsl d29,d19,d20 @ Ch(e,f,g) + vshr.u64 d24,d22,#28 + veor d26,d25 @ Sigma1(e) + vadd.i64 d27,d29,d21 + vshr.u64 d25,d22,#34 + vsli.64 d24,d22,#36 + vadd.i64 d27,d26 + vshr.u64 d26,d22,#39 + vadd.i64 d28,d10 + vsli.64 d25,d22,#30 + veor d30,d22,d23 + vsli.64 d26,d22,#25 + veor d21,d24,d25 + vadd.i64 d27,d28 + vbsl d30,d16,d23 @ Maj(a,b,c) + veor d21,d26 @ Sigma0(a) + vadd.i64 d17,d27 + vadd.i64 d30,d27 + @ vadd.i64 d21,d30 + vshr.u64 d24,d17,#14 @ 11 +#if 11<16 + vld1.64 {d11},[r1]! @ handles unaligned +#endif + vshr.u64 d25,d17,#18 +#if 11>0 + vadd.i64 d21,d30 @ h+=Maj from the past +#endif + vshr.u64 d26,d17,#41 + vld1.64 {d28},[r3,:64]! @ K[i++] + vsli.64 d24,d17,#50 + vsli.64 d25,d17,#46 + vmov d29,d17 + vsli.64 d26,d17,#23 +#if 11<16 && defined(__ARMEL__) + vrev64.8 d11,d11 +#endif + veor d25,d24 + vbsl d29,d18,d19 @ Ch(e,f,g) + vshr.u64 d24,d21,#28 + veor d26,d25 @ Sigma1(e) + vadd.i64 d27,d29,d20 + vshr.u64 d25,d21,#34 + vsli.64 d24,d21,#36 + vadd.i64 d27,d26 + vshr.u64 d26,d21,#39 + vadd.i64 d28,d11 + vsli.64 d25,d21,#30 + veor d30,d21,d22 + vsli.64 d26,d21,#25 + veor d20,d24,d25 + vadd.i64 d27,d28 + vbsl d30,d23,d22 @ Maj(a,b,c) + veor d20,d26 @ Sigma0(a) + vadd.i64 d16,d27 + vadd.i64 d30,d27 + @ vadd.i64 d20,d30 + vshr.u64 d24,d16,#14 @ 12 +#if 12<16 + vld1.64 {d12},[r1]! @ handles unaligned +#endif + vshr.u64 d25,d16,#18 +#if 12>0 + vadd.i64 d20,d30 @ h+=Maj from the past +#endif + vshr.u64 d26,d16,#41 + vld1.64 {d28},[r3,:64]! @ K[i++] + vsli.64 d24,d16,#50 + vsli.64 d25,d16,#46 + vmov d29,d16 + vsli.64 d26,d16,#23 +#if 12<16 && defined(__ARMEL__) + vrev64.8 d12,d12 +#endif + veor d25,d24 + vbsl d29,d17,d18 @ Ch(e,f,g) + vshr.u64 d24,d20,#28 + veor d26,d25 @ Sigma1(e) + vadd.i64 d27,d29,d19 + vshr.u64 d25,d20,#34 + vsli.64 d24,d20,#36 + vadd.i64 d27,d26 + vshr.u64 d26,d20,#39 + vadd.i64 d28,d12 + vsli.64 d25,d20,#30 + veor d30,d20,d21 + vsli.64 d26,d20,#25 + veor d19,d24,d25 + vadd.i64 d27,d28 + vbsl d30,d22,d21 @ Maj(a,b,c) + veor d19,d26 @ Sigma0(a) + vadd.i64 d23,d27 + vadd.i64 d30,d27 + @ vadd.i64 d19,d30 + vshr.u64 d24,d23,#14 @ 13 +#if 13<16 + vld1.64 {d13},[r1]! @ handles unaligned +#endif + vshr.u64 d25,d23,#18 +#if 13>0 + vadd.i64 d19,d30 @ h+=Maj from the past +#endif + vshr.u64 d26,d23,#41 + vld1.64 {d28},[r3,:64]! @ K[i++] + vsli.64 d24,d23,#50 + vsli.64 d25,d23,#46 + vmov d29,d23 + vsli.64 d26,d23,#23 +#if 13<16 && defined(__ARMEL__) + vrev64.8 d13,d13 +#endif + veor d25,d24 + vbsl d29,d16,d17 @ Ch(e,f,g) + vshr.u64 d24,d19,#28 + veor d26,d25 @ Sigma1(e) + vadd.i64 d27,d29,d18 + vshr.u64 d25,d19,#34 + vsli.64 d24,d19,#36 + vadd.i64 d27,d26 + vshr.u64 d26,d19,#39 + vadd.i64 d28,d13 + vsli.64 d25,d19,#30 + veor d30,d19,d20 + vsli.64 d26,d19,#25 + veor d18,d24,d25 + vadd.i64 d27,d28 + vbsl d30,d21,d20 @ Maj(a,b,c) + veor d18,d26 @ Sigma0(a) + vadd.i64 d22,d27 + vadd.i64 d30,d27 + @ vadd.i64 d18,d30 + vshr.u64 d24,d22,#14 @ 14 +#if 14<16 + vld1.64 {d14},[r1]! @ handles unaligned +#endif + vshr.u64 d25,d22,#18 +#if 14>0 + vadd.i64 d18,d30 @ h+=Maj from the past +#endif + vshr.u64 d26,d22,#41 + vld1.64 {d28},[r3,:64]! @ K[i++] + vsli.64 d24,d22,#50 + vsli.64 d25,d22,#46 + vmov d29,d22 + vsli.64 d26,d22,#23 +#if 14<16 && defined(__ARMEL__) + vrev64.8 d14,d14 +#endif + veor d25,d24 + vbsl d29,d23,d16 @ Ch(e,f,g) + vshr.u64 d24,d18,#28 + veor d26,d25 @ Sigma1(e) + vadd.i64 d27,d29,d17 + vshr.u64 d25,d18,#34 + vsli.64 d24,d18,#36 + vadd.i64 d27,d26 + vshr.u64 d26,d18,#39 + vadd.i64 d28,d14 + vsli.64 d25,d18,#30 + veor d30,d18,d19 + vsli.64 d26,d18,#25 + veor d17,d24,d25 + vadd.i64 d27,d28 + vbsl d30,d20,d19 @ Maj(a,b,c) + veor d17,d26 @ Sigma0(a) + vadd.i64 d21,d27 + vadd.i64 d30,d27 + @ vadd.i64 d17,d30 + vshr.u64 d24,d21,#14 @ 15 +#if 15<16 + vld1.64 {d15},[r1]! @ handles unaligned +#endif + vshr.u64 d25,d21,#18 +#if 15>0 + vadd.i64 d17,d30 @ h+=Maj from the past +#endif + vshr.u64 d26,d21,#41 + vld1.64 {d28},[r3,:64]! @ K[i++] + vsli.64 d24,d21,#50 + vsli.64 d25,d21,#46 + vmov d29,d21 + vsli.64 d26,d21,#23 +#if 15<16 && defined(__ARMEL__) + vrev64.8 d15,d15 +#endif + veor d25,d24 + vbsl d29,d22,d23 @ Ch(e,f,g) + vshr.u64 d24,d17,#28 + veor d26,d25 @ Sigma1(e) + vadd.i64 d27,d29,d16 + vshr.u64 d25,d17,#34 + vsli.64 d24,d17,#36 + vadd.i64 d27,d26 + vshr.u64 d26,d17,#39 + vadd.i64 d28,d15 + vsli.64 d25,d17,#30 + veor d30,d17,d18 + vsli.64 d26,d17,#25 + veor d16,d24,d25 + vadd.i64 d27,d28 + vbsl d30,d19,d18 @ Maj(a,b,c) + veor d16,d26 @ Sigma0(a) + vadd.i64 d20,d27 + vadd.i64 d30,d27 + @ vadd.i64 d16,d30 + mov r12,#4 +.L16_79_neon: + subs r12,#1 + vshr.u64 q12,q7,#19 + vshr.u64 q13,q7,#61 + vadd.i64 d16,d30 @ h+=Maj from the past + vshr.u64 q15,q7,#6 + vsli.64 q12,q7,#45 + vext.8 q14,q0,q1,#8 @ X[i+1] + vsli.64 q13,q7,#3 + veor q15,q12 + vshr.u64 q12,q14,#1 + veor q15,q13 @ sigma1(X[i+14]) + vshr.u64 q13,q14,#8 + vadd.i64 q0,q15 + vshr.u64 q15,q14,#7 + vsli.64 q12,q14,#63 + vsli.64 q13,q14,#56 + vext.8 q14,q4,q5,#8 @ X[i+9] + veor q15,q12 + vshr.u64 d24,d20,#14 @ from NEON_00_15 + vadd.i64 q0,q14 + vshr.u64 d25,d20,#18 @ from NEON_00_15 + veor q15,q13 @ sigma0(X[i+1]) + vshr.u64 d26,d20,#41 @ from NEON_00_15 + vadd.i64 q0,q15 + vld1.64 {d28},[r3,:64]! @ K[i++] + vsli.64 d24,d20,#50 + vsli.64 d25,d20,#46 + vmov d29,d20 + vsli.64 d26,d20,#23 +#if 16<16 && defined(__ARMEL__) + vrev64.8 , +#endif + veor d25,d24 + vbsl d29,d21,d22 @ Ch(e,f,g) + vshr.u64 d24,d16,#28 + veor d26,d25 @ Sigma1(e) + vadd.i64 d27,d29,d23 + vshr.u64 d25,d16,#34 + vsli.64 d24,d16,#36 + vadd.i64 d27,d26 + vshr.u64 d26,d16,#39 + vadd.i64 d28,d0 + vsli.64 d25,d16,#30 + veor d30,d16,d17 + vsli.64 d26,d16,#25 + veor d23,d24,d25 + vadd.i64 d27,d28 + vbsl d30,d18,d17 @ Maj(a,b,c) + veor d23,d26 @ Sigma0(a) + vadd.i64 d19,d27 + vadd.i64 d30,d27 + @ vadd.i64 d23,d30 + vshr.u64 d24,d19,#14 @ 17 +#if 17<16 + vld1.64 {d1},[r1]! @ handles unaligned +#endif + vshr.u64 d25,d19,#18 +#if 17>0 + vadd.i64 d23,d30 @ h+=Maj from the past +#endif + vshr.u64 d26,d19,#41 + vld1.64 {d28},[r3,:64]! @ K[i++] + vsli.64 d24,d19,#50 + vsli.64 d25,d19,#46 + vmov d29,d19 + vsli.64 d26,d19,#23 +#if 17<16 && defined(__ARMEL__) + vrev64.8 , +#endif + veor d25,d24 + vbsl d29,d20,d21 @ Ch(e,f,g) + vshr.u64 d24,d23,#28 + veor d26,d25 @ Sigma1(e) + vadd.i64 d27,d29,d22 + vshr.u64 d25,d23,#34 + vsli.64 d24,d23,#36 + vadd.i64 d27,d26 + vshr.u64 d26,d23,#39 + vadd.i64 d28,d1 + vsli.64 d25,d23,#30 + veor d30,d23,d16 + vsli.64 d26,d23,#25 + veor d22,d24,d25 + vadd.i64 d27,d28 + vbsl d30,d17,d16 @ Maj(a,b,c) + veor d22,d26 @ Sigma0(a) + vadd.i64 d18,d27 + vadd.i64 d30,d27 + @ vadd.i64 d22,d30 + vshr.u64 q12,q0,#19 + vshr.u64 q13,q0,#61 + vadd.i64 d22,d30 @ h+=Maj from the past + vshr.u64 q15,q0,#6 + vsli.64 q12,q0,#45 + vext.8 q14,q1,q2,#8 @ X[i+1] + vsli.64 q13,q0,#3 + veor q15,q12 + vshr.u64 q12,q14,#1 + veor q15,q13 @ sigma1(X[i+14]) + vshr.u64 q13,q14,#8 + vadd.i64 q1,q15 + vshr.u64 q15,q14,#7 + vsli.64 q12,q14,#63 + vsli.64 q13,q14,#56 + vext.8 q14,q5,q6,#8 @ X[i+9] + veor q15,q12 + vshr.u64 d24,d18,#14 @ from NEON_00_15 + vadd.i64 q1,q14 + vshr.u64 d25,d18,#18 @ from NEON_00_15 + veor q15,q13 @ sigma0(X[i+1]) + vshr.u64 d26,d18,#41 @ from NEON_00_15 + vadd.i64 q1,q15 + vld1.64 {d28},[r3,:64]! @ K[i++] + vsli.64 d24,d18,#50 + vsli.64 d25,d18,#46 + vmov d29,d18 + vsli.64 d26,d18,#23 +#if 18<16 && defined(__ARMEL__) + vrev64.8 , +#endif + veor d25,d24 + vbsl d29,d19,d20 @ Ch(e,f,g) + vshr.u64 d24,d22,#28 + veor d26,d25 @ Sigma1(e) + vadd.i64 d27,d29,d21 + vshr.u64 d25,d22,#34 + vsli.64 d24,d22,#36 + vadd.i64 d27,d26 + vshr.u64 d26,d22,#39 + vadd.i64 d28,d2 + vsli.64 d25,d22,#30 + veor d30,d22,d23 + vsli.64 d26,d22,#25 + veor d21,d24,d25 + vadd.i64 d27,d28 + vbsl d30,d16,d23 @ Maj(a,b,c) + veor d21,d26 @ Sigma0(a) + vadd.i64 d17,d27 + vadd.i64 d30,d27 + @ vadd.i64 d21,d30 + vshr.u64 d24,d17,#14 @ 19 +#if 19<16 + vld1.64 {d3},[r1]! @ handles unaligned +#endif + vshr.u64 d25,d17,#18 +#if 19>0 + vadd.i64 d21,d30 @ h+=Maj from the past +#endif + vshr.u64 d26,d17,#41 + vld1.64 {d28},[r3,:64]! @ K[i++] + vsli.64 d24,d17,#50 + vsli.64 d25,d17,#46 + vmov d29,d17 + vsli.64 d26,d17,#23 +#if 19<16 && defined(__ARMEL__) + vrev64.8 , +#endif + veor d25,d24 + vbsl d29,d18,d19 @ Ch(e,f,g) + vshr.u64 d24,d21,#28 + veor d26,d25 @ Sigma1(e) + vadd.i64 d27,d29,d20 + vshr.u64 d25,d21,#34 + vsli.64 d24,d21,#36 + vadd.i64 d27,d26 + vshr.u64 d26,d21,#39 + vadd.i64 d28,d3 + vsli.64 d25,d21,#30 + veor d30,d21,d22 + vsli.64 d26,d21,#25 + veor d20,d24,d25 + vadd.i64 d27,d28 + vbsl d30,d23,d22 @ Maj(a,b,c) + veor d20,d26 @ Sigma0(a) + vadd.i64 d16,d27 + vadd.i64 d30,d27 + @ vadd.i64 d20,d30 + vshr.u64 q12,q1,#19 + vshr.u64 q13,q1,#61 + vadd.i64 d20,d30 @ h+=Maj from the past + vshr.u64 q15,q1,#6 + vsli.64 q12,q1,#45 + vext.8 q14,q2,q3,#8 @ X[i+1] + vsli.64 q13,q1,#3 + veor q15,q12 + vshr.u64 q12,q14,#1 + veor q15,q13 @ sigma1(X[i+14]) + vshr.u64 q13,q14,#8 + vadd.i64 q2,q15 + vshr.u64 q15,q14,#7 + vsli.64 q12,q14,#63 + vsli.64 q13,q14,#56 + vext.8 q14,q6,q7,#8 @ X[i+9] + veor q15,q12 + vshr.u64 d24,d16,#14 @ from NEON_00_15 + vadd.i64 q2,q14 + vshr.u64 d25,d16,#18 @ from NEON_00_15 + veor q15,q13 @ sigma0(X[i+1]) + vshr.u64 d26,d16,#41 @ from NEON_00_15 + vadd.i64 q2,q15 + vld1.64 {d28},[r3,:64]! @ K[i++] + vsli.64 d24,d16,#50 + vsli.64 d25,d16,#46 + vmov d29,d16 + vsli.64 d26,d16,#23 +#if 20<16 && defined(__ARMEL__) + vrev64.8 , +#endif + veor d25,d24 + vbsl d29,d17,d18 @ Ch(e,f,g) + vshr.u64 d24,d20,#28 + veor d26,d25 @ Sigma1(e) + vadd.i64 d27,d29,d19 + vshr.u64 d25,d20,#34 + vsli.64 d24,d20,#36 + vadd.i64 d27,d26 + vshr.u64 d26,d20,#39 + vadd.i64 d28,d4 + vsli.64 d25,d20,#30 + veor d30,d20,d21 + vsli.64 d26,d20,#25 + veor d19,d24,d25 + vadd.i64 d27,d28 + vbsl d30,d22,d21 @ Maj(a,b,c) + veor d19,d26 @ Sigma0(a) + vadd.i64 d23,d27 + vadd.i64 d30,d27 + @ vadd.i64 d19,d30 + vshr.u64 d24,d23,#14 @ 21 +#if 21<16 + vld1.64 {d5},[r1]! @ handles unaligned +#endif + vshr.u64 d25,d23,#18 +#if 21>0 + vadd.i64 d19,d30 @ h+=Maj from the past +#endif + vshr.u64 d26,d23,#41 + vld1.64 {d28},[r3,:64]! @ K[i++] + vsli.64 d24,d23,#50 + vsli.64 d25,d23,#46 + vmov d29,d23 + vsli.64 d26,d23,#23 +#if 21<16 && defined(__ARMEL__) + vrev64.8 , +#endif + veor d25,d24 + vbsl d29,d16,d17 @ Ch(e,f,g) + vshr.u64 d24,d19,#28 + veor d26,d25 @ Sigma1(e) + vadd.i64 d27,d29,d18 + vshr.u64 d25,d19,#34 + vsli.64 d24,d19,#36 + vadd.i64 d27,d26 + vshr.u64 d26,d19,#39 + vadd.i64 d28,d5 + vsli.64 d25,d19,#30 + veor d30,d19,d20 + vsli.64 d26,d19,#25 + veor d18,d24,d25 + vadd.i64 d27,d28 + vbsl d30,d21,d20 @ Maj(a,b,c) + veor d18,d26 @ Sigma0(a) + vadd.i64 d22,d27 + vadd.i64 d30,d27 + @ vadd.i64 d18,d30 + vshr.u64 q12,q2,#19 + vshr.u64 q13,q2,#61 + vadd.i64 d18,d30 @ h+=Maj from the past + vshr.u64 q15,q2,#6 + vsli.64 q12,q2,#45 + vext.8 q14,q3,q4,#8 @ X[i+1] + vsli.64 q13,q2,#3 + veor q15,q12 + vshr.u64 q12,q14,#1 + veor q15,q13 @ sigma1(X[i+14]) + vshr.u64 q13,q14,#8 + vadd.i64 q3,q15 + vshr.u64 q15,q14,#7 + vsli.64 q12,q14,#63 + vsli.64 q13,q14,#56 + vext.8 q14,q7,q0,#8 @ X[i+9] + veor q15,q12 + vshr.u64 d24,d22,#14 @ from NEON_00_15 + vadd.i64 q3,q14 + vshr.u64 d25,d22,#18 @ from NEON_00_15 + veor q15,q13 @ sigma0(X[i+1]) + vshr.u64 d26,d22,#41 @ from NEON_00_15 + vadd.i64 q3,q15 + vld1.64 {d28},[r3,:64]! @ K[i++] + vsli.64 d24,d22,#50 + vsli.64 d25,d22,#46 + vmov d29,d22 + vsli.64 d26,d22,#23 +#if 22<16 && defined(__ARMEL__) + vrev64.8 , +#endif + veor d25,d24 + vbsl d29,d23,d16 @ Ch(e,f,g) + vshr.u64 d24,d18,#28 + veor d26,d25 @ Sigma1(e) + vadd.i64 d27,d29,d17 + vshr.u64 d25,d18,#34 + vsli.64 d24,d18,#36 + vadd.i64 d27,d26 + vshr.u64 d26,d18,#39 + vadd.i64 d28,d6 + vsli.64 d25,d18,#30 + veor d30,d18,d19 + vsli.64 d26,d18,#25 + veor d17,d24,d25 + vadd.i64 d27,d28 + vbsl d30,d20,d19 @ Maj(a,b,c) + veor d17,d26 @ Sigma0(a) + vadd.i64 d21,d27 + vadd.i64 d30,d27 + @ vadd.i64 d17,d30 + vshr.u64 d24,d21,#14 @ 23 +#if 23<16 + vld1.64 {d7},[r1]! @ handles unaligned +#endif + vshr.u64 d25,d21,#18 +#if 23>0 + vadd.i64 d17,d30 @ h+=Maj from the past +#endif + vshr.u64 d26,d21,#41 + vld1.64 {d28},[r3,:64]! @ K[i++] + vsli.64 d24,d21,#50 + vsli.64 d25,d21,#46 + vmov d29,d21 + vsli.64 d26,d21,#23 +#if 23<16 && defined(__ARMEL__) + vrev64.8 , +#endif + veor d25,d24 + vbsl d29,d22,d23 @ Ch(e,f,g) + vshr.u64 d24,d17,#28 + veor d26,d25 @ Sigma1(e) + vadd.i64 d27,d29,d16 + vshr.u64 d25,d17,#34 + vsli.64 d24,d17,#36 + vadd.i64 d27,d26 + vshr.u64 d26,d17,#39 + vadd.i64 d28,d7 + vsli.64 d25,d17,#30 + veor d30,d17,d18 + vsli.64 d26,d17,#25 + veor d16,d24,d25 + vadd.i64 d27,d28 + vbsl d30,d19,d18 @ Maj(a,b,c) + veor d16,d26 @ Sigma0(a) + vadd.i64 d20,d27 + vadd.i64 d30,d27 + @ vadd.i64 d16,d30 + vshr.u64 q12,q3,#19 + vshr.u64 q13,q3,#61 + vadd.i64 d16,d30 @ h+=Maj from the past + vshr.u64 q15,q3,#6 + vsli.64 q12,q3,#45 + vext.8 q14,q4,q5,#8 @ X[i+1] + vsli.64 q13,q3,#3 + veor q15,q12 + vshr.u64 q12,q14,#1 + veor q15,q13 @ sigma1(X[i+14]) + vshr.u64 q13,q14,#8 + vadd.i64 q4,q15 + vshr.u64 q15,q14,#7 + vsli.64 q12,q14,#63 + vsli.64 q13,q14,#56 + vext.8 q14,q0,q1,#8 @ X[i+9] + veor q15,q12 + vshr.u64 d24,d20,#14 @ from NEON_00_15 + vadd.i64 q4,q14 + vshr.u64 d25,d20,#18 @ from NEON_00_15 + veor q15,q13 @ sigma0(X[i+1]) + vshr.u64 d26,d20,#41 @ from NEON_00_15 + vadd.i64 q4,q15 + vld1.64 {d28},[r3,:64]! @ K[i++] + vsli.64 d24,d20,#50 + vsli.64 d25,d20,#46 + vmov d29,d20 + vsli.64 d26,d20,#23 +#if 24<16 && defined(__ARMEL__) + vrev64.8 , +#endif + veor d25,d24 + vbsl d29,d21,d22 @ Ch(e,f,g) + vshr.u64 d24,d16,#28 + veor d26,d25 @ Sigma1(e) + vadd.i64 d27,d29,d23 + vshr.u64 d25,d16,#34 + vsli.64 d24,d16,#36 + vadd.i64 d27,d26 + vshr.u64 d26,d16,#39 + vadd.i64 d28,d8 + vsli.64 d25,d16,#30 + veor d30,d16,d17 + vsli.64 d26,d16,#25 + veor d23,d24,d25 + vadd.i64 d27,d28 + vbsl d30,d18,d17 @ Maj(a,b,c) + veor d23,d26 @ Sigma0(a) + vadd.i64 d19,d27 + vadd.i64 d30,d27 + @ vadd.i64 d23,d30 + vshr.u64 d24,d19,#14 @ 25 +#if 25<16 + vld1.64 {d9},[r1]! @ handles unaligned +#endif + vshr.u64 d25,d19,#18 +#if 25>0 + vadd.i64 d23,d30 @ h+=Maj from the past +#endif + vshr.u64 d26,d19,#41 + vld1.64 {d28},[r3,:64]! @ K[i++] + vsli.64 d24,d19,#50 + vsli.64 d25,d19,#46 + vmov d29,d19 + vsli.64 d26,d19,#23 +#if 25<16 && defined(__ARMEL__) + vrev64.8 , +#endif + veor d25,d24 + vbsl d29,d20,d21 @ Ch(e,f,g) + vshr.u64 d24,d23,#28 + veor d26,d25 @ Sigma1(e) + vadd.i64 d27,d29,d22 + vshr.u64 d25,d23,#34 + vsli.64 d24,d23,#36 + vadd.i64 d27,d26 + vshr.u64 d26,d23,#39 + vadd.i64 d28,d9 + vsli.64 d25,d23,#30 + veor d30,d23,d16 + vsli.64 d26,d23,#25 + veor d22,d24,d25 + vadd.i64 d27,d28 + vbsl d30,d17,d16 @ Maj(a,b,c) + veor d22,d26 @ Sigma0(a) + vadd.i64 d18,d27 + vadd.i64 d30,d27 + @ vadd.i64 d22,d30 + vshr.u64 q12,q4,#19 + vshr.u64 q13,q4,#61 + vadd.i64 d22,d30 @ h+=Maj from the past + vshr.u64 q15,q4,#6 + vsli.64 q12,q4,#45 + vext.8 q14,q5,q6,#8 @ X[i+1] + vsli.64 q13,q4,#3 + veor q15,q12 + vshr.u64 q12,q14,#1 + veor q15,q13 @ sigma1(X[i+14]) + vshr.u64 q13,q14,#8 + vadd.i64 q5,q15 + vshr.u64 q15,q14,#7 + vsli.64 q12,q14,#63 + vsli.64 q13,q14,#56 + vext.8 q14,q1,q2,#8 @ X[i+9] + veor q15,q12 + vshr.u64 d24,d18,#14 @ from NEON_00_15 + vadd.i64 q5,q14 + vshr.u64 d25,d18,#18 @ from NEON_00_15 + veor q15,q13 @ sigma0(X[i+1]) + vshr.u64 d26,d18,#41 @ from NEON_00_15 + vadd.i64 q5,q15 + vld1.64 {d28},[r3,:64]! @ K[i++] + vsli.64 d24,d18,#50 + vsli.64 d25,d18,#46 + vmov d29,d18 + vsli.64 d26,d18,#23 +#if 26<16 && defined(__ARMEL__) + vrev64.8 , +#endif + veor d25,d24 + vbsl d29,d19,d20 @ Ch(e,f,g) + vshr.u64 d24,d22,#28 + veor d26,d25 @ Sigma1(e) + vadd.i64 d27,d29,d21 + vshr.u64 d25,d22,#34 + vsli.64 d24,d22,#36 + vadd.i64 d27,d26 + vshr.u64 d26,d22,#39 + vadd.i64 d28,d10 + vsli.64 d25,d22,#30 + veor d30,d22,d23 + vsli.64 d26,d22,#25 + veor d21,d24,d25 + vadd.i64 d27,d28 + vbsl d30,d16,d23 @ Maj(a,b,c) + veor d21,d26 @ Sigma0(a) + vadd.i64 d17,d27 + vadd.i64 d30,d27 + @ vadd.i64 d21,d30 + vshr.u64 d24,d17,#14 @ 27 +#if 27<16 + vld1.64 {d11},[r1]! @ handles unaligned +#endif + vshr.u64 d25,d17,#18 +#if 27>0 + vadd.i64 d21,d30 @ h+=Maj from the past +#endif + vshr.u64 d26,d17,#41 + vld1.64 {d28},[r3,:64]! @ K[i++] + vsli.64 d24,d17,#50 + vsli.64 d25,d17,#46 + vmov d29,d17 + vsli.64 d26,d17,#23 +#if 27<16 && defined(__ARMEL__) + vrev64.8 , +#endif + veor d25,d24 + vbsl d29,d18,d19 @ Ch(e,f,g) + vshr.u64 d24,d21,#28 + veor d26,d25 @ Sigma1(e) + vadd.i64 d27,d29,d20 + vshr.u64 d25,d21,#34 + vsli.64 d24,d21,#36 + vadd.i64 d27,d26 + vshr.u64 d26,d21,#39 + vadd.i64 d28,d11 + vsli.64 d25,d21,#30 + veor d30,d21,d22 + vsli.64 d26,d21,#25 + veor d20,d24,d25 + vadd.i64 d27,d28 + vbsl d30,d23,d22 @ Maj(a,b,c) + veor d20,d26 @ Sigma0(a) + vadd.i64 d16,d27 + vadd.i64 d30,d27 + @ vadd.i64 d20,d30 + vshr.u64 q12,q5,#19 + vshr.u64 q13,q5,#61 + vadd.i64 d20,d30 @ h+=Maj from the past + vshr.u64 q15,q5,#6 + vsli.64 q12,q5,#45 + vext.8 q14,q6,q7,#8 @ X[i+1] + vsli.64 q13,q5,#3 + veor q15,q12 + vshr.u64 q12,q14,#1 + veor q15,q13 @ sigma1(X[i+14]) + vshr.u64 q13,q14,#8 + vadd.i64 q6,q15 + vshr.u64 q15,q14,#7 + vsli.64 q12,q14,#63 + vsli.64 q13,q14,#56 + vext.8 q14,q2,q3,#8 @ X[i+9] + veor q15,q12 + vshr.u64 d24,d16,#14 @ from NEON_00_15 + vadd.i64 q6,q14 + vshr.u64 d25,d16,#18 @ from NEON_00_15 + veor q15,q13 @ sigma0(X[i+1]) + vshr.u64 d26,d16,#41 @ from NEON_00_15 + vadd.i64 q6,q15 + vld1.64 {d28},[r3,:64]! @ K[i++] + vsli.64 d24,d16,#50 + vsli.64 d25,d16,#46 + vmov d29,d16 + vsli.64 d26,d16,#23 +#if 28<16 && defined(__ARMEL__) + vrev64.8 , +#endif + veor d25,d24 + vbsl d29,d17,d18 @ Ch(e,f,g) + vshr.u64 d24,d20,#28 + veor d26,d25 @ Sigma1(e) + vadd.i64 d27,d29,d19 + vshr.u64 d25,d20,#34 + vsli.64 d24,d20,#36 + vadd.i64 d27,d26 + vshr.u64 d26,d20,#39 + vadd.i64 d28,d12 + vsli.64 d25,d20,#30 + veor d30,d20,d21 + vsli.64 d26,d20,#25 + veor d19,d24,d25 + vadd.i64 d27,d28 + vbsl d30,d22,d21 @ Maj(a,b,c) + veor d19,d26 @ Sigma0(a) + vadd.i64 d23,d27 + vadd.i64 d30,d27 + @ vadd.i64 d19,d30 + vshr.u64 d24,d23,#14 @ 29 +#if 29<16 + vld1.64 {d13},[r1]! @ handles unaligned +#endif + vshr.u64 d25,d23,#18 +#if 29>0 + vadd.i64 d19,d30 @ h+=Maj from the past +#endif + vshr.u64 d26,d23,#41 + vld1.64 {d28},[r3,:64]! @ K[i++] + vsli.64 d24,d23,#50 + vsli.64 d25,d23,#46 + vmov d29,d23 + vsli.64 d26,d23,#23 +#if 29<16 && defined(__ARMEL__) + vrev64.8 , +#endif + veor d25,d24 + vbsl d29,d16,d17 @ Ch(e,f,g) + vshr.u64 d24,d19,#28 + veor d26,d25 @ Sigma1(e) + vadd.i64 d27,d29,d18 + vshr.u64 d25,d19,#34 + vsli.64 d24,d19,#36 + vadd.i64 d27,d26 + vshr.u64 d26,d19,#39 + vadd.i64 d28,d13 + vsli.64 d25,d19,#30 + veor d30,d19,d20 + vsli.64 d26,d19,#25 + veor d18,d24,d25 + vadd.i64 d27,d28 + vbsl d30,d21,d20 @ Maj(a,b,c) + veor d18,d26 @ Sigma0(a) + vadd.i64 d22,d27 + vadd.i64 d30,d27 + @ vadd.i64 d18,d30 + vshr.u64 q12,q6,#19 + vshr.u64 q13,q6,#61 + vadd.i64 d18,d30 @ h+=Maj from the past + vshr.u64 q15,q6,#6 + vsli.64 q12,q6,#45 + vext.8 q14,q7,q0,#8 @ X[i+1] + vsli.64 q13,q6,#3 + veor q15,q12 + vshr.u64 q12,q14,#1 + veor q15,q13 @ sigma1(X[i+14]) + vshr.u64 q13,q14,#8 + vadd.i64 q7,q15 + vshr.u64 q15,q14,#7 + vsli.64 q12,q14,#63 + vsli.64 q13,q14,#56 + vext.8 q14,q3,q4,#8 @ X[i+9] + veor q15,q12 + vshr.u64 d24,d22,#14 @ from NEON_00_15 + vadd.i64 q7,q14 + vshr.u64 d25,d22,#18 @ from NEON_00_15 + veor q15,q13 @ sigma0(X[i+1]) + vshr.u64 d26,d22,#41 @ from NEON_00_15 + vadd.i64 q7,q15 + vld1.64 {d28},[r3,:64]! @ K[i++] + vsli.64 d24,d22,#50 + vsli.64 d25,d22,#46 + vmov d29,d22 + vsli.64 d26,d22,#23 +#if 30<16 && defined(__ARMEL__) + vrev64.8 , +#endif + veor d25,d24 + vbsl d29,d23,d16 @ Ch(e,f,g) + vshr.u64 d24,d18,#28 + veor d26,d25 @ Sigma1(e) + vadd.i64 d27,d29,d17 + vshr.u64 d25,d18,#34 + vsli.64 d24,d18,#36 + vadd.i64 d27,d26 + vshr.u64 d26,d18,#39 + vadd.i64 d28,d14 + vsli.64 d25,d18,#30 + veor d30,d18,d19 + vsli.64 d26,d18,#25 + veor d17,d24,d25 + vadd.i64 d27,d28 + vbsl d30,d20,d19 @ Maj(a,b,c) + veor d17,d26 @ Sigma0(a) + vadd.i64 d21,d27 + vadd.i64 d30,d27 + @ vadd.i64 d17,d30 + vshr.u64 d24,d21,#14 @ 31 +#if 31<16 + vld1.64 {d15},[r1]! @ handles unaligned +#endif + vshr.u64 d25,d21,#18 +#if 31>0 + vadd.i64 d17,d30 @ h+=Maj from the past +#endif + vshr.u64 d26,d21,#41 + vld1.64 {d28},[r3,:64]! @ K[i++] + vsli.64 d24,d21,#50 + vsli.64 d25,d21,#46 + vmov d29,d21 + vsli.64 d26,d21,#23 +#if 31<16 && defined(__ARMEL__) + vrev64.8 , +#endif + veor d25,d24 + vbsl d29,d22,d23 @ Ch(e,f,g) + vshr.u64 d24,d17,#28 + veor d26,d25 @ Sigma1(e) + vadd.i64 d27,d29,d16 + vshr.u64 d25,d17,#34 + vsli.64 d24,d17,#36 + vadd.i64 d27,d26 + vshr.u64 d26,d17,#39 + vadd.i64 d28,d15 + vsli.64 d25,d17,#30 + veor d30,d17,d18 + vsli.64 d26,d17,#25 + veor d16,d24,d25 + vadd.i64 d27,d28 + vbsl d30,d19,d18 @ Maj(a,b,c) + veor d16,d26 @ Sigma0(a) + vadd.i64 d20,d27 + vadd.i64 d30,d27 + @ vadd.i64 d16,d30 + bne .L16_79_neon + + vadd.i64 d16,d30 @ h+=Maj from the past + vldmia r0,{d24,d25,d26,d27,d28,d29,d30,d31} @ load context to temp + vadd.i64 q8,q12 @ vectorized accumulate + vadd.i64 q9,q13 + vadd.i64 q10,q14 + vadd.i64 q11,q15 + vstmia r0,{d16,d17,d18,d19,d20,d21,d22,d23} @ save context + teq r1,r2 + sub r3,#640 @ rewind K512 + bne .Loop_neon + + VFP_ABI_POP + bx lr @ .word 0xe12fff1e +.size sha512_block_data_order_neon,.-sha512_block_data_order_neon +#endif +.byte 83,72,65,53,49,50,32,98,108,111,99,107,32,116,114,97,110,115,102,111,114,109,32,102,111,114,32,65,82,77,118,52,47,78,69,79,78,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.align 2 +.align 2 +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_ARM) && defined(__ELF__) diff --git a/http/vendor/ring/pregenerated/sha512-armv8-ios64.S b/http/vendor/ring/pregenerated/sha512-armv8-ios64.S new file mode 100644 index 0000000..06745ec --- /dev/null +++ b/http/vendor/ring/pregenerated/sha512-armv8-ios64.S @@ -0,0 +1,1598 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__APPLE__) +// Copyright 2014-2020 The OpenSSL Project Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// ==================================================================== +// Written by Andy Polyakov for the OpenSSL +// project. +// ==================================================================== +// +// SHA256/512 for ARMv8. +// +// Performance in cycles per processed byte and improvement coefficient +// over code generated with "default" compiler: +// +// SHA256-hw SHA256(*) SHA512 +// Apple A7 1.97 10.5 (+33%) 6.73 (-1%(**)) +// Cortex-A53 2.38 15.5 (+115%) 10.0 (+150%(***)) +// Cortex-A57 2.31 11.6 (+86%) 7.51 (+260%(***)) +// Denver 2.01 10.5 (+26%) 6.70 (+8%) +// X-Gene 20.0 (+100%) 12.8 (+300%(***)) +// Mongoose 2.36 13.0 (+50%) 8.36 (+33%) +// Kryo 1.92 17.4 (+30%) 11.2 (+8%) +// +// (*) Software SHA256 results are of lesser relevance, presented +// mostly for informational purposes. +// (**) The result is a trade-off: it's possible to improve it by +// 10% (or by 1 cycle per round), but at the cost of 20% loss +// on Cortex-A53 (or by 4 cycles per round). +// (***) Super-impressive coefficients over gcc-generated code are +// indication of some compiler "pathology", most notably code +// generated with -mgeneral-regs-only is significantly faster +// and the gap is only 40-90%. + +#ifndef __KERNEL__ +#endif + +.text + +.globl _sha512_block_data_order_nohw +.private_extern _sha512_block_data_order_nohw + +.align 6 +_sha512_block_data_order_nohw: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-128]! + add x29,sp,#0 + + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + stp x27,x28,[sp,#80] + sub sp,sp,#4*8 + + ldp x20,x21,[x0] // load context + ldp x22,x23,[x0,#2*8] + ldp x24,x25,[x0,#4*8] + add x2,x1,x2,lsl#7 // end of input + ldp x26,x27,[x0,#6*8] + adrp x30,LK512@PAGE + add x30,x30,LK512@PAGEOFF + stp x0,x2,[x29,#96] + +Loop: + ldp x3,x4,[x1],#2*8 + ldr x19,[x30],#8 // *K++ + eor x28,x21,x22 // magic seed + str x1,[x29,#112] +#ifndef __AARCH64EB__ + rev x3,x3 // 0 +#endif + ror x16,x24,#14 + add x27,x27,x19 // h+=K[i] + eor x6,x24,x24,ror#23 + and x17,x25,x24 + bic x19,x26,x24 + add x27,x27,x3 // h+=X[i] + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x20,x21 // a^b, b^c in next round + eor x16,x16,x6,ror#18 // Sigma1(e) + ror x6,x20,#28 + add x27,x27,x17 // h+=Ch(e,f,g) + eor x17,x20,x20,ror#5 + add x27,x27,x16 // h+=Sigma1(e) + and x28,x28,x19 // (b^c)&=(a^b) + add x23,x23,x27 // d+=h + eor x28,x28,x21 // Maj(a,b,c) + eor x17,x6,x17,ror#34 // Sigma0(a) + add x27,x27,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + //add x27,x27,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x4,x4 // 1 +#endif + ldp x5,x6,[x1],#2*8 + add x27,x27,x17 // h+=Sigma0(a) + ror x16,x23,#14 + add x26,x26,x28 // h+=K[i] + eor x7,x23,x23,ror#23 + and x17,x24,x23 + bic x28,x25,x23 + add x26,x26,x4 // h+=X[i] + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x27,x20 // a^b, b^c in next round + eor x16,x16,x7,ror#18 // Sigma1(e) + ror x7,x27,#28 + add x26,x26,x17 // h+=Ch(e,f,g) + eor x17,x27,x27,ror#5 + add x26,x26,x16 // h+=Sigma1(e) + and x19,x19,x28 // (b^c)&=(a^b) + add x22,x22,x26 // d+=h + eor x19,x19,x20 // Maj(a,b,c) + eor x17,x7,x17,ror#34 // Sigma0(a) + add x26,x26,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + //add x26,x26,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x5,x5 // 2 +#endif + add x26,x26,x17 // h+=Sigma0(a) + ror x16,x22,#14 + add x25,x25,x19 // h+=K[i] + eor x8,x22,x22,ror#23 + and x17,x23,x22 + bic x19,x24,x22 + add x25,x25,x5 // h+=X[i] + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x26,x27 // a^b, b^c in next round + eor x16,x16,x8,ror#18 // Sigma1(e) + ror x8,x26,#28 + add x25,x25,x17 // h+=Ch(e,f,g) + eor x17,x26,x26,ror#5 + add x25,x25,x16 // h+=Sigma1(e) + and x28,x28,x19 // (b^c)&=(a^b) + add x21,x21,x25 // d+=h + eor x28,x28,x27 // Maj(a,b,c) + eor x17,x8,x17,ror#34 // Sigma0(a) + add x25,x25,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + //add x25,x25,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x6,x6 // 3 +#endif + ldp x7,x8,[x1],#2*8 + add x25,x25,x17 // h+=Sigma0(a) + ror x16,x21,#14 + add x24,x24,x28 // h+=K[i] + eor x9,x21,x21,ror#23 + and x17,x22,x21 + bic x28,x23,x21 + add x24,x24,x6 // h+=X[i] + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x25,x26 // a^b, b^c in next round + eor x16,x16,x9,ror#18 // Sigma1(e) + ror x9,x25,#28 + add x24,x24,x17 // h+=Ch(e,f,g) + eor x17,x25,x25,ror#5 + add x24,x24,x16 // h+=Sigma1(e) + and x19,x19,x28 // (b^c)&=(a^b) + add x20,x20,x24 // d+=h + eor x19,x19,x26 // Maj(a,b,c) + eor x17,x9,x17,ror#34 // Sigma0(a) + add x24,x24,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + //add x24,x24,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x7,x7 // 4 +#endif + add x24,x24,x17 // h+=Sigma0(a) + ror x16,x20,#14 + add x23,x23,x19 // h+=K[i] + eor x10,x20,x20,ror#23 + and x17,x21,x20 + bic x19,x22,x20 + add x23,x23,x7 // h+=X[i] + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x24,x25 // a^b, b^c in next round + eor x16,x16,x10,ror#18 // Sigma1(e) + ror x10,x24,#28 + add x23,x23,x17 // h+=Ch(e,f,g) + eor x17,x24,x24,ror#5 + add x23,x23,x16 // h+=Sigma1(e) + and x28,x28,x19 // (b^c)&=(a^b) + add x27,x27,x23 // d+=h + eor x28,x28,x25 // Maj(a,b,c) + eor x17,x10,x17,ror#34 // Sigma0(a) + add x23,x23,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + //add x23,x23,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x8,x8 // 5 +#endif + ldp x9,x10,[x1],#2*8 + add x23,x23,x17 // h+=Sigma0(a) + ror x16,x27,#14 + add x22,x22,x28 // h+=K[i] + eor x11,x27,x27,ror#23 + and x17,x20,x27 + bic x28,x21,x27 + add x22,x22,x8 // h+=X[i] + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x23,x24 // a^b, b^c in next round + eor x16,x16,x11,ror#18 // Sigma1(e) + ror x11,x23,#28 + add x22,x22,x17 // h+=Ch(e,f,g) + eor x17,x23,x23,ror#5 + add x22,x22,x16 // h+=Sigma1(e) + and x19,x19,x28 // (b^c)&=(a^b) + add x26,x26,x22 // d+=h + eor x19,x19,x24 // Maj(a,b,c) + eor x17,x11,x17,ror#34 // Sigma0(a) + add x22,x22,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + //add x22,x22,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x9,x9 // 6 +#endif + add x22,x22,x17 // h+=Sigma0(a) + ror x16,x26,#14 + add x21,x21,x19 // h+=K[i] + eor x12,x26,x26,ror#23 + and x17,x27,x26 + bic x19,x20,x26 + add x21,x21,x9 // h+=X[i] + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x22,x23 // a^b, b^c in next round + eor x16,x16,x12,ror#18 // Sigma1(e) + ror x12,x22,#28 + add x21,x21,x17 // h+=Ch(e,f,g) + eor x17,x22,x22,ror#5 + add x21,x21,x16 // h+=Sigma1(e) + and x28,x28,x19 // (b^c)&=(a^b) + add x25,x25,x21 // d+=h + eor x28,x28,x23 // Maj(a,b,c) + eor x17,x12,x17,ror#34 // Sigma0(a) + add x21,x21,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + //add x21,x21,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x10,x10 // 7 +#endif + ldp x11,x12,[x1],#2*8 + add x21,x21,x17 // h+=Sigma0(a) + ror x16,x25,#14 + add x20,x20,x28 // h+=K[i] + eor x13,x25,x25,ror#23 + and x17,x26,x25 + bic x28,x27,x25 + add x20,x20,x10 // h+=X[i] + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x21,x22 // a^b, b^c in next round + eor x16,x16,x13,ror#18 // Sigma1(e) + ror x13,x21,#28 + add x20,x20,x17 // h+=Ch(e,f,g) + eor x17,x21,x21,ror#5 + add x20,x20,x16 // h+=Sigma1(e) + and x19,x19,x28 // (b^c)&=(a^b) + add x24,x24,x20 // d+=h + eor x19,x19,x22 // Maj(a,b,c) + eor x17,x13,x17,ror#34 // Sigma0(a) + add x20,x20,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + //add x20,x20,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x11,x11 // 8 +#endif + add x20,x20,x17 // h+=Sigma0(a) + ror x16,x24,#14 + add x27,x27,x19 // h+=K[i] + eor x14,x24,x24,ror#23 + and x17,x25,x24 + bic x19,x26,x24 + add x27,x27,x11 // h+=X[i] + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x20,x21 // a^b, b^c in next round + eor x16,x16,x14,ror#18 // Sigma1(e) + ror x14,x20,#28 + add x27,x27,x17 // h+=Ch(e,f,g) + eor x17,x20,x20,ror#5 + add x27,x27,x16 // h+=Sigma1(e) + and x28,x28,x19 // (b^c)&=(a^b) + add x23,x23,x27 // d+=h + eor x28,x28,x21 // Maj(a,b,c) + eor x17,x14,x17,ror#34 // Sigma0(a) + add x27,x27,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + //add x27,x27,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x12,x12 // 9 +#endif + ldp x13,x14,[x1],#2*8 + add x27,x27,x17 // h+=Sigma0(a) + ror x16,x23,#14 + add x26,x26,x28 // h+=K[i] + eor x15,x23,x23,ror#23 + and x17,x24,x23 + bic x28,x25,x23 + add x26,x26,x12 // h+=X[i] + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x27,x20 // a^b, b^c in next round + eor x16,x16,x15,ror#18 // Sigma1(e) + ror x15,x27,#28 + add x26,x26,x17 // h+=Ch(e,f,g) + eor x17,x27,x27,ror#5 + add x26,x26,x16 // h+=Sigma1(e) + and x19,x19,x28 // (b^c)&=(a^b) + add x22,x22,x26 // d+=h + eor x19,x19,x20 // Maj(a,b,c) + eor x17,x15,x17,ror#34 // Sigma0(a) + add x26,x26,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + //add x26,x26,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x13,x13 // 10 +#endif + add x26,x26,x17 // h+=Sigma0(a) + ror x16,x22,#14 + add x25,x25,x19 // h+=K[i] + eor x0,x22,x22,ror#23 + and x17,x23,x22 + bic x19,x24,x22 + add x25,x25,x13 // h+=X[i] + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x26,x27 // a^b, b^c in next round + eor x16,x16,x0,ror#18 // Sigma1(e) + ror x0,x26,#28 + add x25,x25,x17 // h+=Ch(e,f,g) + eor x17,x26,x26,ror#5 + add x25,x25,x16 // h+=Sigma1(e) + and x28,x28,x19 // (b^c)&=(a^b) + add x21,x21,x25 // d+=h + eor x28,x28,x27 // Maj(a,b,c) + eor x17,x0,x17,ror#34 // Sigma0(a) + add x25,x25,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + //add x25,x25,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x14,x14 // 11 +#endif + ldp x15,x0,[x1],#2*8 + add x25,x25,x17 // h+=Sigma0(a) + str x6,[sp,#24] + ror x16,x21,#14 + add x24,x24,x28 // h+=K[i] + eor x6,x21,x21,ror#23 + and x17,x22,x21 + bic x28,x23,x21 + add x24,x24,x14 // h+=X[i] + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x25,x26 // a^b, b^c in next round + eor x16,x16,x6,ror#18 // Sigma1(e) + ror x6,x25,#28 + add x24,x24,x17 // h+=Ch(e,f,g) + eor x17,x25,x25,ror#5 + add x24,x24,x16 // h+=Sigma1(e) + and x19,x19,x28 // (b^c)&=(a^b) + add x20,x20,x24 // d+=h + eor x19,x19,x26 // Maj(a,b,c) + eor x17,x6,x17,ror#34 // Sigma0(a) + add x24,x24,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + //add x24,x24,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x15,x15 // 12 +#endif + add x24,x24,x17 // h+=Sigma0(a) + str x7,[sp,#0] + ror x16,x20,#14 + add x23,x23,x19 // h+=K[i] + eor x7,x20,x20,ror#23 + and x17,x21,x20 + bic x19,x22,x20 + add x23,x23,x15 // h+=X[i] + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x24,x25 // a^b, b^c in next round + eor x16,x16,x7,ror#18 // Sigma1(e) + ror x7,x24,#28 + add x23,x23,x17 // h+=Ch(e,f,g) + eor x17,x24,x24,ror#5 + add x23,x23,x16 // h+=Sigma1(e) + and x28,x28,x19 // (b^c)&=(a^b) + add x27,x27,x23 // d+=h + eor x28,x28,x25 // Maj(a,b,c) + eor x17,x7,x17,ror#34 // Sigma0(a) + add x23,x23,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + //add x23,x23,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x0,x0 // 13 +#endif + ldp x1,x2,[x1] + add x23,x23,x17 // h+=Sigma0(a) + str x8,[sp,#8] + ror x16,x27,#14 + add x22,x22,x28 // h+=K[i] + eor x8,x27,x27,ror#23 + and x17,x20,x27 + bic x28,x21,x27 + add x22,x22,x0 // h+=X[i] + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x23,x24 // a^b, b^c in next round + eor x16,x16,x8,ror#18 // Sigma1(e) + ror x8,x23,#28 + add x22,x22,x17 // h+=Ch(e,f,g) + eor x17,x23,x23,ror#5 + add x22,x22,x16 // h+=Sigma1(e) + and x19,x19,x28 // (b^c)&=(a^b) + add x26,x26,x22 // d+=h + eor x19,x19,x24 // Maj(a,b,c) + eor x17,x8,x17,ror#34 // Sigma0(a) + add x22,x22,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + //add x22,x22,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x1,x1 // 14 +#endif + ldr x6,[sp,#24] + add x22,x22,x17 // h+=Sigma0(a) + str x9,[sp,#16] + ror x16,x26,#14 + add x21,x21,x19 // h+=K[i] + eor x9,x26,x26,ror#23 + and x17,x27,x26 + bic x19,x20,x26 + add x21,x21,x1 // h+=X[i] + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x22,x23 // a^b, b^c in next round + eor x16,x16,x9,ror#18 // Sigma1(e) + ror x9,x22,#28 + add x21,x21,x17 // h+=Ch(e,f,g) + eor x17,x22,x22,ror#5 + add x21,x21,x16 // h+=Sigma1(e) + and x28,x28,x19 // (b^c)&=(a^b) + add x25,x25,x21 // d+=h + eor x28,x28,x23 // Maj(a,b,c) + eor x17,x9,x17,ror#34 // Sigma0(a) + add x21,x21,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + //add x21,x21,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x2,x2 // 15 +#endif + ldr x7,[sp,#0] + add x21,x21,x17 // h+=Sigma0(a) + str x10,[sp,#24] + ror x16,x25,#14 + add x20,x20,x28 // h+=K[i] + ror x9,x4,#1 + and x17,x26,x25 + ror x8,x1,#19 + bic x28,x27,x25 + ror x10,x21,#28 + add x20,x20,x2 // h+=X[i] + eor x16,x16,x25,ror#18 + eor x9,x9,x4,ror#8 + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x21,x22 // a^b, b^c in next round + eor x16,x16,x25,ror#41 // Sigma1(e) + eor x10,x10,x21,ror#34 + add x20,x20,x17 // h+=Ch(e,f,g) + and x19,x19,x28 // (b^c)&=(a^b) + eor x8,x8,x1,ror#61 + eor x9,x9,x4,lsr#7 // sigma0(X[i+1]) + add x20,x20,x16 // h+=Sigma1(e) + eor x19,x19,x22 // Maj(a,b,c) + eor x17,x10,x21,ror#39 // Sigma0(a) + eor x8,x8,x1,lsr#6 // sigma1(X[i+14]) + add x3,x3,x12 + add x24,x24,x20 // d+=h + add x20,x20,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + add x3,x3,x9 + add x20,x20,x17 // h+=Sigma0(a) + add x3,x3,x8 +Loop_16_xx: + ldr x8,[sp,#8] + str x11,[sp,#0] + ror x16,x24,#14 + add x27,x27,x19 // h+=K[i] + ror x10,x5,#1 + and x17,x25,x24 + ror x9,x2,#19 + bic x19,x26,x24 + ror x11,x20,#28 + add x27,x27,x3 // h+=X[i] + eor x16,x16,x24,ror#18 + eor x10,x10,x5,ror#8 + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x20,x21 // a^b, b^c in next round + eor x16,x16,x24,ror#41 // Sigma1(e) + eor x11,x11,x20,ror#34 + add x27,x27,x17 // h+=Ch(e,f,g) + and x28,x28,x19 // (b^c)&=(a^b) + eor x9,x9,x2,ror#61 + eor x10,x10,x5,lsr#7 // sigma0(X[i+1]) + add x27,x27,x16 // h+=Sigma1(e) + eor x28,x28,x21 // Maj(a,b,c) + eor x17,x11,x20,ror#39 // Sigma0(a) + eor x9,x9,x2,lsr#6 // sigma1(X[i+14]) + add x4,x4,x13 + add x23,x23,x27 // d+=h + add x27,x27,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + add x4,x4,x10 + add x27,x27,x17 // h+=Sigma0(a) + add x4,x4,x9 + ldr x9,[sp,#16] + str x12,[sp,#8] + ror x16,x23,#14 + add x26,x26,x28 // h+=K[i] + ror x11,x6,#1 + and x17,x24,x23 + ror x10,x3,#19 + bic x28,x25,x23 + ror x12,x27,#28 + add x26,x26,x4 // h+=X[i] + eor x16,x16,x23,ror#18 + eor x11,x11,x6,ror#8 + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x27,x20 // a^b, b^c in next round + eor x16,x16,x23,ror#41 // Sigma1(e) + eor x12,x12,x27,ror#34 + add x26,x26,x17 // h+=Ch(e,f,g) + and x19,x19,x28 // (b^c)&=(a^b) + eor x10,x10,x3,ror#61 + eor x11,x11,x6,lsr#7 // sigma0(X[i+1]) + add x26,x26,x16 // h+=Sigma1(e) + eor x19,x19,x20 // Maj(a,b,c) + eor x17,x12,x27,ror#39 // Sigma0(a) + eor x10,x10,x3,lsr#6 // sigma1(X[i+14]) + add x5,x5,x14 + add x22,x22,x26 // d+=h + add x26,x26,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + add x5,x5,x11 + add x26,x26,x17 // h+=Sigma0(a) + add x5,x5,x10 + ldr x10,[sp,#24] + str x13,[sp,#16] + ror x16,x22,#14 + add x25,x25,x19 // h+=K[i] + ror x12,x7,#1 + and x17,x23,x22 + ror x11,x4,#19 + bic x19,x24,x22 + ror x13,x26,#28 + add x25,x25,x5 // h+=X[i] + eor x16,x16,x22,ror#18 + eor x12,x12,x7,ror#8 + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x26,x27 // a^b, b^c in next round + eor x16,x16,x22,ror#41 // Sigma1(e) + eor x13,x13,x26,ror#34 + add x25,x25,x17 // h+=Ch(e,f,g) + and x28,x28,x19 // (b^c)&=(a^b) + eor x11,x11,x4,ror#61 + eor x12,x12,x7,lsr#7 // sigma0(X[i+1]) + add x25,x25,x16 // h+=Sigma1(e) + eor x28,x28,x27 // Maj(a,b,c) + eor x17,x13,x26,ror#39 // Sigma0(a) + eor x11,x11,x4,lsr#6 // sigma1(X[i+14]) + add x6,x6,x15 + add x21,x21,x25 // d+=h + add x25,x25,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + add x6,x6,x12 + add x25,x25,x17 // h+=Sigma0(a) + add x6,x6,x11 + ldr x11,[sp,#0] + str x14,[sp,#24] + ror x16,x21,#14 + add x24,x24,x28 // h+=K[i] + ror x13,x8,#1 + and x17,x22,x21 + ror x12,x5,#19 + bic x28,x23,x21 + ror x14,x25,#28 + add x24,x24,x6 // h+=X[i] + eor x16,x16,x21,ror#18 + eor x13,x13,x8,ror#8 + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x25,x26 // a^b, b^c in next round + eor x16,x16,x21,ror#41 // Sigma1(e) + eor x14,x14,x25,ror#34 + add x24,x24,x17 // h+=Ch(e,f,g) + and x19,x19,x28 // (b^c)&=(a^b) + eor x12,x12,x5,ror#61 + eor x13,x13,x8,lsr#7 // sigma0(X[i+1]) + add x24,x24,x16 // h+=Sigma1(e) + eor x19,x19,x26 // Maj(a,b,c) + eor x17,x14,x25,ror#39 // Sigma0(a) + eor x12,x12,x5,lsr#6 // sigma1(X[i+14]) + add x7,x7,x0 + add x20,x20,x24 // d+=h + add x24,x24,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + add x7,x7,x13 + add x24,x24,x17 // h+=Sigma0(a) + add x7,x7,x12 + ldr x12,[sp,#8] + str x15,[sp,#0] + ror x16,x20,#14 + add x23,x23,x19 // h+=K[i] + ror x14,x9,#1 + and x17,x21,x20 + ror x13,x6,#19 + bic x19,x22,x20 + ror x15,x24,#28 + add x23,x23,x7 // h+=X[i] + eor x16,x16,x20,ror#18 + eor x14,x14,x9,ror#8 + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x24,x25 // a^b, b^c in next round + eor x16,x16,x20,ror#41 // Sigma1(e) + eor x15,x15,x24,ror#34 + add x23,x23,x17 // h+=Ch(e,f,g) + and x28,x28,x19 // (b^c)&=(a^b) + eor x13,x13,x6,ror#61 + eor x14,x14,x9,lsr#7 // sigma0(X[i+1]) + add x23,x23,x16 // h+=Sigma1(e) + eor x28,x28,x25 // Maj(a,b,c) + eor x17,x15,x24,ror#39 // Sigma0(a) + eor x13,x13,x6,lsr#6 // sigma1(X[i+14]) + add x8,x8,x1 + add x27,x27,x23 // d+=h + add x23,x23,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + add x8,x8,x14 + add x23,x23,x17 // h+=Sigma0(a) + add x8,x8,x13 + ldr x13,[sp,#16] + str x0,[sp,#8] + ror x16,x27,#14 + add x22,x22,x28 // h+=K[i] + ror x15,x10,#1 + and x17,x20,x27 + ror x14,x7,#19 + bic x28,x21,x27 + ror x0,x23,#28 + add x22,x22,x8 // h+=X[i] + eor x16,x16,x27,ror#18 + eor x15,x15,x10,ror#8 + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x23,x24 // a^b, b^c in next round + eor x16,x16,x27,ror#41 // Sigma1(e) + eor x0,x0,x23,ror#34 + add x22,x22,x17 // h+=Ch(e,f,g) + and x19,x19,x28 // (b^c)&=(a^b) + eor x14,x14,x7,ror#61 + eor x15,x15,x10,lsr#7 // sigma0(X[i+1]) + add x22,x22,x16 // h+=Sigma1(e) + eor x19,x19,x24 // Maj(a,b,c) + eor x17,x0,x23,ror#39 // Sigma0(a) + eor x14,x14,x7,lsr#6 // sigma1(X[i+14]) + add x9,x9,x2 + add x26,x26,x22 // d+=h + add x22,x22,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + add x9,x9,x15 + add x22,x22,x17 // h+=Sigma0(a) + add x9,x9,x14 + ldr x14,[sp,#24] + str x1,[sp,#16] + ror x16,x26,#14 + add x21,x21,x19 // h+=K[i] + ror x0,x11,#1 + and x17,x27,x26 + ror x15,x8,#19 + bic x19,x20,x26 + ror x1,x22,#28 + add x21,x21,x9 // h+=X[i] + eor x16,x16,x26,ror#18 + eor x0,x0,x11,ror#8 + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x22,x23 // a^b, b^c in next round + eor x16,x16,x26,ror#41 // Sigma1(e) + eor x1,x1,x22,ror#34 + add x21,x21,x17 // h+=Ch(e,f,g) + and x28,x28,x19 // (b^c)&=(a^b) + eor x15,x15,x8,ror#61 + eor x0,x0,x11,lsr#7 // sigma0(X[i+1]) + add x21,x21,x16 // h+=Sigma1(e) + eor x28,x28,x23 // Maj(a,b,c) + eor x17,x1,x22,ror#39 // Sigma0(a) + eor x15,x15,x8,lsr#6 // sigma1(X[i+14]) + add x10,x10,x3 + add x25,x25,x21 // d+=h + add x21,x21,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + add x10,x10,x0 + add x21,x21,x17 // h+=Sigma0(a) + add x10,x10,x15 + ldr x15,[sp,#0] + str x2,[sp,#24] + ror x16,x25,#14 + add x20,x20,x28 // h+=K[i] + ror x1,x12,#1 + and x17,x26,x25 + ror x0,x9,#19 + bic x28,x27,x25 + ror x2,x21,#28 + add x20,x20,x10 // h+=X[i] + eor x16,x16,x25,ror#18 + eor x1,x1,x12,ror#8 + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x21,x22 // a^b, b^c in next round + eor x16,x16,x25,ror#41 // Sigma1(e) + eor x2,x2,x21,ror#34 + add x20,x20,x17 // h+=Ch(e,f,g) + and x19,x19,x28 // (b^c)&=(a^b) + eor x0,x0,x9,ror#61 + eor x1,x1,x12,lsr#7 // sigma0(X[i+1]) + add x20,x20,x16 // h+=Sigma1(e) + eor x19,x19,x22 // Maj(a,b,c) + eor x17,x2,x21,ror#39 // Sigma0(a) + eor x0,x0,x9,lsr#6 // sigma1(X[i+14]) + add x11,x11,x4 + add x24,x24,x20 // d+=h + add x20,x20,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + add x11,x11,x1 + add x20,x20,x17 // h+=Sigma0(a) + add x11,x11,x0 + ldr x0,[sp,#8] + str x3,[sp,#0] + ror x16,x24,#14 + add x27,x27,x19 // h+=K[i] + ror x2,x13,#1 + and x17,x25,x24 + ror x1,x10,#19 + bic x19,x26,x24 + ror x3,x20,#28 + add x27,x27,x11 // h+=X[i] + eor x16,x16,x24,ror#18 + eor x2,x2,x13,ror#8 + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x20,x21 // a^b, b^c in next round + eor x16,x16,x24,ror#41 // Sigma1(e) + eor x3,x3,x20,ror#34 + add x27,x27,x17 // h+=Ch(e,f,g) + and x28,x28,x19 // (b^c)&=(a^b) + eor x1,x1,x10,ror#61 + eor x2,x2,x13,lsr#7 // sigma0(X[i+1]) + add x27,x27,x16 // h+=Sigma1(e) + eor x28,x28,x21 // Maj(a,b,c) + eor x17,x3,x20,ror#39 // Sigma0(a) + eor x1,x1,x10,lsr#6 // sigma1(X[i+14]) + add x12,x12,x5 + add x23,x23,x27 // d+=h + add x27,x27,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + add x12,x12,x2 + add x27,x27,x17 // h+=Sigma0(a) + add x12,x12,x1 + ldr x1,[sp,#16] + str x4,[sp,#8] + ror x16,x23,#14 + add x26,x26,x28 // h+=K[i] + ror x3,x14,#1 + and x17,x24,x23 + ror x2,x11,#19 + bic x28,x25,x23 + ror x4,x27,#28 + add x26,x26,x12 // h+=X[i] + eor x16,x16,x23,ror#18 + eor x3,x3,x14,ror#8 + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x27,x20 // a^b, b^c in next round + eor x16,x16,x23,ror#41 // Sigma1(e) + eor x4,x4,x27,ror#34 + add x26,x26,x17 // h+=Ch(e,f,g) + and x19,x19,x28 // (b^c)&=(a^b) + eor x2,x2,x11,ror#61 + eor x3,x3,x14,lsr#7 // sigma0(X[i+1]) + add x26,x26,x16 // h+=Sigma1(e) + eor x19,x19,x20 // Maj(a,b,c) + eor x17,x4,x27,ror#39 // Sigma0(a) + eor x2,x2,x11,lsr#6 // sigma1(X[i+14]) + add x13,x13,x6 + add x22,x22,x26 // d+=h + add x26,x26,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + add x13,x13,x3 + add x26,x26,x17 // h+=Sigma0(a) + add x13,x13,x2 + ldr x2,[sp,#24] + str x5,[sp,#16] + ror x16,x22,#14 + add x25,x25,x19 // h+=K[i] + ror x4,x15,#1 + and x17,x23,x22 + ror x3,x12,#19 + bic x19,x24,x22 + ror x5,x26,#28 + add x25,x25,x13 // h+=X[i] + eor x16,x16,x22,ror#18 + eor x4,x4,x15,ror#8 + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x26,x27 // a^b, b^c in next round + eor x16,x16,x22,ror#41 // Sigma1(e) + eor x5,x5,x26,ror#34 + add x25,x25,x17 // h+=Ch(e,f,g) + and x28,x28,x19 // (b^c)&=(a^b) + eor x3,x3,x12,ror#61 + eor x4,x4,x15,lsr#7 // sigma0(X[i+1]) + add x25,x25,x16 // h+=Sigma1(e) + eor x28,x28,x27 // Maj(a,b,c) + eor x17,x5,x26,ror#39 // Sigma0(a) + eor x3,x3,x12,lsr#6 // sigma1(X[i+14]) + add x14,x14,x7 + add x21,x21,x25 // d+=h + add x25,x25,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + add x14,x14,x4 + add x25,x25,x17 // h+=Sigma0(a) + add x14,x14,x3 + ldr x3,[sp,#0] + str x6,[sp,#24] + ror x16,x21,#14 + add x24,x24,x28 // h+=K[i] + ror x5,x0,#1 + and x17,x22,x21 + ror x4,x13,#19 + bic x28,x23,x21 + ror x6,x25,#28 + add x24,x24,x14 // h+=X[i] + eor x16,x16,x21,ror#18 + eor x5,x5,x0,ror#8 + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x25,x26 // a^b, b^c in next round + eor x16,x16,x21,ror#41 // Sigma1(e) + eor x6,x6,x25,ror#34 + add x24,x24,x17 // h+=Ch(e,f,g) + and x19,x19,x28 // (b^c)&=(a^b) + eor x4,x4,x13,ror#61 + eor x5,x5,x0,lsr#7 // sigma0(X[i+1]) + add x24,x24,x16 // h+=Sigma1(e) + eor x19,x19,x26 // Maj(a,b,c) + eor x17,x6,x25,ror#39 // Sigma0(a) + eor x4,x4,x13,lsr#6 // sigma1(X[i+14]) + add x15,x15,x8 + add x20,x20,x24 // d+=h + add x24,x24,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + add x15,x15,x5 + add x24,x24,x17 // h+=Sigma0(a) + add x15,x15,x4 + ldr x4,[sp,#8] + str x7,[sp,#0] + ror x16,x20,#14 + add x23,x23,x19 // h+=K[i] + ror x6,x1,#1 + and x17,x21,x20 + ror x5,x14,#19 + bic x19,x22,x20 + ror x7,x24,#28 + add x23,x23,x15 // h+=X[i] + eor x16,x16,x20,ror#18 + eor x6,x6,x1,ror#8 + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x24,x25 // a^b, b^c in next round + eor x16,x16,x20,ror#41 // Sigma1(e) + eor x7,x7,x24,ror#34 + add x23,x23,x17 // h+=Ch(e,f,g) + and x28,x28,x19 // (b^c)&=(a^b) + eor x5,x5,x14,ror#61 + eor x6,x6,x1,lsr#7 // sigma0(X[i+1]) + add x23,x23,x16 // h+=Sigma1(e) + eor x28,x28,x25 // Maj(a,b,c) + eor x17,x7,x24,ror#39 // Sigma0(a) + eor x5,x5,x14,lsr#6 // sigma1(X[i+14]) + add x0,x0,x9 + add x27,x27,x23 // d+=h + add x23,x23,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + add x0,x0,x6 + add x23,x23,x17 // h+=Sigma0(a) + add x0,x0,x5 + ldr x5,[sp,#16] + str x8,[sp,#8] + ror x16,x27,#14 + add x22,x22,x28 // h+=K[i] + ror x7,x2,#1 + and x17,x20,x27 + ror x6,x15,#19 + bic x28,x21,x27 + ror x8,x23,#28 + add x22,x22,x0 // h+=X[i] + eor x16,x16,x27,ror#18 + eor x7,x7,x2,ror#8 + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x23,x24 // a^b, b^c in next round + eor x16,x16,x27,ror#41 // Sigma1(e) + eor x8,x8,x23,ror#34 + add x22,x22,x17 // h+=Ch(e,f,g) + and x19,x19,x28 // (b^c)&=(a^b) + eor x6,x6,x15,ror#61 + eor x7,x7,x2,lsr#7 // sigma0(X[i+1]) + add x22,x22,x16 // h+=Sigma1(e) + eor x19,x19,x24 // Maj(a,b,c) + eor x17,x8,x23,ror#39 // Sigma0(a) + eor x6,x6,x15,lsr#6 // sigma1(X[i+14]) + add x1,x1,x10 + add x26,x26,x22 // d+=h + add x22,x22,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + add x1,x1,x7 + add x22,x22,x17 // h+=Sigma0(a) + add x1,x1,x6 + ldr x6,[sp,#24] + str x9,[sp,#16] + ror x16,x26,#14 + add x21,x21,x19 // h+=K[i] + ror x8,x3,#1 + and x17,x27,x26 + ror x7,x0,#19 + bic x19,x20,x26 + ror x9,x22,#28 + add x21,x21,x1 // h+=X[i] + eor x16,x16,x26,ror#18 + eor x8,x8,x3,ror#8 + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x22,x23 // a^b, b^c in next round + eor x16,x16,x26,ror#41 // Sigma1(e) + eor x9,x9,x22,ror#34 + add x21,x21,x17 // h+=Ch(e,f,g) + and x28,x28,x19 // (b^c)&=(a^b) + eor x7,x7,x0,ror#61 + eor x8,x8,x3,lsr#7 // sigma0(X[i+1]) + add x21,x21,x16 // h+=Sigma1(e) + eor x28,x28,x23 // Maj(a,b,c) + eor x17,x9,x22,ror#39 // Sigma0(a) + eor x7,x7,x0,lsr#6 // sigma1(X[i+14]) + add x2,x2,x11 + add x25,x25,x21 // d+=h + add x21,x21,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + add x2,x2,x8 + add x21,x21,x17 // h+=Sigma0(a) + add x2,x2,x7 + ldr x7,[sp,#0] + str x10,[sp,#24] + ror x16,x25,#14 + add x20,x20,x28 // h+=K[i] + ror x9,x4,#1 + and x17,x26,x25 + ror x8,x1,#19 + bic x28,x27,x25 + ror x10,x21,#28 + add x20,x20,x2 // h+=X[i] + eor x16,x16,x25,ror#18 + eor x9,x9,x4,ror#8 + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x21,x22 // a^b, b^c in next round + eor x16,x16,x25,ror#41 // Sigma1(e) + eor x10,x10,x21,ror#34 + add x20,x20,x17 // h+=Ch(e,f,g) + and x19,x19,x28 // (b^c)&=(a^b) + eor x8,x8,x1,ror#61 + eor x9,x9,x4,lsr#7 // sigma0(X[i+1]) + add x20,x20,x16 // h+=Sigma1(e) + eor x19,x19,x22 // Maj(a,b,c) + eor x17,x10,x21,ror#39 // Sigma0(a) + eor x8,x8,x1,lsr#6 // sigma1(X[i+14]) + add x3,x3,x12 + add x24,x24,x20 // d+=h + add x20,x20,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + add x3,x3,x9 + add x20,x20,x17 // h+=Sigma0(a) + add x3,x3,x8 + cbnz x19,Loop_16_xx + + ldp x0,x2,[x29,#96] + ldr x1,[x29,#112] + sub x30,x30,#648 // rewind + + ldp x3,x4,[x0] + ldp x5,x6,[x0,#2*8] + add x1,x1,#14*8 // advance input pointer + ldp x7,x8,[x0,#4*8] + add x20,x20,x3 + ldp x9,x10,[x0,#6*8] + add x21,x21,x4 + add x22,x22,x5 + add x23,x23,x6 + stp x20,x21,[x0] + add x24,x24,x7 + add x25,x25,x8 + stp x22,x23,[x0,#2*8] + add x26,x26,x9 + add x27,x27,x10 + cmp x1,x2 + stp x24,x25,[x0,#4*8] + stp x26,x27,[x0,#6*8] + b.ne Loop + + ldp x19,x20,[x29,#16] + add sp,sp,#4*8 + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldp x29,x30,[sp],#128 + AARCH64_VALIDATE_LINK_REGISTER + ret + + +.section __TEXT,__const +.align 6 + +LK512: +.quad 0x428a2f98d728ae22,0x7137449123ef65cd +.quad 0xb5c0fbcfec4d3b2f,0xe9b5dba58189dbbc +.quad 0x3956c25bf348b538,0x59f111f1b605d019 +.quad 0x923f82a4af194f9b,0xab1c5ed5da6d8118 +.quad 0xd807aa98a3030242,0x12835b0145706fbe +.quad 0x243185be4ee4b28c,0x550c7dc3d5ffb4e2 +.quad 0x72be5d74f27b896f,0x80deb1fe3b1696b1 +.quad 0x9bdc06a725c71235,0xc19bf174cf692694 +.quad 0xe49b69c19ef14ad2,0xefbe4786384f25e3 +.quad 0x0fc19dc68b8cd5b5,0x240ca1cc77ac9c65 +.quad 0x2de92c6f592b0275,0x4a7484aa6ea6e483 +.quad 0x5cb0a9dcbd41fbd4,0x76f988da831153b5 +.quad 0x983e5152ee66dfab,0xa831c66d2db43210 +.quad 0xb00327c898fb213f,0xbf597fc7beef0ee4 +.quad 0xc6e00bf33da88fc2,0xd5a79147930aa725 +.quad 0x06ca6351e003826f,0x142929670a0e6e70 +.quad 0x27b70a8546d22ffc,0x2e1b21385c26c926 +.quad 0x4d2c6dfc5ac42aed,0x53380d139d95b3df +.quad 0x650a73548baf63de,0x766a0abb3c77b2a8 +.quad 0x81c2c92e47edaee6,0x92722c851482353b +.quad 0xa2bfe8a14cf10364,0xa81a664bbc423001 +.quad 0xc24b8b70d0f89791,0xc76c51a30654be30 +.quad 0xd192e819d6ef5218,0xd69906245565a910 +.quad 0xf40e35855771202a,0x106aa07032bbd1b8 +.quad 0x19a4c116b8d2d0c8,0x1e376c085141ab53 +.quad 0x2748774cdf8eeb99,0x34b0bcb5e19b48a8 +.quad 0x391c0cb3c5c95a63,0x4ed8aa4ae3418acb +.quad 0x5b9cca4f7763e373,0x682e6ff3d6b2b8a3 +.quad 0x748f82ee5defb2fc,0x78a5636f43172f60 +.quad 0x84c87814a1f0ab72,0x8cc702081a6439ec +.quad 0x90befffa23631e28,0xa4506cebde82bde9 +.quad 0xbef9a3f7b2c67915,0xc67178f2e372532b +.quad 0xca273eceea26619c,0xd186b8c721c0c207 +.quad 0xeada7dd6cde0eb1e,0xf57d4f7fee6ed178 +.quad 0x06f067aa72176fba,0x0a637dc5a2c898a6 +.quad 0x113f9804bef90dae,0x1b710b35131c471b +.quad 0x28db77f523047d84,0x32caab7b40c72493 +.quad 0x3c9ebe0a15c9bebc,0x431d67c49c100d4c +.quad 0x4cc5d4becb3e42b6,0x597f299cfc657e2a +.quad 0x5fcb6fab3ad6faec,0x6c44198c4a475817 +.quad 0 // terminator + +.byte 83,72,65,53,49,50,32,98,108,111,99,107,32,116,114,97,110,115,102,111,114,109,32,102,111,114,32,65,82,77,118,56,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.align 2 +.align 2 +.text +#ifndef __KERNEL__ +.globl _sha512_block_data_order_hw +.private_extern _sha512_block_data_order_hw + +.align 6 +_sha512_block_data_order_hw: + // Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later. + AARCH64_VALID_CALL_TARGET + stp x29,x30,[sp,#-16]! + add x29,sp,#0 + + ld1 {v16.16b,v17.16b,v18.16b,v19.16b},[x1],#64 // load input + ld1 {v20.16b,v21.16b,v22.16b,v23.16b},[x1],#64 + + ld1 {v0.2d,v1.2d,v2.2d,v3.2d},[x0] // load context + adrp x3,LK512@PAGE + add x3,x3,LK512@PAGEOFF + + rev64 v16.16b,v16.16b + rev64 v17.16b,v17.16b + rev64 v18.16b,v18.16b + rev64 v19.16b,v19.16b + rev64 v20.16b,v20.16b + rev64 v21.16b,v21.16b + rev64 v22.16b,v22.16b + rev64 v23.16b,v23.16b + b Loop_hw + +.align 4 +Loop_hw: + ld1 {v24.2d},[x3],#16 + subs x2,x2,#1 + sub x4,x1,#128 + orr v26.16b,v0.16b,v0.16b // offload + orr v27.16b,v1.16b,v1.16b + orr v28.16b,v2.16b,v2.16b + orr v29.16b,v3.16b,v3.16b + csel x1,x1,x4,ne // conditional rewind + add v24.2d,v24.2d,v16.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v2.16b,v3.16b,#8 + ext v6.16b,v1.16b,v2.16b,#8 + add v3.2d,v3.2d,v24.2d // "T1 + H + K512[i]" +.long 0xcec08230 //sha512su0 v16.16b,v17.16b + ext v7.16b,v20.16b,v21.16b,#8 +.long 0xce6680a3 //sha512h v3.16b,v5.16b,v6.16b +.long 0xce678af0 //sha512su1 v16.16b,v23.16b,v7.16b + add v4.2d,v1.2d,v3.2d // "D + T1" +.long 0xce608423 //sha512h2 v3.16b,v1.16b,v0.16b + add v25.2d,v25.2d,v17.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v4.16b,v2.16b,#8 + ext v6.16b,v0.16b,v4.16b,#8 + add v2.2d,v2.2d,v25.2d // "T1 + H + K512[i]" +.long 0xcec08251 //sha512su0 v17.16b,v18.16b + ext v7.16b,v21.16b,v22.16b,#8 +.long 0xce6680a2 //sha512h v2.16b,v5.16b,v6.16b +.long 0xce678a11 //sha512su1 v17.16b,v16.16b,v7.16b + add v1.2d,v0.2d,v2.2d // "D + T1" +.long 0xce638402 //sha512h2 v2.16b,v0.16b,v3.16b + add v24.2d,v24.2d,v18.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v1.16b,v4.16b,#8 + ext v6.16b,v3.16b,v1.16b,#8 + add v4.2d,v4.2d,v24.2d // "T1 + H + K512[i]" +.long 0xcec08272 //sha512su0 v18.16b,v19.16b + ext v7.16b,v22.16b,v23.16b,#8 +.long 0xce6680a4 //sha512h v4.16b,v5.16b,v6.16b +.long 0xce678a32 //sha512su1 v18.16b,v17.16b,v7.16b + add v0.2d,v3.2d,v4.2d // "D + T1" +.long 0xce628464 //sha512h2 v4.16b,v3.16b,v2.16b + add v25.2d,v25.2d,v19.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v0.16b,v1.16b,#8 + ext v6.16b,v2.16b,v0.16b,#8 + add v1.2d,v1.2d,v25.2d // "T1 + H + K512[i]" +.long 0xcec08293 //sha512su0 v19.16b,v20.16b + ext v7.16b,v23.16b,v16.16b,#8 +.long 0xce6680a1 //sha512h v1.16b,v5.16b,v6.16b +.long 0xce678a53 //sha512su1 v19.16b,v18.16b,v7.16b + add v3.2d,v2.2d,v1.2d // "D + T1" +.long 0xce648441 //sha512h2 v1.16b,v2.16b,v4.16b + add v24.2d,v24.2d,v20.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v3.16b,v0.16b,#8 + ext v6.16b,v4.16b,v3.16b,#8 + add v0.2d,v0.2d,v24.2d // "T1 + H + K512[i]" +.long 0xcec082b4 //sha512su0 v20.16b,v21.16b + ext v7.16b,v16.16b,v17.16b,#8 +.long 0xce6680a0 //sha512h v0.16b,v5.16b,v6.16b +.long 0xce678a74 //sha512su1 v20.16b,v19.16b,v7.16b + add v2.2d,v4.2d,v0.2d // "D + T1" +.long 0xce618480 //sha512h2 v0.16b,v4.16b,v1.16b + add v25.2d,v25.2d,v21.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v2.16b,v3.16b,#8 + ext v6.16b,v1.16b,v2.16b,#8 + add v3.2d,v3.2d,v25.2d // "T1 + H + K512[i]" +.long 0xcec082d5 //sha512su0 v21.16b,v22.16b + ext v7.16b,v17.16b,v18.16b,#8 +.long 0xce6680a3 //sha512h v3.16b,v5.16b,v6.16b +.long 0xce678a95 //sha512su1 v21.16b,v20.16b,v7.16b + add v4.2d,v1.2d,v3.2d // "D + T1" +.long 0xce608423 //sha512h2 v3.16b,v1.16b,v0.16b + add v24.2d,v24.2d,v22.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v4.16b,v2.16b,#8 + ext v6.16b,v0.16b,v4.16b,#8 + add v2.2d,v2.2d,v24.2d // "T1 + H + K512[i]" +.long 0xcec082f6 //sha512su0 v22.16b,v23.16b + ext v7.16b,v18.16b,v19.16b,#8 +.long 0xce6680a2 //sha512h v2.16b,v5.16b,v6.16b +.long 0xce678ab6 //sha512su1 v22.16b,v21.16b,v7.16b + add v1.2d,v0.2d,v2.2d // "D + T1" +.long 0xce638402 //sha512h2 v2.16b,v0.16b,v3.16b + add v25.2d,v25.2d,v23.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v1.16b,v4.16b,#8 + ext v6.16b,v3.16b,v1.16b,#8 + add v4.2d,v4.2d,v25.2d // "T1 + H + K512[i]" +.long 0xcec08217 //sha512su0 v23.16b,v16.16b + ext v7.16b,v19.16b,v20.16b,#8 +.long 0xce6680a4 //sha512h v4.16b,v5.16b,v6.16b +.long 0xce678ad7 //sha512su1 v23.16b,v22.16b,v7.16b + add v0.2d,v3.2d,v4.2d // "D + T1" +.long 0xce628464 //sha512h2 v4.16b,v3.16b,v2.16b + add v24.2d,v24.2d,v16.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v0.16b,v1.16b,#8 + ext v6.16b,v2.16b,v0.16b,#8 + add v1.2d,v1.2d,v24.2d // "T1 + H + K512[i]" +.long 0xcec08230 //sha512su0 v16.16b,v17.16b + ext v7.16b,v20.16b,v21.16b,#8 +.long 0xce6680a1 //sha512h v1.16b,v5.16b,v6.16b +.long 0xce678af0 //sha512su1 v16.16b,v23.16b,v7.16b + add v3.2d,v2.2d,v1.2d // "D + T1" +.long 0xce648441 //sha512h2 v1.16b,v2.16b,v4.16b + add v25.2d,v25.2d,v17.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v3.16b,v0.16b,#8 + ext v6.16b,v4.16b,v3.16b,#8 + add v0.2d,v0.2d,v25.2d // "T1 + H + K512[i]" +.long 0xcec08251 //sha512su0 v17.16b,v18.16b + ext v7.16b,v21.16b,v22.16b,#8 +.long 0xce6680a0 //sha512h v0.16b,v5.16b,v6.16b +.long 0xce678a11 //sha512su1 v17.16b,v16.16b,v7.16b + add v2.2d,v4.2d,v0.2d // "D + T1" +.long 0xce618480 //sha512h2 v0.16b,v4.16b,v1.16b + add v24.2d,v24.2d,v18.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v2.16b,v3.16b,#8 + ext v6.16b,v1.16b,v2.16b,#8 + add v3.2d,v3.2d,v24.2d // "T1 + H + K512[i]" +.long 0xcec08272 //sha512su0 v18.16b,v19.16b + ext v7.16b,v22.16b,v23.16b,#8 +.long 0xce6680a3 //sha512h v3.16b,v5.16b,v6.16b +.long 0xce678a32 //sha512su1 v18.16b,v17.16b,v7.16b + add v4.2d,v1.2d,v3.2d // "D + T1" +.long 0xce608423 //sha512h2 v3.16b,v1.16b,v0.16b + add v25.2d,v25.2d,v19.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v4.16b,v2.16b,#8 + ext v6.16b,v0.16b,v4.16b,#8 + add v2.2d,v2.2d,v25.2d // "T1 + H + K512[i]" +.long 0xcec08293 //sha512su0 v19.16b,v20.16b + ext v7.16b,v23.16b,v16.16b,#8 +.long 0xce6680a2 //sha512h v2.16b,v5.16b,v6.16b +.long 0xce678a53 //sha512su1 v19.16b,v18.16b,v7.16b + add v1.2d,v0.2d,v2.2d // "D + T1" +.long 0xce638402 //sha512h2 v2.16b,v0.16b,v3.16b + add v24.2d,v24.2d,v20.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v1.16b,v4.16b,#8 + ext v6.16b,v3.16b,v1.16b,#8 + add v4.2d,v4.2d,v24.2d // "T1 + H + K512[i]" +.long 0xcec082b4 //sha512su0 v20.16b,v21.16b + ext v7.16b,v16.16b,v17.16b,#8 +.long 0xce6680a4 //sha512h v4.16b,v5.16b,v6.16b +.long 0xce678a74 //sha512su1 v20.16b,v19.16b,v7.16b + add v0.2d,v3.2d,v4.2d // "D + T1" +.long 0xce628464 //sha512h2 v4.16b,v3.16b,v2.16b + add v25.2d,v25.2d,v21.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v0.16b,v1.16b,#8 + ext v6.16b,v2.16b,v0.16b,#8 + add v1.2d,v1.2d,v25.2d // "T1 + H + K512[i]" +.long 0xcec082d5 //sha512su0 v21.16b,v22.16b + ext v7.16b,v17.16b,v18.16b,#8 +.long 0xce6680a1 //sha512h v1.16b,v5.16b,v6.16b +.long 0xce678a95 //sha512su1 v21.16b,v20.16b,v7.16b + add v3.2d,v2.2d,v1.2d // "D + T1" +.long 0xce648441 //sha512h2 v1.16b,v2.16b,v4.16b + add v24.2d,v24.2d,v22.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v3.16b,v0.16b,#8 + ext v6.16b,v4.16b,v3.16b,#8 + add v0.2d,v0.2d,v24.2d // "T1 + H + K512[i]" +.long 0xcec082f6 //sha512su0 v22.16b,v23.16b + ext v7.16b,v18.16b,v19.16b,#8 +.long 0xce6680a0 //sha512h v0.16b,v5.16b,v6.16b +.long 0xce678ab6 //sha512su1 v22.16b,v21.16b,v7.16b + add v2.2d,v4.2d,v0.2d // "D + T1" +.long 0xce618480 //sha512h2 v0.16b,v4.16b,v1.16b + add v25.2d,v25.2d,v23.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v2.16b,v3.16b,#8 + ext v6.16b,v1.16b,v2.16b,#8 + add v3.2d,v3.2d,v25.2d // "T1 + H + K512[i]" +.long 0xcec08217 //sha512su0 v23.16b,v16.16b + ext v7.16b,v19.16b,v20.16b,#8 +.long 0xce6680a3 //sha512h v3.16b,v5.16b,v6.16b +.long 0xce678ad7 //sha512su1 v23.16b,v22.16b,v7.16b + add v4.2d,v1.2d,v3.2d // "D + T1" +.long 0xce608423 //sha512h2 v3.16b,v1.16b,v0.16b + add v24.2d,v24.2d,v16.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v4.16b,v2.16b,#8 + ext v6.16b,v0.16b,v4.16b,#8 + add v2.2d,v2.2d,v24.2d // "T1 + H + K512[i]" +.long 0xcec08230 //sha512su0 v16.16b,v17.16b + ext v7.16b,v20.16b,v21.16b,#8 +.long 0xce6680a2 //sha512h v2.16b,v5.16b,v6.16b +.long 0xce678af0 //sha512su1 v16.16b,v23.16b,v7.16b + add v1.2d,v0.2d,v2.2d // "D + T1" +.long 0xce638402 //sha512h2 v2.16b,v0.16b,v3.16b + add v25.2d,v25.2d,v17.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v1.16b,v4.16b,#8 + ext v6.16b,v3.16b,v1.16b,#8 + add v4.2d,v4.2d,v25.2d // "T1 + H + K512[i]" +.long 0xcec08251 //sha512su0 v17.16b,v18.16b + ext v7.16b,v21.16b,v22.16b,#8 +.long 0xce6680a4 //sha512h v4.16b,v5.16b,v6.16b +.long 0xce678a11 //sha512su1 v17.16b,v16.16b,v7.16b + add v0.2d,v3.2d,v4.2d // "D + T1" +.long 0xce628464 //sha512h2 v4.16b,v3.16b,v2.16b + add v24.2d,v24.2d,v18.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v0.16b,v1.16b,#8 + ext v6.16b,v2.16b,v0.16b,#8 + add v1.2d,v1.2d,v24.2d // "T1 + H + K512[i]" +.long 0xcec08272 //sha512su0 v18.16b,v19.16b + ext v7.16b,v22.16b,v23.16b,#8 +.long 0xce6680a1 //sha512h v1.16b,v5.16b,v6.16b +.long 0xce678a32 //sha512su1 v18.16b,v17.16b,v7.16b + add v3.2d,v2.2d,v1.2d // "D + T1" +.long 0xce648441 //sha512h2 v1.16b,v2.16b,v4.16b + add v25.2d,v25.2d,v19.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v3.16b,v0.16b,#8 + ext v6.16b,v4.16b,v3.16b,#8 + add v0.2d,v0.2d,v25.2d // "T1 + H + K512[i]" +.long 0xcec08293 //sha512su0 v19.16b,v20.16b + ext v7.16b,v23.16b,v16.16b,#8 +.long 0xce6680a0 //sha512h v0.16b,v5.16b,v6.16b +.long 0xce678a53 //sha512su1 v19.16b,v18.16b,v7.16b + add v2.2d,v4.2d,v0.2d // "D + T1" +.long 0xce618480 //sha512h2 v0.16b,v4.16b,v1.16b + add v24.2d,v24.2d,v20.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v2.16b,v3.16b,#8 + ext v6.16b,v1.16b,v2.16b,#8 + add v3.2d,v3.2d,v24.2d // "T1 + H + K512[i]" +.long 0xcec082b4 //sha512su0 v20.16b,v21.16b + ext v7.16b,v16.16b,v17.16b,#8 +.long 0xce6680a3 //sha512h v3.16b,v5.16b,v6.16b +.long 0xce678a74 //sha512su1 v20.16b,v19.16b,v7.16b + add v4.2d,v1.2d,v3.2d // "D + T1" +.long 0xce608423 //sha512h2 v3.16b,v1.16b,v0.16b + add v25.2d,v25.2d,v21.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v4.16b,v2.16b,#8 + ext v6.16b,v0.16b,v4.16b,#8 + add v2.2d,v2.2d,v25.2d // "T1 + H + K512[i]" +.long 0xcec082d5 //sha512su0 v21.16b,v22.16b + ext v7.16b,v17.16b,v18.16b,#8 +.long 0xce6680a2 //sha512h v2.16b,v5.16b,v6.16b +.long 0xce678a95 //sha512su1 v21.16b,v20.16b,v7.16b + add v1.2d,v0.2d,v2.2d // "D + T1" +.long 0xce638402 //sha512h2 v2.16b,v0.16b,v3.16b + add v24.2d,v24.2d,v22.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v1.16b,v4.16b,#8 + ext v6.16b,v3.16b,v1.16b,#8 + add v4.2d,v4.2d,v24.2d // "T1 + H + K512[i]" +.long 0xcec082f6 //sha512su0 v22.16b,v23.16b + ext v7.16b,v18.16b,v19.16b,#8 +.long 0xce6680a4 //sha512h v4.16b,v5.16b,v6.16b +.long 0xce678ab6 //sha512su1 v22.16b,v21.16b,v7.16b + add v0.2d,v3.2d,v4.2d // "D + T1" +.long 0xce628464 //sha512h2 v4.16b,v3.16b,v2.16b + add v25.2d,v25.2d,v23.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v0.16b,v1.16b,#8 + ext v6.16b,v2.16b,v0.16b,#8 + add v1.2d,v1.2d,v25.2d // "T1 + H + K512[i]" +.long 0xcec08217 //sha512su0 v23.16b,v16.16b + ext v7.16b,v19.16b,v20.16b,#8 +.long 0xce6680a1 //sha512h v1.16b,v5.16b,v6.16b +.long 0xce678ad7 //sha512su1 v23.16b,v22.16b,v7.16b + add v3.2d,v2.2d,v1.2d // "D + T1" +.long 0xce648441 //sha512h2 v1.16b,v2.16b,v4.16b + add v24.2d,v24.2d,v16.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v3.16b,v0.16b,#8 + ext v6.16b,v4.16b,v3.16b,#8 + add v0.2d,v0.2d,v24.2d // "T1 + H + K512[i]" +.long 0xcec08230 //sha512su0 v16.16b,v17.16b + ext v7.16b,v20.16b,v21.16b,#8 +.long 0xce6680a0 //sha512h v0.16b,v5.16b,v6.16b +.long 0xce678af0 //sha512su1 v16.16b,v23.16b,v7.16b + add v2.2d,v4.2d,v0.2d // "D + T1" +.long 0xce618480 //sha512h2 v0.16b,v4.16b,v1.16b + add v25.2d,v25.2d,v17.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v2.16b,v3.16b,#8 + ext v6.16b,v1.16b,v2.16b,#8 + add v3.2d,v3.2d,v25.2d // "T1 + H + K512[i]" +.long 0xcec08251 //sha512su0 v17.16b,v18.16b + ext v7.16b,v21.16b,v22.16b,#8 +.long 0xce6680a3 //sha512h v3.16b,v5.16b,v6.16b +.long 0xce678a11 //sha512su1 v17.16b,v16.16b,v7.16b + add v4.2d,v1.2d,v3.2d // "D + T1" +.long 0xce608423 //sha512h2 v3.16b,v1.16b,v0.16b + add v24.2d,v24.2d,v18.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v4.16b,v2.16b,#8 + ext v6.16b,v0.16b,v4.16b,#8 + add v2.2d,v2.2d,v24.2d // "T1 + H + K512[i]" +.long 0xcec08272 //sha512su0 v18.16b,v19.16b + ext v7.16b,v22.16b,v23.16b,#8 +.long 0xce6680a2 //sha512h v2.16b,v5.16b,v6.16b +.long 0xce678a32 //sha512su1 v18.16b,v17.16b,v7.16b + add v1.2d,v0.2d,v2.2d // "D + T1" +.long 0xce638402 //sha512h2 v2.16b,v0.16b,v3.16b + add v25.2d,v25.2d,v19.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v1.16b,v4.16b,#8 + ext v6.16b,v3.16b,v1.16b,#8 + add v4.2d,v4.2d,v25.2d // "T1 + H + K512[i]" +.long 0xcec08293 //sha512su0 v19.16b,v20.16b + ext v7.16b,v23.16b,v16.16b,#8 +.long 0xce6680a4 //sha512h v4.16b,v5.16b,v6.16b +.long 0xce678a53 //sha512su1 v19.16b,v18.16b,v7.16b + add v0.2d,v3.2d,v4.2d // "D + T1" +.long 0xce628464 //sha512h2 v4.16b,v3.16b,v2.16b + add v24.2d,v24.2d,v20.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v0.16b,v1.16b,#8 + ext v6.16b,v2.16b,v0.16b,#8 + add v1.2d,v1.2d,v24.2d // "T1 + H + K512[i]" +.long 0xcec082b4 //sha512su0 v20.16b,v21.16b + ext v7.16b,v16.16b,v17.16b,#8 +.long 0xce6680a1 //sha512h v1.16b,v5.16b,v6.16b +.long 0xce678a74 //sha512su1 v20.16b,v19.16b,v7.16b + add v3.2d,v2.2d,v1.2d // "D + T1" +.long 0xce648441 //sha512h2 v1.16b,v2.16b,v4.16b + add v25.2d,v25.2d,v21.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v3.16b,v0.16b,#8 + ext v6.16b,v4.16b,v3.16b,#8 + add v0.2d,v0.2d,v25.2d // "T1 + H + K512[i]" +.long 0xcec082d5 //sha512su0 v21.16b,v22.16b + ext v7.16b,v17.16b,v18.16b,#8 +.long 0xce6680a0 //sha512h v0.16b,v5.16b,v6.16b +.long 0xce678a95 //sha512su1 v21.16b,v20.16b,v7.16b + add v2.2d,v4.2d,v0.2d // "D + T1" +.long 0xce618480 //sha512h2 v0.16b,v4.16b,v1.16b + add v24.2d,v24.2d,v22.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v2.16b,v3.16b,#8 + ext v6.16b,v1.16b,v2.16b,#8 + add v3.2d,v3.2d,v24.2d // "T1 + H + K512[i]" +.long 0xcec082f6 //sha512su0 v22.16b,v23.16b + ext v7.16b,v18.16b,v19.16b,#8 +.long 0xce6680a3 //sha512h v3.16b,v5.16b,v6.16b +.long 0xce678ab6 //sha512su1 v22.16b,v21.16b,v7.16b + add v4.2d,v1.2d,v3.2d // "D + T1" +.long 0xce608423 //sha512h2 v3.16b,v1.16b,v0.16b + add v25.2d,v25.2d,v23.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v4.16b,v2.16b,#8 + ext v6.16b,v0.16b,v4.16b,#8 + add v2.2d,v2.2d,v25.2d // "T1 + H + K512[i]" +.long 0xcec08217 //sha512su0 v23.16b,v16.16b + ext v7.16b,v19.16b,v20.16b,#8 +.long 0xce6680a2 //sha512h v2.16b,v5.16b,v6.16b +.long 0xce678ad7 //sha512su1 v23.16b,v22.16b,v7.16b + add v1.2d,v0.2d,v2.2d // "D + T1" +.long 0xce638402 //sha512h2 v2.16b,v0.16b,v3.16b + ld1 {v25.2d},[x3],#16 + add v24.2d,v24.2d,v16.2d + ld1 {v16.16b},[x1],#16 // load next input + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v1.16b,v4.16b,#8 + ext v6.16b,v3.16b,v1.16b,#8 + add v4.2d,v4.2d,v24.2d // "T1 + H + K512[i]" +.long 0xce6680a4 //sha512h v4.16b,v5.16b,v6.16b + rev64 v16.16b,v16.16b + add v0.2d,v3.2d,v4.2d // "D + T1" +.long 0xce628464 //sha512h2 v4.16b,v3.16b,v2.16b + ld1 {v24.2d},[x3],#16 + add v25.2d,v25.2d,v17.2d + ld1 {v17.16b},[x1],#16 // load next input + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v0.16b,v1.16b,#8 + ext v6.16b,v2.16b,v0.16b,#8 + add v1.2d,v1.2d,v25.2d // "T1 + H + K512[i]" +.long 0xce6680a1 //sha512h v1.16b,v5.16b,v6.16b + rev64 v17.16b,v17.16b + add v3.2d,v2.2d,v1.2d // "D + T1" +.long 0xce648441 //sha512h2 v1.16b,v2.16b,v4.16b + ld1 {v25.2d},[x3],#16 + add v24.2d,v24.2d,v18.2d + ld1 {v18.16b},[x1],#16 // load next input + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v3.16b,v0.16b,#8 + ext v6.16b,v4.16b,v3.16b,#8 + add v0.2d,v0.2d,v24.2d // "T1 + H + K512[i]" +.long 0xce6680a0 //sha512h v0.16b,v5.16b,v6.16b + rev64 v18.16b,v18.16b + add v2.2d,v4.2d,v0.2d // "D + T1" +.long 0xce618480 //sha512h2 v0.16b,v4.16b,v1.16b + ld1 {v24.2d},[x3],#16 + add v25.2d,v25.2d,v19.2d + ld1 {v19.16b},[x1],#16 // load next input + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v2.16b,v3.16b,#8 + ext v6.16b,v1.16b,v2.16b,#8 + add v3.2d,v3.2d,v25.2d // "T1 + H + K512[i]" +.long 0xce6680a3 //sha512h v3.16b,v5.16b,v6.16b + rev64 v19.16b,v19.16b + add v4.2d,v1.2d,v3.2d // "D + T1" +.long 0xce608423 //sha512h2 v3.16b,v1.16b,v0.16b + ld1 {v25.2d},[x3],#16 + add v24.2d,v24.2d,v20.2d + ld1 {v20.16b},[x1],#16 // load next input + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v4.16b,v2.16b,#8 + ext v6.16b,v0.16b,v4.16b,#8 + add v2.2d,v2.2d,v24.2d // "T1 + H + K512[i]" +.long 0xce6680a2 //sha512h v2.16b,v5.16b,v6.16b + rev64 v20.16b,v20.16b + add v1.2d,v0.2d,v2.2d // "D + T1" +.long 0xce638402 //sha512h2 v2.16b,v0.16b,v3.16b + ld1 {v24.2d},[x3],#16 + add v25.2d,v25.2d,v21.2d + ld1 {v21.16b},[x1],#16 // load next input + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v1.16b,v4.16b,#8 + ext v6.16b,v3.16b,v1.16b,#8 + add v4.2d,v4.2d,v25.2d // "T1 + H + K512[i]" +.long 0xce6680a4 //sha512h v4.16b,v5.16b,v6.16b + rev64 v21.16b,v21.16b + add v0.2d,v3.2d,v4.2d // "D + T1" +.long 0xce628464 //sha512h2 v4.16b,v3.16b,v2.16b + ld1 {v25.2d},[x3],#16 + add v24.2d,v24.2d,v22.2d + ld1 {v22.16b},[x1],#16 // load next input + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v0.16b,v1.16b,#8 + ext v6.16b,v2.16b,v0.16b,#8 + add v1.2d,v1.2d,v24.2d // "T1 + H + K512[i]" +.long 0xce6680a1 //sha512h v1.16b,v5.16b,v6.16b + rev64 v22.16b,v22.16b + add v3.2d,v2.2d,v1.2d // "D + T1" +.long 0xce648441 //sha512h2 v1.16b,v2.16b,v4.16b + sub x3,x3,#80*8 // rewind + add v25.2d,v25.2d,v23.2d + ld1 {v23.16b},[x1],#16 // load next input + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v3.16b,v0.16b,#8 + ext v6.16b,v4.16b,v3.16b,#8 + add v0.2d,v0.2d,v25.2d // "T1 + H + K512[i]" +.long 0xce6680a0 //sha512h v0.16b,v5.16b,v6.16b + rev64 v23.16b,v23.16b + add v2.2d,v4.2d,v0.2d // "D + T1" +.long 0xce618480 //sha512h2 v0.16b,v4.16b,v1.16b + add v0.2d,v0.2d,v26.2d // accumulate + add v1.2d,v1.2d,v27.2d + add v2.2d,v2.2d,v28.2d + add v3.2d,v3.2d,v29.2d + + cbnz x2,Loop_hw + + st1 {v0.2d,v1.2d,v2.2d,v3.2d},[x0] // store context + + ldr x29,[sp],#16 + ret + +#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__APPLE__) diff --git a/http/vendor/ring/pregenerated/sha512-armv8-linux64.S b/http/vendor/ring/pregenerated/sha512-armv8-linux64.S new file mode 100644 index 0000000..c1aa379 --- /dev/null +++ b/http/vendor/ring/pregenerated/sha512-armv8-linux64.S @@ -0,0 +1,1598 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__ELF__) +// Copyright 2014-2020 The OpenSSL Project Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// ==================================================================== +// Written by Andy Polyakov for the OpenSSL +// project. +// ==================================================================== +// +// SHA256/512 for ARMv8. +// +// Performance in cycles per processed byte and improvement coefficient +// over code generated with "default" compiler: +// +// SHA256-hw SHA256(*) SHA512 +// Apple A7 1.97 10.5 (+33%) 6.73 (-1%(**)) +// Cortex-A53 2.38 15.5 (+115%) 10.0 (+150%(***)) +// Cortex-A57 2.31 11.6 (+86%) 7.51 (+260%(***)) +// Denver 2.01 10.5 (+26%) 6.70 (+8%) +// X-Gene 20.0 (+100%) 12.8 (+300%(***)) +// Mongoose 2.36 13.0 (+50%) 8.36 (+33%) +// Kryo 1.92 17.4 (+30%) 11.2 (+8%) +// +// (*) Software SHA256 results are of lesser relevance, presented +// mostly for informational purposes. +// (**) The result is a trade-off: it's possible to improve it by +// 10% (or by 1 cycle per round), but at the cost of 20% loss +// on Cortex-A53 (or by 4 cycles per round). +// (***) Super-impressive coefficients over gcc-generated code are +// indication of some compiler "pathology", most notably code +// generated with -mgeneral-regs-only is significantly faster +// and the gap is only 40-90%. + +#ifndef __KERNEL__ +#endif + +.text + +.globl sha512_block_data_order_nohw +.hidden sha512_block_data_order_nohw +.type sha512_block_data_order_nohw,%function +.align 6 +sha512_block_data_order_nohw: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-128]! + add x29,sp,#0 + + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + stp x27,x28,[sp,#80] + sub sp,sp,#4*8 + + ldp x20,x21,[x0] // load context + ldp x22,x23,[x0,#2*8] + ldp x24,x25,[x0,#4*8] + add x2,x1,x2,lsl#7 // end of input + ldp x26,x27,[x0,#6*8] + adrp x30,.LK512 + add x30,x30,:lo12:.LK512 + stp x0,x2,[x29,#96] + +.Loop: + ldp x3,x4,[x1],#2*8 + ldr x19,[x30],#8 // *K++ + eor x28,x21,x22 // magic seed + str x1,[x29,#112] +#ifndef __AARCH64EB__ + rev x3,x3 // 0 +#endif + ror x16,x24,#14 + add x27,x27,x19 // h+=K[i] + eor x6,x24,x24,ror#23 + and x17,x25,x24 + bic x19,x26,x24 + add x27,x27,x3 // h+=X[i] + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x20,x21 // a^b, b^c in next round + eor x16,x16,x6,ror#18 // Sigma1(e) + ror x6,x20,#28 + add x27,x27,x17 // h+=Ch(e,f,g) + eor x17,x20,x20,ror#5 + add x27,x27,x16 // h+=Sigma1(e) + and x28,x28,x19 // (b^c)&=(a^b) + add x23,x23,x27 // d+=h + eor x28,x28,x21 // Maj(a,b,c) + eor x17,x6,x17,ror#34 // Sigma0(a) + add x27,x27,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + //add x27,x27,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x4,x4 // 1 +#endif + ldp x5,x6,[x1],#2*8 + add x27,x27,x17 // h+=Sigma0(a) + ror x16,x23,#14 + add x26,x26,x28 // h+=K[i] + eor x7,x23,x23,ror#23 + and x17,x24,x23 + bic x28,x25,x23 + add x26,x26,x4 // h+=X[i] + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x27,x20 // a^b, b^c in next round + eor x16,x16,x7,ror#18 // Sigma1(e) + ror x7,x27,#28 + add x26,x26,x17 // h+=Ch(e,f,g) + eor x17,x27,x27,ror#5 + add x26,x26,x16 // h+=Sigma1(e) + and x19,x19,x28 // (b^c)&=(a^b) + add x22,x22,x26 // d+=h + eor x19,x19,x20 // Maj(a,b,c) + eor x17,x7,x17,ror#34 // Sigma0(a) + add x26,x26,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + //add x26,x26,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x5,x5 // 2 +#endif + add x26,x26,x17 // h+=Sigma0(a) + ror x16,x22,#14 + add x25,x25,x19 // h+=K[i] + eor x8,x22,x22,ror#23 + and x17,x23,x22 + bic x19,x24,x22 + add x25,x25,x5 // h+=X[i] + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x26,x27 // a^b, b^c in next round + eor x16,x16,x8,ror#18 // Sigma1(e) + ror x8,x26,#28 + add x25,x25,x17 // h+=Ch(e,f,g) + eor x17,x26,x26,ror#5 + add x25,x25,x16 // h+=Sigma1(e) + and x28,x28,x19 // (b^c)&=(a^b) + add x21,x21,x25 // d+=h + eor x28,x28,x27 // Maj(a,b,c) + eor x17,x8,x17,ror#34 // Sigma0(a) + add x25,x25,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + //add x25,x25,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x6,x6 // 3 +#endif + ldp x7,x8,[x1],#2*8 + add x25,x25,x17 // h+=Sigma0(a) + ror x16,x21,#14 + add x24,x24,x28 // h+=K[i] + eor x9,x21,x21,ror#23 + and x17,x22,x21 + bic x28,x23,x21 + add x24,x24,x6 // h+=X[i] + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x25,x26 // a^b, b^c in next round + eor x16,x16,x9,ror#18 // Sigma1(e) + ror x9,x25,#28 + add x24,x24,x17 // h+=Ch(e,f,g) + eor x17,x25,x25,ror#5 + add x24,x24,x16 // h+=Sigma1(e) + and x19,x19,x28 // (b^c)&=(a^b) + add x20,x20,x24 // d+=h + eor x19,x19,x26 // Maj(a,b,c) + eor x17,x9,x17,ror#34 // Sigma0(a) + add x24,x24,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + //add x24,x24,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x7,x7 // 4 +#endif + add x24,x24,x17 // h+=Sigma0(a) + ror x16,x20,#14 + add x23,x23,x19 // h+=K[i] + eor x10,x20,x20,ror#23 + and x17,x21,x20 + bic x19,x22,x20 + add x23,x23,x7 // h+=X[i] + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x24,x25 // a^b, b^c in next round + eor x16,x16,x10,ror#18 // Sigma1(e) + ror x10,x24,#28 + add x23,x23,x17 // h+=Ch(e,f,g) + eor x17,x24,x24,ror#5 + add x23,x23,x16 // h+=Sigma1(e) + and x28,x28,x19 // (b^c)&=(a^b) + add x27,x27,x23 // d+=h + eor x28,x28,x25 // Maj(a,b,c) + eor x17,x10,x17,ror#34 // Sigma0(a) + add x23,x23,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + //add x23,x23,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x8,x8 // 5 +#endif + ldp x9,x10,[x1],#2*8 + add x23,x23,x17 // h+=Sigma0(a) + ror x16,x27,#14 + add x22,x22,x28 // h+=K[i] + eor x11,x27,x27,ror#23 + and x17,x20,x27 + bic x28,x21,x27 + add x22,x22,x8 // h+=X[i] + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x23,x24 // a^b, b^c in next round + eor x16,x16,x11,ror#18 // Sigma1(e) + ror x11,x23,#28 + add x22,x22,x17 // h+=Ch(e,f,g) + eor x17,x23,x23,ror#5 + add x22,x22,x16 // h+=Sigma1(e) + and x19,x19,x28 // (b^c)&=(a^b) + add x26,x26,x22 // d+=h + eor x19,x19,x24 // Maj(a,b,c) + eor x17,x11,x17,ror#34 // Sigma0(a) + add x22,x22,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + //add x22,x22,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x9,x9 // 6 +#endif + add x22,x22,x17 // h+=Sigma0(a) + ror x16,x26,#14 + add x21,x21,x19 // h+=K[i] + eor x12,x26,x26,ror#23 + and x17,x27,x26 + bic x19,x20,x26 + add x21,x21,x9 // h+=X[i] + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x22,x23 // a^b, b^c in next round + eor x16,x16,x12,ror#18 // Sigma1(e) + ror x12,x22,#28 + add x21,x21,x17 // h+=Ch(e,f,g) + eor x17,x22,x22,ror#5 + add x21,x21,x16 // h+=Sigma1(e) + and x28,x28,x19 // (b^c)&=(a^b) + add x25,x25,x21 // d+=h + eor x28,x28,x23 // Maj(a,b,c) + eor x17,x12,x17,ror#34 // Sigma0(a) + add x21,x21,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + //add x21,x21,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x10,x10 // 7 +#endif + ldp x11,x12,[x1],#2*8 + add x21,x21,x17 // h+=Sigma0(a) + ror x16,x25,#14 + add x20,x20,x28 // h+=K[i] + eor x13,x25,x25,ror#23 + and x17,x26,x25 + bic x28,x27,x25 + add x20,x20,x10 // h+=X[i] + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x21,x22 // a^b, b^c in next round + eor x16,x16,x13,ror#18 // Sigma1(e) + ror x13,x21,#28 + add x20,x20,x17 // h+=Ch(e,f,g) + eor x17,x21,x21,ror#5 + add x20,x20,x16 // h+=Sigma1(e) + and x19,x19,x28 // (b^c)&=(a^b) + add x24,x24,x20 // d+=h + eor x19,x19,x22 // Maj(a,b,c) + eor x17,x13,x17,ror#34 // Sigma0(a) + add x20,x20,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + //add x20,x20,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x11,x11 // 8 +#endif + add x20,x20,x17 // h+=Sigma0(a) + ror x16,x24,#14 + add x27,x27,x19 // h+=K[i] + eor x14,x24,x24,ror#23 + and x17,x25,x24 + bic x19,x26,x24 + add x27,x27,x11 // h+=X[i] + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x20,x21 // a^b, b^c in next round + eor x16,x16,x14,ror#18 // Sigma1(e) + ror x14,x20,#28 + add x27,x27,x17 // h+=Ch(e,f,g) + eor x17,x20,x20,ror#5 + add x27,x27,x16 // h+=Sigma1(e) + and x28,x28,x19 // (b^c)&=(a^b) + add x23,x23,x27 // d+=h + eor x28,x28,x21 // Maj(a,b,c) + eor x17,x14,x17,ror#34 // Sigma0(a) + add x27,x27,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + //add x27,x27,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x12,x12 // 9 +#endif + ldp x13,x14,[x1],#2*8 + add x27,x27,x17 // h+=Sigma0(a) + ror x16,x23,#14 + add x26,x26,x28 // h+=K[i] + eor x15,x23,x23,ror#23 + and x17,x24,x23 + bic x28,x25,x23 + add x26,x26,x12 // h+=X[i] + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x27,x20 // a^b, b^c in next round + eor x16,x16,x15,ror#18 // Sigma1(e) + ror x15,x27,#28 + add x26,x26,x17 // h+=Ch(e,f,g) + eor x17,x27,x27,ror#5 + add x26,x26,x16 // h+=Sigma1(e) + and x19,x19,x28 // (b^c)&=(a^b) + add x22,x22,x26 // d+=h + eor x19,x19,x20 // Maj(a,b,c) + eor x17,x15,x17,ror#34 // Sigma0(a) + add x26,x26,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + //add x26,x26,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x13,x13 // 10 +#endif + add x26,x26,x17 // h+=Sigma0(a) + ror x16,x22,#14 + add x25,x25,x19 // h+=K[i] + eor x0,x22,x22,ror#23 + and x17,x23,x22 + bic x19,x24,x22 + add x25,x25,x13 // h+=X[i] + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x26,x27 // a^b, b^c in next round + eor x16,x16,x0,ror#18 // Sigma1(e) + ror x0,x26,#28 + add x25,x25,x17 // h+=Ch(e,f,g) + eor x17,x26,x26,ror#5 + add x25,x25,x16 // h+=Sigma1(e) + and x28,x28,x19 // (b^c)&=(a^b) + add x21,x21,x25 // d+=h + eor x28,x28,x27 // Maj(a,b,c) + eor x17,x0,x17,ror#34 // Sigma0(a) + add x25,x25,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + //add x25,x25,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x14,x14 // 11 +#endif + ldp x15,x0,[x1],#2*8 + add x25,x25,x17 // h+=Sigma0(a) + str x6,[sp,#24] + ror x16,x21,#14 + add x24,x24,x28 // h+=K[i] + eor x6,x21,x21,ror#23 + and x17,x22,x21 + bic x28,x23,x21 + add x24,x24,x14 // h+=X[i] + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x25,x26 // a^b, b^c in next round + eor x16,x16,x6,ror#18 // Sigma1(e) + ror x6,x25,#28 + add x24,x24,x17 // h+=Ch(e,f,g) + eor x17,x25,x25,ror#5 + add x24,x24,x16 // h+=Sigma1(e) + and x19,x19,x28 // (b^c)&=(a^b) + add x20,x20,x24 // d+=h + eor x19,x19,x26 // Maj(a,b,c) + eor x17,x6,x17,ror#34 // Sigma0(a) + add x24,x24,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + //add x24,x24,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x15,x15 // 12 +#endif + add x24,x24,x17 // h+=Sigma0(a) + str x7,[sp,#0] + ror x16,x20,#14 + add x23,x23,x19 // h+=K[i] + eor x7,x20,x20,ror#23 + and x17,x21,x20 + bic x19,x22,x20 + add x23,x23,x15 // h+=X[i] + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x24,x25 // a^b, b^c in next round + eor x16,x16,x7,ror#18 // Sigma1(e) + ror x7,x24,#28 + add x23,x23,x17 // h+=Ch(e,f,g) + eor x17,x24,x24,ror#5 + add x23,x23,x16 // h+=Sigma1(e) + and x28,x28,x19 // (b^c)&=(a^b) + add x27,x27,x23 // d+=h + eor x28,x28,x25 // Maj(a,b,c) + eor x17,x7,x17,ror#34 // Sigma0(a) + add x23,x23,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + //add x23,x23,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x0,x0 // 13 +#endif + ldp x1,x2,[x1] + add x23,x23,x17 // h+=Sigma0(a) + str x8,[sp,#8] + ror x16,x27,#14 + add x22,x22,x28 // h+=K[i] + eor x8,x27,x27,ror#23 + and x17,x20,x27 + bic x28,x21,x27 + add x22,x22,x0 // h+=X[i] + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x23,x24 // a^b, b^c in next round + eor x16,x16,x8,ror#18 // Sigma1(e) + ror x8,x23,#28 + add x22,x22,x17 // h+=Ch(e,f,g) + eor x17,x23,x23,ror#5 + add x22,x22,x16 // h+=Sigma1(e) + and x19,x19,x28 // (b^c)&=(a^b) + add x26,x26,x22 // d+=h + eor x19,x19,x24 // Maj(a,b,c) + eor x17,x8,x17,ror#34 // Sigma0(a) + add x22,x22,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + //add x22,x22,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x1,x1 // 14 +#endif + ldr x6,[sp,#24] + add x22,x22,x17 // h+=Sigma0(a) + str x9,[sp,#16] + ror x16,x26,#14 + add x21,x21,x19 // h+=K[i] + eor x9,x26,x26,ror#23 + and x17,x27,x26 + bic x19,x20,x26 + add x21,x21,x1 // h+=X[i] + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x22,x23 // a^b, b^c in next round + eor x16,x16,x9,ror#18 // Sigma1(e) + ror x9,x22,#28 + add x21,x21,x17 // h+=Ch(e,f,g) + eor x17,x22,x22,ror#5 + add x21,x21,x16 // h+=Sigma1(e) + and x28,x28,x19 // (b^c)&=(a^b) + add x25,x25,x21 // d+=h + eor x28,x28,x23 // Maj(a,b,c) + eor x17,x9,x17,ror#34 // Sigma0(a) + add x21,x21,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + //add x21,x21,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x2,x2 // 15 +#endif + ldr x7,[sp,#0] + add x21,x21,x17 // h+=Sigma0(a) + str x10,[sp,#24] + ror x16,x25,#14 + add x20,x20,x28 // h+=K[i] + ror x9,x4,#1 + and x17,x26,x25 + ror x8,x1,#19 + bic x28,x27,x25 + ror x10,x21,#28 + add x20,x20,x2 // h+=X[i] + eor x16,x16,x25,ror#18 + eor x9,x9,x4,ror#8 + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x21,x22 // a^b, b^c in next round + eor x16,x16,x25,ror#41 // Sigma1(e) + eor x10,x10,x21,ror#34 + add x20,x20,x17 // h+=Ch(e,f,g) + and x19,x19,x28 // (b^c)&=(a^b) + eor x8,x8,x1,ror#61 + eor x9,x9,x4,lsr#7 // sigma0(X[i+1]) + add x20,x20,x16 // h+=Sigma1(e) + eor x19,x19,x22 // Maj(a,b,c) + eor x17,x10,x21,ror#39 // Sigma0(a) + eor x8,x8,x1,lsr#6 // sigma1(X[i+14]) + add x3,x3,x12 + add x24,x24,x20 // d+=h + add x20,x20,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + add x3,x3,x9 + add x20,x20,x17 // h+=Sigma0(a) + add x3,x3,x8 +.Loop_16_xx: + ldr x8,[sp,#8] + str x11,[sp,#0] + ror x16,x24,#14 + add x27,x27,x19 // h+=K[i] + ror x10,x5,#1 + and x17,x25,x24 + ror x9,x2,#19 + bic x19,x26,x24 + ror x11,x20,#28 + add x27,x27,x3 // h+=X[i] + eor x16,x16,x24,ror#18 + eor x10,x10,x5,ror#8 + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x20,x21 // a^b, b^c in next round + eor x16,x16,x24,ror#41 // Sigma1(e) + eor x11,x11,x20,ror#34 + add x27,x27,x17 // h+=Ch(e,f,g) + and x28,x28,x19 // (b^c)&=(a^b) + eor x9,x9,x2,ror#61 + eor x10,x10,x5,lsr#7 // sigma0(X[i+1]) + add x27,x27,x16 // h+=Sigma1(e) + eor x28,x28,x21 // Maj(a,b,c) + eor x17,x11,x20,ror#39 // Sigma0(a) + eor x9,x9,x2,lsr#6 // sigma1(X[i+14]) + add x4,x4,x13 + add x23,x23,x27 // d+=h + add x27,x27,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + add x4,x4,x10 + add x27,x27,x17 // h+=Sigma0(a) + add x4,x4,x9 + ldr x9,[sp,#16] + str x12,[sp,#8] + ror x16,x23,#14 + add x26,x26,x28 // h+=K[i] + ror x11,x6,#1 + and x17,x24,x23 + ror x10,x3,#19 + bic x28,x25,x23 + ror x12,x27,#28 + add x26,x26,x4 // h+=X[i] + eor x16,x16,x23,ror#18 + eor x11,x11,x6,ror#8 + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x27,x20 // a^b, b^c in next round + eor x16,x16,x23,ror#41 // Sigma1(e) + eor x12,x12,x27,ror#34 + add x26,x26,x17 // h+=Ch(e,f,g) + and x19,x19,x28 // (b^c)&=(a^b) + eor x10,x10,x3,ror#61 + eor x11,x11,x6,lsr#7 // sigma0(X[i+1]) + add x26,x26,x16 // h+=Sigma1(e) + eor x19,x19,x20 // Maj(a,b,c) + eor x17,x12,x27,ror#39 // Sigma0(a) + eor x10,x10,x3,lsr#6 // sigma1(X[i+14]) + add x5,x5,x14 + add x22,x22,x26 // d+=h + add x26,x26,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + add x5,x5,x11 + add x26,x26,x17 // h+=Sigma0(a) + add x5,x5,x10 + ldr x10,[sp,#24] + str x13,[sp,#16] + ror x16,x22,#14 + add x25,x25,x19 // h+=K[i] + ror x12,x7,#1 + and x17,x23,x22 + ror x11,x4,#19 + bic x19,x24,x22 + ror x13,x26,#28 + add x25,x25,x5 // h+=X[i] + eor x16,x16,x22,ror#18 + eor x12,x12,x7,ror#8 + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x26,x27 // a^b, b^c in next round + eor x16,x16,x22,ror#41 // Sigma1(e) + eor x13,x13,x26,ror#34 + add x25,x25,x17 // h+=Ch(e,f,g) + and x28,x28,x19 // (b^c)&=(a^b) + eor x11,x11,x4,ror#61 + eor x12,x12,x7,lsr#7 // sigma0(X[i+1]) + add x25,x25,x16 // h+=Sigma1(e) + eor x28,x28,x27 // Maj(a,b,c) + eor x17,x13,x26,ror#39 // Sigma0(a) + eor x11,x11,x4,lsr#6 // sigma1(X[i+14]) + add x6,x6,x15 + add x21,x21,x25 // d+=h + add x25,x25,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + add x6,x6,x12 + add x25,x25,x17 // h+=Sigma0(a) + add x6,x6,x11 + ldr x11,[sp,#0] + str x14,[sp,#24] + ror x16,x21,#14 + add x24,x24,x28 // h+=K[i] + ror x13,x8,#1 + and x17,x22,x21 + ror x12,x5,#19 + bic x28,x23,x21 + ror x14,x25,#28 + add x24,x24,x6 // h+=X[i] + eor x16,x16,x21,ror#18 + eor x13,x13,x8,ror#8 + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x25,x26 // a^b, b^c in next round + eor x16,x16,x21,ror#41 // Sigma1(e) + eor x14,x14,x25,ror#34 + add x24,x24,x17 // h+=Ch(e,f,g) + and x19,x19,x28 // (b^c)&=(a^b) + eor x12,x12,x5,ror#61 + eor x13,x13,x8,lsr#7 // sigma0(X[i+1]) + add x24,x24,x16 // h+=Sigma1(e) + eor x19,x19,x26 // Maj(a,b,c) + eor x17,x14,x25,ror#39 // Sigma0(a) + eor x12,x12,x5,lsr#6 // sigma1(X[i+14]) + add x7,x7,x0 + add x20,x20,x24 // d+=h + add x24,x24,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + add x7,x7,x13 + add x24,x24,x17 // h+=Sigma0(a) + add x7,x7,x12 + ldr x12,[sp,#8] + str x15,[sp,#0] + ror x16,x20,#14 + add x23,x23,x19 // h+=K[i] + ror x14,x9,#1 + and x17,x21,x20 + ror x13,x6,#19 + bic x19,x22,x20 + ror x15,x24,#28 + add x23,x23,x7 // h+=X[i] + eor x16,x16,x20,ror#18 + eor x14,x14,x9,ror#8 + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x24,x25 // a^b, b^c in next round + eor x16,x16,x20,ror#41 // Sigma1(e) + eor x15,x15,x24,ror#34 + add x23,x23,x17 // h+=Ch(e,f,g) + and x28,x28,x19 // (b^c)&=(a^b) + eor x13,x13,x6,ror#61 + eor x14,x14,x9,lsr#7 // sigma0(X[i+1]) + add x23,x23,x16 // h+=Sigma1(e) + eor x28,x28,x25 // Maj(a,b,c) + eor x17,x15,x24,ror#39 // Sigma0(a) + eor x13,x13,x6,lsr#6 // sigma1(X[i+14]) + add x8,x8,x1 + add x27,x27,x23 // d+=h + add x23,x23,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + add x8,x8,x14 + add x23,x23,x17 // h+=Sigma0(a) + add x8,x8,x13 + ldr x13,[sp,#16] + str x0,[sp,#8] + ror x16,x27,#14 + add x22,x22,x28 // h+=K[i] + ror x15,x10,#1 + and x17,x20,x27 + ror x14,x7,#19 + bic x28,x21,x27 + ror x0,x23,#28 + add x22,x22,x8 // h+=X[i] + eor x16,x16,x27,ror#18 + eor x15,x15,x10,ror#8 + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x23,x24 // a^b, b^c in next round + eor x16,x16,x27,ror#41 // Sigma1(e) + eor x0,x0,x23,ror#34 + add x22,x22,x17 // h+=Ch(e,f,g) + and x19,x19,x28 // (b^c)&=(a^b) + eor x14,x14,x7,ror#61 + eor x15,x15,x10,lsr#7 // sigma0(X[i+1]) + add x22,x22,x16 // h+=Sigma1(e) + eor x19,x19,x24 // Maj(a,b,c) + eor x17,x0,x23,ror#39 // Sigma0(a) + eor x14,x14,x7,lsr#6 // sigma1(X[i+14]) + add x9,x9,x2 + add x26,x26,x22 // d+=h + add x22,x22,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + add x9,x9,x15 + add x22,x22,x17 // h+=Sigma0(a) + add x9,x9,x14 + ldr x14,[sp,#24] + str x1,[sp,#16] + ror x16,x26,#14 + add x21,x21,x19 // h+=K[i] + ror x0,x11,#1 + and x17,x27,x26 + ror x15,x8,#19 + bic x19,x20,x26 + ror x1,x22,#28 + add x21,x21,x9 // h+=X[i] + eor x16,x16,x26,ror#18 + eor x0,x0,x11,ror#8 + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x22,x23 // a^b, b^c in next round + eor x16,x16,x26,ror#41 // Sigma1(e) + eor x1,x1,x22,ror#34 + add x21,x21,x17 // h+=Ch(e,f,g) + and x28,x28,x19 // (b^c)&=(a^b) + eor x15,x15,x8,ror#61 + eor x0,x0,x11,lsr#7 // sigma0(X[i+1]) + add x21,x21,x16 // h+=Sigma1(e) + eor x28,x28,x23 // Maj(a,b,c) + eor x17,x1,x22,ror#39 // Sigma0(a) + eor x15,x15,x8,lsr#6 // sigma1(X[i+14]) + add x10,x10,x3 + add x25,x25,x21 // d+=h + add x21,x21,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + add x10,x10,x0 + add x21,x21,x17 // h+=Sigma0(a) + add x10,x10,x15 + ldr x15,[sp,#0] + str x2,[sp,#24] + ror x16,x25,#14 + add x20,x20,x28 // h+=K[i] + ror x1,x12,#1 + and x17,x26,x25 + ror x0,x9,#19 + bic x28,x27,x25 + ror x2,x21,#28 + add x20,x20,x10 // h+=X[i] + eor x16,x16,x25,ror#18 + eor x1,x1,x12,ror#8 + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x21,x22 // a^b, b^c in next round + eor x16,x16,x25,ror#41 // Sigma1(e) + eor x2,x2,x21,ror#34 + add x20,x20,x17 // h+=Ch(e,f,g) + and x19,x19,x28 // (b^c)&=(a^b) + eor x0,x0,x9,ror#61 + eor x1,x1,x12,lsr#7 // sigma0(X[i+1]) + add x20,x20,x16 // h+=Sigma1(e) + eor x19,x19,x22 // Maj(a,b,c) + eor x17,x2,x21,ror#39 // Sigma0(a) + eor x0,x0,x9,lsr#6 // sigma1(X[i+14]) + add x11,x11,x4 + add x24,x24,x20 // d+=h + add x20,x20,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + add x11,x11,x1 + add x20,x20,x17 // h+=Sigma0(a) + add x11,x11,x0 + ldr x0,[sp,#8] + str x3,[sp,#0] + ror x16,x24,#14 + add x27,x27,x19 // h+=K[i] + ror x2,x13,#1 + and x17,x25,x24 + ror x1,x10,#19 + bic x19,x26,x24 + ror x3,x20,#28 + add x27,x27,x11 // h+=X[i] + eor x16,x16,x24,ror#18 + eor x2,x2,x13,ror#8 + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x20,x21 // a^b, b^c in next round + eor x16,x16,x24,ror#41 // Sigma1(e) + eor x3,x3,x20,ror#34 + add x27,x27,x17 // h+=Ch(e,f,g) + and x28,x28,x19 // (b^c)&=(a^b) + eor x1,x1,x10,ror#61 + eor x2,x2,x13,lsr#7 // sigma0(X[i+1]) + add x27,x27,x16 // h+=Sigma1(e) + eor x28,x28,x21 // Maj(a,b,c) + eor x17,x3,x20,ror#39 // Sigma0(a) + eor x1,x1,x10,lsr#6 // sigma1(X[i+14]) + add x12,x12,x5 + add x23,x23,x27 // d+=h + add x27,x27,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + add x12,x12,x2 + add x27,x27,x17 // h+=Sigma0(a) + add x12,x12,x1 + ldr x1,[sp,#16] + str x4,[sp,#8] + ror x16,x23,#14 + add x26,x26,x28 // h+=K[i] + ror x3,x14,#1 + and x17,x24,x23 + ror x2,x11,#19 + bic x28,x25,x23 + ror x4,x27,#28 + add x26,x26,x12 // h+=X[i] + eor x16,x16,x23,ror#18 + eor x3,x3,x14,ror#8 + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x27,x20 // a^b, b^c in next round + eor x16,x16,x23,ror#41 // Sigma1(e) + eor x4,x4,x27,ror#34 + add x26,x26,x17 // h+=Ch(e,f,g) + and x19,x19,x28 // (b^c)&=(a^b) + eor x2,x2,x11,ror#61 + eor x3,x3,x14,lsr#7 // sigma0(X[i+1]) + add x26,x26,x16 // h+=Sigma1(e) + eor x19,x19,x20 // Maj(a,b,c) + eor x17,x4,x27,ror#39 // Sigma0(a) + eor x2,x2,x11,lsr#6 // sigma1(X[i+14]) + add x13,x13,x6 + add x22,x22,x26 // d+=h + add x26,x26,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + add x13,x13,x3 + add x26,x26,x17 // h+=Sigma0(a) + add x13,x13,x2 + ldr x2,[sp,#24] + str x5,[sp,#16] + ror x16,x22,#14 + add x25,x25,x19 // h+=K[i] + ror x4,x15,#1 + and x17,x23,x22 + ror x3,x12,#19 + bic x19,x24,x22 + ror x5,x26,#28 + add x25,x25,x13 // h+=X[i] + eor x16,x16,x22,ror#18 + eor x4,x4,x15,ror#8 + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x26,x27 // a^b, b^c in next round + eor x16,x16,x22,ror#41 // Sigma1(e) + eor x5,x5,x26,ror#34 + add x25,x25,x17 // h+=Ch(e,f,g) + and x28,x28,x19 // (b^c)&=(a^b) + eor x3,x3,x12,ror#61 + eor x4,x4,x15,lsr#7 // sigma0(X[i+1]) + add x25,x25,x16 // h+=Sigma1(e) + eor x28,x28,x27 // Maj(a,b,c) + eor x17,x5,x26,ror#39 // Sigma0(a) + eor x3,x3,x12,lsr#6 // sigma1(X[i+14]) + add x14,x14,x7 + add x21,x21,x25 // d+=h + add x25,x25,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + add x14,x14,x4 + add x25,x25,x17 // h+=Sigma0(a) + add x14,x14,x3 + ldr x3,[sp,#0] + str x6,[sp,#24] + ror x16,x21,#14 + add x24,x24,x28 // h+=K[i] + ror x5,x0,#1 + and x17,x22,x21 + ror x4,x13,#19 + bic x28,x23,x21 + ror x6,x25,#28 + add x24,x24,x14 // h+=X[i] + eor x16,x16,x21,ror#18 + eor x5,x5,x0,ror#8 + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x25,x26 // a^b, b^c in next round + eor x16,x16,x21,ror#41 // Sigma1(e) + eor x6,x6,x25,ror#34 + add x24,x24,x17 // h+=Ch(e,f,g) + and x19,x19,x28 // (b^c)&=(a^b) + eor x4,x4,x13,ror#61 + eor x5,x5,x0,lsr#7 // sigma0(X[i+1]) + add x24,x24,x16 // h+=Sigma1(e) + eor x19,x19,x26 // Maj(a,b,c) + eor x17,x6,x25,ror#39 // Sigma0(a) + eor x4,x4,x13,lsr#6 // sigma1(X[i+14]) + add x15,x15,x8 + add x20,x20,x24 // d+=h + add x24,x24,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + add x15,x15,x5 + add x24,x24,x17 // h+=Sigma0(a) + add x15,x15,x4 + ldr x4,[sp,#8] + str x7,[sp,#0] + ror x16,x20,#14 + add x23,x23,x19 // h+=K[i] + ror x6,x1,#1 + and x17,x21,x20 + ror x5,x14,#19 + bic x19,x22,x20 + ror x7,x24,#28 + add x23,x23,x15 // h+=X[i] + eor x16,x16,x20,ror#18 + eor x6,x6,x1,ror#8 + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x24,x25 // a^b, b^c in next round + eor x16,x16,x20,ror#41 // Sigma1(e) + eor x7,x7,x24,ror#34 + add x23,x23,x17 // h+=Ch(e,f,g) + and x28,x28,x19 // (b^c)&=(a^b) + eor x5,x5,x14,ror#61 + eor x6,x6,x1,lsr#7 // sigma0(X[i+1]) + add x23,x23,x16 // h+=Sigma1(e) + eor x28,x28,x25 // Maj(a,b,c) + eor x17,x7,x24,ror#39 // Sigma0(a) + eor x5,x5,x14,lsr#6 // sigma1(X[i+14]) + add x0,x0,x9 + add x27,x27,x23 // d+=h + add x23,x23,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + add x0,x0,x6 + add x23,x23,x17 // h+=Sigma0(a) + add x0,x0,x5 + ldr x5,[sp,#16] + str x8,[sp,#8] + ror x16,x27,#14 + add x22,x22,x28 // h+=K[i] + ror x7,x2,#1 + and x17,x20,x27 + ror x6,x15,#19 + bic x28,x21,x27 + ror x8,x23,#28 + add x22,x22,x0 // h+=X[i] + eor x16,x16,x27,ror#18 + eor x7,x7,x2,ror#8 + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x23,x24 // a^b, b^c in next round + eor x16,x16,x27,ror#41 // Sigma1(e) + eor x8,x8,x23,ror#34 + add x22,x22,x17 // h+=Ch(e,f,g) + and x19,x19,x28 // (b^c)&=(a^b) + eor x6,x6,x15,ror#61 + eor x7,x7,x2,lsr#7 // sigma0(X[i+1]) + add x22,x22,x16 // h+=Sigma1(e) + eor x19,x19,x24 // Maj(a,b,c) + eor x17,x8,x23,ror#39 // Sigma0(a) + eor x6,x6,x15,lsr#6 // sigma1(X[i+14]) + add x1,x1,x10 + add x26,x26,x22 // d+=h + add x22,x22,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + add x1,x1,x7 + add x22,x22,x17 // h+=Sigma0(a) + add x1,x1,x6 + ldr x6,[sp,#24] + str x9,[sp,#16] + ror x16,x26,#14 + add x21,x21,x19 // h+=K[i] + ror x8,x3,#1 + and x17,x27,x26 + ror x7,x0,#19 + bic x19,x20,x26 + ror x9,x22,#28 + add x21,x21,x1 // h+=X[i] + eor x16,x16,x26,ror#18 + eor x8,x8,x3,ror#8 + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x22,x23 // a^b, b^c in next round + eor x16,x16,x26,ror#41 // Sigma1(e) + eor x9,x9,x22,ror#34 + add x21,x21,x17 // h+=Ch(e,f,g) + and x28,x28,x19 // (b^c)&=(a^b) + eor x7,x7,x0,ror#61 + eor x8,x8,x3,lsr#7 // sigma0(X[i+1]) + add x21,x21,x16 // h+=Sigma1(e) + eor x28,x28,x23 // Maj(a,b,c) + eor x17,x9,x22,ror#39 // Sigma0(a) + eor x7,x7,x0,lsr#6 // sigma1(X[i+14]) + add x2,x2,x11 + add x25,x25,x21 // d+=h + add x21,x21,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + add x2,x2,x8 + add x21,x21,x17 // h+=Sigma0(a) + add x2,x2,x7 + ldr x7,[sp,#0] + str x10,[sp,#24] + ror x16,x25,#14 + add x20,x20,x28 // h+=K[i] + ror x9,x4,#1 + and x17,x26,x25 + ror x8,x1,#19 + bic x28,x27,x25 + ror x10,x21,#28 + add x20,x20,x2 // h+=X[i] + eor x16,x16,x25,ror#18 + eor x9,x9,x4,ror#8 + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x21,x22 // a^b, b^c in next round + eor x16,x16,x25,ror#41 // Sigma1(e) + eor x10,x10,x21,ror#34 + add x20,x20,x17 // h+=Ch(e,f,g) + and x19,x19,x28 // (b^c)&=(a^b) + eor x8,x8,x1,ror#61 + eor x9,x9,x4,lsr#7 // sigma0(X[i+1]) + add x20,x20,x16 // h+=Sigma1(e) + eor x19,x19,x22 // Maj(a,b,c) + eor x17,x10,x21,ror#39 // Sigma0(a) + eor x8,x8,x1,lsr#6 // sigma1(X[i+14]) + add x3,x3,x12 + add x24,x24,x20 // d+=h + add x20,x20,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + add x3,x3,x9 + add x20,x20,x17 // h+=Sigma0(a) + add x3,x3,x8 + cbnz x19,.Loop_16_xx + + ldp x0,x2,[x29,#96] + ldr x1,[x29,#112] + sub x30,x30,#648 // rewind + + ldp x3,x4,[x0] + ldp x5,x6,[x0,#2*8] + add x1,x1,#14*8 // advance input pointer + ldp x7,x8,[x0,#4*8] + add x20,x20,x3 + ldp x9,x10,[x0,#6*8] + add x21,x21,x4 + add x22,x22,x5 + add x23,x23,x6 + stp x20,x21,[x0] + add x24,x24,x7 + add x25,x25,x8 + stp x22,x23,[x0,#2*8] + add x26,x26,x9 + add x27,x27,x10 + cmp x1,x2 + stp x24,x25,[x0,#4*8] + stp x26,x27,[x0,#6*8] + b.ne .Loop + + ldp x19,x20,[x29,#16] + add sp,sp,#4*8 + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldp x29,x30,[sp],#128 + AARCH64_VALIDATE_LINK_REGISTER + ret +.size sha512_block_data_order_nohw,.-sha512_block_data_order_nohw + +.section .rodata +.align 6 +.type .LK512,%object +.LK512: +.quad 0x428a2f98d728ae22,0x7137449123ef65cd +.quad 0xb5c0fbcfec4d3b2f,0xe9b5dba58189dbbc +.quad 0x3956c25bf348b538,0x59f111f1b605d019 +.quad 0x923f82a4af194f9b,0xab1c5ed5da6d8118 +.quad 0xd807aa98a3030242,0x12835b0145706fbe +.quad 0x243185be4ee4b28c,0x550c7dc3d5ffb4e2 +.quad 0x72be5d74f27b896f,0x80deb1fe3b1696b1 +.quad 0x9bdc06a725c71235,0xc19bf174cf692694 +.quad 0xe49b69c19ef14ad2,0xefbe4786384f25e3 +.quad 0x0fc19dc68b8cd5b5,0x240ca1cc77ac9c65 +.quad 0x2de92c6f592b0275,0x4a7484aa6ea6e483 +.quad 0x5cb0a9dcbd41fbd4,0x76f988da831153b5 +.quad 0x983e5152ee66dfab,0xa831c66d2db43210 +.quad 0xb00327c898fb213f,0xbf597fc7beef0ee4 +.quad 0xc6e00bf33da88fc2,0xd5a79147930aa725 +.quad 0x06ca6351e003826f,0x142929670a0e6e70 +.quad 0x27b70a8546d22ffc,0x2e1b21385c26c926 +.quad 0x4d2c6dfc5ac42aed,0x53380d139d95b3df +.quad 0x650a73548baf63de,0x766a0abb3c77b2a8 +.quad 0x81c2c92e47edaee6,0x92722c851482353b +.quad 0xa2bfe8a14cf10364,0xa81a664bbc423001 +.quad 0xc24b8b70d0f89791,0xc76c51a30654be30 +.quad 0xd192e819d6ef5218,0xd69906245565a910 +.quad 0xf40e35855771202a,0x106aa07032bbd1b8 +.quad 0x19a4c116b8d2d0c8,0x1e376c085141ab53 +.quad 0x2748774cdf8eeb99,0x34b0bcb5e19b48a8 +.quad 0x391c0cb3c5c95a63,0x4ed8aa4ae3418acb +.quad 0x5b9cca4f7763e373,0x682e6ff3d6b2b8a3 +.quad 0x748f82ee5defb2fc,0x78a5636f43172f60 +.quad 0x84c87814a1f0ab72,0x8cc702081a6439ec +.quad 0x90befffa23631e28,0xa4506cebde82bde9 +.quad 0xbef9a3f7b2c67915,0xc67178f2e372532b +.quad 0xca273eceea26619c,0xd186b8c721c0c207 +.quad 0xeada7dd6cde0eb1e,0xf57d4f7fee6ed178 +.quad 0x06f067aa72176fba,0x0a637dc5a2c898a6 +.quad 0x113f9804bef90dae,0x1b710b35131c471b +.quad 0x28db77f523047d84,0x32caab7b40c72493 +.quad 0x3c9ebe0a15c9bebc,0x431d67c49c100d4c +.quad 0x4cc5d4becb3e42b6,0x597f299cfc657e2a +.quad 0x5fcb6fab3ad6faec,0x6c44198c4a475817 +.quad 0 // terminator +.size .LK512,.-.LK512 +.byte 83,72,65,53,49,50,32,98,108,111,99,107,32,116,114,97,110,115,102,111,114,109,32,102,111,114,32,65,82,77,118,56,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.align 2 +.align 2 +.text +#ifndef __KERNEL__ +.globl sha512_block_data_order_hw +.hidden sha512_block_data_order_hw +.type sha512_block_data_order_hw,%function +.align 6 +sha512_block_data_order_hw: + // Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later. + AARCH64_VALID_CALL_TARGET + stp x29,x30,[sp,#-16]! + add x29,sp,#0 + + ld1 {v16.16b,v17.16b,v18.16b,v19.16b},[x1],#64 // load input + ld1 {v20.16b,v21.16b,v22.16b,v23.16b},[x1],#64 + + ld1 {v0.2d,v1.2d,v2.2d,v3.2d},[x0] // load context + adrp x3,.LK512 + add x3,x3,:lo12:.LK512 + + rev64 v16.16b,v16.16b + rev64 v17.16b,v17.16b + rev64 v18.16b,v18.16b + rev64 v19.16b,v19.16b + rev64 v20.16b,v20.16b + rev64 v21.16b,v21.16b + rev64 v22.16b,v22.16b + rev64 v23.16b,v23.16b + b .Loop_hw + +.align 4 +.Loop_hw: + ld1 {v24.2d},[x3],#16 + subs x2,x2,#1 + sub x4,x1,#128 + orr v26.16b,v0.16b,v0.16b // offload + orr v27.16b,v1.16b,v1.16b + orr v28.16b,v2.16b,v2.16b + orr v29.16b,v3.16b,v3.16b + csel x1,x1,x4,ne // conditional rewind + add v24.2d,v24.2d,v16.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v2.16b,v3.16b,#8 + ext v6.16b,v1.16b,v2.16b,#8 + add v3.2d,v3.2d,v24.2d // "T1 + H + K512[i]" +.inst 0xcec08230 //sha512su0 v16.16b,v17.16b + ext v7.16b,v20.16b,v21.16b,#8 +.inst 0xce6680a3 //sha512h v3.16b,v5.16b,v6.16b +.inst 0xce678af0 //sha512su1 v16.16b,v23.16b,v7.16b + add v4.2d,v1.2d,v3.2d // "D + T1" +.inst 0xce608423 //sha512h2 v3.16b,v1.16b,v0.16b + add v25.2d,v25.2d,v17.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v4.16b,v2.16b,#8 + ext v6.16b,v0.16b,v4.16b,#8 + add v2.2d,v2.2d,v25.2d // "T1 + H + K512[i]" +.inst 0xcec08251 //sha512su0 v17.16b,v18.16b + ext v7.16b,v21.16b,v22.16b,#8 +.inst 0xce6680a2 //sha512h v2.16b,v5.16b,v6.16b +.inst 0xce678a11 //sha512su1 v17.16b,v16.16b,v7.16b + add v1.2d,v0.2d,v2.2d // "D + T1" +.inst 0xce638402 //sha512h2 v2.16b,v0.16b,v3.16b + add v24.2d,v24.2d,v18.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v1.16b,v4.16b,#8 + ext v6.16b,v3.16b,v1.16b,#8 + add v4.2d,v4.2d,v24.2d // "T1 + H + K512[i]" +.inst 0xcec08272 //sha512su0 v18.16b,v19.16b + ext v7.16b,v22.16b,v23.16b,#8 +.inst 0xce6680a4 //sha512h v4.16b,v5.16b,v6.16b +.inst 0xce678a32 //sha512su1 v18.16b,v17.16b,v7.16b + add v0.2d,v3.2d,v4.2d // "D + T1" +.inst 0xce628464 //sha512h2 v4.16b,v3.16b,v2.16b + add v25.2d,v25.2d,v19.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v0.16b,v1.16b,#8 + ext v6.16b,v2.16b,v0.16b,#8 + add v1.2d,v1.2d,v25.2d // "T1 + H + K512[i]" +.inst 0xcec08293 //sha512su0 v19.16b,v20.16b + ext v7.16b,v23.16b,v16.16b,#8 +.inst 0xce6680a1 //sha512h v1.16b,v5.16b,v6.16b +.inst 0xce678a53 //sha512su1 v19.16b,v18.16b,v7.16b + add v3.2d,v2.2d,v1.2d // "D + T1" +.inst 0xce648441 //sha512h2 v1.16b,v2.16b,v4.16b + add v24.2d,v24.2d,v20.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v3.16b,v0.16b,#8 + ext v6.16b,v4.16b,v3.16b,#8 + add v0.2d,v0.2d,v24.2d // "T1 + H + K512[i]" +.inst 0xcec082b4 //sha512su0 v20.16b,v21.16b + ext v7.16b,v16.16b,v17.16b,#8 +.inst 0xce6680a0 //sha512h v0.16b,v5.16b,v6.16b +.inst 0xce678a74 //sha512su1 v20.16b,v19.16b,v7.16b + add v2.2d,v4.2d,v0.2d // "D + T1" +.inst 0xce618480 //sha512h2 v0.16b,v4.16b,v1.16b + add v25.2d,v25.2d,v21.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v2.16b,v3.16b,#8 + ext v6.16b,v1.16b,v2.16b,#8 + add v3.2d,v3.2d,v25.2d // "T1 + H + K512[i]" +.inst 0xcec082d5 //sha512su0 v21.16b,v22.16b + ext v7.16b,v17.16b,v18.16b,#8 +.inst 0xce6680a3 //sha512h v3.16b,v5.16b,v6.16b +.inst 0xce678a95 //sha512su1 v21.16b,v20.16b,v7.16b + add v4.2d,v1.2d,v3.2d // "D + T1" +.inst 0xce608423 //sha512h2 v3.16b,v1.16b,v0.16b + add v24.2d,v24.2d,v22.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v4.16b,v2.16b,#8 + ext v6.16b,v0.16b,v4.16b,#8 + add v2.2d,v2.2d,v24.2d // "T1 + H + K512[i]" +.inst 0xcec082f6 //sha512su0 v22.16b,v23.16b + ext v7.16b,v18.16b,v19.16b,#8 +.inst 0xce6680a2 //sha512h v2.16b,v5.16b,v6.16b +.inst 0xce678ab6 //sha512su1 v22.16b,v21.16b,v7.16b + add v1.2d,v0.2d,v2.2d // "D + T1" +.inst 0xce638402 //sha512h2 v2.16b,v0.16b,v3.16b + add v25.2d,v25.2d,v23.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v1.16b,v4.16b,#8 + ext v6.16b,v3.16b,v1.16b,#8 + add v4.2d,v4.2d,v25.2d // "T1 + H + K512[i]" +.inst 0xcec08217 //sha512su0 v23.16b,v16.16b + ext v7.16b,v19.16b,v20.16b,#8 +.inst 0xce6680a4 //sha512h v4.16b,v5.16b,v6.16b +.inst 0xce678ad7 //sha512su1 v23.16b,v22.16b,v7.16b + add v0.2d,v3.2d,v4.2d // "D + T1" +.inst 0xce628464 //sha512h2 v4.16b,v3.16b,v2.16b + add v24.2d,v24.2d,v16.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v0.16b,v1.16b,#8 + ext v6.16b,v2.16b,v0.16b,#8 + add v1.2d,v1.2d,v24.2d // "T1 + H + K512[i]" +.inst 0xcec08230 //sha512su0 v16.16b,v17.16b + ext v7.16b,v20.16b,v21.16b,#8 +.inst 0xce6680a1 //sha512h v1.16b,v5.16b,v6.16b +.inst 0xce678af0 //sha512su1 v16.16b,v23.16b,v7.16b + add v3.2d,v2.2d,v1.2d // "D + T1" +.inst 0xce648441 //sha512h2 v1.16b,v2.16b,v4.16b + add v25.2d,v25.2d,v17.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v3.16b,v0.16b,#8 + ext v6.16b,v4.16b,v3.16b,#8 + add v0.2d,v0.2d,v25.2d // "T1 + H + K512[i]" +.inst 0xcec08251 //sha512su0 v17.16b,v18.16b + ext v7.16b,v21.16b,v22.16b,#8 +.inst 0xce6680a0 //sha512h v0.16b,v5.16b,v6.16b +.inst 0xce678a11 //sha512su1 v17.16b,v16.16b,v7.16b + add v2.2d,v4.2d,v0.2d // "D + T1" +.inst 0xce618480 //sha512h2 v0.16b,v4.16b,v1.16b + add v24.2d,v24.2d,v18.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v2.16b,v3.16b,#8 + ext v6.16b,v1.16b,v2.16b,#8 + add v3.2d,v3.2d,v24.2d // "T1 + H + K512[i]" +.inst 0xcec08272 //sha512su0 v18.16b,v19.16b + ext v7.16b,v22.16b,v23.16b,#8 +.inst 0xce6680a3 //sha512h v3.16b,v5.16b,v6.16b +.inst 0xce678a32 //sha512su1 v18.16b,v17.16b,v7.16b + add v4.2d,v1.2d,v3.2d // "D + T1" +.inst 0xce608423 //sha512h2 v3.16b,v1.16b,v0.16b + add v25.2d,v25.2d,v19.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v4.16b,v2.16b,#8 + ext v6.16b,v0.16b,v4.16b,#8 + add v2.2d,v2.2d,v25.2d // "T1 + H + K512[i]" +.inst 0xcec08293 //sha512su0 v19.16b,v20.16b + ext v7.16b,v23.16b,v16.16b,#8 +.inst 0xce6680a2 //sha512h v2.16b,v5.16b,v6.16b +.inst 0xce678a53 //sha512su1 v19.16b,v18.16b,v7.16b + add v1.2d,v0.2d,v2.2d // "D + T1" +.inst 0xce638402 //sha512h2 v2.16b,v0.16b,v3.16b + add v24.2d,v24.2d,v20.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v1.16b,v4.16b,#8 + ext v6.16b,v3.16b,v1.16b,#8 + add v4.2d,v4.2d,v24.2d // "T1 + H + K512[i]" +.inst 0xcec082b4 //sha512su0 v20.16b,v21.16b + ext v7.16b,v16.16b,v17.16b,#8 +.inst 0xce6680a4 //sha512h v4.16b,v5.16b,v6.16b +.inst 0xce678a74 //sha512su1 v20.16b,v19.16b,v7.16b + add v0.2d,v3.2d,v4.2d // "D + T1" +.inst 0xce628464 //sha512h2 v4.16b,v3.16b,v2.16b + add v25.2d,v25.2d,v21.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v0.16b,v1.16b,#8 + ext v6.16b,v2.16b,v0.16b,#8 + add v1.2d,v1.2d,v25.2d // "T1 + H + K512[i]" +.inst 0xcec082d5 //sha512su0 v21.16b,v22.16b + ext v7.16b,v17.16b,v18.16b,#8 +.inst 0xce6680a1 //sha512h v1.16b,v5.16b,v6.16b +.inst 0xce678a95 //sha512su1 v21.16b,v20.16b,v7.16b + add v3.2d,v2.2d,v1.2d // "D + T1" +.inst 0xce648441 //sha512h2 v1.16b,v2.16b,v4.16b + add v24.2d,v24.2d,v22.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v3.16b,v0.16b,#8 + ext v6.16b,v4.16b,v3.16b,#8 + add v0.2d,v0.2d,v24.2d // "T1 + H + K512[i]" +.inst 0xcec082f6 //sha512su0 v22.16b,v23.16b + ext v7.16b,v18.16b,v19.16b,#8 +.inst 0xce6680a0 //sha512h v0.16b,v5.16b,v6.16b +.inst 0xce678ab6 //sha512su1 v22.16b,v21.16b,v7.16b + add v2.2d,v4.2d,v0.2d // "D + T1" +.inst 0xce618480 //sha512h2 v0.16b,v4.16b,v1.16b + add v25.2d,v25.2d,v23.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v2.16b,v3.16b,#8 + ext v6.16b,v1.16b,v2.16b,#8 + add v3.2d,v3.2d,v25.2d // "T1 + H + K512[i]" +.inst 0xcec08217 //sha512su0 v23.16b,v16.16b + ext v7.16b,v19.16b,v20.16b,#8 +.inst 0xce6680a3 //sha512h v3.16b,v5.16b,v6.16b +.inst 0xce678ad7 //sha512su1 v23.16b,v22.16b,v7.16b + add v4.2d,v1.2d,v3.2d // "D + T1" +.inst 0xce608423 //sha512h2 v3.16b,v1.16b,v0.16b + add v24.2d,v24.2d,v16.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v4.16b,v2.16b,#8 + ext v6.16b,v0.16b,v4.16b,#8 + add v2.2d,v2.2d,v24.2d // "T1 + H + K512[i]" +.inst 0xcec08230 //sha512su0 v16.16b,v17.16b + ext v7.16b,v20.16b,v21.16b,#8 +.inst 0xce6680a2 //sha512h v2.16b,v5.16b,v6.16b +.inst 0xce678af0 //sha512su1 v16.16b,v23.16b,v7.16b + add v1.2d,v0.2d,v2.2d // "D + T1" +.inst 0xce638402 //sha512h2 v2.16b,v0.16b,v3.16b + add v25.2d,v25.2d,v17.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v1.16b,v4.16b,#8 + ext v6.16b,v3.16b,v1.16b,#8 + add v4.2d,v4.2d,v25.2d // "T1 + H + K512[i]" +.inst 0xcec08251 //sha512su0 v17.16b,v18.16b + ext v7.16b,v21.16b,v22.16b,#8 +.inst 0xce6680a4 //sha512h v4.16b,v5.16b,v6.16b +.inst 0xce678a11 //sha512su1 v17.16b,v16.16b,v7.16b + add v0.2d,v3.2d,v4.2d // "D + T1" +.inst 0xce628464 //sha512h2 v4.16b,v3.16b,v2.16b + add v24.2d,v24.2d,v18.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v0.16b,v1.16b,#8 + ext v6.16b,v2.16b,v0.16b,#8 + add v1.2d,v1.2d,v24.2d // "T1 + H + K512[i]" +.inst 0xcec08272 //sha512su0 v18.16b,v19.16b + ext v7.16b,v22.16b,v23.16b,#8 +.inst 0xce6680a1 //sha512h v1.16b,v5.16b,v6.16b +.inst 0xce678a32 //sha512su1 v18.16b,v17.16b,v7.16b + add v3.2d,v2.2d,v1.2d // "D + T1" +.inst 0xce648441 //sha512h2 v1.16b,v2.16b,v4.16b + add v25.2d,v25.2d,v19.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v3.16b,v0.16b,#8 + ext v6.16b,v4.16b,v3.16b,#8 + add v0.2d,v0.2d,v25.2d // "T1 + H + K512[i]" +.inst 0xcec08293 //sha512su0 v19.16b,v20.16b + ext v7.16b,v23.16b,v16.16b,#8 +.inst 0xce6680a0 //sha512h v0.16b,v5.16b,v6.16b +.inst 0xce678a53 //sha512su1 v19.16b,v18.16b,v7.16b + add v2.2d,v4.2d,v0.2d // "D + T1" +.inst 0xce618480 //sha512h2 v0.16b,v4.16b,v1.16b + add v24.2d,v24.2d,v20.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v2.16b,v3.16b,#8 + ext v6.16b,v1.16b,v2.16b,#8 + add v3.2d,v3.2d,v24.2d // "T1 + H + K512[i]" +.inst 0xcec082b4 //sha512su0 v20.16b,v21.16b + ext v7.16b,v16.16b,v17.16b,#8 +.inst 0xce6680a3 //sha512h v3.16b,v5.16b,v6.16b +.inst 0xce678a74 //sha512su1 v20.16b,v19.16b,v7.16b + add v4.2d,v1.2d,v3.2d // "D + T1" +.inst 0xce608423 //sha512h2 v3.16b,v1.16b,v0.16b + add v25.2d,v25.2d,v21.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v4.16b,v2.16b,#8 + ext v6.16b,v0.16b,v4.16b,#8 + add v2.2d,v2.2d,v25.2d // "T1 + H + K512[i]" +.inst 0xcec082d5 //sha512su0 v21.16b,v22.16b + ext v7.16b,v17.16b,v18.16b,#8 +.inst 0xce6680a2 //sha512h v2.16b,v5.16b,v6.16b +.inst 0xce678a95 //sha512su1 v21.16b,v20.16b,v7.16b + add v1.2d,v0.2d,v2.2d // "D + T1" +.inst 0xce638402 //sha512h2 v2.16b,v0.16b,v3.16b + add v24.2d,v24.2d,v22.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v1.16b,v4.16b,#8 + ext v6.16b,v3.16b,v1.16b,#8 + add v4.2d,v4.2d,v24.2d // "T1 + H + K512[i]" +.inst 0xcec082f6 //sha512su0 v22.16b,v23.16b + ext v7.16b,v18.16b,v19.16b,#8 +.inst 0xce6680a4 //sha512h v4.16b,v5.16b,v6.16b +.inst 0xce678ab6 //sha512su1 v22.16b,v21.16b,v7.16b + add v0.2d,v3.2d,v4.2d // "D + T1" +.inst 0xce628464 //sha512h2 v4.16b,v3.16b,v2.16b + add v25.2d,v25.2d,v23.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v0.16b,v1.16b,#8 + ext v6.16b,v2.16b,v0.16b,#8 + add v1.2d,v1.2d,v25.2d // "T1 + H + K512[i]" +.inst 0xcec08217 //sha512su0 v23.16b,v16.16b + ext v7.16b,v19.16b,v20.16b,#8 +.inst 0xce6680a1 //sha512h v1.16b,v5.16b,v6.16b +.inst 0xce678ad7 //sha512su1 v23.16b,v22.16b,v7.16b + add v3.2d,v2.2d,v1.2d // "D + T1" +.inst 0xce648441 //sha512h2 v1.16b,v2.16b,v4.16b + add v24.2d,v24.2d,v16.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v3.16b,v0.16b,#8 + ext v6.16b,v4.16b,v3.16b,#8 + add v0.2d,v0.2d,v24.2d // "T1 + H + K512[i]" +.inst 0xcec08230 //sha512su0 v16.16b,v17.16b + ext v7.16b,v20.16b,v21.16b,#8 +.inst 0xce6680a0 //sha512h v0.16b,v5.16b,v6.16b +.inst 0xce678af0 //sha512su1 v16.16b,v23.16b,v7.16b + add v2.2d,v4.2d,v0.2d // "D + T1" +.inst 0xce618480 //sha512h2 v0.16b,v4.16b,v1.16b + add v25.2d,v25.2d,v17.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v2.16b,v3.16b,#8 + ext v6.16b,v1.16b,v2.16b,#8 + add v3.2d,v3.2d,v25.2d // "T1 + H + K512[i]" +.inst 0xcec08251 //sha512su0 v17.16b,v18.16b + ext v7.16b,v21.16b,v22.16b,#8 +.inst 0xce6680a3 //sha512h v3.16b,v5.16b,v6.16b +.inst 0xce678a11 //sha512su1 v17.16b,v16.16b,v7.16b + add v4.2d,v1.2d,v3.2d // "D + T1" +.inst 0xce608423 //sha512h2 v3.16b,v1.16b,v0.16b + add v24.2d,v24.2d,v18.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v4.16b,v2.16b,#8 + ext v6.16b,v0.16b,v4.16b,#8 + add v2.2d,v2.2d,v24.2d // "T1 + H + K512[i]" +.inst 0xcec08272 //sha512su0 v18.16b,v19.16b + ext v7.16b,v22.16b,v23.16b,#8 +.inst 0xce6680a2 //sha512h v2.16b,v5.16b,v6.16b +.inst 0xce678a32 //sha512su1 v18.16b,v17.16b,v7.16b + add v1.2d,v0.2d,v2.2d // "D + T1" +.inst 0xce638402 //sha512h2 v2.16b,v0.16b,v3.16b + add v25.2d,v25.2d,v19.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v1.16b,v4.16b,#8 + ext v6.16b,v3.16b,v1.16b,#8 + add v4.2d,v4.2d,v25.2d // "T1 + H + K512[i]" +.inst 0xcec08293 //sha512su0 v19.16b,v20.16b + ext v7.16b,v23.16b,v16.16b,#8 +.inst 0xce6680a4 //sha512h v4.16b,v5.16b,v6.16b +.inst 0xce678a53 //sha512su1 v19.16b,v18.16b,v7.16b + add v0.2d,v3.2d,v4.2d // "D + T1" +.inst 0xce628464 //sha512h2 v4.16b,v3.16b,v2.16b + add v24.2d,v24.2d,v20.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v0.16b,v1.16b,#8 + ext v6.16b,v2.16b,v0.16b,#8 + add v1.2d,v1.2d,v24.2d // "T1 + H + K512[i]" +.inst 0xcec082b4 //sha512su0 v20.16b,v21.16b + ext v7.16b,v16.16b,v17.16b,#8 +.inst 0xce6680a1 //sha512h v1.16b,v5.16b,v6.16b +.inst 0xce678a74 //sha512su1 v20.16b,v19.16b,v7.16b + add v3.2d,v2.2d,v1.2d // "D + T1" +.inst 0xce648441 //sha512h2 v1.16b,v2.16b,v4.16b + add v25.2d,v25.2d,v21.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v3.16b,v0.16b,#8 + ext v6.16b,v4.16b,v3.16b,#8 + add v0.2d,v0.2d,v25.2d // "T1 + H + K512[i]" +.inst 0xcec082d5 //sha512su0 v21.16b,v22.16b + ext v7.16b,v17.16b,v18.16b,#8 +.inst 0xce6680a0 //sha512h v0.16b,v5.16b,v6.16b +.inst 0xce678a95 //sha512su1 v21.16b,v20.16b,v7.16b + add v2.2d,v4.2d,v0.2d // "D + T1" +.inst 0xce618480 //sha512h2 v0.16b,v4.16b,v1.16b + add v24.2d,v24.2d,v22.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v2.16b,v3.16b,#8 + ext v6.16b,v1.16b,v2.16b,#8 + add v3.2d,v3.2d,v24.2d // "T1 + H + K512[i]" +.inst 0xcec082f6 //sha512su0 v22.16b,v23.16b + ext v7.16b,v18.16b,v19.16b,#8 +.inst 0xce6680a3 //sha512h v3.16b,v5.16b,v6.16b +.inst 0xce678ab6 //sha512su1 v22.16b,v21.16b,v7.16b + add v4.2d,v1.2d,v3.2d // "D + T1" +.inst 0xce608423 //sha512h2 v3.16b,v1.16b,v0.16b + add v25.2d,v25.2d,v23.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v4.16b,v2.16b,#8 + ext v6.16b,v0.16b,v4.16b,#8 + add v2.2d,v2.2d,v25.2d // "T1 + H + K512[i]" +.inst 0xcec08217 //sha512su0 v23.16b,v16.16b + ext v7.16b,v19.16b,v20.16b,#8 +.inst 0xce6680a2 //sha512h v2.16b,v5.16b,v6.16b +.inst 0xce678ad7 //sha512su1 v23.16b,v22.16b,v7.16b + add v1.2d,v0.2d,v2.2d // "D + T1" +.inst 0xce638402 //sha512h2 v2.16b,v0.16b,v3.16b + ld1 {v25.2d},[x3],#16 + add v24.2d,v24.2d,v16.2d + ld1 {v16.16b},[x1],#16 // load next input + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v1.16b,v4.16b,#8 + ext v6.16b,v3.16b,v1.16b,#8 + add v4.2d,v4.2d,v24.2d // "T1 + H + K512[i]" +.inst 0xce6680a4 //sha512h v4.16b,v5.16b,v6.16b + rev64 v16.16b,v16.16b + add v0.2d,v3.2d,v4.2d // "D + T1" +.inst 0xce628464 //sha512h2 v4.16b,v3.16b,v2.16b + ld1 {v24.2d},[x3],#16 + add v25.2d,v25.2d,v17.2d + ld1 {v17.16b},[x1],#16 // load next input + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v0.16b,v1.16b,#8 + ext v6.16b,v2.16b,v0.16b,#8 + add v1.2d,v1.2d,v25.2d // "T1 + H + K512[i]" +.inst 0xce6680a1 //sha512h v1.16b,v5.16b,v6.16b + rev64 v17.16b,v17.16b + add v3.2d,v2.2d,v1.2d // "D + T1" +.inst 0xce648441 //sha512h2 v1.16b,v2.16b,v4.16b + ld1 {v25.2d},[x3],#16 + add v24.2d,v24.2d,v18.2d + ld1 {v18.16b},[x1],#16 // load next input + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v3.16b,v0.16b,#8 + ext v6.16b,v4.16b,v3.16b,#8 + add v0.2d,v0.2d,v24.2d // "T1 + H + K512[i]" +.inst 0xce6680a0 //sha512h v0.16b,v5.16b,v6.16b + rev64 v18.16b,v18.16b + add v2.2d,v4.2d,v0.2d // "D + T1" +.inst 0xce618480 //sha512h2 v0.16b,v4.16b,v1.16b + ld1 {v24.2d},[x3],#16 + add v25.2d,v25.2d,v19.2d + ld1 {v19.16b},[x1],#16 // load next input + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v2.16b,v3.16b,#8 + ext v6.16b,v1.16b,v2.16b,#8 + add v3.2d,v3.2d,v25.2d // "T1 + H + K512[i]" +.inst 0xce6680a3 //sha512h v3.16b,v5.16b,v6.16b + rev64 v19.16b,v19.16b + add v4.2d,v1.2d,v3.2d // "D + T1" +.inst 0xce608423 //sha512h2 v3.16b,v1.16b,v0.16b + ld1 {v25.2d},[x3],#16 + add v24.2d,v24.2d,v20.2d + ld1 {v20.16b},[x1],#16 // load next input + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v4.16b,v2.16b,#8 + ext v6.16b,v0.16b,v4.16b,#8 + add v2.2d,v2.2d,v24.2d // "T1 + H + K512[i]" +.inst 0xce6680a2 //sha512h v2.16b,v5.16b,v6.16b + rev64 v20.16b,v20.16b + add v1.2d,v0.2d,v2.2d // "D + T1" +.inst 0xce638402 //sha512h2 v2.16b,v0.16b,v3.16b + ld1 {v24.2d},[x3],#16 + add v25.2d,v25.2d,v21.2d + ld1 {v21.16b},[x1],#16 // load next input + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v1.16b,v4.16b,#8 + ext v6.16b,v3.16b,v1.16b,#8 + add v4.2d,v4.2d,v25.2d // "T1 + H + K512[i]" +.inst 0xce6680a4 //sha512h v4.16b,v5.16b,v6.16b + rev64 v21.16b,v21.16b + add v0.2d,v3.2d,v4.2d // "D + T1" +.inst 0xce628464 //sha512h2 v4.16b,v3.16b,v2.16b + ld1 {v25.2d},[x3],#16 + add v24.2d,v24.2d,v22.2d + ld1 {v22.16b},[x1],#16 // load next input + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v0.16b,v1.16b,#8 + ext v6.16b,v2.16b,v0.16b,#8 + add v1.2d,v1.2d,v24.2d // "T1 + H + K512[i]" +.inst 0xce6680a1 //sha512h v1.16b,v5.16b,v6.16b + rev64 v22.16b,v22.16b + add v3.2d,v2.2d,v1.2d // "D + T1" +.inst 0xce648441 //sha512h2 v1.16b,v2.16b,v4.16b + sub x3,x3,#80*8 // rewind + add v25.2d,v25.2d,v23.2d + ld1 {v23.16b},[x1],#16 // load next input + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v3.16b,v0.16b,#8 + ext v6.16b,v4.16b,v3.16b,#8 + add v0.2d,v0.2d,v25.2d // "T1 + H + K512[i]" +.inst 0xce6680a0 //sha512h v0.16b,v5.16b,v6.16b + rev64 v23.16b,v23.16b + add v2.2d,v4.2d,v0.2d // "D + T1" +.inst 0xce618480 //sha512h2 v0.16b,v4.16b,v1.16b + add v0.2d,v0.2d,v26.2d // accumulate + add v1.2d,v1.2d,v27.2d + add v2.2d,v2.2d,v28.2d + add v3.2d,v3.2d,v29.2d + + cbnz x2,.Loop_hw + + st1 {v0.2d,v1.2d,v2.2d,v3.2d},[x0] // store context + + ldr x29,[sp],#16 + ret +.size sha512_block_data_order_hw,.-sha512_block_data_order_hw +#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__ELF__) diff --git a/http/vendor/ring/pregenerated/sha512-armv8-win64.S b/http/vendor/ring/pregenerated/sha512-armv8-win64.S new file mode 100644 index 0000000..340b2b0 --- /dev/null +++ b/http/vendor/ring/pregenerated/sha512-armv8-win64.S @@ -0,0 +1,1602 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(_WIN32) +// Copyright 2014-2020 The OpenSSL Project Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// ==================================================================== +// Written by Andy Polyakov for the OpenSSL +// project. +// ==================================================================== +// +// SHA256/512 for ARMv8. +// +// Performance in cycles per processed byte and improvement coefficient +// over code generated with "default" compiler: +// +// SHA256-hw SHA256(*) SHA512 +// Apple A7 1.97 10.5 (+33%) 6.73 (-1%(**)) +// Cortex-A53 2.38 15.5 (+115%) 10.0 (+150%(***)) +// Cortex-A57 2.31 11.6 (+86%) 7.51 (+260%(***)) +// Denver 2.01 10.5 (+26%) 6.70 (+8%) +// X-Gene 20.0 (+100%) 12.8 (+300%(***)) +// Mongoose 2.36 13.0 (+50%) 8.36 (+33%) +// Kryo 1.92 17.4 (+30%) 11.2 (+8%) +// +// (*) Software SHA256 results are of lesser relevance, presented +// mostly for informational purposes. +// (**) The result is a trade-off: it's possible to improve it by +// 10% (or by 1 cycle per round), but at the cost of 20% loss +// on Cortex-A53 (or by 4 cycles per round). +// (***) Super-impressive coefficients over gcc-generated code are +// indication of some compiler "pathology", most notably code +// generated with -mgeneral-regs-only is significantly faster +// and the gap is only 40-90%. + +#ifndef __KERNEL__ +#endif + +.text + +.globl sha512_block_data_order_nohw + +.def sha512_block_data_order_nohw + .type 32 +.endef +.align 6 +sha512_block_data_order_nohw: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-128]! + add x29,sp,#0 + + stp x19,x20,[sp,#16] + stp x21,x22,[sp,#32] + stp x23,x24,[sp,#48] + stp x25,x26,[sp,#64] + stp x27,x28,[sp,#80] + sub sp,sp,#4*8 + + ldp x20,x21,[x0] // load context + ldp x22,x23,[x0,#2*8] + ldp x24,x25,[x0,#4*8] + add x2,x1,x2,lsl#7 // end of input + ldp x26,x27,[x0,#6*8] + adrp x30,LK512 + add x30,x30,:lo12:LK512 + stp x0,x2,[x29,#96] + +Loop: + ldp x3,x4,[x1],#2*8 + ldr x19,[x30],#8 // *K++ + eor x28,x21,x22 // magic seed + str x1,[x29,#112] +#ifndef __AARCH64EB__ + rev x3,x3 // 0 +#endif + ror x16,x24,#14 + add x27,x27,x19 // h+=K[i] + eor x6,x24,x24,ror#23 + and x17,x25,x24 + bic x19,x26,x24 + add x27,x27,x3 // h+=X[i] + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x20,x21 // a^b, b^c in next round + eor x16,x16,x6,ror#18 // Sigma1(e) + ror x6,x20,#28 + add x27,x27,x17 // h+=Ch(e,f,g) + eor x17,x20,x20,ror#5 + add x27,x27,x16 // h+=Sigma1(e) + and x28,x28,x19 // (b^c)&=(a^b) + add x23,x23,x27 // d+=h + eor x28,x28,x21 // Maj(a,b,c) + eor x17,x6,x17,ror#34 // Sigma0(a) + add x27,x27,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + //add x27,x27,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x4,x4 // 1 +#endif + ldp x5,x6,[x1],#2*8 + add x27,x27,x17 // h+=Sigma0(a) + ror x16,x23,#14 + add x26,x26,x28 // h+=K[i] + eor x7,x23,x23,ror#23 + and x17,x24,x23 + bic x28,x25,x23 + add x26,x26,x4 // h+=X[i] + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x27,x20 // a^b, b^c in next round + eor x16,x16,x7,ror#18 // Sigma1(e) + ror x7,x27,#28 + add x26,x26,x17 // h+=Ch(e,f,g) + eor x17,x27,x27,ror#5 + add x26,x26,x16 // h+=Sigma1(e) + and x19,x19,x28 // (b^c)&=(a^b) + add x22,x22,x26 // d+=h + eor x19,x19,x20 // Maj(a,b,c) + eor x17,x7,x17,ror#34 // Sigma0(a) + add x26,x26,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + //add x26,x26,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x5,x5 // 2 +#endif + add x26,x26,x17 // h+=Sigma0(a) + ror x16,x22,#14 + add x25,x25,x19 // h+=K[i] + eor x8,x22,x22,ror#23 + and x17,x23,x22 + bic x19,x24,x22 + add x25,x25,x5 // h+=X[i] + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x26,x27 // a^b, b^c in next round + eor x16,x16,x8,ror#18 // Sigma1(e) + ror x8,x26,#28 + add x25,x25,x17 // h+=Ch(e,f,g) + eor x17,x26,x26,ror#5 + add x25,x25,x16 // h+=Sigma1(e) + and x28,x28,x19 // (b^c)&=(a^b) + add x21,x21,x25 // d+=h + eor x28,x28,x27 // Maj(a,b,c) + eor x17,x8,x17,ror#34 // Sigma0(a) + add x25,x25,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + //add x25,x25,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x6,x6 // 3 +#endif + ldp x7,x8,[x1],#2*8 + add x25,x25,x17 // h+=Sigma0(a) + ror x16,x21,#14 + add x24,x24,x28 // h+=K[i] + eor x9,x21,x21,ror#23 + and x17,x22,x21 + bic x28,x23,x21 + add x24,x24,x6 // h+=X[i] + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x25,x26 // a^b, b^c in next round + eor x16,x16,x9,ror#18 // Sigma1(e) + ror x9,x25,#28 + add x24,x24,x17 // h+=Ch(e,f,g) + eor x17,x25,x25,ror#5 + add x24,x24,x16 // h+=Sigma1(e) + and x19,x19,x28 // (b^c)&=(a^b) + add x20,x20,x24 // d+=h + eor x19,x19,x26 // Maj(a,b,c) + eor x17,x9,x17,ror#34 // Sigma0(a) + add x24,x24,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + //add x24,x24,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x7,x7 // 4 +#endif + add x24,x24,x17 // h+=Sigma0(a) + ror x16,x20,#14 + add x23,x23,x19 // h+=K[i] + eor x10,x20,x20,ror#23 + and x17,x21,x20 + bic x19,x22,x20 + add x23,x23,x7 // h+=X[i] + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x24,x25 // a^b, b^c in next round + eor x16,x16,x10,ror#18 // Sigma1(e) + ror x10,x24,#28 + add x23,x23,x17 // h+=Ch(e,f,g) + eor x17,x24,x24,ror#5 + add x23,x23,x16 // h+=Sigma1(e) + and x28,x28,x19 // (b^c)&=(a^b) + add x27,x27,x23 // d+=h + eor x28,x28,x25 // Maj(a,b,c) + eor x17,x10,x17,ror#34 // Sigma0(a) + add x23,x23,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + //add x23,x23,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x8,x8 // 5 +#endif + ldp x9,x10,[x1],#2*8 + add x23,x23,x17 // h+=Sigma0(a) + ror x16,x27,#14 + add x22,x22,x28 // h+=K[i] + eor x11,x27,x27,ror#23 + and x17,x20,x27 + bic x28,x21,x27 + add x22,x22,x8 // h+=X[i] + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x23,x24 // a^b, b^c in next round + eor x16,x16,x11,ror#18 // Sigma1(e) + ror x11,x23,#28 + add x22,x22,x17 // h+=Ch(e,f,g) + eor x17,x23,x23,ror#5 + add x22,x22,x16 // h+=Sigma1(e) + and x19,x19,x28 // (b^c)&=(a^b) + add x26,x26,x22 // d+=h + eor x19,x19,x24 // Maj(a,b,c) + eor x17,x11,x17,ror#34 // Sigma0(a) + add x22,x22,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + //add x22,x22,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x9,x9 // 6 +#endif + add x22,x22,x17 // h+=Sigma0(a) + ror x16,x26,#14 + add x21,x21,x19 // h+=K[i] + eor x12,x26,x26,ror#23 + and x17,x27,x26 + bic x19,x20,x26 + add x21,x21,x9 // h+=X[i] + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x22,x23 // a^b, b^c in next round + eor x16,x16,x12,ror#18 // Sigma1(e) + ror x12,x22,#28 + add x21,x21,x17 // h+=Ch(e,f,g) + eor x17,x22,x22,ror#5 + add x21,x21,x16 // h+=Sigma1(e) + and x28,x28,x19 // (b^c)&=(a^b) + add x25,x25,x21 // d+=h + eor x28,x28,x23 // Maj(a,b,c) + eor x17,x12,x17,ror#34 // Sigma0(a) + add x21,x21,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + //add x21,x21,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x10,x10 // 7 +#endif + ldp x11,x12,[x1],#2*8 + add x21,x21,x17 // h+=Sigma0(a) + ror x16,x25,#14 + add x20,x20,x28 // h+=K[i] + eor x13,x25,x25,ror#23 + and x17,x26,x25 + bic x28,x27,x25 + add x20,x20,x10 // h+=X[i] + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x21,x22 // a^b, b^c in next round + eor x16,x16,x13,ror#18 // Sigma1(e) + ror x13,x21,#28 + add x20,x20,x17 // h+=Ch(e,f,g) + eor x17,x21,x21,ror#5 + add x20,x20,x16 // h+=Sigma1(e) + and x19,x19,x28 // (b^c)&=(a^b) + add x24,x24,x20 // d+=h + eor x19,x19,x22 // Maj(a,b,c) + eor x17,x13,x17,ror#34 // Sigma0(a) + add x20,x20,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + //add x20,x20,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x11,x11 // 8 +#endif + add x20,x20,x17 // h+=Sigma0(a) + ror x16,x24,#14 + add x27,x27,x19 // h+=K[i] + eor x14,x24,x24,ror#23 + and x17,x25,x24 + bic x19,x26,x24 + add x27,x27,x11 // h+=X[i] + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x20,x21 // a^b, b^c in next round + eor x16,x16,x14,ror#18 // Sigma1(e) + ror x14,x20,#28 + add x27,x27,x17 // h+=Ch(e,f,g) + eor x17,x20,x20,ror#5 + add x27,x27,x16 // h+=Sigma1(e) + and x28,x28,x19 // (b^c)&=(a^b) + add x23,x23,x27 // d+=h + eor x28,x28,x21 // Maj(a,b,c) + eor x17,x14,x17,ror#34 // Sigma0(a) + add x27,x27,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + //add x27,x27,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x12,x12 // 9 +#endif + ldp x13,x14,[x1],#2*8 + add x27,x27,x17 // h+=Sigma0(a) + ror x16,x23,#14 + add x26,x26,x28 // h+=K[i] + eor x15,x23,x23,ror#23 + and x17,x24,x23 + bic x28,x25,x23 + add x26,x26,x12 // h+=X[i] + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x27,x20 // a^b, b^c in next round + eor x16,x16,x15,ror#18 // Sigma1(e) + ror x15,x27,#28 + add x26,x26,x17 // h+=Ch(e,f,g) + eor x17,x27,x27,ror#5 + add x26,x26,x16 // h+=Sigma1(e) + and x19,x19,x28 // (b^c)&=(a^b) + add x22,x22,x26 // d+=h + eor x19,x19,x20 // Maj(a,b,c) + eor x17,x15,x17,ror#34 // Sigma0(a) + add x26,x26,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + //add x26,x26,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x13,x13 // 10 +#endif + add x26,x26,x17 // h+=Sigma0(a) + ror x16,x22,#14 + add x25,x25,x19 // h+=K[i] + eor x0,x22,x22,ror#23 + and x17,x23,x22 + bic x19,x24,x22 + add x25,x25,x13 // h+=X[i] + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x26,x27 // a^b, b^c in next round + eor x16,x16,x0,ror#18 // Sigma1(e) + ror x0,x26,#28 + add x25,x25,x17 // h+=Ch(e,f,g) + eor x17,x26,x26,ror#5 + add x25,x25,x16 // h+=Sigma1(e) + and x28,x28,x19 // (b^c)&=(a^b) + add x21,x21,x25 // d+=h + eor x28,x28,x27 // Maj(a,b,c) + eor x17,x0,x17,ror#34 // Sigma0(a) + add x25,x25,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + //add x25,x25,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x14,x14 // 11 +#endif + ldp x15,x0,[x1],#2*8 + add x25,x25,x17 // h+=Sigma0(a) + str x6,[sp,#24] + ror x16,x21,#14 + add x24,x24,x28 // h+=K[i] + eor x6,x21,x21,ror#23 + and x17,x22,x21 + bic x28,x23,x21 + add x24,x24,x14 // h+=X[i] + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x25,x26 // a^b, b^c in next round + eor x16,x16,x6,ror#18 // Sigma1(e) + ror x6,x25,#28 + add x24,x24,x17 // h+=Ch(e,f,g) + eor x17,x25,x25,ror#5 + add x24,x24,x16 // h+=Sigma1(e) + and x19,x19,x28 // (b^c)&=(a^b) + add x20,x20,x24 // d+=h + eor x19,x19,x26 // Maj(a,b,c) + eor x17,x6,x17,ror#34 // Sigma0(a) + add x24,x24,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + //add x24,x24,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x15,x15 // 12 +#endif + add x24,x24,x17 // h+=Sigma0(a) + str x7,[sp,#0] + ror x16,x20,#14 + add x23,x23,x19 // h+=K[i] + eor x7,x20,x20,ror#23 + and x17,x21,x20 + bic x19,x22,x20 + add x23,x23,x15 // h+=X[i] + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x24,x25 // a^b, b^c in next round + eor x16,x16,x7,ror#18 // Sigma1(e) + ror x7,x24,#28 + add x23,x23,x17 // h+=Ch(e,f,g) + eor x17,x24,x24,ror#5 + add x23,x23,x16 // h+=Sigma1(e) + and x28,x28,x19 // (b^c)&=(a^b) + add x27,x27,x23 // d+=h + eor x28,x28,x25 // Maj(a,b,c) + eor x17,x7,x17,ror#34 // Sigma0(a) + add x23,x23,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + //add x23,x23,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x0,x0 // 13 +#endif + ldp x1,x2,[x1] + add x23,x23,x17 // h+=Sigma0(a) + str x8,[sp,#8] + ror x16,x27,#14 + add x22,x22,x28 // h+=K[i] + eor x8,x27,x27,ror#23 + and x17,x20,x27 + bic x28,x21,x27 + add x22,x22,x0 // h+=X[i] + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x23,x24 // a^b, b^c in next round + eor x16,x16,x8,ror#18 // Sigma1(e) + ror x8,x23,#28 + add x22,x22,x17 // h+=Ch(e,f,g) + eor x17,x23,x23,ror#5 + add x22,x22,x16 // h+=Sigma1(e) + and x19,x19,x28 // (b^c)&=(a^b) + add x26,x26,x22 // d+=h + eor x19,x19,x24 // Maj(a,b,c) + eor x17,x8,x17,ror#34 // Sigma0(a) + add x22,x22,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + //add x22,x22,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x1,x1 // 14 +#endif + ldr x6,[sp,#24] + add x22,x22,x17 // h+=Sigma0(a) + str x9,[sp,#16] + ror x16,x26,#14 + add x21,x21,x19 // h+=K[i] + eor x9,x26,x26,ror#23 + and x17,x27,x26 + bic x19,x20,x26 + add x21,x21,x1 // h+=X[i] + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x22,x23 // a^b, b^c in next round + eor x16,x16,x9,ror#18 // Sigma1(e) + ror x9,x22,#28 + add x21,x21,x17 // h+=Ch(e,f,g) + eor x17,x22,x22,ror#5 + add x21,x21,x16 // h+=Sigma1(e) + and x28,x28,x19 // (b^c)&=(a^b) + add x25,x25,x21 // d+=h + eor x28,x28,x23 // Maj(a,b,c) + eor x17,x9,x17,ror#34 // Sigma0(a) + add x21,x21,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + //add x21,x21,x17 // h+=Sigma0(a) +#ifndef __AARCH64EB__ + rev x2,x2 // 15 +#endif + ldr x7,[sp,#0] + add x21,x21,x17 // h+=Sigma0(a) + str x10,[sp,#24] + ror x16,x25,#14 + add x20,x20,x28 // h+=K[i] + ror x9,x4,#1 + and x17,x26,x25 + ror x8,x1,#19 + bic x28,x27,x25 + ror x10,x21,#28 + add x20,x20,x2 // h+=X[i] + eor x16,x16,x25,ror#18 + eor x9,x9,x4,ror#8 + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x21,x22 // a^b, b^c in next round + eor x16,x16,x25,ror#41 // Sigma1(e) + eor x10,x10,x21,ror#34 + add x20,x20,x17 // h+=Ch(e,f,g) + and x19,x19,x28 // (b^c)&=(a^b) + eor x8,x8,x1,ror#61 + eor x9,x9,x4,lsr#7 // sigma0(X[i+1]) + add x20,x20,x16 // h+=Sigma1(e) + eor x19,x19,x22 // Maj(a,b,c) + eor x17,x10,x21,ror#39 // Sigma0(a) + eor x8,x8,x1,lsr#6 // sigma1(X[i+14]) + add x3,x3,x12 + add x24,x24,x20 // d+=h + add x20,x20,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + add x3,x3,x9 + add x20,x20,x17 // h+=Sigma0(a) + add x3,x3,x8 +Loop_16_xx: + ldr x8,[sp,#8] + str x11,[sp,#0] + ror x16,x24,#14 + add x27,x27,x19 // h+=K[i] + ror x10,x5,#1 + and x17,x25,x24 + ror x9,x2,#19 + bic x19,x26,x24 + ror x11,x20,#28 + add x27,x27,x3 // h+=X[i] + eor x16,x16,x24,ror#18 + eor x10,x10,x5,ror#8 + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x20,x21 // a^b, b^c in next round + eor x16,x16,x24,ror#41 // Sigma1(e) + eor x11,x11,x20,ror#34 + add x27,x27,x17 // h+=Ch(e,f,g) + and x28,x28,x19 // (b^c)&=(a^b) + eor x9,x9,x2,ror#61 + eor x10,x10,x5,lsr#7 // sigma0(X[i+1]) + add x27,x27,x16 // h+=Sigma1(e) + eor x28,x28,x21 // Maj(a,b,c) + eor x17,x11,x20,ror#39 // Sigma0(a) + eor x9,x9,x2,lsr#6 // sigma1(X[i+14]) + add x4,x4,x13 + add x23,x23,x27 // d+=h + add x27,x27,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + add x4,x4,x10 + add x27,x27,x17 // h+=Sigma0(a) + add x4,x4,x9 + ldr x9,[sp,#16] + str x12,[sp,#8] + ror x16,x23,#14 + add x26,x26,x28 // h+=K[i] + ror x11,x6,#1 + and x17,x24,x23 + ror x10,x3,#19 + bic x28,x25,x23 + ror x12,x27,#28 + add x26,x26,x4 // h+=X[i] + eor x16,x16,x23,ror#18 + eor x11,x11,x6,ror#8 + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x27,x20 // a^b, b^c in next round + eor x16,x16,x23,ror#41 // Sigma1(e) + eor x12,x12,x27,ror#34 + add x26,x26,x17 // h+=Ch(e,f,g) + and x19,x19,x28 // (b^c)&=(a^b) + eor x10,x10,x3,ror#61 + eor x11,x11,x6,lsr#7 // sigma0(X[i+1]) + add x26,x26,x16 // h+=Sigma1(e) + eor x19,x19,x20 // Maj(a,b,c) + eor x17,x12,x27,ror#39 // Sigma0(a) + eor x10,x10,x3,lsr#6 // sigma1(X[i+14]) + add x5,x5,x14 + add x22,x22,x26 // d+=h + add x26,x26,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + add x5,x5,x11 + add x26,x26,x17 // h+=Sigma0(a) + add x5,x5,x10 + ldr x10,[sp,#24] + str x13,[sp,#16] + ror x16,x22,#14 + add x25,x25,x19 // h+=K[i] + ror x12,x7,#1 + and x17,x23,x22 + ror x11,x4,#19 + bic x19,x24,x22 + ror x13,x26,#28 + add x25,x25,x5 // h+=X[i] + eor x16,x16,x22,ror#18 + eor x12,x12,x7,ror#8 + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x26,x27 // a^b, b^c in next round + eor x16,x16,x22,ror#41 // Sigma1(e) + eor x13,x13,x26,ror#34 + add x25,x25,x17 // h+=Ch(e,f,g) + and x28,x28,x19 // (b^c)&=(a^b) + eor x11,x11,x4,ror#61 + eor x12,x12,x7,lsr#7 // sigma0(X[i+1]) + add x25,x25,x16 // h+=Sigma1(e) + eor x28,x28,x27 // Maj(a,b,c) + eor x17,x13,x26,ror#39 // Sigma0(a) + eor x11,x11,x4,lsr#6 // sigma1(X[i+14]) + add x6,x6,x15 + add x21,x21,x25 // d+=h + add x25,x25,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + add x6,x6,x12 + add x25,x25,x17 // h+=Sigma0(a) + add x6,x6,x11 + ldr x11,[sp,#0] + str x14,[sp,#24] + ror x16,x21,#14 + add x24,x24,x28 // h+=K[i] + ror x13,x8,#1 + and x17,x22,x21 + ror x12,x5,#19 + bic x28,x23,x21 + ror x14,x25,#28 + add x24,x24,x6 // h+=X[i] + eor x16,x16,x21,ror#18 + eor x13,x13,x8,ror#8 + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x25,x26 // a^b, b^c in next round + eor x16,x16,x21,ror#41 // Sigma1(e) + eor x14,x14,x25,ror#34 + add x24,x24,x17 // h+=Ch(e,f,g) + and x19,x19,x28 // (b^c)&=(a^b) + eor x12,x12,x5,ror#61 + eor x13,x13,x8,lsr#7 // sigma0(X[i+1]) + add x24,x24,x16 // h+=Sigma1(e) + eor x19,x19,x26 // Maj(a,b,c) + eor x17,x14,x25,ror#39 // Sigma0(a) + eor x12,x12,x5,lsr#6 // sigma1(X[i+14]) + add x7,x7,x0 + add x20,x20,x24 // d+=h + add x24,x24,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + add x7,x7,x13 + add x24,x24,x17 // h+=Sigma0(a) + add x7,x7,x12 + ldr x12,[sp,#8] + str x15,[sp,#0] + ror x16,x20,#14 + add x23,x23,x19 // h+=K[i] + ror x14,x9,#1 + and x17,x21,x20 + ror x13,x6,#19 + bic x19,x22,x20 + ror x15,x24,#28 + add x23,x23,x7 // h+=X[i] + eor x16,x16,x20,ror#18 + eor x14,x14,x9,ror#8 + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x24,x25 // a^b, b^c in next round + eor x16,x16,x20,ror#41 // Sigma1(e) + eor x15,x15,x24,ror#34 + add x23,x23,x17 // h+=Ch(e,f,g) + and x28,x28,x19 // (b^c)&=(a^b) + eor x13,x13,x6,ror#61 + eor x14,x14,x9,lsr#7 // sigma0(X[i+1]) + add x23,x23,x16 // h+=Sigma1(e) + eor x28,x28,x25 // Maj(a,b,c) + eor x17,x15,x24,ror#39 // Sigma0(a) + eor x13,x13,x6,lsr#6 // sigma1(X[i+14]) + add x8,x8,x1 + add x27,x27,x23 // d+=h + add x23,x23,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + add x8,x8,x14 + add x23,x23,x17 // h+=Sigma0(a) + add x8,x8,x13 + ldr x13,[sp,#16] + str x0,[sp,#8] + ror x16,x27,#14 + add x22,x22,x28 // h+=K[i] + ror x15,x10,#1 + and x17,x20,x27 + ror x14,x7,#19 + bic x28,x21,x27 + ror x0,x23,#28 + add x22,x22,x8 // h+=X[i] + eor x16,x16,x27,ror#18 + eor x15,x15,x10,ror#8 + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x23,x24 // a^b, b^c in next round + eor x16,x16,x27,ror#41 // Sigma1(e) + eor x0,x0,x23,ror#34 + add x22,x22,x17 // h+=Ch(e,f,g) + and x19,x19,x28 // (b^c)&=(a^b) + eor x14,x14,x7,ror#61 + eor x15,x15,x10,lsr#7 // sigma0(X[i+1]) + add x22,x22,x16 // h+=Sigma1(e) + eor x19,x19,x24 // Maj(a,b,c) + eor x17,x0,x23,ror#39 // Sigma0(a) + eor x14,x14,x7,lsr#6 // sigma1(X[i+14]) + add x9,x9,x2 + add x26,x26,x22 // d+=h + add x22,x22,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + add x9,x9,x15 + add x22,x22,x17 // h+=Sigma0(a) + add x9,x9,x14 + ldr x14,[sp,#24] + str x1,[sp,#16] + ror x16,x26,#14 + add x21,x21,x19 // h+=K[i] + ror x0,x11,#1 + and x17,x27,x26 + ror x15,x8,#19 + bic x19,x20,x26 + ror x1,x22,#28 + add x21,x21,x9 // h+=X[i] + eor x16,x16,x26,ror#18 + eor x0,x0,x11,ror#8 + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x22,x23 // a^b, b^c in next round + eor x16,x16,x26,ror#41 // Sigma1(e) + eor x1,x1,x22,ror#34 + add x21,x21,x17 // h+=Ch(e,f,g) + and x28,x28,x19 // (b^c)&=(a^b) + eor x15,x15,x8,ror#61 + eor x0,x0,x11,lsr#7 // sigma0(X[i+1]) + add x21,x21,x16 // h+=Sigma1(e) + eor x28,x28,x23 // Maj(a,b,c) + eor x17,x1,x22,ror#39 // Sigma0(a) + eor x15,x15,x8,lsr#6 // sigma1(X[i+14]) + add x10,x10,x3 + add x25,x25,x21 // d+=h + add x21,x21,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + add x10,x10,x0 + add x21,x21,x17 // h+=Sigma0(a) + add x10,x10,x15 + ldr x15,[sp,#0] + str x2,[sp,#24] + ror x16,x25,#14 + add x20,x20,x28 // h+=K[i] + ror x1,x12,#1 + and x17,x26,x25 + ror x0,x9,#19 + bic x28,x27,x25 + ror x2,x21,#28 + add x20,x20,x10 // h+=X[i] + eor x16,x16,x25,ror#18 + eor x1,x1,x12,ror#8 + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x21,x22 // a^b, b^c in next round + eor x16,x16,x25,ror#41 // Sigma1(e) + eor x2,x2,x21,ror#34 + add x20,x20,x17 // h+=Ch(e,f,g) + and x19,x19,x28 // (b^c)&=(a^b) + eor x0,x0,x9,ror#61 + eor x1,x1,x12,lsr#7 // sigma0(X[i+1]) + add x20,x20,x16 // h+=Sigma1(e) + eor x19,x19,x22 // Maj(a,b,c) + eor x17,x2,x21,ror#39 // Sigma0(a) + eor x0,x0,x9,lsr#6 // sigma1(X[i+14]) + add x11,x11,x4 + add x24,x24,x20 // d+=h + add x20,x20,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + add x11,x11,x1 + add x20,x20,x17 // h+=Sigma0(a) + add x11,x11,x0 + ldr x0,[sp,#8] + str x3,[sp,#0] + ror x16,x24,#14 + add x27,x27,x19 // h+=K[i] + ror x2,x13,#1 + and x17,x25,x24 + ror x1,x10,#19 + bic x19,x26,x24 + ror x3,x20,#28 + add x27,x27,x11 // h+=X[i] + eor x16,x16,x24,ror#18 + eor x2,x2,x13,ror#8 + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x20,x21 // a^b, b^c in next round + eor x16,x16,x24,ror#41 // Sigma1(e) + eor x3,x3,x20,ror#34 + add x27,x27,x17 // h+=Ch(e,f,g) + and x28,x28,x19 // (b^c)&=(a^b) + eor x1,x1,x10,ror#61 + eor x2,x2,x13,lsr#7 // sigma0(X[i+1]) + add x27,x27,x16 // h+=Sigma1(e) + eor x28,x28,x21 // Maj(a,b,c) + eor x17,x3,x20,ror#39 // Sigma0(a) + eor x1,x1,x10,lsr#6 // sigma1(X[i+14]) + add x12,x12,x5 + add x23,x23,x27 // d+=h + add x27,x27,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + add x12,x12,x2 + add x27,x27,x17 // h+=Sigma0(a) + add x12,x12,x1 + ldr x1,[sp,#16] + str x4,[sp,#8] + ror x16,x23,#14 + add x26,x26,x28 // h+=K[i] + ror x3,x14,#1 + and x17,x24,x23 + ror x2,x11,#19 + bic x28,x25,x23 + ror x4,x27,#28 + add x26,x26,x12 // h+=X[i] + eor x16,x16,x23,ror#18 + eor x3,x3,x14,ror#8 + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x27,x20 // a^b, b^c in next round + eor x16,x16,x23,ror#41 // Sigma1(e) + eor x4,x4,x27,ror#34 + add x26,x26,x17 // h+=Ch(e,f,g) + and x19,x19,x28 // (b^c)&=(a^b) + eor x2,x2,x11,ror#61 + eor x3,x3,x14,lsr#7 // sigma0(X[i+1]) + add x26,x26,x16 // h+=Sigma1(e) + eor x19,x19,x20 // Maj(a,b,c) + eor x17,x4,x27,ror#39 // Sigma0(a) + eor x2,x2,x11,lsr#6 // sigma1(X[i+14]) + add x13,x13,x6 + add x22,x22,x26 // d+=h + add x26,x26,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + add x13,x13,x3 + add x26,x26,x17 // h+=Sigma0(a) + add x13,x13,x2 + ldr x2,[sp,#24] + str x5,[sp,#16] + ror x16,x22,#14 + add x25,x25,x19 // h+=K[i] + ror x4,x15,#1 + and x17,x23,x22 + ror x3,x12,#19 + bic x19,x24,x22 + ror x5,x26,#28 + add x25,x25,x13 // h+=X[i] + eor x16,x16,x22,ror#18 + eor x4,x4,x15,ror#8 + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x26,x27 // a^b, b^c in next round + eor x16,x16,x22,ror#41 // Sigma1(e) + eor x5,x5,x26,ror#34 + add x25,x25,x17 // h+=Ch(e,f,g) + and x28,x28,x19 // (b^c)&=(a^b) + eor x3,x3,x12,ror#61 + eor x4,x4,x15,lsr#7 // sigma0(X[i+1]) + add x25,x25,x16 // h+=Sigma1(e) + eor x28,x28,x27 // Maj(a,b,c) + eor x17,x5,x26,ror#39 // Sigma0(a) + eor x3,x3,x12,lsr#6 // sigma1(X[i+14]) + add x14,x14,x7 + add x21,x21,x25 // d+=h + add x25,x25,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + add x14,x14,x4 + add x25,x25,x17 // h+=Sigma0(a) + add x14,x14,x3 + ldr x3,[sp,#0] + str x6,[sp,#24] + ror x16,x21,#14 + add x24,x24,x28 // h+=K[i] + ror x5,x0,#1 + and x17,x22,x21 + ror x4,x13,#19 + bic x28,x23,x21 + ror x6,x25,#28 + add x24,x24,x14 // h+=X[i] + eor x16,x16,x21,ror#18 + eor x5,x5,x0,ror#8 + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x25,x26 // a^b, b^c in next round + eor x16,x16,x21,ror#41 // Sigma1(e) + eor x6,x6,x25,ror#34 + add x24,x24,x17 // h+=Ch(e,f,g) + and x19,x19,x28 // (b^c)&=(a^b) + eor x4,x4,x13,ror#61 + eor x5,x5,x0,lsr#7 // sigma0(X[i+1]) + add x24,x24,x16 // h+=Sigma1(e) + eor x19,x19,x26 // Maj(a,b,c) + eor x17,x6,x25,ror#39 // Sigma0(a) + eor x4,x4,x13,lsr#6 // sigma1(X[i+14]) + add x15,x15,x8 + add x20,x20,x24 // d+=h + add x24,x24,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + add x15,x15,x5 + add x24,x24,x17 // h+=Sigma0(a) + add x15,x15,x4 + ldr x4,[sp,#8] + str x7,[sp,#0] + ror x16,x20,#14 + add x23,x23,x19 // h+=K[i] + ror x6,x1,#1 + and x17,x21,x20 + ror x5,x14,#19 + bic x19,x22,x20 + ror x7,x24,#28 + add x23,x23,x15 // h+=X[i] + eor x16,x16,x20,ror#18 + eor x6,x6,x1,ror#8 + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x24,x25 // a^b, b^c in next round + eor x16,x16,x20,ror#41 // Sigma1(e) + eor x7,x7,x24,ror#34 + add x23,x23,x17 // h+=Ch(e,f,g) + and x28,x28,x19 // (b^c)&=(a^b) + eor x5,x5,x14,ror#61 + eor x6,x6,x1,lsr#7 // sigma0(X[i+1]) + add x23,x23,x16 // h+=Sigma1(e) + eor x28,x28,x25 // Maj(a,b,c) + eor x17,x7,x24,ror#39 // Sigma0(a) + eor x5,x5,x14,lsr#6 // sigma1(X[i+14]) + add x0,x0,x9 + add x27,x27,x23 // d+=h + add x23,x23,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + add x0,x0,x6 + add x23,x23,x17 // h+=Sigma0(a) + add x0,x0,x5 + ldr x5,[sp,#16] + str x8,[sp,#8] + ror x16,x27,#14 + add x22,x22,x28 // h+=K[i] + ror x7,x2,#1 + and x17,x20,x27 + ror x6,x15,#19 + bic x28,x21,x27 + ror x8,x23,#28 + add x22,x22,x0 // h+=X[i] + eor x16,x16,x27,ror#18 + eor x7,x7,x2,ror#8 + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x23,x24 // a^b, b^c in next round + eor x16,x16,x27,ror#41 // Sigma1(e) + eor x8,x8,x23,ror#34 + add x22,x22,x17 // h+=Ch(e,f,g) + and x19,x19,x28 // (b^c)&=(a^b) + eor x6,x6,x15,ror#61 + eor x7,x7,x2,lsr#7 // sigma0(X[i+1]) + add x22,x22,x16 // h+=Sigma1(e) + eor x19,x19,x24 // Maj(a,b,c) + eor x17,x8,x23,ror#39 // Sigma0(a) + eor x6,x6,x15,lsr#6 // sigma1(X[i+14]) + add x1,x1,x10 + add x26,x26,x22 // d+=h + add x22,x22,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + add x1,x1,x7 + add x22,x22,x17 // h+=Sigma0(a) + add x1,x1,x6 + ldr x6,[sp,#24] + str x9,[sp,#16] + ror x16,x26,#14 + add x21,x21,x19 // h+=K[i] + ror x8,x3,#1 + and x17,x27,x26 + ror x7,x0,#19 + bic x19,x20,x26 + ror x9,x22,#28 + add x21,x21,x1 // h+=X[i] + eor x16,x16,x26,ror#18 + eor x8,x8,x3,ror#8 + orr x17,x17,x19 // Ch(e,f,g) + eor x19,x22,x23 // a^b, b^c in next round + eor x16,x16,x26,ror#41 // Sigma1(e) + eor x9,x9,x22,ror#34 + add x21,x21,x17 // h+=Ch(e,f,g) + and x28,x28,x19 // (b^c)&=(a^b) + eor x7,x7,x0,ror#61 + eor x8,x8,x3,lsr#7 // sigma0(X[i+1]) + add x21,x21,x16 // h+=Sigma1(e) + eor x28,x28,x23 // Maj(a,b,c) + eor x17,x9,x22,ror#39 // Sigma0(a) + eor x7,x7,x0,lsr#6 // sigma1(X[i+14]) + add x2,x2,x11 + add x25,x25,x21 // d+=h + add x21,x21,x28 // h+=Maj(a,b,c) + ldr x28,[x30],#8 // *K++, x19 in next round + add x2,x2,x8 + add x21,x21,x17 // h+=Sigma0(a) + add x2,x2,x7 + ldr x7,[sp,#0] + str x10,[sp,#24] + ror x16,x25,#14 + add x20,x20,x28 // h+=K[i] + ror x9,x4,#1 + and x17,x26,x25 + ror x8,x1,#19 + bic x28,x27,x25 + ror x10,x21,#28 + add x20,x20,x2 // h+=X[i] + eor x16,x16,x25,ror#18 + eor x9,x9,x4,ror#8 + orr x17,x17,x28 // Ch(e,f,g) + eor x28,x21,x22 // a^b, b^c in next round + eor x16,x16,x25,ror#41 // Sigma1(e) + eor x10,x10,x21,ror#34 + add x20,x20,x17 // h+=Ch(e,f,g) + and x19,x19,x28 // (b^c)&=(a^b) + eor x8,x8,x1,ror#61 + eor x9,x9,x4,lsr#7 // sigma0(X[i+1]) + add x20,x20,x16 // h+=Sigma1(e) + eor x19,x19,x22 // Maj(a,b,c) + eor x17,x10,x21,ror#39 // Sigma0(a) + eor x8,x8,x1,lsr#6 // sigma1(X[i+14]) + add x3,x3,x12 + add x24,x24,x20 // d+=h + add x20,x20,x19 // h+=Maj(a,b,c) + ldr x19,[x30],#8 // *K++, x28 in next round + add x3,x3,x9 + add x20,x20,x17 // h+=Sigma0(a) + add x3,x3,x8 + cbnz x19,Loop_16_xx + + ldp x0,x2,[x29,#96] + ldr x1,[x29,#112] + sub x30,x30,#648 // rewind + + ldp x3,x4,[x0] + ldp x5,x6,[x0,#2*8] + add x1,x1,#14*8 // advance input pointer + ldp x7,x8,[x0,#4*8] + add x20,x20,x3 + ldp x9,x10,[x0,#6*8] + add x21,x21,x4 + add x22,x22,x5 + add x23,x23,x6 + stp x20,x21,[x0] + add x24,x24,x7 + add x25,x25,x8 + stp x22,x23,[x0,#2*8] + add x26,x26,x9 + add x27,x27,x10 + cmp x1,x2 + stp x24,x25,[x0,#4*8] + stp x26,x27,[x0,#6*8] + b.ne Loop + + ldp x19,x20,[x29,#16] + add sp,sp,#4*8 + ldp x21,x22,[x29,#32] + ldp x23,x24,[x29,#48] + ldp x25,x26,[x29,#64] + ldp x27,x28,[x29,#80] + ldp x29,x30,[sp],#128 + AARCH64_VALIDATE_LINK_REGISTER + ret + + +.section .rodata +.align 6 + +LK512: +.quad 0x428a2f98d728ae22,0x7137449123ef65cd +.quad 0xb5c0fbcfec4d3b2f,0xe9b5dba58189dbbc +.quad 0x3956c25bf348b538,0x59f111f1b605d019 +.quad 0x923f82a4af194f9b,0xab1c5ed5da6d8118 +.quad 0xd807aa98a3030242,0x12835b0145706fbe +.quad 0x243185be4ee4b28c,0x550c7dc3d5ffb4e2 +.quad 0x72be5d74f27b896f,0x80deb1fe3b1696b1 +.quad 0x9bdc06a725c71235,0xc19bf174cf692694 +.quad 0xe49b69c19ef14ad2,0xefbe4786384f25e3 +.quad 0x0fc19dc68b8cd5b5,0x240ca1cc77ac9c65 +.quad 0x2de92c6f592b0275,0x4a7484aa6ea6e483 +.quad 0x5cb0a9dcbd41fbd4,0x76f988da831153b5 +.quad 0x983e5152ee66dfab,0xa831c66d2db43210 +.quad 0xb00327c898fb213f,0xbf597fc7beef0ee4 +.quad 0xc6e00bf33da88fc2,0xd5a79147930aa725 +.quad 0x06ca6351e003826f,0x142929670a0e6e70 +.quad 0x27b70a8546d22ffc,0x2e1b21385c26c926 +.quad 0x4d2c6dfc5ac42aed,0x53380d139d95b3df +.quad 0x650a73548baf63de,0x766a0abb3c77b2a8 +.quad 0x81c2c92e47edaee6,0x92722c851482353b +.quad 0xa2bfe8a14cf10364,0xa81a664bbc423001 +.quad 0xc24b8b70d0f89791,0xc76c51a30654be30 +.quad 0xd192e819d6ef5218,0xd69906245565a910 +.quad 0xf40e35855771202a,0x106aa07032bbd1b8 +.quad 0x19a4c116b8d2d0c8,0x1e376c085141ab53 +.quad 0x2748774cdf8eeb99,0x34b0bcb5e19b48a8 +.quad 0x391c0cb3c5c95a63,0x4ed8aa4ae3418acb +.quad 0x5b9cca4f7763e373,0x682e6ff3d6b2b8a3 +.quad 0x748f82ee5defb2fc,0x78a5636f43172f60 +.quad 0x84c87814a1f0ab72,0x8cc702081a6439ec +.quad 0x90befffa23631e28,0xa4506cebde82bde9 +.quad 0xbef9a3f7b2c67915,0xc67178f2e372532b +.quad 0xca273eceea26619c,0xd186b8c721c0c207 +.quad 0xeada7dd6cde0eb1e,0xf57d4f7fee6ed178 +.quad 0x06f067aa72176fba,0x0a637dc5a2c898a6 +.quad 0x113f9804bef90dae,0x1b710b35131c471b +.quad 0x28db77f523047d84,0x32caab7b40c72493 +.quad 0x3c9ebe0a15c9bebc,0x431d67c49c100d4c +.quad 0x4cc5d4becb3e42b6,0x597f299cfc657e2a +.quad 0x5fcb6fab3ad6faec,0x6c44198c4a475817 +.quad 0 // terminator + +.byte 83,72,65,53,49,50,32,98,108,111,99,107,32,116,114,97,110,115,102,111,114,109,32,102,111,114,32,65,82,77,118,56,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.align 2 +.align 2 +.text +#ifndef __KERNEL__ +.globl sha512_block_data_order_hw + +.def sha512_block_data_order_hw + .type 32 +.endef +.align 6 +sha512_block_data_order_hw: + // Armv8.3-A PAuth: even though x30 is pushed to stack it is not popped later. + AARCH64_VALID_CALL_TARGET + stp x29,x30,[sp,#-16]! + add x29,sp,#0 + + ld1 {v16.16b,v17.16b,v18.16b,v19.16b},[x1],#64 // load input + ld1 {v20.16b,v21.16b,v22.16b,v23.16b},[x1],#64 + + ld1 {v0.2d,v1.2d,v2.2d,v3.2d},[x0] // load context + adrp x3,LK512 + add x3,x3,:lo12:LK512 + + rev64 v16.16b,v16.16b + rev64 v17.16b,v17.16b + rev64 v18.16b,v18.16b + rev64 v19.16b,v19.16b + rev64 v20.16b,v20.16b + rev64 v21.16b,v21.16b + rev64 v22.16b,v22.16b + rev64 v23.16b,v23.16b + b Loop_hw + +.align 4 +Loop_hw: + ld1 {v24.2d},[x3],#16 + subs x2,x2,#1 + sub x4,x1,#128 + orr v26.16b,v0.16b,v0.16b // offload + orr v27.16b,v1.16b,v1.16b + orr v28.16b,v2.16b,v2.16b + orr v29.16b,v3.16b,v3.16b + csel x1,x1,x4,ne // conditional rewind + add v24.2d,v24.2d,v16.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v2.16b,v3.16b,#8 + ext v6.16b,v1.16b,v2.16b,#8 + add v3.2d,v3.2d,v24.2d // "T1 + H + K512[i]" +.long 0xcec08230 //sha512su0 v16.16b,v17.16b + ext v7.16b,v20.16b,v21.16b,#8 +.long 0xce6680a3 //sha512h v3.16b,v5.16b,v6.16b +.long 0xce678af0 //sha512su1 v16.16b,v23.16b,v7.16b + add v4.2d,v1.2d,v3.2d // "D + T1" +.long 0xce608423 //sha512h2 v3.16b,v1.16b,v0.16b + add v25.2d,v25.2d,v17.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v4.16b,v2.16b,#8 + ext v6.16b,v0.16b,v4.16b,#8 + add v2.2d,v2.2d,v25.2d // "T1 + H + K512[i]" +.long 0xcec08251 //sha512su0 v17.16b,v18.16b + ext v7.16b,v21.16b,v22.16b,#8 +.long 0xce6680a2 //sha512h v2.16b,v5.16b,v6.16b +.long 0xce678a11 //sha512su1 v17.16b,v16.16b,v7.16b + add v1.2d,v0.2d,v2.2d // "D + T1" +.long 0xce638402 //sha512h2 v2.16b,v0.16b,v3.16b + add v24.2d,v24.2d,v18.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v1.16b,v4.16b,#8 + ext v6.16b,v3.16b,v1.16b,#8 + add v4.2d,v4.2d,v24.2d // "T1 + H + K512[i]" +.long 0xcec08272 //sha512su0 v18.16b,v19.16b + ext v7.16b,v22.16b,v23.16b,#8 +.long 0xce6680a4 //sha512h v4.16b,v5.16b,v6.16b +.long 0xce678a32 //sha512su1 v18.16b,v17.16b,v7.16b + add v0.2d,v3.2d,v4.2d // "D + T1" +.long 0xce628464 //sha512h2 v4.16b,v3.16b,v2.16b + add v25.2d,v25.2d,v19.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v0.16b,v1.16b,#8 + ext v6.16b,v2.16b,v0.16b,#8 + add v1.2d,v1.2d,v25.2d // "T1 + H + K512[i]" +.long 0xcec08293 //sha512su0 v19.16b,v20.16b + ext v7.16b,v23.16b,v16.16b,#8 +.long 0xce6680a1 //sha512h v1.16b,v5.16b,v6.16b +.long 0xce678a53 //sha512su1 v19.16b,v18.16b,v7.16b + add v3.2d,v2.2d,v1.2d // "D + T1" +.long 0xce648441 //sha512h2 v1.16b,v2.16b,v4.16b + add v24.2d,v24.2d,v20.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v3.16b,v0.16b,#8 + ext v6.16b,v4.16b,v3.16b,#8 + add v0.2d,v0.2d,v24.2d // "T1 + H + K512[i]" +.long 0xcec082b4 //sha512su0 v20.16b,v21.16b + ext v7.16b,v16.16b,v17.16b,#8 +.long 0xce6680a0 //sha512h v0.16b,v5.16b,v6.16b +.long 0xce678a74 //sha512su1 v20.16b,v19.16b,v7.16b + add v2.2d,v4.2d,v0.2d // "D + T1" +.long 0xce618480 //sha512h2 v0.16b,v4.16b,v1.16b + add v25.2d,v25.2d,v21.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v2.16b,v3.16b,#8 + ext v6.16b,v1.16b,v2.16b,#8 + add v3.2d,v3.2d,v25.2d // "T1 + H + K512[i]" +.long 0xcec082d5 //sha512su0 v21.16b,v22.16b + ext v7.16b,v17.16b,v18.16b,#8 +.long 0xce6680a3 //sha512h v3.16b,v5.16b,v6.16b +.long 0xce678a95 //sha512su1 v21.16b,v20.16b,v7.16b + add v4.2d,v1.2d,v3.2d // "D + T1" +.long 0xce608423 //sha512h2 v3.16b,v1.16b,v0.16b + add v24.2d,v24.2d,v22.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v4.16b,v2.16b,#8 + ext v6.16b,v0.16b,v4.16b,#8 + add v2.2d,v2.2d,v24.2d // "T1 + H + K512[i]" +.long 0xcec082f6 //sha512su0 v22.16b,v23.16b + ext v7.16b,v18.16b,v19.16b,#8 +.long 0xce6680a2 //sha512h v2.16b,v5.16b,v6.16b +.long 0xce678ab6 //sha512su1 v22.16b,v21.16b,v7.16b + add v1.2d,v0.2d,v2.2d // "D + T1" +.long 0xce638402 //sha512h2 v2.16b,v0.16b,v3.16b + add v25.2d,v25.2d,v23.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v1.16b,v4.16b,#8 + ext v6.16b,v3.16b,v1.16b,#8 + add v4.2d,v4.2d,v25.2d // "T1 + H + K512[i]" +.long 0xcec08217 //sha512su0 v23.16b,v16.16b + ext v7.16b,v19.16b,v20.16b,#8 +.long 0xce6680a4 //sha512h v4.16b,v5.16b,v6.16b +.long 0xce678ad7 //sha512su1 v23.16b,v22.16b,v7.16b + add v0.2d,v3.2d,v4.2d // "D + T1" +.long 0xce628464 //sha512h2 v4.16b,v3.16b,v2.16b + add v24.2d,v24.2d,v16.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v0.16b,v1.16b,#8 + ext v6.16b,v2.16b,v0.16b,#8 + add v1.2d,v1.2d,v24.2d // "T1 + H + K512[i]" +.long 0xcec08230 //sha512su0 v16.16b,v17.16b + ext v7.16b,v20.16b,v21.16b,#8 +.long 0xce6680a1 //sha512h v1.16b,v5.16b,v6.16b +.long 0xce678af0 //sha512su1 v16.16b,v23.16b,v7.16b + add v3.2d,v2.2d,v1.2d // "D + T1" +.long 0xce648441 //sha512h2 v1.16b,v2.16b,v4.16b + add v25.2d,v25.2d,v17.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v3.16b,v0.16b,#8 + ext v6.16b,v4.16b,v3.16b,#8 + add v0.2d,v0.2d,v25.2d // "T1 + H + K512[i]" +.long 0xcec08251 //sha512su0 v17.16b,v18.16b + ext v7.16b,v21.16b,v22.16b,#8 +.long 0xce6680a0 //sha512h v0.16b,v5.16b,v6.16b +.long 0xce678a11 //sha512su1 v17.16b,v16.16b,v7.16b + add v2.2d,v4.2d,v0.2d // "D + T1" +.long 0xce618480 //sha512h2 v0.16b,v4.16b,v1.16b + add v24.2d,v24.2d,v18.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v2.16b,v3.16b,#8 + ext v6.16b,v1.16b,v2.16b,#8 + add v3.2d,v3.2d,v24.2d // "T1 + H + K512[i]" +.long 0xcec08272 //sha512su0 v18.16b,v19.16b + ext v7.16b,v22.16b,v23.16b,#8 +.long 0xce6680a3 //sha512h v3.16b,v5.16b,v6.16b +.long 0xce678a32 //sha512su1 v18.16b,v17.16b,v7.16b + add v4.2d,v1.2d,v3.2d // "D + T1" +.long 0xce608423 //sha512h2 v3.16b,v1.16b,v0.16b + add v25.2d,v25.2d,v19.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v4.16b,v2.16b,#8 + ext v6.16b,v0.16b,v4.16b,#8 + add v2.2d,v2.2d,v25.2d // "T1 + H + K512[i]" +.long 0xcec08293 //sha512su0 v19.16b,v20.16b + ext v7.16b,v23.16b,v16.16b,#8 +.long 0xce6680a2 //sha512h v2.16b,v5.16b,v6.16b +.long 0xce678a53 //sha512su1 v19.16b,v18.16b,v7.16b + add v1.2d,v0.2d,v2.2d // "D + T1" +.long 0xce638402 //sha512h2 v2.16b,v0.16b,v3.16b + add v24.2d,v24.2d,v20.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v1.16b,v4.16b,#8 + ext v6.16b,v3.16b,v1.16b,#8 + add v4.2d,v4.2d,v24.2d // "T1 + H + K512[i]" +.long 0xcec082b4 //sha512su0 v20.16b,v21.16b + ext v7.16b,v16.16b,v17.16b,#8 +.long 0xce6680a4 //sha512h v4.16b,v5.16b,v6.16b +.long 0xce678a74 //sha512su1 v20.16b,v19.16b,v7.16b + add v0.2d,v3.2d,v4.2d // "D + T1" +.long 0xce628464 //sha512h2 v4.16b,v3.16b,v2.16b + add v25.2d,v25.2d,v21.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v0.16b,v1.16b,#8 + ext v6.16b,v2.16b,v0.16b,#8 + add v1.2d,v1.2d,v25.2d // "T1 + H + K512[i]" +.long 0xcec082d5 //sha512su0 v21.16b,v22.16b + ext v7.16b,v17.16b,v18.16b,#8 +.long 0xce6680a1 //sha512h v1.16b,v5.16b,v6.16b +.long 0xce678a95 //sha512su1 v21.16b,v20.16b,v7.16b + add v3.2d,v2.2d,v1.2d // "D + T1" +.long 0xce648441 //sha512h2 v1.16b,v2.16b,v4.16b + add v24.2d,v24.2d,v22.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v3.16b,v0.16b,#8 + ext v6.16b,v4.16b,v3.16b,#8 + add v0.2d,v0.2d,v24.2d // "T1 + H + K512[i]" +.long 0xcec082f6 //sha512su0 v22.16b,v23.16b + ext v7.16b,v18.16b,v19.16b,#8 +.long 0xce6680a0 //sha512h v0.16b,v5.16b,v6.16b +.long 0xce678ab6 //sha512su1 v22.16b,v21.16b,v7.16b + add v2.2d,v4.2d,v0.2d // "D + T1" +.long 0xce618480 //sha512h2 v0.16b,v4.16b,v1.16b + add v25.2d,v25.2d,v23.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v2.16b,v3.16b,#8 + ext v6.16b,v1.16b,v2.16b,#8 + add v3.2d,v3.2d,v25.2d // "T1 + H + K512[i]" +.long 0xcec08217 //sha512su0 v23.16b,v16.16b + ext v7.16b,v19.16b,v20.16b,#8 +.long 0xce6680a3 //sha512h v3.16b,v5.16b,v6.16b +.long 0xce678ad7 //sha512su1 v23.16b,v22.16b,v7.16b + add v4.2d,v1.2d,v3.2d // "D + T1" +.long 0xce608423 //sha512h2 v3.16b,v1.16b,v0.16b + add v24.2d,v24.2d,v16.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v4.16b,v2.16b,#8 + ext v6.16b,v0.16b,v4.16b,#8 + add v2.2d,v2.2d,v24.2d // "T1 + H + K512[i]" +.long 0xcec08230 //sha512su0 v16.16b,v17.16b + ext v7.16b,v20.16b,v21.16b,#8 +.long 0xce6680a2 //sha512h v2.16b,v5.16b,v6.16b +.long 0xce678af0 //sha512su1 v16.16b,v23.16b,v7.16b + add v1.2d,v0.2d,v2.2d // "D + T1" +.long 0xce638402 //sha512h2 v2.16b,v0.16b,v3.16b + add v25.2d,v25.2d,v17.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v1.16b,v4.16b,#8 + ext v6.16b,v3.16b,v1.16b,#8 + add v4.2d,v4.2d,v25.2d // "T1 + H + K512[i]" +.long 0xcec08251 //sha512su0 v17.16b,v18.16b + ext v7.16b,v21.16b,v22.16b,#8 +.long 0xce6680a4 //sha512h v4.16b,v5.16b,v6.16b +.long 0xce678a11 //sha512su1 v17.16b,v16.16b,v7.16b + add v0.2d,v3.2d,v4.2d // "D + T1" +.long 0xce628464 //sha512h2 v4.16b,v3.16b,v2.16b + add v24.2d,v24.2d,v18.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v0.16b,v1.16b,#8 + ext v6.16b,v2.16b,v0.16b,#8 + add v1.2d,v1.2d,v24.2d // "T1 + H + K512[i]" +.long 0xcec08272 //sha512su0 v18.16b,v19.16b + ext v7.16b,v22.16b,v23.16b,#8 +.long 0xce6680a1 //sha512h v1.16b,v5.16b,v6.16b +.long 0xce678a32 //sha512su1 v18.16b,v17.16b,v7.16b + add v3.2d,v2.2d,v1.2d // "D + T1" +.long 0xce648441 //sha512h2 v1.16b,v2.16b,v4.16b + add v25.2d,v25.2d,v19.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v3.16b,v0.16b,#8 + ext v6.16b,v4.16b,v3.16b,#8 + add v0.2d,v0.2d,v25.2d // "T1 + H + K512[i]" +.long 0xcec08293 //sha512su0 v19.16b,v20.16b + ext v7.16b,v23.16b,v16.16b,#8 +.long 0xce6680a0 //sha512h v0.16b,v5.16b,v6.16b +.long 0xce678a53 //sha512su1 v19.16b,v18.16b,v7.16b + add v2.2d,v4.2d,v0.2d // "D + T1" +.long 0xce618480 //sha512h2 v0.16b,v4.16b,v1.16b + add v24.2d,v24.2d,v20.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v2.16b,v3.16b,#8 + ext v6.16b,v1.16b,v2.16b,#8 + add v3.2d,v3.2d,v24.2d // "T1 + H + K512[i]" +.long 0xcec082b4 //sha512su0 v20.16b,v21.16b + ext v7.16b,v16.16b,v17.16b,#8 +.long 0xce6680a3 //sha512h v3.16b,v5.16b,v6.16b +.long 0xce678a74 //sha512su1 v20.16b,v19.16b,v7.16b + add v4.2d,v1.2d,v3.2d // "D + T1" +.long 0xce608423 //sha512h2 v3.16b,v1.16b,v0.16b + add v25.2d,v25.2d,v21.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v4.16b,v2.16b,#8 + ext v6.16b,v0.16b,v4.16b,#8 + add v2.2d,v2.2d,v25.2d // "T1 + H + K512[i]" +.long 0xcec082d5 //sha512su0 v21.16b,v22.16b + ext v7.16b,v17.16b,v18.16b,#8 +.long 0xce6680a2 //sha512h v2.16b,v5.16b,v6.16b +.long 0xce678a95 //sha512su1 v21.16b,v20.16b,v7.16b + add v1.2d,v0.2d,v2.2d // "D + T1" +.long 0xce638402 //sha512h2 v2.16b,v0.16b,v3.16b + add v24.2d,v24.2d,v22.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v1.16b,v4.16b,#8 + ext v6.16b,v3.16b,v1.16b,#8 + add v4.2d,v4.2d,v24.2d // "T1 + H + K512[i]" +.long 0xcec082f6 //sha512su0 v22.16b,v23.16b + ext v7.16b,v18.16b,v19.16b,#8 +.long 0xce6680a4 //sha512h v4.16b,v5.16b,v6.16b +.long 0xce678ab6 //sha512su1 v22.16b,v21.16b,v7.16b + add v0.2d,v3.2d,v4.2d // "D + T1" +.long 0xce628464 //sha512h2 v4.16b,v3.16b,v2.16b + add v25.2d,v25.2d,v23.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v0.16b,v1.16b,#8 + ext v6.16b,v2.16b,v0.16b,#8 + add v1.2d,v1.2d,v25.2d // "T1 + H + K512[i]" +.long 0xcec08217 //sha512su0 v23.16b,v16.16b + ext v7.16b,v19.16b,v20.16b,#8 +.long 0xce6680a1 //sha512h v1.16b,v5.16b,v6.16b +.long 0xce678ad7 //sha512su1 v23.16b,v22.16b,v7.16b + add v3.2d,v2.2d,v1.2d // "D + T1" +.long 0xce648441 //sha512h2 v1.16b,v2.16b,v4.16b + add v24.2d,v24.2d,v16.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v3.16b,v0.16b,#8 + ext v6.16b,v4.16b,v3.16b,#8 + add v0.2d,v0.2d,v24.2d // "T1 + H + K512[i]" +.long 0xcec08230 //sha512su0 v16.16b,v17.16b + ext v7.16b,v20.16b,v21.16b,#8 +.long 0xce6680a0 //sha512h v0.16b,v5.16b,v6.16b +.long 0xce678af0 //sha512su1 v16.16b,v23.16b,v7.16b + add v2.2d,v4.2d,v0.2d // "D + T1" +.long 0xce618480 //sha512h2 v0.16b,v4.16b,v1.16b + add v25.2d,v25.2d,v17.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v2.16b,v3.16b,#8 + ext v6.16b,v1.16b,v2.16b,#8 + add v3.2d,v3.2d,v25.2d // "T1 + H + K512[i]" +.long 0xcec08251 //sha512su0 v17.16b,v18.16b + ext v7.16b,v21.16b,v22.16b,#8 +.long 0xce6680a3 //sha512h v3.16b,v5.16b,v6.16b +.long 0xce678a11 //sha512su1 v17.16b,v16.16b,v7.16b + add v4.2d,v1.2d,v3.2d // "D + T1" +.long 0xce608423 //sha512h2 v3.16b,v1.16b,v0.16b + add v24.2d,v24.2d,v18.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v4.16b,v2.16b,#8 + ext v6.16b,v0.16b,v4.16b,#8 + add v2.2d,v2.2d,v24.2d // "T1 + H + K512[i]" +.long 0xcec08272 //sha512su0 v18.16b,v19.16b + ext v7.16b,v22.16b,v23.16b,#8 +.long 0xce6680a2 //sha512h v2.16b,v5.16b,v6.16b +.long 0xce678a32 //sha512su1 v18.16b,v17.16b,v7.16b + add v1.2d,v0.2d,v2.2d // "D + T1" +.long 0xce638402 //sha512h2 v2.16b,v0.16b,v3.16b + add v25.2d,v25.2d,v19.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v1.16b,v4.16b,#8 + ext v6.16b,v3.16b,v1.16b,#8 + add v4.2d,v4.2d,v25.2d // "T1 + H + K512[i]" +.long 0xcec08293 //sha512su0 v19.16b,v20.16b + ext v7.16b,v23.16b,v16.16b,#8 +.long 0xce6680a4 //sha512h v4.16b,v5.16b,v6.16b +.long 0xce678a53 //sha512su1 v19.16b,v18.16b,v7.16b + add v0.2d,v3.2d,v4.2d // "D + T1" +.long 0xce628464 //sha512h2 v4.16b,v3.16b,v2.16b + add v24.2d,v24.2d,v20.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v0.16b,v1.16b,#8 + ext v6.16b,v2.16b,v0.16b,#8 + add v1.2d,v1.2d,v24.2d // "T1 + H + K512[i]" +.long 0xcec082b4 //sha512su0 v20.16b,v21.16b + ext v7.16b,v16.16b,v17.16b,#8 +.long 0xce6680a1 //sha512h v1.16b,v5.16b,v6.16b +.long 0xce678a74 //sha512su1 v20.16b,v19.16b,v7.16b + add v3.2d,v2.2d,v1.2d // "D + T1" +.long 0xce648441 //sha512h2 v1.16b,v2.16b,v4.16b + add v25.2d,v25.2d,v21.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v3.16b,v0.16b,#8 + ext v6.16b,v4.16b,v3.16b,#8 + add v0.2d,v0.2d,v25.2d // "T1 + H + K512[i]" +.long 0xcec082d5 //sha512su0 v21.16b,v22.16b + ext v7.16b,v17.16b,v18.16b,#8 +.long 0xce6680a0 //sha512h v0.16b,v5.16b,v6.16b +.long 0xce678a95 //sha512su1 v21.16b,v20.16b,v7.16b + add v2.2d,v4.2d,v0.2d // "D + T1" +.long 0xce618480 //sha512h2 v0.16b,v4.16b,v1.16b + add v24.2d,v24.2d,v22.2d + ld1 {v25.2d},[x3],#16 + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v2.16b,v3.16b,#8 + ext v6.16b,v1.16b,v2.16b,#8 + add v3.2d,v3.2d,v24.2d // "T1 + H + K512[i]" +.long 0xcec082f6 //sha512su0 v22.16b,v23.16b + ext v7.16b,v18.16b,v19.16b,#8 +.long 0xce6680a3 //sha512h v3.16b,v5.16b,v6.16b +.long 0xce678ab6 //sha512su1 v22.16b,v21.16b,v7.16b + add v4.2d,v1.2d,v3.2d // "D + T1" +.long 0xce608423 //sha512h2 v3.16b,v1.16b,v0.16b + add v25.2d,v25.2d,v23.2d + ld1 {v24.2d},[x3],#16 + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v4.16b,v2.16b,#8 + ext v6.16b,v0.16b,v4.16b,#8 + add v2.2d,v2.2d,v25.2d // "T1 + H + K512[i]" +.long 0xcec08217 //sha512su0 v23.16b,v16.16b + ext v7.16b,v19.16b,v20.16b,#8 +.long 0xce6680a2 //sha512h v2.16b,v5.16b,v6.16b +.long 0xce678ad7 //sha512su1 v23.16b,v22.16b,v7.16b + add v1.2d,v0.2d,v2.2d // "D + T1" +.long 0xce638402 //sha512h2 v2.16b,v0.16b,v3.16b + ld1 {v25.2d},[x3],#16 + add v24.2d,v24.2d,v16.2d + ld1 {v16.16b},[x1],#16 // load next input + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v1.16b,v4.16b,#8 + ext v6.16b,v3.16b,v1.16b,#8 + add v4.2d,v4.2d,v24.2d // "T1 + H + K512[i]" +.long 0xce6680a4 //sha512h v4.16b,v5.16b,v6.16b + rev64 v16.16b,v16.16b + add v0.2d,v3.2d,v4.2d // "D + T1" +.long 0xce628464 //sha512h2 v4.16b,v3.16b,v2.16b + ld1 {v24.2d},[x3],#16 + add v25.2d,v25.2d,v17.2d + ld1 {v17.16b},[x1],#16 // load next input + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v0.16b,v1.16b,#8 + ext v6.16b,v2.16b,v0.16b,#8 + add v1.2d,v1.2d,v25.2d // "T1 + H + K512[i]" +.long 0xce6680a1 //sha512h v1.16b,v5.16b,v6.16b + rev64 v17.16b,v17.16b + add v3.2d,v2.2d,v1.2d // "D + T1" +.long 0xce648441 //sha512h2 v1.16b,v2.16b,v4.16b + ld1 {v25.2d},[x3],#16 + add v24.2d,v24.2d,v18.2d + ld1 {v18.16b},[x1],#16 // load next input + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v3.16b,v0.16b,#8 + ext v6.16b,v4.16b,v3.16b,#8 + add v0.2d,v0.2d,v24.2d // "T1 + H + K512[i]" +.long 0xce6680a0 //sha512h v0.16b,v5.16b,v6.16b + rev64 v18.16b,v18.16b + add v2.2d,v4.2d,v0.2d // "D + T1" +.long 0xce618480 //sha512h2 v0.16b,v4.16b,v1.16b + ld1 {v24.2d},[x3],#16 + add v25.2d,v25.2d,v19.2d + ld1 {v19.16b},[x1],#16 // load next input + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v2.16b,v3.16b,#8 + ext v6.16b,v1.16b,v2.16b,#8 + add v3.2d,v3.2d,v25.2d // "T1 + H + K512[i]" +.long 0xce6680a3 //sha512h v3.16b,v5.16b,v6.16b + rev64 v19.16b,v19.16b + add v4.2d,v1.2d,v3.2d // "D + T1" +.long 0xce608423 //sha512h2 v3.16b,v1.16b,v0.16b + ld1 {v25.2d},[x3],#16 + add v24.2d,v24.2d,v20.2d + ld1 {v20.16b},[x1],#16 // load next input + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v4.16b,v2.16b,#8 + ext v6.16b,v0.16b,v4.16b,#8 + add v2.2d,v2.2d,v24.2d // "T1 + H + K512[i]" +.long 0xce6680a2 //sha512h v2.16b,v5.16b,v6.16b + rev64 v20.16b,v20.16b + add v1.2d,v0.2d,v2.2d // "D + T1" +.long 0xce638402 //sha512h2 v2.16b,v0.16b,v3.16b + ld1 {v24.2d},[x3],#16 + add v25.2d,v25.2d,v21.2d + ld1 {v21.16b},[x1],#16 // load next input + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v1.16b,v4.16b,#8 + ext v6.16b,v3.16b,v1.16b,#8 + add v4.2d,v4.2d,v25.2d // "T1 + H + K512[i]" +.long 0xce6680a4 //sha512h v4.16b,v5.16b,v6.16b + rev64 v21.16b,v21.16b + add v0.2d,v3.2d,v4.2d // "D + T1" +.long 0xce628464 //sha512h2 v4.16b,v3.16b,v2.16b + ld1 {v25.2d},[x3],#16 + add v24.2d,v24.2d,v22.2d + ld1 {v22.16b},[x1],#16 // load next input + ext v24.16b,v24.16b,v24.16b,#8 + ext v5.16b,v0.16b,v1.16b,#8 + ext v6.16b,v2.16b,v0.16b,#8 + add v1.2d,v1.2d,v24.2d // "T1 + H + K512[i]" +.long 0xce6680a1 //sha512h v1.16b,v5.16b,v6.16b + rev64 v22.16b,v22.16b + add v3.2d,v2.2d,v1.2d // "D + T1" +.long 0xce648441 //sha512h2 v1.16b,v2.16b,v4.16b + sub x3,x3,#80*8 // rewind + add v25.2d,v25.2d,v23.2d + ld1 {v23.16b},[x1],#16 // load next input + ext v25.16b,v25.16b,v25.16b,#8 + ext v5.16b,v3.16b,v0.16b,#8 + ext v6.16b,v4.16b,v3.16b,#8 + add v0.2d,v0.2d,v25.2d // "T1 + H + K512[i]" +.long 0xce6680a0 //sha512h v0.16b,v5.16b,v6.16b + rev64 v23.16b,v23.16b + add v2.2d,v4.2d,v0.2d // "D + T1" +.long 0xce618480 //sha512h2 v0.16b,v4.16b,v1.16b + add v0.2d,v0.2d,v26.2d // accumulate + add v1.2d,v1.2d,v27.2d + add v2.2d,v2.2d,v28.2d + add v3.2d,v3.2d,v29.2d + + cbnz x2,Loop_hw + + st1 {v0.2d,v1.2d,v2.2d,v3.2d},[x0] // store context + + ldr x29,[sp],#16 + ret + +#endif +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(_WIN32) diff --git a/http/vendor/ring/pregenerated/sha512-x86_64-elf.S b/http/vendor/ring/pregenerated/sha512-x86_64-elf.S new file mode 100644 index 0000000..7e77277 --- /dev/null +++ b/http/vendor/ring/pregenerated/sha512-x86_64-elf.S @@ -0,0 +1,2978 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__) +.text + +.globl sha512_block_data_order_nohw +.hidden sha512_block_data_order_nohw +.type sha512_block_data_order_nohw,@function +.align 16 +sha512_block_data_order_nohw: +.cfi_startproc +_CET_ENDBR + movq %rsp,%rax +.cfi_def_cfa_register %rax + pushq %rbx +.cfi_offset %rbx,-16 + pushq %rbp +.cfi_offset %rbp,-24 + pushq %r12 +.cfi_offset %r12,-32 + pushq %r13 +.cfi_offset %r13,-40 + pushq %r14 +.cfi_offset %r14,-48 + pushq %r15 +.cfi_offset %r15,-56 + shlq $4,%rdx + subq $128+32,%rsp + leaq (%rsi,%rdx,8),%rdx + andq $-64,%rsp + movq %rdi,128+0(%rsp) + movq %rsi,128+8(%rsp) + movq %rdx,128+16(%rsp) + movq %rax,152(%rsp) +.cfi_escape 0x0f,0x06,0x77,0x98,0x01,0x06,0x23,0x08 +.Lprologue: + + movq 0(%rdi),%rax + movq 8(%rdi),%rbx + movq 16(%rdi),%rcx + movq 24(%rdi),%rdx + movq 32(%rdi),%r8 + movq 40(%rdi),%r9 + movq 48(%rdi),%r10 + movq 56(%rdi),%r11 + jmp .Lloop + +.align 16 +.Lloop: + movq %rbx,%rdi + leaq K512(%rip),%rbp + xorq %rcx,%rdi + movq 0(%rsi),%r12 + movq %r8,%r13 + movq %rax,%r14 + bswapq %r12 + rorq $23,%r13 + movq %r9,%r15 + + xorq %r8,%r13 + rorq $5,%r14 + xorq %r10,%r15 + + movq %r12,0(%rsp) + xorq %rax,%r14 + andq %r8,%r15 + + rorq $4,%r13 + addq %r11,%r12 + xorq %r10,%r15 + + rorq $6,%r14 + xorq %r8,%r13 + addq %r15,%r12 + + movq %rax,%r15 + addq (%rbp),%r12 + xorq %rax,%r14 + + xorq %rbx,%r15 + rorq $14,%r13 + movq %rbx,%r11 + + andq %r15,%rdi + rorq $28,%r14 + addq %r13,%r12 + + xorq %rdi,%r11 + addq %r12,%rdx + addq %r12,%r11 + + leaq 8(%rbp),%rbp + addq %r14,%r11 + movq 8(%rsi),%r12 + movq %rdx,%r13 + movq %r11,%r14 + bswapq %r12 + rorq $23,%r13 + movq %r8,%rdi + + xorq %rdx,%r13 + rorq $5,%r14 + xorq %r9,%rdi + + movq %r12,8(%rsp) + xorq %r11,%r14 + andq %rdx,%rdi + + rorq $4,%r13 + addq %r10,%r12 + xorq %r9,%rdi + + rorq $6,%r14 + xorq %rdx,%r13 + addq %rdi,%r12 + + movq %r11,%rdi + addq (%rbp),%r12 + xorq %r11,%r14 + + xorq %rax,%rdi + rorq $14,%r13 + movq %rax,%r10 + + andq %rdi,%r15 + rorq $28,%r14 + addq %r13,%r12 + + xorq %r15,%r10 + addq %r12,%rcx + addq %r12,%r10 + + leaq 24(%rbp),%rbp + addq %r14,%r10 + movq 16(%rsi),%r12 + movq %rcx,%r13 + movq %r10,%r14 + bswapq %r12 + rorq $23,%r13 + movq %rdx,%r15 + + xorq %rcx,%r13 + rorq $5,%r14 + xorq %r8,%r15 + + movq %r12,16(%rsp) + xorq %r10,%r14 + andq %rcx,%r15 + + rorq $4,%r13 + addq %r9,%r12 + xorq %r8,%r15 + + rorq $6,%r14 + xorq %rcx,%r13 + addq %r15,%r12 + + movq %r10,%r15 + addq (%rbp),%r12 + xorq %r10,%r14 + + xorq %r11,%r15 + rorq $14,%r13 + movq %r11,%r9 + + andq %r15,%rdi + rorq $28,%r14 + addq %r13,%r12 + + xorq %rdi,%r9 + addq %r12,%rbx + addq %r12,%r9 + + leaq 8(%rbp),%rbp + addq %r14,%r9 + movq 24(%rsi),%r12 + movq %rbx,%r13 + movq %r9,%r14 + bswapq %r12 + rorq $23,%r13 + movq %rcx,%rdi + + xorq %rbx,%r13 + rorq $5,%r14 + xorq %rdx,%rdi + + movq %r12,24(%rsp) + xorq %r9,%r14 + andq %rbx,%rdi + + rorq $4,%r13 + addq %r8,%r12 + xorq %rdx,%rdi + + rorq $6,%r14 + xorq %rbx,%r13 + addq %rdi,%r12 + + movq %r9,%rdi + addq (%rbp),%r12 + xorq %r9,%r14 + + xorq %r10,%rdi + rorq $14,%r13 + movq %r10,%r8 + + andq %rdi,%r15 + rorq $28,%r14 + addq %r13,%r12 + + xorq %r15,%r8 + addq %r12,%rax + addq %r12,%r8 + + leaq 24(%rbp),%rbp + addq %r14,%r8 + movq 32(%rsi),%r12 + movq %rax,%r13 + movq %r8,%r14 + bswapq %r12 + rorq $23,%r13 + movq %rbx,%r15 + + xorq %rax,%r13 + rorq $5,%r14 + xorq %rcx,%r15 + + movq %r12,32(%rsp) + xorq %r8,%r14 + andq %rax,%r15 + + rorq $4,%r13 + addq %rdx,%r12 + xorq %rcx,%r15 + + rorq $6,%r14 + xorq %rax,%r13 + addq %r15,%r12 + + movq %r8,%r15 + addq (%rbp),%r12 + xorq %r8,%r14 + + xorq %r9,%r15 + rorq $14,%r13 + movq %r9,%rdx + + andq %r15,%rdi + rorq $28,%r14 + addq %r13,%r12 + + xorq %rdi,%rdx + addq %r12,%r11 + addq %r12,%rdx + + leaq 8(%rbp),%rbp + addq %r14,%rdx + movq 40(%rsi),%r12 + movq %r11,%r13 + movq %rdx,%r14 + bswapq %r12 + rorq $23,%r13 + movq %rax,%rdi + + xorq %r11,%r13 + rorq $5,%r14 + xorq %rbx,%rdi + + movq %r12,40(%rsp) + xorq %rdx,%r14 + andq %r11,%rdi + + rorq $4,%r13 + addq %rcx,%r12 + xorq %rbx,%rdi + + rorq $6,%r14 + xorq %r11,%r13 + addq %rdi,%r12 + + movq %rdx,%rdi + addq (%rbp),%r12 + xorq %rdx,%r14 + + xorq %r8,%rdi + rorq $14,%r13 + movq %r8,%rcx + + andq %rdi,%r15 + rorq $28,%r14 + addq %r13,%r12 + + xorq %r15,%rcx + addq %r12,%r10 + addq %r12,%rcx + + leaq 24(%rbp),%rbp + addq %r14,%rcx + movq 48(%rsi),%r12 + movq %r10,%r13 + movq %rcx,%r14 + bswapq %r12 + rorq $23,%r13 + movq %r11,%r15 + + xorq %r10,%r13 + rorq $5,%r14 + xorq %rax,%r15 + + movq %r12,48(%rsp) + xorq %rcx,%r14 + andq %r10,%r15 + + rorq $4,%r13 + addq %rbx,%r12 + xorq %rax,%r15 + + rorq $6,%r14 + xorq %r10,%r13 + addq %r15,%r12 + + movq %rcx,%r15 + addq (%rbp),%r12 + xorq %rcx,%r14 + + xorq %rdx,%r15 + rorq $14,%r13 + movq %rdx,%rbx + + andq %r15,%rdi + rorq $28,%r14 + addq %r13,%r12 + + xorq %rdi,%rbx + addq %r12,%r9 + addq %r12,%rbx + + leaq 8(%rbp),%rbp + addq %r14,%rbx + movq 56(%rsi),%r12 + movq %r9,%r13 + movq %rbx,%r14 + bswapq %r12 + rorq $23,%r13 + movq %r10,%rdi + + xorq %r9,%r13 + rorq $5,%r14 + xorq %r11,%rdi + + movq %r12,56(%rsp) + xorq %rbx,%r14 + andq %r9,%rdi + + rorq $4,%r13 + addq %rax,%r12 + xorq %r11,%rdi + + rorq $6,%r14 + xorq %r9,%r13 + addq %rdi,%r12 + + movq %rbx,%rdi + addq (%rbp),%r12 + xorq %rbx,%r14 + + xorq %rcx,%rdi + rorq $14,%r13 + movq %rcx,%rax + + andq %rdi,%r15 + rorq $28,%r14 + addq %r13,%r12 + + xorq %r15,%rax + addq %r12,%r8 + addq %r12,%rax + + leaq 24(%rbp),%rbp + addq %r14,%rax + movq 64(%rsi),%r12 + movq %r8,%r13 + movq %rax,%r14 + bswapq %r12 + rorq $23,%r13 + movq %r9,%r15 + + xorq %r8,%r13 + rorq $5,%r14 + xorq %r10,%r15 + + movq %r12,64(%rsp) + xorq %rax,%r14 + andq %r8,%r15 + + rorq $4,%r13 + addq %r11,%r12 + xorq %r10,%r15 + + rorq $6,%r14 + xorq %r8,%r13 + addq %r15,%r12 + + movq %rax,%r15 + addq (%rbp),%r12 + xorq %rax,%r14 + + xorq %rbx,%r15 + rorq $14,%r13 + movq %rbx,%r11 + + andq %r15,%rdi + rorq $28,%r14 + addq %r13,%r12 + + xorq %rdi,%r11 + addq %r12,%rdx + addq %r12,%r11 + + leaq 8(%rbp),%rbp + addq %r14,%r11 + movq 72(%rsi),%r12 + movq %rdx,%r13 + movq %r11,%r14 + bswapq %r12 + rorq $23,%r13 + movq %r8,%rdi + + xorq %rdx,%r13 + rorq $5,%r14 + xorq %r9,%rdi + + movq %r12,72(%rsp) + xorq %r11,%r14 + andq %rdx,%rdi + + rorq $4,%r13 + addq %r10,%r12 + xorq %r9,%rdi + + rorq $6,%r14 + xorq %rdx,%r13 + addq %rdi,%r12 + + movq %r11,%rdi + addq (%rbp),%r12 + xorq %r11,%r14 + + xorq %rax,%rdi + rorq $14,%r13 + movq %rax,%r10 + + andq %rdi,%r15 + rorq $28,%r14 + addq %r13,%r12 + + xorq %r15,%r10 + addq %r12,%rcx + addq %r12,%r10 + + leaq 24(%rbp),%rbp + addq %r14,%r10 + movq 80(%rsi),%r12 + movq %rcx,%r13 + movq %r10,%r14 + bswapq %r12 + rorq $23,%r13 + movq %rdx,%r15 + + xorq %rcx,%r13 + rorq $5,%r14 + xorq %r8,%r15 + + movq %r12,80(%rsp) + xorq %r10,%r14 + andq %rcx,%r15 + + rorq $4,%r13 + addq %r9,%r12 + xorq %r8,%r15 + + rorq $6,%r14 + xorq %rcx,%r13 + addq %r15,%r12 + + movq %r10,%r15 + addq (%rbp),%r12 + xorq %r10,%r14 + + xorq %r11,%r15 + rorq $14,%r13 + movq %r11,%r9 + + andq %r15,%rdi + rorq $28,%r14 + addq %r13,%r12 + + xorq %rdi,%r9 + addq %r12,%rbx + addq %r12,%r9 + + leaq 8(%rbp),%rbp + addq %r14,%r9 + movq 88(%rsi),%r12 + movq %rbx,%r13 + movq %r9,%r14 + bswapq %r12 + rorq $23,%r13 + movq %rcx,%rdi + + xorq %rbx,%r13 + rorq $5,%r14 + xorq %rdx,%rdi + + movq %r12,88(%rsp) + xorq %r9,%r14 + andq %rbx,%rdi + + rorq $4,%r13 + addq %r8,%r12 + xorq %rdx,%rdi + + rorq $6,%r14 + xorq %rbx,%r13 + addq %rdi,%r12 + + movq %r9,%rdi + addq (%rbp),%r12 + xorq %r9,%r14 + + xorq %r10,%rdi + rorq $14,%r13 + movq %r10,%r8 + + andq %rdi,%r15 + rorq $28,%r14 + addq %r13,%r12 + + xorq %r15,%r8 + addq %r12,%rax + addq %r12,%r8 + + leaq 24(%rbp),%rbp + addq %r14,%r8 + movq 96(%rsi),%r12 + movq %rax,%r13 + movq %r8,%r14 + bswapq %r12 + rorq $23,%r13 + movq %rbx,%r15 + + xorq %rax,%r13 + rorq $5,%r14 + xorq %rcx,%r15 + + movq %r12,96(%rsp) + xorq %r8,%r14 + andq %rax,%r15 + + rorq $4,%r13 + addq %rdx,%r12 + xorq %rcx,%r15 + + rorq $6,%r14 + xorq %rax,%r13 + addq %r15,%r12 + + movq %r8,%r15 + addq (%rbp),%r12 + xorq %r8,%r14 + + xorq %r9,%r15 + rorq $14,%r13 + movq %r9,%rdx + + andq %r15,%rdi + rorq $28,%r14 + addq %r13,%r12 + + xorq %rdi,%rdx + addq %r12,%r11 + addq %r12,%rdx + + leaq 8(%rbp),%rbp + addq %r14,%rdx + movq 104(%rsi),%r12 + movq %r11,%r13 + movq %rdx,%r14 + bswapq %r12 + rorq $23,%r13 + movq %rax,%rdi + + xorq %r11,%r13 + rorq $5,%r14 + xorq %rbx,%rdi + + movq %r12,104(%rsp) + xorq %rdx,%r14 + andq %r11,%rdi + + rorq $4,%r13 + addq %rcx,%r12 + xorq %rbx,%rdi + + rorq $6,%r14 + xorq %r11,%r13 + addq %rdi,%r12 + + movq %rdx,%rdi + addq (%rbp),%r12 + xorq %rdx,%r14 + + xorq %r8,%rdi + rorq $14,%r13 + movq %r8,%rcx + + andq %rdi,%r15 + rorq $28,%r14 + addq %r13,%r12 + + xorq %r15,%rcx + addq %r12,%r10 + addq %r12,%rcx + + leaq 24(%rbp),%rbp + addq %r14,%rcx + movq 112(%rsi),%r12 + movq %r10,%r13 + movq %rcx,%r14 + bswapq %r12 + rorq $23,%r13 + movq %r11,%r15 + + xorq %r10,%r13 + rorq $5,%r14 + xorq %rax,%r15 + + movq %r12,112(%rsp) + xorq %rcx,%r14 + andq %r10,%r15 + + rorq $4,%r13 + addq %rbx,%r12 + xorq %rax,%r15 + + rorq $6,%r14 + xorq %r10,%r13 + addq %r15,%r12 + + movq %rcx,%r15 + addq (%rbp),%r12 + xorq %rcx,%r14 + + xorq %rdx,%r15 + rorq $14,%r13 + movq %rdx,%rbx + + andq %r15,%rdi + rorq $28,%r14 + addq %r13,%r12 + + xorq %rdi,%rbx + addq %r12,%r9 + addq %r12,%rbx + + leaq 8(%rbp),%rbp + addq %r14,%rbx + movq 120(%rsi),%r12 + movq %r9,%r13 + movq %rbx,%r14 + bswapq %r12 + rorq $23,%r13 + movq %r10,%rdi + + xorq %r9,%r13 + rorq $5,%r14 + xorq %r11,%rdi + + movq %r12,120(%rsp) + xorq %rbx,%r14 + andq %r9,%rdi + + rorq $4,%r13 + addq %rax,%r12 + xorq %r11,%rdi + + rorq $6,%r14 + xorq %r9,%r13 + addq %rdi,%r12 + + movq %rbx,%rdi + addq (%rbp),%r12 + xorq %rbx,%r14 + + xorq %rcx,%rdi + rorq $14,%r13 + movq %rcx,%rax + + andq %rdi,%r15 + rorq $28,%r14 + addq %r13,%r12 + + xorq %r15,%rax + addq %r12,%r8 + addq %r12,%rax + + leaq 24(%rbp),%rbp + jmp .Lrounds_16_xx +.align 16 +.Lrounds_16_xx: + movq 8(%rsp),%r13 + movq 112(%rsp),%r15 + + movq %r13,%r12 + rorq $7,%r13 + addq %r14,%rax + movq %r15,%r14 + rorq $42,%r15 + + xorq %r12,%r13 + shrq $7,%r12 + rorq $1,%r13 + xorq %r14,%r15 + shrq $6,%r14 + + rorq $19,%r15 + xorq %r13,%r12 + xorq %r14,%r15 + addq 72(%rsp),%r12 + + addq 0(%rsp),%r12 + movq %r8,%r13 + addq %r15,%r12 + movq %rax,%r14 + rorq $23,%r13 + movq %r9,%r15 + + xorq %r8,%r13 + rorq $5,%r14 + xorq %r10,%r15 + + movq %r12,0(%rsp) + xorq %rax,%r14 + andq %r8,%r15 + + rorq $4,%r13 + addq %r11,%r12 + xorq %r10,%r15 + + rorq $6,%r14 + xorq %r8,%r13 + addq %r15,%r12 + + movq %rax,%r15 + addq (%rbp),%r12 + xorq %rax,%r14 + + xorq %rbx,%r15 + rorq $14,%r13 + movq %rbx,%r11 + + andq %r15,%rdi + rorq $28,%r14 + addq %r13,%r12 + + xorq %rdi,%r11 + addq %r12,%rdx + addq %r12,%r11 + + leaq 8(%rbp),%rbp + movq 16(%rsp),%r13 + movq 120(%rsp),%rdi + + movq %r13,%r12 + rorq $7,%r13 + addq %r14,%r11 + movq %rdi,%r14 + rorq $42,%rdi + + xorq %r12,%r13 + shrq $7,%r12 + rorq $1,%r13 + xorq %r14,%rdi + shrq $6,%r14 + + rorq $19,%rdi + xorq %r13,%r12 + xorq %r14,%rdi + addq 80(%rsp),%r12 + + addq 8(%rsp),%r12 + movq %rdx,%r13 + addq %rdi,%r12 + movq %r11,%r14 + rorq $23,%r13 + movq %r8,%rdi + + xorq %rdx,%r13 + rorq $5,%r14 + xorq %r9,%rdi + + movq %r12,8(%rsp) + xorq %r11,%r14 + andq %rdx,%rdi + + rorq $4,%r13 + addq %r10,%r12 + xorq %r9,%rdi + + rorq $6,%r14 + xorq %rdx,%r13 + addq %rdi,%r12 + + movq %r11,%rdi + addq (%rbp),%r12 + xorq %r11,%r14 + + xorq %rax,%rdi + rorq $14,%r13 + movq %rax,%r10 + + andq %rdi,%r15 + rorq $28,%r14 + addq %r13,%r12 + + xorq %r15,%r10 + addq %r12,%rcx + addq %r12,%r10 + + leaq 24(%rbp),%rbp + movq 24(%rsp),%r13 + movq 0(%rsp),%r15 + + movq %r13,%r12 + rorq $7,%r13 + addq %r14,%r10 + movq %r15,%r14 + rorq $42,%r15 + + xorq %r12,%r13 + shrq $7,%r12 + rorq $1,%r13 + xorq %r14,%r15 + shrq $6,%r14 + + rorq $19,%r15 + xorq %r13,%r12 + xorq %r14,%r15 + addq 88(%rsp),%r12 + + addq 16(%rsp),%r12 + movq %rcx,%r13 + addq %r15,%r12 + movq %r10,%r14 + rorq $23,%r13 + movq %rdx,%r15 + + xorq %rcx,%r13 + rorq $5,%r14 + xorq %r8,%r15 + + movq %r12,16(%rsp) + xorq %r10,%r14 + andq %rcx,%r15 + + rorq $4,%r13 + addq %r9,%r12 + xorq %r8,%r15 + + rorq $6,%r14 + xorq %rcx,%r13 + addq %r15,%r12 + + movq %r10,%r15 + addq (%rbp),%r12 + xorq %r10,%r14 + + xorq %r11,%r15 + rorq $14,%r13 + movq %r11,%r9 + + andq %r15,%rdi + rorq $28,%r14 + addq %r13,%r12 + + xorq %rdi,%r9 + addq %r12,%rbx + addq %r12,%r9 + + leaq 8(%rbp),%rbp + movq 32(%rsp),%r13 + movq 8(%rsp),%rdi + + movq %r13,%r12 + rorq $7,%r13 + addq %r14,%r9 + movq %rdi,%r14 + rorq $42,%rdi + + xorq %r12,%r13 + shrq $7,%r12 + rorq $1,%r13 + xorq %r14,%rdi + shrq $6,%r14 + + rorq $19,%rdi + xorq %r13,%r12 + xorq %r14,%rdi + addq 96(%rsp),%r12 + + addq 24(%rsp),%r12 + movq %rbx,%r13 + addq %rdi,%r12 + movq %r9,%r14 + rorq $23,%r13 + movq %rcx,%rdi + + xorq %rbx,%r13 + rorq $5,%r14 + xorq %rdx,%rdi + + movq %r12,24(%rsp) + xorq %r9,%r14 + andq %rbx,%rdi + + rorq $4,%r13 + addq %r8,%r12 + xorq %rdx,%rdi + + rorq $6,%r14 + xorq %rbx,%r13 + addq %rdi,%r12 + + movq %r9,%rdi + addq (%rbp),%r12 + xorq %r9,%r14 + + xorq %r10,%rdi + rorq $14,%r13 + movq %r10,%r8 + + andq %rdi,%r15 + rorq $28,%r14 + addq %r13,%r12 + + xorq %r15,%r8 + addq %r12,%rax + addq %r12,%r8 + + leaq 24(%rbp),%rbp + movq 40(%rsp),%r13 + movq 16(%rsp),%r15 + + movq %r13,%r12 + rorq $7,%r13 + addq %r14,%r8 + movq %r15,%r14 + rorq $42,%r15 + + xorq %r12,%r13 + shrq $7,%r12 + rorq $1,%r13 + xorq %r14,%r15 + shrq $6,%r14 + + rorq $19,%r15 + xorq %r13,%r12 + xorq %r14,%r15 + addq 104(%rsp),%r12 + + addq 32(%rsp),%r12 + movq %rax,%r13 + addq %r15,%r12 + movq %r8,%r14 + rorq $23,%r13 + movq %rbx,%r15 + + xorq %rax,%r13 + rorq $5,%r14 + xorq %rcx,%r15 + + movq %r12,32(%rsp) + xorq %r8,%r14 + andq %rax,%r15 + + rorq $4,%r13 + addq %rdx,%r12 + xorq %rcx,%r15 + + rorq $6,%r14 + xorq %rax,%r13 + addq %r15,%r12 + + movq %r8,%r15 + addq (%rbp),%r12 + xorq %r8,%r14 + + xorq %r9,%r15 + rorq $14,%r13 + movq %r9,%rdx + + andq %r15,%rdi + rorq $28,%r14 + addq %r13,%r12 + + xorq %rdi,%rdx + addq %r12,%r11 + addq %r12,%rdx + + leaq 8(%rbp),%rbp + movq 48(%rsp),%r13 + movq 24(%rsp),%rdi + + movq %r13,%r12 + rorq $7,%r13 + addq %r14,%rdx + movq %rdi,%r14 + rorq $42,%rdi + + xorq %r12,%r13 + shrq $7,%r12 + rorq $1,%r13 + xorq %r14,%rdi + shrq $6,%r14 + + rorq $19,%rdi + xorq %r13,%r12 + xorq %r14,%rdi + addq 112(%rsp),%r12 + + addq 40(%rsp),%r12 + movq %r11,%r13 + addq %rdi,%r12 + movq %rdx,%r14 + rorq $23,%r13 + movq %rax,%rdi + + xorq %r11,%r13 + rorq $5,%r14 + xorq %rbx,%rdi + + movq %r12,40(%rsp) + xorq %rdx,%r14 + andq %r11,%rdi + + rorq $4,%r13 + addq %rcx,%r12 + xorq %rbx,%rdi + + rorq $6,%r14 + xorq %r11,%r13 + addq %rdi,%r12 + + movq %rdx,%rdi + addq (%rbp),%r12 + xorq %rdx,%r14 + + xorq %r8,%rdi + rorq $14,%r13 + movq %r8,%rcx + + andq %rdi,%r15 + rorq $28,%r14 + addq %r13,%r12 + + xorq %r15,%rcx + addq %r12,%r10 + addq %r12,%rcx + + leaq 24(%rbp),%rbp + movq 56(%rsp),%r13 + movq 32(%rsp),%r15 + + movq %r13,%r12 + rorq $7,%r13 + addq %r14,%rcx + movq %r15,%r14 + rorq $42,%r15 + + xorq %r12,%r13 + shrq $7,%r12 + rorq $1,%r13 + xorq %r14,%r15 + shrq $6,%r14 + + rorq $19,%r15 + xorq %r13,%r12 + xorq %r14,%r15 + addq 120(%rsp),%r12 + + addq 48(%rsp),%r12 + movq %r10,%r13 + addq %r15,%r12 + movq %rcx,%r14 + rorq $23,%r13 + movq %r11,%r15 + + xorq %r10,%r13 + rorq $5,%r14 + xorq %rax,%r15 + + movq %r12,48(%rsp) + xorq %rcx,%r14 + andq %r10,%r15 + + rorq $4,%r13 + addq %rbx,%r12 + xorq %rax,%r15 + + rorq $6,%r14 + xorq %r10,%r13 + addq %r15,%r12 + + movq %rcx,%r15 + addq (%rbp),%r12 + xorq %rcx,%r14 + + xorq %rdx,%r15 + rorq $14,%r13 + movq %rdx,%rbx + + andq %r15,%rdi + rorq $28,%r14 + addq %r13,%r12 + + xorq %rdi,%rbx + addq %r12,%r9 + addq %r12,%rbx + + leaq 8(%rbp),%rbp + movq 64(%rsp),%r13 + movq 40(%rsp),%rdi + + movq %r13,%r12 + rorq $7,%r13 + addq %r14,%rbx + movq %rdi,%r14 + rorq $42,%rdi + + xorq %r12,%r13 + shrq $7,%r12 + rorq $1,%r13 + xorq %r14,%rdi + shrq $6,%r14 + + rorq $19,%rdi + xorq %r13,%r12 + xorq %r14,%rdi + addq 0(%rsp),%r12 + + addq 56(%rsp),%r12 + movq %r9,%r13 + addq %rdi,%r12 + movq %rbx,%r14 + rorq $23,%r13 + movq %r10,%rdi + + xorq %r9,%r13 + rorq $5,%r14 + xorq %r11,%rdi + + movq %r12,56(%rsp) + xorq %rbx,%r14 + andq %r9,%rdi + + rorq $4,%r13 + addq %rax,%r12 + xorq %r11,%rdi + + rorq $6,%r14 + xorq %r9,%r13 + addq %rdi,%r12 + + movq %rbx,%rdi + addq (%rbp),%r12 + xorq %rbx,%r14 + + xorq %rcx,%rdi + rorq $14,%r13 + movq %rcx,%rax + + andq %rdi,%r15 + rorq $28,%r14 + addq %r13,%r12 + + xorq %r15,%rax + addq %r12,%r8 + addq %r12,%rax + + leaq 24(%rbp),%rbp + movq 72(%rsp),%r13 + movq 48(%rsp),%r15 + + movq %r13,%r12 + rorq $7,%r13 + addq %r14,%rax + movq %r15,%r14 + rorq $42,%r15 + + xorq %r12,%r13 + shrq $7,%r12 + rorq $1,%r13 + xorq %r14,%r15 + shrq $6,%r14 + + rorq $19,%r15 + xorq %r13,%r12 + xorq %r14,%r15 + addq 8(%rsp),%r12 + + addq 64(%rsp),%r12 + movq %r8,%r13 + addq %r15,%r12 + movq %rax,%r14 + rorq $23,%r13 + movq %r9,%r15 + + xorq %r8,%r13 + rorq $5,%r14 + xorq %r10,%r15 + + movq %r12,64(%rsp) + xorq %rax,%r14 + andq %r8,%r15 + + rorq $4,%r13 + addq %r11,%r12 + xorq %r10,%r15 + + rorq $6,%r14 + xorq %r8,%r13 + addq %r15,%r12 + + movq %rax,%r15 + addq (%rbp),%r12 + xorq %rax,%r14 + + xorq %rbx,%r15 + rorq $14,%r13 + movq %rbx,%r11 + + andq %r15,%rdi + rorq $28,%r14 + addq %r13,%r12 + + xorq %rdi,%r11 + addq %r12,%rdx + addq %r12,%r11 + + leaq 8(%rbp),%rbp + movq 80(%rsp),%r13 + movq 56(%rsp),%rdi + + movq %r13,%r12 + rorq $7,%r13 + addq %r14,%r11 + movq %rdi,%r14 + rorq $42,%rdi + + xorq %r12,%r13 + shrq $7,%r12 + rorq $1,%r13 + xorq %r14,%rdi + shrq $6,%r14 + + rorq $19,%rdi + xorq %r13,%r12 + xorq %r14,%rdi + addq 16(%rsp),%r12 + + addq 72(%rsp),%r12 + movq %rdx,%r13 + addq %rdi,%r12 + movq %r11,%r14 + rorq $23,%r13 + movq %r8,%rdi + + xorq %rdx,%r13 + rorq $5,%r14 + xorq %r9,%rdi + + movq %r12,72(%rsp) + xorq %r11,%r14 + andq %rdx,%rdi + + rorq $4,%r13 + addq %r10,%r12 + xorq %r9,%rdi + + rorq $6,%r14 + xorq %rdx,%r13 + addq %rdi,%r12 + + movq %r11,%rdi + addq (%rbp),%r12 + xorq %r11,%r14 + + xorq %rax,%rdi + rorq $14,%r13 + movq %rax,%r10 + + andq %rdi,%r15 + rorq $28,%r14 + addq %r13,%r12 + + xorq %r15,%r10 + addq %r12,%rcx + addq %r12,%r10 + + leaq 24(%rbp),%rbp + movq 88(%rsp),%r13 + movq 64(%rsp),%r15 + + movq %r13,%r12 + rorq $7,%r13 + addq %r14,%r10 + movq %r15,%r14 + rorq $42,%r15 + + xorq %r12,%r13 + shrq $7,%r12 + rorq $1,%r13 + xorq %r14,%r15 + shrq $6,%r14 + + rorq $19,%r15 + xorq %r13,%r12 + xorq %r14,%r15 + addq 24(%rsp),%r12 + + addq 80(%rsp),%r12 + movq %rcx,%r13 + addq %r15,%r12 + movq %r10,%r14 + rorq $23,%r13 + movq %rdx,%r15 + + xorq %rcx,%r13 + rorq $5,%r14 + xorq %r8,%r15 + + movq %r12,80(%rsp) + xorq %r10,%r14 + andq %rcx,%r15 + + rorq $4,%r13 + addq %r9,%r12 + xorq %r8,%r15 + + rorq $6,%r14 + xorq %rcx,%r13 + addq %r15,%r12 + + movq %r10,%r15 + addq (%rbp),%r12 + xorq %r10,%r14 + + xorq %r11,%r15 + rorq $14,%r13 + movq %r11,%r9 + + andq %r15,%rdi + rorq $28,%r14 + addq %r13,%r12 + + xorq %rdi,%r9 + addq %r12,%rbx + addq %r12,%r9 + + leaq 8(%rbp),%rbp + movq 96(%rsp),%r13 + movq 72(%rsp),%rdi + + movq %r13,%r12 + rorq $7,%r13 + addq %r14,%r9 + movq %rdi,%r14 + rorq $42,%rdi + + xorq %r12,%r13 + shrq $7,%r12 + rorq $1,%r13 + xorq %r14,%rdi + shrq $6,%r14 + + rorq $19,%rdi + xorq %r13,%r12 + xorq %r14,%rdi + addq 32(%rsp),%r12 + + addq 88(%rsp),%r12 + movq %rbx,%r13 + addq %rdi,%r12 + movq %r9,%r14 + rorq $23,%r13 + movq %rcx,%rdi + + xorq %rbx,%r13 + rorq $5,%r14 + xorq %rdx,%rdi + + movq %r12,88(%rsp) + xorq %r9,%r14 + andq %rbx,%rdi + + rorq $4,%r13 + addq %r8,%r12 + xorq %rdx,%rdi + + rorq $6,%r14 + xorq %rbx,%r13 + addq %rdi,%r12 + + movq %r9,%rdi + addq (%rbp),%r12 + xorq %r9,%r14 + + xorq %r10,%rdi + rorq $14,%r13 + movq %r10,%r8 + + andq %rdi,%r15 + rorq $28,%r14 + addq %r13,%r12 + + xorq %r15,%r8 + addq %r12,%rax + addq %r12,%r8 + + leaq 24(%rbp),%rbp + movq 104(%rsp),%r13 + movq 80(%rsp),%r15 + + movq %r13,%r12 + rorq $7,%r13 + addq %r14,%r8 + movq %r15,%r14 + rorq $42,%r15 + + xorq %r12,%r13 + shrq $7,%r12 + rorq $1,%r13 + xorq %r14,%r15 + shrq $6,%r14 + + rorq $19,%r15 + xorq %r13,%r12 + xorq %r14,%r15 + addq 40(%rsp),%r12 + + addq 96(%rsp),%r12 + movq %rax,%r13 + addq %r15,%r12 + movq %r8,%r14 + rorq $23,%r13 + movq %rbx,%r15 + + xorq %rax,%r13 + rorq $5,%r14 + xorq %rcx,%r15 + + movq %r12,96(%rsp) + xorq %r8,%r14 + andq %rax,%r15 + + rorq $4,%r13 + addq %rdx,%r12 + xorq %rcx,%r15 + + rorq $6,%r14 + xorq %rax,%r13 + addq %r15,%r12 + + movq %r8,%r15 + addq (%rbp),%r12 + xorq %r8,%r14 + + xorq %r9,%r15 + rorq $14,%r13 + movq %r9,%rdx + + andq %r15,%rdi + rorq $28,%r14 + addq %r13,%r12 + + xorq %rdi,%rdx + addq %r12,%r11 + addq %r12,%rdx + + leaq 8(%rbp),%rbp + movq 112(%rsp),%r13 + movq 88(%rsp),%rdi + + movq %r13,%r12 + rorq $7,%r13 + addq %r14,%rdx + movq %rdi,%r14 + rorq $42,%rdi + + xorq %r12,%r13 + shrq $7,%r12 + rorq $1,%r13 + xorq %r14,%rdi + shrq $6,%r14 + + rorq $19,%rdi + xorq %r13,%r12 + xorq %r14,%rdi + addq 48(%rsp),%r12 + + addq 104(%rsp),%r12 + movq %r11,%r13 + addq %rdi,%r12 + movq %rdx,%r14 + rorq $23,%r13 + movq %rax,%rdi + + xorq %r11,%r13 + rorq $5,%r14 + xorq %rbx,%rdi + + movq %r12,104(%rsp) + xorq %rdx,%r14 + andq %r11,%rdi + + rorq $4,%r13 + addq %rcx,%r12 + xorq %rbx,%rdi + + rorq $6,%r14 + xorq %r11,%r13 + addq %rdi,%r12 + + movq %rdx,%rdi + addq (%rbp),%r12 + xorq %rdx,%r14 + + xorq %r8,%rdi + rorq $14,%r13 + movq %r8,%rcx + + andq %rdi,%r15 + rorq $28,%r14 + addq %r13,%r12 + + xorq %r15,%rcx + addq %r12,%r10 + addq %r12,%rcx + + leaq 24(%rbp),%rbp + movq 120(%rsp),%r13 + movq 96(%rsp),%r15 + + movq %r13,%r12 + rorq $7,%r13 + addq %r14,%rcx + movq %r15,%r14 + rorq $42,%r15 + + xorq %r12,%r13 + shrq $7,%r12 + rorq $1,%r13 + xorq %r14,%r15 + shrq $6,%r14 + + rorq $19,%r15 + xorq %r13,%r12 + xorq %r14,%r15 + addq 56(%rsp),%r12 + + addq 112(%rsp),%r12 + movq %r10,%r13 + addq %r15,%r12 + movq %rcx,%r14 + rorq $23,%r13 + movq %r11,%r15 + + xorq %r10,%r13 + rorq $5,%r14 + xorq %rax,%r15 + + movq %r12,112(%rsp) + xorq %rcx,%r14 + andq %r10,%r15 + + rorq $4,%r13 + addq %rbx,%r12 + xorq %rax,%r15 + + rorq $6,%r14 + xorq %r10,%r13 + addq %r15,%r12 + + movq %rcx,%r15 + addq (%rbp),%r12 + xorq %rcx,%r14 + + xorq %rdx,%r15 + rorq $14,%r13 + movq %rdx,%rbx + + andq %r15,%rdi + rorq $28,%r14 + addq %r13,%r12 + + xorq %rdi,%rbx + addq %r12,%r9 + addq %r12,%rbx + + leaq 8(%rbp),%rbp + movq 0(%rsp),%r13 + movq 104(%rsp),%rdi + + movq %r13,%r12 + rorq $7,%r13 + addq %r14,%rbx + movq %rdi,%r14 + rorq $42,%rdi + + xorq %r12,%r13 + shrq $7,%r12 + rorq $1,%r13 + xorq %r14,%rdi + shrq $6,%r14 + + rorq $19,%rdi + xorq %r13,%r12 + xorq %r14,%rdi + addq 64(%rsp),%r12 + + addq 120(%rsp),%r12 + movq %r9,%r13 + addq %rdi,%r12 + movq %rbx,%r14 + rorq $23,%r13 + movq %r10,%rdi + + xorq %r9,%r13 + rorq $5,%r14 + xorq %r11,%rdi + + movq %r12,120(%rsp) + xorq %rbx,%r14 + andq %r9,%rdi + + rorq $4,%r13 + addq %rax,%r12 + xorq %r11,%rdi + + rorq $6,%r14 + xorq %r9,%r13 + addq %rdi,%r12 + + movq %rbx,%rdi + addq (%rbp),%r12 + xorq %rbx,%r14 + + xorq %rcx,%rdi + rorq $14,%r13 + movq %rcx,%rax + + andq %rdi,%r15 + rorq $28,%r14 + addq %r13,%r12 + + xorq %r15,%rax + addq %r12,%r8 + addq %r12,%rax + + leaq 24(%rbp),%rbp + cmpb $0,7(%rbp) + jnz .Lrounds_16_xx + + movq 128+0(%rsp),%rdi + addq %r14,%rax + leaq 128(%rsi),%rsi + + addq 0(%rdi),%rax + addq 8(%rdi),%rbx + addq 16(%rdi),%rcx + addq 24(%rdi),%rdx + addq 32(%rdi),%r8 + addq 40(%rdi),%r9 + addq 48(%rdi),%r10 + addq 56(%rdi),%r11 + + cmpq 128+16(%rsp),%rsi + + movq %rax,0(%rdi) + movq %rbx,8(%rdi) + movq %rcx,16(%rdi) + movq %rdx,24(%rdi) + movq %r8,32(%rdi) + movq %r9,40(%rdi) + movq %r10,48(%rdi) + movq %r11,56(%rdi) + jb .Lloop + + movq 152(%rsp),%rsi +.cfi_def_cfa %rsi,8 + movq -48(%rsi),%r15 +.cfi_restore %r15 + movq -40(%rsi),%r14 +.cfi_restore %r14 + movq -32(%rsi),%r13 +.cfi_restore %r13 + movq -24(%rsi),%r12 +.cfi_restore %r12 + movq -16(%rsi),%rbp +.cfi_restore %rbp + movq -8(%rsi),%rbx +.cfi_restore %rbx + leaq (%rsi),%rsp +.cfi_def_cfa_register %rsp +.Lepilogue: + ret +.cfi_endproc +.size sha512_block_data_order_nohw,.-sha512_block_data_order_nohw +.section .rodata +.align 64 +.type K512,@object +K512: +.quad 0x428a2f98d728ae22,0x7137449123ef65cd +.quad 0x428a2f98d728ae22,0x7137449123ef65cd +.quad 0xb5c0fbcfec4d3b2f,0xe9b5dba58189dbbc +.quad 0xb5c0fbcfec4d3b2f,0xe9b5dba58189dbbc +.quad 0x3956c25bf348b538,0x59f111f1b605d019 +.quad 0x3956c25bf348b538,0x59f111f1b605d019 +.quad 0x923f82a4af194f9b,0xab1c5ed5da6d8118 +.quad 0x923f82a4af194f9b,0xab1c5ed5da6d8118 +.quad 0xd807aa98a3030242,0x12835b0145706fbe +.quad 0xd807aa98a3030242,0x12835b0145706fbe +.quad 0x243185be4ee4b28c,0x550c7dc3d5ffb4e2 +.quad 0x243185be4ee4b28c,0x550c7dc3d5ffb4e2 +.quad 0x72be5d74f27b896f,0x80deb1fe3b1696b1 +.quad 0x72be5d74f27b896f,0x80deb1fe3b1696b1 +.quad 0x9bdc06a725c71235,0xc19bf174cf692694 +.quad 0x9bdc06a725c71235,0xc19bf174cf692694 +.quad 0xe49b69c19ef14ad2,0xefbe4786384f25e3 +.quad 0xe49b69c19ef14ad2,0xefbe4786384f25e3 +.quad 0x0fc19dc68b8cd5b5,0x240ca1cc77ac9c65 +.quad 0x0fc19dc68b8cd5b5,0x240ca1cc77ac9c65 +.quad 0x2de92c6f592b0275,0x4a7484aa6ea6e483 +.quad 0x2de92c6f592b0275,0x4a7484aa6ea6e483 +.quad 0x5cb0a9dcbd41fbd4,0x76f988da831153b5 +.quad 0x5cb0a9dcbd41fbd4,0x76f988da831153b5 +.quad 0x983e5152ee66dfab,0xa831c66d2db43210 +.quad 0x983e5152ee66dfab,0xa831c66d2db43210 +.quad 0xb00327c898fb213f,0xbf597fc7beef0ee4 +.quad 0xb00327c898fb213f,0xbf597fc7beef0ee4 +.quad 0xc6e00bf33da88fc2,0xd5a79147930aa725 +.quad 0xc6e00bf33da88fc2,0xd5a79147930aa725 +.quad 0x06ca6351e003826f,0x142929670a0e6e70 +.quad 0x06ca6351e003826f,0x142929670a0e6e70 +.quad 0x27b70a8546d22ffc,0x2e1b21385c26c926 +.quad 0x27b70a8546d22ffc,0x2e1b21385c26c926 +.quad 0x4d2c6dfc5ac42aed,0x53380d139d95b3df +.quad 0x4d2c6dfc5ac42aed,0x53380d139d95b3df +.quad 0x650a73548baf63de,0x766a0abb3c77b2a8 +.quad 0x650a73548baf63de,0x766a0abb3c77b2a8 +.quad 0x81c2c92e47edaee6,0x92722c851482353b +.quad 0x81c2c92e47edaee6,0x92722c851482353b +.quad 0xa2bfe8a14cf10364,0xa81a664bbc423001 +.quad 0xa2bfe8a14cf10364,0xa81a664bbc423001 +.quad 0xc24b8b70d0f89791,0xc76c51a30654be30 +.quad 0xc24b8b70d0f89791,0xc76c51a30654be30 +.quad 0xd192e819d6ef5218,0xd69906245565a910 +.quad 0xd192e819d6ef5218,0xd69906245565a910 +.quad 0xf40e35855771202a,0x106aa07032bbd1b8 +.quad 0xf40e35855771202a,0x106aa07032bbd1b8 +.quad 0x19a4c116b8d2d0c8,0x1e376c085141ab53 +.quad 0x19a4c116b8d2d0c8,0x1e376c085141ab53 +.quad 0x2748774cdf8eeb99,0x34b0bcb5e19b48a8 +.quad 0x2748774cdf8eeb99,0x34b0bcb5e19b48a8 +.quad 0x391c0cb3c5c95a63,0x4ed8aa4ae3418acb +.quad 0x391c0cb3c5c95a63,0x4ed8aa4ae3418acb +.quad 0x5b9cca4f7763e373,0x682e6ff3d6b2b8a3 +.quad 0x5b9cca4f7763e373,0x682e6ff3d6b2b8a3 +.quad 0x748f82ee5defb2fc,0x78a5636f43172f60 +.quad 0x748f82ee5defb2fc,0x78a5636f43172f60 +.quad 0x84c87814a1f0ab72,0x8cc702081a6439ec +.quad 0x84c87814a1f0ab72,0x8cc702081a6439ec +.quad 0x90befffa23631e28,0xa4506cebde82bde9 +.quad 0x90befffa23631e28,0xa4506cebde82bde9 +.quad 0xbef9a3f7b2c67915,0xc67178f2e372532b +.quad 0xbef9a3f7b2c67915,0xc67178f2e372532b +.quad 0xca273eceea26619c,0xd186b8c721c0c207 +.quad 0xca273eceea26619c,0xd186b8c721c0c207 +.quad 0xeada7dd6cde0eb1e,0xf57d4f7fee6ed178 +.quad 0xeada7dd6cde0eb1e,0xf57d4f7fee6ed178 +.quad 0x06f067aa72176fba,0x0a637dc5a2c898a6 +.quad 0x06f067aa72176fba,0x0a637dc5a2c898a6 +.quad 0x113f9804bef90dae,0x1b710b35131c471b +.quad 0x113f9804bef90dae,0x1b710b35131c471b +.quad 0x28db77f523047d84,0x32caab7b40c72493 +.quad 0x28db77f523047d84,0x32caab7b40c72493 +.quad 0x3c9ebe0a15c9bebc,0x431d67c49c100d4c +.quad 0x3c9ebe0a15c9bebc,0x431d67c49c100d4c +.quad 0x4cc5d4becb3e42b6,0x597f299cfc657e2a +.quad 0x4cc5d4becb3e42b6,0x597f299cfc657e2a +.quad 0x5fcb6fab3ad6faec,0x6c44198c4a475817 +.quad 0x5fcb6fab3ad6faec,0x6c44198c4a475817 + +.quad 0x0001020304050607,0x08090a0b0c0d0e0f +.quad 0x0001020304050607,0x08090a0b0c0d0e0f +.byte 83,72,65,53,49,50,32,98,108,111,99,107,32,116,114,97,110,115,102,111,114,109,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.text +.globl sha512_block_data_order_avx +.hidden sha512_block_data_order_avx +.type sha512_block_data_order_avx,@function +.align 64 +sha512_block_data_order_avx: +.cfi_startproc +_CET_ENDBR + movq %rsp,%rax +.cfi_def_cfa_register %rax + pushq %rbx +.cfi_offset %rbx,-16 + pushq %rbp +.cfi_offset %rbp,-24 + pushq %r12 +.cfi_offset %r12,-32 + pushq %r13 +.cfi_offset %r13,-40 + pushq %r14 +.cfi_offset %r14,-48 + pushq %r15 +.cfi_offset %r15,-56 + shlq $4,%rdx + subq $160,%rsp + leaq (%rsi,%rdx,8),%rdx + andq $-64,%rsp + movq %rdi,128+0(%rsp) + movq %rsi,128+8(%rsp) + movq %rdx,128+16(%rsp) + movq %rax,152(%rsp) +.cfi_escape 0x0f,0x06,0x77,0x98,0x01,0x06,0x23,0x08 +.Lprologue_avx: + + vzeroupper + movq 0(%rdi),%rax + movq 8(%rdi),%rbx + movq 16(%rdi),%rcx + movq 24(%rdi),%rdx + movq 32(%rdi),%r8 + movq 40(%rdi),%r9 + movq 48(%rdi),%r10 + movq 56(%rdi),%r11 + jmp .Lloop_avx +.align 16 +.Lloop_avx: + vmovdqa K512+1280(%rip),%xmm11 + vmovdqu 0(%rsi),%xmm0 + leaq K512+128(%rip),%rbp + vmovdqu 16(%rsi),%xmm1 + vmovdqu 32(%rsi),%xmm2 + vpshufb %xmm11,%xmm0,%xmm0 + vmovdqu 48(%rsi),%xmm3 + vpshufb %xmm11,%xmm1,%xmm1 + vmovdqu 64(%rsi),%xmm4 + vpshufb %xmm11,%xmm2,%xmm2 + vmovdqu 80(%rsi),%xmm5 + vpshufb %xmm11,%xmm3,%xmm3 + vmovdqu 96(%rsi),%xmm6 + vpshufb %xmm11,%xmm4,%xmm4 + vmovdqu 112(%rsi),%xmm7 + vpshufb %xmm11,%xmm5,%xmm5 + vpaddq -128(%rbp),%xmm0,%xmm8 + vpshufb %xmm11,%xmm6,%xmm6 + vpaddq -96(%rbp),%xmm1,%xmm9 + vpshufb %xmm11,%xmm7,%xmm7 + vpaddq -64(%rbp),%xmm2,%xmm10 + vpaddq -32(%rbp),%xmm3,%xmm11 + vmovdqa %xmm8,0(%rsp) + vpaddq 0(%rbp),%xmm4,%xmm8 + vmovdqa %xmm9,16(%rsp) + vpaddq 32(%rbp),%xmm5,%xmm9 + vmovdqa %xmm10,32(%rsp) + vpaddq 64(%rbp),%xmm6,%xmm10 + vmovdqa %xmm11,48(%rsp) + vpaddq 96(%rbp),%xmm7,%xmm11 + vmovdqa %xmm8,64(%rsp) + movq %rax,%r14 + vmovdqa %xmm9,80(%rsp) + movq %rbx,%rdi + vmovdqa %xmm10,96(%rsp) + xorq %rcx,%rdi + vmovdqa %xmm11,112(%rsp) + movq %r8,%r13 + jmp .Lavx_00_47 + +.align 16 +.Lavx_00_47: + addq $256,%rbp + vpalignr $8,%xmm0,%xmm1,%xmm8 + shrdq $23,%r13,%r13 + movq %r14,%rax + vpalignr $8,%xmm4,%xmm5,%xmm11 + movq %r9,%r12 + shrdq $5,%r14,%r14 + vpsrlq $1,%xmm8,%xmm10 + xorq %r8,%r13 + xorq %r10,%r12 + vpaddq %xmm11,%xmm0,%xmm0 + shrdq $4,%r13,%r13 + xorq %rax,%r14 + vpsrlq $7,%xmm8,%xmm11 + andq %r8,%r12 + xorq %r8,%r13 + vpsllq $56,%xmm8,%xmm9 + addq 0(%rsp),%r11 + movq %rax,%r15 + vpxor %xmm10,%xmm11,%xmm8 + xorq %r10,%r12 + shrdq $6,%r14,%r14 + vpsrlq $7,%xmm10,%xmm10 + xorq %rbx,%r15 + addq %r12,%r11 + vpxor %xmm9,%xmm8,%xmm8 + shrdq $14,%r13,%r13 + andq %r15,%rdi + vpsllq $7,%xmm9,%xmm9 + xorq %rax,%r14 + addq %r13,%r11 + vpxor %xmm10,%xmm8,%xmm8 + xorq %rbx,%rdi + shrdq $28,%r14,%r14 + vpsrlq $6,%xmm7,%xmm11 + addq %r11,%rdx + addq %rdi,%r11 + vpxor %xmm9,%xmm8,%xmm8 + movq %rdx,%r13 + addq %r11,%r14 + vpsllq $3,%xmm7,%xmm10 + shrdq $23,%r13,%r13 + movq %r14,%r11 + vpaddq %xmm8,%xmm0,%xmm0 + movq %r8,%r12 + shrdq $5,%r14,%r14 + vpsrlq $19,%xmm7,%xmm9 + xorq %rdx,%r13 + xorq %r9,%r12 + vpxor %xmm10,%xmm11,%xmm11 + shrdq $4,%r13,%r13 + xorq %r11,%r14 + vpsllq $42,%xmm10,%xmm10 + andq %rdx,%r12 + xorq %rdx,%r13 + vpxor %xmm9,%xmm11,%xmm11 + addq 8(%rsp),%r10 + movq %r11,%rdi + vpsrlq $42,%xmm9,%xmm9 + xorq %r9,%r12 + shrdq $6,%r14,%r14 + vpxor %xmm10,%xmm11,%xmm11 + xorq %rax,%rdi + addq %r12,%r10 + vpxor %xmm9,%xmm11,%xmm11 + shrdq $14,%r13,%r13 + andq %rdi,%r15 + vpaddq %xmm11,%xmm0,%xmm0 + xorq %r11,%r14 + addq %r13,%r10 + vpaddq -128(%rbp),%xmm0,%xmm10 + xorq %rax,%r15 + shrdq $28,%r14,%r14 + addq %r10,%rcx + addq %r15,%r10 + movq %rcx,%r13 + addq %r10,%r14 + vmovdqa %xmm10,0(%rsp) + vpalignr $8,%xmm1,%xmm2,%xmm8 + shrdq $23,%r13,%r13 + movq %r14,%r10 + vpalignr $8,%xmm5,%xmm6,%xmm11 + movq %rdx,%r12 + shrdq $5,%r14,%r14 + vpsrlq $1,%xmm8,%xmm10 + xorq %rcx,%r13 + xorq %r8,%r12 + vpaddq %xmm11,%xmm1,%xmm1 + shrdq $4,%r13,%r13 + xorq %r10,%r14 + vpsrlq $7,%xmm8,%xmm11 + andq %rcx,%r12 + xorq %rcx,%r13 + vpsllq $56,%xmm8,%xmm9 + addq 16(%rsp),%r9 + movq %r10,%r15 + vpxor %xmm10,%xmm11,%xmm8 + xorq %r8,%r12 + shrdq $6,%r14,%r14 + vpsrlq $7,%xmm10,%xmm10 + xorq %r11,%r15 + addq %r12,%r9 + vpxor %xmm9,%xmm8,%xmm8 + shrdq $14,%r13,%r13 + andq %r15,%rdi + vpsllq $7,%xmm9,%xmm9 + xorq %r10,%r14 + addq %r13,%r9 + vpxor %xmm10,%xmm8,%xmm8 + xorq %r11,%rdi + shrdq $28,%r14,%r14 + vpsrlq $6,%xmm0,%xmm11 + addq %r9,%rbx + addq %rdi,%r9 + vpxor %xmm9,%xmm8,%xmm8 + movq %rbx,%r13 + addq %r9,%r14 + vpsllq $3,%xmm0,%xmm10 + shrdq $23,%r13,%r13 + movq %r14,%r9 + vpaddq %xmm8,%xmm1,%xmm1 + movq %rcx,%r12 + shrdq $5,%r14,%r14 + vpsrlq $19,%xmm0,%xmm9 + xorq %rbx,%r13 + xorq %rdx,%r12 + vpxor %xmm10,%xmm11,%xmm11 + shrdq $4,%r13,%r13 + xorq %r9,%r14 + vpsllq $42,%xmm10,%xmm10 + andq %rbx,%r12 + xorq %rbx,%r13 + vpxor %xmm9,%xmm11,%xmm11 + addq 24(%rsp),%r8 + movq %r9,%rdi + vpsrlq $42,%xmm9,%xmm9 + xorq %rdx,%r12 + shrdq $6,%r14,%r14 + vpxor %xmm10,%xmm11,%xmm11 + xorq %r10,%rdi + addq %r12,%r8 + vpxor %xmm9,%xmm11,%xmm11 + shrdq $14,%r13,%r13 + andq %rdi,%r15 + vpaddq %xmm11,%xmm1,%xmm1 + xorq %r9,%r14 + addq %r13,%r8 + vpaddq -96(%rbp),%xmm1,%xmm10 + xorq %r10,%r15 + shrdq $28,%r14,%r14 + addq %r8,%rax + addq %r15,%r8 + movq %rax,%r13 + addq %r8,%r14 + vmovdqa %xmm10,16(%rsp) + vpalignr $8,%xmm2,%xmm3,%xmm8 + shrdq $23,%r13,%r13 + movq %r14,%r8 + vpalignr $8,%xmm6,%xmm7,%xmm11 + movq %rbx,%r12 + shrdq $5,%r14,%r14 + vpsrlq $1,%xmm8,%xmm10 + xorq %rax,%r13 + xorq %rcx,%r12 + vpaddq %xmm11,%xmm2,%xmm2 + shrdq $4,%r13,%r13 + xorq %r8,%r14 + vpsrlq $7,%xmm8,%xmm11 + andq %rax,%r12 + xorq %rax,%r13 + vpsllq $56,%xmm8,%xmm9 + addq 32(%rsp),%rdx + movq %r8,%r15 + vpxor %xmm10,%xmm11,%xmm8 + xorq %rcx,%r12 + shrdq $6,%r14,%r14 + vpsrlq $7,%xmm10,%xmm10 + xorq %r9,%r15 + addq %r12,%rdx + vpxor %xmm9,%xmm8,%xmm8 + shrdq $14,%r13,%r13 + andq %r15,%rdi + vpsllq $7,%xmm9,%xmm9 + xorq %r8,%r14 + addq %r13,%rdx + vpxor %xmm10,%xmm8,%xmm8 + xorq %r9,%rdi + shrdq $28,%r14,%r14 + vpsrlq $6,%xmm1,%xmm11 + addq %rdx,%r11 + addq %rdi,%rdx + vpxor %xmm9,%xmm8,%xmm8 + movq %r11,%r13 + addq %rdx,%r14 + vpsllq $3,%xmm1,%xmm10 + shrdq $23,%r13,%r13 + movq %r14,%rdx + vpaddq %xmm8,%xmm2,%xmm2 + movq %rax,%r12 + shrdq $5,%r14,%r14 + vpsrlq $19,%xmm1,%xmm9 + xorq %r11,%r13 + xorq %rbx,%r12 + vpxor %xmm10,%xmm11,%xmm11 + shrdq $4,%r13,%r13 + xorq %rdx,%r14 + vpsllq $42,%xmm10,%xmm10 + andq %r11,%r12 + xorq %r11,%r13 + vpxor %xmm9,%xmm11,%xmm11 + addq 40(%rsp),%rcx + movq %rdx,%rdi + vpsrlq $42,%xmm9,%xmm9 + xorq %rbx,%r12 + shrdq $6,%r14,%r14 + vpxor %xmm10,%xmm11,%xmm11 + xorq %r8,%rdi + addq %r12,%rcx + vpxor %xmm9,%xmm11,%xmm11 + shrdq $14,%r13,%r13 + andq %rdi,%r15 + vpaddq %xmm11,%xmm2,%xmm2 + xorq %rdx,%r14 + addq %r13,%rcx + vpaddq -64(%rbp),%xmm2,%xmm10 + xorq %r8,%r15 + shrdq $28,%r14,%r14 + addq %rcx,%r10 + addq %r15,%rcx + movq %r10,%r13 + addq %rcx,%r14 + vmovdqa %xmm10,32(%rsp) + vpalignr $8,%xmm3,%xmm4,%xmm8 + shrdq $23,%r13,%r13 + movq %r14,%rcx + vpalignr $8,%xmm7,%xmm0,%xmm11 + movq %r11,%r12 + shrdq $5,%r14,%r14 + vpsrlq $1,%xmm8,%xmm10 + xorq %r10,%r13 + xorq %rax,%r12 + vpaddq %xmm11,%xmm3,%xmm3 + shrdq $4,%r13,%r13 + xorq %rcx,%r14 + vpsrlq $7,%xmm8,%xmm11 + andq %r10,%r12 + xorq %r10,%r13 + vpsllq $56,%xmm8,%xmm9 + addq 48(%rsp),%rbx + movq %rcx,%r15 + vpxor %xmm10,%xmm11,%xmm8 + xorq %rax,%r12 + shrdq $6,%r14,%r14 + vpsrlq $7,%xmm10,%xmm10 + xorq %rdx,%r15 + addq %r12,%rbx + vpxor %xmm9,%xmm8,%xmm8 + shrdq $14,%r13,%r13 + andq %r15,%rdi + vpsllq $7,%xmm9,%xmm9 + xorq %rcx,%r14 + addq %r13,%rbx + vpxor %xmm10,%xmm8,%xmm8 + xorq %rdx,%rdi + shrdq $28,%r14,%r14 + vpsrlq $6,%xmm2,%xmm11 + addq %rbx,%r9 + addq %rdi,%rbx + vpxor %xmm9,%xmm8,%xmm8 + movq %r9,%r13 + addq %rbx,%r14 + vpsllq $3,%xmm2,%xmm10 + shrdq $23,%r13,%r13 + movq %r14,%rbx + vpaddq %xmm8,%xmm3,%xmm3 + movq %r10,%r12 + shrdq $5,%r14,%r14 + vpsrlq $19,%xmm2,%xmm9 + xorq %r9,%r13 + xorq %r11,%r12 + vpxor %xmm10,%xmm11,%xmm11 + shrdq $4,%r13,%r13 + xorq %rbx,%r14 + vpsllq $42,%xmm10,%xmm10 + andq %r9,%r12 + xorq %r9,%r13 + vpxor %xmm9,%xmm11,%xmm11 + addq 56(%rsp),%rax + movq %rbx,%rdi + vpsrlq $42,%xmm9,%xmm9 + xorq %r11,%r12 + shrdq $6,%r14,%r14 + vpxor %xmm10,%xmm11,%xmm11 + xorq %rcx,%rdi + addq %r12,%rax + vpxor %xmm9,%xmm11,%xmm11 + shrdq $14,%r13,%r13 + andq %rdi,%r15 + vpaddq %xmm11,%xmm3,%xmm3 + xorq %rbx,%r14 + addq %r13,%rax + vpaddq -32(%rbp),%xmm3,%xmm10 + xorq %rcx,%r15 + shrdq $28,%r14,%r14 + addq %rax,%r8 + addq %r15,%rax + movq %r8,%r13 + addq %rax,%r14 + vmovdqa %xmm10,48(%rsp) + vpalignr $8,%xmm4,%xmm5,%xmm8 + shrdq $23,%r13,%r13 + movq %r14,%rax + vpalignr $8,%xmm0,%xmm1,%xmm11 + movq %r9,%r12 + shrdq $5,%r14,%r14 + vpsrlq $1,%xmm8,%xmm10 + xorq %r8,%r13 + xorq %r10,%r12 + vpaddq %xmm11,%xmm4,%xmm4 + shrdq $4,%r13,%r13 + xorq %rax,%r14 + vpsrlq $7,%xmm8,%xmm11 + andq %r8,%r12 + xorq %r8,%r13 + vpsllq $56,%xmm8,%xmm9 + addq 64(%rsp),%r11 + movq %rax,%r15 + vpxor %xmm10,%xmm11,%xmm8 + xorq %r10,%r12 + shrdq $6,%r14,%r14 + vpsrlq $7,%xmm10,%xmm10 + xorq %rbx,%r15 + addq %r12,%r11 + vpxor %xmm9,%xmm8,%xmm8 + shrdq $14,%r13,%r13 + andq %r15,%rdi + vpsllq $7,%xmm9,%xmm9 + xorq %rax,%r14 + addq %r13,%r11 + vpxor %xmm10,%xmm8,%xmm8 + xorq %rbx,%rdi + shrdq $28,%r14,%r14 + vpsrlq $6,%xmm3,%xmm11 + addq %r11,%rdx + addq %rdi,%r11 + vpxor %xmm9,%xmm8,%xmm8 + movq %rdx,%r13 + addq %r11,%r14 + vpsllq $3,%xmm3,%xmm10 + shrdq $23,%r13,%r13 + movq %r14,%r11 + vpaddq %xmm8,%xmm4,%xmm4 + movq %r8,%r12 + shrdq $5,%r14,%r14 + vpsrlq $19,%xmm3,%xmm9 + xorq %rdx,%r13 + xorq %r9,%r12 + vpxor %xmm10,%xmm11,%xmm11 + shrdq $4,%r13,%r13 + xorq %r11,%r14 + vpsllq $42,%xmm10,%xmm10 + andq %rdx,%r12 + xorq %rdx,%r13 + vpxor %xmm9,%xmm11,%xmm11 + addq 72(%rsp),%r10 + movq %r11,%rdi + vpsrlq $42,%xmm9,%xmm9 + xorq %r9,%r12 + shrdq $6,%r14,%r14 + vpxor %xmm10,%xmm11,%xmm11 + xorq %rax,%rdi + addq %r12,%r10 + vpxor %xmm9,%xmm11,%xmm11 + shrdq $14,%r13,%r13 + andq %rdi,%r15 + vpaddq %xmm11,%xmm4,%xmm4 + xorq %r11,%r14 + addq %r13,%r10 + vpaddq 0(%rbp),%xmm4,%xmm10 + xorq %rax,%r15 + shrdq $28,%r14,%r14 + addq %r10,%rcx + addq %r15,%r10 + movq %rcx,%r13 + addq %r10,%r14 + vmovdqa %xmm10,64(%rsp) + vpalignr $8,%xmm5,%xmm6,%xmm8 + shrdq $23,%r13,%r13 + movq %r14,%r10 + vpalignr $8,%xmm1,%xmm2,%xmm11 + movq %rdx,%r12 + shrdq $5,%r14,%r14 + vpsrlq $1,%xmm8,%xmm10 + xorq %rcx,%r13 + xorq %r8,%r12 + vpaddq %xmm11,%xmm5,%xmm5 + shrdq $4,%r13,%r13 + xorq %r10,%r14 + vpsrlq $7,%xmm8,%xmm11 + andq %rcx,%r12 + xorq %rcx,%r13 + vpsllq $56,%xmm8,%xmm9 + addq 80(%rsp),%r9 + movq %r10,%r15 + vpxor %xmm10,%xmm11,%xmm8 + xorq %r8,%r12 + shrdq $6,%r14,%r14 + vpsrlq $7,%xmm10,%xmm10 + xorq %r11,%r15 + addq %r12,%r9 + vpxor %xmm9,%xmm8,%xmm8 + shrdq $14,%r13,%r13 + andq %r15,%rdi + vpsllq $7,%xmm9,%xmm9 + xorq %r10,%r14 + addq %r13,%r9 + vpxor %xmm10,%xmm8,%xmm8 + xorq %r11,%rdi + shrdq $28,%r14,%r14 + vpsrlq $6,%xmm4,%xmm11 + addq %r9,%rbx + addq %rdi,%r9 + vpxor %xmm9,%xmm8,%xmm8 + movq %rbx,%r13 + addq %r9,%r14 + vpsllq $3,%xmm4,%xmm10 + shrdq $23,%r13,%r13 + movq %r14,%r9 + vpaddq %xmm8,%xmm5,%xmm5 + movq %rcx,%r12 + shrdq $5,%r14,%r14 + vpsrlq $19,%xmm4,%xmm9 + xorq %rbx,%r13 + xorq %rdx,%r12 + vpxor %xmm10,%xmm11,%xmm11 + shrdq $4,%r13,%r13 + xorq %r9,%r14 + vpsllq $42,%xmm10,%xmm10 + andq %rbx,%r12 + xorq %rbx,%r13 + vpxor %xmm9,%xmm11,%xmm11 + addq 88(%rsp),%r8 + movq %r9,%rdi + vpsrlq $42,%xmm9,%xmm9 + xorq %rdx,%r12 + shrdq $6,%r14,%r14 + vpxor %xmm10,%xmm11,%xmm11 + xorq %r10,%rdi + addq %r12,%r8 + vpxor %xmm9,%xmm11,%xmm11 + shrdq $14,%r13,%r13 + andq %rdi,%r15 + vpaddq %xmm11,%xmm5,%xmm5 + xorq %r9,%r14 + addq %r13,%r8 + vpaddq 32(%rbp),%xmm5,%xmm10 + xorq %r10,%r15 + shrdq $28,%r14,%r14 + addq %r8,%rax + addq %r15,%r8 + movq %rax,%r13 + addq %r8,%r14 + vmovdqa %xmm10,80(%rsp) + vpalignr $8,%xmm6,%xmm7,%xmm8 + shrdq $23,%r13,%r13 + movq %r14,%r8 + vpalignr $8,%xmm2,%xmm3,%xmm11 + movq %rbx,%r12 + shrdq $5,%r14,%r14 + vpsrlq $1,%xmm8,%xmm10 + xorq %rax,%r13 + xorq %rcx,%r12 + vpaddq %xmm11,%xmm6,%xmm6 + shrdq $4,%r13,%r13 + xorq %r8,%r14 + vpsrlq $7,%xmm8,%xmm11 + andq %rax,%r12 + xorq %rax,%r13 + vpsllq $56,%xmm8,%xmm9 + addq 96(%rsp),%rdx + movq %r8,%r15 + vpxor %xmm10,%xmm11,%xmm8 + xorq %rcx,%r12 + shrdq $6,%r14,%r14 + vpsrlq $7,%xmm10,%xmm10 + xorq %r9,%r15 + addq %r12,%rdx + vpxor %xmm9,%xmm8,%xmm8 + shrdq $14,%r13,%r13 + andq %r15,%rdi + vpsllq $7,%xmm9,%xmm9 + xorq %r8,%r14 + addq %r13,%rdx + vpxor %xmm10,%xmm8,%xmm8 + xorq %r9,%rdi + shrdq $28,%r14,%r14 + vpsrlq $6,%xmm5,%xmm11 + addq %rdx,%r11 + addq %rdi,%rdx + vpxor %xmm9,%xmm8,%xmm8 + movq %r11,%r13 + addq %rdx,%r14 + vpsllq $3,%xmm5,%xmm10 + shrdq $23,%r13,%r13 + movq %r14,%rdx + vpaddq %xmm8,%xmm6,%xmm6 + movq %rax,%r12 + shrdq $5,%r14,%r14 + vpsrlq $19,%xmm5,%xmm9 + xorq %r11,%r13 + xorq %rbx,%r12 + vpxor %xmm10,%xmm11,%xmm11 + shrdq $4,%r13,%r13 + xorq %rdx,%r14 + vpsllq $42,%xmm10,%xmm10 + andq %r11,%r12 + xorq %r11,%r13 + vpxor %xmm9,%xmm11,%xmm11 + addq 104(%rsp),%rcx + movq %rdx,%rdi + vpsrlq $42,%xmm9,%xmm9 + xorq %rbx,%r12 + shrdq $6,%r14,%r14 + vpxor %xmm10,%xmm11,%xmm11 + xorq %r8,%rdi + addq %r12,%rcx + vpxor %xmm9,%xmm11,%xmm11 + shrdq $14,%r13,%r13 + andq %rdi,%r15 + vpaddq %xmm11,%xmm6,%xmm6 + xorq %rdx,%r14 + addq %r13,%rcx + vpaddq 64(%rbp),%xmm6,%xmm10 + xorq %r8,%r15 + shrdq $28,%r14,%r14 + addq %rcx,%r10 + addq %r15,%rcx + movq %r10,%r13 + addq %rcx,%r14 + vmovdqa %xmm10,96(%rsp) + vpalignr $8,%xmm7,%xmm0,%xmm8 + shrdq $23,%r13,%r13 + movq %r14,%rcx + vpalignr $8,%xmm3,%xmm4,%xmm11 + movq %r11,%r12 + shrdq $5,%r14,%r14 + vpsrlq $1,%xmm8,%xmm10 + xorq %r10,%r13 + xorq %rax,%r12 + vpaddq %xmm11,%xmm7,%xmm7 + shrdq $4,%r13,%r13 + xorq %rcx,%r14 + vpsrlq $7,%xmm8,%xmm11 + andq %r10,%r12 + xorq %r10,%r13 + vpsllq $56,%xmm8,%xmm9 + addq 112(%rsp),%rbx + movq %rcx,%r15 + vpxor %xmm10,%xmm11,%xmm8 + xorq %rax,%r12 + shrdq $6,%r14,%r14 + vpsrlq $7,%xmm10,%xmm10 + xorq %rdx,%r15 + addq %r12,%rbx + vpxor %xmm9,%xmm8,%xmm8 + shrdq $14,%r13,%r13 + andq %r15,%rdi + vpsllq $7,%xmm9,%xmm9 + xorq %rcx,%r14 + addq %r13,%rbx + vpxor %xmm10,%xmm8,%xmm8 + xorq %rdx,%rdi + shrdq $28,%r14,%r14 + vpsrlq $6,%xmm6,%xmm11 + addq %rbx,%r9 + addq %rdi,%rbx + vpxor %xmm9,%xmm8,%xmm8 + movq %r9,%r13 + addq %rbx,%r14 + vpsllq $3,%xmm6,%xmm10 + shrdq $23,%r13,%r13 + movq %r14,%rbx + vpaddq %xmm8,%xmm7,%xmm7 + movq %r10,%r12 + shrdq $5,%r14,%r14 + vpsrlq $19,%xmm6,%xmm9 + xorq %r9,%r13 + xorq %r11,%r12 + vpxor %xmm10,%xmm11,%xmm11 + shrdq $4,%r13,%r13 + xorq %rbx,%r14 + vpsllq $42,%xmm10,%xmm10 + andq %r9,%r12 + xorq %r9,%r13 + vpxor %xmm9,%xmm11,%xmm11 + addq 120(%rsp),%rax + movq %rbx,%rdi + vpsrlq $42,%xmm9,%xmm9 + xorq %r11,%r12 + shrdq $6,%r14,%r14 + vpxor %xmm10,%xmm11,%xmm11 + xorq %rcx,%rdi + addq %r12,%rax + vpxor %xmm9,%xmm11,%xmm11 + shrdq $14,%r13,%r13 + andq %rdi,%r15 + vpaddq %xmm11,%xmm7,%xmm7 + xorq %rbx,%r14 + addq %r13,%rax + vpaddq 96(%rbp),%xmm7,%xmm10 + xorq %rcx,%r15 + shrdq $28,%r14,%r14 + addq %rax,%r8 + addq %r15,%rax + movq %r8,%r13 + addq %rax,%r14 + vmovdqa %xmm10,112(%rsp) + cmpb $0,135(%rbp) + jne .Lavx_00_47 + shrdq $23,%r13,%r13 + movq %r14,%rax + movq %r9,%r12 + shrdq $5,%r14,%r14 + xorq %r8,%r13 + xorq %r10,%r12 + shrdq $4,%r13,%r13 + xorq %rax,%r14 + andq %r8,%r12 + xorq %r8,%r13 + addq 0(%rsp),%r11 + movq %rax,%r15 + xorq %r10,%r12 + shrdq $6,%r14,%r14 + xorq %rbx,%r15 + addq %r12,%r11 + shrdq $14,%r13,%r13 + andq %r15,%rdi + xorq %rax,%r14 + addq %r13,%r11 + xorq %rbx,%rdi + shrdq $28,%r14,%r14 + addq %r11,%rdx + addq %rdi,%r11 + movq %rdx,%r13 + addq %r11,%r14 + shrdq $23,%r13,%r13 + movq %r14,%r11 + movq %r8,%r12 + shrdq $5,%r14,%r14 + xorq %rdx,%r13 + xorq %r9,%r12 + shrdq $4,%r13,%r13 + xorq %r11,%r14 + andq %rdx,%r12 + xorq %rdx,%r13 + addq 8(%rsp),%r10 + movq %r11,%rdi + xorq %r9,%r12 + shrdq $6,%r14,%r14 + xorq %rax,%rdi + addq %r12,%r10 + shrdq $14,%r13,%r13 + andq %rdi,%r15 + xorq %r11,%r14 + addq %r13,%r10 + xorq %rax,%r15 + shrdq $28,%r14,%r14 + addq %r10,%rcx + addq %r15,%r10 + movq %rcx,%r13 + addq %r10,%r14 + shrdq $23,%r13,%r13 + movq %r14,%r10 + movq %rdx,%r12 + shrdq $5,%r14,%r14 + xorq %rcx,%r13 + xorq %r8,%r12 + shrdq $4,%r13,%r13 + xorq %r10,%r14 + andq %rcx,%r12 + xorq %rcx,%r13 + addq 16(%rsp),%r9 + movq %r10,%r15 + xorq %r8,%r12 + shrdq $6,%r14,%r14 + xorq %r11,%r15 + addq %r12,%r9 + shrdq $14,%r13,%r13 + andq %r15,%rdi + xorq %r10,%r14 + addq %r13,%r9 + xorq %r11,%rdi + shrdq $28,%r14,%r14 + addq %r9,%rbx + addq %rdi,%r9 + movq %rbx,%r13 + addq %r9,%r14 + shrdq $23,%r13,%r13 + movq %r14,%r9 + movq %rcx,%r12 + shrdq $5,%r14,%r14 + xorq %rbx,%r13 + xorq %rdx,%r12 + shrdq $4,%r13,%r13 + xorq %r9,%r14 + andq %rbx,%r12 + xorq %rbx,%r13 + addq 24(%rsp),%r8 + movq %r9,%rdi + xorq %rdx,%r12 + shrdq $6,%r14,%r14 + xorq %r10,%rdi + addq %r12,%r8 + shrdq $14,%r13,%r13 + andq %rdi,%r15 + xorq %r9,%r14 + addq %r13,%r8 + xorq %r10,%r15 + shrdq $28,%r14,%r14 + addq %r8,%rax + addq %r15,%r8 + movq %rax,%r13 + addq %r8,%r14 + shrdq $23,%r13,%r13 + movq %r14,%r8 + movq %rbx,%r12 + shrdq $5,%r14,%r14 + xorq %rax,%r13 + xorq %rcx,%r12 + shrdq $4,%r13,%r13 + xorq %r8,%r14 + andq %rax,%r12 + xorq %rax,%r13 + addq 32(%rsp),%rdx + movq %r8,%r15 + xorq %rcx,%r12 + shrdq $6,%r14,%r14 + xorq %r9,%r15 + addq %r12,%rdx + shrdq $14,%r13,%r13 + andq %r15,%rdi + xorq %r8,%r14 + addq %r13,%rdx + xorq %r9,%rdi + shrdq $28,%r14,%r14 + addq %rdx,%r11 + addq %rdi,%rdx + movq %r11,%r13 + addq %rdx,%r14 + shrdq $23,%r13,%r13 + movq %r14,%rdx + movq %rax,%r12 + shrdq $5,%r14,%r14 + xorq %r11,%r13 + xorq %rbx,%r12 + shrdq $4,%r13,%r13 + xorq %rdx,%r14 + andq %r11,%r12 + xorq %r11,%r13 + addq 40(%rsp),%rcx + movq %rdx,%rdi + xorq %rbx,%r12 + shrdq $6,%r14,%r14 + xorq %r8,%rdi + addq %r12,%rcx + shrdq $14,%r13,%r13 + andq %rdi,%r15 + xorq %rdx,%r14 + addq %r13,%rcx + xorq %r8,%r15 + shrdq $28,%r14,%r14 + addq %rcx,%r10 + addq %r15,%rcx + movq %r10,%r13 + addq %rcx,%r14 + shrdq $23,%r13,%r13 + movq %r14,%rcx + movq %r11,%r12 + shrdq $5,%r14,%r14 + xorq %r10,%r13 + xorq %rax,%r12 + shrdq $4,%r13,%r13 + xorq %rcx,%r14 + andq %r10,%r12 + xorq %r10,%r13 + addq 48(%rsp),%rbx + movq %rcx,%r15 + xorq %rax,%r12 + shrdq $6,%r14,%r14 + xorq %rdx,%r15 + addq %r12,%rbx + shrdq $14,%r13,%r13 + andq %r15,%rdi + xorq %rcx,%r14 + addq %r13,%rbx + xorq %rdx,%rdi + shrdq $28,%r14,%r14 + addq %rbx,%r9 + addq %rdi,%rbx + movq %r9,%r13 + addq %rbx,%r14 + shrdq $23,%r13,%r13 + movq %r14,%rbx + movq %r10,%r12 + shrdq $5,%r14,%r14 + xorq %r9,%r13 + xorq %r11,%r12 + shrdq $4,%r13,%r13 + xorq %rbx,%r14 + andq %r9,%r12 + xorq %r9,%r13 + addq 56(%rsp),%rax + movq %rbx,%rdi + xorq %r11,%r12 + shrdq $6,%r14,%r14 + xorq %rcx,%rdi + addq %r12,%rax + shrdq $14,%r13,%r13 + andq %rdi,%r15 + xorq %rbx,%r14 + addq %r13,%rax + xorq %rcx,%r15 + shrdq $28,%r14,%r14 + addq %rax,%r8 + addq %r15,%rax + movq %r8,%r13 + addq %rax,%r14 + shrdq $23,%r13,%r13 + movq %r14,%rax + movq %r9,%r12 + shrdq $5,%r14,%r14 + xorq %r8,%r13 + xorq %r10,%r12 + shrdq $4,%r13,%r13 + xorq %rax,%r14 + andq %r8,%r12 + xorq %r8,%r13 + addq 64(%rsp),%r11 + movq %rax,%r15 + xorq %r10,%r12 + shrdq $6,%r14,%r14 + xorq %rbx,%r15 + addq %r12,%r11 + shrdq $14,%r13,%r13 + andq %r15,%rdi + xorq %rax,%r14 + addq %r13,%r11 + xorq %rbx,%rdi + shrdq $28,%r14,%r14 + addq %r11,%rdx + addq %rdi,%r11 + movq %rdx,%r13 + addq %r11,%r14 + shrdq $23,%r13,%r13 + movq %r14,%r11 + movq %r8,%r12 + shrdq $5,%r14,%r14 + xorq %rdx,%r13 + xorq %r9,%r12 + shrdq $4,%r13,%r13 + xorq %r11,%r14 + andq %rdx,%r12 + xorq %rdx,%r13 + addq 72(%rsp),%r10 + movq %r11,%rdi + xorq %r9,%r12 + shrdq $6,%r14,%r14 + xorq %rax,%rdi + addq %r12,%r10 + shrdq $14,%r13,%r13 + andq %rdi,%r15 + xorq %r11,%r14 + addq %r13,%r10 + xorq %rax,%r15 + shrdq $28,%r14,%r14 + addq %r10,%rcx + addq %r15,%r10 + movq %rcx,%r13 + addq %r10,%r14 + shrdq $23,%r13,%r13 + movq %r14,%r10 + movq %rdx,%r12 + shrdq $5,%r14,%r14 + xorq %rcx,%r13 + xorq %r8,%r12 + shrdq $4,%r13,%r13 + xorq %r10,%r14 + andq %rcx,%r12 + xorq %rcx,%r13 + addq 80(%rsp),%r9 + movq %r10,%r15 + xorq %r8,%r12 + shrdq $6,%r14,%r14 + xorq %r11,%r15 + addq %r12,%r9 + shrdq $14,%r13,%r13 + andq %r15,%rdi + xorq %r10,%r14 + addq %r13,%r9 + xorq %r11,%rdi + shrdq $28,%r14,%r14 + addq %r9,%rbx + addq %rdi,%r9 + movq %rbx,%r13 + addq %r9,%r14 + shrdq $23,%r13,%r13 + movq %r14,%r9 + movq %rcx,%r12 + shrdq $5,%r14,%r14 + xorq %rbx,%r13 + xorq %rdx,%r12 + shrdq $4,%r13,%r13 + xorq %r9,%r14 + andq %rbx,%r12 + xorq %rbx,%r13 + addq 88(%rsp),%r8 + movq %r9,%rdi + xorq %rdx,%r12 + shrdq $6,%r14,%r14 + xorq %r10,%rdi + addq %r12,%r8 + shrdq $14,%r13,%r13 + andq %rdi,%r15 + xorq %r9,%r14 + addq %r13,%r8 + xorq %r10,%r15 + shrdq $28,%r14,%r14 + addq %r8,%rax + addq %r15,%r8 + movq %rax,%r13 + addq %r8,%r14 + shrdq $23,%r13,%r13 + movq %r14,%r8 + movq %rbx,%r12 + shrdq $5,%r14,%r14 + xorq %rax,%r13 + xorq %rcx,%r12 + shrdq $4,%r13,%r13 + xorq %r8,%r14 + andq %rax,%r12 + xorq %rax,%r13 + addq 96(%rsp),%rdx + movq %r8,%r15 + xorq %rcx,%r12 + shrdq $6,%r14,%r14 + xorq %r9,%r15 + addq %r12,%rdx + shrdq $14,%r13,%r13 + andq %r15,%rdi + xorq %r8,%r14 + addq %r13,%rdx + xorq %r9,%rdi + shrdq $28,%r14,%r14 + addq %rdx,%r11 + addq %rdi,%rdx + movq %r11,%r13 + addq %rdx,%r14 + shrdq $23,%r13,%r13 + movq %r14,%rdx + movq %rax,%r12 + shrdq $5,%r14,%r14 + xorq %r11,%r13 + xorq %rbx,%r12 + shrdq $4,%r13,%r13 + xorq %rdx,%r14 + andq %r11,%r12 + xorq %r11,%r13 + addq 104(%rsp),%rcx + movq %rdx,%rdi + xorq %rbx,%r12 + shrdq $6,%r14,%r14 + xorq %r8,%rdi + addq %r12,%rcx + shrdq $14,%r13,%r13 + andq %rdi,%r15 + xorq %rdx,%r14 + addq %r13,%rcx + xorq %r8,%r15 + shrdq $28,%r14,%r14 + addq %rcx,%r10 + addq %r15,%rcx + movq %r10,%r13 + addq %rcx,%r14 + shrdq $23,%r13,%r13 + movq %r14,%rcx + movq %r11,%r12 + shrdq $5,%r14,%r14 + xorq %r10,%r13 + xorq %rax,%r12 + shrdq $4,%r13,%r13 + xorq %rcx,%r14 + andq %r10,%r12 + xorq %r10,%r13 + addq 112(%rsp),%rbx + movq %rcx,%r15 + xorq %rax,%r12 + shrdq $6,%r14,%r14 + xorq %rdx,%r15 + addq %r12,%rbx + shrdq $14,%r13,%r13 + andq %r15,%rdi + xorq %rcx,%r14 + addq %r13,%rbx + xorq %rdx,%rdi + shrdq $28,%r14,%r14 + addq %rbx,%r9 + addq %rdi,%rbx + movq %r9,%r13 + addq %rbx,%r14 + shrdq $23,%r13,%r13 + movq %r14,%rbx + movq %r10,%r12 + shrdq $5,%r14,%r14 + xorq %r9,%r13 + xorq %r11,%r12 + shrdq $4,%r13,%r13 + xorq %rbx,%r14 + andq %r9,%r12 + xorq %r9,%r13 + addq 120(%rsp),%rax + movq %rbx,%rdi + xorq %r11,%r12 + shrdq $6,%r14,%r14 + xorq %rcx,%rdi + addq %r12,%rax + shrdq $14,%r13,%r13 + andq %rdi,%r15 + xorq %rbx,%r14 + addq %r13,%rax + xorq %rcx,%r15 + shrdq $28,%r14,%r14 + addq %rax,%r8 + addq %r15,%rax + movq %r8,%r13 + addq %rax,%r14 + movq 128+0(%rsp),%rdi + movq %r14,%rax + + addq 0(%rdi),%rax + leaq 128(%rsi),%rsi + addq 8(%rdi),%rbx + addq 16(%rdi),%rcx + addq 24(%rdi),%rdx + addq 32(%rdi),%r8 + addq 40(%rdi),%r9 + addq 48(%rdi),%r10 + addq 56(%rdi),%r11 + + cmpq 128+16(%rsp),%rsi + + movq %rax,0(%rdi) + movq %rbx,8(%rdi) + movq %rcx,16(%rdi) + movq %rdx,24(%rdi) + movq %r8,32(%rdi) + movq %r9,40(%rdi) + movq %r10,48(%rdi) + movq %r11,56(%rdi) + jb .Lloop_avx + + movq 152(%rsp),%rsi +.cfi_def_cfa %rsi,8 + vzeroupper + movq -48(%rsi),%r15 +.cfi_restore %r15 + movq -40(%rsi),%r14 +.cfi_restore %r14 + movq -32(%rsi),%r13 +.cfi_restore %r13 + movq -24(%rsi),%r12 +.cfi_restore %r12 + movq -16(%rsi),%rbp +.cfi_restore %rbp + movq -8(%rsi),%rbx +.cfi_restore %rbx + leaq (%rsi),%rsp +.cfi_def_cfa_register %rsp +.Lepilogue_avx: + ret +.cfi_endproc +.size sha512_block_data_order_avx,.-sha512_block_data_order_avx +#endif diff --git a/http/vendor/ring/pregenerated/sha512-x86_64-macosx.S b/http/vendor/ring/pregenerated/sha512-x86_64-macosx.S new file mode 100644 index 0000000..f882ce0 --- /dev/null +++ b/http/vendor/ring/pregenerated/sha512-x86_64-macosx.S @@ -0,0 +1,2978 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__) +.text + +.globl _sha512_block_data_order_nohw +.private_extern _sha512_block_data_order_nohw + +.p2align 4 +_sha512_block_data_order_nohw: + +_CET_ENDBR + movq %rsp,%rax + + pushq %rbx + + pushq %rbp + + pushq %r12 + + pushq %r13 + + pushq %r14 + + pushq %r15 + + shlq $4,%rdx + subq $128+32,%rsp + leaq (%rsi,%rdx,8),%rdx + andq $-64,%rsp + movq %rdi,128+0(%rsp) + movq %rsi,128+8(%rsp) + movq %rdx,128+16(%rsp) + movq %rax,152(%rsp) + +L$prologue: + + movq 0(%rdi),%rax + movq 8(%rdi),%rbx + movq 16(%rdi),%rcx + movq 24(%rdi),%rdx + movq 32(%rdi),%r8 + movq 40(%rdi),%r9 + movq 48(%rdi),%r10 + movq 56(%rdi),%r11 + jmp L$loop + +.p2align 4 +L$loop: + movq %rbx,%rdi + leaq K512(%rip),%rbp + xorq %rcx,%rdi + movq 0(%rsi),%r12 + movq %r8,%r13 + movq %rax,%r14 + bswapq %r12 + rorq $23,%r13 + movq %r9,%r15 + + xorq %r8,%r13 + rorq $5,%r14 + xorq %r10,%r15 + + movq %r12,0(%rsp) + xorq %rax,%r14 + andq %r8,%r15 + + rorq $4,%r13 + addq %r11,%r12 + xorq %r10,%r15 + + rorq $6,%r14 + xorq %r8,%r13 + addq %r15,%r12 + + movq %rax,%r15 + addq (%rbp),%r12 + xorq %rax,%r14 + + xorq %rbx,%r15 + rorq $14,%r13 + movq %rbx,%r11 + + andq %r15,%rdi + rorq $28,%r14 + addq %r13,%r12 + + xorq %rdi,%r11 + addq %r12,%rdx + addq %r12,%r11 + + leaq 8(%rbp),%rbp + addq %r14,%r11 + movq 8(%rsi),%r12 + movq %rdx,%r13 + movq %r11,%r14 + bswapq %r12 + rorq $23,%r13 + movq %r8,%rdi + + xorq %rdx,%r13 + rorq $5,%r14 + xorq %r9,%rdi + + movq %r12,8(%rsp) + xorq %r11,%r14 + andq %rdx,%rdi + + rorq $4,%r13 + addq %r10,%r12 + xorq %r9,%rdi + + rorq $6,%r14 + xorq %rdx,%r13 + addq %rdi,%r12 + + movq %r11,%rdi + addq (%rbp),%r12 + xorq %r11,%r14 + + xorq %rax,%rdi + rorq $14,%r13 + movq %rax,%r10 + + andq %rdi,%r15 + rorq $28,%r14 + addq %r13,%r12 + + xorq %r15,%r10 + addq %r12,%rcx + addq %r12,%r10 + + leaq 24(%rbp),%rbp + addq %r14,%r10 + movq 16(%rsi),%r12 + movq %rcx,%r13 + movq %r10,%r14 + bswapq %r12 + rorq $23,%r13 + movq %rdx,%r15 + + xorq %rcx,%r13 + rorq $5,%r14 + xorq %r8,%r15 + + movq %r12,16(%rsp) + xorq %r10,%r14 + andq %rcx,%r15 + + rorq $4,%r13 + addq %r9,%r12 + xorq %r8,%r15 + + rorq $6,%r14 + xorq %rcx,%r13 + addq %r15,%r12 + + movq %r10,%r15 + addq (%rbp),%r12 + xorq %r10,%r14 + + xorq %r11,%r15 + rorq $14,%r13 + movq %r11,%r9 + + andq %r15,%rdi + rorq $28,%r14 + addq %r13,%r12 + + xorq %rdi,%r9 + addq %r12,%rbx + addq %r12,%r9 + + leaq 8(%rbp),%rbp + addq %r14,%r9 + movq 24(%rsi),%r12 + movq %rbx,%r13 + movq %r9,%r14 + bswapq %r12 + rorq $23,%r13 + movq %rcx,%rdi + + xorq %rbx,%r13 + rorq $5,%r14 + xorq %rdx,%rdi + + movq %r12,24(%rsp) + xorq %r9,%r14 + andq %rbx,%rdi + + rorq $4,%r13 + addq %r8,%r12 + xorq %rdx,%rdi + + rorq $6,%r14 + xorq %rbx,%r13 + addq %rdi,%r12 + + movq %r9,%rdi + addq (%rbp),%r12 + xorq %r9,%r14 + + xorq %r10,%rdi + rorq $14,%r13 + movq %r10,%r8 + + andq %rdi,%r15 + rorq $28,%r14 + addq %r13,%r12 + + xorq %r15,%r8 + addq %r12,%rax + addq %r12,%r8 + + leaq 24(%rbp),%rbp + addq %r14,%r8 + movq 32(%rsi),%r12 + movq %rax,%r13 + movq %r8,%r14 + bswapq %r12 + rorq $23,%r13 + movq %rbx,%r15 + + xorq %rax,%r13 + rorq $5,%r14 + xorq %rcx,%r15 + + movq %r12,32(%rsp) + xorq %r8,%r14 + andq %rax,%r15 + + rorq $4,%r13 + addq %rdx,%r12 + xorq %rcx,%r15 + + rorq $6,%r14 + xorq %rax,%r13 + addq %r15,%r12 + + movq %r8,%r15 + addq (%rbp),%r12 + xorq %r8,%r14 + + xorq %r9,%r15 + rorq $14,%r13 + movq %r9,%rdx + + andq %r15,%rdi + rorq $28,%r14 + addq %r13,%r12 + + xorq %rdi,%rdx + addq %r12,%r11 + addq %r12,%rdx + + leaq 8(%rbp),%rbp + addq %r14,%rdx + movq 40(%rsi),%r12 + movq %r11,%r13 + movq %rdx,%r14 + bswapq %r12 + rorq $23,%r13 + movq %rax,%rdi + + xorq %r11,%r13 + rorq $5,%r14 + xorq %rbx,%rdi + + movq %r12,40(%rsp) + xorq %rdx,%r14 + andq %r11,%rdi + + rorq $4,%r13 + addq %rcx,%r12 + xorq %rbx,%rdi + + rorq $6,%r14 + xorq %r11,%r13 + addq %rdi,%r12 + + movq %rdx,%rdi + addq (%rbp),%r12 + xorq %rdx,%r14 + + xorq %r8,%rdi + rorq $14,%r13 + movq %r8,%rcx + + andq %rdi,%r15 + rorq $28,%r14 + addq %r13,%r12 + + xorq %r15,%rcx + addq %r12,%r10 + addq %r12,%rcx + + leaq 24(%rbp),%rbp + addq %r14,%rcx + movq 48(%rsi),%r12 + movq %r10,%r13 + movq %rcx,%r14 + bswapq %r12 + rorq $23,%r13 + movq %r11,%r15 + + xorq %r10,%r13 + rorq $5,%r14 + xorq %rax,%r15 + + movq %r12,48(%rsp) + xorq %rcx,%r14 + andq %r10,%r15 + + rorq $4,%r13 + addq %rbx,%r12 + xorq %rax,%r15 + + rorq $6,%r14 + xorq %r10,%r13 + addq %r15,%r12 + + movq %rcx,%r15 + addq (%rbp),%r12 + xorq %rcx,%r14 + + xorq %rdx,%r15 + rorq $14,%r13 + movq %rdx,%rbx + + andq %r15,%rdi + rorq $28,%r14 + addq %r13,%r12 + + xorq %rdi,%rbx + addq %r12,%r9 + addq %r12,%rbx + + leaq 8(%rbp),%rbp + addq %r14,%rbx + movq 56(%rsi),%r12 + movq %r9,%r13 + movq %rbx,%r14 + bswapq %r12 + rorq $23,%r13 + movq %r10,%rdi + + xorq %r9,%r13 + rorq $5,%r14 + xorq %r11,%rdi + + movq %r12,56(%rsp) + xorq %rbx,%r14 + andq %r9,%rdi + + rorq $4,%r13 + addq %rax,%r12 + xorq %r11,%rdi + + rorq $6,%r14 + xorq %r9,%r13 + addq %rdi,%r12 + + movq %rbx,%rdi + addq (%rbp),%r12 + xorq %rbx,%r14 + + xorq %rcx,%rdi + rorq $14,%r13 + movq %rcx,%rax + + andq %rdi,%r15 + rorq $28,%r14 + addq %r13,%r12 + + xorq %r15,%rax + addq %r12,%r8 + addq %r12,%rax + + leaq 24(%rbp),%rbp + addq %r14,%rax + movq 64(%rsi),%r12 + movq %r8,%r13 + movq %rax,%r14 + bswapq %r12 + rorq $23,%r13 + movq %r9,%r15 + + xorq %r8,%r13 + rorq $5,%r14 + xorq %r10,%r15 + + movq %r12,64(%rsp) + xorq %rax,%r14 + andq %r8,%r15 + + rorq $4,%r13 + addq %r11,%r12 + xorq %r10,%r15 + + rorq $6,%r14 + xorq %r8,%r13 + addq %r15,%r12 + + movq %rax,%r15 + addq (%rbp),%r12 + xorq %rax,%r14 + + xorq %rbx,%r15 + rorq $14,%r13 + movq %rbx,%r11 + + andq %r15,%rdi + rorq $28,%r14 + addq %r13,%r12 + + xorq %rdi,%r11 + addq %r12,%rdx + addq %r12,%r11 + + leaq 8(%rbp),%rbp + addq %r14,%r11 + movq 72(%rsi),%r12 + movq %rdx,%r13 + movq %r11,%r14 + bswapq %r12 + rorq $23,%r13 + movq %r8,%rdi + + xorq %rdx,%r13 + rorq $5,%r14 + xorq %r9,%rdi + + movq %r12,72(%rsp) + xorq %r11,%r14 + andq %rdx,%rdi + + rorq $4,%r13 + addq %r10,%r12 + xorq %r9,%rdi + + rorq $6,%r14 + xorq %rdx,%r13 + addq %rdi,%r12 + + movq %r11,%rdi + addq (%rbp),%r12 + xorq %r11,%r14 + + xorq %rax,%rdi + rorq $14,%r13 + movq %rax,%r10 + + andq %rdi,%r15 + rorq $28,%r14 + addq %r13,%r12 + + xorq %r15,%r10 + addq %r12,%rcx + addq %r12,%r10 + + leaq 24(%rbp),%rbp + addq %r14,%r10 + movq 80(%rsi),%r12 + movq %rcx,%r13 + movq %r10,%r14 + bswapq %r12 + rorq $23,%r13 + movq %rdx,%r15 + + xorq %rcx,%r13 + rorq $5,%r14 + xorq %r8,%r15 + + movq %r12,80(%rsp) + xorq %r10,%r14 + andq %rcx,%r15 + + rorq $4,%r13 + addq %r9,%r12 + xorq %r8,%r15 + + rorq $6,%r14 + xorq %rcx,%r13 + addq %r15,%r12 + + movq %r10,%r15 + addq (%rbp),%r12 + xorq %r10,%r14 + + xorq %r11,%r15 + rorq $14,%r13 + movq %r11,%r9 + + andq %r15,%rdi + rorq $28,%r14 + addq %r13,%r12 + + xorq %rdi,%r9 + addq %r12,%rbx + addq %r12,%r9 + + leaq 8(%rbp),%rbp + addq %r14,%r9 + movq 88(%rsi),%r12 + movq %rbx,%r13 + movq %r9,%r14 + bswapq %r12 + rorq $23,%r13 + movq %rcx,%rdi + + xorq %rbx,%r13 + rorq $5,%r14 + xorq %rdx,%rdi + + movq %r12,88(%rsp) + xorq %r9,%r14 + andq %rbx,%rdi + + rorq $4,%r13 + addq %r8,%r12 + xorq %rdx,%rdi + + rorq $6,%r14 + xorq %rbx,%r13 + addq %rdi,%r12 + + movq %r9,%rdi + addq (%rbp),%r12 + xorq %r9,%r14 + + xorq %r10,%rdi + rorq $14,%r13 + movq %r10,%r8 + + andq %rdi,%r15 + rorq $28,%r14 + addq %r13,%r12 + + xorq %r15,%r8 + addq %r12,%rax + addq %r12,%r8 + + leaq 24(%rbp),%rbp + addq %r14,%r8 + movq 96(%rsi),%r12 + movq %rax,%r13 + movq %r8,%r14 + bswapq %r12 + rorq $23,%r13 + movq %rbx,%r15 + + xorq %rax,%r13 + rorq $5,%r14 + xorq %rcx,%r15 + + movq %r12,96(%rsp) + xorq %r8,%r14 + andq %rax,%r15 + + rorq $4,%r13 + addq %rdx,%r12 + xorq %rcx,%r15 + + rorq $6,%r14 + xorq %rax,%r13 + addq %r15,%r12 + + movq %r8,%r15 + addq (%rbp),%r12 + xorq %r8,%r14 + + xorq %r9,%r15 + rorq $14,%r13 + movq %r9,%rdx + + andq %r15,%rdi + rorq $28,%r14 + addq %r13,%r12 + + xorq %rdi,%rdx + addq %r12,%r11 + addq %r12,%rdx + + leaq 8(%rbp),%rbp + addq %r14,%rdx + movq 104(%rsi),%r12 + movq %r11,%r13 + movq %rdx,%r14 + bswapq %r12 + rorq $23,%r13 + movq %rax,%rdi + + xorq %r11,%r13 + rorq $5,%r14 + xorq %rbx,%rdi + + movq %r12,104(%rsp) + xorq %rdx,%r14 + andq %r11,%rdi + + rorq $4,%r13 + addq %rcx,%r12 + xorq %rbx,%rdi + + rorq $6,%r14 + xorq %r11,%r13 + addq %rdi,%r12 + + movq %rdx,%rdi + addq (%rbp),%r12 + xorq %rdx,%r14 + + xorq %r8,%rdi + rorq $14,%r13 + movq %r8,%rcx + + andq %rdi,%r15 + rorq $28,%r14 + addq %r13,%r12 + + xorq %r15,%rcx + addq %r12,%r10 + addq %r12,%rcx + + leaq 24(%rbp),%rbp + addq %r14,%rcx + movq 112(%rsi),%r12 + movq %r10,%r13 + movq %rcx,%r14 + bswapq %r12 + rorq $23,%r13 + movq %r11,%r15 + + xorq %r10,%r13 + rorq $5,%r14 + xorq %rax,%r15 + + movq %r12,112(%rsp) + xorq %rcx,%r14 + andq %r10,%r15 + + rorq $4,%r13 + addq %rbx,%r12 + xorq %rax,%r15 + + rorq $6,%r14 + xorq %r10,%r13 + addq %r15,%r12 + + movq %rcx,%r15 + addq (%rbp),%r12 + xorq %rcx,%r14 + + xorq %rdx,%r15 + rorq $14,%r13 + movq %rdx,%rbx + + andq %r15,%rdi + rorq $28,%r14 + addq %r13,%r12 + + xorq %rdi,%rbx + addq %r12,%r9 + addq %r12,%rbx + + leaq 8(%rbp),%rbp + addq %r14,%rbx + movq 120(%rsi),%r12 + movq %r9,%r13 + movq %rbx,%r14 + bswapq %r12 + rorq $23,%r13 + movq %r10,%rdi + + xorq %r9,%r13 + rorq $5,%r14 + xorq %r11,%rdi + + movq %r12,120(%rsp) + xorq %rbx,%r14 + andq %r9,%rdi + + rorq $4,%r13 + addq %rax,%r12 + xorq %r11,%rdi + + rorq $6,%r14 + xorq %r9,%r13 + addq %rdi,%r12 + + movq %rbx,%rdi + addq (%rbp),%r12 + xorq %rbx,%r14 + + xorq %rcx,%rdi + rorq $14,%r13 + movq %rcx,%rax + + andq %rdi,%r15 + rorq $28,%r14 + addq %r13,%r12 + + xorq %r15,%rax + addq %r12,%r8 + addq %r12,%rax + + leaq 24(%rbp),%rbp + jmp L$rounds_16_xx +.p2align 4 +L$rounds_16_xx: + movq 8(%rsp),%r13 + movq 112(%rsp),%r15 + + movq %r13,%r12 + rorq $7,%r13 + addq %r14,%rax + movq %r15,%r14 + rorq $42,%r15 + + xorq %r12,%r13 + shrq $7,%r12 + rorq $1,%r13 + xorq %r14,%r15 + shrq $6,%r14 + + rorq $19,%r15 + xorq %r13,%r12 + xorq %r14,%r15 + addq 72(%rsp),%r12 + + addq 0(%rsp),%r12 + movq %r8,%r13 + addq %r15,%r12 + movq %rax,%r14 + rorq $23,%r13 + movq %r9,%r15 + + xorq %r8,%r13 + rorq $5,%r14 + xorq %r10,%r15 + + movq %r12,0(%rsp) + xorq %rax,%r14 + andq %r8,%r15 + + rorq $4,%r13 + addq %r11,%r12 + xorq %r10,%r15 + + rorq $6,%r14 + xorq %r8,%r13 + addq %r15,%r12 + + movq %rax,%r15 + addq (%rbp),%r12 + xorq %rax,%r14 + + xorq %rbx,%r15 + rorq $14,%r13 + movq %rbx,%r11 + + andq %r15,%rdi + rorq $28,%r14 + addq %r13,%r12 + + xorq %rdi,%r11 + addq %r12,%rdx + addq %r12,%r11 + + leaq 8(%rbp),%rbp + movq 16(%rsp),%r13 + movq 120(%rsp),%rdi + + movq %r13,%r12 + rorq $7,%r13 + addq %r14,%r11 + movq %rdi,%r14 + rorq $42,%rdi + + xorq %r12,%r13 + shrq $7,%r12 + rorq $1,%r13 + xorq %r14,%rdi + shrq $6,%r14 + + rorq $19,%rdi + xorq %r13,%r12 + xorq %r14,%rdi + addq 80(%rsp),%r12 + + addq 8(%rsp),%r12 + movq %rdx,%r13 + addq %rdi,%r12 + movq %r11,%r14 + rorq $23,%r13 + movq %r8,%rdi + + xorq %rdx,%r13 + rorq $5,%r14 + xorq %r9,%rdi + + movq %r12,8(%rsp) + xorq %r11,%r14 + andq %rdx,%rdi + + rorq $4,%r13 + addq %r10,%r12 + xorq %r9,%rdi + + rorq $6,%r14 + xorq %rdx,%r13 + addq %rdi,%r12 + + movq %r11,%rdi + addq (%rbp),%r12 + xorq %r11,%r14 + + xorq %rax,%rdi + rorq $14,%r13 + movq %rax,%r10 + + andq %rdi,%r15 + rorq $28,%r14 + addq %r13,%r12 + + xorq %r15,%r10 + addq %r12,%rcx + addq %r12,%r10 + + leaq 24(%rbp),%rbp + movq 24(%rsp),%r13 + movq 0(%rsp),%r15 + + movq %r13,%r12 + rorq $7,%r13 + addq %r14,%r10 + movq %r15,%r14 + rorq $42,%r15 + + xorq %r12,%r13 + shrq $7,%r12 + rorq $1,%r13 + xorq %r14,%r15 + shrq $6,%r14 + + rorq $19,%r15 + xorq %r13,%r12 + xorq %r14,%r15 + addq 88(%rsp),%r12 + + addq 16(%rsp),%r12 + movq %rcx,%r13 + addq %r15,%r12 + movq %r10,%r14 + rorq $23,%r13 + movq %rdx,%r15 + + xorq %rcx,%r13 + rorq $5,%r14 + xorq %r8,%r15 + + movq %r12,16(%rsp) + xorq %r10,%r14 + andq %rcx,%r15 + + rorq $4,%r13 + addq %r9,%r12 + xorq %r8,%r15 + + rorq $6,%r14 + xorq %rcx,%r13 + addq %r15,%r12 + + movq %r10,%r15 + addq (%rbp),%r12 + xorq %r10,%r14 + + xorq %r11,%r15 + rorq $14,%r13 + movq %r11,%r9 + + andq %r15,%rdi + rorq $28,%r14 + addq %r13,%r12 + + xorq %rdi,%r9 + addq %r12,%rbx + addq %r12,%r9 + + leaq 8(%rbp),%rbp + movq 32(%rsp),%r13 + movq 8(%rsp),%rdi + + movq %r13,%r12 + rorq $7,%r13 + addq %r14,%r9 + movq %rdi,%r14 + rorq $42,%rdi + + xorq %r12,%r13 + shrq $7,%r12 + rorq $1,%r13 + xorq %r14,%rdi + shrq $6,%r14 + + rorq $19,%rdi + xorq %r13,%r12 + xorq %r14,%rdi + addq 96(%rsp),%r12 + + addq 24(%rsp),%r12 + movq %rbx,%r13 + addq %rdi,%r12 + movq %r9,%r14 + rorq $23,%r13 + movq %rcx,%rdi + + xorq %rbx,%r13 + rorq $5,%r14 + xorq %rdx,%rdi + + movq %r12,24(%rsp) + xorq %r9,%r14 + andq %rbx,%rdi + + rorq $4,%r13 + addq %r8,%r12 + xorq %rdx,%rdi + + rorq $6,%r14 + xorq %rbx,%r13 + addq %rdi,%r12 + + movq %r9,%rdi + addq (%rbp),%r12 + xorq %r9,%r14 + + xorq %r10,%rdi + rorq $14,%r13 + movq %r10,%r8 + + andq %rdi,%r15 + rorq $28,%r14 + addq %r13,%r12 + + xorq %r15,%r8 + addq %r12,%rax + addq %r12,%r8 + + leaq 24(%rbp),%rbp + movq 40(%rsp),%r13 + movq 16(%rsp),%r15 + + movq %r13,%r12 + rorq $7,%r13 + addq %r14,%r8 + movq %r15,%r14 + rorq $42,%r15 + + xorq %r12,%r13 + shrq $7,%r12 + rorq $1,%r13 + xorq %r14,%r15 + shrq $6,%r14 + + rorq $19,%r15 + xorq %r13,%r12 + xorq %r14,%r15 + addq 104(%rsp),%r12 + + addq 32(%rsp),%r12 + movq %rax,%r13 + addq %r15,%r12 + movq %r8,%r14 + rorq $23,%r13 + movq %rbx,%r15 + + xorq %rax,%r13 + rorq $5,%r14 + xorq %rcx,%r15 + + movq %r12,32(%rsp) + xorq %r8,%r14 + andq %rax,%r15 + + rorq $4,%r13 + addq %rdx,%r12 + xorq %rcx,%r15 + + rorq $6,%r14 + xorq %rax,%r13 + addq %r15,%r12 + + movq %r8,%r15 + addq (%rbp),%r12 + xorq %r8,%r14 + + xorq %r9,%r15 + rorq $14,%r13 + movq %r9,%rdx + + andq %r15,%rdi + rorq $28,%r14 + addq %r13,%r12 + + xorq %rdi,%rdx + addq %r12,%r11 + addq %r12,%rdx + + leaq 8(%rbp),%rbp + movq 48(%rsp),%r13 + movq 24(%rsp),%rdi + + movq %r13,%r12 + rorq $7,%r13 + addq %r14,%rdx + movq %rdi,%r14 + rorq $42,%rdi + + xorq %r12,%r13 + shrq $7,%r12 + rorq $1,%r13 + xorq %r14,%rdi + shrq $6,%r14 + + rorq $19,%rdi + xorq %r13,%r12 + xorq %r14,%rdi + addq 112(%rsp),%r12 + + addq 40(%rsp),%r12 + movq %r11,%r13 + addq %rdi,%r12 + movq %rdx,%r14 + rorq $23,%r13 + movq %rax,%rdi + + xorq %r11,%r13 + rorq $5,%r14 + xorq %rbx,%rdi + + movq %r12,40(%rsp) + xorq %rdx,%r14 + andq %r11,%rdi + + rorq $4,%r13 + addq %rcx,%r12 + xorq %rbx,%rdi + + rorq $6,%r14 + xorq %r11,%r13 + addq %rdi,%r12 + + movq %rdx,%rdi + addq (%rbp),%r12 + xorq %rdx,%r14 + + xorq %r8,%rdi + rorq $14,%r13 + movq %r8,%rcx + + andq %rdi,%r15 + rorq $28,%r14 + addq %r13,%r12 + + xorq %r15,%rcx + addq %r12,%r10 + addq %r12,%rcx + + leaq 24(%rbp),%rbp + movq 56(%rsp),%r13 + movq 32(%rsp),%r15 + + movq %r13,%r12 + rorq $7,%r13 + addq %r14,%rcx + movq %r15,%r14 + rorq $42,%r15 + + xorq %r12,%r13 + shrq $7,%r12 + rorq $1,%r13 + xorq %r14,%r15 + shrq $6,%r14 + + rorq $19,%r15 + xorq %r13,%r12 + xorq %r14,%r15 + addq 120(%rsp),%r12 + + addq 48(%rsp),%r12 + movq %r10,%r13 + addq %r15,%r12 + movq %rcx,%r14 + rorq $23,%r13 + movq %r11,%r15 + + xorq %r10,%r13 + rorq $5,%r14 + xorq %rax,%r15 + + movq %r12,48(%rsp) + xorq %rcx,%r14 + andq %r10,%r15 + + rorq $4,%r13 + addq %rbx,%r12 + xorq %rax,%r15 + + rorq $6,%r14 + xorq %r10,%r13 + addq %r15,%r12 + + movq %rcx,%r15 + addq (%rbp),%r12 + xorq %rcx,%r14 + + xorq %rdx,%r15 + rorq $14,%r13 + movq %rdx,%rbx + + andq %r15,%rdi + rorq $28,%r14 + addq %r13,%r12 + + xorq %rdi,%rbx + addq %r12,%r9 + addq %r12,%rbx + + leaq 8(%rbp),%rbp + movq 64(%rsp),%r13 + movq 40(%rsp),%rdi + + movq %r13,%r12 + rorq $7,%r13 + addq %r14,%rbx + movq %rdi,%r14 + rorq $42,%rdi + + xorq %r12,%r13 + shrq $7,%r12 + rorq $1,%r13 + xorq %r14,%rdi + shrq $6,%r14 + + rorq $19,%rdi + xorq %r13,%r12 + xorq %r14,%rdi + addq 0(%rsp),%r12 + + addq 56(%rsp),%r12 + movq %r9,%r13 + addq %rdi,%r12 + movq %rbx,%r14 + rorq $23,%r13 + movq %r10,%rdi + + xorq %r9,%r13 + rorq $5,%r14 + xorq %r11,%rdi + + movq %r12,56(%rsp) + xorq %rbx,%r14 + andq %r9,%rdi + + rorq $4,%r13 + addq %rax,%r12 + xorq %r11,%rdi + + rorq $6,%r14 + xorq %r9,%r13 + addq %rdi,%r12 + + movq %rbx,%rdi + addq (%rbp),%r12 + xorq %rbx,%r14 + + xorq %rcx,%rdi + rorq $14,%r13 + movq %rcx,%rax + + andq %rdi,%r15 + rorq $28,%r14 + addq %r13,%r12 + + xorq %r15,%rax + addq %r12,%r8 + addq %r12,%rax + + leaq 24(%rbp),%rbp + movq 72(%rsp),%r13 + movq 48(%rsp),%r15 + + movq %r13,%r12 + rorq $7,%r13 + addq %r14,%rax + movq %r15,%r14 + rorq $42,%r15 + + xorq %r12,%r13 + shrq $7,%r12 + rorq $1,%r13 + xorq %r14,%r15 + shrq $6,%r14 + + rorq $19,%r15 + xorq %r13,%r12 + xorq %r14,%r15 + addq 8(%rsp),%r12 + + addq 64(%rsp),%r12 + movq %r8,%r13 + addq %r15,%r12 + movq %rax,%r14 + rorq $23,%r13 + movq %r9,%r15 + + xorq %r8,%r13 + rorq $5,%r14 + xorq %r10,%r15 + + movq %r12,64(%rsp) + xorq %rax,%r14 + andq %r8,%r15 + + rorq $4,%r13 + addq %r11,%r12 + xorq %r10,%r15 + + rorq $6,%r14 + xorq %r8,%r13 + addq %r15,%r12 + + movq %rax,%r15 + addq (%rbp),%r12 + xorq %rax,%r14 + + xorq %rbx,%r15 + rorq $14,%r13 + movq %rbx,%r11 + + andq %r15,%rdi + rorq $28,%r14 + addq %r13,%r12 + + xorq %rdi,%r11 + addq %r12,%rdx + addq %r12,%r11 + + leaq 8(%rbp),%rbp + movq 80(%rsp),%r13 + movq 56(%rsp),%rdi + + movq %r13,%r12 + rorq $7,%r13 + addq %r14,%r11 + movq %rdi,%r14 + rorq $42,%rdi + + xorq %r12,%r13 + shrq $7,%r12 + rorq $1,%r13 + xorq %r14,%rdi + shrq $6,%r14 + + rorq $19,%rdi + xorq %r13,%r12 + xorq %r14,%rdi + addq 16(%rsp),%r12 + + addq 72(%rsp),%r12 + movq %rdx,%r13 + addq %rdi,%r12 + movq %r11,%r14 + rorq $23,%r13 + movq %r8,%rdi + + xorq %rdx,%r13 + rorq $5,%r14 + xorq %r9,%rdi + + movq %r12,72(%rsp) + xorq %r11,%r14 + andq %rdx,%rdi + + rorq $4,%r13 + addq %r10,%r12 + xorq %r9,%rdi + + rorq $6,%r14 + xorq %rdx,%r13 + addq %rdi,%r12 + + movq %r11,%rdi + addq (%rbp),%r12 + xorq %r11,%r14 + + xorq %rax,%rdi + rorq $14,%r13 + movq %rax,%r10 + + andq %rdi,%r15 + rorq $28,%r14 + addq %r13,%r12 + + xorq %r15,%r10 + addq %r12,%rcx + addq %r12,%r10 + + leaq 24(%rbp),%rbp + movq 88(%rsp),%r13 + movq 64(%rsp),%r15 + + movq %r13,%r12 + rorq $7,%r13 + addq %r14,%r10 + movq %r15,%r14 + rorq $42,%r15 + + xorq %r12,%r13 + shrq $7,%r12 + rorq $1,%r13 + xorq %r14,%r15 + shrq $6,%r14 + + rorq $19,%r15 + xorq %r13,%r12 + xorq %r14,%r15 + addq 24(%rsp),%r12 + + addq 80(%rsp),%r12 + movq %rcx,%r13 + addq %r15,%r12 + movq %r10,%r14 + rorq $23,%r13 + movq %rdx,%r15 + + xorq %rcx,%r13 + rorq $5,%r14 + xorq %r8,%r15 + + movq %r12,80(%rsp) + xorq %r10,%r14 + andq %rcx,%r15 + + rorq $4,%r13 + addq %r9,%r12 + xorq %r8,%r15 + + rorq $6,%r14 + xorq %rcx,%r13 + addq %r15,%r12 + + movq %r10,%r15 + addq (%rbp),%r12 + xorq %r10,%r14 + + xorq %r11,%r15 + rorq $14,%r13 + movq %r11,%r9 + + andq %r15,%rdi + rorq $28,%r14 + addq %r13,%r12 + + xorq %rdi,%r9 + addq %r12,%rbx + addq %r12,%r9 + + leaq 8(%rbp),%rbp + movq 96(%rsp),%r13 + movq 72(%rsp),%rdi + + movq %r13,%r12 + rorq $7,%r13 + addq %r14,%r9 + movq %rdi,%r14 + rorq $42,%rdi + + xorq %r12,%r13 + shrq $7,%r12 + rorq $1,%r13 + xorq %r14,%rdi + shrq $6,%r14 + + rorq $19,%rdi + xorq %r13,%r12 + xorq %r14,%rdi + addq 32(%rsp),%r12 + + addq 88(%rsp),%r12 + movq %rbx,%r13 + addq %rdi,%r12 + movq %r9,%r14 + rorq $23,%r13 + movq %rcx,%rdi + + xorq %rbx,%r13 + rorq $5,%r14 + xorq %rdx,%rdi + + movq %r12,88(%rsp) + xorq %r9,%r14 + andq %rbx,%rdi + + rorq $4,%r13 + addq %r8,%r12 + xorq %rdx,%rdi + + rorq $6,%r14 + xorq %rbx,%r13 + addq %rdi,%r12 + + movq %r9,%rdi + addq (%rbp),%r12 + xorq %r9,%r14 + + xorq %r10,%rdi + rorq $14,%r13 + movq %r10,%r8 + + andq %rdi,%r15 + rorq $28,%r14 + addq %r13,%r12 + + xorq %r15,%r8 + addq %r12,%rax + addq %r12,%r8 + + leaq 24(%rbp),%rbp + movq 104(%rsp),%r13 + movq 80(%rsp),%r15 + + movq %r13,%r12 + rorq $7,%r13 + addq %r14,%r8 + movq %r15,%r14 + rorq $42,%r15 + + xorq %r12,%r13 + shrq $7,%r12 + rorq $1,%r13 + xorq %r14,%r15 + shrq $6,%r14 + + rorq $19,%r15 + xorq %r13,%r12 + xorq %r14,%r15 + addq 40(%rsp),%r12 + + addq 96(%rsp),%r12 + movq %rax,%r13 + addq %r15,%r12 + movq %r8,%r14 + rorq $23,%r13 + movq %rbx,%r15 + + xorq %rax,%r13 + rorq $5,%r14 + xorq %rcx,%r15 + + movq %r12,96(%rsp) + xorq %r8,%r14 + andq %rax,%r15 + + rorq $4,%r13 + addq %rdx,%r12 + xorq %rcx,%r15 + + rorq $6,%r14 + xorq %rax,%r13 + addq %r15,%r12 + + movq %r8,%r15 + addq (%rbp),%r12 + xorq %r8,%r14 + + xorq %r9,%r15 + rorq $14,%r13 + movq %r9,%rdx + + andq %r15,%rdi + rorq $28,%r14 + addq %r13,%r12 + + xorq %rdi,%rdx + addq %r12,%r11 + addq %r12,%rdx + + leaq 8(%rbp),%rbp + movq 112(%rsp),%r13 + movq 88(%rsp),%rdi + + movq %r13,%r12 + rorq $7,%r13 + addq %r14,%rdx + movq %rdi,%r14 + rorq $42,%rdi + + xorq %r12,%r13 + shrq $7,%r12 + rorq $1,%r13 + xorq %r14,%rdi + shrq $6,%r14 + + rorq $19,%rdi + xorq %r13,%r12 + xorq %r14,%rdi + addq 48(%rsp),%r12 + + addq 104(%rsp),%r12 + movq %r11,%r13 + addq %rdi,%r12 + movq %rdx,%r14 + rorq $23,%r13 + movq %rax,%rdi + + xorq %r11,%r13 + rorq $5,%r14 + xorq %rbx,%rdi + + movq %r12,104(%rsp) + xorq %rdx,%r14 + andq %r11,%rdi + + rorq $4,%r13 + addq %rcx,%r12 + xorq %rbx,%rdi + + rorq $6,%r14 + xorq %r11,%r13 + addq %rdi,%r12 + + movq %rdx,%rdi + addq (%rbp),%r12 + xorq %rdx,%r14 + + xorq %r8,%rdi + rorq $14,%r13 + movq %r8,%rcx + + andq %rdi,%r15 + rorq $28,%r14 + addq %r13,%r12 + + xorq %r15,%rcx + addq %r12,%r10 + addq %r12,%rcx + + leaq 24(%rbp),%rbp + movq 120(%rsp),%r13 + movq 96(%rsp),%r15 + + movq %r13,%r12 + rorq $7,%r13 + addq %r14,%rcx + movq %r15,%r14 + rorq $42,%r15 + + xorq %r12,%r13 + shrq $7,%r12 + rorq $1,%r13 + xorq %r14,%r15 + shrq $6,%r14 + + rorq $19,%r15 + xorq %r13,%r12 + xorq %r14,%r15 + addq 56(%rsp),%r12 + + addq 112(%rsp),%r12 + movq %r10,%r13 + addq %r15,%r12 + movq %rcx,%r14 + rorq $23,%r13 + movq %r11,%r15 + + xorq %r10,%r13 + rorq $5,%r14 + xorq %rax,%r15 + + movq %r12,112(%rsp) + xorq %rcx,%r14 + andq %r10,%r15 + + rorq $4,%r13 + addq %rbx,%r12 + xorq %rax,%r15 + + rorq $6,%r14 + xorq %r10,%r13 + addq %r15,%r12 + + movq %rcx,%r15 + addq (%rbp),%r12 + xorq %rcx,%r14 + + xorq %rdx,%r15 + rorq $14,%r13 + movq %rdx,%rbx + + andq %r15,%rdi + rorq $28,%r14 + addq %r13,%r12 + + xorq %rdi,%rbx + addq %r12,%r9 + addq %r12,%rbx + + leaq 8(%rbp),%rbp + movq 0(%rsp),%r13 + movq 104(%rsp),%rdi + + movq %r13,%r12 + rorq $7,%r13 + addq %r14,%rbx + movq %rdi,%r14 + rorq $42,%rdi + + xorq %r12,%r13 + shrq $7,%r12 + rorq $1,%r13 + xorq %r14,%rdi + shrq $6,%r14 + + rorq $19,%rdi + xorq %r13,%r12 + xorq %r14,%rdi + addq 64(%rsp),%r12 + + addq 120(%rsp),%r12 + movq %r9,%r13 + addq %rdi,%r12 + movq %rbx,%r14 + rorq $23,%r13 + movq %r10,%rdi + + xorq %r9,%r13 + rorq $5,%r14 + xorq %r11,%rdi + + movq %r12,120(%rsp) + xorq %rbx,%r14 + andq %r9,%rdi + + rorq $4,%r13 + addq %rax,%r12 + xorq %r11,%rdi + + rorq $6,%r14 + xorq %r9,%r13 + addq %rdi,%r12 + + movq %rbx,%rdi + addq (%rbp),%r12 + xorq %rbx,%r14 + + xorq %rcx,%rdi + rorq $14,%r13 + movq %rcx,%rax + + andq %rdi,%r15 + rorq $28,%r14 + addq %r13,%r12 + + xorq %r15,%rax + addq %r12,%r8 + addq %r12,%rax + + leaq 24(%rbp),%rbp + cmpb $0,7(%rbp) + jnz L$rounds_16_xx + + movq 128+0(%rsp),%rdi + addq %r14,%rax + leaq 128(%rsi),%rsi + + addq 0(%rdi),%rax + addq 8(%rdi),%rbx + addq 16(%rdi),%rcx + addq 24(%rdi),%rdx + addq 32(%rdi),%r8 + addq 40(%rdi),%r9 + addq 48(%rdi),%r10 + addq 56(%rdi),%r11 + + cmpq 128+16(%rsp),%rsi + + movq %rax,0(%rdi) + movq %rbx,8(%rdi) + movq %rcx,16(%rdi) + movq %rdx,24(%rdi) + movq %r8,32(%rdi) + movq %r9,40(%rdi) + movq %r10,48(%rdi) + movq %r11,56(%rdi) + jb L$loop + + movq 152(%rsp),%rsi + + movq -48(%rsi),%r15 + + movq -40(%rsi),%r14 + + movq -32(%rsi),%r13 + + movq -24(%rsi),%r12 + + movq -16(%rsi),%rbp + + movq -8(%rsi),%rbx + + leaq (%rsi),%rsp + +L$epilogue: + ret + + +.section __DATA,__const +.p2align 6 + +K512: +.quad 0x428a2f98d728ae22,0x7137449123ef65cd +.quad 0x428a2f98d728ae22,0x7137449123ef65cd +.quad 0xb5c0fbcfec4d3b2f,0xe9b5dba58189dbbc +.quad 0xb5c0fbcfec4d3b2f,0xe9b5dba58189dbbc +.quad 0x3956c25bf348b538,0x59f111f1b605d019 +.quad 0x3956c25bf348b538,0x59f111f1b605d019 +.quad 0x923f82a4af194f9b,0xab1c5ed5da6d8118 +.quad 0x923f82a4af194f9b,0xab1c5ed5da6d8118 +.quad 0xd807aa98a3030242,0x12835b0145706fbe +.quad 0xd807aa98a3030242,0x12835b0145706fbe +.quad 0x243185be4ee4b28c,0x550c7dc3d5ffb4e2 +.quad 0x243185be4ee4b28c,0x550c7dc3d5ffb4e2 +.quad 0x72be5d74f27b896f,0x80deb1fe3b1696b1 +.quad 0x72be5d74f27b896f,0x80deb1fe3b1696b1 +.quad 0x9bdc06a725c71235,0xc19bf174cf692694 +.quad 0x9bdc06a725c71235,0xc19bf174cf692694 +.quad 0xe49b69c19ef14ad2,0xefbe4786384f25e3 +.quad 0xe49b69c19ef14ad2,0xefbe4786384f25e3 +.quad 0x0fc19dc68b8cd5b5,0x240ca1cc77ac9c65 +.quad 0x0fc19dc68b8cd5b5,0x240ca1cc77ac9c65 +.quad 0x2de92c6f592b0275,0x4a7484aa6ea6e483 +.quad 0x2de92c6f592b0275,0x4a7484aa6ea6e483 +.quad 0x5cb0a9dcbd41fbd4,0x76f988da831153b5 +.quad 0x5cb0a9dcbd41fbd4,0x76f988da831153b5 +.quad 0x983e5152ee66dfab,0xa831c66d2db43210 +.quad 0x983e5152ee66dfab,0xa831c66d2db43210 +.quad 0xb00327c898fb213f,0xbf597fc7beef0ee4 +.quad 0xb00327c898fb213f,0xbf597fc7beef0ee4 +.quad 0xc6e00bf33da88fc2,0xd5a79147930aa725 +.quad 0xc6e00bf33da88fc2,0xd5a79147930aa725 +.quad 0x06ca6351e003826f,0x142929670a0e6e70 +.quad 0x06ca6351e003826f,0x142929670a0e6e70 +.quad 0x27b70a8546d22ffc,0x2e1b21385c26c926 +.quad 0x27b70a8546d22ffc,0x2e1b21385c26c926 +.quad 0x4d2c6dfc5ac42aed,0x53380d139d95b3df +.quad 0x4d2c6dfc5ac42aed,0x53380d139d95b3df +.quad 0x650a73548baf63de,0x766a0abb3c77b2a8 +.quad 0x650a73548baf63de,0x766a0abb3c77b2a8 +.quad 0x81c2c92e47edaee6,0x92722c851482353b +.quad 0x81c2c92e47edaee6,0x92722c851482353b +.quad 0xa2bfe8a14cf10364,0xa81a664bbc423001 +.quad 0xa2bfe8a14cf10364,0xa81a664bbc423001 +.quad 0xc24b8b70d0f89791,0xc76c51a30654be30 +.quad 0xc24b8b70d0f89791,0xc76c51a30654be30 +.quad 0xd192e819d6ef5218,0xd69906245565a910 +.quad 0xd192e819d6ef5218,0xd69906245565a910 +.quad 0xf40e35855771202a,0x106aa07032bbd1b8 +.quad 0xf40e35855771202a,0x106aa07032bbd1b8 +.quad 0x19a4c116b8d2d0c8,0x1e376c085141ab53 +.quad 0x19a4c116b8d2d0c8,0x1e376c085141ab53 +.quad 0x2748774cdf8eeb99,0x34b0bcb5e19b48a8 +.quad 0x2748774cdf8eeb99,0x34b0bcb5e19b48a8 +.quad 0x391c0cb3c5c95a63,0x4ed8aa4ae3418acb +.quad 0x391c0cb3c5c95a63,0x4ed8aa4ae3418acb +.quad 0x5b9cca4f7763e373,0x682e6ff3d6b2b8a3 +.quad 0x5b9cca4f7763e373,0x682e6ff3d6b2b8a3 +.quad 0x748f82ee5defb2fc,0x78a5636f43172f60 +.quad 0x748f82ee5defb2fc,0x78a5636f43172f60 +.quad 0x84c87814a1f0ab72,0x8cc702081a6439ec +.quad 0x84c87814a1f0ab72,0x8cc702081a6439ec +.quad 0x90befffa23631e28,0xa4506cebde82bde9 +.quad 0x90befffa23631e28,0xa4506cebde82bde9 +.quad 0xbef9a3f7b2c67915,0xc67178f2e372532b +.quad 0xbef9a3f7b2c67915,0xc67178f2e372532b +.quad 0xca273eceea26619c,0xd186b8c721c0c207 +.quad 0xca273eceea26619c,0xd186b8c721c0c207 +.quad 0xeada7dd6cde0eb1e,0xf57d4f7fee6ed178 +.quad 0xeada7dd6cde0eb1e,0xf57d4f7fee6ed178 +.quad 0x06f067aa72176fba,0x0a637dc5a2c898a6 +.quad 0x06f067aa72176fba,0x0a637dc5a2c898a6 +.quad 0x113f9804bef90dae,0x1b710b35131c471b +.quad 0x113f9804bef90dae,0x1b710b35131c471b +.quad 0x28db77f523047d84,0x32caab7b40c72493 +.quad 0x28db77f523047d84,0x32caab7b40c72493 +.quad 0x3c9ebe0a15c9bebc,0x431d67c49c100d4c +.quad 0x3c9ebe0a15c9bebc,0x431d67c49c100d4c +.quad 0x4cc5d4becb3e42b6,0x597f299cfc657e2a +.quad 0x4cc5d4becb3e42b6,0x597f299cfc657e2a +.quad 0x5fcb6fab3ad6faec,0x6c44198c4a475817 +.quad 0x5fcb6fab3ad6faec,0x6c44198c4a475817 + +.quad 0x0001020304050607,0x08090a0b0c0d0e0f +.quad 0x0001020304050607,0x08090a0b0c0d0e0f +.byte 83,72,65,53,49,50,32,98,108,111,99,107,32,116,114,97,110,115,102,111,114,109,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.text +.globl _sha512_block_data_order_avx +.private_extern _sha512_block_data_order_avx + +.p2align 6 +_sha512_block_data_order_avx: + +_CET_ENDBR + movq %rsp,%rax + + pushq %rbx + + pushq %rbp + + pushq %r12 + + pushq %r13 + + pushq %r14 + + pushq %r15 + + shlq $4,%rdx + subq $160,%rsp + leaq (%rsi,%rdx,8),%rdx + andq $-64,%rsp + movq %rdi,128+0(%rsp) + movq %rsi,128+8(%rsp) + movq %rdx,128+16(%rsp) + movq %rax,152(%rsp) + +L$prologue_avx: + + vzeroupper + movq 0(%rdi),%rax + movq 8(%rdi),%rbx + movq 16(%rdi),%rcx + movq 24(%rdi),%rdx + movq 32(%rdi),%r8 + movq 40(%rdi),%r9 + movq 48(%rdi),%r10 + movq 56(%rdi),%r11 + jmp L$loop_avx +.p2align 4 +L$loop_avx: + vmovdqa K512+1280(%rip),%xmm11 + vmovdqu 0(%rsi),%xmm0 + leaq K512+128(%rip),%rbp + vmovdqu 16(%rsi),%xmm1 + vmovdqu 32(%rsi),%xmm2 + vpshufb %xmm11,%xmm0,%xmm0 + vmovdqu 48(%rsi),%xmm3 + vpshufb %xmm11,%xmm1,%xmm1 + vmovdqu 64(%rsi),%xmm4 + vpshufb %xmm11,%xmm2,%xmm2 + vmovdqu 80(%rsi),%xmm5 + vpshufb %xmm11,%xmm3,%xmm3 + vmovdqu 96(%rsi),%xmm6 + vpshufb %xmm11,%xmm4,%xmm4 + vmovdqu 112(%rsi),%xmm7 + vpshufb %xmm11,%xmm5,%xmm5 + vpaddq -128(%rbp),%xmm0,%xmm8 + vpshufb %xmm11,%xmm6,%xmm6 + vpaddq -96(%rbp),%xmm1,%xmm9 + vpshufb %xmm11,%xmm7,%xmm7 + vpaddq -64(%rbp),%xmm2,%xmm10 + vpaddq -32(%rbp),%xmm3,%xmm11 + vmovdqa %xmm8,0(%rsp) + vpaddq 0(%rbp),%xmm4,%xmm8 + vmovdqa %xmm9,16(%rsp) + vpaddq 32(%rbp),%xmm5,%xmm9 + vmovdqa %xmm10,32(%rsp) + vpaddq 64(%rbp),%xmm6,%xmm10 + vmovdqa %xmm11,48(%rsp) + vpaddq 96(%rbp),%xmm7,%xmm11 + vmovdqa %xmm8,64(%rsp) + movq %rax,%r14 + vmovdqa %xmm9,80(%rsp) + movq %rbx,%rdi + vmovdqa %xmm10,96(%rsp) + xorq %rcx,%rdi + vmovdqa %xmm11,112(%rsp) + movq %r8,%r13 + jmp L$avx_00_47 + +.p2align 4 +L$avx_00_47: + addq $256,%rbp + vpalignr $8,%xmm0,%xmm1,%xmm8 + shrdq $23,%r13,%r13 + movq %r14,%rax + vpalignr $8,%xmm4,%xmm5,%xmm11 + movq %r9,%r12 + shrdq $5,%r14,%r14 + vpsrlq $1,%xmm8,%xmm10 + xorq %r8,%r13 + xorq %r10,%r12 + vpaddq %xmm11,%xmm0,%xmm0 + shrdq $4,%r13,%r13 + xorq %rax,%r14 + vpsrlq $7,%xmm8,%xmm11 + andq %r8,%r12 + xorq %r8,%r13 + vpsllq $56,%xmm8,%xmm9 + addq 0(%rsp),%r11 + movq %rax,%r15 + vpxor %xmm10,%xmm11,%xmm8 + xorq %r10,%r12 + shrdq $6,%r14,%r14 + vpsrlq $7,%xmm10,%xmm10 + xorq %rbx,%r15 + addq %r12,%r11 + vpxor %xmm9,%xmm8,%xmm8 + shrdq $14,%r13,%r13 + andq %r15,%rdi + vpsllq $7,%xmm9,%xmm9 + xorq %rax,%r14 + addq %r13,%r11 + vpxor %xmm10,%xmm8,%xmm8 + xorq %rbx,%rdi + shrdq $28,%r14,%r14 + vpsrlq $6,%xmm7,%xmm11 + addq %r11,%rdx + addq %rdi,%r11 + vpxor %xmm9,%xmm8,%xmm8 + movq %rdx,%r13 + addq %r11,%r14 + vpsllq $3,%xmm7,%xmm10 + shrdq $23,%r13,%r13 + movq %r14,%r11 + vpaddq %xmm8,%xmm0,%xmm0 + movq %r8,%r12 + shrdq $5,%r14,%r14 + vpsrlq $19,%xmm7,%xmm9 + xorq %rdx,%r13 + xorq %r9,%r12 + vpxor %xmm10,%xmm11,%xmm11 + shrdq $4,%r13,%r13 + xorq %r11,%r14 + vpsllq $42,%xmm10,%xmm10 + andq %rdx,%r12 + xorq %rdx,%r13 + vpxor %xmm9,%xmm11,%xmm11 + addq 8(%rsp),%r10 + movq %r11,%rdi + vpsrlq $42,%xmm9,%xmm9 + xorq %r9,%r12 + shrdq $6,%r14,%r14 + vpxor %xmm10,%xmm11,%xmm11 + xorq %rax,%rdi + addq %r12,%r10 + vpxor %xmm9,%xmm11,%xmm11 + shrdq $14,%r13,%r13 + andq %rdi,%r15 + vpaddq %xmm11,%xmm0,%xmm0 + xorq %r11,%r14 + addq %r13,%r10 + vpaddq -128(%rbp),%xmm0,%xmm10 + xorq %rax,%r15 + shrdq $28,%r14,%r14 + addq %r10,%rcx + addq %r15,%r10 + movq %rcx,%r13 + addq %r10,%r14 + vmovdqa %xmm10,0(%rsp) + vpalignr $8,%xmm1,%xmm2,%xmm8 + shrdq $23,%r13,%r13 + movq %r14,%r10 + vpalignr $8,%xmm5,%xmm6,%xmm11 + movq %rdx,%r12 + shrdq $5,%r14,%r14 + vpsrlq $1,%xmm8,%xmm10 + xorq %rcx,%r13 + xorq %r8,%r12 + vpaddq %xmm11,%xmm1,%xmm1 + shrdq $4,%r13,%r13 + xorq %r10,%r14 + vpsrlq $7,%xmm8,%xmm11 + andq %rcx,%r12 + xorq %rcx,%r13 + vpsllq $56,%xmm8,%xmm9 + addq 16(%rsp),%r9 + movq %r10,%r15 + vpxor %xmm10,%xmm11,%xmm8 + xorq %r8,%r12 + shrdq $6,%r14,%r14 + vpsrlq $7,%xmm10,%xmm10 + xorq %r11,%r15 + addq %r12,%r9 + vpxor %xmm9,%xmm8,%xmm8 + shrdq $14,%r13,%r13 + andq %r15,%rdi + vpsllq $7,%xmm9,%xmm9 + xorq %r10,%r14 + addq %r13,%r9 + vpxor %xmm10,%xmm8,%xmm8 + xorq %r11,%rdi + shrdq $28,%r14,%r14 + vpsrlq $6,%xmm0,%xmm11 + addq %r9,%rbx + addq %rdi,%r9 + vpxor %xmm9,%xmm8,%xmm8 + movq %rbx,%r13 + addq %r9,%r14 + vpsllq $3,%xmm0,%xmm10 + shrdq $23,%r13,%r13 + movq %r14,%r9 + vpaddq %xmm8,%xmm1,%xmm1 + movq %rcx,%r12 + shrdq $5,%r14,%r14 + vpsrlq $19,%xmm0,%xmm9 + xorq %rbx,%r13 + xorq %rdx,%r12 + vpxor %xmm10,%xmm11,%xmm11 + shrdq $4,%r13,%r13 + xorq %r9,%r14 + vpsllq $42,%xmm10,%xmm10 + andq %rbx,%r12 + xorq %rbx,%r13 + vpxor %xmm9,%xmm11,%xmm11 + addq 24(%rsp),%r8 + movq %r9,%rdi + vpsrlq $42,%xmm9,%xmm9 + xorq %rdx,%r12 + shrdq $6,%r14,%r14 + vpxor %xmm10,%xmm11,%xmm11 + xorq %r10,%rdi + addq %r12,%r8 + vpxor %xmm9,%xmm11,%xmm11 + shrdq $14,%r13,%r13 + andq %rdi,%r15 + vpaddq %xmm11,%xmm1,%xmm1 + xorq %r9,%r14 + addq %r13,%r8 + vpaddq -96(%rbp),%xmm1,%xmm10 + xorq %r10,%r15 + shrdq $28,%r14,%r14 + addq %r8,%rax + addq %r15,%r8 + movq %rax,%r13 + addq %r8,%r14 + vmovdqa %xmm10,16(%rsp) + vpalignr $8,%xmm2,%xmm3,%xmm8 + shrdq $23,%r13,%r13 + movq %r14,%r8 + vpalignr $8,%xmm6,%xmm7,%xmm11 + movq %rbx,%r12 + shrdq $5,%r14,%r14 + vpsrlq $1,%xmm8,%xmm10 + xorq %rax,%r13 + xorq %rcx,%r12 + vpaddq %xmm11,%xmm2,%xmm2 + shrdq $4,%r13,%r13 + xorq %r8,%r14 + vpsrlq $7,%xmm8,%xmm11 + andq %rax,%r12 + xorq %rax,%r13 + vpsllq $56,%xmm8,%xmm9 + addq 32(%rsp),%rdx + movq %r8,%r15 + vpxor %xmm10,%xmm11,%xmm8 + xorq %rcx,%r12 + shrdq $6,%r14,%r14 + vpsrlq $7,%xmm10,%xmm10 + xorq %r9,%r15 + addq %r12,%rdx + vpxor %xmm9,%xmm8,%xmm8 + shrdq $14,%r13,%r13 + andq %r15,%rdi + vpsllq $7,%xmm9,%xmm9 + xorq %r8,%r14 + addq %r13,%rdx + vpxor %xmm10,%xmm8,%xmm8 + xorq %r9,%rdi + shrdq $28,%r14,%r14 + vpsrlq $6,%xmm1,%xmm11 + addq %rdx,%r11 + addq %rdi,%rdx + vpxor %xmm9,%xmm8,%xmm8 + movq %r11,%r13 + addq %rdx,%r14 + vpsllq $3,%xmm1,%xmm10 + shrdq $23,%r13,%r13 + movq %r14,%rdx + vpaddq %xmm8,%xmm2,%xmm2 + movq %rax,%r12 + shrdq $5,%r14,%r14 + vpsrlq $19,%xmm1,%xmm9 + xorq %r11,%r13 + xorq %rbx,%r12 + vpxor %xmm10,%xmm11,%xmm11 + shrdq $4,%r13,%r13 + xorq %rdx,%r14 + vpsllq $42,%xmm10,%xmm10 + andq %r11,%r12 + xorq %r11,%r13 + vpxor %xmm9,%xmm11,%xmm11 + addq 40(%rsp),%rcx + movq %rdx,%rdi + vpsrlq $42,%xmm9,%xmm9 + xorq %rbx,%r12 + shrdq $6,%r14,%r14 + vpxor %xmm10,%xmm11,%xmm11 + xorq %r8,%rdi + addq %r12,%rcx + vpxor %xmm9,%xmm11,%xmm11 + shrdq $14,%r13,%r13 + andq %rdi,%r15 + vpaddq %xmm11,%xmm2,%xmm2 + xorq %rdx,%r14 + addq %r13,%rcx + vpaddq -64(%rbp),%xmm2,%xmm10 + xorq %r8,%r15 + shrdq $28,%r14,%r14 + addq %rcx,%r10 + addq %r15,%rcx + movq %r10,%r13 + addq %rcx,%r14 + vmovdqa %xmm10,32(%rsp) + vpalignr $8,%xmm3,%xmm4,%xmm8 + shrdq $23,%r13,%r13 + movq %r14,%rcx + vpalignr $8,%xmm7,%xmm0,%xmm11 + movq %r11,%r12 + shrdq $5,%r14,%r14 + vpsrlq $1,%xmm8,%xmm10 + xorq %r10,%r13 + xorq %rax,%r12 + vpaddq %xmm11,%xmm3,%xmm3 + shrdq $4,%r13,%r13 + xorq %rcx,%r14 + vpsrlq $7,%xmm8,%xmm11 + andq %r10,%r12 + xorq %r10,%r13 + vpsllq $56,%xmm8,%xmm9 + addq 48(%rsp),%rbx + movq %rcx,%r15 + vpxor %xmm10,%xmm11,%xmm8 + xorq %rax,%r12 + shrdq $6,%r14,%r14 + vpsrlq $7,%xmm10,%xmm10 + xorq %rdx,%r15 + addq %r12,%rbx + vpxor %xmm9,%xmm8,%xmm8 + shrdq $14,%r13,%r13 + andq %r15,%rdi + vpsllq $7,%xmm9,%xmm9 + xorq %rcx,%r14 + addq %r13,%rbx + vpxor %xmm10,%xmm8,%xmm8 + xorq %rdx,%rdi + shrdq $28,%r14,%r14 + vpsrlq $6,%xmm2,%xmm11 + addq %rbx,%r9 + addq %rdi,%rbx + vpxor %xmm9,%xmm8,%xmm8 + movq %r9,%r13 + addq %rbx,%r14 + vpsllq $3,%xmm2,%xmm10 + shrdq $23,%r13,%r13 + movq %r14,%rbx + vpaddq %xmm8,%xmm3,%xmm3 + movq %r10,%r12 + shrdq $5,%r14,%r14 + vpsrlq $19,%xmm2,%xmm9 + xorq %r9,%r13 + xorq %r11,%r12 + vpxor %xmm10,%xmm11,%xmm11 + shrdq $4,%r13,%r13 + xorq %rbx,%r14 + vpsllq $42,%xmm10,%xmm10 + andq %r9,%r12 + xorq %r9,%r13 + vpxor %xmm9,%xmm11,%xmm11 + addq 56(%rsp),%rax + movq %rbx,%rdi + vpsrlq $42,%xmm9,%xmm9 + xorq %r11,%r12 + shrdq $6,%r14,%r14 + vpxor %xmm10,%xmm11,%xmm11 + xorq %rcx,%rdi + addq %r12,%rax + vpxor %xmm9,%xmm11,%xmm11 + shrdq $14,%r13,%r13 + andq %rdi,%r15 + vpaddq %xmm11,%xmm3,%xmm3 + xorq %rbx,%r14 + addq %r13,%rax + vpaddq -32(%rbp),%xmm3,%xmm10 + xorq %rcx,%r15 + shrdq $28,%r14,%r14 + addq %rax,%r8 + addq %r15,%rax + movq %r8,%r13 + addq %rax,%r14 + vmovdqa %xmm10,48(%rsp) + vpalignr $8,%xmm4,%xmm5,%xmm8 + shrdq $23,%r13,%r13 + movq %r14,%rax + vpalignr $8,%xmm0,%xmm1,%xmm11 + movq %r9,%r12 + shrdq $5,%r14,%r14 + vpsrlq $1,%xmm8,%xmm10 + xorq %r8,%r13 + xorq %r10,%r12 + vpaddq %xmm11,%xmm4,%xmm4 + shrdq $4,%r13,%r13 + xorq %rax,%r14 + vpsrlq $7,%xmm8,%xmm11 + andq %r8,%r12 + xorq %r8,%r13 + vpsllq $56,%xmm8,%xmm9 + addq 64(%rsp),%r11 + movq %rax,%r15 + vpxor %xmm10,%xmm11,%xmm8 + xorq %r10,%r12 + shrdq $6,%r14,%r14 + vpsrlq $7,%xmm10,%xmm10 + xorq %rbx,%r15 + addq %r12,%r11 + vpxor %xmm9,%xmm8,%xmm8 + shrdq $14,%r13,%r13 + andq %r15,%rdi + vpsllq $7,%xmm9,%xmm9 + xorq %rax,%r14 + addq %r13,%r11 + vpxor %xmm10,%xmm8,%xmm8 + xorq %rbx,%rdi + shrdq $28,%r14,%r14 + vpsrlq $6,%xmm3,%xmm11 + addq %r11,%rdx + addq %rdi,%r11 + vpxor %xmm9,%xmm8,%xmm8 + movq %rdx,%r13 + addq %r11,%r14 + vpsllq $3,%xmm3,%xmm10 + shrdq $23,%r13,%r13 + movq %r14,%r11 + vpaddq %xmm8,%xmm4,%xmm4 + movq %r8,%r12 + shrdq $5,%r14,%r14 + vpsrlq $19,%xmm3,%xmm9 + xorq %rdx,%r13 + xorq %r9,%r12 + vpxor %xmm10,%xmm11,%xmm11 + shrdq $4,%r13,%r13 + xorq %r11,%r14 + vpsllq $42,%xmm10,%xmm10 + andq %rdx,%r12 + xorq %rdx,%r13 + vpxor %xmm9,%xmm11,%xmm11 + addq 72(%rsp),%r10 + movq %r11,%rdi + vpsrlq $42,%xmm9,%xmm9 + xorq %r9,%r12 + shrdq $6,%r14,%r14 + vpxor %xmm10,%xmm11,%xmm11 + xorq %rax,%rdi + addq %r12,%r10 + vpxor %xmm9,%xmm11,%xmm11 + shrdq $14,%r13,%r13 + andq %rdi,%r15 + vpaddq %xmm11,%xmm4,%xmm4 + xorq %r11,%r14 + addq %r13,%r10 + vpaddq 0(%rbp),%xmm4,%xmm10 + xorq %rax,%r15 + shrdq $28,%r14,%r14 + addq %r10,%rcx + addq %r15,%r10 + movq %rcx,%r13 + addq %r10,%r14 + vmovdqa %xmm10,64(%rsp) + vpalignr $8,%xmm5,%xmm6,%xmm8 + shrdq $23,%r13,%r13 + movq %r14,%r10 + vpalignr $8,%xmm1,%xmm2,%xmm11 + movq %rdx,%r12 + shrdq $5,%r14,%r14 + vpsrlq $1,%xmm8,%xmm10 + xorq %rcx,%r13 + xorq %r8,%r12 + vpaddq %xmm11,%xmm5,%xmm5 + shrdq $4,%r13,%r13 + xorq %r10,%r14 + vpsrlq $7,%xmm8,%xmm11 + andq %rcx,%r12 + xorq %rcx,%r13 + vpsllq $56,%xmm8,%xmm9 + addq 80(%rsp),%r9 + movq %r10,%r15 + vpxor %xmm10,%xmm11,%xmm8 + xorq %r8,%r12 + shrdq $6,%r14,%r14 + vpsrlq $7,%xmm10,%xmm10 + xorq %r11,%r15 + addq %r12,%r9 + vpxor %xmm9,%xmm8,%xmm8 + shrdq $14,%r13,%r13 + andq %r15,%rdi + vpsllq $7,%xmm9,%xmm9 + xorq %r10,%r14 + addq %r13,%r9 + vpxor %xmm10,%xmm8,%xmm8 + xorq %r11,%rdi + shrdq $28,%r14,%r14 + vpsrlq $6,%xmm4,%xmm11 + addq %r9,%rbx + addq %rdi,%r9 + vpxor %xmm9,%xmm8,%xmm8 + movq %rbx,%r13 + addq %r9,%r14 + vpsllq $3,%xmm4,%xmm10 + shrdq $23,%r13,%r13 + movq %r14,%r9 + vpaddq %xmm8,%xmm5,%xmm5 + movq %rcx,%r12 + shrdq $5,%r14,%r14 + vpsrlq $19,%xmm4,%xmm9 + xorq %rbx,%r13 + xorq %rdx,%r12 + vpxor %xmm10,%xmm11,%xmm11 + shrdq $4,%r13,%r13 + xorq %r9,%r14 + vpsllq $42,%xmm10,%xmm10 + andq %rbx,%r12 + xorq %rbx,%r13 + vpxor %xmm9,%xmm11,%xmm11 + addq 88(%rsp),%r8 + movq %r9,%rdi + vpsrlq $42,%xmm9,%xmm9 + xorq %rdx,%r12 + shrdq $6,%r14,%r14 + vpxor %xmm10,%xmm11,%xmm11 + xorq %r10,%rdi + addq %r12,%r8 + vpxor %xmm9,%xmm11,%xmm11 + shrdq $14,%r13,%r13 + andq %rdi,%r15 + vpaddq %xmm11,%xmm5,%xmm5 + xorq %r9,%r14 + addq %r13,%r8 + vpaddq 32(%rbp),%xmm5,%xmm10 + xorq %r10,%r15 + shrdq $28,%r14,%r14 + addq %r8,%rax + addq %r15,%r8 + movq %rax,%r13 + addq %r8,%r14 + vmovdqa %xmm10,80(%rsp) + vpalignr $8,%xmm6,%xmm7,%xmm8 + shrdq $23,%r13,%r13 + movq %r14,%r8 + vpalignr $8,%xmm2,%xmm3,%xmm11 + movq %rbx,%r12 + shrdq $5,%r14,%r14 + vpsrlq $1,%xmm8,%xmm10 + xorq %rax,%r13 + xorq %rcx,%r12 + vpaddq %xmm11,%xmm6,%xmm6 + shrdq $4,%r13,%r13 + xorq %r8,%r14 + vpsrlq $7,%xmm8,%xmm11 + andq %rax,%r12 + xorq %rax,%r13 + vpsllq $56,%xmm8,%xmm9 + addq 96(%rsp),%rdx + movq %r8,%r15 + vpxor %xmm10,%xmm11,%xmm8 + xorq %rcx,%r12 + shrdq $6,%r14,%r14 + vpsrlq $7,%xmm10,%xmm10 + xorq %r9,%r15 + addq %r12,%rdx + vpxor %xmm9,%xmm8,%xmm8 + shrdq $14,%r13,%r13 + andq %r15,%rdi + vpsllq $7,%xmm9,%xmm9 + xorq %r8,%r14 + addq %r13,%rdx + vpxor %xmm10,%xmm8,%xmm8 + xorq %r9,%rdi + shrdq $28,%r14,%r14 + vpsrlq $6,%xmm5,%xmm11 + addq %rdx,%r11 + addq %rdi,%rdx + vpxor %xmm9,%xmm8,%xmm8 + movq %r11,%r13 + addq %rdx,%r14 + vpsllq $3,%xmm5,%xmm10 + shrdq $23,%r13,%r13 + movq %r14,%rdx + vpaddq %xmm8,%xmm6,%xmm6 + movq %rax,%r12 + shrdq $5,%r14,%r14 + vpsrlq $19,%xmm5,%xmm9 + xorq %r11,%r13 + xorq %rbx,%r12 + vpxor %xmm10,%xmm11,%xmm11 + shrdq $4,%r13,%r13 + xorq %rdx,%r14 + vpsllq $42,%xmm10,%xmm10 + andq %r11,%r12 + xorq %r11,%r13 + vpxor %xmm9,%xmm11,%xmm11 + addq 104(%rsp),%rcx + movq %rdx,%rdi + vpsrlq $42,%xmm9,%xmm9 + xorq %rbx,%r12 + shrdq $6,%r14,%r14 + vpxor %xmm10,%xmm11,%xmm11 + xorq %r8,%rdi + addq %r12,%rcx + vpxor %xmm9,%xmm11,%xmm11 + shrdq $14,%r13,%r13 + andq %rdi,%r15 + vpaddq %xmm11,%xmm6,%xmm6 + xorq %rdx,%r14 + addq %r13,%rcx + vpaddq 64(%rbp),%xmm6,%xmm10 + xorq %r8,%r15 + shrdq $28,%r14,%r14 + addq %rcx,%r10 + addq %r15,%rcx + movq %r10,%r13 + addq %rcx,%r14 + vmovdqa %xmm10,96(%rsp) + vpalignr $8,%xmm7,%xmm0,%xmm8 + shrdq $23,%r13,%r13 + movq %r14,%rcx + vpalignr $8,%xmm3,%xmm4,%xmm11 + movq %r11,%r12 + shrdq $5,%r14,%r14 + vpsrlq $1,%xmm8,%xmm10 + xorq %r10,%r13 + xorq %rax,%r12 + vpaddq %xmm11,%xmm7,%xmm7 + shrdq $4,%r13,%r13 + xorq %rcx,%r14 + vpsrlq $7,%xmm8,%xmm11 + andq %r10,%r12 + xorq %r10,%r13 + vpsllq $56,%xmm8,%xmm9 + addq 112(%rsp),%rbx + movq %rcx,%r15 + vpxor %xmm10,%xmm11,%xmm8 + xorq %rax,%r12 + shrdq $6,%r14,%r14 + vpsrlq $7,%xmm10,%xmm10 + xorq %rdx,%r15 + addq %r12,%rbx + vpxor %xmm9,%xmm8,%xmm8 + shrdq $14,%r13,%r13 + andq %r15,%rdi + vpsllq $7,%xmm9,%xmm9 + xorq %rcx,%r14 + addq %r13,%rbx + vpxor %xmm10,%xmm8,%xmm8 + xorq %rdx,%rdi + shrdq $28,%r14,%r14 + vpsrlq $6,%xmm6,%xmm11 + addq %rbx,%r9 + addq %rdi,%rbx + vpxor %xmm9,%xmm8,%xmm8 + movq %r9,%r13 + addq %rbx,%r14 + vpsllq $3,%xmm6,%xmm10 + shrdq $23,%r13,%r13 + movq %r14,%rbx + vpaddq %xmm8,%xmm7,%xmm7 + movq %r10,%r12 + shrdq $5,%r14,%r14 + vpsrlq $19,%xmm6,%xmm9 + xorq %r9,%r13 + xorq %r11,%r12 + vpxor %xmm10,%xmm11,%xmm11 + shrdq $4,%r13,%r13 + xorq %rbx,%r14 + vpsllq $42,%xmm10,%xmm10 + andq %r9,%r12 + xorq %r9,%r13 + vpxor %xmm9,%xmm11,%xmm11 + addq 120(%rsp),%rax + movq %rbx,%rdi + vpsrlq $42,%xmm9,%xmm9 + xorq %r11,%r12 + shrdq $6,%r14,%r14 + vpxor %xmm10,%xmm11,%xmm11 + xorq %rcx,%rdi + addq %r12,%rax + vpxor %xmm9,%xmm11,%xmm11 + shrdq $14,%r13,%r13 + andq %rdi,%r15 + vpaddq %xmm11,%xmm7,%xmm7 + xorq %rbx,%r14 + addq %r13,%rax + vpaddq 96(%rbp),%xmm7,%xmm10 + xorq %rcx,%r15 + shrdq $28,%r14,%r14 + addq %rax,%r8 + addq %r15,%rax + movq %r8,%r13 + addq %rax,%r14 + vmovdqa %xmm10,112(%rsp) + cmpb $0,135(%rbp) + jne L$avx_00_47 + shrdq $23,%r13,%r13 + movq %r14,%rax + movq %r9,%r12 + shrdq $5,%r14,%r14 + xorq %r8,%r13 + xorq %r10,%r12 + shrdq $4,%r13,%r13 + xorq %rax,%r14 + andq %r8,%r12 + xorq %r8,%r13 + addq 0(%rsp),%r11 + movq %rax,%r15 + xorq %r10,%r12 + shrdq $6,%r14,%r14 + xorq %rbx,%r15 + addq %r12,%r11 + shrdq $14,%r13,%r13 + andq %r15,%rdi + xorq %rax,%r14 + addq %r13,%r11 + xorq %rbx,%rdi + shrdq $28,%r14,%r14 + addq %r11,%rdx + addq %rdi,%r11 + movq %rdx,%r13 + addq %r11,%r14 + shrdq $23,%r13,%r13 + movq %r14,%r11 + movq %r8,%r12 + shrdq $5,%r14,%r14 + xorq %rdx,%r13 + xorq %r9,%r12 + shrdq $4,%r13,%r13 + xorq %r11,%r14 + andq %rdx,%r12 + xorq %rdx,%r13 + addq 8(%rsp),%r10 + movq %r11,%rdi + xorq %r9,%r12 + shrdq $6,%r14,%r14 + xorq %rax,%rdi + addq %r12,%r10 + shrdq $14,%r13,%r13 + andq %rdi,%r15 + xorq %r11,%r14 + addq %r13,%r10 + xorq %rax,%r15 + shrdq $28,%r14,%r14 + addq %r10,%rcx + addq %r15,%r10 + movq %rcx,%r13 + addq %r10,%r14 + shrdq $23,%r13,%r13 + movq %r14,%r10 + movq %rdx,%r12 + shrdq $5,%r14,%r14 + xorq %rcx,%r13 + xorq %r8,%r12 + shrdq $4,%r13,%r13 + xorq %r10,%r14 + andq %rcx,%r12 + xorq %rcx,%r13 + addq 16(%rsp),%r9 + movq %r10,%r15 + xorq %r8,%r12 + shrdq $6,%r14,%r14 + xorq %r11,%r15 + addq %r12,%r9 + shrdq $14,%r13,%r13 + andq %r15,%rdi + xorq %r10,%r14 + addq %r13,%r9 + xorq %r11,%rdi + shrdq $28,%r14,%r14 + addq %r9,%rbx + addq %rdi,%r9 + movq %rbx,%r13 + addq %r9,%r14 + shrdq $23,%r13,%r13 + movq %r14,%r9 + movq %rcx,%r12 + shrdq $5,%r14,%r14 + xorq %rbx,%r13 + xorq %rdx,%r12 + shrdq $4,%r13,%r13 + xorq %r9,%r14 + andq %rbx,%r12 + xorq %rbx,%r13 + addq 24(%rsp),%r8 + movq %r9,%rdi + xorq %rdx,%r12 + shrdq $6,%r14,%r14 + xorq %r10,%rdi + addq %r12,%r8 + shrdq $14,%r13,%r13 + andq %rdi,%r15 + xorq %r9,%r14 + addq %r13,%r8 + xorq %r10,%r15 + shrdq $28,%r14,%r14 + addq %r8,%rax + addq %r15,%r8 + movq %rax,%r13 + addq %r8,%r14 + shrdq $23,%r13,%r13 + movq %r14,%r8 + movq %rbx,%r12 + shrdq $5,%r14,%r14 + xorq %rax,%r13 + xorq %rcx,%r12 + shrdq $4,%r13,%r13 + xorq %r8,%r14 + andq %rax,%r12 + xorq %rax,%r13 + addq 32(%rsp),%rdx + movq %r8,%r15 + xorq %rcx,%r12 + shrdq $6,%r14,%r14 + xorq %r9,%r15 + addq %r12,%rdx + shrdq $14,%r13,%r13 + andq %r15,%rdi + xorq %r8,%r14 + addq %r13,%rdx + xorq %r9,%rdi + shrdq $28,%r14,%r14 + addq %rdx,%r11 + addq %rdi,%rdx + movq %r11,%r13 + addq %rdx,%r14 + shrdq $23,%r13,%r13 + movq %r14,%rdx + movq %rax,%r12 + shrdq $5,%r14,%r14 + xorq %r11,%r13 + xorq %rbx,%r12 + shrdq $4,%r13,%r13 + xorq %rdx,%r14 + andq %r11,%r12 + xorq %r11,%r13 + addq 40(%rsp),%rcx + movq %rdx,%rdi + xorq %rbx,%r12 + shrdq $6,%r14,%r14 + xorq %r8,%rdi + addq %r12,%rcx + shrdq $14,%r13,%r13 + andq %rdi,%r15 + xorq %rdx,%r14 + addq %r13,%rcx + xorq %r8,%r15 + shrdq $28,%r14,%r14 + addq %rcx,%r10 + addq %r15,%rcx + movq %r10,%r13 + addq %rcx,%r14 + shrdq $23,%r13,%r13 + movq %r14,%rcx + movq %r11,%r12 + shrdq $5,%r14,%r14 + xorq %r10,%r13 + xorq %rax,%r12 + shrdq $4,%r13,%r13 + xorq %rcx,%r14 + andq %r10,%r12 + xorq %r10,%r13 + addq 48(%rsp),%rbx + movq %rcx,%r15 + xorq %rax,%r12 + shrdq $6,%r14,%r14 + xorq %rdx,%r15 + addq %r12,%rbx + shrdq $14,%r13,%r13 + andq %r15,%rdi + xorq %rcx,%r14 + addq %r13,%rbx + xorq %rdx,%rdi + shrdq $28,%r14,%r14 + addq %rbx,%r9 + addq %rdi,%rbx + movq %r9,%r13 + addq %rbx,%r14 + shrdq $23,%r13,%r13 + movq %r14,%rbx + movq %r10,%r12 + shrdq $5,%r14,%r14 + xorq %r9,%r13 + xorq %r11,%r12 + shrdq $4,%r13,%r13 + xorq %rbx,%r14 + andq %r9,%r12 + xorq %r9,%r13 + addq 56(%rsp),%rax + movq %rbx,%rdi + xorq %r11,%r12 + shrdq $6,%r14,%r14 + xorq %rcx,%rdi + addq %r12,%rax + shrdq $14,%r13,%r13 + andq %rdi,%r15 + xorq %rbx,%r14 + addq %r13,%rax + xorq %rcx,%r15 + shrdq $28,%r14,%r14 + addq %rax,%r8 + addq %r15,%rax + movq %r8,%r13 + addq %rax,%r14 + shrdq $23,%r13,%r13 + movq %r14,%rax + movq %r9,%r12 + shrdq $5,%r14,%r14 + xorq %r8,%r13 + xorq %r10,%r12 + shrdq $4,%r13,%r13 + xorq %rax,%r14 + andq %r8,%r12 + xorq %r8,%r13 + addq 64(%rsp),%r11 + movq %rax,%r15 + xorq %r10,%r12 + shrdq $6,%r14,%r14 + xorq %rbx,%r15 + addq %r12,%r11 + shrdq $14,%r13,%r13 + andq %r15,%rdi + xorq %rax,%r14 + addq %r13,%r11 + xorq %rbx,%rdi + shrdq $28,%r14,%r14 + addq %r11,%rdx + addq %rdi,%r11 + movq %rdx,%r13 + addq %r11,%r14 + shrdq $23,%r13,%r13 + movq %r14,%r11 + movq %r8,%r12 + shrdq $5,%r14,%r14 + xorq %rdx,%r13 + xorq %r9,%r12 + shrdq $4,%r13,%r13 + xorq %r11,%r14 + andq %rdx,%r12 + xorq %rdx,%r13 + addq 72(%rsp),%r10 + movq %r11,%rdi + xorq %r9,%r12 + shrdq $6,%r14,%r14 + xorq %rax,%rdi + addq %r12,%r10 + shrdq $14,%r13,%r13 + andq %rdi,%r15 + xorq %r11,%r14 + addq %r13,%r10 + xorq %rax,%r15 + shrdq $28,%r14,%r14 + addq %r10,%rcx + addq %r15,%r10 + movq %rcx,%r13 + addq %r10,%r14 + shrdq $23,%r13,%r13 + movq %r14,%r10 + movq %rdx,%r12 + shrdq $5,%r14,%r14 + xorq %rcx,%r13 + xorq %r8,%r12 + shrdq $4,%r13,%r13 + xorq %r10,%r14 + andq %rcx,%r12 + xorq %rcx,%r13 + addq 80(%rsp),%r9 + movq %r10,%r15 + xorq %r8,%r12 + shrdq $6,%r14,%r14 + xorq %r11,%r15 + addq %r12,%r9 + shrdq $14,%r13,%r13 + andq %r15,%rdi + xorq %r10,%r14 + addq %r13,%r9 + xorq %r11,%rdi + shrdq $28,%r14,%r14 + addq %r9,%rbx + addq %rdi,%r9 + movq %rbx,%r13 + addq %r9,%r14 + shrdq $23,%r13,%r13 + movq %r14,%r9 + movq %rcx,%r12 + shrdq $5,%r14,%r14 + xorq %rbx,%r13 + xorq %rdx,%r12 + shrdq $4,%r13,%r13 + xorq %r9,%r14 + andq %rbx,%r12 + xorq %rbx,%r13 + addq 88(%rsp),%r8 + movq %r9,%rdi + xorq %rdx,%r12 + shrdq $6,%r14,%r14 + xorq %r10,%rdi + addq %r12,%r8 + shrdq $14,%r13,%r13 + andq %rdi,%r15 + xorq %r9,%r14 + addq %r13,%r8 + xorq %r10,%r15 + shrdq $28,%r14,%r14 + addq %r8,%rax + addq %r15,%r8 + movq %rax,%r13 + addq %r8,%r14 + shrdq $23,%r13,%r13 + movq %r14,%r8 + movq %rbx,%r12 + shrdq $5,%r14,%r14 + xorq %rax,%r13 + xorq %rcx,%r12 + shrdq $4,%r13,%r13 + xorq %r8,%r14 + andq %rax,%r12 + xorq %rax,%r13 + addq 96(%rsp),%rdx + movq %r8,%r15 + xorq %rcx,%r12 + shrdq $6,%r14,%r14 + xorq %r9,%r15 + addq %r12,%rdx + shrdq $14,%r13,%r13 + andq %r15,%rdi + xorq %r8,%r14 + addq %r13,%rdx + xorq %r9,%rdi + shrdq $28,%r14,%r14 + addq %rdx,%r11 + addq %rdi,%rdx + movq %r11,%r13 + addq %rdx,%r14 + shrdq $23,%r13,%r13 + movq %r14,%rdx + movq %rax,%r12 + shrdq $5,%r14,%r14 + xorq %r11,%r13 + xorq %rbx,%r12 + shrdq $4,%r13,%r13 + xorq %rdx,%r14 + andq %r11,%r12 + xorq %r11,%r13 + addq 104(%rsp),%rcx + movq %rdx,%rdi + xorq %rbx,%r12 + shrdq $6,%r14,%r14 + xorq %r8,%rdi + addq %r12,%rcx + shrdq $14,%r13,%r13 + andq %rdi,%r15 + xorq %rdx,%r14 + addq %r13,%rcx + xorq %r8,%r15 + shrdq $28,%r14,%r14 + addq %rcx,%r10 + addq %r15,%rcx + movq %r10,%r13 + addq %rcx,%r14 + shrdq $23,%r13,%r13 + movq %r14,%rcx + movq %r11,%r12 + shrdq $5,%r14,%r14 + xorq %r10,%r13 + xorq %rax,%r12 + shrdq $4,%r13,%r13 + xorq %rcx,%r14 + andq %r10,%r12 + xorq %r10,%r13 + addq 112(%rsp),%rbx + movq %rcx,%r15 + xorq %rax,%r12 + shrdq $6,%r14,%r14 + xorq %rdx,%r15 + addq %r12,%rbx + shrdq $14,%r13,%r13 + andq %r15,%rdi + xorq %rcx,%r14 + addq %r13,%rbx + xorq %rdx,%rdi + shrdq $28,%r14,%r14 + addq %rbx,%r9 + addq %rdi,%rbx + movq %r9,%r13 + addq %rbx,%r14 + shrdq $23,%r13,%r13 + movq %r14,%rbx + movq %r10,%r12 + shrdq $5,%r14,%r14 + xorq %r9,%r13 + xorq %r11,%r12 + shrdq $4,%r13,%r13 + xorq %rbx,%r14 + andq %r9,%r12 + xorq %r9,%r13 + addq 120(%rsp),%rax + movq %rbx,%rdi + xorq %r11,%r12 + shrdq $6,%r14,%r14 + xorq %rcx,%rdi + addq %r12,%rax + shrdq $14,%r13,%r13 + andq %rdi,%r15 + xorq %rbx,%r14 + addq %r13,%rax + xorq %rcx,%r15 + shrdq $28,%r14,%r14 + addq %rax,%r8 + addq %r15,%rax + movq %r8,%r13 + addq %rax,%r14 + movq 128+0(%rsp),%rdi + movq %r14,%rax + + addq 0(%rdi),%rax + leaq 128(%rsi),%rsi + addq 8(%rdi),%rbx + addq 16(%rdi),%rcx + addq 24(%rdi),%rdx + addq 32(%rdi),%r8 + addq 40(%rdi),%r9 + addq 48(%rdi),%r10 + addq 56(%rdi),%r11 + + cmpq 128+16(%rsp),%rsi + + movq %rax,0(%rdi) + movq %rbx,8(%rdi) + movq %rcx,16(%rdi) + movq %rdx,24(%rdi) + movq %r8,32(%rdi) + movq %r9,40(%rdi) + movq %r10,48(%rdi) + movq %r11,56(%rdi) + jb L$loop_avx + + movq 152(%rsp),%rsi + + vzeroupper + movq -48(%rsi),%r15 + + movq -40(%rsi),%r14 + + movq -32(%rsi),%r13 + + movq -24(%rsi),%r12 + + movq -16(%rsi),%rbp + + movq -8(%rsi),%rbx + + leaq (%rsi),%rsp + +L$epilogue_avx: + ret + + +#endif diff --git a/http/vendor/ring/pregenerated/sha512-x86_64-nasm.asm b/http/vendor/ring/pregenerated/sha512-x86_64-nasm.asm new file mode 100644 index 0000000..96e1ad9 --- /dev/null +++ b/http/vendor/ring/pregenerated/sha512-x86_64-nasm.asm @@ -0,0 +1,3138 @@ +; This file is generated from a similarly-named Perl script in the BoringSSL +; source tree. Do not edit by hand. + +%ifidn __OUTPUT_FORMAT__, win64 +default rel +%define XMMWORD +%define YMMWORD +%define ZMMWORD +%define _CET_ENDBR + +%include "ring_core_generated/prefix_symbols_nasm.inc" +section .text code align=64 + + +global sha512_block_data_order_nohw + +ALIGN 16 +sha512_block_data_order_nohw: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_sha512_block_data_order_nohw: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + + + +_CET_ENDBR + mov rax,rsp + + push rbx + + push rbp + + push r12 + + push r13 + + push r14 + + push r15 + + shl rdx,4 + sub rsp,16*8+4*8 + lea rdx,[rdx*8+rsi] + and rsp,-64 + mov QWORD[((128+0))+rsp],rdi + mov QWORD[((128+8))+rsp],rsi + mov QWORD[((128+16))+rsp],rdx + mov QWORD[152+rsp],rax + +$L$prologue: + + mov rax,QWORD[rdi] + mov rbx,QWORD[8+rdi] + mov rcx,QWORD[16+rdi] + mov rdx,QWORD[24+rdi] + mov r8,QWORD[32+rdi] + mov r9,QWORD[40+rdi] + mov r10,QWORD[48+rdi] + mov r11,QWORD[56+rdi] + jmp NEAR $L$loop + +ALIGN 16 +$L$loop: + mov rdi,rbx + lea rbp,[K512] + xor rdi,rcx + mov r12,QWORD[rsi] + mov r13,r8 + mov r14,rax + bswap r12 + ror r13,23 + mov r15,r9 + + xor r13,r8 + ror r14,5 + xor r15,r10 + + mov QWORD[rsp],r12 + xor r14,rax + and r15,r8 + + ror r13,4 + add r12,r11 + xor r15,r10 + + ror r14,6 + xor r13,r8 + add r12,r15 + + mov r15,rax + add r12,QWORD[rbp] + xor r14,rax + + xor r15,rbx + ror r13,14 + mov r11,rbx + + and rdi,r15 + ror r14,28 + add r12,r13 + + xor r11,rdi + add rdx,r12 + add r11,r12 + + lea rbp,[8+rbp] + add r11,r14 + mov r12,QWORD[8+rsi] + mov r13,rdx + mov r14,r11 + bswap r12 + ror r13,23 + mov rdi,r8 + + xor r13,rdx + ror r14,5 + xor rdi,r9 + + mov QWORD[8+rsp],r12 + xor r14,r11 + and rdi,rdx + + ror r13,4 + add r12,r10 + xor rdi,r9 + + ror r14,6 + xor r13,rdx + add r12,rdi + + mov rdi,r11 + add r12,QWORD[rbp] + xor r14,r11 + + xor rdi,rax + ror r13,14 + mov r10,rax + + and r15,rdi + ror r14,28 + add r12,r13 + + xor r10,r15 + add rcx,r12 + add r10,r12 + + lea rbp,[24+rbp] + add r10,r14 + mov r12,QWORD[16+rsi] + mov r13,rcx + mov r14,r10 + bswap r12 + ror r13,23 + mov r15,rdx + + xor r13,rcx + ror r14,5 + xor r15,r8 + + mov QWORD[16+rsp],r12 + xor r14,r10 + and r15,rcx + + ror r13,4 + add r12,r9 + xor r15,r8 + + ror r14,6 + xor r13,rcx + add r12,r15 + + mov r15,r10 + add r12,QWORD[rbp] + xor r14,r10 + + xor r15,r11 + ror r13,14 + mov r9,r11 + + and rdi,r15 + ror r14,28 + add r12,r13 + + xor r9,rdi + add rbx,r12 + add r9,r12 + + lea rbp,[8+rbp] + add r9,r14 + mov r12,QWORD[24+rsi] + mov r13,rbx + mov r14,r9 + bswap r12 + ror r13,23 + mov rdi,rcx + + xor r13,rbx + ror r14,5 + xor rdi,rdx + + mov QWORD[24+rsp],r12 + xor r14,r9 + and rdi,rbx + + ror r13,4 + add r12,r8 + xor rdi,rdx + + ror r14,6 + xor r13,rbx + add r12,rdi + + mov rdi,r9 + add r12,QWORD[rbp] + xor r14,r9 + + xor rdi,r10 + ror r13,14 + mov r8,r10 + + and r15,rdi + ror r14,28 + add r12,r13 + + xor r8,r15 + add rax,r12 + add r8,r12 + + lea rbp,[24+rbp] + add r8,r14 + mov r12,QWORD[32+rsi] + mov r13,rax + mov r14,r8 + bswap r12 + ror r13,23 + mov r15,rbx + + xor r13,rax + ror r14,5 + xor r15,rcx + + mov QWORD[32+rsp],r12 + xor r14,r8 + and r15,rax + + ror r13,4 + add r12,rdx + xor r15,rcx + + ror r14,6 + xor r13,rax + add r12,r15 + + mov r15,r8 + add r12,QWORD[rbp] + xor r14,r8 + + xor r15,r9 + ror r13,14 + mov rdx,r9 + + and rdi,r15 + ror r14,28 + add r12,r13 + + xor rdx,rdi + add r11,r12 + add rdx,r12 + + lea rbp,[8+rbp] + add rdx,r14 + mov r12,QWORD[40+rsi] + mov r13,r11 + mov r14,rdx + bswap r12 + ror r13,23 + mov rdi,rax + + xor r13,r11 + ror r14,5 + xor rdi,rbx + + mov QWORD[40+rsp],r12 + xor r14,rdx + and rdi,r11 + + ror r13,4 + add r12,rcx + xor rdi,rbx + + ror r14,6 + xor r13,r11 + add r12,rdi + + mov rdi,rdx + add r12,QWORD[rbp] + xor r14,rdx + + xor rdi,r8 + ror r13,14 + mov rcx,r8 + + and r15,rdi + ror r14,28 + add r12,r13 + + xor rcx,r15 + add r10,r12 + add rcx,r12 + + lea rbp,[24+rbp] + add rcx,r14 + mov r12,QWORD[48+rsi] + mov r13,r10 + mov r14,rcx + bswap r12 + ror r13,23 + mov r15,r11 + + xor r13,r10 + ror r14,5 + xor r15,rax + + mov QWORD[48+rsp],r12 + xor r14,rcx + and r15,r10 + + ror r13,4 + add r12,rbx + xor r15,rax + + ror r14,6 + xor r13,r10 + add r12,r15 + + mov r15,rcx + add r12,QWORD[rbp] + xor r14,rcx + + xor r15,rdx + ror r13,14 + mov rbx,rdx + + and rdi,r15 + ror r14,28 + add r12,r13 + + xor rbx,rdi + add r9,r12 + add rbx,r12 + + lea rbp,[8+rbp] + add rbx,r14 + mov r12,QWORD[56+rsi] + mov r13,r9 + mov r14,rbx + bswap r12 + ror r13,23 + mov rdi,r10 + + xor r13,r9 + ror r14,5 + xor rdi,r11 + + mov QWORD[56+rsp],r12 + xor r14,rbx + and rdi,r9 + + ror r13,4 + add r12,rax + xor rdi,r11 + + ror r14,6 + xor r13,r9 + add r12,rdi + + mov rdi,rbx + add r12,QWORD[rbp] + xor r14,rbx + + xor rdi,rcx + ror r13,14 + mov rax,rcx + + and r15,rdi + ror r14,28 + add r12,r13 + + xor rax,r15 + add r8,r12 + add rax,r12 + + lea rbp,[24+rbp] + add rax,r14 + mov r12,QWORD[64+rsi] + mov r13,r8 + mov r14,rax + bswap r12 + ror r13,23 + mov r15,r9 + + xor r13,r8 + ror r14,5 + xor r15,r10 + + mov QWORD[64+rsp],r12 + xor r14,rax + and r15,r8 + + ror r13,4 + add r12,r11 + xor r15,r10 + + ror r14,6 + xor r13,r8 + add r12,r15 + + mov r15,rax + add r12,QWORD[rbp] + xor r14,rax + + xor r15,rbx + ror r13,14 + mov r11,rbx + + and rdi,r15 + ror r14,28 + add r12,r13 + + xor r11,rdi + add rdx,r12 + add r11,r12 + + lea rbp,[8+rbp] + add r11,r14 + mov r12,QWORD[72+rsi] + mov r13,rdx + mov r14,r11 + bswap r12 + ror r13,23 + mov rdi,r8 + + xor r13,rdx + ror r14,5 + xor rdi,r9 + + mov QWORD[72+rsp],r12 + xor r14,r11 + and rdi,rdx + + ror r13,4 + add r12,r10 + xor rdi,r9 + + ror r14,6 + xor r13,rdx + add r12,rdi + + mov rdi,r11 + add r12,QWORD[rbp] + xor r14,r11 + + xor rdi,rax + ror r13,14 + mov r10,rax + + and r15,rdi + ror r14,28 + add r12,r13 + + xor r10,r15 + add rcx,r12 + add r10,r12 + + lea rbp,[24+rbp] + add r10,r14 + mov r12,QWORD[80+rsi] + mov r13,rcx + mov r14,r10 + bswap r12 + ror r13,23 + mov r15,rdx + + xor r13,rcx + ror r14,5 + xor r15,r8 + + mov QWORD[80+rsp],r12 + xor r14,r10 + and r15,rcx + + ror r13,4 + add r12,r9 + xor r15,r8 + + ror r14,6 + xor r13,rcx + add r12,r15 + + mov r15,r10 + add r12,QWORD[rbp] + xor r14,r10 + + xor r15,r11 + ror r13,14 + mov r9,r11 + + and rdi,r15 + ror r14,28 + add r12,r13 + + xor r9,rdi + add rbx,r12 + add r9,r12 + + lea rbp,[8+rbp] + add r9,r14 + mov r12,QWORD[88+rsi] + mov r13,rbx + mov r14,r9 + bswap r12 + ror r13,23 + mov rdi,rcx + + xor r13,rbx + ror r14,5 + xor rdi,rdx + + mov QWORD[88+rsp],r12 + xor r14,r9 + and rdi,rbx + + ror r13,4 + add r12,r8 + xor rdi,rdx + + ror r14,6 + xor r13,rbx + add r12,rdi + + mov rdi,r9 + add r12,QWORD[rbp] + xor r14,r9 + + xor rdi,r10 + ror r13,14 + mov r8,r10 + + and r15,rdi + ror r14,28 + add r12,r13 + + xor r8,r15 + add rax,r12 + add r8,r12 + + lea rbp,[24+rbp] + add r8,r14 + mov r12,QWORD[96+rsi] + mov r13,rax + mov r14,r8 + bswap r12 + ror r13,23 + mov r15,rbx + + xor r13,rax + ror r14,5 + xor r15,rcx + + mov QWORD[96+rsp],r12 + xor r14,r8 + and r15,rax + + ror r13,4 + add r12,rdx + xor r15,rcx + + ror r14,6 + xor r13,rax + add r12,r15 + + mov r15,r8 + add r12,QWORD[rbp] + xor r14,r8 + + xor r15,r9 + ror r13,14 + mov rdx,r9 + + and rdi,r15 + ror r14,28 + add r12,r13 + + xor rdx,rdi + add r11,r12 + add rdx,r12 + + lea rbp,[8+rbp] + add rdx,r14 + mov r12,QWORD[104+rsi] + mov r13,r11 + mov r14,rdx + bswap r12 + ror r13,23 + mov rdi,rax + + xor r13,r11 + ror r14,5 + xor rdi,rbx + + mov QWORD[104+rsp],r12 + xor r14,rdx + and rdi,r11 + + ror r13,4 + add r12,rcx + xor rdi,rbx + + ror r14,6 + xor r13,r11 + add r12,rdi + + mov rdi,rdx + add r12,QWORD[rbp] + xor r14,rdx + + xor rdi,r8 + ror r13,14 + mov rcx,r8 + + and r15,rdi + ror r14,28 + add r12,r13 + + xor rcx,r15 + add r10,r12 + add rcx,r12 + + lea rbp,[24+rbp] + add rcx,r14 + mov r12,QWORD[112+rsi] + mov r13,r10 + mov r14,rcx + bswap r12 + ror r13,23 + mov r15,r11 + + xor r13,r10 + ror r14,5 + xor r15,rax + + mov QWORD[112+rsp],r12 + xor r14,rcx + and r15,r10 + + ror r13,4 + add r12,rbx + xor r15,rax + + ror r14,6 + xor r13,r10 + add r12,r15 + + mov r15,rcx + add r12,QWORD[rbp] + xor r14,rcx + + xor r15,rdx + ror r13,14 + mov rbx,rdx + + and rdi,r15 + ror r14,28 + add r12,r13 + + xor rbx,rdi + add r9,r12 + add rbx,r12 + + lea rbp,[8+rbp] + add rbx,r14 + mov r12,QWORD[120+rsi] + mov r13,r9 + mov r14,rbx + bswap r12 + ror r13,23 + mov rdi,r10 + + xor r13,r9 + ror r14,5 + xor rdi,r11 + + mov QWORD[120+rsp],r12 + xor r14,rbx + and rdi,r9 + + ror r13,4 + add r12,rax + xor rdi,r11 + + ror r14,6 + xor r13,r9 + add r12,rdi + + mov rdi,rbx + add r12,QWORD[rbp] + xor r14,rbx + + xor rdi,rcx + ror r13,14 + mov rax,rcx + + and r15,rdi + ror r14,28 + add r12,r13 + + xor rax,r15 + add r8,r12 + add rax,r12 + + lea rbp,[24+rbp] + jmp NEAR $L$rounds_16_xx +ALIGN 16 +$L$rounds_16_xx: + mov r13,QWORD[8+rsp] + mov r15,QWORD[112+rsp] + + mov r12,r13 + ror r13,7 + add rax,r14 + mov r14,r15 + ror r15,42 + + xor r13,r12 + shr r12,7 + ror r13,1 + xor r15,r14 + shr r14,6 + + ror r15,19 + xor r12,r13 + xor r15,r14 + add r12,QWORD[72+rsp] + + add r12,QWORD[rsp] + mov r13,r8 + add r12,r15 + mov r14,rax + ror r13,23 + mov r15,r9 + + xor r13,r8 + ror r14,5 + xor r15,r10 + + mov QWORD[rsp],r12 + xor r14,rax + and r15,r8 + + ror r13,4 + add r12,r11 + xor r15,r10 + + ror r14,6 + xor r13,r8 + add r12,r15 + + mov r15,rax + add r12,QWORD[rbp] + xor r14,rax + + xor r15,rbx + ror r13,14 + mov r11,rbx + + and rdi,r15 + ror r14,28 + add r12,r13 + + xor r11,rdi + add rdx,r12 + add r11,r12 + + lea rbp,[8+rbp] + mov r13,QWORD[16+rsp] + mov rdi,QWORD[120+rsp] + + mov r12,r13 + ror r13,7 + add r11,r14 + mov r14,rdi + ror rdi,42 + + xor r13,r12 + shr r12,7 + ror r13,1 + xor rdi,r14 + shr r14,6 + + ror rdi,19 + xor r12,r13 + xor rdi,r14 + add r12,QWORD[80+rsp] + + add r12,QWORD[8+rsp] + mov r13,rdx + add r12,rdi + mov r14,r11 + ror r13,23 + mov rdi,r8 + + xor r13,rdx + ror r14,5 + xor rdi,r9 + + mov QWORD[8+rsp],r12 + xor r14,r11 + and rdi,rdx + + ror r13,4 + add r12,r10 + xor rdi,r9 + + ror r14,6 + xor r13,rdx + add r12,rdi + + mov rdi,r11 + add r12,QWORD[rbp] + xor r14,r11 + + xor rdi,rax + ror r13,14 + mov r10,rax + + and r15,rdi + ror r14,28 + add r12,r13 + + xor r10,r15 + add rcx,r12 + add r10,r12 + + lea rbp,[24+rbp] + mov r13,QWORD[24+rsp] + mov r15,QWORD[rsp] + + mov r12,r13 + ror r13,7 + add r10,r14 + mov r14,r15 + ror r15,42 + + xor r13,r12 + shr r12,7 + ror r13,1 + xor r15,r14 + shr r14,6 + + ror r15,19 + xor r12,r13 + xor r15,r14 + add r12,QWORD[88+rsp] + + add r12,QWORD[16+rsp] + mov r13,rcx + add r12,r15 + mov r14,r10 + ror r13,23 + mov r15,rdx + + xor r13,rcx + ror r14,5 + xor r15,r8 + + mov QWORD[16+rsp],r12 + xor r14,r10 + and r15,rcx + + ror r13,4 + add r12,r9 + xor r15,r8 + + ror r14,6 + xor r13,rcx + add r12,r15 + + mov r15,r10 + add r12,QWORD[rbp] + xor r14,r10 + + xor r15,r11 + ror r13,14 + mov r9,r11 + + and rdi,r15 + ror r14,28 + add r12,r13 + + xor r9,rdi + add rbx,r12 + add r9,r12 + + lea rbp,[8+rbp] + mov r13,QWORD[32+rsp] + mov rdi,QWORD[8+rsp] + + mov r12,r13 + ror r13,7 + add r9,r14 + mov r14,rdi + ror rdi,42 + + xor r13,r12 + shr r12,7 + ror r13,1 + xor rdi,r14 + shr r14,6 + + ror rdi,19 + xor r12,r13 + xor rdi,r14 + add r12,QWORD[96+rsp] + + add r12,QWORD[24+rsp] + mov r13,rbx + add r12,rdi + mov r14,r9 + ror r13,23 + mov rdi,rcx + + xor r13,rbx + ror r14,5 + xor rdi,rdx + + mov QWORD[24+rsp],r12 + xor r14,r9 + and rdi,rbx + + ror r13,4 + add r12,r8 + xor rdi,rdx + + ror r14,6 + xor r13,rbx + add r12,rdi + + mov rdi,r9 + add r12,QWORD[rbp] + xor r14,r9 + + xor rdi,r10 + ror r13,14 + mov r8,r10 + + and r15,rdi + ror r14,28 + add r12,r13 + + xor r8,r15 + add rax,r12 + add r8,r12 + + lea rbp,[24+rbp] + mov r13,QWORD[40+rsp] + mov r15,QWORD[16+rsp] + + mov r12,r13 + ror r13,7 + add r8,r14 + mov r14,r15 + ror r15,42 + + xor r13,r12 + shr r12,7 + ror r13,1 + xor r15,r14 + shr r14,6 + + ror r15,19 + xor r12,r13 + xor r15,r14 + add r12,QWORD[104+rsp] + + add r12,QWORD[32+rsp] + mov r13,rax + add r12,r15 + mov r14,r8 + ror r13,23 + mov r15,rbx + + xor r13,rax + ror r14,5 + xor r15,rcx + + mov QWORD[32+rsp],r12 + xor r14,r8 + and r15,rax + + ror r13,4 + add r12,rdx + xor r15,rcx + + ror r14,6 + xor r13,rax + add r12,r15 + + mov r15,r8 + add r12,QWORD[rbp] + xor r14,r8 + + xor r15,r9 + ror r13,14 + mov rdx,r9 + + and rdi,r15 + ror r14,28 + add r12,r13 + + xor rdx,rdi + add r11,r12 + add rdx,r12 + + lea rbp,[8+rbp] + mov r13,QWORD[48+rsp] + mov rdi,QWORD[24+rsp] + + mov r12,r13 + ror r13,7 + add rdx,r14 + mov r14,rdi + ror rdi,42 + + xor r13,r12 + shr r12,7 + ror r13,1 + xor rdi,r14 + shr r14,6 + + ror rdi,19 + xor r12,r13 + xor rdi,r14 + add r12,QWORD[112+rsp] + + add r12,QWORD[40+rsp] + mov r13,r11 + add r12,rdi + mov r14,rdx + ror r13,23 + mov rdi,rax + + xor r13,r11 + ror r14,5 + xor rdi,rbx + + mov QWORD[40+rsp],r12 + xor r14,rdx + and rdi,r11 + + ror r13,4 + add r12,rcx + xor rdi,rbx + + ror r14,6 + xor r13,r11 + add r12,rdi + + mov rdi,rdx + add r12,QWORD[rbp] + xor r14,rdx + + xor rdi,r8 + ror r13,14 + mov rcx,r8 + + and r15,rdi + ror r14,28 + add r12,r13 + + xor rcx,r15 + add r10,r12 + add rcx,r12 + + lea rbp,[24+rbp] + mov r13,QWORD[56+rsp] + mov r15,QWORD[32+rsp] + + mov r12,r13 + ror r13,7 + add rcx,r14 + mov r14,r15 + ror r15,42 + + xor r13,r12 + shr r12,7 + ror r13,1 + xor r15,r14 + shr r14,6 + + ror r15,19 + xor r12,r13 + xor r15,r14 + add r12,QWORD[120+rsp] + + add r12,QWORD[48+rsp] + mov r13,r10 + add r12,r15 + mov r14,rcx + ror r13,23 + mov r15,r11 + + xor r13,r10 + ror r14,5 + xor r15,rax + + mov QWORD[48+rsp],r12 + xor r14,rcx + and r15,r10 + + ror r13,4 + add r12,rbx + xor r15,rax + + ror r14,6 + xor r13,r10 + add r12,r15 + + mov r15,rcx + add r12,QWORD[rbp] + xor r14,rcx + + xor r15,rdx + ror r13,14 + mov rbx,rdx + + and rdi,r15 + ror r14,28 + add r12,r13 + + xor rbx,rdi + add r9,r12 + add rbx,r12 + + lea rbp,[8+rbp] + mov r13,QWORD[64+rsp] + mov rdi,QWORD[40+rsp] + + mov r12,r13 + ror r13,7 + add rbx,r14 + mov r14,rdi + ror rdi,42 + + xor r13,r12 + shr r12,7 + ror r13,1 + xor rdi,r14 + shr r14,6 + + ror rdi,19 + xor r12,r13 + xor rdi,r14 + add r12,QWORD[rsp] + + add r12,QWORD[56+rsp] + mov r13,r9 + add r12,rdi + mov r14,rbx + ror r13,23 + mov rdi,r10 + + xor r13,r9 + ror r14,5 + xor rdi,r11 + + mov QWORD[56+rsp],r12 + xor r14,rbx + and rdi,r9 + + ror r13,4 + add r12,rax + xor rdi,r11 + + ror r14,6 + xor r13,r9 + add r12,rdi + + mov rdi,rbx + add r12,QWORD[rbp] + xor r14,rbx + + xor rdi,rcx + ror r13,14 + mov rax,rcx + + and r15,rdi + ror r14,28 + add r12,r13 + + xor rax,r15 + add r8,r12 + add rax,r12 + + lea rbp,[24+rbp] + mov r13,QWORD[72+rsp] + mov r15,QWORD[48+rsp] + + mov r12,r13 + ror r13,7 + add rax,r14 + mov r14,r15 + ror r15,42 + + xor r13,r12 + shr r12,7 + ror r13,1 + xor r15,r14 + shr r14,6 + + ror r15,19 + xor r12,r13 + xor r15,r14 + add r12,QWORD[8+rsp] + + add r12,QWORD[64+rsp] + mov r13,r8 + add r12,r15 + mov r14,rax + ror r13,23 + mov r15,r9 + + xor r13,r8 + ror r14,5 + xor r15,r10 + + mov QWORD[64+rsp],r12 + xor r14,rax + and r15,r8 + + ror r13,4 + add r12,r11 + xor r15,r10 + + ror r14,6 + xor r13,r8 + add r12,r15 + + mov r15,rax + add r12,QWORD[rbp] + xor r14,rax + + xor r15,rbx + ror r13,14 + mov r11,rbx + + and rdi,r15 + ror r14,28 + add r12,r13 + + xor r11,rdi + add rdx,r12 + add r11,r12 + + lea rbp,[8+rbp] + mov r13,QWORD[80+rsp] + mov rdi,QWORD[56+rsp] + + mov r12,r13 + ror r13,7 + add r11,r14 + mov r14,rdi + ror rdi,42 + + xor r13,r12 + shr r12,7 + ror r13,1 + xor rdi,r14 + shr r14,6 + + ror rdi,19 + xor r12,r13 + xor rdi,r14 + add r12,QWORD[16+rsp] + + add r12,QWORD[72+rsp] + mov r13,rdx + add r12,rdi + mov r14,r11 + ror r13,23 + mov rdi,r8 + + xor r13,rdx + ror r14,5 + xor rdi,r9 + + mov QWORD[72+rsp],r12 + xor r14,r11 + and rdi,rdx + + ror r13,4 + add r12,r10 + xor rdi,r9 + + ror r14,6 + xor r13,rdx + add r12,rdi + + mov rdi,r11 + add r12,QWORD[rbp] + xor r14,r11 + + xor rdi,rax + ror r13,14 + mov r10,rax + + and r15,rdi + ror r14,28 + add r12,r13 + + xor r10,r15 + add rcx,r12 + add r10,r12 + + lea rbp,[24+rbp] + mov r13,QWORD[88+rsp] + mov r15,QWORD[64+rsp] + + mov r12,r13 + ror r13,7 + add r10,r14 + mov r14,r15 + ror r15,42 + + xor r13,r12 + shr r12,7 + ror r13,1 + xor r15,r14 + shr r14,6 + + ror r15,19 + xor r12,r13 + xor r15,r14 + add r12,QWORD[24+rsp] + + add r12,QWORD[80+rsp] + mov r13,rcx + add r12,r15 + mov r14,r10 + ror r13,23 + mov r15,rdx + + xor r13,rcx + ror r14,5 + xor r15,r8 + + mov QWORD[80+rsp],r12 + xor r14,r10 + and r15,rcx + + ror r13,4 + add r12,r9 + xor r15,r8 + + ror r14,6 + xor r13,rcx + add r12,r15 + + mov r15,r10 + add r12,QWORD[rbp] + xor r14,r10 + + xor r15,r11 + ror r13,14 + mov r9,r11 + + and rdi,r15 + ror r14,28 + add r12,r13 + + xor r9,rdi + add rbx,r12 + add r9,r12 + + lea rbp,[8+rbp] + mov r13,QWORD[96+rsp] + mov rdi,QWORD[72+rsp] + + mov r12,r13 + ror r13,7 + add r9,r14 + mov r14,rdi + ror rdi,42 + + xor r13,r12 + shr r12,7 + ror r13,1 + xor rdi,r14 + shr r14,6 + + ror rdi,19 + xor r12,r13 + xor rdi,r14 + add r12,QWORD[32+rsp] + + add r12,QWORD[88+rsp] + mov r13,rbx + add r12,rdi + mov r14,r9 + ror r13,23 + mov rdi,rcx + + xor r13,rbx + ror r14,5 + xor rdi,rdx + + mov QWORD[88+rsp],r12 + xor r14,r9 + and rdi,rbx + + ror r13,4 + add r12,r8 + xor rdi,rdx + + ror r14,6 + xor r13,rbx + add r12,rdi + + mov rdi,r9 + add r12,QWORD[rbp] + xor r14,r9 + + xor rdi,r10 + ror r13,14 + mov r8,r10 + + and r15,rdi + ror r14,28 + add r12,r13 + + xor r8,r15 + add rax,r12 + add r8,r12 + + lea rbp,[24+rbp] + mov r13,QWORD[104+rsp] + mov r15,QWORD[80+rsp] + + mov r12,r13 + ror r13,7 + add r8,r14 + mov r14,r15 + ror r15,42 + + xor r13,r12 + shr r12,7 + ror r13,1 + xor r15,r14 + shr r14,6 + + ror r15,19 + xor r12,r13 + xor r15,r14 + add r12,QWORD[40+rsp] + + add r12,QWORD[96+rsp] + mov r13,rax + add r12,r15 + mov r14,r8 + ror r13,23 + mov r15,rbx + + xor r13,rax + ror r14,5 + xor r15,rcx + + mov QWORD[96+rsp],r12 + xor r14,r8 + and r15,rax + + ror r13,4 + add r12,rdx + xor r15,rcx + + ror r14,6 + xor r13,rax + add r12,r15 + + mov r15,r8 + add r12,QWORD[rbp] + xor r14,r8 + + xor r15,r9 + ror r13,14 + mov rdx,r9 + + and rdi,r15 + ror r14,28 + add r12,r13 + + xor rdx,rdi + add r11,r12 + add rdx,r12 + + lea rbp,[8+rbp] + mov r13,QWORD[112+rsp] + mov rdi,QWORD[88+rsp] + + mov r12,r13 + ror r13,7 + add rdx,r14 + mov r14,rdi + ror rdi,42 + + xor r13,r12 + shr r12,7 + ror r13,1 + xor rdi,r14 + shr r14,6 + + ror rdi,19 + xor r12,r13 + xor rdi,r14 + add r12,QWORD[48+rsp] + + add r12,QWORD[104+rsp] + mov r13,r11 + add r12,rdi + mov r14,rdx + ror r13,23 + mov rdi,rax + + xor r13,r11 + ror r14,5 + xor rdi,rbx + + mov QWORD[104+rsp],r12 + xor r14,rdx + and rdi,r11 + + ror r13,4 + add r12,rcx + xor rdi,rbx + + ror r14,6 + xor r13,r11 + add r12,rdi + + mov rdi,rdx + add r12,QWORD[rbp] + xor r14,rdx + + xor rdi,r8 + ror r13,14 + mov rcx,r8 + + and r15,rdi + ror r14,28 + add r12,r13 + + xor rcx,r15 + add r10,r12 + add rcx,r12 + + lea rbp,[24+rbp] + mov r13,QWORD[120+rsp] + mov r15,QWORD[96+rsp] + + mov r12,r13 + ror r13,7 + add rcx,r14 + mov r14,r15 + ror r15,42 + + xor r13,r12 + shr r12,7 + ror r13,1 + xor r15,r14 + shr r14,6 + + ror r15,19 + xor r12,r13 + xor r15,r14 + add r12,QWORD[56+rsp] + + add r12,QWORD[112+rsp] + mov r13,r10 + add r12,r15 + mov r14,rcx + ror r13,23 + mov r15,r11 + + xor r13,r10 + ror r14,5 + xor r15,rax + + mov QWORD[112+rsp],r12 + xor r14,rcx + and r15,r10 + + ror r13,4 + add r12,rbx + xor r15,rax + + ror r14,6 + xor r13,r10 + add r12,r15 + + mov r15,rcx + add r12,QWORD[rbp] + xor r14,rcx + + xor r15,rdx + ror r13,14 + mov rbx,rdx + + and rdi,r15 + ror r14,28 + add r12,r13 + + xor rbx,rdi + add r9,r12 + add rbx,r12 + + lea rbp,[8+rbp] + mov r13,QWORD[rsp] + mov rdi,QWORD[104+rsp] + + mov r12,r13 + ror r13,7 + add rbx,r14 + mov r14,rdi + ror rdi,42 + + xor r13,r12 + shr r12,7 + ror r13,1 + xor rdi,r14 + shr r14,6 + + ror rdi,19 + xor r12,r13 + xor rdi,r14 + add r12,QWORD[64+rsp] + + add r12,QWORD[120+rsp] + mov r13,r9 + add r12,rdi + mov r14,rbx + ror r13,23 + mov rdi,r10 + + xor r13,r9 + ror r14,5 + xor rdi,r11 + + mov QWORD[120+rsp],r12 + xor r14,rbx + and rdi,r9 + + ror r13,4 + add r12,rax + xor rdi,r11 + + ror r14,6 + xor r13,r9 + add r12,rdi + + mov rdi,rbx + add r12,QWORD[rbp] + xor r14,rbx + + xor rdi,rcx + ror r13,14 + mov rax,rcx + + and r15,rdi + ror r14,28 + add r12,r13 + + xor rax,r15 + add r8,r12 + add rax,r12 + + lea rbp,[24+rbp] + cmp BYTE[7+rbp],0 + jnz NEAR $L$rounds_16_xx + + mov rdi,QWORD[((128+0))+rsp] + add rax,r14 + lea rsi,[128+rsi] + + add rax,QWORD[rdi] + add rbx,QWORD[8+rdi] + add rcx,QWORD[16+rdi] + add rdx,QWORD[24+rdi] + add r8,QWORD[32+rdi] + add r9,QWORD[40+rdi] + add r10,QWORD[48+rdi] + add r11,QWORD[56+rdi] + + cmp rsi,QWORD[((128+16))+rsp] + + mov QWORD[rdi],rax + mov QWORD[8+rdi],rbx + mov QWORD[16+rdi],rcx + mov QWORD[24+rdi],rdx + mov QWORD[32+rdi],r8 + mov QWORD[40+rdi],r9 + mov QWORD[48+rdi],r10 + mov QWORD[56+rdi],r11 + jb NEAR $L$loop + + mov rsi,QWORD[152+rsp] + + mov r15,QWORD[((-48))+rsi] + + mov r14,QWORD[((-40))+rsi] + + mov r13,QWORD[((-32))+rsi] + + mov r12,QWORD[((-24))+rsi] + + mov rbp,QWORD[((-16))+rsi] + + mov rbx,QWORD[((-8))+rsi] + + lea rsp,[rsi] + +$L$epilogue: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_sha512_block_data_order_nohw: +section .rdata rdata align=8 +ALIGN 64 + +K512: + DQ 0x428a2f98d728ae22,0x7137449123ef65cd + DQ 0x428a2f98d728ae22,0x7137449123ef65cd + DQ 0xb5c0fbcfec4d3b2f,0xe9b5dba58189dbbc + DQ 0xb5c0fbcfec4d3b2f,0xe9b5dba58189dbbc + DQ 0x3956c25bf348b538,0x59f111f1b605d019 + DQ 0x3956c25bf348b538,0x59f111f1b605d019 + DQ 0x923f82a4af194f9b,0xab1c5ed5da6d8118 + DQ 0x923f82a4af194f9b,0xab1c5ed5da6d8118 + DQ 0xd807aa98a3030242,0x12835b0145706fbe + DQ 0xd807aa98a3030242,0x12835b0145706fbe + DQ 0x243185be4ee4b28c,0x550c7dc3d5ffb4e2 + DQ 0x243185be4ee4b28c,0x550c7dc3d5ffb4e2 + DQ 0x72be5d74f27b896f,0x80deb1fe3b1696b1 + DQ 0x72be5d74f27b896f,0x80deb1fe3b1696b1 + DQ 0x9bdc06a725c71235,0xc19bf174cf692694 + DQ 0x9bdc06a725c71235,0xc19bf174cf692694 + DQ 0xe49b69c19ef14ad2,0xefbe4786384f25e3 + DQ 0xe49b69c19ef14ad2,0xefbe4786384f25e3 + DQ 0x0fc19dc68b8cd5b5,0x240ca1cc77ac9c65 + DQ 0x0fc19dc68b8cd5b5,0x240ca1cc77ac9c65 + DQ 0x2de92c6f592b0275,0x4a7484aa6ea6e483 + DQ 0x2de92c6f592b0275,0x4a7484aa6ea6e483 + DQ 0x5cb0a9dcbd41fbd4,0x76f988da831153b5 + DQ 0x5cb0a9dcbd41fbd4,0x76f988da831153b5 + DQ 0x983e5152ee66dfab,0xa831c66d2db43210 + DQ 0x983e5152ee66dfab,0xa831c66d2db43210 + DQ 0xb00327c898fb213f,0xbf597fc7beef0ee4 + DQ 0xb00327c898fb213f,0xbf597fc7beef0ee4 + DQ 0xc6e00bf33da88fc2,0xd5a79147930aa725 + DQ 0xc6e00bf33da88fc2,0xd5a79147930aa725 + DQ 0x06ca6351e003826f,0x142929670a0e6e70 + DQ 0x06ca6351e003826f,0x142929670a0e6e70 + DQ 0x27b70a8546d22ffc,0x2e1b21385c26c926 + DQ 0x27b70a8546d22ffc,0x2e1b21385c26c926 + DQ 0x4d2c6dfc5ac42aed,0x53380d139d95b3df + DQ 0x4d2c6dfc5ac42aed,0x53380d139d95b3df + DQ 0x650a73548baf63de,0x766a0abb3c77b2a8 + DQ 0x650a73548baf63de,0x766a0abb3c77b2a8 + DQ 0x81c2c92e47edaee6,0x92722c851482353b + DQ 0x81c2c92e47edaee6,0x92722c851482353b + DQ 0xa2bfe8a14cf10364,0xa81a664bbc423001 + DQ 0xa2bfe8a14cf10364,0xa81a664bbc423001 + DQ 0xc24b8b70d0f89791,0xc76c51a30654be30 + DQ 0xc24b8b70d0f89791,0xc76c51a30654be30 + DQ 0xd192e819d6ef5218,0xd69906245565a910 + DQ 0xd192e819d6ef5218,0xd69906245565a910 + DQ 0xf40e35855771202a,0x106aa07032bbd1b8 + DQ 0xf40e35855771202a,0x106aa07032bbd1b8 + DQ 0x19a4c116b8d2d0c8,0x1e376c085141ab53 + DQ 0x19a4c116b8d2d0c8,0x1e376c085141ab53 + DQ 0x2748774cdf8eeb99,0x34b0bcb5e19b48a8 + DQ 0x2748774cdf8eeb99,0x34b0bcb5e19b48a8 + DQ 0x391c0cb3c5c95a63,0x4ed8aa4ae3418acb + DQ 0x391c0cb3c5c95a63,0x4ed8aa4ae3418acb + DQ 0x5b9cca4f7763e373,0x682e6ff3d6b2b8a3 + DQ 0x5b9cca4f7763e373,0x682e6ff3d6b2b8a3 + DQ 0x748f82ee5defb2fc,0x78a5636f43172f60 + DQ 0x748f82ee5defb2fc,0x78a5636f43172f60 + DQ 0x84c87814a1f0ab72,0x8cc702081a6439ec + DQ 0x84c87814a1f0ab72,0x8cc702081a6439ec + DQ 0x90befffa23631e28,0xa4506cebde82bde9 + DQ 0x90befffa23631e28,0xa4506cebde82bde9 + DQ 0xbef9a3f7b2c67915,0xc67178f2e372532b + DQ 0xbef9a3f7b2c67915,0xc67178f2e372532b + DQ 0xca273eceea26619c,0xd186b8c721c0c207 + DQ 0xca273eceea26619c,0xd186b8c721c0c207 + DQ 0xeada7dd6cde0eb1e,0xf57d4f7fee6ed178 + DQ 0xeada7dd6cde0eb1e,0xf57d4f7fee6ed178 + DQ 0x06f067aa72176fba,0x0a637dc5a2c898a6 + DQ 0x06f067aa72176fba,0x0a637dc5a2c898a6 + DQ 0x113f9804bef90dae,0x1b710b35131c471b + DQ 0x113f9804bef90dae,0x1b710b35131c471b + DQ 0x28db77f523047d84,0x32caab7b40c72493 + DQ 0x28db77f523047d84,0x32caab7b40c72493 + DQ 0x3c9ebe0a15c9bebc,0x431d67c49c100d4c + DQ 0x3c9ebe0a15c9bebc,0x431d67c49c100d4c + DQ 0x4cc5d4becb3e42b6,0x597f299cfc657e2a + DQ 0x4cc5d4becb3e42b6,0x597f299cfc657e2a + DQ 0x5fcb6fab3ad6faec,0x6c44198c4a475817 + DQ 0x5fcb6fab3ad6faec,0x6c44198c4a475817 + + DQ 0x0001020304050607,0x08090a0b0c0d0e0f + DQ 0x0001020304050607,0x08090a0b0c0d0e0f + DB 83,72,65,53,49,50,32,98,108,111,99,107,32,116,114,97 + DB 110,115,102,111,114,109,32,102,111,114,32,120,56,54,95,54 + DB 52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121 + DB 32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46 + DB 111,114,103,62,0 +section .text + +global sha512_block_data_order_avx + +ALIGN 64 +sha512_block_data_order_avx: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_sha512_block_data_order_avx: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + + + +_CET_ENDBR + mov rax,rsp + + push rbx + + push rbp + + push r12 + + push r13 + + push r14 + + push r15 + + shl rdx,4 + sub rsp,256 + lea rdx,[rdx*8+rsi] + and rsp,-64 + mov QWORD[((128+0))+rsp],rdi + mov QWORD[((128+8))+rsp],rsi + mov QWORD[((128+16))+rsp],rdx + mov QWORD[152+rsp],rax + + movaps XMMWORD[(128+32)+rsp],xmm6 + movaps XMMWORD[(128+48)+rsp],xmm7 + movaps XMMWORD[(128+64)+rsp],xmm8 + movaps XMMWORD[(128+80)+rsp],xmm9 + movaps XMMWORD[(128+96)+rsp],xmm10 + movaps XMMWORD[(128+112)+rsp],xmm11 +$L$prologue_avx: + + vzeroupper + mov rax,QWORD[rdi] + mov rbx,QWORD[8+rdi] + mov rcx,QWORD[16+rdi] + mov rdx,QWORD[24+rdi] + mov r8,QWORD[32+rdi] + mov r9,QWORD[40+rdi] + mov r10,QWORD[48+rdi] + mov r11,QWORD[56+rdi] + jmp NEAR $L$loop_avx +ALIGN 16 +$L$loop_avx: + vmovdqa xmm11,XMMWORD[((K512+1280))] + vmovdqu xmm0,XMMWORD[rsi] + lea rbp,[((K512+128))] + vmovdqu xmm1,XMMWORD[16+rsi] + vmovdqu xmm2,XMMWORD[32+rsi] + vpshufb xmm0,xmm0,xmm11 + vmovdqu xmm3,XMMWORD[48+rsi] + vpshufb xmm1,xmm1,xmm11 + vmovdqu xmm4,XMMWORD[64+rsi] + vpshufb xmm2,xmm2,xmm11 + vmovdqu xmm5,XMMWORD[80+rsi] + vpshufb xmm3,xmm3,xmm11 + vmovdqu xmm6,XMMWORD[96+rsi] + vpshufb xmm4,xmm4,xmm11 + vmovdqu xmm7,XMMWORD[112+rsi] + vpshufb xmm5,xmm5,xmm11 + vpaddq xmm8,xmm0,XMMWORD[((-128))+rbp] + vpshufb xmm6,xmm6,xmm11 + vpaddq xmm9,xmm1,XMMWORD[((-96))+rbp] + vpshufb xmm7,xmm7,xmm11 + vpaddq xmm10,xmm2,XMMWORD[((-64))+rbp] + vpaddq xmm11,xmm3,XMMWORD[((-32))+rbp] + vmovdqa XMMWORD[rsp],xmm8 + vpaddq xmm8,xmm4,XMMWORD[rbp] + vmovdqa XMMWORD[16+rsp],xmm9 + vpaddq xmm9,xmm5,XMMWORD[32+rbp] + vmovdqa XMMWORD[32+rsp],xmm10 + vpaddq xmm10,xmm6,XMMWORD[64+rbp] + vmovdqa XMMWORD[48+rsp],xmm11 + vpaddq xmm11,xmm7,XMMWORD[96+rbp] + vmovdqa XMMWORD[64+rsp],xmm8 + mov r14,rax + vmovdqa XMMWORD[80+rsp],xmm9 + mov rdi,rbx + vmovdqa XMMWORD[96+rsp],xmm10 + xor rdi,rcx + vmovdqa XMMWORD[112+rsp],xmm11 + mov r13,r8 + jmp NEAR $L$avx_00_47 + +ALIGN 16 +$L$avx_00_47: + add rbp,256 + vpalignr xmm8,xmm1,xmm0,8 + shrd r13,r13,23 + mov rax,r14 + vpalignr xmm11,xmm5,xmm4,8 + mov r12,r9 + shrd r14,r14,5 + vpsrlq xmm10,xmm8,1 + xor r13,r8 + xor r12,r10 + vpaddq xmm0,xmm0,xmm11 + shrd r13,r13,4 + xor r14,rax + vpsrlq xmm11,xmm8,7 + and r12,r8 + xor r13,r8 + vpsllq xmm9,xmm8,56 + add r11,QWORD[rsp] + mov r15,rax + vpxor xmm8,xmm11,xmm10 + xor r12,r10 + shrd r14,r14,6 + vpsrlq xmm10,xmm10,7 + xor r15,rbx + add r11,r12 + vpxor xmm8,xmm8,xmm9 + shrd r13,r13,14 + and rdi,r15 + vpsllq xmm9,xmm9,7 + xor r14,rax + add r11,r13 + vpxor xmm8,xmm8,xmm10 + xor rdi,rbx + shrd r14,r14,28 + vpsrlq xmm11,xmm7,6 + add rdx,r11 + add r11,rdi + vpxor xmm8,xmm8,xmm9 + mov r13,rdx + add r14,r11 + vpsllq xmm10,xmm7,3 + shrd r13,r13,23 + mov r11,r14 + vpaddq xmm0,xmm0,xmm8 + mov r12,r8 + shrd r14,r14,5 + vpsrlq xmm9,xmm7,19 + xor r13,rdx + xor r12,r9 + vpxor xmm11,xmm11,xmm10 + shrd r13,r13,4 + xor r14,r11 + vpsllq xmm10,xmm10,42 + and r12,rdx + xor r13,rdx + vpxor xmm11,xmm11,xmm9 + add r10,QWORD[8+rsp] + mov rdi,r11 + vpsrlq xmm9,xmm9,42 + xor r12,r9 + shrd r14,r14,6 + vpxor xmm11,xmm11,xmm10 + xor rdi,rax + add r10,r12 + vpxor xmm11,xmm11,xmm9 + shrd r13,r13,14 + and r15,rdi + vpaddq xmm0,xmm0,xmm11 + xor r14,r11 + add r10,r13 + vpaddq xmm10,xmm0,XMMWORD[((-128))+rbp] + xor r15,rax + shrd r14,r14,28 + add rcx,r10 + add r10,r15 + mov r13,rcx + add r14,r10 + vmovdqa XMMWORD[rsp],xmm10 + vpalignr xmm8,xmm2,xmm1,8 + shrd r13,r13,23 + mov r10,r14 + vpalignr xmm11,xmm6,xmm5,8 + mov r12,rdx + shrd r14,r14,5 + vpsrlq xmm10,xmm8,1 + xor r13,rcx + xor r12,r8 + vpaddq xmm1,xmm1,xmm11 + shrd r13,r13,4 + xor r14,r10 + vpsrlq xmm11,xmm8,7 + and r12,rcx + xor r13,rcx + vpsllq xmm9,xmm8,56 + add r9,QWORD[16+rsp] + mov r15,r10 + vpxor xmm8,xmm11,xmm10 + xor r12,r8 + shrd r14,r14,6 + vpsrlq xmm10,xmm10,7 + xor r15,r11 + add r9,r12 + vpxor xmm8,xmm8,xmm9 + shrd r13,r13,14 + and rdi,r15 + vpsllq xmm9,xmm9,7 + xor r14,r10 + add r9,r13 + vpxor xmm8,xmm8,xmm10 + xor rdi,r11 + shrd r14,r14,28 + vpsrlq xmm11,xmm0,6 + add rbx,r9 + add r9,rdi + vpxor xmm8,xmm8,xmm9 + mov r13,rbx + add r14,r9 + vpsllq xmm10,xmm0,3 + shrd r13,r13,23 + mov r9,r14 + vpaddq xmm1,xmm1,xmm8 + mov r12,rcx + shrd r14,r14,5 + vpsrlq xmm9,xmm0,19 + xor r13,rbx + xor r12,rdx + vpxor xmm11,xmm11,xmm10 + shrd r13,r13,4 + xor r14,r9 + vpsllq xmm10,xmm10,42 + and r12,rbx + xor r13,rbx + vpxor xmm11,xmm11,xmm9 + add r8,QWORD[24+rsp] + mov rdi,r9 + vpsrlq xmm9,xmm9,42 + xor r12,rdx + shrd r14,r14,6 + vpxor xmm11,xmm11,xmm10 + xor rdi,r10 + add r8,r12 + vpxor xmm11,xmm11,xmm9 + shrd r13,r13,14 + and r15,rdi + vpaddq xmm1,xmm1,xmm11 + xor r14,r9 + add r8,r13 + vpaddq xmm10,xmm1,XMMWORD[((-96))+rbp] + xor r15,r10 + shrd r14,r14,28 + add rax,r8 + add r8,r15 + mov r13,rax + add r14,r8 + vmovdqa XMMWORD[16+rsp],xmm10 + vpalignr xmm8,xmm3,xmm2,8 + shrd r13,r13,23 + mov r8,r14 + vpalignr xmm11,xmm7,xmm6,8 + mov r12,rbx + shrd r14,r14,5 + vpsrlq xmm10,xmm8,1 + xor r13,rax + xor r12,rcx + vpaddq xmm2,xmm2,xmm11 + shrd r13,r13,4 + xor r14,r8 + vpsrlq xmm11,xmm8,7 + and r12,rax + xor r13,rax + vpsllq xmm9,xmm8,56 + add rdx,QWORD[32+rsp] + mov r15,r8 + vpxor xmm8,xmm11,xmm10 + xor r12,rcx + shrd r14,r14,6 + vpsrlq xmm10,xmm10,7 + xor r15,r9 + add rdx,r12 + vpxor xmm8,xmm8,xmm9 + shrd r13,r13,14 + and rdi,r15 + vpsllq xmm9,xmm9,7 + xor r14,r8 + add rdx,r13 + vpxor xmm8,xmm8,xmm10 + xor rdi,r9 + shrd r14,r14,28 + vpsrlq xmm11,xmm1,6 + add r11,rdx + add rdx,rdi + vpxor xmm8,xmm8,xmm9 + mov r13,r11 + add r14,rdx + vpsllq xmm10,xmm1,3 + shrd r13,r13,23 + mov rdx,r14 + vpaddq xmm2,xmm2,xmm8 + mov r12,rax + shrd r14,r14,5 + vpsrlq xmm9,xmm1,19 + xor r13,r11 + xor r12,rbx + vpxor xmm11,xmm11,xmm10 + shrd r13,r13,4 + xor r14,rdx + vpsllq xmm10,xmm10,42 + and r12,r11 + xor r13,r11 + vpxor xmm11,xmm11,xmm9 + add rcx,QWORD[40+rsp] + mov rdi,rdx + vpsrlq xmm9,xmm9,42 + xor r12,rbx + shrd r14,r14,6 + vpxor xmm11,xmm11,xmm10 + xor rdi,r8 + add rcx,r12 + vpxor xmm11,xmm11,xmm9 + shrd r13,r13,14 + and r15,rdi + vpaddq xmm2,xmm2,xmm11 + xor r14,rdx + add rcx,r13 + vpaddq xmm10,xmm2,XMMWORD[((-64))+rbp] + xor r15,r8 + shrd r14,r14,28 + add r10,rcx + add rcx,r15 + mov r13,r10 + add r14,rcx + vmovdqa XMMWORD[32+rsp],xmm10 + vpalignr xmm8,xmm4,xmm3,8 + shrd r13,r13,23 + mov rcx,r14 + vpalignr xmm11,xmm0,xmm7,8 + mov r12,r11 + shrd r14,r14,5 + vpsrlq xmm10,xmm8,1 + xor r13,r10 + xor r12,rax + vpaddq xmm3,xmm3,xmm11 + shrd r13,r13,4 + xor r14,rcx + vpsrlq xmm11,xmm8,7 + and r12,r10 + xor r13,r10 + vpsllq xmm9,xmm8,56 + add rbx,QWORD[48+rsp] + mov r15,rcx + vpxor xmm8,xmm11,xmm10 + xor r12,rax + shrd r14,r14,6 + vpsrlq xmm10,xmm10,7 + xor r15,rdx + add rbx,r12 + vpxor xmm8,xmm8,xmm9 + shrd r13,r13,14 + and rdi,r15 + vpsllq xmm9,xmm9,7 + xor r14,rcx + add rbx,r13 + vpxor xmm8,xmm8,xmm10 + xor rdi,rdx + shrd r14,r14,28 + vpsrlq xmm11,xmm2,6 + add r9,rbx + add rbx,rdi + vpxor xmm8,xmm8,xmm9 + mov r13,r9 + add r14,rbx + vpsllq xmm10,xmm2,3 + shrd r13,r13,23 + mov rbx,r14 + vpaddq xmm3,xmm3,xmm8 + mov r12,r10 + shrd r14,r14,5 + vpsrlq xmm9,xmm2,19 + xor r13,r9 + xor r12,r11 + vpxor xmm11,xmm11,xmm10 + shrd r13,r13,4 + xor r14,rbx + vpsllq xmm10,xmm10,42 + and r12,r9 + xor r13,r9 + vpxor xmm11,xmm11,xmm9 + add rax,QWORD[56+rsp] + mov rdi,rbx + vpsrlq xmm9,xmm9,42 + xor r12,r11 + shrd r14,r14,6 + vpxor xmm11,xmm11,xmm10 + xor rdi,rcx + add rax,r12 + vpxor xmm11,xmm11,xmm9 + shrd r13,r13,14 + and r15,rdi + vpaddq xmm3,xmm3,xmm11 + xor r14,rbx + add rax,r13 + vpaddq xmm10,xmm3,XMMWORD[((-32))+rbp] + xor r15,rcx + shrd r14,r14,28 + add r8,rax + add rax,r15 + mov r13,r8 + add r14,rax + vmovdqa XMMWORD[48+rsp],xmm10 + vpalignr xmm8,xmm5,xmm4,8 + shrd r13,r13,23 + mov rax,r14 + vpalignr xmm11,xmm1,xmm0,8 + mov r12,r9 + shrd r14,r14,5 + vpsrlq xmm10,xmm8,1 + xor r13,r8 + xor r12,r10 + vpaddq xmm4,xmm4,xmm11 + shrd r13,r13,4 + xor r14,rax + vpsrlq xmm11,xmm8,7 + and r12,r8 + xor r13,r8 + vpsllq xmm9,xmm8,56 + add r11,QWORD[64+rsp] + mov r15,rax + vpxor xmm8,xmm11,xmm10 + xor r12,r10 + shrd r14,r14,6 + vpsrlq xmm10,xmm10,7 + xor r15,rbx + add r11,r12 + vpxor xmm8,xmm8,xmm9 + shrd r13,r13,14 + and rdi,r15 + vpsllq xmm9,xmm9,7 + xor r14,rax + add r11,r13 + vpxor xmm8,xmm8,xmm10 + xor rdi,rbx + shrd r14,r14,28 + vpsrlq xmm11,xmm3,6 + add rdx,r11 + add r11,rdi + vpxor xmm8,xmm8,xmm9 + mov r13,rdx + add r14,r11 + vpsllq xmm10,xmm3,3 + shrd r13,r13,23 + mov r11,r14 + vpaddq xmm4,xmm4,xmm8 + mov r12,r8 + shrd r14,r14,5 + vpsrlq xmm9,xmm3,19 + xor r13,rdx + xor r12,r9 + vpxor xmm11,xmm11,xmm10 + shrd r13,r13,4 + xor r14,r11 + vpsllq xmm10,xmm10,42 + and r12,rdx + xor r13,rdx + vpxor xmm11,xmm11,xmm9 + add r10,QWORD[72+rsp] + mov rdi,r11 + vpsrlq xmm9,xmm9,42 + xor r12,r9 + shrd r14,r14,6 + vpxor xmm11,xmm11,xmm10 + xor rdi,rax + add r10,r12 + vpxor xmm11,xmm11,xmm9 + shrd r13,r13,14 + and r15,rdi + vpaddq xmm4,xmm4,xmm11 + xor r14,r11 + add r10,r13 + vpaddq xmm10,xmm4,XMMWORD[rbp] + xor r15,rax + shrd r14,r14,28 + add rcx,r10 + add r10,r15 + mov r13,rcx + add r14,r10 + vmovdqa XMMWORD[64+rsp],xmm10 + vpalignr xmm8,xmm6,xmm5,8 + shrd r13,r13,23 + mov r10,r14 + vpalignr xmm11,xmm2,xmm1,8 + mov r12,rdx + shrd r14,r14,5 + vpsrlq xmm10,xmm8,1 + xor r13,rcx + xor r12,r8 + vpaddq xmm5,xmm5,xmm11 + shrd r13,r13,4 + xor r14,r10 + vpsrlq xmm11,xmm8,7 + and r12,rcx + xor r13,rcx + vpsllq xmm9,xmm8,56 + add r9,QWORD[80+rsp] + mov r15,r10 + vpxor xmm8,xmm11,xmm10 + xor r12,r8 + shrd r14,r14,6 + vpsrlq xmm10,xmm10,7 + xor r15,r11 + add r9,r12 + vpxor xmm8,xmm8,xmm9 + shrd r13,r13,14 + and rdi,r15 + vpsllq xmm9,xmm9,7 + xor r14,r10 + add r9,r13 + vpxor xmm8,xmm8,xmm10 + xor rdi,r11 + shrd r14,r14,28 + vpsrlq xmm11,xmm4,6 + add rbx,r9 + add r9,rdi + vpxor xmm8,xmm8,xmm9 + mov r13,rbx + add r14,r9 + vpsllq xmm10,xmm4,3 + shrd r13,r13,23 + mov r9,r14 + vpaddq xmm5,xmm5,xmm8 + mov r12,rcx + shrd r14,r14,5 + vpsrlq xmm9,xmm4,19 + xor r13,rbx + xor r12,rdx + vpxor xmm11,xmm11,xmm10 + shrd r13,r13,4 + xor r14,r9 + vpsllq xmm10,xmm10,42 + and r12,rbx + xor r13,rbx + vpxor xmm11,xmm11,xmm9 + add r8,QWORD[88+rsp] + mov rdi,r9 + vpsrlq xmm9,xmm9,42 + xor r12,rdx + shrd r14,r14,6 + vpxor xmm11,xmm11,xmm10 + xor rdi,r10 + add r8,r12 + vpxor xmm11,xmm11,xmm9 + shrd r13,r13,14 + and r15,rdi + vpaddq xmm5,xmm5,xmm11 + xor r14,r9 + add r8,r13 + vpaddq xmm10,xmm5,XMMWORD[32+rbp] + xor r15,r10 + shrd r14,r14,28 + add rax,r8 + add r8,r15 + mov r13,rax + add r14,r8 + vmovdqa XMMWORD[80+rsp],xmm10 + vpalignr xmm8,xmm7,xmm6,8 + shrd r13,r13,23 + mov r8,r14 + vpalignr xmm11,xmm3,xmm2,8 + mov r12,rbx + shrd r14,r14,5 + vpsrlq xmm10,xmm8,1 + xor r13,rax + xor r12,rcx + vpaddq xmm6,xmm6,xmm11 + shrd r13,r13,4 + xor r14,r8 + vpsrlq xmm11,xmm8,7 + and r12,rax + xor r13,rax + vpsllq xmm9,xmm8,56 + add rdx,QWORD[96+rsp] + mov r15,r8 + vpxor xmm8,xmm11,xmm10 + xor r12,rcx + shrd r14,r14,6 + vpsrlq xmm10,xmm10,7 + xor r15,r9 + add rdx,r12 + vpxor xmm8,xmm8,xmm9 + shrd r13,r13,14 + and rdi,r15 + vpsllq xmm9,xmm9,7 + xor r14,r8 + add rdx,r13 + vpxor xmm8,xmm8,xmm10 + xor rdi,r9 + shrd r14,r14,28 + vpsrlq xmm11,xmm5,6 + add r11,rdx + add rdx,rdi + vpxor xmm8,xmm8,xmm9 + mov r13,r11 + add r14,rdx + vpsllq xmm10,xmm5,3 + shrd r13,r13,23 + mov rdx,r14 + vpaddq xmm6,xmm6,xmm8 + mov r12,rax + shrd r14,r14,5 + vpsrlq xmm9,xmm5,19 + xor r13,r11 + xor r12,rbx + vpxor xmm11,xmm11,xmm10 + shrd r13,r13,4 + xor r14,rdx + vpsllq xmm10,xmm10,42 + and r12,r11 + xor r13,r11 + vpxor xmm11,xmm11,xmm9 + add rcx,QWORD[104+rsp] + mov rdi,rdx + vpsrlq xmm9,xmm9,42 + xor r12,rbx + shrd r14,r14,6 + vpxor xmm11,xmm11,xmm10 + xor rdi,r8 + add rcx,r12 + vpxor xmm11,xmm11,xmm9 + shrd r13,r13,14 + and r15,rdi + vpaddq xmm6,xmm6,xmm11 + xor r14,rdx + add rcx,r13 + vpaddq xmm10,xmm6,XMMWORD[64+rbp] + xor r15,r8 + shrd r14,r14,28 + add r10,rcx + add rcx,r15 + mov r13,r10 + add r14,rcx + vmovdqa XMMWORD[96+rsp],xmm10 + vpalignr xmm8,xmm0,xmm7,8 + shrd r13,r13,23 + mov rcx,r14 + vpalignr xmm11,xmm4,xmm3,8 + mov r12,r11 + shrd r14,r14,5 + vpsrlq xmm10,xmm8,1 + xor r13,r10 + xor r12,rax + vpaddq xmm7,xmm7,xmm11 + shrd r13,r13,4 + xor r14,rcx + vpsrlq xmm11,xmm8,7 + and r12,r10 + xor r13,r10 + vpsllq xmm9,xmm8,56 + add rbx,QWORD[112+rsp] + mov r15,rcx + vpxor xmm8,xmm11,xmm10 + xor r12,rax + shrd r14,r14,6 + vpsrlq xmm10,xmm10,7 + xor r15,rdx + add rbx,r12 + vpxor xmm8,xmm8,xmm9 + shrd r13,r13,14 + and rdi,r15 + vpsllq xmm9,xmm9,7 + xor r14,rcx + add rbx,r13 + vpxor xmm8,xmm8,xmm10 + xor rdi,rdx + shrd r14,r14,28 + vpsrlq xmm11,xmm6,6 + add r9,rbx + add rbx,rdi + vpxor xmm8,xmm8,xmm9 + mov r13,r9 + add r14,rbx + vpsllq xmm10,xmm6,3 + shrd r13,r13,23 + mov rbx,r14 + vpaddq xmm7,xmm7,xmm8 + mov r12,r10 + shrd r14,r14,5 + vpsrlq xmm9,xmm6,19 + xor r13,r9 + xor r12,r11 + vpxor xmm11,xmm11,xmm10 + shrd r13,r13,4 + xor r14,rbx + vpsllq xmm10,xmm10,42 + and r12,r9 + xor r13,r9 + vpxor xmm11,xmm11,xmm9 + add rax,QWORD[120+rsp] + mov rdi,rbx + vpsrlq xmm9,xmm9,42 + xor r12,r11 + shrd r14,r14,6 + vpxor xmm11,xmm11,xmm10 + xor rdi,rcx + add rax,r12 + vpxor xmm11,xmm11,xmm9 + shrd r13,r13,14 + and r15,rdi + vpaddq xmm7,xmm7,xmm11 + xor r14,rbx + add rax,r13 + vpaddq xmm10,xmm7,XMMWORD[96+rbp] + xor r15,rcx + shrd r14,r14,28 + add r8,rax + add rax,r15 + mov r13,r8 + add r14,rax + vmovdqa XMMWORD[112+rsp],xmm10 + cmp BYTE[135+rbp],0 + jne NEAR $L$avx_00_47 + shrd r13,r13,23 + mov rax,r14 + mov r12,r9 + shrd r14,r14,5 + xor r13,r8 + xor r12,r10 + shrd r13,r13,4 + xor r14,rax + and r12,r8 + xor r13,r8 + add r11,QWORD[rsp] + mov r15,rax + xor r12,r10 + shrd r14,r14,6 + xor r15,rbx + add r11,r12 + shrd r13,r13,14 + and rdi,r15 + xor r14,rax + add r11,r13 + xor rdi,rbx + shrd r14,r14,28 + add rdx,r11 + add r11,rdi + mov r13,rdx + add r14,r11 + shrd r13,r13,23 + mov r11,r14 + mov r12,r8 + shrd r14,r14,5 + xor r13,rdx + xor r12,r9 + shrd r13,r13,4 + xor r14,r11 + and r12,rdx + xor r13,rdx + add r10,QWORD[8+rsp] + mov rdi,r11 + xor r12,r9 + shrd r14,r14,6 + xor rdi,rax + add r10,r12 + shrd r13,r13,14 + and r15,rdi + xor r14,r11 + add r10,r13 + xor r15,rax + shrd r14,r14,28 + add rcx,r10 + add r10,r15 + mov r13,rcx + add r14,r10 + shrd r13,r13,23 + mov r10,r14 + mov r12,rdx + shrd r14,r14,5 + xor r13,rcx + xor r12,r8 + shrd r13,r13,4 + xor r14,r10 + and r12,rcx + xor r13,rcx + add r9,QWORD[16+rsp] + mov r15,r10 + xor r12,r8 + shrd r14,r14,6 + xor r15,r11 + add r9,r12 + shrd r13,r13,14 + and rdi,r15 + xor r14,r10 + add r9,r13 + xor rdi,r11 + shrd r14,r14,28 + add rbx,r9 + add r9,rdi + mov r13,rbx + add r14,r9 + shrd r13,r13,23 + mov r9,r14 + mov r12,rcx + shrd r14,r14,5 + xor r13,rbx + xor r12,rdx + shrd r13,r13,4 + xor r14,r9 + and r12,rbx + xor r13,rbx + add r8,QWORD[24+rsp] + mov rdi,r9 + xor r12,rdx + shrd r14,r14,6 + xor rdi,r10 + add r8,r12 + shrd r13,r13,14 + and r15,rdi + xor r14,r9 + add r8,r13 + xor r15,r10 + shrd r14,r14,28 + add rax,r8 + add r8,r15 + mov r13,rax + add r14,r8 + shrd r13,r13,23 + mov r8,r14 + mov r12,rbx + shrd r14,r14,5 + xor r13,rax + xor r12,rcx + shrd r13,r13,4 + xor r14,r8 + and r12,rax + xor r13,rax + add rdx,QWORD[32+rsp] + mov r15,r8 + xor r12,rcx + shrd r14,r14,6 + xor r15,r9 + add rdx,r12 + shrd r13,r13,14 + and rdi,r15 + xor r14,r8 + add rdx,r13 + xor rdi,r9 + shrd r14,r14,28 + add r11,rdx + add rdx,rdi + mov r13,r11 + add r14,rdx + shrd r13,r13,23 + mov rdx,r14 + mov r12,rax + shrd r14,r14,5 + xor r13,r11 + xor r12,rbx + shrd r13,r13,4 + xor r14,rdx + and r12,r11 + xor r13,r11 + add rcx,QWORD[40+rsp] + mov rdi,rdx + xor r12,rbx + shrd r14,r14,6 + xor rdi,r8 + add rcx,r12 + shrd r13,r13,14 + and r15,rdi + xor r14,rdx + add rcx,r13 + xor r15,r8 + shrd r14,r14,28 + add r10,rcx + add rcx,r15 + mov r13,r10 + add r14,rcx + shrd r13,r13,23 + mov rcx,r14 + mov r12,r11 + shrd r14,r14,5 + xor r13,r10 + xor r12,rax + shrd r13,r13,4 + xor r14,rcx + and r12,r10 + xor r13,r10 + add rbx,QWORD[48+rsp] + mov r15,rcx + xor r12,rax + shrd r14,r14,6 + xor r15,rdx + add rbx,r12 + shrd r13,r13,14 + and rdi,r15 + xor r14,rcx + add rbx,r13 + xor rdi,rdx + shrd r14,r14,28 + add r9,rbx + add rbx,rdi + mov r13,r9 + add r14,rbx + shrd r13,r13,23 + mov rbx,r14 + mov r12,r10 + shrd r14,r14,5 + xor r13,r9 + xor r12,r11 + shrd r13,r13,4 + xor r14,rbx + and r12,r9 + xor r13,r9 + add rax,QWORD[56+rsp] + mov rdi,rbx + xor r12,r11 + shrd r14,r14,6 + xor rdi,rcx + add rax,r12 + shrd r13,r13,14 + and r15,rdi + xor r14,rbx + add rax,r13 + xor r15,rcx + shrd r14,r14,28 + add r8,rax + add rax,r15 + mov r13,r8 + add r14,rax + shrd r13,r13,23 + mov rax,r14 + mov r12,r9 + shrd r14,r14,5 + xor r13,r8 + xor r12,r10 + shrd r13,r13,4 + xor r14,rax + and r12,r8 + xor r13,r8 + add r11,QWORD[64+rsp] + mov r15,rax + xor r12,r10 + shrd r14,r14,6 + xor r15,rbx + add r11,r12 + shrd r13,r13,14 + and rdi,r15 + xor r14,rax + add r11,r13 + xor rdi,rbx + shrd r14,r14,28 + add rdx,r11 + add r11,rdi + mov r13,rdx + add r14,r11 + shrd r13,r13,23 + mov r11,r14 + mov r12,r8 + shrd r14,r14,5 + xor r13,rdx + xor r12,r9 + shrd r13,r13,4 + xor r14,r11 + and r12,rdx + xor r13,rdx + add r10,QWORD[72+rsp] + mov rdi,r11 + xor r12,r9 + shrd r14,r14,6 + xor rdi,rax + add r10,r12 + shrd r13,r13,14 + and r15,rdi + xor r14,r11 + add r10,r13 + xor r15,rax + shrd r14,r14,28 + add rcx,r10 + add r10,r15 + mov r13,rcx + add r14,r10 + shrd r13,r13,23 + mov r10,r14 + mov r12,rdx + shrd r14,r14,5 + xor r13,rcx + xor r12,r8 + shrd r13,r13,4 + xor r14,r10 + and r12,rcx + xor r13,rcx + add r9,QWORD[80+rsp] + mov r15,r10 + xor r12,r8 + shrd r14,r14,6 + xor r15,r11 + add r9,r12 + shrd r13,r13,14 + and rdi,r15 + xor r14,r10 + add r9,r13 + xor rdi,r11 + shrd r14,r14,28 + add rbx,r9 + add r9,rdi + mov r13,rbx + add r14,r9 + shrd r13,r13,23 + mov r9,r14 + mov r12,rcx + shrd r14,r14,5 + xor r13,rbx + xor r12,rdx + shrd r13,r13,4 + xor r14,r9 + and r12,rbx + xor r13,rbx + add r8,QWORD[88+rsp] + mov rdi,r9 + xor r12,rdx + shrd r14,r14,6 + xor rdi,r10 + add r8,r12 + shrd r13,r13,14 + and r15,rdi + xor r14,r9 + add r8,r13 + xor r15,r10 + shrd r14,r14,28 + add rax,r8 + add r8,r15 + mov r13,rax + add r14,r8 + shrd r13,r13,23 + mov r8,r14 + mov r12,rbx + shrd r14,r14,5 + xor r13,rax + xor r12,rcx + shrd r13,r13,4 + xor r14,r8 + and r12,rax + xor r13,rax + add rdx,QWORD[96+rsp] + mov r15,r8 + xor r12,rcx + shrd r14,r14,6 + xor r15,r9 + add rdx,r12 + shrd r13,r13,14 + and rdi,r15 + xor r14,r8 + add rdx,r13 + xor rdi,r9 + shrd r14,r14,28 + add r11,rdx + add rdx,rdi + mov r13,r11 + add r14,rdx + shrd r13,r13,23 + mov rdx,r14 + mov r12,rax + shrd r14,r14,5 + xor r13,r11 + xor r12,rbx + shrd r13,r13,4 + xor r14,rdx + and r12,r11 + xor r13,r11 + add rcx,QWORD[104+rsp] + mov rdi,rdx + xor r12,rbx + shrd r14,r14,6 + xor rdi,r8 + add rcx,r12 + shrd r13,r13,14 + and r15,rdi + xor r14,rdx + add rcx,r13 + xor r15,r8 + shrd r14,r14,28 + add r10,rcx + add rcx,r15 + mov r13,r10 + add r14,rcx + shrd r13,r13,23 + mov rcx,r14 + mov r12,r11 + shrd r14,r14,5 + xor r13,r10 + xor r12,rax + shrd r13,r13,4 + xor r14,rcx + and r12,r10 + xor r13,r10 + add rbx,QWORD[112+rsp] + mov r15,rcx + xor r12,rax + shrd r14,r14,6 + xor r15,rdx + add rbx,r12 + shrd r13,r13,14 + and rdi,r15 + xor r14,rcx + add rbx,r13 + xor rdi,rdx + shrd r14,r14,28 + add r9,rbx + add rbx,rdi + mov r13,r9 + add r14,rbx + shrd r13,r13,23 + mov rbx,r14 + mov r12,r10 + shrd r14,r14,5 + xor r13,r9 + xor r12,r11 + shrd r13,r13,4 + xor r14,rbx + and r12,r9 + xor r13,r9 + add rax,QWORD[120+rsp] + mov rdi,rbx + xor r12,r11 + shrd r14,r14,6 + xor rdi,rcx + add rax,r12 + shrd r13,r13,14 + and r15,rdi + xor r14,rbx + add rax,r13 + xor r15,rcx + shrd r14,r14,28 + add r8,rax + add rax,r15 + mov r13,r8 + add r14,rax + mov rdi,QWORD[((128+0))+rsp] + mov rax,r14 + + add rax,QWORD[rdi] + lea rsi,[128+rsi] + add rbx,QWORD[8+rdi] + add rcx,QWORD[16+rdi] + add rdx,QWORD[24+rdi] + add r8,QWORD[32+rdi] + add r9,QWORD[40+rdi] + add r10,QWORD[48+rdi] + add r11,QWORD[56+rdi] + + cmp rsi,QWORD[((128+16))+rsp] + + mov QWORD[rdi],rax + mov QWORD[8+rdi],rbx + mov QWORD[16+rdi],rcx + mov QWORD[24+rdi],rdx + mov QWORD[32+rdi],r8 + mov QWORD[40+rdi],r9 + mov QWORD[48+rdi],r10 + mov QWORD[56+rdi],r11 + jb NEAR $L$loop_avx + + mov rsi,QWORD[152+rsp] + + vzeroupper + movaps xmm6,XMMWORD[((128+32))+rsp] + movaps xmm7,XMMWORD[((128+48))+rsp] + movaps xmm8,XMMWORD[((128+64))+rsp] + movaps xmm9,XMMWORD[((128+80))+rsp] + movaps xmm10,XMMWORD[((128+96))+rsp] + movaps xmm11,XMMWORD[((128+112))+rsp] + mov r15,QWORD[((-48))+rsi] + + mov r14,QWORD[((-40))+rsi] + + mov r13,QWORD[((-32))+rsi] + + mov r12,QWORD[((-24))+rsi] + + mov rbp,QWORD[((-16))+rsi] + + mov rbx,QWORD[((-8))+rsi] + + lea rsp,[rsi] + +$L$epilogue_avx: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_sha512_block_data_order_avx: +EXTERN __imp_RtlVirtualUnwind + +ALIGN 16 +se_handler: + push rsi + push rdi + push rbx + push rbp + push r12 + push r13 + push r14 + push r15 + pushfq + sub rsp,64 + + mov rax,QWORD[120+r8] + mov rbx,QWORD[248+r8] + + mov rsi,QWORD[8+r9] + mov r11,QWORD[56+r9] + + mov r10d,DWORD[r11] + lea r10,[r10*1+rsi] + cmp rbx,r10 + jb NEAR $L$in_prologue + + mov rax,QWORD[152+r8] + + mov r10d,DWORD[4+r11] + lea r10,[r10*1+rsi] + cmp rbx,r10 + jae NEAR $L$in_prologue + mov rsi,rax + mov rax,QWORD[((128+24))+rax] + + mov rbx,QWORD[((-8))+rax] + mov rbp,QWORD[((-16))+rax] + mov r12,QWORD[((-24))+rax] + mov r13,QWORD[((-32))+rax] + mov r14,QWORD[((-40))+rax] + mov r15,QWORD[((-48))+rax] + mov QWORD[144+r8],rbx + mov QWORD[160+r8],rbp + mov QWORD[216+r8],r12 + mov QWORD[224+r8],r13 + mov QWORD[232+r8],r14 + mov QWORD[240+r8],r15 + + lea r10,[$L$epilogue] + cmp rbx,r10 + jb NEAR $L$in_prologue + + lea rsi,[((128+32))+rsi] + lea rdi,[512+r8] + mov ecx,12 + DD 0xa548f3fc + +$L$in_prologue: + mov rdi,QWORD[8+rax] + mov rsi,QWORD[16+rax] + mov QWORD[152+r8],rax + mov QWORD[168+r8],rsi + mov QWORD[176+r8],rdi + + mov rdi,QWORD[40+r9] + mov rsi,r8 + mov ecx,154 + DD 0xa548f3fc + + mov rsi,r9 + xor rcx,rcx + mov rdx,QWORD[8+rsi] + mov r8,QWORD[rsi] + mov r9,QWORD[16+rsi] + mov r10,QWORD[40+rsi] + lea r11,[56+rsi] + lea r12,[24+rsi] + mov QWORD[32+rsp],r10 + mov QWORD[40+rsp],r11 + mov QWORD[48+rsp],r12 + mov QWORD[56+rsp],rcx + call QWORD[__imp_RtlVirtualUnwind] + + mov eax,1 + add rsp,64 + popfq + pop r15 + pop r14 + pop r13 + pop r12 + pop rbp + pop rbx + pop rdi + pop rsi + ret + +section .pdata rdata align=4 +ALIGN 4 + DD $L$SEH_begin_sha512_block_data_order_nohw wrt ..imagebase + DD $L$SEH_end_sha512_block_data_order_nohw wrt ..imagebase + DD $L$SEH_info_sha512_block_data_order_nohw wrt ..imagebase + DD $L$SEH_begin_sha512_block_data_order_avx wrt ..imagebase + DD $L$SEH_end_sha512_block_data_order_avx wrt ..imagebase + DD $L$SEH_info_sha512_block_data_order_avx wrt ..imagebase +section .xdata rdata align=8 +ALIGN 8 +$L$SEH_info_sha512_block_data_order_nohw: + DB 9,0,0,0 + DD se_handler wrt ..imagebase + DD $L$prologue wrt ..imagebase,$L$epilogue wrt ..imagebase +$L$SEH_info_sha512_block_data_order_avx: + DB 9,0,0,0 + DD se_handler wrt ..imagebase + DD $L$prologue_avx wrt ..imagebase,$L$epilogue_avx wrt ..imagebase +%else +; Work around https://bugzilla.nasm.us/show_bug.cgi?id=3392738 +ret +%endif diff --git a/http/vendor/ring/pregenerated/sha512-x86_64-nasm.o b/http/vendor/ring/pregenerated/sha512-x86_64-nasm.o new file mode 100644 index 0000000..94e2ffe Binary files /dev/null and b/http/vendor/ring/pregenerated/sha512-x86_64-nasm.o differ diff --git a/http/vendor/ring/pregenerated/vpaes-armv7-linux32.S b/http/vendor/ring/pregenerated/vpaes-armv7-linux32.S new file mode 100644 index 0000000..bdf08a2 --- /dev/null +++ b/http/vendor/ring/pregenerated/vpaes-armv7-linux32.S @@ -0,0 +1,722 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_ARM) && defined(__ELF__) +.syntax unified + +.arch armv7-a +.fpu neon + +#if defined(__thumb2__) +.thumb +#else +.code 32 +#endif + +.text + +.type _vpaes_consts,%object +.align 7 @ totally strategic alignment +_vpaes_consts: +.Lk_mc_forward:@ mc_forward +.quad 0x0407060500030201, 0x0C0F0E0D080B0A09 +.quad 0x080B0A0904070605, 0x000302010C0F0E0D +.quad 0x0C0F0E0D080B0A09, 0x0407060500030201 +.quad 0x000302010C0F0E0D, 0x080B0A0904070605 +.Lk_mc_backward:@ mc_backward +.quad 0x0605040702010003, 0x0E0D0C0F0A09080B +.quad 0x020100030E0D0C0F, 0x0A09080B06050407 +.quad 0x0E0D0C0F0A09080B, 0x0605040702010003 +.quad 0x0A09080B06050407, 0x020100030E0D0C0F +.Lk_sr:@ sr +.quad 0x0706050403020100, 0x0F0E0D0C0B0A0908 +.quad 0x030E09040F0A0500, 0x0B06010C07020D08 +.quad 0x0F060D040B020900, 0x070E050C030A0108 +.quad 0x0B0E0104070A0D00, 0x0306090C0F020508 + +@ +@ "Hot" constants +@ +.Lk_inv:@ inv, inva +.quad 0x0E05060F0D080180, 0x040703090A0B0C02 +.quad 0x01040A060F0B0780, 0x030D0E0C02050809 +.Lk_ipt:@ input transform (lo, hi) +.quad 0xC2B2E8985A2A7000, 0xCABAE09052227808 +.quad 0x4C01307D317C4D00, 0xCD80B1FCB0FDCC81 +.Lk_sbo:@ sbou, sbot +.quad 0xD0D26D176FBDC700, 0x15AABF7AC502A878 +.quad 0xCFE474A55FBB6A00, 0x8E1E90D1412B35FA +.Lk_sb1:@ sb1u, sb1t +.quad 0x3618D415FAE22300, 0x3BF7CCC10D2ED9EF +.quad 0xB19BE18FCB503E00, 0xA5DF7A6E142AF544 +.Lk_sb2:@ sb2u, sb2t +.quad 0x69EB88400AE12900, 0xC2A163C8AB82234A +.quad 0xE27A93C60B712400, 0x5EB7E955BC982FCD + +.byte 86,101,99,116,111,114,32,80,101,114,109,117,116,97,116,105,111,110,32,65,69,83,32,102,111,114,32,65,82,77,118,55,32,78,69,79,78,44,32,77,105,107,101,32,72,97,109,98,117,114,103,32,40,83,116,97,110,102,111,114,100,32,85,110,105,118,101,114,115,105,116,121,41,0 +.align 2 +.size _vpaes_consts,.-_vpaes_consts +.align 6 +@@ +@@ _aes_preheat +@@ +@@ Fills q9-q15 as specified below. +@@ +.type _vpaes_preheat,%function +.align 4 +_vpaes_preheat: + adr r10, .Lk_inv + vmov.i8 q9, #0x0f @ .Lk_s0F + vld1.64 {q10,q11}, [r10]! @ .Lk_inv + add r10, r10, #64 @ Skip .Lk_ipt, .Lk_sbo + vld1.64 {q12,q13}, [r10]! @ .Lk_sb1 + vld1.64 {q14,q15}, [r10] @ .Lk_sb2 + bx lr + +@@ +@@ _aes_encrypt_core +@@ +@@ AES-encrypt q0. +@@ +@@ Inputs: +@@ q0 = input +@@ q9-q15 as in _vpaes_preheat +@@ [r2] = scheduled keys +@@ +@@ Output in q0 +@@ Clobbers q1-q5, r8-r11 +@@ Preserves q6-q8 so you get some local vectors +@@ +@@ +.type _vpaes_encrypt_core,%function +.align 4 +_vpaes_encrypt_core: + mov r9, r2 + ldr r8, [r2,#240] @ pull rounds + adr r11, .Lk_ipt + @ vmovdqa .Lk_ipt(%rip), %xmm2 # iptlo + @ vmovdqa .Lk_ipt+16(%rip), %xmm3 # ipthi + vld1.64 {q2, q3}, [r11] + adr r11, .Lk_mc_forward+16 + vld1.64 {q5}, [r9]! @ vmovdqu (%r9), %xmm5 # round0 key + vand q1, q0, q9 @ vpand %xmm9, %xmm0, %xmm1 + vshr.u8 q0, q0, #4 @ vpsrlb $4, %xmm0, %xmm0 + vtbl.8 d2, {q2}, d2 @ vpshufb %xmm1, %xmm2, %xmm1 + vtbl.8 d3, {q2}, d3 + vtbl.8 d4, {q3}, d0 @ vpshufb %xmm0, %xmm3, %xmm2 + vtbl.8 d5, {q3}, d1 + veor q0, q1, q5 @ vpxor %xmm5, %xmm1, %xmm0 + veor q0, q0, q2 @ vpxor %xmm2, %xmm0, %xmm0 + + @ .Lenc_entry ends with a bnz instruction which is normally paired with + @ subs in .Lenc_loop. + tst r8, r8 + b .Lenc_entry + +.align 4 +.Lenc_loop: + @ middle of middle round + add r10, r11, #0x40 + vtbl.8 d8, {q13}, d4 @ vpshufb %xmm2, %xmm13, %xmm4 # 4 = sb1u + vtbl.8 d9, {q13}, d5 + vld1.64 {q1}, [r11]! @ vmovdqa -0x40(%r11,%r10), %xmm1 # .Lk_mc_forward[] + vtbl.8 d0, {q12}, d6 @ vpshufb %xmm3, %xmm12, %xmm0 # 0 = sb1t + vtbl.8 d1, {q12}, d7 + veor q4, q4, q5 @ vpxor %xmm5, %xmm4, %xmm4 # 4 = sb1u + k + vtbl.8 d10, {q15}, d4 @ vpshufb %xmm2, %xmm15, %xmm5 # 4 = sb2u + vtbl.8 d11, {q15}, d5 + veor q0, q0, q4 @ vpxor %xmm4, %xmm0, %xmm0 # 0 = A + vtbl.8 d4, {q14}, d6 @ vpshufb %xmm3, %xmm14, %xmm2 # 2 = sb2t + vtbl.8 d5, {q14}, d7 + vld1.64 {q4}, [r10] @ vmovdqa (%r11,%r10), %xmm4 # .Lk_mc_backward[] + vtbl.8 d6, {q0}, d2 @ vpshufb %xmm1, %xmm0, %xmm3 # 0 = B + vtbl.8 d7, {q0}, d3 + veor q2, q2, q5 @ vpxor %xmm5, %xmm2, %xmm2 # 2 = 2A + @ Write to q5 instead of q0, so the table and destination registers do + @ not overlap. + vtbl.8 d10, {q0}, d8 @ vpshufb %xmm4, %xmm0, %xmm0 # 3 = D + vtbl.8 d11, {q0}, d9 + veor q3, q3, q2 @ vpxor %xmm2, %xmm3, %xmm3 # 0 = 2A+B + vtbl.8 d8, {q3}, d2 @ vpshufb %xmm1, %xmm3, %xmm4 # 0 = 2B+C + vtbl.8 d9, {q3}, d3 + @ Here we restore the original q0/q5 usage. + veor q0, q5, q3 @ vpxor %xmm3, %xmm0, %xmm0 # 3 = 2A+B+D + and r11, r11, #~(1<<6) @ and $0x30, %r11 # ... mod 4 + veor q0, q0, q4 @ vpxor %xmm4, %xmm0, %xmm0 # 0 = 2A+3B+C+D + subs r8, r8, #1 @ nr-- + +.Lenc_entry: + @ top of round + vand q1, q0, q9 @ vpand %xmm0, %xmm9, %xmm1 # 0 = k + vshr.u8 q0, q0, #4 @ vpsrlb $4, %xmm0, %xmm0 # 1 = i + vtbl.8 d10, {q11}, d2 @ vpshufb %xmm1, %xmm11, %xmm5 # 2 = a/k + vtbl.8 d11, {q11}, d3 + veor q1, q1, q0 @ vpxor %xmm0, %xmm1, %xmm1 # 0 = j + vtbl.8 d6, {q10}, d0 @ vpshufb %xmm0, %xmm10, %xmm3 # 3 = 1/i + vtbl.8 d7, {q10}, d1 + vtbl.8 d8, {q10}, d2 @ vpshufb %xmm1, %xmm10, %xmm4 # 4 = 1/j + vtbl.8 d9, {q10}, d3 + veor q3, q3, q5 @ vpxor %xmm5, %xmm3, %xmm3 # 3 = iak = 1/i + a/k + veor q4, q4, q5 @ vpxor %xmm5, %xmm4, %xmm4 # 4 = jak = 1/j + a/k + vtbl.8 d4, {q10}, d6 @ vpshufb %xmm3, %xmm10, %xmm2 # 2 = 1/iak + vtbl.8 d5, {q10}, d7 + vtbl.8 d6, {q10}, d8 @ vpshufb %xmm4, %xmm10, %xmm3 # 3 = 1/jak + vtbl.8 d7, {q10}, d9 + veor q2, q2, q1 @ vpxor %xmm1, %xmm2, %xmm2 # 2 = io + veor q3, q3, q0 @ vpxor %xmm0, %xmm3, %xmm3 # 3 = jo + vld1.64 {q5}, [r9]! @ vmovdqu (%r9), %xmm5 + bne .Lenc_loop + + @ middle of last round + add r10, r11, #0x80 + + adr r11, .Lk_sbo + @ Read to q1 instead of q4, so the vtbl.8 instruction below does not + @ overlap table and destination registers. + vld1.64 {q1}, [r11]! @ vmovdqa -0x60(%r10), %xmm4 # 3 : sbou + vld1.64 {q0}, [r11] @ vmovdqa -0x50(%r10), %xmm0 # 0 : sbot .Lk_sbo+16 + vtbl.8 d8, {q1}, d4 @ vpshufb %xmm2, %xmm4, %xmm4 # 4 = sbou + vtbl.8 d9, {q1}, d5 + vld1.64 {q1}, [r10] @ vmovdqa 0x40(%r11,%r10), %xmm1 # .Lk_sr[] + @ Write to q2 instead of q0 below, to avoid overlapping table and + @ destination registers. + vtbl.8 d4, {q0}, d6 @ vpshufb %xmm3, %xmm0, %xmm0 # 0 = sb1t + vtbl.8 d5, {q0}, d7 + veor q4, q4, q5 @ vpxor %xmm5, %xmm4, %xmm4 # 4 = sb1u + k + veor q2, q2, q4 @ vpxor %xmm4, %xmm0, %xmm0 # 0 = A + @ Here we restore the original q0/q2 usage. + vtbl.8 d0, {q2}, d2 @ vpshufb %xmm1, %xmm0, %xmm0 + vtbl.8 d1, {q2}, d3 + bx lr +.size _vpaes_encrypt_core,.-_vpaes_encrypt_core +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +@@ @@ +@@ AES key schedule @@ +@@ @@ +@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + +@ This function diverges from both x86_64 and armv7 in which constants are +@ pinned. x86_64 has a common preheat function for all operations. aarch64 +@ separates them because it has enough registers to pin nearly all constants. +@ armv7 does not have enough registers, but needing explicit loads and stores +@ also complicates using x86_64's register allocation directly. +@ +@ We pin some constants for convenience and leave q14 and q15 free to load +@ others on demand. + +@ +@ Key schedule constants +@ +.type _vpaes_key_consts,%object +.align 4 +_vpaes_key_consts: +.Lk_rcon:@ rcon +.quad 0x1F8391B9AF9DEEB6, 0x702A98084D7C7D81 + +.Lk_opt:@ output transform +.quad 0xFF9F4929D6B66000, 0xF7974121DEBE6808 +.quad 0x01EDBD5150BCEC00, 0xE10D5DB1B05C0CE0 +.Lk_deskew:@ deskew tables: inverts the sbox's "skew" +.quad 0x07E4A34047A4E300, 0x1DFEB95A5DBEF91A +.quad 0x5F36B5DC83EA6900, 0x2841C2ABF49D1E77 +.size _vpaes_key_consts,.-_vpaes_key_consts + +.type _vpaes_key_preheat,%function +.align 4 +_vpaes_key_preheat: + adr r11, .Lk_rcon + vmov.i8 q12, #0x5b @ .Lk_s63 + adr r10, .Lk_inv @ Must be aligned to 8 mod 16. + vmov.i8 q9, #0x0f @ .Lk_s0F + vld1.64 {q10,q11}, [r10] @ .Lk_inv + vld1.64 {q8}, [r11] @ .Lk_rcon + bx lr +.size _vpaes_key_preheat,.-_vpaes_key_preheat + +.type _vpaes_schedule_core,%function +.align 4 +_vpaes_schedule_core: + @ We only need to save lr, but ARM requires an 8-byte stack alignment, + @ so save an extra register. + stmdb sp!, {r3,lr} + + bl _vpaes_key_preheat @ load the tables + + adr r11, .Lk_ipt @ Must be aligned to 8 mod 16. + vld1.64 {q0}, [r0]! @ vmovdqu (%rdi), %xmm0 # load key (unaligned) + + @ input transform + @ Use q4 here rather than q3 so .Lschedule_am_decrypting does not + @ overlap table and destination. + vmov q4, q0 @ vmovdqa %xmm0, %xmm3 + bl _vpaes_schedule_transform + adr r10, .Lk_sr @ Must be aligned to 8 mod 16. + vmov q7, q0 @ vmovdqa %xmm0, %xmm7 + + add r8, r8, r10 + + @ encrypting, output zeroth round key after transform + vst1.64 {q0}, [r2] @ vmovdqu %xmm0, (%rdx) + + @ *ring*: Decryption removed. + +.Lschedule_go: + cmp r1, #192 @ cmp $192, %esi + bhi .Lschedule_256 + @ 128: fall though + +@@ +@@ .schedule_128 +@@ +@@ 128-bit specific part of key schedule. +@@ +@@ This schedule is really simple, because all its parts +@@ are accomplished by the subroutines. +@@ +.Lschedule_128: + mov r0, #10 @ mov $10, %esi + +.Loop_schedule_128: + bl _vpaes_schedule_round + subs r0, r0, #1 @ dec %esi + beq .Lschedule_mangle_last + bl _vpaes_schedule_mangle @ write output + b .Loop_schedule_128 + +@@ +@@ .aes_schedule_256 +@@ +@@ 256-bit specific part of key schedule. +@@ +@@ The structure here is very similar to the 128-bit +@@ schedule, but with an additional "low side" in +@@ q6. The low side's rounds are the same as the +@@ high side's, except no rcon and no rotation. +@@ +.align 4 +.Lschedule_256: + vld1.64 {q0}, [r0] @ vmovdqu 16(%rdi),%xmm0 # load key part 2 (unaligned) + bl _vpaes_schedule_transform @ input transform + mov r0, #7 @ mov $7, %esi + +.Loop_schedule_256: + bl _vpaes_schedule_mangle @ output low result + vmov q6, q0 @ vmovdqa %xmm0, %xmm6 # save cur_lo in xmm6 + + @ high round + bl _vpaes_schedule_round + subs r0, r0, #1 @ dec %esi + beq .Lschedule_mangle_last + bl _vpaes_schedule_mangle + + @ low round. swap xmm7 and xmm6 + vdup.32 q0, d1[1] @ vpshufd $0xFF, %xmm0, %xmm0 + vmov.i8 q4, #0 + vmov q5, q7 @ vmovdqa %xmm7, %xmm5 + vmov q7, q6 @ vmovdqa %xmm6, %xmm7 + bl _vpaes_schedule_low_round + vmov q7, q5 @ vmovdqa %xmm5, %xmm7 + + b .Loop_schedule_256 + +@@ +@@ .aes_schedule_mangle_last +@@ +@@ Mangler for last round of key schedule +@@ Mangles q0 +@@ when encrypting, outputs out(q0) ^ 63 +@@ when decrypting, outputs unskew(q0) +@@ +@@ Always called right before return... jumps to cleanup and exits +@@ +.align 4 +.Lschedule_mangle_last: + @ schedule last round key from xmm0 + adr r11, .Lk_deskew @ lea .Lk_deskew(%rip),%r11 # prepare to deskew + + @ encrypting + vld1.64 {q1}, [r8] @ vmovdqa (%r8,%r10),%xmm1 + adr r11, .Lk_opt @ lea .Lk_opt(%rip), %r11 # prepare to output transform + add r2, r2, #32 @ add $32, %rdx + vmov q2, q0 + vtbl.8 d0, {q2}, d2 @ vpshufb %xmm1, %xmm0, %xmm0 # output permute + vtbl.8 d1, {q2}, d3 + +.Lschedule_mangle_last_dec: + sub r2, r2, #16 @ add $-16, %rdx + veor q0, q0, q12 @ vpxor .Lk_s63(%rip), %xmm0, %xmm0 + bl _vpaes_schedule_transform @ output transform + vst1.64 {q0}, [r2] @ vmovdqu %xmm0, (%rdx) # save last key + + @ cleanup + veor q0, q0, q0 @ vpxor %xmm0, %xmm0, %xmm0 + veor q1, q1, q1 @ vpxor %xmm1, %xmm1, %xmm1 + veor q2, q2, q2 @ vpxor %xmm2, %xmm2, %xmm2 + veor q3, q3, q3 @ vpxor %xmm3, %xmm3, %xmm3 + veor q4, q4, q4 @ vpxor %xmm4, %xmm4, %xmm4 + veor q5, q5, q5 @ vpxor %xmm5, %xmm5, %xmm5 + veor q6, q6, q6 @ vpxor %xmm6, %xmm6, %xmm6 + veor q7, q7, q7 @ vpxor %xmm7, %xmm7, %xmm7 + ldmia sp!, {r3,pc} @ return +.size _vpaes_schedule_core,.-_vpaes_schedule_core + +@@ +@@ .aes_schedule_round +@@ +@@ Runs one main round of the key schedule on q0, q7 +@@ +@@ Specifically, runs subbytes on the high dword of q0 +@@ then rotates it by one byte and xors into the low dword of +@@ q7. +@@ +@@ Adds rcon from low byte of q8, then rotates q8 for +@@ next rcon. +@@ +@@ Smears the dwords of q7 by xoring the low into the +@@ second low, result into third, result into highest. +@@ +@@ Returns results in q7 = q0. +@@ Clobbers q1-q4, r11. +@@ +.type _vpaes_schedule_round,%function +.align 4 +_vpaes_schedule_round: + @ extract rcon from xmm8 + vmov.i8 q4, #0 @ vpxor %xmm4, %xmm4, %xmm4 + vext.8 q1, q8, q4, #15 @ vpalignr $15, %xmm8, %xmm4, %xmm1 + vext.8 q8, q8, q8, #15 @ vpalignr $15, %xmm8, %xmm8, %xmm8 + veor q7, q7, q1 @ vpxor %xmm1, %xmm7, %xmm7 + + @ rotate + vdup.32 q0, d1[1] @ vpshufd $0xFF, %xmm0, %xmm0 + vext.8 q0, q0, q0, #1 @ vpalignr $1, %xmm0, %xmm0, %xmm0 + + @ fall through... + + @ low round: same as high round, but no rotation and no rcon. +_vpaes_schedule_low_round: + @ The x86_64 version pins .Lk_sb1 in %xmm13 and .Lk_sb1+16 in %xmm12. + @ We pin other values in _vpaes_key_preheat, so load them now. + adr r11, .Lk_sb1 + vld1.64 {q14,q15}, [r11] + + @ smear xmm7 + vext.8 q1, q4, q7, #12 @ vpslldq $4, %xmm7, %xmm1 + veor q7, q7, q1 @ vpxor %xmm1, %xmm7, %xmm7 + vext.8 q4, q4, q7, #8 @ vpslldq $8, %xmm7, %xmm4 + + @ subbytes + vand q1, q0, q9 @ vpand %xmm9, %xmm0, %xmm1 # 0 = k + vshr.u8 q0, q0, #4 @ vpsrlb $4, %xmm0, %xmm0 # 1 = i + veor q7, q7, q4 @ vpxor %xmm4, %xmm7, %xmm7 + vtbl.8 d4, {q11}, d2 @ vpshufb %xmm1, %xmm11, %xmm2 # 2 = a/k + vtbl.8 d5, {q11}, d3 + veor q1, q1, q0 @ vpxor %xmm0, %xmm1, %xmm1 # 0 = j + vtbl.8 d6, {q10}, d0 @ vpshufb %xmm0, %xmm10, %xmm3 # 3 = 1/i + vtbl.8 d7, {q10}, d1 + veor q3, q3, q2 @ vpxor %xmm2, %xmm3, %xmm3 # 3 = iak = 1/i + a/k + vtbl.8 d8, {q10}, d2 @ vpshufb %xmm1, %xmm10, %xmm4 # 4 = 1/j + vtbl.8 d9, {q10}, d3 + veor q7, q7, q12 @ vpxor .Lk_s63(%rip), %xmm7, %xmm7 + vtbl.8 d6, {q10}, d6 @ vpshufb %xmm3, %xmm10, %xmm3 # 2 = 1/iak + vtbl.8 d7, {q10}, d7 + veor q4, q4, q2 @ vpxor %xmm2, %xmm4, %xmm4 # 4 = jak = 1/j + a/k + vtbl.8 d4, {q10}, d8 @ vpshufb %xmm4, %xmm10, %xmm2 # 3 = 1/jak + vtbl.8 d5, {q10}, d9 + veor q3, q3, q1 @ vpxor %xmm1, %xmm3, %xmm3 # 2 = io + veor q2, q2, q0 @ vpxor %xmm0, %xmm2, %xmm2 # 3 = jo + vtbl.8 d8, {q15}, d6 @ vpshufb %xmm3, %xmm13, %xmm4 # 4 = sbou + vtbl.8 d9, {q15}, d7 + vtbl.8 d2, {q14}, d4 @ vpshufb %xmm2, %xmm12, %xmm1 # 0 = sb1t + vtbl.8 d3, {q14}, d5 + veor q1, q1, q4 @ vpxor %xmm4, %xmm1, %xmm1 # 0 = sbox output + + @ add in smeared stuff + veor q0, q1, q7 @ vpxor %xmm7, %xmm1, %xmm0 + veor q7, q1, q7 @ vmovdqa %xmm0, %xmm7 + bx lr +.size _vpaes_schedule_round,.-_vpaes_schedule_round + +@@ +@@ .aes_schedule_transform +@@ +@@ Linear-transform q0 according to tables at [r11] +@@ +@@ Requires that q9 = 0x0F0F... as in preheat +@@ Output in q0 +@@ Clobbers q1, q2, q14, q15 +@@ +.type _vpaes_schedule_transform,%function +.align 4 +_vpaes_schedule_transform: + vld1.64 {q14,q15}, [r11] @ vmovdqa (%r11), %xmm2 # lo + @ vmovdqa 16(%r11), %xmm1 # hi + vand q1, q0, q9 @ vpand %xmm9, %xmm0, %xmm1 + vshr.u8 q0, q0, #4 @ vpsrlb $4, %xmm0, %xmm0 + vtbl.8 d4, {q14}, d2 @ vpshufb %xmm1, %xmm2, %xmm2 + vtbl.8 d5, {q14}, d3 + vtbl.8 d0, {q15}, d0 @ vpshufb %xmm0, %xmm1, %xmm0 + vtbl.8 d1, {q15}, d1 + veor q0, q0, q2 @ vpxor %xmm2, %xmm0, %xmm0 + bx lr +.size _vpaes_schedule_transform,.-_vpaes_schedule_transform + +@@ +@@ .aes_schedule_mangle +@@ +@@ Mangles q0 from (basis-transformed) standard version +@@ to our version. +@@ +@@ On encrypt, +@@ xor with 0x63 +@@ multiply by circulant 0,1,1,1 +@@ apply shiftrows transform +@@ +@@ On decrypt, +@@ xor with 0x63 +@@ multiply by "inverse mixcolumns" circulant E,B,D,9 +@@ deskew +@@ apply shiftrows transform +@@ +@@ +@@ Writes out to [r2], and increments or decrements it +@@ Keeps track of round number mod 4 in r8 +@@ Preserves q0 +@@ Clobbers q1-q5 +@@ +.type _vpaes_schedule_mangle,%function +.align 4 +_vpaes_schedule_mangle: + tst r3, r3 + vmov q4, q0 @ vmovdqa %xmm0, %xmm4 # save xmm0 for later + adr r11, .Lk_mc_forward @ Must be aligned to 8 mod 16. + vld1.64 {q5}, [r11] @ vmovdqa .Lk_mc_forward(%rip),%xmm5 + + @ encrypting + @ Write to q2 so we do not overlap table and destination below. + veor q2, q0, q12 @ vpxor .Lk_s63(%rip), %xmm0, %xmm4 + add r2, r2, #16 @ add $16, %rdx + vtbl.8 d8, {q2}, d10 @ vpshufb %xmm5, %xmm4, %xmm4 + vtbl.8 d9, {q2}, d11 + vtbl.8 d2, {q4}, d10 @ vpshufb %xmm5, %xmm4, %xmm1 + vtbl.8 d3, {q4}, d11 + vtbl.8 d6, {q1}, d10 @ vpshufb %xmm5, %xmm1, %xmm3 + vtbl.8 d7, {q1}, d11 + veor q4, q4, q1 @ vpxor %xmm1, %xmm4, %xmm4 + vld1.64 {q1}, [r8] @ vmovdqa (%r8,%r10), %xmm1 + veor q3, q3, q4 @ vpxor %xmm4, %xmm3, %xmm3 + +.Lschedule_mangle_both: + @ Write to q2 so table and destination do not overlap. + vtbl.8 d4, {q3}, d2 @ vpshufb %xmm1, %xmm3, %xmm3 + vtbl.8 d5, {q3}, d3 + add r8, r8, #64-16 @ add $-16, %r8 + and r8, r8, #~(1<<6) @ and $0x30, %r8 + vst1.64 {q2}, [r2] @ vmovdqu %xmm3, (%rdx) + bx lr +.size _vpaes_schedule_mangle,.-_vpaes_schedule_mangle + +.globl vpaes_set_encrypt_key +.hidden vpaes_set_encrypt_key +.type vpaes_set_encrypt_key,%function +.align 4 +vpaes_set_encrypt_key: + stmdb sp!, {r7,r8,r9,r10,r11, lr} + vstmdb sp!, {d8,d9,d10,d11,d12,d13,d14,d15} + + lsr r9, r1, #5 @ shr $5,%eax + add r9, r9, #5 @ $5,%eax + str r9, [r2,#240] @ mov %eax,240(%rdx) # AES_KEY->rounds = nbits/32+5; + + mov r3, #0 @ mov $0,%ecx + mov r8, #0x30 @ mov $0x30,%r8d + bl _vpaes_schedule_core + eor r0, r0, r0 + + vldmia sp!, {d8,d9,d10,d11,d12,d13,d14,d15} + ldmia sp!, {r7,r8,r9,r10,r11, pc} @ return +.size vpaes_set_encrypt_key,.-vpaes_set_encrypt_key + +@ Additional constants for converting to bsaes. +.type _vpaes_convert_consts,%object +.align 4 +_vpaes_convert_consts: +@ .Lk_opt_then_skew applies skew(opt(x)) XOR 0x63, where skew is the linear +@ transform in the AES S-box. 0x63 is incorporated into the low half of the +@ table. This was computed with the following script: +@ +@ def u64s_to_u128(x, y): +@ return x | (y << 64) +@ def u128_to_u64s(w): +@ return w & ((1<<64)-1), w >> 64 +@ def get_byte(w, i): +@ return (w >> (i*8)) & 0xff +@ def apply_table(table, b): +@ lo = b & 0xf +@ hi = b >> 4 +@ return get_byte(table[0], lo) ^ get_byte(table[1], hi) +@ def opt(b): +@ table = [ +@ u64s_to_u128(0xFF9F4929D6B66000, 0xF7974121DEBE6808), +@ u64s_to_u128(0x01EDBD5150BCEC00, 0xE10D5DB1B05C0CE0), +@ ] +@ return apply_table(table, b) +@ def rot_byte(b, n): +@ return 0xff & ((b << n) | (b >> (8-n))) +@ def skew(x): +@ return (x ^ rot_byte(x, 1) ^ rot_byte(x, 2) ^ rot_byte(x, 3) ^ +@ rot_byte(x, 4)) +@ table = [0, 0] +@ for i in range(16): +@ table[0] |= (skew(opt(i)) ^ 0x63) << (i*8) +@ table[1] |= skew(opt(i<<4)) << (i*8) +@ print(" .quad 0x%016x, 0x%016x" % u128_to_u64s(table[0])) +@ print(" .quad 0x%016x, 0x%016x" % u128_to_u64s(table[1])) +.Lk_opt_then_skew: +.quad 0x9cb8436798bc4763, 0x6440bb9f6044bf9b +.quad 0x1f30062936192f00, 0xb49bad829db284ab + +@ void vpaes_encrypt_key_to_bsaes(AES_KEY *bsaes, const AES_KEY *vpaes); +.globl vpaes_encrypt_key_to_bsaes +.hidden vpaes_encrypt_key_to_bsaes +.type vpaes_encrypt_key_to_bsaes,%function +.align 4 +vpaes_encrypt_key_to_bsaes: + stmdb sp!, {r11, lr} + + @ See _vpaes_schedule_core for the key schedule logic. In particular, + @ _vpaes_schedule_transform(.Lk_ipt) (section 2.2 of the paper), + @ _vpaes_schedule_mangle (section 4.3), and .Lschedule_mangle_last + @ contain the transformations not in the bsaes representation. This + @ function inverts those transforms. + @ + @ Note also that bsaes-armv7.pl expects aes-armv4.pl's key + @ representation, which does not match the other aes_nohw_* + @ implementations. The ARM aes_nohw_* stores each 32-bit word + @ byteswapped, as a convenience for (unsupported) big-endian ARM, at the + @ cost of extra REV and VREV32 operations in little-endian ARM. + + vmov.i8 q9, #0x0f @ Required by _vpaes_schedule_transform + adr r2, .Lk_mc_forward @ Must be aligned to 8 mod 16. + add r3, r2, 0x90 @ .Lk_sr+0x10-.Lk_mc_forward = 0x90 (Apple's toolchain doesn't support the expression) + + vld1.64 {q12}, [r2] + vmov.i8 q10, #0x5b @ .Lk_s63 from vpaes-x86_64 + adr r11, .Lk_opt @ Must be aligned to 8 mod 16. + vmov.i8 q11, #0x63 @ .LK_s63 without .Lk_ipt applied + + @ vpaes stores one fewer round count than bsaes, but the number of keys + @ is the same. + ldr r2, [r1,#240] + add r2, r2, #1 + str r2, [r0,#240] + + @ The first key is transformed with _vpaes_schedule_transform(.Lk_ipt). + @ Invert this with .Lk_opt. + vld1.64 {q0}, [r1]! + bl _vpaes_schedule_transform + vrev32.8 q0, q0 + vst1.64 {q0}, [r0]! + + @ The middle keys have _vpaes_schedule_transform(.Lk_ipt) applied, + @ followed by _vpaes_schedule_mangle. _vpaes_schedule_mangle XORs 0x63, + @ multiplies by the circulant 0,1,1,1, then applies ShiftRows. +.Loop_enc_key_to_bsaes: + vld1.64 {q0}, [r1]! + + @ Invert the ShiftRows step (see .Lschedule_mangle_both). Note we cycle + @ r3 in the opposite direction and start at .Lk_sr+0x10 instead of 0x30. + @ We use r3 rather than r8 to avoid a callee-saved register. + vld1.64 {q1}, [r3] + vtbl.8 d4, {q0}, d2 + vtbl.8 d5, {q0}, d3 + add r3, r3, #16 + and r3, r3, #~(1<<6) + vmov q0, q2 + + @ Handle the last key differently. + subs r2, r2, #1 + beq .Loop_enc_key_to_bsaes_last + + @ Multiply by the circulant. This is its own inverse. + vtbl.8 d2, {q0}, d24 + vtbl.8 d3, {q0}, d25 + vmov q0, q1 + vtbl.8 d4, {q1}, d24 + vtbl.8 d5, {q1}, d25 + veor q0, q0, q2 + vtbl.8 d2, {q2}, d24 + vtbl.8 d3, {q2}, d25 + veor q0, q0, q1 + + @ XOR and finish. + veor q0, q0, q10 + bl _vpaes_schedule_transform + vrev32.8 q0, q0 + vst1.64 {q0}, [r0]! + b .Loop_enc_key_to_bsaes + +.Loop_enc_key_to_bsaes_last: + @ The final key does not have a basis transform (note + @ .Lschedule_mangle_last inverts the original transform). It only XORs + @ 0x63 and applies ShiftRows. The latter was already inverted in the + @ loop. Note that, because we act on the original representation, we use + @ q11, not q10. + veor q0, q0, q11 + vrev32.8 q0, q0 + vst1.64 {q0}, [r0] + + @ Wipe registers which contained key material. + veor q0, q0, q0 + veor q1, q1, q1 + veor q2, q2, q2 + + ldmia sp!, {r11, pc} @ return +.size vpaes_encrypt_key_to_bsaes,.-vpaes_encrypt_key_to_bsaes +.globl vpaes_ctr32_encrypt_blocks +.hidden vpaes_ctr32_encrypt_blocks +.type vpaes_ctr32_encrypt_blocks,%function +.align 4 +vpaes_ctr32_encrypt_blocks: + mov ip, sp + stmdb sp!, {r7,r8,r9,r10,r11, lr} + @ This function uses q4-q7 (d8-d15), which are callee-saved. + vstmdb sp!, {d8,d9,d10,d11,d12,d13,d14,d15} + + cmp r2, #0 + @ r8 is passed on the stack. + ldr r8, [ip] + beq .Lctr32_done + + @ _vpaes_encrypt_core expects the key in r2, so swap r2 and r3. + mov r9, r3 + mov r3, r2 + mov r2, r9 + + @ Load the IV and counter portion. + ldr r7, [r8, #12] + vld1.8 {q7}, [r8] + + bl _vpaes_preheat + rev r7, r7 @ The counter is big-endian. + +.Lctr32_loop: + vmov q0, q7 + vld1.8 {q6}, [r0]! @ .Load input ahead of time + bl _vpaes_encrypt_core + veor q0, q0, q6 @ XOR input and result + vst1.8 {q0}, [r1]! + subs r3, r3, #1 + @ Update the counter. + add r7, r7, #1 + rev r9, r7 + vmov.32 d15[1], r9 + bne .Lctr32_loop + +.Lctr32_done: + vldmia sp!, {d8,d9,d10,d11,d12,d13,d14,d15} + ldmia sp!, {r7,r8,r9,r10,r11, pc} @ return +.size vpaes_ctr32_encrypt_blocks,.-vpaes_ctr32_encrypt_blocks +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_ARM) && defined(__ELF__) diff --git a/http/vendor/ring/pregenerated/vpaes-armv8-ios64.S b/http/vendor/ring/pregenerated/vpaes-armv8-ios64.S new file mode 100644 index 0000000..b4e29dc --- /dev/null +++ b/http/vendor/ring/pregenerated/vpaes-armv8-ios64.S @@ -0,0 +1,744 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__APPLE__) +.section __TEXT,__const + + +.align 7 // totally strategic alignment +_vpaes_consts: +Lk_mc_forward: // mc_forward +.quad 0x0407060500030201, 0x0C0F0E0D080B0A09 +.quad 0x080B0A0904070605, 0x000302010C0F0E0D +.quad 0x0C0F0E0D080B0A09, 0x0407060500030201 +.quad 0x000302010C0F0E0D, 0x080B0A0904070605 +Lk_mc_backward: // mc_backward +.quad 0x0605040702010003, 0x0E0D0C0F0A09080B +.quad 0x020100030E0D0C0F, 0x0A09080B06050407 +.quad 0x0E0D0C0F0A09080B, 0x0605040702010003 +.quad 0x0A09080B06050407, 0x020100030E0D0C0F +Lk_sr: // sr +.quad 0x0706050403020100, 0x0F0E0D0C0B0A0908 +.quad 0x030E09040F0A0500, 0x0B06010C07020D08 +.quad 0x0F060D040B020900, 0x070E050C030A0108 +.quad 0x0B0E0104070A0D00, 0x0306090C0F020508 + +// +// "Hot" constants +// +Lk_inv: // inv, inva +.quad 0x0E05060F0D080180, 0x040703090A0B0C02 +.quad 0x01040A060F0B0780, 0x030D0E0C02050809 +Lk_ipt: // input transform (lo, hi) +.quad 0xC2B2E8985A2A7000, 0xCABAE09052227808 +.quad 0x4C01307D317C4D00, 0xCD80B1FCB0FDCC81 +Lk_sbo: // sbou, sbot +.quad 0xD0D26D176FBDC700, 0x15AABF7AC502A878 +.quad 0xCFE474A55FBB6A00, 0x8E1E90D1412B35FA +Lk_sb1: // sb1u, sb1t +.quad 0x3618D415FAE22300, 0x3BF7CCC10D2ED9EF +.quad 0xB19BE18FCB503E00, 0xA5DF7A6E142AF544 +Lk_sb2: // sb2u, sb2t +.quad 0x69EB88400AE12900, 0xC2A163C8AB82234A +.quad 0xE27A93C60B712400, 0x5EB7E955BC982FCD + +// +// Key schedule constants +// +Lk_dksd: // decryption key schedule: invskew x*D +.quad 0xFEB91A5DA3E44700, 0x0740E3A45A1DBEF9 +.quad 0x41C277F4B5368300, 0x5FDC69EAAB289D1E +Lk_dksb: // decryption key schedule: invskew x*B +.quad 0x9A4FCA1F8550D500, 0x03D653861CC94C99 +.quad 0x115BEDA7B6FC4A00, 0xD993256F7E3482C8 +Lk_dkse: // decryption key schedule: invskew x*E + 0x63 +.quad 0xD5031CCA1FC9D600, 0x53859A4C994F5086 +.quad 0xA23196054FDC7BE8, 0xCD5EF96A20B31487 +Lk_dks9: // decryption key schedule: invskew x*9 +.quad 0xB6116FC87ED9A700, 0x4AED933482255BFC +.quad 0x4576516227143300, 0x8BB89FACE9DAFDCE + +Lk_rcon: // rcon +.quad 0x1F8391B9AF9DEEB6, 0x702A98084D7C7D81 + +Lk_opt: // output transform +.quad 0xFF9F4929D6B66000, 0xF7974121DEBE6808 +.quad 0x01EDBD5150BCEC00, 0xE10D5DB1B05C0CE0 +Lk_deskew: // deskew tables: inverts the sbox's "skew" +.quad 0x07E4A34047A4E300, 0x1DFEB95A5DBEF91A +.quad 0x5F36B5DC83EA6900, 0x2841C2ABF49D1E77 + +.byte 86,101,99,116,111,114,32,80,101,114,109,117,116,97,116,105,111,110,32,65,69,83,32,102,111,114,32,65,82,77,118,56,44,32,77,105,107,101,32,72,97,109,98,117,114,103,32,40,83,116,97,110,102,111,114,100,32,85,110,105,118,101,114,115,105,116,121,41,0 +.align 2 + +.align 6 + +.text +## +## _aes_preheat +## +## Fills register %r10 -> .aes_consts (so you can -fPIC) +## and %xmm9-%xmm15 as specified below. +## + +.align 4 +_vpaes_encrypt_preheat: + adrp x10, Lk_inv@PAGE + add x10, x10, Lk_inv@PAGEOFF + movi v17.16b, #0x0f + ld1 {v18.2d,v19.2d}, [x10],#32 // Lk_inv + ld1 {v20.2d,v21.2d,v22.2d,v23.2d}, [x10],#64 // Lk_ipt, Lk_sbo + ld1 {v24.2d,v25.2d,v26.2d,v27.2d}, [x10] // Lk_sb1, Lk_sb2 + ret + + +## +## _aes_encrypt_core +## +## AES-encrypt %xmm0. +## +## Inputs: +## %xmm0 = input +## %xmm9-%xmm15 as in _vpaes_preheat +## (%rdx) = scheduled keys +## +## Output in %xmm0 +## Clobbers %xmm1-%xmm5, %r9, %r10, %r11, %rax +## Preserves %xmm6 - %xmm8 so you get some local vectors +## +## + +.align 4 +_vpaes_encrypt_core: + mov x9, x2 + ldr w8, [x2,#240] // pull rounds + adrp x11, Lk_mc_forward@PAGE+16 + add x11, x11, Lk_mc_forward@PAGEOFF+16 + // vmovdqa .Lk_ipt(%rip), %xmm2 # iptlo + ld1 {v16.2d}, [x9], #16 // vmovdqu (%r9), %xmm5 # round0 key + and v1.16b, v7.16b, v17.16b // vpand %xmm9, %xmm0, %xmm1 + ushr v0.16b, v7.16b, #4 // vpsrlb $4, %xmm0, %xmm0 + tbl v1.16b, {v20.16b}, v1.16b // vpshufb %xmm1, %xmm2, %xmm1 + // vmovdqa .Lk_ipt+16(%rip), %xmm3 # ipthi + tbl v2.16b, {v21.16b}, v0.16b // vpshufb %xmm0, %xmm3, %xmm2 + eor v0.16b, v1.16b, v16.16b // vpxor %xmm5, %xmm1, %xmm0 + eor v0.16b, v0.16b, v2.16b // vpxor %xmm2, %xmm0, %xmm0 + b Lenc_entry + +.align 4 +Lenc_loop: + // middle of middle round + add x10, x11, #0x40 + tbl v4.16b, {v25.16b}, v2.16b // vpshufb %xmm2, %xmm13, %xmm4 # 4 = sb1u + ld1 {v1.2d}, [x11], #16 // vmovdqa -0x40(%r11,%r10), %xmm1 # Lk_mc_forward[] + tbl v0.16b, {v24.16b}, v3.16b // vpshufb %xmm3, %xmm12, %xmm0 # 0 = sb1t + eor v4.16b, v4.16b, v16.16b // vpxor %xmm5, %xmm4, %xmm4 # 4 = sb1u + k + tbl v5.16b, {v27.16b}, v2.16b // vpshufb %xmm2, %xmm15, %xmm5 # 4 = sb2u + eor v0.16b, v0.16b, v4.16b // vpxor %xmm4, %xmm0, %xmm0 # 0 = A + tbl v2.16b, {v26.16b}, v3.16b // vpshufb %xmm3, %xmm14, %xmm2 # 2 = sb2t + ld1 {v4.2d}, [x10] // vmovdqa (%r11,%r10), %xmm4 # Lk_mc_backward[] + tbl v3.16b, {v0.16b}, v1.16b // vpshufb %xmm1, %xmm0, %xmm3 # 0 = B + eor v2.16b, v2.16b, v5.16b // vpxor %xmm5, %xmm2, %xmm2 # 2 = 2A + tbl v0.16b, {v0.16b}, v4.16b // vpshufb %xmm4, %xmm0, %xmm0 # 3 = D + eor v3.16b, v3.16b, v2.16b // vpxor %xmm2, %xmm3, %xmm3 # 0 = 2A+B + tbl v4.16b, {v3.16b}, v1.16b // vpshufb %xmm1, %xmm3, %xmm4 # 0 = 2B+C + eor v0.16b, v0.16b, v3.16b // vpxor %xmm3, %xmm0, %xmm0 # 3 = 2A+B+D + and x11, x11, #~(1<<6) // and $0x30, %r11 # ... mod 4 + eor v0.16b, v0.16b, v4.16b // vpxor %xmm4, %xmm0, %xmm0 # 0 = 2A+3B+C+D + sub w8, w8, #1 // nr-- + +Lenc_entry: + // top of round + and v1.16b, v0.16b, v17.16b // vpand %xmm0, %xmm9, %xmm1 # 0 = k + ushr v0.16b, v0.16b, #4 // vpsrlb $4, %xmm0, %xmm0 # 1 = i + tbl v5.16b, {v19.16b}, v1.16b // vpshufb %xmm1, %xmm11, %xmm5 # 2 = a/k + eor v1.16b, v1.16b, v0.16b // vpxor %xmm0, %xmm1, %xmm1 # 0 = j + tbl v3.16b, {v18.16b}, v0.16b // vpshufb %xmm0, %xmm10, %xmm3 # 3 = 1/i + tbl v4.16b, {v18.16b}, v1.16b // vpshufb %xmm1, %xmm10, %xmm4 # 4 = 1/j + eor v3.16b, v3.16b, v5.16b // vpxor %xmm5, %xmm3, %xmm3 # 3 = iak = 1/i + a/k + eor v4.16b, v4.16b, v5.16b // vpxor %xmm5, %xmm4, %xmm4 # 4 = jak = 1/j + a/k + tbl v2.16b, {v18.16b}, v3.16b // vpshufb %xmm3, %xmm10, %xmm2 # 2 = 1/iak + tbl v3.16b, {v18.16b}, v4.16b // vpshufb %xmm4, %xmm10, %xmm3 # 3 = 1/jak + eor v2.16b, v2.16b, v1.16b // vpxor %xmm1, %xmm2, %xmm2 # 2 = io + eor v3.16b, v3.16b, v0.16b // vpxor %xmm0, %xmm3, %xmm3 # 3 = jo + ld1 {v16.2d}, [x9],#16 // vmovdqu (%r9), %xmm5 + cbnz w8, Lenc_loop + + // middle of last round + add x10, x11, #0x80 + // vmovdqa -0x60(%r10), %xmm4 # 3 : sbou .Lk_sbo + // vmovdqa -0x50(%r10), %xmm0 # 0 : sbot .Lk_sbo+16 + tbl v4.16b, {v22.16b}, v2.16b // vpshufb %xmm2, %xmm4, %xmm4 # 4 = sbou + ld1 {v1.2d}, [x10] // vmovdqa 0x40(%r11,%r10), %xmm1 # Lk_sr[] + tbl v0.16b, {v23.16b}, v3.16b // vpshufb %xmm3, %xmm0, %xmm0 # 0 = sb1t + eor v4.16b, v4.16b, v16.16b // vpxor %xmm5, %xmm4, %xmm4 # 4 = sb1u + k + eor v0.16b, v0.16b, v4.16b // vpxor %xmm4, %xmm0, %xmm0 # 0 = A + tbl v0.16b, {v0.16b}, v1.16b // vpshufb %xmm1, %xmm0, %xmm0 + ret + + + +.align 4 +_vpaes_encrypt_2x: + mov x9, x2 + ldr w8, [x2,#240] // pull rounds + adrp x11, Lk_mc_forward@PAGE+16 + add x11, x11, Lk_mc_forward@PAGEOFF+16 + // vmovdqa .Lk_ipt(%rip), %xmm2 # iptlo + ld1 {v16.2d}, [x9], #16 // vmovdqu (%r9), %xmm5 # round0 key + and v1.16b, v14.16b, v17.16b // vpand %xmm9, %xmm0, %xmm1 + ushr v0.16b, v14.16b, #4 // vpsrlb $4, %xmm0, %xmm0 + and v9.16b, v15.16b, v17.16b + ushr v8.16b, v15.16b, #4 + tbl v1.16b, {v20.16b}, v1.16b // vpshufb %xmm1, %xmm2, %xmm1 + tbl v9.16b, {v20.16b}, v9.16b + // vmovdqa .Lk_ipt+16(%rip), %xmm3 # ipthi + tbl v2.16b, {v21.16b}, v0.16b // vpshufb %xmm0, %xmm3, %xmm2 + tbl v10.16b, {v21.16b}, v8.16b + eor v0.16b, v1.16b, v16.16b // vpxor %xmm5, %xmm1, %xmm0 + eor v8.16b, v9.16b, v16.16b + eor v0.16b, v0.16b, v2.16b // vpxor %xmm2, %xmm0, %xmm0 + eor v8.16b, v8.16b, v10.16b + b Lenc_2x_entry + +.align 4 +Lenc_2x_loop: + // middle of middle round + add x10, x11, #0x40 + tbl v4.16b, {v25.16b}, v2.16b // vpshufb %xmm2, %xmm13, %xmm4 # 4 = sb1u + tbl v12.16b, {v25.16b}, v10.16b + ld1 {v1.2d}, [x11], #16 // vmovdqa -0x40(%r11,%r10), %xmm1 # Lk_mc_forward[] + tbl v0.16b, {v24.16b}, v3.16b // vpshufb %xmm3, %xmm12, %xmm0 # 0 = sb1t + tbl v8.16b, {v24.16b}, v11.16b + eor v4.16b, v4.16b, v16.16b // vpxor %xmm5, %xmm4, %xmm4 # 4 = sb1u + k + eor v12.16b, v12.16b, v16.16b + tbl v5.16b, {v27.16b}, v2.16b // vpshufb %xmm2, %xmm15, %xmm5 # 4 = sb2u + tbl v13.16b, {v27.16b}, v10.16b + eor v0.16b, v0.16b, v4.16b // vpxor %xmm4, %xmm0, %xmm0 # 0 = A + eor v8.16b, v8.16b, v12.16b + tbl v2.16b, {v26.16b}, v3.16b // vpshufb %xmm3, %xmm14, %xmm2 # 2 = sb2t + tbl v10.16b, {v26.16b}, v11.16b + ld1 {v4.2d}, [x10] // vmovdqa (%r11,%r10), %xmm4 # Lk_mc_backward[] + tbl v3.16b, {v0.16b}, v1.16b // vpshufb %xmm1, %xmm0, %xmm3 # 0 = B + tbl v11.16b, {v8.16b}, v1.16b + eor v2.16b, v2.16b, v5.16b // vpxor %xmm5, %xmm2, %xmm2 # 2 = 2A + eor v10.16b, v10.16b, v13.16b + tbl v0.16b, {v0.16b}, v4.16b // vpshufb %xmm4, %xmm0, %xmm0 # 3 = D + tbl v8.16b, {v8.16b}, v4.16b + eor v3.16b, v3.16b, v2.16b // vpxor %xmm2, %xmm3, %xmm3 # 0 = 2A+B + eor v11.16b, v11.16b, v10.16b + tbl v4.16b, {v3.16b}, v1.16b // vpshufb %xmm1, %xmm3, %xmm4 # 0 = 2B+C + tbl v12.16b, {v11.16b},v1.16b + eor v0.16b, v0.16b, v3.16b // vpxor %xmm3, %xmm0, %xmm0 # 3 = 2A+B+D + eor v8.16b, v8.16b, v11.16b + and x11, x11, #~(1<<6) // and $0x30, %r11 # ... mod 4 + eor v0.16b, v0.16b, v4.16b // vpxor %xmm4, %xmm0, %xmm0 # 0 = 2A+3B+C+D + eor v8.16b, v8.16b, v12.16b + sub w8, w8, #1 // nr-- + +Lenc_2x_entry: + // top of round + and v1.16b, v0.16b, v17.16b // vpand %xmm0, %xmm9, %xmm1 # 0 = k + ushr v0.16b, v0.16b, #4 // vpsrlb $4, %xmm0, %xmm0 # 1 = i + and v9.16b, v8.16b, v17.16b + ushr v8.16b, v8.16b, #4 + tbl v5.16b, {v19.16b},v1.16b // vpshufb %xmm1, %xmm11, %xmm5 # 2 = a/k + tbl v13.16b, {v19.16b},v9.16b + eor v1.16b, v1.16b, v0.16b // vpxor %xmm0, %xmm1, %xmm1 # 0 = j + eor v9.16b, v9.16b, v8.16b + tbl v3.16b, {v18.16b},v0.16b // vpshufb %xmm0, %xmm10, %xmm3 # 3 = 1/i + tbl v11.16b, {v18.16b},v8.16b + tbl v4.16b, {v18.16b},v1.16b // vpshufb %xmm1, %xmm10, %xmm4 # 4 = 1/j + tbl v12.16b, {v18.16b},v9.16b + eor v3.16b, v3.16b, v5.16b // vpxor %xmm5, %xmm3, %xmm3 # 3 = iak = 1/i + a/k + eor v11.16b, v11.16b, v13.16b + eor v4.16b, v4.16b, v5.16b // vpxor %xmm5, %xmm4, %xmm4 # 4 = jak = 1/j + a/k + eor v12.16b, v12.16b, v13.16b + tbl v2.16b, {v18.16b},v3.16b // vpshufb %xmm3, %xmm10, %xmm2 # 2 = 1/iak + tbl v10.16b, {v18.16b},v11.16b + tbl v3.16b, {v18.16b},v4.16b // vpshufb %xmm4, %xmm10, %xmm3 # 3 = 1/jak + tbl v11.16b, {v18.16b},v12.16b + eor v2.16b, v2.16b, v1.16b // vpxor %xmm1, %xmm2, %xmm2 # 2 = io + eor v10.16b, v10.16b, v9.16b + eor v3.16b, v3.16b, v0.16b // vpxor %xmm0, %xmm3, %xmm3 # 3 = jo + eor v11.16b, v11.16b, v8.16b + ld1 {v16.2d}, [x9],#16 // vmovdqu (%r9), %xmm5 + cbnz w8, Lenc_2x_loop + + // middle of last round + add x10, x11, #0x80 + // vmovdqa -0x60(%r10), %xmm4 # 3 : sbou .Lk_sbo + // vmovdqa -0x50(%r10), %xmm0 # 0 : sbot .Lk_sbo+16 + tbl v4.16b, {v22.16b}, v2.16b // vpshufb %xmm2, %xmm4, %xmm4 # 4 = sbou + tbl v12.16b, {v22.16b}, v10.16b + ld1 {v1.2d}, [x10] // vmovdqa 0x40(%r11,%r10), %xmm1 # Lk_sr[] + tbl v0.16b, {v23.16b}, v3.16b // vpshufb %xmm3, %xmm0, %xmm0 # 0 = sb1t + tbl v8.16b, {v23.16b}, v11.16b + eor v4.16b, v4.16b, v16.16b // vpxor %xmm5, %xmm4, %xmm4 # 4 = sb1u + k + eor v12.16b, v12.16b, v16.16b + eor v0.16b, v0.16b, v4.16b // vpxor %xmm4, %xmm0, %xmm0 # 0 = A + eor v8.16b, v8.16b, v12.16b + tbl v0.16b, {v0.16b},v1.16b // vpshufb %xmm1, %xmm0, %xmm0 + tbl v1.16b, {v8.16b},v1.16b + ret + +######################################################## +## ## +## AES key schedule ## +## ## +######################################################## + +.align 4 +_vpaes_key_preheat: + adrp x10, Lk_inv@PAGE + add x10, x10, Lk_inv@PAGEOFF + movi v16.16b, #0x5b // Lk_s63 + adrp x11, Lk_sb1@PAGE + add x11, x11, Lk_sb1@PAGEOFF + movi v17.16b, #0x0f // Lk_s0F + ld1 {v18.2d,v19.2d,v20.2d,v21.2d}, [x10] // Lk_inv, Lk_ipt + adrp x10, Lk_dksd@PAGE + add x10, x10, Lk_dksd@PAGEOFF + ld1 {v22.2d,v23.2d}, [x11] // Lk_sb1 + adrp x11, Lk_mc_forward@PAGE + add x11, x11, Lk_mc_forward@PAGEOFF + ld1 {v24.2d,v25.2d,v26.2d,v27.2d}, [x10],#64 // Lk_dksd, Lk_dksb + ld1 {v28.2d,v29.2d,v30.2d,v31.2d}, [x10],#64 // Lk_dkse, Lk_dks9 + ld1 {v8.2d}, [x10] // Lk_rcon + ld1 {v9.2d}, [x11] // Lk_mc_forward[0] + ret + + + +.align 4 +_vpaes_schedule_core: + AARCH64_SIGN_LINK_REGISTER + stp x29, x30, [sp,#-16]! + add x29,sp,#0 + + bl _vpaes_key_preheat // load the tables + + ld1 {v0.16b}, [x0],#16 // vmovdqu (%rdi), %xmm0 # load key (unaligned) + + // input transform + mov v3.16b, v0.16b // vmovdqa %xmm0, %xmm3 + bl _vpaes_schedule_transform + mov v7.16b, v0.16b // vmovdqa %xmm0, %xmm7 + + adrp x10, Lk_sr@PAGE // lea Lk_sr(%rip),%r10 + add x10, x10, Lk_sr@PAGEOFF + + add x8, x8, x10 + + // encrypting, output zeroth round key after transform + st1 {v0.2d}, [x2] // vmovdqu %xmm0, (%rdx) + + cmp w1, #192 // cmp $192, %esi + b.hi Lschedule_256 + b.eq Lschedule_192 + // 128: fall though + +## +## .schedule_128 +## +## 128-bit specific part of key schedule. +## +## This schedule is really simple, because all its parts +## are accomplished by the subroutines. +## +Lschedule_128: + mov x0, #10 // mov $10, %esi + +Loop_schedule_128: + sub x0, x0, #1 // dec %esi + bl _vpaes_schedule_round + cbz x0, Lschedule_mangle_last + bl _vpaes_schedule_mangle // write output + b Loop_schedule_128 + +## +## .aes_schedule_192 +## +## 192-bit specific part of key schedule. +## +## The main body of this schedule is the same as the 128-bit +## schedule, but with more smearing. The long, high side is +## stored in %xmm7 as before, and the short, low side is in +## the high bits of %xmm6. +## +## This schedule is somewhat nastier, however, because each +## round produces 192 bits of key material, or 1.5 round keys. +## Therefore, on each cycle we do 2 rounds and produce 3 round +## keys. +## +.align 4 +Lschedule_192: + sub x0, x0, #8 + ld1 {v0.16b}, [x0] // vmovdqu 8(%rdi),%xmm0 # load key part 2 (very unaligned) + bl _vpaes_schedule_transform // input transform + mov v6.16b, v0.16b // vmovdqa %xmm0, %xmm6 # save short part + eor v4.16b, v4.16b, v4.16b // vpxor %xmm4, %xmm4, %xmm4 # clear 4 + ins v6.d[0], v4.d[0] // vmovhlps %xmm4, %xmm6, %xmm6 # clobber low side with zeros + mov x0, #4 // mov $4, %esi + +Loop_schedule_192: + sub x0, x0, #1 // dec %esi + bl _vpaes_schedule_round + ext v0.16b, v6.16b, v0.16b, #8 // vpalignr $8,%xmm6,%xmm0,%xmm0 + bl _vpaes_schedule_mangle // save key n + bl _vpaes_schedule_192_smear + bl _vpaes_schedule_mangle // save key n+1 + bl _vpaes_schedule_round + cbz x0, Lschedule_mangle_last + bl _vpaes_schedule_mangle // save key n+2 + bl _vpaes_schedule_192_smear + b Loop_schedule_192 + +## +## .aes_schedule_256 +## +## 256-bit specific part of key schedule. +## +## The structure here is very similar to the 128-bit +## schedule, but with an additional "low side" in +## %xmm6. The low side's rounds are the same as the +## high side's, except no rcon and no rotation. +## +.align 4 +Lschedule_256: + ld1 {v0.16b}, [x0] // vmovdqu 16(%rdi),%xmm0 # load key part 2 (unaligned) + bl _vpaes_schedule_transform // input transform + mov x0, #7 // mov $7, %esi + +Loop_schedule_256: + sub x0, x0, #1 // dec %esi + bl _vpaes_schedule_mangle // output low result + mov v6.16b, v0.16b // vmovdqa %xmm0, %xmm6 # save cur_lo in xmm6 + + // high round + bl _vpaes_schedule_round + cbz x0, Lschedule_mangle_last + bl _vpaes_schedule_mangle + + // low round. swap xmm7 and xmm6 + dup v0.4s, v0.s[3] // vpshufd $0xFF, %xmm0, %xmm0 + movi v4.16b, #0 + mov v5.16b, v7.16b // vmovdqa %xmm7, %xmm5 + mov v7.16b, v6.16b // vmovdqa %xmm6, %xmm7 + bl _vpaes_schedule_low_round + mov v7.16b, v5.16b // vmovdqa %xmm5, %xmm7 + + b Loop_schedule_256 + +## +## .aes_schedule_mangle_last +## +## Mangler for last round of key schedule +## Mangles %xmm0 +## when encrypting, outputs out(%xmm0) ^ 63 +## when decrypting, outputs unskew(%xmm0) +## +## Always called right before return... jumps to cleanup and exits +## +.align 4 +Lschedule_mangle_last: + // schedule last round key from xmm0 + adrp x11, Lk_deskew@PAGE // lea Lk_deskew(%rip),%r11 # prepare to deskew + add x11, x11, Lk_deskew@PAGEOFF + + cbnz w3, Lschedule_mangle_last_dec + + // encrypting + ld1 {v1.2d}, [x8] // vmovdqa (%r8,%r10),%xmm1 + adrp x11, Lk_opt@PAGE // lea Lk_opt(%rip), %r11 # prepare to output transform + add x11, x11, Lk_opt@PAGEOFF + add x2, x2, #32 // add $32, %rdx + tbl v0.16b, {v0.16b}, v1.16b // vpshufb %xmm1, %xmm0, %xmm0 # output permute + +Lschedule_mangle_last_dec: + ld1 {v20.2d,v21.2d}, [x11] // reload constants + sub x2, x2, #16 // add $-16, %rdx + eor v0.16b, v0.16b, v16.16b // vpxor Lk_s63(%rip), %xmm0, %xmm0 + bl _vpaes_schedule_transform // output transform + st1 {v0.2d}, [x2] // vmovdqu %xmm0, (%rdx) # save last key + + // cleanup + eor v0.16b, v0.16b, v0.16b // vpxor %xmm0, %xmm0, %xmm0 + eor v1.16b, v1.16b, v1.16b // vpxor %xmm1, %xmm1, %xmm1 + eor v2.16b, v2.16b, v2.16b // vpxor %xmm2, %xmm2, %xmm2 + eor v3.16b, v3.16b, v3.16b // vpxor %xmm3, %xmm3, %xmm3 + eor v4.16b, v4.16b, v4.16b // vpxor %xmm4, %xmm4, %xmm4 + eor v5.16b, v5.16b, v5.16b // vpxor %xmm5, %xmm5, %xmm5 + eor v6.16b, v6.16b, v6.16b // vpxor %xmm6, %xmm6, %xmm6 + eor v7.16b, v7.16b, v7.16b // vpxor %xmm7, %xmm7, %xmm7 + ldp x29, x30, [sp],#16 + AARCH64_VALIDATE_LINK_REGISTER + ret + + +## +## .aes_schedule_192_smear +## +## Smear the short, low side in the 192-bit key schedule. +## +## Inputs: +## %xmm7: high side, b a x y +## %xmm6: low side, d c 0 0 +## %xmm13: 0 +## +## Outputs: +## %xmm6: b+c+d b+c 0 0 +## %xmm0: b+c+d b+c b a +## + +.align 4 +_vpaes_schedule_192_smear: + movi v1.16b, #0 + dup v0.4s, v7.s[3] + ins v1.s[3], v6.s[2] // vpshufd $0x80, %xmm6, %xmm1 # d c 0 0 -> c 0 0 0 + ins v0.s[0], v7.s[2] // vpshufd $0xFE, %xmm7, %xmm0 # b a _ _ -> b b b a + eor v6.16b, v6.16b, v1.16b // vpxor %xmm1, %xmm6, %xmm6 # -> c+d c 0 0 + eor v1.16b, v1.16b, v1.16b // vpxor %xmm1, %xmm1, %xmm1 + eor v6.16b, v6.16b, v0.16b // vpxor %xmm0, %xmm6, %xmm6 # -> b+c+d b+c b a + mov v0.16b, v6.16b // vmovdqa %xmm6, %xmm0 + ins v6.d[0], v1.d[0] // vmovhlps %xmm1, %xmm6, %xmm6 # clobber low side with zeros + ret + + +## +## .aes_schedule_round +## +## Runs one main round of the key schedule on %xmm0, %xmm7 +## +## Specifically, runs subbytes on the high dword of %xmm0 +## then rotates it by one byte and xors into the low dword of +## %xmm7. +## +## Adds rcon from low byte of %xmm8, then rotates %xmm8 for +## next rcon. +## +## Smears the dwords of %xmm7 by xoring the low into the +## second low, result into third, result into highest. +## +## Returns results in %xmm7 = %xmm0. +## Clobbers %xmm1-%xmm4, %r11. +## + +.align 4 +_vpaes_schedule_round: + // extract rcon from xmm8 + movi v4.16b, #0 // vpxor %xmm4, %xmm4, %xmm4 + ext v1.16b, v8.16b, v4.16b, #15 // vpalignr $15, %xmm8, %xmm4, %xmm1 + ext v8.16b, v8.16b, v8.16b, #15 // vpalignr $15, %xmm8, %xmm8, %xmm8 + eor v7.16b, v7.16b, v1.16b // vpxor %xmm1, %xmm7, %xmm7 + + // rotate + dup v0.4s, v0.s[3] // vpshufd $0xFF, %xmm0, %xmm0 + ext v0.16b, v0.16b, v0.16b, #1 // vpalignr $1, %xmm0, %xmm0, %xmm0 + + // fall through... + + // low round: same as high round, but no rotation and no rcon. +_vpaes_schedule_low_round: + // smear xmm7 + ext v1.16b, v4.16b, v7.16b, #12 // vpslldq $4, %xmm7, %xmm1 + eor v7.16b, v7.16b, v1.16b // vpxor %xmm1, %xmm7, %xmm7 + ext v4.16b, v4.16b, v7.16b, #8 // vpslldq $8, %xmm7, %xmm4 + + // subbytes + and v1.16b, v0.16b, v17.16b // vpand %xmm9, %xmm0, %xmm1 # 0 = k + ushr v0.16b, v0.16b, #4 // vpsrlb $4, %xmm0, %xmm0 # 1 = i + eor v7.16b, v7.16b, v4.16b // vpxor %xmm4, %xmm7, %xmm7 + tbl v2.16b, {v19.16b}, v1.16b // vpshufb %xmm1, %xmm11, %xmm2 # 2 = a/k + eor v1.16b, v1.16b, v0.16b // vpxor %xmm0, %xmm1, %xmm1 # 0 = j + tbl v3.16b, {v18.16b}, v0.16b // vpshufb %xmm0, %xmm10, %xmm3 # 3 = 1/i + eor v3.16b, v3.16b, v2.16b // vpxor %xmm2, %xmm3, %xmm3 # 3 = iak = 1/i + a/k + tbl v4.16b, {v18.16b}, v1.16b // vpshufb %xmm1, %xmm10, %xmm4 # 4 = 1/j + eor v7.16b, v7.16b, v16.16b // vpxor Lk_s63(%rip), %xmm7, %xmm7 + tbl v3.16b, {v18.16b}, v3.16b // vpshufb %xmm3, %xmm10, %xmm3 # 2 = 1/iak + eor v4.16b, v4.16b, v2.16b // vpxor %xmm2, %xmm4, %xmm4 # 4 = jak = 1/j + a/k + tbl v2.16b, {v18.16b}, v4.16b // vpshufb %xmm4, %xmm10, %xmm2 # 3 = 1/jak + eor v3.16b, v3.16b, v1.16b // vpxor %xmm1, %xmm3, %xmm3 # 2 = io + eor v2.16b, v2.16b, v0.16b // vpxor %xmm0, %xmm2, %xmm2 # 3 = jo + tbl v4.16b, {v23.16b}, v3.16b // vpshufb %xmm3, %xmm13, %xmm4 # 4 = sbou + tbl v1.16b, {v22.16b}, v2.16b // vpshufb %xmm2, %xmm12, %xmm1 # 0 = sb1t + eor v1.16b, v1.16b, v4.16b // vpxor %xmm4, %xmm1, %xmm1 # 0 = sbox output + + // add in smeared stuff + eor v0.16b, v1.16b, v7.16b // vpxor %xmm7, %xmm1, %xmm0 + eor v7.16b, v1.16b, v7.16b // vmovdqa %xmm0, %xmm7 + ret + + +## +## .aes_schedule_transform +## +## Linear-transform %xmm0 according to tables at (%r11) +## +## Requires that %xmm9 = 0x0F0F... as in preheat +## Output in %xmm0 +## Clobbers %xmm1, %xmm2 +## + +.align 4 +_vpaes_schedule_transform: + and v1.16b, v0.16b, v17.16b // vpand %xmm9, %xmm0, %xmm1 + ushr v0.16b, v0.16b, #4 // vpsrlb $4, %xmm0, %xmm0 + // vmovdqa (%r11), %xmm2 # lo + tbl v2.16b, {v20.16b}, v1.16b // vpshufb %xmm1, %xmm2, %xmm2 + // vmovdqa 16(%r11), %xmm1 # hi + tbl v0.16b, {v21.16b}, v0.16b // vpshufb %xmm0, %xmm1, %xmm0 + eor v0.16b, v0.16b, v2.16b // vpxor %xmm2, %xmm0, %xmm0 + ret + + +## +## .aes_schedule_mangle +## +## Mangle xmm0 from (basis-transformed) standard version +## to our version. +## +## On encrypt, +## xor with 0x63 +## multiply by circulant 0,1,1,1 +## apply shiftrows transform +## +## On decrypt, +## xor with 0x63 +## multiply by "inverse mixcolumns" circulant E,B,D,9 +## deskew +## apply shiftrows transform +## +## +## Writes out to (%rdx), and increments or decrements it +## Keeps track of round number mod 4 in %r8 +## Preserves xmm0 +## Clobbers xmm1-xmm5 +## + +.align 4 +_vpaes_schedule_mangle: + mov v4.16b, v0.16b // vmovdqa %xmm0, %xmm4 # save xmm0 for later + // vmovdqa .Lk_mc_forward(%rip),%xmm5 + + // encrypting + eor v4.16b, v0.16b, v16.16b // vpxor Lk_s63(%rip), %xmm0, %xmm4 + add x2, x2, #16 // add $16, %rdx + tbl v4.16b, {v4.16b}, v9.16b // vpshufb %xmm5, %xmm4, %xmm4 + tbl v1.16b, {v4.16b}, v9.16b // vpshufb %xmm5, %xmm4, %xmm1 + tbl v3.16b, {v1.16b}, v9.16b // vpshufb %xmm5, %xmm1, %xmm3 + eor v4.16b, v4.16b, v1.16b // vpxor %xmm1, %xmm4, %xmm4 + ld1 {v1.2d}, [x8] // vmovdqa (%r8,%r10), %xmm1 + eor v3.16b, v3.16b, v4.16b // vpxor %xmm4, %xmm3, %xmm3 + +Lschedule_mangle_both: + tbl v3.16b, {v3.16b}, v1.16b // vpshufb %xmm1, %xmm3, %xmm3 + add x8, x8, #48 // add $-16, %r8 + and x8, x8, #~(1<<6) // and $0x30, %r8 + st1 {v3.2d}, [x2] // vmovdqu %xmm3, (%rdx) + ret + + +.globl _vpaes_set_encrypt_key +.private_extern _vpaes_set_encrypt_key + +.align 4 +_vpaes_set_encrypt_key: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-16]! + add x29,sp,#0 + stp d8,d9,[sp,#-16]! // ABI spec says so + + lsr w9, w1, #5 // shr $5,%eax + add w9, w9, #5 // $5,%eax + str w9, [x2,#240] // mov %eax,240(%rdx) # AES_KEY->rounds = nbits/32+5; + + mov w3, #0 // mov $0,%ecx + mov x8, #0x30 // mov $0x30,%r8d + bl _vpaes_schedule_core + eor x0, x0, x0 + + ldp d8,d9,[sp],#16 + ldp x29,x30,[sp],#16 + AARCH64_VALIDATE_LINK_REGISTER + ret + +.globl _vpaes_ctr32_encrypt_blocks +.private_extern _vpaes_ctr32_encrypt_blocks + +.align 4 +_vpaes_ctr32_encrypt_blocks: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-16]! + add x29,sp,#0 + stp d8,d9,[sp,#-16]! // ABI spec says so + stp d10,d11,[sp,#-16]! + stp d12,d13,[sp,#-16]! + stp d14,d15,[sp,#-16]! + + cbz x2, Lctr32_done + + // Note, unlike the other functions, x2 here is measured in blocks, + // not bytes. + mov x17, x2 + mov x2, x3 + + // Load the IV and counter portion. + ldr w6, [x4, #12] + ld1 {v7.16b}, [x4] + + bl _vpaes_encrypt_preheat + tst x17, #1 + rev w6, w6 // The counter is big-endian. + b.eq Lctr32_prep_loop + + // Handle one block so the remaining block count is even for + // _vpaes_encrypt_2x. + ld1 {v6.16b}, [x0], #16 // Load input ahead of time + bl _vpaes_encrypt_core + eor v0.16b, v0.16b, v6.16b // XOR input and result + st1 {v0.16b}, [x1], #16 + subs x17, x17, #1 + // Update the counter. + add w6, w6, #1 + rev w7, w6 + mov v7.s[3], w7 + b.ls Lctr32_done + +Lctr32_prep_loop: + // _vpaes_encrypt_core takes its input from v7, while _vpaes_encrypt_2x + // uses v14 and v15. + mov v15.16b, v7.16b + mov v14.16b, v7.16b + add w6, w6, #1 + rev w7, w6 + mov v15.s[3], w7 + +Lctr32_loop: + ld1 {v6.16b,v7.16b}, [x0], #32 // Load input ahead of time + bl _vpaes_encrypt_2x + eor v0.16b, v0.16b, v6.16b // XOR input and result + eor v1.16b, v1.16b, v7.16b // XOR input and result (#2) + st1 {v0.16b,v1.16b}, [x1], #32 + subs x17, x17, #2 + // Update the counter. + add w7, w6, #1 + add w6, w6, #2 + rev w7, w7 + mov v14.s[3], w7 + rev w7, w6 + mov v15.s[3], w7 + b.hi Lctr32_loop + +Lctr32_done: + ldp d14,d15,[sp],#16 + ldp d12,d13,[sp],#16 + ldp d10,d11,[sp],#16 + ldp d8,d9,[sp],#16 + ldp x29,x30,[sp],#16 + AARCH64_VALIDATE_LINK_REGISTER + ret + +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__APPLE__) diff --git a/http/vendor/ring/pregenerated/vpaes-armv8-linux64.S b/http/vendor/ring/pregenerated/vpaes-armv8-linux64.S new file mode 100644 index 0000000..c3c60f6 --- /dev/null +++ b/http/vendor/ring/pregenerated/vpaes-armv8-linux64.S @@ -0,0 +1,744 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(__ELF__) +.section .rodata + +.type _vpaes_consts,%object +.align 7 // totally strategic alignment +_vpaes_consts: +.Lk_mc_forward: // mc_forward +.quad 0x0407060500030201, 0x0C0F0E0D080B0A09 +.quad 0x080B0A0904070605, 0x000302010C0F0E0D +.quad 0x0C0F0E0D080B0A09, 0x0407060500030201 +.quad 0x000302010C0F0E0D, 0x080B0A0904070605 +.Lk_mc_backward: // mc_backward +.quad 0x0605040702010003, 0x0E0D0C0F0A09080B +.quad 0x020100030E0D0C0F, 0x0A09080B06050407 +.quad 0x0E0D0C0F0A09080B, 0x0605040702010003 +.quad 0x0A09080B06050407, 0x020100030E0D0C0F +.Lk_sr: // sr +.quad 0x0706050403020100, 0x0F0E0D0C0B0A0908 +.quad 0x030E09040F0A0500, 0x0B06010C07020D08 +.quad 0x0F060D040B020900, 0x070E050C030A0108 +.quad 0x0B0E0104070A0D00, 0x0306090C0F020508 + +// +// "Hot" constants +// +.Lk_inv: // inv, inva +.quad 0x0E05060F0D080180, 0x040703090A0B0C02 +.quad 0x01040A060F0B0780, 0x030D0E0C02050809 +.Lk_ipt: // input transform (lo, hi) +.quad 0xC2B2E8985A2A7000, 0xCABAE09052227808 +.quad 0x4C01307D317C4D00, 0xCD80B1FCB0FDCC81 +.Lk_sbo: // sbou, sbot +.quad 0xD0D26D176FBDC700, 0x15AABF7AC502A878 +.quad 0xCFE474A55FBB6A00, 0x8E1E90D1412B35FA +.Lk_sb1: // sb1u, sb1t +.quad 0x3618D415FAE22300, 0x3BF7CCC10D2ED9EF +.quad 0xB19BE18FCB503E00, 0xA5DF7A6E142AF544 +.Lk_sb2: // sb2u, sb2t +.quad 0x69EB88400AE12900, 0xC2A163C8AB82234A +.quad 0xE27A93C60B712400, 0x5EB7E955BC982FCD + +// +// Key schedule constants +// +.Lk_dksd: // decryption key schedule: invskew x*D +.quad 0xFEB91A5DA3E44700, 0x0740E3A45A1DBEF9 +.quad 0x41C277F4B5368300, 0x5FDC69EAAB289D1E +.Lk_dksb: // decryption key schedule: invskew x*B +.quad 0x9A4FCA1F8550D500, 0x03D653861CC94C99 +.quad 0x115BEDA7B6FC4A00, 0xD993256F7E3482C8 +.Lk_dkse: // decryption key schedule: invskew x*E + 0x63 +.quad 0xD5031CCA1FC9D600, 0x53859A4C994F5086 +.quad 0xA23196054FDC7BE8, 0xCD5EF96A20B31487 +.Lk_dks9: // decryption key schedule: invskew x*9 +.quad 0xB6116FC87ED9A700, 0x4AED933482255BFC +.quad 0x4576516227143300, 0x8BB89FACE9DAFDCE + +.Lk_rcon: // rcon +.quad 0x1F8391B9AF9DEEB6, 0x702A98084D7C7D81 + +.Lk_opt: // output transform +.quad 0xFF9F4929D6B66000, 0xF7974121DEBE6808 +.quad 0x01EDBD5150BCEC00, 0xE10D5DB1B05C0CE0 +.Lk_deskew: // deskew tables: inverts the sbox's "skew" +.quad 0x07E4A34047A4E300, 0x1DFEB95A5DBEF91A +.quad 0x5F36B5DC83EA6900, 0x2841C2ABF49D1E77 + +.byte 86,101,99,116,111,114,32,80,101,114,109,117,116,97,116,105,111,110,32,65,69,83,32,102,111,114,32,65,82,77,118,56,44,32,77,105,107,101,32,72,97,109,98,117,114,103,32,40,83,116,97,110,102,111,114,100,32,85,110,105,118,101,114,115,105,116,121,41,0 +.align 2 +.size _vpaes_consts,.-_vpaes_consts +.align 6 + +.text +## +## _aes_preheat +## +## Fills register %r10 -> .aes_consts (so you can -fPIC) +## and %xmm9-%xmm15 as specified below. +## +.type _vpaes_encrypt_preheat,%function +.align 4 +_vpaes_encrypt_preheat: + adrp x10, .Lk_inv + add x10, x10, :lo12:.Lk_inv + movi v17.16b, #0x0f + ld1 {v18.2d,v19.2d}, [x10],#32 // .Lk_inv + ld1 {v20.2d,v21.2d,v22.2d,v23.2d}, [x10],#64 // .Lk_ipt, .Lk_sbo + ld1 {v24.2d,v25.2d,v26.2d,v27.2d}, [x10] // .Lk_sb1, .Lk_sb2 + ret +.size _vpaes_encrypt_preheat,.-_vpaes_encrypt_preheat + +## +## _aes_encrypt_core +## +## AES-encrypt %xmm0. +## +## Inputs: +## %xmm0 = input +## %xmm9-%xmm15 as in _vpaes_preheat +## (%rdx) = scheduled keys +## +## Output in %xmm0 +## Clobbers %xmm1-%xmm5, %r9, %r10, %r11, %rax +## Preserves %xmm6 - %xmm8 so you get some local vectors +## +## +.type _vpaes_encrypt_core,%function +.align 4 +_vpaes_encrypt_core: + mov x9, x2 + ldr w8, [x2,#240] // pull rounds + adrp x11, .Lk_mc_forward+16 + add x11, x11, :lo12:.Lk_mc_forward+16 + // vmovdqa .Lk_ipt(%rip), %xmm2 # iptlo + ld1 {v16.2d}, [x9], #16 // vmovdqu (%r9), %xmm5 # round0 key + and v1.16b, v7.16b, v17.16b // vpand %xmm9, %xmm0, %xmm1 + ushr v0.16b, v7.16b, #4 // vpsrlb $4, %xmm0, %xmm0 + tbl v1.16b, {v20.16b}, v1.16b // vpshufb %xmm1, %xmm2, %xmm1 + // vmovdqa .Lk_ipt+16(%rip), %xmm3 # ipthi + tbl v2.16b, {v21.16b}, v0.16b // vpshufb %xmm0, %xmm3, %xmm2 + eor v0.16b, v1.16b, v16.16b // vpxor %xmm5, %xmm1, %xmm0 + eor v0.16b, v0.16b, v2.16b // vpxor %xmm2, %xmm0, %xmm0 + b .Lenc_entry + +.align 4 +.Lenc_loop: + // middle of middle round + add x10, x11, #0x40 + tbl v4.16b, {v25.16b}, v2.16b // vpshufb %xmm2, %xmm13, %xmm4 # 4 = sb1u + ld1 {v1.2d}, [x11], #16 // vmovdqa -0x40(%r11,%r10), %xmm1 # .Lk_mc_forward[] + tbl v0.16b, {v24.16b}, v3.16b // vpshufb %xmm3, %xmm12, %xmm0 # 0 = sb1t + eor v4.16b, v4.16b, v16.16b // vpxor %xmm5, %xmm4, %xmm4 # 4 = sb1u + k + tbl v5.16b, {v27.16b}, v2.16b // vpshufb %xmm2, %xmm15, %xmm5 # 4 = sb2u + eor v0.16b, v0.16b, v4.16b // vpxor %xmm4, %xmm0, %xmm0 # 0 = A + tbl v2.16b, {v26.16b}, v3.16b // vpshufb %xmm3, %xmm14, %xmm2 # 2 = sb2t + ld1 {v4.2d}, [x10] // vmovdqa (%r11,%r10), %xmm4 # .Lk_mc_backward[] + tbl v3.16b, {v0.16b}, v1.16b // vpshufb %xmm1, %xmm0, %xmm3 # 0 = B + eor v2.16b, v2.16b, v5.16b // vpxor %xmm5, %xmm2, %xmm2 # 2 = 2A + tbl v0.16b, {v0.16b}, v4.16b // vpshufb %xmm4, %xmm0, %xmm0 # 3 = D + eor v3.16b, v3.16b, v2.16b // vpxor %xmm2, %xmm3, %xmm3 # 0 = 2A+B + tbl v4.16b, {v3.16b}, v1.16b // vpshufb %xmm1, %xmm3, %xmm4 # 0 = 2B+C + eor v0.16b, v0.16b, v3.16b // vpxor %xmm3, %xmm0, %xmm0 # 3 = 2A+B+D + and x11, x11, #~(1<<6) // and $0x30, %r11 # ... mod 4 + eor v0.16b, v0.16b, v4.16b // vpxor %xmm4, %xmm0, %xmm0 # 0 = 2A+3B+C+D + sub w8, w8, #1 // nr-- + +.Lenc_entry: + // top of round + and v1.16b, v0.16b, v17.16b // vpand %xmm0, %xmm9, %xmm1 # 0 = k + ushr v0.16b, v0.16b, #4 // vpsrlb $4, %xmm0, %xmm0 # 1 = i + tbl v5.16b, {v19.16b}, v1.16b // vpshufb %xmm1, %xmm11, %xmm5 # 2 = a/k + eor v1.16b, v1.16b, v0.16b // vpxor %xmm0, %xmm1, %xmm1 # 0 = j + tbl v3.16b, {v18.16b}, v0.16b // vpshufb %xmm0, %xmm10, %xmm3 # 3 = 1/i + tbl v4.16b, {v18.16b}, v1.16b // vpshufb %xmm1, %xmm10, %xmm4 # 4 = 1/j + eor v3.16b, v3.16b, v5.16b // vpxor %xmm5, %xmm3, %xmm3 # 3 = iak = 1/i + a/k + eor v4.16b, v4.16b, v5.16b // vpxor %xmm5, %xmm4, %xmm4 # 4 = jak = 1/j + a/k + tbl v2.16b, {v18.16b}, v3.16b // vpshufb %xmm3, %xmm10, %xmm2 # 2 = 1/iak + tbl v3.16b, {v18.16b}, v4.16b // vpshufb %xmm4, %xmm10, %xmm3 # 3 = 1/jak + eor v2.16b, v2.16b, v1.16b // vpxor %xmm1, %xmm2, %xmm2 # 2 = io + eor v3.16b, v3.16b, v0.16b // vpxor %xmm0, %xmm3, %xmm3 # 3 = jo + ld1 {v16.2d}, [x9],#16 // vmovdqu (%r9), %xmm5 + cbnz w8, .Lenc_loop + + // middle of last round + add x10, x11, #0x80 + // vmovdqa -0x60(%r10), %xmm4 # 3 : sbou .Lk_sbo + // vmovdqa -0x50(%r10), %xmm0 # 0 : sbot .Lk_sbo+16 + tbl v4.16b, {v22.16b}, v2.16b // vpshufb %xmm2, %xmm4, %xmm4 # 4 = sbou + ld1 {v1.2d}, [x10] // vmovdqa 0x40(%r11,%r10), %xmm1 # .Lk_sr[] + tbl v0.16b, {v23.16b}, v3.16b // vpshufb %xmm3, %xmm0, %xmm0 # 0 = sb1t + eor v4.16b, v4.16b, v16.16b // vpxor %xmm5, %xmm4, %xmm4 # 4 = sb1u + k + eor v0.16b, v0.16b, v4.16b // vpxor %xmm4, %xmm0, %xmm0 # 0 = A + tbl v0.16b, {v0.16b}, v1.16b // vpshufb %xmm1, %xmm0, %xmm0 + ret +.size _vpaes_encrypt_core,.-_vpaes_encrypt_core + +.type _vpaes_encrypt_2x,%function +.align 4 +_vpaes_encrypt_2x: + mov x9, x2 + ldr w8, [x2,#240] // pull rounds + adrp x11, .Lk_mc_forward+16 + add x11, x11, :lo12:.Lk_mc_forward+16 + // vmovdqa .Lk_ipt(%rip), %xmm2 # iptlo + ld1 {v16.2d}, [x9], #16 // vmovdqu (%r9), %xmm5 # round0 key + and v1.16b, v14.16b, v17.16b // vpand %xmm9, %xmm0, %xmm1 + ushr v0.16b, v14.16b, #4 // vpsrlb $4, %xmm0, %xmm0 + and v9.16b, v15.16b, v17.16b + ushr v8.16b, v15.16b, #4 + tbl v1.16b, {v20.16b}, v1.16b // vpshufb %xmm1, %xmm2, %xmm1 + tbl v9.16b, {v20.16b}, v9.16b + // vmovdqa .Lk_ipt+16(%rip), %xmm3 # ipthi + tbl v2.16b, {v21.16b}, v0.16b // vpshufb %xmm0, %xmm3, %xmm2 + tbl v10.16b, {v21.16b}, v8.16b + eor v0.16b, v1.16b, v16.16b // vpxor %xmm5, %xmm1, %xmm0 + eor v8.16b, v9.16b, v16.16b + eor v0.16b, v0.16b, v2.16b // vpxor %xmm2, %xmm0, %xmm0 + eor v8.16b, v8.16b, v10.16b + b .Lenc_2x_entry + +.align 4 +.Lenc_2x_loop: + // middle of middle round + add x10, x11, #0x40 + tbl v4.16b, {v25.16b}, v2.16b // vpshufb %xmm2, %xmm13, %xmm4 # 4 = sb1u + tbl v12.16b, {v25.16b}, v10.16b + ld1 {v1.2d}, [x11], #16 // vmovdqa -0x40(%r11,%r10), %xmm1 # .Lk_mc_forward[] + tbl v0.16b, {v24.16b}, v3.16b // vpshufb %xmm3, %xmm12, %xmm0 # 0 = sb1t + tbl v8.16b, {v24.16b}, v11.16b + eor v4.16b, v4.16b, v16.16b // vpxor %xmm5, %xmm4, %xmm4 # 4 = sb1u + k + eor v12.16b, v12.16b, v16.16b + tbl v5.16b, {v27.16b}, v2.16b // vpshufb %xmm2, %xmm15, %xmm5 # 4 = sb2u + tbl v13.16b, {v27.16b}, v10.16b + eor v0.16b, v0.16b, v4.16b // vpxor %xmm4, %xmm0, %xmm0 # 0 = A + eor v8.16b, v8.16b, v12.16b + tbl v2.16b, {v26.16b}, v3.16b // vpshufb %xmm3, %xmm14, %xmm2 # 2 = sb2t + tbl v10.16b, {v26.16b}, v11.16b + ld1 {v4.2d}, [x10] // vmovdqa (%r11,%r10), %xmm4 # .Lk_mc_backward[] + tbl v3.16b, {v0.16b}, v1.16b // vpshufb %xmm1, %xmm0, %xmm3 # 0 = B + tbl v11.16b, {v8.16b}, v1.16b + eor v2.16b, v2.16b, v5.16b // vpxor %xmm5, %xmm2, %xmm2 # 2 = 2A + eor v10.16b, v10.16b, v13.16b + tbl v0.16b, {v0.16b}, v4.16b // vpshufb %xmm4, %xmm0, %xmm0 # 3 = D + tbl v8.16b, {v8.16b}, v4.16b + eor v3.16b, v3.16b, v2.16b // vpxor %xmm2, %xmm3, %xmm3 # 0 = 2A+B + eor v11.16b, v11.16b, v10.16b + tbl v4.16b, {v3.16b}, v1.16b // vpshufb %xmm1, %xmm3, %xmm4 # 0 = 2B+C + tbl v12.16b, {v11.16b},v1.16b + eor v0.16b, v0.16b, v3.16b // vpxor %xmm3, %xmm0, %xmm0 # 3 = 2A+B+D + eor v8.16b, v8.16b, v11.16b + and x11, x11, #~(1<<6) // and $0x30, %r11 # ... mod 4 + eor v0.16b, v0.16b, v4.16b // vpxor %xmm4, %xmm0, %xmm0 # 0 = 2A+3B+C+D + eor v8.16b, v8.16b, v12.16b + sub w8, w8, #1 // nr-- + +.Lenc_2x_entry: + // top of round + and v1.16b, v0.16b, v17.16b // vpand %xmm0, %xmm9, %xmm1 # 0 = k + ushr v0.16b, v0.16b, #4 // vpsrlb $4, %xmm0, %xmm0 # 1 = i + and v9.16b, v8.16b, v17.16b + ushr v8.16b, v8.16b, #4 + tbl v5.16b, {v19.16b},v1.16b // vpshufb %xmm1, %xmm11, %xmm5 # 2 = a/k + tbl v13.16b, {v19.16b},v9.16b + eor v1.16b, v1.16b, v0.16b // vpxor %xmm0, %xmm1, %xmm1 # 0 = j + eor v9.16b, v9.16b, v8.16b + tbl v3.16b, {v18.16b},v0.16b // vpshufb %xmm0, %xmm10, %xmm3 # 3 = 1/i + tbl v11.16b, {v18.16b},v8.16b + tbl v4.16b, {v18.16b},v1.16b // vpshufb %xmm1, %xmm10, %xmm4 # 4 = 1/j + tbl v12.16b, {v18.16b},v9.16b + eor v3.16b, v3.16b, v5.16b // vpxor %xmm5, %xmm3, %xmm3 # 3 = iak = 1/i + a/k + eor v11.16b, v11.16b, v13.16b + eor v4.16b, v4.16b, v5.16b // vpxor %xmm5, %xmm4, %xmm4 # 4 = jak = 1/j + a/k + eor v12.16b, v12.16b, v13.16b + tbl v2.16b, {v18.16b},v3.16b // vpshufb %xmm3, %xmm10, %xmm2 # 2 = 1/iak + tbl v10.16b, {v18.16b},v11.16b + tbl v3.16b, {v18.16b},v4.16b // vpshufb %xmm4, %xmm10, %xmm3 # 3 = 1/jak + tbl v11.16b, {v18.16b},v12.16b + eor v2.16b, v2.16b, v1.16b // vpxor %xmm1, %xmm2, %xmm2 # 2 = io + eor v10.16b, v10.16b, v9.16b + eor v3.16b, v3.16b, v0.16b // vpxor %xmm0, %xmm3, %xmm3 # 3 = jo + eor v11.16b, v11.16b, v8.16b + ld1 {v16.2d}, [x9],#16 // vmovdqu (%r9), %xmm5 + cbnz w8, .Lenc_2x_loop + + // middle of last round + add x10, x11, #0x80 + // vmovdqa -0x60(%r10), %xmm4 # 3 : sbou .Lk_sbo + // vmovdqa -0x50(%r10), %xmm0 # 0 : sbot .Lk_sbo+16 + tbl v4.16b, {v22.16b}, v2.16b // vpshufb %xmm2, %xmm4, %xmm4 # 4 = sbou + tbl v12.16b, {v22.16b}, v10.16b + ld1 {v1.2d}, [x10] // vmovdqa 0x40(%r11,%r10), %xmm1 # .Lk_sr[] + tbl v0.16b, {v23.16b}, v3.16b // vpshufb %xmm3, %xmm0, %xmm0 # 0 = sb1t + tbl v8.16b, {v23.16b}, v11.16b + eor v4.16b, v4.16b, v16.16b // vpxor %xmm5, %xmm4, %xmm4 # 4 = sb1u + k + eor v12.16b, v12.16b, v16.16b + eor v0.16b, v0.16b, v4.16b // vpxor %xmm4, %xmm0, %xmm0 # 0 = A + eor v8.16b, v8.16b, v12.16b + tbl v0.16b, {v0.16b},v1.16b // vpshufb %xmm1, %xmm0, %xmm0 + tbl v1.16b, {v8.16b},v1.16b + ret +.size _vpaes_encrypt_2x,.-_vpaes_encrypt_2x +######################################################## +## ## +## AES key schedule ## +## ## +######################################################## +.type _vpaes_key_preheat,%function +.align 4 +_vpaes_key_preheat: + adrp x10, .Lk_inv + add x10, x10, :lo12:.Lk_inv + movi v16.16b, #0x5b // .Lk_s63 + adrp x11, .Lk_sb1 + add x11, x11, :lo12:.Lk_sb1 + movi v17.16b, #0x0f // .Lk_s0F + ld1 {v18.2d,v19.2d,v20.2d,v21.2d}, [x10] // .Lk_inv, .Lk_ipt + adrp x10, .Lk_dksd + add x10, x10, :lo12:.Lk_dksd + ld1 {v22.2d,v23.2d}, [x11] // .Lk_sb1 + adrp x11, .Lk_mc_forward + add x11, x11, :lo12:.Lk_mc_forward + ld1 {v24.2d,v25.2d,v26.2d,v27.2d}, [x10],#64 // .Lk_dksd, .Lk_dksb + ld1 {v28.2d,v29.2d,v30.2d,v31.2d}, [x10],#64 // .Lk_dkse, .Lk_dks9 + ld1 {v8.2d}, [x10] // .Lk_rcon + ld1 {v9.2d}, [x11] // .Lk_mc_forward[0] + ret +.size _vpaes_key_preheat,.-_vpaes_key_preheat + +.type _vpaes_schedule_core,%function +.align 4 +_vpaes_schedule_core: + AARCH64_SIGN_LINK_REGISTER + stp x29, x30, [sp,#-16]! + add x29,sp,#0 + + bl _vpaes_key_preheat // load the tables + + ld1 {v0.16b}, [x0],#16 // vmovdqu (%rdi), %xmm0 # load key (unaligned) + + // input transform + mov v3.16b, v0.16b // vmovdqa %xmm0, %xmm3 + bl _vpaes_schedule_transform + mov v7.16b, v0.16b // vmovdqa %xmm0, %xmm7 + + adrp x10, .Lk_sr // lea .Lk_sr(%rip),%r10 + add x10, x10, :lo12:.Lk_sr + + add x8, x8, x10 + + // encrypting, output zeroth round key after transform + st1 {v0.2d}, [x2] // vmovdqu %xmm0, (%rdx) + + cmp w1, #192 // cmp $192, %esi + b.hi .Lschedule_256 + b.eq .Lschedule_192 + // 128: fall though + +## +## .schedule_128 +## +## 128-bit specific part of key schedule. +## +## This schedule is really simple, because all its parts +## are accomplished by the subroutines. +## +.Lschedule_128: + mov x0, #10 // mov $10, %esi + +.Loop_schedule_128: + sub x0, x0, #1 // dec %esi + bl _vpaes_schedule_round + cbz x0, .Lschedule_mangle_last + bl _vpaes_schedule_mangle // write output + b .Loop_schedule_128 + +## +## .aes_schedule_192 +## +## 192-bit specific part of key schedule. +## +## The main body of this schedule is the same as the 128-bit +## schedule, but with more smearing. The long, high side is +## stored in %xmm7 as before, and the short, low side is in +## the high bits of %xmm6. +## +## This schedule is somewhat nastier, however, because each +## round produces 192 bits of key material, or 1.5 round keys. +## Therefore, on each cycle we do 2 rounds and produce 3 round +## keys. +## +.align 4 +.Lschedule_192: + sub x0, x0, #8 + ld1 {v0.16b}, [x0] // vmovdqu 8(%rdi),%xmm0 # load key part 2 (very unaligned) + bl _vpaes_schedule_transform // input transform + mov v6.16b, v0.16b // vmovdqa %xmm0, %xmm6 # save short part + eor v4.16b, v4.16b, v4.16b // vpxor %xmm4, %xmm4, %xmm4 # clear 4 + ins v6.d[0], v4.d[0] // vmovhlps %xmm4, %xmm6, %xmm6 # clobber low side with zeros + mov x0, #4 // mov $4, %esi + +.Loop_schedule_192: + sub x0, x0, #1 // dec %esi + bl _vpaes_schedule_round + ext v0.16b, v6.16b, v0.16b, #8 // vpalignr $8,%xmm6,%xmm0,%xmm0 + bl _vpaes_schedule_mangle // save key n + bl _vpaes_schedule_192_smear + bl _vpaes_schedule_mangle // save key n+1 + bl _vpaes_schedule_round + cbz x0, .Lschedule_mangle_last + bl _vpaes_schedule_mangle // save key n+2 + bl _vpaes_schedule_192_smear + b .Loop_schedule_192 + +## +## .aes_schedule_256 +## +## 256-bit specific part of key schedule. +## +## The structure here is very similar to the 128-bit +## schedule, but with an additional "low side" in +## %xmm6. The low side's rounds are the same as the +## high side's, except no rcon and no rotation. +## +.align 4 +.Lschedule_256: + ld1 {v0.16b}, [x0] // vmovdqu 16(%rdi),%xmm0 # load key part 2 (unaligned) + bl _vpaes_schedule_transform // input transform + mov x0, #7 // mov $7, %esi + +.Loop_schedule_256: + sub x0, x0, #1 // dec %esi + bl _vpaes_schedule_mangle // output low result + mov v6.16b, v0.16b // vmovdqa %xmm0, %xmm6 # save cur_lo in xmm6 + + // high round + bl _vpaes_schedule_round + cbz x0, .Lschedule_mangle_last + bl _vpaes_schedule_mangle + + // low round. swap xmm7 and xmm6 + dup v0.4s, v0.s[3] // vpshufd $0xFF, %xmm0, %xmm0 + movi v4.16b, #0 + mov v5.16b, v7.16b // vmovdqa %xmm7, %xmm5 + mov v7.16b, v6.16b // vmovdqa %xmm6, %xmm7 + bl _vpaes_schedule_low_round + mov v7.16b, v5.16b // vmovdqa %xmm5, %xmm7 + + b .Loop_schedule_256 + +## +## .aes_schedule_mangle_last +## +## Mangler for last round of key schedule +## Mangles %xmm0 +## when encrypting, outputs out(%xmm0) ^ 63 +## when decrypting, outputs unskew(%xmm0) +## +## Always called right before return... jumps to cleanup and exits +## +.align 4 +.Lschedule_mangle_last: + // schedule last round key from xmm0 + adrp x11, .Lk_deskew // lea .Lk_deskew(%rip),%r11 # prepare to deskew + add x11, x11, :lo12:.Lk_deskew + + cbnz w3, .Lschedule_mangle_last_dec + + // encrypting + ld1 {v1.2d}, [x8] // vmovdqa (%r8,%r10),%xmm1 + adrp x11, .Lk_opt // lea .Lk_opt(%rip), %r11 # prepare to output transform + add x11, x11, :lo12:.Lk_opt + add x2, x2, #32 // add $32, %rdx + tbl v0.16b, {v0.16b}, v1.16b // vpshufb %xmm1, %xmm0, %xmm0 # output permute + +.Lschedule_mangle_last_dec: + ld1 {v20.2d,v21.2d}, [x11] // reload constants + sub x2, x2, #16 // add $-16, %rdx + eor v0.16b, v0.16b, v16.16b // vpxor .Lk_s63(%rip), %xmm0, %xmm0 + bl _vpaes_schedule_transform // output transform + st1 {v0.2d}, [x2] // vmovdqu %xmm0, (%rdx) # save last key + + // cleanup + eor v0.16b, v0.16b, v0.16b // vpxor %xmm0, %xmm0, %xmm0 + eor v1.16b, v1.16b, v1.16b // vpxor %xmm1, %xmm1, %xmm1 + eor v2.16b, v2.16b, v2.16b // vpxor %xmm2, %xmm2, %xmm2 + eor v3.16b, v3.16b, v3.16b // vpxor %xmm3, %xmm3, %xmm3 + eor v4.16b, v4.16b, v4.16b // vpxor %xmm4, %xmm4, %xmm4 + eor v5.16b, v5.16b, v5.16b // vpxor %xmm5, %xmm5, %xmm5 + eor v6.16b, v6.16b, v6.16b // vpxor %xmm6, %xmm6, %xmm6 + eor v7.16b, v7.16b, v7.16b // vpxor %xmm7, %xmm7, %xmm7 + ldp x29, x30, [sp],#16 + AARCH64_VALIDATE_LINK_REGISTER + ret +.size _vpaes_schedule_core,.-_vpaes_schedule_core + +## +## .aes_schedule_192_smear +## +## Smear the short, low side in the 192-bit key schedule. +## +## Inputs: +## %xmm7: high side, b a x y +## %xmm6: low side, d c 0 0 +## %xmm13: 0 +## +## Outputs: +## %xmm6: b+c+d b+c 0 0 +## %xmm0: b+c+d b+c b a +## +.type _vpaes_schedule_192_smear,%function +.align 4 +_vpaes_schedule_192_smear: + movi v1.16b, #0 + dup v0.4s, v7.s[3] + ins v1.s[3], v6.s[2] // vpshufd $0x80, %xmm6, %xmm1 # d c 0 0 -> c 0 0 0 + ins v0.s[0], v7.s[2] // vpshufd $0xFE, %xmm7, %xmm0 # b a _ _ -> b b b a + eor v6.16b, v6.16b, v1.16b // vpxor %xmm1, %xmm6, %xmm6 # -> c+d c 0 0 + eor v1.16b, v1.16b, v1.16b // vpxor %xmm1, %xmm1, %xmm1 + eor v6.16b, v6.16b, v0.16b // vpxor %xmm0, %xmm6, %xmm6 # -> b+c+d b+c b a + mov v0.16b, v6.16b // vmovdqa %xmm6, %xmm0 + ins v6.d[0], v1.d[0] // vmovhlps %xmm1, %xmm6, %xmm6 # clobber low side with zeros + ret +.size _vpaes_schedule_192_smear,.-_vpaes_schedule_192_smear + +## +## .aes_schedule_round +## +## Runs one main round of the key schedule on %xmm0, %xmm7 +## +## Specifically, runs subbytes on the high dword of %xmm0 +## then rotates it by one byte and xors into the low dword of +## %xmm7. +## +## Adds rcon from low byte of %xmm8, then rotates %xmm8 for +## next rcon. +## +## Smears the dwords of %xmm7 by xoring the low into the +## second low, result into third, result into highest. +## +## Returns results in %xmm7 = %xmm0. +## Clobbers %xmm1-%xmm4, %r11. +## +.type _vpaes_schedule_round,%function +.align 4 +_vpaes_schedule_round: + // extract rcon from xmm8 + movi v4.16b, #0 // vpxor %xmm4, %xmm4, %xmm4 + ext v1.16b, v8.16b, v4.16b, #15 // vpalignr $15, %xmm8, %xmm4, %xmm1 + ext v8.16b, v8.16b, v8.16b, #15 // vpalignr $15, %xmm8, %xmm8, %xmm8 + eor v7.16b, v7.16b, v1.16b // vpxor %xmm1, %xmm7, %xmm7 + + // rotate + dup v0.4s, v0.s[3] // vpshufd $0xFF, %xmm0, %xmm0 + ext v0.16b, v0.16b, v0.16b, #1 // vpalignr $1, %xmm0, %xmm0, %xmm0 + + // fall through... + + // low round: same as high round, but no rotation and no rcon. +_vpaes_schedule_low_round: + // smear xmm7 + ext v1.16b, v4.16b, v7.16b, #12 // vpslldq $4, %xmm7, %xmm1 + eor v7.16b, v7.16b, v1.16b // vpxor %xmm1, %xmm7, %xmm7 + ext v4.16b, v4.16b, v7.16b, #8 // vpslldq $8, %xmm7, %xmm4 + + // subbytes + and v1.16b, v0.16b, v17.16b // vpand %xmm9, %xmm0, %xmm1 # 0 = k + ushr v0.16b, v0.16b, #4 // vpsrlb $4, %xmm0, %xmm0 # 1 = i + eor v7.16b, v7.16b, v4.16b // vpxor %xmm4, %xmm7, %xmm7 + tbl v2.16b, {v19.16b}, v1.16b // vpshufb %xmm1, %xmm11, %xmm2 # 2 = a/k + eor v1.16b, v1.16b, v0.16b // vpxor %xmm0, %xmm1, %xmm1 # 0 = j + tbl v3.16b, {v18.16b}, v0.16b // vpshufb %xmm0, %xmm10, %xmm3 # 3 = 1/i + eor v3.16b, v3.16b, v2.16b // vpxor %xmm2, %xmm3, %xmm3 # 3 = iak = 1/i + a/k + tbl v4.16b, {v18.16b}, v1.16b // vpshufb %xmm1, %xmm10, %xmm4 # 4 = 1/j + eor v7.16b, v7.16b, v16.16b // vpxor .Lk_s63(%rip), %xmm7, %xmm7 + tbl v3.16b, {v18.16b}, v3.16b // vpshufb %xmm3, %xmm10, %xmm3 # 2 = 1/iak + eor v4.16b, v4.16b, v2.16b // vpxor %xmm2, %xmm4, %xmm4 # 4 = jak = 1/j + a/k + tbl v2.16b, {v18.16b}, v4.16b // vpshufb %xmm4, %xmm10, %xmm2 # 3 = 1/jak + eor v3.16b, v3.16b, v1.16b // vpxor %xmm1, %xmm3, %xmm3 # 2 = io + eor v2.16b, v2.16b, v0.16b // vpxor %xmm0, %xmm2, %xmm2 # 3 = jo + tbl v4.16b, {v23.16b}, v3.16b // vpshufb %xmm3, %xmm13, %xmm4 # 4 = sbou + tbl v1.16b, {v22.16b}, v2.16b // vpshufb %xmm2, %xmm12, %xmm1 # 0 = sb1t + eor v1.16b, v1.16b, v4.16b // vpxor %xmm4, %xmm1, %xmm1 # 0 = sbox output + + // add in smeared stuff + eor v0.16b, v1.16b, v7.16b // vpxor %xmm7, %xmm1, %xmm0 + eor v7.16b, v1.16b, v7.16b // vmovdqa %xmm0, %xmm7 + ret +.size _vpaes_schedule_round,.-_vpaes_schedule_round + +## +## .aes_schedule_transform +## +## Linear-transform %xmm0 according to tables at (%r11) +## +## Requires that %xmm9 = 0x0F0F... as in preheat +## Output in %xmm0 +## Clobbers %xmm1, %xmm2 +## +.type _vpaes_schedule_transform,%function +.align 4 +_vpaes_schedule_transform: + and v1.16b, v0.16b, v17.16b // vpand %xmm9, %xmm0, %xmm1 + ushr v0.16b, v0.16b, #4 // vpsrlb $4, %xmm0, %xmm0 + // vmovdqa (%r11), %xmm2 # lo + tbl v2.16b, {v20.16b}, v1.16b // vpshufb %xmm1, %xmm2, %xmm2 + // vmovdqa 16(%r11), %xmm1 # hi + tbl v0.16b, {v21.16b}, v0.16b // vpshufb %xmm0, %xmm1, %xmm0 + eor v0.16b, v0.16b, v2.16b // vpxor %xmm2, %xmm0, %xmm0 + ret +.size _vpaes_schedule_transform,.-_vpaes_schedule_transform + +## +## .aes_schedule_mangle +## +## Mangle xmm0 from (basis-transformed) standard version +## to our version. +## +## On encrypt, +## xor with 0x63 +## multiply by circulant 0,1,1,1 +## apply shiftrows transform +## +## On decrypt, +## xor with 0x63 +## multiply by "inverse mixcolumns" circulant E,B,D,9 +## deskew +## apply shiftrows transform +## +## +## Writes out to (%rdx), and increments or decrements it +## Keeps track of round number mod 4 in %r8 +## Preserves xmm0 +## Clobbers xmm1-xmm5 +## +.type _vpaes_schedule_mangle,%function +.align 4 +_vpaes_schedule_mangle: + mov v4.16b, v0.16b // vmovdqa %xmm0, %xmm4 # save xmm0 for later + // vmovdqa .Lk_mc_forward(%rip),%xmm5 + + // encrypting + eor v4.16b, v0.16b, v16.16b // vpxor .Lk_s63(%rip), %xmm0, %xmm4 + add x2, x2, #16 // add $16, %rdx + tbl v4.16b, {v4.16b}, v9.16b // vpshufb %xmm5, %xmm4, %xmm4 + tbl v1.16b, {v4.16b}, v9.16b // vpshufb %xmm5, %xmm4, %xmm1 + tbl v3.16b, {v1.16b}, v9.16b // vpshufb %xmm5, %xmm1, %xmm3 + eor v4.16b, v4.16b, v1.16b // vpxor %xmm1, %xmm4, %xmm4 + ld1 {v1.2d}, [x8] // vmovdqa (%r8,%r10), %xmm1 + eor v3.16b, v3.16b, v4.16b // vpxor %xmm4, %xmm3, %xmm3 + +.Lschedule_mangle_both: + tbl v3.16b, {v3.16b}, v1.16b // vpshufb %xmm1, %xmm3, %xmm3 + add x8, x8, #48 // add $-16, %r8 + and x8, x8, #~(1<<6) // and $0x30, %r8 + st1 {v3.2d}, [x2] // vmovdqu %xmm3, (%rdx) + ret +.size _vpaes_schedule_mangle,.-_vpaes_schedule_mangle + +.globl vpaes_set_encrypt_key +.hidden vpaes_set_encrypt_key +.type vpaes_set_encrypt_key,%function +.align 4 +vpaes_set_encrypt_key: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-16]! + add x29,sp,#0 + stp d8,d9,[sp,#-16]! // ABI spec says so + + lsr w9, w1, #5 // shr $5,%eax + add w9, w9, #5 // $5,%eax + str w9, [x2,#240] // mov %eax,240(%rdx) # AES_KEY->rounds = nbits/32+5; + + mov w3, #0 // mov $0,%ecx + mov x8, #0x30 // mov $0x30,%r8d + bl _vpaes_schedule_core + eor x0, x0, x0 + + ldp d8,d9,[sp],#16 + ldp x29,x30,[sp],#16 + AARCH64_VALIDATE_LINK_REGISTER + ret +.size vpaes_set_encrypt_key,.-vpaes_set_encrypt_key +.globl vpaes_ctr32_encrypt_blocks +.hidden vpaes_ctr32_encrypt_blocks +.type vpaes_ctr32_encrypt_blocks,%function +.align 4 +vpaes_ctr32_encrypt_blocks: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-16]! + add x29,sp,#0 + stp d8,d9,[sp,#-16]! // ABI spec says so + stp d10,d11,[sp,#-16]! + stp d12,d13,[sp,#-16]! + stp d14,d15,[sp,#-16]! + + cbz x2, .Lctr32_done + + // Note, unlike the other functions, x2 here is measured in blocks, + // not bytes. + mov x17, x2 + mov x2, x3 + + // Load the IV and counter portion. + ldr w6, [x4, #12] + ld1 {v7.16b}, [x4] + + bl _vpaes_encrypt_preheat + tst x17, #1 + rev w6, w6 // The counter is big-endian. + b.eq .Lctr32_prep_loop + + // Handle one block so the remaining block count is even for + // _vpaes_encrypt_2x. + ld1 {v6.16b}, [x0], #16 // .Load input ahead of time + bl _vpaes_encrypt_core + eor v0.16b, v0.16b, v6.16b // XOR input and result + st1 {v0.16b}, [x1], #16 + subs x17, x17, #1 + // Update the counter. + add w6, w6, #1 + rev w7, w6 + mov v7.s[3], w7 + b.ls .Lctr32_done + +.Lctr32_prep_loop: + // _vpaes_encrypt_core takes its input from v7, while _vpaes_encrypt_2x + // uses v14 and v15. + mov v15.16b, v7.16b + mov v14.16b, v7.16b + add w6, w6, #1 + rev w7, w6 + mov v15.s[3], w7 + +.Lctr32_loop: + ld1 {v6.16b,v7.16b}, [x0], #32 // .Load input ahead of time + bl _vpaes_encrypt_2x + eor v0.16b, v0.16b, v6.16b // XOR input and result + eor v1.16b, v1.16b, v7.16b // XOR input and result (#2) + st1 {v0.16b,v1.16b}, [x1], #32 + subs x17, x17, #2 + // Update the counter. + add w7, w6, #1 + add w6, w6, #2 + rev w7, w7 + mov v14.s[3], w7 + rev w7, w6 + mov v15.s[3], w7 + b.hi .Lctr32_loop + +.Lctr32_done: + ldp d14,d15,[sp],#16 + ldp d12,d13,[sp],#16 + ldp d10,d11,[sp],#16 + ldp d8,d9,[sp],#16 + ldp x29,x30,[sp],#16 + AARCH64_VALIDATE_LINK_REGISTER + ret +.size vpaes_ctr32_encrypt_blocks,.-vpaes_ctr32_encrypt_blocks +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(__ELF__) diff --git a/http/vendor/ring/pregenerated/vpaes-armv8-win64.S b/http/vendor/ring/pregenerated/vpaes-armv8-win64.S new file mode 100644 index 0000000..6a52437 --- /dev/null +++ b/http/vendor/ring/pregenerated/vpaes-armv8-win64.S @@ -0,0 +1,766 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_AARCH64) && defined(_WIN32) +.section .rodata + + +.align 7 // totally strategic alignment +_vpaes_consts: +Lk_mc_forward: // mc_forward +.quad 0x0407060500030201, 0x0C0F0E0D080B0A09 +.quad 0x080B0A0904070605, 0x000302010C0F0E0D +.quad 0x0C0F0E0D080B0A09, 0x0407060500030201 +.quad 0x000302010C0F0E0D, 0x080B0A0904070605 +Lk_mc_backward: // mc_backward +.quad 0x0605040702010003, 0x0E0D0C0F0A09080B +.quad 0x020100030E0D0C0F, 0x0A09080B06050407 +.quad 0x0E0D0C0F0A09080B, 0x0605040702010003 +.quad 0x0A09080B06050407, 0x020100030E0D0C0F +Lk_sr: // sr +.quad 0x0706050403020100, 0x0F0E0D0C0B0A0908 +.quad 0x030E09040F0A0500, 0x0B06010C07020D08 +.quad 0x0F060D040B020900, 0x070E050C030A0108 +.quad 0x0B0E0104070A0D00, 0x0306090C0F020508 + +// +// "Hot" constants +// +Lk_inv: // inv, inva +.quad 0x0E05060F0D080180, 0x040703090A0B0C02 +.quad 0x01040A060F0B0780, 0x030D0E0C02050809 +Lk_ipt: // input transform (lo, hi) +.quad 0xC2B2E8985A2A7000, 0xCABAE09052227808 +.quad 0x4C01307D317C4D00, 0xCD80B1FCB0FDCC81 +Lk_sbo: // sbou, sbot +.quad 0xD0D26D176FBDC700, 0x15AABF7AC502A878 +.quad 0xCFE474A55FBB6A00, 0x8E1E90D1412B35FA +Lk_sb1: // sb1u, sb1t +.quad 0x3618D415FAE22300, 0x3BF7CCC10D2ED9EF +.quad 0xB19BE18FCB503E00, 0xA5DF7A6E142AF544 +Lk_sb2: // sb2u, sb2t +.quad 0x69EB88400AE12900, 0xC2A163C8AB82234A +.quad 0xE27A93C60B712400, 0x5EB7E955BC982FCD + +// +// Key schedule constants +// +Lk_dksd: // decryption key schedule: invskew x*D +.quad 0xFEB91A5DA3E44700, 0x0740E3A45A1DBEF9 +.quad 0x41C277F4B5368300, 0x5FDC69EAAB289D1E +Lk_dksb: // decryption key schedule: invskew x*B +.quad 0x9A4FCA1F8550D500, 0x03D653861CC94C99 +.quad 0x115BEDA7B6FC4A00, 0xD993256F7E3482C8 +Lk_dkse: // decryption key schedule: invskew x*E + 0x63 +.quad 0xD5031CCA1FC9D600, 0x53859A4C994F5086 +.quad 0xA23196054FDC7BE8, 0xCD5EF96A20B31487 +Lk_dks9: // decryption key schedule: invskew x*9 +.quad 0xB6116FC87ED9A700, 0x4AED933482255BFC +.quad 0x4576516227143300, 0x8BB89FACE9DAFDCE + +Lk_rcon: // rcon +.quad 0x1F8391B9AF9DEEB6, 0x702A98084D7C7D81 + +Lk_opt: // output transform +.quad 0xFF9F4929D6B66000, 0xF7974121DEBE6808 +.quad 0x01EDBD5150BCEC00, 0xE10D5DB1B05C0CE0 +Lk_deskew: // deskew tables: inverts the sbox's "skew" +.quad 0x07E4A34047A4E300, 0x1DFEB95A5DBEF91A +.quad 0x5F36B5DC83EA6900, 0x2841C2ABF49D1E77 + +.byte 86,101,99,116,111,114,32,80,101,114,109,117,116,97,116,105,111,110,32,65,69,83,32,102,111,114,32,65,82,77,118,56,44,32,77,105,107,101,32,72,97,109,98,117,114,103,32,40,83,116,97,110,102,111,114,100,32,85,110,105,118,101,114,115,105,116,121,41,0 +.align 2 + +.align 6 + +.text +## +## _aes_preheat +## +## Fills register %r10 -> .aes_consts (so you can -fPIC) +## and %xmm9-%xmm15 as specified below. +## +.def _vpaes_encrypt_preheat + .type 32 +.endef +.align 4 +_vpaes_encrypt_preheat: + adrp x10, Lk_inv + add x10, x10, :lo12:Lk_inv + movi v17.16b, #0x0f + ld1 {v18.2d,v19.2d}, [x10],#32 // Lk_inv + ld1 {v20.2d,v21.2d,v22.2d,v23.2d}, [x10],#64 // Lk_ipt, Lk_sbo + ld1 {v24.2d,v25.2d,v26.2d,v27.2d}, [x10] // Lk_sb1, Lk_sb2 + ret + + +## +## _aes_encrypt_core +## +## AES-encrypt %xmm0. +## +## Inputs: +## %xmm0 = input +## %xmm9-%xmm15 as in _vpaes_preheat +## (%rdx) = scheduled keys +## +## Output in %xmm0 +## Clobbers %xmm1-%xmm5, %r9, %r10, %r11, %rax +## Preserves %xmm6 - %xmm8 so you get some local vectors +## +## +.def _vpaes_encrypt_core + .type 32 +.endef +.align 4 +_vpaes_encrypt_core: + mov x9, x2 + ldr w8, [x2,#240] // pull rounds + adrp x11, Lk_mc_forward+16 + add x11, x11, :lo12:Lk_mc_forward+16 + // vmovdqa .Lk_ipt(%rip), %xmm2 # iptlo + ld1 {v16.2d}, [x9], #16 // vmovdqu (%r9), %xmm5 # round0 key + and v1.16b, v7.16b, v17.16b // vpand %xmm9, %xmm0, %xmm1 + ushr v0.16b, v7.16b, #4 // vpsrlb $4, %xmm0, %xmm0 + tbl v1.16b, {v20.16b}, v1.16b // vpshufb %xmm1, %xmm2, %xmm1 + // vmovdqa .Lk_ipt+16(%rip), %xmm3 # ipthi + tbl v2.16b, {v21.16b}, v0.16b // vpshufb %xmm0, %xmm3, %xmm2 + eor v0.16b, v1.16b, v16.16b // vpxor %xmm5, %xmm1, %xmm0 + eor v0.16b, v0.16b, v2.16b // vpxor %xmm2, %xmm0, %xmm0 + b Lenc_entry + +.align 4 +Lenc_loop: + // middle of middle round + add x10, x11, #0x40 + tbl v4.16b, {v25.16b}, v2.16b // vpshufb %xmm2, %xmm13, %xmm4 # 4 = sb1u + ld1 {v1.2d}, [x11], #16 // vmovdqa -0x40(%r11,%r10), %xmm1 # Lk_mc_forward[] + tbl v0.16b, {v24.16b}, v3.16b // vpshufb %xmm3, %xmm12, %xmm0 # 0 = sb1t + eor v4.16b, v4.16b, v16.16b // vpxor %xmm5, %xmm4, %xmm4 # 4 = sb1u + k + tbl v5.16b, {v27.16b}, v2.16b // vpshufb %xmm2, %xmm15, %xmm5 # 4 = sb2u + eor v0.16b, v0.16b, v4.16b // vpxor %xmm4, %xmm0, %xmm0 # 0 = A + tbl v2.16b, {v26.16b}, v3.16b // vpshufb %xmm3, %xmm14, %xmm2 # 2 = sb2t + ld1 {v4.2d}, [x10] // vmovdqa (%r11,%r10), %xmm4 # Lk_mc_backward[] + tbl v3.16b, {v0.16b}, v1.16b // vpshufb %xmm1, %xmm0, %xmm3 # 0 = B + eor v2.16b, v2.16b, v5.16b // vpxor %xmm5, %xmm2, %xmm2 # 2 = 2A + tbl v0.16b, {v0.16b}, v4.16b // vpshufb %xmm4, %xmm0, %xmm0 # 3 = D + eor v3.16b, v3.16b, v2.16b // vpxor %xmm2, %xmm3, %xmm3 # 0 = 2A+B + tbl v4.16b, {v3.16b}, v1.16b // vpshufb %xmm1, %xmm3, %xmm4 # 0 = 2B+C + eor v0.16b, v0.16b, v3.16b // vpxor %xmm3, %xmm0, %xmm0 # 3 = 2A+B+D + and x11, x11, #~(1<<6) // and $0x30, %r11 # ... mod 4 + eor v0.16b, v0.16b, v4.16b // vpxor %xmm4, %xmm0, %xmm0 # 0 = 2A+3B+C+D + sub w8, w8, #1 // nr-- + +Lenc_entry: + // top of round + and v1.16b, v0.16b, v17.16b // vpand %xmm0, %xmm9, %xmm1 # 0 = k + ushr v0.16b, v0.16b, #4 // vpsrlb $4, %xmm0, %xmm0 # 1 = i + tbl v5.16b, {v19.16b}, v1.16b // vpshufb %xmm1, %xmm11, %xmm5 # 2 = a/k + eor v1.16b, v1.16b, v0.16b // vpxor %xmm0, %xmm1, %xmm1 # 0 = j + tbl v3.16b, {v18.16b}, v0.16b // vpshufb %xmm0, %xmm10, %xmm3 # 3 = 1/i + tbl v4.16b, {v18.16b}, v1.16b // vpshufb %xmm1, %xmm10, %xmm4 # 4 = 1/j + eor v3.16b, v3.16b, v5.16b // vpxor %xmm5, %xmm3, %xmm3 # 3 = iak = 1/i + a/k + eor v4.16b, v4.16b, v5.16b // vpxor %xmm5, %xmm4, %xmm4 # 4 = jak = 1/j + a/k + tbl v2.16b, {v18.16b}, v3.16b // vpshufb %xmm3, %xmm10, %xmm2 # 2 = 1/iak + tbl v3.16b, {v18.16b}, v4.16b // vpshufb %xmm4, %xmm10, %xmm3 # 3 = 1/jak + eor v2.16b, v2.16b, v1.16b // vpxor %xmm1, %xmm2, %xmm2 # 2 = io + eor v3.16b, v3.16b, v0.16b // vpxor %xmm0, %xmm3, %xmm3 # 3 = jo + ld1 {v16.2d}, [x9],#16 // vmovdqu (%r9), %xmm5 + cbnz w8, Lenc_loop + + // middle of last round + add x10, x11, #0x80 + // vmovdqa -0x60(%r10), %xmm4 # 3 : sbou .Lk_sbo + // vmovdqa -0x50(%r10), %xmm0 # 0 : sbot .Lk_sbo+16 + tbl v4.16b, {v22.16b}, v2.16b // vpshufb %xmm2, %xmm4, %xmm4 # 4 = sbou + ld1 {v1.2d}, [x10] // vmovdqa 0x40(%r11,%r10), %xmm1 # Lk_sr[] + tbl v0.16b, {v23.16b}, v3.16b // vpshufb %xmm3, %xmm0, %xmm0 # 0 = sb1t + eor v4.16b, v4.16b, v16.16b // vpxor %xmm5, %xmm4, %xmm4 # 4 = sb1u + k + eor v0.16b, v0.16b, v4.16b // vpxor %xmm4, %xmm0, %xmm0 # 0 = A + tbl v0.16b, {v0.16b}, v1.16b // vpshufb %xmm1, %xmm0, %xmm0 + ret + + +.def _vpaes_encrypt_2x + .type 32 +.endef +.align 4 +_vpaes_encrypt_2x: + mov x9, x2 + ldr w8, [x2,#240] // pull rounds + adrp x11, Lk_mc_forward+16 + add x11, x11, :lo12:Lk_mc_forward+16 + // vmovdqa .Lk_ipt(%rip), %xmm2 # iptlo + ld1 {v16.2d}, [x9], #16 // vmovdqu (%r9), %xmm5 # round0 key + and v1.16b, v14.16b, v17.16b // vpand %xmm9, %xmm0, %xmm1 + ushr v0.16b, v14.16b, #4 // vpsrlb $4, %xmm0, %xmm0 + and v9.16b, v15.16b, v17.16b + ushr v8.16b, v15.16b, #4 + tbl v1.16b, {v20.16b}, v1.16b // vpshufb %xmm1, %xmm2, %xmm1 + tbl v9.16b, {v20.16b}, v9.16b + // vmovdqa .Lk_ipt+16(%rip), %xmm3 # ipthi + tbl v2.16b, {v21.16b}, v0.16b // vpshufb %xmm0, %xmm3, %xmm2 + tbl v10.16b, {v21.16b}, v8.16b + eor v0.16b, v1.16b, v16.16b // vpxor %xmm5, %xmm1, %xmm0 + eor v8.16b, v9.16b, v16.16b + eor v0.16b, v0.16b, v2.16b // vpxor %xmm2, %xmm0, %xmm0 + eor v8.16b, v8.16b, v10.16b + b Lenc_2x_entry + +.align 4 +Lenc_2x_loop: + // middle of middle round + add x10, x11, #0x40 + tbl v4.16b, {v25.16b}, v2.16b // vpshufb %xmm2, %xmm13, %xmm4 # 4 = sb1u + tbl v12.16b, {v25.16b}, v10.16b + ld1 {v1.2d}, [x11], #16 // vmovdqa -0x40(%r11,%r10), %xmm1 # Lk_mc_forward[] + tbl v0.16b, {v24.16b}, v3.16b // vpshufb %xmm3, %xmm12, %xmm0 # 0 = sb1t + tbl v8.16b, {v24.16b}, v11.16b + eor v4.16b, v4.16b, v16.16b // vpxor %xmm5, %xmm4, %xmm4 # 4 = sb1u + k + eor v12.16b, v12.16b, v16.16b + tbl v5.16b, {v27.16b}, v2.16b // vpshufb %xmm2, %xmm15, %xmm5 # 4 = sb2u + tbl v13.16b, {v27.16b}, v10.16b + eor v0.16b, v0.16b, v4.16b // vpxor %xmm4, %xmm0, %xmm0 # 0 = A + eor v8.16b, v8.16b, v12.16b + tbl v2.16b, {v26.16b}, v3.16b // vpshufb %xmm3, %xmm14, %xmm2 # 2 = sb2t + tbl v10.16b, {v26.16b}, v11.16b + ld1 {v4.2d}, [x10] // vmovdqa (%r11,%r10), %xmm4 # Lk_mc_backward[] + tbl v3.16b, {v0.16b}, v1.16b // vpshufb %xmm1, %xmm0, %xmm3 # 0 = B + tbl v11.16b, {v8.16b}, v1.16b + eor v2.16b, v2.16b, v5.16b // vpxor %xmm5, %xmm2, %xmm2 # 2 = 2A + eor v10.16b, v10.16b, v13.16b + tbl v0.16b, {v0.16b}, v4.16b // vpshufb %xmm4, %xmm0, %xmm0 # 3 = D + tbl v8.16b, {v8.16b}, v4.16b + eor v3.16b, v3.16b, v2.16b // vpxor %xmm2, %xmm3, %xmm3 # 0 = 2A+B + eor v11.16b, v11.16b, v10.16b + tbl v4.16b, {v3.16b}, v1.16b // vpshufb %xmm1, %xmm3, %xmm4 # 0 = 2B+C + tbl v12.16b, {v11.16b},v1.16b + eor v0.16b, v0.16b, v3.16b // vpxor %xmm3, %xmm0, %xmm0 # 3 = 2A+B+D + eor v8.16b, v8.16b, v11.16b + and x11, x11, #~(1<<6) // and $0x30, %r11 # ... mod 4 + eor v0.16b, v0.16b, v4.16b // vpxor %xmm4, %xmm0, %xmm0 # 0 = 2A+3B+C+D + eor v8.16b, v8.16b, v12.16b + sub w8, w8, #1 // nr-- + +Lenc_2x_entry: + // top of round + and v1.16b, v0.16b, v17.16b // vpand %xmm0, %xmm9, %xmm1 # 0 = k + ushr v0.16b, v0.16b, #4 // vpsrlb $4, %xmm0, %xmm0 # 1 = i + and v9.16b, v8.16b, v17.16b + ushr v8.16b, v8.16b, #4 + tbl v5.16b, {v19.16b},v1.16b // vpshufb %xmm1, %xmm11, %xmm5 # 2 = a/k + tbl v13.16b, {v19.16b},v9.16b + eor v1.16b, v1.16b, v0.16b // vpxor %xmm0, %xmm1, %xmm1 # 0 = j + eor v9.16b, v9.16b, v8.16b + tbl v3.16b, {v18.16b},v0.16b // vpshufb %xmm0, %xmm10, %xmm3 # 3 = 1/i + tbl v11.16b, {v18.16b},v8.16b + tbl v4.16b, {v18.16b},v1.16b // vpshufb %xmm1, %xmm10, %xmm4 # 4 = 1/j + tbl v12.16b, {v18.16b},v9.16b + eor v3.16b, v3.16b, v5.16b // vpxor %xmm5, %xmm3, %xmm3 # 3 = iak = 1/i + a/k + eor v11.16b, v11.16b, v13.16b + eor v4.16b, v4.16b, v5.16b // vpxor %xmm5, %xmm4, %xmm4 # 4 = jak = 1/j + a/k + eor v12.16b, v12.16b, v13.16b + tbl v2.16b, {v18.16b},v3.16b // vpshufb %xmm3, %xmm10, %xmm2 # 2 = 1/iak + tbl v10.16b, {v18.16b},v11.16b + tbl v3.16b, {v18.16b},v4.16b // vpshufb %xmm4, %xmm10, %xmm3 # 3 = 1/jak + tbl v11.16b, {v18.16b},v12.16b + eor v2.16b, v2.16b, v1.16b // vpxor %xmm1, %xmm2, %xmm2 # 2 = io + eor v10.16b, v10.16b, v9.16b + eor v3.16b, v3.16b, v0.16b // vpxor %xmm0, %xmm3, %xmm3 # 3 = jo + eor v11.16b, v11.16b, v8.16b + ld1 {v16.2d}, [x9],#16 // vmovdqu (%r9), %xmm5 + cbnz w8, Lenc_2x_loop + + // middle of last round + add x10, x11, #0x80 + // vmovdqa -0x60(%r10), %xmm4 # 3 : sbou .Lk_sbo + // vmovdqa -0x50(%r10), %xmm0 # 0 : sbot .Lk_sbo+16 + tbl v4.16b, {v22.16b}, v2.16b // vpshufb %xmm2, %xmm4, %xmm4 # 4 = sbou + tbl v12.16b, {v22.16b}, v10.16b + ld1 {v1.2d}, [x10] // vmovdqa 0x40(%r11,%r10), %xmm1 # Lk_sr[] + tbl v0.16b, {v23.16b}, v3.16b // vpshufb %xmm3, %xmm0, %xmm0 # 0 = sb1t + tbl v8.16b, {v23.16b}, v11.16b + eor v4.16b, v4.16b, v16.16b // vpxor %xmm5, %xmm4, %xmm4 # 4 = sb1u + k + eor v12.16b, v12.16b, v16.16b + eor v0.16b, v0.16b, v4.16b // vpxor %xmm4, %xmm0, %xmm0 # 0 = A + eor v8.16b, v8.16b, v12.16b + tbl v0.16b, {v0.16b},v1.16b // vpshufb %xmm1, %xmm0, %xmm0 + tbl v1.16b, {v8.16b},v1.16b + ret + +######################################################## +## ## +## AES key schedule ## +## ## +######################################################## +.def _vpaes_key_preheat + .type 32 +.endef +.align 4 +_vpaes_key_preheat: + adrp x10, Lk_inv + add x10, x10, :lo12:Lk_inv + movi v16.16b, #0x5b // Lk_s63 + adrp x11, Lk_sb1 + add x11, x11, :lo12:Lk_sb1 + movi v17.16b, #0x0f // Lk_s0F + ld1 {v18.2d,v19.2d,v20.2d,v21.2d}, [x10] // Lk_inv, Lk_ipt + adrp x10, Lk_dksd + add x10, x10, :lo12:Lk_dksd + ld1 {v22.2d,v23.2d}, [x11] // Lk_sb1 + adrp x11, Lk_mc_forward + add x11, x11, :lo12:Lk_mc_forward + ld1 {v24.2d,v25.2d,v26.2d,v27.2d}, [x10],#64 // Lk_dksd, Lk_dksb + ld1 {v28.2d,v29.2d,v30.2d,v31.2d}, [x10],#64 // Lk_dkse, Lk_dks9 + ld1 {v8.2d}, [x10] // Lk_rcon + ld1 {v9.2d}, [x11] // Lk_mc_forward[0] + ret + + +.def _vpaes_schedule_core + .type 32 +.endef +.align 4 +_vpaes_schedule_core: + AARCH64_SIGN_LINK_REGISTER + stp x29, x30, [sp,#-16]! + add x29,sp,#0 + + bl _vpaes_key_preheat // load the tables + + ld1 {v0.16b}, [x0],#16 // vmovdqu (%rdi), %xmm0 # load key (unaligned) + + // input transform + mov v3.16b, v0.16b // vmovdqa %xmm0, %xmm3 + bl _vpaes_schedule_transform + mov v7.16b, v0.16b // vmovdqa %xmm0, %xmm7 + + adrp x10, Lk_sr // lea Lk_sr(%rip),%r10 + add x10, x10, :lo12:Lk_sr + + add x8, x8, x10 + + // encrypting, output zeroth round key after transform + st1 {v0.2d}, [x2] // vmovdqu %xmm0, (%rdx) + + cmp w1, #192 // cmp $192, %esi + b.hi Lschedule_256 + b.eq Lschedule_192 + // 128: fall though + +## +## .schedule_128 +## +## 128-bit specific part of key schedule. +## +## This schedule is really simple, because all its parts +## are accomplished by the subroutines. +## +Lschedule_128: + mov x0, #10 // mov $10, %esi + +Loop_schedule_128: + sub x0, x0, #1 // dec %esi + bl _vpaes_schedule_round + cbz x0, Lschedule_mangle_last + bl _vpaes_schedule_mangle // write output + b Loop_schedule_128 + +## +## .aes_schedule_192 +## +## 192-bit specific part of key schedule. +## +## The main body of this schedule is the same as the 128-bit +## schedule, but with more smearing. The long, high side is +## stored in %xmm7 as before, and the short, low side is in +## the high bits of %xmm6. +## +## This schedule is somewhat nastier, however, because each +## round produces 192 bits of key material, or 1.5 round keys. +## Therefore, on each cycle we do 2 rounds and produce 3 round +## keys. +## +.align 4 +Lschedule_192: + sub x0, x0, #8 + ld1 {v0.16b}, [x0] // vmovdqu 8(%rdi),%xmm0 # load key part 2 (very unaligned) + bl _vpaes_schedule_transform // input transform + mov v6.16b, v0.16b // vmovdqa %xmm0, %xmm6 # save short part + eor v4.16b, v4.16b, v4.16b // vpxor %xmm4, %xmm4, %xmm4 # clear 4 + ins v6.d[0], v4.d[0] // vmovhlps %xmm4, %xmm6, %xmm6 # clobber low side with zeros + mov x0, #4 // mov $4, %esi + +Loop_schedule_192: + sub x0, x0, #1 // dec %esi + bl _vpaes_schedule_round + ext v0.16b, v6.16b, v0.16b, #8 // vpalignr $8,%xmm6,%xmm0,%xmm0 + bl _vpaes_schedule_mangle // save key n + bl _vpaes_schedule_192_smear + bl _vpaes_schedule_mangle // save key n+1 + bl _vpaes_schedule_round + cbz x0, Lschedule_mangle_last + bl _vpaes_schedule_mangle // save key n+2 + bl _vpaes_schedule_192_smear + b Loop_schedule_192 + +## +## .aes_schedule_256 +## +## 256-bit specific part of key schedule. +## +## The structure here is very similar to the 128-bit +## schedule, but with an additional "low side" in +## %xmm6. The low side's rounds are the same as the +## high side's, except no rcon and no rotation. +## +.align 4 +Lschedule_256: + ld1 {v0.16b}, [x0] // vmovdqu 16(%rdi),%xmm0 # load key part 2 (unaligned) + bl _vpaes_schedule_transform // input transform + mov x0, #7 // mov $7, %esi + +Loop_schedule_256: + sub x0, x0, #1 // dec %esi + bl _vpaes_schedule_mangle // output low result + mov v6.16b, v0.16b // vmovdqa %xmm0, %xmm6 # save cur_lo in xmm6 + + // high round + bl _vpaes_schedule_round + cbz x0, Lschedule_mangle_last + bl _vpaes_schedule_mangle + + // low round. swap xmm7 and xmm6 + dup v0.4s, v0.s[3] // vpshufd $0xFF, %xmm0, %xmm0 + movi v4.16b, #0 + mov v5.16b, v7.16b // vmovdqa %xmm7, %xmm5 + mov v7.16b, v6.16b // vmovdqa %xmm6, %xmm7 + bl _vpaes_schedule_low_round + mov v7.16b, v5.16b // vmovdqa %xmm5, %xmm7 + + b Loop_schedule_256 + +## +## .aes_schedule_mangle_last +## +## Mangler for last round of key schedule +## Mangles %xmm0 +## when encrypting, outputs out(%xmm0) ^ 63 +## when decrypting, outputs unskew(%xmm0) +## +## Always called right before return... jumps to cleanup and exits +## +.align 4 +Lschedule_mangle_last: + // schedule last round key from xmm0 + adrp x11, Lk_deskew // lea Lk_deskew(%rip),%r11 # prepare to deskew + add x11, x11, :lo12:Lk_deskew + + cbnz w3, Lschedule_mangle_last_dec + + // encrypting + ld1 {v1.2d}, [x8] // vmovdqa (%r8,%r10),%xmm1 + adrp x11, Lk_opt // lea Lk_opt(%rip), %r11 # prepare to output transform + add x11, x11, :lo12:Lk_opt + add x2, x2, #32 // add $32, %rdx + tbl v0.16b, {v0.16b}, v1.16b // vpshufb %xmm1, %xmm0, %xmm0 # output permute + +Lschedule_mangle_last_dec: + ld1 {v20.2d,v21.2d}, [x11] // reload constants + sub x2, x2, #16 // add $-16, %rdx + eor v0.16b, v0.16b, v16.16b // vpxor Lk_s63(%rip), %xmm0, %xmm0 + bl _vpaes_schedule_transform // output transform + st1 {v0.2d}, [x2] // vmovdqu %xmm0, (%rdx) # save last key + + // cleanup + eor v0.16b, v0.16b, v0.16b // vpxor %xmm0, %xmm0, %xmm0 + eor v1.16b, v1.16b, v1.16b // vpxor %xmm1, %xmm1, %xmm1 + eor v2.16b, v2.16b, v2.16b // vpxor %xmm2, %xmm2, %xmm2 + eor v3.16b, v3.16b, v3.16b // vpxor %xmm3, %xmm3, %xmm3 + eor v4.16b, v4.16b, v4.16b // vpxor %xmm4, %xmm4, %xmm4 + eor v5.16b, v5.16b, v5.16b // vpxor %xmm5, %xmm5, %xmm5 + eor v6.16b, v6.16b, v6.16b // vpxor %xmm6, %xmm6, %xmm6 + eor v7.16b, v7.16b, v7.16b // vpxor %xmm7, %xmm7, %xmm7 + ldp x29, x30, [sp],#16 + AARCH64_VALIDATE_LINK_REGISTER + ret + + +## +## .aes_schedule_192_smear +## +## Smear the short, low side in the 192-bit key schedule. +## +## Inputs: +## %xmm7: high side, b a x y +## %xmm6: low side, d c 0 0 +## %xmm13: 0 +## +## Outputs: +## %xmm6: b+c+d b+c 0 0 +## %xmm0: b+c+d b+c b a +## +.def _vpaes_schedule_192_smear + .type 32 +.endef +.align 4 +_vpaes_schedule_192_smear: + movi v1.16b, #0 + dup v0.4s, v7.s[3] + ins v1.s[3], v6.s[2] // vpshufd $0x80, %xmm6, %xmm1 # d c 0 0 -> c 0 0 0 + ins v0.s[0], v7.s[2] // vpshufd $0xFE, %xmm7, %xmm0 # b a _ _ -> b b b a + eor v6.16b, v6.16b, v1.16b // vpxor %xmm1, %xmm6, %xmm6 # -> c+d c 0 0 + eor v1.16b, v1.16b, v1.16b // vpxor %xmm1, %xmm1, %xmm1 + eor v6.16b, v6.16b, v0.16b // vpxor %xmm0, %xmm6, %xmm6 # -> b+c+d b+c b a + mov v0.16b, v6.16b // vmovdqa %xmm6, %xmm0 + ins v6.d[0], v1.d[0] // vmovhlps %xmm1, %xmm6, %xmm6 # clobber low side with zeros + ret + + +## +## .aes_schedule_round +## +## Runs one main round of the key schedule on %xmm0, %xmm7 +## +## Specifically, runs subbytes on the high dword of %xmm0 +## then rotates it by one byte and xors into the low dword of +## %xmm7. +## +## Adds rcon from low byte of %xmm8, then rotates %xmm8 for +## next rcon. +## +## Smears the dwords of %xmm7 by xoring the low into the +## second low, result into third, result into highest. +## +## Returns results in %xmm7 = %xmm0. +## Clobbers %xmm1-%xmm4, %r11. +## +.def _vpaes_schedule_round + .type 32 +.endef +.align 4 +_vpaes_schedule_round: + // extract rcon from xmm8 + movi v4.16b, #0 // vpxor %xmm4, %xmm4, %xmm4 + ext v1.16b, v8.16b, v4.16b, #15 // vpalignr $15, %xmm8, %xmm4, %xmm1 + ext v8.16b, v8.16b, v8.16b, #15 // vpalignr $15, %xmm8, %xmm8, %xmm8 + eor v7.16b, v7.16b, v1.16b // vpxor %xmm1, %xmm7, %xmm7 + + // rotate + dup v0.4s, v0.s[3] // vpshufd $0xFF, %xmm0, %xmm0 + ext v0.16b, v0.16b, v0.16b, #1 // vpalignr $1, %xmm0, %xmm0, %xmm0 + + // fall through... + + // low round: same as high round, but no rotation and no rcon. +_vpaes_schedule_low_round: + // smear xmm7 + ext v1.16b, v4.16b, v7.16b, #12 // vpslldq $4, %xmm7, %xmm1 + eor v7.16b, v7.16b, v1.16b // vpxor %xmm1, %xmm7, %xmm7 + ext v4.16b, v4.16b, v7.16b, #8 // vpslldq $8, %xmm7, %xmm4 + + // subbytes + and v1.16b, v0.16b, v17.16b // vpand %xmm9, %xmm0, %xmm1 # 0 = k + ushr v0.16b, v0.16b, #4 // vpsrlb $4, %xmm0, %xmm0 # 1 = i + eor v7.16b, v7.16b, v4.16b // vpxor %xmm4, %xmm7, %xmm7 + tbl v2.16b, {v19.16b}, v1.16b // vpshufb %xmm1, %xmm11, %xmm2 # 2 = a/k + eor v1.16b, v1.16b, v0.16b // vpxor %xmm0, %xmm1, %xmm1 # 0 = j + tbl v3.16b, {v18.16b}, v0.16b // vpshufb %xmm0, %xmm10, %xmm3 # 3 = 1/i + eor v3.16b, v3.16b, v2.16b // vpxor %xmm2, %xmm3, %xmm3 # 3 = iak = 1/i + a/k + tbl v4.16b, {v18.16b}, v1.16b // vpshufb %xmm1, %xmm10, %xmm4 # 4 = 1/j + eor v7.16b, v7.16b, v16.16b // vpxor Lk_s63(%rip), %xmm7, %xmm7 + tbl v3.16b, {v18.16b}, v3.16b // vpshufb %xmm3, %xmm10, %xmm3 # 2 = 1/iak + eor v4.16b, v4.16b, v2.16b // vpxor %xmm2, %xmm4, %xmm4 # 4 = jak = 1/j + a/k + tbl v2.16b, {v18.16b}, v4.16b // vpshufb %xmm4, %xmm10, %xmm2 # 3 = 1/jak + eor v3.16b, v3.16b, v1.16b // vpxor %xmm1, %xmm3, %xmm3 # 2 = io + eor v2.16b, v2.16b, v0.16b // vpxor %xmm0, %xmm2, %xmm2 # 3 = jo + tbl v4.16b, {v23.16b}, v3.16b // vpshufb %xmm3, %xmm13, %xmm4 # 4 = sbou + tbl v1.16b, {v22.16b}, v2.16b // vpshufb %xmm2, %xmm12, %xmm1 # 0 = sb1t + eor v1.16b, v1.16b, v4.16b // vpxor %xmm4, %xmm1, %xmm1 # 0 = sbox output + + // add in smeared stuff + eor v0.16b, v1.16b, v7.16b // vpxor %xmm7, %xmm1, %xmm0 + eor v7.16b, v1.16b, v7.16b // vmovdqa %xmm0, %xmm7 + ret + + +## +## .aes_schedule_transform +## +## Linear-transform %xmm0 according to tables at (%r11) +## +## Requires that %xmm9 = 0x0F0F... as in preheat +## Output in %xmm0 +## Clobbers %xmm1, %xmm2 +## +.def _vpaes_schedule_transform + .type 32 +.endef +.align 4 +_vpaes_schedule_transform: + and v1.16b, v0.16b, v17.16b // vpand %xmm9, %xmm0, %xmm1 + ushr v0.16b, v0.16b, #4 // vpsrlb $4, %xmm0, %xmm0 + // vmovdqa (%r11), %xmm2 # lo + tbl v2.16b, {v20.16b}, v1.16b // vpshufb %xmm1, %xmm2, %xmm2 + // vmovdqa 16(%r11), %xmm1 # hi + tbl v0.16b, {v21.16b}, v0.16b // vpshufb %xmm0, %xmm1, %xmm0 + eor v0.16b, v0.16b, v2.16b // vpxor %xmm2, %xmm0, %xmm0 + ret + + +## +## .aes_schedule_mangle +## +## Mangle xmm0 from (basis-transformed) standard version +## to our version. +## +## On encrypt, +## xor with 0x63 +## multiply by circulant 0,1,1,1 +## apply shiftrows transform +## +## On decrypt, +## xor with 0x63 +## multiply by "inverse mixcolumns" circulant E,B,D,9 +## deskew +## apply shiftrows transform +## +## +## Writes out to (%rdx), and increments or decrements it +## Keeps track of round number mod 4 in %r8 +## Preserves xmm0 +## Clobbers xmm1-xmm5 +## +.def _vpaes_schedule_mangle + .type 32 +.endef +.align 4 +_vpaes_schedule_mangle: + mov v4.16b, v0.16b // vmovdqa %xmm0, %xmm4 # save xmm0 for later + // vmovdqa .Lk_mc_forward(%rip),%xmm5 + + // encrypting + eor v4.16b, v0.16b, v16.16b // vpxor Lk_s63(%rip), %xmm0, %xmm4 + add x2, x2, #16 // add $16, %rdx + tbl v4.16b, {v4.16b}, v9.16b // vpshufb %xmm5, %xmm4, %xmm4 + tbl v1.16b, {v4.16b}, v9.16b // vpshufb %xmm5, %xmm4, %xmm1 + tbl v3.16b, {v1.16b}, v9.16b // vpshufb %xmm5, %xmm1, %xmm3 + eor v4.16b, v4.16b, v1.16b // vpxor %xmm1, %xmm4, %xmm4 + ld1 {v1.2d}, [x8] // vmovdqa (%r8,%r10), %xmm1 + eor v3.16b, v3.16b, v4.16b // vpxor %xmm4, %xmm3, %xmm3 + +Lschedule_mangle_both: + tbl v3.16b, {v3.16b}, v1.16b // vpshufb %xmm1, %xmm3, %xmm3 + add x8, x8, #48 // add $-16, %r8 + and x8, x8, #~(1<<6) // and $0x30, %r8 + st1 {v3.2d}, [x2] // vmovdqu %xmm3, (%rdx) + ret + + +.globl vpaes_set_encrypt_key + +.def vpaes_set_encrypt_key + .type 32 +.endef +.align 4 +vpaes_set_encrypt_key: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-16]! + add x29,sp,#0 + stp d8,d9,[sp,#-16]! // ABI spec says so + + lsr w9, w1, #5 // shr $5,%eax + add w9, w9, #5 // $5,%eax + str w9, [x2,#240] // mov %eax,240(%rdx) # AES_KEY->rounds = nbits/32+5; + + mov w3, #0 // mov $0,%ecx + mov x8, #0x30 // mov $0x30,%r8d + bl _vpaes_schedule_core + eor x0, x0, x0 + + ldp d8,d9,[sp],#16 + ldp x29,x30,[sp],#16 + AARCH64_VALIDATE_LINK_REGISTER + ret + +.globl vpaes_ctr32_encrypt_blocks + +.def vpaes_ctr32_encrypt_blocks + .type 32 +.endef +.align 4 +vpaes_ctr32_encrypt_blocks: + AARCH64_SIGN_LINK_REGISTER + stp x29,x30,[sp,#-16]! + add x29,sp,#0 + stp d8,d9,[sp,#-16]! // ABI spec says so + stp d10,d11,[sp,#-16]! + stp d12,d13,[sp,#-16]! + stp d14,d15,[sp,#-16]! + + cbz x2, Lctr32_done + + // Note, unlike the other functions, x2 here is measured in blocks, + // not bytes. + mov x17, x2 + mov x2, x3 + + // Load the IV and counter portion. + ldr w6, [x4, #12] + ld1 {v7.16b}, [x4] + + bl _vpaes_encrypt_preheat + tst x17, #1 + rev w6, w6 // The counter is big-endian. + b.eq Lctr32_prep_loop + + // Handle one block so the remaining block count is even for + // _vpaes_encrypt_2x. + ld1 {v6.16b}, [x0], #16 // Load input ahead of time + bl _vpaes_encrypt_core + eor v0.16b, v0.16b, v6.16b // XOR input and result + st1 {v0.16b}, [x1], #16 + subs x17, x17, #1 + // Update the counter. + add w6, w6, #1 + rev w7, w6 + mov v7.s[3], w7 + b.ls Lctr32_done + +Lctr32_prep_loop: + // _vpaes_encrypt_core takes its input from v7, while _vpaes_encrypt_2x + // uses v14 and v15. + mov v15.16b, v7.16b + mov v14.16b, v7.16b + add w6, w6, #1 + rev w7, w6 + mov v15.s[3], w7 + +Lctr32_loop: + ld1 {v6.16b,v7.16b}, [x0], #32 // Load input ahead of time + bl _vpaes_encrypt_2x + eor v0.16b, v0.16b, v6.16b // XOR input and result + eor v1.16b, v1.16b, v7.16b // XOR input and result (#2) + st1 {v0.16b,v1.16b}, [x1], #32 + subs x17, x17, #2 + // Update the counter. + add w7, w6, #1 + add w6, w6, #2 + rev w7, w7 + mov v14.s[3], w7 + rev w7, w6 + mov v15.s[3], w7 + b.hi Lctr32_loop + +Lctr32_done: + ldp d14,d15,[sp],#16 + ldp d12,d13,[sp],#16 + ldp d10,d11,[sp],#16 + ldp d8,d9,[sp],#16 + ldp x29,x30,[sp],#16 + AARCH64_VALIDATE_LINK_REGISTER + ret + +#endif // !OPENSSL_NO_ASM && defined(OPENSSL_AARCH64) && defined(_WIN32) diff --git a/http/vendor/ring/pregenerated/vpaes-x86-elf.S b/http/vendor/ring/pregenerated/vpaes-x86-elf.S new file mode 100644 index 0000000..e4077ae --- /dev/null +++ b/http/vendor/ring/pregenerated/vpaes-x86-elf.S @@ -0,0 +1,422 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) +.text +#ifdef BORINGSSL_DISPATCH_TEST +#endif +.align 64 +.L_vpaes_consts: +.long 218628480,235210255,168496130,67568393 +.long 252381056,17041926,33884169,51187212 +.long 252645135,252645135,252645135,252645135 +.long 1512730624,3266504856,1377990664,3401244816 +.long 830229760,1275146365,2969422977,3447763452 +.long 3411033600,2979783055,338359620,2782886510 +.long 4209124096,907596821,221174255,1006095553 +.long 191964160,3799684038,3164090317,1589111125 +.long 182528256,1777043520,2877432650,3265356744 +.long 1874708224,3503451415,3305285752,363511674 +.long 1606117888,3487855781,1093350906,2384367825 +.long 197121,67569157,134941193,202313229 +.long 67569157,134941193,202313229,197121 +.long 134941193,202313229,197121,67569157 +.long 202313229,197121,67569157,134941193 +.long 33619971,100992007,168364043,235736079 +.long 235736079,33619971,100992007,168364043 +.long 168364043,235736079,33619971,100992007 +.long 100992007,168364043,235736079,33619971 +.long 50462976,117835012,185207048,252579084 +.long 252314880,51251460,117574920,184942860 +.long 184682752,252054788,50987272,118359308 +.long 118099200,185467140,251790600,50727180 +.long 2946363062,528716217,1300004225,1881839624 +.long 1532713819,1532713819,1532713819,1532713819 +.long 3602276352,4288629033,3737020424,4153884961 +.long 1354558464,32357713,2958822624,3775749553 +.long 1201988352,132424512,1572796698,503232858 +.long 2213177600,1597421020,4103937655,675398315 +.byte 86,101,99,116,111,114,32,80,101,114,109,117,116,97,116,105 +.byte 111,110,32,65,69,83,32,102,111,114,32,120,56,54,47,83 +.byte 83,83,69,51,44,32,77,105,107,101,32,72,97,109,98,117 +.byte 114,103,32,40,83,116,97,110,102,111,114,100,32,85,110,105 +.byte 118,101,114,115,105,116,121,41,0 +.align 64 +.hidden _vpaes_preheat +.type _vpaes_preheat,@function +.align 16 +_vpaes_preheat: + addl (%esp),%ebp + movdqa -48(%ebp),%xmm7 + movdqa -16(%ebp),%xmm6 + ret +.size _vpaes_preheat,.-_vpaes_preheat +.hidden _vpaes_encrypt_core +.type _vpaes_encrypt_core,@function +.align 16 +_vpaes_encrypt_core: + movl $16,%ecx + movl 240(%edx),%eax + movdqa %xmm6,%xmm1 + movdqa (%ebp),%xmm2 + pandn %xmm0,%xmm1 + pand %xmm6,%xmm0 + movdqu (%edx),%xmm5 +.byte 102,15,56,0,208 + movdqa 16(%ebp),%xmm0 + pxor %xmm5,%xmm2 + psrld $4,%xmm1 + addl $16,%edx +.byte 102,15,56,0,193 + leal 192(%ebp),%ebx + pxor %xmm2,%xmm0 + jmp .L000enc_entry +.align 16 +.L001enc_loop: + movdqa 32(%ebp),%xmm4 + movdqa 48(%ebp),%xmm0 +.byte 102,15,56,0,226 +.byte 102,15,56,0,195 + pxor %xmm5,%xmm4 + movdqa 64(%ebp),%xmm5 + pxor %xmm4,%xmm0 + movdqa -64(%ebx,%ecx,1),%xmm1 +.byte 102,15,56,0,234 + movdqa 80(%ebp),%xmm2 + movdqa (%ebx,%ecx,1),%xmm4 +.byte 102,15,56,0,211 + movdqa %xmm0,%xmm3 + pxor %xmm5,%xmm2 +.byte 102,15,56,0,193 + addl $16,%edx + pxor %xmm2,%xmm0 +.byte 102,15,56,0,220 + addl $16,%ecx + pxor %xmm0,%xmm3 +.byte 102,15,56,0,193 + andl $48,%ecx + subl $1,%eax + pxor %xmm3,%xmm0 +.L000enc_entry: + movdqa %xmm6,%xmm1 + movdqa -32(%ebp),%xmm5 + pandn %xmm0,%xmm1 + psrld $4,%xmm1 + pand %xmm6,%xmm0 +.byte 102,15,56,0,232 + movdqa %xmm7,%xmm3 + pxor %xmm1,%xmm0 +.byte 102,15,56,0,217 + movdqa %xmm7,%xmm4 + pxor %xmm5,%xmm3 +.byte 102,15,56,0,224 + movdqa %xmm7,%xmm2 + pxor %xmm5,%xmm4 +.byte 102,15,56,0,211 + movdqa %xmm7,%xmm3 + pxor %xmm0,%xmm2 +.byte 102,15,56,0,220 + movdqu (%edx),%xmm5 + pxor %xmm1,%xmm3 + jnz .L001enc_loop + movdqa 96(%ebp),%xmm4 + movdqa 112(%ebp),%xmm0 +.byte 102,15,56,0,226 + pxor %xmm5,%xmm4 +.byte 102,15,56,0,195 + movdqa 64(%ebx,%ecx,1),%xmm1 + pxor %xmm4,%xmm0 +.byte 102,15,56,0,193 + ret +.size _vpaes_encrypt_core,.-_vpaes_encrypt_core +.hidden _vpaes_schedule_core +.type _vpaes_schedule_core,@function +.align 16 +_vpaes_schedule_core: + addl (%esp),%ebp + movdqu (%esi),%xmm0 + movdqa 320(%ebp),%xmm2 + movdqa %xmm0,%xmm3 + leal (%ebp),%ebx + movdqa %xmm2,4(%esp) + call _vpaes_schedule_transform + movdqa %xmm0,%xmm7 + testl %edi,%edi + jnz .L002schedule_am_decrypting + movdqu %xmm0,(%edx) + jmp .L003schedule_go +.L002schedule_am_decrypting: + movdqa 256(%ebp,%ecx,1),%xmm1 +.byte 102,15,56,0,217 + movdqu %xmm3,(%edx) + xorl $48,%ecx +.L003schedule_go: + cmpl $192,%eax + ja .L004schedule_256 +.L005schedule_128: + movl $10,%eax +.L006loop_schedule_128: + call _vpaes_schedule_round + decl %eax + jz .L007schedule_mangle_last + call _vpaes_schedule_mangle + jmp .L006loop_schedule_128 +.align 16 +.L004schedule_256: + movdqu 16(%esi),%xmm0 + call _vpaes_schedule_transform + movl $7,%eax +.L008loop_schedule_256: + call _vpaes_schedule_mangle + movdqa %xmm0,%xmm6 + call _vpaes_schedule_round + decl %eax + jz .L007schedule_mangle_last + call _vpaes_schedule_mangle + pshufd $255,%xmm0,%xmm0 + movdqa %xmm7,20(%esp) + movdqa %xmm6,%xmm7 + call .L_vpaes_schedule_low_round + movdqa 20(%esp),%xmm7 + jmp .L008loop_schedule_256 +.align 16 +.L007schedule_mangle_last: + leal 384(%ebp),%ebx + testl %edi,%edi + jnz .L009schedule_mangle_last_dec + movdqa 256(%ebp,%ecx,1),%xmm1 +.byte 102,15,56,0,193 + leal 352(%ebp),%ebx + addl $32,%edx +.L009schedule_mangle_last_dec: + addl $-16,%edx + pxor 336(%ebp),%xmm0 + call _vpaes_schedule_transform + movdqu %xmm0,(%edx) + pxor %xmm0,%xmm0 + pxor %xmm1,%xmm1 + pxor %xmm2,%xmm2 + pxor %xmm3,%xmm3 + pxor %xmm4,%xmm4 + pxor %xmm5,%xmm5 + pxor %xmm6,%xmm6 + pxor %xmm7,%xmm7 + ret +.size _vpaes_schedule_core,.-_vpaes_schedule_core +.hidden _vpaes_schedule_round +.type _vpaes_schedule_round,@function +.align 16 +_vpaes_schedule_round: + movdqa 8(%esp),%xmm2 + pxor %xmm1,%xmm1 +.byte 102,15,58,15,202,15 +.byte 102,15,58,15,210,15 + pxor %xmm1,%xmm7 + pshufd $255,%xmm0,%xmm0 +.byte 102,15,58,15,192,1 + movdqa %xmm2,8(%esp) +.L_vpaes_schedule_low_round: + movdqa %xmm7,%xmm1 + pslldq $4,%xmm7 + pxor %xmm1,%xmm7 + movdqa %xmm7,%xmm1 + pslldq $8,%xmm7 + pxor %xmm1,%xmm7 + pxor 336(%ebp),%xmm7 + movdqa -16(%ebp),%xmm4 + movdqa -48(%ebp),%xmm5 + movdqa %xmm4,%xmm1 + pandn %xmm0,%xmm1 + psrld $4,%xmm1 + pand %xmm4,%xmm0 + movdqa -32(%ebp),%xmm2 +.byte 102,15,56,0,208 + pxor %xmm1,%xmm0 + movdqa %xmm5,%xmm3 +.byte 102,15,56,0,217 + pxor %xmm2,%xmm3 + movdqa %xmm5,%xmm4 +.byte 102,15,56,0,224 + pxor %xmm2,%xmm4 + movdqa %xmm5,%xmm2 +.byte 102,15,56,0,211 + pxor %xmm0,%xmm2 + movdqa %xmm5,%xmm3 +.byte 102,15,56,0,220 + pxor %xmm1,%xmm3 + movdqa 32(%ebp),%xmm4 +.byte 102,15,56,0,226 + movdqa 48(%ebp),%xmm0 +.byte 102,15,56,0,195 + pxor %xmm4,%xmm0 + pxor %xmm7,%xmm0 + movdqa %xmm0,%xmm7 + ret +.size _vpaes_schedule_round,.-_vpaes_schedule_round +.hidden _vpaes_schedule_transform +.type _vpaes_schedule_transform,@function +.align 16 +_vpaes_schedule_transform: + movdqa -16(%ebp),%xmm2 + movdqa %xmm2,%xmm1 + pandn %xmm0,%xmm1 + psrld $4,%xmm1 + pand %xmm2,%xmm0 + movdqa (%ebx),%xmm2 +.byte 102,15,56,0,208 + movdqa 16(%ebx),%xmm0 +.byte 102,15,56,0,193 + pxor %xmm2,%xmm0 + ret +.size _vpaes_schedule_transform,.-_vpaes_schedule_transform +.hidden _vpaes_schedule_mangle +.type _vpaes_schedule_mangle,@function +.align 16 +_vpaes_schedule_mangle: + movdqa %xmm0,%xmm4 + movdqa 128(%ebp),%xmm5 + testl %edi,%edi + jnz .L010schedule_mangle_dec + addl $16,%edx + pxor 336(%ebp),%xmm4 +.byte 102,15,56,0,229 + movdqa %xmm4,%xmm3 +.byte 102,15,56,0,229 + pxor %xmm4,%xmm3 +.byte 102,15,56,0,229 + pxor %xmm4,%xmm3 + jmp .L011schedule_mangle_both +.align 16 +.L010schedule_mangle_dec: + movdqa -16(%ebp),%xmm2 + leal (%ebp),%esi + movdqa %xmm2,%xmm1 + pandn %xmm4,%xmm1 + psrld $4,%xmm1 + pand %xmm2,%xmm4 + movdqa (%esi),%xmm2 +.byte 102,15,56,0,212 + movdqa 16(%esi),%xmm3 +.byte 102,15,56,0,217 + pxor %xmm2,%xmm3 +.byte 102,15,56,0,221 + movdqa 32(%esi),%xmm2 +.byte 102,15,56,0,212 + pxor %xmm3,%xmm2 + movdqa 48(%esi),%xmm3 +.byte 102,15,56,0,217 + pxor %xmm2,%xmm3 +.byte 102,15,56,0,221 + movdqa 64(%esi),%xmm2 +.byte 102,15,56,0,212 + pxor %xmm3,%xmm2 + movdqa 80(%esi),%xmm3 +.byte 102,15,56,0,217 + pxor %xmm2,%xmm3 +.byte 102,15,56,0,221 + movdqa 96(%esi),%xmm2 +.byte 102,15,56,0,212 + pxor %xmm3,%xmm2 + movdqa 112(%esi),%xmm3 +.byte 102,15,56,0,217 + pxor %xmm2,%xmm3 + addl $-16,%edx +.L011schedule_mangle_both: + movdqa 256(%ebp,%ecx,1),%xmm1 +.byte 102,15,56,0,217 + addl $-16,%ecx + andl $48,%ecx + movdqu %xmm3,(%edx) + ret +.size _vpaes_schedule_mangle,.-_vpaes_schedule_mangle +.globl vpaes_set_encrypt_key +.hidden vpaes_set_encrypt_key +.type vpaes_set_encrypt_key,@function +.align 16 +vpaes_set_encrypt_key: +.L_vpaes_set_encrypt_key_begin: + pushl %ebp + pushl %ebx + pushl %esi + pushl %edi +#ifdef BORINGSSL_DISPATCH_TEST + pushl %ebx + pushl %edx + call .L012pic_for_function_hit +.L012pic_for_function_hit: + popl %ebx + leal BORINGSSL_function_hit+5-.L012pic_for_function_hit(%ebx),%ebx + movl $1,%edx + movb %dl,(%ebx) + popl %edx + popl %ebx +#endif + movl 20(%esp),%esi + leal -56(%esp),%ebx + movl 24(%esp),%eax + andl $-16,%ebx + movl 28(%esp),%edx + xchgl %esp,%ebx + movl %ebx,48(%esp) + movl %eax,%ebx + shrl $5,%ebx + addl $5,%ebx + movl %ebx,240(%edx) + movl $48,%ecx + movl $0,%edi + leal .L_vpaes_consts+0x30-.L013pic_point,%ebp + call _vpaes_schedule_core +.L013pic_point: + movl 48(%esp),%esp + xorl %eax,%eax + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.size vpaes_set_encrypt_key,.-.L_vpaes_set_encrypt_key_begin +.globl vpaes_encrypt +.hidden vpaes_encrypt +.type vpaes_encrypt,@function +.align 16 +vpaes_encrypt: +.L_vpaes_encrypt_begin: + pushl %ebp + pushl %ebx + pushl %esi + pushl %edi +#ifdef BORINGSSL_DISPATCH_TEST + pushl %ebx + pushl %edx + call .L014pic_for_function_hit +.L014pic_for_function_hit: + popl %ebx + leal BORINGSSL_function_hit+4-.L014pic_for_function_hit(%ebx),%ebx + movl $1,%edx + movb %dl,(%ebx) + popl %edx + popl %ebx +#endif + leal .L_vpaes_consts+0x30-.L015pic_point,%ebp + call _vpaes_preheat +.L015pic_point: + movl 20(%esp),%esi + leal -56(%esp),%ebx + movl 24(%esp),%edi + andl $-16,%ebx + movl 28(%esp),%edx + xchgl %esp,%ebx + movl %ebx,48(%esp) + movdqu (%esi),%xmm0 + call _vpaes_encrypt_core + movdqu %xmm0,(%edi) + movl 48(%esp),%esp + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.size vpaes_encrypt,.-.L_vpaes_encrypt_begin +#endif // !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) diff --git a/http/vendor/ring/pregenerated/vpaes-x86-win32n.asm b/http/vendor/ring/pregenerated/vpaes-x86-win32n.asm new file mode 100644 index 0000000..f52f7ca --- /dev/null +++ b/http/vendor/ring/pregenerated/vpaes-x86-win32n.asm @@ -0,0 +1,408 @@ +; This file is generated from a similarly-named Perl script in the BoringSSL +; source tree. Do not edit by hand. + +%include "ring_core_generated/prefix_symbols_nasm.inc" +%ifidn __OUTPUT_FORMAT__, win32 +%ifidn __OUTPUT_FORMAT__,obj +section code use32 class=code align=64 +%elifidn __OUTPUT_FORMAT__,win32 +$@feat.00 equ 1 +section .text code align=64 +%else +section .text code +%endif +%ifdef BORINGSSL_DISPATCH_TEST +extern _BORINGSSL_function_hit +%endif +align 64 +L$_vpaes_consts: +dd 218628480,235210255,168496130,67568393 +dd 252381056,17041926,33884169,51187212 +dd 252645135,252645135,252645135,252645135 +dd 1512730624,3266504856,1377990664,3401244816 +dd 830229760,1275146365,2969422977,3447763452 +dd 3411033600,2979783055,338359620,2782886510 +dd 4209124096,907596821,221174255,1006095553 +dd 191964160,3799684038,3164090317,1589111125 +dd 182528256,1777043520,2877432650,3265356744 +dd 1874708224,3503451415,3305285752,363511674 +dd 1606117888,3487855781,1093350906,2384367825 +dd 197121,67569157,134941193,202313229 +dd 67569157,134941193,202313229,197121 +dd 134941193,202313229,197121,67569157 +dd 202313229,197121,67569157,134941193 +dd 33619971,100992007,168364043,235736079 +dd 235736079,33619971,100992007,168364043 +dd 168364043,235736079,33619971,100992007 +dd 100992007,168364043,235736079,33619971 +dd 50462976,117835012,185207048,252579084 +dd 252314880,51251460,117574920,184942860 +dd 184682752,252054788,50987272,118359308 +dd 118099200,185467140,251790600,50727180 +dd 2946363062,528716217,1300004225,1881839624 +dd 1532713819,1532713819,1532713819,1532713819 +dd 3602276352,4288629033,3737020424,4153884961 +dd 1354558464,32357713,2958822624,3775749553 +dd 1201988352,132424512,1572796698,503232858 +dd 2213177600,1597421020,4103937655,675398315 +db 86,101,99,116,111,114,32,80,101,114,109,117,116,97,116,105 +db 111,110,32,65,69,83,32,102,111,114,32,120,56,54,47,83 +db 83,83,69,51,44,32,77,105,107,101,32,72,97,109,98,117 +db 114,103,32,40,83,116,97,110,102,111,114,100,32,85,110,105 +db 118,101,114,115,105,116,121,41,0 +align 64 +align 16 +__vpaes_preheat: + add ebp,DWORD [esp] + movdqa xmm7,[ebp-48] + movdqa xmm6,[ebp-16] + ret +align 16 +__vpaes_encrypt_core: + mov ecx,16 + mov eax,DWORD [240+edx] + movdqa xmm1,xmm6 + movdqa xmm2,[ebp] + pandn xmm1,xmm0 + pand xmm0,xmm6 + movdqu xmm5,[edx] +db 102,15,56,0,208 + movdqa xmm0,[16+ebp] + pxor xmm2,xmm5 + psrld xmm1,4 + add edx,16 +db 102,15,56,0,193 + lea ebx,[192+ebp] + pxor xmm0,xmm2 + jmp NEAR L$000enc_entry +align 16 +L$001enc_loop: + movdqa xmm4,[32+ebp] + movdqa xmm0,[48+ebp] +db 102,15,56,0,226 +db 102,15,56,0,195 + pxor xmm4,xmm5 + movdqa xmm5,[64+ebp] + pxor xmm0,xmm4 + movdqa xmm1,[ecx*1+ebx-64] +db 102,15,56,0,234 + movdqa xmm2,[80+ebp] + movdqa xmm4,[ecx*1+ebx] +db 102,15,56,0,211 + movdqa xmm3,xmm0 + pxor xmm2,xmm5 +db 102,15,56,0,193 + add edx,16 + pxor xmm0,xmm2 +db 102,15,56,0,220 + add ecx,16 + pxor xmm3,xmm0 +db 102,15,56,0,193 + and ecx,48 + sub eax,1 + pxor xmm0,xmm3 +L$000enc_entry: + movdqa xmm1,xmm6 + movdqa xmm5,[ebp-32] + pandn xmm1,xmm0 + psrld xmm1,4 + pand xmm0,xmm6 +db 102,15,56,0,232 + movdqa xmm3,xmm7 + pxor xmm0,xmm1 +db 102,15,56,0,217 + movdqa xmm4,xmm7 + pxor xmm3,xmm5 +db 102,15,56,0,224 + movdqa xmm2,xmm7 + pxor xmm4,xmm5 +db 102,15,56,0,211 + movdqa xmm3,xmm7 + pxor xmm2,xmm0 +db 102,15,56,0,220 + movdqu xmm5,[edx] + pxor xmm3,xmm1 + jnz NEAR L$001enc_loop + movdqa xmm4,[96+ebp] + movdqa xmm0,[112+ebp] +db 102,15,56,0,226 + pxor xmm4,xmm5 +db 102,15,56,0,195 + movdqa xmm1,[64+ecx*1+ebx] + pxor xmm0,xmm4 +db 102,15,56,0,193 + ret +align 16 +__vpaes_schedule_core: + add ebp,DWORD [esp] + movdqu xmm0,[esi] + movdqa xmm2,[320+ebp] + movdqa xmm3,xmm0 + lea ebx,[ebp] + movdqa [4+esp],xmm2 + call __vpaes_schedule_transform + movdqa xmm7,xmm0 + test edi,edi + jnz NEAR L$002schedule_am_decrypting + movdqu [edx],xmm0 + jmp NEAR L$003schedule_go +L$002schedule_am_decrypting: + movdqa xmm1,[256+ecx*1+ebp] +db 102,15,56,0,217 + movdqu [edx],xmm3 + xor ecx,48 +L$003schedule_go: + cmp eax,192 + ja NEAR L$004schedule_256 +L$005schedule_128: + mov eax,10 +L$006loop_schedule_128: + call __vpaes_schedule_round + dec eax + jz NEAR L$007schedule_mangle_last + call __vpaes_schedule_mangle + jmp NEAR L$006loop_schedule_128 +align 16 +L$004schedule_256: + movdqu xmm0,[16+esi] + call __vpaes_schedule_transform + mov eax,7 +L$008loop_schedule_256: + call __vpaes_schedule_mangle + movdqa xmm6,xmm0 + call __vpaes_schedule_round + dec eax + jz NEAR L$007schedule_mangle_last + call __vpaes_schedule_mangle + pshufd xmm0,xmm0,255 + movdqa [20+esp],xmm7 + movdqa xmm7,xmm6 + call L$_vpaes_schedule_low_round + movdqa xmm7,[20+esp] + jmp NEAR L$008loop_schedule_256 +align 16 +L$007schedule_mangle_last: + lea ebx,[384+ebp] + test edi,edi + jnz NEAR L$009schedule_mangle_last_dec + movdqa xmm1,[256+ecx*1+ebp] +db 102,15,56,0,193 + lea ebx,[352+ebp] + add edx,32 +L$009schedule_mangle_last_dec: + add edx,-16 + pxor xmm0,[336+ebp] + call __vpaes_schedule_transform + movdqu [edx],xmm0 + pxor xmm0,xmm0 + pxor xmm1,xmm1 + pxor xmm2,xmm2 + pxor xmm3,xmm3 + pxor xmm4,xmm4 + pxor xmm5,xmm5 + pxor xmm6,xmm6 + pxor xmm7,xmm7 + ret +align 16 +__vpaes_schedule_round: + movdqa xmm2,[8+esp] + pxor xmm1,xmm1 +db 102,15,58,15,202,15 +db 102,15,58,15,210,15 + pxor xmm7,xmm1 + pshufd xmm0,xmm0,255 +db 102,15,58,15,192,1 + movdqa [8+esp],xmm2 +L$_vpaes_schedule_low_round: + movdqa xmm1,xmm7 + pslldq xmm7,4 + pxor xmm7,xmm1 + movdqa xmm1,xmm7 + pslldq xmm7,8 + pxor xmm7,xmm1 + pxor xmm7,[336+ebp] + movdqa xmm4,[ebp-16] + movdqa xmm5,[ebp-48] + movdqa xmm1,xmm4 + pandn xmm1,xmm0 + psrld xmm1,4 + pand xmm0,xmm4 + movdqa xmm2,[ebp-32] +db 102,15,56,0,208 + pxor xmm0,xmm1 + movdqa xmm3,xmm5 +db 102,15,56,0,217 + pxor xmm3,xmm2 + movdqa xmm4,xmm5 +db 102,15,56,0,224 + pxor xmm4,xmm2 + movdqa xmm2,xmm5 +db 102,15,56,0,211 + pxor xmm2,xmm0 + movdqa xmm3,xmm5 +db 102,15,56,0,220 + pxor xmm3,xmm1 + movdqa xmm4,[32+ebp] +db 102,15,56,0,226 + movdqa xmm0,[48+ebp] +db 102,15,56,0,195 + pxor xmm0,xmm4 + pxor xmm0,xmm7 + movdqa xmm7,xmm0 + ret +align 16 +__vpaes_schedule_transform: + movdqa xmm2,[ebp-16] + movdqa xmm1,xmm2 + pandn xmm1,xmm0 + psrld xmm1,4 + pand xmm0,xmm2 + movdqa xmm2,[ebx] +db 102,15,56,0,208 + movdqa xmm0,[16+ebx] +db 102,15,56,0,193 + pxor xmm0,xmm2 + ret +align 16 +__vpaes_schedule_mangle: + movdqa xmm4,xmm0 + movdqa xmm5,[128+ebp] + test edi,edi + jnz NEAR L$010schedule_mangle_dec + add edx,16 + pxor xmm4,[336+ebp] +db 102,15,56,0,229 + movdqa xmm3,xmm4 +db 102,15,56,0,229 + pxor xmm3,xmm4 +db 102,15,56,0,229 + pxor xmm3,xmm4 + jmp NEAR L$011schedule_mangle_both +align 16 +L$010schedule_mangle_dec: + movdqa xmm2,[ebp-16] + lea esi,[ebp] + movdqa xmm1,xmm2 + pandn xmm1,xmm4 + psrld xmm1,4 + pand xmm4,xmm2 + movdqa xmm2,[esi] +db 102,15,56,0,212 + movdqa xmm3,[16+esi] +db 102,15,56,0,217 + pxor xmm3,xmm2 +db 102,15,56,0,221 + movdqa xmm2,[32+esi] +db 102,15,56,0,212 + pxor xmm2,xmm3 + movdqa xmm3,[48+esi] +db 102,15,56,0,217 + pxor xmm3,xmm2 +db 102,15,56,0,221 + movdqa xmm2,[64+esi] +db 102,15,56,0,212 + pxor xmm2,xmm3 + movdqa xmm3,[80+esi] +db 102,15,56,0,217 + pxor xmm3,xmm2 +db 102,15,56,0,221 + movdqa xmm2,[96+esi] +db 102,15,56,0,212 + pxor xmm2,xmm3 + movdqa xmm3,[112+esi] +db 102,15,56,0,217 + pxor xmm3,xmm2 + add edx,-16 +L$011schedule_mangle_both: + movdqa xmm1,[256+ecx*1+ebp] +db 102,15,56,0,217 + add ecx,-16 + and ecx,48 + movdqu [edx],xmm3 + ret +global _vpaes_set_encrypt_key +align 16 +_vpaes_set_encrypt_key: +L$_vpaes_set_encrypt_key_begin: + push ebp + push ebx + push esi + push edi +%ifdef BORINGSSL_DISPATCH_TEST + push ebx + push edx + call L$012pic_for_function_hit +L$012pic_for_function_hit: + pop ebx + lea ebx,[(_BORINGSSL_function_hit+5-L$012pic_for_function_hit)+ebx] + mov edx,1 + mov BYTE [ebx],dl + pop edx + pop ebx +%endif + mov esi,DWORD [20+esp] + lea ebx,[esp-56] + mov eax,DWORD [24+esp] + and ebx,-16 + mov edx,DWORD [28+esp] + xchg ebx,esp + mov DWORD [48+esp],ebx + mov ebx,eax + shr ebx,5 + add ebx,5 + mov DWORD [240+edx],ebx + mov ecx,48 + mov edi,0 + lea ebp,[(L$_vpaes_consts+0x30-L$013pic_point)] + call __vpaes_schedule_core +L$013pic_point: + mov esp,DWORD [48+esp] + xor eax,eax + pop edi + pop esi + pop ebx + pop ebp + ret +global _vpaes_encrypt +align 16 +_vpaes_encrypt: +L$_vpaes_encrypt_begin: + push ebp + push ebx + push esi + push edi +%ifdef BORINGSSL_DISPATCH_TEST + push ebx + push edx + call L$014pic_for_function_hit +L$014pic_for_function_hit: + pop ebx + lea ebx,[(_BORINGSSL_function_hit+4-L$014pic_for_function_hit)+ebx] + mov edx,1 + mov BYTE [ebx],dl + pop edx + pop ebx +%endif + lea ebp,[(L$_vpaes_consts+0x30-L$015pic_point)] + call __vpaes_preheat +L$015pic_point: + mov esi,DWORD [20+esp] + lea ebx,[esp-56] + mov edi,DWORD [24+esp] + and ebx,-16 + mov edx,DWORD [28+esp] + xchg ebx,esp + mov DWORD [48+esp],ebx + movdqu xmm0,[esi] + call __vpaes_encrypt_core + movdqu [edi],xmm0 + mov esp,DWORD [48+esp] + pop edi + pop esi + pop ebx + pop ebp + ret +%else +; Work around https://bugzilla.nasm.us/show_bug.cgi?id=3392738 +ret +%endif diff --git a/http/vendor/ring/pregenerated/vpaes-x86-win32n.o b/http/vendor/ring/pregenerated/vpaes-x86-win32n.o new file mode 100644 index 0000000..b630709 Binary files /dev/null and b/http/vendor/ring/pregenerated/vpaes-x86-win32n.o differ diff --git a/http/vendor/ring/pregenerated/vpaes-x86_64-elf.S b/http/vendor/ring/pregenerated/vpaes-x86_64-elf.S new file mode 100644 index 0000000..146439f --- /dev/null +++ b/http/vendor/ring/pregenerated/vpaes-x86_64-elf.S @@ -0,0 +1,758 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__) +.text + + + + + + + + + + + + + + + + +.type _vpaes_encrypt_core,@function +.align 16 +_vpaes_encrypt_core: +.cfi_startproc + movq %rdx,%r9 + movq $16,%r11 + movl 240(%rdx),%eax + movdqa %xmm9,%xmm1 + movdqa .Lk_ipt(%rip),%xmm2 + pandn %xmm0,%xmm1 + movdqu (%r9),%xmm5 + psrld $4,%xmm1 + pand %xmm9,%xmm0 +.byte 102,15,56,0,208 + movdqa .Lk_ipt+16(%rip),%xmm0 +.byte 102,15,56,0,193 + pxor %xmm5,%xmm2 + addq $16,%r9 + pxor %xmm2,%xmm0 + leaq .Lk_mc_backward(%rip),%r10 + jmp .Lenc_entry + +.align 16 +.Lenc_loop: + + movdqa %xmm13,%xmm4 + movdqa %xmm12,%xmm0 +.byte 102,15,56,0,226 +.byte 102,15,56,0,195 + pxor %xmm5,%xmm4 + movdqa %xmm15,%xmm5 + pxor %xmm4,%xmm0 + movdqa -64(%r11,%r10,1),%xmm1 +.byte 102,15,56,0,234 + movdqa (%r11,%r10,1),%xmm4 + movdqa %xmm14,%xmm2 +.byte 102,15,56,0,211 + movdqa %xmm0,%xmm3 + pxor %xmm5,%xmm2 +.byte 102,15,56,0,193 + addq $16,%r9 + pxor %xmm2,%xmm0 +.byte 102,15,56,0,220 + addq $16,%r11 + pxor %xmm0,%xmm3 +.byte 102,15,56,0,193 + andq $0x30,%r11 + subq $1,%rax + pxor %xmm3,%xmm0 + +.Lenc_entry: + + movdqa %xmm9,%xmm1 + movdqa %xmm11,%xmm5 + pandn %xmm0,%xmm1 + psrld $4,%xmm1 + pand %xmm9,%xmm0 +.byte 102,15,56,0,232 + movdqa %xmm10,%xmm3 + pxor %xmm1,%xmm0 +.byte 102,15,56,0,217 + movdqa %xmm10,%xmm4 + pxor %xmm5,%xmm3 +.byte 102,15,56,0,224 + movdqa %xmm10,%xmm2 + pxor %xmm5,%xmm4 +.byte 102,15,56,0,211 + movdqa %xmm10,%xmm3 + pxor %xmm0,%xmm2 +.byte 102,15,56,0,220 + movdqu (%r9),%xmm5 + pxor %xmm1,%xmm3 + jnz .Lenc_loop + + + movdqa -96(%r10),%xmm4 + movdqa -80(%r10),%xmm0 +.byte 102,15,56,0,226 + pxor %xmm5,%xmm4 +.byte 102,15,56,0,195 + movdqa 64(%r11,%r10,1),%xmm1 + pxor %xmm4,%xmm0 +.byte 102,15,56,0,193 + ret +.cfi_endproc +.size _vpaes_encrypt_core,.-_vpaes_encrypt_core + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +.type _vpaes_encrypt_core_2x,@function +.align 16 +_vpaes_encrypt_core_2x: +.cfi_startproc + movq %rdx,%r9 + movq $16,%r11 + movl 240(%rdx),%eax + movdqa %xmm9,%xmm1 + movdqa %xmm9,%xmm7 + movdqa .Lk_ipt(%rip),%xmm2 + movdqa %xmm2,%xmm8 + pandn %xmm0,%xmm1 + pandn %xmm6,%xmm7 + movdqu (%r9),%xmm5 + + psrld $4,%xmm1 + psrld $4,%xmm7 + pand %xmm9,%xmm0 + pand %xmm9,%xmm6 +.byte 102,15,56,0,208 +.byte 102,68,15,56,0,198 + movdqa .Lk_ipt+16(%rip),%xmm0 + movdqa %xmm0,%xmm6 +.byte 102,15,56,0,193 +.byte 102,15,56,0,247 + pxor %xmm5,%xmm2 + pxor %xmm5,%xmm8 + addq $16,%r9 + pxor %xmm2,%xmm0 + pxor %xmm8,%xmm6 + leaq .Lk_mc_backward(%rip),%r10 + jmp .Lenc2x_entry + +.align 16 +.Lenc2x_loop: + + movdqa .Lk_sb1(%rip),%xmm4 + movdqa .Lk_sb1+16(%rip),%xmm0 + movdqa %xmm4,%xmm12 + movdqa %xmm0,%xmm6 +.byte 102,15,56,0,226 +.byte 102,69,15,56,0,224 +.byte 102,15,56,0,195 +.byte 102,65,15,56,0,243 + pxor %xmm5,%xmm4 + pxor %xmm5,%xmm12 + movdqa .Lk_sb2(%rip),%xmm5 + movdqa %xmm5,%xmm13 + pxor %xmm4,%xmm0 + pxor %xmm12,%xmm6 + movdqa -64(%r11,%r10,1),%xmm1 + +.byte 102,15,56,0,234 +.byte 102,69,15,56,0,232 + movdqa (%r11,%r10,1),%xmm4 + + movdqa .Lk_sb2+16(%rip),%xmm2 + movdqa %xmm2,%xmm8 +.byte 102,15,56,0,211 +.byte 102,69,15,56,0,195 + movdqa %xmm0,%xmm3 + movdqa %xmm6,%xmm11 + pxor %xmm5,%xmm2 + pxor %xmm13,%xmm8 +.byte 102,15,56,0,193 +.byte 102,15,56,0,241 + addq $16,%r9 + pxor %xmm2,%xmm0 + pxor %xmm8,%xmm6 +.byte 102,15,56,0,220 +.byte 102,68,15,56,0,220 + addq $16,%r11 + pxor %xmm0,%xmm3 + pxor %xmm6,%xmm11 +.byte 102,15,56,0,193 +.byte 102,15,56,0,241 + andq $0x30,%r11 + subq $1,%rax + pxor %xmm3,%xmm0 + pxor %xmm11,%xmm6 + +.Lenc2x_entry: + + movdqa %xmm9,%xmm1 + movdqa %xmm9,%xmm7 + movdqa .Lk_inv+16(%rip),%xmm5 + movdqa %xmm5,%xmm13 + pandn %xmm0,%xmm1 + pandn %xmm6,%xmm7 + psrld $4,%xmm1 + psrld $4,%xmm7 + pand %xmm9,%xmm0 + pand %xmm9,%xmm6 +.byte 102,15,56,0,232 +.byte 102,68,15,56,0,238 + movdqa %xmm10,%xmm3 + movdqa %xmm10,%xmm11 + pxor %xmm1,%xmm0 + pxor %xmm7,%xmm6 +.byte 102,15,56,0,217 +.byte 102,68,15,56,0,223 + movdqa %xmm10,%xmm4 + movdqa %xmm10,%xmm12 + pxor %xmm5,%xmm3 + pxor %xmm13,%xmm11 +.byte 102,15,56,0,224 +.byte 102,68,15,56,0,230 + movdqa %xmm10,%xmm2 + movdqa %xmm10,%xmm8 + pxor %xmm5,%xmm4 + pxor %xmm13,%xmm12 +.byte 102,15,56,0,211 +.byte 102,69,15,56,0,195 + movdqa %xmm10,%xmm3 + movdqa %xmm10,%xmm11 + pxor %xmm0,%xmm2 + pxor %xmm6,%xmm8 +.byte 102,15,56,0,220 +.byte 102,69,15,56,0,220 + movdqu (%r9),%xmm5 + + pxor %xmm1,%xmm3 + pxor %xmm7,%xmm11 + jnz .Lenc2x_loop + + + movdqa -96(%r10),%xmm4 + movdqa -80(%r10),%xmm0 + movdqa %xmm4,%xmm12 + movdqa %xmm0,%xmm6 +.byte 102,15,56,0,226 +.byte 102,69,15,56,0,224 + pxor %xmm5,%xmm4 + pxor %xmm5,%xmm12 +.byte 102,15,56,0,195 +.byte 102,65,15,56,0,243 + movdqa 64(%r11,%r10,1),%xmm1 + + pxor %xmm4,%xmm0 + pxor %xmm12,%xmm6 +.byte 102,15,56,0,193 +.byte 102,15,56,0,241 + ret +.cfi_endproc +.size _vpaes_encrypt_core_2x,.-_vpaes_encrypt_core_2x + + + + + + +.type _vpaes_schedule_core,@function +.align 16 +_vpaes_schedule_core: +.cfi_startproc + + + + + + call _vpaes_preheat + movdqa .Lk_rcon(%rip),%xmm8 + movdqu (%rdi),%xmm0 + + + movdqa %xmm0,%xmm3 + leaq .Lk_ipt(%rip),%r11 + call _vpaes_schedule_transform + movdqa %xmm0,%xmm7 + + leaq .Lk_sr(%rip),%r10 + + + movdqu %xmm0,(%rdx) + +.Lschedule_go: + cmpl $192,%esi + ja .Lschedule_256 + + + + + + + + + + + +.Lschedule_128: + movl $10,%esi + +.Loop_schedule_128: + call _vpaes_schedule_round + decq %rsi + jz .Lschedule_mangle_last + call _vpaes_schedule_mangle + jmp .Loop_schedule_128 + + + + + + + + + + + +.align 16 +.Lschedule_256: + movdqu 16(%rdi),%xmm0 + call _vpaes_schedule_transform + movl $7,%esi + +.Loop_schedule_256: + call _vpaes_schedule_mangle + movdqa %xmm0,%xmm6 + + + call _vpaes_schedule_round + decq %rsi + jz .Lschedule_mangle_last + call _vpaes_schedule_mangle + + + pshufd $0xFF,%xmm0,%xmm0 + movdqa %xmm7,%xmm5 + movdqa %xmm6,%xmm7 + call _vpaes_schedule_low_round + movdqa %xmm5,%xmm7 + + jmp .Loop_schedule_256 + + + + + + + + + + + + +.align 16 +.Lschedule_mangle_last: + + leaq .Lk_deskew(%rip),%r11 + + + movdqa (%r8,%r10,1),%xmm1 +.byte 102,15,56,0,193 + leaq .Lk_opt(%rip),%r11 + addq $32,%rdx + +.Lschedule_mangle_last_dec: + addq $-16,%rdx + pxor .Lk_s63(%rip),%xmm0 + call _vpaes_schedule_transform + movdqu %xmm0,(%rdx) + + + pxor %xmm0,%xmm0 + pxor %xmm1,%xmm1 + pxor %xmm2,%xmm2 + pxor %xmm3,%xmm3 + pxor %xmm4,%xmm4 + pxor %xmm5,%xmm5 + pxor %xmm6,%xmm6 + pxor %xmm7,%xmm7 + ret +.cfi_endproc +.size _vpaes_schedule_core,.-_vpaes_schedule_core + + + + + + + + + + + + + + + + + + + +.type _vpaes_schedule_round,@function +.align 16 +_vpaes_schedule_round: +.cfi_startproc + + pxor %xmm1,%xmm1 +.byte 102,65,15,58,15,200,15 +.byte 102,69,15,58,15,192,15 + pxor %xmm1,%xmm7 + + + pshufd $0xFF,%xmm0,%xmm0 +.byte 102,15,58,15,192,1 + + + + +_vpaes_schedule_low_round: + + movdqa %xmm7,%xmm1 + pslldq $4,%xmm7 + pxor %xmm1,%xmm7 + movdqa %xmm7,%xmm1 + pslldq $8,%xmm7 + pxor %xmm1,%xmm7 + pxor .Lk_s63(%rip),%xmm7 + + + movdqa %xmm9,%xmm1 + pandn %xmm0,%xmm1 + psrld $4,%xmm1 + pand %xmm9,%xmm0 + movdqa %xmm11,%xmm2 +.byte 102,15,56,0,208 + pxor %xmm1,%xmm0 + movdqa %xmm10,%xmm3 +.byte 102,15,56,0,217 + pxor %xmm2,%xmm3 + movdqa %xmm10,%xmm4 +.byte 102,15,56,0,224 + pxor %xmm2,%xmm4 + movdqa %xmm10,%xmm2 +.byte 102,15,56,0,211 + pxor %xmm0,%xmm2 + movdqa %xmm10,%xmm3 +.byte 102,15,56,0,220 + pxor %xmm1,%xmm3 + movdqa %xmm13,%xmm4 +.byte 102,15,56,0,226 + movdqa %xmm12,%xmm0 +.byte 102,15,56,0,195 + pxor %xmm4,%xmm0 + + + pxor %xmm7,%xmm0 + movdqa %xmm0,%xmm7 + ret +.cfi_endproc +.size _vpaes_schedule_round,.-_vpaes_schedule_round + + + + + + + + + + +.type _vpaes_schedule_transform,@function +.align 16 +_vpaes_schedule_transform: +.cfi_startproc + movdqa %xmm9,%xmm1 + pandn %xmm0,%xmm1 + psrld $4,%xmm1 + pand %xmm9,%xmm0 + movdqa (%r11),%xmm2 +.byte 102,15,56,0,208 + movdqa 16(%r11),%xmm0 +.byte 102,15,56,0,193 + pxor %xmm2,%xmm0 + ret +.cfi_endproc +.size _vpaes_schedule_transform,.-_vpaes_schedule_transform + + + + + + + + + + + + + + + + + + + + + + + + +.type _vpaes_schedule_mangle,@function +.align 16 +_vpaes_schedule_mangle: +.cfi_startproc + movdqa %xmm0,%xmm4 + movdqa .Lk_mc_forward(%rip),%xmm5 + + + addq $16,%rdx + pxor .Lk_s63(%rip),%xmm4 +.byte 102,15,56,0,229 + movdqa %xmm4,%xmm3 +.byte 102,15,56,0,229 + pxor %xmm4,%xmm3 +.byte 102,15,56,0,229 + pxor %xmm4,%xmm3 + +.Lschedule_mangle_both: + movdqa (%r8,%r10,1),%xmm1 +.byte 102,15,56,0,217 + addq $-16,%r8 + andq $0x30,%r8 + movdqu %xmm3,(%rdx) + ret +.cfi_endproc +.size _vpaes_schedule_mangle,.-_vpaes_schedule_mangle + + + + +.globl vpaes_set_encrypt_key +.hidden vpaes_set_encrypt_key +.type vpaes_set_encrypt_key,@function +.align 16 +vpaes_set_encrypt_key: +.cfi_startproc +_CET_ENDBR +#ifdef BORINGSSL_DISPATCH_TEST +.extern BORINGSSL_function_hit +.hidden BORINGSSL_function_hit + movb $1,BORINGSSL_function_hit+5(%rip) +#endif + + movl %esi,%eax + shrl $5,%eax + addl $5,%eax + movl %eax,240(%rdx) + + movl $0,%ecx + movl $0x30,%r8d + call _vpaes_schedule_core + xorl %eax,%eax + ret +.cfi_endproc +.size vpaes_set_encrypt_key,.-vpaes_set_encrypt_key +.globl vpaes_ctr32_encrypt_blocks +.hidden vpaes_ctr32_encrypt_blocks +.type vpaes_ctr32_encrypt_blocks,@function +.align 16 +vpaes_ctr32_encrypt_blocks: +.cfi_startproc +_CET_ENDBR + + xchgq %rcx,%rdx + testq %rcx,%rcx + jz .Lctr32_abort + movdqu (%r8),%xmm0 + movdqa .Lctr_add_one(%rip),%xmm8 + subq %rdi,%rsi + call _vpaes_preheat + movdqa %xmm0,%xmm6 + pshufb .Lrev_ctr(%rip),%xmm6 + + testq $1,%rcx + jz .Lctr32_prep_loop + + + + movdqu (%rdi),%xmm7 + call _vpaes_encrypt_core + pxor %xmm7,%xmm0 + paddd %xmm8,%xmm6 + movdqu %xmm0,(%rsi,%rdi,1) + subq $1,%rcx + leaq 16(%rdi),%rdi + jz .Lctr32_done + +.Lctr32_prep_loop: + + + movdqa %xmm6,%xmm14 + movdqa %xmm6,%xmm15 + paddd %xmm8,%xmm15 + +.Lctr32_loop: + movdqa .Lrev_ctr(%rip),%xmm1 + movdqa %xmm14,%xmm0 + movdqa %xmm15,%xmm6 +.byte 102,15,56,0,193 +.byte 102,15,56,0,241 + call _vpaes_encrypt_core_2x + movdqu (%rdi),%xmm1 + movdqu 16(%rdi),%xmm2 + movdqa .Lctr_add_two(%rip),%xmm3 + pxor %xmm1,%xmm0 + pxor %xmm2,%xmm6 + paddd %xmm3,%xmm14 + paddd %xmm3,%xmm15 + movdqu %xmm0,(%rsi,%rdi,1) + movdqu %xmm6,16(%rsi,%rdi,1) + subq $2,%rcx + leaq 32(%rdi),%rdi + jnz .Lctr32_loop + +.Lctr32_done: +.Lctr32_abort: + ret +.cfi_endproc +.size vpaes_ctr32_encrypt_blocks,.-vpaes_ctr32_encrypt_blocks + + + + + + +.type _vpaes_preheat,@function +.align 16 +_vpaes_preheat: +.cfi_startproc + leaq .Lk_s0F(%rip),%r10 + movdqa -32(%r10),%xmm10 + movdqa -16(%r10),%xmm11 + movdqa 0(%r10),%xmm9 + movdqa 48(%r10),%xmm13 + movdqa 64(%r10),%xmm12 + movdqa 80(%r10),%xmm15 + movdqa 96(%r10),%xmm14 + ret +.cfi_endproc +.size _vpaes_preheat,.-_vpaes_preheat + + + + + +.type _vpaes_consts,@object +.section .rodata +.align 64 +_vpaes_consts: +.Lk_inv: +.quad 0x0E05060F0D080180, 0x040703090A0B0C02 +.quad 0x01040A060F0B0780, 0x030D0E0C02050809 + +.Lk_s0F: +.quad 0x0F0F0F0F0F0F0F0F, 0x0F0F0F0F0F0F0F0F + +.Lk_ipt: +.quad 0xC2B2E8985A2A7000, 0xCABAE09052227808 +.quad 0x4C01307D317C4D00, 0xCD80B1FCB0FDCC81 + +.Lk_sb1: +.quad 0xB19BE18FCB503E00, 0xA5DF7A6E142AF544 +.quad 0x3618D415FAE22300, 0x3BF7CCC10D2ED9EF +.Lk_sb2: +.quad 0xE27A93C60B712400, 0x5EB7E955BC982FCD +.quad 0x69EB88400AE12900, 0xC2A163C8AB82234A +.Lk_sbo: +.quad 0xD0D26D176FBDC700, 0x15AABF7AC502A878 +.quad 0xCFE474A55FBB6A00, 0x8E1E90D1412B35FA + +.Lk_mc_forward: +.quad 0x0407060500030201, 0x0C0F0E0D080B0A09 +.quad 0x080B0A0904070605, 0x000302010C0F0E0D +.quad 0x0C0F0E0D080B0A09, 0x0407060500030201 +.quad 0x000302010C0F0E0D, 0x080B0A0904070605 + +.Lk_mc_backward: +.quad 0x0605040702010003, 0x0E0D0C0F0A09080B +.quad 0x020100030E0D0C0F, 0x0A09080B06050407 +.quad 0x0E0D0C0F0A09080B, 0x0605040702010003 +.quad 0x0A09080B06050407, 0x020100030E0D0C0F + +.Lk_sr: +.quad 0x0706050403020100, 0x0F0E0D0C0B0A0908 +.quad 0x030E09040F0A0500, 0x0B06010C07020D08 +.quad 0x0F060D040B020900, 0x070E050C030A0108 +.quad 0x0B0E0104070A0D00, 0x0306090C0F020508 + +.Lk_rcon: +.quad 0x1F8391B9AF9DEEB6, 0x702A98084D7C7D81 + +.Lk_s63: +.quad 0x5B5B5B5B5B5B5B5B, 0x5B5B5B5B5B5B5B5B + +.Lk_opt: +.quad 0xFF9F4929D6B66000, 0xF7974121DEBE6808 +.quad 0x01EDBD5150BCEC00, 0xE10D5DB1B05C0CE0 + +.Lk_deskew: +.quad 0x07E4A34047A4E300, 0x1DFEB95A5DBEF91A +.quad 0x5F36B5DC83EA6900, 0x2841C2ABF49D1E77 + + +.Lrev_ctr: +.quad 0x0706050403020100, 0x0c0d0e0f0b0a0908 + + +.Lctr_add_one: +.quad 0x0000000000000000, 0x0000000100000000 +.Lctr_add_two: +.quad 0x0000000000000000, 0x0000000200000000 + +.byte 86,101,99,116,111,114,32,80,101,114,109,117,116,97,116,105,111,110,32,65,69,83,32,102,111,114,32,120,56,54,95,54,52,47,83,83,83,69,51,44,32,77,105,107,101,32,72,97,109,98,117,114,103,32,40,83,116,97,110,102,111,114,100,32,85,110,105,118,101,114,115,105,116,121,41,0 +.align 64 +.size _vpaes_consts,.-_vpaes_consts +.text +#endif diff --git a/http/vendor/ring/pregenerated/vpaes-x86_64-macosx.S b/http/vendor/ring/pregenerated/vpaes-x86_64-macosx.S new file mode 100644 index 0000000..b113e79 --- /dev/null +++ b/http/vendor/ring/pregenerated/vpaes-x86_64-macosx.S @@ -0,0 +1,757 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__) +.text + + + + + + + + + + + + + + + + + +.p2align 4 +_vpaes_encrypt_core: + + movq %rdx,%r9 + movq $16,%r11 + movl 240(%rdx),%eax + movdqa %xmm9,%xmm1 + movdqa L$k_ipt(%rip),%xmm2 + pandn %xmm0,%xmm1 + movdqu (%r9),%xmm5 + psrld $4,%xmm1 + pand %xmm9,%xmm0 +.byte 102,15,56,0,208 + movdqa L$k_ipt+16(%rip),%xmm0 +.byte 102,15,56,0,193 + pxor %xmm5,%xmm2 + addq $16,%r9 + pxor %xmm2,%xmm0 + leaq L$k_mc_backward(%rip),%r10 + jmp L$enc_entry + +.p2align 4 +L$enc_loop: + + movdqa %xmm13,%xmm4 + movdqa %xmm12,%xmm0 +.byte 102,15,56,0,226 +.byte 102,15,56,0,195 + pxor %xmm5,%xmm4 + movdqa %xmm15,%xmm5 + pxor %xmm4,%xmm0 + movdqa -64(%r11,%r10,1),%xmm1 +.byte 102,15,56,0,234 + movdqa (%r11,%r10,1),%xmm4 + movdqa %xmm14,%xmm2 +.byte 102,15,56,0,211 + movdqa %xmm0,%xmm3 + pxor %xmm5,%xmm2 +.byte 102,15,56,0,193 + addq $16,%r9 + pxor %xmm2,%xmm0 +.byte 102,15,56,0,220 + addq $16,%r11 + pxor %xmm0,%xmm3 +.byte 102,15,56,0,193 + andq $0x30,%r11 + subq $1,%rax + pxor %xmm3,%xmm0 + +L$enc_entry: + + movdqa %xmm9,%xmm1 + movdqa %xmm11,%xmm5 + pandn %xmm0,%xmm1 + psrld $4,%xmm1 + pand %xmm9,%xmm0 +.byte 102,15,56,0,232 + movdqa %xmm10,%xmm3 + pxor %xmm1,%xmm0 +.byte 102,15,56,0,217 + movdqa %xmm10,%xmm4 + pxor %xmm5,%xmm3 +.byte 102,15,56,0,224 + movdqa %xmm10,%xmm2 + pxor %xmm5,%xmm4 +.byte 102,15,56,0,211 + movdqa %xmm10,%xmm3 + pxor %xmm0,%xmm2 +.byte 102,15,56,0,220 + movdqu (%r9),%xmm5 + pxor %xmm1,%xmm3 + jnz L$enc_loop + + + movdqa -96(%r10),%xmm4 + movdqa -80(%r10),%xmm0 +.byte 102,15,56,0,226 + pxor %xmm5,%xmm4 +.byte 102,15,56,0,195 + movdqa 64(%r11,%r10,1),%xmm1 + pxor %xmm4,%xmm0 +.byte 102,15,56,0,193 + ret + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +.p2align 4 +_vpaes_encrypt_core_2x: + + movq %rdx,%r9 + movq $16,%r11 + movl 240(%rdx),%eax + movdqa %xmm9,%xmm1 + movdqa %xmm9,%xmm7 + movdqa L$k_ipt(%rip),%xmm2 + movdqa %xmm2,%xmm8 + pandn %xmm0,%xmm1 + pandn %xmm6,%xmm7 + movdqu (%r9),%xmm5 + + psrld $4,%xmm1 + psrld $4,%xmm7 + pand %xmm9,%xmm0 + pand %xmm9,%xmm6 +.byte 102,15,56,0,208 +.byte 102,68,15,56,0,198 + movdqa L$k_ipt+16(%rip),%xmm0 + movdqa %xmm0,%xmm6 +.byte 102,15,56,0,193 +.byte 102,15,56,0,247 + pxor %xmm5,%xmm2 + pxor %xmm5,%xmm8 + addq $16,%r9 + pxor %xmm2,%xmm0 + pxor %xmm8,%xmm6 + leaq L$k_mc_backward(%rip),%r10 + jmp L$enc2x_entry + +.p2align 4 +L$enc2x_loop: + + movdqa L$k_sb1(%rip),%xmm4 + movdqa L$k_sb1+16(%rip),%xmm0 + movdqa %xmm4,%xmm12 + movdqa %xmm0,%xmm6 +.byte 102,15,56,0,226 +.byte 102,69,15,56,0,224 +.byte 102,15,56,0,195 +.byte 102,65,15,56,0,243 + pxor %xmm5,%xmm4 + pxor %xmm5,%xmm12 + movdqa L$k_sb2(%rip),%xmm5 + movdqa %xmm5,%xmm13 + pxor %xmm4,%xmm0 + pxor %xmm12,%xmm6 + movdqa -64(%r11,%r10,1),%xmm1 + +.byte 102,15,56,0,234 +.byte 102,69,15,56,0,232 + movdqa (%r11,%r10,1),%xmm4 + + movdqa L$k_sb2+16(%rip),%xmm2 + movdqa %xmm2,%xmm8 +.byte 102,15,56,0,211 +.byte 102,69,15,56,0,195 + movdqa %xmm0,%xmm3 + movdqa %xmm6,%xmm11 + pxor %xmm5,%xmm2 + pxor %xmm13,%xmm8 +.byte 102,15,56,0,193 +.byte 102,15,56,0,241 + addq $16,%r9 + pxor %xmm2,%xmm0 + pxor %xmm8,%xmm6 +.byte 102,15,56,0,220 +.byte 102,68,15,56,0,220 + addq $16,%r11 + pxor %xmm0,%xmm3 + pxor %xmm6,%xmm11 +.byte 102,15,56,0,193 +.byte 102,15,56,0,241 + andq $0x30,%r11 + subq $1,%rax + pxor %xmm3,%xmm0 + pxor %xmm11,%xmm6 + +L$enc2x_entry: + + movdqa %xmm9,%xmm1 + movdqa %xmm9,%xmm7 + movdqa L$k_inv+16(%rip),%xmm5 + movdqa %xmm5,%xmm13 + pandn %xmm0,%xmm1 + pandn %xmm6,%xmm7 + psrld $4,%xmm1 + psrld $4,%xmm7 + pand %xmm9,%xmm0 + pand %xmm9,%xmm6 +.byte 102,15,56,0,232 +.byte 102,68,15,56,0,238 + movdqa %xmm10,%xmm3 + movdqa %xmm10,%xmm11 + pxor %xmm1,%xmm0 + pxor %xmm7,%xmm6 +.byte 102,15,56,0,217 +.byte 102,68,15,56,0,223 + movdqa %xmm10,%xmm4 + movdqa %xmm10,%xmm12 + pxor %xmm5,%xmm3 + pxor %xmm13,%xmm11 +.byte 102,15,56,0,224 +.byte 102,68,15,56,0,230 + movdqa %xmm10,%xmm2 + movdqa %xmm10,%xmm8 + pxor %xmm5,%xmm4 + pxor %xmm13,%xmm12 +.byte 102,15,56,0,211 +.byte 102,69,15,56,0,195 + movdqa %xmm10,%xmm3 + movdqa %xmm10,%xmm11 + pxor %xmm0,%xmm2 + pxor %xmm6,%xmm8 +.byte 102,15,56,0,220 +.byte 102,69,15,56,0,220 + movdqu (%r9),%xmm5 + + pxor %xmm1,%xmm3 + pxor %xmm7,%xmm11 + jnz L$enc2x_loop + + + movdqa -96(%r10),%xmm4 + movdqa -80(%r10),%xmm0 + movdqa %xmm4,%xmm12 + movdqa %xmm0,%xmm6 +.byte 102,15,56,0,226 +.byte 102,69,15,56,0,224 + pxor %xmm5,%xmm4 + pxor %xmm5,%xmm12 +.byte 102,15,56,0,195 +.byte 102,65,15,56,0,243 + movdqa 64(%r11,%r10,1),%xmm1 + + pxor %xmm4,%xmm0 + pxor %xmm12,%xmm6 +.byte 102,15,56,0,193 +.byte 102,15,56,0,241 + ret + + + + + + + + + +.p2align 4 +_vpaes_schedule_core: + + + + + + + call _vpaes_preheat + movdqa L$k_rcon(%rip),%xmm8 + movdqu (%rdi),%xmm0 + + + movdqa %xmm0,%xmm3 + leaq L$k_ipt(%rip),%r11 + call _vpaes_schedule_transform + movdqa %xmm0,%xmm7 + + leaq L$k_sr(%rip),%r10 + + + movdqu %xmm0,(%rdx) + +L$schedule_go: + cmpl $192,%esi + ja L$schedule_256 + + + + + + + + + + + +L$schedule_128: + movl $10,%esi + +L$oop_schedule_128: + call _vpaes_schedule_round + decq %rsi + jz L$schedule_mangle_last + call _vpaes_schedule_mangle + jmp L$oop_schedule_128 + + + + + + + + + + + +.p2align 4 +L$schedule_256: + movdqu 16(%rdi),%xmm0 + call _vpaes_schedule_transform + movl $7,%esi + +L$oop_schedule_256: + call _vpaes_schedule_mangle + movdqa %xmm0,%xmm6 + + + call _vpaes_schedule_round + decq %rsi + jz L$schedule_mangle_last + call _vpaes_schedule_mangle + + + pshufd $0xFF,%xmm0,%xmm0 + movdqa %xmm7,%xmm5 + movdqa %xmm6,%xmm7 + call _vpaes_schedule_low_round + movdqa %xmm5,%xmm7 + + jmp L$oop_schedule_256 + + + + + + + + + + + + +.p2align 4 +L$schedule_mangle_last: + + leaq L$k_deskew(%rip),%r11 + + + movdqa (%r8,%r10,1),%xmm1 +.byte 102,15,56,0,193 + leaq L$k_opt(%rip),%r11 + addq $32,%rdx + +L$schedule_mangle_last_dec: + addq $-16,%rdx + pxor L$k_s63(%rip),%xmm0 + call _vpaes_schedule_transform + movdqu %xmm0,(%rdx) + + + pxor %xmm0,%xmm0 + pxor %xmm1,%xmm1 + pxor %xmm2,%xmm2 + pxor %xmm3,%xmm3 + pxor %xmm4,%xmm4 + pxor %xmm5,%xmm5 + pxor %xmm6,%xmm6 + pxor %xmm7,%xmm7 + ret + + + + + + + + + + + + + + + + + + + + + + +.p2align 4 +_vpaes_schedule_round: + + + pxor %xmm1,%xmm1 +.byte 102,65,15,58,15,200,15 +.byte 102,69,15,58,15,192,15 + pxor %xmm1,%xmm7 + + + pshufd $0xFF,%xmm0,%xmm0 +.byte 102,15,58,15,192,1 + + + + +_vpaes_schedule_low_round: + + movdqa %xmm7,%xmm1 + pslldq $4,%xmm7 + pxor %xmm1,%xmm7 + movdqa %xmm7,%xmm1 + pslldq $8,%xmm7 + pxor %xmm1,%xmm7 + pxor L$k_s63(%rip),%xmm7 + + + movdqa %xmm9,%xmm1 + pandn %xmm0,%xmm1 + psrld $4,%xmm1 + pand %xmm9,%xmm0 + movdqa %xmm11,%xmm2 +.byte 102,15,56,0,208 + pxor %xmm1,%xmm0 + movdqa %xmm10,%xmm3 +.byte 102,15,56,0,217 + pxor %xmm2,%xmm3 + movdqa %xmm10,%xmm4 +.byte 102,15,56,0,224 + pxor %xmm2,%xmm4 + movdqa %xmm10,%xmm2 +.byte 102,15,56,0,211 + pxor %xmm0,%xmm2 + movdqa %xmm10,%xmm3 +.byte 102,15,56,0,220 + pxor %xmm1,%xmm3 + movdqa %xmm13,%xmm4 +.byte 102,15,56,0,226 + movdqa %xmm12,%xmm0 +.byte 102,15,56,0,195 + pxor %xmm4,%xmm0 + + + pxor %xmm7,%xmm0 + movdqa %xmm0,%xmm7 + ret + + + + + + + + + + + + + +.p2align 4 +_vpaes_schedule_transform: + + movdqa %xmm9,%xmm1 + pandn %xmm0,%xmm1 + psrld $4,%xmm1 + pand %xmm9,%xmm0 + movdqa (%r11),%xmm2 +.byte 102,15,56,0,208 + movdqa 16(%r11),%xmm0 +.byte 102,15,56,0,193 + pxor %xmm2,%xmm0 + ret + + + + + + + + + + + + + + + + + + + + + + + + + + + +.p2align 4 +_vpaes_schedule_mangle: + + movdqa %xmm0,%xmm4 + movdqa L$k_mc_forward(%rip),%xmm5 + + + addq $16,%rdx + pxor L$k_s63(%rip),%xmm4 +.byte 102,15,56,0,229 + movdqa %xmm4,%xmm3 +.byte 102,15,56,0,229 + pxor %xmm4,%xmm3 +.byte 102,15,56,0,229 + pxor %xmm4,%xmm3 + +L$schedule_mangle_both: + movdqa (%r8,%r10,1),%xmm1 +.byte 102,15,56,0,217 + addq $-16,%r8 + andq $0x30,%r8 + movdqu %xmm3,(%rdx) + ret + + + + + + +.globl _vpaes_set_encrypt_key +.private_extern _vpaes_set_encrypt_key + +.p2align 4 +_vpaes_set_encrypt_key: + +_CET_ENDBR +#ifdef BORINGSSL_DISPATCH_TEST + + movb $1,_BORINGSSL_function_hit+5(%rip) +#endif + + movl %esi,%eax + shrl $5,%eax + addl $5,%eax + movl %eax,240(%rdx) + + movl $0,%ecx + movl $0x30,%r8d + call _vpaes_schedule_core + xorl %eax,%eax + ret + + +.globl _vpaes_ctr32_encrypt_blocks +.private_extern _vpaes_ctr32_encrypt_blocks + +.p2align 4 +_vpaes_ctr32_encrypt_blocks: + +_CET_ENDBR + + xchgq %rcx,%rdx + testq %rcx,%rcx + jz L$ctr32_abort + movdqu (%r8),%xmm0 + movdqa L$ctr_add_one(%rip),%xmm8 + subq %rdi,%rsi + call _vpaes_preheat + movdqa %xmm0,%xmm6 + pshufb L$rev_ctr(%rip),%xmm6 + + testq $1,%rcx + jz L$ctr32_prep_loop + + + + movdqu (%rdi),%xmm7 + call _vpaes_encrypt_core + pxor %xmm7,%xmm0 + paddd %xmm8,%xmm6 + movdqu %xmm0,(%rsi,%rdi,1) + subq $1,%rcx + leaq 16(%rdi),%rdi + jz L$ctr32_done + +L$ctr32_prep_loop: + + + movdqa %xmm6,%xmm14 + movdqa %xmm6,%xmm15 + paddd %xmm8,%xmm15 + +L$ctr32_loop: + movdqa L$rev_ctr(%rip),%xmm1 + movdqa %xmm14,%xmm0 + movdqa %xmm15,%xmm6 +.byte 102,15,56,0,193 +.byte 102,15,56,0,241 + call _vpaes_encrypt_core_2x + movdqu (%rdi),%xmm1 + movdqu 16(%rdi),%xmm2 + movdqa L$ctr_add_two(%rip),%xmm3 + pxor %xmm1,%xmm0 + pxor %xmm2,%xmm6 + paddd %xmm3,%xmm14 + paddd %xmm3,%xmm15 + movdqu %xmm0,(%rsi,%rdi,1) + movdqu %xmm6,16(%rsi,%rdi,1) + subq $2,%rcx + leaq 32(%rdi),%rdi + jnz L$ctr32_loop + +L$ctr32_done: +L$ctr32_abort: + ret + + + + + + + + + +.p2align 4 +_vpaes_preheat: + + leaq L$k_s0F(%rip),%r10 + movdqa -32(%r10),%xmm10 + movdqa -16(%r10),%xmm11 + movdqa 0(%r10),%xmm9 + movdqa 48(%r10),%xmm13 + movdqa 64(%r10),%xmm12 + movdqa 80(%r10),%xmm15 + movdqa 96(%r10),%xmm14 + ret + + + + + + + + +.section __DATA,__const +.p2align 6 +_vpaes_consts: +L$k_inv: +.quad 0x0E05060F0D080180, 0x040703090A0B0C02 +.quad 0x01040A060F0B0780, 0x030D0E0C02050809 + +L$k_s0F: +.quad 0x0F0F0F0F0F0F0F0F, 0x0F0F0F0F0F0F0F0F + +L$k_ipt: +.quad 0xC2B2E8985A2A7000, 0xCABAE09052227808 +.quad 0x4C01307D317C4D00, 0xCD80B1FCB0FDCC81 + +L$k_sb1: +.quad 0xB19BE18FCB503E00, 0xA5DF7A6E142AF544 +.quad 0x3618D415FAE22300, 0x3BF7CCC10D2ED9EF +L$k_sb2: +.quad 0xE27A93C60B712400, 0x5EB7E955BC982FCD +.quad 0x69EB88400AE12900, 0xC2A163C8AB82234A +L$k_sbo: +.quad 0xD0D26D176FBDC700, 0x15AABF7AC502A878 +.quad 0xCFE474A55FBB6A00, 0x8E1E90D1412B35FA + +L$k_mc_forward: +.quad 0x0407060500030201, 0x0C0F0E0D080B0A09 +.quad 0x080B0A0904070605, 0x000302010C0F0E0D +.quad 0x0C0F0E0D080B0A09, 0x0407060500030201 +.quad 0x000302010C0F0E0D, 0x080B0A0904070605 + +L$k_mc_backward: +.quad 0x0605040702010003, 0x0E0D0C0F0A09080B +.quad 0x020100030E0D0C0F, 0x0A09080B06050407 +.quad 0x0E0D0C0F0A09080B, 0x0605040702010003 +.quad 0x0A09080B06050407, 0x020100030E0D0C0F + +L$k_sr: +.quad 0x0706050403020100, 0x0F0E0D0C0B0A0908 +.quad 0x030E09040F0A0500, 0x0B06010C07020D08 +.quad 0x0F060D040B020900, 0x070E050C030A0108 +.quad 0x0B0E0104070A0D00, 0x0306090C0F020508 + +L$k_rcon: +.quad 0x1F8391B9AF9DEEB6, 0x702A98084D7C7D81 + +L$k_s63: +.quad 0x5B5B5B5B5B5B5B5B, 0x5B5B5B5B5B5B5B5B + +L$k_opt: +.quad 0xFF9F4929D6B66000, 0xF7974121DEBE6808 +.quad 0x01EDBD5150BCEC00, 0xE10D5DB1B05C0CE0 + +L$k_deskew: +.quad 0x07E4A34047A4E300, 0x1DFEB95A5DBEF91A +.quad 0x5F36B5DC83EA6900, 0x2841C2ABF49D1E77 + + +L$rev_ctr: +.quad 0x0706050403020100, 0x0c0d0e0f0b0a0908 + + +L$ctr_add_one: +.quad 0x0000000000000000, 0x0000000100000000 +L$ctr_add_two: +.quad 0x0000000000000000, 0x0000000200000000 + +.byte 86,101,99,116,111,114,32,80,101,114,109,117,116,97,116,105,111,110,32,65,69,83,32,102,111,114,32,120,56,54,95,54,52,47,83,83,83,69,51,44,32,77,105,107,101,32,72,97,109,98,117,114,103,32,40,83,116,97,110,102,111,114,100,32,85,110,105,118,101,114,115,105,116,121,41,0 +.p2align 6 + +.text +#endif diff --git a/http/vendor/ring/pregenerated/vpaes-x86_64-nasm.asm b/http/vendor/ring/pregenerated/vpaes-x86_64-nasm.asm new file mode 100644 index 0000000..c7e6eed --- /dev/null +++ b/http/vendor/ring/pregenerated/vpaes-x86_64-nasm.asm @@ -0,0 +1,940 @@ +; This file is generated from a similarly-named Perl script in the BoringSSL +; source tree. Do not edit by hand. + +%ifidn __OUTPUT_FORMAT__, win64 +default rel +%define XMMWORD +%define YMMWORD +%define ZMMWORD +%define _CET_ENDBR + +%include "ring_core_generated/prefix_symbols_nasm.inc" +section .text code align=64 + + + + + + + + + + + + + + + + + + +ALIGN 16 +_vpaes_encrypt_core: + + mov r9,rdx + mov r11,16 + mov eax,DWORD[240+rdx] + movdqa xmm1,xmm9 + movdqa xmm2,XMMWORD[$L$k_ipt] + pandn xmm1,xmm0 + movdqu xmm5,XMMWORD[r9] + psrld xmm1,4 + pand xmm0,xmm9 +DB 102,15,56,0,208 + movdqa xmm0,XMMWORD[(($L$k_ipt+16))] +DB 102,15,56,0,193 + pxor xmm2,xmm5 + add r9,16 + pxor xmm0,xmm2 + lea r10,[$L$k_mc_backward] + jmp NEAR $L$enc_entry + +ALIGN 16 +$L$enc_loop: + + movdqa xmm4,xmm13 + movdqa xmm0,xmm12 +DB 102,15,56,0,226 +DB 102,15,56,0,195 + pxor xmm4,xmm5 + movdqa xmm5,xmm15 + pxor xmm0,xmm4 + movdqa xmm1,XMMWORD[((-64))+r10*1+r11] +DB 102,15,56,0,234 + movdqa xmm4,XMMWORD[r10*1+r11] + movdqa xmm2,xmm14 +DB 102,15,56,0,211 + movdqa xmm3,xmm0 + pxor xmm2,xmm5 +DB 102,15,56,0,193 + add r9,16 + pxor xmm0,xmm2 +DB 102,15,56,0,220 + add r11,16 + pxor xmm3,xmm0 +DB 102,15,56,0,193 + and r11,0x30 + sub rax,1 + pxor xmm0,xmm3 + +$L$enc_entry: + + movdqa xmm1,xmm9 + movdqa xmm5,xmm11 + pandn xmm1,xmm0 + psrld xmm1,4 + pand xmm0,xmm9 +DB 102,15,56,0,232 + movdqa xmm3,xmm10 + pxor xmm0,xmm1 +DB 102,15,56,0,217 + movdqa xmm4,xmm10 + pxor xmm3,xmm5 +DB 102,15,56,0,224 + movdqa xmm2,xmm10 + pxor xmm4,xmm5 +DB 102,15,56,0,211 + movdqa xmm3,xmm10 + pxor xmm2,xmm0 +DB 102,15,56,0,220 + movdqu xmm5,XMMWORD[r9] + pxor xmm3,xmm1 + jnz NEAR $L$enc_loop + + + movdqa xmm4,XMMWORD[((-96))+r10] + movdqa xmm0,XMMWORD[((-80))+r10] +DB 102,15,56,0,226 + pxor xmm4,xmm5 +DB 102,15,56,0,195 + movdqa xmm1,XMMWORD[64+r10*1+r11] + pxor xmm0,xmm4 +DB 102,15,56,0,193 + ret + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +ALIGN 16 +_vpaes_encrypt_core_2x: + + mov r9,rdx + mov r11,16 + mov eax,DWORD[240+rdx] + movdqa xmm1,xmm9 + movdqa xmm7,xmm9 + movdqa xmm2,XMMWORD[$L$k_ipt] + movdqa xmm8,xmm2 + pandn xmm1,xmm0 + pandn xmm7,xmm6 + movdqu xmm5,XMMWORD[r9] + + psrld xmm1,4 + psrld xmm7,4 + pand xmm0,xmm9 + pand xmm6,xmm9 +DB 102,15,56,0,208 +DB 102,68,15,56,0,198 + movdqa xmm0,XMMWORD[(($L$k_ipt+16))] + movdqa xmm6,xmm0 +DB 102,15,56,0,193 +DB 102,15,56,0,247 + pxor xmm2,xmm5 + pxor xmm8,xmm5 + add r9,16 + pxor xmm0,xmm2 + pxor xmm6,xmm8 + lea r10,[$L$k_mc_backward] + jmp NEAR $L$enc2x_entry + +ALIGN 16 +$L$enc2x_loop: + + movdqa xmm4,XMMWORD[$L$k_sb1] + movdqa xmm0,XMMWORD[(($L$k_sb1+16))] + movdqa xmm12,xmm4 + movdqa xmm6,xmm0 +DB 102,15,56,0,226 +DB 102,69,15,56,0,224 +DB 102,15,56,0,195 +DB 102,65,15,56,0,243 + pxor xmm4,xmm5 + pxor xmm12,xmm5 + movdqa xmm5,XMMWORD[$L$k_sb2] + movdqa xmm13,xmm5 + pxor xmm0,xmm4 + pxor xmm6,xmm12 + movdqa xmm1,XMMWORD[((-64))+r10*1+r11] + +DB 102,15,56,0,234 +DB 102,69,15,56,0,232 + movdqa xmm4,XMMWORD[r10*1+r11] + + movdqa xmm2,XMMWORD[(($L$k_sb2+16))] + movdqa xmm8,xmm2 +DB 102,15,56,0,211 +DB 102,69,15,56,0,195 + movdqa xmm3,xmm0 + movdqa xmm11,xmm6 + pxor xmm2,xmm5 + pxor xmm8,xmm13 +DB 102,15,56,0,193 +DB 102,15,56,0,241 + add r9,16 + pxor xmm0,xmm2 + pxor xmm6,xmm8 +DB 102,15,56,0,220 +DB 102,68,15,56,0,220 + add r11,16 + pxor xmm3,xmm0 + pxor xmm11,xmm6 +DB 102,15,56,0,193 +DB 102,15,56,0,241 + and r11,0x30 + sub rax,1 + pxor xmm0,xmm3 + pxor xmm6,xmm11 + +$L$enc2x_entry: + + movdqa xmm1,xmm9 + movdqa xmm7,xmm9 + movdqa xmm5,XMMWORD[(($L$k_inv+16))] + movdqa xmm13,xmm5 + pandn xmm1,xmm0 + pandn xmm7,xmm6 + psrld xmm1,4 + psrld xmm7,4 + pand xmm0,xmm9 + pand xmm6,xmm9 +DB 102,15,56,0,232 +DB 102,68,15,56,0,238 + movdqa xmm3,xmm10 + movdqa xmm11,xmm10 + pxor xmm0,xmm1 + pxor xmm6,xmm7 +DB 102,15,56,0,217 +DB 102,68,15,56,0,223 + movdqa xmm4,xmm10 + movdqa xmm12,xmm10 + pxor xmm3,xmm5 + pxor xmm11,xmm13 +DB 102,15,56,0,224 +DB 102,68,15,56,0,230 + movdqa xmm2,xmm10 + movdqa xmm8,xmm10 + pxor xmm4,xmm5 + pxor xmm12,xmm13 +DB 102,15,56,0,211 +DB 102,69,15,56,0,195 + movdqa xmm3,xmm10 + movdqa xmm11,xmm10 + pxor xmm2,xmm0 + pxor xmm8,xmm6 +DB 102,15,56,0,220 +DB 102,69,15,56,0,220 + movdqu xmm5,XMMWORD[r9] + + pxor xmm3,xmm1 + pxor xmm11,xmm7 + jnz NEAR $L$enc2x_loop + + + movdqa xmm4,XMMWORD[((-96))+r10] + movdqa xmm0,XMMWORD[((-80))+r10] + movdqa xmm12,xmm4 + movdqa xmm6,xmm0 +DB 102,15,56,0,226 +DB 102,69,15,56,0,224 + pxor xmm4,xmm5 + pxor xmm12,xmm5 +DB 102,15,56,0,195 +DB 102,65,15,56,0,243 + movdqa xmm1,XMMWORD[64+r10*1+r11] + + pxor xmm0,xmm4 + pxor xmm6,xmm12 +DB 102,15,56,0,193 +DB 102,15,56,0,241 + ret + + + + + + + + + +ALIGN 16 +_vpaes_schedule_core: + + + + + + + call _vpaes_preheat + movdqa xmm8,XMMWORD[$L$k_rcon] + movdqu xmm0,XMMWORD[rdi] + + + movdqa xmm3,xmm0 + lea r11,[$L$k_ipt] + call _vpaes_schedule_transform + movdqa xmm7,xmm0 + + lea r10,[$L$k_sr] + + + movdqu XMMWORD[rdx],xmm0 + +$L$schedule_go: + cmp esi,192 + ja NEAR $L$schedule_256 + + + + + + + + + + + +$L$schedule_128: + mov esi,10 + +$L$oop_schedule_128: + call _vpaes_schedule_round + dec rsi + jz NEAR $L$schedule_mangle_last + call _vpaes_schedule_mangle + jmp NEAR $L$oop_schedule_128 + + + + + + + + + + + +ALIGN 16 +$L$schedule_256: + movdqu xmm0,XMMWORD[16+rdi] + call _vpaes_schedule_transform + mov esi,7 + +$L$oop_schedule_256: + call _vpaes_schedule_mangle + movdqa xmm6,xmm0 + + + call _vpaes_schedule_round + dec rsi + jz NEAR $L$schedule_mangle_last + call _vpaes_schedule_mangle + + + pshufd xmm0,xmm0,0xFF + movdqa xmm5,xmm7 + movdqa xmm7,xmm6 + call _vpaes_schedule_low_round + movdqa xmm7,xmm5 + + jmp NEAR $L$oop_schedule_256 + + + + + + + + + + + + +ALIGN 16 +$L$schedule_mangle_last: + + lea r11,[$L$k_deskew] + + + movdqa xmm1,XMMWORD[r10*1+r8] +DB 102,15,56,0,193 + lea r11,[$L$k_opt] + add rdx,32 + +$L$schedule_mangle_last_dec: + add rdx,-16 + pxor xmm0,XMMWORD[$L$k_s63] + call _vpaes_schedule_transform + movdqu XMMWORD[rdx],xmm0 + + + pxor xmm0,xmm0 + pxor xmm1,xmm1 + pxor xmm2,xmm2 + pxor xmm3,xmm3 + pxor xmm4,xmm4 + pxor xmm5,xmm5 + pxor xmm6,xmm6 + pxor xmm7,xmm7 + ret + + + + + + + + + + + + + + + + + + + + + + +ALIGN 16 +_vpaes_schedule_round: + + + pxor xmm1,xmm1 +DB 102,65,15,58,15,200,15 +DB 102,69,15,58,15,192,15 + pxor xmm7,xmm1 + + + pshufd xmm0,xmm0,0xFF +DB 102,15,58,15,192,1 + + + + +_vpaes_schedule_low_round: + + movdqa xmm1,xmm7 + pslldq xmm7,4 + pxor xmm7,xmm1 + movdqa xmm1,xmm7 + pslldq xmm7,8 + pxor xmm7,xmm1 + pxor xmm7,XMMWORD[$L$k_s63] + + + movdqa xmm1,xmm9 + pandn xmm1,xmm0 + psrld xmm1,4 + pand xmm0,xmm9 + movdqa xmm2,xmm11 +DB 102,15,56,0,208 + pxor xmm0,xmm1 + movdqa xmm3,xmm10 +DB 102,15,56,0,217 + pxor xmm3,xmm2 + movdqa xmm4,xmm10 +DB 102,15,56,0,224 + pxor xmm4,xmm2 + movdqa xmm2,xmm10 +DB 102,15,56,0,211 + pxor xmm2,xmm0 + movdqa xmm3,xmm10 +DB 102,15,56,0,220 + pxor xmm3,xmm1 + movdqa xmm4,xmm13 +DB 102,15,56,0,226 + movdqa xmm0,xmm12 +DB 102,15,56,0,195 + pxor xmm0,xmm4 + + + pxor xmm0,xmm7 + movdqa xmm7,xmm0 + ret + + + + + + + + + + + + + +ALIGN 16 +_vpaes_schedule_transform: + + movdqa xmm1,xmm9 + pandn xmm1,xmm0 + psrld xmm1,4 + pand xmm0,xmm9 + movdqa xmm2,XMMWORD[r11] +DB 102,15,56,0,208 + movdqa xmm0,XMMWORD[16+r11] +DB 102,15,56,0,193 + pxor xmm0,xmm2 + ret + + + + + + + + + + + + + + + + + + + + + + + + + + + +ALIGN 16 +_vpaes_schedule_mangle: + + movdqa xmm4,xmm0 + movdqa xmm5,XMMWORD[$L$k_mc_forward] + + + add rdx,16 + pxor xmm4,XMMWORD[$L$k_s63] +DB 102,15,56,0,229 + movdqa xmm3,xmm4 +DB 102,15,56,0,229 + pxor xmm3,xmm4 +DB 102,15,56,0,229 + pxor xmm3,xmm4 + +$L$schedule_mangle_both: + movdqa xmm1,XMMWORD[r10*1+r8] +DB 102,15,56,0,217 + add r8,-16 + and r8,0x30 + movdqu XMMWORD[rdx],xmm3 + ret + + + + + + +global vpaes_set_encrypt_key + +ALIGN 16 +vpaes_set_encrypt_key: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_vpaes_set_encrypt_key: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + + + +_CET_ENDBR +%ifdef BORINGSSL_DISPATCH_TEST +EXTERN BORINGSSL_function_hit + mov BYTE[((BORINGSSL_function_hit+5))],1 +%endif + + lea rsp,[((-184))+rsp] + movaps XMMWORD[16+rsp],xmm6 + movaps XMMWORD[32+rsp],xmm7 + movaps XMMWORD[48+rsp],xmm8 + movaps XMMWORD[64+rsp],xmm9 + movaps XMMWORD[80+rsp],xmm10 + movaps XMMWORD[96+rsp],xmm11 + movaps XMMWORD[112+rsp],xmm12 + movaps XMMWORD[128+rsp],xmm13 + movaps XMMWORD[144+rsp],xmm14 + movaps XMMWORD[160+rsp],xmm15 +$L$enc_key_body: + mov eax,esi + shr eax,5 + add eax,5 + mov DWORD[240+rdx],eax + + mov ecx,0 + mov r8d,0x30 + call _vpaes_schedule_core + movaps xmm6,XMMWORD[16+rsp] + movaps xmm7,XMMWORD[32+rsp] + movaps xmm8,XMMWORD[48+rsp] + movaps xmm9,XMMWORD[64+rsp] + movaps xmm10,XMMWORD[80+rsp] + movaps xmm11,XMMWORD[96+rsp] + movaps xmm12,XMMWORD[112+rsp] + movaps xmm13,XMMWORD[128+rsp] + movaps xmm14,XMMWORD[144+rsp] + movaps xmm15,XMMWORD[160+rsp] + lea rsp,[184+rsp] +$L$enc_key_epilogue: + xor eax,eax + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_vpaes_set_encrypt_key: +global vpaes_ctr32_encrypt_blocks + +ALIGN 16 +vpaes_ctr32_encrypt_blocks: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_vpaes_ctr32_encrypt_blocks: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + mov rcx,r9 + mov r8,QWORD[40+rsp] + + + +_CET_ENDBR + + xchg rdx,rcx + test rcx,rcx + jz NEAR $L$ctr32_abort + lea rsp,[((-184))+rsp] + movaps XMMWORD[16+rsp],xmm6 + movaps XMMWORD[32+rsp],xmm7 + movaps XMMWORD[48+rsp],xmm8 + movaps XMMWORD[64+rsp],xmm9 + movaps XMMWORD[80+rsp],xmm10 + movaps XMMWORD[96+rsp],xmm11 + movaps XMMWORD[112+rsp],xmm12 + movaps XMMWORD[128+rsp],xmm13 + movaps XMMWORD[144+rsp],xmm14 + movaps XMMWORD[160+rsp],xmm15 +$L$ctr32_body: + movdqu xmm0,XMMWORD[r8] + movdqa xmm8,XMMWORD[$L$ctr_add_one] + sub rsi,rdi + call _vpaes_preheat + movdqa xmm6,xmm0 + pshufb xmm6,XMMWORD[$L$rev_ctr] + + test rcx,1 + jz NEAR $L$ctr32_prep_loop + + + + movdqu xmm7,XMMWORD[rdi] + call _vpaes_encrypt_core + pxor xmm0,xmm7 + paddd xmm6,xmm8 + movdqu XMMWORD[rdi*1+rsi],xmm0 + sub rcx,1 + lea rdi,[16+rdi] + jz NEAR $L$ctr32_done + +$L$ctr32_prep_loop: + + + movdqa xmm14,xmm6 + movdqa xmm15,xmm6 + paddd xmm15,xmm8 + +$L$ctr32_loop: + movdqa xmm1,XMMWORD[$L$rev_ctr] + movdqa xmm0,xmm14 + movdqa xmm6,xmm15 +DB 102,15,56,0,193 +DB 102,15,56,0,241 + call _vpaes_encrypt_core_2x + movdqu xmm1,XMMWORD[rdi] + movdqu xmm2,XMMWORD[16+rdi] + movdqa xmm3,XMMWORD[$L$ctr_add_two] + pxor xmm0,xmm1 + pxor xmm6,xmm2 + paddd xmm14,xmm3 + paddd xmm15,xmm3 + movdqu XMMWORD[rdi*1+rsi],xmm0 + movdqu XMMWORD[16+rdi*1+rsi],xmm6 + sub rcx,2 + lea rdi,[32+rdi] + jnz NEAR $L$ctr32_loop + +$L$ctr32_done: + movaps xmm6,XMMWORD[16+rsp] + movaps xmm7,XMMWORD[32+rsp] + movaps xmm8,XMMWORD[48+rsp] + movaps xmm9,XMMWORD[64+rsp] + movaps xmm10,XMMWORD[80+rsp] + movaps xmm11,XMMWORD[96+rsp] + movaps xmm12,XMMWORD[112+rsp] + movaps xmm13,XMMWORD[128+rsp] + movaps xmm14,XMMWORD[144+rsp] + movaps xmm15,XMMWORD[160+rsp] + lea rsp,[184+rsp] +$L$ctr32_epilogue: +$L$ctr32_abort: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_vpaes_ctr32_encrypt_blocks: + + + + + + + +ALIGN 16 +_vpaes_preheat: + + lea r10,[$L$k_s0F] + movdqa xmm10,XMMWORD[((-32))+r10] + movdqa xmm11,XMMWORD[((-16))+r10] + movdqa xmm9,XMMWORD[r10] + movdqa xmm13,XMMWORD[48+r10] + movdqa xmm12,XMMWORD[64+r10] + movdqa xmm15,XMMWORD[80+r10] + movdqa xmm14,XMMWORD[96+r10] + ret + + + + + + + + +section .rdata rdata align=8 +ALIGN 64 +_vpaes_consts: +$L$k_inv: + DQ 0x0E05060F0D080180,0x040703090A0B0C02 + DQ 0x01040A060F0B0780,0x030D0E0C02050809 + +$L$k_s0F: + DQ 0x0F0F0F0F0F0F0F0F,0x0F0F0F0F0F0F0F0F + +$L$k_ipt: + DQ 0xC2B2E8985A2A7000,0xCABAE09052227808 + DQ 0x4C01307D317C4D00,0xCD80B1FCB0FDCC81 + +$L$k_sb1: + DQ 0xB19BE18FCB503E00,0xA5DF7A6E142AF544 + DQ 0x3618D415FAE22300,0x3BF7CCC10D2ED9EF +$L$k_sb2: + DQ 0xE27A93C60B712400,0x5EB7E955BC982FCD + DQ 0x69EB88400AE12900,0xC2A163C8AB82234A +$L$k_sbo: + DQ 0xD0D26D176FBDC700,0x15AABF7AC502A878 + DQ 0xCFE474A55FBB6A00,0x8E1E90D1412B35FA + +$L$k_mc_forward: + DQ 0x0407060500030201,0x0C0F0E0D080B0A09 + DQ 0x080B0A0904070605,0x000302010C0F0E0D + DQ 0x0C0F0E0D080B0A09,0x0407060500030201 + DQ 0x000302010C0F0E0D,0x080B0A0904070605 + +$L$k_mc_backward: + DQ 0x0605040702010003,0x0E0D0C0F0A09080B + DQ 0x020100030E0D0C0F,0x0A09080B06050407 + DQ 0x0E0D0C0F0A09080B,0x0605040702010003 + DQ 0x0A09080B06050407,0x020100030E0D0C0F + +$L$k_sr: + DQ 0x0706050403020100,0x0F0E0D0C0B0A0908 + DQ 0x030E09040F0A0500,0x0B06010C07020D08 + DQ 0x0F060D040B020900,0x070E050C030A0108 + DQ 0x0B0E0104070A0D00,0x0306090C0F020508 + +$L$k_rcon: + DQ 0x1F8391B9AF9DEEB6,0x702A98084D7C7D81 + +$L$k_s63: + DQ 0x5B5B5B5B5B5B5B5B,0x5B5B5B5B5B5B5B5B + +$L$k_opt: + DQ 0xFF9F4929D6B66000,0xF7974121DEBE6808 + DQ 0x01EDBD5150BCEC00,0xE10D5DB1B05C0CE0 + +$L$k_deskew: + DQ 0x07E4A34047A4E300,0x1DFEB95A5DBEF91A + DQ 0x5F36B5DC83EA6900,0x2841C2ABF49D1E77 + + +$L$rev_ctr: + DQ 0x0706050403020100,0x0c0d0e0f0b0a0908 + + +$L$ctr_add_one: + DQ 0x0000000000000000,0x0000000100000000 +$L$ctr_add_two: + DQ 0x0000000000000000,0x0000000200000000 + + DB 86,101,99,116,111,114,32,80,101,114,109,117,116,97,116,105 + DB 111,110,32,65,69,83,32,102,111,114,32,120,56,54,95,54 + DB 52,47,83,83,83,69,51,44,32,77,105,107,101,32,72,97 + DB 109,98,117,114,103,32,40,83,116,97,110,102,111,114,100,32 + DB 85,110,105,118,101,114,115,105,116,121,41,0 +ALIGN 64 + +section .text + +EXTERN __imp_RtlVirtualUnwind + +ALIGN 16 +se_handler: + push rsi + push rdi + push rbx + push rbp + push r12 + push r13 + push r14 + push r15 + pushfq + sub rsp,64 + + mov rax,QWORD[120+r8] + mov rbx,QWORD[248+r8] + + mov rsi,QWORD[8+r9] + mov r11,QWORD[56+r9] + + mov r10d,DWORD[r11] + lea r10,[r10*1+rsi] + cmp rbx,r10 + jb NEAR $L$in_prologue + + mov rax,QWORD[152+r8] + + mov r10d,DWORD[4+r11] + lea r10,[r10*1+rsi] + cmp rbx,r10 + jae NEAR $L$in_prologue + + lea rsi,[16+rax] + lea rdi,[512+r8] + mov ecx,20 + DD 0xa548f3fc + lea rax,[184+rax] + +$L$in_prologue: + mov rdi,QWORD[8+rax] + mov rsi,QWORD[16+rax] + mov QWORD[152+r8],rax + mov QWORD[168+r8],rsi + mov QWORD[176+r8],rdi + + mov rdi,QWORD[40+r9] + mov rsi,r8 + mov ecx,154 + DD 0xa548f3fc + + mov rsi,r9 + xor rcx,rcx + mov rdx,QWORD[8+rsi] + mov r8,QWORD[rsi] + mov r9,QWORD[16+rsi] + mov r10,QWORD[40+rsi] + lea r11,[56+rsi] + lea r12,[24+rsi] + mov QWORD[32+rsp],r10 + mov QWORD[40+rsp],r11 + mov QWORD[48+rsp],r12 + mov QWORD[56+rsp],rcx + call QWORD[__imp_RtlVirtualUnwind] + + mov eax,1 + add rsp,64 + popfq + pop r15 + pop r14 + pop r13 + pop r12 + pop rbp + pop rbx + pop rdi + pop rsi + ret + + +section .pdata rdata align=4 +ALIGN 4 + DD $L$SEH_begin_vpaes_set_encrypt_key wrt ..imagebase + DD $L$SEH_end_vpaes_set_encrypt_key wrt ..imagebase + DD $L$SEH_info_vpaes_set_encrypt_key wrt ..imagebase + + DD $L$SEH_begin_vpaes_ctr32_encrypt_blocks wrt ..imagebase + DD $L$SEH_end_vpaes_ctr32_encrypt_blocks wrt ..imagebase + DD $L$SEH_info_vpaes_ctr32_encrypt_blocks wrt ..imagebase + +section .xdata rdata align=8 +ALIGN 8 +$L$SEH_info_vpaes_set_encrypt_key: + DB 9,0,0,0 + DD se_handler wrt ..imagebase + DD $L$enc_key_body wrt ..imagebase,$L$enc_key_epilogue wrt ..imagebase +$L$SEH_info_vpaes_ctr32_encrypt_blocks: + DB 9,0,0,0 + DD se_handler wrt ..imagebase + DD $L$ctr32_body wrt ..imagebase,$L$ctr32_epilogue wrt ..imagebase +%else +; Work around https://bugzilla.nasm.us/show_bug.cgi?id=3392738 +ret +%endif diff --git a/http/vendor/ring/pregenerated/vpaes-x86_64-nasm.o b/http/vendor/ring/pregenerated/vpaes-x86_64-nasm.o new file mode 100644 index 0000000..4b04ba3 Binary files /dev/null and b/http/vendor/ring/pregenerated/vpaes-x86_64-nasm.o differ diff --git a/http/vendor/ring/pregenerated/x86-mont-elf.S b/http/vendor/ring/pregenerated/x86-mont-elf.S new file mode 100644 index 0000000..e1923ea --- /dev/null +++ b/http/vendor/ring/pregenerated/x86-mont-elf.S @@ -0,0 +1,220 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) +.text +.globl bn_mul_mont +.hidden bn_mul_mont +.type bn_mul_mont,@function +.align 16 +bn_mul_mont: +.L_bn_mul_mont_begin: + pushl %ebp + pushl %ebx + pushl %esi + pushl %edi + xorl %eax,%eax + movl 40(%esp),%edi + leal 20(%esp),%esi + leal 24(%esp),%edx + addl $2,%edi + negl %edi + leal -32(%esp,%edi,4),%ebp + negl %edi + movl %ebp,%eax + subl %edx,%eax + andl $2047,%eax + subl %eax,%ebp + xorl %ebp,%edx + andl $2048,%edx + xorl $2048,%edx + subl %edx,%ebp + andl $-64,%ebp + movl %esp,%eax + subl %ebp,%eax + andl $-4096,%eax + movl %esp,%edx + leal (%ebp,%eax,1),%esp + movl (%esp),%eax + cmpl %ebp,%esp + ja .L000page_walk + jmp .L001page_walk_done +.align 16 +.L000page_walk: + leal -4096(%esp),%esp + movl (%esp),%eax + cmpl %ebp,%esp + ja .L000page_walk +.L001page_walk_done: + movl (%esi),%eax + movl 4(%esi),%ebx + movl 8(%esi),%ecx + movl 12(%esi),%ebp + movl 16(%esi),%esi + movl (%esi),%esi + movl %eax,4(%esp) + movl %ebx,8(%esp) + movl %ecx,12(%esp) + movl %ebp,16(%esp) + movl %esi,20(%esp) + leal -3(%edi),%ebx + movl %edx,24(%esp) + movl $-1,%eax + movd %eax,%mm7 + movl 8(%esp),%esi + movl 12(%esp),%edi + movl 16(%esp),%ebp + xorl %edx,%edx + xorl %ecx,%ecx + movd (%edi),%mm4 + movd (%esi),%mm5 + movd (%ebp),%mm3 + pmuludq %mm4,%mm5 + movq %mm5,%mm2 + movq %mm5,%mm0 + pand %mm7,%mm0 + pmuludq 20(%esp),%mm5 + pmuludq %mm5,%mm3 + paddq %mm0,%mm3 + movd 4(%ebp),%mm1 + movd 4(%esi),%mm0 + psrlq $32,%mm2 + psrlq $32,%mm3 + incl %ecx +.align 16 +.L0021st: + pmuludq %mm4,%mm0 + pmuludq %mm5,%mm1 + paddq %mm0,%mm2 + paddq %mm1,%mm3 + movq %mm2,%mm0 + pand %mm7,%mm0 + movd 4(%ebp,%ecx,4),%mm1 + paddq %mm0,%mm3 + movd 4(%esi,%ecx,4),%mm0 + psrlq $32,%mm2 + movd %mm3,28(%esp,%ecx,4) + psrlq $32,%mm3 + leal 1(%ecx),%ecx + cmpl %ebx,%ecx + jl .L0021st + pmuludq %mm4,%mm0 + pmuludq %mm5,%mm1 + paddq %mm0,%mm2 + paddq %mm1,%mm3 + movq %mm2,%mm0 + pand %mm7,%mm0 + paddq %mm0,%mm3 + movd %mm3,28(%esp,%ecx,4) + psrlq $32,%mm2 + psrlq $32,%mm3 + paddq %mm2,%mm3 + movq %mm3,32(%esp,%ebx,4) + incl %edx +.L003outer: + xorl %ecx,%ecx + movd (%edi,%edx,4),%mm4 + movd (%esi),%mm5 + movd 32(%esp),%mm6 + movd (%ebp),%mm3 + pmuludq %mm4,%mm5 + paddq %mm6,%mm5 + movq %mm5,%mm0 + movq %mm5,%mm2 + pand %mm7,%mm0 + pmuludq 20(%esp),%mm5 + pmuludq %mm5,%mm3 + paddq %mm0,%mm3 + movd 36(%esp),%mm6 + movd 4(%ebp),%mm1 + movd 4(%esi),%mm0 + psrlq $32,%mm2 + psrlq $32,%mm3 + paddq %mm6,%mm2 + incl %ecx + decl %ebx +.L004inner: + pmuludq %mm4,%mm0 + pmuludq %mm5,%mm1 + paddq %mm0,%mm2 + paddq %mm1,%mm3 + movq %mm2,%mm0 + movd 36(%esp,%ecx,4),%mm6 + pand %mm7,%mm0 + movd 4(%ebp,%ecx,4),%mm1 + paddq %mm0,%mm3 + movd 4(%esi,%ecx,4),%mm0 + psrlq $32,%mm2 + movd %mm3,28(%esp,%ecx,4) + psrlq $32,%mm3 + paddq %mm6,%mm2 + decl %ebx + leal 1(%ecx),%ecx + jnz .L004inner + movl %ecx,%ebx + pmuludq %mm4,%mm0 + pmuludq %mm5,%mm1 + paddq %mm0,%mm2 + paddq %mm1,%mm3 + movq %mm2,%mm0 + pand %mm7,%mm0 + paddq %mm0,%mm3 + movd %mm3,28(%esp,%ecx,4) + psrlq $32,%mm2 + psrlq $32,%mm3 + movd 36(%esp,%ebx,4),%mm6 + paddq %mm2,%mm3 + paddq %mm6,%mm3 + movq %mm3,32(%esp,%ebx,4) + leal 1(%edx),%edx + cmpl %ebx,%edx + jle .L003outer + emms + jmp .L005common_tail +.align 16 +.L005common_tail: + movl 16(%esp),%ebp + movl 4(%esp),%edi + leal 32(%esp),%esi + movl (%esi),%eax + movl %ebx,%ecx + xorl %edx,%edx +.align 16 +.L006sub: + sbbl (%ebp,%edx,4),%eax + movl %eax,(%edi,%edx,4) + decl %ecx + movl 4(%esi,%edx,4),%eax + leal 1(%edx),%edx + jge .L006sub + sbbl $0,%eax + movl $-1,%edx + xorl %eax,%edx + jmp .L007copy +.align 16 +.L007copy: + movl 32(%esp,%ebx,4),%esi + movl (%edi,%ebx,4),%ebp + movl %ecx,32(%esp,%ebx,4) + andl %eax,%esi + andl %edx,%ebp + orl %esi,%ebp + movl %ebp,(%edi,%ebx,4) + decl %ebx + jge .L007copy + movl 24(%esp),%esp + movl $1,%eax + popl %edi + popl %esi + popl %ebx + popl %ebp + ret +.size bn_mul_mont,.-.L_bn_mul_mont_begin +.byte 77,111,110,116,103,111,109,101,114,121,32,77,117,108,116,105 +.byte 112,108,105,99,97,116,105,111,110,32,102,111,114,32,120,56 +.byte 54,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121 +.byte 32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46 +.byte 111,114,103,62,0 +#endif // !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86) && defined(__ELF__) diff --git a/http/vendor/ring/pregenerated/x86-mont-win32n.asm b/http/vendor/ring/pregenerated/x86-mont-win32n.asm new file mode 100644 index 0000000..fe0cc97 --- /dev/null +++ b/http/vendor/ring/pregenerated/x86-mont-win32n.asm @@ -0,0 +1,226 @@ +; This file is generated from a similarly-named Perl script in the BoringSSL +; source tree. Do not edit by hand. + +%include "ring_core_generated/prefix_symbols_nasm.inc" +%ifidn __OUTPUT_FORMAT__, win32 +%ifidn __OUTPUT_FORMAT__,obj +section code use32 class=code align=64 +%elifidn __OUTPUT_FORMAT__,win32 +$@feat.00 equ 1 +section .text code align=64 +%else +section .text code +%endif +global _bn_mul_mont +align 16 +_bn_mul_mont: +L$_bn_mul_mont_begin: + push ebp + push ebx + push esi + push edi + xor eax,eax + mov edi,DWORD [40+esp] + lea esi,[20+esp] + lea edx,[24+esp] + add edi,2 + neg edi + lea ebp,[edi*4+esp-32] + neg edi + mov eax,ebp + sub eax,edx + and eax,2047 + sub ebp,eax + xor edx,ebp + and edx,2048 + xor edx,2048 + sub ebp,edx + and ebp,-64 + mov eax,esp + sub eax,ebp + and eax,-4096 + mov edx,esp + lea esp,[eax*1+ebp] + mov eax,DWORD [esp] + cmp esp,ebp + ja NEAR L$000page_walk + jmp NEAR L$001page_walk_done +align 16 +L$000page_walk: + lea esp,[esp-4096] + mov eax,DWORD [esp] + cmp esp,ebp + ja NEAR L$000page_walk +L$001page_walk_done: + mov eax,DWORD [esi] + mov ebx,DWORD [4+esi] + mov ecx,DWORD [8+esi] + mov ebp,DWORD [12+esi] + mov esi,DWORD [16+esi] + mov esi,DWORD [esi] + mov DWORD [4+esp],eax + mov DWORD [8+esp],ebx + mov DWORD [12+esp],ecx + mov DWORD [16+esp],ebp + mov DWORD [20+esp],esi + lea ebx,[edi-3] + mov DWORD [24+esp],edx + mov eax,-1 + movd mm7,eax + mov esi,DWORD [8+esp] + mov edi,DWORD [12+esp] + mov ebp,DWORD [16+esp] + xor edx,edx + xor ecx,ecx + movd mm4,DWORD [edi] + movd mm5,DWORD [esi] + movd mm3,DWORD [ebp] + pmuludq mm5,mm4 + movq mm2,mm5 + movq mm0,mm5 + pand mm0,mm7 + pmuludq mm5,[20+esp] + pmuludq mm3,mm5 + paddq mm3,mm0 + movd mm1,DWORD [4+ebp] + movd mm0,DWORD [4+esi] + psrlq mm2,32 + psrlq mm3,32 + inc ecx +align 16 +L$0021st: + pmuludq mm0,mm4 + pmuludq mm1,mm5 + paddq mm2,mm0 + paddq mm3,mm1 + movq mm0,mm2 + pand mm0,mm7 + movd mm1,DWORD [4+ecx*4+ebp] + paddq mm3,mm0 + movd mm0,DWORD [4+ecx*4+esi] + psrlq mm2,32 + movd DWORD [28+ecx*4+esp],mm3 + psrlq mm3,32 + lea ecx,[1+ecx] + cmp ecx,ebx + jl NEAR L$0021st + pmuludq mm0,mm4 + pmuludq mm1,mm5 + paddq mm2,mm0 + paddq mm3,mm1 + movq mm0,mm2 + pand mm0,mm7 + paddq mm3,mm0 + movd DWORD [28+ecx*4+esp],mm3 + psrlq mm2,32 + psrlq mm3,32 + paddq mm3,mm2 + movq [32+ebx*4+esp],mm3 + inc edx +L$003outer: + xor ecx,ecx + movd mm4,DWORD [edx*4+edi] + movd mm5,DWORD [esi] + movd mm6,DWORD [32+esp] + movd mm3,DWORD [ebp] + pmuludq mm5,mm4 + paddq mm5,mm6 + movq mm0,mm5 + movq mm2,mm5 + pand mm0,mm7 + pmuludq mm5,[20+esp] + pmuludq mm3,mm5 + paddq mm3,mm0 + movd mm6,DWORD [36+esp] + movd mm1,DWORD [4+ebp] + movd mm0,DWORD [4+esi] + psrlq mm2,32 + psrlq mm3,32 + paddq mm2,mm6 + inc ecx + dec ebx +L$004inner: + pmuludq mm0,mm4 + pmuludq mm1,mm5 + paddq mm2,mm0 + paddq mm3,mm1 + movq mm0,mm2 + movd mm6,DWORD [36+ecx*4+esp] + pand mm0,mm7 + movd mm1,DWORD [4+ecx*4+ebp] + paddq mm3,mm0 + movd mm0,DWORD [4+ecx*4+esi] + psrlq mm2,32 + movd DWORD [28+ecx*4+esp],mm3 + psrlq mm3,32 + paddq mm2,mm6 + dec ebx + lea ecx,[1+ecx] + jnz NEAR L$004inner + mov ebx,ecx + pmuludq mm0,mm4 + pmuludq mm1,mm5 + paddq mm2,mm0 + paddq mm3,mm1 + movq mm0,mm2 + pand mm0,mm7 + paddq mm3,mm0 + movd DWORD [28+ecx*4+esp],mm3 + psrlq mm2,32 + psrlq mm3,32 + movd mm6,DWORD [36+ebx*4+esp] + paddq mm3,mm2 + paddq mm3,mm6 + movq [32+ebx*4+esp],mm3 + lea edx,[1+edx] + cmp edx,ebx + jle NEAR L$003outer + emms + jmp NEAR L$005common_tail +align 16 +L$005common_tail: + mov ebp,DWORD [16+esp] + mov edi,DWORD [4+esp] + lea esi,[32+esp] + mov eax,DWORD [esi] + mov ecx,ebx + xor edx,edx +align 16 +L$006sub: + sbb eax,DWORD [edx*4+ebp] + mov DWORD [edx*4+edi],eax + dec ecx + mov eax,DWORD [4+edx*4+esi] + lea edx,[1+edx] + jge NEAR L$006sub + sbb eax,0 + mov edx,-1 + xor edx,eax + jmp NEAR L$007copy +align 16 +L$007copy: + mov esi,DWORD [32+ebx*4+esp] + mov ebp,DWORD [ebx*4+edi] + mov DWORD [32+ebx*4+esp],ecx + and esi,eax + and ebp,edx + or ebp,esi + mov DWORD [ebx*4+edi],ebp + dec ebx + jge NEAR L$007copy + mov esp,DWORD [24+esp] + mov eax,1 + pop edi + pop esi + pop ebx + pop ebp + ret +db 77,111,110,116,103,111,109,101,114,121,32,77,117,108,116,105 +db 112,108,105,99,97,116,105,111,110,32,102,111,114,32,120,56 +db 54,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121 +db 32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46 +db 111,114,103,62,0 +%else +; Work around https://bugzilla.nasm.us/show_bug.cgi?id=3392738 +ret +%endif diff --git a/http/vendor/ring/pregenerated/x86-mont-win32n.o b/http/vendor/ring/pregenerated/x86-mont-win32n.o new file mode 100644 index 0000000..9d1b72b Binary files /dev/null and b/http/vendor/ring/pregenerated/x86-mont-win32n.o differ diff --git a/http/vendor/ring/pregenerated/x86_64-mont-elf.S b/http/vendor/ring/pregenerated/x86_64-mont-elf.S new file mode 100644 index 0000000..01888e7 --- /dev/null +++ b/http/vendor/ring/pregenerated/x86_64-mont-elf.S @@ -0,0 +1,1237 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__) +.text + +.globl bn_mul_mont_nohw +.hidden bn_mul_mont_nohw +.type bn_mul_mont_nohw,@function +.align 16 +bn_mul_mont_nohw: +.cfi_startproc +_CET_ENDBR + movl %r9d,%r9d + movq %rsp,%rax +.cfi_def_cfa_register %rax + pushq %rbx +.cfi_offset %rbx,-16 + pushq %rbp +.cfi_offset %rbp,-24 + pushq %r12 +.cfi_offset %r12,-32 + pushq %r13 +.cfi_offset %r13,-40 + pushq %r14 +.cfi_offset %r14,-48 + pushq %r15 +.cfi_offset %r15,-56 + + negq %r9 + movq %rsp,%r11 + leaq -16(%rsp,%r9,8),%r10 + negq %r9 + andq $-1024,%r10 + + + + + + + + + + subq %r10,%r11 + andq $-4096,%r11 + leaq (%r10,%r11,1),%rsp + movq (%rsp),%r11 + cmpq %r10,%rsp + ja .Lmul_page_walk + jmp .Lmul_page_walk_done + +.align 16 +.Lmul_page_walk: + leaq -4096(%rsp),%rsp + movq (%rsp),%r11 + cmpq %r10,%rsp + ja .Lmul_page_walk +.Lmul_page_walk_done: + + movq %rax,8(%rsp,%r9,8) +.cfi_escape 0x0f,0x0a,0x77,0x08,0x79,0x00,0x38,0x1e,0x22,0x06,0x23,0x08 +.Lmul_body: + movq %rdx,%r12 + movq (%r8),%r8 + movq (%r12),%rbx + movq (%rsi),%rax + + xorq %r14,%r14 + xorq %r15,%r15 + + movq %r8,%rbp + mulq %rbx + movq %rax,%r10 + movq (%rcx),%rax + + imulq %r10,%rbp + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r10 + movq 8(%rsi),%rax + adcq $0,%rdx + movq %rdx,%r13 + + leaq 1(%r15),%r15 + jmp .L1st_enter + +.align 16 +.L1st: + addq %rax,%r13 + movq (%rsi,%r15,8),%rax + adcq $0,%rdx + addq %r11,%r13 + movq %r10,%r11 + adcq $0,%rdx + movq %r13,-16(%rsp,%r15,8) + movq %rdx,%r13 + +.L1st_enter: + mulq %rbx + addq %rax,%r11 + movq (%rcx,%r15,8),%rax + adcq $0,%rdx + leaq 1(%r15),%r15 + movq %rdx,%r10 + + mulq %rbp + cmpq %r9,%r15 + jne .L1st + + addq %rax,%r13 + movq (%rsi),%rax + adcq $0,%rdx + addq %r11,%r13 + adcq $0,%rdx + movq %r13,-16(%rsp,%r15,8) + movq %rdx,%r13 + movq %r10,%r11 + + xorq %rdx,%rdx + addq %r11,%r13 + adcq $0,%rdx + movq %r13,-8(%rsp,%r9,8) + movq %rdx,(%rsp,%r9,8) + + leaq 1(%r14),%r14 + jmp .Louter +.align 16 +.Louter: + movq (%r12,%r14,8),%rbx + xorq %r15,%r15 + movq %r8,%rbp + movq (%rsp),%r10 + mulq %rbx + addq %rax,%r10 + movq (%rcx),%rax + adcq $0,%rdx + + imulq %r10,%rbp + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r10 + movq 8(%rsi),%rax + adcq $0,%rdx + movq 8(%rsp),%r10 + movq %rdx,%r13 + + leaq 1(%r15),%r15 + jmp .Linner_enter + +.align 16 +.Linner: + addq %rax,%r13 + movq (%rsi,%r15,8),%rax + adcq $0,%rdx + addq %r10,%r13 + movq (%rsp,%r15,8),%r10 + adcq $0,%rdx + movq %r13,-16(%rsp,%r15,8) + movq %rdx,%r13 + +.Linner_enter: + mulq %rbx + addq %rax,%r11 + movq (%rcx,%r15,8),%rax + adcq $0,%rdx + addq %r11,%r10 + movq %rdx,%r11 + adcq $0,%r11 + leaq 1(%r15),%r15 + + mulq %rbp + cmpq %r9,%r15 + jne .Linner + + addq %rax,%r13 + movq (%rsi),%rax + adcq $0,%rdx + addq %r10,%r13 + movq (%rsp,%r15,8),%r10 + adcq $0,%rdx + movq %r13,-16(%rsp,%r15,8) + movq %rdx,%r13 + + xorq %rdx,%rdx + addq %r11,%r13 + adcq $0,%rdx + addq %r10,%r13 + adcq $0,%rdx + movq %r13,-8(%rsp,%r9,8) + movq %rdx,(%rsp,%r9,8) + + leaq 1(%r14),%r14 + cmpq %r9,%r14 + jb .Louter + + xorq %r14,%r14 + movq (%rsp),%rax + movq %r9,%r15 + +.align 16 +.Lsub: sbbq (%rcx,%r14,8),%rax + movq %rax,(%rdi,%r14,8) + movq 8(%rsp,%r14,8),%rax + leaq 1(%r14),%r14 + decq %r15 + jnz .Lsub + + sbbq $0,%rax + movq $-1,%rbx + xorq %rax,%rbx + xorq %r14,%r14 + movq %r9,%r15 + +.Lcopy: + movq (%rdi,%r14,8),%rcx + movq (%rsp,%r14,8),%rdx + andq %rbx,%rcx + andq %rax,%rdx + movq %r9,(%rsp,%r14,8) + orq %rcx,%rdx + movq %rdx,(%rdi,%r14,8) + leaq 1(%r14),%r14 + subq $1,%r15 + jnz .Lcopy + + movq 8(%rsp,%r9,8),%rsi +.cfi_def_cfa %rsi,8 + movq $1,%rax + movq -48(%rsi),%r15 +.cfi_restore %r15 + movq -40(%rsi),%r14 +.cfi_restore %r14 + movq -32(%rsi),%r13 +.cfi_restore %r13 + movq -24(%rsi),%r12 +.cfi_restore %r12 + movq -16(%rsi),%rbp +.cfi_restore %rbp + movq -8(%rsi),%rbx +.cfi_restore %rbx + leaq (%rsi),%rsp +.cfi_def_cfa_register %rsp +.Lmul_epilogue: + ret +.cfi_endproc +.size bn_mul_mont_nohw,.-bn_mul_mont_nohw +.globl bn_mul4x_mont +.hidden bn_mul4x_mont +.type bn_mul4x_mont,@function +.align 16 +bn_mul4x_mont: +.cfi_startproc +_CET_ENDBR + movl %r9d,%r9d + movq %rsp,%rax +.cfi_def_cfa_register %rax + pushq %rbx +.cfi_offset %rbx,-16 + pushq %rbp +.cfi_offset %rbp,-24 + pushq %r12 +.cfi_offset %r12,-32 + pushq %r13 +.cfi_offset %r13,-40 + pushq %r14 +.cfi_offset %r14,-48 + pushq %r15 +.cfi_offset %r15,-56 + + negq %r9 + movq %rsp,%r11 + leaq -32(%rsp,%r9,8),%r10 + negq %r9 + andq $-1024,%r10 + + subq %r10,%r11 + andq $-4096,%r11 + leaq (%r10,%r11,1),%rsp + movq (%rsp),%r11 + cmpq %r10,%rsp + ja .Lmul4x_page_walk + jmp .Lmul4x_page_walk_done + +.Lmul4x_page_walk: + leaq -4096(%rsp),%rsp + movq (%rsp),%r11 + cmpq %r10,%rsp + ja .Lmul4x_page_walk +.Lmul4x_page_walk_done: + + movq %rax,8(%rsp,%r9,8) +.cfi_escape 0x0f,0x0a,0x77,0x08,0x79,0x00,0x38,0x1e,0x22,0x06,0x23,0x08 +.Lmul4x_body: + movq %rdi,16(%rsp,%r9,8) + movq %rdx,%r12 + movq (%r8),%r8 + movq (%r12),%rbx + movq (%rsi),%rax + + xorq %r14,%r14 + xorq %r15,%r15 + + movq %r8,%rbp + mulq %rbx + movq %rax,%r10 + movq (%rcx),%rax + + imulq %r10,%rbp + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r10 + movq 8(%rsi),%rax + adcq $0,%rdx + movq %rdx,%rdi + + mulq %rbx + addq %rax,%r11 + movq 8(%rcx),%rax + adcq $0,%rdx + movq %rdx,%r10 + + mulq %rbp + addq %rax,%rdi + movq 16(%rsi),%rax + adcq $0,%rdx + addq %r11,%rdi + leaq 4(%r15),%r15 + adcq $0,%rdx + movq %rdi,(%rsp) + movq %rdx,%r13 + jmp .L1st4x +.align 16 +.L1st4x: + mulq %rbx + addq %rax,%r10 + movq -16(%rcx,%r15,8),%rax + adcq $0,%rdx + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r13 + movq -8(%rsi,%r15,8),%rax + adcq $0,%rdx + addq %r10,%r13 + adcq $0,%rdx + movq %r13,-24(%rsp,%r15,8) + movq %rdx,%rdi + + mulq %rbx + addq %rax,%r11 + movq -8(%rcx,%r15,8),%rax + adcq $0,%rdx + movq %rdx,%r10 + + mulq %rbp + addq %rax,%rdi + movq (%rsi,%r15,8),%rax + adcq $0,%rdx + addq %r11,%rdi + adcq $0,%rdx + movq %rdi,-16(%rsp,%r15,8) + movq %rdx,%r13 + + mulq %rbx + addq %rax,%r10 + movq (%rcx,%r15,8),%rax + adcq $0,%rdx + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r13 + movq 8(%rsi,%r15,8),%rax + adcq $0,%rdx + addq %r10,%r13 + adcq $0,%rdx + movq %r13,-8(%rsp,%r15,8) + movq %rdx,%rdi + + mulq %rbx + addq %rax,%r11 + movq 8(%rcx,%r15,8),%rax + adcq $0,%rdx + leaq 4(%r15),%r15 + movq %rdx,%r10 + + mulq %rbp + addq %rax,%rdi + movq -16(%rsi,%r15,8),%rax + adcq $0,%rdx + addq %r11,%rdi + adcq $0,%rdx + movq %rdi,-32(%rsp,%r15,8) + movq %rdx,%r13 + cmpq %r9,%r15 + jb .L1st4x + + mulq %rbx + addq %rax,%r10 + movq -16(%rcx,%r15,8),%rax + adcq $0,%rdx + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r13 + movq -8(%rsi,%r15,8),%rax + adcq $0,%rdx + addq %r10,%r13 + adcq $0,%rdx + movq %r13,-24(%rsp,%r15,8) + movq %rdx,%rdi + + mulq %rbx + addq %rax,%r11 + movq -8(%rcx,%r15,8),%rax + adcq $0,%rdx + movq %rdx,%r10 + + mulq %rbp + addq %rax,%rdi + movq (%rsi),%rax + adcq $0,%rdx + addq %r11,%rdi + adcq $0,%rdx + movq %rdi,-16(%rsp,%r15,8) + movq %rdx,%r13 + + xorq %rdi,%rdi + addq %r10,%r13 + adcq $0,%rdi + movq %r13,-8(%rsp,%r15,8) + movq %rdi,(%rsp,%r15,8) + + leaq 1(%r14),%r14 +.align 4 +.Louter4x: + movq (%r12,%r14,8),%rbx + xorq %r15,%r15 + movq (%rsp),%r10 + movq %r8,%rbp + mulq %rbx + addq %rax,%r10 + movq (%rcx),%rax + adcq $0,%rdx + + imulq %r10,%rbp + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r10 + movq 8(%rsi),%rax + adcq $0,%rdx + movq %rdx,%rdi + + mulq %rbx + addq %rax,%r11 + movq 8(%rcx),%rax + adcq $0,%rdx + addq 8(%rsp),%r11 + adcq $0,%rdx + movq %rdx,%r10 + + mulq %rbp + addq %rax,%rdi + movq 16(%rsi),%rax + adcq $0,%rdx + addq %r11,%rdi + leaq 4(%r15),%r15 + adcq $0,%rdx + movq %rdi,(%rsp) + movq %rdx,%r13 + jmp .Linner4x +.align 16 +.Linner4x: + mulq %rbx + addq %rax,%r10 + movq -16(%rcx,%r15,8),%rax + adcq $0,%rdx + addq -16(%rsp,%r15,8),%r10 + adcq $0,%rdx + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r13 + movq -8(%rsi,%r15,8),%rax + adcq $0,%rdx + addq %r10,%r13 + adcq $0,%rdx + movq %r13,-24(%rsp,%r15,8) + movq %rdx,%rdi + + mulq %rbx + addq %rax,%r11 + movq -8(%rcx,%r15,8),%rax + adcq $0,%rdx + addq -8(%rsp,%r15,8),%r11 + adcq $0,%rdx + movq %rdx,%r10 + + mulq %rbp + addq %rax,%rdi + movq (%rsi,%r15,8),%rax + adcq $0,%rdx + addq %r11,%rdi + adcq $0,%rdx + movq %rdi,-16(%rsp,%r15,8) + movq %rdx,%r13 + + mulq %rbx + addq %rax,%r10 + movq (%rcx,%r15,8),%rax + adcq $0,%rdx + addq (%rsp,%r15,8),%r10 + adcq $0,%rdx + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r13 + movq 8(%rsi,%r15,8),%rax + adcq $0,%rdx + addq %r10,%r13 + adcq $0,%rdx + movq %r13,-8(%rsp,%r15,8) + movq %rdx,%rdi + + mulq %rbx + addq %rax,%r11 + movq 8(%rcx,%r15,8),%rax + adcq $0,%rdx + addq 8(%rsp,%r15,8),%r11 + adcq $0,%rdx + leaq 4(%r15),%r15 + movq %rdx,%r10 + + mulq %rbp + addq %rax,%rdi + movq -16(%rsi,%r15,8),%rax + adcq $0,%rdx + addq %r11,%rdi + adcq $0,%rdx + movq %rdi,-32(%rsp,%r15,8) + movq %rdx,%r13 + cmpq %r9,%r15 + jb .Linner4x + + mulq %rbx + addq %rax,%r10 + movq -16(%rcx,%r15,8),%rax + adcq $0,%rdx + addq -16(%rsp,%r15,8),%r10 + adcq $0,%rdx + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r13 + movq -8(%rsi,%r15,8),%rax + adcq $0,%rdx + addq %r10,%r13 + adcq $0,%rdx + movq %r13,-24(%rsp,%r15,8) + movq %rdx,%rdi + + mulq %rbx + addq %rax,%r11 + movq -8(%rcx,%r15,8),%rax + adcq $0,%rdx + addq -8(%rsp,%r15,8),%r11 + adcq $0,%rdx + leaq 1(%r14),%r14 + movq %rdx,%r10 + + mulq %rbp + addq %rax,%rdi + movq (%rsi),%rax + adcq $0,%rdx + addq %r11,%rdi + adcq $0,%rdx + movq %rdi,-16(%rsp,%r15,8) + movq %rdx,%r13 + + xorq %rdi,%rdi + addq %r10,%r13 + adcq $0,%rdi + addq (%rsp,%r9,8),%r13 + adcq $0,%rdi + movq %r13,-8(%rsp,%r15,8) + movq %rdi,(%rsp,%r15,8) + + cmpq %r9,%r14 + jb .Louter4x + movq 16(%rsp,%r9,8),%rdi + leaq -4(%r9),%r15 + movq 0(%rsp),%rax + movq 8(%rsp),%rdx + shrq $2,%r15 + leaq (%rsp),%rsi + xorq %r14,%r14 + + subq 0(%rcx),%rax + movq 16(%rsi),%rbx + movq 24(%rsi),%rbp + sbbq 8(%rcx),%rdx + +.Lsub4x: + movq %rax,0(%rdi,%r14,8) + movq %rdx,8(%rdi,%r14,8) + sbbq 16(%rcx,%r14,8),%rbx + movq 32(%rsi,%r14,8),%rax + movq 40(%rsi,%r14,8),%rdx + sbbq 24(%rcx,%r14,8),%rbp + movq %rbx,16(%rdi,%r14,8) + movq %rbp,24(%rdi,%r14,8) + sbbq 32(%rcx,%r14,8),%rax + movq 48(%rsi,%r14,8),%rbx + movq 56(%rsi,%r14,8),%rbp + sbbq 40(%rcx,%r14,8),%rdx + leaq 4(%r14),%r14 + decq %r15 + jnz .Lsub4x + + movq %rax,0(%rdi,%r14,8) + movq 32(%rsi,%r14,8),%rax + sbbq 16(%rcx,%r14,8),%rbx + movq %rdx,8(%rdi,%r14,8) + sbbq 24(%rcx,%r14,8),%rbp + movq %rbx,16(%rdi,%r14,8) + + sbbq $0,%rax + movq %rbp,24(%rdi,%r14,8) + pxor %xmm0,%xmm0 +.byte 102,72,15,110,224 + pcmpeqd %xmm5,%xmm5 + pshufd $0,%xmm4,%xmm4 + movq %r9,%r15 + pxor %xmm4,%xmm5 + shrq $2,%r15 + xorl %eax,%eax + + jmp .Lcopy4x +.align 16 +.Lcopy4x: + movdqa (%rsp,%rax,1),%xmm1 + movdqu (%rdi,%rax,1),%xmm2 + pand %xmm4,%xmm1 + pand %xmm5,%xmm2 + movdqa 16(%rsp,%rax,1),%xmm3 + movdqa %xmm0,(%rsp,%rax,1) + por %xmm2,%xmm1 + movdqu 16(%rdi,%rax,1),%xmm2 + movdqu %xmm1,(%rdi,%rax,1) + pand %xmm4,%xmm3 + pand %xmm5,%xmm2 + movdqa %xmm0,16(%rsp,%rax,1) + por %xmm2,%xmm3 + movdqu %xmm3,16(%rdi,%rax,1) + leaq 32(%rax),%rax + decq %r15 + jnz .Lcopy4x + movq 8(%rsp,%r9,8),%rsi +.cfi_def_cfa %rsi, 8 + movq $1,%rax + movq -48(%rsi),%r15 +.cfi_restore %r15 + movq -40(%rsi),%r14 +.cfi_restore %r14 + movq -32(%rsi),%r13 +.cfi_restore %r13 + movq -24(%rsi),%r12 +.cfi_restore %r12 + movq -16(%rsi),%rbp +.cfi_restore %rbp + movq -8(%rsi),%rbx +.cfi_restore %rbx + leaq (%rsi),%rsp +.cfi_def_cfa_register %rsp +.Lmul4x_epilogue: + ret +.cfi_endproc +.size bn_mul4x_mont,.-bn_mul4x_mont +.extern bn_sqrx8x_internal +.hidden bn_sqrx8x_internal +.extern bn_sqr8x_internal +.hidden bn_sqr8x_internal + +.globl bn_sqr8x_mont +.hidden bn_sqr8x_mont +.type bn_sqr8x_mont,@function +.align 32 +bn_sqr8x_mont: +.cfi_startproc +_CET_ENDBR + movl %r9d,%r9d + movq %rsp,%rax +.cfi_def_cfa_register %rax + pushq %rbx +.cfi_offset %rbx,-16 + pushq %rbp +.cfi_offset %rbp,-24 + pushq %r12 +.cfi_offset %r12,-32 + pushq %r13 +.cfi_offset %r13,-40 + pushq %r14 +.cfi_offset %r14,-48 + pushq %r15 +.cfi_offset %r15,-56 +.Lsqr8x_prologue: + + movl %r9d,%r10d + shll $3,%r9d + shlq $3+2,%r10 + negq %r9 + + + + + + + leaq -64(%rsp,%r9,2),%r11 + movq %rsp,%rbp + movq (%r8),%r8 + subq %rsi,%r11 + andq $4095,%r11 + cmpq %r11,%r10 + jb .Lsqr8x_sp_alt + subq %r11,%rbp + leaq -64(%rbp,%r9,2),%rbp + jmp .Lsqr8x_sp_done + +.align 32 +.Lsqr8x_sp_alt: + leaq 4096-64(,%r9,2),%r10 + leaq -64(%rbp,%r9,2),%rbp + subq %r10,%r11 + movq $0,%r10 + cmovcq %r10,%r11 + subq %r11,%rbp +.Lsqr8x_sp_done: + andq $-64,%rbp + movq %rsp,%r11 + subq %rbp,%r11 + andq $-4096,%r11 + leaq (%r11,%rbp,1),%rsp + movq (%rsp),%r10 + cmpq %rbp,%rsp + ja .Lsqr8x_page_walk + jmp .Lsqr8x_page_walk_done + +.align 16 +.Lsqr8x_page_walk: + leaq -4096(%rsp),%rsp + movq (%rsp),%r10 + cmpq %rbp,%rsp + ja .Lsqr8x_page_walk +.Lsqr8x_page_walk_done: + + movq %r9,%r10 + negq %r9 + + movq %r8,32(%rsp) + movq %rax,40(%rsp) +.cfi_escape 0x0f,0x05,0x77,0x28,0x06,0x23,0x08 +.Lsqr8x_body: + +.byte 102,72,15,110,209 + pxor %xmm0,%xmm0 +.byte 102,72,15,110,207 +.byte 102,73,15,110,218 + testq %rdx,%rdx + jz .Lsqr8x_nox + + call bn_sqrx8x_internal + + + + + leaq (%r8,%rcx,1),%rbx + movq %rcx,%r9 + movq %rcx,%rdx +.byte 102,72,15,126,207 + sarq $3+2,%rcx + jmp .Lsqr8x_sub + +.align 32 +.Lsqr8x_nox: + call bn_sqr8x_internal + + + + + leaq (%rdi,%r9,1),%rbx + movq %r9,%rcx + movq %r9,%rdx +.byte 102,72,15,126,207 + sarq $3+2,%rcx + jmp .Lsqr8x_sub + +.align 32 +.Lsqr8x_sub: + movq 0(%rbx),%r12 + movq 8(%rbx),%r13 + movq 16(%rbx),%r14 + movq 24(%rbx),%r15 + leaq 32(%rbx),%rbx + sbbq 0(%rbp),%r12 + sbbq 8(%rbp),%r13 + sbbq 16(%rbp),%r14 + sbbq 24(%rbp),%r15 + leaq 32(%rbp),%rbp + movq %r12,0(%rdi) + movq %r13,8(%rdi) + movq %r14,16(%rdi) + movq %r15,24(%rdi) + leaq 32(%rdi),%rdi + incq %rcx + jnz .Lsqr8x_sub + + sbbq $0,%rax + leaq (%rbx,%r9,1),%rbx + leaq (%rdi,%r9,1),%rdi + +.byte 102,72,15,110,200 + pxor %xmm0,%xmm0 + pshufd $0,%xmm1,%xmm1 + movq 40(%rsp),%rsi +.cfi_def_cfa %rsi,8 + jmp .Lsqr8x_cond_copy + +.align 32 +.Lsqr8x_cond_copy: + movdqa 0(%rbx),%xmm2 + movdqa 16(%rbx),%xmm3 + leaq 32(%rbx),%rbx + movdqu 0(%rdi),%xmm4 + movdqu 16(%rdi),%xmm5 + leaq 32(%rdi),%rdi + movdqa %xmm0,-32(%rbx) + movdqa %xmm0,-16(%rbx) + movdqa %xmm0,-32(%rbx,%rdx,1) + movdqa %xmm0,-16(%rbx,%rdx,1) + pcmpeqd %xmm1,%xmm0 + pand %xmm1,%xmm2 + pand %xmm1,%xmm3 + pand %xmm0,%xmm4 + pand %xmm0,%xmm5 + pxor %xmm0,%xmm0 + por %xmm2,%xmm4 + por %xmm3,%xmm5 + movdqu %xmm4,-32(%rdi) + movdqu %xmm5,-16(%rdi) + addq $32,%r9 + jnz .Lsqr8x_cond_copy + + movq $1,%rax + movq -48(%rsi),%r15 +.cfi_restore %r15 + movq -40(%rsi),%r14 +.cfi_restore %r14 + movq -32(%rsi),%r13 +.cfi_restore %r13 + movq -24(%rsi),%r12 +.cfi_restore %r12 + movq -16(%rsi),%rbp +.cfi_restore %rbp + movq -8(%rsi),%rbx +.cfi_restore %rbx + leaq (%rsi),%rsp +.cfi_def_cfa_register %rsp +.Lsqr8x_epilogue: + ret +.cfi_endproc +.size bn_sqr8x_mont,.-bn_sqr8x_mont +.globl bn_mulx4x_mont +.hidden bn_mulx4x_mont +.type bn_mulx4x_mont,@function +.align 32 +bn_mulx4x_mont: +.cfi_startproc +_CET_ENDBR + movq %rsp,%rax +.cfi_def_cfa_register %rax + pushq %rbx +.cfi_offset %rbx,-16 + pushq %rbp +.cfi_offset %rbp,-24 + pushq %r12 +.cfi_offset %r12,-32 + pushq %r13 +.cfi_offset %r13,-40 + pushq %r14 +.cfi_offset %r14,-48 + pushq %r15 +.cfi_offset %r15,-56 +.Lmulx4x_prologue: + + shll $3,%r9d + xorq %r10,%r10 + subq %r9,%r10 + movq (%r8),%r8 + leaq -72(%rsp,%r10,1),%rbp + andq $-128,%rbp + movq %rsp,%r11 + subq %rbp,%r11 + andq $-4096,%r11 + leaq (%r11,%rbp,1),%rsp + movq (%rsp),%r10 + cmpq %rbp,%rsp + ja .Lmulx4x_page_walk + jmp .Lmulx4x_page_walk_done + +.align 16 +.Lmulx4x_page_walk: + leaq -4096(%rsp),%rsp + movq (%rsp),%r10 + cmpq %rbp,%rsp + ja .Lmulx4x_page_walk +.Lmulx4x_page_walk_done: + + leaq (%rdx,%r9,1),%r10 + + + + + + + + + + + + + movq %r9,0(%rsp) + shrq $5,%r9 + movq %r10,16(%rsp) + subq $1,%r9 + movq %r8,24(%rsp) + movq %rdi,32(%rsp) + movq %rax,40(%rsp) +.cfi_escape 0x0f,0x05,0x77,0x28,0x06,0x23,0x08 + movq %r9,48(%rsp) + jmp .Lmulx4x_body + +.align 32 +.Lmulx4x_body: + leaq 8(%rdx),%rdi + movq (%rdx),%rdx + leaq 64+32(%rsp),%rbx + movq %rdx,%r9 + + mulxq 0(%rsi),%r8,%rax + mulxq 8(%rsi),%r11,%r14 + addq %rax,%r11 + movq %rdi,8(%rsp) + mulxq 16(%rsi),%r12,%r13 + adcq %r14,%r12 + adcq $0,%r13 + + movq %r8,%rdi + imulq 24(%rsp),%r8 + xorq %rbp,%rbp + + mulxq 24(%rsi),%rax,%r14 + movq %r8,%rdx + leaq 32(%rsi),%rsi + adcxq %rax,%r13 + adcxq %rbp,%r14 + + mulxq 0(%rcx),%rax,%r10 + adcxq %rax,%rdi + adoxq %r11,%r10 + mulxq 8(%rcx),%rax,%r11 + adcxq %rax,%r10 + adoxq %r12,%r11 +.byte 0xc4,0x62,0xfb,0xf6,0xa1,0x10,0x00,0x00,0x00 + movq 48(%rsp),%rdi + movq %r10,-32(%rbx) + adcxq %rax,%r11 + adoxq %r13,%r12 + mulxq 24(%rcx),%rax,%r15 + movq %r9,%rdx + movq %r11,-24(%rbx) + adcxq %rax,%r12 + adoxq %rbp,%r15 + leaq 32(%rcx),%rcx + movq %r12,-16(%rbx) + + jmp .Lmulx4x_1st + +.align 32 +.Lmulx4x_1st: + adcxq %rbp,%r15 + mulxq 0(%rsi),%r10,%rax + adcxq %r14,%r10 + mulxq 8(%rsi),%r11,%r14 + adcxq %rax,%r11 + mulxq 16(%rsi),%r12,%rax + adcxq %r14,%r12 + mulxq 24(%rsi),%r13,%r14 +.byte 0x67,0x67 + movq %r8,%rdx + adcxq %rax,%r13 + adcxq %rbp,%r14 + leaq 32(%rsi),%rsi + leaq 32(%rbx),%rbx + + adoxq %r15,%r10 + mulxq 0(%rcx),%rax,%r15 + adcxq %rax,%r10 + adoxq %r15,%r11 + mulxq 8(%rcx),%rax,%r15 + adcxq %rax,%r11 + adoxq %r15,%r12 + mulxq 16(%rcx),%rax,%r15 + movq %r10,-40(%rbx) + adcxq %rax,%r12 + movq %r11,-32(%rbx) + adoxq %r15,%r13 + mulxq 24(%rcx),%rax,%r15 + movq %r9,%rdx + movq %r12,-24(%rbx) + adcxq %rax,%r13 + adoxq %rbp,%r15 + leaq 32(%rcx),%rcx + movq %r13,-16(%rbx) + + decq %rdi + jnz .Lmulx4x_1st + + movq 0(%rsp),%rax + movq 8(%rsp),%rdi + adcq %rbp,%r15 + addq %r15,%r14 + sbbq %r15,%r15 + movq %r14,-8(%rbx) + jmp .Lmulx4x_outer + +.align 32 +.Lmulx4x_outer: + movq (%rdi),%rdx + leaq 8(%rdi),%rdi + subq %rax,%rsi + movq %r15,(%rbx) + leaq 64+32(%rsp),%rbx + subq %rax,%rcx + + mulxq 0(%rsi),%r8,%r11 + xorl %ebp,%ebp + movq %rdx,%r9 + mulxq 8(%rsi),%r14,%r12 + adoxq -32(%rbx),%r8 + adcxq %r14,%r11 + mulxq 16(%rsi),%r15,%r13 + adoxq -24(%rbx),%r11 + adcxq %r15,%r12 + adoxq -16(%rbx),%r12 + adcxq %rbp,%r13 + adoxq %rbp,%r13 + + movq %rdi,8(%rsp) + movq %r8,%r15 + imulq 24(%rsp),%r8 + xorl %ebp,%ebp + + mulxq 24(%rsi),%rax,%r14 + movq %r8,%rdx + adcxq %rax,%r13 + adoxq -8(%rbx),%r13 + adcxq %rbp,%r14 + leaq 32(%rsi),%rsi + adoxq %rbp,%r14 + + mulxq 0(%rcx),%rax,%r10 + adcxq %rax,%r15 + adoxq %r11,%r10 + mulxq 8(%rcx),%rax,%r11 + adcxq %rax,%r10 + adoxq %r12,%r11 + mulxq 16(%rcx),%rax,%r12 + movq %r10,-32(%rbx) + adcxq %rax,%r11 + adoxq %r13,%r12 + mulxq 24(%rcx),%rax,%r15 + movq %r9,%rdx + movq %r11,-24(%rbx) + leaq 32(%rcx),%rcx + adcxq %rax,%r12 + adoxq %rbp,%r15 + movq 48(%rsp),%rdi + movq %r12,-16(%rbx) + + jmp .Lmulx4x_inner + +.align 32 +.Lmulx4x_inner: + mulxq 0(%rsi),%r10,%rax + adcxq %rbp,%r15 + adoxq %r14,%r10 + mulxq 8(%rsi),%r11,%r14 + adcxq 0(%rbx),%r10 + adoxq %rax,%r11 + mulxq 16(%rsi),%r12,%rax + adcxq 8(%rbx),%r11 + adoxq %r14,%r12 + mulxq 24(%rsi),%r13,%r14 + movq %r8,%rdx + adcxq 16(%rbx),%r12 + adoxq %rax,%r13 + adcxq 24(%rbx),%r13 + adoxq %rbp,%r14 + leaq 32(%rsi),%rsi + leaq 32(%rbx),%rbx + adcxq %rbp,%r14 + + adoxq %r15,%r10 + mulxq 0(%rcx),%rax,%r15 + adcxq %rax,%r10 + adoxq %r15,%r11 + mulxq 8(%rcx),%rax,%r15 + adcxq %rax,%r11 + adoxq %r15,%r12 + mulxq 16(%rcx),%rax,%r15 + movq %r10,-40(%rbx) + adcxq %rax,%r12 + adoxq %r15,%r13 + mulxq 24(%rcx),%rax,%r15 + movq %r9,%rdx + movq %r11,-32(%rbx) + movq %r12,-24(%rbx) + adcxq %rax,%r13 + adoxq %rbp,%r15 + leaq 32(%rcx),%rcx + movq %r13,-16(%rbx) + + decq %rdi + jnz .Lmulx4x_inner + + movq 0(%rsp),%rax + movq 8(%rsp),%rdi + adcq %rbp,%r15 + subq 0(%rbx),%rbp + adcq %r15,%r14 + sbbq %r15,%r15 + movq %r14,-8(%rbx) + + cmpq 16(%rsp),%rdi + jne .Lmulx4x_outer + + leaq 64(%rsp),%rbx + subq %rax,%rcx + negq %r15 + movq %rax,%rdx + shrq $3+2,%rax + movq 32(%rsp),%rdi + jmp .Lmulx4x_sub + +.align 32 +.Lmulx4x_sub: + movq 0(%rbx),%r11 + movq 8(%rbx),%r12 + movq 16(%rbx),%r13 + movq 24(%rbx),%r14 + leaq 32(%rbx),%rbx + sbbq 0(%rcx),%r11 + sbbq 8(%rcx),%r12 + sbbq 16(%rcx),%r13 + sbbq 24(%rcx),%r14 + leaq 32(%rcx),%rcx + movq %r11,0(%rdi) + movq %r12,8(%rdi) + movq %r13,16(%rdi) + movq %r14,24(%rdi) + leaq 32(%rdi),%rdi + decq %rax + jnz .Lmulx4x_sub + + sbbq $0,%r15 + leaq 64(%rsp),%rbx + subq %rdx,%rdi + +.byte 102,73,15,110,207 + pxor %xmm0,%xmm0 + pshufd $0,%xmm1,%xmm1 + movq 40(%rsp),%rsi +.cfi_def_cfa %rsi,8 + jmp .Lmulx4x_cond_copy + +.align 32 +.Lmulx4x_cond_copy: + movdqa 0(%rbx),%xmm2 + movdqa 16(%rbx),%xmm3 + leaq 32(%rbx),%rbx + movdqu 0(%rdi),%xmm4 + movdqu 16(%rdi),%xmm5 + leaq 32(%rdi),%rdi + movdqa %xmm0,-32(%rbx) + movdqa %xmm0,-16(%rbx) + pcmpeqd %xmm1,%xmm0 + pand %xmm1,%xmm2 + pand %xmm1,%xmm3 + pand %xmm0,%xmm4 + pand %xmm0,%xmm5 + pxor %xmm0,%xmm0 + por %xmm2,%xmm4 + por %xmm3,%xmm5 + movdqu %xmm4,-32(%rdi) + movdqu %xmm5,-16(%rdi) + subq $32,%rdx + jnz .Lmulx4x_cond_copy + + movq %rdx,(%rbx) + + movq $1,%rax + movq -48(%rsi),%r15 +.cfi_restore %r15 + movq -40(%rsi),%r14 +.cfi_restore %r14 + movq -32(%rsi),%r13 +.cfi_restore %r13 + movq -24(%rsi),%r12 +.cfi_restore %r12 + movq -16(%rsi),%rbp +.cfi_restore %rbp + movq -8(%rsi),%rbx +.cfi_restore %rbx + leaq (%rsi),%rsp +.cfi_def_cfa_register %rsp +.Lmulx4x_epilogue: + ret +.cfi_endproc +.size bn_mulx4x_mont,.-bn_mulx4x_mont +.byte 77,111,110,116,103,111,109,101,114,121,32,77,117,108,116,105,112,108,105,99,97,116,105,111,110,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.align 16 +#endif diff --git a/http/vendor/ring/pregenerated/x86_64-mont-macosx.S b/http/vendor/ring/pregenerated/x86_64-mont-macosx.S new file mode 100644 index 0000000..8b81855 --- /dev/null +++ b/http/vendor/ring/pregenerated/x86_64-mont-macosx.S @@ -0,0 +1,1235 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__) +.text + +.globl _bn_mul_mont_nohw +.private_extern _bn_mul_mont_nohw + +.p2align 4 +_bn_mul_mont_nohw: + +_CET_ENDBR + movl %r9d,%r9d + movq %rsp,%rax + + pushq %rbx + + pushq %rbp + + pushq %r12 + + pushq %r13 + + pushq %r14 + + pushq %r15 + + + negq %r9 + movq %rsp,%r11 + leaq -16(%rsp,%r9,8),%r10 + negq %r9 + andq $-1024,%r10 + + + + + + + + + + subq %r10,%r11 + andq $-4096,%r11 + leaq (%r10,%r11,1),%rsp + movq (%rsp),%r11 + cmpq %r10,%rsp + ja L$mul_page_walk + jmp L$mul_page_walk_done + +.p2align 4 +L$mul_page_walk: + leaq -4096(%rsp),%rsp + movq (%rsp),%r11 + cmpq %r10,%rsp + ja L$mul_page_walk +L$mul_page_walk_done: + + movq %rax,8(%rsp,%r9,8) + +L$mul_body: + movq %rdx,%r12 + movq (%r8),%r8 + movq (%r12),%rbx + movq (%rsi),%rax + + xorq %r14,%r14 + xorq %r15,%r15 + + movq %r8,%rbp + mulq %rbx + movq %rax,%r10 + movq (%rcx),%rax + + imulq %r10,%rbp + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r10 + movq 8(%rsi),%rax + adcq $0,%rdx + movq %rdx,%r13 + + leaq 1(%r15),%r15 + jmp L$1st_enter + +.p2align 4 +L$1st: + addq %rax,%r13 + movq (%rsi,%r15,8),%rax + adcq $0,%rdx + addq %r11,%r13 + movq %r10,%r11 + adcq $0,%rdx + movq %r13,-16(%rsp,%r15,8) + movq %rdx,%r13 + +L$1st_enter: + mulq %rbx + addq %rax,%r11 + movq (%rcx,%r15,8),%rax + adcq $0,%rdx + leaq 1(%r15),%r15 + movq %rdx,%r10 + + mulq %rbp + cmpq %r9,%r15 + jne L$1st + + addq %rax,%r13 + movq (%rsi),%rax + adcq $0,%rdx + addq %r11,%r13 + adcq $0,%rdx + movq %r13,-16(%rsp,%r15,8) + movq %rdx,%r13 + movq %r10,%r11 + + xorq %rdx,%rdx + addq %r11,%r13 + adcq $0,%rdx + movq %r13,-8(%rsp,%r9,8) + movq %rdx,(%rsp,%r9,8) + + leaq 1(%r14),%r14 + jmp L$outer +.p2align 4 +L$outer: + movq (%r12,%r14,8),%rbx + xorq %r15,%r15 + movq %r8,%rbp + movq (%rsp),%r10 + mulq %rbx + addq %rax,%r10 + movq (%rcx),%rax + adcq $0,%rdx + + imulq %r10,%rbp + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r10 + movq 8(%rsi),%rax + adcq $0,%rdx + movq 8(%rsp),%r10 + movq %rdx,%r13 + + leaq 1(%r15),%r15 + jmp L$inner_enter + +.p2align 4 +L$inner: + addq %rax,%r13 + movq (%rsi,%r15,8),%rax + adcq $0,%rdx + addq %r10,%r13 + movq (%rsp,%r15,8),%r10 + adcq $0,%rdx + movq %r13,-16(%rsp,%r15,8) + movq %rdx,%r13 + +L$inner_enter: + mulq %rbx + addq %rax,%r11 + movq (%rcx,%r15,8),%rax + adcq $0,%rdx + addq %r11,%r10 + movq %rdx,%r11 + adcq $0,%r11 + leaq 1(%r15),%r15 + + mulq %rbp + cmpq %r9,%r15 + jne L$inner + + addq %rax,%r13 + movq (%rsi),%rax + adcq $0,%rdx + addq %r10,%r13 + movq (%rsp,%r15,8),%r10 + adcq $0,%rdx + movq %r13,-16(%rsp,%r15,8) + movq %rdx,%r13 + + xorq %rdx,%rdx + addq %r11,%r13 + adcq $0,%rdx + addq %r10,%r13 + adcq $0,%rdx + movq %r13,-8(%rsp,%r9,8) + movq %rdx,(%rsp,%r9,8) + + leaq 1(%r14),%r14 + cmpq %r9,%r14 + jb L$outer + + xorq %r14,%r14 + movq (%rsp),%rax + movq %r9,%r15 + +.p2align 4 +L$sub: sbbq (%rcx,%r14,8),%rax + movq %rax,(%rdi,%r14,8) + movq 8(%rsp,%r14,8),%rax + leaq 1(%r14),%r14 + decq %r15 + jnz L$sub + + sbbq $0,%rax + movq $-1,%rbx + xorq %rax,%rbx + xorq %r14,%r14 + movq %r9,%r15 + +L$copy: + movq (%rdi,%r14,8),%rcx + movq (%rsp,%r14,8),%rdx + andq %rbx,%rcx + andq %rax,%rdx + movq %r9,(%rsp,%r14,8) + orq %rcx,%rdx + movq %rdx,(%rdi,%r14,8) + leaq 1(%r14),%r14 + subq $1,%r15 + jnz L$copy + + movq 8(%rsp,%r9,8),%rsi + + movq $1,%rax + movq -48(%rsi),%r15 + + movq -40(%rsi),%r14 + + movq -32(%rsi),%r13 + + movq -24(%rsi),%r12 + + movq -16(%rsi),%rbp + + movq -8(%rsi),%rbx + + leaq (%rsi),%rsp + +L$mul_epilogue: + ret + + +.globl _bn_mul4x_mont +.private_extern _bn_mul4x_mont + +.p2align 4 +_bn_mul4x_mont: + +_CET_ENDBR + movl %r9d,%r9d + movq %rsp,%rax + + pushq %rbx + + pushq %rbp + + pushq %r12 + + pushq %r13 + + pushq %r14 + + pushq %r15 + + + negq %r9 + movq %rsp,%r11 + leaq -32(%rsp,%r9,8),%r10 + negq %r9 + andq $-1024,%r10 + + subq %r10,%r11 + andq $-4096,%r11 + leaq (%r10,%r11,1),%rsp + movq (%rsp),%r11 + cmpq %r10,%rsp + ja L$mul4x_page_walk + jmp L$mul4x_page_walk_done + +L$mul4x_page_walk: + leaq -4096(%rsp),%rsp + movq (%rsp),%r11 + cmpq %r10,%rsp + ja L$mul4x_page_walk +L$mul4x_page_walk_done: + + movq %rax,8(%rsp,%r9,8) + +L$mul4x_body: + movq %rdi,16(%rsp,%r9,8) + movq %rdx,%r12 + movq (%r8),%r8 + movq (%r12),%rbx + movq (%rsi),%rax + + xorq %r14,%r14 + xorq %r15,%r15 + + movq %r8,%rbp + mulq %rbx + movq %rax,%r10 + movq (%rcx),%rax + + imulq %r10,%rbp + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r10 + movq 8(%rsi),%rax + adcq $0,%rdx + movq %rdx,%rdi + + mulq %rbx + addq %rax,%r11 + movq 8(%rcx),%rax + adcq $0,%rdx + movq %rdx,%r10 + + mulq %rbp + addq %rax,%rdi + movq 16(%rsi),%rax + adcq $0,%rdx + addq %r11,%rdi + leaq 4(%r15),%r15 + adcq $0,%rdx + movq %rdi,(%rsp) + movq %rdx,%r13 + jmp L$1st4x +.p2align 4 +L$1st4x: + mulq %rbx + addq %rax,%r10 + movq -16(%rcx,%r15,8),%rax + adcq $0,%rdx + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r13 + movq -8(%rsi,%r15,8),%rax + adcq $0,%rdx + addq %r10,%r13 + adcq $0,%rdx + movq %r13,-24(%rsp,%r15,8) + movq %rdx,%rdi + + mulq %rbx + addq %rax,%r11 + movq -8(%rcx,%r15,8),%rax + adcq $0,%rdx + movq %rdx,%r10 + + mulq %rbp + addq %rax,%rdi + movq (%rsi,%r15,8),%rax + adcq $0,%rdx + addq %r11,%rdi + adcq $0,%rdx + movq %rdi,-16(%rsp,%r15,8) + movq %rdx,%r13 + + mulq %rbx + addq %rax,%r10 + movq (%rcx,%r15,8),%rax + adcq $0,%rdx + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r13 + movq 8(%rsi,%r15,8),%rax + adcq $0,%rdx + addq %r10,%r13 + adcq $0,%rdx + movq %r13,-8(%rsp,%r15,8) + movq %rdx,%rdi + + mulq %rbx + addq %rax,%r11 + movq 8(%rcx,%r15,8),%rax + adcq $0,%rdx + leaq 4(%r15),%r15 + movq %rdx,%r10 + + mulq %rbp + addq %rax,%rdi + movq -16(%rsi,%r15,8),%rax + adcq $0,%rdx + addq %r11,%rdi + adcq $0,%rdx + movq %rdi,-32(%rsp,%r15,8) + movq %rdx,%r13 + cmpq %r9,%r15 + jb L$1st4x + + mulq %rbx + addq %rax,%r10 + movq -16(%rcx,%r15,8),%rax + adcq $0,%rdx + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r13 + movq -8(%rsi,%r15,8),%rax + adcq $0,%rdx + addq %r10,%r13 + adcq $0,%rdx + movq %r13,-24(%rsp,%r15,8) + movq %rdx,%rdi + + mulq %rbx + addq %rax,%r11 + movq -8(%rcx,%r15,8),%rax + adcq $0,%rdx + movq %rdx,%r10 + + mulq %rbp + addq %rax,%rdi + movq (%rsi),%rax + adcq $0,%rdx + addq %r11,%rdi + adcq $0,%rdx + movq %rdi,-16(%rsp,%r15,8) + movq %rdx,%r13 + + xorq %rdi,%rdi + addq %r10,%r13 + adcq $0,%rdi + movq %r13,-8(%rsp,%r15,8) + movq %rdi,(%rsp,%r15,8) + + leaq 1(%r14),%r14 +.p2align 2 +L$outer4x: + movq (%r12,%r14,8),%rbx + xorq %r15,%r15 + movq (%rsp),%r10 + movq %r8,%rbp + mulq %rbx + addq %rax,%r10 + movq (%rcx),%rax + adcq $0,%rdx + + imulq %r10,%rbp + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r10 + movq 8(%rsi),%rax + adcq $0,%rdx + movq %rdx,%rdi + + mulq %rbx + addq %rax,%r11 + movq 8(%rcx),%rax + adcq $0,%rdx + addq 8(%rsp),%r11 + adcq $0,%rdx + movq %rdx,%r10 + + mulq %rbp + addq %rax,%rdi + movq 16(%rsi),%rax + adcq $0,%rdx + addq %r11,%rdi + leaq 4(%r15),%r15 + adcq $0,%rdx + movq %rdi,(%rsp) + movq %rdx,%r13 + jmp L$inner4x +.p2align 4 +L$inner4x: + mulq %rbx + addq %rax,%r10 + movq -16(%rcx,%r15,8),%rax + adcq $0,%rdx + addq -16(%rsp,%r15,8),%r10 + adcq $0,%rdx + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r13 + movq -8(%rsi,%r15,8),%rax + adcq $0,%rdx + addq %r10,%r13 + adcq $0,%rdx + movq %r13,-24(%rsp,%r15,8) + movq %rdx,%rdi + + mulq %rbx + addq %rax,%r11 + movq -8(%rcx,%r15,8),%rax + adcq $0,%rdx + addq -8(%rsp,%r15,8),%r11 + adcq $0,%rdx + movq %rdx,%r10 + + mulq %rbp + addq %rax,%rdi + movq (%rsi,%r15,8),%rax + adcq $0,%rdx + addq %r11,%rdi + adcq $0,%rdx + movq %rdi,-16(%rsp,%r15,8) + movq %rdx,%r13 + + mulq %rbx + addq %rax,%r10 + movq (%rcx,%r15,8),%rax + adcq $0,%rdx + addq (%rsp,%r15,8),%r10 + adcq $0,%rdx + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r13 + movq 8(%rsi,%r15,8),%rax + adcq $0,%rdx + addq %r10,%r13 + adcq $0,%rdx + movq %r13,-8(%rsp,%r15,8) + movq %rdx,%rdi + + mulq %rbx + addq %rax,%r11 + movq 8(%rcx,%r15,8),%rax + adcq $0,%rdx + addq 8(%rsp,%r15,8),%r11 + adcq $0,%rdx + leaq 4(%r15),%r15 + movq %rdx,%r10 + + mulq %rbp + addq %rax,%rdi + movq -16(%rsi,%r15,8),%rax + adcq $0,%rdx + addq %r11,%rdi + adcq $0,%rdx + movq %rdi,-32(%rsp,%r15,8) + movq %rdx,%r13 + cmpq %r9,%r15 + jb L$inner4x + + mulq %rbx + addq %rax,%r10 + movq -16(%rcx,%r15,8),%rax + adcq $0,%rdx + addq -16(%rsp,%r15,8),%r10 + adcq $0,%rdx + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r13 + movq -8(%rsi,%r15,8),%rax + adcq $0,%rdx + addq %r10,%r13 + adcq $0,%rdx + movq %r13,-24(%rsp,%r15,8) + movq %rdx,%rdi + + mulq %rbx + addq %rax,%r11 + movq -8(%rcx,%r15,8),%rax + adcq $0,%rdx + addq -8(%rsp,%r15,8),%r11 + adcq $0,%rdx + leaq 1(%r14),%r14 + movq %rdx,%r10 + + mulq %rbp + addq %rax,%rdi + movq (%rsi),%rax + adcq $0,%rdx + addq %r11,%rdi + adcq $0,%rdx + movq %rdi,-16(%rsp,%r15,8) + movq %rdx,%r13 + + xorq %rdi,%rdi + addq %r10,%r13 + adcq $0,%rdi + addq (%rsp,%r9,8),%r13 + adcq $0,%rdi + movq %r13,-8(%rsp,%r15,8) + movq %rdi,(%rsp,%r15,8) + + cmpq %r9,%r14 + jb L$outer4x + movq 16(%rsp,%r9,8),%rdi + leaq -4(%r9),%r15 + movq 0(%rsp),%rax + movq 8(%rsp),%rdx + shrq $2,%r15 + leaq (%rsp),%rsi + xorq %r14,%r14 + + subq 0(%rcx),%rax + movq 16(%rsi),%rbx + movq 24(%rsi),%rbp + sbbq 8(%rcx),%rdx + +L$sub4x: + movq %rax,0(%rdi,%r14,8) + movq %rdx,8(%rdi,%r14,8) + sbbq 16(%rcx,%r14,8),%rbx + movq 32(%rsi,%r14,8),%rax + movq 40(%rsi,%r14,8),%rdx + sbbq 24(%rcx,%r14,8),%rbp + movq %rbx,16(%rdi,%r14,8) + movq %rbp,24(%rdi,%r14,8) + sbbq 32(%rcx,%r14,8),%rax + movq 48(%rsi,%r14,8),%rbx + movq 56(%rsi,%r14,8),%rbp + sbbq 40(%rcx,%r14,8),%rdx + leaq 4(%r14),%r14 + decq %r15 + jnz L$sub4x + + movq %rax,0(%rdi,%r14,8) + movq 32(%rsi,%r14,8),%rax + sbbq 16(%rcx,%r14,8),%rbx + movq %rdx,8(%rdi,%r14,8) + sbbq 24(%rcx,%r14,8),%rbp + movq %rbx,16(%rdi,%r14,8) + + sbbq $0,%rax + movq %rbp,24(%rdi,%r14,8) + pxor %xmm0,%xmm0 +.byte 102,72,15,110,224 + pcmpeqd %xmm5,%xmm5 + pshufd $0,%xmm4,%xmm4 + movq %r9,%r15 + pxor %xmm4,%xmm5 + shrq $2,%r15 + xorl %eax,%eax + + jmp L$copy4x +.p2align 4 +L$copy4x: + movdqa (%rsp,%rax,1),%xmm1 + movdqu (%rdi,%rax,1),%xmm2 + pand %xmm4,%xmm1 + pand %xmm5,%xmm2 + movdqa 16(%rsp,%rax,1),%xmm3 + movdqa %xmm0,(%rsp,%rax,1) + por %xmm2,%xmm1 + movdqu 16(%rdi,%rax,1),%xmm2 + movdqu %xmm1,(%rdi,%rax,1) + pand %xmm4,%xmm3 + pand %xmm5,%xmm2 + movdqa %xmm0,16(%rsp,%rax,1) + por %xmm2,%xmm3 + movdqu %xmm3,16(%rdi,%rax,1) + leaq 32(%rax),%rax + decq %r15 + jnz L$copy4x + movq 8(%rsp,%r9,8),%rsi + + movq $1,%rax + movq -48(%rsi),%r15 + + movq -40(%rsi),%r14 + + movq -32(%rsi),%r13 + + movq -24(%rsi),%r12 + + movq -16(%rsi),%rbp + + movq -8(%rsi),%rbx + + leaq (%rsi),%rsp + +L$mul4x_epilogue: + ret + + + + + +.globl _bn_sqr8x_mont +.private_extern _bn_sqr8x_mont + +.p2align 5 +_bn_sqr8x_mont: + +_CET_ENDBR + movl %r9d,%r9d + movq %rsp,%rax + + pushq %rbx + + pushq %rbp + + pushq %r12 + + pushq %r13 + + pushq %r14 + + pushq %r15 + +L$sqr8x_prologue: + + movl %r9d,%r10d + shll $3,%r9d + shlq $3+2,%r10 + negq %r9 + + + + + + + leaq -64(%rsp,%r9,2),%r11 + movq %rsp,%rbp + movq (%r8),%r8 + subq %rsi,%r11 + andq $4095,%r11 + cmpq %r11,%r10 + jb L$sqr8x_sp_alt + subq %r11,%rbp + leaq -64(%rbp,%r9,2),%rbp + jmp L$sqr8x_sp_done + +.p2align 5 +L$sqr8x_sp_alt: + leaq 4096-64(,%r9,2),%r10 + leaq -64(%rbp,%r9,2),%rbp + subq %r10,%r11 + movq $0,%r10 + cmovcq %r10,%r11 + subq %r11,%rbp +L$sqr8x_sp_done: + andq $-64,%rbp + movq %rsp,%r11 + subq %rbp,%r11 + andq $-4096,%r11 + leaq (%r11,%rbp,1),%rsp + movq (%rsp),%r10 + cmpq %rbp,%rsp + ja L$sqr8x_page_walk + jmp L$sqr8x_page_walk_done + +.p2align 4 +L$sqr8x_page_walk: + leaq -4096(%rsp),%rsp + movq (%rsp),%r10 + cmpq %rbp,%rsp + ja L$sqr8x_page_walk +L$sqr8x_page_walk_done: + + movq %r9,%r10 + negq %r9 + + movq %r8,32(%rsp) + movq %rax,40(%rsp) + +L$sqr8x_body: + +.byte 102,72,15,110,209 + pxor %xmm0,%xmm0 +.byte 102,72,15,110,207 +.byte 102,73,15,110,218 + testq %rdx,%rdx + jz L$sqr8x_nox + + call _bn_sqrx8x_internal + + + + + leaq (%r8,%rcx,1),%rbx + movq %rcx,%r9 + movq %rcx,%rdx +.byte 102,72,15,126,207 + sarq $3+2,%rcx + jmp L$sqr8x_sub + +.p2align 5 +L$sqr8x_nox: + call _bn_sqr8x_internal + + + + + leaq (%rdi,%r9,1),%rbx + movq %r9,%rcx + movq %r9,%rdx +.byte 102,72,15,126,207 + sarq $3+2,%rcx + jmp L$sqr8x_sub + +.p2align 5 +L$sqr8x_sub: + movq 0(%rbx),%r12 + movq 8(%rbx),%r13 + movq 16(%rbx),%r14 + movq 24(%rbx),%r15 + leaq 32(%rbx),%rbx + sbbq 0(%rbp),%r12 + sbbq 8(%rbp),%r13 + sbbq 16(%rbp),%r14 + sbbq 24(%rbp),%r15 + leaq 32(%rbp),%rbp + movq %r12,0(%rdi) + movq %r13,8(%rdi) + movq %r14,16(%rdi) + movq %r15,24(%rdi) + leaq 32(%rdi),%rdi + incq %rcx + jnz L$sqr8x_sub + + sbbq $0,%rax + leaq (%rbx,%r9,1),%rbx + leaq (%rdi,%r9,1),%rdi + +.byte 102,72,15,110,200 + pxor %xmm0,%xmm0 + pshufd $0,%xmm1,%xmm1 + movq 40(%rsp),%rsi + + jmp L$sqr8x_cond_copy + +.p2align 5 +L$sqr8x_cond_copy: + movdqa 0(%rbx),%xmm2 + movdqa 16(%rbx),%xmm3 + leaq 32(%rbx),%rbx + movdqu 0(%rdi),%xmm4 + movdqu 16(%rdi),%xmm5 + leaq 32(%rdi),%rdi + movdqa %xmm0,-32(%rbx) + movdqa %xmm0,-16(%rbx) + movdqa %xmm0,-32(%rbx,%rdx,1) + movdqa %xmm0,-16(%rbx,%rdx,1) + pcmpeqd %xmm1,%xmm0 + pand %xmm1,%xmm2 + pand %xmm1,%xmm3 + pand %xmm0,%xmm4 + pand %xmm0,%xmm5 + pxor %xmm0,%xmm0 + por %xmm2,%xmm4 + por %xmm3,%xmm5 + movdqu %xmm4,-32(%rdi) + movdqu %xmm5,-16(%rdi) + addq $32,%r9 + jnz L$sqr8x_cond_copy + + movq $1,%rax + movq -48(%rsi),%r15 + + movq -40(%rsi),%r14 + + movq -32(%rsi),%r13 + + movq -24(%rsi),%r12 + + movq -16(%rsi),%rbp + + movq -8(%rsi),%rbx + + leaq (%rsi),%rsp + +L$sqr8x_epilogue: + ret + + +.globl _bn_mulx4x_mont +.private_extern _bn_mulx4x_mont + +.p2align 5 +_bn_mulx4x_mont: + +_CET_ENDBR + movq %rsp,%rax + + pushq %rbx + + pushq %rbp + + pushq %r12 + + pushq %r13 + + pushq %r14 + + pushq %r15 + +L$mulx4x_prologue: + + shll $3,%r9d + xorq %r10,%r10 + subq %r9,%r10 + movq (%r8),%r8 + leaq -72(%rsp,%r10,1),%rbp + andq $-128,%rbp + movq %rsp,%r11 + subq %rbp,%r11 + andq $-4096,%r11 + leaq (%r11,%rbp,1),%rsp + movq (%rsp),%r10 + cmpq %rbp,%rsp + ja L$mulx4x_page_walk + jmp L$mulx4x_page_walk_done + +.p2align 4 +L$mulx4x_page_walk: + leaq -4096(%rsp),%rsp + movq (%rsp),%r10 + cmpq %rbp,%rsp + ja L$mulx4x_page_walk +L$mulx4x_page_walk_done: + + leaq (%rdx,%r9,1),%r10 + + + + + + + + + + + + + movq %r9,0(%rsp) + shrq $5,%r9 + movq %r10,16(%rsp) + subq $1,%r9 + movq %r8,24(%rsp) + movq %rdi,32(%rsp) + movq %rax,40(%rsp) + + movq %r9,48(%rsp) + jmp L$mulx4x_body + +.p2align 5 +L$mulx4x_body: + leaq 8(%rdx),%rdi + movq (%rdx),%rdx + leaq 64+32(%rsp),%rbx + movq %rdx,%r9 + + mulxq 0(%rsi),%r8,%rax + mulxq 8(%rsi),%r11,%r14 + addq %rax,%r11 + movq %rdi,8(%rsp) + mulxq 16(%rsi),%r12,%r13 + adcq %r14,%r12 + adcq $0,%r13 + + movq %r8,%rdi + imulq 24(%rsp),%r8 + xorq %rbp,%rbp + + mulxq 24(%rsi),%rax,%r14 + movq %r8,%rdx + leaq 32(%rsi),%rsi + adcxq %rax,%r13 + adcxq %rbp,%r14 + + mulxq 0(%rcx),%rax,%r10 + adcxq %rax,%rdi + adoxq %r11,%r10 + mulxq 8(%rcx),%rax,%r11 + adcxq %rax,%r10 + adoxq %r12,%r11 +.byte 0xc4,0x62,0xfb,0xf6,0xa1,0x10,0x00,0x00,0x00 + movq 48(%rsp),%rdi + movq %r10,-32(%rbx) + adcxq %rax,%r11 + adoxq %r13,%r12 + mulxq 24(%rcx),%rax,%r15 + movq %r9,%rdx + movq %r11,-24(%rbx) + adcxq %rax,%r12 + adoxq %rbp,%r15 + leaq 32(%rcx),%rcx + movq %r12,-16(%rbx) + + jmp L$mulx4x_1st + +.p2align 5 +L$mulx4x_1st: + adcxq %rbp,%r15 + mulxq 0(%rsi),%r10,%rax + adcxq %r14,%r10 + mulxq 8(%rsi),%r11,%r14 + adcxq %rax,%r11 + mulxq 16(%rsi),%r12,%rax + adcxq %r14,%r12 + mulxq 24(%rsi),%r13,%r14 +.byte 0x67,0x67 + movq %r8,%rdx + adcxq %rax,%r13 + adcxq %rbp,%r14 + leaq 32(%rsi),%rsi + leaq 32(%rbx),%rbx + + adoxq %r15,%r10 + mulxq 0(%rcx),%rax,%r15 + adcxq %rax,%r10 + adoxq %r15,%r11 + mulxq 8(%rcx),%rax,%r15 + adcxq %rax,%r11 + adoxq %r15,%r12 + mulxq 16(%rcx),%rax,%r15 + movq %r10,-40(%rbx) + adcxq %rax,%r12 + movq %r11,-32(%rbx) + adoxq %r15,%r13 + mulxq 24(%rcx),%rax,%r15 + movq %r9,%rdx + movq %r12,-24(%rbx) + adcxq %rax,%r13 + adoxq %rbp,%r15 + leaq 32(%rcx),%rcx + movq %r13,-16(%rbx) + + decq %rdi + jnz L$mulx4x_1st + + movq 0(%rsp),%rax + movq 8(%rsp),%rdi + adcq %rbp,%r15 + addq %r15,%r14 + sbbq %r15,%r15 + movq %r14,-8(%rbx) + jmp L$mulx4x_outer + +.p2align 5 +L$mulx4x_outer: + movq (%rdi),%rdx + leaq 8(%rdi),%rdi + subq %rax,%rsi + movq %r15,(%rbx) + leaq 64+32(%rsp),%rbx + subq %rax,%rcx + + mulxq 0(%rsi),%r8,%r11 + xorl %ebp,%ebp + movq %rdx,%r9 + mulxq 8(%rsi),%r14,%r12 + adoxq -32(%rbx),%r8 + adcxq %r14,%r11 + mulxq 16(%rsi),%r15,%r13 + adoxq -24(%rbx),%r11 + adcxq %r15,%r12 + adoxq -16(%rbx),%r12 + adcxq %rbp,%r13 + adoxq %rbp,%r13 + + movq %rdi,8(%rsp) + movq %r8,%r15 + imulq 24(%rsp),%r8 + xorl %ebp,%ebp + + mulxq 24(%rsi),%rax,%r14 + movq %r8,%rdx + adcxq %rax,%r13 + adoxq -8(%rbx),%r13 + adcxq %rbp,%r14 + leaq 32(%rsi),%rsi + adoxq %rbp,%r14 + + mulxq 0(%rcx),%rax,%r10 + adcxq %rax,%r15 + adoxq %r11,%r10 + mulxq 8(%rcx),%rax,%r11 + adcxq %rax,%r10 + adoxq %r12,%r11 + mulxq 16(%rcx),%rax,%r12 + movq %r10,-32(%rbx) + adcxq %rax,%r11 + adoxq %r13,%r12 + mulxq 24(%rcx),%rax,%r15 + movq %r9,%rdx + movq %r11,-24(%rbx) + leaq 32(%rcx),%rcx + adcxq %rax,%r12 + adoxq %rbp,%r15 + movq 48(%rsp),%rdi + movq %r12,-16(%rbx) + + jmp L$mulx4x_inner + +.p2align 5 +L$mulx4x_inner: + mulxq 0(%rsi),%r10,%rax + adcxq %rbp,%r15 + adoxq %r14,%r10 + mulxq 8(%rsi),%r11,%r14 + adcxq 0(%rbx),%r10 + adoxq %rax,%r11 + mulxq 16(%rsi),%r12,%rax + adcxq 8(%rbx),%r11 + adoxq %r14,%r12 + mulxq 24(%rsi),%r13,%r14 + movq %r8,%rdx + adcxq 16(%rbx),%r12 + adoxq %rax,%r13 + adcxq 24(%rbx),%r13 + adoxq %rbp,%r14 + leaq 32(%rsi),%rsi + leaq 32(%rbx),%rbx + adcxq %rbp,%r14 + + adoxq %r15,%r10 + mulxq 0(%rcx),%rax,%r15 + adcxq %rax,%r10 + adoxq %r15,%r11 + mulxq 8(%rcx),%rax,%r15 + adcxq %rax,%r11 + adoxq %r15,%r12 + mulxq 16(%rcx),%rax,%r15 + movq %r10,-40(%rbx) + adcxq %rax,%r12 + adoxq %r15,%r13 + mulxq 24(%rcx),%rax,%r15 + movq %r9,%rdx + movq %r11,-32(%rbx) + movq %r12,-24(%rbx) + adcxq %rax,%r13 + adoxq %rbp,%r15 + leaq 32(%rcx),%rcx + movq %r13,-16(%rbx) + + decq %rdi + jnz L$mulx4x_inner + + movq 0(%rsp),%rax + movq 8(%rsp),%rdi + adcq %rbp,%r15 + subq 0(%rbx),%rbp + adcq %r15,%r14 + sbbq %r15,%r15 + movq %r14,-8(%rbx) + + cmpq 16(%rsp),%rdi + jne L$mulx4x_outer + + leaq 64(%rsp),%rbx + subq %rax,%rcx + negq %r15 + movq %rax,%rdx + shrq $3+2,%rax + movq 32(%rsp),%rdi + jmp L$mulx4x_sub + +.p2align 5 +L$mulx4x_sub: + movq 0(%rbx),%r11 + movq 8(%rbx),%r12 + movq 16(%rbx),%r13 + movq 24(%rbx),%r14 + leaq 32(%rbx),%rbx + sbbq 0(%rcx),%r11 + sbbq 8(%rcx),%r12 + sbbq 16(%rcx),%r13 + sbbq 24(%rcx),%r14 + leaq 32(%rcx),%rcx + movq %r11,0(%rdi) + movq %r12,8(%rdi) + movq %r13,16(%rdi) + movq %r14,24(%rdi) + leaq 32(%rdi),%rdi + decq %rax + jnz L$mulx4x_sub + + sbbq $0,%r15 + leaq 64(%rsp),%rbx + subq %rdx,%rdi + +.byte 102,73,15,110,207 + pxor %xmm0,%xmm0 + pshufd $0,%xmm1,%xmm1 + movq 40(%rsp),%rsi + + jmp L$mulx4x_cond_copy + +.p2align 5 +L$mulx4x_cond_copy: + movdqa 0(%rbx),%xmm2 + movdqa 16(%rbx),%xmm3 + leaq 32(%rbx),%rbx + movdqu 0(%rdi),%xmm4 + movdqu 16(%rdi),%xmm5 + leaq 32(%rdi),%rdi + movdqa %xmm0,-32(%rbx) + movdqa %xmm0,-16(%rbx) + pcmpeqd %xmm1,%xmm0 + pand %xmm1,%xmm2 + pand %xmm1,%xmm3 + pand %xmm0,%xmm4 + pand %xmm0,%xmm5 + pxor %xmm0,%xmm0 + por %xmm2,%xmm4 + por %xmm3,%xmm5 + movdqu %xmm4,-32(%rdi) + movdqu %xmm5,-16(%rdi) + subq $32,%rdx + jnz L$mulx4x_cond_copy + + movq %rdx,(%rbx) + + movq $1,%rax + movq -48(%rsi),%r15 + + movq -40(%rsi),%r14 + + movq -32(%rsi),%r13 + + movq -24(%rsi),%r12 + + movq -16(%rsi),%rbp + + movq -8(%rsi),%rbx + + leaq (%rsi),%rsp + +L$mulx4x_epilogue: + ret + + +.byte 77,111,110,116,103,111,109,101,114,121,32,77,117,108,116,105,112,108,105,99,97,116,105,111,110,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.p2align 4 +#endif diff --git a/http/vendor/ring/pregenerated/x86_64-mont-nasm.asm b/http/vendor/ring/pregenerated/x86_64-mont-nasm.asm new file mode 100644 index 0000000..361eace --- /dev/null +++ b/http/vendor/ring/pregenerated/x86_64-mont-nasm.asm @@ -0,0 +1,1468 @@ +; This file is generated from a similarly-named Perl script in the BoringSSL +; source tree. Do not edit by hand. + +%ifidn __OUTPUT_FORMAT__, win64 +default rel +%define XMMWORD +%define YMMWORD +%define ZMMWORD +%define _CET_ENDBR + +%include "ring_core_generated/prefix_symbols_nasm.inc" +section .text code align=64 + + +global bn_mul_mont_nohw + +ALIGN 16 +bn_mul_mont_nohw: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_bn_mul_mont_nohw: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + mov rcx,r9 + mov r8,QWORD[40+rsp] + mov r9,QWORD[48+rsp] + + + +_CET_ENDBR + mov r9d,r9d + mov rax,rsp + + push rbx + + push rbp + + push r12 + + push r13 + + push r14 + + push r15 + + + neg r9 + mov r11,rsp + lea r10,[((-16))+r9*8+rsp] + neg r9 + and r10,-1024 + + + + + + + + + + sub r11,r10 + and r11,-4096 + lea rsp,[r11*1+r10] + mov r11,QWORD[rsp] + cmp rsp,r10 + ja NEAR $L$mul_page_walk + jmp NEAR $L$mul_page_walk_done + +ALIGN 16 +$L$mul_page_walk: + lea rsp,[((-4096))+rsp] + mov r11,QWORD[rsp] + cmp rsp,r10 + ja NEAR $L$mul_page_walk +$L$mul_page_walk_done: + + mov QWORD[8+r9*8+rsp],rax + +$L$mul_body: + mov r12,rdx + mov r8,QWORD[r8] + mov rbx,QWORD[r12] + mov rax,QWORD[rsi] + + xor r14,r14 + xor r15,r15 + + mov rbp,r8 + mul rbx + mov r10,rax + mov rax,QWORD[rcx] + + imul rbp,r10 + mov r11,rdx + + mul rbp + add r10,rax + mov rax,QWORD[8+rsi] + adc rdx,0 + mov r13,rdx + + lea r15,[1+r15] + jmp NEAR $L$1st_enter + +ALIGN 16 +$L$1st: + add r13,rax + mov rax,QWORD[r15*8+rsi] + adc rdx,0 + add r13,r11 + mov r11,r10 + adc rdx,0 + mov QWORD[((-16))+r15*8+rsp],r13 + mov r13,rdx + +$L$1st_enter: + mul rbx + add r11,rax + mov rax,QWORD[r15*8+rcx] + adc rdx,0 + lea r15,[1+r15] + mov r10,rdx + + mul rbp + cmp r15,r9 + jne NEAR $L$1st + + add r13,rax + mov rax,QWORD[rsi] + adc rdx,0 + add r13,r11 + adc rdx,0 + mov QWORD[((-16))+r15*8+rsp],r13 + mov r13,rdx + mov r11,r10 + + xor rdx,rdx + add r13,r11 + adc rdx,0 + mov QWORD[((-8))+r9*8+rsp],r13 + mov QWORD[r9*8+rsp],rdx + + lea r14,[1+r14] + jmp NEAR $L$outer +ALIGN 16 +$L$outer: + mov rbx,QWORD[r14*8+r12] + xor r15,r15 + mov rbp,r8 + mov r10,QWORD[rsp] + mul rbx + add r10,rax + mov rax,QWORD[rcx] + adc rdx,0 + + imul rbp,r10 + mov r11,rdx + + mul rbp + add r10,rax + mov rax,QWORD[8+rsi] + adc rdx,0 + mov r10,QWORD[8+rsp] + mov r13,rdx + + lea r15,[1+r15] + jmp NEAR $L$inner_enter + +ALIGN 16 +$L$inner: + add r13,rax + mov rax,QWORD[r15*8+rsi] + adc rdx,0 + add r13,r10 + mov r10,QWORD[r15*8+rsp] + adc rdx,0 + mov QWORD[((-16))+r15*8+rsp],r13 + mov r13,rdx + +$L$inner_enter: + mul rbx + add r11,rax + mov rax,QWORD[r15*8+rcx] + adc rdx,0 + add r10,r11 + mov r11,rdx + adc r11,0 + lea r15,[1+r15] + + mul rbp + cmp r15,r9 + jne NEAR $L$inner + + add r13,rax + mov rax,QWORD[rsi] + adc rdx,0 + add r13,r10 + mov r10,QWORD[r15*8+rsp] + adc rdx,0 + mov QWORD[((-16))+r15*8+rsp],r13 + mov r13,rdx + + xor rdx,rdx + add r13,r11 + adc rdx,0 + add r13,r10 + adc rdx,0 + mov QWORD[((-8))+r9*8+rsp],r13 + mov QWORD[r9*8+rsp],rdx + + lea r14,[1+r14] + cmp r14,r9 + jb NEAR $L$outer + + xor r14,r14 + mov rax,QWORD[rsp] + mov r15,r9 + +ALIGN 16 +$L$sub: sbb rax,QWORD[r14*8+rcx] + mov QWORD[r14*8+rdi],rax + mov rax,QWORD[8+r14*8+rsp] + lea r14,[1+r14] + dec r15 + jnz NEAR $L$sub + + sbb rax,0 + mov rbx,-1 + xor rbx,rax + xor r14,r14 + mov r15,r9 + +$L$copy: + mov rcx,QWORD[r14*8+rdi] + mov rdx,QWORD[r14*8+rsp] + and rcx,rbx + and rdx,rax + mov QWORD[r14*8+rsp],r9 + or rdx,rcx + mov QWORD[r14*8+rdi],rdx + lea r14,[1+r14] + sub r15,1 + jnz NEAR $L$copy + + mov rsi,QWORD[8+r9*8+rsp] + + mov rax,1 + mov r15,QWORD[((-48))+rsi] + + mov r14,QWORD[((-40))+rsi] + + mov r13,QWORD[((-32))+rsi] + + mov r12,QWORD[((-24))+rsi] + + mov rbp,QWORD[((-16))+rsi] + + mov rbx,QWORD[((-8))+rsi] + + lea rsp,[rsi] + +$L$mul_epilogue: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_bn_mul_mont_nohw: +global bn_mul4x_mont + +ALIGN 16 +bn_mul4x_mont: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_bn_mul4x_mont: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + mov rcx,r9 + mov r8,QWORD[40+rsp] + mov r9,QWORD[48+rsp] + + + +_CET_ENDBR + mov r9d,r9d + mov rax,rsp + + push rbx + + push rbp + + push r12 + + push r13 + + push r14 + + push r15 + + + neg r9 + mov r11,rsp + lea r10,[((-32))+r9*8+rsp] + neg r9 + and r10,-1024 + + sub r11,r10 + and r11,-4096 + lea rsp,[r11*1+r10] + mov r11,QWORD[rsp] + cmp rsp,r10 + ja NEAR $L$mul4x_page_walk + jmp NEAR $L$mul4x_page_walk_done + +$L$mul4x_page_walk: + lea rsp,[((-4096))+rsp] + mov r11,QWORD[rsp] + cmp rsp,r10 + ja NEAR $L$mul4x_page_walk +$L$mul4x_page_walk_done: + + mov QWORD[8+r9*8+rsp],rax + +$L$mul4x_body: + mov QWORD[16+r9*8+rsp],rdi + mov r12,rdx + mov r8,QWORD[r8] + mov rbx,QWORD[r12] + mov rax,QWORD[rsi] + + xor r14,r14 + xor r15,r15 + + mov rbp,r8 + mul rbx + mov r10,rax + mov rax,QWORD[rcx] + + imul rbp,r10 + mov r11,rdx + + mul rbp + add r10,rax + mov rax,QWORD[8+rsi] + adc rdx,0 + mov rdi,rdx + + mul rbx + add r11,rax + mov rax,QWORD[8+rcx] + adc rdx,0 + mov r10,rdx + + mul rbp + add rdi,rax + mov rax,QWORD[16+rsi] + adc rdx,0 + add rdi,r11 + lea r15,[4+r15] + adc rdx,0 + mov QWORD[rsp],rdi + mov r13,rdx + jmp NEAR $L$1st4x +ALIGN 16 +$L$1st4x: + mul rbx + add r10,rax + mov rax,QWORD[((-16))+r15*8+rcx] + adc rdx,0 + mov r11,rdx + + mul rbp + add r13,rax + mov rax,QWORD[((-8))+r15*8+rsi] + adc rdx,0 + add r13,r10 + adc rdx,0 + mov QWORD[((-24))+r15*8+rsp],r13 + mov rdi,rdx + + mul rbx + add r11,rax + mov rax,QWORD[((-8))+r15*8+rcx] + adc rdx,0 + mov r10,rdx + + mul rbp + add rdi,rax + mov rax,QWORD[r15*8+rsi] + adc rdx,0 + add rdi,r11 + adc rdx,0 + mov QWORD[((-16))+r15*8+rsp],rdi + mov r13,rdx + + mul rbx + add r10,rax + mov rax,QWORD[r15*8+rcx] + adc rdx,0 + mov r11,rdx + + mul rbp + add r13,rax + mov rax,QWORD[8+r15*8+rsi] + adc rdx,0 + add r13,r10 + adc rdx,0 + mov QWORD[((-8))+r15*8+rsp],r13 + mov rdi,rdx + + mul rbx + add r11,rax + mov rax,QWORD[8+r15*8+rcx] + adc rdx,0 + lea r15,[4+r15] + mov r10,rdx + + mul rbp + add rdi,rax + mov rax,QWORD[((-16))+r15*8+rsi] + adc rdx,0 + add rdi,r11 + adc rdx,0 + mov QWORD[((-32))+r15*8+rsp],rdi + mov r13,rdx + cmp r15,r9 + jb NEAR $L$1st4x + + mul rbx + add r10,rax + mov rax,QWORD[((-16))+r15*8+rcx] + adc rdx,0 + mov r11,rdx + + mul rbp + add r13,rax + mov rax,QWORD[((-8))+r15*8+rsi] + adc rdx,0 + add r13,r10 + adc rdx,0 + mov QWORD[((-24))+r15*8+rsp],r13 + mov rdi,rdx + + mul rbx + add r11,rax + mov rax,QWORD[((-8))+r15*8+rcx] + adc rdx,0 + mov r10,rdx + + mul rbp + add rdi,rax + mov rax,QWORD[rsi] + adc rdx,0 + add rdi,r11 + adc rdx,0 + mov QWORD[((-16))+r15*8+rsp],rdi + mov r13,rdx + + xor rdi,rdi + add r13,r10 + adc rdi,0 + mov QWORD[((-8))+r15*8+rsp],r13 + mov QWORD[r15*8+rsp],rdi + + lea r14,[1+r14] +ALIGN 4 +$L$outer4x: + mov rbx,QWORD[r14*8+r12] + xor r15,r15 + mov r10,QWORD[rsp] + mov rbp,r8 + mul rbx + add r10,rax + mov rax,QWORD[rcx] + adc rdx,0 + + imul rbp,r10 + mov r11,rdx + + mul rbp + add r10,rax + mov rax,QWORD[8+rsi] + adc rdx,0 + mov rdi,rdx + + mul rbx + add r11,rax + mov rax,QWORD[8+rcx] + adc rdx,0 + add r11,QWORD[8+rsp] + adc rdx,0 + mov r10,rdx + + mul rbp + add rdi,rax + mov rax,QWORD[16+rsi] + adc rdx,0 + add rdi,r11 + lea r15,[4+r15] + adc rdx,0 + mov QWORD[rsp],rdi + mov r13,rdx + jmp NEAR $L$inner4x +ALIGN 16 +$L$inner4x: + mul rbx + add r10,rax + mov rax,QWORD[((-16))+r15*8+rcx] + adc rdx,0 + add r10,QWORD[((-16))+r15*8+rsp] + adc rdx,0 + mov r11,rdx + + mul rbp + add r13,rax + mov rax,QWORD[((-8))+r15*8+rsi] + adc rdx,0 + add r13,r10 + adc rdx,0 + mov QWORD[((-24))+r15*8+rsp],r13 + mov rdi,rdx + + mul rbx + add r11,rax + mov rax,QWORD[((-8))+r15*8+rcx] + adc rdx,0 + add r11,QWORD[((-8))+r15*8+rsp] + adc rdx,0 + mov r10,rdx + + mul rbp + add rdi,rax + mov rax,QWORD[r15*8+rsi] + adc rdx,0 + add rdi,r11 + adc rdx,0 + mov QWORD[((-16))+r15*8+rsp],rdi + mov r13,rdx + + mul rbx + add r10,rax + mov rax,QWORD[r15*8+rcx] + adc rdx,0 + add r10,QWORD[r15*8+rsp] + adc rdx,0 + mov r11,rdx + + mul rbp + add r13,rax + mov rax,QWORD[8+r15*8+rsi] + adc rdx,0 + add r13,r10 + adc rdx,0 + mov QWORD[((-8))+r15*8+rsp],r13 + mov rdi,rdx + + mul rbx + add r11,rax + mov rax,QWORD[8+r15*8+rcx] + adc rdx,0 + add r11,QWORD[8+r15*8+rsp] + adc rdx,0 + lea r15,[4+r15] + mov r10,rdx + + mul rbp + add rdi,rax + mov rax,QWORD[((-16))+r15*8+rsi] + adc rdx,0 + add rdi,r11 + adc rdx,0 + mov QWORD[((-32))+r15*8+rsp],rdi + mov r13,rdx + cmp r15,r9 + jb NEAR $L$inner4x + + mul rbx + add r10,rax + mov rax,QWORD[((-16))+r15*8+rcx] + adc rdx,0 + add r10,QWORD[((-16))+r15*8+rsp] + adc rdx,0 + mov r11,rdx + + mul rbp + add r13,rax + mov rax,QWORD[((-8))+r15*8+rsi] + adc rdx,0 + add r13,r10 + adc rdx,0 + mov QWORD[((-24))+r15*8+rsp],r13 + mov rdi,rdx + + mul rbx + add r11,rax + mov rax,QWORD[((-8))+r15*8+rcx] + adc rdx,0 + add r11,QWORD[((-8))+r15*8+rsp] + adc rdx,0 + lea r14,[1+r14] + mov r10,rdx + + mul rbp + add rdi,rax + mov rax,QWORD[rsi] + adc rdx,0 + add rdi,r11 + adc rdx,0 + mov QWORD[((-16))+r15*8+rsp],rdi + mov r13,rdx + + xor rdi,rdi + add r13,r10 + adc rdi,0 + add r13,QWORD[r9*8+rsp] + adc rdi,0 + mov QWORD[((-8))+r15*8+rsp],r13 + mov QWORD[r15*8+rsp],rdi + + cmp r14,r9 + jb NEAR $L$outer4x + mov rdi,QWORD[16+r9*8+rsp] + lea r15,[((-4))+r9] + mov rax,QWORD[rsp] + mov rdx,QWORD[8+rsp] + shr r15,2 + lea rsi,[rsp] + xor r14,r14 + + sub rax,QWORD[rcx] + mov rbx,QWORD[16+rsi] + mov rbp,QWORD[24+rsi] + sbb rdx,QWORD[8+rcx] + +$L$sub4x: + mov QWORD[r14*8+rdi],rax + mov QWORD[8+r14*8+rdi],rdx + sbb rbx,QWORD[16+r14*8+rcx] + mov rax,QWORD[32+r14*8+rsi] + mov rdx,QWORD[40+r14*8+rsi] + sbb rbp,QWORD[24+r14*8+rcx] + mov QWORD[16+r14*8+rdi],rbx + mov QWORD[24+r14*8+rdi],rbp + sbb rax,QWORD[32+r14*8+rcx] + mov rbx,QWORD[48+r14*8+rsi] + mov rbp,QWORD[56+r14*8+rsi] + sbb rdx,QWORD[40+r14*8+rcx] + lea r14,[4+r14] + dec r15 + jnz NEAR $L$sub4x + + mov QWORD[r14*8+rdi],rax + mov rax,QWORD[32+r14*8+rsi] + sbb rbx,QWORD[16+r14*8+rcx] + mov QWORD[8+r14*8+rdi],rdx + sbb rbp,QWORD[24+r14*8+rcx] + mov QWORD[16+r14*8+rdi],rbx + + sbb rax,0 + mov QWORD[24+r14*8+rdi],rbp + pxor xmm0,xmm0 +DB 102,72,15,110,224 + pcmpeqd xmm5,xmm5 + pshufd xmm4,xmm4,0 + mov r15,r9 + pxor xmm5,xmm4 + shr r15,2 + xor eax,eax + + jmp NEAR $L$copy4x +ALIGN 16 +$L$copy4x: + movdqa xmm1,XMMWORD[rax*1+rsp] + movdqu xmm2,XMMWORD[rax*1+rdi] + pand xmm1,xmm4 + pand xmm2,xmm5 + movdqa xmm3,XMMWORD[16+rax*1+rsp] + movdqa XMMWORD[rax*1+rsp],xmm0 + por xmm1,xmm2 + movdqu xmm2,XMMWORD[16+rax*1+rdi] + movdqu XMMWORD[rax*1+rdi],xmm1 + pand xmm3,xmm4 + pand xmm2,xmm5 + movdqa XMMWORD[16+rax*1+rsp],xmm0 + por xmm3,xmm2 + movdqu XMMWORD[16+rax*1+rdi],xmm3 + lea rax,[32+rax] + dec r15 + jnz NEAR $L$copy4x + mov rsi,QWORD[8+r9*8+rsp] + + mov rax,1 + mov r15,QWORD[((-48))+rsi] + + mov r14,QWORD[((-40))+rsi] + + mov r13,QWORD[((-32))+rsi] + + mov r12,QWORD[((-24))+rsi] + + mov rbp,QWORD[((-16))+rsi] + + mov rbx,QWORD[((-8))+rsi] + + lea rsp,[rsi] + +$L$mul4x_epilogue: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_bn_mul4x_mont: +EXTERN bn_sqrx8x_internal +EXTERN bn_sqr8x_internal + +global bn_sqr8x_mont + +ALIGN 32 +bn_sqr8x_mont: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_bn_sqr8x_mont: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + mov rcx,r9 + mov r8,QWORD[40+rsp] + mov r9,QWORD[48+rsp] + + + +_CET_ENDBR + mov r9d,r9d + mov rax,rsp + + push rbx + + push rbp + + push r12 + + push r13 + + push r14 + + push r15 + +$L$sqr8x_prologue: + + mov r10d,r9d + shl r9d,3 + shl r10,3+2 + neg r9 + + + + + + + lea r11,[((-64))+r9*2+rsp] + mov rbp,rsp + mov r8,QWORD[r8] + sub r11,rsi + and r11,4095 + cmp r10,r11 + jb NEAR $L$sqr8x_sp_alt + sub rbp,r11 + lea rbp,[((-64))+r9*2+rbp] + jmp NEAR $L$sqr8x_sp_done + +ALIGN 32 +$L$sqr8x_sp_alt: + lea r10,[((4096-64))+r9*2] + lea rbp,[((-64))+r9*2+rbp] + sub r11,r10 + mov r10,0 + cmovc r11,r10 + sub rbp,r11 +$L$sqr8x_sp_done: + and rbp,-64 + mov r11,rsp + sub r11,rbp + and r11,-4096 + lea rsp,[rbp*1+r11] + mov r10,QWORD[rsp] + cmp rsp,rbp + ja NEAR $L$sqr8x_page_walk + jmp NEAR $L$sqr8x_page_walk_done + +ALIGN 16 +$L$sqr8x_page_walk: + lea rsp,[((-4096))+rsp] + mov r10,QWORD[rsp] + cmp rsp,rbp + ja NEAR $L$sqr8x_page_walk +$L$sqr8x_page_walk_done: + + mov r10,r9 + neg r9 + + mov QWORD[32+rsp],r8 + mov QWORD[40+rsp],rax + +$L$sqr8x_body: + +DB 102,72,15,110,209 + pxor xmm0,xmm0 +DB 102,72,15,110,207 +DB 102,73,15,110,218 + test rdx,rdx + jz NEAR $L$sqr8x_nox + + call bn_sqrx8x_internal + + + + + lea rbx,[rcx*1+r8] + mov r9,rcx + mov rdx,rcx +DB 102,72,15,126,207 + sar rcx,3+2 + jmp NEAR $L$sqr8x_sub + +ALIGN 32 +$L$sqr8x_nox: + call bn_sqr8x_internal + + + + + lea rbx,[r9*1+rdi] + mov rcx,r9 + mov rdx,r9 +DB 102,72,15,126,207 + sar rcx,3+2 + jmp NEAR $L$sqr8x_sub + +ALIGN 32 +$L$sqr8x_sub: + mov r12,QWORD[rbx] + mov r13,QWORD[8+rbx] + mov r14,QWORD[16+rbx] + mov r15,QWORD[24+rbx] + lea rbx,[32+rbx] + sbb r12,QWORD[rbp] + sbb r13,QWORD[8+rbp] + sbb r14,QWORD[16+rbp] + sbb r15,QWORD[24+rbp] + lea rbp,[32+rbp] + mov QWORD[rdi],r12 + mov QWORD[8+rdi],r13 + mov QWORD[16+rdi],r14 + mov QWORD[24+rdi],r15 + lea rdi,[32+rdi] + inc rcx + jnz NEAR $L$sqr8x_sub + + sbb rax,0 + lea rbx,[r9*1+rbx] + lea rdi,[r9*1+rdi] + +DB 102,72,15,110,200 + pxor xmm0,xmm0 + pshufd xmm1,xmm1,0 + mov rsi,QWORD[40+rsp] + + jmp NEAR $L$sqr8x_cond_copy + +ALIGN 32 +$L$sqr8x_cond_copy: + movdqa xmm2,XMMWORD[rbx] + movdqa xmm3,XMMWORD[16+rbx] + lea rbx,[32+rbx] + movdqu xmm4,XMMWORD[rdi] + movdqu xmm5,XMMWORD[16+rdi] + lea rdi,[32+rdi] + movdqa XMMWORD[(-32)+rbx],xmm0 + movdqa XMMWORD[(-16)+rbx],xmm0 + movdqa XMMWORD[(-32)+rdx*1+rbx],xmm0 + movdqa XMMWORD[(-16)+rdx*1+rbx],xmm0 + pcmpeqd xmm0,xmm1 + pand xmm2,xmm1 + pand xmm3,xmm1 + pand xmm4,xmm0 + pand xmm5,xmm0 + pxor xmm0,xmm0 + por xmm4,xmm2 + por xmm5,xmm3 + movdqu XMMWORD[(-32)+rdi],xmm4 + movdqu XMMWORD[(-16)+rdi],xmm5 + add r9,32 + jnz NEAR $L$sqr8x_cond_copy + + mov rax,1 + mov r15,QWORD[((-48))+rsi] + + mov r14,QWORD[((-40))+rsi] + + mov r13,QWORD[((-32))+rsi] + + mov r12,QWORD[((-24))+rsi] + + mov rbp,QWORD[((-16))+rsi] + + mov rbx,QWORD[((-8))+rsi] + + lea rsp,[rsi] + +$L$sqr8x_epilogue: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_bn_sqr8x_mont: +global bn_mulx4x_mont + +ALIGN 32 +bn_mulx4x_mont: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_bn_mulx4x_mont: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + mov rcx,r9 + mov r8,QWORD[40+rsp] + mov r9,QWORD[48+rsp] + + + +_CET_ENDBR + mov rax,rsp + + push rbx + + push rbp + + push r12 + + push r13 + + push r14 + + push r15 + +$L$mulx4x_prologue: + + shl r9d,3 + xor r10,r10 + sub r10,r9 + mov r8,QWORD[r8] + lea rbp,[((-72))+r10*1+rsp] + and rbp,-128 + mov r11,rsp + sub r11,rbp + and r11,-4096 + lea rsp,[rbp*1+r11] + mov r10,QWORD[rsp] + cmp rsp,rbp + ja NEAR $L$mulx4x_page_walk + jmp NEAR $L$mulx4x_page_walk_done + +ALIGN 16 +$L$mulx4x_page_walk: + lea rsp,[((-4096))+rsp] + mov r10,QWORD[rsp] + cmp rsp,rbp + ja NEAR $L$mulx4x_page_walk +$L$mulx4x_page_walk_done: + + lea r10,[r9*1+rdx] + + + + + + + + + + + + + mov QWORD[rsp],r9 + shr r9,5 + mov QWORD[16+rsp],r10 + sub r9,1 + mov QWORD[24+rsp],r8 + mov QWORD[32+rsp],rdi + mov QWORD[40+rsp],rax + + mov QWORD[48+rsp],r9 + jmp NEAR $L$mulx4x_body + +ALIGN 32 +$L$mulx4x_body: + lea rdi,[8+rdx] + mov rdx,QWORD[rdx] + lea rbx,[((64+32))+rsp] + mov r9,rdx + + mulx rax,r8,QWORD[rsi] + mulx r14,r11,QWORD[8+rsi] + add r11,rax + mov QWORD[8+rsp],rdi + mulx r13,r12,QWORD[16+rsi] + adc r12,r14 + adc r13,0 + + mov rdi,r8 + imul r8,QWORD[24+rsp] + xor rbp,rbp + + mulx r14,rax,QWORD[24+rsi] + mov rdx,r8 + lea rsi,[32+rsi] + adcx r13,rax + adcx r14,rbp + + mulx r10,rax,QWORD[rcx] + adcx rdi,rax + adox r10,r11 + mulx r11,rax,QWORD[8+rcx] + adcx r10,rax + adox r11,r12 + DB 0xc4,0x62,0xfb,0xf6,0xa1,0x10,0x00,0x00,0x00 + mov rdi,QWORD[48+rsp] + mov QWORD[((-32))+rbx],r10 + adcx r11,rax + adox r12,r13 + mulx r15,rax,QWORD[24+rcx] + mov rdx,r9 + mov QWORD[((-24))+rbx],r11 + adcx r12,rax + adox r15,rbp + lea rcx,[32+rcx] + mov QWORD[((-16))+rbx],r12 + + jmp NEAR $L$mulx4x_1st + +ALIGN 32 +$L$mulx4x_1st: + adcx r15,rbp + mulx rax,r10,QWORD[rsi] + adcx r10,r14 + mulx r14,r11,QWORD[8+rsi] + adcx r11,rax + mulx rax,r12,QWORD[16+rsi] + adcx r12,r14 + mulx r14,r13,QWORD[24+rsi] + DB 0x67,0x67 + mov rdx,r8 + adcx r13,rax + adcx r14,rbp + lea rsi,[32+rsi] + lea rbx,[32+rbx] + + adox r10,r15 + mulx r15,rax,QWORD[rcx] + adcx r10,rax + adox r11,r15 + mulx r15,rax,QWORD[8+rcx] + adcx r11,rax + adox r12,r15 + mulx r15,rax,QWORD[16+rcx] + mov QWORD[((-40))+rbx],r10 + adcx r12,rax + mov QWORD[((-32))+rbx],r11 + adox r13,r15 + mulx r15,rax,QWORD[24+rcx] + mov rdx,r9 + mov QWORD[((-24))+rbx],r12 + adcx r13,rax + adox r15,rbp + lea rcx,[32+rcx] + mov QWORD[((-16))+rbx],r13 + + dec rdi + jnz NEAR $L$mulx4x_1st + + mov rax,QWORD[rsp] + mov rdi,QWORD[8+rsp] + adc r15,rbp + add r14,r15 + sbb r15,r15 + mov QWORD[((-8))+rbx],r14 + jmp NEAR $L$mulx4x_outer + +ALIGN 32 +$L$mulx4x_outer: + mov rdx,QWORD[rdi] + lea rdi,[8+rdi] + sub rsi,rax + mov QWORD[rbx],r15 + lea rbx,[((64+32))+rsp] + sub rcx,rax + + mulx r11,r8,QWORD[rsi] + xor ebp,ebp + mov r9,rdx + mulx r12,r14,QWORD[8+rsi] + adox r8,QWORD[((-32))+rbx] + adcx r11,r14 + mulx r13,r15,QWORD[16+rsi] + adox r11,QWORD[((-24))+rbx] + adcx r12,r15 + adox r12,QWORD[((-16))+rbx] + adcx r13,rbp + adox r13,rbp + + mov QWORD[8+rsp],rdi + mov r15,r8 + imul r8,QWORD[24+rsp] + xor ebp,ebp + + mulx r14,rax,QWORD[24+rsi] + mov rdx,r8 + adcx r13,rax + adox r13,QWORD[((-8))+rbx] + adcx r14,rbp + lea rsi,[32+rsi] + adox r14,rbp + + mulx r10,rax,QWORD[rcx] + adcx r15,rax + adox r10,r11 + mulx r11,rax,QWORD[8+rcx] + adcx r10,rax + adox r11,r12 + mulx r12,rax,QWORD[16+rcx] + mov QWORD[((-32))+rbx],r10 + adcx r11,rax + adox r12,r13 + mulx r15,rax,QWORD[24+rcx] + mov rdx,r9 + mov QWORD[((-24))+rbx],r11 + lea rcx,[32+rcx] + adcx r12,rax + adox r15,rbp + mov rdi,QWORD[48+rsp] + mov QWORD[((-16))+rbx],r12 + + jmp NEAR $L$mulx4x_inner + +ALIGN 32 +$L$mulx4x_inner: + mulx rax,r10,QWORD[rsi] + adcx r15,rbp + adox r10,r14 + mulx r14,r11,QWORD[8+rsi] + adcx r10,QWORD[rbx] + adox r11,rax + mulx rax,r12,QWORD[16+rsi] + adcx r11,QWORD[8+rbx] + adox r12,r14 + mulx r14,r13,QWORD[24+rsi] + mov rdx,r8 + adcx r12,QWORD[16+rbx] + adox r13,rax + adcx r13,QWORD[24+rbx] + adox r14,rbp + lea rsi,[32+rsi] + lea rbx,[32+rbx] + adcx r14,rbp + + adox r10,r15 + mulx r15,rax,QWORD[rcx] + adcx r10,rax + adox r11,r15 + mulx r15,rax,QWORD[8+rcx] + adcx r11,rax + adox r12,r15 + mulx r15,rax,QWORD[16+rcx] + mov QWORD[((-40))+rbx],r10 + adcx r12,rax + adox r13,r15 + mulx r15,rax,QWORD[24+rcx] + mov rdx,r9 + mov QWORD[((-32))+rbx],r11 + mov QWORD[((-24))+rbx],r12 + adcx r13,rax + adox r15,rbp + lea rcx,[32+rcx] + mov QWORD[((-16))+rbx],r13 + + dec rdi + jnz NEAR $L$mulx4x_inner + + mov rax,QWORD[rsp] + mov rdi,QWORD[8+rsp] + adc r15,rbp + sub rbp,QWORD[rbx] + adc r14,r15 + sbb r15,r15 + mov QWORD[((-8))+rbx],r14 + + cmp rdi,QWORD[16+rsp] + jne NEAR $L$mulx4x_outer + + lea rbx,[64+rsp] + sub rcx,rax + neg r15 + mov rdx,rax + shr rax,3+2 + mov rdi,QWORD[32+rsp] + jmp NEAR $L$mulx4x_sub + +ALIGN 32 +$L$mulx4x_sub: + mov r11,QWORD[rbx] + mov r12,QWORD[8+rbx] + mov r13,QWORD[16+rbx] + mov r14,QWORD[24+rbx] + lea rbx,[32+rbx] + sbb r11,QWORD[rcx] + sbb r12,QWORD[8+rcx] + sbb r13,QWORD[16+rcx] + sbb r14,QWORD[24+rcx] + lea rcx,[32+rcx] + mov QWORD[rdi],r11 + mov QWORD[8+rdi],r12 + mov QWORD[16+rdi],r13 + mov QWORD[24+rdi],r14 + lea rdi,[32+rdi] + dec rax + jnz NEAR $L$mulx4x_sub + + sbb r15,0 + lea rbx,[64+rsp] + sub rdi,rdx + +DB 102,73,15,110,207 + pxor xmm0,xmm0 + pshufd xmm1,xmm1,0 + mov rsi,QWORD[40+rsp] + + jmp NEAR $L$mulx4x_cond_copy + +ALIGN 32 +$L$mulx4x_cond_copy: + movdqa xmm2,XMMWORD[rbx] + movdqa xmm3,XMMWORD[16+rbx] + lea rbx,[32+rbx] + movdqu xmm4,XMMWORD[rdi] + movdqu xmm5,XMMWORD[16+rdi] + lea rdi,[32+rdi] + movdqa XMMWORD[(-32)+rbx],xmm0 + movdqa XMMWORD[(-16)+rbx],xmm0 + pcmpeqd xmm0,xmm1 + pand xmm2,xmm1 + pand xmm3,xmm1 + pand xmm4,xmm0 + pand xmm5,xmm0 + pxor xmm0,xmm0 + por xmm4,xmm2 + por xmm5,xmm3 + movdqu XMMWORD[(-32)+rdi],xmm4 + movdqu XMMWORD[(-16)+rdi],xmm5 + sub rdx,32 + jnz NEAR $L$mulx4x_cond_copy + + mov QWORD[rbx],rdx + + mov rax,1 + mov r15,QWORD[((-48))+rsi] + + mov r14,QWORD[((-40))+rsi] + + mov r13,QWORD[((-32))+rsi] + + mov r12,QWORD[((-24))+rsi] + + mov rbp,QWORD[((-16))+rsi] + + mov rbx,QWORD[((-8))+rsi] + + lea rsp,[rsi] + +$L$mulx4x_epilogue: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_bn_mulx4x_mont: + DB 77,111,110,116,103,111,109,101,114,121,32,77,117,108,116,105 + DB 112,108,105,99,97,116,105,111,110,32,102,111,114,32,120,56 + DB 54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83 + DB 32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115 + DB 115,108,46,111,114,103,62,0 +ALIGN 16 +EXTERN __imp_RtlVirtualUnwind + +ALIGN 16 +mul_handler: + push rsi + push rdi + push rbx + push rbp + push r12 + push r13 + push r14 + push r15 + pushfq + sub rsp,64 + + mov rax,QWORD[120+r8] + mov rbx,QWORD[248+r8] + + mov rsi,QWORD[8+r9] + mov r11,QWORD[56+r9] + + mov r10d,DWORD[r11] + lea r10,[r10*1+rsi] + cmp rbx,r10 + jb NEAR $L$common_seh_tail + + mov rax,QWORD[152+r8] + + mov r10d,DWORD[4+r11] + lea r10,[r10*1+rsi] + cmp rbx,r10 + jae NEAR $L$common_seh_tail + + mov r10,QWORD[192+r8] + mov rax,QWORD[8+r10*8+rax] + + jmp NEAR $L$common_pop_regs + + + +ALIGN 16 +sqr_handler: + push rsi + push rdi + push rbx + push rbp + push r12 + push r13 + push r14 + push r15 + pushfq + sub rsp,64 + + mov rax,QWORD[120+r8] + mov rbx,QWORD[248+r8] + + mov rsi,QWORD[8+r9] + mov r11,QWORD[56+r9] + + mov r10d,DWORD[r11] + lea r10,[r10*1+rsi] + cmp rbx,r10 + jb NEAR $L$common_seh_tail + + mov r10d,DWORD[4+r11] + lea r10,[r10*1+rsi] + cmp rbx,r10 + jb NEAR $L$common_pop_regs + + mov rax,QWORD[152+r8] + + mov r10d,DWORD[8+r11] + lea r10,[r10*1+rsi] + cmp rbx,r10 + jae NEAR $L$common_seh_tail + + mov rax,QWORD[40+rax] + +$L$common_pop_regs: + mov rbx,QWORD[((-8))+rax] + mov rbp,QWORD[((-16))+rax] + mov r12,QWORD[((-24))+rax] + mov r13,QWORD[((-32))+rax] + mov r14,QWORD[((-40))+rax] + mov r15,QWORD[((-48))+rax] + mov QWORD[144+r8],rbx + mov QWORD[160+r8],rbp + mov QWORD[216+r8],r12 + mov QWORD[224+r8],r13 + mov QWORD[232+r8],r14 + mov QWORD[240+r8],r15 + +$L$common_seh_tail: + mov rdi,QWORD[8+rax] + mov rsi,QWORD[16+rax] + mov QWORD[152+r8],rax + mov QWORD[168+r8],rsi + mov QWORD[176+r8],rdi + + mov rdi,QWORD[40+r9] + mov rsi,r8 + mov ecx,154 + DD 0xa548f3fc + + mov rsi,r9 + xor rcx,rcx + mov rdx,QWORD[8+rsi] + mov r8,QWORD[rsi] + mov r9,QWORD[16+rsi] + mov r10,QWORD[40+rsi] + lea r11,[56+rsi] + lea r12,[24+rsi] + mov QWORD[32+rsp],r10 + mov QWORD[40+rsp],r11 + mov QWORD[48+rsp],r12 + mov QWORD[56+rsp],rcx + call QWORD[__imp_RtlVirtualUnwind] + + mov eax,1 + add rsp,64 + popfq + pop r15 + pop r14 + pop r13 + pop r12 + pop rbp + pop rbx + pop rdi + pop rsi + ret + + +section .pdata rdata align=4 +ALIGN 4 + DD $L$SEH_begin_bn_mul_mont_nohw wrt ..imagebase + DD $L$SEH_end_bn_mul_mont_nohw wrt ..imagebase + DD $L$SEH_info_bn_mul_mont_nohw wrt ..imagebase + + DD $L$SEH_begin_bn_mul4x_mont wrt ..imagebase + DD $L$SEH_end_bn_mul4x_mont wrt ..imagebase + DD $L$SEH_info_bn_mul4x_mont wrt ..imagebase + + DD $L$SEH_begin_bn_sqr8x_mont wrt ..imagebase + DD $L$SEH_end_bn_sqr8x_mont wrt ..imagebase + DD $L$SEH_info_bn_sqr8x_mont wrt ..imagebase + DD $L$SEH_begin_bn_mulx4x_mont wrt ..imagebase + DD $L$SEH_end_bn_mulx4x_mont wrt ..imagebase + DD $L$SEH_info_bn_mulx4x_mont wrt ..imagebase +section .xdata rdata align=8 +ALIGN 8 +$L$SEH_info_bn_mul_mont_nohw: + DB 9,0,0,0 + DD mul_handler wrt ..imagebase + DD $L$mul_body wrt ..imagebase,$L$mul_epilogue wrt ..imagebase +$L$SEH_info_bn_mul4x_mont: + DB 9,0,0,0 + DD mul_handler wrt ..imagebase + DD $L$mul4x_body wrt ..imagebase,$L$mul4x_epilogue wrt ..imagebase +$L$SEH_info_bn_sqr8x_mont: + DB 9,0,0,0 + DD sqr_handler wrt ..imagebase + DD $L$sqr8x_prologue wrt ..imagebase,$L$sqr8x_body wrt ..imagebase,$L$sqr8x_epilogue wrt ..imagebase +ALIGN 8 +$L$SEH_info_bn_mulx4x_mont: + DB 9,0,0,0 + DD sqr_handler wrt ..imagebase + DD $L$mulx4x_prologue wrt ..imagebase,$L$mulx4x_body wrt ..imagebase,$L$mulx4x_epilogue wrt ..imagebase +ALIGN 8 +%else +; Work around https://bugzilla.nasm.us/show_bug.cgi?id=3392738 +ret +%endif diff --git a/http/vendor/ring/pregenerated/x86_64-mont-nasm.o b/http/vendor/ring/pregenerated/x86_64-mont-nasm.o new file mode 100644 index 0000000..211ade6 Binary files /dev/null and b/http/vendor/ring/pregenerated/x86_64-mont-nasm.o differ diff --git a/http/vendor/ring/pregenerated/x86_64-mont5-elf.S b/http/vendor/ring/pregenerated/x86_64-mont5-elf.S new file mode 100644 index 0000000..f202ea3 --- /dev/null +++ b/http/vendor/ring/pregenerated/x86_64-mont5-elf.S @@ -0,0 +1,3188 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__ELF__) +.text + +.globl bn_mul4x_mont_gather5 +.hidden bn_mul4x_mont_gather5 +.type bn_mul4x_mont_gather5,@function +.align 32 +bn_mul4x_mont_gather5: +.cfi_startproc +_CET_ENDBR +.byte 0x67 + movq %rsp,%rax +.cfi_def_cfa_register %rax + pushq %rbx +.cfi_offset %rbx,-16 + pushq %rbp +.cfi_offset %rbp,-24 + pushq %r12 +.cfi_offset %r12,-32 + pushq %r13 +.cfi_offset %r13,-40 + pushq %r14 +.cfi_offset %r14,-48 + pushq %r15 +.cfi_offset %r15,-56 +.Lmul4x_prologue: + +.byte 0x67 + + + + shll $3,%r9d + leaq (%r9,%r9,2),%r10 + negq %r9 + + + + + + + + + + + leaq -320(%rsp,%r9,2),%r11 + movq %rsp,%rbp + subq %rdi,%r11 + andq $4095,%r11 + cmpq %r11,%r10 + jb .Lmul4xsp_alt + subq %r11,%rbp + leaq -320(%rbp,%r9,2),%rbp + jmp .Lmul4xsp_done + +.align 32 +.Lmul4xsp_alt: + leaq 4096-320(,%r9,2),%r10 + leaq -320(%rbp,%r9,2),%rbp + subq %r10,%r11 + movq $0,%r10 + cmovcq %r10,%r11 + subq %r11,%rbp +.Lmul4xsp_done: + andq $-64,%rbp + movq %rsp,%r11 + subq %rbp,%r11 + andq $-4096,%r11 + leaq (%r11,%rbp,1),%rsp + movq (%rsp),%r10 + cmpq %rbp,%rsp + ja .Lmul4x_page_walk + jmp .Lmul4x_page_walk_done + +.Lmul4x_page_walk: + leaq -4096(%rsp),%rsp + movq (%rsp),%r10 + cmpq %rbp,%rsp + ja .Lmul4x_page_walk +.Lmul4x_page_walk_done: + + negq %r9 + + movq %rax,40(%rsp) +.cfi_escape 0x0f,0x05,0x77,0x28,0x06,0x23,0x08 +.Lmul4x_body: + + call mul4x_internal + + movq 40(%rsp),%rsi +.cfi_def_cfa %rsi,8 + movq $1,%rax + + movq -48(%rsi),%r15 +.cfi_restore %r15 + movq -40(%rsi),%r14 +.cfi_restore %r14 + movq -32(%rsi),%r13 +.cfi_restore %r13 + movq -24(%rsi),%r12 +.cfi_restore %r12 + movq -16(%rsi),%rbp +.cfi_restore %rbp + movq -8(%rsi),%rbx +.cfi_restore %rbx + leaq (%rsi),%rsp +.cfi_def_cfa_register %rsp +.Lmul4x_epilogue: + ret +.cfi_endproc +.size bn_mul4x_mont_gather5,.-bn_mul4x_mont_gather5 + +.type mul4x_internal,@function +.align 32 +mul4x_internal: +.cfi_startproc + shlq $5,%r9 + movd 8(%rax),%xmm5 + leaq .Linc(%rip),%rax + leaq 128(%rdx,%r9,1),%r13 + shrq $5,%r9 + movdqa 0(%rax),%xmm0 + movdqa 16(%rax),%xmm1 + leaq 88-112(%rsp,%r9,1),%r10 + leaq 128(%rdx),%r12 + + pshufd $0,%xmm5,%xmm5 + movdqa %xmm1,%xmm4 +.byte 0x67,0x67 + movdqa %xmm1,%xmm2 + paddd %xmm0,%xmm1 + pcmpeqd %xmm5,%xmm0 +.byte 0x67 + movdqa %xmm4,%xmm3 + paddd %xmm1,%xmm2 + pcmpeqd %xmm5,%xmm1 + movdqa %xmm0,112(%r10) + movdqa %xmm4,%xmm0 + + paddd %xmm2,%xmm3 + pcmpeqd %xmm5,%xmm2 + movdqa %xmm1,128(%r10) + movdqa %xmm4,%xmm1 + + paddd %xmm3,%xmm0 + pcmpeqd %xmm5,%xmm3 + movdqa %xmm2,144(%r10) + movdqa %xmm4,%xmm2 + + paddd %xmm0,%xmm1 + pcmpeqd %xmm5,%xmm0 + movdqa %xmm3,160(%r10) + movdqa %xmm4,%xmm3 + paddd %xmm1,%xmm2 + pcmpeqd %xmm5,%xmm1 + movdqa %xmm0,176(%r10) + movdqa %xmm4,%xmm0 + + paddd %xmm2,%xmm3 + pcmpeqd %xmm5,%xmm2 + movdqa %xmm1,192(%r10) + movdqa %xmm4,%xmm1 + + paddd %xmm3,%xmm0 + pcmpeqd %xmm5,%xmm3 + movdqa %xmm2,208(%r10) + movdqa %xmm4,%xmm2 + + paddd %xmm0,%xmm1 + pcmpeqd %xmm5,%xmm0 + movdqa %xmm3,224(%r10) + movdqa %xmm4,%xmm3 + paddd %xmm1,%xmm2 + pcmpeqd %xmm5,%xmm1 + movdqa %xmm0,240(%r10) + movdqa %xmm4,%xmm0 + + paddd %xmm2,%xmm3 + pcmpeqd %xmm5,%xmm2 + movdqa %xmm1,256(%r10) + movdqa %xmm4,%xmm1 + + paddd %xmm3,%xmm0 + pcmpeqd %xmm5,%xmm3 + movdqa %xmm2,272(%r10) + movdqa %xmm4,%xmm2 + + paddd %xmm0,%xmm1 + pcmpeqd %xmm5,%xmm0 + movdqa %xmm3,288(%r10) + movdqa %xmm4,%xmm3 + paddd %xmm1,%xmm2 + pcmpeqd %xmm5,%xmm1 + movdqa %xmm0,304(%r10) + + paddd %xmm2,%xmm3 +.byte 0x67 + pcmpeqd %xmm5,%xmm2 + movdqa %xmm1,320(%r10) + + pcmpeqd %xmm5,%xmm3 + movdqa %xmm2,336(%r10) + pand 64(%r12),%xmm0 + + pand 80(%r12),%xmm1 + pand 96(%r12),%xmm2 + movdqa %xmm3,352(%r10) + pand 112(%r12),%xmm3 + por %xmm2,%xmm0 + por %xmm3,%xmm1 + movdqa -128(%r12),%xmm4 + movdqa -112(%r12),%xmm5 + movdqa -96(%r12),%xmm2 + pand 112(%r10),%xmm4 + movdqa -80(%r12),%xmm3 + pand 128(%r10),%xmm5 + por %xmm4,%xmm0 + pand 144(%r10),%xmm2 + por %xmm5,%xmm1 + pand 160(%r10),%xmm3 + por %xmm2,%xmm0 + por %xmm3,%xmm1 + movdqa -64(%r12),%xmm4 + movdqa -48(%r12),%xmm5 + movdqa -32(%r12),%xmm2 + pand 176(%r10),%xmm4 + movdqa -16(%r12),%xmm3 + pand 192(%r10),%xmm5 + por %xmm4,%xmm0 + pand 208(%r10),%xmm2 + por %xmm5,%xmm1 + pand 224(%r10),%xmm3 + por %xmm2,%xmm0 + por %xmm3,%xmm1 + movdqa 0(%r12),%xmm4 + movdqa 16(%r12),%xmm5 + movdqa 32(%r12),%xmm2 + pand 240(%r10),%xmm4 + movdqa 48(%r12),%xmm3 + pand 256(%r10),%xmm5 + por %xmm4,%xmm0 + pand 272(%r10),%xmm2 + por %xmm5,%xmm1 + pand 288(%r10),%xmm3 + por %xmm2,%xmm0 + por %xmm3,%xmm1 + por %xmm1,%xmm0 + + pshufd $0x4e,%xmm0,%xmm1 + por %xmm1,%xmm0 + leaq 256(%r12),%r12 +.byte 102,72,15,126,195 + + movq %r13,16+8(%rsp) + movq %rdi,56+8(%rsp) + + movq (%r8),%r8 + movq (%rsi),%rax + leaq (%rsi,%r9,1),%rsi + negq %r9 + + movq %r8,%rbp + mulq %rbx + movq %rax,%r10 + movq (%rcx),%rax + + imulq %r10,%rbp + leaq 64+8(%rsp),%r14 + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r10 + movq 8(%rsi,%r9,1),%rax + adcq $0,%rdx + movq %rdx,%rdi + + mulq %rbx + addq %rax,%r11 + movq 8(%rcx),%rax + adcq $0,%rdx + movq %rdx,%r10 + + mulq %rbp + addq %rax,%rdi + movq 16(%rsi,%r9,1),%rax + adcq $0,%rdx + addq %r11,%rdi + leaq 32(%r9),%r15 + leaq 32(%rcx),%rcx + adcq $0,%rdx + movq %rdi,(%r14) + movq %rdx,%r13 + jmp .L1st4x + +.align 32 +.L1st4x: + mulq %rbx + addq %rax,%r10 + movq -16(%rcx),%rax + leaq 32(%r14),%r14 + adcq $0,%rdx + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r13 + movq -8(%rsi,%r15,1),%rax + adcq $0,%rdx + addq %r10,%r13 + adcq $0,%rdx + movq %r13,-24(%r14) + movq %rdx,%rdi + + mulq %rbx + addq %rax,%r11 + movq -8(%rcx),%rax + adcq $0,%rdx + movq %rdx,%r10 + + mulq %rbp + addq %rax,%rdi + movq (%rsi,%r15,1),%rax + adcq $0,%rdx + addq %r11,%rdi + adcq $0,%rdx + movq %rdi,-16(%r14) + movq %rdx,%r13 + + mulq %rbx + addq %rax,%r10 + movq 0(%rcx),%rax + adcq $0,%rdx + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r13 + movq 8(%rsi,%r15,1),%rax + adcq $0,%rdx + addq %r10,%r13 + adcq $0,%rdx + movq %r13,-8(%r14) + movq %rdx,%rdi + + mulq %rbx + addq %rax,%r11 + movq 8(%rcx),%rax + adcq $0,%rdx + movq %rdx,%r10 + + mulq %rbp + addq %rax,%rdi + movq 16(%rsi,%r15,1),%rax + adcq $0,%rdx + addq %r11,%rdi + leaq 32(%rcx),%rcx + adcq $0,%rdx + movq %rdi,(%r14) + movq %rdx,%r13 + + addq $32,%r15 + jnz .L1st4x + + mulq %rbx + addq %rax,%r10 + movq -16(%rcx),%rax + leaq 32(%r14),%r14 + adcq $0,%rdx + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r13 + movq -8(%rsi),%rax + adcq $0,%rdx + addq %r10,%r13 + adcq $0,%rdx + movq %r13,-24(%r14) + movq %rdx,%rdi + + mulq %rbx + addq %rax,%r11 + movq -8(%rcx),%rax + adcq $0,%rdx + movq %rdx,%r10 + + mulq %rbp + addq %rax,%rdi + movq (%rsi,%r9,1),%rax + adcq $0,%rdx + addq %r11,%rdi + adcq $0,%rdx + movq %rdi,-16(%r14) + movq %rdx,%r13 + + leaq (%rcx,%r9,1),%rcx + + xorq %rdi,%rdi + addq %r10,%r13 + adcq $0,%rdi + movq %r13,-8(%r14) + + jmp .Louter4x + +.align 32 +.Louter4x: + leaq 16+128(%r14),%rdx + pxor %xmm4,%xmm4 + pxor %xmm5,%xmm5 + movdqa -128(%r12),%xmm0 + movdqa -112(%r12),%xmm1 + movdqa -96(%r12),%xmm2 + movdqa -80(%r12),%xmm3 + pand -128(%rdx),%xmm0 + pand -112(%rdx),%xmm1 + por %xmm0,%xmm4 + pand -96(%rdx),%xmm2 + por %xmm1,%xmm5 + pand -80(%rdx),%xmm3 + por %xmm2,%xmm4 + por %xmm3,%xmm5 + movdqa -64(%r12),%xmm0 + movdqa -48(%r12),%xmm1 + movdqa -32(%r12),%xmm2 + movdqa -16(%r12),%xmm3 + pand -64(%rdx),%xmm0 + pand -48(%rdx),%xmm1 + por %xmm0,%xmm4 + pand -32(%rdx),%xmm2 + por %xmm1,%xmm5 + pand -16(%rdx),%xmm3 + por %xmm2,%xmm4 + por %xmm3,%xmm5 + movdqa 0(%r12),%xmm0 + movdqa 16(%r12),%xmm1 + movdqa 32(%r12),%xmm2 + movdqa 48(%r12),%xmm3 + pand 0(%rdx),%xmm0 + pand 16(%rdx),%xmm1 + por %xmm0,%xmm4 + pand 32(%rdx),%xmm2 + por %xmm1,%xmm5 + pand 48(%rdx),%xmm3 + por %xmm2,%xmm4 + por %xmm3,%xmm5 + movdqa 64(%r12),%xmm0 + movdqa 80(%r12),%xmm1 + movdqa 96(%r12),%xmm2 + movdqa 112(%r12),%xmm3 + pand 64(%rdx),%xmm0 + pand 80(%rdx),%xmm1 + por %xmm0,%xmm4 + pand 96(%rdx),%xmm2 + por %xmm1,%xmm5 + pand 112(%rdx),%xmm3 + por %xmm2,%xmm4 + por %xmm3,%xmm5 + por %xmm5,%xmm4 + + pshufd $0x4e,%xmm4,%xmm0 + por %xmm4,%xmm0 + leaq 256(%r12),%r12 +.byte 102,72,15,126,195 + + movq (%r14,%r9,1),%r10 + movq %r8,%rbp + mulq %rbx + addq %rax,%r10 + movq (%rcx),%rax + adcq $0,%rdx + + imulq %r10,%rbp + movq %rdx,%r11 + movq %rdi,(%r14) + + leaq (%r14,%r9,1),%r14 + + mulq %rbp + addq %rax,%r10 + movq 8(%rsi,%r9,1),%rax + adcq $0,%rdx + movq %rdx,%rdi + + mulq %rbx + addq %rax,%r11 + movq 8(%rcx),%rax + adcq $0,%rdx + addq 8(%r14),%r11 + adcq $0,%rdx + movq %rdx,%r10 + + mulq %rbp + addq %rax,%rdi + movq 16(%rsi,%r9,1),%rax + adcq $0,%rdx + addq %r11,%rdi + leaq 32(%r9),%r15 + leaq 32(%rcx),%rcx + adcq $0,%rdx + movq %rdx,%r13 + jmp .Linner4x + +.align 32 +.Linner4x: + mulq %rbx + addq %rax,%r10 + movq -16(%rcx),%rax + adcq $0,%rdx + addq 16(%r14),%r10 + leaq 32(%r14),%r14 + adcq $0,%rdx + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r13 + movq -8(%rsi,%r15,1),%rax + adcq $0,%rdx + addq %r10,%r13 + adcq $0,%rdx + movq %rdi,-32(%r14) + movq %rdx,%rdi + + mulq %rbx + addq %rax,%r11 + movq -8(%rcx),%rax + adcq $0,%rdx + addq -8(%r14),%r11 + adcq $0,%rdx + movq %rdx,%r10 + + mulq %rbp + addq %rax,%rdi + movq (%rsi,%r15,1),%rax + adcq $0,%rdx + addq %r11,%rdi + adcq $0,%rdx + movq %r13,-24(%r14) + movq %rdx,%r13 + + mulq %rbx + addq %rax,%r10 + movq 0(%rcx),%rax + adcq $0,%rdx + addq (%r14),%r10 + adcq $0,%rdx + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r13 + movq 8(%rsi,%r15,1),%rax + adcq $0,%rdx + addq %r10,%r13 + adcq $0,%rdx + movq %rdi,-16(%r14) + movq %rdx,%rdi + + mulq %rbx + addq %rax,%r11 + movq 8(%rcx),%rax + adcq $0,%rdx + addq 8(%r14),%r11 + adcq $0,%rdx + movq %rdx,%r10 + + mulq %rbp + addq %rax,%rdi + movq 16(%rsi,%r15,1),%rax + adcq $0,%rdx + addq %r11,%rdi + leaq 32(%rcx),%rcx + adcq $0,%rdx + movq %r13,-8(%r14) + movq %rdx,%r13 + + addq $32,%r15 + jnz .Linner4x + + mulq %rbx + addq %rax,%r10 + movq -16(%rcx),%rax + adcq $0,%rdx + addq 16(%r14),%r10 + leaq 32(%r14),%r14 + adcq $0,%rdx + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r13 + movq -8(%rsi),%rax + adcq $0,%rdx + addq %r10,%r13 + adcq $0,%rdx + movq %rdi,-32(%r14) + movq %rdx,%rdi + + mulq %rbx + addq %rax,%r11 + movq %rbp,%rax + movq -8(%rcx),%rbp + adcq $0,%rdx + addq -8(%r14),%r11 + adcq $0,%rdx + movq %rdx,%r10 + + mulq %rbp + addq %rax,%rdi + movq (%rsi,%r9,1),%rax + adcq $0,%rdx + addq %r11,%rdi + adcq $0,%rdx + movq %r13,-24(%r14) + movq %rdx,%r13 + + movq %rdi,-16(%r14) + leaq (%rcx,%r9,1),%rcx + + xorq %rdi,%rdi + addq %r10,%r13 + adcq $0,%rdi + addq (%r14),%r13 + adcq $0,%rdi + movq %r13,-8(%r14) + + cmpq 16+8(%rsp),%r12 + jb .Louter4x + xorq %rax,%rax + subq %r13,%rbp + adcq %r15,%r15 + orq %r15,%rdi + subq %rdi,%rax + leaq (%r14,%r9,1),%rbx + movq (%rcx),%r12 + leaq (%rcx),%rbp + movq %r9,%rcx + sarq $3+2,%rcx + movq 56+8(%rsp),%rdi + decq %r12 + xorq %r10,%r10 + movq 8(%rbp),%r13 + movq 16(%rbp),%r14 + movq 24(%rbp),%r15 + jmp .Lsqr4x_sub_entry +.cfi_endproc +.size mul4x_internal,.-mul4x_internal +.globl bn_power5_nohw +.hidden bn_power5_nohw +.type bn_power5_nohw,@function +.align 32 +bn_power5_nohw: +.cfi_startproc +_CET_ENDBR + movq %rsp,%rax +.cfi_def_cfa_register %rax + pushq %rbx +.cfi_offset %rbx,-16 + pushq %rbp +.cfi_offset %rbp,-24 + pushq %r12 +.cfi_offset %r12,-32 + pushq %r13 +.cfi_offset %r13,-40 + pushq %r14 +.cfi_offset %r14,-48 + pushq %r15 +.cfi_offset %r15,-56 +.Lpower5_prologue: + + + + + shll $3,%r9d + leal (%r9,%r9,2),%r10d + negq %r9 + movq (%r8),%r8 + + + + + + + + + leaq -320(%rsp,%r9,2),%r11 + movq %rsp,%rbp + subq %rdi,%r11 + andq $4095,%r11 + cmpq %r11,%r10 + jb .Lpwr_sp_alt + subq %r11,%rbp + leaq -320(%rbp,%r9,2),%rbp + jmp .Lpwr_sp_done + +.align 32 +.Lpwr_sp_alt: + leaq 4096-320(,%r9,2),%r10 + leaq -320(%rbp,%r9,2),%rbp + subq %r10,%r11 + movq $0,%r10 + cmovcq %r10,%r11 + subq %r11,%rbp +.Lpwr_sp_done: + andq $-64,%rbp + movq %rsp,%r11 + subq %rbp,%r11 + andq $-4096,%r11 + leaq (%r11,%rbp,1),%rsp + movq (%rsp),%r10 + cmpq %rbp,%rsp + ja .Lpwr_page_walk + jmp .Lpwr_page_walk_done + +.Lpwr_page_walk: + leaq -4096(%rsp),%rsp + movq (%rsp),%r10 + cmpq %rbp,%rsp + ja .Lpwr_page_walk +.Lpwr_page_walk_done: + + movq %r9,%r10 + negq %r9 + + + + + + + + + + + movq %r8,32(%rsp) + movq %rax,40(%rsp) +.cfi_escape 0x0f,0x05,0x77,0x28,0x06,0x23,0x08 +.Lpower5_body: +.byte 102,72,15,110,207 +.byte 102,72,15,110,209 +.byte 102,73,15,110,218 +.byte 102,72,15,110,226 + + call __bn_sqr8x_internal + call __bn_post4x_internal + call __bn_sqr8x_internal + call __bn_post4x_internal + call __bn_sqr8x_internal + call __bn_post4x_internal + call __bn_sqr8x_internal + call __bn_post4x_internal + call __bn_sqr8x_internal + call __bn_post4x_internal + +.byte 102,72,15,126,209 +.byte 102,72,15,126,226 + movq %rsi,%rdi + movq 40(%rsp),%rax + leaq 32(%rsp),%r8 + + call mul4x_internal + + movq 40(%rsp),%rsi +.cfi_def_cfa %rsi,8 + movq $1,%rax + movq -48(%rsi),%r15 +.cfi_restore %r15 + movq -40(%rsi),%r14 +.cfi_restore %r14 + movq -32(%rsi),%r13 +.cfi_restore %r13 + movq -24(%rsi),%r12 +.cfi_restore %r12 + movq -16(%rsi),%rbp +.cfi_restore %rbp + movq -8(%rsi),%rbx +.cfi_restore %rbx + leaq (%rsi),%rsp +.cfi_def_cfa_register %rsp +.Lpower5_epilogue: + ret +.cfi_endproc +.size bn_power5_nohw,.-bn_power5_nohw + +.globl bn_sqr8x_internal +.hidden bn_sqr8x_internal +.hidden bn_sqr8x_internal +.type bn_sqr8x_internal,@function +.align 32 +bn_sqr8x_internal: +__bn_sqr8x_internal: +.cfi_startproc +_CET_ENDBR + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + leaq 32(%r10),%rbp + leaq (%rsi,%r9,1),%rsi + + movq %r9,%rcx + + + movq -32(%rsi,%rbp,1),%r14 + leaq 48+8(%rsp,%r9,2),%rdi + movq -24(%rsi,%rbp,1),%rax + leaq -32(%rdi,%rbp,1),%rdi + movq -16(%rsi,%rbp,1),%rbx + movq %rax,%r15 + + mulq %r14 + movq %rax,%r10 + movq %rbx,%rax + movq %rdx,%r11 + movq %r10,-24(%rdi,%rbp,1) + + mulq %r14 + addq %rax,%r11 + movq %rbx,%rax + adcq $0,%rdx + movq %r11,-16(%rdi,%rbp,1) + movq %rdx,%r10 + + + movq -8(%rsi,%rbp,1),%rbx + mulq %r15 + movq %rax,%r12 + movq %rbx,%rax + movq %rdx,%r13 + + leaq (%rbp),%rcx + mulq %r14 + addq %rax,%r10 + movq %rbx,%rax + movq %rdx,%r11 + adcq $0,%r11 + addq %r12,%r10 + adcq $0,%r11 + movq %r10,-8(%rdi,%rcx,1) + jmp .Lsqr4x_1st + +.align 32 +.Lsqr4x_1st: + movq (%rsi,%rcx,1),%rbx + mulq %r15 + addq %rax,%r13 + movq %rbx,%rax + movq %rdx,%r12 + adcq $0,%r12 + + mulq %r14 + addq %rax,%r11 + movq %rbx,%rax + movq 8(%rsi,%rcx,1),%rbx + movq %rdx,%r10 + adcq $0,%r10 + addq %r13,%r11 + adcq $0,%r10 + + + mulq %r15 + addq %rax,%r12 + movq %rbx,%rax + movq %r11,(%rdi,%rcx,1) + movq %rdx,%r13 + adcq $0,%r13 + + mulq %r14 + addq %rax,%r10 + movq %rbx,%rax + movq 16(%rsi,%rcx,1),%rbx + movq %rdx,%r11 + adcq $0,%r11 + addq %r12,%r10 + adcq $0,%r11 + + mulq %r15 + addq %rax,%r13 + movq %rbx,%rax + movq %r10,8(%rdi,%rcx,1) + movq %rdx,%r12 + adcq $0,%r12 + + mulq %r14 + addq %rax,%r11 + movq %rbx,%rax + movq 24(%rsi,%rcx,1),%rbx + movq %rdx,%r10 + adcq $0,%r10 + addq %r13,%r11 + adcq $0,%r10 + + + mulq %r15 + addq %rax,%r12 + movq %rbx,%rax + movq %r11,16(%rdi,%rcx,1) + movq %rdx,%r13 + adcq $0,%r13 + leaq 32(%rcx),%rcx + + mulq %r14 + addq %rax,%r10 + movq %rbx,%rax + movq %rdx,%r11 + adcq $0,%r11 + addq %r12,%r10 + adcq $0,%r11 + movq %r10,-8(%rdi,%rcx,1) + + cmpq $0,%rcx + jne .Lsqr4x_1st + + mulq %r15 + addq %rax,%r13 + leaq 16(%rbp),%rbp + adcq $0,%rdx + addq %r11,%r13 + adcq $0,%rdx + + movq %r13,(%rdi) + movq %rdx,%r12 + movq %rdx,8(%rdi) + jmp .Lsqr4x_outer + +.align 32 +.Lsqr4x_outer: + movq -32(%rsi,%rbp,1),%r14 + leaq 48+8(%rsp,%r9,2),%rdi + movq -24(%rsi,%rbp,1),%rax + leaq -32(%rdi,%rbp,1),%rdi + movq -16(%rsi,%rbp,1),%rbx + movq %rax,%r15 + + mulq %r14 + movq -24(%rdi,%rbp,1),%r10 + addq %rax,%r10 + movq %rbx,%rax + adcq $0,%rdx + movq %r10,-24(%rdi,%rbp,1) + movq %rdx,%r11 + + mulq %r14 + addq %rax,%r11 + movq %rbx,%rax + adcq $0,%rdx + addq -16(%rdi,%rbp,1),%r11 + movq %rdx,%r10 + adcq $0,%r10 + movq %r11,-16(%rdi,%rbp,1) + + xorq %r12,%r12 + + movq -8(%rsi,%rbp,1),%rbx + mulq %r15 + addq %rax,%r12 + movq %rbx,%rax + adcq $0,%rdx + addq -8(%rdi,%rbp,1),%r12 + movq %rdx,%r13 + adcq $0,%r13 + + mulq %r14 + addq %rax,%r10 + movq %rbx,%rax + adcq $0,%rdx + addq %r12,%r10 + movq %rdx,%r11 + adcq $0,%r11 + movq %r10,-8(%rdi,%rbp,1) + + leaq (%rbp),%rcx + jmp .Lsqr4x_inner + +.align 32 +.Lsqr4x_inner: + movq (%rsi,%rcx,1),%rbx + mulq %r15 + addq %rax,%r13 + movq %rbx,%rax + movq %rdx,%r12 + adcq $0,%r12 + addq (%rdi,%rcx,1),%r13 + adcq $0,%r12 + +.byte 0x67 + mulq %r14 + addq %rax,%r11 + movq %rbx,%rax + movq 8(%rsi,%rcx,1),%rbx + movq %rdx,%r10 + adcq $0,%r10 + addq %r13,%r11 + adcq $0,%r10 + + mulq %r15 + addq %rax,%r12 + movq %r11,(%rdi,%rcx,1) + movq %rbx,%rax + movq %rdx,%r13 + adcq $0,%r13 + addq 8(%rdi,%rcx,1),%r12 + leaq 16(%rcx),%rcx + adcq $0,%r13 + + mulq %r14 + addq %rax,%r10 + movq %rbx,%rax + adcq $0,%rdx + addq %r12,%r10 + movq %rdx,%r11 + adcq $0,%r11 + movq %r10,-8(%rdi,%rcx,1) + + cmpq $0,%rcx + jne .Lsqr4x_inner + +.byte 0x67 + mulq %r15 + addq %rax,%r13 + adcq $0,%rdx + addq %r11,%r13 + adcq $0,%rdx + + movq %r13,(%rdi) + movq %rdx,%r12 + movq %rdx,8(%rdi) + + addq $16,%rbp + jnz .Lsqr4x_outer + + + movq -32(%rsi),%r14 + leaq 48+8(%rsp,%r9,2),%rdi + movq -24(%rsi),%rax + leaq -32(%rdi,%rbp,1),%rdi + movq -16(%rsi),%rbx + movq %rax,%r15 + + mulq %r14 + addq %rax,%r10 + movq %rbx,%rax + movq %rdx,%r11 + adcq $0,%r11 + + mulq %r14 + addq %rax,%r11 + movq %rbx,%rax + movq %r10,-24(%rdi) + movq %rdx,%r10 + adcq $0,%r10 + addq %r13,%r11 + movq -8(%rsi),%rbx + adcq $0,%r10 + + mulq %r15 + addq %rax,%r12 + movq %rbx,%rax + movq %r11,-16(%rdi) + movq %rdx,%r13 + adcq $0,%r13 + + mulq %r14 + addq %rax,%r10 + movq %rbx,%rax + movq %rdx,%r11 + adcq $0,%r11 + addq %r12,%r10 + adcq $0,%r11 + movq %r10,-8(%rdi) + + mulq %r15 + addq %rax,%r13 + movq -16(%rsi),%rax + adcq $0,%rdx + addq %r11,%r13 + adcq $0,%rdx + + movq %r13,(%rdi) + movq %rdx,%r12 + movq %rdx,8(%rdi) + + mulq %rbx + addq $16,%rbp + xorq %r14,%r14 + subq %r9,%rbp + xorq %r15,%r15 + + addq %r12,%rax + adcq $0,%rdx + movq %rax,8(%rdi) + movq %rdx,16(%rdi) + movq %r15,24(%rdi) + + movq -16(%rsi,%rbp,1),%rax + leaq 48+8(%rsp),%rdi + xorq %r10,%r10 + movq 8(%rdi),%r11 + + leaq (%r14,%r10,2),%r12 + shrq $63,%r10 + leaq (%rcx,%r11,2),%r13 + shrq $63,%r11 + orq %r10,%r13 + movq 16(%rdi),%r10 + movq %r11,%r14 + mulq %rax + negq %r15 + movq 24(%rdi),%r11 + adcq %rax,%r12 + movq -8(%rsi,%rbp,1),%rax + movq %r12,(%rdi) + adcq %rdx,%r13 + + leaq (%r14,%r10,2),%rbx + movq %r13,8(%rdi) + sbbq %r15,%r15 + shrq $63,%r10 + leaq (%rcx,%r11,2),%r8 + shrq $63,%r11 + orq %r10,%r8 + movq 32(%rdi),%r10 + movq %r11,%r14 + mulq %rax + negq %r15 + movq 40(%rdi),%r11 + adcq %rax,%rbx + movq 0(%rsi,%rbp,1),%rax + movq %rbx,16(%rdi) + adcq %rdx,%r8 + leaq 16(%rbp),%rbp + movq %r8,24(%rdi) + sbbq %r15,%r15 + leaq 64(%rdi),%rdi + jmp .Lsqr4x_shift_n_add + +.align 32 +.Lsqr4x_shift_n_add: + leaq (%r14,%r10,2),%r12 + shrq $63,%r10 + leaq (%rcx,%r11,2),%r13 + shrq $63,%r11 + orq %r10,%r13 + movq -16(%rdi),%r10 + movq %r11,%r14 + mulq %rax + negq %r15 + movq -8(%rdi),%r11 + adcq %rax,%r12 + movq -8(%rsi,%rbp,1),%rax + movq %r12,-32(%rdi) + adcq %rdx,%r13 + + leaq (%r14,%r10,2),%rbx + movq %r13,-24(%rdi) + sbbq %r15,%r15 + shrq $63,%r10 + leaq (%rcx,%r11,2),%r8 + shrq $63,%r11 + orq %r10,%r8 + movq 0(%rdi),%r10 + movq %r11,%r14 + mulq %rax + negq %r15 + movq 8(%rdi),%r11 + adcq %rax,%rbx + movq 0(%rsi,%rbp,1),%rax + movq %rbx,-16(%rdi) + adcq %rdx,%r8 + + leaq (%r14,%r10,2),%r12 + movq %r8,-8(%rdi) + sbbq %r15,%r15 + shrq $63,%r10 + leaq (%rcx,%r11,2),%r13 + shrq $63,%r11 + orq %r10,%r13 + movq 16(%rdi),%r10 + movq %r11,%r14 + mulq %rax + negq %r15 + movq 24(%rdi),%r11 + adcq %rax,%r12 + movq 8(%rsi,%rbp,1),%rax + movq %r12,0(%rdi) + adcq %rdx,%r13 + + leaq (%r14,%r10,2),%rbx + movq %r13,8(%rdi) + sbbq %r15,%r15 + shrq $63,%r10 + leaq (%rcx,%r11,2),%r8 + shrq $63,%r11 + orq %r10,%r8 + movq 32(%rdi),%r10 + movq %r11,%r14 + mulq %rax + negq %r15 + movq 40(%rdi),%r11 + adcq %rax,%rbx + movq 16(%rsi,%rbp,1),%rax + movq %rbx,16(%rdi) + adcq %rdx,%r8 + movq %r8,24(%rdi) + sbbq %r15,%r15 + leaq 64(%rdi),%rdi + addq $32,%rbp + jnz .Lsqr4x_shift_n_add + + leaq (%r14,%r10,2),%r12 +.byte 0x67 + shrq $63,%r10 + leaq (%rcx,%r11,2),%r13 + shrq $63,%r11 + orq %r10,%r13 + movq -16(%rdi),%r10 + movq %r11,%r14 + mulq %rax + negq %r15 + movq -8(%rdi),%r11 + adcq %rax,%r12 + movq -8(%rsi),%rax + movq %r12,-32(%rdi) + adcq %rdx,%r13 + + leaq (%r14,%r10,2),%rbx + movq %r13,-24(%rdi) + sbbq %r15,%r15 + shrq $63,%r10 + leaq (%rcx,%r11,2),%r8 + shrq $63,%r11 + orq %r10,%r8 + mulq %rax + negq %r15 + adcq %rax,%rbx + adcq %rdx,%r8 + movq %rbx,-16(%rdi) + movq %r8,-8(%rdi) +.byte 102,72,15,126,213 +__bn_sqr8x_reduction: + xorq %rax,%rax + leaq (%r9,%rbp,1),%rcx + leaq 48+8(%rsp,%r9,2),%rdx + movq %rcx,0+8(%rsp) + leaq 48+8(%rsp,%r9,1),%rdi + movq %rdx,8+8(%rsp) + negq %r9 + jmp .L8x_reduction_loop + +.align 32 +.L8x_reduction_loop: + leaq (%rdi,%r9,1),%rdi +.byte 0x66 + movq 0(%rdi),%rbx + movq 8(%rdi),%r9 + movq 16(%rdi),%r10 + movq 24(%rdi),%r11 + movq 32(%rdi),%r12 + movq 40(%rdi),%r13 + movq 48(%rdi),%r14 + movq 56(%rdi),%r15 + movq %rax,(%rdx) + leaq 64(%rdi),%rdi + +.byte 0x67 + movq %rbx,%r8 + imulq 32+8(%rsp),%rbx + movq 0(%rbp),%rax + movl $8,%ecx + jmp .L8x_reduce + +.align 32 +.L8x_reduce: + mulq %rbx + movq 8(%rbp),%rax + negq %r8 + movq %rdx,%r8 + adcq $0,%r8 + + mulq %rbx + addq %rax,%r9 + movq 16(%rbp),%rax + adcq $0,%rdx + addq %r9,%r8 + movq %rbx,48-8+8(%rsp,%rcx,8) + movq %rdx,%r9 + adcq $0,%r9 + + mulq %rbx + addq %rax,%r10 + movq 24(%rbp),%rax + adcq $0,%rdx + addq %r10,%r9 + movq 32+8(%rsp),%rsi + movq %rdx,%r10 + adcq $0,%r10 + + mulq %rbx + addq %rax,%r11 + movq 32(%rbp),%rax + adcq $0,%rdx + imulq %r8,%rsi + addq %r11,%r10 + movq %rdx,%r11 + adcq $0,%r11 + + mulq %rbx + addq %rax,%r12 + movq 40(%rbp),%rax + adcq $0,%rdx + addq %r12,%r11 + movq %rdx,%r12 + adcq $0,%r12 + + mulq %rbx + addq %rax,%r13 + movq 48(%rbp),%rax + adcq $0,%rdx + addq %r13,%r12 + movq %rdx,%r13 + adcq $0,%r13 + + mulq %rbx + addq %rax,%r14 + movq 56(%rbp),%rax + adcq $0,%rdx + addq %r14,%r13 + movq %rdx,%r14 + adcq $0,%r14 + + mulq %rbx + movq %rsi,%rbx + addq %rax,%r15 + movq 0(%rbp),%rax + adcq $0,%rdx + addq %r15,%r14 + movq %rdx,%r15 + adcq $0,%r15 + + decl %ecx + jnz .L8x_reduce + + leaq 64(%rbp),%rbp + xorq %rax,%rax + movq 8+8(%rsp),%rdx + cmpq 0+8(%rsp),%rbp + jae .L8x_no_tail + +.byte 0x66 + addq 0(%rdi),%r8 + adcq 8(%rdi),%r9 + adcq 16(%rdi),%r10 + adcq 24(%rdi),%r11 + adcq 32(%rdi),%r12 + adcq 40(%rdi),%r13 + adcq 48(%rdi),%r14 + adcq 56(%rdi),%r15 + sbbq %rsi,%rsi + + movq 48+56+8(%rsp),%rbx + movl $8,%ecx + movq 0(%rbp),%rax + jmp .L8x_tail + +.align 32 +.L8x_tail: + mulq %rbx + addq %rax,%r8 + movq 8(%rbp),%rax + movq %r8,(%rdi) + movq %rdx,%r8 + adcq $0,%r8 + + mulq %rbx + addq %rax,%r9 + movq 16(%rbp),%rax + adcq $0,%rdx + addq %r9,%r8 + leaq 8(%rdi),%rdi + movq %rdx,%r9 + adcq $0,%r9 + + mulq %rbx + addq %rax,%r10 + movq 24(%rbp),%rax + adcq $0,%rdx + addq %r10,%r9 + movq %rdx,%r10 + adcq $0,%r10 + + mulq %rbx + addq %rax,%r11 + movq 32(%rbp),%rax + adcq $0,%rdx + addq %r11,%r10 + movq %rdx,%r11 + adcq $0,%r11 + + mulq %rbx + addq %rax,%r12 + movq 40(%rbp),%rax + adcq $0,%rdx + addq %r12,%r11 + movq %rdx,%r12 + adcq $0,%r12 + + mulq %rbx + addq %rax,%r13 + movq 48(%rbp),%rax + adcq $0,%rdx + addq %r13,%r12 + movq %rdx,%r13 + adcq $0,%r13 + + mulq %rbx + addq %rax,%r14 + movq 56(%rbp),%rax + adcq $0,%rdx + addq %r14,%r13 + movq %rdx,%r14 + adcq $0,%r14 + + mulq %rbx + movq 48-16+8(%rsp,%rcx,8),%rbx + addq %rax,%r15 + adcq $0,%rdx + addq %r15,%r14 + movq 0(%rbp),%rax + movq %rdx,%r15 + adcq $0,%r15 + + decl %ecx + jnz .L8x_tail + + leaq 64(%rbp),%rbp + movq 8+8(%rsp),%rdx + cmpq 0+8(%rsp),%rbp + jae .L8x_tail_done + + movq 48+56+8(%rsp),%rbx + negq %rsi + movq 0(%rbp),%rax + adcq 0(%rdi),%r8 + adcq 8(%rdi),%r9 + adcq 16(%rdi),%r10 + adcq 24(%rdi),%r11 + adcq 32(%rdi),%r12 + adcq 40(%rdi),%r13 + adcq 48(%rdi),%r14 + adcq 56(%rdi),%r15 + sbbq %rsi,%rsi + + movl $8,%ecx + jmp .L8x_tail + +.align 32 +.L8x_tail_done: + xorq %rax,%rax + addq (%rdx),%r8 + adcq $0,%r9 + adcq $0,%r10 + adcq $0,%r11 + adcq $0,%r12 + adcq $0,%r13 + adcq $0,%r14 + adcq $0,%r15 + adcq $0,%rax + + negq %rsi +.L8x_no_tail: + adcq 0(%rdi),%r8 + adcq 8(%rdi),%r9 + adcq 16(%rdi),%r10 + adcq 24(%rdi),%r11 + adcq 32(%rdi),%r12 + adcq 40(%rdi),%r13 + adcq 48(%rdi),%r14 + adcq 56(%rdi),%r15 + adcq $0,%rax + movq -8(%rbp),%rcx + xorq %rsi,%rsi + +.byte 102,72,15,126,213 + + movq %r8,0(%rdi) + movq %r9,8(%rdi) +.byte 102,73,15,126,217 + movq %r10,16(%rdi) + movq %r11,24(%rdi) + movq %r12,32(%rdi) + movq %r13,40(%rdi) + movq %r14,48(%rdi) + movq %r15,56(%rdi) + leaq 64(%rdi),%rdi + + cmpq %rdx,%rdi + jb .L8x_reduction_loop + ret +.cfi_endproc +.size bn_sqr8x_internal,.-bn_sqr8x_internal +.type __bn_post4x_internal,@function +.align 32 +__bn_post4x_internal: +.cfi_startproc + movq 0(%rbp),%r12 + leaq (%rdi,%r9,1),%rbx + movq %r9,%rcx +.byte 102,72,15,126,207 + negq %rax +.byte 102,72,15,126,206 + sarq $3+2,%rcx + decq %r12 + xorq %r10,%r10 + movq 8(%rbp),%r13 + movq 16(%rbp),%r14 + movq 24(%rbp),%r15 + jmp .Lsqr4x_sub_entry + +.align 16 +.Lsqr4x_sub: + movq 0(%rbp),%r12 + movq 8(%rbp),%r13 + movq 16(%rbp),%r14 + movq 24(%rbp),%r15 +.Lsqr4x_sub_entry: + leaq 32(%rbp),%rbp + notq %r12 + notq %r13 + notq %r14 + notq %r15 + andq %rax,%r12 + andq %rax,%r13 + andq %rax,%r14 + andq %rax,%r15 + + negq %r10 + adcq 0(%rbx),%r12 + adcq 8(%rbx),%r13 + adcq 16(%rbx),%r14 + adcq 24(%rbx),%r15 + movq %r12,0(%rdi) + leaq 32(%rbx),%rbx + movq %r13,8(%rdi) + sbbq %r10,%r10 + movq %r14,16(%rdi) + movq %r15,24(%rdi) + leaq 32(%rdi),%rdi + + incq %rcx + jnz .Lsqr4x_sub + + movq %r9,%r10 + negq %r9 + ret +.cfi_endproc +.size __bn_post4x_internal,.-__bn_post4x_internal +.globl bn_mulx4x_mont_gather5 +.hidden bn_mulx4x_mont_gather5 +.type bn_mulx4x_mont_gather5,@function +.align 32 +bn_mulx4x_mont_gather5: +.cfi_startproc +_CET_ENDBR + movq %rsp,%rax +.cfi_def_cfa_register %rax + pushq %rbx +.cfi_offset %rbx,-16 + pushq %rbp +.cfi_offset %rbp,-24 + pushq %r12 +.cfi_offset %r12,-32 + pushq %r13 +.cfi_offset %r13,-40 + pushq %r14 +.cfi_offset %r14,-48 + pushq %r15 +.cfi_offset %r15,-56 +.Lmulx4x_prologue: + + + + + shll $3,%r9d + leaq (%r9,%r9,2),%r10 + negq %r9 + movq (%r8),%r8 + + + + + + + + + + + leaq -320(%rsp,%r9,2),%r11 + movq %rsp,%rbp + subq %rdi,%r11 + andq $4095,%r11 + cmpq %r11,%r10 + jb .Lmulx4xsp_alt + subq %r11,%rbp + leaq -320(%rbp,%r9,2),%rbp + jmp .Lmulx4xsp_done + +.Lmulx4xsp_alt: + leaq 4096-320(,%r9,2),%r10 + leaq -320(%rbp,%r9,2),%rbp + subq %r10,%r11 + movq $0,%r10 + cmovcq %r10,%r11 + subq %r11,%rbp +.Lmulx4xsp_done: + andq $-64,%rbp + movq %rsp,%r11 + subq %rbp,%r11 + andq $-4096,%r11 + leaq (%r11,%rbp,1),%rsp + movq (%rsp),%r10 + cmpq %rbp,%rsp + ja .Lmulx4x_page_walk + jmp .Lmulx4x_page_walk_done + +.Lmulx4x_page_walk: + leaq -4096(%rsp),%rsp + movq (%rsp),%r10 + cmpq %rbp,%rsp + ja .Lmulx4x_page_walk +.Lmulx4x_page_walk_done: + + + + + + + + + + + + + + movq %r8,32(%rsp) + movq %rax,40(%rsp) +.cfi_escape 0x0f,0x05,0x77,0x28,0x06,0x23,0x08 +.Lmulx4x_body: + call mulx4x_internal + + movq 40(%rsp),%rsi +.cfi_def_cfa %rsi,8 + movq $1,%rax + + movq -48(%rsi),%r15 +.cfi_restore %r15 + movq -40(%rsi),%r14 +.cfi_restore %r14 + movq -32(%rsi),%r13 +.cfi_restore %r13 + movq -24(%rsi),%r12 +.cfi_restore %r12 + movq -16(%rsi),%rbp +.cfi_restore %rbp + movq -8(%rsi),%rbx +.cfi_restore %rbx + leaq (%rsi),%rsp +.cfi_def_cfa_register %rsp +.Lmulx4x_epilogue: + ret +.cfi_endproc +.size bn_mulx4x_mont_gather5,.-bn_mulx4x_mont_gather5 + +.type mulx4x_internal,@function +.align 32 +mulx4x_internal: +.cfi_startproc + movq %r9,8(%rsp) + movq %r9,%r10 + negq %r9 + shlq $5,%r9 + negq %r10 + leaq 128(%rdx,%r9,1),%r13 + shrq $5+5,%r9 + movd 8(%rax),%xmm5 + subq $1,%r9 + leaq .Linc(%rip),%rax + movq %r13,16+8(%rsp) + movq %r9,24+8(%rsp) + movq %rdi,56+8(%rsp) + movdqa 0(%rax),%xmm0 + movdqa 16(%rax),%xmm1 + leaq 88-112(%rsp,%r10,1),%r10 + leaq 128(%rdx),%rdi + + pshufd $0,%xmm5,%xmm5 + movdqa %xmm1,%xmm4 +.byte 0x67 + movdqa %xmm1,%xmm2 +.byte 0x67 + paddd %xmm0,%xmm1 + pcmpeqd %xmm5,%xmm0 + movdqa %xmm4,%xmm3 + paddd %xmm1,%xmm2 + pcmpeqd %xmm5,%xmm1 + movdqa %xmm0,112(%r10) + movdqa %xmm4,%xmm0 + + paddd %xmm2,%xmm3 + pcmpeqd %xmm5,%xmm2 + movdqa %xmm1,128(%r10) + movdqa %xmm4,%xmm1 + + paddd %xmm3,%xmm0 + pcmpeqd %xmm5,%xmm3 + movdqa %xmm2,144(%r10) + movdqa %xmm4,%xmm2 + + paddd %xmm0,%xmm1 + pcmpeqd %xmm5,%xmm0 + movdqa %xmm3,160(%r10) + movdqa %xmm4,%xmm3 + paddd %xmm1,%xmm2 + pcmpeqd %xmm5,%xmm1 + movdqa %xmm0,176(%r10) + movdqa %xmm4,%xmm0 + + paddd %xmm2,%xmm3 + pcmpeqd %xmm5,%xmm2 + movdqa %xmm1,192(%r10) + movdqa %xmm4,%xmm1 + + paddd %xmm3,%xmm0 + pcmpeqd %xmm5,%xmm3 + movdqa %xmm2,208(%r10) + movdqa %xmm4,%xmm2 + + paddd %xmm0,%xmm1 + pcmpeqd %xmm5,%xmm0 + movdqa %xmm3,224(%r10) + movdqa %xmm4,%xmm3 + paddd %xmm1,%xmm2 + pcmpeqd %xmm5,%xmm1 + movdqa %xmm0,240(%r10) + movdqa %xmm4,%xmm0 + + paddd %xmm2,%xmm3 + pcmpeqd %xmm5,%xmm2 + movdqa %xmm1,256(%r10) + movdqa %xmm4,%xmm1 + + paddd %xmm3,%xmm0 + pcmpeqd %xmm5,%xmm3 + movdqa %xmm2,272(%r10) + movdqa %xmm4,%xmm2 + + paddd %xmm0,%xmm1 + pcmpeqd %xmm5,%xmm0 + movdqa %xmm3,288(%r10) + movdqa %xmm4,%xmm3 +.byte 0x67 + paddd %xmm1,%xmm2 + pcmpeqd %xmm5,%xmm1 + movdqa %xmm0,304(%r10) + + paddd %xmm2,%xmm3 + pcmpeqd %xmm5,%xmm2 + movdqa %xmm1,320(%r10) + + pcmpeqd %xmm5,%xmm3 + movdqa %xmm2,336(%r10) + + pand 64(%rdi),%xmm0 + pand 80(%rdi),%xmm1 + pand 96(%rdi),%xmm2 + movdqa %xmm3,352(%r10) + pand 112(%rdi),%xmm3 + por %xmm2,%xmm0 + por %xmm3,%xmm1 + movdqa -128(%rdi),%xmm4 + movdqa -112(%rdi),%xmm5 + movdqa -96(%rdi),%xmm2 + pand 112(%r10),%xmm4 + movdqa -80(%rdi),%xmm3 + pand 128(%r10),%xmm5 + por %xmm4,%xmm0 + pand 144(%r10),%xmm2 + por %xmm5,%xmm1 + pand 160(%r10),%xmm3 + por %xmm2,%xmm0 + por %xmm3,%xmm1 + movdqa -64(%rdi),%xmm4 + movdqa -48(%rdi),%xmm5 + movdqa -32(%rdi),%xmm2 + pand 176(%r10),%xmm4 + movdqa -16(%rdi),%xmm3 + pand 192(%r10),%xmm5 + por %xmm4,%xmm0 + pand 208(%r10),%xmm2 + por %xmm5,%xmm1 + pand 224(%r10),%xmm3 + por %xmm2,%xmm0 + por %xmm3,%xmm1 + movdqa 0(%rdi),%xmm4 + movdqa 16(%rdi),%xmm5 + movdqa 32(%rdi),%xmm2 + pand 240(%r10),%xmm4 + movdqa 48(%rdi),%xmm3 + pand 256(%r10),%xmm5 + por %xmm4,%xmm0 + pand 272(%r10),%xmm2 + por %xmm5,%xmm1 + pand 288(%r10),%xmm3 + por %xmm2,%xmm0 + por %xmm3,%xmm1 + pxor %xmm1,%xmm0 + + pshufd $0x4e,%xmm0,%xmm1 + por %xmm1,%xmm0 + leaq 256(%rdi),%rdi +.byte 102,72,15,126,194 + leaq 64+32+8(%rsp),%rbx + + movq %rdx,%r9 + mulxq 0(%rsi),%r8,%rax + mulxq 8(%rsi),%r11,%r12 + addq %rax,%r11 + mulxq 16(%rsi),%rax,%r13 + adcq %rax,%r12 + adcq $0,%r13 + mulxq 24(%rsi),%rax,%r14 + + movq %r8,%r15 + imulq 32+8(%rsp),%r8 + xorq %rbp,%rbp + movq %r8,%rdx + + movq %rdi,8+8(%rsp) + + leaq 32(%rsi),%rsi + adcxq %rax,%r13 + adcxq %rbp,%r14 + + mulxq 0(%rcx),%rax,%r10 + adcxq %rax,%r15 + adoxq %r11,%r10 + mulxq 8(%rcx),%rax,%r11 + adcxq %rax,%r10 + adoxq %r12,%r11 + mulxq 16(%rcx),%rax,%r12 + movq 24+8(%rsp),%rdi + movq %r10,-32(%rbx) + adcxq %rax,%r11 + adoxq %r13,%r12 + mulxq 24(%rcx),%rax,%r15 + movq %r9,%rdx + movq %r11,-24(%rbx) + adcxq %rax,%r12 + adoxq %rbp,%r15 + leaq 32(%rcx),%rcx + movq %r12,-16(%rbx) + jmp .Lmulx4x_1st + +.align 32 +.Lmulx4x_1st: + adcxq %rbp,%r15 + mulxq 0(%rsi),%r10,%rax + adcxq %r14,%r10 + mulxq 8(%rsi),%r11,%r14 + adcxq %rax,%r11 + mulxq 16(%rsi),%r12,%rax + adcxq %r14,%r12 + mulxq 24(%rsi),%r13,%r14 +.byte 0x67,0x67 + movq %r8,%rdx + adcxq %rax,%r13 + adcxq %rbp,%r14 + leaq 32(%rsi),%rsi + leaq 32(%rbx),%rbx + + adoxq %r15,%r10 + mulxq 0(%rcx),%rax,%r15 + adcxq %rax,%r10 + adoxq %r15,%r11 + mulxq 8(%rcx),%rax,%r15 + adcxq %rax,%r11 + adoxq %r15,%r12 + mulxq 16(%rcx),%rax,%r15 + movq %r10,-40(%rbx) + adcxq %rax,%r12 + movq %r11,-32(%rbx) + adoxq %r15,%r13 + mulxq 24(%rcx),%rax,%r15 + movq %r9,%rdx + movq %r12,-24(%rbx) + adcxq %rax,%r13 + adoxq %rbp,%r15 + leaq 32(%rcx),%rcx + movq %r13,-16(%rbx) + + decq %rdi + jnz .Lmulx4x_1st + + movq 8(%rsp),%rax + adcq %rbp,%r15 + leaq (%rsi,%rax,1),%rsi + addq %r15,%r14 + movq 8+8(%rsp),%rdi + adcq %rbp,%rbp + movq %r14,-8(%rbx) + jmp .Lmulx4x_outer + +.align 32 +.Lmulx4x_outer: + leaq 16-256(%rbx),%r10 + pxor %xmm4,%xmm4 +.byte 0x67,0x67 + pxor %xmm5,%xmm5 + movdqa -128(%rdi),%xmm0 + movdqa -112(%rdi),%xmm1 + movdqa -96(%rdi),%xmm2 + pand 256(%r10),%xmm0 + movdqa -80(%rdi),%xmm3 + pand 272(%r10),%xmm1 + por %xmm0,%xmm4 + pand 288(%r10),%xmm2 + por %xmm1,%xmm5 + pand 304(%r10),%xmm3 + por %xmm2,%xmm4 + por %xmm3,%xmm5 + movdqa -64(%rdi),%xmm0 + movdqa -48(%rdi),%xmm1 + movdqa -32(%rdi),%xmm2 + pand 320(%r10),%xmm0 + movdqa -16(%rdi),%xmm3 + pand 336(%r10),%xmm1 + por %xmm0,%xmm4 + pand 352(%r10),%xmm2 + por %xmm1,%xmm5 + pand 368(%r10),%xmm3 + por %xmm2,%xmm4 + por %xmm3,%xmm5 + movdqa 0(%rdi),%xmm0 + movdqa 16(%rdi),%xmm1 + movdqa 32(%rdi),%xmm2 + pand 384(%r10),%xmm0 + movdqa 48(%rdi),%xmm3 + pand 400(%r10),%xmm1 + por %xmm0,%xmm4 + pand 416(%r10),%xmm2 + por %xmm1,%xmm5 + pand 432(%r10),%xmm3 + por %xmm2,%xmm4 + por %xmm3,%xmm5 + movdqa 64(%rdi),%xmm0 + movdqa 80(%rdi),%xmm1 + movdqa 96(%rdi),%xmm2 + pand 448(%r10),%xmm0 + movdqa 112(%rdi),%xmm3 + pand 464(%r10),%xmm1 + por %xmm0,%xmm4 + pand 480(%r10),%xmm2 + por %xmm1,%xmm5 + pand 496(%r10),%xmm3 + por %xmm2,%xmm4 + por %xmm3,%xmm5 + por %xmm5,%xmm4 + + pshufd $0x4e,%xmm4,%xmm0 + por %xmm4,%xmm0 + leaq 256(%rdi),%rdi +.byte 102,72,15,126,194 + + movq %rbp,(%rbx) + leaq 32(%rbx,%rax,1),%rbx + mulxq 0(%rsi),%r8,%r11 + xorq %rbp,%rbp + movq %rdx,%r9 + mulxq 8(%rsi),%r14,%r12 + adoxq -32(%rbx),%r8 + adcxq %r14,%r11 + mulxq 16(%rsi),%r15,%r13 + adoxq -24(%rbx),%r11 + adcxq %r15,%r12 + mulxq 24(%rsi),%rdx,%r14 + adoxq -16(%rbx),%r12 + adcxq %rdx,%r13 + leaq (%rcx,%rax,1),%rcx + leaq 32(%rsi),%rsi + adoxq -8(%rbx),%r13 + adcxq %rbp,%r14 + adoxq %rbp,%r14 + + movq %r8,%r15 + imulq 32+8(%rsp),%r8 + + movq %r8,%rdx + xorq %rbp,%rbp + movq %rdi,8+8(%rsp) + + mulxq 0(%rcx),%rax,%r10 + adcxq %rax,%r15 + adoxq %r11,%r10 + mulxq 8(%rcx),%rax,%r11 + adcxq %rax,%r10 + adoxq %r12,%r11 + mulxq 16(%rcx),%rax,%r12 + adcxq %rax,%r11 + adoxq %r13,%r12 + mulxq 24(%rcx),%rax,%r15 + movq %r9,%rdx + movq 24+8(%rsp),%rdi + movq %r10,-32(%rbx) + adcxq %rax,%r12 + movq %r11,-24(%rbx) + adoxq %rbp,%r15 + movq %r12,-16(%rbx) + leaq 32(%rcx),%rcx + jmp .Lmulx4x_inner + +.align 32 +.Lmulx4x_inner: + mulxq 0(%rsi),%r10,%rax + adcxq %rbp,%r15 + adoxq %r14,%r10 + mulxq 8(%rsi),%r11,%r14 + adcxq 0(%rbx),%r10 + adoxq %rax,%r11 + mulxq 16(%rsi),%r12,%rax + adcxq 8(%rbx),%r11 + adoxq %r14,%r12 + mulxq 24(%rsi),%r13,%r14 + movq %r8,%rdx + adcxq 16(%rbx),%r12 + adoxq %rax,%r13 + adcxq 24(%rbx),%r13 + adoxq %rbp,%r14 + leaq 32(%rsi),%rsi + leaq 32(%rbx),%rbx + adcxq %rbp,%r14 + + adoxq %r15,%r10 + mulxq 0(%rcx),%rax,%r15 + adcxq %rax,%r10 + adoxq %r15,%r11 + mulxq 8(%rcx),%rax,%r15 + adcxq %rax,%r11 + adoxq %r15,%r12 + mulxq 16(%rcx),%rax,%r15 + movq %r10,-40(%rbx) + adcxq %rax,%r12 + adoxq %r15,%r13 + movq %r11,-32(%rbx) + mulxq 24(%rcx),%rax,%r15 + movq %r9,%rdx + leaq 32(%rcx),%rcx + movq %r12,-24(%rbx) + adcxq %rax,%r13 + adoxq %rbp,%r15 + movq %r13,-16(%rbx) + + decq %rdi + jnz .Lmulx4x_inner + + movq 0+8(%rsp),%rax + adcq %rbp,%r15 + subq 0(%rbx),%rdi + movq 8+8(%rsp),%rdi + movq 16+8(%rsp),%r10 + adcq %r15,%r14 + leaq (%rsi,%rax,1),%rsi + adcq %rbp,%rbp + movq %r14,-8(%rbx) + + cmpq %r10,%rdi + jb .Lmulx4x_outer + + movq -8(%rcx),%r10 + movq %rbp,%r8 + movq (%rcx,%rax,1),%r12 + leaq (%rcx,%rax,1),%rbp + movq %rax,%rcx + leaq (%rbx,%rax,1),%rdi + xorl %eax,%eax + xorq %r15,%r15 + subq %r14,%r10 + adcq %r15,%r15 + orq %r15,%r8 + sarq $3+2,%rcx + subq %r8,%rax + movq 56+8(%rsp),%rdx + decq %r12 + movq 8(%rbp),%r13 + xorq %r8,%r8 + movq 16(%rbp),%r14 + movq 24(%rbp),%r15 + jmp .Lsqrx4x_sub_entry +.cfi_endproc +.size mulx4x_internal,.-mulx4x_internal +.globl bn_powerx5 +.hidden bn_powerx5 +.type bn_powerx5,@function +.align 32 +bn_powerx5: +.cfi_startproc +_CET_ENDBR + movq %rsp,%rax +.cfi_def_cfa_register %rax + pushq %rbx +.cfi_offset %rbx,-16 + pushq %rbp +.cfi_offset %rbp,-24 + pushq %r12 +.cfi_offset %r12,-32 + pushq %r13 +.cfi_offset %r13,-40 + pushq %r14 +.cfi_offset %r14,-48 + pushq %r15 +.cfi_offset %r15,-56 +.Lpowerx5_prologue: + + + + + shll $3,%r9d + leaq (%r9,%r9,2),%r10 + negq %r9 + movq (%r8),%r8 + + + + + + + + + leaq -320(%rsp,%r9,2),%r11 + movq %rsp,%rbp + subq %rdi,%r11 + andq $4095,%r11 + cmpq %r11,%r10 + jb .Lpwrx_sp_alt + subq %r11,%rbp + leaq -320(%rbp,%r9,2),%rbp + jmp .Lpwrx_sp_done + +.align 32 +.Lpwrx_sp_alt: + leaq 4096-320(,%r9,2),%r10 + leaq -320(%rbp,%r9,2),%rbp + subq %r10,%r11 + movq $0,%r10 + cmovcq %r10,%r11 + subq %r11,%rbp +.Lpwrx_sp_done: + andq $-64,%rbp + movq %rsp,%r11 + subq %rbp,%r11 + andq $-4096,%r11 + leaq (%r11,%rbp,1),%rsp + movq (%rsp),%r10 + cmpq %rbp,%rsp + ja .Lpwrx_page_walk + jmp .Lpwrx_page_walk_done + +.Lpwrx_page_walk: + leaq -4096(%rsp),%rsp + movq (%rsp),%r10 + cmpq %rbp,%rsp + ja .Lpwrx_page_walk +.Lpwrx_page_walk_done: + + movq %r9,%r10 + negq %r9 + + + + + + + + + + + + + pxor %xmm0,%xmm0 +.byte 102,72,15,110,207 +.byte 102,72,15,110,209 +.byte 102,73,15,110,218 +.byte 102,72,15,110,226 + movq %r8,32(%rsp) + movq %rax,40(%rsp) +.cfi_escape 0x0f,0x05,0x77,0x28,0x06,0x23,0x08 +.Lpowerx5_body: + + call __bn_sqrx8x_internal + call __bn_postx4x_internal + call __bn_sqrx8x_internal + call __bn_postx4x_internal + call __bn_sqrx8x_internal + call __bn_postx4x_internal + call __bn_sqrx8x_internal + call __bn_postx4x_internal + call __bn_sqrx8x_internal + call __bn_postx4x_internal + + movq %r10,%r9 + movq %rsi,%rdi +.byte 102,72,15,126,209 +.byte 102,72,15,126,226 + movq 40(%rsp),%rax + + call mulx4x_internal + + movq 40(%rsp),%rsi +.cfi_def_cfa %rsi,8 + movq $1,%rax + + movq -48(%rsi),%r15 +.cfi_restore %r15 + movq -40(%rsi),%r14 +.cfi_restore %r14 + movq -32(%rsi),%r13 +.cfi_restore %r13 + movq -24(%rsi),%r12 +.cfi_restore %r12 + movq -16(%rsi),%rbp +.cfi_restore %rbp + movq -8(%rsi),%rbx +.cfi_restore %rbx + leaq (%rsi),%rsp +.cfi_def_cfa_register %rsp +.Lpowerx5_epilogue: + ret +.cfi_endproc +.size bn_powerx5,.-bn_powerx5 + +.globl bn_sqrx8x_internal +.hidden bn_sqrx8x_internal +.hidden bn_sqrx8x_internal +.type bn_sqrx8x_internal,@function +.align 32 +bn_sqrx8x_internal: +__bn_sqrx8x_internal: +.cfi_startproc +_CET_ENDBR + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + leaq 48+8(%rsp),%rdi + leaq (%rsi,%r9,1),%rbp + movq %r9,0+8(%rsp) + movq %rbp,8+8(%rsp) + jmp .Lsqr8x_zero_start + +.align 32 +.byte 0x66,0x66,0x66,0x2e,0x0f,0x1f,0x84,0x00,0x00,0x00,0x00,0x00 +.Lsqrx8x_zero: +.byte 0x3e + movdqa %xmm0,0(%rdi) + movdqa %xmm0,16(%rdi) + movdqa %xmm0,32(%rdi) + movdqa %xmm0,48(%rdi) +.Lsqr8x_zero_start: + movdqa %xmm0,64(%rdi) + movdqa %xmm0,80(%rdi) + movdqa %xmm0,96(%rdi) + movdqa %xmm0,112(%rdi) + leaq 128(%rdi),%rdi + subq $64,%r9 + jnz .Lsqrx8x_zero + + movq 0(%rsi),%rdx + + xorq %r10,%r10 + xorq %r11,%r11 + xorq %r12,%r12 + xorq %r13,%r13 + xorq %r14,%r14 + xorq %r15,%r15 + leaq 48+8(%rsp),%rdi + xorq %rbp,%rbp + jmp .Lsqrx8x_outer_loop + +.align 32 +.Lsqrx8x_outer_loop: + mulxq 8(%rsi),%r8,%rax + adcxq %r9,%r8 + adoxq %rax,%r10 + mulxq 16(%rsi),%r9,%rax + adcxq %r10,%r9 + adoxq %rax,%r11 +.byte 0xc4,0xe2,0xab,0xf6,0x86,0x18,0x00,0x00,0x00 + adcxq %r11,%r10 + adoxq %rax,%r12 +.byte 0xc4,0xe2,0xa3,0xf6,0x86,0x20,0x00,0x00,0x00 + adcxq %r12,%r11 + adoxq %rax,%r13 + mulxq 40(%rsi),%r12,%rax + adcxq %r13,%r12 + adoxq %rax,%r14 + mulxq 48(%rsi),%r13,%rax + adcxq %r14,%r13 + adoxq %r15,%rax + mulxq 56(%rsi),%r14,%r15 + movq 8(%rsi),%rdx + adcxq %rax,%r14 + adoxq %rbp,%r15 + adcq 64(%rdi),%r15 + movq %r8,8(%rdi) + movq %r9,16(%rdi) + sbbq %rcx,%rcx + xorq %rbp,%rbp + + + mulxq 16(%rsi),%r8,%rbx + mulxq 24(%rsi),%r9,%rax + adcxq %r10,%r8 + adoxq %rbx,%r9 + mulxq 32(%rsi),%r10,%rbx + adcxq %r11,%r9 + adoxq %rax,%r10 +.byte 0xc4,0xe2,0xa3,0xf6,0x86,0x28,0x00,0x00,0x00 + adcxq %r12,%r10 + adoxq %rbx,%r11 +.byte 0xc4,0xe2,0x9b,0xf6,0x9e,0x30,0x00,0x00,0x00 + adcxq %r13,%r11 + adoxq %r14,%r12 +.byte 0xc4,0x62,0x93,0xf6,0xb6,0x38,0x00,0x00,0x00 + movq 16(%rsi),%rdx + adcxq %rax,%r12 + adoxq %rbx,%r13 + adcxq %r15,%r13 + adoxq %rbp,%r14 + adcxq %rbp,%r14 + + movq %r8,24(%rdi) + movq %r9,32(%rdi) + + mulxq 24(%rsi),%r8,%rbx + mulxq 32(%rsi),%r9,%rax + adcxq %r10,%r8 + adoxq %rbx,%r9 + mulxq 40(%rsi),%r10,%rbx + adcxq %r11,%r9 + adoxq %rax,%r10 +.byte 0xc4,0xe2,0xa3,0xf6,0x86,0x30,0x00,0x00,0x00 + adcxq %r12,%r10 + adoxq %r13,%r11 +.byte 0xc4,0x62,0x9b,0xf6,0xae,0x38,0x00,0x00,0x00 +.byte 0x3e + movq 24(%rsi),%rdx + adcxq %rbx,%r11 + adoxq %rax,%r12 + adcxq %r14,%r12 + movq %r8,40(%rdi) + movq %r9,48(%rdi) + mulxq 32(%rsi),%r8,%rax + adoxq %rbp,%r13 + adcxq %rbp,%r13 + + mulxq 40(%rsi),%r9,%rbx + adcxq %r10,%r8 + adoxq %rax,%r9 + mulxq 48(%rsi),%r10,%rax + adcxq %r11,%r9 + adoxq %r12,%r10 + mulxq 56(%rsi),%r11,%r12 + movq 32(%rsi),%rdx + movq 40(%rsi),%r14 + adcxq %rbx,%r10 + adoxq %rax,%r11 + movq 48(%rsi),%r15 + adcxq %r13,%r11 + adoxq %rbp,%r12 + adcxq %rbp,%r12 + + movq %r8,56(%rdi) + movq %r9,64(%rdi) + + mulxq %r14,%r9,%rax + movq 56(%rsi),%r8 + adcxq %r10,%r9 + mulxq %r15,%r10,%rbx + adoxq %rax,%r10 + adcxq %r11,%r10 + mulxq %r8,%r11,%rax + movq %r14,%rdx + adoxq %rbx,%r11 + adcxq %r12,%r11 + + adcxq %rbp,%rax + + mulxq %r15,%r14,%rbx + mulxq %r8,%r12,%r13 + movq %r15,%rdx + leaq 64(%rsi),%rsi + adcxq %r14,%r11 + adoxq %rbx,%r12 + adcxq %rax,%r12 + adoxq %rbp,%r13 + +.byte 0x67,0x67 + mulxq %r8,%r8,%r14 + adcxq %r8,%r13 + adcxq %rbp,%r14 + + cmpq 8+8(%rsp),%rsi + je .Lsqrx8x_outer_break + + negq %rcx + movq $-8,%rcx + movq %rbp,%r15 + movq 64(%rdi),%r8 + adcxq 72(%rdi),%r9 + adcxq 80(%rdi),%r10 + adcxq 88(%rdi),%r11 + adcq 96(%rdi),%r12 + adcq 104(%rdi),%r13 + adcq 112(%rdi),%r14 + adcq 120(%rdi),%r15 + leaq (%rsi),%rbp + leaq 128(%rdi),%rdi + sbbq %rax,%rax + + movq -64(%rsi),%rdx + movq %rax,16+8(%rsp) + movq %rdi,24+8(%rsp) + + + xorl %eax,%eax + jmp .Lsqrx8x_loop + +.align 32 +.Lsqrx8x_loop: + movq %r8,%rbx + mulxq 0(%rbp),%rax,%r8 + adcxq %rax,%rbx + adoxq %r9,%r8 + + mulxq 8(%rbp),%rax,%r9 + adcxq %rax,%r8 + adoxq %r10,%r9 + + mulxq 16(%rbp),%rax,%r10 + adcxq %rax,%r9 + adoxq %r11,%r10 + + mulxq 24(%rbp),%rax,%r11 + adcxq %rax,%r10 + adoxq %r12,%r11 + +.byte 0xc4,0x62,0xfb,0xf6,0xa5,0x20,0x00,0x00,0x00 + adcxq %rax,%r11 + adoxq %r13,%r12 + + mulxq 40(%rbp),%rax,%r13 + adcxq %rax,%r12 + adoxq %r14,%r13 + + mulxq 48(%rbp),%rax,%r14 + movq %rbx,(%rdi,%rcx,8) + movl $0,%ebx + adcxq %rax,%r13 + adoxq %r15,%r14 + +.byte 0xc4,0x62,0xfb,0xf6,0xbd,0x38,0x00,0x00,0x00 + movq 8(%rsi,%rcx,8),%rdx + adcxq %rax,%r14 + adoxq %rbx,%r15 + adcxq %rbx,%r15 + +.byte 0x67 + incq %rcx + jnz .Lsqrx8x_loop + + leaq 64(%rbp),%rbp + movq $-8,%rcx + cmpq 8+8(%rsp),%rbp + je .Lsqrx8x_break + + subq 16+8(%rsp),%rbx +.byte 0x66 + movq -64(%rsi),%rdx + adcxq 0(%rdi),%r8 + adcxq 8(%rdi),%r9 + adcq 16(%rdi),%r10 + adcq 24(%rdi),%r11 + adcq 32(%rdi),%r12 + adcq 40(%rdi),%r13 + adcq 48(%rdi),%r14 + adcq 56(%rdi),%r15 + leaq 64(%rdi),%rdi +.byte 0x67 + sbbq %rax,%rax + xorl %ebx,%ebx + movq %rax,16+8(%rsp) + jmp .Lsqrx8x_loop + +.align 32 +.Lsqrx8x_break: + xorq %rbp,%rbp + subq 16+8(%rsp),%rbx + adcxq %rbp,%r8 + movq 24+8(%rsp),%rcx + adcxq %rbp,%r9 + movq 0(%rsi),%rdx + adcq $0,%r10 + movq %r8,0(%rdi) + adcq $0,%r11 + adcq $0,%r12 + adcq $0,%r13 + adcq $0,%r14 + adcq $0,%r15 + cmpq %rcx,%rdi + je .Lsqrx8x_outer_loop + + movq %r9,8(%rdi) + movq 8(%rcx),%r9 + movq %r10,16(%rdi) + movq 16(%rcx),%r10 + movq %r11,24(%rdi) + movq 24(%rcx),%r11 + movq %r12,32(%rdi) + movq 32(%rcx),%r12 + movq %r13,40(%rdi) + movq 40(%rcx),%r13 + movq %r14,48(%rdi) + movq 48(%rcx),%r14 + movq %r15,56(%rdi) + movq 56(%rcx),%r15 + movq %rcx,%rdi + jmp .Lsqrx8x_outer_loop + +.align 32 +.Lsqrx8x_outer_break: + movq %r9,72(%rdi) +.byte 102,72,15,126,217 + movq %r10,80(%rdi) + movq %r11,88(%rdi) + movq %r12,96(%rdi) + movq %r13,104(%rdi) + movq %r14,112(%rdi) + leaq 48+8(%rsp),%rdi + movq (%rsi,%rcx,1),%rdx + + movq 8(%rdi),%r11 + xorq %r10,%r10 + movq 0+8(%rsp),%r9 + adoxq %r11,%r11 + movq 16(%rdi),%r12 + movq 24(%rdi),%r13 + + +.align 32 +.Lsqrx4x_shift_n_add: + mulxq %rdx,%rax,%rbx + adoxq %r12,%r12 + adcxq %r10,%rax +.byte 0x48,0x8b,0x94,0x0e,0x08,0x00,0x00,0x00 +.byte 0x4c,0x8b,0x97,0x20,0x00,0x00,0x00 + adoxq %r13,%r13 + adcxq %r11,%rbx + movq 40(%rdi),%r11 + movq %rax,0(%rdi) + movq %rbx,8(%rdi) + + mulxq %rdx,%rax,%rbx + adoxq %r10,%r10 + adcxq %r12,%rax + movq 16(%rsi,%rcx,1),%rdx + movq 48(%rdi),%r12 + adoxq %r11,%r11 + adcxq %r13,%rbx + movq 56(%rdi),%r13 + movq %rax,16(%rdi) + movq %rbx,24(%rdi) + + mulxq %rdx,%rax,%rbx + adoxq %r12,%r12 + adcxq %r10,%rax + movq 24(%rsi,%rcx,1),%rdx + leaq 32(%rcx),%rcx + movq 64(%rdi),%r10 + adoxq %r13,%r13 + adcxq %r11,%rbx + movq 72(%rdi),%r11 + movq %rax,32(%rdi) + movq %rbx,40(%rdi) + + mulxq %rdx,%rax,%rbx + adoxq %r10,%r10 + adcxq %r12,%rax + jrcxz .Lsqrx4x_shift_n_add_break +.byte 0x48,0x8b,0x94,0x0e,0x00,0x00,0x00,0x00 + adoxq %r11,%r11 + adcxq %r13,%rbx + movq 80(%rdi),%r12 + movq 88(%rdi),%r13 + movq %rax,48(%rdi) + movq %rbx,56(%rdi) + leaq 64(%rdi),%rdi + nop + jmp .Lsqrx4x_shift_n_add + +.align 32 +.Lsqrx4x_shift_n_add_break: + adcxq %r13,%rbx + movq %rax,48(%rdi) + movq %rbx,56(%rdi) + leaq 64(%rdi),%rdi +.byte 102,72,15,126,213 +__bn_sqrx8x_reduction: + xorl %eax,%eax + movq 32+8(%rsp),%rbx + movq 48+8(%rsp),%rdx + leaq -64(%rbp,%r9,1),%rcx + + movq %rcx,0+8(%rsp) + movq %rdi,8+8(%rsp) + + leaq 48+8(%rsp),%rdi + jmp .Lsqrx8x_reduction_loop + +.align 32 +.Lsqrx8x_reduction_loop: + movq 8(%rdi),%r9 + movq 16(%rdi),%r10 + movq 24(%rdi),%r11 + movq 32(%rdi),%r12 + movq %rdx,%r8 + imulq %rbx,%rdx + movq 40(%rdi),%r13 + movq 48(%rdi),%r14 + movq 56(%rdi),%r15 + movq %rax,24+8(%rsp) + + leaq 64(%rdi),%rdi + xorq %rsi,%rsi + movq $-8,%rcx + jmp .Lsqrx8x_reduce + +.align 32 +.Lsqrx8x_reduce: + movq %r8,%rbx + mulxq 0(%rbp),%rax,%r8 + adcxq %rbx,%rax + adoxq %r9,%r8 + + mulxq 8(%rbp),%rbx,%r9 + adcxq %rbx,%r8 + adoxq %r10,%r9 + + mulxq 16(%rbp),%rbx,%r10 + adcxq %rbx,%r9 + adoxq %r11,%r10 + + mulxq 24(%rbp),%rbx,%r11 + adcxq %rbx,%r10 + adoxq %r12,%r11 + +.byte 0xc4,0x62,0xe3,0xf6,0xa5,0x20,0x00,0x00,0x00 + movq %rdx,%rax + movq %r8,%rdx + adcxq %rbx,%r11 + adoxq %r13,%r12 + + mulxq 32+8(%rsp),%rbx,%rdx + movq %rax,%rdx + movq %rax,64+48+8(%rsp,%rcx,8) + + mulxq 40(%rbp),%rax,%r13 + adcxq %rax,%r12 + adoxq %r14,%r13 + + mulxq 48(%rbp),%rax,%r14 + adcxq %rax,%r13 + adoxq %r15,%r14 + + mulxq 56(%rbp),%rax,%r15 + movq %rbx,%rdx + adcxq %rax,%r14 + adoxq %rsi,%r15 + adcxq %rsi,%r15 + +.byte 0x67,0x67,0x67 + incq %rcx + jnz .Lsqrx8x_reduce + + movq %rsi,%rax + cmpq 0+8(%rsp),%rbp + jae .Lsqrx8x_no_tail + + movq 48+8(%rsp),%rdx + addq 0(%rdi),%r8 + leaq 64(%rbp),%rbp + movq $-8,%rcx + adcxq 8(%rdi),%r9 + adcxq 16(%rdi),%r10 + adcq 24(%rdi),%r11 + adcq 32(%rdi),%r12 + adcq 40(%rdi),%r13 + adcq 48(%rdi),%r14 + adcq 56(%rdi),%r15 + leaq 64(%rdi),%rdi + sbbq %rax,%rax + + xorq %rsi,%rsi + movq %rax,16+8(%rsp) + jmp .Lsqrx8x_tail + +.align 32 +.Lsqrx8x_tail: + movq %r8,%rbx + mulxq 0(%rbp),%rax,%r8 + adcxq %rax,%rbx + adoxq %r9,%r8 + + mulxq 8(%rbp),%rax,%r9 + adcxq %rax,%r8 + adoxq %r10,%r9 + + mulxq 16(%rbp),%rax,%r10 + adcxq %rax,%r9 + adoxq %r11,%r10 + + mulxq 24(%rbp),%rax,%r11 + adcxq %rax,%r10 + adoxq %r12,%r11 + +.byte 0xc4,0x62,0xfb,0xf6,0xa5,0x20,0x00,0x00,0x00 + adcxq %rax,%r11 + adoxq %r13,%r12 + + mulxq 40(%rbp),%rax,%r13 + adcxq %rax,%r12 + adoxq %r14,%r13 + + mulxq 48(%rbp),%rax,%r14 + adcxq %rax,%r13 + adoxq %r15,%r14 + + mulxq 56(%rbp),%rax,%r15 + movq 72+48+8(%rsp,%rcx,8),%rdx + adcxq %rax,%r14 + adoxq %rsi,%r15 + movq %rbx,(%rdi,%rcx,8) + movq %r8,%rbx + adcxq %rsi,%r15 + + incq %rcx + jnz .Lsqrx8x_tail + + cmpq 0+8(%rsp),%rbp + jae .Lsqrx8x_tail_done + + subq 16+8(%rsp),%rsi + movq 48+8(%rsp),%rdx + leaq 64(%rbp),%rbp + adcq 0(%rdi),%r8 + adcq 8(%rdi),%r9 + adcq 16(%rdi),%r10 + adcq 24(%rdi),%r11 + adcq 32(%rdi),%r12 + adcq 40(%rdi),%r13 + adcq 48(%rdi),%r14 + adcq 56(%rdi),%r15 + leaq 64(%rdi),%rdi + sbbq %rax,%rax + subq $8,%rcx + + xorq %rsi,%rsi + movq %rax,16+8(%rsp) + jmp .Lsqrx8x_tail + +.align 32 +.Lsqrx8x_tail_done: + xorq %rax,%rax + addq 24+8(%rsp),%r8 + adcq $0,%r9 + adcq $0,%r10 + adcq $0,%r11 + adcq $0,%r12 + adcq $0,%r13 + adcq $0,%r14 + adcq $0,%r15 + adcq $0,%rax + + subq 16+8(%rsp),%rsi +.Lsqrx8x_no_tail: + adcq 0(%rdi),%r8 +.byte 102,72,15,126,217 + adcq 8(%rdi),%r9 + movq 56(%rbp),%rsi +.byte 102,72,15,126,213 + adcq 16(%rdi),%r10 + adcq 24(%rdi),%r11 + adcq 32(%rdi),%r12 + adcq 40(%rdi),%r13 + adcq 48(%rdi),%r14 + adcq 56(%rdi),%r15 + adcq $0,%rax + + movq 32+8(%rsp),%rbx + movq 64(%rdi,%rcx,1),%rdx + + movq %r8,0(%rdi) + leaq 64(%rdi),%r8 + movq %r9,8(%rdi) + movq %r10,16(%rdi) + movq %r11,24(%rdi) + movq %r12,32(%rdi) + movq %r13,40(%rdi) + movq %r14,48(%rdi) + movq %r15,56(%rdi) + + leaq 64(%rdi,%rcx,1),%rdi + cmpq 8+8(%rsp),%r8 + jb .Lsqrx8x_reduction_loop + ret +.cfi_endproc +.size bn_sqrx8x_internal,.-bn_sqrx8x_internal +.align 32 +.type __bn_postx4x_internal,@function +__bn_postx4x_internal: +.cfi_startproc + movq 0(%rbp),%r12 + movq %rcx,%r10 + movq %rcx,%r9 + negq %rax + sarq $3+2,%rcx + +.byte 102,72,15,126,202 +.byte 102,72,15,126,206 + decq %r12 + movq 8(%rbp),%r13 + xorq %r8,%r8 + movq 16(%rbp),%r14 + movq 24(%rbp),%r15 + jmp .Lsqrx4x_sub_entry + +.align 16 +.Lsqrx4x_sub: + movq 0(%rbp),%r12 + movq 8(%rbp),%r13 + movq 16(%rbp),%r14 + movq 24(%rbp),%r15 +.Lsqrx4x_sub_entry: + andnq %rax,%r12,%r12 + leaq 32(%rbp),%rbp + andnq %rax,%r13,%r13 + andnq %rax,%r14,%r14 + andnq %rax,%r15,%r15 + + negq %r8 + adcq 0(%rdi),%r12 + adcq 8(%rdi),%r13 + adcq 16(%rdi),%r14 + adcq 24(%rdi),%r15 + movq %r12,0(%rdx) + leaq 32(%rdi),%rdi + movq %r13,8(%rdx) + sbbq %r8,%r8 + movq %r14,16(%rdx) + movq %r15,24(%rdx) + leaq 32(%rdx),%rdx + + incq %rcx + jnz .Lsqrx4x_sub + + negq %r9 + + ret +.cfi_endproc +.size __bn_postx4x_internal,.-__bn_postx4x_internal +.globl bn_scatter5 +.hidden bn_scatter5 +.type bn_scatter5,@function +.align 16 +bn_scatter5: +.cfi_startproc +_CET_ENDBR + cmpl $0,%esi + jz .Lscatter_epilogue + + + + + + + + + + leaq (%rdx,%rcx,8),%rdx +.Lscatter: + movq (%rdi),%rax + leaq 8(%rdi),%rdi + movq %rax,(%rdx) + leaq 256(%rdx),%rdx + subl $1,%esi + jnz .Lscatter +.Lscatter_epilogue: + ret +.cfi_endproc +.size bn_scatter5,.-bn_scatter5 + +.globl bn_gather5 +.hidden bn_gather5 +.type bn_gather5,@function +.align 32 +bn_gather5: +.cfi_startproc +.LSEH_begin_bn_gather5: +_CET_ENDBR + +.byte 0x4c,0x8d,0x14,0x24 +.cfi_def_cfa_register %r10 +.byte 0x48,0x81,0xec,0x08,0x01,0x00,0x00 + leaq .Linc(%rip),%rax + andq $-16,%rsp + + movd %ecx,%xmm5 + movdqa 0(%rax),%xmm0 + movdqa 16(%rax),%xmm1 + leaq 128(%rdx),%r11 + leaq 128(%rsp),%rax + + pshufd $0,%xmm5,%xmm5 + movdqa %xmm1,%xmm4 + movdqa %xmm1,%xmm2 + paddd %xmm0,%xmm1 + pcmpeqd %xmm5,%xmm0 + movdqa %xmm4,%xmm3 + + paddd %xmm1,%xmm2 + pcmpeqd %xmm5,%xmm1 + movdqa %xmm0,-128(%rax) + movdqa %xmm4,%xmm0 + + paddd %xmm2,%xmm3 + pcmpeqd %xmm5,%xmm2 + movdqa %xmm1,-112(%rax) + movdqa %xmm4,%xmm1 + + paddd %xmm3,%xmm0 + pcmpeqd %xmm5,%xmm3 + movdqa %xmm2,-96(%rax) + movdqa %xmm4,%xmm2 + paddd %xmm0,%xmm1 + pcmpeqd %xmm5,%xmm0 + movdqa %xmm3,-80(%rax) + movdqa %xmm4,%xmm3 + + paddd %xmm1,%xmm2 + pcmpeqd %xmm5,%xmm1 + movdqa %xmm0,-64(%rax) + movdqa %xmm4,%xmm0 + + paddd %xmm2,%xmm3 + pcmpeqd %xmm5,%xmm2 + movdqa %xmm1,-48(%rax) + movdqa %xmm4,%xmm1 + + paddd %xmm3,%xmm0 + pcmpeqd %xmm5,%xmm3 + movdqa %xmm2,-32(%rax) + movdqa %xmm4,%xmm2 + paddd %xmm0,%xmm1 + pcmpeqd %xmm5,%xmm0 + movdqa %xmm3,-16(%rax) + movdqa %xmm4,%xmm3 + + paddd %xmm1,%xmm2 + pcmpeqd %xmm5,%xmm1 + movdqa %xmm0,0(%rax) + movdqa %xmm4,%xmm0 + + paddd %xmm2,%xmm3 + pcmpeqd %xmm5,%xmm2 + movdqa %xmm1,16(%rax) + movdqa %xmm4,%xmm1 + + paddd %xmm3,%xmm0 + pcmpeqd %xmm5,%xmm3 + movdqa %xmm2,32(%rax) + movdqa %xmm4,%xmm2 + paddd %xmm0,%xmm1 + pcmpeqd %xmm5,%xmm0 + movdqa %xmm3,48(%rax) + movdqa %xmm4,%xmm3 + + paddd %xmm1,%xmm2 + pcmpeqd %xmm5,%xmm1 + movdqa %xmm0,64(%rax) + movdqa %xmm4,%xmm0 + + paddd %xmm2,%xmm3 + pcmpeqd %xmm5,%xmm2 + movdqa %xmm1,80(%rax) + movdqa %xmm4,%xmm1 + + paddd %xmm3,%xmm0 + pcmpeqd %xmm5,%xmm3 + movdqa %xmm2,96(%rax) + movdqa %xmm4,%xmm2 + movdqa %xmm3,112(%rax) + jmp .Lgather + +.align 32 +.Lgather: + pxor %xmm4,%xmm4 + pxor %xmm5,%xmm5 + movdqa -128(%r11),%xmm0 + movdqa -112(%r11),%xmm1 + movdqa -96(%r11),%xmm2 + pand -128(%rax),%xmm0 + movdqa -80(%r11),%xmm3 + pand -112(%rax),%xmm1 + por %xmm0,%xmm4 + pand -96(%rax),%xmm2 + por %xmm1,%xmm5 + pand -80(%rax),%xmm3 + por %xmm2,%xmm4 + por %xmm3,%xmm5 + movdqa -64(%r11),%xmm0 + movdqa -48(%r11),%xmm1 + movdqa -32(%r11),%xmm2 + pand -64(%rax),%xmm0 + movdqa -16(%r11),%xmm3 + pand -48(%rax),%xmm1 + por %xmm0,%xmm4 + pand -32(%rax),%xmm2 + por %xmm1,%xmm5 + pand -16(%rax),%xmm3 + por %xmm2,%xmm4 + por %xmm3,%xmm5 + movdqa 0(%r11),%xmm0 + movdqa 16(%r11),%xmm1 + movdqa 32(%r11),%xmm2 + pand 0(%rax),%xmm0 + movdqa 48(%r11),%xmm3 + pand 16(%rax),%xmm1 + por %xmm0,%xmm4 + pand 32(%rax),%xmm2 + por %xmm1,%xmm5 + pand 48(%rax),%xmm3 + por %xmm2,%xmm4 + por %xmm3,%xmm5 + movdqa 64(%r11),%xmm0 + movdqa 80(%r11),%xmm1 + movdqa 96(%r11),%xmm2 + pand 64(%rax),%xmm0 + movdqa 112(%r11),%xmm3 + pand 80(%rax),%xmm1 + por %xmm0,%xmm4 + pand 96(%rax),%xmm2 + por %xmm1,%xmm5 + pand 112(%rax),%xmm3 + por %xmm2,%xmm4 + por %xmm3,%xmm5 + por %xmm5,%xmm4 + leaq 256(%r11),%r11 + + pshufd $0x4e,%xmm4,%xmm0 + por %xmm4,%xmm0 + movq %xmm0,(%rdi) + leaq 8(%rdi),%rdi + subl $1,%esi + jnz .Lgather + + leaq (%r10),%rsp +.cfi_def_cfa_register %rsp + ret +.LSEH_end_bn_gather5: +.cfi_endproc +.size bn_gather5,.-bn_gather5 +.section .rodata +.align 64 +.Linc: +.long 0,0, 1,1 +.long 2,2, 2,2 +.byte 77,111,110,116,103,111,109,101,114,121,32,77,117,108,116,105,112,108,105,99,97,116,105,111,110,32,119,105,116,104,32,115,99,97,116,116,101,114,47,103,97,116,104,101,114,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.text +#endif diff --git a/http/vendor/ring/pregenerated/x86_64-mont5-macosx.S b/http/vendor/ring/pregenerated/x86_64-mont5-macosx.S new file mode 100644 index 0000000..dd17dc9 --- /dev/null +++ b/http/vendor/ring/pregenerated/x86_64-mont5-macosx.S @@ -0,0 +1,3188 @@ +// This file is generated from a similarly-named Perl script in the BoringSSL +// source tree. Do not edit by hand. + +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && defined(__APPLE__) +.text + +.globl _bn_mul4x_mont_gather5 +.private_extern _bn_mul4x_mont_gather5 + +.p2align 5 +_bn_mul4x_mont_gather5: + +_CET_ENDBR +.byte 0x67 + movq %rsp,%rax + + pushq %rbx + + pushq %rbp + + pushq %r12 + + pushq %r13 + + pushq %r14 + + pushq %r15 + +L$mul4x_prologue: + +.byte 0x67 + + + + shll $3,%r9d + leaq (%r9,%r9,2),%r10 + negq %r9 + + + + + + + + + + + leaq -320(%rsp,%r9,2),%r11 + movq %rsp,%rbp + subq %rdi,%r11 + andq $4095,%r11 + cmpq %r11,%r10 + jb L$mul4xsp_alt + subq %r11,%rbp + leaq -320(%rbp,%r9,2),%rbp + jmp L$mul4xsp_done + +.p2align 5 +L$mul4xsp_alt: + leaq 4096-320(,%r9,2),%r10 + leaq -320(%rbp,%r9,2),%rbp + subq %r10,%r11 + movq $0,%r10 + cmovcq %r10,%r11 + subq %r11,%rbp +L$mul4xsp_done: + andq $-64,%rbp + movq %rsp,%r11 + subq %rbp,%r11 + andq $-4096,%r11 + leaq (%r11,%rbp,1),%rsp + movq (%rsp),%r10 + cmpq %rbp,%rsp + ja L$mul4x_page_walk + jmp L$mul4x_page_walk_done + +L$mul4x_page_walk: + leaq -4096(%rsp),%rsp + movq (%rsp),%r10 + cmpq %rbp,%rsp + ja L$mul4x_page_walk +L$mul4x_page_walk_done: + + negq %r9 + + movq %rax,40(%rsp) + +L$mul4x_body: + + call mul4x_internal + + movq 40(%rsp),%rsi + + movq $1,%rax + + movq -48(%rsi),%r15 + + movq -40(%rsi),%r14 + + movq -32(%rsi),%r13 + + movq -24(%rsi),%r12 + + movq -16(%rsi),%rbp + + movq -8(%rsi),%rbx + + leaq (%rsi),%rsp + +L$mul4x_epilogue: + ret + + + + +.p2align 5 +mul4x_internal: + + shlq $5,%r9 + movd 8(%rax),%xmm5 + leaq L$inc(%rip),%rax + leaq 128(%rdx,%r9,1),%r13 + shrq $5,%r9 + movdqa 0(%rax),%xmm0 + movdqa 16(%rax),%xmm1 + leaq 88-112(%rsp,%r9,1),%r10 + leaq 128(%rdx),%r12 + + pshufd $0,%xmm5,%xmm5 + movdqa %xmm1,%xmm4 +.byte 0x67,0x67 + movdqa %xmm1,%xmm2 + paddd %xmm0,%xmm1 + pcmpeqd %xmm5,%xmm0 +.byte 0x67 + movdqa %xmm4,%xmm3 + paddd %xmm1,%xmm2 + pcmpeqd %xmm5,%xmm1 + movdqa %xmm0,112(%r10) + movdqa %xmm4,%xmm0 + + paddd %xmm2,%xmm3 + pcmpeqd %xmm5,%xmm2 + movdqa %xmm1,128(%r10) + movdqa %xmm4,%xmm1 + + paddd %xmm3,%xmm0 + pcmpeqd %xmm5,%xmm3 + movdqa %xmm2,144(%r10) + movdqa %xmm4,%xmm2 + + paddd %xmm0,%xmm1 + pcmpeqd %xmm5,%xmm0 + movdqa %xmm3,160(%r10) + movdqa %xmm4,%xmm3 + paddd %xmm1,%xmm2 + pcmpeqd %xmm5,%xmm1 + movdqa %xmm0,176(%r10) + movdqa %xmm4,%xmm0 + + paddd %xmm2,%xmm3 + pcmpeqd %xmm5,%xmm2 + movdqa %xmm1,192(%r10) + movdqa %xmm4,%xmm1 + + paddd %xmm3,%xmm0 + pcmpeqd %xmm5,%xmm3 + movdqa %xmm2,208(%r10) + movdqa %xmm4,%xmm2 + + paddd %xmm0,%xmm1 + pcmpeqd %xmm5,%xmm0 + movdqa %xmm3,224(%r10) + movdqa %xmm4,%xmm3 + paddd %xmm1,%xmm2 + pcmpeqd %xmm5,%xmm1 + movdqa %xmm0,240(%r10) + movdqa %xmm4,%xmm0 + + paddd %xmm2,%xmm3 + pcmpeqd %xmm5,%xmm2 + movdqa %xmm1,256(%r10) + movdqa %xmm4,%xmm1 + + paddd %xmm3,%xmm0 + pcmpeqd %xmm5,%xmm3 + movdqa %xmm2,272(%r10) + movdqa %xmm4,%xmm2 + + paddd %xmm0,%xmm1 + pcmpeqd %xmm5,%xmm0 + movdqa %xmm3,288(%r10) + movdqa %xmm4,%xmm3 + paddd %xmm1,%xmm2 + pcmpeqd %xmm5,%xmm1 + movdqa %xmm0,304(%r10) + + paddd %xmm2,%xmm3 +.byte 0x67 + pcmpeqd %xmm5,%xmm2 + movdqa %xmm1,320(%r10) + + pcmpeqd %xmm5,%xmm3 + movdqa %xmm2,336(%r10) + pand 64(%r12),%xmm0 + + pand 80(%r12),%xmm1 + pand 96(%r12),%xmm2 + movdqa %xmm3,352(%r10) + pand 112(%r12),%xmm3 + por %xmm2,%xmm0 + por %xmm3,%xmm1 + movdqa -128(%r12),%xmm4 + movdqa -112(%r12),%xmm5 + movdqa -96(%r12),%xmm2 + pand 112(%r10),%xmm4 + movdqa -80(%r12),%xmm3 + pand 128(%r10),%xmm5 + por %xmm4,%xmm0 + pand 144(%r10),%xmm2 + por %xmm5,%xmm1 + pand 160(%r10),%xmm3 + por %xmm2,%xmm0 + por %xmm3,%xmm1 + movdqa -64(%r12),%xmm4 + movdqa -48(%r12),%xmm5 + movdqa -32(%r12),%xmm2 + pand 176(%r10),%xmm4 + movdqa -16(%r12),%xmm3 + pand 192(%r10),%xmm5 + por %xmm4,%xmm0 + pand 208(%r10),%xmm2 + por %xmm5,%xmm1 + pand 224(%r10),%xmm3 + por %xmm2,%xmm0 + por %xmm3,%xmm1 + movdqa 0(%r12),%xmm4 + movdqa 16(%r12),%xmm5 + movdqa 32(%r12),%xmm2 + pand 240(%r10),%xmm4 + movdqa 48(%r12),%xmm3 + pand 256(%r10),%xmm5 + por %xmm4,%xmm0 + pand 272(%r10),%xmm2 + por %xmm5,%xmm1 + pand 288(%r10),%xmm3 + por %xmm2,%xmm0 + por %xmm3,%xmm1 + por %xmm1,%xmm0 + + pshufd $0x4e,%xmm0,%xmm1 + por %xmm1,%xmm0 + leaq 256(%r12),%r12 +.byte 102,72,15,126,195 + + movq %r13,16+8(%rsp) + movq %rdi,56+8(%rsp) + + movq (%r8),%r8 + movq (%rsi),%rax + leaq (%rsi,%r9,1),%rsi + negq %r9 + + movq %r8,%rbp + mulq %rbx + movq %rax,%r10 + movq (%rcx),%rax + + imulq %r10,%rbp + leaq 64+8(%rsp),%r14 + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r10 + movq 8(%rsi,%r9,1),%rax + adcq $0,%rdx + movq %rdx,%rdi + + mulq %rbx + addq %rax,%r11 + movq 8(%rcx),%rax + adcq $0,%rdx + movq %rdx,%r10 + + mulq %rbp + addq %rax,%rdi + movq 16(%rsi,%r9,1),%rax + adcq $0,%rdx + addq %r11,%rdi + leaq 32(%r9),%r15 + leaq 32(%rcx),%rcx + adcq $0,%rdx + movq %rdi,(%r14) + movq %rdx,%r13 + jmp L$1st4x + +.p2align 5 +L$1st4x: + mulq %rbx + addq %rax,%r10 + movq -16(%rcx),%rax + leaq 32(%r14),%r14 + adcq $0,%rdx + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r13 + movq -8(%rsi,%r15,1),%rax + adcq $0,%rdx + addq %r10,%r13 + adcq $0,%rdx + movq %r13,-24(%r14) + movq %rdx,%rdi + + mulq %rbx + addq %rax,%r11 + movq -8(%rcx),%rax + adcq $0,%rdx + movq %rdx,%r10 + + mulq %rbp + addq %rax,%rdi + movq (%rsi,%r15,1),%rax + adcq $0,%rdx + addq %r11,%rdi + adcq $0,%rdx + movq %rdi,-16(%r14) + movq %rdx,%r13 + + mulq %rbx + addq %rax,%r10 + movq 0(%rcx),%rax + adcq $0,%rdx + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r13 + movq 8(%rsi,%r15,1),%rax + adcq $0,%rdx + addq %r10,%r13 + adcq $0,%rdx + movq %r13,-8(%r14) + movq %rdx,%rdi + + mulq %rbx + addq %rax,%r11 + movq 8(%rcx),%rax + adcq $0,%rdx + movq %rdx,%r10 + + mulq %rbp + addq %rax,%rdi + movq 16(%rsi,%r15,1),%rax + adcq $0,%rdx + addq %r11,%rdi + leaq 32(%rcx),%rcx + adcq $0,%rdx + movq %rdi,(%r14) + movq %rdx,%r13 + + addq $32,%r15 + jnz L$1st4x + + mulq %rbx + addq %rax,%r10 + movq -16(%rcx),%rax + leaq 32(%r14),%r14 + adcq $0,%rdx + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r13 + movq -8(%rsi),%rax + adcq $0,%rdx + addq %r10,%r13 + adcq $0,%rdx + movq %r13,-24(%r14) + movq %rdx,%rdi + + mulq %rbx + addq %rax,%r11 + movq -8(%rcx),%rax + adcq $0,%rdx + movq %rdx,%r10 + + mulq %rbp + addq %rax,%rdi + movq (%rsi,%r9,1),%rax + adcq $0,%rdx + addq %r11,%rdi + adcq $0,%rdx + movq %rdi,-16(%r14) + movq %rdx,%r13 + + leaq (%rcx,%r9,1),%rcx + + xorq %rdi,%rdi + addq %r10,%r13 + adcq $0,%rdi + movq %r13,-8(%r14) + + jmp L$outer4x + +.p2align 5 +L$outer4x: + leaq 16+128(%r14),%rdx + pxor %xmm4,%xmm4 + pxor %xmm5,%xmm5 + movdqa -128(%r12),%xmm0 + movdqa -112(%r12),%xmm1 + movdqa -96(%r12),%xmm2 + movdqa -80(%r12),%xmm3 + pand -128(%rdx),%xmm0 + pand -112(%rdx),%xmm1 + por %xmm0,%xmm4 + pand -96(%rdx),%xmm2 + por %xmm1,%xmm5 + pand -80(%rdx),%xmm3 + por %xmm2,%xmm4 + por %xmm3,%xmm5 + movdqa -64(%r12),%xmm0 + movdqa -48(%r12),%xmm1 + movdqa -32(%r12),%xmm2 + movdqa -16(%r12),%xmm3 + pand -64(%rdx),%xmm0 + pand -48(%rdx),%xmm1 + por %xmm0,%xmm4 + pand -32(%rdx),%xmm2 + por %xmm1,%xmm5 + pand -16(%rdx),%xmm3 + por %xmm2,%xmm4 + por %xmm3,%xmm5 + movdqa 0(%r12),%xmm0 + movdqa 16(%r12),%xmm1 + movdqa 32(%r12),%xmm2 + movdqa 48(%r12),%xmm3 + pand 0(%rdx),%xmm0 + pand 16(%rdx),%xmm1 + por %xmm0,%xmm4 + pand 32(%rdx),%xmm2 + por %xmm1,%xmm5 + pand 48(%rdx),%xmm3 + por %xmm2,%xmm4 + por %xmm3,%xmm5 + movdqa 64(%r12),%xmm0 + movdqa 80(%r12),%xmm1 + movdqa 96(%r12),%xmm2 + movdqa 112(%r12),%xmm3 + pand 64(%rdx),%xmm0 + pand 80(%rdx),%xmm1 + por %xmm0,%xmm4 + pand 96(%rdx),%xmm2 + por %xmm1,%xmm5 + pand 112(%rdx),%xmm3 + por %xmm2,%xmm4 + por %xmm3,%xmm5 + por %xmm5,%xmm4 + + pshufd $0x4e,%xmm4,%xmm0 + por %xmm4,%xmm0 + leaq 256(%r12),%r12 +.byte 102,72,15,126,195 + + movq (%r14,%r9,1),%r10 + movq %r8,%rbp + mulq %rbx + addq %rax,%r10 + movq (%rcx),%rax + adcq $0,%rdx + + imulq %r10,%rbp + movq %rdx,%r11 + movq %rdi,(%r14) + + leaq (%r14,%r9,1),%r14 + + mulq %rbp + addq %rax,%r10 + movq 8(%rsi,%r9,1),%rax + adcq $0,%rdx + movq %rdx,%rdi + + mulq %rbx + addq %rax,%r11 + movq 8(%rcx),%rax + adcq $0,%rdx + addq 8(%r14),%r11 + adcq $0,%rdx + movq %rdx,%r10 + + mulq %rbp + addq %rax,%rdi + movq 16(%rsi,%r9,1),%rax + adcq $0,%rdx + addq %r11,%rdi + leaq 32(%r9),%r15 + leaq 32(%rcx),%rcx + adcq $0,%rdx + movq %rdx,%r13 + jmp L$inner4x + +.p2align 5 +L$inner4x: + mulq %rbx + addq %rax,%r10 + movq -16(%rcx),%rax + adcq $0,%rdx + addq 16(%r14),%r10 + leaq 32(%r14),%r14 + adcq $0,%rdx + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r13 + movq -8(%rsi,%r15,1),%rax + adcq $0,%rdx + addq %r10,%r13 + adcq $0,%rdx + movq %rdi,-32(%r14) + movq %rdx,%rdi + + mulq %rbx + addq %rax,%r11 + movq -8(%rcx),%rax + adcq $0,%rdx + addq -8(%r14),%r11 + adcq $0,%rdx + movq %rdx,%r10 + + mulq %rbp + addq %rax,%rdi + movq (%rsi,%r15,1),%rax + adcq $0,%rdx + addq %r11,%rdi + adcq $0,%rdx + movq %r13,-24(%r14) + movq %rdx,%r13 + + mulq %rbx + addq %rax,%r10 + movq 0(%rcx),%rax + adcq $0,%rdx + addq (%r14),%r10 + adcq $0,%rdx + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r13 + movq 8(%rsi,%r15,1),%rax + adcq $0,%rdx + addq %r10,%r13 + adcq $0,%rdx + movq %rdi,-16(%r14) + movq %rdx,%rdi + + mulq %rbx + addq %rax,%r11 + movq 8(%rcx),%rax + adcq $0,%rdx + addq 8(%r14),%r11 + adcq $0,%rdx + movq %rdx,%r10 + + mulq %rbp + addq %rax,%rdi + movq 16(%rsi,%r15,1),%rax + adcq $0,%rdx + addq %r11,%rdi + leaq 32(%rcx),%rcx + adcq $0,%rdx + movq %r13,-8(%r14) + movq %rdx,%r13 + + addq $32,%r15 + jnz L$inner4x + + mulq %rbx + addq %rax,%r10 + movq -16(%rcx),%rax + adcq $0,%rdx + addq 16(%r14),%r10 + leaq 32(%r14),%r14 + adcq $0,%rdx + movq %rdx,%r11 + + mulq %rbp + addq %rax,%r13 + movq -8(%rsi),%rax + adcq $0,%rdx + addq %r10,%r13 + adcq $0,%rdx + movq %rdi,-32(%r14) + movq %rdx,%rdi + + mulq %rbx + addq %rax,%r11 + movq %rbp,%rax + movq -8(%rcx),%rbp + adcq $0,%rdx + addq -8(%r14),%r11 + adcq $0,%rdx + movq %rdx,%r10 + + mulq %rbp + addq %rax,%rdi + movq (%rsi,%r9,1),%rax + adcq $0,%rdx + addq %r11,%rdi + adcq $0,%rdx + movq %r13,-24(%r14) + movq %rdx,%r13 + + movq %rdi,-16(%r14) + leaq (%rcx,%r9,1),%rcx + + xorq %rdi,%rdi + addq %r10,%r13 + adcq $0,%rdi + addq (%r14),%r13 + adcq $0,%rdi + movq %r13,-8(%r14) + + cmpq 16+8(%rsp),%r12 + jb L$outer4x + xorq %rax,%rax + subq %r13,%rbp + adcq %r15,%r15 + orq %r15,%rdi + subq %rdi,%rax + leaq (%r14,%r9,1),%rbx + movq (%rcx),%r12 + leaq (%rcx),%rbp + movq %r9,%rcx + sarq $3+2,%rcx + movq 56+8(%rsp),%rdi + decq %r12 + xorq %r10,%r10 + movq 8(%rbp),%r13 + movq 16(%rbp),%r14 + movq 24(%rbp),%r15 + jmp L$sqr4x_sub_entry + + +.globl _bn_power5_nohw +.private_extern _bn_power5_nohw + +.p2align 5 +_bn_power5_nohw: + +_CET_ENDBR + movq %rsp,%rax + + pushq %rbx + + pushq %rbp + + pushq %r12 + + pushq %r13 + + pushq %r14 + + pushq %r15 + +L$power5_prologue: + + + + + shll $3,%r9d + leal (%r9,%r9,2),%r10d + negq %r9 + movq (%r8),%r8 + + + + + + + + + leaq -320(%rsp,%r9,2),%r11 + movq %rsp,%rbp + subq %rdi,%r11 + andq $4095,%r11 + cmpq %r11,%r10 + jb L$pwr_sp_alt + subq %r11,%rbp + leaq -320(%rbp,%r9,2),%rbp + jmp L$pwr_sp_done + +.p2align 5 +L$pwr_sp_alt: + leaq 4096-320(,%r9,2),%r10 + leaq -320(%rbp,%r9,2),%rbp + subq %r10,%r11 + movq $0,%r10 + cmovcq %r10,%r11 + subq %r11,%rbp +L$pwr_sp_done: + andq $-64,%rbp + movq %rsp,%r11 + subq %rbp,%r11 + andq $-4096,%r11 + leaq (%r11,%rbp,1),%rsp + movq (%rsp),%r10 + cmpq %rbp,%rsp + ja L$pwr_page_walk + jmp L$pwr_page_walk_done + +L$pwr_page_walk: + leaq -4096(%rsp),%rsp + movq (%rsp),%r10 + cmpq %rbp,%rsp + ja L$pwr_page_walk +L$pwr_page_walk_done: + + movq %r9,%r10 + negq %r9 + + + + + + + + + + + movq %r8,32(%rsp) + movq %rax,40(%rsp) + +L$power5_body: +.byte 102,72,15,110,207 +.byte 102,72,15,110,209 +.byte 102,73,15,110,218 +.byte 102,72,15,110,226 + + call __bn_sqr8x_internal + call __bn_post4x_internal + call __bn_sqr8x_internal + call __bn_post4x_internal + call __bn_sqr8x_internal + call __bn_post4x_internal + call __bn_sqr8x_internal + call __bn_post4x_internal + call __bn_sqr8x_internal + call __bn_post4x_internal + +.byte 102,72,15,126,209 +.byte 102,72,15,126,226 + movq %rsi,%rdi + movq 40(%rsp),%rax + leaq 32(%rsp),%r8 + + call mul4x_internal + + movq 40(%rsp),%rsi + + movq $1,%rax + movq -48(%rsi),%r15 + + movq -40(%rsi),%r14 + + movq -32(%rsi),%r13 + + movq -24(%rsi),%r12 + + movq -16(%rsi),%rbp + + movq -8(%rsi),%rbx + + leaq (%rsi),%rsp + +L$power5_epilogue: + ret + + + +.globl _bn_sqr8x_internal +.private_extern _bn_sqr8x_internal +.private_extern _bn_sqr8x_internal + +.p2align 5 +_bn_sqr8x_internal: +__bn_sqr8x_internal: + +_CET_ENDBR + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + leaq 32(%r10),%rbp + leaq (%rsi,%r9,1),%rsi + + movq %r9,%rcx + + + movq -32(%rsi,%rbp,1),%r14 + leaq 48+8(%rsp,%r9,2),%rdi + movq -24(%rsi,%rbp,1),%rax + leaq -32(%rdi,%rbp,1),%rdi + movq -16(%rsi,%rbp,1),%rbx + movq %rax,%r15 + + mulq %r14 + movq %rax,%r10 + movq %rbx,%rax + movq %rdx,%r11 + movq %r10,-24(%rdi,%rbp,1) + + mulq %r14 + addq %rax,%r11 + movq %rbx,%rax + adcq $0,%rdx + movq %r11,-16(%rdi,%rbp,1) + movq %rdx,%r10 + + + movq -8(%rsi,%rbp,1),%rbx + mulq %r15 + movq %rax,%r12 + movq %rbx,%rax + movq %rdx,%r13 + + leaq (%rbp),%rcx + mulq %r14 + addq %rax,%r10 + movq %rbx,%rax + movq %rdx,%r11 + adcq $0,%r11 + addq %r12,%r10 + adcq $0,%r11 + movq %r10,-8(%rdi,%rcx,1) + jmp L$sqr4x_1st + +.p2align 5 +L$sqr4x_1st: + movq (%rsi,%rcx,1),%rbx + mulq %r15 + addq %rax,%r13 + movq %rbx,%rax + movq %rdx,%r12 + adcq $0,%r12 + + mulq %r14 + addq %rax,%r11 + movq %rbx,%rax + movq 8(%rsi,%rcx,1),%rbx + movq %rdx,%r10 + adcq $0,%r10 + addq %r13,%r11 + adcq $0,%r10 + + + mulq %r15 + addq %rax,%r12 + movq %rbx,%rax + movq %r11,(%rdi,%rcx,1) + movq %rdx,%r13 + adcq $0,%r13 + + mulq %r14 + addq %rax,%r10 + movq %rbx,%rax + movq 16(%rsi,%rcx,1),%rbx + movq %rdx,%r11 + adcq $0,%r11 + addq %r12,%r10 + adcq $0,%r11 + + mulq %r15 + addq %rax,%r13 + movq %rbx,%rax + movq %r10,8(%rdi,%rcx,1) + movq %rdx,%r12 + adcq $0,%r12 + + mulq %r14 + addq %rax,%r11 + movq %rbx,%rax + movq 24(%rsi,%rcx,1),%rbx + movq %rdx,%r10 + adcq $0,%r10 + addq %r13,%r11 + adcq $0,%r10 + + + mulq %r15 + addq %rax,%r12 + movq %rbx,%rax + movq %r11,16(%rdi,%rcx,1) + movq %rdx,%r13 + adcq $0,%r13 + leaq 32(%rcx),%rcx + + mulq %r14 + addq %rax,%r10 + movq %rbx,%rax + movq %rdx,%r11 + adcq $0,%r11 + addq %r12,%r10 + adcq $0,%r11 + movq %r10,-8(%rdi,%rcx,1) + + cmpq $0,%rcx + jne L$sqr4x_1st + + mulq %r15 + addq %rax,%r13 + leaq 16(%rbp),%rbp + adcq $0,%rdx + addq %r11,%r13 + adcq $0,%rdx + + movq %r13,(%rdi) + movq %rdx,%r12 + movq %rdx,8(%rdi) + jmp L$sqr4x_outer + +.p2align 5 +L$sqr4x_outer: + movq -32(%rsi,%rbp,1),%r14 + leaq 48+8(%rsp,%r9,2),%rdi + movq -24(%rsi,%rbp,1),%rax + leaq -32(%rdi,%rbp,1),%rdi + movq -16(%rsi,%rbp,1),%rbx + movq %rax,%r15 + + mulq %r14 + movq -24(%rdi,%rbp,1),%r10 + addq %rax,%r10 + movq %rbx,%rax + adcq $0,%rdx + movq %r10,-24(%rdi,%rbp,1) + movq %rdx,%r11 + + mulq %r14 + addq %rax,%r11 + movq %rbx,%rax + adcq $0,%rdx + addq -16(%rdi,%rbp,1),%r11 + movq %rdx,%r10 + adcq $0,%r10 + movq %r11,-16(%rdi,%rbp,1) + + xorq %r12,%r12 + + movq -8(%rsi,%rbp,1),%rbx + mulq %r15 + addq %rax,%r12 + movq %rbx,%rax + adcq $0,%rdx + addq -8(%rdi,%rbp,1),%r12 + movq %rdx,%r13 + adcq $0,%r13 + + mulq %r14 + addq %rax,%r10 + movq %rbx,%rax + adcq $0,%rdx + addq %r12,%r10 + movq %rdx,%r11 + adcq $0,%r11 + movq %r10,-8(%rdi,%rbp,1) + + leaq (%rbp),%rcx + jmp L$sqr4x_inner + +.p2align 5 +L$sqr4x_inner: + movq (%rsi,%rcx,1),%rbx + mulq %r15 + addq %rax,%r13 + movq %rbx,%rax + movq %rdx,%r12 + adcq $0,%r12 + addq (%rdi,%rcx,1),%r13 + adcq $0,%r12 + +.byte 0x67 + mulq %r14 + addq %rax,%r11 + movq %rbx,%rax + movq 8(%rsi,%rcx,1),%rbx + movq %rdx,%r10 + adcq $0,%r10 + addq %r13,%r11 + adcq $0,%r10 + + mulq %r15 + addq %rax,%r12 + movq %r11,(%rdi,%rcx,1) + movq %rbx,%rax + movq %rdx,%r13 + adcq $0,%r13 + addq 8(%rdi,%rcx,1),%r12 + leaq 16(%rcx),%rcx + adcq $0,%r13 + + mulq %r14 + addq %rax,%r10 + movq %rbx,%rax + adcq $0,%rdx + addq %r12,%r10 + movq %rdx,%r11 + adcq $0,%r11 + movq %r10,-8(%rdi,%rcx,1) + + cmpq $0,%rcx + jne L$sqr4x_inner + +.byte 0x67 + mulq %r15 + addq %rax,%r13 + adcq $0,%rdx + addq %r11,%r13 + adcq $0,%rdx + + movq %r13,(%rdi) + movq %rdx,%r12 + movq %rdx,8(%rdi) + + addq $16,%rbp + jnz L$sqr4x_outer + + + movq -32(%rsi),%r14 + leaq 48+8(%rsp,%r9,2),%rdi + movq -24(%rsi),%rax + leaq -32(%rdi,%rbp,1),%rdi + movq -16(%rsi),%rbx + movq %rax,%r15 + + mulq %r14 + addq %rax,%r10 + movq %rbx,%rax + movq %rdx,%r11 + adcq $0,%r11 + + mulq %r14 + addq %rax,%r11 + movq %rbx,%rax + movq %r10,-24(%rdi) + movq %rdx,%r10 + adcq $0,%r10 + addq %r13,%r11 + movq -8(%rsi),%rbx + adcq $0,%r10 + + mulq %r15 + addq %rax,%r12 + movq %rbx,%rax + movq %r11,-16(%rdi) + movq %rdx,%r13 + adcq $0,%r13 + + mulq %r14 + addq %rax,%r10 + movq %rbx,%rax + movq %rdx,%r11 + adcq $0,%r11 + addq %r12,%r10 + adcq $0,%r11 + movq %r10,-8(%rdi) + + mulq %r15 + addq %rax,%r13 + movq -16(%rsi),%rax + adcq $0,%rdx + addq %r11,%r13 + adcq $0,%rdx + + movq %r13,(%rdi) + movq %rdx,%r12 + movq %rdx,8(%rdi) + + mulq %rbx + addq $16,%rbp + xorq %r14,%r14 + subq %r9,%rbp + xorq %r15,%r15 + + addq %r12,%rax + adcq $0,%rdx + movq %rax,8(%rdi) + movq %rdx,16(%rdi) + movq %r15,24(%rdi) + + movq -16(%rsi,%rbp,1),%rax + leaq 48+8(%rsp),%rdi + xorq %r10,%r10 + movq 8(%rdi),%r11 + + leaq (%r14,%r10,2),%r12 + shrq $63,%r10 + leaq (%rcx,%r11,2),%r13 + shrq $63,%r11 + orq %r10,%r13 + movq 16(%rdi),%r10 + movq %r11,%r14 + mulq %rax + negq %r15 + movq 24(%rdi),%r11 + adcq %rax,%r12 + movq -8(%rsi,%rbp,1),%rax + movq %r12,(%rdi) + adcq %rdx,%r13 + + leaq (%r14,%r10,2),%rbx + movq %r13,8(%rdi) + sbbq %r15,%r15 + shrq $63,%r10 + leaq (%rcx,%r11,2),%r8 + shrq $63,%r11 + orq %r10,%r8 + movq 32(%rdi),%r10 + movq %r11,%r14 + mulq %rax + negq %r15 + movq 40(%rdi),%r11 + adcq %rax,%rbx + movq 0(%rsi,%rbp,1),%rax + movq %rbx,16(%rdi) + adcq %rdx,%r8 + leaq 16(%rbp),%rbp + movq %r8,24(%rdi) + sbbq %r15,%r15 + leaq 64(%rdi),%rdi + jmp L$sqr4x_shift_n_add + +.p2align 5 +L$sqr4x_shift_n_add: + leaq (%r14,%r10,2),%r12 + shrq $63,%r10 + leaq (%rcx,%r11,2),%r13 + shrq $63,%r11 + orq %r10,%r13 + movq -16(%rdi),%r10 + movq %r11,%r14 + mulq %rax + negq %r15 + movq -8(%rdi),%r11 + adcq %rax,%r12 + movq -8(%rsi,%rbp,1),%rax + movq %r12,-32(%rdi) + adcq %rdx,%r13 + + leaq (%r14,%r10,2),%rbx + movq %r13,-24(%rdi) + sbbq %r15,%r15 + shrq $63,%r10 + leaq (%rcx,%r11,2),%r8 + shrq $63,%r11 + orq %r10,%r8 + movq 0(%rdi),%r10 + movq %r11,%r14 + mulq %rax + negq %r15 + movq 8(%rdi),%r11 + adcq %rax,%rbx + movq 0(%rsi,%rbp,1),%rax + movq %rbx,-16(%rdi) + adcq %rdx,%r8 + + leaq (%r14,%r10,2),%r12 + movq %r8,-8(%rdi) + sbbq %r15,%r15 + shrq $63,%r10 + leaq (%rcx,%r11,2),%r13 + shrq $63,%r11 + orq %r10,%r13 + movq 16(%rdi),%r10 + movq %r11,%r14 + mulq %rax + negq %r15 + movq 24(%rdi),%r11 + adcq %rax,%r12 + movq 8(%rsi,%rbp,1),%rax + movq %r12,0(%rdi) + adcq %rdx,%r13 + + leaq (%r14,%r10,2),%rbx + movq %r13,8(%rdi) + sbbq %r15,%r15 + shrq $63,%r10 + leaq (%rcx,%r11,2),%r8 + shrq $63,%r11 + orq %r10,%r8 + movq 32(%rdi),%r10 + movq %r11,%r14 + mulq %rax + negq %r15 + movq 40(%rdi),%r11 + adcq %rax,%rbx + movq 16(%rsi,%rbp,1),%rax + movq %rbx,16(%rdi) + adcq %rdx,%r8 + movq %r8,24(%rdi) + sbbq %r15,%r15 + leaq 64(%rdi),%rdi + addq $32,%rbp + jnz L$sqr4x_shift_n_add + + leaq (%r14,%r10,2),%r12 +.byte 0x67 + shrq $63,%r10 + leaq (%rcx,%r11,2),%r13 + shrq $63,%r11 + orq %r10,%r13 + movq -16(%rdi),%r10 + movq %r11,%r14 + mulq %rax + negq %r15 + movq -8(%rdi),%r11 + adcq %rax,%r12 + movq -8(%rsi),%rax + movq %r12,-32(%rdi) + adcq %rdx,%r13 + + leaq (%r14,%r10,2),%rbx + movq %r13,-24(%rdi) + sbbq %r15,%r15 + shrq $63,%r10 + leaq (%rcx,%r11,2),%r8 + shrq $63,%r11 + orq %r10,%r8 + mulq %rax + negq %r15 + adcq %rax,%rbx + adcq %rdx,%r8 + movq %rbx,-16(%rdi) + movq %r8,-8(%rdi) +.byte 102,72,15,126,213 +__bn_sqr8x_reduction: + xorq %rax,%rax + leaq (%r9,%rbp,1),%rcx + leaq 48+8(%rsp,%r9,2),%rdx + movq %rcx,0+8(%rsp) + leaq 48+8(%rsp,%r9,1),%rdi + movq %rdx,8+8(%rsp) + negq %r9 + jmp L$8x_reduction_loop + +.p2align 5 +L$8x_reduction_loop: + leaq (%rdi,%r9,1),%rdi +.byte 0x66 + movq 0(%rdi),%rbx + movq 8(%rdi),%r9 + movq 16(%rdi),%r10 + movq 24(%rdi),%r11 + movq 32(%rdi),%r12 + movq 40(%rdi),%r13 + movq 48(%rdi),%r14 + movq 56(%rdi),%r15 + movq %rax,(%rdx) + leaq 64(%rdi),%rdi + +.byte 0x67 + movq %rbx,%r8 + imulq 32+8(%rsp),%rbx + movq 0(%rbp),%rax + movl $8,%ecx + jmp L$8x_reduce + +.p2align 5 +L$8x_reduce: + mulq %rbx + movq 8(%rbp),%rax + negq %r8 + movq %rdx,%r8 + adcq $0,%r8 + + mulq %rbx + addq %rax,%r9 + movq 16(%rbp),%rax + adcq $0,%rdx + addq %r9,%r8 + movq %rbx,48-8+8(%rsp,%rcx,8) + movq %rdx,%r9 + adcq $0,%r9 + + mulq %rbx + addq %rax,%r10 + movq 24(%rbp),%rax + adcq $0,%rdx + addq %r10,%r9 + movq 32+8(%rsp),%rsi + movq %rdx,%r10 + adcq $0,%r10 + + mulq %rbx + addq %rax,%r11 + movq 32(%rbp),%rax + adcq $0,%rdx + imulq %r8,%rsi + addq %r11,%r10 + movq %rdx,%r11 + adcq $0,%r11 + + mulq %rbx + addq %rax,%r12 + movq 40(%rbp),%rax + adcq $0,%rdx + addq %r12,%r11 + movq %rdx,%r12 + adcq $0,%r12 + + mulq %rbx + addq %rax,%r13 + movq 48(%rbp),%rax + adcq $0,%rdx + addq %r13,%r12 + movq %rdx,%r13 + adcq $0,%r13 + + mulq %rbx + addq %rax,%r14 + movq 56(%rbp),%rax + adcq $0,%rdx + addq %r14,%r13 + movq %rdx,%r14 + adcq $0,%r14 + + mulq %rbx + movq %rsi,%rbx + addq %rax,%r15 + movq 0(%rbp),%rax + adcq $0,%rdx + addq %r15,%r14 + movq %rdx,%r15 + adcq $0,%r15 + + decl %ecx + jnz L$8x_reduce + + leaq 64(%rbp),%rbp + xorq %rax,%rax + movq 8+8(%rsp),%rdx + cmpq 0+8(%rsp),%rbp + jae L$8x_no_tail + +.byte 0x66 + addq 0(%rdi),%r8 + adcq 8(%rdi),%r9 + adcq 16(%rdi),%r10 + adcq 24(%rdi),%r11 + adcq 32(%rdi),%r12 + adcq 40(%rdi),%r13 + adcq 48(%rdi),%r14 + adcq 56(%rdi),%r15 + sbbq %rsi,%rsi + + movq 48+56+8(%rsp),%rbx + movl $8,%ecx + movq 0(%rbp),%rax + jmp L$8x_tail + +.p2align 5 +L$8x_tail: + mulq %rbx + addq %rax,%r8 + movq 8(%rbp),%rax + movq %r8,(%rdi) + movq %rdx,%r8 + adcq $0,%r8 + + mulq %rbx + addq %rax,%r9 + movq 16(%rbp),%rax + adcq $0,%rdx + addq %r9,%r8 + leaq 8(%rdi),%rdi + movq %rdx,%r9 + adcq $0,%r9 + + mulq %rbx + addq %rax,%r10 + movq 24(%rbp),%rax + adcq $0,%rdx + addq %r10,%r9 + movq %rdx,%r10 + adcq $0,%r10 + + mulq %rbx + addq %rax,%r11 + movq 32(%rbp),%rax + adcq $0,%rdx + addq %r11,%r10 + movq %rdx,%r11 + adcq $0,%r11 + + mulq %rbx + addq %rax,%r12 + movq 40(%rbp),%rax + adcq $0,%rdx + addq %r12,%r11 + movq %rdx,%r12 + adcq $0,%r12 + + mulq %rbx + addq %rax,%r13 + movq 48(%rbp),%rax + adcq $0,%rdx + addq %r13,%r12 + movq %rdx,%r13 + adcq $0,%r13 + + mulq %rbx + addq %rax,%r14 + movq 56(%rbp),%rax + adcq $0,%rdx + addq %r14,%r13 + movq %rdx,%r14 + adcq $0,%r14 + + mulq %rbx + movq 48-16+8(%rsp,%rcx,8),%rbx + addq %rax,%r15 + adcq $0,%rdx + addq %r15,%r14 + movq 0(%rbp),%rax + movq %rdx,%r15 + adcq $0,%r15 + + decl %ecx + jnz L$8x_tail + + leaq 64(%rbp),%rbp + movq 8+8(%rsp),%rdx + cmpq 0+8(%rsp),%rbp + jae L$8x_tail_done + + movq 48+56+8(%rsp),%rbx + negq %rsi + movq 0(%rbp),%rax + adcq 0(%rdi),%r8 + adcq 8(%rdi),%r9 + adcq 16(%rdi),%r10 + adcq 24(%rdi),%r11 + adcq 32(%rdi),%r12 + adcq 40(%rdi),%r13 + adcq 48(%rdi),%r14 + adcq 56(%rdi),%r15 + sbbq %rsi,%rsi + + movl $8,%ecx + jmp L$8x_tail + +.p2align 5 +L$8x_tail_done: + xorq %rax,%rax + addq (%rdx),%r8 + adcq $0,%r9 + adcq $0,%r10 + adcq $0,%r11 + adcq $0,%r12 + adcq $0,%r13 + adcq $0,%r14 + adcq $0,%r15 + adcq $0,%rax + + negq %rsi +L$8x_no_tail: + adcq 0(%rdi),%r8 + adcq 8(%rdi),%r9 + adcq 16(%rdi),%r10 + adcq 24(%rdi),%r11 + adcq 32(%rdi),%r12 + adcq 40(%rdi),%r13 + adcq 48(%rdi),%r14 + adcq 56(%rdi),%r15 + adcq $0,%rax + movq -8(%rbp),%rcx + xorq %rsi,%rsi + +.byte 102,72,15,126,213 + + movq %r8,0(%rdi) + movq %r9,8(%rdi) +.byte 102,73,15,126,217 + movq %r10,16(%rdi) + movq %r11,24(%rdi) + movq %r12,32(%rdi) + movq %r13,40(%rdi) + movq %r14,48(%rdi) + movq %r15,56(%rdi) + leaq 64(%rdi),%rdi + + cmpq %rdx,%rdi + jb L$8x_reduction_loop + ret + + + +.p2align 5 +__bn_post4x_internal: + + movq 0(%rbp),%r12 + leaq (%rdi,%r9,1),%rbx + movq %r9,%rcx +.byte 102,72,15,126,207 + negq %rax +.byte 102,72,15,126,206 + sarq $3+2,%rcx + decq %r12 + xorq %r10,%r10 + movq 8(%rbp),%r13 + movq 16(%rbp),%r14 + movq 24(%rbp),%r15 + jmp L$sqr4x_sub_entry + +.p2align 4 +L$sqr4x_sub: + movq 0(%rbp),%r12 + movq 8(%rbp),%r13 + movq 16(%rbp),%r14 + movq 24(%rbp),%r15 +L$sqr4x_sub_entry: + leaq 32(%rbp),%rbp + notq %r12 + notq %r13 + notq %r14 + notq %r15 + andq %rax,%r12 + andq %rax,%r13 + andq %rax,%r14 + andq %rax,%r15 + + negq %r10 + adcq 0(%rbx),%r12 + adcq 8(%rbx),%r13 + adcq 16(%rbx),%r14 + adcq 24(%rbx),%r15 + movq %r12,0(%rdi) + leaq 32(%rbx),%rbx + movq %r13,8(%rdi) + sbbq %r10,%r10 + movq %r14,16(%rdi) + movq %r15,24(%rdi) + leaq 32(%rdi),%rdi + + incq %rcx + jnz L$sqr4x_sub + + movq %r9,%r10 + negq %r9 + ret + + +.globl _bn_mulx4x_mont_gather5 +.private_extern _bn_mulx4x_mont_gather5 + +.p2align 5 +_bn_mulx4x_mont_gather5: + +_CET_ENDBR + movq %rsp,%rax + + pushq %rbx + + pushq %rbp + + pushq %r12 + + pushq %r13 + + pushq %r14 + + pushq %r15 + +L$mulx4x_prologue: + + + + + shll $3,%r9d + leaq (%r9,%r9,2),%r10 + negq %r9 + movq (%r8),%r8 + + + + + + + + + + + leaq -320(%rsp,%r9,2),%r11 + movq %rsp,%rbp + subq %rdi,%r11 + andq $4095,%r11 + cmpq %r11,%r10 + jb L$mulx4xsp_alt + subq %r11,%rbp + leaq -320(%rbp,%r9,2),%rbp + jmp L$mulx4xsp_done + +L$mulx4xsp_alt: + leaq 4096-320(,%r9,2),%r10 + leaq -320(%rbp,%r9,2),%rbp + subq %r10,%r11 + movq $0,%r10 + cmovcq %r10,%r11 + subq %r11,%rbp +L$mulx4xsp_done: + andq $-64,%rbp + movq %rsp,%r11 + subq %rbp,%r11 + andq $-4096,%r11 + leaq (%r11,%rbp,1),%rsp + movq (%rsp),%r10 + cmpq %rbp,%rsp + ja L$mulx4x_page_walk + jmp L$mulx4x_page_walk_done + +L$mulx4x_page_walk: + leaq -4096(%rsp),%rsp + movq (%rsp),%r10 + cmpq %rbp,%rsp + ja L$mulx4x_page_walk +L$mulx4x_page_walk_done: + + + + + + + + + + + + + + movq %r8,32(%rsp) + movq %rax,40(%rsp) + +L$mulx4x_body: + call mulx4x_internal + + movq 40(%rsp),%rsi + + movq $1,%rax + + movq -48(%rsi),%r15 + + movq -40(%rsi),%r14 + + movq -32(%rsi),%r13 + + movq -24(%rsi),%r12 + + movq -16(%rsi),%rbp + + movq -8(%rsi),%rbx + + leaq (%rsi),%rsp + +L$mulx4x_epilogue: + ret + + + + +.p2align 5 +mulx4x_internal: + + movq %r9,8(%rsp) + movq %r9,%r10 + negq %r9 + shlq $5,%r9 + negq %r10 + leaq 128(%rdx,%r9,1),%r13 + shrq $5+5,%r9 + movd 8(%rax),%xmm5 + subq $1,%r9 + leaq L$inc(%rip),%rax + movq %r13,16+8(%rsp) + movq %r9,24+8(%rsp) + movq %rdi,56+8(%rsp) + movdqa 0(%rax),%xmm0 + movdqa 16(%rax),%xmm1 + leaq 88-112(%rsp,%r10,1),%r10 + leaq 128(%rdx),%rdi + + pshufd $0,%xmm5,%xmm5 + movdqa %xmm1,%xmm4 +.byte 0x67 + movdqa %xmm1,%xmm2 +.byte 0x67 + paddd %xmm0,%xmm1 + pcmpeqd %xmm5,%xmm0 + movdqa %xmm4,%xmm3 + paddd %xmm1,%xmm2 + pcmpeqd %xmm5,%xmm1 + movdqa %xmm0,112(%r10) + movdqa %xmm4,%xmm0 + + paddd %xmm2,%xmm3 + pcmpeqd %xmm5,%xmm2 + movdqa %xmm1,128(%r10) + movdqa %xmm4,%xmm1 + + paddd %xmm3,%xmm0 + pcmpeqd %xmm5,%xmm3 + movdqa %xmm2,144(%r10) + movdqa %xmm4,%xmm2 + + paddd %xmm0,%xmm1 + pcmpeqd %xmm5,%xmm0 + movdqa %xmm3,160(%r10) + movdqa %xmm4,%xmm3 + paddd %xmm1,%xmm2 + pcmpeqd %xmm5,%xmm1 + movdqa %xmm0,176(%r10) + movdqa %xmm4,%xmm0 + + paddd %xmm2,%xmm3 + pcmpeqd %xmm5,%xmm2 + movdqa %xmm1,192(%r10) + movdqa %xmm4,%xmm1 + + paddd %xmm3,%xmm0 + pcmpeqd %xmm5,%xmm3 + movdqa %xmm2,208(%r10) + movdqa %xmm4,%xmm2 + + paddd %xmm0,%xmm1 + pcmpeqd %xmm5,%xmm0 + movdqa %xmm3,224(%r10) + movdqa %xmm4,%xmm3 + paddd %xmm1,%xmm2 + pcmpeqd %xmm5,%xmm1 + movdqa %xmm0,240(%r10) + movdqa %xmm4,%xmm0 + + paddd %xmm2,%xmm3 + pcmpeqd %xmm5,%xmm2 + movdqa %xmm1,256(%r10) + movdqa %xmm4,%xmm1 + + paddd %xmm3,%xmm0 + pcmpeqd %xmm5,%xmm3 + movdqa %xmm2,272(%r10) + movdqa %xmm4,%xmm2 + + paddd %xmm0,%xmm1 + pcmpeqd %xmm5,%xmm0 + movdqa %xmm3,288(%r10) + movdqa %xmm4,%xmm3 +.byte 0x67 + paddd %xmm1,%xmm2 + pcmpeqd %xmm5,%xmm1 + movdqa %xmm0,304(%r10) + + paddd %xmm2,%xmm3 + pcmpeqd %xmm5,%xmm2 + movdqa %xmm1,320(%r10) + + pcmpeqd %xmm5,%xmm3 + movdqa %xmm2,336(%r10) + + pand 64(%rdi),%xmm0 + pand 80(%rdi),%xmm1 + pand 96(%rdi),%xmm2 + movdqa %xmm3,352(%r10) + pand 112(%rdi),%xmm3 + por %xmm2,%xmm0 + por %xmm3,%xmm1 + movdqa -128(%rdi),%xmm4 + movdqa -112(%rdi),%xmm5 + movdqa -96(%rdi),%xmm2 + pand 112(%r10),%xmm4 + movdqa -80(%rdi),%xmm3 + pand 128(%r10),%xmm5 + por %xmm4,%xmm0 + pand 144(%r10),%xmm2 + por %xmm5,%xmm1 + pand 160(%r10),%xmm3 + por %xmm2,%xmm0 + por %xmm3,%xmm1 + movdqa -64(%rdi),%xmm4 + movdqa -48(%rdi),%xmm5 + movdqa -32(%rdi),%xmm2 + pand 176(%r10),%xmm4 + movdqa -16(%rdi),%xmm3 + pand 192(%r10),%xmm5 + por %xmm4,%xmm0 + pand 208(%r10),%xmm2 + por %xmm5,%xmm1 + pand 224(%r10),%xmm3 + por %xmm2,%xmm0 + por %xmm3,%xmm1 + movdqa 0(%rdi),%xmm4 + movdqa 16(%rdi),%xmm5 + movdqa 32(%rdi),%xmm2 + pand 240(%r10),%xmm4 + movdqa 48(%rdi),%xmm3 + pand 256(%r10),%xmm5 + por %xmm4,%xmm0 + pand 272(%r10),%xmm2 + por %xmm5,%xmm1 + pand 288(%r10),%xmm3 + por %xmm2,%xmm0 + por %xmm3,%xmm1 + pxor %xmm1,%xmm0 + + pshufd $0x4e,%xmm0,%xmm1 + por %xmm1,%xmm0 + leaq 256(%rdi),%rdi +.byte 102,72,15,126,194 + leaq 64+32+8(%rsp),%rbx + + movq %rdx,%r9 + mulxq 0(%rsi),%r8,%rax + mulxq 8(%rsi),%r11,%r12 + addq %rax,%r11 + mulxq 16(%rsi),%rax,%r13 + adcq %rax,%r12 + adcq $0,%r13 + mulxq 24(%rsi),%rax,%r14 + + movq %r8,%r15 + imulq 32+8(%rsp),%r8 + xorq %rbp,%rbp + movq %r8,%rdx + + movq %rdi,8+8(%rsp) + + leaq 32(%rsi),%rsi + adcxq %rax,%r13 + adcxq %rbp,%r14 + + mulxq 0(%rcx),%rax,%r10 + adcxq %rax,%r15 + adoxq %r11,%r10 + mulxq 8(%rcx),%rax,%r11 + adcxq %rax,%r10 + adoxq %r12,%r11 + mulxq 16(%rcx),%rax,%r12 + movq 24+8(%rsp),%rdi + movq %r10,-32(%rbx) + adcxq %rax,%r11 + adoxq %r13,%r12 + mulxq 24(%rcx),%rax,%r15 + movq %r9,%rdx + movq %r11,-24(%rbx) + adcxq %rax,%r12 + adoxq %rbp,%r15 + leaq 32(%rcx),%rcx + movq %r12,-16(%rbx) + jmp L$mulx4x_1st + +.p2align 5 +L$mulx4x_1st: + adcxq %rbp,%r15 + mulxq 0(%rsi),%r10,%rax + adcxq %r14,%r10 + mulxq 8(%rsi),%r11,%r14 + adcxq %rax,%r11 + mulxq 16(%rsi),%r12,%rax + adcxq %r14,%r12 + mulxq 24(%rsi),%r13,%r14 +.byte 0x67,0x67 + movq %r8,%rdx + adcxq %rax,%r13 + adcxq %rbp,%r14 + leaq 32(%rsi),%rsi + leaq 32(%rbx),%rbx + + adoxq %r15,%r10 + mulxq 0(%rcx),%rax,%r15 + adcxq %rax,%r10 + adoxq %r15,%r11 + mulxq 8(%rcx),%rax,%r15 + adcxq %rax,%r11 + adoxq %r15,%r12 + mulxq 16(%rcx),%rax,%r15 + movq %r10,-40(%rbx) + adcxq %rax,%r12 + movq %r11,-32(%rbx) + adoxq %r15,%r13 + mulxq 24(%rcx),%rax,%r15 + movq %r9,%rdx + movq %r12,-24(%rbx) + adcxq %rax,%r13 + adoxq %rbp,%r15 + leaq 32(%rcx),%rcx + movq %r13,-16(%rbx) + + decq %rdi + jnz L$mulx4x_1st + + movq 8(%rsp),%rax + adcq %rbp,%r15 + leaq (%rsi,%rax,1),%rsi + addq %r15,%r14 + movq 8+8(%rsp),%rdi + adcq %rbp,%rbp + movq %r14,-8(%rbx) + jmp L$mulx4x_outer + +.p2align 5 +L$mulx4x_outer: + leaq 16-256(%rbx),%r10 + pxor %xmm4,%xmm4 +.byte 0x67,0x67 + pxor %xmm5,%xmm5 + movdqa -128(%rdi),%xmm0 + movdqa -112(%rdi),%xmm1 + movdqa -96(%rdi),%xmm2 + pand 256(%r10),%xmm0 + movdqa -80(%rdi),%xmm3 + pand 272(%r10),%xmm1 + por %xmm0,%xmm4 + pand 288(%r10),%xmm2 + por %xmm1,%xmm5 + pand 304(%r10),%xmm3 + por %xmm2,%xmm4 + por %xmm3,%xmm5 + movdqa -64(%rdi),%xmm0 + movdqa -48(%rdi),%xmm1 + movdqa -32(%rdi),%xmm2 + pand 320(%r10),%xmm0 + movdqa -16(%rdi),%xmm3 + pand 336(%r10),%xmm1 + por %xmm0,%xmm4 + pand 352(%r10),%xmm2 + por %xmm1,%xmm5 + pand 368(%r10),%xmm3 + por %xmm2,%xmm4 + por %xmm3,%xmm5 + movdqa 0(%rdi),%xmm0 + movdqa 16(%rdi),%xmm1 + movdqa 32(%rdi),%xmm2 + pand 384(%r10),%xmm0 + movdqa 48(%rdi),%xmm3 + pand 400(%r10),%xmm1 + por %xmm0,%xmm4 + pand 416(%r10),%xmm2 + por %xmm1,%xmm5 + pand 432(%r10),%xmm3 + por %xmm2,%xmm4 + por %xmm3,%xmm5 + movdqa 64(%rdi),%xmm0 + movdqa 80(%rdi),%xmm1 + movdqa 96(%rdi),%xmm2 + pand 448(%r10),%xmm0 + movdqa 112(%rdi),%xmm3 + pand 464(%r10),%xmm1 + por %xmm0,%xmm4 + pand 480(%r10),%xmm2 + por %xmm1,%xmm5 + pand 496(%r10),%xmm3 + por %xmm2,%xmm4 + por %xmm3,%xmm5 + por %xmm5,%xmm4 + + pshufd $0x4e,%xmm4,%xmm0 + por %xmm4,%xmm0 + leaq 256(%rdi),%rdi +.byte 102,72,15,126,194 + + movq %rbp,(%rbx) + leaq 32(%rbx,%rax,1),%rbx + mulxq 0(%rsi),%r8,%r11 + xorq %rbp,%rbp + movq %rdx,%r9 + mulxq 8(%rsi),%r14,%r12 + adoxq -32(%rbx),%r8 + adcxq %r14,%r11 + mulxq 16(%rsi),%r15,%r13 + adoxq -24(%rbx),%r11 + adcxq %r15,%r12 + mulxq 24(%rsi),%rdx,%r14 + adoxq -16(%rbx),%r12 + adcxq %rdx,%r13 + leaq (%rcx,%rax,1),%rcx + leaq 32(%rsi),%rsi + adoxq -8(%rbx),%r13 + adcxq %rbp,%r14 + adoxq %rbp,%r14 + + movq %r8,%r15 + imulq 32+8(%rsp),%r8 + + movq %r8,%rdx + xorq %rbp,%rbp + movq %rdi,8+8(%rsp) + + mulxq 0(%rcx),%rax,%r10 + adcxq %rax,%r15 + adoxq %r11,%r10 + mulxq 8(%rcx),%rax,%r11 + adcxq %rax,%r10 + adoxq %r12,%r11 + mulxq 16(%rcx),%rax,%r12 + adcxq %rax,%r11 + adoxq %r13,%r12 + mulxq 24(%rcx),%rax,%r15 + movq %r9,%rdx + movq 24+8(%rsp),%rdi + movq %r10,-32(%rbx) + adcxq %rax,%r12 + movq %r11,-24(%rbx) + adoxq %rbp,%r15 + movq %r12,-16(%rbx) + leaq 32(%rcx),%rcx + jmp L$mulx4x_inner + +.p2align 5 +L$mulx4x_inner: + mulxq 0(%rsi),%r10,%rax + adcxq %rbp,%r15 + adoxq %r14,%r10 + mulxq 8(%rsi),%r11,%r14 + adcxq 0(%rbx),%r10 + adoxq %rax,%r11 + mulxq 16(%rsi),%r12,%rax + adcxq 8(%rbx),%r11 + adoxq %r14,%r12 + mulxq 24(%rsi),%r13,%r14 + movq %r8,%rdx + adcxq 16(%rbx),%r12 + adoxq %rax,%r13 + adcxq 24(%rbx),%r13 + adoxq %rbp,%r14 + leaq 32(%rsi),%rsi + leaq 32(%rbx),%rbx + adcxq %rbp,%r14 + + adoxq %r15,%r10 + mulxq 0(%rcx),%rax,%r15 + adcxq %rax,%r10 + adoxq %r15,%r11 + mulxq 8(%rcx),%rax,%r15 + adcxq %rax,%r11 + adoxq %r15,%r12 + mulxq 16(%rcx),%rax,%r15 + movq %r10,-40(%rbx) + adcxq %rax,%r12 + adoxq %r15,%r13 + movq %r11,-32(%rbx) + mulxq 24(%rcx),%rax,%r15 + movq %r9,%rdx + leaq 32(%rcx),%rcx + movq %r12,-24(%rbx) + adcxq %rax,%r13 + adoxq %rbp,%r15 + movq %r13,-16(%rbx) + + decq %rdi + jnz L$mulx4x_inner + + movq 0+8(%rsp),%rax + adcq %rbp,%r15 + subq 0(%rbx),%rdi + movq 8+8(%rsp),%rdi + movq 16+8(%rsp),%r10 + adcq %r15,%r14 + leaq (%rsi,%rax,1),%rsi + adcq %rbp,%rbp + movq %r14,-8(%rbx) + + cmpq %r10,%rdi + jb L$mulx4x_outer + + movq -8(%rcx),%r10 + movq %rbp,%r8 + movq (%rcx,%rax,1),%r12 + leaq (%rcx,%rax,1),%rbp + movq %rax,%rcx + leaq (%rbx,%rax,1),%rdi + xorl %eax,%eax + xorq %r15,%r15 + subq %r14,%r10 + adcq %r15,%r15 + orq %r15,%r8 + sarq $3+2,%rcx + subq %r8,%rax + movq 56+8(%rsp),%rdx + decq %r12 + movq 8(%rbp),%r13 + xorq %r8,%r8 + movq 16(%rbp),%r14 + movq 24(%rbp),%r15 + jmp L$sqrx4x_sub_entry + + +.globl _bn_powerx5 +.private_extern _bn_powerx5 + +.p2align 5 +_bn_powerx5: + +_CET_ENDBR + movq %rsp,%rax + + pushq %rbx + + pushq %rbp + + pushq %r12 + + pushq %r13 + + pushq %r14 + + pushq %r15 + +L$powerx5_prologue: + + + + + shll $3,%r9d + leaq (%r9,%r9,2),%r10 + negq %r9 + movq (%r8),%r8 + + + + + + + + + leaq -320(%rsp,%r9,2),%r11 + movq %rsp,%rbp + subq %rdi,%r11 + andq $4095,%r11 + cmpq %r11,%r10 + jb L$pwrx_sp_alt + subq %r11,%rbp + leaq -320(%rbp,%r9,2),%rbp + jmp L$pwrx_sp_done + +.p2align 5 +L$pwrx_sp_alt: + leaq 4096-320(,%r9,2),%r10 + leaq -320(%rbp,%r9,2),%rbp + subq %r10,%r11 + movq $0,%r10 + cmovcq %r10,%r11 + subq %r11,%rbp +L$pwrx_sp_done: + andq $-64,%rbp + movq %rsp,%r11 + subq %rbp,%r11 + andq $-4096,%r11 + leaq (%r11,%rbp,1),%rsp + movq (%rsp),%r10 + cmpq %rbp,%rsp + ja L$pwrx_page_walk + jmp L$pwrx_page_walk_done + +L$pwrx_page_walk: + leaq -4096(%rsp),%rsp + movq (%rsp),%r10 + cmpq %rbp,%rsp + ja L$pwrx_page_walk +L$pwrx_page_walk_done: + + movq %r9,%r10 + negq %r9 + + + + + + + + + + + + + pxor %xmm0,%xmm0 +.byte 102,72,15,110,207 +.byte 102,72,15,110,209 +.byte 102,73,15,110,218 +.byte 102,72,15,110,226 + movq %r8,32(%rsp) + movq %rax,40(%rsp) + +L$powerx5_body: + + call __bn_sqrx8x_internal + call __bn_postx4x_internal + call __bn_sqrx8x_internal + call __bn_postx4x_internal + call __bn_sqrx8x_internal + call __bn_postx4x_internal + call __bn_sqrx8x_internal + call __bn_postx4x_internal + call __bn_sqrx8x_internal + call __bn_postx4x_internal + + movq %r10,%r9 + movq %rsi,%rdi +.byte 102,72,15,126,209 +.byte 102,72,15,126,226 + movq 40(%rsp),%rax + + call mulx4x_internal + + movq 40(%rsp),%rsi + + movq $1,%rax + + movq -48(%rsi),%r15 + + movq -40(%rsi),%r14 + + movq -32(%rsi),%r13 + + movq -24(%rsi),%r12 + + movq -16(%rsi),%rbp + + movq -8(%rsi),%rbx + + leaq (%rsi),%rsp + +L$powerx5_epilogue: + ret + + + +.globl _bn_sqrx8x_internal +.private_extern _bn_sqrx8x_internal +.private_extern _bn_sqrx8x_internal + +.p2align 5 +_bn_sqrx8x_internal: +__bn_sqrx8x_internal: + +_CET_ENDBR + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + leaq 48+8(%rsp),%rdi + leaq (%rsi,%r9,1),%rbp + movq %r9,0+8(%rsp) + movq %rbp,8+8(%rsp) + jmp L$sqr8x_zero_start + +.p2align 5 +.byte 0x66,0x66,0x66,0x2e,0x0f,0x1f,0x84,0x00,0x00,0x00,0x00,0x00 +L$sqrx8x_zero: +.byte 0x3e + movdqa %xmm0,0(%rdi) + movdqa %xmm0,16(%rdi) + movdqa %xmm0,32(%rdi) + movdqa %xmm0,48(%rdi) +L$sqr8x_zero_start: + movdqa %xmm0,64(%rdi) + movdqa %xmm0,80(%rdi) + movdqa %xmm0,96(%rdi) + movdqa %xmm0,112(%rdi) + leaq 128(%rdi),%rdi + subq $64,%r9 + jnz L$sqrx8x_zero + + movq 0(%rsi),%rdx + + xorq %r10,%r10 + xorq %r11,%r11 + xorq %r12,%r12 + xorq %r13,%r13 + xorq %r14,%r14 + xorq %r15,%r15 + leaq 48+8(%rsp),%rdi + xorq %rbp,%rbp + jmp L$sqrx8x_outer_loop + +.p2align 5 +L$sqrx8x_outer_loop: + mulxq 8(%rsi),%r8,%rax + adcxq %r9,%r8 + adoxq %rax,%r10 + mulxq 16(%rsi),%r9,%rax + adcxq %r10,%r9 + adoxq %rax,%r11 +.byte 0xc4,0xe2,0xab,0xf6,0x86,0x18,0x00,0x00,0x00 + adcxq %r11,%r10 + adoxq %rax,%r12 +.byte 0xc4,0xe2,0xa3,0xf6,0x86,0x20,0x00,0x00,0x00 + adcxq %r12,%r11 + adoxq %rax,%r13 + mulxq 40(%rsi),%r12,%rax + adcxq %r13,%r12 + adoxq %rax,%r14 + mulxq 48(%rsi),%r13,%rax + adcxq %r14,%r13 + adoxq %r15,%rax + mulxq 56(%rsi),%r14,%r15 + movq 8(%rsi),%rdx + adcxq %rax,%r14 + adoxq %rbp,%r15 + adcq 64(%rdi),%r15 + movq %r8,8(%rdi) + movq %r9,16(%rdi) + sbbq %rcx,%rcx + xorq %rbp,%rbp + + + mulxq 16(%rsi),%r8,%rbx + mulxq 24(%rsi),%r9,%rax + adcxq %r10,%r8 + adoxq %rbx,%r9 + mulxq 32(%rsi),%r10,%rbx + adcxq %r11,%r9 + adoxq %rax,%r10 +.byte 0xc4,0xe2,0xa3,0xf6,0x86,0x28,0x00,0x00,0x00 + adcxq %r12,%r10 + adoxq %rbx,%r11 +.byte 0xc4,0xe2,0x9b,0xf6,0x9e,0x30,0x00,0x00,0x00 + adcxq %r13,%r11 + adoxq %r14,%r12 +.byte 0xc4,0x62,0x93,0xf6,0xb6,0x38,0x00,0x00,0x00 + movq 16(%rsi),%rdx + adcxq %rax,%r12 + adoxq %rbx,%r13 + adcxq %r15,%r13 + adoxq %rbp,%r14 + adcxq %rbp,%r14 + + movq %r8,24(%rdi) + movq %r9,32(%rdi) + + mulxq 24(%rsi),%r8,%rbx + mulxq 32(%rsi),%r9,%rax + adcxq %r10,%r8 + adoxq %rbx,%r9 + mulxq 40(%rsi),%r10,%rbx + adcxq %r11,%r9 + adoxq %rax,%r10 +.byte 0xc4,0xe2,0xa3,0xf6,0x86,0x30,0x00,0x00,0x00 + adcxq %r12,%r10 + adoxq %r13,%r11 +.byte 0xc4,0x62,0x9b,0xf6,0xae,0x38,0x00,0x00,0x00 +.byte 0x3e + movq 24(%rsi),%rdx + adcxq %rbx,%r11 + adoxq %rax,%r12 + adcxq %r14,%r12 + movq %r8,40(%rdi) + movq %r9,48(%rdi) + mulxq 32(%rsi),%r8,%rax + adoxq %rbp,%r13 + adcxq %rbp,%r13 + + mulxq 40(%rsi),%r9,%rbx + adcxq %r10,%r8 + adoxq %rax,%r9 + mulxq 48(%rsi),%r10,%rax + adcxq %r11,%r9 + adoxq %r12,%r10 + mulxq 56(%rsi),%r11,%r12 + movq 32(%rsi),%rdx + movq 40(%rsi),%r14 + adcxq %rbx,%r10 + adoxq %rax,%r11 + movq 48(%rsi),%r15 + adcxq %r13,%r11 + adoxq %rbp,%r12 + adcxq %rbp,%r12 + + movq %r8,56(%rdi) + movq %r9,64(%rdi) + + mulxq %r14,%r9,%rax + movq 56(%rsi),%r8 + adcxq %r10,%r9 + mulxq %r15,%r10,%rbx + adoxq %rax,%r10 + adcxq %r11,%r10 + mulxq %r8,%r11,%rax + movq %r14,%rdx + adoxq %rbx,%r11 + adcxq %r12,%r11 + + adcxq %rbp,%rax + + mulxq %r15,%r14,%rbx + mulxq %r8,%r12,%r13 + movq %r15,%rdx + leaq 64(%rsi),%rsi + adcxq %r14,%r11 + adoxq %rbx,%r12 + adcxq %rax,%r12 + adoxq %rbp,%r13 + +.byte 0x67,0x67 + mulxq %r8,%r8,%r14 + adcxq %r8,%r13 + adcxq %rbp,%r14 + + cmpq 8+8(%rsp),%rsi + je L$sqrx8x_outer_break + + negq %rcx + movq $-8,%rcx + movq %rbp,%r15 + movq 64(%rdi),%r8 + adcxq 72(%rdi),%r9 + adcxq 80(%rdi),%r10 + adcxq 88(%rdi),%r11 + adcq 96(%rdi),%r12 + adcq 104(%rdi),%r13 + adcq 112(%rdi),%r14 + adcq 120(%rdi),%r15 + leaq (%rsi),%rbp + leaq 128(%rdi),%rdi + sbbq %rax,%rax + + movq -64(%rsi),%rdx + movq %rax,16+8(%rsp) + movq %rdi,24+8(%rsp) + + + xorl %eax,%eax + jmp L$sqrx8x_loop + +.p2align 5 +L$sqrx8x_loop: + movq %r8,%rbx + mulxq 0(%rbp),%rax,%r8 + adcxq %rax,%rbx + adoxq %r9,%r8 + + mulxq 8(%rbp),%rax,%r9 + adcxq %rax,%r8 + adoxq %r10,%r9 + + mulxq 16(%rbp),%rax,%r10 + adcxq %rax,%r9 + adoxq %r11,%r10 + + mulxq 24(%rbp),%rax,%r11 + adcxq %rax,%r10 + adoxq %r12,%r11 + +.byte 0xc4,0x62,0xfb,0xf6,0xa5,0x20,0x00,0x00,0x00 + adcxq %rax,%r11 + adoxq %r13,%r12 + + mulxq 40(%rbp),%rax,%r13 + adcxq %rax,%r12 + adoxq %r14,%r13 + + mulxq 48(%rbp),%rax,%r14 + movq %rbx,(%rdi,%rcx,8) + movl $0,%ebx + adcxq %rax,%r13 + adoxq %r15,%r14 + +.byte 0xc4,0x62,0xfb,0xf6,0xbd,0x38,0x00,0x00,0x00 + movq 8(%rsi,%rcx,8),%rdx + adcxq %rax,%r14 + adoxq %rbx,%r15 + adcxq %rbx,%r15 + +.byte 0x67 + incq %rcx + jnz L$sqrx8x_loop + + leaq 64(%rbp),%rbp + movq $-8,%rcx + cmpq 8+8(%rsp),%rbp + je L$sqrx8x_break + + subq 16+8(%rsp),%rbx +.byte 0x66 + movq -64(%rsi),%rdx + adcxq 0(%rdi),%r8 + adcxq 8(%rdi),%r9 + adcq 16(%rdi),%r10 + adcq 24(%rdi),%r11 + adcq 32(%rdi),%r12 + adcq 40(%rdi),%r13 + adcq 48(%rdi),%r14 + adcq 56(%rdi),%r15 + leaq 64(%rdi),%rdi +.byte 0x67 + sbbq %rax,%rax + xorl %ebx,%ebx + movq %rax,16+8(%rsp) + jmp L$sqrx8x_loop + +.p2align 5 +L$sqrx8x_break: + xorq %rbp,%rbp + subq 16+8(%rsp),%rbx + adcxq %rbp,%r8 + movq 24+8(%rsp),%rcx + adcxq %rbp,%r9 + movq 0(%rsi),%rdx + adcq $0,%r10 + movq %r8,0(%rdi) + adcq $0,%r11 + adcq $0,%r12 + adcq $0,%r13 + adcq $0,%r14 + adcq $0,%r15 + cmpq %rcx,%rdi + je L$sqrx8x_outer_loop + + movq %r9,8(%rdi) + movq 8(%rcx),%r9 + movq %r10,16(%rdi) + movq 16(%rcx),%r10 + movq %r11,24(%rdi) + movq 24(%rcx),%r11 + movq %r12,32(%rdi) + movq 32(%rcx),%r12 + movq %r13,40(%rdi) + movq 40(%rcx),%r13 + movq %r14,48(%rdi) + movq 48(%rcx),%r14 + movq %r15,56(%rdi) + movq 56(%rcx),%r15 + movq %rcx,%rdi + jmp L$sqrx8x_outer_loop + +.p2align 5 +L$sqrx8x_outer_break: + movq %r9,72(%rdi) +.byte 102,72,15,126,217 + movq %r10,80(%rdi) + movq %r11,88(%rdi) + movq %r12,96(%rdi) + movq %r13,104(%rdi) + movq %r14,112(%rdi) + leaq 48+8(%rsp),%rdi + movq (%rsi,%rcx,1),%rdx + + movq 8(%rdi),%r11 + xorq %r10,%r10 + movq 0+8(%rsp),%r9 + adoxq %r11,%r11 + movq 16(%rdi),%r12 + movq 24(%rdi),%r13 + + +.p2align 5 +L$sqrx4x_shift_n_add: + mulxq %rdx,%rax,%rbx + adoxq %r12,%r12 + adcxq %r10,%rax +.byte 0x48,0x8b,0x94,0x0e,0x08,0x00,0x00,0x00 +.byte 0x4c,0x8b,0x97,0x20,0x00,0x00,0x00 + adoxq %r13,%r13 + adcxq %r11,%rbx + movq 40(%rdi),%r11 + movq %rax,0(%rdi) + movq %rbx,8(%rdi) + + mulxq %rdx,%rax,%rbx + adoxq %r10,%r10 + adcxq %r12,%rax + movq 16(%rsi,%rcx,1),%rdx + movq 48(%rdi),%r12 + adoxq %r11,%r11 + adcxq %r13,%rbx + movq 56(%rdi),%r13 + movq %rax,16(%rdi) + movq %rbx,24(%rdi) + + mulxq %rdx,%rax,%rbx + adoxq %r12,%r12 + adcxq %r10,%rax + movq 24(%rsi,%rcx,1),%rdx + leaq 32(%rcx),%rcx + movq 64(%rdi),%r10 + adoxq %r13,%r13 + adcxq %r11,%rbx + movq 72(%rdi),%r11 + movq %rax,32(%rdi) + movq %rbx,40(%rdi) + + mulxq %rdx,%rax,%rbx + adoxq %r10,%r10 + adcxq %r12,%rax + jrcxz L$sqrx4x_shift_n_add_break +.byte 0x48,0x8b,0x94,0x0e,0x00,0x00,0x00,0x00 + adoxq %r11,%r11 + adcxq %r13,%rbx + movq 80(%rdi),%r12 + movq 88(%rdi),%r13 + movq %rax,48(%rdi) + movq %rbx,56(%rdi) + leaq 64(%rdi),%rdi + nop + jmp L$sqrx4x_shift_n_add + +.p2align 5 +L$sqrx4x_shift_n_add_break: + adcxq %r13,%rbx + movq %rax,48(%rdi) + movq %rbx,56(%rdi) + leaq 64(%rdi),%rdi +.byte 102,72,15,126,213 +__bn_sqrx8x_reduction: + xorl %eax,%eax + movq 32+8(%rsp),%rbx + movq 48+8(%rsp),%rdx + leaq -64(%rbp,%r9,1),%rcx + + movq %rcx,0+8(%rsp) + movq %rdi,8+8(%rsp) + + leaq 48+8(%rsp),%rdi + jmp L$sqrx8x_reduction_loop + +.p2align 5 +L$sqrx8x_reduction_loop: + movq 8(%rdi),%r9 + movq 16(%rdi),%r10 + movq 24(%rdi),%r11 + movq 32(%rdi),%r12 + movq %rdx,%r8 + imulq %rbx,%rdx + movq 40(%rdi),%r13 + movq 48(%rdi),%r14 + movq 56(%rdi),%r15 + movq %rax,24+8(%rsp) + + leaq 64(%rdi),%rdi + xorq %rsi,%rsi + movq $-8,%rcx + jmp L$sqrx8x_reduce + +.p2align 5 +L$sqrx8x_reduce: + movq %r8,%rbx + mulxq 0(%rbp),%rax,%r8 + adcxq %rbx,%rax + adoxq %r9,%r8 + + mulxq 8(%rbp),%rbx,%r9 + adcxq %rbx,%r8 + adoxq %r10,%r9 + + mulxq 16(%rbp),%rbx,%r10 + adcxq %rbx,%r9 + adoxq %r11,%r10 + + mulxq 24(%rbp),%rbx,%r11 + adcxq %rbx,%r10 + adoxq %r12,%r11 + +.byte 0xc4,0x62,0xe3,0xf6,0xa5,0x20,0x00,0x00,0x00 + movq %rdx,%rax + movq %r8,%rdx + adcxq %rbx,%r11 + adoxq %r13,%r12 + + mulxq 32+8(%rsp),%rbx,%rdx + movq %rax,%rdx + movq %rax,64+48+8(%rsp,%rcx,8) + + mulxq 40(%rbp),%rax,%r13 + adcxq %rax,%r12 + adoxq %r14,%r13 + + mulxq 48(%rbp),%rax,%r14 + adcxq %rax,%r13 + adoxq %r15,%r14 + + mulxq 56(%rbp),%rax,%r15 + movq %rbx,%rdx + adcxq %rax,%r14 + adoxq %rsi,%r15 + adcxq %rsi,%r15 + +.byte 0x67,0x67,0x67 + incq %rcx + jnz L$sqrx8x_reduce + + movq %rsi,%rax + cmpq 0+8(%rsp),%rbp + jae L$sqrx8x_no_tail + + movq 48+8(%rsp),%rdx + addq 0(%rdi),%r8 + leaq 64(%rbp),%rbp + movq $-8,%rcx + adcxq 8(%rdi),%r9 + adcxq 16(%rdi),%r10 + adcq 24(%rdi),%r11 + adcq 32(%rdi),%r12 + adcq 40(%rdi),%r13 + adcq 48(%rdi),%r14 + adcq 56(%rdi),%r15 + leaq 64(%rdi),%rdi + sbbq %rax,%rax + + xorq %rsi,%rsi + movq %rax,16+8(%rsp) + jmp L$sqrx8x_tail + +.p2align 5 +L$sqrx8x_tail: + movq %r8,%rbx + mulxq 0(%rbp),%rax,%r8 + adcxq %rax,%rbx + adoxq %r9,%r8 + + mulxq 8(%rbp),%rax,%r9 + adcxq %rax,%r8 + adoxq %r10,%r9 + + mulxq 16(%rbp),%rax,%r10 + adcxq %rax,%r9 + adoxq %r11,%r10 + + mulxq 24(%rbp),%rax,%r11 + adcxq %rax,%r10 + adoxq %r12,%r11 + +.byte 0xc4,0x62,0xfb,0xf6,0xa5,0x20,0x00,0x00,0x00 + adcxq %rax,%r11 + adoxq %r13,%r12 + + mulxq 40(%rbp),%rax,%r13 + adcxq %rax,%r12 + adoxq %r14,%r13 + + mulxq 48(%rbp),%rax,%r14 + adcxq %rax,%r13 + adoxq %r15,%r14 + + mulxq 56(%rbp),%rax,%r15 + movq 72+48+8(%rsp,%rcx,8),%rdx + adcxq %rax,%r14 + adoxq %rsi,%r15 + movq %rbx,(%rdi,%rcx,8) + movq %r8,%rbx + adcxq %rsi,%r15 + + incq %rcx + jnz L$sqrx8x_tail + + cmpq 0+8(%rsp),%rbp + jae L$sqrx8x_tail_done + + subq 16+8(%rsp),%rsi + movq 48+8(%rsp),%rdx + leaq 64(%rbp),%rbp + adcq 0(%rdi),%r8 + adcq 8(%rdi),%r9 + adcq 16(%rdi),%r10 + adcq 24(%rdi),%r11 + adcq 32(%rdi),%r12 + adcq 40(%rdi),%r13 + adcq 48(%rdi),%r14 + adcq 56(%rdi),%r15 + leaq 64(%rdi),%rdi + sbbq %rax,%rax + subq $8,%rcx + + xorq %rsi,%rsi + movq %rax,16+8(%rsp) + jmp L$sqrx8x_tail + +.p2align 5 +L$sqrx8x_tail_done: + xorq %rax,%rax + addq 24+8(%rsp),%r8 + adcq $0,%r9 + adcq $0,%r10 + adcq $0,%r11 + adcq $0,%r12 + adcq $0,%r13 + adcq $0,%r14 + adcq $0,%r15 + adcq $0,%rax + + subq 16+8(%rsp),%rsi +L$sqrx8x_no_tail: + adcq 0(%rdi),%r8 +.byte 102,72,15,126,217 + adcq 8(%rdi),%r9 + movq 56(%rbp),%rsi +.byte 102,72,15,126,213 + adcq 16(%rdi),%r10 + adcq 24(%rdi),%r11 + adcq 32(%rdi),%r12 + adcq 40(%rdi),%r13 + adcq 48(%rdi),%r14 + adcq 56(%rdi),%r15 + adcq $0,%rax + + movq 32+8(%rsp),%rbx + movq 64(%rdi,%rcx,1),%rdx + + movq %r8,0(%rdi) + leaq 64(%rdi),%r8 + movq %r9,8(%rdi) + movq %r10,16(%rdi) + movq %r11,24(%rdi) + movq %r12,32(%rdi) + movq %r13,40(%rdi) + movq %r14,48(%rdi) + movq %r15,56(%rdi) + + leaq 64(%rdi,%rcx,1),%rdi + cmpq 8+8(%rsp),%r8 + jb L$sqrx8x_reduction_loop + ret + + +.p2align 5 + +__bn_postx4x_internal: + + movq 0(%rbp),%r12 + movq %rcx,%r10 + movq %rcx,%r9 + negq %rax + sarq $3+2,%rcx + +.byte 102,72,15,126,202 +.byte 102,72,15,126,206 + decq %r12 + movq 8(%rbp),%r13 + xorq %r8,%r8 + movq 16(%rbp),%r14 + movq 24(%rbp),%r15 + jmp L$sqrx4x_sub_entry + +.p2align 4 +L$sqrx4x_sub: + movq 0(%rbp),%r12 + movq 8(%rbp),%r13 + movq 16(%rbp),%r14 + movq 24(%rbp),%r15 +L$sqrx4x_sub_entry: + andnq %rax,%r12,%r12 + leaq 32(%rbp),%rbp + andnq %rax,%r13,%r13 + andnq %rax,%r14,%r14 + andnq %rax,%r15,%r15 + + negq %r8 + adcq 0(%rdi),%r12 + adcq 8(%rdi),%r13 + adcq 16(%rdi),%r14 + adcq 24(%rdi),%r15 + movq %r12,0(%rdx) + leaq 32(%rdi),%rdi + movq %r13,8(%rdx) + sbbq %r8,%r8 + movq %r14,16(%rdx) + movq %r15,24(%rdx) + leaq 32(%rdx),%rdx + + incq %rcx + jnz L$sqrx4x_sub + + negq %r9 + + ret + + +.globl _bn_scatter5 +.private_extern _bn_scatter5 + +.p2align 4 +_bn_scatter5: + +_CET_ENDBR + cmpl $0,%esi + jz L$scatter_epilogue + + + + + + + + + + leaq (%rdx,%rcx,8),%rdx +L$scatter: + movq (%rdi),%rax + leaq 8(%rdi),%rdi + movq %rax,(%rdx) + leaq 256(%rdx),%rdx + subl $1,%esi + jnz L$scatter +L$scatter_epilogue: + ret + + + +.globl _bn_gather5 +.private_extern _bn_gather5 + +.p2align 5 +_bn_gather5: + +L$SEH_begin_bn_gather5: +_CET_ENDBR + +.byte 0x4c,0x8d,0x14,0x24 + +.byte 0x48,0x81,0xec,0x08,0x01,0x00,0x00 + leaq L$inc(%rip),%rax + andq $-16,%rsp + + movd %ecx,%xmm5 + movdqa 0(%rax),%xmm0 + movdqa 16(%rax),%xmm1 + leaq 128(%rdx),%r11 + leaq 128(%rsp),%rax + + pshufd $0,%xmm5,%xmm5 + movdqa %xmm1,%xmm4 + movdqa %xmm1,%xmm2 + paddd %xmm0,%xmm1 + pcmpeqd %xmm5,%xmm0 + movdqa %xmm4,%xmm3 + + paddd %xmm1,%xmm2 + pcmpeqd %xmm5,%xmm1 + movdqa %xmm0,-128(%rax) + movdqa %xmm4,%xmm0 + + paddd %xmm2,%xmm3 + pcmpeqd %xmm5,%xmm2 + movdqa %xmm1,-112(%rax) + movdqa %xmm4,%xmm1 + + paddd %xmm3,%xmm0 + pcmpeqd %xmm5,%xmm3 + movdqa %xmm2,-96(%rax) + movdqa %xmm4,%xmm2 + paddd %xmm0,%xmm1 + pcmpeqd %xmm5,%xmm0 + movdqa %xmm3,-80(%rax) + movdqa %xmm4,%xmm3 + + paddd %xmm1,%xmm2 + pcmpeqd %xmm5,%xmm1 + movdqa %xmm0,-64(%rax) + movdqa %xmm4,%xmm0 + + paddd %xmm2,%xmm3 + pcmpeqd %xmm5,%xmm2 + movdqa %xmm1,-48(%rax) + movdqa %xmm4,%xmm1 + + paddd %xmm3,%xmm0 + pcmpeqd %xmm5,%xmm3 + movdqa %xmm2,-32(%rax) + movdqa %xmm4,%xmm2 + paddd %xmm0,%xmm1 + pcmpeqd %xmm5,%xmm0 + movdqa %xmm3,-16(%rax) + movdqa %xmm4,%xmm3 + + paddd %xmm1,%xmm2 + pcmpeqd %xmm5,%xmm1 + movdqa %xmm0,0(%rax) + movdqa %xmm4,%xmm0 + + paddd %xmm2,%xmm3 + pcmpeqd %xmm5,%xmm2 + movdqa %xmm1,16(%rax) + movdqa %xmm4,%xmm1 + + paddd %xmm3,%xmm0 + pcmpeqd %xmm5,%xmm3 + movdqa %xmm2,32(%rax) + movdqa %xmm4,%xmm2 + paddd %xmm0,%xmm1 + pcmpeqd %xmm5,%xmm0 + movdqa %xmm3,48(%rax) + movdqa %xmm4,%xmm3 + + paddd %xmm1,%xmm2 + pcmpeqd %xmm5,%xmm1 + movdqa %xmm0,64(%rax) + movdqa %xmm4,%xmm0 + + paddd %xmm2,%xmm3 + pcmpeqd %xmm5,%xmm2 + movdqa %xmm1,80(%rax) + movdqa %xmm4,%xmm1 + + paddd %xmm3,%xmm0 + pcmpeqd %xmm5,%xmm3 + movdqa %xmm2,96(%rax) + movdqa %xmm4,%xmm2 + movdqa %xmm3,112(%rax) + jmp L$gather + +.p2align 5 +L$gather: + pxor %xmm4,%xmm4 + pxor %xmm5,%xmm5 + movdqa -128(%r11),%xmm0 + movdqa -112(%r11),%xmm1 + movdqa -96(%r11),%xmm2 + pand -128(%rax),%xmm0 + movdqa -80(%r11),%xmm3 + pand -112(%rax),%xmm1 + por %xmm0,%xmm4 + pand -96(%rax),%xmm2 + por %xmm1,%xmm5 + pand -80(%rax),%xmm3 + por %xmm2,%xmm4 + por %xmm3,%xmm5 + movdqa -64(%r11),%xmm0 + movdqa -48(%r11),%xmm1 + movdqa -32(%r11),%xmm2 + pand -64(%rax),%xmm0 + movdqa -16(%r11),%xmm3 + pand -48(%rax),%xmm1 + por %xmm0,%xmm4 + pand -32(%rax),%xmm2 + por %xmm1,%xmm5 + pand -16(%rax),%xmm3 + por %xmm2,%xmm4 + por %xmm3,%xmm5 + movdqa 0(%r11),%xmm0 + movdqa 16(%r11),%xmm1 + movdqa 32(%r11),%xmm2 + pand 0(%rax),%xmm0 + movdqa 48(%r11),%xmm3 + pand 16(%rax),%xmm1 + por %xmm0,%xmm4 + pand 32(%rax),%xmm2 + por %xmm1,%xmm5 + pand 48(%rax),%xmm3 + por %xmm2,%xmm4 + por %xmm3,%xmm5 + movdqa 64(%r11),%xmm0 + movdqa 80(%r11),%xmm1 + movdqa 96(%r11),%xmm2 + pand 64(%rax),%xmm0 + movdqa 112(%r11),%xmm3 + pand 80(%rax),%xmm1 + por %xmm0,%xmm4 + pand 96(%rax),%xmm2 + por %xmm1,%xmm5 + pand 112(%rax),%xmm3 + por %xmm2,%xmm4 + por %xmm3,%xmm5 + por %xmm5,%xmm4 + leaq 256(%r11),%r11 + + pshufd $0x4e,%xmm4,%xmm0 + por %xmm4,%xmm0 + movq %xmm0,(%rdi) + leaq 8(%rdi),%rdi + subl $1,%esi + jnz L$gather + + leaq (%r10),%rsp + + ret +L$SEH_end_bn_gather5: + + +.section __DATA,__const +.p2align 6 +L$inc: +.long 0,0, 1,1 +.long 2,2, 2,2 +.byte 77,111,110,116,103,111,109,101,114,121,32,77,117,108,116,105,112,108,105,99,97,116,105,111,110,32,119,105,116,104,32,115,99,97,116,116,101,114,47,103,97,116,104,101,114,32,102,111,114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0 +.text +#endif diff --git a/http/vendor/ring/pregenerated/x86_64-mont5-nasm.asm b/http/vendor/ring/pregenerated/x86_64-mont5-nasm.asm new file mode 100644 index 0000000..eeb3543 --- /dev/null +++ b/http/vendor/ring/pregenerated/x86_64-mont5-nasm.asm @@ -0,0 +1,3401 @@ +; This file is generated from a similarly-named Perl script in the BoringSSL +; source tree. Do not edit by hand. + +%ifidn __OUTPUT_FORMAT__, win64 +default rel +%define XMMWORD +%define YMMWORD +%define ZMMWORD +%define _CET_ENDBR + +%include "ring_core_generated/prefix_symbols_nasm.inc" +section .text code align=64 + + +global bn_mul4x_mont_gather5 + +ALIGN 32 +bn_mul4x_mont_gather5: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_bn_mul4x_mont_gather5: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + mov rcx,r9 + mov r8,QWORD[40+rsp] + mov r9,QWORD[48+rsp] + + + +_CET_ENDBR + DB 0x67 + mov rax,rsp + + push rbx + + push rbp + + push r12 + + push r13 + + push r14 + + push r15 + +$L$mul4x_prologue: + + DB 0x67 + + + + shl r9d,3 + lea r10,[r9*2+r9] + neg r9 + + + + + + + + + + + lea r11,[((-320))+r9*2+rsp] + mov rbp,rsp + sub r11,rdi + and r11,4095 + cmp r10,r11 + jb NEAR $L$mul4xsp_alt + sub rbp,r11 + lea rbp,[((-320))+r9*2+rbp] + jmp NEAR $L$mul4xsp_done + +ALIGN 32 +$L$mul4xsp_alt: + lea r10,[((4096-320))+r9*2] + lea rbp,[((-320))+r9*2+rbp] + sub r11,r10 + mov r10,0 + cmovc r11,r10 + sub rbp,r11 +$L$mul4xsp_done: + and rbp,-64 + mov r11,rsp + sub r11,rbp + and r11,-4096 + lea rsp,[rbp*1+r11] + mov r10,QWORD[rsp] + cmp rsp,rbp + ja NEAR $L$mul4x_page_walk + jmp NEAR $L$mul4x_page_walk_done + +$L$mul4x_page_walk: + lea rsp,[((-4096))+rsp] + mov r10,QWORD[rsp] + cmp rsp,rbp + ja NEAR $L$mul4x_page_walk +$L$mul4x_page_walk_done: + + neg r9 + + mov QWORD[40+rsp],rax + +$L$mul4x_body: + + call mul4x_internal + + mov rsi,QWORD[40+rsp] + + mov rax,1 + + mov r15,QWORD[((-48))+rsi] + + mov r14,QWORD[((-40))+rsi] + + mov r13,QWORD[((-32))+rsi] + + mov r12,QWORD[((-24))+rsi] + + mov rbp,QWORD[((-16))+rsi] + + mov rbx,QWORD[((-8))+rsi] + + lea rsp,[rsi] + +$L$mul4x_epilogue: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_bn_mul4x_mont_gather5: + + +ALIGN 32 +mul4x_internal: + + shl r9,5 + movd xmm5,DWORD[56+rax] + lea rax,[$L$inc] + lea r13,[128+r9*1+rdx] + shr r9,5 + movdqa xmm0,XMMWORD[rax] + movdqa xmm1,XMMWORD[16+rax] + lea r10,[((88-112))+r9*1+rsp] + lea r12,[128+rdx] + + pshufd xmm5,xmm5,0 + movdqa xmm4,xmm1 + DB 0x67,0x67 + movdqa xmm2,xmm1 + paddd xmm1,xmm0 + pcmpeqd xmm0,xmm5 + DB 0x67 + movdqa xmm3,xmm4 + paddd xmm2,xmm1 + pcmpeqd xmm1,xmm5 + movdqa XMMWORD[112+r10],xmm0 + movdqa xmm0,xmm4 + + paddd xmm3,xmm2 + pcmpeqd xmm2,xmm5 + movdqa XMMWORD[128+r10],xmm1 + movdqa xmm1,xmm4 + + paddd xmm0,xmm3 + pcmpeqd xmm3,xmm5 + movdqa XMMWORD[144+r10],xmm2 + movdqa xmm2,xmm4 + + paddd xmm1,xmm0 + pcmpeqd xmm0,xmm5 + movdqa XMMWORD[160+r10],xmm3 + movdqa xmm3,xmm4 + paddd xmm2,xmm1 + pcmpeqd xmm1,xmm5 + movdqa XMMWORD[176+r10],xmm0 + movdqa xmm0,xmm4 + + paddd xmm3,xmm2 + pcmpeqd xmm2,xmm5 + movdqa XMMWORD[192+r10],xmm1 + movdqa xmm1,xmm4 + + paddd xmm0,xmm3 + pcmpeqd xmm3,xmm5 + movdqa XMMWORD[208+r10],xmm2 + movdqa xmm2,xmm4 + + paddd xmm1,xmm0 + pcmpeqd xmm0,xmm5 + movdqa XMMWORD[224+r10],xmm3 + movdqa xmm3,xmm4 + paddd xmm2,xmm1 + pcmpeqd xmm1,xmm5 + movdqa XMMWORD[240+r10],xmm0 + movdqa xmm0,xmm4 + + paddd xmm3,xmm2 + pcmpeqd xmm2,xmm5 + movdqa XMMWORD[256+r10],xmm1 + movdqa xmm1,xmm4 + + paddd xmm0,xmm3 + pcmpeqd xmm3,xmm5 + movdqa XMMWORD[272+r10],xmm2 + movdqa xmm2,xmm4 + + paddd xmm1,xmm0 + pcmpeqd xmm0,xmm5 + movdqa XMMWORD[288+r10],xmm3 + movdqa xmm3,xmm4 + paddd xmm2,xmm1 + pcmpeqd xmm1,xmm5 + movdqa XMMWORD[304+r10],xmm0 + + paddd xmm3,xmm2 + DB 0x67 + pcmpeqd xmm2,xmm5 + movdqa XMMWORD[320+r10],xmm1 + + pcmpeqd xmm3,xmm5 + movdqa XMMWORD[336+r10],xmm2 + pand xmm0,XMMWORD[64+r12] + + pand xmm1,XMMWORD[80+r12] + pand xmm2,XMMWORD[96+r12] + movdqa XMMWORD[352+r10],xmm3 + pand xmm3,XMMWORD[112+r12] + por xmm0,xmm2 + por xmm1,xmm3 + movdqa xmm4,XMMWORD[((-128))+r12] + movdqa xmm5,XMMWORD[((-112))+r12] + movdqa xmm2,XMMWORD[((-96))+r12] + pand xmm4,XMMWORD[112+r10] + movdqa xmm3,XMMWORD[((-80))+r12] + pand xmm5,XMMWORD[128+r10] + por xmm0,xmm4 + pand xmm2,XMMWORD[144+r10] + por xmm1,xmm5 + pand xmm3,XMMWORD[160+r10] + por xmm0,xmm2 + por xmm1,xmm3 + movdqa xmm4,XMMWORD[((-64))+r12] + movdqa xmm5,XMMWORD[((-48))+r12] + movdqa xmm2,XMMWORD[((-32))+r12] + pand xmm4,XMMWORD[176+r10] + movdqa xmm3,XMMWORD[((-16))+r12] + pand xmm5,XMMWORD[192+r10] + por xmm0,xmm4 + pand xmm2,XMMWORD[208+r10] + por xmm1,xmm5 + pand xmm3,XMMWORD[224+r10] + por xmm0,xmm2 + por xmm1,xmm3 + movdqa xmm4,XMMWORD[r12] + movdqa xmm5,XMMWORD[16+r12] + movdqa xmm2,XMMWORD[32+r12] + pand xmm4,XMMWORD[240+r10] + movdqa xmm3,XMMWORD[48+r12] + pand xmm5,XMMWORD[256+r10] + por xmm0,xmm4 + pand xmm2,XMMWORD[272+r10] + por xmm1,xmm5 + pand xmm3,XMMWORD[288+r10] + por xmm0,xmm2 + por xmm1,xmm3 + por xmm0,xmm1 + + pshufd xmm1,xmm0,0x4e + por xmm0,xmm1 + lea r12,[256+r12] +DB 102,72,15,126,195 + + mov QWORD[((16+8))+rsp],r13 + mov QWORD[((56+8))+rsp],rdi + + mov r8,QWORD[r8] + mov rax,QWORD[rsi] + lea rsi,[r9*1+rsi] + neg r9 + + mov rbp,r8 + mul rbx + mov r10,rax + mov rax,QWORD[rcx] + + imul rbp,r10 + lea r14,[((64+8))+rsp] + mov r11,rdx + + mul rbp + add r10,rax + mov rax,QWORD[8+r9*1+rsi] + adc rdx,0 + mov rdi,rdx + + mul rbx + add r11,rax + mov rax,QWORD[8+rcx] + adc rdx,0 + mov r10,rdx + + mul rbp + add rdi,rax + mov rax,QWORD[16+r9*1+rsi] + adc rdx,0 + add rdi,r11 + lea r15,[32+r9] + lea rcx,[32+rcx] + adc rdx,0 + mov QWORD[r14],rdi + mov r13,rdx + jmp NEAR $L$1st4x + +ALIGN 32 +$L$1st4x: + mul rbx + add r10,rax + mov rax,QWORD[((-16))+rcx] + lea r14,[32+r14] + adc rdx,0 + mov r11,rdx + + mul rbp + add r13,rax + mov rax,QWORD[((-8))+r15*1+rsi] + adc rdx,0 + add r13,r10 + adc rdx,0 + mov QWORD[((-24))+r14],r13 + mov rdi,rdx + + mul rbx + add r11,rax + mov rax,QWORD[((-8))+rcx] + adc rdx,0 + mov r10,rdx + + mul rbp + add rdi,rax + mov rax,QWORD[r15*1+rsi] + adc rdx,0 + add rdi,r11 + adc rdx,0 + mov QWORD[((-16))+r14],rdi + mov r13,rdx + + mul rbx + add r10,rax + mov rax,QWORD[rcx] + adc rdx,0 + mov r11,rdx + + mul rbp + add r13,rax + mov rax,QWORD[8+r15*1+rsi] + adc rdx,0 + add r13,r10 + adc rdx,0 + mov QWORD[((-8))+r14],r13 + mov rdi,rdx + + mul rbx + add r11,rax + mov rax,QWORD[8+rcx] + adc rdx,0 + mov r10,rdx + + mul rbp + add rdi,rax + mov rax,QWORD[16+r15*1+rsi] + adc rdx,0 + add rdi,r11 + lea rcx,[32+rcx] + adc rdx,0 + mov QWORD[r14],rdi + mov r13,rdx + + add r15,32 + jnz NEAR $L$1st4x + + mul rbx + add r10,rax + mov rax,QWORD[((-16))+rcx] + lea r14,[32+r14] + adc rdx,0 + mov r11,rdx + + mul rbp + add r13,rax + mov rax,QWORD[((-8))+rsi] + adc rdx,0 + add r13,r10 + adc rdx,0 + mov QWORD[((-24))+r14],r13 + mov rdi,rdx + + mul rbx + add r11,rax + mov rax,QWORD[((-8))+rcx] + adc rdx,0 + mov r10,rdx + + mul rbp + add rdi,rax + mov rax,QWORD[r9*1+rsi] + adc rdx,0 + add rdi,r11 + adc rdx,0 + mov QWORD[((-16))+r14],rdi + mov r13,rdx + + lea rcx,[r9*1+rcx] + + xor rdi,rdi + add r13,r10 + adc rdi,0 + mov QWORD[((-8))+r14],r13 + + jmp NEAR $L$outer4x + +ALIGN 32 +$L$outer4x: + lea rdx,[((16+128))+r14] + pxor xmm4,xmm4 + pxor xmm5,xmm5 + movdqa xmm0,XMMWORD[((-128))+r12] + movdqa xmm1,XMMWORD[((-112))+r12] + movdqa xmm2,XMMWORD[((-96))+r12] + movdqa xmm3,XMMWORD[((-80))+r12] + pand xmm0,XMMWORD[((-128))+rdx] + pand xmm1,XMMWORD[((-112))+rdx] + por xmm4,xmm0 + pand xmm2,XMMWORD[((-96))+rdx] + por xmm5,xmm1 + pand xmm3,XMMWORD[((-80))+rdx] + por xmm4,xmm2 + por xmm5,xmm3 + movdqa xmm0,XMMWORD[((-64))+r12] + movdqa xmm1,XMMWORD[((-48))+r12] + movdqa xmm2,XMMWORD[((-32))+r12] + movdqa xmm3,XMMWORD[((-16))+r12] + pand xmm0,XMMWORD[((-64))+rdx] + pand xmm1,XMMWORD[((-48))+rdx] + por xmm4,xmm0 + pand xmm2,XMMWORD[((-32))+rdx] + por xmm5,xmm1 + pand xmm3,XMMWORD[((-16))+rdx] + por xmm4,xmm2 + por xmm5,xmm3 + movdqa xmm0,XMMWORD[r12] + movdqa xmm1,XMMWORD[16+r12] + movdqa xmm2,XMMWORD[32+r12] + movdqa xmm3,XMMWORD[48+r12] + pand xmm0,XMMWORD[rdx] + pand xmm1,XMMWORD[16+rdx] + por xmm4,xmm0 + pand xmm2,XMMWORD[32+rdx] + por xmm5,xmm1 + pand xmm3,XMMWORD[48+rdx] + por xmm4,xmm2 + por xmm5,xmm3 + movdqa xmm0,XMMWORD[64+r12] + movdqa xmm1,XMMWORD[80+r12] + movdqa xmm2,XMMWORD[96+r12] + movdqa xmm3,XMMWORD[112+r12] + pand xmm0,XMMWORD[64+rdx] + pand xmm1,XMMWORD[80+rdx] + por xmm4,xmm0 + pand xmm2,XMMWORD[96+rdx] + por xmm5,xmm1 + pand xmm3,XMMWORD[112+rdx] + por xmm4,xmm2 + por xmm5,xmm3 + por xmm4,xmm5 + + pshufd xmm0,xmm4,0x4e + por xmm0,xmm4 + lea r12,[256+r12] +DB 102,72,15,126,195 + + mov r10,QWORD[r9*1+r14] + mov rbp,r8 + mul rbx + add r10,rax + mov rax,QWORD[rcx] + adc rdx,0 + + imul rbp,r10 + mov r11,rdx + mov QWORD[r14],rdi + + lea r14,[r9*1+r14] + + mul rbp + add r10,rax + mov rax,QWORD[8+r9*1+rsi] + adc rdx,0 + mov rdi,rdx + + mul rbx + add r11,rax + mov rax,QWORD[8+rcx] + adc rdx,0 + add r11,QWORD[8+r14] + adc rdx,0 + mov r10,rdx + + mul rbp + add rdi,rax + mov rax,QWORD[16+r9*1+rsi] + adc rdx,0 + add rdi,r11 + lea r15,[32+r9] + lea rcx,[32+rcx] + adc rdx,0 + mov r13,rdx + jmp NEAR $L$inner4x + +ALIGN 32 +$L$inner4x: + mul rbx + add r10,rax + mov rax,QWORD[((-16))+rcx] + adc rdx,0 + add r10,QWORD[16+r14] + lea r14,[32+r14] + adc rdx,0 + mov r11,rdx + + mul rbp + add r13,rax + mov rax,QWORD[((-8))+r15*1+rsi] + adc rdx,0 + add r13,r10 + adc rdx,0 + mov QWORD[((-32))+r14],rdi + mov rdi,rdx + + mul rbx + add r11,rax + mov rax,QWORD[((-8))+rcx] + adc rdx,0 + add r11,QWORD[((-8))+r14] + adc rdx,0 + mov r10,rdx + + mul rbp + add rdi,rax + mov rax,QWORD[r15*1+rsi] + adc rdx,0 + add rdi,r11 + adc rdx,0 + mov QWORD[((-24))+r14],r13 + mov r13,rdx + + mul rbx + add r10,rax + mov rax,QWORD[rcx] + adc rdx,0 + add r10,QWORD[r14] + adc rdx,0 + mov r11,rdx + + mul rbp + add r13,rax + mov rax,QWORD[8+r15*1+rsi] + adc rdx,0 + add r13,r10 + adc rdx,0 + mov QWORD[((-16))+r14],rdi + mov rdi,rdx + + mul rbx + add r11,rax + mov rax,QWORD[8+rcx] + adc rdx,0 + add r11,QWORD[8+r14] + adc rdx,0 + mov r10,rdx + + mul rbp + add rdi,rax + mov rax,QWORD[16+r15*1+rsi] + adc rdx,0 + add rdi,r11 + lea rcx,[32+rcx] + adc rdx,0 + mov QWORD[((-8))+r14],r13 + mov r13,rdx + + add r15,32 + jnz NEAR $L$inner4x + + mul rbx + add r10,rax + mov rax,QWORD[((-16))+rcx] + adc rdx,0 + add r10,QWORD[16+r14] + lea r14,[32+r14] + adc rdx,0 + mov r11,rdx + + mul rbp + add r13,rax + mov rax,QWORD[((-8))+rsi] + adc rdx,0 + add r13,r10 + adc rdx,0 + mov QWORD[((-32))+r14],rdi + mov rdi,rdx + + mul rbx + add r11,rax + mov rax,rbp + mov rbp,QWORD[((-8))+rcx] + adc rdx,0 + add r11,QWORD[((-8))+r14] + adc rdx,0 + mov r10,rdx + + mul rbp + add rdi,rax + mov rax,QWORD[r9*1+rsi] + adc rdx,0 + add rdi,r11 + adc rdx,0 + mov QWORD[((-24))+r14],r13 + mov r13,rdx + + mov QWORD[((-16))+r14],rdi + lea rcx,[r9*1+rcx] + + xor rdi,rdi + add r13,r10 + adc rdi,0 + add r13,QWORD[r14] + adc rdi,0 + mov QWORD[((-8))+r14],r13 + + cmp r12,QWORD[((16+8))+rsp] + jb NEAR $L$outer4x + xor rax,rax + sub rbp,r13 + adc r15,r15 + or rdi,r15 + sub rax,rdi + lea rbx,[r9*1+r14] + mov r12,QWORD[rcx] + lea rbp,[rcx] + mov rcx,r9 + sar rcx,3+2 + mov rdi,QWORD[((56+8))+rsp] + dec r12 + xor r10,r10 + mov r13,QWORD[8+rbp] + mov r14,QWORD[16+rbp] + mov r15,QWORD[24+rbp] + jmp NEAR $L$sqr4x_sub_entry + + +global bn_power5_nohw + +ALIGN 32 +bn_power5_nohw: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_bn_power5_nohw: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + mov rcx,r9 + mov r8,QWORD[40+rsp] + mov r9,QWORD[48+rsp] + + + +_CET_ENDBR + mov rax,rsp + + push rbx + + push rbp + + push r12 + + push r13 + + push r14 + + push r15 + +$L$power5_prologue: + + + + + shl r9d,3 + lea r10d,[r9*2+r9] + neg r9 + mov r8,QWORD[r8] + + + + + + + + + lea r11,[((-320))+r9*2+rsp] + mov rbp,rsp + sub r11,rdi + and r11,4095 + cmp r10,r11 + jb NEAR $L$pwr_sp_alt + sub rbp,r11 + lea rbp,[((-320))+r9*2+rbp] + jmp NEAR $L$pwr_sp_done + +ALIGN 32 +$L$pwr_sp_alt: + lea r10,[((4096-320))+r9*2] + lea rbp,[((-320))+r9*2+rbp] + sub r11,r10 + mov r10,0 + cmovc r11,r10 + sub rbp,r11 +$L$pwr_sp_done: + and rbp,-64 + mov r11,rsp + sub r11,rbp + and r11,-4096 + lea rsp,[rbp*1+r11] + mov r10,QWORD[rsp] + cmp rsp,rbp + ja NEAR $L$pwr_page_walk + jmp NEAR $L$pwr_page_walk_done + +$L$pwr_page_walk: + lea rsp,[((-4096))+rsp] + mov r10,QWORD[rsp] + cmp rsp,rbp + ja NEAR $L$pwr_page_walk +$L$pwr_page_walk_done: + + mov r10,r9 + neg r9 + + + + + + + + + + + mov QWORD[32+rsp],r8 + mov QWORD[40+rsp],rax + +$L$power5_body: +DB 102,72,15,110,207 +DB 102,72,15,110,209 +DB 102,73,15,110,218 +DB 102,72,15,110,226 + + call __bn_sqr8x_internal + call __bn_post4x_internal + call __bn_sqr8x_internal + call __bn_post4x_internal + call __bn_sqr8x_internal + call __bn_post4x_internal + call __bn_sqr8x_internal + call __bn_post4x_internal + call __bn_sqr8x_internal + call __bn_post4x_internal + +DB 102,72,15,126,209 +DB 102,72,15,126,226 + mov rdi,rsi + mov rax,QWORD[40+rsp] + lea r8,[32+rsp] + + call mul4x_internal + + mov rsi,QWORD[40+rsp] + + mov rax,1 + mov r15,QWORD[((-48))+rsi] + + mov r14,QWORD[((-40))+rsi] + + mov r13,QWORD[((-32))+rsi] + + mov r12,QWORD[((-24))+rsi] + + mov rbp,QWORD[((-16))+rsi] + + mov rbx,QWORD[((-8))+rsi] + + lea rsp,[rsi] + +$L$power5_epilogue: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_bn_power5_nohw: + +global bn_sqr8x_internal + + +ALIGN 32 +bn_sqr8x_internal: +__bn_sqr8x_internal: + +_CET_ENDBR + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + lea rbp,[32+r10] + lea rsi,[r9*1+rsi] + + mov rcx,r9 + + + mov r14,QWORD[((-32))+rbp*1+rsi] + lea rdi,[((48+8))+r9*2+rsp] + mov rax,QWORD[((-24))+rbp*1+rsi] + lea rdi,[((-32))+rbp*1+rdi] + mov rbx,QWORD[((-16))+rbp*1+rsi] + mov r15,rax + + mul r14 + mov r10,rax + mov rax,rbx + mov r11,rdx + mov QWORD[((-24))+rbp*1+rdi],r10 + + mul r14 + add r11,rax + mov rax,rbx + adc rdx,0 + mov QWORD[((-16))+rbp*1+rdi],r11 + mov r10,rdx + + + mov rbx,QWORD[((-8))+rbp*1+rsi] + mul r15 + mov r12,rax + mov rax,rbx + mov r13,rdx + + lea rcx,[rbp] + mul r14 + add r10,rax + mov rax,rbx + mov r11,rdx + adc r11,0 + add r10,r12 + adc r11,0 + mov QWORD[((-8))+rcx*1+rdi],r10 + jmp NEAR $L$sqr4x_1st + +ALIGN 32 +$L$sqr4x_1st: + mov rbx,QWORD[rcx*1+rsi] + mul r15 + add r13,rax + mov rax,rbx + mov r12,rdx + adc r12,0 + + mul r14 + add r11,rax + mov rax,rbx + mov rbx,QWORD[8+rcx*1+rsi] + mov r10,rdx + adc r10,0 + add r11,r13 + adc r10,0 + + + mul r15 + add r12,rax + mov rax,rbx + mov QWORD[rcx*1+rdi],r11 + mov r13,rdx + adc r13,0 + + mul r14 + add r10,rax + mov rax,rbx + mov rbx,QWORD[16+rcx*1+rsi] + mov r11,rdx + adc r11,0 + add r10,r12 + adc r11,0 + + mul r15 + add r13,rax + mov rax,rbx + mov QWORD[8+rcx*1+rdi],r10 + mov r12,rdx + adc r12,0 + + mul r14 + add r11,rax + mov rax,rbx + mov rbx,QWORD[24+rcx*1+rsi] + mov r10,rdx + adc r10,0 + add r11,r13 + adc r10,0 + + + mul r15 + add r12,rax + mov rax,rbx + mov QWORD[16+rcx*1+rdi],r11 + mov r13,rdx + adc r13,0 + lea rcx,[32+rcx] + + mul r14 + add r10,rax + mov rax,rbx + mov r11,rdx + adc r11,0 + add r10,r12 + adc r11,0 + mov QWORD[((-8))+rcx*1+rdi],r10 + + cmp rcx,0 + jne NEAR $L$sqr4x_1st + + mul r15 + add r13,rax + lea rbp,[16+rbp] + adc rdx,0 + add r13,r11 + adc rdx,0 + + mov QWORD[rdi],r13 + mov r12,rdx + mov QWORD[8+rdi],rdx + jmp NEAR $L$sqr4x_outer + +ALIGN 32 +$L$sqr4x_outer: + mov r14,QWORD[((-32))+rbp*1+rsi] + lea rdi,[((48+8))+r9*2+rsp] + mov rax,QWORD[((-24))+rbp*1+rsi] + lea rdi,[((-32))+rbp*1+rdi] + mov rbx,QWORD[((-16))+rbp*1+rsi] + mov r15,rax + + mul r14 + mov r10,QWORD[((-24))+rbp*1+rdi] + add r10,rax + mov rax,rbx + adc rdx,0 + mov QWORD[((-24))+rbp*1+rdi],r10 + mov r11,rdx + + mul r14 + add r11,rax + mov rax,rbx + adc rdx,0 + add r11,QWORD[((-16))+rbp*1+rdi] + mov r10,rdx + adc r10,0 + mov QWORD[((-16))+rbp*1+rdi],r11 + + xor r12,r12 + + mov rbx,QWORD[((-8))+rbp*1+rsi] + mul r15 + add r12,rax + mov rax,rbx + adc rdx,0 + add r12,QWORD[((-8))+rbp*1+rdi] + mov r13,rdx + adc r13,0 + + mul r14 + add r10,rax + mov rax,rbx + adc rdx,0 + add r10,r12 + mov r11,rdx + adc r11,0 + mov QWORD[((-8))+rbp*1+rdi],r10 + + lea rcx,[rbp] + jmp NEAR $L$sqr4x_inner + +ALIGN 32 +$L$sqr4x_inner: + mov rbx,QWORD[rcx*1+rsi] + mul r15 + add r13,rax + mov rax,rbx + mov r12,rdx + adc r12,0 + add r13,QWORD[rcx*1+rdi] + adc r12,0 + + DB 0x67 + mul r14 + add r11,rax + mov rax,rbx + mov rbx,QWORD[8+rcx*1+rsi] + mov r10,rdx + adc r10,0 + add r11,r13 + adc r10,0 + + mul r15 + add r12,rax + mov QWORD[rcx*1+rdi],r11 + mov rax,rbx + mov r13,rdx + adc r13,0 + add r12,QWORD[8+rcx*1+rdi] + lea rcx,[16+rcx] + adc r13,0 + + mul r14 + add r10,rax + mov rax,rbx + adc rdx,0 + add r10,r12 + mov r11,rdx + adc r11,0 + mov QWORD[((-8))+rcx*1+rdi],r10 + + cmp rcx,0 + jne NEAR $L$sqr4x_inner + + DB 0x67 + mul r15 + add r13,rax + adc rdx,0 + add r13,r11 + adc rdx,0 + + mov QWORD[rdi],r13 + mov r12,rdx + mov QWORD[8+rdi],rdx + + add rbp,16 + jnz NEAR $L$sqr4x_outer + + + mov r14,QWORD[((-32))+rsi] + lea rdi,[((48+8))+r9*2+rsp] + mov rax,QWORD[((-24))+rsi] + lea rdi,[((-32))+rbp*1+rdi] + mov rbx,QWORD[((-16))+rsi] + mov r15,rax + + mul r14 + add r10,rax + mov rax,rbx + mov r11,rdx + adc r11,0 + + mul r14 + add r11,rax + mov rax,rbx + mov QWORD[((-24))+rdi],r10 + mov r10,rdx + adc r10,0 + add r11,r13 + mov rbx,QWORD[((-8))+rsi] + adc r10,0 + + mul r15 + add r12,rax + mov rax,rbx + mov QWORD[((-16))+rdi],r11 + mov r13,rdx + adc r13,0 + + mul r14 + add r10,rax + mov rax,rbx + mov r11,rdx + adc r11,0 + add r10,r12 + adc r11,0 + mov QWORD[((-8))+rdi],r10 + + mul r15 + add r13,rax + mov rax,QWORD[((-16))+rsi] + adc rdx,0 + add r13,r11 + adc rdx,0 + + mov QWORD[rdi],r13 + mov r12,rdx + mov QWORD[8+rdi],rdx + + mul rbx + add rbp,16 + xor r14,r14 + sub rbp,r9 + xor r15,r15 + + add rax,r12 + adc rdx,0 + mov QWORD[8+rdi],rax + mov QWORD[16+rdi],rdx + mov QWORD[24+rdi],r15 + + mov rax,QWORD[((-16))+rbp*1+rsi] + lea rdi,[((48+8))+rsp] + xor r10,r10 + mov r11,QWORD[8+rdi] + + lea r12,[r10*2+r14] + shr r10,63 + lea r13,[r11*2+rcx] + shr r11,63 + or r13,r10 + mov r10,QWORD[16+rdi] + mov r14,r11 + mul rax + neg r15 + mov r11,QWORD[24+rdi] + adc r12,rax + mov rax,QWORD[((-8))+rbp*1+rsi] + mov QWORD[rdi],r12 + adc r13,rdx + + lea rbx,[r10*2+r14] + mov QWORD[8+rdi],r13 + sbb r15,r15 + shr r10,63 + lea r8,[r11*2+rcx] + shr r11,63 + or r8,r10 + mov r10,QWORD[32+rdi] + mov r14,r11 + mul rax + neg r15 + mov r11,QWORD[40+rdi] + adc rbx,rax + mov rax,QWORD[rbp*1+rsi] + mov QWORD[16+rdi],rbx + adc r8,rdx + lea rbp,[16+rbp] + mov QWORD[24+rdi],r8 + sbb r15,r15 + lea rdi,[64+rdi] + jmp NEAR $L$sqr4x_shift_n_add + +ALIGN 32 +$L$sqr4x_shift_n_add: + lea r12,[r10*2+r14] + shr r10,63 + lea r13,[r11*2+rcx] + shr r11,63 + or r13,r10 + mov r10,QWORD[((-16))+rdi] + mov r14,r11 + mul rax + neg r15 + mov r11,QWORD[((-8))+rdi] + adc r12,rax + mov rax,QWORD[((-8))+rbp*1+rsi] + mov QWORD[((-32))+rdi],r12 + adc r13,rdx + + lea rbx,[r10*2+r14] + mov QWORD[((-24))+rdi],r13 + sbb r15,r15 + shr r10,63 + lea r8,[r11*2+rcx] + shr r11,63 + or r8,r10 + mov r10,QWORD[rdi] + mov r14,r11 + mul rax + neg r15 + mov r11,QWORD[8+rdi] + adc rbx,rax + mov rax,QWORD[rbp*1+rsi] + mov QWORD[((-16))+rdi],rbx + adc r8,rdx + + lea r12,[r10*2+r14] + mov QWORD[((-8))+rdi],r8 + sbb r15,r15 + shr r10,63 + lea r13,[r11*2+rcx] + shr r11,63 + or r13,r10 + mov r10,QWORD[16+rdi] + mov r14,r11 + mul rax + neg r15 + mov r11,QWORD[24+rdi] + adc r12,rax + mov rax,QWORD[8+rbp*1+rsi] + mov QWORD[rdi],r12 + adc r13,rdx + + lea rbx,[r10*2+r14] + mov QWORD[8+rdi],r13 + sbb r15,r15 + shr r10,63 + lea r8,[r11*2+rcx] + shr r11,63 + or r8,r10 + mov r10,QWORD[32+rdi] + mov r14,r11 + mul rax + neg r15 + mov r11,QWORD[40+rdi] + adc rbx,rax + mov rax,QWORD[16+rbp*1+rsi] + mov QWORD[16+rdi],rbx + adc r8,rdx + mov QWORD[24+rdi],r8 + sbb r15,r15 + lea rdi,[64+rdi] + add rbp,32 + jnz NEAR $L$sqr4x_shift_n_add + + lea r12,[r10*2+r14] + DB 0x67 + shr r10,63 + lea r13,[r11*2+rcx] + shr r11,63 + or r13,r10 + mov r10,QWORD[((-16))+rdi] + mov r14,r11 + mul rax + neg r15 + mov r11,QWORD[((-8))+rdi] + adc r12,rax + mov rax,QWORD[((-8))+rsi] + mov QWORD[((-32))+rdi],r12 + adc r13,rdx + + lea rbx,[r10*2+r14] + mov QWORD[((-24))+rdi],r13 + sbb r15,r15 + shr r10,63 + lea r8,[r11*2+rcx] + shr r11,63 + or r8,r10 + mul rax + neg r15 + adc rbx,rax + adc r8,rdx + mov QWORD[((-16))+rdi],rbx + mov QWORD[((-8))+rdi],r8 +DB 102,72,15,126,213 +__bn_sqr8x_reduction: + xor rax,rax + lea rcx,[rbp*1+r9] + lea rdx,[((48+8))+r9*2+rsp] + mov QWORD[((0+8))+rsp],rcx + lea rdi,[((48+8))+r9*1+rsp] + mov QWORD[((8+8))+rsp],rdx + neg r9 + jmp NEAR $L$8x_reduction_loop + +ALIGN 32 +$L$8x_reduction_loop: + lea rdi,[r9*1+rdi] + DB 0x66 + mov rbx,QWORD[rdi] + mov r9,QWORD[8+rdi] + mov r10,QWORD[16+rdi] + mov r11,QWORD[24+rdi] + mov r12,QWORD[32+rdi] + mov r13,QWORD[40+rdi] + mov r14,QWORD[48+rdi] + mov r15,QWORD[56+rdi] + mov QWORD[rdx],rax + lea rdi,[64+rdi] + + DB 0x67 + mov r8,rbx + imul rbx,QWORD[((32+8))+rsp] + mov rax,QWORD[rbp] + mov ecx,8 + jmp NEAR $L$8x_reduce + +ALIGN 32 +$L$8x_reduce: + mul rbx + mov rax,QWORD[8+rbp] + neg r8 + mov r8,rdx + adc r8,0 + + mul rbx + add r9,rax + mov rax,QWORD[16+rbp] + adc rdx,0 + add r8,r9 + mov QWORD[((48-8+8))+rcx*8+rsp],rbx + mov r9,rdx + adc r9,0 + + mul rbx + add r10,rax + mov rax,QWORD[24+rbp] + adc rdx,0 + add r9,r10 + mov rsi,QWORD[((32+8))+rsp] + mov r10,rdx + adc r10,0 + + mul rbx + add r11,rax + mov rax,QWORD[32+rbp] + adc rdx,0 + imul rsi,r8 + add r10,r11 + mov r11,rdx + adc r11,0 + + mul rbx + add r12,rax + mov rax,QWORD[40+rbp] + adc rdx,0 + add r11,r12 + mov r12,rdx + adc r12,0 + + mul rbx + add r13,rax + mov rax,QWORD[48+rbp] + adc rdx,0 + add r12,r13 + mov r13,rdx + adc r13,0 + + mul rbx + add r14,rax + mov rax,QWORD[56+rbp] + adc rdx,0 + add r13,r14 + mov r14,rdx + adc r14,0 + + mul rbx + mov rbx,rsi + add r15,rax + mov rax,QWORD[rbp] + adc rdx,0 + add r14,r15 + mov r15,rdx + adc r15,0 + + dec ecx + jnz NEAR $L$8x_reduce + + lea rbp,[64+rbp] + xor rax,rax + mov rdx,QWORD[((8+8))+rsp] + cmp rbp,QWORD[((0+8))+rsp] + jae NEAR $L$8x_no_tail + + DB 0x66 + add r8,QWORD[rdi] + adc r9,QWORD[8+rdi] + adc r10,QWORD[16+rdi] + adc r11,QWORD[24+rdi] + adc r12,QWORD[32+rdi] + adc r13,QWORD[40+rdi] + adc r14,QWORD[48+rdi] + adc r15,QWORD[56+rdi] + sbb rsi,rsi + + mov rbx,QWORD[((48+56+8))+rsp] + mov ecx,8 + mov rax,QWORD[rbp] + jmp NEAR $L$8x_tail + +ALIGN 32 +$L$8x_tail: + mul rbx + add r8,rax + mov rax,QWORD[8+rbp] + mov QWORD[rdi],r8 + mov r8,rdx + adc r8,0 + + mul rbx + add r9,rax + mov rax,QWORD[16+rbp] + adc rdx,0 + add r8,r9 + lea rdi,[8+rdi] + mov r9,rdx + adc r9,0 + + mul rbx + add r10,rax + mov rax,QWORD[24+rbp] + adc rdx,0 + add r9,r10 + mov r10,rdx + adc r10,0 + + mul rbx + add r11,rax + mov rax,QWORD[32+rbp] + adc rdx,0 + add r10,r11 + mov r11,rdx + adc r11,0 + + mul rbx + add r12,rax + mov rax,QWORD[40+rbp] + adc rdx,0 + add r11,r12 + mov r12,rdx + adc r12,0 + + mul rbx + add r13,rax + mov rax,QWORD[48+rbp] + adc rdx,0 + add r12,r13 + mov r13,rdx + adc r13,0 + + mul rbx + add r14,rax + mov rax,QWORD[56+rbp] + adc rdx,0 + add r13,r14 + mov r14,rdx + adc r14,0 + + mul rbx + mov rbx,QWORD[((48-16+8))+rcx*8+rsp] + add r15,rax + adc rdx,0 + add r14,r15 + mov rax,QWORD[rbp] + mov r15,rdx + adc r15,0 + + dec ecx + jnz NEAR $L$8x_tail + + lea rbp,[64+rbp] + mov rdx,QWORD[((8+8))+rsp] + cmp rbp,QWORD[((0+8))+rsp] + jae NEAR $L$8x_tail_done + + mov rbx,QWORD[((48+56+8))+rsp] + neg rsi + mov rax,QWORD[rbp] + adc r8,QWORD[rdi] + adc r9,QWORD[8+rdi] + adc r10,QWORD[16+rdi] + adc r11,QWORD[24+rdi] + adc r12,QWORD[32+rdi] + adc r13,QWORD[40+rdi] + adc r14,QWORD[48+rdi] + adc r15,QWORD[56+rdi] + sbb rsi,rsi + + mov ecx,8 + jmp NEAR $L$8x_tail + +ALIGN 32 +$L$8x_tail_done: + xor rax,rax + add r8,QWORD[rdx] + adc r9,0 + adc r10,0 + adc r11,0 + adc r12,0 + adc r13,0 + adc r14,0 + adc r15,0 + adc rax,0 + + neg rsi +$L$8x_no_tail: + adc r8,QWORD[rdi] + adc r9,QWORD[8+rdi] + adc r10,QWORD[16+rdi] + adc r11,QWORD[24+rdi] + adc r12,QWORD[32+rdi] + adc r13,QWORD[40+rdi] + adc r14,QWORD[48+rdi] + adc r15,QWORD[56+rdi] + adc rax,0 + mov rcx,QWORD[((-8))+rbp] + xor rsi,rsi + +DB 102,72,15,126,213 + + mov QWORD[rdi],r8 + mov QWORD[8+rdi],r9 +DB 102,73,15,126,217 + mov QWORD[16+rdi],r10 + mov QWORD[24+rdi],r11 + mov QWORD[32+rdi],r12 + mov QWORD[40+rdi],r13 + mov QWORD[48+rdi],r14 + mov QWORD[56+rdi],r15 + lea rdi,[64+rdi] + + cmp rdi,rdx + jb NEAR $L$8x_reduction_loop + ret + + + +ALIGN 32 +__bn_post4x_internal: + + mov r12,QWORD[rbp] + lea rbx,[r9*1+rdi] + mov rcx,r9 +DB 102,72,15,126,207 + neg rax +DB 102,72,15,126,206 + sar rcx,3+2 + dec r12 + xor r10,r10 + mov r13,QWORD[8+rbp] + mov r14,QWORD[16+rbp] + mov r15,QWORD[24+rbp] + jmp NEAR $L$sqr4x_sub_entry + +ALIGN 16 +$L$sqr4x_sub: + mov r12,QWORD[rbp] + mov r13,QWORD[8+rbp] + mov r14,QWORD[16+rbp] + mov r15,QWORD[24+rbp] +$L$sqr4x_sub_entry: + lea rbp,[32+rbp] + not r12 + not r13 + not r14 + not r15 + and r12,rax + and r13,rax + and r14,rax + and r15,rax + + neg r10 + adc r12,QWORD[rbx] + adc r13,QWORD[8+rbx] + adc r14,QWORD[16+rbx] + adc r15,QWORD[24+rbx] + mov QWORD[rdi],r12 + lea rbx,[32+rbx] + mov QWORD[8+rdi],r13 + sbb r10,r10 + mov QWORD[16+rdi],r14 + mov QWORD[24+rdi],r15 + lea rdi,[32+rdi] + + inc rcx + jnz NEAR $L$sqr4x_sub + + mov r10,r9 + neg r9 + ret + + +global bn_mulx4x_mont_gather5 + +ALIGN 32 +bn_mulx4x_mont_gather5: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_bn_mulx4x_mont_gather5: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + mov rcx,r9 + mov r8,QWORD[40+rsp] + mov r9,QWORD[48+rsp] + + + +_CET_ENDBR + mov rax,rsp + + push rbx + + push rbp + + push r12 + + push r13 + + push r14 + + push r15 + +$L$mulx4x_prologue: + + + + + shl r9d,3 + lea r10,[r9*2+r9] + neg r9 + mov r8,QWORD[r8] + + + + + + + + + + + lea r11,[((-320))+r9*2+rsp] + mov rbp,rsp + sub r11,rdi + and r11,4095 + cmp r10,r11 + jb NEAR $L$mulx4xsp_alt + sub rbp,r11 + lea rbp,[((-320))+r9*2+rbp] + jmp NEAR $L$mulx4xsp_done + +$L$mulx4xsp_alt: + lea r10,[((4096-320))+r9*2] + lea rbp,[((-320))+r9*2+rbp] + sub r11,r10 + mov r10,0 + cmovc r11,r10 + sub rbp,r11 +$L$mulx4xsp_done: + and rbp,-64 + mov r11,rsp + sub r11,rbp + and r11,-4096 + lea rsp,[rbp*1+r11] + mov r10,QWORD[rsp] + cmp rsp,rbp + ja NEAR $L$mulx4x_page_walk + jmp NEAR $L$mulx4x_page_walk_done + +$L$mulx4x_page_walk: + lea rsp,[((-4096))+rsp] + mov r10,QWORD[rsp] + cmp rsp,rbp + ja NEAR $L$mulx4x_page_walk +$L$mulx4x_page_walk_done: + + + + + + + + + + + + + + mov QWORD[32+rsp],r8 + mov QWORD[40+rsp],rax + +$L$mulx4x_body: + call mulx4x_internal + + mov rsi,QWORD[40+rsp] + + mov rax,1 + + mov r15,QWORD[((-48))+rsi] + + mov r14,QWORD[((-40))+rsi] + + mov r13,QWORD[((-32))+rsi] + + mov r12,QWORD[((-24))+rsi] + + mov rbp,QWORD[((-16))+rsi] + + mov rbx,QWORD[((-8))+rsi] + + lea rsp,[rsi] + +$L$mulx4x_epilogue: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_bn_mulx4x_mont_gather5: + + +ALIGN 32 +mulx4x_internal: + + mov QWORD[8+rsp],r9 + mov r10,r9 + neg r9 + shl r9,5 + neg r10 + lea r13,[128+r9*1+rdx] + shr r9,5+5 + movd xmm5,DWORD[56+rax] + sub r9,1 + lea rax,[$L$inc] + mov QWORD[((16+8))+rsp],r13 + mov QWORD[((24+8))+rsp],r9 + mov QWORD[((56+8))+rsp],rdi + movdqa xmm0,XMMWORD[rax] + movdqa xmm1,XMMWORD[16+rax] + lea r10,[((88-112))+r10*1+rsp] + lea rdi,[128+rdx] + + pshufd xmm5,xmm5,0 + movdqa xmm4,xmm1 + DB 0x67 + movdqa xmm2,xmm1 + DB 0x67 + paddd xmm1,xmm0 + pcmpeqd xmm0,xmm5 + movdqa xmm3,xmm4 + paddd xmm2,xmm1 + pcmpeqd xmm1,xmm5 + movdqa XMMWORD[112+r10],xmm0 + movdqa xmm0,xmm4 + + paddd xmm3,xmm2 + pcmpeqd xmm2,xmm5 + movdqa XMMWORD[128+r10],xmm1 + movdqa xmm1,xmm4 + + paddd xmm0,xmm3 + pcmpeqd xmm3,xmm5 + movdqa XMMWORD[144+r10],xmm2 + movdqa xmm2,xmm4 + + paddd xmm1,xmm0 + pcmpeqd xmm0,xmm5 + movdqa XMMWORD[160+r10],xmm3 + movdqa xmm3,xmm4 + paddd xmm2,xmm1 + pcmpeqd xmm1,xmm5 + movdqa XMMWORD[176+r10],xmm0 + movdqa xmm0,xmm4 + + paddd xmm3,xmm2 + pcmpeqd xmm2,xmm5 + movdqa XMMWORD[192+r10],xmm1 + movdqa xmm1,xmm4 + + paddd xmm0,xmm3 + pcmpeqd xmm3,xmm5 + movdqa XMMWORD[208+r10],xmm2 + movdqa xmm2,xmm4 + + paddd xmm1,xmm0 + pcmpeqd xmm0,xmm5 + movdqa XMMWORD[224+r10],xmm3 + movdqa xmm3,xmm4 + paddd xmm2,xmm1 + pcmpeqd xmm1,xmm5 + movdqa XMMWORD[240+r10],xmm0 + movdqa xmm0,xmm4 + + paddd xmm3,xmm2 + pcmpeqd xmm2,xmm5 + movdqa XMMWORD[256+r10],xmm1 + movdqa xmm1,xmm4 + + paddd xmm0,xmm3 + pcmpeqd xmm3,xmm5 + movdqa XMMWORD[272+r10],xmm2 + movdqa xmm2,xmm4 + + paddd xmm1,xmm0 + pcmpeqd xmm0,xmm5 + movdqa XMMWORD[288+r10],xmm3 + movdqa xmm3,xmm4 + DB 0x67 + paddd xmm2,xmm1 + pcmpeqd xmm1,xmm5 + movdqa XMMWORD[304+r10],xmm0 + + paddd xmm3,xmm2 + pcmpeqd xmm2,xmm5 + movdqa XMMWORD[320+r10],xmm1 + + pcmpeqd xmm3,xmm5 + movdqa XMMWORD[336+r10],xmm2 + + pand xmm0,XMMWORD[64+rdi] + pand xmm1,XMMWORD[80+rdi] + pand xmm2,XMMWORD[96+rdi] + movdqa XMMWORD[352+r10],xmm3 + pand xmm3,XMMWORD[112+rdi] + por xmm0,xmm2 + por xmm1,xmm3 + movdqa xmm4,XMMWORD[((-128))+rdi] + movdqa xmm5,XMMWORD[((-112))+rdi] + movdqa xmm2,XMMWORD[((-96))+rdi] + pand xmm4,XMMWORD[112+r10] + movdqa xmm3,XMMWORD[((-80))+rdi] + pand xmm5,XMMWORD[128+r10] + por xmm0,xmm4 + pand xmm2,XMMWORD[144+r10] + por xmm1,xmm5 + pand xmm3,XMMWORD[160+r10] + por xmm0,xmm2 + por xmm1,xmm3 + movdqa xmm4,XMMWORD[((-64))+rdi] + movdqa xmm5,XMMWORD[((-48))+rdi] + movdqa xmm2,XMMWORD[((-32))+rdi] + pand xmm4,XMMWORD[176+r10] + movdqa xmm3,XMMWORD[((-16))+rdi] + pand xmm5,XMMWORD[192+r10] + por xmm0,xmm4 + pand xmm2,XMMWORD[208+r10] + por xmm1,xmm5 + pand xmm3,XMMWORD[224+r10] + por xmm0,xmm2 + por xmm1,xmm3 + movdqa xmm4,XMMWORD[rdi] + movdqa xmm5,XMMWORD[16+rdi] + movdqa xmm2,XMMWORD[32+rdi] + pand xmm4,XMMWORD[240+r10] + movdqa xmm3,XMMWORD[48+rdi] + pand xmm5,XMMWORD[256+r10] + por xmm0,xmm4 + pand xmm2,XMMWORD[272+r10] + por xmm1,xmm5 + pand xmm3,XMMWORD[288+r10] + por xmm0,xmm2 + por xmm1,xmm3 + pxor xmm0,xmm1 + + pshufd xmm1,xmm0,0x4e + por xmm0,xmm1 + lea rdi,[256+rdi] +DB 102,72,15,126,194 + lea rbx,[((64+32+8))+rsp] + + mov r9,rdx + mulx rax,r8,QWORD[rsi] + mulx r12,r11,QWORD[8+rsi] + add r11,rax + mulx r13,rax,QWORD[16+rsi] + adc r12,rax + adc r13,0 + mulx r14,rax,QWORD[24+rsi] + + mov r15,r8 + imul r8,QWORD[((32+8))+rsp] + xor rbp,rbp + mov rdx,r8 + + mov QWORD[((8+8))+rsp],rdi + + lea rsi,[32+rsi] + adcx r13,rax + adcx r14,rbp + + mulx r10,rax,QWORD[rcx] + adcx r15,rax + adox r10,r11 + mulx r11,rax,QWORD[8+rcx] + adcx r10,rax + adox r11,r12 + mulx r12,rax,QWORD[16+rcx] + mov rdi,QWORD[((24+8))+rsp] + mov QWORD[((-32))+rbx],r10 + adcx r11,rax + adox r12,r13 + mulx r15,rax,QWORD[24+rcx] + mov rdx,r9 + mov QWORD[((-24))+rbx],r11 + adcx r12,rax + adox r15,rbp + lea rcx,[32+rcx] + mov QWORD[((-16))+rbx],r12 + jmp NEAR $L$mulx4x_1st + +ALIGN 32 +$L$mulx4x_1st: + adcx r15,rbp + mulx rax,r10,QWORD[rsi] + adcx r10,r14 + mulx r14,r11,QWORD[8+rsi] + adcx r11,rax + mulx rax,r12,QWORD[16+rsi] + adcx r12,r14 + mulx r14,r13,QWORD[24+rsi] + DB 0x67,0x67 + mov rdx,r8 + adcx r13,rax + adcx r14,rbp + lea rsi,[32+rsi] + lea rbx,[32+rbx] + + adox r10,r15 + mulx r15,rax,QWORD[rcx] + adcx r10,rax + adox r11,r15 + mulx r15,rax,QWORD[8+rcx] + adcx r11,rax + adox r12,r15 + mulx r15,rax,QWORD[16+rcx] + mov QWORD[((-40))+rbx],r10 + adcx r12,rax + mov QWORD[((-32))+rbx],r11 + adox r13,r15 + mulx r15,rax,QWORD[24+rcx] + mov rdx,r9 + mov QWORD[((-24))+rbx],r12 + adcx r13,rax + adox r15,rbp + lea rcx,[32+rcx] + mov QWORD[((-16))+rbx],r13 + + dec rdi + jnz NEAR $L$mulx4x_1st + + mov rax,QWORD[8+rsp] + adc r15,rbp + lea rsi,[rax*1+rsi] + add r14,r15 + mov rdi,QWORD[((8+8))+rsp] + adc rbp,rbp + mov QWORD[((-8))+rbx],r14 + jmp NEAR $L$mulx4x_outer + +ALIGN 32 +$L$mulx4x_outer: + lea r10,[((16-256))+rbx] + pxor xmm4,xmm4 + DB 0x67,0x67 + pxor xmm5,xmm5 + movdqa xmm0,XMMWORD[((-128))+rdi] + movdqa xmm1,XMMWORD[((-112))+rdi] + movdqa xmm2,XMMWORD[((-96))+rdi] + pand xmm0,XMMWORD[256+r10] + movdqa xmm3,XMMWORD[((-80))+rdi] + pand xmm1,XMMWORD[272+r10] + por xmm4,xmm0 + pand xmm2,XMMWORD[288+r10] + por xmm5,xmm1 + pand xmm3,XMMWORD[304+r10] + por xmm4,xmm2 + por xmm5,xmm3 + movdqa xmm0,XMMWORD[((-64))+rdi] + movdqa xmm1,XMMWORD[((-48))+rdi] + movdqa xmm2,XMMWORD[((-32))+rdi] + pand xmm0,XMMWORD[320+r10] + movdqa xmm3,XMMWORD[((-16))+rdi] + pand xmm1,XMMWORD[336+r10] + por xmm4,xmm0 + pand xmm2,XMMWORD[352+r10] + por xmm5,xmm1 + pand xmm3,XMMWORD[368+r10] + por xmm4,xmm2 + por xmm5,xmm3 + movdqa xmm0,XMMWORD[rdi] + movdqa xmm1,XMMWORD[16+rdi] + movdqa xmm2,XMMWORD[32+rdi] + pand xmm0,XMMWORD[384+r10] + movdqa xmm3,XMMWORD[48+rdi] + pand xmm1,XMMWORD[400+r10] + por xmm4,xmm0 + pand xmm2,XMMWORD[416+r10] + por xmm5,xmm1 + pand xmm3,XMMWORD[432+r10] + por xmm4,xmm2 + por xmm5,xmm3 + movdqa xmm0,XMMWORD[64+rdi] + movdqa xmm1,XMMWORD[80+rdi] + movdqa xmm2,XMMWORD[96+rdi] + pand xmm0,XMMWORD[448+r10] + movdqa xmm3,XMMWORD[112+rdi] + pand xmm1,XMMWORD[464+r10] + por xmm4,xmm0 + pand xmm2,XMMWORD[480+r10] + por xmm5,xmm1 + pand xmm3,XMMWORD[496+r10] + por xmm4,xmm2 + por xmm5,xmm3 + por xmm4,xmm5 + + pshufd xmm0,xmm4,0x4e + por xmm0,xmm4 + lea rdi,[256+rdi] +DB 102,72,15,126,194 + + mov QWORD[rbx],rbp + lea rbx,[32+rax*1+rbx] + mulx r11,r8,QWORD[rsi] + xor rbp,rbp + mov r9,rdx + mulx r12,r14,QWORD[8+rsi] + adox r8,QWORD[((-32))+rbx] + adcx r11,r14 + mulx r13,r15,QWORD[16+rsi] + adox r11,QWORD[((-24))+rbx] + adcx r12,r15 + mulx r14,rdx,QWORD[24+rsi] + adox r12,QWORD[((-16))+rbx] + adcx r13,rdx + lea rcx,[rax*1+rcx] + lea rsi,[32+rsi] + adox r13,QWORD[((-8))+rbx] + adcx r14,rbp + adox r14,rbp + + mov r15,r8 + imul r8,QWORD[((32+8))+rsp] + + mov rdx,r8 + xor rbp,rbp + mov QWORD[((8+8))+rsp],rdi + + mulx r10,rax,QWORD[rcx] + adcx r15,rax + adox r10,r11 + mulx r11,rax,QWORD[8+rcx] + adcx r10,rax + adox r11,r12 + mulx r12,rax,QWORD[16+rcx] + adcx r11,rax + adox r12,r13 + mulx r15,rax,QWORD[24+rcx] + mov rdx,r9 + mov rdi,QWORD[((24+8))+rsp] + mov QWORD[((-32))+rbx],r10 + adcx r12,rax + mov QWORD[((-24))+rbx],r11 + adox r15,rbp + mov QWORD[((-16))+rbx],r12 + lea rcx,[32+rcx] + jmp NEAR $L$mulx4x_inner + +ALIGN 32 +$L$mulx4x_inner: + mulx rax,r10,QWORD[rsi] + adcx r15,rbp + adox r10,r14 + mulx r14,r11,QWORD[8+rsi] + adcx r10,QWORD[rbx] + adox r11,rax + mulx rax,r12,QWORD[16+rsi] + adcx r11,QWORD[8+rbx] + adox r12,r14 + mulx r14,r13,QWORD[24+rsi] + mov rdx,r8 + adcx r12,QWORD[16+rbx] + adox r13,rax + adcx r13,QWORD[24+rbx] + adox r14,rbp + lea rsi,[32+rsi] + lea rbx,[32+rbx] + adcx r14,rbp + + adox r10,r15 + mulx r15,rax,QWORD[rcx] + adcx r10,rax + adox r11,r15 + mulx r15,rax,QWORD[8+rcx] + adcx r11,rax + adox r12,r15 + mulx r15,rax,QWORD[16+rcx] + mov QWORD[((-40))+rbx],r10 + adcx r12,rax + adox r13,r15 + mov QWORD[((-32))+rbx],r11 + mulx r15,rax,QWORD[24+rcx] + mov rdx,r9 + lea rcx,[32+rcx] + mov QWORD[((-24))+rbx],r12 + adcx r13,rax + adox r15,rbp + mov QWORD[((-16))+rbx],r13 + + dec rdi + jnz NEAR $L$mulx4x_inner + + mov rax,QWORD[((0+8))+rsp] + adc r15,rbp + sub rdi,QWORD[rbx] + mov rdi,QWORD[((8+8))+rsp] + mov r10,QWORD[((16+8))+rsp] + adc r14,r15 + lea rsi,[rax*1+rsi] + adc rbp,rbp + mov QWORD[((-8))+rbx],r14 + + cmp rdi,r10 + jb NEAR $L$mulx4x_outer + + mov r10,QWORD[((-8))+rcx] + mov r8,rbp + mov r12,QWORD[rax*1+rcx] + lea rbp,[rax*1+rcx] + mov rcx,rax + lea rdi,[rax*1+rbx] + xor eax,eax + xor r15,r15 + sub r10,r14 + adc r15,r15 + or r8,r15 + sar rcx,3+2 + sub rax,r8 + mov rdx,QWORD[((56+8))+rsp] + dec r12 + mov r13,QWORD[8+rbp] + xor r8,r8 + mov r14,QWORD[16+rbp] + mov r15,QWORD[24+rbp] + jmp NEAR $L$sqrx4x_sub_entry + + +global bn_powerx5 + +ALIGN 32 +bn_powerx5: + mov QWORD[8+rsp],rdi ;WIN64 prologue + mov QWORD[16+rsp],rsi + mov rax,rsp +$L$SEH_begin_bn_powerx5: + mov rdi,rcx + mov rsi,rdx + mov rdx,r8 + mov rcx,r9 + mov r8,QWORD[40+rsp] + mov r9,QWORD[48+rsp] + + + +_CET_ENDBR + mov rax,rsp + + push rbx + + push rbp + + push r12 + + push r13 + + push r14 + + push r15 + +$L$powerx5_prologue: + + + + + shl r9d,3 + lea r10,[r9*2+r9] + neg r9 + mov r8,QWORD[r8] + + + + + + + + + lea r11,[((-320))+r9*2+rsp] + mov rbp,rsp + sub r11,rdi + and r11,4095 + cmp r10,r11 + jb NEAR $L$pwrx_sp_alt + sub rbp,r11 + lea rbp,[((-320))+r9*2+rbp] + jmp NEAR $L$pwrx_sp_done + +ALIGN 32 +$L$pwrx_sp_alt: + lea r10,[((4096-320))+r9*2] + lea rbp,[((-320))+r9*2+rbp] + sub r11,r10 + mov r10,0 + cmovc r11,r10 + sub rbp,r11 +$L$pwrx_sp_done: + and rbp,-64 + mov r11,rsp + sub r11,rbp + and r11,-4096 + lea rsp,[rbp*1+r11] + mov r10,QWORD[rsp] + cmp rsp,rbp + ja NEAR $L$pwrx_page_walk + jmp NEAR $L$pwrx_page_walk_done + +$L$pwrx_page_walk: + lea rsp,[((-4096))+rsp] + mov r10,QWORD[rsp] + cmp rsp,rbp + ja NEAR $L$pwrx_page_walk +$L$pwrx_page_walk_done: + + mov r10,r9 + neg r9 + + + + + + + + + + + + + pxor xmm0,xmm0 +DB 102,72,15,110,207 +DB 102,72,15,110,209 +DB 102,73,15,110,218 +DB 102,72,15,110,226 + mov QWORD[32+rsp],r8 + mov QWORD[40+rsp],rax + +$L$powerx5_body: + + call __bn_sqrx8x_internal + call __bn_postx4x_internal + call __bn_sqrx8x_internal + call __bn_postx4x_internal + call __bn_sqrx8x_internal + call __bn_postx4x_internal + call __bn_sqrx8x_internal + call __bn_postx4x_internal + call __bn_sqrx8x_internal + call __bn_postx4x_internal + + mov r9,r10 + mov rdi,rsi +DB 102,72,15,126,209 +DB 102,72,15,126,226 + mov rax,QWORD[40+rsp] + + call mulx4x_internal + + mov rsi,QWORD[40+rsp] + + mov rax,1 + + mov r15,QWORD[((-48))+rsi] + + mov r14,QWORD[((-40))+rsi] + + mov r13,QWORD[((-32))+rsi] + + mov r12,QWORD[((-24))+rsi] + + mov rbp,QWORD[((-16))+rsi] + + mov rbx,QWORD[((-8))+rsi] + + lea rsp,[rsi] + +$L$powerx5_epilogue: + mov rdi,QWORD[8+rsp] ;WIN64 epilogue + mov rsi,QWORD[16+rsp] + ret + +$L$SEH_end_bn_powerx5: + +global bn_sqrx8x_internal + + +ALIGN 32 +bn_sqrx8x_internal: +__bn_sqrx8x_internal: + +_CET_ENDBR + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + lea rdi,[((48+8))+rsp] + lea rbp,[r9*1+rsi] + mov QWORD[((0+8))+rsp],r9 + mov QWORD[((8+8))+rsp],rbp + jmp NEAR $L$sqr8x_zero_start + +ALIGN 32 + DB 0x66,0x66,0x66,0x2e,0x0f,0x1f,0x84,0x00,0x00,0x00,0x00,0x00 +$L$sqrx8x_zero: + DB 0x3e + movdqa XMMWORD[rdi],xmm0 + movdqa XMMWORD[16+rdi],xmm0 + movdqa XMMWORD[32+rdi],xmm0 + movdqa XMMWORD[48+rdi],xmm0 +$L$sqr8x_zero_start: + movdqa XMMWORD[64+rdi],xmm0 + movdqa XMMWORD[80+rdi],xmm0 + movdqa XMMWORD[96+rdi],xmm0 + movdqa XMMWORD[112+rdi],xmm0 + lea rdi,[128+rdi] + sub r9,64 + jnz NEAR $L$sqrx8x_zero + + mov rdx,QWORD[rsi] + + xor r10,r10 + xor r11,r11 + xor r12,r12 + xor r13,r13 + xor r14,r14 + xor r15,r15 + lea rdi,[((48+8))+rsp] + xor rbp,rbp + jmp NEAR $L$sqrx8x_outer_loop + +ALIGN 32 +$L$sqrx8x_outer_loop: + mulx rax,r8,QWORD[8+rsi] + adcx r8,r9 + adox r10,rax + mulx rax,r9,QWORD[16+rsi] + adcx r9,r10 + adox r11,rax + DB 0xc4,0xe2,0xab,0xf6,0x86,0x18,0x00,0x00,0x00 + adcx r10,r11 + adox r12,rax + DB 0xc4,0xe2,0xa3,0xf6,0x86,0x20,0x00,0x00,0x00 + adcx r11,r12 + adox r13,rax + mulx rax,r12,QWORD[40+rsi] + adcx r12,r13 + adox r14,rax + mulx rax,r13,QWORD[48+rsi] + adcx r13,r14 + adox rax,r15 + mulx r15,r14,QWORD[56+rsi] + mov rdx,QWORD[8+rsi] + adcx r14,rax + adox r15,rbp + adc r15,QWORD[64+rdi] + mov QWORD[8+rdi],r8 + mov QWORD[16+rdi],r9 + sbb rcx,rcx + xor rbp,rbp + + + mulx rbx,r8,QWORD[16+rsi] + mulx rax,r9,QWORD[24+rsi] + adcx r8,r10 + adox r9,rbx + mulx rbx,r10,QWORD[32+rsi] + adcx r9,r11 + adox r10,rax + DB 0xc4,0xe2,0xa3,0xf6,0x86,0x28,0x00,0x00,0x00 + adcx r10,r12 + adox r11,rbx + DB 0xc4,0xe2,0x9b,0xf6,0x9e,0x30,0x00,0x00,0x00 + adcx r11,r13 + adox r12,r14 + DB 0xc4,0x62,0x93,0xf6,0xb6,0x38,0x00,0x00,0x00 + mov rdx,QWORD[16+rsi] + adcx r12,rax + adox r13,rbx + adcx r13,r15 + adox r14,rbp + adcx r14,rbp + + mov QWORD[24+rdi],r8 + mov QWORD[32+rdi],r9 + + mulx rbx,r8,QWORD[24+rsi] + mulx rax,r9,QWORD[32+rsi] + adcx r8,r10 + adox r9,rbx + mulx rbx,r10,QWORD[40+rsi] + adcx r9,r11 + adox r10,rax + DB 0xc4,0xe2,0xa3,0xf6,0x86,0x30,0x00,0x00,0x00 + adcx r10,r12 + adox r11,r13 + DB 0xc4,0x62,0x9b,0xf6,0xae,0x38,0x00,0x00,0x00 + DB 0x3e + mov rdx,QWORD[24+rsi] + adcx r11,rbx + adox r12,rax + adcx r12,r14 + mov QWORD[40+rdi],r8 + mov QWORD[48+rdi],r9 + mulx rax,r8,QWORD[32+rsi] + adox r13,rbp + adcx r13,rbp + + mulx rbx,r9,QWORD[40+rsi] + adcx r8,r10 + adox r9,rax + mulx rax,r10,QWORD[48+rsi] + adcx r9,r11 + adox r10,r12 + mulx r12,r11,QWORD[56+rsi] + mov rdx,QWORD[32+rsi] + mov r14,QWORD[40+rsi] + adcx r10,rbx + adox r11,rax + mov r15,QWORD[48+rsi] + adcx r11,r13 + adox r12,rbp + adcx r12,rbp + + mov QWORD[56+rdi],r8 + mov QWORD[64+rdi],r9 + + mulx rax,r9,r14 + mov r8,QWORD[56+rsi] + adcx r9,r10 + mulx rbx,r10,r15 + adox r10,rax + adcx r10,r11 + mulx rax,r11,r8 + mov rdx,r14 + adox r11,rbx + adcx r11,r12 + + adcx rax,rbp + + mulx rbx,r14,r15 + mulx r13,r12,r8 + mov rdx,r15 + lea rsi,[64+rsi] + adcx r11,r14 + adox r12,rbx + adcx r12,rax + adox r13,rbp + + DB 0x67,0x67 + mulx r14,r8,r8 + adcx r13,r8 + adcx r14,rbp + + cmp rsi,QWORD[((8+8))+rsp] + je NEAR $L$sqrx8x_outer_break + + neg rcx + mov rcx,-8 + mov r15,rbp + mov r8,QWORD[64+rdi] + adcx r9,QWORD[72+rdi] + adcx r10,QWORD[80+rdi] + adcx r11,QWORD[88+rdi] + adc r12,QWORD[96+rdi] + adc r13,QWORD[104+rdi] + adc r14,QWORD[112+rdi] + adc r15,QWORD[120+rdi] + lea rbp,[rsi] + lea rdi,[128+rdi] + sbb rax,rax + + mov rdx,QWORD[((-64))+rsi] + mov QWORD[((16+8))+rsp],rax + mov QWORD[((24+8))+rsp],rdi + + + xor eax,eax + jmp NEAR $L$sqrx8x_loop + +ALIGN 32 +$L$sqrx8x_loop: + mov rbx,r8 + mulx r8,rax,QWORD[rbp] + adcx rbx,rax + adox r8,r9 + + mulx r9,rax,QWORD[8+rbp] + adcx r8,rax + adox r9,r10 + + mulx r10,rax,QWORD[16+rbp] + adcx r9,rax + adox r10,r11 + + mulx r11,rax,QWORD[24+rbp] + adcx r10,rax + adox r11,r12 + + DB 0xc4,0x62,0xfb,0xf6,0xa5,0x20,0x00,0x00,0x00 + adcx r11,rax + adox r12,r13 + + mulx r13,rax,QWORD[40+rbp] + adcx r12,rax + adox r13,r14 + + mulx r14,rax,QWORD[48+rbp] + mov QWORD[rcx*8+rdi],rbx + mov ebx,0 + adcx r13,rax + adox r14,r15 + + DB 0xc4,0x62,0xfb,0xf6,0xbd,0x38,0x00,0x00,0x00 + mov rdx,QWORD[8+rcx*8+rsi] + adcx r14,rax + adox r15,rbx + adcx r15,rbx + + DB 0x67 + inc rcx + jnz NEAR $L$sqrx8x_loop + + lea rbp,[64+rbp] + mov rcx,-8 + cmp rbp,QWORD[((8+8))+rsp] + je NEAR $L$sqrx8x_break + + sub rbx,QWORD[((16+8))+rsp] + DB 0x66 + mov rdx,QWORD[((-64))+rsi] + adcx r8,QWORD[rdi] + adcx r9,QWORD[8+rdi] + adc r10,QWORD[16+rdi] + adc r11,QWORD[24+rdi] + adc r12,QWORD[32+rdi] + adc r13,QWORD[40+rdi] + adc r14,QWORD[48+rdi] + adc r15,QWORD[56+rdi] + lea rdi,[64+rdi] + DB 0x67 + sbb rax,rax + xor ebx,ebx + mov QWORD[((16+8))+rsp],rax + jmp NEAR $L$sqrx8x_loop + +ALIGN 32 +$L$sqrx8x_break: + xor rbp,rbp + sub rbx,QWORD[((16+8))+rsp] + adcx r8,rbp + mov rcx,QWORD[((24+8))+rsp] + adcx r9,rbp + mov rdx,QWORD[rsi] + adc r10,0 + mov QWORD[rdi],r8 + adc r11,0 + adc r12,0 + adc r13,0 + adc r14,0 + adc r15,0 + cmp rdi,rcx + je NEAR $L$sqrx8x_outer_loop + + mov QWORD[8+rdi],r9 + mov r9,QWORD[8+rcx] + mov QWORD[16+rdi],r10 + mov r10,QWORD[16+rcx] + mov QWORD[24+rdi],r11 + mov r11,QWORD[24+rcx] + mov QWORD[32+rdi],r12 + mov r12,QWORD[32+rcx] + mov QWORD[40+rdi],r13 + mov r13,QWORD[40+rcx] + mov QWORD[48+rdi],r14 + mov r14,QWORD[48+rcx] + mov QWORD[56+rdi],r15 + mov r15,QWORD[56+rcx] + mov rdi,rcx + jmp NEAR $L$sqrx8x_outer_loop + +ALIGN 32 +$L$sqrx8x_outer_break: + mov QWORD[72+rdi],r9 +DB 102,72,15,126,217 + mov QWORD[80+rdi],r10 + mov QWORD[88+rdi],r11 + mov QWORD[96+rdi],r12 + mov QWORD[104+rdi],r13 + mov QWORD[112+rdi],r14 + lea rdi,[((48+8))+rsp] + mov rdx,QWORD[rcx*1+rsi] + + mov r11,QWORD[8+rdi] + xor r10,r10 + mov r9,QWORD[((0+8))+rsp] + adox r11,r11 + mov r12,QWORD[16+rdi] + mov r13,QWORD[24+rdi] + + +ALIGN 32 +$L$sqrx4x_shift_n_add: + mulx rbx,rax,rdx + adox r12,r12 + adcx rax,r10 + DB 0x48,0x8b,0x94,0x0e,0x08,0x00,0x00,0x00 + DB 0x4c,0x8b,0x97,0x20,0x00,0x00,0x00 + adox r13,r13 + adcx rbx,r11 + mov r11,QWORD[40+rdi] + mov QWORD[rdi],rax + mov QWORD[8+rdi],rbx + + mulx rbx,rax,rdx + adox r10,r10 + adcx rax,r12 + mov rdx,QWORD[16+rcx*1+rsi] + mov r12,QWORD[48+rdi] + adox r11,r11 + adcx rbx,r13 + mov r13,QWORD[56+rdi] + mov QWORD[16+rdi],rax + mov QWORD[24+rdi],rbx + + mulx rbx,rax,rdx + adox r12,r12 + adcx rax,r10 + mov rdx,QWORD[24+rcx*1+rsi] + lea rcx,[32+rcx] + mov r10,QWORD[64+rdi] + adox r13,r13 + adcx rbx,r11 + mov r11,QWORD[72+rdi] + mov QWORD[32+rdi],rax + mov QWORD[40+rdi],rbx + + mulx rbx,rax,rdx + adox r10,r10 + adcx rax,r12 + jrcxz $L$sqrx4x_shift_n_add_break + DB 0x48,0x8b,0x94,0x0e,0x00,0x00,0x00,0x00 + adox r11,r11 + adcx rbx,r13 + mov r12,QWORD[80+rdi] + mov r13,QWORD[88+rdi] + mov QWORD[48+rdi],rax + mov QWORD[56+rdi],rbx + lea rdi,[64+rdi] + nop + jmp NEAR $L$sqrx4x_shift_n_add + +ALIGN 32 +$L$sqrx4x_shift_n_add_break: + adcx rbx,r13 + mov QWORD[48+rdi],rax + mov QWORD[56+rdi],rbx + lea rdi,[64+rdi] +DB 102,72,15,126,213 +__bn_sqrx8x_reduction: + xor eax,eax + mov rbx,QWORD[((32+8))+rsp] + mov rdx,QWORD[((48+8))+rsp] + lea rcx,[((-64))+r9*1+rbp] + + mov QWORD[((0+8))+rsp],rcx + mov QWORD[((8+8))+rsp],rdi + + lea rdi,[((48+8))+rsp] + jmp NEAR $L$sqrx8x_reduction_loop + +ALIGN 32 +$L$sqrx8x_reduction_loop: + mov r9,QWORD[8+rdi] + mov r10,QWORD[16+rdi] + mov r11,QWORD[24+rdi] + mov r12,QWORD[32+rdi] + mov r8,rdx + imul rdx,rbx + mov r13,QWORD[40+rdi] + mov r14,QWORD[48+rdi] + mov r15,QWORD[56+rdi] + mov QWORD[((24+8))+rsp],rax + + lea rdi,[64+rdi] + xor rsi,rsi + mov rcx,-8 + jmp NEAR $L$sqrx8x_reduce + +ALIGN 32 +$L$sqrx8x_reduce: + mov rbx,r8 + mulx r8,rax,QWORD[rbp] + adcx rax,rbx + adox r8,r9 + + mulx r9,rbx,QWORD[8+rbp] + adcx r8,rbx + adox r9,r10 + + mulx r10,rbx,QWORD[16+rbp] + adcx r9,rbx + adox r10,r11 + + mulx r11,rbx,QWORD[24+rbp] + adcx r10,rbx + adox r11,r12 + + DB 0xc4,0x62,0xe3,0xf6,0xa5,0x20,0x00,0x00,0x00 + mov rax,rdx + mov rdx,r8 + adcx r11,rbx + adox r12,r13 + + mulx rdx,rbx,QWORD[((32+8))+rsp] + mov rdx,rax + mov QWORD[((64+48+8))+rcx*8+rsp],rax + + mulx r13,rax,QWORD[40+rbp] + adcx r12,rax + adox r13,r14 + + mulx r14,rax,QWORD[48+rbp] + adcx r13,rax + adox r14,r15 + + mulx r15,rax,QWORD[56+rbp] + mov rdx,rbx + adcx r14,rax + adox r15,rsi + adcx r15,rsi + + DB 0x67,0x67,0x67 + inc rcx + jnz NEAR $L$sqrx8x_reduce + + mov rax,rsi + cmp rbp,QWORD[((0+8))+rsp] + jae NEAR $L$sqrx8x_no_tail + + mov rdx,QWORD[((48+8))+rsp] + add r8,QWORD[rdi] + lea rbp,[64+rbp] + mov rcx,-8 + adcx r9,QWORD[8+rdi] + adcx r10,QWORD[16+rdi] + adc r11,QWORD[24+rdi] + adc r12,QWORD[32+rdi] + adc r13,QWORD[40+rdi] + adc r14,QWORD[48+rdi] + adc r15,QWORD[56+rdi] + lea rdi,[64+rdi] + sbb rax,rax + + xor rsi,rsi + mov QWORD[((16+8))+rsp],rax + jmp NEAR $L$sqrx8x_tail + +ALIGN 32 +$L$sqrx8x_tail: + mov rbx,r8 + mulx r8,rax,QWORD[rbp] + adcx rbx,rax + adox r8,r9 + + mulx r9,rax,QWORD[8+rbp] + adcx r8,rax + adox r9,r10 + + mulx r10,rax,QWORD[16+rbp] + adcx r9,rax + adox r10,r11 + + mulx r11,rax,QWORD[24+rbp] + adcx r10,rax + adox r11,r12 + + DB 0xc4,0x62,0xfb,0xf6,0xa5,0x20,0x00,0x00,0x00 + adcx r11,rax + adox r12,r13 + + mulx r13,rax,QWORD[40+rbp] + adcx r12,rax + adox r13,r14 + + mulx r14,rax,QWORD[48+rbp] + adcx r13,rax + adox r14,r15 + + mulx r15,rax,QWORD[56+rbp] + mov rdx,QWORD[((72+48+8))+rcx*8+rsp] + adcx r14,rax + adox r15,rsi + mov QWORD[rcx*8+rdi],rbx + mov rbx,r8 + adcx r15,rsi + + inc rcx + jnz NEAR $L$sqrx8x_tail + + cmp rbp,QWORD[((0+8))+rsp] + jae NEAR $L$sqrx8x_tail_done + + sub rsi,QWORD[((16+8))+rsp] + mov rdx,QWORD[((48+8))+rsp] + lea rbp,[64+rbp] + adc r8,QWORD[rdi] + adc r9,QWORD[8+rdi] + adc r10,QWORD[16+rdi] + adc r11,QWORD[24+rdi] + adc r12,QWORD[32+rdi] + adc r13,QWORD[40+rdi] + adc r14,QWORD[48+rdi] + adc r15,QWORD[56+rdi] + lea rdi,[64+rdi] + sbb rax,rax + sub rcx,8 + + xor rsi,rsi + mov QWORD[((16+8))+rsp],rax + jmp NEAR $L$sqrx8x_tail + +ALIGN 32 +$L$sqrx8x_tail_done: + xor rax,rax + add r8,QWORD[((24+8))+rsp] + adc r9,0 + adc r10,0 + adc r11,0 + adc r12,0 + adc r13,0 + adc r14,0 + adc r15,0 + adc rax,0 + + sub rsi,QWORD[((16+8))+rsp] +$L$sqrx8x_no_tail: + adc r8,QWORD[rdi] +DB 102,72,15,126,217 + adc r9,QWORD[8+rdi] + mov rsi,QWORD[56+rbp] +DB 102,72,15,126,213 + adc r10,QWORD[16+rdi] + adc r11,QWORD[24+rdi] + adc r12,QWORD[32+rdi] + adc r13,QWORD[40+rdi] + adc r14,QWORD[48+rdi] + adc r15,QWORD[56+rdi] + adc rax,0 + + mov rbx,QWORD[((32+8))+rsp] + mov rdx,QWORD[64+rcx*1+rdi] + + mov QWORD[rdi],r8 + lea r8,[64+rdi] + mov QWORD[8+rdi],r9 + mov QWORD[16+rdi],r10 + mov QWORD[24+rdi],r11 + mov QWORD[32+rdi],r12 + mov QWORD[40+rdi],r13 + mov QWORD[48+rdi],r14 + mov QWORD[56+rdi],r15 + + lea rdi,[64+rcx*1+rdi] + cmp r8,QWORD[((8+8))+rsp] + jb NEAR $L$sqrx8x_reduction_loop + ret + + +ALIGN 32 + +__bn_postx4x_internal: + + mov r12,QWORD[rbp] + mov r10,rcx + mov r9,rcx + neg rax + sar rcx,3+2 + +DB 102,72,15,126,202 +DB 102,72,15,126,206 + dec r12 + mov r13,QWORD[8+rbp] + xor r8,r8 + mov r14,QWORD[16+rbp] + mov r15,QWORD[24+rbp] + jmp NEAR $L$sqrx4x_sub_entry + +ALIGN 16 +$L$sqrx4x_sub: + mov r12,QWORD[rbp] + mov r13,QWORD[8+rbp] + mov r14,QWORD[16+rbp] + mov r15,QWORD[24+rbp] +$L$sqrx4x_sub_entry: + andn r12,r12,rax + lea rbp,[32+rbp] + andn r13,r13,rax + andn r14,r14,rax + andn r15,r15,rax + + neg r8 + adc r12,QWORD[rdi] + adc r13,QWORD[8+rdi] + adc r14,QWORD[16+rdi] + adc r15,QWORD[24+rdi] + mov QWORD[rdx],r12 + lea rdi,[32+rdi] + mov QWORD[8+rdx],r13 + sbb r8,r8 + mov QWORD[16+rdx],r14 + mov QWORD[24+rdx],r15 + lea rdx,[32+rdx] + + inc rcx + jnz NEAR $L$sqrx4x_sub + + neg r9 + + ret + + +global bn_scatter5 + +ALIGN 16 +bn_scatter5: + +_CET_ENDBR + cmp edx,0 + jz NEAR $L$scatter_epilogue + + + + + + + + + + lea r8,[r9*8+r8] +$L$scatter: + mov rax,QWORD[rcx] + lea rcx,[8+rcx] + mov QWORD[r8],rax + lea r8,[256+r8] + sub edx,1 + jnz NEAR $L$scatter +$L$scatter_epilogue: + ret + + + +global bn_gather5 + +ALIGN 32 +bn_gather5: + +$L$SEH_begin_bn_gather5: +_CET_ENDBR + + DB 0x4c,0x8d,0x14,0x24 + + DB 0x48,0x81,0xec,0x08,0x01,0x00,0x00 + lea rax,[$L$inc] + and rsp,-16 + + movd xmm5,r9d + movdqa xmm0,XMMWORD[rax] + movdqa xmm1,XMMWORD[16+rax] + lea r11,[128+r8] + lea rax,[128+rsp] + + pshufd xmm5,xmm5,0 + movdqa xmm4,xmm1 + movdqa xmm2,xmm1 + paddd xmm1,xmm0 + pcmpeqd xmm0,xmm5 + movdqa xmm3,xmm4 + + paddd xmm2,xmm1 + pcmpeqd xmm1,xmm5 + movdqa XMMWORD[(-128)+rax],xmm0 + movdqa xmm0,xmm4 + + paddd xmm3,xmm2 + pcmpeqd xmm2,xmm5 + movdqa XMMWORD[(-112)+rax],xmm1 + movdqa xmm1,xmm4 + + paddd xmm0,xmm3 + pcmpeqd xmm3,xmm5 + movdqa XMMWORD[(-96)+rax],xmm2 + movdqa xmm2,xmm4 + paddd xmm1,xmm0 + pcmpeqd xmm0,xmm5 + movdqa XMMWORD[(-80)+rax],xmm3 + movdqa xmm3,xmm4 + + paddd xmm2,xmm1 + pcmpeqd xmm1,xmm5 + movdqa XMMWORD[(-64)+rax],xmm0 + movdqa xmm0,xmm4 + + paddd xmm3,xmm2 + pcmpeqd xmm2,xmm5 + movdqa XMMWORD[(-48)+rax],xmm1 + movdqa xmm1,xmm4 + + paddd xmm0,xmm3 + pcmpeqd xmm3,xmm5 + movdqa XMMWORD[(-32)+rax],xmm2 + movdqa xmm2,xmm4 + paddd xmm1,xmm0 + pcmpeqd xmm0,xmm5 + movdqa XMMWORD[(-16)+rax],xmm3 + movdqa xmm3,xmm4 + + paddd xmm2,xmm1 + pcmpeqd xmm1,xmm5 + movdqa XMMWORD[rax],xmm0 + movdqa xmm0,xmm4 + + paddd xmm3,xmm2 + pcmpeqd xmm2,xmm5 + movdqa XMMWORD[16+rax],xmm1 + movdqa xmm1,xmm4 + + paddd xmm0,xmm3 + pcmpeqd xmm3,xmm5 + movdqa XMMWORD[32+rax],xmm2 + movdqa xmm2,xmm4 + paddd xmm1,xmm0 + pcmpeqd xmm0,xmm5 + movdqa XMMWORD[48+rax],xmm3 + movdqa xmm3,xmm4 + + paddd xmm2,xmm1 + pcmpeqd xmm1,xmm5 + movdqa XMMWORD[64+rax],xmm0 + movdqa xmm0,xmm4 + + paddd xmm3,xmm2 + pcmpeqd xmm2,xmm5 + movdqa XMMWORD[80+rax],xmm1 + movdqa xmm1,xmm4 + + paddd xmm0,xmm3 + pcmpeqd xmm3,xmm5 + movdqa XMMWORD[96+rax],xmm2 + movdqa xmm2,xmm4 + movdqa XMMWORD[112+rax],xmm3 + jmp NEAR $L$gather + +ALIGN 32 +$L$gather: + pxor xmm4,xmm4 + pxor xmm5,xmm5 + movdqa xmm0,XMMWORD[((-128))+r11] + movdqa xmm1,XMMWORD[((-112))+r11] + movdqa xmm2,XMMWORD[((-96))+r11] + pand xmm0,XMMWORD[((-128))+rax] + movdqa xmm3,XMMWORD[((-80))+r11] + pand xmm1,XMMWORD[((-112))+rax] + por xmm4,xmm0 + pand xmm2,XMMWORD[((-96))+rax] + por xmm5,xmm1 + pand xmm3,XMMWORD[((-80))+rax] + por xmm4,xmm2 + por xmm5,xmm3 + movdqa xmm0,XMMWORD[((-64))+r11] + movdqa xmm1,XMMWORD[((-48))+r11] + movdqa xmm2,XMMWORD[((-32))+r11] + pand xmm0,XMMWORD[((-64))+rax] + movdqa xmm3,XMMWORD[((-16))+r11] + pand xmm1,XMMWORD[((-48))+rax] + por xmm4,xmm0 + pand xmm2,XMMWORD[((-32))+rax] + por xmm5,xmm1 + pand xmm3,XMMWORD[((-16))+rax] + por xmm4,xmm2 + por xmm5,xmm3 + movdqa xmm0,XMMWORD[r11] + movdqa xmm1,XMMWORD[16+r11] + movdqa xmm2,XMMWORD[32+r11] + pand xmm0,XMMWORD[rax] + movdqa xmm3,XMMWORD[48+r11] + pand xmm1,XMMWORD[16+rax] + por xmm4,xmm0 + pand xmm2,XMMWORD[32+rax] + por xmm5,xmm1 + pand xmm3,XMMWORD[48+rax] + por xmm4,xmm2 + por xmm5,xmm3 + movdqa xmm0,XMMWORD[64+r11] + movdqa xmm1,XMMWORD[80+r11] + movdqa xmm2,XMMWORD[96+r11] + pand xmm0,XMMWORD[64+rax] + movdqa xmm3,XMMWORD[112+r11] + pand xmm1,XMMWORD[80+rax] + por xmm4,xmm0 + pand xmm2,XMMWORD[96+rax] + por xmm5,xmm1 + pand xmm3,XMMWORD[112+rax] + por xmm4,xmm2 + por xmm5,xmm3 + por xmm4,xmm5 + lea r11,[256+r11] + + pshufd xmm0,xmm4,0x4e + por xmm0,xmm4 + movq QWORD[rcx],xmm0 + lea rcx,[8+rcx] + sub edx,1 + jnz NEAR $L$gather + + lea rsp,[r10] + + ret +$L$SEH_end_bn_gather5: + + +section .rdata rdata align=8 +ALIGN 64 +$L$inc: + DD 0,0,1,1 + DD 2,2,2,2 + DB 77,111,110,116,103,111,109,101,114,121,32,77,117,108,116,105 + DB 112,108,105,99,97,116,105,111,110,32,119,105,116,104,32,115 + DB 99,97,116,116,101,114,47,103,97,116,104,101,114,32,102,111 + DB 114,32,120,56,54,95,54,52,44,32,67,82,89,80,84,79 + DB 71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111 + DB 112,101,110,115,115,108,46,111,114,103,62,0 +section .text + +EXTERN __imp_RtlVirtualUnwind + +ALIGN 16 +mul_handler: + push rsi + push rdi + push rbx + push rbp + push r12 + push r13 + push r14 + push r15 + pushfq + sub rsp,64 + + mov rax,QWORD[120+r8] + mov rbx,QWORD[248+r8] + + mov rsi,QWORD[8+r9] + mov r11,QWORD[56+r9] + + mov r10d,DWORD[r11] + lea r10,[r10*1+rsi] + cmp rbx,r10 + jb NEAR $L$common_seh_tail + + mov r10d,DWORD[4+r11] + lea r10,[r10*1+rsi] + cmp rbx,r10 + jb NEAR $L$common_pop_regs + + mov rax,QWORD[152+r8] + + mov r10d,DWORD[8+r11] + lea r10,[r10*1+rsi] + cmp rbx,r10 + jae NEAR $L$common_seh_tail + + lea r10,[$L$mul4x_epilogue] + cmp rbx,r10 + ja NEAR $L$body_40 + + mov r10,QWORD[192+r8] + mov rax,QWORD[8+r10*8+rax] + + jmp NEAR $L$common_pop_regs + +$L$body_40: + mov rax,QWORD[40+rax] +$L$common_pop_regs: + mov rbx,QWORD[((-8))+rax] + mov rbp,QWORD[((-16))+rax] + mov r12,QWORD[((-24))+rax] + mov r13,QWORD[((-32))+rax] + mov r14,QWORD[((-40))+rax] + mov r15,QWORD[((-48))+rax] + mov QWORD[144+r8],rbx + mov QWORD[160+r8],rbp + mov QWORD[216+r8],r12 + mov QWORD[224+r8],r13 + mov QWORD[232+r8],r14 + mov QWORD[240+r8],r15 + +$L$common_seh_tail: + mov rdi,QWORD[8+rax] + mov rsi,QWORD[16+rax] + mov QWORD[152+r8],rax + mov QWORD[168+r8],rsi + mov QWORD[176+r8],rdi + + mov rdi,QWORD[40+r9] + mov rsi,r8 + mov ecx,154 + DD 0xa548f3fc + + mov rsi,r9 + xor rcx,rcx + mov rdx,QWORD[8+rsi] + mov r8,QWORD[rsi] + mov r9,QWORD[16+rsi] + mov r10,QWORD[40+rsi] + lea r11,[56+rsi] + lea r12,[24+rsi] + mov QWORD[32+rsp],r10 + mov QWORD[40+rsp],r11 + mov QWORD[48+rsp],r12 + mov QWORD[56+rsp],rcx + call QWORD[__imp_RtlVirtualUnwind] + + mov eax,1 + add rsp,64 + popfq + pop r15 + pop r14 + pop r13 + pop r12 + pop rbp + pop rbx + pop rdi + pop rsi + ret + + +section .pdata rdata align=4 +ALIGN 4 + DD $L$SEH_begin_bn_mul4x_mont_gather5 wrt ..imagebase + DD $L$SEH_end_bn_mul4x_mont_gather5 wrt ..imagebase + DD $L$SEH_info_bn_mul4x_mont_gather5 wrt ..imagebase + + DD $L$SEH_begin_bn_power5_nohw wrt ..imagebase + DD $L$SEH_end_bn_power5_nohw wrt ..imagebase + DD $L$SEH_info_bn_power5_nohw wrt ..imagebase + DD $L$SEH_begin_bn_mulx4x_mont_gather5 wrt ..imagebase + DD $L$SEH_end_bn_mulx4x_mont_gather5 wrt ..imagebase + DD $L$SEH_info_bn_mulx4x_mont_gather5 wrt ..imagebase + + DD $L$SEH_begin_bn_powerx5 wrt ..imagebase + DD $L$SEH_end_bn_powerx5 wrt ..imagebase + DD $L$SEH_info_bn_powerx5 wrt ..imagebase + DD $L$SEH_begin_bn_gather5 wrt ..imagebase + DD $L$SEH_end_bn_gather5 wrt ..imagebase + DD $L$SEH_info_bn_gather5 wrt ..imagebase + +section .xdata rdata align=8 +ALIGN 8 +$L$SEH_info_bn_mul4x_mont_gather5: + DB 9,0,0,0 + DD mul_handler wrt ..imagebase + DD $L$mul4x_prologue wrt ..imagebase,$L$mul4x_body wrt ..imagebase,$L$mul4x_epilogue wrt ..imagebase +ALIGN 8 +$L$SEH_info_bn_power5_nohw: + DB 9,0,0,0 + DD mul_handler wrt ..imagebase + DD $L$power5_prologue wrt ..imagebase,$L$power5_body wrt ..imagebase,$L$power5_epilogue wrt ..imagebase +ALIGN 8 +$L$SEH_info_bn_mulx4x_mont_gather5: + DB 9,0,0,0 + DD mul_handler wrt ..imagebase + DD $L$mulx4x_prologue wrt ..imagebase,$L$mulx4x_body wrt ..imagebase,$L$mulx4x_epilogue wrt ..imagebase +ALIGN 8 +$L$SEH_info_bn_powerx5: + DB 9,0,0,0 + DD mul_handler wrt ..imagebase + DD $L$powerx5_prologue wrt ..imagebase,$L$powerx5_body wrt ..imagebase,$L$powerx5_epilogue wrt ..imagebase +ALIGN 8 +$L$SEH_info_bn_gather5: + DB 0x01,0x0b,0x03,0x0a + DB 0x0b,0x01,0x21,0x00 + DB 0x04,0xa3,0x00,0x00 +ALIGN 8 +%else +; Work around https://bugzilla.nasm.us/show_bug.cgi?id=3392738 +ret +%endif diff --git a/http/vendor/ring/pregenerated/x86_64-mont5-nasm.o b/http/vendor/ring/pregenerated/x86_64-mont5-nasm.o new file mode 100644 index 0000000..2d5a63e Binary files /dev/null and b/http/vendor/ring/pregenerated/x86_64-mont5-nasm.o differ diff --git a/http/vendor/ring/src/aead.rs b/http/vendor/ring/src/aead.rs new file mode 100644 index 0000000..16a8aba --- /dev/null +++ b/http/vendor/ring/src/aead.rs @@ -0,0 +1,186 @@ +// Copyright 2015-2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! Authenticated Encryption with Associated Data (AEAD). +//! +//! See [Authenticated encryption: relations among notions and analysis of the +//! generic composition paradigm][AEAD] for an introduction to the concept of +//! AEADs. +//! +//! [AEAD]: https://eprint.iacr.org/2000/025.pdf +//! [`crypto.cipher.AEAD`]: https://golang.org/pkg/crypto/cipher/#AEAD + +use crate::{ + cpu, error, + polyfill::{u64_from_usize, usize_from_u64_saturated}, +}; + +pub use self::{ + algorithm::{Algorithm, AES_128_GCM, AES_256_GCM, CHACHA20_POLY1305}, + less_safe_key::LessSafeKey, + nonce::{Nonce, NONCE_LEN}, + opening_key::OpeningKey, + sealing_key::SealingKey, + unbound_key::UnboundKey, +}; + +/// A sequences of unique nonces. +/// +/// A given `NonceSequence` must never return the same `Nonce` twice from +/// `advance()`. +/// +/// A simple counter is a reasonable (but probably not ideal) `NonceSequence`. +/// +/// Intentionally not `Clone` or `Copy` since cloning would allow duplication +/// of the sequence. +pub trait NonceSequence { + /// Returns the next nonce in the sequence. + /// + /// This may fail if "too many" nonces have been requested, where how many + /// is too many is up to the implementation of `NonceSequence`. An + /// implementation may that enforce a maximum number of records are + /// sent/received under a key this way. Once `advance()` fails, it must + /// fail for all subsequent calls. + fn advance(&mut self) -> Result; +} + +/// An AEAD key bound to a nonce sequence. +pub trait BoundKey: core::fmt::Debug { + /// Constructs a new key from the given `UnboundKey` and `NonceSequence`. + fn new(key: UnboundKey, nonce_sequence: N) -> Self; + + /// The key's AEAD algorithm. + fn algorithm(&self) -> &'static Algorithm; +} + +/// The additionally authenticated data (AAD) for an opening or sealing +/// operation. This data is authenticated but is **not** encrypted. +/// +/// The type `A` could be a byte slice `&[u8]`, a byte array `[u8; N]` +/// for some constant `N`, `Vec`, etc. +#[derive(Clone, Copy)] +pub struct Aad(A); + +impl> Aad { + /// Construct the `Aad` from the given bytes. + #[inline] + pub fn from(aad: A) -> Self { + Self(aad) + } +} + +impl AsRef<[u8]> for Aad +where + A: AsRef<[u8]>, +{ + fn as_ref(&self) -> &[u8] { + self.0.as_ref() + } +} + +impl Aad<[u8; 0]> { + /// Construct an empty `Aad`. + pub fn empty() -> Self { + Self::from([]) + } +} + +impl core::fmt::Debug for Aad +where + A: core::fmt::Debug, +{ + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.debug_tuple("Aad").field(&self.0).finish() + } +} + +impl PartialEq for Aad +where + A: PartialEq, +{ + #[inline] + fn eq(&self, other: &Self) -> bool { + self.0.eq(&other.0) + } +} + +impl Eq for Aad where A: Eq {} + +#[allow(clippy::large_enum_variant, variant_size_differences)] +#[derive(Clone)] +enum KeyInner { + AesGcm(aes_gcm::Key), + ChaCha20Poly1305(chacha20_poly1305::Key), +} + +const fn max_input_len(block_len: usize, overhead_blocks_per_nonce: usize) -> usize { + // Each of our AEADs use a 32-bit block counter so the maximum is the + // largest input that will not overflow the counter. + usize_from_u64_saturated( + ((1u64 << 32) - u64_from_usize(overhead_blocks_per_nonce)) * u64_from_usize(block_len), + ) +} + +/// A possibly valid authentication tag. +#[must_use] +#[repr(C)] +#[derive(Clone, Copy)] +pub struct Tag([u8; TAG_LEN]); + +impl AsRef<[u8]> for Tag { + fn as_ref(&self) -> &[u8] { + self.0.as_ref() + } +} + +impl TryFrom<&[u8]> for Tag { + type Error = error::Unspecified; + + fn try_from(value: &[u8]) -> Result { + let raw_tag: [u8; TAG_LEN] = value.try_into().map_err(|_| error::Unspecified)?; + Ok(Self::from(raw_tag)) + } +} + +impl From<[u8; TAG_LEN]> for Tag { + #[inline] + fn from(value: [u8; TAG_LEN]) -> Self { + Self(value) + } +} + +const MAX_KEY_LEN: usize = 32; + +// All the AEADs we support use 128-bit tags. +const TAG_LEN: usize = 16; + +/// The maximum length of a tag for the algorithms in this module. +pub const MAX_TAG_LEN: usize = TAG_LEN; + +mod aes; +mod aes_gcm; +mod algorithm; +mod chacha; +mod chacha20_poly1305; +pub mod chacha20_poly1305_openssh; +mod gcm; +mod less_safe_key; +mod nonce; +mod opening_key; +mod overlapping; +mod poly1305; +pub mod quic; +mod sealing_key; +mod shift; +mod unbound_key; diff --git a/http/vendor/ring/src/aead/aes.rs b/http/vendor/ring/src/aead/aes.rs new file mode 100644 index 0000000..d9832ae --- /dev/null +++ b/http/vendor/ring/src/aead/aes.rs @@ -0,0 +1,284 @@ +// Copyright 2018-2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::{nonce::Nonce, overlapping, quic::Sample, NONCE_LEN}; +use crate::{ + bb, + cpu::{self, GetFeature as _}, + error, + polyfill::unwrap_const, +}; +use cfg_if::cfg_if; +use core::num::NonZeroU32; + +pub(super) use ffi::Counter; + +#[macro_use] +mod ffi; + +mod bs; +pub(super) mod fallback; +pub(super) mod hw; +pub(super) mod vp; + +pub type Overlapping<'o> = overlapping::Overlapping<'o, u8>; +pub type OverlappingPartialBlock<'o> = overlapping::PartialBlock<'o, u8, BLOCK_LEN>; + +cfg_if! { + if #[cfg(any(all(target_arch = "aarch64", target_endian = "little"), target_arch = "x86_64"))] { + pub(super) use ffi::AES_KEY; + } else { + use ffi::AES_KEY; + } +} + +#[derive(Clone)] +pub(super) enum Key { + #[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + target_arch = "x86_64", + target_arch = "x86" + ))] + Hw(hw::Key), + + #[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little"), + target_arch = "x86", + target_arch = "x86_64" + ))] + Vp(vp::Key), + + Fallback(fallback::Key), +} + +impl Key { + #[inline] + pub fn new( + bytes: KeyBytes<'_>, + cpu_features: cpu::Features, + ) -> Result { + #[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + target_arch = "x86", + target_arch = "x86_64" + ))] + if let Some(hw_features) = cpu_features.get_feature() { + return Ok(Self::Hw(hw::Key::new( + bytes, + hw_features, + cpu_features.get_feature(), + )?)); + } + + #[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little"), + target_arch = "x86_64", + target_arch = "x86" + ))] + if let Some(vp_features) = cpu_features.get_feature() { + return Ok(Self::Vp(vp::Key::new(bytes, vp_features)?)); + } + + let _ = cpu_features; + + Ok(Self::Fallback(fallback::Key::new(bytes)?)) + } + + #[inline] + fn encrypt_block(&self, a: Block) -> Block { + match self { + #[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + target_arch = "x86_64", + target_arch = "x86" + ))] + Key::Hw(inner) => inner.encrypt_block(a), + + #[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little"), + target_arch = "x86", + target_arch = "x86_64" + ))] + Key::Vp(inner) => inner.encrypt_block(a), + + Key::Fallback(inner) => inner.encrypt_block(a), + } + } + + pub fn new_mask(&self, sample: Sample) -> [u8; 5] { + let [b0, b1, b2, b3, b4, ..] = self.encrypt_block(sample); + [b0, b1, b2, b3, b4] + } +} + +pub const AES_128_KEY_LEN: usize = 128 / 8; +pub const AES_256_KEY_LEN: usize = 256 / 8; + +pub enum KeyBytes<'a> { + AES_128(&'a [u8; AES_128_KEY_LEN]), + AES_256(&'a [u8; AES_256_KEY_LEN]), +} + +// `Counter` is `ffi::Counter` as its representation is dictated by its use in +// the FFI. +impl Counter { + pub fn one(nonce: Nonce) -> Self { + let mut value = [0u8; BLOCK_LEN]; + value[..NONCE_LEN].copy_from_slice(nonce.as_ref()); + value[BLOCK_LEN - 1] = 1; + Self(value) + } + + pub fn increment(&mut self) -> Iv { + const ONE: NonZeroU32 = unwrap_const(NonZeroU32::new(1)); + + let iv = Iv(self.0); + self.increment_by_less_safe(ONE); + iv + } + + pub(super) fn increment_by_less_safe(&mut self, increment_by: NonZeroU32) { + let [.., c0, c1, c2, c3] = &mut self.0; + let old_value: u32 = u32::from_be_bytes([*c0, *c1, *c2, *c3]); + let new_value = old_value.wrapping_add(increment_by.get()); + [*c0, *c1, *c2, *c3] = u32::to_be_bytes(new_value); + } +} + +/// The IV for a single block encryption. +/// +/// Intentionally not `Clone` to ensure each is used only once. +pub struct Iv(Block); + +impl From for Iv { + fn from(counter: Counter) -> Self { + Self(counter.0) + } +} + +pub(super) type Block = [u8; BLOCK_LEN]; +pub(super) const BLOCK_LEN: usize = 16; +pub(super) const ZERO_BLOCK: Block = [0u8; BLOCK_LEN]; + +pub(super) trait EncryptBlock { + fn encrypt_block(&self, block: Block) -> Block; + fn encrypt_iv_xor_block(&self, iv: Iv, block: Block) -> Block; +} + +pub(super) trait EncryptCtr32 { + fn ctr32_encrypt_within(&self, in_out: Overlapping<'_>, ctr: &mut Counter); +} + +#[allow(dead_code)] +fn encrypt_block_using_encrypt_iv_xor_block(key: &impl EncryptBlock, block: Block) -> Block { + key.encrypt_iv_xor_block(Iv(block), ZERO_BLOCK) +} + +fn encrypt_iv_xor_block_using_encrypt_block( + key: &impl EncryptBlock, + iv: Iv, + block: Block, +) -> Block { + let encrypted_iv = key.encrypt_block(iv.0); + bb::xor_16(encrypted_iv, block) +} + +#[allow(dead_code)] +fn encrypt_iv_xor_block_using_ctr32(key: &impl EncryptCtr32, iv: Iv, mut block: Block) -> Block { + let mut ctr = Counter(iv.0); // This is OK because we're only encrypting one block. + key.ctr32_encrypt_within(block.as_mut().into(), &mut ctr); + block +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::testutil as test; + + #[test] + pub fn test_aes() { + test::run(test_vector_file!("aes_tests.txt"), |section, test_case| { + assert_eq!(section, ""); + let key = consume_key(test_case, "Key"); + let input = test_case.consume_bytes("Input"); + let block: Block = input.as_slice().try_into()?; + let expected_output = test_case.consume_bytes("Output"); + + let output = key.encrypt_block(block); + assert_eq!(output.as_ref(), &expected_output[..]); + + Ok(()) + }) + } + + fn consume_key(test_case: &mut test::TestCase, name: &str) -> Key { + let key = test_case.consume_bytes(name); + let key = &key[..]; + let key = match key.len() { + 16 => KeyBytes::AES_128(key.try_into().unwrap()), + 32 => KeyBytes::AES_256(key.try_into().unwrap()), + _ => unreachable!(), + }; + Key::new(key, cpu::features()).unwrap() + } +} + +// These AES-GCM-specific tests are here instead of in `aes_gcm` because +// `Counter`'s API isn't visible (enough) to aes_gcm. +#[cfg(test)] +mod aes_gcm_tests { + use super::{super::aes_gcm::MAX_IN_OUT_LEN, *}; + use core::num::NonZeroU32; + + #[test] + fn test_aes_gcm_counter_blocks_max() { + test_aes_gcm_counter_blocks(MAX_IN_OUT_LEN, &[0, 0, 0, 0]); + } + + #[test] + fn test_aes_gcm_counter_blocks_max_minus_one() { + test_aes_gcm_counter_blocks(MAX_IN_OUT_LEN - BLOCK_LEN, &[0xff, 0xff, 0xff, 0xff]); + } + + fn test_aes_gcm_counter_blocks(in_out_len: usize, expected_final_counter: &[u8; 4]) { + fn ctr32(ctr: &Counter) -> &[u8; 4] { + (&ctr.0[12..]).try_into().unwrap() + } + + let rounded_down = in_out_len / BLOCK_LEN; + let blocks = rounded_down + (if in_out_len % BLOCK_LEN == 0 { 0 } else { 1 }); + let blocks = u32::try_from(blocks) + .ok() + .and_then(NonZeroU32::new) + .unwrap(); + + let nonce = Nonce::assume_unique_for_key([1; 12]); + let mut ctr = Counter::one(nonce); + assert_eq!(ctr32(&ctr), &[0, 0, 0, 1]); + let _tag_iv = ctr.increment(); + assert_eq!(ctr32(&ctr), &[0, 0, 0, 2]); + ctr.increment_by_less_safe(blocks); + + // `MAX_IN_OUT_LEN` is less on 32-bit targets, so we don't even get + // close to wrapping, but run the tests on them anyway. + #[cfg(target_pointer_width = "64")] + assert_eq!(ctr32(&ctr), expected_final_counter); + + #[cfg(target_pointer_width = "32")] + let _ = expected_final_counter; + } +} diff --git a/http/vendor/ring/src/aead/aes/bs.rs b/http/vendor/ring/src/aead/aes/bs.rs new file mode 100644 index 0000000..2e418bb --- /dev/null +++ b/http/vendor/ring/src/aead/aes/bs.rs @@ -0,0 +1,60 @@ +// Copyright 2018-2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#![cfg(all(target_arch = "arm", target_endian = "little"))] + +use super::{Counter, Overlapping, AES_KEY}; + +/// SAFETY: +/// * The caller must ensure that if blocks > 0 then either `input` and +/// `output` do not overlap at all, or input == output.add(n) for some +/// (nonnegative) n. +/// * if blocks > 0, The caller must ensure `input` points to `blocks` blocks +/// and that `output` points to writable space for `blocks` blocks. +/// * The caller must ensure that `vpaes_key` was initialized with +/// `vpaes_set_encrypt_key`. +/// * Upon returning, `blocks` blocks will have been read from `input` and +/// written to `output`. +pub(super) unsafe fn ctr32_encrypt_blocks_with_vpaes_key( + in_out: Overlapping<'_>, + vpaes_key: &AES_KEY, + ctr: &mut Counter, +) { + prefixed_extern! { + // bsaes_ctr32_encrypt_blocks requires transformation of an existing + // VPAES key; there is no `bsaes_set_encrypt_key`. + fn vpaes_encrypt_key_to_bsaes(bsaes_key: *mut AES_KEY, vpaes_key: &AES_KEY); + } + + // SAFETY: + // * The caller ensures `vpaes_key` was initialized by + // `vpaes_set_encrypt_key`. + // * `bsaes_key was zeroed above, and `vpaes_encrypt_key_to_bsaes` + // is assumed to initialize `bsaes_key`. + let bsaes_key = unsafe { AES_KEY::derive(vpaes_encrypt_key_to_bsaes, vpaes_key) }; + + // The code for `vpaes_encrypt_key_to_bsaes` notes "vpaes stores one + // fewer round count than bsaes, but the number of keys is the same," + // so use this as a sanity check. + debug_assert_eq!(bsaes_key.rounds(), vpaes_key.rounds() + 1); + + // SAFETY: + // * `bsaes_key` is in bsaes format after calling + // `vpaes_encrypt_key_to_bsaes`. + // * `bsaes_ctr32_encrypt_blocks` satisfies the contract for + // `ctr32_encrypt_blocks`. + unsafe { + ctr32_encrypt_blocks!(bsaes_ctr32_encrypt_blocks, in_out, &bsaes_key, ctr); + } +} diff --git a/http/vendor/ring/src/aead/aes/fallback.rs b/http/vendor/ring/src/aead/aes/fallback.rs new file mode 100644 index 0000000..40dee0d --- /dev/null +++ b/http/vendor/ring/src/aead/aes/fallback.rs @@ -0,0 +1,44 @@ +// Copyright 2018-2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::{Block, Counter, EncryptBlock, EncryptCtr32, Iv, KeyBytes, Overlapping, AES_KEY}; +use crate::error; + +#[derive(Clone)] +pub struct Key { + inner: AES_KEY, +} + +impl Key { + pub(in super::super) fn new(bytes: KeyBytes<'_>) -> Result { + let inner = unsafe { set_encrypt_key!(aes_nohw_set_encrypt_key, bytes) }?; + Ok(Self { inner }) + } +} + +impl EncryptBlock for Key { + fn encrypt_block(&self, block: Block) -> Block { + unsafe { encrypt_block!(aes_nohw_encrypt, block, &self.inner) } + } + + fn encrypt_iv_xor_block(&self, iv: Iv, block: Block) -> Block { + super::encrypt_iv_xor_block_using_encrypt_block(self, iv, block) + } +} + +impl EncryptCtr32 for Key { + fn ctr32_encrypt_within(&self, in_out: Overlapping<'_>, ctr: &mut Counter) { + unsafe { ctr32_encrypt_blocks!(aes_nohw_ctr32_encrypt_blocks, in_out, &self.inner, ctr) } + } +} diff --git a/http/vendor/ring/src/aead/aes/ffi.rs b/http/vendor/ring/src/aead/aes/ffi.rs new file mode 100644 index 0000000..c2286e1 --- /dev/null +++ b/http/vendor/ring/src/aead/aes/ffi.rs @@ -0,0 +1,206 @@ +// Copyright 2018-2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::{Block, KeyBytes, Overlapping, BLOCK_LEN}; +use crate::{bits::BitLength, c, error}; +use core::{ + ffi::{c_int, c_uint}, + num::{NonZeroU32, NonZeroUsize}, +}; + +/// nonce || big-endian counter. +#[repr(transparent)] +pub(in super::super) struct Counter(pub(super) [u8; BLOCK_LEN]); + +// Keep this in sync with AES_KEY in aes.h. +#[repr(C)] +#[derive(Clone)] +pub(in super::super) struct AES_KEY { + pub rd_key: [u32; 4 * (MAX_ROUNDS + 1)], + pub rounds: c_uint, +} + +// Keep this in sync with `AES_MAXNR` in aes.h. +const MAX_ROUNDS: usize = 14; + +impl AES_KEY { + #[inline] + pub(super) unsafe fn new( + f: unsafe extern "C" fn(*const u8, BitLength, *mut AES_KEY) -> c_int, + bytes: KeyBytes<'_>, + ) -> Result { + let mut key = Self { + rd_key: [0; 4 * (MAX_ROUNDS + 1)], + rounds: 0, + }; + + let (bytes, key_bits) = match bytes { + KeyBytes::AES_128(bytes) => (&bytes[..], BitLength::from_bits(128)), + KeyBytes::AES_256(bytes) => (&bytes[..], BitLength::from_bits(256)), + }; + + // Unusually, in this case zero means success and non-zero means failure. + if 0 == unsafe { f(bytes.as_ptr(), key_bits, &mut key) } { + debug_assert_ne!(key.rounds, 0); // Sanity check initialization. + Ok(key) + } else { + Err(error::Unspecified) + } + } +} + +#[cfg(all(target_arch = "arm", target_endian = "little"))] +impl AES_KEY { + pub(super) unsafe fn derive( + f: for<'a> unsafe extern "C" fn(*mut AES_KEY, &'a AES_KEY), + src: &Self, + ) -> Self { + let mut r = AES_KEY { + rd_key: [0u32; 4 * (MAX_ROUNDS + 1)], + rounds: 0, + }; + unsafe { f(&mut r, src) }; + r + } + + pub(super) fn rounds(&self) -> u32 { + self.rounds + } +} + +// SAFETY: +// * The function `$name` must read `bits` bits from `user_key`; `bits` will +// always be a valid AES key length, i.e. a whole number of bytes. +// * `$name` must set `key.rounds` to the value expected by the corresponding +// encryption/decryption functions and return 0, or otherwise must return +// non-zero to indicate failure. +// * `$name` may inspect CPU features. +// +// In BoringSSL, the C prototypes for these are in +// crypto/fipsmodule/aes/internal.h. +macro_rules! set_encrypt_key { + ( $name:ident, $key_bytes:expr $(,)? ) => {{ + use crate::bits::BitLength; + use core::ffi::c_int; + prefixed_extern! { + fn $name(user_key: *const u8, bits: BitLength, key: *mut AES_KEY) -> c_int; + } + $crate::aead::aes::ffi::AES_KEY::new($name, $key_bytes) + }}; +} + +macro_rules! encrypt_block { + ($name:ident, $block:expr, $key:expr) => {{ + use crate::aead::aes::{ffi::AES_KEY, Block}; + prefixed_extern! { + fn $name(a: &Block, r: *mut Block, key: &AES_KEY); + } + $key.encrypt_block($name, $block) + }}; +} + +impl AES_KEY { + #[inline] + pub(super) unsafe fn encrypt_block( + &self, + f: unsafe extern "C" fn(&Block, *mut Block, &AES_KEY), + a: Block, + ) -> Block { + let mut result = core::mem::MaybeUninit::uninit(); + unsafe { + f(&a, result.as_mut_ptr(), self); + result.assume_init() + } + } +} + +/// SAFETY: +/// * The caller must ensure that `$key` was initialized with the +/// `set_encrypt_key!` invocation that `$name` requires. +/// * The caller must ensure that fhe function `$name` satisfies the conditions +/// for the `f` parameter to `ctr32_encrypt_blocks`. +macro_rules! ctr32_encrypt_blocks { + ($name:ident, $in_out:expr, $key:expr, $ctr:expr $(,)? ) => {{ + use crate::{ + aead::aes::{ffi::AES_KEY, Counter, BLOCK_LEN}, + c, + }; + prefixed_extern! { + fn $name( + input: *const [u8; BLOCK_LEN], + output: *mut [u8; BLOCK_LEN], + blocks: c::NonZero_size_t, + key: &AES_KEY, + ivec: &Counter, + ); + } + $key.ctr32_encrypt_blocks($name, $in_out, $ctr) + }}; +} + +impl AES_KEY { + /// SAFETY: + /// * `f` must not read more than `blocks` blocks from `input`. + /// * `f` must write exactly `block` blocks to `output`. + /// * In particular, `f` must handle blocks == 0 without reading from `input` + /// or writing to `output`. + /// * `f` must support the input overlapping with the output exactly or + /// with any nonnegative offset `n` (i.e. `input == output.add(n)`); + /// `f` does NOT need to support the cases where input < output. + /// * `key` must have been initialized with the `set_encrypt_key!` invocation + /// that corresponds to `f`. + /// * `f` may inspect CPU features. + #[inline] + pub(super) unsafe fn ctr32_encrypt_blocks( + &self, + f: unsafe extern "C" fn( + input: *const [u8; BLOCK_LEN], + output: *mut [u8; BLOCK_LEN], + blocks: c::NonZero_size_t, + key: &AES_KEY, + ivec: &Counter, + ), + in_out: Overlapping<'_>, + ctr: &mut Counter, + ) { + in_out.with_input_output_len(|input, output, len| { + debug_assert_eq!(len % BLOCK_LEN, 0); + + let blocks = match NonZeroUsize::new(len / BLOCK_LEN) { + Some(blocks) => blocks, + None => { + return; + } + }; + + let input: *const [u8; BLOCK_LEN] = input.cast(); + let output: *mut [u8; BLOCK_LEN] = output.cast(); + let blocks_u32: NonZeroU32 = blocks.try_into().unwrap(); + + // SAFETY: + // * `input` points to `blocks` blocks. + // * `output` points to space for `blocks` blocks to be written. + // * input == output.add(n), where n == src.start, and the caller is + // responsible for ensuing this sufficient for `f` to work correctly. + // * `blocks` is non-zero so `f` doesn't have to work for empty slices. + // * The caller is responsible for ensuring `key` was initialized by the + // `set_encrypt_key!` invocation required by `f`. + unsafe { + f(input, output, blocks, self, ctr); + } + + ctr.increment_by_less_safe(blocks_u32); + }); + } +} diff --git a/http/vendor/ring/src/aead/aes/hw.rs b/http/vendor/ring/src/aead/aes/hw.rs new file mode 100644 index 0000000..6310f22 --- /dev/null +++ b/http/vendor/ring/src/aead/aes/hw.rs @@ -0,0 +1,95 @@ +// Copyright 2018-2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#![cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + target_arch = "x86", + target_arch = "x86_64" +))] + +use super::{Block, Counter, EncryptBlock, EncryptCtr32, Iv, KeyBytes, Overlapping, AES_KEY}; +use crate::{cpu, error}; +use cfg_if::cfg_if; + +cfg_if! { + if #[cfg(all(target_arch = "aarch64", target_endian = "little"))] { + pub(in super::super) type RequiredCpuFeatures = cpu::arm::Aes; + pub(in super::super) type OptionalCpuFeatures = (); + } else if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { + use cpu::intel::{Aes, Avx, Ssse3}; + // Some functions seem to have been written to require only SSE/SSE2 + // but there seem to be no SSSE3-less CPUs with AES-NI, and we don't + // have feature detection for SSE2. + pub(in super::super) type RequiredCpuFeatures = (Aes, Ssse3); + pub(in super::super) type OptionalCpuFeatures = Avx; + } +} + +#[derive(Clone)] +pub struct Key { + inner: AES_KEY, +} + +impl Key { + #[cfg(all(target_arch = "aarch64", target_endian = "little"))] + pub(in super::super) fn new( + bytes: KeyBytes<'_>, + _required_cpu_features: RequiredCpuFeatures, + _optional_cpu_features: Option, + ) -> Result { + let inner = unsafe { set_encrypt_key!(aes_hw_set_encrypt_key, bytes) }?; + Ok(Self { inner }) + } + + #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + pub(in super::super) fn new( + bytes: KeyBytes<'_>, + (Aes { .. }, Ssse3 { .. }): RequiredCpuFeatures, + optional_cpu_features: Option, + ) -> Result { + // Ssse3 is required, but upstream only uses this if there is also Avx; + // presumably the base version is faster on pre-AVX CPUs. + let inner = if let Some(Avx { .. }) = optional_cpu_features { + unsafe { set_encrypt_key!(aes_hw_set_encrypt_key_alt, bytes) }? + } else { + unsafe { set_encrypt_key!(aes_hw_set_encrypt_key_base, bytes) }? + }; + Ok(Self { inner }) + } + + #[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + target_arch = "x86_64" + ))] + #[must_use] + pub(in super::super) fn inner_less_safe(&self) -> &AES_KEY { + &self.inner + } +} + +impl EncryptBlock for Key { + fn encrypt_block(&self, block: Block) -> Block { + super::encrypt_block_using_encrypt_iv_xor_block(self, block) + } + + fn encrypt_iv_xor_block(&self, iv: Iv, block: Block) -> Block { + super::encrypt_iv_xor_block_using_ctr32(self, iv, block) + } +} + +impl EncryptCtr32 for Key { + fn ctr32_encrypt_within(&self, in_out: Overlapping<'_>, ctr: &mut Counter) { + unsafe { ctr32_encrypt_blocks!(aes_hw_ctr32_encrypt_blocks, in_out, &self.inner, ctr) } + } +} diff --git a/http/vendor/ring/src/aead/aes/vp.rs b/http/vendor/ring/src/aead/aes/vp.rs new file mode 100644 index 0000000..283cd7d --- /dev/null +++ b/http/vendor/ring/src/aead/aes/vp.rs @@ -0,0 +1,139 @@ +// Copyright 2018-2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#![cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little"), + target_arch = "x86", + target_arch = "x86_64" +))] + +use super::{Block, Counter, EncryptBlock, EncryptCtr32, Iv, KeyBytes, Overlapping, AES_KEY}; +use crate::{cpu, error}; + +#[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little") +))] +type RequiredCpuFeatures = cpu::arm::Neon; + +#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +pub(in super::super) type RequiredCpuFeatures = cpu::intel::Ssse3; + +#[derive(Clone)] +pub(in super::super) struct Key { + inner: AES_KEY, +} + +impl Key { + pub(in super::super) fn new( + bytes: KeyBytes<'_>, + _cpu: RequiredCpuFeatures, + ) -> Result { + let inner = unsafe { set_encrypt_key!(vpaes_set_encrypt_key, bytes) }?; + Ok(Self { inner }) + } +} + +#[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little"), + target_arch = "x86_64" +))] +impl EncryptBlock for Key { + fn encrypt_block(&self, block: Block) -> Block { + super::encrypt_block_using_encrypt_iv_xor_block(self, block) + } + + fn encrypt_iv_xor_block(&self, iv: Iv, block: Block) -> Block { + super::encrypt_iv_xor_block_using_ctr32(self, iv, block) + } +} + +#[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + target_arch = "x86_64" +))] +impl EncryptCtr32 for Key { + fn ctr32_encrypt_within(&self, in_out: Overlapping<'_>, ctr: &mut Counter) { + unsafe { ctr32_encrypt_blocks!(vpaes_ctr32_encrypt_blocks, in_out, &self.inner, ctr) } + } +} + +#[cfg(all(target_arch = "arm", target_endian = "little"))] +impl EncryptCtr32 for Key { + fn ctr32_encrypt_within(&self, in_out: Overlapping<'_>, ctr: &mut Counter) { + use super::{super::overlapping::IndexError, bs, BLOCK_LEN}; + + let in_out = { + let (in_out, src) = in_out.into_slice_src_mut(); + let blocks = in_out[src.clone()].len() / BLOCK_LEN; + + // bsaes operates in batches of 8 blocks. + let bsaes_blocks = if blocks >= 8 && (blocks % 8) < 6 { + // It's faster to use bsaes for all the full batches and then + // switch to vpaes for the last partial batch (if any). + blocks - (blocks % 8) + } else if blocks >= 8 { + // It's faster to let bsaes handle everything including + // the last partial batch. + blocks + } else { + // It's faster to let vpaes handle everything. + 0 + }; + let bsaes_in_out_len = bsaes_blocks * BLOCK_LEN; + let bs_in_out = + Overlapping::new(&mut in_out[..(src.start + bsaes_in_out_len)], src.clone()) + .unwrap_or_else(|IndexError { .. }| unreachable!()); + + // SAFETY: + // * self.inner was initialized with `vpaes_set_encrypt_key` above, + // as required by `bsaes_ctr32_encrypt_blocks_with_vpaes_key`. + unsafe { + bs::ctr32_encrypt_blocks_with_vpaes_key(bs_in_out, &self.inner, ctr); + } + + Overlapping::new(&mut in_out[bsaes_in_out_len..], src) + .unwrap_or_else(|IndexError { .. }| unreachable!()) + }; + + // SAFETY: + // * self.inner was initialized with `vpaes_set_encrypt_key` above, + // as required by `vpaes_ctr32_encrypt_blocks`. + // * `vpaes_ctr32_encrypt_blocks` satisfies the contract for + // `ctr32_encrypt_blocks`. + unsafe { ctr32_encrypt_blocks!(vpaes_ctr32_encrypt_blocks, in_out, &self.inner, ctr) } + } +} + +#[cfg(target_arch = "x86")] +impl EncryptBlock for Key { + fn encrypt_block(&self, block: Block) -> Block { + unsafe { encrypt_block!(vpaes_encrypt, block, &self.inner) } + } + + fn encrypt_iv_xor_block(&self, iv: Iv, block: Block) -> Block { + super::encrypt_iv_xor_block_using_encrypt_block(self, iv, block) + } +} + +#[cfg(target_arch = "x86")] +impl EncryptCtr32 for Key { + fn ctr32_encrypt_within(&self, in_out: Overlapping<'_>, ctr: &mut Counter) { + super::super::shift::shift_full_blocks(in_out, |input| { + self.encrypt_iv_xor_block(ctr.increment(), *input) + }); + } +} diff --git a/http/vendor/ring/src/aead/aes_gcm.rs b/http/vendor/ring/src/aead/aes_gcm.rs new file mode 100644 index 0000000..d9e08a3 --- /dev/null +++ b/http/vendor/ring/src/aead/aes_gcm.rs @@ -0,0 +1,505 @@ +// Copyright 2015-2025 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::{ + aes::{self, Counter, Overlapping, OverlappingPartialBlock, BLOCK_LEN, ZERO_BLOCK}, + gcm, + overlapping::IndexError, + Aad, Nonce, Tag, +}; +use crate::{ + cpu, + error::{self, InputTooLongError}, + polyfill::{slice, sliceutil::overwrite_at_start, usize_from_u64_saturated}, +}; +use core::ops::RangeFrom; + +#[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little"), + target_arch = "x86", + target_arch = "x86_64" +))] +use cpu::GetFeature as _; + +mod aarch64; +mod aeshwclmulmovbe; +mod vaesclmulavx2; + +#[derive(Clone)] +pub(super) struct Key(DynKey); + +impl Key { + pub(super) fn new( + key: aes::KeyBytes, + cpu_features: cpu::Features, + ) -> Result { + Ok(Self(DynKey::new(key, cpu_features)?)) + } +} + +#[derive(Clone)] +enum DynKey { + #[cfg(target_arch = "x86_64")] + VAesClMulAvx2(Combo), + + #[cfg(target_arch = "x86_64")] + AesHwClMulAvxMovbe(Combo), + + #[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + target_arch = "x86", + target_arch = "x86_64" + ))] + AesHwClMul(Combo), + + #[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little") + ))] + Simd(Combo), + + #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + Simd(Combo), + + Fallback(Combo), +} + +impl DynKey { + fn new(key: aes::KeyBytes, cpu: cpu::Features) -> Result { + let cpu = cpu.values(); + + #[cfg(target_arch = "x86_64")] + if let Some((aes, gcm)) = cpu.get_feature() { + // 14.3.1 Detection of VEX-Encoded AES and VPCLMULQDQ + let aes_key = aes::hw::Key::new(key, aes, cpu.get_feature())?; + let gcm_key_value = derive_gcm_key_value(&aes_key); + let combo = if let Some(cpu) = cpu.get_feature() { + let gcm_key = gcm::vclmulavx2::Key::new(gcm_key_value, cpu); + Self::VAesClMulAvx2(Combo { aes_key, gcm_key }) + } else if let Some(cpu) = cpu.get_feature() { + let gcm_key = gcm::clmulavxmovbe::Key::new(gcm_key_value, cpu); + Self::AesHwClMulAvxMovbe(Combo { aes_key, gcm_key }) + } else { + let gcm_key = gcm::clmul::Key::new(gcm_key_value, gcm); + Self::AesHwClMul(Combo { aes_key, gcm_key }) + }; + return Ok(combo); + } + + // x86_64 is handled above. + #[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + target_arch = "x86" + ))] + if let (Some(aes), Some(gcm)) = (cpu.get_feature(), cpu.get_feature()) { + let aes_key = aes::hw::Key::new(key, aes, cpu.get_feature())?; + let gcm_key_value = derive_gcm_key_value(&aes_key); + let gcm_key = gcm::clmul::Key::new(gcm_key_value, gcm); + return Ok(Self::AesHwClMul(Combo { aes_key, gcm_key })); + } + + #[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little") + ))] + if let Some(cpu) = cpu.get_feature() { + return Self::new_neon(key, cpu); + } + + #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + if let Some(cpu) = cpu.get_feature() { + return Self::new_ssse3(key, cpu); + } + + let _ = cpu; + Self::new_fallback(key) + } + + #[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little") + ))] + #[cfg_attr(target_arch = "aarch64", inline(never))] + fn new_neon(key: aes::KeyBytes, cpu: cpu::arm::Neon) -> Result { + let aes_key = aes::vp::Key::new(key, cpu)?; + let gcm_key_value = derive_gcm_key_value(&aes_key); + let gcm_key = gcm::neon::Key::new(gcm_key_value, cpu); + Ok(Self::Simd(Combo { aes_key, gcm_key })) + } + + #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + #[inline(never)] + fn new_ssse3( + key: aes::KeyBytes, + cpu: aes::vp::RequiredCpuFeatures, + ) -> Result { + let aes_key = aes::vp::Key::new(key, cpu)?; + let gcm_key_value = derive_gcm_key_value(&aes_key); + let gcm_key = gcm::fallback::Key::new(gcm_key_value); + Ok(Self::Simd(Combo { aes_key, gcm_key })) + } + + #[cfg_attr( + any( + all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little"), + target_arch = "x86", + target_arch = "x86_64", + ), + inline(never) + )] + fn new_fallback(key: aes::KeyBytes) -> Result { + let aes_key = aes::fallback::Key::new(key)?; + let gcm_key_value = derive_gcm_key_value(&aes_key); + let gcm_key = gcm::fallback::Key::new(gcm_key_value); + Ok(Self::Fallback(Combo { aes_key, gcm_key })) + } +} + +fn derive_gcm_key_value(aes_key: &impl aes::EncryptBlock) -> gcm::KeyValue { + gcm::KeyValue::new(aes_key.encrypt_block(ZERO_BLOCK)) +} + +const CHUNK_BLOCKS: usize = 3 * 1024 / 16; + +#[inline(never)] +pub(super) fn seal( + Key(key): &Key, + nonce: Nonce, + aad: Aad<&[u8]>, + in_out: &mut [u8], +) -> Result { + let mut ctr = Counter::one(nonce); + let tag_iv = ctr.increment(); + + match key { + #[cfg(all(target_arch = "aarch64", target_endian = "little"))] + DynKey::AesHwClMul(c) => { + seal_whole_partial(c, aad, in_out, ctr, tag_iv, aarch64::seal_whole) + } + + #[cfg(target_arch = "x86_64")] + DynKey::VAesClMulAvx2(c) => seal_whole_partial( + c, + aad, + in_out, + ctr, + tag_iv, + vaesclmulavx2::seal_whole_vaes_clmul_avx2, + ), + + #[cfg(target_arch = "x86_64")] + DynKey::AesHwClMulAvxMovbe(Combo { aes_key, gcm_key }) => { + aeshwclmulmovbe::seal(aes_key, gcm_key, ctr, tag_iv, aad, in_out) + } + + #[cfg(any(target_arch = "x86_64", target_arch = "x86"))] + DynKey::AesHwClMul(c) => seal_strided(c, aad, in_out, ctr, tag_iv), + + #[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little"), + target_arch = "x86_64", + target_arch = "x86" + ))] + DynKey::Simd(c) => seal_strided(c, aad, in_out, ctr, tag_iv), + + DynKey::Fallback(c) => seal_strided(c, aad, in_out, ctr, tag_iv), + } +} + +#[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + target_arch = "x86_64" +))] +fn seal_whole_partial( + Combo { aes_key, gcm_key }: &Combo, + aad: Aad<&[u8]>, + in_out: &mut [u8], + mut ctr: Counter, + tag_iv: aes::Iv, + seal_whole: impl FnOnce(&A, &mut gcm::Context, &mut Counter, slice::AsChunksMut), +) -> Result { + let mut auth = gcm::Context::new(gcm_key, aad, in_out.len())?; + let (whole, remainder) = slice::as_chunks_mut(in_out); + seal_whole(aes_key, &mut auth, &mut ctr, whole); + let remainder = OverlappingPartialBlock::new(remainder.into()) + .unwrap_or_else(|InputTooLongError { .. }| unreachable!()); + seal_finish(aes_key, auth, remainder, ctr, tag_iv) +} + +#[cfg_attr( + any( + all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little"), + target_arch = "x86", + target_arch = "x86_64" + ), + inline(never) +)] +#[cfg_attr( + any( + all(target_arch = "aarch64", target_endian = "little"), + target_arch = "x86_64" + ), + cold +)] +fn seal_strided< + A: aes::EncryptBlock + aes::EncryptCtr32, + G: gcm::UpdateBlock + gcm::UpdateBlocks, +>( + Combo { aes_key, gcm_key }: &Combo, + aad: Aad<&[u8]>, + in_out: &mut [u8], + mut ctr: Counter, + tag_iv: aes::Iv, +) -> Result { + let mut auth = gcm::Context::new(gcm_key, aad, in_out.len())?; + + let (mut whole, remainder) = slice::as_chunks_mut(in_out); + + for mut chunk in whole.chunks_mut::() { + aes_key.ctr32_encrypt_within(chunk.as_flattened_mut().into(), &mut ctr); + auth.update_blocks(chunk.as_ref()); + } + + let remainder = OverlappingPartialBlock::new(remainder.into()) + .unwrap_or_else(|InputTooLongError { .. }| unreachable!()); + seal_finish(aes_key, auth, remainder, ctr, tag_iv) +} + +fn seal_finish( + aes_key: &A, + mut auth: gcm::Context, + remainder: OverlappingPartialBlock<'_>, + ctr: Counter, + tag_iv: aes::Iv, +) -> Result { + let remainder_len = remainder.len(); + if remainder_len > 0 { + let mut input = ZERO_BLOCK; + overwrite_at_start(&mut input, remainder.input()); + let mut output = aes_key.encrypt_iv_xor_block(ctr.into(), input); + output[remainder_len..].fill(0); + auth.update_block(output); + remainder.overwrite_at_start(output); + } + + Ok(finish(aes_key, auth, tag_iv)) +} + +#[inline(never)] +pub(super) fn open( + Key(key): &Key, + nonce: Nonce, + aad: Aad<&[u8]>, + in_out_slice: &mut [u8], + src: RangeFrom, +) -> Result { + let mut ctr = Counter::one(nonce); + let tag_iv = ctr.increment(); + + match key { + #[cfg(all(target_arch = "aarch64", target_endian = "little"))] + DynKey::AesHwClMul(c) => { + open_whole_partial(c, aad, in_out_slice, src, ctr, tag_iv, aarch64::open_whole) + } + + #[cfg(target_arch = "x86_64")] + DynKey::VAesClMulAvx2(c) => open_whole_partial( + c, + aad, + in_out_slice, + src, + ctr, + tag_iv, + vaesclmulavx2::open_whole_vaes_clmul_avx2, + ), + + #[cfg(target_arch = "x86_64")] + DynKey::AesHwClMulAvxMovbe(Combo { aes_key, gcm_key }) => { + aeshwclmulmovbe::open(aes_key, gcm_key, ctr, tag_iv, aad, in_out_slice, src) + } + + #[cfg(any(target_arch = "x86_64", target_arch = "x86"))] + DynKey::AesHwClMul(c) => open_strided(c, aad, in_out_slice, src, ctr, tag_iv), + + #[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little"), + target_arch = "x86_64", + target_arch = "x86" + ))] + DynKey::Simd(c) => open_strided(c, aad, in_out_slice, src, ctr, tag_iv), + + DynKey::Fallback(c) => open_strided(c, aad, in_out_slice, src, ctr, tag_iv), + } +} + +#[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + target_arch = "x86_64" +))] +fn open_whole_partial( + Combo { aes_key, gcm_key }: &Combo, + aad: Aad<&[u8]>, + in_out_slice: &mut [u8], + src: RangeFrom, + mut ctr: Counter, + tag_iv: aes::Iv, + open_whole: impl FnOnce(&A, &mut gcm::Context, Overlapping, &mut Counter), +) -> Result { + let in_out = Overlapping::new(in_out_slice, src.clone()).map_err(error::erase::)?; + let mut auth = gcm::Context::new(gcm_key, aad, in_out.len())?; + + let remainder_len = in_out.len() % BLOCK_LEN; + + let in_out_slice_len = in_out_slice.len(); + let whole_in_out_slice = &mut in_out_slice[..(in_out_slice_len - remainder_len)]; + let whole = Overlapping::new(whole_in_out_slice, src.clone()) + .unwrap_or_else(|IndexError { .. }| unreachable!()); + let whole_len = whole.len(); + open_whole(aes_key, &mut auth, whole, &mut ctr); + + let remainder = &mut in_out_slice[whole_len..]; + let remainder = + Overlapping::new(remainder, src).unwrap_or_else(|IndexError { .. }| unreachable!()); + let remainder = OverlappingPartialBlock::new(remainder) + .unwrap_or_else(|InputTooLongError { .. }| unreachable!()); + open_finish(aes_key, auth, remainder, ctr, tag_iv) +} + +#[cfg_attr( + any( + all( + any( + all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little") + ), + target_feature = "neon" + ), + all( + any(target_arch = "x86", target_arch = "x86_64"), + target_feature = "sse" + ) + ), + inline(never) +)] +#[cfg_attr( + any( + all(target_arch = "aarch64", target_endian = "little"), + target_arch = "x86_64" + ), + cold +)] +fn open_strided< + A: aes::EncryptBlock + aes::EncryptCtr32, + G: gcm::UpdateBlock + gcm::UpdateBlocks, +>( + Combo { aes_key, gcm_key }: &Combo, + aad: Aad<&[u8]>, + in_out_slice: &mut [u8], + src: RangeFrom, + mut ctr: Counter, + tag_iv: aes::Iv, +) -> Result { + let in_out = Overlapping::new(in_out_slice, src.clone()).map_err(error::erase::)?; + let input = in_out.input(); + let input_len = input.len(); + + let mut auth = gcm::Context::new(gcm_key, aad, input_len)?; + + let remainder_len = input_len % BLOCK_LEN; + let whole_len = input_len - remainder_len; + let in_prefix_len = src.start; + + { + let mut chunk_len = CHUNK_BLOCKS * BLOCK_LEN; + let mut output = 0; + let mut input = in_prefix_len; + loop { + if whole_len - output < chunk_len { + chunk_len = whole_len - output; + } + + let ciphertext = &in_out_slice[input..][..chunk_len]; + let (ciphertext, leftover) = slice::as_chunks(ciphertext); + debug_assert_eq!(leftover.len(), 0); + if ciphertext.is_empty() { + break; + } + auth.update_blocks(ciphertext); + + let chunk = Overlapping::new( + &mut in_out_slice[output..][..(chunk_len + in_prefix_len)], + in_prefix_len.., + ) + .map_err(error::erase::)?; + aes_key.ctr32_encrypt_within(chunk, &mut ctr); + output += chunk_len; + input += chunk_len; + } + } + + let in_out = Overlapping::new(&mut in_out_slice[whole_len..], src) + .unwrap_or_else(|IndexError { .. }| unreachable!()); + let in_out = OverlappingPartialBlock::new(in_out) + .unwrap_or_else(|InputTooLongError { .. }| unreachable!()); + + open_finish(aes_key, auth, in_out, ctr, tag_iv) +} + +fn open_finish( + aes_key: &A, + mut auth: gcm::Context, + remainder: OverlappingPartialBlock<'_>, + ctr: Counter, + tag_iv: aes::Iv, +) -> Result { + if remainder.len() > 0 { + let mut input = ZERO_BLOCK; + overwrite_at_start(&mut input, remainder.input()); + auth.update_block(input); + remainder.overwrite_at_start(aes_key.encrypt_iv_xor_block(ctr.into(), input)); + } + Ok(finish(aes_key, auth, tag_iv)) +} + +fn finish( + aes_key: &A, + gcm_ctx: gcm::Context, + tag_iv: aes::Iv, +) -> Tag { + // Finalize the tag and return it. + gcm_ctx.pre_finish(|pre_tag| Tag(aes_key.encrypt_iv_xor_block(tag_iv, pre_tag))) +} + +pub(super) const MAX_IN_OUT_LEN: usize = super::max_input_len(BLOCK_LEN, 2); + +// [NIST SP800-38D] Section 5.2.1.1. Note that [RFC 5116 Section 5.1] and +// [RFC 5116 Section 5.2] have an off-by-one error in `P_MAX`. +// +// [NIST SP800-38D]: +// http://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf +// [RFC 5116 Section 5.1]: https://tools.ietf.org/html/rfc5116#section-5.1 +// [RFC 5116 Section 5.2]: https://tools.ietf.org/html/rfc5116#section-5.2 +const _MAX_INPUT_LEN_BOUNDED_BY_NIST: () = + assert!(MAX_IN_OUT_LEN == usize_from_u64_saturated(((1u64 << 39) - 256) / 8)); + +#[derive(Copy, Clone)] +pub(super) struct Combo { + pub(super) aes_key: Aes, + pub(super) gcm_key: Gcm, +} diff --git a/http/vendor/ring/src/aead/aes_gcm/aarch64.rs b/http/vendor/ring/src/aead/aes_gcm/aarch64.rs new file mode 100644 index 0000000..15aa5b1 --- /dev/null +++ b/http/vendor/ring/src/aead/aes_gcm/aarch64.rs @@ -0,0 +1,95 @@ +// Copyright 2015-2025 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#![cfg(all(target_arch = "aarch64", target_endian = "little"))] + +use super::{aes, gcm, Counter, BLOCK_LEN}; +use crate::{aead::aes::Overlapping, bits::BitLength, polyfill::slice::AsChunksMut}; +use core::num::NonZeroU64; + +pub(super) fn seal_whole( + aes_key: &aes::hw::Key, + auth: &mut gcm::Context, + ctr: &mut Counter, + mut in_out: AsChunksMut, +) { + let whole_block_bits = auth.in_out_whole_block_bits(); + let whole_block_bits_u64: BitLength = whole_block_bits.into(); + if let Ok(whole_block_bits) = whole_block_bits_u64.try_into() { + let (htable, xi) = auth.inner(); + + prefixed_extern! { + fn aes_gcm_enc_kernel( + input: *const [u8; BLOCK_LEN], + in_bits: BitLength, + output: *mut [u8; BLOCK_LEN], + Xi: &mut gcm::Xi, + ivec: &mut Counter, + key: &aes::AES_KEY, + Htable: &gcm::HTable); + } + + unsafe { + aes_gcm_enc_kernel( + in_out.as_ptr(), + whole_block_bits, + in_out.as_mut_ptr(), + xi, + ctr, + aes_key.inner_less_safe(), + htable, + ) + } + } +} + +pub(super) fn open_whole( + aes_key: &aes::hw::Key, + auth: &mut gcm::Context, + in_out: Overlapping, + ctr: &mut Counter, +) { + // Precondition. TODO: Create an overlapping::AsChunks for this. + assert_eq!(in_out.len() % BLOCK_LEN, 0); + + in_out.with_input_output_len(|input, output, _len| { + let whole_block_bits = auth.in_out_whole_block_bits(); + let whole_block_bits_u64: BitLength = whole_block_bits.into(); + if let Ok(whole_block_bits) = whole_block_bits_u64.try_into() { + let (htable, xi) = auth.inner(); + prefixed_extern! { + fn aes_gcm_dec_kernel( + input: *const u8, + in_bits: BitLength, + output: *mut u8, + Xi: &mut gcm::Xi, + ivec: &mut Counter, + key: &aes::AES_KEY, + Htable: &gcm::HTable); + } + + unsafe { + aes_gcm_dec_kernel( + input, + whole_block_bits, + output, + xi, + ctr, + aes_key.inner_less_safe(), + htable, + ) + } + } + }) +} diff --git a/http/vendor/ring/src/aead/aes_gcm/aeshwclmulmovbe.rs b/http/vendor/ring/src/aead/aes_gcm/aeshwclmulmovbe.rs new file mode 100644 index 0000000..e6d49ee --- /dev/null +++ b/http/vendor/ring/src/aead/aes_gcm/aeshwclmulmovbe.rs @@ -0,0 +1,154 @@ +// Copyright 2015-2025 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#![cfg(target_arch = "x86_64")] + +use super::{ + super::overlapping::IndexError, + aes::{self, Counter, EncryptCtr32, Overlapping, OverlappingPartialBlock}, + gcm, Aad, Tag, +}; +use crate::{ + c, + error::{self, InputTooLongError}, + polyfill::slice, +}; +use core::ops::RangeFrom; + +#[inline(never)] +pub(super) fn seal( + aes_key: &aes::hw::Key, + gcm_key: &gcm::clmulavxmovbe::Key, + mut ctr: Counter, + tag_iv: aes::Iv, + aad: Aad<&[u8]>, + in_out: &mut [u8], +) -> Result { + prefixed_extern! { + // `HTable` and `Xi` should be 128-bit aligned. TODO: Can we shrink `HTable`? The + // assembly says it needs just nine values in that array. + fn aesni_gcm_encrypt( + input: *const u8, + output: *mut u8, + len: c::size_t, + key: &aes::AES_KEY, + ivec: &mut Counter, + Htable: &gcm::HTable, + Xi: &mut gcm::Xi) -> c::size_t; + } + + let mut auth = gcm::Context::new(gcm_key, aad, in_out.len())?; + let (htable, xi) = auth.inner(); + + let processed = unsafe { + aesni_gcm_encrypt( + in_out.as_ptr(), + in_out.as_mut_ptr(), + in_out.len(), + aes_key.inner_less_safe(), + &mut ctr, + htable, + xi, + ) + }; + + let ramaining = match in_out.get_mut(processed..) { + Some(remaining) => remaining, + None => { + // This can't happen. If it did, then the assembly already + // caused a buffer overflow. + unreachable!() + } + }; + let (mut whole, remainder) = slice::as_chunks_mut(ramaining); + aes_key.ctr32_encrypt_within(whole.as_flattened_mut().into(), &mut ctr); + auth.update_blocks(whole.as_ref()); + let remainder = OverlappingPartialBlock::new(remainder.into()) + .unwrap_or_else(|InputTooLongError { .. }| unreachable!()); + + super::seal_finish(aes_key, auth, remainder, ctr, tag_iv) +} + +#[inline(never)] +pub(super) fn open( + aes_key: &aes::hw::Key, + gcm_key: &gcm::clmulavxmovbe::Key, + mut ctr: Counter, + tag_iv: aes::Iv, + aad: Aad<&[u8]>, + in_out_slice: &mut [u8], + src: RangeFrom, +) -> Result { + prefixed_extern! { + // `HTable` and `Xi` should be 128-bit aligned. TODO: Can we shrink `HTable`? The + // assembly says it needs just nine values in that array. + fn aesni_gcm_decrypt( + input: *const u8, + output: *mut u8, + len: c::size_t, + key: &aes::AES_KEY, + ivec: &mut Counter, + Htable: &gcm::HTable, + Xi: &mut gcm::Xi) -> c::size_t; + } + + let in_out = Overlapping::new(in_out_slice, src.clone()).map_err(error::erase::)?; + let mut auth = gcm::Context::new(gcm_key, aad, in_out.len())?; + let processed = in_out.with_input_output_len(|input, output, len| { + let (htable, xi) = auth.inner(); + unsafe { + aesni_gcm_decrypt( + input, + output, + len, + aes_key.inner_less_safe(), + &mut ctr, + htable, + xi, + ) + } + }); + let in_out_slice = in_out_slice.get_mut(processed..).unwrap_or_else(|| { + // This can't happen. If it did, then the assembly already + // caused a buffer overflow. + unreachable!() + }); + // Authenticate any remaining whole blocks. + let in_out = + Overlapping::new(in_out_slice, src.clone()).unwrap_or_else(|IndexError { .. }| { + // This can't happen. If it did, then the assembly already + // overwrote part of the remaining input. + unreachable!() + }); + let (whole, _) = slice::as_chunks(in_out.input()); + auth.update_blocks(whole); + + let whole_len = whole.as_flattened().len(); + + // Decrypt any remaining whole blocks. + let whole = Overlapping::new(&mut in_out_slice[..(src.start + whole_len)], src.clone()) + .map_err(error::erase::)?; + aes_key.ctr32_encrypt_within(whole, &mut ctr); + + let in_out_slice = match in_out_slice.get_mut(whole_len..) { + Some(partial) => partial, + None => unreachable!(), + }; + let in_out = + Overlapping::new(in_out_slice, src).unwrap_or_else(|IndexError { .. }| unreachable!()); + let in_out = OverlappingPartialBlock::new(in_out) + .unwrap_or_else(|InputTooLongError { .. }| unreachable!()); + + super::open_finish(aes_key, auth, in_out, ctr, tag_iv) +} diff --git a/http/vendor/ring/src/aead/aes_gcm/vaesclmulavx2.rs b/http/vendor/ring/src/aead/aes_gcm/vaesclmulavx2.rs new file mode 100644 index 0000000..8a2a68f --- /dev/null +++ b/http/vendor/ring/src/aead/aes_gcm/vaesclmulavx2.rs @@ -0,0 +1,86 @@ +// Copyright 2015-2025 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#![cfg(target_arch = "x86_64")] + +use super::{aes, gcm, Counter, BLOCK_LEN}; +use crate::{aead::aes::Overlapping, c, polyfill::slice::AsChunksMut}; +use core::num::NonZeroU32; + +pub(super) fn seal_whole_vaes_clmul_avx2( + aes_key: &aes::hw::Key, + auth: &mut gcm::Context, + ctr: &mut Counter, + mut in_out: AsChunksMut, +) { + prefixed_extern! { + fn aes_gcm_enc_update_vaes_avx2( + input: *const u8, + output: *mut u8, + len: c::size_t, + key: &aes::AES_KEY, + ivec: &Counter, + Htable: &gcm::HTable, + Xi: &mut gcm::Xi); + } + + let in_out = in_out.as_flattened_mut(); + + // Precondition: Since we have a `gcm::Context` then the number of blocks + // must fit in `u32`. + let blocks = u32::try_from(in_out.len() / BLOCK_LEN).unwrap(); + + if let Some(blocks) = NonZeroU32::new(blocks) { + let aes_key = aes_key.inner_less_safe(); + let (htable, xi) = auth.inner(); + let input = in_out.as_ptr(); + let output = in_out.as_mut_ptr(); + let len = in_out.len(); + unsafe { aes_gcm_enc_update_vaes_avx2(input, output, len, aes_key, ctr, htable, xi) }; + ctr.increment_by_less_safe(blocks); + } +} + +pub(super) fn open_whole_vaes_clmul_avx2( + aes_key: &aes::hw::Key, + auth: &mut gcm::Context, + in_out: Overlapping, + ctr: &mut Counter, +) { + prefixed_extern! { + fn aes_gcm_dec_update_vaes_avx2( + input: *const u8, + output: *mut u8, + len: c::size_t, + key: &aes::AES_KEY, + ivec: &mut Counter, + Htable: &gcm::HTable, + Xi: &mut gcm::Xi); + } + + // Precondition. TODO: Create an overlapping::AsChunks for this. + assert_eq!(in_out.len() % BLOCK_LEN, 0); + // Precondition: Since we have a `gcm::Context` then the number of blocks + // must fit in `u32`. + let blocks = u32::try_from(in_out.len() / BLOCK_LEN).unwrap(); + + if let Some(blocks) = NonZeroU32::new(blocks) { + let aes_key = aes_key.inner_less_safe(); + let (htable, xi) = auth.inner(); + in_out.with_input_output_len(|input, output, len| unsafe { + aes_gcm_dec_update_vaes_avx2(input, output, len, aes_key, ctr, htable, xi) + }); + ctr.increment_by_less_safe(blocks); + } +} diff --git a/http/vendor/ring/src/aead/algorithm.rs b/http/vendor/ring/src/aead/algorithm.rs new file mode 100644 index 0000000..24d4fb8 --- /dev/null +++ b/http/vendor/ring/src/aead/algorithm.rs @@ -0,0 +1,269 @@ +// Copyright 2015-2021 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use crate::{ + bb, cpu, + error::{self, InputTooLongError}, + hkdf, +}; +use core::ops::RangeFrom; + +use super::{ + aes, aes_gcm, chacha20_poly1305, + nonce::{Nonce, NONCE_LEN}, + overlapping::{IndexError, Overlapping}, + Aad, KeyInner, Tag, TAG_LEN, +}; + +impl hkdf::KeyType for &'static Algorithm { + #[inline] + fn len(&self) -> usize { + self.key_len() + } +} + +/// An AEAD Algorithm. +pub struct Algorithm { + init: fn(key: &[u8], cpu_features: cpu::Features) -> Result, + + seal: fn( + key: &KeyInner, + nonce: Nonce, + aad: Aad<&[u8]>, + in_out: &mut [u8], + cpu_features: cpu::Features, + ) -> Result, + open: fn( + key: &KeyInner, + nonce: Nonce, + aad: Aad<&[u8]>, + in_out: &mut [u8], + src: RangeFrom, + cpu_features: cpu::Features, + ) -> Result, + + key_len: usize, + id: AlgorithmID, +} + +impl Algorithm { + /// The length of the key. + #[inline(always)] + pub fn key_len(&self) -> usize { + self.key_len + } + + /// The length of a tag. + /// + /// See also `MAX_TAG_LEN`. + #[inline(always)] + pub fn tag_len(&self) -> usize { + TAG_LEN + } + + /// The length of the nonces. + #[inline(always)] + pub fn nonce_len(&self) -> usize { + NONCE_LEN + } + + pub(super) fn new_key( + &self, + key_bytes: &[u8], + cpu_features: cpu::Features, + ) -> Result { + (self.init)(key_bytes, cpu_features) + } + + pub(super) fn open_within<'io>( + &self, + key: &KeyInner, + nonce: Nonce, + aad: Aad<&[u8]>, + received_tag: Tag, + in_out: &'io mut [u8], + src: RangeFrom, + cpu_features: cpu::Features, + ) -> Result<&'io mut [u8], error::Unspecified> { + let ciphertext_len = in_out.get(src.clone()).ok_or(error::Unspecified)?.len(); + + let Tag(calculated_tag) = (self.open)(key, nonce, aad, in_out, src, cpu_features)?; + + if bb::verify_slices_are_equal(calculated_tag.as_ref(), received_tag.as_ref()).is_err() { + // Zero out the plaintext so that it isn't accidentally leaked or used + // after verification fails. It would be safest if we could check the + // tag before decrypting, but some `open` implementations interleave + // authentication with decryption for performance. + for b in &mut in_out[..ciphertext_len] { + *b = 0; + } + return Err(error::Unspecified); + } + + // `ciphertext_len` is also the plaintext length. + Ok(&mut in_out[..ciphertext_len]) + } + + #[inline] + pub(super) fn seal( + &self, + key: &KeyInner, + nonce: Nonce, + aad: Aad<&[u8]>, + in_out: &mut [u8], + cpu_features: cpu::Features, + ) -> Result { + (self.seal)(key, nonce, aad, in_out, cpu_features) + } +} + +derive_debug_via_id!(Algorithm); + +#[derive(Debug, Eq, PartialEq)] +pub(super) enum AlgorithmID { + AES_128_GCM, + AES_256_GCM, + CHACHA20_POLY1305, +} + +impl PartialEq for Algorithm { + fn eq(&self, other: &Self) -> bool { + self.id == other.id + } +} + +impl Eq for Algorithm {} + +/// AES-128 in GCM mode with 128-bit tags and 96 bit nonces. +pub static AES_128_GCM: Algorithm = Algorithm { + key_len: aes::AES_128_KEY_LEN, + init: aes_gcm_init_128, + seal: aes_gcm_seal, + open: aes_gcm_open, + id: AlgorithmID::AES_128_GCM, +}; + +/// AES-256 in GCM mode with 128-bit tags and 96 bit nonces. +pub static AES_256_GCM: Algorithm = Algorithm { + key_len: aes::AES_256_KEY_LEN, + init: aes_gcm_init_256, + seal: aes_gcm_seal, + open: aes_gcm_open, + id: AlgorithmID::AES_256_GCM, +}; + +fn aes_gcm_init_128( + key: &[u8], + cpu_features: cpu::Features, +) -> Result { + let key = key.try_into().map_err(|_| error::Unspecified)?; + Ok(KeyInner::AesGcm(aes_gcm::Key::new( + aes::KeyBytes::AES_128(key), + cpu_features, + )?)) +} + +fn aes_gcm_init_256( + key: &[u8], + cpu_features: cpu::Features, +) -> Result { + let key = key.try_into().map_err(|_| error::Unspecified)?; + Ok(KeyInner::AesGcm(aes_gcm::Key::new( + aes::KeyBytes::AES_256(key), + cpu_features, + )?)) +} + +fn aes_gcm_seal( + key: &KeyInner, + nonce: Nonce, + aad: Aad<&[u8]>, + in_out: &mut [u8], + _cpu_features: cpu::Features, +) -> Result { + let key = match key { + KeyInner::AesGcm(key) => key, + _ => unreachable!(), + }; + aes_gcm::seal(key, nonce, aad, in_out) +} + +pub(super) fn aes_gcm_open( + key: &KeyInner, + nonce: Nonce, + aad: Aad<&[u8]>, + in_out: &mut [u8], + src: RangeFrom, + _cpu_features: cpu::Features, +) -> Result { + let key = match key { + KeyInner::AesGcm(key) => key, + _ => unreachable!(), + }; + aes_gcm::open(key, nonce, aad, in_out, src) +} + +/// ChaCha20-Poly1305 as described in [RFC 8439]. +/// +/// The keys are 256 bits long and the nonces are 96 bits long. +/// +/// [RFC 8439]: https://tools.ietf.org/html/rfc8439 +pub static CHACHA20_POLY1305: Algorithm = Algorithm { + key_len: chacha20_poly1305::KEY_LEN, + init: chacha20_poly1305_init, + seal: chacha20_poly1305_seal, + open: chacha20_poly1305_open, + id: AlgorithmID::CHACHA20_POLY1305, +}; + +/// Copies |key| into |ctx_buf|. +fn chacha20_poly1305_init( + key: &[u8], + _cpu_features: cpu::Features, +) -> Result { + let key: [u8; chacha20_poly1305::KEY_LEN] = key.try_into()?; + Ok(KeyInner::ChaCha20Poly1305(chacha20_poly1305::Key::new(key))) +} + +fn chacha20_poly1305_seal( + key: &KeyInner, + nonce: Nonce, + aad: Aad<&[u8]>, + in_out: &mut [u8], + cpu_features: cpu::Features, +) -> Result { + let key = match key { + KeyInner::ChaCha20Poly1305(key) => key, + _ => unreachable!(), + }; + chacha20_poly1305::seal(key, nonce, aad, in_out, cpu_features) + .map_err(error::erase::) +} + +fn chacha20_poly1305_open( + key: &KeyInner, + nonce: Nonce, + aad: Aad<&[u8]>, + in_out: &mut [u8], + src: RangeFrom, + cpu_features: cpu::Features, +) -> Result { + let key = match key { + KeyInner::ChaCha20Poly1305(key) => key, + _ => unreachable!(), + }; + let in_out = Overlapping::new(in_out, src).map_err(error::erase::)?; + chacha20_poly1305::open(key, nonce, aad, in_out, cpu_features) + .map_err(error::erase::) +} diff --git a/http/vendor/ring/src/aead/chacha.rs b/http/vendor/ring/src/aead/chacha.rs new file mode 100644 index 0000000..8d7230b --- /dev/null +++ b/http/vendor/ring/src/aead/chacha.rs @@ -0,0 +1,327 @@ +// Copyright 2016 Brian Smith. +// Portions Copyright (c) 2016, Google Inc. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::{overlapping, quic::Sample, Nonce}; +use crate::cpu; +use cfg_if::cfg_if; + +cfg_if! { + if #[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little"), + target_arch = "x86", + target_arch = "x86_64" + ))] { + #[macro_use] + mod ffi; + #[cfg(any(target_arch = "x86", test))] + mod fallback; + } else { + mod fallback; + } +} + +use crate::polyfill::ArraySplitMap; + +pub type Overlapping<'o> = overlapping::Overlapping<'o, u8>; + +#[derive(Clone)] +pub struct Key { + words: [u32; KEY_LEN / 4], +} + +impl Key { + pub(super) fn new(value: [u8; KEY_LEN]) -> Self { + Self { + words: value.array_split_map(u32::from_le_bytes), + } + } +} + +impl Key { + // Encrypts `in_out` with the counter 0 and returns counter 1, + // where the counter is derived from the nonce `nonce`. + #[inline] + pub(super) fn encrypt_single_block_with_ctr_0( + &self, + nonce: Nonce, + in_out: &mut [u8; N], + cpu: cpu::Features, + ) -> Counter { + assert!(N <= BLOCK_LEN); + let (zero, one) = Counter::zero_one_less_safe(nonce); + self.encrypt(zero, in_out.as_mut().into(), cpu); + one + } + + #[inline] + pub fn new_mask(&self, sample: Sample) -> [u8; 5] { + let cpu = cpu::features(); // TODO: Remove this. + let (ctr, nonce) = sample.split_at(4); + let ctr = u32::from_le_bytes(ctr.try_into().unwrap()); + let nonce = Nonce::assume_unique_for_key(nonce.try_into().unwrap()); + let ctr = Counter::from_nonce_and_ctr(nonce, ctr); + + let mut out: [u8; 5] = [0; 5]; + self.encrypt(ctr, out.as_mut().into(), cpu); + out + } + + #[inline(always)] + pub(super) fn encrypt(&self, counter: Counter, in_out: Overlapping<'_>, cpu: cpu::Features) { + cfg_if! { + if #[cfg(all(target_arch = "aarch64", target_endian = "little"))] { + use cpu::{GetFeature as _, arm::Neon}; + const NEON_MIN_LEN: usize = 192 + 1; + if in_out.len() >= NEON_MIN_LEN { + if let Some(cpu) = cpu.get_feature() { + return chacha20_ctr32_ffi!( + unsafe { (NEON_MIN_LEN, Neon, Overlapping<'_>) => ChaCha20_ctr32_neon }, + self, counter, in_out, cpu); + } + } + if in_out.len() >= 1 { + chacha20_ctr32_ffi!( + unsafe { (1, (), Overlapping<'_>) => ChaCha20_ctr32_nohw }, + self, counter, in_out, ()) + } + } else if #[cfg(all(target_arch = "arm", target_endian = "little"))] { + use cpu::{GetFeature as _, arm::Neon}; + const NEON_MIN_LEN: usize = 192 + 1; + if in_out.len() >= NEON_MIN_LEN { + if let Some(cpu) = cpu.get_feature() { + return chacha20_ctr32_ffi!( + unsafe { (NEON_MIN_LEN, Neon, &mut [u8]) => ChaCha20_ctr32_neon }, + self, counter, in_out.copy_within(), cpu); + } + } + if in_out.len() >= 1 { + chacha20_ctr32_ffi!( + unsafe { (1, (), &mut [u8]) => ChaCha20_ctr32_nohw }, + self, counter, in_out.copy_within(), ()) + } + } else if #[cfg(target_arch = "x86")] { + use cpu::{GetFeature as _, intel::Ssse3}; + if in_out.len() >= 1 { + if let Some(cpu) = cpu.get_feature() { + chacha20_ctr32_ffi!( + unsafe { (1, Ssse3, &mut [u8]) => ChaCha20_ctr32_ssse3 }, + self, counter, in_out.copy_within(), cpu) + } else { + let _: cpu::Features = cpu; + fallback::ChaCha20_ctr32(self, counter, in_out) + } + } + } else if #[cfg(target_arch = "x86_64")] { + use cpu::{GetFeature, intel::{Avx2, Ssse3}}; + const SSE_MIN_LEN: usize = 128 + 1; // Also AVX2, SSSE3_4X, SSSE3 + if in_out.len() >= SSE_MIN_LEN { + let values = cpu.values(); + if let Some(cpu) = values.get_feature() { + return chacha20_ctr32_ffi!( + unsafe { (SSE_MIN_LEN, Avx2, Overlapping<'_>) => ChaCha20_ctr32_avx2 }, + self, counter, in_out, cpu); + } + if let Some(cpu) = values.get_feature() { + return chacha20_ctr32_ffi!( + unsafe { (SSE_MIN_LEN, Ssse3, Overlapping<'_>) => + ChaCha20_ctr32_ssse3_4x }, + self, counter, in_out, cpu); + } + } + if in_out.len() >= 1 { + chacha20_ctr32_ffi!( + unsafe { (1, (), Overlapping<'_>) => ChaCha20_ctr32_nohw }, + self, counter, in_out, ()) + } + } else { + let _: cpu::Features = cpu; + fallback::ChaCha20_ctr32(self, counter, in_out) + } + } + } + + #[inline] + pub(super) fn words_less_safe(&self) -> &[u32; KEY_LEN / 4] { + &self.words + } +} + +/// Counter || Nonce, all native endian. +#[repr(transparent)] +pub struct Counter([u32; 4]); + +impl Counter { + // Nonce-reuse: the caller must only use the first counter (0) for at most + // a single block. + fn zero_one_less_safe(nonce: Nonce) -> (Self, Self) { + let ctr0 @ Self([_, n0, n1, n2]) = Self::from_nonce_and_ctr(nonce, 0); + let ctr1 = Self([1, n0, n1, n2]); + (ctr0, ctr1) + } + + fn from_nonce_and_ctr(nonce: Nonce, ctr: u32) -> Self { + let [n0, n1, n2] = nonce.as_ref().array_split_map(u32::from_le_bytes); + Self([ctr, n0, n1, n2]) + } + + /// This is "less safe" because it hands off management of the counter to + /// the caller. + #[cfg(any( + test, + not(any( + all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little"), + target_arch = "x86_64" + )) + ))] + fn into_words_less_safe(self) -> [u32; 4] { + self.0 + } +} + +pub const KEY_LEN: usize = 32; + +const BLOCK_LEN: usize = 64; + +#[cfg(test)] +mod tests { + extern crate alloc; + + use super::{super::overlapping::IndexError, *}; + use crate::error; + use crate::testutil as test; + use alloc::vec; + + const MAX_ALIGNMENT_AND_OFFSET: (usize, usize) = (15, 259); + const MAX_ALIGNMENT_AND_OFFSET_SUBSET: (usize, usize) = + if cfg!(any(not(debug_assertions), feature = "slow_tests")) { + MAX_ALIGNMENT_AND_OFFSET + } else { + (0, 0) + }; + + #[test] + fn chacha20_test_default() { + // Always use `MAX_OFFSET` if we hav assembly code. + let max_offset = if cfg!(any( + all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little"), + target_arch = "x86", + target_arch = "x86_64" + )) { + MAX_ALIGNMENT_AND_OFFSET + } else { + MAX_ALIGNMENT_AND_OFFSET_SUBSET + }; + chacha20_test(max_offset, Key::encrypt); + } + + // Smoketest the fallback implementation. + #[test] + fn chacha20_test_fallback() { + chacha20_test(MAX_ALIGNMENT_AND_OFFSET_SUBSET, |key, ctr, in_out, _cpu| { + fallback::ChaCha20_ctr32(key, ctr, in_out) + }); + } + + // Verifies the encryption is successful when done on overlapping buffers. + // + // On some branches of the 32-bit x86 and ARM assembly code the in-place + // operation fails in some situations where the input/output buffers are + // not exactly overlapping. Such failures are dependent not only on the + // degree of overlapping but also the length of the data. `encrypt_within` + // works around that. + fn chacha20_test( + max_alignment_and_offset: (usize, usize), + f: impl for<'k, 'o> Fn(&'k Key, Counter, Overlapping<'o>, cpu::Features), + ) { + let cpu = cpu::features(); + + // Reuse a buffer to avoid slowing down the tests with allocations. + let mut buf = vec![0u8; 1300]; + + test::run( + test_vector_file!("chacha_tests.txt"), + move |section, test_case| { + assert_eq!(section, ""); + + let key = test_case.consume_bytes("Key"); + let key: &[u8; KEY_LEN] = key.as_slice().try_into()?; + let key = Key::new(*key); + + let ctr = test_case.consume_usize("Ctr"); + let nonce = test_case.consume_bytes("Nonce"); + let input = test_case.consume_bytes("Input"); + let output = test_case.consume_bytes("Output"); + + // Run the test case over all prefixes of the input because the + // behavior of ChaCha20 implementation changes dependent on the + // length of the input. + for len in 0..=input.len() { + #[allow(clippy::cast_possible_truncation)] + chacha20_test_case_inner( + &key, + &nonce, + ctr as u32, + &input[..len], + &output[..len], + &mut buf, + max_alignment_and_offset, + cpu, + &f, + ); + } + + Ok(()) + }, + ); + } + + fn chacha20_test_case_inner( + key: &Key, + nonce: &[u8], + ctr: u32, + input: &[u8], + expected: &[u8], + buf: &mut [u8], + (max_alignment, max_offset): (usize, usize), + cpu: cpu::Features, + f: &impl for<'k, 'o> Fn(&'k Key, Counter, Overlapping<'o>, cpu::Features), + ) { + const ARBITRARY: u8 = 123; + + for alignment in 0..=max_alignment { + buf[..alignment].fill(ARBITRARY); + let buf = &mut buf[alignment..]; + for offset in 0..=max_offset { + let buf = &mut buf[..(offset + input.len())]; + buf[..offset].fill(ARBITRARY); + let src = offset..; + buf[src.clone()].copy_from_slice(input); + + let ctr = Counter::from_nonce_and_ctr( + Nonce::try_assume_unique_for_key(nonce).unwrap(), + ctr, + ); + let in_out = Overlapping::new(buf, src) + .map_err(error::erase::) + .unwrap(); + f(key, ctr, in_out, cpu); + assert_eq!(&buf[..input.len()], expected) + } + } + } +} diff --git a/http/vendor/ring/src/aead/chacha/fallback.rs b/http/vendor/ring/src/aead/chacha/fallback.rs new file mode 100644 index 0000000..38f5430 --- /dev/null +++ b/http/vendor/ring/src/aead/chacha/fallback.rs @@ -0,0 +1,108 @@ +// Copyright 2021 Brian Smith. +// Portions Copyright (c) 2014, Google Inc. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +// Adapted from the public domain, estream code by D. Bernstein. +// Adapted from the BoringSSL crypto/chacha/chacha.c. + +use super::{super::overlapping::IndexError, Counter, Key, Overlapping, BLOCK_LEN}; +use crate::{bb, polyfill::sliceutil}; +use core::mem::size_of; + +pub(super) fn ChaCha20_ctr32(key: &Key, counter: Counter, mut in_out: Overlapping<'_>) { + const SIGMA: [u32; 4] = [ + u32::from_le_bytes(*b"expa"), + u32::from_le_bytes(*b"nd 3"), + u32::from_le_bytes(*b"2-by"), + u32::from_le_bytes(*b"te k"), + ]; + + let key = key.words_less_safe(); + let counter = counter.into_words_less_safe(); + + let mut state = [ + SIGMA[0], SIGMA[1], SIGMA[2], SIGMA[3], key[0], key[1], key[2], key[3], key[4], key[5], + key[6], key[7], counter[0], counter[1], counter[2], counter[3], + ]; + + let mut in_out_len = in_out.len(); + + let mut buf = [0u8; BLOCK_LEN]; + while in_out_len > 0 { + chacha_core(&mut buf, &state); + state[12] += 1; + + debug_assert_eq!(in_out_len, in_out.len()); + + // Both branches do the same thing, but the duplication helps the + // compiler optimize (vectorize) the `BLOCK_LEN` case. + if in_out_len >= BLOCK_LEN { + in_out = in_out + .split_first_chunk::(|in_out| { + bb::xor_assign_at_start(&mut buf, in_out.input()); + sliceutil::overwrite_at_start(in_out.into_unwritten_output(), &buf); + }) + .unwrap_or_else(|IndexError { .. }| { + // Since `in_out_len == in_out.len() && in_out_len >= BLOCK_LEN`. + unreachable!() + }); + } else { + bb::xor_assign_at_start(&mut buf, in_out.input()); + sliceutil::overwrite_at_start(in_out.into_unwritten_output(), &buf); + break; + } + + in_out_len -= BLOCK_LEN; + } +} + +// Performs 20 rounds of ChaCha on `input`, storing the result in `output`. +#[inline(always)] +fn chacha_core(output: &mut [u8; BLOCK_LEN], input: &State) { + let mut x = *input; + + for _ in (0..20).step_by(2) { + quarterround(&mut x, 0, 4, 8, 12); + quarterround(&mut x, 1, 5, 9, 13); + quarterround(&mut x, 2, 6, 10, 14); + quarterround(&mut x, 3, 7, 11, 15); + quarterround(&mut x, 0, 5, 10, 15); + quarterround(&mut x, 1, 6, 11, 12); + quarterround(&mut x, 2, 7, 8, 13); + quarterround(&mut x, 3, 4, 9, 14); + } + + for (x, input) in x.iter_mut().zip(input.iter()) { + *x = x.wrapping_add(*input); + } + + output + .chunks_exact_mut(size_of::()) + .zip(x.iter()) + .for_each(|(output, &x)| output.copy_from_slice(&x.to_le_bytes())); +} + +#[inline(always)] +fn quarterround(x: &mut State, a: usize, b: usize, c: usize, d: usize) { + #[inline(always)] + fn step(x: &mut State, a: usize, b: usize, c: usize, rotation: u32) { + x[a] = x[a].wrapping_add(x[b]); + x[c] = (x[c] ^ x[a]).rotate_left(rotation); + } + step(x, a, b, d, 16); + step(x, c, d, b, 12); + step(x, a, b, d, 8); + step(x, c, d, b, 7); +} + +type State = [u32; BLOCK_LEN / 4]; diff --git a/http/vendor/ring/src/aead/chacha/ffi.rs b/http/vendor/ring/src/aead/chacha/ffi.rs new file mode 100644 index 0000000..bd57013 --- /dev/null +++ b/http/vendor/ring/src/aead/chacha/ffi.rs @@ -0,0 +1,66 @@ +// Copyright 2016-2025 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::{super::overlapping::Overlapping, Counter, Key}; + +// `unsafe { (N, C, InOut) => f }` means that the function `f` is safe to call +// iff the in/out length is at least `N`, the CPU features `C` are available, +// and the input type is `InOut`. If `f` supports overlapping input/output then +// `InOut` should be `Overlapping<'_, u8>`; otherwise it should be `&mut [u8]`. +macro_rules! chacha20_ctr32_ffi { + ( unsafe { ($MIN_LEN:expr, $Cpu:ty, $InOut:ty) => $f:ident }, + $key:expr, $counter:expr, $in_out:expr, $cpu:expr ) => {{ + prefixed_extern! { + fn $f( + out: *mut u8, + in_: *const u8, + in_len: crate::c::size_t, + key: &[u32; 8], + counter: &crate::aead::chacha::Counter, + ); + } + // SAFETY: The user asserts that $f has the signature above and is safe + // to call if additionally we have a value of type `$Cpu` and an in/out + // value of the indicated type, which we do. + unsafe { + crate::aead::chacha::ffi::chacha20_ctr32_ffi::<$InOut, $Cpu, $MIN_LEN>( + $key, $counter, $in_out, $cpu, $f, + ) + } + }}; +} + +// Panics if `in_out.len() < MIN_LEN`. The caller should have guarded against +// that so that the assertion gets optimized away. +pub(super) unsafe fn chacha20_ctr32_ffi< + 'o, + InOut: 'o + Into>, + Cpu, + const MIN_LEN: usize, +>( + key: &Key, + counter: Counter, + in_out: InOut, + cpu: Cpu, + f: unsafe extern "C" fn(*mut u8, *const u8, crate::c::size_t, &[u32; 8], &Counter), +) { + assert!(MIN_LEN > 0); + let in_out: Overlapping<'_, u8> = in_out.into(); + in_out.with_input_output_len(|input, output, len| { + assert!(len >= MIN_LEN); + let key = key.words_less_safe(); + let _: Cpu = cpu; + unsafe { f(output, input, len, key, &counter) } + }); +} diff --git a/http/vendor/ring/src/aead/chacha20_poly1305/integrated.rs b/http/vendor/ring/src/aead/chacha20_poly1305/integrated.rs new file mode 100644 index 0000000..bb7ec28 --- /dev/null +++ b/http/vendor/ring/src/aead/chacha20_poly1305/integrated.rs @@ -0,0 +1,230 @@ +// Copyright 2015-2025 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::{ + super::{NONCE_LEN, TAG_LEN}, + chacha::Overlapping, + check_input_lengths, Aad, InputTooLongError, Key, Nonce, Tag, KEY_LEN, +}; +use cfg_if::cfg_if; + +macro_rules! declare_open { + ( $name:ident ) => { + prefixed_extern! { + fn $name( + out_plaintext: *mut u8, + ciphertext: *const u8, + plaintext_len: usize, + ad: *const u8, + ad_len: usize, + data: &mut InOut, + ); + } + }; +} + +macro_rules! declare_seal { + ( $name:ident ) => { + prefixed_extern! { + fn $name( + out_ciphertext: *mut u8, + plaintext: *const u8, + plaintext_len: usize, + ad: *const u8, + ad_len: usize, + data: &mut InOut, + ); + } + }; +} + +cfg_if! { + if #[cfg(all(target_arch = "aarch64", target_endian = "little"))] { + use crate::cpu::arm::Neon; + type RequiredCpuFeatures = Neon; + type OptionalCpuFeatures = (); + } else { + use crate::cpu::intel::{Avx2, Bmi2, Sse41}; + type RequiredCpuFeatures = Sse41; + type OptionalCpuFeatures = (Avx2, Bmi2); + } +} + +pub(super) fn seal( + Key(key): &Key, + nonce: Nonce, + aad: Aad<&[u8]>, + in_out: &mut [u8], + required_cpu_features: RequiredCpuFeatures, + optional_cpu_features: Option, +) -> Result { + check_input_lengths(aad, in_out)?; + + // XXX: BoringSSL uses `alignas(16)` on `key` instead of on the + // structure, but Rust can't do that yet; see + // https://github.com/rust-lang/rust/issues/73557. + // + // Keep in sync with the anonymous struct of BoringSSL's + // `chacha20_poly1305_seal_data`. + #[repr(align(16), C)] + #[derive(Clone, Copy)] + struct seal_data_in { + key: [u32; KEY_LEN / 4], + counter: u32, + nonce: [u8; NONCE_LEN], + extra_ciphertext: *const u8, + extra_ciphertext_len: usize, + } + + let mut data = InOut { + input: seal_data_in { + key: *key.words_less_safe(), + counter: 0, + nonce: *nonce.as_ref(), + extra_ciphertext: core::ptr::null(), + extra_ciphertext_len: 0, + }, + }; + + // Encrypts `plaintext_len` bytes from `plaintext` and writes them to `out_ciphertext`. + + let output = in_out.as_mut_ptr(); + let input = in_out.as_ptr(); + let len = in_out.len(); + let ad = aad.as_ref().as_ptr(); + let ad_len = aad.as_ref().len(); + + #[allow(clippy::needless_late_init)] + let tag; + + cfg_if! { + if #[cfg(all(target_arch = "aarch64", target_endian = "little"))] { + declare_seal! { chacha20_poly1305_seal } + let _: Neon = required_cpu_features; + let _: Option<()> = optional_cpu_features; + tag = unsafe { + chacha20_poly1305_seal(output, input, len, ad, ad_len, &mut data); + &data.out.tag + }; + } else { + let _: Sse41 = required_cpu_features; + if matches!(optional_cpu_features, Some((Avx2 { .. }, Bmi2 { .. }))) { + declare_seal! { chacha20_poly1305_seal_avx2 } + tag = unsafe { + chacha20_poly1305_seal_avx2(output, input, len, ad, ad_len, &mut data); + &data.out.tag + }; + } else { + declare_seal! { chacha20_poly1305_seal_sse41 } + tag = unsafe { + chacha20_poly1305_seal_sse41(output, input, len, ad, ad_len, &mut data); + &data.out.tag + }; + } + } + } + + Ok(Tag(*tag)) +} + +pub(super) fn open( + Key(key): &Key, + nonce: Nonce, + aad: Aad<&[u8]>, + in_out: Overlapping<'_>, + required_cpu_features: RequiredCpuFeatures, + optional_cpu_features: Option, +) -> Result { + check_input_lengths(aad, in_out.input())?; + + // XXX: BoringSSL uses `alignas(16)` on `key` instead of on the + // structure, but Rust can't do that yet; see + // https://github.com/rust-lang/rust/issues/73557. + // + // Keep in sync with the anonymous struct of BoringSSL's + // `chacha20_poly1305_open_data`. + #[derive(Copy, Clone)] + #[repr(align(16), C)] + struct open_data_in { + key: [u32; KEY_LEN / 4], + counter: u32, + nonce: [u8; NONCE_LEN], + } + + let mut data = InOut { + input: open_data_in { + key: *key.words_less_safe(), + counter: 0, + nonce: *nonce.as_ref(), + }, + }; + + in_out.with_input_output_len(|input, output, len| { + let ad = aad.as_ref().as_ptr(); + let ad_len = aad.as_ref().len(); + + #[allow(clippy::needless_late_init)] + let tag; + + cfg_if! { + if #[cfg(all(target_arch = "aarch64", target_endian = "little"))] { + declare_open! { chacha20_poly1305_open } + let _: Neon = required_cpu_features; + let _: Option<()> = optional_cpu_features; + tag = unsafe { + chacha20_poly1305_open(output, input, len, ad, ad_len, &mut data); + &data.out.tag + }; + } else { + let _: Sse41 = required_cpu_features; + if matches!(optional_cpu_features, Some((Avx2 { .. }, Bmi2 { .. }))) { + declare_open! { chacha20_poly1305_open_avx2 } + tag = unsafe { + chacha20_poly1305_open_avx2(output, input, len, ad, ad_len, &mut data); + &data.out.tag + }; + } else { + declare_open! { chacha20_poly1305_open_sse41 } + tag = unsafe { + chacha20_poly1305_open_sse41(output, input, len, ad, ad_len, &mut data); + &data.out.tag + }; + } + } + } + + Ok(Tag(*tag)) + }) +} + +// Keep in sync with BoringSSL's `chacha20_poly1305_open_data` and +// `chacha20_poly1305_seal_data`. +#[repr(C)] +pub(super) union InOut +where + T: Copy, +{ + pub(super) input: T, + pub(super) out: Out, +} + +// It isn't obvious whether the assembly code works for tags that aren't +// 16-byte aligned. In practice it will always be 16-byte aligned because it +// is embedded in a union where the other member of the union is 16-byte +// aligned. +#[derive(Clone, Copy)] +#[repr(align(16), C)] +pub(super) struct Out { + pub(super) tag: [u8; TAG_LEN], +} diff --git a/http/vendor/ring/src/aead/chacha20_poly1305/mod.rs b/http/vendor/ring/src/aead/chacha20_poly1305/mod.rs new file mode 100644 index 0000000..8817490 --- /dev/null +++ b/http/vendor/ring/src/aead/chacha20_poly1305/mod.rs @@ -0,0 +1,167 @@ +// Copyright 2015-2025 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::{ + chacha::{self, Counter, Overlapping}, + poly1305, Aad, Nonce, Tag, +}; +use crate::{ + cpu, + error::InputTooLongError, + polyfill::{slice, sliceutil, u64_from_usize, usize_from_u64_saturated}, +}; +use cfg_if::cfg_if; + +cfg_if! { + if #[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + target_arch = "x86_64"))] { + use cpu::GetFeature as _; + mod integrated; + } +} + +pub(super) const KEY_LEN: usize = chacha::KEY_LEN; + +const MAX_IN_OUT_LEN: usize = super::max_input_len(64, 1); +// https://tools.ietf.org/html/rfc8439#section-2.8 +const _MAX_IN_OUT_LEN_BOUNDED_BY_RFC: () = + assert!(MAX_IN_OUT_LEN == usize_from_u64_saturated(274_877_906_880u64)); + +#[derive(Clone)] +pub(super) struct Key(chacha::Key); + +impl Key { + pub(super) fn new(value: [u8; KEY_LEN]) -> Self { + Self(chacha::Key::new(value)) + } +} + +pub(super) fn seal( + key: &Key, + nonce: Nonce, + aad: Aad<&[u8]>, + in_out: &mut [u8], + cpu: cpu::Features, +) -> Result { + #[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + target_arch = "x86_64" + ))] + if let Some(required) = cpu.get_feature() { + return integrated::seal(key, nonce, aad, in_out, required, cpu.get_feature()); + } + + seal_fallback(key, nonce, aad, in_out, cpu) +} + +pub(super) fn seal_fallback( + Key(chacha20_key): &Key, + nonce: Nonce, + aad: Aad<&[u8]>, + in_out: &mut [u8], + cpu: cpu::Features, +) -> Result { + let (counter, poly1305_key) = begin(chacha20_key, nonce, aad, in_out, cpu)?; + let mut auth = poly1305::Context::from_key(poly1305_key, cpu); + + poly1305_update_padded_16(&mut auth, aad.as_ref()); + chacha20_key.encrypt(counter, in_out.into(), cpu); + poly1305_update_padded_16(&mut auth, in_out); + Ok(finish(auth, aad.as_ref().len(), in_out.len())) +} + +pub(super) fn open( + key: &Key, + nonce: Nonce, + aad: Aad<&[u8]>, + in_out: Overlapping<'_>, + cpu: cpu::Features, +) -> Result { + #[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + target_arch = "x86_64" + ))] + if let Some(required) = cpu.get_feature() { + return integrated::open(key, nonce, aad, in_out, required, cpu.get_feature()); + } + + open_fallback(key, nonce, aad, in_out, cpu) +} + +pub(super) fn open_fallback( + Key(chacha20_key): &Key, + nonce: Nonce, + aad: Aad<&[u8]>, + in_out: Overlapping<'_>, + cpu: cpu::Features, +) -> Result { + let (counter, poly1305_key) = begin(chacha20_key, nonce, aad, in_out.input(), cpu)?; + let mut auth = poly1305::Context::from_key(poly1305_key, cpu); + + poly1305_update_padded_16(&mut auth, aad.as_ref()); + poly1305_update_padded_16(&mut auth, in_out.input()); + let in_out_len = in_out.len(); + chacha20_key.encrypt(counter, in_out, cpu); + Ok(finish(auth, aad.as_ref().len(), in_out_len)) +} + +fn check_input_lengths(aad: Aad<&[u8]>, input: &[u8]) -> Result<(), InputTooLongError> { + if input.len() > MAX_IN_OUT_LEN { + return Err(InputTooLongError::new(input.len())); + } + + // RFC 8439 Section 2.8 says the maximum AAD length is 2**64 - 1, which is + // never larger than usize::MAX, so we don't need an explicit length + // check. + const _USIZE_BOUNDED_BY_U64: u64 = u64_from_usize(usize::MAX); + let _ = aad; + + Ok(()) +} + +// Also used by chacha20_poly1305_openssh. +pub(super) fn begin( + key: &chacha::Key, + nonce: Nonce, + aad: Aad<&[u8]>, + input: &[u8], + cpu: cpu::Features, +) -> Result<(Counter, poly1305::Key), InputTooLongError> { + check_input_lengths(aad, input)?; + + let mut key_bytes = [0u8; poly1305::KEY_LEN]; + let counter = key.encrypt_single_block_with_ctr_0(nonce, &mut key_bytes, cpu); + let poly1305_key = poly1305::Key::new(key_bytes); + Ok((counter, poly1305_key)) +} + +fn finish(auth: poly1305::Context, aad_len: usize, in_out_len: usize) -> Tag { + let mut block = [0u8; poly1305::BLOCK_LEN]; + let (alen, clen) = block.split_at_mut(poly1305::BLOCK_LEN / 2); + alen.copy_from_slice(&u64::to_le_bytes(u64_from_usize(aad_len))); + clen.copy_from_slice(&u64::to_le_bytes(u64_from_usize(in_out_len))); + auth.finish(&block) +} + +#[inline] +fn poly1305_update_padded_16(ctx: &mut poly1305::Context, input: &[u8]) { + let (whole, remainder) = slice::as_chunks(input); + ctx.update(whole); + if !remainder.is_empty() { + let mut block = [0u8; poly1305::BLOCK_LEN]; + sliceutil::overwrite_at_start(&mut block, remainder); + ctx.update_block(block); + } +} diff --git a/http/vendor/ring/src/aead/chacha20_poly1305_openssh.rs b/http/vendor/ring/src/aead/chacha20_poly1305_openssh.rs new file mode 100644 index 0000000..cf3950b --- /dev/null +++ b/http/vendor/ring/src/aead/chacha20_poly1305_openssh.rs @@ -0,0 +1,212 @@ +// Copyright 2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! The [chacha20-poly1305@openssh.com] AEAD-ish construct. +//! +//! This should only be used by SSH implementations. It has a similar, but +//! different API from `ring::aead` because the construct cannot use the same +//! API as `ring::aead` due to the way the construct handles the encrypted +//! packet length. +//! +//! The concatenation of a and b is denoted `a||b`. `K_1` and `K_2` are defined +//! in the [chacha20-poly1305@openssh.com] specification. `packet_length`, +//! `padding_length`, `payload`, and `random padding` are defined in +//! [RFC 4253]. The term `plaintext` is used as a shorthand for +//! `padding_length||payload||random padding`. +//! +//! [chacha20-poly1305@openssh.com]: +//! http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/PROTOCOL.chacha20poly1305?annotate=HEAD +//! [RFC 4253]: https://tools.ietf.org/html/rfc4253 + +use super::{ + chacha::{self, *}, + chacha20_poly1305, cpu, poly1305, Aad, Nonce, Tag, +}; +use crate::{ + bb, + error::{self, InputTooLongError}, + polyfill::slice, +}; + +/// A key for sealing packets. +pub struct SealingKey { + key: Key, +} + +impl SealingKey { + /// Constructs a new `SealingKey`. + pub fn new(key_material: &[u8; KEY_LEN]) -> Self { + Self { + key: Key::new(key_material), + } + } + + /// Seals (encrypts and signs) a packet. + /// + /// On input, `plaintext_in_ciphertext_out` must contain the unencrypted + /// `packet_length||plaintext` where `plaintext` is the + /// `padding_length||payload||random padding`. It will be overwritten by + /// `encrypted_packet_length||ciphertext`, where `encrypted_packet_length` + /// is encrypted with `K_1` and `ciphertext` is encrypted by `K_2`. + /// + /// # Panics + /// + /// Panics if `plaintext_in_ciphertext_out.len() < PACKET_LENGTH_LEN`. + /// + /// Panics if `plaintext_in_ciphertext_out` is longer than the maximum + /// input size for ChaCha20-Poly1305. Note that this limit is much, + /// much larger than SSH's 256KB maximum record size. + pub fn seal_in_place( + &self, + sequence_number: u32, + plaintext_in_ciphertext_out: &mut [u8], + tag_out: &mut [u8; TAG_LEN], + ) { + // XXX/TODO(SemVer): Refactor API to return an error. + let (len_in_out, data_and_padding_in_out): (&mut [u8; PACKET_LENGTH_LEN], _) = + slice::split_first_chunk_mut(plaintext_in_ciphertext_out).unwrap(); + + let cpu = cpu::features(); + // XXX/TODO(SemVer): Refactor API to return an error. + let (counter, poly_key) = chacha20_poly1305::begin( + &self.key.k_2, + make_nonce(sequence_number), + Aad::from(len_in_out), + data_and_padding_in_out, + cpu, + ) + .map_err(error::erase::) + .unwrap(); + + let _: Counter = self.key.k_1.encrypt_single_block_with_ctr_0( + make_nonce(sequence_number), + len_in_out, + cpu, + ); + self.key + .k_2 + .encrypt(counter, data_and_padding_in_out.into(), cpu); + + let Tag(tag) = poly1305::sign(poly_key, plaintext_in_ciphertext_out, cpu); + *tag_out = tag; + } +} + +/// A key for opening packets. +pub struct OpeningKey { + key: Key, +} + +impl OpeningKey { + /// Constructs a new `OpeningKey`. + pub fn new(key_material: &[u8; KEY_LEN]) -> Self { + Self { + key: Key::new(key_material), + } + } + + /// Returns the decrypted, but unauthenticated, packet length. + /// + /// Importantly, the result won't be authenticated until `open_in_place` is + /// called. + pub fn decrypt_packet_length( + &self, + sequence_number: u32, + encrypted_packet_length: [u8; PACKET_LENGTH_LEN], + ) -> [u8; PACKET_LENGTH_LEN] { + let cpu = cpu::features(); + let mut packet_length = encrypted_packet_length; + let _: Counter = self.key.k_1.encrypt_single_block_with_ctr_0( + make_nonce(sequence_number), + &mut packet_length, + cpu, + ); + packet_length + } + + /// Opens (authenticates and decrypts) a packet. + /// + /// `ciphertext_in_plaintext_out` must be of the form + /// `encrypted_packet_length||ciphertext` where `ciphertext` is the + /// encrypted `plaintext`. When the function succeeds the ciphertext is + /// replaced by the plaintext and the result is `Ok(plaintext)`, where + /// `plaintext` is `&ciphertext_in_plaintext_out[PACKET_LENGTH_LEN..]`; + /// otherwise the contents of `ciphertext_in_plaintext_out` are unspecified + /// and must not be used. + pub fn open_in_place<'a>( + &self, + sequence_number: u32, + ciphertext_in_plaintext_out: &'a mut [u8], + tag: &[u8; TAG_LEN], + ) -> Result<&'a [u8], error::Unspecified> { + let (packet_length, after_packet_length): (&mut [u8; PACKET_LENGTH_LEN], _) = + slice::split_first_chunk_mut(ciphertext_in_plaintext_out).ok_or(error::Unspecified)?; + + let cpu = cpu::features(); + let (counter, poly_key) = chacha20_poly1305::begin( + &self.key.k_2, + make_nonce(sequence_number), + Aad::from(packet_length), + after_packet_length, + cpu, + ) + .map_err(error::erase::)?; + + // We must verify the tag before decrypting so that + // `ciphertext_in_plaintext_out` is unmodified if verification fails. + // This is beyond what we guarantee. + let calculated_tag = poly1305::sign(poly_key, ciphertext_in_plaintext_out, cpu); + bb::verify_slices_are_equal(calculated_tag.as_ref(), tag)?; + + // Won't panic because the length was checked above. + let after_packet_length = &mut ciphertext_in_plaintext_out[PACKET_LENGTH_LEN..]; + + self.key + .k_2 + .encrypt(counter, after_packet_length.into(), cpu); + + Ok(after_packet_length) + } +} + +struct Key { + k_1: chacha::Key, + k_2: chacha::Key, +} + +impl Key { + fn new(key_material: &[u8; KEY_LEN]) -> Self { + // The first half becomes K_2 and the second half becomes K_1. + let (k_2, k_1) = key_material.split_at(chacha::KEY_LEN); + Self { + k_1: chacha::Key::new(k_1.try_into().unwrap()), + k_2: chacha::Key::new(k_2.try_into().unwrap()), + } + } +} + +fn make_nonce(sequence_number: u32) -> Nonce { + let [s0, s1, s2, s3] = sequence_number.to_be_bytes(); + let nonce = [0, 0, 0, 0, 0, 0, 0, 0, s0, s1, s2, s3]; + Nonce::assume_unique_for_key(nonce) +} + +/// The length of key. +pub const KEY_LEN: usize = chacha::KEY_LEN * 2; + +/// The length in bytes of the `packet_length` field in a SSH packet. +pub const PACKET_LENGTH_LEN: usize = 4; // 32 bits + +/// The length in bytes of an authentication tag. +pub const TAG_LEN: usize = super::TAG_LEN; diff --git a/http/vendor/ring/src/aead/gcm.rs b/http/vendor/ring/src/aead/gcm.rs new file mode 100644 index 0000000..443c19e --- /dev/null +++ b/http/vendor/ring/src/aead/gcm.rs @@ -0,0 +1,163 @@ +// Copyright 2018-2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use self::ffi::{Block, BLOCK_LEN, ZERO_BLOCK}; +use super::{aes_gcm, Aad}; +use crate::{ + bits::{BitLength, FromByteLen as _}, + error::{self, InputTooLongError}, + polyfill::{slice::AsChunks, sliceutil::overwrite_at_start, NotSend}, +}; +use cfg_if::cfg_if; + +pub(super) use ffi::KeyValue; + +cfg_if! { + if #[cfg(any(all(target_arch = "aarch64", target_endian = "little"), target_arch = "x86_64"))] { + pub(super) use self::ffi::{HTable, Xi}; + } else { + use self::ffi::{HTable, Xi}; + } +} + +#[macro_use] +mod ffi; + +pub(super) mod clmul; +pub(super) mod clmulavxmovbe; +pub(super) mod fallback; +pub(super) mod neon; +pub(super) mod vclmulavx2; + +pub(super) struct Context<'key, K> { + Xi: Xi, + key: &'key K, + aad_len: BitLength, + in_out_len: BitLength, + _not_send: NotSend, +} + +impl<'key, K: UpdateBlock> Context<'key, K> { + #[inline(always)] + pub(crate) fn new( + key: &'key K, + aad: Aad<&[u8]>, + in_out_len: usize, + ) -> Result { + if in_out_len > aes_gcm::MAX_IN_OUT_LEN { + return Err(error::Unspecified); + } + let in_out_len = + BitLength::from_byte_len(in_out_len).map_err(error::erase::)?; + let aad_len = BitLength::from_byte_len(aad.as_ref().len()) + .map_err(error::erase::)?; + + // NIST SP800-38D Section 5.2.1.1 says that the maximum AAD length is + // 2**64 - 1 bits, i.e. BitLength::MAX, so we don't need to do an + // explicit check here. + + let mut ctx = Self { + Xi: Xi(ZERO_BLOCK), + key, + aad_len, + in_out_len, + _not_send: NotSend::VALUE, + }; + + for ad in aad.0.chunks(BLOCK_LEN) { + let mut block = ZERO_BLOCK; + overwrite_at_start(&mut block, ad); + ctx.update_block(block); + } + + Ok(ctx) + } +} + +#[cfg(all( + target_arch = "aarch64", + target_endian = "little", + target_pointer_width = "64" +))] +impl Context<'_, K> { + pub(super) fn in_out_whole_block_bits(&self) -> BitLength { + use crate::polyfill::usize_from_u64; + const WHOLE_BLOCK_BITS_MASK: usize = !0b111_1111; + #[allow(clippy::assertions_on_constants)] + const _WHOLE_BLOCK_BITS_MASK_CORRECT: () = + assert!(WHOLE_BLOCK_BITS_MASK == !((BLOCK_LEN * 8) - 1)); + BitLength::from_bits(usize_from_u64(self.in_out_len.as_bits()) & WHOLE_BLOCK_BITS_MASK) + } +} + +#[cfg(all(target_arch = "aarch64", target_endian = "little"))] +/// Access to `inner` for the integrated AES-GCM implementations only. +impl Context<'_, clmul::Key> { + #[inline] + pub(super) fn inner(&mut self) -> (&HTable, &mut Xi) { + (&self.key.inner(), &mut self.Xi) + } +} + +#[cfg(target_arch = "x86_64")] +impl Context<'_, clmulavxmovbe::Key> { + /// Access to `inner` for the integrated AES-GCM implementations only. + #[inline] + pub(super) fn inner(&mut self) -> (&HTable, &mut Xi) { + (self.key.inner(), &mut self.Xi) + } +} + +#[cfg(target_arch = "x86_64")] +impl Context<'_, vclmulavx2::Key> { + /// Access to `inner` for the integrated AES-GCM implementations only. + #[inline] + pub(super) fn inner(&mut self) -> (&HTable, &mut Xi) { + (self.key.inner(), &mut self.Xi) + } +} + +impl Context<'_, K> { + #[inline(always)] + pub fn update_blocks(&mut self, input: AsChunks) { + self.key.update_blocks(&mut self.Xi, input); + } +} + +impl Context<'_, K> { + pub fn update_block(&mut self, a: Block) { + self.key.update_block(&mut self.Xi, a); + } + + #[inline(always)] + pub(super) fn pre_finish(mut self, f: F) -> super::Tag + where + F: FnOnce(Block) -> super::Tag, + { + let mut block = [0u8; BLOCK_LEN]; + let (alen, clen) = block.split_at_mut(BLOCK_LEN / 2); + alen.copy_from_slice(&BitLength::::to_be_bytes(self.aad_len)); + clen.copy_from_slice(&BitLength::::to_be_bytes(self.in_out_len)); + self.update_block(block); + f(self.Xi.0) + } +} + +pub(super) trait UpdateBlock { + fn update_block(&self, xi: &mut Xi, a: Block); +} + +pub(super) trait UpdateBlocks { + fn update_blocks(&self, xi: &mut Xi, input: AsChunks); +} diff --git a/http/vendor/ring/src/aead/gcm/clmul.rs b/http/vendor/ring/src/aead/gcm/clmul.rs new file mode 100644 index 0000000..8cd55a4 --- /dev/null +++ b/http/vendor/ring/src/aead/gcm/clmul.rs @@ -0,0 +1,73 @@ +// Copyright 2018-2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#![cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + target_arch = "x86", + target_arch = "x86_64" +))] + +use super::{ffi::KeyValue, HTable, UpdateBlock, Xi}; +use crate::aead::gcm::ffi::BLOCK_LEN; +use crate::cpu; +#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +use {super::UpdateBlocks, crate::polyfill::slice::AsChunks}; + +#[cfg(all(target_arch = "aarch64", target_endian = "little"))] +pub(in super::super) type RequiredCpuFeatures = cpu::arm::PMull; + +#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +pub(in super::super) type RequiredCpuFeatures = (cpu::intel::ClMul, cpu::intel::Ssse3); + +#[derive(Clone)] +pub struct Key { + h_table: HTable, +} + +impl Key { + #[cfg_attr(target_arch = "x86_64", inline(never))] + pub(in super::super) fn new(value: KeyValue, _cpu: RequiredCpuFeatures) -> Self { + Self { + h_table: unsafe { htable_new!(gcm_init_clmul, value) }, + } + } + + #[cfg(target_arch = "aarch64")] + pub(super) fn inner(&self) -> &HTable { + &self.h_table + } +} + +impl UpdateBlock for Key { + #[cfg(target_arch = "aarch64")] + fn update_block(&self, xi: &mut Xi, a: [u8; BLOCK_LEN]) { + prefixed_extern! { + fn gcm_gmult_clmul(xi: &mut Xi, Htable: &HTable); + } + xi.bitxor_assign(a); + unsafe { self.h_table.gmult(gcm_gmult_clmul, xi) }; + } + + #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] + fn update_block(&self, xi: &mut Xi, a: [u8; BLOCK_LEN]) { + self.update_blocks(xi, (&a).into()) + } +} + +#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +impl UpdateBlocks for Key { + fn update_blocks(&self, xi: &mut Xi, input: AsChunks) { + unsafe { ghash!(gcm_ghash_clmul, xi, &self.h_table, input) } + } +} diff --git a/http/vendor/ring/src/aead/gcm/clmulavxmovbe.rs b/http/vendor/ring/src/aead/gcm/clmulavxmovbe.rs new file mode 100644 index 0000000..c53e241 --- /dev/null +++ b/http/vendor/ring/src/aead/gcm/clmulavxmovbe.rs @@ -0,0 +1,51 @@ +// Copyright 2018-2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#![cfg(target_arch = "x86_64")] + +use super::{HTable, KeyValue, UpdateBlock, UpdateBlocks, Xi, BLOCK_LEN}; +use crate::{cpu::intel, polyfill::slice::AsChunks}; + +#[derive(Clone)] +pub struct Key { + h_table: HTable, +} + +impl Key { + #[inline(never)] + pub(in super::super) fn new( + value: KeyValue, + _required_cpu_features: (intel::ClMul, intel::Avx, intel::Movbe), + ) -> Self { + Self { + h_table: unsafe { htable_new!(gcm_init_avx, value) }, + } + } + + pub(super) fn inner(&self) -> &HTable { + &self.h_table + } +} + +impl UpdateBlock for Key { + fn update_block(&self, xi: &mut Xi, a: [u8; BLOCK_LEN]) { + self.update_blocks(xi, (&a).into()) + } +} + +impl UpdateBlocks for Key { + fn update_blocks(&self, xi: &mut Xi, input: AsChunks) { + unsafe { ghash!(gcm_ghash_avx, xi, self.inner(), input) } + } +} diff --git a/http/vendor/ring/src/aead/gcm/fallback.rs b/http/vendor/ring/src/aead/gcm/fallback.rs new file mode 100644 index 0000000..4d5403b --- /dev/null +++ b/http/vendor/ring/src/aead/gcm/fallback.rs @@ -0,0 +1,271 @@ +// Copyright (c) 2019, Google Inc. +// Portions Copyright 2020-2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +// This file is based on BoringSSL's gcm_nohw.c. + +// This file contains a implementation of GHASH based on the notes +// in https://bearssl.org/constanttime.html#ghash-for-gcm and the reduction +// algorithm described in +// https://crypto.stanford.edu/RealWorldCrypto/slides/gueron.pdf. +// +// Unlike the BearSSL notes, we use u128 in the 64-bit implementation. + +use super::{ffi::U128, KeyValue, UpdateBlock, UpdateBlocks, Xi, BLOCK_LEN}; +use crate::polyfill::{slice::AsChunks, ArraySplitMap as _}; + +#[derive(Clone)] +pub struct Key { + h: U128, +} + +impl Key { + pub(in super::super) fn new(value: KeyValue) -> Self { + Self { h: init(value) } + } +} + +impl UpdateBlock for Key { + fn update_block(&self, xi: &mut Xi, a: [u8; BLOCK_LEN]) { + xi.bitxor_assign(a); + gmult(xi, self.h); + } +} + +impl UpdateBlocks for Key { + fn update_blocks(&self, xi: &mut Xi, input: AsChunks) { + ghash(xi, self.h, input); + } +} + +#[cfg(target_pointer_width = "64")] +fn gcm_mul64_nohw(a: u64, b: u64) -> (u64, u64) { + #[allow(clippy::cast_possible_truncation)] + #[inline(always)] + fn lo(a: u128) -> u64 { + a as u64 + } + + #[inline(always)] + fn hi(a: u128) -> u64 { + lo(a >> 64) + } + + #[inline(always)] + fn mul(a: u64, b: u64) -> u128 { + u128::from(a) * u128::from(b) + } + + // One term every four bits means the largest term is 64/4 = 16, which barely + // overflows into the next term. Using one term every five bits would cost 25 + // multiplications instead of 16. It is faster to mask off the bottom four + // bits of |a|, giving a largest term of 60/4 = 15, and apply the bottom bits + // separately. + let a0 = a & 0x1111111111111110; + let a1 = a & 0x2222222222222220; + let a2 = a & 0x4444444444444440; + let a3 = a & 0x8888888888888880; + + let b0 = b & 0x1111111111111111; + let b1 = b & 0x2222222222222222; + let b2 = b & 0x4444444444444444; + let b3 = b & 0x8888888888888888; + + let c0 = mul(a0, b0) ^ mul(a1, b3) ^ mul(a2, b2) ^ mul(a3, b1); + let c1 = mul(a0, b1) ^ mul(a1, b0) ^ mul(a2, b3) ^ mul(a3, b2); + let c2 = mul(a0, b2) ^ mul(a1, b1) ^ mul(a2, b0) ^ mul(a3, b3); + let c3 = mul(a0, b3) ^ mul(a1, b2) ^ mul(a2, b1) ^ mul(a3, b0); + + // Multiply the bottom four bits of |a| with |b|. + let a0_mask = 0u64.wrapping_sub(a & 1); + let a1_mask = 0u64.wrapping_sub((a >> 1) & 1); + let a2_mask = 0u64.wrapping_sub((a >> 2) & 1); + let a3_mask = 0u64.wrapping_sub((a >> 3) & 1); + let extra = u128::from(a0_mask & b) + ^ (u128::from(a1_mask & b) << 1) + ^ (u128::from(a2_mask & b) << 2) + ^ (u128::from(a3_mask & b) << 3); + + let lo = (lo(c0) & 0x1111111111111111) + ^ (lo(c1) & 0x2222222222222222) + ^ (lo(c2) & 0x4444444444444444) + ^ (lo(c3) & 0x8888888888888888) + ^ lo(extra); + let hi = (hi(c0) & 0x1111111111111111) + ^ (hi(c1) & 0x2222222222222222) + ^ (hi(c2) & 0x4444444444444444) + ^ (hi(c3) & 0x8888888888888888) + ^ hi(extra); + (lo, hi) +} + +#[cfg(not(target_pointer_width = "64"))] +fn gcm_mul32_nohw(a: u32, b: u32) -> u64 { + #[inline(always)] + fn mul(a: u32, b: u32) -> u64 { + u64::from(a) * u64::from(b) + } + + // One term every four bits means the largest term is 32/4 = 8, which does not + // overflow into the next term. + let a0 = a & 0x11111111; + let a1 = a & 0x22222222; + let a2 = a & 0x44444444; + let a3 = a & 0x88888888; + + let b0 = b & 0x11111111; + let b1 = b & 0x22222222; + let b2 = b & 0x44444444; + let b3 = b & 0x88888888; + + let c0 = mul(a0, b0) ^ mul(a1, b3) ^ mul(a2, b2) ^ mul(a3, b1); + let c1 = mul(a0, b1) ^ mul(a1, b0) ^ mul(a2, b3) ^ mul(a3, b2); + let c2 = mul(a0, b2) ^ mul(a1, b1) ^ mul(a2, b0) ^ mul(a3, b3); + let c3 = mul(a0, b3) ^ mul(a1, b2) ^ mul(a2, b1) ^ mul(a3, b0); + + (c0 & 0x1111111111111111) + | (c1 & 0x2222222222222222) + | (c2 & 0x4444444444444444) + | (c3 & 0x8888888888888888) +} + +#[cfg(not(target_pointer_width = "64"))] +fn gcm_mul64_nohw(a: u64, b: u64) -> (u64, u64) { + #[inline(always)] + fn lo(a: u64) -> u32 { + a as u32 + } + #[inline(always)] + fn hi(a: u64) -> u32 { + lo(a >> 32) + } + + let a0 = lo(a); + let a1 = hi(a); + let b0 = lo(b); + let b1 = hi(b); + // Karatsuba multiplication. + let lo = gcm_mul32_nohw(a0, b0); + let hi = gcm_mul32_nohw(a1, b1); + let mid = gcm_mul32_nohw(a0 ^ a1, b0 ^ b1) ^ lo ^ hi; + (lo ^ (mid << 32), hi ^ (mid >> 32)) +} + +fn init(value: KeyValue) -> U128 { + let xi = value.into_inner(); + + // We implement GHASH in terms of POLYVAL, as described in RFC 8452. This + // avoids a shift by 1 in the multiplication, needed to account for bit + // reversal losing a bit after multiplication, that is, + // rev128(X) * rev128(Y) = rev255(X*Y). + // + // Per Appendix A, we run mulX_POLYVAL. Note this is the same transformation + // applied by |gcm_init_clmul|, etc. Note |Xi| has already been byteswapped. + // + // See also slide 16 of + // https://crypto.stanford.edu/RealWorldCrypto/slides/gueron.pdf + let mut lo = xi[1]; + let mut hi = xi[0]; + + let mut carry = hi >> 63; + carry = 0u64.wrapping_sub(carry); + + hi <<= 1; + hi |= lo >> 63; + lo <<= 1; + + // The irreducible polynomial is 1 + x^121 + x^126 + x^127 + x^128, so we + // conditionally add 0xc200...0001. + lo ^= carry & 1; + hi ^= carry & 0xc200000000000000; + + // This implementation does not use the rest of |Htable|. + U128 { hi, lo } +} + +fn gcm_polyval_nohw(xi: &mut [u64; 2], h: U128) { + // Karatsuba multiplication. The product of |Xi| and |H| is stored in |r0| + // through |r3|. Note there is no byte or bit reversal because we are + // evaluating POLYVAL. + let (r0, mut r1) = gcm_mul64_nohw(xi[0], h.lo); + let (mut r2, mut r3) = gcm_mul64_nohw(xi[1], h.hi); + let (mut mid0, mut mid1) = gcm_mul64_nohw(xi[0] ^ xi[1], h.hi ^ h.lo); + mid0 ^= r0 ^ r2; + mid1 ^= r1 ^ r3; + r2 ^= mid1; + r1 ^= mid0; + + // Now we multiply our 256-bit result by x^-128 and reduce. |r2| and + // |r3| shifts into position and we must multiply |r0| and |r1| by x^-128. We + // have: + // + // 1 = x^121 + x^126 + x^127 + x^128 + // x^-128 = x^-7 + x^-2 + x^-1 + 1 + // + // This is the GHASH reduction step, but with bits flowing in reverse. + + // The x^-7, x^-2, and x^-1 terms shift bits past x^0, which would require + // another reduction steps. Instead, we gather the excess bits, incorporate + // them into |r0| and |r1| and reduce once. See slides 17-19 + // of https://crypto.stanford.edu/RealWorldCrypto/slides/gueron.pdf. + r1 ^= (r0 << 63) ^ (r0 << 62) ^ (r0 << 57); + + // 1 + r2 ^= r0; + r3 ^= r1; + + // x^-1 + r2 ^= r0 >> 1; + r2 ^= r1 << 63; + r3 ^= r1 >> 1; + + // x^-2 + r2 ^= r0 >> 2; + r2 ^= r1 << 62; + r3 ^= r1 >> 2; + + // x^-7 + r2 ^= r0 >> 7; + r2 ^= r1 << 57; + r3 ^= r1 >> 7; + + *xi = [r2, r3]; +} + +fn gmult(xi: &mut Xi, h: U128) { + with_swapped_xi(xi, |swapped| { + gcm_polyval_nohw(swapped, h); + }) +} + +fn ghash(xi: &mut Xi, h: U128, input: AsChunks) { + with_swapped_xi(xi, |swapped| { + input.into_iter().for_each(|&input| { + let input = input.array_split_map(u64::from_be_bytes); + swapped[0] ^= input[1]; + swapped[1] ^= input[0]; + gcm_polyval_nohw(swapped, h); + }); + }); +} + +#[inline] +fn with_swapped_xi(Xi(xi): &mut Xi, f: impl FnOnce(&mut [u64; 2])) { + let unswapped: [u64; 2] = xi.array_split_map(u64::from_be_bytes); + let mut swapped: [u64; 2] = [unswapped[1], unswapped[0]]; + f(&mut swapped); + let (xi_0, xi_1) = xi.split_at_mut(BLOCK_LEN / 2); + xi_0.copy_from_slice(&u64::to_be_bytes(swapped[1])); + xi_1.copy_from_slice(&u64::to_be_bytes(swapped[0])); +} diff --git a/http/vendor/ring/src/aead/gcm/ffi.rs b/http/vendor/ring/src/aead/gcm/ffi.rs new file mode 100644 index 0000000..c655a0d --- /dev/null +++ b/http/vendor/ring/src/aead/gcm/ffi.rs @@ -0,0 +1,165 @@ +// Copyright 2018 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use crate::{ + bb, + polyfill::{slice::AsChunks, ArraySplitMap}, +}; + +pub(in super::super) const BLOCK_LEN: usize = 16; +pub(in super::super) type Block = [u8; BLOCK_LEN]; +pub(super) const ZERO_BLOCK: Block = [0u8; BLOCK_LEN]; + +#[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little"), + target_arch = "x86", + target_arch = "x86_64" +))] +macro_rules! htable_new { + ( $name:ident, $value:expr $(,)? ) => {{ + use crate::aead::gcm::ffi::HTable; + prefixed_extern! { + fn $name(HTable: &mut HTable, h: &[u64; 2]); + } + HTable::new($name, $value) + }}; +} + +/// SAFETY: +/// * The function `$name` must meet the contract of the `f` paramweter of +/// `ghash()`. +#[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little"), + target_arch = "x86", + target_arch = "x86_64" +))] +macro_rules! ghash { + ( $name:ident, $xi:expr, $h_table:expr, $input:expr $(,)? ) => {{ + use crate::aead::gcm::ffi::{HTable, Xi}; + prefixed_extern! { + fn $name( + xi: &mut Xi, + Htable: &HTable, + inp: *const u8, + len: crate::c::NonZero_size_t, + ); + } + $h_table.ghash($name, $xi, $input) + }}; +} + +pub(in super::super) struct KeyValue([u64; 2]); + +impl KeyValue { + pub(in super::super) fn new(value: Block) -> Self { + Self(value.array_split_map(u64::from_be_bytes)) + } + + pub(super) fn into_inner(self) -> [u64; 2] { + self.0 + } +} + +/// SAFETY: +/// * `f` must read `len` bytes from `inp`; it may assume +/// that `len` is a (non-zero) multiple of `BLOCK_LEN`. +/// * `f` may inspect CPU features. +#[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little"), + target_arch = "x86", + target_arch = "x86_64" +))] +impl HTable { + pub(super) unsafe fn new( + init: unsafe extern "C" fn(HTable: &mut HTable, &[u64; 2]), + value: KeyValue, + ) -> Self { + let mut r = Self { + Htable: [U128 { hi: 0, lo: 0 }; HTABLE_LEN], + }; + unsafe { init(&mut r, &value.0) }; + r + } + + #[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little") + ))] + pub(super) unsafe fn gmult( + &self, + f: unsafe extern "C" fn(xi: &mut Xi, h_table: &HTable), + xi: &mut Xi, + ) { + unsafe { f(xi, self) } + } + + pub(super) unsafe fn ghash( + &self, + f: unsafe extern "C" fn( + xi: &mut Xi, + Htable: &HTable, + inp: *const u8, + len: crate::c::NonZero_size_t, + ), + xi: &mut Xi, + input: AsChunks, + ) { + use core::num::NonZeroUsize; + + let input = input.as_flattened(); + + let input_len = match NonZeroUsize::new(input.len()) { + Some(len) => len, + None => { + return; + } + }; + + // SAFETY: + // * There are `input_len: NonZeroUsize` bytes available at `input` for + // `f` to read. + unsafe { + f(xi, self, input.as_ptr(), input_len); + } + } +} + +// The alignment is required by some assembly code, such as `ghash-ssse3-*`. +#[derive(Clone)] +#[repr(C, align(16))] +pub(in super::super) struct HTable { + Htable: [U128; HTABLE_LEN], +} + +#[derive(Clone, Copy)] +#[repr(C)] +pub(super) struct U128 { + pub(super) hi: u64, + pub(super) lo: u64, +} + +const HTABLE_LEN: usize = 16; + +#[repr(transparent)] +pub(in super::super) struct Xi(pub(super) Block); + +impl Xi { + #[inline] + pub(super) fn bitxor_assign(&mut self, a: Block) { + self.0 = bb::xor_16(self.0, a) + } +} diff --git a/http/vendor/ring/src/aead/gcm/neon.rs b/http/vendor/ring/src/aead/gcm/neon.rs new file mode 100644 index 0000000..814cd52 --- /dev/null +++ b/http/vendor/ring/src/aead/gcm/neon.rs @@ -0,0 +1,52 @@ +// Copyright 2018-2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#![cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little") +))] + +use super::{HTable, KeyValue, UpdateBlock, UpdateBlocks, Xi, BLOCK_LEN}; +use crate::{cpu, polyfill::slice::AsChunks}; + +pub(in super::super) type RequiredCpuFeatures = cpu::arm::Neon; + +#[derive(Clone)] +pub struct Key { + h_table: HTable, +} + +impl Key { + pub(in super::super) fn new(value: KeyValue, _cpu: RequiredCpuFeatures) -> Self { + Self { + h_table: unsafe { htable_new!(gcm_init_neon, value) }, + } + } +} + +impl UpdateBlock for Key { + fn update_block(&self, xi: &mut Xi, a: [u8; BLOCK_LEN]) { + prefixed_extern! { + fn gcm_gmult_neon(xi: &mut Xi, Htable: &HTable); + } + xi.bitxor_assign(a); + unsafe { self.h_table.gmult(gcm_gmult_neon, xi) }; + } +} + +impl UpdateBlocks for Key { + fn update_blocks(&self, xi: &mut Xi, input: AsChunks) { + unsafe { ghash!(gcm_ghash_neon, xi, &self.h_table, input) } + } +} diff --git a/http/vendor/ring/src/aead/gcm/vclmulavx2.rs b/http/vendor/ring/src/aead/gcm/vclmulavx2.rs new file mode 100644 index 0000000..ebf4e76 --- /dev/null +++ b/http/vendor/ring/src/aead/gcm/vclmulavx2.rs @@ -0,0 +1,46 @@ +// Copyright 2018-2025 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#![cfg(target_arch = "x86_64")] + +use super::{ffi::KeyValue, HTable, UpdateBlock, Xi}; +use crate::{ + aead::gcm::ffi::BLOCK_LEN, + cpu::intel::{Avx2, VAesClmul}, + polyfill::slice::AsChunks, +}; + +#[derive(Clone)] +pub struct Key { + h_table: HTable, +} + +impl Key { + pub(in super::super) fn new(value: KeyValue, _cpu: (Avx2, VAesClmul)) -> Self { + Self { + h_table: unsafe { htable_new!(gcm_init_vpclmulqdq_avx2, value) }, + } + } + + pub(super) fn inner(&self) -> &HTable { + &self.h_table + } +} + +impl UpdateBlock for Key { + fn update_block(&self, xi: &mut Xi, a: [u8; BLOCK_LEN]) { + let input: AsChunks = (&a).into(); + unsafe { ghash!(gcm_ghash_vpclmulqdq_avx2_1, xi, &self.h_table, input) } + } +} diff --git a/http/vendor/ring/src/aead/less_safe_key.rs b/http/vendor/ring/src/aead/less_safe_key.rs new file mode 100644 index 0000000..10483fc --- /dev/null +++ b/http/vendor/ring/src/aead/less_safe_key.rs @@ -0,0 +1,181 @@ +// Copyright 2015-2021 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::{Aad, Algorithm, KeyInner, Nonce, Tag, UnboundKey, TAG_LEN}; +use crate::{cpu, error}; +use core::ops::RangeFrom; + +/// Immutable keys for use in situations where `OpeningKey`/`SealingKey` and +/// `NonceSequence` cannot reasonably be used. +/// +/// Prefer to use `OpeningKey`/`SealingKey` and `NonceSequence` when practical. +#[derive(Clone)] +pub struct LessSafeKey { + inner: KeyInner, + algorithm: &'static Algorithm, +} + +impl LessSafeKey { + /// Constructs a `LessSafeKey`. + #[inline] + pub fn new(key: UnboundKey) -> Self { + key.into_inner() + } + + pub(super) fn new_( + algorithm: &'static Algorithm, + key_bytes: &[u8], + cpu_features: cpu::Features, + ) -> Result { + Ok(Self { + inner: algorithm.new_key(key_bytes, cpu_features)?, + algorithm, + }) + } + + /// Like [open_in_place](Self::open_in_place), except the authentication tag is + /// passed separately. + #[inline] + pub fn open_in_place_separate_tag<'in_out, A>( + &self, + nonce: Nonce, + aad: Aad, + tag: Tag, + in_out: &'in_out mut [u8], + ciphertext: RangeFrom, + ) -> Result<&'in_out mut [u8], error::Unspecified> + where + A: AsRef<[u8]>, + { + let aad = Aad::from(aad.as_ref()); + self.algorithm.open_within( + &self.inner, + nonce, + aad, + tag, + in_out, + ciphertext, + cpu::features(), + ) + } + + /// Like [`super::OpeningKey::open_in_place()`], except it accepts an + /// arbitrary nonce. + /// + /// `nonce` must be unique for every use of the key to open data. + #[inline] + pub fn open_in_place<'in_out, A>( + &self, + nonce: Nonce, + aad: Aad, + in_out: &'in_out mut [u8], + ) -> Result<&'in_out mut [u8], error::Unspecified> + where + A: AsRef<[u8]>, + { + self.open_within(nonce, aad, in_out, 0..) + } + + /// Like [`super::OpeningKey::open_within()`], except it accepts an + /// arbitrary nonce. + /// + /// `nonce` must be unique for every use of the key to open data. + #[inline] + pub fn open_within<'in_out, A>( + &self, + nonce: Nonce, + aad: Aad, + in_out: &'in_out mut [u8], + ciphertext_and_tag: RangeFrom, + ) -> Result<&'in_out mut [u8], error::Unspecified> + where + A: AsRef<[u8]>, + { + let tag_offset = in_out + .len() + .checked_sub(TAG_LEN) + .ok_or(error::Unspecified)?; + + // Split the tag off the end of `in_out`. + let (in_out, received_tag) = in_out.split_at_mut(tag_offset); + let received_tag = (*received_tag).try_into()?; + let ciphertext = ciphertext_and_tag; + + self.open_in_place_separate_tag(nonce, aad, received_tag, in_out, ciphertext) + } + + /// Like [`super::SealingKey::seal_in_place_append_tag()`], except it + /// accepts an arbitrary nonce. + /// + /// `nonce` must be unique for every use of the key to seal data. + #[inline] + pub fn seal_in_place_append_tag( + &self, + nonce: Nonce, + aad: Aad, + in_out: &mut InOut, + ) -> Result<(), error::Unspecified> + where + A: AsRef<[u8]>, + InOut: AsMut<[u8]> + for<'in_out> Extend<&'in_out u8>, + { + self.seal_in_place_separate_tag(nonce, aad, in_out.as_mut()) + .map(|tag| in_out.extend(tag.as_ref())) + } + + /// Like `super::SealingKey::seal_in_place_separate_tag()`, except it + /// accepts an arbitrary nonce. + /// + /// `nonce` must be unique for every use of the key to seal data. + #[inline] + pub fn seal_in_place_separate_tag( + &self, + nonce: Nonce, + aad: Aad, + in_out: &mut [u8], + ) -> Result + where + A: AsRef<[u8]>, + { + self.algorithm.seal( + &self.inner, + nonce, + Aad::from(aad.as_ref()), + in_out, + cpu::features(), + ) + } + + /// The key's AEAD algorithm. + #[inline] + pub fn algorithm(&self) -> &'static Algorithm { + self.algorithm + } + + pub(super) fn fmt_debug( + &self, + type_name: &'static str, + f: &mut core::fmt::Formatter, + ) -> Result<(), core::fmt::Error> { + f.debug_struct(type_name) + .field("algorithm", &self.algorithm()) + .finish() + } +} + +impl core::fmt::Debug for LessSafeKey { + fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> { + self.fmt_debug("LessSafeKey", f) + } +} diff --git a/http/vendor/ring/src/aead/nonce.rs b/http/vendor/ring/src/aead/nonce.rs new file mode 100644 index 0000000..e314fae --- /dev/null +++ b/http/vendor/ring/src/aead/nonce.rs @@ -0,0 +1,51 @@ +// Copyright 2018 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use crate::error; + +/// A nonce for a single AEAD opening or sealing operation. +/// +/// The user must ensure, for a particular key, that each nonce is unique. +/// +/// `Nonce` intentionally doesn't implement `Clone` to ensure that each one is +/// consumed at most once. +pub struct Nonce([u8; NONCE_LEN]); + +impl Nonce { + /// Constructs a `Nonce` with the given value, assuming that the value is + /// unique for the lifetime of the key it is being used with. + /// + /// Fails if `value` isn't `NONCE_LEN` bytes long. + #[inline] + pub fn try_assume_unique_for_key(value: &[u8]) -> Result { + let value: &[u8; NONCE_LEN] = value.try_into()?; + Ok(Self::assume_unique_for_key(*value)) + } + + /// Constructs a `Nonce` with the given value, assuming that the value is + /// unique for the lifetime of the key it is being used with. + #[inline] + pub fn assume_unique_for_key(value: [u8; NONCE_LEN]) -> Self { + Self(value) + } +} + +impl AsRef<[u8; NONCE_LEN]> for Nonce { + fn as_ref(&self) -> &[u8; NONCE_LEN] { + &self.0 + } +} + +/// All the AEADs we support use 96-bit nonces. +pub const NONCE_LEN: usize = 96 / 8; diff --git a/http/vendor/ring/src/aead/opening_key.rs b/http/vendor/ring/src/aead/opening_key.rs new file mode 100644 index 0000000..9e10fc9 --- /dev/null +++ b/http/vendor/ring/src/aead/opening_key.rs @@ -0,0 +1,143 @@ +// Copyright 2015-2021 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! Authenticated Encryption with Associated Data (AEAD). +//! +//! See [Authenticated encryption: relations among notions and analysis of the +//! generic composition paradigm][AEAD] for an introduction to the concept of +//! AEADs. +//! +//! [AEAD]: https://eprint.iacr.org/2000/025.pdf +//! [`crypto.cipher.AEAD`]: https://golang.org/pkg/crypto/cipher/#AEAD + +use super::{Aad, Algorithm, BoundKey, LessSafeKey, NonceSequence, UnboundKey}; +use crate::error; +use core::ops::RangeFrom; + +/// An AEAD key for authenticating and decrypting ("opening"), bound to a nonce +/// sequence. +/// +/// Intentionally not `Clone` or `Copy` since cloning would allow duplication +/// of the nonce sequence. +pub struct OpeningKey { + key: LessSafeKey, + nonce_sequence: N, +} + +impl BoundKey for OpeningKey { + fn new(key: UnboundKey, nonce_sequence: N) -> Self { + Self { + key: key.into_inner(), + nonce_sequence, + } + } + + #[inline] + fn algorithm(&self) -> &'static Algorithm { + self.key.algorithm() + } +} + +impl core::fmt::Debug for OpeningKey { + fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> { + self.key.fmt_debug("OpeningKey", f) + } +} + +impl OpeningKey { + /// Authenticates and decrypts (“opens”) data in place. + /// + /// `aad` is the additional authenticated data (AAD), if any. + /// + /// On input, `in_out` must be the ciphertext followed by the tag. When + /// `open_in_place()` returns `Ok(plaintext)`, the input ciphertext + /// has been overwritten by the plaintext; `plaintext` will refer to the + /// plaintext without the tag. + /// + /// When `open_in_place()` returns `Err(..)`, `in_out` may have been + /// overwritten in an unspecified way. + #[inline] + pub fn open_in_place<'in_out, A>( + &mut self, + aad: Aad, + in_out: &'in_out mut [u8], + ) -> Result<&'in_out mut [u8], error::Unspecified> + where + A: AsRef<[u8]>, + { + self.key + .open_in_place(self.nonce_sequence.advance()?, aad, in_out) + } + + /// Authenticates and decrypts (“opens”) data in place, with a shift. + /// + /// `aad` is the additional authenticated data (AAD), if any. + /// + /// On input, `in_out[ciphertext_and_tag]` must be the ciphertext followed + /// by the tag. When `open_within()` returns `Ok(plaintext)`, the plaintext + /// will be at `in_out[0..plaintext.len()]`. In other words, the following + /// two code fragments are equivalent for valid values of + /// `ciphertext_and_tag`, except `open_within` will often be more efficient: + /// + /// + /// ```skip + /// let plaintext = key.open_within(aad, in_out, cipertext_and_tag)?; + /// ``` + /// + /// ```skip + /// let ciphertext_and_tag_len = in_out[ciphertext_and_tag].len(); + /// in_out.copy_within(ciphertext_and_tag, 0); + /// let plaintext = key.open_in_place(aad, &mut in_out[..ciphertext_and_tag_len])?; + /// ``` + /// + /// Similarly, `key.open_within(aad, in_out, 0..)` is equivalent to + /// `key.open_in_place(aad, in_out)`. + /// + /// When `open_in_place()` returns `Err(..)`, `in_out` may have been + /// overwritten in an unspecified way. + /// + /// The shifting feature is useful in the case where multiple packets are + /// being reassembled in place. Consider this example where the peer has + /// sent the message “Split stream reassembled in place” split into + /// three sealed packets: + /// + /// ```ascii-art + /// Packet 1 Packet 2 Packet 3 + /// Input: [Header][Ciphertext][Tag][Header][Ciphertext][Tag][Header][Ciphertext][Tag] + /// | +--------------+ | + /// +------+ +-----+ +----------------------------------+ + /// v v v + /// Output: [Plaintext][Plaintext][Plaintext] + /// “Split stream reassembled in place” + /// ``` + /// + /// This reassembly can be accomplished with three calls to `open_within()`. + #[inline] + pub fn open_within<'in_out, A>( + &mut self, + aad: Aad, + in_out: &'in_out mut [u8], + ciphertext_and_tag: RangeFrom, + ) -> Result<&'in_out mut [u8], error::Unspecified> + where + A: AsRef<[u8]>, + { + self.key.open_within( + self.nonce_sequence.advance()?, + aad, + in_out, + ciphertext_and_tag, + ) + } +} diff --git a/http/vendor/ring/src/aead/overlapping/array.rs b/http/vendor/ring/src/aead/overlapping/array.rs new file mode 100644 index 0000000..9c797da --- /dev/null +++ b/http/vendor/ring/src/aead/overlapping/array.rs @@ -0,0 +1,60 @@ +// Copyright 2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#![cfg_attr(not(test), allow(dead_code))] + +use super::Overlapping; +use crate::error::LenMismatchError; +use core::array::TryFromSliceError; + +pub struct Array<'o, T, const N: usize> { + // Invariant: N != 0. + // Invariant: `self.in_out.len() == N`. + in_out: Overlapping<'o, T>, +} + +impl<'o, T, const N: usize> Array<'o, T, N> { + pub(super) fn new(in_out: Overlapping<'o, T>) -> Result { + if N == 0 || in_out.len() != N { + return Err(LenMismatchError::new(N)); + } + Ok(Self { in_out }) + } + + pub fn into_unwritten_output(self) -> &'o mut [T; N] + where + &'o mut [T]: TryInto<&'o mut [T; N], Error = TryFromSliceError>, + { + self.in_out + .into_unwritten_output() + .try_into() + .unwrap_or_else(|TryFromSliceError { .. }| { + unreachable!() // Due to invariant + }) + } +} + +impl Array<'_, T, N> { + pub fn input<'s>(&'s self) -> &'s [T; N] + where + &'s [T]: TryInto<&'s [T; N], Error = TryFromSliceError>, + { + self.in_out + .input() + .try_into() + .unwrap_or_else(|TryFromSliceError { .. }| { + unreachable!() // Due to invariant + }) + } +} diff --git a/http/vendor/ring/src/aead/overlapping/base.rs b/http/vendor/ring/src/aead/overlapping/base.rs new file mode 100644 index 0000000..6923587 --- /dev/null +++ b/http/vendor/ring/src/aead/overlapping/base.rs @@ -0,0 +1,152 @@ +// Copyright 2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +pub use self::index_error::IndexError; +use super::Array; +use crate::error::LenMismatchError; +use core::{mem, ops::RangeFrom}; + +pub struct Overlapping<'o, T> { + // Invariant: self.src.start <= in_out.len(). + in_out: &'o mut [T], + src: RangeFrom, +} + +impl<'o, T> From<&'o mut [T]> for Overlapping<'o, T> { + fn from(in_out: &'o mut [T]) -> Self { + Self { in_out, src: 0.. } + } +} + +impl<'o, T> Overlapping<'o, T> { + pub fn new(in_out: &'o mut [T], src: RangeFrom) -> Result { + match in_out.get(src.clone()) { + Some(_) => Ok(Self { in_out, src }), + None => Err(IndexError::new(src.start)), + } + } + + #[cfg(any( + all(target_arch = "arm", target_endian = "little"), + target_arch = "x86" + ))] + pub fn copy_within(self) -> &'o mut [T] + where + T: Copy, + { + if self.src.start == 0 { + self.in_out + } else { + let len = self.len(); + self.in_out.copy_within(self.src, 0); + &mut self.in_out[..len] + } + } + + #[cfg(any( + all(target_arch = "arm", target_endian = "little"), + target_arch = "x86" + ))] + pub fn into_slice_src_mut(self) -> (&'o mut [T], RangeFrom) { + (self.in_out, self.src) + } + + pub fn into_unwritten_output(self) -> &'o mut [T] { + let len = self.len(); + self.in_out.get_mut(..len).unwrap_or_else(|| { + // The invariant ensures this succeeds. + unreachable!() + }) + } +} + +impl Overlapping<'_, T> { + pub fn len(&self) -> usize { + self.input().len() + } + + pub fn input(&self) -> &[T] { + self.in_out.get(self.src.clone()).unwrap_or_else(|| { + // Ensured by invariant. + unreachable!() + }) + } + + pub fn with_input_output_len(self, f: impl FnOnce(*const T, *mut T, usize) -> R) -> R { + let len = self.len(); + let output = self.in_out.as_mut_ptr(); + // TODO: MSRV(1.65): use `output.cast_const()` + let output_const: *const T = output; + // SAFETY: The constructor ensures that `src` is a valid range. + // Equivalent to `self.in_out[src.clone()].as_ptr()` but without + // worries about compatibility with the stacked borrows model. + // TODO(MSRV-1.80, probably): Avoid special casing 0; see + // https://github.com/rust-lang/rust/pull/117329 + // https://github.com/rust-lang/rustc_codegen_gcc/issues/516 + let input = if self.src.start == 0 { + output_const + } else { + unsafe { output_const.add(self.src.start) } + }; + f(input, output, len) + } + + // Perhaps unlike `slice::split_first_chunk_mut`, this is biased, + // performance-wise, against the case where `N > self.len()`, so callers + // should be structured to avoid that. + // + // If the result is `Err` then nothing was written to `self`; if anything + // was written then the result will not be `Err`. + #[cfg_attr(not(test), allow(dead_code))] + pub fn split_first_chunk( + mut self, + f: impl for<'a> FnOnce(Array<'a, T, N>), + ) -> Result { + let src = self.src.clone(); + let end = self + .src + .start + .checked_add(N) + .ok_or_else(|| IndexError::new(N))?; + let first = self + .in_out + .get_mut(..end) + .ok_or_else(|| IndexError::new(N))?; + let first = Overlapping::new(first, src).unwrap_or_else(|IndexError { .. }| { + // Since `end == src.start + N`. + unreachable!() + }); + let first = Array::new(first).unwrap_or_else(|LenMismatchError { .. }| { + // Since `end == src.start + N`. + unreachable!() + }); + // Once we call `f`, we must return `Ok` because `f` may have written + // over (part of) the input. + Ok({ + f(first); + let tail = mem::take(&mut self.in_out).get_mut(N..).unwrap_or_else(|| { + // There are at least `N` elements since `end == src.start + N`. + unreachable!() + }); + Self::new(tail, self.src).unwrap_or_else(|IndexError { .. }| { + // Follows from `end == src.start + N`. + unreachable!() + }) + }) + } +} + +cold_exhaustive_error! { + struct index_error::IndexError { index: usize } +} diff --git a/http/vendor/ring/src/aead/overlapping/mod.rs b/http/vendor/ring/src/aead/overlapping/mod.rs new file mode 100644 index 0000000..77086cd --- /dev/null +++ b/http/vendor/ring/src/aead/overlapping/mod.rs @@ -0,0 +1,23 @@ +// Copyright 2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +pub use self::{ + array::Array, + base::{IndexError, Overlapping}, + partial_block::PartialBlock, +}; + +mod array; +mod base; +mod partial_block; diff --git a/http/vendor/ring/src/aead/overlapping/partial_block.rs b/http/vendor/ring/src/aead/overlapping/partial_block.rs new file mode 100644 index 0000000..9b7864a --- /dev/null +++ b/http/vendor/ring/src/aead/overlapping/partial_block.rs @@ -0,0 +1,59 @@ +// Copyright 2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::Overlapping; +use crate::error::InputTooLongError; + +pub struct PartialBlock<'i, T, const BLOCK_LEN: usize> { + // invariant: `self.in_out.len() < BLOCK_LEN`. + in_out: Overlapping<'i, T>, +} + +impl<'i, T, const BLOCK_LEN: usize> PartialBlock<'i, T, BLOCK_LEN> { + pub fn new(in_out: Overlapping<'i, T>) -> Result { + let len = in_out.len(); + if len >= BLOCK_LEN { + return Err(InputTooLongError::new(len)); + } + Ok(Self { in_out }) + } + + pub fn overwrite_at_start(self, padded: [T; BLOCK_LEN]) + where + T: Copy, + { + let len = self.len(); + let output = self.in_out.into_unwritten_output(); + assert!(output.len() <= padded.len()); + output.copy_from_slice(&padded[..len]); + } +} + +impl PartialBlock<'_, T, BLOCK_LEN> { + #[inline(always)] + pub fn input(&self) -> &[T] { + let r = self.in_out.input(); + // Help the optimizer optimize the caller using the invariant. + // TODO: Does this actually help? + if r.len() >= BLOCK_LEN { + unreachable!() + } + r + } + + #[inline(always)] + pub fn len(&self) -> usize { + self.input().len() + } +} diff --git a/http/vendor/ring/src/aead/poly1305.rs b/http/vendor/ring/src/aead/poly1305.rs new file mode 100644 index 0000000..70dcda3 --- /dev/null +++ b/http/vendor/ring/src/aead/poly1305.rs @@ -0,0 +1,117 @@ +// Copyright 2015-2025 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +// TODO: enforce maximum input length. + +use super::{Tag, TAG_LEN}; +#[cfg(all(target_arch = "arm", target_endian = "little"))] +use crate::cpu::GetFeature as _; +use crate::{cpu, polyfill::slice::AsChunks}; + +mod ffi_arm_neon; +mod ffi_fallback; + +/// A Poly1305 key. +pub(super) struct Key { + key_and_nonce: [u8; KEY_LEN], +} + +pub(super) const BLOCK_LEN: usize = 16; +pub(super) const KEY_LEN: usize = 2 * BLOCK_LEN; + +impl Key { + #[inline] + pub(super) fn new(key_and_nonce: [u8; KEY_LEN]) -> Self { + Self { key_and_nonce } + } +} + +pub(super) enum Context { + #[cfg(all(target_arch = "arm", target_endian = "little"))] + ArmNeon(ffi_arm_neon::State), + Fallback(ffi_fallback::State), +} + +impl Context { + #[inline] + pub(super) fn from_key(key: Key, cpu: cpu::Features) -> Self { + #[cfg(all(target_arch = "arm", target_endian = "little"))] + if let Some(cpu) = cpu.get_feature() { + return ffi_arm_neon::State::new_context(key, cpu); + } + let _: cpu::Features = cpu; + ffi_fallback::State::new_context(key) + } + + pub fn update_block(&mut self, input: [u8; BLOCK_LEN]) { + self.update(AsChunks::from_ref(&input)) + } + + pub fn update(&mut self, input: AsChunks) { + self.update_internal(input.as_flattened()); + } + + fn update_internal(&mut self, input: &[u8]) { + match self { + #[cfg(all(target_arch = "arm", target_endian = "little"))] + Self::ArmNeon(state) => state.update_internal(input), + Self::Fallback(state) => state.update_internal(input), + } + } + + pub(super) fn finish(mut self, input: &[u8]) -> Tag { + self.update_internal(input); + match self { + #[cfg(all(target_arch = "arm", target_endian = "little"))] + Self::ArmNeon(state) => state.finish(), + Self::Fallback(state) => state.finish(), + } + } +} + +/// Implements the original, non-IETF padding semantics. +/// +/// This is used by chacha20_poly1305_openssh and the standalone +/// poly1305 test vectors. +pub(super) fn sign(key: Key, input: &[u8], cpu_features: cpu::Features) -> Tag { + let ctx = Context::from_key(key, cpu_features); + ctx.finish(input) +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::testutil as test; + + // Adapted from BoringSSL's crypto/poly1305/poly1305_test.cc. + #[test] + pub fn test_poly1305() { + let cpu_features = cpu::features(); + test::run( + test_vector_file!("poly1305_test.txt"), + |section, test_case| { + assert_eq!(section, ""); + let key = test_case.consume_bytes("Key"); + let key: &[u8; KEY_LEN] = key.as_slice().try_into().unwrap(); + let input = test_case.consume_bytes("Input"); + let expected_mac = test_case.consume_bytes("MAC"); + let key = Key::new(*key); + let Tag(actual_mac) = sign(key, &input, cpu_features); + assert_eq!(expected_mac, actual_mac.as_ref()); + + Ok(()) + }, + ) + } +} diff --git a/http/vendor/ring/src/aead/poly1305/ffi_arm_neon.rs b/http/vendor/ring/src/aead/poly1305/ffi_arm_neon.rs new file mode 100644 index 0000000..5c1542d --- /dev/null +++ b/http/vendor/ring/src/aead/poly1305/ffi_arm_neon.rs @@ -0,0 +1,98 @@ +// Copyright 2015-2025 Brian Smith. +// Portions Copyright (c) 2014, 2015, Google Inc. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#![cfg(all(target_arch = "arm", target_endian = "little"))] + +use super::{Key, Tag, KEY_LEN, TAG_LEN}; +use crate::{c, cpu::arm::Neon}; +use core::num::NonZeroUsize; + +// XXX/TODO(MSRV): change to `pub(super)`. +pub(in super::super) struct State { + state: poly1305_state_st, + neon: Neon, +} + +// TODO: Is 16 enough? +#[repr(C, align(16))] +struct poly1305_state_st { + r: fe1305x2, + h: fe1305x2, + c: fe1305x2, + precomp: [fe1305x2; 2], + + data: [u8; data_len()], + + buf: [u8; 32], + buf_used: c::size_t, + key: [u8; 16], +} + +const fn data_len() -> usize { + 128 +} + +#[derive(Clone, Copy)] +#[repr(C)] +struct fe1305x2 { + v: [u32; 12], // for alignment; only using 10 +} + +impl State { + pub(super) fn new_context(Key { key_and_nonce }: Key, neon: Neon) -> super::Context { + prefixed_extern! { + fn CRYPTO_poly1305_init_neon(state: &mut poly1305_state_st, key: &[u8; KEY_LEN]); + } + let mut r = Self { + state: poly1305_state_st { + r: fe1305x2 { v: [0; 12] }, + h: fe1305x2 { v: [0; 12] }, + c: fe1305x2 { v: [0; 12] }, + precomp: [fe1305x2 { v: [0; 12] }; 2], + + data: [0u8; data_len()], + buf: Default::default(), + buf_used: 0, + key: [0u8; 16], + }, + neon, + }; + unsafe { CRYPTO_poly1305_init_neon(&mut r.state, &key_and_nonce) } + super::Context::ArmNeon(r) + } + + pub(super) fn update_internal(&mut self, input: &[u8]) { + prefixed_extern! { + fn CRYPTO_poly1305_update_neon( + st: &mut poly1305_state_st, + input: *const u8, + in_len: c::NonZero_size_t); + } + if let Some(len) = NonZeroUsize::new(input.len()) { + let _: Neon = self.neon; + let input = input.as_ptr(); + unsafe { CRYPTO_poly1305_update_neon(&mut self.state, input, len) } + } + } + + pub(super) fn finish(mut self) -> Tag { + prefixed_extern! { + fn CRYPTO_poly1305_finish_neon(st: &mut poly1305_state_st, mac: &mut [u8; TAG_LEN]); + } + let mut tag = Tag([0u8; TAG_LEN]); + unsafe { CRYPTO_poly1305_finish_neon(&mut self.state, &mut tag.0) } + tag + } +} diff --git a/http/vendor/ring/src/aead/poly1305/ffi_fallback.rs b/http/vendor/ring/src/aead/poly1305/ffi_fallback.rs new file mode 100644 index 0000000..f689cfc --- /dev/null +++ b/http/vendor/ring/src/aead/poly1305/ffi_fallback.rs @@ -0,0 +1,96 @@ +// Copyright 2015-2025 Brian Smith. +// Portions Copyright (c) 2014, 2015, Google Inc. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::{Key, Tag, KEY_LEN, TAG_LEN}; +use crate::c; +use core::num::NonZeroUsize; + +// XXX/TODO(MSRV): change to `pub(super)`. +pub(in super::super) struct State { + state: poly1305_state_st, +} + +// Keep in sync with `poly1305_state_st` in poly1305.c +#[repr(C, align(64))] +struct poly1305_state_st { + r0: u32, + r1: u32, + r2: u32, + r3: u32, + r4: u32, + s1: u32, + s2: u32, + s3: u32, + s4: u32, + h0: u32, + h1: u32, + h2: u32, + h3: u32, + h4: u32, + key: [u8; 16], +} + +impl State { + pub(super) fn new_context(Key { key_and_nonce }: Key) -> super::Context { + prefixed_extern! { + fn CRYPTO_poly1305_init(state: &mut poly1305_state_st, key: &[u8; KEY_LEN]); + } + let mut r = Self { + state: poly1305_state_st { + r0: 0, + r1: 0, + r2: 0, + r3: 0, + r4: 0, + s1: 0, + s2: 0, + s3: 0, + s4: 0, + h0: 0, + h1: 0, + h2: 0, + h3: 0, + h4: 0, + key: [0u8; 16], + }, + }; + unsafe { CRYPTO_poly1305_init(&mut r.state, &key_and_nonce) } + super::Context::Fallback(r) + } + + // `input.len % BLOCK_LEN == 0` must be true for every call except the + // final one. + pub(super) fn update_internal(&mut self, input: &[u8]) { + prefixed_extern! { + fn CRYPTO_poly1305_update( + state: &mut poly1305_state_st, + input: *const u8, + in_len: c::NonZero_size_t); + } + if let Some(len) = NonZeroUsize::new(input.len()) { + let input = input.as_ptr(); + unsafe { CRYPTO_poly1305_update(&mut self.state, input, len) } + } + } + + pub(super) fn finish(mut self) -> Tag { + prefixed_extern! { + fn CRYPTO_poly1305_finish(statep: &mut poly1305_state_st, mac: &mut [u8; TAG_LEN]); + } + let mut tag = Tag([0u8; TAG_LEN]); + unsafe { CRYPTO_poly1305_finish(&mut self.state, &mut tag.0) } + tag + } +} diff --git a/http/vendor/ring/src/aead/poly1305_test.txt b/http/vendor/ring/src/aead/poly1305_test.txt new file mode 100644 index 0000000..586477d --- /dev/null +++ b/http/vendor/ring/src/aead/poly1305_test.txt @@ -0,0 +1,170 @@ +# Test Vectors from OpenSSL commit bbe9769ba66ab2512678a87b0d9b266ba970db05. + +Key = 2d773be37adb1e4d683bf0075e79c4ee037918535a7f99ccb7040fb5f5f43aea +Input = 89dab80b7717c1db5db437860a3f70218e93e1b8f461fb677f16f35f6f87e2a91c99bc3a47ace47640cc95c345be5ecca5a3523c35cc01893af0b64a620334270372ec12482d1b1e363561698a578b359803495bb4e2ef1930b17a5190b580f141300df30adbeca28f6427a8bc1a999fd51c554a017d095d8c3e3127daf9f595 +MAC = c85d15ed44c378d6b00e23064c7bcd51 + +Key = 99e5822dd4173c995e3dae0ddefb97743fde3b080134b39f76e9bf8d0e88d546 +Input = 000000000000000b170303020000000006db1f1f368d696a810a349c0c714c9a5e7850c2407d721acded95e018d7a85266a6e1289cdb4aeb18da5ac8a2b0026d24a59ad485227f3eaedbb2e7e35e1c66cd60f9abf716dcc9ac42682dd7dab287a7024c4eefc321cc0574e16793e37cec03c5bda42b54c114a80b57af26416c7be742005e20855c73e21dc8e2edc9d435cb6f6059280011c270b71570051c1c9b3052126620bc1e2730fa066c7a509d53c60e5ae1b40aa6e39e49669228c90eecb4a50db32a50bc49e90b4f4b359a1dfd11749cd3867fcf2fb7bb6cd4738f6a4ad6f7ca5058f7618845af9f020f6c3b967b8f4cd4a91e2813b507ae66f2d35c18284f7292186062e10fd5510d18775351ef334e7634ab4743f5b68f49adcab384d3fd75f7390f4006ef2a295c8c7a076ad54546cd25d2107fbe1436c840924aaebe5b370893cd63d1325b8616fc4810886bc152c53221b6df373119393255ee72bcaa880174f1717f9184fa91646f17a24ac55d16bfddca9581a92eda479201f0edbf633600d6066d1ab36d5d2415d71351bbcd608a25108d25641992c1f26c531cf9f90203bc4cc19f5927d834b0a47116d3884bbb164b8ec883d1ac832e56b3918a98601a08d171881541d594db399c6ae6151221745aec814c45b0b05b565436fd6f137aa10a0c0b643761dbd6f9a9dcb99b1a6e690854ce0769cde39761d82fcdec15f0d92d7d8e94ade8eb83fbe0 +MAC = 2637408fe13086ea73f971e3425e2820 + + +# RFC 8439, section 2.5.2. + +Key = 85d6be7857556d337f4452fe42d506a80103808afb0db2fd4abff6af4149f51b +Input = "Cryptographic Forum Research Group" +MAC = a8061dc1305136c6c22b8baf0c0127a9 + + +# RFC 8439, section A.3. + +Key = 0000000000000000000000000000000000000000000000000000000000000000 +Input = 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +MAC = 00000000000000000000000000000000 + +Key = 0000000000000000000000000000000036e5f6b5c5e06070f0efca96227a863e +Input = 416e79207375626d697373696f6e20746f20746865204945544620696e74656e6465642062792074686520436f6e7472696275746f7220666f72207075626c69636174696f6e20617320616c6c206f722070617274206f6620616e204945544620496e7465726e65742d4472616674206f722052464320616e6420616e792073746174656d656e74206d6164652077697468696e2074686520636f6e74657874206f6620616e204945544620616374697669747920697320636f6e7369646572656420616e20224945544620436f6e747269627574696f6e222e20537563682073746174656d656e747320696e636c756465206f72616c2073746174656d656e747320696e20494554462073657373696f6e732c2061732077656c6c206173207772697474656e20616e6420656c656374726f6e696320636f6d6d756e69636174696f6e73206d61646520617420616e792074696d65206f7220706c6163652c207768696368206172652061646472657373656420746f +MAC = 36e5f6b5c5e06070f0efca96227a863e + +Key = 36e5f6b5c5e06070f0efca96227a863e00000000000000000000000000000000 +Input = 416e79207375626d697373696f6e20746f20746865204945544620696e74656e6465642062792074686520436f6e7472696275746f7220666f72207075626c69636174696f6e20617320616c6c206f722070617274206f6620616e204945544620496e7465726e65742d4472616674206f722052464320616e6420616e792073746174656d656e74206d6164652077697468696e2074686520636f6e74657874206f6620616e204945544620616374697669747920697320636f6e7369646572656420616e20224945544620436f6e747269627574696f6e222e20537563682073746174656d656e747320696e636c756465206f72616c2073746174656d656e747320696e20494554462073657373696f6e732c2061732077656c6c206173207772697474656e20616e6420656c656374726f6e696320636f6d6d756e69636174696f6e73206d61646520617420616e792074696d65206f7220706c6163652c207768696368206172652061646472657373656420746f +MAC = f3477e7cd95417af89a6b8794c310cf0 + +Key = 1c9240a5eb55d38af333888604f6b5f0473917c1402b80099dca5cbc207075c0 +Input = 2754776173206272696c6c69672c20616e642074686520736c6974687920746f7665730a446964206779726520616e642067696d626c6520696e2074686520776162653a0a416c6c206d696d737920776572652074686520626f726f676f7665732c0a416e6420746865206d6f6d65207261746873206f757467726162652e +MAC = 4541669a7eaaee61e708dc7cbcc5eb62 + +Key = 0200000000000000000000000000000000000000000000000000000000000000 +Input = ffffffffffffffffffffffffffffffff +MAC = 03000000000000000000000000000000 + +Key = 02000000000000000000000000000000ffffffffffffffffffffffffffffffff +Input = 02000000000000000000000000000000 +MAC = 03000000000000000000000000000000 + +Key = 0100000000000000000000000000000000000000000000000000000000000000 +Input = fffffffffffffffffffffffffffffffff0ffffffffffffffffffffffffffffff11000000000000000000000000000000 +MAC = 05000000000000000000000000000000 + +Key = 0100000000000000000000000000000000000000000000000000000000000000 +Input = fffffffffffffffffffffffffffffffffbfefefefefefefefefefefefefefefe01010101010101010101010101010101 +MAC = 00000000000000000000000000000000 + +Key = 0200000000000000000000000000000000000000000000000000000000000000 +Input = fdffffffffffffffffffffffffffffff +MAC = faffffffffffffffffffffffffffffff + +Key = 0100000000000000040000000000000000000000000000000000000000000000 +Input = e33594d7505e43b900000000000000003394d7505e4379cd01000000000000000000000000000000000000000000000001000000000000000000000000000000 +MAC = 14000000000000005500000000000000 + +Key = 0100000000000000040000000000000000000000000000000000000000000000 +Input = e33594d7505e43b900000000000000003394d7505e4379cd010000000000000000000000000000000000000000000000 +MAC = 13000000000000000000000000000000 + + +# Additional test vectors that are long enough to ensure OpenSSL's SIMD +# assembly is fully tested. + +# Length 2048. +Key = 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f +Input = 248ac31085b6c2adaaa38259a0d7192c5c35d1bb4ef39ad94c38d1c82479e2dd2159a077024b0589bc8a20101b506f0a1ad0bbab76e83a83f1b94be6beae74e874cab692c5963a75436b776121ec9f62399a3e66b2d22707dae81933b6277f3c8516bcbe26dbbd86f373103d7cf4cad1888c952118fbfbd0d7b4bedc4ae4936aff91157e7aa47c54442ea78d6ac251d324a0fbe49d89cc3521b66d16e9c66a3709894e4eb0a4eedc4ae19468e66b81f271351b1d921ea551047abcc6b87a901fde7db79fa1818c11336dbc07244a40eb14cf77bde35e78ae9ad7d3f57ed7e7f23926c9172f82d77684ea5ed7d74ebc6f142b997036bcb7cce8df1bbc0d5b35a46509c954fc9469d214d6238f166cbf872156b4c41d7aac5942cffb175023078252a3f36e315c5d4ce0e39928a018252862becacef96a19f03bdcf46d75584299d1f8b03c0169e9e407d937145b5e5024139e7022a1978f114f24cdfa23780a119735c41da8fb759bbb3f025c6ec30e6c6e9bce8615be68e392fce59fd26a8e6a6cc5c606e3848116e4d01d29565a1facfb524b6d29643b826eee1e42869fc76df229dd79b39a2b1df28bb335c3a5f15a855d0121e4a6da34b5e4d5b7b5d5746a03ecff70811e1516fcec1bf7462e8876a2d21710aa168c78f45a6a15015950e221da85d3ec822ad6d0a6931b25a06b7bb5f3c10bb36cd4d647f9561982fde9818de5d4bf8db7f86c53b4ff14928ac15f79023b61861e73e44216540bb302153770da2533de9795252ab5fb77ad924c9338c8144c23d4c90dab9a18feac1a1574d4545e1435eb405e6c4c439fc724fce992ae85badf345bad16d85fbd338f04433703614754d0e7e54c4ccde2670587d52ecfb5a70a14a501bacc727722649931d8515b13d020a78e511fe136d45fbf97f9c7f689fcc677cfb3683723878350ffe9d08130cc6e567b6179e01b7eb2b3bbcf0873e1308eec018edeb8cce946338e15d5bf68c71916a83a99358039ef071e009546a2df936879dffbba397a93925d229a469fd17d71b7f524e03a30da6ee927542f8b369bed4734fe25dbd63d24ffd2a222f5f84f75d858ab989be925af570ad6d45bd28ce61b5139e1dd2f0b7795fe072e6e83acbb5e7b777a70c641e4cab2af40eed69abc334cd2703c3273204fac580c6a3d6680427e5f7d051e8380a53f93a180f4556ecea4530b9a2d5948dad63d415b6874f6b90e767d6d265be86351b53ba690780bb57c21b57418c5b97559e840c68257f839e7583a4bf7c7645c5987d40cc1ba79a218c35edfacdabe581d950e4bb7a481ebe64d61d00e75b1f25f1ce5f5462334a5b9038a697aa0937a3f8017e05d2c9c05dcb05c0b02508dea619b137f5444b6f088eb3cb2c66788f88afdfbba8faa1c490485624c88ae11e57347a676902e7553f056188493209bdbb30acc63c9e41e16a9d6c009416b520a76ba38f57628170c43626b5cb46179dc5bf65de865085f84bf741c223fbe474d2d19d8f43914fbd6586351089e73babf344f988b7963fe44528457d7aad3c564f6bcbd0d772a4c9fd328e6022d1c7c9f86726f8d5a23797d309c0f653ab1ac687833eb2700f156296062a8b377078f45f6b68c3d07cae1913ba8d5a6f9bf7525a3439eb932d4cefc4bf8e1b07b48ca13ece366cbc3e0388915915d1757475103a9e9454e7e6355de2d6acbf4710f9a63e4f6d3cd70c2d6fca88dd8a14448fdb63ce9350fdaafbe0b8bd1c5d307dae76dfed799aef2d8f23d5608d37d1330dd38b94860905dbeebf78d7b7318b7d42aed40d3f9899e9f420cbd92a6eeae3026f7725694e0e4bee016ba346fed2c21172bdb4a461cebe0cfe38e76645226ac127a259c193264d735ce8c8a57e17dd3f0579e2e86dc295ad1f45ba2d85db35044da61f7d401274b31eefbeb34e8d2ae596e9b4541aae117bdac5ed0b324c20539c27c07a411d5288b0b5f6fa16e9a7df85dc319fa6b71cd08a859c06a3f7b0289e1750adbf182f9750fea96fea5ab7aa3473340607cd7ed2c626f5382491c26d5d5bea61401dee7319c94d418f297e61ceac8f258ee8c23831bda081591f5a918e96855774ddedffc51e5b180f1971806d42fc333020b734aeb45adb0bc47325d0cea5f6713a786558022afc39d573892aa3635efbfd8bcb11c57f306c72146afe8b45388125cb7bf9ecf965a7ba4f768c77be366470dcdcf214b7f6a5a9460ed4fe44ae559d85e2fdc2094de83fff12ea8804db1215c4ca865871bdd7f8ef32ab799bf923ffb02c1ded7d129beadad46c5eda31ab1a6f43da05ea08bff7ffa88d8966353d01830558c39b930b01d175e437124d8edd0d2698fd8932f2b2c9b14746e52879c57a395538150f390264f00e60d470711202f4194499ff79037ca9885dc8d695f7d917a3086ca88e8f8d0243efee09302cf39e039eb7cc8dd19d28120d5fe533b5727cd39133181c729ca6f90a015ed30be7668d5cb5ecc33a53ee69bf7d1a5ecbdb153803743c6adaaabd36bf84e5be38d3f04a5d5dbfd67bdcd3b176e65bd1391ade775cc32ce43a847fb6c672a3fe97a5d4081c4986959ec5fb898f42a9397ba2b3ec2c1018f8d76d057f2366bd0e4465514ad6560c599664fb85621fe771e00f43d39b591b2a6a321100f4d1ef23a376d5ae3eeedbfe23da73dff0ee4d16b34ebddd8f5f053db9824105fc7300dbee7ea6af56b112319e3e215a0fc79ae946f6b5227453ec7fcaf17cf7651f71499a50d81221404d5f129ac50ea7528ff0e0069ec4ab8acb7919d81749ab37a870c5ef2cc5a15cf96709d3c65b4addc77e7416847160bcabb94ea36377e0ef71be80b5cc53effd5444888044a353574c72c924bba2a8b4e8354188ebfed +MAC = 69d28f73dd09d39a92aa179da354b7ea + +# Length 2049. +Key = 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f +Input = 248ac31085b6c2adaaa38259a0d7192c5c35d1bb4ef39ad94c38d1c82479e2dd2159a077024b0589bc8a20101b506f0a1ad0bbab76e83a83f1b94be6beae74e874cab692c5963a75436b776121ec9f62399a3e66b2d22707dae81933b6277f3c8516bcbe26dbbd86f373103d7cf4cad1888c952118fbfbd0d7b4bedc4ae4936aff91157e7aa47c54442ea78d6ac251d324a0fbe49d89cc3521b66d16e9c66a3709894e4eb0a4eedc4ae19468e66b81f271351b1d921ea551047abcc6b87a901fde7db79fa1818c11336dbc07244a40eb14cf77bde35e78ae9ad7d3f57ed7e7f23926c9172f82d77684ea5ed7d74ebc6f142b997036bcb7cce8df1bbc0d5b35a46509c954fc9469d214d6238f166cbf872156b4c41d7aac5942cffb175023078252a3f36e315c5d4ce0e39928a018252862becacef96a19f03bdcf46d75584299d1f8b03c0169e9e407d937145b5e5024139e7022a1978f114f24cdfa23780a119735c41da8fb759bbb3f025c6ec30e6c6e9bce8615be68e392fce59fd26a8e6a6cc5c606e3848116e4d01d29565a1facfb524b6d29643b826eee1e42869fc76df229dd79b39a2b1df28bb335c3a5f15a855d0121e4a6da34b5e4d5b7b5d5746a03ecff70811e1516fcec1bf7462e8876a2d21710aa168c78f45a6a15015950e221da85d3ec822ad6d0a6931b25a06b7bb5f3c10bb36cd4d647f9561982fde9818de5d4bf8db7f86c53b4ff14928ac15f79023b61861e73e44216540bb302153770da2533de9795252ab5fb77ad924c9338c8144c23d4c90dab9a18feac1a1574d4545e1435eb405e6c4c439fc724fce992ae85badf345bad16d85fbd338f04433703614754d0e7e54c4ccde2670587d52ecfb5a70a14a501bacc727722649931d8515b13d020a78e511fe136d45fbf97f9c7f689fcc677cfb3683723878350ffe9d08130cc6e567b6179e01b7eb2b3bbcf0873e1308eec018edeb8cce946338e15d5bf68c71916a83a99358039ef071e009546a2df936879dffbba397a93925d229a469fd17d71b7f524e03a30da6ee927542f8b369bed4734fe25dbd63d24ffd2a222f5f84f75d858ab989be925af570ad6d45bd28ce61b5139e1dd2f0b7795fe072e6e83acbb5e7b777a70c641e4cab2af40eed69abc334cd2703c3273204fac580c6a3d6680427e5f7d051e8380a53f93a180f4556ecea4530b9a2d5948dad63d415b6874f6b90e767d6d265be86351b53ba690780bb57c21b57418c5b97559e840c68257f839e7583a4bf7c7645c5987d40cc1ba79a218c35edfacdabe581d950e4bb7a481ebe64d61d00e75b1f25f1ce5f5462334a5b9038a697aa0937a3f8017e05d2c9c05dcb05c0b02508dea619b137f5444b6f088eb3cb2c66788f88afdfbba8faa1c490485624c88ae11e57347a676902e7553f056188493209bdbb30acc63c9e41e16a9d6c009416b520a76ba38f57628170c43626b5cb46179dc5bf65de865085f84bf741c223fbe474d2d19d8f43914fbd6586351089e73babf344f988b7963fe44528457d7aad3c564f6bcbd0d772a4c9fd328e6022d1c7c9f86726f8d5a23797d309c0f653ab1ac687833eb2700f156296062a8b377078f45f6b68c3d07cae1913ba8d5a6f9bf7525a3439eb932d4cefc4bf8e1b07b48ca13ece366cbc3e0388915915d1757475103a9e9454e7e6355de2d6acbf4710f9a63e4f6d3cd70c2d6fca88dd8a14448fdb63ce9350fdaafbe0b8bd1c5d307dae76dfed799aef2d8f23d5608d37d1330dd38b94860905dbeebf78d7b7318b7d42aed40d3f9899e9f420cbd92a6eeae3026f7725694e0e4bee016ba346fed2c21172bdb4a461cebe0cfe38e76645226ac127a259c193264d735ce8c8a57e17dd3f0579e2e86dc295ad1f45ba2d85db35044da61f7d401274b31eefbeb34e8d2ae596e9b4541aae117bdac5ed0b324c20539c27c07a411d5288b0b5f6fa16e9a7df85dc319fa6b71cd08a859c06a3f7b0289e1750adbf182f9750fea96fea5ab7aa3473340607cd7ed2c626f5382491c26d5d5bea61401dee7319c94d418f297e61ceac8f258ee8c23831bda081591f5a918e96855774ddedffc51e5b180f1971806d42fc333020b734aeb45adb0bc47325d0cea5f6713a786558022afc39d573892aa3635efbfd8bcb11c57f306c72146afe8b45388125cb7bf9ecf965a7ba4f768c77be366470dcdcf214b7f6a5a9460ed4fe44ae559d85e2fdc2094de83fff12ea8804db1215c4ca865871bdd7f8ef32ab799bf923ffb02c1ded7d129beadad46c5eda31ab1a6f43da05ea08bff7ffa88d8966353d01830558c39b930b01d175e437124d8edd0d2698fd8932f2b2c9b14746e52879c57a395538150f390264f00e60d470711202f4194499ff79037ca9885dc8d695f7d917a3086ca88e8f8d0243efee09302cf39e039eb7cc8dd19d28120d5fe533b5727cd39133181c729ca6f90a015ed30be7668d5cb5ecc33a53ee69bf7d1a5ecbdb153803743c6adaaabd36bf84e5be38d3f04a5d5dbfd67bdcd3b176e65bd1391ade775cc32ce43a847fb6c672a3fe97a5d4081c4986959ec5fb898f42a9397ba2b3ec2c1018f8d76d057f2366bd0e4465514ad6560c599664fb85621fe771e00f43d39b591b2a6a321100f4d1ef23a376d5ae3eeedbfe23da73dff0ee4d16b34ebddd8f5f053db9824105fc7300dbee7ea6af56b112319e3e215a0fc79ae946f6b5227453ec7fcaf17cf7651f71499a50d81221404d5f129ac50ea7528ff0e0069ec4ab8acb7919d81749ab37a870c5ef2cc5a15cf96709d3c65b4addc77e7416847160bcabb94ea36377e0ef71be80b5cc53effd5444888044a353574c72c924bba2a8b4e8354188ebfedc8 +MAC = d6a26654b88572e875d9661c83471c1b + +# Length 2050. +Key = 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f +Input = 248ac31085b6c2adaaa38259a0d7192c5c35d1bb4ef39ad94c38d1c82479e2dd2159a077024b0589bc8a20101b506f0a1ad0bbab76e83a83f1b94be6beae74e874cab692c5963a75436b776121ec9f62399a3e66b2d22707dae81933b6277f3c8516bcbe26dbbd86f373103d7cf4cad1888c952118fbfbd0d7b4bedc4ae4936aff91157e7aa47c54442ea78d6ac251d324a0fbe49d89cc3521b66d16e9c66a3709894e4eb0a4eedc4ae19468e66b81f271351b1d921ea551047abcc6b87a901fde7db79fa1818c11336dbc07244a40eb14cf77bde35e78ae9ad7d3f57ed7e7f23926c9172f82d77684ea5ed7d74ebc6f142b997036bcb7cce8df1bbc0d5b35a46509c954fc9469d214d6238f166cbf872156b4c41d7aac5942cffb175023078252a3f36e315c5d4ce0e39928a018252862becacef96a19f03bdcf46d75584299d1f8b03c0169e9e407d937145b5e5024139e7022a1978f114f24cdfa23780a119735c41da8fb759bbb3f025c6ec30e6c6e9bce8615be68e392fce59fd26a8e6a6cc5c606e3848116e4d01d29565a1facfb524b6d29643b826eee1e42869fc76df229dd79b39a2b1df28bb335c3a5f15a855d0121e4a6da34b5e4d5b7b5d5746a03ecff70811e1516fcec1bf7462e8876a2d21710aa168c78f45a6a15015950e221da85d3ec822ad6d0a6931b25a06b7bb5f3c10bb36cd4d647f9561982fde9818de5d4bf8db7f86c53b4ff14928ac15f79023b61861e73e44216540bb302153770da2533de9795252ab5fb77ad924c9338c8144c23d4c90dab9a18feac1a1574d4545e1435eb405e6c4c439fc724fce992ae85badf345bad16d85fbd338f04433703614754d0e7e54c4ccde2670587d52ecfb5a70a14a501bacc727722649931d8515b13d020a78e511fe136d45fbf97f9c7f689fcc677cfb3683723878350ffe9d08130cc6e567b6179e01b7eb2b3bbcf0873e1308eec018edeb8cce946338e15d5bf68c71916a83a99358039ef071e009546a2df936879dffbba397a93925d229a469fd17d71b7f524e03a30da6ee927542f8b369bed4734fe25dbd63d24ffd2a222f5f84f75d858ab989be925af570ad6d45bd28ce61b5139e1dd2f0b7795fe072e6e83acbb5e7b777a70c641e4cab2af40eed69abc334cd2703c3273204fac580c6a3d6680427e5f7d051e8380a53f93a180f4556ecea4530b9a2d5948dad63d415b6874f6b90e767d6d265be86351b53ba690780bb57c21b57418c5b97559e840c68257f839e7583a4bf7c7645c5987d40cc1ba79a218c35edfacdabe581d950e4bb7a481ebe64d61d00e75b1f25f1ce5f5462334a5b9038a697aa0937a3f8017e05d2c9c05dcb05c0b02508dea619b137f5444b6f088eb3cb2c66788f88afdfbba8faa1c490485624c88ae11e57347a676902e7553f056188493209bdbb30acc63c9e41e16a9d6c009416b520a76ba38f57628170c43626b5cb46179dc5bf65de865085f84bf741c223fbe474d2d19d8f43914fbd6586351089e73babf344f988b7963fe44528457d7aad3c564f6bcbd0d772a4c9fd328e6022d1c7c9f86726f8d5a23797d309c0f653ab1ac687833eb2700f156296062a8b377078f45f6b68c3d07cae1913ba8d5a6f9bf7525a3439eb932d4cefc4bf8e1b07b48ca13ece366cbc3e0388915915d1757475103a9e9454e7e6355de2d6acbf4710f9a63e4f6d3cd70c2d6fca88dd8a14448fdb63ce9350fdaafbe0b8bd1c5d307dae76dfed799aef2d8f23d5608d37d1330dd38b94860905dbeebf78d7b7318b7d42aed40d3f9899e9f420cbd92a6eeae3026f7725694e0e4bee016ba346fed2c21172bdb4a461cebe0cfe38e76645226ac127a259c193264d735ce8c8a57e17dd3f0579e2e86dc295ad1f45ba2d85db35044da61f7d401274b31eefbeb34e8d2ae596e9b4541aae117bdac5ed0b324c20539c27c07a411d5288b0b5f6fa16e9a7df85dc319fa6b71cd08a859c06a3f7b0289e1750adbf182f9750fea96fea5ab7aa3473340607cd7ed2c626f5382491c26d5d5bea61401dee7319c94d418f297e61ceac8f258ee8c23831bda081591f5a918e96855774ddedffc51e5b180f1971806d42fc333020b734aeb45adb0bc47325d0cea5f6713a786558022afc39d573892aa3635efbfd8bcb11c57f306c72146afe8b45388125cb7bf9ecf965a7ba4f768c77be366470dcdcf214b7f6a5a9460ed4fe44ae559d85e2fdc2094de83fff12ea8804db1215c4ca865871bdd7f8ef32ab799bf923ffb02c1ded7d129beadad46c5eda31ab1a6f43da05ea08bff7ffa88d8966353d01830558c39b930b01d175e437124d8edd0d2698fd8932f2b2c9b14746e52879c57a395538150f390264f00e60d470711202f4194499ff79037ca9885dc8d695f7d917a3086ca88e8f8d0243efee09302cf39e039eb7cc8dd19d28120d5fe533b5727cd39133181c729ca6f90a015ed30be7668d5cb5ecc33a53ee69bf7d1a5ecbdb153803743c6adaaabd36bf84e5be38d3f04a5d5dbfd67bdcd3b176e65bd1391ade775cc32ce43a847fb6c672a3fe97a5d4081c4986959ec5fb898f42a9397ba2b3ec2c1018f8d76d057f2366bd0e4465514ad6560c599664fb85621fe771e00f43d39b591b2a6a321100f4d1ef23a376d5ae3eeedbfe23da73dff0ee4d16b34ebddd8f5f053db9824105fc7300dbee7ea6af56b112319e3e215a0fc79ae946f6b5227453ec7fcaf17cf7651f71499a50d81221404d5f129ac50ea7528ff0e0069ec4ab8acb7919d81749ab37a870c5ef2cc5a15cf96709d3c65b4addc77e7416847160bcabb94ea36377e0ef71be80b5cc53effd5444888044a353574c72c924bba2a8b4e8354188ebfedc852 +MAC = 9fbbb7f7adcd0cd5b46a4a520b22499a + +# Length 2051. +Key = 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f +Input = 248ac31085b6c2adaaa38259a0d7192c5c35d1bb4ef39ad94c38d1c82479e2dd2159a077024b0589bc8a20101b506f0a1ad0bbab76e83a83f1b94be6beae74e874cab692c5963a75436b776121ec9f62399a3e66b2d22707dae81933b6277f3c8516bcbe26dbbd86f373103d7cf4cad1888c952118fbfbd0d7b4bedc4ae4936aff91157e7aa47c54442ea78d6ac251d324a0fbe49d89cc3521b66d16e9c66a3709894e4eb0a4eedc4ae19468e66b81f271351b1d921ea551047abcc6b87a901fde7db79fa1818c11336dbc07244a40eb14cf77bde35e78ae9ad7d3f57ed7e7f23926c9172f82d77684ea5ed7d74ebc6f142b997036bcb7cce8df1bbc0d5b35a46509c954fc9469d214d6238f166cbf872156b4c41d7aac5942cffb175023078252a3f36e315c5d4ce0e39928a018252862becacef96a19f03bdcf46d75584299d1f8b03c0169e9e407d937145b5e5024139e7022a1978f114f24cdfa23780a119735c41da8fb759bbb3f025c6ec30e6c6e9bce8615be68e392fce59fd26a8e6a6cc5c606e3848116e4d01d29565a1facfb524b6d29643b826eee1e42869fc76df229dd79b39a2b1df28bb335c3a5f15a855d0121e4a6da34b5e4d5b7b5d5746a03ecff70811e1516fcec1bf7462e8876a2d21710aa168c78f45a6a15015950e221da85d3ec822ad6d0a6931b25a06b7bb5f3c10bb36cd4d647f9561982fde9818de5d4bf8db7f86c53b4ff14928ac15f79023b61861e73e44216540bb302153770da2533de9795252ab5fb77ad924c9338c8144c23d4c90dab9a18feac1a1574d4545e1435eb405e6c4c439fc724fce992ae85badf345bad16d85fbd338f04433703614754d0e7e54c4ccde2670587d52ecfb5a70a14a501bacc727722649931d8515b13d020a78e511fe136d45fbf97f9c7f689fcc677cfb3683723878350ffe9d08130cc6e567b6179e01b7eb2b3bbcf0873e1308eec018edeb8cce946338e15d5bf68c71916a83a99358039ef071e009546a2df936879dffbba397a93925d229a469fd17d71b7f524e03a30da6ee927542f8b369bed4734fe25dbd63d24ffd2a222f5f84f75d858ab989be925af570ad6d45bd28ce61b5139e1dd2f0b7795fe072e6e83acbb5e7b777a70c641e4cab2af40eed69abc334cd2703c3273204fac580c6a3d6680427e5f7d051e8380a53f93a180f4556ecea4530b9a2d5948dad63d415b6874f6b90e767d6d265be86351b53ba690780bb57c21b57418c5b97559e840c68257f839e7583a4bf7c7645c5987d40cc1ba79a218c35edfacdabe581d950e4bb7a481ebe64d61d00e75b1f25f1ce5f5462334a5b9038a697aa0937a3f8017e05d2c9c05dcb05c0b02508dea619b137f5444b6f088eb3cb2c66788f88afdfbba8faa1c490485624c88ae11e57347a676902e7553f056188493209bdbb30acc63c9e41e16a9d6c009416b520a76ba38f57628170c43626b5cb46179dc5bf65de865085f84bf741c223fbe474d2d19d8f43914fbd6586351089e73babf344f988b7963fe44528457d7aad3c564f6bcbd0d772a4c9fd328e6022d1c7c9f86726f8d5a23797d309c0f653ab1ac687833eb2700f156296062a8b377078f45f6b68c3d07cae1913ba8d5a6f9bf7525a3439eb932d4cefc4bf8e1b07b48ca13ece366cbc3e0388915915d1757475103a9e9454e7e6355de2d6acbf4710f9a63e4f6d3cd70c2d6fca88dd8a14448fdb63ce9350fdaafbe0b8bd1c5d307dae76dfed799aef2d8f23d5608d37d1330dd38b94860905dbeebf78d7b7318b7d42aed40d3f9899e9f420cbd92a6eeae3026f7725694e0e4bee016ba346fed2c21172bdb4a461cebe0cfe38e76645226ac127a259c193264d735ce8c8a57e17dd3f0579e2e86dc295ad1f45ba2d85db35044da61f7d401274b31eefbeb34e8d2ae596e9b4541aae117bdac5ed0b324c20539c27c07a411d5288b0b5f6fa16e9a7df85dc319fa6b71cd08a859c06a3f7b0289e1750adbf182f9750fea96fea5ab7aa3473340607cd7ed2c626f5382491c26d5d5bea61401dee7319c94d418f297e61ceac8f258ee8c23831bda081591f5a918e96855774ddedffc51e5b180f1971806d42fc333020b734aeb45adb0bc47325d0cea5f6713a786558022afc39d573892aa3635efbfd8bcb11c57f306c72146afe8b45388125cb7bf9ecf965a7ba4f768c77be366470dcdcf214b7f6a5a9460ed4fe44ae559d85e2fdc2094de83fff12ea8804db1215c4ca865871bdd7f8ef32ab799bf923ffb02c1ded7d129beadad46c5eda31ab1a6f43da05ea08bff7ffa88d8966353d01830558c39b930b01d175e437124d8edd0d2698fd8932f2b2c9b14746e52879c57a395538150f390264f00e60d470711202f4194499ff79037ca9885dc8d695f7d917a3086ca88e8f8d0243efee09302cf39e039eb7cc8dd19d28120d5fe533b5727cd39133181c729ca6f90a015ed30be7668d5cb5ecc33a53ee69bf7d1a5ecbdb153803743c6adaaabd36bf84e5be38d3f04a5d5dbfd67bdcd3b176e65bd1391ade775cc32ce43a847fb6c672a3fe97a5d4081c4986959ec5fb898f42a9397ba2b3ec2c1018f8d76d057f2366bd0e4465514ad6560c599664fb85621fe771e00f43d39b591b2a6a321100f4d1ef23a376d5ae3eeedbfe23da73dff0ee4d16b34ebddd8f5f053db9824105fc7300dbee7ea6af56b112319e3e215a0fc79ae946f6b5227453ec7fcaf17cf7651f71499a50d81221404d5f129ac50ea7528ff0e0069ec4ab8acb7919d81749ab37a870c5ef2cc5a15cf96709d3c65b4addc77e7416847160bcabb94ea36377e0ef71be80b5cc53effd5444888044a353574c72c924bba2a8b4e8354188ebfedc852f5 +MAC = eb7cdceb97ade2a07622f8f5a4b1ce15 + +# Length 2052. +Key = 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f +Input = 248ac31085b6c2adaaa38259a0d7192c5c35d1bb4ef39ad94c38d1c82479e2dd2159a077024b0589bc8a20101b506f0a1ad0bbab76e83a83f1b94be6beae74e874cab692c5963a75436b776121ec9f62399a3e66b2d22707dae81933b6277f3c8516bcbe26dbbd86f373103d7cf4cad1888c952118fbfbd0d7b4bedc4ae4936aff91157e7aa47c54442ea78d6ac251d324a0fbe49d89cc3521b66d16e9c66a3709894e4eb0a4eedc4ae19468e66b81f271351b1d921ea551047abcc6b87a901fde7db79fa1818c11336dbc07244a40eb14cf77bde35e78ae9ad7d3f57ed7e7f23926c9172f82d77684ea5ed7d74ebc6f142b997036bcb7cce8df1bbc0d5b35a46509c954fc9469d214d6238f166cbf872156b4c41d7aac5942cffb175023078252a3f36e315c5d4ce0e39928a018252862becacef96a19f03bdcf46d75584299d1f8b03c0169e9e407d937145b5e5024139e7022a1978f114f24cdfa23780a119735c41da8fb759bbb3f025c6ec30e6c6e9bce8615be68e392fce59fd26a8e6a6cc5c606e3848116e4d01d29565a1facfb524b6d29643b826eee1e42869fc76df229dd79b39a2b1df28bb335c3a5f15a855d0121e4a6da34b5e4d5b7b5d5746a03ecff70811e1516fcec1bf7462e8876a2d21710aa168c78f45a6a15015950e221da85d3ec822ad6d0a6931b25a06b7bb5f3c10bb36cd4d647f9561982fde9818de5d4bf8db7f86c53b4ff14928ac15f79023b61861e73e44216540bb302153770da2533de9795252ab5fb77ad924c9338c8144c23d4c90dab9a18feac1a1574d4545e1435eb405e6c4c439fc724fce992ae85badf345bad16d85fbd338f04433703614754d0e7e54c4ccde2670587d52ecfb5a70a14a501bacc727722649931d8515b13d020a78e511fe136d45fbf97f9c7f689fcc677cfb3683723878350ffe9d08130cc6e567b6179e01b7eb2b3bbcf0873e1308eec018edeb8cce946338e15d5bf68c71916a83a99358039ef071e009546a2df936879dffbba397a93925d229a469fd17d71b7f524e03a30da6ee927542f8b369bed4734fe25dbd63d24ffd2a222f5f84f75d858ab989be925af570ad6d45bd28ce61b5139e1dd2f0b7795fe072e6e83acbb5e7b777a70c641e4cab2af40eed69abc334cd2703c3273204fac580c6a3d6680427e5f7d051e8380a53f93a180f4556ecea4530b9a2d5948dad63d415b6874f6b90e767d6d265be86351b53ba690780bb57c21b57418c5b97559e840c68257f839e7583a4bf7c7645c5987d40cc1ba79a218c35edfacdabe581d950e4bb7a481ebe64d61d00e75b1f25f1ce5f5462334a5b9038a697aa0937a3f8017e05d2c9c05dcb05c0b02508dea619b137f5444b6f088eb3cb2c66788f88afdfbba8faa1c490485624c88ae11e57347a676902e7553f056188493209bdbb30acc63c9e41e16a9d6c009416b520a76ba38f57628170c43626b5cb46179dc5bf65de865085f84bf741c223fbe474d2d19d8f43914fbd6586351089e73babf344f988b7963fe44528457d7aad3c564f6bcbd0d772a4c9fd328e6022d1c7c9f86726f8d5a23797d309c0f653ab1ac687833eb2700f156296062a8b377078f45f6b68c3d07cae1913ba8d5a6f9bf7525a3439eb932d4cefc4bf8e1b07b48ca13ece366cbc3e0388915915d1757475103a9e9454e7e6355de2d6acbf4710f9a63e4f6d3cd70c2d6fca88dd8a14448fdb63ce9350fdaafbe0b8bd1c5d307dae76dfed799aef2d8f23d5608d37d1330dd38b94860905dbeebf78d7b7318b7d42aed40d3f9899e9f420cbd92a6eeae3026f7725694e0e4bee016ba346fed2c21172bdb4a461cebe0cfe38e76645226ac127a259c193264d735ce8c8a57e17dd3f0579e2e86dc295ad1f45ba2d85db35044da61f7d401274b31eefbeb34e8d2ae596e9b4541aae117bdac5ed0b324c20539c27c07a411d5288b0b5f6fa16e9a7df85dc319fa6b71cd08a859c06a3f7b0289e1750adbf182f9750fea96fea5ab7aa3473340607cd7ed2c626f5382491c26d5d5bea61401dee7319c94d418f297e61ceac8f258ee8c23831bda081591f5a918e96855774ddedffc51e5b180f1971806d42fc333020b734aeb45adb0bc47325d0cea5f6713a786558022afc39d573892aa3635efbfd8bcb11c57f306c72146afe8b45388125cb7bf9ecf965a7ba4f768c77be366470dcdcf214b7f6a5a9460ed4fe44ae559d85e2fdc2094de83fff12ea8804db1215c4ca865871bdd7f8ef32ab799bf923ffb02c1ded7d129beadad46c5eda31ab1a6f43da05ea08bff7ffa88d8966353d01830558c39b930b01d175e437124d8edd0d2698fd8932f2b2c9b14746e52879c57a395538150f390264f00e60d470711202f4194499ff79037ca9885dc8d695f7d917a3086ca88e8f8d0243efee09302cf39e039eb7cc8dd19d28120d5fe533b5727cd39133181c729ca6f90a015ed30be7668d5cb5ecc33a53ee69bf7d1a5ecbdb153803743c6adaaabd36bf84e5be38d3f04a5d5dbfd67bdcd3b176e65bd1391ade775cc32ce43a847fb6c672a3fe97a5d4081c4986959ec5fb898f42a9397ba2b3ec2c1018f8d76d057f2366bd0e4465514ad6560c599664fb85621fe771e00f43d39b591b2a6a321100f4d1ef23a376d5ae3eeedbfe23da73dff0ee4d16b34ebddd8f5f053db9824105fc7300dbee7ea6af56b112319e3e215a0fc79ae946f6b5227453ec7fcaf17cf7651f71499a50d81221404d5f129ac50ea7528ff0e0069ec4ab8acb7919d81749ab37a870c5ef2cc5a15cf96709d3c65b4addc77e7416847160bcabb94ea36377e0ef71be80b5cc53effd5444888044a353574c72c924bba2a8b4e8354188ebfedc852f590 +MAC = d41c310927cd92e14784ea78b85503db + +# Length 2053. +Key = 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f +Input = 248ac31085b6c2adaaa38259a0d7192c5c35d1bb4ef39ad94c38d1c82479e2dd2159a077024b0589bc8a20101b506f0a1ad0bbab76e83a83f1b94be6beae74e874cab692c5963a75436b776121ec9f62399a3e66b2d22707dae81933b6277f3c8516bcbe26dbbd86f373103d7cf4cad1888c952118fbfbd0d7b4bedc4ae4936aff91157e7aa47c54442ea78d6ac251d324a0fbe49d89cc3521b66d16e9c66a3709894e4eb0a4eedc4ae19468e66b81f271351b1d921ea551047abcc6b87a901fde7db79fa1818c11336dbc07244a40eb14cf77bde35e78ae9ad7d3f57ed7e7f23926c9172f82d77684ea5ed7d74ebc6f142b997036bcb7cce8df1bbc0d5b35a46509c954fc9469d214d6238f166cbf872156b4c41d7aac5942cffb175023078252a3f36e315c5d4ce0e39928a018252862becacef96a19f03bdcf46d75584299d1f8b03c0169e9e407d937145b5e5024139e7022a1978f114f24cdfa23780a119735c41da8fb759bbb3f025c6ec30e6c6e9bce8615be68e392fce59fd26a8e6a6cc5c606e3848116e4d01d29565a1facfb524b6d29643b826eee1e42869fc76df229dd79b39a2b1df28bb335c3a5f15a855d0121e4a6da34b5e4d5b7b5d5746a03ecff70811e1516fcec1bf7462e8876a2d21710aa168c78f45a6a15015950e221da85d3ec822ad6d0a6931b25a06b7bb5f3c10bb36cd4d647f9561982fde9818de5d4bf8db7f86c53b4ff14928ac15f79023b61861e73e44216540bb302153770da2533de9795252ab5fb77ad924c9338c8144c23d4c90dab9a18feac1a1574d4545e1435eb405e6c4c439fc724fce992ae85badf345bad16d85fbd338f04433703614754d0e7e54c4ccde2670587d52ecfb5a70a14a501bacc727722649931d8515b13d020a78e511fe136d45fbf97f9c7f689fcc677cfb3683723878350ffe9d08130cc6e567b6179e01b7eb2b3bbcf0873e1308eec018edeb8cce946338e15d5bf68c71916a83a99358039ef071e009546a2df936879dffbba397a93925d229a469fd17d71b7f524e03a30da6ee927542f8b369bed4734fe25dbd63d24ffd2a222f5f84f75d858ab989be925af570ad6d45bd28ce61b5139e1dd2f0b7795fe072e6e83acbb5e7b777a70c641e4cab2af40eed69abc334cd2703c3273204fac580c6a3d6680427e5f7d051e8380a53f93a180f4556ecea4530b9a2d5948dad63d415b6874f6b90e767d6d265be86351b53ba690780bb57c21b57418c5b97559e840c68257f839e7583a4bf7c7645c5987d40cc1ba79a218c35edfacdabe581d950e4bb7a481ebe64d61d00e75b1f25f1ce5f5462334a5b9038a697aa0937a3f8017e05d2c9c05dcb05c0b02508dea619b137f5444b6f088eb3cb2c66788f88afdfbba8faa1c490485624c88ae11e57347a676902e7553f056188493209bdbb30acc63c9e41e16a9d6c009416b520a76ba38f57628170c43626b5cb46179dc5bf65de865085f84bf741c223fbe474d2d19d8f43914fbd6586351089e73babf344f988b7963fe44528457d7aad3c564f6bcbd0d772a4c9fd328e6022d1c7c9f86726f8d5a23797d309c0f653ab1ac687833eb2700f156296062a8b377078f45f6b68c3d07cae1913ba8d5a6f9bf7525a3439eb932d4cefc4bf8e1b07b48ca13ece366cbc3e0388915915d1757475103a9e9454e7e6355de2d6acbf4710f9a63e4f6d3cd70c2d6fca88dd8a14448fdb63ce9350fdaafbe0b8bd1c5d307dae76dfed799aef2d8f23d5608d37d1330dd38b94860905dbeebf78d7b7318b7d42aed40d3f9899e9f420cbd92a6eeae3026f7725694e0e4bee016ba346fed2c21172bdb4a461cebe0cfe38e76645226ac127a259c193264d735ce8c8a57e17dd3f0579e2e86dc295ad1f45ba2d85db35044da61f7d401274b31eefbeb34e8d2ae596e9b4541aae117bdac5ed0b324c20539c27c07a411d5288b0b5f6fa16e9a7df85dc319fa6b71cd08a859c06a3f7b0289e1750adbf182f9750fea96fea5ab7aa3473340607cd7ed2c626f5382491c26d5d5bea61401dee7319c94d418f297e61ceac8f258ee8c23831bda081591f5a918e96855774ddedffc51e5b180f1971806d42fc333020b734aeb45adb0bc47325d0cea5f6713a786558022afc39d573892aa3635efbfd8bcb11c57f306c72146afe8b45388125cb7bf9ecf965a7ba4f768c77be366470dcdcf214b7f6a5a9460ed4fe44ae559d85e2fdc2094de83fff12ea8804db1215c4ca865871bdd7f8ef32ab799bf923ffb02c1ded7d129beadad46c5eda31ab1a6f43da05ea08bff7ffa88d8966353d01830558c39b930b01d175e437124d8edd0d2698fd8932f2b2c9b14746e52879c57a395538150f390264f00e60d470711202f4194499ff79037ca9885dc8d695f7d917a3086ca88e8f8d0243efee09302cf39e039eb7cc8dd19d28120d5fe533b5727cd39133181c729ca6f90a015ed30be7668d5cb5ecc33a53ee69bf7d1a5ecbdb153803743c6adaaabd36bf84e5be38d3f04a5d5dbfd67bdcd3b176e65bd1391ade775cc32ce43a847fb6c672a3fe97a5d4081c4986959ec5fb898f42a9397ba2b3ec2c1018f8d76d057f2366bd0e4465514ad6560c599664fb85621fe771e00f43d39b591b2a6a321100f4d1ef23a376d5ae3eeedbfe23da73dff0ee4d16b34ebddd8f5f053db9824105fc7300dbee7ea6af56b112319e3e215a0fc79ae946f6b5227453ec7fcaf17cf7651f71499a50d81221404d5f129ac50ea7528ff0e0069ec4ab8acb7919d81749ab37a870c5ef2cc5a15cf96709d3c65b4addc77e7416847160bcabb94ea36377e0ef71be80b5cc53effd5444888044a353574c72c924bba2a8b4e8354188ebfedc852f59073 +MAC = 16af133c423f783a14c49d9f526384cf + +# Length 2054. +Key = 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f +Input = 248ac31085b6c2adaaa38259a0d7192c5c35d1bb4ef39ad94c38d1c82479e2dd2159a077024b0589bc8a20101b506f0a1ad0bbab76e83a83f1b94be6beae74e874cab692c5963a75436b776121ec9f62399a3e66b2d22707dae81933b6277f3c8516bcbe26dbbd86f373103d7cf4cad1888c952118fbfbd0d7b4bedc4ae4936aff91157e7aa47c54442ea78d6ac251d324a0fbe49d89cc3521b66d16e9c66a3709894e4eb0a4eedc4ae19468e66b81f271351b1d921ea551047abcc6b87a901fde7db79fa1818c11336dbc07244a40eb14cf77bde35e78ae9ad7d3f57ed7e7f23926c9172f82d77684ea5ed7d74ebc6f142b997036bcb7cce8df1bbc0d5b35a46509c954fc9469d214d6238f166cbf872156b4c41d7aac5942cffb175023078252a3f36e315c5d4ce0e39928a018252862becacef96a19f03bdcf46d75584299d1f8b03c0169e9e407d937145b5e5024139e7022a1978f114f24cdfa23780a119735c41da8fb759bbb3f025c6ec30e6c6e9bce8615be68e392fce59fd26a8e6a6cc5c606e3848116e4d01d29565a1facfb524b6d29643b826eee1e42869fc76df229dd79b39a2b1df28bb335c3a5f15a855d0121e4a6da34b5e4d5b7b5d5746a03ecff70811e1516fcec1bf7462e8876a2d21710aa168c78f45a6a15015950e221da85d3ec822ad6d0a6931b25a06b7bb5f3c10bb36cd4d647f9561982fde9818de5d4bf8db7f86c53b4ff14928ac15f79023b61861e73e44216540bb302153770da2533de9795252ab5fb77ad924c9338c8144c23d4c90dab9a18feac1a1574d4545e1435eb405e6c4c439fc724fce992ae85badf345bad16d85fbd338f04433703614754d0e7e54c4ccde2670587d52ecfb5a70a14a501bacc727722649931d8515b13d020a78e511fe136d45fbf97f9c7f689fcc677cfb3683723878350ffe9d08130cc6e567b6179e01b7eb2b3bbcf0873e1308eec018edeb8cce946338e15d5bf68c71916a83a99358039ef071e009546a2df936879dffbba397a93925d229a469fd17d71b7f524e03a30da6ee927542f8b369bed4734fe25dbd63d24ffd2a222f5f84f75d858ab989be925af570ad6d45bd28ce61b5139e1dd2f0b7795fe072e6e83acbb5e7b777a70c641e4cab2af40eed69abc334cd2703c3273204fac580c6a3d6680427e5f7d051e8380a53f93a180f4556ecea4530b9a2d5948dad63d415b6874f6b90e767d6d265be86351b53ba690780bb57c21b57418c5b97559e840c68257f839e7583a4bf7c7645c5987d40cc1ba79a218c35edfacdabe581d950e4bb7a481ebe64d61d00e75b1f25f1ce5f5462334a5b9038a697aa0937a3f8017e05d2c9c05dcb05c0b02508dea619b137f5444b6f088eb3cb2c66788f88afdfbba8faa1c490485624c88ae11e57347a676902e7553f056188493209bdbb30acc63c9e41e16a9d6c009416b520a76ba38f57628170c43626b5cb46179dc5bf65de865085f84bf741c223fbe474d2d19d8f43914fbd6586351089e73babf344f988b7963fe44528457d7aad3c564f6bcbd0d772a4c9fd328e6022d1c7c9f86726f8d5a23797d309c0f653ab1ac687833eb2700f156296062a8b377078f45f6b68c3d07cae1913ba8d5a6f9bf7525a3439eb932d4cefc4bf8e1b07b48ca13ece366cbc3e0388915915d1757475103a9e9454e7e6355de2d6acbf4710f9a63e4f6d3cd70c2d6fca88dd8a14448fdb63ce9350fdaafbe0b8bd1c5d307dae76dfed799aef2d8f23d5608d37d1330dd38b94860905dbeebf78d7b7318b7d42aed40d3f9899e9f420cbd92a6eeae3026f7725694e0e4bee016ba346fed2c21172bdb4a461cebe0cfe38e76645226ac127a259c193264d735ce8c8a57e17dd3f0579e2e86dc295ad1f45ba2d85db35044da61f7d401274b31eefbeb34e8d2ae596e9b4541aae117bdac5ed0b324c20539c27c07a411d5288b0b5f6fa16e9a7df85dc319fa6b71cd08a859c06a3f7b0289e1750adbf182f9750fea96fea5ab7aa3473340607cd7ed2c626f5382491c26d5d5bea61401dee7319c94d418f297e61ceac8f258ee8c23831bda081591f5a918e96855774ddedffc51e5b180f1971806d42fc333020b734aeb45adb0bc47325d0cea5f6713a786558022afc39d573892aa3635efbfd8bcb11c57f306c72146afe8b45388125cb7bf9ecf965a7ba4f768c77be366470dcdcf214b7f6a5a9460ed4fe44ae559d85e2fdc2094de83fff12ea8804db1215c4ca865871bdd7f8ef32ab799bf923ffb02c1ded7d129beadad46c5eda31ab1a6f43da05ea08bff7ffa88d8966353d01830558c39b930b01d175e437124d8edd0d2698fd8932f2b2c9b14746e52879c57a395538150f390264f00e60d470711202f4194499ff79037ca9885dc8d695f7d917a3086ca88e8f8d0243efee09302cf39e039eb7cc8dd19d28120d5fe533b5727cd39133181c729ca6f90a015ed30be7668d5cb5ecc33a53ee69bf7d1a5ecbdb153803743c6adaaabd36bf84e5be38d3f04a5d5dbfd67bdcd3b176e65bd1391ade775cc32ce43a847fb6c672a3fe97a5d4081c4986959ec5fb898f42a9397ba2b3ec2c1018f8d76d057f2366bd0e4465514ad6560c599664fb85621fe771e00f43d39b591b2a6a321100f4d1ef23a376d5ae3eeedbfe23da73dff0ee4d16b34ebddd8f5f053db9824105fc7300dbee7ea6af56b112319e3e215a0fc79ae946f6b5227453ec7fcaf17cf7651f71499a50d81221404d5f129ac50ea7528ff0e0069ec4ab8acb7919d81749ab37a870c5ef2cc5a15cf96709d3c65b4addc77e7416847160bcabb94ea36377e0ef71be80b5cc53effd5444888044a353574c72c924bba2a8b4e8354188ebfedc852f59073f4 +MAC = 00c75db8f0636b22f195645b03091f5f + +# Length 2055. +Key = 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f +Input = 248ac31085b6c2adaaa38259a0d7192c5c35d1bb4ef39ad94c38d1c82479e2dd2159a077024b0589bc8a20101b506f0a1ad0bbab76e83a83f1b94be6beae74e874cab692c5963a75436b776121ec9f62399a3e66b2d22707dae81933b6277f3c8516bcbe26dbbd86f373103d7cf4cad1888c952118fbfbd0d7b4bedc4ae4936aff91157e7aa47c54442ea78d6ac251d324a0fbe49d89cc3521b66d16e9c66a3709894e4eb0a4eedc4ae19468e66b81f271351b1d921ea551047abcc6b87a901fde7db79fa1818c11336dbc07244a40eb14cf77bde35e78ae9ad7d3f57ed7e7f23926c9172f82d77684ea5ed7d74ebc6f142b997036bcb7cce8df1bbc0d5b35a46509c954fc9469d214d6238f166cbf872156b4c41d7aac5942cffb175023078252a3f36e315c5d4ce0e39928a018252862becacef96a19f03bdcf46d75584299d1f8b03c0169e9e407d937145b5e5024139e7022a1978f114f24cdfa23780a119735c41da8fb759bbb3f025c6ec30e6c6e9bce8615be68e392fce59fd26a8e6a6cc5c606e3848116e4d01d29565a1facfb524b6d29643b826eee1e42869fc76df229dd79b39a2b1df28bb335c3a5f15a855d0121e4a6da34b5e4d5b7b5d5746a03ecff70811e1516fcec1bf7462e8876a2d21710aa168c78f45a6a15015950e221da85d3ec822ad6d0a6931b25a06b7bb5f3c10bb36cd4d647f9561982fde9818de5d4bf8db7f86c53b4ff14928ac15f79023b61861e73e44216540bb302153770da2533de9795252ab5fb77ad924c9338c8144c23d4c90dab9a18feac1a1574d4545e1435eb405e6c4c439fc724fce992ae85badf345bad16d85fbd338f04433703614754d0e7e54c4ccde2670587d52ecfb5a70a14a501bacc727722649931d8515b13d020a78e511fe136d45fbf97f9c7f689fcc677cfb3683723878350ffe9d08130cc6e567b6179e01b7eb2b3bbcf0873e1308eec018edeb8cce946338e15d5bf68c71916a83a99358039ef071e009546a2df936879dffbba397a93925d229a469fd17d71b7f524e03a30da6ee927542f8b369bed4734fe25dbd63d24ffd2a222f5f84f75d858ab989be925af570ad6d45bd28ce61b5139e1dd2f0b7795fe072e6e83acbb5e7b777a70c641e4cab2af40eed69abc334cd2703c3273204fac580c6a3d6680427e5f7d051e8380a53f93a180f4556ecea4530b9a2d5948dad63d415b6874f6b90e767d6d265be86351b53ba690780bb57c21b57418c5b97559e840c68257f839e7583a4bf7c7645c5987d40cc1ba79a218c35edfacdabe581d950e4bb7a481ebe64d61d00e75b1f25f1ce5f5462334a5b9038a697aa0937a3f8017e05d2c9c05dcb05c0b02508dea619b137f5444b6f088eb3cb2c66788f88afdfbba8faa1c490485624c88ae11e57347a676902e7553f056188493209bdbb30acc63c9e41e16a9d6c009416b520a76ba38f57628170c43626b5cb46179dc5bf65de865085f84bf741c223fbe474d2d19d8f43914fbd6586351089e73babf344f988b7963fe44528457d7aad3c564f6bcbd0d772a4c9fd328e6022d1c7c9f86726f8d5a23797d309c0f653ab1ac687833eb2700f156296062a8b377078f45f6b68c3d07cae1913ba8d5a6f9bf7525a3439eb932d4cefc4bf8e1b07b48ca13ece366cbc3e0388915915d1757475103a9e9454e7e6355de2d6acbf4710f9a63e4f6d3cd70c2d6fca88dd8a14448fdb63ce9350fdaafbe0b8bd1c5d307dae76dfed799aef2d8f23d5608d37d1330dd38b94860905dbeebf78d7b7318b7d42aed40d3f9899e9f420cbd92a6eeae3026f7725694e0e4bee016ba346fed2c21172bdb4a461cebe0cfe38e76645226ac127a259c193264d735ce8c8a57e17dd3f0579e2e86dc295ad1f45ba2d85db35044da61f7d401274b31eefbeb34e8d2ae596e9b4541aae117bdac5ed0b324c20539c27c07a411d5288b0b5f6fa16e9a7df85dc319fa6b71cd08a859c06a3f7b0289e1750adbf182f9750fea96fea5ab7aa3473340607cd7ed2c626f5382491c26d5d5bea61401dee7319c94d418f297e61ceac8f258ee8c23831bda081591f5a918e96855774ddedffc51e5b180f1971806d42fc333020b734aeb45adb0bc47325d0cea5f6713a786558022afc39d573892aa3635efbfd8bcb11c57f306c72146afe8b45388125cb7bf9ecf965a7ba4f768c77be366470dcdcf214b7f6a5a9460ed4fe44ae559d85e2fdc2094de83fff12ea8804db1215c4ca865871bdd7f8ef32ab799bf923ffb02c1ded7d129beadad46c5eda31ab1a6f43da05ea08bff7ffa88d8966353d01830558c39b930b01d175e437124d8edd0d2698fd8932f2b2c9b14746e52879c57a395538150f390264f00e60d470711202f4194499ff79037ca9885dc8d695f7d917a3086ca88e8f8d0243efee09302cf39e039eb7cc8dd19d28120d5fe533b5727cd39133181c729ca6f90a015ed30be7668d5cb5ecc33a53ee69bf7d1a5ecbdb153803743c6adaaabd36bf84e5be38d3f04a5d5dbfd67bdcd3b176e65bd1391ade775cc32ce43a847fb6c672a3fe97a5d4081c4986959ec5fb898f42a9397ba2b3ec2c1018f8d76d057f2366bd0e4465514ad6560c599664fb85621fe771e00f43d39b591b2a6a321100f4d1ef23a376d5ae3eeedbfe23da73dff0ee4d16b34ebddd8f5f053db9824105fc7300dbee7ea6af56b112319e3e215a0fc79ae946f6b5227453ec7fcaf17cf7651f71499a50d81221404d5f129ac50ea7528ff0e0069ec4ab8acb7919d81749ab37a870c5ef2cc5a15cf96709d3c65b4addc77e7416847160bcabb94ea36377e0ef71be80b5cc53effd5444888044a353574c72c924bba2a8b4e8354188ebfedc852f59073f434 +MAC = 4a532bc740f581555831345f3b75bf33 + +# Length 2056. +Key = 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f +Input = 248ac31085b6c2adaaa38259a0d7192c5c35d1bb4ef39ad94c38d1c82479e2dd2159a077024b0589bc8a20101b506f0a1ad0bbab76e83a83f1b94be6beae74e874cab692c5963a75436b776121ec9f62399a3e66b2d22707dae81933b6277f3c8516bcbe26dbbd86f373103d7cf4cad1888c952118fbfbd0d7b4bedc4ae4936aff91157e7aa47c54442ea78d6ac251d324a0fbe49d89cc3521b66d16e9c66a3709894e4eb0a4eedc4ae19468e66b81f271351b1d921ea551047abcc6b87a901fde7db79fa1818c11336dbc07244a40eb14cf77bde35e78ae9ad7d3f57ed7e7f23926c9172f82d77684ea5ed7d74ebc6f142b997036bcb7cce8df1bbc0d5b35a46509c954fc9469d214d6238f166cbf872156b4c41d7aac5942cffb175023078252a3f36e315c5d4ce0e39928a018252862becacef96a19f03bdcf46d75584299d1f8b03c0169e9e407d937145b5e5024139e7022a1978f114f24cdfa23780a119735c41da8fb759bbb3f025c6ec30e6c6e9bce8615be68e392fce59fd26a8e6a6cc5c606e3848116e4d01d29565a1facfb524b6d29643b826eee1e42869fc76df229dd79b39a2b1df28bb335c3a5f15a855d0121e4a6da34b5e4d5b7b5d5746a03ecff70811e1516fcec1bf7462e8876a2d21710aa168c78f45a6a15015950e221da85d3ec822ad6d0a6931b25a06b7bb5f3c10bb36cd4d647f9561982fde9818de5d4bf8db7f86c53b4ff14928ac15f79023b61861e73e44216540bb302153770da2533de9795252ab5fb77ad924c9338c8144c23d4c90dab9a18feac1a1574d4545e1435eb405e6c4c439fc724fce992ae85badf345bad16d85fbd338f04433703614754d0e7e54c4ccde2670587d52ecfb5a70a14a501bacc727722649931d8515b13d020a78e511fe136d45fbf97f9c7f689fcc677cfb3683723878350ffe9d08130cc6e567b6179e01b7eb2b3bbcf0873e1308eec018edeb8cce946338e15d5bf68c71916a83a99358039ef071e009546a2df936879dffbba397a93925d229a469fd17d71b7f524e03a30da6ee927542f8b369bed4734fe25dbd63d24ffd2a222f5f84f75d858ab989be925af570ad6d45bd28ce61b5139e1dd2f0b7795fe072e6e83acbb5e7b777a70c641e4cab2af40eed69abc334cd2703c3273204fac580c6a3d6680427e5f7d051e8380a53f93a180f4556ecea4530b9a2d5948dad63d415b6874f6b90e767d6d265be86351b53ba690780bb57c21b57418c5b97559e840c68257f839e7583a4bf7c7645c5987d40cc1ba79a218c35edfacdabe581d950e4bb7a481ebe64d61d00e75b1f25f1ce5f5462334a5b9038a697aa0937a3f8017e05d2c9c05dcb05c0b02508dea619b137f5444b6f088eb3cb2c66788f88afdfbba8faa1c490485624c88ae11e57347a676902e7553f056188493209bdbb30acc63c9e41e16a9d6c009416b520a76ba38f57628170c43626b5cb46179dc5bf65de865085f84bf741c223fbe474d2d19d8f43914fbd6586351089e73babf344f988b7963fe44528457d7aad3c564f6bcbd0d772a4c9fd328e6022d1c7c9f86726f8d5a23797d309c0f653ab1ac687833eb2700f156296062a8b377078f45f6b68c3d07cae1913ba8d5a6f9bf7525a3439eb932d4cefc4bf8e1b07b48ca13ece366cbc3e0388915915d1757475103a9e9454e7e6355de2d6acbf4710f9a63e4f6d3cd70c2d6fca88dd8a14448fdb63ce9350fdaafbe0b8bd1c5d307dae76dfed799aef2d8f23d5608d37d1330dd38b94860905dbeebf78d7b7318b7d42aed40d3f9899e9f420cbd92a6eeae3026f7725694e0e4bee016ba346fed2c21172bdb4a461cebe0cfe38e76645226ac127a259c193264d735ce8c8a57e17dd3f0579e2e86dc295ad1f45ba2d85db35044da61f7d401274b31eefbeb34e8d2ae596e9b4541aae117bdac5ed0b324c20539c27c07a411d5288b0b5f6fa16e9a7df85dc319fa6b71cd08a859c06a3f7b0289e1750adbf182f9750fea96fea5ab7aa3473340607cd7ed2c626f5382491c26d5d5bea61401dee7319c94d418f297e61ceac8f258ee8c23831bda081591f5a918e96855774ddedffc51e5b180f1971806d42fc333020b734aeb45adb0bc47325d0cea5f6713a786558022afc39d573892aa3635efbfd8bcb11c57f306c72146afe8b45388125cb7bf9ecf965a7ba4f768c77be366470dcdcf214b7f6a5a9460ed4fe44ae559d85e2fdc2094de83fff12ea8804db1215c4ca865871bdd7f8ef32ab799bf923ffb02c1ded7d129beadad46c5eda31ab1a6f43da05ea08bff7ffa88d8966353d01830558c39b930b01d175e437124d8edd0d2698fd8932f2b2c9b14746e52879c57a395538150f390264f00e60d470711202f4194499ff79037ca9885dc8d695f7d917a3086ca88e8f8d0243efee09302cf39e039eb7cc8dd19d28120d5fe533b5727cd39133181c729ca6f90a015ed30be7668d5cb5ecc33a53ee69bf7d1a5ecbdb153803743c6adaaabd36bf84e5be38d3f04a5d5dbfd67bdcd3b176e65bd1391ade775cc32ce43a847fb6c672a3fe97a5d4081c4986959ec5fb898f42a9397ba2b3ec2c1018f8d76d057f2366bd0e4465514ad6560c599664fb85621fe771e00f43d39b591b2a6a321100f4d1ef23a376d5ae3eeedbfe23da73dff0ee4d16b34ebddd8f5f053db9824105fc7300dbee7ea6af56b112319e3e215a0fc79ae946f6b5227453ec7fcaf17cf7651f71499a50d81221404d5f129ac50ea7528ff0e0069ec4ab8acb7919d81749ab37a870c5ef2cc5a15cf96709d3c65b4addc77e7416847160bcabb94ea36377e0ef71be80b5cc53effd5444888044a353574c72c924bba2a8b4e8354188ebfedc852f59073f4347a +MAC = 698c7d32c5923871d124a2479e521706 + +# Length 2057. +Key = 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f +Input = 248ac31085b6c2adaaa38259a0d7192c5c35d1bb4ef39ad94c38d1c82479e2dd2159a077024b0589bc8a20101b506f0a1ad0bbab76e83a83f1b94be6beae74e874cab692c5963a75436b776121ec9f62399a3e66b2d22707dae81933b6277f3c8516bcbe26dbbd86f373103d7cf4cad1888c952118fbfbd0d7b4bedc4ae4936aff91157e7aa47c54442ea78d6ac251d324a0fbe49d89cc3521b66d16e9c66a3709894e4eb0a4eedc4ae19468e66b81f271351b1d921ea551047abcc6b87a901fde7db79fa1818c11336dbc07244a40eb14cf77bde35e78ae9ad7d3f57ed7e7f23926c9172f82d77684ea5ed7d74ebc6f142b997036bcb7cce8df1bbc0d5b35a46509c954fc9469d214d6238f166cbf872156b4c41d7aac5942cffb175023078252a3f36e315c5d4ce0e39928a018252862becacef96a19f03bdcf46d75584299d1f8b03c0169e9e407d937145b5e5024139e7022a1978f114f24cdfa23780a119735c41da8fb759bbb3f025c6ec30e6c6e9bce8615be68e392fce59fd26a8e6a6cc5c606e3848116e4d01d29565a1facfb524b6d29643b826eee1e42869fc76df229dd79b39a2b1df28bb335c3a5f15a855d0121e4a6da34b5e4d5b7b5d5746a03ecff70811e1516fcec1bf7462e8876a2d21710aa168c78f45a6a15015950e221da85d3ec822ad6d0a6931b25a06b7bb5f3c10bb36cd4d647f9561982fde9818de5d4bf8db7f86c53b4ff14928ac15f79023b61861e73e44216540bb302153770da2533de9795252ab5fb77ad924c9338c8144c23d4c90dab9a18feac1a1574d4545e1435eb405e6c4c439fc724fce992ae85badf345bad16d85fbd338f04433703614754d0e7e54c4ccde2670587d52ecfb5a70a14a501bacc727722649931d8515b13d020a78e511fe136d45fbf97f9c7f689fcc677cfb3683723878350ffe9d08130cc6e567b6179e01b7eb2b3bbcf0873e1308eec018edeb8cce946338e15d5bf68c71916a83a99358039ef071e009546a2df936879dffbba397a93925d229a469fd17d71b7f524e03a30da6ee927542f8b369bed4734fe25dbd63d24ffd2a222f5f84f75d858ab989be925af570ad6d45bd28ce61b5139e1dd2f0b7795fe072e6e83acbb5e7b777a70c641e4cab2af40eed69abc334cd2703c3273204fac580c6a3d6680427e5f7d051e8380a53f93a180f4556ecea4530b9a2d5948dad63d415b6874f6b90e767d6d265be86351b53ba690780bb57c21b57418c5b97559e840c68257f839e7583a4bf7c7645c5987d40cc1ba79a218c35edfacdabe581d950e4bb7a481ebe64d61d00e75b1f25f1ce5f5462334a5b9038a697aa0937a3f8017e05d2c9c05dcb05c0b02508dea619b137f5444b6f088eb3cb2c66788f88afdfbba8faa1c490485624c88ae11e57347a676902e7553f056188493209bdbb30acc63c9e41e16a9d6c009416b520a76ba38f57628170c43626b5cb46179dc5bf65de865085f84bf741c223fbe474d2d19d8f43914fbd6586351089e73babf344f988b7963fe44528457d7aad3c564f6bcbd0d772a4c9fd328e6022d1c7c9f86726f8d5a23797d309c0f653ab1ac687833eb2700f156296062a8b377078f45f6b68c3d07cae1913ba8d5a6f9bf7525a3439eb932d4cefc4bf8e1b07b48ca13ece366cbc3e0388915915d1757475103a9e9454e7e6355de2d6acbf4710f9a63e4f6d3cd70c2d6fca88dd8a14448fdb63ce9350fdaafbe0b8bd1c5d307dae76dfed799aef2d8f23d5608d37d1330dd38b94860905dbeebf78d7b7318b7d42aed40d3f9899e9f420cbd92a6eeae3026f7725694e0e4bee016ba346fed2c21172bdb4a461cebe0cfe38e76645226ac127a259c193264d735ce8c8a57e17dd3f0579e2e86dc295ad1f45ba2d85db35044da61f7d401274b31eefbeb34e8d2ae596e9b4541aae117bdac5ed0b324c20539c27c07a411d5288b0b5f6fa16e9a7df85dc319fa6b71cd08a859c06a3f7b0289e1750adbf182f9750fea96fea5ab7aa3473340607cd7ed2c626f5382491c26d5d5bea61401dee7319c94d418f297e61ceac8f258ee8c23831bda081591f5a918e96855774ddedffc51e5b180f1971806d42fc333020b734aeb45adb0bc47325d0cea5f6713a786558022afc39d573892aa3635efbfd8bcb11c57f306c72146afe8b45388125cb7bf9ecf965a7ba4f768c77be366470dcdcf214b7f6a5a9460ed4fe44ae559d85e2fdc2094de83fff12ea8804db1215c4ca865871bdd7f8ef32ab799bf923ffb02c1ded7d129beadad46c5eda31ab1a6f43da05ea08bff7ffa88d8966353d01830558c39b930b01d175e437124d8edd0d2698fd8932f2b2c9b14746e52879c57a395538150f390264f00e60d470711202f4194499ff79037ca9885dc8d695f7d917a3086ca88e8f8d0243efee09302cf39e039eb7cc8dd19d28120d5fe533b5727cd39133181c729ca6f90a015ed30be7668d5cb5ecc33a53ee69bf7d1a5ecbdb153803743c6adaaabd36bf84e5be38d3f04a5d5dbfd67bdcd3b176e65bd1391ade775cc32ce43a847fb6c672a3fe97a5d4081c4986959ec5fb898f42a9397ba2b3ec2c1018f8d76d057f2366bd0e4465514ad6560c599664fb85621fe771e00f43d39b591b2a6a321100f4d1ef23a376d5ae3eeedbfe23da73dff0ee4d16b34ebddd8f5f053db9824105fc7300dbee7ea6af56b112319e3e215a0fc79ae946f6b5227453ec7fcaf17cf7651f71499a50d81221404d5f129ac50ea7528ff0e0069ec4ab8acb7919d81749ab37a870c5ef2cc5a15cf96709d3c65b4addc77e7416847160bcabb94ea36377e0ef71be80b5cc53effd5444888044a353574c72c924bba2a8b4e8354188ebfedc852f59073f4347a8c +MAC = a677187dbf3c927aeeafb9ebce0f61dc + +# Length 2058. +Key = 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f +Input = 248ac31085b6c2adaaa38259a0d7192c5c35d1bb4ef39ad94c38d1c82479e2dd2159a077024b0589bc8a20101b506f0a1ad0bbab76e83a83f1b94be6beae74e874cab692c5963a75436b776121ec9f62399a3e66b2d22707dae81933b6277f3c8516bcbe26dbbd86f373103d7cf4cad1888c952118fbfbd0d7b4bedc4ae4936aff91157e7aa47c54442ea78d6ac251d324a0fbe49d89cc3521b66d16e9c66a3709894e4eb0a4eedc4ae19468e66b81f271351b1d921ea551047abcc6b87a901fde7db79fa1818c11336dbc07244a40eb14cf77bde35e78ae9ad7d3f57ed7e7f23926c9172f82d77684ea5ed7d74ebc6f142b997036bcb7cce8df1bbc0d5b35a46509c954fc9469d214d6238f166cbf872156b4c41d7aac5942cffb175023078252a3f36e315c5d4ce0e39928a018252862becacef96a19f03bdcf46d75584299d1f8b03c0169e9e407d937145b5e5024139e7022a1978f114f24cdfa23780a119735c41da8fb759bbb3f025c6ec30e6c6e9bce8615be68e392fce59fd26a8e6a6cc5c606e3848116e4d01d29565a1facfb524b6d29643b826eee1e42869fc76df229dd79b39a2b1df28bb335c3a5f15a855d0121e4a6da34b5e4d5b7b5d5746a03ecff70811e1516fcec1bf7462e8876a2d21710aa168c78f45a6a15015950e221da85d3ec822ad6d0a6931b25a06b7bb5f3c10bb36cd4d647f9561982fde9818de5d4bf8db7f86c53b4ff14928ac15f79023b61861e73e44216540bb302153770da2533de9795252ab5fb77ad924c9338c8144c23d4c90dab9a18feac1a1574d4545e1435eb405e6c4c439fc724fce992ae85badf345bad16d85fbd338f04433703614754d0e7e54c4ccde2670587d52ecfb5a70a14a501bacc727722649931d8515b13d020a78e511fe136d45fbf97f9c7f689fcc677cfb3683723878350ffe9d08130cc6e567b6179e01b7eb2b3bbcf0873e1308eec018edeb8cce946338e15d5bf68c71916a83a99358039ef071e009546a2df936879dffbba397a93925d229a469fd17d71b7f524e03a30da6ee927542f8b369bed4734fe25dbd63d24ffd2a222f5f84f75d858ab989be925af570ad6d45bd28ce61b5139e1dd2f0b7795fe072e6e83acbb5e7b777a70c641e4cab2af40eed69abc334cd2703c3273204fac580c6a3d6680427e5f7d051e8380a53f93a180f4556ecea4530b9a2d5948dad63d415b6874f6b90e767d6d265be86351b53ba690780bb57c21b57418c5b97559e840c68257f839e7583a4bf7c7645c5987d40cc1ba79a218c35edfacdabe581d950e4bb7a481ebe64d61d00e75b1f25f1ce5f5462334a5b9038a697aa0937a3f8017e05d2c9c05dcb05c0b02508dea619b137f5444b6f088eb3cb2c66788f88afdfbba8faa1c490485624c88ae11e57347a676902e7553f056188493209bdbb30acc63c9e41e16a9d6c009416b520a76ba38f57628170c43626b5cb46179dc5bf65de865085f84bf741c223fbe474d2d19d8f43914fbd6586351089e73babf344f988b7963fe44528457d7aad3c564f6bcbd0d772a4c9fd328e6022d1c7c9f86726f8d5a23797d309c0f653ab1ac687833eb2700f156296062a8b377078f45f6b68c3d07cae1913ba8d5a6f9bf7525a3439eb932d4cefc4bf8e1b07b48ca13ece366cbc3e0388915915d1757475103a9e9454e7e6355de2d6acbf4710f9a63e4f6d3cd70c2d6fca88dd8a14448fdb63ce9350fdaafbe0b8bd1c5d307dae76dfed799aef2d8f23d5608d37d1330dd38b94860905dbeebf78d7b7318b7d42aed40d3f9899e9f420cbd92a6eeae3026f7725694e0e4bee016ba346fed2c21172bdb4a461cebe0cfe38e76645226ac127a259c193264d735ce8c8a57e17dd3f0579e2e86dc295ad1f45ba2d85db35044da61f7d401274b31eefbeb34e8d2ae596e9b4541aae117bdac5ed0b324c20539c27c07a411d5288b0b5f6fa16e9a7df85dc319fa6b71cd08a859c06a3f7b0289e1750adbf182f9750fea96fea5ab7aa3473340607cd7ed2c626f5382491c26d5d5bea61401dee7319c94d418f297e61ceac8f258ee8c23831bda081591f5a918e96855774ddedffc51e5b180f1971806d42fc333020b734aeb45adb0bc47325d0cea5f6713a786558022afc39d573892aa3635efbfd8bcb11c57f306c72146afe8b45388125cb7bf9ecf965a7ba4f768c77be366470dcdcf214b7f6a5a9460ed4fe44ae559d85e2fdc2094de83fff12ea8804db1215c4ca865871bdd7f8ef32ab799bf923ffb02c1ded7d129beadad46c5eda31ab1a6f43da05ea08bff7ffa88d8966353d01830558c39b930b01d175e437124d8edd0d2698fd8932f2b2c9b14746e52879c57a395538150f390264f00e60d470711202f4194499ff79037ca9885dc8d695f7d917a3086ca88e8f8d0243efee09302cf39e039eb7cc8dd19d28120d5fe533b5727cd39133181c729ca6f90a015ed30be7668d5cb5ecc33a53ee69bf7d1a5ecbdb153803743c6adaaabd36bf84e5be38d3f04a5d5dbfd67bdcd3b176e65bd1391ade775cc32ce43a847fb6c672a3fe97a5d4081c4986959ec5fb898f42a9397ba2b3ec2c1018f8d76d057f2366bd0e4465514ad6560c599664fb85621fe771e00f43d39b591b2a6a321100f4d1ef23a376d5ae3eeedbfe23da73dff0ee4d16b34ebddd8f5f053db9824105fc7300dbee7ea6af56b112319e3e215a0fc79ae946f6b5227453ec7fcaf17cf7651f71499a50d81221404d5f129ac50ea7528ff0e0069ec4ab8acb7919d81749ab37a870c5ef2cc5a15cf96709d3c65b4addc77e7416847160bcabb94ea36377e0ef71be80b5cc53effd5444888044a353574c72c924bba2a8b4e8354188ebfedc852f59073f4347a8c8a +MAC = 201fed7eee981b31d2cc42ff6c38141a + +# Length 2059. +Key = 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f +Input = 248ac31085b6c2adaaa38259a0d7192c5c35d1bb4ef39ad94c38d1c82479e2dd2159a077024b0589bc8a20101b506f0a1ad0bbab76e83a83f1b94be6beae74e874cab692c5963a75436b776121ec9f62399a3e66b2d22707dae81933b6277f3c8516bcbe26dbbd86f373103d7cf4cad1888c952118fbfbd0d7b4bedc4ae4936aff91157e7aa47c54442ea78d6ac251d324a0fbe49d89cc3521b66d16e9c66a3709894e4eb0a4eedc4ae19468e66b81f271351b1d921ea551047abcc6b87a901fde7db79fa1818c11336dbc07244a40eb14cf77bde35e78ae9ad7d3f57ed7e7f23926c9172f82d77684ea5ed7d74ebc6f142b997036bcb7cce8df1bbc0d5b35a46509c954fc9469d214d6238f166cbf872156b4c41d7aac5942cffb175023078252a3f36e315c5d4ce0e39928a018252862becacef96a19f03bdcf46d75584299d1f8b03c0169e9e407d937145b5e5024139e7022a1978f114f24cdfa23780a119735c41da8fb759bbb3f025c6ec30e6c6e9bce8615be68e392fce59fd26a8e6a6cc5c606e3848116e4d01d29565a1facfb524b6d29643b826eee1e42869fc76df229dd79b39a2b1df28bb335c3a5f15a855d0121e4a6da34b5e4d5b7b5d5746a03ecff70811e1516fcec1bf7462e8876a2d21710aa168c78f45a6a15015950e221da85d3ec822ad6d0a6931b25a06b7bb5f3c10bb36cd4d647f9561982fde9818de5d4bf8db7f86c53b4ff14928ac15f79023b61861e73e44216540bb302153770da2533de9795252ab5fb77ad924c9338c8144c23d4c90dab9a18feac1a1574d4545e1435eb405e6c4c439fc724fce992ae85badf345bad16d85fbd338f04433703614754d0e7e54c4ccde2670587d52ecfb5a70a14a501bacc727722649931d8515b13d020a78e511fe136d45fbf97f9c7f689fcc677cfb3683723878350ffe9d08130cc6e567b6179e01b7eb2b3bbcf0873e1308eec018edeb8cce946338e15d5bf68c71916a83a99358039ef071e009546a2df936879dffbba397a93925d229a469fd17d71b7f524e03a30da6ee927542f8b369bed4734fe25dbd63d24ffd2a222f5f84f75d858ab989be925af570ad6d45bd28ce61b5139e1dd2f0b7795fe072e6e83acbb5e7b777a70c641e4cab2af40eed69abc334cd2703c3273204fac580c6a3d6680427e5f7d051e8380a53f93a180f4556ecea4530b9a2d5948dad63d415b6874f6b90e767d6d265be86351b53ba690780bb57c21b57418c5b97559e840c68257f839e7583a4bf7c7645c5987d40cc1ba79a218c35edfacdabe581d950e4bb7a481ebe64d61d00e75b1f25f1ce5f5462334a5b9038a697aa0937a3f8017e05d2c9c05dcb05c0b02508dea619b137f5444b6f088eb3cb2c66788f88afdfbba8faa1c490485624c88ae11e57347a676902e7553f056188493209bdbb30acc63c9e41e16a9d6c009416b520a76ba38f57628170c43626b5cb46179dc5bf65de865085f84bf741c223fbe474d2d19d8f43914fbd6586351089e73babf344f988b7963fe44528457d7aad3c564f6bcbd0d772a4c9fd328e6022d1c7c9f86726f8d5a23797d309c0f653ab1ac687833eb2700f156296062a8b377078f45f6b68c3d07cae1913ba8d5a6f9bf7525a3439eb932d4cefc4bf8e1b07b48ca13ece366cbc3e0388915915d1757475103a9e9454e7e6355de2d6acbf4710f9a63e4f6d3cd70c2d6fca88dd8a14448fdb63ce9350fdaafbe0b8bd1c5d307dae76dfed799aef2d8f23d5608d37d1330dd38b94860905dbeebf78d7b7318b7d42aed40d3f9899e9f420cbd92a6eeae3026f7725694e0e4bee016ba346fed2c21172bdb4a461cebe0cfe38e76645226ac127a259c193264d735ce8c8a57e17dd3f0579e2e86dc295ad1f45ba2d85db35044da61f7d401274b31eefbeb34e8d2ae596e9b4541aae117bdac5ed0b324c20539c27c07a411d5288b0b5f6fa16e9a7df85dc319fa6b71cd08a859c06a3f7b0289e1750adbf182f9750fea96fea5ab7aa3473340607cd7ed2c626f5382491c26d5d5bea61401dee7319c94d418f297e61ceac8f258ee8c23831bda081591f5a918e96855774ddedffc51e5b180f1971806d42fc333020b734aeb45adb0bc47325d0cea5f6713a786558022afc39d573892aa3635efbfd8bcb11c57f306c72146afe8b45388125cb7bf9ecf965a7ba4f768c77be366470dcdcf214b7f6a5a9460ed4fe44ae559d85e2fdc2094de83fff12ea8804db1215c4ca865871bdd7f8ef32ab799bf923ffb02c1ded7d129beadad46c5eda31ab1a6f43da05ea08bff7ffa88d8966353d01830558c39b930b01d175e437124d8edd0d2698fd8932f2b2c9b14746e52879c57a395538150f390264f00e60d470711202f4194499ff79037ca9885dc8d695f7d917a3086ca88e8f8d0243efee09302cf39e039eb7cc8dd19d28120d5fe533b5727cd39133181c729ca6f90a015ed30be7668d5cb5ecc33a53ee69bf7d1a5ecbdb153803743c6adaaabd36bf84e5be38d3f04a5d5dbfd67bdcd3b176e65bd1391ade775cc32ce43a847fb6c672a3fe97a5d4081c4986959ec5fb898f42a9397ba2b3ec2c1018f8d76d057f2366bd0e4465514ad6560c599664fb85621fe771e00f43d39b591b2a6a321100f4d1ef23a376d5ae3eeedbfe23da73dff0ee4d16b34ebddd8f5f053db9824105fc7300dbee7ea6af56b112319e3e215a0fc79ae946f6b5227453ec7fcaf17cf7651f71499a50d81221404d5f129ac50ea7528ff0e0069ec4ab8acb7919d81749ab37a870c5ef2cc5a15cf96709d3c65b4addc77e7416847160bcabb94ea36377e0ef71be80b5cc53effd5444888044a353574c72c924bba2a8b4e8354188ebfedc852f59073f4347a8c8a28 +MAC = 0c3d3d01a37f347c4f7c5826bcafb3e1 + +# Length 2060. +Key = 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f +Input = 248ac31085b6c2adaaa38259a0d7192c5c35d1bb4ef39ad94c38d1c82479e2dd2159a077024b0589bc8a20101b506f0a1ad0bbab76e83a83f1b94be6beae74e874cab692c5963a75436b776121ec9f62399a3e66b2d22707dae81933b6277f3c8516bcbe26dbbd86f373103d7cf4cad1888c952118fbfbd0d7b4bedc4ae4936aff91157e7aa47c54442ea78d6ac251d324a0fbe49d89cc3521b66d16e9c66a3709894e4eb0a4eedc4ae19468e66b81f271351b1d921ea551047abcc6b87a901fde7db79fa1818c11336dbc07244a40eb14cf77bde35e78ae9ad7d3f57ed7e7f23926c9172f82d77684ea5ed7d74ebc6f142b997036bcb7cce8df1bbc0d5b35a46509c954fc9469d214d6238f166cbf872156b4c41d7aac5942cffb175023078252a3f36e315c5d4ce0e39928a018252862becacef96a19f03bdcf46d75584299d1f8b03c0169e9e407d937145b5e5024139e7022a1978f114f24cdfa23780a119735c41da8fb759bbb3f025c6ec30e6c6e9bce8615be68e392fce59fd26a8e6a6cc5c606e3848116e4d01d29565a1facfb524b6d29643b826eee1e42869fc76df229dd79b39a2b1df28bb335c3a5f15a855d0121e4a6da34b5e4d5b7b5d5746a03ecff70811e1516fcec1bf7462e8876a2d21710aa168c78f45a6a15015950e221da85d3ec822ad6d0a6931b25a06b7bb5f3c10bb36cd4d647f9561982fde9818de5d4bf8db7f86c53b4ff14928ac15f79023b61861e73e44216540bb302153770da2533de9795252ab5fb77ad924c9338c8144c23d4c90dab9a18feac1a1574d4545e1435eb405e6c4c439fc724fce992ae85badf345bad16d85fbd338f04433703614754d0e7e54c4ccde2670587d52ecfb5a70a14a501bacc727722649931d8515b13d020a78e511fe136d45fbf97f9c7f689fcc677cfb3683723878350ffe9d08130cc6e567b6179e01b7eb2b3bbcf0873e1308eec018edeb8cce946338e15d5bf68c71916a83a99358039ef071e009546a2df936879dffbba397a93925d229a469fd17d71b7f524e03a30da6ee927542f8b369bed4734fe25dbd63d24ffd2a222f5f84f75d858ab989be925af570ad6d45bd28ce61b5139e1dd2f0b7795fe072e6e83acbb5e7b777a70c641e4cab2af40eed69abc334cd2703c3273204fac580c6a3d6680427e5f7d051e8380a53f93a180f4556ecea4530b9a2d5948dad63d415b6874f6b90e767d6d265be86351b53ba690780bb57c21b57418c5b97559e840c68257f839e7583a4bf7c7645c5987d40cc1ba79a218c35edfacdabe581d950e4bb7a481ebe64d61d00e75b1f25f1ce5f5462334a5b9038a697aa0937a3f8017e05d2c9c05dcb05c0b02508dea619b137f5444b6f088eb3cb2c66788f88afdfbba8faa1c490485624c88ae11e57347a676902e7553f056188493209bdbb30acc63c9e41e16a9d6c009416b520a76ba38f57628170c43626b5cb46179dc5bf65de865085f84bf741c223fbe474d2d19d8f43914fbd6586351089e73babf344f988b7963fe44528457d7aad3c564f6bcbd0d772a4c9fd328e6022d1c7c9f86726f8d5a23797d309c0f653ab1ac687833eb2700f156296062a8b377078f45f6b68c3d07cae1913ba8d5a6f9bf7525a3439eb932d4cefc4bf8e1b07b48ca13ece366cbc3e0388915915d1757475103a9e9454e7e6355de2d6acbf4710f9a63e4f6d3cd70c2d6fca88dd8a14448fdb63ce9350fdaafbe0b8bd1c5d307dae76dfed799aef2d8f23d5608d37d1330dd38b94860905dbeebf78d7b7318b7d42aed40d3f9899e9f420cbd92a6eeae3026f7725694e0e4bee016ba346fed2c21172bdb4a461cebe0cfe38e76645226ac127a259c193264d735ce8c8a57e17dd3f0579e2e86dc295ad1f45ba2d85db35044da61f7d401274b31eefbeb34e8d2ae596e9b4541aae117bdac5ed0b324c20539c27c07a411d5288b0b5f6fa16e9a7df85dc319fa6b71cd08a859c06a3f7b0289e1750adbf182f9750fea96fea5ab7aa3473340607cd7ed2c626f5382491c26d5d5bea61401dee7319c94d418f297e61ceac8f258ee8c23831bda081591f5a918e96855774ddedffc51e5b180f1971806d42fc333020b734aeb45adb0bc47325d0cea5f6713a786558022afc39d573892aa3635efbfd8bcb11c57f306c72146afe8b45388125cb7bf9ecf965a7ba4f768c77be366470dcdcf214b7f6a5a9460ed4fe44ae559d85e2fdc2094de83fff12ea8804db1215c4ca865871bdd7f8ef32ab799bf923ffb02c1ded7d129beadad46c5eda31ab1a6f43da05ea08bff7ffa88d8966353d01830558c39b930b01d175e437124d8edd0d2698fd8932f2b2c9b14746e52879c57a395538150f390264f00e60d470711202f4194499ff79037ca9885dc8d695f7d917a3086ca88e8f8d0243efee09302cf39e039eb7cc8dd19d28120d5fe533b5727cd39133181c729ca6f90a015ed30be7668d5cb5ecc33a53ee69bf7d1a5ecbdb153803743c6adaaabd36bf84e5be38d3f04a5d5dbfd67bdcd3b176e65bd1391ade775cc32ce43a847fb6c672a3fe97a5d4081c4986959ec5fb898f42a9397ba2b3ec2c1018f8d76d057f2366bd0e4465514ad6560c599664fb85621fe771e00f43d39b591b2a6a321100f4d1ef23a376d5ae3eeedbfe23da73dff0ee4d16b34ebddd8f5f053db9824105fc7300dbee7ea6af56b112319e3e215a0fc79ae946f6b5227453ec7fcaf17cf7651f71499a50d81221404d5f129ac50ea7528ff0e0069ec4ab8acb7919d81749ab37a870c5ef2cc5a15cf96709d3c65b4addc77e7416847160bcabb94ea36377e0ef71be80b5cc53effd5444888044a353574c72c924bba2a8b4e8354188ebfedc852f59073f4347a8c8a28c9 +MAC = 33a4e0e0bed7c84c5cc5dd4784410f07 + +# Length 2061. +Key = 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f +Input = 248ac31085b6c2adaaa38259a0d7192c5c35d1bb4ef39ad94c38d1c82479e2dd2159a077024b0589bc8a20101b506f0a1ad0bbab76e83a83f1b94be6beae74e874cab692c5963a75436b776121ec9f62399a3e66b2d22707dae81933b6277f3c8516bcbe26dbbd86f373103d7cf4cad1888c952118fbfbd0d7b4bedc4ae4936aff91157e7aa47c54442ea78d6ac251d324a0fbe49d89cc3521b66d16e9c66a3709894e4eb0a4eedc4ae19468e66b81f271351b1d921ea551047abcc6b87a901fde7db79fa1818c11336dbc07244a40eb14cf77bde35e78ae9ad7d3f57ed7e7f23926c9172f82d77684ea5ed7d74ebc6f142b997036bcb7cce8df1bbc0d5b35a46509c954fc9469d214d6238f166cbf872156b4c41d7aac5942cffb175023078252a3f36e315c5d4ce0e39928a018252862becacef96a19f03bdcf46d75584299d1f8b03c0169e9e407d937145b5e5024139e7022a1978f114f24cdfa23780a119735c41da8fb759bbb3f025c6ec30e6c6e9bce8615be68e392fce59fd26a8e6a6cc5c606e3848116e4d01d29565a1facfb524b6d29643b826eee1e42869fc76df229dd79b39a2b1df28bb335c3a5f15a855d0121e4a6da34b5e4d5b7b5d5746a03ecff70811e1516fcec1bf7462e8876a2d21710aa168c78f45a6a15015950e221da85d3ec822ad6d0a6931b25a06b7bb5f3c10bb36cd4d647f9561982fde9818de5d4bf8db7f86c53b4ff14928ac15f79023b61861e73e44216540bb302153770da2533de9795252ab5fb77ad924c9338c8144c23d4c90dab9a18feac1a1574d4545e1435eb405e6c4c439fc724fce992ae85badf345bad16d85fbd338f04433703614754d0e7e54c4ccde2670587d52ecfb5a70a14a501bacc727722649931d8515b13d020a78e511fe136d45fbf97f9c7f689fcc677cfb3683723878350ffe9d08130cc6e567b6179e01b7eb2b3bbcf0873e1308eec018edeb8cce946338e15d5bf68c71916a83a99358039ef071e009546a2df936879dffbba397a93925d229a469fd17d71b7f524e03a30da6ee927542f8b369bed4734fe25dbd63d24ffd2a222f5f84f75d858ab989be925af570ad6d45bd28ce61b5139e1dd2f0b7795fe072e6e83acbb5e7b777a70c641e4cab2af40eed69abc334cd2703c3273204fac580c6a3d6680427e5f7d051e8380a53f93a180f4556ecea4530b9a2d5948dad63d415b6874f6b90e767d6d265be86351b53ba690780bb57c21b57418c5b97559e840c68257f839e7583a4bf7c7645c5987d40cc1ba79a218c35edfacdabe581d950e4bb7a481ebe64d61d00e75b1f25f1ce5f5462334a5b9038a697aa0937a3f8017e05d2c9c05dcb05c0b02508dea619b137f5444b6f088eb3cb2c66788f88afdfbba8faa1c490485624c88ae11e57347a676902e7553f056188493209bdbb30acc63c9e41e16a9d6c009416b520a76ba38f57628170c43626b5cb46179dc5bf65de865085f84bf741c223fbe474d2d19d8f43914fbd6586351089e73babf344f988b7963fe44528457d7aad3c564f6bcbd0d772a4c9fd328e6022d1c7c9f86726f8d5a23797d309c0f653ab1ac687833eb2700f156296062a8b377078f45f6b68c3d07cae1913ba8d5a6f9bf7525a3439eb932d4cefc4bf8e1b07b48ca13ece366cbc3e0388915915d1757475103a9e9454e7e6355de2d6acbf4710f9a63e4f6d3cd70c2d6fca88dd8a14448fdb63ce9350fdaafbe0b8bd1c5d307dae76dfed799aef2d8f23d5608d37d1330dd38b94860905dbeebf78d7b7318b7d42aed40d3f9899e9f420cbd92a6eeae3026f7725694e0e4bee016ba346fed2c21172bdb4a461cebe0cfe38e76645226ac127a259c193264d735ce8c8a57e17dd3f0579e2e86dc295ad1f45ba2d85db35044da61f7d401274b31eefbeb34e8d2ae596e9b4541aae117bdac5ed0b324c20539c27c07a411d5288b0b5f6fa16e9a7df85dc319fa6b71cd08a859c06a3f7b0289e1750adbf182f9750fea96fea5ab7aa3473340607cd7ed2c626f5382491c26d5d5bea61401dee7319c94d418f297e61ceac8f258ee8c23831bda081591f5a918e96855774ddedffc51e5b180f1971806d42fc333020b734aeb45adb0bc47325d0cea5f6713a786558022afc39d573892aa3635efbfd8bcb11c57f306c72146afe8b45388125cb7bf9ecf965a7ba4f768c77be366470dcdcf214b7f6a5a9460ed4fe44ae559d85e2fdc2094de83fff12ea8804db1215c4ca865871bdd7f8ef32ab799bf923ffb02c1ded7d129beadad46c5eda31ab1a6f43da05ea08bff7ffa88d8966353d01830558c39b930b01d175e437124d8edd0d2698fd8932f2b2c9b14746e52879c57a395538150f390264f00e60d470711202f4194499ff79037ca9885dc8d695f7d917a3086ca88e8f8d0243efee09302cf39e039eb7cc8dd19d28120d5fe533b5727cd39133181c729ca6f90a015ed30be7668d5cb5ecc33a53ee69bf7d1a5ecbdb153803743c6adaaabd36bf84e5be38d3f04a5d5dbfd67bdcd3b176e65bd1391ade775cc32ce43a847fb6c672a3fe97a5d4081c4986959ec5fb898f42a9397ba2b3ec2c1018f8d76d057f2366bd0e4465514ad6560c599664fb85621fe771e00f43d39b591b2a6a321100f4d1ef23a376d5ae3eeedbfe23da73dff0ee4d16b34ebddd8f5f053db9824105fc7300dbee7ea6af56b112319e3e215a0fc79ae946f6b5227453ec7fcaf17cf7651f71499a50d81221404d5f129ac50ea7528ff0e0069ec4ab8acb7919d81749ab37a870c5ef2cc5a15cf96709d3c65b4addc77e7416847160bcabb94ea36377e0ef71be80b5cc53effd5444888044a353574c72c924bba2a8b4e8354188ebfedc852f59073f4347a8c8a28c99e +MAC = 8e41c40a2f8ec58fe594f3a3a2de4ae1 + +# Length 2062. +Key = 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f +Input = 248ac31085b6c2adaaa38259a0d7192c5c35d1bb4ef39ad94c38d1c82479e2dd2159a077024b0589bc8a20101b506f0a1ad0bbab76e83a83f1b94be6beae74e874cab692c5963a75436b776121ec9f62399a3e66b2d22707dae81933b6277f3c8516bcbe26dbbd86f373103d7cf4cad1888c952118fbfbd0d7b4bedc4ae4936aff91157e7aa47c54442ea78d6ac251d324a0fbe49d89cc3521b66d16e9c66a3709894e4eb0a4eedc4ae19468e66b81f271351b1d921ea551047abcc6b87a901fde7db79fa1818c11336dbc07244a40eb14cf77bde35e78ae9ad7d3f57ed7e7f23926c9172f82d77684ea5ed7d74ebc6f142b997036bcb7cce8df1bbc0d5b35a46509c954fc9469d214d6238f166cbf872156b4c41d7aac5942cffb175023078252a3f36e315c5d4ce0e39928a018252862becacef96a19f03bdcf46d75584299d1f8b03c0169e9e407d937145b5e5024139e7022a1978f114f24cdfa23780a119735c41da8fb759bbb3f025c6ec30e6c6e9bce8615be68e392fce59fd26a8e6a6cc5c606e3848116e4d01d29565a1facfb524b6d29643b826eee1e42869fc76df229dd79b39a2b1df28bb335c3a5f15a855d0121e4a6da34b5e4d5b7b5d5746a03ecff70811e1516fcec1bf7462e8876a2d21710aa168c78f45a6a15015950e221da85d3ec822ad6d0a6931b25a06b7bb5f3c10bb36cd4d647f9561982fde9818de5d4bf8db7f86c53b4ff14928ac15f79023b61861e73e44216540bb302153770da2533de9795252ab5fb77ad924c9338c8144c23d4c90dab9a18feac1a1574d4545e1435eb405e6c4c439fc724fce992ae85badf345bad16d85fbd338f04433703614754d0e7e54c4ccde2670587d52ecfb5a70a14a501bacc727722649931d8515b13d020a78e511fe136d45fbf97f9c7f689fcc677cfb3683723878350ffe9d08130cc6e567b6179e01b7eb2b3bbcf0873e1308eec018edeb8cce946338e15d5bf68c71916a83a99358039ef071e009546a2df936879dffbba397a93925d229a469fd17d71b7f524e03a30da6ee927542f8b369bed4734fe25dbd63d24ffd2a222f5f84f75d858ab989be925af570ad6d45bd28ce61b5139e1dd2f0b7795fe072e6e83acbb5e7b777a70c641e4cab2af40eed69abc334cd2703c3273204fac580c6a3d6680427e5f7d051e8380a53f93a180f4556ecea4530b9a2d5948dad63d415b6874f6b90e767d6d265be86351b53ba690780bb57c21b57418c5b97559e840c68257f839e7583a4bf7c7645c5987d40cc1ba79a218c35edfacdabe581d950e4bb7a481ebe64d61d00e75b1f25f1ce5f5462334a5b9038a697aa0937a3f8017e05d2c9c05dcb05c0b02508dea619b137f5444b6f088eb3cb2c66788f88afdfbba8faa1c490485624c88ae11e57347a676902e7553f056188493209bdbb30acc63c9e41e16a9d6c009416b520a76ba38f57628170c43626b5cb46179dc5bf65de865085f84bf741c223fbe474d2d19d8f43914fbd6586351089e73babf344f988b7963fe44528457d7aad3c564f6bcbd0d772a4c9fd328e6022d1c7c9f86726f8d5a23797d309c0f653ab1ac687833eb2700f156296062a8b377078f45f6b68c3d07cae1913ba8d5a6f9bf7525a3439eb932d4cefc4bf8e1b07b48ca13ece366cbc3e0388915915d1757475103a9e9454e7e6355de2d6acbf4710f9a63e4f6d3cd70c2d6fca88dd8a14448fdb63ce9350fdaafbe0b8bd1c5d307dae76dfed799aef2d8f23d5608d37d1330dd38b94860905dbeebf78d7b7318b7d42aed40d3f9899e9f420cbd92a6eeae3026f7725694e0e4bee016ba346fed2c21172bdb4a461cebe0cfe38e76645226ac127a259c193264d735ce8c8a57e17dd3f0579e2e86dc295ad1f45ba2d85db35044da61f7d401274b31eefbeb34e8d2ae596e9b4541aae117bdac5ed0b324c20539c27c07a411d5288b0b5f6fa16e9a7df85dc319fa6b71cd08a859c06a3f7b0289e1750adbf182f9750fea96fea5ab7aa3473340607cd7ed2c626f5382491c26d5d5bea61401dee7319c94d418f297e61ceac8f258ee8c23831bda081591f5a918e96855774ddedffc51e5b180f1971806d42fc333020b734aeb45adb0bc47325d0cea5f6713a786558022afc39d573892aa3635efbfd8bcb11c57f306c72146afe8b45388125cb7bf9ecf965a7ba4f768c77be366470dcdcf214b7f6a5a9460ed4fe44ae559d85e2fdc2094de83fff12ea8804db1215c4ca865871bdd7f8ef32ab799bf923ffb02c1ded7d129beadad46c5eda31ab1a6f43da05ea08bff7ffa88d8966353d01830558c39b930b01d175e437124d8edd0d2698fd8932f2b2c9b14746e52879c57a395538150f390264f00e60d470711202f4194499ff79037ca9885dc8d695f7d917a3086ca88e8f8d0243efee09302cf39e039eb7cc8dd19d28120d5fe533b5727cd39133181c729ca6f90a015ed30be7668d5cb5ecc33a53ee69bf7d1a5ecbdb153803743c6adaaabd36bf84e5be38d3f04a5d5dbfd67bdcd3b176e65bd1391ade775cc32ce43a847fb6c672a3fe97a5d4081c4986959ec5fb898f42a9397ba2b3ec2c1018f8d76d057f2366bd0e4465514ad6560c599664fb85621fe771e00f43d39b591b2a6a321100f4d1ef23a376d5ae3eeedbfe23da73dff0ee4d16b34ebddd8f5f053db9824105fc7300dbee7ea6af56b112319e3e215a0fc79ae946f6b5227453ec7fcaf17cf7651f71499a50d81221404d5f129ac50ea7528ff0e0069ec4ab8acb7919d81749ab37a870c5ef2cc5a15cf96709d3c65b4addc77e7416847160bcabb94ea36377e0ef71be80b5cc53effd5444888044a353574c72c924bba2a8b4e8354188ebfedc852f59073f4347a8c8a28c99e21 +MAC = c6e5d1810fd878ac6b844c66cef36a22 + +# Length 2063. +Key = 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f +Input = 248ac31085b6c2adaaa38259a0d7192c5c35d1bb4ef39ad94c38d1c82479e2dd2159a077024b0589bc8a20101b506f0a1ad0bbab76e83a83f1b94be6beae74e874cab692c5963a75436b776121ec9f62399a3e66b2d22707dae81933b6277f3c8516bcbe26dbbd86f373103d7cf4cad1888c952118fbfbd0d7b4bedc4ae4936aff91157e7aa47c54442ea78d6ac251d324a0fbe49d89cc3521b66d16e9c66a3709894e4eb0a4eedc4ae19468e66b81f271351b1d921ea551047abcc6b87a901fde7db79fa1818c11336dbc07244a40eb14cf77bde35e78ae9ad7d3f57ed7e7f23926c9172f82d77684ea5ed7d74ebc6f142b997036bcb7cce8df1bbc0d5b35a46509c954fc9469d214d6238f166cbf872156b4c41d7aac5942cffb175023078252a3f36e315c5d4ce0e39928a018252862becacef96a19f03bdcf46d75584299d1f8b03c0169e9e407d937145b5e5024139e7022a1978f114f24cdfa23780a119735c41da8fb759bbb3f025c6ec30e6c6e9bce8615be68e392fce59fd26a8e6a6cc5c606e3848116e4d01d29565a1facfb524b6d29643b826eee1e42869fc76df229dd79b39a2b1df28bb335c3a5f15a855d0121e4a6da34b5e4d5b7b5d5746a03ecff70811e1516fcec1bf7462e8876a2d21710aa168c78f45a6a15015950e221da85d3ec822ad6d0a6931b25a06b7bb5f3c10bb36cd4d647f9561982fde9818de5d4bf8db7f86c53b4ff14928ac15f79023b61861e73e44216540bb302153770da2533de9795252ab5fb77ad924c9338c8144c23d4c90dab9a18feac1a1574d4545e1435eb405e6c4c439fc724fce992ae85badf345bad16d85fbd338f04433703614754d0e7e54c4ccde2670587d52ecfb5a70a14a501bacc727722649931d8515b13d020a78e511fe136d45fbf97f9c7f689fcc677cfb3683723878350ffe9d08130cc6e567b6179e01b7eb2b3bbcf0873e1308eec018edeb8cce946338e15d5bf68c71916a83a99358039ef071e009546a2df936879dffbba397a93925d229a469fd17d71b7f524e03a30da6ee927542f8b369bed4734fe25dbd63d24ffd2a222f5f84f75d858ab989be925af570ad6d45bd28ce61b5139e1dd2f0b7795fe072e6e83acbb5e7b777a70c641e4cab2af40eed69abc334cd2703c3273204fac580c6a3d6680427e5f7d051e8380a53f93a180f4556ecea4530b9a2d5948dad63d415b6874f6b90e767d6d265be86351b53ba690780bb57c21b57418c5b97559e840c68257f839e7583a4bf7c7645c5987d40cc1ba79a218c35edfacdabe581d950e4bb7a481ebe64d61d00e75b1f25f1ce5f5462334a5b9038a697aa0937a3f8017e05d2c9c05dcb05c0b02508dea619b137f5444b6f088eb3cb2c66788f88afdfbba8faa1c490485624c88ae11e57347a676902e7553f056188493209bdbb30acc63c9e41e16a9d6c009416b520a76ba38f57628170c43626b5cb46179dc5bf65de865085f84bf741c223fbe474d2d19d8f43914fbd6586351089e73babf344f988b7963fe44528457d7aad3c564f6bcbd0d772a4c9fd328e6022d1c7c9f86726f8d5a23797d309c0f653ab1ac687833eb2700f156296062a8b377078f45f6b68c3d07cae1913ba8d5a6f9bf7525a3439eb932d4cefc4bf8e1b07b48ca13ece366cbc3e0388915915d1757475103a9e9454e7e6355de2d6acbf4710f9a63e4f6d3cd70c2d6fca88dd8a14448fdb63ce9350fdaafbe0b8bd1c5d307dae76dfed799aef2d8f23d5608d37d1330dd38b94860905dbeebf78d7b7318b7d42aed40d3f9899e9f420cbd92a6eeae3026f7725694e0e4bee016ba346fed2c21172bdb4a461cebe0cfe38e76645226ac127a259c193264d735ce8c8a57e17dd3f0579e2e86dc295ad1f45ba2d85db35044da61f7d401274b31eefbeb34e8d2ae596e9b4541aae117bdac5ed0b324c20539c27c07a411d5288b0b5f6fa16e9a7df85dc319fa6b71cd08a859c06a3f7b0289e1750adbf182f9750fea96fea5ab7aa3473340607cd7ed2c626f5382491c26d5d5bea61401dee7319c94d418f297e61ceac8f258ee8c23831bda081591f5a918e96855774ddedffc51e5b180f1971806d42fc333020b734aeb45adb0bc47325d0cea5f6713a786558022afc39d573892aa3635efbfd8bcb11c57f306c72146afe8b45388125cb7bf9ecf965a7ba4f768c77be366470dcdcf214b7f6a5a9460ed4fe44ae559d85e2fdc2094de83fff12ea8804db1215c4ca865871bdd7f8ef32ab799bf923ffb02c1ded7d129beadad46c5eda31ab1a6f43da05ea08bff7ffa88d8966353d01830558c39b930b01d175e437124d8edd0d2698fd8932f2b2c9b14746e52879c57a395538150f390264f00e60d470711202f4194499ff79037ca9885dc8d695f7d917a3086ca88e8f8d0243efee09302cf39e039eb7cc8dd19d28120d5fe533b5727cd39133181c729ca6f90a015ed30be7668d5cb5ecc33a53ee69bf7d1a5ecbdb153803743c6adaaabd36bf84e5be38d3f04a5d5dbfd67bdcd3b176e65bd1391ade775cc32ce43a847fb6c672a3fe97a5d4081c4986959ec5fb898f42a9397ba2b3ec2c1018f8d76d057f2366bd0e4465514ad6560c599664fb85621fe771e00f43d39b591b2a6a321100f4d1ef23a376d5ae3eeedbfe23da73dff0ee4d16b34ebddd8f5f053db9824105fc7300dbee7ea6af56b112319e3e215a0fc79ae946f6b5227453ec7fcaf17cf7651f71499a50d81221404d5f129ac50ea7528ff0e0069ec4ab8acb7919d81749ab37a870c5ef2cc5a15cf96709d3c65b4addc77e7416847160bcabb94ea36377e0ef71be80b5cc53effd5444888044a353574c72c924bba2a8b4e8354188ebfedc852f59073f4347a8c8a28c99e21df +MAC = f6eaae369c3cb5c05748e8d919178e00 + +# Regression test for https://rt.openssl.org/Ticket/Display.html?id=4439 +Key = 2d773be37adb1e4d683bf0075e79c4ee037918535a7f99ccb7040fb5f5f43aea +Input = 89dab80b7717c1db5db437860a3f70218e93e1b8f461fb677f16f35f6f87e2a91c99bc3a47ace47640cc95c345be5ecca5a3523c35cc01893af0b64a620334270372ec12482d1b1e363561698a578b359803495bb4e2ef1930b17a5190b580f141300df30adbeca28f6427a8bc1a999fd51c554a017d095d8c3e3127daf9f595 +MAC = c85d15ed44c378d6b00e23064c7bcd51 + +# Regression tests for https://rt.openssl.org/Ticket/Display.html?id=4483 + +Key = 7f1b02640000000000000000000000000000000000000000cccccccccccccccc +Input = cccccccccccccccccccccccccccccccccccccccccccccccccc80ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccceccccccccccccccccccccccccccccccccccccc5cccccccccccccccccccccccccccccccccccccccccce3ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccaccccccccccccccccccccce6cccccccccc000000afccccccccccccccccccfffffff5000000000000000000000000000000000000000000000000000000ffffffe70000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000719205a8521dfc +MAC = 8559b876eceed66eb37798c0457baff9 + +Key = e00016000000000000000000000000000000aaaaaaaaaaaaaaaaaaaaaaaaaaaa +Input = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa000000000000000000800264 +MAC = 00bd1258978e205444c9aaaa82006fed + +Key = 0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c +Input = 02fc +MAC = 06120c0c0c0c0c0c0c0c0c0c0c0c0c0c + +Key = 00ff000000000000000000000000000000000000001e00000000000000007b7b +Input = 7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7a7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b5c7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b6e7b007b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7a7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b5c7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b6e7b001300000000b300000000000000000000000000000000000000000000f20000000000000000000000000000000000002000efff0009000000000000000000000000100000000009000000640000000000000000000000001300000000b300000000000000000000000000000000000000000000f20000000000000000000000000000000000002000efff00090000000000000000007a000010000000000900000064000000000000000000000000000000000000000000000000fc +MAC = 33205bbf9e9f8f7212ab9e2ab9b7e4a5 diff --git a/http/vendor/ring/src/aead/quic.rs b/http/vendor/ring/src/aead/quic.rs new file mode 100644 index 0000000..a0cbe08 --- /dev/null +++ b/http/vendor/ring/src/aead/quic.rs @@ -0,0 +1,187 @@ +// Copyright 2018 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! QUIC Header Protection. +//! +//! See draft-ietf-quic-tls. + +use crate::{ + aead::{aes, chacha}, + cpu, error, hkdf, +}; + +/// A key for generating QUIC Header Protection masks. +pub struct HeaderProtectionKey { + inner: KeyInner, + algorithm: &'static Algorithm, +} + +#[allow(clippy::large_enum_variant, variant_size_differences)] +enum KeyInner { + Aes(aes::Key), + ChaCha20(chacha::Key), +} + +impl From> for HeaderProtectionKey { + fn from(okm: hkdf::Okm<&'static Algorithm>) -> Self { + let mut key_bytes = [0; super::MAX_KEY_LEN]; + let algorithm = *okm.len(); + let key_bytes = &mut key_bytes[..algorithm.key_len()]; + okm.fill(key_bytes).unwrap(); + Self::new(algorithm, key_bytes).unwrap() + } +} + +impl HeaderProtectionKey { + /// Create a new header protection key. + /// + /// `key_bytes` must be exactly `algorithm.key_len` bytes long. + pub fn new( + algorithm: &'static Algorithm, + key_bytes: &[u8], + ) -> Result { + Ok(Self { + inner: (algorithm.init)(key_bytes, cpu::features())?, + algorithm, + }) + } + + /// Generate a new QUIC Header Protection mask. + /// + /// `sample` must be exactly `self.algorithm().sample_len()` bytes long. + pub fn new_mask(&self, sample: &[u8]) -> Result<[u8; 5], error::Unspecified> { + let sample = <&[u8; SAMPLE_LEN]>::try_from(sample)?; + + let out = (self.algorithm.new_mask)(&self.inner, *sample); + Ok(out) + } + + /// The key's algorithm. + #[inline(always)] + pub fn algorithm(&self) -> &'static Algorithm { + self.algorithm + } +} + +const SAMPLE_LEN: usize = super::TAG_LEN; + +/// QUIC sample for new key masks +pub type Sample = [u8; SAMPLE_LEN]; + +/// A QUIC Header Protection Algorithm. +pub struct Algorithm { + init: fn(key: &[u8], cpu_features: cpu::Features) -> Result, + + new_mask: fn(key: &KeyInner, sample: Sample) -> [u8; 5], + + key_len: usize, + id: AlgorithmID, +} + +impl hkdf::KeyType for &'static Algorithm { + #[inline] + fn len(&self) -> usize { + self.key_len() + } +} + +impl Algorithm { + /// The length of the key. + #[inline(always)] + pub fn key_len(&self) -> usize { + self.key_len + } + + /// The required sample length. + #[inline(always)] + pub fn sample_len(&self) -> usize { + SAMPLE_LEN + } +} + +derive_debug_via_id!(Algorithm); + +#[derive(Debug, Eq, PartialEq)] +enum AlgorithmID { + AES_128, + AES_256, + CHACHA20, +} + +impl PartialEq for Algorithm { + fn eq(&self, other: &Self) -> bool { + self.id == other.id + } +} + +impl Eq for Algorithm {} + +/// AES-128. +pub static AES_128: Algorithm = Algorithm { + key_len: 16, + init: aes_init_128, + new_mask: aes_new_mask, + id: AlgorithmID::AES_128, +}; + +/// AES-256. +pub static AES_256: Algorithm = Algorithm { + key_len: 32, + init: aes_init_256, + new_mask: aes_new_mask, + id: AlgorithmID::AES_256, +}; + +fn aes_init_128(key: &[u8], cpu_features: cpu::Features) -> Result { + let key = key.try_into().map_err(|_| error::Unspecified)?; + let aes_key = aes::Key::new(aes::KeyBytes::AES_128(key), cpu_features)?; + Ok(KeyInner::Aes(aes_key)) +} + +fn aes_init_256(key: &[u8], cpu_features: cpu::Features) -> Result { + let key = key.try_into().map_err(|_| error::Unspecified)?; + let aes_key = aes::Key::new(aes::KeyBytes::AES_256(key), cpu_features)?; + Ok(KeyInner::Aes(aes_key)) +} + +fn aes_new_mask(key: &KeyInner, sample: Sample) -> [u8; 5] { + let aes_key = match key { + KeyInner::Aes(key) => key, + _ => unreachable!(), + }; + + aes_key.new_mask(sample) +} + +/// ChaCha20. +pub static CHACHA20: Algorithm = Algorithm { + key_len: chacha::KEY_LEN, + init: chacha20_init, + new_mask: chacha20_new_mask, + id: AlgorithmID::CHACHA20, +}; + +fn chacha20_init(key: &[u8], _cpu_features: cpu::Features) -> Result { + let chacha20_key: [u8; chacha::KEY_LEN] = key.try_into()?; + Ok(KeyInner::ChaCha20(chacha::Key::new(chacha20_key))) +} + +fn chacha20_new_mask(key: &KeyInner, sample: Sample) -> [u8; 5] { + let chacha20_key = match key { + KeyInner::ChaCha20(key) => key, + _ => unreachable!(), + }; + + chacha20_key.new_mask(sample) +} diff --git a/http/vendor/ring/src/aead/sealing_key.rs b/http/vendor/ring/src/aead/sealing_key.rs new file mode 100644 index 0000000..5b8607b --- /dev/null +++ b/http/vendor/ring/src/aead/sealing_key.rs @@ -0,0 +1,104 @@ +// Copyright 2015-2021 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! Authenticated Encryption with Associated Data (AEAD). +//! +//! See [Authenticated encryption: relations among notions and analysis of the +//! generic composition paradigm][AEAD] for an introduction to the concept of +//! AEADs. +//! +//! [AEAD]: https://eprint.iacr.org/2000/025.pdf +//! [`crypto.cipher.AEAD`]: https://golang.org/pkg/crypto/cipher/#AEAD + +use super::{Aad, Algorithm, BoundKey, LessSafeKey, NonceSequence, Tag, UnboundKey}; +use crate::error; + +/// An AEAD key for encrypting and signing ("sealing"), bound to a nonce +/// sequence. +/// +/// Intentionally not `Clone` or `Copy` since cloning would allow duplication +/// of the nonce sequence. +pub struct SealingKey { + key: LessSafeKey, + nonce_sequence: N, +} + +impl BoundKey for SealingKey { + fn new(key: UnboundKey, nonce_sequence: N) -> Self { + Self { + key: key.into_inner(), + nonce_sequence, + } + } + + #[inline] + fn algorithm(&self) -> &'static Algorithm { + self.key.algorithm() + } +} + +impl core::fmt::Debug for SealingKey { + fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> { + self.key.fmt_debug("SealingKey", f) + } +} + +impl SealingKey { + /// Encrypts and signs (“seals”) data in place, appending the tag to the + /// resulting ciphertext. + /// + /// `key.seal_in_place_append_tag(aad, in_out)` is equivalent to: + /// + /// ```skip + /// key.seal_in_place_separate_tag(aad, in_out.as_mut()) + /// .map(|tag| in_out.extend(tag.as_ref())) + /// ``` + #[inline] + pub fn seal_in_place_append_tag( + &mut self, + aad: Aad, + in_out: &mut InOut, + ) -> Result<(), error::Unspecified> + where + A: AsRef<[u8]>, + InOut: AsMut<[u8]> + for<'in_out> Extend<&'in_out u8>, + { + self.key + .seal_in_place_append_tag(self.nonce_sequence.advance()?, aad, in_out) + } + + /// Encrypts and signs (“seals”) data in place. + /// + /// `aad` is the additional authenticated data (AAD), if any. This is + /// authenticated but not encrypted. The type `A` could be a byte slice + /// `&[u8]`, a byte array `[u8; N]` for some constant `N`, `Vec`, etc. + /// If there is no AAD then use `Aad::empty()`. + /// + /// The plaintext is given as the input value of `in_out`. `seal_in_place()` + /// will overwrite the plaintext with the ciphertext and return the tag. + /// For most protocols, the caller must append the tag to the ciphertext. + /// The tag will be `self.algorithm.tag_len()` bytes long. + #[inline] + pub fn seal_in_place_separate_tag( + &mut self, + aad: Aad, + in_out: &mut [u8], + ) -> Result + where + A: AsRef<[u8]>, + { + self.key + .seal_in_place_separate_tag(self.nonce_sequence.advance()?, aad, in_out) + } +} diff --git a/http/vendor/ring/src/aead/shift.rs b/http/vendor/ring/src/aead/shift.rs new file mode 100644 index 0000000..3bd7f46 --- /dev/null +++ b/http/vendor/ring/src/aead/shift.rs @@ -0,0 +1,32 @@ +// Copyright 2018 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#[cfg(target_arch = "x86")] +pub fn shift_full_blocks( + in_out: super::overlapping::Overlapping<'_, u8>, + mut transform: impl FnMut(&[u8; BLOCK_LEN]) -> [u8; BLOCK_LEN], +) { + let (in_out, src) = in_out.into_slice_src_mut(); + let in_out_len = in_out[src.clone()].len(); + + for i in (0..in_out_len).step_by(BLOCK_LEN) { + let block = { + let input = + <&[u8; BLOCK_LEN]>::try_from(&in_out[(src.start + i)..][..BLOCK_LEN]).unwrap(); + transform(input) + }; + let output = <&mut [u8; BLOCK_LEN]>::try_from(&mut in_out[i..][..BLOCK_LEN]).unwrap(); + *output = block; + } +} diff --git a/http/vendor/ring/src/aead/unbound_key.rs b/http/vendor/ring/src/aead/unbound_key.rs new file mode 100644 index 0000000..23f9df9 --- /dev/null +++ b/http/vendor/ring/src/aead/unbound_key.rs @@ -0,0 +1,74 @@ +// Copyright 2015-2021 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! Authenticated Encryption with Associated Data (AEAD). +//! +//! See [Authenticated encryption: relations among notions and analysis of the +//! generic composition paradigm][AEAD] for an introduction to the concept of +//! AEADs. +//! +//! [AEAD]: https://eprint.iacr.org/2000/025.pdf +//! [`crypto.cipher.AEAD`]: https://golang.org/pkg/crypto/cipher/#AEAD + +use super::{Algorithm, LessSafeKey, MAX_KEY_LEN}; +use crate::{cpu, error, hkdf}; + +/// An AEAD key without a designated role or nonce sequence. +pub struct UnboundKey { + inner: LessSafeKey, +} + +impl UnboundKey { + /// Constructs a `UnboundKey`. + /// + /// Fails if `key_bytes.len() != algorithm.key_len()`. + #[inline] + pub fn new( + algorithm: &'static Algorithm, + key_bytes: &[u8], + ) -> Result { + Ok(Self { + inner: LessSafeKey::new_(algorithm, key_bytes, cpu::features())?, + }) + } + + /// The key's AEAD algorithm. + #[inline] + pub fn algorithm(&self) -> &'static Algorithm { + self.inner.algorithm() + } + + #[inline] + pub(super) fn into_inner(self) -> LessSafeKey { + self.inner + } +} + +impl core::fmt::Debug for UnboundKey { + fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> { + self.inner.fmt_debug("UnboundKey", f) + } +} + +impl From> for UnboundKey { + fn from(okm: hkdf::Okm<&'static Algorithm>) -> Self { + let mut key_bytes = [0; MAX_KEY_LEN]; + let key_bytes = &mut key_bytes[..okm.len().key_len()]; + let algorithm = *okm.len(); + okm.fill(key_bytes).unwrap(); + Self { + inner: LessSafeKey::new_(algorithm, key_bytes, cpu::features()).unwrap(), + } + } +} diff --git a/http/vendor/ring/src/agreement.rs b/http/vendor/ring/src/agreement.rs new file mode 100644 index 0000000..770423f --- /dev/null +++ b/http/vendor/ring/src/agreement.rs @@ -0,0 +1,311 @@ +// Copyright 2015-2017 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! Key Agreement: ECDH, including X25519. +//! +//! # Example +//! +//! Note that this example uses X25519, but ECDH using NIST P-256/P-384 is done +//! exactly the same way, just substituting +//! `agreement::ECDH_P256`/`agreement::ECDH_P384` for `agreement::X25519`. +//! +//! ``` +//! use ring::{agreement, rand}; +//! +//! let rng = rand::SystemRandom::new(); +//! +//! let my_private_key = agreement::EphemeralPrivateKey::generate(&agreement::X25519, &rng)?; +//! +//! // Make `my_public_key` a byte slice containing my public key. In a real +//! // application, this would be sent to the peer in an encoded protocol +//! // message. +//! let my_public_key = my_private_key.compute_public_key()?; +//! +//! let peer_public_key_bytes = { +//! // In a real application, the peer public key would be parsed out of a +//! // protocol message. Here we just generate one. +//! let peer_private_key = +//! agreement::EphemeralPrivateKey::generate(&agreement::X25519, &rng)?; +//! peer_private_key.compute_public_key()? +//! }; +//! +//! let peer_public_key = agreement::UnparsedPublicKey::new( +//! &agreement::X25519, +//! peer_public_key_bytes); +//! +//! agreement::agree_ephemeral( +//! my_private_key, +//! &peer_public_key, +//! |_key_material| { +//! // In a real application, we'd apply a KDF to the key material and the +//! // public keys (as recommended in RFC 7748) and then derive session +//! // keys from the result. We omit all that here. +//! }, +//! )?; +//! +//! # Ok::<(), ring::error::Unspecified>(()) +//! ``` + +// The "NSA Guide" steps here are from from section 3.1, "Ephemeral Unified +// Model." + +use crate::{cpu, debug, ec, error, rand}; + +pub use crate::ec::{ + curve25519::x25519::X25519, + suite_b::ecdh::{ECDH_P256, ECDH_P384}, +}; + +/// A key agreement algorithm. +pub struct Algorithm { + pub(crate) curve: &'static ec::Curve, + pub(crate) ecdh: fn( + out: &mut [u8], + private_key: &ec::Seed, + peer_public_key: untrusted::Input, + cpu: cpu::Features, + ) -> Result<(), error::Unspecified>, +} + +derive_debug_via_field!(Algorithm, curve); + +impl Eq for Algorithm {} +impl PartialEq for Algorithm { + fn eq(&self, other: &Self) -> bool { + self.curve.id == other.curve.id + } +} + +/// An ephemeral private key for use (only) with `agree_ephemeral`. The +/// signature of `agree_ephemeral` ensures that an `EphemeralPrivateKey` can be +/// used for at most one key agreement. +pub struct EphemeralPrivateKey { + private_key: ec::Seed, + algorithm: &'static Algorithm, +} + +derive_debug_via_field!( + EphemeralPrivateKey, + stringify!(EphemeralPrivateKey), + algorithm +); + +impl EphemeralPrivateKey { + /// Generate a new ephemeral private key for the given algorithm. + pub fn generate( + alg: &'static Algorithm, + rng: &dyn rand::SecureRandom, + ) -> Result { + let cpu_features = cpu::features(); + + // NSA Guide Step 1. + // + // This only handles the key generation part of step 1. The rest of + // step one is done by `compute_public_key()`. + let private_key = ec::Seed::generate(alg.curve, rng, cpu_features)?; + Ok(Self { + private_key, + algorithm: alg, + }) + } + + /// Computes the public key from the private key. + #[inline(always)] + pub fn compute_public_key(&self) -> Result { + // NSA Guide Step 1. + // + // Obviously, this only handles the part of Step 1 between the private + // key generation and the sending of the public key to the peer. `out` + // is what should be sent to the peer. + self.private_key + .compute_public_key(cpu::features()) + .map(|public_key| PublicKey { + algorithm: self.algorithm, + bytes: public_key, + }) + } + + /// The algorithm for the private key. + #[inline] + pub fn algorithm(&self) -> &'static Algorithm { + self.algorithm + } + + /// Do not use. + #[deprecated] + #[cfg(test)] + pub fn bytes(&self) -> &[u8] { + self.bytes_for_test() + } + + #[cfg(test)] + pub(super) fn bytes_for_test(&self) -> &[u8] { + self.private_key.bytes_less_safe() + } +} + +/// A public key for key agreement. +#[derive(Clone)] +pub struct PublicKey { + algorithm: &'static Algorithm, + bytes: ec::PublicKey, +} + +impl AsRef<[u8]> for PublicKey { + fn as_ref(&self) -> &[u8] { + self.bytes.as_ref() + } +} + +impl core::fmt::Debug for PublicKey { + fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> { + f.debug_struct("PublicKey") + .field("algorithm", &self.algorithm) + .field("bytes", &debug::HexStr(self.as_ref())) + .finish() + } +} + +impl PublicKey { + /// The algorithm for the public key. + #[inline] + pub fn algorithm(&self) -> &'static Algorithm { + self.algorithm + } +} + +/// An unparsed, possibly malformed, public key for key agreement. +#[derive(Clone, Copy)] +pub struct UnparsedPublicKey { + algorithm: &'static Algorithm, + bytes: B, +} + +impl AsRef<[u8]> for UnparsedPublicKey +where + B: AsRef<[u8]>, +{ + fn as_ref(&self) -> &[u8] { + self.bytes.as_ref() + } +} + +impl core::fmt::Debug for UnparsedPublicKey +where + B: AsRef<[u8]>, +{ + fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> { + f.debug_struct("UnparsedPublicKey") + .field("algorithm", &self.algorithm) + .field("bytes", &debug::HexStr(self.bytes.as_ref())) + .finish() + } +} + +impl UnparsedPublicKey { + /// Constructs a new `UnparsedPublicKey`. + pub fn new(algorithm: &'static Algorithm, bytes: B) -> Self { + Self { algorithm, bytes } + } + + /// The algorithm for the public key. + #[inline] + pub fn algorithm(&self) -> &'static Algorithm { + self.algorithm + } + + /// TODO: doc + #[inline] + pub fn bytes(&self) -> &B { + &self.bytes + } +} + +/// Performs a key agreement with an ephemeral private key and the given public +/// key. +/// +/// `my_private_key` is the ephemeral private key to use. Since it is moved, it +/// will not be usable after calling `agree_ephemeral`, thus guaranteeing that +/// the key is used for only one key agreement. +/// +/// `peer_public_key` is the peer's public key. `agree_ephemeral` will return +/// `Err(error_value)` if it does not match `my_private_key's` algorithm/curve. +/// `agree_ephemeral` verifies that it is encoded in the standard form for the +/// algorithm and that the key is *valid*; see the algorithm's documentation for +/// details on how keys are to be encoded and what constitutes a valid key for +/// that algorithm. +/// +/// After the key agreement is done, `agree_ephemeral` calls `kdf` with the raw +/// key material from the key agreement operation and then returns what `kdf` +/// returns. +#[inline] +pub fn agree_ephemeral, R>( + my_private_key: EphemeralPrivateKey, + peer_public_key: &UnparsedPublicKey, + kdf: impl FnOnce(&[u8]) -> R, +) -> Result { + let peer_public_key = UnparsedPublicKey { + algorithm: peer_public_key.algorithm, + bytes: peer_public_key.bytes.as_ref(), + }; + agree_ephemeral_(my_private_key, peer_public_key, kdf, cpu::features()) +} + +fn agree_ephemeral_( + my_private_key: EphemeralPrivateKey, + peer_public_key: UnparsedPublicKey<&[u8]>, + kdf: impl FnOnce(&[u8]) -> R, + cpu: cpu::Features, +) -> Result { + // NSA Guide Prerequisite 1. + // + // The domain parameters are hard-coded. This check verifies that the + // peer's public key's domain parameters match the domain parameters of + // this private key. + if peer_public_key.algorithm != my_private_key.algorithm { + return Err(error::Unspecified); + } + + let alg = &my_private_key.algorithm; + + // NSA Guide Prerequisite 2, regarding which KDFs are allowed, is delegated + // to the caller. + + // NSA Guide Prerequisite 3, "Prior to or during the key-agreement process, + // each party shall obtain the identifier associated with the other party + // during the key-agreement scheme," is delegated to the caller. + + // NSA Guide Step 1 is handled by `EphemeralPrivateKey::generate()` and + // `EphemeralPrivateKey::compute_public_key()`. + + let mut shared_key = [0u8; ec::ELEM_MAX_BYTES]; + let shared_key = &mut shared_key[..alg.curve.elem_scalar_seed_len]; + + // NSA Guide Steps 2, 3, and 4. + // + // We have a pretty liberal interpretation of the NIST's spec's "Destroy" + // that doesn't meet the NSA requirement to "zeroize." + (alg.ecdh)( + shared_key, + &my_private_key.private_key, + untrusted::Input::from(peer_public_key.bytes), + cpu, + )?; + + // NSA Guide Steps 5 and 6. + // + // Again, we have a pretty liberal interpretation of the NIST's spec's + // "Destroy" that doesn't meet the NSA requirement to "zeroize." + Ok(kdf(shared_key)) +} diff --git a/http/vendor/ring/src/arithmetic.rs b/http/vendor/ring/src/arithmetic.rs new file mode 100644 index 0000000..94df7e4 --- /dev/null +++ b/http/vendor/ring/src/arithmetic.rs @@ -0,0 +1,47 @@ +// Copyright 2017-2023 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +pub(crate) use self::{constant::limbs_from_hex, limb_slice_error::LimbSliceError}; +use crate::{error::LenMismatchError, limb::LIMB_BITS}; + +#[macro_use] +mod ffi; + +mod constant; + +#[cfg(feature = "alloc")] +pub mod bigint; + +pub(crate) mod inout; +mod limbs; +mod limbs512; +pub mod montgomery; + +mod n0; + +// The minimum number of limbs allowed for any `&[Limb]` operation. +// +// TODO: Use `256 / LIMB_BITS` so that the limit is independent of limb size. +pub const MIN_LIMBS: usize = 4; + +// The maximum number of limbs allowed for any `&[Limb]` operation. +pub const MAX_LIMBS: usize = 8192 / LIMB_BITS; + +cold_exhaustive_error! { + enum limb_slice_error::LimbSliceError { + len_mismatch => LenMismatch(LenMismatchError), + too_short => TooShort(usize), + too_long => TooLong(usize), + } +} diff --git a/http/vendor/ring/src/arithmetic/bigint.rs b/http/vendor/ring/src/arithmetic/bigint.rs new file mode 100644 index 0000000..7251a64 --- /dev/null +++ b/http/vendor/ring/src/arithmetic/bigint.rs @@ -0,0 +1,1068 @@ +// Copyright 2015-2023 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! Multi-precision integers. +//! +//! # Modular Arithmetic. +//! +//! Modular arithmetic is done in finite commutative rings ℤ/mℤ for some +//! modulus *m*. We work in finite commutative rings instead of finite fields +//! because the RSA public modulus *n* is not prime, which means ℤ/nℤ contains +//! nonzero elements that have no multiplicative inverse, so ℤ/nℤ is not a +//! finite field. +//! +//! In some calculations we need to deal with multiple rings at once. For +//! example, RSA private key operations operate in the rings ℤ/nℤ, ℤ/pℤ, and +//! ℤ/qℤ. Types and functions dealing with such rings are all parameterized +//! over a type `M` to ensure that we don't wrongly mix up the math, e.g. by +//! multiplying an element of ℤ/pℤ by an element of ℤ/qℤ modulo q. This follows +//! the "unit" pattern described in [Static checking of units in Servo]. +//! +//! `Elem` also uses the static unit checking pattern to statically track the +//! Montgomery factors that need to be canceled out in each value using it's +//! `E` parameter. +//! +//! [Static checking of units in Servo]: +//! https://blog.mozilla.org/research/2014/06/23/static-checking-of-units-in-servo/ + +use self::boxed_limbs::BoxedLimbs; +pub(crate) use self::{ + modulus::{Modulus, OwnedModulus}, + modulusvalue::OwnedModulusValue, + private_exponent::PrivateExponent, +}; +use super::{inout::AliasingSlices3, limbs512, montgomery::*, LimbSliceError, MAX_LIMBS}; +use crate::{ + bits::BitLength, + c, + error::{self, LenMismatchError}, + limb::{self, Limb, LIMB_BITS}, + polyfill::slice::{self, AsChunks}, +}; +use core::{ + marker::PhantomData, + num::{NonZeroU64, NonZeroUsize}, +}; + +mod boxed_limbs; +mod modulus; +mod modulusvalue; +mod private_exponent; + +pub trait PublicModulus {} + +// When we need to create a new `Elem`, first we create a `Storage` and then +// move its `limbs` into the new element. When we want to recylce an `Elem`'s +// memory allocation, we convert it back into a `Storage`. +pub struct Storage { + limbs: BoxedLimbs, +} + +impl From> for Storage { + fn from(elem: Elem) -> Self { + Self { limbs: elem.limbs } + } +} + +/// Elements of ℤ/mℤ for some modulus *m*. +// +// Defaulting `E` to `Unencoded` is a convenience for callers from outside this +// submodule. However, for maximum clarity, we always explicitly use +// `Unencoded` within the `bigint` submodule. +pub struct Elem { + limbs: BoxedLimbs, + + /// The number of Montgomery factors that need to be canceled out from + /// `value` to get the actual value. + encoding: PhantomData, +} + +impl Elem { + pub fn clone_into(&self, mut out: Storage) -> Self { + out.limbs.copy_from_slice(&self.limbs); + Self { + limbs: out.limbs, + encoding: self.encoding, + } + } +} + +impl Elem { + #[inline] + pub fn is_zero(&self) -> bool { + limb::limbs_are_zero(&self.limbs).leak() + } +} + +/// Does a Montgomery reduction on `limbs` assuming they are Montgomery-encoded ('R') and assuming +/// they are the same size as `m`, but perhaps not reduced mod `m`. The result will be +/// fully reduced mod `m`. +/// +/// WARNING: Takes a `Storage` as an in/out value. +fn from_montgomery_amm(mut in_out: Storage, m: &Modulus) -> Elem { + let mut one = [0; MAX_LIMBS]; + one[0] = 1; + let one = &one[..m.limbs().len()]; + limbs_mul_mont( + (&mut in_out.limbs[..], one), + m.limbs(), + m.n0(), + m.cpu_features(), + ) + .unwrap_or_else(unwrap_impossible_limb_slice_error); + Elem { + limbs: in_out.limbs, + encoding: PhantomData, + } +} + +#[cfg(any(test, not(target_arch = "x86_64")))] +impl Elem { + #[inline] + pub fn into_unencoded(self, m: &Modulus) -> Elem { + from_montgomery_amm(Storage::from(self), m) + } +} + +impl Elem { + pub fn from_be_bytes_padded( + input: untrusted::Input, + m: &Modulus, + ) -> Result { + Ok(Self { + limbs: BoxedLimbs::from_be_bytes_padded_less_than(input, m)?, + encoding: PhantomData, + }) + } + + #[inline] + pub fn fill_be_bytes(&self, out: &mut [u8]) { + // See Falko Strenzke, "Manger's Attack revisited", ICICS 2010. + limb::big_endian_from_limbs(&self.limbs, out) + } +} + +pub fn elem_mul_into( + mut out: Storage, + a: &Elem, + b: &Elem, + m: &Modulus, +) -> Elem::Output> +where + (AF, BF): ProductEncoding, +{ + limbs_mul_mont( + (out.limbs.as_mut(), b.limbs.as_ref(), a.limbs.as_ref()), + m.limbs(), + m.n0(), + m.cpu_features(), + ) + .unwrap_or_else(unwrap_impossible_limb_slice_error); + Elem { + limbs: out.limbs, + encoding: PhantomData, + } +} + +pub fn elem_mul( + a: &Elem, + mut b: Elem, + m: &Modulus, +) -> Elem::Output> +where + (AF, BF): ProductEncoding, +{ + limbs_mul_mont( + (&mut b.limbs[..], &a.limbs[..]), + m.limbs(), + m.n0(), + m.cpu_features(), + ) + .unwrap_or_else(unwrap_impossible_limb_slice_error); + Elem { + limbs: b.limbs, + encoding: PhantomData, + } +} + +// r *= 2. +fn elem_double(r: &mut Elem, m: &Modulus) { + limb::limbs_double_mod(&mut r.limbs, m.limbs()) + .unwrap_or_else(unwrap_impossible_len_mismatch_error) +} + +// TODO: This is currently unused, but we intend to eventually use this to +// reduce elements (x mod q) mod p in the RSA CRT. If/when we do so, we +// should update the testing so it is reflective of that usage, instead of +// the old usage. +pub fn elem_reduced_once( + mut r: Storage, + a: &Elem, + m: &Modulus, + other_modulus_len_bits: BitLength, +) -> Elem { + assert_eq!(m.len_bits(), other_modulus_len_bits); + r.limbs.copy_from_slice(&a.limbs); + limb::limbs_reduce_once(&mut r.limbs, m.limbs()) + .unwrap_or_else(unwrap_impossible_len_mismatch_error); + Elem { + limbs: r.limbs, + encoding: PhantomData, + } +} + +#[inline] +pub fn elem_reduced( + mut r: Storage, + a: &Elem, + m: &Modulus, + other_prime_len_bits: BitLength, +) -> Elem { + // This is stricter than required mathematically but this is what we + // guarantee and this is easier to check. The real requirement is that + // that `a < m*R` where `R` is the Montgomery `R` for `m`. + assert_eq!(other_prime_len_bits, m.len_bits()); + + // `limbs_from_mont_in_place` requires this. + assert_eq!(a.limbs.len(), m.limbs().len() * 2); + + let mut tmp = [0; MAX_LIMBS]; + let tmp = &mut tmp[..a.limbs.len()]; + tmp.copy_from_slice(&a.limbs); + + limbs_from_mont_in_place(&mut r.limbs, tmp, m.limbs(), m.n0()); + Elem { + limbs: r.limbs, + encoding: PhantomData, + } +} + +#[inline] +fn elem_squared( + mut a: Elem, + m: &Modulus, +) -> Elem::Output> +where + (E, E): ProductEncoding, +{ + limbs_square_mont(&mut a.limbs, m.limbs(), m.n0(), m.cpu_features()) + .unwrap_or_else(unwrap_impossible_limb_slice_error); + Elem { + limbs: a.limbs, + encoding: PhantomData, + } +} + +pub fn elem_widen( + mut r: Storage, + a: Elem, + m: &Modulus, + smaller_modulus_bits: BitLength, +) -> Result, error::Unspecified> { + if smaller_modulus_bits >= m.len_bits() { + return Err(error::Unspecified); + } + let (to_copy, to_zero) = r.limbs.split_at_mut(a.limbs.len()); + to_copy.copy_from_slice(&a.limbs); + to_zero.fill(0); + Ok(Elem { + limbs: r.limbs, + encoding: PhantomData, + }) +} + +// TODO: Document why this works for all Montgomery factors. +pub fn elem_add(mut a: Elem, b: Elem, m: &Modulus) -> Elem { + limb::limbs_add_assign_mod(&mut a.limbs, &b.limbs, m.limbs()) + .unwrap_or_else(unwrap_impossible_len_mismatch_error); + a +} + +// TODO: Document why this works for all Montgomery factors. +pub fn elem_sub(mut a: Elem, b: &Elem, m: &Modulus) -> Elem { + prefixed_extern! { + // `r` and `a` may alias. + fn LIMBS_sub_mod( + r: *mut Limb, + a: *const Limb, + b: *const Limb, + m: *const Limb, + num_limbs: c::NonZero_size_t, + ); + } + let num_limbs = NonZeroUsize::new(m.limbs().len()).unwrap(); + (a.limbs.as_mut(), b.limbs.as_ref()) + .with_non_dangling_non_null_pointers_rab(num_limbs, |r, a, b| { + let m = m.limbs().as_ptr(); // Also non-dangling because num_limbs is non-zero. + unsafe { LIMBS_sub_mod(r, a, b, m, num_limbs) } + }) + .unwrap_or_else(unwrap_impossible_len_mismatch_error); + a +} + +// The value 1, Montgomery-encoded some number of times. +pub struct One(Elem); + +impl One { + // Returns RR = = R**2 (mod n) where R = 2**r is the smallest power of + // 2**LIMB_BITS such that R > m. + // + // Even though the assembly on some 32-bit platforms works with 64-bit + // values, using `LIMB_BITS` here, rather than `N0::LIMBS_USED * LIMB_BITS`, + // is correct because R**2 will still be a multiple of the latter as + // `N0::LIMBS_USED` is either one or two. + pub(crate) fn newRR(mut out: Storage, m: &Modulus) -> Self { + // The number of limbs in the numbers involved. + let w = m.limbs().len(); + + // The length of the numbers involved, in bits. R = 2**r. + let r = w * LIMB_BITS; + + m.oneR(&mut out.limbs); + let mut acc: Elem = Elem { + limbs: out.limbs, + encoding: PhantomData, + }; + + // 2**t * R can be calculated by t doublings starting with R. + // + // Choose a t that divides r and where t doublings are cheaper than 1 squaring. + // + // We could choose other values of t than w. But if t < d then the exponentiation that + // follows would require multiplications. Normally d is 1 (i.e. the modulus length is a + // power of two: RSA 1024, 2048, 4097, 8192) or 3 (RSA 1536, 3072). + // + // XXX(perf): Currently t = w / 2 is slightly faster. TODO(perf): Optimize `elem_double` + // and re-run benchmarks to rebalance this. + let t = w; + let z = w.trailing_zeros(); + let d = w >> z; + debug_assert_eq!(w, d * (1 << z)); + debug_assert!(d <= t); + debug_assert!(t < r); + for _ in 0..t { + elem_double(&mut acc, m); + } + + // Because t | r: + // + // MontExp(2**t * R, r / t) + // = (2**t)**(r / t) * R (mod m) by definition of MontExp. + // = (2**t)**(1/t * r) * R (mod m) + // = (2**(t * 1/t))**r * R (mod m) + // = (2**1)**r * R (mod m) + // = 2**r * R (mod m) + // = R * R (mod m) + // = RR + // + // Like BoringSSL, use t = w (`m.limbs.len()`) which ensures that the exponent is a power + // of two. Consequently, there will be no multiplications in the Montgomery exponentiation; + // there will only be lg(r / t) squarings. + // + // lg(r / t) + // = lg((w * 2**b) / t) + // = lg((t * 2**b) / t) + // = lg(2**b) + // = b + // TODO(MSRV:1.67): const B: u32 = LIMB_BITS.ilog2(); + const B: u32 = if cfg!(target_pointer_width = "64") { + 6 + } else if cfg!(target_pointer_width = "32") { + 5 + } else { + panic!("unsupported target_pointer_width") + }; + #[allow(clippy::assertions_on_constants)] + const _LIMB_BITS_IS_2_POW_B: () = assert!(LIMB_BITS == 1 << B); + debug_assert_eq!(r, t * (1 << B)); + for _ in 0..B { + acc = elem_squared(acc, m); + } + + Self(Elem { + limbs: acc.limbs, + encoding: PhantomData, // PhantomData + }) + } +} + +impl One { + pub(crate) fn newRRR(One(oneRR): One, m: &Modulus) -> Self { + Self(elem_squared(oneRR, m)) + } +} + +impl AsRef> for One { + fn as_ref(&self) -> &Elem { + &self.0 + } +} + +impl One { + pub fn clone_into(&self, out: Storage) -> Self { + Self(self.0.clone_into(out)) + } +} + +/// Calculates base**exponent (mod m). +/// +/// The run time is a function of the number of limbs in `m` and the bit +/// length and Hamming Weight of `exponent`. The bounds on `m` are pretty +/// obvious but the bounds on `exponent` are less obvious. Callers should +/// document the bounds they place on the maximum value and maximum Hamming +/// weight of `exponent`. +// TODO: The test coverage needs to be expanded, e.g. test with the largest +// accepted exponent and with the most common values of 65537 and 3. +pub(crate) fn elem_exp_vartime( + out: Storage, + base: Elem, + exponent: NonZeroU64, + m: &Modulus, +) -> Elem { + // Use what [Knuth] calls the "S-and-X binary method", i.e. variable-time + // square-and-multiply that scans the exponent from the most significant + // bit to the least significant bit (left-to-right). Left-to-right requires + // less storage compared to right-to-left scanning, at the cost of needing + // to compute `exponent.leading_zeros()`, which we assume to be cheap. + // + // As explained in [Knuth], exponentiation by squaring is the most + // efficient algorithm when the Hamming weight is 2 or less. It isn't the + // most efficient for all other, uncommon, exponent values but any + // suboptimality is bounded at least by the small bit length of `exponent` + // as enforced by its type. + // + // This implementation is slightly simplified by taking advantage of the + // fact that we require the exponent to be a positive integer. + // + // [Knuth]: The Art of Computer Programming, Volume 2: Seminumerical + // Algorithms (3rd Edition), Section 4.6.3. + let exponent = exponent.get(); + let mut acc = base.clone_into(out); + let mut bit = 1 << (64 - 1 - exponent.leading_zeros()); + debug_assert!((exponent & bit) != 0); + while bit > 1 { + bit >>= 1; + acc = elem_squared(acc, m); + if (exponent & bit) != 0 { + acc = elem_mul(&base, acc, m); + } + } + acc +} + +pub fn elem_exp_consttime( + out: Storage

, + base: &Elem, + oneRRR: &One, + exponent: &PrivateExponent, + p: &Modulus

, + q: PrivateCrtPrime, + qInv: bigint::Elem, + public: PublicKey, +} + +derive_debug_via_field!(KeyPair, stringify!(RsaKeyPair), public); + +impl KeyPair { + /// Parses an unencrypted PKCS#8-encoded RSA private key. + /// + /// This will generate a 2048-bit RSA private key of the correct form using + /// OpenSSL's command line tool: + /// + /// ```sh + /// openssl genpkey -algorithm RSA \ + /// -pkeyopt rsa_keygen_bits:2048 \ + /// -pkeyopt rsa_keygen_pubexp:65537 | \ + /// openssl pkcs8 -topk8 -nocrypt -outform der > rsa-2048-private-key.pk8 + /// ``` + /// + /// This will generate a 3072-bit RSA private key of the correct form: + /// + /// ```sh + /// openssl genpkey -algorithm RSA \ + /// -pkeyopt rsa_keygen_bits:3072 \ + /// -pkeyopt rsa_keygen_pubexp:65537 | \ + /// openssl pkcs8 -topk8 -nocrypt -outform der > rsa-3072-private-key.pk8 + /// ``` + /// + /// Often, keys generated for use in OpenSSL-based software are stored in + /// the Base64 “PEM” format without the PKCS#8 wrapper. Such keys can be + /// converted to binary PKCS#8 form using the OpenSSL command line tool like + /// this: + /// + /// ```sh + /// openssl pkcs8 -topk8 -nocrypt -outform der \ + /// -in rsa-2048-private-key.pem > rsa-2048-private-key.pk8 + /// ``` + /// + /// Base64 (“PEM”) PKCS#8-encoded keys can be converted to the binary PKCS#8 + /// form like this: + /// + /// ```sh + /// openssl pkcs8 -nocrypt -outform der \ + /// -in rsa-2048-private-key.pem > rsa-2048-private-key.pk8 + /// ``` + /// + /// See [`Self::from_components`] for more details on how the input is + /// validated. + /// + /// See [RFC 5958] and [RFC 3447 Appendix A.1.2] for more details of the + /// encoding of the key. + /// + /// [NIST SP-800-56B rev. 1]: + /// http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-56Br1.pdf + /// + /// [RFC 3447 Appendix A.1.2]: + /// https://tools.ietf.org/html/rfc3447#appendix-A.1.2 + /// + /// [RFC 5958]: + /// https://tools.ietf.org/html/rfc5958 + pub fn from_pkcs8(pkcs8: &[u8]) -> Result { + const RSA_ENCRYPTION: &[u8] = include_bytes!("../data/alg-rsa-encryption.der"); + let (der, _) = pkcs8::unwrap_key_( + untrusted::Input::from(RSA_ENCRYPTION), + pkcs8::Version::V1Only, + untrusted::Input::from(pkcs8), + )?; + Self::from_der(der.as_slice_less_safe()) + } + + /// Parses an RSA private key that is not inside a PKCS#8 wrapper. + /// + /// The private key must be encoded as a binary DER-encoded ASN.1 + /// `RSAPrivateKey` as described in [RFC 3447 Appendix A.1.2]). In all other + /// respects, this is just like `from_pkcs8()`. See the documentation for + /// `from_pkcs8()` for more details. + /// + /// It is recommended to use `from_pkcs8()` (with a PKCS#8-encoded key) + /// instead. + /// + /// See [`Self::from_components()`] for more details on how the input is + /// validated. + /// + /// [RFC 3447 Appendix A.1.2]: + /// https://tools.ietf.org/html/rfc3447#appendix-A.1.2 + /// + /// [NIST SP-800-56B rev. 1]: + /// http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-56Br1.pdf + pub fn from_der(input: &[u8]) -> Result { + untrusted::Input::from(input).read_all(KeyRejected::invalid_encoding(), |input| { + der::nested( + input, + der::Tag::Sequence, + KeyRejected::invalid_encoding(), + Self::from_der_reader, + ) + }) + } + + fn from_der_reader(input: &mut untrusted::Reader) -> Result { + let version = der::small_nonnegative_integer(input) + .map_err(|error::Unspecified| KeyRejected::invalid_encoding())?; + if version != 0 { + return Err(KeyRejected::version_not_supported()); + } + + fn nonnegative_integer<'a>( + input: &mut untrusted::Reader<'a>, + ) -> Result<&'a [u8], KeyRejected> { + der::nonnegative_integer(input) + .map(|input| input.as_slice_less_safe()) + .map_err(|error::Unspecified| KeyRejected::invalid_encoding()) + } + + let n = nonnegative_integer(input)?; + let e = nonnegative_integer(input)?; + let d = nonnegative_integer(input)?; + let p = nonnegative_integer(input)?; + let q = nonnegative_integer(input)?; + let dP = nonnegative_integer(input)?; + let dQ = nonnegative_integer(input)?; + let qInv = nonnegative_integer(input)?; + + let components = KeyPairComponents { + public_key: PublicKeyComponents { n, e }, + d, + p, + q, + dP, + dQ, + qInv, + }; + + Self::from_components(&components) + } + + /// Constructs an RSA private key from its big-endian-encoded components. + /// + /// Only two-prime (not multi-prime) keys are supported. The public modulus + /// (n) must be at least 2047 bits. The public modulus must be no larger + /// than 4096 bits. It is recommended that the public modulus be exactly + /// 2048 or 3072 bits. The public exponent must be at least 65537 and must + /// be no more than 33 bits long. + /// + /// The private key is validated according to [NIST SP-800-56B rev. 1] + /// section 6.4.1.4.3, crt_pkv (Intended Exponent-Creation Method Unknown), + /// with the following exceptions: + /// + /// * Section 6.4.1.2.1, Step 1: Neither a target security level nor an + /// expected modulus length is provided as a parameter, so checks + /// regarding these expectations are not done. + /// * Section 6.4.1.2.1, Step 3: Since neither the public key nor the + /// expected modulus length is provided as a parameter, the consistency + /// check between these values and the private key's value of n isn't + /// done. + /// * Section 6.4.1.2.1, Step 5: No primality tests are done, both for + /// performance reasons and to avoid any side channels that such tests + /// would provide. + /// * Section 6.4.1.2.1, Step 6, and 6.4.1.4.3, Step 7: + /// * *ring* has a slightly looser lower bound for the values of `p` + /// and `q` than what the NIST document specifies. This looser lower + /// bound matches what most other crypto libraries do. The check might + /// be tightened to meet NIST's requirements in the future. Similarly, + /// the check that `p` and `q` are not too close together is skipped + /// currently, but may be added in the future. + /// * The validity of the mathematical relationship of `dP`, `dQ`, `e` + /// and `n` is verified only during signing. Some size checks of `d`, + /// `dP` and `dQ` are performed at construction, but some NIST checks + /// are skipped because they would be expensive and/or they would leak + /// information through side channels. If a preemptive check of the + /// consistency of `dP`, `dQ`, `e` and `n` with each other is + /// necessary, that can be done by signing any message with the key + /// pair. + /// + /// * `d` is not fully validated, neither at construction nor during + /// signing. This is OK as far as *ring*'s usage of the key is + /// concerned because *ring* never uses the value of `d` (*ring* always + /// uses `p`, `q`, `dP` and `dQ` via the Chinese Remainder Theorem, + /// instead). However, *ring*'s checks would not be sufficient for + /// validating a key pair for use by some other system; that other + /// system must check the value of `d` itself if `d` is to be used. + pub fn from_components( + components: &KeyPairComponents, + ) -> Result + where + Public: AsRef<[u8]>, + Private: AsRef<[u8]>, + { + let components = KeyPairComponents { + public_key: PublicKeyComponents { + n: components.public_key.n.as_ref(), + e: components.public_key.e.as_ref(), + }, + d: components.d.as_ref(), + p: components.p.as_ref(), + q: components.q.as_ref(), + dP: components.dP.as_ref(), + dQ: components.dQ.as_ref(), + qInv: components.qInv.as_ref(), + }; + Self::from_components_(&components, cpu::features()) + } + + fn from_components_( + &KeyPairComponents { + public_key, + d, + p, + q, + dP, + dQ, + qInv, + }: &KeyPairComponents<&[u8]>, + cpu_features: cpu::Features, + ) -> Result { + let d = untrusted::Input::from(d); + let p = untrusted::Input::from(p); + let q = untrusted::Input::from(q); + let dP = untrusted::Input::from(dP); + let dQ = untrusted::Input::from(dQ); + let qInv = untrusted::Input::from(qInv); + + // XXX: Some steps are done out of order, but the NIST steps are worded + // in such a way that it is clear that NIST intends for them to be done + // in order. TODO: Does this matter at all? + + // 6.4.1.4.3/6.4.1.2.1 - Step 1. + + // Step 1.a is omitted, as explained above. + + // Step 1.b is omitted per above. Instead, we check that the public + // modulus is 2048 to `PRIVATE_KEY_PUBLIC_MODULUS_MAX_BITS` bits. + // XXX: The maximum limit of 4096 bits is primarily due to lack of + // testing of larger key sizes; see, in particular, + // https://www.mail-archive.com/openssl-dev@openssl.org/msg44586.html + // and + // https://www.mail-archive.com/openssl-dev@openssl.org/msg44759.html. + // Also, this limit might help with memory management decisions later. + + // Step 1.c. We validate e >= 65537. + let n = untrusted::Input::from(public_key.n); + let e = untrusted::Input::from(public_key.e); + let public_key = PublicKey::from_modulus_and_exponent( + n, + e, + BitLength::from_bits(2048), + super::PRIVATE_KEY_PUBLIC_MODULUS_MAX_BITS, + PublicExponent::_65537, + cpu_features, + )?; + + let n_one = public_key.inner().n().oneRR(); + let n = &public_key.inner().n().value(cpu_features); + + // 6.4.1.4.3 says to skip 6.4.1.2.1 Step 2. + + // 6.4.1.4.3 Step 3. + + // Step 3.a is done below, out of order. + // Step 3.b is unneeded since `n_bits` is derived here from `n`. + + // 6.4.1.4.3 says to skip 6.4.1.2.1 Step 4. (We don't need to recover + // the prime factors since they are already given.) + + // 6.4.1.4.3 - Step 5. + + // Steps 5.a and 5.b are omitted, as explained above. + + let n_bits = public_key.inner().n().len_bits(); + + let p = PrivatePrime::new(p, n_bits, cpu_features)?; + let q = PrivatePrime::new(q, n_bits, cpu_features)?; + + // TODO: Step 5.i + // + // 3.b is unneeded since `n_bits` is derived here from `n`. + + // 6.4.1.4.3 - Step 3.a (out of order). + // + // Verify that p * q == n. We restrict ourselves to modular + // multiplication. We rely on the fact that we've verified + // 0 < q < p < n. We check that q and p are close to sqrt(n) and then + // assume that these preconditions are enough to let us assume that + // checking p * q == 0 (mod n) is equivalent to checking p * q == n. + let q_mod_n = q + .modulus + .to_elem(n) + .map_err(|error::Unspecified| KeyRejected::inconsistent_components())?; + let p_mod_n = p + .modulus + .to_elem(n) + .map_err(|error::Unspecified| KeyRejected::inconsistent_components())?; + let p_mod_n = bigint::elem_mul(n_one, p_mod_n, n); + let pq_mod_n = bigint::elem_mul(&q_mod_n, p_mod_n, n); + if !pq_mod_n.is_zero() { + return Err(KeyRejected::inconsistent_components()); + } + + // 6.4.1.4.3/6.4.1.2.1 - Step 6. + + // Step 6.a, partial. + // + // First, validate `2**half_n_bits < d`. Since 2**half_n_bits has a bit + // length of half_n_bits + 1, this check gives us 2**half_n_bits <= d, + // and knowing d is odd makes the inequality strict. + let d = bigint::OwnedModulusValue::::from_be_bytes(d) + .map_err(|_| KeyRejected::invalid_component())?; + if !(n_bits.half_rounded_up() < d.len_bits()) { + return Err(KeyRejected::inconsistent_components()); + } + // XXX: This check should be `d < LCM(p - 1, q - 1)`, but we don't have + // a good way of calculating LCM, so it is omitted, as explained above. + d.verify_less_than(n) + .map_err(|error::Unspecified| KeyRejected::inconsistent_components())?; + + // Step 6.b is omitted as explained above. + + let pm = &p.modulus.modulus(cpu_features); + + // 6.4.1.4.3 - Step 7. + + // Step 7.c. + let qInv = bigint::Elem::from_be_bytes_padded(qInv, pm) + .map_err(|error::Unspecified| KeyRejected::invalid_component())?; + + // Steps 7.d and 7.e are omitted per the documentation above, and + // because we don't (in the long term) have a good way to do modulo + // with an even modulus. + + // Step 7.f. + let qInv = bigint::elem_mul(p.oneRR.as_ref(), qInv, pm); + let q_mod_p = bigint::elem_reduced(pm.alloc_zero(), &q_mod_n, pm, q.modulus.len_bits()); + let q_mod_p = bigint::elem_mul(p.oneRR.as_ref(), q_mod_p, pm); + bigint::verify_inverses_consttime(&qInv, q_mod_p, pm) + .map_err(|error::Unspecified| KeyRejected::inconsistent_components())?; + + // This should never fail since `n` and `e` were validated above. + + let p = PrivateCrtPrime::new(p, dP, cpu_features)?; + let q = PrivateCrtPrime::new(q, dQ, cpu_features)?; + + Ok(Self { + p, + q, + qInv, + public: public_key, + }) + } + + /// Returns a reference to the public key. + pub fn public(&self) -> &PublicKey { + &self.public + } + + /// Returns the length in bytes of the key pair's public modulus. + /// + /// A signature has the same length as the public modulus. + #[deprecated = "Use `public().modulus_len()`"] + #[inline] + pub fn public_modulus_len(&self) -> usize { + self.public().modulus_len() + } +} + +impl signature::KeyPair for KeyPair { + type PublicKey = PublicKey; + + fn public_key(&self) -> &Self::PublicKey { + self.public() + } +} + +struct PrivatePrime { + modulus: bigint::OwnedModulus, + oneRR: bigint::One, +} + +impl PrivatePrime { + fn new( + p: untrusted::Input, + n_bits: BitLength, + cpu_features: cpu::Features, + ) -> Result { + let p = bigint::OwnedModulusValue::from_be_bytes(p)?; + + // 5.c / 5.g: + // + // TODO: First, stop if `p < (√2) * 2**((nBits/2) - 1)`. + // TODO: First, stop if `q < (√2) * 2**((nBits/2) - 1)`. + // + // Second, stop if `p > 2**(nBits/2) - 1`. + // Second, stop if `q > 2**(nBits/2) - 1`. + if p.len_bits() != n_bits.half_rounded_up() { + return Err(KeyRejected::inconsistent_components()); + } + + if p.len_bits().as_bits() % 512 != 0 { + return Err(KeyRejected::private_modulus_len_not_multiple_of_512_bits()); + } + + // TODO: Step 5.d: Verify GCD(p - 1, e) == 1. + // TODO: Step 5.h: Verify GCD(q - 1, e) == 1. + + // Steps 5.e and 5.f are omitted as explained above. + let p = bigint::OwnedModulus::from(p); + let pm = p.modulus(cpu_features); + let oneRR = bigint::One::newRR(pm.alloc_zero(), &pm); + + Ok(Self { modulus: p, oneRR }) + } +} + +struct PrivateCrtPrime { + modulus: bigint::OwnedModulus, + oneRRR: bigint::One, + exponent: bigint::PrivateExponent, +} + +impl PrivateCrtPrime { + /// Constructs a `PrivateCrtPrime` from the private prime `p` and `dP` where + /// dP == d % (p - 1). + fn new( + p: PrivatePrime, + dP: untrusted::Input, + cpu_features: cpu::Features, + ) -> Result { + let m = &p.modulus.modulus(cpu_features); + // [NIST SP-800-56B rev. 1] 6.4.1.4.3 - Steps 7.a & 7.b. + let dP = bigint::PrivateExponent::from_be_bytes_padded(dP, m) + .map_err(|error::Unspecified| KeyRejected::inconsistent_components())?; + + // XXX: Steps 7.d and 7.e are omitted. We don't check that + // `dP == d % (p - 1)` because we don't (in the long term) have a good + // way to do modulo with an even modulus. Instead we just check that + // `1 <= dP < p - 1`. We'll check it, to some unknown extent, when we + // do the private key operation, since we verify that the result of the + // private key operation using the CRT parameters is consistent with `n` + // and `e`. TODO: Either prove that what we do is sufficient, or make + // it so. + + let oneRRR = bigint::One::newRRR(p.oneRR, m); + + Ok(Self { + modulus: p.modulus, + oneRRR, + exponent: dP, + }) + } +} + +fn elem_exp_consttime( + c: &bigint::Elem, + p: &PrivateCrtPrime, + other_prime_len_bits: BitLength, + cpu_features: cpu::Features, +) -> Result, error::Unspecified> { + let m = &p.modulus.modulus(cpu_features); + bigint::elem_exp_consttime( + m.alloc_zero(), + c, + &p.oneRRR, + &p.exponent, + m, + other_prime_len_bits, + ) + .map_err(error::erase::) +} + +// Type-level representations of the different moduli used in RSA signing, in +// addition to `super::N`. See `super::bigint`'s modulue-level documentation. + +enum P {} + +enum Q {} + +enum D {} + +impl KeyPair { + /// Computes the signature of `msg` and writes it into `signature`. + /// + /// `msg` is digested using the digest algorithm from `padding_alg` and the + /// digest is then padded using the padding algorithm from `padding_alg`. + /// + /// The signature it written into `signature`; `signature`'s length must be + /// exactly the length returned by `self::public().modulus_len()` or else + /// an error will be returned. On failure, `signature` may contain + /// intermediate results, but won't contain anything that would endanger the + /// private key. + /// + /// `rng` may be used to randomize the padding (e.g. for PSS). + /// + /// Many other crypto libraries have signing functions that takes a + /// precomputed digest as input, instead of the message to digest. This + /// function does *not* take a precomputed digest; instead, `sign` + /// calculates the digest itself. + pub fn sign( + &self, + padding_alg: &'static dyn RsaEncoding, + rng: &dyn rand::SecureRandom, + msg: &[u8], + signature: &mut [u8], + ) -> Result<(), error::Unspecified> { + let cpu_features = cpu::features(); + + if signature.len() != self.public().modulus_len() { + return Err(error::Unspecified); + } + + let m_hash = digest::digest(padding_alg.digest_alg(), msg); + + // Use the output buffer as the scratch space for the signature to + // reduce the required stack space. + padding::encode( + padding_alg, + m_hash, + signature, + self.public().inner().n().len_bits(), + rng, + )?; + + // RFC 8017 Section 5.1.2: RSADP, using the Chinese Remainder Theorem + // with Garner's algorithm. + + // Steps 1 and 2. + let m = self.private_exponentiate(signature, cpu_features)?; + + // Step 3. + m.fill_be_bytes(signature); + + Ok(()) + } + + /// Returns base**d (mod n). + /// + /// This does not return or write any intermediate results into any buffers + /// that are provided by the caller so that no intermediate state will be + /// leaked that would endanger the private key. + /// + /// Panics if `in_out` is not `self.public().modulus_len()`. + fn private_exponentiate( + &self, + base: &[u8], + cpu_features: cpu::Features, + ) -> Result, error::Unspecified> { + assert_eq!(base.len(), self.public().modulus_len()); + + // RFC 8017 Section 5.1.2: RSADP, using the Chinese Remainder Theorem + // with Garner's algorithm. + + let n = &self.public.inner().n().value(cpu_features); + let n_one = self.public.inner().n().oneRR(); + + // Step 1. The value zero is also rejected. + let base = bigint::Elem::from_be_bytes_padded(untrusted::Input::from(base), n)?; + + // Step 2 + let c = base; + + // Step 2.b.i. + let q_bits = self.q.modulus.len_bits(); + let m_1 = elem_exp_consttime(&c, &self.p, q_bits, cpu_features)?; + let m_2 = elem_exp_consttime(&c, &self.q, self.p.modulus.len_bits(), cpu_features)?; + + // Step 2.b.ii isn't needed since there are only two primes. + + // Step 2.b.iii. + let h = { + let p = &self.p.modulus.modulus(cpu_features); + let m_2 = bigint::elem_reduced_once(p.alloc_zero(), &m_2, p, q_bits); + let m_1_minus_m_2 = bigint::elem_sub(m_1, &m_2, p); + bigint::elem_mul(&self.qInv, m_1_minus_m_2, p) + }; + + // Step 2.b.iv. The reduction in the modular multiplication isn't + // necessary because `h < p` and `p * q == n` implies `h * q < n`. + // Modular arithmetic is used simply to avoid implementing + // non-modular arithmetic. + let p_bits = self.p.modulus.len_bits(); + let h = bigint::elem_widen(n.alloc_zero(), h, n, p_bits)?; + let q_mod_n = self.q.modulus.to_elem(n)?; + let q_mod_n = bigint::elem_mul(n_one, q_mod_n, n); + let q_times_h = bigint::elem_mul(&q_mod_n, h, n); + let m_2 = bigint::elem_widen(n.alloc_zero(), m_2, n, q_bits)?; + let m = bigint::elem_add(m_2, q_times_h, n); + + // Step 2.b.v isn't needed since there are only two primes. + + // Verify the result to protect against fault attacks as described + // in "On the Importance of Checking Cryptographic Protocols for + // Faults" by Dan Boneh, Richard A. DeMillo, and Richard J. Lipton. + // This check is cheap assuming `e` is small, which is ensured during + // `KeyPair` construction. Note that this is the only validation of `e` + // that is done other than basic checks on its size, oddness, and + // minimum value, since the relationship of `e` to `d`, `p`, and `q` is + // not verified during `KeyPair` construction. + { + let verify = n.alloc_zero(); + let verify = self + .public + .inner() + .exponentiate_elem(verify, &m, cpu_features); + bigint::elem_verify_equal_consttime(&verify, &c)?; + } + + // Step 3 will be done by the caller. + + Ok(m) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::testutil as test; + use alloc::vec; + + #[test] + fn test_rsakeypair_private_exponentiate() { + let cpu = cpu::features(); + test::run( + test_vector_file!("keypair_private_exponentiate_tests.txt"), + |section, test_case| { + assert_eq!(section, ""); + + let key = test_case.consume_bytes("Key"); + let key = KeyPair::from_pkcs8(&key).unwrap(); + let test_cases = &[ + test_case.consume_bytes("p"), + test_case.consume_bytes("p_plus_1"), + test_case.consume_bytes("p_minus_1"), + test_case.consume_bytes("q"), + test_case.consume_bytes("q_plus_1"), + test_case.consume_bytes("q_minus_1"), + ]; + for test_case in test_cases { + // THe call to `elem_verify_equal_consttime` will cause + // `private_exponentiate` to fail if the computation is + // incorrect. + let mut padded = vec![0; key.public.modulus_len()]; + let zeroes = padded.len() - test_case.len(); + padded[zeroes..].copy_from_slice(test_case); + let _: bigint::Elem<_> = key.private_exponentiate(&padded, cpu).unwrap(); + } + Ok(()) + }, + ); + } +} diff --git a/http/vendor/ring/src/rsa/keypair_components.rs b/http/vendor/ring/src/rsa/keypair_components.rs new file mode 100644 index 0000000..66e7679 --- /dev/null +++ b/http/vendor/ring/src/rsa/keypair_components.rs @@ -0,0 +1,38 @@ +use super::PublicKeyComponents; + +/// RSA key pair components. +#[derive(Clone, Copy)] +pub struct KeyPairComponents { + /// The public key components. + pub public_key: PublicKeyComponents, + + /// The private exponent. + pub d: Private, + + /// The first prime factor of `d`. + pub p: Private, + + /// The second prime factor of `d`. + pub q: Private, + + /// `p`'s public Chinese Remainder Theorem exponent. + pub dP: Private, + + /// `q`'s public Chinese Remainder Theorem exponent. + pub dQ: Private, + + /// `q**-1 mod p`. + pub qInv: Private, +} + +impl core::fmt::Debug for KeyPairComponents +where + PublicKeyComponents: core::fmt::Debug, +{ + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> { + // Non-public components are intentionally skipped + f.debug_struct("KeyPairComponents") + .field("public_key", &self.public_key) + .finish() + } +} diff --git a/http/vendor/ring/src/rsa/padding.rs b/http/vendor/ring/src/rsa/padding.rs new file mode 100644 index 0000000..98a45fc --- /dev/null +++ b/http/vendor/ring/src/rsa/padding.rs @@ -0,0 +1,177 @@ +// Copyright 2015-2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use crate::{bb, bits, digest, error, rand}; + +mod pkcs1; +mod pss; + +pub use self::{ + pkcs1::{RSA_PKCS1_SHA256, RSA_PKCS1_SHA384, RSA_PKCS1_SHA512}, + pss::{RSA_PSS_SHA256, RSA_PSS_SHA384, RSA_PSS_SHA512}, +}; +pub(super) use pkcs1::RSA_PKCS1_SHA1_FOR_LEGACY_USE_ONLY; + +/// Common features of both RSA padding encoding and RSA padding verification. +pub trait Padding: 'static + Sync + crate::sealed::Sealed + core::fmt::Debug { + // The digest algorithm used for digesting the message (and maybe for + // other things). + fn digest_alg(&self) -> &'static digest::Algorithm; +} + +pub(super) fn encode( + encoding: &dyn RsaEncoding, + m_hash: digest::Digest, + m_out: &mut [u8], + mod_bits: bits::BitLength, + rng: &dyn rand::SecureRandom, +) -> Result<(), error::Unspecified> { + #[allow(deprecated)] + encoding.encode(m_hash, m_out, mod_bits, rng) +} + +/// An RSA signature encoding as described in [RFC 3447 Section 8]. +/// +/// [RFC 3447 Section 8]: https://tools.ietf.org/html/rfc3447#section-8 +#[cfg(feature = "alloc")] +pub trait RsaEncoding: Padding { + #[deprecated(note = "internal API that will be removed")] + #[doc(hidden)] + fn encode( + &self, + m_hash: digest::Digest, + m_out: &mut [u8], + mod_bits: bits::BitLength, + rng: &dyn rand::SecureRandom, + ) -> Result<(), error::Unspecified>; +} + +/// Verification of an RSA signature encoding as described in +/// [RFC 3447 Section 8]. +/// +/// [RFC 3447 Section 8]: https://tools.ietf.org/html/rfc3447#section-8 +pub trait Verification: Padding { + fn verify( + &self, + m_hash: digest::Digest, + m: &mut untrusted::Reader, + mod_bits: bits::BitLength, + ) -> Result<(), error::Unspecified>; +} + +// Masks `out` with the output of the mask-generating function MGF1 as +// described in https://tools.ietf.org/html/rfc3447#appendix-B.2.1. +fn mgf1(digest_alg: &'static digest::Algorithm, seed: &[u8], out: &mut [u8]) { + let digest_len = digest_alg.output_len(); + + // Maximum counter value is the value of (mask_len / digest_len) rounded up. + for (i, out) in out.chunks_mut(digest_len).enumerate() { + let mut ctx = digest::Context::new(digest_alg); + ctx.update(seed); + // The counter will always fit in a `u32` because we reject absurdly + // long inputs very early. + ctx.update(&u32::to_be_bytes(i.try_into().unwrap())); + let digest = ctx.finish(); + + // The last chunk may legitimately be shorter than `digest`, but + // `digest` will never be shorter than `out`. + bb::xor_assign_at_start(out, digest.as_ref()); + } +} + +#[cfg(test)] +mod test { + use super::*; + use crate::testutil as test; + use crate::{digest, error}; + use alloc::vec; + + #[test] + fn test_pss_padding_verify() { + test::run( + test_vector_file!("rsa_pss_padding_tests.txt"), + |section, test_case| { + assert_eq!(section, ""); + + let digest_name = test_case.consume_string("Digest"); + let alg = match digest_name.as_ref() { + "SHA256" => &RSA_PSS_SHA256, + "SHA384" => &RSA_PSS_SHA384, + "SHA512" => &RSA_PSS_SHA512, + _ => panic!("Unsupported digest: {}", digest_name), + }; + + let msg = test_case.consume_bytes("Msg"); + let msg = untrusted::Input::from(&msg); + let m_hash = digest::digest(alg.digest_alg(), msg.as_slice_less_safe()); + + let encoded = test_case.consume_bytes("EM"); + let encoded = untrusted::Input::from(&encoded); + + // Salt is recomputed in verification algorithm. + let _ = test_case.consume_bytes("Salt"); + + let bit_len = test_case.consume_usize_bits("Len"); + let is_valid = test_case.consume_string("Result") == "P"; + + let actual_result = + encoded.read_all(error::Unspecified, |m| alg.verify(m_hash, m, bit_len)); + assert_eq!(actual_result.is_ok(), is_valid); + + Ok(()) + }, + ); + } + + // Tests PSS encoding for various public modulus lengths. + #[cfg(feature = "alloc")] + #[test] + fn test_pss_padding_encode() { + test::run( + test_vector_file!("rsa_pss_padding_tests.txt"), + |section, test_case| { + assert_eq!(section, ""); + + let digest_name = test_case.consume_string("Digest"); + let alg = match digest_name.as_ref() { + "SHA256" => &RSA_PSS_SHA256, + "SHA384" => &RSA_PSS_SHA384, + "SHA512" => &RSA_PSS_SHA512, + _ => panic!("Unsupported digest: {}", digest_name), + }; + + let msg = test_case.consume_bytes("Msg"); + let salt = test_case.consume_bytes("Salt"); + let encoded = test_case.consume_bytes("EM"); + let bit_len = test_case.consume_usize_bits("Len"); + let expected_result = test_case.consume_string("Result"); + + // Only test the valid outputs + if expected_result != "P" { + return Ok(()); + } + + let rng = test::rand::FixedSliceRandom { bytes: &salt }; + + let mut m_out = vec![0u8; bit_len.as_usize_bytes_rounded_up()]; + let digest = digest::digest(alg.digest_alg(), &msg); + #[allow(deprecated)] + alg.encode(digest, &mut m_out, bit_len, &rng).unwrap(); + assert_eq!(m_out, encoded); + + Ok(()) + }, + ); + } +} diff --git a/http/vendor/ring/src/rsa/padding/pkcs1.rs b/http/vendor/ring/src/rsa/padding/pkcs1.rs new file mode 100644 index 0000000..880b1dc --- /dev/null +++ b/http/vendor/ring/src/rsa/padding/pkcs1.rs @@ -0,0 +1,177 @@ +// Copyright 2015-2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::{super::PUBLIC_KEY_PUBLIC_MODULUS_MAX_LEN, Padding, RsaEncoding, Verification}; +use crate::{bits, digest, error, io::der, rand}; + +/// PKCS#1 1.5 padding as described in [RFC 3447 Section 8.2]. +/// +/// See "`RSA_PSS_*` Details\" in `ring::signature`'s module-level +/// documentation for more details. +/// +/// [RFC 3447 Section 8.2]: https://tools.ietf.org/html/rfc3447#section-8.2 +#[derive(Debug)] +pub struct PKCS1 { + digest_alg: &'static digest::Algorithm, + digestinfo_prefix: &'static [u8], +} + +impl crate::sealed::Sealed for PKCS1 {} + +impl Padding for PKCS1 { + fn digest_alg(&self) -> &'static digest::Algorithm { + self.digest_alg + } +} + +impl RsaEncoding for PKCS1 { + fn encode( + &self, + m_hash: digest::Digest, + m_out: &mut [u8], + _mod_bits: bits::BitLength, + _rng: &dyn rand::SecureRandom, + ) -> Result<(), error::Unspecified> { + pkcs1_encode(self, m_hash, m_out); + Ok(()) + } +} + +impl Verification for PKCS1 { + fn verify( + &self, + m_hash: digest::Digest, + m: &mut untrusted::Reader, + mod_bits: bits::BitLength, + ) -> Result<(), error::Unspecified> { + // `mod_bits.as_usize_bytes_rounded_up() <= + // PUBLIC_KEY_PUBLIC_MODULUS_MAX_LEN` is ensured by `verify_rsa_()`. + let mut calculated = [0u8; PUBLIC_KEY_PUBLIC_MODULUS_MAX_LEN]; + let calculated = &mut calculated[..mod_bits.as_usize_bytes_rounded_up()]; + pkcs1_encode(self, m_hash, calculated); + if m.read_bytes_to_end().as_slice_less_safe() != calculated { + return Err(error::Unspecified); + } + Ok(()) + } +} + +// Implement padding procedure per EMSA-PKCS1-v1_5, +// https://tools.ietf.org/html/rfc3447#section-9.2. This is used by both +// verification and signing so it needs to be able to handle moduli of the +// minimum and maximum sizes for both operations. +fn pkcs1_encode(pkcs1: &PKCS1, m_hash: digest::Digest, m_out: &mut [u8]) { + let em = m_out; + + let digest_len = pkcs1.digestinfo_prefix.len() + pkcs1.digest_alg.output_len(); + + // The specification requires at least 8 bytes of padding. Since we + // disallow keys smaller than 1024 bits, this should always be true. + assert!(em.len() >= digest_len + 11); + let pad_len = em.len() - digest_len - 3; + em[0] = 0; + em[1] = 1; + for i in 0..pad_len { + em[2 + i] = 0xff; + } + em[2 + pad_len] = 0; + + let (digest_prefix, digest_dst) = em[3 + pad_len..].split_at_mut(pkcs1.digestinfo_prefix.len()); + digest_prefix.copy_from_slice(pkcs1.digestinfo_prefix); + digest_dst.copy_from_slice(m_hash.as_ref()); +} + +macro_rules! rsa_pkcs1_padding { + ( $vis:vis $PADDING_ALGORITHM:ident, $digest_alg:expr, $digestinfo_prefix:expr, + $doc_str:expr ) => { + #[doc=$doc_str] + $vis static $PADDING_ALGORITHM: PKCS1 = PKCS1 { + digest_alg: $digest_alg, + digestinfo_prefix: $digestinfo_prefix, + }; + }; +} + +// Intentionally not exposed except internally for signature verification. At a +// minimum, we'd need to create test vectors for signing with it, which we +// don't currently have. But, it's a bad idea to use SHA-1 anyway, so perhaps +// we just won't ever expose it. +rsa_pkcs1_padding!( + pub(in super::super) RSA_PKCS1_SHA1_FOR_LEGACY_USE_ONLY, + &digest::SHA1_FOR_LEGACY_USE_ONLY, + &SHA1_PKCS1_DIGESTINFO_PREFIX, + "PKCS#1 1.5 padding using SHA-1 for RSA signatures." +); + +rsa_pkcs1_padding!( + pub RSA_PKCS1_SHA256, + &digest::SHA256, + &SHA256_PKCS1_DIGESTINFO_PREFIX, + "PKCS#1 1.5 padding using SHA-256 for RSA signatures." +); + +rsa_pkcs1_padding!( + pub RSA_PKCS1_SHA384, + &digest::SHA384, + &SHA384_PKCS1_DIGESTINFO_PREFIX, + "PKCS#1 1.5 padding using SHA-384 for RSA signatures." +); + +rsa_pkcs1_padding!( + pub RSA_PKCS1_SHA512, + &digest::SHA512, + &SHA512_PKCS1_DIGESTINFO_PREFIX, + "PKCS#1 1.5 padding using SHA-512 for RSA signatures." +); + +macro_rules! pkcs1_digestinfo_prefix { + ( $name:ident, $digest_len:expr, $digest_oid_len:expr, + [ $( $digest_oid:expr ),* ] ) => { + static $name: [u8; 2 + 8 + $digest_oid_len] = [ + der::Tag::Sequence.into(), 8 + $digest_oid_len + $digest_len, + der::Tag::Sequence.into(), 2 + $digest_oid_len + 2, + der::Tag::OID.into(), $digest_oid_len, $( $digest_oid ),*, + der::Tag::Null.into(), 0, + der::Tag::OctetString.into(), $digest_len, + ]; + } +} + +pkcs1_digestinfo_prefix!( + SHA1_PKCS1_DIGESTINFO_PREFIX, + 20, + 5, + [0x2b, 0x0e, 0x03, 0x02, 0x1a] +); + +pkcs1_digestinfo_prefix!( + SHA256_PKCS1_DIGESTINFO_PREFIX, + 32, + 9, + [0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01] +); + +pkcs1_digestinfo_prefix!( + SHA384_PKCS1_DIGESTINFO_PREFIX, + 48, + 9, + [0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02] +); + +pkcs1_digestinfo_prefix!( + SHA512_PKCS1_DIGESTINFO_PREFIX, + 64, + 9, + [0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03] +); diff --git a/http/vendor/ring/src/rsa/padding/pss.rs b/http/vendor/ring/src/rsa/padding/pss.rs new file mode 100644 index 0000000..8dd126c --- /dev/null +++ b/http/vendor/ring/src/rsa/padding/pss.rs @@ -0,0 +1,289 @@ +// Copyright 2015-2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::{super::PUBLIC_KEY_PUBLIC_MODULUS_MAX_LEN, mgf1, Padding, RsaEncoding, Verification}; +use crate::{bb, bits, digest, error, rand}; + +/// RSA PSS padding as described in [RFC 3447 Section 8.1]. +/// +/// See "`RSA_PSS_*` Details\" in `ring::signature`'s module-level +/// documentation for more details. +/// +/// [RFC 3447 Section 8.1]: https://tools.ietf.org/html/rfc3447#section-8.1 +#[allow(clippy::upper_case_acronyms)] // TODO: Until we implement cargo-semver-checks +#[derive(Debug)] +pub struct PSS { + digest_alg: &'static digest::Algorithm, +} + +impl crate::sealed::Sealed for PSS {} + +impl Padding for PSS { + fn digest_alg(&self) -> &'static digest::Algorithm { + self.digest_alg + } +} + +impl RsaEncoding for PSS { + // Implement padding procedure per EMSA-PSS, + // https://tools.ietf.org/html/rfc3447#section-9.1. + fn encode( + &self, + m_hash: digest::Digest, + m_out: &mut [u8], + mod_bits: bits::BitLength, + rng: &dyn rand::SecureRandom, + ) -> Result<(), error::Unspecified> { + let metrics = PSSMetrics::new(self.digest_alg, mod_bits)?; + + // The `m_out` this function fills is the big-endian-encoded value of `m` + // from the specification, padded to `k` bytes, where `k` is the length + // in bytes of the public modulus. The spec says "Note that emLen will + // be one less than k if modBits - 1 is divisible by 8 and equal to k + // otherwise." In other words we might need to prefix `em` with a + // leading zero byte to form a correct value of `m`. + let em = if metrics.top_byte_mask == 0xff { + m_out[0] = 0; + &mut m_out[1..] + } else { + m_out + }; + assert_eq!(em.len(), metrics.em_len); + + // Steps 1 and 2 are done by the caller to produce `m_hash`. + + // Step 3 is done by `PSSMetrics::new()` above. + + let (db, digest_terminator) = em.split_at_mut(metrics.db_len); + + let separator_pos = db.len() - 1 - metrics.s_len; + + // Step 4. + let salt: &[u8] = { + let salt = &mut db[(separator_pos + 1)..]; + rng.fill(salt)?; // salt + salt + }; + + // Steps 5 and 6. + let h = pss_digest(self.digest_alg, m_hash, salt); + + // Step 7. + db[..separator_pos].fill(0); // ps + + // Step 8. + db[separator_pos] = 0x01; + + // Steps 9 and 10. + mgf1(self.digest_alg, h.as_ref(), db); + + // Step 11. + db[0] &= metrics.top_byte_mask; + + // Step 12. + digest_terminator[..metrics.h_len].copy_from_slice(h.as_ref()); + digest_terminator[metrics.h_len] = 0xbc; + + Ok(()) + } +} + +impl Verification for PSS { + // RSASSA-PSS-VERIFY from https://tools.ietf.org/html/rfc3447#section-8.1.2 + // where steps 1, 2(a), and 2(b) have been done for us. + fn verify( + &self, + m_hash: digest::Digest, + m: &mut untrusted::Reader, + mod_bits: bits::BitLength, + ) -> Result<(), error::Unspecified> { + let metrics = PSSMetrics::new(self.digest_alg, mod_bits)?; + + // RSASSA-PSS-VERIFY Step 2(c). The `m` this function is given is the + // big-endian-encoded value of `m` from the specification, padded to + // `k` bytes, where `k` is the length in bytes of the public modulus. + // The spec. says "Note that emLen will be one less than k if + // modBits - 1 is divisible by 8 and equal to k otherwise," where `k` + // is the length in octets of the RSA public modulus `n`. In other + // words, `em` might have an extra leading zero byte that we need to + // strip before we start the PSS decoding steps which is an artifact of + // the `Verification` interface. + if metrics.top_byte_mask == 0xff { + if m.read_byte()? != 0 { + return Err(error::Unspecified); + } + }; + let em = m; + + // The rest of this function is EMSA-PSS-VERIFY from + // https://tools.ietf.org/html/rfc3447#section-9.1.2. + + // Steps 1 and 2 are done by the caller to produce `m_hash`. + + // Step 3 is done by `PSSMetrics::new()` above. + + // Step 5, out of order. + let masked_db = em.read_bytes(metrics.db_len)?; + let h_hash = em.read_bytes(metrics.h_len)?; + + // Step 4. + if em.read_byte()? != 0xbc { + return Err(error::Unspecified); + } + + // Step 7. + let mut db = [0u8; PUBLIC_KEY_PUBLIC_MODULUS_MAX_LEN]; + let db = &mut db[..metrics.db_len]; + + mgf1(self.digest_alg, h_hash.as_slice_less_safe(), db); + + masked_db.read_all(error::Unspecified, |masked_bytes| { + // Step 6. Check the top bits of first byte are zero. + let b = masked_bytes.read_byte()?; + if b & !metrics.top_byte_mask != 0 { + return Err(error::Unspecified); + } + db[0] ^= b; + + // Step 8. + let db_rest = &mut db[1..]; + let masked_bytes = masked_bytes.read_bytes(db_rest.len())?; + bb::xor_assign_at_start(db_rest, masked_bytes.as_slice_less_safe()); + Ok(()) + })?; + + // Step 9. + db[0] &= metrics.top_byte_mask; + + // Step 10. + let ps_len = metrics.ps_len; + if db[0..ps_len].iter().any(|&db| db != 0) { + return Err(error::Unspecified); + } + if db[metrics.ps_len] != 1 { + return Err(error::Unspecified); + } + + // Step 11. + let salt = &db[(db.len() - metrics.s_len)..]; + + // Step 12 and 13. + let h_prime = pss_digest(self.digest_alg, m_hash, salt); + + // Step 14. + if h_hash.as_slice_less_safe() != h_prime.as_ref() { + return Err(error::Unspecified); + } + + Ok(()) + } +} + +struct PSSMetrics { + #[cfg_attr(not(feature = "alloc"), allow(dead_code))] + em_len: usize, + db_len: usize, + ps_len: usize, + s_len: usize, + h_len: usize, + top_byte_mask: u8, +} + +impl PSSMetrics { + fn new( + digest_alg: &'static digest::Algorithm, + mod_bits: bits::BitLength, + ) -> Result { + let em_bits = mod_bits.try_sub_1()?; + let em_len = em_bits.as_usize_bytes_rounded_up(); + let leading_zero_bits = (8 * em_len) - em_bits.as_bits(); + debug_assert!(leading_zero_bits < 8); + let top_byte_mask = 0xffu8 >> leading_zero_bits; + + let h_len = digest_alg.output_len(); + + // We require the salt length to be equal to the digest length. + let s_len = h_len; + + // Step 3 of both `EMSA-PSS-ENCODE` is `EMSA-PSS-VERIFY` requires that + // we reject inputs where "emLen < hLen + sLen + 2". The definition of + // `emBits` in RFC 3447 Sections 9.1.1 and 9.1.2 says `emBits` must be + // "at least 8hLen + 8sLen + 9". Since 9 bits requires two bytes, these + // two conditions are equivalent. 9 bits are required as the 0x01 + // before the salt requires 1 bit and the 0xbc after the digest + // requires 8 bits. + let db_len = em_len.checked_sub(1 + s_len).ok_or(error::Unspecified)?; + let ps_len = db_len.checked_sub(h_len + 1).ok_or(error::Unspecified)?; + + debug_assert!(em_bits.as_bits() >= (8 * h_len) + (8 * s_len) + 9); + + Ok(Self { + em_len, + db_len, + ps_len, + s_len, + h_len, + top_byte_mask, + }) + } +} + +fn pss_digest( + digest_alg: &'static digest::Algorithm, + m_hash: digest::Digest, + salt: &[u8], +) -> digest::Digest { + // Fixed prefix. + const PREFIX_ZEROS: [u8; 8] = [0u8; 8]; + + // Encoding step 5 and 6, Verification step 12 and 13. + let mut ctx = digest::Context::new(digest_alg); + ctx.update(&PREFIX_ZEROS); + ctx.update(m_hash.as_ref()); + ctx.update(salt); + ctx.finish() +} + +macro_rules! rsa_pss_padding { + ( $vis:vis $PADDING_ALGORITHM:ident, $digest_alg:expr, $doc_str:expr ) => { + #[doc=$doc_str] + $vis static $PADDING_ALGORITHM: PSS = PSS { + digest_alg: $digest_alg, + }; + }; +} + +rsa_pss_padding!( + pub RSA_PSS_SHA256, + &digest::SHA256, + "RSA PSS padding using SHA-256 for RSA signatures.\n\nSee + \"`RSA_PSS_*` Details\" in `ring::signature`'s module-level + documentation for more details." +); + +rsa_pss_padding!( + pub RSA_PSS_SHA384, + &digest::SHA384, + "RSA PSS padding using SHA-384 for RSA signatures.\n\nSee + \"`RSA_PSS_*` Details\" in `ring::signature`'s module-level + documentation for more details." +); + +rsa_pss_padding!( + pub RSA_PSS_SHA512, + &digest::SHA512, + "RSA PSS padding using SHA-512 for RSA signatures.\n\nSee + \"`RSA_PSS_*` Details\" in `ring::signature`'s module-level + documentation for more details." +); diff --git a/http/vendor/ring/src/rsa/public_exponent.rs b/http/vendor/ring/src/rsa/public_exponent.rs new file mode 100644 index 0000000..b87b30b --- /dev/null +++ b/http/vendor/ring/src/rsa/public_exponent.rs @@ -0,0 +1,104 @@ +use crate::error; +use crate::polyfill::{unwrap_const, ArrayFlatMap, LeadingZerosStripped}; +use core::num::NonZeroU64; + +/// The exponent `e` of an RSA public key. +#[derive(Clone, Copy)] +pub struct PublicExponent(NonZeroU64); + +impl PublicExponent { + #[cfg(test)] + const ALL_CONSTANTS: [Self; 3] = [Self::_3, Self::_65537, Self::MAX]; + + pub(super) const _3: Self = Self(unwrap_const(NonZeroU64::new(3))); + pub(super) const _65537: Self = Self(unwrap_const(NonZeroU64::new(65537))); + + // This limit was chosen to bound the performance of the simple + // exponentiation-by-squaring implementation in `elem_exp_vartime`. In + // particular, it helps mitigate theoretical resource exhaustion attacks. 33 + // bits was chosen as the limit based on the recommendations in [1] and + // [2]. Windows CryptoAPI (at least older versions) doesn't support values + // larger than 32 bits [3], so it is unlikely that exponents larger than 32 + // bits are being used for anything Windows commonly does. + // + // [1] https://www.imperialviolet.org/2012/03/16/rsae.html + // [2] https://www.imperialviolet.org/2012/03/17/rsados.html + // [3] https://msdn.microsoft.com/en-us/library/aa387685(VS.85).aspx + const MAX: Self = Self(unwrap_const(NonZeroU64::new((1u64 << 33) - 1))); + + pub(super) fn from_be_bytes( + input: untrusted::Input, + min_value: Self, + ) -> Result { + // See `PublicKey::from_modulus_and_exponent` for background on the step + // numbering. + + if input.len() > 5 { + return Err(error::KeyRejected::too_large()); + } + let value = input.read_all(error::KeyRejected::invalid_encoding(), |input| { + // The exponent can't be zero and it can't be prefixed with + // zero-valued bytes. + if input.peek(0) { + return Err(error::KeyRejected::invalid_encoding()); + } + let mut value = 0u64; + loop { + let byte = input + .read_byte() + .map_err(|untrusted::EndOfInput| error::KeyRejected::invalid_encoding())?; + value = (value << 8) | u64::from(byte); + if input.at_end() { + return Ok(value); + } + } + })?; + + // Step 2 / Step b. NIST SP800-89 defers to FIPS 186-3, which requires + // `e >= 65537`. We enforce this when signing, but are more flexible in + // verification, for compatibility. Only small public exponents are + // supported. + let value = NonZeroU64::new(value).ok_or_else(error::KeyRejected::too_small)?; + if value < min_value.0 { + return Err(error::KeyRejected::too_small()); + } + if value > Self::MAX.0 { + return Err(error::KeyRejected::too_large()); + } + + // Step 3 / Step c. + if value.get() & 1 != 1 { + return Err(error::KeyRejected::invalid_component()); + } + + Ok(Self(value)) + } + + /// The big-endian encoding of the exponent. + /// + /// There are no leading zeros. + pub fn be_bytes(&self) -> impl ExactSizeIterator + Clone + '_ { + // The `unwrap()` won't fail as `self.0` is only a few bytes long. + let bytes = ArrayFlatMap::new(core::iter::once(self.0.get()), u64::to_be_bytes).unwrap(); + LeadingZerosStripped::new(bytes) + } + + pub(super) fn value(self) -> NonZeroU64 { + self.0 + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_public_exponent_constants() { + for value in PublicExponent::ALL_CONSTANTS.iter() { + let value: u64 = value.0.into(); + assert_eq!(value & 1, 1); + assert!(value >= PublicExponent::_3.0.into()); // The absolute minimum. + assert!(value <= PublicExponent::MAX.0.into()); + } + } +} diff --git a/http/vendor/ring/src/rsa/public_key.rs b/http/vendor/ring/src/rsa/public_key.rs new file mode 100644 index 0000000..87e1a30 --- /dev/null +++ b/http/vendor/ring/src/rsa/public_key.rs @@ -0,0 +1,228 @@ +// Copyright 2015-2021 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::{PublicExponent, PublicModulus, N, PUBLIC_KEY_PUBLIC_MODULUS_MAX_LEN}; +use crate::{ + arithmetic::bigint, + bits, cpu, error, + io::{self, der, der_writer}, + limb::LIMB_BYTES, +}; +use alloc::boxed::Box; +use core::num::NonZeroU64; + +/// An RSA Public Key. +#[derive(Clone)] +pub struct PublicKey { + inner: Inner, + serialized: Box<[u8]>, +} + +derive_debug_self_as_ref_hex_bytes!(PublicKey); + +impl PublicKey { + pub(super) fn from_modulus_and_exponent( + n: untrusted::Input, + e: untrusted::Input, + n_min_bits: bits::BitLength, + n_max_bits: bits::BitLength, + e_min_value: PublicExponent, + cpu_features: cpu::Features, + ) -> Result { + let inner = Inner::from_modulus_and_exponent( + n, + e, + n_min_bits, + n_max_bits, + e_min_value, + cpu_features, + )?; + + let n_bytes = n; + let e_bytes = e; + + // TODO: Remove this re-parsing, and stop allocating this here. + // Instead we should serialize on demand without allocation, from + // `Modulus::be_bytes()` and `Exponent::be_bytes()`. Once this is + // fixed, merge `Inner` back into `PublicKey`. + let n_bytes = io::Positive::from_be_bytes(n_bytes) + .map_err(|_: error::Unspecified| error::KeyRejected::unexpected_error())?; + let e_bytes = io::Positive::from_be_bytes(e_bytes) + .map_err(|_: error::Unspecified| error::KeyRejected::unexpected_error())?; + let serialized = der_writer::write_all(der::Tag::Sequence, &|output| { + der_writer::write_positive_integer(output, &n_bytes)?; + der_writer::write_positive_integer(output, &e_bytes) + }) + .map_err(|_: io::TooLongError| error::KeyRejected::unexpected_error())?; + + Ok(Self { inner, serialized }) + } + + /// The length, in bytes, of the public modulus. + /// + /// The modulus length is rounded up to a whole number of bytes if its + /// bit length isn't a multiple of 8. + pub fn modulus_len(&self) -> usize { + self.inner.n().len_bits().as_usize_bytes_rounded_up() + } + + pub(super) fn inner(&self) -> &Inner { + &self.inner + } +} + +/// `PublicKey` but without any superfluous allocations, optimized for one-shot +/// RSA signature verification. +#[derive(Clone)] +pub(crate) struct Inner { + n: PublicModulus, + e: PublicExponent, +} + +impl Inner { + pub(super) fn from_modulus_and_exponent( + n: untrusted::Input, + e: untrusted::Input, + n_min_bits: bits::BitLength, + n_max_bits: bits::BitLength, + e_min_value: PublicExponent, + cpu_features: cpu::Features, + ) -> Result { + // This is an incomplete implementation of NIST SP800-56Br1 Section + // 6.4.2.2, "Partial Public-Key Validation for RSA." That spec defers + // to NIST SP800-89 Section 5.3.3, "(Explicit) Partial Public Key + // Validation for RSA," "with the caveat that the length of the modulus + // shall be a length that is specified in this Recommendation." In + // SP800-89, two different sets of steps are given, one set numbered, + // and one set lettered. TODO: Document this in the end-user + // documentation for RSA keys. + + let n = PublicModulus::from_be_bytes(n, n_min_bits..=n_max_bits, cpu_features)?; + + let e = PublicExponent::from_be_bytes(e, e_min_value)?; + + // If `n` is less than `e` then somebody has probably accidentally swapped + // them. The largest acceptable `e` is smaller than the smallest acceptable + // `n`, so no additional checks need to be done. + + // XXX: Steps 4 & 5 / Steps d, e, & f are not implemented. This is also the + // case in most other commonly-used crypto libraries. + + Ok(Self { n, e }) + } + + /// The public modulus. + #[inline] + pub(super) fn n(&self) -> &PublicModulus { + &self.n + } + + /// The public exponent. + #[inline] + pub(super) fn e(&self) -> PublicExponent { + self.e + } + + /// Calculates base**e (mod n), filling the first part of `out_buffer` with + /// the result. + /// + /// This is constant-time with respect to the value in `base` (only). + /// + /// The result will be a slice of the encoded bytes of the result within + /// `out_buffer`, if successful. + pub(super) fn exponentiate<'out>( + &self, + base: untrusted::Input, + out_buffer: &'out mut [u8; PUBLIC_KEY_PUBLIC_MODULUS_MAX_LEN], + cpu_features: cpu::Features, + ) -> Result<&'out [u8], error::Unspecified> { + let n = &self.n.value(cpu_features); + + // The encoded value of the base must be the same length as the modulus, + // in bytes. + if base.len() != self.n.len_bits().as_usize_bytes_rounded_up() { + return Err(error::Unspecified); + } + + // RFC 8017 Section 5.2.2: RSAVP1. + + // Step 1. + let s = bigint::Elem::from_be_bytes_padded(base, n)?; + if s.is_zero() { + return Err(error::Unspecified); + } + + // Step 2. + let m = n.alloc_zero(); + let m = self.exponentiate_elem(m, &s, cpu_features); + + // Step 3. + Ok(fill_be_bytes_n(m, self.n.len_bits(), out_buffer)) + } + + /// Calculates base**e (mod n). + /// + /// This is constant-time with respect to `base` only. + pub(super) fn exponentiate_elem( + &self, + out: bigint::Storage, + base: &bigint::Elem, + cpu_features: cpu::Features, + ) -> bigint::Elem { + // The exponent was already checked to be at least 3. + let exponent_without_low_bit = NonZeroU64::try_from(self.e.value().get() & !1).unwrap(); + // The exponent was already checked to be odd. + debug_assert_ne!(exponent_without_low_bit, self.e.value()); + + let n = &self.n.value(cpu_features); + + let tmp = n.alloc_zero(); + let base_r = bigint::elem_mul_into(tmp, self.n.oneRR(), base, n); + + // During RSA public key operations the exponent is almost always either + // 65537 (0b10000000000000001) or 3 (0b11), both of which have a Hamming + // weight of 2. The maximum bit length and maximum Hamming weight of the + // exponent is bounded by the value of `PublicExponent::MAX`. + let acc = bigint::elem_exp_vartime(out, base_r, exponent_without_low_bit, n); + + // Now do the multiplication for the low bit and convert out of the Montgomery domain. + bigint::elem_mul(base, acc, n) + } +} + +// XXX: Refactor `signature::KeyPair` to get rid of this. +impl AsRef<[u8]> for PublicKey { + fn as_ref(&self) -> &[u8] { + &self.serialized + } +} + +/// Returns the big-endian representation of `elem` that is +/// the same length as the minimal-length big-endian representation of +/// the modulus `n`. +/// +/// `n_bits` must be the bit length of the public modulus `n`. +fn fill_be_bytes_n( + elem: bigint::Elem, + n_bits: bits::BitLength, + out: &mut [u8; PUBLIC_KEY_PUBLIC_MODULUS_MAX_LEN], +) -> &[u8] { + let n_bytes = n_bits.as_usize_bytes_rounded_up(); + let n_bytes_padded = ((n_bytes + (LIMB_BYTES - 1)) / LIMB_BYTES) * LIMB_BYTES; + let out = &mut out[..n_bytes_padded]; + elem.fill_be_bytes(out); + let (padding, out) = out.split_at(n_bytes_padded - n_bytes); + assert!(padding.iter().all(|&b| b == 0)); + out +} diff --git a/http/vendor/ring/src/rsa/public_key_components.rs b/http/vendor/ring/src/rsa/public_key_components.rs new file mode 100644 index 0000000..3220d75 --- /dev/null +++ b/http/vendor/ring/src/rsa/public_key_components.rs @@ -0,0 +1,52 @@ +// Copyright 2015-2021 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::PublicKey; +use core::iter::FromIterator; + +/// RSA public key components. +/// +/// `B` must implement `AsRef<[u8]>` like `&[u8]` or `Vec`. +#[derive(Clone, Copy)] +pub struct PublicKeyComponents { + /// The public modulus, encoded in big-endian bytes without leading zeros. + pub n: B, + + /// The public exponent, encoded in big-endian bytes without leading zeros. + pub e: B, +} + +impl core::fmt::Debug for PublicKeyComponents +where + B: core::fmt::Debug, +{ + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> { + f.debug_struct("PublicKeyComponents") + .field("n", &self.n) + .field("e", &self.e) + .finish() + } +} + +impl From<&PublicKey> for PublicKeyComponents +where + B: FromIterator, +{ + fn from(public_key: &PublicKey) -> Self { + Self { + n: public_key.inner().n().be_bytes().collect(), + e: public_key.inner().e().be_bytes().collect(), + } + } +} diff --git a/http/vendor/ring/src/rsa/public_modulus.rs b/http/vendor/ring/src/rsa/public_modulus.rs new file mode 100644 index 0000000..c40e49e --- /dev/null +++ b/http/vendor/ring/src/rsa/public_modulus.rs @@ -0,0 +1,98 @@ +use crate::{ + arithmetic::{bigint, montgomery::RR}, + bits::{self, FromByteLen as _}, + cpu, + error::{self, InputTooLongError}, + rsa::N, +}; +use core::ops::RangeInclusive; + +/// The modulus (n) of an RSA public key. +pub struct PublicModulus { + value: bigint::OwnedModulus, + oneRR: bigint::One, +} + +impl Clone for PublicModulus { + fn clone(&self) -> Self { + let PublicModulus { value, oneRR } = self; + let value = value.clone(); + + // XXX: Shouldn't really be needed just to call `alloc_zero()`, + // but not worth optimizing away. + let cpu = cpu::features(); + let n = value.modulus(cpu); + let oneRR = oneRR.clone_into(n.alloc_zero()); + + Self { value, oneRR } + } +} + +/* +impl core::fmt::Debug for PublicModulus { + fn fmt(&self, fmt: &mut ::core::fmt::Formatter) -> Result<(), ::core::fmt::Error> { + self.value.fmt(fmt) + } +}*/ + +impl PublicModulus { + pub(super) fn from_be_bytes( + n: untrusted::Input, + allowed_bit_lengths: RangeInclusive, + cpu_features: cpu::Features, + ) -> Result { + // See `PublicKey::from_modulus_and_exponent` for background on the step + // numbering. + + let min_bits = *allowed_bit_lengths.start(); + let max_bits = *allowed_bit_lengths.end(); + + // `pkcs1_encode` depends on this not being small. Otherwise, + // `pkcs1_encode` would generate padding that is invalid (too few 0xFF + // bytes) for very small keys. + const MIN_BITS: bits::BitLength = bits::BitLength::from_bits(1024); + + // Step 3 / Step c for `n` (out of order). + let value = bigint::OwnedModulusValue::from_be_bytes(n)?; + let bits = value.len_bits(); + + // Step 1 / Step a. XXX: SP800-56Br1 and SP800-89 require the length of + // the public modulus to be exactly 2048 or 3072 bits, but we are more + // flexible to be compatible with other commonly-used crypto libraries. + assert!(min_bits >= MIN_BITS); + let bits_rounded_up = bits::BitLength::from_byte_len(bits.as_usize_bytes_rounded_up()) + .map_err(error::erase::) + .unwrap(); // TODO: safe? + if bits_rounded_up < min_bits { + return Err(error::KeyRejected::too_small()); + } + if bits > max_bits { + return Err(error::KeyRejected::too_large()); + } + let value = bigint::OwnedModulus::from(value); + let m = value.modulus(cpu_features); + let oneRR = bigint::One::newRR(m.alloc_zero(), &m); + + Ok(Self { value, oneRR }) + } + + /// The big-endian encoding of the modulus. + /// + /// There are no leading zeros. + pub fn be_bytes(&self) -> impl ExactSizeIterator + Clone + '_ { + self.value.be_bytes() + } + + /// The length of the modulus in bits. + pub fn len_bits(&self) -> bits::BitLength { + self.value.len_bits() + } + + pub(super) fn value(&self, cpu_features: cpu::Features) -> bigint::Modulus { + self.value.modulus(cpu_features) + } + + pub(super) fn oneRR(&self) -> &bigint::Elem { + self.oneRR.as_ref() + } +} diff --git a/http/vendor/ring/src/rsa/signature_rsa_example_private_key.der b/http/vendor/ring/src/rsa/signature_rsa_example_private_key.der new file mode 100644 index 0000000..47f08a4 Binary files /dev/null and b/http/vendor/ring/src/rsa/signature_rsa_example_private_key.der differ diff --git a/http/vendor/ring/src/rsa/signature_rsa_example_public_key.der b/http/vendor/ring/src/rsa/signature_rsa_example_public_key.der new file mode 100644 index 0000000..19e944f Binary files /dev/null and b/http/vendor/ring/src/rsa/signature_rsa_example_public_key.der differ diff --git a/http/vendor/ring/src/rsa/verification.rs b/http/vendor/ring/src/rsa/verification.rs new file mode 100644 index 0000000..4ffbaec --- /dev/null +++ b/http/vendor/ring/src/rsa/verification.rs @@ -0,0 +1,231 @@ +// Copyright 2015-2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! Verification of RSA signatures. + +use super::{ + parse_public_key, public_key, PublicExponent, RsaParameters, PUBLIC_KEY_PUBLIC_MODULUS_MAX_LEN, +}; +use crate::{ + bits::{self, FromByteLen as _}, + cpu, digest, + error::{self, InputTooLongError}, + sealed, signature, +}; + +impl signature::VerificationAlgorithm for RsaParameters { + fn verify( + &self, + public_key: untrusted::Input, + msg: untrusted::Input, + signature: untrusted::Input, + ) -> Result<(), error::Unspecified> { + let (n, e) = parse_public_key(public_key)?; + verify_rsa_( + self, + ( + n.big_endian_without_leading_zero_as_input(), + e.big_endian_without_leading_zero_as_input(), + ), + msg, + signature, + cpu::features(), + ) + } +} + +impl sealed::Sealed for RsaParameters {} + +macro_rules! rsa_params { + ( $VERIFY_ALGORITHM:ident, $min_bits:expr, $PADDING_ALGORITHM:expr, + $doc_str:expr ) => { + #[doc=$doc_str] + /// + /// Only available in `alloc` mode. + pub static $VERIFY_ALGORITHM: RsaParameters = RsaParameters { + padding_alg: $PADDING_ALGORITHM, + min_bits: bits::BitLength::from_bits($min_bits), + }; + }; +} + +rsa_params!( + RSA_PKCS1_1024_8192_SHA1_FOR_LEGACY_USE_ONLY, + 1024, + &super::padding::RSA_PKCS1_SHA1_FOR_LEGACY_USE_ONLY, + "Verification of signatures using RSA keys of 1024-8192 bits, + PKCS#1.5 padding, and SHA-1.\n\nSee \"`RSA_PKCS1_*` Details\" in + `ring::signature`'s module-level documentation for more details." +); +rsa_params!( + RSA_PKCS1_2048_8192_SHA1_FOR_LEGACY_USE_ONLY, + 2048, + &super::padding::RSA_PKCS1_SHA1_FOR_LEGACY_USE_ONLY, + "Verification of signatures using RSA keys of 2048-8192 bits, + PKCS#1.5 padding, and SHA-1.\n\nSee \"`RSA_PKCS1_*` Details\" in + `ring::signature`'s module-level documentation for more details." +); +rsa_params!( + RSA_PKCS1_1024_8192_SHA256_FOR_LEGACY_USE_ONLY, + 1024, + &super::padding::RSA_PKCS1_SHA256, + "Verification of signatures using RSA keys of 1024-8192 bits, + PKCS#1.5 padding, and SHA-256.\n\nSee \"`RSA_PKCS1_*` Details\" in + `ring::signature`'s module-level documentation for more details." +); +rsa_params!( + RSA_PKCS1_2048_8192_SHA256, + 2048, + &super::padding::RSA_PKCS1_SHA256, + "Verification of signatures using RSA keys of 2048-8192 bits, + PKCS#1.5 padding, and SHA-256.\n\nSee \"`RSA_PKCS1_*` Details\" in + `ring::signature`'s module-level documentation for more details." +); +rsa_params!( + RSA_PKCS1_2048_8192_SHA384, + 2048, + &super::padding::RSA_PKCS1_SHA384, + "Verification of signatures using RSA keys of 2048-8192 bits, + PKCS#1.5 padding, and SHA-384.\n\nSee \"`RSA_PKCS1_*` Details\" in + `ring::signature`'s module-level documentation for more details." +); +rsa_params!( + RSA_PKCS1_2048_8192_SHA512, + 2048, + &super::padding::RSA_PKCS1_SHA512, + "Verification of signatures using RSA keys of 2048-8192 bits, + PKCS#1.5 padding, and SHA-512.\n\nSee \"`RSA_PKCS1_*` Details\" in + `ring::signature`'s module-level documentation for more details." +); +rsa_params!( + RSA_PKCS1_1024_8192_SHA512_FOR_LEGACY_USE_ONLY, + 1024, + &super::padding::RSA_PKCS1_SHA512, + "Verification of signatures using RSA keys of 1024-8192 bits, + PKCS#1.5 padding, and SHA-512.\n\nSee \"`RSA_PKCS1_*` Details\" in + `ring::signature`'s module-level documentation for more details." +); +rsa_params!( + RSA_PKCS1_3072_8192_SHA384, + 3072, + &super::padding::RSA_PKCS1_SHA384, + "Verification of signatures using RSA keys of 3072-8192 bits, + PKCS#1.5 padding, and SHA-384.\n\nSee \"`RSA_PKCS1_*` Details\" in + `ring::signature`'s module-level documentation for more details." +); + +rsa_params!( + RSA_PSS_2048_8192_SHA256, + 2048, + &super::padding::RSA_PSS_SHA256, + "Verification of signatures using RSA keys of 2048-8192 bits, + PSS padding, and SHA-256.\n\nSee \"`RSA_PSS_*` Details\" in + `ring::signature`'s module-level documentation for more details." +); +rsa_params!( + RSA_PSS_2048_8192_SHA384, + 2048, + &super::padding::RSA_PSS_SHA384, + "Verification of signatures using RSA keys of 2048-8192 bits, + PSS padding, and SHA-384.\n\nSee \"`RSA_PSS_*` Details\" in + `ring::signature`'s module-level documentation for more details." +); +rsa_params!( + RSA_PSS_2048_8192_SHA512, + 2048, + &super::padding::RSA_PSS_SHA512, + "Verification of signatures using RSA keys of 2048-8192 bits, + PSS padding, and SHA-512.\n\nSee \"`RSA_PSS_*` Details\" in + `ring::signature`'s module-level documentation for more details." +); + +pub use super::PublicKeyComponents as RsaPublicKeyComponents; + +impl super::PublicKeyComponents +where + B: AsRef<[u8]>, +{ + /// Verifies that `signature` is a valid signature of `message` using `self` + /// as the public key. `params` determine what algorithm parameters + /// (padding, digest algorithm, key length range, etc.) are used in the + /// verification. + /// + /// When the public key is in DER-encoded PKCS#1 ASN.1 format, it is + /// recommended to use `ring::signature::verify()` with + /// `ring::signature::RSA_PKCS1_*`, because `ring::signature::verify()` + /// will handle the parsing in that case. Otherwise, this function can be used + /// to pass in the raw bytes for the public key components as + /// `untrusted::Input` arguments. + // + // There are a small number of tests that test this directly, but the + // test coverage for this function mostly depends on the test coverage for the + // `signature::VerificationAlgorithm` implementation for `RsaParameters`. If we + // change that, test coverage for `verify_rsa()` will need to be reconsidered. + // (The NIST test vectors were originally in a form that was optimized for + // testing `verify_rsa` directly, but the testing work for RSA PKCS#1 + // verification was done during the implementation of + // `signature::VerificationAlgorithm`, before `verify_rsa` was factored out). + pub fn verify( + &self, + params: &RsaParameters, + message: &[u8], + signature: &[u8], + ) -> Result<(), error::Unspecified> { + verify_rsa_( + params, + ( + untrusted::Input::from(self.n.as_ref()), + untrusted::Input::from(self.e.as_ref()), + ), + untrusted::Input::from(message), + untrusted::Input::from(signature), + cpu::features(), + ) + } +} + +pub(crate) fn verify_rsa_( + params: &RsaParameters, + (n, e): (untrusted::Input, untrusted::Input), + msg: untrusted::Input, + signature: untrusted::Input, + cpu_features: cpu::Features, +) -> Result<(), error::Unspecified> { + let max_bits: bits::BitLength = + bits::BitLength::from_byte_len(PUBLIC_KEY_PUBLIC_MODULUS_MAX_LEN) + .map_err(error::erase::)?; + + // XXX: FIPS 186-4 seems to indicate that the minimum + // exponent value is 2**16 + 1, but it isn't clear if this is just for + // signing or also for verification. We support exponents of 3 and larger + // for compatibility with other commonly-used crypto libraries. + let key = public_key::Inner::from_modulus_and_exponent( + n, + e, + params.min_bits, + max_bits, + PublicExponent::_3, + cpu_features, + )?; + + // RFC 8017 Section 5.2.2: RSAVP1. + let mut decoded = [0u8; PUBLIC_KEY_PUBLIC_MODULUS_MAX_LEN]; + let decoded = key.exponentiate(signature, &mut decoded, cpu_features)?; + + // Verify the padded message is correct. + let m_hash = digest::digest(params.padding_alg.digest_alg(), msg.as_slice_less_safe()); + untrusted::Input::from(decoded).read_all(error::Unspecified, |m| { + params.padding_alg.verify(m_hash, m, key.n().len_bits()) + }) +} diff --git a/http/vendor/ring/src/signature.rs b/http/vendor/ring/src/signature.rs new file mode 100644 index 0000000..70806ca --- /dev/null +++ b/http/vendor/ring/src/signature.rs @@ -0,0 +1,409 @@ +// Copyright 2015-2017 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! Public key signatures: signing and verification. +//! +//! Use the `verify` function to verify signatures, passing a reference to the +//! algorithm that identifies the algorithm. See the documentation for `verify` +//! for examples. +//! +//! For signature verification, this API treats each combination of parameters +//! as a separate algorithm. For example, instead of having a single "RSA" +//! algorithm with a verification function that takes a bunch of parameters, +//! there are `RSA_PKCS1_2048_8192_SHA256`, `RSA_PKCS1_2048_8192_SHA384`, etc., +//! which encode sets of parameter choices into objects. This is designed to +//! reduce the risks of algorithm agility and to provide consistency with ECDSA +//! and EdDSA. +//! +//! Currently this module does not support digesting the message to be signed +//! separately from the public key operation, as it is currently being +//! optimized for Ed25519 and for the implementation of protocols that do not +//! requiring signing large messages. An interface for efficiently supporting +//! larger messages may be added later. +//! +//! +//! # Algorithm Details +//! +//! ## `ECDSA_*_ASN1` Details: ASN.1-encoded ECDSA Signatures +//! +//! The signature is a ASN.1 DER-encoded `Ecdsa-Sig-Value` as described in +//! [RFC 3279 Section 2.2.3]. This is the form of ECDSA signature used in +//! X.509-related structures and in TLS's `ServerKeyExchange` messages. +//! +//! The public key is encoding in uncompressed form using the +//! Octet-String-to-Elliptic-Curve-Point algorithm in +//! [SEC 1: Elliptic Curve Cryptography, Version 2.0]. +//! +//! During verification, the public key is validated using the ECC Partial +//! Public-Key Validation Routine from Section 5.6.2.3.3 of +//! [NIST Special Publication 800-56A, revision 2] and Appendix A.3 of the +//! NSA's [Suite B implementer's guide to FIPS 186-3]. Note that, as explained +//! in the NSA guide, ECC Partial Public-Key Validation is equivalent to ECC +//! Full Public-Key Validation for prime-order curves like this one. +//! +//! ## `ECDSA_*_FIXED` Details: Fixed-length (PKCS#11-style) ECDSA Signatures +//! +//! The signature is *r*||*s*, where || denotes concatenation, and where both +//! *r* and *s* are both big-endian-encoded values that are left-padded to the +//! maximum length. A P-256 signature will be 64 bytes long (two 32-byte +//! components) and a P-384 signature will be 96 bytes long (two 48-byte +//! components). This is the form of ECDSA signature used PKCS#11 and DNSSEC. +//! +//! The public key is encoding in uncompressed form using the +//! Octet-String-to-Elliptic-Curve-Point algorithm in +//! [SEC 1: Elliptic Curve Cryptography, Version 2.0]. +//! +//! During verification, the public key is validated using the ECC Partial +//! Public-Key Validation Routine from Section 5.6.2.3.3 of +//! [NIST Special Publication 800-56A, revision 2] and Appendix A.3 of the +//! NSA's [Suite B implementer's guide to FIPS 186-3]. Note that, as explained +//! in the NSA guide, ECC Partial Public-Key Validation is equivalent to ECC +//! Full Public-Key Validation for prime-order curves like this one. +//! +//! ## `RSA_PKCS1_*` Details: RSA PKCS#1 1.5 Signatures +//! +//! The signature is an RSASSA-PKCS1-v1_5 signature as described in +//! [RFC 3447 Section 8.2]. +//! +//! The public key is encoded as an ASN.1 `RSAPublicKey` as described in +//! [RFC 3447 Appendix-A.1.1]. The public key modulus length, rounded *up* to +//! the nearest (larger) multiple of 8 bits, must be in the range given in the +//! name of the algorithm. The public exponent must be an odd integer of 2-33 +//! bits, inclusive. +//! +//! +//! ## `RSA_PSS_*` Details: RSA PSS Signatures +//! +//! The signature is an RSASSA-PSS signature as described in +//! [RFC 3447 Section 8.1]. +//! +//! The public key is encoded as an ASN.1 `RSAPublicKey` as described in +//! [RFC 3447 Appendix-A.1.1]. The public key modulus length, rounded *up* to +//! the nearest (larger) multiple of 8 bits, must be in the range given in the +//! name of the algorithm. The public exponent must be an odd integer of 2-33 +//! bits, inclusive. +//! +//! During verification, signatures will only be accepted if the MGF1 digest +//! algorithm is the same as the message digest algorithm and if the salt +//! length is the same length as the message digest. This matches the +//! requirements in TLS 1.3 and other recent specifications. +//! +//! During signing, the message digest algorithm will be used as the MGF1 +//! digest algorithm. The salt will be the same length as the message digest. +//! This matches the requirements in TLS 1.3 and other recent specifications. +//! Additionally, the entire salt is randomly generated separately for each +//! signature using the secure random number generator passed to `sign()`. +//! +//! +//! [SEC 1: Elliptic Curve Cryptography, Version 2.0]: +//! http://www.secg.org/sec1-v2.pdf +//! [NIST Special Publication 800-56A, revision 2]: +//! http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-56Ar2.pdf +//! [Suite B implementer's guide to FIPS 186-3]: +//! https://github.com/briansmith/ring/blob/main/doc/ecdsa.pdf +//! [RFC 3279 Section 2.2.3]: +//! https://tools.ietf.org/html/rfc3279#section-2.2.3 +//! [RFC 3447 Section 8.2]: +//! https://tools.ietf.org/html/rfc3447#section-7.2 +//! [RFC 3447 Section 8.1]: +//! https://tools.ietf.org/html/rfc3447#section-8.1 +//! [RFC 3447 Appendix-A.1.1]: +//! https://tools.ietf.org/html/rfc3447#appendix-A.1.1 +//! +//! +//! # Examples +//! +//! ## Signing and verifying with Ed25519 +//! +//! ``` +//! use ring::{ +//! rand, +//! signature::{self, KeyPair}, +//! }; +//! +//! # fn main() -> Result<(), ring::error::Unspecified> { +//! // Generate a key pair in PKCS#8 (v2) format. +//! let rng = rand::SystemRandom::new(); +//! let pkcs8_bytes = signature::Ed25519KeyPair::generate_pkcs8(&rng)?; +//! +//! // Normally the application would store the PKCS#8 file persistently. Later +//! // it would read the PKCS#8 file from persistent storage to use it. +//! +//! let key_pair = signature::Ed25519KeyPair::from_pkcs8(pkcs8_bytes.as_ref())?; +//! +//! // Sign the message "hello, world". +//! const MESSAGE: &[u8] = b"hello, world"; +//! let sig = key_pair.sign(MESSAGE); +//! +//! // Normally an application would extract the bytes of the signature and +//! // send them in a protocol message to the peer(s). Here we just get the +//! // public key key directly from the key pair. +//! let peer_public_key_bytes = key_pair.public_key().as_ref(); +//! +//! // Verify the signature of the message using the public key. Normally the +//! // verifier of the message would parse the inputs to this code out of the +//! // protocol message(s) sent by the signer. +//! let peer_public_key = +//! signature::UnparsedPublicKey::new(&signature::ED25519, peer_public_key_bytes); +//! peer_public_key.verify(MESSAGE, sig.as_ref())?; +//! +//! # Ok(()) +//! # } +//! ``` +//! +//! ## Signing and verifying with RSA (PKCS#1 1.5 padding) +//! +//! By default OpenSSL writes RSA public keys in SubjectPublicKeyInfo format, +//! not RSAPublicKey format, and Base64-encodes them (“PEM” format). +//! +//! To convert the PEM SubjectPublicKeyInfo format (“BEGIN PUBLIC KEY”) to the +//! binary RSAPublicKey format needed by `verify()`, use: +//! +//! ```sh +//! openssl rsa -pubin \ +//! -in public_key.pem \ +//! -inform PEM \ +//! -RSAPublicKey_out \ +//! -outform DER \ +//! -out public_key.der +//! ``` +//! +//! To extract the RSAPublicKey-formatted public key from an ASN.1 (binary) +//! DER-encoded RSAPrivateKey format private key file, use: +//! +//! ```sh +//! openssl rsa -in private_key.der \ +//! -inform DER \ +//! -RSAPublicKey_out \ +//! -outform DER \ +//! -out public_key.der +//! ``` +//! +//! ``` +//! # #[cfg(feature = "std")] +//! use ring::{rand, rsa, signature}; +//! +//! # #[cfg(feature = "std")] +//! fn sign_and_verify_rsa(private_key_path: &std::path::Path, +//! public_key_path: &std::path::Path) +//! -> Result<(), MyError> { +//! // Create an RSA keypair from the DER-encoded bytes. This example uses +//! // a 2048-bit key, but larger keys are also supported. +//! let private_key_der = read_file(private_key_path)?; +//! let key_pair = rsa::KeyPair::from_der(&private_key_der) +//! .map_err(|_| MyError::BadPrivateKey)?; +//! +//! // Sign the message "hello, world", using PKCS#1 v1.5 padding and the +//! // SHA256 digest algorithm. +//! const MESSAGE: &'static [u8] = b"hello, world"; +//! let rng = rand::SystemRandom::new(); +//! let mut signature = vec![0; key_pair.public().modulus_len()]; +//! key_pair.sign(&signature::RSA_PKCS1_SHA256, &rng, MESSAGE, &mut signature) +//! .map_err(|_| MyError::OOM)?; +//! +//! // Verify the signature. +//! let public_key = +//! signature::UnparsedPublicKey::new(&signature::RSA_PKCS1_2048_8192_SHA256, +//! read_file(public_key_path)?); +//! public_key.verify(MESSAGE, &signature) +//! .map_err(|_| MyError::BadSignature) +//! } +//! +//! #[derive(Debug)] +//! enum MyError { +//! # #[cfg(feature = "std")] +//! IO(std::io::Error), +//! BadPrivateKey, +//! OOM, +//! BadSignature, +//! } +//! +//! # #[cfg(feature = "std")] +//! fn read_file(path: &std::path::Path) -> Result, MyError> { +//! use std::io::Read; +//! +//! let mut file = std::fs::File::open(path).map_err(|e| MyError::IO(e))?; +//! let mut contents: Vec = Vec::new(); +//! file.read_to_end(&mut contents).map_err(|e| MyError::IO(e))?; +//! Ok(contents) +//! } +//! # +//! # #[cfg(not(feature = "std"))] +//! # fn sign_and_verify_rsa(_private_key_path: &std::path::Path, +//! # _public_key_path: &std::path::Path) +//! # -> Result<(), ()> { +//! # Ok(()) +//! # } +//! # +//! # fn main() { +//! # let private_key_path = +//! # std::path::Path::new("src/rsa/signature_rsa_example_private_key.der"); +//! # let public_key_path = +//! # std::path::Path::new("src/rsa/signature_rsa_example_public_key.der"); +//! # sign_and_verify_rsa(&private_key_path, &public_key_path).unwrap() +//! # } +//! ``` + +use crate::{cpu, debug, ec, error, sealed}; + +pub use crate::ec::{ + curve25519::ed25519::{ + signing::Ed25519KeyPair, + verification::{EdDSAParameters, ED25519}, + ED25519_PUBLIC_KEY_LEN, + }, + suite_b::ecdsa::{ + signing::{ + EcdsaKeyPair, EcdsaSigningAlgorithm, ECDSA_P256_SHA256_ASN1_SIGNING, + ECDSA_P256_SHA256_FIXED_SIGNING, ECDSA_P384_SHA384_ASN1_SIGNING, + ECDSA_P384_SHA384_FIXED_SIGNING, + }, + verification::{ + EcdsaVerificationAlgorithm, ECDSA_P256_SHA256_ASN1, ECDSA_P256_SHA256_FIXED, + ECDSA_P256_SHA384_ASN1, ECDSA_P384_SHA256_ASN1, ECDSA_P384_SHA384_ASN1, + ECDSA_P384_SHA384_FIXED, + }, + }, +}; + +#[cfg(feature = "alloc")] +pub use crate::rsa::{ + padding::{ + RsaEncoding, RSA_PKCS1_SHA256, RSA_PKCS1_SHA384, RSA_PKCS1_SHA512, RSA_PSS_SHA256, + RSA_PSS_SHA384, RSA_PSS_SHA512, + }, + verification::{ + RsaPublicKeyComponents, RSA_PKCS1_1024_8192_SHA1_FOR_LEGACY_USE_ONLY, + RSA_PKCS1_1024_8192_SHA256_FOR_LEGACY_USE_ONLY, + RSA_PKCS1_1024_8192_SHA512_FOR_LEGACY_USE_ONLY, + RSA_PKCS1_2048_8192_SHA1_FOR_LEGACY_USE_ONLY, RSA_PKCS1_2048_8192_SHA256, + RSA_PKCS1_2048_8192_SHA384, RSA_PKCS1_2048_8192_SHA512, RSA_PKCS1_3072_8192_SHA384, + RSA_PSS_2048_8192_SHA256, RSA_PSS_2048_8192_SHA384, RSA_PSS_2048_8192_SHA512, + }, + RsaParameters, +}; + +/// An RSA key pair, used for signing. +#[cfg(feature = "alloc")] +pub type RsaKeyPair = crate::rsa::KeyPair; + +/// A public key signature returned from a signing operation. +#[derive(Clone, Copy)] +pub struct Signature { + value: [u8; MAX_LEN], + len: usize, +} + +impl Signature { + // Panics if `value` is too long. + pub(crate) fn new(fill: F) -> Self + where + F: FnOnce(&mut [u8; MAX_LEN]) -> usize, + { + let mut r = Self { + value: [0; MAX_LEN], + len: 0, + }; + r.len = fill(&mut r.value); + r + } +} + +impl AsRef<[u8]> for Signature { + fn as_ref(&self) -> &[u8] { + &self.value[..self.len] + } +} + +/// Key pairs for signing messages (private key and public key). +pub trait KeyPair: core::fmt::Debug + Send + Sized + Sync { + /// The type of the public key. + type PublicKey: AsRef<[u8]> + core::fmt::Debug + Clone + Send + Sized + Sync; + + /// The public key for the key pair. + fn public_key(&self) -> &Self::PublicKey; +} + +/// The longest signature is an ASN.1 P-384 signature where *r* and *s* are of +/// maximum length with the leading high bit set on each. Then each component +/// will have a tag, a one-byte length, and a one-byte “I'm not negative” +/// prefix, and the outer sequence will have a two-byte length. +pub(crate) const MAX_LEN: usize = 1/*tag:SEQUENCE*/ + 2/*len*/ + + (2 * (1/*tag:INTEGER*/ + 1/*len*/ + 1/*zero*/ + ec::SCALAR_MAX_BYTES)); + +/// A signature verification algorithm. +pub trait VerificationAlgorithm: core::fmt::Debug + Sync + sealed::Sealed { + /// Verify the signature `signature` of message `msg` with the public key + /// `public_key`. + fn verify( + &self, + public_key: untrusted::Input, + msg: untrusted::Input, + signature: untrusted::Input, + ) -> Result<(), error::Unspecified>; +} + +/// An unparsed, possibly malformed, public key for signature verification. +#[derive(Clone, Copy)] +pub struct UnparsedPublicKey { + algorithm: &'static dyn VerificationAlgorithm, + bytes: B, +} + +impl AsRef<[u8]> for UnparsedPublicKey +where + B: AsRef<[u8]>, +{ + fn as_ref(&self) -> &[u8] { + self.bytes.as_ref() + } +} + +impl core::fmt::Debug for UnparsedPublicKey +where + B: AsRef<[u8]>, +{ + fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> { + f.debug_struct("UnparsedPublicKey") + .field("algorithm", &self.algorithm) + .field("bytes", &debug::HexStr(self.bytes.as_ref())) + .finish() + } +} + +impl UnparsedPublicKey { + /// Construct a new `UnparsedPublicKey`. + /// + /// No validation of `bytes` is done until `verify()` is called. + #[inline] + pub fn new(algorithm: &'static dyn VerificationAlgorithm, bytes: B) -> Self { + Self { algorithm, bytes } + } + + /// Parses the public key and verifies `signature` is a valid signature of + /// `message` using it. + /// + /// See the [crate::signature] module-level documentation for examples. + pub fn verify(&self, message: &[u8], signature: &[u8]) -> Result<(), error::Unspecified> + where + B: AsRef<[u8]>, + { + let _ = cpu::features(); + self.algorithm.verify( + untrusted::Input::from(self.bytes.as_ref()), + untrusted::Input::from(message), + untrusted::Input::from(signature), + ) + } +} diff --git a/http/vendor/ring/src/tests/bits_tests.rs b/http/vendor/ring/src/tests/bits_tests.rs new file mode 100644 index 0000000..f825202 --- /dev/null +++ b/http/vendor/ring/src/tests/bits_tests.rs @@ -0,0 +1,64 @@ +// Copyright 2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use crate::{ + bits::{BitLength, FromByteLen as _}, + polyfill::u64_from_usize, +}; + +#[test] +fn test_from_byte_len_overflow() { + const USIZE_MAX_VALID_BYTES: usize = usize::MAX / 8; + + // Maximum valid input for BitLength. + match BitLength::::from_byte_len(USIZE_MAX_VALID_BYTES) { + Ok(bits) => { + assert_eq!(bits.as_usize_bytes_rounded_up(), USIZE_MAX_VALID_BYTES); + assert_eq!(bits.as_bits(), usize::MAX & !0b111); + } + Err(_) => unreachable!(), + } + + // Minimum invalid usize input for BitLength. + assert!(BitLength::::from_byte_len(USIZE_MAX_VALID_BYTES + 1).is_err()); + + // Minimum invalid usize input for BitLength on 64-bit targets. + { + let r = BitLength::::from_byte_len(USIZE_MAX_VALID_BYTES + 1); + if cfg!(target_pointer_width = "64") { + assert!(r.is_err()); + } else { + match r { + Ok(bits) => { + assert_eq!( + bits.as_bits(), + (u64_from_usize(USIZE_MAX_VALID_BYTES) + 1) * 8 + ); + } + Err(_) => unreachable!(), + } + } + } + + const U64_MAX_VALID_BYTES: u64 = u64::MAX / 8; + + // Maximum valid u64 input for BitLength. + match BitLength::::from_byte_len(U64_MAX_VALID_BYTES) { + Ok(bits) => assert_eq!(bits.as_bits(), u64::MAX & !0b111), + Err(_) => unreachable!(), + }; + + // Minimum invalid usize input for BitLength on 64-bit targets. + assert!(BitLength::::from_byte_len(U64_MAX_VALID_BYTES + 1).is_err()); +} diff --git a/http/vendor/ring/src/tests/mod.rs b/http/vendor/ring/src/tests/mod.rs new file mode 100644 index 0000000..b1cabd6 --- /dev/null +++ b/http/vendor/ring/src/tests/mod.rs @@ -0,0 +1,17 @@ +// Copyright 2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! Integration tests for non-public APIs. + +mod bits_tests; diff --git a/http/vendor/ring/src/testutil.rs b/http/vendor/ring/src/testutil.rs new file mode 100644 index 0000000..31cfb98 --- /dev/null +++ b/http/vendor/ring/src/testutil.rs @@ -0,0 +1,640 @@ +// Copyright 2015-2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! Testing framework. +//! +//! Unlike the rest of *ring*, this testing framework uses panics pretty +//! liberally. It was originally designed for internal use--it drives most of +//! *ring*'s internal tests, and so it is optimized for getting *ring*'s tests +//! written quickly at the expense of some usability. The documentation is +//! lacking. The best way to learn it is to look at some examples. The digest +//! tests are the most complicated because they use named sections. Other tests +//! avoid named sections and so are easier to understand. +//! +//! # Examples +//! +//! ## Writing Tests +//! +//! Input files look like this: +//! +//! ```text +//! # This is a comment. +//! +//! HMAC = SHA1 +//! Input = "My test data" +//! Key = "" +//! Output = 61afdecb95429ef494d61fdee15990cabf0826fc +//! +//! HMAC = SHA256 +//! Input = "Sample message for keylen +//! at C:\Users\Example\example\:4 +//! 9: 0x7ff65496d49c - example_test +//! at C:\Users\Example\example\src\example.rs:652 +//! 10: 0x7ff6549d192a - test::stats::Summary::new::ha139494ed2e4e01f +//! 11: 0x7ff6549d51a2 - test::stats::Summary::new::ha139494ed2e4e01f +//! 12: 0x7ff654a0a911 - _rust_maybe_catch_panic +//! 13: 0x7ff6549d56dd - test::stats::Summary::new::ha139494ed2e4e01f +//! 14: 0x7ff654a03783 - std::sys::thread::Thread::new::h2b08da6cd2517f79 +//! 15: 0x7ff968518101 - BaseThreadInitThunk +//! ``` +//! +//! Notice that the output shows the name of the data file +//! (`src/example_tests.txt`), the test inputs that led to the failure, and the +//! stack trace to the line in the test code that panicked: entry 9 in the +//! stack trace pointing to line 652 of the file `example.rs`. + +extern crate alloc; + +use alloc::{format, string::String, vec::Vec}; + +use crate::{bits, digest, error}; + +#[cfg(any(feature = "std", feature = "test_logging"))] +extern crate std; + +/// `compile_time_assert_clone::();` fails to compile if `T` doesn't +/// implement `Clone`. +pub const fn compile_time_assert_clone() {} + +/// `compile_time_assert_copy::();` fails to compile if `T` doesn't +/// implement `Copy`. +pub const fn compile_time_assert_copy() {} + +/// `compile_time_assert_eq::();` fails to compile if `T` doesn't +/// implement `Eq`. +pub const fn compile_time_assert_eq() {} + +/// `compile_time_assert_send::();` fails to compile if `T` doesn't +/// implement `Send`. +pub const fn compile_time_assert_send() {} + +/// `compile_time_assert_sync::();` fails to compile if `T` doesn't +/// implement `Sync`. +pub const fn compile_time_assert_sync() {} + +/// `compile_time_assert_std_error_error::();` fails to compile if `T` +/// doesn't implement `std::error::Error`. +#[cfg(feature = "std")] +pub const fn compile_time_assert_std_error_error() {} + +/// A test case. A test case consists of a set of named attributes. Every +/// attribute in the test case must be consumed exactly once; this helps catch +/// typos and omissions. +/// +/// Requires the `alloc` default feature to be enabled. +#[derive(Debug)] +pub struct TestCase { + attributes: Vec<(String, String, bool)>, +} + +impl TestCase { + /// Maps the string "true" to true and the string "false" to false. + pub fn consume_bool(&mut self, key: &str) -> bool { + match self.consume_string(key).as_ref() { + "true" => true, + "false" => false, + s => panic!("Invalid bool value: {}", s), + } + } + + /// Maps the strings "SHA1", "SHA256", "SHA384", and "SHA512" to digest + /// algorithms, maps "SHA224" to `None`, and panics on other (erroneous) + /// inputs. "SHA224" is mapped to None because *ring* intentionally does + /// not support SHA224, but we need to consume test vectors from NIST that + /// have SHA224 vectors in them. + pub fn consume_digest_alg(&mut self, key: &str) -> Option<&'static digest::Algorithm> { + let name = self.consume_string(key); + match name.as_ref() { + "SHA1" => Some(&digest::SHA1_FOR_LEGACY_USE_ONLY), + "SHA224" => None, // We actively skip SHA-224 support. + "SHA256" => Some(&digest::SHA256), + "SHA384" => Some(&digest::SHA384), + "SHA512" => Some(&digest::SHA512), + "SHA512_256" => Some(&digest::SHA512_256), + _ => panic!("Unsupported digest algorithm: {}", name), + } + } + + /// Returns the value of an attribute that is encoded as a sequence of an + /// even number of hex digits, or as a double-quoted UTF-8 string. The + /// empty (zero-length) value is represented as "". + pub fn consume_bytes(&mut self, key: &str) -> Vec { + self.consume_optional_bytes(key) + .unwrap_or_else(|| panic!("No attribute named \"{}\"", key)) + } + + /// Like `consume_bytes()` except it returns `None` if the test case + /// doesn't have the attribute. + pub fn consume_optional_bytes(&mut self, key: &str) -> Option> { + let s = self.consume_optional_string(key)?; + let result = if let [b'\"', s @ ..] = s.as_bytes() { + // The value is a quoted UTF-8 string. + let mut s = s.iter(); + let mut bytes = Vec::with_capacity(s.len() - 1); + loop { + let b = match s.next() { + Some(b'\\') => { + match s.next() { + // We don't allow all octal escape sequences, only "\0" for null. + Some(b'0') => 0u8, + Some(b't') => b'\t', + Some(b'n') => b'\n', + // "\xHH" + Some(b'x') => { + let hi = s.next().expect("Invalid hex escape sequence in string."); + let lo = s.next().expect("Invalid hex escape sequence in string."); + if let (Ok(hi), Ok(lo)) = (from_hex_digit(*hi), from_hex_digit(*lo)) + { + (hi << 4) | lo + } else { + panic!("Invalid hex escape sequence in string."); + } + } + _ => { + panic!("Invalid hex escape sequence in string."); + } + } + } + Some(b'"') => { + if s.next().is_some() { + panic!("characters after the closing quote of a quoted string."); + } + break; + } + Some(b) => *b, + None => panic!("Missing terminating '\"' in string literal."), + }; + bytes.push(b); + } + bytes + } else { + // The value is hex encoded. + match from_hex(&s) { + Ok(s) => s, + Err(err_str) => { + panic!("{} in {}", err_str, s); + } + } + }; + Some(result) + } + + /// Returns the value of an attribute that is an integer, in decimal + /// notation. + pub fn consume_usize(&mut self, key: &str) -> usize { + let s = self.consume_string(key); + s.parse::().unwrap() + } + + /// Returns the value of an attribute that is an integer, in decimal + /// notation, as a bit length. + pub fn consume_usize_bits(&mut self, key: &str) -> bits::BitLength { + let s = self.consume_string(key); + let bits = s.parse::().unwrap(); + bits::BitLength::from_bits(bits) + } + + /// Returns the raw value of an attribute, without any unquoting or + /// other interpretation. + pub fn consume_string(&mut self, key: &str) -> String { + self.consume_optional_string(key) + .unwrap_or_else(|| panic!("No attribute named \"{}\"", key)) + } + + /// Like `consume_string()` except it returns `None` if the test case + /// doesn't have the attribute. + pub fn consume_optional_string(&mut self, key: &str) -> Option { + for (name, value, consumed) in &mut self.attributes { + if key == name { + if *consumed { + panic!("Attribute {} was already consumed", key); + } + *consumed = true; + return Some(value.clone()); + } + } + None + } +} + +/// References a test input file. +#[cfg(test)] +macro_rules! test_vector_file { + ($file_name:expr) => { + $crate::testutil::File { + file_name: $file_name, + contents: include_str!($file_name), + } + }; +} + +/// A test input file. +pub struct File<'a> { + /// The name (path) of the file. + pub file_name: &'a str, + + /// The contents of the file. + pub contents: &'a str, +} + +/// Parses test cases out of the given file, calling `f` on each vector until +/// `f` fails or until all the test vectors have been read. `f` can indicate +/// failure either by returning `Err()` or by panicking. +pub fn run(test_file: File, mut f: F) +where + F: FnMut(&str, &mut TestCase) -> Result<(), error::Unspecified>, +{ + let lines = &mut test_file.contents.lines(); + + let mut current_section = String::from(""); + let mut failed = false; + + while let Some(mut test_case) = parse_test_case(&mut current_section, lines) { + let result = match f(¤t_section, &mut test_case) { + Ok(()) => { + if !test_case + .attributes + .iter() + .any(|&(_, _, consumed)| !consumed) + { + Ok(()) + } else { + failed = true; + Err("Test didn't consume all attributes.") + } + } + Err(error::Unspecified) => Err("Test returned Err(error::Unspecified)."), + }; + + if result.is_err() { + failed = true; + } + + #[cfg(feature = "test_logging")] + if let Err(msg) = result { + std::println!("{}: {}", test_file.file_name, msg); + + for (name, value, consumed) in test_case.attributes { + let consumed_str = if consumed { "" } else { " (unconsumed)" }; + std::println!("{}{} = {}", name, consumed_str, value); + } + }; + } + + if failed { + panic!("Test failed.") + } +} + +/// Decode an string of hex digits into a sequence of bytes. The input must +/// have an even number of digits. +pub fn from_hex(hex_str: &str) -> Result, String> { + if hex_str.len() % 2 != 0 { + return Err(String::from( + "Hex string does not have an even number of digits", + )); + } + + let mut result = Vec::with_capacity(hex_str.len() / 2); + for digits in hex_str.as_bytes().chunks(2) { + let hi = from_hex_digit(digits[0])?; + let lo = from_hex_digit(digits[1])?; + result.push((hi * 0x10) | lo); + } + Ok(result) +} + +fn from_hex_digit(d: u8) -> Result { + use core::ops::RangeInclusive; + const DECIMAL: (u8, RangeInclusive) = (0, b'0'..=b'9'); + const HEX_LOWER: (u8, RangeInclusive) = (10, b'a'..=b'f'); + const HEX_UPPER: (u8, RangeInclusive) = (10, b'A'..=b'F'); + for (offset, range) in &[DECIMAL, HEX_LOWER, HEX_UPPER] { + if range.contains(&d) { + return Ok(d - range.start() + offset); + } + } + Err(format!("Invalid hex digit '{}'", d as char)) +} + +fn parse_test_case( + current_section: &mut String, + lines: &mut dyn Iterator, +) -> Option { + let mut attributes = Vec::new(); + + let mut is_first_line = true; + loop { + let line = lines.next(); + + #[cfg(feature = "test_logging")] + if let Some(text) = &line { + std::println!("Line: {}", text); + } + + match line { + // If we get to EOF when we're not in the middle of a test case, + // then we're done. + None if is_first_line => { + return None; + } + + // End of the file on a non-empty test cases ends the test case. + None => { + return Some(TestCase { attributes }); + } + + // A blank line ends a test case if the test case isn't empty. + Some("") => { + if !is_first_line { + return Some(TestCase { attributes }); + } + // Ignore leading blank lines. + } + + // Comments start with '#'; ignore them. + Some(line) if line.starts_with('#') => (), + + Some(line) if line.starts_with('[') => { + assert!(is_first_line); + assert!(line.ends_with(']')); + current_section.truncate(0); + current_section.push_str(line); + let _ = current_section.pop(); + let _ = current_section.remove(0); + } + + Some(line) => { + is_first_line = false; + + let parts: Vec<&str> = line.splitn(2, " = ").collect(); + if parts.len() != 2 { + panic!("Syntax error: Expected Key = Value."); + }; + + let key = parts[0].trim(); + let value = parts[1].trim(); + + // Don't allow the value to be omitted. An empty value can be + // represented as an empty quoted string. + assert_ne!(value.len(), 0); + + // Checking is_none() ensures we don't accept duplicate keys. + attributes.push((String::from(key), String::from(value), false)); + } + } + } +} + +/// Deterministic implementations of `ring::rand::SecureRandom`. +/// +/// These implementations are particularly useful for testing implementations +/// of randomized algorithms & protocols using known-answer-tests where the +/// test vectors contain the random seed to use. They are also especially +/// useful for some types of fuzzing. +#[doc(hidden)] +pub mod rand { + use crate::{error, rand}; + + /// An implementation of `SecureRandom` that always fills the output slice + /// with the given byte. + #[derive(Debug)] + pub struct FixedByteRandom { + pub byte: u8, + } + + impl rand::sealed::SecureRandom for FixedByteRandom { + fn fill_impl(&self, dest: &mut [u8]) -> Result<(), error::Unspecified> { + dest.fill(self.byte); + Ok(()) + } + } + + /// An implementation of `SecureRandom` that always fills the output slice + /// with the slice in `bytes`. The length of the slice given to `slice` + /// must match exactly. + #[derive(Debug)] + pub struct FixedSliceRandom<'a> { + pub bytes: &'a [u8], + } + + impl rand::sealed::SecureRandom for FixedSliceRandom<'_> { + fn fill_impl(&self, dest: &mut [u8]) -> Result<(), error::Unspecified> { + dest.copy_from_slice(self.bytes); + Ok(()) + } + } + + /// An implementation of `SecureRandom` where each slice in `bytes` is a + /// test vector for one call to `fill()`. *Not thread-safe.* + /// + /// The first slice in `bytes` is the output for the first call to + /// `fill()`, the second slice is the output for the second call to + /// `fill()`, etc. The output slice passed to `fill()` must have exactly + /// the length of the corresponding entry in `bytes`. `current` must be + /// initialized to zero. `fill()` must be called exactly once for each + /// entry in `bytes`. + #[derive(Debug)] + pub struct FixedSliceSequenceRandom<'a> { + /// The value. + pub bytes: &'a [&'a [u8]], + pub current: core::cell::UnsafeCell, + } + + impl rand::sealed::SecureRandom for FixedSliceSequenceRandom<'_> { + fn fill_impl(&self, dest: &mut [u8]) -> Result<(), error::Unspecified> { + let current = unsafe { *self.current.get() }; + let bytes = self.bytes[current]; + dest.copy_from_slice(bytes); + // Remember that we returned this slice and prepare to return + // the next one, if any. + unsafe { *self.current.get() += 1 }; + Ok(()) + } + } + + impl Drop for FixedSliceSequenceRandom<'_> { + fn drop(&mut self) { + // Ensure that `fill()` was called exactly the right number of + // times. + assert_eq!(unsafe { *self.current.get() }, self.bytes.len()); + } + } +} + +#[cfg(test)] +mod tests { + use crate::error; + use crate::testutil as test; + + #[test] + fn one_ok() { + test::run(test_vector_file!("test_1_tests.txt"), |_, test_case| { + let _ = test_case.consume_string("Key"); + Ok(()) + }); + } + + #[test] + #[should_panic(expected = "Test failed.")] + fn one_err() { + test::run(test_vector_file!("test_1_tests.txt"), |_, test_case| { + let _ = test_case.consume_string("Key"); + Err(error::Unspecified) + }); + } + + #[test] + #[should_panic(expected = "Oh noes!")] + fn one_panics() { + test::run(test_vector_file!("test_1_tests.txt"), |_, test_case| { + let _ = test_case.consume_string("Key"); + panic!("Oh noes!"); + }); + } + + #[test] + #[should_panic(expected = "Test failed.")] + fn first_err() { + err_one(0) + } + + #[test] + #[should_panic(expected = "Test failed.")] + fn middle_err() { + err_one(1) + } + + #[test] + #[should_panic(expected = "Test failed.")] + fn last_err() { + err_one(2) + } + + fn err_one(test_to_fail: usize) { + let mut n = 0; + test::run(test_vector_file!("test_3_tests.txt"), |_, test_case| { + let _ = test_case.consume_string("Key"); + let result = if n != test_to_fail { + Ok(()) + } else { + Err(error::Unspecified) + }; + n += 1; + result + }); + } + + #[test] + #[should_panic(expected = "Oh Noes!")] + fn first_panic() { + panic_one(0) + } + + #[test] + #[should_panic(expected = "Oh Noes!")] + fn middle_panic() { + panic_one(1) + } + + #[test] + #[should_panic(expected = "Oh Noes!")] + fn last_panic() { + panic_one(2) + } + + fn panic_one(test_to_fail: usize) { + let mut n = 0; + test::run(test_vector_file!("test_3_tests.txt"), |_, test_case| { + let _ = test_case.consume_string("Key"); + if n == test_to_fail { + panic!("Oh Noes!"); + }; + n += 1; + Ok(()) + }); + } + + #[test] + #[should_panic(expected = "Syntax error: Expected Key = Value.")] + fn syntax_error() { + test::run( + test_vector_file!("test_1_syntax_error_tests.txt"), + |_, _| Ok(()), + ); + } +} diff --git a/http/vendor/ring/tests/aead_tests.rs b/http/vendor/ring/tests/aead_tests.rs new file mode 100644 index 0000000..261822f --- /dev/null +++ b/http/vendor/ring/tests/aead_tests.rs @@ -0,0 +1,653 @@ +// Copyright 2015-2021 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#![allow(missing_docs)] + +#[cfg(all(target_arch = "wasm32", target_os = "unknown"))] +use wasm_bindgen_test::{wasm_bindgen_test as test, wasm_bindgen_test_configure}; + +#[cfg(all(target_arch = "wasm32", target_os = "unknown"))] +wasm_bindgen_test_configure!(run_in_browser); + +use core::ops::RangeFrom; +use ring::{aead, error}; +#[allow(deprecated)] +use ring::{test, test_file}; + +/// Generate the known answer test functions for the given algorithm and test +/// case input file, where each test is implemented by a test in `$test`. +/// +/// All of these tests can be run in parallel. +macro_rules! test_known_answer { + ( $alg:ident, $test_file:expr, [ $( $test:ident ),+, ] ) => { + $( + #[test] + fn $test() { + test_aead( + &aead::$alg, + super::super::$test, + test_file!($test_file)); + } + )+ + } +} + +/// Generate the tests for a given algorithm. +/// +/// All of these tests can be run in parallel. +macro_rules! test_aead { + { $( { $alg:ident, $test_file:expr } ),+, } => { + mod aead_test { // Make `cargo test aead` include these files. + $( + #[allow(non_snake_case)] + mod $alg { // Provide a separate namespace for each algorithm's test. + use super::super::*; + + #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] + use wasm_bindgen_test::wasm_bindgen_test as test; + + test_known_answer!( + $alg, + $test_file, + [ + less_safe_key_open_in_place, + less_safe_key_open_within, + less_safe_key_seal_in_place_append_tag, + less_safe_key_seal_in_place_separate_tag, + opening_key_open_in_place, + opening_key_open_within, + sealing_key_seal_in_place_append_tag, + sealing_key_seal_in_place_separate_tag, + test_open_in_place_seperate_tag, + ]); + + #[test] + fn key_sizes() { + super::super::key_sizes(&aead::$alg); + } + } + )+ + } + } +} + +test_aead! { + { AES_128_GCM, "aead_aes_128_gcm_tests.txt" }, + { AES_256_GCM, "aead_aes_256_gcm_tests.txt" }, + { CHACHA20_POLY1305, "aead_chacha20_poly1305_tests.txt" }, +} + +struct KnownAnswerTestCase<'a> { + key: &'a [u8], + nonce: [u8; aead::NONCE_LEN], + plaintext: &'a [u8], + aad: aead::Aad<&'a [u8]>, + ciphertext: &'a [u8], + tag: &'a [u8], +} + +fn test_aead( + aead_alg: &'static aead::Algorithm, + f: impl Fn(&'static aead::Algorithm, KnownAnswerTestCase) -> Result<(), error::Unspecified>, + test_file: test::File, +) { + test::run(test_file, |section, test_case| { + assert_eq!(section, ""); + let key = test_case.consume_bytes("KEY"); + let nonce = test_case.consume_bytes("NONCE"); + let plaintext = test_case.consume_bytes("IN"); + let aad = test_case.consume_bytes("AD"); + let ct = test_case.consume_bytes("CT"); + let tag = test_case.consume_bytes("TAG"); + let error = test_case.consume_optional_string("FAILS"); + + match error.as_deref() { + Some("WRONG_NONCE_LENGTH") => { + assert!(matches!( + aead::Nonce::try_assume_unique_for_key(&nonce), + Err(error::Unspecified) + )); + return Ok(()); + } + Some(unexpected) => { + unreachable!("unexpected error in test data: {}", unexpected); + } + None => {} + }; + + let test_case = KnownAnswerTestCase { + key: &key, + nonce: nonce.as_slice().try_into().unwrap(), + plaintext: &plaintext, + aad: aead::Aad::from(&aad), + ciphertext: &ct, + tag: &tag, + }; + + f(aead_alg, test_case) + }) +} + +fn test_seal_append_tag( + tc: &KnownAnswerTestCase, + seal: Seal, +) -> Result<(), error::Unspecified> +where + Seal: FnOnce(aead::Nonce, &mut Vec) -> Result<(), error::Unspecified>, +{ + let mut in_out = Vec::from(tc.plaintext); + seal(aead::Nonce::assume_unique_for_key(tc.nonce), &mut in_out)?; + + let mut expected_ciphertext_and_tag = Vec::from(tc.ciphertext); + expected_ciphertext_and_tag.extend_from_slice(tc.tag); + + assert_eq!(in_out, expected_ciphertext_and_tag); + + Ok(()) +} + +fn test_seal_separate_tag( + tc: &KnownAnswerTestCase, + seal: Seal, +) -> Result<(), error::Unspecified> +where + Seal: Fn(aead::Nonce, &mut [u8]) -> Result, +{ + let mut in_out = Vec::from(tc.plaintext); + let actual_tag = seal(aead::Nonce::assume_unique_for_key(tc.nonce), &mut in_out)?; + assert_eq!(actual_tag.as_ref(), tc.tag); + assert_eq!(in_out, tc.ciphertext); + + Ok(()) +} + +fn test_open_in_place( + tc: &KnownAnswerTestCase<'_>, + open_in_place: OpenInPlace, +) -> Result<(), error::Unspecified> +where + OpenInPlace: + for<'a> FnOnce(aead::Nonce, &'a mut [u8]) -> Result<&'a mut [u8], error::Unspecified>, +{ + let nonce = aead::Nonce::assume_unique_for_key(tc.nonce); + + let mut in_out = Vec::from(tc.ciphertext); + in_out.extend_from_slice(tc.tag); + + let actual_plaintext = open_in_place(nonce, &mut in_out)?; + + assert_eq!(actual_plaintext, tc.plaintext); + assert_eq!(&in_out[..tc.plaintext.len()], tc.plaintext); + Ok(()) +} + +fn test_open_in_place_seperate_tag( + alg: &'static aead::Algorithm, + tc: KnownAnswerTestCase, +) -> Result<(), error::Unspecified> { + let key = make_less_safe_key(alg, tc.key); + + let mut in_out = Vec::from(tc.ciphertext); + let tag = tc.tag.try_into().unwrap(); + + // Test the simplest behavior. + { + let nonce = aead::Nonce::assume_unique_for_key(tc.nonce); + let actual_plaintext = + key.open_in_place_separate_tag(nonce, tc.aad, tag, &mut in_out, 0..)?; + + assert_eq!(actual_plaintext, tc.plaintext); + assert_eq!(&in_out[..tc.plaintext.len()], tc.plaintext); + } + + // Test that ciphertext range shifting works as expected. + { + let range = in_out.len()..; + in_out.extend_from_slice(tc.ciphertext); + + let nonce = aead::Nonce::assume_unique_for_key(tc.nonce); + let actual_plaintext = + key.open_in_place_separate_tag(nonce, tc.aad, tag, &mut in_out, range)?; + + assert_eq!(actual_plaintext, tc.plaintext); + assert_eq!(&in_out[..tc.plaintext.len()], tc.plaintext); + } + + Ok(()) +} + +fn test_open_within( + tc: &KnownAnswerTestCase<'_>, + open_within: OpenWithin, +) -> Result<(), error::Unspecified> +where + OpenWithin: for<'a> Fn( + aead::Nonce, + &'a mut [u8], + RangeFrom, + ) -> Result<&'a mut [u8], error::Unspecified>, +{ + // In release builds, test all prefix lengths from 0 to 4096 bytes. + // Debug builds are too slow for this, so for those builds, only + // test a smaller subset. + + // TLS record headers are 5 bytes long. + // TLS explicit nonces for AES-GCM are 8 bytes long. + static MINIMAL_IN_PREFIX_LENS: [usize; 36] = [ + // No input prefix to overwrite; i.e. the opening is exactly + // "in place." + 0, + 1, + 2, + // Proposed TLS 1.3 header (no explicit nonce). + 5, + 8, + // Probably the most common use of a non-zero `in_prefix_len` + // would be to write a decrypted TLS record over the top of the + // TLS header and nonce. + 5 /* record header */ + 8, /* explicit nonce */ + // The stitched AES-GCM x86-64 code works on 6-block (96 byte) + // units. Some of the ChaCha20 code is even weirder. + 15, // The maximum partial AES block. + 16, // One AES block. + 17, // One byte more than a full AES block. + 31, // 2 AES blocks or 1 ChaCha20 block, minus 1. + 32, // Two AES blocks, one ChaCha20 block. + 33, // 2 AES blocks or 1 ChaCha20 block, plus 1. + 47, // Three AES blocks - 1. + 48, // Three AES blocks. + 49, // Three AES blocks + 1. + 63, // Four AES blocks or two ChaCha20 blocks, minus 1. + 64, // Four AES blocks or two ChaCha20 blocks. + 65, // Four AES blocks or two ChaCha20 blocks, plus 1. + 79, // Five AES blocks, minus 1. + 80, // Five AES blocks. + 81, // Five AES blocks, plus 1. + 95, // Six AES blocks or three ChaCha20 blocks, minus 1. + 96, // Six AES blocks or three ChaCha20 blocks. + 97, // Six AES blocks or three ChaCha20 blocks, plus 1. + 111, // Seven AES blocks, minus 1. + 112, // Seven AES blocks. + 113, // Seven AES blocks, plus 1. + 127, // Eight AES blocks or four ChaCha20 blocks, minus 1. + 128, // Eight AES blocks or four ChaCha20 blocks. + 129, // Eight AES blocks or four ChaCha20 blocks, plus 1. + 143, // Nine AES blocks, minus 1. + 144, // Nine AES blocks. + 145, // Nine AES blocks, plus 1. + 255, // 16 AES blocks or 8 ChaCha20 blocks, minus 1. + 256, // 16 AES blocks or 8 ChaCha20 blocks. + 257, // 16 AES blocks or 8 ChaCha20 blocks, plus 1. + ]; + + let mut more_comprehensive_in_prefix_lengths = [0; 4096]; + let in_prefix_lengths = if cfg!(debug_assertions) { + &MINIMAL_IN_PREFIX_LENS[..] + } else { + #[allow(clippy::needless_range_loop)] + for b in 0..more_comprehensive_in_prefix_lengths.len() { + more_comprehensive_in_prefix_lengths[b] = b; + } + &more_comprehensive_in_prefix_lengths[..] + }; + let mut in_out = vec![123u8; 4096]; + + for &in_prefix_len in in_prefix_lengths.iter() { + in_out.truncate(0); + in_out.resize(in_prefix_len, 123); + in_out.extend_from_slice(tc.ciphertext); + in_out.extend_from_slice(tc.tag); + + let actual_plaintext = open_within( + aead::Nonce::assume_unique_for_key(tc.nonce), + &mut in_out, + in_prefix_len.., + )?; + assert_eq!(actual_plaintext, tc.plaintext); + assert_eq!(&in_out[..tc.plaintext.len()], tc.plaintext); + } + + Ok(()) +} + +fn sealing_key_seal_in_place_append_tag( + alg: &'static aead::Algorithm, + tc: KnownAnswerTestCase, +) -> Result<(), error::Unspecified> { + test_seal_append_tag(&tc, |nonce, in_out| { + let mut key: aead::SealingKey = make_key(alg, tc.key, nonce); + key.seal_in_place_append_tag(tc.aad, in_out) + }) +} + +fn sealing_key_seal_in_place_separate_tag( + alg: &'static aead::Algorithm, + tc: KnownAnswerTestCase, +) -> Result<(), error::Unspecified> { + test_seal_separate_tag(&tc, |nonce, in_out| { + let mut key: aead::SealingKey<_> = make_key(alg, tc.key, nonce); + key.seal_in_place_separate_tag(tc.aad, in_out) + }) +} + +fn opening_key_open_in_place( + alg: &'static aead::Algorithm, + tc: KnownAnswerTestCase, +) -> Result<(), error::Unspecified> { + test_open_in_place(&tc, |nonce, in_out| { + let mut key: aead::OpeningKey<_> = make_key(alg, tc.key, nonce); + key.open_in_place(tc.aad, in_out) + }) +} + +fn opening_key_open_within( + alg: &'static aead::Algorithm, + tc: KnownAnswerTestCase, +) -> Result<(), error::Unspecified> { + test_open_within(&tc, |nonce, in_out, ciphertext_and_tag| { + let mut key: aead::OpeningKey = make_key(alg, tc.key, nonce); + key.open_within(tc.aad, in_out, ciphertext_and_tag) + }) +} + +fn less_safe_key_seal_in_place_append_tag( + alg: &'static aead::Algorithm, + tc: KnownAnswerTestCase, +) -> Result<(), error::Unspecified> { + test_seal_append_tag(&tc, |nonce, in_out| { + let key = make_less_safe_key(alg, tc.key); + key.seal_in_place_append_tag(nonce, tc.aad, in_out) + }) +} + +fn less_safe_key_open_in_place( + alg: &'static aead::Algorithm, + tc: KnownAnswerTestCase, +) -> Result<(), error::Unspecified> { + test_open_in_place(&tc, |nonce, in_out| { + let key = make_less_safe_key(alg, tc.key); + key.open_in_place(nonce, tc.aad, in_out) + }) +} + +fn less_safe_key_seal_in_place_separate_tag( + alg: &'static aead::Algorithm, + tc: KnownAnswerTestCase, +) -> Result<(), error::Unspecified> { + test_seal_separate_tag(&tc, |nonce, in_out| { + let key = make_less_safe_key(alg, tc.key); + key.seal_in_place_separate_tag(nonce, tc.aad, in_out) + }) +} + +fn less_safe_key_open_within( + alg: &'static aead::Algorithm, + tc: KnownAnswerTestCase, +) -> Result<(), error::Unspecified> { + test_open_within(&tc, |nonce, in_out, ciphertext_and_tag| { + let key = make_less_safe_key(alg, tc.key); + key.open_within(nonce, tc.aad, in_out, ciphertext_and_tag) + }) +} + +#[allow(clippy::range_plus_one)] +fn key_sizes(aead_alg: &'static aead::Algorithm) { + let key_len = aead_alg.key_len(); + let key_data = vec![0u8; key_len * 2]; + + // Key is the right size. + assert!(aead::UnboundKey::new(aead_alg, &key_data[..key_len]).is_ok()); + + // Key is one byte too small. + assert!(aead::UnboundKey::new(aead_alg, &key_data[..(key_len - 1)]).is_err()); + + // Key is one byte too large. + assert!(aead::UnboundKey::new(aead_alg, &key_data[..(key_len + 1)]).is_err()); + + // Key is half the required size. + assert!(aead::UnboundKey::new(aead_alg, &key_data[..(key_len / 2)]).is_err()); + + // Key is twice the required size. + assert!(aead::UnboundKey::new(aead_alg, &key_data[..(key_len * 2)]).is_err()); + + // Key is empty. + assert!(aead::UnboundKey::new(aead_alg, &[]).is_err()); + + // Key is one byte. + assert!(aead::UnboundKey::new(aead_alg, &[0]).is_err()); +} + +// Test that we reject non-standard nonce sizes. +#[allow(clippy::range_plus_one)] +#[test] +fn test_aead_nonce_sizes() { + let nonce_len = aead::NONCE_LEN; + let nonce = vec![0u8; nonce_len * 2]; + + assert!(aead::Nonce::try_assume_unique_for_key(&nonce[..nonce_len]).is_ok()); + assert!(aead::Nonce::try_assume_unique_for_key(&nonce[..(nonce_len - 1)]).is_err()); + assert!(aead::Nonce::try_assume_unique_for_key(&nonce[..(nonce_len + 1)]).is_err()); + assert!(aead::Nonce::try_assume_unique_for_key(&nonce[..(nonce_len / 2)]).is_err()); + assert!(aead::Nonce::try_assume_unique_for_key(&nonce[..(nonce_len * 2)]).is_err()); + assert!(aead::Nonce::try_assume_unique_for_key(&[]).is_err()); + assert!(aead::Nonce::try_assume_unique_for_key(&nonce[..1]).is_err()); + assert!(aead::Nonce::try_assume_unique_for_key(&nonce[..16]).is_err()); // 128 bits. +} + +#[allow(clippy::range_plus_one)] +#[test] +fn aead_chacha20_poly1305_openssh() { + // TODO: test_aead_key_sizes(...); + + test::run( + test_file!("aead_chacha20_poly1305_openssh_tests.txt"), + |section, test_case| { + assert_eq!(section, ""); + + // XXX: `polyfill::convert` isn't available here. + let key_bytes = { + let as_vec = test_case.consume_bytes("KEY"); + let mut as_array = [0u8; aead::chacha20_poly1305_openssh::KEY_LEN]; + as_array.copy_from_slice(&as_vec); + as_array + }; + + let sequence_num: u32 = test_case + .consume_usize("SEQUENCE_NUMBER") + .try_into() + .unwrap(); + let plaintext = test_case.consume_bytes("IN"); + let ct = test_case.consume_bytes("CT"); + let expected_tag = test_case.consume_bytes("TAG"); + + // TODO: Add some tests for when things fail. + //let error = test_case.consume_optional_string("FAILS"); + + let mut tag = [0u8; aead::chacha20_poly1305_openssh::TAG_LEN]; + let mut s_in_out = plaintext.clone(); + let s_key = aead::chacha20_poly1305_openssh::SealingKey::new(&key_bytes); + s_key.seal_in_place(sequence_num, &mut s_in_out[..], &mut tag); + assert_eq!(&ct, &s_in_out); + assert_eq!(&expected_tag, &tag); + let o_key = aead::chacha20_poly1305_openssh::OpeningKey::new(&key_bytes); + + { + let o_result = o_key.open_in_place(sequence_num, &mut s_in_out[..], &tag); + assert_eq!(o_result, Ok(&plaintext[4..])); + } + assert_eq!(&s_in_out[..4], &ct[..4]); + assert_eq!(&s_in_out[4..], &plaintext[4..]); + + Ok(()) + }, + ); +} + +#[test] +fn aead_test_aad_traits() { + test::compile_time_assert_send::>(); + test::compile_time_assert_sync::>(); + test::compile_time_assert_copy::>(); + test::compile_time_assert_eq::>>(); // `!Copy` + + let aad_123 = aead::Aad::from(vec![1, 2, 3]); // `!Copy` + assert_eq!(aad_123, aad_123.clone()); // Cover `Clone` and `PartialEq` + assert_eq!( + format!("{:?}", aead::Aad::from(&[1, 2, 3])), + "Aad([1, 2, 3])" + ); +} + +#[test] +fn test_nonce_traits() { + test::compile_time_assert_send::(); + test::compile_time_assert_sync::(); +} + +#[test] +fn test_tag_traits() { + test::compile_time_assert_send::(); + test::compile_time_assert_sync::(); + + test::compile_time_assert_copy::(); + test::compile_time_assert_clone::(); + + let tag = aead::Tag::from([4u8; 16]); + let _tag_2 = tag; // Cover `Copy` + assert_eq!(tag.as_ref(), tag.clone().as_ref()); // Cover `Clone` +} + +fn test_aead_key_traits() {} + +#[test] +fn test_aead_key_traits_all() { + test_aead_key_traits::>(); + test_aead_key_traits::>(); + test_aead_key_traits::(); +} + +#[test] +fn test_aead_key_debug() { + let key_bytes = [0; 32]; + let nonce = [0; aead::NONCE_LEN]; + + let key = aead::UnboundKey::new(&aead::AES_256_GCM, &key_bytes).unwrap(); + assert_eq!( + "UnboundKey { algorithm: AES_256_GCM }", + format!("{:?}", key) + ); + + let sealing_key: aead::SealingKey = make_key( + &aead::AES_256_GCM, + &key_bytes, + aead::Nonce::try_assume_unique_for_key(&nonce).unwrap(), + ); + assert_eq!( + "SealingKey { algorithm: AES_256_GCM }", + format!("{:?}", sealing_key) + ); + + let opening_key: aead::OpeningKey = make_key( + &aead::AES_256_GCM, + &key_bytes, + aead::Nonce::try_assume_unique_for_key(&nonce).unwrap(), + ); + assert_eq!( + "OpeningKey { algorithm: AES_256_GCM }", + format!("{:?}", opening_key) + ); + + let key: aead::LessSafeKey = make_less_safe_key(&aead::AES_256_GCM, &key_bytes); + assert_eq!( + "LessSafeKey { algorithm: AES_256_GCM }", + format!("{:?}", key) + ); +} + +fn test_aead_lesssafekey_clone_for_algorithm(algorithm: &'static aead::Algorithm) { + let test_bytes: Vec = (0..32).collect(); + let key_bytes = &test_bytes[..algorithm.key_len()]; + let nonce_bytes = &test_bytes[..algorithm.nonce_len()]; + + let key1: aead::LessSafeKey = + aead::LessSafeKey::new(aead::UnboundKey::new(algorithm, key_bytes).unwrap()); + let key2 = key1.clone(); + + // LessSafeKey doesn't support AsRef or PartialEq, so instead just check that both keys produce + // the same encrypted output. + let mut buf1: Vec = (0..100).collect(); + let mut buf2 = buf1.clone(); + let tag1 = key1 + .seal_in_place_separate_tag( + aead::Nonce::try_assume_unique_for_key(nonce_bytes).unwrap(), + aead::Aad::empty(), + &mut buf1, + ) + .unwrap(); + let tag2 = key2 + .seal_in_place_separate_tag( + aead::Nonce::try_assume_unique_for_key(nonce_bytes).unwrap(), + aead::Aad::empty(), + &mut buf2, + ) + .unwrap(); + assert_eq!(tag1.as_ref(), tag2.as_ref()); + assert_eq!(buf1, buf2); +} + +#[test] +fn test_aead_lesssafekey_clone_aes_128_gcm() { + test_aead_lesssafekey_clone_for_algorithm(&aead::AES_128_GCM); +} + +#[test] +fn test_aead_lesssafekey_clone_aes_256_gcm() { + test_aead_lesssafekey_clone_for_algorithm(&aead::AES_256_GCM); +} + +#[test] +fn test_aead_lesssafekey_clone_chacha20_poly1305() { + test_aead_lesssafekey_clone_for_algorithm(&aead::CHACHA20_POLY1305); +} + +fn make_key>( + algorithm: &'static aead::Algorithm, + key: &[u8], + nonce: aead::Nonce, +) -> K { + let key = aead::UnboundKey::new(algorithm, key).unwrap(); + let nonce_sequence = OneNonceSequence::new(nonce); + K::new(key, nonce_sequence) +} + +fn make_less_safe_key(algorithm: &'static aead::Algorithm, key: &[u8]) -> aead::LessSafeKey { + let key = aead::UnboundKey::new(algorithm, key).unwrap(); + aead::LessSafeKey::new(key) +} + +struct OneNonceSequence(Option); + +impl OneNonceSequence { + /// Constructs the sequence allowing `advance()` to be called + /// `allowed_invocations` times. + fn new(nonce: aead::Nonce) -> Self { + Self(Some(nonce)) + } +} + +impl aead::NonceSequence for OneNonceSequence { + fn advance(&mut self) -> Result { + self.0.take().ok_or(error::Unspecified) + } +} diff --git a/http/vendor/ring/tests/agreement_tests.rs b/http/vendor/ring/tests/agreement_tests.rs new file mode 100644 index 0000000..edbe04f --- /dev/null +++ b/http/vendor/ring/tests/agreement_tests.rs @@ -0,0 +1,218 @@ +// Copyright 2015-2017 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#![allow(missing_docs)] + +#[cfg(all(target_arch = "wasm32", target_os = "unknown"))] +use wasm_bindgen_test::{wasm_bindgen_test as test, wasm_bindgen_test_configure}; + +#[cfg(all(target_arch = "wasm32", target_os = "unknown"))] +wasm_bindgen_test_configure!(run_in_browser); + +extern crate alloc; + +use ring::{agreement, error, rand}; +#[allow(deprecated)] +use ring::{test, test_file}; + +#[test] +fn agreement_traits() { + use alloc::vec::Vec; + + let rng = rand::SystemRandom::new(); + let private_key = + agreement::EphemeralPrivateKey::generate(&agreement::ECDH_P256, &rng).unwrap(); + + test::compile_time_assert_send::(); + test::compile_time_assert_sync::(); + + assert_eq!( + format!("{:?}", &private_key), + "EphemeralPrivateKey { algorithm: Algorithm { curve: P256 } }" + ); + + let public_key = private_key.compute_public_key().unwrap(); + + test::compile_time_assert_clone::(); + test::compile_time_assert_send::(); + test::compile_time_assert_sync::(); + + // Verify `PublicKey` implements `Debug`. + // + // TODO: Test the actual output. + let _: &dyn core::fmt::Debug = &public_key; + + test::compile_time_assert_clone::>(); + test::compile_time_assert_copy::>(); + test::compile_time_assert_sync::>(); + + test::compile_time_assert_clone::>>(); + test::compile_time_assert_sync::>>(); + + let unparsed_public_key = + agreement::UnparsedPublicKey::new(&agreement::X25519, &[0x01, 0x02, 0x03]); + + assert_eq!( + format!("{:?}", unparsed_public_key), + r#"UnparsedPublicKey { algorithm: Algorithm { curve: Curve25519 }, bytes: "010203" }"# + ); + + // Test `AsRef<[u8]>` + assert_eq!(unparsed_public_key.as_ref(), &[0x01, 0x02, 0x03]); +} + +#[test] +fn agreement_agree_ephemeral() { + let rng = rand::SystemRandom::new(); + + test::run(test_file!("agreement_tests.txt"), |section, test_case| { + assert_eq!(section, ""); + + let curve_name = test_case.consume_string("Curve"); + let alg = alg_from_curve_name(&curve_name); + let peer_public = agreement::UnparsedPublicKey::new(alg, test_case.consume_bytes("PeerQ")); + + match test_case.consume_optional_string("Error") { + None => { + let my_private = test_case.consume_bytes("D"); + let my_private = { + #[allow(deprecated)] + let rng = test::rand::FixedSliceRandom { bytes: &my_private }; + agreement::EphemeralPrivateKey::generate(alg, &rng)? + }; + let my_public = test_case.consume_bytes("MyQ"); + let output = test_case.consume_bytes("Output"); + + assert_eq!(my_private.algorithm(), alg); + + let computed_public = my_private.compute_public_key().unwrap(); + assert_eq!(computed_public.as_ref(), &my_public[..]); + + assert_eq!(my_private.algorithm(), alg); + + let result = agreement::agree_ephemeral(my_private, &peer_public, |key_material| { + assert_eq!(key_material, &output[..]); + }); + assert_eq!(result, Ok(())); + } + + Some(_) => { + // In the no-heap mode, some algorithms aren't supported so + // we have to skip those algorithms' test cases. + let dummy_private_key = agreement::EphemeralPrivateKey::generate(alg, &rng)?; + fn kdf_not_called(_: &[u8]) -> Result<(), ()> { + panic!( + "The KDF was called during ECDH when the peer's \ + public key is invalid." + ); + } + assert!(agreement::agree_ephemeral( + dummy_private_key, + &peer_public, + kdf_not_called + ) + .is_err()); + } + } + + Ok(()) + }); +} + +#[test] +fn test_agreement_ecdh_x25519_rfc_iterated() { + let mut k = h("0900000000000000000000000000000000000000000000000000000000000000"); + let mut u = k.clone(); + + fn expect_iterated_x25519( + expected_result: &str, + range: core::ops::Range, + k: &mut Vec, + u: &mut Vec, + ) { + for _ in range { + let new_k = x25519(k, u); + u.clone_from(k); + *k = new_k; + } + assert_eq!(&h(expected_result), k); + } + + expect_iterated_x25519( + "422c8e7a6227d7bca1350b3e2bb7279f7897b87bb6854b783c60e80311ae3079", + 0..1, + &mut k, + &mut u, + ); + expect_iterated_x25519( + "684cf59ba83309552800ef566f2f4d3c1c3887c49360e3875f2eb94d99532c51", + 1..1_000, + &mut k, + &mut u, + ); + + // The spec gives a test vector for 1,000,000 iterations but it takes + // too long to do 1,000,000 iterations by default right now. This + // 10,000 iteration vector is self-computed. + expect_iterated_x25519( + "2c125a20f639d504a7703d2e223c79a79de48c4ee8c23379aa19a62ecd211815", + 1_000..10_000, + &mut k, + &mut u, + ); + + if cfg!(feature = "slow_tests") { + expect_iterated_x25519( + "7c3911e0ab2586fd864497297e575e6f3bc601c0883c30df5f4dd2d24f665424", + 10_000..1_000_000, + &mut k, + &mut u, + ); + } +} + +fn x25519(private_key: &[u8], public_key: &[u8]) -> Vec { + x25519_(private_key, public_key).unwrap() +} + +fn x25519_(private_key: &[u8], public_key: &[u8]) -> Result, error::Unspecified> { + #[allow(deprecated)] + let rng = test::rand::FixedSliceRandom { bytes: private_key }; + let private_key = agreement::EphemeralPrivateKey::generate(&agreement::X25519, &rng)?; + let public_key = agreement::UnparsedPublicKey::new(&agreement::X25519, public_key); + agreement::agree_ephemeral(private_key, &public_key, |agreed_value| { + Vec::from(agreed_value) + }) +} + +fn h(s: &str) -> Vec { + match test::from_hex(s) { + Ok(v) => v, + Err(msg) => { + panic!("{} in {}", msg, s); + } + } +} + +fn alg_from_curve_name(curve_name: &str) -> &'static agreement::Algorithm { + if curve_name == "P-256" { + &agreement::ECDH_P256 + } else if curve_name == "P-384" { + &agreement::ECDH_P384 + } else if curve_name == "X25519" { + &agreement::X25519 + } else { + panic!("Unsupported curve: {}", curve_name); + } +} diff --git a/http/vendor/ring/tests/constant_time_tests.rs b/http/vendor/ring/tests/constant_time_tests.rs new file mode 100644 index 0000000..b8d9ac3 --- /dev/null +++ b/http/vendor/ring/tests/constant_time_tests.rs @@ -0,0 +1,78 @@ +// Copyright 2020 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#![allow(missing_docs)] + +#[allow(deprecated)] +use constant_time::verify_slices_are_equal; +#[allow(deprecated)] +use ring::constant_time; +use ring::{error, rand}; + +#[cfg(all(target_arch = "wasm32", target_os = "unknown"))] +use wasm_bindgen_test::{wasm_bindgen_test as test, wasm_bindgen_test_configure}; + +#[cfg(all(target_arch = "wasm32", target_os = "unknown"))] +wasm_bindgen_test_configure!(run_in_browser); + +// This logic is loosely based on BoringSSL's `TEST(ConstantTimeTest, MemCmp)`. +#[allow(deprecated)] +#[test] +fn test_verify_slices_are_equal() { + let initial: [u8; 256] = rand::generate(&rand::SystemRandom::new()).unwrap().expose(); + + { + let copy = initial; + for len in 0..copy.len() { + // Not equal because the lengths do not match. + assert_eq!( + verify_slices_are_equal(&initial, ©[..len]), + Err(error::Unspecified) + ); + // Equal lengths and equal contents. + assert_eq!( + verify_slices_are_equal(&initial[..len], ©[..len]), + Ok(()) + ); + } + // Equal lengths and equal contents. + assert_eq!(verify_slices_are_equal(&initial, ©), Ok(())); + } + + for i in 0..initial.len() { + for bit in 0..8 { + let mut copy = initial; + copy[i] ^= 1u8 << bit; + + for len in 0..=initial.len() { + // We flipped at least one bit in `copy`. + assert_ne!(&initial[..], ©[..]); + + let a = &initial[..len]; + let b = ©[..len]; + + let expected_result = if i < len { + // The flipped bit is within `b` so `a` and `b` are not equal. + Err(error::Unspecified) + } else { + // The flipped bit is outside of `b` so `a` and `b` are equal. + Ok(()) + }; + assert_eq!(a == b, expected_result.is_ok()); // Sanity check. + assert_eq!(verify_slices_are_equal(a, b), expected_result); + assert_eq!(verify_slices_are_equal(b, a), expected_result); + } + } + } +} diff --git a/http/vendor/ring/tests/digest_tests.rs b/http/vendor/ring/tests/digest_tests.rs new file mode 100644 index 0000000..0a3a824 --- /dev/null +++ b/http/vendor/ring/tests/digest_tests.rs @@ -0,0 +1,137 @@ +// Copyright 2015-2017 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#![allow(missing_docs)] + +use ring::digest; +#[allow(deprecated)] +use ring::{test, test_file}; + +#[cfg(all(target_arch = "wasm32", target_os = "unknown"))] +use wasm_bindgen_test::{wasm_bindgen_test as test, wasm_bindgen_test_configure}; + +#[cfg(all(target_arch = "wasm32", target_os = "unknown"))] +wasm_bindgen_test_configure!(run_in_browser); + +/// Test vectors from BoringSSL, Go, and other sources. +#[test] +fn digest_misc() { + test::run(test_file!("digest_tests.txt"), |section, test_case| { + assert_eq!(section, ""); + let digest_alg = test_case.consume_digest_alg("Hash").unwrap(); + let input = test_case.consume_bytes("Input"); + let repeat = test_case.consume_usize("Repeat"); + let expected = test_case.consume_bytes("Output"); + + let mut ctx = digest::Context::new(digest_alg); + let mut data = Vec::new(); + for _ in 0..repeat { + ctx.update(&input); + data.extend(&input); + } + let actual_from_chunks = ctx.finish(); + assert_eq!(&expected, &actual_from_chunks.as_ref()); + + let actual_from_one_shot = digest::digest(digest_alg, &data); + assert_eq!(&expected, &actual_from_one_shot.as_ref()); + + Ok(()) + }); +} + +/// Test some ways in which `Context::update` and/or `Context::finish` +/// could go wrong by testing every combination of updating three inputs +/// that vary from zero bytes to one byte larger than the block length. +/// +/// These are not run in dev (debug) builds because they are too slow. +macro_rules! test_i_u_f { + ( $test_name:ident, $alg:expr) => { + #[cfg(not(debug_assertions))] + #[test] + fn $test_name() { + let mut input = [0; (digest::MAX_BLOCK_LEN + 1) * 3]; + let max = $alg.block_len() + 1; + for i in 0..(max * 3) { + input[i] = (i & 0xff) as u8; + } + + for i in 0..max { + for j in 0..max { + for k in 0..max { + let part1 = &input[..i]; + let part2 = &input[i..(i + j)]; + let part3 = &input[(i + j)..(i + j + k)]; + + let mut ctx = digest::Context::new(&$alg); + ctx.update(part1); + ctx.update(part2); + ctx.update(part3); + let i_u_f = ctx.finish(); + + let one_shot = digest::digest(&$alg, &input[..(i + j + k)]); + + assert_eq!(i_u_f.as_ref(), one_shot.as_ref()); + } + } + } + } + }; +} +test_i_u_f!(digest_test_i_u_f_sha1, digest::SHA1_FOR_LEGACY_USE_ONLY); +test_i_u_f!(digest_test_i_u_f_sha256, digest::SHA256); +test_i_u_f!(digest_test_i_u_f_sha384, digest::SHA384); +test_i_u_f!(digest_test_i_u_f_sha512, digest::SHA512); + +#[test] +fn test_fmt_algorithm() { + assert_eq!("SHA1", &format!("{:?}", digest::SHA1_FOR_LEGACY_USE_ONLY)); + assert_eq!("SHA256", &format!("{:?}", digest::SHA256)); + assert_eq!("SHA384", &format!("{:?}", digest::SHA384)); + assert_eq!("SHA512", &format!("{:?}", digest::SHA512)); + assert_eq!("SHA512_256", &format!("{:?}", digest::SHA512_256)); +} + +#[test] +fn digest_test_fmt() { + assert_eq!( + "SHA1:b7e23ec29af22b0b4e41da31e868d57226121c84", + &format!( + "{:?}", + digest::digest(&digest::SHA1_FOR_LEGACY_USE_ONLY, b"hello, world") + ) + ); + assert_eq!( + "SHA256:09ca7e4eaa6e8ae9c7d261167129184883644d\ + 07dfba7cbfbc4c8a2e08360d5b", + &format!("{:?}", digest::digest(&digest::SHA256, b"hello, world")) + ); + assert_eq!( + "SHA384:1fcdb6059ce05172a26bbe2a3ccc88ed5a8cd5\ + fc53edfd9053304d429296a6da23b1cd9e5c9ed3bb34f0\ + 0418a70cdb7e", + &format!("{:?}", digest::digest(&digest::SHA384, b"hello, world")) + ); + assert_eq!( + "SHA512:8710339dcb6814d0d9d2290ef422285c9322b7\ + 163951f9a0ca8f883d3305286f44139aa374848e4174f5\ + aada663027e4548637b6d19894aec4fb6c46a139fbf9", + &format!("{:?}", digest::digest(&digest::SHA512, b"hello, world")) + ); + + assert_eq!( + "SHA512_256:11f2c88c04f0a9c3d0970894ad2472505e\ + 0bc6e8c7ec46b5211cd1fa3e253e62", + &format!("{:?}", digest::digest(&digest::SHA512_256, b"hello, world")) + ); +} diff --git a/http/vendor/ring/tests/ecdsa_test_private_key_p256.p8 b/http/vendor/ring/tests/ecdsa_test_private_key_p256.p8 new file mode 100644 index 0000000..bc11884 Binary files /dev/null and b/http/vendor/ring/tests/ecdsa_test_private_key_p256.p8 differ diff --git a/http/vendor/ring/tests/ecdsa_test_public_key_p256.der b/http/vendor/ring/tests/ecdsa_test_public_key_p256.der new file mode 100644 index 0000000..ce3e6d7 --- /dev/null +++ b/http/vendor/ring/tests/ecdsa_test_public_key_p256.der @@ -0,0 +1 @@ +f#eP墳M`*eғP3M?5Y$^[Zzܧk3Y5 . \ No newline at end of file diff --git a/http/vendor/ring/tests/ecdsa_test_public_key_p256_debug.txt b/http/vendor/ring/tests/ecdsa_test_public_key_p256_debug.txt new file mode 100644 index 0000000..b590fc8 --- /dev/null +++ b/http/vendor/ring/tests/ecdsa_test_public_key_p256_debug.txt @@ -0,0 +1 @@ +PublicKey("04fc116698a3e3236550c4c9efa9bd4d0619602a65d2930e9150ab33e84dbc83f8a6a6b9933f35ab59245e5b5a7af5dca76b33cbe7aeee5981b3ca350bebf52ecd") \ No newline at end of file diff --git a/http/vendor/ring/tests/ecdsa_tests.rs b/http/vendor/ring/tests/ecdsa_tests.rs new file mode 100644 index 0000000..83e5abf --- /dev/null +++ b/http/vendor/ring/tests/ecdsa_tests.rs @@ -0,0 +1,321 @@ +// Copyright 2015-2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#![allow(missing_docs)] + +use ring::{ + rand, + signature::{self, KeyPair}, +}; +#[allow(deprecated)] +use ring::{test, test_file}; + +// ECDSA *signing* tests are in src/ec/ecdsa/signing.rs. + +#[test] +fn ecdsa_from_pkcs8_test() { + let rng = rand::SystemRandom::new(); + + test::run( + test_file!("ecdsa_from_pkcs8_tests.txt"), + |section, test_case| { + assert_eq!(section, ""); + + let curve_name = test_case.consume_string("Curve"); + let ((this_fixed, this_asn1), (other_fixed, other_asn1)) = match curve_name.as_str() { + "P-256" => ( + ( + &signature::ECDSA_P256_SHA256_FIXED_SIGNING, + &signature::ECDSA_P256_SHA256_ASN1_SIGNING, + ), + ( + &signature::ECDSA_P384_SHA384_FIXED_SIGNING, + &signature::ECDSA_P384_SHA384_ASN1_SIGNING, + ), + ), + "P-384" => ( + ( + &signature::ECDSA_P384_SHA384_FIXED_SIGNING, + &signature::ECDSA_P384_SHA384_ASN1_SIGNING, + ), + ( + &signature::ECDSA_P256_SHA256_FIXED_SIGNING, + &signature::ECDSA_P256_SHA256_ASN1_SIGNING, + ), + ), + _ => unreachable!(), + }; + + let input = test_case.consume_bytes("Input"); + + let error = test_case.consume_optional_string("Error"); + + match ( + signature::EcdsaKeyPair::from_pkcs8(this_fixed, &input, &rng), + error.clone(), + ) { + (Ok(_), None) => (), + (Err(e), None) => panic!("Failed with error \"{}\", but expected to succeed", e), + (Ok(_), Some(e)) => panic!("Succeeded, but expected error \"{}\"", e), + (Err(actual), Some(expected)) => assert_eq!(format!("{}", actual), expected), + }; + + match ( + signature::EcdsaKeyPair::from_pkcs8(this_asn1, &input, &rng), + error, + ) { + (Ok(_), None) => (), + (Err(e), None) => panic!("Failed with error \"{}\", but expected to succeed", e), + (Ok(_), Some(e)) => panic!("Succeeded, but expected error \"{}\"", e), + (Err(actual), Some(expected)) => assert_eq!(format!("{}", actual), expected), + }; + + assert!(signature::EcdsaKeyPair::from_pkcs8(other_fixed, &input, &rng).is_err()); + assert!(signature::EcdsaKeyPair::from_pkcs8(other_asn1, &input, &rng).is_err()); + + Ok(()) + }, + ); +} + +// Verify that, at least, we generate PKCS#8 documents that we can read. +#[test] +fn ecdsa_generate_pkcs8_test() { + let rng = rand::SystemRandom::new(); + + for alg in &[ + &signature::ECDSA_P256_SHA256_ASN1_SIGNING, + &signature::ECDSA_P256_SHA256_FIXED_SIGNING, + &signature::ECDSA_P384_SHA384_ASN1_SIGNING, + &signature::ECDSA_P384_SHA384_FIXED_SIGNING, + ] { + let pkcs8 = signature::EcdsaKeyPair::generate_pkcs8(alg, &rng).unwrap(); + println!(); + for b in pkcs8.as_ref() { + print!("{:02x}", *b); + } + println!(); + println!(); + + #[cfg(feature = "alloc")] + let _ = signature::EcdsaKeyPair::from_pkcs8(alg, pkcs8.as_ref(), &rng).unwrap(); + } +} + +#[test] +fn signature_ecdsa_verify_asn1_test() { + test::run( + test_file!("ecdsa_verify_asn1_tests.txt"), + |section, test_case| { + assert_eq!(section, ""); + + let curve_name = test_case.consume_string("Curve"); + let digest_name = test_case.consume_string("Digest"); + let msg = test_case.consume_bytes("Msg"); + let public_key = test_case.consume_bytes("Q"); + let sig = test_case.consume_bytes("Sig"); + let is_valid = test_case.consume_string("Result") == "P (0 )"; + + let alg = match (curve_name.as_str(), digest_name.as_str()) { + ("P-256", "SHA256") => &signature::ECDSA_P256_SHA256_ASN1, + ("P-256", "SHA384") => &signature::ECDSA_P256_SHA384_ASN1, + ("P-384", "SHA256") => &signature::ECDSA_P384_SHA256_ASN1, + ("P-384", "SHA384") => &signature::ECDSA_P384_SHA384_ASN1, + _ => { + panic!("Unsupported curve+digest: {}+{}", curve_name, digest_name); + } + }; + + let actual_result = + signature::UnparsedPublicKey::new(alg, &public_key).verify(&msg, &sig); + assert_eq!(actual_result.is_ok(), is_valid); + + Ok(()) + }, + ); +} + +#[test] +fn signature_ecdsa_verify_fixed_test() { + test::run( + test_file!("ecdsa_verify_fixed_tests.txt"), + |section, test_case| { + assert_eq!(section, ""); + + let curve_name = test_case.consume_string("Curve"); + let digest_name = test_case.consume_string("Digest"); + + let msg = test_case.consume_bytes("Msg"); + let public_key = test_case.consume_bytes("Q"); + let sig = test_case.consume_bytes("Sig"); + let expected_result = test_case.consume_string("Result"); + + let alg = match (curve_name.as_str(), digest_name.as_str()) { + ("P-256", "SHA256") => &signature::ECDSA_P256_SHA256_FIXED, + ("P-384", "SHA384") => &signature::ECDSA_P384_SHA384_FIXED, + _ => { + panic!("Unsupported curve+digest: {}+{}", curve_name, digest_name); + } + }; + + let is_valid = expected_result == "P (0 )"; + + let actual_result = + signature::UnparsedPublicKey::new(alg, &public_key).verify(&msg, &sig); + assert_eq!(actual_result.is_ok(), is_valid); + + Ok(()) + }, + ); +} + +#[test] +fn ecdsa_test_public_key_coverage() { + const PRIVATE_KEY: &[u8] = include_bytes!("ecdsa_test_private_key_p256.p8"); + const PUBLIC_KEY: &[u8] = include_bytes!("ecdsa_test_public_key_p256.der"); + const PUBLIC_KEY_DEBUG: &str = include_str!("ecdsa_test_public_key_p256_debug.txt"); + + let rng = rand::SystemRandom::new(); + let key_pair = signature::EcdsaKeyPair::from_pkcs8( + &signature::ECDSA_P256_SHA256_FIXED_SIGNING, + PRIVATE_KEY, + &rng, + ) + .unwrap(); + + // Test `AsRef<[u8]>` + assert_eq!(key_pair.public_key().as_ref(), PUBLIC_KEY); + + // Test `Clone`. + #[allow(clippy::clone_on_copy, clippy::redundant_clone)] + let _: ::PublicKey = key_pair.public_key().clone(); + + // Test `Copy`. + let _: ::PublicKey = *key_pair.public_key(); + + // Test `Debug`. + assert_eq!(PUBLIC_KEY_DEBUG, format!("{:?}", key_pair.public_key())); + assert_eq!( + format!("EcdsaKeyPair {{ public_key: {:?} }}", key_pair.public_key()), + format!("{:?}", key_pair) + ); +} + +// This test is not a known-answer test, though it re-uses the known-answer +// test vectors. Because the nonce is randomized, the signature will be +// different each time. Because of that, here we simply verify that the +// signature verifies correctly. The known-answer tests themselves are in +// ecsda/signing.rs. +#[test] +fn signature_ecdsa_sign_fixed_sign_and_verify_test() { + let rng = rand::SystemRandom::new(); + + test::run( + test_file!("../src/ec/suite_b/ecdsa/ecdsa_sign_fixed_tests.txt"), + |section, test_case| { + assert_eq!(section, ""); + + let curve_name = test_case.consume_string("Curve"); + let digest_name = test_case.consume_string("Digest"); + + let msg = test_case.consume_bytes("Msg"); + let d = test_case.consume_bytes("d"); + let q = test_case.consume_bytes("Q"); + + // Ignored since the actual signature will use a randomized nonce. + let _k = test_case.consume_bytes("k"); + let _expected_result = test_case.consume_bytes("Sig"); + + let (signing_alg, verification_alg) = match (curve_name.as_str(), digest_name.as_str()) + { + ("P-256", "SHA256") => ( + &signature::ECDSA_P256_SHA256_FIXED_SIGNING, + &signature::ECDSA_P256_SHA256_FIXED, + ), + ("P-384", "SHA384") => ( + &signature::ECDSA_P384_SHA384_FIXED_SIGNING, + &signature::ECDSA_P384_SHA384_FIXED, + ), + _ => { + panic!("Unsupported curve+digest: {}+{}", curve_name, digest_name); + } + }; + + let private_key = + signature::EcdsaKeyPair::from_private_key_and_public_key(signing_alg, &d, &q, &rng) + .unwrap(); + + let signature = private_key.sign(&rng, &msg).unwrap(); + + let public_key = signature::UnparsedPublicKey::new(verification_alg, q); + assert_eq!(public_key.verify(&msg, signature.as_ref()), Ok(())); + + Ok(()) + }, + ); +} + +// This test is not a known-answer test, though it re-uses the known-answer +// test vectors. Because the nonce is randomized, the signature will be +// different each time. Because of that, here we simply verify that the +// signature verifies correctly. The known-answer tests themselves are in +// ecsda/signing.rs. +#[test] +fn signature_ecdsa_sign_asn1_test() { + let rng = rand::SystemRandom::new(); + + test::run( + test_file!("../src/ec/suite_b/ecdsa/ecdsa_sign_asn1_tests.txt"), + |section, test_case| { + assert_eq!(section, ""); + + let curve_name = test_case.consume_string("Curve"); + let digest_name = test_case.consume_string("Digest"); + + let msg = test_case.consume_bytes("Msg"); + let d = test_case.consume_bytes("d"); + let q = test_case.consume_bytes("Q"); + + // Ignored since the actual signature will use a randomized nonce. + let _k = test_case.consume_bytes("k"); + let _expected_result = test_case.consume_bytes("Sig"); + + let (signing_alg, verification_alg) = match (curve_name.as_str(), digest_name.as_str()) + { + ("P-256", "SHA256") => ( + &signature::ECDSA_P256_SHA256_ASN1_SIGNING, + &signature::ECDSA_P256_SHA256_ASN1, + ), + ("P-384", "SHA384") => ( + &signature::ECDSA_P384_SHA384_ASN1_SIGNING, + &signature::ECDSA_P384_SHA384_ASN1, + ), + _ => { + panic!("Unsupported curve+digest: {}+{}", curve_name, digest_name); + } + }; + + let private_key = + signature::EcdsaKeyPair::from_private_key_and_public_key(signing_alg, &d, &q, &rng) + .unwrap(); + + let signature = private_key.sign(&rng, &msg).unwrap(); + + let public_key = signature::UnparsedPublicKey::new(verification_alg, q); + assert_eq!(public_key.verify(&msg, signature.as_ref()), Ok(())); + + Ok(()) + }, + ); +} diff --git a/http/vendor/ring/tests/ed25519_test_private_key.bin b/http/vendor/ring/tests/ed25519_test_private_key.bin new file mode 100644 index 0000000..afd7169 --- /dev/null +++ b/http/vendor/ring/tests/ed25519_test_private_key.bin @@ -0,0 +1 @@ +aZ`J,DIi{2ip;` \ No newline at end of file diff --git a/http/vendor/ring/tests/ed25519_test_private_key.p8 b/http/vendor/ring/tests/ed25519_test_private_key.p8 new file mode 100644 index 0000000..fc90176 Binary files /dev/null and b/http/vendor/ring/tests/ed25519_test_private_key.p8 differ diff --git a/http/vendor/ring/tests/ed25519_test_public_key.bin b/http/vendor/ring/tests/ed25519_test_public_key.bin new file mode 100644 index 0000000..9ed9163 --- /dev/null +++ b/http/vendor/ring/tests/ed25519_test_public_key.bin @@ -0,0 +1,2 @@ +Z +Kd:rڦ#%hQ \ No newline at end of file diff --git a/http/vendor/ring/tests/ed25519_test_public_key.der b/http/vendor/ring/tests/ed25519_test_public_key.der new file mode 100644 index 0000000..0ac2bd5 --- /dev/null +++ b/http/vendor/ring/tests/ed25519_test_public_key.der @@ -0,0 +1 @@ +X X~WX5ök} \ No newline at end of file diff --git a/http/vendor/ring/tests/ed25519_tests.rs b/http/vendor/ring/tests/ed25519_tests.rs new file mode 100644 index 0000000..65afc94 --- /dev/null +++ b/http/vendor/ring/tests/ed25519_tests.rs @@ -0,0 +1,236 @@ +// Copyright 2015-2017 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#![allow(missing_docs)] + +use ring::{ + error, rand, + signature::{self, Ed25519KeyPair, KeyPair}, +}; +#[allow(deprecated)] +use ring::{test, test_file}; + +#[cfg(all(target_arch = "wasm32", target_os = "unknown"))] +use wasm_bindgen_test::{wasm_bindgen_test as test, wasm_bindgen_test_configure}; + +#[cfg(all(target_arch = "wasm32", target_os = "unknown"))] +wasm_bindgen_test_configure!(run_in_browser); + +/// Test vectors from BoringSSL. +#[test] +fn test_signature_ed25519() { + test::run(test_file!("ed25519_tests.txt"), |section, test_case| { + assert_eq!(section, ""); + let seed = test_case.consume_bytes("SEED"); + assert_eq!(32, seed.len()); + + let public_key = test_case.consume_bytes("PUB"); + assert_eq!(32, public_key.len()); + + let msg = test_case.consume_bytes("MESSAGE"); + + let expected_sig = test_case.consume_bytes("SIG"); + + { + let key_pair = Ed25519KeyPair::from_seed_and_public_key(&seed, &public_key).unwrap(); + let actual_sig = key_pair.sign(&msg); + assert_eq!(&expected_sig[..], actual_sig.as_ref()); + } + + // Test PKCS#8 generation, parsing, and private-to-public calculations. + #[allow(deprecated)] + let rng = test::rand::FixedSliceRandom { bytes: &seed }; + let pkcs8 = Ed25519KeyPair::generate_pkcs8(&rng).unwrap(); + let key_pair = Ed25519KeyPair::from_pkcs8(pkcs8.as_ref()).unwrap(); + assert_eq!(public_key, key_pair.public_key().as_ref()); + + // Test Signature generation. + let actual_sig = key_pair.sign(&msg); + assert_eq!(&expected_sig[..], actual_sig.as_ref()); + + // Test Signature verification. + test_signature_verification(&public_key, &msg, &expected_sig, Ok(())); + + let mut tampered_sig = expected_sig; + tampered_sig[0] ^= 1; + + test_signature_verification(&public_key, &msg, &tampered_sig, Err(error::Unspecified)); + + Ok(()) + }); +} + +/// Test vectors from BoringSSL. +#[test] +fn test_signature_ed25519_verify() { + test::run( + test_file!("ed25519_verify_tests.txt"), + |section, test_case| { + assert_eq!(section, ""); + + let public_key = test_case.consume_bytes("PUB"); + let msg = test_case.consume_bytes("MESSAGE"); + let sig = test_case.consume_bytes("SIG"); + let expected_result = match test_case.consume_string("Result").as_str() { + "P" => Ok(()), + "F" => Err(error::Unspecified), + s => panic!("{:?} is not a valid result", s), + }; + test_signature_verification(&public_key, &msg, &sig, expected_result); + Ok(()) + }, + ); +} + +fn test_signature_verification( + public_key: &[u8], + msg: &[u8], + sig: &[u8], + expected_result: Result<(), error::Unspecified>, +) { + assert_eq!( + expected_result, + signature::UnparsedPublicKey::new(&signature::ED25519, public_key).verify(msg, sig) + ); +} + +#[test] +fn test_ed25519_from_seed_and_public_key_misuse() { + const PRIVATE_KEY: &[u8] = include_bytes!("ed25519_test_private_key.bin"); + const PUBLIC_KEY: &[u8] = include_bytes!("ed25519_test_public_key.bin"); + + assert!(Ed25519KeyPair::from_seed_and_public_key(PRIVATE_KEY, PUBLIC_KEY).is_ok()); + + // Truncated private key. + assert!(Ed25519KeyPair::from_seed_and_public_key(&PRIVATE_KEY[..31], PUBLIC_KEY).is_err()); + + // Truncated public key. + assert!(Ed25519KeyPair::from_seed_and_public_key(PRIVATE_KEY, &PUBLIC_KEY[..31]).is_err()); + + // Swapped public and private key. + assert!(Ed25519KeyPair::from_seed_and_public_key(PUBLIC_KEY, PRIVATE_KEY).is_err()); +} + +enum FromPkcs8Variant { + Checked, + MaybeUnchecked, +} + +#[test] +fn test_ed25519_from_pkcs8_unchecked() { + test_ed25519_from_pkcs8_( + FromPkcs8Variant::MaybeUnchecked, + Ed25519KeyPair::from_pkcs8_maybe_unchecked, + ) +} + +#[test] +fn test_ed25519_from_pkcs8() { + test_ed25519_from_pkcs8_(FromPkcs8Variant::Checked, Ed25519KeyPair::from_pkcs8) +} + +fn test_ed25519_from_pkcs8_( + variant: FromPkcs8Variant, + f: impl Fn(&[u8]) -> Result, +) { + // Just test that we can parse the input. + test::run( + test_file!("ed25519_from_pkcs8_tests.txt"), + |section, test_case| { + assert_eq!(section, ""); + let input = test_case.consume_bytes("Input"); + let expected_error = { + let expected_checked = test_case.consume_string("Result-Checked"); + let expected_maybe_unchecked = test_case.consume_string("Result-Maybe-Unchecked"); + let expected_result = match variant { + FromPkcs8Variant::Checked => expected_checked, + FromPkcs8Variant::MaybeUnchecked => expected_maybe_unchecked, + }; + if expected_result == "OK" { + None + } else { + Some(expected_result) + } + }; + let expected_public = { + let expected_if_no_error = test_case.consume_optional_bytes("Public"); + if expected_error.is_none() { + Some(expected_if_no_error.unwrap()) + } else { + None + } + }; + + match f(&input) { + Ok(keypair) => { + assert_eq!(expected_error, None); + assert_eq!( + expected_public.as_deref(), + Some(keypair.public_key().as_ref()) + ); + } + Err(actual_error) => { + assert_eq!(expected_error, Some(format!("{}", actual_error))); + assert_eq!(expected_public, None); + } + } + + Ok(()) + }, + ); +} + +#[test] +fn ed25519_test_generate_pkcs8() { + let rng = rand::SystemRandom::new(); + let generated = Ed25519KeyPair::generate_pkcs8(&rng).unwrap(); + let generated = generated.as_ref(); + + let _ronudtripped = Ed25519KeyPair::from_pkcs8(generated).unwrap(); + + // Regression test: Verify we're generating the correct encoding, as + // `Ed25519KeyPair::from_pkcs8` also accepts our old wrong encoding. + assert_eq!(generated.len(), 19 + 32 + 32); + assert_eq!(&generated[..2], &[0x30, 0x51]); +} + +#[test] +fn ed25519_test_public_key_coverage() { + const PRIVATE_KEY: &[u8] = include_bytes!("ed25519_test_private_key.p8"); + const PUBLIC_KEY: &[u8] = include_bytes!("ed25519_test_public_key.der"); + const PUBLIC_KEY_DEBUG: &str = + "PublicKey(\"5809e9fef6dcec58f0f2e3b0d67e9880a11957e083ace85835c3b6c8fbaf6b7d\")"; + + let key_pair = Ed25519KeyPair::from_pkcs8(PRIVATE_KEY).unwrap(); + + // Test `AsRef<[u8]>` + assert_eq!(key_pair.public_key().as_ref(), PUBLIC_KEY); + + // Test `Clone`. + #[allow(clippy::clone_on_copy)] + let _: ::PublicKey = key_pair.public_key().clone(); + + // Test `Copy`. + let _: ::PublicKey = *key_pair.public_key(); + + // Test `Debug`. + assert_eq!(PUBLIC_KEY_DEBUG, format!("{:?}", key_pair.public_key())); + assert_eq!( + format!( + "Ed25519KeyPair {{ public_key: {:?} }}", + key_pair.public_key() + ), + format!("{:?}", key_pair) + ); +} diff --git a/http/vendor/ring/tests/error_tests.rs b/http/vendor/ring/tests/error_tests.rs new file mode 100644 index 0000000..0152b70 --- /dev/null +++ b/http/vendor/ring/tests/error_tests.rs @@ -0,0 +1,12 @@ +#![allow(missing_docs)] + +#[cfg(feature = "std")] +#[test] +fn error_impl_std_error_error_test() { + use ring::error; + #[allow(deprecated)] + use ring::test; + + test::compile_time_assert_std_error_error::(); + test::compile_time_assert_std_error_error::(); +} diff --git a/http/vendor/ring/tests/hkdf_tests.rs b/http/vendor/ring/tests/hkdf_tests.rs new file mode 100644 index 0000000..64f664b --- /dev/null +++ b/http/vendor/ring/tests/hkdf_tests.rs @@ -0,0 +1,131 @@ +// Copyright 2015 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#![allow(missing_docs)] + +use ring::{digest, error, hkdf}; +#[allow(deprecated)] +use ring::{test, test_file}; + +#[cfg(all(target_arch = "wasm32", target_os = "unknown"))] +use wasm_bindgen_test::{wasm_bindgen_test as test, wasm_bindgen_test_configure}; + +#[cfg(all(target_arch = "wasm32", target_os = "unknown"))] +wasm_bindgen_test_configure!(run_in_browser); + +#[test] +fn hkdf_tests() { + test::run(test_file!("hkdf_tests.txt"), |section, test_case| { + assert_eq!(section, ""); + let alg = { + let digest_alg = test_case + .consume_digest_alg("Hash") + .ok_or(error::Unspecified)?; + if digest_alg == &digest::SHA256 { + hkdf::HKDF_SHA256 + } else { + // TODO: add test vectors for other algorithms + panic!("unsupported algorithm: {:?}", digest_alg); + } + }; + let secret = test_case.consume_bytes("IKM"); + let salt = test_case.consume_bytes("salt"); + let info = test_case.consume_bytes("info"); + let _ = test_case.consume_bytes("PRK"); + let expected_out = test_case.consume_bytes("OKM"); + + let salt = hkdf::Salt::new(alg, &salt); + + // TODO: test multi-part info, especially with empty parts. + let My(out) = salt + .extract(&secret) + .expand(&[&info], My(expected_out.len())) + .unwrap() + .into(); + assert_eq!(out, expected_out); + + Ok(()) + }); +} + +#[test] +fn hkdf_output_len_tests() { + for &alg in &[hkdf::HKDF_SHA256, hkdf::HKDF_SHA384, hkdf::HKDF_SHA512] { + const MAX_BLOCKS: usize = 255; + + let salt = hkdf::Salt::new(alg, &[]); + let prk = salt.extract(&[]); // TODO: enforce minimum length. + + { + // Test zero length. + let okm = prk.expand(&[b"info"], My(0)).unwrap(); + let result: My> = okm.into(); + assert_eq!(&result.0, &[]); + } + + let max_out_len = MAX_BLOCKS * alg.hmac_algorithm().digest_algorithm().output_len(); + + { + // Test maximum length output succeeds. + let okm = prk.expand(&[b"info"], My(max_out_len)).unwrap(); + let result: My> = okm.into(); + assert_eq!(result.0.len(), max_out_len); + } + + { + // Test too-large output fails. + assert!(prk.expand(&[b"info"], My(max_out_len + 1)).is_err()); + } + + { + // Test length mismatch (smaller). + let okm = prk.expand(&[b"info"], My(2)).unwrap(); + let mut buf = [0u8; 1]; + assert_eq!(okm.fill(&mut buf), Err(error::Unspecified)); + } + + { + // Test length mismatch (larger). + let okm = prk.expand(&[b"info"], My(2)).unwrap(); + let mut buf = [0u8; 3]; + assert_eq!(okm.fill(&mut buf), Err(error::Unspecified)); + } + + { + // Control for above two tests. + let okm = prk.expand(&[b"info"], My(2)).unwrap(); + let mut buf = [0u8; 2]; + assert_eq!(okm.fill(&mut buf), Ok(())); + } + } +} + +/// Generic newtype wrapper that lets us implement traits for externally-defined +/// types. +#[derive(Debug, PartialEq)] +struct My(T); + +impl hkdf::KeyType for My { + fn len(&self) -> usize { + self.0 + } +} + +impl From>> for My> { + fn from(okm: hkdf::Okm>) -> Self { + let mut r = vec![0u8; okm.len().0]; + okm.fill(&mut r).unwrap(); + Self(r) + } +} diff --git a/http/vendor/ring/tests/hmac_tests.rs b/http/vendor/ring/tests/hmac_tests.rs new file mode 100644 index 0000000..4a56f30 --- /dev/null +++ b/http/vendor/ring/tests/hmac_tests.rs @@ -0,0 +1,113 @@ +// Copyright 2015-2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#![allow(missing_docs)] + +use ring::{digest, hmac}; +#[allow(deprecated)] +use ring::{test, test_file}; + +#[cfg(all(target_arch = "wasm32", target_os = "unknown"))] +use wasm_bindgen_test::{wasm_bindgen_test as test, wasm_bindgen_test_configure}; + +#[cfg(all(target_arch = "wasm32", target_os = "unknown"))] +wasm_bindgen_test_configure!(run_in_browser); + +#[test] +fn hmac_tests() { + test::run(test_file!("hmac_tests.txt"), |section, test_case| { + assert_eq!(section, ""); + let digest_alg = test_case.consume_digest_alg("HMAC"); + let key_value = test_case.consume_bytes("Key"); + let mut input = test_case.consume_bytes("Input"); + let output = test_case.consume_bytes("Output"); + + let algorithm = { + let digest_alg = match digest_alg { + Some(digest_alg) => digest_alg, + None => { + return Ok(()); + } // Unsupported digest algorithm + }; + if digest_alg == &digest::SHA1_FOR_LEGACY_USE_ONLY { + hmac::HMAC_SHA1_FOR_LEGACY_USE_ONLY + } else if digest_alg == &digest::SHA256 { + hmac::HMAC_SHA256 + } else if digest_alg == &digest::SHA384 { + hmac::HMAC_SHA384 + } else if digest_alg == &digest::SHA512 { + hmac::HMAC_SHA512 + } else { + unreachable!() + } + }; + + hmac_test_case_inner(algorithm, &key_value[..], &input[..], &output[..], true); + + // Tamper with the input and check that verification fails. + if input.is_empty() { + input.push(0); + } else { + input[0] ^= 1; + } + + hmac_test_case_inner(algorithm, &key_value[..], &input[..], &output[..], false); + + Ok(()) + }); +} + +fn hmac_test_case_inner( + algorithm: hmac::Algorithm, + key_value: &[u8], + input: &[u8], + output: &[u8], + is_ok: bool, +) { + let key = hmac::Key::new(algorithm, key_value); + + // One-shot API. + { + let signature = hmac::sign(&key, input); + assert_eq!(is_ok, signature.as_ref() == output); + assert_eq!(is_ok, hmac::verify(&key, input, output).is_ok()); + } + + // Multi-part API, one single part. + { + let mut s_ctx = hmac::Context::with_key(&key); + s_ctx.update(input); + let signature = s_ctx.sign(); + assert_eq!(is_ok, signature.as_ref() == output); + } + + // Multi-part API, byte by byte. + { + let mut ctx = hmac::Context::with_key(&key); + for b in input { + ctx.update(&[*b]); + } + let signature = ctx.sign(); + assert_eq!(is_ok, signature.as_ref() == output); + } +} + +#[test] +fn hmac_debug() { + let key = hmac::Key::new(hmac::HMAC_SHA256, &[0; 32]); + assert_eq!("Key { algorithm: SHA256 }", format!("{:?}", &key)); + + let ctx = hmac::Context::with_key(&key); + assert_eq!("Context { algorithm: SHA256 }", format!("{:?}", &ctx)); +} diff --git a/http/vendor/ring/tests/pbkdf2_tests.rs b/http/vendor/ring/tests/pbkdf2_tests.rs new file mode 100644 index 0000000..a78506e --- /dev/null +++ b/http/vendor/ring/tests/pbkdf2_tests.rs @@ -0,0 +1,72 @@ +// Copyright 2015-2017 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#![allow(missing_docs)] + +use core::num::NonZeroU32; +use ring::{digest, error, pbkdf2}; +#[allow(deprecated)] +use ring::{test, test_file}; + +#[cfg(all(target_arch = "wasm32", target_os = "unknown"))] +use wasm_bindgen_test::{wasm_bindgen_test as test, wasm_bindgen_test_configure}; + +#[cfg(all(target_arch = "wasm32", target_os = "unknown"))] +wasm_bindgen_test_configure!(run_in_browser); + +/// Test vectors from BoringSSL, Go, and other sources. +#[test] +pub fn pbkdf2_tests() { + test::run(test_file!("pbkdf2_tests.txt"), |section, test_case| { + assert_eq!(section, ""); + let algorithm = { + let digest_alg = test_case.consume_digest_alg("Hash").unwrap(); + if digest_alg == &digest::SHA1_FOR_LEGACY_USE_ONLY { + pbkdf2::PBKDF2_HMAC_SHA1 + } else if digest_alg == &digest::SHA256 { + pbkdf2::PBKDF2_HMAC_SHA256 + } else if digest_alg == &digest::SHA384 { + pbkdf2::PBKDF2_HMAC_SHA384 + } else if digest_alg == &digest::SHA512 { + pbkdf2::PBKDF2_HMAC_SHA512 + } else { + unreachable!() + } + }; + let iterations: u32 = test_case.consume_usize("c").try_into().unwrap(); + let iterations: NonZeroU32 = iterations.try_into().unwrap(); + let secret = test_case.consume_bytes("P"); + let salt = test_case.consume_bytes("S"); + let dk = test_case.consume_bytes("DK"); + let verify_expected_result = test_case.consume_string("Verify"); + let verify_expected_result = match verify_expected_result.as_str() { + "OK" => Ok(()), + "Err" => Err(error::Unspecified), + _ => panic!("Unsupported value of \"Verify\""), + }; + + { + let mut out = vec![0u8; dk.len()]; + pbkdf2::derive(algorithm, iterations, &salt, &secret, &mut out); + assert_eq!(dk == out, verify_expected_result.is_ok() || dk.is_empty()); + } + + assert_eq!( + pbkdf2::verify(algorithm, iterations, &salt, &secret, &dk), + verify_expected_result + ); + + Ok(()) + }); +} diff --git a/http/vendor/ring/tests/quic_tests.rs b/http/vendor/ring/tests/quic_tests.rs new file mode 100644 index 0000000..dae3033 --- /dev/null +++ b/http/vendor/ring/tests/quic_tests.rs @@ -0,0 +1,87 @@ +// Copyright 2018 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#![allow(missing_docs)] + +use ring::aead::quic; +#[allow(deprecated)] +use ring::{test, test_file}; + +#[test] +fn quic_aes_128() { + test_quic(&quic::AES_128, test_file!("quic_aes_128_tests.txt")); +} + +#[test] +fn quic_aes_256() { + test_quic(&quic::AES_256, test_file!("quic_aes_256_tests.txt")); +} + +#[test] +fn quic_chacha20() { + test_quic(&quic::CHACHA20, test_file!("quic_chacha20_tests.txt")); +} + +fn test_quic(alg: &'static quic::Algorithm, test_file: test::File) { + test_key_len(alg); + test_sample_len(alg); + + test::run(test_file, |section, test_case| { + assert_eq!(section, ""); + let key_bytes = test_case.consume_bytes("KEY"); + let sample = test_case.consume_bytes("SAMPLE"); + let mask = test_case.consume_bytes("MASK"); + + let key = quic::HeaderProtectionKey::new(alg, &key_bytes)?; + + assert_eq!(mask.as_ref(), key.new_mask(&sample)?); + + Ok(()) + }); +} + +#[allow(clippy::range_plus_one)] +fn test_key_len(alg: &'static quic::Algorithm) { + let key_len = alg.key_len(); + let key_data = vec![0u8; key_len + 1]; + + assert!(quic::HeaderProtectionKey::new(alg, &[]).is_err()); + assert!(quic::HeaderProtectionKey::new(alg, &key_data[..key_len]).is_ok()); + assert!(quic::HeaderProtectionKey::new(alg, &key_data[..(key_len + 1)]).is_err()); + assert!(quic::HeaderProtectionKey::new(alg, &key_data[..(key_len - 1)]).is_err()); +} + +#[allow(clippy::range_plus_one)] +fn test_sample_len(alg: &'static quic::Algorithm) { + let key_len = alg.key_len(); + let key_data = vec![0u8; key_len]; + + let key = quic::HeaderProtectionKey::new(alg, &key_data).unwrap(); + + let sample_len = alg.sample_len(); + assert_eq!(sample_len, 16); // For all currently-implemented algorithms + let sample_data = vec![0u8; sample_len + 2]; + + // Sample is the right size. + assert!(key.new_mask(&sample_data[..sample_len]).is_ok()); + + // Sample is one byte too small. + assert!(key.new_mask(&sample_data[..(sample_len - 1)]).is_err()); + + // Sample is one byte too big. + assert!(key.new_mask(&sample_data[..(sample_len + 1)]).is_err()); + + // Sample is empty. + assert!(key.new_mask(&[]).is_err()); +} diff --git a/http/vendor/ring/tests/rand_tests.rs b/http/vendor/ring/tests/rand_tests.rs new file mode 100644 index 0000000..9196536 --- /dev/null +++ b/http/vendor/ring/tests/rand_tests.rs @@ -0,0 +1,79 @@ +// Copyright 2015-2019 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#![allow(missing_docs)] + +use ring::rand::{self, SecureRandom as _}; +#[allow(deprecated)] +use ring::test; + +#[cfg(all(target_arch = "wasm32", target_os = "unknown"))] +use wasm_bindgen_test::{wasm_bindgen_test as test, wasm_bindgen_test_configure}; + +#[cfg(all(target_arch = "wasm32", target_os = "unknown"))] +wasm_bindgen_test_configure!(run_in_browser); + +#[test] +fn test_system_random_lengths() { + const LINUX_LIMIT: usize = 256; + const WEB_LIMIT: usize = 65536; + + // Test that `fill` succeeds for various interesting lengths. `256` and + // multiples thereof are interesting because that's an edge case for + // `getrandom` on Linux. + let lengths = [ + 0, + 1, + 2, + 3, + 96, + LINUX_LIMIT - 1, + LINUX_LIMIT, + LINUX_LIMIT + 1, + LINUX_LIMIT * 2, + 511, + 512, + 513, + 4096, + WEB_LIMIT - 1, + WEB_LIMIT, + WEB_LIMIT + 1, + WEB_LIMIT * 2, + ]; + + for len in lengths.iter() { + let mut buf = vec![0; *len]; + + let rng = rand::SystemRandom::new(); + assert!(rng.fill(&mut buf).is_ok()); + + // If `len` < 96 then there's a big chance of false positives, but + // otherwise the likelihood of a false positive is so too low to + // worry about. + if *len >= 96 { + assert!(buf.iter().any(|x| *x != 0)); + } + } +} + +#[test] +fn test_system_random_traits() { + test::compile_time_assert_clone::(); + test::compile_time_assert_send::(); + + assert_eq!( + "SystemRandom(())", + format!("{:?}", rand::SystemRandom::new()) + ); +} diff --git a/http/vendor/ring/tests/rsa_test_private_key_2048.p8 b/http/vendor/ring/tests/rsa_test_private_key_2048.p8 new file mode 100644 index 0000000..26c480b Binary files /dev/null and b/http/vendor/ring/tests/rsa_test_private_key_2048.p8 differ diff --git a/http/vendor/ring/tests/rsa_test_public_key_2048.der b/http/vendor/ring/tests/rsa_test_public_key_2048.der new file mode 100644 index 0000000..47f18a7 Binary files /dev/null and b/http/vendor/ring/tests/rsa_test_public_key_2048.der differ diff --git a/http/vendor/ring/tests/rsa_test_public_key_2048_debug.txt b/http/vendor/ring/tests/rsa_test_public_key_2048_debug.txt new file mode 100644 index 0000000..659d6ee --- /dev/null +++ b/http/vendor/ring/tests/rsa_test_public_key_2048_debug.txt @@ -0,0 +1 @@ +PublicKey("3082010a0282010100c8a78500a5a250db8ed36c85b8dcf83c4be1953114faaac7616e0ea24922fa6b7ab01f85582c815cc3bdeb5ed46762bc536accaa8b72705b00cef316b2ec508fb9697241b9e34238419cccf7339eeb8b062147af4f5932f613d9bc0ae70bf6d56d4432e83e13767587531bfa9dd56531741244be75e8bc9226b9fa44b4b8a101358d7e8bb75d0c724a4f11ece77776263faefe79612eb1d71646e77e8982866be1400eafc3580d3139b41aaa7380187372f22e35bd55b288496165c881ed154d5811245c52d56cc09d4916d4f2a50bcf5ae0a2637f4cfa6bf9daafc113dba8383b6dd7da6dd8db22d8510a8d3115983308909a1a0332517aa55e896e154249b30203010001") \ No newline at end of file diff --git a/http/vendor/ring/tests/rsa_test_public_modulus.bin b/http/vendor/ring/tests/rsa_test_public_modulus.bin new file mode 100644 index 0000000..1f473ee Binary files /dev/null and b/http/vendor/ring/tests/rsa_test_public_modulus.bin differ diff --git a/http/vendor/ring/tests/rsa_tests.rs b/http/vendor/ring/tests/rsa_tests.rs new file mode 100644 index 0000000..835fc85 --- /dev/null +++ b/http/vendor/ring/tests/rsa_tests.rs @@ -0,0 +1,348 @@ +// Copyright 2017 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#![allow(missing_docs)] +#![cfg(feature = "alloc")] + +use ring::{ + error, + io::der, + rand, rsa, + signature::{self, KeyPair}, +}; +#[allow(deprecated)] +use ring::{test, test_file}; + +#[cfg(all(target_arch = "wasm32", target_os = "unknown"))] +use wasm_bindgen_test::{wasm_bindgen_test as test, wasm_bindgen_test_configure}; + +#[cfg(all(target_arch = "wasm32", target_os = "unknown"))] +wasm_bindgen_test_configure!(run_in_browser); + +#[test] +fn rsa_from_pkcs8_test() { + test::run( + test_file!("rsa_from_pkcs8_tests.txt"), + |section, test_case| { + assert_eq!(section, ""); + + let input = test_case.consume_bytes("Input"); + let error = test_case.consume_optional_string("Error"); + + match (rsa::KeyPair::from_pkcs8(&input), error) { + (Ok(_), None) => {} + (Err(e), None) => panic!("Failed with error \"{}\", but expected to succeed", e), + (Ok(_), Some(e)) => panic!("Succeeded, but expected error \"{}\"", e), + (Err(actual), Some(expected)) => assert_eq!(format!("{}", actual), expected), + }; + + Ok(()) + }, + ); +} + +#[cfg(feature = "alloc")] +#[test] +fn test_signature_rsa_pkcs1_sign() { + let rng = rand::SystemRandom::new(); + test::run( + test_file!("rsa_pkcs1_sign_tests.txt"), + |section, test_case| { + assert_eq!(section, ""); + + let digest_name = test_case.consume_string("Digest"); + let alg = match digest_name.as_ref() { + "SHA256" => &signature::RSA_PKCS1_SHA256, + "SHA384" => &signature::RSA_PKCS1_SHA384, + "SHA512" => &signature::RSA_PKCS1_SHA512, + _ => panic!("Unsupported digest: {}", digest_name), + }; + + let private_key = test_case.consume_bytes("Key"); + let msg = test_case.consume_bytes("Msg"); + let expected = test_case.consume_bytes("Sig"); + let result = test_case.consume_string("Result"); + + let key_pair = rsa::KeyPair::from_der(&private_key); + if result == "Fail-Invalid-Key" { + assert!(key_pair.is_err()); + return Ok(()); + } + let key_pair = key_pair.unwrap(); + + // XXX: This test is too slow on Android ARM Travis CI builds. + // TODO: re-enable these tests on Android ARM. + let mut actual = vec![0u8; key_pair.public().modulus_len()]; + key_pair + .sign(alg, &rng, &msg, actual.as_mut_slice()) + .unwrap(); + assert_eq!(actual.as_slice() == &expected[..], result == "Pass"); + Ok(()) + }, + ); +} + +#[cfg(feature = "alloc")] +#[test] +fn test_signature_rsa_pss_sign() { + test::run( + test_file!("rsa_pss_sign_tests.txt"), + |section, test_case| { + assert_eq!(section, ""); + + let digest_name = test_case.consume_string("Digest"); + let alg = match digest_name.as_ref() { + "SHA256" => &signature::RSA_PSS_SHA256, + "SHA384" => &signature::RSA_PSS_SHA384, + "SHA512" => &signature::RSA_PSS_SHA512, + _ => panic!("Unsupported digest: {}", digest_name), + }; + + let result = test_case.consume_string("Result"); + let private_key = test_case.consume_bytes("Key"); + let key_pair = rsa::KeyPair::from_der(&private_key); + if key_pair.is_err() && result == "Fail-Invalid-Key" { + return Ok(()); + } + let key_pair = key_pair.unwrap(); + let msg = test_case.consume_bytes("Msg"); + let salt = test_case.consume_bytes("Salt"); + let expected = test_case.consume_bytes("Sig"); + + #[allow(deprecated)] + let rng = test::rand::FixedSliceRandom { bytes: &salt }; + + let mut actual = vec![0u8; key_pair.public().modulus_len()]; + key_pair.sign(alg, &rng, &msg, actual.as_mut_slice())?; + assert_eq!(actual.as_slice() == &expected[..], result == "Pass"); + Ok(()) + }, + ); +} + +// `KeyPair::sign` requires that the output buffer is the same length as +// the public key modulus. Test what happens when it isn't the same length. +#[test] +fn test_signature_rsa_pkcs1_sign_output_buffer_len() { + // Sign the message "hello, world", using PKCS#1 v1.5 padding and the + // SHA256 digest algorithm. + const MESSAGE: &[u8] = b"hello, world"; + let rng = rand::SystemRandom::new(); + + const PRIVATE_KEY_DER: &[u8] = + include_bytes!("../src/rsa/signature_rsa_example_private_key.der"); + let key_pair = rsa::KeyPair::from_der(PRIVATE_KEY_DER).unwrap(); + + // When the output buffer is not exactly the right length, `sign()` returns + // an error (and does not panic or invoke UB). if `sign` doesn't check that + // the length is correct at the beginning then there are various possible + // failure points when the output buffer is too small. + for len in 0..key_pair.public().modulus_len() + 1 { + let mut signature = vec![0; len]; + assert_eq!( + len == key_pair.public().modulus_len(), + key_pair + .sign(&signature::RSA_PKCS1_SHA256, &rng, MESSAGE, &mut signature) + .is_ok() + ); + } +} + +#[cfg(feature = "alloc")] +#[test] +fn test_signature_rsa_pkcs1_verify() { + let sha1_params = &[ + ( + &signature::RSA_PKCS1_1024_8192_SHA1_FOR_LEGACY_USE_ONLY, + 1024, + ), + ( + &signature::RSA_PKCS1_2048_8192_SHA1_FOR_LEGACY_USE_ONLY, + 2048, + ), + ]; + let sha256_params = &[ + ( + &signature::RSA_PKCS1_1024_8192_SHA256_FOR_LEGACY_USE_ONLY, + 1024, + ), + (&signature::RSA_PKCS1_2048_8192_SHA256, 2048), + ]; + let sha384_params = &[ + (&signature::RSA_PKCS1_2048_8192_SHA384, 2048), + (&signature::RSA_PKCS1_3072_8192_SHA384, 3072), + ]; + let sha512_params = &[ + ( + &signature::RSA_PKCS1_1024_8192_SHA512_FOR_LEGACY_USE_ONLY, + 1024, + ), + (&signature::RSA_PKCS1_2048_8192_SHA512, 2048), + ]; + test::run( + test_file!("rsa_pkcs1_verify_tests.txt"), + |section, test_case| { + assert_eq!(section, ""); + + let digest_name = test_case.consume_string("Digest"); + let params: &[_] = match digest_name.as_ref() { + "SHA1" => sha1_params, + "SHA256" => sha256_params, + "SHA384" => sha384_params, + "SHA512" => sha512_params, + _ => panic!("Unsupported digest: {}", digest_name), + }; + + let public_key = test_case.consume_bytes("Key"); + + // Sanity check that we correctly DER-encoded the originally- + // provided separate (n, e) components. When we add test vectors + // for improperly-encoded signatures, we'll have to revisit this. + let key_bits = untrusted::Input::from(&public_key) + .read_all(error::Unspecified, |input| { + der::nested(input, der::Tag::Sequence, error::Unspecified, |input| { + let n_bytes = + der::positive_integer(input)?.big_endian_without_leading_zero(); + let _e = der::positive_integer(input)?; + + // Because `n_bytes` has the leading zeros stripped and is big-endian, there + // must be less than 8 leading zero bits. + let n_leading_zeros = usize::try_from(n_bytes[0].leading_zeros()).unwrap(); + assert!(n_leading_zeros < 8); + Ok((n_bytes.len() * 8) - n_leading_zeros) + }) + }) + .expect("invalid DER"); + + let msg = test_case.consume_bytes("Msg"); + let sig = test_case.consume_bytes("Sig"); + let is_valid = test_case.consume_string("Result") == "P"; + for &(alg, min_bits) in params { + let width_ok = key_bits >= min_bits; + let actual_result = + signature::UnparsedPublicKey::new(alg, &public_key).verify(&msg, &sig); + assert_eq!(actual_result.is_ok(), is_valid && width_ok); + } + + Ok(()) + }, + ); +} + +#[cfg(feature = "alloc")] +#[test] +fn test_signature_rsa_pss_verify() { + test::run( + test_file!("rsa_pss_verify_tests.txt"), + |section, test_case| { + assert_eq!(section, ""); + + let digest_name = test_case.consume_string("Digest"); + let alg = match digest_name.as_ref() { + "SHA256" => &signature::RSA_PSS_2048_8192_SHA256, + "SHA384" => &signature::RSA_PSS_2048_8192_SHA384, + "SHA512" => &signature::RSA_PSS_2048_8192_SHA512, + _ => panic!("Unsupported digest: {}", digest_name), + }; + + let public_key = test_case.consume_bytes("Key"); + + // Sanity check that we correctly DER-encoded the originally- + // provided separate (n, e) components. When we add test vectors + // for improperly-encoded signatures, we'll have to revisit this. + assert!(untrusted::Input::from(&public_key) + .read_all(error::Unspecified, |input| der::nested( + input, + der::Tag::Sequence, + error::Unspecified, + |input| { + let _ = der::positive_integer(input)?; + let _ = der::positive_integer(input)?; + Ok(()) + } + )) + .is_ok()); + + let msg = test_case.consume_bytes("Msg"); + let sig = test_case.consume_bytes("Sig"); + let is_valid = test_case.consume_string("Result") == "P"; + + let actual_result = + signature::UnparsedPublicKey::new(alg, &public_key).verify(&msg, &sig); + assert_eq!(actual_result.is_ok(), is_valid); + + Ok(()) + }, + ); +} + +// Test for `primitive::verify()`. Read public key parts from a file +// and use them to verify a signature. +#[cfg(feature = "alloc")] +#[test] +fn test_signature_rsa_primitive_verification() { + test::run( + test_file!("rsa_primitive_verify_tests.txt"), + |section, test_case| { + assert_eq!(section, ""); + let n = test_case.consume_bytes("n"); + let e = test_case.consume_bytes("e"); + let msg = test_case.consume_bytes("Msg"); + let sig = test_case.consume_bytes("Sig"); + let expected = test_case.consume_string("Result"); + let public_key = signature::RsaPublicKeyComponents { n: &n, e: &e }; + let result = public_key.verify(&signature::RSA_PKCS1_2048_8192_SHA256, &msg, &sig); + assert_eq!(result.is_ok(), expected == "Pass"); + Ok(()) + }, + ) +} + +#[cfg(feature = "alloc")] +#[test] +fn rsa_test_keypair_coverage() { + const PRIVATE_KEY: &[u8] = include_bytes!("rsa_test_private_key_2048.p8"); + + let key_pair = rsa::KeyPair::from_pkcs8(PRIVATE_KEY).unwrap(); + + // Test that `signature::KeyPair::PublicKey` is `rsa::PublicKey`; if it + // were a separate type then it would need to be tested separately. + let _: &rsa::PublicKey = key_pair.public_key(); + + test_public_key_coverage(key_pair.public()); + // Test clones. + test_public_key_coverage(&key_pair.public().clone()); + + // Test `Debug` + assert_eq!( + format!("RsaKeyPair {{ public: {:?} }}", key_pair.public_key()), + format!("{:?}", key_pair) + ); +} + +fn test_public_key_coverage(key: &rsa::PublicKey) { + // Test `AsRef<[u8]>` + const PUBLIC_KEY: &[u8] = include_bytes!("rsa_test_public_key_2048.der"); + assert_eq!(key.as_ref(), PUBLIC_KEY); + + // Test `Debug`. + const PUBLIC_KEY_DEBUG: &str = include_str!("rsa_test_public_key_2048_debug.txt"); + assert_eq!(PUBLIC_KEY_DEBUG, format!("{:?}", key)); + + let components = rsa::PublicKeyComponents::>::from(key); + const PUBLIC_KEY_MODULUS_BE_BYTES: &[u8] = include_bytes!("rsa_test_public_modulus.bin"); + assert_eq!(PUBLIC_KEY_MODULUS_BE_BYTES, &components.n); + const _65537: &[u8] = &[0x01, 0x00, 0x01]; + assert_eq!(_65537, &components.e); +} diff --git a/http/vendor/ring/tests/signature_tests.rs b/http/vendor/ring/tests/signature_tests.rs new file mode 100644 index 0000000..dd340fa --- /dev/null +++ b/http/vendor/ring/tests/signature_tests.rs @@ -0,0 +1,30 @@ +#![allow(missing_docs)] + +use ring::signature; +#[allow(deprecated)] +use ring::test; + +#[cfg(all(target_arch = "wasm32", target_os = "unknown"))] +use wasm_bindgen_test::{wasm_bindgen_test as test, wasm_bindgen_test_configure}; + +#[cfg(all(target_arch = "wasm32", target_os = "unknown"))] +wasm_bindgen_test_configure!(run_in_browser); + +#[test] +fn signature_impl_test() { + test::compile_time_assert_clone::(); + test::compile_time_assert_copy::(); + test::compile_time_assert_send::(); + test::compile_time_assert_sync::(); + + let unparsed_public_key = + signature::UnparsedPublicKey::new(&signature::ED25519, &[0x01, 0x02, 0x03]); + + assert_eq!( + format!("{:?}", unparsed_public_key), + r#"UnparsedPublicKey { algorithm: ring::signature::ED25519, bytes: "010203" }"# + ); + + // Test `AsRef<[u8]>` + assert_eq!(unparsed_public_key.as_ref(), &[0x01, 0x02, 0x03]); +} diff --git a/http/vendor/ring/third_party/fiat/LICENSE b/http/vendor/ring/third_party/fiat/LICENSE new file mode 100644 index 0000000..3bc4b88 --- /dev/null +++ b/http/vendor/ring/third_party/fiat/LICENSE @@ -0,0 +1,15 @@ +The Apache License, Version 2.0 (Apache-2.0) + +Copyright 2015-2020 the fiat-crypto authors (see the AUTHORS file) + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/http/vendor/ring/third_party/fiat/asm/fiat_curve25519_adx_mul.S b/http/vendor/ring/third_party/fiat/asm/fiat_curve25519_adx_mul.S new file mode 100644 index 0000000..7e7be03 --- /dev/null +++ b/http/vendor/ring/third_party/fiat/asm/fiat_curve25519_adx_mul.S @@ -0,0 +1,178 @@ +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && \ + (defined(__APPLE__) || defined(__ELF__)) + +.intel_syntax noprefix +.text +#if defined(__APPLE__) +.private_extern _fiat_curve25519_adx_mul +.global _fiat_curve25519_adx_mul +_fiat_curve25519_adx_mul: +#else +.type fiat_curve25519_adx_mul, @function +.hidden fiat_curve25519_adx_mul +.global fiat_curve25519_adx_mul +fiat_curve25519_adx_mul: +#endif + +.cfi_startproc +_CET_ENDBR +push rbp +.cfi_adjust_cfa_offset 8 +.cfi_offset rbp, -16 +mov rbp, rsp + +mov rax, rdx +mov rdx, [ rsi + 0x18 ] +mulx r11, r10, [ rax + 0x8 ] +mov rdx, [ rax + 0x0 ] +mov [ rsp - 0x58 ], r15 +.cfi_offset r15, -16-0x58 +mulx r8, rcx, [ rsi + 0x18 ] +mov rdx, [ rsi + 0x8 ] +mov [ rsp - 0x80 ], rbx +.cfi_offset rbx, -16-0x80 +mulx rbx, r9, [ rax + 0x18 ] +mov rdx, [ rsi + 0x8 ] +mov [ rsp - 0x70 ], r12 +.cfi_offset r12, -16-0x70 +mulx r15, r12, [ rax + 0x8 ] +mov rdx, [ rsi + 0x0 ] +mov [ rsp - 0x68 ], r13 +.cfi_offset r13, -16-0x68 +mov [ rsp - 0x60 ], r14 +.cfi_offset r14, -16-0x60 +mulx r14, r13, [ rax + 0x0 ] +mov rdx, [ rax + 0x10 ] +mov [ rsp - 0x18 ], r15 +mov [ rsp - 0x50 ], rdi +mulx rdi, r15, [ rsi + 0x0 ] +mov rdx, [ rax + 0x18 ] +mov [ rsp - 0x48 ], r13 +mov [ rsp - 0x40 ], r9 +mulx r9, r13, [ rsi + 0x0 ] +test al, al +adox rcx, rdi +mov rdx, [ rsi + 0x10 ] +mov [ rsp - 0x38 ], r13 +mulx r13, rdi, [ rax + 0x8 ] +adox r10, r9 +mov rdx, 0x0 +adox rbx, rdx +adcx rdi, rcx +adcx r8, r10 +mov r9, rdx +adcx r9, rbx +mov rdx, [ rsi + 0x10 ] +mulx r10, rcx, [ rax + 0x0 ] +mov rdx, [ rsi + 0x0 ] +mov [ rsp - 0x30 ], r15 +mulx r15, rbx, [ rax + 0x8 ] +mov rdx, -0x2 +inc rdx +adox rcx, r15 +setc r15b +clc +adcx rcx, r12 +adox r10, rdi +mov rdx, [ rax + 0x10 ] +mov [ rsp - 0x78 ], rcx +mulx rcx, rdi, [ rsi + 0x10 ] +adox rdi, r8 +mov rdx, [ rax + 0x18 ] +mov [ rsp - 0x28 ], rcx +mulx rcx, r8, [ rsi + 0x10 ] +mov rdx, [ rax + 0x10 ] +mov [ rsp - 0x20 ], r8 +mulx r12, r8, [ rsi + 0x18 ] +adox r8, r9 +mov rdx, [ rsi + 0x8 ] +mov [ rsp - 0x10 ], r12 +mulx r12, r9, [ rax + 0x10 ] +movzx rdx, r15b +lea rdx, [ rdx + rcx ] +adcx r9, r10 +adcx r13, rdi +mov r15, 0x0 +mov r10, r15 +adox r10, rdx +mov rdx, [ rax + 0x18 ] +mulx rcx, rdi, [ rsi + 0x18 ] +adox rcx, r15 +adcx r11, r8 +mov rdx, r15 +adcx rdx, r10 +adcx rcx, r15 +mov r8, rdx +mov rdx, [ rax + 0x0 ] +mulx r15, r10, [ rsi + 0x8 ] +test al, al +adox r10, r14 +adcx rbx, r10 +adox r15, [ rsp - 0x78 ] +adcx r15, [ rsp - 0x30 ] +adox r9, [ rsp - 0x18 ] +adcx r9, [ rsp - 0x38 ] +adox r13, [ rsp - 0x40 ] +adcx r12, r13 +adox r11, [ rsp - 0x20 ] +adcx r11, [ rsp - 0x28 ] +mov rdx, 0x26 +mulx rsi, r14, r12 +adox rdi, r8 +adcx rdi, [ rsp - 0x10 ] +mulx r10, r8, r11 +mov r13, 0x0 +adox rcx, r13 +adcx rcx, r13 +mulx r11, r12, rdi +xor rdi, rdi +adox r8, rbx +adox r12, r15 +mulx rbx, r13, rcx +adcx r14, [ rsp - 0x48 ] +adox r13, r9 +adox rbx, rdi +adcx rsi, r8 +adcx r10, r12 +adcx r11, r13 +adc rbx, 0x0 +mulx r9, r15, rbx +xor r9, r9 +adox r15, r14 +mov rdi, r9 +adox rdi, rsi +mov rcx, r9 +adox rcx, r10 +mov r8, [ rsp - 0x50 ] +mov [ r8 + 0x8 ], rdi +mov r12, r9 +adox r12, r11 +mov r14, r9 +cmovo r14, rdx +mov [ r8 + 0x18 ], r12 +adcx r15, r14 +mov [ r8 + 0x0 ], r15 +mov [ r8 + 0x10 ], rcx +mov rbx, [ rsp - 0x80 ] +.cfi_restore rbx +mov r12, [ rsp - 0x70 ] +.cfi_restore r12 +mov r13, [ rsp - 0x68 ] +.cfi_restore r13 +mov r14, [ rsp - 0x60 ] +.cfi_restore r14 +mov r15, [ rsp - 0x58 ] +.cfi_restore r15 + +pop rbp +.cfi_restore rbp +.cfi_adjust_cfa_offset -8 +ret +.cfi_endproc +#if defined(__ELF__) +.size fiat_curve25519_adx_mul, .-fiat_curve25519_adx_mul +#endif + +#endif diff --git a/http/vendor/ring/third_party/fiat/asm/fiat_curve25519_adx_square.S b/http/vendor/ring/third_party/fiat/asm/fiat_curve25519_adx_square.S new file mode 100644 index 0000000..ccf7b76 --- /dev/null +++ b/http/vendor/ring/third_party/fiat/asm/fiat_curve25519_adx_square.S @@ -0,0 +1,146 @@ +#include + +#if !defined(OPENSSL_NO_ASM) && defined(OPENSSL_X86_64) && \ + (defined(__APPLE__) || defined(__ELF__)) + +.intel_syntax noprefix +.text +#if defined(__APPLE__) +.private_extern _fiat_curve25519_adx_square +.global _fiat_curve25519_adx_square +_fiat_curve25519_adx_square: +#else +.type fiat_curve25519_adx_square, @function +.hidden fiat_curve25519_adx_square +.global fiat_curve25519_adx_square +fiat_curve25519_adx_square: +#endif + +.cfi_startproc +_CET_ENDBR +push rbp +.cfi_adjust_cfa_offset 8 +.cfi_offset rbp, -16 +mov rbp, rsp + +mov rdx, [ rsi + 0x0 ] +mulx r10, rax, [ rsi + 0x8 ] +mov rdx, [ rsi + 0x0 ] +mulx rcx, r11, [ rsi + 0x10 ] +xor rdx, rdx +adox r11, r10 +mov rdx, [ rsi + 0x0 ] +mulx r9, r8, [ rsi + 0x18 ] +mov rdx, [ rsi + 0x8 ] +mov [ rsp - 0x80 ], rbx +.cfi_offset rbx, -16-0x80 +mulx rbx, r10, [ rsi + 0x18 ] +adox r8, rcx +mov [rsp - 0x48 ], rdi +adox r10, r9 +adcx rax, rax +mov rdx, [ rsi + 0x10 ] +mulx r9, rcx, [ rsi + 0x18 ] +adox rcx, rbx +mov rdx, [ rsi + 0x10 ] +mulx rdi, rbx, [ rsi + 0x8 ] +mov rdx, 0x0 +adox r9, rdx +mov [ rsp - 0x70 ], r12 +.cfi_offset r12, -16-0x70 +mov r12, -0x3 +inc r12 +adox rbx, r8 +adox rdi, r10 +adcx r11, r11 +mov r8, rdx +adox r8, rcx +mov r10, rdx +adox r10, r9 +adcx rbx, rbx +mov rdx, [ rsi + 0x0 ] +mulx r9, rcx, rdx +mov rdx, [ rsi + 0x8 ] +mov [ rsp - 0x68 ], r13 +.cfi_offset r13, -16-0x68 +mov [ rsp - 0x60 ], r14 +.cfi_offset r14, -16-0x60 +mulx r14, r13, rdx +seto dl +inc r12 +adox r9, rax +adox r13, r11 +adox r14, rbx +adcx rdi, rdi +mov al, dl +mov rdx, [ rsi + 0x10 ] +mulx rbx, r11, rdx +adox r11, rdi +adcx r8, r8 +adox rbx, r8 +adcx r10, r10 +movzx rdx, al +mov rdi, 0x0 +adcx rdx, rdi +movzx r8, al +lea r8, [ r8 + rdx ] +mov rdx, [ rsi + 0x18 ] +mulx rdi, rax, rdx +adox rax, r10 +mov rdx, 0x26 +mov [ rsp - 0x58 ], r15 +.cfi_offset r15, -16-0x58 +mulx r15, r10, r11 +clc +adcx r10, rcx +mulx r11, rcx, rbx +adox r8, rdi +mulx rdi, rbx, r8 +inc r12 +adox rcx, r9 +mulx r8, r9, rax +adcx r15, rcx +adox r9, r13 +adcx r11, r9 +adox rbx, r14 +adox rdi, r12 +adcx r8, rbx +adc rdi, 0x0 +mulx r14, r13, rdi +test al, al +mov rdi, [ rsp - 0x48 ] +adox r13, r10 +mov r14, r12 +adox r14, r15 +mov [ rdi + 0x8 ], r14 +mov rax, r12 +adox rax, r11 +mov r10, r12 +adox r10, r8 +mov [ rdi + 0x10 ], rax +mov rcx, r12 +cmovo rcx, rdx +adcx r13, rcx +mov [ rdi + 0x0 ], r13 +mov [ rdi + 0x18 ], r10 +mov rbx, [ rsp - 0x80 ] +.cfi_restore rbx +mov r12, [ rsp - 0x70 ] +.cfi_restore r12 +mov r13, [ rsp - 0x68 ] +.cfi_restore r13 +mov r14, [ rsp - 0x60 ] +.cfi_restore r14 +mov r15, [ rsp - 0x58 ] +.cfi_restore r15 + +pop rbp +.cfi_restore rbp +.cfi_adjust_cfa_offset -8 +ret +.cfi_endproc +#if defined(__ELF__) +.size fiat_curve25519_adx_square, .-fiat_curve25519_adx_square +#endif + +#endif diff --git a/http/vendor/ring/third_party/fiat/curve25519_32.h b/http/vendor/ring/third_party/fiat/curve25519_32.h new file mode 100644 index 0000000..56417ce --- /dev/null +++ b/http/vendor/ring/third_party/fiat/curve25519_32.h @@ -0,0 +1,1479 @@ +/* Autogenerated: 'src/ExtractionOCaml/unsaturated_solinas' --inline --static --use-value-barrier 25519 32 '(auto)' '2^255 - 19' carry_mul carry_square carry add sub opp selectznz to_bytes from_bytes relax carry_scmul121666 */ +/* curve description: 25519 */ +/* machine_wordsize = 32 (from "32") */ +/* requested operations: carry_mul, carry_square, carry, add, sub, opp, selectznz, to_bytes, from_bytes, relax, carry_scmul121666 */ +/* n = 10 (from "(auto)") */ +/* s-c = 2^255 - [(1, 19)] (from "2^255 - 19") */ +/* tight_bounds_multiplier = 1 (from "") */ +/* */ +/* Computed values: */ +/* carry_chain = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1] */ +/* eval z = z[0] + (z[1] << 26) + (z[2] << 51) + (z[3] << 77) + (z[4] << 102) + (z[5] << 128) + (z[6] << 153) + (z[7] << 179) + (z[8] << 204) + (z[9] << 230) */ +/* bytes_eval z = z[0] + (z[1] << 8) + (z[2] << 16) + (z[3] << 24) + (z[4] << 32) + (z[5] << 40) + (z[6] << 48) + (z[7] << 56) + (z[8] << 64) + (z[9] << 72) + (z[10] << 80) + (z[11] << 88) + (z[12] << 96) + (z[13] << 104) + (z[14] << 112) + (z[15] << 120) + (z[16] << 128) + (z[17] << 136) + (z[18] << 144) + (z[19] << 152) + (z[20] << 160) + (z[21] << 168) + (z[22] << 176) + (z[23] << 184) + (z[24] << 192) + (z[25] << 200) + (z[26] << 208) + (z[27] << 216) + (z[28] << 224) + (z[29] << 232) + (z[30] << 240) + (z[31] << 248) */ +/* balance = [0x7ffffda, 0x3fffffe, 0x7fffffe, 0x3fffffe, 0x7fffffe, 0x3fffffe, 0x7fffffe, 0x3fffffe, 0x7fffffe, 0x3fffffe] */ + +#include +typedef unsigned char fiat_25519_uint1; +typedef signed char fiat_25519_int1; +#if defined(__GNUC__) || defined(__clang__) +# define FIAT_25519_FIAT_INLINE __inline__ +#else +# define FIAT_25519_FIAT_INLINE +#endif + +/* The type fiat_25519_loose_field_element is a field element with loose bounds. */ +/* Bounds: [[0x0 ~> 0xc000000], [0x0 ~> 0x6000000], [0x0 ~> 0xc000000], [0x0 ~> 0x6000000], [0x0 ~> 0xc000000], [0x0 ~> 0x6000000], [0x0 ~> 0xc000000], [0x0 ~> 0x6000000], [0x0 ~> 0xc000000], [0x0 ~> 0x6000000]] */ +typedef uint32_t fiat_25519_loose_field_element[10]; + +/* The type fiat_25519_tight_field_element is a field element with tight bounds. */ +/* Bounds: [[0x0 ~> 0x4000000], [0x0 ~> 0x2000000], [0x0 ~> 0x4000000], [0x0 ~> 0x2000000], [0x0 ~> 0x4000000], [0x0 ~> 0x2000000], [0x0 ~> 0x4000000], [0x0 ~> 0x2000000], [0x0 ~> 0x4000000], [0x0 ~> 0x2000000]] */ +typedef uint32_t fiat_25519_tight_field_element[10]; + +#if (-1 & 3) != 3 +#error "This code only works on a two's complement system" +#endif + +#if !defined(FIAT_25519_NO_ASM) && (defined(__GNUC__) || defined(__clang__)) +static __inline__ uint32_t fiat_25519_value_barrier_u32(uint32_t a) { + __asm__("" : "+r"(a) : /* no inputs */); + return a; +} +#else +# define fiat_25519_value_barrier_u32(x) (x) +#endif + + +/* + * The function fiat_25519_addcarryx_u26 is an addition with carry. + * + * Postconditions: + * out1 = (arg1 + arg2 + arg3) mod 2^26 + * out2 = ⌊(arg1 + arg2 + arg3) / 2^26⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0x3ffffff] + * arg3: [0x0 ~> 0x3ffffff] + * Output Bounds: + * out1: [0x0 ~> 0x3ffffff] + * out2: [0x0 ~> 0x1] + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_addcarryx_u26(uint32_t* out1, fiat_25519_uint1* out2, fiat_25519_uint1 arg1, uint32_t arg2, uint32_t arg3) { + uint32_t x1; + uint32_t x2; + fiat_25519_uint1 x3; + x1 = ((arg1 + arg2) + arg3); + x2 = (x1 & UINT32_C(0x3ffffff)); + x3 = (fiat_25519_uint1)(x1 >> 26); + *out1 = x2; + *out2 = x3; +} + +/* + * The function fiat_25519_subborrowx_u26 is a subtraction with borrow. + * + * Postconditions: + * out1 = (-arg1 + arg2 + -arg3) mod 2^26 + * out2 = -⌊(-arg1 + arg2 + -arg3) / 2^26⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0x3ffffff] + * arg3: [0x0 ~> 0x3ffffff] + * Output Bounds: + * out1: [0x0 ~> 0x3ffffff] + * out2: [0x0 ~> 0x1] + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_subborrowx_u26(uint32_t* out1, fiat_25519_uint1* out2, fiat_25519_uint1 arg1, uint32_t arg2, uint32_t arg3) { + int32_t x1; + fiat_25519_int1 x2; + uint32_t x3; + x1 = ((int32_t)(arg2 - arg1) - (int32_t)arg3); + x2 = (fiat_25519_int1)(x1 >> 26); + x3 = (x1 & UINT32_C(0x3ffffff)); + *out1 = x3; + *out2 = (fiat_25519_uint1)(0x0 - x2); +} + +/* + * The function fiat_25519_addcarryx_u25 is an addition with carry. + * + * Postconditions: + * out1 = (arg1 + arg2 + arg3) mod 2^25 + * out2 = ⌊(arg1 + arg2 + arg3) / 2^25⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0x1ffffff] + * arg3: [0x0 ~> 0x1ffffff] + * Output Bounds: + * out1: [0x0 ~> 0x1ffffff] + * out2: [0x0 ~> 0x1] + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_addcarryx_u25(uint32_t* out1, fiat_25519_uint1* out2, fiat_25519_uint1 arg1, uint32_t arg2, uint32_t arg3) { + uint32_t x1; + uint32_t x2; + fiat_25519_uint1 x3; + x1 = ((arg1 + arg2) + arg3); + x2 = (x1 & UINT32_C(0x1ffffff)); + x3 = (fiat_25519_uint1)(x1 >> 25); + *out1 = x2; + *out2 = x3; +} + +/* + * The function fiat_25519_subborrowx_u25 is a subtraction with borrow. + * + * Postconditions: + * out1 = (-arg1 + arg2 + -arg3) mod 2^25 + * out2 = -⌊(-arg1 + arg2 + -arg3) / 2^25⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0x1ffffff] + * arg3: [0x0 ~> 0x1ffffff] + * Output Bounds: + * out1: [0x0 ~> 0x1ffffff] + * out2: [0x0 ~> 0x1] + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_subborrowx_u25(uint32_t* out1, fiat_25519_uint1* out2, fiat_25519_uint1 arg1, uint32_t arg2, uint32_t arg3) { + int32_t x1; + fiat_25519_int1 x2; + uint32_t x3; + x1 = ((int32_t)(arg2 - arg1) - (int32_t)arg3); + x2 = (fiat_25519_int1)(x1 >> 25); + x3 = (x1 & UINT32_C(0x1ffffff)); + *out1 = x3; + *out2 = (fiat_25519_uint1)(0x0 - x2); +} + +/* + * The function fiat_25519_cmovznz_u32 is a single-word conditional move. + * + * Postconditions: + * out1 = (if arg1 = 0 then arg2 else arg3) + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0xffffffff] + * arg3: [0x0 ~> 0xffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffff] + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_cmovznz_u32(uint32_t* out1, fiat_25519_uint1 arg1, uint32_t arg2, uint32_t arg3) { + fiat_25519_uint1 x1; + uint32_t x2; + uint32_t x3; + x1 = (!(!arg1)); + x2 = ((fiat_25519_int1)(0x0 - x1) & UINT32_C(0xffffffff)); + x3 = ((fiat_25519_value_barrier_u32(x2) & arg3) | (fiat_25519_value_barrier_u32((~x2)) & arg2)); + *out1 = x3; +} + +/* + * The function fiat_25519_carry_mul multiplies two field elements and reduces the result. + * + * Postconditions: + * eval out1 mod m = (eval arg1 * eval arg2) mod m + * + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_carry_mul(fiat_25519_tight_field_element out1, const fiat_25519_loose_field_element arg1, const fiat_25519_loose_field_element arg2) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + uint64_t x6; + uint64_t x7; + uint64_t x8; + uint64_t x9; + uint64_t x10; + uint64_t x11; + uint64_t x12; + uint64_t x13; + uint64_t x14; + uint64_t x15; + uint64_t x16; + uint64_t x17; + uint64_t x18; + uint64_t x19; + uint64_t x20; + uint64_t x21; + uint64_t x22; + uint64_t x23; + uint64_t x24; + uint64_t x25; + uint64_t x26; + uint64_t x27; + uint64_t x28; + uint64_t x29; + uint64_t x30; + uint64_t x31; + uint64_t x32; + uint64_t x33; + uint64_t x34; + uint64_t x35; + uint64_t x36; + uint64_t x37; + uint64_t x38; + uint64_t x39; + uint64_t x40; + uint64_t x41; + uint64_t x42; + uint64_t x43; + uint64_t x44; + uint64_t x45; + uint64_t x46; + uint64_t x47; + uint64_t x48; + uint64_t x49; + uint64_t x50; + uint64_t x51; + uint64_t x52; + uint64_t x53; + uint64_t x54; + uint64_t x55; + uint64_t x56; + uint64_t x57; + uint64_t x58; + uint64_t x59; + uint64_t x60; + uint64_t x61; + uint64_t x62; + uint64_t x63; + uint64_t x64; + uint64_t x65; + uint64_t x66; + uint64_t x67; + uint64_t x68; + uint64_t x69; + uint64_t x70; + uint64_t x71; + uint64_t x72; + uint64_t x73; + uint64_t x74; + uint64_t x75; + uint64_t x76; + uint64_t x77; + uint64_t x78; + uint64_t x79; + uint64_t x80; + uint64_t x81; + uint64_t x82; + uint64_t x83; + uint64_t x84; + uint64_t x85; + uint64_t x86; + uint64_t x87; + uint64_t x88; + uint64_t x89; + uint64_t x90; + uint64_t x91; + uint64_t x92; + uint64_t x93; + uint64_t x94; + uint64_t x95; + uint64_t x96; + uint64_t x97; + uint64_t x98; + uint64_t x99; + uint64_t x100; + uint64_t x101; + uint64_t x102; + uint32_t x103; + uint64_t x104; + uint64_t x105; + uint64_t x106; + uint64_t x107; + uint64_t x108; + uint64_t x109; + uint64_t x110; + uint64_t x111; + uint64_t x112; + uint64_t x113; + uint64_t x114; + uint32_t x115; + uint64_t x116; + uint64_t x117; + uint32_t x118; + uint64_t x119; + uint64_t x120; + uint32_t x121; + uint64_t x122; + uint64_t x123; + uint32_t x124; + uint64_t x125; + uint64_t x126; + uint32_t x127; + uint64_t x128; + uint64_t x129; + uint32_t x130; + uint64_t x131; + uint64_t x132; + uint32_t x133; + uint64_t x134; + uint64_t x135; + uint32_t x136; + uint64_t x137; + uint64_t x138; + uint32_t x139; + uint64_t x140; + uint64_t x141; + uint32_t x142; + uint32_t x143; + uint32_t x144; + fiat_25519_uint1 x145; + uint32_t x146; + uint32_t x147; + x1 = ((uint64_t)(arg1[9]) * ((arg2[9]) * UINT8_C(0x26))); + x2 = ((uint64_t)(arg1[9]) * ((arg2[8]) * UINT8_C(0x13))); + x3 = ((uint64_t)(arg1[9]) * ((arg2[7]) * UINT8_C(0x26))); + x4 = ((uint64_t)(arg1[9]) * ((arg2[6]) * UINT8_C(0x13))); + x5 = ((uint64_t)(arg1[9]) * ((arg2[5]) * UINT8_C(0x26))); + x6 = ((uint64_t)(arg1[9]) * ((arg2[4]) * UINT8_C(0x13))); + x7 = ((uint64_t)(arg1[9]) * ((arg2[3]) * UINT8_C(0x26))); + x8 = ((uint64_t)(arg1[9]) * ((arg2[2]) * UINT8_C(0x13))); + x9 = ((uint64_t)(arg1[9]) * ((arg2[1]) * UINT8_C(0x26))); + x10 = ((uint64_t)(arg1[8]) * ((arg2[9]) * UINT8_C(0x13))); + x11 = ((uint64_t)(arg1[8]) * ((arg2[8]) * UINT8_C(0x13))); + x12 = ((uint64_t)(arg1[8]) * ((arg2[7]) * UINT8_C(0x13))); + x13 = ((uint64_t)(arg1[8]) * ((arg2[6]) * UINT8_C(0x13))); + x14 = ((uint64_t)(arg1[8]) * ((arg2[5]) * UINT8_C(0x13))); + x15 = ((uint64_t)(arg1[8]) * ((arg2[4]) * UINT8_C(0x13))); + x16 = ((uint64_t)(arg1[8]) * ((arg2[3]) * UINT8_C(0x13))); + x17 = ((uint64_t)(arg1[8]) * ((arg2[2]) * UINT8_C(0x13))); + x18 = ((uint64_t)(arg1[7]) * ((arg2[9]) * UINT8_C(0x26))); + x19 = ((uint64_t)(arg1[7]) * ((arg2[8]) * UINT8_C(0x13))); + x20 = ((uint64_t)(arg1[7]) * ((arg2[7]) * UINT8_C(0x26))); + x21 = ((uint64_t)(arg1[7]) * ((arg2[6]) * UINT8_C(0x13))); + x22 = ((uint64_t)(arg1[7]) * ((arg2[5]) * UINT8_C(0x26))); + x23 = ((uint64_t)(arg1[7]) * ((arg2[4]) * UINT8_C(0x13))); + x24 = ((uint64_t)(arg1[7]) * ((arg2[3]) * UINT8_C(0x26))); + x25 = ((uint64_t)(arg1[6]) * ((arg2[9]) * UINT8_C(0x13))); + x26 = ((uint64_t)(arg1[6]) * ((arg2[8]) * UINT8_C(0x13))); + x27 = ((uint64_t)(arg1[6]) * ((arg2[7]) * UINT8_C(0x13))); + x28 = ((uint64_t)(arg1[6]) * ((arg2[6]) * UINT8_C(0x13))); + x29 = ((uint64_t)(arg1[6]) * ((arg2[5]) * UINT8_C(0x13))); + x30 = ((uint64_t)(arg1[6]) * ((arg2[4]) * UINT8_C(0x13))); + x31 = ((uint64_t)(arg1[5]) * ((arg2[9]) * UINT8_C(0x26))); + x32 = ((uint64_t)(arg1[5]) * ((arg2[8]) * UINT8_C(0x13))); + x33 = ((uint64_t)(arg1[5]) * ((arg2[7]) * UINT8_C(0x26))); + x34 = ((uint64_t)(arg1[5]) * ((arg2[6]) * UINT8_C(0x13))); + x35 = ((uint64_t)(arg1[5]) * ((arg2[5]) * UINT8_C(0x26))); + x36 = ((uint64_t)(arg1[4]) * ((arg2[9]) * UINT8_C(0x13))); + x37 = ((uint64_t)(arg1[4]) * ((arg2[8]) * UINT8_C(0x13))); + x38 = ((uint64_t)(arg1[4]) * ((arg2[7]) * UINT8_C(0x13))); + x39 = ((uint64_t)(arg1[4]) * ((arg2[6]) * UINT8_C(0x13))); + x40 = ((uint64_t)(arg1[3]) * ((arg2[9]) * UINT8_C(0x26))); + x41 = ((uint64_t)(arg1[3]) * ((arg2[8]) * UINT8_C(0x13))); + x42 = ((uint64_t)(arg1[3]) * ((arg2[7]) * UINT8_C(0x26))); + x43 = ((uint64_t)(arg1[2]) * ((arg2[9]) * UINT8_C(0x13))); + x44 = ((uint64_t)(arg1[2]) * ((arg2[8]) * UINT8_C(0x13))); + x45 = ((uint64_t)(arg1[1]) * ((arg2[9]) * UINT8_C(0x26))); + x46 = ((uint64_t)(arg1[9]) * (arg2[0])); + x47 = ((uint64_t)(arg1[8]) * (arg2[1])); + x48 = ((uint64_t)(arg1[8]) * (arg2[0])); + x49 = ((uint64_t)(arg1[7]) * (arg2[2])); + x50 = ((uint64_t)(arg1[7]) * ((arg2[1]) * 0x2)); + x51 = ((uint64_t)(arg1[7]) * (arg2[0])); + x52 = ((uint64_t)(arg1[6]) * (arg2[3])); + x53 = ((uint64_t)(arg1[6]) * (arg2[2])); + x54 = ((uint64_t)(arg1[6]) * (arg2[1])); + x55 = ((uint64_t)(arg1[6]) * (arg2[0])); + x56 = ((uint64_t)(arg1[5]) * (arg2[4])); + x57 = ((uint64_t)(arg1[5]) * ((arg2[3]) * 0x2)); + x58 = ((uint64_t)(arg1[5]) * (arg2[2])); + x59 = ((uint64_t)(arg1[5]) * ((arg2[1]) * 0x2)); + x60 = ((uint64_t)(arg1[5]) * (arg2[0])); + x61 = ((uint64_t)(arg1[4]) * (arg2[5])); + x62 = ((uint64_t)(arg1[4]) * (arg2[4])); + x63 = ((uint64_t)(arg1[4]) * (arg2[3])); + x64 = ((uint64_t)(arg1[4]) * (arg2[2])); + x65 = ((uint64_t)(arg1[4]) * (arg2[1])); + x66 = ((uint64_t)(arg1[4]) * (arg2[0])); + x67 = ((uint64_t)(arg1[3]) * (arg2[6])); + x68 = ((uint64_t)(arg1[3]) * ((arg2[5]) * 0x2)); + x69 = ((uint64_t)(arg1[3]) * (arg2[4])); + x70 = ((uint64_t)(arg1[3]) * ((arg2[3]) * 0x2)); + x71 = ((uint64_t)(arg1[3]) * (arg2[2])); + x72 = ((uint64_t)(arg1[3]) * ((arg2[1]) * 0x2)); + x73 = ((uint64_t)(arg1[3]) * (arg2[0])); + x74 = ((uint64_t)(arg1[2]) * (arg2[7])); + x75 = ((uint64_t)(arg1[2]) * (arg2[6])); + x76 = ((uint64_t)(arg1[2]) * (arg2[5])); + x77 = ((uint64_t)(arg1[2]) * (arg2[4])); + x78 = ((uint64_t)(arg1[2]) * (arg2[3])); + x79 = ((uint64_t)(arg1[2]) * (arg2[2])); + x80 = ((uint64_t)(arg1[2]) * (arg2[1])); + x81 = ((uint64_t)(arg1[2]) * (arg2[0])); + x82 = ((uint64_t)(arg1[1]) * (arg2[8])); + x83 = ((uint64_t)(arg1[1]) * ((arg2[7]) * 0x2)); + x84 = ((uint64_t)(arg1[1]) * (arg2[6])); + x85 = ((uint64_t)(arg1[1]) * ((arg2[5]) * 0x2)); + x86 = ((uint64_t)(arg1[1]) * (arg2[4])); + x87 = ((uint64_t)(arg1[1]) * ((arg2[3]) * 0x2)); + x88 = ((uint64_t)(arg1[1]) * (arg2[2])); + x89 = ((uint64_t)(arg1[1]) * ((arg2[1]) * 0x2)); + x90 = ((uint64_t)(arg1[1]) * (arg2[0])); + x91 = ((uint64_t)(arg1[0]) * (arg2[9])); + x92 = ((uint64_t)(arg1[0]) * (arg2[8])); + x93 = ((uint64_t)(arg1[0]) * (arg2[7])); + x94 = ((uint64_t)(arg1[0]) * (arg2[6])); + x95 = ((uint64_t)(arg1[0]) * (arg2[5])); + x96 = ((uint64_t)(arg1[0]) * (arg2[4])); + x97 = ((uint64_t)(arg1[0]) * (arg2[3])); + x98 = ((uint64_t)(arg1[0]) * (arg2[2])); + x99 = ((uint64_t)(arg1[0]) * (arg2[1])); + x100 = ((uint64_t)(arg1[0]) * (arg2[0])); + x101 = (x100 + (x45 + (x44 + (x42 + (x39 + (x35 + (x30 + (x24 + (x17 + x9))))))))); + x102 = (x101 >> 26); + x103 = (uint32_t)(x101 & UINT32_C(0x3ffffff)); + x104 = (x91 + (x82 + (x74 + (x67 + (x61 + (x56 + (x52 + (x49 + (x47 + x46))))))))); + x105 = (x92 + (x83 + (x75 + (x68 + (x62 + (x57 + (x53 + (x50 + (x48 + x1))))))))); + x106 = (x93 + (x84 + (x76 + (x69 + (x63 + (x58 + (x54 + (x51 + (x10 + x2))))))))); + x107 = (x94 + (x85 + (x77 + (x70 + (x64 + (x59 + (x55 + (x18 + (x11 + x3))))))))); + x108 = (x95 + (x86 + (x78 + (x71 + (x65 + (x60 + (x25 + (x19 + (x12 + x4))))))))); + x109 = (x96 + (x87 + (x79 + (x72 + (x66 + (x31 + (x26 + (x20 + (x13 + x5))))))))); + x110 = (x97 + (x88 + (x80 + (x73 + (x36 + (x32 + (x27 + (x21 + (x14 + x6))))))))); + x111 = (x98 + (x89 + (x81 + (x40 + (x37 + (x33 + (x28 + (x22 + (x15 + x7))))))))); + x112 = (x99 + (x90 + (x43 + (x41 + (x38 + (x34 + (x29 + (x23 + (x16 + x8))))))))); + x113 = (x102 + x112); + x114 = (x113 >> 25); + x115 = (uint32_t)(x113 & UINT32_C(0x1ffffff)); + x116 = (x114 + x111); + x117 = (x116 >> 26); + x118 = (uint32_t)(x116 & UINT32_C(0x3ffffff)); + x119 = (x117 + x110); + x120 = (x119 >> 25); + x121 = (uint32_t)(x119 & UINT32_C(0x1ffffff)); + x122 = (x120 + x109); + x123 = (x122 >> 26); + x124 = (uint32_t)(x122 & UINT32_C(0x3ffffff)); + x125 = (x123 + x108); + x126 = (x125 >> 25); + x127 = (uint32_t)(x125 & UINT32_C(0x1ffffff)); + x128 = (x126 + x107); + x129 = (x128 >> 26); + x130 = (uint32_t)(x128 & UINT32_C(0x3ffffff)); + x131 = (x129 + x106); + x132 = (x131 >> 25); + x133 = (uint32_t)(x131 & UINT32_C(0x1ffffff)); + x134 = (x132 + x105); + x135 = (x134 >> 26); + x136 = (uint32_t)(x134 & UINT32_C(0x3ffffff)); + x137 = (x135 + x104); + x138 = (x137 >> 25); + x139 = (uint32_t)(x137 & UINT32_C(0x1ffffff)); + x140 = (x138 * UINT8_C(0x13)); + x141 = (x103 + x140); + x142 = (uint32_t)(x141 >> 26); + x143 = (uint32_t)(x141 & UINT32_C(0x3ffffff)); + x144 = (x142 + x115); + x145 = (fiat_25519_uint1)(x144 >> 25); + x146 = (x144 & UINT32_C(0x1ffffff)); + x147 = (x145 + x118); + out1[0] = x143; + out1[1] = x146; + out1[2] = x147; + out1[3] = x121; + out1[4] = x124; + out1[5] = x127; + out1[6] = x130; + out1[7] = x133; + out1[8] = x136; + out1[9] = x139; +} + +/* + * The function fiat_25519_carry_square squares a field element and reduces the result. + * + * Postconditions: + * eval out1 mod m = (eval arg1 * eval arg1) mod m + * + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_carry_square(fiat_25519_tight_field_element out1, const fiat_25519_loose_field_element arg1) { + uint32_t x1; + uint32_t x2; + uint32_t x3; + uint32_t x4; + uint64_t x5; + uint32_t x6; + uint32_t x7; + uint32_t x8; + uint32_t x9; + uint32_t x10; + uint64_t x11; + uint32_t x12; + uint32_t x13; + uint32_t x14; + uint32_t x15; + uint32_t x16; + uint32_t x17; + uint32_t x18; + uint64_t x19; + uint64_t x20; + uint64_t x21; + uint64_t x22; + uint64_t x23; + uint64_t x24; + uint64_t x25; + uint64_t x26; + uint64_t x27; + uint64_t x28; + uint64_t x29; + uint64_t x30; + uint64_t x31; + uint64_t x32; + uint64_t x33; + uint64_t x34; + uint64_t x35; + uint64_t x36; + uint64_t x37; + uint64_t x38; + uint64_t x39; + uint64_t x40; + uint64_t x41; + uint64_t x42; + uint64_t x43; + uint64_t x44; + uint64_t x45; + uint64_t x46; + uint64_t x47; + uint64_t x48; + uint64_t x49; + uint64_t x50; + uint64_t x51; + uint64_t x52; + uint64_t x53; + uint64_t x54; + uint64_t x55; + uint64_t x56; + uint64_t x57; + uint64_t x58; + uint64_t x59; + uint64_t x60; + uint64_t x61; + uint64_t x62; + uint64_t x63; + uint64_t x64; + uint64_t x65; + uint64_t x66; + uint64_t x67; + uint64_t x68; + uint64_t x69; + uint64_t x70; + uint64_t x71; + uint64_t x72; + uint64_t x73; + uint64_t x74; + uint64_t x75; + uint32_t x76; + uint64_t x77; + uint64_t x78; + uint64_t x79; + uint64_t x80; + uint64_t x81; + uint64_t x82; + uint64_t x83; + uint64_t x84; + uint64_t x85; + uint64_t x86; + uint64_t x87; + uint32_t x88; + uint64_t x89; + uint64_t x90; + uint32_t x91; + uint64_t x92; + uint64_t x93; + uint32_t x94; + uint64_t x95; + uint64_t x96; + uint32_t x97; + uint64_t x98; + uint64_t x99; + uint32_t x100; + uint64_t x101; + uint64_t x102; + uint32_t x103; + uint64_t x104; + uint64_t x105; + uint32_t x106; + uint64_t x107; + uint64_t x108; + uint32_t x109; + uint64_t x110; + uint64_t x111; + uint32_t x112; + uint64_t x113; + uint64_t x114; + uint32_t x115; + uint32_t x116; + uint32_t x117; + fiat_25519_uint1 x118; + uint32_t x119; + uint32_t x120; + x1 = ((arg1[9]) * UINT8_C(0x13)); + x2 = (x1 * 0x2); + x3 = ((arg1[9]) * 0x2); + x4 = ((arg1[8]) * UINT8_C(0x13)); + x5 = ((uint64_t)x4 * 0x2); + x6 = ((arg1[8]) * 0x2); + x7 = ((arg1[7]) * UINT8_C(0x13)); + x8 = (x7 * 0x2); + x9 = ((arg1[7]) * 0x2); + x10 = ((arg1[6]) * UINT8_C(0x13)); + x11 = ((uint64_t)x10 * 0x2); + x12 = ((arg1[6]) * 0x2); + x13 = ((arg1[5]) * UINT8_C(0x13)); + x14 = ((arg1[5]) * 0x2); + x15 = ((arg1[4]) * 0x2); + x16 = ((arg1[3]) * 0x2); + x17 = ((arg1[2]) * 0x2); + x18 = ((arg1[1]) * 0x2); + x19 = ((uint64_t)(arg1[9]) * (x1 * 0x2)); + x20 = ((uint64_t)(arg1[8]) * x2); + x21 = ((uint64_t)(arg1[8]) * x4); + x22 = ((arg1[7]) * ((uint64_t)x2 * 0x2)); + x23 = ((arg1[7]) * x5); + x24 = ((uint64_t)(arg1[7]) * (x7 * 0x2)); + x25 = ((uint64_t)(arg1[6]) * x2); + x26 = ((arg1[6]) * x5); + x27 = ((uint64_t)(arg1[6]) * x8); + x28 = ((uint64_t)(arg1[6]) * x10); + x29 = ((arg1[5]) * ((uint64_t)x2 * 0x2)); + x30 = ((arg1[5]) * x5); + x31 = ((arg1[5]) * ((uint64_t)x8 * 0x2)); + x32 = ((arg1[5]) * x11); + x33 = ((uint64_t)(arg1[5]) * (x13 * 0x2)); + x34 = ((uint64_t)(arg1[4]) * x2); + x35 = ((arg1[4]) * x5); + x36 = ((uint64_t)(arg1[4]) * x8); + x37 = ((arg1[4]) * x11); + x38 = ((uint64_t)(arg1[4]) * x14); + x39 = ((uint64_t)(arg1[4]) * (arg1[4])); + x40 = ((arg1[3]) * ((uint64_t)x2 * 0x2)); + x41 = ((arg1[3]) * x5); + x42 = ((arg1[3]) * ((uint64_t)x8 * 0x2)); + x43 = ((uint64_t)(arg1[3]) * x12); + x44 = ((uint64_t)(arg1[3]) * (x14 * 0x2)); + x45 = ((uint64_t)(arg1[3]) * x15); + x46 = ((uint64_t)(arg1[3]) * ((arg1[3]) * 0x2)); + x47 = ((uint64_t)(arg1[2]) * x2); + x48 = ((arg1[2]) * x5); + x49 = ((uint64_t)(arg1[2]) * x9); + x50 = ((uint64_t)(arg1[2]) * x12); + x51 = ((uint64_t)(arg1[2]) * x14); + x52 = ((uint64_t)(arg1[2]) * x15); + x53 = ((uint64_t)(arg1[2]) * x16); + x54 = ((uint64_t)(arg1[2]) * (arg1[2])); + x55 = ((arg1[1]) * ((uint64_t)x2 * 0x2)); + x56 = ((uint64_t)(arg1[1]) * x6); + x57 = ((uint64_t)(arg1[1]) * (x9 * 0x2)); + x58 = ((uint64_t)(arg1[1]) * x12); + x59 = ((uint64_t)(arg1[1]) * (x14 * 0x2)); + x60 = ((uint64_t)(arg1[1]) * x15); + x61 = ((uint64_t)(arg1[1]) * (x16 * 0x2)); + x62 = ((uint64_t)(arg1[1]) * x17); + x63 = ((uint64_t)(arg1[1]) * ((arg1[1]) * 0x2)); + x64 = ((uint64_t)(arg1[0]) * x3); + x65 = ((uint64_t)(arg1[0]) * x6); + x66 = ((uint64_t)(arg1[0]) * x9); + x67 = ((uint64_t)(arg1[0]) * x12); + x68 = ((uint64_t)(arg1[0]) * x14); + x69 = ((uint64_t)(arg1[0]) * x15); + x70 = ((uint64_t)(arg1[0]) * x16); + x71 = ((uint64_t)(arg1[0]) * x17); + x72 = ((uint64_t)(arg1[0]) * x18); + x73 = ((uint64_t)(arg1[0]) * (arg1[0])); + x74 = (x73 + (x55 + (x48 + (x42 + (x37 + x33))))); + x75 = (x74 >> 26); + x76 = (uint32_t)(x74 & UINT32_C(0x3ffffff)); + x77 = (x64 + (x56 + (x49 + (x43 + x38)))); + x78 = (x65 + (x57 + (x50 + (x44 + (x39 + x19))))); + x79 = (x66 + (x58 + (x51 + (x45 + x20)))); + x80 = (x67 + (x59 + (x52 + (x46 + (x22 + x21))))); + x81 = (x68 + (x60 + (x53 + (x25 + x23)))); + x82 = (x69 + (x61 + (x54 + (x29 + (x26 + x24))))); + x83 = (x70 + (x62 + (x34 + (x30 + x27)))); + x84 = (x71 + (x63 + (x40 + (x35 + (x31 + x28))))); + x85 = (x72 + (x47 + (x41 + (x36 + x32)))); + x86 = (x75 + x85); + x87 = (x86 >> 25); + x88 = (uint32_t)(x86 & UINT32_C(0x1ffffff)); + x89 = (x87 + x84); + x90 = (x89 >> 26); + x91 = (uint32_t)(x89 & UINT32_C(0x3ffffff)); + x92 = (x90 + x83); + x93 = (x92 >> 25); + x94 = (uint32_t)(x92 & UINT32_C(0x1ffffff)); + x95 = (x93 + x82); + x96 = (x95 >> 26); + x97 = (uint32_t)(x95 & UINT32_C(0x3ffffff)); + x98 = (x96 + x81); + x99 = (x98 >> 25); + x100 = (uint32_t)(x98 & UINT32_C(0x1ffffff)); + x101 = (x99 + x80); + x102 = (x101 >> 26); + x103 = (uint32_t)(x101 & UINT32_C(0x3ffffff)); + x104 = (x102 + x79); + x105 = (x104 >> 25); + x106 = (uint32_t)(x104 & UINT32_C(0x1ffffff)); + x107 = (x105 + x78); + x108 = (x107 >> 26); + x109 = (uint32_t)(x107 & UINT32_C(0x3ffffff)); + x110 = (x108 + x77); + x111 = (x110 >> 25); + x112 = (uint32_t)(x110 & UINT32_C(0x1ffffff)); + x113 = (x111 * UINT8_C(0x13)); + x114 = (x76 + x113); + x115 = (uint32_t)(x114 >> 26); + x116 = (uint32_t)(x114 & UINT32_C(0x3ffffff)); + x117 = (x115 + x88); + x118 = (fiat_25519_uint1)(x117 >> 25); + x119 = (x117 & UINT32_C(0x1ffffff)); + x120 = (x118 + x91); + out1[0] = x116; + out1[1] = x119; + out1[2] = x120; + out1[3] = x94; + out1[4] = x97; + out1[5] = x100; + out1[6] = x103; + out1[7] = x106; + out1[8] = x109; + out1[9] = x112; +} + +/* + * The function fiat_25519_carry reduces a field element. + * + * Postconditions: + * eval out1 mod m = eval arg1 mod m + * + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_carry(fiat_25519_tight_field_element out1, const fiat_25519_loose_field_element arg1) { + uint32_t x1; + uint32_t x2; + uint32_t x3; + uint32_t x4; + uint32_t x5; + uint32_t x6; + uint32_t x7; + uint32_t x8; + uint32_t x9; + uint32_t x10; + uint32_t x11; + uint32_t x12; + uint32_t x13; + uint32_t x14; + uint32_t x15; + uint32_t x16; + uint32_t x17; + uint32_t x18; + uint32_t x19; + uint32_t x20; + uint32_t x21; + uint32_t x22; + x1 = (arg1[0]); + x2 = ((x1 >> 26) + (arg1[1])); + x3 = ((x2 >> 25) + (arg1[2])); + x4 = ((x3 >> 26) + (arg1[3])); + x5 = ((x4 >> 25) + (arg1[4])); + x6 = ((x5 >> 26) + (arg1[5])); + x7 = ((x6 >> 25) + (arg1[6])); + x8 = ((x7 >> 26) + (arg1[7])); + x9 = ((x8 >> 25) + (arg1[8])); + x10 = ((x9 >> 26) + (arg1[9])); + x11 = ((x1 & UINT32_C(0x3ffffff)) + ((x10 >> 25) * UINT8_C(0x13))); + x12 = ((fiat_25519_uint1)(x11 >> 26) + (x2 & UINT32_C(0x1ffffff))); + x13 = (x11 & UINT32_C(0x3ffffff)); + x14 = (x12 & UINT32_C(0x1ffffff)); + x15 = ((fiat_25519_uint1)(x12 >> 25) + (x3 & UINT32_C(0x3ffffff))); + x16 = (x4 & UINT32_C(0x1ffffff)); + x17 = (x5 & UINT32_C(0x3ffffff)); + x18 = (x6 & UINT32_C(0x1ffffff)); + x19 = (x7 & UINT32_C(0x3ffffff)); + x20 = (x8 & UINT32_C(0x1ffffff)); + x21 = (x9 & UINT32_C(0x3ffffff)); + x22 = (x10 & UINT32_C(0x1ffffff)); + out1[0] = x13; + out1[1] = x14; + out1[2] = x15; + out1[3] = x16; + out1[4] = x17; + out1[5] = x18; + out1[6] = x19; + out1[7] = x20; + out1[8] = x21; + out1[9] = x22; +} + +/* + * The function fiat_25519_add adds two field elements. + * + * Postconditions: + * eval out1 mod m = (eval arg1 + eval arg2) mod m + * + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_add(fiat_25519_loose_field_element out1, const fiat_25519_tight_field_element arg1, const fiat_25519_tight_field_element arg2) { + uint32_t x1; + uint32_t x2; + uint32_t x3; + uint32_t x4; + uint32_t x5; + uint32_t x6; + uint32_t x7; + uint32_t x8; + uint32_t x9; + uint32_t x10; + x1 = ((arg1[0]) + (arg2[0])); + x2 = ((arg1[1]) + (arg2[1])); + x3 = ((arg1[2]) + (arg2[2])); + x4 = ((arg1[3]) + (arg2[3])); + x5 = ((arg1[4]) + (arg2[4])); + x6 = ((arg1[5]) + (arg2[5])); + x7 = ((arg1[6]) + (arg2[6])); + x8 = ((arg1[7]) + (arg2[7])); + x9 = ((arg1[8]) + (arg2[8])); + x10 = ((arg1[9]) + (arg2[9])); + out1[0] = x1; + out1[1] = x2; + out1[2] = x3; + out1[3] = x4; + out1[4] = x5; + out1[5] = x6; + out1[6] = x7; + out1[7] = x8; + out1[8] = x9; + out1[9] = x10; +} + +/* + * The function fiat_25519_sub subtracts two field elements. + * + * Postconditions: + * eval out1 mod m = (eval arg1 - eval arg2) mod m + * + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_sub(fiat_25519_loose_field_element out1, const fiat_25519_tight_field_element arg1, const fiat_25519_tight_field_element arg2) { + uint32_t x1; + uint32_t x2; + uint32_t x3; + uint32_t x4; + uint32_t x5; + uint32_t x6; + uint32_t x7; + uint32_t x8; + uint32_t x9; + uint32_t x10; + x1 = ((UINT32_C(0x7ffffda) + (arg1[0])) - (arg2[0])); + x2 = ((UINT32_C(0x3fffffe) + (arg1[1])) - (arg2[1])); + x3 = ((UINT32_C(0x7fffffe) + (arg1[2])) - (arg2[2])); + x4 = ((UINT32_C(0x3fffffe) + (arg1[3])) - (arg2[3])); + x5 = ((UINT32_C(0x7fffffe) + (arg1[4])) - (arg2[4])); + x6 = ((UINT32_C(0x3fffffe) + (arg1[5])) - (arg2[5])); + x7 = ((UINT32_C(0x7fffffe) + (arg1[6])) - (arg2[6])); + x8 = ((UINT32_C(0x3fffffe) + (arg1[7])) - (arg2[7])); + x9 = ((UINT32_C(0x7fffffe) + (arg1[8])) - (arg2[8])); + x10 = ((UINT32_C(0x3fffffe) + (arg1[9])) - (arg2[9])); + out1[0] = x1; + out1[1] = x2; + out1[2] = x3; + out1[3] = x4; + out1[4] = x5; + out1[5] = x6; + out1[6] = x7; + out1[7] = x8; + out1[8] = x9; + out1[9] = x10; +} + +/* + * The function fiat_25519_opp negates a field element. + * + * Postconditions: + * eval out1 mod m = -eval arg1 mod m + * + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_opp(fiat_25519_loose_field_element out1, const fiat_25519_tight_field_element arg1) { + uint32_t x1; + uint32_t x2; + uint32_t x3; + uint32_t x4; + uint32_t x5; + uint32_t x6; + uint32_t x7; + uint32_t x8; + uint32_t x9; + uint32_t x10; + x1 = (UINT32_C(0x7ffffda) - (arg1[0])); + x2 = (UINT32_C(0x3fffffe) - (arg1[1])); + x3 = (UINT32_C(0x7fffffe) - (arg1[2])); + x4 = (UINT32_C(0x3fffffe) - (arg1[3])); + x5 = (UINT32_C(0x7fffffe) - (arg1[4])); + x6 = (UINT32_C(0x3fffffe) - (arg1[5])); + x7 = (UINT32_C(0x7fffffe) - (arg1[6])); + x8 = (UINT32_C(0x3fffffe) - (arg1[7])); + x9 = (UINT32_C(0x7fffffe) - (arg1[8])); + x10 = (UINT32_C(0x3fffffe) - (arg1[9])); + out1[0] = x1; + out1[1] = x2; + out1[2] = x3; + out1[3] = x4; + out1[4] = x5; + out1[5] = x6; + out1[6] = x7; + out1[7] = x8; + out1[8] = x9; + out1[9] = x10; +} + +/* + * The function fiat_25519_to_bytes serializes a field element to bytes in little-endian order. + * + * Postconditions: + * out1 = map (λ x, ⌊((eval arg1 mod m) mod 2^(8 * (x + 1))) / 2^(8 * x)⌋) [0..31] + * + * Output Bounds: + * out1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0x7f]] + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_to_bytes(uint8_t out1[32], const fiat_25519_tight_field_element arg1) { + uint32_t x1; + fiat_25519_uint1 x2; + uint32_t x3; + fiat_25519_uint1 x4; + uint32_t x5; + fiat_25519_uint1 x6; + uint32_t x7; + fiat_25519_uint1 x8; + uint32_t x9; + fiat_25519_uint1 x10; + uint32_t x11; + fiat_25519_uint1 x12; + uint32_t x13; + fiat_25519_uint1 x14; + uint32_t x15; + fiat_25519_uint1 x16; + uint32_t x17; + fiat_25519_uint1 x18; + uint32_t x19; + fiat_25519_uint1 x20; + uint32_t x21; + uint32_t x22; + fiat_25519_uint1 x23; + uint32_t x24; + fiat_25519_uint1 x25; + uint32_t x26; + fiat_25519_uint1 x27; + uint32_t x28; + fiat_25519_uint1 x29; + uint32_t x30; + fiat_25519_uint1 x31; + uint32_t x32; + fiat_25519_uint1 x33; + uint32_t x34; + fiat_25519_uint1 x35; + uint32_t x36; + fiat_25519_uint1 x37; + uint32_t x38; + fiat_25519_uint1 x39; + uint32_t x40; + fiat_25519_uint1 x41; + uint32_t x42; + uint32_t x43; + uint32_t x44; + uint32_t x45; + uint32_t x46; + uint32_t x47; + uint32_t x48; + uint32_t x49; + uint8_t x50; + uint32_t x51; + uint8_t x52; + uint32_t x53; + uint8_t x54; + uint8_t x55; + uint32_t x56; + uint8_t x57; + uint32_t x58; + uint8_t x59; + uint32_t x60; + uint8_t x61; + uint8_t x62; + uint32_t x63; + uint8_t x64; + uint32_t x65; + uint8_t x66; + uint32_t x67; + uint8_t x68; + uint8_t x69; + uint32_t x70; + uint8_t x71; + uint32_t x72; + uint8_t x73; + uint32_t x74; + uint8_t x75; + uint8_t x76; + uint32_t x77; + uint8_t x78; + uint32_t x79; + uint8_t x80; + uint32_t x81; + uint8_t x82; + uint8_t x83; + uint8_t x84; + uint32_t x85; + uint8_t x86; + uint32_t x87; + uint8_t x88; + fiat_25519_uint1 x89; + uint32_t x90; + uint8_t x91; + uint32_t x92; + uint8_t x93; + uint32_t x94; + uint8_t x95; + uint8_t x96; + uint32_t x97; + uint8_t x98; + uint32_t x99; + uint8_t x100; + uint32_t x101; + uint8_t x102; + uint8_t x103; + uint32_t x104; + uint8_t x105; + uint32_t x106; + uint8_t x107; + uint32_t x108; + uint8_t x109; + uint8_t x110; + uint32_t x111; + uint8_t x112; + uint32_t x113; + uint8_t x114; + uint32_t x115; + uint8_t x116; + uint8_t x117; + fiat_25519_subborrowx_u26(&x1, &x2, 0x0, (arg1[0]), UINT32_C(0x3ffffed)); + fiat_25519_subborrowx_u25(&x3, &x4, x2, (arg1[1]), UINT32_C(0x1ffffff)); + fiat_25519_subborrowx_u26(&x5, &x6, x4, (arg1[2]), UINT32_C(0x3ffffff)); + fiat_25519_subborrowx_u25(&x7, &x8, x6, (arg1[3]), UINT32_C(0x1ffffff)); + fiat_25519_subborrowx_u26(&x9, &x10, x8, (arg1[4]), UINT32_C(0x3ffffff)); + fiat_25519_subborrowx_u25(&x11, &x12, x10, (arg1[5]), UINT32_C(0x1ffffff)); + fiat_25519_subborrowx_u26(&x13, &x14, x12, (arg1[6]), UINT32_C(0x3ffffff)); + fiat_25519_subborrowx_u25(&x15, &x16, x14, (arg1[7]), UINT32_C(0x1ffffff)); + fiat_25519_subborrowx_u26(&x17, &x18, x16, (arg1[8]), UINT32_C(0x3ffffff)); + fiat_25519_subborrowx_u25(&x19, &x20, x18, (arg1[9]), UINT32_C(0x1ffffff)); + fiat_25519_cmovznz_u32(&x21, x20, 0x0, UINT32_C(0xffffffff)); + fiat_25519_addcarryx_u26(&x22, &x23, 0x0, x1, (x21 & UINT32_C(0x3ffffed))); + fiat_25519_addcarryx_u25(&x24, &x25, x23, x3, (x21 & UINT32_C(0x1ffffff))); + fiat_25519_addcarryx_u26(&x26, &x27, x25, x5, (x21 & UINT32_C(0x3ffffff))); + fiat_25519_addcarryx_u25(&x28, &x29, x27, x7, (x21 & UINT32_C(0x1ffffff))); + fiat_25519_addcarryx_u26(&x30, &x31, x29, x9, (x21 & UINT32_C(0x3ffffff))); + fiat_25519_addcarryx_u25(&x32, &x33, x31, x11, (x21 & UINT32_C(0x1ffffff))); + fiat_25519_addcarryx_u26(&x34, &x35, x33, x13, (x21 & UINT32_C(0x3ffffff))); + fiat_25519_addcarryx_u25(&x36, &x37, x35, x15, (x21 & UINT32_C(0x1ffffff))); + fiat_25519_addcarryx_u26(&x38, &x39, x37, x17, (x21 & UINT32_C(0x3ffffff))); + fiat_25519_addcarryx_u25(&x40, &x41, x39, x19, (x21 & UINT32_C(0x1ffffff))); + x42 = (x40 << 6); + x43 = (x38 << 4); + x44 = (x36 << 3); + x45 = (x34 * (uint32_t)0x2); + x46 = (x30 << 6); + x47 = (x28 << 5); + x48 = (x26 << 3); + x49 = (x24 << 2); + x50 = (uint8_t)(x22 & UINT8_C(0xff)); + x51 = (x22 >> 8); + x52 = (uint8_t)(x51 & UINT8_C(0xff)); + x53 = (x51 >> 8); + x54 = (uint8_t)(x53 & UINT8_C(0xff)); + x55 = (uint8_t)(x53 >> 8); + x56 = (x49 + (uint32_t)x55); + x57 = (uint8_t)(x56 & UINT8_C(0xff)); + x58 = (x56 >> 8); + x59 = (uint8_t)(x58 & UINT8_C(0xff)); + x60 = (x58 >> 8); + x61 = (uint8_t)(x60 & UINT8_C(0xff)); + x62 = (uint8_t)(x60 >> 8); + x63 = (x48 + (uint32_t)x62); + x64 = (uint8_t)(x63 & UINT8_C(0xff)); + x65 = (x63 >> 8); + x66 = (uint8_t)(x65 & UINT8_C(0xff)); + x67 = (x65 >> 8); + x68 = (uint8_t)(x67 & UINT8_C(0xff)); + x69 = (uint8_t)(x67 >> 8); + x70 = (x47 + (uint32_t)x69); + x71 = (uint8_t)(x70 & UINT8_C(0xff)); + x72 = (x70 >> 8); + x73 = (uint8_t)(x72 & UINT8_C(0xff)); + x74 = (x72 >> 8); + x75 = (uint8_t)(x74 & UINT8_C(0xff)); + x76 = (uint8_t)(x74 >> 8); + x77 = (x46 + (uint32_t)x76); + x78 = (uint8_t)(x77 & UINT8_C(0xff)); + x79 = (x77 >> 8); + x80 = (uint8_t)(x79 & UINT8_C(0xff)); + x81 = (x79 >> 8); + x82 = (uint8_t)(x81 & UINT8_C(0xff)); + x83 = (uint8_t)(x81 >> 8); + x84 = (uint8_t)(x32 & UINT8_C(0xff)); + x85 = (x32 >> 8); + x86 = (uint8_t)(x85 & UINT8_C(0xff)); + x87 = (x85 >> 8); + x88 = (uint8_t)(x87 & UINT8_C(0xff)); + x89 = (fiat_25519_uint1)(x87 >> 8); + x90 = (x45 + (uint32_t)x89); + x91 = (uint8_t)(x90 & UINT8_C(0xff)); + x92 = (x90 >> 8); + x93 = (uint8_t)(x92 & UINT8_C(0xff)); + x94 = (x92 >> 8); + x95 = (uint8_t)(x94 & UINT8_C(0xff)); + x96 = (uint8_t)(x94 >> 8); + x97 = (x44 + (uint32_t)x96); + x98 = (uint8_t)(x97 & UINT8_C(0xff)); + x99 = (x97 >> 8); + x100 = (uint8_t)(x99 & UINT8_C(0xff)); + x101 = (x99 >> 8); + x102 = (uint8_t)(x101 & UINT8_C(0xff)); + x103 = (uint8_t)(x101 >> 8); + x104 = (x43 + (uint32_t)x103); + x105 = (uint8_t)(x104 & UINT8_C(0xff)); + x106 = (x104 >> 8); + x107 = (uint8_t)(x106 & UINT8_C(0xff)); + x108 = (x106 >> 8); + x109 = (uint8_t)(x108 & UINT8_C(0xff)); + x110 = (uint8_t)(x108 >> 8); + x111 = (x42 + (uint32_t)x110); + x112 = (uint8_t)(x111 & UINT8_C(0xff)); + x113 = (x111 >> 8); + x114 = (uint8_t)(x113 & UINT8_C(0xff)); + x115 = (x113 >> 8); + x116 = (uint8_t)(x115 & UINT8_C(0xff)); + x117 = (uint8_t)(x115 >> 8); + out1[0] = x50; + out1[1] = x52; + out1[2] = x54; + out1[3] = x57; + out1[4] = x59; + out1[5] = x61; + out1[6] = x64; + out1[7] = x66; + out1[8] = x68; + out1[9] = x71; + out1[10] = x73; + out1[11] = x75; + out1[12] = x78; + out1[13] = x80; + out1[14] = x82; + out1[15] = x83; + out1[16] = x84; + out1[17] = x86; + out1[18] = x88; + out1[19] = x91; + out1[20] = x93; + out1[21] = x95; + out1[22] = x98; + out1[23] = x100; + out1[24] = x102; + out1[25] = x105; + out1[26] = x107; + out1[27] = x109; + out1[28] = x112; + out1[29] = x114; + out1[30] = x116; + out1[31] = x117; +} + +/* + * The function fiat_25519_from_bytes deserializes a field element from bytes in little-endian order. + * + * Postconditions: + * eval out1 mod m = bytes_eval arg1 mod m + * + * Input Bounds: + * arg1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0x7f]] + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_from_bytes(fiat_25519_tight_field_element out1, const uint8_t arg1[32]) { + uint32_t x1; + uint32_t x2; + uint32_t x3; + uint32_t x4; + uint32_t x5; + uint32_t x6; + uint32_t x7; + uint32_t x8; + uint32_t x9; + uint32_t x10; + uint32_t x11; + uint32_t x12; + uint32_t x13; + uint32_t x14; + uint32_t x15; + uint8_t x16; + uint32_t x17; + uint32_t x18; + uint32_t x19; + uint32_t x20; + uint32_t x21; + uint32_t x22; + uint32_t x23; + uint32_t x24; + uint32_t x25; + uint32_t x26; + uint32_t x27; + uint32_t x28; + uint32_t x29; + uint32_t x30; + uint32_t x31; + uint8_t x32; + uint32_t x33; + uint32_t x34; + uint32_t x35; + uint32_t x36; + uint8_t x37; + uint32_t x38; + uint32_t x39; + uint32_t x40; + uint32_t x41; + uint8_t x42; + uint32_t x43; + uint32_t x44; + uint32_t x45; + uint32_t x46; + uint8_t x47; + uint32_t x48; + uint32_t x49; + uint32_t x50; + uint32_t x51; + uint8_t x52; + uint32_t x53; + uint32_t x54; + uint32_t x55; + uint32_t x56; + uint32_t x57; + uint32_t x58; + uint32_t x59; + uint8_t x60; + uint32_t x61; + uint32_t x62; + uint32_t x63; + uint32_t x64; + uint8_t x65; + uint32_t x66; + uint32_t x67; + uint32_t x68; + uint32_t x69; + uint8_t x70; + uint32_t x71; + uint32_t x72; + uint32_t x73; + uint32_t x74; + uint8_t x75; + uint32_t x76; + uint32_t x77; + uint32_t x78; + x1 = ((uint32_t)(arg1[31]) << 18); + x2 = ((uint32_t)(arg1[30]) << 10); + x3 = ((uint32_t)(arg1[29]) << 2); + x4 = ((uint32_t)(arg1[28]) << 20); + x5 = ((uint32_t)(arg1[27]) << 12); + x6 = ((uint32_t)(arg1[26]) << 4); + x7 = ((uint32_t)(arg1[25]) << 21); + x8 = ((uint32_t)(arg1[24]) << 13); + x9 = ((uint32_t)(arg1[23]) << 5); + x10 = ((uint32_t)(arg1[22]) << 23); + x11 = ((uint32_t)(arg1[21]) << 15); + x12 = ((uint32_t)(arg1[20]) << 7); + x13 = ((uint32_t)(arg1[19]) << 24); + x14 = ((uint32_t)(arg1[18]) << 16); + x15 = ((uint32_t)(arg1[17]) << 8); + x16 = (arg1[16]); + x17 = ((uint32_t)(arg1[15]) << 18); + x18 = ((uint32_t)(arg1[14]) << 10); + x19 = ((uint32_t)(arg1[13]) << 2); + x20 = ((uint32_t)(arg1[12]) << 19); + x21 = ((uint32_t)(arg1[11]) << 11); + x22 = ((uint32_t)(arg1[10]) << 3); + x23 = ((uint32_t)(arg1[9]) << 21); + x24 = ((uint32_t)(arg1[8]) << 13); + x25 = ((uint32_t)(arg1[7]) << 5); + x26 = ((uint32_t)(arg1[6]) << 22); + x27 = ((uint32_t)(arg1[5]) << 14); + x28 = ((uint32_t)(arg1[4]) << 6); + x29 = ((uint32_t)(arg1[3]) << 24); + x30 = ((uint32_t)(arg1[2]) << 16); + x31 = ((uint32_t)(arg1[1]) << 8); + x32 = (arg1[0]); + x33 = (x31 + (uint32_t)x32); + x34 = (x30 + x33); + x35 = (x29 + x34); + x36 = (x35 & UINT32_C(0x3ffffff)); + x37 = (uint8_t)(x35 >> 26); + x38 = (x28 + (uint32_t)x37); + x39 = (x27 + x38); + x40 = (x26 + x39); + x41 = (x40 & UINT32_C(0x1ffffff)); + x42 = (uint8_t)(x40 >> 25); + x43 = (x25 + (uint32_t)x42); + x44 = (x24 + x43); + x45 = (x23 + x44); + x46 = (x45 & UINT32_C(0x3ffffff)); + x47 = (uint8_t)(x45 >> 26); + x48 = (x22 + (uint32_t)x47); + x49 = (x21 + x48); + x50 = (x20 + x49); + x51 = (x50 & UINT32_C(0x1ffffff)); + x52 = (uint8_t)(x50 >> 25); + x53 = (x19 + (uint32_t)x52); + x54 = (x18 + x53); + x55 = (x17 + x54); + x56 = (x15 + (uint32_t)x16); + x57 = (x14 + x56); + x58 = (x13 + x57); + x59 = (x58 & UINT32_C(0x1ffffff)); + x60 = (uint8_t)(x58 >> 25); + x61 = (x12 + (uint32_t)x60); + x62 = (x11 + x61); + x63 = (x10 + x62); + x64 = (x63 & UINT32_C(0x3ffffff)); + x65 = (uint8_t)(x63 >> 26); + x66 = (x9 + (uint32_t)x65); + x67 = (x8 + x66); + x68 = (x7 + x67); + x69 = (x68 & UINT32_C(0x1ffffff)); + x70 = (uint8_t)(x68 >> 25); + x71 = (x6 + (uint32_t)x70); + x72 = (x5 + x71); + x73 = (x4 + x72); + x74 = (x73 & UINT32_C(0x3ffffff)); + x75 = (uint8_t)(x73 >> 26); + x76 = (x3 + (uint32_t)x75); + x77 = (x2 + x76); + x78 = (x1 + x77); + out1[0] = x36; + out1[1] = x41; + out1[2] = x46; + out1[3] = x51; + out1[4] = x55; + out1[5] = x59; + out1[6] = x64; + out1[7] = x69; + out1[8] = x74; + out1[9] = x78; +} + +/* + * The function fiat_25519_carry_scmul_121666 multiplies a field element by 121666 and reduces the result. + * + * Postconditions: + * eval out1 mod m = (121666 * eval arg1) mod m + * + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_carry_scmul_121666(fiat_25519_tight_field_element out1, const fiat_25519_loose_field_element arg1) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + uint64_t x6; + uint64_t x7; + uint64_t x8; + uint64_t x9; + uint64_t x10; + uint32_t x11; + uint32_t x12; + uint64_t x13; + uint32_t x14; + uint32_t x15; + uint64_t x16; + uint32_t x17; + uint32_t x18; + uint64_t x19; + uint32_t x20; + uint32_t x21; + uint64_t x22; + uint32_t x23; + uint32_t x24; + uint64_t x25; + uint32_t x26; + uint32_t x27; + uint64_t x28; + uint32_t x29; + uint32_t x30; + uint64_t x31; + uint32_t x32; + uint32_t x33; + uint64_t x34; + uint32_t x35; + uint32_t x36; + uint64_t x37; + uint32_t x38; + uint32_t x39; + uint32_t x40; + uint32_t x41; + fiat_25519_uint1 x42; + uint32_t x43; + uint32_t x44; + fiat_25519_uint1 x45; + uint32_t x46; + uint32_t x47; + x1 = ((uint64_t)UINT32_C(0x1db42) * (arg1[9])); + x2 = ((uint64_t)UINT32_C(0x1db42) * (arg1[8])); + x3 = ((uint64_t)UINT32_C(0x1db42) * (arg1[7])); + x4 = ((uint64_t)UINT32_C(0x1db42) * (arg1[6])); + x5 = ((uint64_t)UINT32_C(0x1db42) * (arg1[5])); + x6 = ((uint64_t)UINT32_C(0x1db42) * (arg1[4])); + x7 = ((uint64_t)UINT32_C(0x1db42) * (arg1[3])); + x8 = ((uint64_t)UINT32_C(0x1db42) * (arg1[2])); + x9 = ((uint64_t)UINT32_C(0x1db42) * (arg1[1])); + x10 = ((uint64_t)UINT32_C(0x1db42) * (arg1[0])); + x11 = (uint32_t)(x10 >> 26); + x12 = (uint32_t)(x10 & UINT32_C(0x3ffffff)); + x13 = (x11 + x9); + x14 = (uint32_t)(x13 >> 25); + x15 = (uint32_t)(x13 & UINT32_C(0x1ffffff)); + x16 = (x14 + x8); + x17 = (uint32_t)(x16 >> 26); + x18 = (uint32_t)(x16 & UINT32_C(0x3ffffff)); + x19 = (x17 + x7); + x20 = (uint32_t)(x19 >> 25); + x21 = (uint32_t)(x19 & UINT32_C(0x1ffffff)); + x22 = (x20 + x6); + x23 = (uint32_t)(x22 >> 26); + x24 = (uint32_t)(x22 & UINT32_C(0x3ffffff)); + x25 = (x23 + x5); + x26 = (uint32_t)(x25 >> 25); + x27 = (uint32_t)(x25 & UINT32_C(0x1ffffff)); + x28 = (x26 + x4); + x29 = (uint32_t)(x28 >> 26); + x30 = (uint32_t)(x28 & UINT32_C(0x3ffffff)); + x31 = (x29 + x3); + x32 = (uint32_t)(x31 >> 25); + x33 = (uint32_t)(x31 & UINT32_C(0x1ffffff)); + x34 = (x32 + x2); + x35 = (uint32_t)(x34 >> 26); + x36 = (uint32_t)(x34 & UINT32_C(0x3ffffff)); + x37 = (x35 + x1); + x38 = (uint32_t)(x37 >> 25); + x39 = (uint32_t)(x37 & UINT32_C(0x1ffffff)); + x40 = (x38 * UINT8_C(0x13)); + x41 = (x12 + x40); + x42 = (fiat_25519_uint1)(x41 >> 26); + x43 = (x41 & UINT32_C(0x3ffffff)); + x44 = (x42 + x15); + x45 = (fiat_25519_uint1)(x44 >> 25); + x46 = (x44 & UINT32_C(0x1ffffff)); + x47 = (x45 + x18); + out1[0] = x43; + out1[1] = x46; + out1[2] = x47; + out1[3] = x21; + out1[4] = x24; + out1[5] = x27; + out1[6] = x30; + out1[7] = x33; + out1[8] = x36; + out1[9] = x39; +} diff --git a/http/vendor/ring/third_party/fiat/curve25519_64.h b/http/vendor/ring/third_party/fiat/curve25519_64.h new file mode 100644 index 0000000..ea2c23c --- /dev/null +++ b/http/vendor/ring/third_party/fiat/curve25519_64.h @@ -0,0 +1,916 @@ +/* Autogenerated: 'src/ExtractionOCaml/unsaturated_solinas' --inline --static --use-value-barrier 25519 64 '(auto)' '2^255 - 19' carry_mul carry_square carry add sub opp selectznz to_bytes from_bytes relax carry_scmul121666 */ +/* curve description: 25519 */ +/* machine_wordsize = 64 (from "64") */ +/* requested operations: carry_mul, carry_square, carry, add, sub, opp, selectznz, to_bytes, from_bytes, relax, carry_scmul121666 */ +/* n = 5 (from "(auto)") */ +/* s-c = 2^255 - [(1, 19)] (from "2^255 - 19") */ +/* tight_bounds_multiplier = 1 (from "") */ +/* */ +/* Computed values: */ +/* carry_chain = [0, 1, 2, 3, 4, 0, 1] */ +/* eval z = z[0] + (z[1] << 51) + (z[2] << 102) + (z[3] << 153) + (z[4] << 204) */ +/* bytes_eval z = z[0] + (z[1] << 8) + (z[2] << 16) + (z[3] << 24) + (z[4] << 32) + (z[5] << 40) + (z[6] << 48) + (z[7] << 56) + (z[8] << 64) + (z[9] << 72) + (z[10] << 80) + (z[11] << 88) + (z[12] << 96) + (z[13] << 104) + (z[14] << 112) + (z[15] << 120) + (z[16] << 128) + (z[17] << 136) + (z[18] << 144) + (z[19] << 152) + (z[20] << 160) + (z[21] << 168) + (z[22] << 176) + (z[23] << 184) + (z[24] << 192) + (z[25] << 200) + (z[26] << 208) + (z[27] << 216) + (z[28] << 224) + (z[29] << 232) + (z[30] << 240) + (z[31] << 248) */ +/* balance = [0xfffffffffffda, 0xffffffffffffe, 0xffffffffffffe, 0xffffffffffffe, 0xffffffffffffe] */ + +#include +typedef unsigned char fiat_25519_uint1; +typedef signed char fiat_25519_int1; +#if defined(__GNUC__) || defined(__clang__) +# define FIAT_25519_FIAT_EXTENSION __extension__ +# define FIAT_25519_FIAT_INLINE __inline__ +#else +# define FIAT_25519_FIAT_EXTENSION +# define FIAT_25519_FIAT_INLINE +#endif + +FIAT_25519_FIAT_EXTENSION typedef signed __int128 fiat_25519_int128; +FIAT_25519_FIAT_EXTENSION typedef unsigned __int128 fiat_25519_uint128; + +/* The type fiat_25519_loose_field_element is a field element with loose bounds. */ +/* Bounds: [[0x0 ~> 0x18000000000000], [0x0 ~> 0x18000000000000], [0x0 ~> 0x18000000000000], [0x0 ~> 0x18000000000000], [0x0 ~> 0x18000000000000]] */ +typedef uint64_t fiat_25519_loose_field_element[5]; + +/* The type fiat_25519_tight_field_element is a field element with tight bounds. */ +/* Bounds: [[0x0 ~> 0x8000000000000], [0x0 ~> 0x8000000000000], [0x0 ~> 0x8000000000000], [0x0 ~> 0x8000000000000], [0x0 ~> 0x8000000000000]] */ +typedef uint64_t fiat_25519_tight_field_element[5]; + +#if (-1 & 3) != 3 +#error "This code only works on a two's complement system" +#endif + +#if !defined(FIAT_25519_NO_ASM) && (defined(__GNUC__) || defined(__clang__)) +static __inline__ uint64_t fiat_25519_value_barrier_u64(uint64_t a) { + __asm__("" : "+r"(a) : /* no inputs */); + return a; +} +#else +# define fiat_25519_value_barrier_u64(x) (x) +#endif + + +/* + * The function fiat_25519_addcarryx_u51 is an addition with carry. + * + * Postconditions: + * out1 = (arg1 + arg2 + arg3) mod 2^51 + * out2 = ⌊(arg1 + arg2 + arg3) / 2^51⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0x7ffffffffffff] + * arg3: [0x0 ~> 0x7ffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0x7ffffffffffff] + * out2: [0x0 ~> 0x1] + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_addcarryx_u51(uint64_t* out1, fiat_25519_uint1* out2, fiat_25519_uint1 arg1, uint64_t arg2, uint64_t arg3) { + uint64_t x1; + uint64_t x2; + fiat_25519_uint1 x3; + x1 = ((arg1 + arg2) + arg3); + x2 = (x1 & UINT64_C(0x7ffffffffffff)); + x3 = (fiat_25519_uint1)(x1 >> 51); + *out1 = x2; + *out2 = x3; +} + +/* + * The function fiat_25519_subborrowx_u51 is a subtraction with borrow. + * + * Postconditions: + * out1 = (-arg1 + arg2 + -arg3) mod 2^51 + * out2 = -⌊(-arg1 + arg2 + -arg3) / 2^51⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0x7ffffffffffff] + * arg3: [0x0 ~> 0x7ffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0x7ffffffffffff] + * out2: [0x0 ~> 0x1] + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_subborrowx_u51(uint64_t* out1, fiat_25519_uint1* out2, fiat_25519_uint1 arg1, uint64_t arg2, uint64_t arg3) { + int64_t x1; + fiat_25519_int1 x2; + uint64_t x3; + x1 = ((int64_t)(arg2 - (int64_t)arg1) - (int64_t)arg3); + x2 = (fiat_25519_int1)(x1 >> 51); + x3 = (x1 & UINT64_C(0x7ffffffffffff)); + *out1 = x3; + *out2 = (fiat_25519_uint1)(0x0 - x2); +} + +/* + * The function fiat_25519_cmovznz_u64 is a single-word conditional move. + * + * Postconditions: + * out1 = (if arg1 = 0 then arg2 else arg3) + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0xffffffffffffffff] + * arg3: [0x0 ~> 0xffffffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_cmovznz_u64(uint64_t* out1, fiat_25519_uint1 arg1, uint64_t arg2, uint64_t arg3) { + fiat_25519_uint1 x1; + uint64_t x2; + uint64_t x3; + x1 = (!(!arg1)); + x2 = ((fiat_25519_int1)(0x0 - x1) & UINT64_C(0xffffffffffffffff)); + x3 = ((fiat_25519_value_barrier_u64(x2) & arg3) | (fiat_25519_value_barrier_u64((~x2)) & arg2)); + *out1 = x3; +} + +/* + * The function fiat_25519_carry_mul multiplies two field elements and reduces the result. + * + * Postconditions: + * eval out1 mod m = (eval arg1 * eval arg2) mod m + * + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_carry_mul(fiat_25519_tight_field_element out1, const fiat_25519_loose_field_element arg1, const fiat_25519_loose_field_element arg2) { + fiat_25519_uint128 x1; + fiat_25519_uint128 x2; + fiat_25519_uint128 x3; + fiat_25519_uint128 x4; + fiat_25519_uint128 x5; + fiat_25519_uint128 x6; + fiat_25519_uint128 x7; + fiat_25519_uint128 x8; + fiat_25519_uint128 x9; + fiat_25519_uint128 x10; + fiat_25519_uint128 x11; + fiat_25519_uint128 x12; + fiat_25519_uint128 x13; + fiat_25519_uint128 x14; + fiat_25519_uint128 x15; + fiat_25519_uint128 x16; + fiat_25519_uint128 x17; + fiat_25519_uint128 x18; + fiat_25519_uint128 x19; + fiat_25519_uint128 x20; + fiat_25519_uint128 x21; + fiat_25519_uint128 x22; + fiat_25519_uint128 x23; + fiat_25519_uint128 x24; + fiat_25519_uint128 x25; + fiat_25519_uint128 x26; + uint64_t x27; + uint64_t x28; + fiat_25519_uint128 x29; + fiat_25519_uint128 x30; + fiat_25519_uint128 x31; + fiat_25519_uint128 x32; + fiat_25519_uint128 x33; + uint64_t x34; + uint64_t x35; + fiat_25519_uint128 x36; + uint64_t x37; + uint64_t x38; + fiat_25519_uint128 x39; + uint64_t x40; + uint64_t x41; + fiat_25519_uint128 x42; + uint64_t x43; + uint64_t x44; + uint64_t x45; + uint64_t x46; + uint64_t x47; + uint64_t x48; + uint64_t x49; + fiat_25519_uint1 x50; + uint64_t x51; + uint64_t x52; + x1 = ((fiat_25519_uint128)(arg1[4]) * ((arg2[4]) * UINT8_C(0x13))); + x2 = ((fiat_25519_uint128)(arg1[4]) * ((arg2[3]) * UINT8_C(0x13))); + x3 = ((fiat_25519_uint128)(arg1[4]) * ((arg2[2]) * UINT8_C(0x13))); + x4 = ((fiat_25519_uint128)(arg1[4]) * ((arg2[1]) * UINT8_C(0x13))); + x5 = ((fiat_25519_uint128)(arg1[3]) * ((arg2[4]) * UINT8_C(0x13))); + x6 = ((fiat_25519_uint128)(arg1[3]) * ((arg2[3]) * UINT8_C(0x13))); + x7 = ((fiat_25519_uint128)(arg1[3]) * ((arg2[2]) * UINT8_C(0x13))); + x8 = ((fiat_25519_uint128)(arg1[2]) * ((arg2[4]) * UINT8_C(0x13))); + x9 = ((fiat_25519_uint128)(arg1[2]) * ((arg2[3]) * UINT8_C(0x13))); + x10 = ((fiat_25519_uint128)(arg1[1]) * ((arg2[4]) * UINT8_C(0x13))); + x11 = ((fiat_25519_uint128)(arg1[4]) * (arg2[0])); + x12 = ((fiat_25519_uint128)(arg1[3]) * (arg2[1])); + x13 = ((fiat_25519_uint128)(arg1[3]) * (arg2[0])); + x14 = ((fiat_25519_uint128)(arg1[2]) * (arg2[2])); + x15 = ((fiat_25519_uint128)(arg1[2]) * (arg2[1])); + x16 = ((fiat_25519_uint128)(arg1[2]) * (arg2[0])); + x17 = ((fiat_25519_uint128)(arg1[1]) * (arg2[3])); + x18 = ((fiat_25519_uint128)(arg1[1]) * (arg2[2])); + x19 = ((fiat_25519_uint128)(arg1[1]) * (arg2[1])); + x20 = ((fiat_25519_uint128)(arg1[1]) * (arg2[0])); + x21 = ((fiat_25519_uint128)(arg1[0]) * (arg2[4])); + x22 = ((fiat_25519_uint128)(arg1[0]) * (arg2[3])); + x23 = ((fiat_25519_uint128)(arg1[0]) * (arg2[2])); + x24 = ((fiat_25519_uint128)(arg1[0]) * (arg2[1])); + x25 = ((fiat_25519_uint128)(arg1[0]) * (arg2[0])); + x26 = (x25 + (x10 + (x9 + (x7 + x4)))); + x27 = (uint64_t)(x26 >> 51); + x28 = (uint64_t)(x26 & UINT64_C(0x7ffffffffffff)); + x29 = (x21 + (x17 + (x14 + (x12 + x11)))); + x30 = (x22 + (x18 + (x15 + (x13 + x1)))); + x31 = (x23 + (x19 + (x16 + (x5 + x2)))); + x32 = (x24 + (x20 + (x8 + (x6 + x3)))); + x33 = (x27 + x32); + x34 = (uint64_t)(x33 >> 51); + x35 = (uint64_t)(x33 & UINT64_C(0x7ffffffffffff)); + x36 = (x34 + x31); + x37 = (uint64_t)(x36 >> 51); + x38 = (uint64_t)(x36 & UINT64_C(0x7ffffffffffff)); + x39 = (x37 + x30); + x40 = (uint64_t)(x39 >> 51); + x41 = (uint64_t)(x39 & UINT64_C(0x7ffffffffffff)); + x42 = (x40 + x29); + x43 = (uint64_t)(x42 >> 51); + x44 = (uint64_t)(x42 & UINT64_C(0x7ffffffffffff)); + x45 = (x43 * UINT8_C(0x13)); + x46 = (x28 + x45); + x47 = (x46 >> 51); + x48 = (x46 & UINT64_C(0x7ffffffffffff)); + x49 = (x47 + x35); + x50 = (fiat_25519_uint1)(x49 >> 51); + x51 = (x49 & UINT64_C(0x7ffffffffffff)); + x52 = (x50 + x38); + out1[0] = x48; + out1[1] = x51; + out1[2] = x52; + out1[3] = x41; + out1[4] = x44; +} + +/* + * The function fiat_25519_carry_square squares a field element and reduces the result. + * + * Postconditions: + * eval out1 mod m = (eval arg1 * eval arg1) mod m + * + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_carry_square(fiat_25519_tight_field_element out1, const fiat_25519_loose_field_element arg1) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + uint64_t x6; + uint64_t x7; + uint64_t x8; + fiat_25519_uint128 x9; + fiat_25519_uint128 x10; + fiat_25519_uint128 x11; + fiat_25519_uint128 x12; + fiat_25519_uint128 x13; + fiat_25519_uint128 x14; + fiat_25519_uint128 x15; + fiat_25519_uint128 x16; + fiat_25519_uint128 x17; + fiat_25519_uint128 x18; + fiat_25519_uint128 x19; + fiat_25519_uint128 x20; + fiat_25519_uint128 x21; + fiat_25519_uint128 x22; + fiat_25519_uint128 x23; + fiat_25519_uint128 x24; + uint64_t x25; + uint64_t x26; + fiat_25519_uint128 x27; + fiat_25519_uint128 x28; + fiat_25519_uint128 x29; + fiat_25519_uint128 x30; + fiat_25519_uint128 x31; + uint64_t x32; + uint64_t x33; + fiat_25519_uint128 x34; + uint64_t x35; + uint64_t x36; + fiat_25519_uint128 x37; + uint64_t x38; + uint64_t x39; + fiat_25519_uint128 x40; + uint64_t x41; + uint64_t x42; + uint64_t x43; + uint64_t x44; + uint64_t x45; + uint64_t x46; + uint64_t x47; + fiat_25519_uint1 x48; + uint64_t x49; + uint64_t x50; + x1 = ((arg1[4]) * UINT8_C(0x13)); + x2 = (x1 * 0x2); + x3 = ((arg1[4]) * 0x2); + x4 = ((arg1[3]) * UINT8_C(0x13)); + x5 = (x4 * 0x2); + x6 = ((arg1[3]) * 0x2); + x7 = ((arg1[2]) * 0x2); + x8 = ((arg1[1]) * 0x2); + x9 = ((fiat_25519_uint128)(arg1[4]) * x1); + x10 = ((fiat_25519_uint128)(arg1[3]) * x2); + x11 = ((fiat_25519_uint128)(arg1[3]) * x4); + x12 = ((fiat_25519_uint128)(arg1[2]) * x2); + x13 = ((fiat_25519_uint128)(arg1[2]) * x5); + x14 = ((fiat_25519_uint128)(arg1[2]) * (arg1[2])); + x15 = ((fiat_25519_uint128)(arg1[1]) * x2); + x16 = ((fiat_25519_uint128)(arg1[1]) * x6); + x17 = ((fiat_25519_uint128)(arg1[1]) * x7); + x18 = ((fiat_25519_uint128)(arg1[1]) * (arg1[1])); + x19 = ((fiat_25519_uint128)(arg1[0]) * x3); + x20 = ((fiat_25519_uint128)(arg1[0]) * x6); + x21 = ((fiat_25519_uint128)(arg1[0]) * x7); + x22 = ((fiat_25519_uint128)(arg1[0]) * x8); + x23 = ((fiat_25519_uint128)(arg1[0]) * (arg1[0])); + x24 = (x23 + (x15 + x13)); + x25 = (uint64_t)(x24 >> 51); + x26 = (uint64_t)(x24 & UINT64_C(0x7ffffffffffff)); + x27 = (x19 + (x16 + x14)); + x28 = (x20 + (x17 + x9)); + x29 = (x21 + (x18 + x10)); + x30 = (x22 + (x12 + x11)); + x31 = (x25 + x30); + x32 = (uint64_t)(x31 >> 51); + x33 = (uint64_t)(x31 & UINT64_C(0x7ffffffffffff)); + x34 = (x32 + x29); + x35 = (uint64_t)(x34 >> 51); + x36 = (uint64_t)(x34 & UINT64_C(0x7ffffffffffff)); + x37 = (x35 + x28); + x38 = (uint64_t)(x37 >> 51); + x39 = (uint64_t)(x37 & UINT64_C(0x7ffffffffffff)); + x40 = (x38 + x27); + x41 = (uint64_t)(x40 >> 51); + x42 = (uint64_t)(x40 & UINT64_C(0x7ffffffffffff)); + x43 = (x41 * UINT8_C(0x13)); + x44 = (x26 + x43); + x45 = (x44 >> 51); + x46 = (x44 & UINT64_C(0x7ffffffffffff)); + x47 = (x45 + x33); + x48 = (fiat_25519_uint1)(x47 >> 51); + x49 = (x47 & UINT64_C(0x7ffffffffffff)); + x50 = (x48 + x36); + out1[0] = x46; + out1[1] = x49; + out1[2] = x50; + out1[3] = x39; + out1[4] = x42; +} + +/* + * The function fiat_25519_carry reduces a field element. + * + * Postconditions: + * eval out1 mod m = eval arg1 mod m + * + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_carry(fiat_25519_tight_field_element out1, const fiat_25519_loose_field_element arg1) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + uint64_t x6; + uint64_t x7; + uint64_t x8; + uint64_t x9; + uint64_t x10; + uint64_t x11; + uint64_t x12; + x1 = (arg1[0]); + x2 = ((x1 >> 51) + (arg1[1])); + x3 = ((x2 >> 51) + (arg1[2])); + x4 = ((x3 >> 51) + (arg1[3])); + x5 = ((x4 >> 51) + (arg1[4])); + x6 = ((x1 & UINT64_C(0x7ffffffffffff)) + ((x5 >> 51) * UINT8_C(0x13))); + x7 = ((fiat_25519_uint1)(x6 >> 51) + (x2 & UINT64_C(0x7ffffffffffff))); + x8 = (x6 & UINT64_C(0x7ffffffffffff)); + x9 = (x7 & UINT64_C(0x7ffffffffffff)); + x10 = ((fiat_25519_uint1)(x7 >> 51) + (x3 & UINT64_C(0x7ffffffffffff))); + x11 = (x4 & UINT64_C(0x7ffffffffffff)); + x12 = (x5 & UINT64_C(0x7ffffffffffff)); + out1[0] = x8; + out1[1] = x9; + out1[2] = x10; + out1[3] = x11; + out1[4] = x12; +} + +/* + * The function fiat_25519_add adds two field elements. + * + * Postconditions: + * eval out1 mod m = (eval arg1 + eval arg2) mod m + * + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_add(fiat_25519_loose_field_element out1, const fiat_25519_tight_field_element arg1, const fiat_25519_tight_field_element arg2) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + x1 = ((arg1[0]) + (arg2[0])); + x2 = ((arg1[1]) + (arg2[1])); + x3 = ((arg1[2]) + (arg2[2])); + x4 = ((arg1[3]) + (arg2[3])); + x5 = ((arg1[4]) + (arg2[4])); + out1[0] = x1; + out1[1] = x2; + out1[2] = x3; + out1[3] = x4; + out1[4] = x5; +} + +/* + * The function fiat_25519_sub subtracts two field elements. + * + * Postconditions: + * eval out1 mod m = (eval arg1 - eval arg2) mod m + * + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_sub(fiat_25519_loose_field_element out1, const fiat_25519_tight_field_element arg1, const fiat_25519_tight_field_element arg2) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + x1 = ((UINT64_C(0xfffffffffffda) + (arg1[0])) - (arg2[0])); + x2 = ((UINT64_C(0xffffffffffffe) + (arg1[1])) - (arg2[1])); + x3 = ((UINT64_C(0xffffffffffffe) + (arg1[2])) - (arg2[2])); + x4 = ((UINT64_C(0xffffffffffffe) + (arg1[3])) - (arg2[3])); + x5 = ((UINT64_C(0xffffffffffffe) + (arg1[4])) - (arg2[4])); + out1[0] = x1; + out1[1] = x2; + out1[2] = x3; + out1[3] = x4; + out1[4] = x5; +} + +/* + * The function fiat_25519_opp negates a field element. + * + * Postconditions: + * eval out1 mod m = -eval arg1 mod m + * + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_opp(fiat_25519_loose_field_element out1, const fiat_25519_tight_field_element arg1) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + x1 = (UINT64_C(0xfffffffffffda) - (arg1[0])); + x2 = (UINT64_C(0xffffffffffffe) - (arg1[1])); + x3 = (UINT64_C(0xffffffffffffe) - (arg1[2])); + x4 = (UINT64_C(0xffffffffffffe) - (arg1[3])); + x5 = (UINT64_C(0xffffffffffffe) - (arg1[4])); + out1[0] = x1; + out1[1] = x2; + out1[2] = x3; + out1[3] = x4; + out1[4] = x5; +} + +/* + * The function fiat_25519_to_bytes serializes a field element to bytes in little-endian order. + * + * Postconditions: + * out1 = map (λ x, ⌊((eval arg1 mod m) mod 2^(8 * (x + 1))) / 2^(8 * x)⌋) [0..31] + * + * Output Bounds: + * out1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0x7f]] + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_to_bytes(uint8_t out1[32], const fiat_25519_tight_field_element arg1) { + uint64_t x1; + fiat_25519_uint1 x2; + uint64_t x3; + fiat_25519_uint1 x4; + uint64_t x5; + fiat_25519_uint1 x6; + uint64_t x7; + fiat_25519_uint1 x8; + uint64_t x9; + fiat_25519_uint1 x10; + uint64_t x11; + uint64_t x12; + fiat_25519_uint1 x13; + uint64_t x14; + fiat_25519_uint1 x15; + uint64_t x16; + fiat_25519_uint1 x17; + uint64_t x18; + fiat_25519_uint1 x19; + uint64_t x20; + fiat_25519_uint1 x21; + uint64_t x22; + uint64_t x23; + uint64_t x24; + uint64_t x25; + uint8_t x26; + uint64_t x27; + uint8_t x28; + uint64_t x29; + uint8_t x30; + uint64_t x31; + uint8_t x32; + uint64_t x33; + uint8_t x34; + uint64_t x35; + uint8_t x36; + uint8_t x37; + uint64_t x38; + uint8_t x39; + uint64_t x40; + uint8_t x41; + uint64_t x42; + uint8_t x43; + uint64_t x44; + uint8_t x45; + uint64_t x46; + uint8_t x47; + uint64_t x48; + uint8_t x49; + uint8_t x50; + uint64_t x51; + uint8_t x52; + uint64_t x53; + uint8_t x54; + uint64_t x55; + uint8_t x56; + uint64_t x57; + uint8_t x58; + uint64_t x59; + uint8_t x60; + uint64_t x61; + uint8_t x62; + uint64_t x63; + uint8_t x64; + fiat_25519_uint1 x65; + uint64_t x66; + uint8_t x67; + uint64_t x68; + uint8_t x69; + uint64_t x70; + uint8_t x71; + uint64_t x72; + uint8_t x73; + uint64_t x74; + uint8_t x75; + uint64_t x76; + uint8_t x77; + uint8_t x78; + uint64_t x79; + uint8_t x80; + uint64_t x81; + uint8_t x82; + uint64_t x83; + uint8_t x84; + uint64_t x85; + uint8_t x86; + uint64_t x87; + uint8_t x88; + uint64_t x89; + uint8_t x90; + uint8_t x91; + fiat_25519_subborrowx_u51(&x1, &x2, 0x0, (arg1[0]), UINT64_C(0x7ffffffffffed)); + fiat_25519_subborrowx_u51(&x3, &x4, x2, (arg1[1]), UINT64_C(0x7ffffffffffff)); + fiat_25519_subborrowx_u51(&x5, &x6, x4, (arg1[2]), UINT64_C(0x7ffffffffffff)); + fiat_25519_subborrowx_u51(&x7, &x8, x6, (arg1[3]), UINT64_C(0x7ffffffffffff)); + fiat_25519_subborrowx_u51(&x9, &x10, x8, (arg1[4]), UINT64_C(0x7ffffffffffff)); + fiat_25519_cmovznz_u64(&x11, x10, 0x0, UINT64_C(0xffffffffffffffff)); + fiat_25519_addcarryx_u51(&x12, &x13, 0x0, x1, (x11 & UINT64_C(0x7ffffffffffed))); + fiat_25519_addcarryx_u51(&x14, &x15, x13, x3, (x11 & UINT64_C(0x7ffffffffffff))); + fiat_25519_addcarryx_u51(&x16, &x17, x15, x5, (x11 & UINT64_C(0x7ffffffffffff))); + fiat_25519_addcarryx_u51(&x18, &x19, x17, x7, (x11 & UINT64_C(0x7ffffffffffff))); + fiat_25519_addcarryx_u51(&x20, &x21, x19, x9, (x11 & UINT64_C(0x7ffffffffffff))); + x22 = (x20 << 4); + x23 = (x18 * (uint64_t)0x2); + x24 = (x16 << 6); + x25 = (x14 << 3); + x26 = (uint8_t)(x12 & UINT8_C(0xff)); + x27 = (x12 >> 8); + x28 = (uint8_t)(x27 & UINT8_C(0xff)); + x29 = (x27 >> 8); + x30 = (uint8_t)(x29 & UINT8_C(0xff)); + x31 = (x29 >> 8); + x32 = (uint8_t)(x31 & UINT8_C(0xff)); + x33 = (x31 >> 8); + x34 = (uint8_t)(x33 & UINT8_C(0xff)); + x35 = (x33 >> 8); + x36 = (uint8_t)(x35 & UINT8_C(0xff)); + x37 = (uint8_t)(x35 >> 8); + x38 = (x25 + (uint64_t)x37); + x39 = (uint8_t)(x38 & UINT8_C(0xff)); + x40 = (x38 >> 8); + x41 = (uint8_t)(x40 & UINT8_C(0xff)); + x42 = (x40 >> 8); + x43 = (uint8_t)(x42 & UINT8_C(0xff)); + x44 = (x42 >> 8); + x45 = (uint8_t)(x44 & UINT8_C(0xff)); + x46 = (x44 >> 8); + x47 = (uint8_t)(x46 & UINT8_C(0xff)); + x48 = (x46 >> 8); + x49 = (uint8_t)(x48 & UINT8_C(0xff)); + x50 = (uint8_t)(x48 >> 8); + x51 = (x24 + (uint64_t)x50); + x52 = (uint8_t)(x51 & UINT8_C(0xff)); + x53 = (x51 >> 8); + x54 = (uint8_t)(x53 & UINT8_C(0xff)); + x55 = (x53 >> 8); + x56 = (uint8_t)(x55 & UINT8_C(0xff)); + x57 = (x55 >> 8); + x58 = (uint8_t)(x57 & UINT8_C(0xff)); + x59 = (x57 >> 8); + x60 = (uint8_t)(x59 & UINT8_C(0xff)); + x61 = (x59 >> 8); + x62 = (uint8_t)(x61 & UINT8_C(0xff)); + x63 = (x61 >> 8); + x64 = (uint8_t)(x63 & UINT8_C(0xff)); + x65 = (fiat_25519_uint1)(x63 >> 8); + x66 = (x23 + (uint64_t)x65); + x67 = (uint8_t)(x66 & UINT8_C(0xff)); + x68 = (x66 >> 8); + x69 = (uint8_t)(x68 & UINT8_C(0xff)); + x70 = (x68 >> 8); + x71 = (uint8_t)(x70 & UINT8_C(0xff)); + x72 = (x70 >> 8); + x73 = (uint8_t)(x72 & UINT8_C(0xff)); + x74 = (x72 >> 8); + x75 = (uint8_t)(x74 & UINT8_C(0xff)); + x76 = (x74 >> 8); + x77 = (uint8_t)(x76 & UINT8_C(0xff)); + x78 = (uint8_t)(x76 >> 8); + x79 = (x22 + (uint64_t)x78); + x80 = (uint8_t)(x79 & UINT8_C(0xff)); + x81 = (x79 >> 8); + x82 = (uint8_t)(x81 & UINT8_C(0xff)); + x83 = (x81 >> 8); + x84 = (uint8_t)(x83 & UINT8_C(0xff)); + x85 = (x83 >> 8); + x86 = (uint8_t)(x85 & UINT8_C(0xff)); + x87 = (x85 >> 8); + x88 = (uint8_t)(x87 & UINT8_C(0xff)); + x89 = (x87 >> 8); + x90 = (uint8_t)(x89 & UINT8_C(0xff)); + x91 = (uint8_t)(x89 >> 8); + out1[0] = x26; + out1[1] = x28; + out1[2] = x30; + out1[3] = x32; + out1[4] = x34; + out1[5] = x36; + out1[6] = x39; + out1[7] = x41; + out1[8] = x43; + out1[9] = x45; + out1[10] = x47; + out1[11] = x49; + out1[12] = x52; + out1[13] = x54; + out1[14] = x56; + out1[15] = x58; + out1[16] = x60; + out1[17] = x62; + out1[18] = x64; + out1[19] = x67; + out1[20] = x69; + out1[21] = x71; + out1[22] = x73; + out1[23] = x75; + out1[24] = x77; + out1[25] = x80; + out1[26] = x82; + out1[27] = x84; + out1[28] = x86; + out1[29] = x88; + out1[30] = x90; + out1[31] = x91; +} + +/* + * The function fiat_25519_from_bytes deserializes a field element from bytes in little-endian order. + * + * Postconditions: + * eval out1 mod m = bytes_eval arg1 mod m + * + * Input Bounds: + * arg1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0x7f]] + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_from_bytes(fiat_25519_tight_field_element out1, const uint8_t arg1[32]) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + uint64_t x6; + uint64_t x7; + uint64_t x8; + uint64_t x9; + uint64_t x10; + uint64_t x11; + uint64_t x12; + uint64_t x13; + uint64_t x14; + uint64_t x15; + uint64_t x16; + uint64_t x17; + uint64_t x18; + uint64_t x19; + uint64_t x20; + uint64_t x21; + uint64_t x22; + uint64_t x23; + uint64_t x24; + uint64_t x25; + uint64_t x26; + uint64_t x27; + uint64_t x28; + uint64_t x29; + uint64_t x30; + uint64_t x31; + uint8_t x32; + uint64_t x33; + uint64_t x34; + uint64_t x35; + uint64_t x36; + uint64_t x37; + uint64_t x38; + uint64_t x39; + uint8_t x40; + uint64_t x41; + uint64_t x42; + uint64_t x43; + uint64_t x44; + uint64_t x45; + uint64_t x46; + uint64_t x47; + uint8_t x48; + uint64_t x49; + uint64_t x50; + uint64_t x51; + uint64_t x52; + uint64_t x53; + uint64_t x54; + uint64_t x55; + uint64_t x56; + uint8_t x57; + uint64_t x58; + uint64_t x59; + uint64_t x60; + uint64_t x61; + uint64_t x62; + uint64_t x63; + uint64_t x64; + uint8_t x65; + uint64_t x66; + uint64_t x67; + uint64_t x68; + uint64_t x69; + uint64_t x70; + uint64_t x71; + x1 = ((uint64_t)(arg1[31]) << 44); + x2 = ((uint64_t)(arg1[30]) << 36); + x3 = ((uint64_t)(arg1[29]) << 28); + x4 = ((uint64_t)(arg1[28]) << 20); + x5 = ((uint64_t)(arg1[27]) << 12); + x6 = ((uint64_t)(arg1[26]) << 4); + x7 = ((uint64_t)(arg1[25]) << 47); + x8 = ((uint64_t)(arg1[24]) << 39); + x9 = ((uint64_t)(arg1[23]) << 31); + x10 = ((uint64_t)(arg1[22]) << 23); + x11 = ((uint64_t)(arg1[21]) << 15); + x12 = ((uint64_t)(arg1[20]) << 7); + x13 = ((uint64_t)(arg1[19]) << 50); + x14 = ((uint64_t)(arg1[18]) << 42); + x15 = ((uint64_t)(arg1[17]) << 34); + x16 = ((uint64_t)(arg1[16]) << 26); + x17 = ((uint64_t)(arg1[15]) << 18); + x18 = ((uint64_t)(arg1[14]) << 10); + x19 = ((uint64_t)(arg1[13]) << 2); + x20 = ((uint64_t)(arg1[12]) << 45); + x21 = ((uint64_t)(arg1[11]) << 37); + x22 = ((uint64_t)(arg1[10]) << 29); + x23 = ((uint64_t)(arg1[9]) << 21); + x24 = ((uint64_t)(arg1[8]) << 13); + x25 = ((uint64_t)(arg1[7]) << 5); + x26 = ((uint64_t)(arg1[6]) << 48); + x27 = ((uint64_t)(arg1[5]) << 40); + x28 = ((uint64_t)(arg1[4]) << 32); + x29 = ((uint64_t)(arg1[3]) << 24); + x30 = ((uint64_t)(arg1[2]) << 16); + x31 = ((uint64_t)(arg1[1]) << 8); + x32 = (arg1[0]); + x33 = (x31 + (uint64_t)x32); + x34 = (x30 + x33); + x35 = (x29 + x34); + x36 = (x28 + x35); + x37 = (x27 + x36); + x38 = (x26 + x37); + x39 = (x38 & UINT64_C(0x7ffffffffffff)); + x40 = (uint8_t)(x38 >> 51); + x41 = (x25 + (uint64_t)x40); + x42 = (x24 + x41); + x43 = (x23 + x42); + x44 = (x22 + x43); + x45 = (x21 + x44); + x46 = (x20 + x45); + x47 = (x46 & UINT64_C(0x7ffffffffffff)); + x48 = (uint8_t)(x46 >> 51); + x49 = (x19 + (uint64_t)x48); + x50 = (x18 + x49); + x51 = (x17 + x50); + x52 = (x16 + x51); + x53 = (x15 + x52); + x54 = (x14 + x53); + x55 = (x13 + x54); + x56 = (x55 & UINT64_C(0x7ffffffffffff)); + x57 = (uint8_t)(x55 >> 51); + x58 = (x12 + (uint64_t)x57); + x59 = (x11 + x58); + x60 = (x10 + x59); + x61 = (x9 + x60); + x62 = (x8 + x61); + x63 = (x7 + x62); + x64 = (x63 & UINT64_C(0x7ffffffffffff)); + x65 = (uint8_t)(x63 >> 51); + x66 = (x6 + (uint64_t)x65); + x67 = (x5 + x66); + x68 = (x4 + x67); + x69 = (x3 + x68); + x70 = (x2 + x69); + x71 = (x1 + x70); + out1[0] = x39; + out1[1] = x47; + out1[2] = x56; + out1[3] = x64; + out1[4] = x71; +} + +/* + * The function fiat_25519_carry_scmul_121666 multiplies a field element by 121666 and reduces the result. + * + * Postconditions: + * eval out1 mod m = (121666 * eval arg1) mod m + * + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_carry_scmul_121666(fiat_25519_tight_field_element out1, const fiat_25519_loose_field_element arg1) { + fiat_25519_uint128 x1; + fiat_25519_uint128 x2; + fiat_25519_uint128 x3; + fiat_25519_uint128 x4; + fiat_25519_uint128 x5; + uint64_t x6; + uint64_t x7; + fiat_25519_uint128 x8; + uint64_t x9; + uint64_t x10; + fiat_25519_uint128 x11; + uint64_t x12; + uint64_t x13; + fiat_25519_uint128 x14; + uint64_t x15; + uint64_t x16; + fiat_25519_uint128 x17; + uint64_t x18; + uint64_t x19; + uint64_t x20; + uint64_t x21; + fiat_25519_uint1 x22; + uint64_t x23; + uint64_t x24; + fiat_25519_uint1 x25; + uint64_t x26; + uint64_t x27; + x1 = ((fiat_25519_uint128)UINT32_C(0x1db42) * (arg1[4])); + x2 = ((fiat_25519_uint128)UINT32_C(0x1db42) * (arg1[3])); + x3 = ((fiat_25519_uint128)UINT32_C(0x1db42) * (arg1[2])); + x4 = ((fiat_25519_uint128)UINT32_C(0x1db42) * (arg1[1])); + x5 = ((fiat_25519_uint128)UINT32_C(0x1db42) * (arg1[0])); + x6 = (uint64_t)(x5 >> 51); + x7 = (uint64_t)(x5 & UINT64_C(0x7ffffffffffff)); + x8 = (x6 + x4); + x9 = (uint64_t)(x8 >> 51); + x10 = (uint64_t)(x8 & UINT64_C(0x7ffffffffffff)); + x11 = (x9 + x3); + x12 = (uint64_t)(x11 >> 51); + x13 = (uint64_t)(x11 & UINT64_C(0x7ffffffffffff)); + x14 = (x12 + x2); + x15 = (uint64_t)(x14 >> 51); + x16 = (uint64_t)(x14 & UINT64_C(0x7ffffffffffff)); + x17 = (x15 + x1); + x18 = (uint64_t)(x17 >> 51); + x19 = (uint64_t)(x17 & UINT64_C(0x7ffffffffffff)); + x20 = (x18 * UINT8_C(0x13)); + x21 = (x7 + x20); + x22 = (fiat_25519_uint1)(x21 >> 51); + x23 = (x21 & UINT64_C(0x7ffffffffffff)); + x24 = (x22 + x10); + x25 = (fiat_25519_uint1)(x24 >> 51); + x26 = (x24 & UINT64_C(0x7ffffffffffff)); + x27 = (x25 + x13); + out1[0] = x23; + out1[1] = x26; + out1[2] = x27; + out1[3] = x16; + out1[4] = x19; +} diff --git a/http/vendor/ring/third_party/fiat/curve25519_64_adx.h b/http/vendor/ring/third_party/fiat/curve25519_64_adx.h new file mode 100644 index 0000000..02e8ad9 --- /dev/null +++ b/http/vendor/ring/third_party/fiat/curve25519_64_adx.h @@ -0,0 +1,695 @@ +#include +#include "../../crypto/internal.h" + +#include +#include +#include + +typedef uint64_t fe4[4]; +typedef uint8_t fiat_uint1; +typedef int8_t fiat_int1; + +static __inline__ uint64_t fiat_value_barrier_u64(uint64_t a) { + __asm__("" : "+r"(a) : /* no inputs */); + return a; +} + +__attribute__((target("adx,bmi2"))) +static inline void fe4_mul(fe4 out, const fe4 x, const fe4 y) { fiat_curve25519_adx_mul(out, x, y); } + +__attribute__((target("adx,bmi2"))) +static inline void fe4_sq(fe4 out, const fe4 x) { fiat_curve25519_adx_square(out, x); } + +/* + * The function fiat_mulx_u64 is a multiplication, returning the full double-width result. + * + * Postconditions: + * out1 = (arg1 * arg2) mod 2^64 + * out2 = ⌊arg1 * arg2 / 2^64⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0xffffffffffffffff] + * arg2: [0x0 ~> 0xffffffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + * out2: [0x0 ~> 0xffffffffffffffff] + */ +__attribute__((target("adx,bmi2"))) +static inline void fiat_mulx_u64(uint64_t* out1, uint64_t* out2, uint64_t arg1, uint64_t arg2) { +// NOTE: edited after generation +#if defined(_M_X64) + unsigned long long t; + *out1 = _umul128(arg1, arg2, &t); + *out2 = t; +#elif defined(_M_ARM64) + *out1 = arg1 * arg2; + *out2 = __umulh(arg1, arg2); +#else + unsigned __int128 t = (unsigned __int128)arg1 * arg2; + *out1 = t; + *out2 = (t >> 64); +#endif +} + +/* + * The function fiat_addcarryx_u64 is an addition with carry. + * + * Postconditions: + * out1 = (arg1 + arg2 + arg3) mod 2^64 + * out2 = ⌊(arg1 + arg2 + arg3) / 2^64⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0xffffffffffffffff] + * arg3: [0x0 ~> 0xffffffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + * out2: [0x0 ~> 0x1] + */ +__attribute__((target("adx,bmi2"))) +static inline void fiat_addcarryx_u64(uint64_t* out1, fiat_uint1* out2, fiat_uint1 arg1, uint64_t arg2, uint64_t arg3) { +// NOTE: edited after generation +#if defined(__has_builtin) +# if __has_builtin(__builtin_ia32_addcarryx_u64) +# define addcarry64 __builtin_ia32_addcarryx_u64 +# endif +#endif +#if defined(addcarry64) + long long unsigned int t; + *out2 = addcarry64(arg1, arg2, arg3, &t); + *out1 = t; +#elif defined(_M_X64) + long long unsigned int t; + *out2 = _addcarry_u64(arg1, arg2, arg3, out1); + *out1 = t; +#else + arg2 += arg1; + arg1 = arg2 < arg1; + uint64_t ret = arg2 + arg3; + arg1 += ret < arg2; + *out1 = ret; + *out2 = arg1; +#endif +#undef addcarry64 +} + +/* + * The function fiat_subborrowx_u64 is a subtraction with borrow. + * + * Postconditions: + * out1 = (-arg1 + arg2 + -arg3) mod 2^64 + * out2 = -⌊(-arg1 + arg2 + -arg3) / 2^64⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0xffffffffffffffff] + * arg3: [0x0 ~> 0xffffffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + * out2: [0x0 ~> 0x1] + */ +__attribute__((target("adx,bmi2"))) +static inline void fiat_subborrowx_u64(uint64_t* out1, fiat_uint1* out2, fiat_uint1 arg1, uint64_t arg2, uint64_t arg3) { +#if defined(__has_builtin) +# if __has_builtin(__builtin_ia32_subborrow_u64) +# define subborrow64 __builtin_ia32_subborrow_u64 +# endif +#endif +#if defined(subborrow64) + long long unsigned int t; + *out2 = subborrow64(arg1, arg2, arg3, &t); + *out1 = t; +#elif defined(_M_X64) + long long unsigned int t; + *out2 = _subborrow_u64(arg1, arg2, arg3, &t); // NOTE: edited after generation + *out1 = t; +#else + *out1 = arg2 - arg3 - arg1; + *out2 = (arg2 < arg3) | ((arg2 == arg3) & arg1); +#endif +#undef subborrow64 +} + +/* + * The function fiat_cmovznz_u64 is a single-word conditional move. + * + * Postconditions: + * out1 = (if arg1 = 0 then arg2 else arg3) + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0xffffffffffffffff] + * arg3: [0x0 ~> 0xffffffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + */ +__attribute__((target("adx,bmi2"))) +static inline void fiat_cmovznz_u64(uint64_t* out1, fiat_uint1 arg1, uint64_t arg2, uint64_t arg3) { + fiat_uint1 x1; + uint64_t x2; + uint64_t x3; + x1 = (!(!arg1)); + x2 = ((fiat_int1)(0x0 - x1) & UINT64_C(0xffffffffffffffff)); + x3 = ((fiat_value_barrier_u64(x2) & arg3) | (fiat_value_barrier_u64((~x2)) & arg2)); + *out1 = x3; +} + +/* + * Input Bounds: + * arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * Output Bounds: + * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + */ +__attribute__((target("adx,bmi2"))) +static void fe4_add(uint64_t out1[4], const uint64_t arg1[4], const uint64_t arg2[4]) { + uint64_t x1; + fiat_uint1 x2; + uint64_t x3; + fiat_uint1 x4; + uint64_t x5; + fiat_uint1 x6; + uint64_t x7; + fiat_uint1 x8; + uint64_t x9; + uint64_t x10; + fiat_uint1 x11; + uint64_t x12; + fiat_uint1 x13; + uint64_t x14; + fiat_uint1 x15; + uint64_t x16; + fiat_uint1 x17; + uint64_t x18; + uint64_t x19; + fiat_uint1 x20; + fiat_addcarryx_u64(&x1, &x2, 0x0, (arg1[0]), (arg2[0])); + fiat_addcarryx_u64(&x3, &x4, x2, (arg1[1]), (arg2[1])); + fiat_addcarryx_u64(&x5, &x6, x4, (arg1[2]), (arg2[2])); + fiat_addcarryx_u64(&x7, &x8, x6, (arg1[3]), (arg2[3])); + fiat_cmovznz_u64(&x9, x8, 0x0, UINT8_C(0x26)); // NOTE: clang 14 for Zen 2 uses sbb, and + fiat_addcarryx_u64(&x10, &x11, 0x0, x1, x9); + fiat_addcarryx_u64(&x12, &x13, x11, x3, 0x0); + fiat_addcarryx_u64(&x14, &x15, x13, x5, 0x0); + fiat_addcarryx_u64(&x16, &x17, x15, x7, 0x0); + fiat_cmovznz_u64(&x18, x17, 0x0, UINT8_C(0x26)); // NOTE: clang 14 for Zen 2 uses sbb, and + fiat_addcarryx_u64(&x19, &x20, 0x0, x10, x18); + out1[0] = x19; + out1[1] = x12; + out1[2] = x14; + out1[3] = x16; +} + +/* + * Input Bounds: + * arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * Output Bounds: + * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + */ +__attribute__((target("adx,bmi2"))) +static void fe4_sub(uint64_t out1[4], const uint64_t arg1[4], const uint64_t arg2[4]) { + uint64_t x1; + uint64_t x2; + fiat_uint1 x3; + uint64_t x4; + uint64_t x5; + fiat_uint1 x6; + uint64_t x7; + uint64_t x8; + fiat_uint1 x9; + uint64_t x10; + uint64_t x11; + fiat_uint1 x12; + uint64_t x13; + uint64_t x14; + fiat_uint1 x15; + uint64_t x16; + fiat_uint1 x17; + uint64_t x18; + fiat_uint1 x19; + uint64_t x20; + fiat_uint1 x21; + uint64_t x22; + uint64_t x23; + fiat_uint1 x24; + x1 = (arg2[0]); + fiat_subborrowx_u64(&x2, &x3, 0x0, (arg1[0]), x1); + x4 = (arg2[1]); + fiat_subborrowx_u64(&x5, &x6, x3, (arg1[1]), x4); + x7 = (arg2[2]); + fiat_subborrowx_u64(&x8, &x9, x6, (arg1[2]), x7); + x10 = (arg2[3]); + fiat_subborrowx_u64(&x11, &x12, x9, (arg1[3]), x10); + fiat_cmovznz_u64(&x13, x12, 0x0, UINT8_C(0x26)); // NOTE: clang 14 for Zen 2 uses sbb, and + fiat_subborrowx_u64(&x14, &x15, 0x0, x2, x13); + fiat_subborrowx_u64(&x16, &x17, x15, x5, 0x0); + fiat_subborrowx_u64(&x18, &x19, x17, x8, 0x0); + fiat_subborrowx_u64(&x20, &x21, x19, x11, 0x0); + fiat_cmovznz_u64(&x22, x21, 0x0, UINT8_C(0x26)); // NOTE: clang 14 for Zen 2 uses sbb, and + fiat_subborrowx_u64(&x23, &x24, 0x0, x14, x22); + out1[0] = x23; + out1[1] = x16; + out1[2] = x18; + out1[3] = x20; +} + +/* + * Input Bounds: + * arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * arg2: [0x0 ~> 0x3ffffffffffffff] // NOTE: this is not any uint64! + * Output Bounds: + * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + */ +__attribute__((target("adx,bmi2"))) +static void fe4_scmul(uint64_t out1[4], const uint64_t arg1[4], uint64_t arg2) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + fiat_uint1 x6; + uint64_t x7; + uint64_t x8; + uint64_t x9; + fiat_uint1 x10; + uint64_t x11; + uint64_t x12; + uint64_t x13; + fiat_uint1 x14; + uint64_t x15; + uint64_t x16; + uint64_t x17; + fiat_uint1 x18; + uint64_t x19; + fiat_uint1 x20; + uint64_t x21; + fiat_uint1 x22; + uint64_t x23; + fiat_uint1 x24; + uint64_t x25; + uint64_t x26; + fiat_uint1 x27; + fiat_mulx_u64(&x1, &x2, (arg1[0]), arg2); + fiat_mulx_u64(&x3, &x4, (arg1[1]), arg2); + fiat_addcarryx_u64(&x5, &x6, 0x0, x2, x3); + fiat_mulx_u64(&x7, &x8, (arg1[2]), arg2); + fiat_addcarryx_u64(&x9, &x10, x6, x4, x7); + fiat_mulx_u64(&x11, &x12, (arg1[3]), arg2); + fiat_addcarryx_u64(&x13, &x14, x10, x8, x11); + fiat_mulx_u64(&x15, &x16, (x12 + (uint64_t)x14), UINT8_C(0x26)); + fiat_addcarryx_u64(&x17, &x18, 0x0, x1, x15); + fiat_addcarryx_u64(&x19, &x20, x18, x5, 0x0); + fiat_addcarryx_u64(&x21, &x22, x20, x9, 0x0); + fiat_addcarryx_u64(&x23, &x24, x22, x13, 0x0); + fiat_cmovznz_u64(&x25, x24, 0x0, UINT8_C(0x26)); // NOTE: clang 14 for Zen 2 uses sbb, and + fiat_addcarryx_u64(&x26, &x27, 0x0, x17, x25); + out1[0] = x26; + out1[1] = x19; + out1[2] = x21; + out1[3] = x23; +} + +/* + * Input Bounds: + * arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * Output Bounds: + * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + */ +__attribute__((target("adx,bmi2"))) +static void fe4_canon(uint64_t out1[4], const uint64_t arg1[4]) { + uint64_t x1; + fiat_uint1 x2; + uint64_t x3; + fiat_uint1 x4; + uint64_t x5; + fiat_uint1 x6; + uint64_t x7; + fiat_uint1 x8; + uint64_t x9; + uint64_t x10; + uint64_t x11; + uint64_t x12; + uint64_t x13; + fiat_uint1 x14; + uint64_t x15; + fiat_uint1 x16; + uint64_t x17; + fiat_uint1 x18; + uint64_t x19; + fiat_uint1 x20; + uint64_t x21; + uint64_t x22; + uint64_t x23; + uint64_t x24; + fiat_subborrowx_u64(&x1, &x2, 0x0, (arg1[0]), UINT64_C(0xffffffffffffffed)); + fiat_subborrowx_u64(&x3, &x4, x2, (arg1[1]), UINT64_C(0xffffffffffffffff)); + fiat_subborrowx_u64(&x5, &x6, x4, (arg1[2]), UINT64_C(0xffffffffffffffff)); + fiat_subborrowx_u64(&x7, &x8, x6, (arg1[3]), UINT64_C(0x7fffffffffffffff)); + fiat_cmovznz_u64(&x9, x8, x1, (arg1[0])); + fiat_cmovznz_u64(&x10, x8, x3, (arg1[1])); + fiat_cmovznz_u64(&x11, x8, x5, (arg1[2])); + fiat_cmovznz_u64(&x12, x8, x7, (arg1[3])); + fiat_subborrowx_u64(&x13, &x14, 0x0, x9, UINT64_C(0xffffffffffffffed)); + fiat_subborrowx_u64(&x15, &x16, x14, x10, UINT64_C(0xffffffffffffffff)); + fiat_subborrowx_u64(&x17, &x18, x16, x11, UINT64_C(0xffffffffffffffff)); + fiat_subborrowx_u64(&x19, &x20, x18, x12, UINT64_C(0x7fffffffffffffff)); + fiat_cmovznz_u64(&x21, x20, x13, x9); + fiat_cmovznz_u64(&x22, x20, x15, x10); + fiat_cmovznz_u64(&x23, x20, x17, x11); + fiat_cmovznz_u64(&x24, x20, x19, x12); + out1[0] = x21; + out1[1] = x22; + out1[2] = x23; + out1[3] = x24; +} + +/* + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * arg3: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * Output Bounds: + * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * out2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + */ +__attribute__((target("adx,bmi2"))) +static void fe4_cswap(uint64_t out1[4], uint64_t out2[4], fiat_uint1 arg1, const uint64_t arg2[4], const uint64_t arg3[4]) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + uint64_t x6; + uint64_t x7; + uint64_t x8; + // NOTE: clang 14 for Zen 2 uses YMM registers + fiat_cmovznz_u64(&x1, arg1, (arg2[0]), (arg3[0])); + fiat_cmovznz_u64(&x2, arg1, (arg2[1]), (arg3[1])); + fiat_cmovznz_u64(&x3, arg1, (arg2[2]), (arg3[2])); + fiat_cmovznz_u64(&x4, arg1, (arg2[3]), (arg3[3])); + fiat_cmovznz_u64(&x5, arg1, (arg3[0]), (arg2[0])); + fiat_cmovznz_u64(&x6, arg1, (arg3[1]), (arg2[1])); + fiat_cmovznz_u64(&x7, arg1, (arg3[2]), (arg2[2])); + fiat_cmovznz_u64(&x8, arg1, (arg3[3]), (arg2[3])); + out1[0] = x1; + out1[1] = x2; + out1[2] = x3; + out1[3] = x4; + out2[0] = x5; + out2[1] = x6; + out2[2] = x7; + out2[3] = x8; +} + +// The following functions are adaped from crypto/curve25519/curve25519.c +// It would be desirable to share the code, but with the current field +// implementations both 4-limb and 5-limb versions of the curve-level code need +// to be included in builds targetting an unknown variant of x86_64. + +__attribute__((target("adx,bmi2"))) +static void fe4_invert(fe4 out, const fe4 z) { + fe4 t0; + fe4 t1; + fe4 t2; + fe4 t3; + int i; + + fe4_sq(t0, z); + fe4_sq(t1, t0); + for (i = 1; i < 2; ++i) { + fe4_sq(t1, t1); + } + fe4_mul(t1, z, t1); + fe4_mul(t0, t0, t1); + fe4_sq(t2, t0); + fe4_mul(t1, t1, t2); + fe4_sq(t2, t1); + for (i = 1; i < 5; ++i) { + fe4_sq(t2, t2); + } + fe4_mul(t1, t2, t1); + fe4_sq(t2, t1); + for (i = 1; i < 10; ++i) { + fe4_sq(t2, t2); + } + fe4_mul(t2, t2, t1); + fe4_sq(t3, t2); + for (i = 1; i < 20; ++i) { + fe4_sq(t3, t3); + } + fe4_mul(t2, t3, t2); + fe4_sq(t2, t2); + for (i = 1; i < 10; ++i) { + fe4_sq(t2, t2); + } + fe4_mul(t1, t2, t1); + fe4_sq(t2, t1); + for (i = 1; i < 50; ++i) { + fe4_sq(t2, t2); + } + fe4_mul(t2, t2, t1); + fe4_sq(t3, t2); + for (i = 1; i < 100; ++i) { + fe4_sq(t3, t3); + } + fe4_mul(t2, t3, t2); + fe4_sq(t2, t2); + for (i = 1; i < 50; ++i) { + fe4_sq(t2, t2); + } + fe4_mul(t1, t2, t1); + fe4_sq(t1, t1); + for (i = 1; i < 5; ++i) { + fe4_sq(t1, t1); + } + fe4_mul(out, t1, t0); +} + +RING_NOINLINE // https://github.com/rust-lang/rust/issues/116573 +__attribute__((target("adx,bmi2"))) +void x25519_scalar_mult_adx(uint8_t out[32], const uint8_t scalar[32], + const uint8_t point[32]) { + uint8_t e[32]; + OPENSSL_memcpy(e, scalar, 32); + e[0] &= 248; + e[31] &= 127; + e[31] |= 64; + + // The following implementation was transcribed to Coq and proven to + // correspond to unary scalar multiplication in affine coordinates given that + // x1 != 0 is the x coordinate of some point on the curve. It was also checked + // in Coq that doing a ladderstep with x1 = x3 = 0 gives z2' = z3' = 0, and z2 + // = z3 = 0 gives z2' = z3' = 0. The statement was quantified over the + // underlying field, so it applies to Curve25519 itself and the quadratic + // twist of Curve25519. It was not proven in Coq that prime-field arithmetic + // correctly simulates extension-field arithmetic on prime-field values. + // The decoding of the byte array representation of e was not considered. + // Specification of Montgomery curves in affine coordinates: + // + // Proof that these form a group that is isomorphic to a Weierstrass curve: + // + // Coq transcription and correctness proof of the loop (where scalarbits=255): + // + // + // preconditions: 0 <= e < 2^255 (not necessarily e < order), fe_invert(0) = 0 + fe4 x1, x2 = {1}, z2 = {0}, x3, z3 = {1}, tmp0, tmp1; + OPENSSL_memcpy(x1, point, sizeof(fe4)); + x1[3] &= (uint64_t)(-1)>>1; + OPENSSL_memcpy(x3, x1, sizeof(fe4)); + + unsigned swap = 0; + int pos; + for (pos = 254; pos >= 0; --pos) { + // loop invariant as of right before the test, for the case where x1 != 0: + // pos >= -1; if z2 = 0 then x2 is nonzero; if z3 = 0 then x3 is nonzero + // let r := e >> (pos+1) in the following equalities of projective points: + // to_xz (r*P) === if swap then (x3, z3) else (x2, z2) + // to_xz ((r+1)*P) === if swap then (x2, z2) else (x3, z3) + // x1 is the nonzero x coordinate of the nonzero point (r*P-(r+1)*P) + unsigned b = 1 & (e[pos / 8] >> (pos & 7)); + swap ^= b; + fe4_cswap(x2, x3, swap, x2, x3); + fe4_cswap(z2, z3, swap, z2, z3); + swap = b; + // Coq transcription of ladderstep formula (called from transcribed loop): + // + // + // x1 != 0 + // x1 = 0 + fe4_sub(tmp0, x3, z3); + fe4_sub(tmp1, x2, z2); + fe4_add(x2, x2, z2); + fe4_add(z2, x3, z3); + fe4_mul(z3, tmp0, x2); + fe4_mul(z2, z2, tmp1); + fe4_sq(tmp0, tmp1); + fe4_sq(tmp1, x2); + fe4_add(x3, z3, z2); + fe4_sub(z2, z3, z2); + fe4_mul(x2, tmp1, tmp0); + fe4_sub(tmp1, tmp1, tmp0); + fe4_sq(z2, z2); + fe4_scmul(z3, tmp1, 121666); + fe4_sq(x3, x3); + fe4_add(tmp0, tmp0, z3); + fe4_mul(z3, x1, z2); + fe4_mul(z2, tmp1, tmp0); + } + // here pos=-1, so r=e, so to_xz (e*P) === if swap then (x3, z3) else (x2, z2) + fe4_cswap(x2, x3, swap, x2, x3); + fe4_cswap(z2, z3, swap, z2, z3); + + fe4_invert(z2, z2); + fe4_mul(x2, x2, z2); + fe4_canon(x2, x2); + OPENSSL_memcpy(out, x2, sizeof(fe4)); +} + +typedef struct { + fe4 X; + fe4 Y; + fe4 Z; + fe4 T; +} ge_p3_4; + +typedef struct { + fe4 yplusx; + fe4 yminusx; + fe4 xy2d; +} ge_precomp_4; + +__attribute__((target("adx,bmi2"))) +static void inline_x25519_ge_dbl_4(ge_p3_4 *r, const ge_p3_4 *p, bool skip_t) { + // Transcribed from a Coq function proven against affine coordinates. + // https://github.com/mit-plv/fiat-crypto/blob/9943ba9e7d8f3e1c0054b2c94a5edca46ea73ef8/src/Curves/Edwards/XYZT/Basic.v#L136-L165 + fe4 trX, trZ, trT, t0, cX, cY, cZ, cT; + fe4_sq(trX, p->X); + fe4_sq(trZ, p->Y); + fe4_sq(trT, p->Z); + fe4_add(trT, trT, trT); + fe4_add(cY, p->X, p->Y); + fe4_sq(t0, cY); + fe4_add(cY, trZ, trX); + fe4_sub(cZ, trZ, trX); + fe4_sub(cX, t0, cY); + fe4_sub(cT, trT, cZ); + fe4_mul(r->X, cX, cT); + fe4_mul(r->Y, cY, cZ); + fe4_mul(r->Z, cZ, cT); + if (!skip_t) { + fe4_mul(r->T, cX, cY); + } +} + +__attribute__((target("adx,bmi2"))) +__attribute__((always_inline)) // 4% speedup with clang14 and zen2 +static inline void +ge_p3_add_p3_precomp_4(ge_p3_4 *r, const ge_p3_4 *p, const ge_precomp_4 *q) { + fe4 A, B, C, YplusX, YminusX, D, X3, Y3, Z3, T3; + // Transcribed from a Coq function proven against affine coordinates. + // https://github.com/mit-plv/fiat-crypto/blob/a36568d1d73aff5d7accc79fd28be672882f9c17/src/Curves/Edwards/XYZT/Precomputed.v#L38-L56 + fe4_add(YplusX, p->Y, p->X); + fe4_sub(YminusX, p->Y, p->X); + fe4_mul(A, YplusX, q->yplusx); + fe4_mul(B, YminusX, q->yminusx); + fe4_mul(C, q->xy2d, p->T); + fe4_add(D, p->Z, p->Z); + fe4_sub(X3, A, B); + fe4_add(Y3, A, B); + fe4_add(Z3, D, C); + fe4_sub(T3, D, C); + fe4_mul(r->X, X3, T3); + fe4_mul(r->Y, Y3, Z3); + fe4_mul(r->Z, Z3, T3); + fe4_mul(r->T, X3, Y3); +} + +__attribute__((always_inline)) // 25% speedup with clang14 and zen2 +static inline void table_select_4(ge_precomp_4 *t, const int pos, + const signed char b) { + uint8_t bnegative = constant_time_msb_w(b); + uint8_t babs = b - ((bnegative & b) << 1); + + uint8_t t_bytes[3][32] = { + {constant_time_is_zero_w(b) & 1}, {constant_time_is_zero_w(b) & 1}, {0}}; +#if defined(__clang__) + __asm__("" : "+m" (t_bytes) : /*no inputs*/); +#endif + OPENSSL_STATIC_ASSERT(sizeof(t_bytes) == sizeof(k25519Precomp[pos][0]), ""); + for (int i = 0; i < 8; i++) { + constant_time_conditional_memxor(t_bytes, k25519Precomp[pos][i], + sizeof(t_bytes), + constant_time_eq_w(babs, 1 + i)); + } + + OPENSSL_STATIC_ASSERT(sizeof(t_bytes) == sizeof(ge_precomp_4), ""); + + // fe4 uses saturated 64-bit limbs, so converting from bytes is just a copy. + OPENSSL_memcpy(t, t_bytes, sizeof(ge_precomp_4)); + + fe4 xy2d_neg = {0}; + fe4_sub(xy2d_neg, xy2d_neg, t->xy2d); + constant_time_conditional_memcpy(t->yplusx, t_bytes[1], sizeof(fe4), + bnegative); + constant_time_conditional_memcpy(t->yminusx, t_bytes[0], sizeof(fe4), + bnegative); + constant_time_conditional_memcpy(t->xy2d, xy2d_neg, sizeof(fe4), bnegative); +} + +// h = a * B +// where a = a[0]+256*a[1]+...+256^31 a[31] +// B is the Ed25519 base point (x,4/5) with x positive. +// +// Preconditions: +// a[31] <= 127 +RING_NOINLINE // https://github.com/rust-lang/rust/issues/116573 +__attribute__((target("adx,bmi2"))) +void x25519_ge_scalarmult_base_adx(uint8_t h[4][32], const uint8_t a[32]) { + signed char e[64]; + signed char carry; + + for (unsigned i = 0; i < 32; ++i) { + e[2 * i + 0] = (a[i] >> 0) & 15; + e[2 * i + 1] = (a[i] >> 4) & 15; + } + // each e[i] is between 0 and 15 + // e[63] is between 0 and 7 + + carry = 0; + for (unsigned i = 0; i < 63; ++i) { + e[i] += carry; + carry = e[i] + 8; + carry >>= 4; + e[i] -= carry << 4; + } + e[63] += carry; + // each e[i] is between -8 and 8 + + ge_p3_4 r = {{0}, {1}, {1}, {0}}; + for (unsigned i = 1; i < 64; i += 2) { + ge_precomp_4 t; + table_select_4(&t, i / 2, e[i]); + ge_p3_add_p3_precomp_4(&r, &r, &t); + } + + inline_x25519_ge_dbl_4(&r, &r, /*skip_t=*/true); + inline_x25519_ge_dbl_4(&r, &r, /*skip_t=*/true); + inline_x25519_ge_dbl_4(&r, &r, /*skip_t=*/true); + inline_x25519_ge_dbl_4(&r, &r, /*skip_t=*/false); + + for (unsigned i = 0; i < 64; i += 2) { + ge_precomp_4 t; + table_select_4(&t, i / 2, e[i]); + ge_p3_add_p3_precomp_4(&r, &r, &t); + } + + // fe4 uses saturated 64-bit limbs, so converting to bytes is just a copy. + // Satisfy stated precondition of fiat_25519_from_bytes; tests pass either way + fe4_canon(r.X, r.X); + fe4_canon(r.Y, r.Y); + fe4_canon(r.Z, r.Z); + fe4_canon(r.T, r.T); + OPENSSL_STATIC_ASSERT(sizeof(ge_p3_4) == sizeof(uint8_t[4][32]), ""); + OPENSSL_memcpy(h, &r, sizeof(ge_p3_4)); +} diff --git a/http/vendor/ring/third_party/fiat/curve25519_64_msvc.h b/http/vendor/ring/third_party/fiat/curve25519_64_msvc.h new file mode 100644 index 0000000..4b916e4 --- /dev/null +++ b/http/vendor/ring/third_party/fiat/curve25519_64_msvc.h @@ -0,0 +1,1225 @@ +/* Autogenerated: 'src/ExtractionOCaml/unsaturated_solinas' --inline --static --use-value-barrier --no-wide-int 25519 64 '(auto)' '2^255 - 19' carry_mul carry_square carry add sub opp selectznz to_bytes from_bytes relax carry_scmul121666 */ +/* curve description: 25519 */ +/* machine_wordsize = 64 (from "64") */ +/* requested operations: carry_mul, carry_square, carry, add, sub, opp, selectznz, to_bytes, from_bytes, relax, carry_scmul121666 */ +/* n = 5 (from "(auto)") */ +/* s-c = 2^255 - [(1, 19)] (from "2^255 - 19") */ +/* tight_bounds_multiplier = 1 (from "") */ +/* */ +/* Computed values: */ +/* carry_chain = [0, 1, 2, 3, 4, 0, 1] */ +/* eval z = z[0] + (z[1] << 51) + (z[2] << 102) + (z[3] << 153) + (z[4] << 204) */ +/* bytes_eval z = z[0] + (z[1] << 8) + (z[2] << 16) + (z[3] << 24) + (z[4] << 32) + (z[5] << 40) + (z[6] << 48) + (z[7] << 56) + (z[8] << 64) + (z[9] << 72) + (z[10] << 80) + (z[11] << 88) + (z[12] << 96) + (z[13] << 104) + (z[14] << 112) + (z[15] << 120) + (z[16] << 128) + (z[17] << 136) + (z[18] << 144) + (z[19] << 152) + (z[20] << 160) + (z[21] << 168) + (z[22] << 176) + (z[23] << 184) + (z[24] << 192) + (z[25] << 200) + (z[26] << 208) + (z[27] << 216) + (z[28] << 224) + (z[29] << 232) + (z[30] << 240) + (z[31] << 248) */ +/* balance = [0xfffffffffffda, 0xffffffffffffe, 0xffffffffffffe, 0xffffffffffffe, 0xffffffffffffe] */ + +#include +#include +#if defined(_M_X64) +#include +#endif + +typedef unsigned char fiat_25519_uint1; +typedef signed char fiat_25519_int1; + +#define FIAT_25519_FIAT_INLINE inline + +/* The type fiat_25519_loose_field_element is a field element with loose bounds. */ +/* Bounds: [[0x0 ~> 0x18000000000000], [0x0 ~> 0x18000000000000], [0x0 ~> 0x18000000000000], [0x0 ~> 0x18000000000000], [0x0 ~> 0x18000000000000]] */ +typedef uint64_t fiat_25519_loose_field_element[5]; + +/* The type fiat_25519_tight_field_element is a field element with tight bounds. */ +/* Bounds: [[0x0 ~> 0x8000000000000], [0x0 ~> 0x8000000000000], [0x0 ~> 0x8000000000000], [0x0 ~> 0x8000000000000], [0x0 ~> 0x8000000000000]] */ +typedef uint64_t fiat_25519_tight_field_element[5]; + +#if (-1 & 3) != 3 +#error "This code only works on a two's complement system" +#endif + +#define fiat_25519_value_barrier_u64(x) (x) + +/* + * The function fiat_25519_addcarryx_u64 is an addition with carry. + * + * Postconditions: + * out1 = (arg1 + arg2 + arg3) mod 2^64 + * out2 = ⌊(arg1 + arg2 + arg3) / 2^64⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0xffffffffffffffff] + * arg3: [0x0 ~> 0xffffffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + * out2: [0x0 ~> 0x1] + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_addcarryx_u64(uint64_t* out1, fiat_25519_uint1* out2, fiat_25519_uint1 arg1, uint64_t arg2, uint64_t arg3) { +// NOTE: edited after generation +#if defined(_M_X64) + *out2 = _addcarry_u64(arg1, arg2, arg3, out1); +#else + arg2 += arg1; + arg1 = arg2 < arg1; + arg3 += arg2; + arg1 += arg3 < arg2; + *out1 = arg3; + *out2 = arg1; +#endif +} + +/* + * The function fiat_25519_subborrowx_u64 is a subtraction with borrow. + * + * Postconditions: + * out1 = (-arg1 + arg2 + -arg3) mod 2^64 + * out2 = -⌊(-arg1 + arg2 + -arg3) / 2^64⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0xffffffffffffffff] + * arg3: [0x0 ~> 0xffffffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + * out2: [0x0 ~> 0x1] + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_subborrowx_u64(uint64_t* out1, fiat_25519_uint1* out2, fiat_25519_uint1 arg1, uint64_t arg2, uint64_t arg3) { +#if defined(_M_X64) + *out2 = _subborrow_u64(arg1, arg2, arg3, out1); // NOTE: edited after generation +#else + *out1 = arg2 - arg3 - arg1; + *out2 = (arg2 < arg3) | ((arg2 == arg3) & arg1); +#endif +} + +/* + * The function fiat_25519_addcarryx_u51 is an addition with carry. + * + * Postconditions: + * out1 = (arg1 + arg2 + arg3) mod 2^51 + * out2 = ⌊(arg1 + arg2 + arg3) / 2^51⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0x7ffffffffffff] + * arg3: [0x0 ~> 0x7ffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0x7ffffffffffff] + * out2: [0x0 ~> 0x1] + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_addcarryx_u51(uint64_t* out1, fiat_25519_uint1* out2, fiat_25519_uint1 arg1, uint64_t arg2, uint64_t arg3) { + uint64_t x1; + uint64_t x2; + fiat_25519_uint1 x3; + x1 = ((arg1 + arg2) + arg3); + x2 = (x1 & UINT64_C(0x7ffffffffffff)); + x3 = (fiat_25519_uint1)(x1 >> 51); + *out1 = x2; + *out2 = x3; +} + +/* + * The function fiat_25519_subborrowx_u51 is a subtraction with borrow. + * + * Postconditions: + * out1 = (-arg1 + arg2 + -arg3) mod 2^51 + * out2 = -⌊(-arg1 + arg2 + -arg3) / 2^51⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0x7ffffffffffff] + * arg3: [0x0 ~> 0x7ffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0x7ffffffffffff] + * out2: [0x0 ~> 0x1] + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_subborrowx_u51(uint64_t* out1, fiat_25519_uint1* out2, fiat_25519_uint1 arg1, uint64_t arg2, uint64_t arg3) { + int64_t x1; + fiat_25519_int1 x2; + uint64_t x3; + x1 = ((int64_t)(arg2 - (int64_t)arg1) - (int64_t)arg3); + x2 = (fiat_25519_int1)(x1 >> 51); + x3 = (x1 & UINT64_C(0x7ffffffffffff)); + *out1 = x3; + *out2 = (fiat_25519_uint1)(0x0 - x2); +} + +/* + * The function fiat_25519_mulx_u64 is a multiplication, returning the full double-width result. + * + * Postconditions: + * out1 = (arg1 * arg2) mod 2^64 + * out2 = ⌊arg1 * arg2 / 2^64⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0xffffffffffffffff] + * arg2: [0x0 ~> 0xffffffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + * out2: [0x0 ~> 0xffffffffffffffff] + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_mulx_u64(uint64_t* out1, uint64_t* out2, uint64_t arg1, uint64_t arg2) { +// NOTE: edited after generation +#if defined(_M_X64) + *out1 = _umul128(arg1, arg2, out2); +#elif defined(_M_ARM64) + *out1 = arg1 * arg2; + *out2 = __umulh(arg1, arg2); +#else +#error "This file is intended for MSVC on X64 or ARM64" +#endif +} + +/* + * The function fiat_25519_cmovznz_u64 is a single-word conditional move. + * + * Postconditions: + * out1 = (if arg1 = 0 then arg2 else arg3) + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0xffffffffffffffff] + * arg3: [0x0 ~> 0xffffffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_cmovznz_u64(uint64_t* out1, fiat_25519_uint1 arg1, uint64_t arg2, uint64_t arg3) { + fiat_25519_uint1 x1; + uint64_t x2; + uint64_t x3; + x1 = (!(!arg1)); + x2 = ((fiat_25519_int1)(0x0 - x1) & UINT64_C(0xffffffffffffffff)); + x3 = ((fiat_25519_value_barrier_u64(x2) & arg3) | (fiat_25519_value_barrier_u64((~x2)) & arg2)); + *out1 = x3; +} + +/* + * The function fiat_25519_carry_mul multiplies two field elements and reduces the result. + * + * Postconditions: + * eval out1 mod m = (eval arg1 * eval arg2) mod m + * + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_carry_mul(fiat_25519_tight_field_element out1, const fiat_25519_loose_field_element arg1, const fiat_25519_loose_field_element arg2) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + uint64_t x6; + uint64_t x7; + uint64_t x8; + uint64_t x9; + uint64_t x10; + uint64_t x11; + uint64_t x12; + uint64_t x13; + uint64_t x14; + uint64_t x15; + uint64_t x16; + uint64_t x17; + uint64_t x18; + uint64_t x19; + uint64_t x20; + uint64_t x21; + uint64_t x22; + uint64_t x23; + uint64_t x24; + uint64_t x25; + uint64_t x26; + uint64_t x27; + uint64_t x28; + uint64_t x29; + uint64_t x30; + uint64_t x31; + uint64_t x32; + uint64_t x33; + uint64_t x34; + uint64_t x35; + uint64_t x36; + uint64_t x37; + uint64_t x38; + uint64_t x39; + uint64_t x40; + uint64_t x41; + uint64_t x42; + uint64_t x43; + uint64_t x44; + uint64_t x45; + uint64_t x46; + uint64_t x47; + uint64_t x48; + uint64_t x49; + uint64_t x50; + uint64_t x51; + fiat_25519_uint1 x52; + uint64_t x53; + fiat_25519_uint1 x54; + uint64_t x55; + fiat_25519_uint1 x56; + uint64_t x57; + fiat_25519_uint1 x58; + uint64_t x59; + fiat_25519_uint1 x60; + uint64_t x61; + fiat_25519_uint1 x62; + uint64_t x63; + fiat_25519_uint1 x64; + uint64_t x65; + fiat_25519_uint1 x66; + uint64_t x67; + uint64_t x68; + uint64_t x69; + fiat_25519_uint1 x70; + uint64_t x71; + fiat_25519_uint1 x72; + uint64_t x73; + fiat_25519_uint1 x74; + uint64_t x75; + fiat_25519_uint1 x76; + uint64_t x77; + fiat_25519_uint1 x78; + uint64_t x79; + fiat_25519_uint1 x80; + uint64_t x81; + fiat_25519_uint1 x82; + uint64_t x83; + fiat_25519_uint1 x84; + uint64_t x85; + fiat_25519_uint1 x86; + uint64_t x87; + fiat_25519_uint1 x88; + uint64_t x89; + fiat_25519_uint1 x90; + uint64_t x91; + fiat_25519_uint1 x92; + uint64_t x93; + fiat_25519_uint1 x94; + uint64_t x95; + fiat_25519_uint1 x96; + uint64_t x97; + fiat_25519_uint1 x98; + uint64_t x99; + fiat_25519_uint1 x100; + uint64_t x101; + fiat_25519_uint1 x102; + uint64_t x103; + fiat_25519_uint1 x104; + uint64_t x105; + fiat_25519_uint1 x106; + uint64_t x107; + fiat_25519_uint1 x108; + uint64_t x109; + fiat_25519_uint1 x110; + uint64_t x111; + fiat_25519_uint1 x112; + uint64_t x113; + fiat_25519_uint1 x114; + uint64_t x115; + fiat_25519_uint1 x116; + uint64_t x117; + fiat_25519_uint1 x118; + uint64_t x119; + fiat_25519_uint1 x120; + uint64_t x121; + fiat_25519_uint1 x122; + uint64_t x123; + fiat_25519_uint1 x124; + uint64_t x125; + fiat_25519_uint1 x126; + uint64_t x127; + fiat_25519_uint1 x128; + uint64_t x129; + fiat_25519_uint1 x130; + uint64_t x131; + fiat_25519_uint1 x132; + uint64_t x133; + fiat_25519_uint1 x134; + uint64_t x135; + uint64_t x136; + uint64_t x137; + uint64_t x138; + fiat_25519_uint1 x139; + uint64_t x140; + uint64_t x141; + uint64_t x142; + uint64_t x143; + fiat_25519_uint1 x144; + uint64_t x145; + uint64_t x146; + uint64_t x147; + uint64_t x148; + fiat_25519_uint1 x149; + uint64_t x150; + uint64_t x151; + uint64_t x152; + uint64_t x153; + uint64_t x154; + uint64_t x155; + uint64_t x156; + uint64_t x157; + fiat_25519_uint1 x158; + uint64_t x159; + uint64_t x160; + fiat_25519_mulx_u64(&x1, &x2, (arg1[4]), ((arg2[4]) * UINT8_C(0x13))); + fiat_25519_mulx_u64(&x3, &x4, (arg1[4]), ((arg2[3]) * UINT8_C(0x13))); + fiat_25519_mulx_u64(&x5, &x6, (arg1[4]), ((arg2[2]) * UINT8_C(0x13))); + fiat_25519_mulx_u64(&x7, &x8, (arg1[4]), ((arg2[1]) * UINT8_C(0x13))); + fiat_25519_mulx_u64(&x9, &x10, (arg1[3]), ((arg2[4]) * UINT8_C(0x13))); + fiat_25519_mulx_u64(&x11, &x12, (arg1[3]), ((arg2[3]) * UINT8_C(0x13))); + fiat_25519_mulx_u64(&x13, &x14, (arg1[3]), ((arg2[2]) * UINT8_C(0x13))); + fiat_25519_mulx_u64(&x15, &x16, (arg1[2]), ((arg2[4]) * UINT8_C(0x13))); + fiat_25519_mulx_u64(&x17, &x18, (arg1[2]), ((arg2[3]) * UINT8_C(0x13))); + fiat_25519_mulx_u64(&x19, &x20, (arg1[1]), ((arg2[4]) * UINT8_C(0x13))); + fiat_25519_mulx_u64(&x21, &x22, (arg1[4]), (arg2[0])); + fiat_25519_mulx_u64(&x23, &x24, (arg1[3]), (arg2[1])); + fiat_25519_mulx_u64(&x25, &x26, (arg1[3]), (arg2[0])); + fiat_25519_mulx_u64(&x27, &x28, (arg1[2]), (arg2[2])); + fiat_25519_mulx_u64(&x29, &x30, (arg1[2]), (arg2[1])); + fiat_25519_mulx_u64(&x31, &x32, (arg1[2]), (arg2[0])); + fiat_25519_mulx_u64(&x33, &x34, (arg1[1]), (arg2[3])); + fiat_25519_mulx_u64(&x35, &x36, (arg1[1]), (arg2[2])); + fiat_25519_mulx_u64(&x37, &x38, (arg1[1]), (arg2[1])); + fiat_25519_mulx_u64(&x39, &x40, (arg1[1]), (arg2[0])); + fiat_25519_mulx_u64(&x41, &x42, (arg1[0]), (arg2[4])); + fiat_25519_mulx_u64(&x43, &x44, (arg1[0]), (arg2[3])); + fiat_25519_mulx_u64(&x45, &x46, (arg1[0]), (arg2[2])); + fiat_25519_mulx_u64(&x47, &x48, (arg1[0]), (arg2[1])); + fiat_25519_mulx_u64(&x49, &x50, (arg1[0]), (arg2[0])); + fiat_25519_addcarryx_u64(&x51, &x52, 0x0, x13, x7); + fiat_25519_addcarryx_u64(&x53, &x54, x52, x14, x8); + fiat_25519_addcarryx_u64(&x55, &x56, 0x0, x17, x51); + fiat_25519_addcarryx_u64(&x57, &x58, x56, x18, x53); + fiat_25519_addcarryx_u64(&x59, &x60, 0x0, x19, x55); + fiat_25519_addcarryx_u64(&x61, &x62, x60, x20, x57); + fiat_25519_addcarryx_u64(&x63, &x64, 0x0, x49, x59); + fiat_25519_addcarryx_u64(&x65, &x66, x64, x50, x61); + x67 = ((x63 >> 51) | ((x65 << 13) & UINT64_C(0xffffffffffffffff))); + x68 = (x63 & UINT64_C(0x7ffffffffffff)); + fiat_25519_addcarryx_u64(&x69, &x70, 0x0, x23, x21); + fiat_25519_addcarryx_u64(&x71, &x72, x70, x24, x22); + fiat_25519_addcarryx_u64(&x73, &x74, 0x0, x27, x69); + fiat_25519_addcarryx_u64(&x75, &x76, x74, x28, x71); + fiat_25519_addcarryx_u64(&x77, &x78, 0x0, x33, x73); + fiat_25519_addcarryx_u64(&x79, &x80, x78, x34, x75); + fiat_25519_addcarryx_u64(&x81, &x82, 0x0, x41, x77); + fiat_25519_addcarryx_u64(&x83, &x84, x82, x42, x79); + fiat_25519_addcarryx_u64(&x85, &x86, 0x0, x25, x1); + fiat_25519_addcarryx_u64(&x87, &x88, x86, x26, x2); + fiat_25519_addcarryx_u64(&x89, &x90, 0x0, x29, x85); + fiat_25519_addcarryx_u64(&x91, &x92, x90, x30, x87); + fiat_25519_addcarryx_u64(&x93, &x94, 0x0, x35, x89); + fiat_25519_addcarryx_u64(&x95, &x96, x94, x36, x91); + fiat_25519_addcarryx_u64(&x97, &x98, 0x0, x43, x93); + fiat_25519_addcarryx_u64(&x99, &x100, x98, x44, x95); + fiat_25519_addcarryx_u64(&x101, &x102, 0x0, x9, x3); + fiat_25519_addcarryx_u64(&x103, &x104, x102, x10, x4); + fiat_25519_addcarryx_u64(&x105, &x106, 0x0, x31, x101); + fiat_25519_addcarryx_u64(&x107, &x108, x106, x32, x103); + fiat_25519_addcarryx_u64(&x109, &x110, 0x0, x37, x105); + fiat_25519_addcarryx_u64(&x111, &x112, x110, x38, x107); + fiat_25519_addcarryx_u64(&x113, &x114, 0x0, x45, x109); + fiat_25519_addcarryx_u64(&x115, &x116, x114, x46, x111); + fiat_25519_addcarryx_u64(&x117, &x118, 0x0, x11, x5); + fiat_25519_addcarryx_u64(&x119, &x120, x118, x12, x6); + fiat_25519_addcarryx_u64(&x121, &x122, 0x0, x15, x117); + fiat_25519_addcarryx_u64(&x123, &x124, x122, x16, x119); + fiat_25519_addcarryx_u64(&x125, &x126, 0x0, x39, x121); + fiat_25519_addcarryx_u64(&x127, &x128, x126, x40, x123); + fiat_25519_addcarryx_u64(&x129, &x130, 0x0, x47, x125); + fiat_25519_addcarryx_u64(&x131, &x132, x130, x48, x127); + fiat_25519_addcarryx_u64(&x133, &x134, 0x0, x67, x129); + x135 = (x134 + x131); + x136 = ((x133 >> 51) | ((x135 << 13) & UINT64_C(0xffffffffffffffff))); + x137 = (x133 & UINT64_C(0x7ffffffffffff)); + fiat_25519_addcarryx_u64(&x138, &x139, 0x0, x136, x113); + x140 = (x139 + x115); + x141 = ((x138 >> 51) | ((x140 << 13) & UINT64_C(0xffffffffffffffff))); + x142 = (x138 & UINT64_C(0x7ffffffffffff)); + fiat_25519_addcarryx_u64(&x143, &x144, 0x0, x141, x97); + x145 = (x144 + x99); + x146 = ((x143 >> 51) | ((x145 << 13) & UINT64_C(0xffffffffffffffff))); + x147 = (x143 & UINT64_C(0x7ffffffffffff)); + fiat_25519_addcarryx_u64(&x148, &x149, 0x0, x146, x81); + x150 = (x149 + x83); + x151 = ((x148 >> 51) | ((x150 << 13) & UINT64_C(0xffffffffffffffff))); + x152 = (x148 & UINT64_C(0x7ffffffffffff)); + x153 = (x151 * UINT8_C(0x13)); + x154 = (x68 + x153); + x155 = (x154 >> 51); + x156 = (x154 & UINT64_C(0x7ffffffffffff)); + x157 = (x155 + x137); + x158 = (fiat_25519_uint1)(x157 >> 51); + x159 = (x157 & UINT64_C(0x7ffffffffffff)); + x160 = (x158 + x142); + out1[0] = x156; + out1[1] = x159; + out1[2] = x160; + out1[3] = x147; + out1[4] = x152; +} + +/* + * The function fiat_25519_carry_square squares a field element and reduces the result. + * + * Postconditions: + * eval out1 mod m = (eval arg1 * eval arg1) mod m + * + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_carry_square(fiat_25519_tight_field_element out1, const fiat_25519_loose_field_element arg1) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + uint64_t x6; + uint64_t x7; + uint64_t x8; + uint64_t x9; + uint64_t x10; + uint64_t x11; + uint64_t x12; + uint64_t x13; + uint64_t x14; + uint64_t x15; + uint64_t x16; + uint64_t x17; + uint64_t x18; + uint64_t x19; + uint64_t x20; + uint64_t x21; + uint64_t x22; + uint64_t x23; + uint64_t x24; + uint64_t x25; + uint64_t x26; + uint64_t x27; + uint64_t x28; + uint64_t x29; + uint64_t x30; + uint64_t x31; + uint64_t x32; + uint64_t x33; + uint64_t x34; + uint64_t x35; + uint64_t x36; + uint64_t x37; + uint64_t x38; + uint64_t x39; + fiat_25519_uint1 x40; + uint64_t x41; + fiat_25519_uint1 x42; + uint64_t x43; + fiat_25519_uint1 x44; + uint64_t x45; + fiat_25519_uint1 x46; + uint64_t x47; + uint64_t x48; + uint64_t x49; + fiat_25519_uint1 x50; + uint64_t x51; + fiat_25519_uint1 x52; + uint64_t x53; + fiat_25519_uint1 x54; + uint64_t x55; + fiat_25519_uint1 x56; + uint64_t x57; + fiat_25519_uint1 x58; + uint64_t x59; + fiat_25519_uint1 x60; + uint64_t x61; + fiat_25519_uint1 x62; + uint64_t x63; + fiat_25519_uint1 x64; + uint64_t x65; + fiat_25519_uint1 x66; + uint64_t x67; + fiat_25519_uint1 x68; + uint64_t x69; + fiat_25519_uint1 x70; + uint64_t x71; + fiat_25519_uint1 x72; + uint64_t x73; + fiat_25519_uint1 x74; + uint64_t x75; + fiat_25519_uint1 x76; + uint64_t x77; + fiat_25519_uint1 x78; + uint64_t x79; + fiat_25519_uint1 x80; + uint64_t x81; + fiat_25519_uint1 x82; + uint64_t x83; + uint64_t x84; + uint64_t x85; + uint64_t x86; + fiat_25519_uint1 x87; + uint64_t x88; + uint64_t x89; + uint64_t x90; + uint64_t x91; + fiat_25519_uint1 x92; + uint64_t x93; + uint64_t x94; + uint64_t x95; + uint64_t x96; + fiat_25519_uint1 x97; + uint64_t x98; + uint64_t x99; + uint64_t x100; + uint64_t x101; + uint64_t x102; + uint64_t x103; + uint64_t x104; + uint64_t x105; + fiat_25519_uint1 x106; + uint64_t x107; + uint64_t x108; + x1 = ((arg1[4]) * UINT8_C(0x13)); + x2 = (x1 * 0x2); + x3 = ((arg1[4]) * 0x2); + x4 = ((arg1[3]) * UINT8_C(0x13)); + x5 = (x4 * 0x2); + x6 = ((arg1[3]) * 0x2); + x7 = ((arg1[2]) * 0x2); + x8 = ((arg1[1]) * 0x2); + fiat_25519_mulx_u64(&x9, &x10, (arg1[4]), x1); + fiat_25519_mulx_u64(&x11, &x12, (arg1[3]), x2); + fiat_25519_mulx_u64(&x13, &x14, (arg1[3]), x4); + fiat_25519_mulx_u64(&x15, &x16, (arg1[2]), x2); + fiat_25519_mulx_u64(&x17, &x18, (arg1[2]), x5); + fiat_25519_mulx_u64(&x19, &x20, (arg1[2]), (arg1[2])); + fiat_25519_mulx_u64(&x21, &x22, (arg1[1]), x2); + fiat_25519_mulx_u64(&x23, &x24, (arg1[1]), x6); + fiat_25519_mulx_u64(&x25, &x26, (arg1[1]), x7); + fiat_25519_mulx_u64(&x27, &x28, (arg1[1]), (arg1[1])); + fiat_25519_mulx_u64(&x29, &x30, (arg1[0]), x3); + fiat_25519_mulx_u64(&x31, &x32, (arg1[0]), x6); + fiat_25519_mulx_u64(&x33, &x34, (arg1[0]), x7); + fiat_25519_mulx_u64(&x35, &x36, (arg1[0]), x8); + fiat_25519_mulx_u64(&x37, &x38, (arg1[0]), (arg1[0])); + fiat_25519_addcarryx_u64(&x39, &x40, 0x0, x21, x17); + fiat_25519_addcarryx_u64(&x41, &x42, x40, x22, x18); + fiat_25519_addcarryx_u64(&x43, &x44, 0x0, x37, x39); + fiat_25519_addcarryx_u64(&x45, &x46, x44, x38, x41); + x47 = ((x43 >> 51) | ((x45 << 13) & UINT64_C(0xffffffffffffffff))); + x48 = (x43 & UINT64_C(0x7ffffffffffff)); + fiat_25519_addcarryx_u64(&x49, &x50, 0x0, x23, x19); + fiat_25519_addcarryx_u64(&x51, &x52, x50, x24, x20); + fiat_25519_addcarryx_u64(&x53, &x54, 0x0, x29, x49); + fiat_25519_addcarryx_u64(&x55, &x56, x54, x30, x51); + fiat_25519_addcarryx_u64(&x57, &x58, 0x0, x25, x9); + fiat_25519_addcarryx_u64(&x59, &x60, x58, x26, x10); + fiat_25519_addcarryx_u64(&x61, &x62, 0x0, x31, x57); + fiat_25519_addcarryx_u64(&x63, &x64, x62, x32, x59); + fiat_25519_addcarryx_u64(&x65, &x66, 0x0, x27, x11); + fiat_25519_addcarryx_u64(&x67, &x68, x66, x28, x12); + fiat_25519_addcarryx_u64(&x69, &x70, 0x0, x33, x65); + fiat_25519_addcarryx_u64(&x71, &x72, x70, x34, x67); + fiat_25519_addcarryx_u64(&x73, &x74, 0x0, x15, x13); + fiat_25519_addcarryx_u64(&x75, &x76, x74, x16, x14); + fiat_25519_addcarryx_u64(&x77, &x78, 0x0, x35, x73); + fiat_25519_addcarryx_u64(&x79, &x80, x78, x36, x75); + fiat_25519_addcarryx_u64(&x81, &x82, 0x0, x47, x77); + x83 = (x82 + x79); + x84 = ((x81 >> 51) | ((x83 << 13) & UINT64_C(0xffffffffffffffff))); + x85 = (x81 & UINT64_C(0x7ffffffffffff)); + fiat_25519_addcarryx_u64(&x86, &x87, 0x0, x84, x69); + x88 = (x87 + x71); + x89 = ((x86 >> 51) | ((x88 << 13) & UINT64_C(0xffffffffffffffff))); + x90 = (x86 & UINT64_C(0x7ffffffffffff)); + fiat_25519_addcarryx_u64(&x91, &x92, 0x0, x89, x61); + x93 = (x92 + x63); + x94 = ((x91 >> 51) | ((x93 << 13) & UINT64_C(0xffffffffffffffff))); + x95 = (x91 & UINT64_C(0x7ffffffffffff)); + fiat_25519_addcarryx_u64(&x96, &x97, 0x0, x94, x53); + x98 = (x97 + x55); + x99 = ((x96 >> 51) | ((x98 << 13) & UINT64_C(0xffffffffffffffff))); + x100 = (x96 & UINT64_C(0x7ffffffffffff)); + x101 = (x99 * UINT8_C(0x13)); + x102 = (x48 + x101); + x103 = (x102 >> 51); + x104 = (x102 & UINT64_C(0x7ffffffffffff)); + x105 = (x103 + x85); + x106 = (fiat_25519_uint1)(x105 >> 51); + x107 = (x105 & UINT64_C(0x7ffffffffffff)); + x108 = (x106 + x90); + out1[0] = x104; + out1[1] = x107; + out1[2] = x108; + out1[3] = x95; + out1[4] = x100; +} + +/* + * The function fiat_25519_carry reduces a field element. + * + * Postconditions: + * eval out1 mod m = eval arg1 mod m + * + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_carry(fiat_25519_tight_field_element out1, const fiat_25519_loose_field_element arg1) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + uint64_t x6; + uint64_t x7; + uint64_t x8; + uint64_t x9; + uint64_t x10; + uint64_t x11; + uint64_t x12; + x1 = (arg1[0]); + x2 = ((x1 >> 51) + (arg1[1])); + x3 = ((x2 >> 51) + (arg1[2])); + x4 = ((x3 >> 51) + (arg1[3])); + x5 = ((x4 >> 51) + (arg1[4])); + x6 = ((x1 & UINT64_C(0x7ffffffffffff)) + ((x5 >> 51) * UINT8_C(0x13))); + x7 = ((fiat_25519_uint1)(x6 >> 51) + (x2 & UINT64_C(0x7ffffffffffff))); + x8 = (x6 & UINT64_C(0x7ffffffffffff)); + x9 = (x7 & UINT64_C(0x7ffffffffffff)); + x10 = ((fiat_25519_uint1)(x7 >> 51) + (x3 & UINT64_C(0x7ffffffffffff))); + x11 = (x4 & UINT64_C(0x7ffffffffffff)); + x12 = (x5 & UINT64_C(0x7ffffffffffff)); + out1[0] = x8; + out1[1] = x9; + out1[2] = x10; + out1[3] = x11; + out1[4] = x12; +} + +/* + * The function fiat_25519_add adds two field elements. + * + * Postconditions: + * eval out1 mod m = (eval arg1 + eval arg2) mod m + * + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_add(fiat_25519_loose_field_element out1, const fiat_25519_tight_field_element arg1, const fiat_25519_tight_field_element arg2) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + x1 = ((arg1[0]) + (arg2[0])); + x2 = ((arg1[1]) + (arg2[1])); + x3 = ((arg1[2]) + (arg2[2])); + x4 = ((arg1[3]) + (arg2[3])); + x5 = ((arg1[4]) + (arg2[4])); + out1[0] = x1; + out1[1] = x2; + out1[2] = x3; + out1[3] = x4; + out1[4] = x5; +} + +/* + * The function fiat_25519_sub subtracts two field elements. + * + * Postconditions: + * eval out1 mod m = (eval arg1 - eval arg2) mod m + * + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_sub(fiat_25519_loose_field_element out1, const fiat_25519_tight_field_element arg1, const fiat_25519_tight_field_element arg2) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + x1 = ((UINT64_C(0xfffffffffffda) + (arg1[0])) - (arg2[0])); + x2 = ((UINT64_C(0xffffffffffffe) + (arg1[1])) - (arg2[1])); + x3 = ((UINT64_C(0xffffffffffffe) + (arg1[2])) - (arg2[2])); + x4 = ((UINT64_C(0xffffffffffffe) + (arg1[3])) - (arg2[3])); + x5 = ((UINT64_C(0xffffffffffffe) + (arg1[4])) - (arg2[4])); + out1[0] = x1; + out1[1] = x2; + out1[2] = x3; + out1[3] = x4; + out1[4] = x5; +} + +/* + * The function fiat_25519_opp negates a field element. + * + * Postconditions: + * eval out1 mod m = -eval arg1 mod m + * + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_opp(fiat_25519_loose_field_element out1, const fiat_25519_tight_field_element arg1) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + x1 = (UINT64_C(0xfffffffffffda) - (arg1[0])); + x2 = (UINT64_C(0xffffffffffffe) - (arg1[1])); + x3 = (UINT64_C(0xffffffffffffe) - (arg1[2])); + x4 = (UINT64_C(0xffffffffffffe) - (arg1[3])); + x5 = (UINT64_C(0xffffffffffffe) - (arg1[4])); + out1[0] = x1; + out1[1] = x2; + out1[2] = x3; + out1[3] = x4; + out1[4] = x5; +} + +/* + * The function fiat_25519_to_bytes serializes a field element to bytes in little-endian order. + * + * Postconditions: + * out1 = map (λ x, ⌊((eval arg1 mod m) mod 2^(8 * (x + 1))) / 2^(8 * x)⌋) [0..31] + * + * Output Bounds: + * out1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0x7f]] + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_to_bytes(uint8_t out1[32], const fiat_25519_tight_field_element arg1) { + uint64_t x1; + fiat_25519_uint1 x2; + uint64_t x3; + fiat_25519_uint1 x4; + uint64_t x5; + fiat_25519_uint1 x6; + uint64_t x7; + fiat_25519_uint1 x8; + uint64_t x9; + fiat_25519_uint1 x10; + uint64_t x11; + uint64_t x12; + fiat_25519_uint1 x13; + uint64_t x14; + fiat_25519_uint1 x15; + uint64_t x16; + fiat_25519_uint1 x17; + uint64_t x18; + fiat_25519_uint1 x19; + uint64_t x20; + fiat_25519_uint1 x21; + uint64_t x22; + uint64_t x23; + uint64_t x24; + uint64_t x25; + uint8_t x26; + uint64_t x27; + uint8_t x28; + uint64_t x29; + uint8_t x30; + uint64_t x31; + uint8_t x32; + uint64_t x33; + uint8_t x34; + uint64_t x35; + uint8_t x36; + uint8_t x37; + uint64_t x38; + uint8_t x39; + uint64_t x40; + uint8_t x41; + uint64_t x42; + uint8_t x43; + uint64_t x44; + uint8_t x45; + uint64_t x46; + uint8_t x47; + uint64_t x48; + uint8_t x49; + uint8_t x50; + uint64_t x51; + uint8_t x52; + uint64_t x53; + uint8_t x54; + uint64_t x55; + uint8_t x56; + uint64_t x57; + uint8_t x58; + uint64_t x59; + uint8_t x60; + uint64_t x61; + uint8_t x62; + uint64_t x63; + uint8_t x64; + fiat_25519_uint1 x65; + uint64_t x66; + uint8_t x67; + uint64_t x68; + uint8_t x69; + uint64_t x70; + uint8_t x71; + uint64_t x72; + uint8_t x73; + uint64_t x74; + uint8_t x75; + uint64_t x76; + uint8_t x77; + uint8_t x78; + uint64_t x79; + uint8_t x80; + uint64_t x81; + uint8_t x82; + uint64_t x83; + uint8_t x84; + uint64_t x85; + uint8_t x86; + uint64_t x87; + uint8_t x88; + uint64_t x89; + uint8_t x90; + uint8_t x91; + fiat_25519_subborrowx_u51(&x1, &x2, 0x0, (arg1[0]), UINT64_C(0x7ffffffffffed)); + fiat_25519_subborrowx_u51(&x3, &x4, x2, (arg1[1]), UINT64_C(0x7ffffffffffff)); + fiat_25519_subborrowx_u51(&x5, &x6, x4, (arg1[2]), UINT64_C(0x7ffffffffffff)); + fiat_25519_subborrowx_u51(&x7, &x8, x6, (arg1[3]), UINT64_C(0x7ffffffffffff)); + fiat_25519_subborrowx_u51(&x9, &x10, x8, (arg1[4]), UINT64_C(0x7ffffffffffff)); + fiat_25519_cmovznz_u64(&x11, x10, 0x0, UINT64_C(0xffffffffffffffff)); + fiat_25519_addcarryx_u51(&x12, &x13, 0x0, x1, (x11 & UINT64_C(0x7ffffffffffed))); + fiat_25519_addcarryx_u51(&x14, &x15, x13, x3, (x11 & UINT64_C(0x7ffffffffffff))); + fiat_25519_addcarryx_u51(&x16, &x17, x15, x5, (x11 & UINT64_C(0x7ffffffffffff))); + fiat_25519_addcarryx_u51(&x18, &x19, x17, x7, (x11 & UINT64_C(0x7ffffffffffff))); + fiat_25519_addcarryx_u51(&x20, &x21, x19, x9, (x11 & UINT64_C(0x7ffffffffffff))); + x22 = (x20 << 4); + x23 = (x18 * (uint64_t)0x2); + x24 = (x16 << 6); + x25 = (x14 << 3); + x26 = (uint8_t)(x12 & UINT8_C(0xff)); + x27 = (x12 >> 8); + x28 = (uint8_t)(x27 & UINT8_C(0xff)); + x29 = (x27 >> 8); + x30 = (uint8_t)(x29 & UINT8_C(0xff)); + x31 = (x29 >> 8); + x32 = (uint8_t)(x31 & UINT8_C(0xff)); + x33 = (x31 >> 8); + x34 = (uint8_t)(x33 & UINT8_C(0xff)); + x35 = (x33 >> 8); + x36 = (uint8_t)(x35 & UINT8_C(0xff)); + x37 = (uint8_t)(x35 >> 8); + x38 = (x25 + (uint64_t)x37); + x39 = (uint8_t)(x38 & UINT8_C(0xff)); + x40 = (x38 >> 8); + x41 = (uint8_t)(x40 & UINT8_C(0xff)); + x42 = (x40 >> 8); + x43 = (uint8_t)(x42 & UINT8_C(0xff)); + x44 = (x42 >> 8); + x45 = (uint8_t)(x44 & UINT8_C(0xff)); + x46 = (x44 >> 8); + x47 = (uint8_t)(x46 & UINT8_C(0xff)); + x48 = (x46 >> 8); + x49 = (uint8_t)(x48 & UINT8_C(0xff)); + x50 = (uint8_t)(x48 >> 8); + x51 = (x24 + (uint64_t)x50); + x52 = (uint8_t)(x51 & UINT8_C(0xff)); + x53 = (x51 >> 8); + x54 = (uint8_t)(x53 & UINT8_C(0xff)); + x55 = (x53 >> 8); + x56 = (uint8_t)(x55 & UINT8_C(0xff)); + x57 = (x55 >> 8); + x58 = (uint8_t)(x57 & UINT8_C(0xff)); + x59 = (x57 >> 8); + x60 = (uint8_t)(x59 & UINT8_C(0xff)); + x61 = (x59 >> 8); + x62 = (uint8_t)(x61 & UINT8_C(0xff)); + x63 = (x61 >> 8); + x64 = (uint8_t)(x63 & UINT8_C(0xff)); + x65 = (fiat_25519_uint1)(x63 >> 8); + x66 = (x23 + (uint64_t)x65); + x67 = (uint8_t)(x66 & UINT8_C(0xff)); + x68 = (x66 >> 8); + x69 = (uint8_t)(x68 & UINT8_C(0xff)); + x70 = (x68 >> 8); + x71 = (uint8_t)(x70 & UINT8_C(0xff)); + x72 = (x70 >> 8); + x73 = (uint8_t)(x72 & UINT8_C(0xff)); + x74 = (x72 >> 8); + x75 = (uint8_t)(x74 & UINT8_C(0xff)); + x76 = (x74 >> 8); + x77 = (uint8_t)(x76 & UINT8_C(0xff)); + x78 = (uint8_t)(x76 >> 8); + x79 = (x22 + (uint64_t)x78); + x80 = (uint8_t)(x79 & UINT8_C(0xff)); + x81 = (x79 >> 8); + x82 = (uint8_t)(x81 & UINT8_C(0xff)); + x83 = (x81 >> 8); + x84 = (uint8_t)(x83 & UINT8_C(0xff)); + x85 = (x83 >> 8); + x86 = (uint8_t)(x85 & UINT8_C(0xff)); + x87 = (x85 >> 8); + x88 = (uint8_t)(x87 & UINT8_C(0xff)); + x89 = (x87 >> 8); + x90 = (uint8_t)(x89 & UINT8_C(0xff)); + x91 = (uint8_t)(x89 >> 8); + out1[0] = x26; + out1[1] = x28; + out1[2] = x30; + out1[3] = x32; + out1[4] = x34; + out1[5] = x36; + out1[6] = x39; + out1[7] = x41; + out1[8] = x43; + out1[9] = x45; + out1[10] = x47; + out1[11] = x49; + out1[12] = x52; + out1[13] = x54; + out1[14] = x56; + out1[15] = x58; + out1[16] = x60; + out1[17] = x62; + out1[18] = x64; + out1[19] = x67; + out1[20] = x69; + out1[21] = x71; + out1[22] = x73; + out1[23] = x75; + out1[24] = x77; + out1[25] = x80; + out1[26] = x82; + out1[27] = x84; + out1[28] = x86; + out1[29] = x88; + out1[30] = x90; + out1[31] = x91; +} + +/* + * The function fiat_25519_from_bytes deserializes a field element from bytes in little-endian order. + * + * Postconditions: + * eval out1 mod m = bytes_eval arg1 mod m + * + * Input Bounds: + * arg1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0x7f]] + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_from_bytes(fiat_25519_tight_field_element out1, const uint8_t arg1[32]) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + uint64_t x6; + uint64_t x7; + uint64_t x8; + uint64_t x9; + uint64_t x10; + uint64_t x11; + uint64_t x12; + uint64_t x13; + uint64_t x14; + uint64_t x15; + uint64_t x16; + uint64_t x17; + uint64_t x18; + uint64_t x19; + uint64_t x20; + uint64_t x21; + uint64_t x22; + uint64_t x23; + uint64_t x24; + uint64_t x25; + uint64_t x26; + uint64_t x27; + uint64_t x28; + uint64_t x29; + uint64_t x30; + uint64_t x31; + uint8_t x32; + uint64_t x33; + uint64_t x34; + uint64_t x35; + uint64_t x36; + uint64_t x37; + uint64_t x38; + uint64_t x39; + uint8_t x40; + uint64_t x41; + uint64_t x42; + uint64_t x43; + uint64_t x44; + uint64_t x45; + uint64_t x46; + uint64_t x47; + uint8_t x48; + uint64_t x49; + uint64_t x50; + uint64_t x51; + uint64_t x52; + uint64_t x53; + uint64_t x54; + uint64_t x55; + uint64_t x56; + uint8_t x57; + uint64_t x58; + uint64_t x59; + uint64_t x60; + uint64_t x61; + uint64_t x62; + uint64_t x63; + uint64_t x64; + uint8_t x65; + uint64_t x66; + uint64_t x67; + uint64_t x68; + uint64_t x69; + uint64_t x70; + uint64_t x71; + x1 = ((uint64_t)(arg1[31]) << 44); + x2 = ((uint64_t)(arg1[30]) << 36); + x3 = ((uint64_t)(arg1[29]) << 28); + x4 = ((uint64_t)(arg1[28]) << 20); + x5 = ((uint64_t)(arg1[27]) << 12); + x6 = ((uint64_t)(arg1[26]) << 4); + x7 = ((uint64_t)(arg1[25]) << 47); + x8 = ((uint64_t)(arg1[24]) << 39); + x9 = ((uint64_t)(arg1[23]) << 31); + x10 = ((uint64_t)(arg1[22]) << 23); + x11 = ((uint64_t)(arg1[21]) << 15); + x12 = ((uint64_t)(arg1[20]) << 7); + x13 = ((uint64_t)(arg1[19]) << 50); + x14 = ((uint64_t)(arg1[18]) << 42); + x15 = ((uint64_t)(arg1[17]) << 34); + x16 = ((uint64_t)(arg1[16]) << 26); + x17 = ((uint64_t)(arg1[15]) << 18); + x18 = ((uint64_t)(arg1[14]) << 10); + x19 = ((uint64_t)(arg1[13]) << 2); + x20 = ((uint64_t)(arg1[12]) << 45); + x21 = ((uint64_t)(arg1[11]) << 37); + x22 = ((uint64_t)(arg1[10]) << 29); + x23 = ((uint64_t)(arg1[9]) << 21); + x24 = ((uint64_t)(arg1[8]) << 13); + x25 = ((uint64_t)(arg1[7]) << 5); + x26 = ((uint64_t)(arg1[6]) << 48); + x27 = ((uint64_t)(arg1[5]) << 40); + x28 = ((uint64_t)(arg1[4]) << 32); + x29 = ((uint64_t)(arg1[3]) << 24); + x30 = ((uint64_t)(arg1[2]) << 16); + x31 = ((uint64_t)(arg1[1]) << 8); + x32 = (arg1[0]); + x33 = (x31 + (uint64_t)x32); + x34 = (x30 + x33); + x35 = (x29 + x34); + x36 = (x28 + x35); + x37 = (x27 + x36); + x38 = (x26 + x37); + x39 = (x38 & UINT64_C(0x7ffffffffffff)); + x40 = (uint8_t)(x38 >> 51); + x41 = (x25 + (uint64_t)x40); + x42 = (x24 + x41); + x43 = (x23 + x42); + x44 = (x22 + x43); + x45 = (x21 + x44); + x46 = (x20 + x45); + x47 = (x46 & UINT64_C(0x7ffffffffffff)); + x48 = (uint8_t)(x46 >> 51); + x49 = (x19 + (uint64_t)x48); + x50 = (x18 + x49); + x51 = (x17 + x50); + x52 = (x16 + x51); + x53 = (x15 + x52); + x54 = (x14 + x53); + x55 = (x13 + x54); + x56 = (x55 & UINT64_C(0x7ffffffffffff)); + x57 = (uint8_t)(x55 >> 51); + x58 = (x12 + (uint64_t)x57); + x59 = (x11 + x58); + x60 = (x10 + x59); + x61 = (x9 + x60); + x62 = (x8 + x61); + x63 = (x7 + x62); + x64 = (x63 & UINT64_C(0x7ffffffffffff)); + x65 = (uint8_t)(x63 >> 51); + x66 = (x6 + (uint64_t)x65); + x67 = (x5 + x66); + x68 = (x4 + x67); + x69 = (x3 + x68); + x70 = (x2 + x69); + x71 = (x1 + x70); + out1[0] = x39; + out1[1] = x47; + out1[2] = x56; + out1[3] = x64; + out1[4] = x71; +} + +/* + * The function fiat_25519_carry_scmul_121666 multiplies a field element by 121666 and reduces the result. + * + * Postconditions: + * eval out1 mod m = (121666 * eval arg1) mod m + * + */ +static FIAT_25519_FIAT_INLINE void fiat_25519_carry_scmul_121666(fiat_25519_tight_field_element out1, const fiat_25519_loose_field_element arg1) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + uint64_t x6; + uint64_t x7; + uint64_t x8; + uint64_t x9; + uint64_t x10; + uint64_t x11; + uint64_t x12; + uint64_t x13; + fiat_25519_uint1 x14; + uint64_t x15; + uint64_t x16; + uint64_t x17; + uint64_t x18; + fiat_25519_uint1 x19; + uint64_t x20; + uint64_t x21; + uint64_t x22; + uint64_t x23; + fiat_25519_uint1 x24; + uint64_t x25; + uint64_t x26; + uint64_t x27; + uint64_t x28; + fiat_25519_uint1 x29; + uint64_t x30; + uint64_t x31; + uint64_t x32; + uint64_t x33; + uint64_t x34; + fiat_25519_uint1 x35; + uint64_t x36; + uint64_t x37; + fiat_25519_uint1 x38; + uint64_t x39; + uint64_t x40; + fiat_25519_mulx_u64(&x1, &x2, UINT32_C(0x1db42), (arg1[4])); + fiat_25519_mulx_u64(&x3, &x4, UINT32_C(0x1db42), (arg1[3])); + fiat_25519_mulx_u64(&x5, &x6, UINT32_C(0x1db42), (arg1[2])); + fiat_25519_mulx_u64(&x7, &x8, UINT32_C(0x1db42), (arg1[1])); + fiat_25519_mulx_u64(&x9, &x10, UINT32_C(0x1db42), (arg1[0])); + x11 = ((x9 >> 51) | ((x10 << 13) & UINT64_C(0xffffffffffffffff))); + x12 = (x9 & UINT64_C(0x7ffffffffffff)); + fiat_25519_addcarryx_u64(&x13, &x14, 0x0, x11, x7); + x15 = (x14 + x8); + x16 = ((x13 >> 51) | ((x15 << 13) & UINT64_C(0xffffffffffffffff))); + x17 = (x13 & UINT64_C(0x7ffffffffffff)); + fiat_25519_addcarryx_u64(&x18, &x19, 0x0, x16, x5); + x20 = (x19 + x6); + x21 = ((x18 >> 51) | ((x20 << 13) & UINT64_C(0xffffffffffffffff))); + x22 = (x18 & UINT64_C(0x7ffffffffffff)); + fiat_25519_addcarryx_u64(&x23, &x24, 0x0, x21, x3); + x25 = (x24 + x4); + x26 = ((x23 >> 51) | ((x25 << 13) & UINT64_C(0xffffffffffffffff))); + x27 = (x23 & UINT64_C(0x7ffffffffffff)); + fiat_25519_addcarryx_u64(&x28, &x29, 0x0, x26, x1); + x30 = (x29 + x2); + x31 = ((x28 >> 51) | ((x30 << 13) & UINT64_C(0xffffffffffffffff))); + x32 = (x28 & UINT64_C(0x7ffffffffffff)); + x33 = (x31 * UINT8_C(0x13)); + x34 = (x12 + x33); + x35 = (fiat_25519_uint1)(x34 >> 51); + x36 = (x34 & UINT64_C(0x7ffffffffffff)); + x37 = (x35 + x17); + x38 = (fiat_25519_uint1)(x37 >> 51); + x39 = (x37 & UINT64_C(0x7ffffffffffff)); + x40 = (x38 + x22); + out1[0] = x36; + out1[1] = x39; + out1[2] = x40; + out1[3] = x27; + out1[4] = x32; +} diff --git a/http/vendor/ring/third_party/fiat/p256_32.h b/http/vendor/ring/third_party/fiat/p256_32.h new file mode 100644 index 0000000..83289a1 --- /dev/null +++ b/http/vendor/ring/third_party/fiat/p256_32.h @@ -0,0 +1,2511 @@ +/* Autogenerated: 'src/ExtractionOCaml/word_by_word_montgomery' --inline --static --use-value-barrier p256 32 '2^256 - 2^224 + 2^192 + 2^96 - 1' mul square add sub opp from_montgomery to_montgomery nonzero selectznz to_bytes from_bytes one msat divstep divstep_precomp */ +/* curve description: p256 */ +/* machine_wordsize = 32 (from "32") */ +/* requested operations: mul, square, add, sub, opp, from_montgomery, to_montgomery, nonzero, selectznz, to_bytes, from_bytes, one, msat, divstep, divstep_precomp */ +/* m = 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff (from "2^256 - 2^224 + 2^192 + 2^96 - 1") */ +/* */ +/* NOTE: In addition to the bounds specified above each function, all */ +/* functions synthesized for this Montgomery arithmetic require the */ +/* input to be strictly less than the prime modulus (m), and also */ +/* require the input to be in the unique saturated representation. */ +/* All functions also ensure that these two properties are true of */ +/* return values. */ +/* */ +/* Computed values: */ +/* eval z = z[0] + (z[1] << 32) + (z[2] << 64) + (z[3] << 96) + (z[4] << 128) + (z[5] << 160) + (z[6] << 192) + (z[7] << 224) */ +/* bytes_eval z = z[0] + (z[1] << 8) + (z[2] << 16) + (z[3] << 24) + (z[4] << 32) + (z[5] << 40) + (z[6] << 48) + (z[7] << 56) + (z[8] << 64) + (z[9] << 72) + (z[10] << 80) + (z[11] << 88) + (z[12] << 96) + (z[13] << 104) + (z[14] << 112) + (z[15] << 120) + (z[16] << 128) + (z[17] << 136) + (z[18] << 144) + (z[19] << 152) + (z[20] << 160) + (z[21] << 168) + (z[22] << 176) + (z[23] << 184) + (z[24] << 192) + (z[25] << 200) + (z[26] << 208) + (z[27] << 216) + (z[28] << 224) + (z[29] << 232) + (z[30] << 240) + (z[31] << 248) */ +/* twos_complement_eval z = let x1 := z[0] + (z[1] << 32) + (z[2] << 64) + (z[3] << 96) + (z[4] << 128) + (z[5] << 160) + (z[6] << 192) + (z[7] << 224) in */ +/* if x1 & (2^256-1) < 2^255 then x1 & (2^256-1) else (x1 & (2^256-1)) - 2^256 */ + +#include +typedef unsigned char fiat_p256_uint1; +typedef signed char fiat_p256_int1; +#if defined(__GNUC__) || defined(__clang__) +# define FIAT_P256_FIAT_INLINE __inline__ +#else +# define FIAT_P256_FIAT_INLINE +#endif + +/* The type fiat_p256_montgomery_domain_field_element is a field element in the Montgomery domain. */ +/* Bounds: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] */ +typedef uint32_t fiat_p256_montgomery_domain_field_element[8]; + +/* The type fiat_p256_non_montgomery_domain_field_element is a field element NOT in the Montgomery domain. */ +/* Bounds: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] */ +typedef uint32_t fiat_p256_non_montgomery_domain_field_element[8]; + +#if (-1 & 3) != 3 +#error "This code only works on a two's complement system" +#endif + +#if !defined(FIAT_P256_NO_ASM) && (defined(__GNUC__) || defined(__clang__)) +static __inline__ uint32_t fiat_p256_value_barrier_u32(uint32_t a) { + __asm__("" : "+r"(a) : /* no inputs */); + return a; +} +#else +# define fiat_p256_value_barrier_u32(x) (x) +#endif + + +/* + * The function fiat_p256_addcarryx_u32 is an addition with carry. + * + * Postconditions: + * out1 = (arg1 + arg2 + arg3) mod 2^32 + * out2 = ⌊(arg1 + arg2 + arg3) / 2^32⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0xffffffff] + * arg3: [0x0 ~> 0xffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffff] + * out2: [0x0 ~> 0x1] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_addcarryx_u32(uint32_t* out1, fiat_p256_uint1* out2, fiat_p256_uint1 arg1, uint32_t arg2, uint32_t arg3) { + uint64_t x1; + uint32_t x2; + fiat_p256_uint1 x3; + x1 = ((arg1 + (uint64_t)arg2) + arg3); + x2 = (uint32_t)(x1 & UINT32_C(0xffffffff)); + x3 = (fiat_p256_uint1)(x1 >> 32); + *out1 = x2; + *out2 = x3; +} + +/* + * The function fiat_p256_subborrowx_u32 is a subtraction with borrow. + * + * Postconditions: + * out1 = (-arg1 + arg2 + -arg3) mod 2^32 + * out2 = -⌊(-arg1 + arg2 + -arg3) / 2^32⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0xffffffff] + * arg3: [0x0 ~> 0xffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffff] + * out2: [0x0 ~> 0x1] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_subborrowx_u32(uint32_t* out1, fiat_p256_uint1* out2, fiat_p256_uint1 arg1, uint32_t arg2, uint32_t arg3) { + int64_t x1; + fiat_p256_int1 x2; + uint32_t x3; + x1 = ((arg2 - (int64_t)arg1) - arg3); + x2 = (fiat_p256_int1)(x1 >> 32); + x3 = (uint32_t)(x1 & UINT32_C(0xffffffff)); + *out1 = x3; + *out2 = (fiat_p256_uint1)(0x0 - x2); +} + +/* + * The function fiat_p256_mulx_u32 is a multiplication, returning the full double-width result. + * + * Postconditions: + * out1 = (arg1 * arg2) mod 2^32 + * out2 = ⌊arg1 * arg2 / 2^32⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0xffffffff] + * arg2: [0x0 ~> 0xffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffff] + * out2: [0x0 ~> 0xffffffff] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_mulx_u32(uint32_t* out1, uint32_t* out2, uint32_t arg1, uint32_t arg2) { + uint64_t x1; + uint32_t x2; + uint32_t x3; + x1 = ((uint64_t)arg1 * arg2); + x2 = (uint32_t)(x1 & UINT32_C(0xffffffff)); + x3 = (uint32_t)(x1 >> 32); + *out1 = x2; + *out2 = x3; +} + +/* + * The function fiat_p256_cmovznz_u32 is a single-word conditional move. + * + * Postconditions: + * out1 = (if arg1 = 0 then arg2 else arg3) + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0xffffffff] + * arg3: [0x0 ~> 0xffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffff] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_cmovznz_u32(uint32_t* out1, fiat_p256_uint1 arg1, uint32_t arg2, uint32_t arg3) { + fiat_p256_uint1 x1; + uint32_t x2; + uint32_t x3; + x1 = (!(!arg1)); + x2 = ((fiat_p256_int1)(0x0 - x1) & UINT32_C(0xffffffff)); + x3 = ((fiat_p256_value_barrier_u32(x2) & arg3) | (fiat_p256_value_barrier_u32((~x2)) & arg2)); + *out1 = x3; +} + +/* + * The function fiat_p256_mul multiplies two field elements in the Montgomery domain. + * + * Preconditions: + * 0 ≤ eval arg1 < m + * 0 ≤ eval arg2 < m + * Postconditions: + * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) * eval (from_montgomery arg2)) mod m + * 0 ≤ eval out1 < m + * + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_mul(fiat_p256_montgomery_domain_field_element out1, const fiat_p256_montgomery_domain_field_element arg1, const fiat_p256_montgomery_domain_field_element arg2) { + uint32_t x1; + uint32_t x2; + uint32_t x3; + uint32_t x4; + uint32_t x5; + uint32_t x6; + uint32_t x7; + uint32_t x8; + uint32_t x9; + uint32_t x10; + uint32_t x11; + uint32_t x12; + uint32_t x13; + uint32_t x14; + uint32_t x15; + uint32_t x16; + uint32_t x17; + uint32_t x18; + uint32_t x19; + uint32_t x20; + uint32_t x21; + uint32_t x22; + uint32_t x23; + uint32_t x24; + uint32_t x25; + fiat_p256_uint1 x26; + uint32_t x27; + fiat_p256_uint1 x28; + uint32_t x29; + fiat_p256_uint1 x30; + uint32_t x31; + fiat_p256_uint1 x32; + uint32_t x33; + fiat_p256_uint1 x34; + uint32_t x35; + fiat_p256_uint1 x36; + uint32_t x37; + fiat_p256_uint1 x38; + uint32_t x39; + uint32_t x40; + uint32_t x41; + uint32_t x42; + uint32_t x43; + uint32_t x44; + uint32_t x45; + uint32_t x46; + uint32_t x47; + uint32_t x48; + fiat_p256_uint1 x49; + uint32_t x50; + fiat_p256_uint1 x51; + uint32_t x52; + uint32_t x53; + fiat_p256_uint1 x54; + uint32_t x55; + fiat_p256_uint1 x56; + uint32_t x57; + fiat_p256_uint1 x58; + uint32_t x59; + fiat_p256_uint1 x60; + uint32_t x61; + fiat_p256_uint1 x62; + uint32_t x63; + fiat_p256_uint1 x64; + uint32_t x65; + fiat_p256_uint1 x66; + uint32_t x67; + fiat_p256_uint1 x68; + uint32_t x69; + fiat_p256_uint1 x70; + uint32_t x71; + uint32_t x72; + uint32_t x73; + uint32_t x74; + uint32_t x75; + uint32_t x76; + uint32_t x77; + uint32_t x78; + uint32_t x79; + uint32_t x80; + uint32_t x81; + uint32_t x82; + uint32_t x83; + uint32_t x84; + uint32_t x85; + uint32_t x86; + uint32_t x87; + fiat_p256_uint1 x88; + uint32_t x89; + fiat_p256_uint1 x90; + uint32_t x91; + fiat_p256_uint1 x92; + uint32_t x93; + fiat_p256_uint1 x94; + uint32_t x95; + fiat_p256_uint1 x96; + uint32_t x97; + fiat_p256_uint1 x98; + uint32_t x99; + fiat_p256_uint1 x100; + uint32_t x101; + uint32_t x102; + fiat_p256_uint1 x103; + uint32_t x104; + fiat_p256_uint1 x105; + uint32_t x106; + fiat_p256_uint1 x107; + uint32_t x108; + fiat_p256_uint1 x109; + uint32_t x110; + fiat_p256_uint1 x111; + uint32_t x112; + fiat_p256_uint1 x113; + uint32_t x114; + fiat_p256_uint1 x115; + uint32_t x116; + fiat_p256_uint1 x117; + uint32_t x118; + fiat_p256_uint1 x119; + uint32_t x120; + uint32_t x121; + uint32_t x122; + uint32_t x123; + uint32_t x124; + uint32_t x125; + uint32_t x126; + uint32_t x127; + uint32_t x128; + fiat_p256_uint1 x129; + uint32_t x130; + fiat_p256_uint1 x131; + uint32_t x132; + uint32_t x133; + fiat_p256_uint1 x134; + uint32_t x135; + fiat_p256_uint1 x136; + uint32_t x137; + fiat_p256_uint1 x138; + uint32_t x139; + fiat_p256_uint1 x140; + uint32_t x141; + fiat_p256_uint1 x142; + uint32_t x143; + fiat_p256_uint1 x144; + uint32_t x145; + fiat_p256_uint1 x146; + uint32_t x147; + fiat_p256_uint1 x148; + uint32_t x149; + fiat_p256_uint1 x150; + uint32_t x151; + uint32_t x152; + uint32_t x153; + uint32_t x154; + uint32_t x155; + uint32_t x156; + uint32_t x157; + uint32_t x158; + uint32_t x159; + uint32_t x160; + uint32_t x161; + uint32_t x162; + uint32_t x163; + uint32_t x164; + uint32_t x165; + uint32_t x166; + uint32_t x167; + uint32_t x168; + fiat_p256_uint1 x169; + uint32_t x170; + fiat_p256_uint1 x171; + uint32_t x172; + fiat_p256_uint1 x173; + uint32_t x174; + fiat_p256_uint1 x175; + uint32_t x176; + fiat_p256_uint1 x177; + uint32_t x178; + fiat_p256_uint1 x179; + uint32_t x180; + fiat_p256_uint1 x181; + uint32_t x182; + uint32_t x183; + fiat_p256_uint1 x184; + uint32_t x185; + fiat_p256_uint1 x186; + uint32_t x187; + fiat_p256_uint1 x188; + uint32_t x189; + fiat_p256_uint1 x190; + uint32_t x191; + fiat_p256_uint1 x192; + uint32_t x193; + fiat_p256_uint1 x194; + uint32_t x195; + fiat_p256_uint1 x196; + uint32_t x197; + fiat_p256_uint1 x198; + uint32_t x199; + fiat_p256_uint1 x200; + uint32_t x201; + uint32_t x202; + uint32_t x203; + uint32_t x204; + uint32_t x205; + uint32_t x206; + uint32_t x207; + uint32_t x208; + uint32_t x209; + fiat_p256_uint1 x210; + uint32_t x211; + fiat_p256_uint1 x212; + uint32_t x213; + uint32_t x214; + fiat_p256_uint1 x215; + uint32_t x216; + fiat_p256_uint1 x217; + uint32_t x218; + fiat_p256_uint1 x219; + uint32_t x220; + fiat_p256_uint1 x221; + uint32_t x222; + fiat_p256_uint1 x223; + uint32_t x224; + fiat_p256_uint1 x225; + uint32_t x226; + fiat_p256_uint1 x227; + uint32_t x228; + fiat_p256_uint1 x229; + uint32_t x230; + fiat_p256_uint1 x231; + uint32_t x232; + uint32_t x233; + uint32_t x234; + uint32_t x235; + uint32_t x236; + uint32_t x237; + uint32_t x238; + uint32_t x239; + uint32_t x240; + uint32_t x241; + uint32_t x242; + uint32_t x243; + uint32_t x244; + uint32_t x245; + uint32_t x246; + uint32_t x247; + uint32_t x248; + uint32_t x249; + fiat_p256_uint1 x250; + uint32_t x251; + fiat_p256_uint1 x252; + uint32_t x253; + fiat_p256_uint1 x254; + uint32_t x255; + fiat_p256_uint1 x256; + uint32_t x257; + fiat_p256_uint1 x258; + uint32_t x259; + fiat_p256_uint1 x260; + uint32_t x261; + fiat_p256_uint1 x262; + uint32_t x263; + uint32_t x264; + fiat_p256_uint1 x265; + uint32_t x266; + fiat_p256_uint1 x267; + uint32_t x268; + fiat_p256_uint1 x269; + uint32_t x270; + fiat_p256_uint1 x271; + uint32_t x272; + fiat_p256_uint1 x273; + uint32_t x274; + fiat_p256_uint1 x275; + uint32_t x276; + fiat_p256_uint1 x277; + uint32_t x278; + fiat_p256_uint1 x279; + uint32_t x280; + fiat_p256_uint1 x281; + uint32_t x282; + uint32_t x283; + uint32_t x284; + uint32_t x285; + uint32_t x286; + uint32_t x287; + uint32_t x288; + uint32_t x289; + uint32_t x290; + fiat_p256_uint1 x291; + uint32_t x292; + fiat_p256_uint1 x293; + uint32_t x294; + uint32_t x295; + fiat_p256_uint1 x296; + uint32_t x297; + fiat_p256_uint1 x298; + uint32_t x299; + fiat_p256_uint1 x300; + uint32_t x301; + fiat_p256_uint1 x302; + uint32_t x303; + fiat_p256_uint1 x304; + uint32_t x305; + fiat_p256_uint1 x306; + uint32_t x307; + fiat_p256_uint1 x308; + uint32_t x309; + fiat_p256_uint1 x310; + uint32_t x311; + fiat_p256_uint1 x312; + uint32_t x313; + uint32_t x314; + uint32_t x315; + uint32_t x316; + uint32_t x317; + uint32_t x318; + uint32_t x319; + uint32_t x320; + uint32_t x321; + uint32_t x322; + uint32_t x323; + uint32_t x324; + uint32_t x325; + uint32_t x326; + uint32_t x327; + uint32_t x328; + uint32_t x329; + uint32_t x330; + fiat_p256_uint1 x331; + uint32_t x332; + fiat_p256_uint1 x333; + uint32_t x334; + fiat_p256_uint1 x335; + uint32_t x336; + fiat_p256_uint1 x337; + uint32_t x338; + fiat_p256_uint1 x339; + uint32_t x340; + fiat_p256_uint1 x341; + uint32_t x342; + fiat_p256_uint1 x343; + uint32_t x344; + uint32_t x345; + fiat_p256_uint1 x346; + uint32_t x347; + fiat_p256_uint1 x348; + uint32_t x349; + fiat_p256_uint1 x350; + uint32_t x351; + fiat_p256_uint1 x352; + uint32_t x353; + fiat_p256_uint1 x354; + uint32_t x355; + fiat_p256_uint1 x356; + uint32_t x357; + fiat_p256_uint1 x358; + uint32_t x359; + fiat_p256_uint1 x360; + uint32_t x361; + fiat_p256_uint1 x362; + uint32_t x363; + uint32_t x364; + uint32_t x365; + uint32_t x366; + uint32_t x367; + uint32_t x368; + uint32_t x369; + uint32_t x370; + uint32_t x371; + fiat_p256_uint1 x372; + uint32_t x373; + fiat_p256_uint1 x374; + uint32_t x375; + uint32_t x376; + fiat_p256_uint1 x377; + uint32_t x378; + fiat_p256_uint1 x379; + uint32_t x380; + fiat_p256_uint1 x381; + uint32_t x382; + fiat_p256_uint1 x383; + uint32_t x384; + fiat_p256_uint1 x385; + uint32_t x386; + fiat_p256_uint1 x387; + uint32_t x388; + fiat_p256_uint1 x389; + uint32_t x390; + fiat_p256_uint1 x391; + uint32_t x392; + fiat_p256_uint1 x393; + uint32_t x394; + uint32_t x395; + uint32_t x396; + uint32_t x397; + uint32_t x398; + uint32_t x399; + uint32_t x400; + uint32_t x401; + uint32_t x402; + uint32_t x403; + uint32_t x404; + uint32_t x405; + uint32_t x406; + uint32_t x407; + uint32_t x408; + uint32_t x409; + uint32_t x410; + uint32_t x411; + fiat_p256_uint1 x412; + uint32_t x413; + fiat_p256_uint1 x414; + uint32_t x415; + fiat_p256_uint1 x416; + uint32_t x417; + fiat_p256_uint1 x418; + uint32_t x419; + fiat_p256_uint1 x420; + uint32_t x421; + fiat_p256_uint1 x422; + uint32_t x423; + fiat_p256_uint1 x424; + uint32_t x425; + uint32_t x426; + fiat_p256_uint1 x427; + uint32_t x428; + fiat_p256_uint1 x429; + uint32_t x430; + fiat_p256_uint1 x431; + uint32_t x432; + fiat_p256_uint1 x433; + uint32_t x434; + fiat_p256_uint1 x435; + uint32_t x436; + fiat_p256_uint1 x437; + uint32_t x438; + fiat_p256_uint1 x439; + uint32_t x440; + fiat_p256_uint1 x441; + uint32_t x442; + fiat_p256_uint1 x443; + uint32_t x444; + uint32_t x445; + uint32_t x446; + uint32_t x447; + uint32_t x448; + uint32_t x449; + uint32_t x450; + uint32_t x451; + uint32_t x452; + fiat_p256_uint1 x453; + uint32_t x454; + fiat_p256_uint1 x455; + uint32_t x456; + uint32_t x457; + fiat_p256_uint1 x458; + uint32_t x459; + fiat_p256_uint1 x460; + uint32_t x461; + fiat_p256_uint1 x462; + uint32_t x463; + fiat_p256_uint1 x464; + uint32_t x465; + fiat_p256_uint1 x466; + uint32_t x467; + fiat_p256_uint1 x468; + uint32_t x469; + fiat_p256_uint1 x470; + uint32_t x471; + fiat_p256_uint1 x472; + uint32_t x473; + fiat_p256_uint1 x474; + uint32_t x475; + uint32_t x476; + uint32_t x477; + uint32_t x478; + uint32_t x479; + uint32_t x480; + uint32_t x481; + uint32_t x482; + uint32_t x483; + uint32_t x484; + uint32_t x485; + uint32_t x486; + uint32_t x487; + uint32_t x488; + uint32_t x489; + uint32_t x490; + uint32_t x491; + uint32_t x492; + fiat_p256_uint1 x493; + uint32_t x494; + fiat_p256_uint1 x495; + uint32_t x496; + fiat_p256_uint1 x497; + uint32_t x498; + fiat_p256_uint1 x499; + uint32_t x500; + fiat_p256_uint1 x501; + uint32_t x502; + fiat_p256_uint1 x503; + uint32_t x504; + fiat_p256_uint1 x505; + uint32_t x506; + uint32_t x507; + fiat_p256_uint1 x508; + uint32_t x509; + fiat_p256_uint1 x510; + uint32_t x511; + fiat_p256_uint1 x512; + uint32_t x513; + fiat_p256_uint1 x514; + uint32_t x515; + fiat_p256_uint1 x516; + uint32_t x517; + fiat_p256_uint1 x518; + uint32_t x519; + fiat_p256_uint1 x520; + uint32_t x521; + fiat_p256_uint1 x522; + uint32_t x523; + fiat_p256_uint1 x524; + uint32_t x525; + uint32_t x526; + uint32_t x527; + uint32_t x528; + uint32_t x529; + uint32_t x530; + uint32_t x531; + uint32_t x532; + uint32_t x533; + fiat_p256_uint1 x534; + uint32_t x535; + fiat_p256_uint1 x536; + uint32_t x537; + uint32_t x538; + fiat_p256_uint1 x539; + uint32_t x540; + fiat_p256_uint1 x541; + uint32_t x542; + fiat_p256_uint1 x543; + uint32_t x544; + fiat_p256_uint1 x545; + uint32_t x546; + fiat_p256_uint1 x547; + uint32_t x548; + fiat_p256_uint1 x549; + uint32_t x550; + fiat_p256_uint1 x551; + uint32_t x552; + fiat_p256_uint1 x553; + uint32_t x554; + fiat_p256_uint1 x555; + uint32_t x556; + uint32_t x557; + uint32_t x558; + uint32_t x559; + uint32_t x560; + uint32_t x561; + uint32_t x562; + uint32_t x563; + uint32_t x564; + uint32_t x565; + uint32_t x566; + uint32_t x567; + uint32_t x568; + uint32_t x569; + uint32_t x570; + uint32_t x571; + uint32_t x572; + uint32_t x573; + fiat_p256_uint1 x574; + uint32_t x575; + fiat_p256_uint1 x576; + uint32_t x577; + fiat_p256_uint1 x578; + uint32_t x579; + fiat_p256_uint1 x580; + uint32_t x581; + fiat_p256_uint1 x582; + uint32_t x583; + fiat_p256_uint1 x584; + uint32_t x585; + fiat_p256_uint1 x586; + uint32_t x587; + uint32_t x588; + fiat_p256_uint1 x589; + uint32_t x590; + fiat_p256_uint1 x591; + uint32_t x592; + fiat_p256_uint1 x593; + uint32_t x594; + fiat_p256_uint1 x595; + uint32_t x596; + fiat_p256_uint1 x597; + uint32_t x598; + fiat_p256_uint1 x599; + uint32_t x600; + fiat_p256_uint1 x601; + uint32_t x602; + fiat_p256_uint1 x603; + uint32_t x604; + fiat_p256_uint1 x605; + uint32_t x606; + uint32_t x607; + uint32_t x608; + uint32_t x609; + uint32_t x610; + uint32_t x611; + uint32_t x612; + uint32_t x613; + uint32_t x614; + fiat_p256_uint1 x615; + uint32_t x616; + fiat_p256_uint1 x617; + uint32_t x618; + uint32_t x619; + fiat_p256_uint1 x620; + uint32_t x621; + fiat_p256_uint1 x622; + uint32_t x623; + fiat_p256_uint1 x624; + uint32_t x625; + fiat_p256_uint1 x626; + uint32_t x627; + fiat_p256_uint1 x628; + uint32_t x629; + fiat_p256_uint1 x630; + uint32_t x631; + fiat_p256_uint1 x632; + uint32_t x633; + fiat_p256_uint1 x634; + uint32_t x635; + fiat_p256_uint1 x636; + uint32_t x637; + uint32_t x638; + fiat_p256_uint1 x639; + uint32_t x640; + fiat_p256_uint1 x641; + uint32_t x642; + fiat_p256_uint1 x643; + uint32_t x644; + fiat_p256_uint1 x645; + uint32_t x646; + fiat_p256_uint1 x647; + uint32_t x648; + fiat_p256_uint1 x649; + uint32_t x650; + fiat_p256_uint1 x651; + uint32_t x652; + fiat_p256_uint1 x653; + uint32_t x654; + fiat_p256_uint1 x655; + uint32_t x656; + uint32_t x657; + uint32_t x658; + uint32_t x659; + uint32_t x660; + uint32_t x661; + uint32_t x662; + uint32_t x663; + x1 = (arg1[1]); + x2 = (arg1[2]); + x3 = (arg1[3]); + x4 = (arg1[4]); + x5 = (arg1[5]); + x6 = (arg1[6]); + x7 = (arg1[7]); + x8 = (arg1[0]); + fiat_p256_mulx_u32(&x9, &x10, x8, (arg2[7])); + fiat_p256_mulx_u32(&x11, &x12, x8, (arg2[6])); + fiat_p256_mulx_u32(&x13, &x14, x8, (arg2[5])); + fiat_p256_mulx_u32(&x15, &x16, x8, (arg2[4])); + fiat_p256_mulx_u32(&x17, &x18, x8, (arg2[3])); + fiat_p256_mulx_u32(&x19, &x20, x8, (arg2[2])); + fiat_p256_mulx_u32(&x21, &x22, x8, (arg2[1])); + fiat_p256_mulx_u32(&x23, &x24, x8, (arg2[0])); + fiat_p256_addcarryx_u32(&x25, &x26, 0x0, x24, x21); + fiat_p256_addcarryx_u32(&x27, &x28, x26, x22, x19); + fiat_p256_addcarryx_u32(&x29, &x30, x28, x20, x17); + fiat_p256_addcarryx_u32(&x31, &x32, x30, x18, x15); + fiat_p256_addcarryx_u32(&x33, &x34, x32, x16, x13); + fiat_p256_addcarryx_u32(&x35, &x36, x34, x14, x11); + fiat_p256_addcarryx_u32(&x37, &x38, x36, x12, x9); + x39 = (x38 + x10); + fiat_p256_mulx_u32(&x40, &x41, x23, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x42, &x43, x23, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x44, &x45, x23, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x46, &x47, x23, UINT32_C(0xffffffff)); + fiat_p256_addcarryx_u32(&x48, &x49, 0x0, x47, x44); + fiat_p256_addcarryx_u32(&x50, &x51, x49, x45, x42); + x52 = (x51 + x43); + fiat_p256_addcarryx_u32(&x53, &x54, 0x0, x23, x46); + fiat_p256_addcarryx_u32(&x55, &x56, x54, x25, x48); + fiat_p256_addcarryx_u32(&x57, &x58, x56, x27, x50); + fiat_p256_addcarryx_u32(&x59, &x60, x58, x29, x52); + fiat_p256_addcarryx_u32(&x61, &x62, x60, x31, 0x0); + fiat_p256_addcarryx_u32(&x63, &x64, x62, x33, 0x0); + fiat_p256_addcarryx_u32(&x65, &x66, x64, x35, x23); + fiat_p256_addcarryx_u32(&x67, &x68, x66, x37, x40); + fiat_p256_addcarryx_u32(&x69, &x70, x68, x39, x41); + fiat_p256_mulx_u32(&x71, &x72, x1, (arg2[7])); + fiat_p256_mulx_u32(&x73, &x74, x1, (arg2[6])); + fiat_p256_mulx_u32(&x75, &x76, x1, (arg2[5])); + fiat_p256_mulx_u32(&x77, &x78, x1, (arg2[4])); + fiat_p256_mulx_u32(&x79, &x80, x1, (arg2[3])); + fiat_p256_mulx_u32(&x81, &x82, x1, (arg2[2])); + fiat_p256_mulx_u32(&x83, &x84, x1, (arg2[1])); + fiat_p256_mulx_u32(&x85, &x86, x1, (arg2[0])); + fiat_p256_addcarryx_u32(&x87, &x88, 0x0, x86, x83); + fiat_p256_addcarryx_u32(&x89, &x90, x88, x84, x81); + fiat_p256_addcarryx_u32(&x91, &x92, x90, x82, x79); + fiat_p256_addcarryx_u32(&x93, &x94, x92, x80, x77); + fiat_p256_addcarryx_u32(&x95, &x96, x94, x78, x75); + fiat_p256_addcarryx_u32(&x97, &x98, x96, x76, x73); + fiat_p256_addcarryx_u32(&x99, &x100, x98, x74, x71); + x101 = (x100 + x72); + fiat_p256_addcarryx_u32(&x102, &x103, 0x0, x55, x85); + fiat_p256_addcarryx_u32(&x104, &x105, x103, x57, x87); + fiat_p256_addcarryx_u32(&x106, &x107, x105, x59, x89); + fiat_p256_addcarryx_u32(&x108, &x109, x107, x61, x91); + fiat_p256_addcarryx_u32(&x110, &x111, x109, x63, x93); + fiat_p256_addcarryx_u32(&x112, &x113, x111, x65, x95); + fiat_p256_addcarryx_u32(&x114, &x115, x113, x67, x97); + fiat_p256_addcarryx_u32(&x116, &x117, x115, x69, x99); + fiat_p256_addcarryx_u32(&x118, &x119, x117, x70, x101); + fiat_p256_mulx_u32(&x120, &x121, x102, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x122, &x123, x102, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x124, &x125, x102, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x126, &x127, x102, UINT32_C(0xffffffff)); + fiat_p256_addcarryx_u32(&x128, &x129, 0x0, x127, x124); + fiat_p256_addcarryx_u32(&x130, &x131, x129, x125, x122); + x132 = (x131 + x123); + fiat_p256_addcarryx_u32(&x133, &x134, 0x0, x102, x126); + fiat_p256_addcarryx_u32(&x135, &x136, x134, x104, x128); + fiat_p256_addcarryx_u32(&x137, &x138, x136, x106, x130); + fiat_p256_addcarryx_u32(&x139, &x140, x138, x108, x132); + fiat_p256_addcarryx_u32(&x141, &x142, x140, x110, 0x0); + fiat_p256_addcarryx_u32(&x143, &x144, x142, x112, 0x0); + fiat_p256_addcarryx_u32(&x145, &x146, x144, x114, x102); + fiat_p256_addcarryx_u32(&x147, &x148, x146, x116, x120); + fiat_p256_addcarryx_u32(&x149, &x150, x148, x118, x121); + x151 = ((uint32_t)x150 + x119); + fiat_p256_mulx_u32(&x152, &x153, x2, (arg2[7])); + fiat_p256_mulx_u32(&x154, &x155, x2, (arg2[6])); + fiat_p256_mulx_u32(&x156, &x157, x2, (arg2[5])); + fiat_p256_mulx_u32(&x158, &x159, x2, (arg2[4])); + fiat_p256_mulx_u32(&x160, &x161, x2, (arg2[3])); + fiat_p256_mulx_u32(&x162, &x163, x2, (arg2[2])); + fiat_p256_mulx_u32(&x164, &x165, x2, (arg2[1])); + fiat_p256_mulx_u32(&x166, &x167, x2, (arg2[0])); + fiat_p256_addcarryx_u32(&x168, &x169, 0x0, x167, x164); + fiat_p256_addcarryx_u32(&x170, &x171, x169, x165, x162); + fiat_p256_addcarryx_u32(&x172, &x173, x171, x163, x160); + fiat_p256_addcarryx_u32(&x174, &x175, x173, x161, x158); + fiat_p256_addcarryx_u32(&x176, &x177, x175, x159, x156); + fiat_p256_addcarryx_u32(&x178, &x179, x177, x157, x154); + fiat_p256_addcarryx_u32(&x180, &x181, x179, x155, x152); + x182 = (x181 + x153); + fiat_p256_addcarryx_u32(&x183, &x184, 0x0, x135, x166); + fiat_p256_addcarryx_u32(&x185, &x186, x184, x137, x168); + fiat_p256_addcarryx_u32(&x187, &x188, x186, x139, x170); + fiat_p256_addcarryx_u32(&x189, &x190, x188, x141, x172); + fiat_p256_addcarryx_u32(&x191, &x192, x190, x143, x174); + fiat_p256_addcarryx_u32(&x193, &x194, x192, x145, x176); + fiat_p256_addcarryx_u32(&x195, &x196, x194, x147, x178); + fiat_p256_addcarryx_u32(&x197, &x198, x196, x149, x180); + fiat_p256_addcarryx_u32(&x199, &x200, x198, x151, x182); + fiat_p256_mulx_u32(&x201, &x202, x183, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x203, &x204, x183, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x205, &x206, x183, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x207, &x208, x183, UINT32_C(0xffffffff)); + fiat_p256_addcarryx_u32(&x209, &x210, 0x0, x208, x205); + fiat_p256_addcarryx_u32(&x211, &x212, x210, x206, x203); + x213 = (x212 + x204); + fiat_p256_addcarryx_u32(&x214, &x215, 0x0, x183, x207); + fiat_p256_addcarryx_u32(&x216, &x217, x215, x185, x209); + fiat_p256_addcarryx_u32(&x218, &x219, x217, x187, x211); + fiat_p256_addcarryx_u32(&x220, &x221, x219, x189, x213); + fiat_p256_addcarryx_u32(&x222, &x223, x221, x191, 0x0); + fiat_p256_addcarryx_u32(&x224, &x225, x223, x193, 0x0); + fiat_p256_addcarryx_u32(&x226, &x227, x225, x195, x183); + fiat_p256_addcarryx_u32(&x228, &x229, x227, x197, x201); + fiat_p256_addcarryx_u32(&x230, &x231, x229, x199, x202); + x232 = ((uint32_t)x231 + x200); + fiat_p256_mulx_u32(&x233, &x234, x3, (arg2[7])); + fiat_p256_mulx_u32(&x235, &x236, x3, (arg2[6])); + fiat_p256_mulx_u32(&x237, &x238, x3, (arg2[5])); + fiat_p256_mulx_u32(&x239, &x240, x3, (arg2[4])); + fiat_p256_mulx_u32(&x241, &x242, x3, (arg2[3])); + fiat_p256_mulx_u32(&x243, &x244, x3, (arg2[2])); + fiat_p256_mulx_u32(&x245, &x246, x3, (arg2[1])); + fiat_p256_mulx_u32(&x247, &x248, x3, (arg2[0])); + fiat_p256_addcarryx_u32(&x249, &x250, 0x0, x248, x245); + fiat_p256_addcarryx_u32(&x251, &x252, x250, x246, x243); + fiat_p256_addcarryx_u32(&x253, &x254, x252, x244, x241); + fiat_p256_addcarryx_u32(&x255, &x256, x254, x242, x239); + fiat_p256_addcarryx_u32(&x257, &x258, x256, x240, x237); + fiat_p256_addcarryx_u32(&x259, &x260, x258, x238, x235); + fiat_p256_addcarryx_u32(&x261, &x262, x260, x236, x233); + x263 = (x262 + x234); + fiat_p256_addcarryx_u32(&x264, &x265, 0x0, x216, x247); + fiat_p256_addcarryx_u32(&x266, &x267, x265, x218, x249); + fiat_p256_addcarryx_u32(&x268, &x269, x267, x220, x251); + fiat_p256_addcarryx_u32(&x270, &x271, x269, x222, x253); + fiat_p256_addcarryx_u32(&x272, &x273, x271, x224, x255); + fiat_p256_addcarryx_u32(&x274, &x275, x273, x226, x257); + fiat_p256_addcarryx_u32(&x276, &x277, x275, x228, x259); + fiat_p256_addcarryx_u32(&x278, &x279, x277, x230, x261); + fiat_p256_addcarryx_u32(&x280, &x281, x279, x232, x263); + fiat_p256_mulx_u32(&x282, &x283, x264, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x284, &x285, x264, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x286, &x287, x264, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x288, &x289, x264, UINT32_C(0xffffffff)); + fiat_p256_addcarryx_u32(&x290, &x291, 0x0, x289, x286); + fiat_p256_addcarryx_u32(&x292, &x293, x291, x287, x284); + x294 = (x293 + x285); + fiat_p256_addcarryx_u32(&x295, &x296, 0x0, x264, x288); + fiat_p256_addcarryx_u32(&x297, &x298, x296, x266, x290); + fiat_p256_addcarryx_u32(&x299, &x300, x298, x268, x292); + fiat_p256_addcarryx_u32(&x301, &x302, x300, x270, x294); + fiat_p256_addcarryx_u32(&x303, &x304, x302, x272, 0x0); + fiat_p256_addcarryx_u32(&x305, &x306, x304, x274, 0x0); + fiat_p256_addcarryx_u32(&x307, &x308, x306, x276, x264); + fiat_p256_addcarryx_u32(&x309, &x310, x308, x278, x282); + fiat_p256_addcarryx_u32(&x311, &x312, x310, x280, x283); + x313 = ((uint32_t)x312 + x281); + fiat_p256_mulx_u32(&x314, &x315, x4, (arg2[7])); + fiat_p256_mulx_u32(&x316, &x317, x4, (arg2[6])); + fiat_p256_mulx_u32(&x318, &x319, x4, (arg2[5])); + fiat_p256_mulx_u32(&x320, &x321, x4, (arg2[4])); + fiat_p256_mulx_u32(&x322, &x323, x4, (arg2[3])); + fiat_p256_mulx_u32(&x324, &x325, x4, (arg2[2])); + fiat_p256_mulx_u32(&x326, &x327, x4, (arg2[1])); + fiat_p256_mulx_u32(&x328, &x329, x4, (arg2[0])); + fiat_p256_addcarryx_u32(&x330, &x331, 0x0, x329, x326); + fiat_p256_addcarryx_u32(&x332, &x333, x331, x327, x324); + fiat_p256_addcarryx_u32(&x334, &x335, x333, x325, x322); + fiat_p256_addcarryx_u32(&x336, &x337, x335, x323, x320); + fiat_p256_addcarryx_u32(&x338, &x339, x337, x321, x318); + fiat_p256_addcarryx_u32(&x340, &x341, x339, x319, x316); + fiat_p256_addcarryx_u32(&x342, &x343, x341, x317, x314); + x344 = (x343 + x315); + fiat_p256_addcarryx_u32(&x345, &x346, 0x0, x297, x328); + fiat_p256_addcarryx_u32(&x347, &x348, x346, x299, x330); + fiat_p256_addcarryx_u32(&x349, &x350, x348, x301, x332); + fiat_p256_addcarryx_u32(&x351, &x352, x350, x303, x334); + fiat_p256_addcarryx_u32(&x353, &x354, x352, x305, x336); + fiat_p256_addcarryx_u32(&x355, &x356, x354, x307, x338); + fiat_p256_addcarryx_u32(&x357, &x358, x356, x309, x340); + fiat_p256_addcarryx_u32(&x359, &x360, x358, x311, x342); + fiat_p256_addcarryx_u32(&x361, &x362, x360, x313, x344); + fiat_p256_mulx_u32(&x363, &x364, x345, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x365, &x366, x345, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x367, &x368, x345, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x369, &x370, x345, UINT32_C(0xffffffff)); + fiat_p256_addcarryx_u32(&x371, &x372, 0x0, x370, x367); + fiat_p256_addcarryx_u32(&x373, &x374, x372, x368, x365); + x375 = (x374 + x366); + fiat_p256_addcarryx_u32(&x376, &x377, 0x0, x345, x369); + fiat_p256_addcarryx_u32(&x378, &x379, x377, x347, x371); + fiat_p256_addcarryx_u32(&x380, &x381, x379, x349, x373); + fiat_p256_addcarryx_u32(&x382, &x383, x381, x351, x375); + fiat_p256_addcarryx_u32(&x384, &x385, x383, x353, 0x0); + fiat_p256_addcarryx_u32(&x386, &x387, x385, x355, 0x0); + fiat_p256_addcarryx_u32(&x388, &x389, x387, x357, x345); + fiat_p256_addcarryx_u32(&x390, &x391, x389, x359, x363); + fiat_p256_addcarryx_u32(&x392, &x393, x391, x361, x364); + x394 = ((uint32_t)x393 + x362); + fiat_p256_mulx_u32(&x395, &x396, x5, (arg2[7])); + fiat_p256_mulx_u32(&x397, &x398, x5, (arg2[6])); + fiat_p256_mulx_u32(&x399, &x400, x5, (arg2[5])); + fiat_p256_mulx_u32(&x401, &x402, x5, (arg2[4])); + fiat_p256_mulx_u32(&x403, &x404, x5, (arg2[3])); + fiat_p256_mulx_u32(&x405, &x406, x5, (arg2[2])); + fiat_p256_mulx_u32(&x407, &x408, x5, (arg2[1])); + fiat_p256_mulx_u32(&x409, &x410, x5, (arg2[0])); + fiat_p256_addcarryx_u32(&x411, &x412, 0x0, x410, x407); + fiat_p256_addcarryx_u32(&x413, &x414, x412, x408, x405); + fiat_p256_addcarryx_u32(&x415, &x416, x414, x406, x403); + fiat_p256_addcarryx_u32(&x417, &x418, x416, x404, x401); + fiat_p256_addcarryx_u32(&x419, &x420, x418, x402, x399); + fiat_p256_addcarryx_u32(&x421, &x422, x420, x400, x397); + fiat_p256_addcarryx_u32(&x423, &x424, x422, x398, x395); + x425 = (x424 + x396); + fiat_p256_addcarryx_u32(&x426, &x427, 0x0, x378, x409); + fiat_p256_addcarryx_u32(&x428, &x429, x427, x380, x411); + fiat_p256_addcarryx_u32(&x430, &x431, x429, x382, x413); + fiat_p256_addcarryx_u32(&x432, &x433, x431, x384, x415); + fiat_p256_addcarryx_u32(&x434, &x435, x433, x386, x417); + fiat_p256_addcarryx_u32(&x436, &x437, x435, x388, x419); + fiat_p256_addcarryx_u32(&x438, &x439, x437, x390, x421); + fiat_p256_addcarryx_u32(&x440, &x441, x439, x392, x423); + fiat_p256_addcarryx_u32(&x442, &x443, x441, x394, x425); + fiat_p256_mulx_u32(&x444, &x445, x426, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x446, &x447, x426, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x448, &x449, x426, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x450, &x451, x426, UINT32_C(0xffffffff)); + fiat_p256_addcarryx_u32(&x452, &x453, 0x0, x451, x448); + fiat_p256_addcarryx_u32(&x454, &x455, x453, x449, x446); + x456 = (x455 + x447); + fiat_p256_addcarryx_u32(&x457, &x458, 0x0, x426, x450); + fiat_p256_addcarryx_u32(&x459, &x460, x458, x428, x452); + fiat_p256_addcarryx_u32(&x461, &x462, x460, x430, x454); + fiat_p256_addcarryx_u32(&x463, &x464, x462, x432, x456); + fiat_p256_addcarryx_u32(&x465, &x466, x464, x434, 0x0); + fiat_p256_addcarryx_u32(&x467, &x468, x466, x436, 0x0); + fiat_p256_addcarryx_u32(&x469, &x470, x468, x438, x426); + fiat_p256_addcarryx_u32(&x471, &x472, x470, x440, x444); + fiat_p256_addcarryx_u32(&x473, &x474, x472, x442, x445); + x475 = ((uint32_t)x474 + x443); + fiat_p256_mulx_u32(&x476, &x477, x6, (arg2[7])); + fiat_p256_mulx_u32(&x478, &x479, x6, (arg2[6])); + fiat_p256_mulx_u32(&x480, &x481, x6, (arg2[5])); + fiat_p256_mulx_u32(&x482, &x483, x6, (arg2[4])); + fiat_p256_mulx_u32(&x484, &x485, x6, (arg2[3])); + fiat_p256_mulx_u32(&x486, &x487, x6, (arg2[2])); + fiat_p256_mulx_u32(&x488, &x489, x6, (arg2[1])); + fiat_p256_mulx_u32(&x490, &x491, x6, (arg2[0])); + fiat_p256_addcarryx_u32(&x492, &x493, 0x0, x491, x488); + fiat_p256_addcarryx_u32(&x494, &x495, x493, x489, x486); + fiat_p256_addcarryx_u32(&x496, &x497, x495, x487, x484); + fiat_p256_addcarryx_u32(&x498, &x499, x497, x485, x482); + fiat_p256_addcarryx_u32(&x500, &x501, x499, x483, x480); + fiat_p256_addcarryx_u32(&x502, &x503, x501, x481, x478); + fiat_p256_addcarryx_u32(&x504, &x505, x503, x479, x476); + x506 = (x505 + x477); + fiat_p256_addcarryx_u32(&x507, &x508, 0x0, x459, x490); + fiat_p256_addcarryx_u32(&x509, &x510, x508, x461, x492); + fiat_p256_addcarryx_u32(&x511, &x512, x510, x463, x494); + fiat_p256_addcarryx_u32(&x513, &x514, x512, x465, x496); + fiat_p256_addcarryx_u32(&x515, &x516, x514, x467, x498); + fiat_p256_addcarryx_u32(&x517, &x518, x516, x469, x500); + fiat_p256_addcarryx_u32(&x519, &x520, x518, x471, x502); + fiat_p256_addcarryx_u32(&x521, &x522, x520, x473, x504); + fiat_p256_addcarryx_u32(&x523, &x524, x522, x475, x506); + fiat_p256_mulx_u32(&x525, &x526, x507, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x527, &x528, x507, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x529, &x530, x507, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x531, &x532, x507, UINT32_C(0xffffffff)); + fiat_p256_addcarryx_u32(&x533, &x534, 0x0, x532, x529); + fiat_p256_addcarryx_u32(&x535, &x536, x534, x530, x527); + x537 = (x536 + x528); + fiat_p256_addcarryx_u32(&x538, &x539, 0x0, x507, x531); + fiat_p256_addcarryx_u32(&x540, &x541, x539, x509, x533); + fiat_p256_addcarryx_u32(&x542, &x543, x541, x511, x535); + fiat_p256_addcarryx_u32(&x544, &x545, x543, x513, x537); + fiat_p256_addcarryx_u32(&x546, &x547, x545, x515, 0x0); + fiat_p256_addcarryx_u32(&x548, &x549, x547, x517, 0x0); + fiat_p256_addcarryx_u32(&x550, &x551, x549, x519, x507); + fiat_p256_addcarryx_u32(&x552, &x553, x551, x521, x525); + fiat_p256_addcarryx_u32(&x554, &x555, x553, x523, x526); + x556 = ((uint32_t)x555 + x524); + fiat_p256_mulx_u32(&x557, &x558, x7, (arg2[7])); + fiat_p256_mulx_u32(&x559, &x560, x7, (arg2[6])); + fiat_p256_mulx_u32(&x561, &x562, x7, (arg2[5])); + fiat_p256_mulx_u32(&x563, &x564, x7, (arg2[4])); + fiat_p256_mulx_u32(&x565, &x566, x7, (arg2[3])); + fiat_p256_mulx_u32(&x567, &x568, x7, (arg2[2])); + fiat_p256_mulx_u32(&x569, &x570, x7, (arg2[1])); + fiat_p256_mulx_u32(&x571, &x572, x7, (arg2[0])); + fiat_p256_addcarryx_u32(&x573, &x574, 0x0, x572, x569); + fiat_p256_addcarryx_u32(&x575, &x576, x574, x570, x567); + fiat_p256_addcarryx_u32(&x577, &x578, x576, x568, x565); + fiat_p256_addcarryx_u32(&x579, &x580, x578, x566, x563); + fiat_p256_addcarryx_u32(&x581, &x582, x580, x564, x561); + fiat_p256_addcarryx_u32(&x583, &x584, x582, x562, x559); + fiat_p256_addcarryx_u32(&x585, &x586, x584, x560, x557); + x587 = (x586 + x558); + fiat_p256_addcarryx_u32(&x588, &x589, 0x0, x540, x571); + fiat_p256_addcarryx_u32(&x590, &x591, x589, x542, x573); + fiat_p256_addcarryx_u32(&x592, &x593, x591, x544, x575); + fiat_p256_addcarryx_u32(&x594, &x595, x593, x546, x577); + fiat_p256_addcarryx_u32(&x596, &x597, x595, x548, x579); + fiat_p256_addcarryx_u32(&x598, &x599, x597, x550, x581); + fiat_p256_addcarryx_u32(&x600, &x601, x599, x552, x583); + fiat_p256_addcarryx_u32(&x602, &x603, x601, x554, x585); + fiat_p256_addcarryx_u32(&x604, &x605, x603, x556, x587); + fiat_p256_mulx_u32(&x606, &x607, x588, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x608, &x609, x588, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x610, &x611, x588, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x612, &x613, x588, UINT32_C(0xffffffff)); + fiat_p256_addcarryx_u32(&x614, &x615, 0x0, x613, x610); + fiat_p256_addcarryx_u32(&x616, &x617, x615, x611, x608); + x618 = (x617 + x609); + fiat_p256_addcarryx_u32(&x619, &x620, 0x0, x588, x612); + fiat_p256_addcarryx_u32(&x621, &x622, x620, x590, x614); + fiat_p256_addcarryx_u32(&x623, &x624, x622, x592, x616); + fiat_p256_addcarryx_u32(&x625, &x626, x624, x594, x618); + fiat_p256_addcarryx_u32(&x627, &x628, x626, x596, 0x0); + fiat_p256_addcarryx_u32(&x629, &x630, x628, x598, 0x0); + fiat_p256_addcarryx_u32(&x631, &x632, x630, x600, x588); + fiat_p256_addcarryx_u32(&x633, &x634, x632, x602, x606); + fiat_p256_addcarryx_u32(&x635, &x636, x634, x604, x607); + x637 = ((uint32_t)x636 + x605); + fiat_p256_subborrowx_u32(&x638, &x639, 0x0, x621, UINT32_C(0xffffffff)); + fiat_p256_subborrowx_u32(&x640, &x641, x639, x623, UINT32_C(0xffffffff)); + fiat_p256_subborrowx_u32(&x642, &x643, x641, x625, UINT32_C(0xffffffff)); + fiat_p256_subborrowx_u32(&x644, &x645, x643, x627, 0x0); + fiat_p256_subborrowx_u32(&x646, &x647, x645, x629, 0x0); + fiat_p256_subborrowx_u32(&x648, &x649, x647, x631, 0x0); + fiat_p256_subborrowx_u32(&x650, &x651, x649, x633, 0x1); + fiat_p256_subborrowx_u32(&x652, &x653, x651, x635, UINT32_C(0xffffffff)); + fiat_p256_subborrowx_u32(&x654, &x655, x653, x637, 0x0); + fiat_p256_cmovznz_u32(&x656, x655, x638, x621); + fiat_p256_cmovznz_u32(&x657, x655, x640, x623); + fiat_p256_cmovznz_u32(&x658, x655, x642, x625); + fiat_p256_cmovznz_u32(&x659, x655, x644, x627); + fiat_p256_cmovznz_u32(&x660, x655, x646, x629); + fiat_p256_cmovznz_u32(&x661, x655, x648, x631); + fiat_p256_cmovznz_u32(&x662, x655, x650, x633); + fiat_p256_cmovznz_u32(&x663, x655, x652, x635); + out1[0] = x656; + out1[1] = x657; + out1[2] = x658; + out1[3] = x659; + out1[4] = x660; + out1[5] = x661; + out1[6] = x662; + out1[7] = x663; +} + +/* + * The function fiat_p256_square squares a field element in the Montgomery domain. + * + * Preconditions: + * 0 ≤ eval arg1 < m + * Postconditions: + * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) * eval (from_montgomery arg1)) mod m + * 0 ≤ eval out1 < m + * + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_square(fiat_p256_montgomery_domain_field_element out1, const fiat_p256_montgomery_domain_field_element arg1) { + uint32_t x1; + uint32_t x2; + uint32_t x3; + uint32_t x4; + uint32_t x5; + uint32_t x6; + uint32_t x7; + uint32_t x8; + uint32_t x9; + uint32_t x10; + uint32_t x11; + uint32_t x12; + uint32_t x13; + uint32_t x14; + uint32_t x15; + uint32_t x16; + uint32_t x17; + uint32_t x18; + uint32_t x19; + uint32_t x20; + uint32_t x21; + uint32_t x22; + uint32_t x23; + uint32_t x24; + uint32_t x25; + fiat_p256_uint1 x26; + uint32_t x27; + fiat_p256_uint1 x28; + uint32_t x29; + fiat_p256_uint1 x30; + uint32_t x31; + fiat_p256_uint1 x32; + uint32_t x33; + fiat_p256_uint1 x34; + uint32_t x35; + fiat_p256_uint1 x36; + uint32_t x37; + fiat_p256_uint1 x38; + uint32_t x39; + uint32_t x40; + uint32_t x41; + uint32_t x42; + uint32_t x43; + uint32_t x44; + uint32_t x45; + uint32_t x46; + uint32_t x47; + uint32_t x48; + fiat_p256_uint1 x49; + uint32_t x50; + fiat_p256_uint1 x51; + uint32_t x52; + uint32_t x53; + fiat_p256_uint1 x54; + uint32_t x55; + fiat_p256_uint1 x56; + uint32_t x57; + fiat_p256_uint1 x58; + uint32_t x59; + fiat_p256_uint1 x60; + uint32_t x61; + fiat_p256_uint1 x62; + uint32_t x63; + fiat_p256_uint1 x64; + uint32_t x65; + fiat_p256_uint1 x66; + uint32_t x67; + fiat_p256_uint1 x68; + uint32_t x69; + fiat_p256_uint1 x70; + uint32_t x71; + uint32_t x72; + uint32_t x73; + uint32_t x74; + uint32_t x75; + uint32_t x76; + uint32_t x77; + uint32_t x78; + uint32_t x79; + uint32_t x80; + uint32_t x81; + uint32_t x82; + uint32_t x83; + uint32_t x84; + uint32_t x85; + uint32_t x86; + uint32_t x87; + fiat_p256_uint1 x88; + uint32_t x89; + fiat_p256_uint1 x90; + uint32_t x91; + fiat_p256_uint1 x92; + uint32_t x93; + fiat_p256_uint1 x94; + uint32_t x95; + fiat_p256_uint1 x96; + uint32_t x97; + fiat_p256_uint1 x98; + uint32_t x99; + fiat_p256_uint1 x100; + uint32_t x101; + uint32_t x102; + fiat_p256_uint1 x103; + uint32_t x104; + fiat_p256_uint1 x105; + uint32_t x106; + fiat_p256_uint1 x107; + uint32_t x108; + fiat_p256_uint1 x109; + uint32_t x110; + fiat_p256_uint1 x111; + uint32_t x112; + fiat_p256_uint1 x113; + uint32_t x114; + fiat_p256_uint1 x115; + uint32_t x116; + fiat_p256_uint1 x117; + uint32_t x118; + fiat_p256_uint1 x119; + uint32_t x120; + uint32_t x121; + uint32_t x122; + uint32_t x123; + uint32_t x124; + uint32_t x125; + uint32_t x126; + uint32_t x127; + uint32_t x128; + fiat_p256_uint1 x129; + uint32_t x130; + fiat_p256_uint1 x131; + uint32_t x132; + uint32_t x133; + fiat_p256_uint1 x134; + uint32_t x135; + fiat_p256_uint1 x136; + uint32_t x137; + fiat_p256_uint1 x138; + uint32_t x139; + fiat_p256_uint1 x140; + uint32_t x141; + fiat_p256_uint1 x142; + uint32_t x143; + fiat_p256_uint1 x144; + uint32_t x145; + fiat_p256_uint1 x146; + uint32_t x147; + fiat_p256_uint1 x148; + uint32_t x149; + fiat_p256_uint1 x150; + uint32_t x151; + uint32_t x152; + uint32_t x153; + uint32_t x154; + uint32_t x155; + uint32_t x156; + uint32_t x157; + uint32_t x158; + uint32_t x159; + uint32_t x160; + uint32_t x161; + uint32_t x162; + uint32_t x163; + uint32_t x164; + uint32_t x165; + uint32_t x166; + uint32_t x167; + uint32_t x168; + fiat_p256_uint1 x169; + uint32_t x170; + fiat_p256_uint1 x171; + uint32_t x172; + fiat_p256_uint1 x173; + uint32_t x174; + fiat_p256_uint1 x175; + uint32_t x176; + fiat_p256_uint1 x177; + uint32_t x178; + fiat_p256_uint1 x179; + uint32_t x180; + fiat_p256_uint1 x181; + uint32_t x182; + uint32_t x183; + fiat_p256_uint1 x184; + uint32_t x185; + fiat_p256_uint1 x186; + uint32_t x187; + fiat_p256_uint1 x188; + uint32_t x189; + fiat_p256_uint1 x190; + uint32_t x191; + fiat_p256_uint1 x192; + uint32_t x193; + fiat_p256_uint1 x194; + uint32_t x195; + fiat_p256_uint1 x196; + uint32_t x197; + fiat_p256_uint1 x198; + uint32_t x199; + fiat_p256_uint1 x200; + uint32_t x201; + uint32_t x202; + uint32_t x203; + uint32_t x204; + uint32_t x205; + uint32_t x206; + uint32_t x207; + uint32_t x208; + uint32_t x209; + fiat_p256_uint1 x210; + uint32_t x211; + fiat_p256_uint1 x212; + uint32_t x213; + uint32_t x214; + fiat_p256_uint1 x215; + uint32_t x216; + fiat_p256_uint1 x217; + uint32_t x218; + fiat_p256_uint1 x219; + uint32_t x220; + fiat_p256_uint1 x221; + uint32_t x222; + fiat_p256_uint1 x223; + uint32_t x224; + fiat_p256_uint1 x225; + uint32_t x226; + fiat_p256_uint1 x227; + uint32_t x228; + fiat_p256_uint1 x229; + uint32_t x230; + fiat_p256_uint1 x231; + uint32_t x232; + uint32_t x233; + uint32_t x234; + uint32_t x235; + uint32_t x236; + uint32_t x237; + uint32_t x238; + uint32_t x239; + uint32_t x240; + uint32_t x241; + uint32_t x242; + uint32_t x243; + uint32_t x244; + uint32_t x245; + uint32_t x246; + uint32_t x247; + uint32_t x248; + uint32_t x249; + fiat_p256_uint1 x250; + uint32_t x251; + fiat_p256_uint1 x252; + uint32_t x253; + fiat_p256_uint1 x254; + uint32_t x255; + fiat_p256_uint1 x256; + uint32_t x257; + fiat_p256_uint1 x258; + uint32_t x259; + fiat_p256_uint1 x260; + uint32_t x261; + fiat_p256_uint1 x262; + uint32_t x263; + uint32_t x264; + fiat_p256_uint1 x265; + uint32_t x266; + fiat_p256_uint1 x267; + uint32_t x268; + fiat_p256_uint1 x269; + uint32_t x270; + fiat_p256_uint1 x271; + uint32_t x272; + fiat_p256_uint1 x273; + uint32_t x274; + fiat_p256_uint1 x275; + uint32_t x276; + fiat_p256_uint1 x277; + uint32_t x278; + fiat_p256_uint1 x279; + uint32_t x280; + fiat_p256_uint1 x281; + uint32_t x282; + uint32_t x283; + uint32_t x284; + uint32_t x285; + uint32_t x286; + uint32_t x287; + uint32_t x288; + uint32_t x289; + uint32_t x290; + fiat_p256_uint1 x291; + uint32_t x292; + fiat_p256_uint1 x293; + uint32_t x294; + uint32_t x295; + fiat_p256_uint1 x296; + uint32_t x297; + fiat_p256_uint1 x298; + uint32_t x299; + fiat_p256_uint1 x300; + uint32_t x301; + fiat_p256_uint1 x302; + uint32_t x303; + fiat_p256_uint1 x304; + uint32_t x305; + fiat_p256_uint1 x306; + uint32_t x307; + fiat_p256_uint1 x308; + uint32_t x309; + fiat_p256_uint1 x310; + uint32_t x311; + fiat_p256_uint1 x312; + uint32_t x313; + uint32_t x314; + uint32_t x315; + uint32_t x316; + uint32_t x317; + uint32_t x318; + uint32_t x319; + uint32_t x320; + uint32_t x321; + uint32_t x322; + uint32_t x323; + uint32_t x324; + uint32_t x325; + uint32_t x326; + uint32_t x327; + uint32_t x328; + uint32_t x329; + uint32_t x330; + fiat_p256_uint1 x331; + uint32_t x332; + fiat_p256_uint1 x333; + uint32_t x334; + fiat_p256_uint1 x335; + uint32_t x336; + fiat_p256_uint1 x337; + uint32_t x338; + fiat_p256_uint1 x339; + uint32_t x340; + fiat_p256_uint1 x341; + uint32_t x342; + fiat_p256_uint1 x343; + uint32_t x344; + uint32_t x345; + fiat_p256_uint1 x346; + uint32_t x347; + fiat_p256_uint1 x348; + uint32_t x349; + fiat_p256_uint1 x350; + uint32_t x351; + fiat_p256_uint1 x352; + uint32_t x353; + fiat_p256_uint1 x354; + uint32_t x355; + fiat_p256_uint1 x356; + uint32_t x357; + fiat_p256_uint1 x358; + uint32_t x359; + fiat_p256_uint1 x360; + uint32_t x361; + fiat_p256_uint1 x362; + uint32_t x363; + uint32_t x364; + uint32_t x365; + uint32_t x366; + uint32_t x367; + uint32_t x368; + uint32_t x369; + uint32_t x370; + uint32_t x371; + fiat_p256_uint1 x372; + uint32_t x373; + fiat_p256_uint1 x374; + uint32_t x375; + uint32_t x376; + fiat_p256_uint1 x377; + uint32_t x378; + fiat_p256_uint1 x379; + uint32_t x380; + fiat_p256_uint1 x381; + uint32_t x382; + fiat_p256_uint1 x383; + uint32_t x384; + fiat_p256_uint1 x385; + uint32_t x386; + fiat_p256_uint1 x387; + uint32_t x388; + fiat_p256_uint1 x389; + uint32_t x390; + fiat_p256_uint1 x391; + uint32_t x392; + fiat_p256_uint1 x393; + uint32_t x394; + uint32_t x395; + uint32_t x396; + uint32_t x397; + uint32_t x398; + uint32_t x399; + uint32_t x400; + uint32_t x401; + uint32_t x402; + uint32_t x403; + uint32_t x404; + uint32_t x405; + uint32_t x406; + uint32_t x407; + uint32_t x408; + uint32_t x409; + uint32_t x410; + uint32_t x411; + fiat_p256_uint1 x412; + uint32_t x413; + fiat_p256_uint1 x414; + uint32_t x415; + fiat_p256_uint1 x416; + uint32_t x417; + fiat_p256_uint1 x418; + uint32_t x419; + fiat_p256_uint1 x420; + uint32_t x421; + fiat_p256_uint1 x422; + uint32_t x423; + fiat_p256_uint1 x424; + uint32_t x425; + uint32_t x426; + fiat_p256_uint1 x427; + uint32_t x428; + fiat_p256_uint1 x429; + uint32_t x430; + fiat_p256_uint1 x431; + uint32_t x432; + fiat_p256_uint1 x433; + uint32_t x434; + fiat_p256_uint1 x435; + uint32_t x436; + fiat_p256_uint1 x437; + uint32_t x438; + fiat_p256_uint1 x439; + uint32_t x440; + fiat_p256_uint1 x441; + uint32_t x442; + fiat_p256_uint1 x443; + uint32_t x444; + uint32_t x445; + uint32_t x446; + uint32_t x447; + uint32_t x448; + uint32_t x449; + uint32_t x450; + uint32_t x451; + uint32_t x452; + fiat_p256_uint1 x453; + uint32_t x454; + fiat_p256_uint1 x455; + uint32_t x456; + uint32_t x457; + fiat_p256_uint1 x458; + uint32_t x459; + fiat_p256_uint1 x460; + uint32_t x461; + fiat_p256_uint1 x462; + uint32_t x463; + fiat_p256_uint1 x464; + uint32_t x465; + fiat_p256_uint1 x466; + uint32_t x467; + fiat_p256_uint1 x468; + uint32_t x469; + fiat_p256_uint1 x470; + uint32_t x471; + fiat_p256_uint1 x472; + uint32_t x473; + fiat_p256_uint1 x474; + uint32_t x475; + uint32_t x476; + uint32_t x477; + uint32_t x478; + uint32_t x479; + uint32_t x480; + uint32_t x481; + uint32_t x482; + uint32_t x483; + uint32_t x484; + uint32_t x485; + uint32_t x486; + uint32_t x487; + uint32_t x488; + uint32_t x489; + uint32_t x490; + uint32_t x491; + uint32_t x492; + fiat_p256_uint1 x493; + uint32_t x494; + fiat_p256_uint1 x495; + uint32_t x496; + fiat_p256_uint1 x497; + uint32_t x498; + fiat_p256_uint1 x499; + uint32_t x500; + fiat_p256_uint1 x501; + uint32_t x502; + fiat_p256_uint1 x503; + uint32_t x504; + fiat_p256_uint1 x505; + uint32_t x506; + uint32_t x507; + fiat_p256_uint1 x508; + uint32_t x509; + fiat_p256_uint1 x510; + uint32_t x511; + fiat_p256_uint1 x512; + uint32_t x513; + fiat_p256_uint1 x514; + uint32_t x515; + fiat_p256_uint1 x516; + uint32_t x517; + fiat_p256_uint1 x518; + uint32_t x519; + fiat_p256_uint1 x520; + uint32_t x521; + fiat_p256_uint1 x522; + uint32_t x523; + fiat_p256_uint1 x524; + uint32_t x525; + uint32_t x526; + uint32_t x527; + uint32_t x528; + uint32_t x529; + uint32_t x530; + uint32_t x531; + uint32_t x532; + uint32_t x533; + fiat_p256_uint1 x534; + uint32_t x535; + fiat_p256_uint1 x536; + uint32_t x537; + uint32_t x538; + fiat_p256_uint1 x539; + uint32_t x540; + fiat_p256_uint1 x541; + uint32_t x542; + fiat_p256_uint1 x543; + uint32_t x544; + fiat_p256_uint1 x545; + uint32_t x546; + fiat_p256_uint1 x547; + uint32_t x548; + fiat_p256_uint1 x549; + uint32_t x550; + fiat_p256_uint1 x551; + uint32_t x552; + fiat_p256_uint1 x553; + uint32_t x554; + fiat_p256_uint1 x555; + uint32_t x556; + uint32_t x557; + uint32_t x558; + uint32_t x559; + uint32_t x560; + uint32_t x561; + uint32_t x562; + uint32_t x563; + uint32_t x564; + uint32_t x565; + uint32_t x566; + uint32_t x567; + uint32_t x568; + uint32_t x569; + uint32_t x570; + uint32_t x571; + uint32_t x572; + uint32_t x573; + fiat_p256_uint1 x574; + uint32_t x575; + fiat_p256_uint1 x576; + uint32_t x577; + fiat_p256_uint1 x578; + uint32_t x579; + fiat_p256_uint1 x580; + uint32_t x581; + fiat_p256_uint1 x582; + uint32_t x583; + fiat_p256_uint1 x584; + uint32_t x585; + fiat_p256_uint1 x586; + uint32_t x587; + uint32_t x588; + fiat_p256_uint1 x589; + uint32_t x590; + fiat_p256_uint1 x591; + uint32_t x592; + fiat_p256_uint1 x593; + uint32_t x594; + fiat_p256_uint1 x595; + uint32_t x596; + fiat_p256_uint1 x597; + uint32_t x598; + fiat_p256_uint1 x599; + uint32_t x600; + fiat_p256_uint1 x601; + uint32_t x602; + fiat_p256_uint1 x603; + uint32_t x604; + fiat_p256_uint1 x605; + uint32_t x606; + uint32_t x607; + uint32_t x608; + uint32_t x609; + uint32_t x610; + uint32_t x611; + uint32_t x612; + uint32_t x613; + uint32_t x614; + fiat_p256_uint1 x615; + uint32_t x616; + fiat_p256_uint1 x617; + uint32_t x618; + uint32_t x619; + fiat_p256_uint1 x620; + uint32_t x621; + fiat_p256_uint1 x622; + uint32_t x623; + fiat_p256_uint1 x624; + uint32_t x625; + fiat_p256_uint1 x626; + uint32_t x627; + fiat_p256_uint1 x628; + uint32_t x629; + fiat_p256_uint1 x630; + uint32_t x631; + fiat_p256_uint1 x632; + uint32_t x633; + fiat_p256_uint1 x634; + uint32_t x635; + fiat_p256_uint1 x636; + uint32_t x637; + uint32_t x638; + fiat_p256_uint1 x639; + uint32_t x640; + fiat_p256_uint1 x641; + uint32_t x642; + fiat_p256_uint1 x643; + uint32_t x644; + fiat_p256_uint1 x645; + uint32_t x646; + fiat_p256_uint1 x647; + uint32_t x648; + fiat_p256_uint1 x649; + uint32_t x650; + fiat_p256_uint1 x651; + uint32_t x652; + fiat_p256_uint1 x653; + uint32_t x654; + fiat_p256_uint1 x655; + uint32_t x656; + uint32_t x657; + uint32_t x658; + uint32_t x659; + uint32_t x660; + uint32_t x661; + uint32_t x662; + uint32_t x663; + x1 = (arg1[1]); + x2 = (arg1[2]); + x3 = (arg1[3]); + x4 = (arg1[4]); + x5 = (arg1[5]); + x6 = (arg1[6]); + x7 = (arg1[7]); + x8 = (arg1[0]); + fiat_p256_mulx_u32(&x9, &x10, x8, (arg1[7])); + fiat_p256_mulx_u32(&x11, &x12, x8, (arg1[6])); + fiat_p256_mulx_u32(&x13, &x14, x8, (arg1[5])); + fiat_p256_mulx_u32(&x15, &x16, x8, (arg1[4])); + fiat_p256_mulx_u32(&x17, &x18, x8, (arg1[3])); + fiat_p256_mulx_u32(&x19, &x20, x8, (arg1[2])); + fiat_p256_mulx_u32(&x21, &x22, x8, (arg1[1])); + fiat_p256_mulx_u32(&x23, &x24, x8, (arg1[0])); + fiat_p256_addcarryx_u32(&x25, &x26, 0x0, x24, x21); + fiat_p256_addcarryx_u32(&x27, &x28, x26, x22, x19); + fiat_p256_addcarryx_u32(&x29, &x30, x28, x20, x17); + fiat_p256_addcarryx_u32(&x31, &x32, x30, x18, x15); + fiat_p256_addcarryx_u32(&x33, &x34, x32, x16, x13); + fiat_p256_addcarryx_u32(&x35, &x36, x34, x14, x11); + fiat_p256_addcarryx_u32(&x37, &x38, x36, x12, x9); + x39 = (x38 + x10); + fiat_p256_mulx_u32(&x40, &x41, x23, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x42, &x43, x23, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x44, &x45, x23, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x46, &x47, x23, UINT32_C(0xffffffff)); + fiat_p256_addcarryx_u32(&x48, &x49, 0x0, x47, x44); + fiat_p256_addcarryx_u32(&x50, &x51, x49, x45, x42); + x52 = (x51 + x43); + fiat_p256_addcarryx_u32(&x53, &x54, 0x0, x23, x46); + fiat_p256_addcarryx_u32(&x55, &x56, x54, x25, x48); + fiat_p256_addcarryx_u32(&x57, &x58, x56, x27, x50); + fiat_p256_addcarryx_u32(&x59, &x60, x58, x29, x52); + fiat_p256_addcarryx_u32(&x61, &x62, x60, x31, 0x0); + fiat_p256_addcarryx_u32(&x63, &x64, x62, x33, 0x0); + fiat_p256_addcarryx_u32(&x65, &x66, x64, x35, x23); + fiat_p256_addcarryx_u32(&x67, &x68, x66, x37, x40); + fiat_p256_addcarryx_u32(&x69, &x70, x68, x39, x41); + fiat_p256_mulx_u32(&x71, &x72, x1, (arg1[7])); + fiat_p256_mulx_u32(&x73, &x74, x1, (arg1[6])); + fiat_p256_mulx_u32(&x75, &x76, x1, (arg1[5])); + fiat_p256_mulx_u32(&x77, &x78, x1, (arg1[4])); + fiat_p256_mulx_u32(&x79, &x80, x1, (arg1[3])); + fiat_p256_mulx_u32(&x81, &x82, x1, (arg1[2])); + fiat_p256_mulx_u32(&x83, &x84, x1, (arg1[1])); + fiat_p256_mulx_u32(&x85, &x86, x1, (arg1[0])); + fiat_p256_addcarryx_u32(&x87, &x88, 0x0, x86, x83); + fiat_p256_addcarryx_u32(&x89, &x90, x88, x84, x81); + fiat_p256_addcarryx_u32(&x91, &x92, x90, x82, x79); + fiat_p256_addcarryx_u32(&x93, &x94, x92, x80, x77); + fiat_p256_addcarryx_u32(&x95, &x96, x94, x78, x75); + fiat_p256_addcarryx_u32(&x97, &x98, x96, x76, x73); + fiat_p256_addcarryx_u32(&x99, &x100, x98, x74, x71); + x101 = (x100 + x72); + fiat_p256_addcarryx_u32(&x102, &x103, 0x0, x55, x85); + fiat_p256_addcarryx_u32(&x104, &x105, x103, x57, x87); + fiat_p256_addcarryx_u32(&x106, &x107, x105, x59, x89); + fiat_p256_addcarryx_u32(&x108, &x109, x107, x61, x91); + fiat_p256_addcarryx_u32(&x110, &x111, x109, x63, x93); + fiat_p256_addcarryx_u32(&x112, &x113, x111, x65, x95); + fiat_p256_addcarryx_u32(&x114, &x115, x113, x67, x97); + fiat_p256_addcarryx_u32(&x116, &x117, x115, x69, x99); + fiat_p256_addcarryx_u32(&x118, &x119, x117, x70, x101); + fiat_p256_mulx_u32(&x120, &x121, x102, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x122, &x123, x102, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x124, &x125, x102, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x126, &x127, x102, UINT32_C(0xffffffff)); + fiat_p256_addcarryx_u32(&x128, &x129, 0x0, x127, x124); + fiat_p256_addcarryx_u32(&x130, &x131, x129, x125, x122); + x132 = (x131 + x123); + fiat_p256_addcarryx_u32(&x133, &x134, 0x0, x102, x126); + fiat_p256_addcarryx_u32(&x135, &x136, x134, x104, x128); + fiat_p256_addcarryx_u32(&x137, &x138, x136, x106, x130); + fiat_p256_addcarryx_u32(&x139, &x140, x138, x108, x132); + fiat_p256_addcarryx_u32(&x141, &x142, x140, x110, 0x0); + fiat_p256_addcarryx_u32(&x143, &x144, x142, x112, 0x0); + fiat_p256_addcarryx_u32(&x145, &x146, x144, x114, x102); + fiat_p256_addcarryx_u32(&x147, &x148, x146, x116, x120); + fiat_p256_addcarryx_u32(&x149, &x150, x148, x118, x121); + x151 = ((uint32_t)x150 + x119); + fiat_p256_mulx_u32(&x152, &x153, x2, (arg1[7])); + fiat_p256_mulx_u32(&x154, &x155, x2, (arg1[6])); + fiat_p256_mulx_u32(&x156, &x157, x2, (arg1[5])); + fiat_p256_mulx_u32(&x158, &x159, x2, (arg1[4])); + fiat_p256_mulx_u32(&x160, &x161, x2, (arg1[3])); + fiat_p256_mulx_u32(&x162, &x163, x2, (arg1[2])); + fiat_p256_mulx_u32(&x164, &x165, x2, (arg1[1])); + fiat_p256_mulx_u32(&x166, &x167, x2, (arg1[0])); + fiat_p256_addcarryx_u32(&x168, &x169, 0x0, x167, x164); + fiat_p256_addcarryx_u32(&x170, &x171, x169, x165, x162); + fiat_p256_addcarryx_u32(&x172, &x173, x171, x163, x160); + fiat_p256_addcarryx_u32(&x174, &x175, x173, x161, x158); + fiat_p256_addcarryx_u32(&x176, &x177, x175, x159, x156); + fiat_p256_addcarryx_u32(&x178, &x179, x177, x157, x154); + fiat_p256_addcarryx_u32(&x180, &x181, x179, x155, x152); + x182 = (x181 + x153); + fiat_p256_addcarryx_u32(&x183, &x184, 0x0, x135, x166); + fiat_p256_addcarryx_u32(&x185, &x186, x184, x137, x168); + fiat_p256_addcarryx_u32(&x187, &x188, x186, x139, x170); + fiat_p256_addcarryx_u32(&x189, &x190, x188, x141, x172); + fiat_p256_addcarryx_u32(&x191, &x192, x190, x143, x174); + fiat_p256_addcarryx_u32(&x193, &x194, x192, x145, x176); + fiat_p256_addcarryx_u32(&x195, &x196, x194, x147, x178); + fiat_p256_addcarryx_u32(&x197, &x198, x196, x149, x180); + fiat_p256_addcarryx_u32(&x199, &x200, x198, x151, x182); + fiat_p256_mulx_u32(&x201, &x202, x183, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x203, &x204, x183, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x205, &x206, x183, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x207, &x208, x183, UINT32_C(0xffffffff)); + fiat_p256_addcarryx_u32(&x209, &x210, 0x0, x208, x205); + fiat_p256_addcarryx_u32(&x211, &x212, x210, x206, x203); + x213 = (x212 + x204); + fiat_p256_addcarryx_u32(&x214, &x215, 0x0, x183, x207); + fiat_p256_addcarryx_u32(&x216, &x217, x215, x185, x209); + fiat_p256_addcarryx_u32(&x218, &x219, x217, x187, x211); + fiat_p256_addcarryx_u32(&x220, &x221, x219, x189, x213); + fiat_p256_addcarryx_u32(&x222, &x223, x221, x191, 0x0); + fiat_p256_addcarryx_u32(&x224, &x225, x223, x193, 0x0); + fiat_p256_addcarryx_u32(&x226, &x227, x225, x195, x183); + fiat_p256_addcarryx_u32(&x228, &x229, x227, x197, x201); + fiat_p256_addcarryx_u32(&x230, &x231, x229, x199, x202); + x232 = ((uint32_t)x231 + x200); + fiat_p256_mulx_u32(&x233, &x234, x3, (arg1[7])); + fiat_p256_mulx_u32(&x235, &x236, x3, (arg1[6])); + fiat_p256_mulx_u32(&x237, &x238, x3, (arg1[5])); + fiat_p256_mulx_u32(&x239, &x240, x3, (arg1[4])); + fiat_p256_mulx_u32(&x241, &x242, x3, (arg1[3])); + fiat_p256_mulx_u32(&x243, &x244, x3, (arg1[2])); + fiat_p256_mulx_u32(&x245, &x246, x3, (arg1[1])); + fiat_p256_mulx_u32(&x247, &x248, x3, (arg1[0])); + fiat_p256_addcarryx_u32(&x249, &x250, 0x0, x248, x245); + fiat_p256_addcarryx_u32(&x251, &x252, x250, x246, x243); + fiat_p256_addcarryx_u32(&x253, &x254, x252, x244, x241); + fiat_p256_addcarryx_u32(&x255, &x256, x254, x242, x239); + fiat_p256_addcarryx_u32(&x257, &x258, x256, x240, x237); + fiat_p256_addcarryx_u32(&x259, &x260, x258, x238, x235); + fiat_p256_addcarryx_u32(&x261, &x262, x260, x236, x233); + x263 = (x262 + x234); + fiat_p256_addcarryx_u32(&x264, &x265, 0x0, x216, x247); + fiat_p256_addcarryx_u32(&x266, &x267, x265, x218, x249); + fiat_p256_addcarryx_u32(&x268, &x269, x267, x220, x251); + fiat_p256_addcarryx_u32(&x270, &x271, x269, x222, x253); + fiat_p256_addcarryx_u32(&x272, &x273, x271, x224, x255); + fiat_p256_addcarryx_u32(&x274, &x275, x273, x226, x257); + fiat_p256_addcarryx_u32(&x276, &x277, x275, x228, x259); + fiat_p256_addcarryx_u32(&x278, &x279, x277, x230, x261); + fiat_p256_addcarryx_u32(&x280, &x281, x279, x232, x263); + fiat_p256_mulx_u32(&x282, &x283, x264, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x284, &x285, x264, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x286, &x287, x264, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x288, &x289, x264, UINT32_C(0xffffffff)); + fiat_p256_addcarryx_u32(&x290, &x291, 0x0, x289, x286); + fiat_p256_addcarryx_u32(&x292, &x293, x291, x287, x284); + x294 = (x293 + x285); + fiat_p256_addcarryx_u32(&x295, &x296, 0x0, x264, x288); + fiat_p256_addcarryx_u32(&x297, &x298, x296, x266, x290); + fiat_p256_addcarryx_u32(&x299, &x300, x298, x268, x292); + fiat_p256_addcarryx_u32(&x301, &x302, x300, x270, x294); + fiat_p256_addcarryx_u32(&x303, &x304, x302, x272, 0x0); + fiat_p256_addcarryx_u32(&x305, &x306, x304, x274, 0x0); + fiat_p256_addcarryx_u32(&x307, &x308, x306, x276, x264); + fiat_p256_addcarryx_u32(&x309, &x310, x308, x278, x282); + fiat_p256_addcarryx_u32(&x311, &x312, x310, x280, x283); + x313 = ((uint32_t)x312 + x281); + fiat_p256_mulx_u32(&x314, &x315, x4, (arg1[7])); + fiat_p256_mulx_u32(&x316, &x317, x4, (arg1[6])); + fiat_p256_mulx_u32(&x318, &x319, x4, (arg1[5])); + fiat_p256_mulx_u32(&x320, &x321, x4, (arg1[4])); + fiat_p256_mulx_u32(&x322, &x323, x4, (arg1[3])); + fiat_p256_mulx_u32(&x324, &x325, x4, (arg1[2])); + fiat_p256_mulx_u32(&x326, &x327, x4, (arg1[1])); + fiat_p256_mulx_u32(&x328, &x329, x4, (arg1[0])); + fiat_p256_addcarryx_u32(&x330, &x331, 0x0, x329, x326); + fiat_p256_addcarryx_u32(&x332, &x333, x331, x327, x324); + fiat_p256_addcarryx_u32(&x334, &x335, x333, x325, x322); + fiat_p256_addcarryx_u32(&x336, &x337, x335, x323, x320); + fiat_p256_addcarryx_u32(&x338, &x339, x337, x321, x318); + fiat_p256_addcarryx_u32(&x340, &x341, x339, x319, x316); + fiat_p256_addcarryx_u32(&x342, &x343, x341, x317, x314); + x344 = (x343 + x315); + fiat_p256_addcarryx_u32(&x345, &x346, 0x0, x297, x328); + fiat_p256_addcarryx_u32(&x347, &x348, x346, x299, x330); + fiat_p256_addcarryx_u32(&x349, &x350, x348, x301, x332); + fiat_p256_addcarryx_u32(&x351, &x352, x350, x303, x334); + fiat_p256_addcarryx_u32(&x353, &x354, x352, x305, x336); + fiat_p256_addcarryx_u32(&x355, &x356, x354, x307, x338); + fiat_p256_addcarryx_u32(&x357, &x358, x356, x309, x340); + fiat_p256_addcarryx_u32(&x359, &x360, x358, x311, x342); + fiat_p256_addcarryx_u32(&x361, &x362, x360, x313, x344); + fiat_p256_mulx_u32(&x363, &x364, x345, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x365, &x366, x345, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x367, &x368, x345, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x369, &x370, x345, UINT32_C(0xffffffff)); + fiat_p256_addcarryx_u32(&x371, &x372, 0x0, x370, x367); + fiat_p256_addcarryx_u32(&x373, &x374, x372, x368, x365); + x375 = (x374 + x366); + fiat_p256_addcarryx_u32(&x376, &x377, 0x0, x345, x369); + fiat_p256_addcarryx_u32(&x378, &x379, x377, x347, x371); + fiat_p256_addcarryx_u32(&x380, &x381, x379, x349, x373); + fiat_p256_addcarryx_u32(&x382, &x383, x381, x351, x375); + fiat_p256_addcarryx_u32(&x384, &x385, x383, x353, 0x0); + fiat_p256_addcarryx_u32(&x386, &x387, x385, x355, 0x0); + fiat_p256_addcarryx_u32(&x388, &x389, x387, x357, x345); + fiat_p256_addcarryx_u32(&x390, &x391, x389, x359, x363); + fiat_p256_addcarryx_u32(&x392, &x393, x391, x361, x364); + x394 = ((uint32_t)x393 + x362); + fiat_p256_mulx_u32(&x395, &x396, x5, (arg1[7])); + fiat_p256_mulx_u32(&x397, &x398, x5, (arg1[6])); + fiat_p256_mulx_u32(&x399, &x400, x5, (arg1[5])); + fiat_p256_mulx_u32(&x401, &x402, x5, (arg1[4])); + fiat_p256_mulx_u32(&x403, &x404, x5, (arg1[3])); + fiat_p256_mulx_u32(&x405, &x406, x5, (arg1[2])); + fiat_p256_mulx_u32(&x407, &x408, x5, (arg1[1])); + fiat_p256_mulx_u32(&x409, &x410, x5, (arg1[0])); + fiat_p256_addcarryx_u32(&x411, &x412, 0x0, x410, x407); + fiat_p256_addcarryx_u32(&x413, &x414, x412, x408, x405); + fiat_p256_addcarryx_u32(&x415, &x416, x414, x406, x403); + fiat_p256_addcarryx_u32(&x417, &x418, x416, x404, x401); + fiat_p256_addcarryx_u32(&x419, &x420, x418, x402, x399); + fiat_p256_addcarryx_u32(&x421, &x422, x420, x400, x397); + fiat_p256_addcarryx_u32(&x423, &x424, x422, x398, x395); + x425 = (x424 + x396); + fiat_p256_addcarryx_u32(&x426, &x427, 0x0, x378, x409); + fiat_p256_addcarryx_u32(&x428, &x429, x427, x380, x411); + fiat_p256_addcarryx_u32(&x430, &x431, x429, x382, x413); + fiat_p256_addcarryx_u32(&x432, &x433, x431, x384, x415); + fiat_p256_addcarryx_u32(&x434, &x435, x433, x386, x417); + fiat_p256_addcarryx_u32(&x436, &x437, x435, x388, x419); + fiat_p256_addcarryx_u32(&x438, &x439, x437, x390, x421); + fiat_p256_addcarryx_u32(&x440, &x441, x439, x392, x423); + fiat_p256_addcarryx_u32(&x442, &x443, x441, x394, x425); + fiat_p256_mulx_u32(&x444, &x445, x426, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x446, &x447, x426, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x448, &x449, x426, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x450, &x451, x426, UINT32_C(0xffffffff)); + fiat_p256_addcarryx_u32(&x452, &x453, 0x0, x451, x448); + fiat_p256_addcarryx_u32(&x454, &x455, x453, x449, x446); + x456 = (x455 + x447); + fiat_p256_addcarryx_u32(&x457, &x458, 0x0, x426, x450); + fiat_p256_addcarryx_u32(&x459, &x460, x458, x428, x452); + fiat_p256_addcarryx_u32(&x461, &x462, x460, x430, x454); + fiat_p256_addcarryx_u32(&x463, &x464, x462, x432, x456); + fiat_p256_addcarryx_u32(&x465, &x466, x464, x434, 0x0); + fiat_p256_addcarryx_u32(&x467, &x468, x466, x436, 0x0); + fiat_p256_addcarryx_u32(&x469, &x470, x468, x438, x426); + fiat_p256_addcarryx_u32(&x471, &x472, x470, x440, x444); + fiat_p256_addcarryx_u32(&x473, &x474, x472, x442, x445); + x475 = ((uint32_t)x474 + x443); + fiat_p256_mulx_u32(&x476, &x477, x6, (arg1[7])); + fiat_p256_mulx_u32(&x478, &x479, x6, (arg1[6])); + fiat_p256_mulx_u32(&x480, &x481, x6, (arg1[5])); + fiat_p256_mulx_u32(&x482, &x483, x6, (arg1[4])); + fiat_p256_mulx_u32(&x484, &x485, x6, (arg1[3])); + fiat_p256_mulx_u32(&x486, &x487, x6, (arg1[2])); + fiat_p256_mulx_u32(&x488, &x489, x6, (arg1[1])); + fiat_p256_mulx_u32(&x490, &x491, x6, (arg1[0])); + fiat_p256_addcarryx_u32(&x492, &x493, 0x0, x491, x488); + fiat_p256_addcarryx_u32(&x494, &x495, x493, x489, x486); + fiat_p256_addcarryx_u32(&x496, &x497, x495, x487, x484); + fiat_p256_addcarryx_u32(&x498, &x499, x497, x485, x482); + fiat_p256_addcarryx_u32(&x500, &x501, x499, x483, x480); + fiat_p256_addcarryx_u32(&x502, &x503, x501, x481, x478); + fiat_p256_addcarryx_u32(&x504, &x505, x503, x479, x476); + x506 = (x505 + x477); + fiat_p256_addcarryx_u32(&x507, &x508, 0x0, x459, x490); + fiat_p256_addcarryx_u32(&x509, &x510, x508, x461, x492); + fiat_p256_addcarryx_u32(&x511, &x512, x510, x463, x494); + fiat_p256_addcarryx_u32(&x513, &x514, x512, x465, x496); + fiat_p256_addcarryx_u32(&x515, &x516, x514, x467, x498); + fiat_p256_addcarryx_u32(&x517, &x518, x516, x469, x500); + fiat_p256_addcarryx_u32(&x519, &x520, x518, x471, x502); + fiat_p256_addcarryx_u32(&x521, &x522, x520, x473, x504); + fiat_p256_addcarryx_u32(&x523, &x524, x522, x475, x506); + fiat_p256_mulx_u32(&x525, &x526, x507, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x527, &x528, x507, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x529, &x530, x507, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x531, &x532, x507, UINT32_C(0xffffffff)); + fiat_p256_addcarryx_u32(&x533, &x534, 0x0, x532, x529); + fiat_p256_addcarryx_u32(&x535, &x536, x534, x530, x527); + x537 = (x536 + x528); + fiat_p256_addcarryx_u32(&x538, &x539, 0x0, x507, x531); + fiat_p256_addcarryx_u32(&x540, &x541, x539, x509, x533); + fiat_p256_addcarryx_u32(&x542, &x543, x541, x511, x535); + fiat_p256_addcarryx_u32(&x544, &x545, x543, x513, x537); + fiat_p256_addcarryx_u32(&x546, &x547, x545, x515, 0x0); + fiat_p256_addcarryx_u32(&x548, &x549, x547, x517, 0x0); + fiat_p256_addcarryx_u32(&x550, &x551, x549, x519, x507); + fiat_p256_addcarryx_u32(&x552, &x553, x551, x521, x525); + fiat_p256_addcarryx_u32(&x554, &x555, x553, x523, x526); + x556 = ((uint32_t)x555 + x524); + fiat_p256_mulx_u32(&x557, &x558, x7, (arg1[7])); + fiat_p256_mulx_u32(&x559, &x560, x7, (arg1[6])); + fiat_p256_mulx_u32(&x561, &x562, x7, (arg1[5])); + fiat_p256_mulx_u32(&x563, &x564, x7, (arg1[4])); + fiat_p256_mulx_u32(&x565, &x566, x7, (arg1[3])); + fiat_p256_mulx_u32(&x567, &x568, x7, (arg1[2])); + fiat_p256_mulx_u32(&x569, &x570, x7, (arg1[1])); + fiat_p256_mulx_u32(&x571, &x572, x7, (arg1[0])); + fiat_p256_addcarryx_u32(&x573, &x574, 0x0, x572, x569); + fiat_p256_addcarryx_u32(&x575, &x576, x574, x570, x567); + fiat_p256_addcarryx_u32(&x577, &x578, x576, x568, x565); + fiat_p256_addcarryx_u32(&x579, &x580, x578, x566, x563); + fiat_p256_addcarryx_u32(&x581, &x582, x580, x564, x561); + fiat_p256_addcarryx_u32(&x583, &x584, x582, x562, x559); + fiat_p256_addcarryx_u32(&x585, &x586, x584, x560, x557); + x587 = (x586 + x558); + fiat_p256_addcarryx_u32(&x588, &x589, 0x0, x540, x571); + fiat_p256_addcarryx_u32(&x590, &x591, x589, x542, x573); + fiat_p256_addcarryx_u32(&x592, &x593, x591, x544, x575); + fiat_p256_addcarryx_u32(&x594, &x595, x593, x546, x577); + fiat_p256_addcarryx_u32(&x596, &x597, x595, x548, x579); + fiat_p256_addcarryx_u32(&x598, &x599, x597, x550, x581); + fiat_p256_addcarryx_u32(&x600, &x601, x599, x552, x583); + fiat_p256_addcarryx_u32(&x602, &x603, x601, x554, x585); + fiat_p256_addcarryx_u32(&x604, &x605, x603, x556, x587); + fiat_p256_mulx_u32(&x606, &x607, x588, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x608, &x609, x588, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x610, &x611, x588, UINT32_C(0xffffffff)); + fiat_p256_mulx_u32(&x612, &x613, x588, UINT32_C(0xffffffff)); + fiat_p256_addcarryx_u32(&x614, &x615, 0x0, x613, x610); + fiat_p256_addcarryx_u32(&x616, &x617, x615, x611, x608); + x618 = (x617 + x609); + fiat_p256_addcarryx_u32(&x619, &x620, 0x0, x588, x612); + fiat_p256_addcarryx_u32(&x621, &x622, x620, x590, x614); + fiat_p256_addcarryx_u32(&x623, &x624, x622, x592, x616); + fiat_p256_addcarryx_u32(&x625, &x626, x624, x594, x618); + fiat_p256_addcarryx_u32(&x627, &x628, x626, x596, 0x0); + fiat_p256_addcarryx_u32(&x629, &x630, x628, x598, 0x0); + fiat_p256_addcarryx_u32(&x631, &x632, x630, x600, x588); + fiat_p256_addcarryx_u32(&x633, &x634, x632, x602, x606); + fiat_p256_addcarryx_u32(&x635, &x636, x634, x604, x607); + x637 = ((uint32_t)x636 + x605); + fiat_p256_subborrowx_u32(&x638, &x639, 0x0, x621, UINT32_C(0xffffffff)); + fiat_p256_subborrowx_u32(&x640, &x641, x639, x623, UINT32_C(0xffffffff)); + fiat_p256_subborrowx_u32(&x642, &x643, x641, x625, UINT32_C(0xffffffff)); + fiat_p256_subborrowx_u32(&x644, &x645, x643, x627, 0x0); + fiat_p256_subborrowx_u32(&x646, &x647, x645, x629, 0x0); + fiat_p256_subborrowx_u32(&x648, &x649, x647, x631, 0x0); + fiat_p256_subborrowx_u32(&x650, &x651, x649, x633, 0x1); + fiat_p256_subborrowx_u32(&x652, &x653, x651, x635, UINT32_C(0xffffffff)); + fiat_p256_subborrowx_u32(&x654, &x655, x653, x637, 0x0); + fiat_p256_cmovznz_u32(&x656, x655, x638, x621); + fiat_p256_cmovznz_u32(&x657, x655, x640, x623); + fiat_p256_cmovznz_u32(&x658, x655, x642, x625); + fiat_p256_cmovznz_u32(&x659, x655, x644, x627); + fiat_p256_cmovznz_u32(&x660, x655, x646, x629); + fiat_p256_cmovznz_u32(&x661, x655, x648, x631); + fiat_p256_cmovznz_u32(&x662, x655, x650, x633); + fiat_p256_cmovznz_u32(&x663, x655, x652, x635); + out1[0] = x656; + out1[1] = x657; + out1[2] = x658; + out1[3] = x659; + out1[4] = x660; + out1[5] = x661; + out1[6] = x662; + out1[7] = x663; +} + +/* + * The function fiat_p256_add adds two field elements in the Montgomery domain. + * + * Preconditions: + * 0 ≤ eval arg1 < m + * 0 ≤ eval arg2 < m + * Postconditions: + * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) + eval (from_montgomery arg2)) mod m + * 0 ≤ eval out1 < m + * + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_add(fiat_p256_montgomery_domain_field_element out1, const fiat_p256_montgomery_domain_field_element arg1, const fiat_p256_montgomery_domain_field_element arg2) { + uint32_t x1; + fiat_p256_uint1 x2; + uint32_t x3; + fiat_p256_uint1 x4; + uint32_t x5; + fiat_p256_uint1 x6; + uint32_t x7; + fiat_p256_uint1 x8; + uint32_t x9; + fiat_p256_uint1 x10; + uint32_t x11; + fiat_p256_uint1 x12; + uint32_t x13; + fiat_p256_uint1 x14; + uint32_t x15; + fiat_p256_uint1 x16; + uint32_t x17; + fiat_p256_uint1 x18; + uint32_t x19; + fiat_p256_uint1 x20; + uint32_t x21; + fiat_p256_uint1 x22; + uint32_t x23; + fiat_p256_uint1 x24; + uint32_t x25; + fiat_p256_uint1 x26; + uint32_t x27; + fiat_p256_uint1 x28; + uint32_t x29; + fiat_p256_uint1 x30; + uint32_t x31; + fiat_p256_uint1 x32; + uint32_t x33; + fiat_p256_uint1 x34; + uint32_t x35; + uint32_t x36; + uint32_t x37; + uint32_t x38; + uint32_t x39; + uint32_t x40; + uint32_t x41; + uint32_t x42; + fiat_p256_addcarryx_u32(&x1, &x2, 0x0, (arg1[0]), (arg2[0])); + fiat_p256_addcarryx_u32(&x3, &x4, x2, (arg1[1]), (arg2[1])); + fiat_p256_addcarryx_u32(&x5, &x6, x4, (arg1[2]), (arg2[2])); + fiat_p256_addcarryx_u32(&x7, &x8, x6, (arg1[3]), (arg2[3])); + fiat_p256_addcarryx_u32(&x9, &x10, x8, (arg1[4]), (arg2[4])); + fiat_p256_addcarryx_u32(&x11, &x12, x10, (arg1[5]), (arg2[5])); + fiat_p256_addcarryx_u32(&x13, &x14, x12, (arg1[6]), (arg2[6])); + fiat_p256_addcarryx_u32(&x15, &x16, x14, (arg1[7]), (arg2[7])); + fiat_p256_subborrowx_u32(&x17, &x18, 0x0, x1, UINT32_C(0xffffffff)); + fiat_p256_subborrowx_u32(&x19, &x20, x18, x3, UINT32_C(0xffffffff)); + fiat_p256_subborrowx_u32(&x21, &x22, x20, x5, UINT32_C(0xffffffff)); + fiat_p256_subborrowx_u32(&x23, &x24, x22, x7, 0x0); + fiat_p256_subborrowx_u32(&x25, &x26, x24, x9, 0x0); + fiat_p256_subborrowx_u32(&x27, &x28, x26, x11, 0x0); + fiat_p256_subborrowx_u32(&x29, &x30, x28, x13, 0x1); + fiat_p256_subborrowx_u32(&x31, &x32, x30, x15, UINT32_C(0xffffffff)); + fiat_p256_subborrowx_u32(&x33, &x34, x32, x16, 0x0); + fiat_p256_cmovznz_u32(&x35, x34, x17, x1); + fiat_p256_cmovznz_u32(&x36, x34, x19, x3); + fiat_p256_cmovznz_u32(&x37, x34, x21, x5); + fiat_p256_cmovznz_u32(&x38, x34, x23, x7); + fiat_p256_cmovznz_u32(&x39, x34, x25, x9); + fiat_p256_cmovznz_u32(&x40, x34, x27, x11); + fiat_p256_cmovznz_u32(&x41, x34, x29, x13); + fiat_p256_cmovznz_u32(&x42, x34, x31, x15); + out1[0] = x35; + out1[1] = x36; + out1[2] = x37; + out1[3] = x38; + out1[4] = x39; + out1[5] = x40; + out1[6] = x41; + out1[7] = x42; +} + +/* + * The function fiat_p256_sub subtracts two field elements in the Montgomery domain. + * + * Preconditions: + * 0 ≤ eval arg1 < m + * 0 ≤ eval arg2 < m + * Postconditions: + * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) - eval (from_montgomery arg2)) mod m + * 0 ≤ eval out1 < m + * + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_sub(fiat_p256_montgomery_domain_field_element out1, const fiat_p256_montgomery_domain_field_element arg1, const fiat_p256_montgomery_domain_field_element arg2) { + uint32_t x1; + fiat_p256_uint1 x2; + uint32_t x3; + fiat_p256_uint1 x4; + uint32_t x5; + fiat_p256_uint1 x6; + uint32_t x7; + fiat_p256_uint1 x8; + uint32_t x9; + fiat_p256_uint1 x10; + uint32_t x11; + fiat_p256_uint1 x12; + uint32_t x13; + fiat_p256_uint1 x14; + uint32_t x15; + fiat_p256_uint1 x16; + uint32_t x17; + uint32_t x18; + fiat_p256_uint1 x19; + uint32_t x20; + fiat_p256_uint1 x21; + uint32_t x22; + fiat_p256_uint1 x23; + uint32_t x24; + fiat_p256_uint1 x25; + uint32_t x26; + fiat_p256_uint1 x27; + uint32_t x28; + fiat_p256_uint1 x29; + uint32_t x30; + fiat_p256_uint1 x31; + uint32_t x32; + fiat_p256_uint1 x33; + fiat_p256_subborrowx_u32(&x1, &x2, 0x0, (arg1[0]), (arg2[0])); + fiat_p256_subborrowx_u32(&x3, &x4, x2, (arg1[1]), (arg2[1])); + fiat_p256_subborrowx_u32(&x5, &x6, x4, (arg1[2]), (arg2[2])); + fiat_p256_subborrowx_u32(&x7, &x8, x6, (arg1[3]), (arg2[3])); + fiat_p256_subborrowx_u32(&x9, &x10, x8, (arg1[4]), (arg2[4])); + fiat_p256_subborrowx_u32(&x11, &x12, x10, (arg1[5]), (arg2[5])); + fiat_p256_subborrowx_u32(&x13, &x14, x12, (arg1[6]), (arg2[6])); + fiat_p256_subborrowx_u32(&x15, &x16, x14, (arg1[7]), (arg2[7])); + fiat_p256_cmovznz_u32(&x17, x16, 0x0, UINT32_C(0xffffffff)); + fiat_p256_addcarryx_u32(&x18, &x19, 0x0, x1, x17); + fiat_p256_addcarryx_u32(&x20, &x21, x19, x3, x17); + fiat_p256_addcarryx_u32(&x22, &x23, x21, x5, x17); + fiat_p256_addcarryx_u32(&x24, &x25, x23, x7, 0x0); + fiat_p256_addcarryx_u32(&x26, &x27, x25, x9, 0x0); + fiat_p256_addcarryx_u32(&x28, &x29, x27, x11, 0x0); + fiat_p256_addcarryx_u32(&x30, &x31, x29, x13, (fiat_p256_uint1)(x17 & 0x1)); + fiat_p256_addcarryx_u32(&x32, &x33, x31, x15, x17); + out1[0] = x18; + out1[1] = x20; + out1[2] = x22; + out1[3] = x24; + out1[4] = x26; + out1[5] = x28; + out1[6] = x30; + out1[7] = x32; +} + +/* + * The function fiat_p256_opp negates a field element in the Montgomery domain. + * + * Preconditions: + * 0 ≤ eval arg1 < m + * Postconditions: + * eval (from_montgomery out1) mod m = -eval (from_montgomery arg1) mod m + * 0 ≤ eval out1 < m + * + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_opp(fiat_p256_montgomery_domain_field_element out1, const fiat_p256_montgomery_domain_field_element arg1) { + uint32_t x1; + fiat_p256_uint1 x2; + uint32_t x3; + fiat_p256_uint1 x4; + uint32_t x5; + fiat_p256_uint1 x6; + uint32_t x7; + fiat_p256_uint1 x8; + uint32_t x9; + fiat_p256_uint1 x10; + uint32_t x11; + fiat_p256_uint1 x12; + uint32_t x13; + fiat_p256_uint1 x14; + uint32_t x15; + fiat_p256_uint1 x16; + uint32_t x17; + uint32_t x18; + fiat_p256_uint1 x19; + uint32_t x20; + fiat_p256_uint1 x21; + uint32_t x22; + fiat_p256_uint1 x23; + uint32_t x24; + fiat_p256_uint1 x25; + uint32_t x26; + fiat_p256_uint1 x27; + uint32_t x28; + fiat_p256_uint1 x29; + uint32_t x30; + fiat_p256_uint1 x31; + uint32_t x32; + fiat_p256_uint1 x33; + fiat_p256_subborrowx_u32(&x1, &x2, 0x0, 0x0, (arg1[0])); + fiat_p256_subborrowx_u32(&x3, &x4, x2, 0x0, (arg1[1])); + fiat_p256_subborrowx_u32(&x5, &x6, x4, 0x0, (arg1[2])); + fiat_p256_subborrowx_u32(&x7, &x8, x6, 0x0, (arg1[3])); + fiat_p256_subborrowx_u32(&x9, &x10, x8, 0x0, (arg1[4])); + fiat_p256_subborrowx_u32(&x11, &x12, x10, 0x0, (arg1[5])); + fiat_p256_subborrowx_u32(&x13, &x14, x12, 0x0, (arg1[6])); + fiat_p256_subborrowx_u32(&x15, &x16, x14, 0x0, (arg1[7])); + fiat_p256_cmovznz_u32(&x17, x16, 0x0, UINT32_C(0xffffffff)); + fiat_p256_addcarryx_u32(&x18, &x19, 0x0, x1, x17); + fiat_p256_addcarryx_u32(&x20, &x21, x19, x3, x17); + fiat_p256_addcarryx_u32(&x22, &x23, x21, x5, x17); + fiat_p256_addcarryx_u32(&x24, &x25, x23, x7, 0x0); + fiat_p256_addcarryx_u32(&x26, &x27, x25, x9, 0x0); + fiat_p256_addcarryx_u32(&x28, &x29, x27, x11, 0x0); + fiat_p256_addcarryx_u32(&x30, &x31, x29, x13, (fiat_p256_uint1)(x17 & 0x1)); + fiat_p256_addcarryx_u32(&x32, &x33, x31, x15, x17); + out1[0] = x18; + out1[1] = x20; + out1[2] = x22; + out1[3] = x24; + out1[4] = x26; + out1[5] = x28; + out1[6] = x30; + out1[7] = x32; +} + +/* + * The function fiat_p256_nonzero outputs a single non-zero word if the input is non-zero and zero otherwise. + * + * Preconditions: + * 0 ≤ eval arg1 < m + * Postconditions: + * out1 = 0 ↔ eval (from_montgomery arg1) mod m = 0 + * + * Input Bounds: + * arg1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] + * Output Bounds: + * out1: [0x0 ~> 0xffffffff] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_nonzero(uint32_t* out1, const uint32_t arg1[8]) { + uint32_t x1; + x1 = ((arg1[0]) | ((arg1[1]) | ((arg1[2]) | ((arg1[3]) | ((arg1[4]) | ((arg1[5]) | ((arg1[6]) | (arg1[7])))))))); + *out1 = x1; +} + +/* + * The function fiat_p256_selectznz is a multi-limb conditional select. + * + * Postconditions: + * eval out1 = (if arg1 = 0 then eval arg2 else eval arg3) + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] + * arg3: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] + * Output Bounds: + * out1: [[0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff], [0x0 ~> 0xffffffff]] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_selectznz(uint32_t out1[8], fiat_p256_uint1 arg1, const uint32_t arg2[8], const uint32_t arg3[8]) { + uint32_t x1; + uint32_t x2; + uint32_t x3; + uint32_t x4; + uint32_t x5; + uint32_t x6; + uint32_t x7; + uint32_t x8; + fiat_p256_cmovznz_u32(&x1, arg1, (arg2[0]), (arg3[0])); + fiat_p256_cmovznz_u32(&x2, arg1, (arg2[1]), (arg3[1])); + fiat_p256_cmovznz_u32(&x3, arg1, (arg2[2]), (arg3[2])); + fiat_p256_cmovznz_u32(&x4, arg1, (arg2[3]), (arg3[3])); + fiat_p256_cmovznz_u32(&x5, arg1, (arg2[4]), (arg3[4])); + fiat_p256_cmovznz_u32(&x6, arg1, (arg2[5]), (arg3[5])); + fiat_p256_cmovznz_u32(&x7, arg1, (arg2[6]), (arg3[6])); + fiat_p256_cmovznz_u32(&x8, arg1, (arg2[7]), (arg3[7])); + out1[0] = x1; + out1[1] = x2; + out1[2] = x3; + out1[3] = x4; + out1[4] = x5; + out1[5] = x6; + out1[6] = x7; + out1[7] = x8; +} diff --git a/http/vendor/ring/third_party/fiat/p256_64.h b/http/vendor/ring/third_party/fiat/p256_64.h new file mode 100644 index 0000000..a06dd22 --- /dev/null +++ b/http/vendor/ring/third_party/fiat/p256_64.h @@ -0,0 +1,957 @@ +/* Autogenerated: 'src/ExtractionOCaml/word_by_word_montgomery' --inline --static --use-value-barrier p256 64 '2^256 - 2^224 + 2^192 + 2^96 - 1' mul square add sub opp from_montgomery to_montgomery nonzero selectznz to_bytes from_bytes one msat divstep divstep_precomp */ +/* curve description: p256 */ +/* machine_wordsize = 64 (from "64") */ +/* requested operations: mul, square, add, sub, opp, from_montgomery, to_montgomery, nonzero, selectznz, to_bytes, from_bytes, one, msat, divstep, divstep_precomp */ +/* m = 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff (from "2^256 - 2^224 + 2^192 + 2^96 - 1") */ +/* */ +/* NOTE: In addition to the bounds specified above each function, all */ +/* functions synthesized for this Montgomery arithmetic require the */ +/* input to be strictly less than the prime modulus (m), and also */ +/* require the input to be in the unique saturated representation. */ +/* All functions also ensure that these two properties are true of */ +/* return values. */ +/* */ +/* Computed values: */ +/* eval z = z[0] + (z[1] << 64) + (z[2] << 128) + (z[3] << 192) */ +/* bytes_eval z = z[0] + (z[1] << 8) + (z[2] << 16) + (z[3] << 24) + (z[4] << 32) + (z[5] << 40) + (z[6] << 48) + (z[7] << 56) + (z[8] << 64) + (z[9] << 72) + (z[10] << 80) + (z[11] << 88) + (z[12] << 96) + (z[13] << 104) + (z[14] << 112) + (z[15] << 120) + (z[16] << 128) + (z[17] << 136) + (z[18] << 144) + (z[19] << 152) + (z[20] << 160) + (z[21] << 168) + (z[22] << 176) + (z[23] << 184) + (z[24] << 192) + (z[25] << 200) + (z[26] << 208) + (z[27] << 216) + (z[28] << 224) + (z[29] << 232) + (z[30] << 240) + (z[31] << 248) */ +/* twos_complement_eval z = let x1 := z[0] + (z[1] << 64) + (z[2] << 128) + (z[3] << 192) in */ +/* if x1 & (2^256-1) < 2^255 then x1 & (2^256-1) else (x1 & (2^256-1)) - 2^256 */ + +#include +typedef unsigned char fiat_p256_uint1; +typedef signed char fiat_p256_int1; +#if defined(__GNUC__) || defined(__clang__) +# define FIAT_P256_FIAT_EXTENSION __extension__ +# define FIAT_P256_FIAT_INLINE __inline__ +#else +# define FIAT_P256_FIAT_EXTENSION +# define FIAT_P256_FIAT_INLINE +#endif + +FIAT_P256_FIAT_EXTENSION typedef signed __int128 fiat_p256_int128; +FIAT_P256_FIAT_EXTENSION typedef unsigned __int128 fiat_p256_uint128; + +/* The type fiat_p256_montgomery_domain_field_element is a field element in the Montgomery domain. */ +/* Bounds: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ +typedef uint64_t fiat_p256_montgomery_domain_field_element[4]; + +/* The type fiat_p256_non_montgomery_domain_field_element is a field element NOT in the Montgomery domain. */ +/* Bounds: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ +typedef uint64_t fiat_p256_non_montgomery_domain_field_element[4]; + +#if (-1 & 3) != 3 +#error "This code only works on a two's complement system" +#endif + +#if !defined(FIAT_P256_NO_ASM) && (defined(__GNUC__) || defined(__clang__)) +static __inline__ uint64_t fiat_p256_value_barrier_u64(uint64_t a) { + __asm__("" : "+r"(a) : /* no inputs */); + return a; +} +#else +# define fiat_p256_value_barrier_u64(x) (x) +#endif + + +/* + * The function fiat_p256_addcarryx_u64 is an addition with carry. + * + * Postconditions: + * out1 = (arg1 + arg2 + arg3) mod 2^64 + * out2 = ⌊(arg1 + arg2 + arg3) / 2^64⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0xffffffffffffffff] + * arg3: [0x0 ~> 0xffffffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + * out2: [0x0 ~> 0x1] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_addcarryx_u64(uint64_t* out1, fiat_p256_uint1* out2, fiat_p256_uint1 arg1, uint64_t arg2, uint64_t arg3) { + fiat_p256_uint128 x1; + uint64_t x2; + fiat_p256_uint1 x3; + x1 = ((arg1 + (fiat_p256_uint128)arg2) + arg3); + x2 = (uint64_t)(x1 & UINT64_C(0xffffffffffffffff)); + x3 = (fiat_p256_uint1)(x1 >> 64); + *out1 = x2; + *out2 = x3; +} + +/* + * The function fiat_p256_subborrowx_u64 is a subtraction with borrow. + * + * Postconditions: + * out1 = (-arg1 + arg2 + -arg3) mod 2^64 + * out2 = -⌊(-arg1 + arg2 + -arg3) / 2^64⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0xffffffffffffffff] + * arg3: [0x0 ~> 0xffffffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + * out2: [0x0 ~> 0x1] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_subborrowx_u64(uint64_t* out1, fiat_p256_uint1* out2, fiat_p256_uint1 arg1, uint64_t arg2, uint64_t arg3) { + fiat_p256_int128 x1; + fiat_p256_int1 x2; + uint64_t x3; + x1 = ((arg2 - (fiat_p256_int128)arg1) - arg3); + x2 = (fiat_p256_int1)(x1 >> 64); + x3 = (uint64_t)(x1 & UINT64_C(0xffffffffffffffff)); + *out1 = x3; + *out2 = (fiat_p256_uint1)(0x0 - x2); +} + +/* + * The function fiat_p256_mulx_u64 is a multiplication, returning the full double-width result. + * + * Postconditions: + * out1 = (arg1 * arg2) mod 2^64 + * out2 = ⌊arg1 * arg2 / 2^64⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0xffffffffffffffff] + * arg2: [0x0 ~> 0xffffffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + * out2: [0x0 ~> 0xffffffffffffffff] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_mulx_u64(uint64_t* out1, uint64_t* out2, uint64_t arg1, uint64_t arg2) { + fiat_p256_uint128 x1; + uint64_t x2; + uint64_t x3; + x1 = ((fiat_p256_uint128)arg1 * arg2); + x2 = (uint64_t)(x1 & UINT64_C(0xffffffffffffffff)); + x3 = (uint64_t)(x1 >> 64); + *out1 = x2; + *out2 = x3; +} + +/* + * The function fiat_p256_cmovznz_u64 is a single-word conditional move. + * + * Postconditions: + * out1 = (if arg1 = 0 then arg2 else arg3) + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0xffffffffffffffff] + * arg3: [0x0 ~> 0xffffffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_cmovznz_u64(uint64_t* out1, fiat_p256_uint1 arg1, uint64_t arg2, uint64_t arg3) { + fiat_p256_uint1 x1; + uint64_t x2; + uint64_t x3; + x1 = (!(!arg1)); + x2 = ((fiat_p256_int1)(0x0 - x1) & UINT64_C(0xffffffffffffffff)); + x3 = ((fiat_p256_value_barrier_u64(x2) & arg3) | (fiat_p256_value_barrier_u64((~x2)) & arg2)); + *out1 = x3; +} + +/* + * The function fiat_p256_mul multiplies two field elements in the Montgomery domain. + * + * Preconditions: + * 0 ≤ eval arg1 < m + * 0 ≤ eval arg2 < m + * Postconditions: + * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) * eval (from_montgomery arg2)) mod m + * 0 ≤ eval out1 < m + * + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_mul(fiat_p256_montgomery_domain_field_element out1, const fiat_p256_montgomery_domain_field_element arg1, const fiat_p256_montgomery_domain_field_element arg2) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + uint64_t x6; + uint64_t x7; + uint64_t x8; + uint64_t x9; + uint64_t x10; + uint64_t x11; + uint64_t x12; + uint64_t x13; + fiat_p256_uint1 x14; + uint64_t x15; + fiat_p256_uint1 x16; + uint64_t x17; + fiat_p256_uint1 x18; + uint64_t x19; + uint64_t x20; + uint64_t x21; + uint64_t x22; + uint64_t x23; + uint64_t x24; + uint64_t x25; + uint64_t x26; + fiat_p256_uint1 x27; + uint64_t x28; + uint64_t x29; + fiat_p256_uint1 x30; + uint64_t x31; + fiat_p256_uint1 x32; + uint64_t x33; + fiat_p256_uint1 x34; + uint64_t x35; + fiat_p256_uint1 x36; + uint64_t x37; + fiat_p256_uint1 x38; + uint64_t x39; + uint64_t x40; + uint64_t x41; + uint64_t x42; + uint64_t x43; + uint64_t x44; + uint64_t x45; + uint64_t x46; + uint64_t x47; + fiat_p256_uint1 x48; + uint64_t x49; + fiat_p256_uint1 x50; + uint64_t x51; + fiat_p256_uint1 x52; + uint64_t x53; + uint64_t x54; + fiat_p256_uint1 x55; + uint64_t x56; + fiat_p256_uint1 x57; + uint64_t x58; + fiat_p256_uint1 x59; + uint64_t x60; + fiat_p256_uint1 x61; + uint64_t x62; + fiat_p256_uint1 x63; + uint64_t x64; + uint64_t x65; + uint64_t x66; + uint64_t x67; + uint64_t x68; + uint64_t x69; + uint64_t x70; + fiat_p256_uint1 x71; + uint64_t x72; + uint64_t x73; + fiat_p256_uint1 x74; + uint64_t x75; + fiat_p256_uint1 x76; + uint64_t x77; + fiat_p256_uint1 x78; + uint64_t x79; + fiat_p256_uint1 x80; + uint64_t x81; + fiat_p256_uint1 x82; + uint64_t x83; + uint64_t x84; + uint64_t x85; + uint64_t x86; + uint64_t x87; + uint64_t x88; + uint64_t x89; + uint64_t x90; + uint64_t x91; + uint64_t x92; + fiat_p256_uint1 x93; + uint64_t x94; + fiat_p256_uint1 x95; + uint64_t x96; + fiat_p256_uint1 x97; + uint64_t x98; + uint64_t x99; + fiat_p256_uint1 x100; + uint64_t x101; + fiat_p256_uint1 x102; + uint64_t x103; + fiat_p256_uint1 x104; + uint64_t x105; + fiat_p256_uint1 x106; + uint64_t x107; + fiat_p256_uint1 x108; + uint64_t x109; + uint64_t x110; + uint64_t x111; + uint64_t x112; + uint64_t x113; + uint64_t x114; + uint64_t x115; + fiat_p256_uint1 x116; + uint64_t x117; + uint64_t x118; + fiat_p256_uint1 x119; + uint64_t x120; + fiat_p256_uint1 x121; + uint64_t x122; + fiat_p256_uint1 x123; + uint64_t x124; + fiat_p256_uint1 x125; + uint64_t x126; + fiat_p256_uint1 x127; + uint64_t x128; + uint64_t x129; + uint64_t x130; + uint64_t x131; + uint64_t x132; + uint64_t x133; + uint64_t x134; + uint64_t x135; + uint64_t x136; + uint64_t x137; + fiat_p256_uint1 x138; + uint64_t x139; + fiat_p256_uint1 x140; + uint64_t x141; + fiat_p256_uint1 x142; + uint64_t x143; + uint64_t x144; + fiat_p256_uint1 x145; + uint64_t x146; + fiat_p256_uint1 x147; + uint64_t x148; + fiat_p256_uint1 x149; + uint64_t x150; + fiat_p256_uint1 x151; + uint64_t x152; + fiat_p256_uint1 x153; + uint64_t x154; + uint64_t x155; + uint64_t x156; + uint64_t x157; + uint64_t x158; + uint64_t x159; + uint64_t x160; + fiat_p256_uint1 x161; + uint64_t x162; + uint64_t x163; + fiat_p256_uint1 x164; + uint64_t x165; + fiat_p256_uint1 x166; + uint64_t x167; + fiat_p256_uint1 x168; + uint64_t x169; + fiat_p256_uint1 x170; + uint64_t x171; + fiat_p256_uint1 x172; + uint64_t x173; + uint64_t x174; + fiat_p256_uint1 x175; + uint64_t x176; + fiat_p256_uint1 x177; + uint64_t x178; + fiat_p256_uint1 x179; + uint64_t x180; + fiat_p256_uint1 x181; + uint64_t x182; + fiat_p256_uint1 x183; + uint64_t x184; + uint64_t x185; + uint64_t x186; + uint64_t x187; + x1 = (arg1[1]); + x2 = (arg1[2]); + x3 = (arg1[3]); + x4 = (arg1[0]); + fiat_p256_mulx_u64(&x5, &x6, x4, (arg2[3])); + fiat_p256_mulx_u64(&x7, &x8, x4, (arg2[2])); + fiat_p256_mulx_u64(&x9, &x10, x4, (arg2[1])); + fiat_p256_mulx_u64(&x11, &x12, x4, (arg2[0])); + fiat_p256_addcarryx_u64(&x13, &x14, 0x0, x12, x9); + fiat_p256_addcarryx_u64(&x15, &x16, x14, x10, x7); + fiat_p256_addcarryx_u64(&x17, &x18, x16, x8, x5); + x19 = (x18 + x6); + fiat_p256_mulx_u64(&x20, &x21, x11, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x22, &x23, x11, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x24, &x25, x11, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x26, &x27, 0x0, x25, x22); + x28 = (x27 + x23); + fiat_p256_addcarryx_u64(&x29, &x30, 0x0, x11, x24); + fiat_p256_addcarryx_u64(&x31, &x32, x30, x13, x26); + fiat_p256_addcarryx_u64(&x33, &x34, x32, x15, x28); + fiat_p256_addcarryx_u64(&x35, &x36, x34, x17, x20); + fiat_p256_addcarryx_u64(&x37, &x38, x36, x19, x21); + fiat_p256_mulx_u64(&x39, &x40, x1, (arg2[3])); + fiat_p256_mulx_u64(&x41, &x42, x1, (arg2[2])); + fiat_p256_mulx_u64(&x43, &x44, x1, (arg2[1])); + fiat_p256_mulx_u64(&x45, &x46, x1, (arg2[0])); + fiat_p256_addcarryx_u64(&x47, &x48, 0x0, x46, x43); + fiat_p256_addcarryx_u64(&x49, &x50, x48, x44, x41); + fiat_p256_addcarryx_u64(&x51, &x52, x50, x42, x39); + x53 = (x52 + x40); + fiat_p256_addcarryx_u64(&x54, &x55, 0x0, x31, x45); + fiat_p256_addcarryx_u64(&x56, &x57, x55, x33, x47); + fiat_p256_addcarryx_u64(&x58, &x59, x57, x35, x49); + fiat_p256_addcarryx_u64(&x60, &x61, x59, x37, x51); + fiat_p256_addcarryx_u64(&x62, &x63, x61, x38, x53); + fiat_p256_mulx_u64(&x64, &x65, x54, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x66, &x67, x54, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x68, &x69, x54, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x70, &x71, 0x0, x69, x66); + x72 = (x71 + x67); + fiat_p256_addcarryx_u64(&x73, &x74, 0x0, x54, x68); + fiat_p256_addcarryx_u64(&x75, &x76, x74, x56, x70); + fiat_p256_addcarryx_u64(&x77, &x78, x76, x58, x72); + fiat_p256_addcarryx_u64(&x79, &x80, x78, x60, x64); + fiat_p256_addcarryx_u64(&x81, &x82, x80, x62, x65); + x83 = ((uint64_t)x82 + x63); + fiat_p256_mulx_u64(&x84, &x85, x2, (arg2[3])); + fiat_p256_mulx_u64(&x86, &x87, x2, (arg2[2])); + fiat_p256_mulx_u64(&x88, &x89, x2, (arg2[1])); + fiat_p256_mulx_u64(&x90, &x91, x2, (arg2[0])); + fiat_p256_addcarryx_u64(&x92, &x93, 0x0, x91, x88); + fiat_p256_addcarryx_u64(&x94, &x95, x93, x89, x86); + fiat_p256_addcarryx_u64(&x96, &x97, x95, x87, x84); + x98 = (x97 + x85); + fiat_p256_addcarryx_u64(&x99, &x100, 0x0, x75, x90); + fiat_p256_addcarryx_u64(&x101, &x102, x100, x77, x92); + fiat_p256_addcarryx_u64(&x103, &x104, x102, x79, x94); + fiat_p256_addcarryx_u64(&x105, &x106, x104, x81, x96); + fiat_p256_addcarryx_u64(&x107, &x108, x106, x83, x98); + fiat_p256_mulx_u64(&x109, &x110, x99, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x111, &x112, x99, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x113, &x114, x99, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x115, &x116, 0x0, x114, x111); + x117 = (x116 + x112); + fiat_p256_addcarryx_u64(&x118, &x119, 0x0, x99, x113); + fiat_p256_addcarryx_u64(&x120, &x121, x119, x101, x115); + fiat_p256_addcarryx_u64(&x122, &x123, x121, x103, x117); + fiat_p256_addcarryx_u64(&x124, &x125, x123, x105, x109); + fiat_p256_addcarryx_u64(&x126, &x127, x125, x107, x110); + x128 = ((uint64_t)x127 + x108); + fiat_p256_mulx_u64(&x129, &x130, x3, (arg2[3])); + fiat_p256_mulx_u64(&x131, &x132, x3, (arg2[2])); + fiat_p256_mulx_u64(&x133, &x134, x3, (arg2[1])); + fiat_p256_mulx_u64(&x135, &x136, x3, (arg2[0])); + fiat_p256_addcarryx_u64(&x137, &x138, 0x0, x136, x133); + fiat_p256_addcarryx_u64(&x139, &x140, x138, x134, x131); + fiat_p256_addcarryx_u64(&x141, &x142, x140, x132, x129); + x143 = (x142 + x130); + fiat_p256_addcarryx_u64(&x144, &x145, 0x0, x120, x135); + fiat_p256_addcarryx_u64(&x146, &x147, x145, x122, x137); + fiat_p256_addcarryx_u64(&x148, &x149, x147, x124, x139); + fiat_p256_addcarryx_u64(&x150, &x151, x149, x126, x141); + fiat_p256_addcarryx_u64(&x152, &x153, x151, x128, x143); + fiat_p256_mulx_u64(&x154, &x155, x144, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x156, &x157, x144, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x158, &x159, x144, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x160, &x161, 0x0, x159, x156); + x162 = (x161 + x157); + fiat_p256_addcarryx_u64(&x163, &x164, 0x0, x144, x158); + fiat_p256_addcarryx_u64(&x165, &x166, x164, x146, x160); + fiat_p256_addcarryx_u64(&x167, &x168, x166, x148, x162); + fiat_p256_addcarryx_u64(&x169, &x170, x168, x150, x154); + fiat_p256_addcarryx_u64(&x171, &x172, x170, x152, x155); + x173 = ((uint64_t)x172 + x153); + fiat_p256_subborrowx_u64(&x174, &x175, 0x0, x165, UINT64_C(0xffffffffffffffff)); + fiat_p256_subborrowx_u64(&x176, &x177, x175, x167, UINT32_C(0xffffffff)); + fiat_p256_subborrowx_u64(&x178, &x179, x177, x169, 0x0); + fiat_p256_subborrowx_u64(&x180, &x181, x179, x171, UINT64_C(0xffffffff00000001)); + fiat_p256_subborrowx_u64(&x182, &x183, x181, x173, 0x0); + fiat_p256_cmovznz_u64(&x184, x183, x174, x165); + fiat_p256_cmovznz_u64(&x185, x183, x176, x167); + fiat_p256_cmovznz_u64(&x186, x183, x178, x169); + fiat_p256_cmovznz_u64(&x187, x183, x180, x171); + out1[0] = x184; + out1[1] = x185; + out1[2] = x186; + out1[3] = x187; +} + +/* + * The function fiat_p256_square squares a field element in the Montgomery domain. + * + * Preconditions: + * 0 ≤ eval arg1 < m + * Postconditions: + * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) * eval (from_montgomery arg1)) mod m + * 0 ≤ eval out1 < m + * + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_square(fiat_p256_montgomery_domain_field_element out1, const fiat_p256_montgomery_domain_field_element arg1) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + uint64_t x6; + uint64_t x7; + uint64_t x8; + uint64_t x9; + uint64_t x10; + uint64_t x11; + uint64_t x12; + uint64_t x13; + fiat_p256_uint1 x14; + uint64_t x15; + fiat_p256_uint1 x16; + uint64_t x17; + fiat_p256_uint1 x18; + uint64_t x19; + uint64_t x20; + uint64_t x21; + uint64_t x22; + uint64_t x23; + uint64_t x24; + uint64_t x25; + uint64_t x26; + fiat_p256_uint1 x27; + uint64_t x28; + uint64_t x29; + fiat_p256_uint1 x30; + uint64_t x31; + fiat_p256_uint1 x32; + uint64_t x33; + fiat_p256_uint1 x34; + uint64_t x35; + fiat_p256_uint1 x36; + uint64_t x37; + fiat_p256_uint1 x38; + uint64_t x39; + uint64_t x40; + uint64_t x41; + uint64_t x42; + uint64_t x43; + uint64_t x44; + uint64_t x45; + uint64_t x46; + uint64_t x47; + fiat_p256_uint1 x48; + uint64_t x49; + fiat_p256_uint1 x50; + uint64_t x51; + fiat_p256_uint1 x52; + uint64_t x53; + uint64_t x54; + fiat_p256_uint1 x55; + uint64_t x56; + fiat_p256_uint1 x57; + uint64_t x58; + fiat_p256_uint1 x59; + uint64_t x60; + fiat_p256_uint1 x61; + uint64_t x62; + fiat_p256_uint1 x63; + uint64_t x64; + uint64_t x65; + uint64_t x66; + uint64_t x67; + uint64_t x68; + uint64_t x69; + uint64_t x70; + fiat_p256_uint1 x71; + uint64_t x72; + uint64_t x73; + fiat_p256_uint1 x74; + uint64_t x75; + fiat_p256_uint1 x76; + uint64_t x77; + fiat_p256_uint1 x78; + uint64_t x79; + fiat_p256_uint1 x80; + uint64_t x81; + fiat_p256_uint1 x82; + uint64_t x83; + uint64_t x84; + uint64_t x85; + uint64_t x86; + uint64_t x87; + uint64_t x88; + uint64_t x89; + uint64_t x90; + uint64_t x91; + uint64_t x92; + fiat_p256_uint1 x93; + uint64_t x94; + fiat_p256_uint1 x95; + uint64_t x96; + fiat_p256_uint1 x97; + uint64_t x98; + uint64_t x99; + fiat_p256_uint1 x100; + uint64_t x101; + fiat_p256_uint1 x102; + uint64_t x103; + fiat_p256_uint1 x104; + uint64_t x105; + fiat_p256_uint1 x106; + uint64_t x107; + fiat_p256_uint1 x108; + uint64_t x109; + uint64_t x110; + uint64_t x111; + uint64_t x112; + uint64_t x113; + uint64_t x114; + uint64_t x115; + fiat_p256_uint1 x116; + uint64_t x117; + uint64_t x118; + fiat_p256_uint1 x119; + uint64_t x120; + fiat_p256_uint1 x121; + uint64_t x122; + fiat_p256_uint1 x123; + uint64_t x124; + fiat_p256_uint1 x125; + uint64_t x126; + fiat_p256_uint1 x127; + uint64_t x128; + uint64_t x129; + uint64_t x130; + uint64_t x131; + uint64_t x132; + uint64_t x133; + uint64_t x134; + uint64_t x135; + uint64_t x136; + uint64_t x137; + fiat_p256_uint1 x138; + uint64_t x139; + fiat_p256_uint1 x140; + uint64_t x141; + fiat_p256_uint1 x142; + uint64_t x143; + uint64_t x144; + fiat_p256_uint1 x145; + uint64_t x146; + fiat_p256_uint1 x147; + uint64_t x148; + fiat_p256_uint1 x149; + uint64_t x150; + fiat_p256_uint1 x151; + uint64_t x152; + fiat_p256_uint1 x153; + uint64_t x154; + uint64_t x155; + uint64_t x156; + uint64_t x157; + uint64_t x158; + uint64_t x159; + uint64_t x160; + fiat_p256_uint1 x161; + uint64_t x162; + uint64_t x163; + fiat_p256_uint1 x164; + uint64_t x165; + fiat_p256_uint1 x166; + uint64_t x167; + fiat_p256_uint1 x168; + uint64_t x169; + fiat_p256_uint1 x170; + uint64_t x171; + fiat_p256_uint1 x172; + uint64_t x173; + uint64_t x174; + fiat_p256_uint1 x175; + uint64_t x176; + fiat_p256_uint1 x177; + uint64_t x178; + fiat_p256_uint1 x179; + uint64_t x180; + fiat_p256_uint1 x181; + uint64_t x182; + fiat_p256_uint1 x183; + uint64_t x184; + uint64_t x185; + uint64_t x186; + uint64_t x187; + x1 = (arg1[1]); + x2 = (arg1[2]); + x3 = (arg1[3]); + x4 = (arg1[0]); + fiat_p256_mulx_u64(&x5, &x6, x4, (arg1[3])); + fiat_p256_mulx_u64(&x7, &x8, x4, (arg1[2])); + fiat_p256_mulx_u64(&x9, &x10, x4, (arg1[1])); + fiat_p256_mulx_u64(&x11, &x12, x4, (arg1[0])); + fiat_p256_addcarryx_u64(&x13, &x14, 0x0, x12, x9); + fiat_p256_addcarryx_u64(&x15, &x16, x14, x10, x7); + fiat_p256_addcarryx_u64(&x17, &x18, x16, x8, x5); + x19 = (x18 + x6); + fiat_p256_mulx_u64(&x20, &x21, x11, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x22, &x23, x11, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x24, &x25, x11, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x26, &x27, 0x0, x25, x22); + x28 = (x27 + x23); + fiat_p256_addcarryx_u64(&x29, &x30, 0x0, x11, x24); + fiat_p256_addcarryx_u64(&x31, &x32, x30, x13, x26); + fiat_p256_addcarryx_u64(&x33, &x34, x32, x15, x28); + fiat_p256_addcarryx_u64(&x35, &x36, x34, x17, x20); + fiat_p256_addcarryx_u64(&x37, &x38, x36, x19, x21); + fiat_p256_mulx_u64(&x39, &x40, x1, (arg1[3])); + fiat_p256_mulx_u64(&x41, &x42, x1, (arg1[2])); + fiat_p256_mulx_u64(&x43, &x44, x1, (arg1[1])); + fiat_p256_mulx_u64(&x45, &x46, x1, (arg1[0])); + fiat_p256_addcarryx_u64(&x47, &x48, 0x0, x46, x43); + fiat_p256_addcarryx_u64(&x49, &x50, x48, x44, x41); + fiat_p256_addcarryx_u64(&x51, &x52, x50, x42, x39); + x53 = (x52 + x40); + fiat_p256_addcarryx_u64(&x54, &x55, 0x0, x31, x45); + fiat_p256_addcarryx_u64(&x56, &x57, x55, x33, x47); + fiat_p256_addcarryx_u64(&x58, &x59, x57, x35, x49); + fiat_p256_addcarryx_u64(&x60, &x61, x59, x37, x51); + fiat_p256_addcarryx_u64(&x62, &x63, x61, x38, x53); + fiat_p256_mulx_u64(&x64, &x65, x54, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x66, &x67, x54, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x68, &x69, x54, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x70, &x71, 0x0, x69, x66); + x72 = (x71 + x67); + fiat_p256_addcarryx_u64(&x73, &x74, 0x0, x54, x68); + fiat_p256_addcarryx_u64(&x75, &x76, x74, x56, x70); + fiat_p256_addcarryx_u64(&x77, &x78, x76, x58, x72); + fiat_p256_addcarryx_u64(&x79, &x80, x78, x60, x64); + fiat_p256_addcarryx_u64(&x81, &x82, x80, x62, x65); + x83 = ((uint64_t)x82 + x63); + fiat_p256_mulx_u64(&x84, &x85, x2, (arg1[3])); + fiat_p256_mulx_u64(&x86, &x87, x2, (arg1[2])); + fiat_p256_mulx_u64(&x88, &x89, x2, (arg1[1])); + fiat_p256_mulx_u64(&x90, &x91, x2, (arg1[0])); + fiat_p256_addcarryx_u64(&x92, &x93, 0x0, x91, x88); + fiat_p256_addcarryx_u64(&x94, &x95, x93, x89, x86); + fiat_p256_addcarryx_u64(&x96, &x97, x95, x87, x84); + x98 = (x97 + x85); + fiat_p256_addcarryx_u64(&x99, &x100, 0x0, x75, x90); + fiat_p256_addcarryx_u64(&x101, &x102, x100, x77, x92); + fiat_p256_addcarryx_u64(&x103, &x104, x102, x79, x94); + fiat_p256_addcarryx_u64(&x105, &x106, x104, x81, x96); + fiat_p256_addcarryx_u64(&x107, &x108, x106, x83, x98); + fiat_p256_mulx_u64(&x109, &x110, x99, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x111, &x112, x99, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x113, &x114, x99, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x115, &x116, 0x0, x114, x111); + x117 = (x116 + x112); + fiat_p256_addcarryx_u64(&x118, &x119, 0x0, x99, x113); + fiat_p256_addcarryx_u64(&x120, &x121, x119, x101, x115); + fiat_p256_addcarryx_u64(&x122, &x123, x121, x103, x117); + fiat_p256_addcarryx_u64(&x124, &x125, x123, x105, x109); + fiat_p256_addcarryx_u64(&x126, &x127, x125, x107, x110); + x128 = ((uint64_t)x127 + x108); + fiat_p256_mulx_u64(&x129, &x130, x3, (arg1[3])); + fiat_p256_mulx_u64(&x131, &x132, x3, (arg1[2])); + fiat_p256_mulx_u64(&x133, &x134, x3, (arg1[1])); + fiat_p256_mulx_u64(&x135, &x136, x3, (arg1[0])); + fiat_p256_addcarryx_u64(&x137, &x138, 0x0, x136, x133); + fiat_p256_addcarryx_u64(&x139, &x140, x138, x134, x131); + fiat_p256_addcarryx_u64(&x141, &x142, x140, x132, x129); + x143 = (x142 + x130); + fiat_p256_addcarryx_u64(&x144, &x145, 0x0, x120, x135); + fiat_p256_addcarryx_u64(&x146, &x147, x145, x122, x137); + fiat_p256_addcarryx_u64(&x148, &x149, x147, x124, x139); + fiat_p256_addcarryx_u64(&x150, &x151, x149, x126, x141); + fiat_p256_addcarryx_u64(&x152, &x153, x151, x128, x143); + fiat_p256_mulx_u64(&x154, &x155, x144, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x156, &x157, x144, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x158, &x159, x144, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x160, &x161, 0x0, x159, x156); + x162 = (x161 + x157); + fiat_p256_addcarryx_u64(&x163, &x164, 0x0, x144, x158); + fiat_p256_addcarryx_u64(&x165, &x166, x164, x146, x160); + fiat_p256_addcarryx_u64(&x167, &x168, x166, x148, x162); + fiat_p256_addcarryx_u64(&x169, &x170, x168, x150, x154); + fiat_p256_addcarryx_u64(&x171, &x172, x170, x152, x155); + x173 = ((uint64_t)x172 + x153); + fiat_p256_subborrowx_u64(&x174, &x175, 0x0, x165, UINT64_C(0xffffffffffffffff)); + fiat_p256_subborrowx_u64(&x176, &x177, x175, x167, UINT32_C(0xffffffff)); + fiat_p256_subborrowx_u64(&x178, &x179, x177, x169, 0x0); + fiat_p256_subborrowx_u64(&x180, &x181, x179, x171, UINT64_C(0xffffffff00000001)); + fiat_p256_subborrowx_u64(&x182, &x183, x181, x173, 0x0); + fiat_p256_cmovznz_u64(&x184, x183, x174, x165); + fiat_p256_cmovznz_u64(&x185, x183, x176, x167); + fiat_p256_cmovznz_u64(&x186, x183, x178, x169); + fiat_p256_cmovznz_u64(&x187, x183, x180, x171); + out1[0] = x184; + out1[1] = x185; + out1[2] = x186; + out1[3] = x187; +} + +/* + * The function fiat_p256_add adds two field elements in the Montgomery domain. + * + * Preconditions: + * 0 ≤ eval arg1 < m + * 0 ≤ eval arg2 < m + * Postconditions: + * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) + eval (from_montgomery arg2)) mod m + * 0 ≤ eval out1 < m + * + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_add(fiat_p256_montgomery_domain_field_element out1, const fiat_p256_montgomery_domain_field_element arg1, const fiat_p256_montgomery_domain_field_element arg2) { + uint64_t x1; + fiat_p256_uint1 x2; + uint64_t x3; + fiat_p256_uint1 x4; + uint64_t x5; + fiat_p256_uint1 x6; + uint64_t x7; + fiat_p256_uint1 x8; + uint64_t x9; + fiat_p256_uint1 x10; + uint64_t x11; + fiat_p256_uint1 x12; + uint64_t x13; + fiat_p256_uint1 x14; + uint64_t x15; + fiat_p256_uint1 x16; + uint64_t x17; + fiat_p256_uint1 x18; + uint64_t x19; + uint64_t x20; + uint64_t x21; + uint64_t x22; + fiat_p256_addcarryx_u64(&x1, &x2, 0x0, (arg1[0]), (arg2[0])); + fiat_p256_addcarryx_u64(&x3, &x4, x2, (arg1[1]), (arg2[1])); + fiat_p256_addcarryx_u64(&x5, &x6, x4, (arg1[2]), (arg2[2])); + fiat_p256_addcarryx_u64(&x7, &x8, x6, (arg1[3]), (arg2[3])); + fiat_p256_subborrowx_u64(&x9, &x10, 0x0, x1, UINT64_C(0xffffffffffffffff)); + fiat_p256_subborrowx_u64(&x11, &x12, x10, x3, UINT32_C(0xffffffff)); + fiat_p256_subborrowx_u64(&x13, &x14, x12, x5, 0x0); + fiat_p256_subborrowx_u64(&x15, &x16, x14, x7, UINT64_C(0xffffffff00000001)); + fiat_p256_subborrowx_u64(&x17, &x18, x16, x8, 0x0); + fiat_p256_cmovznz_u64(&x19, x18, x9, x1); + fiat_p256_cmovznz_u64(&x20, x18, x11, x3); + fiat_p256_cmovznz_u64(&x21, x18, x13, x5); + fiat_p256_cmovznz_u64(&x22, x18, x15, x7); + out1[0] = x19; + out1[1] = x20; + out1[2] = x21; + out1[3] = x22; +} + +/* + * The function fiat_p256_sub subtracts two field elements in the Montgomery domain. + * + * Preconditions: + * 0 ≤ eval arg1 < m + * 0 ≤ eval arg2 < m + * Postconditions: + * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) - eval (from_montgomery arg2)) mod m + * 0 ≤ eval out1 < m + * + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_sub(fiat_p256_montgomery_domain_field_element out1, const fiat_p256_montgomery_domain_field_element arg1, const fiat_p256_montgomery_domain_field_element arg2) { + uint64_t x1; + fiat_p256_uint1 x2; + uint64_t x3; + fiat_p256_uint1 x4; + uint64_t x5; + fiat_p256_uint1 x6; + uint64_t x7; + fiat_p256_uint1 x8; + uint64_t x9; + uint64_t x10; + fiat_p256_uint1 x11; + uint64_t x12; + fiat_p256_uint1 x13; + uint64_t x14; + fiat_p256_uint1 x15; + uint64_t x16; + fiat_p256_uint1 x17; + fiat_p256_subborrowx_u64(&x1, &x2, 0x0, (arg1[0]), (arg2[0])); + fiat_p256_subborrowx_u64(&x3, &x4, x2, (arg1[1]), (arg2[1])); + fiat_p256_subborrowx_u64(&x5, &x6, x4, (arg1[2]), (arg2[2])); + fiat_p256_subborrowx_u64(&x7, &x8, x6, (arg1[3]), (arg2[3])); + fiat_p256_cmovznz_u64(&x9, x8, 0x0, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x10, &x11, 0x0, x1, x9); + fiat_p256_addcarryx_u64(&x12, &x13, x11, x3, (x9 & UINT32_C(0xffffffff))); + fiat_p256_addcarryx_u64(&x14, &x15, x13, x5, 0x0); + fiat_p256_addcarryx_u64(&x16, &x17, x15, x7, (x9 & UINT64_C(0xffffffff00000001))); + out1[0] = x10; + out1[1] = x12; + out1[2] = x14; + out1[3] = x16; +} + +/* + * The function fiat_p256_opp negates a field element in the Montgomery domain. + * + * Preconditions: + * 0 ≤ eval arg1 < m + * Postconditions: + * eval (from_montgomery out1) mod m = -eval (from_montgomery arg1) mod m + * 0 ≤ eval out1 < m + * + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_opp(fiat_p256_montgomery_domain_field_element out1, const fiat_p256_montgomery_domain_field_element arg1) { + uint64_t x1; + fiat_p256_uint1 x2; + uint64_t x3; + fiat_p256_uint1 x4; + uint64_t x5; + fiat_p256_uint1 x6; + uint64_t x7; + fiat_p256_uint1 x8; + uint64_t x9; + uint64_t x10; + fiat_p256_uint1 x11; + uint64_t x12; + fiat_p256_uint1 x13; + uint64_t x14; + fiat_p256_uint1 x15; + uint64_t x16; + fiat_p256_uint1 x17; + fiat_p256_subborrowx_u64(&x1, &x2, 0x0, 0x0, (arg1[0])); + fiat_p256_subborrowx_u64(&x3, &x4, x2, 0x0, (arg1[1])); + fiat_p256_subborrowx_u64(&x5, &x6, x4, 0x0, (arg1[2])); + fiat_p256_subborrowx_u64(&x7, &x8, x6, 0x0, (arg1[3])); + fiat_p256_cmovznz_u64(&x9, x8, 0x0, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x10, &x11, 0x0, x1, x9); + fiat_p256_addcarryx_u64(&x12, &x13, x11, x3, (x9 & UINT32_C(0xffffffff))); + fiat_p256_addcarryx_u64(&x14, &x15, x13, x5, 0x0); + fiat_p256_addcarryx_u64(&x16, &x17, x15, x7, (x9 & UINT64_C(0xffffffff00000001))); + out1[0] = x10; + out1[1] = x12; + out1[2] = x14; + out1[3] = x16; +} + +/* + * The function fiat_p256_nonzero outputs a single non-zero word if the input is non-zero and zero otherwise. + * + * Preconditions: + * 0 ≤ eval arg1 < m + * Postconditions: + * out1 = 0 ↔ eval (from_montgomery arg1) mod m = 0 + * + * Input Bounds: + * arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_nonzero(uint64_t* out1, const uint64_t arg1[4]) { + uint64_t x1; + x1 = ((arg1[0]) | ((arg1[1]) | ((arg1[2]) | (arg1[3])))); + *out1 = x1; +} + +/* + * The function fiat_p256_selectznz is a multi-limb conditional select. + * + * Postconditions: + * eval out1 = (if arg1 = 0 then eval arg2 else eval arg3) + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * arg3: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * Output Bounds: + * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_selectznz(uint64_t out1[4], fiat_p256_uint1 arg1, const uint64_t arg2[4], const uint64_t arg3[4]) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + fiat_p256_cmovznz_u64(&x1, arg1, (arg2[0]), (arg3[0])); + fiat_p256_cmovznz_u64(&x2, arg1, (arg2[1]), (arg3[1])); + fiat_p256_cmovznz_u64(&x3, arg1, (arg2[2]), (arg3[2])); + fiat_p256_cmovznz_u64(&x4, arg1, (arg2[3]), (arg3[3])); + out1[0] = x1; + out1[1] = x2; + out1[2] = x3; + out1[3] = x4; +} + diff --git a/http/vendor/ring/third_party/fiat/p256_64_msvc.h b/http/vendor/ring/third_party/fiat/p256_64_msvc.h new file mode 100644 index 0000000..8b65a37 --- /dev/null +++ b/http/vendor/ring/third_party/fiat/p256_64_msvc.h @@ -0,0 +1,2002 @@ +/* Autogenerated: 'src/ExtractionOCaml/word_by_word_montgomery' --inline --static --use-value-barrier --no-wide-int p256 64 '2^256 - 2^224 + 2^192 + 2^96 - 1' mul square add sub opp from_montgomery to_montgomery nonzero selectznz to_bytes from_bytes one msat divstep divstep_precomp */ +/* curve description: p256 */ +/* machine_wordsize = 64 (from "64") */ +/* requested operations: mul, square, add, sub, opp, from_montgomery, to_montgomery, nonzero, selectznz, to_bytes, from_bytes, one, msat, divstep, divstep_precomp */ +/* m = 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff (from "2^256 - 2^224 + 2^192 + 2^96 - 1") */ +/* */ +/* NOTE: In addition to the bounds specified above each function, all */ +/* functions synthesized for this Montgomery arithmetic require the */ +/* input to be strictly less than the prime modulus (m), and also */ +/* require the input to be in the unique saturated representation. */ +/* All functions also ensure that these two properties are true of */ +/* return values. */ +/* */ +/* Computed values: */ +/* eval z = z[0] + (z[1] << 64) + (z[2] << 128) + (z[3] << 192) */ +/* bytes_eval z = z[0] + (z[1] << 8) + (z[2] << 16) + (z[3] << 24) + (z[4] << 32) + (z[5] << 40) + (z[6] << 48) + (z[7] << 56) + (z[8] << 64) + (z[9] << 72) + (z[10] << 80) + (z[11] << 88) + (z[12] << 96) + (z[13] << 104) + (z[14] << 112) + (z[15] << 120) + (z[16] << 128) + (z[17] << 136) + (z[18] << 144) + (z[19] << 152) + (z[20] << 160) + (z[21] << 168) + (z[22] << 176) + (z[23] << 184) + (z[24] << 192) + (z[25] << 200) + (z[26] << 208) + (z[27] << 216) + (z[28] << 224) + (z[29] << 232) + (z[30] << 240) + (z[31] << 248) */ +/* twos_complement_eval z = let x1 := z[0] + (z[1] << 64) + (z[2] << 128) + (z[3] << 192) in */ +/* if x1 & (2^256-1) < 2^255 then x1 & (2^256-1) else (x1 & (2^256-1)) - 2^256 */ + +#include +#include +#if defined(_M_X64) +#include +#endif + +typedef unsigned char fiat_p256_uint1; +typedef signed char fiat_p256_int1; + +#define FIAT_P256_FIAT_INLINE inline + +/* The type fiat_p256_montgomery_domain_field_element is a field element in the Montgomery domain. */ +/* Bounds: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ +typedef uint64_t fiat_p256_montgomery_domain_field_element[4]; + +/* The type fiat_p256_non_montgomery_domain_field_element is a field element NOT in the Montgomery domain. */ +/* Bounds: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] */ +typedef uint64_t fiat_p256_non_montgomery_domain_field_element[4]; + +#if (-1 & 3) != 3 +#error "This code only works on a two's complement system" +#endif + +#define fiat_p256_value_barrier_u64(x) (x) + + +/* + * The function fiat_p256_addcarryx_u64 is an addition with carry. + * + * Postconditions: + * out1 = (arg1 + arg2 + arg3) mod 2^64 + * out2 = ⌊(arg1 + arg2 + arg3) / 2^64⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0xffffffffffffffff] + * arg3: [0x0 ~> 0xffffffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + * out2: [0x0 ~> 0x1] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_addcarryx_u64(uint64_t* out1, fiat_p256_uint1* out2, fiat_p256_uint1 arg1, uint64_t arg2, uint64_t arg3) { +#if defined(_M_X64) + *out2 = _addcarry_u64(arg1, arg2, arg3, out1); +#else + arg2 += arg1; + arg1 = arg2 < arg1; + arg3 += arg2; + arg1 += arg3 < arg2; + *out1 = arg3; + *out2 = arg1; +#endif +} + +/* + * The function fiat_p256_subborrowx_u64 is a subtraction with borrow. + * + * Postconditions: + * out1 = (-arg1 + arg2 + -arg3) mod 2^64 + * out2 = -⌊(-arg1 + arg2 + -arg3) / 2^64⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0xffffffffffffffff] + * arg3: [0x0 ~> 0xffffffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + * out2: [0x0 ~> 0x1] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_subborrowx_u64(uint64_t* out1, fiat_p256_uint1* out2, fiat_p256_uint1 arg1, uint64_t arg2, uint64_t arg3) { +#if defined(_M_X64) + *out2 = _subborrow_u64(arg1, arg2, arg3, out1); // NOTE: edited after generation +#else + *out1 = arg2 - arg3 - arg1; + *out2 = (arg2 < arg3) | ((arg2 == arg3) & arg1); +#endif +} + +/* + * The function fiat_p256_mulx_u64 is a multiplication, returning the full double-width result. + * + * Postconditions: + * out1 = (arg1 * arg2) mod 2^64 + * out2 = ⌊arg1 * arg2 / 2^64⌋ + * + * Input Bounds: + * arg1: [0x0 ~> 0xffffffffffffffff] + * arg2: [0x0 ~> 0xffffffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + * out2: [0x0 ~> 0xffffffffffffffff] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_mulx_u64(uint64_t* out1, uint64_t* out2, uint64_t arg1, uint64_t arg2) { +// NOTE: edited after generation +#if defined(_M_X64) + *out1 = _umul128(arg1, arg2, out2); +#elif defined(_M_ARM64) + *out1 = arg1 * arg2; + *out2 = __umulh(arg1, arg2); +#else +#error "This file is intended for MSVC on X64 or ARM64" +#endif +} + +/* + * The function fiat_p256_cmovznz_u64 is a single-word conditional move. + * + * Postconditions: + * out1 = (if arg1 = 0 then arg2 else arg3) + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [0x0 ~> 0xffffffffffffffff] + * arg3: [0x0 ~> 0xffffffffffffffff] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_cmovznz_u64(uint64_t* out1, fiat_p256_uint1 arg1, uint64_t arg2, uint64_t arg3) { + fiat_p256_uint1 x1; + uint64_t x2; + uint64_t x3; + x1 = (!(!arg1)); + x2 = ((fiat_p256_int1)(0x0 - x1) & UINT64_C(0xffffffffffffffff)); + x3 = ((fiat_p256_value_barrier_u64(x2) & arg3) | (fiat_p256_value_barrier_u64((~x2)) & arg2)); + *out1 = x3; +} + +/* + * The function fiat_p256_mul multiplies two field elements in the Montgomery domain. + * + * Preconditions: + * 0 ≤ eval arg1 < m + * 0 ≤ eval arg2 < m + * Postconditions: + * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) * eval (from_montgomery arg2)) mod m + * 0 ≤ eval out1 < m + * + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_mul(fiat_p256_montgomery_domain_field_element out1, const fiat_p256_montgomery_domain_field_element arg1, const fiat_p256_montgomery_domain_field_element arg2) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + uint64_t x6; + uint64_t x7; + uint64_t x8; + uint64_t x9; + uint64_t x10; + uint64_t x11; + uint64_t x12; + uint64_t x13; + fiat_p256_uint1 x14; + uint64_t x15; + fiat_p256_uint1 x16; + uint64_t x17; + fiat_p256_uint1 x18; + uint64_t x19; + uint64_t x20; + uint64_t x21; + uint64_t x22; + uint64_t x23; + uint64_t x24; + uint64_t x25; + uint64_t x26; + fiat_p256_uint1 x27; + uint64_t x28; + uint64_t x29; + fiat_p256_uint1 x30; + uint64_t x31; + fiat_p256_uint1 x32; + uint64_t x33; + fiat_p256_uint1 x34; + uint64_t x35; + fiat_p256_uint1 x36; + uint64_t x37; + fiat_p256_uint1 x38; + uint64_t x39; + uint64_t x40; + uint64_t x41; + uint64_t x42; + uint64_t x43; + uint64_t x44; + uint64_t x45; + uint64_t x46; + uint64_t x47; + fiat_p256_uint1 x48; + uint64_t x49; + fiat_p256_uint1 x50; + uint64_t x51; + fiat_p256_uint1 x52; + uint64_t x53; + uint64_t x54; + fiat_p256_uint1 x55; + uint64_t x56; + fiat_p256_uint1 x57; + uint64_t x58; + fiat_p256_uint1 x59; + uint64_t x60; + fiat_p256_uint1 x61; + uint64_t x62; + fiat_p256_uint1 x63; + uint64_t x64; + uint64_t x65; + uint64_t x66; + uint64_t x67; + uint64_t x68; + uint64_t x69; + uint64_t x70; + fiat_p256_uint1 x71; + uint64_t x72; + uint64_t x73; + fiat_p256_uint1 x74; + uint64_t x75; + fiat_p256_uint1 x76; + uint64_t x77; + fiat_p256_uint1 x78; + uint64_t x79; + fiat_p256_uint1 x80; + uint64_t x81; + fiat_p256_uint1 x82; + uint64_t x83; + uint64_t x84; + uint64_t x85; + uint64_t x86; + uint64_t x87; + uint64_t x88; + uint64_t x89; + uint64_t x90; + uint64_t x91; + uint64_t x92; + fiat_p256_uint1 x93; + uint64_t x94; + fiat_p256_uint1 x95; + uint64_t x96; + fiat_p256_uint1 x97; + uint64_t x98; + uint64_t x99; + fiat_p256_uint1 x100; + uint64_t x101; + fiat_p256_uint1 x102; + uint64_t x103; + fiat_p256_uint1 x104; + uint64_t x105; + fiat_p256_uint1 x106; + uint64_t x107; + fiat_p256_uint1 x108; + uint64_t x109; + uint64_t x110; + uint64_t x111; + uint64_t x112; + uint64_t x113; + uint64_t x114; + uint64_t x115; + fiat_p256_uint1 x116; + uint64_t x117; + uint64_t x118; + fiat_p256_uint1 x119; + uint64_t x120; + fiat_p256_uint1 x121; + uint64_t x122; + fiat_p256_uint1 x123; + uint64_t x124; + fiat_p256_uint1 x125; + uint64_t x126; + fiat_p256_uint1 x127; + uint64_t x128; + uint64_t x129; + uint64_t x130; + uint64_t x131; + uint64_t x132; + uint64_t x133; + uint64_t x134; + uint64_t x135; + uint64_t x136; + uint64_t x137; + fiat_p256_uint1 x138; + uint64_t x139; + fiat_p256_uint1 x140; + uint64_t x141; + fiat_p256_uint1 x142; + uint64_t x143; + uint64_t x144; + fiat_p256_uint1 x145; + uint64_t x146; + fiat_p256_uint1 x147; + uint64_t x148; + fiat_p256_uint1 x149; + uint64_t x150; + fiat_p256_uint1 x151; + uint64_t x152; + fiat_p256_uint1 x153; + uint64_t x154; + uint64_t x155; + uint64_t x156; + uint64_t x157; + uint64_t x158; + uint64_t x159; + uint64_t x160; + fiat_p256_uint1 x161; + uint64_t x162; + uint64_t x163; + fiat_p256_uint1 x164; + uint64_t x165; + fiat_p256_uint1 x166; + uint64_t x167; + fiat_p256_uint1 x168; + uint64_t x169; + fiat_p256_uint1 x170; + uint64_t x171; + fiat_p256_uint1 x172; + uint64_t x173; + uint64_t x174; + fiat_p256_uint1 x175; + uint64_t x176; + fiat_p256_uint1 x177; + uint64_t x178; + fiat_p256_uint1 x179; + uint64_t x180; + fiat_p256_uint1 x181; + uint64_t x182; + fiat_p256_uint1 x183; + uint64_t x184; + uint64_t x185; + uint64_t x186; + uint64_t x187; + x1 = (arg1[1]); + x2 = (arg1[2]); + x3 = (arg1[3]); + x4 = (arg1[0]); + fiat_p256_mulx_u64(&x5, &x6, x4, (arg2[3])); + fiat_p256_mulx_u64(&x7, &x8, x4, (arg2[2])); + fiat_p256_mulx_u64(&x9, &x10, x4, (arg2[1])); + fiat_p256_mulx_u64(&x11, &x12, x4, (arg2[0])); + fiat_p256_addcarryx_u64(&x13, &x14, 0x0, x12, x9); + fiat_p256_addcarryx_u64(&x15, &x16, x14, x10, x7); + fiat_p256_addcarryx_u64(&x17, &x18, x16, x8, x5); + x19 = (x18 + x6); + fiat_p256_mulx_u64(&x20, &x21, x11, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x22, &x23, x11, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x24, &x25, x11, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x26, &x27, 0x0, x25, x22); + x28 = (x27 + x23); + fiat_p256_addcarryx_u64(&x29, &x30, 0x0, x11, x24); + fiat_p256_addcarryx_u64(&x31, &x32, x30, x13, x26); + fiat_p256_addcarryx_u64(&x33, &x34, x32, x15, x28); + fiat_p256_addcarryx_u64(&x35, &x36, x34, x17, x20); + fiat_p256_addcarryx_u64(&x37, &x38, x36, x19, x21); + fiat_p256_mulx_u64(&x39, &x40, x1, (arg2[3])); + fiat_p256_mulx_u64(&x41, &x42, x1, (arg2[2])); + fiat_p256_mulx_u64(&x43, &x44, x1, (arg2[1])); + fiat_p256_mulx_u64(&x45, &x46, x1, (arg2[0])); + fiat_p256_addcarryx_u64(&x47, &x48, 0x0, x46, x43); + fiat_p256_addcarryx_u64(&x49, &x50, x48, x44, x41); + fiat_p256_addcarryx_u64(&x51, &x52, x50, x42, x39); + x53 = (x52 + x40); + fiat_p256_addcarryx_u64(&x54, &x55, 0x0, x31, x45); + fiat_p256_addcarryx_u64(&x56, &x57, x55, x33, x47); + fiat_p256_addcarryx_u64(&x58, &x59, x57, x35, x49); + fiat_p256_addcarryx_u64(&x60, &x61, x59, x37, x51); + fiat_p256_addcarryx_u64(&x62, &x63, x61, x38, x53); + fiat_p256_mulx_u64(&x64, &x65, x54, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x66, &x67, x54, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x68, &x69, x54, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x70, &x71, 0x0, x69, x66); + x72 = (x71 + x67); + fiat_p256_addcarryx_u64(&x73, &x74, 0x0, x54, x68); + fiat_p256_addcarryx_u64(&x75, &x76, x74, x56, x70); + fiat_p256_addcarryx_u64(&x77, &x78, x76, x58, x72); + fiat_p256_addcarryx_u64(&x79, &x80, x78, x60, x64); + fiat_p256_addcarryx_u64(&x81, &x82, x80, x62, x65); + x83 = ((uint64_t)x82 + x63); + fiat_p256_mulx_u64(&x84, &x85, x2, (arg2[3])); + fiat_p256_mulx_u64(&x86, &x87, x2, (arg2[2])); + fiat_p256_mulx_u64(&x88, &x89, x2, (arg2[1])); + fiat_p256_mulx_u64(&x90, &x91, x2, (arg2[0])); + fiat_p256_addcarryx_u64(&x92, &x93, 0x0, x91, x88); + fiat_p256_addcarryx_u64(&x94, &x95, x93, x89, x86); + fiat_p256_addcarryx_u64(&x96, &x97, x95, x87, x84); + x98 = (x97 + x85); + fiat_p256_addcarryx_u64(&x99, &x100, 0x0, x75, x90); + fiat_p256_addcarryx_u64(&x101, &x102, x100, x77, x92); + fiat_p256_addcarryx_u64(&x103, &x104, x102, x79, x94); + fiat_p256_addcarryx_u64(&x105, &x106, x104, x81, x96); + fiat_p256_addcarryx_u64(&x107, &x108, x106, x83, x98); + fiat_p256_mulx_u64(&x109, &x110, x99, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x111, &x112, x99, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x113, &x114, x99, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x115, &x116, 0x0, x114, x111); + x117 = (x116 + x112); + fiat_p256_addcarryx_u64(&x118, &x119, 0x0, x99, x113); + fiat_p256_addcarryx_u64(&x120, &x121, x119, x101, x115); + fiat_p256_addcarryx_u64(&x122, &x123, x121, x103, x117); + fiat_p256_addcarryx_u64(&x124, &x125, x123, x105, x109); + fiat_p256_addcarryx_u64(&x126, &x127, x125, x107, x110); + x128 = ((uint64_t)x127 + x108); + fiat_p256_mulx_u64(&x129, &x130, x3, (arg2[3])); + fiat_p256_mulx_u64(&x131, &x132, x3, (arg2[2])); + fiat_p256_mulx_u64(&x133, &x134, x3, (arg2[1])); + fiat_p256_mulx_u64(&x135, &x136, x3, (arg2[0])); + fiat_p256_addcarryx_u64(&x137, &x138, 0x0, x136, x133); + fiat_p256_addcarryx_u64(&x139, &x140, x138, x134, x131); + fiat_p256_addcarryx_u64(&x141, &x142, x140, x132, x129); + x143 = (x142 + x130); + fiat_p256_addcarryx_u64(&x144, &x145, 0x0, x120, x135); + fiat_p256_addcarryx_u64(&x146, &x147, x145, x122, x137); + fiat_p256_addcarryx_u64(&x148, &x149, x147, x124, x139); + fiat_p256_addcarryx_u64(&x150, &x151, x149, x126, x141); + fiat_p256_addcarryx_u64(&x152, &x153, x151, x128, x143); + fiat_p256_mulx_u64(&x154, &x155, x144, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x156, &x157, x144, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x158, &x159, x144, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x160, &x161, 0x0, x159, x156); + x162 = (x161 + x157); + fiat_p256_addcarryx_u64(&x163, &x164, 0x0, x144, x158); + fiat_p256_addcarryx_u64(&x165, &x166, x164, x146, x160); + fiat_p256_addcarryx_u64(&x167, &x168, x166, x148, x162); + fiat_p256_addcarryx_u64(&x169, &x170, x168, x150, x154); + fiat_p256_addcarryx_u64(&x171, &x172, x170, x152, x155); + x173 = ((uint64_t)x172 + x153); + fiat_p256_subborrowx_u64(&x174, &x175, 0x0, x165, UINT64_C(0xffffffffffffffff)); + fiat_p256_subborrowx_u64(&x176, &x177, x175, x167, UINT32_C(0xffffffff)); + fiat_p256_subborrowx_u64(&x178, &x179, x177, x169, 0x0); + fiat_p256_subborrowx_u64(&x180, &x181, x179, x171, UINT64_C(0xffffffff00000001)); + fiat_p256_subborrowx_u64(&x182, &x183, x181, x173, 0x0); + fiat_p256_cmovznz_u64(&x184, x183, x174, x165); + fiat_p256_cmovznz_u64(&x185, x183, x176, x167); + fiat_p256_cmovznz_u64(&x186, x183, x178, x169); + fiat_p256_cmovznz_u64(&x187, x183, x180, x171); + out1[0] = x184; + out1[1] = x185; + out1[2] = x186; + out1[3] = x187; +} + +/* + * The function fiat_p256_square squares a field element in the Montgomery domain. + * + * Preconditions: + * 0 ≤ eval arg1 < m + * Postconditions: + * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) * eval (from_montgomery arg1)) mod m + * 0 ≤ eval out1 < m + * + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_square(fiat_p256_montgomery_domain_field_element out1, const fiat_p256_montgomery_domain_field_element arg1) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + uint64_t x6; + uint64_t x7; + uint64_t x8; + uint64_t x9; + uint64_t x10; + uint64_t x11; + uint64_t x12; + uint64_t x13; + fiat_p256_uint1 x14; + uint64_t x15; + fiat_p256_uint1 x16; + uint64_t x17; + fiat_p256_uint1 x18; + uint64_t x19; + uint64_t x20; + uint64_t x21; + uint64_t x22; + uint64_t x23; + uint64_t x24; + uint64_t x25; + uint64_t x26; + fiat_p256_uint1 x27; + uint64_t x28; + uint64_t x29; + fiat_p256_uint1 x30; + uint64_t x31; + fiat_p256_uint1 x32; + uint64_t x33; + fiat_p256_uint1 x34; + uint64_t x35; + fiat_p256_uint1 x36; + uint64_t x37; + fiat_p256_uint1 x38; + uint64_t x39; + uint64_t x40; + uint64_t x41; + uint64_t x42; + uint64_t x43; + uint64_t x44; + uint64_t x45; + uint64_t x46; + uint64_t x47; + fiat_p256_uint1 x48; + uint64_t x49; + fiat_p256_uint1 x50; + uint64_t x51; + fiat_p256_uint1 x52; + uint64_t x53; + uint64_t x54; + fiat_p256_uint1 x55; + uint64_t x56; + fiat_p256_uint1 x57; + uint64_t x58; + fiat_p256_uint1 x59; + uint64_t x60; + fiat_p256_uint1 x61; + uint64_t x62; + fiat_p256_uint1 x63; + uint64_t x64; + uint64_t x65; + uint64_t x66; + uint64_t x67; + uint64_t x68; + uint64_t x69; + uint64_t x70; + fiat_p256_uint1 x71; + uint64_t x72; + uint64_t x73; + fiat_p256_uint1 x74; + uint64_t x75; + fiat_p256_uint1 x76; + uint64_t x77; + fiat_p256_uint1 x78; + uint64_t x79; + fiat_p256_uint1 x80; + uint64_t x81; + fiat_p256_uint1 x82; + uint64_t x83; + uint64_t x84; + uint64_t x85; + uint64_t x86; + uint64_t x87; + uint64_t x88; + uint64_t x89; + uint64_t x90; + uint64_t x91; + uint64_t x92; + fiat_p256_uint1 x93; + uint64_t x94; + fiat_p256_uint1 x95; + uint64_t x96; + fiat_p256_uint1 x97; + uint64_t x98; + uint64_t x99; + fiat_p256_uint1 x100; + uint64_t x101; + fiat_p256_uint1 x102; + uint64_t x103; + fiat_p256_uint1 x104; + uint64_t x105; + fiat_p256_uint1 x106; + uint64_t x107; + fiat_p256_uint1 x108; + uint64_t x109; + uint64_t x110; + uint64_t x111; + uint64_t x112; + uint64_t x113; + uint64_t x114; + uint64_t x115; + fiat_p256_uint1 x116; + uint64_t x117; + uint64_t x118; + fiat_p256_uint1 x119; + uint64_t x120; + fiat_p256_uint1 x121; + uint64_t x122; + fiat_p256_uint1 x123; + uint64_t x124; + fiat_p256_uint1 x125; + uint64_t x126; + fiat_p256_uint1 x127; + uint64_t x128; + uint64_t x129; + uint64_t x130; + uint64_t x131; + uint64_t x132; + uint64_t x133; + uint64_t x134; + uint64_t x135; + uint64_t x136; + uint64_t x137; + fiat_p256_uint1 x138; + uint64_t x139; + fiat_p256_uint1 x140; + uint64_t x141; + fiat_p256_uint1 x142; + uint64_t x143; + uint64_t x144; + fiat_p256_uint1 x145; + uint64_t x146; + fiat_p256_uint1 x147; + uint64_t x148; + fiat_p256_uint1 x149; + uint64_t x150; + fiat_p256_uint1 x151; + uint64_t x152; + fiat_p256_uint1 x153; + uint64_t x154; + uint64_t x155; + uint64_t x156; + uint64_t x157; + uint64_t x158; + uint64_t x159; + uint64_t x160; + fiat_p256_uint1 x161; + uint64_t x162; + uint64_t x163; + fiat_p256_uint1 x164; + uint64_t x165; + fiat_p256_uint1 x166; + uint64_t x167; + fiat_p256_uint1 x168; + uint64_t x169; + fiat_p256_uint1 x170; + uint64_t x171; + fiat_p256_uint1 x172; + uint64_t x173; + uint64_t x174; + fiat_p256_uint1 x175; + uint64_t x176; + fiat_p256_uint1 x177; + uint64_t x178; + fiat_p256_uint1 x179; + uint64_t x180; + fiat_p256_uint1 x181; + uint64_t x182; + fiat_p256_uint1 x183; + uint64_t x184; + uint64_t x185; + uint64_t x186; + uint64_t x187; + x1 = (arg1[1]); + x2 = (arg1[2]); + x3 = (arg1[3]); + x4 = (arg1[0]); + fiat_p256_mulx_u64(&x5, &x6, x4, (arg1[3])); + fiat_p256_mulx_u64(&x7, &x8, x4, (arg1[2])); + fiat_p256_mulx_u64(&x9, &x10, x4, (arg1[1])); + fiat_p256_mulx_u64(&x11, &x12, x4, (arg1[0])); + fiat_p256_addcarryx_u64(&x13, &x14, 0x0, x12, x9); + fiat_p256_addcarryx_u64(&x15, &x16, x14, x10, x7); + fiat_p256_addcarryx_u64(&x17, &x18, x16, x8, x5); + x19 = (x18 + x6); + fiat_p256_mulx_u64(&x20, &x21, x11, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x22, &x23, x11, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x24, &x25, x11, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x26, &x27, 0x0, x25, x22); + x28 = (x27 + x23); + fiat_p256_addcarryx_u64(&x29, &x30, 0x0, x11, x24); + fiat_p256_addcarryx_u64(&x31, &x32, x30, x13, x26); + fiat_p256_addcarryx_u64(&x33, &x34, x32, x15, x28); + fiat_p256_addcarryx_u64(&x35, &x36, x34, x17, x20); + fiat_p256_addcarryx_u64(&x37, &x38, x36, x19, x21); + fiat_p256_mulx_u64(&x39, &x40, x1, (arg1[3])); + fiat_p256_mulx_u64(&x41, &x42, x1, (arg1[2])); + fiat_p256_mulx_u64(&x43, &x44, x1, (arg1[1])); + fiat_p256_mulx_u64(&x45, &x46, x1, (arg1[0])); + fiat_p256_addcarryx_u64(&x47, &x48, 0x0, x46, x43); + fiat_p256_addcarryx_u64(&x49, &x50, x48, x44, x41); + fiat_p256_addcarryx_u64(&x51, &x52, x50, x42, x39); + x53 = (x52 + x40); + fiat_p256_addcarryx_u64(&x54, &x55, 0x0, x31, x45); + fiat_p256_addcarryx_u64(&x56, &x57, x55, x33, x47); + fiat_p256_addcarryx_u64(&x58, &x59, x57, x35, x49); + fiat_p256_addcarryx_u64(&x60, &x61, x59, x37, x51); + fiat_p256_addcarryx_u64(&x62, &x63, x61, x38, x53); + fiat_p256_mulx_u64(&x64, &x65, x54, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x66, &x67, x54, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x68, &x69, x54, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x70, &x71, 0x0, x69, x66); + x72 = (x71 + x67); + fiat_p256_addcarryx_u64(&x73, &x74, 0x0, x54, x68); + fiat_p256_addcarryx_u64(&x75, &x76, x74, x56, x70); + fiat_p256_addcarryx_u64(&x77, &x78, x76, x58, x72); + fiat_p256_addcarryx_u64(&x79, &x80, x78, x60, x64); + fiat_p256_addcarryx_u64(&x81, &x82, x80, x62, x65); + x83 = ((uint64_t)x82 + x63); + fiat_p256_mulx_u64(&x84, &x85, x2, (arg1[3])); + fiat_p256_mulx_u64(&x86, &x87, x2, (arg1[2])); + fiat_p256_mulx_u64(&x88, &x89, x2, (arg1[1])); + fiat_p256_mulx_u64(&x90, &x91, x2, (arg1[0])); + fiat_p256_addcarryx_u64(&x92, &x93, 0x0, x91, x88); + fiat_p256_addcarryx_u64(&x94, &x95, x93, x89, x86); + fiat_p256_addcarryx_u64(&x96, &x97, x95, x87, x84); + x98 = (x97 + x85); + fiat_p256_addcarryx_u64(&x99, &x100, 0x0, x75, x90); + fiat_p256_addcarryx_u64(&x101, &x102, x100, x77, x92); + fiat_p256_addcarryx_u64(&x103, &x104, x102, x79, x94); + fiat_p256_addcarryx_u64(&x105, &x106, x104, x81, x96); + fiat_p256_addcarryx_u64(&x107, &x108, x106, x83, x98); + fiat_p256_mulx_u64(&x109, &x110, x99, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x111, &x112, x99, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x113, &x114, x99, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x115, &x116, 0x0, x114, x111); + x117 = (x116 + x112); + fiat_p256_addcarryx_u64(&x118, &x119, 0x0, x99, x113); + fiat_p256_addcarryx_u64(&x120, &x121, x119, x101, x115); + fiat_p256_addcarryx_u64(&x122, &x123, x121, x103, x117); + fiat_p256_addcarryx_u64(&x124, &x125, x123, x105, x109); + fiat_p256_addcarryx_u64(&x126, &x127, x125, x107, x110); + x128 = ((uint64_t)x127 + x108); + fiat_p256_mulx_u64(&x129, &x130, x3, (arg1[3])); + fiat_p256_mulx_u64(&x131, &x132, x3, (arg1[2])); + fiat_p256_mulx_u64(&x133, &x134, x3, (arg1[1])); + fiat_p256_mulx_u64(&x135, &x136, x3, (arg1[0])); + fiat_p256_addcarryx_u64(&x137, &x138, 0x0, x136, x133); + fiat_p256_addcarryx_u64(&x139, &x140, x138, x134, x131); + fiat_p256_addcarryx_u64(&x141, &x142, x140, x132, x129); + x143 = (x142 + x130); + fiat_p256_addcarryx_u64(&x144, &x145, 0x0, x120, x135); + fiat_p256_addcarryx_u64(&x146, &x147, x145, x122, x137); + fiat_p256_addcarryx_u64(&x148, &x149, x147, x124, x139); + fiat_p256_addcarryx_u64(&x150, &x151, x149, x126, x141); + fiat_p256_addcarryx_u64(&x152, &x153, x151, x128, x143); + fiat_p256_mulx_u64(&x154, &x155, x144, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x156, &x157, x144, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x158, &x159, x144, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x160, &x161, 0x0, x159, x156); + x162 = (x161 + x157); + fiat_p256_addcarryx_u64(&x163, &x164, 0x0, x144, x158); + fiat_p256_addcarryx_u64(&x165, &x166, x164, x146, x160); + fiat_p256_addcarryx_u64(&x167, &x168, x166, x148, x162); + fiat_p256_addcarryx_u64(&x169, &x170, x168, x150, x154); + fiat_p256_addcarryx_u64(&x171, &x172, x170, x152, x155); + x173 = ((uint64_t)x172 + x153); + fiat_p256_subborrowx_u64(&x174, &x175, 0x0, x165, UINT64_C(0xffffffffffffffff)); + fiat_p256_subborrowx_u64(&x176, &x177, x175, x167, UINT32_C(0xffffffff)); + fiat_p256_subborrowx_u64(&x178, &x179, x177, x169, 0x0); + fiat_p256_subborrowx_u64(&x180, &x181, x179, x171, UINT64_C(0xffffffff00000001)); + fiat_p256_subborrowx_u64(&x182, &x183, x181, x173, 0x0); + fiat_p256_cmovznz_u64(&x184, x183, x174, x165); + fiat_p256_cmovznz_u64(&x185, x183, x176, x167); + fiat_p256_cmovznz_u64(&x186, x183, x178, x169); + fiat_p256_cmovznz_u64(&x187, x183, x180, x171); + out1[0] = x184; + out1[1] = x185; + out1[2] = x186; + out1[3] = x187; +} + +/* + * The function fiat_p256_add adds two field elements in the Montgomery domain. + * + * Preconditions: + * 0 ≤ eval arg1 < m + * 0 ≤ eval arg2 < m + * Postconditions: + * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) + eval (from_montgomery arg2)) mod m + * 0 ≤ eval out1 < m + * + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_add(fiat_p256_montgomery_domain_field_element out1, const fiat_p256_montgomery_domain_field_element arg1, const fiat_p256_montgomery_domain_field_element arg2) { + uint64_t x1; + fiat_p256_uint1 x2; + uint64_t x3; + fiat_p256_uint1 x4; + uint64_t x5; + fiat_p256_uint1 x6; + uint64_t x7; + fiat_p256_uint1 x8; + uint64_t x9; + fiat_p256_uint1 x10; + uint64_t x11; + fiat_p256_uint1 x12; + uint64_t x13; + fiat_p256_uint1 x14; + uint64_t x15; + fiat_p256_uint1 x16; + uint64_t x17; + fiat_p256_uint1 x18; + uint64_t x19; + uint64_t x20; + uint64_t x21; + uint64_t x22; + fiat_p256_addcarryx_u64(&x1, &x2, 0x0, (arg1[0]), (arg2[0])); + fiat_p256_addcarryx_u64(&x3, &x4, x2, (arg1[1]), (arg2[1])); + fiat_p256_addcarryx_u64(&x5, &x6, x4, (arg1[2]), (arg2[2])); + fiat_p256_addcarryx_u64(&x7, &x8, x6, (arg1[3]), (arg2[3])); + fiat_p256_subborrowx_u64(&x9, &x10, 0x0, x1, UINT64_C(0xffffffffffffffff)); + fiat_p256_subborrowx_u64(&x11, &x12, x10, x3, UINT32_C(0xffffffff)); + fiat_p256_subborrowx_u64(&x13, &x14, x12, x5, 0x0); + fiat_p256_subborrowx_u64(&x15, &x16, x14, x7, UINT64_C(0xffffffff00000001)); + fiat_p256_subborrowx_u64(&x17, &x18, x16, x8, 0x0); + fiat_p256_cmovznz_u64(&x19, x18, x9, x1); + fiat_p256_cmovznz_u64(&x20, x18, x11, x3); + fiat_p256_cmovznz_u64(&x21, x18, x13, x5); + fiat_p256_cmovznz_u64(&x22, x18, x15, x7); + out1[0] = x19; + out1[1] = x20; + out1[2] = x21; + out1[3] = x22; +} + +/* + * The function fiat_p256_sub subtracts two field elements in the Montgomery domain. + * + * Preconditions: + * 0 ≤ eval arg1 < m + * 0 ≤ eval arg2 < m + * Postconditions: + * eval (from_montgomery out1) mod m = (eval (from_montgomery arg1) - eval (from_montgomery arg2)) mod m + * 0 ≤ eval out1 < m + * + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_sub(fiat_p256_montgomery_domain_field_element out1, const fiat_p256_montgomery_domain_field_element arg1, const fiat_p256_montgomery_domain_field_element arg2) { + uint64_t x1; + fiat_p256_uint1 x2; + uint64_t x3; + fiat_p256_uint1 x4; + uint64_t x5; + fiat_p256_uint1 x6; + uint64_t x7; + fiat_p256_uint1 x8; + uint64_t x9; + uint64_t x10; + fiat_p256_uint1 x11; + uint64_t x12; + fiat_p256_uint1 x13; + uint64_t x14; + fiat_p256_uint1 x15; + uint64_t x16; + fiat_p256_uint1 x17; + fiat_p256_subborrowx_u64(&x1, &x2, 0x0, (arg1[0]), (arg2[0])); + fiat_p256_subborrowx_u64(&x3, &x4, x2, (arg1[1]), (arg2[1])); + fiat_p256_subborrowx_u64(&x5, &x6, x4, (arg1[2]), (arg2[2])); + fiat_p256_subborrowx_u64(&x7, &x8, x6, (arg1[3]), (arg2[3])); + fiat_p256_cmovznz_u64(&x9, x8, 0x0, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x10, &x11, 0x0, x1, x9); + fiat_p256_addcarryx_u64(&x12, &x13, x11, x3, (x9 & UINT32_C(0xffffffff))); + fiat_p256_addcarryx_u64(&x14, &x15, x13, x5, 0x0); + fiat_p256_addcarryx_u64(&x16, &x17, x15, x7, (x9 & UINT64_C(0xffffffff00000001))); + out1[0] = x10; + out1[1] = x12; + out1[2] = x14; + out1[3] = x16; +} + +/* + * The function fiat_p256_opp negates a field element in the Montgomery domain. + * + * Preconditions: + * 0 ≤ eval arg1 < m + * Postconditions: + * eval (from_montgomery out1) mod m = -eval (from_montgomery arg1) mod m + * 0 ≤ eval out1 < m + * + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_opp(fiat_p256_montgomery_domain_field_element out1, const fiat_p256_montgomery_domain_field_element arg1) { + uint64_t x1; + fiat_p256_uint1 x2; + uint64_t x3; + fiat_p256_uint1 x4; + uint64_t x5; + fiat_p256_uint1 x6; + uint64_t x7; + fiat_p256_uint1 x8; + uint64_t x9; + uint64_t x10; + fiat_p256_uint1 x11; + uint64_t x12; + fiat_p256_uint1 x13; + uint64_t x14; + fiat_p256_uint1 x15; + uint64_t x16; + fiat_p256_uint1 x17; + fiat_p256_subborrowx_u64(&x1, &x2, 0x0, 0x0, (arg1[0])); + fiat_p256_subborrowx_u64(&x3, &x4, x2, 0x0, (arg1[1])); + fiat_p256_subborrowx_u64(&x5, &x6, x4, 0x0, (arg1[2])); + fiat_p256_subborrowx_u64(&x7, &x8, x6, 0x0, (arg1[3])); + fiat_p256_cmovznz_u64(&x9, x8, 0x0, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x10, &x11, 0x0, x1, x9); + fiat_p256_addcarryx_u64(&x12, &x13, x11, x3, (x9 & UINT32_C(0xffffffff))); + fiat_p256_addcarryx_u64(&x14, &x15, x13, x5, 0x0); + fiat_p256_addcarryx_u64(&x16, &x17, x15, x7, (x9 & UINT64_C(0xffffffff00000001))); + out1[0] = x10; + out1[1] = x12; + out1[2] = x14; + out1[3] = x16; +} + +/* + * The function fiat_p256_from_montgomery translates a field element out of the Montgomery domain. + * + * Preconditions: + * 0 ≤ eval arg1 < m + * Postconditions: + * eval out1 mod m = (eval arg1 * ((2^64)⁻¹ mod m)^4) mod m + * 0 ≤ eval out1 < m + * + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_from_montgomery(fiat_p256_non_montgomery_domain_field_element out1, const fiat_p256_montgomery_domain_field_element arg1) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + uint64_t x6; + uint64_t x7; + uint64_t x8; + fiat_p256_uint1 x9; + uint64_t x10; + fiat_p256_uint1 x11; + uint64_t x12; + fiat_p256_uint1 x13; + uint64_t x14; + fiat_p256_uint1 x15; + uint64_t x16; + uint64_t x17; + uint64_t x18; + uint64_t x19; + uint64_t x20; + uint64_t x21; + uint64_t x22; + fiat_p256_uint1 x23; + uint64_t x24; + fiat_p256_uint1 x25; + uint64_t x26; + fiat_p256_uint1 x27; + uint64_t x28; + fiat_p256_uint1 x29; + uint64_t x30; + fiat_p256_uint1 x31; + uint64_t x32; + fiat_p256_uint1 x33; + uint64_t x34; + fiat_p256_uint1 x35; + uint64_t x36; + fiat_p256_uint1 x37; + uint64_t x38; + uint64_t x39; + uint64_t x40; + uint64_t x41; + uint64_t x42; + uint64_t x43; + uint64_t x44; + fiat_p256_uint1 x45; + uint64_t x46; + fiat_p256_uint1 x47; + uint64_t x48; + fiat_p256_uint1 x49; + uint64_t x50; + fiat_p256_uint1 x51; + uint64_t x52; + fiat_p256_uint1 x53; + uint64_t x54; + fiat_p256_uint1 x55; + uint64_t x56; + fiat_p256_uint1 x57; + uint64_t x58; + fiat_p256_uint1 x59; + uint64_t x60; + uint64_t x61; + uint64_t x62; + uint64_t x63; + uint64_t x64; + uint64_t x65; + uint64_t x66; + fiat_p256_uint1 x67; + uint64_t x68; + fiat_p256_uint1 x69; + uint64_t x70; + fiat_p256_uint1 x71; + uint64_t x72; + fiat_p256_uint1 x73; + uint64_t x74; + fiat_p256_uint1 x75; + uint64_t x76; + uint64_t x77; + fiat_p256_uint1 x78; + uint64_t x79; + fiat_p256_uint1 x80; + uint64_t x81; + fiat_p256_uint1 x82; + uint64_t x83; + fiat_p256_uint1 x84; + uint64_t x85; + fiat_p256_uint1 x86; + uint64_t x87; + uint64_t x88; + uint64_t x89; + uint64_t x90; + x1 = (arg1[0]); + fiat_p256_mulx_u64(&x2, &x3, x1, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x4, &x5, x1, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x6, &x7, x1, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x8, &x9, 0x0, x7, x4); + fiat_p256_addcarryx_u64(&x10, &x11, 0x0, x1, x6); + fiat_p256_addcarryx_u64(&x12, &x13, x11, 0x0, x8); + fiat_p256_addcarryx_u64(&x14, &x15, 0x0, x12, (arg1[1])); + fiat_p256_mulx_u64(&x16, &x17, x14, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x18, &x19, x14, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x20, &x21, x14, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x22, &x23, 0x0, x21, x18); + fiat_p256_addcarryx_u64(&x24, &x25, 0x0, x14, x20); + fiat_p256_addcarryx_u64(&x26, &x27, x25, (x15 + (x13 + (x9 + x5))), x22); + fiat_p256_addcarryx_u64(&x28, &x29, x27, x2, (x23 + x19)); + fiat_p256_addcarryx_u64(&x30, &x31, x29, x3, x16); + fiat_p256_addcarryx_u64(&x32, &x33, 0x0, x26, (arg1[2])); + fiat_p256_addcarryx_u64(&x34, &x35, x33, x28, 0x0); + fiat_p256_addcarryx_u64(&x36, &x37, x35, x30, 0x0); + fiat_p256_mulx_u64(&x38, &x39, x32, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x40, &x41, x32, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x42, &x43, x32, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x44, &x45, 0x0, x43, x40); + fiat_p256_addcarryx_u64(&x46, &x47, 0x0, x32, x42); + fiat_p256_addcarryx_u64(&x48, &x49, x47, x34, x44); + fiat_p256_addcarryx_u64(&x50, &x51, x49, x36, (x45 + x41)); + fiat_p256_addcarryx_u64(&x52, &x53, x51, (x37 + (x31 + x17)), x38); + fiat_p256_addcarryx_u64(&x54, &x55, 0x0, x48, (arg1[3])); + fiat_p256_addcarryx_u64(&x56, &x57, x55, x50, 0x0); + fiat_p256_addcarryx_u64(&x58, &x59, x57, x52, 0x0); + fiat_p256_mulx_u64(&x60, &x61, x54, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x62, &x63, x54, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x64, &x65, x54, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x66, &x67, 0x0, x65, x62); + fiat_p256_addcarryx_u64(&x68, &x69, 0x0, x54, x64); + fiat_p256_addcarryx_u64(&x70, &x71, x69, x56, x66); + fiat_p256_addcarryx_u64(&x72, &x73, x71, x58, (x67 + x63)); + fiat_p256_addcarryx_u64(&x74, &x75, x73, (x59 + (x53 + x39)), x60); + x76 = (x75 + x61); + fiat_p256_subborrowx_u64(&x77, &x78, 0x0, x70, UINT64_C(0xffffffffffffffff)); + fiat_p256_subborrowx_u64(&x79, &x80, x78, x72, UINT32_C(0xffffffff)); + fiat_p256_subborrowx_u64(&x81, &x82, x80, x74, 0x0); + fiat_p256_subborrowx_u64(&x83, &x84, x82, x76, UINT64_C(0xffffffff00000001)); + fiat_p256_subborrowx_u64(&x85, &x86, x84, 0x0, 0x0); + fiat_p256_cmovznz_u64(&x87, x86, x77, x70); + fiat_p256_cmovznz_u64(&x88, x86, x79, x72); + fiat_p256_cmovznz_u64(&x89, x86, x81, x74); + fiat_p256_cmovznz_u64(&x90, x86, x83, x76); + out1[0] = x87; + out1[1] = x88; + out1[2] = x89; + out1[3] = x90; +} + +/* + * The function fiat_p256_to_montgomery translates a field element into the Montgomery domain. + * + * Preconditions: + * 0 ≤ eval arg1 < m + * Postconditions: + * eval (from_montgomery out1) mod m = eval arg1 mod m + * 0 ≤ eval out1 < m + * + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_to_montgomery(fiat_p256_montgomery_domain_field_element out1, const fiat_p256_non_montgomery_domain_field_element arg1) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + uint64_t x6; + uint64_t x7; + uint64_t x8; + uint64_t x9; + uint64_t x10; + uint64_t x11; + uint64_t x12; + uint64_t x13; + fiat_p256_uint1 x14; + uint64_t x15; + fiat_p256_uint1 x16; + uint64_t x17; + fiat_p256_uint1 x18; + uint64_t x19; + uint64_t x20; + uint64_t x21; + uint64_t x22; + uint64_t x23; + uint64_t x24; + uint64_t x25; + fiat_p256_uint1 x26; + uint64_t x27; + fiat_p256_uint1 x28; + uint64_t x29; + fiat_p256_uint1 x30; + uint64_t x31; + fiat_p256_uint1 x32; + uint64_t x33; + fiat_p256_uint1 x34; + uint64_t x35; + fiat_p256_uint1 x36; + uint64_t x37; + uint64_t x38; + uint64_t x39; + uint64_t x40; + uint64_t x41; + uint64_t x42; + uint64_t x43; + uint64_t x44; + uint64_t x45; + fiat_p256_uint1 x46; + uint64_t x47; + fiat_p256_uint1 x48; + uint64_t x49; + fiat_p256_uint1 x50; + uint64_t x51; + fiat_p256_uint1 x52; + uint64_t x53; + fiat_p256_uint1 x54; + uint64_t x55; + fiat_p256_uint1 x56; + uint64_t x57; + fiat_p256_uint1 x58; + uint64_t x59; + uint64_t x60; + uint64_t x61; + uint64_t x62; + uint64_t x63; + uint64_t x64; + uint64_t x65; + fiat_p256_uint1 x66; + uint64_t x67; + fiat_p256_uint1 x68; + uint64_t x69; + fiat_p256_uint1 x70; + uint64_t x71; + fiat_p256_uint1 x72; + uint64_t x73; + fiat_p256_uint1 x74; + uint64_t x75; + fiat_p256_uint1 x76; + uint64_t x77; + uint64_t x78; + uint64_t x79; + uint64_t x80; + uint64_t x81; + uint64_t x82; + uint64_t x83; + uint64_t x84; + uint64_t x85; + fiat_p256_uint1 x86; + uint64_t x87; + fiat_p256_uint1 x88; + uint64_t x89; + fiat_p256_uint1 x90; + uint64_t x91; + fiat_p256_uint1 x92; + uint64_t x93; + fiat_p256_uint1 x94; + uint64_t x95; + fiat_p256_uint1 x96; + uint64_t x97; + fiat_p256_uint1 x98; + uint64_t x99; + uint64_t x100; + uint64_t x101; + uint64_t x102; + uint64_t x103; + uint64_t x104; + uint64_t x105; + fiat_p256_uint1 x106; + uint64_t x107; + fiat_p256_uint1 x108; + uint64_t x109; + fiat_p256_uint1 x110; + uint64_t x111; + fiat_p256_uint1 x112; + uint64_t x113; + fiat_p256_uint1 x114; + uint64_t x115; + fiat_p256_uint1 x116; + uint64_t x117; + uint64_t x118; + uint64_t x119; + uint64_t x120; + uint64_t x121; + uint64_t x122; + uint64_t x123; + uint64_t x124; + uint64_t x125; + fiat_p256_uint1 x126; + uint64_t x127; + fiat_p256_uint1 x128; + uint64_t x129; + fiat_p256_uint1 x130; + uint64_t x131; + fiat_p256_uint1 x132; + uint64_t x133; + fiat_p256_uint1 x134; + uint64_t x135; + fiat_p256_uint1 x136; + uint64_t x137; + fiat_p256_uint1 x138; + uint64_t x139; + uint64_t x140; + uint64_t x141; + uint64_t x142; + uint64_t x143; + uint64_t x144; + uint64_t x145; + fiat_p256_uint1 x146; + uint64_t x147; + fiat_p256_uint1 x148; + uint64_t x149; + fiat_p256_uint1 x150; + uint64_t x151; + fiat_p256_uint1 x152; + uint64_t x153; + fiat_p256_uint1 x154; + uint64_t x155; + fiat_p256_uint1 x156; + uint64_t x157; + fiat_p256_uint1 x158; + uint64_t x159; + fiat_p256_uint1 x160; + uint64_t x161; + fiat_p256_uint1 x162; + uint64_t x163; + fiat_p256_uint1 x164; + uint64_t x165; + fiat_p256_uint1 x166; + uint64_t x167; + uint64_t x168; + uint64_t x169; + uint64_t x170; + x1 = (arg1[1]); + x2 = (arg1[2]); + x3 = (arg1[3]); + x4 = (arg1[0]); + fiat_p256_mulx_u64(&x5, &x6, x4, UINT64_C(0x4fffffffd)); + fiat_p256_mulx_u64(&x7, &x8, x4, UINT64_C(0xfffffffffffffffe)); + fiat_p256_mulx_u64(&x9, &x10, x4, UINT64_C(0xfffffffbffffffff)); + fiat_p256_mulx_u64(&x11, &x12, x4, 0x3); + fiat_p256_addcarryx_u64(&x13, &x14, 0x0, x12, x9); + fiat_p256_addcarryx_u64(&x15, &x16, x14, x10, x7); + fiat_p256_addcarryx_u64(&x17, &x18, x16, x8, x5); + fiat_p256_mulx_u64(&x19, &x20, x11, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x21, &x22, x11, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x23, &x24, x11, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x25, &x26, 0x0, x24, x21); + fiat_p256_addcarryx_u64(&x27, &x28, 0x0, x11, x23); + fiat_p256_addcarryx_u64(&x29, &x30, x28, x13, x25); + fiat_p256_addcarryx_u64(&x31, &x32, x30, x15, (x26 + x22)); + fiat_p256_addcarryx_u64(&x33, &x34, x32, x17, x19); + fiat_p256_addcarryx_u64(&x35, &x36, x34, (x18 + x6), x20); + fiat_p256_mulx_u64(&x37, &x38, x1, UINT64_C(0x4fffffffd)); + fiat_p256_mulx_u64(&x39, &x40, x1, UINT64_C(0xfffffffffffffffe)); + fiat_p256_mulx_u64(&x41, &x42, x1, UINT64_C(0xfffffffbffffffff)); + fiat_p256_mulx_u64(&x43, &x44, x1, 0x3); + fiat_p256_addcarryx_u64(&x45, &x46, 0x0, x44, x41); + fiat_p256_addcarryx_u64(&x47, &x48, x46, x42, x39); + fiat_p256_addcarryx_u64(&x49, &x50, x48, x40, x37); + fiat_p256_addcarryx_u64(&x51, &x52, 0x0, x29, x43); + fiat_p256_addcarryx_u64(&x53, &x54, x52, x31, x45); + fiat_p256_addcarryx_u64(&x55, &x56, x54, x33, x47); + fiat_p256_addcarryx_u64(&x57, &x58, x56, x35, x49); + fiat_p256_mulx_u64(&x59, &x60, x51, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x61, &x62, x51, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x63, &x64, x51, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x65, &x66, 0x0, x64, x61); + fiat_p256_addcarryx_u64(&x67, &x68, 0x0, x51, x63); + fiat_p256_addcarryx_u64(&x69, &x70, x68, x53, x65); + fiat_p256_addcarryx_u64(&x71, &x72, x70, x55, (x66 + x62)); + fiat_p256_addcarryx_u64(&x73, &x74, x72, x57, x59); + fiat_p256_addcarryx_u64(&x75, &x76, x74, (((uint64_t)x58 + x36) + (x50 + x38)), x60); + fiat_p256_mulx_u64(&x77, &x78, x2, UINT64_C(0x4fffffffd)); + fiat_p256_mulx_u64(&x79, &x80, x2, UINT64_C(0xfffffffffffffffe)); + fiat_p256_mulx_u64(&x81, &x82, x2, UINT64_C(0xfffffffbffffffff)); + fiat_p256_mulx_u64(&x83, &x84, x2, 0x3); + fiat_p256_addcarryx_u64(&x85, &x86, 0x0, x84, x81); + fiat_p256_addcarryx_u64(&x87, &x88, x86, x82, x79); + fiat_p256_addcarryx_u64(&x89, &x90, x88, x80, x77); + fiat_p256_addcarryx_u64(&x91, &x92, 0x0, x69, x83); + fiat_p256_addcarryx_u64(&x93, &x94, x92, x71, x85); + fiat_p256_addcarryx_u64(&x95, &x96, x94, x73, x87); + fiat_p256_addcarryx_u64(&x97, &x98, x96, x75, x89); + fiat_p256_mulx_u64(&x99, &x100, x91, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x101, &x102, x91, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x103, &x104, x91, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x105, &x106, 0x0, x104, x101); + fiat_p256_addcarryx_u64(&x107, &x108, 0x0, x91, x103); + fiat_p256_addcarryx_u64(&x109, &x110, x108, x93, x105); + fiat_p256_addcarryx_u64(&x111, &x112, x110, x95, (x106 + x102)); + fiat_p256_addcarryx_u64(&x113, &x114, x112, x97, x99); + fiat_p256_addcarryx_u64(&x115, &x116, x114, (((uint64_t)x98 + x76) + (x90 + x78)), x100); + fiat_p256_mulx_u64(&x117, &x118, x3, UINT64_C(0x4fffffffd)); + fiat_p256_mulx_u64(&x119, &x120, x3, UINT64_C(0xfffffffffffffffe)); + fiat_p256_mulx_u64(&x121, &x122, x3, UINT64_C(0xfffffffbffffffff)); + fiat_p256_mulx_u64(&x123, &x124, x3, 0x3); + fiat_p256_addcarryx_u64(&x125, &x126, 0x0, x124, x121); + fiat_p256_addcarryx_u64(&x127, &x128, x126, x122, x119); + fiat_p256_addcarryx_u64(&x129, &x130, x128, x120, x117); + fiat_p256_addcarryx_u64(&x131, &x132, 0x0, x109, x123); + fiat_p256_addcarryx_u64(&x133, &x134, x132, x111, x125); + fiat_p256_addcarryx_u64(&x135, &x136, x134, x113, x127); + fiat_p256_addcarryx_u64(&x137, &x138, x136, x115, x129); + fiat_p256_mulx_u64(&x139, &x140, x131, UINT64_C(0xffffffff00000001)); + fiat_p256_mulx_u64(&x141, &x142, x131, UINT32_C(0xffffffff)); + fiat_p256_mulx_u64(&x143, &x144, x131, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x145, &x146, 0x0, x144, x141); + fiat_p256_addcarryx_u64(&x147, &x148, 0x0, x131, x143); + fiat_p256_addcarryx_u64(&x149, &x150, x148, x133, x145); + fiat_p256_addcarryx_u64(&x151, &x152, x150, x135, (x146 + x142)); + fiat_p256_addcarryx_u64(&x153, &x154, x152, x137, x139); + fiat_p256_addcarryx_u64(&x155, &x156, x154, (((uint64_t)x138 + x116) + (x130 + x118)), x140); + fiat_p256_subborrowx_u64(&x157, &x158, 0x0, x149, UINT64_C(0xffffffffffffffff)); + fiat_p256_subborrowx_u64(&x159, &x160, x158, x151, UINT32_C(0xffffffff)); + fiat_p256_subborrowx_u64(&x161, &x162, x160, x153, 0x0); + fiat_p256_subborrowx_u64(&x163, &x164, x162, x155, UINT64_C(0xffffffff00000001)); + fiat_p256_subborrowx_u64(&x165, &x166, x164, x156, 0x0); + fiat_p256_cmovznz_u64(&x167, x166, x157, x149); + fiat_p256_cmovznz_u64(&x168, x166, x159, x151); + fiat_p256_cmovznz_u64(&x169, x166, x161, x153); + fiat_p256_cmovznz_u64(&x170, x166, x163, x155); + out1[0] = x167; + out1[1] = x168; + out1[2] = x169; + out1[3] = x170; +} + +/* + * The function fiat_p256_nonzero outputs a single non-zero word if the input is non-zero and zero otherwise. + * + * Preconditions: + * 0 ≤ eval arg1 < m + * Postconditions: + * out1 = 0 ↔ eval (from_montgomery arg1) mod m = 0 + * + * Input Bounds: + * arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_nonzero(uint64_t* out1, const uint64_t arg1[4]) { + uint64_t x1; + x1 = ((arg1[0]) | ((arg1[1]) | ((arg1[2]) | (arg1[3])))); + *out1 = x1; +} + +/* + * The function fiat_p256_selectznz is a multi-limb conditional select. + * + * Postconditions: + * out1 = (if arg1 = 0 then arg2 else arg3) + * + * Input Bounds: + * arg1: [0x0 ~> 0x1] + * arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * arg3: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * Output Bounds: + * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_selectznz(uint64_t out1[4], fiat_p256_uint1 arg1, const uint64_t arg2[4], const uint64_t arg3[4]) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + fiat_p256_cmovznz_u64(&x1, arg1, (arg2[0]), (arg3[0])); + fiat_p256_cmovznz_u64(&x2, arg1, (arg2[1]), (arg3[1])); + fiat_p256_cmovznz_u64(&x3, arg1, (arg2[2]), (arg3[2])); + fiat_p256_cmovznz_u64(&x4, arg1, (arg2[3]), (arg3[3])); + out1[0] = x1; + out1[1] = x2; + out1[2] = x3; + out1[3] = x4; +} + +/* + * The function fiat_p256_to_bytes serializes a field element NOT in the Montgomery domain to bytes in little-endian order. + * + * Preconditions: + * 0 ≤ eval arg1 < m + * Postconditions: + * out1 = map (λ x, ⌊((eval arg1 mod m) mod 2^(8 * (x + 1))) / 2^(8 * x)⌋) [0..31] + * + * Input Bounds: + * arg1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * Output Bounds: + * out1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff]] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_to_bytes(uint8_t out1[32], const uint64_t arg1[4]) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint8_t x5; + uint64_t x6; + uint8_t x7; + uint64_t x8; + uint8_t x9; + uint64_t x10; + uint8_t x11; + uint64_t x12; + uint8_t x13; + uint64_t x14; + uint8_t x15; + uint64_t x16; + uint8_t x17; + uint8_t x18; + uint8_t x19; + uint64_t x20; + uint8_t x21; + uint64_t x22; + uint8_t x23; + uint64_t x24; + uint8_t x25; + uint64_t x26; + uint8_t x27; + uint64_t x28; + uint8_t x29; + uint64_t x30; + uint8_t x31; + uint8_t x32; + uint8_t x33; + uint64_t x34; + uint8_t x35; + uint64_t x36; + uint8_t x37; + uint64_t x38; + uint8_t x39; + uint64_t x40; + uint8_t x41; + uint64_t x42; + uint8_t x43; + uint64_t x44; + uint8_t x45; + uint8_t x46; + uint8_t x47; + uint64_t x48; + uint8_t x49; + uint64_t x50; + uint8_t x51; + uint64_t x52; + uint8_t x53; + uint64_t x54; + uint8_t x55; + uint64_t x56; + uint8_t x57; + uint64_t x58; + uint8_t x59; + uint8_t x60; + x1 = (arg1[3]); + x2 = (arg1[2]); + x3 = (arg1[1]); + x4 = (arg1[0]); + x5 = (uint8_t)(x4 & UINT8_C(0xff)); + x6 = (x4 >> 8); + x7 = (uint8_t)(x6 & UINT8_C(0xff)); + x8 = (x6 >> 8); + x9 = (uint8_t)(x8 & UINT8_C(0xff)); + x10 = (x8 >> 8); + x11 = (uint8_t)(x10 & UINT8_C(0xff)); + x12 = (x10 >> 8); + x13 = (uint8_t)(x12 & UINT8_C(0xff)); + x14 = (x12 >> 8); + x15 = (uint8_t)(x14 & UINT8_C(0xff)); + x16 = (x14 >> 8); + x17 = (uint8_t)(x16 & UINT8_C(0xff)); + x18 = (uint8_t)(x16 >> 8); + x19 = (uint8_t)(x3 & UINT8_C(0xff)); + x20 = (x3 >> 8); + x21 = (uint8_t)(x20 & UINT8_C(0xff)); + x22 = (x20 >> 8); + x23 = (uint8_t)(x22 & UINT8_C(0xff)); + x24 = (x22 >> 8); + x25 = (uint8_t)(x24 & UINT8_C(0xff)); + x26 = (x24 >> 8); + x27 = (uint8_t)(x26 & UINT8_C(0xff)); + x28 = (x26 >> 8); + x29 = (uint8_t)(x28 & UINT8_C(0xff)); + x30 = (x28 >> 8); + x31 = (uint8_t)(x30 & UINT8_C(0xff)); + x32 = (uint8_t)(x30 >> 8); + x33 = (uint8_t)(x2 & UINT8_C(0xff)); + x34 = (x2 >> 8); + x35 = (uint8_t)(x34 & UINT8_C(0xff)); + x36 = (x34 >> 8); + x37 = (uint8_t)(x36 & UINT8_C(0xff)); + x38 = (x36 >> 8); + x39 = (uint8_t)(x38 & UINT8_C(0xff)); + x40 = (x38 >> 8); + x41 = (uint8_t)(x40 & UINT8_C(0xff)); + x42 = (x40 >> 8); + x43 = (uint8_t)(x42 & UINT8_C(0xff)); + x44 = (x42 >> 8); + x45 = (uint8_t)(x44 & UINT8_C(0xff)); + x46 = (uint8_t)(x44 >> 8); + x47 = (uint8_t)(x1 & UINT8_C(0xff)); + x48 = (x1 >> 8); + x49 = (uint8_t)(x48 & UINT8_C(0xff)); + x50 = (x48 >> 8); + x51 = (uint8_t)(x50 & UINT8_C(0xff)); + x52 = (x50 >> 8); + x53 = (uint8_t)(x52 & UINT8_C(0xff)); + x54 = (x52 >> 8); + x55 = (uint8_t)(x54 & UINT8_C(0xff)); + x56 = (x54 >> 8); + x57 = (uint8_t)(x56 & UINT8_C(0xff)); + x58 = (x56 >> 8); + x59 = (uint8_t)(x58 & UINT8_C(0xff)); + x60 = (uint8_t)(x58 >> 8); + out1[0] = x5; + out1[1] = x7; + out1[2] = x9; + out1[3] = x11; + out1[4] = x13; + out1[5] = x15; + out1[6] = x17; + out1[7] = x18; + out1[8] = x19; + out1[9] = x21; + out1[10] = x23; + out1[11] = x25; + out1[12] = x27; + out1[13] = x29; + out1[14] = x31; + out1[15] = x32; + out1[16] = x33; + out1[17] = x35; + out1[18] = x37; + out1[19] = x39; + out1[20] = x41; + out1[21] = x43; + out1[22] = x45; + out1[23] = x46; + out1[24] = x47; + out1[25] = x49; + out1[26] = x51; + out1[27] = x53; + out1[28] = x55; + out1[29] = x57; + out1[30] = x59; + out1[31] = x60; +} + +/* + * The function fiat_p256_from_bytes deserializes a field element NOT in the Montgomery domain from bytes in little-endian order. + * + * Preconditions: + * 0 ≤ bytes_eval arg1 < m + * Postconditions: + * eval out1 mod m = bytes_eval arg1 mod m + * 0 ≤ eval out1 < m + * + * Input Bounds: + * arg1: [[0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff], [0x0 ~> 0xff]] + * Output Bounds: + * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_from_bytes(uint64_t out1[4], const uint8_t arg1[32]) { + uint64_t x1; + uint64_t x2; + uint64_t x3; + uint64_t x4; + uint64_t x5; + uint64_t x6; + uint64_t x7; + uint8_t x8; + uint64_t x9; + uint64_t x10; + uint64_t x11; + uint64_t x12; + uint64_t x13; + uint64_t x14; + uint64_t x15; + uint8_t x16; + uint64_t x17; + uint64_t x18; + uint64_t x19; + uint64_t x20; + uint64_t x21; + uint64_t x22; + uint64_t x23; + uint8_t x24; + uint64_t x25; + uint64_t x26; + uint64_t x27; + uint64_t x28; + uint64_t x29; + uint64_t x30; + uint64_t x31; + uint8_t x32; + uint64_t x33; + uint64_t x34; + uint64_t x35; + uint64_t x36; + uint64_t x37; + uint64_t x38; + uint64_t x39; + uint64_t x40; + uint64_t x41; + uint64_t x42; + uint64_t x43; + uint64_t x44; + uint64_t x45; + uint64_t x46; + uint64_t x47; + uint64_t x48; + uint64_t x49; + uint64_t x50; + uint64_t x51; + uint64_t x52; + uint64_t x53; + uint64_t x54; + uint64_t x55; + uint64_t x56; + uint64_t x57; + uint64_t x58; + uint64_t x59; + uint64_t x60; + x1 = ((uint64_t)(arg1[31]) << 56); + x2 = ((uint64_t)(arg1[30]) << 48); + x3 = ((uint64_t)(arg1[29]) << 40); + x4 = ((uint64_t)(arg1[28]) << 32); + x5 = ((uint64_t)(arg1[27]) << 24); + x6 = ((uint64_t)(arg1[26]) << 16); + x7 = ((uint64_t)(arg1[25]) << 8); + x8 = (arg1[24]); + x9 = ((uint64_t)(arg1[23]) << 56); + x10 = ((uint64_t)(arg1[22]) << 48); + x11 = ((uint64_t)(arg1[21]) << 40); + x12 = ((uint64_t)(arg1[20]) << 32); + x13 = ((uint64_t)(arg1[19]) << 24); + x14 = ((uint64_t)(arg1[18]) << 16); + x15 = ((uint64_t)(arg1[17]) << 8); + x16 = (arg1[16]); + x17 = ((uint64_t)(arg1[15]) << 56); + x18 = ((uint64_t)(arg1[14]) << 48); + x19 = ((uint64_t)(arg1[13]) << 40); + x20 = ((uint64_t)(arg1[12]) << 32); + x21 = ((uint64_t)(arg1[11]) << 24); + x22 = ((uint64_t)(arg1[10]) << 16); + x23 = ((uint64_t)(arg1[9]) << 8); + x24 = (arg1[8]); + x25 = ((uint64_t)(arg1[7]) << 56); + x26 = ((uint64_t)(arg1[6]) << 48); + x27 = ((uint64_t)(arg1[5]) << 40); + x28 = ((uint64_t)(arg1[4]) << 32); + x29 = ((uint64_t)(arg1[3]) << 24); + x30 = ((uint64_t)(arg1[2]) << 16); + x31 = ((uint64_t)(arg1[1]) << 8); + x32 = (arg1[0]); + x33 = (x31 + (uint64_t)x32); + x34 = (x30 + x33); + x35 = (x29 + x34); + x36 = (x28 + x35); + x37 = (x27 + x36); + x38 = (x26 + x37); + x39 = (x25 + x38); + x40 = (x23 + (uint64_t)x24); + x41 = (x22 + x40); + x42 = (x21 + x41); + x43 = (x20 + x42); + x44 = (x19 + x43); + x45 = (x18 + x44); + x46 = (x17 + x45); + x47 = (x15 + (uint64_t)x16); + x48 = (x14 + x47); + x49 = (x13 + x48); + x50 = (x12 + x49); + x51 = (x11 + x50); + x52 = (x10 + x51); + x53 = (x9 + x52); + x54 = (x7 + (uint64_t)x8); + x55 = (x6 + x54); + x56 = (x5 + x55); + x57 = (x4 + x56); + x58 = (x3 + x57); + x59 = (x2 + x58); + x60 = (x1 + x59); + out1[0] = x39; + out1[1] = x46; + out1[2] = x53; + out1[3] = x60; +} + +/* + * The function fiat_p256_set_one returns the field element one in the Montgomery domain. + * + * Postconditions: + * eval (from_montgomery out1) mod m = 1 mod m + * 0 ≤ eval out1 < m + * + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_set_one(fiat_p256_montgomery_domain_field_element out1) { + out1[0] = 0x1; + out1[1] = UINT64_C(0xffffffff00000000); + out1[2] = UINT64_C(0xffffffffffffffff); + out1[3] = UINT32_C(0xfffffffe); +} + +/* + * The function fiat_p256_msat returns the saturated representation of the prime modulus. + * + * Postconditions: + * twos_complement_eval out1 = m + * 0 ≤ eval out1 < m + * + * Output Bounds: + * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_msat(uint64_t out1[5]) { + out1[0] = UINT64_C(0xffffffffffffffff); + out1[1] = UINT32_C(0xffffffff); + out1[2] = 0x0; + out1[3] = UINT64_C(0xffffffff00000001); + out1[4] = 0x0; +} + +/* + * The function fiat_p256_divstep computes a divstep. + * + * Preconditions: + * 0 ≤ eval arg4 < m + * 0 ≤ eval arg5 < m + * Postconditions: + * out1 = (if 0 < arg1 ∧ (twos_complement_eval arg3) is odd then 1 - arg1 else 1 + arg1) + * twos_complement_eval out2 = (if 0 < arg1 ∧ (twos_complement_eval arg3) is odd then twos_complement_eval arg3 else twos_complement_eval arg2) + * twos_complement_eval out3 = (if 0 < arg1 ∧ (twos_complement_eval arg3) is odd then ⌊(twos_complement_eval arg3 - twos_complement_eval arg2) / 2⌋ else ⌊(twos_complement_eval arg3 + (twos_complement_eval arg3 mod 2) * twos_complement_eval arg2) / 2⌋) + * eval (from_montgomery out4) mod m = (if 0 < arg1 ∧ (twos_complement_eval arg3) is odd then (2 * eval (from_montgomery arg5)) mod m else (2 * eval (from_montgomery arg4)) mod m) + * eval (from_montgomery out5) mod m = (if 0 < arg1 ∧ (twos_complement_eval arg3) is odd then (eval (from_montgomery arg4) - eval (from_montgomery arg4)) mod m else (eval (from_montgomery arg5) + (twos_complement_eval arg3 mod 2) * eval (from_montgomery arg4)) mod m) + * 0 ≤ eval out5 < m + * 0 ≤ eval out5 < m + * 0 ≤ eval out2 < m + * 0 ≤ eval out3 < m + * + * Input Bounds: + * arg1: [0x0 ~> 0xffffffffffffffff] + * arg2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * arg3: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * arg4: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * arg5: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * Output Bounds: + * out1: [0x0 ~> 0xffffffffffffffff] + * out2: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * out3: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * out4: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + * out5: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_divstep(uint64_t* out1, uint64_t out2[5], uint64_t out3[5], uint64_t out4[4], uint64_t out5[4], uint64_t arg1, const uint64_t arg2[5], const uint64_t arg3[5], const uint64_t arg4[4], const uint64_t arg5[4]) { + uint64_t x1; + fiat_p256_uint1 x2; + fiat_p256_uint1 x3; + uint64_t x4; + fiat_p256_uint1 x5; + uint64_t x6; + uint64_t x7; + uint64_t x8; + uint64_t x9; + uint64_t x10; + uint64_t x11; + uint64_t x12; + fiat_p256_uint1 x13; + uint64_t x14; + fiat_p256_uint1 x15; + uint64_t x16; + fiat_p256_uint1 x17; + uint64_t x18; + fiat_p256_uint1 x19; + uint64_t x20; + fiat_p256_uint1 x21; + uint64_t x22; + uint64_t x23; + uint64_t x24; + uint64_t x25; + uint64_t x26; + uint64_t x27; + uint64_t x28; + uint64_t x29; + uint64_t x30; + uint64_t x31; + fiat_p256_uint1 x32; + uint64_t x33; + fiat_p256_uint1 x34; + uint64_t x35; + fiat_p256_uint1 x36; + uint64_t x37; + fiat_p256_uint1 x38; + uint64_t x39; + fiat_p256_uint1 x40; + uint64_t x41; + fiat_p256_uint1 x42; + uint64_t x43; + fiat_p256_uint1 x44; + uint64_t x45; + fiat_p256_uint1 x46; + uint64_t x47; + fiat_p256_uint1 x48; + uint64_t x49; + uint64_t x50; + uint64_t x51; + uint64_t x52; + uint64_t x53; + fiat_p256_uint1 x54; + uint64_t x55; + fiat_p256_uint1 x56; + uint64_t x57; + fiat_p256_uint1 x58; + uint64_t x59; + fiat_p256_uint1 x60; + uint64_t x61; + uint64_t x62; + fiat_p256_uint1 x63; + uint64_t x64; + fiat_p256_uint1 x65; + uint64_t x66; + fiat_p256_uint1 x67; + uint64_t x68; + fiat_p256_uint1 x69; + uint64_t x70; + uint64_t x71; + uint64_t x72; + uint64_t x73; + fiat_p256_uint1 x74; + uint64_t x75; + uint64_t x76; + uint64_t x77; + uint64_t x78; + uint64_t x79; + uint64_t x80; + fiat_p256_uint1 x81; + uint64_t x82; + fiat_p256_uint1 x83; + uint64_t x84; + fiat_p256_uint1 x85; + uint64_t x86; + fiat_p256_uint1 x87; + uint64_t x88; + fiat_p256_uint1 x89; + uint64_t x90; + uint64_t x91; + uint64_t x92; + uint64_t x93; + uint64_t x94; + fiat_p256_uint1 x95; + uint64_t x96; + fiat_p256_uint1 x97; + uint64_t x98; + fiat_p256_uint1 x99; + uint64_t x100; + fiat_p256_uint1 x101; + uint64_t x102; + fiat_p256_uint1 x103; + uint64_t x104; + fiat_p256_uint1 x105; + uint64_t x106; + fiat_p256_uint1 x107; + uint64_t x108; + fiat_p256_uint1 x109; + uint64_t x110; + fiat_p256_uint1 x111; + uint64_t x112; + fiat_p256_uint1 x113; + uint64_t x114; + uint64_t x115; + uint64_t x116; + uint64_t x117; + uint64_t x118; + uint64_t x119; + uint64_t x120; + uint64_t x121; + uint64_t x122; + uint64_t x123; + uint64_t x124; + uint64_t x125; + uint64_t x126; + fiat_p256_addcarryx_u64(&x1, &x2, 0x0, (~arg1), 0x1); + x3 = (fiat_p256_uint1)((fiat_p256_uint1)(x1 >> 63) & (fiat_p256_uint1)((arg3[0]) & 0x1)); + fiat_p256_addcarryx_u64(&x4, &x5, 0x0, (~arg1), 0x1); + fiat_p256_cmovznz_u64(&x6, x3, arg1, x4); + fiat_p256_cmovznz_u64(&x7, x3, (arg2[0]), (arg3[0])); + fiat_p256_cmovznz_u64(&x8, x3, (arg2[1]), (arg3[1])); + fiat_p256_cmovznz_u64(&x9, x3, (arg2[2]), (arg3[2])); + fiat_p256_cmovznz_u64(&x10, x3, (arg2[3]), (arg3[3])); + fiat_p256_cmovznz_u64(&x11, x3, (arg2[4]), (arg3[4])); + fiat_p256_addcarryx_u64(&x12, &x13, 0x0, 0x1, (~(arg2[0]))); + fiat_p256_addcarryx_u64(&x14, &x15, x13, 0x0, (~(arg2[1]))); + fiat_p256_addcarryx_u64(&x16, &x17, x15, 0x0, (~(arg2[2]))); + fiat_p256_addcarryx_u64(&x18, &x19, x17, 0x0, (~(arg2[3]))); + fiat_p256_addcarryx_u64(&x20, &x21, x19, 0x0, (~(arg2[4]))); + fiat_p256_cmovznz_u64(&x22, x3, (arg3[0]), x12); + fiat_p256_cmovznz_u64(&x23, x3, (arg3[1]), x14); + fiat_p256_cmovznz_u64(&x24, x3, (arg3[2]), x16); + fiat_p256_cmovznz_u64(&x25, x3, (arg3[3]), x18); + fiat_p256_cmovznz_u64(&x26, x3, (arg3[4]), x20); + fiat_p256_cmovznz_u64(&x27, x3, (arg4[0]), (arg5[0])); + fiat_p256_cmovznz_u64(&x28, x3, (arg4[1]), (arg5[1])); + fiat_p256_cmovznz_u64(&x29, x3, (arg4[2]), (arg5[2])); + fiat_p256_cmovznz_u64(&x30, x3, (arg4[3]), (arg5[3])); + fiat_p256_addcarryx_u64(&x31, &x32, 0x0, x27, x27); + fiat_p256_addcarryx_u64(&x33, &x34, x32, x28, x28); + fiat_p256_addcarryx_u64(&x35, &x36, x34, x29, x29); + fiat_p256_addcarryx_u64(&x37, &x38, x36, x30, x30); + fiat_p256_subborrowx_u64(&x39, &x40, 0x0, x31, UINT64_C(0xffffffffffffffff)); + fiat_p256_subborrowx_u64(&x41, &x42, x40, x33, UINT32_C(0xffffffff)); + fiat_p256_subborrowx_u64(&x43, &x44, x42, x35, 0x0); + fiat_p256_subborrowx_u64(&x45, &x46, x44, x37, UINT64_C(0xffffffff00000001)); + fiat_p256_subborrowx_u64(&x47, &x48, x46, x38, 0x0); + x49 = (arg4[3]); + x50 = (arg4[2]); + x51 = (arg4[1]); + x52 = (arg4[0]); + fiat_p256_subborrowx_u64(&x53, &x54, 0x0, 0x0, x52); + fiat_p256_subborrowx_u64(&x55, &x56, x54, 0x0, x51); + fiat_p256_subborrowx_u64(&x57, &x58, x56, 0x0, x50); + fiat_p256_subborrowx_u64(&x59, &x60, x58, 0x0, x49); + fiat_p256_cmovznz_u64(&x61, x60, 0x0, UINT64_C(0xffffffffffffffff)); + fiat_p256_addcarryx_u64(&x62, &x63, 0x0, x53, x61); + fiat_p256_addcarryx_u64(&x64, &x65, x63, x55, (x61 & UINT32_C(0xffffffff))); + fiat_p256_addcarryx_u64(&x66, &x67, x65, x57, 0x0); + fiat_p256_addcarryx_u64(&x68, &x69, x67, x59, (x61 & UINT64_C(0xffffffff00000001))); + fiat_p256_cmovznz_u64(&x70, x3, (arg5[0]), x62); + fiat_p256_cmovznz_u64(&x71, x3, (arg5[1]), x64); + fiat_p256_cmovznz_u64(&x72, x3, (arg5[2]), x66); + fiat_p256_cmovznz_u64(&x73, x3, (arg5[3]), x68); + x74 = (fiat_p256_uint1)(x22 & 0x1); + fiat_p256_cmovznz_u64(&x75, x74, 0x0, x7); + fiat_p256_cmovznz_u64(&x76, x74, 0x0, x8); + fiat_p256_cmovznz_u64(&x77, x74, 0x0, x9); + fiat_p256_cmovznz_u64(&x78, x74, 0x0, x10); + fiat_p256_cmovznz_u64(&x79, x74, 0x0, x11); + fiat_p256_addcarryx_u64(&x80, &x81, 0x0, x22, x75); + fiat_p256_addcarryx_u64(&x82, &x83, x81, x23, x76); + fiat_p256_addcarryx_u64(&x84, &x85, x83, x24, x77); + fiat_p256_addcarryx_u64(&x86, &x87, x85, x25, x78); + fiat_p256_addcarryx_u64(&x88, &x89, x87, x26, x79); + fiat_p256_cmovznz_u64(&x90, x74, 0x0, x27); + fiat_p256_cmovznz_u64(&x91, x74, 0x0, x28); + fiat_p256_cmovznz_u64(&x92, x74, 0x0, x29); + fiat_p256_cmovznz_u64(&x93, x74, 0x0, x30); + fiat_p256_addcarryx_u64(&x94, &x95, 0x0, x70, x90); + fiat_p256_addcarryx_u64(&x96, &x97, x95, x71, x91); + fiat_p256_addcarryx_u64(&x98, &x99, x97, x72, x92); + fiat_p256_addcarryx_u64(&x100, &x101, x99, x73, x93); + fiat_p256_subborrowx_u64(&x102, &x103, 0x0, x94, UINT64_C(0xffffffffffffffff)); + fiat_p256_subborrowx_u64(&x104, &x105, x103, x96, UINT32_C(0xffffffff)); + fiat_p256_subborrowx_u64(&x106, &x107, x105, x98, 0x0); + fiat_p256_subborrowx_u64(&x108, &x109, x107, x100, UINT64_C(0xffffffff00000001)); + fiat_p256_subborrowx_u64(&x110, &x111, x109, x101, 0x0); + fiat_p256_addcarryx_u64(&x112, &x113, 0x0, x6, 0x1); + x114 = ((x80 >> 1) | ((x82 << 63) & UINT64_C(0xffffffffffffffff))); + x115 = ((x82 >> 1) | ((x84 << 63) & UINT64_C(0xffffffffffffffff))); + x116 = ((x84 >> 1) | ((x86 << 63) & UINT64_C(0xffffffffffffffff))); + x117 = ((x86 >> 1) | ((x88 << 63) & UINT64_C(0xffffffffffffffff))); + x118 = ((x88 & UINT64_C(0x8000000000000000)) | (x88 >> 1)); + fiat_p256_cmovznz_u64(&x119, x48, x39, x31); + fiat_p256_cmovznz_u64(&x120, x48, x41, x33); + fiat_p256_cmovznz_u64(&x121, x48, x43, x35); + fiat_p256_cmovznz_u64(&x122, x48, x45, x37); + fiat_p256_cmovznz_u64(&x123, x111, x102, x94); + fiat_p256_cmovznz_u64(&x124, x111, x104, x96); + fiat_p256_cmovznz_u64(&x125, x111, x106, x98); + fiat_p256_cmovznz_u64(&x126, x111, x108, x100); + *out1 = x112; + out2[0] = x7; + out2[1] = x8; + out2[2] = x9; + out2[3] = x10; + out2[4] = x11; + out3[0] = x114; + out3[1] = x115; + out3[2] = x116; + out3[3] = x117; + out3[4] = x118; + out4[0] = x119; + out4[1] = x120; + out4[2] = x121; + out4[3] = x122; + out5[0] = x123; + out5[1] = x124; + out5[2] = x125; + out5[3] = x126; +} + +/* + * The function fiat_p256_divstep_precomp returns the precomputed value for Bernstein-Yang-inversion (in montgomery form). + * + * Postconditions: + * eval (from_montgomery out1) = ⌊(m - 1) / 2⌋^(if ⌊log2 m⌋ + 1 < 46 then ⌊(49 * (⌊log2 m⌋ + 1) + 80) / 17⌋ else ⌊(49 * (⌊log2 m⌋ + 1) + 57) / 17⌋) + * 0 ≤ eval out1 < m + * + * Output Bounds: + * out1: [[0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff], [0x0 ~> 0xffffffffffffffff]] + */ +static FIAT_P256_FIAT_INLINE void fiat_p256_divstep_precomp(uint64_t out1[4]) { + out1[0] = UINT64_C(0x67ffffffb8000000); + out1[1] = UINT64_C(0xc000000038000000); + out1[2] = UINT64_C(0xd80000007fffffff); + out1[3] = UINT64_C(0x2fffffffffffffff); +} diff --git a/http/vendor/rustls-pki-types/.cargo-checksum.json b/http/vendor/rustls-pki-types/.cargo-checksum.json new file mode 100644 index 0000000..2e6ce35 --- /dev/null +++ b/http/vendor/rustls-pki-types/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{".cargo_vcs_info.json":"3f67e74fc67c7eea3be685c43c54ce9444db0db7e681d746025963f7e8a94905","Cargo.lock":"59fdc41d493ef26fa2626a23f959d23d3ffe8108a664f82334fa1808820b6168","Cargo.toml":"79e1a79e27aef58f9482c8a27c915e7b3d75c9444444e514184367aba1a8fb4e","Cargo.toml.orig":"704eac6cbb8bfa3d641e90c601ddf9b7fc1f749be710547c7bba20164b85efdf","LICENSE-APACHE":"45fd05c4865e7c350b98ad7ac50e1b15462d49af4a91e9b0c9dd933dc9a69742","LICENSE-MIT":"9117d922e667125508dde62b02c1f57ed22f5ad21eb536aa2e2d99e1c796e639","README.md":"52ab92f5b204b89f9ad02b778ca2b6ad6d32c7f94916e1917dae4e95569d0b92","src/alg_id.rs":"16ad8158a1d9ac992262ba0dd6c63dcefa64930de4d1c0ce229d7e78ce7ad8b3","src/base64.rs":"b72362a35405bde9709ff31e6e96689d19f2bc593c0ee08f5e9f452d8d647479","src/data/README.md":"a20436d042d01819b65817bde6872147da740ac726016bdd6121a3f773b8ceb3","src/data/alg-ecdsa-p256.der":"431ab0da5859f972141d7a6b17bfff1006ec2465878890eecacf4764748f999a","src/data/alg-ecdsa-p256k1.der":"00905fc68a9ba09041e71c6f12869f8e9d4cb3adfd90d8439f540e7ccf516dcd","src/data/alg-ecdsa-p384.der":"a6307e2efeff1b4db45622b626b9a0f2b6395be5dd4024a899c057e512a0207e","src/data/alg-ecdsa-p521.der":"1fe6d1f888400adc8b5775a63d1e2738246eec45c36bf0cd3060eb1c420b4cc2","src/data/alg-ecdsa-sha256.der":"8748ad98184c8f81b5db874ef1b7d3599afe05e2f92dac215a77f45e9b0699bc","src/data/alg-ecdsa-sha384.der":"5f6e0dc69f6930ca890ebcafaf7677254640b931439cd5bcad7688b1a06aaf92","src/data/alg-ecdsa-sha512.der":"c09d17b3609dc0987bc81b2b990f9a461697aea0258fb565501da4f2c8caf6f0","src/data/alg-ed25519.der":"0b6d661fe75a1ce7a832d515b39b504032f1a6cbb67a5113fa74d635d038f4d9","src/data/alg-ed448.der":"173f629fc725926a0af1bff26907a3850e19e9a2763fa7f3bea3f2ff8319a2f0","src/data/alg-ml-dsa-44.der":"cc050f14a811907c1c1186ce00447580344e379ff7679ab7359beefbeeac5c13","src/data/alg-ml-dsa-65.der":"f7ab8e2df130b24fed009839ca3f961ebbcbe3a567e591c2354fe397f849f861","src/data/alg-ml-dsa-87.der":"2a3fe7ce00d5707ae6ec5d310dd648050599a94b27baa02f6daac72b9cf553a0","src/data/alg-rsa-encryption.der":"7bc023427767a2f2e156f8ae030d06d19f862e326b952116649b423c3ff7110e","src/data/alg-rsa-pkcs1-sha256.der":"c0d1c5108d05adfdf58c73697af5c4e644d1a09fb2e4a76361c048eb0ec7a219","src/data/alg-rsa-pkcs1-sha384.der":"d3e50513620bac7e02f5c1821c569cf4fc2ca5a891fd1103e36574c77e6a888a","src/data/alg-rsa-pkcs1-sha512.der":"3705399877ad5d5bb559e5b5ed3cd80b352166511c2fd2b8f8959e1176ed72f8","src/data/alg-rsa-pss-sha256.der":"6eeb65499d8c64c3ef3e74305f2daaca0d947e7fca735ad072b5581392d73068","src/data/alg-rsa-pss-sha384.der":"b6e27adae679feb8f49925f4457da316657a6b7a55a1bfd164c66eec59d7d090","src/data/alg-rsa-pss-sha512.der":"60cea04c0dcb23c248eb644fe036d1b6b883004f73c68785895c885c8fa5d688","src/lib.rs":"6eb21656ce495593f1e108a112bced740ad895bfc39c66542caca8ca0293d248","src/pem.rs":"b0fbf1416f09894808cb058fdb05989bb9ca2364e288c9c6a7c20c18d15d3051","src/server_name.rs":"87ae29a98c974bad006e71a0dba41d8b764615c97dc7855f65c3adf954ad81f1"},"package":"30a7197ae7eb376e574fe940d068c30fe0462554a3ddbe4eca7838e049c937a9"} \ No newline at end of file diff --git a/http/vendor/rustls-pki-types/.cargo_vcs_info.json b/http/vendor/rustls-pki-types/.cargo_vcs_info.json new file mode 100644 index 0000000..dad1488 --- /dev/null +++ b/http/vendor/rustls-pki-types/.cargo_vcs_info.json @@ -0,0 +1,6 @@ +{ + "git": { + "sha1": "bb3c1da0e69e8ee3dcdfb16c245f974d636ed481" + }, + "path_in_vcs": "" +} \ No newline at end of file diff --git a/http/vendor/rustls-pki-types/Cargo.lock b/http/vendor/rustls-pki-types/Cargo.lock new file mode 100644 index 0000000..e75593a --- /dev/null +++ b/http/vendor/rustls-pki-types/Cargo.lock @@ -0,0 +1,195 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "bumpalo" +version = "3.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" + +[[package]] +name = "cc" +version = "1.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fcb57c740ae1daf453ae85f16e37396f672b039e00d9d866e07ddb24e328e3a" +dependencies = [ + "jobserver", + "libc", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "crabgrind" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdbd43e4f32a9681a504577db2d4ea7d3f7b1bf2e97955561af98501ab600508" +dependencies = [ + "cc", +] + +[[package]] +name = "jobserver" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" +dependencies = [ + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "libc" +version = "0.2.171" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" + +[[package]] +name = "log" +version = "0.4.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" + +[[package]] +name = "once_cell" +version = "1.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc" + +[[package]] +name = "proc-macro2" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rustls-pki-types" +version = "1.14.1" +dependencies = [ + "crabgrind", + "web-time", + "zeroize", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "syn" +version = "2.0.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" + +[[package]] +name = "wasm-bindgen" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" +dependencies = [ + "cfg-if", + "once_cell", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" +dependencies = [ + "bumpalo", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" diff --git a/http/vendor/rustls-pki-types/Cargo.toml b/http/vendor/rustls-pki-types/Cargo.toml new file mode 100644 index 0000000..8344353 --- /dev/null +++ b/http/vendor/rustls-pki-types/Cargo.toml @@ -0,0 +1,86 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies. +# +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. + +[package] +edition = "2021" +rust-version = "1.60" +name = "rustls-pki-types" +version = "1.14.1" +build = false +include = [ + "Cargo.toml", + "LICENSE-APACHE", + "LICENSE-MIT", + "src/**/*.rs", + "README.md", + "src/data/*.der", +] +autolib = false +autobins = false +autoexamples = false +autotests = false +autobenches = false +description = "Shared types for the rustls PKI ecosystem" +homepage = "https://github.com/rustls/pki-types" +documentation = "https://docs.rs/rustls-pki-types" +readme = "README.md" +categories = [ + "network-programming", + "data-structures", + "cryptography", +] +license = "MIT OR Apache-2.0" +repository = "https://github.com/rustls/pki-types" + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = [ + "--cfg", + "rustls_pki_types_docsrs", +] + +[package.metadata.cargo_check_external_types] +allowed_external_types = ["zeroize::Zeroize"] + +[features] +alloc = ["dep:zeroize"] +default = ["alloc"] +std = ["alloc"] +web = ["web-time"] + +[lib] +name = "rustls_pki_types" +path = "src/lib.rs" + +[dependencies.zeroize] +version = "1" +optional = true + +[target.'cfg(all(target_family = "wasm", target_os = "unknown"))'.dependencies.web-time] +version = "1" +optional = true + +[target.'cfg(all(target_os = "linux", target_arch = "x86_64"))'.dev-dependencies.crabgrind] +version = "=0.1.9" + +[lints.rust] +elided_lifetimes_in_paths = "warn" +trivial_numeric_casts = "warn" +unnameable_types = "warn" +unreachable_pub = "warn" +unused_extern_crates = "warn" +unused_import_braces = "warn" +unused_qualifications = "warn" + +[lints.rust.unexpected_cfgs] +level = "warn" +priority = 0 +check-cfg = ["cfg(rustls_pki_types_docsrs)"] diff --git a/http/vendor/rustls-pki-types/Cargo.toml.orig b/http/vendor/rustls-pki-types/Cargo.toml.orig new file mode 100644 index 0000000..b6d43d6 --- /dev/null +++ b/http/vendor/rustls-pki-types/Cargo.toml.orig @@ -0,0 +1,53 @@ +[package] +name = "rustls-pki-types" +version = "1.14.1" +edition = "2021" +rust-version = "1.60" +license = "MIT OR Apache-2.0" +description = "Shared types for the rustls PKI ecosystem" +documentation = "https://docs.rs/rustls-pki-types" +homepage = "https://github.com/rustls/pki-types" +repository = "https://github.com/rustls/pki-types" +categories = ["network-programming", "data-structures", "cryptography"] +include = ["Cargo.toml", "LICENSE-APACHE", "LICENSE-MIT", "src/**/*.rs", "README.md", "src/data/*.der"] + +[features] +default = ["alloc"] +alloc = ["dep:zeroize"] +std = ["alloc"] +web = ["web-time"] + +[dependencies] +zeroize = { version = "1", optional = true } + +[target.'cfg(all(target_os = "linux", target_arch = "x86_64"))'.dev-dependencies] +crabgrind = "=0.1.9" # compatible with valgrind package on GHA ubuntu-latest + +[target.'cfg(all(target_family = "wasm", target_os = "unknown"))'.dependencies] +web-time = { version = "1", optional = true } + +[lints.rust] +elided_lifetimes_in_paths = "warn" +trivial_numeric_casts = "warn" +unexpected_cfgs = { level = "warn", check-cfg = ["cfg(rustls_pki_types_docsrs)"] } +unnameable_types = "warn" +unreachable_pub = "warn" +unused_extern_crates = "warn" +unused_import_braces = "warn" +unused_qualifications = "warn" + +[workspace.lints.clippy] +alloc_instead_of_core = "warn" +cloned_instead_of_copied = "warn" +manual_let_else = "warn" +or_fun_call = "warn" +std_instead_of_core = "warn" +upper_case_acronyms = "warn" +use_self = "warn" + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "rustls_pki_types_docsrs"] + +[package.metadata.cargo_check_external_types] +allowed_external_types = ["zeroize::Zeroize"] diff --git a/http/vendor/rustls-pki-types/LICENSE-APACHE b/http/vendor/rustls-pki-types/LICENSE-APACHE new file mode 100644 index 0000000..5449729 --- /dev/null +++ b/http/vendor/rustls-pki-types/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright 2023 Dirkjan Ochtman + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/http/vendor/rustls-pki-types/LICENSE-MIT b/http/vendor/rustls-pki-types/LICENSE-MIT new file mode 100644 index 0000000..f8cdbfd --- /dev/null +++ b/http/vendor/rustls-pki-types/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2023 Dirkjan Ochtman + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/http/vendor/rustls-pki-types/README.md b/http/vendor/rustls-pki-types/README.md new file mode 100644 index 0000000..8bda0c7 --- /dev/null +++ b/http/vendor/rustls-pki-types/README.md @@ -0,0 +1,53 @@ +# rustls-pki-types + +[![Build Status](https://github.com/rustls/pki-types/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/rustls/pki-types/actions/workflows/ci.yml?query=branch%3Amain) +[![Documentation](https://docs.rs/rustls-pki-types/badge.svg)](https://docs.rs/rustls-pki-types/) +[![Chat](https://img.shields.io/discord/976380008299917365?logo=discord)](https://discord.gg/MCSB76RU96) + +This crate provides types for representing X.509 certificates, keys and other types as commonly +used in the rustls ecosystem. It is intended to be used by crates that need to work with such X.509 +types, such as [rustls](https://crates.io/crates/rustls), +[rustls-webpki](https://crates.io/crates/rustls-webpki), +and others. + +Some of these crates used to define their own trivial wrappers around DER-encoded bytes. +However, in order to avoid inconvenient dependency edges, these were all disconnected. By +using a common low-level crate of types with long-term stable API, we hope to avoid the +downsides of unnecessary dependency edges while providing interoperability between crates. + +## Features + +- Interoperability between different crates in the rustls ecosystem +- Long-term stable API +- No dependencies +- Support for `no_std` contexts, with optional support for `alloc` + +## DER and PEM + +Many of the types defined in this crate represent DER-encoded data. DER is a binary encoding of +the ASN.1 format commonly used in web PKI specifications. It is a binary encoding, so it is +relatively compact when stored in memory. However, as a binary format, it is not very easy to +work with for humans and in contexts where binary data is inconvenient. For this reason, +many tools and protocols use a ASCII-based encoding of DER, called PEM. In addition to the +base64-encoded DER, PEM objects are delimited by header and footer lines which indicate the type +of object contained in the PEM blob. + +This crate's types can be created from both DER and PEM encodings. + +## Creating new certificates and keys + +This crate does not provide any functionality for creating new certificates or keys. However, +the [rcgen](https://docs.rs/rcgen) crate can be used to create new certificates and keys. + +## Cloning private keys + +This crate intentionally **does not** implement `Clone` on private key types in +order to minimize the exposure of private key data in memory. + +If you want to extend the lifetime of a `PrivateKeyDer<'_>`, consider [`PrivateKeyDer::clone_key()`]. +Alternatively since these types are immutable, consider wrapping the `PrivateKeyDer<'_>` in a [`Rc`] +or an [`Arc`]. + +[`Rc`]: https://doc.rust-lang.org/std/rc/struct.Rc.html +[`Arc`]: https://doc.rust-lang.org/std/sync/struct.Arc.html +[`PrivateKeyDer::clone_key()`]: https://docs.rs/rustls-pki-types/latest/rustls_pki_types/enum.PrivateKeyDer.html#method.clone_key diff --git a/http/vendor/rustls-pki-types/src/alg_id.rs b/http/vendor/rustls-pki-types/src/alg_id.rs new file mode 100644 index 0000000..b11e97b --- /dev/null +++ b/http/vendor/rustls-pki-types/src/alg_id.rs @@ -0,0 +1,395 @@ +//! The PKIX [`AlgorithmIdentifier`] type, and common values. +//! +//! If you need to use an [`AlgorithmIdentifier`] not defined here, +//! you can define it locally. + +use core::fmt; +use core::ops::Deref; + +// See src/data/README.md. + +/// AlgorithmIdentifier for `id-ml-dsa-44`. +/// +/// This is: +/// +/// ```text +/// OBJECT_IDENTIFIER { 2.16.840.1.101.3.4.3.17 } +/// ``` +/// +/// +pub const ML_DSA_44: AlgorithmIdentifier = + AlgorithmIdentifier::from_slice(include_bytes!("data/alg-ml-dsa-44.der")); + +/// AlgorithmIdentifier for `id-ml-dsa-65`. +/// +/// This is: +/// +/// ```text +/// OBJECT_IDENTIFIER { 2.16.840.1.101.3.4.3.18 } +/// ``` +/// +/// +pub const ML_DSA_65: AlgorithmIdentifier = + AlgorithmIdentifier::from_slice(include_bytes!("data/alg-ml-dsa-65.der")); + +/// AlgorithmIdentifier for `id-ml-dsa-87`. +/// +/// This is: +/// +/// ```text +/// OBJECT_IDENTIFIER { 2.16.840.1.101.3.4.3.19 } +/// ``` +/// +/// +pub const ML_DSA_87: AlgorithmIdentifier = + AlgorithmIdentifier::from_slice(include_bytes!("data/alg-ml-dsa-87.der")); + +/// AlgorithmIdentifier for `id-ecPublicKey` with named curve `secp256k1`. +/// +/// This is: +/// +/// ```text +/// # ecPublicKey +/// OBJECT_IDENTIFIER { 1.2.840.10045.2.1 } +/// # secp256k1 +/// OBJECT_IDENTIFIER { 1.3.132.0.10 } +/// ``` +pub const ECDSA_P256K1: AlgorithmIdentifier = + AlgorithmIdentifier::from_slice(include_bytes!("data/alg-ecdsa-p256k1.der")); + +/// AlgorithmIdentifier for `id-ecPublicKey` with named curve `secp256r1`. +/// +/// This is: +/// +/// ```text +/// # ecPublicKey +/// OBJECT_IDENTIFIER { 1.2.840.10045.2.1 } +/// # secp256r1 +/// OBJECT_IDENTIFIER { 1.2.840.10045.3.1.7 } +/// ``` +pub const ECDSA_P256: AlgorithmIdentifier = + AlgorithmIdentifier::from_slice(include_bytes!("data/alg-ecdsa-p256.der")); + +/// AlgorithmIdentifier for `id-ecPublicKey` with named curve `secp384r1`. +/// +/// This is: +/// +/// ```text +/// # ecPublicKey +/// OBJECT_IDENTIFIER { 1.2.840.10045.2.1 } +/// # secp384r1 +/// OBJECT_IDENTIFIER { 1.3.132.0.34 } +/// ``` +pub const ECDSA_P384: AlgorithmIdentifier = + AlgorithmIdentifier::from_slice(include_bytes!("data/alg-ecdsa-p384.der")); + +/// AlgorithmIdentifier for `id-ecPublicKey` with named curve `secp521r1`. +/// +/// This is: +/// +/// ```text +/// # ecPublicKey +/// OBJECT_IDENTIFIER { 1.2.840.10045.2.1 } +/// # secp521r1 +/// OBJECT_IDENTIFIER { 1.3.132.0.35 } +/// ``` +pub const ECDSA_P521: AlgorithmIdentifier = + AlgorithmIdentifier::from_slice(include_bytes!("data/alg-ecdsa-p521.der")); + +/// AlgorithmIdentifier for `ecdsa-with-SHA256`. +/// +/// This is: +/// +/// ```text +/// # ecdsa-with-SHA256 +/// OBJECT_IDENTIFIER { 1.2.840.10045.4.3.2 } +/// ``` +pub const ECDSA_SHA256: AlgorithmIdentifier = + AlgorithmIdentifier::from_slice(include_bytes!("data/alg-ecdsa-sha256.der")); + +/// AlgorithmIdentifier for `ecdsa-with-SHA384`. +/// +/// This is: +/// +/// ```text +/// # ecdsa-with-SHA384 +/// OBJECT_IDENTIFIER { 1.2.840.10045.4.3.3 } +/// ``` +pub const ECDSA_SHA384: AlgorithmIdentifier = + AlgorithmIdentifier::from_slice(include_bytes!("data/alg-ecdsa-sha384.der")); + +/// AlgorithmIdentifier for `ecdsa-with-SHA512`. +/// +/// This is: +/// +/// ```text +/// # ecdsa-with-SHA512 +/// OBJECT_IDENTIFIER { 1.2.840.10045.4.3.4 } +/// ``` +pub const ECDSA_SHA512: AlgorithmIdentifier = + AlgorithmIdentifier::from_slice(include_bytes!("data/alg-ecdsa-sha512.der")); + +/// AlgorithmIdentifier for `rsaEncryption`. +/// +/// This is: +/// +/// ```text +/// # rsaEncryption +/// OBJECT_IDENTIFIER { 1.2.840.113549.1.1.1 } +/// NULL {} +/// ``` +pub const RSA_ENCRYPTION: AlgorithmIdentifier = + AlgorithmIdentifier::from_slice(include_bytes!("data/alg-rsa-encryption.der")); + +/// AlgorithmIdentifier for `sha256WithRSAEncryption`. +/// +/// This is: +/// +/// ```text +/// # sha256WithRSAEncryption +/// OBJECT_IDENTIFIER { 1.2.840.113549.1.1.11 } +/// NULL {} +/// ``` +pub const RSA_PKCS1_SHA256: AlgorithmIdentifier = + AlgorithmIdentifier::from_slice(include_bytes!("data/alg-rsa-pkcs1-sha256.der")); + +/// AlgorithmIdentifier for `sha384WithRSAEncryption`. +/// +/// This is: +/// +/// ```text +/// # sha384WithRSAEncryption +/// OBJECT_IDENTIFIER { 1.2.840.113549.1.1.12 } +/// NULL {} +/// ``` +pub const RSA_PKCS1_SHA384: AlgorithmIdentifier = + AlgorithmIdentifier::from_slice(include_bytes!("data/alg-rsa-pkcs1-sha384.der")); + +/// AlgorithmIdentifier for `sha512WithRSAEncryption`. +/// +/// This is: +/// +/// ```text +/// # sha512WithRSAEncryption +/// OBJECT_IDENTIFIER { 1.2.840.113549.1.1.13 } +/// NULL {} +/// ``` +pub const RSA_PKCS1_SHA512: AlgorithmIdentifier = + AlgorithmIdentifier::from_slice(include_bytes!("data/alg-rsa-pkcs1-sha512.der")); + +/// AlgorithmIdentifier for `rsassaPss` with: +/// +/// - hashAlgorithm: sha256 +/// - maskGenAlgorithm: mgf1 with sha256 +/// - saltLength: 32 +/// +/// This is: +/// +/// ```text +/// # rsassa-pss +/// OBJECT_IDENTIFIER { 1.2.840.113549.1.1.10 } +/// SEQUENCE { +/// # hashAlgorithm: +/// [0] { +/// SEQUENCE { +/// # sha256 +/// OBJECT_IDENTIFIER { 2.16.840.1.101.3.4.2.1 } +/// NULL {} +/// } +/// } +/// # maskGenAlgorithm: +/// [1] { +/// SEQUENCE { +/// # mgf1 +/// OBJECT_IDENTIFIER { 1.2.840.113549.1.1.8 } +/// SEQUENCE { +/// # sha256 +/// OBJECT_IDENTIFIER { 2.16.840.1.101.3.4.2.1 } +/// NULL {} +/// } +/// } +/// } +/// # saltLength: +/// [2] { +/// INTEGER { 32 } +/// } +/// } +/// ``` +/// +/// See for +/// the meaning of the context-specific tags. +pub const RSA_PSS_SHA256: AlgorithmIdentifier = + AlgorithmIdentifier::from_slice(include_bytes!("data/alg-rsa-pss-sha256.der")); + +/// AlgorithmIdentifier for `rsassaPss` with: +/// +/// - hashAlgorithm: sha384 +/// - maskGenAlgorithm: mgf1 with sha384 +/// - saltLength: 48 +/// +/// This is: +/// +/// ```text +/// # rsassa-pss +/// OBJECT_IDENTIFIER { 1.2.840.113549.1.1.10 } +/// SEQUENCE { +/// # hashAlgorithm: +/// [0] { +/// SEQUENCE { +/// # sha384 +/// OBJECT_IDENTIFIER { 2.16.840.1.101.3.4.2.2 } +/// NULL {} +/// } +/// } +/// # maskGenAlgorithm: +/// [1] { +/// SEQUENCE { +/// # mgf1 +/// OBJECT_IDENTIFIER { 1.2.840.113549.1.1.8 } +/// SEQUENCE { +/// # sha384 +/// OBJECT_IDENTIFIER { 2.16.840.1.101.3.4.2.2 } +/// NULL {} +/// } +/// } +/// } +/// # saltLength: +/// [2] { +/// INTEGER { 48 } +/// } +/// } +/// ``` +/// +/// See for +/// the meaning of the context-specific tags. +pub const RSA_PSS_SHA384: AlgorithmIdentifier = + AlgorithmIdentifier::from_slice(include_bytes!("data/alg-rsa-pss-sha384.der")); + +/// AlgorithmIdentifier for `rsassaPss` with: +/// +/// - hashAlgorithm: sha512 +/// - maskGenAlgorithm: mgf1 with sha512 +/// - saltLength: 64 +/// +/// This is: +/// +/// ```text +/// # rsassa-pss +/// OBJECT_IDENTIFIER { 1.2.840.113549.1.1.10 } +/// SEQUENCE { +/// # hashAlgorithm: +/// [0] { +/// SEQUENCE { +/// # sha512 +/// OBJECT_IDENTIFIER { 2.16.840.1.101.3.4.2.3 } +/// NULL {} +/// } +/// } +/// # maskGenAlgorithm: +/// [1] { +/// SEQUENCE { +/// # mgf1 +/// OBJECT_IDENTIFIER { 1.2.840.113549.1.1.8 } +/// SEQUENCE { +/// # sha512 +/// OBJECT_IDENTIFIER { 2.16.840.1.101.3.4.2.3 } +/// NULL {} +/// } +/// } +/// } +/// # saltLength: +/// [2] { +/// INTEGER { 64 } +/// } +/// } +/// ``` +/// +/// See for +/// the meaning of the context-specific tags. +pub const RSA_PSS_SHA512: AlgorithmIdentifier = + AlgorithmIdentifier::from_slice(include_bytes!("data/alg-rsa-pss-sha512.der")); + +/// AlgorithmIdentifier for `ED25519`. +/// +/// This is: +/// +/// ```text +/// # ed25519 +/// OBJECT_IDENTIFIER { 1.3.101.112 } +/// ``` +pub const ED25519: AlgorithmIdentifier = + AlgorithmIdentifier::from_slice(include_bytes!("data/alg-ed25519.der")); + +/// AlgorithmIdentifier for `ED448`. +/// +/// This is: +/// +/// ```text +/// # ed448 +/// OBJECT_IDENTIFIER { 1.3.101.113 } +/// ``` +pub const ED448: AlgorithmIdentifier = + AlgorithmIdentifier::from_slice(include_bytes!("data/alg-ed448.der")); + +/// A DER encoding of the PKIX AlgorithmIdentifier type: +/// +/// ```ASN.1 +/// AlgorithmIdentifier ::= SEQUENCE { +/// algorithm OBJECT IDENTIFIER, +/// parameters ANY DEFINED BY algorithm OPTIONAL } +/// -- contains a value of the type +/// -- registered for use with the +/// -- algorithm object identifier value +/// ``` +/// (from ) +/// +/// The outer sequence encoding is *not included*, so this is the DER encoding +/// of an OID for `algorithm` plus the `parameters` value. +/// +/// For example, this is the `rsaEncryption` algorithm (but prefer to use the constant +/// [`RSA_ENCRYPTION`] instead): +/// +/// ``` +/// let rsa_encryption = rustls_pki_types::AlgorithmIdentifier::from_slice( +/// &[ +/// // algorithm: 1.2.840.113549.1.1.1 +/// 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, +/// // parameters: NULL +/// 0x05, 0x00 +/// ] +/// ); +/// assert_eq!(rustls_pki_types::alg_id::RSA_ENCRYPTION, rsa_encryption); +/// ``` +/// +/// Common values for this type are provided in this module. +#[derive(Clone, Copy, PartialEq, Eq)] +pub struct AlgorithmIdentifier(&'static [u8]); + +impl AlgorithmIdentifier { + /// Makes a new `AlgorithmIdentifier` from a static octet slice. + /// + /// This does not validate the contents of the slice. + pub const fn from_slice(bytes: &'static [u8]) -> Self { + Self(bytes) + } +} + +impl AsRef<[u8]> for AlgorithmIdentifier { + fn as_ref(&self) -> &[u8] { + self.0 + } +} + +impl fmt::Debug for AlgorithmIdentifier { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + super::hex(f, self.0) + } +} + +impl Deref for AlgorithmIdentifier { + type Target = [u8]; + + fn deref(&self) -> &Self::Target { + self.as_ref() + } +} diff --git a/http/vendor/rustls-pki-types/src/base64.rs b/http/vendor/rustls-pki-types/src/base64.rs new file mode 100644 index 0000000..e249666 --- /dev/null +++ b/http/vendor/rustls-pki-types/src/base64.rs @@ -0,0 +1,750 @@ +/// Decode base64 `input`, writing the result into `output`. +/// +/// `input` is treated as secret, so efforts are made to avoid +/// leaking its value via side channels, such as timing, +/// memory accesses, and execution trace. +/// +/// The following is deemed non-secret information: +/// +/// - Appearance of whitespace in `input` +/// - Erroneous characters in `input` (indeed, the first illegal +/// character is quoted in the error type) +/// - The length of `input` +/// - The length of `output` +/// +/// Returns the prefix of `output` that was written to. +pub(crate) fn decode_secret<'a>(input: &[u8], output: &'a mut [u8]) -> Result<&'a [u8], Error> { + decode(input, output, CodePoint::decode_secret) +} + +/// Decode base64 `input`, writing the result into `output`. +/// +/// `input` is treated as public information, so its value may +/// be leaked via side channels. +/// +/// Returns the prefix of `output` that was written to. +pub(crate) fn decode_public<'a>(input: &[u8], output: &'a mut [u8]) -> Result<&'a [u8], Error> { + decode(input, output, CodePoint::decode_public) +} + +/// Provide an upper limit on how much space could be required +/// to decode a base64 encoding of len `base64_len`. +pub(crate) const fn decoded_length(base64_len: usize) -> usize { + ((base64_len + 3) / 4) * 3 +} + +fn decode<'a>( + input: &[u8], + output: &'a mut [u8], + decode_byte: impl Fn(u8) -> CodePoint, +) -> Result<&'a [u8], Error> { + let mut buffer = 0u64; + let mut used = 0; + let mut shift = SHIFT_INITIAL; + let mut pad_mask = 0; + + let mut output_offset = 0; + + const SHIFT_INITIAL: i32 = (8 - 1) * 6; + + for byte in input.iter().copied() { + let (item, pad) = match decode_byte(byte) { + CodePoint::WHITESPACE => continue, + CodePoint::INVALID => return Err(Error::InvalidCharacter(byte)), + CodePoint::PAD => (0, 1), + CodePoint(n) => (n, 0), + }; + + // we collect 8 code points (therefore: 6 output bytes) into + // `buffer`. this keeps this loop as tight as possible. + if used == 8 { + if pad_mask != 0b0000_0000 { + return Err(Error::PrematurePadding); + } + + let chunk = output + .get_mut(output_offset..output_offset + 6) + .ok_or(Error::InsufficientOutputSpace)?; + + chunk[0] = (buffer >> 40) as u8; + chunk[1] = (buffer >> 32) as u8; + chunk[2] = (buffer >> 24) as u8; + chunk[3] = (buffer >> 16) as u8; + chunk[4] = (buffer >> 8) as u8; + chunk[5] = buffer as u8; + + output_offset += 6; + buffer = 0; + used = 0; + pad_mask = 0; + shift = SHIFT_INITIAL; + } + + buffer |= (item as u64) << shift; + shift -= 6; + pad_mask |= pad << used; + used += 1; + } + + // reduce to final block + if used > 4 { + if pad_mask & 0b0000_1111 != 0 { + return Err(Error::PrematurePadding); + } + let chunk = output + .get_mut(output_offset..output_offset + 3) + .ok_or(Error::InsufficientOutputSpace)?; + chunk[0] = (buffer >> 40) as u8; + chunk[1] = (buffer >> 32) as u8; + chunk[2] = (buffer >> 24) as u8; + + buffer <<= 24; + pad_mask >>= 4; + used -= 4; + output_offset += 3; + } + + match (used, pad_mask) { + // no trailing bytes + (0, 0b0000) => {} + + // 4 trailing bytes, no padding + (4, 0b0000) => { + let chunk = output + .get_mut(output_offset..output_offset + 3) + .ok_or(Error::InsufficientOutputSpace)?; + chunk[0] = (buffer >> 40) as u8; + chunk[1] = (buffer >> 32) as u8; + chunk[2] = (buffer >> 24) as u8; + output_offset += 3; + } + + // 4 trailing bytes with one padding char, or 3 trailing bytes + (4, 0b1000) | (3, 0b0000) => { + let chunk = output + .get_mut(output_offset..output_offset + 2) + .ok_or(Error::InsufficientOutputSpace)?; + + chunk[0] = (buffer >> 40) as u8; + chunk[1] = (buffer >> 32) as u8; + output_offset += 2; + } + + // 4 trailing bytes with two padding char, or 2 trailing bytes + (4, 0b1100) | (2, 0b0000) => { + let chunk = output + .get_mut(output_offset..output_offset + 1) + .ok_or(Error::InsufficientOutputSpace)?; + chunk[0] = (buffer >> 40) as u8; + output_offset += 1; + } + + // everything else is illegal + _ => return Err(Error::InvalidTrailingPadding), + } + + Ok(&output[..output_offset]) +} + +#[derive(Debug, PartialEq)] +pub(crate) enum Error { + /// Given character is not valid in base64 alphabet. + InvalidCharacter(u8), + + /// A padding character (`=`) appeared outside the final + /// block of 4 characters. + PrematurePadding, + + /// The padding characters at the end of the input were invalid. + InvalidTrailingPadding, + + /// Not enough space in output buffer. + /// + /// Use `decoded_length` to get an upper bound. + InsufficientOutputSpace, +} + +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +struct CodePoint(u8); + +impl CodePoint { + const WHITESPACE: Self = Self(0xf0); + const PAD: Self = Self(0xf1); + const INVALID: Self = Self(0xf2); +} + +impl CodePoint { + /// Side-channel rules: + /// + /// - code paths that produce `CodePoint(n)` must not make + /// `n` observable via a side channel. + /// - other code paths -- whitespace, padding or invalid -- need not, + /// these are not considered secret conditions. + fn decode_secret(b: u8) -> Self { + let is_upper = u8_in_range(b, b'A', b'Z'); + let is_lower = u8_in_range(b, b'a', b'z'); + let is_digit = u8_in_range(b, b'0', b'9'); + let is_plus = u8_equals(b, b'+'); + let is_slash = u8_equals(b, b'/'); + let is_pad = u8_equals(b, b'='); + let is_space = u8_in_range(b, b'\t', b'\r') | u8_equals(b, b' '); + + let is_invalid = !(is_lower | is_upper | is_digit | is_plus | is_slash | is_pad | is_space); + + Self( + (is_upper & b.wrapping_sub(b'A')) + | (is_lower & (b.wrapping_sub(b'a').wrapping_add(26))) + | (is_digit & (b.wrapping_sub(b'0').wrapping_add(52))) + | (is_plus & 62) + | (is_slash & 63) + | (is_space & Self::WHITESPACE.0) + | (is_pad & Self::PAD.0) + | (is_invalid & Self::INVALID.0), + ) + } + + const fn decode_public(a: u8) -> Self { + const TABLE: [CodePoint; 256] = [ + // 0x00..0x0f + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::WHITESPACE, + CodePoint::WHITESPACE, + CodePoint::WHITESPACE, + CodePoint::WHITESPACE, + CodePoint::WHITESPACE, + CodePoint::INVALID, + CodePoint::INVALID, + // 0x10..0x1f + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + // 0x20..0x2f + CodePoint::WHITESPACE, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint(62), + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint(63), + // 0x30..0x3f + CodePoint(52), + CodePoint(53), + CodePoint(54), + CodePoint(55), + CodePoint(56), + CodePoint(57), + CodePoint(58), + CodePoint(59), + CodePoint(60), + CodePoint(61), + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::PAD, + CodePoint::INVALID, + CodePoint::INVALID, + // 0x40..0x4f + CodePoint::INVALID, + CodePoint(0), + CodePoint(1), + CodePoint(2), + CodePoint(3), + CodePoint(4), + CodePoint(5), + CodePoint(6), + CodePoint(7), + CodePoint(8), + CodePoint(9), + CodePoint(10), + CodePoint(11), + CodePoint(12), + CodePoint(13), + CodePoint(14), + // 0x50..0x5f + CodePoint(15), + CodePoint(16), + CodePoint(17), + CodePoint(18), + CodePoint(19), + CodePoint(20), + CodePoint(21), + CodePoint(22), + CodePoint(23), + CodePoint(24), + CodePoint(25), + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + // 0x60..0x6f + CodePoint::INVALID, + CodePoint(26), + CodePoint(27), + CodePoint(28), + CodePoint(29), + CodePoint(30), + CodePoint(31), + CodePoint(32), + CodePoint(33), + CodePoint(34), + CodePoint(35), + CodePoint(36), + CodePoint(37), + CodePoint(38), + CodePoint(39), + CodePoint(40), + // 0x70..0x7f + CodePoint(41), + CodePoint(42), + CodePoint(43), + CodePoint(44), + CodePoint(45), + CodePoint(46), + CodePoint(47), + CodePoint(48), + CodePoint(49), + CodePoint(50), + CodePoint(51), + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + // 0x80..0x8f + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + // 0x90..0x9f + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + // 0xa0..0xaf + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + // 0xb0..0xbf + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + // 0xc0..0xcf + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + // 0xd0..0xdf + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + // 0xe0..0xef + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + // 0xf0..0xff + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + CodePoint::INVALID, + ]; + + TABLE[a as usize] + } +} + +/// Returns 0xff if `a` in `lo..=hi`. +/// +/// lo..=hi must not be 0..=255. Callers in this file have constant +/// `lo` and `hi`, and this function is private to this file. +fn u8_in_range(a: u8, lo: u8, hi: u8) -> u8 { + debug_assert!(lo <= hi); + debug_assert!(hi - lo != 255); + let a = a.wrapping_sub(lo); + u8_less_than(a, (hi - lo).wrapping_add(1)) +} + +/// Returns 0xff if a < b, 0 otherwise. +fn u8_less_than(a: u8, b: u8) -> u8 { + let a = u16::from(a); + let b = u16::from(b); + u8_broadcast16(a.wrapping_sub(b)) +} + +/// Returns 0xff if a == b, 0 otherwise. +const fn u8_equals(a: u8, b: u8) -> u8 { + let diff = a ^ b; + u8_nonzero(diff) +} + +/// Returns 0xff if a != 0, 0 otherwise. +const fn u8_nonzero(x: u8) -> u8 { + u8_broadcast8(!x & x.wrapping_sub(1)) +} + +/// Broadcasts the top bit of `x` +/// +/// In other words, if the top bit of `x` is set, +/// returns 0xff else 0x00. +const fn u8_broadcast8(x: u8) -> u8 { + let msb = x >> 7; + 0u8.wrapping_sub(msb) +} + +/// Broadcasts the top bit of `x` +/// +/// In other words, if the top bit of `x` is set, +/// returns 0xff else 0x00. +const fn u8_broadcast16(x: u16) -> u8 { + let msb = x >> 15; + 0u8.wrapping_sub(msb as u8) +} + +#[cfg(all(test, feature = "alloc"))] +mod tests { + use alloc::vec::Vec; + + use super::*; + + #[test] + fn decode_test() { + assert_eq!( + decode(b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), + b"\x00\x10\x83\x10\x51\x87\x20\x92\x8b\x30\xd3\x8f\x41\x14\x93\x51\x55\x97\ + \x61\x96\x9b\x71\xd7\x9f\x82\x18\xa3\x92\x59\xa7\xa2\x9a\xab\xb2\xdb\xaf\ + \xc3\x1c\xb3\xd3\x5d\xb7\xe3\x9e\xbb\xf3\xdf\xbf" + ); + assert_eq!(decode(b"aGVsbG8="), b"hello"); + assert_eq!(decode(b"aGVsbG8gd29ybGQ="), b"hello world"); + assert_eq!(decode(b"aGVsbG8gd29ybGQh"), b"hello world!"); + assert_eq!(decode(b"////"), b"\xff\xff\xff"); + assert_eq!(decode(b"++++"), b"\xfb\xef\xbe"); + assert_eq!(decode(b"AAAA"), b"\x00\x00\x00"); + assert_eq!(decode(b"AAA="), b"\x00\x00"); + assert_eq!(decode(b"AA=="), b"\x00"); + + // like our previous use of rust-base64, we don't require padding + // if the encoding is otherwise valid given the length + assert_eq!(decode(b"AAA"), b"\x00\x00"); + assert_eq!(decode(b"AA"), b"\x00"); + + assert_eq!(decode(b""), b""); + } + + #[test] + fn decode_errors() { + let mut buf = [0u8; 6]; + + // illegal trailing padding + assert_eq!( + decode_both(b"A===", &mut buf), + Err(Error::InvalidTrailingPadding) + ); + assert_eq!( + decode_both(b"====", &mut buf), + Err(Error::InvalidTrailingPadding) + ); + assert_eq!( + decode_both(b"A==", &mut buf), + Err(Error::InvalidTrailingPadding) + ); + assert_eq!( + decode_both(b"AA=", &mut buf), + Err(Error::InvalidTrailingPadding) + ); + assert_eq!( + decode_both(b"A", &mut buf), + Err(Error::InvalidTrailingPadding) + ); + + // padding before final block + assert_eq!( + decode_both(b"=AAAAA==", &mut buf), + Err(Error::PrematurePadding) + ); + assert_eq!( + decode_both(b"A=AAAA==", &mut buf), + Err(Error::PrematurePadding) + ); + assert_eq!( + decode_both(b"AA=AAA==", &mut buf), + Err(Error::PrematurePadding) + ); + assert_eq!( + decode_both(b"AAA=AA==", &mut buf), + Err(Error::PrematurePadding) + ); + + // illegal inputs + assert_eq!( + decode_both(b"%AAA", &mut buf), + Err(Error::InvalidCharacter(b'%')) + ); + assert_eq!( + decode_both(b"A%AA", &mut buf), + Err(Error::InvalidCharacter(b'%')) + ); + assert_eq!( + decode_both(b"AA%A", &mut buf), + Err(Error::InvalidCharacter(b'%')) + ); + assert_eq!( + decode_both(b"AAA%", &mut buf), + Err(Error::InvalidCharacter(b'%')) + ); + + // output sizing + assert_eq!(decode_both(b"am9lIGJw", &mut [0u8; 7]), Ok(&b"joe bp"[..])); + assert_eq!(decode_both(b"am9lIGJw", &mut [0u8; 6]), Ok(&b"joe bp"[..])); + assert_eq!( + decode_both(b"am9lIGJw", &mut [0u8; 5]), + Err(Error::InsufficientOutputSpace) + ); + assert_eq!( + decode_both(b"am9lIGJw", &mut [0u8; 4]), + Err(Error::InsufficientOutputSpace) + ); + assert_eq!( + decode_both(b"am9lIGJw", &mut [0u8; 3]), + Err(Error::InsufficientOutputSpace) + ); + + // output sizing is not pessimistic when padding is valid + assert_eq!(decode_both(b"am9=", &mut [0u8; 2]), Ok(&b"jo"[..])); + assert_eq!(decode_both(b"am==", &mut [0u8; 1]), Ok(&b"j"[..])); + assert_eq!(decode_both(b"am9", &mut [0u8; 2]), Ok(&b"jo"[..])); + assert_eq!(decode_both(b"am", &mut [0u8; 1]), Ok(&b"j"[..])); + } + + #[test] + fn check_models() { + fn u8_broadcast8_model(x: u8) -> u8 { + match x & 0x80 { + 0x80 => 0xff, + _ => 0x00, + } + } + + fn u8_broadcast16_model(x: u16) -> u8 { + match x & 0x8000 { + 0x8000 => 0xff, + _ => 0x00, + } + } + + fn u8_nonzero_model(x: u8) -> u8 { + match x { + 0 => 0xff, + _ => 0x00, + } + } + + fn u8_equals_model(x: u8, y: u8) -> u8 { + match x == y { + true => 0xff, + false => 0x00, + } + } + + fn u8_in_range_model(x: u8, y: u8, z: u8) -> u8 { + match (y..=z).contains(&x) { + true => 0xff, + false => 0x00, + } + } + + for x in u8::MIN..=u8::MAX { + assert_eq!(u8_broadcast8(x), u8_broadcast8_model(x)); + assert_eq!(u8_nonzero(x), u8_nonzero_model(x)); + assert_eq!(CodePoint::decode_secret(x), CodePoint::decode_public(x)); + + for y in u8::MIN..=u8::MAX { + assert_eq!(u8_equals(x, y), u8_equals_model(x, y)); + + let v = (x as u16) | ((y as u16) << 8); + assert_eq!(u8_broadcast16(v), u8_broadcast16_model(v)); + + for z in y..=u8::MAX { + if z - y == 255 { + continue; + } + assert_eq!(u8_in_range(x, y, z), u8_in_range_model(x, y, z)); + } + } + } + } + + #[cfg(all(feature = "std", target_os = "linux", target_arch = "x86_64"))] + #[test] + fn codepoint_decode_secret_does_not_branch_or_index_on_secret_input() { + // this is using the same theory as + use crabgrind as cg; + + if matches!(cg::run_mode(), cg::RunMode::Native) { + std::println!("SKIPPED: must be run under valgrind"); + return; + } + + let input = [b'a']; + cg::monitor_command(format!( + "make_memory undefined {:p} {}", + input.as_ptr(), + input.len() + )) + .unwrap(); + + core::hint::black_box(CodePoint::decode_secret(input[0])); + } + + #[track_caller] + fn decode(input: &[u8]) -> Vec { + let length = decoded_length(input.len()); + + let mut v = alloc::vec![0u8; length]; + let used = decode_both(input, &mut v).unwrap().len(); + v.truncate(used); + + v + } + + fn decode_both<'a>(input: &'_ [u8], output: &'a mut [u8]) -> Result<&'a [u8], Error> { + let mut output_copy = output.to_vec(); + let r_pub = decode_public(input, &mut output_copy); + + let r_sec = decode_secret(input, output); + + assert_eq!(r_pub, r_sec); + + r_sec + } +} diff --git a/http/vendor/rustls-pki-types/src/data/README.md b/http/vendor/rustls-pki-types/src/data/README.md new file mode 100644 index 0000000..45cf697 --- /dev/null +++ b/http/vendor/rustls-pki-types/src/data/README.md @@ -0,0 +1,21 @@ +These files contain the binary DER encoding of the *values* of some +ASN.1 [`AlgorithmIdentifier`]s, without the outer `SEQUENCE` tag or the outer +length component. + +These files were encoded with the help of [der-ascii]. They can be decoded +using: + +```sh +go install github.com/google/der-ascii/cmd/der2ascii@latest +der2ascii -i -o .ascii +``` + +New or modified der-ascii files can be encoded using: + +```sh +go install github.com/google/der-ascii/cmd/ascii2der@latest +ascii2der i .ascii -o +``` + +[`AlgorithmIdentifier`]: https://tools.ietf.org/html/rfc5280#section-4.1.1.2] +[der-ascii]: https://github.com/google/der-ascii diff --git a/http/vendor/rustls-pki-types/src/data/alg-ecdsa-p256.der b/http/vendor/rustls-pki-types/src/data/alg-ecdsa-p256.der new file mode 100644 index 0000000..d49c30d --- /dev/null +++ b/http/vendor/rustls-pki-types/src/data/alg-ecdsa-p256.der @@ -0,0 +1 @@ +*H=*H= \ No newline at end of file diff --git a/http/vendor/rustls-pki-types/src/data/alg-ecdsa-p256k1.der b/http/vendor/rustls-pki-types/src/data/alg-ecdsa-p256k1.der new file mode 100644 index 0000000..8e910d8 Binary files /dev/null and b/http/vendor/rustls-pki-types/src/data/alg-ecdsa-p256k1.der differ diff --git a/http/vendor/rustls-pki-types/src/data/alg-ecdsa-p384.der b/http/vendor/rustls-pki-types/src/data/alg-ecdsa-p384.der new file mode 100644 index 0000000..8b24916 Binary files /dev/null and b/http/vendor/rustls-pki-types/src/data/alg-ecdsa-p384.der differ diff --git a/http/vendor/rustls-pki-types/src/data/alg-ecdsa-p521.der b/http/vendor/rustls-pki-types/src/data/alg-ecdsa-p521.der new file mode 100644 index 0000000..9ad544c Binary files /dev/null and b/http/vendor/rustls-pki-types/src/data/alg-ecdsa-p521.der differ diff --git a/http/vendor/rustls-pki-types/src/data/alg-ecdsa-sha256.der b/http/vendor/rustls-pki-types/src/data/alg-ecdsa-sha256.der new file mode 100644 index 0000000..b2ee128 --- /dev/null +++ b/http/vendor/rustls-pki-types/src/data/alg-ecdsa-sha256.der @@ -0,0 +1 @@ +*H= \ No newline at end of file diff --git a/http/vendor/rustls-pki-types/src/data/alg-ecdsa-sha384.der b/http/vendor/rustls-pki-types/src/data/alg-ecdsa-sha384.der new file mode 100644 index 0000000..7c61d3a --- /dev/null +++ b/http/vendor/rustls-pki-types/src/data/alg-ecdsa-sha384.der @@ -0,0 +1 @@ +*H= \ No newline at end of file diff --git a/http/vendor/rustls-pki-types/src/data/alg-ecdsa-sha512.der b/http/vendor/rustls-pki-types/src/data/alg-ecdsa-sha512.der new file mode 100644 index 0000000..d87b899 --- /dev/null +++ b/http/vendor/rustls-pki-types/src/data/alg-ecdsa-sha512.der @@ -0,0 +1 @@ +*H= \ No newline at end of file diff --git a/http/vendor/rustls-pki-types/src/data/alg-ed25519.der b/http/vendor/rustls-pki-types/src/data/alg-ed25519.der new file mode 100644 index 0000000..7ca46fd --- /dev/null +++ b/http/vendor/rustls-pki-types/src/data/alg-ed25519.der @@ -0,0 +1 @@ ++ep \ No newline at end of file diff --git a/http/vendor/rustls-pki-types/src/data/alg-ed448.der b/http/vendor/rustls-pki-types/src/data/alg-ed448.der new file mode 100644 index 0000000..81655bb --- /dev/null +++ b/http/vendor/rustls-pki-types/src/data/alg-ed448.der @@ -0,0 +1 @@ ++eq \ No newline at end of file diff --git a/http/vendor/rustls-pki-types/src/data/alg-ml-dsa-44.der b/http/vendor/rustls-pki-types/src/data/alg-ml-dsa-44.der new file mode 100644 index 0000000..d55fb4f --- /dev/null +++ b/http/vendor/rustls-pki-types/src/data/alg-ml-dsa-44.der @@ -0,0 +1 @@ + `He \ No newline at end of file diff --git a/http/vendor/rustls-pki-types/src/data/alg-ml-dsa-65.der b/http/vendor/rustls-pki-types/src/data/alg-ml-dsa-65.der new file mode 100644 index 0000000..846fb54 --- /dev/null +++ b/http/vendor/rustls-pki-types/src/data/alg-ml-dsa-65.der @@ -0,0 +1 @@ + `He \ No newline at end of file diff --git a/http/vendor/rustls-pki-types/src/data/alg-ml-dsa-87.der b/http/vendor/rustls-pki-types/src/data/alg-ml-dsa-87.der new file mode 100644 index 0000000..57faec8 --- /dev/null +++ b/http/vendor/rustls-pki-types/src/data/alg-ml-dsa-87.der @@ -0,0 +1 @@ + `He \ No newline at end of file diff --git a/http/vendor/rustls-pki-types/src/data/alg-rsa-encryption.der b/http/vendor/rustls-pki-types/src/data/alg-rsa-encryption.der new file mode 100644 index 0000000..77d159a Binary files /dev/null and b/http/vendor/rustls-pki-types/src/data/alg-rsa-encryption.der differ diff --git a/http/vendor/rustls-pki-types/src/data/alg-rsa-pkcs1-sha256.der b/http/vendor/rustls-pki-types/src/data/alg-rsa-pkcs1-sha256.der new file mode 100644 index 0000000..ab52bcd Binary files /dev/null and b/http/vendor/rustls-pki-types/src/data/alg-rsa-pkcs1-sha256.der differ diff --git a/http/vendor/rustls-pki-types/src/data/alg-rsa-pkcs1-sha384.der b/http/vendor/rustls-pki-types/src/data/alg-rsa-pkcs1-sha384.der new file mode 100644 index 0000000..c0d43b1 Binary files /dev/null and b/http/vendor/rustls-pki-types/src/data/alg-rsa-pkcs1-sha384.der differ diff --git a/http/vendor/rustls-pki-types/src/data/alg-rsa-pkcs1-sha512.der b/http/vendor/rustls-pki-types/src/data/alg-rsa-pkcs1-sha512.der new file mode 100644 index 0000000..71aded5 Binary files /dev/null and b/http/vendor/rustls-pki-types/src/data/alg-rsa-pkcs1-sha512.der differ diff --git a/http/vendor/rustls-pki-types/src/data/alg-rsa-pss-sha256.der b/http/vendor/rustls-pki-types/src/data/alg-rsa-pss-sha256.der new file mode 100644 index 0000000..87328f7 Binary files /dev/null and b/http/vendor/rustls-pki-types/src/data/alg-rsa-pss-sha256.der differ diff --git a/http/vendor/rustls-pki-types/src/data/alg-rsa-pss-sha384.der b/http/vendor/rustls-pki-types/src/data/alg-rsa-pss-sha384.der new file mode 100644 index 0000000..9c3b170 Binary files /dev/null and b/http/vendor/rustls-pki-types/src/data/alg-rsa-pss-sha384.der differ diff --git a/http/vendor/rustls-pki-types/src/data/alg-rsa-pss-sha512.der b/http/vendor/rustls-pki-types/src/data/alg-rsa-pss-sha512.der new file mode 100644 index 0000000..c0ad57d Binary files /dev/null and b/http/vendor/rustls-pki-types/src/data/alg-rsa-pss-sha512.der differ diff --git a/http/vendor/rustls-pki-types/src/lib.rs b/http/vendor/rustls-pki-types/src/lib.rs new file mode 100644 index 0000000..5284cd9 --- /dev/null +++ b/http/vendor/rustls-pki-types/src/lib.rs @@ -0,0 +1,1156 @@ +//! This crate provides types for representing X.509 certificates, keys and other types as +//! commonly used in the rustls ecosystem. It is intended to be used by crates that need to work +//! with such X.509 types, such as [rustls](https://crates.io/crates/rustls), +//! [rustls-webpki](https://crates.io/crates/rustls-webpki), and others. +//! +//! Some of these crates used to define their own trivial wrappers around DER-encoded bytes. +//! However, in order to avoid inconvenient dependency edges, these were all disconnected. By +//! using a common low-level crate of types with long-term stable API, we hope to avoid the +//! downsides of unnecessary dependency edges while providing good interoperability between crates. +//! +//! ## DER and PEM +//! +//! Many of the types defined in this crate represent DER-encoded data. DER is a binary encoding of +//! the ASN.1 format commonly used in web PKI specifications. It is a binary encoding, so it is +//! relatively compact when stored in memory. However, as a binary format, it is not very easy to +//! work with for humans and in contexts where binary data is inconvenient. For this reason, +//! many tools and protocols use a ASCII-based encoding of DER, called PEM. In addition to the +//! base64-encoded DER, PEM objects are delimited by header and footer lines which indicate the type +//! of object contained in the PEM blob. +//! +//! Types here can be created from: +//! +//! - DER using (for example) [`PrivatePkcs8KeyDer::from()`]. +//! - PEM using (for example) [`pem::PemObject::from_pem_slice()`]. +//! +//! The [`pem::PemObject`] trait contains the full selection of ways to construct +//! these types from PEM encodings. That includes ways to open and read from a file, +//! from a slice, or from an `std::io` stream. +//! +//! There is also a lower-level API that allows a given PEM file to be fully consumed +//! in one pass, even if it contains different data types: see the implementation of +//! the [`pem::PemObject`] trait on the `(pem::SectionKind, Vec)` tuple. +//! +//! ## Creating new certificates and keys +//! +//! This crate does not provide any functionality for creating new certificates or keys. However, +//! the [rcgen](https://docs.rs/rcgen) crate can be used to create new certificates and keys. +//! +//! ## Cloning private keys +//! +//! This crate intentionally **does not** implement `Clone` on private key types in +//! order to minimize the exposure of private key data in memory. +//! +//! If you want to extend the lifetime of a `PrivateKeyDer<'_>`, consider [`PrivateKeyDer::clone_key()`]. +//! Alternatively since these types are immutable, consider wrapping the `PrivateKeyDer<'_>` in a [`Rc`] +//! or an [`Arc`]. +//! +//! [`Rc`]: https://doc.rust-lang.org/std/rc/struct.Rc.html +//! [`Arc`]: https://doc.rust-lang.org/std/sync/struct.Arc.html +//! [`PrivateKeyDer::clone_key()`]: https://docs.rs/rustls-pki-types/latest/rustls_pki_types/enum.PrivateKeyDer.html#method.clone_key +//! +//! ## Target `wasm32-unknown-unknown` with the `web` feature +//! +//! [`std::time::SystemTime`](https://doc.rust-lang.org/std/time/struct.SystemTime.html) +//! is unavailable in `wasm32-unknown-unknown` targets, so calls to +//! [`UnixTime::now()`](https://docs.rs/rustls-pki-types/latest/rustls_pki_types/struct.UnixTime.html#method.now), +//! otherwise enabled by the [`std`](https://docs.rs/crate/rustls-pki-types/latest/features#std) feature, +//! require building instead with the [`web`](https://docs.rs/crate/rustls-pki-types/latest/features#web) +//! feature. It gets time by calling [`Date.now()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now) +//! in the browser. + +#![cfg_attr(not(feature = "std"), no_std)] +#![warn( + missing_docs, + clippy::exhaustive_enums, + clippy::exhaustive_structs, + clippy::use_self +)] +#![cfg_attr(rustls_pki_types_docsrs, feature(doc_cfg))] + +#[cfg(feature = "alloc")] +extern crate alloc; + +#[cfg(feature = "alloc")] +use alloc::vec::Vec; +use core::fmt; +use core::ops::Deref; +use core::time::Duration; +#[cfg(feature = "alloc")] +use pem::{PemObject, PemObjectFilter, SectionKind}; +#[cfg(all( + feature = "std", + not(all(target_family = "wasm", target_os = "unknown")) +))] +use std::time::SystemTime; +#[cfg(all(target_family = "wasm", target_os = "unknown", feature = "web"))] +use web_time::SystemTime; + +pub mod alg_id; +mod base64; +mod server_name; + +/// Low-level PEM decoding APIs. +/// +/// These APIs allow decoding PEM format in an iterator, which means you +/// can load multiple different types of PEM section from a file in a single +/// pass. +#[cfg(feature = "alloc")] +pub mod pem; + +pub use alg_id::AlgorithmIdentifier; +pub use server_name::{ + AddrParseError, DnsName, InvalidDnsNameError, IpAddr, Ipv4Addr, Ipv6Addr, ServerName, +}; + +/// A DER-encoded X.509 private key, in one of several formats +/// +/// See variant inner types for more detailed information. +/// +/// This can load several types of PEM-encoded private key, and then reveal +/// which types were found: +/// +/// ```rust +/// # #[cfg(all(feature = "alloc", feature = "std"))] { +/// use rustls_pki_types::{PrivateKeyDer, pem::PemObject}; +/// +/// // load from a PEM file +/// let pkcs8 = PrivateKeyDer::from_pem_file("tests/data/nistp256key.pkcs8.pem").unwrap(); +/// let pkcs1 = PrivateKeyDer::from_pem_file("tests/data/rsa1024.pkcs1.pem").unwrap(); +/// let sec1 = PrivateKeyDer::from_pem_file("tests/data/nistp256key.pem").unwrap(); +/// assert!(matches!(pkcs8, PrivateKeyDer::Pkcs8(_))); +/// assert!(matches!(pkcs1, PrivateKeyDer::Pkcs1(_))); +/// assert!(matches!(sec1, PrivateKeyDer::Sec1(_))); +/// # } +/// ``` +#[non_exhaustive] +#[derive(Debug, PartialEq, Eq)] +pub enum PrivateKeyDer<'a> { + /// An RSA private key + Pkcs1(PrivatePkcs1KeyDer<'a>), + /// A Sec1 private key + Sec1(PrivateSec1KeyDer<'a>), + /// A PKCS#8 private key + Pkcs8(PrivatePkcs8KeyDer<'a>), +} + +#[cfg(feature = "alloc")] +impl zeroize::Zeroize for PrivateKeyDer<'static> { + fn zeroize(&mut self) { + match self { + Self::Pkcs1(key) => key.zeroize(), + Self::Sec1(key) => key.zeroize(), + Self::Pkcs8(key) => key.zeroize(), + } + } +} + +impl PrivateKeyDer<'_> { + /// Clone the private key to a `'static` value + #[cfg(feature = "alloc")] + pub fn clone_key(&self) -> PrivateKeyDer<'static> { + use PrivateKeyDer::*; + match self { + Pkcs1(key) => Pkcs1(key.clone_key()), + Sec1(key) => Sec1(key.clone_key()), + Pkcs8(key) => Pkcs8(key.clone_key()), + } + } + + /// Yield the DER-encoded bytes of the private key + pub fn secret_der(&self) -> &[u8] { + match self { + PrivateKeyDer::Pkcs1(key) => key.secret_pkcs1_der(), + PrivateKeyDer::Sec1(key) => key.secret_sec1_der(), + PrivateKeyDer::Pkcs8(key) => key.secret_pkcs8_der(), + } + } +} + +#[cfg(feature = "alloc")] +impl PemObject for PrivateKeyDer<'static> { + fn from_pem(kind: SectionKind, value: Vec) -> Option { + match kind { + SectionKind::RsaPrivateKey => Some(Self::Pkcs1(value.into())), + SectionKind::EcPrivateKey => Some(Self::Sec1(value.into())), + SectionKind::PrivateKey => Some(Self::Pkcs8(value.into())), + _ => None, + } + } +} + +impl<'a> From> for PrivateKeyDer<'a> { + fn from(key: PrivatePkcs1KeyDer<'a>) -> Self { + Self::Pkcs1(key) + } +} + +impl<'a> From> for PrivateKeyDer<'a> { + fn from(key: PrivateSec1KeyDer<'a>) -> Self { + Self::Sec1(key) + } +} + +impl<'a> From> for PrivateKeyDer<'a> { + fn from(key: PrivatePkcs8KeyDer<'a>) -> Self { + Self::Pkcs8(key) + } +} + +impl<'a> TryFrom<&'a [u8]> for PrivateKeyDer<'a> { + type Error = &'static str; + + fn try_from(key: &'a [u8]) -> Result { + const SHORT_FORM_LEN_MAX: u8 = 128; + const TAG_SEQUENCE: u8 = 0x30; + const TAG_INTEGER: u8 = 0x02; + + // We expect all key formats to begin with a SEQUENCE, which requires at least 2 bytes + // in the short length encoding. + if key.first() != Some(&TAG_SEQUENCE) || key.len() < 2 { + return Err(INVALID_KEY_DER_ERR); + } + + // The length of the SEQUENCE is encoded in the second byte. We must skip this many bytes. + let skip_len = match key[1] >= SHORT_FORM_LEN_MAX { + // 1 byte for SEQUENCE tag, 1 byte for short-form len + false => 2, + // 1 byte for SEQUENCE tag, 1 byte for start of len, remaining bytes encoded + // in key[1]. + true => 2 + (key[1] - SHORT_FORM_LEN_MAX) as usize, + }; + let key_bytes = key.get(skip_len..).ok_or(INVALID_KEY_DER_ERR)?; + + // PKCS#8 (https://www.rfc-editor.org/rfc/rfc5208) describes the PrivateKeyInfo + // structure as: + // PrivateKeyInfo ::= SEQUENCE { + // version Version, + // privateKeyAlgorithm AlgorithmIdentifier {{PrivateKeyAlgorithms}}, + // privateKey PrivateKey, + // attributes [0] Attributes OPTIONAL + // } + // PKCS#5 (https://www.rfc-editor.org/rfc/rfc8018) describes the AlgorithmIdentifier + // as a SEQUENCE. + // + // Therefore, we consider the outer SEQUENCE, a version number, and the start of + // an AlgorithmIdentifier to be enough to identify a PKCS#8 key. If it were PKCS#1 or SEC1 + // the version would not be followed by a SEQUENCE. + if matches!(key_bytes, [TAG_INTEGER, 0x01, _, TAG_SEQUENCE, ..]) { + return Ok(Self::Pkcs8(key.into())); + } + + // PKCS#1 (https://www.rfc-editor.org/rfc/rfc8017) describes the RSAPrivateKey structure + // as: + // RSAPrivateKey ::= SEQUENCE { + // version Version, + // modulus INTEGER, -- n + // publicExponent INTEGER, -- e + // privateExponent INTEGER, -- d + // prime1 INTEGER, -- p + // prime2 INTEGER, -- q + // exponent1 INTEGER, -- d mod (p-1) + // exponent2 INTEGER, -- d mod (q-1) + // coefficient INTEGER, -- (inverse of q) mod p + // otherPrimeInfos OtherPrimeInfos OPTIONAL + // } + // + // Therefore, we consider the outer SEQUENCE and a Version of 0 to be enough to identify + // a PKCS#1 key. If it were PKCS#8, the version would be followed by a SEQUENCE. If it + // were SEC1, the VERSION would have been 1. + if key_bytes.starts_with(&[TAG_INTEGER, 0x01, 0x00]) { + return Ok(Self::Pkcs1(key.into())); + } + + // SEC1 (https://www.rfc-editor.org/rfc/rfc5915) describes the ECPrivateKey structure as: + // ECPrivateKey ::= SEQUENCE { + // version INTEGER { ecPrivkeyVer1(1) } (ecPrivkeyVer1), + // privateKey OCTET STRING, + // parameters [0] ECParameters {{ NamedCurve }} OPTIONAL, + // publicKey [1] BIT STRING OPTIONAL + // } + // + // Therefore, we consider the outer SEQUENCE and an INTEGER of 1 to be enough to + // identify a SEC1 key. If it were PKCS#8 or PKCS#1, the version would have been 0. + if key_bytes.starts_with(&[TAG_INTEGER, 0x01, 0x01]) { + return Ok(Self::Sec1(key.into())); + } + + Err(INVALID_KEY_DER_ERR) + } +} + +static INVALID_KEY_DER_ERR: &str = "unknown or invalid key format"; + +#[cfg(feature = "alloc")] +impl TryFrom> for PrivateKeyDer<'_> { + type Error = &'static str; + + fn try_from(key: Vec) -> Result { + Ok(match PrivateKeyDer::try_from(&key[..])? { + PrivateKeyDer::Pkcs1(_) => Self::Pkcs1(key.into()), + PrivateKeyDer::Sec1(_) => Self::Sec1(key.into()), + PrivateKeyDer::Pkcs8(_) => Self::Pkcs8(key.into()), + }) + } +} + +/// A DER-encoded plaintext RSA private key; as specified in PKCS#1/RFC 3447 +/// +/// RSA private keys are identified in PEM context as `RSA PRIVATE KEY` and when stored in a +/// file usually use a `.pem` or `.key` extension. +/// +/// ```rust +/// # #[cfg(all(feature = "alloc", feature = "std"))] { +/// use rustls_pki_types::{PrivatePkcs1KeyDer, pem::PemObject}; +/// +/// // load from a PEM file +/// PrivatePkcs1KeyDer::from_pem_file("tests/data/rsa1024.pkcs1.pem").unwrap(); +/// +/// // or from a PEM byte slice... +/// # let byte_slice = include_bytes!("../tests/data/rsa1024.pkcs1.pem"); +/// PrivatePkcs1KeyDer::from_pem_slice(byte_slice).unwrap(); +/// # } +/// ``` +#[derive(PartialEq, Eq)] +pub struct PrivatePkcs1KeyDer<'a>(Der<'a>); + +impl PrivatePkcs1KeyDer<'_> { + /// Clone the private key to a `'static` value + #[cfg(feature = "alloc")] + pub fn clone_key(&self) -> PrivatePkcs1KeyDer<'static> { + PrivatePkcs1KeyDer::from(self.0.as_ref().to_vec()) + } + + /// Yield the DER-encoded bytes of the private key + pub fn secret_pkcs1_der(&self) -> &[u8] { + self.0.as_ref() + } +} + +#[cfg(feature = "alloc")] +impl zeroize::Zeroize for PrivatePkcs1KeyDer<'static> { + fn zeroize(&mut self) { + self.0.0.zeroize() + } +} + +#[cfg(feature = "alloc")] +impl PemObjectFilter for PrivatePkcs1KeyDer<'static> { + const KIND: SectionKind = SectionKind::RsaPrivateKey; +} + +impl<'a> From<&'a [u8]> for PrivatePkcs1KeyDer<'a> { + fn from(slice: &'a [u8]) -> Self { + Self(Der(BytesInner::Borrowed(slice))) + } +} + +#[cfg(feature = "alloc")] +impl From> for PrivatePkcs1KeyDer<'_> { + fn from(vec: Vec) -> Self { + Self(Der(BytesInner::Owned(vec))) + } +} + +impl fmt::Debug for PrivatePkcs1KeyDer<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_tuple("PrivatePkcs1KeyDer") + .field(&"[secret key elided]") + .finish() + } +} + +/// A Sec1-encoded plaintext private key; as specified in RFC 5915 +/// +/// Sec1 private keys are identified in PEM context as `EC PRIVATE KEY` and when stored in a +/// file usually use a `.pem` or `.key` extension. For more on PEM files, refer to the crate +/// documentation. +/// +/// ```rust +/// # #[cfg(all(feature = "alloc", feature = "std"))] { +/// use rustls_pki_types::{PrivateSec1KeyDer, pem::PemObject}; +/// +/// // load from a PEM file +/// PrivateSec1KeyDer::from_pem_file("tests/data/nistp256key.pem").unwrap(); +/// +/// // or from a PEM byte slice... +/// # let byte_slice = include_bytes!("../tests/data/nistp256key.pem"); +/// PrivateSec1KeyDer::from_pem_slice(byte_slice).unwrap(); +/// # } +/// ``` +#[derive(PartialEq, Eq)] +pub struct PrivateSec1KeyDer<'a>(Der<'a>); + +impl PrivateSec1KeyDer<'_> { + /// Clone the private key to a `'static` value + #[cfg(feature = "alloc")] + pub fn clone_key(&self) -> PrivateSec1KeyDer<'static> { + PrivateSec1KeyDer::from(self.0.as_ref().to_vec()) + } + + /// Yield the DER-encoded bytes of the private key + pub fn secret_sec1_der(&self) -> &[u8] { + self.0.as_ref() + } +} + +#[cfg(feature = "alloc")] +impl zeroize::Zeroize for PrivateSec1KeyDer<'static> { + fn zeroize(&mut self) { + self.0.0.zeroize() + } +} + +#[cfg(feature = "alloc")] +impl PemObjectFilter for PrivateSec1KeyDer<'static> { + const KIND: SectionKind = SectionKind::EcPrivateKey; +} + +impl<'a> From<&'a [u8]> for PrivateSec1KeyDer<'a> { + fn from(slice: &'a [u8]) -> Self { + Self(Der(BytesInner::Borrowed(slice))) + } +} + +#[cfg(feature = "alloc")] +impl From> for PrivateSec1KeyDer<'_> { + fn from(vec: Vec) -> Self { + Self(Der(BytesInner::Owned(vec))) + } +} + +impl fmt::Debug for PrivateSec1KeyDer<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_tuple("PrivateSec1KeyDer") + .field(&"[secret key elided]") + .finish() + } +} + +/// A DER-encoded plaintext private key; as specified in PKCS#8/RFC 5958 +/// +/// PKCS#8 private keys are identified in PEM context as `PRIVATE KEY` and when stored in a +/// file usually use a `.pem` or `.key` extension. For more on PEM files, refer to the crate +/// documentation. +/// +/// ```rust +/// # #[cfg(all(feature = "alloc", feature = "std"))] { +/// use rustls_pki_types::{PrivatePkcs8KeyDer, pem::PemObject}; +/// +/// // load from a PEM file +/// PrivatePkcs8KeyDer::from_pem_file("tests/data/nistp256key.pkcs8.pem").unwrap(); +/// PrivatePkcs8KeyDer::from_pem_file("tests/data/rsa1024.pkcs8.pem").unwrap(); +/// +/// // or from a PEM byte slice... +/// # let byte_slice = include_bytes!("../tests/data/nistp256key.pkcs8.pem"); +/// PrivatePkcs8KeyDer::from_pem_slice(byte_slice).unwrap(); +/// # } +/// ``` +#[derive(PartialEq, Eq)] +pub struct PrivatePkcs8KeyDer<'a>(Der<'a>); + +impl PrivatePkcs8KeyDer<'_> { + /// Clone the private key to a `'static` value + #[cfg(feature = "alloc")] + pub fn clone_key(&self) -> PrivatePkcs8KeyDer<'static> { + PrivatePkcs8KeyDer::from(self.0.as_ref().to_vec()) + } + + /// Yield the DER-encoded bytes of the private key + pub fn secret_pkcs8_der(&self) -> &[u8] { + self.0.as_ref() + } +} + +#[cfg(feature = "alloc")] +impl zeroize::Zeroize for PrivatePkcs8KeyDer<'static> { + fn zeroize(&mut self) { + self.0.0.zeroize() + } +} + +#[cfg(feature = "alloc")] +impl PemObjectFilter for PrivatePkcs8KeyDer<'static> { + const KIND: SectionKind = SectionKind::PrivateKey; +} + +impl<'a> From<&'a [u8]> for PrivatePkcs8KeyDer<'a> { + fn from(slice: &'a [u8]) -> Self { + Self(Der(BytesInner::Borrowed(slice))) + } +} + +#[cfg(feature = "alloc")] +impl From> for PrivatePkcs8KeyDer<'_> { + fn from(vec: Vec) -> Self { + Self(Der(BytesInner::Owned(vec))) + } +} + +impl fmt::Debug for PrivatePkcs8KeyDer<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_tuple("PrivatePkcs8KeyDer") + .field(&"[secret key elided]") + .finish() + } +} + +/// A trust anchor (a.k.a. root CA) +/// +/// Traditionally, certificate verification libraries have represented trust anchors as full X.509 +/// root certificates. However, those certificates contain a lot more data than is needed for +/// verifying certificates. The [`TrustAnchor`] representation allows an application to store +/// just the essential elements of trust anchors. +/// +/// The most common way to get one of these is to call [`rustls_webpki::anchor_from_trusted_cert()`]. +/// +/// [`rustls_webpki::anchor_from_trusted_cert()`]: https://docs.rs/rustls-webpki/latest/webpki/fn.anchor_from_trusted_cert.html +#[allow(clippy::exhaustive_structs)] +#[derive(Clone, Debug, Hash, PartialEq, Eq)] +pub struct TrustAnchor<'a> { + /// Value of the `subject` field of the trust anchor + pub subject: Der<'a>, + /// Value of the `subjectPublicKeyInfo` field of the trust anchor + pub subject_public_key_info: Der<'a>, + /// Value of DER-encoded `NameConstraints`, containing name constraints to the trust anchor, if any + pub name_constraints: Option>, +} + +impl TrustAnchor<'_> { + /// Yield a `'static` lifetime of the `TrustAnchor` by allocating owned `Der` variants + #[cfg(feature = "alloc")] + pub fn to_owned(&self) -> TrustAnchor<'static> { + #[cfg(not(feature = "std"))] + use alloc::borrow::ToOwned; + TrustAnchor { + subject: self.subject.as_ref().to_owned().into(), + subject_public_key_info: self.subject_public_key_info.as_ref().to_owned().into(), + name_constraints: self + .name_constraints + .as_ref() + .map(|nc| nc.as_ref().to_owned().into()), + } + } +} + +/// A Certificate Revocation List; as specified in RFC 5280 +/// +/// Certificate revocation lists are identified in PEM context as `X509 CRL` and when stored in a +/// file usually use a `.crl` extension. For more on PEM files, refer to the crate documentation. +/// +/// ```rust +/// # #[cfg(all(feature = "alloc", feature = "std"))] { +/// use rustls_pki_types::{CertificateRevocationListDer, pem::PemObject}; +/// +/// // load several from a PEM file +/// let crls: Vec<_> = CertificateRevocationListDer::pem_file_iter("tests/data/crl.pem") +/// .unwrap() +/// .collect(); +/// assert!(crls.len() >= 1); +/// +/// // or one from a PEM byte slice... +/// # let byte_slice = include_bytes!("../tests/data/crl.pem"); +/// CertificateRevocationListDer::from_pem_slice(byte_slice).unwrap(); +/// +/// // or several from a PEM byte slice +/// let crls: Vec<_> = CertificateRevocationListDer::pem_slice_iter(byte_slice) +/// .collect(); +/// assert!(crls.len() >= 1); +/// # } +/// ``` + +#[derive(Clone, Debug, Hash, PartialEq, Eq)] +pub struct CertificateRevocationListDer<'a>(Der<'a>); + +#[cfg(feature = "alloc")] +impl PemObjectFilter for CertificateRevocationListDer<'static> { + const KIND: SectionKind = SectionKind::Crl; +} + +impl AsRef<[u8]> for CertificateRevocationListDer<'_> { + fn as_ref(&self) -> &[u8] { + self.0.as_ref() + } +} + +impl Deref for CertificateRevocationListDer<'_> { + type Target = [u8]; + + fn deref(&self) -> &Self::Target { + self.as_ref() + } +} + +impl<'a> From<&'a [u8]> for CertificateRevocationListDer<'a> { + fn from(slice: &'a [u8]) -> Self { + Self(Der::from(slice)) + } +} + +#[cfg(feature = "alloc")] +impl From> for CertificateRevocationListDer<'_> { + fn from(vec: Vec) -> Self { + Self(Der::from(vec)) + } +} + +/// A Certificate Signing Request; as specified in RFC 2986 +/// +/// Certificate signing requests are identified in PEM context as `CERTIFICATE REQUEST` and when stored in a +/// file usually use a `.csr` extension. For more on PEM files, refer to the crate documentation. +/// +/// ```rust +/// # #[cfg(all(feature = "alloc", feature = "std"))] { +/// use rustls_pki_types::{CertificateSigningRequestDer, pem::PemObject}; +/// +/// // load from a PEM file +/// CertificateSigningRequestDer::from_pem_file("tests/data/csr.pem").unwrap(); +/// +/// // or from a PEM byte slice... +/// # let byte_slice = include_bytes!("../tests/data/csr.pem"); +/// CertificateSigningRequestDer::from_pem_slice(byte_slice).unwrap(); +/// # } +/// ``` +#[derive(Clone, Debug, Hash, PartialEq, Eq)] +pub struct CertificateSigningRequestDer<'a>(Der<'a>); + +#[cfg(feature = "alloc")] +impl PemObjectFilter for CertificateSigningRequestDer<'static> { + const KIND: SectionKind = SectionKind::Csr; +} + +impl AsRef<[u8]> for CertificateSigningRequestDer<'_> { + fn as_ref(&self) -> &[u8] { + self.0.as_ref() + } +} + +impl Deref for CertificateSigningRequestDer<'_> { + type Target = [u8]; + + fn deref(&self) -> &Self::Target { + self.as_ref() + } +} + +impl<'a> From<&'a [u8]> for CertificateSigningRequestDer<'a> { + fn from(slice: &'a [u8]) -> Self { + Self(Der::from(slice)) + } +} + +#[cfg(feature = "alloc")] +impl From> for CertificateSigningRequestDer<'_> { + fn from(vec: Vec) -> Self { + Self(Der::from(vec)) + } +} + +/// A DER-encoded X.509 certificate; as specified in RFC 5280 +/// +/// Certificates are identified in PEM context as `CERTIFICATE` and when stored in a +/// file usually use a `.pem`, `.cer` or `.crt` extension. For more on PEM files, refer to the +/// crate documentation. +/// +/// ```rust +/// # #[cfg(all(feature = "alloc", feature = "std"))] { +/// use rustls_pki_types::{CertificateDer, pem::PemObject}; +/// +/// // load several from a PEM file +/// let certs: Vec<_> = CertificateDer::pem_file_iter("tests/data/certificate.chain.pem") +/// .unwrap() +/// .collect(); +/// assert_eq!(certs.len(), 3); +/// +/// // or one from a PEM byte slice... +/// # let byte_slice = include_bytes!("../tests/data/certificate.chain.pem"); +/// CertificateDer::from_pem_slice(byte_slice).unwrap(); +/// +/// // or several from a PEM byte slice +/// let certs: Vec<_> = CertificateDer::pem_slice_iter(byte_slice) +/// .collect(); +/// assert_eq!(certs.len(), 3); +/// # } +/// ``` +#[derive(Clone, Debug, Hash, PartialEq, Eq)] +pub struct CertificateDer<'a>(Der<'a>); + +impl<'a> CertificateDer<'a> { + /// A const constructor to create a `CertificateDer` from a slice of DER. + pub const fn from_slice(bytes: &'a [u8]) -> Self { + Self(Der::from_slice(bytes)) + } +} + +#[cfg(feature = "alloc")] +impl PemObjectFilter for CertificateDer<'static> { + const KIND: SectionKind = SectionKind::Certificate; +} + +impl AsRef<[u8]> for CertificateDer<'_> { + fn as_ref(&self) -> &[u8] { + self.0.as_ref() + } +} + +impl Deref for CertificateDer<'_> { + type Target = [u8]; + + fn deref(&self) -> &Self::Target { + self.as_ref() + } +} + +impl<'a> From<&'a [u8]> for CertificateDer<'a> { + fn from(slice: &'a [u8]) -> Self { + Self(Der::from(slice)) + } +} + +#[cfg(feature = "alloc")] +impl From> for CertificateDer<'_> { + fn from(vec: Vec) -> Self { + Self(Der::from(vec)) + } +} + +impl CertificateDer<'_> { + /// Converts this certificate into its owned variant, unfreezing borrowed content (if any) + #[cfg(feature = "alloc")] + pub fn into_owned(self) -> CertificateDer<'static> { + CertificateDer(Der(self.0.0.into_owned())) + } +} + +/// A DER-encoded SubjectPublicKeyInfo (SPKI), as specified in RFC 5280. +#[deprecated(since = "1.7.0", note = "Prefer `SubjectPublicKeyInfoDer` instead")] +pub type SubjectPublicKeyInfo<'a> = SubjectPublicKeyInfoDer<'a>; + +/// A DER-encoded SubjectPublicKeyInfo (SPKI), as specified in RFC 5280. +/// +/// Public keys are identified in PEM context as a `PUBLIC KEY`. +/// +/// ```rust +/// # #[cfg(all(feature = "alloc", feature = "std"))] { +/// use rustls_pki_types::{SubjectPublicKeyInfoDer, pem::PemObject}; +/// +/// // load from a PEM file +/// SubjectPublicKeyInfoDer::from_pem_file("tests/data/spki.pem").unwrap(); +/// +/// // or from a PEM byte slice... +/// # let byte_slice = include_bytes!("../tests/data/spki.pem"); +/// SubjectPublicKeyInfoDer::from_pem_slice(byte_slice).unwrap(); +/// # } +/// ``` +#[derive(Clone, Debug, Hash, PartialEq, Eq)] +pub struct SubjectPublicKeyInfoDer<'a>(Der<'a>); + +#[cfg(feature = "alloc")] +impl PemObjectFilter for SubjectPublicKeyInfoDer<'static> { + const KIND: SectionKind = SectionKind::PublicKey; +} + +impl AsRef<[u8]> for SubjectPublicKeyInfoDer<'_> { + fn as_ref(&self) -> &[u8] { + self.0.as_ref() + } +} + +impl Deref for SubjectPublicKeyInfoDer<'_> { + type Target = [u8]; + + fn deref(&self) -> &Self::Target { + self.as_ref() + } +} + +impl<'a> From<&'a [u8]> for SubjectPublicKeyInfoDer<'a> { + fn from(slice: &'a [u8]) -> Self { + Self(Der::from(slice)) + } +} + +#[cfg(feature = "alloc")] +impl From> for SubjectPublicKeyInfoDer<'_> { + fn from(vec: Vec) -> Self { + Self(Der::from(vec)) + } +} + +impl SubjectPublicKeyInfoDer<'_> { + /// Converts this SubjectPublicKeyInfo into its owned variant, unfreezing borrowed content (if any) + #[cfg(feature = "alloc")] + pub fn into_owned(self) -> SubjectPublicKeyInfoDer<'static> { + SubjectPublicKeyInfoDer(Der(self.0.0.into_owned())) + } +} + +/// A TLS-encoded Encrypted Client Hello (ECH) configuration list (`ECHConfigList`); as specified in +/// [RFC 9849 §4](https://datatracker.ietf.org/doc/html/rfc9849#section-4) +#[derive(Clone, Eq, Hash, PartialEq)] +pub struct EchConfigListBytes<'a>(BytesInner<'a>); + +impl EchConfigListBytes<'_> { + /// Converts this config into its owned variant, unfreezing borrowed content (if any) + #[cfg(feature = "alloc")] + pub fn into_owned(self) -> EchConfigListBytes<'static> { + EchConfigListBytes(self.0.into_owned()) + } +} + +#[cfg(feature = "alloc")] +impl EchConfigListBytes<'static> { + /// Convert an iterator over PEM items into an `EchConfigListBytes` and private key. + /// + /// This handles the "ECHConfig file" format specified in + /// + /// + /// Use it like: + /// + /// ```rust + /// # #[cfg(all(feature = "alloc", feature = "std"))] { + /// # use rustls_pki_types::{EchConfigListBytes, pem::PemObject}; + /// let (config, key) = EchConfigListBytes::config_and_key_from_iter( + /// PemObject::pem_file_iter("tests/data/ech.pem").unwrap() + /// ).unwrap(); + /// # } + /// ``` + pub fn config_and_key_from_iter( + iter: impl Iterator), pem::Error>>, + ) -> Result<(Self, PrivatePkcs8KeyDer<'static>), pem::Error> { + let mut key = None; + let mut config = None; + + for item in iter { + let (kind, data) = item?; + match kind { + SectionKind::PrivateKey => { + key = PrivatePkcs8KeyDer::from_pem(kind, data); + } + SectionKind::EchConfigList => { + config = Self::from_pem(kind, data); + } + _ => continue, + }; + + if let (Some(_key), Some(_config)) = (&key, &config) { + return Ok((config.take().unwrap(), key.take().unwrap())); + } + } + + Err(pem::Error::NoItemsFound) + } +} + +#[cfg(feature = "alloc")] +impl PemObjectFilter for EchConfigListBytes<'static> { + const KIND: SectionKind = SectionKind::EchConfigList; +} + +impl fmt::Debug for EchConfigListBytes<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + hex(f, self.as_ref()) + } +} + +impl AsRef<[u8]> for EchConfigListBytes<'_> { + fn as_ref(&self) -> &[u8] { + self.0.as_ref() + } +} + +impl Deref for EchConfigListBytes<'_> { + type Target = [u8]; + + fn deref(&self) -> &Self::Target { + self.as_ref() + } +} + +impl<'a> From<&'a [u8]> for EchConfigListBytes<'a> { + fn from(slice: &'a [u8]) -> Self { + Self(BytesInner::Borrowed(slice)) + } +} + +#[cfg(feature = "alloc")] +impl From> for EchConfigListBytes<'_> { + fn from(vec: Vec) -> Self { + Self(BytesInner::Owned(vec)) + } +} + +/// An abstract signature verification algorithm. +/// +/// One of these is needed per supported pair of public key type (identified +/// with `public_key_alg_id()`) and `signatureAlgorithm` (identified with +/// `signature_alg_id()`). Note that both of these `AlgorithmIdentifier`s include +/// the parameters encoding, so separate `SignatureVerificationAlgorithm`s are needed +/// for each possible public key or signature parameters. +/// +/// Debug implementations should list the public key algorithm identifier and +/// signature algorithm identifier in human friendly form (i.e. not encoded bytes), +/// along with the name of the implementing library (to distinguish different +/// implementations of the same algorithms). +pub trait SignatureVerificationAlgorithm: Send + Sync + fmt::Debug { + /// Verify a signature. + /// + /// `public_key` is the `subjectPublicKey` value from a `SubjectPublicKeyInfo` encoding + /// and is untrusted. The key's `subjectPublicKeyInfo` matches the [`AlgorithmIdentifier`] + /// returned by `public_key_alg_id()`. + /// + /// `message` is the data over which the signature was allegedly computed. + /// It is not hashed; implementations of this trait function must do hashing + /// if that is required by the algorithm they implement. + /// + /// `signature` is the signature allegedly over `message`. + /// + /// Return `Ok(())` only if `signature` is a valid signature on `message`. + /// + /// Return `Err(InvalidSignature)` if the signature is invalid, including if the `public_key` + /// encoding is invalid. There is no need or opportunity to produce errors + /// that are more specific than this. + fn verify_signature( + &self, + public_key: &[u8], + message: &[u8], + signature: &[u8], + ) -> Result<(), InvalidSignature>; + + /// Return the `AlgorithmIdentifier` that must equal a public key's + /// `subjectPublicKeyInfo` value for this `SignatureVerificationAlgorithm` + /// to be used for signature verification. + fn public_key_alg_id(&self) -> AlgorithmIdentifier; + + /// Return the `AlgorithmIdentifier` that must equal the `signatureAlgorithm` value + /// on the data to be verified for this `SignatureVerificationAlgorithm` to be used + /// for signature verification. + fn signature_alg_id(&self) -> AlgorithmIdentifier; + + /// Return the FIPS status of this algorithm or implementation. + fn fips_status(&self) -> FipsStatus { + match self.fips() { + true => FipsStatus::Pending, + false => FipsStatus::Unvalidated, + } + } + + /// Return `true` if this is backed by a FIPS-approved implementation. + fn fips(&self) -> bool { + false + } +} + +/// A detail-less error when a signature is not valid. +#[allow(clippy::exhaustive_structs)] +#[derive(Debug, Copy, Clone)] +pub struct InvalidSignature; + +/// A timestamp, tracking the number of non-leap seconds since the Unix epoch. +/// +/// The Unix epoch is defined January 1, 1970 00:00:00 UTC. +#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)] +pub struct UnixTime(u64); + +impl UnixTime { + /// The current time, as a `UnixTime` + #[cfg(any( + all( + feature = "std", + not(all(target_family = "wasm", target_os = "unknown")) + ), + all(target_family = "wasm", target_os = "unknown", feature = "web") + ))] + pub fn now() -> Self { + Self::since_unix_epoch( + SystemTime::now() + .duration_since(SystemTime::UNIX_EPOCH) + .unwrap(), // Safe: this code did not exist before 1970. + ) + } + + /// Convert a `Duration` since the start of 1970 to a `UnixTime` + /// + /// The `duration` must be relative to the Unix epoch. + pub const fn since_unix_epoch(duration: Duration) -> Self { + Self(duration.as_secs()) + } + + /// Number of seconds since the Unix epoch + pub const fn as_secs(&self) -> u64 { + self.0 + } +} + +/// DER-encoded data, either owned or borrowed +/// +/// This wrapper type is used to represent DER-encoded data in a way that is agnostic to whether +/// the data is owned (by a `Vec`) or borrowed (by a `&[u8]`). Support for the owned +/// variant is only available when the `alloc` feature is enabled. +#[derive(Clone, Eq, Hash, PartialEq)] +pub struct Der<'a>(BytesInner<'a>); + +impl<'a> Der<'a> { + /// A const constructor to create a `Der` from a borrowed slice + pub const fn from_slice(der: &'a [u8]) -> Self { + Self(BytesInner::Borrowed(der)) + } +} + +impl AsRef<[u8]> for Der<'_> { + fn as_ref(&self) -> &[u8] { + self.0.as_ref() + } +} + +impl Deref for Der<'_> { + type Target = [u8]; + + fn deref(&self) -> &Self::Target { + self.as_ref() + } +} + +impl<'a> From<&'a [u8]> for Der<'a> { + fn from(slice: &'a [u8]) -> Self { + Self(BytesInner::Borrowed(slice)) + } +} + +#[cfg(feature = "alloc")] +impl From> for Der<'static> { + fn from(vec: Vec) -> Self { + Self(BytesInner::Owned(vec)) + } +} + +impl fmt::Debug for Der<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + hex(f, self.as_ref()) + } +} + +#[derive(Debug, Clone)] +enum BytesInner<'a> { + #[cfg(feature = "alloc")] + Owned(Vec), + Borrowed(&'a [u8]), +} + +#[cfg(feature = "alloc")] +impl BytesInner<'_> { + fn into_owned(self) -> BytesInner<'static> { + BytesInner::Owned(match self { + Self::Owned(vec) => vec, + Self::Borrowed(slice) => slice.to_vec(), + }) + } +} + +#[cfg(feature = "alloc")] +impl zeroize::Zeroize for BytesInner<'static> { + fn zeroize(&mut self) { + match self { + BytesInner::Owned(vec) => vec.zeroize(), + BytesInner::Borrowed(_) => (), + } + } +} + +impl AsRef<[u8]> for BytesInner<'_> { + fn as_ref(&self) -> &[u8] { + match &self { + #[cfg(feature = "alloc")] + BytesInner::Owned(vec) => vec.as_ref(), + BytesInner::Borrowed(slice) => slice, + } + } +} + +impl core::hash::Hash for BytesInner<'_> { + fn hash(&self, state: &mut H) { + state.write(self.as_ref()); + } +} + +impl PartialEq for BytesInner<'_> { + fn eq(&self, other: &Self) -> bool { + self.as_ref() == other.as_ref() + } +} + +impl Eq for BytesInner<'_> {} + +/// FIPS validation status of an algorithm or implementation. +#[allow(clippy::exhaustive_enums)] +#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)] +pub enum FipsStatus { + /// Not FIPS tested, or unapproved algorithm. + Unvalidated, + /// In queue for FIPS validation. + Pending, + /// FIPS certified, with named certificate. + #[non_exhaustive] + Certified { + /// A name, number or URL referencing the FIPS certificate. + certificate: &'static str, + }, +} + +// Format an iterator of u8 into a hex string +fn hex<'a>(f: &mut fmt::Formatter<'_>, payload: impl IntoIterator) -> fmt::Result { + for (i, b) in payload.into_iter().enumerate() { + if i == 0 { + write!(f, "0x")?; + } + write!(f, "{b:02x}")?; + } + Ok(()) +} + +#[cfg(all(test, feature = "std"))] +mod tests { + use super::*; + + #[test] + fn der_debug() { + let der = Der::from_slice(&[0x01, 0x02, 0x03]); + assert_eq!(format!("{der:?}"), "0x010203"); + } + + #[test] + fn alg_id_debug() { + let alg_id = AlgorithmIdentifier::from_slice(&[0x01, 0x02, 0x03]); + assert_eq!(format!("{alg_id:?}"), "0x010203"); + } + + #[test] + fn bytes_inner_equality() { + let owned_a = BytesInner::Owned(vec![1, 2, 3]); + let owned_b = BytesInner::Owned(vec![4, 5]); + let borrowed_a = BytesInner::Borrowed(&[1, 2, 3]); + let borrowed_b = BytesInner::Borrowed(&[99]); + + // Self-equality. + assert_eq!(owned_a, owned_a); + assert_eq!(owned_b, owned_b); + assert_eq!(borrowed_a, borrowed_a); + assert_eq!(borrowed_b, borrowed_b); + + // Borrowed vs Owned equality + assert_eq!(owned_a, borrowed_a); + assert_eq!(borrowed_a, owned_a); + + // Owned inequality + assert_ne!(owned_a, owned_b); + assert_ne!(owned_b, owned_a); + + // Borrowed inequality + assert_ne!(borrowed_a, borrowed_b); + assert_ne!(borrowed_b, borrowed_a); + + // Borrowed vs Owned inequality + assert_ne!(owned_a, borrowed_b); + assert_ne!(borrowed_b, owned_a); + } +} diff --git a/http/vendor/rustls-pki-types/src/pem.rs b/http/vendor/rustls-pki-types/src/pem.rs new file mode 100644 index 0000000..473392f --- /dev/null +++ b/http/vendor/rustls-pki-types/src/pem.rs @@ -0,0 +1,562 @@ +use alloc::format; +use alloc::string::String; +use alloc::vec; +use alloc::vec::Vec; +use core::fmt; +use core::marker::PhantomData; +use core::ops::ControlFlow; +#[cfg(feature = "std")] +use std::fs::File; +#[cfg(feature = "std")] +use std::io::{self, ErrorKind}; + +use crate::base64; + +/// Items that can be decoded from PEM data. +pub trait PemObject: Sized { + /// Decode the first section of this type from PEM contained in + /// a byte slice. + /// + /// [`Error::NoItemsFound`] is returned if no such items are found. + fn from_pem_slice(pem: &[u8]) -> Result { + Self::pem_slice_iter(pem) + .next() + .unwrap_or(Err(Error::NoItemsFound)) + } + + /// Iterate over all sections of this type from PEM contained in + /// a byte slice. + fn pem_slice_iter(pem: &[u8]) -> SliceIter<'_, Self> { + SliceIter::new(pem) + } + + /// Decode the first section of this type from the PEM contents of the named file. + /// + /// [`Error::NoItemsFound`] is returned if no such items are found. + #[cfg(feature = "std")] + fn from_pem_file(file_name: impl AsRef) -> Result { + Self::pem_file_iter(file_name)? + .next() + .unwrap_or(Err(Error::NoItemsFound)) + } + + /// Iterate over all sections of this type from the PEM contents of the named file. + /// + /// This reports errors in two phases: + /// + /// - errors opening the file are reported from this function directly, + /// - errors reading from the file are reported from the returned iterator, + #[cfg(feature = "std")] + fn pem_file_iter( + file_name: impl AsRef, + ) -> Result, Self>, Error> { + Ok(ReadIter::new(io::BufReader::new( + File::open(file_name).map_err(Error::Io)?, + ))) + } + + /// Decode the first section of this type from PEM read from an [`io::Read`]. + #[cfg(feature = "std")] + fn from_pem_reader(rd: impl io::Read) -> Result { + Self::pem_reader_iter(rd) + .next() + .unwrap_or(Err(Error::NoItemsFound)) + } + + /// Iterate over all sections of this type from PEM present in an [`io::Read`]. + #[cfg(feature = "std")] + fn pem_reader_iter(rd: R) -> ReadIter, Self> { + ReadIter::new(io::BufReader::new(rd)) + } + + /// Conversion from a PEM [`SectionKind`] and body data. + /// + /// This inspects `kind`, and if it matches this type's PEM section kind, + /// converts `der` into this type. + fn from_pem(kind: SectionKind, der: Vec) -> Option; +} + +pub(crate) trait PemObjectFilter: PemObject + From> { + const KIND: SectionKind; +} + +impl>> PemObject for T { + fn from_pem(kind: SectionKind, der: Vec) -> Option { + match Self::KIND == kind { + true => Some(Self::from(der)), + false => None, + } + } +} + +/// Extract and return all PEM sections by reading `rd`. +#[cfg(feature = "std")] +pub struct ReadIter { + rd: R, + _ty: PhantomData, + line: Vec, + b64_buf: Vec, + /// Used to fuse the iterator on I/O errors + done: bool, +} + +#[cfg(feature = "std")] +impl ReadIter { + /// Create a new iterator. + pub fn new(rd: R) -> Self { + Self { + rd, + _ty: PhantomData, + line: Vec::with_capacity(80), + b64_buf: Vec::with_capacity(1024), + done: false, + } + } +} + +#[cfg(feature = "std")] +impl Iterator for ReadIter { + type Item = Result; + + fn next(&mut self) -> Option { + if self.done { + return None; + } + + loop { + self.b64_buf.clear(); + return match from_buf_inner(&mut self.rd, &mut self.line, &mut self.b64_buf) { + Ok(Some((sec, item))) => match T::from_pem(sec, item) { + Some(res) => Some(Ok(res)), + None => continue, + }, + Ok(None) => return None, + Err(Error::Io(error)) => { + self.done = true; + Some(Err(Error::Io(error))) + } + Err(err) => Some(Err(err)), + }; + } + } +} + +/// Iterator over all PEM sections in a `&[u8]` slice. +pub struct SliceIter<'a, T> { + current: &'a [u8], + _ty: PhantomData, + b64_buf: Vec, +} + +impl<'a, T: PemObject> SliceIter<'a, T> { + /// Create a new iterator. + pub fn new(current: &'a [u8]) -> Self { + Self { + current, + _ty: PhantomData, + b64_buf: Vec::with_capacity(1024), + } + } + + /// Extract and decode the next supported PEM section from `input` + /// + /// - `Ok(None)` is returned if there is no PEM section to read from `input` + /// - Syntax errors and decoding errors produce a `Err(...)` + /// - Otherwise each decoded section is returned with a `Ok(Some((..., remainder)))` where + /// `remainder` is the part of the `input` that follows the returned section + fn read_section(&mut self) -> Result)>, Error> { + self.b64_buf.clear(); + let mut section = None; + loop { + let next_line = if let Some(index) = self + .current + .iter() + .position(|byte| *byte == b'\n' || *byte == b'\r') + { + let (line, newline_plus_remainder) = self.current.split_at(index); + self.current = &newline_plus_remainder[1..]; + Some(line) + } else if !self.current.is_empty() { + let next_line = self.current; + self.current = &[]; + Some(next_line) + } else { + None + }; + + match read(next_line, &mut section, &mut self.b64_buf)? { + ControlFlow::Continue(()) => continue, + ControlFlow::Break(item) => return Ok(item), + } + } + } + + /// Returns the rest of the unparsed data. + /// + /// This is the slice immediately following the most + /// recently returned item from `next()`. + #[doc(hidden)] + pub fn remainder(&self) -> &'a [u8] { + self.current + } +} + +impl Iterator for SliceIter<'_, T> { + type Item = Result; + + fn next(&mut self) -> Option { + loop { + return match self.read_section() { + Ok(Some((sec, item))) => match T::from_pem(sec, item) { + Some(res) => Some(Ok(res)), + None => continue, + }, + Ok(None) => return None, + Err(err) => Some(Err(err)), + }; + } + } +} + +impl PemObject for (SectionKind, Vec) { + fn from_pem(kind: SectionKind, der: Vec) -> Option { + Some((kind, der)) + } +} + +/// Extract and decode the next supported PEM section from `rd`. +/// +/// - Ok(None) is returned if there is no PEM section read from `rd`. +/// - Underlying IO errors produce a `Err(...)` +/// - Otherwise each decoded section is returned with a `Ok(Some(...))` +#[cfg(feature = "std")] +pub fn from_buf(rd: &mut dyn io::BufRead) -> Result)>, Error> { + let mut b64buf = Vec::with_capacity(1024); + let mut line = Vec::with_capacity(80); + from_buf_inner(rd, &mut line, &mut b64buf) +} + +#[cfg(feature = "std")] +fn from_buf_inner( + rd: &mut dyn io::BufRead, + line: &mut Vec, + b64buf: &mut Vec, +) -> Result)>, Error> { + let mut section = None; + loop { + line.clear(); + let len = read_until_newline(rd, line).map_err(Error::Io)?; + + let next_line = if len == 0 { + None + } else { + Some(line.as_slice()) + }; + + match read(next_line, &mut section, b64buf) { + Ok(ControlFlow::Break(opt)) => return Ok(opt), + Ok(ControlFlow::Continue(())) => continue, + Err(e) => return Err(e), + } + } +} + +#[allow(clippy::type_complexity)] +fn read( + next_line: Option<&[u8]>, + section: &mut Option, + b64buf: &mut Vec, +) -> Result)>, ()>, Error> { + let line = if let Some(line) = next_line { + line + } else { + // EOF + return match section.take() { + Some(label) => Err(Error::MissingSectionEnd { + end_marker: label.as_ref().to_vec(), + }), + None => Ok(ControlFlow::Break(None)), + }; + }; + + if line.starts_with(b"-----BEGIN ") { + let (mut trailer, mut pos) = (0, line.len()); + for (i, &b) in line.iter().enumerate().rev() { + match b { + b'-' => { + trailer += 1; + pos = i; + } + b'\n' | b'\r' | b' ' => continue, + _ => break, + } + } + + if trailer != 5 { + return Err(Error::IllegalSectionStart { + line: line.to_vec(), + }); + } + + let ty = &line[11..pos]; + *section = Some(SectionLabel::from(ty)); + return Ok(ControlFlow::Continue(())); + } + + if let Some(label) = section.as_ref() { + if label.is_end(line) { + let kind = match label { + SectionLabel::Known(kind) => *kind, + // unhandled section: have caller try again + SectionLabel::Unknown(_) => { + *section = None; + b64buf.clear(); + return Ok(ControlFlow::Continue(())); + } + }; + + let mut der = vec![0u8; base64::decoded_length(b64buf.len())]; + let der_len = match kind.secret() { + true => base64::decode_secret(b64buf, &mut der), + false => base64::decode_public(b64buf, &mut der), + } + .map_err(|err| Error::Base64Decode(format!("{err:?}")))? + .len(); + + der.truncate(der_len); + + return Ok(ControlFlow::Break(Some((kind, der)))); + } + } + + if section.is_some() { + b64buf.extend(line); + if b64buf.len() > MAX_PEM_SECTION_SIZE { + return Err(Error::SectionTooLarge); + } + } + + Ok(ControlFlow::Continue(())) +} + +// We've seen CRLs of 100MB (DER) / ~135MB (PEM) in the wild. +// 256MB seems like an OK upper bound. +const MAX_PEM_SECTION_SIZE: usize = 256 * 1024 * 1024; + +enum SectionLabel { + Known(SectionKind), + Unknown(Vec), +} + +impl SectionLabel { + fn is_end(&self, line: &[u8]) -> bool { + let rest = match line.strip_prefix(b"-----END ") { + Some(rest) => rest, + None => return false, + }; + + let ty = match self { + Self::Known(kind) => kind.as_slice(), + Self::Unknown(ty) => ty, + }; + + let rest = match rest.strip_prefix(ty) { + Some(rest) => rest, + None => return false, + }; + + rest.starts_with(b"-----") + } +} + +impl From<&[u8]> for SectionLabel { + fn from(value: &[u8]) -> Self { + match SectionKind::try_from(value) { + Ok(kind) => Self::Known(kind), + Err(_) => Self::Unknown(value.to_vec()), + } + } +} + +impl AsRef<[u8]> for SectionLabel { + fn as_ref(&self) -> &[u8] { + match self { + Self::Known(kind) => kind.as_slice(), + Self::Unknown(ty) => ty, + } + } +} + +/// A single recognised section in a PEM file. +#[non_exhaustive] +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum SectionKind { + /// A DER-encoded x509 certificate. + /// + /// Appears as "CERTIFICATE" in PEM files. + Certificate, + + /// A DER-encoded Subject Public Key Info; as specified in RFC 7468. + /// + /// Appears as "PUBLIC KEY" in PEM files. + PublicKey, + + /// A DER-encoded plaintext RSA private key; as specified in PKCS #1/RFC 3447 + /// + /// Appears as "RSA PRIVATE KEY" in PEM files. + RsaPrivateKey, + + /// A DER-encoded plaintext private key; as specified in PKCS #8/RFC 5958 + /// + /// Appears as "PRIVATE KEY" in PEM files. + PrivateKey, + + /// A Sec1-encoded plaintext private key; as specified in RFC 5915 + /// + /// Appears as "EC PRIVATE KEY" in PEM files. + EcPrivateKey, + + /// A Certificate Revocation List; as specified in RFC 5280 + /// + /// Appears as "X509 CRL" in PEM files. + Crl, + + /// A Certificate Signing Request; as specified in RFC 2986 + /// + /// Appears as "CERTIFICATE REQUEST" in PEM files. + Csr, + + /// An EchConfigList structure, as specified in + /// . + /// + /// Appears as "ECHCONFIG" in PEM files. + EchConfigList, +} + +impl SectionKind { + const fn secret(&self) -> bool { + match self { + Self::RsaPrivateKey | Self::PrivateKey | Self::EcPrivateKey => true, + Self::Certificate | Self::PublicKey | Self::Crl | Self::Csr | Self::EchConfigList => { + false + } + } + } + + fn as_slice(&self) -> &'static [u8] { + match self { + Self::Certificate => b"CERTIFICATE", + Self::PublicKey => b"PUBLIC KEY", + Self::RsaPrivateKey => b"RSA PRIVATE KEY", + Self::PrivateKey => b"PRIVATE KEY", + Self::EcPrivateKey => b"EC PRIVATE KEY", + Self::Crl => b"X509 CRL", + Self::Csr => b"CERTIFICATE REQUEST", + Self::EchConfigList => b"ECHCONFIG", + } + } +} + +impl TryFrom<&[u8]> for SectionKind { + type Error = (); + + fn try_from(value: &[u8]) -> Result { + Ok(match value { + b"CERTIFICATE" => Self::Certificate, + b"PUBLIC KEY" => Self::PublicKey, + b"RSA PRIVATE KEY" => Self::RsaPrivateKey, + b"PRIVATE KEY" => Self::PrivateKey, + b"EC PRIVATE KEY" => Self::EcPrivateKey, + b"X509 CRL" => Self::Crl, + b"CERTIFICATE REQUEST" => Self::Csr, + b"ECHCONFIG" => Self::EchConfigList, + _ => return Err(()), + }) + } +} + +/// Errors that may arise when parsing the contents of a PEM file +#[non_exhaustive] +#[derive(Debug)] +pub enum Error { + /// a section is missing its "END marker" line + MissingSectionEnd { + /// the expected "END marker" line that was not found + end_marker: Vec, + }, + + /// syntax error found in the line that starts a new section + IllegalSectionStart { + /// line that contains the syntax error + line: Vec, + }, + + /// base64 decode error + Base64Decode(String), + + /// I/O errors, from APIs that accept `std::io` types. + #[cfg(feature = "std")] + Io(io::Error), + + /// No items found of desired type + NoItemsFound, + + /// PEM section exceeds maximum allowed size of 256 MB + SectionTooLarge, +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::MissingSectionEnd { end_marker } => { + write!(f, "missing section end marker: {end_marker:?}") + } + Self::IllegalSectionStart { line } => { + write!(f, "illegal section start: {line:?}") + } + Self::Base64Decode(e) => write!(f, "base64 decode error: {e}"), + #[cfg(feature = "std")] + Self::Io(e) => write!(f, "I/O error: {e}"), + Self::NoItemsFound => write!(f, "no items found"), + Self::SectionTooLarge => write!(f, "PEM section exceeds maximum allowed size of 10 MB"), + } + } +} + +#[cfg(feature = "std")] +impl std::error::Error for Error {} + +// Ported from https://github.com/rust-lang/rust/blob/91cfcb021935853caa06698b759c293c09d1e96a/library/std/src/io/mod.rs#L1990 and +// modified to look for our accepted newlines. +#[cfg(feature = "std")] +fn read_until_newline(r: &mut R, buf: &mut Vec) -> io::Result { + let mut read = 0; + loop { + let (done, used) = { + let available = match r.fill_buf() { + Ok(n) => n, + Err(ref e) if e.kind() == ErrorKind::Interrupted => continue, + Err(e) => return Err(e), + }; + match available + .iter() + .copied() + .position(|b| b == b'\n' || b == b'\r') + { + Some(i) => { + buf.extend_from_slice(&available[..=i]); + (true, i + 1) + } + None => { + buf.extend_from_slice(available); + (false, available.len()) + } + } + }; + r.consume(used); + read += used; + if done || used == 0 { + return Ok(read); + } + } +} diff --git a/http/vendor/rustls-pki-types/src/server_name.rs b/http/vendor/rustls-pki-types/src/server_name.rs new file mode 100644 index 0000000..6e8fabc --- /dev/null +++ b/http/vendor/rustls-pki-types/src/server_name.rs @@ -0,0 +1,1214 @@ +//! DNS name validation according to RFC1035, but with underscores allowed. + +#[cfg(all(feature = "alloc", feature = "std"))] +use alloc::borrow::Cow; +#[cfg(feature = "alloc")] +use alloc::string::{String, ToString}; +use core::hash::{Hash, Hasher}; +use core::{fmt, mem, str}; +#[cfg(feature = "std")] +use std::error::Error as StdError; + +/// Encodes ways a client can know the expected name of the server. +/// +/// This currently covers knowing the DNS name of the server, but +/// will be extended in the future to supporting privacy-preserving names +/// for the server ("ECH"). For this reason this enum is `non_exhaustive`. +/// +/// # Making one +/// +/// If you have a DNS name as a `&str`, this type implements `TryFrom<&str>`, +/// so you can do: +/// +/// ``` +/// # use rustls_pki_types::ServerName; +/// ServerName::try_from("example.com").expect("invalid DNS name"); +/// ``` +/// +/// If you have an owned `String`, you can use `TryFrom` directly: +/// +/// ``` +/// # use rustls_pki_types::ServerName; +/// let name = "example.com".to_string(); +/// #[cfg(feature = "alloc")] +/// ServerName::try_from(name).expect("invalid DNS name"); +/// ``` +/// +/// which will yield a `ServerName<'static>` if successful. +/// +/// or, alternatively... +/// +/// ``` +/// # use rustls_pki_types::ServerName; +/// let x: ServerName = "example.com".try_into().expect("invalid DNS name"); +/// ``` +#[non_exhaustive] +#[derive(Clone, Eq, Hash, PartialEq)] +pub enum ServerName<'a> { + /// The server is identified by a DNS name. The name + /// is sent in the TLS Server Name Indication (SNI) + /// extension. + DnsName(DnsName<'a>), + + /// The server is identified by an IP address. SNI is not + /// done. + IpAddress(IpAddr), +} + +impl ServerName<'_> { + /// Produce an owned `ServerName` from this (potentially borrowed) `ServerName`. + #[cfg(feature = "alloc")] + pub fn to_owned(&self) -> ServerName<'static> { + match self { + Self::DnsName(d) => ServerName::DnsName(d.to_owned()), + Self::IpAddress(i) => ServerName::IpAddress(*i), + } + } + + /// Return the string representation of this `ServerName`. + /// + /// In the case of a `ServerName::DnsName` instance, this function returns a borrowed `str`. + /// For a `ServerName::IpAddress` instance it returns an allocated `String`. + #[cfg(feature = "std")] + pub fn to_str(&self) -> Cow<'_, str> { + match self { + Self::DnsName(d) => d.as_ref().into(), + Self::IpAddress(i) => std::net::IpAddr::from(*i).to_string().into(), + } + } +} + +impl fmt::Debug for ServerName<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::DnsName(d) => f.debug_tuple("DnsName").field(&d.as_ref()).finish(), + Self::IpAddress(i) => f.debug_tuple("IpAddress").field(i).finish(), + } + } +} + +#[cfg(feature = "alloc")] +impl TryFrom for ServerName<'static> { + type Error = InvalidDnsNameError; + + fn try_from(value: String) -> Result { + match DnsName::try_from_string(value) { + Ok(dns) => Ok(Self::DnsName(dns)), + Err(value) => match IpAddr::try_from(value.as_str()) { + Ok(ip) => Ok(Self::IpAddress(ip)), + Err(_) => Err(InvalidDnsNameError), + }, + } + } +} + +impl<'a> TryFrom<&'a [u8]> for ServerName<'a> { + type Error = InvalidDnsNameError; + + fn try_from(value: &'a [u8]) -> Result { + match str::from_utf8(value) { + Ok(s) => Self::try_from(s), + Err(_) => Err(InvalidDnsNameError), + } + } +} + +/// Attempt to make a ServerName from a string by parsing as a DNS name or IP address. +impl<'a> TryFrom<&'a str> for ServerName<'a> { + type Error = InvalidDnsNameError; + fn try_from(s: &'a str) -> Result { + match DnsName::try_from(s) { + Ok(dns) => Ok(Self::DnsName(dns)), + Err(InvalidDnsNameError) => match IpAddr::try_from(s) { + Ok(ip) => Ok(Self::IpAddress(ip)), + Err(_) => Err(InvalidDnsNameError), + }, + } + } +} + +impl From for ServerName<'_> { + fn from(addr: IpAddr) -> Self { + Self::IpAddress(addr) + } +} + +#[cfg(feature = "std")] +impl From for ServerName<'_> { + fn from(addr: std::net::IpAddr) -> Self { + Self::IpAddress(addr.into()) + } +} + +impl From for ServerName<'_> { + fn from(v4: Ipv4Addr) -> Self { + Self::IpAddress(IpAddr::V4(v4)) + } +} + +impl From for ServerName<'_> { + fn from(v6: Ipv6Addr) -> Self { + Self::IpAddress(IpAddr::V6(v6)) + } +} + +#[cfg(feature = "std")] +impl From for ServerName<'_> { + fn from(v4: std::net::Ipv4Addr) -> Self { + Self::IpAddress(IpAddr::V4(v4.into())) + } +} + +#[cfg(feature = "std")] +impl From for ServerName<'_> { + fn from(v6: std::net::Ipv6Addr) -> Self { + Self::IpAddress(IpAddr::V6(v6.into())) + } +} + +impl<'a> From> for ServerName<'a> { + fn from(dns_name: DnsName<'a>) -> Self { + Self::DnsName(dns_name) + } +} + +/// A type which encapsulates a string (borrowed or owned) that is a syntactically valid DNS name. +#[derive(Clone, Debug, Eq, Hash, PartialEq)] +pub struct DnsName<'a>(DnsNameInner<'a>); + +impl<'a> DnsName<'a> { + /// Produce a borrowed `DnsName` from this owned `DnsName`. + pub fn borrow(&'a self) -> Self { + Self(match self { + Self(DnsNameInner::Borrowed(s)) => DnsNameInner::Borrowed(s), + #[cfg(feature = "alloc")] + Self(DnsNameInner::Owned(s)) => DnsNameInner::Borrowed(s.as_str()), + }) + } + + /// Copy this object to produce an owned `DnsName`, smashing the case to lowercase + /// in one operation. + #[cfg(feature = "alloc")] + pub fn to_lowercase_owned(&self) -> DnsName<'static> { + DnsName(DnsNameInner::Owned(self.as_ref().to_ascii_lowercase())) + } + + /// Produce an owned `DnsName` from this (potentially borrowed) `DnsName`. + #[cfg(feature = "alloc")] + pub fn to_owned(&self) -> DnsName<'static> { + DnsName(DnsNameInner::Owned(match self { + Self(DnsNameInner::Borrowed(s)) => s.to_string(), + #[cfg(feature = "alloc")] + Self(DnsNameInner::Owned(s)) => s.clone(), + })) + } + + #[cfg(feature = "alloc")] + fn try_from_string(s: String) -> Result { + match validate(s.as_bytes()) { + Ok(_) => Ok(Self(DnsNameInner::Owned(s))), + Err(_) => Err(s), + } + } + + /// Produces a borrowed [`DnsName`] from a borrowed [`str`]. + pub const fn try_from_str(s: &str) -> Result, InvalidDnsNameError> { + match validate(s.as_bytes()) { + Ok(_) => Ok(DnsName(DnsNameInner::Borrowed(s))), + Err(err) => Err(err), + } + } +} + +#[cfg(feature = "alloc")] +impl TryFrom for DnsName<'static> { + type Error = InvalidDnsNameError; + + fn try_from(value: String) -> Result { + Self::try_from_string(value).map_err(|_| InvalidDnsNameError) + } +} + +impl<'a> TryFrom<&'a str> for DnsName<'a> { + type Error = InvalidDnsNameError; + + fn try_from(value: &'a str) -> Result { + DnsName::try_from_str(value) + } +} + +impl<'a> TryFrom<&'a [u8]> for DnsName<'a> { + type Error = InvalidDnsNameError; + + fn try_from(value: &'a [u8]) -> Result { + validate(value)?; + Ok(Self(DnsNameInner::Borrowed(str::from_utf8(value).unwrap()))) + } +} + +impl AsRef for DnsName<'_> { + fn as_ref(&self) -> &str { + match self { + Self(DnsNameInner::Borrowed(s)) => s, + #[cfg(feature = "alloc")] + Self(DnsNameInner::Owned(s)) => s.as_str(), + } + } +} + +#[derive(Clone, Eq)] +enum DnsNameInner<'a> { + Borrowed(&'a str), + #[cfg(feature = "alloc")] + Owned(String), +} + +impl PartialEq for DnsNameInner<'_> { + fn eq(&self, other: &Self) -> bool { + match (self, other) { + (Self::Borrowed(s), Self::Borrowed(o)) => s.eq_ignore_ascii_case(o), + #[cfg(feature = "alloc")] + (Self::Borrowed(s), Self::Owned(o)) => s.eq_ignore_ascii_case(o.as_str()), + #[cfg(feature = "alloc")] + (Self::Owned(s), Self::Borrowed(o)) => s.eq_ignore_ascii_case(o), + #[cfg(feature = "alloc")] + (Self::Owned(s), Self::Owned(o)) => s.eq_ignore_ascii_case(o.as_str()), + } + } +} + +impl Hash for DnsNameInner<'_> { + fn hash(&self, state: &mut H) { + let s = match self { + Self::Borrowed(s) => s, + #[cfg(feature = "alloc")] + Self::Owned(s) => s.as_str(), + }; + + s.chars().for_each(|c| c.to_ascii_lowercase().hash(state)); + } +} + +impl fmt::Debug for DnsNameInner<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::Borrowed(s) => f.write_fmt(format_args!("{s:?}")), + #[cfg(feature = "alloc")] + Self::Owned(s) => f.write_fmt(format_args!("{s:?}")), + } + } +} + +/// The provided input could not be parsed because +/// it is not a syntactically-valid DNS Name. +#[allow(clippy::exhaustive_structs)] +#[derive(Debug)] +pub struct InvalidDnsNameError; + +impl fmt::Display for InvalidDnsNameError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str("invalid dns name") + } +} + +#[cfg(feature = "std")] +impl StdError for InvalidDnsNameError {} + +const fn validate(input: &[u8]) -> Result<(), InvalidDnsNameError> { + enum State { + Start, + Next, + NumericOnly { len: usize }, + NextAfterNumericOnly, + Subsequent { len: usize }, + Hyphen { len: usize }, + } + + use State::*; + let mut state = Start; + + /// "Labels must be 63 characters or less." + const MAX_LABEL_LENGTH: usize = 63; + + /// https://devblogs.microsoft.com/oldnewthing/20120412-00/?p=7873 + const MAX_NAME_LENGTH: usize = 253; + + if input.len() > MAX_NAME_LENGTH { + return Err(InvalidDnsNameError); + } + + let mut idx = 0; + while idx < input.len() { + let ch = input[idx]; + state = match (state, ch) { + (Start | Next | NextAfterNumericOnly | Hyphen { .. }, b'.') => { + return Err(InvalidDnsNameError); + } + (Subsequent { .. }, b'.') => Next, + (NumericOnly { .. }, b'.') => NextAfterNumericOnly, + (Subsequent { len } | NumericOnly { len } | Hyphen { len }, _) + if len >= MAX_LABEL_LENGTH => + { + return Err(InvalidDnsNameError); + } + (Start | Next | NextAfterNumericOnly, b'0'..=b'9') => NumericOnly { len: 1 }, + (NumericOnly { len }, b'0'..=b'9') => NumericOnly { len: len + 1 }, + (Start | Next | NextAfterNumericOnly, b'a'..=b'z' | b'A'..=b'Z' | b'_') => { + Subsequent { len: 1 } + } + (Subsequent { len } | NumericOnly { len } | Hyphen { len }, b'-') => { + Hyphen { len: len + 1 } + } + ( + Subsequent { len } | NumericOnly { len } | Hyphen { len }, + b'a'..=b'z' | b'A'..=b'Z' | b'_' | b'0'..=b'9', + ) => Subsequent { len: len + 1 }, + _ => return Err(InvalidDnsNameError), + }; + idx += 1; + } + + if matches!( + state, + Start | Hyphen { .. } | NumericOnly { .. } | NextAfterNumericOnly + ) { + return Err(InvalidDnsNameError); + } + + Ok(()) +} + +/// `no_std` implementation of `std::net::IpAddr`. +/// +/// Note: because we intend to replace this type with `core::net::IpAddr` as soon as it is +/// stabilized, the identity of this type should not be considered semver-stable. However, the +/// attached interfaces are stable; they form a subset of those provided by `core::net::IpAddr`. +#[allow(clippy::exhaustive_enums)] +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] +pub enum IpAddr { + /// An Ipv4 address. + V4(Ipv4Addr), + /// An Ipv6 address. + V6(Ipv6Addr), +} + +impl TryFrom<&str> for IpAddr { + type Error = AddrParseError; + + fn try_from(value: &str) -> Result { + match Ipv4Addr::try_from(value) { + Ok(v4) => Ok(Self::V4(v4)), + Err(_) => match Ipv6Addr::try_from(value) { + Ok(v6) => Ok(Self::V6(v6)), + Err(e) => Err(e), + }, + } + } +} + +#[cfg(feature = "std")] +impl From for IpAddr { + fn from(addr: std::net::IpAddr) -> Self { + match addr { + std::net::IpAddr::V4(v4) => Self::V4(v4.into()), + std::net::IpAddr::V6(v6) => Self::V6(v6.into()), + } + } +} + +#[cfg(feature = "std")] +impl From for std::net::IpAddr { + fn from(value: IpAddr) -> Self { + match value { + IpAddr::V4(v4) => Self::from(std::net::Ipv4Addr::from(v4)), + IpAddr::V6(v6) => Self::from(std::net::Ipv6Addr::from(v6)), + } + } +} + +#[cfg(feature = "std")] +impl From for IpAddr { + fn from(v4: std::net::Ipv4Addr) -> Self { + Self::V4(v4.into()) + } +} + +#[cfg(feature = "std")] +impl From for IpAddr { + fn from(v6: std::net::Ipv6Addr) -> Self { + Self::V6(v6.into()) + } +} + +/// `no_std` implementation of `std::net::Ipv4Addr`. +/// +/// Note: because we intend to replace this type with `core::net::Ipv4Addr` as soon as it is +/// stabilized, the identity of this type should not be considered semver-stable. However, the +/// attached interfaces are stable; they form a subset of those provided by `core::net::Ipv4Addr`. +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] +pub struct Ipv4Addr([u8; 4]); + +impl From<[u8; 4]> for Ipv4Addr { + fn from(value: [u8; 4]) -> Self { + Self(value) + } +} + +impl TryFrom<&str> for Ipv4Addr { + type Error = AddrParseError; + + fn try_from(value: &str) -> Result { + // don't try to parse if too long + if value.len() > 15 { + Err(AddrParseError(AddrKind::Ipv4)) + } else { + Parser::new(value.as_bytes()).parse_with(|p| p.read_ipv4_addr(), AddrKind::Ipv4) + } + } +} + +#[cfg(feature = "std")] +impl From for Ipv4Addr { + fn from(addr: std::net::Ipv4Addr) -> Self { + Self(addr.octets()) + } +} + +#[cfg(feature = "std")] +impl From for std::net::Ipv4Addr { + fn from(value: Ipv4Addr) -> Self { + Self::from(value.0) + } +} + +impl AsRef<[u8; 4]> for Ipv4Addr { + fn as_ref(&self) -> &[u8; 4] { + &self.0 + } +} + +/// `no_std` implementation of `std::net::Ipv6Addr`. +/// +/// Note: because we intend to replace this type with `core::net::Ipv6Addr` as soon as it is +/// stabilized, the identity of this type should not be considered semver-stable. However, the +/// attached interfaces are stable; they form a subset of those provided by `core::net::Ipv6Addr`. +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] +pub struct Ipv6Addr([u8; 16]); + +impl TryFrom<&str> for Ipv6Addr { + type Error = AddrParseError; + + fn try_from(value: &str) -> Result { + Parser::new(value.as_bytes()).parse_with(|p| p.read_ipv6_addr(), AddrKind::Ipv6) + } +} + +impl From<[u16; 8]> for Ipv6Addr { + fn from(value: [u16; 8]) -> Self { + // Adapted from `std::net::Ipv6Addr::new()` + let addr16 = [ + value[0].to_be(), + value[1].to_be(), + value[2].to_be(), + value[3].to_be(), + value[4].to_be(), + value[5].to_be(), + value[6].to_be(), + value[7].to_be(), + ]; + Self( + // All elements in `addr16` are big endian. + // SAFETY: `[u16; 8]` is always safe to transmute to `[u8; 16]`. + unsafe { mem::transmute::<[u16; 8], [u8; 16]>(addr16) }, + ) + } +} + +#[cfg(feature = "std")] +impl From for Ipv6Addr { + fn from(addr: std::net::Ipv6Addr) -> Self { + Self(addr.octets()) + } +} + +#[cfg(feature = "std")] +impl From for std::net::Ipv6Addr { + fn from(value: Ipv6Addr) -> Self { + Self::from(value.0) + } +} + +impl AsRef<[u8; 16]> for Ipv6Addr { + fn as_ref(&self) -> &[u8; 16] { + &self.0 + } +} + +// Adapted from core, 2023-11-23 +// +// https://github.com/rust-lang/rust/blob/fc13ca6d70f7381513c22443fc5aaee1d151ea45/library/core/src/net/parser.rs#L34 +mod parser { + use super::{AddrParseError, Ipv4Addr, Ipv6Addr}; + + pub(super) struct Parser<'a> { + // Parsing as ASCII, so can use byte array. + state: &'a [u8], + } + + impl<'a> Parser<'a> { + pub(super) const fn new(input: &'a [u8]) -> Self { + Parser { state: input } + } + + /// Run a parser, and restore the pre-parse state if it fails. + fn read_atomically(&mut self, inner: F) -> Option + where + F: FnOnce(&mut Parser<'_>) -> Option, + { + let state = self.state; + let result = inner(self); + if result.is_none() { + self.state = state; + } + result + } + + /// Run a parser, but fail if the entire input wasn't consumed. + /// Doesn't run atomically. + pub(super) fn parse_with( + &mut self, + inner: F, + kind: AddrKind, + ) -> Result + where + F: FnOnce(&mut Parser<'_>) -> Option, + { + let result = inner(self); + if self.state.is_empty() { result } else { None }.ok_or(AddrParseError(kind)) + } + + /// Peek the next character from the input + fn peek_char(&self) -> Option { + self.state.first().map(|&b| char::from(b)) + } + + /// Read the next character from the input + fn read_char(&mut self) -> Option { + self.state.split_first().map(|(&b, tail)| { + self.state = tail; + char::from(b) + }) + } + + #[must_use] + /// Read the next character from the input if it matches the target. + fn read_given_char(&mut self, target: char) -> Option<()> { + self.read_atomically(|p| { + p.read_char() + .and_then(|c| if c == target { Some(()) } else { None }) + }) + } + + /// Helper for reading separators in an indexed loop. Reads the separator + /// character iff index > 0, then runs the parser. When used in a loop, + /// the separator character will only be read on index > 0 (see + /// read_ipv4_addr for an example) + fn read_separator(&mut self, sep: char, index: usize, inner: F) -> Option + where + F: FnOnce(&mut Parser<'_>) -> Option, + { + self.read_atomically(move |p| { + if index > 0 { + p.read_given_char(sep)?; + } + inner(p) + }) + } + + // Read a number off the front of the input in the given radix, stopping + // at the first non-digit character or eof. Fails if the number has more + // digits than max_digits or if there is no number. + fn read_number( + &mut self, + radix: u32, + max_digits: Option, + allow_zero_prefix: bool, + ) -> Option { + self.read_atomically(move |p| { + let mut result = T::ZERO; + let mut digit_count = 0; + let has_leading_zero = p.peek_char() == Some('0'); + + while let Some(digit) = p.read_atomically(|p| p.read_char()?.to_digit(radix)) { + result = result.checked_mul(radix)?; + result = result.checked_add(digit)?; + digit_count += 1; + if let Some(max_digits) = max_digits { + if digit_count > max_digits { + return None; + } + } + } + + if digit_count == 0 || (!allow_zero_prefix && has_leading_zero && digit_count > 1) { + None + } else { + Some(result) + } + }) + } + + /// Read an IPv4 address. + pub(super) fn read_ipv4_addr(&mut self) -> Option { + self.read_atomically(|p| { + let mut groups = [0; 4]; + + for (i, slot) in groups.iter_mut().enumerate() { + *slot = p.read_separator('.', i, |p| { + // Disallow octal number in IP string. + // https://tools.ietf.org/html/rfc6943#section-3.1.1 + p.read_number(10, Some(3), false) + })?; + } + + Some(Ipv4Addr(groups)) + }) + } + + /// Read an IPv6 Address. + pub(super) fn read_ipv6_addr(&mut self) -> Option { + /// Read a chunk of an IPv6 address into `groups`. Returns the number + /// of groups read, along with a bool indicating if an embedded + /// trailing IPv4 address was read. Specifically, read a series of + /// colon-separated IPv6 groups (0x0000 - 0xFFFF), with an optional + /// trailing embedded IPv4 address. + fn read_groups(p: &mut Parser<'_>, groups: &mut [u16]) -> (usize, bool) { + let limit = groups.len(); + + for (i, slot) in groups.iter_mut().enumerate() { + // Try to read a trailing embedded IPv4 address. There must be + // at least two groups left. + if i < limit - 1 { + let ipv4 = p.read_separator(':', i, |p| p.read_ipv4_addr()); + + if let Some(v4_addr) = ipv4 { + let [one, two, three, four] = v4_addr.0; + groups[i] = u16::from_be_bytes([one, two]); + groups[i + 1] = u16::from_be_bytes([three, four]); + return (i + 2, true); + } + } + + let group = p.read_separator(':', i, |p| p.read_number(16, Some(4), true)); + + match group { + Some(g) => *slot = g, + None => return (i, false), + } + } + (groups.len(), false) + } + + self.read_atomically(|p| { + // Read the front part of the address; either the whole thing, or up + // to the first :: + let mut head = [0; 8]; + let (head_size, head_ipv4) = read_groups(p, &mut head); + + if head_size == 8 { + return Some(head.into()); + } + + // IPv4 part is not allowed before `::` + if head_ipv4 { + return None; + } + + // Read `::` if previous code parsed less than 8 groups. + // `::` indicates one or more groups of 16 bits of zeros. + p.read_given_char(':')?; + p.read_given_char(':')?; + + // Read the back part of the address. The :: must contain at least one + // set of zeroes, so our max length is 7. + let mut tail = [0; 7]; + let limit = 8 - (head_size + 1); + let (tail_size, _) = read_groups(p, &mut tail[..limit]); + + // Concat the head and tail of the IP address + head[(8 - tail_size)..8].copy_from_slice(&tail[..tail_size]); + + Some(head.into()) + }) + } + } + + trait ReadNumberHelper: Sized { + const ZERO: Self; + fn checked_mul(&self, other: u32) -> Option; + fn checked_add(&self, other: u32) -> Option; + } + + macro_rules! impl_helper { + ($($t:ty)*) => ($(impl ReadNumberHelper for $t { + const ZERO: Self = 0; + #[inline] + fn checked_mul(&self, other: u32) -> Option { + Self::checked_mul(*self, other.try_into().ok()?) + } + #[inline] + fn checked_add(&self, other: u32) -> Option { + Self::checked_add(*self, other.try_into().ok()?) + } + })*) + } + + impl_helper! { u8 u16 u32 } + + #[derive(Debug, Clone, Copy, Eq, PartialEq)] + pub(super) enum AddrKind { + Ipv4, + Ipv6, + } +} + +use parser::{AddrKind, Parser}; + +/// Failure to parse an IP address +#[derive(Debug, Clone, Copy, Eq, PartialEq)] +pub struct AddrParseError(AddrKind); + +impl fmt::Display for AddrParseError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(match self.0 { + AddrKind::Ipv4 => "invalid IPv4 address syntax", + AddrKind::Ipv6 => "invalid IPv6 address syntax", + }) + } +} + +#[cfg(feature = "std")] +impl ::std::error::Error for AddrParseError {} + +#[cfg(test)] +mod tests { + use super::*; + #[cfg(feature = "alloc")] + use alloc::format; + + #[cfg(feature = "alloc")] + static TESTS: &[(&str, bool)] = &[ + ("", false), + ("localhost", true), + ("LOCALHOST", true), + (".localhost", false), + ("..localhost", false), + ("1.2.3.4", false), + ("127.0.0.1", false), + ("absolute.", true), + ("absolute..", false), + ("multiple.labels.absolute.", true), + ("foo.bar.com", true), + ("infix-hyphen-allowed.com", true), + ("-prefixhypheninvalid.com", false), + ("suffixhypheninvalid--", false), + ("suffixhypheninvalid-.com", false), + ("foo.lastlabelendswithhyphen-", false), + ("infix_underscore_allowed.com", true), + ("_prefixunderscorevalid.com", true), + ("labelendswithnumber1.bar.com", true), + ("xn--bcher-kva.example", true), + ( + "sixtythreesixtythreesixtythreesixtythreesixtythreesixtythreesix.com", + true, + ), + ( + "sixtyfoursixtyfoursixtyfoursixtyfoursixtyfoursixtyfoursixtyfours.com", + false, + ), + ( + "012345678901234567890123456789012345678901234567890123456789012.com", + true, + ), + ( + "0123456789012345678901234567890123456789012345678901234567890123.com", + false, + ), + ( + "01234567890123456789012345678901234567890123456789012345678901-.com", + false, + ), + ( + "012345678901234567890123456789012345678901234567890123456789012-.com", + false, + ), + ("numeric-only-final-label.1", false), + ("numeric-only-final-label.absolute.1.", false), + ("1starts-with-number.com", true), + ("1Starts-with-number.com", true), + ("1.2.3.4.com", true), + ("123.numeric-only-first-label", true), + ("a123b.com", true), + ("numeric-only-middle-label.4.com", true), + ("1000-sans.badssl.com", true), + ( + "twohundredandfiftythreecharacters.twohundredandfiftythreecharacters.twohundredandfiftythreecharacters.twohundredandfiftythreecharacters.twohundredandfiftythreecharacters.twohundredandfiftythreecharacters.twohundredandfiftythreecharacters.twohundredandfi", + true, + ), + ( + "twohundredandfiftyfourcharacters.twohundredandfiftyfourcharacters.twohundredandfiftyfourcharacters.twohundredandfiftyfourcharacters.twohundredandfiftyfourcharacters.twohundredandfiftyfourcharacters.twohundredandfiftyfourcharacters.twohundredandfiftyfourc", + false, + ), + ]; + + #[cfg(feature = "alloc")] + #[test] + fn test_validation() { + for (input, expected) in TESTS { + #[cfg(feature = "std")] + println!("test: {input:?} expected valid? {expected:?}"); + let name_ref = DnsName::try_from(*input); + assert_eq!(*expected, name_ref.is_ok()); + let name = DnsName::try_from(input.to_string()); + assert_eq!(*expected, name.is_ok()); + } + } + + #[cfg(feature = "alloc")] + #[test] + fn error_is_debug() { + assert_eq!(format!("{InvalidDnsNameError:?}"), "InvalidDnsNameError"); + } + + #[cfg(feature = "alloc")] + #[test] + fn error_is_display() { + assert_eq!(format!("{InvalidDnsNameError}"), "invalid dns name"); + } + + #[cfg(feature = "alloc")] + #[test] + fn dns_name_is_debug() { + let example = DnsName::try_from("example.com".to_string()).unwrap(); + assert_eq!(format!("{example:?}"), "DnsName(\"example.com\")"); + } + + #[cfg(feature = "alloc")] + #[test] + fn dns_name_traits() { + let example = DnsName::try_from("example.com".to_string()).unwrap(); + assert_eq!(example, example); // PartialEq + + #[cfg(feature = "std")] + { + use std::collections::HashSet; + let mut h = HashSet::>::new(); + h.insert(example); + } + } + + #[cfg(feature = "alloc")] + #[test] + fn try_from_ascii_rejects_bad_utf8() { + assert_eq!( + format!("{:?}", DnsName::try_from(&b"\x80"[..])), + "Err(InvalidDnsNameError)" + ); + } + + const fn ipv4_address( + ip_address: &str, + octets: [u8; 4], + ) -> (&str, Result) { + (ip_address, Ok(Ipv4Addr(octets))) + } + + const IPV4_ADDRESSES: &[(&str, Result)] = &[ + // Valid IPv4 addresses + ipv4_address("0.0.0.0", [0, 0, 0, 0]), + ipv4_address("1.1.1.1", [1, 1, 1, 1]), + ipv4_address("205.0.0.0", [205, 0, 0, 0]), + ipv4_address("0.205.0.0", [0, 205, 0, 0]), + ipv4_address("0.0.205.0", [0, 0, 205, 0]), + ipv4_address("0.0.0.205", [0, 0, 0, 205]), + ipv4_address("0.0.0.20", [0, 0, 0, 20]), + // Invalid IPv4 addresses + ("", Err(AddrParseError(AddrKind::Ipv4))), + ("...", Err(AddrParseError(AddrKind::Ipv4))), + (".0.0.0.0", Err(AddrParseError(AddrKind::Ipv4))), + ("0.0.0.0.", Err(AddrParseError(AddrKind::Ipv4))), + ("0.0.0", Err(AddrParseError(AddrKind::Ipv4))), + ("0.0.0.", Err(AddrParseError(AddrKind::Ipv4))), + ("256.0.0.0", Err(AddrParseError(AddrKind::Ipv4))), + ("0.256.0.0", Err(AddrParseError(AddrKind::Ipv4))), + ("0.0.256.0", Err(AddrParseError(AddrKind::Ipv4))), + ("0.0.0.256", Err(AddrParseError(AddrKind::Ipv4))), + ("1..1.1.1", Err(AddrParseError(AddrKind::Ipv4))), + ("1.1..1.1", Err(AddrParseError(AddrKind::Ipv4))), + ("1.1.1..1", Err(AddrParseError(AddrKind::Ipv4))), + ("025.0.0.0", Err(AddrParseError(AddrKind::Ipv4))), + ("0.025.0.0", Err(AddrParseError(AddrKind::Ipv4))), + ("0.0.025.0", Err(AddrParseError(AddrKind::Ipv4))), + ("0.0.0.025", Err(AddrParseError(AddrKind::Ipv4))), + ("1234.0.0.0", Err(AddrParseError(AddrKind::Ipv4))), + ("0.1234.0.0", Err(AddrParseError(AddrKind::Ipv4))), + ("0.0.1234.0", Err(AddrParseError(AddrKind::Ipv4))), + ("0.0.0.1234", Err(AddrParseError(AddrKind::Ipv4))), + ]; + + #[test] + fn parse_ipv4_address_test() { + for &(ip_address, expected_result) in IPV4_ADDRESSES { + assert_eq!(Ipv4Addr::try_from(ip_address), expected_result); + } + } + + const fn ipv6_address( + ip_address: &str, + octets: [u8; 16], + ) -> (&str, Result) { + (ip_address, Ok(Ipv6Addr(octets))) + } + + const IPV6_ADDRESSES: &[(&str, Result)] = &[ + // Valid IPv6 addresses + ipv6_address( + "2a05:d018:076c:b685:e8ab:afd3:af51:3aed", + [ + 0x2a, 0x05, 0xd0, 0x18, 0x07, 0x6c, 0xb6, 0x85, 0xe8, 0xab, 0xaf, 0xd3, 0xaf, 0x51, + 0x3a, 0xed, + ], + ), + ipv6_address( + "2A05:D018:076C:B685:E8AB:AFD3:AF51:3AED", + [ + 0x2a, 0x05, 0xd0, 0x18, 0x07, 0x6c, 0xb6, 0x85, 0xe8, 0xab, 0xaf, 0xd3, 0xaf, 0x51, + 0x3a, 0xed, + ], + ), + ipv6_address( + "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", + [ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, + ], + ), + ipv6_address( + "FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF", + [ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, + ], + ), + ipv6_address( + "FFFF:ffff:ffff:ffff:ffff:ffff:ffff:ffff", + [ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, + ], + ), + // Wrong hexadecimal characters on different positions + ( + "ffgf:ffff:ffff:ffff:ffff:ffff:ffff:ffff", + Err(AddrParseError(AddrKind::Ipv6)), + ), + ( + "ffff:gfff:ffff:ffff:ffff:ffff:ffff:ffff", + Err(AddrParseError(AddrKind::Ipv6)), + ), + ( + "ffff:ffff:fffg:ffff:ffff:ffff:ffff:ffff", + Err(AddrParseError(AddrKind::Ipv6)), + ), + ( + "ffff:ffff:ffff:ffgf:ffff:ffff:ffff:ffff", + Err(AddrParseError(AddrKind::Ipv6)), + ), + ( + "ffff:ffff:ffff:ffff:gfff:ffff:ffff:ffff", + Err(AddrParseError(AddrKind::Ipv6)), + ), + ( + "ffff:ffff:ffff:ffff:ffff:fgff:ffff:ffff", + Err(AddrParseError(AddrKind::Ipv6)), + ), + ( + "ffff:ffff:ffff:ffff:ffff:ffff:ffgf:ffff", + Err(AddrParseError(AddrKind::Ipv6)), + ), + ( + "ffff:ffff:ffff:ffff:ffff:ffff:ffgf:fffg", + Err(AddrParseError(AddrKind::Ipv6)), + ), + // Wrong colons on uncompressed addresses + ( + ":ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", + Err(AddrParseError(AddrKind::Ipv6)), + ), + ( + "ffff::ffff:ffff:ffff:ffff:ffff:ffff:ffff", + Err(AddrParseError(AddrKind::Ipv6)), + ), + ( + "ffff:ffff::ffff:ffff:ffff:ffff:ffff:ffff", + Err(AddrParseError(AddrKind::Ipv6)), + ), + ( + "ffff:ffff:ffff::ffff:ffff:ffff:ffff:ffff", + Err(AddrParseError(AddrKind::Ipv6)), + ), + ( + "ffff:ffff:ffff:ffff::ffff:ffff:ffff:ffff", + Err(AddrParseError(AddrKind::Ipv6)), + ), + ( + "ffff:ffff:ffff:ffff:ffff::ffff:ffff:ffff", + Err(AddrParseError(AddrKind::Ipv6)), + ), + ( + "ffff:ffff:ffff:ffff:ffff:ffff::ffff:ffff", + Err(AddrParseError(AddrKind::Ipv6)), + ), + ( + "ffff:ffff:ffff:ffff:ffff:ffff:ffff::ffff", + Err(AddrParseError(AddrKind::Ipv6)), + ), + // More colons than allowed + ( + "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff:", + Err(AddrParseError(AddrKind::Ipv6)), + ), + ( + "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", + Err(AddrParseError(AddrKind::Ipv6)), + ), + // v Invalid hexadecimal + ( + "ga05:d018:076c:b685:e8ab:afd3:af51:3aed", + Err(AddrParseError(AddrKind::Ipv6)), + ), + // Cannot start with colon + ( + ":a05:d018:076c:b685:e8ab:afd3:af51:3aed", + Err(AddrParseError(AddrKind::Ipv6)), + ), + // Cannot end with colon + ( + "2a05:d018:076c:b685:e8ab:afd3:af51:3ae:", + Err(AddrParseError(AddrKind::Ipv6)), + ), + // Cannot have more than seven colons + ( + "2a05:d018:076c:b685:e8ab:afd3:af51:3a::", + Err(AddrParseError(AddrKind::Ipv6)), + ), + // Cannot contain two colons in a row + ( + "2a05::018:076c:b685:e8ab:afd3:af51:3aed", + Err(AddrParseError(AddrKind::Ipv6)), + ), + // v Textual block size is longer + ( + "2a056:d018:076c:b685:e8ab:afd3:af51:3ae", + Err(AddrParseError(AddrKind::Ipv6)), + ), + // v Textual block size is shorter + ( + "2a0:d018:076c:b685:e8ab:afd3:af51:3aed ", + Err(AddrParseError(AddrKind::Ipv6)), + ), + // Shorter IPv6 address + ( + "d018:076c:b685:e8ab:afd3:af51:3aed", + Err(AddrParseError(AddrKind::Ipv6)), + ), + // Longer IPv6 address + ( + "2a05:d018:076c:b685:e8ab:afd3:af51:3aed3aed", + Err(AddrParseError(AddrKind::Ipv6)), + ), + ]; + + #[test] + fn parse_ipv6_address_test() { + for &(ip_address, expected_result) in IPV6_ADDRESSES { + assert_eq!(Ipv6Addr::try_from(ip_address), expected_result); + } + } + + #[test] + fn try_from_ascii_ip_address_test() { + const IP_ADDRESSES: &[(&str, Result)] = &[ + // Valid IPv4 addresses + ("127.0.0.1", Ok(IpAddr::V4(Ipv4Addr([127, 0, 0, 1])))), + // Invalid IPv4 addresses + ( + // Ends with a dot; misses one octet + "127.0.0.", + Err(AddrParseError(AddrKind::Ipv6)), + ), + // Valid IPv6 addresses + ( + "0000:0000:0000:0000:0000:0000:0000:0001", + Ok(IpAddr::V6(Ipv6Addr([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + ]))), + ), + // Something else + ( + // A hostname + "example.com", + Err(AddrParseError(AddrKind::Ipv6)), + ), + ]; + for &(ip_address, expected_result) in IP_ADDRESSES { + assert_eq!(IpAddr::try_from(ip_address), expected_result) + } + } + + #[test] + fn try_from_ascii_str_ip_address_test() { + const IP_ADDRESSES: &[(&str, Result)] = &[ + // Valid IPv4 addresses + ("127.0.0.1", Ok(IpAddr::V4(Ipv4Addr([127, 0, 0, 1])))), + // Invalid IPv4 addresses + ( + // Ends with a dot; misses one octet + "127.0.0.", + Err(AddrParseError(AddrKind::Ipv6)), + ), + // Valid IPv6 addresses + ( + "0000:0000:0000:0000:0000:0000:0000:0001", + Ok(IpAddr::V6(Ipv6Addr([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + ]))), + ), + // Something else + ( + // A hostname + "example.com", + Err(AddrParseError(AddrKind::Ipv6)), + ), + ]; + for &(ip_address, expected_result) in IP_ADDRESSES { + assert_eq!(IpAddr::try_from(ip_address), expected_result) + } + } + + #[test] + #[cfg(feature = "std")] + fn to_str() { + let domain_str = "example.com"; + let domain_servername = ServerName::try_from(domain_str).unwrap(); + assert_eq!(domain_str, domain_servername.to_str()); + + let ipv4_str = "127.0.0.1"; + let ipv4_servername = ServerName::try_from("127.0.0.1").unwrap(); + assert_eq!(ipv4_str, ipv4_servername.to_str()); + + let ipv6_str = "::1"; + let ipv6_servername = ServerName::try_from(ipv6_str).unwrap(); + assert_eq!("::1", ipv6_servername.to_str()); + } +} diff --git a/http/vendor/rustls-webpki/.cargo-checksum.json b/http/vendor/rustls-webpki/.cargo-checksum.json new file mode 100644 index 0000000..d079439 --- /dev/null +++ b/http/vendor/rustls-webpki/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{".cargo_vcs_info.json":"27fe0c3d4d72dcbaf59fa2a7f9e34b1e056435f2d67591219b294a613e272bc0","Cargo.lock":"c821765eec9b1c6d6f55b7f9ada070f6be7504a82af2d1ee363fc38c3b04c2e1","Cargo.toml":"a9b2f60ecbca2b9e33449899b15e344c2003664c5901bec9b8ada33722c18285","Cargo.toml.orig":"35b44a3ba7e46cd4b05d678bd52de7698bd20846e019ca901b648065f0961474","LICENSE":"5b698ca13897be3afdb7174256fa1574f8c6892b8bea1a66dd6469d3fe27885a","README.md":"084c37ee4b35887c813373cb98f3712e20d42e238cd16b59bd90dd8ae870dbf2","src/alg_tests.rs":"aa05065896cebe413d8d03a57842e5c34d201f2b914d2ff16f351230d810f19f","src/aws_lc_rs_algs.rs":"f220ede4189835dbeb3d63d5f3629c59fb3d51651b19a3835eec73381c5f558d","src/cert.rs":"1a4da3c745a72f61e8e95f222fc5847cb4779a4de524f4d6d09ae1d25b27c001","src/crl/mod.rs":"6b59ca00ed53c0883ce13a36880636a1c41053013c9ced732859b0c1b3d60ff3","src/crl/types.rs":"ff0a08f92bcae303b4148cb40f267a2dbc99732afd52c70c261a8ecd2d6070ba","src/data/alg-rsa-pkcs1-sha256-absent-params.der":"269462d02de5597c547cc473cefb4471ee93d836c75d272a0e5a36863e96d228","src/data/alg-rsa-pkcs1-sha384-absent-params.der":"dc7e012a12d034dd581de85ad49913a020df7c8a684213f03629c1fd53dcf14f","src/data/alg-rsa-pkcs1-sha512-absent-params.der":"1c9021c531e93720d2539bd989fbd9f6ce34d24aa0b694c376a87c0a1ba9dd29","src/der.rs":"ed693c0410cb8e89e586de76682841156dc3825f9a4181ac7f425232d8640da0","src/end_entity.rs":"dcd6176df075627bbd38881bb1b729462721ecb53e7968d56b116a8532043c42","src/error.rs":"6d79c7ec3b9063e156670c4db7155eb04cdf67b82ea384bc33c1f2c7109a32fc","src/lib.rs":"4fc2b9e67c3b68fabf65d4aadda9ed3fea39e3af61e41ad40fe36bdd1cae52dd","src/ring_algs.rs":"f6b17aa2e26442b6c940c5bf4b8e431a9e74152ba8b0573a3f74b99a73ba5412","src/rpk_entity.rs":"29a59f4c5123fca851ff6b8a6a7f3120f2890df90d3169367f611dc05f31ed3b","src/signed_data.rs":"9edbc160fd6ec158bbcc67e408c2bc09078142c4feee3ce6e8dae6b7da806fe0","src/subject_name/dns_name.rs":"c5989e0e46973d8d6a3e94608aad7964089f25599c1f326a6ac30f85204c8328","src/subject_name/ip_address.rs":"e76e24bfb15d367732fccd4cc0ebae3bb3970d4a209b7c30a67263ab14200185","src/subject_name/mod.rs":"4415187af1bb98ac076d5a0e8b5f224f173bae006629bd35bb465cd0f11e7130","src/time.rs":"e92721be14ac2f99b4a9a28125947307bbb1f87136b64e2b51ea07644fafa7a6","src/trust_anchor.rs":"5a4a54b4525b710bfadb4c35f041700e965b51631d4b9b8d9842c157f057b5b1","src/verify_cert.rs":"235986cb11713f256caea24f29fece0c767896bf4a6de35764205cf1adb5fed9","src/x509.rs":"3c12557b2430268e0155094883e119414bd2e94776d757bfe5c38a3c3490958e"},"package":"61c429a8649f110dddef65e2a5ad240f747e85f7758a6bccc7e5777bd33f756e"} \ No newline at end of file diff --git a/http/vendor/rustls-webpki/.cargo_vcs_info.json b/http/vendor/rustls-webpki/.cargo_vcs_info.json new file mode 100644 index 0000000..b71601e --- /dev/null +++ b/http/vendor/rustls-webpki/.cargo_vcs_info.json @@ -0,0 +1,6 @@ +{ + "git": { + "sha1": "2879b2ce7a476181ac3050f73fe0835f04728e86" + }, + "path_in_vcs": "" +} \ No newline at end of file diff --git a/http/vendor/rustls-webpki/Cargo.lock b/http/vendor/rustls-webpki/Cargo.lock new file mode 100644 index 0000000..9f5c3a4 --- /dev/null +++ b/http/vendor/rustls-webpki/Cargo.lock @@ -0,0 +1,829 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + +[[package]] +name = "asn1-rs" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56624a96882bb8c26d61312ae18cb45868e5a9992ea73c58e45c3101e56a1e60" +dependencies = [ + "asn1-rs-derive", + "asn1-rs-impl", + "displaydoc", + "nom", + "num-traits", + "rusticata-macros", + "thiserror", + "time", +] + +[[package]] +name = "asn1-rs-derive" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3109e49b1e4909e9db6515a30c633684d68cdeaa252f215214cb4fa1a5bfee2c" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "asn1-rs-impl" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "aws-lc-fips-sys" +version = "0.13.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8bce4948d2520386c6d92a6ea2d472300257702242e5a1d01d6add52bd2e7c1" +dependencies = [ + "bindgen", + "cc", + "cmake", + "dunce", + "fs_extra", + "regex", +] + +[[package]] +name = "aws-lc-rs" +version = "1.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a054912289d18629dc78375ba2c3726a3afe3ff71b4edba9dedfca0e3446d1fc" +dependencies = [ + "aws-lc-fips-sys", + "aws-lc-sys", + "untrusted 0.7.1", + "zeroize", +] + +[[package]] +name = "aws-lc-sys" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa7e52a4c5c547c741610a2c6f123f3881e409b714cd27e6798ef020c514f0a" +dependencies = [ + "cc", + "cmake", + "dunce", + "fs_extra", +] + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bencher" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dfdb4953a096c551ce9ace855a604d702e6e62d77fac690575ae347571717f5" + +[[package]] +name = "bindgen" +version = "0.72.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895" +dependencies = [ + "bitflags", + "cexpr", + "clang-sys", + "itertools", + "log", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn", +] + +[[package]] +name = "bitflags" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af" + +[[package]] +name = "bzip2" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3a53fac24f34a81bc9954b5d6cfce0c21e18ec6959f44f56e8e90e4bb7c346c" +dependencies = [ + "libbz2-rs-sys", +] + +[[package]] +name = "cc" +version = "1.2.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a0dd1ca384932ff3641c8718a02769f1698e7563dc6974ffd03346116310423" +dependencies = [ + "find-msvc-tools", + "jobserver", + "libc", + "shlex", +] + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "clang-sys" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "cmake" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75443c44cd6b379beb8c5b45d85d0773baf31cce901fe7bb252f4eff3008ef7d" +dependencies = [ + "cc", +] + +[[package]] +name = "data-encoding" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7a1e2f27636f116493b8b860f5546edb47c8d8f8ea73e1d2a20be88e28d1fea" + +[[package]] +name = "der-parser" +version = "10.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07da5016415d5a3c4dd39b11ed26f915f52fc4e0dc197d87908bc916e51bc1a6" +dependencies = [ + "asn1-rs", + "displaydoc", + "nom", + "num-bigint", + "num-traits", + "rusticata-macros", +] + +[[package]] +name = "deranged" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" +dependencies = [ + "powerfmt", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "dunce" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" + +[[package]] +name = "either" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasip2", +] + +[[package]] +name = "glob" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" + +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "jobserver" +version = "0.1.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" +dependencies = [ + "getrandom 0.3.4", + "libc", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libbz2-rs-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c4a545a15244c7d945065b5d392b2d2d7f21526fba56ce51467b06ed445e8f7" + +[[package]] +name = "libc" +version = "0.2.183" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d" + +[[package]] +name = "libloading" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55" +dependencies = [ + "cfg-if", + "windows-link", +] + +[[package]] +name = "log" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" + +[[package]] +name = "memchr" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-conv" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf97ec579c3c42f953ef76dbf8d55ac91fb219dde70e49aa4a6b7d74e9919050" + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "oid-registry" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12f40cff3dde1b6087cc5d5f5d4d65712f34016a03ed60e9c08dcc392736b5b7" +dependencies = [ + "asn1-rs", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn", +] + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "rcgen" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10b99e0098aa4082912d4c649628623db6aba77335e4f4569ff5083a6448b32e" +dependencies = [ + "aws-lc-rs", + "rustls-pki-types", + "time", + "x509-parser", + "yasna", +] + +[[package]] +name = "regex" +version = "1.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.17", + "libc", + "untrusted 0.9.0", + "windows-sys", +] + +[[package]] +name = "rustc-hash" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" + +[[package]] +name = "rusticata-macros" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faf0c4a6ece9950b9abdb62b1cfcf2a68b3b67a10ba445b3bb85be2a293d0632" +dependencies = [ + "nom", +] + +[[package]] +name = "rustls-pki-types" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be040f8b0a225e40375822a563fa9524378b9d63112f53e19ffff34df5d33fdd" +dependencies = [ + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.13" +dependencies = [ + "aws-lc-rs", + "base64", + "bencher", + "bzip2", + "once_cell", + "rcgen", + "ring", + "rustls-pki-types", + "serde", + "serde_json", + "untrusted 0.9.0", + "x509-parser", +] + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "syn" +version = "2.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thiserror" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "time" +version = "0.3.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "743bd48c283afc0388f9b8827b976905fb217ad9e647fae3a379a9283c4def2c" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde_core", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca" + +[[package]] +name = "time-macros" +version = "0.2.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e70e4c5a0e0a8a4823ad65dfe1a6930e4f4d756dcd9dd7939022b5e8c501215" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.2+wasi-0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "wit-bindgen" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" + +[[package]] +name = "x509-parser" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d43b0f71ce057da06bc0851b23ee24f3f86190b07203dd8f567d0b706a185202" +dependencies = [ + "asn1-rs", + "aws-lc-rs", + "data-encoding", + "der-parser", + "lazy_static", + "nom", + "oid-registry", + "rusticata-macros", + "thiserror", + "time", +] + +[[package]] +name = "yasna" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17bb3549cc1321ae1296b9cdc2698e2b6cb1992adfa19a8c72e5b7a738f44cd" +dependencies = [ + "time", +] + +[[package]] +name = "zeroize" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" + +[[package]] +name = "zmij" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/http/vendor/rustls-webpki/Cargo.toml b/http/vendor/rustls-webpki/Cargo.toml new file mode 100644 index 0000000..52fe1c7 --- /dev/null +++ b/http/vendor/rustls-webpki/Cargo.toml @@ -0,0 +1,171 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies. +# +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. + +[package] +edition = "2021" +rust-version = "1.71" +name = "rustls-webpki" +version = "0.103.13" +build = false +include = [ + "Cargo.toml", + "/LICENSE", + "/README.md", + "src/aws_lc_rs_algs.rs", + "src/calendar.rs", + "src/cert.rs", + "src/crl/mod.rs", + "src/crl/types.rs", + "src/data/", + "src/der.rs", + "src/end_entity.rs", + "src/error.rs", + "src/rpk_entity.rs", + "src/subject_name/dns_name.rs", + "src/subject_name/ip_address.rs", + "src/subject_name/mod.rs", + "src/subject_name/name.rs", + "src/subject_name/verify.rs", + "src/name/verify.rs", + "src/name/name.rs", + "src/signed_data.rs", + "src/ring_algs.rs", + "src/alg_tests.rs", + "src/time.rs", + "src/trust_anchor.rs", + "src/x509.rs", + "src/verify_cert.rs", + "src/lib.rs", +] +autolib = false +autobins = false +autoexamples = false +autotests = false +autobenches = false +description = "Web PKI X.509 Certificate Verification." +readme = "README.md" +categories = [ + "cryptography", + "no-std", +] +license = "ISC" +repository = "https://github.com/rustls/webpki" + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = [ + "--cfg", + "webpki_docsrs", +] + +[package.metadata.cargo_check_external_types] +allowed_external_types = [ + "rustls_pki_types::*", + "rustls_pki_types", +] + +[package.metadata.cargo-semver-checks.lints] +enum_variant_marked_deprecated = "warn" + +[features] +alloc = [ + "ring?/alloc", + "pki-types/alloc", +] +aws-lc-rs = [ + "dep:aws-lc-rs", + "aws-lc-rs/aws-lc-sys", + "aws-lc-rs/prebuilt-nasm", +] +aws-lc-rs-fips = [ + "dep:aws-lc-rs", + "aws-lc-rs/fips", +] +aws-lc-rs-unstable = [ + "aws-lc-rs", + "aws-lc-rs/unstable", +] +default = ["std"] +ring = ["dep:ring"] +std = [ + "alloc", + "pki-types/std", +] + +[lib] +name = "webpki" +path = "src/lib.rs" + +[dependencies.aws-lc-rs] +version = "1.14" +optional = true +default-features = false + +[dependencies.pki-types] +version = "1.12" +default-features = false +package = "rustls-pki-types" + +[dependencies.ring] +version = "0.17" +optional = true +default-features = false + +[dependencies.untrusted] +version = "0.9" + +[dev-dependencies.base64] +version = "0.22" + +[dev-dependencies.bencher] +version = "0.1.5" + +[dev-dependencies.bzip2] +version = "0.6" + +[dev-dependencies.once_cell] +version = "1.17.2" + +[dev-dependencies.rcgen] +version = "0.14.2" +features = ["aws_lc_rs"] +default-features = false + +[dev-dependencies.serde] +version = "1.0" +features = ["derive"] + +[dev-dependencies.serde_json] +version = "1.0" + +[dev-dependencies.x509-parser] +version = "0.18.1" + +[lints.rust.unexpected_cfgs] +level = "warn" +priority = 0 +check-cfg = ["cfg(webpki_docsrs)"] + +[profile.bench] +opt-level = 3 +lto = true +codegen-units = 1 +debug = 0 +debug-assertions = false +rpath = false + +[profile.release] +opt-level = 3 +lto = true +codegen-units = 1 +debug = 0 +debug-assertions = false +rpath = false diff --git a/http/vendor/rustls-webpki/Cargo.toml.orig b/http/vendor/rustls-webpki/Cargo.toml.orig new file mode 100644 index 0000000..a98d320 --- /dev/null +++ b/http/vendor/rustls-webpki/Cargo.toml.orig @@ -0,0 +1,122 @@ +# Copyright 2015 Brian Smith. +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +[package] +categories = ["cryptography", "no-std"] +description = "Web PKI X.509 Certificate Verification." +edition = "2021" +rust-version = "1.71" +license = "ISC" +name = "rustls-webpki" +readme = "README.md" +repository = "https://github.com/rustls/webpki" +version = "0.103.13" + +include = [ + "Cargo.toml", + + "/LICENSE", + "/README.md", + + "src/aws_lc_rs_algs.rs", + "src/calendar.rs", + "src/cert.rs", + "src/crl/mod.rs", + "src/crl/types.rs", + "src/data/", + "src/der.rs", + "src/end_entity.rs", + "src/error.rs", + "src/rpk_entity.rs", + "src/subject_name/dns_name.rs", + "src/subject_name/ip_address.rs", + "src/subject_name/mod.rs", + "src/subject_name/name.rs", + "src/subject_name/verify.rs", + "src/name/verify.rs", + "src/name/name.rs", + "src/signed_data.rs", + "src/ring_algs.rs", + "src/alg_tests.rs", + "src/time.rs", + "src/trust_anchor.rs", + "src/x509.rs", + "src/verify_cert.rs", + "src/lib.rs", +] + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "webpki_docsrs"] + +[package.metadata.cargo_check_external_types] +allowed_external_types = [ + "rustls_pki_types::*", + "rustls_pki_types", # To allow re-export. +] + +[lib] +name = "webpki" + +[features] +default = ["std"] +alloc = ["ring?/alloc", "pki-types/alloc"] +aws-lc-rs-unstable = ["aws-lc-rs", "aws-lc-rs/unstable"] +aws-lc-rs = ["dep:aws-lc-rs", "aws-lc-rs/aws-lc-sys", "aws-lc-rs/prebuilt-nasm"] +aws-lc-rs-fips = ["dep:aws-lc-rs", "aws-lc-rs/fips"] +ring = ["dep:ring"] +std = ["alloc", "pki-types/std"] + +[dependencies] +aws-lc-rs = { version = "1.14", optional = true, default-features = false } +pki-types = { package = "rustls-pki-types", version = "1.12", default-features = false } +ring = { version = "0.17", default-features = false, optional = true } +untrusted = "0.9" + +[dev-dependencies] +base64 = "0.22" +bencher = "0.1.5" +bzip2 = "0.6" +once_cell = "1.17.2" +rcgen = { version = "0.14.2", default-features = false, features = ["aws_lc_rs"] } +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" +x509-parser = "0.18.1" + +[profile.bench] +opt-level = 3 +debug = false +rpath = false +lto = true +debug-assertions = false +codegen-units = 1 + +[profile.release] +opt-level = 3 +debug = false +rpath = false +lto = true +debug-assertions = false +codegen-units = 1 + +[[bench]] +name = "benchmarks" +path = "benches/benchmark.rs" +harness = false + +[package.metadata.cargo-semver-checks.lints] +enum_variant_marked_deprecated = "warn" + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(webpki_docsrs)'] } diff --git a/http/vendor/rustls-webpki/LICENSE b/http/vendor/rustls-webpki/LICENSE new file mode 100644 index 0000000..cd87be1 --- /dev/null +++ b/http/vendor/rustls-webpki/LICENSE @@ -0,0 +1,19 @@ +Except as otherwise noted, this project is licensed under the following +(ISC-style) terms: + +Copyright 2015 Brian Smith. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +The files under third-party/chromium are licensed as described in +third-party/chromium/LICENSE. diff --git a/http/vendor/rustls-webpki/README.md b/http/vendor/rustls-webpki/README.md new file mode 100644 index 0000000..5481570 --- /dev/null +++ b/http/vendor/rustls-webpki/README.md @@ -0,0 +1,79 @@ +[![Build Status](https://github.com/rustls/webpki/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/rustls/webpki/actions/workflows/ci.yml?query=branch%3Amain) +[![Coverage Status (codecov.io)](https://codecov.io/gh/rustls/webpki/branch/main/graph/badge.svg)](https://codecov.io/gh/rustls/webpki/) +[![Documentation](https://docs.rs/rustls-webpki/badge.svg)](https://docs.rs/rustls-webpki/) +[![Chat](https://img.shields.io/discord/976380008299917365?logo=discord)](https://discord.gg/MCSB76RU96) + +webpki is a library that validates Web PKI (TLS/SSL) certificates. It's +used by [Rustls](https://github.com/rustls/rustls) to handle certificate-related +tasks required for implementing TLS clients and servers. + +webpki is written in [Rust](https://www.rust-lang.org/) and uses +[*ring*](https://github.com/briansmith/ring) for cryptographic operations and +low-level parsing. + +This is a fork of the [original webpki project](https://github.com/briansmith/webpki) +which adds a number of features required by the rustls project. This fork is +released as the `rustls-webpki` crate, with versions starting 0.100.0 so as to +not confusingly overlap with `webpki` versions. + + +Features +=============== + +* Representing trust anchors - webpki requires the caller to bootstrap trust by + explicitly specifying a set of trust anchors using the `TrustAnchor` type. + +* Parsing certificates - webpki can convert from the raw encoded form of + a certificate into something that can be used for making trust decisions. + +* Path building - webpki can determine if a certificate for an end entity like + a website or client identity was issued by a trust anchor, or a series of + intermediate certificates the trust anchor has endorsed. + +* Name/usage validation - webpki can determine if a certificate is valid for + a given DNS name or IP address by considering the allowed usage of the + certificate and additional constraints. + + +Limitations +=============== + +webpki offers a minimal feature set tailored to the needs of Rustls. Notably it +does not offer: + +* Support for self-signed certificates +* Certificate or keypair generation +* Access to arbitrary certificate extensions +* Parsing/representation of certificate subjects, or human-friendly display of + these fields + +For these tasks you may prefer using webpki in combination with libraries like +[x509-parser](https://github.com/rusticata/x509-parser) and +[rcgen](https://github.com/est31/rcgen). + + +Changelog +========= + +Release history can be found [on GitHub](https://github.com/rustls/webpki/releases). + + +Demo +==== + +See https://github.com/rustls/rustls#example-code for an example of using +webpki. + + +License +======= + +See [LICENSE](LICENSE). This project happily accepts pull requests without any +formal copyright/contributor license agreement. + + +Bug Reporting +============= + +Please refer to the [SECURITY](SECURITY.md) policy for security issues. All +other bugs should be reported as [GitHub issues](https://github.com/rustls/webpki/issues/new). diff --git a/http/vendor/rustls-webpki/src/alg_tests.rs b/http/vendor/rustls-webpki/src/alg_tests.rs new file mode 100644 index 0000000..394b898 --- /dev/null +++ b/http/vendor/rustls-webpki/src/alg_tests.rs @@ -0,0 +1,648 @@ +// Copyright 2015 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#![allow(clippy::duplicate_mod)] + +use alloc::string::String; +use alloc::vec::Vec; + +use base64::{Engine as _, engine::general_purpose}; +use pki_types::alg_id; + +use crate::error::{DerTypeId, Error, UnsupportedSignatureAlgorithmForPublicKeyContext}; +use crate::verify_cert::Budget; +use crate::{der, signed_data}; + +use super::{ + OK_IF_POINT_COMPRESSION_SUPPORTED, SUPPORTED_ALGORITHMS_IN_TESTS, invalid_rsa_signature, + maybe_rsa, unsupported, unsupported_for_ecdsa, unsupported_for_rsa, +}; + +macro_rules! test_file_bytes { + ( $file_name:expr ) => { + include_bytes!(concat!( + "../third-party/chromium/data/verify_signed_data/", + $file_name + )) + }; +} + +// TODO: The expected results need to be modified for SHA-1 deprecation. + +fn test_verify_signed_data(file_contents: &[u8]) -> Result<(), Error> { + let tsd = parse_test_signed_data(file_contents); + let spki_value = untrusted::Input::from(&tsd.spki); + let spki_value = spki_value + .read_all(Error::BadDer, |input| { + der::expect_tag(input, der::Tag::Sequence) + }) + .unwrap(); + + // we can't use `parse_signed_data` because it requires `data` + // to be an ASN.1 SEQUENCE, and that isn't the case with + // Chromium's test data. TODO: The test data set should be + // expanded with SEQUENCE-wrapped data so that we can actually + // test `parse_signed_data`. + + let algorithm = untrusted::Input::from(&tsd.algorithm); + let algorithm = algorithm + .read_all( + Error::TrailingData(DerTypeId::SignatureAlgorithm), + |input| der::expect_tag(input, der::Tag::Sequence), + ) + .unwrap(); + + let signature = untrusted::Input::from(&tsd.signature); + let signature = signature + .read_all(Error::TrailingData(DerTypeId::Signature), |input| { + der::bit_string_with_no_unused_bits(input) + }) + .unwrap(); + + let signed_data = signed_data::SignedData { + data: untrusted::Input::from(&tsd.data), + algorithm, + signature, + }; + + signed_data::verify_signed_data( + SUPPORTED_ALGORITHMS_IN_TESTS, + spki_value, + &signed_data, + &mut Budget::default(), + ) +} + +fn test_verify_signed_data_signature_outer(file_contents: &[u8]) -> Result<(), Error> { + let tsd = parse_test_signed_data(file_contents); + let signature = untrusted::Input::from(&tsd.signature); + signature.read_all(Error::TrailingData(DerTypeId::Signature), |input| { + der::bit_string_with_no_unused_bits(input) + })?; + + Ok(()) +} + +fn test_parse_spki_bad_outer(file_contents: &[u8]) -> Result<(), Error> { + let tsd = parse_test_signed_data(file_contents); + let spki = untrusted::Input::from(&tsd.spki); + spki.read_all(Error::BadDer, |input| { + der::expect_tag(input, der::Tag::Sequence) + })?; + + Ok(()) +} + +// XXX: Some of the BadDer tests should have better error codes, maybe? + +// XXX: We should have a variant of this test with a SHA-256 digest that gives +// `Error::UnsupportedSignatureAlgorithmForPublicKey`. +#[test] +fn test_ecdsa_prime256v1_sha512_spki_params_null() { + assert_eq!( + test_verify_signed_data(test_file_bytes!( + "ecdsa-prime256v1-sha512-spki-params-null.pem" + )), + Err(unsupported_for_ecdsa( + &alg_id::ECDSA_SHA512, + include_bytes!("../tests/signatures/alg-id-ecpublickey-params-null.der") + )) + ); +} + +#[test] +fn test_ecdsa_prime256v1_sha512_unused_bits_signature() { + assert_eq!( + test_verify_signed_data_signature_outer(test_file_bytes!( + "ecdsa-prime256v1-sha512-unused-bits-signature.pem" + )), + Err(Error::BadDer) + ); +} + +// XXX: We should have a variant of this test with a SHA-256 digest that gives +// `Error::UnsupportedSignatureAlgorithmForPublicKey`. +#[test] +fn test_ecdsa_prime256v1_sha512_using_ecdh_key() { + assert_eq!( + test_verify_signed_data(test_file_bytes!( + "ecdsa-prime256v1-sha512-using-ecdh-key.pem" + )), + Err(unsupported_for_ecdsa( + &alg_id::ECDSA_SHA512, + include_bytes!("../tests/signatures/alg-ecdh-secp256r1.der") + )) + ); +} + +// XXX: We should have a variant of this test with a SHA-256 digest that gives +// `Error::UnsupportedSignatureAlgorithmForPublicKey`. +#[test] +fn test_ecdsa_prime256v1_sha512_using_ecmqv_key() { + assert_eq!( + test_verify_signed_data(test_file_bytes!( + "ecdsa-prime256v1-sha512-using-ecmqv-key.pem" + )), + Err(unsupported_for_ecdsa( + &alg_id::ECDSA_SHA512, + include_bytes!("../tests/signatures/alg-ecmqv-secp256r1.der") + )) + ); +} + +#[test] +fn test_ecdsa_prime256v1_sha512_using_rsa_algorithm() { + assert_eq!( + test_verify_signed_data(test_file_bytes!( + "ecdsa-prime256v1-sha512-using-rsa-algorithm.pem" + ),), + Err(unsupported_for_rsa( + &alg_id::RSA_PKCS1_SHA512, + &alg_id::ECDSA_P256, + )) + ); +} + +// XXX: We should have a variant of this test with a SHA-256 digest that gives +// `Error::InvalidSignatureForPublicKey`. +#[test] +fn test_ecdsa_prime256v1_sha512_wrong_signature_format() { + assert_eq!( + test_verify_signed_data(test_file_bytes!( + "ecdsa-prime256v1-sha512-wrong-signature-format.pem" + )), + Err(unsupported_for_ecdsa( + &alg_id::ECDSA_SHA512, + &alg_id::ECDSA_P256, + )) + ); +} + +// Differs from Chromium because we don't support P-256 with SHA-512. +#[test] +fn test_ecdsa_prime256v1_sha512() { + assert_eq!( + test_verify_signed_data(test_file_bytes!("ecdsa-prime256v1-sha512.pem")), + Err(unsupported_for_ecdsa( + &alg_id::ECDSA_SHA512, + &alg_id::ECDSA_P256, + )) + ); +} + +#[test] +fn test_ecdsa_secp384r1_sha256_corrupted_data() { + assert_eq!( + test_verify_signed_data(test_file_bytes!( + "ecdsa-secp384r1-sha256-corrupted-data.pem" + )), + Err(Error::InvalidSignatureForPublicKey) + ); +} + +#[test] +fn test_ecdsa_secp384r1_sha256() { + assert_eq!( + test_verify_signed_data(test_file_bytes!("ecdsa-secp384r1-sha256.pem")), + Ok(()) + ); +} + +#[test] +fn test_ecdsa_using_rsa_key() { + assert_eq!( + test_verify_signed_data(test_file_bytes!("ecdsa-using-rsa-key.pem")), + Err(Error::UnsupportedSignatureAlgorithmForPublicKeyContext( + UnsupportedSignatureAlgorithmForPublicKeyContext { + #[cfg(feature = "alloc")] + signature_algorithm_id: alg_id::ECDSA_SHA256.as_ref().to_vec(), + #[cfg(feature = "alloc")] + public_key_algorithm_id: alg_id::RSA_ENCRYPTION.as_ref().to_vec(), + } + )) + ); +} + +#[test] +fn test_rsa_pkcs1_sha1_bad_key_der_length() { + assert_eq!( + test_parse_spki_bad_outer(test_file_bytes!("rsa-pkcs1-sha1-bad-key-der-length.pem")), + Err(Error::BadDer) + ); +} + +#[test] +fn test_rsa_pkcs1_sha1_bad_key_der_null() { + assert_eq!( + test_parse_spki_bad_outer(test_file_bytes!("rsa-pkcs1-sha1-bad-key-der-null.pem")), + Err(Error::BadDer) + ); +} + +#[test] +fn test_rsa_pkcs1_sha1_key_params_absent() { + assert_eq!( + test_verify_signed_data(test_file_bytes!("rsa-pkcs1-sha1-key-params-absent.pem")), + Err(unsupported(include_bytes!( + "../tests/signatures/alg-rsae-sha1.der" + ))) + ); +} + +#[test] +fn test_rsa_pkcs1_sha1_using_pss_key_no_params() { + assert_eq!( + test_verify_signed_data(test_file_bytes!( + "rsa-pkcs1-sha1-using-pss-key-no-params.pem" + )), + Err(unsupported(include_bytes!( + "../tests/signatures/alg-rsae-sha1.der" + ))) + ); +} + +#[test] +fn test_rsa_pkcs1_sha1_wrong_algorithm() { + assert_eq!( + test_verify_signed_data(test_file_bytes!("rsa-pkcs1-sha1-wrong-algorithm.pem")), + Err(invalid_rsa_signature()) + ); +} + +#[test] +fn test_rsa_pkcs1_sha1() { + assert_eq!( + test_verify_signed_data(test_file_bytes!("rsa-pkcs1-sha1.pem")), + Err(unsupported(include_bytes!( + "../tests/signatures/alg-rsae-sha1.der" + ))) + ); +} + +// XXX: RSA PKCS#1 with SHA-1 is a supported algorithm, but we only accept +// 2048-8192 bit keys, and this test file is using a 1024 bit key. Thus, +// our results differ from Chromium's. TODO: this means we need a 2048+ bit +// version of this test. + +#[test] +fn test_rsa_pkcs1_sha256() { + assert_eq!( + test_verify_signed_data(test_file_bytes!("rsa-pkcs1-sha256.pem")), + Err(invalid_rsa_signature()) + ); +} + +#[test] +fn test_rsa_pkcs1_sha256_key_encoded_ber() { + assert_eq!( + test_parse_spki_bad_outer(test_file_bytes!("rsa-pkcs1-sha256-key-encoded-ber.pem")), + Err(Error::BadDer) + ); +} + +#[test] +fn test_rsa_pkcs1_sha256_spki_non_null_params() { + assert_eq!( + test_verify_signed_data(test_file_bytes!( + "rsa-pkcs1-sha256-spki-non-null-params.pem" + )), + Err(unsupported_for_rsa( + &alg_id::RSA_PKCS1_SHA256, + include_bytes!("../tests/signatures/alg-rsae-bad-params.der") + )) + ); +} + +#[test] +fn test_rsa_pkcs1_sha256_using_ecdsa_algorithm() { + assert_eq!( + test_verify_signed_data(test_file_bytes!( + "rsa-pkcs1-sha256-using-ecdsa-algorithm.pem" + )), + Err(Error::UnsupportedSignatureAlgorithmForPublicKeyContext( + UnsupportedSignatureAlgorithmForPublicKeyContext { + #[cfg(feature = "alloc")] + signature_algorithm_id: alg_id::ECDSA_SHA256.as_ref().to_vec(), + #[cfg(feature = "alloc")] + public_key_algorithm_id: alg_id::RSA_ENCRYPTION.as_ref().to_vec(), + } + )) + ); +} + +#[test] +fn test_rsa_pkcs1_sha256_using_id_ea_rsa() { + assert_eq!( + test_verify_signed_data(test_file_bytes!("rsa-pkcs1-sha256-using-id-ea-rsa.pem")), + Err(unsupported_for_rsa( + &alg_id::RSA_PKCS1_SHA256, + include_bytes!("../tests/signatures/alg-rsa-null-params.der") + )) + ); +} + +// Chromium's PSS test are for parameter combinations we don't support. + +#[test] +fn test_rsa_pss_sha1_salt20_using_pss_key_no_params() { + assert_eq!( + test_verify_signed_data(test_file_bytes!( + "rsa-pss-sha1-salt20-using-pss-key-no-params.pem" + )), + Err(unsupported(include_bytes!( + "../tests/signatures/alg-rsapss-defaults.der" + ))) + ); +} + +#[test] +fn test_rsa_pss_sha1_salt20_using_pss_key_with_null_params() { + assert_eq!( + test_verify_signed_data(test_file_bytes!( + "rsa-pss-sha1-salt20-using-pss-key-with-null-params.pem" + )), + Err(unsupported(include_bytes!( + "../tests/signatures/alg-rsapss-defaults.der" + ))) + ); +} +#[test] +fn test_rsa_pss_sha1_salt20() { + assert_eq!( + test_verify_signed_data(test_file_bytes!("rsa-pss-sha1-salt20.pem")), + Err(unsupported(include_bytes!( + "../tests/signatures/alg-rsapss-defaults.der" + ))) + ); +} + +#[test] +fn test_rsa_pss_sha1_wrong_salt() { + assert_eq!( + test_verify_signed_data(test_file_bytes!("rsa-pss-sha1-wrong-salt.pem")), + Err(unsupported(include_bytes!( + "../tests/signatures/alg-rsapss-salt23.der" + ))) + ); +} + +#[test] +fn test_rsa_pss_sha256_mgf1_sha512_salt33() { + assert_eq!( + test_verify_signed_data(test_file_bytes!("rsa-pss-sha256-mgf1-sha512-salt33.pem")), + Err(unsupported(include_bytes!( + "../tests/signatures/alg-rsapss-sha256-mgf1-sha512-salt33.der" + ))) + ); +} + +#[test] +fn test_rsa_pss_sha256_salt10_using_pss_key_with_params() { + assert_eq!( + test_verify_signed_data(test_file_bytes!( + "rsa-pss-sha256-salt10-using-pss-key-with-params.pem" + )), + Err(unsupported(include_bytes!( + "../tests/signatures/alg-rsapss-sha256-mgf1-sha256-salt10.der" + ))) + ); +} +#[test] +fn test_rsa_pss_sha256_salt10_using_pss_key_with_wrong_params() { + assert_eq!( + test_verify_signed_data(test_file_bytes!( + "rsa-pss-sha256-salt10-using-pss-key-with-wrong-params.pem" + )), + Err(unsupported(include_bytes!( + "../tests/signatures/alg-rsapss-sha256-mgf1-sha256-salt10.der" + ))) + ); +} + +#[test] +fn test_rsa_pss_sha256_salt10() { + assert_eq!( + test_verify_signed_data(test_file_bytes!("rsa-pss-sha256-salt10.pem")), + Err(unsupported(include_bytes!( + "../tests/signatures/alg-rsapss-sha256-mgf1-sha256-salt10.der" + ))) + ); +} + +// Our PSS tests that should work. + +#[test] +fn test_rsa_pss_sha256_salt32() { + assert_eq!( + test_verify_signed_data(test_file_bytes!("ours/rsa-pss-sha256-salt32.pem")), + maybe_rsa() + ); +} + +#[test] +fn test_rsa_pss_sha384_salt48() { + assert_eq!( + test_verify_signed_data(test_file_bytes!("ours/rsa-pss-sha384-salt48.pem")), + maybe_rsa() + ); +} + +#[test] +fn test_rsa_pss_sha512_salt64() { + assert_eq!( + test_verify_signed_data(test_file_bytes!("ours/rsa-pss-sha512-salt64.pem")), + maybe_rsa() + ); +} + +#[test] +fn test_rsa_pss_sha256_salt32_corrupted_data() { + assert_eq!( + test_verify_signed_data(test_file_bytes!( + "ours/rsa-pss-sha256-salt32-corrupted-data.pem" + )), + Err(invalid_rsa_signature()) + ); +} + +#[test] +fn test_rsa_pss_sha384_salt48_corrupted_data() { + assert_eq!( + test_verify_signed_data(test_file_bytes!( + "ours/rsa-pss-sha384-salt48-corrupted-data.pem" + )), + Err(invalid_rsa_signature()) + ); +} + +#[test] +fn test_rsa_pss_sha512_salt64_corrupted_data() { + assert_eq!( + test_verify_signed_data(test_file_bytes!( + "ours/rsa-pss-sha512-salt64-corrupted-data.pem" + )), + Err(invalid_rsa_signature()) + ); +} + +#[test] +fn test_rsa_using_ec_key() { + assert_eq!( + test_verify_signed_data(test_file_bytes!("rsa-using-ec-key.pem")), + Err(unsupported_for_rsa( + &alg_id::RSA_PKCS1_SHA256, + &alg_id::ECDSA_P256 + )) + ); +} + +#[test] +fn test_rsa2048_pkcs1_sha512() { + assert_eq!( + test_verify_signed_data(test_file_bytes!("rsa2048-pkcs1-sha512.pem")), + maybe_rsa() + ); +} + +#[test] +fn test_ecdsa_prime256v1_sha256() { + assert_eq!( + test_verify_signed_data(test_file_bytes!("ours/ecdsa-prime256v1-sha256.pem")), + (Ok(())) + ); +} + +#[test] +fn test_ecdsa_prime256v1_sha256_compressed() { + assert_eq!( + test_verify_signed_data(test_file_bytes!( + "ours/ecdsa-prime256v1-sha256-compressed.pem" + )), + OK_IF_POINT_COMPRESSION_SUPPORTED + ); +} + +#[test] +fn test_ecdsa_prime256v1_sha256_spki_inside_spki() { + assert_eq!( + test_verify_signed_data(test_file_bytes!( + "ours/ecdsa-prime256v1-sha256-spki-inside-spki.pem" + )), + Err(Error::InvalidSignatureForPublicKey) + ); +} + +#[cfg(all(feature = "aws-lc-rs-unstable", not(feature = "aws-lc-rs-fips")))] +mod aws_lc_rs_unstable { + use pki_types::CertificateDer; + use pki_types::pem::PemObject; + use untrusted::Input; + + use super::*; + use crate::cert::Cert; + use crate::signed_data::verify_signed_data; + + /// From . + #[test] + fn self_signed_ml_dsa_44() { + let pem = include_bytes!("../tests/tls_server_certs/ml-dsa-44-certificate.pem"); + let der = CertificateDer::from_pem_slice(pem).unwrap(); + let cert = Cert::from_der(Input::from(&der)).unwrap(); + verify_signed_data( + SUPPORTED_ALGORITHMS_IN_TESTS, + cert.spki, + &cert.signed_data, + &mut Budget::default(), + ) + .unwrap(); + } + + /// From . + #[test] + fn self_signed_ml_dsa_65() { + let pem = include_bytes!("../tests/tls_server_certs/ml-dsa-65-certificate.pem"); + let der = CertificateDer::from_pem_slice(pem).unwrap(); + let cert = Cert::from_der(Input::from(&der)).unwrap(); + verify_signed_data( + SUPPORTED_ALGORITHMS_IN_TESTS, + cert.spki, + &cert.signed_data, + &mut Budget::default(), + ) + .unwrap(); + } + + /// From . + #[test] + fn self_signed_ml_dsa_87() { + let pem = include_bytes!("../tests/tls_server_certs/ml-dsa-87-certificate.pem"); + let der = CertificateDer::from_pem_slice(pem).unwrap(); + let cert = Cert::from_der(Input::from(&der)).unwrap(); + verify_signed_data( + SUPPORTED_ALGORITHMS_IN_TESTS, + cert.spki, + &cert.signed_data, + &mut Budget::default(), + ) + .unwrap(); + } +} + +struct TestSignedData { + spki: Vec, + data: Vec, + algorithm: Vec, + signature: Vec, +} + +fn parse_test_signed_data(file_contents: &[u8]) -> TestSignedData { + let mut lines = core::str::from_utf8(file_contents).unwrap().lines(); + let spki = read_pem_section(&mut lines, "PUBLIC KEY"); + let algorithm = read_pem_section(&mut lines, "ALGORITHM"); + let data = read_pem_section(&mut lines, "DATA"); + let signature = read_pem_section(&mut lines, "SIGNATURE"); + + TestSignedData { + spki, + data, + algorithm, + signature, + } +} + +use alloc::str::Lines; + +fn read_pem_section(lines: &mut Lines<'_>, section_name: &str) -> Vec { + // Skip comments and header + let begin_section = format!("-----BEGIN {section_name}-----"); + loop { + let line = lines.next().unwrap(); + if line == begin_section { + break; + } + } + + let mut base64 = String::new(); + + let end_section = format!("-----END {section_name}-----"); + loop { + let line = lines.next().unwrap(); + if line == end_section { + break; + } + base64.push_str(line); + } + + general_purpose::STANDARD.decode(&base64).unwrap() +} diff --git a/http/vendor/rustls-webpki/src/aws_lc_rs_algs.rs b/http/vendor/rustls-webpki/src/aws_lc_rs_algs.rs new file mode 100644 index 0000000..e518b4e --- /dev/null +++ b/http/vendor/rustls-webpki/src/aws_lc_rs_algs.rs @@ -0,0 +1,381 @@ +#[cfg(all(feature = "aws-lc-rs-unstable", not(feature = "aws-lc-rs-fips")))] +use aws_lc_rs::unstable; +use aws_lc_rs::{signature, try_fips_mode}; +use pki_types::{AlgorithmIdentifier, InvalidSignature, SignatureVerificationAlgorithm, alg_id}; + +// nb. aws-lc-rs has an API that is broadly compatible with *ring*, +// so this is very similar to ring_algs.rs. + +/// A `SignatureVerificationAlgorithm` implemented using aws-lc-rs. +#[derive(Debug)] +struct AwsLcRsAlgorithm { + public_key_alg_id: AlgorithmIdentifier, + signature_alg_id: AlgorithmIdentifier, + verification_alg: &'static dyn signature::VerificationAlgorithm, + in_fips_submission: bool, +} + +impl SignatureVerificationAlgorithm for AwsLcRsAlgorithm { + fn public_key_alg_id(&self) -> AlgorithmIdentifier { + self.public_key_alg_id + } + + fn signature_alg_id(&self) -> AlgorithmIdentifier { + self.signature_alg_id + } + + fn verify_signature( + &self, + public_key: &[u8], + message: &[u8], + signature: &[u8], + ) -> Result<(), InvalidSignature> { + if matches!( + self.public_key_alg_id, + alg_id::ECDSA_P256 | alg_id::ECDSA_P384 | alg_id::ECDSA_P521 + ) { + // Restrict the allowed encodings of EC public keys. + // + // "The first octet of the OCTET STRING indicates whether the key is + // compressed or uncompressed. The uncompressed form is indicated + // by 0x04 and the compressed form is indicated by either 0x02 or + // 0x03 (see 2.3.3 in [SEC1]). The public key MUST be rejected if + // any other value is included in the first octet." + // -- + match public_key.first() { + Some(0x04) | Some(0x02) | Some(0x03) => {} + _ => return Err(InvalidSignature), + }; + } + signature::UnparsedPublicKey::new(self.verification_alg, public_key) + .verify(message, signature) + .map_err(|_| InvalidSignature) + } + + fn fips(&self) -> bool { + self.in_fips_submission && try_fips_mode().is_ok() + } +} + +/// ML-DSA signatures using the [4, 4] matrix (security strength category 2). +#[cfg(all(feature = "aws-lc-rs-unstable", not(feature = "aws-lc-rs-fips")))] +pub static ML_DSA_44: &dyn SignatureVerificationAlgorithm = &AwsLcRsAlgorithm { + public_key_alg_id: alg_id::ML_DSA_44, + signature_alg_id: alg_id::ML_DSA_44, + verification_alg: &unstable::signature::ML_DSA_44, + // Not included in AWS-LC-FIPS 3.0 FIPS scope + in_fips_submission: false, +}; + +/// ML-DSA signatures using the [6, 5] matrix (security strength category 3). +#[cfg(all(feature = "aws-lc-rs-unstable", not(feature = "aws-lc-rs-fips")))] +pub static ML_DSA_65: &dyn SignatureVerificationAlgorithm = &AwsLcRsAlgorithm { + public_key_alg_id: alg_id::ML_DSA_65, + signature_alg_id: alg_id::ML_DSA_65, + verification_alg: &unstable::signature::ML_DSA_65, + // Not included in AWS-LC-FIPS 3.0 FIPS scope + in_fips_submission: false, +}; + +/// ML-DSA signatures using the [8. 7] matrix (security strength category 5). +#[cfg(all(feature = "aws-lc-rs-unstable", not(feature = "aws-lc-rs-fips")))] +pub static ML_DSA_87: &dyn SignatureVerificationAlgorithm = &AwsLcRsAlgorithm { + public_key_alg_id: alg_id::ML_DSA_87, + signature_alg_id: alg_id::ML_DSA_87, + verification_alg: &unstable::signature::ML_DSA_87, + // Not included in AWS-LC-FIPS 3.0 FIPS scope + in_fips_submission: false, +}; + +/// ECDSA signatures using the P-256 curve and SHA-256. +pub static ECDSA_P256_SHA256: &dyn SignatureVerificationAlgorithm = &AwsLcRsAlgorithm { + public_key_alg_id: alg_id::ECDSA_P256, + signature_alg_id: alg_id::ECDSA_SHA256, + verification_alg: &signature::ECDSA_P256_SHA256_ASN1, + in_fips_submission: true, +}; + +/// ECDSA signatures using the P-256 curve and SHA-384. Deprecated. +pub static ECDSA_P256_SHA384: &dyn SignatureVerificationAlgorithm = &AwsLcRsAlgorithm { + public_key_alg_id: alg_id::ECDSA_P256, + signature_alg_id: alg_id::ECDSA_SHA384, + verification_alg: &signature::ECDSA_P256_SHA384_ASN1, + in_fips_submission: true, +}; + +/// ECDSA signatures using the P-256 curve and SHA-512. Deprecated. +pub static ECDSA_P256_SHA512: &dyn SignatureVerificationAlgorithm = &AwsLcRsAlgorithm { + public_key_alg_id: alg_id::ECDSA_P256, + signature_alg_id: alg_id::ECDSA_SHA512, + verification_alg: &signature::ECDSA_P256_SHA512_ASN1, + in_fips_submission: true, +}; + +/// ECDSA signatures using the P-384 curve and SHA-256. Deprecated. +pub static ECDSA_P384_SHA256: &dyn SignatureVerificationAlgorithm = &AwsLcRsAlgorithm { + public_key_alg_id: alg_id::ECDSA_P384, + signature_alg_id: alg_id::ECDSA_SHA256, + verification_alg: &signature::ECDSA_P384_SHA256_ASN1, + in_fips_submission: true, +}; + +/// ECDSA signatures using the P-384 curve and SHA-384. +pub static ECDSA_P384_SHA384: &dyn SignatureVerificationAlgorithm = &AwsLcRsAlgorithm { + public_key_alg_id: alg_id::ECDSA_P384, + signature_alg_id: alg_id::ECDSA_SHA384, + verification_alg: &signature::ECDSA_P384_SHA384_ASN1, + in_fips_submission: true, +}; + +/// ECDSA signatures using the P-384 curve and SHA-512. Deprecated. +pub static ECDSA_P384_SHA512: &dyn SignatureVerificationAlgorithm = &AwsLcRsAlgorithm { + public_key_alg_id: alg_id::ECDSA_P384, + signature_alg_id: alg_id::ECDSA_SHA512, + verification_alg: &signature::ECDSA_P384_SHA512_ASN1, + in_fips_submission: true, +}; + +/// ECDSA signatures using the P-521 curve and SHA-256. +pub static ECDSA_P521_SHA256: &dyn SignatureVerificationAlgorithm = &AwsLcRsAlgorithm { + public_key_alg_id: alg_id::ECDSA_P521, + signature_alg_id: alg_id::ECDSA_SHA256, + verification_alg: &signature::ECDSA_P521_SHA256_ASN1, + in_fips_submission: true, +}; + +/// ECDSA signatures using the P-521 curve and SHA-384. +pub static ECDSA_P521_SHA384: &dyn SignatureVerificationAlgorithm = &AwsLcRsAlgorithm { + public_key_alg_id: alg_id::ECDSA_P521, + signature_alg_id: alg_id::ECDSA_SHA384, + verification_alg: &signature::ECDSA_P521_SHA384_ASN1, + in_fips_submission: true, +}; + +/// ECDSA signatures using the P-521 curve and SHA-512. +pub static ECDSA_P521_SHA512: &dyn SignatureVerificationAlgorithm = &AwsLcRsAlgorithm { + public_key_alg_id: alg_id::ECDSA_P521, + signature_alg_id: alg_id::ECDSA_SHA512, + verification_alg: &signature::ECDSA_P521_SHA512_ASN1, + in_fips_submission: true, +}; + +/// RSA PKCS#1 1.5 signatures using SHA-256 for keys of 2048-8192 bits. +pub static RSA_PKCS1_2048_8192_SHA256: &dyn SignatureVerificationAlgorithm = &AwsLcRsAlgorithm { + public_key_alg_id: alg_id::RSA_ENCRYPTION, + signature_alg_id: alg_id::RSA_PKCS1_SHA256, + verification_alg: &signature::RSA_PKCS1_2048_8192_SHA256, + in_fips_submission: true, +}; + +/// RSA PKCS#1 1.5 signatures using SHA-384 for keys of 2048-8192 bits. +pub static RSA_PKCS1_2048_8192_SHA384: &dyn SignatureVerificationAlgorithm = &AwsLcRsAlgorithm { + public_key_alg_id: alg_id::RSA_ENCRYPTION, + signature_alg_id: alg_id::RSA_PKCS1_SHA384, + verification_alg: &signature::RSA_PKCS1_2048_8192_SHA384, + in_fips_submission: true, +}; + +/// RSA PKCS#1 1.5 signatures using SHA-512 for keys of 2048-8192 bits. +pub static RSA_PKCS1_2048_8192_SHA512: &dyn SignatureVerificationAlgorithm = &AwsLcRsAlgorithm { + public_key_alg_id: alg_id::RSA_ENCRYPTION, + signature_alg_id: alg_id::RSA_PKCS1_SHA512, + verification_alg: &signature::RSA_PKCS1_2048_8192_SHA512, + in_fips_submission: true, +}; + +/// RSA PKCS#1 1.5 signatures using SHA-256 for keys of 2048-8192 bits, +/// with illegally absent AlgorithmIdentifier parameters. +/// +/// RFC4055 says on sha256WithRSAEncryption and company: +/// +/// > When any of these four object identifiers appears within an +/// > AlgorithmIdentifier, the parameters MUST be NULL. Implementations +/// > MUST accept the parameters being absent as well as present. +/// +/// This algorithm covers the absent case, [`RSA_PKCS1_2048_8192_SHA256`] covers +/// the present case. +pub static RSA_PKCS1_2048_8192_SHA256_ABSENT_PARAMS: &dyn SignatureVerificationAlgorithm = + &AwsLcRsAlgorithm { + public_key_alg_id: alg_id::RSA_ENCRYPTION, + signature_alg_id: alg_id::AlgorithmIdentifier::from_slice(include_bytes!( + "data/alg-rsa-pkcs1-sha256-absent-params.der" + )), + verification_alg: &signature::RSA_PKCS1_2048_8192_SHA256, + in_fips_submission: true, + }; + +/// RSA PKCS#1 1.5 signatures using SHA-384 for keys of 2048-8192 bits, +/// with illegally absent AlgorithmIdentifier parameters. +/// +/// RFC4055 says on sha256WithRSAEncryption and company: +/// +/// > When any of these four object identifiers appears within an +/// > AlgorithmIdentifier, the parameters MUST be NULL. Implementations +/// > MUST accept the parameters being absent as well as present. +/// +/// This algorithm covers the absent case, [`RSA_PKCS1_2048_8192_SHA384`] covers +/// the present case. +pub static RSA_PKCS1_2048_8192_SHA384_ABSENT_PARAMS: &dyn SignatureVerificationAlgorithm = + &AwsLcRsAlgorithm { + public_key_alg_id: alg_id::RSA_ENCRYPTION, + signature_alg_id: alg_id::AlgorithmIdentifier::from_slice(include_bytes!( + "data/alg-rsa-pkcs1-sha384-absent-params.der" + )), + verification_alg: &signature::RSA_PKCS1_2048_8192_SHA384, + in_fips_submission: true, + }; + +/// RSA PKCS#1 1.5 signatures using SHA-512 for keys of 2048-8192 bits, +/// with illegally absent AlgorithmIdentifier parameters. +/// +/// RFC4055 says on sha256WithRSAEncryption and company: +/// +/// > When any of these four object identifiers appears within an +/// > AlgorithmIdentifier, the parameters MUST be NULL. Implementations +/// > MUST accept the parameters being absent as well as present. +/// +/// This algorithm covers the absent case, [`RSA_PKCS1_2048_8192_SHA512`] covers +/// the present case. +pub static RSA_PKCS1_2048_8192_SHA512_ABSENT_PARAMS: &dyn SignatureVerificationAlgorithm = + &AwsLcRsAlgorithm { + public_key_alg_id: alg_id::RSA_ENCRYPTION, + signature_alg_id: alg_id::AlgorithmIdentifier::from_slice(include_bytes!( + "data/alg-rsa-pkcs1-sha512-absent-params.der" + )), + verification_alg: &signature::RSA_PKCS1_2048_8192_SHA512, + in_fips_submission: true, + }; + +/// RSA PKCS#1 1.5 signatures using SHA-384 for keys of 3072-8192 bits. +pub static RSA_PKCS1_3072_8192_SHA384: &dyn SignatureVerificationAlgorithm = &AwsLcRsAlgorithm { + public_key_alg_id: alg_id::RSA_ENCRYPTION, + signature_alg_id: alg_id::RSA_PKCS1_SHA384, + verification_alg: &signature::RSA_PKCS1_3072_8192_SHA384, + in_fips_submission: true, +}; + +/// RSA PSS signatures using SHA-256 for keys of 2048-8192 bits and of +/// type rsaEncryption; see [RFC 4055 Section 1.2]. +/// +/// [RFC 4055 Section 1.2]: https://tools.ietf.org/html/rfc4055#section-1.2 +pub static RSA_PSS_2048_8192_SHA256_LEGACY_KEY: &dyn SignatureVerificationAlgorithm = + &AwsLcRsAlgorithm { + public_key_alg_id: alg_id::RSA_ENCRYPTION, + signature_alg_id: alg_id::RSA_PSS_SHA256, + verification_alg: &signature::RSA_PSS_2048_8192_SHA256, + in_fips_submission: true, + }; + +/// RSA PSS signatures using SHA-384 for keys of 2048-8192 bits and of +/// type rsaEncryption; see [RFC 4055 Section 1.2]. +/// +/// [RFC 4055 Section 1.2]: https://tools.ietf.org/html/rfc4055#section-1.2 +pub static RSA_PSS_2048_8192_SHA384_LEGACY_KEY: &dyn SignatureVerificationAlgorithm = + &AwsLcRsAlgorithm { + public_key_alg_id: alg_id::RSA_ENCRYPTION, + signature_alg_id: alg_id::RSA_PSS_SHA384, + verification_alg: &signature::RSA_PSS_2048_8192_SHA384, + in_fips_submission: true, + }; + +/// RSA PSS signatures using SHA-512 for keys of 2048-8192 bits and of +/// type rsaEncryption; see [RFC 4055 Section 1.2]. +/// +/// [RFC 4055 Section 1.2]: https://tools.ietf.org/html/rfc4055#section-1.2 +pub static RSA_PSS_2048_8192_SHA512_LEGACY_KEY: &dyn SignatureVerificationAlgorithm = + &AwsLcRsAlgorithm { + public_key_alg_id: alg_id::RSA_ENCRYPTION, + signature_alg_id: alg_id::RSA_PSS_SHA512, + verification_alg: &signature::RSA_PSS_2048_8192_SHA512, + in_fips_submission: true, + }; + +/// ED25519 signatures according to RFC 8410 +pub static ED25519: &dyn SignatureVerificationAlgorithm = &AwsLcRsAlgorithm { + public_key_alg_id: alg_id::ED25519, + signature_alg_id: alg_id::ED25519, + verification_alg: &signature::ED25519, + in_fips_submission: true, +}; + +#[cfg(test)] +#[path = "."] +mod tests { + use crate::error::{ + Error, UnsupportedSignatureAlgorithmContext, + UnsupportedSignatureAlgorithmForPublicKeyContext, + }; + + static SUPPORTED_ALGORITHMS_IN_TESTS: &[&dyn super::SignatureVerificationAlgorithm] = &[ + // Reasonable algorithms. + super::ECDSA_P256_SHA256, + super::ECDSA_P384_SHA384, + super::ECDSA_P521_SHA256, + super::ECDSA_P521_SHA384, + super::ECDSA_P521_SHA512, + super::ED25519, + super::RSA_PKCS1_2048_8192_SHA256, + super::RSA_PKCS1_2048_8192_SHA384, + super::RSA_PKCS1_2048_8192_SHA512, + super::RSA_PKCS1_3072_8192_SHA384, + super::RSA_PSS_2048_8192_SHA256_LEGACY_KEY, + super::RSA_PSS_2048_8192_SHA384_LEGACY_KEY, + super::RSA_PSS_2048_8192_SHA512_LEGACY_KEY, + // Algorithms deprecated because they are nonsensical combinations. + super::ECDSA_P256_SHA384, // Truncates digest. + super::ECDSA_P384_SHA256, // Digest is unnecessarily short. + #[cfg(all(feature = "aws-lc-rs-unstable", not(feature = "aws-lc-rs-fips")))] + super::ML_DSA_44, + #[cfg(all(feature = "aws-lc-rs-unstable", not(feature = "aws-lc-rs-fips")))] + super::ML_DSA_65, + #[cfg(all(feature = "aws-lc-rs-unstable", not(feature = "aws-lc-rs-fips")))] + super::ML_DSA_87, + ]; + + const OK_IF_POINT_COMPRESSION_SUPPORTED: Result<(), Error> = Ok(()); + + #[path = "alg_tests.rs"] + mod alg_tests; + + fn maybe_rsa() -> Result<(), Error> { + Ok(()) + } + + fn unsupported_for_rsa(_sig_alg_id: &[u8], _public_key_alg_id: &[u8]) -> Error { + Error::UnsupportedSignatureAlgorithmForPublicKeyContext( + UnsupportedSignatureAlgorithmForPublicKeyContext { + #[cfg(feature = "alloc")] + signature_algorithm_id: _sig_alg_id.to_vec(), + #[cfg(feature = "alloc")] + public_key_algorithm_id: _public_key_alg_id.to_vec(), + }, + ) + } + + fn invalid_rsa_signature() -> Error { + Error::InvalidSignatureForPublicKey + } + + fn unsupported_for_ecdsa(_sig_alg_id: &[u8], _public_key_alg_id: &[u8]) -> Error { + Error::UnsupportedSignatureAlgorithmForPublicKeyContext( + UnsupportedSignatureAlgorithmForPublicKeyContext { + #[cfg(feature = "alloc")] + signature_algorithm_id: _sig_alg_id.to_vec(), + #[cfg(feature = "alloc")] + public_key_algorithm_id: _public_key_alg_id.to_vec(), + }, + ) + } + + fn unsupported(_sig_alg_id: &[u8]) -> Error { + Error::UnsupportedSignatureAlgorithmContext(UnsupportedSignatureAlgorithmContext { + #[cfg(feature = "alloc")] + signature_algorithm_id: _sig_alg_id.to_vec(), + #[cfg(feature = "alloc")] + supported_algorithms: SUPPORTED_ALGORITHMS_IN_TESTS + .iter() + .map(|&alg| alg.signature_alg_id()) + .collect(), + }) + } +} diff --git a/http/vendor/rustls-webpki/src/cert.rs b/http/vendor/rustls-webpki/src/cert.rs new file mode 100644 index 0000000..1998a14 --- /dev/null +++ b/http/vendor/rustls-webpki/src/cert.rs @@ -0,0 +1,749 @@ +// Copyright 2015 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#[cfg(feature = "alloc")] +use pki_types::SubjectPublicKeyInfoDer; +use pki_types::{CertificateDer, DnsName}; + +use crate::der::{self, CONSTRUCTED, CONTEXT_SPECIFIC, DerIterator, FromDer, Tag}; +use crate::error::{DerTypeId, Error}; +use crate::public_values_eq; +use crate::signed_data::SignedData; +use crate::subject_name::{GeneralName, NameIterator, WildcardDnsNameRef}; +use crate::x509::{ + DistributionPointName, Extension, UnknownExtensionPolicy, remember_extension, + set_extension_once, +}; + +/// A parsed X509 certificate. +pub struct Cert<'a> { + pub(crate) serial: untrusted::Input<'a>, + pub(crate) signed_data: SignedData<'a>, + pub(crate) issuer: untrusted::Input<'a>, + pub(crate) validity: untrusted::Input<'a>, + pub(crate) subject: untrusted::Input<'a>, + pub(crate) spki: untrusted::Input<'a>, + + pub(crate) basic_constraints: Option>, + // key usage (KU) extension (if any). When validating certificate revocation lists (CRLs) this + // field will be consulted to determine if the cert is allowed to sign CRLs. For cert validation + // this field is ignored (for more detail see in `verify_cert.rs` and + // `check_issuer_independent_properties`). + pub(crate) key_usage: Option>, + pub(crate) eku: Option>, + pub(crate) name_constraints: Option>, + pub(crate) subject_alt_name: Option>, + pub(crate) crl_distribution_points: Option>, + + der: CertificateDer<'a>, +} + +impl<'a> Cert<'a> { + pub(crate) fn for_trust_anchor(cert_der: untrusted::Input<'a>) -> Result { + Self::from_input(cert_der, UnknownExtensionPolicy::IgnoreCritical) + } + + pub(crate) fn from_der(cert_der: untrusted::Input<'a>) -> Result { + Self::from_input(cert_der, UnknownExtensionPolicy::default()) + } + + fn from_input( + cert_der: untrusted::Input<'a>, + ext_policy: UnknownExtensionPolicy, + ) -> Result { + let (tbs, signed_data) = + cert_der.read_all(Error::TrailingData(DerTypeId::Certificate), |cert_der| { + der::nested( + cert_der, + der::Tag::Sequence, + Error::TrailingData(DerTypeId::SignedData), + |der| { + // limited to SEQUENCEs of size 2^16 or less. + SignedData::from_der(der, der::TWO_BYTE_DER_SIZE) + }, + ) + })?; + + tbs.read_all( + Error::TrailingData(DerTypeId::CertificateTbsCertificate), + |tbs| { + version3(tbs)?; + + let serial = lenient_certificate_serial_number(tbs)?; + + let signature = der::expect_tag(tbs, der::Tag::Sequence)?; + // TODO: In mozilla::pkix, the comparison is done based on the + // normalized value (ignoring whether or not there is an optional NULL + // parameter for RSA-based algorithms), so this may be too strict. + if !public_values_eq(signature, signed_data.algorithm) { + return Err(Error::SignatureAlgorithmMismatch); + } + + let issuer = der::expect_tag(tbs, der::Tag::Sequence)?; + let validity = der::expect_tag(tbs, der::Tag::Sequence)?; + let subject = der::expect_tag(tbs, der::Tag::Sequence)?; + let spki = der::expect_tag(tbs, der::Tag::Sequence)?; + + // In theory there could be fields [1] issuerUniqueID and [2] + // subjectUniqueID, but in practice there never are, and to keep the + // code small and simple we don't accept any certificates that do + // contain them. + + let mut cert = Cert { + signed_data, + serial, + issuer, + validity, + subject, + spki, + + basic_constraints: None, + key_usage: None, + eku: None, + name_constraints: None, + subject_alt_name: None, + crl_distribution_points: None, + + der: CertificateDer::from(cert_der.as_slice_less_safe()), + }; + + // When used to read X509v3 Certificate.tbsCertificate.extensions, we allow + // the extensions to be empty. This is in spite of RFC5280: + // + // "If present, this field is a SEQUENCE of one or more certificate extensions." + // + // Unfortunately other implementations don't get this right, eg: + // - https://github.com/golang/go/issues/52319 + // - https://github.com/openssl/openssl/issues/20877 + const ALLOW_EMPTY: bool = true; + + if !tbs.at_end() { + der::nested( + tbs, + der::Tag::ContextSpecificConstructed3, + Error::TrailingData(DerTypeId::CertificateExtensions), + |tagged| { + der::nested_of_mut( + tagged, + der::Tag::Sequence, + der::Tag::Sequence, + Error::TrailingData(DerTypeId::Extension), + ALLOW_EMPTY, + |extension| { + remember_cert_extension( + &mut cert, + &Extension::from_der(extension)?, + ext_policy, + ) + }, + ) + }, + )?; + } + + Ok(cert) + }, + ) + } + + /// Returns a list of valid DNS names provided in the subject alternative names extension + /// + /// This function must not be used to implement custom DNS name verification. + /// Checking that a certificate is valid for a given subject name should always be done with + /// [EndEntityCert::verify_is_valid_for_subject_name]. + /// + /// [EndEntityCert::verify_is_valid_for_subject_name]: crate::EndEntityCert::verify_is_valid_for_subject_name + pub fn valid_dns_names(&self) -> impl Iterator { + NameIterator::new(self.subject_alt_name).filter_map(|result| { + let presented_id = match result.ok()? { + GeneralName::DnsName(presented) => presented, + _ => return None, + }; + + // if the name could be converted to a DNS name, return it; otherwise, + // keep going. + let dns_str = core::str::from_utf8(presented_id.as_slice_less_safe()).ok()?; + match DnsName::try_from(dns_str) { + Ok(_) => Some(dns_str), + Err(_) => { + match WildcardDnsNameRef::try_from_ascii(presented_id.as_slice_less_safe()) { + Ok(wildcard_dns_name) => Some(wildcard_dns_name.as_str()), + Err(_) => None, + } + } + } + }) + } + + /// Returns a list of valid URI names provided in the subject alternative names extension + /// + /// This function returns URIs as strings without performing validation beyond checking that + /// they are valid UTF-8. + pub fn valid_uri_names(&self) -> impl Iterator { + NameIterator::new(self.subject_alt_name).filter_map(|result| { + let presented_id = match result.ok()? { + GeneralName::UniformResourceIdentifier(presented) => presented, + _ => return None, + }; + + // if the URI can be converted to a valid UTF-8 string, return it; otherwise, + // keep going. + core::str::from_utf8(presented_id.as_slice_less_safe()).ok() + }) + } + + /// Raw certificate serial number. + /// + /// This is in big-endian byte order, in twos-complement encoding. + /// + /// If the caller were to add an `INTEGER` tag and suitable length, this + /// would become a valid DER encoding. + pub fn serial(&self) -> &[u8] { + self.serial.as_slice_less_safe() + } + + /// Raw DER-encoded certificate issuer. + /// + /// This does not include the outer `SEQUENCE` tag or length. + pub fn issuer(&self) -> &[u8] { + self.issuer.as_slice_less_safe() + } + + /// Raw DER encoded certificate subject. + /// + /// This does not include the outer `SEQUENCE` tag or length. + pub fn subject(&self) -> &[u8] { + self.subject.as_slice_less_safe() + } + + /// Get the RFC 5280-compliant [`SubjectPublicKeyInfoDer`] (SPKI) of this [`Cert`]. + /// + /// This **does** include the outer `SEQUENCE` tag and length. + #[cfg(feature = "alloc")] + pub fn subject_public_key_info(&self) -> SubjectPublicKeyInfoDer<'static> { + // Our SPKI representation contains only the content of the RFC 5280 SEQUENCE + // So we wrap the SPKI contents back into a properly-encoded ASN.1 SEQUENCE + SubjectPublicKeyInfoDer::from(der::asn1_wrap( + Tag::Sequence, + self.spki.as_slice_less_safe(), + )) + } + + /// Returns an iterator over the certificate's cRLDistributionPoints extension values, if any. + pub(crate) fn crl_distribution_points( + &self, + ) -> Option, Error>>> { + self.crl_distribution_points.map(DerIterator::new) + } + + /// Raw DER-encoded representation of the certificate. + pub fn der(&self) -> CertificateDer<'a> { + self.der.clone() // This is cheap, just cloning a reference. + } +} + +// mozilla::pkix supports v1, v2, v3, and v4, including both the implicit +// (correct) and explicit (incorrect) encoding of v1. We allow only v3. +fn version3(input: &mut untrusted::Reader<'_>) -> Result<(), Error> { + der::nested( + input, + der::Tag::ContextSpecificConstructed0, + Error::UnsupportedCertVersion, + |input| { + let version = u8::from_der(input)?; + if version != 2 { + // v3 + return Err(Error::UnsupportedCertVersion); + } + Ok(()) + }, + ) +} + +pub(crate) fn lenient_certificate_serial_number<'a>( + input: &mut untrusted::Reader<'a>, +) -> Result, Error> { + // https://tools.ietf.org/html/rfc5280#section-4.1.2.2: + // * Conforming CAs MUST NOT use serialNumber values longer than 20 octets." + // * "The serial number MUST be a positive integer [...]" + // + // However, we don't enforce these constraints, as there are widely-deployed trust anchors + // and many X.509 implementations in common use that violate these constraints. This is called + // out by the same section of RFC 5280 as cited above: + // Note: Non-conforming CAs may issue certificates with serial numbers + // that are negative or zero. Certificate users SHOULD be prepared to + // gracefully handle such certificates. + der::expect_tag(input, Tag::Integer) +} + +fn remember_cert_extension<'a>( + cert: &mut Cert<'a>, + extension: &Extension<'a>, + ext_policy: UnknownExtensionPolicy, +) -> Result<(), Error> { + // We don't do anything with certificate policies so we can safely ignore + // all policy-related stuff. We assume that the policy-related extensions + // are not marked critical. + + remember_extension(extension, ext_policy, |id| { + let out = match id { + // id-ce-keyUsage 2.5.29.15. + 15 => &mut cert.key_usage, + + // id-ce-subjectAltName 2.5.29.17 + 17 => &mut cert.subject_alt_name, + + // id-ce-basicConstraints 2.5.29.19 + 19 => &mut cert.basic_constraints, + + // id-ce-nameConstraints 2.5.29.30 + 30 => &mut cert.name_constraints, + + // id-ce-cRLDistributionPoints 2.5.29.31 + 31 => &mut cert.crl_distribution_points, + + // id-ce-extKeyUsage 2.5.29.37 + 37 => &mut cert.eku, + + // Unsupported extension + _ => return extension.unsupported(ext_policy), + }; + + set_extension_once(out, || { + extension.value.read_all(Error::BadDer, |value| match id { + // Unlike the other extensions we remember KU is a BitString and not a Sequence. We + // read the raw bytes here and parse at the time of use. + 15 => Ok(value.read_bytes_to_end()), + // All other remembered certificate extensions are wrapped in a Sequence. + _ => der::expect_tag(value, Tag::Sequence), + }) + }) + }) +} + +/// A certificate revocation list (CRL) distribution point, describing a source of +/// CRL information for a given certificate as described in RFC 5280 section 4.2.3.13[^1]. +/// +/// [^1]: +pub(crate) struct CrlDistributionPoint<'a> { + /// distributionPoint describes the location of CRL information. + distribution_point: Option>, + + /// reasons holds a bit flag set of certificate revocation reasons associated with the + /// CRL distribution point. + pub(crate) reasons: Option>, + + /// when the CRL issuer is not the certificate issuer, crl_issuer identifies the issuer of the + /// CRL. + pub(crate) crl_issuer: Option>, +} + +impl<'a> CrlDistributionPoint<'a> { + /// Return the distribution point names (if any). + pub(crate) fn names(&self) -> Result>, Error> { + self.distribution_point + .map(|input| DistributionPointName::from_der(&mut untrusted::Reader::new(input))) + .transpose() + } +} + +impl<'a> FromDer<'a> for CrlDistributionPoint<'a> { + fn from_der(reader: &mut untrusted::Reader<'a>) -> Result { + // RFC 5280 section §4.2.1.13: + // A DistributionPoint consists of three fields, each of which is optional: + // distributionPoint, reasons, and cRLIssuer. + let mut result = CrlDistributionPoint { + distribution_point: None, + reasons: None, + crl_issuer: None, + }; + + der::nested( + reader, + Tag::Sequence, + Error::TrailingData(Self::TYPE_ID), + |der| { + const DISTRIBUTION_POINT_TAG: u8 = CONTEXT_SPECIFIC | CONSTRUCTED; + const REASONS_TAG: u8 = CONTEXT_SPECIFIC | 1; + const CRL_ISSUER_TAG: u8 = CONTEXT_SPECIFIC | CONSTRUCTED | 2; + + while !der.at_end() { + let (tag, value) = der::read_tag_and_get_value(der)?; + match tag { + DISTRIBUTION_POINT_TAG => { + set_extension_once(&mut result.distribution_point, || Ok(value))? + } + REASONS_TAG => set_extension_once(&mut result.reasons, || { + der::bit_string_flags(value) + })?, + CRL_ISSUER_TAG => set_extension_once(&mut result.crl_issuer, || Ok(value))?, + _ => return Err(Error::BadDer), + } + } + + // RFC 5280 section §4.2.1.13: + // a DistributionPoint MUST NOT consist of only the reasons field; either distributionPoint or + // cRLIssuer MUST be present. + match (result.distribution_point, result.crl_issuer) { + (None, None) => Err(Error::MalformedExtensions), + _ => Ok(result), + } + }, + ) + } + + const TYPE_ID: DerTypeId = DerTypeId::CrlDistributionPoint; +} + +#[cfg(test)] +mod tests { + #[cfg(feature = "alloc")] + use alloc::vec::Vec; + + use super::*; + #[cfg(feature = "alloc")] + use crate::crl::RevocationReason; + + #[test] + // Note: cert::parse_cert is crate-local visibility, and EndEntityCert doesn't expose the + // inner Cert, or the serial number. As a result we test that the raw serial value + // is read correctly here instead of in tests/integration.rs. + fn test_serial_read() { + let ee = include_bytes!("../tests/misc/serial_neg_ee.der"); + let cert = Cert::from_der(untrusted::Input::from(ee)).expect("failed to parse certificate"); + assert_eq!(cert.serial.as_slice_less_safe(), &[255, 33, 82, 65, 17]); + + let ee = include_bytes!("../tests/misc/serial_large_positive.der"); + let cert = Cert::from_der(untrusted::Input::from(ee)).expect("failed to parse certificate"); + assert_eq!( + cert.serial.as_slice_less_safe(), + &[ + 0, 230, 9, 254, 122, 234, 0, 104, 140, 224, 36, 180, 237, 32, 27, 31, 239, 82, 180, + 68, 209 + ] + ) + } + + #[cfg(feature = "alloc")] + #[test] + fn test_spki_read() { + let ee = include_bytes!("../tests/ed25519/ee.der"); + let cert = Cert::from_der(untrusted::Input::from(ee)).expect("failed to parse certificate"); + // How did I get this lovely string of hex bytes? + // openssl x509 -in tests/ed25519/ee.der -pubkey -noout > pubkey.pem + // openssl ec -pubin -in pubkey.pem -outform DER -out pubkey.der + // xxd -plain -cols 1 pubkey.der + let expected_spki = [ + 0x30, 0x2a, 0x30, 0x05, 0x06, 0x03, 0x2b, 0x65, 0x70, 0x03, 0x21, 0x00, 0xfe, 0x5a, + 0x1e, 0x36, 0x6c, 0x17, 0x27, 0x5b, 0xf1, 0x58, 0x1e, 0x3a, 0x0e, 0xe6, 0x56, 0x29, + 0x8d, 0x9e, 0x1b, 0x3f, 0xd3, 0x3f, 0x96, 0x46, 0xef, 0xbf, 0x04, 0x6b, 0xc7, 0x3d, + 0x47, 0x5c, + ]; + assert_eq!(expected_spki, *cert.subject_public_key_info()) + } + + #[test] + #[cfg(feature = "alloc")] + fn test_crl_distribution_point_netflix() { + let ee = include_bytes!("../tests/netflix/ee.der"); + let inter = include_bytes!("../tests/netflix/inter.der"); + let ee_cert = Cert::from_der(untrusted::Input::from(ee)).expect("failed to parse EE cert"); + let cert = + Cert::from_der(untrusted::Input::from(inter)).expect("failed to parse certificate"); + + // The end entity certificate shouldn't have a distribution point. + assert!(ee_cert.crl_distribution_points.is_none()); + + // We expect to be able to parse the intermediate certificate's CRL distribution points. + let crl_distribution_points = cert + .crl_distribution_points() + .expect("missing distribution points extension") + .collect::, Error>>() + .expect("failed to parse distribution points"); + + // There should be one distribution point present. + assert_eq!(crl_distribution_points.len(), 1); + let crl_distribution_point = crl_distribution_points + .first() + .expect("missing distribution point"); + + // The distribution point shouldn't have revocation reasons listed. + assert!(crl_distribution_point.reasons.is_none()); + + // The distribution point shouldn't have a CRL issuer listed. + assert!(crl_distribution_point.crl_issuer.is_none()); + + // We should be able to parse the distribution point name. + let distribution_point_name = crl_distribution_point + .names() + .expect("failed to parse distribution point names") + .expect("missing distribution point name"); + + // We expect the distribution point name to be a sequence of GeneralNames, not a name + // relative to the CRL issuer. + let names = match distribution_point_name { + DistributionPointName::NameRelativeToCrlIssuer => { + panic!("unexpected name relative to crl issuer") + } + DistributionPointName::FullName(names) => names, + }; + + // The general names should parse. + let names = names + .collect::, Error>>() + .expect("failed to parse general names"); + + // There should be one general name. + assert_eq!(names.len(), 1); + let name = names.first().expect("missing general name"); + + // The general name should be a URI matching the expected value. + match name { + GeneralName::UniformResourceIdentifier(uri) => { + assert_eq!( + uri.as_slice_less_safe(), + "http://s.symcb.com/pca3-g3.crl".as_bytes() + ); + } + _ => panic!("unexpected general name type"), + } + } + + #[test] + #[cfg(feature = "alloc")] + fn test_crl_distribution_point_with_reasons() { + let der = include_bytes!("../tests/crl_distrib_point/with_reasons.der"); + let cert = + Cert::from_der(untrusted::Input::from(der)).expect("failed to parse certificate"); + + // We expect to be able to parse the intermediate certificate's CRL distribution points. + let crl_distribution_points = cert + .crl_distribution_points() + .expect("missing distribution points extension") + .collect::, Error>>() + .expect("failed to parse distribution points"); + + // There should be one distribution point present. + assert_eq!(crl_distribution_points.len(), 1); + let crl_distribution_point = crl_distribution_points + .first() + .expect("missing distribution point"); + + // The distribution point should include the expected revocation reasons, and no others. + let reasons = crl_distribution_point + .reasons + .as_ref() + .expect("missing revocation reasons"); + let expected = &[ + RevocationReason::KeyCompromise, + RevocationReason::AffiliationChanged, + ]; + for reason in RevocationReason::iter() { + #[allow(clippy::as_conversions)] + // revocation reason is u8, infallible to convert to usize. + match expected.contains(&reason) { + true => assert!(reasons.bit_set(reason as usize)), + false => assert!(!reasons.bit_set(reason as usize)), + } + } + } + + #[test] + #[cfg(feature = "alloc")] + fn test_crl_distribution_point_with_crl_issuer() { + let der = include_bytes!("../tests/crl_distrib_point/with_crl_issuer.der"); + let cert = + Cert::from_der(untrusted::Input::from(der)).expect("failed to parse certificate"); + + // We expect to be able to parse the intermediate certificate's CRL distribution points. + let crl_distribution_points = cert + .crl_distribution_points() + .expect("missing distribution points extension") + .collect::, Error>>() + .expect("failed to parse distribution points"); + + // There should be one distribution point present. + assert_eq!(crl_distribution_points.len(), 1); + let crl_distribution_point = crl_distribution_points + .first() + .expect("missing distribution point"); + + // The CRL issuer should be present, but not anything else. + assert!(crl_distribution_point.crl_issuer.is_some()); + assert!(crl_distribution_point.distribution_point.is_none()); + assert!(crl_distribution_point.reasons.is_none()); + } + + #[test] + #[cfg(feature = "alloc")] + fn test_crl_distribution_point_bad_der() { + // Created w/ + // ascii2der -i tests/crl_distrib_point/unknown_tag.der.txt -o tests/crl_distrib_point/unknown_tag.der + let der = include_bytes!("../tests/crl_distrib_point/unknown_tag.der"); + let cert = + Cert::from_der(untrusted::Input::from(der)).expect("failed to parse certificate"); + + // We expect there to be a distribution point extension, but parsing it should fail + // due to the unknown tag in the SEQUENCE. + let result = cert + .crl_distribution_points() + .expect("missing distribution points extension") + .collect::, Error>>(); + assert!(matches!(result, Err(Error::BadDer))); + } + + #[test] + #[cfg(feature = "alloc")] + fn test_crl_distribution_point_only_reasons() { + // Created w/ + // ascii2der -i tests/crl_distrib_point/only_reasons.der.txt -o tests/crl_distrib_point/only_reasons.der + let der = include_bytes!("../tests/crl_distrib_point/only_reasons.der"); + let cert = + Cert::from_der(untrusted::Input::from(der)).expect("failed to parse certificate"); + + // We expect there to be a distribution point extension, but parsing it should fail + // because no distribution points or cRLIssuer are set in the SEQUENCE, just reason codes. + let result = cert + .crl_distribution_points() + .expect("missing distribution points extension") + .collect::, Error>>(); + assert!(matches!(result, Err(Error::MalformedExtensions))); + } + + #[test] + #[cfg(feature = "alloc")] + fn test_crl_distribution_point_name_relative_to_issuer() { + let der = include_bytes!("../tests/crl_distrib_point/dp_name_relative_to_issuer.der"); + let cert = + Cert::from_der(untrusted::Input::from(der)).expect("failed to parse certificate"); + + // We expect to be able to parse the intermediate certificate's CRL distribution points. + let crl_distribution_points = cert + .crl_distribution_points() + .expect("missing distribution points extension") + .collect::, Error>>() + .expect("failed to parse distribution points"); + + // There should be one distribution point present. + assert_eq!(crl_distribution_points.len(), 1); + let crl_distribution_point = crl_distribution_points + .first() + .expect("missing distribution point"); + + assert!(crl_distribution_point.crl_issuer.is_none()); + assert!(crl_distribution_point.reasons.is_none()); + + // We should be able to parse the distribution point name. + let distribution_point_name = crl_distribution_point + .names() + .expect("failed to parse distribution point names") + .expect("missing distribution point name"); + + // We expect the distribution point name to be a name relative to the CRL issuer. + assert!(matches!( + distribution_point_name, + DistributionPointName::NameRelativeToCrlIssuer + )); + } + + #[test] + #[cfg(feature = "alloc")] + fn test_crl_distribution_point_unknown_name_tag() { + // Created w/ + // ascii2der -i tests/crl_distrib_point/unknown_dp_name_tag.der.txt > tests/crl_distrib_point/unknown_dp_name_tag.der + let der = include_bytes!("../tests/crl_distrib_point/unknown_dp_name_tag.der"); + let cert = + Cert::from_der(untrusted::Input::from(der)).expect("failed to parse certificate"); + + // We expect to be able to parse the intermediate certificate's CRL distribution points. + let crl_distribution_points = cert + .crl_distribution_points() + .expect("missing distribution points extension") + .collect::, Error>>() + .expect("failed to parse distribution points"); + + // There should be one distribution point present. + assert_eq!(crl_distribution_points.len(), 1); + let crl_distribution_point = crl_distribution_points + .first() + .expect("missing distribution point"); + + // Parsing the distrubition point names should fail due to the unknown name tag. + let result = crl_distribution_point.names(); + assert!(matches!(result, Err(Error::BadDer))) + } + + #[test] + #[cfg(feature = "alloc")] + fn test_crl_distribution_point_multiple() { + let der = include_bytes!("../tests/crl_distrib_point/multiple_distribution_points.der"); + let cert = + Cert::from_der(untrusted::Input::from(der)).expect("failed to parse certificate"); + + // We expect to be able to parse the intermediate certificate's CRL distribution points. + let crl_distribution_points = cert + .crl_distribution_points() + .expect("missing distribution points extension") + .collect::, Error>>() + .expect("failed to parse distribution points"); + + // There should be two distribution points present. + let (point_a, point_b) = ( + crl_distribution_points + .first() + .expect("missing first distribution point"), + crl_distribution_points + .get(1) + .expect("missing second distribution point"), + ); + + fn get_names<'a>( + point: &'a CrlDistributionPoint<'a>, + ) -> impl Iterator, Error>> { + match point + .names() + .expect("failed to parse distribution point names") + .expect("missing distribution point name") + { + DistributionPointName::NameRelativeToCrlIssuer => { + panic!("unexpected relative name") + } + DistributionPointName::FullName(names) => names, + } + } + + fn uri_bytes<'a>(name: &'a GeneralName<'a>) -> &'a [u8] { + match name { + GeneralName::UniformResourceIdentifier(uri) => uri.as_slice_less_safe(), + _ => panic!("unexpected name type"), + } + } + + // We expect to find three URIs across the two distribution points. + let expected_names = [ + "http://example.com/crl.1.der".as_bytes(), + "http://example.com/crl.2.der".as_bytes(), + "http://example.com/crl.3.der".as_bytes(), + ]; + let all_names = get_names(point_a) + .chain(get_names(point_b)) + .collect::, Error>>() + .expect("failed to parse names"); + + assert_eq!( + all_names.iter().map(uri_bytes).collect::>(), + expected_names + ); + } +} diff --git a/http/vendor/rustls-webpki/src/crl/mod.rs b/http/vendor/rustls-webpki/src/crl/mod.rs new file mode 100644 index 0000000..de0bc35 --- /dev/null +++ b/http/vendor/rustls-webpki/src/crl/mod.rs @@ -0,0 +1,374 @@ +// Copyright 2023 Daniel McCarney. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use pki_types::{SignatureVerificationAlgorithm, UnixTime}; + +use crate::error::Error; +use crate::verify_cert::{Budget, PathNode, Role}; +use crate::{der, public_values_eq}; + +use core::fmt::Debug; + +mod types; +pub use types::{ + BorrowedCertRevocationList, BorrowedRevokedCert, CertRevocationList, RevocationReason, +}; +#[cfg(feature = "alloc")] +pub use types::{OwnedCertRevocationList, OwnedRevokedCert}; + +/// Builds a RevocationOptions instance to control how revocation checking is performed. +#[derive(Debug, Copy, Clone)] +pub struct RevocationOptionsBuilder<'a> { + crls: &'a [&'a CertRevocationList<'a>], + + depth: RevocationCheckDepth, + + status_policy: UnknownStatusPolicy, + + expiration_policy: ExpirationPolicy, +} + +impl<'a> RevocationOptionsBuilder<'a> { + /// Create a builder that will perform revocation checking using the provided certificate + /// revocation lists (CRLs). At least one CRL must be provided. + /// + /// Use [RevocationOptionsBuilder::build] to create a [RevocationOptions] instance. + /// + /// By default revocation checking will be performed on both the end-entity (leaf) certificate + /// and intermediate certificates. This can be customized using the + /// [RevocationOptionsBuilder::with_depth] method. + /// + /// By default revocation checking will fail if the revocation status of a certificate cannot + /// be determined. This can be customized using the + /// [RevocationOptionsBuilder::with_status_policy] method. + /// + /// By default revocation checking will *not* fail if the verification time is beyond the time + /// in the CRL nextUpdate field. This can be customized using the + /// [RevocationOptionsBuilder::with_expiration_policy] method. + pub fn new(crls: &'a [&'a CertRevocationList<'a>]) -> Result { + if crls.is_empty() { + return Err(CrlsRequired(())); + } + + Ok(Self { + crls, + depth: RevocationCheckDepth::Chain, + status_policy: UnknownStatusPolicy::Deny, + expiration_policy: ExpirationPolicy::Ignore, + }) + } + + /// Customize the depth at which revocation checking will be performed, controlling + /// whether only the end-entity (leaf) certificate in the chain to a trust anchor will + /// have its revocation status checked, or whether the intermediate certificates will as well. + pub fn with_depth(mut self, depth: RevocationCheckDepth) -> Self { + self.depth = depth; + self + } + + /// Customize whether unknown revocation status is an error, or permitted. + pub fn with_status_policy(mut self, policy: UnknownStatusPolicy) -> Self { + self.status_policy = policy; + self + } + + /// Customize whether the CRL nextUpdate field (i.e. expiration) is enforced. + pub fn with_expiration_policy(mut self, policy: ExpirationPolicy) -> Self { + self.expiration_policy = policy; + self + } + + /// Construct a [RevocationOptions] instance based on the builder's configuration. + pub fn build(self) -> RevocationOptions<'a> { + RevocationOptions { + crls: self.crls, + depth: self.depth, + status_policy: self.status_policy, + expiration_policy: self.expiration_policy, + } + } +} + +/// Describes how revocation checking is performed, if at all. Can be constructed with a +/// [RevocationOptionsBuilder] instance. +#[derive(Debug, Copy, Clone)] +pub struct RevocationOptions<'a> { + pub(crate) crls: &'a [&'a CertRevocationList<'a>], + pub(crate) depth: RevocationCheckDepth, + pub(crate) status_policy: UnknownStatusPolicy, + pub(crate) expiration_policy: ExpirationPolicy, +} + +impl RevocationOptions<'_> { + #[allow(clippy::too_many_arguments)] + pub(crate) fn check( + &self, + path: &PathNode<'_>, + issuer_subject: untrusted::Input<'_>, + issuer_spki: untrusted::Input<'_>, + issuer_ku: Option>, + supported_sig_algs: &[&dyn SignatureVerificationAlgorithm], + budget: &mut Budget, + time: UnixTime, + ) -> Result, Error> { + assert!(public_values_eq(path.cert.issuer, issuer_subject)); + + // If the policy only specifies checking EndEntity revocation state and we're looking at an + // issuer certificate, return early without considering the certificate's revocation state. + if let (RevocationCheckDepth::EndEntity, Role::Issuer) = (self.depth, path.role()) { + return Ok(None); + } + + let crl = self + .crls + .iter() + .find(|candidate_crl| candidate_crl.authoritative(path)); + + use UnknownStatusPolicy::*; + let crl = match (crl, self.status_policy) { + (Some(crl), _) => crl, + // If the policy allows unknown, return Ok(None) to indicate that the certificate + // was not confirmed as CertNotRevoked, but that this isn't an error condition. + (None, Allow) => return Ok(None), + // Otherwise, this is an error condition based on the provided policy. + (None, _) => return Err(Error::UnknownRevocationStatus), + }; + + // Verify the CRL signature with the issuer SPKI. + // TODO(XXX): consider whether we can refactor so this happens once up-front, instead + // of per-lookup. + // https://github.com/rustls/webpki/issues/81 + crl.verify_signature(supported_sig_algs, issuer_spki, budget) + .map_err(crl_signature_err)?; + + if self.expiration_policy == ExpirationPolicy::Enforce { + crl.check_expiration(time)?; + } + + // Verify that if the issuer has a KeyUsage bitstring it asserts cRLSign. + KeyUsageMode::CrlSign.check(issuer_ku)?; + + // Try to find the cert serial in the verified CRL contents. + let cert_serial = path.cert.serial.as_slice_less_safe(); + match crl.find_serial(cert_serial)? { + None => Ok(Some(CertNotRevoked::assertion())), + Some(_) => Err(Error::CertRevoked), + } + } +} + +// https://www.rfc-editor.org/rfc/rfc5280#section-4.2.1.3 +#[repr(u8)] +#[derive(Clone, Copy)] +enum KeyUsageMode { + // DigitalSignature = 0, + // ContentCommitment = 1, + // KeyEncipherment = 2, + // DataEncipherment = 3, + // KeyAgreement = 4, + // CertSign = 5, + CrlSign = 6, + // EncipherOnly = 7, + // DecipherOnly = 8, +} + +impl KeyUsageMode { + // https://www.rfc-editor.org/rfc/rfc5280#section-4.2.1.3 + fn check(self, input: Option>) -> Result<(), Error> { + let bit_string = match input { + Some(input) => { + der::expect_tag(&mut untrusted::Reader::new(input), der::Tag::BitString)? + } + // While RFC 5280 requires KeyUsage be present, historically the absence of a KeyUsage + // has been treated as "Any Usage". We follow that convention here and assume the absence + // of KeyUsage implies the required_ku_bit_if_present we're checking for. + None => return Ok(()), + }; + + let flags = der::bit_string_flags(bit_string)?; + #[allow(clippy::as_conversions)] // u8 always fits in usize. + match flags.bit_set(self as usize) { + true => Ok(()), + false => Err(Error::IssuerNotCrlSigner), + } + } +} + +// When verifying CRL signed data we want to disambiguate the context of possible errors by mapping +// them to CRL specific variants that a consumer can use to tell the issue was with the CRL's +// signature, not a certificate. +fn crl_signature_err(err: Error) -> Error { + match err { + #[allow(deprecated)] + Error::UnsupportedSignatureAlgorithm => Error::UnsupportedCrlSignatureAlgorithm, + Error::UnsupportedSignatureAlgorithmContext(cx) => { + Error::UnsupportedCrlSignatureAlgorithmContext(cx) + } + #[allow(deprecated)] + Error::UnsupportedSignatureAlgorithmForPublicKey => { + Error::UnsupportedCrlSignatureAlgorithmForPublicKey + } + Error::UnsupportedSignatureAlgorithmForPublicKeyContext(cx) => { + Error::UnsupportedCrlSignatureAlgorithmForPublicKeyContext(cx) + } + Error::InvalidSignatureForPublicKey => Error::InvalidCrlSignatureForPublicKey, + _ => err, + } +} + +/// Describes how much of a certificate chain is checked for revocation status. +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub enum RevocationCheckDepth { + /// Only check the end entity (leaf) certificate's revocation status. + EndEntity, + /// Check the revocation status of the end entity (leaf) and all intermediates. + Chain, +} + +/// Describes how to handle the case where a certificate's revocation status is unknown. +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub enum UnknownStatusPolicy { + /// Treat unknown revocation status permissively, acting as if the certificate were + /// not revoked. + Allow, + /// Treat unknown revocation status as an error condition, yielding + /// [Error::UnknownRevocationStatus]. + Deny, +} + +/// Describes how to handle the nextUpdate field of the CRL (i.e. expiration). +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub enum ExpirationPolicy { + /// Enforce the verification time is before the time in the nextUpdate field. + /// Treats an expired CRL as an error condition yielding [Error::CrlExpired]. + Enforce, + /// Ignore the CRL nextUpdate field. + Ignore, +} + +// Zero-sized marker type representing positive assertion that revocation status was checked +// for a certificate and the result was that the certificate is not revoked. +pub(crate) struct CertNotRevoked(()); + +impl CertNotRevoked { + // Construct a CertNotRevoked marker. + fn assertion() -> Self { + Self(()) + } +} + +#[derive(Debug, Copy, Clone)] +/// An opaque error indicating the caller must provide at least one CRL when building a +/// [RevocationOptions] instance. +pub struct CrlsRequired(pub(crate) ()); + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + // redundant clone, clone_on_copy allowed to verify derived traits. + #[allow(clippy::redundant_clone, clippy::clone_on_copy)] + fn test_revocation_opts_builder() { + // Trying to build a RevocationOptionsBuilder w/o CRLs should err. + let result = RevocationOptionsBuilder::new(&[]); + assert!(matches!(result, Err(CrlsRequired(_)))); + + // The CrlsRequired error should be debug and clone when alloc is enabled. + #[cfg(feature = "alloc")] + { + let err = result.unwrap_err(); + std::println!("{:?}", err.clone()); + } + + // It should be possible to build a revocation options builder with defaults. + let crl = include_bytes!("../../tests/crls/crl.valid.der"); + let crl = BorrowedCertRevocationList::from_der(&crl[..]) + .unwrap() + .into(); + let crls = [&crl]; + let builder = RevocationOptionsBuilder::new(&crls).unwrap(); + #[cfg(feature = "alloc")] + { + // The builder should be debug, and clone when alloc is enabled + std::println!("{builder:?}"); + _ = builder.clone(); + } + let opts = builder.build(); + assert_eq!(opts.depth, RevocationCheckDepth::Chain); + assert_eq!(opts.status_policy, UnknownStatusPolicy::Deny); + assert_eq!(opts.expiration_policy, ExpirationPolicy::Ignore); + assert_eq!(opts.crls.len(), 1); + + // It should be possible to build a revocation options builder with custom depth. + let opts = RevocationOptionsBuilder::new(&crls) + .unwrap() + .with_depth(RevocationCheckDepth::EndEntity) + .build(); + assert_eq!(opts.depth, RevocationCheckDepth::EndEntity); + assert_eq!(opts.status_policy, UnknownStatusPolicy::Deny); + assert_eq!(opts.expiration_policy, ExpirationPolicy::Ignore); + assert_eq!(opts.crls.len(), 1); + + // It should be possible to build a revocation options builder that allows unknown + // revocation status. + let opts = RevocationOptionsBuilder::new(&crls) + .unwrap() + .with_status_policy(UnknownStatusPolicy::Allow) + .build(); + assert_eq!(opts.depth, RevocationCheckDepth::Chain); + assert_eq!(opts.status_policy, UnknownStatusPolicy::Allow); + assert_eq!(opts.expiration_policy, ExpirationPolicy::Ignore); + assert_eq!(opts.crls.len(), 1); + + // It should be possible to specify both depth and unknown status policy together. + let opts = RevocationOptionsBuilder::new(&crls) + .unwrap() + .with_status_policy(UnknownStatusPolicy::Allow) + .with_depth(RevocationCheckDepth::EndEntity) + .build(); + assert_eq!(opts.depth, RevocationCheckDepth::EndEntity); + assert_eq!(opts.status_policy, UnknownStatusPolicy::Allow); + assert_eq!(opts.expiration_policy, ExpirationPolicy::Ignore); + assert_eq!(opts.crls.len(), 1); + + // The same should be true for explicitly forbidding unknown status. + let opts = RevocationOptionsBuilder::new(&crls) + .unwrap() + .with_status_policy(UnknownStatusPolicy::Deny) + .with_depth(RevocationCheckDepth::EndEntity) + .build(); + assert_eq!(opts.depth, RevocationCheckDepth::EndEntity); + assert_eq!(opts.status_policy, UnknownStatusPolicy::Deny); + assert_eq!(opts.expiration_policy, ExpirationPolicy::Ignore); + assert_eq!(opts.crls.len(), 1); + + // It should be possible to build a revocation options builder that allows unknown + // revocation status. + let opts = RevocationOptionsBuilder::new(&crls) + .unwrap() + .with_expiration_policy(ExpirationPolicy::Enforce) + .build(); + assert_eq!(opts.depth, RevocationCheckDepth::Chain); + assert_eq!(opts.status_policy, UnknownStatusPolicy::Deny); + assert_eq!(opts.expiration_policy, ExpirationPolicy::Enforce); + assert_eq!(opts.crls.len(), 1); + + // Built revocation options should be debug and clone when alloc is enabled. + #[cfg(feature = "alloc")] + { + std::println!("{:?}", opts.clone()); + } + } +} diff --git a/http/vendor/rustls-webpki/src/crl/types.rs b/http/vendor/rustls-webpki/src/crl/types.rs new file mode 100644 index 0000000..f81bf86 --- /dev/null +++ b/http/vendor/rustls-webpki/src/crl/types.rs @@ -0,0 +1,1291 @@ +#[cfg(feature = "alloc")] +use alloc::collections::BTreeMap; +#[cfg(feature = "alloc")] +use alloc::vec::Vec; +use core::fmt::Debug; + +use pki_types::{SignatureVerificationAlgorithm, UnixTime}; + +use crate::cert::lenient_certificate_serial_number; +use crate::crl::crl_signature_err; +use crate::der::{self, CONSTRUCTED, CONTEXT_SPECIFIC, DerIterator, FromDer, Tag}; +use crate::error::{DerTypeId, Error}; +use crate::public_values_eq; +use crate::signed_data::{self, SignedData}; +use crate::subject_name::GeneralName; +use crate::verify_cert::{Budget, PathNode, Role}; +use crate::x509::{ + DistributionPointName, Extension, UnknownExtensionPolicy, remember_extension, + set_extension_once, +}; + +/// A RFC 5280[^1] profile Certificate Revocation List (CRL). +/// +/// May be either an owned, or a borrowed representation. +/// +/// [^1]: +#[derive(Debug)] +pub enum CertRevocationList<'a> { + /// An owned representation of a CRL. + #[cfg(feature = "alloc")] + Owned(OwnedCertRevocationList), + /// A borrowed representation of a CRL. + Borrowed(BorrowedCertRevocationList<'a>), +} + +#[cfg(feature = "alloc")] +impl From for CertRevocationList<'_> { + fn from(crl: OwnedCertRevocationList) -> Self { + Self::Owned(crl) + } +} + +impl<'a> From> for CertRevocationList<'a> { + fn from(crl: BorrowedCertRevocationList<'a>) -> Self { + Self::Borrowed(crl) + } +} + +impl CertRevocationList<'_> { + /// Return the DER encoded issuer of the CRL. + pub fn issuer(&self) -> &[u8] { + match self { + #[cfg(feature = "alloc")] + CertRevocationList::Owned(crl) => crl.issuer.as_ref(), + CertRevocationList::Borrowed(crl) => crl.issuer.as_slice_less_safe(), + } + } + + /// Return the DER encoded issuing distribution point of the CRL, if any. + pub fn issuing_distribution_point(&self) -> Option<&[u8]> { + match self { + #[cfg(feature = "alloc")] + CertRevocationList::Owned(crl) => crl.issuing_distribution_point.as_deref(), + CertRevocationList::Borrowed(crl) => crl + .issuing_distribution_point + .map(|idp| idp.as_slice_less_safe()), + } + } + + /// Try to find a revoked certificate in the CRL by DER encoded serial number. This + /// may yield an error if the CRL has malformed revoked certificates. + pub fn find_serial(&self, serial: &[u8]) -> Result>, Error> { + match self { + #[cfg(feature = "alloc")] + CertRevocationList::Owned(crl) => crl.find_serial(serial), + CertRevocationList::Borrowed(crl) => crl.find_serial(serial), + } + } + + /// Returns true if the CRL can be considered authoritative for the given certificate. + /// + /// A CRL is considered authoritative for a certificate when: + /// * The certificate issuer matches the CRL issuer and, + /// * The certificate has no CRL distribution points, and the CRL has no issuing distribution + /// point extension. + /// * Or, the certificate has no CRL distribution points, but the the CRL has an issuing + /// distribution point extension with a scope that includes the certificate. + /// * Or, the certificate has CRL distribution points, and the CRL has an issuing + /// distribution point extension with a scope that includes the certificate, and at least + /// one distribution point full name is a URI type general name that can also be found in + /// the CRL issuing distribution point full name general name sequence. + /// * Or, the certificate has CRL distribution points, and the CRL has no issuing + /// distribution point extension. + /// + /// In all other circumstances the CRL is not considered authoritative. + pub(crate) fn authoritative(&self, path: &PathNode<'_>) -> bool { + // In all cases we require that the authoritative CRL have the same issuer + // as the certificate. Recall we do not support indirect CRLs. + if self.issuer() != path.cert.issuer() { + return false; + } + + let crl_idp = match self.issuing_distribution_point() { + // If the CRL has an issuing distribution point, parse it so we can consider its scope + // and compare against the cert CRL distribution points, if present. + Some(crl_idp) => { + match IssuingDistributionPoint::from_der(untrusted::Input::from(crl_idp)) { + Ok(crl_idp) => crl_idp, + Err(_) => return false, // Note: shouldn't happen - we verify IDP at CRL-load. + } + } + // If the CRL has no issuing distribution point we assume the CRL scope + // to be "everything" and consider the CRL authoritative for the cert based on the + // issuer matching. We do not need to consider the certificate's CRL distribution point + // extension (see also https://github.com/rustls/webpki/issues/228). + None => return true, + }; + + crl_idp.authoritative_for(path) + } + + /// Verify the CRL signature using the issuer certificate and a list of supported signature + /// verification algorithms, consuming signature operations from the [`Budget`]. + pub(crate) fn verify_signature( + &self, + supported_sig_algs: &[&dyn SignatureVerificationAlgorithm], + issuer_spki: untrusted::Input<'_>, + budget: &mut Budget, + ) -> Result<(), Error> { + signed_data::verify_signed_data( + supported_sig_algs, + issuer_spki, + &match self { + #[cfg(feature = "alloc")] + CertRevocationList::Owned(crl) => crl.signed_data.borrow(), + CertRevocationList::Borrowed(crl) => SignedData { + data: crl.signed_data.data, + algorithm: crl.signed_data.algorithm, + signature: crl.signed_data.signature, + }, + }, + budget, + ) + .map_err(crl_signature_err) + } + + /// Checks the verification time is before the time in the CRL nextUpdate field. + pub(crate) fn check_expiration(&self, time: UnixTime) -> Result<(), Error> { + let next_update = match self { + #[cfg(feature = "alloc")] + CertRevocationList::Owned(crl) => crl.next_update, + CertRevocationList::Borrowed(crl) => crl.next_update, + }; + + if time >= next_update { + return Err(Error::CrlExpired { time, next_update }); + } + + Ok(()) + } +} + +/// Owned representation of a RFC 5280[^1] profile Certificate Revocation List (CRL). +/// +/// [^1]: +#[cfg(feature = "alloc")] +#[derive(Debug, Clone)] +pub struct OwnedCertRevocationList { + /// A map of the revoked certificates contained in then CRL, keyed by the DER encoding + /// of the revoked cert's serial number. + revoked_certs: BTreeMap, OwnedRevokedCert>, + + issuer: Vec, + + issuing_distribution_point: Option>, + + signed_data: signed_data::OwnedSignedData, + + next_update: UnixTime, +} + +#[cfg(feature = "alloc")] +impl OwnedCertRevocationList { + /// Try to parse the given bytes as a RFC 5280[^1] profile Certificate Revocation List (CRL). + /// + /// Webpki does not support: + /// * CRL versions other than version 2. + /// * CRLs missing the next update field. + /// * CRLs missing certificate revocation list extensions. + /// * Delta CRLs. + /// * CRLs larger than (2^32)-1 bytes in size. + /// + /// See [BorrowedCertRevocationList::from_der] for more details. + /// + /// [^1]: + pub fn from_der(crl_der: &[u8]) -> Result { + BorrowedCertRevocationList::from_der(crl_der)?.to_owned() + } + + fn find_serial(&self, serial: &[u8]) -> Result>, Error> { + // note: this is infallible for the owned representation because we process all + // revoked certificates at the time of construction to build the `revoked_certs` map, + // returning any encountered errors at that time. + Ok(self + .revoked_certs + .get(serial) + .map(|owned_revoked_cert| owned_revoked_cert.borrow())) + } +} + +/// Borrowed representation of a RFC 5280[^1] profile Certificate Revocation List (CRL). +/// +/// [^1]: +#[derive(Debug)] +pub struct BorrowedCertRevocationList<'a> { + /// A `SignedData` structure that can be passed to `verify_signed_data`. + signed_data: SignedData<'a>, + + /// Identifies the entity that has signed and issued this + /// CRL. + issuer: untrusted::Input<'a>, + + /// An optional CRL extension that identifies the CRL distribution point and scope for the CRL. + issuing_distribution_point: Option>, + + /// List of certificates revoked by the issuer in this CRL. + revoked_certs: untrusted::Input<'a>, + + next_update: UnixTime, +} + +impl<'a> BorrowedCertRevocationList<'a> { + /// Try to parse the given bytes as a RFC 5280[^1] profile Certificate Revocation List (CRL). + /// + /// Webpki does not support: + /// * CRL versions other than version 2. + /// * CRLs missing the next update field. + /// * CRLs missing certificate revocation list extensions. + /// * Delta CRLs. + /// * CRLs larger than (2^32)-1 bytes in size. + /// + /// [^1]: + pub fn from_der(crl_der: &'a [u8]) -> Result { + der::read_all(untrusted::Input::from(crl_der)) + } + + /// Convert the CRL to an [`OwnedCertRevocationList`]. This may error if any of the revoked + /// certificates in the CRL are malformed or contain unsupported features. + #[cfg(feature = "alloc")] + pub fn to_owned(&self) -> Result { + // Parse and collect the CRL's revoked cert entries, ensuring there are no errors. With + // the full set in-hand, create a lookup map by serial number for fast revocation checking. + let revoked_certs = self + .into_iter() + .collect::, _>>()? + .iter() + .map(|revoked_cert| (revoked_cert.serial_number.to_vec(), revoked_cert.to_owned())) + .collect::>(); + + Ok(OwnedCertRevocationList { + signed_data: self.signed_data.to_owned(), + issuer: self.issuer.as_slice_less_safe().to_vec(), + issuing_distribution_point: self + .issuing_distribution_point + .map(|idp| idp.as_slice_less_safe().to_vec()), + revoked_certs, + next_update: self.next_update, + }) + } + + fn remember_extension(&mut self, extension: &Extension<'a>) -> Result<(), Error> { + remember_extension(extension, UnknownExtensionPolicy::default(), |id| { + match id { + // id-ce-cRLNumber 2.5.29.20 - RFC 5280 §5.2.3 + 20 => { + // RFC 5280 §5.2.3: + // CRL verifiers MUST be able to handle CRLNumber values + // up to 20 octets. Conforming CRL issuers MUST NOT use CRLNumber + // values longer than 20 octets. + // + extension.value.read_all(Error::InvalidCrlNumber, |der| { + let crl_number = der::nonnegative_integer(der) + .map_err(|_| Error::InvalidCrlNumber)? + .as_slice_less_safe(); + if crl_number.len() <= 20 { + Ok(crl_number) + } else { + Err(Error::InvalidCrlNumber) + } + })?; + // We enforce the cRLNumber is sensible, but don't retain the value for use. + Ok(()) + } + + // id-ce-deltaCRLIndicator 2.5.29.27 - RFC 5280 §5.2.4 + // We explicitly do not support delta CRLs. + 27 => Err(Error::UnsupportedDeltaCrl), + + // id-ce-issuingDistributionPoint 2.5.29.28 - RFC 5280 §5.2.4 + // We recognize the extension and retain its value for use. + 28 => { + set_extension_once(&mut self.issuing_distribution_point, || Ok(extension.value)) + } + + // id-ce-authorityKeyIdentifier 2.5.29.35 - RFC 5280 §5.2.1, §4.2.1.1 + // We recognize the extension but don't retain its value for use. + 35 => Ok(()), + + // Unsupported extension + _ => extension.unsupported(UnknownExtensionPolicy::default()), + } + }) + } + + fn find_serial(&self, serial: &[u8]) -> Result>, Error> { + for revoked_cert_result in self { + match revoked_cert_result { + Err(e) => return Err(e), + Ok(revoked_cert) => { + if revoked_cert.serial_number.eq(serial) { + return Ok(Some(revoked_cert)); + } + } + } + } + + Ok(None) + } +} + +impl<'a> FromDer<'a> for BorrowedCertRevocationList<'a> { + /// Try to parse the given bytes as a RFC 5280[^1] profile Certificate Revocation List (CRL). + /// + /// Webpki does not support: + /// * CRL versions other than version 2. + /// * CRLs missing the next update field. + /// * CRLs missing certificate revocation list extensions. + /// * Delta CRLs. + /// * CRLs larger than (2^32)-1 bytes in size. + /// + /// [^1]: + fn from_der(reader: &mut untrusted::Reader<'a>) -> Result { + let (tbs_cert_list, signed_data) = der::nested_limited( + reader, + Tag::Sequence, + Error::TrailingData(Self::TYPE_ID), + |signed_der| SignedData::from_der(signed_der, der::MAX_DER_SIZE), + der::MAX_DER_SIZE, + )?; + + let crl = tbs_cert_list.read_all(Error::BadDer, |tbs_cert_list| { + // RFC 5280 §5.1.2.1: + // This optional field describes the version of the encoded CRL. When + // extensions are used, as required by this profile, this field MUST be + // present and MUST specify version 2 (the integer value is 1). + // RFC 5280 §5.2: + // Conforming CRL issuers are REQUIRED to include the authority key + // identifier (Section 5.2.1) and the CRL number (Section 5.2.3) + // extensions in all CRLs issued. + // As a result of the above we parse this as a required section, not OPTIONAL. + // NOTE: Encoded value of version 2 is 1. + if u8::from_der(tbs_cert_list)? != 1 { + return Err(Error::UnsupportedCrlVersion); + } + + // RFC 5280 §5.1.2.2: + // This field MUST contain the same algorithm identifier as the + // signatureAlgorithm field in the sequence CertificateList + let signature = der::expect_tag(tbs_cert_list, Tag::Sequence)?; + if !public_values_eq(signature, signed_data.algorithm) { + return Err(Error::SignatureAlgorithmMismatch); + } + + // RFC 5280 §5.1.2.3: + // The issuer field MUST contain a non-empty X.500 distinguished name (DN). + let issuer = der::expect_tag(tbs_cert_list, Tag::Sequence)?; + + // RFC 5280 §5.1.2.4: + // This field indicates the issue date of this CRL. thisUpdate may be + // encoded as UTCTime or GeneralizedTime. + // We do not presently enforce the correct choice of UTCTime or GeneralizedTime based on + // whether the date is post 2050. + UnixTime::from_der(tbs_cert_list)?; + + // While OPTIONAL in the ASN.1 module, RFC 5280 §5.1.2.5 says: + // Conforming CRL issuers MUST include the nextUpdate field in all CRLs. + // We do not presently enforce the correct choice of UTCTime or GeneralizedTime based on + // whether the date is post 2050. + let next_update = UnixTime::from_der(tbs_cert_list)?; + + // RFC 5280 §5.1.2.6: + // When there are no revoked certificates, the revoked certificates list + // MUST be absent + // TODO(@cpu): Do we care to support empty CRLs if we don't support delta CRLs? + let revoked_certs = if tbs_cert_list.peek(Tag::Sequence.into()) { + der::expect_tag_and_get_value_limited( + tbs_cert_list, + Tag::Sequence, + der::MAX_DER_SIZE, + )? + } else { + untrusted::Input::from(&[]) + }; + + let mut crl = BorrowedCertRevocationList { + signed_data, + issuer, + revoked_certs, + issuing_distribution_point: None, + next_update, + }; + + // RFC 5280 §5.1.2.7: + // This field may only appear if the version is 2 (Section 5.1.2.1). If + // present, this field is a sequence of one or more CRL extensions. + // RFC 5280 §5.2: + // Conforming CRL issuers are REQUIRED to include the authority key + // identifier (Section 5.2.1) and the CRL number (Section 5.2.3) + // extensions in all CRLs issued. + // As a result of the above we parse this as a required section, not OPTIONAL. + der::nested( + tbs_cert_list, + Tag::ContextSpecificConstructed0, + Error::MalformedExtensions, + |tagged| { + der::nested_of_mut( + tagged, + Tag::Sequence, + Tag::Sequence, + Error::TrailingData(DerTypeId::CertRevocationListExtension), + false, + |extension| { + // RFC 5280 §5.2: + // If a CRL contains a critical extension + // that the application cannot process, then the application MUST NOT + // use that CRL to determine the status of certificates. However, + // applications may ignore unrecognized non-critical extensions. + crl.remember_extension(&Extension::from_der(extension)?) + }, + ) + }, + )?; + + Ok(crl) + })?; + + // If an issuing distribution point extension is present, parse it up-front to validate + // that it only uses well-formed and supported features. + if let Some(der) = crl.issuing_distribution_point { + IssuingDistributionPoint::from_der(der)?; + } + + Ok(crl) + } + + const TYPE_ID: DerTypeId = DerTypeId::CertRevocationList; +} + +impl<'a> IntoIterator for &'a BorrowedCertRevocationList<'a> { + type Item = Result, Error>; + type IntoIter = DerIterator<'a, BorrowedRevokedCert<'a>>; + + fn into_iter(self) -> Self::IntoIter { + DerIterator::new(self.revoked_certs) + } +} + +pub(crate) struct IssuingDistributionPoint<'a> { + distribution_point: Option>, + pub(crate) only_contains_user_certs: bool, + pub(crate) only_contains_ca_certs: bool, + pub(crate) only_some_reasons: Option>, + pub(crate) indirect_crl: bool, + pub(crate) only_contains_attribute_certs: bool, +} + +impl<'a> IssuingDistributionPoint<'a> { + pub(crate) fn from_der(der: untrusted::Input<'a>) -> Result { + const DISTRIBUTION_POINT_TAG: u8 = CONTEXT_SPECIFIC | CONSTRUCTED; + const ONLY_CONTAINS_USER_CERTS_TAG: u8 = CONTEXT_SPECIFIC | 1; + const ONLY_CONTAINS_CA_CERTS_TAG: u8 = CONTEXT_SPECIFIC | 2; + const ONLY_CONTAINS_SOME_REASONS_TAG: u8 = CONTEXT_SPECIFIC | 3; + const INDIRECT_CRL_TAG: u8 = CONTEXT_SPECIFIC | 4; + const ONLY_CONTAINS_ATTRIBUTE_CERTS_TAG: u8 = CONTEXT_SPECIFIC | 5; + + let mut result = IssuingDistributionPoint { + distribution_point: None, + only_contains_user_certs: false, + only_contains_ca_certs: false, + only_some_reasons: None, + indirect_crl: false, + only_contains_attribute_certs: false, + }; + + // Note: we can't use der::optional_boolean here because the distribution point + // booleans are context specific primitives and der::optional_boolean expects + // to unwrap a Tag::Boolean constructed value. + fn decode_bool(value: untrusted::Input<'_>) -> Result { + let mut reader = untrusted::Reader::new(value); + let value = reader.read_byte().map_err(der::end_of_input_err)?; + if !reader.at_end() { + return Err(Error::BadDer); + } + match value { + 0xFF => Ok(true), + 0x00 => Ok(false), // non-conformant explicit encoding allowed for compat. + _ => Err(Error::BadDer), + } + } + + // RFC 5280 section §4.2.1.13: + der::nested( + &mut untrusted::Reader::new(der), + Tag::Sequence, + Error::TrailingData(DerTypeId::IssuingDistributionPoint), + |der| { + while !der.at_end() { + let (tag, value) = der::read_tag_and_get_value(der)?; + match tag { + DISTRIBUTION_POINT_TAG => { + set_extension_once(&mut result.distribution_point, || Ok(value))? + } + ONLY_CONTAINS_USER_CERTS_TAG => { + result.only_contains_user_certs = decode_bool(value)? + } + ONLY_CONTAINS_CA_CERTS_TAG => { + result.only_contains_ca_certs = decode_bool(value)? + } + ONLY_CONTAINS_SOME_REASONS_TAG => { + set_extension_once(&mut result.only_some_reasons, || { + der::bit_string_flags(value) + })? + } + INDIRECT_CRL_TAG => result.indirect_crl = decode_bool(value)?, + ONLY_CONTAINS_ATTRIBUTE_CERTS_TAG => { + result.only_contains_attribute_certs = decode_bool(value)? + } + _ => return Err(Error::BadDer), + } + } + + Ok(()) + }, + )?; + + // RFC 5280 4.2.1.10: + // Conforming CRLs issuers MUST set the onlyContainsAttributeCerts boolean to FALSE. + if result.only_contains_attribute_certs { + return Err(Error::MalformedExtensions); + } + + // We don't support indirect CRLs. + if result.indirect_crl { + return Err(Error::UnsupportedIndirectCrl); + } + + // We don't support CRLs partitioned by revocation reason. + if result.only_some_reasons.is_some() { + return Err(Error::UnsupportedRevocationReasonsPartitioning); + } + + // We require a distribution point, and it must be a full name. + use DistributionPointName::*; + match result.names() { + Ok(Some(FullName(_))) => Ok(result), + Ok(Some(NameRelativeToCrlIssuer)) | Ok(None) => { + Err(Error::UnsupportedCrlIssuingDistributionPoint) + } + Err(_) => Err(Error::MalformedExtensions), + } + } + + /// Return the distribution point names (if any). + pub(crate) fn names(&self) -> Result>, Error> { + self.distribution_point + .map(|input| DistributionPointName::from_der(&mut untrusted::Reader::new(input))) + .transpose() + } + + /// Returns true if the CRL can be considered authoritative for the given certificate. We make + /// this determination using the certificate and CRL issuers, and the distribution point names + /// that may be present in extensions found on both. + /// + /// We consider the CRL authoritative for the certificate if the CRL issuing distribution point + /// has a scope that could include the cert and if the cert has CRL distribution points, that + /// at least one CRL DP has a valid distribution point full name where one of the general names + /// is a Uniform Resource Identifier (URI) general name that can also be found in the CRL + /// issuing distribution point. + /// + /// We do not consider: + /// * Distribution point names relative to an issuer. + /// * General names of a type other than URI. + /// * Malformed names or invalid IDP or CRL DP extensions. + pub(crate) fn authoritative_for(&self, node: &PathNode<'a>) -> bool { + assert!(!self.only_contains_attribute_certs); // We check this at time of parse. + + // Check that the scope of the CRL issuing distribution point could include the cert. + if self.only_contains_ca_certs && node.role() != Role::Issuer + || self.only_contains_user_certs && node.role() != Role::EndEntity + { + return false; // CRL scope excludes this cert's role. + } + + let cert_dps = match node.cert.crl_distribution_points() { + // If the certificate has no distribution points, then the CRL can be authoritative + // based on the issuer matching and the scope including the cert. + None => return true, + Some(cert_dps) => cert_dps, + }; + + for cert_dp in cert_dps { + let Ok(cert_dp) = cert_dp else { + continue; // Malformed DP, try next cert DP. + }; + + // If the certificate CRL DP was for an indirect CRL, or a CRL + // sharded by revocation reason, it can't match. + if cert_dp.crl_issuer.is_some() || cert_dp.reasons.is_some() { + continue; // Indirect CRL or reason-partitioned DP, try next cert DP. + } + + let Ok(Some(DistributionPointName::FullName(dp_general_names))) = cert_dp.names() + else { + continue; // No full names or malformed, try next cert DP. + }; + + // At least one URI type name in the IDP full names must match a URI type name in the + // DP full names. + for dp_name in dp_general_names { + let dp_uri = match dp_name { + Ok(GeneralName::UniformResourceIdentifier(dp_uri)) => dp_uri, + Ok(_) => continue, // Not a URI type name, skip. + Err(_) => continue, // Malformed general name, try next name. + }; + + let Ok(Some(DistributionPointName::FullName(idp_general_names))) = self.names() + else { + return false; // IDP has no full names or is malformed. + }; + + for idp_name in idp_general_names.flatten() { + match idp_name { + GeneralName::UniformResourceIdentifier(idp_uri) + if dp_uri.as_slice_less_safe() == idp_uri.as_slice_less_safe() => + { + return true; // DP URI matches IDP URI. + } + _ => continue, // Not a matching URI, try next IDP name. + } + } + } + } + + false + } +} + +/// Owned representation of a RFC 5280[^1] profile Certificate Revocation List (CRL) revoked +/// certificate entry. +/// +/// Only available when the "alloc" feature is enabled. +/// +/// [^1]: +#[cfg(feature = "alloc")] +#[derive(Clone, Debug)] +pub struct OwnedRevokedCert { + /// Serial number of the revoked certificate. + pub serial_number: Vec, + + /// The date at which the CA processed the revocation. + pub revocation_date: UnixTime, + + /// Identifies the reason for the certificate revocation. When absent, the revocation reason + /// is assumed to be RevocationReason::Unspecified. For consistency with other extensions + /// and to ensure only one revocation reason extension may be present we maintain this field + /// as optional instead of defaulting to unspecified. + pub reason_code: Option, + + /// Provides the date on which it is known or suspected that the private key was compromised or + /// that the certificate otherwise became invalid. This date may be earlier than the revocation + /// date which is the date at which the CA processed the revocation. + pub invalidity_date: Option, +} + +#[cfg(feature = "alloc")] +impl OwnedRevokedCert { + /// Convert the owned representation of this revoked cert to a borrowed version. + pub fn borrow(&self) -> BorrowedRevokedCert<'_> { + BorrowedRevokedCert { + serial_number: &self.serial_number, + revocation_date: self.revocation_date, + reason_code: self.reason_code, + invalidity_date: self.invalidity_date, + } + } +} + +/// Borrowed representation of a RFC 5280[^1] profile Certificate Revocation List (CRL) revoked +/// certificate entry. +/// +/// [^1]: +#[derive(Debug)] +pub struct BorrowedRevokedCert<'a> { + /// Serial number of the revoked certificate. + pub serial_number: &'a [u8], + + /// The date at which the CA processed the revocation. + pub revocation_date: UnixTime, + + /// Identifies the reason for the certificate revocation. When absent, the revocation reason + /// is assumed to be RevocationReason::Unspecified. For consistency with other extensions + /// and to ensure only one revocation reason extension may be present we maintain this field + /// as optional instead of defaulting to unspecified. + pub reason_code: Option, + + /// Provides the date on which it is known or suspected that the private key was compromised or + /// that the certificate otherwise became invalid. This date may be earlier than the revocation + /// date which is the date at which the CA processed the revocation. + pub invalidity_date: Option, +} + +impl<'a> BorrowedRevokedCert<'a> { + /// Construct an owned representation of the revoked certificate. + #[cfg(feature = "alloc")] + pub fn to_owned(&self) -> OwnedRevokedCert { + OwnedRevokedCert { + serial_number: self.serial_number.to_vec(), + revocation_date: self.revocation_date, + reason_code: self.reason_code, + invalidity_date: self.invalidity_date, + } + } + + fn remember_extension(&mut self, extension: &Extension<'a>) -> Result<(), Error> { + remember_extension(extension, UnknownExtensionPolicy::default(), |id| { + match id { + // id-ce-cRLReasons 2.5.29.21 - RFC 5280 §5.3.1. + 21 => set_extension_once(&mut self.reason_code, || der::read_all(extension.value)), + + // id-ce-invalidityDate 2.5.29.24 - RFC 5280 §5.3.2. + 24 => set_extension_once(&mut self.invalidity_date, || { + extension.value.read_all(Error::BadDer, UnixTime::from_der) + }), + + // id-ce-certificateIssuer 2.5.29.29 - RFC 5280 §5.3.3. + // This CRL entry extension identifies the certificate issuer associated + // with an entry in an indirect CRL, that is, a CRL that has the + // indirectCRL indicator set in its issuing distribution point + // extension. + // We choose not to support indirect CRLs and so turn this into a more specific + // error rather than simply letting it fail as an unsupported critical extension. + 29 => Err(Error::UnsupportedIndirectCrl), + + // Unsupported extension + _ => extension.unsupported(UnknownExtensionPolicy::default()), + } + }) + } +} + +impl<'a> FromDer<'a> for BorrowedRevokedCert<'a> { + fn from_der(reader: &mut untrusted::Reader<'a>) -> Result { + der::nested( + reader, + Tag::Sequence, + Error::TrailingData(DerTypeId::RevokedCertEntry), + |der| { + // RFC 5280 §4.1.2.2: + // Certificate users MUST be able to handle serialNumber values up to 20 octets. + // Conforming CAs MUST NOT use serialNumber values longer than 20 octets. + // + // Note: Non-conforming CAs may issue certificates with serial numbers + // that are negative or zero. Certificate users SHOULD be prepared to + // gracefully handle such certificates. + // Like the handling in cert.rs we choose to be lenient here, not enforcing the length + // of a CRL revoked certificate's serial number is less than 20 octets in encoded form. + let serial_number = lenient_certificate_serial_number(der) + .map_err(|_| Error::InvalidSerialNumber)? + .as_slice_less_safe(); + + let revocation_date = UnixTime::from_der(der)?; + + let mut revoked_cert = BorrowedRevokedCert { + serial_number, + revocation_date, + reason_code: None, + invalidity_date: None, + }; + + // RFC 5280 §5.3: + // Support for the CRL entry extensions defined in this specification is + // optional for conforming CRL issuers and applications. However, CRL + // issuers SHOULD include reason codes (Section 5.3.1) and invalidity + // dates (Section 5.3.2) whenever this information is available. + if der.at_end() { + return Ok(revoked_cert); + } + + // It would be convenient to use der::nested_of_mut here to unpack a SEQUENCE of one or + // more SEQUENCEs, however CAs have been mis-encoding the absence of extensions as an + // empty SEQUENCE so we must be tolerant of that. + let ext_seq = der::expect_tag(der, Tag::Sequence)?; + if ext_seq.is_empty() { + return Ok(revoked_cert); + } + + let mut reader = untrusted::Reader::new(ext_seq); + loop { + der::nested( + &mut reader, + Tag::Sequence, + Error::TrailingData(DerTypeId::RevokedCertificateExtension), + |ext_der| { + // RFC 5280 §5.3: + // If a CRL contains a critical CRL entry extension that the application cannot + // process, then the application MUST NOT use that CRL to determine the + // status of any certificates. However, applications may ignore + // unrecognized non-critical CRL entry extensions. + revoked_cert.remember_extension(&Extension::from_der(ext_der)?) + }, + )?; + if reader.at_end() { + break; + } + } + + Ok(revoked_cert) + }, + ) + } + + const TYPE_ID: DerTypeId = DerTypeId::RevokedCertificate; +} + +/// Identifies the reason a certificate was revoked. +/// See [RFC 5280 §5.3.1][1] +/// +/// [1]: +#[derive(Debug, Clone, Copy, Eq, PartialEq)] +#[allow(missing_docs)] // Not much to add above the code name. +pub enum RevocationReason { + /// Unspecified should not be used, and is instead assumed by the absence of a RevocationReason + /// extension. + Unspecified = 0, + KeyCompromise = 1, + CaCompromise = 2, + AffiliationChanged = 3, + Superseded = 4, + CessationOfOperation = 5, + CertificateHold = 6, + // 7 is not used. + /// RemoveFromCrl only appears in delta CRLs that are unsupported. + RemoveFromCrl = 8, + PrivilegeWithdrawn = 9, + AaCompromise = 10, +} + +impl RevocationReason { + /// Return an iterator over all possible [RevocationReason] variants. + pub fn iter() -> impl Iterator { + use RevocationReason::*; + [ + Unspecified, + KeyCompromise, + CaCompromise, + AffiliationChanged, + Superseded, + CessationOfOperation, + CertificateHold, + RemoveFromCrl, + PrivilegeWithdrawn, + AaCompromise, + ] + .into_iter() + } +} + +impl<'a> FromDer<'a> for RevocationReason { + // RFC 5280 §5.3.1. + fn from_der(reader: &mut untrusted::Reader<'a>) -> Result { + let input = der::expect_tag(reader, Tag::Enum)?; + Self::try_from(input.read_all(Error::BadDer, |reason| { + reason.read_byte().map_err(|_| Error::BadDer) + })?) + } + + const TYPE_ID: DerTypeId = DerTypeId::RevocationReason; +} + +impl TryFrom for RevocationReason { + type Error = Error; + + fn try_from(value: u8) -> Result { + // See https://www.rfc-editor.org/rfc/rfc5280#section-5.3.1 + match value { + 0 => Ok(Self::Unspecified), + 1 => Ok(Self::KeyCompromise), + 2 => Ok(Self::CaCompromise), + 3 => Ok(Self::AffiliationChanged), + 4 => Ok(Self::Superseded), + 5 => Ok(Self::CessationOfOperation), + 6 => Ok(Self::CertificateHold), + // 7 is not used. + 8 => Ok(Self::RemoveFromCrl), + 9 => Ok(Self::PrivilegeWithdrawn), + 10 => Ok(Self::AaCompromise), + _ => Err(Error::UnsupportedRevocationReason), + } + } +} + +#[cfg(feature = "alloc")] +#[cfg(test)] +mod tests { + use std::time::Duration; + + use pki_types::CertificateDer; + use std::println; + + use super::*; + use crate::cert::Cert; + use crate::end_entity::EndEntityCert; + use crate::verify_cert::PartialPath; + + #[test] + fn parse_issuing_distribution_point_ext() { + let crl = include_bytes!("../../tests/crls/crl.idp.valid.der"); + let crl = BorrowedCertRevocationList::from_der(&crl[..]).unwrap(); + + // We should be able to parse the issuing distribution point extension. + let crl_issuing_dp = crl + .issuing_distribution_point + .expect("missing crl distribution point DER"); + + #[cfg(feature = "alloc")] + { + // We should also be able to find the distribution point extensions bytes from + // an owned representation of the CRL. + let owned_crl = crl.to_owned().unwrap(); + assert!(owned_crl.issuing_distribution_point.is_some()); + } + + let crl_issuing_dp = IssuingDistributionPoint::from_der(untrusted::Input::from( + crl_issuing_dp.as_slice_less_safe(), + )) + .expect("failed to parse issuing distribution point DER"); + + // We don't expect any of the bool fields to have been set true. + assert!(!crl_issuing_dp.only_contains_user_certs); + assert!(!crl_issuing_dp.only_contains_ca_certs); + assert!(!crl_issuing_dp.indirect_crl); + + // Since the issuing distribution point doesn't specify the optional onlySomeReasons field, + // we shouldn't find that it was parsed. + assert!(crl_issuing_dp.only_some_reasons.is_none()); + + // We should find the expected URI distribution point name. + let dp_name = crl_issuing_dp + .names() + .expect("failed to parse distribution point names") + .expect("missing distribution point name"); + let uri = match dp_name { + DistributionPointName::NameRelativeToCrlIssuer => { + panic!("unexpected relative dp name") + } + DistributionPointName::FullName(general_names) => { + general_names.map(|general_name| match general_name { + Ok(GeneralName::UniformResourceIdentifier(uri)) => uri.as_slice_less_safe(), + _ => panic!("unexpected general name type"), + }) + } + } + .collect::>(); + let expected = &["http://crl.trustcor.ca/sub/dv-ssl-rsa-s-0.crl".as_bytes()]; + assert_eq!(uri, expected); + } + + #[test] + fn test_issuing_distribution_point_only_user_certs() { + let crl = include_bytes!("../../tests/crls/crl.idp.only_user_certs.der"); + let crl = BorrowedCertRevocationList::from_der(&crl[..]).unwrap(); + + // We should be able to parse the issuing distribution point extension. + let crl_issuing_dp = crl + .issuing_distribution_point + .expect("missing crl distribution point DER"); + let crl_issuing_dp = IssuingDistributionPoint::from_der(crl_issuing_dp) + .expect("failed to parse issuing distribution point DER"); + + // We should find the expected bool state. + assert!(crl_issuing_dp.only_contains_user_certs); + + // The IDP shouldn't be considered authoritative for a CA Cert. + let ee = CertificateDer::from( + &include_bytes!("../../tests/client_auth_revocation/no_crl_ku_chain.ee.der")[..], + ); + let ee = EndEntityCert::try_from(&ee).unwrap(); + let ca = include_bytes!("../../tests/client_auth_revocation/no_crl_ku_chain.int.a.ca.der"); + let ca = Cert::from_der(untrusted::Input::from(&ca[..])).unwrap(); + + let mut path = PartialPath::new(&ee); + path.push(ca).unwrap(); + + assert!(!crl_issuing_dp.authoritative_for(&path.node())); + } + + #[test] + fn test_issuing_distribution_point_only_ca_certs() { + let crl = include_bytes!("../../tests/crls/crl.idp.only_ca_certs.der"); + let crl = BorrowedCertRevocationList::from_der(&crl[..]).unwrap(); + + // We should be able to parse the issuing distribution point extension. + let crl_issuing_dp = crl + .issuing_distribution_point + .expect("missing crl distribution point DER"); + let crl_issuing_dp = IssuingDistributionPoint::from_der(crl_issuing_dp) + .expect("failed to parse issuing distribution point DER"); + + // We should find the expected bool state. + assert!(crl_issuing_dp.only_contains_ca_certs); + + // The IDP shouldn't be considered authoritative for an EE Cert. + let ee = CertificateDer::from( + &include_bytes!("../../tests/client_auth_revocation/no_crl_ku_chain.ee.der")[..], + ); + let ee = EndEntityCert::try_from(&ee).unwrap(); + let path = PartialPath::new(&ee); + + assert!(!crl_issuing_dp.authoritative_for(&path.node())); + } + + #[test] + fn test_issuing_distribution_point_indirect() { + let crl = include_bytes!("../../tests/crls/crl.idp.indirect_crl.der"); + // We should encounter an error parsing a CRL with an IDP extension that indicates it's an + // indirect CRL. + let result = BorrowedCertRevocationList::from_der(&crl[..]); + assert!(matches!(result, Err(Error::UnsupportedIndirectCrl))); + } + + #[test] + fn test_issuing_distribution_only_attribute_certs() { + let crl = include_bytes!("../../tests/crls/crl.idp.only_attribute_certs.der"); + // We should find an error when we parse a CRL with an IDP extension that indicates it only + // contains attribute certs. + let result = BorrowedCertRevocationList::from_der(&crl[..]); + assert!(matches!(result, Err(Error::MalformedExtensions))); + } + + #[test] + fn test_issuing_distribution_only_some_reasons() { + let crl = include_bytes!("../../tests/crls/crl.idp.only_some_reasons.der"); + // We should encounter an error parsing a CRL with an IDP extension that indicates it's + // partitioned by revocation reason. + let result = BorrowedCertRevocationList::from_der(&crl[..]); + assert!(matches!( + result, + Err(Error::UnsupportedRevocationReasonsPartitioning) + )); + } + + #[test] + fn test_issuing_distribution_invalid_bool() { + // Created w/ + // ascii2der -i tests/crls/crl.idp.invalid.bool.der.txt -o tests/crls/crl.idp.invalid.bool.der + let crl = include_bytes!("../../tests/crls/crl.idp.invalid.bool.der"); + // We should encounter an error parsing a CRL with an IDP extension with an invalid encoded boolean. + let result = BorrowedCertRevocationList::from_der(&crl[..]); + assert!(matches!(result, Err(Error::BadDer))) + } + + #[test] + fn test_issuing_distribution_explicit_false_bool() { + // Created w/ + // ascii2der -i tests/crls/crl.idp.explicit.false.bool.der.txt -o tests/crls/crl.idp.explicit.false.bool.der + let crl = include_bytes!("../../tests/crls/crl.idp.explicit.false.bool.der"); + let crl = BorrowedCertRevocationList::from_der(&crl[..]).unwrap(); + + // We should be able to parse the issuing distribution point extension. + let crl_issuing_dp = crl + .issuing_distribution_point + .expect("missing crl distribution point DER"); + assert!(IssuingDistributionPoint::from_der(crl_issuing_dp).is_ok()); + } + + #[test] + fn test_issuing_distribution_unknown_tag() { + // Created w/ + // ascii2der -i tests/crls/crl.idp.unknown.tag.der.txt -o tests/crls/crl.idp.unknown.tag.der + let crl = include_bytes!("../../tests/crls/crl.idp.unknown.tag.der"); + // We should encounter an error parsing a CRL with an invalid IDP extension. + let result = BorrowedCertRevocationList::from_der(&crl[..]); + assert!(matches!(result, Err(Error::BadDer))); + } + + #[test] + fn test_issuing_distribution_invalid_name() { + // Created w/ + // ascii2der -i tests/crls/crl.idp.invalid.name.der.txt -o tests/crls/crl.idp.invalid.name.der + let crl = include_bytes!("../../tests/crls/crl.idp.invalid.name.der"); + + // We should encounter an error parsing a CRL with an invalid issuing distribution point name. + let result = BorrowedCertRevocationList::from_der(&crl[..]); + assert!(matches!(result, Err(Error::MalformedExtensions))) + } + + #[test] + fn test_issuing_distribution_relative_name() { + let crl = include_bytes!("../../tests/crls/crl.idp.name_relative_to_issuer.der"); + // We should encounter an error parsing a CRL with an issuing distribution point extension + // that has a distribution point name relative to an issuer. + let result = BorrowedCertRevocationList::from_der(&crl[..]); + assert!(matches!( + result, + Err(Error::UnsupportedCrlIssuingDistributionPoint) + )) + } + + #[test] + fn test_issuing_distribution_no_name() { + let crl = include_bytes!("../../tests/crls/crl.idp.no_distribution_point_name.der"); + // We should encounter an error parsing a CRL with an issuing distribution point extension + // that has no distribution point name. + let result = BorrowedCertRevocationList::from_der(&crl[..]); + assert!(matches!( + result, + Err(Error::UnsupportedCrlIssuingDistributionPoint) + )) + } + + #[test] + fn revocation_reasons() { + // Test that we can convert the allowed u8 revocation reason code values into the expected + // revocation reason variant. + let testcases: Vec<(u8, RevocationReason)> = vec![ + (0, RevocationReason::Unspecified), + (1, RevocationReason::KeyCompromise), + (2, RevocationReason::CaCompromise), + (3, RevocationReason::AffiliationChanged), + (4, RevocationReason::Superseded), + (5, RevocationReason::CessationOfOperation), + (6, RevocationReason::CertificateHold), + // Note: 7 is unused. + (8, RevocationReason::RemoveFromCrl), + (9, RevocationReason::PrivilegeWithdrawn), + (10, RevocationReason::AaCompromise), + ]; + for tc in testcases.iter() { + let (id, expected) = tc; + let actual = >::try_into(*id) + .expect("unexpected reason code conversion error"); + assert_eq!(actual, *expected); + #[cfg(feature = "alloc")] + { + // revocation reasons should be Debug. + println!("{actual:?}"); + } + } + + // Unsupported/unknown revocation reason codes should produce an error. + let res = >::try_into(7); + assert!(matches!(res, Err(Error::UnsupportedRevocationReason))); + + // The iterator should produce all possible revocation reason variants. + let expected = testcases + .iter() + .map(|(_, reason)| *reason) + .collect::>(); + let actual = RevocationReason::iter().collect::>(); + assert_eq!(actual, expected); + } + + #[test] + // redundant clone, clone_on_copy allowed to verify derived traits. + #[allow(clippy::redundant_clone, clippy::clone_on_copy)] + fn test_derived_traits() { + let crl = + BorrowedCertRevocationList::from_der(include_bytes!("../../tests/crls/crl.valid.der")) + .unwrap(); + println!("{crl:?}"); // BorrowedCertRevocationList should be debug. + + let owned_crl = crl.to_owned().unwrap(); + println!("{owned_crl:?}"); // OwnedCertRevocationList should be debug. + let _ = owned_crl.clone(); // OwnedCertRevocationList should be clone. + + let mut revoked_certs = crl.into_iter(); + println!("{revoked_certs:?}"); // RevokedCert should be debug. + + let revoked_cert = revoked_certs.next().unwrap().unwrap(); + println!("{revoked_cert:?}"); // BorrowedRevokedCert should be debug. + + let owned_revoked_cert = revoked_cert.to_owned(); + println!("{owned_revoked_cert:?}"); // OwnedRevokedCert should be debug. + let _ = owned_revoked_cert.clone(); // OwnedRevokedCert should be clone. + } + + #[test] + fn test_enum_conversions() { + let crl = + include_bytes!("../../tests/client_auth_revocation/ee_revoked_crl_ku_ee_depth.crl.der"); + let borrowed_crl = BorrowedCertRevocationList::from_der(&crl[..]).unwrap(); + let owned_crl = borrowed_crl.to_owned().unwrap(); + + // It should be possible to convert a BorrowedCertRevocationList to a CertRevocationList. + let _crl = CertRevocationList::from(borrowed_crl); + // And similar for an OwnedCertRevocationList. + let _crl = CertRevocationList::from(owned_crl); + } + + #[test] + fn test_crl_authoritative_issuer_mismatch() { + let crl = include_bytes!("../../tests/crls/crl.valid.der"); + let crl = CertRevocationList::from(BorrowedCertRevocationList::from_der(&crl[..]).unwrap()); + + let ee = CertificateDer::from( + &include_bytes!("../../tests/client_auth_revocation/no_ku_chain.ee.der")[..], + ); + let ee = EndEntityCert::try_from(&ee).unwrap(); + let path = PartialPath::new(&ee); + + // The CRL should not be authoritative for an EE issued by a different issuer. + assert!(!crl.authoritative(&path.node())); + } + + #[test] + fn test_crl_authoritative_no_idp_no_cert_dp() { + let crl = + include_bytes!("../../tests/client_auth_revocation/ee_revoked_crl_ku_ee_depth.crl.der"); + let crl = CertRevocationList::from(BorrowedCertRevocationList::from_der(&crl[..]).unwrap()); + + let ee = CertificateDer::from( + &include_bytes!("../../tests/client_auth_revocation/ku_chain.ee.der")[..], + ); + let ee = EndEntityCert::try_from(&ee).unwrap(); + let path = PartialPath::new(&ee); + + // The CRL should be considered authoritative, the issuers match, the CRL has no IDP and the + // cert has no CRL DPs. + assert!(crl.authoritative(&path.node())); + } + + #[test] + fn test_crl_expired() { + let crl = include_bytes!("../../tests/crls/crl.valid.der"); + let crl = CertRevocationList::from(BorrowedCertRevocationList::from_der(&crl[..]).unwrap()); + // Friday, February 2, 2024 8:26:19 PM GMT + let time = UnixTime::since_unix_epoch(Duration::from_secs(1_706_905_579)); + assert!(matches!( + crl.check_expiration(time), + Err(Error::CrlExpired { .. }) + )); + } + + #[test] + fn test_crl_not_expired() { + let crl = include_bytes!("../../tests/crls/crl.valid.der"); + let crl = CertRevocationList::from(BorrowedCertRevocationList::from_der(&crl[..]).unwrap()); + // Wednesday, October 19, 2022 8:12:06 PM GMT + let expiration_time = 1_666_210_326; + let time = UnixTime::since_unix_epoch(Duration::from_secs(expiration_time - 1000)); + + assert!(matches!(crl.check_expiration(time), Ok(()))); + } + + #[test] + fn test_construct_owned_crl() { + // It should be possible to construct an owned CRL directly from DER without needing + // to build a borrowed representation first. + let crl = + include_bytes!("../../tests/client_auth_revocation/ee_revoked_crl_ku_ee_depth.crl.der"); + assert!(OwnedCertRevocationList::from_der(crl).is_ok()) + } + + #[test] + fn test_crl_issuing_distribution_point_illegal_bit_string() { + let crl = &[ + 0x30, 0x65, 0x30, 0x50, 0x02, 0x01, 0x01, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, + 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x0c, 0x31, 0x0a, 0x30, 0x08, + 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x01, 0x41, 0x17, 0x0d, 0x32, 0x30, 0x30, 0x31, + 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x17, 0x0d, 0x32, 0x31, 0x30, + 0x31, 0x30, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0xa0, 0x10, 0x30, 0x0e, + 0x30, 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x1c, 0x04, 0x05, 0x30, 0x03, 0x83, 0x01, 0x00, + 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, + 0x00, 0x03, 0x02, 0x00, 0x00, + ]; + assert_eq!( + BorrowedCertRevocationList::from_der(crl).err(), + Some(Error::UnsupportedRevocationReasonsPartitioning) + ); + } +} diff --git a/http/vendor/rustls-webpki/src/data/alg-rsa-pkcs1-sha256-absent-params.der b/http/vendor/rustls-webpki/src/data/alg-rsa-pkcs1-sha256-absent-params.der new file mode 100644 index 0000000..a934df8 --- /dev/null +++ b/http/vendor/rustls-webpki/src/data/alg-rsa-pkcs1-sha256-absent-params.der @@ -0,0 +1 @@ + *H  \ No newline at end of file diff --git a/http/vendor/rustls-webpki/src/data/alg-rsa-pkcs1-sha384-absent-params.der b/http/vendor/rustls-webpki/src/data/alg-rsa-pkcs1-sha384-absent-params.der new file mode 100644 index 0000000..03aa775 --- /dev/null +++ b/http/vendor/rustls-webpki/src/data/alg-rsa-pkcs1-sha384-absent-params.der @@ -0,0 +1 @@ + *H  \ No newline at end of file diff --git a/http/vendor/rustls-webpki/src/data/alg-rsa-pkcs1-sha512-absent-params.der b/http/vendor/rustls-webpki/src/data/alg-rsa-pkcs1-sha512-absent-params.der new file mode 100644 index 0000000..e59473c --- /dev/null +++ b/http/vendor/rustls-webpki/src/data/alg-rsa-pkcs1-sha512-absent-params.der @@ -0,0 +1 @@ + *H  \ No newline at end of file diff --git a/http/vendor/rustls-webpki/src/der.rs b/http/vendor/rustls-webpki/src/der.rs new file mode 100644 index 0000000..76c6da4 --- /dev/null +++ b/http/vendor/rustls-webpki/src/der.rs @@ -0,0 +1,908 @@ +// Copyright 2015 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#[cfg(feature = "alloc")] +use alloc::vec::Vec; +use core::marker::PhantomData; + +use crate::{Error, error::DerTypeId}; + +/// Iterator to parse a sequence of DER-encoded values of type `T`. +#[derive(Debug)] +pub struct DerIterator<'a, T> { + reader: untrusted::Reader<'a>, + marker: PhantomData, +} + +impl<'a, T> DerIterator<'a, T> { + /// [`DerIterator`] will consume all of the bytes in `input` reading values of type `T`. + pub(crate) fn new(input: untrusted::Input<'a>) -> Self { + Self { + reader: untrusted::Reader::new(input), + marker: PhantomData, + } + } +} + +impl<'a, T: FromDer<'a>> Iterator for DerIterator<'a, T> { + type Item = Result; + + fn next(&mut self) -> Option { + (!self.reader.at_end()).then(|| T::from_der(&mut self.reader)) + } +} + +pub(crate) trait FromDer<'a>: Sized + 'a { + /// Parse a value of type `Self` from the given DER-encoded input. + fn from_der(reader: &mut untrusted::Reader<'a>) -> Result; + + const TYPE_ID: DerTypeId; +} + +pub(crate) fn read_all<'a, T: FromDer<'a>>(input: untrusted::Input<'a>) -> Result { + input.read_all(Error::TrailingData(T::TYPE_ID), T::from_der) +} + +// Copied (and extended) from ring's src/der.rs +#[allow(clippy::upper_case_acronyms)] +#[derive(Clone, Copy, Eq, PartialEq)] +#[repr(u8)] +pub(crate) enum Tag { + Boolean = 0x01, + Integer = 0x02, + BitString = 0x03, + OctetString = 0x04, + OID = 0x06, + Enum = 0x0A, + Sequence = CONSTRUCTED | 0x10, // 0x30 + UTCTime = 0x17, + GeneralizedTime = 0x18, + + #[allow(clippy::identity_op)] + ContextSpecificConstructed0 = CONTEXT_SPECIFIC | CONSTRUCTED | 0, + ContextSpecificConstructed1 = CONTEXT_SPECIFIC | CONSTRUCTED | 1, + ContextSpecificConstructed3 = CONTEXT_SPECIFIC | CONSTRUCTED | 3, +} + +pub(crate) const CONSTRUCTED: u8 = 0x20; +pub(crate) const CONTEXT_SPECIFIC: u8 = 0x80; + +impl From for usize { + #[allow(clippy::as_conversions)] + fn from(tag: Tag) -> Self { + tag as Self + } +} + +impl From for u8 { + #[allow(clippy::as_conversions)] + fn from(tag: Tag) -> Self { + tag as Self + } // XXX: narrowing conversion. +} + +#[inline(always)] +pub(crate) fn expect_tag_and_get_value_limited<'a>( + input: &mut untrusted::Reader<'a>, + tag: Tag, + size_limit: usize, +) -> Result, Error> { + let (actual_tag, inner) = read_tag_and_get_value_limited(input, size_limit)?; + if usize::from(tag) != usize::from(actual_tag) { + return Err(Error::BadDer); + } + Ok(inner) +} + +pub(crate) fn nested_limited<'a, R>( + input: &mut untrusted::Reader<'a>, + tag: Tag, + error: Error, + decoder: impl FnOnce(&mut untrusted::Reader<'a>) -> Result, + size_limit: usize, +) -> Result { + match expect_tag_and_get_value_limited(input, tag, size_limit) { + Ok(value) => value.read_all(error, decoder), + Err(_) => Err(error), + } +} + +// TODO: investigate taking decoder as a reference to reduce generated code +// size. +pub(crate) fn nested<'a, R>( + input: &mut untrusted::Reader<'a>, + tag: Tag, + error: Error, + decoder: impl FnOnce(&mut untrusted::Reader<'a>) -> Result, +) -> Result { + nested_limited(input, tag, error, decoder, TWO_BYTE_DER_SIZE) +} + +pub(crate) fn expect_tag<'a>( + input: &mut untrusted::Reader<'a>, + tag: Tag, +) -> Result, Error> { + let (actual_tag, value) = read_tag_and_get_value_limited(input, TWO_BYTE_DER_SIZE)?; + if usize::from(tag) != usize::from(actual_tag) { + return Err(Error::BadDer); + } + + Ok(value) +} + +#[inline(always)] +pub(crate) fn read_tag_and_get_value<'a>( + input: &mut untrusted::Reader<'a>, +) -> Result<(u8, untrusted::Input<'a>), Error> { + read_tag_and_get_value_limited(input, TWO_BYTE_DER_SIZE) +} + +#[inline(always)] +pub(crate) fn read_tag_and_get_value_limited<'a>( + input: &mut untrusted::Reader<'a>, + size_limit: usize, +) -> Result<(u8, untrusted::Input<'a>), Error> { + let tag = input.read_byte().map_err(end_of_input_err)?; + if (tag & HIGH_TAG_RANGE_START) == HIGH_TAG_RANGE_START { + return Err(Error::BadDer); // High tag number form is not allowed. + } + + // If the high order bit of the first byte is set to zero then the length + // is encoded in the seven remaining bits of that byte. Otherwise, those + // seven bits represent the number of bytes used to encode the length. + let length = match input.read_byte().map_err(end_of_input_err)? { + n if (n & SHORT_FORM_LEN_MAX) == 0 => usize::from(n), + LONG_FORM_LEN_ONE_BYTE => { + let length_byte = input.read_byte().map_err(end_of_input_err)?; + if length_byte < SHORT_FORM_LEN_MAX { + return Err(Error::BadDer); // Not the canonical encoding. + } + usize::from(length_byte) + } + LONG_FORM_LEN_TWO_BYTES => { + let length_byte_one = usize::from(input.read_byte().map_err(end_of_input_err)?); + let length_byte_two = usize::from(input.read_byte().map_err(end_of_input_err)?); + let combined = (length_byte_one << 8) | length_byte_two; + if combined <= LONG_FORM_LEN_ONE_BYTE_MAX { + return Err(Error::BadDer); // Not the canonical encoding. + } + combined + } + LONG_FORM_LEN_THREE_BYTES => { + let length_byte_one = usize::from(input.read_byte().map_err(end_of_input_err)?); + let length_byte_two = usize::from(input.read_byte().map_err(end_of_input_err)?); + let length_byte_three = usize::from(input.read_byte().map_err(end_of_input_err)?); + let combined = (length_byte_one << 16) | (length_byte_two << 8) | length_byte_three; + if combined <= LONG_FORM_LEN_TWO_BYTES_MAX { + return Err(Error::BadDer); // Not the canonical encoding. + } + combined + } + LONG_FORM_LEN_FOUR_BYTES => { + let length_byte_one = usize::from(input.read_byte().map_err(end_of_input_err)?); + let length_byte_two = usize::from(input.read_byte().map_err(end_of_input_err)?); + let length_byte_three = usize::from(input.read_byte().map_err(end_of_input_err)?); + let length_byte_four = usize::from(input.read_byte().map_err(end_of_input_err)?); + let combined = (length_byte_one << 24) + | (length_byte_two << 16) + | (length_byte_three << 8) + | length_byte_four; + if combined <= LONG_FORM_LEN_THREE_BYTES_MAX { + return Err(Error::BadDer); // Not the canonical encoding. + } + combined + } + _ => { + return Err(Error::BadDer); // We don't support longer lengths. + } + }; + + if length >= size_limit { + return Err(Error::BadDer); // The length is larger than the caller accepts. + } + + let inner = input.read_bytes(length).map_err(end_of_input_err)?; + Ok((tag, inner)) +} + +/// Prepend `bytes` with the given ASN.1 [`Tag`] and appropriately encoded length byte(s). +/// Useful for "adding back" ASN.1 bytes to parsed content. +#[cfg(feature = "alloc")] +#[allow(clippy::as_conversions)] +pub(crate) fn asn1_wrap(tag: Tag, bytes: &[u8]) -> Vec { + let len = bytes.len(); + // The length is encoded differently depending on how many bytes there are + if len < usize::from(SHORT_FORM_LEN_MAX) { + // Short form: the length is encoded using a single byte + // Contents: Tag byte, single length byte, and passed bytes + let mut ret = Vec::with_capacity(2 + len); + ret.push(tag.into()); // Tag byte + ret.push(len as u8); // Single length byte + ret.extend_from_slice(bytes); // Passed bytes + ret + } else { + // Long form: The length is encoded using multiple bytes + // Contents: Tag byte, number-of-length-bytes byte, length bytes, and passed bytes + // The first byte indicates how many more bytes will be used to encode the length + // First, get a big-endian representation of the byte slice's length + let size = len.to_be_bytes(); + // Find the number of leading empty bytes in that representation + // This will determine the smallest number of bytes we need to encode the length + let leading_zero_bytes = size + .iter() + .position(|&byte| byte != 0) + .unwrap_or(size.len()); + assert!(leading_zero_bytes < size.len()); + // Number of bytes used - number of not needed bytes = smallest number needed + let encoded_bytes = size.len() - leading_zero_bytes; + let mut ret = Vec::with_capacity(2 + encoded_bytes + len); + // Indicate this is a number-of-length-bytes byte by setting the high order bit + let number_of_length_bytes_byte = SHORT_FORM_LEN_MAX + encoded_bytes as u8; + ret.push(tag.into()); // Tag byte + ret.push(number_of_length_bytes_byte); // Number-of-length-bytes byte + ret.extend_from_slice(&size[leading_zero_bytes..]); // Length bytes + ret.extend_from_slice(bytes); // Passed bytes + ret + } +} + +// Long-form DER encoded lengths of two bytes can express lengths up to the following limit. +// +// The upstream ring::io::der::read_tag_and_get_value() function limits itself to up to two byte +// long-form DER lengths, and so this limit represents the maximum length that was possible to +// read before the introduction of the read_tag_and_get_value_limited function. +pub(crate) const TWO_BYTE_DER_SIZE: usize = LONG_FORM_LEN_TWO_BYTES_MAX; + +// The maximum size of a DER value that Webpki can support reading. +// +// Webpki limits itself to four byte long-form DER lengths, and so this limit represents +// the maximum size tagged DER value that can be read for any purpose. +pub(crate) const MAX_DER_SIZE: usize = LONG_FORM_LEN_FOUR_BYTES_MAX; + +// DER Tag identifiers have two forms: +// * Low tag number form (for tags values in the range [0..30] +// * High tag number form (for tag values in the range [31..] +// We only support low tag number form. +const HIGH_TAG_RANGE_START: u8 = 31; + +// DER length octets have two forms: +// * Short form: 1 octet supporting lengths between 0 and 127. +// * Long definite form: 2 to 127 octets, number of octets encoded into first octet. +const SHORT_FORM_LEN_MAX: u8 = 128; + +// Leading octet for long definite form DER length expressed in second byte. +const LONG_FORM_LEN_ONE_BYTE: u8 = 0x81; + +// Maximum size that can be expressed in a one byte long form len. +const LONG_FORM_LEN_ONE_BYTE_MAX: usize = 0xff; + +// Leading octet for long definite form DER length expressed in subsequent two bytes. +const LONG_FORM_LEN_TWO_BYTES: u8 = 0x82; + +// Maximum size that can be expressed in a two byte long form len. +const LONG_FORM_LEN_TWO_BYTES_MAX: usize = 0xff_ff; + +// Leading octet for long definite form DER length expressed in subsequent three bytes. +const LONG_FORM_LEN_THREE_BYTES: u8 = 0x83; + +// Maximum size that can be expressed in a three byte long form len. +const LONG_FORM_LEN_THREE_BYTES_MAX: usize = 0xff_ff_ff; + +// Leading octet for long definite form DER length expressed in subsequent four bytes. +const LONG_FORM_LEN_FOUR_BYTES: u8 = 0x84; + +// Maximum size that can be expressed in a four byte long form der len. +const LONG_FORM_LEN_FOUR_BYTES_MAX: usize = 0xff_ff_ff_ff; + +// TODO: investigate taking decoder as a reference to reduce generated code +// size. +pub(crate) fn nested_of_mut<'a>( + input: &mut untrusted::Reader<'a>, + outer_tag: Tag, + inner_tag: Tag, + error: Error, + allow_empty: bool, + mut decoder: impl FnMut(&mut untrusted::Reader<'a>) -> Result<(), Error>, +) -> Result<(), Error> { + nested(input, outer_tag, error.clone(), |outer| { + if allow_empty && outer.at_end() { + return Ok(()); + } + loop { + nested(outer, inner_tag, error.clone(), |inner| decoder(inner))?; + if outer.at_end() { + break; + } + } + Ok(()) + }) +} + +pub(crate) fn bit_string_with_no_unused_bits<'a>( + input: &mut untrusted::Reader<'a>, +) -> Result, Error> { + nested( + input, + Tag::BitString, + Error::TrailingData(DerTypeId::BitString), + |value| { + let unused_bits_at_end = value.read_byte().map_err(|_| Error::BadDer)?; + if unused_bits_at_end != 0 { + return Err(Error::BadDer); + } + Ok(value.read_bytes_to_end()) + }, + ) +} + +pub(crate) struct BitStringFlags<'a> { + raw_bits: &'a [u8], +} + +impl BitStringFlags<'_> { + pub(crate) fn bit_set(&self, bit: usize) -> bool { + let byte_index = bit / 8; + let bit_shift = 7 - (bit % 8); + + if self.raw_bits.len() < (byte_index + 1) { + false + } else { + ((self.raw_bits[byte_index] >> bit_shift) & 1) != 0 + } + } +} + +// ASN.1 BIT STRING fields for sets of flags are encoded in DER with some peculiar details related +// to padding. Notably this means we expect an indicator of the number of bits of padding, and then +// the actual bit values. See this Stack Overflow discussion[0], and ITU X690-0207[1] Section 8.6 +// and Section 11.2 for more information. +// +// [0]: https://security.stackexchange.com/a/10396 +// [1]: https://www.itu.int/ITU-T/studygroups/com17/languages/X.690-0207.pdf +pub(crate) fn bit_string_flags(input: untrusted::Input<'_>) -> Result, Error> { + input.read_all(Error::BadDer, |bit_string| { + // ITU X690-0207 11.2: + // "The initial octet shall encode, as an unsigned binary integer with bit 1 as the least + // significant bit, the number of unused bits in the final subsequent octet. + // The number shall be in the range zero to seven" + let padding_bits = bit_string.read_byte().map_err(|_| Error::BadDer)?; + let raw_bits = bit_string.read_bytes_to_end().as_slice_less_safe(); + + match (padding_bits, raw_bits.last()) { + // It's illegal to have more than 7 bits of padding. + (8.., _) => Err(Error::BadDer), + + // If the raw bitflags are empty there should be no padding. + (0, None) => Ok(BitStringFlags { raw_bits }), + (_, None) => Err(Error::BadDer), + + // If there are padding bits then the last bit of the last raw byte must be 0 or the + // distinguished encoding rules are not being followed. + (1..=7, Some(last)) if last & ((1 << padding_bits) - 1) != 0 => Err(Error::BadDer), + + (_, Some(_)) => Ok(BitStringFlags { raw_bits }), + } + }) +} + +impl<'a> FromDer<'a> for u8 { + fn from_der(reader: &mut untrusted::Reader<'a>) -> Result { + match *nonnegative_integer(reader)?.as_slice_less_safe() { + [b] => Ok(b), + _ => Err(Error::BadDer), + } + } + + const TYPE_ID: DerTypeId = DerTypeId::U8; +} + +pub(crate) fn nonnegative_integer<'a>( + input: &mut untrusted::Reader<'a>, +) -> Result, Error> { + let value = expect_tag(input, Tag::Integer)?; + match value + .as_slice_less_safe() + .split_first() + .ok_or(Error::BadDer)? + { + // Zero or leading zero. + (0, rest) => { + match rest.first() { + // Zero + None => Ok(value), + // Necessary leading zero. + Some(&second) if second & 0x80 == 0x80 => Ok(untrusted::Input::from(rest)), + // Unnecessary leading zero. + _ => Err(Error::BadDer), + } + } + // Positive value with no leading zero. + (first, _) if first & 0x80 == 0x00 => Ok(value), + // Negative value. + (_, _) => Err(Error::BadDer), + } +} + +pub(crate) fn end_of_input_err(_: untrusted::EndOfInput) -> Error { + Error::BadDer +} + +// Like mozilla::pkix, we accept the nonconformant explicit encoding of +// the default value (false) for compatibility with real-world certificates. +impl<'a> FromDer<'a> for bool { + fn from_der(reader: &mut untrusted::Reader<'a>) -> Result { + if !reader.peek(Tag::Boolean.into()) { + return Ok(false); + } + + nested( + reader, + Tag::Boolean, + Error::TrailingData(Self::TYPE_ID), + |input| match input.read_byte() { + Ok(0xff) => Ok(true), + Ok(0x00) => Ok(false), + _ => Err(Error::BadDer), + }, + ) + } + + const TYPE_ID: DerTypeId = DerTypeId::Bool; +} + +macro_rules! oid { + ( $first:expr, $second:expr, $( $tail:expr ),* ) => + ( + [(40 * $first) + $second, $( $tail ),*] + ) +} + +#[cfg(test)] +mod tests { + use super::DerTypeId; + #[cfg(feature = "alloc")] + use alloc::vec::Vec; + + #[cfg(feature = "alloc")] + #[test] + fn test_asn1_wrap() { + // Prepend stuff to `bytes` to put it in a DER SEQUENCE. + let wrap_in_sequence = |bytes: &[u8]| super::asn1_wrap(super::Tag::Sequence, bytes); + + // Empty slice + assert_eq!(vec![0x30, 0x00], wrap_in_sequence(&[])); + + // Small size + assert_eq!( + vec![0x30, 0x04, 0x00, 0x11, 0x22, 0x33], + wrap_in_sequence(&[0x00, 0x11, 0x22, 0x33]) + ); + + // Medium size + let mut val = Vec::new(); + val.resize(255, 0x12); + assert_eq!( + vec![0x30, 0x81, 0xff, 0x12, 0x12, 0x12], + wrap_in_sequence(&val)[..6] + ); + + // Large size + let mut val = Vec::new(); + val.resize(4660, 0x12); + wrap_in_sequence(&val); + assert_eq!( + vec![0x30, 0x82, 0x12, 0x34, 0x12, 0x12], + wrap_in_sequence(&val)[..6] + ); + + // Huge size + let mut val = Vec::new(); + val.resize(0xffff, 0x12); + let result = wrap_in_sequence(&val); + assert_eq!(vec![0x30, 0x82, 0xff, 0xff, 0x12, 0x12], result[..6]); + assert_eq!(result.len(), 0xffff + 4); + + // Gigantic size + let mut val = Vec::new(); + val.resize(0x100000, 0x12); + let result = wrap_in_sequence(&val); + assert_eq!(vec![0x30, 0x83, 0x10, 0x00, 0x00, 0x12, 0x12], result[..7]); + assert_eq!(result.len(), 0x100000 + 5); + + // Ludicrous size + let mut val = Vec::new(); + val.resize(0x1000000, 0x12); + let result = wrap_in_sequence(&val); + assert_eq!( + vec![0x30, 0x84, 0x01, 0x00, 0x00, 0x00, 0x12, 0x12], + result[..8] + ); + assert_eq!(result.len(), 0x1000000 + 6); + } + + #[test] + fn test_optional_boolean() { + use super::{Error, FromDer}; + + // Empty input results in false + assert!(!bool::from_der(&mut bytes_reader(&[])).unwrap()); + + // Optional, so another data type results in false + assert!(!bool::from_der(&mut bytes_reader(&[0x05, 0x00])).unwrap()); + + // Only 0x00 and 0xff are accepted values + assert_eq!( + Err(Error::BadDer), + bool::from_der(&mut bytes_reader(&[0x01, 0x01, 0x42])) + ); + + // True + assert!(bool::from_der(&mut bytes_reader(&[0x01, 0x01, 0xff])).unwrap()); + + // False + assert!(!bool::from_der(&mut bytes_reader(&[0x01, 0x01, 0x00])).unwrap()); + } + + #[test] + fn test_bit_string_with_no_unused_bits() { + use super::{Error, bit_string_with_no_unused_bits}; + + // Unexpected type + assert_eq!( + bit_string_with_no_unused_bits(&mut bytes_reader(&[0x01, 0x01, 0xff])).unwrap_err(), + Error::TrailingData(DerTypeId::BitString), + ); + + // Unexpected nonexistent type + assert_eq!( + bit_string_with_no_unused_bits(&mut bytes_reader(&[0x42, 0xff, 0xff])).unwrap_err(), + Error::TrailingData(DerTypeId::BitString), + ); + + // Unexpected empty input + assert_eq!( + bit_string_with_no_unused_bits(&mut bytes_reader(&[])).unwrap_err(), + Error::TrailingData(DerTypeId::BitString), + ); + + // Valid input with non-zero unused bits + assert_eq!( + bit_string_with_no_unused_bits(&mut bytes_reader(&[0x03, 0x03, 0x04, 0x12, 0x34])) + .unwrap_err(), + Error::BadDer, + ); + + // Valid input + assert_eq!( + bit_string_with_no_unused_bits(&mut bytes_reader(&[0x03, 0x03, 0x00, 0x12, 0x34])) + .unwrap() + .as_slice_less_safe(), + &[0x12, 0x34], + ); + } + + fn bytes_reader(bytes: &[u8]) -> untrusted::Reader<'_> { + untrusted::Reader::new(untrusted::Input::from(bytes)) + } + + #[test] + fn read_tag_and_get_value_default_limit() { + use super::{Error, read_tag_and_get_value}; + + let inputs = &[ + // DER with short-form length encoded as three bytes. + &[EXAMPLE_TAG, 0x83, 0xFF, 0xFF, 0xFF].as_slice(), + // DER with short-form length encoded as four bytes. + &[EXAMPLE_TAG, 0x84, 0xFF, 0xFF, 0xFF, 0xFF].as_slice(), + ]; + + for input in inputs { + let mut bytes = untrusted::Reader::new(untrusted::Input::from(input)); + // read_tag_and_get_value should reject DER with encoded lengths larger than two + // bytes as BadDer. + assert!(matches!( + read_tag_and_get_value(&mut bytes), + Err(Error::BadDer) + )); + } + } + + #[test] + fn read_tag_and_get_value_limited_high_form() { + use super::{Error, LONG_FORM_LEN_TWO_BYTES_MAX, read_tag_and_get_value_limited}; + + let mut bytes = untrusted::Reader::new(untrusted::Input::from(&[0xFF])); + // read_tag_and_get_value_limited_high_form should reject DER with "high tag number form" tags. + assert!(matches!( + read_tag_and_get_value_limited(&mut bytes, LONG_FORM_LEN_TWO_BYTES_MAX), + Err(Error::BadDer) + )); + } + + #[test] + fn read_tag_and_get_value_limited_non_canonical() { + use super::{Error, LONG_FORM_LEN_TWO_BYTES_MAX, read_tag_and_get_value_limited}; + + let inputs = &[ + // Two byte length, with expressed length < 128. + &[EXAMPLE_TAG, 0x81, 0x01].as_slice(), + // Three byte length, with expressed length < 256. + &[EXAMPLE_TAG, 0x82, 0x00, 0x01].as_slice(), + // Four byte length, with expressed length, < 65536. + &[EXAMPLE_TAG, 0x83, 0x00, 0x00, 0x01].as_slice(), + // Five byte length, with expressed length < 16777216. + &[EXAMPLE_TAG, 0x84, 0x00, 0x00, 0x00, 0x01].as_slice(), + ]; + + for input in inputs { + let mut bytes = untrusted::Reader::new(untrusted::Input::from(input)); + // read_tag_and_get_value_limited should reject DER with non-canonical lengths. + assert!(matches!( + read_tag_and_get_value_limited(&mut bytes, LONG_FORM_LEN_TWO_BYTES_MAX), + Err(Error::BadDer) + )); + } + } + + #[test] + #[cfg(feature = "alloc")] + fn read_tag_and_get_value_limited_limits() { + use super::{Error, read_tag_and_get_value_limited}; + + let short_input = &[0xFF]; + let short_input_encoded = &[ + &[EXAMPLE_TAG], + der_encode_length(short_input.len()).as_slice(), + short_input, + ] + .concat(); + + let long_input = &[1_u8; 65537]; + let long_input_encoded = &[ + &[EXAMPLE_TAG], + der_encode_length(long_input.len()).as_slice(), + long_input, + ] + .concat(); + + struct Testcase<'a> { + input: &'a [u8], + limit: usize, + err: Option, + } + + let testcases = &[ + Testcase { + input: short_input_encoded, + limit: 1, + err: Some(Error::BadDer), + }, + Testcase { + input: short_input_encoded, + limit: short_input_encoded.len() + 1, + err: None, + }, + Testcase { + input: long_input_encoded, + limit: long_input.len(), + err: Some(Error::BadDer), + }, + Testcase { + input: long_input_encoded, + limit: long_input.len() + 1, + err: None, + }, + ]; + + for tc in testcases { + let mut bytes = untrusted::Reader::new(untrusted::Input::from(tc.input)); + + let res = read_tag_and_get_value_limited(&mut bytes, tc.limit); + match &tc.err { + None => assert!(res.is_ok()), + Some(e) => { + let actual = res.unwrap_err(); + assert_eq!(&actual, e) + } + } + } + } + + #[allow(clippy::as_conversions)] // infallible. + const EXAMPLE_TAG: u8 = super::Tag::Sequence as u8; + + #[cfg(feature = "alloc")] + #[allow(clippy::as_conversions)] // test code. + fn der_encode_length(length: usize) -> Vec { + if length < 128 { + vec![length as u8] + } else { + let mut encoded: Vec = Vec::new(); + let mut remaining_length = length; + + while remaining_length > 0 { + let byte = (remaining_length & 0xFF) as u8; + encoded.insert(0, byte); + remaining_length >>= 8; + } + + let length_octet = encoded.len() as u8 | 0x80; + encoded.insert(0, length_octet); + + encoded + } + } + + #[test] + fn misencoded_bit_string_flags() { + use super::{Error, bit_string_flags}; + + let bad_padding_example = untrusted::Input::from(&[ + 0x08, // 8 bit of padding (illegal!). + 0x06, // 1 byte of bit flags asserting bits 5 and 6. + ]); + assert!(matches!( + bit_string_flags(bad_padding_example), + Err(Error::BadDer) + )); + + let bad_padding_example = untrusted::Input::from(&[ + 0x01, // 1 bit of padding. + // No flags value (illegal with padding!). + ]); + assert!(matches!( + bit_string_flags(bad_padding_example), + Err(Error::BadDer) + )); + + // invalid padding for empty set + for pad in 1..=255 { + assert_eq!( + bit_string_flags(untrusted::Input::from(&[pad])).err(), + Some(Error::BadDer) + ); + } + } + + #[test] + fn valid_bit_string_flags() { + use super::bit_string_flags; + + let example_key_usage = untrusted::Input::from(&[ + 0x01, // 1 bit of padding. + 0x06, // 1 byte of bit flags asserting bits 5 and 6. + ]); + let res = bit_string_flags(example_key_usage).unwrap(); + + assert!(!res.bit_set(0)); + assert!(!res.bit_set(1)); + assert!(!res.bit_set(2)); + assert!(!res.bit_set(3)); + assert!(!res.bit_set(4)); + // NB: Bits 5 and 6 should be set. + assert!(res.bit_set(5)); + assert!(res.bit_set(6)); + assert!(!res.bit_set(7)); + assert!(!res.bit_set(8)); + // Bits outside the range of values shouldn't be considered set. + assert!(!res.bit_set(256)); + } + + #[test] + fn empty_bit_string_flags() { + let bs = super::bit_string_flags(untrusted::Input::from(&[0x00])).unwrap(); + + // all bits are unset + for b in 0..256 { + assert!(!bs.bit_set(b)); + } + } + + #[test] + fn mispadded_bit_string_flags() { + assert_eq!( + super::bit_string_flags(untrusted::Input::from(&[0x04, 0xff])).err(), + Some(super::Error::BadDer) + ); + } + + #[test] + fn test_small_nonnegative_integer() { + use super::{Error, FromDer, Tag}; + + for value in 0..=127 { + let data = [Tag::Integer.into(), 1, value]; + let mut rd = untrusted::Reader::new(untrusted::Input::from(&data)); + assert_eq!(u8::from_der(&mut rd), Ok(value),); + } + + for value in 128..=255 { + let data = [Tag::Integer.into(), 2, 0x00, value]; + let mut rd = untrusted::Reader::new(untrusted::Input::from(&data)); + assert_eq!(u8::from_der(&mut rd), Ok(value),); + } + + // not an integer + assert_eq!( + u8::from_der(&mut untrusted::Reader::new(untrusted::Input::from(&[ + Tag::Sequence.into(), + 1, + 1 + ]))), + Err(Error::BadDer) + ); + + // negative + assert_eq!( + u8::from_der(&mut untrusted::Reader::new(untrusted::Input::from(&[ + Tag::Integer.into(), + 1, + 0xff + ]))), + Err(Error::BadDer) + ); + + // positive but too large + assert_eq!( + u8::from_der(&mut untrusted::Reader::new(untrusted::Input::from(&[ + Tag::Integer.into(), + 2, + 0x01, + 0x00 + ]))), + Err(Error::BadDer) + ); + + // unnecessary leading zero + assert_eq!( + u8::from_der(&mut untrusted::Reader::new(untrusted::Input::from(&[ + Tag::Integer.into(), + 2, + 0x00, + 0x05 + ]))), + Err(Error::BadDer) + ); + + // truncations + assert_eq!( + u8::from_der(&mut untrusted::Reader::new(untrusted::Input::from(&[]))), + Err(Error::BadDer) + ); + + assert_eq!( + u8::from_der(&mut untrusted::Reader::new(untrusted::Input::from(&[ + Tag::Integer.into(), + ]))), + Err(Error::BadDer) + ); + + assert_eq!( + u8::from_der(&mut untrusted::Reader::new(untrusted::Input::from(&[ + Tag::Integer.into(), + 1, + ]))), + Err(Error::BadDer) + ); + + assert_eq!( + u8::from_der(&mut untrusted::Reader::new(untrusted::Input::from(&[ + Tag::Integer.into(), + 2, + 0 + ]))), + Err(Error::BadDer) + ); + } +} diff --git a/http/vendor/rustls-webpki/src/end_entity.rs b/http/vendor/rustls-webpki/src/end_entity.rs new file mode 100644 index 0000000..79e2b61 --- /dev/null +++ b/http/vendor/rustls-webpki/src/end_entity.rs @@ -0,0 +1,240 @@ +// Copyright 2015-2021 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use core::ops::Deref; + +use pki_types::{ + CertificateDer, ServerName, SignatureVerificationAlgorithm, TrustAnchor, UnixTime, +}; + +use crate::crl::RevocationOptions; +use crate::error::Error; +use crate::subject_name::{verify_dns_names, verify_ip_address_names}; +use crate::verify_cert::{self, ExtendedKeyUsageValidator, VerifiedPath}; +use crate::{cert, signed_data}; + +/// An end-entity certificate. +/// +/// Server certificate processing in a TLS connection consists of several +/// steps. All of these steps are necessary: +/// +/// * [`EndEntityCert::verify_for_usage()`]: Verify that the peer's certificate +/// is valid for the current usage scenario. For server authentication, use +/// [`crate::KeyUsage::server_auth()`]. +/// * [`EndEntityCert::verify_is_valid_for_subject_name()`]: Verify that the server's +/// certificate is valid for the host or IP address that is being connected to. +/// * [`EndEntityCert::verify_signature()`]: Verify that the signature of server's +/// `ServerKeyExchange` message is valid for the server's certificate. +/// +/// Client certificate processing in a TLS connection consists of analogous +/// steps. All of these steps are necessary: +/// +/// * [`EndEntityCert::verify_for_usage()`]: Verify that the peer's certificate +/// is valid for the current usage scenario. For client authentication, use +/// [`crate::KeyUsage::client_auth()`]. +/// * [`EndEntityCert::verify_signature()`]: Verify that the signature of client's +/// `CertificateVerify` message is valid using the public key from the +/// client's certificate. +/// +/// Although it would be less error-prone to combine all these steps into a +/// single function call, some significant optimizations are possible if the +/// three steps are processed separately (in parallel). It does not matter much +/// which order the steps are done in, but **all of these steps must completed +/// before application data is sent and before received application data is +/// processed**. The [`TryFrom`] conversion from `&CertificateDer<'_>` is an +/// inexpensive operation and is deterministic, so if these tasks are done in +/// multiple threads, it is probably best to just create multiple [`EndEntityCert`] +/// instances for the same DER-encoded ASN.1 certificate bytes. +pub struct EndEntityCert<'a> { + inner: cert::Cert<'a>, +} + +impl<'a> TryFrom<&'a CertificateDer<'a>> for EndEntityCert<'a> { + type Error = Error; + + /// Parse the ASN.1 DER-encoded X.509 encoding of the certificate + /// `cert_der`. + fn try_from(cert: &'a CertificateDer<'a>) -> Result { + Ok(Self { + inner: cert::Cert::from_der(untrusted::Input::from(cert.as_ref()))?, + }) + } +} + +impl EndEntityCert<'_> { + /// Verifies that the end-entity certificate is valid for use against the + /// specified Extended Key Usage (EKU). + /// + /// * `supported_sig_algs` is the list of signature algorithms that are + /// trusted for use in certificate signatures; the end-entity certificate's + /// public key is not validated against this list. + /// * `trust_anchors` is the list of root CAs to trust in the built path. + /// * `intermediate_certs` is the sequence of intermediate certificates that + /// a peer sent for the purpose of path building. + /// * `time` is the time for which the validation is effective (usually the + /// current time). + /// * `usage` is the intended usage of the certificate, indicating what kind + /// of usage we're verifying the certificate for. The default [`ExtendedKeyUsageValidator`] + /// implementation is [`KeyUsage`](crate::KeyUsage). + /// * `crls` is the list of certificate revocation lists to check + /// the certificate against. + /// * `verify_path` is an optional verification function for path candidates. + /// + /// If successful, yields a `VerifiedPath` type that can be used to inspect a verified chain + /// of certificates that leads from the `end_entity` to one of the `self.trust_anchors`. + /// + /// `verify_path` will only be called for potentially verified paths, that is, paths that + /// have been verified up to the trust anchor. As such, `verify_path()` cannot be used to + /// verify a path that doesn't satisfy the constraints listed above; it can only be used to + /// reject a path that does satisfy the aforementioned constraints. If `verify_path` returns + /// an error, path building will continue in order to try other options. + #[allow(clippy::too_many_arguments)] + pub fn verify_for_usage<'p>( + &'p self, + supported_sig_algs: &[&dyn SignatureVerificationAlgorithm], + trust_anchors: &'p [TrustAnchor<'_>], + intermediate_certs: &'p [CertificateDer<'p>], + time: UnixTime, + usage: impl ExtendedKeyUsageValidator, + revocation: Option>, + verify_path: Option<&dyn Fn(&VerifiedPath<'_>) -> Result<(), Error>>, + ) -> Result, Error> { + verify_cert::ChainOptions { + eku: usage, + supported_sig_algs, + trust_anchors, + intermediate_certs, + revocation, + } + .build_chain(self, time, verify_path) + } + + /// Verifies that the certificate is valid for the given Subject Name. + pub fn verify_is_valid_for_subject_name( + &self, + server_name: &ServerName<'_>, + ) -> Result<(), Error> { + match server_name { + ServerName::DnsName(dns_name) => verify_dns_names(dns_name, &self.inner), + // IP addresses are not compared against the subject field; + // only against Subject Alternative Names. + ServerName::IpAddress(ip_address) => verify_ip_address_names(ip_address, &self.inner), + _ => Err(Error::UnsupportedNameType), + } + } + + /// Verifies the signature `signature` of message `msg` using the + /// certificate's public key. + /// + /// `signature_alg` is the algorithm to use to + /// verify the signature; the certificate's public key is verified to be + /// compatible with this algorithm. + /// + /// For TLS 1.2, `signature` corresponds to TLS's + /// `DigitallySigned.signature` and `signature_alg` corresponds to TLS's + /// `DigitallySigned.algorithm` of TLS type `SignatureAndHashAlgorithm`. In + /// TLS 1.2 a single `SignatureAndHashAlgorithm` may map to multiple + /// `SignatureVerificationAlgorithm`s. For example, a TLS 1.2 + /// `SignatureAndHashAlgorithm` of (ECDSA, SHA-256) may map to any or all + /// of {`ECDSA_P256_SHA256`, `ECDSA_P384_SHA256`}, depending on how the TLS + /// implementation is configured. + /// + /// For current TLS 1.3 drafts, `signature_alg` corresponds to TLS's + /// `algorithm` fields of type `SignatureScheme`. There is (currently) a + /// one-to-one correspondence between TLS 1.3's `SignatureScheme` and + /// `SignatureVerificationAlgorithm`. + pub fn verify_signature( + &self, + signature_alg: &dyn SignatureVerificationAlgorithm, + msg: &[u8], + signature: &[u8], + ) -> Result<(), Error> { + signed_data::verify_signature( + signature_alg, + self.inner.spki, + untrusted::Input::from(msg), + untrusted::Input::from(signature), + ) + } +} + +impl<'a> Deref for EndEntityCert<'a> { + type Target = cert::Cert<'a>; + + fn deref(&self) -> &Self::Target { + &self.inner + } +} + +#[cfg(feature = "alloc")] +#[cfg(test)] +mod tests { + use alloc::string::ToString; + + use super::*; + use crate::test_utils; + use crate::test_utils::RCGEN_SIGNATURE_ALG; + + // This test reproduces https://github.com/rustls/webpki/issues/167 --- an + // end-entity cert where the common name is a `PrintableString` rather than + // a `UTF8String` cannot iterate over its subject alternative names. + #[test] + fn printable_string_common_name() { + const DNS_NAME: &str = "test.example.com"; + + let issuer = test_utils::make_issuer("Test"); + + let ee_cert = { + let mut params = test_utils::end_entity_params(vec![DNS_NAME.to_string()]); + // construct a certificate that uses `PrintableString` as the + // common name value, rather than `UTF8String`. + params.distinguished_name.push( + rcgen::DnType::CommonName, + rcgen::DnValue::PrintableString( + rcgen::string::PrintableString::try_from("example.com").unwrap(), + ), + ); + params + .signed_by( + &rcgen::KeyPair::generate_for(RCGEN_SIGNATURE_ALG).unwrap(), + &issuer, + ) + .expect("failed to make ee cert (this is a test bug)") + }; + + expect_dns_name(ee_cert.der(), DNS_NAME); + } + + // This test reproduces https://github.com/rustls/webpki/issues/167 --- an + // end-entity cert where the common name is an empty SEQUENCE. + #[test] + fn empty_sequence_common_name() { + let ee_cert_der = { + // handcrafted cert DER produced using `ascii2der`, since `rcgen` is + // unwilling to generate this particular weird cert. + let bytes = include_bytes!("../tests/misc/empty_sequence_common_name.der"); + CertificateDer::from(&bytes[..]) + }; + expect_dns_name(&ee_cert_der, "example.com"); + } + + fn expect_dns_name(der: &CertificateDer<'_>, name: &str) { + let cert = + EndEntityCert::try_from(der).expect("should parse end entity certificate correctly"); + + let mut names = cert.valid_dns_names(); + assert_eq!(names.next(), Some(name)); + assert_eq!(names.next(), None); + } +} diff --git a/http/vendor/rustls-webpki/src/error.rs b/http/vendor/rustls-webpki/src/error.rs new file mode 100644 index 0000000..c104d50 --- /dev/null +++ b/http/vendor/rustls-webpki/src/error.rs @@ -0,0 +1,460 @@ +// Copyright 2015 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#[cfg(feature = "alloc")] +use alloc::string::String; +#[cfg(feature = "alloc")] +use alloc::vec::Vec; +use core::fmt; +use core::ops::ControlFlow; + +use pki_types::UnixTime; +#[cfg(feature = "alloc")] +use pki_types::{AlgorithmIdentifier, ServerName}; + +use crate::verify_cert::RequiredEkuNotFoundContext; + +/// An error that occurs during certificate validation or name validation. +#[derive(Clone, Debug, PartialEq, Eq)] +#[non_exhaustive] +pub enum Error { + /// The encoding of some ASN.1 DER-encoded item is invalid. + BadDer, + + /// The encoding of an ASN.1 DER-encoded time is invalid. + BadDerTime, + + /// A CA certificate is being used as an end-entity certificate. + CaUsedAsEndEntity, + + /// The certificate is expired; i.e. the time it is being validated for is + /// later than the certificate's notAfter time. + CertExpired { + /// The validation time. + time: UnixTime, + /// The notAfter time of the certificate. + not_after: UnixTime, + }, + + /// The certificate is not valid for the name it is being validated for. + CertNotValidForName(InvalidNameContext), + + /// The certificate is not valid yet; i.e. the time it is being validated + /// for is earlier than the certificate's notBefore time. + CertNotValidYet { + /// The validation time. + time: UnixTime, + /// The notBefore time of the certificate. + not_before: UnixTime, + }, + + /// The certificate, or one of its issuers, has been revoked. + CertRevoked, + + /// The CRL is expired; i.e. the verification time is not before the time + /// in the CRL nextUpdate field. + CrlExpired { + /// The validation time. + time: UnixTime, + /// The nextUpdate time of the CRL. + next_update: UnixTime, + }, + + /// The certificate has an Extended Key Usage extension without any EKU values. + EmptyEkuExtension, + + /// An end-entity certificate is being used as a CA certificate. + EndEntityUsedAsCa, + + /// An X.509 extension is invalid. + ExtensionValueInvalid, + + /// The certificate validity period (notBefore, notAfter) is invalid; e.g. + /// the notAfter time is earlier than the notBefore time. + InvalidCertValidity, + + /// A CRL number extension was invalid: + /// - it was mis-encoded + /// - it was negative + /// - it was too long + InvalidCrlNumber, + + /// A iPAddress name constraint was invalid: + /// - it had a sparse network mask (ie, cannot be written in CIDR form). + /// - it was too long or short + InvalidNetworkMaskConstraint, + + /// A serial number was invalid: + /// - it was misencoded + /// - it was negative + /// - it was too long + InvalidSerialNumber, + + /// The CRL signature is invalid for the issuer's public key. + InvalidCrlSignatureForPublicKey, + + /// The signature is invalid for the given public key. + InvalidSignatureForPublicKey, + + /// A CRL was signed by an issuer that has a KeyUsage bitstring that does not include + /// the cRLSign key usage bit. + IssuerNotCrlSigner, + + /// A presented or reference DNS identifier was malformed, potentially + /// containing invalid characters or invalid labels. + MalformedDnsIdentifier, + + /// The certificate extensions are malformed. + /// + /// In particular, webpki requires the DNS name(s) be in the subjectAltName + /// extension as required by the CA/Browser Forum Baseline Requirements + /// and as recommended by RFC6125. + MalformedExtensions, + + /// A name constraint was malformed, potentially containing invalid characters or + /// invalid labels. + MalformedNameConstraint, + + /// The maximum number of name constraint comparisons has been reached. + MaximumNameConstraintComparisonsExceeded, + + /// The maximum number of internal path building calls has been reached. Path complexity is too great. + MaximumPathBuildCallsExceeded, + + /// The path search was terminated because it became too deep. + MaximumPathDepthExceeded, + + /// The maximum number of signature checks has been reached. Path complexity is too great. + MaximumSignatureChecksExceeded, + + /// The certificate violates one or more name constraints. + NameConstraintViolation, + + /// The certificate violates one or more path length constraints. + PathLenConstraintViolated, + + /// The certificate is not valid for the Extended Key Usage for which it is + /// being validated. + #[deprecated(since = "0.103.2", note = "use RequiredEkuNotFoundContext instead")] + RequiredEkuNotFound, + + /// The certificate is not valid for the Extended Key Usage for which it is + /// being validated. + RequiredEkuNotFoundContext(RequiredEkuNotFoundContext), + + /// The algorithm in the TBSCertificate "signature" field of a certificate + /// does not match the algorithm in the signature of the certificate. + SignatureAlgorithmMismatch, + + /// Trailing data was found while parsing DER-encoded input for the named type. + TrailingData(DerTypeId), + + /// A valid issuer for the certificate could not be found. + UnknownIssuer, + + /// The certificate's revocation status could not be determined. + UnknownRevocationStatus, + + /// The certificate is not a v3 X.509 certificate. + /// + /// This error may be also reported if the certificate version field + /// is malformed. + UnsupportedCertVersion, + + /// The certificate contains an unsupported critical extension. + UnsupportedCriticalExtension, + + /// The CRL contains an issuing distribution point with no distribution point name, + /// or a distribution point name relative to an issuer. + UnsupportedCrlIssuingDistributionPoint, + + /// The CRL is not a v2 X.509 CRL. + /// + /// The RFC 5280 web PKI profile mandates only version 2 be used. See section + /// 5.1.2.1 for more information. + /// + /// This error may also be reported if the CRL version field is malformed. + UnsupportedCrlVersion, + + /// The CRL is an unsupported "delta" CRL. + UnsupportedDeltaCrl, + + /// The CRL contains unsupported "indirect" entries. + UnsupportedIndirectCrl, + + /// The `ServerName` contained an unsupported type of value. + UnsupportedNameType, + + /// The revocation reason is not in the set of supported revocation reasons. + UnsupportedRevocationReason, + + /// The CRL is partitioned by revocation reasons. + UnsupportedRevocationReasonsPartitioning, + + /// The signature algorithm for a signature over a CRL is not in the set of supported + /// signature algorithms given. + #[deprecated( + since = "0.103.4", + note = "use UnsupportedCrlSignatureAlgorithmContext instead" + )] + UnsupportedCrlSignatureAlgorithm, + + /// The signature algorithm for a signature is not in the set of supported + /// signature algorithms given. + UnsupportedCrlSignatureAlgorithmContext(UnsupportedSignatureAlgorithmContext), + + /// The signature algorithm for a signature is not in the set of supported + /// signature algorithms given. + #[deprecated( + since = "0.103.4", + note = "use UnsupportedSignatureAlgorithmContext instead" + )] + UnsupportedSignatureAlgorithm, + + /// The signature algorithm for a signature is not in the set of supported + /// signature algorithms given. + UnsupportedSignatureAlgorithmContext(UnsupportedSignatureAlgorithmContext), + + /// The CRL signature's algorithm does not match the algorithm of the issuer + /// public key it is being validated for. This may be because the public key + /// algorithm's OID isn't recognized (e.g. DSA), or the public key + /// algorithm's parameters don't match the supported parameters for that + /// algorithm (e.g. ECC keys for unsupported curves), or the public key + /// algorithm and the signature algorithm simply don't match (e.g. + /// verifying an RSA signature with an ECC public key). + #[deprecated( + since = "0.103.4", + note = "use UnsupportedCrlSignatureAlgorithmForPublicKeyContext instead" + )] + UnsupportedCrlSignatureAlgorithmForPublicKey, + + /// The signature's algorithm does not match the algorithm of the public + /// key it is being validated for. This may be because the public key + /// algorithm's OID isn't recognized (e.g. DSA), or the public key + /// algorithm's parameters don't match the supported parameters for that + /// algorithm (e.g. ECC keys for unsupported curves), or the public key + /// algorithm and the signature algorithm simply don't match (e.g. + /// verifying an RSA signature with an ECC public key). + UnsupportedCrlSignatureAlgorithmForPublicKeyContext( + UnsupportedSignatureAlgorithmForPublicKeyContext, + ), + + /// The signature's algorithm does not match the algorithm of the public + /// key it is being validated for. This may be because the public key + /// algorithm's OID isn't recognized (e.g. DSA), or the public key + /// algorithm's parameters don't match the supported parameters for that + /// algorithm (e.g. ECC keys for unsupported curves), or the public key + /// algorithm and the signature algorithm simply don't match (e.g. + /// verifying an RSA signature with an ECC public key). + #[deprecated( + since = "0.103.4", + note = "use UnsupportedSignatureAlgorithmForPublicKeyContext instead" + )] + UnsupportedSignatureAlgorithmForPublicKey, + + /// The signature's algorithm does not match the algorithm of the public + /// key it is being validated for. This may be because the public key + /// algorithm's OID isn't recognized (e.g. DSA), or the public key + /// algorithm's parameters don't match the supported parameters for that + /// algorithm (e.g. ECC keys for unsupported curves), or the public key + /// algorithm and the signature algorithm simply don't match (e.g. + /// verifying an RSA signature with an ECC public key). + UnsupportedSignatureAlgorithmForPublicKeyContext( + UnsupportedSignatureAlgorithmForPublicKeyContext, + ), +} + +impl Error { + // Compare the Error with the new error by rank, returning the higher rank of the two as + // the most specific error. + pub(crate) fn most_specific(self, new: Self) -> Self { + // Assign an error a numeric value ranking it by specificity. + if self.rank() >= new.rank() { self } else { new } + } + + // Return a numeric indication of how specific the error is, where an error with a higher rank + // is considered more useful to an end user than an error with a lower rank. This is used by + // Error::most_specific to compare two errors in order to return which is more specific. + #[allow(clippy::as_conversions)] // We won't exceed u32 errors. + pub(crate) fn rank(&self) -> u32 { + match &self { + // Errors related to certificate validity + Self::CertNotValidYet { .. } | Self::CertExpired { .. } => 290, + Self::CertNotValidForName(_) => 280, + Self::CertRevoked | Self::UnknownRevocationStatus | Self::CrlExpired { .. } => 270, + Self::InvalidCrlSignatureForPublicKey | Self::InvalidSignatureForPublicKey => 260, + Self::SignatureAlgorithmMismatch => 250, + Self::EmptyEkuExtension => 245, + #[allow(deprecated)] + Self::RequiredEkuNotFound | Self::RequiredEkuNotFoundContext(_) => 240, + Self::NameConstraintViolation => 230, + Self::PathLenConstraintViolated => 220, + Self::CaUsedAsEndEntity | Self::EndEntityUsedAsCa => 210, + Self::IssuerNotCrlSigner => 200, + + // Errors related to supported features used in an invalid way. + Self::InvalidCertValidity => 190, + Self::InvalidNetworkMaskConstraint => 180, + Self::InvalidSerialNumber => 170, + Self::InvalidCrlNumber => 160, + + // Errors related to unsupported features. + #[allow(deprecated)] + Self::UnsupportedCrlSignatureAlgorithmForPublicKey + | Self::UnsupportedCrlSignatureAlgorithmForPublicKeyContext(_) + | Self::UnsupportedSignatureAlgorithmForPublicKey + | Self::UnsupportedSignatureAlgorithmForPublicKeyContext(_) => 150, + #[allow(deprecated)] + Self::UnsupportedCrlSignatureAlgorithm + | Self::UnsupportedCrlSignatureAlgorithmContext(_) + | Self::UnsupportedSignatureAlgorithm + | Self::UnsupportedSignatureAlgorithmContext(_) => 140, + Self::UnsupportedCriticalExtension => 130, + Self::UnsupportedCertVersion => 130, + Self::UnsupportedCrlVersion => 120, + Self::UnsupportedDeltaCrl => 110, + Self::UnsupportedIndirectCrl => 100, + Self::UnsupportedNameType => 95, + Self::UnsupportedRevocationReason => 90, + Self::UnsupportedRevocationReasonsPartitioning => 80, + Self::UnsupportedCrlIssuingDistributionPoint => 70, + Self::MaximumPathDepthExceeded => 61, + + // Errors related to malformed data. + Self::MalformedDnsIdentifier => 60, + Self::MalformedNameConstraint => 50, + Self::MalformedExtensions | Self::TrailingData(_) => 40, + Self::ExtensionValueInvalid => 30, + + // Generic DER errors. + Self::BadDerTime => 20, + Self::BadDer => 10, + + // Special case errors - not subject to ranking. + Self::MaximumSignatureChecksExceeded => 0, + Self::MaximumPathBuildCallsExceeded => 0, + Self::MaximumNameConstraintComparisonsExceeded => 0, + + // Default catch all error - should be renamed in the future. + Self::UnknownIssuer => 0, + } + } + + /// Returns true for errors that should be considered fatal during path building. Errors of + /// this class should halt any further path building and be returned immediately. + #[inline] + pub(crate) fn is_fatal(&self) -> bool { + matches!( + self, + Self::MaximumSignatureChecksExceeded + | Self::MaximumPathBuildCallsExceeded + | Self::MaximumNameConstraintComparisonsExceeded + ) + } +} + +impl From for ControlFlow { + fn from(value: Error) -> Self { + match value { + // If an error is fatal, we've exhausted the potential for continued search. + err if err.is_fatal() => Self::Break(err), + // Otherwise we've rejected one candidate chain, but may continue to search for others. + err => Self::Continue(err), + } + } +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "{self:?}") + } +} + +#[cfg(feature = "std")] +impl ::std::error::Error for Error {} + +/// Additional context for the `CertNotValidForName` error variant. +/// +/// The contents of this type depend on whether the `alloc` feature is enabled. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct InvalidNameContext { + /// Expected server name. + #[cfg(feature = "alloc")] + pub expected: ServerName<'static>, + /// The names presented in the end entity certificate. + /// + /// These are the subject names as present in the leaf certificate and may contain DNS names + /// with or without a wildcard label as well as IP address names. + #[cfg(feature = "alloc")] + pub presented: Vec, +} + +/// Additional context for the `UnsupportedSignatureAlgorithmForPublicKey` error variant. +/// +/// The contents of this type depend on whether the `alloc` feature is enabled. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct UnsupportedSignatureAlgorithmForPublicKeyContext { + /// The signature algorithm OID. + #[cfg(feature = "alloc")] + pub signature_algorithm_id: Vec, + /// The public key algorithm OID. + #[cfg(feature = "alloc")] + pub public_key_algorithm_id: Vec, +} + +/// Additional context for the `UnsupportedSignatureAlgorithm` error variant. +/// +/// The contents of this type depend on whether the `alloc` feature is enabled. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct UnsupportedSignatureAlgorithmContext { + /// The signature algorithm OID that was unsupported. + #[cfg(feature = "alloc")] + pub signature_algorithm_id: Vec, + /// Supported algorithms that were available for signature verification. + #[cfg(feature = "alloc")] + pub supported_algorithms: Vec, +} + +/// Trailing data was found while parsing DER-encoded input for the named type. +#[allow(missing_docs)] +#[non_exhaustive] +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub enum DerTypeId { + BitString, + Bool, + Certificate, + CertificateExtensions, + CertificateTbsCertificate, + CertRevocationList, + CertRevocationListExtension, + CrlDistributionPoint, + CommonNameInner, + CommonNameOuter, + DistributionPointName, + Extension, + GeneralName, + RevocationReason, + Signature, + SignatureAlgorithm, + SignedData, + SubjectPublicKeyInfo, + Time, + TrustAnchorV1, + TrustAnchorV1TbsCertificate, + U8, + RevokedCertificate, + RevokedCertificateExtension, + RevokedCertEntry, + IssuingDistributionPoint, +} diff --git a/http/vendor/rustls-webpki/src/lib.rs b/http/vendor/rustls-webpki/src/lib.rs new file mode 100644 index 0000000..922365f --- /dev/null +++ b/http/vendor/rustls-webpki/src/lib.rs @@ -0,0 +1,221 @@ +// Copyright 2015 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! webpki: Web PKI X.509 Certificate Validation. +//! +//! See `EndEntityCert`'s documentation for a description of the certificate +//! processing steps necessary for a TLS connection. +//! +//! # Features +//! +//! | Feature | Description | +//! | ------- | ----------- | +//! | `alloc` | Enable features that require use of the heap. Currently all RSA signature algorithms require this feature. | +//! | `std` | Enable features that require libstd. Implies `alloc`. | +//! | `ring` | Enable use of the *ring* crate for cryptography. | +//! | `aws-lc-rs` | Enable use of the aws-lc-rs crate for cryptography. Previously this feature was named `aws_lc_rs`. | + +#![no_std] +#![warn( + elided_lifetimes_in_paths, + unnameable_types, + unreachable_pub, + clippy::use_self +)] +#![deny(missing_docs, clippy::as_conversions)] +#![allow( + clippy::len_without_is_empty, + clippy::manual_let_else, + clippy::new_without_default, + clippy::single_match, + clippy::single_match_else, + clippy::type_complexity, + clippy::upper_case_acronyms +)] +// Enable documentation for all features on docs.rs +#![cfg_attr(webpki_docsrs, feature(doc_cfg))] + +#[cfg(any(feature = "std", test))] +extern crate std; + +#[cfg(any(test, feature = "alloc"))] +#[cfg_attr(test, macro_use)] +extern crate alloc; + +#[macro_use] +mod der; + +#[cfg(feature = "aws-lc-rs")] +mod aws_lc_rs_algs; +mod cert; +mod end_entity; +mod error; +#[cfg(feature = "ring")] +mod ring_algs; +mod rpk_entity; +mod signed_data; +mod subject_name; +mod time; +mod trust_anchor; + +mod crl; +mod verify_cert; +mod x509; + +#[cfg(test)] +pub(crate) mod test_utils; + +pub use { + cert::Cert, + crl::{ + BorrowedCertRevocationList, BorrowedRevokedCert, CertRevocationList, CrlsRequired, + ExpirationPolicy, RevocationCheckDepth, RevocationOptions, RevocationOptionsBuilder, + RevocationReason, UnknownStatusPolicy, + }, + der::DerIterator, + end_entity::EndEntityCert, + error::{ + DerTypeId, Error, InvalidNameContext, UnsupportedSignatureAlgorithmContext, + UnsupportedSignatureAlgorithmForPublicKeyContext, + }, + rpk_entity::RawPublicKeyEntity, + trust_anchor::anchor_from_trusted_cert, + verify_cert::{ + ExtendedKeyUsageValidator, IntermediateIterator, KeyPurposeId, KeyPurposeIdIter, KeyUsage, + RequiredEkuNotFoundContext, VerifiedPath, + }, +}; + +#[cfg(feature = "alloc")] +pub use crl::{OwnedCertRevocationList, OwnedRevokedCert}; + +#[cfg(feature = "ring")] +/// Signature verification algorithm implementations using the *ring* crypto library. +pub mod ring { + pub use super::ring_algs::{ + ECDSA_P256_SHA256, ECDSA_P256_SHA384, ECDSA_P384_SHA256, ECDSA_P384_SHA384, ED25519, + }; + + #[cfg(feature = "alloc")] + pub use super::ring_algs::{ + RSA_PKCS1_2048_8192_SHA256, RSA_PKCS1_2048_8192_SHA256_ABSENT_PARAMS, + RSA_PKCS1_2048_8192_SHA384, RSA_PKCS1_2048_8192_SHA384_ABSENT_PARAMS, + RSA_PKCS1_2048_8192_SHA512, RSA_PKCS1_2048_8192_SHA512_ABSENT_PARAMS, + RSA_PKCS1_3072_8192_SHA384, RSA_PSS_2048_8192_SHA256_LEGACY_KEY, + RSA_PSS_2048_8192_SHA384_LEGACY_KEY, RSA_PSS_2048_8192_SHA512_LEGACY_KEY, + }; +} + +#[cfg(feature = "aws-lc-rs")] +/// Signature verification algorithm implementations using the aws-lc-rs crypto library. +pub mod aws_lc_rs { + pub use super::aws_lc_rs_algs::{ + ECDSA_P256_SHA256, ECDSA_P256_SHA384, ECDSA_P256_SHA512, ECDSA_P384_SHA256, + ECDSA_P384_SHA384, ECDSA_P384_SHA512, ECDSA_P521_SHA256, ECDSA_P521_SHA384, + ECDSA_P521_SHA512, ED25519, RSA_PKCS1_2048_8192_SHA256, + RSA_PKCS1_2048_8192_SHA256_ABSENT_PARAMS, RSA_PKCS1_2048_8192_SHA384, + RSA_PKCS1_2048_8192_SHA384_ABSENT_PARAMS, RSA_PKCS1_2048_8192_SHA512, + RSA_PKCS1_2048_8192_SHA512_ABSENT_PARAMS, RSA_PKCS1_3072_8192_SHA384, + RSA_PSS_2048_8192_SHA256_LEGACY_KEY, RSA_PSS_2048_8192_SHA384_LEGACY_KEY, + RSA_PSS_2048_8192_SHA512_LEGACY_KEY, + }; + #[cfg(all(feature = "aws-lc-rs-unstable", not(feature = "aws-lc-rs-fips")))] + pub use super::aws_lc_rs_algs::{ML_DSA_44, ML_DSA_65, ML_DSA_87}; +} + +/// An array of all the verification algorithms exported by this crate. +/// +/// This will be empty if the crate is built without the `ring` and `aws-lc-rs` features. +pub static ALL_VERIFICATION_ALGS: &[&dyn pki_types::SignatureVerificationAlgorithm] = &[ + #[cfg(feature = "ring")] + ring::ECDSA_P256_SHA256, + #[cfg(feature = "ring")] + ring::ECDSA_P256_SHA384, + #[cfg(feature = "ring")] + ring::ECDSA_P384_SHA256, + #[cfg(feature = "ring")] + ring::ECDSA_P384_SHA384, + #[cfg(feature = "ring")] + ring::ED25519, + #[cfg(all(feature = "ring", feature = "alloc"))] + ring::RSA_PKCS1_2048_8192_SHA256, + #[cfg(all(feature = "ring", feature = "alloc"))] + ring::RSA_PKCS1_2048_8192_SHA384, + #[cfg(all(feature = "ring", feature = "alloc"))] + ring::RSA_PKCS1_2048_8192_SHA512, + #[cfg(all(feature = "ring", feature = "alloc"))] + ring::RSA_PKCS1_2048_8192_SHA256_ABSENT_PARAMS, + #[cfg(all(feature = "ring", feature = "alloc"))] + ring::RSA_PKCS1_2048_8192_SHA384_ABSENT_PARAMS, + #[cfg(all(feature = "ring", feature = "alloc"))] + ring::RSA_PKCS1_2048_8192_SHA512_ABSENT_PARAMS, + #[cfg(all(feature = "ring", feature = "alloc"))] + ring::RSA_PKCS1_3072_8192_SHA384, + #[cfg(all(feature = "ring", feature = "alloc"))] + ring::RSA_PSS_2048_8192_SHA256_LEGACY_KEY, + #[cfg(all(feature = "ring", feature = "alloc"))] + ring::RSA_PSS_2048_8192_SHA384_LEGACY_KEY, + #[cfg(all(feature = "ring", feature = "alloc"))] + ring::RSA_PSS_2048_8192_SHA512_LEGACY_KEY, + #[cfg(feature = "aws-lc-rs")] + aws_lc_rs::ECDSA_P256_SHA256, + #[cfg(feature = "aws-lc-rs")] + aws_lc_rs::ECDSA_P256_SHA384, + #[cfg(feature = "aws-lc-rs")] + aws_lc_rs::ECDSA_P256_SHA512, + #[cfg(feature = "aws-lc-rs")] + aws_lc_rs::ECDSA_P384_SHA256, + #[cfg(feature = "aws-lc-rs")] + aws_lc_rs::ECDSA_P384_SHA384, + #[cfg(feature = "aws-lc-rs")] + aws_lc_rs::ECDSA_P384_SHA512, + #[cfg(feature = "aws-lc-rs")] + aws_lc_rs::ECDSA_P521_SHA256, + #[cfg(feature = "aws-lc-rs")] + aws_lc_rs::ECDSA_P521_SHA384, + #[cfg(feature = "aws-lc-rs")] + aws_lc_rs::ECDSA_P521_SHA512, + #[cfg(feature = "aws-lc-rs")] + aws_lc_rs::ED25519, + #[cfg(feature = "aws-lc-rs")] + aws_lc_rs::RSA_PKCS1_2048_8192_SHA256, + #[cfg(feature = "aws-lc-rs")] + aws_lc_rs::RSA_PKCS1_2048_8192_SHA384, + #[cfg(feature = "aws-lc-rs")] + aws_lc_rs::RSA_PKCS1_2048_8192_SHA512, + #[cfg(feature = "aws-lc-rs")] + aws_lc_rs::RSA_PKCS1_2048_8192_SHA256_ABSENT_PARAMS, + #[cfg(feature = "aws-lc-rs")] + aws_lc_rs::RSA_PKCS1_2048_8192_SHA384_ABSENT_PARAMS, + #[cfg(feature = "aws-lc-rs")] + aws_lc_rs::RSA_PKCS1_2048_8192_SHA512_ABSENT_PARAMS, + #[cfg(feature = "aws-lc-rs")] + aws_lc_rs::RSA_PKCS1_3072_8192_SHA384, + #[cfg(feature = "aws-lc-rs")] + aws_lc_rs::RSA_PSS_2048_8192_SHA256_LEGACY_KEY, + #[cfg(feature = "aws-lc-rs")] + aws_lc_rs::RSA_PSS_2048_8192_SHA384_LEGACY_KEY, + #[cfg(feature = "aws-lc-rs")] + aws_lc_rs::RSA_PSS_2048_8192_SHA512_LEGACY_KEY, + #[cfg(all(feature = "aws-lc-rs-unstable", not(feature = "aws-lc-rs-fips")))] + aws_lc_rs::ML_DSA_44, + #[cfg(all(feature = "aws-lc-rs-unstable", not(feature = "aws-lc-rs-fips")))] + aws_lc_rs::ML_DSA_65, + #[cfg(all(feature = "aws-lc-rs-unstable", not(feature = "aws-lc-rs-fips")))] + aws_lc_rs::ML_DSA_87, +]; + +fn public_values_eq(a: untrusted::Input<'_>, b: untrusted::Input<'_>) -> bool { + a.as_slice_less_safe() == b.as_slice_less_safe() +} diff --git a/http/vendor/rustls-webpki/src/ring_algs.rs b/http/vendor/rustls-webpki/src/ring_algs.rs new file mode 100644 index 0000000..7b7ae3f --- /dev/null +++ b/http/vendor/rustls-webpki/src/ring_algs.rs @@ -0,0 +1,303 @@ +// Copyright 2015 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use pki_types::{AlgorithmIdentifier, InvalidSignature, SignatureVerificationAlgorithm, alg_id}; +use ring::signature; + +/// A `SignatureVerificationAlgorithm` implemented using *ring*. +#[derive(Debug)] +struct RingAlgorithm { + public_key_alg_id: AlgorithmIdentifier, + signature_alg_id: AlgorithmIdentifier, + verification_alg: &'static dyn signature::VerificationAlgorithm, +} + +impl SignatureVerificationAlgorithm for RingAlgorithm { + fn public_key_alg_id(&self) -> AlgorithmIdentifier { + self.public_key_alg_id + } + + fn signature_alg_id(&self) -> AlgorithmIdentifier { + self.signature_alg_id + } + + fn verify_signature( + &self, + public_key: &[u8], + message: &[u8], + signature: &[u8], + ) -> Result<(), InvalidSignature> { + signature::UnparsedPublicKey::new(self.verification_alg, public_key) + .verify(message, signature) + .map_err(|_| InvalidSignature) + } +} + +/// ECDSA signatures using the P-256 curve and SHA-256. +pub static ECDSA_P256_SHA256: &dyn SignatureVerificationAlgorithm = &RingAlgorithm { + public_key_alg_id: alg_id::ECDSA_P256, + signature_alg_id: alg_id::ECDSA_SHA256, + verification_alg: &signature::ECDSA_P256_SHA256_ASN1, +}; + +/// ECDSA signatures using the P-256 curve and SHA-384. Deprecated. +pub static ECDSA_P256_SHA384: &dyn SignatureVerificationAlgorithm = &RingAlgorithm { + public_key_alg_id: alg_id::ECDSA_P256, + signature_alg_id: alg_id::ECDSA_SHA384, + verification_alg: &signature::ECDSA_P256_SHA384_ASN1, +}; + +/// ECDSA signatures using the P-384 curve and SHA-256. Deprecated. +pub static ECDSA_P384_SHA256: &dyn SignatureVerificationAlgorithm = &RingAlgorithm { + public_key_alg_id: alg_id::ECDSA_P384, + signature_alg_id: alg_id::ECDSA_SHA256, + verification_alg: &signature::ECDSA_P384_SHA256_ASN1, +}; + +/// ECDSA signatures using the P-384 curve and SHA-384. +pub static ECDSA_P384_SHA384: &dyn SignatureVerificationAlgorithm = &RingAlgorithm { + public_key_alg_id: alg_id::ECDSA_P384, + signature_alg_id: alg_id::ECDSA_SHA384, + verification_alg: &signature::ECDSA_P384_SHA384_ASN1, +}; + +/// RSA PKCS#1 1.5 signatures using SHA-256 for keys of 2048-8192 bits. +#[cfg(feature = "alloc")] +pub static RSA_PKCS1_2048_8192_SHA256: &dyn SignatureVerificationAlgorithm = &RingAlgorithm { + public_key_alg_id: alg_id::RSA_ENCRYPTION, + signature_alg_id: alg_id::RSA_PKCS1_SHA256, + verification_alg: &signature::RSA_PKCS1_2048_8192_SHA256, +}; + +/// RSA PKCS#1 1.5 signatures using SHA-384 for keys of 2048-8192 bits. +#[cfg(feature = "alloc")] +pub static RSA_PKCS1_2048_8192_SHA384: &dyn SignatureVerificationAlgorithm = &RingAlgorithm { + public_key_alg_id: alg_id::RSA_ENCRYPTION, + signature_alg_id: alg_id::RSA_PKCS1_SHA384, + verification_alg: &signature::RSA_PKCS1_2048_8192_SHA384, +}; + +/// RSA PKCS#1 1.5 signatures using SHA-512 for keys of 2048-8192 bits. +#[cfg(feature = "alloc")] +pub static RSA_PKCS1_2048_8192_SHA512: &dyn SignatureVerificationAlgorithm = &RingAlgorithm { + public_key_alg_id: alg_id::RSA_ENCRYPTION, + signature_alg_id: alg_id::RSA_PKCS1_SHA512, + verification_alg: &signature::RSA_PKCS1_2048_8192_SHA512, +}; + +/// RSA PKCS#1 1.5 signatures using SHA-256 for keys of 2048-8192 bits, +/// with illegally absent AlgorithmIdentifier parameters. +/// +/// RFC4055 says on sha256WithRSAEncryption and company: +/// +/// > When any of these four object identifiers appears within an +/// > AlgorithmIdentifier, the parameters MUST be NULL. Implementations +/// > MUST accept the parameters being absent as well as present. +/// +/// This algorithm covers the absent case, [`RSA_PKCS1_2048_8192_SHA256`] covers +/// the present case. +#[cfg(feature = "alloc")] +pub static RSA_PKCS1_2048_8192_SHA256_ABSENT_PARAMS: &dyn SignatureVerificationAlgorithm = + &RingAlgorithm { + public_key_alg_id: alg_id::RSA_ENCRYPTION, + signature_alg_id: alg_id::AlgorithmIdentifier::from_slice(include_bytes!( + "data/alg-rsa-pkcs1-sha256-absent-params.der" + )), + verification_alg: &signature::RSA_PKCS1_2048_8192_SHA256, + }; + +/// RSA PKCS#1 1.5 signatures using SHA-384 for keys of 2048-8192 bits, +/// with illegally absent AlgorithmIdentifier parameters. +/// +/// RFC4055 says on sha256WithRSAEncryption and company: +/// +/// > When any of these four object identifiers appears within an +/// > AlgorithmIdentifier, the parameters MUST be NULL. Implementations +/// > MUST accept the parameters being absent as well as present. +/// +/// This algorithm covers the absent case, [`RSA_PKCS1_2048_8192_SHA384`] covers +/// the present case. +#[cfg(feature = "alloc")] +pub static RSA_PKCS1_2048_8192_SHA384_ABSENT_PARAMS: &dyn SignatureVerificationAlgorithm = + &RingAlgorithm { + public_key_alg_id: alg_id::RSA_ENCRYPTION, + signature_alg_id: alg_id::AlgorithmIdentifier::from_slice(include_bytes!( + "data/alg-rsa-pkcs1-sha384-absent-params.der" + )), + verification_alg: &signature::RSA_PKCS1_2048_8192_SHA384, + }; + +/// RSA PKCS#1 1.5 signatures using SHA-512 for keys of 2048-8192 bits, +/// with illegally absent AlgorithmIdentifier parameters. +/// +/// RFC4055 says on sha256WithRSAEncryption and company: +/// +/// > When any of these four object identifiers appears within an +/// > AlgorithmIdentifier, the parameters MUST be NULL. Implementations +/// > MUST accept the parameters being absent as well as present. +/// +/// This algorithm covers the absent case, [`RSA_PKCS1_2048_8192_SHA512`] covers +/// the present case. +#[cfg(feature = "alloc")] +pub static RSA_PKCS1_2048_8192_SHA512_ABSENT_PARAMS: &dyn SignatureVerificationAlgorithm = + &RingAlgorithm { + public_key_alg_id: alg_id::RSA_ENCRYPTION, + signature_alg_id: alg_id::AlgorithmIdentifier::from_slice(include_bytes!( + "data/alg-rsa-pkcs1-sha512-absent-params.der" + )), + verification_alg: &signature::RSA_PKCS1_2048_8192_SHA512, + }; + +/// RSA PKCS#1 1.5 signatures using SHA-384 for keys of 3072-8192 bits. +#[cfg(feature = "alloc")] +pub static RSA_PKCS1_3072_8192_SHA384: &dyn SignatureVerificationAlgorithm = &RingAlgorithm { + public_key_alg_id: alg_id::RSA_ENCRYPTION, + signature_alg_id: alg_id::RSA_PKCS1_SHA384, + verification_alg: &signature::RSA_PKCS1_3072_8192_SHA384, +}; + +/// RSA PSS signatures using SHA-256 for keys of 2048-8192 bits and of +/// type rsaEncryption; see [RFC 4055 Section 1.2]. +/// +/// [RFC 4055 Section 1.2]: https://tools.ietf.org/html/rfc4055#section-1.2 +#[cfg(feature = "alloc")] +pub static RSA_PSS_2048_8192_SHA256_LEGACY_KEY: &dyn SignatureVerificationAlgorithm = + &RingAlgorithm { + public_key_alg_id: alg_id::RSA_ENCRYPTION, + signature_alg_id: alg_id::RSA_PSS_SHA256, + verification_alg: &signature::RSA_PSS_2048_8192_SHA256, + }; + +/// RSA PSS signatures using SHA-384 for keys of 2048-8192 bits and of +/// type rsaEncryption; see [RFC 4055 Section 1.2]. +/// +/// [RFC 4055 Section 1.2]: https://tools.ietf.org/html/rfc4055#section-1.2 +#[cfg(feature = "alloc")] +pub static RSA_PSS_2048_8192_SHA384_LEGACY_KEY: &dyn SignatureVerificationAlgorithm = + &RingAlgorithm { + public_key_alg_id: alg_id::RSA_ENCRYPTION, + signature_alg_id: alg_id::RSA_PSS_SHA384, + verification_alg: &signature::RSA_PSS_2048_8192_SHA384, + }; + +/// RSA PSS signatures using SHA-512 for keys of 2048-8192 bits and of +/// type rsaEncryption; see [RFC 4055 Section 1.2]. +/// +/// [RFC 4055 Section 1.2]: https://tools.ietf.org/html/rfc4055#section-1.2 +#[cfg(feature = "alloc")] +pub static RSA_PSS_2048_8192_SHA512_LEGACY_KEY: &dyn SignatureVerificationAlgorithm = + &RingAlgorithm { + public_key_alg_id: alg_id::RSA_ENCRYPTION, + signature_alg_id: alg_id::RSA_PSS_SHA512, + verification_alg: &signature::RSA_PSS_2048_8192_SHA512, + }; + +/// ED25519 signatures according to RFC 8410 +pub static ED25519: &dyn SignatureVerificationAlgorithm = &RingAlgorithm { + public_key_alg_id: alg_id::ED25519, + signature_alg_id: alg_id::ED25519, + verification_alg: &signature::ED25519, +}; + +#[cfg(test)] +#[path = "."] +mod tests { + #[cfg(feature = "alloc")] + use crate::error::UnsupportedSignatureAlgorithmForPublicKeyContext; + use crate::error::{Error, UnsupportedSignatureAlgorithmContext}; + + static SUPPORTED_ALGORITHMS_IN_TESTS: &[&dyn super::SignatureVerificationAlgorithm] = &[ + // Reasonable algorithms. + super::ECDSA_P256_SHA256, + super::ECDSA_P384_SHA384, + super::ED25519, + #[cfg(feature = "alloc")] + super::RSA_PKCS1_2048_8192_SHA256, + #[cfg(feature = "alloc")] + super::RSA_PKCS1_2048_8192_SHA384, + #[cfg(feature = "alloc")] + super::RSA_PKCS1_2048_8192_SHA512, + #[cfg(feature = "alloc")] + super::RSA_PKCS1_3072_8192_SHA384, + #[cfg(feature = "alloc")] + super::RSA_PSS_2048_8192_SHA256_LEGACY_KEY, + #[cfg(feature = "alloc")] + super::RSA_PSS_2048_8192_SHA384_LEGACY_KEY, + #[cfg(feature = "alloc")] + super::RSA_PSS_2048_8192_SHA512_LEGACY_KEY, + // Algorithms deprecated because they are nonsensical combinations. + super::ECDSA_P256_SHA384, // Truncates digest. + super::ECDSA_P384_SHA256, // Digest is unnecessarily short. + ]; + + const OK_IF_POINT_COMPRESSION_SUPPORTED: Result<(), Error> = + Err(Error::InvalidSignatureForPublicKey); + + #[path = "alg_tests.rs"] + mod alg_tests; + + fn maybe_rsa() -> Result<(), Error> { + #[cfg(feature = "alloc")] + { + Ok(()) + } + #[cfg(not(feature = "alloc"))] + { + Err(unsupported(&[])) + } + } + + fn unsupported_for_rsa(sig_alg_id: &[u8], _public_key_alg_id: &[u8]) -> Error { + #[cfg(feature = "alloc")] + { + Error::UnsupportedSignatureAlgorithmForPublicKeyContext( + UnsupportedSignatureAlgorithmForPublicKeyContext { + signature_algorithm_id: sig_alg_id.to_vec(), + public_key_algorithm_id: _public_key_alg_id.to_vec(), + }, + ) + } + #[cfg(not(feature = "alloc"))] + { + unsupported(sig_alg_id) + } + } + + fn invalid_rsa_signature() -> Error { + #[cfg(feature = "alloc")] + { + Error::InvalidSignatureForPublicKey + } + #[cfg(not(feature = "alloc"))] + { + unsupported(&[]) + } + } + + fn unsupported_for_ecdsa(sig_alg_id: &[u8], _public_key_alg_id: &[u8]) -> Error { + unsupported(sig_alg_id) + } + + fn unsupported(_sig_alg_id: &[u8]) -> Error { + Error::UnsupportedSignatureAlgorithmContext(UnsupportedSignatureAlgorithmContext { + #[cfg(feature = "alloc")] + signature_algorithm_id: _sig_alg_id.to_vec(), + #[cfg(feature = "alloc")] + supported_algorithms: SUPPORTED_ALGORITHMS_IN_TESTS + .iter() + .map(|&alg| alg.signature_alg_id()) + .collect(), + }) + } +} diff --git a/http/vendor/rustls-webpki/src/rpk_entity.rs b/http/vendor/rustls-webpki/src/rpk_entity.rs new file mode 100644 index 0000000..4b41100 --- /dev/null +++ b/http/vendor/rustls-webpki/src/rpk_entity.rs @@ -0,0 +1,84 @@ +use crate::error::Error; +use crate::signed_data::SubjectPublicKeyInfo; +use crate::{DerTypeId, der, signed_data}; +use pki_types::{SignatureVerificationAlgorithm, SubjectPublicKeyInfoDer}; + +/// A Raw Public Key, used for connections using raw public keys as specified +/// in [RFC 7250](https://www.rfc-editor.org/rfc/rfc7250). +#[derive(Debug)] +pub struct RawPublicKeyEntity<'a> { + inner: untrusted::Input<'a>, +} + +impl<'a> TryFrom<&'a SubjectPublicKeyInfoDer<'a>> for RawPublicKeyEntity<'a> { + type Error = Error; + + /// Parse the ASN.1 DER-encoded SPKI encoding of the raw public key `spki`. + /// Since we are parsing a raw public key, we first strip the outer sequence tag. + fn try_from(spki: &'a SubjectPublicKeyInfoDer<'a>) -> Result { + let input = untrusted::Input::from(spki.as_ref()); + let spki = input.read_all( + Error::TrailingData(DerTypeId::SubjectPublicKeyInfo), + |reader| { + let untagged_spki = der::expect_tag(reader, der::Tag::Sequence)?; + der::read_all::>(untagged_spki)?; + Ok(untagged_spki) + }, + )?; + Ok(Self { inner: spki }) + } +} + +impl RawPublicKeyEntity<'_> { + /// Verifies the signature `signature` of message `msg` using a raw public key, + /// supporting RFC 7250. + /// + /// For more information on `signature_alg` and `signature` see the documentation for [`crate::end_entity::EndEntityCert::verify_signature`]. + pub fn verify_signature( + &self, + signature_alg: &dyn SignatureVerificationAlgorithm, + msg: &[u8], + signature: &[u8], + ) -> Result<(), Error> { + signed_data::verify_signature( + signature_alg, + self.inner, + untrusted::Input::from(msg), + untrusted::Input::from(signature), + ) + } +} + +#[cfg(feature = "alloc")] +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_ee_read_for_rpk() { + // Try to read an end entity certificate into a RawPublicKeyEntity. + // It will fail to parse the key value since we expect no unused bits. + let ee = include_bytes!("../tests/ed25519/ee.der"); + let ee_der = SubjectPublicKeyInfoDer::from(ee.as_slice()); + assert_eq!( + RawPublicKeyEntity::try_from(&ee_der).expect_err("unexpectedly parsed certificate"), + Error::TrailingData(DerTypeId::BitString) + ); + } + + #[test] + fn test_spki_read_for_rpk() { + let pubkey = include_bytes!("../tests/ed25519/ee-pubkey.der"); + let spki_der = SubjectPublicKeyInfoDer::from(pubkey.as_slice()); + let rpk = RawPublicKeyEntity::try_from(&spki_der).expect("failed to parse rpk"); + + // Retrieved the SPKI from the pubkey.der using the following commands (as in [`cert::test_spki_read`]): + // xxd -plain -cols 1 tests/ed255519/ee-pubkey.der + let expected_spki = [ + 0x30, 0x05, 0x06, 0x03, 0x2b, 0x65, 0x70, 0x03, 0x21, 0x00, 0xfe, 0x5a, 0x1e, 0x36, + 0x6c, 0x17, 0x27, 0x5b, 0xf1, 0x58, 0x1e, 0x3a, 0x0e, 0xe6, 0x56, 0x29, 0x8d, 0x9e, + 0x1b, 0x3f, 0xd3, 0x3f, 0x96, 0x46, 0xef, 0xbf, 0x04, 0x6b, 0xc7, 0x3d, 0x47, 0x5c, + ]; + assert_eq!(expected_spki, rpk.inner.as_slice_less_safe()) + } +} diff --git a/http/vendor/rustls-webpki/src/signed_data.rs b/http/vendor/rustls-webpki/src/signed_data.rs new file mode 100644 index 0000000..1367d23 --- /dev/null +++ b/http/vendor/rustls-webpki/src/signed_data.rs @@ -0,0 +1,269 @@ +// Copyright 2015 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use crate::der::{self, FromDer}; +use crate::error::{ + DerTypeId, Error, UnsupportedSignatureAlgorithmContext, + UnsupportedSignatureAlgorithmForPublicKeyContext, +}; +use crate::verify_cert::Budget; + +use pki_types::SignatureVerificationAlgorithm; + +#[cfg(feature = "alloc")] +use alloc::vec::Vec; + +/// X.509 certificates and related items that are signed are almost always +/// encoded in the format "tbs||signatureAlgorithm||signature". This structure +/// captures this pattern as an owned data type. +#[cfg(feature = "alloc")] +#[derive(Clone, Debug)] +pub(crate) struct OwnedSignedData { + /// The signed data. This would be `tbsCertificate` in the case of an X.509 + /// certificate, `tbsResponseData` in the case of an OCSP response, `tbsCertList` + /// in the case of a CRL, and the data nested in the `digitally-signed` construct for + /// TLS 1.2 signed data. + pub(crate) data: Vec, + + /// The value of the `AlgorithmIdentifier`. This would be + /// `signatureAlgorithm` in the case of an X.509 certificate, OCSP + /// response or CRL. This would have to be synthesized in the case of TLS 1.2 + /// signed data, since TLS does not identify algorithms by ASN.1 OIDs. + pub(crate) algorithm: Vec, + + /// The value of the signature. This would be `signature` in an X.509 + /// certificate, OCSP response or CRL. This would be the value of + /// `DigitallySigned.signature` for TLS 1.2 signed data. + pub(crate) signature: Vec, +} + +#[cfg(feature = "alloc")] +impl OwnedSignedData { + /// Return a borrowed [`SignedData`] from the owned representation. + pub(crate) fn borrow(&self) -> SignedData<'_> { + SignedData { + data: untrusted::Input::from(&self.data), + algorithm: untrusted::Input::from(&self.algorithm), + signature: untrusted::Input::from(&self.signature), + } + } +} + +/// X.509 certificates and related items that are signed are almost always +/// encoded in the format "tbs||signatureAlgorithm||signature". This structure +/// captures this pattern. +#[derive(Debug)] +pub(crate) struct SignedData<'a> { + /// The signed data. This would be `tbsCertificate` in the case of an X.509 + /// certificate, `tbsResponseData` in the case of an OCSP response, `tbsCertList` + /// in the case of a CRL, and the data nested in the `digitally-signed` construct for + /// TLS 1.2 signed data. + pub(crate) data: untrusted::Input<'a>, + + /// The value of the `AlgorithmIdentifier`. This would be + /// `signatureAlgorithm` in the case of an X.509 certificate, OCSP + /// response or CRL. This would have to be synthesized in the case of TLS 1.2 + /// signed data, since TLS does not identify algorithms by ASN.1 OIDs. + pub(crate) algorithm: untrusted::Input<'a>, + + /// The value of the signature. This would be `signature` in an X.509 + /// certificate, OCSP response or CRL. This would be the value of + /// `DigitallySigned.signature` for TLS 1.2 signed data. + pub(crate) signature: untrusted::Input<'a>, +} + +impl<'a> SignedData<'a> { + /// Parses the concatenation of "tbs||signatureAlgorithm||signature" that + /// is common in the X.509 certificate and OCSP response syntaxes. + /// + /// X.509 Certificates (RFC 5280) look like this: + /// + /// ```ASN.1 + /// Certificate (SEQUENCE) { + /// tbsCertificate TBSCertificate, + /// signatureAlgorithm AlgorithmIdentifier, + /// signatureValue BIT STRING + /// } + /// ``` + /// + /// OCSP responses (RFC 6960) look like this: + /// ```ASN.1 + /// BasicOCSPResponse { + /// tbsResponseData ResponseData, + /// signatureAlgorithm AlgorithmIdentifier, + /// signature BIT STRING, + /// certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL + /// } + /// ``` + /// + /// Note that this function does NOT parse the outermost `SEQUENCE` or the + /// `certs` value. + /// + /// The return value's first component is the contents of + /// `tbsCertificate`/`tbsResponseData`; the second component is a `SignedData` + /// structure that can be passed to `verify_signed_data`. + /// + /// The provided size_limit will enforce the largest possible outermost `SEQUENCE` this + /// function will read. + pub(crate) fn from_der( + der: &mut untrusted::Reader<'a>, + size_limit: usize, + ) -> Result<(untrusted::Input<'a>, Self), Error> { + let (data, tbs) = der.read_partial(|input| { + der::expect_tag_and_get_value_limited(input, der::Tag::Sequence, size_limit) + })?; + let algorithm = der::expect_tag(der, der::Tag::Sequence)?; + let signature = der::bit_string_with_no_unused_bits(der)?; + + Ok(( + tbs, + SignedData { + data, + algorithm, + signature, + }, + )) + } + + /// Convert the borrowed signed data to an [`OwnedSignedData`]. + #[cfg(feature = "alloc")] + pub(crate) fn to_owned(&self) -> OwnedSignedData { + OwnedSignedData { + data: self.data.as_slice_less_safe().to_vec(), + algorithm: self.algorithm.as_slice_less_safe().to_vec(), + signature: self.signature.as_slice_less_safe().to_vec(), + } + } +} + +/// Verify `signed_data` using the public key in the DER-encoded +/// SubjectPublicKeyInfo `spki` using one of the algorithms in +/// `supported_algorithms`. +/// +/// The algorithm is chosen based on the algorithm information encoded in the +/// algorithm identifiers in `public_key` and `signed_data.algorithm`. The +/// ordering of the algorithms in `supported_algorithms` does not really matter, +/// but generally more common algorithms should go first, as it is scanned +/// linearly for matches. +pub(crate) fn verify_signed_data( + supported_algorithms: &[&dyn SignatureVerificationAlgorithm], + spki_value: untrusted::Input<'_>, + signed_data: &SignedData<'_>, + budget: &mut Budget, +) -> Result<(), Error> { + budget.consume_signature()?; + + // We need to verify the signature in `signed_data` using the public key + // in `public_key`. In order to know which *ring* signature verification + // algorithm to use, we need to know the public key algorithm (ECDSA, + // RSA PKCS#1, etc.), the curve (if applicable), and the digest algorithm. + // `signed_data` identifies only the public key algorithm and the digest + // algorithm, and `public_key` identifies only the public key algorithm and + // the curve (if any). Thus, we have to combine information from both + // inputs to figure out which `ring::signature::VerificationAlgorithm` to + // use to verify the signature. + // + // This is all further complicated by the fact that we don't have any + // implicit knowledge about any algorithms or identifiers, since all of + // that information is encoded in `supported_algorithms.` In particular, we + // avoid hard-coding any of that information so that (link-time) dead code + // elimination will work effectively in eliminating code for unused + // algorithms. + + // Parse the signature. + // + let mut invalid_for_public_key = None; + for supported_alg in supported_algorithms + .iter() + .filter(|alg| alg.signature_alg_id().as_ref() == signed_data.algorithm.as_slice_less_safe()) + { + match verify_signature( + *supported_alg, + spki_value, + signed_data.data, + signed_data.signature, + ) { + Err(Error::UnsupportedSignatureAlgorithmForPublicKeyContext(cx)) => { + invalid_for_public_key = Some(cx); + continue; + } + result => return result, + } + } + + if let Some(cx) = invalid_for_public_key { + return Err(Error::UnsupportedSignatureAlgorithmForPublicKeyContext(cx)); + } + + Err(Error::UnsupportedSignatureAlgorithmContext( + UnsupportedSignatureAlgorithmContext { + #[cfg(feature = "alloc")] + signature_algorithm_id: signed_data.algorithm.as_slice_less_safe().to_vec(), + #[cfg(feature = "alloc")] + supported_algorithms: supported_algorithms + .iter() + .map(|&alg| alg.signature_alg_id()) + .collect(), + }, + )) +} + +pub(crate) fn verify_signature( + signature_alg: &dyn SignatureVerificationAlgorithm, + spki_value: untrusted::Input<'_>, + msg: untrusted::Input<'_>, + signature: untrusted::Input<'_>, +) -> Result<(), Error> { + let spki = der::read_all::>(spki_value)?; + if signature_alg.public_key_alg_id().as_ref() != spki.algorithm_id_value.as_slice_less_safe() { + return Err(Error::UnsupportedSignatureAlgorithmForPublicKeyContext( + UnsupportedSignatureAlgorithmForPublicKeyContext { + #[cfg(feature = "alloc")] + signature_algorithm_id: signature_alg.signature_alg_id().as_ref().to_vec(), + #[cfg(feature = "alloc")] + public_key_algorithm_id: spki.algorithm_id_value.as_slice_less_safe().to_vec(), + }, + )); + } + + signature_alg + .verify_signature( + spki.key_value.as_slice_less_safe(), + msg.as_slice_less_safe(), + signature.as_slice_less_safe(), + ) + .map_err(|_| Error::InvalidSignatureForPublicKey) +} + +pub(crate) struct SubjectPublicKeyInfo<'a> { + algorithm_id_value: untrusted::Input<'a>, + key_value: untrusted::Input<'a>, +} + +impl<'a> FromDer<'a> for SubjectPublicKeyInfo<'a> { + // Parse the public key into an algorithm OID, an optional curve OID, and the + // key value. The caller needs to check whether these match the + // `PublicKeyAlgorithm` for the `SignatureVerificationAlgorithm` that is matched when + // parsing the signature. + fn from_der(reader: &mut untrusted::Reader<'a>) -> Result { + let algorithm_id_value = der::expect_tag(reader, der::Tag::Sequence)?; + let key_value = der::bit_string_with_no_unused_bits(reader)?; + Ok(SubjectPublicKeyInfo { + algorithm_id_value, + key_value, + }) + } + + const TYPE_ID: DerTypeId = DerTypeId::SubjectPublicKeyInfo; +} diff --git a/http/vendor/rustls-webpki/src/subject_name/dns_name.rs b/http/vendor/rustls-webpki/src/subject_name/dns_name.rs new file mode 100644 index 0000000..634dab2 --- /dev/null +++ b/http/vendor/rustls-webpki/src/subject_name/dns_name.rs @@ -0,0 +1,1059 @@ +// Copyright 2015-2020 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#[cfg(feature = "alloc")] +use alloc::format; +use core::fmt::Write; + +#[cfg(feature = "alloc")] +use pki_types::ServerName; +use pki_types::{DnsName, InvalidDnsNameError}; + +use super::{GeneralName, NameIterator}; +use crate::cert::Cert; +use crate::error::{Error, InvalidNameContext}; +use crate::subject_name::Subtrees; + +pub(crate) fn verify_dns_names(reference: &DnsName<'_>, cert: &Cert<'_>) -> Result<(), Error> { + let dns_name = untrusted::Input::from(reference.as_ref().as_bytes()); + let result = NameIterator::new(cert.subject_alt_name).find_map(|result| { + let name = match result { + Ok(name) => name, + Err(err) => return Some(Err(err)), + }; + + let presented_id = match name { + GeneralName::DnsName(presented) => presented, + _ => return None, + }; + + match presented_id_matches_reference_id(presented_id, IdRole::Reference, dns_name) { + Ok(true) => Some(Ok(())), + Ok(false) | Err(Error::MalformedDnsIdentifier) => None, + Err(e) => Some(Err(e)), + } + }); + + match result { + Some(result) => return result, + #[cfg(feature = "alloc")] + None => {} + #[cfg(not(feature = "alloc"))] + None => Err(Error::CertNotValidForName(InvalidNameContext {})), + } + + // Try to yield a more useful error. To avoid allocating on the happy path, + // we reconstruct the same `NameIterator` and replay it. + #[cfg(feature = "alloc")] + { + Err(Error::CertNotValidForName(InvalidNameContext { + expected: ServerName::DnsName(reference.to_owned()), + presented: NameIterator::new(cert.subject_alt_name) + .filter_map(|result| Some(format!("{:?}", result.ok()?))) + .collect(), + })) + } +} + +/// A reference to a DNS Name presented by a server that may include a wildcard. +/// +/// A `WildcardDnsNameRef` is guaranteed to be syntactically valid. The validity rules +/// are specified in [RFC 5280 Section 7.2], except that underscores are also +/// allowed. +/// +/// Additionally, while [RFC6125 Section 4.1] says that a wildcard label may be of the form +/// `*.`, where `` and/or `` may be empty, we follow a stricter policy common +/// to most validation libraries (e.g. NSS) and only accept wildcard labels that are exactly `*`. +/// +/// [RFC 5280 Section 7.2]: https://tools.ietf.org/html/rfc5280#section-7.2 +/// [RFC 6125 Section 4.1]: https://www.rfc-editor.org/rfc/rfc6125#section-4.1 +#[derive(Clone, Copy, Eq, PartialEq, Hash)] +pub(crate) struct WildcardDnsNameRef<'a>(&'a [u8]); + +impl<'a> WildcardDnsNameRef<'a> { + /// Constructs a `WildcardDnsNameRef` from the given input if the input is a + /// syntactically-valid DNS name. + pub(crate) fn try_from_ascii(dns_name: &'a [u8]) -> Result { + if !is_valid_dns_id( + untrusted::Input::from(dns_name), + IdRole::Reference, + Wildcards::Allow, + ) { + return Err(InvalidDnsNameError); + } + + Ok(Self(dns_name)) + } + + /// Yields a reference to the DNS name as a `&str`. + pub(crate) fn as_str(&self) -> &'a str { + // The unwrap won't fail because a `WildcardDnsNameRef` is guaranteed to be ASCII and + // ASCII is a subset of UTF-8. + core::str::from_utf8(self.0).unwrap() + } +} + +impl core::fmt::Debug for WildcardDnsNameRef<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> { + f.write_str("WildcardDnsNameRef(\"")?; + + // Convert each byte of the underlying ASCII string to a `char` and + // downcase it prior to formatting it. We avoid self.to_owned() since + // it requires allocation. + for &ch in self.0 { + f.write_char(char::from(ch).to_ascii_lowercase())?; + } + + f.write_str("\")") + } +} + +// We assume that both presented_dns_id and reference_dns_id are encoded in +// such a way that US-ASCII (7-bit) characters are encoded in one byte and no +// encoding of a non-US-ASCII character contains a code point in the range +// 0-127. For example, UTF-8 is OK but UTF-16 is not. +// +// RFC6125 says that a wildcard label may be of the form *., where +// and/or may be empty. However, NSS requires to be empty, and we +// follow NSS's stricter policy by accepting wildcards only of the form +// *., where may be empty. +// +// An relative presented DNS ID matches both an absolute reference ID and a +// relative reference ID. Absolute presented DNS IDs are not supported: +// +// Presented ID Reference ID Result +// ------------------------------------- +// example.com example.com Match +// example.com. example.com Mismatch +// example.com example.com. Match +// example.com. example.com. Mismatch +// +// There are more subtleties documented inline in the code. +// +// Name constraints /////////////////////////////////////////////////////////// +// +// This is all RFC 5280 has to say about dNSName constraints: +// +// DNS name restrictions are expressed as host.example.com. Any DNS +// name that can be constructed by simply adding zero or more labels to +// the left-hand side of the name satisfies the name constraint. For +// example, www.host.example.com would satisfy the constraint but +// host1.example.com would not. +// +// This lack of specificity has lead to a lot of uncertainty regarding +// subdomain matching. In particular, the following questions have been +// raised and answered: +// +// Q: Does a presented identifier equal (case insensitive) to the name +// constraint match the constraint? For example, does the presented +// ID "host.example.com" match a "host.example.com" constraint? +// A: Yes. RFC5280 says "by simply adding zero or more labels" and this +// is the case of adding zero labels. +// +// Q: When the name constraint does not start with ".", do subdomain +// presented identifiers match it? For example, does the presented +// ID "www.host.example.com" match a "host.example.com" constraint? +// A: Yes. RFC5280 says "by simply adding zero or more labels" and this +// is the case of adding more than zero labels. The example is the +// one from RFC 5280. +// +// Q: When the name constraint does not start with ".", does a +// non-subdomain prefix match it? For example, does "bigfoo.bar.com" +// match "foo.bar.com"? [4] +// A: No. We interpret RFC 5280's language of "adding zero or more labels" +// to mean that whole labels must be prefixed. +// +// (Note that the above three scenarios are the same as the RFC 6265 +// domain matching rules [0].) +// +// Q: Is a name constraint that starts with "." valid, and if so, what +// semantics does it have? For example, does a presented ID of +// "www.example.com" match a constraint of ".example.com"? Does a +// presented ID of "example.com" match a constraint of ".example.com"? +// A: This implementation, NSS[1], and SChannel[2] all support a +// leading ".", but OpenSSL[3] does not yet. Amongst the +// implementations that support it, a leading "." is legal and means +// the same thing as when the "." is omitted, EXCEPT that a +// presented identifier equal (case insensitive) to the name +// constraint is not matched; i.e. presented dNSName identifiers +// must be subdomains. Some CAs in Mozilla's CA program (e.g. HARICA) +// have name constraints with the leading "." in their root +// certificates. The name constraints imposed on DCISS by Mozilla also +// have the it, so supporting this is a requirement for backward +// compatibility, even if it is not yet standardized. So, for example, a +// presented ID of "www.example.com" matches a constraint of +// ".example.com" but a presented ID of "example.com" does not. +// +// Q: Is there a way to prevent subdomain matches? +// A: Yes. +// +// Some people have proposed that dNSName constraints that do not +// start with a "." should be restricted to exact (case insensitive) +// matches. However, such a change of semantics from what RFC5280 +// specifies would be a non-backward-compatible change in the case of +// permittedSubtrees constraints, and it would be a security issue for +// excludedSubtrees constraints. +// +// However, it can be done with a combination of permittedSubtrees and +// excludedSubtrees, e.g. "example.com" in permittedSubtrees and +// ".example.com" in excludedSubtrees. +// +// Q: Are name constraints allowed to be specified as absolute names? +// For example, does a presented ID of "example.com" match a name +// constraint of "example.com." and vice versa. +// A: Absolute names are not supported as presented IDs or name +// constraints. Only reference IDs may be absolute. +// +// Q: Is "" a valid dNSName constraint? If so, what does it mean? +// A: Yes. Any valid presented dNSName can be formed "by simply adding zero +// or more labels to the left-hand side" of "". In particular, an +// excludedSubtrees dNSName constraint of "" forbids all dNSNames. +// +// Q: Is "." a valid dNSName constraint? If so, what does it mean? +// A: No, because absolute names are not allowed (see above). +// +// [0] RFC 6265 (Cookies) Domain Matching rules: +// http://tools.ietf.org/html/rfc6265#section-5.1.3 +// [1] NSS source code: +// https://mxr.mozilla.org/nss/source/lib/certdb/genname.c?rev=2a7348f013cb#1209 +// [2] Description of SChannel's behavior from Microsoft: +// http://www.imc.org/ietf-pkix/mail-archive/msg04668.html +// [3] Proposal to add such support to OpenSSL: +// http://www.mail-archive.com/openssl-dev%40openssl.org/msg36204.html +// https://rt.openssl.org/Ticket/Display.html?id=3562 +// [4] Feedback on the lack of clarify in the definition that never got +// incorporated into the spec: +// https://www.ietf.org/mail-archive/web/pkix/current/msg21192.html +pub(super) fn presented_id_matches_reference_id( + presented_dns_id: untrusted::Input<'_>, + reference_dns_id_role: IdRole, + reference_dns_id: untrusted::Input<'_>, +) -> Result { + if !is_valid_dns_id(presented_dns_id, IdRole::Presented, Wildcards::Allow) { + return Err(Error::MalformedDnsIdentifier); + } + + if !is_valid_dns_id(reference_dns_id, reference_dns_id_role, Wildcards::Deny) { + return Err(match reference_dns_id_role { + IdRole::NameConstraint(_) => Error::MalformedNameConstraint, + _ => Error::MalformedDnsIdentifier, + }); + } + + let mut presented = untrusted::Reader::new(presented_dns_id); + let mut reference = untrusted::Reader::new(reference_dns_id); + + match reference_dns_id_role { + IdRole::Reference => (), + + IdRole::NameConstraint(_) if presented_dns_id.len() > reference_dns_id.len() => { + if reference_dns_id.is_empty() { + // An empty constraint matches everything. + return Ok(true); + } + + // If the reference ID starts with a dot then skip the prefix of + // the presented ID and start the comparison at the position of + // that dot. Examples: + // + // Matches Doesn't Match + // ----------------------------------------------------------- + // original presented ID: www.example.com badexample.com + // skipped: www ba + // presented ID w/o prefix: .example.com dexample.com + // reference ID: .example.com .example.com + // + // If the reference ID does not start with a dot then we skip + // the prefix of the presented ID but also verify that the + // prefix ends with a dot. Examples: + // + // Matches Doesn't Match + // ----------------------------------------------------------- + // original presented ID: www.example.com badexample.com + // skipped: www ba + // must be '.': . d + // presented ID w/o prefix: example.com example.com + // reference ID: example.com example.com + // + if reference.peek(b'.') { + if presented + .skip(presented_dns_id.len() - reference_dns_id.len()) + .is_err() + { + unreachable!(); + } + } else { + if presented + .skip(presented_dns_id.len() - reference_dns_id.len() - 1) + .is_err() + { + unreachable!(); + } + if presented.read_byte() != Ok(b'.') { + return Ok(false); + } + } + } + + IdRole::NameConstraint(_) => (), + + IdRole::Presented => unreachable!(), + } + + // Only allow wildcard labels that consist only of '*'. + // + // For permitted subtrees: ignore the wildcard label entirely; a wildcard SAN like + // `*.example.com` can expand to names (like `evil.example.com`) that fall outside the + // permitted subtree, so we must not treat it as contained. + // + // For excluded subtrees: we still expand the wildcard so that a SAN whose expansions could + // reach into an excluded subtree is rejected (see CVE-2025-61727). + if presented.peek(b'*') && reference_dns_id_role != IdRole::NameConstraint(Subtrees::Permitted) + { + if presented.skip(1).is_err() { + unreachable!(); + } + + loop { + if reference.read_byte().is_err() { + return Ok(false); + } + if reference.peek(b'.') { + break; + } + } + } + + loop { + let presented_byte = match (presented.read_byte(), reference.read_byte()) { + (Ok(p), Ok(r)) if ascii_lower(p) == ascii_lower(r) => p, + _ => { + return Ok(false); + } + }; + + if presented.at_end() { + // Don't allow presented IDs to be absolute. + if presented_byte == b'.' { + return Err(Error::MalformedDnsIdentifier); + } + break; + } + } + + // Allow a relative presented DNS ID to match an absolute reference DNS ID, + // unless we're matching a name constraint. + if !reference.at_end() { + if !matches!(reference_dns_id_role, IdRole::NameConstraint(_)) { + match reference.read_byte() { + Ok(b'.') => (), + _ => { + return Ok(false); + } + }; + } + if !reference.at_end() { + return Ok(false); + } + } + + assert!(presented.at_end()); + assert!(reference.at_end()); + + Ok(true) +} + +#[inline] +fn ascii_lower(b: u8) -> u8 { + match b { + b'A'..=b'Z' => b + b'a' - b'A', + _ => b, + } +} + +#[derive(Clone, Copy, PartialEq)] +enum Wildcards { + Deny, + Allow, +} + +#[derive(Clone, Copy, PartialEq)] +pub(super) enum IdRole { + Reference, + Presented, + NameConstraint(Subtrees), +} + +// https://tools.ietf.org/html/rfc5280#section-4.2.1.6: +// +// When the subjectAltName extension contains a domain name system +// label, the domain name MUST be stored in the dNSName (an IA5String). +// The name MUST be in the "preferred name syntax", as specified by +// Section 3.5 of [RFC1034] and as modified by Section 2.1 of +// [RFC1123]. +// +// https://bugzilla.mozilla.org/show_bug.cgi?id=1136616: As an exception to the +// requirement above, underscores are also allowed in names for compatibility. +fn is_valid_dns_id( + hostname: untrusted::Input<'_>, + id_role: IdRole, + allow_wildcards: Wildcards, +) -> bool { + // https://blogs.msdn.microsoft.com/oldnewthing/20120412-00/?p=7873/ + if hostname.len() > 253 { + return false; + } + + let mut input = untrusted::Reader::new(hostname); + + if matches!(id_role, IdRole::NameConstraint(_)) && input.at_end() { + return true; + } + + let mut dot_count = 0; + let mut label_length = 0; + let mut label_is_all_numeric = false; + let mut label_ends_with_hyphen = false; + + // Only presented IDs are allowed to have wildcard labels. And, like + // Chromium, be stricter than RFC 6125 requires by insisting that a + // wildcard label consist only of '*'. + let is_wildcard = allow_wildcards == Wildcards::Allow && input.peek(b'*'); + let mut is_first_byte = !is_wildcard; + if is_wildcard { + if input.read_byte() != Ok(b'*') || input.read_byte() != Ok(b'.') { + return false; + } + dot_count += 1; + } + + loop { + const MAX_LABEL_LENGTH: usize = 63; + + match input.read_byte() { + Ok(b'-') => { + if label_length == 0 { + return false; // Labels must not start with a hyphen. + } + label_is_all_numeric = false; + label_ends_with_hyphen = true; + label_length += 1; + if label_length > MAX_LABEL_LENGTH { + return false; + } + } + + Ok(b'0'..=b'9') => { + if label_length == 0 { + label_is_all_numeric = true; + } + label_ends_with_hyphen = false; + label_length += 1; + if label_length > MAX_LABEL_LENGTH { + return false; + } + } + + Ok(b'a'..=b'z') | Ok(b'A'..=b'Z') | Ok(b'_') => { + label_is_all_numeric = false; + label_ends_with_hyphen = false; + label_length += 1; + if label_length > MAX_LABEL_LENGTH { + return false; + } + } + + Ok(b'.') => { + dot_count += 1; + let name_constrained = matches!(id_role, IdRole::NameConstraint(_)); + if label_length == 0 && (!name_constrained || !is_first_byte) { + return false; + } + if label_ends_with_hyphen { + return false; // Labels must not end with a hyphen. + } + label_length = 0; + } + + _ => { + return false; + } + } + is_first_byte = false; + + if input.at_end() { + break; + } + } + + // Only reference IDs, not presented IDs or name constraints, may be + // absolute. + if label_length == 0 && id_role != IdRole::Reference { + return false; + } + + if label_ends_with_hyphen { + return false; // Labels must not end with a hyphen. + } + + if label_is_all_numeric { + return false; // Last label must not be all numeric. + } + + if is_wildcard { + // If the DNS ID ends with a dot, the last dot signifies an absolute ID. + let label_count = if label_length == 0 { + dot_count + } else { + dot_count + 1 + }; + + // Like NSS, require at least two labels to follow the wildcard label. + // TODO: Allow the TrustDomain to control this on a per-eTLD+1 basis, + // similar to Chromium. Even then, it might be better to still enforce + // that there are at least two labels after the wildcard. + if label_count < 3 { + return false; + } + } + + true +} + +#[cfg(test)] +mod tests { + use super::*; + + #[allow(clippy::type_complexity)] + const PRESENTED_MATCHES_REFERENCE: &[(&[u8], &[u8], Result)] = &[ + (b"", b"a", Err(Error::MalformedDnsIdentifier)), + (b"a", b"a", Ok(true)), + (b"b", b"a", Ok(false)), + (b"*.b.a", b"c.b.a", Ok(true)), + (b"*.b.a", b"b.a", Ok(false)), + (b"*.b.a", b"b.a.", Ok(false)), + // Wildcard not in leftmost label + (b"d.c.b.a", b"d.c.b.a", Ok(true)), + (b"d.*.b.a", b"d.c.b.a", Err(Error::MalformedDnsIdentifier)), + (b"d.c*.b.a", b"d.c.b.a", Err(Error::MalformedDnsIdentifier)), + (b"d.c*.b.a", b"d.cc.b.a", Err(Error::MalformedDnsIdentifier)), + // case sensitivity + ( + b"abcdefghijklmnopqrstuvwxyz", + b"ABCDEFGHIJKLMNOPQRSTUVWXYZ", + Ok(true), + ), + ( + b"ABCDEFGHIJKLMNOPQRSTUVWXYZ", + b"abcdefghijklmnopqrstuvwxyz", + Ok(true), + ), + (b"aBc", b"Abc", Ok(true)), + // digits + (b"a1", b"a1", Ok(true)), + // A trailing dot indicates an absolute name, and absolute names can match + // relative names, and vice-versa. + (b"example", b"example", Ok(true)), + (b"example.", b"example.", Err(Error::MalformedDnsIdentifier)), + (b"example", b"example.", Ok(true)), + (b"example.", b"example", Err(Error::MalformedDnsIdentifier)), + (b"example.com", b"example.com", Ok(true)), + ( + b"example.com.", + b"example.com.", + Err(Error::MalformedDnsIdentifier), + ), + (b"example.com", b"example.com.", Ok(true)), + ( + b"example.com.", + b"example.com", + Err(Error::MalformedDnsIdentifier), + ), + ( + b"example.com..", + b"example.com.", + Err(Error::MalformedDnsIdentifier), + ), + ( + b"example.com..", + b"example.com", + Err(Error::MalformedDnsIdentifier), + ), + ( + b"example.com...", + b"example.com.", + Err(Error::MalformedDnsIdentifier), + ), + // xn-- IDN prefix + (b"x*.b.a", b"xa.b.a", Err(Error::MalformedDnsIdentifier)), + (b"x*.b.a", b"xna.b.a", Err(Error::MalformedDnsIdentifier)), + (b"x*.b.a", b"xn-a.b.a", Err(Error::MalformedDnsIdentifier)), + (b"x*.b.a", b"xn--a.b.a", Err(Error::MalformedDnsIdentifier)), + (b"xn*.b.a", b"xn--a.b.a", Err(Error::MalformedDnsIdentifier)), + ( + b"xn-*.b.a", + b"xn--a.b.a", + Err(Error::MalformedDnsIdentifier), + ), + ( + b"xn--*.b.a", + b"xn--a.b.a", + Err(Error::MalformedDnsIdentifier), + ), + (b"xn*.b.a", b"xn--a.b.a", Err(Error::MalformedDnsIdentifier)), + ( + b"xn-*.b.a", + b"xn--a.b.a", + Err(Error::MalformedDnsIdentifier), + ), + ( + b"xn--*.b.a", + b"xn--a.b.a", + Err(Error::MalformedDnsIdentifier), + ), + ( + b"xn---*.b.a", + b"xn--a.b.a", + Err(Error::MalformedDnsIdentifier), + ), + // "*" cannot expand to nothing. + (b"c*.b.a", b"c.b.a", Err(Error::MalformedDnsIdentifier)), + // -------------------------------------------------------------------------- + // The rest of these are test cases adapted from Chromium's + // x509_certificate_unittest.cc. The parameter order is the opposite in + // Chromium's tests. Also, they Ok tests were modified to fit into this + // framework or due to intentional differences between mozilla::pkix and + // Chromium. + (b"foo.com", b"foo.com", Ok(true)), + (b"f", b"f", Ok(true)), + (b"i", b"h", Ok(false)), + (b"*.foo.com", b"bar.foo.com", Ok(true)), + (b"*.test.fr", b"www.test.fr", Ok(true)), + (b"*.test.FR", b"wwW.tESt.fr", Ok(true)), + (b".uk", b"f.uk", Err(Error::MalformedDnsIdentifier)), + ( + b"?.bar.foo.com", + b"w.bar.foo.com", + Err(Error::MalformedDnsIdentifier), + ), + ( + b"(www|ftp).foo.com", + b"www.foo.com", + Err(Error::MalformedDnsIdentifier), + ), // regex! + ( + b"www.foo.com\0", + b"www.foo.com", + Err(Error::MalformedDnsIdentifier), + ), + ( + b"www.foo.com\0*.foo.com", + b"www.foo.com", + Err(Error::MalformedDnsIdentifier), + ), + (b"ww.house.example", b"www.house.example", Ok(false)), + (b"www.test.org", b"test.org", Ok(false)), + (b"*.test.org", b"test.org", Ok(false)), + (b"*.org", b"test.org", Err(Error::MalformedDnsIdentifier)), + // '*' must be the only character in the wildcard label + ( + b"w*.bar.foo.com", + b"w.bar.foo.com", + Err(Error::MalformedDnsIdentifier), + ), + ( + b"ww*ww.bar.foo.com", + b"www.bar.foo.com", + Err(Error::MalformedDnsIdentifier), + ), + ( + b"ww*ww.bar.foo.com", + b"wwww.bar.foo.com", + Err(Error::MalformedDnsIdentifier), + ), + ( + b"w*w.bar.foo.com", + b"wwww.bar.foo.com", + Err(Error::MalformedDnsIdentifier), + ), + ( + b"w*w.bar.foo.c0m", + b"wwww.bar.foo.com", + Err(Error::MalformedDnsIdentifier), + ), + ( + b"wa*.bar.foo.com", + b"WALLY.bar.foo.com", + Err(Error::MalformedDnsIdentifier), + ), + ( + b"*Ly.bar.foo.com", + b"wally.bar.foo.com", + Err(Error::MalformedDnsIdentifier), + ), + // Chromium does URL decoding of the reference ID, but we don't, and we also + // require that the reference ID is valid, so we can't test these two. + // (b"www.foo.com", b"ww%57.foo.com", Ok(true)), + // (b"www&.foo.com", b"www%26.foo.com", Ok(true)), + (b"*.test.de", b"www.test.co.jp", Ok(false)), + ( + b"*.jp", + b"www.test.co.jp", + Err(Error::MalformedDnsIdentifier), + ), + (b"www.test.co.uk", b"www.test.co.jp", Ok(false)), + ( + b"www.*.co.jp", + b"www.test.co.jp", + Err(Error::MalformedDnsIdentifier), + ), + (b"www.bar.foo.com", b"www.bar.foo.com", Ok(true)), + (b"*.foo.com", b"www.bar.foo.com", Ok(false)), + ( + b"*.*.foo.com", + b"www.bar.foo.com", + Err(Error::MalformedDnsIdentifier), + ), + // Our matcher requires the reference ID to be a valid DNS name, so we cannot + // test this case. + // (b"*.*.bar.foo.com", b"*..bar.foo.com", Ok(false)), + (b"www.bath.org", b"www.bath.org", Ok(true)), + // Our matcher requires the reference ID to be a valid DNS name, so we cannot + // test these cases. + // DNS_ID_MISMATCH("www.bath.org", ""), + // (b"www.bath.org", b"20.30.40.50", Ok(false)), + // (b"www.bath.org", b"66.77.88.99", Ok(false)), + + // IDN tests + ( + b"xn--poema-9qae5a.com.br", + b"xn--poema-9qae5a.com.br", + Ok(true), + ), + ( + b"*.xn--poema-9qae5a.com.br", + b"www.xn--poema-9qae5a.com.br", + Ok(true), + ), + ( + b"*.xn--poema-9qae5a.com.br", + b"xn--poema-9qae5a.com.br", + Ok(false), + ), + ( + b"xn--poema-*.com.br", + b"xn--poema-9qae5a.com.br", + Err(Error::MalformedDnsIdentifier), + ), + ( + b"xn--*-9qae5a.com.br", + b"xn--poema-9qae5a.com.br", + Err(Error::MalformedDnsIdentifier), + ), + ( + b"*--poema-9qae5a.com.br", + b"xn--poema-9qae5a.com.br", + Err(Error::MalformedDnsIdentifier), + ), + // The following are adapted from the examples quoted from + // http://tools.ietf.org/html/rfc6125#section-6.4.3 + // (e.g., *.example.com would match foo.example.com but + // not bar.foo.example.com or example.com). + (b"*.example.com", b"foo.example.com", Ok(true)), + (b"*.example.com", b"bar.foo.example.com", Ok(false)), + (b"*.example.com", b"example.com", Ok(false)), + ( + b"baz*.example.net", + b"baz1.example.net", + Err(Error::MalformedDnsIdentifier), + ), + ( + b"*baz.example.net", + b"foobaz.example.net", + Err(Error::MalformedDnsIdentifier), + ), + ( + b"b*z.example.net", + b"buzz.example.net", + Err(Error::MalformedDnsIdentifier), + ), + // Wildcards should not be valid for public registry controlled domains, + // and unknown/unrecognized domains, at least three domain components must + // be present. For mozilla::pkix and NSS, there must always be at least two + // labels after the wildcard label. + (b"*.test.example", b"www.test.example", Ok(true)), + (b"*.example.co.uk", b"test.example.co.uk", Ok(true)), + ( + b"*.example", + b"test.example", + Err(Error::MalformedDnsIdentifier), + ), + // The result is different than Chromium, because Chromium takes into account + // the additional knowledge it has that "co.uk" is a TLD. mozilla::pkix does + // not know that. + (b"*.co.uk", b"example.co.uk", Ok(true)), + (b"*.com", b"foo.com", Err(Error::MalformedDnsIdentifier)), + (b"*.us", b"foo.us", Err(Error::MalformedDnsIdentifier)), + (b"*", b"foo", Err(Error::MalformedDnsIdentifier)), + // IDN variants of wildcards and registry controlled domains. + ( + b"*.xn--poema-9qae5a.com.br", + b"www.xn--poema-9qae5a.com.br", + Ok(true), + ), + ( + b"*.example.xn--mgbaam7a8h", + b"test.example.xn--mgbaam7a8h", + Ok(true), + ), + // RFC6126 allows this, and NSS accepts it, but Chromium disallows it. + // TODO: File bug against Chromium. + (b"*.com.br", b"xn--poema-9qae5a.com.br", Ok(true)), + ( + b"*.xn--mgbaam7a8h", + b"example.xn--mgbaam7a8h", + Err(Error::MalformedDnsIdentifier), + ), + // Wildcards should be permissible for 'private' registry-controlled + // domains. (In mozilla::pkix, we do not know if it is a private registry- + // controlled domain or not.) + (b"*.appspot.com", b"www.appspot.com", Ok(true)), + (b"*.s3.amazonaws.com", b"foo.s3.amazonaws.com", Ok(true)), + // Multiple wildcards are not valid. + ( + b"*.*.com", + b"foo.example.com", + Err(Error::MalformedDnsIdentifier), + ), + ( + b"*.bar.*.com", + b"foo.bar.example.com", + Err(Error::MalformedDnsIdentifier), + ), + // Absolute vs relative DNS name tests. Although not explicitly specified + // in RFC 6125, absolute reference names (those ending in a .) should + // match either absolute or relative presented names. + // TODO: File errata against RFC 6125 about this. + (b"foo.com.", b"foo.com", Err(Error::MalformedDnsIdentifier)), + (b"foo.com", b"foo.com.", Ok(true)), + (b"foo.com.", b"foo.com.", Err(Error::MalformedDnsIdentifier)), + (b"f.", b"f", Err(Error::MalformedDnsIdentifier)), + (b"f", b"f.", Ok(true)), + (b"f.", b"f.", Err(Error::MalformedDnsIdentifier)), + ( + b"*.bar.foo.com.", + b"www-3.bar.foo.com", + Err(Error::MalformedDnsIdentifier), + ), + (b"*.bar.foo.com", b"www-3.bar.foo.com.", Ok(true)), + ( + b"*.bar.foo.com.", + b"www-3.bar.foo.com.", + Err(Error::MalformedDnsIdentifier), + ), + // We require the reference ID to be a valid DNS name, so we cannot test this + // case. + // (b".", b".", Ok(false)), + ( + b"*.com.", + b"example.com", + Err(Error::MalformedDnsIdentifier), + ), + ( + b"*.com", + b"example.com.", + Err(Error::MalformedDnsIdentifier), + ), + ( + b"*.com.", + b"example.com.", + Err(Error::MalformedDnsIdentifier), + ), + (b"*.", b"foo.", Err(Error::MalformedDnsIdentifier)), + (b"*.", b"foo", Err(Error::MalformedDnsIdentifier)), + // The result is different than Chromium because we don't know that co.uk is + // a TLD. + ( + b"*.co.uk.", + b"foo.co.uk", + Err(Error::MalformedDnsIdentifier), + ), + ( + b"*.co.uk.", + b"foo.co.uk.", + Err(Error::MalformedDnsIdentifier), + ), + ]; + + #[test] + fn presented_matches_reference_test() { + for (presented, reference, expected_result) in PRESENTED_MATCHES_REFERENCE { + let actual_result = presented_id_matches_reference_id( + untrusted::Input::from(presented), + IdRole::Reference, + untrusted::Input::from(reference), + ); + assert_eq!( + &actual_result, expected_result, + "presented_id_matches_reference_id(\"{presented:?}\", \"{reference:?}\")" + ); + } + } + + // (presented_name, constraint, expected_matches) + #[allow(clippy::type_complexity)] + const PRESENTED_MATCHES_CONSTRAINT: &[(&[u8], &[u8], Result)] = &[ + // No absolute presented IDs allowed + (b".", b"", Err(Error::MalformedDnsIdentifier)), + (b"www.example.com.", b"", Err(Error::MalformedDnsIdentifier)), + ( + b"www.example.com.", + b"www.example.com.", + Err(Error::MalformedDnsIdentifier), + ), + // No absolute constraints allowed + ( + b"www.example.com", + b".", + Err(Error::MalformedNameConstraint), + ), + ( + b"www.example.com", + b"www.example.com.", + Err(Error::MalformedNameConstraint), + ), + // No wildcard in constraints allowed + ( + b"www.example.com", + b"*.example.com", + Err(Error::MalformedNameConstraint), + ), + // No empty presented IDs allowed + (b"", b"", Err(Error::MalformedDnsIdentifier)), + // Empty constraints match everything allowed + (b"example.com", b"", Ok(true)), + (b"*.example.com", b"", Ok(true)), + // Constraints that start with a dot + (b"www.example.com", b".example.com", Ok(true)), + (b"www.example.com", b".EXAMPLE.COM", Ok(true)), + (b"www.example.com", b".axample.com", Ok(false)), + (b"www.example.com", b".xample.com", Ok(false)), + (b"www.example.com", b".exampl.com", Ok(false)), + (b"badexample.com", b".example.com", Ok(false)), + // Constraints that do not start with a dot + (b"www.example.com", b"example.com", Ok(true)), + (b"www.example.com", b"EXAMPLE.COM", Ok(true)), + (b"www.example.com", b"axample.com", Ok(false)), + (b"www.example.com", b"xample.com", Ok(false)), + (b"www.example.com", b"exampl.com", Ok(false)), + (b"badexample.com", b"example.com", Ok(false)), + // Presented IDs with wildcard + (b"*.example.com", b".example.com", Ok(true)), + (b"*.example.com", b"example.com", Ok(true)), + // `*.example.com` expands to names like `evil.example.com` that are + // outside the subtree `www.example.com`, so it is not contained. + (b"*.example.com", b"www.example.com", Ok(false)), + (b"*.example.com", b"www.EXAMPLE.COM", Ok(false)), + (b"*.example.com", b"www.axample.com", Ok(false)), + (b"*.example.com", b".xample.com", Ok(false)), + (b"*.example.com", b"xample.com", Ok(false)), + (b"*.example.com", b".exampl.com", Ok(false)), + (b"*.example.com", b"exampl.com", Ok(false)), + // Matching IDs + (b"www.example.com", b"www.example.com", Ok(true)), + ]; + + #[test] + fn presented_matches_constraint_test() { + for (presented, constraint, expected_result) in PRESENTED_MATCHES_CONSTRAINT { + let actual_result = presented_id_matches_reference_id( + untrusted::Input::from(presented), + IdRole::NameConstraint(Subtrees::Permitted), + untrusted::Input::from(constraint), + ); + assert_eq!( + &actual_result, expected_result, + "presented_id_matches_constraint(\"{presented:?}\", \"{constraint:?}\")", + ); + } + } + + #[test] + fn wildcard_san_not_contained_in_constraint() { + for (presented, constraint, expected_result) in WILDCARD_CONSTRAINT_CONTAINMENT { + let actual_result = presented_id_matches_reference_id( + untrusted::Input::from(presented), + IdRole::NameConstraint(Subtrees::Permitted), + untrusted::Input::from(constraint), + ); + assert_eq!( + &actual_result, expected_result, + "presented_id_matches_constraint(\"{presented:?}\", \"{constraint:?}\")", + ); + } + } + + // Per RFC 5280 4.2.1.10, a permitted dNSName subtree `www.example.com` + // covers only names formed by prepending labels to `www.example.com`. + // A wildcard SAN `*.example.com` can expand to e.g. `evil.example.com`, + // which is outside that subtree, so it must not be considered contained. + // In contrast, `*.www.example.com` only expands to names inside the + // subtree and is correctly accepted. + #[expect(clippy::type_complexity)] + const WILDCARD_CONSTRAINT_CONTAINMENT: &[(&[u8], &[u8], Result)] = &[ + // Bug: `*.example.com` is broader than the permitted subtree + // `www.example.com` and must not satisfy the constraint. + (b"*.example.com", b"www.example.com", Ok(false)), + // Control: `*.www.example.com` stays within the subtree. + (b"*.www.example.com", b"www.example.com", Ok(true)), + // Further out-of-subtree wildcard SANs that must be rejected. + (b"*.example.com", b"a.b.example.com", Ok(false)), + (b"*.b.example.com", b"a.b.example.com", Ok(false)), + ]; + + // For excluded subtrees, a wildcard SAN must be treated as matching if + // any of its expansions could fall inside the excluded subtree + // (CVE-2025-61727). This is the opposite polarity from the containment + // test used for permitted subtrees. + #[test] + fn wildcard_san_could_match_excluded_subtree() { + for (presented, constraint, expected_result) in WILDCARD_EXCLUDED_INTERSECTION { + let actual_result = presented_id_matches_reference_id( + untrusted::Input::from(presented), + IdRole::NameConstraint(Subtrees::Excluded), + untrusted::Input::from(constraint), + ); + assert_eq!( + &actual_result, expected_result, + "presented_id_matches_constraint(\"{presented:?}\", \"{constraint:?}\")", + ); + } + } + + #[expect(clippy::type_complexity)] + const WILDCARD_EXCLUDED_INTERSECTION: &[(&[u8], &[u8], Result)] = &[ + // All expansions of `*.example.com` fall under the excluded subtree. + (b"*.example.com", b"example.com", Ok(true)), + (b"*.example.com", b".example.com", Ok(true)), + // `*.example.com` can expand to `www.example.com`, which is inside + // the excluded subtree rooted at `www.example.com`. + (b"*.example.com", b"www.example.com", Ok(true)), + (b"*.example.com", b"www.EXAMPLE.COM", Ok(true)), + // The wildcard cannot reach two labels deep, so it does not + // intersect a more specific excluded subtree. + (b"*.example.com", b"a.b.example.com", Ok(false)), + // Disjoint parent labels never intersect. + (b"*.example.com", b"www.other.com", Ok(false)), + ]; +} diff --git a/http/vendor/rustls-webpki/src/subject_name/ip_address.rs b/http/vendor/rustls-webpki/src/subject_name/ip_address.rs new file mode 100644 index 0000000..0c60ac0 --- /dev/null +++ b/http/vendor/rustls-webpki/src/subject_name/ip_address.rs @@ -0,0 +1,706 @@ +// Copyright 2015-2020 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#[cfg(feature = "alloc")] +use alloc::format; + +use pki_types::IpAddr; +#[cfg(feature = "alloc")] +use pki_types::ServerName; + +use super::{GeneralName, NameIterator}; +use crate::cert::Cert; +use crate::error::{Error, InvalidNameContext}; + +pub(crate) fn verify_ip_address_names(reference: &IpAddr, cert: &Cert<'_>) -> Result<(), Error> { + let ip_address = match reference { + IpAddr::V4(ip) => untrusted::Input::from(ip.as_ref()), + IpAddr::V6(ip) => untrusted::Input::from(ip.as_ref()), + }; + + let result = NameIterator::new(cert.subject_alt_name).find_map(|result| { + let name = match result { + Ok(name) => name, + Err(err) => return Some(Err(err)), + }; + + let presented_id = match name { + GeneralName::IpAddress(presented) => presented, + _ => return None, + }; + + match presented_id_matches_reference_id(presented_id, ip_address) { + true => Some(Ok(())), + false => None, + } + }); + + match result { + Some(result) => return result, + #[cfg(feature = "alloc")] + None => {} + #[cfg(not(feature = "alloc"))] + None => Err(Error::CertNotValidForName(InvalidNameContext {})), + } + + #[cfg(feature = "alloc")] + { + Err(Error::CertNotValidForName(InvalidNameContext { + expected: ServerName::from(*reference), + presented: NameIterator::new(cert.subject_alt_name) + .filter_map(|result| Some(format!("{:?}", result.ok()?))) + .collect(), + })) + } +} + +// https://tools.ietf.org/html/rfc5280#section-4.2.1.6 says: +// When the subjectAltName extension contains an iPAddress, the address +// MUST be stored in the octet string in "network byte order", as +// specified in [RFC791]. The least significant bit (LSB) of each octet +// is the LSB of the corresponding byte in the network address. For IP +// version 4, as specified in [RFC791], the octet string MUST contain +// exactly four octets. For IP version 6, as specified in +// [RFC2460], the octet string MUST contain exactly sixteen octets. +fn presented_id_matches_reference_id( + presented_id: untrusted::Input<'_>, + reference_id: untrusted::Input<'_>, +) -> bool { + match (presented_id.len(), reference_id.len()) { + (4, 4) => (), + (16, 16) => (), + _ => { + return false; + } + }; + + let mut presented_ip_address = untrusted::Reader::new(presented_id); + let mut reference_ip_address = untrusted::Reader::new(reference_id); + while !presented_ip_address.at_end() { + let presented_ip_address_byte = presented_ip_address.read_byte().unwrap(); + let reference_ip_address_byte = reference_ip_address.read_byte().unwrap(); + if presented_ip_address_byte != reference_ip_address_byte { + return false; + } + } + + true +} + +// https://tools.ietf.org/html/rfc5280#section-4.2.1.10 says: +// +// For IPv4 addresses, the iPAddress field of GeneralName MUST contain +// eight (8) octets, encoded in the style of RFC 4632 (CIDR) to represent +// an address range [RFC4632]. For IPv6 addresses, the iPAddress field +// MUST contain 32 octets similarly encoded. For example, a name +// constraint for "class C" subnet 192.0.2.0 is represented as the +// octets C0 00 02 00 FF FF FF 00, representing the CIDR notation +// 192.0.2.0/24 (mask 255.255.255.0). +pub(super) fn presented_id_matches_constraint( + name: untrusted::Input<'_>, + constraint: untrusted::Input<'_>, +) -> Result { + match (name.len(), constraint.len()) { + (4, 8) => (), + (16, 32) => (), + + // an IPv4 address never matches an IPv6 constraint, and vice versa. + (4, 32) | (16, 8) => { + return Ok(false); + } + + // invalid constraint length + (4, _) | (16, _) => { + return Err(Error::InvalidNetworkMaskConstraint); + } + + // invalid name length, or anything else + _ => { + return Err(Error::BadDer); + } + }; + + let (constraint_address, constraint_mask) = constraint.read_all(Error::BadDer, |value| { + let address = value.read_bytes(constraint.len() / 2).unwrap(); + let mask = value.read_bytes(constraint.len() / 2).unwrap(); + Ok((address, mask)) + })?; + + let mut name = untrusted::Reader::new(name); + let mut constraint_address = untrusted::Reader::new(constraint_address); + let mut constraint_mask = untrusted::Reader::new(constraint_mask); + let mut seen_zero_bit = false; + + loop { + // Iterate through the name, constraint address, and constraint mask + // a byte at a time. + let name_byte = name.read_byte().unwrap(); + let constraint_address_byte = constraint_address.read_byte().unwrap(); + let constraint_mask_byte = constraint_mask.read_byte().unwrap(); + + // A valid mask consists of a sequence of 1 bits, followed by a + // sequence of 0 bits. Either sequence could be empty. + + let leading = constraint_mask_byte.leading_ones(); + let trailing = constraint_mask_byte.trailing_zeros(); + + // At the resolution of a single octet, a valid mask is one where + // leading_ones() and trailing_zeros() sums to 8. + // This includes all-ones and all-zeroes. + if leading + trailing != 8 { + return Err(Error::InvalidNetworkMaskConstraint); + } + + // There should be no bits set after the first octet with a zero bit is seen. + if seen_zero_bit && constraint_mask_byte != 0x00 { + return Err(Error::InvalidNetworkMaskConstraint); + } + + // Note when a zero bit is seen for later octets. + if constraint_mask_byte != 0xff { + seen_zero_bit = true; + } + + if ((name_byte ^ constraint_address_byte) & constraint_mask_byte) != 0 { + return Ok(false); + } + if name.at_end() { + break; + } + } + + Ok(true) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn presented_id_matches_constraint_ipv4_test() { + let names_and_constraints = vec![ + ( + // 192.0.2.0 matches constraint 192.0.2.0/24 + [0xC0, 0x00, 0x02, 0x00], + [0xC0, 0x00, 0x02, 0x00, 0xFF, 0xFF, 0xFF, 0x00], + Ok(true), + ), + ( + // 192.0.2.1 matches constraint 192.0.2.0/24 + [0xC0, 0x00, 0x02, 0x01], + [0xC0, 0x00, 0x02, 0x00, 0xFF, 0xFF, 0xFF, 0x00], + Ok(true), + ), + ( + // 192.0.2.255 matches constraint 192.0.2.0/24 + [0xC0, 0x00, 0x02, 0xFF], + [0xC0, 0x00, 0x02, 0x00, 0xFF, 0xFF, 0xFF, 0x00], + Ok(true), + ), + ( + // 192.0.1.255 does not match constraint 192.0.2.0/24 + [0xC0, 0x00, 0x01, 0xFF], + [0xC0, 0x00, 0x02, 0x00, 0xFF, 0xFF, 0xFF, 0x00], + Ok(false), + ), + ( + // 192.0.3.0 does not match constraint 192.0.2.0/24 + [0xC0, 0x00, 0x03, 0x00], + [0xC0, 0x00, 0x02, 0x00, 0xFF, 0xFF, 0xFF, 0x00], + Ok(false), + ), + ]; + for (name, constraint, match_result) in names_and_constraints { + assert_eq!( + presented_id_matches_constraint( + untrusted::Input::from(&name), + untrusted::Input::from(&constraint), + ), + match_result + ) + } + + // Invalid name length (shorter) + assert_eq!( + presented_id_matches_constraint( + untrusted::Input::from(&[0xC0, 0x00, 0x02]), + untrusted::Input::from(&[0xC0, 0x00, 0x02, 0x00, 0xFF, 0xFF, 0xFF, 0x00]), + ), + Err(Error::BadDer), + ); + + // Invalid name length (longer) + assert_eq!( + presented_id_matches_constraint( + untrusted::Input::from(&[0xC0, 0x00, 0x02, 0x00, 0x00]), + untrusted::Input::from(&[0xC0, 0x00, 0x02, 0x00, 0xFF, 0xFF, 0xFF, 0x00]), + ), + Err(Error::BadDer), + ); + + // Unmatching constraint size (shorter) + assert_eq!( + presented_id_matches_constraint( + untrusted::Input::from(&[0xC0, 0x00, 0x02, 0x00]), + untrusted::Input::from(&[0xC0, 0x00, 0x02, 0x00, 0xFF, 0xFF, 0xFF]), + ), + Err(Error::InvalidNetworkMaskConstraint), + ); + + // Unmatching constraint size (longer) + assert_eq!( + presented_id_matches_constraint( + untrusted::Input::from(&[0xC0, 0x00, 0x02, 0x00]), + untrusted::Input::from(&[0xC0, 0x00, 0x02, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00]), + ), + Err(Error::InvalidNetworkMaskConstraint), + ); + + // Unmatching constraint size (IPv6 constraint for IPv4 address) + assert_eq!( + presented_id_matches_constraint( + untrusted::Input::from(&[0xC0, 0x00, 0x02, 0x00]), + untrusted::Input::from(&[ + 0x20, 0x01, 0x0D, 0xB8, 0xAB, 0xCD, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + ]), + ), + Ok(false), + ); + } + + #[test] + fn presented_id_matches_constraint_ipv6_test() { + let names_and_constraints = vec![ + ( + // 2001:0DB8:ABCD:0012:0000:0000:0000:0000 matches constraint + // 2001:0DB8:ABCD:0012:0000:0000:0000:0000/64 + [ + 0x20, 0x01, 0x0D, 0xB8, 0xAB, 0xCD, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, + ], + [ + 0x20, 0x01, 0x0D, 0xB8, 0xAB, 0xCD, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + ], + Ok(true), + ), + ( + // 2001:0DB8:ABCD:0012:0000:0000:0000:0001 matches constraint + // 2001:0DB8:ABCD:0012:0000:0000:0000:0000/64 + [ + 0x20, 0x01, 0x0D, 0xB8, 0xAB, 0xCD, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, + ], + [ + 0x20, 0x01, 0x0D, 0xB8, 0xAB, 0xCD, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + ], + Ok(true), + ), + ( + // 2001:0DB8:ABCD:0012:FFFF:FFFF:FFFF:FFFF matches constraint + // 2001:0DB8:ABCD:0012:0000:0000:0000:0000/64 + [ + 0x20, 0x01, 0x0D, 0xB8, 0xAB, 0xCD, 0x00, 0x12, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, + ], + [ + 0x20, 0x01, 0x0D, 0xB8, 0xAB, 0xCD, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + ], + Ok(true), + ), + ( + // 2001:0DB8:ABCD:0011:0000:0000:0000:0000 does not match constraint + // 2001:0DB8:ABCD:0012:0000:0000:0000:0000/64 + [ + 0x20, 0x01, 0x0D, 0xB8, 0xAB, 0xCD, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, + ], + [ + 0x20, 0x01, 0x0D, 0xB8, 0xAB, 0xCD, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + ], + Ok(false), + ), + ( + // 2001:0DB8:ABCD:0013:0000:0000:0000:0000 does not match constraint + // 2001:0DB8:ABCD:0012:0000:0000:0000:0000/64 + [ + 0x20, 0x01, 0x0D, 0xB8, 0xAB, 0xCD, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, + ], + [ + 0x20, 0x01, 0x0D, 0xB8, 0xAB, 0xCD, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + ], + Ok(false), + ), + ]; + for (name, constraint, match_result) in names_and_constraints { + assert_eq!( + presented_id_matches_constraint( + untrusted::Input::from(&name), + untrusted::Input::from(&constraint), + ), + match_result + ) + } + + // Invalid name length (shorter) + assert_eq!( + presented_id_matches_constraint( + untrusted::Input::from(&[ + 0x20, 0x01, 0x0D, 0xB8, 0xAB, 0xCD, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00 + ]), + untrusted::Input::from(&[ + 0x20, 0x01, 0x0D, 0xB8, 0xAB, 0xCD, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + ]), + ), + Err(Error::BadDer), + ); + + // Invalid name length (longer) + assert_eq!( + presented_id_matches_constraint( + untrusted::Input::from(&[ + 0x20, 0x01, 0x0D, 0xB8, 0xAB, 0xCD, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 + ]), + untrusted::Input::from(&[ + 0x20, 0x01, 0x0D, 0xB8, 0xAB, 0xCD, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + ]), + ), + Err(Error::BadDer), + ); + + // Unmatching constraint size (shorter) + assert_eq!( + presented_id_matches_constraint( + untrusted::Input::from(&[ + 0x20, 0x01, 0x0D, 0xB8, 0xAB, 0xCD, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, + ]), + untrusted::Input::from(&[ + 0x20, 0x01, 0x0D, 0xB8, 0xAB, 0xCD, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00 + ]), + ), + Err(Error::InvalidNetworkMaskConstraint), + ); + + // Unmatching constraint size (longer) + assert_eq!( + presented_id_matches_constraint( + untrusted::Input::from(&[ + 0x20, 0x01, 0x0D, 0xB8, 0xAB, 0xCD, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, + ]), + untrusted::Input::from(&[ + 0x20, 0x01, 0x0D, 0xB8, 0xAB, 0xCD, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + ]), + ), + Err(Error::InvalidNetworkMaskConstraint), + ); + + // Unmatching constraint size (IPv4 constraint for IPv6 address) + assert_eq!( + presented_id_matches_constraint( + untrusted::Input::from(&[ + 0x20, 0x01, 0x0D, 0xB8, 0xAB, 0xCD, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, + ]), + untrusted::Input::from(&[0xC0, 0x00, 0x02, 0x00, 0xFF, 0xFF, 0xFF, 0x00]), + ), + Ok(false), + ); + } + + #[test] + fn test_presented_id_matches_reference_id() { + assert!(!presented_id_matches_reference_id( + untrusted::Input::from(&[]), + untrusted::Input::from(&[]), + )); + + assert!(!presented_id_matches_reference_id( + untrusted::Input::from(&[0x01]), + untrusted::Input::from(&[]) + )); + + assert!(!presented_id_matches_reference_id( + untrusted::Input::from(&[]), + untrusted::Input::from(&[0x01]) + )); + + assert!(presented_id_matches_reference_id( + untrusted::Input::from(&[1, 2, 3, 4]), + untrusted::Input::from(&[1, 2, 3, 4]) + )); + + assert!(!presented_id_matches_reference_id( + untrusted::Input::from(&[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]), + untrusted::Input::from(&[1, 2, 3, 4]) + )); + + assert!(!presented_id_matches_reference_id( + untrusted::Input::from(&[1, 2, 3, 4]), + untrusted::Input::from(&[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) + )); + + assert!(presented_id_matches_reference_id( + untrusted::Input::from(&[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]), + untrusted::Input::from(&[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) + )); + } + + #[test] + fn presented_id_matches_constraint_rejects_incorrect_length_arguments() { + // wrong length names + assert_eq!( + presented_id_matches_constraint( + untrusted::Input::from(b"\x00\x00\x00"), + untrusted::Input::from(b"") + ), + Err(Error::BadDer) + ); + assert_eq!( + presented_id_matches_constraint( + untrusted::Input::from(b"\x00\x00\x00\x00\x00"), + untrusted::Input::from(b"") + ), + Err(Error::BadDer) + ); + + assert_eq!( + presented_id_matches_constraint( + untrusted::Input::from( + b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + ), + untrusted::Input::from(b"") + ), + Err(Error::BadDer) + ); + assert_eq!( + presented_id_matches_constraint( + untrusted::Input::from( + b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + ), + untrusted::Input::from(b"") + ), + Err(Error::BadDer) + ); + + // wrong length constraints + assert_eq!( + presented_id_matches_constraint( + untrusted::Input::from(b"\x00\x00\x00\x00"), + untrusted::Input::from(b"\x00\x00\x00\x00\xff\xff\xff") + ), + Err(Error::InvalidNetworkMaskConstraint) + ); + assert_eq!( + presented_id_matches_constraint( + untrusted::Input::from(b"\x00\x00\x00\x00"), + untrusted::Input::from(b"\x00\x00\x00\x00\xff\xff\xff\xff\x00") + ), + Err(Error::InvalidNetworkMaskConstraint) + ); + assert_eq!( + presented_id_matches_constraint(untrusted::Input::from(b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"), + untrusted::Input::from(b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ + \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff")), + Err(Error::InvalidNetworkMaskConstraint) + ); + assert_eq!( + presented_id_matches_constraint(untrusted::Input::from(b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"), + untrusted::Input::from(b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ + \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff")), + Err(Error::InvalidNetworkMaskConstraint) + ); + + // ipv4-length not considered for ipv6-length name, and vv + assert_eq!( + presented_id_matches_constraint(untrusted::Input::from(b"\x00\x00\x00\x00"), + untrusted::Input::from(b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\ + \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff")), + Ok(false) + ); + assert_eq!( + presented_id_matches_constraint( + untrusted::Input::from( + b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" + ), + untrusted::Input::from(b"\x00\x00\x00\x00\xff\xff\xff\xff") + ), + Ok(false) + ); + } +} + +#[cfg(all(test, feature = "std"))] +mod alloc_tests { + use super::*; + + // (presented_address, constraint_address, constraint_mask, expected_result) + const PRESENTED_MATCHES_CONSTRAINT: &[(&str, &str, &str, Result)] = &[ + // Cannot mix IpV4 with IpV6 and viceversa + ("2001:db8::", "8.8.8.8", "255.255.255.255", Ok(false)), + ("8.8.8.8", "2001:db8::", "ffff::", Ok(false)), + // IpV4 non-contiguous masks + ( + "8.8.8.8", + "8.8.8.8", + "255.255.255.1", + Err(Error::InvalidNetworkMaskConstraint), + ), + ( + "8.8.8.8", + "8.8.8.8", + "255.255.0.255", + Err(Error::InvalidNetworkMaskConstraint), + ), + ( + "8.8.8.8", + "8.8.8.8", + "255.0.255.255", + Err(Error::InvalidNetworkMaskConstraint), + ), + ( + "8.8.8.8", + "8.8.8.8", + "0.255.255.255", + Err(Error::InvalidNetworkMaskConstraint), + ), + ( + "8.8.8.8", + "8.8.8.8", + "1.255.255.255", + Err(Error::InvalidNetworkMaskConstraint), + ), + ( + "8.8.8.8", + "8.8.8.8", + "128.128.128.128", + Err(Error::InvalidNetworkMaskConstraint), + ), + // IpV4 + ("8.8.8.8", "8.8.8.8", "255.255.255.255", Ok(true)), + ("8.8.8.9", "8.8.8.8", "255.255.255.255", Ok(false)), + ("8.8.8.9", "8.8.8.8", "255.255.255.254", Ok(true)), + ("8.8.8.10", "8.8.8.8", "255.255.255.254", Ok(false)), + ("8.8.8.10", "8.8.8.8", "255.255.255.0", Ok(true)), + ("8.8.15.10", "8.8.8.8", "255.255.248.0", Ok(true)), + ("8.8.16.10", "8.8.8.8", "255.255.248.0", Ok(false)), + ("8.8.16.10", "8.8.8.8", "255.255.0.0", Ok(true)), + ("8.31.16.10", "8.8.8.8", "255.224.0.0", Ok(true)), + ("8.32.16.10", "8.8.8.8", "255.224.0.0", Ok(false)), + ("8.32.16.10", "8.8.8.8", "255.0.0.0", Ok(true)), + ("63.32.16.10", "8.8.8.8", "192.0.0.0", Ok(true)), + ("64.32.16.10", "8.8.8.8", "192.0.0.0", Ok(false)), + ("64.32.16.10", "8.8.8.8", "0.0.0.0", Ok(true)), + // IpV6 non-contiguous masks + ( + "2001:db8::", + "2001:db8::", + "fffe:ffff::", + Err(Error::InvalidNetworkMaskConstraint), + ), + ( + "2001:db8::", + "2001:db8::", + "ffff:fdff::", + Err(Error::InvalidNetworkMaskConstraint), + ), + ( + "2001:db8::", + "2001:db8::", + "ffff:feff::", + Err(Error::InvalidNetworkMaskConstraint), + ), + ( + "2001:db8::", + "2001:db8::", + "ffff:fcff::", + Err(Error::InvalidNetworkMaskConstraint), + ), + ( + "2001:db8::", + "2001:db8::", + "7fff:ffff::", + Err(Error::InvalidNetworkMaskConstraint), + ), + // IpV6 + ("2001:db8::", "2001:db8::", "ffff:ffff::", Ok(true)), + ("2001:db9::", "2001:db8::", "ffff:ffff::", Ok(false)), + ("2001:db9::", "2001:db8::", "ffff:fffe::", Ok(true)), + ("2001:dba::", "2001:db8::", "ffff:fffe::", Ok(false)), + ("2001:dba::", "2001:db8::", "ffff:ff00::", Ok(true)), + ("2001:dca::", "2001:db8::", "ffff:fe00::", Ok(true)), + ("2001:fca::", "2001:db8::", "ffff:fe00::", Ok(false)), + ("2001:fca::", "2001:db8::", "ffff:0000::", Ok(true)), + ("2000:fca::", "2001:db8::", "fffe:0000::", Ok(true)), + ("2003:fca::", "2001:db8::", "fffe:0000::", Ok(false)), + ("2003:fca::", "2001:db8::", "ff00:0000::", Ok(true)), + ("1003:fca::", "2001:db8::", "e000:0000::", Ok(false)), + ("1003:fca::", "2001:db8::", "0000:0000::", Ok(true)), + ]; + + #[test] + fn presented_matches_constraint_test() { + use std::boxed::Box; + use std::net::IpAddr; + + for (presented, constraint_address, constraint_mask, expected_result) in + PRESENTED_MATCHES_CONSTRAINT + { + let presented_bytes: Box<[u8]> = match presented.parse::().unwrap() { + IpAddr::V4(p) => Box::new(p.octets()), + IpAddr::V6(p) => Box::new(p.octets()), + }; + let ca_bytes: Box<[u8]> = match constraint_address.parse::().unwrap() { + IpAddr::V4(ca) => Box::new(ca.octets()), + IpAddr::V6(ca) => Box::new(ca.octets()), + }; + let cm_bytes: Box<[u8]> = match constraint_mask.parse::().unwrap() { + IpAddr::V4(cm) => Box::new(cm.octets()), + IpAddr::V6(cm) => Box::new(cm.octets()), + }; + let constraint_bytes = [ca_bytes, cm_bytes].concat(); + let actual_result = presented_id_matches_constraint( + untrusted::Input::from(&presented_bytes), + untrusted::Input::from(&constraint_bytes), + ); + assert_eq!( + &actual_result, expected_result, + "presented_id_matches_constraint(\"{presented_bytes:?}\", \"{constraint_bytes:?}\")" + ); + } + } +} diff --git a/http/vendor/rustls-webpki/src/subject_name/mod.rs b/http/vendor/rustls-webpki/src/subject_name/mod.rs new file mode 100644 index 0000000..1600390 --- /dev/null +++ b/http/vendor/rustls-webpki/src/subject_name/mod.rs @@ -0,0 +1,472 @@ +// Copyright 2022 Rafael Fernández López. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#[cfg(feature = "alloc")] +use alloc::string::String; +#[cfg(feature = "alloc")] +use core::fmt; + +use crate::der::{self, FromDer}; +use crate::error::{DerTypeId, Error}; +use crate::verify_cert::{Budget, PathNode}; + +mod dns_name; +use dns_name::IdRole; +pub(crate) use dns_name::{WildcardDnsNameRef, verify_dns_names}; + +mod ip_address; +pub(crate) use ip_address::verify_ip_address_names; + +// https://tools.ietf.org/html/rfc5280#section-4.2.1.10 +pub(crate) fn check_name_constraints( + constraints: Option<&mut untrusted::Reader<'_>>, + path: &PathNode<'_>, + budget: &mut Budget, +) -> Result<(), Error> { + let constraints = match constraints { + Some(input) => input, + None => return Ok(()), + }; + + fn parse_subtrees<'b>( + inner: &mut untrusted::Reader<'b>, + subtrees_tag: der::Tag, + ) -> Result>, Error> { + if !inner.peek(subtrees_tag.into()) { + return Ok(None); + } + der::expect_tag(inner, subtrees_tag).map(Some) + } + + let permitted_subtrees = parse_subtrees(constraints, der::Tag::ContextSpecificConstructed0)?; + let excluded_subtrees = parse_subtrees(constraints, der::Tag::ContextSpecificConstructed1)?; + + for path in path.iter() { + let result = NameIterator::new(path.cert.subject_alt_name).find_map(|result| { + let name = match result { + Ok(name) => name, + Err(err) => return Some(Err(err)), + }; + + check_presented_id_conforms_to_constraints( + name, + permitted_subtrees, + excluded_subtrees, + budget, + ) + }); + + if let Some(Err(err)) = result { + return Err(err); + } + + let result = check_presented_id_conforms_to_constraints( + GeneralName::DirectoryName, + permitted_subtrees, + excluded_subtrees, + budget, + ); + + if let Some(Err(err)) = result { + return Err(err); + } + } + + Ok(()) +} + +fn check_presented_id_conforms_to_constraints( + name: GeneralName<'_>, + permitted_subtrees: Option>, + excluded_subtrees: Option>, + budget: &mut Budget, +) -> Option> { + let subtrees = [ + (Subtrees::Permitted, permitted_subtrees), + (Subtrees::Excluded, excluded_subtrees), + ]; + + fn general_subtree<'b>(input: &mut untrusted::Reader<'b>) -> Result, Error> { + der::read_all(der::expect_tag(input, der::Tag::Sequence)?) + } + + for (subtrees, constraints) in subtrees { + let mut constraints = match constraints { + Some(constraints) => untrusted::Reader::new(constraints), + None => continue, + }; + + let mut has_permitted_subtrees_match = false; + let mut has_permitted_subtrees_mismatch = false; + while !constraints.at_end() { + if let Err(e) = budget.consume_name_constraint_comparison() { + return Some(Err(e)); + } + + // http://tools.ietf.org/html/rfc5280#section-4.2.1.10: "Within this + // profile, the minimum and maximum fields are not used with any name + // forms, thus, the minimum MUST be zero, and maximum MUST be absent." + // + // Since the default value isn't allowed to be encoded according to the + // DER encoding rules for DEFAULT, this is equivalent to saying that + // neither minimum or maximum must be encoded. + let base = match general_subtree(&mut constraints) { + Ok(base) => base, + Err(err) => return Some(Err(err)), + }; + + // Avoid having a catch-all branch here which might fail open on new variants + let matches = match (name, base) { + (GeneralName::DnsName(name), GeneralName::DnsName(base)) => { + dns_name::presented_id_matches_reference_id( + name, + IdRole::NameConstraint(subtrees), + base, + ) + } + (GeneralName::DnsName(_), _) => continue, + + (GeneralName::DirectoryName, GeneralName::DirectoryName) => Ok( + // Reject any uses of directory name constraints; we don't implement this. + // + // Rejecting everything technically confirms to RFC5280: + // + // "If a name constraints extension that is marked as critical imposes constraints + // on a particular name form, and an instance of that name form appears in the + // subject field or subjectAltName extension of a subsequent certificate, then + // the application MUST either process the constraint or _reject the certificate_." + // + // TODO: rustls/webpki#19 + // + // Rejection is achieved by not matching any PermittedSubtrees, and matching all + // ExcludedSubtrees. + match subtrees { + Subtrees::Permitted => false, + Subtrees::Excluded => true, + }, + ), + (GeneralName::DirectoryName, _) => continue, + + (GeneralName::IpAddress(name), GeneralName::IpAddress(base)) => { + ip_address::presented_id_matches_constraint(name, base) + } + (GeneralName::IpAddress(_), _) => continue, + + // We currently don't support URI constraints -- fail closed for now. + // + // Rejection is achieved by not matching any PermittedSubtrees, and matching all + // ExcludedSubtrees. + ( + GeneralName::UniformResourceIdentifier(_), + GeneralName::UniformResourceIdentifier(_), + ) => Ok(match subtrees { + Subtrees::Permitted => false, + Subtrees::Excluded => true, + }), + (GeneralName::UniformResourceIdentifier(_), _) => continue, + + // RFC 4280 says "If a name constraints extension that is marked as + // critical imposes constraints on a particular name form, and an + // instance of that name form appears in the subject field or + // subjectAltName extension of a subsequent certificate, then the + // application MUST either process the constraint or reject the + // certificate." Later, the CABForum agreed to support non-critical + // constraints, so it is important to reject the cert without + // considering whether the name constraint it critical. + (GeneralName::Unsupported(name_tag), GeneralName::Unsupported(base_tag)) + if name_tag == base_tag => + { + Err(Error::NameConstraintViolation) + } + (GeneralName::Unsupported(_), _) => continue, + }; + + match (subtrees, matches) { + (Subtrees::Permitted, Ok(true)) => { + has_permitted_subtrees_match = true; + } + + (Subtrees::Permitted, Ok(false)) => { + has_permitted_subtrees_mismatch = true; + } + + (Subtrees::Excluded, Ok(true)) => { + return Some(Err(Error::NameConstraintViolation)); + } + + (Subtrees::Excluded, Ok(false)) => (), + (_, Err(err)) => return Some(Err(err)), + } + } + + if has_permitted_subtrees_mismatch && !has_permitted_subtrees_match { + // If there was any entry of the given type in permittedSubtrees, then + // it required that at least one of them must match. Since none of them + // did, we have a failure. + return Some(Err(Error::NameConstraintViolation)); + } + } + + None +} + +#[derive(Clone, Copy, PartialEq)] +enum Subtrees { + Permitted, + Excluded, +} + +pub(crate) struct NameIterator<'a> { + subject_alt_name: Option>, +} + +impl<'a> NameIterator<'a> { + pub(crate) fn new(subject_alt_name: Option>) -> Self { + Self { + subject_alt_name: subject_alt_name.map(untrusted::Reader::new), + } + } +} + +impl<'a> Iterator for NameIterator<'a> { + type Item = Result, Error>; + + fn next(&mut self) -> Option { + let subject_alt_name = self.subject_alt_name.as_mut()?; + // https://bugzilla.mozilla.org/show_bug.cgi?id=1143085: An empty + // subjectAltName is not legal, but some certificates have an empty + // subjectAltName. Since we don't support CN-IDs, the certificate + // will be rejected either way, but checking `at_end` before + // attempting to parse the first entry allows us to return a better + // error code. + + if subject_alt_name.at_end() { + self.subject_alt_name = None; + return None; + } + + let err = match GeneralName::from_der(subject_alt_name) { + Ok(name) => return Some(Ok(name)), + Err(err) => err, + }; + + // Make sure we don't yield any items after this error. + self.subject_alt_name = None; + Some(Err(err)) + } +} + +// It is *not* valid to derive `Eq`, `PartialEq, etc. for this type. In +// particular, for the types of `GeneralName`s that we don't understand, we +// don't even store the value. Also, the meaning of a `GeneralName` in a name +// constraint is different than the meaning of the identically-represented +// `GeneralName` in other contexts. +#[derive(Clone, Copy)] +pub(crate) enum GeneralName<'a> { + DnsName(untrusted::Input<'a>), + DirectoryName, + IpAddress(untrusted::Input<'a>), + UniformResourceIdentifier(untrusted::Input<'a>), + + // The value is the `tag & ~(der::CONTEXT_SPECIFIC | der::CONSTRUCTED)` so + // that the name constraint checking matches tags regardless of whether + // those bits are set. + Unsupported(u8), +} + +impl<'a> FromDer<'a> for GeneralName<'a> { + fn from_der(reader: &mut untrusted::Reader<'a>) -> Result { + use GeneralName::*; + use der::{CONSTRUCTED, CONTEXT_SPECIFIC}; + + #[allow(clippy::identity_op)] + const OTHER_NAME_TAG: u8 = CONTEXT_SPECIFIC | CONSTRUCTED | 0; + const RFC822_NAME_TAG: u8 = CONTEXT_SPECIFIC | 1; + const DNS_NAME_TAG: u8 = CONTEXT_SPECIFIC | 2; + const X400_ADDRESS_TAG: u8 = CONTEXT_SPECIFIC | CONSTRUCTED | 3; + const DIRECTORY_NAME_TAG: u8 = CONTEXT_SPECIFIC | CONSTRUCTED | 4; + const EDI_PARTY_NAME_TAG: u8 = CONTEXT_SPECIFIC | CONSTRUCTED | 5; + const UNIFORM_RESOURCE_IDENTIFIER_TAG: u8 = CONTEXT_SPECIFIC | 6; + const IP_ADDRESS_TAG: u8 = CONTEXT_SPECIFIC | 7; + const REGISTERED_ID_TAG: u8 = CONTEXT_SPECIFIC | 8; + + let (tag, value) = der::read_tag_and_get_value(reader)?; + Ok(match tag { + DNS_NAME_TAG => DnsName(value), + DIRECTORY_NAME_TAG => DirectoryName, + IP_ADDRESS_TAG => IpAddress(value), + UNIFORM_RESOURCE_IDENTIFIER_TAG => UniformResourceIdentifier(value), + + OTHER_NAME_TAG | RFC822_NAME_TAG | X400_ADDRESS_TAG | EDI_PARTY_NAME_TAG + | REGISTERED_ID_TAG => Unsupported(tag & !(CONTEXT_SPECIFIC | CONSTRUCTED)), + + _ => return Err(Error::BadDer), + }) + } + + const TYPE_ID: DerTypeId = DerTypeId::GeneralName; +} + +#[cfg(feature = "alloc")] +impl fmt::Debug for GeneralName<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + GeneralName::DnsName(name) => write!( + f, + "DnsName(\"{}\")", + String::from_utf8_lossy(name.as_slice_less_safe()) + ), + GeneralName::DirectoryName => write!(f, "DirectoryName"), + GeneralName::IpAddress(ip) => { + write!(f, "IpAddress({:?})", IpAddrSlice(ip.as_slice_less_safe())) + } + GeneralName::UniformResourceIdentifier(uri) => write!( + f, + "UniformResourceIdentifier(\"{}\")", + String::from_utf8_lossy(uri.as_slice_less_safe()) + ), + GeneralName::Unsupported(tag) => write!(f, "Unsupported(0x{tag:02x})"), + } + } +} + +#[cfg(feature = "alloc")] +struct IpAddrSlice<'a>(&'a [u8]); + +#[cfg(feature = "alloc")] +impl fmt::Debug for IpAddrSlice<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self.0.len() { + 4 => { + let mut first = true; + for byte in self.0 { + match first { + true => first = false, + false => f.write_str(".")?, + } + + write!(f, "{byte}")?; + } + + Ok(()) + } + 16 => { + let (mut first, mut skipping) = (true, false); + for group in self.0.chunks_exact(2) { + match (first, group == [0, 0], skipping) { + (true, _, _) => first = false, + (false, false, false) => f.write_str(":")?, + (false, true, _) => { + skipping = true; + continue; + } + (false, false, true) => { + skipping = false; + f.write_str("::")?; + } + } + + if group[0] != 0 { + write!(f, "{:x}", group[0])?; + } + + match group[0] { + 0 => write!(f, "{:x}", group[1])?, + _ => write!(f, "{:02x}", group[1])?, + } + } + Ok(()) + } + _ => { + f.write_str("[invalid: ")?; + let mut first = true; + for byte in self.0 { + match first { + true => first = false, + false => f.write_str(", ")?, + } + write!(f, "{byte:02x}")?; + } + f.write_str("]") + } + } + } +} + +#[cfg(all(test, feature = "alloc"))] +mod tests { + use super::*; + + #[test] + fn debug_names() { + assert_eq!( + format!( + "{:?}", + GeneralName::DnsName(untrusted::Input::from(b"example.com")) + ), + "DnsName(\"example.com\")" + ); + + assert_eq!(format!("{:?}", GeneralName::DirectoryName), "DirectoryName"); + + assert_eq!( + format!( + "{:?}", + GeneralName::IpAddress(untrusted::Input::from(&[192, 0, 2, 1][..])) + ), + "IpAddress(192.0.2.1)" + ); + + assert_eq!( + format!( + "{:?}", + GeneralName::IpAddress(untrusted::Input::from( + &[0x20, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x0d, 0xb8][..] + )) + ), + "IpAddress(2001::db8)" + ); + + assert_eq!( + format!( + "{:?}", + GeneralName::IpAddress(untrusted::Input::from(&[1, 2, 3, 4, 5, 6][..])) + ), + "IpAddress([invalid: 01, 02, 03, 04, 05, 06])" + ); + + assert_eq!( + format!( + "{:?}", + GeneralName::UniformResourceIdentifier(untrusted::Input::from( + b"https://example.com" + )) + ), + "UniformResourceIdentifier(\"https://example.com\")" + ); + + assert_eq!( + format!("{:?}", GeneralName::Unsupported(0x66)), + "Unsupported(0x66)" + ); + } + + #[test] + fn name_iter_end_after_error() { + let input = untrusted::Input::from(&[0x30]); + let mut iter = NameIterator::new(Some(input)); + assert_eq!(iter.next().unwrap().unwrap_err(), Error::BadDer); + assert!(iter.next().is_none()); + } +} diff --git a/http/vendor/rustls-webpki/src/time.rs b/http/vendor/rustls-webpki/src/time.rs new file mode 100644 index 0000000..f96aeb6 --- /dev/null +++ b/http/vendor/rustls-webpki/src/time.rs @@ -0,0 +1,283 @@ +// Copyright 2015-2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! Conversions into the library's time type. + +use core::time::Duration; + +use pki_types::UnixTime; + +use crate::der::{self, FromDer, Tag}; +use crate::error::{DerTypeId, Error}; + +impl<'a> FromDer<'a> for UnixTime { + fn from_der(input: &mut untrusted::Reader<'a>) -> Result { + let is_utc_time = input.peek(Tag::UTCTime.into()); + let expected_tag = if is_utc_time { + Tag::UTCTime + } else { + Tag::GeneralizedTime + }; + + fn read_digit(inner: &mut untrusted::Reader<'_>) -> Result { + const DIGIT: core::ops::RangeInclusive = b'0'..=b'9'; + let b = inner.read_byte().map_err(|_| Error::BadDerTime)?; + if DIGIT.contains(&b) { + return Ok(u64::from(b - DIGIT.start())); + } + Err(Error::BadDerTime) + } + + fn read_two_digits( + inner: &mut untrusted::Reader<'_>, + min: u64, + max: u64, + ) -> Result { + let hi = read_digit(inner)?; + let lo = read_digit(inner)?; + let value = (hi * 10) + lo; + if value < min || value > max { + return Err(Error::BadDerTime); + } + Ok(value) + } + + der::nested( + input, + expected_tag, + Error::TrailingData(Self::TYPE_ID), + |value| { + let (year_hi, year_lo) = if is_utc_time { + let lo = read_two_digits(value, 0, 99)?; + let hi = if lo >= 50 { 19 } else { 20 }; + (hi, lo) + } else { + let hi = read_two_digits(value, 0, 99)?; + let lo = read_two_digits(value, 0, 99)?; + (hi, lo) + }; + + let year = (year_hi * 100) + year_lo; + let month = read_two_digits(value, 1, 12)?; + let days_in_month = days_in_month(year, month); + let day_of_month = read_two_digits(value, 1, days_in_month)?; + let hours = read_two_digits(value, 0, 23)?; + let minutes = read_two_digits(value, 0, 59)?; + let seconds = read_two_digits(value, 0, 59)?; + + let time_zone = value.read_byte().map_err(|_| Error::BadDerTime)?; + if time_zone != b'Z' { + return Err(Error::BadDerTime); + } + + time_from_ymdhms_utc(year, month, day_of_month, hours, minutes, seconds) + }, + ) + } + + const TYPE_ID: DerTypeId = DerTypeId::Time; +} + +pub(crate) fn time_from_ymdhms_utc( + year: u64, + month: u64, + day_of_month: u64, + hours: u64, + minutes: u64, + seconds: u64, +) -> Result { + let days_before_year_since_unix_epoch = days_before_year_since_unix_epoch(year)?; + + const JAN: u64 = 31; + let feb = days_in_feb(year); + const MAR: u64 = 31; + const APR: u64 = 30; + const MAY: u64 = 31; + const JUN: u64 = 30; + const JUL: u64 = 31; + const AUG: u64 = 31; + const SEP: u64 = 30; + const OCT: u64 = 31; + const NOV: u64 = 30; + let days_before_month_in_year = match month { + 1 => 0, + 2 => JAN, + 3 => JAN + feb, + 4 => JAN + feb + MAR, + 5 => JAN + feb + MAR + APR, + 6 => JAN + feb + MAR + APR + MAY, + 7 => JAN + feb + MAR + APR + MAY + JUN, + 8 => JAN + feb + MAR + APR + MAY + JUN + JUL, + 9 => JAN + feb + MAR + APR + MAY + JUN + JUL + AUG, + 10 => JAN + feb + MAR + APR + MAY + JUN + JUL + AUG + SEP, + 11 => JAN + feb + MAR + APR + MAY + JUN + JUL + AUG + SEP + OCT, + 12 => JAN + feb + MAR + APR + MAY + JUN + JUL + AUG + SEP + OCT + NOV, + _ => unreachable!(), // `read_two_digits` already bounds-checked it. + }; + + let days_before = + days_before_year_since_unix_epoch + days_before_month_in_year + day_of_month - 1; + + let seconds_since_unix_epoch = + (days_before * 24 * 60 * 60) + (hours * 60 * 60) + (minutes * 60) + seconds; + + Ok(UnixTime::since_unix_epoch(Duration::from_secs( + seconds_since_unix_epoch, + ))) +} + +fn days_before_year_since_unix_epoch(year: u64) -> Result { + // We don't support dates before January 1, 1970 because that is the + // Unix epoch. It is likely that other software won't deal well with + // certificates that have dates before the epoch. + if year < UNIX_EPOCH_YEAR { + return Err(Error::BadDerTime); + } + let days_before_year_ad = days_before_year_ad(year); + debug_assert!(days_before_year_ad >= DAYS_BEFORE_UNIX_EPOCH_AD); + Ok(days_before_year_ad - DAYS_BEFORE_UNIX_EPOCH_AD) +} + +const UNIX_EPOCH_YEAR: u64 = 1970; + +fn days_before_year_ad(year: u64) -> u64 { + ((year - 1) * 365) + + ((year - 1) / 4) // leap years are every 4 years, + - ((year - 1) / 100) // except years divisible by 100, + + ((year - 1) / 400) // except years divisible by 400. +} + +pub(crate) fn days_in_month(year: u64, month: u64) -> u64 { + match month { + 1 | 3 | 5 | 7 | 8 | 10 | 12 => 31, + 4 | 6 | 9 | 11 => 30, + 2 => days_in_feb(year), + _ => unreachable!(), // `read_two_digits` already bounds-checked it. + } +} + +fn days_in_feb(year: u64) -> u64 { + if (year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0)) { + 29 + } else { + 28 + } +} + +/// All the days up to and including 1969, plus the 477 leap days since AD began +/// (calculated in Gregorian rules). +const DAYS_BEFORE_UNIX_EPOCH_AD: u64 = 1969 * 365 + 477; + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_days_before_unix_epoch() { + assert_eq!( + DAYS_BEFORE_UNIX_EPOCH_AD, + days_before_year_ad(UNIX_EPOCH_YEAR) + ); + } + + #[test] + fn test_days_before_year_since_unix_epoch() { + assert_eq!(Ok(0), days_before_year_since_unix_epoch(UNIX_EPOCH_YEAR)); + assert_eq!( + Ok(365), + days_before_year_since_unix_epoch(UNIX_EPOCH_YEAR + 1) + ); + assert_eq!( + Err(Error::BadDerTime), + days_before_year_since_unix_epoch(UNIX_EPOCH_YEAR - 1) + ); + } + + #[test] + fn test_days_in_month() { + assert_eq!(days_in_month(2017, 1), 31); + assert_eq!(days_in_month(2017, 2), 28); + assert_eq!(days_in_month(2017, 3), 31); + assert_eq!(days_in_month(2017, 4), 30); + assert_eq!(days_in_month(2017, 5), 31); + assert_eq!(days_in_month(2017, 6), 30); + assert_eq!(days_in_month(2017, 7), 31); + assert_eq!(days_in_month(2017, 8), 31); + assert_eq!(days_in_month(2017, 9), 30); + assert_eq!(days_in_month(2017, 10), 31); + assert_eq!(days_in_month(2017, 11), 30); + assert_eq!(days_in_month(2017, 12), 31); + + // leap cases + assert_eq!(days_in_month(2000, 2), 29); + assert_eq!(days_in_month(2004, 2), 29); + assert_eq!(days_in_month(2016, 2), 29); + assert_eq!(days_in_month(2100, 2), 28); + } + + #[test] + fn test_time_from_ymdhms_utc() { + // 1969-12-31 00:00:00 + assert_eq!( + Err(Error::BadDerTime), + time_from_ymdhms_utc(UNIX_EPOCH_YEAR - 1, 1, 1, 0, 0, 0) + ); + + // 1969-12-31 23:59:59 + assert_eq!( + Err(Error::BadDerTime), + time_from_ymdhms_utc(UNIX_EPOCH_YEAR - 1, 12, 31, 23, 59, 59) + ); + + // 1970-01-01 00:00:00 + assert_eq!( + UnixTime::since_unix_epoch(Duration::from_secs(0)), + time_from_ymdhms_utc(UNIX_EPOCH_YEAR, 1, 1, 0, 0, 0).unwrap() + ); + + // 1970-01-01 00:00:01 + assert_eq!( + UnixTime::since_unix_epoch(Duration::from_secs(1)), + time_from_ymdhms_utc(UNIX_EPOCH_YEAR, 1, 1, 0, 0, 1).unwrap() + ); + + // 1971-01-01 00:00:00 + assert_eq!( + UnixTime::since_unix_epoch(Duration::from_secs(365 * 86400)), + time_from_ymdhms_utc(UNIX_EPOCH_YEAR + 1, 1, 1, 0, 0, 0).unwrap() + ); + + // year boundary + assert_eq!( + UnixTime::since_unix_epoch(Duration::from_secs(1_483_228_799)), + time_from_ymdhms_utc(2016, 12, 31, 23, 59, 59).unwrap() + ); + assert_eq!( + UnixTime::since_unix_epoch(Duration::from_secs(1_483_228_800)), + time_from_ymdhms_utc(2017, 1, 1, 0, 0, 0).unwrap() + ); + + // not a leap year + assert_eq!( + UnixTime::since_unix_epoch(Duration::from_secs(1_492_449_162)), + time_from_ymdhms_utc(2017, 4, 17, 17, 12, 42).unwrap() + ); + + // leap year, post-feb + assert_eq!( + UnixTime::since_unix_epoch(Duration::from_secs(1_460_913_162)), + time_from_ymdhms_utc(2016, 4, 17, 17, 12, 42).unwrap() + ); + } +} diff --git a/http/vendor/rustls-webpki/src/trust_anchor.rs b/http/vendor/rustls-webpki/src/trust_anchor.rs new file mode 100644 index 0000000..1489c90 --- /dev/null +++ b/http/vendor/rustls-webpki/src/trust_anchor.rs @@ -0,0 +1,141 @@ +use pki_types::{CertificateDer, TrustAnchor}; + +use crate::cert::{Cert, lenient_certificate_serial_number}; +use crate::der; +use crate::error::{DerTypeId, Error}; + +/// Interprets the given pre-validated DER-encoded certificate as a `TrustAnchor`. +/// +/// This function extracts the components of a trust anchor (see [RFC 5280 6.1.1]) from +/// an X.509 certificate obtained from a source trusted to have appropriately validated +/// the subject name, public key, and name constraints in the certificate, for example your +/// operating system's trust store. +/// +/// No additional checks on the content of the certificate, including whether it is self-signed, +/// or has a basic constraints extension indicating the `cA` boolean is true, will be performed. +/// [RFC 5280 6.2] notes: +/// > Implementations that use self-signed certificates to specify trust +/// > anchor information are free to process or ignore such information. +/// +/// This function is intended for users constructing `TrustAnchor`'s from existing trust stores +/// that express trust anchors as X.509 certificates. It should **not** be used to treat an +/// end-entity certificate as a `TrustAnchor` in an effort to validate the same end-entity +/// certificate during path building. Webpki has no support for self-signed certificates. +/// +/// [RFC 5280 6.1.1]: +/// [RFC 5280 6.2]: +pub fn anchor_from_trusted_cert<'a>( + cert: &'a CertificateDer<'a>, +) -> Result, Error> { + let cert_der = untrusted::Input::from(cert.as_ref()); + + // v1 certificates will result in `Error::BadDer` because `parse_cert` will + // expect a version field that isn't there. In that case, try to parse the + // certificate using a special parser for v1 certificates. Notably, that + // parser doesn't allow extensions, so there's no need to worry about + // embedded name constraints in a v1 certificate. + match Cert::for_trust_anchor(cert_der) { + Ok(cert) => Ok(TrustAnchor::from(cert)), + Err(Error::UnsupportedCertVersion) => { + extract_trust_anchor_from_v1_cert_der(cert_der).or(Err(Error::BadDer)) + } + Err(err) => Err(err), + } +} + +/// Parses a v1 certificate directly into a TrustAnchor. +fn extract_trust_anchor_from_v1_cert_der( + cert_der: untrusted::Input<'_>, +) -> Result, Error> { + // X.509 Certificate: https://tools.ietf.org/html/rfc5280#section-4.1. + cert_der.read_all(Error::BadDer, |cert_der| { + der::nested( + cert_der, + der::Tag::Sequence, + Error::TrailingData(DerTypeId::TrustAnchorV1), + |cert_der| { + let anchor = der::nested( + cert_der, + der::Tag::Sequence, + Error::TrailingData(DerTypeId::TrustAnchorV1TbsCertificate), + |tbs| { + // The version number field does not appear in v1 certificates. + lenient_certificate_serial_number(tbs)?; + + skip(tbs, der::Tag::Sequence)?; // signature. + skip(tbs, der::Tag::Sequence)?; // issuer. + skip(tbs, der::Tag::Sequence)?; // validity. + let subject = der::expect_tag(tbs, der::Tag::Sequence)?; + let spki = der::expect_tag(tbs, der::Tag::Sequence)?; + + Ok(TrustAnchor { + subject: subject.as_slice_less_safe().into(), + subject_public_key_info: spki.as_slice_less_safe().into(), + name_constraints: None, + }) + }, + ); + + // read and discard signatureAlgorithm + signature + skip(cert_der, der::Tag::Sequence)?; + skip(cert_der, der::Tag::BitString)?; + + anchor + }, + ) + }) +} + +impl<'a> From> for TrustAnchor<'a> { + fn from(cert: Cert<'a>) -> Self { + Self { + subject: cert.subject.as_slice_less_safe().into(), + subject_public_key_info: cert.spki.as_slice_less_safe().into(), + name_constraints: cert + .name_constraints + .map(|nc| nc.as_slice_less_safe().into()), + } + } +} + +fn skip(input: &mut untrusted::Reader<'_>, tag: der::Tag) -> Result<(), Error> { + der::expect_tag(input, tag).map(|_| ()) +} + +#[cfg(test)] +mod tests { + use rcgen::{CertificateParams, CustomExtension, KeyPair}; + + use super::*; + + // OID 1.2.3.4 -- not under the id-ce arc, so `ExtensionOid::lookup` returns `None`. + // This exercises the unknown-OID path in `remember_extension`. + #[test] + fn anchor_ignores_critical_extension_with_unknown_oid() { + let der = cert_with_critical_extension(&[1, 2, 3, 4]); + anchor_from_trusted_cert(&der) + .expect("critical extension with unknown OID should be ignored for trust anchors"); + } + + // OID 2.5.29.99 -- under the id-ce arc, so `ExtensionOid::lookup` returns + // `Some(Standard(99))`, but 99 isn't handled in `remember_cert_extension`. + // This exercises the unsupported-extension path in `remember_cert_extension`. + #[test] + fn anchor_ignores_critical_extension_with_unknown_id_ce_oid() { + let der = cert_with_critical_extension(&[2, 5, 29, 99]); + anchor_from_trusted_cert(&der).expect( + "critical id-ce extension with unknown OID should be ignored for trust anchors", + ); + } + + fn cert_with_critical_extension(oid: &[u64]) -> CertificateDer<'static> { + let mut params = CertificateParams::new(vec!["example.com".into()]).unwrap(); + let mut ext = CustomExtension::from_oid_content(oid, vec![1, 2]); + ext.set_criticality(true); + params.custom_extensions.push(ext); + + let key = KeyPair::generate_for(&rcgen::PKCS_ECDSA_P256_SHA256).unwrap(); + let cert = params.self_signed(&key).unwrap(); + CertificateDer::from(cert.der().to_vec()) + } +} diff --git a/http/vendor/rustls-webpki/src/verify_cert.rs b/http/vendor/rustls-webpki/src/verify_cert.rs new file mode 100644 index 0000000..409c2a3 --- /dev/null +++ b/http/vendor/rustls-webpki/src/verify_cert.rs @@ -0,0 +1,1373 @@ +// Copyright 2015 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#[cfg(feature = "alloc")] +use alloc::vec::Vec; +use core::fmt; +use core::ops::ControlFlow; + +use pki_types::{CertificateDer, SignatureVerificationAlgorithm, TrustAnchor, UnixTime}; + +use crate::cert::Cert; +use crate::crl::RevocationOptions; +use crate::der::{self, FromDer}; +use crate::end_entity::EndEntityCert; +use crate::error::Error; +use crate::{public_values_eq, signed_data, subject_name}; + +// Use `'a` for lifetimes that we don't care about, `'p` for lifetimes that become a part of +// the `VerifiedPath`. +pub(crate) struct ChainOptions<'a, 'p, V> { + pub(crate) eku: V, + pub(crate) supported_sig_algs: &'a [&'a dyn SignatureVerificationAlgorithm], + pub(crate) trust_anchors: &'p [TrustAnchor<'p>], + pub(crate) intermediate_certs: &'p [CertificateDer<'p>], + pub(crate) revocation: Option>, +} + +impl<'a, 'p: 'a, V: ExtendedKeyUsageValidator> ChainOptions<'a, 'p, V> { + pub(crate) fn build_chain( + &self, + end_entity: &'p EndEntityCert<'p>, + time: UnixTime, + verify_path: Option<&dyn Fn(&VerifiedPath<'_>) -> Result<(), Error>>, + ) -> Result, Error> { + let mut path = PartialPath::new(end_entity); + match self.build_chain_inner(&mut path, time, verify_path, 0, &mut Budget::default()) { + Ok(anchor) => Ok(VerifiedPath::new(end_entity, anchor, path)), + Err(ControlFlow::Break(err)) | Err(ControlFlow::Continue(err)) => Err(err), + } + } + + fn build_chain_inner( + &self, + path: &mut PartialPath<'p>, + time: UnixTime, + verify_path: Option<&dyn Fn(&VerifiedPath<'_>) -> Result<(), Error>>, + sub_ca_count: usize, + budget: &mut Budget, + ) -> Result<&'p TrustAnchor<'p>, ControlFlow> { + let role = path.node().role(); + + check_issuer_independent_properties(path.head(), time, role, sub_ca_count, &self.eku)?; + + // TODO: HPKP checks. + + let result = + loop_while_non_fatal_error(Error::UnknownIssuer, self.trust_anchors, |trust_anchor| { + let trust_anchor_subject = untrusted::Input::from(trust_anchor.subject.as_ref()); + if !public_values_eq(path.head().issuer, trust_anchor_subject) { + return Err(Error::UnknownIssuer.into()); + } + + // TODO: check_distrust(trust_anchor_subject, trust_anchor_spki)?; + + let node = path.node(); + self.check_signed_chain(&node, time, trust_anchor, budget)?; + check_signed_chain_name_constraints(&node, trust_anchor, budget)?; + + let verify = match verify_path { + Some(verify) => verify, + None => return Ok(trust_anchor), + }; + + let candidate = VerifiedPath { + end_entity: path.end_entity, + intermediates: Intermediates::Borrowed(&path.intermediates[..path.used]), + anchor: trust_anchor, + }; + + match verify(&candidate) { + Ok(()) => Ok(trust_anchor), + Err(err) => Err(ControlFlow::Continue(err)), + } + }); + + let err = match result { + Ok(anchor) => return Ok(anchor), + // Fatal errors should halt further path building. + res @ Err(ControlFlow::Break(_)) => return res, + // Non-fatal errors should be carried forward as the default_error for subsequent + // loop_while_non_fatal_error processing and only returned once all other path-building + // options have been exhausted. + Err(ControlFlow::Continue(err)) => err, + }; + + loop_while_non_fatal_error(err, self.intermediate_certs, |cert_der| { + let potential_issuer = Cert::from_der(untrusted::Input::from(cert_der))?; + if !public_values_eq(potential_issuer.subject, path.head().issuer) { + return Err(Error::UnknownIssuer.into()); + } + + // Prevent loops; see RFC 4158 section 5.2. + if path.node().iter().any(|prev| { + public_values_eq(potential_issuer.spki, prev.cert.spki) + && public_values_eq(potential_issuer.subject, prev.cert.subject) + }) { + return Err(Error::UnknownIssuer.into()); + } + + let next_sub_ca_count = match role { + Role::EndEntity => sub_ca_count, + Role::Issuer => sub_ca_count + 1, + }; + + budget.consume_build_chain_call()?; + path.push(potential_issuer)?; + let result = self.build_chain_inner(path, time, verify_path, next_sub_ca_count, budget); + if result.is_err() { + path.pop(); + } + + result + }) + } + + fn check_signed_chain( + &self, + path: &PathNode<'_>, + time: UnixTime, + trust_anchor: &TrustAnchor<'_>, + budget: &mut Budget, + ) -> Result<(), ControlFlow> { + let mut spki_value = untrusted::Input::from(trust_anchor.subject_public_key_info.as_ref()); + let mut issuer_subject = untrusted::Input::from(trust_anchor.subject.as_ref()); + let mut issuer_key_usage = None; // TODO(XXX): Consider whether to track TrustAnchor KU. + for path in path.iter() { + signed_data::verify_signed_data( + self.supported_sig_algs, + spki_value, + &path.cert.signed_data, + budget, + )?; + + if let Some(revocation_opts) = &self.revocation { + revocation_opts.check( + &path, + issuer_subject, + spki_value, + issuer_key_usage, + self.supported_sig_algs, + budget, + time, + )?; + } + + spki_value = path.cert.spki; + issuer_subject = path.cert.subject; + issuer_key_usage = path.cert.key_usage; + } + + Ok(()) + } +} + +/// Path from end-entity certificate to trust anchor that's been verified. +/// +/// See [`EndEntityCert::verify_for_usage()`] for more details on what verification entails. +pub struct VerifiedPath<'p> { + end_entity: &'p EndEntityCert<'p>, + intermediates: Intermediates<'p>, + anchor: &'p TrustAnchor<'p>, +} + +impl<'p> VerifiedPath<'p> { + fn new( + end_entity: &'p EndEntityCert<'p>, + anchor: &'p TrustAnchor<'p>, + partial: PartialPath<'p>, + ) -> Self { + Self { + end_entity, + intermediates: Intermediates::Owned { + certs: partial.intermediates, + used: partial.used, + }, + anchor, + } + } + + /// Yields a (double-ended) iterator over the intermediate certificates in this path. + pub fn intermediate_certificates(&'p self) -> IntermediateIterator<'p> { + IntermediateIterator { + intermediates: self.intermediates.as_ref(), + } + } + + /// Yields the end-entity certificate for this path. + pub fn end_entity(&self) -> &'p EndEntityCert<'p> { + self.end_entity + } + + /// Yields the trust anchor for this path. + pub fn anchor(&self) -> &'p TrustAnchor<'p> { + self.anchor + } +} + +/// Iterator over a path's intermediate certificates. +/// +/// Implements [`DoubleEndedIterator`] so it can be traversed in both directions. +pub struct IntermediateIterator<'a> { + /// Invariant: all of these `Option`s are `Some`. + intermediates: &'a [Option>], +} + +impl<'a> Iterator for IntermediateIterator<'a> { + type Item = &'a Cert<'a>; + + fn next(&mut self) -> Option { + match self.intermediates.split_first() { + Some((head, tail)) => { + self.intermediates = tail; + Some(head.as_ref().unwrap()) + } + None => None, + } + } +} + +impl DoubleEndedIterator for IntermediateIterator<'_> { + fn next_back(&mut self) -> Option { + match self.intermediates.split_last() { + Some((head, tail)) => { + self.intermediates = tail; + Some(head.as_ref().unwrap()) + } + None => None, + } + } +} + +#[allow(clippy::large_enum_variant)] +enum Intermediates<'a> { + Owned { + certs: [Option>; MAX_SUB_CA_COUNT], + used: usize, + }, + Borrowed(&'a [Option>]), +} + +impl<'a> AsRef<[Option>]> for Intermediates<'a> { + fn as_ref(&self) -> &[Option>] { + match self { + Intermediates::Owned { certs, used } => &certs[..*used], + Intermediates::Borrowed(certs) => certs, + } + } +} + +fn check_signed_chain_name_constraints( + path: &PathNode<'_>, + trust_anchor: &TrustAnchor<'_>, + budget: &mut Budget, +) -> Result<(), ControlFlow> { + let mut name_constraints = trust_anchor + .name_constraints + .as_ref() + .map(|der| untrusted::Input::from(der.as_ref())); + + for path in path.iter() { + untrusted::read_all_optional(name_constraints, Error::BadDer, |value| { + subject_name::check_name_constraints(value, &path, budget) + })?; + + name_constraints = path.cert.name_constraints; + } + + Ok(()) +} + +pub(crate) struct Budget { + signatures: usize, + build_chain_calls: usize, + name_constraint_comparisons: usize, +} + +impl Budget { + #[inline] + pub(crate) fn consume_signature(&mut self) -> Result<(), Error> { + self.signatures = self + .signatures + .checked_sub(1) + .ok_or(Error::MaximumSignatureChecksExceeded)?; + Ok(()) + } + + #[inline] + fn consume_build_chain_call(&mut self) -> Result<(), Error> { + self.build_chain_calls = self + .build_chain_calls + .checked_sub(1) + .ok_or(Error::MaximumPathBuildCallsExceeded)?; + Ok(()) + } + + #[inline] + pub(crate) fn consume_name_constraint_comparison(&mut self) -> Result<(), Error> { + self.name_constraint_comparisons = self + .name_constraint_comparisons + .checked_sub(1) + .ok_or(Error::MaximumNameConstraintComparisonsExceeded)?; + Ok(()) + } +} + +impl Default for Budget { + fn default() -> Self { + Self { + // This limit is taken from the remediation for golang CVE-2018-16875. However, + // note that golang subsequently implemented AKID matching due to this limit + // being hit in real applications (see ). + // So this may actually be too aggressive. + signatures: 100, + + // This limit is taken from mozilla::pkix, see: + // + build_chain_calls: 200_000, + + // This limit is taken from golang crypto/x509's default, see: + // + name_constraint_comparisons: 250_000, + } + } +} + +fn check_issuer_independent_properties( + cert: &Cert<'_>, + time: UnixTime, + role: Role, + sub_ca_count: usize, + eku: &impl ExtendedKeyUsageValidator, +) -> Result<(), Error> { + // TODO: check_distrust(trust_anchor_subject, trust_anchor_spki)?; + // TODO: Check signature algorithm like mozilla::pkix. + // TODO: Check SPKI like mozilla::pkix. + // TODO: check for active distrust like mozilla::pkix. + + // For cert validation, we ignore the KeyUsage extension. For CA + // certificates, BasicConstraints.cA makes KeyUsage redundant. Firefox + // and other common browsers do not check KeyUsage for end-entities, + // though it would be kind of nice to ensure that a KeyUsage without + // the keyEncipherment bit could not be used for RSA key exchange. + + cert.validity + .read_all(Error::BadDer, |value| check_validity(value, time))?; + untrusted::read_all_optional(cert.basic_constraints, Error::BadDer, |value| { + check_basic_constraints(value, role, sub_ca_count) + })?; + untrusted::read_all_optional(cert.eku, Error::BadDer, |input| check_eku(input, eku))?; + + Ok(()) +} + +fn check_eku( + input: Option<&mut untrusted::Reader<'_>>, + eku: &impl ExtendedKeyUsageValidator, +) -> Result<(), Error> { + match input { + Some(input) if input.at_end() => Err(Error::EmptyEkuExtension), + Some(input) => eku.validate(KeyPurposeIdIter { input }), + None => eku.validate(KeyPurposeIdIter { + input: &mut untrusted::Reader::new(untrusted::Input::from(&[])), + }), + } +} + +// https://tools.ietf.org/html/rfc5280#section-4.1.2.5 +fn check_validity(input: &mut untrusted::Reader<'_>, time: UnixTime) -> Result<(), Error> { + let not_before = UnixTime::from_der(input)?; + let not_after = UnixTime::from_der(input)?; + + if not_before > not_after { + return Err(Error::InvalidCertValidity); + } + if time < not_before { + return Err(Error::CertNotValidYet { time, not_before }); + } + if time > not_after { + return Err(Error::CertExpired { time, not_after }); + } + + // TODO: mozilla::pkix allows the TrustDomain to check not_before and + // not_after, to enforce things like a maximum validity period. We should + // do something similar. + + Ok(()) +} + +// https://tools.ietf.org/html/rfc5280#section-4.2.1.9 +fn check_basic_constraints( + input: Option<&mut untrusted::Reader<'_>>, + role: Role, + sub_ca_count: usize, +) -> Result<(), Error> { + let (is_ca, path_len_constraint) = match input { + Some(input) => { + let is_ca = bool::from_der(input)?; + + // https://bugzilla.mozilla.org/show_bug.cgi?id=985025: RFC 5280 + // says that a certificate must not have pathLenConstraint unless + // it is a CA certificate, but some real-world end-entity + // certificates have pathLenConstraint. + let path_len_constraint = if !input.at_end() { + Some(usize::from(u8::from_der(input)?)) + } else { + None + }; + + (is_ca, path_len_constraint) + } + None => (false, None), + }; + + match (role, is_ca, path_len_constraint) { + (Role::EndEntity, true, _) => Err(Error::CaUsedAsEndEntity), + (Role::Issuer, false, _) => Err(Error::EndEntityUsedAsCa), + (Role::Issuer, true, Some(len)) if sub_ca_count > len => { + Err(Error::PathLenConstraintViolated) + } + _ => Ok(()), + } +} + +/// Additional context for the `RequiredEkuNotFoundContext` error variant. +/// +/// The contents of this type depend on whether the `alloc` feature is enabled. +#[derive(Clone, PartialEq, Eq)] +pub struct RequiredEkuNotFoundContext { + /// The required ExtendedKeyUsage. + #[cfg(feature = "alloc")] + pub required: KeyUsage, + /// The ExtendedKeyUsage OIDs present in the certificate. + #[cfg(feature = "alloc")] + pub present: Vec>, +} + +impl fmt::Debug for RequiredEkuNotFoundContext { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let mut builder = f.debug_struct("RequiredEkuNotFoundContext"); + #[cfg(feature = "alloc")] + builder.field( + "required", + match &self.required.inner { + ExtendedKeyUsage::Required(inner) => inner, + ExtendedKeyUsage::RequiredIfPresent(inner) => inner, + }, + ); + #[cfg(feature = "alloc")] + builder.field("present", &EkuListDebug(&self.present)); + builder.finish() + } +} + +#[cfg(feature = "alloc")] +struct EkuListDebug<'a>(&'a [Vec]); + +#[cfg(feature = "alloc")] +impl fmt::Debug for EkuListDebug<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "[")?; + for (i, part) in self.0.iter().enumerate() { + if i > 0 { + write!(f, ", ")?; + } + + write!(f, "KeyPurposeId(")?; + for (j, part) in part.iter().enumerate() { + if j > 0 { + write!(f, ".")?; + } + write!(f, "{part}")?; + } + write!(f, ")")?; + } + write!(f, "]") + } +} + +/// The expected key usage of a certificate. +/// +/// This type represents the expected key usage of an end entity certificate. Although for most +/// kinds of certificates the extended key usage extension is optional (and so certificates +/// not carrying a particular value in the EKU extension are acceptable). If the extension +/// is present, the certificate MUST only be used for one of the purposes indicated. +/// +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub struct KeyUsage { + inner: ExtendedKeyUsage, +} + +impl KeyUsage { + /// Construct a new [`KeyUsage`] as appropriate for server certificate authentication. + /// + /// As specified in , this does not require the certificate to specify the eKU extension. + pub const fn server_auth() -> Self { + Self::required_if_present(EKU_SERVER_AUTH) + } + + /// Construct a new [`KeyUsage`] as appropriate for client certificate authentication. + /// + /// As specified in <>, this does not require the certificate to specify the eKU extension. + pub const fn client_auth() -> Self { + Self::required_if_present(EKU_CLIENT_AUTH) + } + + /// Construct a new [`KeyUsage`] requiring a certificate to support the specified OID. + pub const fn required(oid: &'static [u8]) -> Self { + Self { + inner: ExtendedKeyUsage::Required(KeyPurposeId::new(oid)), + } + } + + /// Construct a new [`KeyUsage`] requiring a certificate to support the specified OID, if the certificate has EKUs. + pub const fn required_if_present(oid: &'static [u8]) -> Self { + Self { + inner: ExtendedKeyUsage::RequiredIfPresent(KeyPurposeId::new(oid)), + } + } + + /// Yield the OID values of the required extended key usage. + pub fn oid_values(&self) -> impl Iterator + '_ { + OidDecoder::new( + match &self.inner { + ExtendedKeyUsage::Required(eku) => eku, + ExtendedKeyUsage::RequiredIfPresent(eku) => eku, + } + .oid_value + .as_slice_less_safe(), + ) + } + + /// Human-readable representation of the server authentication OID. + pub const SERVER_AUTH_REPR: &[usize] = &[1, 3, 6, 1, 5, 5, 7, 3, 1]; + /// Human-readable representation of the client authentication OID. + pub const CLIENT_AUTH_REPR: &[usize] = &[1, 3, 6, 1, 5, 5, 7, 3, 2]; +} + +impl ExtendedKeyUsageValidator for KeyUsage { + // https://tools.ietf.org/html/rfc5280#section-4.2.1.12 + fn validate(&self, iter: KeyPurposeIdIter<'_, '_>) -> Result<(), Error> { + let mut empty = true; + #[cfg(feature = "alloc")] + let mut present = Vec::new(); + + for id in iter { + empty = false; + let id = id?; + if self.inner.id() == id { + return Ok(()); + } + + #[cfg(feature = "alloc")] + present.push(id.to_decoded_oid()); + } + + match (empty, self.inner) { + (true, ExtendedKeyUsage::RequiredIfPresent(_)) => Ok(()), + _ => Err(Error::RequiredEkuNotFoundContext( + RequiredEkuNotFoundContext { + #[cfg(feature = "alloc")] + required: Self { inner: self.inner }, + #[cfg(feature = "alloc")] + present, + }, + )), + } + } +} + +impl ExtendedKeyUsageValidator for &V { + fn validate(&self, iter: KeyPurposeIdIter<'_, '_>) -> Result<(), Error> { + (*self).validate(iter) + } +} + +/// A trait for validating the Extended Key Usage (EKU) extensions of a certificate. +pub trait ExtendedKeyUsageValidator { + /// Validate the EKU values in a certificate. + /// + /// `iter` yields the EKU OIDs in the certificate, or an error if the EKU extension + /// is malformed. `validate()` should yield `Ok(())` if the EKU values match the + /// required policy, or an `Error` if they do not. Ideally the `Error` should be + /// `Error::RequiredEkuNotFoundContext` if the policy is not met. + fn validate(&self, iter: KeyPurposeIdIter<'_, '_>) -> Result<(), Error>; +} + +/// Extended Key Usage (EKU) of a certificate. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +enum ExtendedKeyUsage { + /// The certificate must contain the specified [`KeyPurposeId`] as EKU. + Required(KeyPurposeId<'static>), + + /// If the certificate has EKUs, then the specified [`KeyPurposeId`] must be included. + RequiredIfPresent(KeyPurposeId<'static>), +} + +impl ExtendedKeyUsage { + fn id(&self) -> KeyPurposeId<'static> { + match self { + Self::Required(id) => *id, + Self::RequiredIfPresent(id) => *id, + } + } +} + +/// Iterator over [`KeyPurposeId`]s, for use in [`ExtendedKeyUsageValidator`]. +pub struct KeyPurposeIdIter<'a, 'r> { + input: &'r mut untrusted::Reader<'a>, +} + +impl<'a, 'r> Iterator for KeyPurposeIdIter<'a, 'r> { + type Item = Result, Error>; + + fn next(&mut self) -> Option { + if self.input.at_end() { + return None; + } + + Some(der::expect_tag(self.input, der::Tag::OID).map(|oid_value| KeyPurposeId { oid_value })) + } +} + +impl Drop for KeyPurposeIdIter<'_, '_> { + fn drop(&mut self) { + self.input.skip_to_end(); + } +} + +/// An OID value indicating an Extended Key Usage (EKU) key purpose. +#[derive(Clone, Copy)] +pub struct KeyPurposeId<'a> { + oid_value: untrusted::Input<'a>, +} + +impl<'a> KeyPurposeId<'a> { + /// Construct a new [`KeyPurposeId`]. + /// + /// `oid` is the OBJECT IDENTIFIER in bytes. + pub const fn new(oid: &'a [u8]) -> Self { + Self { + oid_value: untrusted::Input::from(oid), + } + } + + /// Yield the OID value as a sequence of `usize` components. + #[cfg(feature = "alloc")] + pub fn to_decoded_oid(&self) -> Vec { + OidDecoder::new(self.oid_value.as_slice_less_safe()).collect() + } +} + +impl fmt::Debug for KeyPurposeId<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "KeyPurposeId(")?; + let decoder = OidDecoder::new(self.oid_value.as_slice_less_safe()); + for (i, part) in decoder.enumerate() { + if i > 0 { + write!(f, ".")?; + } + write!(f, "{part}")?; + } + write!(f, ")") + } +} + +impl PartialEq for KeyPurposeId<'_> { + fn eq(&self, other: &Self) -> bool { + public_values_eq(self.oid_value, other.oid_value) + } +} + +impl Eq for KeyPurposeId<'_> {} + +// id-pkix OBJECT IDENTIFIER ::= { 1 3 6 1 5 5 7 } +// id-kp OBJECT IDENTIFIER ::= { id-pkix 3 } + +// id-kp-serverAuth OBJECT IDENTIFIER ::= { id-kp 1 } +const EKU_SERVER_AUTH: &[u8] = &oid!(1, 3, 6, 1, 5, 5, 7, 3, 1); + +// id-kp-clientAuth OBJECT IDENTIFIER ::= { id-kp 2 } +const EKU_CLIENT_AUTH: &[u8] = &oid!(1, 3, 6, 1, 5, 5, 7, 3, 2); + +struct OidDecoder<'a> { + encoded: &'a [u8], + left: Option, + first: bool, +} + +impl<'a> OidDecoder<'a> { + fn new(encoded: &'a [u8]) -> Self { + Self { + encoded, + left: None, + first: true, + } + } +} + +impl Iterator for OidDecoder<'_> { + type Item = usize; + + fn next(&mut self) -> Option { + if let Some(next) = self.left.take() { + return Some(next); + } + + let mut cur = 0; + for (i, &byte) in self.encoded.iter().enumerate() { + cur = (cur << 8) + usize::from(byte & 0x7f); + if byte & 0x80 > 0 { + continue; + } + + if !self.first { + self.encoded = &self.encoded[i + 1..]; + return Some(cur); + } + + let (cur, next) = match cur { + ..=39 => (0, cur), + 40..=79 => (1, cur - 40), + _ => (2, cur - 80), + }; + + self.encoded = &self.encoded[i + 1..]; + self.first = false; + self.left = Some(next); + return Some(cur); + } + + None + } +} + +fn loop_while_non_fatal_error<'a, V: IntoIterator + 'a>( + default_error: Error, + values: V, + mut f: impl FnMut(V::Item) -> Result<&'a TrustAnchor<'a>, ControlFlow>, +) -> Result<&'a TrustAnchor<'a>, ControlFlow> { + let mut error = default_error; + for v in values { + match f(v) { + Ok(anchor) => return Ok(anchor), + // Fatal errors should halt further looping. + res @ Err(ControlFlow::Break(_)) => return res, + // Non-fatal errors should be ranked by specificity and only returned + // once all other path-building options have been exhausted. + Err(ControlFlow::Continue(new_error)) => error = error.most_specific(new_error), + } + } + Err(error.into()) +} + +/// A path for consideration in path building. +/// +/// This represents a partial path because it does not yet contain the trust anchor. It stores +/// the end-entity certificates, and an array of intermediate certificates. +pub(crate) struct PartialPath<'a> { + end_entity: &'a EndEntityCert<'a>, + /// Intermediate certificates, in order from end-entity to trust anchor. + /// + /// Invariant: all values below `used` are `Some`. + intermediates: [Option>; MAX_SUB_CA_COUNT], + /// The number of `Some` values in `intermediates`. + /// + /// The next `Cert` passed to `push()` will be placed at `intermediates[used]`. + /// If this value is 0, the path contains only the end-entity certificate. + used: usize, +} + +impl<'a> PartialPath<'a> { + pub(crate) fn new(end_entity: &'a EndEntityCert<'a>) -> Self { + Self { + end_entity, + intermediates: Default::default(), + used: 0, + } + } + + pub(crate) fn push(&mut self, cert: Cert<'a>) -> Result<(), ControlFlow> { + if self.used >= MAX_SUB_CA_COUNT { + return Err(Error::MaximumPathDepthExceeded.into()); + } + + self.intermediates[self.used] = Some(cert); + self.used += 1; + Ok(()) + } + + fn pop(&mut self) { + debug_assert!(self.used > 0); + if self.used == 0 { + return; + } + + self.used -= 1; + self.intermediates[self.used] = None; + } + + pub(crate) fn node(&self) -> PathNode<'_> { + PathNode { + path: self, + index: self.used, + cert: self.head(), + } + } + + /// Current head of the path. + pub(crate) fn head(&self) -> &Cert<'a> { + self.get(self.used) + } + + /// Get the certificate at index `idx` in the path. + /// + // `idx` must be in the range `0..=self.used`; `idx` 0 thus yields the `end_entity`, + // while subsequent indexes yield the intermediate at `self.intermediates[idx - 1]`. + fn get(&self, idx: usize) -> &Cert<'a> { + match idx { + 0 => self.end_entity, + _ => self.intermediates[idx - 1].as_ref().unwrap(), + } + } +} + +const MAX_SUB_CA_COUNT: usize = 6; + +pub(crate) struct PathNode<'a> { + /// The path we're iterating. + path: &'a PartialPath<'a>, + /// The index of the current node in the path (input for `path.get()`). + index: usize, + /// The [`Cert`] at `index`. + pub(crate) cert: &'a Cert<'a>, +} + +impl<'a> PathNode<'a> { + pub(crate) fn iter(&self) -> PathIter<'a> { + PathIter { + path: self.path, + next: Some(self.index), + } + } + + pub(crate) fn role(&self) -> Role { + match self.index { + 0 => Role::EndEntity, + _ => Role::Issuer, + } + } +} + +pub(crate) struct PathIter<'a> { + path: &'a PartialPath<'a>, + next: Option, +} + +impl<'a> Iterator for PathIter<'a> { + type Item = PathNode<'a>; + + fn next(&mut self) -> Option { + let next = self.next?; + self.next = match next { + 0 => None, + _ => Some(next - 1), + }; + + Some(PathNode { + path: self.path, + index: next, + cert: self.path.get(next), + }) + } +} + +#[derive(Clone, Copy, PartialEq)] +pub(crate) enum Role { + Issuer, + EndEntity, +} + +#[cfg(all(test, feature = "alloc", any(feature = "ring", feature = "aws-lc-rs")))] +mod tests { + use alloc::borrow::ToOwned; + use alloc::string::{String, ToString}; + use std::dbg; + use std::slice; + + use super::*; + use crate::test_utils; + use crate::test_utils::{issuer_params, make_end_entity, make_issuer}; + use crate::trust_anchor::anchor_from_trusted_cert; + use rcgen::{CertifiedIssuer, Issuer, KeyPair, SigningKey}; + + #[test] + fn roundtrip() { + // 2.999.3 -> 1079.3 -> [0x84, 0x37, 0x3] + const ENCODED: &[u8] = &[0x84, 0x37, 0x3]; + let decoded = OidDecoder::new(ENCODED); + assert_eq!(decoded.collect::>(), [2, 999, 3]); + } + + #[test] + fn oid_decoding() { + assert_eq!( + KeyUsage::server_auth().oid_values().collect::>(), + KeyUsage::SERVER_AUTH_REPR + ); + assert_eq!( + KeyUsage::client_auth().oid_values().collect::>(), + KeyUsage::CLIENT_AUTH_REPR + ); + } + + #[test] + fn eku_fail_empty() { + let err = KeyUsage::required(EKU_SERVER_AUTH) + .validate(KeyPurposeIdIter { + input: &mut untrusted::Reader::new(untrusted::Input::from(&[])), + }) + .unwrap_err(); + assert_eq!( + err, + Error::RequiredEkuNotFoundContext(RequiredEkuNotFoundContext { + #[cfg(feature = "alloc")] + required: dbg!(KeyUsage::required(EKU_SERVER_AUTH)), // Cover Debug impl + #[cfg(feature = "alloc")] + present: Vec::new(), + }) + ); + } + + #[test] + fn eku_fail_empty_with_optional() { + let mut empty_eku = untrusted::Reader::new(untrusted::Input::from(&[])); + let validator = KeyUsage::required_if_present(EKU_SERVER_AUTH); + assert_eq!( + check_eku(Some(&mut empty_eku), &validator).unwrap_err(), + Error::EmptyEkuExtension, + ); + } + + #[test] + fn eku_key_purpose_id() { + assert!( + ExtendedKeyUsage::RequiredIfPresent(KeyPurposeId::new(EKU_SERVER_AUTH)).id() + == KeyPurposeId::new(EKU_SERVER_AUTH) + ) + } + + #[test] + fn test_too_many_signatures() { + assert!(matches!( + build_and_verify_degenerate_chain(5, ChainTrustAnchor::NotInChain), + ControlFlow::Break(Error::MaximumSignatureChecksExceeded) + )); + } + + #[test] + fn test_too_many_path_calls() { + assert!(matches!( + dbg!(build_and_verify_degenerate_chain( + 10, + ChainTrustAnchor::InChain + )), + ControlFlow::Break(Error::MaximumPathBuildCallsExceeded) + )); + } + + #[test] + fn longest_allowed_path() { + assert!(build_and_verify_linear_chain(1).is_ok()); + assert!(build_and_verify_linear_chain(2).is_ok()); + assert!(build_and_verify_linear_chain(3).is_ok()); + assert!(build_and_verify_linear_chain(4).is_ok()); + assert!(build_and_verify_linear_chain(5).is_ok()); + assert!(build_and_verify_linear_chain(6).is_ok()); + } + + #[test] + fn path_too_long() { + assert!(matches!( + build_and_verify_linear_chain(7), + Err(ControlFlow::Continue(Error::MaximumPathDepthExceeded)) + )); + } + + #[test] + fn name_constraint_budget() { + // Issue a trust anchor that imposes name constraints. The constraint should match + // the end entity certificate SAN. + let mut ca_cert_params = issuer_params("Constrained Root"); + ca_cert_params.name_constraints = Some(rcgen::NameConstraints { + permitted_subtrees: vec![rcgen::GeneralSubtree::DnsName(".com".into())], + excluded_subtrees: vec![], + }); + let ca_key_pair = KeyPair::generate_for(test_utils::RCGEN_SIGNATURE_ALG).unwrap(); + let ca = CertifiedIssuer::self_signed(ca_cert_params, ca_key_pair).unwrap(); + + // Create a series of intermediate issuers. We'll only use one in the actual built path, + // helping demonstrate that the name constraint budget is not expended checking certificates + // that are not part of the path we compute. + let mut intermediates = Vec::with_capacity(5); + for i in 0..5 { + let intermediate = issuer_params(format!("Intermediate {i}")); + let intermediate_key_pair = + KeyPair::generate_for(test_utils::RCGEN_SIGNATURE_ALG).unwrap(); + // Each intermediate should be issued by the trust anchor. + intermediates.push( + CertifiedIssuer::signed_by(intermediate, intermediate_key_pair, &ca).unwrap(), + ); + } + + // Create an end-entity cert that is issued by the last of the intermediates. + let ee_cert = make_end_entity(intermediates.last().unwrap()); + let ee_cert = EndEntityCert::try_from(ee_cert.cert.der()).unwrap(); + + // We use a custom budget to make it easier to write a test, otherwise it is tricky to + // stuff enough names/constraints into the potential chains while staying within the path + // depth limit and the build chain call limit. + let passing_budget = Budget { + // One comparison against the intermediate's distinguished name. + // One comparison against the EE's distinguished name. + // One comparison against the EE's SAN. + // = 3 total comparisons. + name_constraint_comparisons: 3, + ..Budget::default() + }; + + let anchors = &[anchor_from_trusted_cert(ca.der()).unwrap()]; + let intermediates_der = intermediates + .iter() + .map(|issuer| issuer.der().clone()) + .collect::>(); + + // Validation should succeed with the name constraint comparison budget allocated above. + // This shows that we're not consuming budget on unused intermediates: we didn't budget + // enough comparisons for that to pass the overall chain building. + let path = verify_chain( + anchors, + &intermediates_der, + &ee_cert, + None, + Some(passing_budget), + ) + .unwrap(); + assert_eq!(path.anchor().subject, anchors.first().unwrap().subject); + + let failing_budget = Budget { + // See passing_budget: 2 comparisons is not sufficient. + name_constraint_comparisons: 2, + ..Budget::default() + }; + // Validation should fail when the budget is smaller than the number of comparisons performed + // on the validated path. This demonstrates we properly fail path building when too many + // name constraint comparisons occur. + let result = verify_chain( + anchors, + &intermediates_der, + &ee_cert, + None, + Some(failing_budget), + ); + + assert!(matches!( + result, + Err(ControlFlow::Break( + Error::MaximumNameConstraintComparisonsExceeded + )) + )); + } + + /// This test builds a PKI like the following diagram depicts. We first verify + /// that we can build a path EE -> B -> A -> TA. Next we supply a custom path verification + /// function that rejects the B->A path, and verify that we build a path EE -> B -> C -> TA. + /// + /// ┌───────────┐ + /// │ │ + /// │ TA │ + /// │ │ + /// └───┬───┬───┘ + /// │ │ + /// │ │ + /// ┌────────┐◄┘ └──►┌────────┐ + /// │ │ │ │ + /// │ A │ │ C │ + /// │ │ │ │ + /// └────┬───┘ └───┬────┘ + /// │ │ + /// │ │ + /// │ ┌─────────┐ │ + /// └──►│ │◄──┘ + /// │ B │ + /// │ │ + /// └────┬────┘ + /// │ + /// │ + /// │ + /// ┌────▼────┐ + /// │ │ + /// │ EE │ + /// │ │ + /// └─────────┘ + #[test] + fn test_reject_candidate_path() { + // Create a trust anchor, and use it to issue two distinct intermediate certificates, each + // with a unique subject and keypair. + let trust_anchor = make_issuer("Trust Anchor"); + let trust_anchor_cert = Cert::from_der(untrusted::Input::from(trust_anchor.der())).unwrap(); + let trust_anchors = &[anchor_from_trusted_cert(trust_anchor.der()).unwrap()]; + + let intermediate_a = make_intermediate("Intermediate A", &trust_anchor); + let intermediate_c = make_intermediate("Intermediate C", &trust_anchor); + + // Next, create an intermediate that is issued by both of the intermediates above. + // Both should share the same subject, and key pair, but will differ in the issuer. + let (intermediate_b, intermediate_b_a_cert, intermediate_b_c_cert) = { + let key = KeyPair::generate_for(test_utils::RCGEN_SIGNATURE_ALG).unwrap(); + let params = issuer_params("Intermediate"); + let intermediate_b_a_cert = params.signed_by(&key, &intermediate_a).unwrap(); + let intermediate_b_c_cert = params.signed_by(&key, &intermediate_c).unwrap(); + let issuer = Issuer::new(params, key); + (issuer, intermediate_b_a_cert, intermediate_b_c_cert) + }; + + let intermediates = &[ + intermediate_a.der().clone(), + intermediate_c.der().clone(), + intermediate_b_a_cert.der().clone(), + intermediate_b_c_cert.der().clone(), + ]; + + // Create an end entity certificate signed by the keypair of the intermediates created above. + let ee = make_end_entity(&intermediate_b); + let ee_cert = &EndEntityCert::try_from(ee.cert.der()).unwrap(); + + // We should be able to create a valid path from EE to trust anchor. + let path = verify_chain(trust_anchors, intermediates, ee_cert, None, None).unwrap(); + let path_intermediates = path.intermediate_certificates().collect::>(); + + // We expect that without applying any additional constraints, that the path will be + // EE -> intermediate_b_a -> intermediate_a -> trust_anchor. + let intermediate_a_cert = + Cert::from_der(untrusted::Input::from(intermediate_a.der())).unwrap(); + assert_eq!(path_intermediates.len(), 2); + assert_eq!( + path_intermediates[0].issuer(), + intermediate_a_cert.subject() + ); + assert_eq!(path_intermediates[1].issuer(), trust_anchor_cert.subject()); + + // Now, we'll create a function that will reject the intermediate_b_a path. + let expected_chain = |path: &VerifiedPath<'_>| { + for intermediate in path.intermediate_certificates() { + // Reject any intermediates issued by intermediate A. + if intermediate.issuer() == intermediate_a_cert.subject() { + return Err(Error::UnknownIssuer); + } + } + + Ok(()) + }; + + // We should still be able to build a valid path. + let path = verify_chain( + trust_anchors, + intermediates, + ee_cert, + Some(&expected_chain), + None, + ) + .unwrap(); + let path_intermediates = path.intermediate_certificates().collect::>(); + + // We expect that the path will now be + // EE -> intermediate_b_c -> intermediate_c -> trust_anchor. + let intermediate_c_cert = + Cert::from_der(untrusted::Input::from(intermediate_c.der())).unwrap(); + assert_eq!(path_intermediates.len(), 2); + assert_eq!( + path_intermediates[0].issuer(), + intermediate_c_cert.subject() + ); + assert_eq!(path_intermediates[1].issuer(), trust_anchor_cert.subject()); + } + + fn make_intermediate( + org_name: impl Into, + issuer: &Issuer<'_, impl SigningKey>, + ) -> CertifiedIssuer<'static, KeyPair> { + let params = issuer_params(org_name); + let key = KeyPair::generate_for(test_utils::RCGEN_SIGNATURE_ALG).unwrap(); + CertifiedIssuer::signed_by(params, key, issuer).unwrap() + } + + fn build_and_verify_degenerate_chain( + intermediate_count: usize, + trust_anchor: ChainTrustAnchor, + ) -> ControlFlow { + let ca = make_issuer("Bogus Subject"); + let mut intermediate_chain = IntermediateChain::new(intermediate_count, true, &ca); + + let verify_trust_anchor = match trust_anchor { + ChainTrustAnchor::InChain => make_issuer("Bogus Trust Anchor"), + ChainTrustAnchor::NotInChain => ca, + }; + + let ee_cert = make_end_entity(&intermediate_chain.last_issuer); + let ee_cert = EndEntityCert::try_from(ee_cert.cert.der()).unwrap(); + let webpki_ta = anchor_from_trusted_cert(verify_trust_anchor.der()).unwrap(); + if matches!(trust_anchor, ChainTrustAnchor::InChain) { + // Note: we clone the trust anchor DER here because we can't move it into the chain + // as it's loaned to webpki_ta above. + intermediate_chain + .chain + .insert(0, verify_trust_anchor.der().to_owned()) + } + + verify_chain( + &[webpki_ta], + &intermediate_chain.chain, + &ee_cert, + None, + None, + ) + .map(|_| ()) + .unwrap_err() + } + + #[cfg(feature = "alloc")] + enum ChainTrustAnchor { + NotInChain, + InChain, + } + + fn build_and_verify_linear_chain(chain_length: usize) -> Result<(), ControlFlow> { + let ca = make_issuer(format!("Bogus Subject {chain_length}")); + let intermediate_chain = IntermediateChain::new(chain_length, false, &ca); + + let anchor = anchor_from_trusted_cert(ca.der()).unwrap(); + let anchors = slice::from_ref(&anchor); + + let ee_cert = make_end_entity(&intermediate_chain.last_issuer); + let ee_cert = EndEntityCert::try_from(ee_cert.cert.der()).unwrap(); + + let expected_chain = |path: &VerifiedPath<'_>| { + assert_eq!(path.anchor().subject, anchor.subject); + assert!(public_values_eq(path.end_entity().subject, ee_cert.subject)); + assert_eq!(path.intermediate_certificates().count(), chain_length); + + let intermediate_certs = intermediate_chain + .chain + .iter() + .map(|der| Cert::from_der(untrusted::Input::from(der)).unwrap()) + .collect::>(); + + for (cert, expected) in path + .intermediate_certificates() + .rev() + .zip(intermediate_certs.iter()) + { + assert!(public_values_eq(cert.subject, expected.subject)); + assert_eq!(cert.der(), expected.der()); + } + + for (cert, expected) in path + .intermediate_certificates() + .zip(intermediate_certs.iter().rev()) + { + assert!(public_values_eq(cert.subject, expected.subject)); + assert_eq!(cert.der(), expected.der()); + } + + Ok(()) + }; + + verify_chain( + anchors, + &intermediate_chain.chain, + &ee_cert, + Some(&expected_chain), + None, + ) + .map(|_| ()) + } + + struct IntermediateChain { + last_issuer: Issuer<'static, KeyPair>, + chain: Vec>, + } + + impl IntermediateChain { + fn new(chain_length: usize, all_same_subject: bool, ca_cert: &Issuer<'_, KeyPair>) -> Self { + let mut chain = Vec::with_capacity(chain_length); + + let mut prev = None; + for i in 0..chain_length { + let issuer = match &prev { + Some(prev) => prev, + None => ca_cert, + }; + + let intermediate = issuer_params(match all_same_subject { + true => "Bogus Subject".to_string(), + false => format!("Bogus Subject {i}"), + }); + + let key_pair = KeyPair::generate_for(test_utils::RCGEN_SIGNATURE_ALG).unwrap(); + let cert = intermediate.signed_by(&key_pair, issuer).unwrap(); + + chain.push(cert.der().clone()); + prev = Some(Issuer::new(intermediate, key_pair)); + } + + Self { + last_issuer: prev.unwrap(), + chain, + } + } + } + + fn verify_chain<'a>( + trust_anchors: &'a [TrustAnchor<'a>], + intermediate_certs: &'a [CertificateDer<'a>], + ee_cert: &'a EndEntityCert<'a>, + verify_path: Option<&dyn Fn(&VerifiedPath<'_>) -> Result<(), Error>>, + budget: Option, + ) -> Result, ControlFlow> { + use core::time::Duration; + + let time = UnixTime::since_unix_epoch(Duration::from_secs(0x1fed_f00d)); + let mut path = PartialPath::new(ee_cert); + let opts = ChainOptions { + eku: KeyUsage::server_auth(), + supported_sig_algs: crate::ALL_VERIFICATION_ALGS, + trust_anchors, + intermediate_certs, + revocation: None, + }; + + match opts.build_chain_inner( + &mut path, + time, + verify_path, + 0, + &mut budget.unwrap_or_default(), + ) { + Ok(anchor) => Ok(VerifiedPath::new(ee_cert, anchor, path)), + Err(err) => Err(err), + } + } +} diff --git a/http/vendor/rustls-webpki/src/x509.rs b/http/vendor/rustls-webpki/src/x509.rs new file mode 100644 index 0000000..b0f9e13 --- /dev/null +++ b/http/vendor/rustls-webpki/src/x509.rs @@ -0,0 +1,119 @@ +// Copyright 2015 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use crate::der::{self, CONSTRUCTED, CONTEXT_SPECIFIC, DerIterator, FromDer}; +use crate::error::{DerTypeId, Error}; +use crate::subject_name::GeneralName; + +pub(crate) struct Extension<'a> { + pub(crate) critical: bool, + pub(crate) id: untrusted::Input<'a>, + pub(crate) value: untrusted::Input<'a>, +} + +impl Extension<'_> { + pub(crate) fn unsupported(&self, policy: UnknownExtensionPolicy) -> Result<(), Error> { + match (policy, self.critical) { + (UnknownExtensionPolicy::Strict, true) => Err(Error::UnsupportedCriticalExtension), + _ => Ok(()), + } + } +} + +impl<'a> FromDer<'a> for Extension<'a> { + fn from_der(reader: &mut untrusted::Reader<'a>) -> Result { + let id = der::expect_tag(reader, der::Tag::OID)?; + let critical = bool::from_der(reader)?; + let value = der::expect_tag(reader, der::Tag::OctetString)?; + Ok(Extension { + id, + critical, + value, + }) + } + + const TYPE_ID: DerTypeId = DerTypeId::Extension; +} + +pub(crate) fn set_extension_once( + destination: &mut Option, + parser: impl Fn() -> Result, +) -> Result<(), Error> { + match destination { + // The extension value has already been set, indicating that we encountered it + // more than once in our serialized data. That's invalid! + Some(..) => Err(Error::ExtensionValueInvalid), + None => { + *destination = Some(parser()?); + Ok(()) + } + } +} + +pub(crate) fn remember_extension( + extension: &Extension<'_>, + ext_policy: UnknownExtensionPolicy, + mut handler: impl FnMut(u8) -> Result<(), Error>, +) -> Result<(), Error> { + // ISO arc for standard certificate and CRL extensions. + // https://www.rfc-editor.org/rfc/rfc5280#appendix-A.2 + static ID_CE: [u8; 2] = oid![2, 5, 29]; + + if extension.id.len() != ID_CE.len() + 1 + || !extension.id.as_slice_less_safe().starts_with(&ID_CE) + { + return extension.unsupported(ext_policy); + } + + // safety: we verify len is non-zero and has the correct prefix above. + let last_octet = *extension.id.as_slice_less_safe().last().unwrap(); + handler(last_octet) +} + +#[derive(Clone, Copy, Debug, Default)] +pub(crate) enum UnknownExtensionPolicy { + #[default] + Strict, + IgnoreCritical, +} + +/// A certificate revocation list (CRL) distribution point name, describing a source of +/// CRL information for a given certificate as described in RFC 5280 section 4.2.3.13[^1]. +/// +/// [^1]: +pub(crate) enum DistributionPointName<'a> { + /// The distribution point name is a relative distinguished name, relative to the CRL issuer. + NameRelativeToCrlIssuer, + /// The distribution point name is a sequence of [GeneralName] items. + FullName(DerIterator<'a, GeneralName<'a>>), +} + +impl<'a> FromDer<'a> for DistributionPointName<'a> { + fn from_der(reader: &mut untrusted::Reader<'a>) -> Result { + // RFC 5280 section §4.2.1.13: + // When the distributionPoint field is present, it contains either a + // SEQUENCE of general names or a single value, nameRelativeToCRLIssuer + const FULL_NAME_TAG: u8 = CONTEXT_SPECIFIC | CONSTRUCTED; + const NAME_RELATIVE_TO_CRL_ISSUER_TAG: u8 = CONTEXT_SPECIFIC | CONSTRUCTED | 1; + + let (tag, value) = der::read_tag_and_get_value(reader)?; + match tag { + FULL_NAME_TAG => Ok(DistributionPointName::FullName(DerIterator::new(value))), + NAME_RELATIVE_TO_CRL_ISSUER_TAG => Ok(DistributionPointName::NameRelativeToCrlIssuer), + _ => Err(Error::BadDer), + } + } + + const TYPE_ID: DerTypeId = DerTypeId::DistributionPointName; +} diff --git a/http/vendor/rustls/.cargo-checksum.json b/http/vendor/rustls/.cargo-checksum.json new file mode 100644 index 0000000..f111c14 --- /dev/null +++ b/http/vendor/rustls/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{".cargo_vcs_info.json":"62a5ba9c90a96ea0b58ad19d9000f615c59b3e4156179b99345cdce4ec0dee9a",".clippy.toml":"9b9db19a4fa5a982c6af00c29aaabb16edd8d3b72ac00ad60edd78ace574b281","Cargo.lock":"bf67b48e76399a9dd74d2e228f0dd99262884316321ed8631176bfec314e6ba4","Cargo.toml":"3c7dca97723b68026a35f6f0a316b57dcc0365d21b88e470c9fc59ff8b3dc14d","Cargo.toml.orig":"ecca8bd0683434348af5611cec6b31a5f58e6df9dda347495a1796ea37023878","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-ISC":"7cfafc877eccc46c0e346ccbaa5c51bb6b894d2b818e617d970211e232785ad4","LICENSE-MIT":"709e3175b4212f7b13aa93971c9f62ff8c69ec45ad8c6532a7e0c41d7a7d6f8c","README.md":"1f3cec2c07d17bf1c3860fa6a692953fd456315134a1abe79ae4cc0c8cc1ca35","benches/benchmarks.rs":"4a249cd0b24459845608f2741f3cb70df1396a94b1e6532ab7854d1b12001bc9","build.rs":"380b9a051325baa7d4957bd9a4f1a637c27a663610b1b502f9524530f6995f4d","examples/internal/test_ca.rs":"bcb952d082cc46e53e8ef0ac547cda0cd990e7d36f0e9512448aa5ef4dd5e056","src/bs_debug.rs":"4e4ff4ee2d1db612ba7367e88ee587d525a973167c87b28bb2b35555a9eda27b","src/builder.rs":"3cfebc1faeb5e2b7fbb8ede68aca1240c7ba69061f3381a1a4ded87f11bf5d6a","src/check.rs":"8e5b8a35aebe931c60afa009159a398cf81f300c21898d2002fec88b42d13ad7","src/client/builder.rs":"477ece7d60eecb8062341878cf541fc32ce02a1987f5790117b218ebc5b2ed7e","src/client/client_conn.rs":"e496dd0d588bfb5fd42e6c721f723925184f98399b2fd234b3814845e53401d6","src/client/common.rs":"c745f89b8fd2381118dda319ab69c71a410212d879d380fb8205aa74ece52b48","src/client/ech.rs":"9563d93c649cd8abf159d4fcf9096284d6f661372440c279a78d807d58afd80d","src/client/handy.rs":"7137eeea1cbd8df5a8620e5934a2c3a6889d992caf45c5b13f33072c46ddefb1","src/client/hs.rs":"77a6dbbaddc9cb5da062516bda9ab5e814af4db6263adb223d9b0245b17e1b0f","src/client/test.rs":"7e1b05243a6315e2c061fa28729067b0bab8cf8982760765bc83090a1add5e27","src/client/tls12.rs":"b43cda1428f0eace5dd71a65e6f2c11adcbc152c23fd8f06151987d6aad5238b","src/client/tls13.rs":"818650319e7e48148eb947b2659f4e40a0d67a8b6a7657f62c864401b3ffc888","src/common_state.rs":"728270f0e4e5e17f22a2b5d8eab419a4d903fbdd045aaa79727481f90b27929a","src/compress.rs":"c8c969fc3c8d2c5294652396b2f04def4d58276c0fab634484f60cf525945db3","src/conn.rs":"ec079b9e98de995942f95981e4913e1abec530cbc69130bce75d9b00cad7f66c","src/conn/kernel.rs":"ecdbb41cd6e4aa95c33a16584723befe6b310754452174cee9ab201917ffb87e","src/conn/unbuffered.rs":"d971c9c046b03e6a2147ab6f99635cf5272083d7c677d257403d7d40c887447f","src/crypto/aws_lc_rs/hpke.rs":"3ebd35dbd22cf7914288565ab6946be7b243e6c61f079e18cb0f13075a368d68","src/crypto/aws_lc_rs/mod.rs":"81a60a0e447dbaad5e6986a3b7b039186f435ccdded702557f18f5c862388a44","src/crypto/aws_lc_rs/pq/hybrid.rs":"a1ac53e228fe7bb6851b3a73b1ba4aa64f09bdbc77a09053f59ae89c8ea152b8","src/crypto/aws_lc_rs/pq/mlkem.rs":"431389d968ac98aba0a7c6b480d7379a788ac5a6eb77c11cc6df41054515e8b7","src/crypto/aws_lc_rs/pq/mod.rs":"91edf8221f00d573151bb064badee925afb98a86cb37c1aaf7e23014f3956bf7","src/crypto/aws_lc_rs/sign.rs":"972f4deb09c5b64091bc9e16bd8062e39aceffb94bad5cc77ab58af066e35543","src/crypto/aws_lc_rs/ticketer.rs":"a16431d3ac21b944e6b43a78f930e13bd82603483b85cfa823f43f2a86eb0e32","src/crypto/aws_lc_rs/tls12.rs":"9e3a9220b68ce2a340d2289d376107bf4b75bc73319d1562c2800c5c01476d28","src/crypto/aws_lc_rs/tls13.rs":"e9998aa39049aa886c34c7ffb0da3b8d74388ce823bd310d07e1cd83b3559857","src/crypto/cipher.rs":"067842d11b0f2d373ced097392503c36eb318e685d85e1147048c7fbad421672","src/crypto/hash.rs":"eaa21b2d8f11afb9f5e41794e3461bcc18c950c53153d1fc37dfd23e3bdc1094","src/crypto/hmac.rs":"82ac9b1da0295b0ab70adec4ce321fb87d7873f530652a8b86397655042d035b","src/crypto/hpke.rs":"b65ace9c09cc0f83888c000b369376d8b8ca8a49e016d1aa0a9691c7921fdfbc","src/crypto/mod.rs":"46cb1c195e52824c98ea11129c93cbab03d06fb0c3a6daed81a3bab6f9f79e12","src/crypto/ring/hash.rs":"d4b594369971c8e8dc275a85beea83b51f5134174a4b37f620e130a51266d6ea","src/crypto/ring/hmac.rs":"7df8a4c33176c4e53306c23285ed965c9e35e0aebcc6fd03f1cd68759122ae94","src/crypto/ring/kx.rs":"d385431f42e76b7aa8bd0749ea256da268239d762114b40a37bee8306b07229d","src/crypto/ring/mod.rs":"b43827457ae0248f1ec3888464d40875f80e60b2d785e38517c79dda819b7675","src/crypto/ring/quic.rs":"5f6df314c0d7a3988a2cfb4e98a910bf5926b11a4771a4a420a2205274ab8967","src/crypto/ring/sign.rs":"6bb88454d5751ce1262d68c670ba41a52f88cd152b75d0740743ef603a43f650","src/crypto/ring/ticketer.rs":"2ec1193097d3032fc31dda08277cfb0fcb8defc6667af09d4ff1bd16be95eba4","src/crypto/ring/tls12.rs":"a3a65ebd7cf6fe7157dd19500d35ac7a948970fc64f94909ec4cc22e889e3a44","src/crypto/ring/tls13.rs":"2d093ce74d9ad824ed15f0a18abf5d845fd701a5b8de2d7db088e706dd49ab62","src/crypto/signer.rs":"b097775c0b30d507255824a8ac65d8d7440e723b16a9e91036e0d096a3d7b071","src/crypto/tls12.rs":"b729e02f64415570ba68fdde0a17cfaa60062f4d694001658b0467672a4e626d","src/crypto/tls13.rs":"feec69f36dcc738ccf735bc69e12a767857d8b52ad9af139b2b8584990b651d3","src/enums.rs":"f688a062b2f395d77cff37fffaf3eb393fe5c81091f28b21a13f0e7323aa8478","src/error.rs":"d85c232735d313be3661d564c2858fe26ebe72b203a127c3a681ef44d3c95ffd","src/hash_hs.rs":"6a03da8c8aea2f44f162843bc803a0dfb683b4b99137e5e5f5a6dd7978b02849","src/key_log.rs":"6aeb8c45365e6d53c51246fe8773243096b8c6806274cdcc3ffd1bb82fe360e9","src/key_log_file.rs":"cd836c370aa8d611e1f6e148ab51be682c19ba698a8d8c224f4eb0a25cbd78dc","src/lib.rs":"a88a095f061d679a88d255252c881509348fbc29decc10829befa56020003e3f","src/limited_cache.rs":"a53eb38036ab1db04fe7c561d804076690631dedb17040eaa006f1264cfed097","src/lock.rs":"a4d9befd9a53e7dfbd7fb5d30ca16bcdd54e61f3fc9b353992cd45928818d70e","src/manual/defaults.rs":"71e854184d355b71a96280d82f3e83224491300e861655916d76f44325bf626a","src/manual/features.rs":"a7fecd590287388215fa6bcc6403f425897f3d4ea4f44b72a5dee9bfa2ee8345","src/manual/fips.rs":"1e2cd9db42896c0504ae229190f5dca8b540ef5939c5382a5b718b6fc94abe45","src/manual/howto.rs":"df03dcc9abd0e8c11c13573680d43c84fd92876e4b128fb8bd881a58e07a0ae2","src/manual/implvulns.rs":"b42abb13ce142e83da012f7fa47759091c43216628abd46563de9910748efe5b","src/manual/mod.rs":"45e5d510140d668553030695a45e6ad50da2274e097e3e8fa8900446944a7576","src/manual/tlsvulns.rs":"9d2dc1d4f8f5703b67eb159d698325788863795848a246e36bef779dbba252be","src/msgs/alert.rs":"cf85febb6f1bd2719dd4767f6dea61468e2cee211f507956e93cfe79a9139afc","src/msgs/base.rs":"b6bb842fcfdf2d800e0594cb63c574663e335d4725dc870ee5fb26256f9eba64","src/msgs/ccs.rs":"61117e8e8cc2fb7b030360f959b66d6392d34a601f4ae1dc7276bb444462a742","src/msgs/codec.rs":"fa53201ef4387a453c626c37138a6a2de2d2ff13d85c0ec34f8b13ee20daeeaf","src/msgs/deframer/buffers.rs":"48bb18eff4e5859ec56aba8910488a791457afabc79feba0b09375e11bcca459","src/msgs/deframer/handshake.rs":"e7309acb70aa406dbd6c2c35c17e9d8fe036e9d24e4d29b362b37aa59bae9944","src/msgs/deframer/mod.rs":"bab59c49aa59b4d44e49928ab3aa6b58a5d167412585017bdae88cd32ce23847","src/msgs/enums.rs":"c2e12839e5490d78089d078b856dd3621ea6bc004d6f15e4d86bc4e5ca0eba5e","src/msgs/ffdhe_groups.rs":"22a2abdede92e082300998e0b0d49cc915a995713db2cdd811b4ff3502c1c619","src/msgs/fragmenter.rs":"c324f9ac144999ec36673736d0ef026122be9d4f6eb1f2908c01461cebe1122d","src/msgs/handshake.rs":"08219f5e36f75163f2c64e3dbf1a4506ef0d1266a42791e33863609225f0c3c8","src/msgs/handshake_test.rs":"bb73da98b08bfeea59762441c56a5aa0d9a17f30468ef5f6f87d8feb6cc1ef28","src/msgs/macros.rs":"f8f99b70d11e611eba54fbfd599f6df9bd1072dd099aeb1a954352373cc18617","src/msgs/message/inbound.rs":"85c75ca765f5f7ce70b2f1afbb4d7a1568c1098e7be5267a16a4cb20b50b7ed5","src/msgs/message/mod.rs":"f1bdfa1ee08e31e54c85dd1c47d090afee672bd50bb6074aaa9c51d08feae3bf","src/msgs/message/outbound.rs":"fb214090aff53ea7228519feeac4444fa4b0f389c9af6dc062bf6efbe6c8a8ff","src/msgs/message_test.rs":"b3889ee3db6b8a28241fc1795209e2202f942445d8ec8ed0b08424ad6ad56dd0","src/msgs/mod.rs":"39c54a233a8bd46497c27b3e2626d8aee173d4c41ec8670386bb8c1f19249d07","src/msgs/persist.rs":"33ae762fe42981379082622bd66b2133e224cbaef012535834a4f2eeeaef9a72","src/polyfill.rs":"a6c6dcb5c42aa481099e60b85fd16d84559daa68bbef215c5cb02f93d5c65bec","src/quic.rs":"f2588a74ab5a0543b1ef2deeec0b04c5ea23c0dd81adf40623c178307f3145a7","src/rand.rs":"c0c55d130516c8415836187c9050ecb5269ed7b51f65d70b40305f05f9ba57fb","src/record_layer.rs":"299c725f5bb3e032ecb17e9d1b228a1fa6fc580714c1470d5ff93c54592dc97d","src/server/builder.rs":"58e8cf2a3655dd1b48876f684dd3642c7dd09fea8162480bbe2feb70b7ab238e","src/server/common.rs":"aef13bfc295f17218aa9b157f69c6fdfb9802ee90263acd43e880465a707bb20","src/server/handy.rs":"85ce7ea135eb5582703cb41eb8a5ec7d1d6b9266a130935d291eb71c1327394d","src/server/hs.rs":"5cfe9298ddf83d22786870460dd22b803d450ae4f0cc13e1e83c67512a24838f","src/server/server_conn.rs":"9447faf6672a4542e6a39a8e35628a9f9730e7091e91cf5df0adaab30024196d","src/server/test.rs":"dd16d68359b782dd4062a7ced14add95b187f8f9a67f72b17d8664abceca0aa4","src/server/tls12.rs":"4db5408886f09341063bde2d143f3bc29c2e4456c942fd1d16309dd4bcd3371c","src/server/tls13.rs":"a399e36edbda2f10d2b1e000d30555a4d8e23a40969d3121895bcb2f2be9758c","src/stream.rs":"25758eff9f145099e127fe74b30d27347c13bfa87351749e90a0bb8a0d02a443","src/suites.rs":"c30424784a78519c041f18200c0e05375b44e0ba32e60a56643e4ee0d4c9c89f","src/test_macros.rs":"e5f98aa388375cc195cef7bae2cdba8b33c795ce48e8ff228fbfef153a493c47","src/ticketer.rs":"b722e6be43f8920ca495e4a3cbd624a4e69d61e1ad7584cfae0d8bc06429290a","src/time_provider.rs":"cdc75369bb353ca1edfb1d700a6467e42779c1c0cba5d5bd7d9f67f392ea92b1","src/tls12/mod.rs":"159fb6a519534986e1d1fd2326d30ffa0422650d9fe636c3dac8a5bd113c7c8b","src/tls13/key_schedule.rs":"dfe3a46dc72f4b175c70f0e0504819697a4876eed1e68715348d3f30585185cf","src/tls13/mod.rs":"f22e73dd261d1cc94076a9d3e0147352d7aa4c86872566bb79c93a8ad9f1c1a7","src/vecbuf.rs":"ab3129d12dbf01c946586f83ebf4fa00c5aac778315948e000f595f14a77ff6c","src/verify.rs":"b663615e265fede551c613f20e187d08ce6975c9ab4465e5538add685ea75de7","src/verifybench.rs":"f4ef5158bc5e86fb160f9d3fdab34d6a56d731440d422f6dfdd3f9ec5949a5a2","src/versions.rs":"125d9981b8c02ed6dcbabfdd76721fef3537f41d424ac1fb79e088331061fb22","src/webpki/anchors.rs":"1caba02e098ff418429943b0ae8bc178af4994152a3d2a18327ac73392e4f4bd","src/webpki/client_verifier.rs":"c6051e79858a70ce746fb55208751a429c691c1bb76bcaca238be310ae11d652","src/webpki/mod.rs":"eeb6747164b7a1776afebb6e50bc400a8dc0a9cbe327a5beabdfcc0a276fd768","src/webpki/server_verifier.rs":"1678d02f7fa352b990915de691959e1d90309ba631b714992afd1e98600cb301","src/webpki/verify.rs":"fcbc90dc30793cbe7f15f363fda793d6e08a132a82d003c1f9e88019a6e1f2b4","src/x509.rs":"e036e80ceb688d1b7ff2ff82a63e99545678b262cf5af0c331fbebc714db4444"},"package":"6b92b125634d9b795e7beca796cc790df15a7fb38323bf3196fda83292d06b1f"} \ No newline at end of file diff --git a/http/vendor/rustls/.cargo_vcs_info.json b/http/vendor/rustls/.cargo_vcs_info.json new file mode 100644 index 0000000..ae5573e --- /dev/null +++ b/http/vendor/rustls/.cargo_vcs_info.json @@ -0,0 +1,6 @@ +{ + "git": { + "sha1": "642a10300a1e703279bdc70e73f7e6db8d99ccbf" + }, + "path_in_vcs": "rustls" +} \ No newline at end of file diff --git a/http/vendor/rustls/.clippy.toml b/http/vendor/rustls/.clippy.toml new file mode 100644 index 0000000..8b79edd --- /dev/null +++ b/http/vendor/rustls/.clippy.toml @@ -0,0 +1,6 @@ +upper-case-acronyms-aggressive = true + +disallowed-types = [ + { path = "std::sync::Arc", reason = "must use Arc from sync module to support downstream forks targeting architectures without atomic ptrs" }, + { path = "std::sync::Weak", reason = "must use Weak from sync module to support downstream forks targeting architectures without atomic ptrs" }, +] diff --git a/http/vendor/rustls/Cargo.lock b/http/vendor/rustls/Cargo.lock new file mode 100644 index 0000000..bef56fa --- /dev/null +++ b/http/vendor/rustls/Cargo.lock @@ -0,0 +1,1191 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + +[[package]] +name = "alloc-no-stdlib" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" + +[[package]] +name = "alloc-stdlib" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e76a019e91224d279006ff972f1e984179a6e9feb050adba6ce8274aef23195" +dependencies = [ + "alloc-no-stdlib", +] + +[[package]] +name = "anstream" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" + +[[package]] +name = "anstyle-parse" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.61.2", +] + +[[package]] +name = "asn1-rs" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7f43a50ac4fdca5df8e885c21b835997f0a1cdee65494a6847694a98652d9d8" +dependencies = [ + "asn1-rs-derive", + "asn1-rs-impl", + "displaydoc", + "nom", + "num-traits", + "rusticata-macros", + "thiserror", + "time", +] + +[[package]] +name = "asn1-rs-derive" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3109e49b1e4909e9db6515a30c633684d68cdeaa252f215214cb4fa1a5bfee2c" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "asn1-rs-impl" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + +[[package]] +name = "aws-lc-fips-sys" +version = "0.13.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3d619165468401dec3caa3366ebffbcb83f2f31883e5b3932f8e2dec2ddc568" +dependencies = [ + "bindgen", + "cc", + "cmake", + "dunce", + "fs_extra", + "regex", +] + +[[package]] +name = "aws-lc-rs" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ec2f1fc3ec205783a5da9a7e6c1509cc69dedf09a1949e412c1e18469326d00" +dependencies = [ + "aws-lc-fips-sys", + "aws-lc-sys", + "untrusted 0.7.1", + "zeroize", +] + +[[package]] +name = "aws-lc-sys" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a2f9779ce85b93ab6170dd940ad0169b5766ff848247aff13bb788b832fe3f4" +dependencies = [ + "cc", + "cmake", + "dunce", + "fs_extra", +] + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bencher" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dfdb4953a096c551ce9ace855a604d702e6e62d77fac690575ae347571717f5" + +[[package]] +name = "bindgen" +version = "0.72.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895" +dependencies = [ + "bitflags 2.13.0", + "cexpr", + "clang-sys", + "itertools", + "log", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex 1.3.0", + "syn", +] + +[[package]] +name = "bit-vec" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b71798fca2c1fe1086445a7258a4bc81e6e49dcd24c8d0dd9a1e57395b603f51" +dependencies = [ + "serde", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8" + +[[package]] +name = "brotli" +version = "8.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cc91aac060a7a1e25823bdccbfb6af1875b88f17c6daac97894eed8207166b3" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", + "brotli-decompressor", +] + +[[package]] +name = "brotli-decompressor" +version = "5.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a32acac15fe1967bc3986b2a6347dffc965602354ea6f450ad07e8bfd253583" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", +] + +[[package]] +name = "cc" +version = "1.2.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e228eec9be7c17ccb640b59b36a5cd805ea2a564a4c5e162c2f659fea30d3b96" +dependencies = [ + "find-msvc-tools", + "jobserver", + "libc", + "shlex 2.0.1", +] + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "clang-sys" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "cmake" +version = "0.1.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0f78a02292a74a88ac736019ab962ece0bc380e3f977bf72e376c5d78ff0678" +dependencies = [ + "cc", +] + +[[package]] +name = "colorchoice" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570" + +[[package]] +name = "data-encoding" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4ae5f15dda3c708c0ade84bfee31ccab44a3da4f88015ed22f63732abe300c8" + +[[package]] +name = "defmt" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6e524506490a1953d237cb87b1cfc1e46f88c18f10a22dfe0f507dc6bfc7f7f" +dependencies = [ + "bitflags 1.3.2", + "defmt-macros", +] + +[[package]] +name = "defmt-macros" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0a27770e9c8f719a79d8b638281f4d828f77d8fd61e0bd94451b9b85e576a0b" +dependencies = [ + "defmt-parser", + "proc-macro-error2", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "defmt-parser" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10d60334b3b2e7c9d91ef8150abfb6fa4c1c39ebbcf4a81c2e346aad939fee3e" +dependencies = [ + "thiserror", +] + +[[package]] +name = "der-parser" +version = "10.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07da5016415d5a3c4dd39b11ed26f915f52fc4e0dc197d87908bc916e51bc1a6" +dependencies = [ + "asn1-rs", + "displaydoc", + "nom", + "num-bigint", + "num-traits", + "rusticata-macros", +] + +[[package]] +name = "deranged" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" + +[[package]] +name = "displaydoc" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ac70aa55017e108007fbaf5aa0f54b021c98f92ff8af59d42eda9da96e3dd4f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "dunce" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" + +[[package]] +name = "either" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91622ff5e7162018101f2fea40d6ebf4a78bbe5a49736a2020649edf9693679e" + +[[package]] +name = "env_filter" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32e90c2accc4b07a8456ea0debdc2e7587bdd890680d71173a15d4ae604f6eef" +dependencies = [ + "log", + "regex", +] + +[[package]] +name = "env_logger" +version = "0.11.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0621c04f2196ac3f488dd583365b9c09be011a4ab8b9f37248ffcc8f6198b56a" +dependencies = [ + "anstream", + "anstyle", + "env_filter", + "jiff", + "log", +] + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasip2", +] + +[[package]] +name = "glob" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" + +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "jiff" +version = "0.2.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34f877a98676d2fb664698d74cc6a51ce6c484ce8c770f05d0108ec9090aeb46" +dependencies = [ + "defmt", + "jiff-static", + "log", + "portable-atomic", + "portable-atomic-util", + "serde_core", +] + +[[package]] +name = "jiff-static" +version = "0.2.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0666b5ab5ecaca213fc2a85b8c0083d9004e84ee2d5f9a7e0017aaf50986f25f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "jobserver" +version = "0.1.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" +dependencies = [ + "getrandom 0.3.4", + "libc", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.186" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" + +[[package]] +name = "libloading" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55" +dependencies = [ + "cfg-if", + "windows-link", +] + +[[package]] +name = "log" +version = "0.4.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad" + +[[package]] +name = "macro_rules_attribute" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65049d7923698040cd0b1ddcced9b0eb14dd22c5f86ae59c3740eab64a676520" +dependencies = [ + "macro_rules_attribute-proc_macro", + "paste", +] + +[[package]] +name = "macro_rules_attribute-proc_macro" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "670fdfda89751bc4a84ac13eaa63e205cf0fd22b4c9a5fbfa085b63c1f1d3a30" + +[[package]] +name = "memchr" +version = "2.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88904434abc2901f197fe8cc55f0445e7ded921dba5911dad2e2b39b48e663c4" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-conv" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "oid-registry" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12f40cff3dde1b6087cc5d5f5d4d65712f34016a03ed60e9c08dcc392736b5b7" +dependencies = [ + "asn1-rs", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "once_cell_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "pem" +version = "3.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d30c53c26bc5b31a98cd02d20f25a7c8567146caf63ed593a9d87b2775291be" +dependencies = [ + "base64", + "serde_core", +] + +[[package]] +name = "portable-atomic" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" + +[[package]] +name = "portable-atomic-util" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a106d1259c23fac8e543272398ae0e3c0b8d33c88ed73d0cc71b0f1d902618" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn", +] + +[[package]] +name = "proc-macro-error-attr2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96de42df36bb9bba5542fe9f1a054b8cc87e172759a1868aa05c1f3acc89dfc5" +dependencies = [ + "proc-macro2", + "quote", +] + +[[package]] +name = "proc-macro-error2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11ec05c52be0a07b08061f7dd003e7d7092e0472bc731b4af7bb1ef876109802" +dependencies = [ + "proc-macro-error-attr2", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfbc457d0c7a0759a614551b11a6409e5951f6c7537be1f1b7682b9ae9230368" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "rcgen" +version = "0.14.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57f6d249aad744e274e682777a50283a225a32705394ee6d5fcc01efa25e4055" +dependencies = [ + "aws-lc-rs", + "pem", + "rustls-pki-types", + "time", + "x509-parser 0.18.1", + "yasna", +] + +[[package]] +name = "regex" +version = "1.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1292b7759ae1cb9ec195452d1390a074f0cd8541ab7a5a8c31cd6db45d4a6ba" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.17", + "libc", + "untrusted 0.9.0", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustc-hash" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" + +[[package]] +name = "rusticata-macros" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faf0c4a6ece9950b9abdb62b1cfcf2a68b3b67a10ba445b3bb85be2a293d0632" +dependencies = [ + "nom", +] + +[[package]] +name = "rustls" +version = "0.23.41" +dependencies = [ + "aws-lc-rs", + "base64", + "bencher", + "brotli", + "brotli-decompressor", + "env_logger", + "hashbrown", + "hex", + "log", + "macro_rules_attribute", + "num-bigint", + "once_cell", + "rcgen", + "ring", + "rustls-pki-types", + "rustls-webpki", + "rustversion", + "serde", + "serde_json", + "subtle", + "time", + "webpki-roots", + "x509-parser 0.17.0", + "zeroize", + "zlib-rs", +] + +[[package]] +name = "rustls-pki-types" +version = "1.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30a7197ae7eb376e574fe940d068c30fe0462554a3ddbe4eca7838e049c937a9" +dependencies = [ + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61c429a8649f110dddef65e2a5ad240f747e85f7758a6bccc7e5777bd33f756e" +dependencies = [ + "aws-lc-rs", + "ring", + "rustls-pki-types", + "untrusted 0.9.0", +] + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.150" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "2.0.118" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9ae57f904213ebb649ce6895b8a66c66f0203b9319718f69a5612a065b1422" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thiserror" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "time" +version = "0.3.51" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85c17d80feb7334b40c484e45ed1a5273dfd8bfda537c3be2e74a06a6686f327" +dependencies = [ + "deranged", + "num-conv", + "powerfmt", + "serde_core", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109" + +[[package]] +name = "time-macros" +version = "0.2.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcef1a61bdb119096e153208ec5cbec23944ce8bca13be5c7f60c634f7403935" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.4+wasi-0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "webpki-roots" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf85cb06032201fa7c6f829d7db5a7e5aa45bcc0655327713065f6f0576731bf" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "wit-bindgen" +version = "0.57.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" + +[[package]] +name = "x509-parser" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4569f339c0c402346d4a75a9e39cf8dad310e287eef1ff56d4c68e5067f53460" +dependencies = [ + "asn1-rs", + "data-encoding", + "der-parser", + "lazy_static", + "nom", + "oid-registry", + "rusticata-macros", + "thiserror", + "time", +] + +[[package]] +name = "x509-parser" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d43b0f71ce057da06bc0851b23ee24f3f86190b07203dd8f567d0b706a185202" +dependencies = [ + "asn1-rs", + "aws-lc-rs", + "data-encoding", + "der-parser", + "lazy_static", + "nom", + "oid-registry", + "rusticata-macros", + "thiserror", + "time", +] + +[[package]] +name = "yasna" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5f6765e852b9b4dc8e2a76843e4d64d1cea8e79bcde0b6901aea8e7c7f08282" +dependencies = [ + "bit-vec", + "time", +] + +[[package]] +name = "zeroize" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" + +[[package]] +name = "zlib-rs" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "977347db8caa080403f6b6b7c1cda9479a8e869316f7e13a59b19076a40f94e3" + +[[package]] +name = "zmij" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/http/vendor/rustls/Cargo.toml b/http/vendor/rustls/Cargo.toml new file mode 100644 index 0000000..36e26b1 --- /dev/null +++ b/http/vendor/rustls/Cargo.toml @@ -0,0 +1,234 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies. +# +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. + +[package] +edition = "2021" +rust-version = "1.71" +name = "rustls" +version = "0.23.41" +build = "build.rs" +exclude = [ + "src/testdata", + "tests/**", +] +autolib = false +autobins = false +autoexamples = false +autotests = false +autobenches = false +description = "Rustls is a modern TLS library written in Rust." +homepage = "https://github.com/rustls/rustls" +readme = "README.md" +categories = [ + "network-programming", + "cryptography", +] +license = "Apache-2.0 OR ISC OR MIT" +repository = "https://github.com/rustls/rustls" + +[package.metadata.docs.rs] +features = [ + "read_buf", + "ring", +] +rustdoc-args = [ + "--cfg", + "rustls_docsrs", +] + +[package.metadata.cargo_check_external_types] +allowed_external_types = [ + "rustls_pki_types", + "rustls_pki_types::*", +] + +[package.metadata.cargo-semver-checks.lints] +enum_no_repr_variant_discriminant_changed = "warn" + +[features] +aws-lc-rs = ["aws_lc_rs"] +aws_lc_rs = [ + "dep:aws-lc-rs", + "webpki/aws-lc-rs", + "aws-lc-rs/aws-lc-sys", + "aws-lc-rs/prebuilt-nasm", +] +brotli = [ + "dep:brotli", + "dep:brotli-decompressor", + "std", +] +custom-provider = [] +default = [ + "aws_lc_rs", + "logging", + "prefer-post-quantum", + "std", + "tls12", +] +fips = [ + "aws_lc_rs", + "aws-lc-rs?/fips", + "webpki/aws-lc-rs-fips", +] +logging = ["log"] +prefer-post-quantum = ["aws_lc_rs"] +read_buf = [ + "rustversion", + "std", +] +ring = [ + "dep:ring", + "webpki/ring", +] +std = [ + "webpki/std", + "pki-types/std", + "once_cell/std", +] +tls12 = [] +zlib = ["dep:zlib-rs"] + +[lib] +name = "rustls" +path = "src/lib.rs" + +[[example]] +name = "test_ca" +path = "examples/internal/test_ca.rs" + +[[bench]] +name = "benchmarks" +path = "benches/benchmarks.rs" +harness = false +required-features = ["ring"] + +[dependencies.aws-lc-rs] +version = "1.14" +optional = true +default-features = false + +[dependencies.brotli] +version = "8" +features = ["std"] +optional = true +default-features = false + +[dependencies.brotli-decompressor] +version = "5.0.0" +optional = true + +[dependencies.hashbrown] +version = "0.15" +features = [ + "default-hasher", + "inline-more", +] +optional = true +default-features = false + +[dependencies.log] +version = "0.4.8" +optional = true + +[dependencies.once_cell] +version = "1.16" +features = [ + "alloc", + "race", +] +default-features = false + +[dependencies.pki-types] +version = "1.12" +features = ["alloc"] +package = "rustls-pki-types" + +[dependencies.ring] +version = "0.17" +optional = true + +[dependencies.subtle] +version = "2.5.0" +default-features = false + +[dependencies.webpki] +version = "0.103.5" +features = ["alloc"] +default-features = false +package = "rustls-webpki" + +[dependencies.zeroize] +version = "1.8" + +[dependencies.zlib-rs] +version = "0.6" +optional = true + +[dev-dependencies.base64] +version = "0.22" + +[dev-dependencies.bencher] +version = "0.1.5" + +[dev-dependencies.env_logger] +version = "0.11" + +[dev-dependencies.hex] +version = "0.4" + +[dev-dependencies.log] +version = "0.4.8" + +[dev-dependencies.macro_rules_attribute] +version = "0.2" + +[dev-dependencies.num-bigint] +version = "0.4.4" + +[dev-dependencies.rcgen] +version = "0.14" +features = [ + "pem", + "aws_lc_rs", +] +default-features = false + +[dev-dependencies.serde] +version = "1" +features = ["derive"] + +[dev-dependencies.serde_json] +version = "1" + +[dev-dependencies.time] +version = "0.3.6" +default-features = false + +[dev-dependencies.webpki-roots] +version = "1" + +[dev-dependencies.x509-parser] +version = "0.17" + +[build-dependencies.rustversion] +version = "1.0.6" +optional = true + +[lints.rust.unexpected_cfgs] +level = "warn" +priority = 0 +check-cfg = [ + "cfg(bench)", + "cfg(coverage_nightly)", + "cfg(read_buf)", + "cfg(rustls_docsrs)", +] diff --git a/http/vendor/rustls/Cargo.toml.orig b/http/vendor/rustls/Cargo.toml.orig new file mode 100644 index 0000000..b7fe9c1 --- /dev/null +++ b/http/vendor/rustls/Cargo.toml.orig @@ -0,0 +1,135 @@ +[package] +name = "rustls" +version = "0.23.41" +edition = "2021" +rust-version = "1.71" +license = "Apache-2.0 OR ISC OR MIT" +readme = "../README.md" +description = "Rustls is a modern TLS library written in Rust." +homepage = "https://github.com/rustls/rustls" +repository = "https://github.com/rustls/rustls" +categories = ["network-programming", "cryptography"] +autobenches = false +autotests = false +exclude = ["src/testdata", "tests/**"] +build = "build.rs" + +[features] +default = ["aws_lc_rs", "logging", "prefer-post-quantum", "std", "tls12"] + +aws-lc-rs = ["aws_lc_rs"] # Alias because Cargo features commonly use `-` +aws_lc_rs = ["dep:aws-lc-rs", "webpki/aws-lc-rs", "aws-lc-rs/aws-lc-sys", "aws-lc-rs/prebuilt-nasm"] +brotli = ["dep:brotli", "dep:brotli-decompressor", "std"] +custom-provider = [] +fips = ["aws_lc_rs", "aws-lc-rs?/fips", "webpki/aws-lc-rs-fips"] +logging = ["log"] +prefer-post-quantum = ["aws_lc_rs"] +read_buf = ["rustversion", "std"] +ring = ["dep:ring", "webpki/ring"] +std = ["webpki/std", "pki-types/std", "once_cell/std"] +tls12 = [] +zlib = ["dep:zlib-rs"] + +[build-dependencies] +rustversion = { version = "1.0.6", optional = true } + +[dependencies] +aws-lc-rs = { workspace = true, optional = true } +brotli = { workspace = true, optional = true } +brotli-decompressor = { workspace = true, optional = true } +hashbrown = { workspace = true, optional = true } +log = { workspace = true, optional = true } +# only required for no-std +once_cell = { workspace = true } +ring = { workspace = true, optional = true } +subtle = { workspace = true } +webpki = { workspace = true } +pki-types = { workspace = true } +zeroize = { workspace = true } +zlib-rs = { workspace = true, optional = true } + +[dev-dependencies] +base64 = { workspace = true } +bencher = { workspace = true } +env_logger = { workspace = true } +hex = { workspace = true } +log = { workspace = true } +macro_rules_attribute = { workspace = true } +num-bigint = { workspace = true } +rcgen = { workspace = true } +rustls-test = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +time = { workspace = true } +webpki-roots = { workspace = true } +x509-parser = { workspace = true } + +[[bench]] +name = "benchmarks" +path = "benches/benchmarks.rs" +harness = false +required-features = ["ring"] + +[[example]] +name = "test_ca" +path = "examples/internal/test_ca.rs" + +[[test]] +name = "api" +path = "tests/runners/api.rs" + +[[test]] +name = "api_ffdhe" +path = "tests/runners/api_ffdhe.rs" +required-features = ["tls12"] + +[[test]] +name = "bogo" +path = "tests/bogo.rs" + +[[test]] +name = "client_cert_verifier" +path = "tests/runners/client_cert_verifier.rs" + +[[test]] +name = "ech" +path = "tests/ech.rs" + +[[test]] +name = "key_log_file_env" +path = "tests/runners/key_log_file_env.rs" + +[[test]] +name = "process_provider" +path = "tests/process_provider.rs" + +[[test]] +name = "server_cert_verifier" +path = "tests/runners/server_cert_verifier.rs" + +[[test]] +name = "unbuffered" +path = "tests/runners/unbuffered.rs" + +[package.metadata.docs.rs] +# all non-default features except fips (cannot build on docs.rs environment) +features = ["read_buf", "ring"] +rustdoc-args = ["--cfg", "rustls_docsrs"] + +[package.metadata.cargo_check_external_types] +allowed_external_types = [ + # --- + "rustls_pki_types", + "rustls_pki_types::*", +] + +[package.metadata.cargo-semver-checks.lints] +enum_no_repr_variant_discriminant_changed = "warn" + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = [ + "cfg(bench)", + "cfg(coverage_nightly)", + "cfg(read_buf)", + "cfg(rustls_docsrs)", +] } diff --git a/http/vendor/rustls/LICENSE-APACHE b/http/vendor/rustls/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/http/vendor/rustls/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/http/vendor/rustls/LICENSE-ISC b/http/vendor/rustls/LICENSE-ISC new file mode 100644 index 0000000..03acf1b --- /dev/null +++ b/http/vendor/rustls/LICENSE-ISC @@ -0,0 +1,15 @@ +ISC License (ISC) +Copyright (c) 2016, Joseph Birr-Pixton + +Permission to use, copy, modify, and/or distribute this software for +any purpose with or without fee is hereby granted, provided that the +above copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL +WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE +AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL +DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR +PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS +ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. diff --git a/http/vendor/rustls/LICENSE-MIT b/http/vendor/rustls/LICENSE-MIT new file mode 100644 index 0000000..ef480e6 --- /dev/null +++ b/http/vendor/rustls/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2016 Joseph Birr-Pixton + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/http/vendor/rustls/README.md b/http/vendor/rustls/README.md new file mode 100644 index 0000000..5b8f012 --- /dev/null +++ b/http/vendor/rustls/README.md @@ -0,0 +1,222 @@ +

+ +

+ +

+Rustls is a modern TLS library written in Rust. +

+ +# Status + +Rustls is used in production at many organizations and projects. We aim to maintain +reasonable API surface stability but the API may evolve as we make changes to accommodate +new features or performance improvements. + +We have a [roadmap](ROADMAP.md) for our future plans. We also have [benchmarks](BENCHMARKING.md) to +prevent performance regressions and to let you evaluate rustls on your target hardware. + +If you'd like to help out, please see [CONTRIBUTING.md](CONTRIBUTING.md). + +[![Build Status](https://github.com/rustls/rustls/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/rustls/rustls/actions/workflows/build.yml?query=branch%3Amain) +[![Coverage Status (codecov.io)](https://codecov.io/gh/rustls/rustls/branch/main/graph/badge.svg)](https://codecov.io/gh/rustls/rustls/) +[![Documentation](https://docs.rs/rustls/badge.svg)](https://docs.rs/rustls/) +[![Chat](https://img.shields.io/discord/976380008299917365?logo=discord)](https://discord.gg/MCSB76RU96) +[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/9034/badge)](https://www.bestpractices.dev/projects/9034) + +## Changelog + +The detailed list of changes in each release can be found at +https://github.com/rustls/rustls/releases. + +# Documentation + +https://docs.rs/rustls/ + +# Approach + +Rustls is a TLS library that aims to provide a good level of cryptographic security, +requires no configuration to achieve that security, and provides no unsafe features or +obsolete cryptography by default. + +Rustls implements TLS1.2 and TLS1.3 for both clients and servers. See [the full +list of protocol features](https://docs.rs/rustls/latest/rustls/manual/_04_features/index.html). + +### Platform support + +While Rustls itself is platform independent, by default it uses [`aws-lc-rs`] for implementing +the cryptography in TLS. See [the aws-lc-rs FAQ][aws-lc-rs-platforms-faq] for more details of the +platform/architecture support constraints in aws-lc-rs. + +[`ring`] is also available via the `ring` crate feature: see +[the supported `ring` target platforms][ring-target-platforms]. + +By providing a custom instance of the [`crypto::CryptoProvider`] struct, you +can replace all cryptography dependencies of rustls. This is a route to being portable +to a wider set of architectures and environments, or compliance requirements. See the +[`crypto::CryptoProvider`] documentation for more details. + +Specifying `default-features = false` when depending on rustls will remove the implicit +dependency on aws-lc-rs. + +Rustls requires Rust 1.71 or later. It has an optional dependency on zlib-rs which requires 1.75 or later. + +[ring-target-platforms]: https://github.com/briansmith/ring/blob/2e8363b433fa3b3962c877d9ed2e9145612f3160/include/ring-core/target.h#L18-L64 +[`crypto::CryptoProvider`]: https://docs.rs/rustls/latest/rustls/crypto/struct.CryptoProvider.html +[`ring`]: https://crates.io/crates/ring +[aws-lc-rs-platforms-faq]: https://aws.github.io/aws-lc-rs/faq.html#can-i-run-aws-lc-rs-on-x-platform-or-architecture +[`aws-lc-rs`]: https://crates.io/crates/aws-lc-rs + +### Cryptography providers + +Since Rustls 0.22 it has been possible to choose the provider of the cryptographic primitives +that Rustls uses. This may be appealing if you have specific platform, compliance or feature +requirements that aren't met by the default provider, [`aws-lc-rs`]. + +Users that wish to customize the provider in use can do so when constructing `ClientConfig` +and `ServerConfig` instances using the `with_crypto_provider` method on the respective config +builder types. See the [`crypto::CryptoProvider`] documentation for more details. + +#### Built-in providers + +Rustls ships with two built-in providers controlled by associated crate features: + +* [`aws-lc-rs`] - enabled by default, available with the `aws_lc_rs` crate feature enabled. +* [`ring`] - available with the `ring` crate feature enabled. + +See the documentation for [`crypto::CryptoProvider`] for details on how providers are +selected. + +#### Third-party providers + +The community has also started developing third-party providers for Rustls: + +* [`boring-rustls-provider`] - a work-in-progress provider that uses [`boringssl`] for +cryptography. +* [`rustls-graviola`] - a provider that uses [`graviola`] for cryptography. +* [`rustls-mbedtls-provider`] - a provider that uses [`mbedtls`] for cryptography. +* [`rustls-openssl`] - a provider that uses [OpenSSL] for cryptography. +* [`rustls-rustcrypto`] - an experimental provider that uses the crypto primitives +from [`RustCrypto`] for cryptography. +* [`rustls-symcrypt`] - a provider that uses Microsoft's [SymCrypt] library. +* [`rustls-wolfcrypt-provider`] - a work-in-progress provider that uses [`wolfCrypt`] for cryptography. + +[`rustls-graviola`]: https://crates.io/crates/rustls-graviola +[`graviola`]: https://github.com/ctz/graviola +[`rustls-mbedtls-provider`]: https://github.com/fortanix/rustls-mbedtls-provider +[`mbedtls`]: https://github.com/Mbed-TLS/mbedtls +[`rustls-openssl`]: https://github.com/tofay/rustls-openssl +[OpenSSL]: https://openssl-library.org/ +[`rustls-symcrypt`]: https://github.com/microsoft/rustls-symcrypt +[SymCrypt]: https://github.com/microsoft/SymCrypt +[`boring-rustls-provider`]: https://github.com/janrueth/boring-rustls-provider +[`boringssl`]: https://github.com/google/boringssl +[`rustls-rustcrypto`]: https://github.com/RustCrypto/rustls-rustcrypto +[`RustCrypto`]: https://github.com/RustCrypto +[`rustls-wolfcrypt-provider`]: https://github.com/wolfSSL/rustls-wolfcrypt-provider +[`wolfCrypt`]: https://www.wolfssl.com/products/wolfcrypt + +#### Custom provider + +We also provide a simple example of writing your own provider in the [custom provider example]. +This example implements a minimal provider using parts of the [`RustCrypto`] ecosystem. + +See the [Making a custom CryptoProvider] section of the documentation for more information +on this topic. + +[custom provider example]: https://github.com/rustls/rustls/tree/main/provider-example/ +[`RustCrypto`]: https://github.com/RustCrypto +[Making a custom CryptoProvider]: https://docs.rs/rustls/latest/rustls/crypto/struct.CryptoProvider.html#making-a-custom-cryptoprovider + +# Example code + +Our [examples] directory contains demos that show how to handle I/O using the +[`stream::Stream`] helper, as well as more complex asynchronous I/O using [`mio`]. +If you're already using Tokio for an async runtime you may prefer to use +[`tokio-rustls`] instead of interacting with rustls directly. + +The [`mio`] based examples are the most complete, and discussed below. Users +new to Rustls may prefer to look at the simple client/server examples before +diving in to the more complex MIO examples. + +[examples]: examples/ +[`stream::Stream`]: https://docs.rs/rustls/latest/rustls/struct.Stream.html +[`mio`]: https://docs.rs/mio/latest/mio/ +[`tokio-rustls`]: https://docs.rs/tokio-rustls/latest/tokio_rustls/ + +## Client example program + +The MIO client example program is named `tlsclient-mio`. + +Some sample runs: + +``` +$ cargo run --bin tlsclient-mio -- --http mozilla-modern.badssl.com +HTTP/1.1 200 OK +Server: nginx/1.6.2 (Ubuntu) +Date: Wed, 01 Jun 2016 18:44:00 GMT +Content-Type: text/html +Content-Length: 644 +(...) +``` + +or + +``` +$ cargo run --bin tlsclient-mio -- --http expired.badssl.com +TLS error: InvalidCertificate(Expired) +Connection closed +``` + +Run `cargo run --bin tlsclient-mio -- --help` for more options. + +## Server example program + +The MIO server example program is named `tlsserver-mio`. + +Here's a sample run; we start a TLS echo server, then connect to it with +`openssl` and `tlsclient-mio`: + +``` +$ cargo run --bin tlsserver-mio -- --certs test-ca/rsa-2048/end.fullchain --key test-ca/rsa-2048/end.key -p 8443 echo & +$ echo hello world | openssl s_client -ign_eof -quiet -connect localhost:8443 +depth=2 CN = ponytown RSA CA +verify error:num=19:self signed certificate in certificate chain +hello world +^C +$ echo hello world | cargo run --bin tlsclient-mio -- --cafile test-ca/rsa-2048/ca.cert --port 8443 localhost +hello world +^C +``` + +Run `cargo run --bin tlsserver-mio -- --help` for more options. + +# License + +Rustls is distributed under the following three licenses: + +- Apache License version 2.0. +- MIT license. +- ISC license. + +These are included as LICENSE-APACHE, LICENSE-MIT and LICENSE-ISC +respectively. You may use this software under the terms of any +of these licenses, at your option. + +# Project Membership + +- Joe Birr-Pixton ([@ctz], Project Founder - full-time funded by [Prossimo]) +- Dirkjan Ochtman ([@djc], Co-maintainer) +- Daniel McCarney ([@cpu], Co-maintainer) +- Josh Aas ([@bdaehlie], Project Management) + +[@ctz]: https://github.com/ctz +[@djc]: https://github.com/djc +[@cpu]: https://github.com/cpu +[@bdaehlie]: https://github.com/bdaehlie +[Prossimo]: https://www.memorysafety.org/initiative/rustls/ + +# Code of conduct + +This project adopts the [Rust Code of Conduct](https://www.rust-lang.org/policies/code-of-conduct). +Please email rustls-mod@googlegroups.com to report any instance of misconduct, or if you +have any comments or questions on the Code of Conduct. diff --git a/http/vendor/rustls/benches/benchmarks.rs b/http/vendor/rustls/benches/benchmarks.rs new file mode 100644 index 0000000..5fc473d --- /dev/null +++ b/http/vendor/rustls/benches/benchmarks.rs @@ -0,0 +1,18 @@ +#![cfg(feature = "ring")] +#![allow(clippy::disallowed_types)] + +use std::sync::Arc; + +use bencher::{Bencher, benchmark_group, benchmark_main}; +use rustls::ServerConnection; +use rustls::crypto::ring as provider; +use rustls_test::{KeyType, TestNonBlockIo, make_server_config}; + +fn bench_ewouldblock(c: &mut Bencher) { + let server_config = make_server_config(KeyType::Rsa2048, &provider::default_provider()); + let mut server = ServerConnection::new(Arc::new(server_config)).unwrap(); + c.iter(|| server.read_tls(&mut TestNonBlockIo::default())); +} + +benchmark_group!(benches, bench_ewouldblock); +benchmark_main!(benches); diff --git a/http/vendor/rustls/build.rs b/http/vendor/rustls/build.rs new file mode 100644 index 0000000..8c0bd2a --- /dev/null +++ b/http/vendor/rustls/build.rs @@ -0,0 +1,13 @@ +//! This build script allows us to enable the `read_buf` language feature only +//! for Rust Nightly. +//! +//! See the comment in lib.rs to understand why we need this. + +#[cfg_attr(feature = "read_buf", rustversion::not(nightly))] +fn main() {} + +#[cfg(feature = "read_buf")] +#[rustversion::nightly] +fn main() { + println!("cargo:rustc-cfg=read_buf"); +} diff --git a/http/vendor/rustls/examples/internal/test_ca.rs b/http/vendor/rustls/examples/internal/test_ca.rs new file mode 100644 index 0000000..1df3848 --- /dev/null +++ b/http/vendor/rustls/examples/internal/test_ca.rs @@ -0,0 +1,352 @@ +use std::collections::HashMap; +use std::env; +use std::fs::{self, File}; +use std::io::Write; +use std::net::IpAddr; +use std::path::PathBuf; +use std::str::FromStr; +use std::sync::atomic::{AtomicU64, Ordering}; +use std::time::Duration; + +use rcgen::string::Ia5String; +use rcgen::{ + BasicConstraints, Certificate, CertificateParams, CertificateRevocationListParams, + DistinguishedName, DnType, ExtendedKeyUsagePurpose, IsCa, Issuer, KeyIdMethod, KeyPair, + KeyUsagePurpose, PKCS_ECDSA_P256_SHA256, PKCS_ECDSA_P384_SHA384, PKCS_ECDSA_P521_SHA512, + PKCS_ED25519, PKCS_RSA_SHA256, PKCS_RSA_SHA384, PKCS_RSA_SHA512, RevocationReason, + RevokedCertParams, RsaKeySize, SanType, SerialNumber, SignatureAlgorithm, +}; +use time::OffsetDateTime; + +fn main() -> Result<(), Box> { + let mut certified_keys = HashMap::< + (Role, &'static SignatureAlgorithm), + (Issuer<'static, KeyPair>, Certificate), + >::with_capacity(ROLES.len() * SIG_ALGS.len()); + + for role in ROLES { + for alg in SIG_ALGS { + // Generate a key pair and serialize it to a PEM encoded file. + let key_pair = alg.key_pair(); + let mut key_pair_file = File::create(role.key_file_path(alg))?; + key_pair_file.write_all(key_pair.serialize_pem().as_bytes())?; + + // Issue a certificate for the key pair. For trust anchors, this will be self-signed. + // Otherwise we dig out the issuer and issuer_key for the issuer, which should have + // been produced in earlier iterations based on the careful ordering of roles. + let (params, cert) = match role { + Role::TrustAnchor => { + let params = role.params(alg); + let cert = params.self_signed(&key_pair)?; + (params, cert) + } + Role::Intermediate => { + let issuer = certified_keys + .get(&(Role::TrustAnchor, alg.inner)) + .unwrap(); + let params = role.params(alg); + let cert = params.signed_by(&key_pair, &issuer.0)?; + (params, cert) + } + Role::EndEntity | Role::Client => { + let issuer = certified_keys + .get(&(Role::Intermediate, alg.inner)) + .unwrap(); + let params = role.params(alg); + let cert = params.signed_by(&key_pair, &issuer.0)?; + (params, cert) + } + }; + + // Serialize the issued certificate to a PEM encoded file. + let mut cert_file = File::create(role.cert_pem_file_path(alg))?; + cert_file.write_all(cert.pem().as_bytes())?; + // And to a DER encoded file. + let mut cert_file = File::create(role.cert_der_file_path(alg))?; + cert_file.write_all(cert.der())?; + + // If we're not a trust anchor, generate a CRL for the certificate we just issued. + if role != Role::TrustAnchor { + // The CRL will be signed by the issuer of the certificate being revoked. For + // intermediates this will be the trust anchor, and for client/EE certs this will + // be the intermediate. + let issuer = match role { + Role::Intermediate => certified_keys + .get(&(Role::TrustAnchor, alg.inner)) + .unwrap(), + Role::EndEntity | Role::Client => certified_keys + .get(&(Role::Intermediate, alg.inner)) + .unwrap(), + _ => panic!("unexpected role for CRL generation: {role:?}"), + }; + + let revoked_crl = + crl_for_serial(params.serial_number.clone().unwrap()).signed_by(&issuer.0)?; + let mut revoked_crl_file = File::create( + alg.output_directory() + .join(format!("{}.revoked.crl.pem", role.label())), + )?; + revoked_crl_file.write_all(revoked_crl.pem().unwrap().as_bytes())?; + + let expired_crl = expired_crl().signed_by(&issuer.0)?; + let mut expired_crl_file = File::create( + alg.output_directory() + .join(format!("{}.expired.crl.pem", role.label())), + )?; + expired_crl_file.write_all(expired_crl.pem().unwrap().as_bytes())?; + } + + // When we're issuing end entity or client certs we have a bit of extra work to do + // now that we have full chains in hand. + if matches!(role, Role::EndEntity | Role::Client) { + let root = &certified_keys + .get(&(Role::TrustAnchor, alg.inner)) + .unwrap() + .1; + let intermediate = &certified_keys + .get(&(Role::Intermediate, alg.inner)) + .unwrap() + .1; + + // Write the PEM chain and full chain files for the end entity and client certs. + // Chain files include the intermediate and root certs, while full chain files include + // the end entity or client cert as well. + for f in [ + ("chain", &[intermediate, root][..]), + ("fullchain", &[&cert, intermediate, root][..]), + ] { + let mut chain_file = File::create(alg.output_directory().join(format!( + "{}.{}", + role.label(), + f.0 + )))?; + for cert in f.1 { + chain_file.write_all(cert.pem().as_bytes())?; + } + } + + // Write the PEM public key for the end entity and client. + let mut raw_public_key_file = File::create( + alg.output_directory() + .join(format!("{}.spki.pem", role.label())), + )?; + raw_public_key_file.write_all(key_pair.public_key_pem().as_bytes())?; + } + + certified_keys.insert((role, alg.inner), (Issuer::new(params, key_pair), cert)); + } + } + + Ok(()) +} + +fn crl_for_serial(serial_number: SerialNumber) -> CertificateRevocationListParams { + let now = OffsetDateTime::now_utc(); + CertificateRevocationListParams { + this_update: now, + next_update: now + Duration::from_secs(60 * 60 * 24 * 365 * 100), // 100 years + crl_number: SerialNumber::from(1234), + issuing_distribution_point: None, + revoked_certs: vec![RevokedCertParams { + serial_number, + revocation_time: now, + reason_code: Some(RevocationReason::KeyCompromise), + invalidity_date: None, + }], + key_identifier_method: KeyIdMethod::Sha256, + } +} + +fn expired_crl() -> CertificateRevocationListParams { + let now = OffsetDateTime::now_utc(); + CertificateRevocationListParams { + this_update: now - Duration::from_secs(60), + next_update: now, + crl_number: SerialNumber::from(1234), + issuing_distribution_point: None, + revoked_certs: vec![], + key_identifier_method: KeyIdMethod::Sha256, + } +} + +// Note: these are ordered such that the data dependencies for issuance are satisfied. +const ROLES: [Role; 4] = [ + Role::TrustAnchor, + Role::Intermediate, + Role::EndEntity, + Role::Client, +]; + +#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)] +enum Role { + Client, + EndEntity, + Intermediate, + TrustAnchor, +} + +impl Role { + fn params(&self, alg: &'static SigAlgContext) -> CertificateParams { + let mut params = CertificateParams::default(); + params.distinguished_name = self.common_name(alg); + params.use_authority_key_identifier_extension = true; + let serial = SERIAL_NUMBER.fetch_add(1, Ordering::SeqCst); + params.serial_number = Some(SerialNumber::from_slice(&serial.to_be_bytes()[..])); + + match self { + Self::TrustAnchor | Self::Intermediate => { + params.is_ca = IsCa::Ca(BasicConstraints::Unconstrained); + params.key_usages = ISSUER_KEY_USAGES.to_vec(); + params.extended_key_usages = ISSUER_EXTENDED_KEY_USAGES.to_vec(); + } + Self::EndEntity | Self::Client => { + params.is_ca = IsCa::NoCa; + params.key_usages = EE_KEY_USAGES.to_vec(); + params.subject_alt_names = vec![ + SanType::DnsName(Ia5String::try_from("testserver.com".to_string()).unwrap()), + SanType::DnsName( + Ia5String::try_from("second.testserver.com".to_string()).unwrap(), + ), + SanType::DnsName(Ia5String::try_from("localhost".to_string()).unwrap()), + SanType::IpAddress(IpAddr::from_str("198.51.100.1").unwrap()), + SanType::IpAddress(IpAddr::from_str("2001:db8::1").unwrap()), + ]; + } + } + + // Client certificates additionally get the client auth EKU. + if *self == Self::Client { + params.extended_key_usages = vec![ExtendedKeyUsagePurpose::ClientAuth]; + } + + params + } + + fn common_name(&self, alg: &'static SigAlgContext) -> DistinguishedName { + let mut distinguished_name = DistinguishedName::new(); + distinguished_name.push( + DnType::CommonName, + match self { + Self::Client => "ponytown client".to_owned(), + Self::EndEntity => "testserver.com".to_owned(), + Self::Intermediate => { + format!("ponytown {} level 2 intermediate", alg.issuer_cn) + } + Self::TrustAnchor => format!("ponytown {} CA", alg.issuer_cn), + }, + ); + distinguished_name + } + + fn key_file_path(&self, alg: &'static SigAlgContext) -> PathBuf { + alg.output_directory() + .join(format!("{}.key", self.label())) + } + + fn cert_pem_file_path(&self, alg: &'static SigAlgContext) -> PathBuf { + alg.output_directory() + .join(format!("{}.cert", self.label())) + } + + fn cert_der_file_path(&self, alg: &'static SigAlgContext) -> PathBuf { + alg.output_directory() + .join(format!("{}.der", self.label())) + } + + fn label(&self) -> &'static str { + match self { + Self::Client => "client", + Self::EndEntity => "end", + Self::Intermediate => "inter", + Self::TrustAnchor => "ca", + } + } +} + +// Note: for convenience we use the RSA sigalg digest algorithm to inform the RSA modulus +// size, mapping SHA256 to RSA 2048, SHA384 to RSA 3072, and SHA512 to RSA 4096. +static SIG_ALGS: &[SigAlgContext] = &[ + SigAlgContext { + inner: &PKCS_RSA_SHA256, + issuer_cn: "RSA 2048", + }, + SigAlgContext { + inner: &PKCS_RSA_SHA384, + issuer_cn: "RSA 3072", + }, + SigAlgContext { + inner: &PKCS_RSA_SHA512, + issuer_cn: "RSA 4096", + }, + SigAlgContext { + inner: &PKCS_ECDSA_P256_SHA256, + issuer_cn: "ECDSA p256", + }, + SigAlgContext { + inner: &PKCS_ECDSA_P384_SHA384, + issuer_cn: "ECDSA p384", + }, + SigAlgContext { + inner: &PKCS_ECDSA_P521_SHA512, + issuer_cn: "ECDSA p521", + }, + SigAlgContext { + inner: &PKCS_ED25519, + issuer_cn: "EdDSA", + }, +]; + +struct SigAlgContext { + pub(crate) inner: &'static SignatureAlgorithm, + pub(crate) issuer_cn: &'static str, +} + +impl SigAlgContext { + fn output_directory(&self) -> PathBuf { + let output_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()) + .join("../") + .join("test-ca") + .join( + self.issuer_cn + .to_lowercase() + .replace(' ', "-"), + ); + fs::create_dir_all(&output_dir).unwrap(); + output_dir + } + + fn key_pair(&self) -> KeyPair { + if *self.inner == PKCS_RSA_SHA256 { + KeyPair::generate_rsa_for(&PKCS_RSA_SHA256, RsaKeySize::_2048) + } else if *self.inner == PKCS_RSA_SHA384 { + KeyPair::generate_rsa_for(&PKCS_RSA_SHA384, RsaKeySize::_3072) + } else if *self.inner == PKCS_RSA_SHA512 { + KeyPair::generate_rsa_for(&PKCS_RSA_SHA512, RsaKeySize::_4096) + } else { + KeyPair::generate_for(self.inner) + } + .unwrap() + } +} + +const ISSUER_KEY_USAGES: &[KeyUsagePurpose; 7] = &[ + KeyUsagePurpose::CrlSign, + KeyUsagePurpose::KeyCertSign, + KeyUsagePurpose::DigitalSignature, + KeyUsagePurpose::ContentCommitment, + KeyUsagePurpose::KeyEncipherment, + KeyUsagePurpose::DataEncipherment, + KeyUsagePurpose::KeyAgreement, +]; + +const ISSUER_EXTENDED_KEY_USAGES: &[ExtendedKeyUsagePurpose; 2] = &[ + ExtendedKeyUsagePurpose::ServerAuth, + ExtendedKeyUsagePurpose::ClientAuth, +]; + +const EE_KEY_USAGES: &[KeyUsagePurpose; 2] = &[ + KeyUsagePurpose::DigitalSignature, + KeyUsagePurpose::ContentCommitment, +]; + +static SERIAL_NUMBER: AtomicU64 = AtomicU64::new(1); diff --git a/http/vendor/rustls/src/bs_debug.rs b/http/vendor/rustls/src/bs_debug.rs new file mode 100644 index 0000000..eac4149 --- /dev/null +++ b/http/vendor/rustls/src/bs_debug.rs @@ -0,0 +1,80 @@ +use core::fmt; + +/// Alternative implementation of `fmt::Debug` for byte slice. +/// +/// Standard `Debug` implementation for `[u8]` is comma separated +/// list of numbers. Since large amount of byte strings are in fact +/// ASCII strings or contain a lot of ASCII strings (e. g. HTTP), +/// it is convenient to print strings as ASCII when possible. +/// +/// This struct wraps `&[u8]` just to override `fmt::Debug`. +/// +/// `BsDebug` is not a part of public API of bytes crate. +pub(crate) struct BsDebug<'a>(pub(crate) &'a [u8]); + +impl fmt::Debug for BsDebug<'_> { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { + write!(fmt, "b\"")?; + for &c in self.0 { + // https://doc.rust-lang.org/reference.html#byte-escapes + if c == b'\n' { + write!(fmt, "\\n")?; + } else if c == b'\r' { + write!(fmt, "\\r")?; + } else if c == b'\t' { + write!(fmt, "\\t")?; + } else if c == b'\\' || c == b'"' { + write!(fmt, "\\{}", c as char)?; + } else if c == b'\0' { + write!(fmt, "\\0")?; + // ASCII printable + } else if (0x20..0x7f).contains(&c) { + write!(fmt, "{}", c as char)?; + } else { + write!(fmt, "\\x{c:02x}")?; + } + } + write!(fmt, "\"")?; + Ok(()) + } +} + +#[cfg(test)] +mod tests { + use std::format; + use std::prelude::v1::*; + + use super::BsDebug; + + #[test] + fn debug() { + let vec: Vec<_> = (0..0x100).map(|b| b as u8).collect(); + + let expected = "b\"\ + \\0\\x01\\x02\\x03\\x04\\x05\\x06\\x07\ + \\x08\\t\\n\\x0b\\x0c\\r\\x0e\\x0f\ + \\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\ + \\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x1f\ + \x20!\\\"#$%&'()*+,-./0123456789:;<=>?\ + @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_\ + `abcdefghijklmnopqrstuvwxyz{|}~\\x7f\ + \\x80\\x81\\x82\\x83\\x84\\x85\\x86\\x87\ + \\x88\\x89\\x8a\\x8b\\x8c\\x8d\\x8e\\x8f\ + \\x90\\x91\\x92\\x93\\x94\\x95\\x96\\x97\ + \\x98\\x99\\x9a\\x9b\\x9c\\x9d\\x9e\\x9f\ + \\xa0\\xa1\\xa2\\xa3\\xa4\\xa5\\xa6\\xa7\ + \\xa8\\xa9\\xaa\\xab\\xac\\xad\\xae\\xaf\ + \\xb0\\xb1\\xb2\\xb3\\xb4\\xb5\\xb6\\xb7\ + \\xb8\\xb9\\xba\\xbb\\xbc\\xbd\\xbe\\xbf\ + \\xc0\\xc1\\xc2\\xc3\\xc4\\xc5\\xc6\\xc7\ + \\xc8\\xc9\\xca\\xcb\\xcc\\xcd\\xce\\xcf\ + \\xd0\\xd1\\xd2\\xd3\\xd4\\xd5\\xd6\\xd7\ + \\xd8\\xd9\\xda\\xdb\\xdc\\xdd\\xde\\xdf\ + \\xe0\\xe1\\xe2\\xe3\\xe4\\xe5\\xe6\\xe7\ + \\xe8\\xe9\\xea\\xeb\\xec\\xed\\xee\\xef\ + \\xf0\\xf1\\xf2\\xf3\\xf4\\xf5\\xf6\\xf7\ + \\xf8\\xf9\\xfa\\xfb\\xfc\\xfd\\xfe\\xff\""; + + assert_eq!(expected, format!("{:?}", BsDebug(&vec))); + } +} diff --git a/http/vendor/rustls/src/builder.rs b/http/vendor/rustls/src/builder.rs new file mode 100644 index 0000000..f8ff614 --- /dev/null +++ b/http/vendor/rustls/src/builder.rs @@ -0,0 +1,290 @@ +use alloc::format; +use alloc::vec::Vec; +use core::fmt; +use core::marker::PhantomData; + +use crate::client::EchMode; +use crate::crypto::CryptoProvider; +use crate::error::Error; +use crate::msgs::handshake::ALL_KEY_EXCHANGE_ALGORITHMS; +use crate::sync::Arc; +use crate::time_provider::TimeProvider; +use crate::versions; +#[cfg(doc)] +use crate::{ClientConfig, ServerConfig}; + +/// A [builder] for [`ServerConfig`] or [`ClientConfig`] values. +/// +/// To get one of these, call [`ServerConfig::builder()`] or [`ClientConfig::builder()`]. +/// +/// To build a config, you must make at least two decisions (in order): +/// +/// - How should this client or server verify certificates provided by its peer? +/// - What certificates should this client or server present to its peer? +/// +/// For settings besides these, see the fields of [`ServerConfig`] and [`ClientConfig`]. +/// +/// The usual choice for protocol primitives is to call +/// [`ClientConfig::builder`]/[`ServerConfig::builder`] +/// which will use rustls' default cryptographic provider and safe defaults for ciphersuites and +/// supported protocol versions. +/// +/// ``` +/// # #[cfg(feature = "aws_lc_rs")] { +/// # rustls::crypto::aws_lc_rs::default_provider().install_default(); +/// use rustls::{ClientConfig, ServerConfig}; +/// ClientConfig::builder() +/// // ... +/// # ; +/// +/// ServerConfig::builder() +/// // ... +/// # ; +/// # } +/// ``` +/// +/// You may also override the choice of protocol versions: +/// +/// ```no_run +/// # #[cfg(feature = "aws_lc_rs")] { +/// # rustls::crypto::aws_lc_rs::default_provider().install_default(); +/// # use rustls::ServerConfig; +/// ServerConfig::builder_with_protocol_versions(&[&rustls::version::TLS13]) +/// // ... +/// # ; +/// # } +/// ``` +/// +/// Overriding the default cryptographic provider introduces a `Result` that must be unwrapped, +/// because the config builder checks for consistency of the choices made. For instance, it's an error to +/// configure only TLS 1.2 cipher suites while specifying that TLS 1.3 should be the only supported protocol +/// version. +/// +/// If you configure a smaller set of protocol primitives than the default, you may get a smaller binary, +/// since the code for the unused ones can be optimized away at link time. +/// +/// After choosing protocol primitives, you must choose (a) how to verify certificates and (b) what certificates +/// (if any) to send to the peer. The methods to do this are specific to whether you're building a ClientConfig +/// or a ServerConfig, as tracked by the [`ConfigSide`] type parameter on the various impls of ConfigBuilder. +/// +/// # ClientConfig certificate configuration +/// +/// For a client, _certificate verification_ must be configured either by calling one of: +/// - [`ConfigBuilder::with_root_certificates`] or +/// - [`ConfigBuilder::dangerous()`] and [`DangerousClientConfigBuilder::with_custom_certificate_verifier`] +/// +/// Next, _certificate sending_ (also known as "client authentication", "mutual TLS", or "mTLS") must be configured +/// or disabled using one of: +/// - [`ConfigBuilder::with_no_client_auth`] - to not send client authentication (most common) +/// - [`ConfigBuilder::with_client_auth_cert`] - to always send a specific certificate +/// - [`ConfigBuilder::with_client_cert_resolver`] - to send a certificate chosen dynamically +/// +/// For example: +/// +/// ``` +/// # #[cfg(feature = "aws_lc_rs")] { +/// # rustls::crypto::aws_lc_rs::default_provider().install_default(); +/// # use rustls::ClientConfig; +/// # let root_certs = rustls::RootCertStore::empty(); +/// ClientConfig::builder() +/// .with_root_certificates(root_certs) +/// .with_no_client_auth(); +/// # } +/// ``` +/// +/// # ServerConfig certificate configuration +/// +/// For a server, _certificate verification_ must be configured by calling one of: +/// - [`ConfigBuilder::with_no_client_auth`] - to not require client authentication (most common) +/// - [`ConfigBuilder::with_client_cert_verifier`] - to use a custom verifier +/// +/// Next, _certificate sending_ must be configured by calling one of: +/// - [`ConfigBuilder::with_single_cert`] - to send a specific certificate +/// - [`ConfigBuilder::with_single_cert_with_ocsp`] - to send a specific certificate, plus stapled OCSP +/// - [`ConfigBuilder::with_cert_resolver`] - to send a certificate chosen dynamically +/// +/// For example: +/// +/// ```no_run +/// # #[cfg(feature = "aws_lc_rs")] { +/// # rustls::crypto::aws_lc_rs::default_provider().install_default(); +/// # use rustls::ServerConfig; +/// # let certs = vec![]; +/// # let private_key = pki_types::PrivateKeyDer::from( +/// # pki_types::PrivatePkcs8KeyDer::from(vec![]) +/// # ); +/// ServerConfig::builder() +/// .with_no_client_auth() +/// .with_single_cert(certs, private_key) +/// .expect("bad certificate/key"); +/// # } +/// ``` +/// +/// # Types +/// +/// ConfigBuilder uses the [typestate] pattern to ensure at compile time that each required +/// configuration item is provided exactly once. This is tracked in the `State` type parameter, +/// which can have these values: +/// +/// - [`WantsVersions`] +/// - [`WantsVerifier`] +/// - [`WantsClientCert`] +/// - [`WantsServerCert`] +/// +/// The other type parameter is `Side`, which is either `ServerConfig` or `ClientConfig` +/// depending on whether the ConfigBuilder was built with [`ServerConfig::builder()`] or +/// [`ClientConfig::builder()`]. +/// +/// You won't need to write out either of these type parameters explicitly. If you write a +/// correct chain of configuration calls they will be used automatically. If you write an +/// incorrect chain of configuration calls you will get an error message from the compiler +/// mentioning some of these types. +/// +/// Additionally, ServerConfig and ClientConfig carry a private field containing a +/// [`CryptoProvider`], from [`ClientConfig::builder_with_provider()`] or +/// [`ServerConfig::builder_with_provider()`]. This determines which cryptographic backend +/// is used. The default is [the process-default provider](`CryptoProvider::get_default`). +/// +/// [builder]: https://rust-unofficial.github.io/patterns/patterns/creational/builder.html +/// [typestate]: http://cliffle.com/blog/rust-typestate/ +/// [`ServerConfig`]: crate::ServerConfig +/// [`ServerConfig::builder`]: crate::ServerConfig::builder +/// [`ClientConfig`]: crate::ClientConfig +/// [`ClientConfig::builder()`]: crate::ClientConfig::builder() +/// [`ServerConfig::builder()`]: crate::ServerConfig::builder() +/// [`ClientConfig::builder_with_provider()`]: crate::ClientConfig::builder_with_provider() +/// [`ServerConfig::builder_with_provider()`]: crate::ServerConfig::builder_with_provider() +/// [`ConfigBuilder`]: struct.ConfigBuilder.html#impl-3 +/// [`ConfigBuilder`]: struct.ConfigBuilder.html#impl-6 +/// [`WantsClientCert`]: crate::client::WantsClientCert +/// [`WantsServerCert`]: crate::server::WantsServerCert +/// [`CryptoProvider::get_default`]: crate::crypto::CryptoProvider::get_default +/// [`DangerousClientConfigBuilder::with_custom_certificate_verifier`]: crate::client::danger::DangerousClientConfigBuilder::with_custom_certificate_verifier +#[derive(Clone)] +pub struct ConfigBuilder { + pub(crate) state: State, + pub(crate) provider: Arc, + pub(crate) time_provider: Arc, + pub(crate) side: PhantomData, +} + +impl ConfigBuilder { + /// Return the crypto provider used to construct this builder. + pub fn crypto_provider(&self) -> &Arc { + &self.provider + } +} + +impl fmt::Debug for ConfigBuilder { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let side_name = core::any::type_name::(); + let (ty, _) = side_name + .split_once('<') + .unwrap_or((side_name, "")); + let (_, name) = ty.rsplit_once("::").unwrap_or(("", ty)); + + f.debug_struct(&format!("ConfigBuilder<{name}, _>",)) + .field("state", &self.state) + .finish() + } +} + +/// Config builder state where the caller must supply TLS protocol versions. +/// +/// For more information, see the [`ConfigBuilder`] documentation. +#[derive(Clone, Debug)] +pub struct WantsVersions {} + +impl ConfigBuilder { + /// Accept the default protocol versions: both TLS1.2 and TLS1.3 are enabled. + pub fn with_safe_default_protocol_versions( + self, + ) -> Result, Error> { + self.with_protocol_versions(versions::DEFAULT_VERSIONS) + } + + /// Use a specific set of protocol versions. + pub fn with_protocol_versions( + self, + versions: &[&'static versions::SupportedProtocolVersion], + ) -> Result, Error> { + let mut any_usable_suite = false; + for suite in &self.provider.cipher_suites { + if versions.contains(&suite.version()) { + any_usable_suite = true; + break; + } + } + + if !any_usable_suite { + return Err(Error::General("no usable cipher suites configured".into())); + } + + if self.provider.kx_groups.is_empty() { + return Err(Error::General("no kx groups configured".into())); + } + + // verifying cipher suites have matching kx groups + let mut supported_kx_algos = Vec::with_capacity(ALL_KEY_EXCHANGE_ALGORITHMS.len()); + for group in self.provider.kx_groups.iter() { + let kx = group.name().key_exchange_algorithm(); + if !supported_kx_algos.contains(&kx) { + supported_kx_algos.push(kx); + } + // Small optimization. We don't need to go over other key exchange groups + // if we already cover all supported key exchange algorithms + if supported_kx_algos.len() == ALL_KEY_EXCHANGE_ALGORITHMS.len() { + break; + } + } + + for cs in self.provider.cipher_suites.iter() { + let cs_kx = cs.key_exchange_algorithms(); + if cs_kx + .iter() + .any(|kx| supported_kx_algos.contains(kx)) + { + continue; + } + let suite_name = cs.common().suite; + return Err(Error::General(alloc::format!( + "Ciphersuite {suite_name:?} requires {cs_kx:?} key exchange, but no {cs_kx:?}-compatible \ + key exchange groups were present in `CryptoProvider`'s `kx_groups` field", + ))); + } + + Ok(ConfigBuilder { + state: WantsVerifier { + versions: versions::EnabledVersions::new(versions), + client_ech_mode: None, + }, + provider: self.provider, + time_provider: self.time_provider, + side: self.side, + }) + } +} + +/// Config builder state where the caller must supply a verifier. +/// +/// For more information, see the [`ConfigBuilder`] documentation. +#[derive(Clone, Debug)] +pub struct WantsVerifier { + pub(crate) versions: versions::EnabledVersions, + pub(crate) client_ech_mode: Option, +} + +/// Helper trait to abstract [`ConfigBuilder`] over building a [`ClientConfig`] or [`ServerConfig`]. +/// +/// [`ClientConfig`]: crate::ClientConfig +/// [`ServerConfig`]: crate::ServerConfig +pub trait ConfigSide: sealed::Sealed {} + +impl ConfigSide for crate::ClientConfig {} +impl ConfigSide for crate::ServerConfig {} + +mod sealed { + pub trait Sealed {} + impl Sealed for crate::ClientConfig {} + impl Sealed for crate::ServerConfig {} +} diff --git a/http/vendor/rustls/src/check.rs b/http/vendor/rustls/src/check.rs new file mode 100644 index 0000000..9875bc8 --- /dev/null +++ b/http/vendor/rustls/src/check.rs @@ -0,0 +1,70 @@ +use crate::enums::{ContentType, HandshakeType}; +use crate::error::Error; +use crate::log::warn; +use crate::msgs::message::MessagePayload; + +/// For a Message $m, and a HandshakePayload enum member $payload_type, +/// return Ok(payload) if $m is both a handshake message and one that +/// has the given $payload_type. If not, return Err(rustls::Error) quoting +/// $handshake_type as the expected handshake type. +macro_rules! require_handshake_msg( + ( $m:expr, $handshake_type:path, $payload_type:path ) => ( + match &$m.payload { + MessagePayload::Handshake { parsed: $crate::msgs::handshake::HandshakeMessagePayload( + $payload_type(hm), + ), .. } => Ok(hm), + payload => Err($crate::check::inappropriate_handshake_message( + payload, + &[$crate::ContentType::Handshake], + &[$handshake_type])) + } + ) +); + +/// Like require_handshake_msg, but moves the payload out of $m. +macro_rules! require_handshake_msg_move( + ( $m:expr, $handshake_type:path, $payload_type:path ) => ( + match $m.payload { + MessagePayload::Handshake { parsed: $crate::msgs::handshake::HandshakeMessagePayload( + $payload_type(hm), + ), .. } => Ok(hm), + payload => + Err($crate::check::inappropriate_handshake_message( + &payload, + &[$crate::ContentType::Handshake], + &[$handshake_type])) + } + ) +); + +pub(crate) fn inappropriate_message( + payload: &MessagePayload<'_>, + content_types: &[ContentType], +) -> Error { + warn!( + "Received a {:?} message while expecting {content_types:?}", + payload.content_type(), + ); + Error::InappropriateMessage { + expect_types: content_types.to_vec(), + got_type: payload.content_type(), + } +} + +pub(crate) fn inappropriate_handshake_message( + payload: &MessagePayload<'_>, + content_types: &[ContentType], + handshake_types: &[HandshakeType], +) -> Error { + match payload { + MessagePayload::Handshake { parsed, .. } => { + let got_type = parsed.0.handshake_type(); + warn!("Received a {got_type:?} handshake message while expecting {handshake_types:?}",); + Error::InappropriateHandshakeMessage { + expect_types: handshake_types.to_vec(), + got_type, + } + } + payload => inappropriate_message(payload, content_types), + } +} diff --git a/http/vendor/rustls/src/client/builder.rs b/http/vendor/rustls/src/client/builder.rs new file mode 100644 index 0000000..4b110d1 --- /dev/null +++ b/http/vendor/rustls/src/client/builder.rs @@ -0,0 +1,190 @@ +use alloc::vec::Vec; +use core::marker::PhantomData; + +use pki_types::{CertificateDer, PrivateKeyDer}; + +use super::client_conn::Resumption; +use crate::builder::{ConfigBuilder, WantsVerifier}; +use crate::client::{ClientConfig, EchMode, ResolvesClientCert, handy}; +use crate::error::Error; +use crate::key_log::NoKeyLog; +use crate::sign::{CertifiedKey, SingleCertAndKey}; +use crate::sync::Arc; +use crate::versions::TLS13; +use crate::webpki::{self, WebPkiServerVerifier}; +use crate::{WantsVersions, compress, verify, versions}; + +impl ConfigBuilder { + /// Enable Encrypted Client Hello (ECH) in the given mode. + /// + /// This implicitly selects TLS 1.3 as the only supported protocol version to meet the + /// requirement to support ECH. + /// + /// The `ClientConfig` that will be produced by this builder will be specific to the provided + /// [`crate::client::EchConfig`] and may not be appropriate for all connections made by the program. + /// In this case the configuration should only be shared by connections intended for domains + /// that offer the provided [`crate::client::EchConfig`] in their DNS zone. + pub fn with_ech( + self, + mode: EchMode, + ) -> Result, Error> { + let mut res = self.with_protocol_versions(&[&TLS13][..])?; + res.state.client_ech_mode = Some(mode); + Ok(res) + } +} + +impl ConfigBuilder { + /// Choose how to verify server certificates. + /// + /// Using this function does not configure revocation. If you wish to + /// configure revocation, instead use: + /// + /// ```diff + /// - .with_root_certificates(root_store) + /// + .with_webpki_verifier( + /// + WebPkiServerVerifier::builder_with_provider(root_store, crypto_provider) + /// + .with_crls(...) + /// + .build()? + /// + ) + /// ``` + pub fn with_root_certificates( + self, + root_store: impl Into>, + ) -> ConfigBuilder { + let algorithms = self + .provider + .signature_verification_algorithms; + self.with_webpki_verifier( + WebPkiServerVerifier::new_without_revocation(root_store, algorithms).into(), + ) + } + + /// Choose how to verify server certificates using a webpki verifier. + /// + /// See [`webpki::WebPkiServerVerifier::builder`] and + /// [`webpki::WebPkiServerVerifier::builder_with_provider`] for more information. + pub fn with_webpki_verifier( + self, + verifier: Arc, + ) -> ConfigBuilder { + ConfigBuilder { + state: WantsClientCert { + versions: self.state.versions, + verifier, + client_ech_mode: self.state.client_ech_mode, + }, + provider: self.provider, + time_provider: self.time_provider, + side: PhantomData, + } + } + + /// Access configuration options whose use is dangerous and requires + /// extra care. + pub fn dangerous(self) -> danger::DangerousClientConfigBuilder { + danger::DangerousClientConfigBuilder { cfg: self } + } +} + +/// Container for unsafe APIs +pub(super) mod danger { + use core::marker::PhantomData; + + use crate::client::WantsClientCert; + use crate::sync::Arc; + use crate::{ClientConfig, ConfigBuilder, WantsVerifier, verify}; + + /// Accessor for dangerous configuration options. + #[derive(Debug)] + pub struct DangerousClientConfigBuilder { + /// The underlying ClientConfigBuilder + pub cfg: ConfigBuilder, + } + + impl DangerousClientConfigBuilder { + /// Set a custom certificate verifier. + pub fn with_custom_certificate_verifier( + self, + verifier: Arc, + ) -> ConfigBuilder { + ConfigBuilder { + state: WantsClientCert { + versions: self.cfg.state.versions, + verifier, + client_ech_mode: self.cfg.state.client_ech_mode, + }, + provider: self.cfg.provider, + time_provider: self.cfg.time_provider, + side: PhantomData, + } + } + } +} + +/// A config builder state where the caller needs to supply whether and how to provide a client +/// certificate. +/// +/// For more information, see the [`ConfigBuilder`] documentation. +#[derive(Clone)] +pub struct WantsClientCert { + versions: versions::EnabledVersions, + verifier: Arc, + client_ech_mode: Option, +} + +impl ConfigBuilder { + /// Sets a single certificate chain and matching private key for use + /// in client authentication. + /// + /// `cert_chain` is a vector of DER-encoded certificates. + /// `key_der` is a DER-encoded private key as PKCS#1, PKCS#8, or SEC1. The + /// `aws-lc-rs` and `ring` [`CryptoProvider`][crate::CryptoProvider]s support + /// all three encodings, but other `CryptoProviders` may not. + /// + /// This function fails if `key_der` is invalid. + pub fn with_client_auth_cert( + self, + cert_chain: Vec>, + key_der: PrivateKeyDer<'static>, + ) -> Result { + let certified_key = CertifiedKey::from_der(cert_chain, key_der, &self.provider)?; + Ok(self.with_client_cert_resolver(Arc::new(SingleCertAndKey::from(certified_key)))) + } + + /// Do not support client auth. + pub fn with_no_client_auth(self) -> ClientConfig { + self.with_client_cert_resolver(Arc::new(handy::FailResolveClientCert {})) + } + + /// Sets a custom [`ResolvesClientCert`]. + pub fn with_client_cert_resolver( + self, + client_auth_cert_resolver: Arc, + ) -> ClientConfig { + #[cfg(feature = "tls12")] + let require_ems = self.provider.fips(); + + ClientConfig { + provider: self.provider, + alpn_protocols: Vec::new(), + check_selected_alpn: true, + resumption: Resumption::default(), + max_fragment_size: None, + client_auth_cert_resolver, + versions: self.state.versions, + enable_sni: true, + verifier: self.state.verifier, + key_log: Arc::new(NoKeyLog {}), + enable_secret_extraction: false, + enable_early_data: false, + #[cfg(feature = "tls12")] + require_ems, + time_provider: self.time_provider, + cert_compressors: compress::default_cert_compressors().to_vec(), + cert_compression_cache: Arc::new(compress::CompressionCache::default()), + cert_decompressors: compress::default_cert_decompressors().to_vec(), + ech_mode: self.state.client_ech_mode, + } + } +} diff --git a/http/vendor/rustls/src/client/client_conn.rs b/http/vendor/rustls/src/client/client_conn.rs new file mode 100644 index 0000000..374a70d --- /dev/null +++ b/http/vendor/rustls/src/client/client_conn.rs @@ -0,0 +1,1068 @@ +use alloc::vec::Vec; +use core::marker::PhantomData; +use core::ops::{Deref, DerefMut}; +use core::{fmt, mem}; + +use pki_types::{ServerName, UnixTime}; + +use super::handy::NoClientSessionStorage; +use super::hs::{self, ClientHelloInput}; +#[cfg(feature = "std")] +use crate::WantsVerifier; +use crate::builder::ConfigBuilder; +use crate::client::{EchMode, EchStatus}; +use crate::common_state::{CommonState, Protocol, Side}; +use crate::conn::{ConnectionCore, UnbufferedConnectionCommon}; +use crate::crypto::{CryptoProvider, SupportedKxGroup}; +use crate::enums::{CipherSuite, ProtocolVersion, SignatureScheme}; +use crate::error::Error; +use crate::kernel::KernelConnection; +use crate::log::trace; +use crate::msgs::enums::NamedGroup; +use crate::msgs::handshake::ClientExtensionsInput; +use crate::msgs::persist; +use crate::suites::{ExtractedSecrets, SupportedCipherSuite}; +use crate::sync::Arc; +#[cfg(feature = "std")] +use crate::time_provider::DefaultTimeProvider; +use crate::time_provider::TimeProvider; +use crate::unbuffered::{EncryptError, TransmitTlsData}; +#[cfg(doc)] +use crate::{DistinguishedName, crypto}; +use crate::{KeyLog, WantsVersions, compress, sign, verify, versions}; + +/// A trait for the ability to store client session data, so that sessions +/// can be resumed in future connections. +/// +/// Generally all data in this interface should be treated as +/// **highly sensitive**, containing enough key material to break all security +/// of the corresponding session. +/// +/// `set_`, `insert_`, `remove_` and `take_` operations are mutating; this isn't +/// expressed in the type system to allow implementations freedom in +/// how to achieve interior mutability. `Mutex` is a common choice. +pub trait ClientSessionStore: fmt::Debug + Send + Sync { + /// Remember what `NamedGroup` the given server chose. + fn set_kx_hint(&self, server_name: ServerName<'static>, group: NamedGroup); + + /// This should return the value most recently passed to `set_kx_hint` + /// for the given `server_name`. + /// + /// If `None` is returned, the caller chooses the first configured group, + /// and an extra round trip might happen if that choice is unsatisfactory + /// to the server. + fn kx_hint(&self, server_name: &ServerName<'_>) -> Option; + + /// Remember a TLS1.2 session. + /// + /// At most one of these can be remembered at a time, per `server_name`. + fn set_tls12_session( + &self, + server_name: ServerName<'static>, + value: persist::Tls12ClientSessionValue, + ); + + /// Get the most recently saved TLS1.2 session for `server_name` provided to `set_tls12_session`. + fn tls12_session( + &self, + server_name: &ServerName<'_>, + ) -> Option; + + /// Remove and forget any saved TLS1.2 session for `server_name`. + fn remove_tls12_session(&self, server_name: &ServerName<'static>); + + /// Remember a TLS1.3 ticket that might be retrieved later from `take_tls13_ticket`, allowing + /// resumption of this session. + /// + /// This can be called multiple times for a given session, allowing multiple independent tickets + /// to be valid at once. The number of times this is called is controlled by the server, so + /// implementations of this trait should apply a reasonable bound of how many items are stored + /// simultaneously. + fn insert_tls13_ticket( + &self, + server_name: ServerName<'static>, + value: persist::Tls13ClientSessionValue, + ); + + /// Return a TLS1.3 ticket previously provided to `add_tls13_ticket`. + /// + /// Implementations of this trait must return each value provided to `add_tls13_ticket` _at most once_. + fn take_tls13_ticket( + &self, + server_name: &ServerName<'static>, + ) -> Option; +} + +/// A trait for the ability to choose a certificate chain and +/// private key for the purposes of client authentication. +pub trait ResolvesClientCert: fmt::Debug + Send + Sync { + /// Resolve a client certificate chain/private key to use as the client's + /// identity. + /// + /// `root_hint_subjects` is an optional list of certificate authority + /// subject distinguished names that the client can use to help + /// decide on a client certificate the server is likely to accept. If + /// the list is empty, the client should send whatever certificate it + /// has. The hints are expected to be DER-encoded X.500 distinguished names, + /// per [RFC 5280 A.1]. See [`DistinguishedName`] for more information + /// on decoding with external crates like `x509-parser`. + /// + /// `sigschemes` is the list of the [`SignatureScheme`]s the server + /// supports. + /// + /// Return `None` to continue the handshake without any client + /// authentication. The server may reject the handshake later + /// if it requires authentication. + /// + /// [RFC 5280 A.1]: https://www.rfc-editor.org/rfc/rfc5280#appendix-A.1 + fn resolve( + &self, + root_hint_subjects: &[&[u8]], + sigschemes: &[SignatureScheme], + ) -> Option>; + + /// Return true if the client only supports raw public keys. + /// + /// See [RFC 7250](https://www.rfc-editor.org/rfc/rfc7250). + fn only_raw_public_keys(&self) -> bool { + false + } + + /// Return true if any certificates at all are available. + fn has_certs(&self) -> bool; +} + +/// Common configuration for (typically) all connections made by a program. +/// +/// Making one of these is cheap, though one of the inputs may be expensive: gathering trust roots +/// from the operating system to add to the [`RootCertStore`] passed to `with_root_certificates()` +/// (the rustls-native-certs crate is often used for this) may take on the order of a few hundred +/// milliseconds. +/// +/// These must be created via the [`ClientConfig::builder()`] or [`ClientConfig::builder_with_provider()`] +/// function. +/// +/// Note that using [`ConfigBuilder::with_ech()`] will produce a common +/// configuration specific to the provided [`crate::client::EchConfig`] that may not be appropriate +/// for all connections made by the program. In this case the configuration should only be shared +/// by connections intended for domains that offer the provided [`crate::client::EchConfig`] in +/// their DNS zone. +/// +/// # Defaults +/// +/// * [`ClientConfig::max_fragment_size`]: the default is `None` (meaning 16kB). +/// * [`ClientConfig::resumption`]: supports resumption with up to 256 server names, using session +/// ids or tickets, with a max of eight tickets per server. +/// * [`ClientConfig::alpn_protocols`]: the default is empty -- no ALPN protocol is negotiated. +/// * [`ClientConfig::key_log`]: key material is not logged. +/// * [`ClientConfig::cert_decompressors`]: depends on the crate features, see [`compress::default_cert_decompressors()`]. +/// * [`ClientConfig::cert_compressors`]: depends on the crate features, see [`compress::default_cert_compressors()`]. +/// * [`ClientConfig::cert_compression_cache`]: caches the most recently used 4 compressions +/// +/// [`RootCertStore`]: crate::RootCertStore +#[derive(Clone, Debug)] +pub struct ClientConfig { + /// Which ALPN protocols we include in our client hello. + /// If empty, no ALPN extension is sent. + pub alpn_protocols: Vec>, + + /// Whether to check the selected ALPN was offered. + /// + /// The default is true. + pub check_selected_alpn: bool, + + /// How and when the client can resume a previous session. + /// + /// # Sharing `resumption` between `ClientConfig`s + /// In a program using many `ClientConfig`s it may improve resumption rates + /// (which has a significant impact on connection performance) if those + /// configs share a single `Resumption`. + /// + /// However, resumption is only allowed between two `ClientConfig`s if their + /// `client_auth_cert_resolver` (ie, potential client authentication credentials) + /// and `verifier` (ie, server certificate verification settings) are + /// the same (according to `Arc::ptr_eq`). + /// + /// To illustrate, imagine two `ClientConfig`s `A` and `B`. `A` fully validates + /// the server certificate, `B` does not. If `A` and `B` shared a resumption store, + /// it would be possible for a session originated by `B` to be inserted into the + /// store, and then resumed by `A`. This would give a false impression to the user + /// of `A` that the server certificate is fully validated. + pub resumption: Resumption, + + /// The maximum size of plaintext input to be emitted in a single TLS record. + /// A value of None is equivalent to the [TLS maximum] of 16 kB. + /// + /// rustls enforces an arbitrary minimum of 32 bytes for this field. + /// Out of range values are reported as errors from [ClientConnection::new]. + /// + /// Setting this value to a little less than the TCP MSS may improve latency + /// for stream-y workloads. + /// + /// [TLS maximum]: https://datatracker.ietf.org/doc/html/rfc8446#section-5.1 + /// [ClientConnection::new]: crate::client::ClientConnection::new + pub max_fragment_size: Option, + + /// How to decide what client auth certificate/keys to use. + pub client_auth_cert_resolver: Arc, + + /// Whether to send the Server Name Indication (SNI) extension + /// during the client handshake. + /// + /// The default is true. + pub enable_sni: bool, + + /// How to output key material for debugging. The default + /// does nothing. + pub key_log: Arc, + + /// Allows traffic secrets to be extracted after the handshake, + /// e.g. for kTLS setup. + pub enable_secret_extraction: bool, + + /// Whether to send data on the first flight ("early data") in + /// TLS 1.3 handshakes. + /// + /// The default is false. + pub enable_early_data: bool, + + /// If set to `true`, requires the server to support the extended + /// master secret extraction method defined in [RFC 7627]. + /// + /// The default is `true` if the configured [`CryptoProvider`] is + /// FIPS-compliant (i.e., [`CryptoProvider::fips()`] returns `true`), + /// `false` otherwise. + /// + /// It must be set to `true` to meet FIPS requirement mentioned in section + /// **D.Q Transition of the TLS 1.2 KDF to Support the Extended Master + /// Secret** from [FIPS 140-3 IG.pdf]. + /// + /// [RFC 7627]: https://datatracker.ietf.org/doc/html/rfc7627 + /// [FIPS 140-3 IG.pdf]: https://csrc.nist.gov/csrc/media/Projects/cryptographic-module-validation-program/documents/fips%20140-3/FIPS%20140-3%20IG.pdf + #[cfg(feature = "tls12")] + pub require_ems: bool, + + /// Provides the current system time + pub time_provider: Arc, + + /// Source of randomness and other crypto. + pub(super) provider: Arc, + + /// Supported versions, in no particular order. The default + /// is all supported versions. + pub(super) versions: versions::EnabledVersions, + + /// How to verify the server certificate chain. + pub(super) verifier: Arc, + + /// How to decompress the server's certificate chain. + /// + /// If this is non-empty, the [RFC8779] certificate compression + /// extension is offered, and any compressed certificates are + /// transparently decompressed during the handshake. + /// + /// This only applies to TLS1.3 connections. It is ignored for + /// TLS1.2 connections. + /// + /// [RFC8779]: https://datatracker.ietf.org/doc/rfc8879/ + pub cert_decompressors: Vec<&'static dyn compress::CertDecompressor>, + + /// How to compress the client's certificate chain. + /// + /// If a server supports this extension, and advertises support + /// for one of the compression algorithms included here, the + /// client certificate will be compressed according to [RFC8779]. + /// + /// This only applies to TLS1.3 connections. It is ignored for + /// TLS1.2 connections. + /// + /// [RFC8779]: https://datatracker.ietf.org/doc/rfc8879/ + pub cert_compressors: Vec<&'static dyn compress::CertCompressor>, + + /// Caching for compressed certificates. + /// + /// This is optional: [`compress::CompressionCache::Disabled`] gives + /// a cache that does no caching. + pub cert_compression_cache: Arc, + + /// How to offer Encrypted Client Hello (ECH). The default is to not offer ECH. + pub(super) ech_mode: Option, +} + +impl ClientConfig { + /// Create a builder for a client configuration with + /// [the process-default `CryptoProvider`][CryptoProvider#using-the-per-process-default-cryptoprovider] + /// and safe protocol version defaults. + /// + /// For more information, see the [`ConfigBuilder`] documentation. + #[cfg(feature = "std")] + pub fn builder() -> ConfigBuilder { + Self::builder_with_protocol_versions(versions::DEFAULT_VERSIONS) + } + + /// Create a builder for a client configuration with + /// [the process-default `CryptoProvider`][CryptoProvider#using-the-per-process-default-cryptoprovider] + /// and the provided protocol versions. + /// + /// Panics if + /// - the supported versions are not compatible with the provider (eg. + /// the combination of ciphersuites supported by the provider and supported + /// versions lead to zero cipher suites being usable), + /// - if a `CryptoProvider` cannot be resolved using a combination of + /// the crate features and process default. + /// + /// For more information, see the [`ConfigBuilder`] documentation. + #[cfg(feature = "std")] + pub fn builder_with_protocol_versions( + versions: &[&'static versions::SupportedProtocolVersion], + ) -> ConfigBuilder { + // Safety assumptions: + // 1. that the provider has been installed (explicitly or implicitly) + // 2. that the process-level default provider is usable with the supplied protocol versions. + Self::builder_with_provider( + CryptoProvider::get_default_or_install_from_crate_features().clone(), + ) + .with_protocol_versions(versions) + .unwrap() + } + + /// Create a builder for a client configuration with a specific [`CryptoProvider`]. + /// + /// This will use the provider's configured ciphersuites. You must additionally choose + /// which protocol versions to enable, using `with_protocol_versions` or + /// `with_safe_default_protocol_versions` and handling the `Result` in case a protocol + /// version is not supported by the provider's ciphersuites. + /// + /// For more information, see the [`ConfigBuilder`] documentation. + #[cfg(feature = "std")] + pub fn builder_with_provider( + provider: Arc, + ) -> ConfigBuilder { + ConfigBuilder { + state: WantsVersions {}, + provider, + time_provider: Arc::new(DefaultTimeProvider), + side: PhantomData, + } + } + /// Create a builder for a client configuration with no default implementation details. + /// + /// This API must be used by `no_std` users. + /// + /// You must provide a specific [`TimeProvider`]. + /// + /// You must provide a specific [`CryptoProvider`]. + /// + /// This will use the provider's configured ciphersuites. You must additionally choose + /// which protocol versions to enable, using `with_protocol_versions` or + /// `with_safe_default_protocol_versions` and handling the `Result` in case a protocol + /// version is not supported by the provider's ciphersuites. + /// + /// For more information, see the [`ConfigBuilder`] documentation. + pub fn builder_with_details( + provider: Arc, + time_provider: Arc, + ) -> ConfigBuilder { + ConfigBuilder { + state: WantsVersions {}, + provider, + time_provider, + side: PhantomData, + } + } + + /// Return true if connections made with this `ClientConfig` will + /// operate in FIPS mode. + /// + /// This is different from [`CryptoProvider::fips()`]: [`CryptoProvider::fips()`] + /// is concerned only with cryptography, whereas this _also_ covers TLS-level + /// configuration that NIST recommends, as well as ECH HPKE suites if applicable. + pub fn fips(&self) -> bool { + let mut is_fips = self.provider.fips(); + + #[cfg(feature = "tls12")] + { + is_fips = is_fips && self.require_ems + } + + if let Some(ech_mode) = &self.ech_mode { + is_fips = is_fips && ech_mode.fips(); + } + + is_fips + } + + /// Return the crypto provider used to construct this client configuration. + pub fn crypto_provider(&self) -> &Arc { + &self.provider + } + + /// Access configuration options whose use is dangerous and requires + /// extra care. + pub fn dangerous(&mut self) -> danger::DangerousClientConfig<'_> { + danger::DangerousClientConfig { cfg: self } + } + + pub(super) fn needs_key_share(&self) -> bool { + self.supports_version(ProtocolVersion::TLSv1_3) + } + + /// We support a given TLS version if it's quoted in the configured + /// versions *and* at least one ciphersuite for this version is + /// also configured. + pub(crate) fn supports_version(&self, v: ProtocolVersion) -> bool { + self.versions.contains(v) + && self + .provider + .cipher_suites + .iter() + .any(|cs| cs.version().version == v) + } + + #[cfg(feature = "std")] + pub(crate) fn supports_protocol(&self, proto: Protocol) -> bool { + self.provider + .cipher_suites + .iter() + .any(|cs| cs.usable_for_protocol(proto)) + } + + pub(super) fn find_cipher_suite(&self, suite: CipherSuite) -> Option { + self.provider + .cipher_suites + .iter() + .copied() + .find(|&scs| scs.suite() == suite) + } + + pub(super) fn find_kx_group( + &self, + group: NamedGroup, + version: ProtocolVersion, + ) -> Option<&'static dyn SupportedKxGroup> { + self.provider + .kx_groups + .iter() + .copied() + .find(|skxg| skxg.usable_for_version(version) && skxg.name() == group) + } + + pub(super) fn current_time(&self) -> Result { + self.time_provider + .current_time() + .ok_or(Error::FailedToGetCurrentTime) + } +} + +/// Configuration for how/when a client is allowed to resume a previous session. +#[derive(Clone, Debug)] +pub struct Resumption { + /// How we store session data or tickets. The default is to use an in-memory + /// [super::handy::ClientSessionMemoryCache]. + pub(super) store: Arc, + + /// What mechanism is used for resuming a TLS 1.2 session. + pub(super) tls12_resumption: Tls12Resumption, +} + +impl Resumption { + /// Create a new `Resumption` that stores data for the given number of sessions in memory. + /// + /// This is the default `Resumption` choice, and enables resuming a TLS 1.2 session with + /// a session id or RFC 5077 ticket. + #[cfg(feature = "std")] + pub fn in_memory_sessions(num: usize) -> Self { + Self { + store: Arc::new(super::handy::ClientSessionMemoryCache::new(num)), + tls12_resumption: Tls12Resumption::SessionIdOrTickets, + } + } + + /// Use a custom [`ClientSessionStore`] implementation to store sessions. + /// + /// By default, enables resuming a TLS 1.2 session with a session id or RFC 5077 ticket. + pub fn store(store: Arc) -> Self { + Self { + store, + tls12_resumption: Tls12Resumption::SessionIdOrTickets, + } + } + + /// Disable all use of session resumption. + pub fn disabled() -> Self { + Self { + store: Arc::new(NoClientSessionStorage), + tls12_resumption: Tls12Resumption::Disabled, + } + } + + /// Configure whether TLS 1.2 sessions may be resumed, and by what mechanism. + /// + /// This is meaningless if you've disabled resumption entirely, which is the case in `no-std` + /// contexts. + pub fn tls12_resumption(mut self, tls12: Tls12Resumption) -> Self { + self.tls12_resumption = tls12; + self + } +} + +impl Default for Resumption { + /// Create an in-memory session store resumption with up to 256 server names, allowing + /// a TLS 1.2 session to resume with a session id or RFC 5077 ticket. + fn default() -> Self { + #[cfg(feature = "std")] + let ret = Self::in_memory_sessions(256); + + #[cfg(not(feature = "std"))] + let ret = Self::disabled(); + + ret + } +} + +/// What mechanisms to support for resuming a TLS 1.2 session. +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum Tls12Resumption { + /// Disable 1.2 resumption. + Disabled, + /// Support 1.2 resumption using session ids only. + SessionIdOnly, + /// Support 1.2 resumption using session ids or RFC 5077 tickets. + /// + /// See[^1] for why you might like to disable RFC 5077 by instead choosing the `SessionIdOnly` + /// option. Note that TLS 1.3 tickets do not have those issues. + /// + /// [^1]: + SessionIdOrTickets, +} + +/// Container for unsafe APIs +pub(super) mod danger { + use super::ClientConfig; + use super::verify::ServerCertVerifier; + use crate::sync::Arc; + + /// Accessor for dangerous configuration options. + #[derive(Debug)] + pub struct DangerousClientConfig<'a> { + /// The underlying ClientConfig + pub cfg: &'a mut ClientConfig, + } + + impl DangerousClientConfig<'_> { + /// Overrides the default `ServerCertVerifier` with something else. + pub fn set_certificate_verifier(&mut self, verifier: Arc) { + self.cfg.verifier = verifier; + } + } +} + +#[derive(Debug, PartialEq)] +enum EarlyDataState { + Disabled, + Ready, + Accepted, + AcceptedFinished, + Rejected, +} + +#[derive(Debug)] +pub(super) struct EarlyData { + state: EarlyDataState, + left: usize, +} + +impl EarlyData { + fn new() -> Self { + Self { + left: 0, + state: EarlyDataState::Disabled, + } + } + + pub(super) fn is_enabled(&self) -> bool { + matches!(self.state, EarlyDataState::Ready | EarlyDataState::Accepted) + } + + #[cfg(feature = "std")] + fn is_accepted(&self) -> bool { + matches!( + self.state, + EarlyDataState::Accepted | EarlyDataState::AcceptedFinished + ) + } + + pub(super) fn enable(&mut self, max_data: usize) { + assert_eq!(self.state, EarlyDataState::Disabled); + self.state = EarlyDataState::Ready; + self.left = max_data; + } + + pub(super) fn rejected(&mut self) { + trace!("EarlyData rejected"); + self.state = EarlyDataState::Rejected; + } + + pub(super) fn accepted(&mut self) { + trace!("EarlyData accepted"); + assert_eq!(self.state, EarlyDataState::Ready); + self.state = EarlyDataState::Accepted; + } + + pub(super) fn finished(&mut self) { + trace!("EarlyData finished"); + self.state = match self.state { + EarlyDataState::Accepted => EarlyDataState::AcceptedFinished, + _ => panic!("bad EarlyData state"), + } + } + + fn check_write_opt(&mut self, sz: usize) -> Option { + match self.state { + EarlyDataState::Disabled => unreachable!(), + EarlyDataState::Ready | EarlyDataState::Accepted => { + let take = if self.left < sz { + mem::replace(&mut self.left, 0) + } else { + self.left -= sz; + sz + }; + + Some(take) + } + EarlyDataState::Rejected | EarlyDataState::AcceptedFinished => None, + } + } +} + +#[cfg(feature = "std")] +mod connection { + use alloc::vec::Vec; + use core::fmt; + use core::ops::{Deref, DerefMut}; + use std::io; + + use pki_types::ServerName; + + use super::{ClientConnectionData, ClientExtensionsInput}; + use crate::ClientConfig; + use crate::client::EchStatus; + use crate::common_state::Protocol; + use crate::conn::{ConnectionCommon, ConnectionCore}; + use crate::error::Error; + use crate::suites::ExtractedSecrets; + use crate::sync::Arc; + + /// Stub that implements io::Write and dispatches to `write_early_data`. + pub struct WriteEarlyData<'a> { + sess: &'a mut ClientConnection, + } + + impl<'a> WriteEarlyData<'a> { + fn new(sess: &'a mut ClientConnection) -> Self { + WriteEarlyData { sess } + } + + /// How many bytes you may send. Writes will become short + /// once this reaches zero. + pub fn bytes_left(&self) -> usize { + self.sess + .inner + .core + .data + .early_data + .bytes_left() + } + } + + impl io::Write for WriteEarlyData<'_> { + fn write(&mut self, buf: &[u8]) -> io::Result { + self.sess.write_early_data(buf) + } + + fn flush(&mut self) -> io::Result<()> { + Ok(()) + } + } + + impl super::EarlyData { + fn check_write(&mut self, sz: usize) -> io::Result { + self.check_write_opt(sz) + .ok_or_else(|| io::Error::from(io::ErrorKind::InvalidInput)) + } + + fn bytes_left(&self) -> usize { + self.left + } + } + + /// This represents a single TLS client connection. + pub struct ClientConnection { + inner: ConnectionCommon, + } + + impl fmt::Debug for ClientConnection { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("ClientConnection") + .finish() + } + } + + impl ClientConnection { + /// Make a new ClientConnection. `config` controls how + /// we behave in the TLS protocol, `name` is the + /// name of the server we want to talk to. + pub fn new(config: Arc, name: ServerName<'static>) -> Result { + Self::new_with_alpn(config.clone(), name, config.alpn_protocols.clone()) + } + + /// Make a new ClientConnection with custom ALPN protocols. + pub fn new_with_alpn( + config: Arc, + name: ServerName<'static>, + alpn_protocols: Vec>, + ) -> Result { + Ok(Self { + inner: ConnectionCommon::from(ConnectionCore::for_client( + config, + name, + ClientExtensionsInput::from_alpn(alpn_protocols), + Protocol::Tcp, + )?), + }) + } + /// Returns an `io::Write` implementer you can write bytes to + /// to send TLS1.3 early data (a.k.a. "0-RTT data") to the server. + /// + /// This returns None in many circumstances when the capability to + /// send early data is not available, including but not limited to: + /// + /// - The server hasn't been talked to previously. + /// - The server does not support resumption. + /// - The server does not support early data. + /// - The resumption data for the server has expired. + /// + /// The server specifies a maximum amount of early data. You can + /// learn this limit through the returned object, and writes through + /// it will process only this many bytes. + /// + /// The server can choose not to accept any sent early data -- + /// in this case the data is lost but the connection continues. You + /// can tell this happened using `is_early_data_accepted`. + pub fn early_data(&mut self) -> Option> { + if self + .inner + .core + .data + .early_data + .is_enabled() + { + Some(WriteEarlyData::new(self)) + } else { + None + } + } + + /// Returns True if the server signalled it will process early data. + /// + /// If you sent early data and this returns false at the end of the + /// handshake then the server will not process the data. This + /// is not an error, but you may wish to resend the data. + pub fn is_early_data_accepted(&self) -> bool { + self.inner.core.is_early_data_accepted() + } + + /// Extract secrets, so they can be used when configuring kTLS, for example. + /// Should be used with care as it exposes secret key material. + pub fn dangerous_extract_secrets(self) -> Result { + self.inner.dangerous_extract_secrets() + } + + /// Return the connection's Encrypted Client Hello (ECH) status. + pub fn ech_status(&self) -> EchStatus { + self.inner.core.data.ech_status + } + + /// Returns the number of TLS1.3 tickets that have been received. + pub fn tls13_tickets_received(&self) -> u32 { + self.inner.tls13_tickets_received + } + + /// Return true if the connection was made with a `ClientConfig` that is FIPS compatible. + /// + /// This is different from [`crate::crypto::CryptoProvider::fips()`]: + /// it is concerned only with cryptography, whereas this _also_ covers TLS-level + /// configuration that NIST recommends, as well as ECH HPKE suites if applicable. + pub fn fips(&self) -> bool { + self.inner.core.common_state.fips + } + + fn write_early_data(&mut self, data: &[u8]) -> io::Result { + self.inner + .core + .data + .early_data + .check_write(data.len()) + .map(|sz| { + self.inner + .send_early_plaintext(&data[..sz]) + }) + } + } + + impl Deref for ClientConnection { + type Target = ConnectionCommon; + + fn deref(&self) -> &Self::Target { + &self.inner + } + } + + impl DerefMut for ClientConnection { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.inner + } + } + + #[doc(hidden)] + impl<'a> TryFrom<&'a mut crate::Connection> for &'a mut ClientConnection { + type Error = (); + + fn try_from(value: &'a mut crate::Connection) -> Result { + use crate::Connection::*; + match value { + Client(conn) => Ok(conn), + Server(_) => Err(()), + } + } + } + + impl From for crate::Connection { + fn from(conn: ClientConnection) -> Self { + Self::Client(conn) + } + } +} +#[cfg(feature = "std")] +pub use connection::{ClientConnection, WriteEarlyData}; + +impl ConnectionCore { + pub(crate) fn for_client( + config: Arc, + name: ServerName<'static>, + extra_exts: ClientExtensionsInput<'static>, + proto: Protocol, + ) -> Result { + let mut common_state = CommonState::new(Side::Client); + common_state.set_max_fragment_size(config.max_fragment_size)?; + common_state.protocol = proto; + common_state.enable_secret_extraction = config.enable_secret_extraction; + common_state.fips = config.fips(); + let mut data = ClientConnectionData::new(); + + let mut cx = hs::ClientContext { + common: &mut common_state, + data: &mut data, + // `start_handshake` won't produce plaintext + sendable_plaintext: None, + }; + + let input = ClientHelloInput::new(name, &extra_exts, &mut cx, config)?; + let state = input.start_handshake(extra_exts, &mut cx)?; + Ok(Self::new(state, data, common_state)) + } + + #[cfg(feature = "std")] + pub(crate) fn is_early_data_accepted(&self) -> bool { + self.data.early_data.is_accepted() + } +} + +/// Unbuffered version of `ClientConnection` +/// +/// See the [`crate::unbuffered`] module docs for more details +pub struct UnbufferedClientConnection { + inner: UnbufferedConnectionCommon, +} + +impl UnbufferedClientConnection { + /// Make a new ClientConnection. `config` controls how we behave in the TLS protocol, `name` is + /// the name of the server we want to talk to. + pub fn new(config: Arc, name: ServerName<'static>) -> Result { + Self::new_with_extensions( + config.clone(), + name, + ClientExtensionsInput::from_alpn(config.alpn_protocols.clone()), + ) + } + + /// Make a new UnbufferedClientConnection with custom ALPN protocols. + pub fn new_with_alpn( + config: Arc, + name: ServerName<'static>, + alpn_protocols: Vec>, + ) -> Result { + Self::new_with_extensions( + config, + name, + ClientExtensionsInput::from_alpn(alpn_protocols), + ) + } + + fn new_with_extensions( + config: Arc, + name: ServerName<'static>, + extensions: ClientExtensionsInput<'static>, + ) -> Result { + Ok(Self { + inner: UnbufferedConnectionCommon::from(ConnectionCore::for_client( + config, + name, + extensions, + Protocol::Tcp, + )?), + }) + } + + /// Extract secrets, so they can be used when configuring kTLS, for example. + /// Should be used with care as it exposes secret key material. + #[deprecated = "dangerous_extract_secrets() does not support session tickets or \ + key updates, use dangerous_into_kernel_connection() instead"] + pub fn dangerous_extract_secrets(self) -> Result { + self.inner.dangerous_extract_secrets() + } + + /// Extract secrets and a [`KernelConnection`] object. + /// + /// This allows you use rustls to manage keys and then manage encryption and + /// decryption yourself (e.g. for kTLS). + /// + /// Should be used with care as it exposes secret key material. + /// + /// See the [`crate::kernel`] documentations for details on prerequisites + /// for calling this method. + pub fn dangerous_into_kernel_connection( + self, + ) -> Result<(ExtractedSecrets, KernelConnection), Error> { + self.inner + .core + .dangerous_into_kernel_connection() + } + + /// Returns the number of TLS1.3 tickets that have been received. + pub fn tls13_tickets_received(&self) -> u32 { + self.inner.tls13_tickets_received + } +} + +impl Deref for UnbufferedClientConnection { + type Target = UnbufferedConnectionCommon; + + fn deref(&self) -> &Self::Target { + &self.inner + } +} + +impl DerefMut for UnbufferedClientConnection { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.inner + } +} + +impl TransmitTlsData<'_, ClientConnectionData> { + /// returns an adapter that allows encrypting early (RTT-0) data before transmitting the + /// already encoded TLS data + /// + /// IF allowed by the protocol + pub fn may_encrypt_early_data(&mut self) -> Option> { + if self + .conn + .core + .data + .early_data + .is_enabled() + { + Some(MayEncryptEarlyData { conn: self.conn }) + } else { + None + } + } +} + +/// Allows encrypting early (RTT-0) data +pub struct MayEncryptEarlyData<'c> { + conn: &'c mut UnbufferedConnectionCommon, +} + +impl MayEncryptEarlyData<'_> { + /// Encrypts `application_data` into the `outgoing_tls` buffer + /// + /// returns the number of bytes that were written into `outgoing_tls`, or an error if + /// the provided buffer was too small. In the error case, `outgoing_tls` is not modified + pub fn encrypt( + &mut self, + early_data: &[u8], + outgoing_tls: &mut [u8], + ) -> Result { + let Some(allowed) = self + .conn + .core + .data + .early_data + .check_write_opt(early_data.len()) + else { + return Err(EarlyDataError::ExceededAllowedEarlyData); + }; + + self.conn + .core + .common_state + .write_plaintext(early_data[..allowed].into(), outgoing_tls) + .map_err(|e| e.into()) + } +} + +/// Errors that may arise when encrypting early (RTT-0) data +#[derive(Debug)] +pub enum EarlyDataError { + /// Cannot encrypt more early data due to imposed limits + ExceededAllowedEarlyData, + /// Encryption error + Encrypt(EncryptError), +} + +impl From for EarlyDataError { + fn from(v: EncryptError) -> Self { + Self::Encrypt(v) + } +} + +impl fmt::Display for EarlyDataError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::ExceededAllowedEarlyData => f.write_str("cannot send any more early data"), + Self::Encrypt(e) => fmt::Display::fmt(e, f), + } + } +} + +#[cfg(feature = "std")] +impl std::error::Error for EarlyDataError {} + +/// State associated with a client connection. +#[derive(Debug)] +pub struct ClientConnectionData { + pub(super) early_data: EarlyData, + pub(super) ech_status: EchStatus, +} + +impl ClientConnectionData { + fn new() -> Self { + Self { + early_data: EarlyData::new(), + ech_status: EchStatus::NotOffered, + } + } +} + +impl crate::conn::SideData for ClientConnectionData {} diff --git a/http/vendor/rustls/src/client/common.rs b/http/vendor/rustls/src/client/common.rs new file mode 100644 index 0000000..9afa0c3 --- /dev/null +++ b/http/vendor/rustls/src/client/common.rs @@ -0,0 +1,119 @@ +use alloc::boxed::Box; +use alloc::vec::Vec; + +use super::ResolvesClientCert; +use crate::log::{debug, trace}; +use crate::msgs::enums::ExtensionType; +use crate::msgs::handshake::{CertificateChain, DistinguishedName, ProtocolName, ServerExtensions}; +use crate::sync::Arc; +use crate::{SignatureScheme, compress, sign}; + +#[derive(Debug)] +pub(super) struct ServerCertDetails<'a> { + pub(super) cert_chain: CertificateChain<'a>, + pub(super) ocsp_response: Vec, +} + +impl<'a> ServerCertDetails<'a> { + pub(super) fn new(cert_chain: CertificateChain<'a>, ocsp_response: Vec) -> Self { + Self { + cert_chain, + ocsp_response, + } + } + + pub(super) fn into_owned(self) -> ServerCertDetails<'static> { + let Self { + cert_chain, + ocsp_response, + } = self; + ServerCertDetails { + cert_chain: cert_chain.into_owned(), + ocsp_response, + } + } +} + +pub(super) struct ClientHelloDetails { + pub(super) alpn_protocols: Vec, + pub(super) sent_extensions: Vec, + pub(super) extension_order_seed: u16, + pub(super) offered_cert_compression: bool, +} + +impl ClientHelloDetails { + pub(super) fn new(alpn_protocols: Vec, extension_order_seed: u16) -> Self { + Self { + alpn_protocols, + sent_extensions: Vec::new(), + extension_order_seed, + offered_cert_compression: false, + } + } + + pub(super) fn server_sent_unsolicited_extensions( + &self, + received_exts: &ServerExtensions<'_>, + allowed_unsolicited: &[ExtensionType], + ) -> bool { + let mut extensions = received_exts.collect_used(); + extensions.extend( + received_exts + .unknown_extensions + .iter() + .map(|ext| ExtensionType::from(*ext)), + ); + for ext_type in extensions { + if !self.sent_extensions.contains(&ext_type) && !allowed_unsolicited.contains(&ext_type) + { + trace!("Unsolicited extension {ext_type:?}"); + return true; + } + } + + false + } +} + +pub(super) enum ClientAuthDetails { + /// Send an empty `Certificate` and no `CertificateVerify`. + Empty { auth_context_tls13: Option> }, + /// Send a non-empty `Certificate` and a `CertificateVerify`. + Verify { + certkey: Arc, + signer: Box, + auth_context_tls13: Option>, + compressor: Option<&'static dyn compress::CertCompressor>, + }, +} + +impl ClientAuthDetails { + pub(super) fn resolve( + resolver: &dyn ResolvesClientCert, + canames: Option<&[DistinguishedName]>, + sigschemes: &[SignatureScheme], + auth_context_tls13: Option>, + compressor: Option<&'static dyn compress::CertCompressor>, + ) -> Self { + let acceptable_issuers = canames + .unwrap_or_default() + .iter() + .map(|p| p.as_ref()) + .collect::>(); + + if let Some(certkey) = resolver.resolve(&acceptable_issuers, sigschemes) { + if let Some(signer) = certkey.key.choose_scheme(sigschemes) { + debug!("Attempting client auth"); + return Self::Verify { + certkey, + signer, + auth_context_tls13, + compressor, + }; + } + } + + debug!("Client auth requested but no cert/sigscheme available"); + Self::Empty { auth_context_tls13 } + } +} diff --git a/http/vendor/rustls/src/client/ech.rs b/http/vendor/rustls/src/client/ech.rs new file mode 100644 index 0000000..5675e71 --- /dev/null +++ b/http/vendor/rustls/src/client/ech.rs @@ -0,0 +1,1083 @@ +use alloc::boxed::Box; +use alloc::vec; +use alloc::vec::Vec; +use core::iter; + +use pki_types::{DnsName, EchConfigListBytes, ServerName}; +use subtle::ConstantTimeEq; + +use crate::CipherSuite::TLS_EMPTY_RENEGOTIATION_INFO_SCSV; +use crate::client::tls13; +use crate::crypto::SecureRandom; +use crate::crypto::hash::Hash; +use crate::crypto::hpke::{EncapsulatedSecret, Hpke, HpkePublicKey, HpkeSealer, HpkeSuite}; +use crate::hash_hs::{HandshakeHash, HandshakeHashBuffer}; +use crate::log::{debug, trace, warn}; +use crate::msgs::base::{Payload, PayloadU16}; +use crate::msgs::codec::{Codec, Reader}; +use crate::msgs::enums::{ExtensionType, HpkeKem}; +use crate::msgs::handshake::{ + ClientExtensions, ClientHelloPayload, EchConfigContents, EchConfigPayload, Encoding, + EncryptedClientHello, EncryptedClientHelloOuter, HandshakeMessagePayload, HandshakePayload, + HelloRetryRequest, HpkeKeyConfig, HpkeSymmetricCipherSuite, PresharedKeyBinder, + PresharedKeyOffer, Random, ServerHelloPayload, ServerNamePayload, +}; +use crate::msgs::message::{Message, MessagePayload}; +use crate::msgs::persist; +use crate::msgs::persist::Retrieved; +use crate::tls13::key_schedule::{ + KeyScheduleEarly, KeyScheduleHandshakeStart, server_ech_hrr_confirmation_secret, +}; +use crate::{ + AlertDescription, ClientConfig, CommonState, EncryptedClientHelloError, Error, + PeerIncompatible, PeerMisbehaved, ProtocolVersion, Tls13CipherSuite, +}; + +/// Controls how Encrypted Client Hello (ECH) is used in a client handshake. +#[derive(Clone, Debug)] +pub enum EchMode { + /// ECH is enabled and the ClientHello will be encrypted based on the provided + /// configuration. + Enable(EchConfig), + + /// No ECH configuration is available but the client should act as though it were. + /// + /// This is an anti-ossification measure, sometimes referred to as "GREASE"[^0]. + /// [^0]: + Grease(EchGreaseConfig), +} + +impl EchMode { + /// Returns true if the ECH mode will use a FIPS approved HPKE suite. + pub fn fips(&self) -> bool { + match self { + Self::Enable(ech_config) => ech_config.suite.fips(), + Self::Grease(grease_config) => grease_config.suite.fips(), + } + } +} + +impl From for EchMode { + fn from(config: EchConfig) -> Self { + Self::Enable(config) + } +} + +impl From for EchMode { + fn from(config: EchGreaseConfig) -> Self { + Self::Grease(config) + } +} + +/// Configuration for performing encrypted client hello. +/// +/// Note: differs from the protocol-encoded EchConfig (`EchConfigMsg`). +#[derive(Clone, Debug)] +pub struct EchConfig { + /// The selected EchConfig. + pub(crate) config: EchConfigPayload, + + /// An HPKE instance corresponding to a suite from the `config` we have selected as + /// a compatible choice. + pub(crate) suite: &'static dyn Hpke, +} + +impl EchConfig { + /// Construct an EchConfig by selecting a ECH config from the provided bytes that is compatible + /// with one of the given HPKE suites. + /// + /// The config list bytes should be sourced from a DNS-over-HTTPS lookup resolving the `HTTPS` + /// resource record for the host name of the server you wish to connect via ECH, + /// and extracting the ECH configuration from the `ech` parameter. The extracted bytes should + /// be base64 decoded to yield the `EchConfigListBytes` you provide to rustls. + /// + /// One of the provided ECH configurations must be compatible with the HPKE provider's supported + /// suites or an error will be returned. + /// + /// See the [`ech-client.rs`] example for a complete example of fetching ECH configs from DNS. + /// + /// [`ech-client.rs`]: https://github.com/rustls/rustls/blob/main/examples/src/bin/ech-client.rs + pub fn new( + ech_config_list: EchConfigListBytes<'_>, + hpke_suites: &[&'static dyn Hpke], + ) -> Result { + let ech_configs = Vec::::read(&mut Reader::init(&ech_config_list)) + .map_err(|_| { + Error::InvalidEncryptedClientHello(EncryptedClientHelloError::InvalidConfigList) + })?; + + // Note: we name the index var _i because if the log feature is disabled + // it is unused. + #[cfg_attr(not(feature = "logging"), allow(clippy::unused_enumerate_index))] + for (_i, config) in ech_configs.iter().enumerate() { + let contents = match config { + EchConfigPayload::V18(contents) => contents, + EchConfigPayload::Unknown { + version: _version, .. + } => { + warn!( + "ECH config {} has unsupported version {:?}", + _i + 1, + _version + ); + continue; // Unsupported version. + } + }; + + if contents.has_unknown_mandatory_extension() || contents.has_duplicate_extension() { + warn!("ECH config has duplicate, or unknown mandatory extensions: {contents:?}",); + continue; // Unsupported, or malformed extensions. + } + + let key_config = &contents.key_config; + for cipher_suite in &key_config.symmetric_cipher_suites { + if cipher_suite.aead_id.tag_len().is_none() { + continue; // Unsupported EXPORT_ONLY AEAD cipher suite. + } + + let suite = HpkeSuite { + kem: key_config.kem_id, + sym: *cipher_suite, + }; + if let Some(hpke) = hpke_suites + .iter() + .find(|hpke| hpke.suite() == suite) + { + debug!( + "selected ECH config ID {:?} suite {:?} public_name {:?}", + key_config.config_id, suite, contents.public_name + ); + return Ok(Self { + config: config.clone(), + suite: *hpke, + }); + } + } + } + + Err(EncryptedClientHelloError::NoCompatibleConfig.into()) + } + + pub(super) fn state( + &self, + server_name: ServerName<'static>, + config: &ClientConfig, + ) -> Result { + EchState::new( + self, + server_name.clone(), + config + .client_auth_cert_resolver + .has_certs(), + config.provider.secure_random, + config.enable_sni, + ) + } + + /// Compute the HPKE `SetupBaseS` `info` parameter for this ECH configuration. + /// + /// See . + pub(crate) fn hpke_info(&self) -> Vec { + let mut info = Vec::with_capacity(128); + // "tls ech" || 0x00 || ECHConfig + info.extend_from_slice(b"tls ech\0"); + self.config.encode(&mut info); + info + } +} + +/// Configuration for GREASE Encrypted Client Hello. +#[derive(Clone, Debug)] +pub struct EchGreaseConfig { + pub(crate) suite: &'static dyn Hpke, + pub(crate) placeholder_key: HpkePublicKey, +} + +impl EchGreaseConfig { + /// Construct a GREASE ECH configuration. + /// + /// This configuration is used when the client wishes to offer ECH to prevent ossification, + /// but doesn't have a real ECH configuration to use for the remote server. In this case + /// a placeholder or "GREASE"[^0] extension is used. + /// + /// Returns an error if the HPKE provider does not support the given suite. + /// + /// [^0]: + pub fn new(suite: &'static dyn Hpke, placeholder_key: HpkePublicKey) -> Self { + Self { + suite, + placeholder_key, + } + } + + /// Build a GREASE ECH extension based on the placeholder configuration. + /// + /// See for + /// more information. + pub(crate) fn grease_ext( + &self, + secure_random: &'static dyn SecureRandom, + inner_name: ServerName<'static>, + outer_hello: &ClientHelloPayload, + ) -> Result { + trace!("Preparing GREASE ECH extension"); + + // Pick a random config id. + let mut config_id: [u8; 1] = [0; 1]; + secure_random.fill(&mut config_id[..])?; + + let suite = self.suite.suite(); + + // Construct a dummy ECH state - we don't have a real ECH config from a server since + // this is for GREASE. + let mut grease_state = EchState::new( + &EchConfig { + config: EchConfigPayload::V18(EchConfigContents { + key_config: HpkeKeyConfig { + config_id: config_id[0], + kem_id: HpkeKem::DHKEM_P256_HKDF_SHA256, + public_key: PayloadU16::new(self.placeholder_key.0.clone()), + symmetric_cipher_suites: vec![suite.sym], + }, + maximum_name_length: 0, + public_name: DnsName::try_from("filler").unwrap(), + extensions: Vec::default(), + }), + suite: self.suite, + }, + inner_name, + false, + secure_random, + false, // Does not matter if we enable/disable SNI here. Inner hello is not used. + )?; + + // Construct an inner hello using the outer hello - this allows us to know the size of + // dummy payload we should use for the GREASE extension. + let encoded_inner_hello = grease_state.encode_inner_hello(outer_hello, None, &None); + + // Generate a payload of random data equivalent in length to a real inner hello. + let payload_len = encoded_inner_hello.len() + + suite + .sym + .aead_id + .tag_len() + // Safety: we have confirmed the AEAD is supported when building the config. All + // supported AEADs have a tag length. + .unwrap(); + let mut payload = vec![0; payload_len]; + secure_random.fill(&mut payload)?; + + // Return the GREASE extension. + Ok(EncryptedClientHello::Outer(EncryptedClientHelloOuter { + cipher_suite: suite.sym, + config_id: config_id[0], + enc: PayloadU16::new(grease_state.enc.0), + payload: PayloadU16::new(payload), + })) + } +} + +/// An enum representing ECH offer status. +#[derive(Debug, Clone, Copy, Eq, PartialEq)] +pub enum EchStatus { + /// ECH was not offered - it is a normal TLS handshake. + NotOffered, + /// GREASE ECH was sent. This is not considered offering ECH. + Grease, + /// ECH was offered but we do not yet know whether the offer was accepted or rejected. + Offered, + /// ECH was offered and the server accepted. + Accepted, + /// ECH was offered and the server rejected. + Rejected, +} + +/// Contextual data for a TLS client handshake that has offered encrypted client hello (ECH). +pub(crate) struct EchState { + // The public DNS name from the ECH configuration we've chosen - this is included as the SNI + // value for the "outer" client hello. It can only be a DnsName, not an IP address. + pub(crate) outer_name: DnsName<'static>, + // If we're resuming in the inner hello, this is the early key schedule to use for encrypting + // early data if the ECH offer is accepted. + pub(crate) early_data_key_schedule: Option, + // A random value we use for the inner hello. + pub(crate) inner_hello_random: Random, + // A transcript buffer maintained for the inner hello. Once ECH is confirmed we switch to + // using this transcript for the handshake. + pub(crate) inner_hello_transcript: HandshakeHashBuffer, + // A source of secure random data. + secure_random: &'static dyn SecureRandom, + // An HPKE sealer context that can be used for encrypting ECH data. + sender: Box, + // The ID of the ECH configuration we've chosen - this is included in the outer ECH extension. + config_id: u8, + // The private server name we'll use for the inner protected hello. + inner_name: ServerName<'static>, + // The advertised maximum name length from the ECH configuration we've chosen - this is used + // for padding calculations. + maximum_name_length: u8, + // A supported symmetric cipher suite from the ECH configuration we've chosen - this is + // included in the outer ECH extension. + cipher_suite: HpkeSymmetricCipherSuite, + // A secret encapsulated to the public key of the remote server. This is included in the + // outer ECH extension for non-retry outer hello messages. + enc: EncapsulatedSecret, + // Whether the inner client hello should contain a server name indication (SNI) extension. + enable_sni: bool, + // The extensions sent in the inner hello. + sent_extensions: Vec, +} + +impl EchState { + pub(crate) fn new( + config: &EchConfig, + inner_name: ServerName<'static>, + client_auth_enabled: bool, + secure_random: &'static dyn SecureRandom, + enable_sni: bool, + ) -> Result { + let EchConfigPayload::V18(config_contents) = &config.config else { + // the public EchConfig::new() constructor ensures we only have supported + // configurations. + unreachable!("ECH config version mismatch"); + }; + let key_config = &config_contents.key_config; + + // Encapsulate a secret for the server's public key, and set up a sender context + // we can use to seal messages. + let (enc, sender) = config.suite.setup_sealer( + &config.hpke_info(), + &HpkePublicKey(key_config.public_key.0.clone()), + )?; + + // Start a new transcript buffer for the inner hello. + let mut inner_hello_transcript = HandshakeHashBuffer::new(); + if client_auth_enabled { + inner_hello_transcript.set_client_auth_enabled(); + } + + Ok(Self { + secure_random, + sender, + config_id: key_config.config_id, + inner_name, + outer_name: config_contents.public_name.clone(), + maximum_name_length: config_contents.maximum_name_length, + cipher_suite: config.suite.suite().sym, + enc, + inner_hello_random: Random::new(secure_random)?, + inner_hello_transcript, + early_data_key_schedule: None, + enable_sni, + sent_extensions: Vec::new(), + }) + } + + /// Construct a ClientHelloPayload offering ECH. + /// + /// An outer hello, with a protected inner hello for the `inner_name` will be returned, and the + /// ECH context will be updated to reflect the inner hello that was offered. + /// + /// If `retry_req` is `Some`, then the outer hello will be constructed for a hello retry request. + /// + /// If `resuming` is `Some`, then the inner hello will be constructed for a resumption handshake. + pub(crate) fn ech_hello( + &mut self, + mut outer_hello: ClientHelloPayload, + retry_req: Option<&HelloRetryRequest>, + resuming: &Option>, + ) -> Result { + trace!( + "Preparing ECH offer {}", + if retry_req.is_some() { "for retry" } else { "" } + ); + + // Construct the encoded inner hello and update the transcript. + let encoded_inner_hello = self.encode_inner_hello(&outer_hello, retry_req, resuming); + + // Complete the ClientHelloOuterAAD with an ech extension, the payload should be a placeholder + // of size L, all zeroes. L == length of encrypting encoded client hello inner w/ the selected + // HPKE AEAD. (sum of plaintext + tag length, typically). + let payload_len = encoded_inner_hello.len() + + self + .cipher_suite + .aead_id + .tag_len() + // Safety: we've already verified this AEAD is supported when loading the config + // that was used to create the ECH context. All supported AEADs have a tag length. + .unwrap(); + + // Outer hello's created in response to a hello retry request omit the enc value. + let enc = match retry_req.is_some() { + true => Vec::default(), + false => self.enc.0.clone(), + }; + + fn outer_hello_ext(ctx: &EchState, enc: Vec, payload: Vec) -> EncryptedClientHello { + EncryptedClientHello::Outer(EncryptedClientHelloOuter { + cipher_suite: ctx.cipher_suite, + config_id: ctx.config_id, + enc: PayloadU16::new(enc), + payload: PayloadU16::new(payload), + }) + } + + // The outer handshake is not permitted to resume a session. If we're resuming in the + // inner handshake we remove the PSK extension from the outer hello, replacing it + // with a GREASE PSK to implement the "ClientHello Malleability Mitigation" mentioned + // in 10.12.3. + if let Some(psk_offer) = outer_hello.preshared_key_offer.as_mut() { + self.grease_psk(psk_offer)?; + } + + // To compute the encoded AAD we add a placeholder extension with an empty payload. + outer_hello.encrypted_client_hello = + Some(outer_hello_ext(self, enc.clone(), vec![0; payload_len])); + + // Next we compute the proper extension payload. + let payload = self + .sender + .seal(&outer_hello.get_encoding(), &encoded_inner_hello)?; + + // And then we replace the placeholder extension with the real one. + outer_hello.encrypted_client_hello = Some(outer_hello_ext(self, enc, payload)); + + Ok(outer_hello) + } + + /// Confirm whether an ECH offer was accepted based on examining the server hello. + pub(crate) fn confirm_acceptance( + self, + ks: &mut KeyScheduleHandshakeStart, + server_hello: &ServerHelloPayload, + server_hello_encoded: &Payload<'_>, + hash: &'static dyn Hash, + ) -> Result, Error> { + // Start the inner transcript hash now that we know the hash algorithm to use. + let inner_transcript = self + .inner_hello_transcript + .start_hash(hash); + + // Fork the transcript that we've started with the inner hello to use for a confirmation step. + // We need to preserve the original inner_transcript to use if this confirmation succeeds. + let mut confirmation_transcript = inner_transcript.clone(); + + // Add the server hello confirmation - this is computed by altering the received + // encoding rather than reencoding it. + confirmation_transcript + .add_message(&Self::server_hello_conf(server_hello, server_hello_encoded)); + + // Derive a confirmation secret from the inner hello random and the confirmation transcript. + let derived = ks.server_ech_confirmation_secret( + self.inner_hello_random.0.as_ref(), + confirmation_transcript.current_hash(), + ); + + // Check that first 8 digits of the derived secret match the last 8 digits of the original + // server random. This match signals that the server accepted the ECH offer. + // Indexing safety: Random is [0; 32] by construction. + + match ConstantTimeEq::ct_eq(derived.as_ref(), server_hello.random.0[24..].as_ref()).into() { + true => { + trace!("ECH accepted by server"); + Ok(Some(EchAccepted { + transcript: inner_transcript, + random: self.inner_hello_random, + sent_extensions: self.sent_extensions, + })) + } + false => { + trace!("ECH rejected by server"); + Ok(None) + } + } + } + + pub(crate) fn confirm_hrr_acceptance( + &self, + hrr: &HelloRetryRequest, + cs: &Tls13CipherSuite, + common: &mut CommonState, + ) -> Result { + // The client checks for the "encrypted_client_hello" extension. + let ech_conf = match &hrr.encrypted_client_hello { + // If none is found, the server has implicitly rejected ECH. + None => return Ok(false), + // Otherwise, if it has a length other than 8, the client aborts the + // handshake with a "decode_error" alert. + Some(ech_conf) if ech_conf.bytes().len() != 8 => { + return Err({ + common.send_fatal_alert( + AlertDescription::DecodeError, + PeerMisbehaved::IllegalHelloRetryRequestWithInvalidEch, + ) + }); + } + Some(ech_conf) => ech_conf, + }; + + // Otherwise the client computes hrr_accept_confirmation as described in Section + // 7.2.1 + let confirmation_transcript = self.inner_hello_transcript.clone(); + let mut confirmation_transcript = + confirmation_transcript.start_hash(cs.common.hash_provider); + confirmation_transcript.rollup_for_hrr(); + confirmation_transcript.add_message(&Self::hello_retry_request_conf(hrr)); + + let derived = server_ech_hrr_confirmation_secret( + cs.hkdf_provider, + &self.inner_hello_random.0, + confirmation_transcript.current_hash(), + ); + + match ConstantTimeEq::ct_eq(derived.as_ref(), ech_conf.bytes()).into() { + true => { + trace!("ECH accepted by server in hello retry request"); + Ok(true) + } + false => { + trace!("ECH rejected by server in hello retry request"); + Ok(false) + } + } + } + + /// Update the ECH context inner hello transcript based on a received hello retry request message. + /// + /// This will start the in-progress transcript using the given `hash`, convert it into an HRR + /// buffer, and then add the hello retry message `m`. + pub(crate) fn transcript_hrr_update(&mut self, hash: &'static dyn Hash, m: &Message<'_>) { + trace!("Updating ECH inner transcript for HRR"); + + let inner_transcript = self + .inner_hello_transcript + .clone() + .start_hash(hash); + + let mut inner_transcript_buffer = inner_transcript.into_hrr_buffer(); + inner_transcript_buffer.add_message(m); + self.inner_hello_transcript = inner_transcript_buffer; + } + + // 5.1 "Encoding the ClientHelloInner" + fn encode_inner_hello( + &mut self, + outer_hello: &ClientHelloPayload, + retryreq: Option<&HelloRetryRequest>, + resuming: &Option>, + ) -> Vec { + // Start building an inner hello using the outer_hello as a template. + let mut inner_hello = ClientHelloPayload { + // Some information is copied over as-is. + client_version: outer_hello.client_version, + session_id: outer_hello.session_id, + compression_methods: outer_hello.compression_methods.clone(), + + // We will build up the included extensions ourselves. + extensions: Box::new(ClientExtensions::default()), + + // Set the inner hello random to the one we generated when creating the ECH state. + // We hold on to the inner_hello_random in the ECH state to use later for confirming + // whether ECH was accepted or not. + random: self.inner_hello_random, + + // We remove the empty renegotiation info SCSV from the outer hello's ciphersuite. + // Similar to the TLS 1.2 specific extensions we will filter out, this is seen as a + // TLS 1.2 only feature by bogo. + cipher_suites: outer_hello + .cipher_suites + .iter() + .filter(|cs| **cs != TLS_EMPTY_RENEGOTIATION_INFO_SCSV) + .cloned() + .collect(), + }; + + inner_hello.order_seed = outer_hello.order_seed; + + // The inner hello will always have an inner variant of the ECH extension added. + // See Section 6.1 rule 4. + inner_hello.encrypted_client_hello = Some(EncryptedClientHello::Inner); + + let inner_sni = match &self.inner_name { + // The inner hello only gets a SNI value if enable_sni is true and the inner name + // is a domain name (not an IP address). + ServerName::DnsName(dns_name) if self.enable_sni => Some(dns_name), + _ => None, + }; + + // Now we consider each of the outer hello's extensions - we can either: + // 1. Omit the extension if it isn't appropriate (e.g. is a TLS 1.2 extension). + // 2. Add the extension to the inner hello as-is. + // 3. Compress the extension, by collecting it into a list of to-be-compressed + // extensions we'll handle separately. + let outer_extensions = outer_hello.used_extensions_in_encoding_order(); + let mut compressed_exts = Vec::with_capacity(outer_extensions.len()); + for ext in outer_extensions { + // Some outer hello extensions are only useful in the context where a TLS 1.3 + // connection allows TLS 1.2. This isn't the case for ECH so we skip adding them + // to the inner hello. + if matches!( + ext, + ExtensionType::ExtendedMasterSecret + | ExtensionType::SessionTicket + | ExtensionType::ECPointFormats + ) { + continue; + } + + if ext == ExtensionType::ServerName { + // We may want to replace the outer hello SNI with our own inner hello specific SNI. + if let Some(sni_value) = inner_sni { + inner_hello.server_name = Some(ServerNamePayload::from(sni_value)); + } + // We don't want to add, or compress, the SNI from the outer hello. + continue; + } + + // Compressed extensions need to be put aside to include in one contiguous block. + // Uncompressed extensions get added directly to the inner hello. + if ext.ech_compress() { + compressed_exts.push(ext); + } + + inner_hello.clone_one(outer_hello, ext); + } + + // We've added all the uncompressed extensions. Now we need to add the contiguous + // block of to-be-compressed extensions. + inner_hello.contiguous_extensions = compressed_exts.clone(); + + // Note which extensions we're sending in the inner hello. This may differ from + // the outer hello (e.g. the inner hello may omit SNI while the outer hello will + // always have the ECH cover name in SNI). + self.sent_extensions = inner_hello.collect_used(); + + // If we're resuming, we need to update the PSK binder in the inner hello. + if let Some(resuming) = resuming.as_ref() { + let mut chp = HandshakeMessagePayload(HandshakePayload::ClientHello(inner_hello)); + + // Retain the early key schedule we get from processing the binder. + self.early_data_key_schedule = Some(tls13::fill_in_psk_binder( + resuming, + &self.inner_hello_transcript, + &mut chp, + )); + + // fill_in_psk_binder works on an owned HandshakeMessagePayload, so we need to + // extract our inner hello back out of it to retain ownership. + inner_hello = match chp.0 { + HandshakePayload::ClientHello(chp) => chp, + // Safety: we construct the HMP above and know its type unconditionally. + _ => unreachable!(), + }; + } + + trace!("ECH Inner Hello: {inner_hello:#?}"); + + // Encode the inner hello according to the rules required for ECH. This differs + // from the standard encoding in several ways. Notably this is where we will + // replace the block of contiguous to-be-compressed extensions with a marker. + let mut encoded_hello = inner_hello.ech_inner_encoding(compressed_exts); + + // Calculate padding + // max_name_len = L + let max_name_len = usize::from(self.maximum_name_length); + let max_name_len = if max_name_len > 0 { max_name_len } else { 255 }; + + let name_padding_len = match &inner_hello.server_name { + Some(ServerNamePayload::SingleDnsName(name)) => { + // name.len() = D + // max(0, L - D) + Ord::max(0, max_name_len.saturating_sub(name.as_ref().len())) + } + // L + 9 + // "This is the length of a "server_name" extension with an L-byte name." + _ => max_name_len + 9, + }; + encoded_hello.extend(iter::repeat(0).take(name_padding_len)); + + // Let L be the length of the EncodedClientHelloInner with all the padding computed so far + // Let N = 31 - ((L - 1) % 32) and add N bytes of padding. + let padding_len = 31 - ((encoded_hello.len() - 1) % 32); + encoded_hello.extend(iter::repeat(0).take(padding_len)); + + // Construct the inner hello message that will be used for the transcript. + let inner_hello_msg = Message { + version: match retryreq { + // : + // "This value MUST be set to 0x0303 for all records generated + // by a TLS 1.3 implementation ..." + Some(_) => ProtocolVersion::TLSv1_2, + // "... other than an initial ClientHello (i.e., one not + // generated after a HelloRetryRequest), where it MAY also be + // 0x0301 for compatibility purposes" + // + // (retryreq == None means we're in the "initial ClientHello" case) + None => ProtocolVersion::TLSv1_0, + }, + payload: MessagePayload::handshake(HandshakeMessagePayload( + HandshakePayload::ClientHello(inner_hello), + )), + }; + + // Update the inner transcript buffer with the inner hello message. + self.inner_hello_transcript + .add_message(&inner_hello_msg); + + encoded_hello + } + + // See https://datatracker.ietf.org/doc/html/draft-ietf-tls-esni-18#name-grease-psk + fn grease_psk(&self, psk_offer: &mut PresharedKeyOffer) -> Result<(), Error> { + for ident in psk_offer.identities.iter_mut() { + // "For each PSK identity advertised in the ClientHelloInner, the + // client generates a random PSK identity with the same length." + self.secure_random + .fill(&mut ident.identity.0)?; + // "It also generates a random, 32-bit, unsigned integer to use as + // the obfuscated_ticket_age." + let mut ticket_age = [0_u8; 4]; + self.secure_random + .fill(&mut ticket_age)?; + ident.obfuscated_ticket_age = u32::from_be_bytes(ticket_age); + } + + // "Likewise, for each inner PSK binder, the client generates a random string + // of the same length." + psk_offer.binders = psk_offer + .binders + .iter() + .map(|old_binder| { + // We can't access the wrapped binder PresharedKeyBinder's PayloadU8 mutably, + // so we construct new PresharedKeyBinder's from scratch with the same length. + let mut new_binder = vec![0; old_binder.as_ref().len()]; + self.secure_random + .fill(&mut new_binder)?; + Ok::(PresharedKeyBinder::from(new_binder)) + }) + .collect::>()?; + Ok(()) + } + + fn server_hello_conf( + server_hello: &ServerHelloPayload, + server_hello_encoded: &Payload<'_>, + ) -> Message<'static> { + // The confirmation is computed over the server hello, which has had + // its `random` field altered to zero the final 8 bytes. + // + // nb. we don't require that we can round-trip a `ServerHelloPayload`, to + // allow for efficiency in its in-memory representation. That means + // we operate here on the received encoding, as the confirmation needs + // to be computed on that. + let mut encoded = server_hello_encoded.clone().into_vec(); + encoded[SERVER_HELLO_ECH_CONFIRMATION_SPAN].fill(0x00); + + Message { + version: ProtocolVersion::TLSv1_3, + payload: MessagePayload::Handshake { + encoded: Payload::Owned(encoded), + parsed: HandshakeMessagePayload(HandshakePayload::ServerHello( + server_hello.clone(), + )), + }, + } + } + + fn hello_retry_request_conf(retry_req: &HelloRetryRequest) -> Message<'_> { + Self::ech_conf_message(HandshakeMessagePayload( + HandshakePayload::HelloRetryRequest(retry_req.clone()), + )) + } + + fn ech_conf_message(hmp: HandshakeMessagePayload<'_>) -> Message<'_> { + let mut hmp_encoded = Vec::new(); + hmp.payload_encode(&mut hmp_encoded, Encoding::EchConfirmation); + Message { + version: ProtocolVersion::TLSv1_3, + payload: MessagePayload::Handshake { + encoded: Payload::new(hmp_encoded), + parsed: hmp, + }, + } + } +} + +/// The last eight bytes of the ServerHello's random, taken from a Handshake message containing it. +/// +/// This has: +/// - a HandshakeType (1 byte), +/// - an exterior length (3 bytes), +/// - the legacy_version (2 bytes), and +/// - the balance of the random field (24 bytes). +const SERVER_HELLO_ECH_CONFIRMATION_SPAN: core::ops::Range = + (1 + 3 + 2 + 24)..(1 + 3 + 2 + 32); + +/// Returned from EchState::check_acceptance when the server has accepted the ECH offer. +/// +/// Holds the state required to continue the handshake with the inner hello from the ECH offer. +pub(crate) struct EchAccepted { + pub(crate) transcript: HandshakeHash, + pub(crate) random: Random, + pub(crate) sent_extensions: Vec, +} + +pub(crate) fn fatal_alert_required( + retry_configs: Option>, + common: &mut CommonState, +) -> Error { + common.send_fatal_alert( + AlertDescription::EncryptedClientHelloRequired, + PeerIncompatible::ServerRejectedEncryptedClientHello(retry_configs), + ) +} + +#[cfg(test)] +mod tests { + use std::string::String; + + use super::*; + use crate::enums::CipherSuite; + use crate::msgs::enums::{Compression, HpkeAead, HpkeKdf}; + use crate::msgs::handshake::{Random, ServerExtensions, SessionId}; + + #[test] + fn server_hello_conf_alters_server_hello_random() { + let server_hello = ServerHelloPayload { + legacy_version: ProtocolVersion::TLSv1_2, + random: Random([0xffu8; 32]), + session_id: SessionId::empty(), + cipher_suite: CipherSuite::TLS13_AES_256_GCM_SHA384, + compression_method: Compression::Null, + extensions: Box::new(ServerExtensions::default()), + }; + let message = Message { + version: ProtocolVersion::TLSv1_3, + payload: MessagePayload::handshake(HandshakeMessagePayload( + HandshakePayload::ServerHello(server_hello.clone()), + )), + }; + let Message { + payload: + MessagePayload::Handshake { + encoded: server_hello_encoded_before, + .. + }, + .. + } = &message + else { + unreachable!("ServerHello is a handshake message"); + }; + + let message = EchState::server_hello_conf(&server_hello, server_hello_encoded_before); + + let Message { + payload: + MessagePayload::Handshake { + encoded: server_hello_encoded_after, + .. + }, + .. + } = &message + else { + unreachable!("ServerHello is a handshake message"); + }; + + assert_eq!( + std::format!("{server_hello_encoded_before:x?}"), + "020000280303ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001302000000", + "beforehand eight bytes at end of Random should be 0xff here ^^^^^^^^^^^^^^^^ " + ); + assert_eq!( + std::format!("{server_hello_encoded_after:x?}"), + "020000280303ffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000001302000000", + " afterwards those bytes are zeroed ^^^^^^^^^^^^^^^^ " + ); + } + + #[test] + fn inner_client_hello_length_conceals_inner_name_length() { + let base_inner_len = inner_hello_encoding_for_name(dns_name_of_len(1), true).len(); + assert!( + base_inner_len % 32 == 0, + "inner hello length must be 32-byte padded" + ); + assert!( + base_inner_len >= 256, + "inner hello must include inner name and its padding" + ); + + for inner_name_len in 1..251 { + assert_eq!( + inner_hello_encoding_for_name(dns_name_of_len(inner_name_len), true).len(), + base_inner_len, + "all inner hello lengths must be invariant wrt inner name length" + ); + } + } + + #[test] + fn inner_client_hello_length_does_not_leak_length_of_omitted_inner_name() { + let base_inner_len = inner_hello_encoding_for_name(dns_name_of_len(1), false).len(); + assert!( + base_inner_len % 32 == 0, + "inner hello length must be 32-byte padded" + ); + assert!( + base_inner_len >= 256, + "inner hello must include maximum_name_length bytes of padding" + ); + + for inner_name_len in 1..251 { + assert_eq!( + inner_hello_encoding_for_name(dns_name_of_len(inner_name_len), false).len(), + base_inner_len, + "all inner hello lengths must be invariant wrt inner name length" + ); + } + } + + fn inner_hello_encoding_for_name(name: DnsName<'static>, enable_sni: bool) -> Vec { + let config = EchConfig { + config: EchConfigPayload::V18(EchConfigContents { + key_config: HpkeKeyConfig { + config_id: 0, + kem_id: MockHpke::SUITE.kem, + public_key: PayloadU16::new(vec![0; 32]), + symmetric_cipher_suites: vec![], + }, + maximum_name_length: 255, + public_name: DnsName::try_from("public").unwrap(), + extensions: vec![], + }), + suite: &MockHpke, + }; + + EchState::new( + &config, + ServerName::from(name.clone()), + false, + &FixedRandom, + enable_sni, + ) + .unwrap() + .encode_inner_hello( + &ClientHelloPayload { + client_version: ProtocolVersion::TLSv1_3, + random: Random([0u8; 32]), + session_id: SessionId::empty(), + cipher_suites: vec![], + compression_methods: vec![Compression::Null], + extensions: Box::new(ClientExtensions { + server_name: Some(ServerNamePayload::from(&name)), + ..Default::default() + }), + }, + None, + &None, + ) + } + + fn dns_name_of_len(mut len: usize) -> DnsName<'static> { + let mut s = String::new(); + let labels = len.div_ceil(63); + for _ in 0..labels { + let chars = Ord::min(len, 63); + len -= chars; + for _ in 0..chars { + s.push('a'); + } + if len != 0 { + s.push('.'); + } + } + DnsName::try_from(s).unwrap() + } + + #[derive(Debug)] + struct MockHpke; + + impl MockHpke { + const SUITE: HpkeSuite = HpkeSuite { + kem: HpkeKem::DHKEM_P256_HKDF_SHA256, + sym: HpkeSymmetricCipherSuite { + kdf_id: HpkeKdf::HKDF_SHA256, + aead_id: HpkeAead::AES_128_GCM, + }, + }; + } + + impl Hpke for MockHpke { + #[cfg_attr(coverage_nightly, coverage(off))] + fn seal( + &self, + _info: &[u8], + _aad: &[u8], + _plaintext: &[u8], + _pub_key: &HpkePublicKey, + ) -> Result<(EncapsulatedSecret, Vec), Error> { + todo!() + } + + fn setup_sealer( + &self, + _info: &[u8], + _pub_key: &HpkePublicKey, + ) -> Result<(EncapsulatedSecret, Box), Error> { + Ok((EncapsulatedSecret(vec![]), Box::new(MockHpkeSealer))) + } + + #[cfg_attr(coverage_nightly, coverage(off))] + fn open( + &self, + _enc: &EncapsulatedSecret, + _info: &[u8], + _aad: &[u8], + _ciphertext: &[u8], + _secret_key: &crate::crypto::hpke::HpkePrivateKey, + ) -> Result, Error> { + todo!() + } + + #[cfg_attr(coverage_nightly, coverage(off))] + fn setup_opener( + &self, + _enc: &EncapsulatedSecret, + _info: &[u8], + _secret_key: &crate::crypto::hpke::HpkePrivateKey, + ) -> Result, Error> { + todo!() + } + + #[cfg_attr(coverage_nightly, coverage(off))] + fn generate_key_pair( + &self, + ) -> Result<(HpkePublicKey, crate::crypto::hpke::HpkePrivateKey), Error> { + todo!() + } + + fn suite(&self) -> HpkeSuite { + Self::SUITE + } + } + + #[derive(Debug)] + struct MockHpkeSealer; + + impl HpkeSealer for MockHpkeSealer { + #[cfg_attr(coverage_nightly, coverage(off))] + fn seal(&mut self, _aad: &[u8], _plaintext: &[u8]) -> Result, Error> { + todo!() + } + } + + #[derive(Debug)] + struct FixedRandom; + + impl SecureRandom for FixedRandom { + fn fill(&self, buf: &mut [u8]) -> Result<(), crate::rand::GetRandomFailed> { + buf.fill(0x55); + Ok(()) + } + } +} diff --git a/http/vendor/rustls/src/client/handy.rs b/http/vendor/rustls/src/client/handy.rs new file mode 100644 index 0000000..3ad3073 --- /dev/null +++ b/http/vendor/rustls/src/client/handy.rs @@ -0,0 +1,390 @@ +use pki_types::ServerName; + +use crate::enums::SignatureScheme; +use crate::msgs::persist; +use crate::sync::Arc; +use crate::{NamedGroup, client, sign}; + +/// An implementer of `ClientSessionStore` which does nothing. +#[derive(Debug)] +pub(super) struct NoClientSessionStorage; + +impl client::ClientSessionStore for NoClientSessionStorage { + fn set_kx_hint(&self, _: ServerName<'static>, _: NamedGroup) {} + + fn kx_hint(&self, _: &ServerName<'_>) -> Option { + None + } + + fn set_tls12_session(&self, _: ServerName<'static>, _: persist::Tls12ClientSessionValue) {} + + fn tls12_session(&self, _: &ServerName<'_>) -> Option { + None + } + + fn remove_tls12_session(&self, _: &ServerName<'_>) {} + + fn insert_tls13_ticket(&self, _: ServerName<'static>, _: persist::Tls13ClientSessionValue) {} + + fn take_tls13_ticket(&self, _: &ServerName<'_>) -> Option { + None + } +} + +#[cfg(any(feature = "std", feature = "hashbrown"))] +mod cache { + use alloc::collections::VecDeque; + use core::fmt; + + use pki_types::ServerName; + + use crate::lock::Mutex; + use crate::msgs::persist; + use crate::{NamedGroup, limited_cache}; + + const MAX_TLS13_TICKETS_PER_SERVER: usize = 8; + + struct ServerData { + kx_hint: Option, + + // Zero or one TLS1.2 sessions. + #[cfg(feature = "tls12")] + tls12: Option, + + // Up to MAX_TLS13_TICKETS_PER_SERVER TLS1.3 tickets, oldest first. + tls13: VecDeque, + } + + impl Default for ServerData { + fn default() -> Self { + Self { + kx_hint: None, + #[cfg(feature = "tls12")] + tls12: None, + tls13: VecDeque::with_capacity(MAX_TLS13_TICKETS_PER_SERVER), + } + } + } + + /// An implementer of `ClientSessionStore` that stores everything + /// in memory. + /// + /// It enforces a limit on the number of entries to bound memory usage. + pub struct ClientSessionMemoryCache { + servers: Mutex, ServerData>>, + } + + impl ClientSessionMemoryCache { + /// Make a new ClientSessionMemoryCache. `size` is the + /// maximum number of stored sessions. + #[cfg(feature = "std")] + pub fn new(size: usize) -> Self { + let max_servers = size.saturating_add(MAX_TLS13_TICKETS_PER_SERVER - 1) + / MAX_TLS13_TICKETS_PER_SERVER; + Self { + servers: Mutex::new(limited_cache::LimitedCache::new(max_servers)), + } + } + + /// Make a new ClientSessionMemoryCache. `size` is the + /// maximum number of stored sessions. + #[cfg(not(feature = "std"))] + pub fn new(size: usize) -> Self { + let max_servers = size.saturating_add(MAX_TLS13_TICKETS_PER_SERVER - 1) + / MAX_TLS13_TICKETS_PER_SERVER; + Self { + servers: Mutex::new::(limited_cache::LimitedCache::new(max_servers)), + } + } + } + + impl super::client::ClientSessionStore for ClientSessionMemoryCache { + fn set_kx_hint(&self, server_name: ServerName<'static>, group: NamedGroup) { + self.servers + .lock() + .unwrap() + .get_or_insert_default_and_edit(server_name, |data| data.kx_hint = Some(group)); + } + + fn kx_hint(&self, server_name: &ServerName<'_>) -> Option { + self.servers + .lock() + .unwrap() + .get(server_name) + .and_then(|sd| sd.kx_hint) + } + + fn set_tls12_session( + &self, + _server_name: ServerName<'static>, + _value: persist::Tls12ClientSessionValue, + ) { + #[cfg(feature = "tls12")] + self.servers + .lock() + .unwrap() + .get_or_insert_default_and_edit(_server_name.clone(), |data| { + data.tls12 = Some(_value) + }); + } + + fn tls12_session( + &self, + _server_name: &ServerName<'_>, + ) -> Option { + #[cfg(not(feature = "tls12"))] + return None; + + #[cfg(feature = "tls12")] + self.servers + .lock() + .unwrap() + .get(_server_name) + .and_then(|sd| sd.tls12.as_ref().cloned()) + } + + fn remove_tls12_session(&self, _server_name: &ServerName<'static>) { + #[cfg(feature = "tls12")] + self.servers + .lock() + .unwrap() + .get_mut(_server_name) + .and_then(|data| data.tls12.take()); + } + + fn insert_tls13_ticket( + &self, + server_name: ServerName<'static>, + value: persist::Tls13ClientSessionValue, + ) { + self.servers + .lock() + .unwrap() + .get_or_insert_default_and_edit(server_name.clone(), |data| { + if data.tls13.len() == data.tls13.capacity() { + data.tls13.pop_front(); + } + data.tls13.push_back(value); + }); + } + + fn take_tls13_ticket( + &self, + server_name: &ServerName<'static>, + ) -> Option { + self.servers + .lock() + .unwrap() + .get_mut(server_name) + .and_then(|data| data.tls13.pop_back()) + } + } + + impl fmt::Debug for ClientSessionMemoryCache { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + // Note: we omit self.servers as it may contain sensitive data. + f.debug_struct("ClientSessionMemoryCache") + .finish() + } + } +} + +#[cfg(any(feature = "std", feature = "hashbrown"))] +pub use cache::ClientSessionMemoryCache; + +#[derive(Debug)] +pub(super) struct FailResolveClientCert {} + +impl client::ResolvesClientCert for FailResolveClientCert { + fn resolve( + &self, + _root_hint_subjects: &[&[u8]], + _sigschemes: &[SignatureScheme], + ) -> Option> { + None + } + + fn has_certs(&self) -> bool { + false + } +} + +/// An exemplar `ResolvesClientCert` implementation that always resolves to a single +/// [RFC 7250] raw public key. +/// +/// [RFC 7250]: https://tools.ietf.org/html/rfc7250 +#[derive(Clone, Debug)] +pub struct AlwaysResolvesClientRawPublicKeys(Arc); +impl AlwaysResolvesClientRawPublicKeys { + /// Create a new `AlwaysResolvesClientRawPublicKeys` instance. + pub fn new(certified_key: Arc) -> Self { + Self(certified_key) + } +} + +impl client::ResolvesClientCert for AlwaysResolvesClientRawPublicKeys { + fn resolve( + &self, + _root_hint_subjects: &[&[u8]], + _sigschemes: &[SignatureScheme], + ) -> Option> { + Some(self.0.clone()) + } + + fn only_raw_public_keys(&self) -> bool { + true + } + + /// Returns true if the resolver is ready to present an identity. + /// + /// Even though the function is called `has_certs`, it returns true + /// although only an RPK (Raw Public Key) is available, not an actual certificate. + fn has_certs(&self) -> bool { + true + } +} + +#[cfg(test)] +#[macro_rules_attribute::apply(test_for_each_provider)] +mod tests { + use std::prelude::v1::*; + + use pki_types::{ServerName, UnixTime}; + + use super::NoClientSessionStorage; + use super::provider::cipher_suite; + use crate::client::danger::{HandshakeSignatureValid, ServerCertVerified, ServerCertVerifier}; + use crate::client::{ClientSessionStore, ResolvesClientCert}; + use crate::msgs::base::PayloadU16; + use crate::msgs::enums::NamedGroup; + use crate::msgs::handshake::CertificateChain; + #[cfg(feature = "tls12")] + use crate::msgs::handshake::SessionId; + use crate::msgs::persist::Tls13ClientSessionValue; + use crate::pki_types::CertificateDer; + use crate::suites::SupportedCipherSuite; + use crate::sync::Arc; + use crate::{DigitallySignedStruct, Error, SignatureScheme, sign}; + + #[test] + fn test_noclientsessionstorage_does_nothing() { + let c = NoClientSessionStorage {}; + let name = ServerName::try_from("example.com").unwrap(); + let now = UnixTime::now(); + let server_cert_verifier: Arc = Arc::new(DummyServerCertVerifier); + let resolves_client_cert: Arc = Arc::new(DummyResolvesClientCert); + + c.set_kx_hint(name.clone(), NamedGroup::X25519); + assert_eq!(None, c.kx_hint(&name)); + + #[cfg(feature = "tls12")] + { + use crate::msgs::persist::Tls12ClientSessionValue; + let SupportedCipherSuite::Tls12(tls12_suite) = + cipher_suite::TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 + else { + unreachable!() + }; + + c.set_tls12_session( + name.clone(), + Tls12ClientSessionValue::new( + tls12_suite, + SessionId::empty(), + Arc::new(PayloadU16::empty()), + &[], + CertificateChain::default(), + &server_cert_verifier, + &resolves_client_cert, + now, + 0, + true, + ), + ); + assert!(c.tls12_session(&name).is_none()); + c.remove_tls12_session(&name); + } + + let SupportedCipherSuite::Tls13(tls13_suite) = cipher_suite::TLS13_AES_256_GCM_SHA384 + else { + unreachable!(); + }; + c.insert_tls13_ticket( + name.clone(), + Tls13ClientSessionValue::new( + tls13_suite, + Arc::new(PayloadU16::empty()), + &[], + CertificateChain::default(), + &server_cert_verifier, + &resolves_client_cert, + now, + 0, + 0, + 0, + ), + ); + assert!(c.take_tls13_ticket(&name).is_none()); + } + + #[derive(Debug)] + struct DummyServerCertVerifier; + + impl ServerCertVerifier for DummyServerCertVerifier { + #[cfg_attr(coverage_nightly, coverage(off))] + fn verify_server_cert( + &self, + _end_entity: &CertificateDer<'_>, + _intermediates: &[CertificateDer<'_>], + _server_name: &ServerName<'_>, + _ocsp_response: &[u8], + _now: UnixTime, + ) -> Result { + unreachable!() + } + + #[cfg_attr(coverage_nightly, coverage(off))] + fn verify_tls12_signature( + &self, + _message: &[u8], + _cert: &CertificateDer<'_>, + _dss: &DigitallySignedStruct, + ) -> Result { + unreachable!() + } + + #[cfg_attr(coverage_nightly, coverage(off))] + fn verify_tls13_signature( + &self, + _message: &[u8], + _cert: &CertificateDer<'_>, + _dss: &DigitallySignedStruct, + ) -> Result { + unreachable!() + } + + #[cfg_attr(coverage_nightly, coverage(off))] + fn supported_verify_schemes(&self) -> Vec { + unreachable!() + } + } + + #[derive(Debug)] + struct DummyResolvesClientCert; + + impl ResolvesClientCert for DummyResolvesClientCert { + #[cfg_attr(coverage_nightly, coverage(off))] + fn resolve( + &self, + _root_hint_subjects: &[&[u8]], + _sigschemes: &[SignatureScheme], + ) -> Option> { + unreachable!() + } + + #[cfg_attr(coverage_nightly, coverage(off))] + fn has_certs(&self) -> bool { + unreachable!() + } + } +} diff --git a/http/vendor/rustls/src/client/hs.rs b/http/vendor/rustls/src/client/hs.rs new file mode 100644 index 0000000..12e885e --- /dev/null +++ b/http/vendor/rustls/src/client/hs.rs @@ -0,0 +1,1180 @@ +use alloc::borrow::ToOwned; +use alloc::boxed::Box; +use alloc::vec; +use alloc::vec::Vec; +use core::ops::Deref; + +use pki_types::ServerName; + +#[cfg(feature = "tls12")] +use super::tls12; +use super::{ResolvesClientCert, Tls12Resumption}; +use crate::SupportedCipherSuite; +#[cfg(feature = "logging")] +use crate::bs_debug; +use crate::check::inappropriate_handshake_message; +use crate::client::client_conn::ClientConnectionData; +use crate::client::common::ClientHelloDetails; +use crate::client::ech::EchState; +use crate::client::{ClientConfig, EchMode, EchStatus, tls13}; +use crate::common_state::{CommonState, HandshakeKind, KxState, State}; +use crate::conn::ConnectionRandoms; +use crate::crypto::{ActiveKeyExchange, KeyExchangeAlgorithm}; +use crate::enums::{ + AlertDescription, CertificateType, CipherSuite, ContentType, HandshakeType, ProtocolVersion, +}; +use crate::error::{Error, PeerIncompatible, PeerMisbehaved}; +use crate::hash_hs::HandshakeHashBuffer; +use crate::log::{debug, trace}; +use crate::msgs::base::Payload; +use crate::msgs::enums::{Compression, ExtensionType}; +use crate::msgs::handshake::{ + CertificateStatusRequest, ClientExtensions, ClientExtensionsInput, ClientHelloPayload, + ClientSessionTicket, EncryptedClientHello, HandshakeMessagePayload, HandshakePayload, + HelloRetryRequest, KeyShareEntry, ProtocolName, PskKeyExchangeModes, Random, ServerNamePayload, + SessionId, SupportedEcPointFormats, SupportedProtocolVersions, TransportParameters, +}; +use crate::msgs::message::{Message, MessagePayload}; +use crate::msgs::persist; +use crate::sync::Arc; +use crate::tls13::key_schedule::KeyScheduleEarly; +use crate::verify::ServerCertVerifier; + +pub(super) type NextState<'a> = Box + 'a>; +pub(super) type NextStateOrError<'a> = Result, Error>; +pub(super) type ClientContext<'a> = crate::common_state::Context<'a, ClientConnectionData>; + +struct ExpectServerHello { + input: ClientHelloInput, + transcript_buffer: HandshakeHashBuffer, + // The key schedule for sending early data. + // + // If the server accepts the PSK used for early data then + // this is used to compute the rest of the key schedule. + // Otherwise, it is thrown away. + // + // If this is `None` then we do not support early data. + early_data_key_schedule: Option, + offered_key_share: Option>, + suite: Option, + ech_state: Option, +} + +struct ExpectServerHelloOrHelloRetryRequest { + next: ExpectServerHello, + extra_exts: ClientExtensionsInput<'static>, +} + +pub(super) struct ClientHelloInput { + pub(super) config: Arc, + pub(super) resuming: Option>, + pub(super) random: Random, + pub(super) sent_tls13_fake_ccs: bool, + pub(super) hello: ClientHelloDetails, + pub(super) session_id: SessionId, + pub(super) server_name: ServerName<'static>, + pub(super) prev_ech_ext: Option, +} + +impl ClientHelloInput { + pub(super) fn new( + server_name: ServerName<'static>, + extra_exts: &ClientExtensionsInput<'_>, + cx: &mut ClientContext<'_>, + config: Arc, + ) -> Result { + let mut resuming = ClientSessionValue::retrieve(&server_name, &config, cx); + let session_id = match &mut resuming { + Some(_resuming) => { + debug!("Resuming session"); + match &mut _resuming.value { + #[cfg(feature = "tls12")] + ClientSessionValue::Tls12(inner) => { + // If we have a ticket, we use the sessionid as a signal that + // we're doing an abbreviated handshake. See section 3.4 in + // RFC5077. + if !inner.ticket().0.is_empty() { + inner.session_id = SessionId::random(config.provider.secure_random)?; + } + Some(inner.session_id) + } + _ => None, + } + } + _ => { + debug!("Not resuming any session"); + None + } + }; + + // https://tools.ietf.org/html/rfc8446#appendix-D.4 + // https://tools.ietf.org/html/draft-ietf-quic-tls-34#section-8.4 + let session_id = match session_id { + Some(session_id) => session_id, + None if cx.common.is_quic() => SessionId::empty(), + None if !config.supports_version(ProtocolVersion::TLSv1_3) => SessionId::empty(), + None => SessionId::random(config.provider.secure_random)?, + }; + + let hello = ClientHelloDetails::new( + extra_exts + .protocols + .clone() + .unwrap_or_default(), + crate::rand::random_u16(config.provider.secure_random)?, + ); + + Ok(Self { + resuming, + random: Random::new(config.provider.secure_random)?, + sent_tls13_fake_ccs: false, + hello, + session_id, + server_name, + prev_ech_ext: None, + config, + }) + } + + pub(super) fn start_handshake( + self, + extra_exts: ClientExtensionsInput<'static>, + cx: &mut ClientContext<'_>, + ) -> NextStateOrError<'static> { + let mut transcript_buffer = HandshakeHashBuffer::new(); + if self + .config + .client_auth_cert_resolver + .has_certs() + { + transcript_buffer.set_client_auth_enabled(); + } + + let key_share = if self.config.needs_key_share() { + Some(tls13::initial_key_share( + &self.config, + &self.server_name, + &mut cx.common.kx_state, + )?) + } else { + None + }; + + let ech_state = match self.config.ech_mode.as_ref() { + Some(EchMode::Enable(ech_config)) => { + Some(ech_config.state(self.server_name.clone(), &self.config)?) + } + _ => None, + }; + + emit_client_hello_for_retry( + transcript_buffer, + None, + key_share, + extra_exts, + None, + self, + cx, + ech_state, + ) + } +} + +/// Emits the initial ClientHello or a ClientHello in response to +/// a HelloRetryRequest. +/// +/// `retryreq` and `suite` are `None` if this is the initial +/// ClientHello. +fn emit_client_hello_for_retry( + mut transcript_buffer: HandshakeHashBuffer, + retryreq: Option<&HelloRetryRequest>, + key_share: Option>, + extra_exts: ClientExtensionsInput<'static>, + suite: Option, + mut input: ClientHelloInput, + cx: &mut ClientContext<'_>, + mut ech_state: Option, +) -> NextStateOrError<'static> { + let config = &input.config; + // Defense in depth: the ECH state should be None if ECH is disabled based on config + // builder semantics. + let forbids_tls12 = cx.common.is_quic() || ech_state.is_some(); + + let supported_versions = SupportedProtocolVersions { + tls12: config.supports_version(ProtocolVersion::TLSv1_2) && !forbids_tls12, + tls13: config.supports_version(ProtocolVersion::TLSv1_3), + }; + + // should be unreachable thanks to config builder + assert!(supported_versions.any(|_| true)); + + let mut exts = Box::new(ClientExtensions { + // offer groups which are usable for any offered version + named_groups: Some( + config + .provider + .kx_groups + .iter() + .filter(|skxg| supported_versions.any(|v| skxg.usable_for_version(v))) + .map(|skxg| skxg.name()) + .collect(), + ), + supported_versions: Some(supported_versions), + signature_schemes: Some( + config + .verifier + .supported_verify_schemes(), + ), + extended_master_secret_request: Some(()), + certificate_status_request: Some(CertificateStatusRequest::build_ocsp()), + protocols: extra_exts.protocols.clone(), + ..Default::default() + }); + + match extra_exts.transport_parameters.clone() { + Some(TransportParameters::Quic(v)) => exts.transport_parameters = Some(v), + Some(TransportParameters::QuicDraft(v)) => exts.transport_parameters_draft = Some(v), + None => {} + }; + + if supported_versions.tls13 { + if let Some(cas_extension) = config.verifier.root_hint_subjects() { + exts.certificate_authority_names = Some(cas_extension.to_owned()); + } + } + + // Send the ECPointFormat extension only if we are proposing ECDHE + if config + .provider + .kx_groups + .iter() + .any(|skxg| skxg.name().key_exchange_algorithm() == KeyExchangeAlgorithm::ECDHE) + { + exts.ec_point_formats = Some(SupportedEcPointFormats::default()); + } + + exts.server_name = match (ech_state.as_ref(), config.enable_sni) { + // If we have ECH state we have a "cover name" to send in the outer hello + // as the SNI domain name. This happens unconditionally so we ignore the + // `enable_sni` value. That will be used later to decide what to do for + // the protected inner hello's SNI. + (Some(ech_state), _) => Some(ServerNamePayload::from(&ech_state.outer_name)), + + // If we have no ECH state, and SNI is enabled, try to use the input server_name + // for the SNI domain name. + (None, true) => match &input.server_name { + ServerName::DnsName(dns_name) => Some(ServerNamePayload::from(dns_name)), + _ => None, + }, + + // If we have no ECH state, and SNI is not enabled, there's nothing to do. + (None, false) => None, + }; + + if let Some(key_share) = &key_share { + debug_assert!(supported_versions.tls13); + let mut shares = vec![KeyShareEntry::new(key_share.group(), key_share.pub_key())]; + + if !retryreq + .map(|rr| rr.key_share.is_some()) + .unwrap_or_default() + { + // Only for the initial client hello, or a HRR that does not specify a kx group, + // see if we can send a second KeyShare for "free". We only do this if the same + // algorithm is also supported separately by our provider for this version + // (`find_kx_group` looks that up). + if let Some((component_group, component_share)) = + key_share + .hybrid_component() + .filter(|(group, _)| { + config + .find_kx_group(*group, ProtocolVersion::TLSv1_3) + .is_some() + }) + { + shares.push(KeyShareEntry::new(component_group, component_share)); + } + } + + exts.key_shares = Some(shares); + } + + if let Some(cookie) = retryreq.and_then(|hrr| hrr.cookie.as_ref()) { + exts.cookie = Some(cookie.clone()); + } + + if supported_versions.tls13 { + // We could support PSK_KE here too. Such connections don't + // have forward secrecy, and are similar to TLS1.2 resumption. + exts.preshared_key_modes = Some(PskKeyExchangeModes { + psk: false, + psk_dhe: true, + }); + } + + input.hello.offered_cert_compression = + if supported_versions.tls13 && !config.cert_decompressors.is_empty() { + exts.certificate_compression_algorithms = Some( + config + .cert_decompressors + .iter() + .map(|dec| dec.algorithm()) + .collect(), + ); + true + } else { + false + }; + + if config + .client_auth_cert_resolver + .only_raw_public_keys() + { + exts.client_certificate_types = Some(vec![CertificateType::RawPublicKey]); + } + + if config + .verifier + .requires_raw_public_keys() + { + exts.server_certificate_types = Some(vec![CertificateType::RawPublicKey]); + } + + // If this is a second client hello we're constructing in response to an HRR, and + // we've rejected ECH or sent GREASE ECH, then we need to carry forward the + // exact same ECH extension we used in the first hello. + if matches!(cx.data.ech_status, EchStatus::Rejected | EchStatus::Grease) & retryreq.is_some() { + if let Some(prev_ech_ext) = input.prev_ech_ext.take() { + exts.encrypted_client_hello = Some(prev_ech_ext); + } + } + + // Do we have a SessionID or ticket cached for this host? + let tls13_session = prepare_resumption(&input.resuming, &mut exts, suite, cx, config); + + // Extensions MAY be randomized + // but they also need to keep the same order as the previous ClientHello + exts.order_seed = input.hello.extension_order_seed; + + let mut cipher_suites: Vec<_> = config + .provider + .cipher_suites + .iter() + .filter_map(|cs| match cs.usable_for_protocol(cx.common.protocol) { + true => Some(cs.suite()), + false => None, + }) + .collect(); + + if supported_versions.tls12 { + // We don't do renegotiation at all, in fact. + cipher_suites.push(CipherSuite::TLS_EMPTY_RENEGOTIATION_INFO_SCSV); + } + + let mut chp_payload = ClientHelloPayload { + client_version: ProtocolVersion::TLSv1_2, + random: input.random, + session_id: input.session_id, + cipher_suites, + compression_methods: vec![Compression::Null], + extensions: exts, + }; + + let ech_grease_ext = config + .ech_mode + .as_ref() + .and_then(|mode| match mode { + EchMode::Grease(cfg) => Some(cfg.grease_ext( + config.provider.secure_random, + input.server_name.clone(), + &chp_payload, + )), + _ => None, + }); + + match (cx.data.ech_status, &mut ech_state) { + // If we haven't offered ECH, or have offered ECH but got a non-rejecting HRR, then + // we need to replace the client hello payload with an ECH client hello payload. + (EchStatus::NotOffered | EchStatus::Offered, Some(ech_state)) => { + // Replace the client hello payload with an ECH client hello payload. + chp_payload = ech_state.ech_hello(chp_payload, retryreq, &tls13_session)?; + cx.data.ech_status = EchStatus::Offered; + // Store the ECH extension in case we need to carry it forward in a subsequent hello. + input.prev_ech_ext = chp_payload + .encrypted_client_hello + .clone(); + } + // If we haven't offered ECH, and have no ECH state, then consider whether to use GREASE + // ECH. + (EchStatus::NotOffered, None) => { + if let Some(grease_ext) = ech_grease_ext { + // Add the GREASE ECH extension. + let grease_ext = grease_ext?; + chp_payload.encrypted_client_hello = Some(grease_ext.clone()); + cx.data.ech_status = EchStatus::Grease; + // Store the GREASE ECH extension in case we need to carry it forward in a + // subsequent hello. + input.prev_ech_ext = Some(grease_ext); + } + } + _ => {} + } + + // Note what extensions we sent. + input.hello.sent_extensions = chp_payload.collect_used(); + + let mut chp = HandshakeMessagePayload(HandshakePayload::ClientHello(chp_payload)); + + let tls13_early_data_key_schedule = match (ech_state.as_mut(), tls13_session) { + // If we're performing ECH and resuming, then the PSK binder will have been dealt with + // separately, and we need to take the early_data_key_schedule computed for the inner hello. + (Some(ech_state), Some(tls13_session)) => ech_state + .early_data_key_schedule + .take() + .map(|schedule| (tls13_session.suite(), schedule)), + + // When we're not doing ECH and resuming, then the PSK binder need to be filled in as + // normal. + (_, Some(tls13_session)) => Some(( + tls13_session.suite(), + tls13::fill_in_psk_binder(&tls13_session, &transcript_buffer, &mut chp), + )), + + // No early key schedule in other cases. + _ => None, + }; + + let ch = Message { + version: match retryreq { + // : + // "This value MUST be set to 0x0303 for all records generated + // by a TLS 1.3 implementation ..." + Some(_) => ProtocolVersion::TLSv1_2, + // "... other than an initial ClientHello (i.e., one not + // generated after a HelloRetryRequest), where it MAY also be + // 0x0301 for compatibility purposes" + // + // (retryreq == None means we're in the "initial ClientHello" case) + None => ProtocolVersion::TLSv1_0, + }, + payload: MessagePayload::handshake(chp), + }; + + if retryreq.is_some() { + // send dummy CCS to fool middleboxes prior + // to second client hello + tls13::emit_fake_ccs(&mut input.sent_tls13_fake_ccs, cx.common); + } + + trace!("Sending ClientHello {ch:#?}"); + + transcript_buffer.add_message(&ch); + cx.common.send_msg(ch, false); + + // Calculate the hash of ClientHello and use it to derive EarlyTrafficSecret + let early_data_key_schedule = + tls13_early_data_key_schedule.map(|(resuming_suite, schedule)| { + if !cx.data.early_data.is_enabled() { + return schedule; + } + + let (transcript_buffer, random) = match &ech_state { + // When using ECH the early data key schedule is derived based on the inner + // hello transcript and random. + Some(ech_state) => ( + &ech_state.inner_hello_transcript, + &ech_state.inner_hello_random.0, + ), + None => (&transcript_buffer, &input.random.0), + }; + + tls13::derive_early_traffic_secret( + &*config.key_log, + cx, + resuming_suite.common.hash_provider, + &schedule, + &mut input.sent_tls13_fake_ccs, + transcript_buffer, + random, + ); + schedule + }); + + let next = ExpectServerHello { + input, + transcript_buffer, + early_data_key_schedule, + offered_key_share: key_share, + suite, + ech_state, + }; + + Ok(if supported_versions.tls13 && retryreq.is_none() { + Box::new(ExpectServerHelloOrHelloRetryRequest { + next, + extra_exts: extra_exts.into_owned(), + }) + } else { + Box::new(next) + }) +} + +/// Prepares `exts` and `cx` with TLS 1.2 or TLS 1.3 session +/// resumption. +/// +/// - `suite` is `None` if this is the initial ClientHello, or +/// `Some` if we're retrying in response to +/// a HelloRetryRequest. +/// +/// This function will push onto `exts` to +/// +/// (a) request a new ticket if we don't have one, +/// (b) send our TLS 1.2 ticket after retrieving an 1.2 session, +/// (c) send a request for 1.3 early data if allowed and +/// (d) send a 1.3 preshared key if we have one. +/// +/// It returns the TLS 1.3 PSKs, if any, for further processing. +fn prepare_resumption<'a>( + resuming: &'a Option>, + exts: &mut ClientExtensions<'_>, + suite: Option, + cx: &mut ClientContext<'_>, + config: &ClientConfig, +) -> Option> { + // Check whether we're resuming with a non-empty ticket. + let resuming = match resuming { + Some(resuming) if !resuming.ticket().is_empty() => resuming, + _ => { + if config.supports_version(ProtocolVersion::TLSv1_2) + && config.resumption.tls12_resumption == Tls12Resumption::SessionIdOrTickets + { + // If we don't have a ticket, request one. + exts.session_ticket = Some(ClientSessionTicket::Request); + } + return None; + } + }; + + let Some(tls13) = resuming.map(|csv| csv.tls13()) else { + // TLS 1.2; send the ticket if we have support this protocol version + if config.supports_version(ProtocolVersion::TLSv1_2) + && config.resumption.tls12_resumption == Tls12Resumption::SessionIdOrTickets + { + exts.session_ticket = Some(ClientSessionTicket::Offer(Payload::new(resuming.ticket()))); + } + return None; // TLS 1.2, so nothing to return here + }; + + if !config.supports_version(ProtocolVersion::TLSv1_3) { + return None; + } + + // If the server selected TLS 1.2, we can't resume. + let suite = match suite { + Some(SupportedCipherSuite::Tls13(suite)) => Some(suite), + #[cfg(feature = "tls12")] + Some(SupportedCipherSuite::Tls12(_)) => return None, + None => None, + }; + + // If the selected cipher suite can't select from the session's, we can't resume. + if let Some(suite) = suite { + suite.can_resume_from(tls13.suite())?; + } + + tls13::prepare_resumption(config, cx, &tls13, exts, suite.is_some()); + Some(tls13) +} + +pub(super) fn process_alpn_protocol( + common: &mut CommonState, + offered_protocols: &[ProtocolName], + selected: Option<&ProtocolName>, + check_selected_offered: bool, +) -> Result<(), Error> { + common.alpn_protocol = selected.map(ToOwned::to_owned); + + if let Some(alpn_protocol) = &common.alpn_protocol { + if check_selected_offered && !offered_protocols.contains(alpn_protocol) { + return Err(common.send_fatal_alert( + AlertDescription::IllegalParameter, + PeerMisbehaved::SelectedUnofferedApplicationProtocol, + )); + } + } + + // RFC 9001 says: "While ALPN only specifies that servers use this alert, QUIC clients MUST + // use error 0x0178 to terminate a connection when ALPN negotiation fails." We judge that + // the user intended to use ALPN (rather than some out-of-band protocol negotiation + // mechanism) if and only if any ALPN protocols were configured. This defends against badly-behaved + // servers which accept a connection that requires an application-layer protocol they do not + // understand. + if common.is_quic() && common.alpn_protocol.is_none() && !offered_protocols.is_empty() { + return Err(common.send_fatal_alert( + AlertDescription::NoApplicationProtocol, + Error::NoApplicationProtocol, + )); + } + + debug!( + "ALPN protocol is {:?}", + common + .alpn_protocol + .as_ref() + .map(|v| bs_debug::BsDebug(v.as_ref())) + ); + Ok(()) +} + +pub(super) fn process_server_cert_type_extension( + common: &mut CommonState, + config: &ClientConfig, + server_cert_extension: Option<&CertificateType>, +) -> Result, Error> { + process_cert_type_extension( + common, + config + .verifier + .requires_raw_public_keys(), + server_cert_extension.copied(), + ExtensionType::ServerCertificateType, + ) +} + +pub(super) fn process_client_cert_type_extension( + common: &mut CommonState, + config: &ClientConfig, + client_cert_extension: Option<&CertificateType>, +) -> Result, Error> { + process_cert_type_extension( + common, + config + .client_auth_cert_resolver + .only_raw_public_keys(), + client_cert_extension.copied(), + ExtensionType::ClientCertificateType, + ) +} + +impl State for ExpectServerHello { + fn handle<'m>( + mut self: Box, + cx: &mut ClientContext<'_>, + m: Message<'m>, + ) -> NextStateOrError<'m> + where + Self: 'm, + { + let server_hello = + require_handshake_msg!(m, HandshakeType::ServerHello, HandshakePayload::ServerHello)?; + trace!("We got ServerHello {server_hello:#?}"); + + use crate::ProtocolVersion::{TLSv1_2, TLSv1_3}; + let config = &self.input.config; + let tls13_supported = config.supports_version(TLSv1_3); + + let server_version = if server_hello.legacy_version == TLSv1_2 { + server_hello + .selected_version + .unwrap_or(server_hello.legacy_version) + } else { + server_hello.legacy_version + }; + + let version = match server_version { + TLSv1_3 if tls13_supported => TLSv1_3, + TLSv1_2 if config.supports_version(TLSv1_2) => { + if cx.data.early_data.is_enabled() && cx.common.early_traffic { + // The client must fail with a dedicated error code if the server + // responds with TLS 1.2 when offering 0-RTT. + return Err(PeerMisbehaved::OfferedEarlyDataWithOldProtocolVersion.into()); + } + + if server_hello.selected_version.is_some() { + return Err({ + cx.common.send_fatal_alert( + AlertDescription::IllegalParameter, + PeerMisbehaved::SelectedTls12UsingTls13VersionExtension, + ) + }); + } + + TLSv1_2 + } + _ => { + let reason = match server_version { + TLSv1_2 | TLSv1_3 => PeerIncompatible::ServerTlsVersionIsDisabledByOurConfig, + _ => PeerIncompatible::ServerDoesNotSupportTls12Or13, + }; + return Err(cx + .common + .send_fatal_alert(AlertDescription::ProtocolVersion, reason)); + } + }; + + if server_hello.compression_method != Compression::Null { + return Err({ + cx.common.send_fatal_alert( + AlertDescription::IllegalParameter, + PeerMisbehaved::SelectedUnofferedCompression, + ) + }); + } + + let allowed_unsolicited = [ExtensionType::RenegotiationInfo]; + if self + .input + .hello + .server_sent_unsolicited_extensions(server_hello, &allowed_unsolicited) + { + return Err(cx.common.send_fatal_alert( + AlertDescription::UnsupportedExtension, + PeerMisbehaved::UnsolicitedServerHelloExtension, + )); + } + + cx.common.negotiated_version = Some(version); + + // Extract ALPN protocol + if !cx.common.is_tls13() { + process_alpn_protocol( + cx.common, + &self.input.hello.alpn_protocols, + server_hello + .selected_protocol + .as_ref() + .map(|s| s.as_ref()), + self.input.config.check_selected_alpn, + )?; + } + + // If ECPointFormats extension is supplied by the server, it must contain + // Uncompressed. But it's allowed to be omitted. + if let Some(point_fmts) = &server_hello.ec_point_formats { + if !point_fmts.uncompressed { + return Err(cx.common.send_fatal_alert( + AlertDescription::HandshakeFailure, + PeerMisbehaved::ServerHelloMustOfferUncompressedEcPoints, + )); + } + } + + let suite = config + .find_cipher_suite(server_hello.cipher_suite) + .ok_or_else(|| { + cx.common.send_fatal_alert( + AlertDescription::HandshakeFailure, + PeerMisbehaved::SelectedUnofferedCipherSuite, + ) + })?; + + if version != suite.version().version { + return Err({ + cx.common.send_fatal_alert( + AlertDescription::IllegalParameter, + PeerMisbehaved::SelectedUnusableCipherSuiteForVersion, + ) + }); + } + + match self.suite { + Some(prev_suite) if prev_suite != suite => { + return Err({ + cx.common.send_fatal_alert( + AlertDescription::IllegalParameter, + PeerMisbehaved::SelectedDifferentCipherSuiteAfterRetry, + ) + }); + } + _ => { + debug!("Using ciphersuite {suite:?}"); + self.suite = Some(suite); + cx.common.suite = Some(suite); + } + } + + // Start our handshake hash, and input the server-hello. + let mut transcript = self + .transcript_buffer + .start_hash(suite.hash_provider()); + transcript.add_message(&m); + + let randoms = ConnectionRandoms::new(self.input.random, server_hello.random); + // For TLS1.3, start message encryption using + // handshake_traffic_secret. + match suite { + SupportedCipherSuite::Tls13(suite) => { + tls13::handle_server_hello( + cx, + server_hello, + randoms, + suite, + transcript, + self.early_data_key_schedule, + // We always send a key share when TLS 1.3 is enabled. + self.offered_key_share.unwrap(), + &m, + self.ech_state, + self.input, + ) + } + #[cfg(feature = "tls12")] + SupportedCipherSuite::Tls12(suite) => tls12::CompleteServerHelloHandling { + randoms, + transcript, + input: self.input, + } + .handle_server_hello(cx, suite, server_hello, tls13_supported), + } + } + + fn into_owned(self: Box) -> NextState<'static> { + self + } +} + +impl ExpectServerHelloOrHelloRetryRequest { + fn into_expect_server_hello(self) -> NextState<'static> { + Box::new(self.next) + } + + fn handle_hello_retry_request( + mut self, + cx: &mut ClientContext<'_>, + m: Message<'_>, + ) -> NextStateOrError<'static> { + let hrr = require_handshake_msg!( + m, + HandshakeType::HelloRetryRequest, + HandshakePayload::HelloRetryRequest + )?; + trace!("Got HRR {hrr:?}"); + + cx.common.check_aligned_handshake()?; + + // We always send a key share when TLS 1.3 is enabled. + let offered_key_share = self.next.offered_key_share.unwrap(); + + // A retry request is illegal if it contains no cookie and asks for + // retry of a group we already sent. + let config = &self.next.input.config; + + if let (None, Some(req_group)) = (&hrr.cookie, hrr.key_share) { + let offered_hybrid = offered_key_share + .hybrid_component() + .and_then(|(group_name, _)| { + config.find_kx_group(group_name, ProtocolVersion::TLSv1_3) + }) + .map(|skxg| skxg.name()); + + if req_group == offered_key_share.group() || Some(req_group) == offered_hybrid { + return Err({ + cx.common.send_fatal_alert( + AlertDescription::IllegalParameter, + PeerMisbehaved::IllegalHelloRetryRequestWithOfferedGroup, + ) + }); + } + } + + // Or has an empty cookie. + if let Some(cookie) = &hrr.cookie { + if cookie.0.is_empty() { + return Err({ + cx.common.send_fatal_alert( + AlertDescription::IllegalParameter, + PeerMisbehaved::IllegalHelloRetryRequestWithEmptyCookie, + ) + }); + } + } + + // Or asks us to change nothing. + if hrr.cookie.is_none() && hrr.key_share.is_none() { + return Err({ + cx.common.send_fatal_alert( + AlertDescription::IllegalParameter, + PeerMisbehaved::IllegalHelloRetryRequestWithNoChanges, + ) + }); + } + + // Or does not echo the session_id from our ClientHello: + // + // > the HelloRetryRequest has the same format as a ServerHello message, + // > and the legacy_version, legacy_session_id_echo, cipher_suite, and + // > legacy_compression_method fields have the same meaning + // + // + // and + // + // > A client which receives a legacy_session_id_echo field that does not + // > match what it sent in the ClientHello MUST abort the handshake with an + // > "illegal_parameter" alert. + // + if hrr.session_id != self.next.input.session_id { + return Err({ + cx.common.send_fatal_alert( + AlertDescription::IllegalParameter, + PeerMisbehaved::IllegalHelloRetryRequestWithWrongSessionId, + ) + }); + } + + // Or asks us to talk a protocol we didn't offer, or doesn't support HRR at all. + match hrr.supported_versions { + Some(ProtocolVersion::TLSv1_3) => { + cx.common.negotiated_version = Some(ProtocolVersion::TLSv1_3); + } + _ => { + return Err({ + cx.common.send_fatal_alert( + AlertDescription::IllegalParameter, + PeerMisbehaved::IllegalHelloRetryRequestWithUnsupportedVersion, + ) + }); + } + } + + // Or asks us to use a ciphersuite we didn't offer. + let Some(cs) = config.find_cipher_suite(hrr.cipher_suite) else { + return Err({ + cx.common.send_fatal_alert( + AlertDescription::IllegalParameter, + PeerMisbehaved::IllegalHelloRetryRequestWithUnofferedCipherSuite, + ) + }); + }; + + // Or offers ECH related extensions when we didn't offer ECH. + if cx.data.ech_status == EchStatus::NotOffered && hrr.encrypted_client_hello.is_some() { + return Err({ + cx.common.send_fatal_alert( + AlertDescription::UnsupportedExtension, + PeerMisbehaved::IllegalHelloRetryRequestWithInvalidEch, + ) + }); + } + + // HRR selects the ciphersuite. + cx.common.suite = Some(cs); + cx.common.handshake_kind = Some(HandshakeKind::FullWithHelloRetryRequest); + + // If we offered ECH, we need to confirm that the server accepted it. + match (self.next.ech_state.as_ref(), cs.tls13()) { + // If the server did not confirm, then note the new ECH status but + // continue the handshake. We will abort with an ECH required error + // at the end. + (Some(ech_state), Some(tls13_cs)) + if !ech_state.confirm_hrr_acceptance(hrr, tls13_cs, cx.common)? => + { + cx.data.ech_status = EchStatus::Rejected + } + (Some(_), None) => { + unreachable!("ECH state should only be set when TLS 1.3 was negotiated") + } + _ => {} + }; + + // This is the draft19 change where the transcript became a tree + let transcript = self + .next + .transcript_buffer + .start_hash(cs.hash_provider()); + let mut transcript_buffer = transcript.into_hrr_buffer(); + transcript_buffer.add_message(&m); + + // If we offered ECH and the server accepted, we also need to update the separate + // ECH transcript with the hello retry request message. + if let Some(ech_state) = self.next.ech_state.as_mut() { + ech_state.transcript_hrr_update(cs.hash_provider(), &m); + } + + // Early data is not allowed after HelloRetryrequest + if cx.data.early_data.is_enabled() { + cx.data.early_data.rejected(); + } + + let key_share = match hrr.key_share { + Some(group) if group != offered_key_share.group() => { + let Some(skxg) = config.find_kx_group(group, ProtocolVersion::TLSv1_3) else { + return Err(cx.common.send_fatal_alert( + AlertDescription::IllegalParameter, + PeerMisbehaved::IllegalHelloRetryRequestWithUnofferedNamedGroup, + )); + }; + + cx.common.kx_state = KxState::Start(skxg); + skxg.start()? + } + _ => offered_key_share, + }; + + emit_client_hello_for_retry( + transcript_buffer, + Some(hrr), + Some(key_share), + self.extra_exts, + Some(cs), + self.next.input, + cx, + self.next.ech_state, + ) + } +} + +impl State for ExpectServerHelloOrHelloRetryRequest { + fn handle<'m>( + self: Box, + cx: &mut ClientContext<'_>, + m: Message<'m>, + ) -> NextStateOrError<'m> + where + Self: 'm, + { + match m.payload { + MessagePayload::Handshake { + parsed: HandshakeMessagePayload(HandshakePayload::ServerHello(..)), + .. + } => self + .into_expect_server_hello() + .handle(cx, m), + MessagePayload::Handshake { + parsed: HandshakeMessagePayload(HandshakePayload::HelloRetryRequest(..)), + .. + } => self.handle_hello_retry_request(cx, m), + payload => Err(inappropriate_handshake_message( + &payload, + &[ContentType::Handshake], + &[HandshakeType::ServerHello, HandshakeType::HelloRetryRequest], + )), + } + } + + fn into_owned(self: Box) -> NextState<'static> { + self + } +} + +fn process_cert_type_extension( + common: &mut CommonState, + client_expects: bool, + server_negotiated: Option, + extension_type: ExtensionType, +) -> Result, Error> { + match (client_expects, server_negotiated) { + (true, Some(CertificateType::RawPublicKey)) => { + Ok(Some((extension_type, CertificateType::RawPublicKey))) + } + (true, _) => Err(common.send_fatal_alert( + AlertDescription::HandshakeFailure, + Error::PeerIncompatible(PeerIncompatible::IncorrectCertificateTypeExtension), + )), + (_, Some(CertificateType::RawPublicKey)) => { + unreachable!("Caught by `PeerMisbehaved::UnsolicitedEncryptedExtension`") + } + (_, _) => Ok(None), + } +} + +pub(super) enum ClientSessionValue { + Tls13(persist::Tls13ClientSessionValue), + #[cfg(feature = "tls12")] + Tls12(persist::Tls12ClientSessionValue), +} + +impl ClientSessionValue { + fn retrieve( + server_name: &ServerName<'static>, + config: &ClientConfig, + cx: &mut ClientContext<'_>, + ) -> Option> { + let found = config + .resumption + .store + .take_tls13_ticket(server_name) + .map(ClientSessionValue::Tls13) + .or_else(|| { + #[cfg(feature = "tls12")] + { + config + .resumption + .store + .tls12_session(server_name) + .map(ClientSessionValue::Tls12) + } + + #[cfg(not(feature = "tls12"))] + None + }) + .and_then(|resuming| { + resuming.compatible_config(&config.verifier, &config.client_auth_cert_resolver) + }) + .and_then(|resuming| { + let now = config + .current_time() + .map_err(|_err| debug!("Could not get current time: {_err}")) + .ok()?; + + let retrieved = persist::Retrieved::new(resuming, now); + match retrieved.has_expired() { + false => Some(retrieved), + true => None, + } + }) + .or_else(|| { + debug!("No cached session for {server_name:?}"); + None + }); + + if let Some(resuming) = &found { + if cx.common.is_quic() { + cx.common.quic.params = resuming + .tls13() + .map(|v| v.quic_params()); + } + } + + found + } + + fn common(&self) -> &persist::ClientSessionCommon { + match self { + Self::Tls13(inner) => &inner.common, + #[cfg(feature = "tls12")] + Self::Tls12(inner) => &inner.common, + } + } + + fn tls13(&self) -> Option<&persist::Tls13ClientSessionValue> { + match self { + Self::Tls13(v) => Some(v), + #[cfg(feature = "tls12")] + Self::Tls12(_) => None, + } + } + + fn compatible_config( + self, + server_cert_verifier: &Arc, + client_creds: &Arc, + ) -> Option { + match &self { + Self::Tls13(v) => v + .compatible_config(server_cert_verifier, client_creds) + .then_some(self), + #[cfg(feature = "tls12")] + Self::Tls12(v) => v + .compatible_config(server_cert_verifier, client_creds) + .then_some(self), + } + } +} + +impl Deref for ClientSessionValue { + type Target = persist::ClientSessionCommon; + + fn deref(&self) -> &Self::Target { + self.common() + } +} diff --git a/http/vendor/rustls/src/client/test.rs b/http/vendor/rustls/src/client/test.rs new file mode 100644 index 0000000..e4051d6 --- /dev/null +++ b/http/vendor/rustls/src/client/test.rs @@ -0,0 +1,713 @@ +#![cfg(any(feature = "ring", feature = "aws_lc_rs"))] +use alloc::boxed::Box; +use alloc::vec; +use alloc::vec::Vec; +use core::sync::atomic::{AtomicBool, Ordering}; + +use pki_types::{CertificateDer, ServerName}; + +use crate::client::{ClientConfig, ClientConnection, Resumption, Tls12Resumption}; +use crate::crypto::CryptoProvider; +use crate::enums::{CipherSuite, ProtocolVersion, SignatureScheme}; +use crate::msgs::base::PayloadU16; +use crate::msgs::codec::Reader; +use crate::msgs::enums::{Compression, NamedGroup}; +use crate::msgs::handshake::{ + ClientHelloPayload, HandshakeMessagePayload, HandshakePayload, HelloRetryRequest, Random, + ServerHelloPayload, SessionId, +}; +use crate::msgs::message::{Message, MessagePayload, OutboundOpaqueMessage}; +use crate::sync::Arc; +use crate::{Error, PeerIncompatible, PeerMisbehaved, RootCertStore}; + +#[macro_rules_attribute::apply(test_for_each_provider)] +mod tests { + use std::sync::OnceLock; + + use super::super::*; + use crate::client::AlwaysResolvesClientRawPublicKeys; + use crate::crypto::cipher::MessageEncrypter; + use crate::crypto::tls13::OkmBlock; + use crate::enums::CertificateType; + use crate::msgs::base::PayloadU8; + use crate::msgs::enums::ECCurveType; + use crate::msgs::handshake::{ + CertificateChain, EcParameters, HelloRetryRequestExtensions, KeyShareEntry, + ServerEcdhParams, ServerExtensions, ServerKeyExchange, ServerKeyExchangeParams, + ServerKeyExchangePayload, + }; + use crate::msgs::message::PlainMessage; + use crate::pki_types::pem::PemObject; + use crate::pki_types::{PrivateKeyDer, UnixTime}; + use crate::sign::CertifiedKey; + use crate::tls13::key_schedule::{derive_traffic_iv, derive_traffic_key}; + use crate::verify::{HandshakeSignatureValid, ServerCertVerified, ServerCertVerifier}; + use crate::{DigitallySignedStruct, DistinguishedName, KeyLog, version}; + + /// Tests that session_ticket(35) extension + /// is not sent if the client does not support TLS 1.2. + #[test] + fn test_no_session_ticket_request_on_tls_1_3() { + let mut config = + ClientConfig::builder_with_provider(super::provider::default_provider().into()) + .with_protocol_versions(&[&version::TLS13]) + .unwrap() + .with_root_certificates(roots()) + .with_no_client_auth(); + config.resumption = Resumption::in_memory_sessions(128) + .tls12_resumption(Tls12Resumption::SessionIdOrTickets); + let ch = client_hello_sent_for_config(config).unwrap(); + assert!(ch.extensions.session_ticket.is_none()); + } + + #[test] + fn test_no_renegotiation_scsv_on_tls_1_3() { + let ch = client_hello_sent_for_config( + ClientConfig::builder_with_provider(super::provider::default_provider().into()) + .with_protocol_versions(&[&version::TLS13]) + .unwrap() + .with_root_certificates(roots()) + .with_no_client_auth(), + ) + .unwrap(); + assert!( + !ch.cipher_suites + .contains(&CipherSuite::TLS_EMPTY_RENEGOTIATION_INFO_SCSV) + ); + } + + #[test] + fn test_client_does_not_offer_sha1() { + for version in crate::ALL_VERSIONS { + let config = + ClientConfig::builder_with_provider(super::provider::default_provider().into()) + .with_protocol_versions(&[version]) + .unwrap() + .with_root_certificates(roots()) + .with_no_client_auth(); + let ch = client_hello_sent_for_config(config).unwrap(); + assert!( + !ch.extensions + .signature_schemes + .as_ref() + .unwrap() + .contains(&SignatureScheme::RSA_PKCS1_SHA1), + "sha1 unexpectedly offered" + ); + } + } + + #[test] + fn test_client_rejects_hrr_with_varied_session_id() { + let config = + ClientConfig::builder_with_provider(super::provider::default_provider().into()) + .with_safe_default_protocol_versions() + .unwrap() + .with_root_certificates(roots()) + .with_no_client_auth(); + let mut conn = + ClientConnection::new(config.into(), ServerName::try_from("localhost").unwrap()) + .unwrap(); + let mut sent = Vec::new(); + conn.write_tls(&mut sent).unwrap(); + + // server replies with HRR, but does not echo `session_id` as required. + let hrr = Message { + version: ProtocolVersion::TLSv1_3, + payload: MessagePayload::handshake(HandshakeMessagePayload( + HandshakePayload::HelloRetryRequest(HelloRetryRequest { + cipher_suite: CipherSuite::TLS13_AES_128_GCM_SHA256, + legacy_version: ProtocolVersion::TLSv1_2, + session_id: SessionId::empty(), + extensions: HelloRetryRequestExtensions { + cookie: Some(PayloadU16::new(vec![1, 2, 3, 4])), + ..HelloRetryRequestExtensions::default() + }, + }), + )), + }; + + conn.read_tls(&mut hrr.into_wire_bytes().as_slice()) + .unwrap(); + assert_eq!( + conn.process_new_packets().unwrap_err(), + PeerMisbehaved::IllegalHelloRetryRequestWithWrongSessionId.into() + ); + } + + #[cfg(feature = "tls12")] + #[test] + fn test_client_rejects_no_extended_master_secret_extension_when_require_ems_or_fips() { + let mut config = + ClientConfig::builder_with_provider(super::provider::default_provider().into()) + .with_safe_default_protocol_versions() + .unwrap() + .with_root_certificates(roots()) + .with_no_client_auth(); + if config.provider.fips() { + assert!(config.require_ems); + } else { + config.require_ems = true; + } + + let config = Arc::new(config); + let mut conn = + ClientConnection::new(config.clone(), ServerName::try_from("localhost").unwrap()) + .unwrap(); + let mut sent = Vec::new(); + conn.write_tls(&mut sent).unwrap(); + + let sh = Message { + version: ProtocolVersion::TLSv1_3, + payload: MessagePayload::handshake(HandshakeMessagePayload( + HandshakePayload::ServerHello(ServerHelloPayload { + random: Random::new(config.provider.secure_random).unwrap(), + compression_method: Compression::Null, + cipher_suite: CipherSuite::TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, + legacy_version: ProtocolVersion::TLSv1_2, + session_id: SessionId::empty(), + extensions: Box::new(ServerExtensions::default()), + }), + )), + }; + conn.read_tls(&mut sh.into_wire_bytes().as_slice()) + .unwrap(); + + assert_eq!( + conn.process_new_packets(), + Err(PeerIncompatible::ExtendedMasterSecretExtensionRequired.into()) + ); + } + + #[test] + fn cas_extension_in_client_hello_if_server_verifier_requests_it() { + let cas_sending_server_verifier = + ServerVerifierWithAuthorityNames(vec![DistinguishedName::from(b"hello".to_vec())]); + + for (protocol_version, cas_extension_expected) in + [(&version::TLS12, false), (&version::TLS13, true)] + { + let client_hello = client_hello_sent_for_config( + ClientConfig::builder_with_provider(super::provider::default_provider().into()) + .with_protocol_versions(&[protocol_version]) + .unwrap() + .dangerous() + .with_custom_certificate_verifier(Arc::new(cas_sending_server_verifier.clone())) + .with_no_client_auth(), + ) + .unwrap(); + assert_eq!( + client_hello + .extensions + .certificate_authority_names + .is_some(), + cas_extension_expected + ); + } + } + + /// Regression test for + #[cfg(feature = "tls12")] + #[test] + fn test_client_with_custom_verifier_can_accept_ecdsa_sha1_signatures() { + let verifier = Arc::new(ExpectSha1EcdsaVerifier::default()); + let config = ClientConfig::builder_with_provider(x25519_provider().into()) + .with_safe_default_protocol_versions() + .unwrap() + .dangerous() + .with_custom_certificate_verifier(verifier.clone()) + .with_no_client_auth(); + + let mut conn = + ClientConnection::new(config.into(), ServerName::try_from("localhost").unwrap()) + .unwrap(); + let mut sent = Vec::new(); + conn.write_tls(&mut sent).unwrap(); + + let sh = Message { + version: ProtocolVersion::TLSv1_2, + payload: MessagePayload::handshake(HandshakeMessagePayload( + HandshakePayload::ServerHello(ServerHelloPayload { + random: Random([0u8; 32]), + compression_method: Compression::Null, + cipher_suite: CipherSuite::TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, + legacy_version: ProtocolVersion::TLSv1_2, + session_id: SessionId::empty(), + extensions: Box::new(ServerExtensions { + extended_master_secret_ack: Some(()), + ..ServerExtensions::default() + }), + }), + )), + }; + conn.read_tls(&mut sh.into_wire_bytes().as_slice()) + .unwrap(); + conn.process_new_packets().unwrap(); + + let cert = Message { + version: ProtocolVersion::TLSv1_2, + payload: MessagePayload::handshake(HandshakeMessagePayload( + HandshakePayload::Certificate(CertificateChain(vec![CertificateDer::from( + &b"does not matter"[..], + )])), + )), + }; + conn.read_tls(&mut cert.into_wire_bytes().as_slice()) + .unwrap(); + conn.process_new_packets().unwrap(); + + let server_kx = Message { + version: ProtocolVersion::TLSv1_2, + payload: MessagePayload::handshake(HandshakeMessagePayload( + HandshakePayload::ServerKeyExchange(ServerKeyExchangePayload::Known( + ServerKeyExchange { + dss: DigitallySignedStruct::new( + SignatureScheme::ECDSA_SHA1_Legacy, + b"also does not matter".to_vec(), + ), + params: ServerKeyExchangeParams::Ecdh(ServerEcdhParams { + curve_params: EcParameters { + curve_type: ECCurveType::NamedCurve, + named_group: NamedGroup::X25519, + }, + public: PayloadU8::new(vec![0xab; 32]), + }), + }, + )), + )), + }; + conn.read_tls(&mut server_kx.into_wire_bytes().as_slice()) + .unwrap(); + conn.process_new_packets().unwrap(); + + let server_done = Message { + version: ProtocolVersion::TLSv1_2, + payload: MessagePayload::handshake(HandshakeMessagePayload( + HandshakePayload::ServerHelloDone, + )), + }; + conn.read_tls(&mut server_done.into_wire_bytes().as_slice()) + .unwrap(); + conn.process_new_packets().unwrap(); + + assert!( + verifier + .seen_sha1_signature + .load(Ordering::SeqCst) + ); + } + + #[derive(Debug, Default)] + struct ExpectSha1EcdsaVerifier { + seen_sha1_signature: AtomicBool, + } + + impl ServerCertVerifier for ExpectSha1EcdsaVerifier { + fn verify_server_cert( + &self, + _end_entity: &CertificateDer<'_>, + _intermediates: &[CertificateDer<'_>], + _server_name: &ServerName<'_>, + _ocsp_response: &[u8], + _now: UnixTime, + ) -> Result { + Ok(ServerCertVerified::assertion()) + } + + fn verify_tls12_signature( + &self, + _message: &[u8], + _cert: &CertificateDer<'_>, + dss: &DigitallySignedStruct, + ) -> Result { + assert_eq!(dss.scheme, SignatureScheme::ECDSA_SHA1_Legacy); + self.seen_sha1_signature + .store(true, Ordering::SeqCst); + Ok(HandshakeSignatureValid::assertion()) + } + + #[cfg_attr(coverage_nightly, coverage(off))] + fn verify_tls13_signature( + &self, + _message: &[u8], + _cert: &CertificateDer<'_>, + _dss: &DigitallySignedStruct, + ) -> Result { + todo!() + } + + fn supported_verify_schemes(&self) -> Vec { + vec![SignatureScheme::ECDSA_SHA1_Legacy] + } + } + + #[test] + fn test_client_requiring_rpk_rejects_server_that_only_offers_x509_id_by_omission() { + assert_eq!( + client_requiring_rpk_receives_server_ee(ServerExtensions::default()), + Err(PeerIncompatible::IncorrectCertificateTypeExtension.into()) + ); + } + + #[test] + fn test_client_requiring_rpk_rejects_server_that_only_offers_x509_id() { + assert_eq!( + client_requiring_rpk_receives_server_ee(ServerExtensions { + server_certificate_type: Some(CertificateType::X509), + ..ServerExtensions::default() + }), + Err(PeerIncompatible::IncorrectCertificateTypeExtension.into()) + ); + } + + #[test] + fn test_client_requiring_rpk_rejects_server_that_only_demands_x509_by_omission() { + assert_eq!( + client_requiring_rpk_receives_server_ee(ServerExtensions { + server_certificate_type: Some(CertificateType::RawPublicKey), + ..ServerExtensions::default() + }), + Err(PeerIncompatible::IncorrectCertificateTypeExtension.into()) + ); + } + + #[test] + fn test_client_requiring_rpk_rejects_server_that_only_demands_x509() { + assert_eq!( + client_requiring_rpk_receives_server_ee(ServerExtensions { + client_certificate_type: Some(CertificateType::X509), + server_certificate_type: Some(CertificateType::RawPublicKey), + ..ServerExtensions::default() + }), + Err(PeerIncompatible::IncorrectCertificateTypeExtension.into()) + ); + } + + #[test] + fn test_client_requiring_rpk_accepts_rpk_server() { + assert_eq!( + client_requiring_rpk_receives_server_ee(ServerExtensions { + client_certificate_type: Some(CertificateType::RawPublicKey), + server_certificate_type: Some(CertificateType::RawPublicKey), + ..ServerExtensions::default() + }), + Ok(()) + ); + } + + fn client_requiring_rpk_receives_server_ee( + encrypted_extensions: ServerExtensions<'_>, + ) -> Result<(), Error> { + let fake_server_crypto = Arc::new(FakeServerCrypto::new()); + let mut conn = ClientConnection::new( + client_config_for_rpk(fake_server_crypto.clone()).into(), + ServerName::try_from("localhost").unwrap(), + ) + .unwrap(); + let mut sent = Vec::new(); + conn.write_tls(&mut sent).unwrap(); + + let sh = Message { + version: ProtocolVersion::TLSv1_3, + payload: MessagePayload::handshake(HandshakeMessagePayload( + HandshakePayload::ServerHello(ServerHelloPayload { + random: Random([0; 32]), + compression_method: Compression::Null, + cipher_suite: CipherSuite::TLS13_AES_128_GCM_SHA256, + legacy_version: ProtocolVersion::TLSv1_3, + session_id: SessionId::empty(), + extensions: Box::new(ServerExtensions { + key_share: Some(KeyShareEntry { + group: NamedGroup::X25519, + payload: PayloadU16::new(vec![0xaa; 32]), + }), + ..ServerExtensions::default() + }), + }), + )), + }; + conn.read_tls(&mut sh.into_wire_bytes().as_slice()) + .unwrap(); + conn.process_new_packets().unwrap(); + + let ee = Message { + version: ProtocolVersion::TLSv1_3, + payload: MessagePayload::handshake(HandshakeMessagePayload( + HandshakePayload::EncryptedExtensions(Box::new(encrypted_extensions)), + )), + }; + + let mut encrypter = fake_server_crypto.server_handshake_encrypter(); + let enc_ee = encrypter + .encrypt(PlainMessage::from(ee).borrow_outbound(), 0) + .unwrap(); + conn.read_tls(&mut enc_ee.encode().as_slice()) + .unwrap(); + conn.process_new_packets().map(|_| ()) + } + + fn client_config_for_rpk(key_log: Arc) -> ClientConfig { + let mut config = ClientConfig::builder_with_provider(x25519_provider().into()) + .with_protocol_versions(&[&version::TLS13]) + .unwrap() + .dangerous() + .with_custom_certificate_verifier(Arc::new(ServerVerifierRequiringRpk)) + .with_client_cert_resolver(Arc::new(AlwaysResolvesClientRawPublicKeys::new(Arc::new( + client_certified_key(), + )))); + config.key_log = key_log; + config + } + + fn client_certified_key() -> CertifiedKey { + let key = super::provider::default_provider() + .key_provider + .load_private_key(client_key()) + .unwrap(); + let public_key_as_cert = vec![CertificateDer::from( + key.public_key() + .unwrap() + .as_ref() + .to_vec(), + )]; + CertifiedKey::new(public_key_as_cert, key) + } + + fn client_key() -> PrivateKeyDer<'static> { + PrivateKeyDer::from_pem_reader( + &mut include_bytes!("../../../test-ca/rsa-2048/client.key").as_slice(), + ) + .unwrap() + } + + fn x25519_provider() -> CryptoProvider { + // ensures X25519 is offered irrespective of cfg(feature = "fips"), which eases + // creation of fake server messages. + CryptoProvider { + kx_groups: vec![super::provider::kx_group::X25519], + ..super::provider::default_provider() + } + } + + #[derive(Clone, Debug)] + struct ServerVerifierWithAuthorityNames(Vec); + + impl ServerCertVerifier for ServerVerifierWithAuthorityNames { + fn root_hint_subjects(&self) -> Option<&[DistinguishedName]> { + Some(self.0.as_slice()) + } + + #[cfg_attr(coverage_nightly, coverage(off))] + fn verify_server_cert( + &self, + _end_entity: &CertificateDer<'_>, + _intermediates: &[CertificateDer<'_>], + _server_name: &ServerName<'_>, + _ocsp_response: &[u8], + _now: UnixTime, + ) -> Result { + unreachable!() + } + + #[cfg_attr(coverage_nightly, coverage(off))] + fn verify_tls12_signature( + &self, + _message: &[u8], + _cert: &CertificateDer<'_>, + _dss: &DigitallySignedStruct, + ) -> Result { + unreachable!() + } + + #[cfg_attr(coverage_nightly, coverage(off))] + fn verify_tls13_signature( + &self, + _message: &[u8], + _cert: &CertificateDer<'_>, + _dss: &DigitallySignedStruct, + ) -> Result { + unreachable!() + } + + fn supported_verify_schemes(&self) -> Vec { + vec![SignatureScheme::RSA_PKCS1_SHA1] + } + } + + #[derive(Debug)] + struct ServerVerifierRequiringRpk; + + impl ServerCertVerifier for ServerVerifierRequiringRpk { + #[cfg_attr(coverage_nightly, coverage(off))] + fn verify_server_cert( + &self, + _end_entity: &CertificateDer<'_>, + _intermediates: &[CertificateDer<'_>], + _server_name: &ServerName<'_>, + _ocsp_response: &[u8], + _now: UnixTime, + ) -> Result { + todo!() + } + + #[cfg_attr(coverage_nightly, coverage(off))] + fn verify_tls12_signature( + &self, + _message: &[u8], + _cert: &CertificateDer<'_>, + _dss: &DigitallySignedStruct, + ) -> Result { + todo!() + } + + #[cfg_attr(coverage_nightly, coverage(off))] + fn verify_tls13_signature( + &self, + _message: &[u8], + _cert: &CertificateDer<'_>, + _dss: &DigitallySignedStruct, + ) -> Result { + todo!() + } + + fn supported_verify_schemes(&self) -> Vec { + vec![SignatureScheme::RSA_PKCS1_SHA1] + } + + fn requires_raw_public_keys(&self) -> bool { + true + } + } + + #[derive(Debug)] + struct FakeServerCrypto { + server_handshake_secret: OnceLock>, + } + + impl FakeServerCrypto { + fn new() -> Self { + Self { + server_handshake_secret: OnceLock::new(), + } + } + + fn server_handshake_encrypter(&self) -> Box { + let cipher_suite = super::provider::cipher_suite::TLS13_AES_128_GCM_SHA256 + .tls13() + .unwrap(); + + let secret = self + .server_handshake_secret + .get() + .unwrap(); + + let expander = cipher_suite + .hkdf_provider + .expander_for_okm(&OkmBlock::new(secret)); + + // Derive Encrypter + let key = derive_traffic_key(expander.as_ref(), cipher_suite.aead_alg); + let iv = derive_traffic_iv(expander.as_ref()); + cipher_suite.aead_alg.encrypter(key, iv) + } + } + + impl KeyLog for FakeServerCrypto { + fn will_log(&self, _label: &str) -> bool { + true + } + + fn log(&self, label: &str, _client_random: &[u8], secret: &[u8]) { + if label == "SERVER_HANDSHAKE_TRAFFIC_SECRET" { + self.server_handshake_secret + .set(secret.to_vec()) + .unwrap(); + } + } + } +} + +// invalid with fips, as we can't offer X25519 separately +#[cfg(all( + feature = "aws-lc-rs", + feature = "prefer-post-quantum", + not(feature = "fips") +))] +#[test] +fn hybrid_kx_component_share_offered_if_supported_separately() { + let ch = client_hello_sent_for_config( + ClientConfig::builder_with_provider(crate::crypto::aws_lc_rs::default_provider().into()) + .with_safe_default_protocol_versions() + .unwrap() + .with_root_certificates(roots()) + .with_no_client_auth(), + ) + .unwrap(); + + let key_shares = ch + .extensions + .key_shares + .as_ref() + .unwrap(); + assert_eq!(key_shares.len(), 2); + assert_eq!(key_shares[0].group, NamedGroup::X25519MLKEM768); + assert_eq!(key_shares[1].group, NamedGroup::X25519); +} + +#[cfg(feature = "aws-lc-rs")] +#[test] +fn hybrid_kx_component_share_not_offered_unless_supported_separately() { + use crate::crypto::aws_lc_rs; + let provider = CryptoProvider { + kx_groups: vec![aws_lc_rs::kx_group::X25519MLKEM768], + ..aws_lc_rs::default_provider() + }; + let ch = client_hello_sent_for_config( + ClientConfig::builder_with_provider(provider.into()) + .with_safe_default_protocol_versions() + .unwrap() + .with_root_certificates(roots()) + .with_no_client_auth(), + ) + .unwrap(); + + let key_shares = ch + .extensions + .key_shares + .as_ref() + .unwrap(); + assert_eq!(key_shares.len(), 1); + assert_eq!(key_shares[0].group, NamedGroup::X25519MLKEM768); +} + +fn client_hello_sent_for_config(config: ClientConfig) -> Result { + let mut conn = + ClientConnection::new(config.into(), ServerName::try_from("localhost").unwrap())?; + let mut bytes = Vec::new(); + conn.write_tls(&mut bytes).unwrap(); + + let message = OutboundOpaqueMessage::read(&mut Reader::init(&bytes)) + .unwrap() + .into_plain_message(); + + match Message::try_from(message).unwrap() { + Message { + payload: + MessagePayload::Handshake { + parsed: HandshakeMessagePayload(HandshakePayload::ClientHello(ch)), + .. + }, + .. + } => Ok(ch), + other => panic!("unexpected message {other:?}"), + } +} + +fn roots() -> RootCertStore { + let mut r = RootCertStore::empty(); + r.add(CertificateDer::from_slice(include_bytes!( + "../../../test-ca/rsa-2048/ca.der" + ))) + .unwrap(); + r +} diff --git a/http/vendor/rustls/src/client/tls12.rs b/http/vendor/rustls/src/client/tls12.rs new file mode 100644 index 0000000..3366021 --- /dev/null +++ b/http/vendor/rustls/src/client/tls12.rs @@ -0,0 +1,1372 @@ +use alloc::borrow::ToOwned; +use alloc::boxed::Box; +use alloc::vec; +use alloc::vec::Vec; + +use pki_types::ServerName; +pub(super) use server_hello::CompleteServerHelloHandling; +use subtle::ConstantTimeEq; + +use super::client_conn::ClientConnectionData; +use super::hs::ClientContext; +use crate::ConnectionTrafficSecrets; +use crate::check::{inappropriate_handshake_message, inappropriate_message}; +use crate::client::common::{ClientAuthDetails, ServerCertDetails}; +use crate::client::{ClientConfig, hs}; +use crate::common_state::{CommonState, HandshakeKind, KxState, Side, State}; +use crate::conn::ConnectionRandoms; +use crate::conn::kernel::{Direction, KernelContext, KernelState}; +use crate::crypto::KeyExchangeAlgorithm; +use crate::enums::{AlertDescription, ContentType, HandshakeType, ProtocolVersion}; +use crate::error::{Error, InvalidMessage, PeerIncompatible, PeerMisbehaved}; +use crate::hash_hs::HandshakeHash; +use crate::log::{debug, trace, warn}; +use crate::msgs::base::{Payload, PayloadU8, PayloadU16}; +use crate::msgs::ccs::ChangeCipherSpecPayload; +use crate::msgs::handshake::{ + CertificateChain, ClientDhParams, ClientEcdhParams, ClientKeyExchangeParams, + HandshakeMessagePayload, HandshakePayload, NewSessionTicketPayload, + NewSessionTicketPayloadTls13, ServerKeyExchangeParams, SessionId, +}; +use crate::msgs::message::{Message, MessagePayload}; +use crate::msgs::persist; +use crate::sign::Signer; +use crate::suites::{PartiallyExtractedSecrets, SupportedCipherSuite}; +use crate::sync::Arc; +use crate::tls12::{self, ConnectionSecrets, Tls12CipherSuite}; +use crate::verify::{self, DigitallySignedStruct}; + +mod server_hello { + use super::*; + use crate::client::hs::{ClientHelloInput, ClientSessionValue}; + use crate::msgs::handshake::ServerHelloPayload; + + pub(in crate::client) struct CompleteServerHelloHandling { + pub(in crate::client) randoms: ConnectionRandoms, + pub(in crate::client) transcript: HandshakeHash, + pub(in crate::client) input: ClientHelloInput, + } + + impl CompleteServerHelloHandling { + pub(in crate::client) fn handle_server_hello( + mut self, + cx: &mut ClientContext<'_>, + suite: &'static Tls12CipherSuite, + server_hello: &ServerHelloPayload, + tls13_supported: bool, + ) -> hs::NextStateOrError<'static> { + self.randoms + .server + .clone_from_slice(&server_hello.random.0[..]); + + // Look for TLS1.3 downgrade signal in server random + // both the server random and TLS12_DOWNGRADE_SENTINEL are + // public values and don't require constant time comparison + let has_downgrade_marker = self.randoms.server[24..] == tls12::DOWNGRADE_SENTINEL; + if tls13_supported && has_downgrade_marker { + return Err({ + cx.common.send_fatal_alert( + AlertDescription::IllegalParameter, + PeerMisbehaved::AttemptedDowngradeToTls12WhenTls13IsSupported, + ) + }); + } + + // If we didn't have an input session to resume, and we sent a session ID, + // that implies we sent a TLS 1.3 legacy_session_id for compatibility purposes. + // In this instance since we're now continuing a TLS 1.2 handshake the server + // should not have echoed it back: it's a randomly generated session ID it couldn't + // have known. + if self.input.resuming.is_none() + && !self.input.session_id.is_empty() + && self.input.session_id == server_hello.session_id + { + return Err({ + cx.common.send_fatal_alert( + AlertDescription::IllegalParameter, + PeerMisbehaved::ServerEchoedCompatibilitySessionId, + ) + }); + } + + let ClientHelloInput { + config, + server_name, + .. + } = self.input; + + let resuming_session = self + .input + .resuming + .and_then(|resuming| match resuming.value { + ClientSessionValue::Tls12(inner) => Some(inner), + ClientSessionValue::Tls13(_) => None, + }); + + // Doing EMS? + let using_ems = server_hello + .extended_master_secret_ack + .is_some(); + if config.require_ems && !using_ems { + return Err({ + cx.common.send_fatal_alert( + AlertDescription::HandshakeFailure, + PeerIncompatible::ExtendedMasterSecretExtensionRequired, + ) + }); + } + + // Might the server send a ticket? + let must_issue_new_ticket = if server_hello + .session_ticket_ack + .is_some() + { + debug!("Server supports tickets"); + true + } else { + false + }; + + // Might the server send a CertificateStatus between Certificate and + // ServerKeyExchange? + let may_send_cert_status = server_hello + .certificate_status_request_ack + .is_some(); + if may_send_cert_status { + debug!("Server may staple OCSP response"); + } + + // See if we're successfully resuming. + if let Some(resuming) = resuming_session { + if resuming.session_id == server_hello.session_id { + debug!("Server agreed to resume"); + + // Is the server telling lies about the ciphersuite? + if resuming.suite() != suite { + return Err(PeerMisbehaved::ResumptionOfferedWithVariedCipherSuite.into()); + } + + // And about EMS support? + if resuming.extended_ms() != using_ems { + return Err(PeerMisbehaved::ResumptionOfferedWithVariedEms.into()); + } + + let secrets = + ConnectionSecrets::new_resume(self.randoms, suite, resuming.secret()); + config.key_log.log( + "CLIENT_RANDOM", + &secrets.randoms.client, + &secrets.master_secret, + ); + cx.common + .start_encryption_tls12(&secrets, Side::Client); + + // Since we're resuming, we verified the certificate and + // proof of possession in the prior session. + cx.common.peer_certificates = Some( + resuming + .server_cert_chain() + .clone() + .into_owned(), + ); + cx.common.handshake_kind = Some(HandshakeKind::Resumed); + let cert_verified = verify::ServerCertVerified::assertion(); + let sig_verified = verify::HandshakeSignatureValid::assertion(); + + return if must_issue_new_ticket { + Ok(Box::new(ExpectNewTicket { + config, + secrets, + resuming_session: Some(resuming), + session_id: server_hello.session_id, + server_name, + using_ems, + transcript: self.transcript, + resuming: true, + cert_verified, + sig_verified, + })) + } else { + Ok(Box::new(ExpectCcs { + config, + secrets, + resuming_session: Some(resuming), + session_id: server_hello.session_id, + server_name, + using_ems, + transcript: self.transcript, + ticket: None, + resuming: true, + cert_verified, + sig_verified, + })) + }; + } + } + + cx.common.handshake_kind = Some(HandshakeKind::Full); + Ok(Box::new(ExpectCertificate { + config, + resuming_session: None, + session_id: server_hello.session_id, + server_name, + randoms: self.randoms, + using_ems, + transcript: self.transcript, + suite, + may_send_cert_status, + must_issue_new_ticket, + })) + } + } +} + +struct ExpectCertificate { + config: Arc, + resuming_session: Option, + session_id: SessionId, + server_name: ServerName<'static>, + randoms: ConnectionRandoms, + using_ems: bool, + transcript: HandshakeHash, + pub(super) suite: &'static Tls12CipherSuite, + may_send_cert_status: bool, + must_issue_new_ticket: bool, +} + +impl State for ExpectCertificate { + fn handle<'m>( + mut self: Box, + _cx: &mut ClientContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + self.transcript.add_message(&m); + let server_cert_chain = require_handshake_msg_move!( + m, + HandshakeType::Certificate, + HandshakePayload::Certificate + )?; + + if self.may_send_cert_status { + Ok(Box::new(ExpectCertificateStatusOrServerKx { + config: self.config, + resuming_session: self.resuming_session, + session_id: self.session_id, + server_name: self.server_name, + randoms: self.randoms, + using_ems: self.using_ems, + transcript: self.transcript, + suite: self.suite, + server_cert_chain, + must_issue_new_ticket: self.must_issue_new_ticket, + })) + } else { + let server_cert = ServerCertDetails::new(server_cert_chain, vec![]); + + Ok(Box::new(ExpectServerKx { + config: self.config, + resuming_session: self.resuming_session, + session_id: self.session_id, + server_name: self.server_name, + randoms: self.randoms, + using_ems: self.using_ems, + transcript: self.transcript, + suite: self.suite, + server_cert, + must_issue_new_ticket: self.must_issue_new_ticket, + })) + } + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + self + } +} + +struct ExpectCertificateStatusOrServerKx<'m> { + config: Arc, + resuming_session: Option, + session_id: SessionId, + server_name: ServerName<'static>, + randoms: ConnectionRandoms, + using_ems: bool, + transcript: HandshakeHash, + suite: &'static Tls12CipherSuite, + server_cert_chain: CertificateChain<'m>, + must_issue_new_ticket: bool, +} + +impl State for ExpectCertificateStatusOrServerKx<'_> { + fn handle<'m>( + self: Box, + cx: &mut ClientContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + match m.payload { + MessagePayload::Handshake { + parsed: HandshakeMessagePayload(HandshakePayload::ServerKeyExchange(..)), + .. + } => Box::new(ExpectServerKx { + config: self.config, + resuming_session: self.resuming_session, + session_id: self.session_id, + server_name: self.server_name, + randoms: self.randoms, + using_ems: self.using_ems, + transcript: self.transcript, + suite: self.suite, + server_cert: ServerCertDetails::new(self.server_cert_chain, vec![]), + must_issue_new_ticket: self.must_issue_new_ticket, + }) + .handle(cx, m), + MessagePayload::Handshake { + parsed: HandshakeMessagePayload(HandshakePayload::CertificateStatus(..)), + .. + } => Box::new(ExpectCertificateStatus { + config: self.config, + resuming_session: self.resuming_session, + session_id: self.session_id, + server_name: self.server_name, + randoms: self.randoms, + using_ems: self.using_ems, + transcript: self.transcript, + suite: self.suite, + server_cert_chain: self.server_cert_chain, + must_issue_new_ticket: self.must_issue_new_ticket, + }) + .handle(cx, m), + payload => Err(inappropriate_handshake_message( + &payload, + &[ContentType::Handshake], + &[ + HandshakeType::ServerKeyExchange, + HandshakeType::CertificateStatus, + ], + )), + } + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + Box::new(ExpectCertificateStatusOrServerKx { + config: self.config, + resuming_session: self.resuming_session, + session_id: self.session_id, + server_name: self.server_name, + randoms: self.randoms, + using_ems: self.using_ems, + transcript: self.transcript, + suite: self.suite, + server_cert_chain: self.server_cert_chain.into_owned(), + must_issue_new_ticket: self.must_issue_new_ticket, + }) + } +} + +struct ExpectCertificateStatus<'a> { + config: Arc, + resuming_session: Option, + session_id: SessionId, + server_name: ServerName<'static>, + randoms: ConnectionRandoms, + using_ems: bool, + transcript: HandshakeHash, + suite: &'static Tls12CipherSuite, + server_cert_chain: CertificateChain<'a>, + must_issue_new_ticket: bool, +} + +impl State for ExpectCertificateStatus<'_> { + fn handle<'m>( + mut self: Box, + _cx: &mut ClientContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + self.transcript.add_message(&m); + let server_cert_ocsp_response = require_handshake_msg_move!( + m, + HandshakeType::CertificateStatus, + HandshakePayload::CertificateStatus + )? + .into_inner(); + + trace!( + "Server stapled OCSP response is {:?}", + server_cert_ocsp_response + ); + + let server_cert = ServerCertDetails::new(self.server_cert_chain, server_cert_ocsp_response); + + Ok(Box::new(ExpectServerKx { + config: self.config, + resuming_session: self.resuming_session, + session_id: self.session_id, + server_name: self.server_name, + randoms: self.randoms, + using_ems: self.using_ems, + transcript: self.transcript, + suite: self.suite, + server_cert, + must_issue_new_ticket: self.must_issue_new_ticket, + })) + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + Box::new(ExpectCertificateStatus { + config: self.config, + resuming_session: self.resuming_session, + session_id: self.session_id, + server_name: self.server_name, + randoms: self.randoms, + using_ems: self.using_ems, + transcript: self.transcript, + suite: self.suite, + server_cert_chain: self.server_cert_chain.into_owned(), + must_issue_new_ticket: self.must_issue_new_ticket, + }) + } +} + +struct ExpectServerKx<'a> { + config: Arc, + resuming_session: Option, + session_id: SessionId, + server_name: ServerName<'static>, + randoms: ConnectionRandoms, + using_ems: bool, + transcript: HandshakeHash, + suite: &'static Tls12CipherSuite, + server_cert: ServerCertDetails<'a>, + must_issue_new_ticket: bool, +} + +impl State for ExpectServerKx<'_> { + fn handle<'m>( + mut self: Box, + cx: &mut ClientContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + let opaque_kx = require_handshake_msg!( + m, + HandshakeType::ServerKeyExchange, + HandshakePayload::ServerKeyExchange + )?; + self.transcript.add_message(&m); + + let kx = opaque_kx + .unwrap_given_kxa(self.suite.kx) + .ok_or_else(|| { + cx.common.send_fatal_alert( + AlertDescription::DecodeError, + InvalidMessage::MissingKeyExchange, + ) + })?; + + // Save the signature and signed parameters for later verification. + let mut kx_params = Vec::new(); + kx.params.encode(&mut kx_params); + let server_kx = ServerKxDetails::new(kx_params, kx.dss); + + #[cfg_attr(not(feature = "logging"), allow(unused_variables))] + { + match &kx.params { + ServerKeyExchangeParams::Ecdh(ecdhe) => { + debug!("ECDHE curve is {:?}", ecdhe.curve_params) + } + ServerKeyExchangeParams::Dh(dhe) => { + debug!("DHE params are p = {:?}, g = {:?}", dhe.dh_p, dhe.dh_g) + } + } + } + + Ok(Box::new(ExpectServerDoneOrCertReq { + config: self.config, + resuming_session: self.resuming_session, + session_id: self.session_id, + server_name: self.server_name, + randoms: self.randoms, + using_ems: self.using_ems, + transcript: self.transcript, + suite: self.suite, + server_cert: self.server_cert, + server_kx, + must_issue_new_ticket: self.must_issue_new_ticket, + })) + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + Box::new(ExpectServerKx { + config: self.config, + resuming_session: self.resuming_session, + session_id: self.session_id, + server_name: self.server_name, + randoms: self.randoms, + using_ems: self.using_ems, + transcript: self.transcript, + suite: self.suite, + server_cert: self.server_cert.into_owned(), + must_issue_new_ticket: self.must_issue_new_ticket, + }) + } +} + +fn emit_certificate( + transcript: &mut HandshakeHash, + cert_chain: CertificateChain<'static>, + common: &mut CommonState, +) { + let cert = Message { + version: ProtocolVersion::TLSv1_2, + payload: MessagePayload::handshake(HandshakeMessagePayload(HandshakePayload::Certificate( + cert_chain, + ))), + }; + + transcript.add_message(&cert); + common.send_msg(cert, false); +} + +fn emit_client_kx( + transcript: &mut HandshakeHash, + kxa: KeyExchangeAlgorithm, + common: &mut CommonState, + pub_key: &[u8], +) { + let mut buf = Vec::new(); + match kxa { + KeyExchangeAlgorithm::ECDHE => ClientKeyExchangeParams::Ecdh(ClientEcdhParams { + public: PayloadU8::new(pub_key.to_vec()), + }), + KeyExchangeAlgorithm::DHE => ClientKeyExchangeParams::Dh(ClientDhParams { + public: PayloadU16::new(pub_key.to_vec()), + }), + } + .encode(&mut buf); + let pubkey = Payload::new(buf); + + let ckx = Message { + version: ProtocolVersion::TLSv1_2, + payload: MessagePayload::handshake(HandshakeMessagePayload( + HandshakePayload::ClientKeyExchange(pubkey), + )), + }; + + transcript.add_message(&ckx); + common.send_msg(ckx, false); +} + +fn emit_certverify( + transcript: &mut HandshakeHash, + signer: &dyn Signer, + common: &mut CommonState, +) -> Result<(), Error> { + let message = transcript + .take_handshake_buf() + .ok_or_else(|| Error::General("Expected transcript".to_owned()))?; + + let scheme = signer.scheme(); + let sig = signer.sign(&message)?; + let body = DigitallySignedStruct::new(scheme, sig); + + let m = Message { + version: ProtocolVersion::TLSv1_2, + payload: MessagePayload::handshake(HandshakeMessagePayload( + HandshakePayload::CertificateVerify(body), + )), + }; + + transcript.add_message(&m); + common.send_msg(m, false); + Ok(()) +} + +fn emit_ccs(common: &mut CommonState) { + let ccs = Message { + version: ProtocolVersion::TLSv1_2, + payload: MessagePayload::ChangeCipherSpec(ChangeCipherSpecPayload {}), + }; + + common.send_msg(ccs, false); +} + +fn emit_finished( + secrets: &ConnectionSecrets, + transcript: &mut HandshakeHash, + common: &mut CommonState, +) { + let vh = transcript.current_hash(); + let verify_data = secrets.client_verify_data(&vh); + let verify_data_payload = Payload::new(verify_data); + + let f = Message { + version: ProtocolVersion::TLSv1_2, + payload: MessagePayload::handshake(HandshakeMessagePayload(HandshakePayload::Finished( + verify_data_payload, + ))), + }; + + transcript.add_message(&f); + common.send_msg(f, true); +} + +struct ServerKxDetails { + kx_params: Vec, + kx_sig: DigitallySignedStruct, +} + +impl ServerKxDetails { + fn new(params: Vec, sig: DigitallySignedStruct) -> Self { + Self { + kx_params: params, + kx_sig: sig, + } + } +} + +// --- Either a CertificateRequest, or a ServerHelloDone. --- +// Existence of the CertificateRequest tells us the server is asking for +// client auth. Otherwise we go straight to ServerHelloDone. +struct ExpectServerDoneOrCertReq<'a> { + config: Arc, + resuming_session: Option, + session_id: SessionId, + server_name: ServerName<'static>, + randoms: ConnectionRandoms, + using_ems: bool, + transcript: HandshakeHash, + suite: &'static Tls12CipherSuite, + server_cert: ServerCertDetails<'a>, + server_kx: ServerKxDetails, + must_issue_new_ticket: bool, +} + +impl State for ExpectServerDoneOrCertReq<'_> { + fn handle<'m>( + mut self: Box, + cx: &mut ClientContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + if matches!( + m.payload, + MessagePayload::Handshake { + parsed: HandshakeMessagePayload(HandshakePayload::CertificateRequest(_)), + .. + } + ) { + Box::new(ExpectCertificateRequest { + config: self.config, + resuming_session: self.resuming_session, + session_id: self.session_id, + server_name: self.server_name, + randoms: self.randoms, + using_ems: self.using_ems, + transcript: self.transcript, + suite: self.suite, + server_cert: self.server_cert, + server_kx: self.server_kx, + must_issue_new_ticket: self.must_issue_new_ticket, + }) + .handle(cx, m) + } else { + self.transcript.abandon_client_auth(); + + Box::new(ExpectServerDone { + config: self.config, + resuming_session: self.resuming_session, + session_id: self.session_id, + server_name: self.server_name, + randoms: self.randoms, + using_ems: self.using_ems, + transcript: self.transcript, + suite: self.suite, + server_cert: self.server_cert, + server_kx: self.server_kx, + client_auth: None, + must_issue_new_ticket: self.must_issue_new_ticket, + }) + .handle(cx, m) + } + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + Box::new(ExpectServerDoneOrCertReq { + config: self.config, + resuming_session: self.resuming_session, + session_id: self.session_id, + server_name: self.server_name, + randoms: self.randoms, + using_ems: self.using_ems, + transcript: self.transcript, + suite: self.suite, + server_cert: self.server_cert.into_owned(), + server_kx: self.server_kx, + must_issue_new_ticket: self.must_issue_new_ticket, + }) + } +} + +struct ExpectCertificateRequest<'a> { + config: Arc, + resuming_session: Option, + session_id: SessionId, + server_name: ServerName<'static>, + randoms: ConnectionRandoms, + using_ems: bool, + transcript: HandshakeHash, + suite: &'static Tls12CipherSuite, + server_cert: ServerCertDetails<'a>, + server_kx: ServerKxDetails, + must_issue_new_ticket: bool, +} + +impl State for ExpectCertificateRequest<'_> { + fn handle<'m>( + mut self: Box, + _cx: &mut ClientContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + let certreq = require_handshake_msg!( + m, + HandshakeType::CertificateRequest, + HandshakePayload::CertificateRequest + )?; + self.transcript.add_message(&m); + debug!("Got CertificateRequest {certreq:?}"); + + // The RFC jovially describes the design here as 'somewhat complicated' + // and 'somewhat underspecified'. So thanks for that. + // + // We ignore certreq.certtypes as a result, since the information it contains + // is entirely duplicated in certreq.sigschemes. + + const NO_CONTEXT: Option> = None; // TLS 1.2 doesn't use a context. + let no_compression = None; // or compression + let client_auth = ClientAuthDetails::resolve( + self.config + .client_auth_cert_resolver + .as_ref(), + Some(&certreq.canames), + &certreq.sigschemes, + NO_CONTEXT, + no_compression, + ); + + Ok(Box::new(ExpectServerDone { + config: self.config, + resuming_session: self.resuming_session, + session_id: self.session_id, + server_name: self.server_name, + randoms: self.randoms, + using_ems: self.using_ems, + transcript: self.transcript, + suite: self.suite, + server_cert: self.server_cert, + server_kx: self.server_kx, + client_auth: Some(client_auth), + must_issue_new_ticket: self.must_issue_new_ticket, + })) + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + Box::new(ExpectCertificateRequest { + config: self.config, + resuming_session: self.resuming_session, + session_id: self.session_id, + server_name: self.server_name, + randoms: self.randoms, + using_ems: self.using_ems, + transcript: self.transcript, + suite: self.suite, + server_cert: self.server_cert.into_owned(), + server_kx: self.server_kx, + must_issue_new_ticket: self.must_issue_new_ticket, + }) + } +} + +struct ExpectServerDone<'a> { + config: Arc, + resuming_session: Option, + session_id: SessionId, + server_name: ServerName<'static>, + randoms: ConnectionRandoms, + using_ems: bool, + transcript: HandshakeHash, + suite: &'static Tls12CipherSuite, + server_cert: ServerCertDetails<'a>, + server_kx: ServerKxDetails, + client_auth: Option, + must_issue_new_ticket: bool, +} + +impl State for ExpectServerDone<'_> { + fn handle<'m>( + self: Box, + cx: &mut ClientContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + match m.payload { + MessagePayload::Handshake { + parsed: HandshakeMessagePayload(HandshakePayload::ServerHelloDone), + .. + } => {} + payload => { + return Err(inappropriate_handshake_message( + &payload, + &[ContentType::Handshake], + &[HandshakeType::ServerHelloDone], + )); + } + } + + let mut st = *self; + st.transcript.add_message(&m); + + cx.common.check_aligned_handshake()?; + + trace!("Server cert is {:?}", st.server_cert.cert_chain); + debug!("Server DNS name is {:?}", st.server_name); + + let suite = st.suite; + + // 1. Verify the cert chain. + // 2. Verify that the top certificate signed their kx. + // 3. If doing client auth, send our Certificate. + // 4. Complete the key exchange: + // a) generate our kx pair + // b) emit a ClientKeyExchange containing it + // c) if doing client auth, emit a CertificateVerify + // d) derive the shared keys + // e) emit a CCS + // f) use the derived keys to start encryption + // 5. emit a Finished, our first encrypted message under the new keys. + + // 1. + let (end_entity, intermediates) = st + .server_cert + .cert_chain + .split_first() + .ok_or(Error::NoCertificatesPresented)?; + + let now = st.config.current_time()?; + + let cert_verified = st + .config + .verifier + .verify_server_cert( + end_entity, + intermediates, + &st.server_name, + &st.server_cert.ocsp_response, + now, + ) + .map_err(|err| { + cx.common + .send_cert_verify_error_alert(err) + })?; + + // 2. + // Build up the contents of the signed message. + // It's ClientHello.random || ServerHello.random || ServerKeyExchange.params + let sig_verified = { + let mut message = Vec::new(); + message.extend_from_slice(&st.randoms.client); + message.extend_from_slice(&st.randoms.server); + message.extend_from_slice(&st.server_kx.kx_params); + + // Check the signature is compatible with the ciphersuite. + let sig = &st.server_kx.kx_sig; + if !SupportedCipherSuite::from(suite) + .usable_for_signature_algorithm(sig.scheme.algorithm()) + { + warn!( + "peer signed kx with wrong algorithm (got {:?} expect {:?})", + sig.scheme.algorithm(), + suite.sign + ); + return Err(PeerMisbehaved::SignedKxWithWrongAlgorithm.into()); + } + + st.config + .verifier + .verify_tls12_signature(&message, end_entity, sig) + .map_err(|err| { + cx.common + .send_cert_verify_error_alert(err) + })? + }; + cx.common.peer_certificates = Some(st.server_cert.cert_chain.into_owned()); + + // 3. + if let Some(client_auth) = &st.client_auth { + let certs = match client_auth { + ClientAuthDetails::Empty { .. } => CertificateChain::default(), + ClientAuthDetails::Verify { certkey, .. } => CertificateChain(certkey.cert.clone()), + }; + emit_certificate(&mut st.transcript, certs, cx.common); + } + + // 4a. + let kx_params = tls12::decode_kx_params::( + st.suite.kx, + cx.common, + &st.server_kx.kx_params, + )?; + let maybe_skxg = match &kx_params { + ServerKeyExchangeParams::Ecdh(ecdh) => st + .config + .find_kx_group(ecdh.curve_params.named_group, ProtocolVersion::TLSv1_2), + ServerKeyExchangeParams::Dh(dh) => { + let ffdhe_group = dh.as_ffdhe_group(); + + st.config + .provider + .kx_groups + .iter() + .find(|kxg| kxg.ffdhe_group() == Some(ffdhe_group)) + .copied() + } + }; + let Some(skxg) = maybe_skxg else { + return Err(cx.common.send_fatal_alert( + AlertDescription::IllegalParameter, + PeerMisbehaved::SelectedUnofferedKxGroup, + )); + }; + cx.common.kx_state = KxState::Start(skxg); + let kx = skxg.start()?; + + // 4b. + let mut transcript = st.transcript; + emit_client_kx(&mut transcript, st.suite.kx, cx.common, kx.pub_key()); + // Note: EMS handshake hash only runs up to ClientKeyExchange. + let ems_seed = st + .using_ems + .then(|| transcript.current_hash()); + + // 4c. + if let Some(ClientAuthDetails::Verify { signer, .. }) = &st.client_auth { + emit_certverify(&mut transcript, signer.as_ref(), cx.common)?; + } + + // 4d. Derive secrets. + // An alert at this point will be sent in plaintext. That must happen + // prior to the CCS, or else the peer will try to decrypt it. + let secrets = ConnectionSecrets::from_key_exchange( + kx, + kx_params.pub_key(), + ems_seed, + st.randoms, + suite, + ) + .map_err(|err| { + cx.common + .send_fatal_alert(AlertDescription::IllegalParameter, err) + })?; + cx.common.kx_state.complete(); + + // 4e. CCS. We are definitely going to switch on encryption. + emit_ccs(cx.common); + + // 4f. Now commit secrets. + st.config.key_log.log( + "CLIENT_RANDOM", + &secrets.randoms.client, + &secrets.master_secret, + ); + cx.common + .start_encryption_tls12(&secrets, Side::Client); + cx.common + .record_layer + .start_encrypting(); + + // 5. + emit_finished(&secrets, &mut transcript, cx.common); + + if st.must_issue_new_ticket { + Ok(Box::new(ExpectNewTicket { + config: st.config, + secrets, + resuming_session: st.resuming_session, + session_id: st.session_id, + server_name: st.server_name, + using_ems: st.using_ems, + transcript, + resuming: false, + cert_verified, + sig_verified, + })) + } else { + Ok(Box::new(ExpectCcs { + config: st.config, + secrets, + resuming_session: st.resuming_session, + session_id: st.session_id, + server_name: st.server_name, + using_ems: st.using_ems, + transcript, + ticket: None, + resuming: false, + cert_verified, + sig_verified, + })) + } + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + Box::new(ExpectServerDone { + config: self.config, + resuming_session: self.resuming_session, + session_id: self.session_id, + server_name: self.server_name, + randoms: self.randoms, + using_ems: self.using_ems, + transcript: self.transcript, + suite: self.suite, + server_cert: self.server_cert.into_owned(), + server_kx: self.server_kx, + client_auth: self.client_auth, + must_issue_new_ticket: self.must_issue_new_ticket, + }) + } +} + +struct ExpectNewTicket { + config: Arc, + secrets: ConnectionSecrets, + resuming_session: Option, + session_id: SessionId, + server_name: ServerName<'static>, + using_ems: bool, + transcript: HandshakeHash, + resuming: bool, + cert_verified: verify::ServerCertVerified, + sig_verified: verify::HandshakeSignatureValid, +} + +impl State for ExpectNewTicket { + fn handle<'m>( + mut self: Box, + _cx: &mut ClientContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + self.transcript.add_message(&m); + + let nst = require_handshake_msg_move!( + m, + HandshakeType::NewSessionTicket, + HandshakePayload::NewSessionTicket + )?; + + Ok(Box::new(ExpectCcs { + config: self.config, + secrets: self.secrets, + resuming_session: self.resuming_session, + session_id: self.session_id, + server_name: self.server_name, + using_ems: self.using_ems, + transcript: self.transcript, + ticket: Some(nst), + resuming: self.resuming, + cert_verified: self.cert_verified, + sig_verified: self.sig_verified, + })) + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + self + } +} + +// -- Waiting for their CCS -- +struct ExpectCcs { + config: Arc, + secrets: ConnectionSecrets, + resuming_session: Option, + session_id: SessionId, + server_name: ServerName<'static>, + using_ems: bool, + transcript: HandshakeHash, + ticket: Option, + resuming: bool, + cert_verified: verify::ServerCertVerified, + sig_verified: verify::HandshakeSignatureValid, +} + +impl State for ExpectCcs { + fn handle<'m>( + self: Box, + cx: &mut ClientContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + match m.payload { + MessagePayload::ChangeCipherSpec(..) => {} + payload => { + return Err(inappropriate_message( + &payload, + &[ContentType::ChangeCipherSpec], + )); + } + } + // CCS should not be received interleaved with fragmented handshake-level + // message. + cx.common.check_aligned_handshake()?; + + // Note: msgs layer validates trivial contents of CCS. + cx.common + .record_layer + .start_decrypting(); + + Ok(Box::new(ExpectFinished { + config: self.config, + secrets: self.secrets, + resuming_session: self.resuming_session, + session_id: self.session_id, + server_name: self.server_name, + using_ems: self.using_ems, + transcript: self.transcript, + ticket: self.ticket, + resuming: self.resuming, + cert_verified: self.cert_verified, + sig_verified: self.sig_verified, + })) + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + self + } +} + +struct ExpectFinished { + config: Arc, + resuming_session: Option, + session_id: SessionId, + server_name: ServerName<'static>, + using_ems: bool, + transcript: HandshakeHash, + ticket: Option, + secrets: ConnectionSecrets, + resuming: bool, + cert_verified: verify::ServerCertVerified, + sig_verified: verify::HandshakeSignatureValid, +} + +impl ExpectFinished { + // -- Waiting for their finished -- + fn save_session(&mut self, cx: &ClientContext<'_>) { + // Save a ticket. If we got a new ticket, save that. Otherwise, save the + // original ticket again. + let (mut ticket, lifetime) = match self.ticket.take() { + Some(nst) => (nst.ticket, nst.lifetime_hint), + None => (Arc::new(PayloadU16::empty()), 0), + }; + + if ticket.0.is_empty() { + if let Some(resuming_session) = &mut self.resuming_session { + ticket = resuming_session.ticket(); + } + } + + if self.session_id.is_empty() && ticket.0.is_empty() { + debug!("Session not saved: server didn't allocate id or ticket"); + return; + } + + let Ok(now) = self.config.current_time() else { + debug!("Could not get current time"); + return; + }; + + let session_value = persist::Tls12ClientSessionValue::new( + self.secrets.suite(), + self.session_id, + ticket, + self.secrets.master_secret(), + cx.common + .peer_certificates + .clone() + .unwrap_or_default(), + &self.config.verifier, + &self.config.client_auth_cert_resolver, + now, + lifetime, + self.using_ems, + ); + + self.config + .resumption + .store + .set_tls12_session(self.server_name.clone(), session_value); + } +} + +impl State for ExpectFinished { + fn handle<'m>( + self: Box, + cx: &mut ClientContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + let mut st = *self; + let finished = + require_handshake_msg!(m, HandshakeType::Finished, HandshakePayload::Finished)?; + + cx.common.check_aligned_handshake()?; + + // Work out what verify_data we expect. + let vh = st.transcript.current_hash(); + let expect_verify_data = st.secrets.server_verify_data(&vh); + + // Constant-time verification of this is relatively unimportant: they only + // get one chance. But it can't hurt. + let _fin_verified = + match ConstantTimeEq::ct_eq(&expect_verify_data[..], finished.bytes()).into() { + true => verify::FinishedMessageVerified::assertion(), + false => { + return Err(cx + .common + .send_fatal_alert(AlertDescription::DecryptError, Error::DecryptError)); + } + }; + + // Hash this message too. + st.transcript.add_message(&m); + + st.save_session(cx); + + if st.resuming { + emit_ccs(cx.common); + cx.common + .record_layer + .start_encrypting(); + emit_finished(&st.secrets, &mut st.transcript, cx.common); + } + + cx.common + .start_traffic(&mut cx.sendable_plaintext); + Ok(Box::new(ExpectTraffic { + secrets: st.secrets, + _cert_verified: st.cert_verified, + _sig_verified: st.sig_verified, + _fin_verified, + })) + } + + // we could not decrypt the encrypted handshake message with session resumption + // this might mean that the ticket was invalid for some reason, so we remove it + // from the store to restart a session from scratch + fn handle_decrypt_error(&self) { + if self.resuming { + self.config + .resumption + .store + .remove_tls12_session(&self.server_name); + } + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + self + } +} + +// -- Traffic transit state -- +struct ExpectTraffic { + secrets: ConnectionSecrets, + _cert_verified: verify::ServerCertVerified, + _sig_verified: verify::HandshakeSignatureValid, + _fin_verified: verify::FinishedMessageVerified, +} + +impl State for ExpectTraffic { + fn handle<'m>( + self: Box, + cx: &mut ClientContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + match m.payload { + MessagePayload::ApplicationData(payload) => cx + .common + .take_received_plaintext(payload), + payload => { + return Err(inappropriate_message( + &payload, + &[ContentType::ApplicationData], + )); + } + } + Ok(self) + } + + fn export_keying_material( + &self, + output: &mut [u8], + label: &[u8], + context: Option<&[u8]>, + ) -> Result<(), Error> { + self.secrets + .export_keying_material(output, label, context); + Ok(()) + } + + fn extract_secrets(&self) -> Result { + self.secrets + .extract_secrets(Side::Client) + } + + fn into_external_state(self: Box) -> Result, Error> { + Ok(self) + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + self + } +} + +impl KernelState for ExpectTraffic { + fn update_secrets(&mut self, _: Direction) -> Result { + Err(Error::General( + "TLS 1.2 connections do not support traffic secret updates".into(), + )) + } + + fn handle_new_session_ticket( + &mut self, + _cx: &mut KernelContext<'_>, + _message: &NewSessionTicketPayloadTls13, + ) -> Result<(), Error> { + Err(Error::General( + "TLS 1.2 session tickets may not be sent once the handshake has completed".into(), + )) + } +} diff --git a/http/vendor/rustls/src/client/tls13.rs b/http/vendor/rustls/src/client/tls13.rs new file mode 100644 index 0000000..5f15f36 --- /dev/null +++ b/http/vendor/rustls/src/client/tls13.rs @@ -0,0 +1,1701 @@ +use alloc::boxed::Box; +use alloc::vec; +use alloc::vec::Vec; + +use pki_types::ServerName; +use subtle::ConstantTimeEq; + +use super::client_conn::ClientConnectionData; +use super::hs::{ClientContext, ClientHelloInput, ClientSessionValue}; +use crate::check::inappropriate_handshake_message; +use crate::client::common::{ClientAuthDetails, ClientHelloDetails, ServerCertDetails}; +use crate::client::ech::{self, EchState, EchStatus}; +use crate::client::{ClientConfig, ClientSessionStore, hs}; +use crate::common_state::{ + CommonState, HandshakeFlightTls13, HandshakeKind, KxState, Protocol, Side, State, +}; +use crate::conn::ConnectionRandoms; +use crate::conn::kernel::{Direction, KernelContext, KernelState}; +use crate::crypto::hash::Hash; +use crate::crypto::{ActiveKeyExchange, SharedSecret}; +use crate::enums::{ + AlertDescription, ContentType, HandshakeType, ProtocolVersion, SignatureScheme, +}; +use crate::error::{Error, InvalidMessage, PeerIncompatible, PeerMisbehaved}; +use crate::hash_hs::{HandshakeHash, HandshakeHashBuffer}; +use crate::log::{debug, trace, warn}; +use crate::msgs::base::{Payload, PayloadU8}; +use crate::msgs::ccs::ChangeCipherSpecPayload; +use crate::msgs::codec::{Codec, Reader}; +use crate::msgs::enums::{ExtensionType, KeyUpdateRequest}; +use crate::msgs::handshake::{ + CERTIFICATE_MAX_SIZE_LIMIT, CertificatePayloadTls13, ClientExtensions, EchConfigPayload, + HandshakeMessagePayload, HandshakePayload, KeyShareEntry, NewSessionTicketPayloadTls13, + PresharedKeyBinder, PresharedKeyIdentity, PresharedKeyOffer, ServerExtensions, + ServerHelloPayload, +}; +use crate::msgs::message::{Message, MessagePayload}; +use crate::msgs::persist::{self, Retrieved}; +use crate::sign::{CertifiedKey, Signer}; +use crate::suites::PartiallyExtractedSecrets; +use crate::sync::Arc; +use crate::tls13::key_schedule::{ + KeyScheduleEarly, KeyScheduleHandshake, KeySchedulePreHandshake, KeyScheduleResumption, + KeyScheduleTraffic, +}; +use crate::tls13::{ + Tls13CipherSuite, construct_client_verify_message, construct_server_verify_message, +}; +use crate::verify::{self, DigitallySignedStruct}; +use crate::{ConnectionTrafficSecrets, KeyLog, compress, crypto}; + +// Extensions we expect in plaintext in the ServerHello. +static ALLOWED_PLAINTEXT_EXTS: &[ExtensionType] = &[ + ExtensionType::KeyShare, + ExtensionType::PreSharedKey, + ExtensionType::SupportedVersions, +]; + +// Only the intersection of things we offer, and those disallowed +// in TLS1.3 +static DISALLOWED_TLS13_EXTS: &[ExtensionType] = &[ + ExtensionType::ECPointFormats, + ExtensionType::SessionTicket, + ExtensionType::RenegotiationInfo, + ExtensionType::ExtendedMasterSecret, +]; + +/// `early_data_key_schedule` is `Some` if we sent the +/// "early_data" extension to the server. +pub(super) fn handle_server_hello( + cx: &mut ClientContext<'_>, + server_hello: &ServerHelloPayload, + mut randoms: ConnectionRandoms, + suite: &'static Tls13CipherSuite, + mut transcript: HandshakeHash, + early_data_key_schedule: Option, + our_key_share: Box, + server_hello_msg: &Message<'_>, + ech_state: Option, + input: ClientHelloInput, +) -> hs::NextStateOrError<'static> { + validate_server_hello(cx.common, server_hello)?; + + let their_key_share = server_hello + .key_share + .as_ref() + .ok_or_else(|| { + cx.common.send_fatal_alert( + AlertDescription::MissingExtension, + PeerMisbehaved::MissingKeyShare, + ) + })?; + + let ClientHelloInput { + config, + resuming, + mut sent_tls13_fake_ccs, + mut hello, + server_name, + .. + } = input; + + let mut resuming_session = match resuming { + Some(Retrieved { + value: ClientSessionValue::Tls13(value), + .. + }) => Some(value), + _ => None, + }; + + let our_key_share = KeyExchangeChoice::new(&config, cx, our_key_share, their_key_share) + .map_err(|_| { + cx.common.send_fatal_alert( + AlertDescription::IllegalParameter, + PeerMisbehaved::WrongGroupForKeyShare, + ) + })?; + + let key_schedule_pre_handshake = match (server_hello.preshared_key, early_data_key_schedule) { + (Some(selected_psk), Some(early_key_schedule)) => { + match &resuming_session { + Some(resuming) => { + let Some(resuming_suite) = suite.can_resume_from(resuming.suite()) else { + return Err({ + cx.common.send_fatal_alert( + AlertDescription::IllegalParameter, + PeerMisbehaved::ResumptionOfferedWithIncompatibleCipherSuite, + ) + }); + }; + + // If the server varies the suite here, we will have encrypted early data with + // the wrong suite. + if cx.data.early_data.is_enabled() && resuming_suite != suite { + return Err({ + cx.common.send_fatal_alert( + AlertDescription::IllegalParameter, + PeerMisbehaved::EarlyDataOfferedWithVariedCipherSuite, + ) + }); + } + + if selected_psk != 0 { + return Err({ + cx.common.send_fatal_alert( + AlertDescription::IllegalParameter, + PeerMisbehaved::SelectedInvalidPsk, + ) + }); + } + + debug!("Resuming using PSK"); + // The key schedule has been initialized and set in fill_in_psk_binder() + } + _ => { + return Err(PeerMisbehaved::SelectedUnofferedPsk.into()); + } + } + KeySchedulePreHandshake::from(early_key_schedule) + } + _ => { + debug!("Not resuming"); + // Discard the early data key schedule. + cx.data.early_data.rejected(); + cx.common.early_traffic = false; + resuming_session.take(); + KeySchedulePreHandshake::new(suite) + } + }; + + cx.common.kx_state.complete(); + let shared_secret = our_key_share + .complete(&their_key_share.payload.0) + .map_err(|err| { + cx.common + .send_fatal_alert(AlertDescription::IllegalParameter, err) + })?; + + let mut key_schedule = key_schedule_pre_handshake.into_handshake(shared_secret); + + // If we have ECH state, check that the server accepted our offer. + if let Some(ech_state) = ech_state { + let Message { + payload: + MessagePayload::Handshake { + encoded: server_hello_encoded, + .. + }, + .. + } = &server_hello_msg + else { + unreachable!("ServerHello is a handshake message"); + }; + cx.data.ech_status = match ech_state.confirm_acceptance( + &mut key_schedule, + server_hello, + server_hello_encoded, + suite.common.hash_provider, + )? { + // The server accepted our ECH offer, so complete the inner transcript with the + // server hello message, and switch the relevant state to the copies for the + // inner client hello. + Some(mut accepted) => { + accepted + .transcript + .add_message(server_hello_msg); + transcript = accepted.transcript; + randoms.client = accepted.random.0; + hello.sent_extensions = accepted.sent_extensions; + EchStatus::Accepted + } + // The server rejected our ECH offer. + None => EchStatus::Rejected, + }; + } + + // Remember what KX group the server liked for next time. + config + .resumption + .store + .set_kx_hint(server_name.clone(), their_key_share.group); + + // If we change keying when a subsequent handshake message is being joined, + // the two halves will have different record layer protections. Disallow this. + cx.common.check_aligned_handshake()?; + + let hash_at_client_recvd_server_hello = transcript.current_hash(); + let key_schedule = key_schedule.derive_client_handshake_secrets( + cx.data.early_data.is_enabled(), + hash_at_client_recvd_server_hello, + suite, + &*config.key_log, + &randoms.client, + cx.common, + ); + + emit_fake_ccs(&mut sent_tls13_fake_ccs, cx.common); + + Ok(Box::new(ExpectEncryptedExtensions { + config, + resuming_session, + server_name, + randoms, + suite, + transcript, + key_schedule, + hello, + })) +} + +enum KeyExchangeChoice { + Whole(Box), + Component(Box), +} + +impl KeyExchangeChoice { + /// Decide between `our_key_share` or `our_key_share.hybrid_component()` + /// based on the selection of the server expressed in `their_key_share`. + fn new( + config: &Arc, + cx: &mut ClientContext<'_>, + our_key_share: Box, + their_key_share: &KeyShareEntry, + ) -> Result { + if our_key_share.group() == their_key_share.group { + return Ok(Self::Whole(our_key_share)); + } + + let (component_group, _) = our_key_share + .hybrid_component() + .ok_or(())?; + + if component_group != their_key_share.group { + return Err(()); + } + + // correct the record for the benefit of accuracy of + // `negotiated_key_exchange_group()` + let actual_skxg = config + .find_kx_group(component_group, ProtocolVersion::TLSv1_3) + .ok_or(())?; + cx.common.kx_state = KxState::Start(actual_skxg); + + Ok(Self::Component(our_key_share)) + } + + fn complete(self, peer_pub_key: &[u8]) -> Result { + match self { + Self::Whole(akx) => akx.complete(peer_pub_key), + Self::Component(akx) => akx.complete_hybrid_component(peer_pub_key), + } + } +} + +fn validate_server_hello( + common: &mut CommonState, + server_hello: &ServerHelloPayload, +) -> Result<(), Error> { + if !server_hello.only_contains(ALLOWED_PLAINTEXT_EXTS) { + return Err(common.send_fatal_alert( + AlertDescription::UnsupportedExtension, + PeerMisbehaved::UnexpectedCleartextExtension, + )); + } + + Ok(()) +} + +pub(super) fn initial_key_share( + config: &ClientConfig, + server_name: &ServerName<'_>, + kx_state: &mut KxState, +) -> Result, Error> { + let group = config + .resumption + .store + .kx_hint(server_name) + .and_then(|group_name| config.find_kx_group(group_name, ProtocolVersion::TLSv1_3)) + .unwrap_or_else(|| { + config + .provider + .kx_groups + .iter() + .copied() + .next() + .expect("No kx groups configured") + }); + + *kx_state = KxState::Start(group); + group.start() +} + +/// This implements the horrifying TLS1.3 hack where PSK binders have a +/// data dependency on the message they are contained within. +pub(super) fn fill_in_psk_binder( + resuming: &persist::Tls13ClientSessionValue, + transcript: &HandshakeHashBuffer, + hmp: &mut HandshakeMessagePayload<'_>, +) -> KeyScheduleEarly { + // We need to know the hash function of the suite we're trying to resume into. + let suite = resuming.suite(); + let suite_hash = suite.common.hash_provider; + + // The binder is calculated over the clienthello, but doesn't include itself or its + // length, or the length of its container. + let binder_plaintext = hmp.encoding_for_binder_signing(); + let handshake_hash = transcript.hash_given(suite_hash, &binder_plaintext); + + // Run a fake key_schedule to simulate what the server will do if it chooses + // to resume. + let key_schedule = KeyScheduleEarly::new(suite, resuming.secret()); + let real_binder = key_schedule.resumption_psk_binder_key_and_sign_verify_data(&handshake_hash); + + if let HandshakePayload::ClientHello(ch) = &mut hmp.0 { + if let Some(PresharedKeyOffer { + binders, + identities, + }) = &mut ch.preshared_key_offer + { + // the caller of this function must have set up the desired identity, and a + // matching (dummy) binder; or else the binder we compute here will be incorrect. + // See `prepare_resumption()`. + debug_assert_eq!(identities.len(), 1); + debug_assert_eq!(binders.len(), 1); + debug_assert_eq!(binders[0].as_ref().len(), real_binder.as_ref().len()); + binders[0] = PresharedKeyBinder::from(real_binder.as_ref().to_vec()); + } + }; + + key_schedule +} + +pub(super) fn prepare_resumption( + config: &ClientConfig, + cx: &mut ClientContext<'_>, + resuming_session: &Retrieved<&persist::Tls13ClientSessionValue>, + exts: &mut ClientExtensions<'_>, + doing_retry: bool, +) { + let resuming_suite = resuming_session.suite(); + cx.common.suite = Some(resuming_suite.into()); + // The EarlyData extension MUST be supplied together with the + // PreSharedKey extension. + let max_early_data_size = resuming_session.max_early_data_size(); + if config.enable_early_data && max_early_data_size > 0 && !doing_retry { + cx.data + .early_data + .enable(max_early_data_size as usize); + exts.early_data_request = Some(()); + } + + // Finally, and only for TLS1.3 with a ticket resumption, include a binder + // for our ticket. This must go last. + // + // Include an empty binder. It gets filled in below because it depends on + // the message it's contained in (!!!). + let obfuscated_ticket_age = resuming_session.obfuscated_ticket_age(); + + let binder_len = resuming_suite + .common + .hash_provider + .output_len(); + let binder = vec![0u8; binder_len]; + + let psk_identity = + PresharedKeyIdentity::new(resuming_session.ticket().to_vec(), obfuscated_ticket_age); + let psk_offer = PresharedKeyOffer::new(psk_identity, binder); + exts.preshared_key_offer = Some(psk_offer); +} + +pub(super) fn derive_early_traffic_secret( + key_log: &dyn KeyLog, + cx: &mut ClientContext<'_>, + hash_alg: &'static dyn Hash, + early_key_schedule: &KeyScheduleEarly, + sent_tls13_fake_ccs: &mut bool, + transcript_buffer: &HandshakeHashBuffer, + client_random: &[u8; 32], +) { + // For middlebox compatibility + emit_fake_ccs(sent_tls13_fake_ccs, cx.common); + + let client_hello_hash = transcript_buffer.hash_given(hash_alg, &[]); + early_key_schedule.client_early_traffic_secret( + &client_hello_hash, + key_log, + client_random, + cx.common, + ); + + // Now the client can send encrypted early data + cx.common.early_traffic = true; + trace!("Starting early data traffic"); +} + +pub(super) fn emit_fake_ccs(sent_tls13_fake_ccs: &mut bool, common: &mut CommonState) { + if common.is_quic() { + return; + } + + if core::mem::replace(sent_tls13_fake_ccs, true) { + return; + } + + let m = Message { + version: ProtocolVersion::TLSv1_2, + payload: MessagePayload::ChangeCipherSpec(ChangeCipherSpecPayload {}), + }; + common.send_msg(m, false); +} + +fn validate_encrypted_extensions( + common: &mut CommonState, + hello: &ClientHelloDetails, + exts: &ServerExtensions<'_>, +) -> Result<(), Error> { + if hello.server_sent_unsolicited_extensions(exts, &[]) { + return Err(common.send_fatal_alert( + AlertDescription::UnsupportedExtension, + PeerMisbehaved::UnsolicitedEncryptedExtension, + )); + } + + if exts.contains_any(ALLOWED_PLAINTEXT_EXTS) || exts.contains_any(DISALLOWED_TLS13_EXTS) { + return Err(common.send_fatal_alert( + AlertDescription::UnsupportedExtension, + PeerMisbehaved::DisallowedEncryptedExtension, + )); + } + + Ok(()) +} + +struct ExpectEncryptedExtensions { + config: Arc, + resuming_session: Option, + server_name: ServerName<'static>, + randoms: ConnectionRandoms, + suite: &'static Tls13CipherSuite, + transcript: HandshakeHash, + key_schedule: KeyScheduleHandshake, + hello: ClientHelloDetails, +} + +impl State for ExpectEncryptedExtensions { + fn handle<'m>( + mut self: Box, + cx: &mut ClientContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + let exts = require_handshake_msg!( + m, + HandshakeType::EncryptedExtensions, + HandshakePayload::EncryptedExtensions + )?; + debug!("TLS1.3 encrypted extensions: {exts:?}"); + self.transcript.add_message(&m); + + validate_encrypted_extensions(cx.common, &self.hello, exts)?; + hs::process_alpn_protocol( + cx.common, + &self.hello.alpn_protocols, + exts.selected_protocol + .as_ref() + .map(|protocol| protocol.as_ref()), + self.config.check_selected_alpn, + )?; + hs::process_client_cert_type_extension( + cx.common, + &self.config, + exts.client_certificate_type.as_ref(), + )?; + hs::process_server_cert_type_extension( + cx.common, + &self.config, + exts.server_certificate_type.as_ref(), + )?; + + let ech_retry_configs = match (cx.data.ech_status, &exts.encrypted_client_hello_ack) { + // If we didn't offer ECH, or ECH was accepted, but the server sent an ECH encrypted + // extension with retry configs, we must error. + (EchStatus::NotOffered | EchStatus::Accepted, Some(_)) => { + return Err(cx.common.send_fatal_alert( + AlertDescription::UnsupportedExtension, + PeerMisbehaved::UnsolicitedEchExtension, + )); + } + // If we offered ECH, and it was rejected, store the retry configs (if any) from + // the server's ECH extension. We will return them in an error produced at the end + // of the handshake. + (EchStatus::Rejected, ext) => ext + .as_ref() + .map(|ext| ext.retry_configs.to_vec()), + _ => None, + }; + + // QUIC transport parameters + if cx.common.is_quic() { + match exts + .transport_parameters + .as_ref() + .or(exts.transport_parameters_draft.as_ref()) + { + Some(params) => cx.common.quic.params = Some(params.clone().into_vec()), + None => { + return Err(cx + .common + .missing_extension(PeerMisbehaved::MissingQuicTransportParameters)); + } + } + } + + match self.resuming_session { + Some(resuming_session) => { + let was_early_traffic = cx.common.early_traffic; + if was_early_traffic { + match exts.early_data_ack { + Some(()) => cx.data.early_data.accepted(), + None => { + cx.data.early_data.rejected(); + cx.common.early_traffic = false; + } + } + } + + if was_early_traffic && !cx.common.early_traffic { + // If no early traffic, set the encryption key for handshakes + self.key_schedule + .set_handshake_encrypter(cx.common); + } + + cx.common.peer_certificates = Some( + resuming_session + .server_cert_chain() + .clone(), + ); + cx.common.handshake_kind = Some(HandshakeKind::Resumed); + + // We *don't* reverify the certificate chain here: resumption is a + // continuation of the previous session in terms of security policy. + let cert_verified = verify::ServerCertVerified::assertion(); + let sig_verified = verify::HandshakeSignatureValid::assertion(); + Ok(Box::new(ExpectFinished { + config: self.config, + server_name: self.server_name, + randoms: self.randoms, + suite: self.suite, + transcript: self.transcript, + key_schedule: self.key_schedule, + client_auth: None, + cert_verified, + sig_verified, + ech_retry_configs, + })) + } + _ => { + if exts.early_data_ack.is_some() { + return Err(PeerMisbehaved::EarlyDataExtensionWithoutResumption.into()); + } + cx.common + .handshake_kind + .get_or_insert(HandshakeKind::Full); + + Ok(if self.hello.offered_cert_compression { + Box::new(ExpectCertificateOrCompressedCertificateOrCertReq { + config: self.config, + server_name: self.server_name, + randoms: self.randoms, + suite: self.suite, + transcript: self.transcript, + key_schedule: self.key_schedule, + ech_retry_configs, + }) + } else { + Box::new(ExpectCertificateOrCertReq { + config: self.config, + server_name: self.server_name, + randoms: self.randoms, + suite: self.suite, + transcript: self.transcript, + key_schedule: self.key_schedule, + ech_retry_configs, + }) + }) + } + } + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + self + } +} + +struct ExpectCertificateOrCompressedCertificateOrCertReq { + config: Arc, + server_name: ServerName<'static>, + randoms: ConnectionRandoms, + suite: &'static Tls13CipherSuite, + transcript: HandshakeHash, + key_schedule: KeyScheduleHandshake, + ech_retry_configs: Option>, +} + +impl State for ExpectCertificateOrCompressedCertificateOrCertReq { + fn handle<'m>( + self: Box, + cx: &mut ClientContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + match m.payload { + MessagePayload::Handshake { + parsed: HandshakeMessagePayload(HandshakePayload::CertificateTls13(..)), + .. + } => Box::new(ExpectCertificate { + config: self.config, + server_name: self.server_name, + randoms: self.randoms, + suite: self.suite, + transcript: self.transcript, + key_schedule: self.key_schedule, + client_auth: None, + message_already_in_transcript: false, + ech_retry_configs: self.ech_retry_configs, + }) + .handle(cx, m), + MessagePayload::Handshake { + parsed: HandshakeMessagePayload(HandshakePayload::CompressedCertificate(..)), + .. + } => Box::new(ExpectCompressedCertificate { + config: self.config, + server_name: self.server_name, + randoms: self.randoms, + suite: self.suite, + transcript: self.transcript, + key_schedule: self.key_schedule, + client_auth: None, + ech_retry_configs: self.ech_retry_configs, + }) + .handle(cx, m), + MessagePayload::Handshake { + parsed: HandshakeMessagePayload(HandshakePayload::CertificateRequestTls13(..)), + .. + } => Box::new(ExpectCertificateRequest { + config: self.config, + server_name: self.server_name, + randoms: self.randoms, + suite: self.suite, + transcript: self.transcript, + key_schedule: self.key_schedule, + offered_cert_compression: true, + ech_retry_configs: self.ech_retry_configs, + }) + .handle(cx, m), + payload => Err(inappropriate_handshake_message( + &payload, + &[ContentType::Handshake], + &[ + HandshakeType::Certificate, + HandshakeType::CertificateRequest, + HandshakeType::CompressedCertificate, + ], + )), + } + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + self + } +} + +struct ExpectCertificateOrCompressedCertificate { + config: Arc, + server_name: ServerName<'static>, + randoms: ConnectionRandoms, + suite: &'static Tls13CipherSuite, + transcript: HandshakeHash, + key_schedule: KeyScheduleHandshake, + client_auth: Option, + ech_retry_configs: Option>, +} + +impl State for ExpectCertificateOrCompressedCertificate { + fn handle<'m>( + self: Box, + cx: &mut ClientContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + match m.payload { + MessagePayload::Handshake { + parsed: HandshakeMessagePayload(HandshakePayload::CertificateTls13(..)), + .. + } => Box::new(ExpectCertificate { + config: self.config, + server_name: self.server_name, + randoms: self.randoms, + suite: self.suite, + transcript: self.transcript, + key_schedule: self.key_schedule, + client_auth: self.client_auth, + message_already_in_transcript: false, + ech_retry_configs: self.ech_retry_configs, + }) + .handle(cx, m), + MessagePayload::Handshake { + parsed: HandshakeMessagePayload(HandshakePayload::CompressedCertificate(..)), + .. + } => Box::new(ExpectCompressedCertificate { + config: self.config, + server_name: self.server_name, + randoms: self.randoms, + suite: self.suite, + transcript: self.transcript, + key_schedule: self.key_schedule, + client_auth: self.client_auth, + ech_retry_configs: self.ech_retry_configs, + }) + .handle(cx, m), + payload => Err(inappropriate_handshake_message( + &payload, + &[ContentType::Handshake], + &[ + HandshakeType::Certificate, + HandshakeType::CompressedCertificate, + ], + )), + } + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + self + } +} + +struct ExpectCertificateOrCertReq { + config: Arc, + server_name: ServerName<'static>, + randoms: ConnectionRandoms, + suite: &'static Tls13CipherSuite, + transcript: HandshakeHash, + key_schedule: KeyScheduleHandshake, + ech_retry_configs: Option>, +} + +impl State for ExpectCertificateOrCertReq { + fn handle<'m>( + self: Box, + cx: &mut ClientContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + match m.payload { + MessagePayload::Handshake { + parsed: HandshakeMessagePayload(HandshakePayload::CertificateTls13(..)), + .. + } => Box::new(ExpectCertificate { + config: self.config, + server_name: self.server_name, + randoms: self.randoms, + suite: self.suite, + transcript: self.transcript, + key_schedule: self.key_schedule, + client_auth: None, + message_already_in_transcript: false, + ech_retry_configs: self.ech_retry_configs, + }) + .handle(cx, m), + MessagePayload::Handshake { + parsed: HandshakeMessagePayload(HandshakePayload::CertificateRequestTls13(..)), + .. + } => Box::new(ExpectCertificateRequest { + config: self.config, + server_name: self.server_name, + randoms: self.randoms, + suite: self.suite, + transcript: self.transcript, + key_schedule: self.key_schedule, + offered_cert_compression: false, + ech_retry_configs: self.ech_retry_configs, + }) + .handle(cx, m), + payload => Err(inappropriate_handshake_message( + &payload, + &[ContentType::Handshake], + &[ + HandshakeType::Certificate, + HandshakeType::CertificateRequest, + ], + )), + } + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + self + } +} + +// TLS1.3 version of CertificateRequest handling. We then move to expecting the server +// Certificate. Unfortunately the CertificateRequest type changed in an annoying way +// in TLS1.3. +struct ExpectCertificateRequest { + config: Arc, + server_name: ServerName<'static>, + randoms: ConnectionRandoms, + suite: &'static Tls13CipherSuite, + transcript: HandshakeHash, + key_schedule: KeyScheduleHandshake, + offered_cert_compression: bool, + ech_retry_configs: Option>, +} + +impl State for ExpectCertificateRequest { + fn handle<'m>( + mut self: Box, + cx: &mut ClientContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + let certreq = &require_handshake_msg!( + m, + HandshakeType::CertificateRequest, + HandshakePayload::CertificateRequestTls13 + )?; + self.transcript.add_message(&m); + debug!("Got CertificateRequest {certreq:?}"); + + // Fortunately the problems here in TLS1.2 and prior are corrected in + // TLS1.3. + + // Must be empty during handshake. + if !certreq.context.0.is_empty() { + warn!("Server sent non-empty certreq context"); + return Err(cx.common.send_fatal_alert( + AlertDescription::DecodeError, + InvalidMessage::InvalidCertRequest, + )); + } + + let compat_sigschemes = certreq + .extensions + .signature_algorithms + .as_deref() + .unwrap_or_default() + .iter() + .cloned() + .filter(SignatureScheme::supported_in_tls13) + .collect::>(); + + if compat_sigschemes.is_empty() { + return Err(cx.common.send_fatal_alert( + AlertDescription::HandshakeFailure, + PeerIncompatible::NoCertificateRequestSignatureSchemesInCommon, + )); + } + + let compat_compressor = certreq + .extensions + .certificate_compression_algorithms + .as_deref() + .and_then(|offered| { + self.config + .cert_compressors + .iter() + .find(|compressor| offered.contains(&compressor.algorithm())) + }) + .cloned(); + + let client_auth = ClientAuthDetails::resolve( + self.config + .client_auth_cert_resolver + .as_ref(), + certreq + .extensions + .authority_names + .as_deref(), + &compat_sigschemes, + Some(certreq.context.0.clone()), + compat_compressor, + ); + + Ok(if self.offered_cert_compression { + Box::new(ExpectCertificateOrCompressedCertificate { + config: self.config, + server_name: self.server_name, + randoms: self.randoms, + suite: self.suite, + transcript: self.transcript, + key_schedule: self.key_schedule, + client_auth: Some(client_auth), + ech_retry_configs: self.ech_retry_configs, + }) + } else { + Box::new(ExpectCertificate { + config: self.config, + server_name: self.server_name, + randoms: self.randoms, + suite: self.suite, + transcript: self.transcript, + key_schedule: self.key_schedule, + client_auth: Some(client_auth), + message_already_in_transcript: false, + ech_retry_configs: self.ech_retry_configs, + }) + }) + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + self + } +} + +struct ExpectCompressedCertificate { + config: Arc, + server_name: ServerName<'static>, + randoms: ConnectionRandoms, + suite: &'static Tls13CipherSuite, + transcript: HandshakeHash, + key_schedule: KeyScheduleHandshake, + client_auth: Option, + ech_retry_configs: Option>, +} + +impl State for ExpectCompressedCertificate { + fn handle<'m>( + mut self: Box, + cx: &mut ClientContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + self.transcript.add_message(&m); + let compressed_cert = require_handshake_msg_move!( + m, + HandshakeType::CompressedCertificate, + HandshakePayload::CompressedCertificate + )?; + + let selected_decompressor = self + .config + .cert_decompressors + .iter() + .find(|item| item.algorithm() == compressed_cert.alg); + + let Some(decompressor) = selected_decompressor else { + return Err(cx.common.send_fatal_alert( + AlertDescription::BadCertificate, + PeerMisbehaved::SelectedUnofferedCertCompression, + )); + }; + + if compressed_cert.uncompressed_len as usize > CERTIFICATE_MAX_SIZE_LIMIT { + return Err(cx.common.send_fatal_alert( + AlertDescription::BadCertificate, + InvalidMessage::MessageTooLarge, + )); + } + + let mut decompress_buffer = vec![0u8; compressed_cert.uncompressed_len as usize]; + if let Err(compress::DecompressionFailed) = + decompressor.decompress(compressed_cert.compressed.0.bytes(), &mut decompress_buffer) + { + return Err(cx.common.send_fatal_alert( + AlertDescription::BadCertificate, + PeerMisbehaved::InvalidCertCompression, + )); + } + + let cert_payload = + match CertificatePayloadTls13::read(&mut Reader::init(&decompress_buffer)) { + Ok(cm) => cm, + Err(err) => { + return Err(cx + .common + .send_fatal_alert(AlertDescription::BadCertificate, err)); + } + }; + trace!( + "Server certificate decompressed using {:?} ({} bytes -> {})", + compressed_cert.alg, + compressed_cert + .compressed + .0 + .bytes() + .len(), + compressed_cert.uncompressed_len, + ); + + let m = Message { + version: ProtocolVersion::TLSv1_3, + payload: MessagePayload::handshake(HandshakeMessagePayload( + HandshakePayload::CertificateTls13(cert_payload.into_owned()), + )), + }; + + Box::new(ExpectCertificate { + config: self.config, + server_name: self.server_name, + randoms: self.randoms, + suite: self.suite, + transcript: self.transcript, + key_schedule: self.key_schedule, + client_auth: self.client_auth, + message_already_in_transcript: true, + ech_retry_configs: self.ech_retry_configs, + }) + .handle(cx, m) + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + self + } +} + +struct ExpectCertificate { + config: Arc, + server_name: ServerName<'static>, + randoms: ConnectionRandoms, + suite: &'static Tls13CipherSuite, + transcript: HandshakeHash, + key_schedule: KeyScheduleHandshake, + client_auth: Option, + message_already_in_transcript: bool, + ech_retry_configs: Option>, +} + +impl State for ExpectCertificate { + fn handle<'m>( + mut self: Box, + cx: &mut ClientContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + if !self.message_already_in_transcript { + self.transcript.add_message(&m); + } + let cert_chain = require_handshake_msg_move!( + m, + HandshakeType::Certificate, + HandshakePayload::CertificateTls13 + )?; + + // This is only non-empty for client auth. + if !cert_chain.context.0.is_empty() { + return Err(cx.common.send_fatal_alert( + AlertDescription::DecodeError, + InvalidMessage::InvalidCertRequest, + )); + } + + let end_entity_ocsp = cert_chain.end_entity_ocsp().to_vec(); + let server_cert = ServerCertDetails::new( + cert_chain + .into_certificate_chain() + .into_owned(), + end_entity_ocsp, + ); + + Ok(Box::new(ExpectCertificateVerify { + config: self.config, + server_name: self.server_name, + randoms: self.randoms, + suite: self.suite, + transcript: self.transcript, + key_schedule: self.key_schedule, + server_cert, + client_auth: self.client_auth, + ech_retry_configs: self.ech_retry_configs, + })) + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + self + } +} + +// --- TLS1.3 CertificateVerify --- +struct ExpectCertificateVerify<'a> { + config: Arc, + server_name: ServerName<'static>, + randoms: ConnectionRandoms, + suite: &'static Tls13CipherSuite, + transcript: HandshakeHash, + key_schedule: KeyScheduleHandshake, + server_cert: ServerCertDetails<'a>, + client_auth: Option, + ech_retry_configs: Option>, +} + +impl State for ExpectCertificateVerify<'_> { + fn handle<'m>( + mut self: Box, + cx: &mut ClientContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + let cert_verify = require_handshake_msg!( + m, + HandshakeType::CertificateVerify, + HandshakePayload::CertificateVerify + )?; + + trace!("Server cert is {:?}", self.server_cert.cert_chain); + + // 1. Verify the certificate chain. + let (end_entity, intermediates) = self + .server_cert + .cert_chain + .split_first() + .ok_or(Error::NoCertificatesPresented)?; + + let now = self.config.current_time()?; + + let cert_verified = self + .config + .verifier + .verify_server_cert( + end_entity, + intermediates, + &self.server_name, + &self.server_cert.ocsp_response, + now, + ) + .map_err(|err| { + cx.common + .send_cert_verify_error_alert(err) + })?; + + // 2. Verify their signature on the handshake. + let handshake_hash = self.transcript.current_hash(); + let sig_verified = self + .config + .verifier + .verify_tls13_signature( + construct_server_verify_message(&handshake_hash).as_ref(), + end_entity, + cert_verify, + ) + .map_err(|err| { + cx.common + .send_cert_verify_error_alert(err) + })?; + + cx.common.peer_certificates = Some(self.server_cert.cert_chain.into_owned()); + self.transcript.add_message(&m); + + Ok(Box::new(ExpectFinished { + config: self.config, + server_name: self.server_name, + randoms: self.randoms, + suite: self.suite, + transcript: self.transcript, + key_schedule: self.key_schedule, + client_auth: self.client_auth, + cert_verified, + sig_verified, + ech_retry_configs: self.ech_retry_configs, + })) + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + Box::new(ExpectCertificateVerify { + config: self.config, + server_name: self.server_name, + randoms: self.randoms, + suite: self.suite, + transcript: self.transcript, + key_schedule: self.key_schedule, + server_cert: self.server_cert.into_owned(), + client_auth: self.client_auth, + ech_retry_configs: self.ech_retry_configs, + }) + } +} + +fn emit_compressed_certificate_tls13( + flight: &mut HandshakeFlightTls13<'_>, + certkey: &CertifiedKey, + auth_context: Option>, + compressor: &dyn compress::CertCompressor, + config: &ClientConfig, +) { + let mut cert_payload = CertificatePayloadTls13::new(certkey.cert.iter(), None); + cert_payload.context = PayloadU8::new(auth_context.clone().unwrap_or_default()); + + let Ok(compressed) = config + .cert_compression_cache + .compression_for(compressor, &cert_payload) + else { + return emit_certificate_tls13(flight, Some(certkey), auth_context); + }; + + flight.add(HandshakeMessagePayload( + HandshakePayload::CompressedCertificate(compressed.compressed_cert_payload()), + )); +} + +fn emit_certificate_tls13( + flight: &mut HandshakeFlightTls13<'_>, + certkey: Option<&CertifiedKey>, + auth_context: Option>, +) { + let certs = certkey + .map(|ck| ck.cert.as_ref()) + .unwrap_or(&[][..]); + let mut cert_payload = CertificatePayloadTls13::new(certs.iter(), None); + cert_payload.context = PayloadU8::new(auth_context.unwrap_or_default()); + + flight.add(HandshakeMessagePayload(HandshakePayload::CertificateTls13( + cert_payload, + ))); +} + +fn emit_certverify_tls13( + flight: &mut HandshakeFlightTls13<'_>, + signer: &dyn Signer, +) -> Result<(), Error> { + let message = construct_client_verify_message(&flight.transcript.current_hash()); + + let scheme = signer.scheme(); + let sig = signer.sign(message.as_ref())?; + let dss = DigitallySignedStruct::new(scheme, sig); + + flight.add(HandshakeMessagePayload( + HandshakePayload::CertificateVerify(dss), + )); + Ok(()) +} + +fn emit_finished_tls13(flight: &mut HandshakeFlightTls13<'_>, verify_data: &crypto::hmac::Tag) { + let verify_data_payload = Payload::new(verify_data.as_ref()); + + flight.add(HandshakeMessagePayload(HandshakePayload::Finished( + verify_data_payload, + ))); +} + +fn emit_end_of_early_data_tls13(transcript: &mut HandshakeHash, common: &mut CommonState) { + if common.is_quic() { + return; + } + + let m = Message { + version: ProtocolVersion::TLSv1_3, + payload: MessagePayload::handshake(HandshakeMessagePayload( + HandshakePayload::EndOfEarlyData, + )), + }; + + transcript.add_message(&m); + common.send_msg(m, true); +} + +struct ExpectFinished { + config: Arc, + server_name: ServerName<'static>, + randoms: ConnectionRandoms, + suite: &'static Tls13CipherSuite, + transcript: HandshakeHash, + key_schedule: KeyScheduleHandshake, + client_auth: Option, + cert_verified: verify::ServerCertVerified, + sig_verified: verify::HandshakeSignatureValid, + ech_retry_configs: Option>, +} + +impl State for ExpectFinished { + fn handle<'m>( + self: Box, + cx: &mut ClientContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + let mut st = *self; + let finished = + require_handshake_msg!(m, HandshakeType::Finished, HandshakePayload::Finished)?; + + let handshake_hash = st.transcript.current_hash(); + let expect_verify_data = st + .key_schedule + .sign_server_finish(&handshake_hash); + + let fin = match ConstantTimeEq::ct_eq(expect_verify_data.as_ref(), finished.bytes()).into() + { + true => verify::FinishedMessageVerified::assertion(), + false => { + return Err(cx + .common + .send_fatal_alert(AlertDescription::DecryptError, Error::DecryptError)); + } + }; + + st.transcript.add_message(&m); + + let hash_after_handshake = st.transcript.current_hash(); + /* The EndOfEarlyData message to server is still encrypted with early data keys, + * but appears in the transcript after the server Finished. */ + if cx.common.early_traffic { + emit_end_of_early_data_tls13(&mut st.transcript, cx.common); + cx.common.early_traffic = false; + cx.data.early_data.finished(); + st.key_schedule + .set_handshake_encrypter(cx.common); + } + + let mut flight = HandshakeFlightTls13::new(&mut st.transcript); + + /* Send our authentication/finished messages. These are still encrypted + * with our handshake keys. */ + if let Some(client_auth) = st.client_auth { + match client_auth { + ClientAuthDetails::Empty { + auth_context_tls13: auth_context, + } => { + emit_certificate_tls13(&mut flight, None, auth_context); + } + ClientAuthDetails::Verify { + auth_context_tls13: auth_context, + .. + } if cx.data.ech_status == EchStatus::Rejected => { + // If ECH was offered, and rejected, we MUST respond with + // an empty certificate message. + emit_certificate_tls13(&mut flight, None, auth_context); + } + ClientAuthDetails::Verify { + certkey, + signer, + auth_context_tls13: auth_context, + compressor, + } => { + if let Some(compressor) = compressor { + emit_compressed_certificate_tls13( + &mut flight, + &certkey, + auth_context, + compressor, + &st.config, + ); + } else { + emit_certificate_tls13(&mut flight, Some(&certkey), auth_context); + } + emit_certverify_tls13(&mut flight, signer.as_ref())?; + } + } + } + + let (key_schedule_pre_finished, verify_data) = st + .key_schedule + .into_pre_finished_client_traffic( + hash_after_handshake, + flight.transcript.current_hash(), + &*st.config.key_log, + &st.randoms.client, + ); + + emit_finished_tls13(&mut flight, &verify_data); + flight.finish(cx.common); + + /* We're now sure this server supports TLS1.3. But if we run out of TLS1.3 tickets + * when connecting to it again, we definitely don't want to attempt a TLS1.2 resumption. */ + st.config + .resumption + .store + .remove_tls12_session(&st.server_name); + + /* Now move to our application traffic keys. */ + cx.common.check_aligned_handshake()?; + let (key_schedule, resumption) = + key_schedule_pre_finished.into_traffic(cx.common, st.transcript.current_hash()); + cx.common + .start_traffic(&mut cx.sendable_plaintext); + + // Now that we've reached the end of the normal handshake we must enforce ECH acceptance by + // sending an alert and returning an error (potentially with retry configs) if the server + // did not accept our ECH offer. + if cx.data.ech_status == EchStatus::Rejected { + return Err(ech::fatal_alert_required(st.ech_retry_configs, cx.common)); + } + + let st = ExpectTraffic { + config: st.config.clone(), + session_storage: st.config.resumption.store.clone(), + server_name: st.server_name, + suite: st.suite, + key_schedule, + resumption, + _cert_verified: st.cert_verified, + _sig_verified: st.sig_verified, + _fin_verified: fin, + }; + + Ok(match cx.common.is_quic() { + true => Box::new(ExpectQuicTraffic(st)), + false => Box::new(st), + }) + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + self + } +} + +// -- Traffic transit state (TLS1.3) -- +// In this state we can be sent tickets, key updates, +// and application data. +struct ExpectTraffic { + config: Arc, + session_storage: Arc, + server_name: ServerName<'static>, + suite: &'static Tls13CipherSuite, + key_schedule: KeyScheduleTraffic, + resumption: KeyScheduleResumption, + _cert_verified: verify::ServerCertVerified, + _sig_verified: verify::HandshakeSignatureValid, + _fin_verified: verify::FinishedMessageVerified, +} + +impl ExpectTraffic { + fn handle_new_ticket_impl( + &mut self, + cx: &mut KernelContext<'_>, + nst: &NewSessionTicketPayloadTls13, + ) -> Result<(), Error> { + let secret = self + .resumption + .derive_ticket_psk(&nst.nonce.0); + + let now = self.config.current_time()?; + + #[allow(unused_mut)] + let mut value = persist::Tls13ClientSessionValue::new( + self.suite, + nst.ticket.clone(), + secret.as_ref(), + cx.peer_certificates + .cloned() + .unwrap_or_default(), + &self.config.verifier, + &self.config.client_auth_cert_resolver, + now, + nst.lifetime, + nst.age_add, + nst.extensions + .max_early_data_size + .unwrap_or_default(), + ); + + if cx.is_quic() { + if let Some(sz) = nst.extensions.max_early_data_size { + if sz != 0 && sz != 0xffff_ffff { + return Err(PeerMisbehaved::InvalidMaxEarlyDataSize.into()); + } + } + + if let Some(quic_params) = &cx.quic.params { + value.set_quic_params(quic_params); + } + } + + self.session_storage + .insert_tls13_ticket(self.server_name.clone(), value); + Ok(()) + } + + fn handle_new_ticket_tls13( + &mut self, + cx: &mut ClientContext<'_>, + nst: &NewSessionTicketPayloadTls13, + ) -> Result<(), Error> { + let mut kcx = KernelContext { + peer_certificates: cx.common.peer_certificates.as_ref(), + protocol: cx.common.protocol, + quic: &cx.common.quic, + }; + cx.common.tls13_tickets_received = cx + .common + .tls13_tickets_received + .saturating_add(1); + self.handle_new_ticket_impl(&mut kcx, nst) + } + + fn handle_key_update( + &mut self, + common: &mut CommonState, + key_update_request: &KeyUpdateRequest, + ) -> Result<(), Error> { + if let Protocol::Quic = common.protocol { + return Err(common.send_fatal_alert( + AlertDescription::UnexpectedMessage, + PeerMisbehaved::KeyUpdateReceivedInQuicConnection, + )); + } + + // Mustn't be interleaved with other handshake messages. + common.check_aligned_handshake()?; + + if common.should_update_key(key_update_request)? { + self.key_schedule + .update_encrypter_and_notify(common); + } + + // Update our read-side keys. + self.key_schedule + .update_decrypter(common); + Ok(()) + } +} + +impl State for ExpectTraffic { + fn handle<'m>( + mut self: Box, + cx: &mut ClientContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + match m.payload { + MessagePayload::ApplicationData(payload) => cx + .common + .take_received_plaintext(payload), + MessagePayload::Handshake { + parsed: HandshakeMessagePayload(HandshakePayload::NewSessionTicketTls13(new_ticket)), + .. + } => self.handle_new_ticket_tls13(cx, &new_ticket)?, + MessagePayload::Handshake { + parsed: HandshakeMessagePayload(HandshakePayload::KeyUpdate(key_update)), + .. + } => self.handle_key_update(cx.common, &key_update)?, + payload => { + return Err(inappropriate_handshake_message( + &payload, + &[ContentType::ApplicationData, ContentType::Handshake], + &[HandshakeType::NewSessionTicket, HandshakeType::KeyUpdate], + )); + } + } + + Ok(self) + } + + fn send_key_update_request(&mut self, common: &mut CommonState) -> Result<(), Error> { + self.key_schedule + .request_key_update_and_update_encrypter(common) + } + + fn export_keying_material( + &self, + output: &mut [u8], + label: &[u8], + context: Option<&[u8]>, + ) -> Result<(), Error> { + self.key_schedule + .export_keying_material(output, label, context) + } + + fn extract_secrets(&self) -> Result { + self.key_schedule + .extract_secrets(Side::Client) + } + + fn into_external_state(self: Box) -> Result, Error> { + Ok(self) + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + self + } +} + +impl KernelState for ExpectTraffic { + fn update_secrets(&mut self, dir: Direction) -> Result { + self.key_schedule + .refresh_traffic_secret(match dir { + Direction::Transmit => Side::Client, + Direction::Receive => Side::Server, + }) + } + + fn handle_new_session_ticket( + &mut self, + cx: &mut KernelContext<'_>, + message: &NewSessionTicketPayloadTls13, + ) -> Result<(), Error> { + self.handle_new_ticket_impl(cx, message) + } +} + +struct ExpectQuicTraffic(ExpectTraffic); + +impl State for ExpectQuicTraffic { + fn handle<'m>( + mut self: Box, + cx: &mut ClientContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + let nst = require_handshake_msg!( + m, + HandshakeType::NewSessionTicket, + HandshakePayload::NewSessionTicketTls13 + )?; + self.0 + .handle_new_ticket_tls13(cx, nst)?; + Ok(self) + } + + fn export_keying_material( + &self, + output: &mut [u8], + label: &[u8], + context: Option<&[u8]>, + ) -> Result<(), Error> { + self.0 + .export_keying_material(output, label, context) + } + + fn into_external_state(self: Box) -> Result, Error> { + Ok(self) + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + self + } +} + +impl KernelState for ExpectQuicTraffic { + fn update_secrets(&mut self, _: Direction) -> Result { + Err(Error::General( + "KeyUpdate is not supported for QUIC connections".into(), + )) + } + + fn handle_new_session_ticket( + &mut self, + cx: &mut KernelContext<'_>, + nst: &NewSessionTicketPayloadTls13, + ) -> Result<(), Error> { + self.0.handle_new_ticket_impl(cx, nst) + } +} diff --git a/http/vendor/rustls/src/common_state.rs b/http/vendor/rustls/src/common_state.rs new file mode 100644 index 0000000..77ba0bb --- /dev/null +++ b/http/vendor/rustls/src/common_state.rs @@ -0,0 +1,1056 @@ +use alloc::boxed::Box; +use alloc::vec::Vec; + +use pki_types::CertificateDer; + +use crate::conn::kernel::KernelState; +use crate::crypto::SupportedKxGroup; +use crate::enums::{AlertDescription, ContentType, HandshakeType, ProtocolVersion}; +use crate::error::{Error, InvalidMessage, PeerMisbehaved}; +use crate::hash_hs::HandshakeHash; +use crate::log::{debug, error, warn}; +use crate::msgs::alert::AlertMessagePayload; +use crate::msgs::base::Payload; +use crate::msgs::codec::Codec; +use crate::msgs::enums::{AlertLevel, KeyUpdateRequest}; +use crate::msgs::fragmenter::MessageFragmenter; +use crate::msgs::handshake::{CertificateChain, HandshakeMessagePayload, ProtocolName}; +use crate::msgs::message::{ + Message, MessagePayload, OutboundChunks, OutboundOpaqueMessage, OutboundPlainMessage, + PlainMessage, +}; +use crate::record_layer::PreEncryptAction; +use crate::suites::{PartiallyExtractedSecrets, SupportedCipherSuite}; +#[cfg(feature = "tls12")] +use crate::tls12::ConnectionSecrets; +use crate::unbuffered::{EncryptError, InsufficientSizeError}; +use crate::vecbuf::ChunkVecBuffer; +use crate::{quic, record_layer}; + +/// Connection state common to both client and server connections. +pub struct CommonState { + pub(crate) negotiated_version: Option, + pub(crate) handshake_kind: Option, + pub(crate) side: Side, + pub(crate) record_layer: record_layer::RecordLayer, + pub(crate) suite: Option, + pub(crate) kx_state: KxState, + pub(crate) alpn_protocol: Option, + pub(crate) aligned_handshake: bool, + pub(crate) may_send_application_data: bool, + pub(crate) may_receive_application_data: bool, + pub(crate) early_traffic: bool, + sent_fatal_alert: bool, + /// If we signaled end of stream. + pub(crate) has_sent_close_notify: bool, + /// If the peer has signaled end of stream. + pub(crate) has_received_close_notify: bool, + #[cfg(feature = "std")] + pub(crate) has_seen_eof: bool, + pub(crate) peer_certificates: Option>, + message_fragmenter: MessageFragmenter, + pub(crate) received_plaintext: ChunkVecBuffer, + pub(crate) sendable_tls: ChunkVecBuffer, + queued_key_update_message: Option>, + + /// Protocol whose key schedule should be used. Unused for TLS < 1.3. + pub(crate) protocol: Protocol, + pub(crate) quic: quic::Quic, + pub(crate) enable_secret_extraction: bool, + temper_counters: TemperCounters, + pub(crate) refresh_traffic_keys_pending: bool, + pub(crate) fips: bool, + pub(crate) tls13_tickets_received: u32, +} + +impl CommonState { + pub(crate) fn new(side: Side) -> Self { + Self { + negotiated_version: None, + handshake_kind: None, + side, + record_layer: record_layer::RecordLayer::new(), + suite: None, + kx_state: KxState::default(), + alpn_protocol: None, + aligned_handshake: true, + may_send_application_data: false, + may_receive_application_data: false, + early_traffic: false, + sent_fatal_alert: false, + has_sent_close_notify: false, + has_received_close_notify: false, + #[cfg(feature = "std")] + has_seen_eof: false, + peer_certificates: None, + message_fragmenter: MessageFragmenter::default(), + received_plaintext: ChunkVecBuffer::new(Some(DEFAULT_RECEIVED_PLAINTEXT_LIMIT)), + sendable_tls: ChunkVecBuffer::new(Some(DEFAULT_BUFFER_LIMIT)), + queued_key_update_message: None, + protocol: Protocol::Tcp, + quic: quic::Quic::default(), + enable_secret_extraction: false, + temper_counters: TemperCounters::default(), + refresh_traffic_keys_pending: false, + fips: false, + tls13_tickets_received: 0, + } + } + + /// Returns true if the caller should call [`Connection::write_tls`] as soon as possible. + /// + /// [`Connection::write_tls`]: crate::Connection::write_tls + pub fn wants_write(&self) -> bool { + !self.sendable_tls.is_empty() + } + + /// Returns true if the connection is currently performing the TLS handshake. + /// + /// During this time plaintext written to the connection is buffered in memory. After + /// [`Connection::process_new_packets()`] has been called, this might start to return `false` + /// while the final handshake packets still need to be extracted from the connection's buffers. + /// + /// [`Connection::process_new_packets()`]: crate::Connection::process_new_packets + pub fn is_handshaking(&self) -> bool { + !(self.may_send_application_data && self.may_receive_application_data) + } + + /// Retrieves the certificate chain or the raw public key used by the peer to authenticate. + /// + /// The order of the certificate chain is as it appears in the TLS + /// protocol: the first certificate relates to the peer, the + /// second certifies the first, the third certifies the second, and + /// so on. + /// + /// When using raw public keys, the first and only element is the raw public key. + /// + /// This is made available for both full and resumed handshakes. + /// + /// For clients, this is the certificate chain or the raw public key of the server. + /// + /// For servers, this is the certificate chain or the raw public key of the client, + /// if client authentication was completed. + /// + /// The return value is None until this value is available. + /// + /// Note: the return type of the 'certificate', when using raw public keys is `CertificateDer<'static>` + /// even though this should technically be a `SubjectPublicKeyInfoDer<'static>`. + /// This choice simplifies the API and ensures backwards compatibility. + pub fn peer_certificates(&self) -> Option<&[CertificateDer<'static>]> { + self.peer_certificates.as_deref() + } + + /// Retrieves the protocol agreed with the peer via ALPN. + /// + /// A return value of `None` after handshake completion + /// means no protocol was agreed (because no protocols + /// were offered or accepted by the peer). + pub fn alpn_protocol(&self) -> Option<&[u8]> { + self.get_alpn_protocol() + } + + /// Retrieves the ciphersuite agreed with the peer. + /// + /// This returns None until the ciphersuite is agreed. + pub fn negotiated_cipher_suite(&self) -> Option { + self.suite + } + + /// Retrieves the key exchange group agreed with the peer. + /// + /// This function may return `None` depending on the state of the connection, + /// the type of handshake, and the protocol version. + /// + /// If [`CommonState::is_handshaking()`] is true this function will return `None`. + /// Similarly, if the [`CommonState::handshake_kind()`] is [`HandshakeKind::Resumed`] + /// and the [`CommonState::protocol_version()`] is TLS 1.2, then no key exchange will have + /// occurred and this function will return `None`. + pub fn negotiated_key_exchange_group(&self) -> Option<&'static dyn SupportedKxGroup> { + match self.kx_state { + KxState::Complete(group) => Some(group), + _ => None, + } + } + + /// Retrieves the protocol version agreed with the peer. + /// + /// This returns `None` until the version is agreed. + pub fn protocol_version(&self) -> Option { + self.negotiated_version + } + + /// Which kind of handshake was performed. + /// + /// This tells you whether the handshake was a resumption or not. + /// + /// This will return `None` before it is known which sort of + /// handshake occurred. + pub fn handshake_kind(&self) -> Option { + self.handshake_kind + } + + pub(crate) fn is_tls13(&self) -> bool { + matches!(self.negotiated_version, Some(ProtocolVersion::TLSv1_3)) + } + + pub(crate) fn process_main_protocol( + &mut self, + msg: Message<'_>, + mut state: Box>, + data: &mut Data, + sendable_plaintext: Option<&mut ChunkVecBuffer>, + ) -> Result>, Error> { + // For TLS1.2, outside of the handshake, send rejection alerts for + // renegotiation requests. These can occur any time. + if self.may_receive_application_data && !self.is_tls13() { + let reject_ty = match self.side { + Side::Client => HandshakeType::HelloRequest, + Side::Server => HandshakeType::ClientHello, + }; + if msg.is_handshake_type(reject_ty) { + self.temper_counters + .received_renegotiation_request()?; + self.send_warning_alert(AlertDescription::NoRenegotiation); + return Ok(state); + } + } + + let mut cx = Context { + common: self, + data, + sendable_plaintext, + }; + match state.handle(&mut cx, msg) { + Ok(next) => { + state = next.into_owned(); + Ok(state) + } + Err(e @ Error::InappropriateMessage { .. }) + | Err(e @ Error::InappropriateHandshakeMessage { .. }) => { + Err(self.send_fatal_alert(AlertDescription::UnexpectedMessage, e)) + } + Err(e) => Err(e), + } + } + + pub(crate) fn write_plaintext( + &mut self, + payload: OutboundChunks<'_>, + outgoing_tls: &mut [u8], + ) -> Result { + if payload.is_empty() { + return Ok(0); + } + + let fragments = self + .message_fragmenter + .fragment_payload( + ContentType::ApplicationData, + ProtocolVersion::TLSv1_2, + payload.clone(), + ); + + for f in 0..fragments.len() { + match self + .record_layer + .pre_encrypt_action(f as u64) + { + PreEncryptAction::Nothing => {} + PreEncryptAction::RefreshOrClose => match self.negotiated_version { + Some(ProtocolVersion::TLSv1_3) => { + // driven by caller, as we don't have the `State` here + self.refresh_traffic_keys_pending = true; + } + _ => { + error!( + "traffic keys exhausted, closing connection to prevent security failure" + ); + self.send_close_notify(); + return Err(EncryptError::EncryptExhausted); + } + }, + PreEncryptAction::Refuse => { + return Err(EncryptError::EncryptExhausted); + } + } + } + + self.perhaps_write_key_update(); + + self.check_required_size(outgoing_tls, fragments)?; + + let fragments = self + .message_fragmenter + .fragment_payload( + ContentType::ApplicationData, + ProtocolVersion::TLSv1_2, + payload, + ); + + Ok(self.write_fragments(outgoing_tls, fragments)) + } + + // Changing the keys must not span any fragmented handshake + // messages. Otherwise the defragmented messages will have + // been protected with two different record layer protections, + // which is illegal. Not mentioned in RFC. + pub(crate) fn check_aligned_handshake(&mut self) -> Result<(), Error> { + if !self.aligned_handshake { + Err(self.send_fatal_alert( + AlertDescription::UnexpectedMessage, + PeerMisbehaved::KeyEpochWithPendingFragment, + )) + } else { + Ok(()) + } + } + + /// Fragment `m`, encrypt the fragments, and then queue + /// the encrypted fragments for sending. + pub(crate) fn send_msg_encrypt(&mut self, m: PlainMessage) { + let iter = self + .message_fragmenter + .fragment_message(&m); + for m in iter { + self.send_single_fragment(m); + } + } + + /// Like send_msg_encrypt, but operate on an appdata directly. + fn send_appdata_encrypt(&mut self, payload: OutboundChunks<'_>, limit: Limit) -> usize { + // Here, the limit on sendable_tls applies to encrypted data, + // but we're respecting it for plaintext data -- so we'll + // be out by whatever the cipher+record overhead is. That's a + // constant and predictable amount, so it's not a terrible issue. + let len = match limit { + #[cfg(feature = "std")] + Limit::Yes => self + .sendable_tls + .apply_limit(payload.len()), + Limit::No => payload.len(), + }; + + let iter = self + .message_fragmenter + .fragment_payload( + ContentType::ApplicationData, + ProtocolVersion::TLSv1_2, + payload.split_at(len).0, + ); + for m in iter { + self.send_single_fragment(m); + } + + len + } + + fn send_single_fragment(&mut self, m: OutboundPlainMessage<'_>) { + if m.typ == ContentType::Alert { + // Alerts are always sendable -- never quashed by a PreEncryptAction. + let em = self.record_layer.encrypt_outgoing(m); + self.queue_tls_message(em); + return; + } + + match self + .record_layer + .next_pre_encrypt_action() + { + PreEncryptAction::Nothing => {} + + // Close connection once we start to run out of + // sequence space. + PreEncryptAction::RefreshOrClose => { + match self.negotiated_version { + Some(ProtocolVersion::TLSv1_3) => { + // driven by caller, as we don't have the `State` here + self.refresh_traffic_keys_pending = true; + } + _ => { + error!( + "traffic keys exhausted, closing connection to prevent security failure" + ); + self.send_close_notify(); + return; + } + } + } + + // Refuse to wrap counter at all costs. This + // is basically untestable unfortunately. + PreEncryptAction::Refuse => { + return; + } + }; + + let em = self.record_layer.encrypt_outgoing(m); + self.queue_tls_message(em); + } + + fn send_plain_non_buffering(&mut self, payload: OutboundChunks<'_>, limit: Limit) -> usize { + debug_assert!(self.may_send_application_data); + debug_assert!(self.record_layer.is_encrypting()); + + if payload.is_empty() { + // Don't send empty fragments. + return 0; + } + + self.send_appdata_encrypt(payload, limit) + } + + /// Mark the connection as ready to send application data. + /// + /// Also flush `sendable_plaintext` if it is `Some`. + pub(crate) fn start_outgoing_traffic( + &mut self, + sendable_plaintext: &mut Option<&mut ChunkVecBuffer>, + ) { + self.may_send_application_data = true; + if let Some(sendable_plaintext) = sendable_plaintext { + self.flush_plaintext(sendable_plaintext); + } + } + + /// Mark the connection as ready to send and receive application data. + /// + /// Also flush `sendable_plaintext` if it is `Some`. + pub(crate) fn start_traffic(&mut self, sendable_plaintext: &mut Option<&mut ChunkVecBuffer>) { + self.may_receive_application_data = true; + self.start_outgoing_traffic(sendable_plaintext); + } + + /// Send any buffered plaintext. Plaintext is buffered if + /// written during handshake. + fn flush_plaintext(&mut self, sendable_plaintext: &mut ChunkVecBuffer) { + if !self.may_send_application_data { + return; + } + + while let Some(buf) = sendable_plaintext.pop() { + self.send_plain_non_buffering(buf.as_slice().into(), Limit::No); + } + } + + // Put m into sendable_tls for writing. + fn queue_tls_message(&mut self, m: OutboundOpaqueMessage) { + self.perhaps_write_key_update(); + self.sendable_tls.append(m.encode()); + } + + pub(crate) fn perhaps_write_key_update(&mut self) { + if let Some(message) = self.queued_key_update_message.take() { + self.sendable_tls.append(message); + } + } + + /// Send a raw TLS message, fragmenting it if needed. + pub(crate) fn send_msg(&mut self, m: Message<'_>, must_encrypt: bool) { + { + if let Protocol::Quic = self.protocol { + if let MessagePayload::Alert(alert) = m.payload { + self.quic.alert = Some(alert.description); + } else { + debug_assert!( + matches!( + m.payload, + MessagePayload::Handshake { .. } | MessagePayload::HandshakeFlight(_) + ), + "QUIC uses TLS for the cryptographic handshake only" + ); + let mut bytes = Vec::new(); + m.payload.encode(&mut bytes); + self.quic + .hs_queue + .push_back((must_encrypt, bytes)); + } + return; + } + } + if !must_encrypt { + let msg = &m.into(); + let iter = self + .message_fragmenter + .fragment_message(msg); + for m in iter { + self.queue_tls_message(m.to_unencrypted_opaque()); + } + } else { + self.send_msg_encrypt(m.into()); + } + } + + pub(crate) fn take_received_plaintext(&mut self, bytes: Payload<'_>) { + self.temper_counters.received_app_data(); + self.received_plaintext + .append(bytes.into_vec()); + } + + #[cfg(feature = "tls12")] + pub(crate) fn start_encryption_tls12(&mut self, secrets: &ConnectionSecrets, side: Side) { + let (dec, enc) = secrets.make_cipher_pair(side); + self.record_layer + .prepare_message_encrypter( + enc, + secrets + .suite() + .common + .confidentiality_limit, + ); + self.record_layer + .prepare_message_decrypter(dec); + } + + pub(crate) fn missing_extension(&mut self, why: PeerMisbehaved) -> Error { + self.send_fatal_alert(AlertDescription::MissingExtension, why) + } + + fn send_warning_alert(&mut self, desc: AlertDescription) { + warn!("Sending warning alert {desc:?}"); + self.send_warning_alert_no_log(desc); + } + + pub(crate) fn process_alert(&mut self, alert: &AlertMessagePayload) -> Result<(), Error> { + // Reject unknown AlertLevels. + if let AlertLevel::Unknown(_) = alert.level { + return Err(self.send_fatal_alert( + AlertDescription::IllegalParameter, + Error::AlertReceived(alert.description), + )); + } + + // If we get a CloseNotify, make a note to declare EOF to our + // caller. But do not treat unauthenticated alerts like this. + if self.may_receive_application_data && alert.description == AlertDescription::CloseNotify { + self.has_received_close_notify = true; + return Ok(()); + } + + // Warnings are nonfatal for TLS1.2, but outlawed in TLS1.3 + // (except, for no good reason, user_cancelled). + let err = Error::AlertReceived(alert.description); + if alert.level == AlertLevel::Warning { + self.temper_counters + .received_warning_alert()?; + if self.is_tls13() && alert.description != AlertDescription::UserCanceled { + return Err(self.send_fatal_alert(AlertDescription::DecodeError, err)); + } + + // Some implementations send pointless `user_canceled` alerts, don't log them + // in release mode (https://bugs.openjdk.org/browse/JDK-8323517). + if alert.description != AlertDescription::UserCanceled || cfg!(debug_assertions) { + warn!("TLS alert warning received: {alert:?}"); + } + + return Ok(()); + } + + Err(err) + } + + pub(crate) fn send_cert_verify_error_alert(&mut self, err: Error) -> Error { + self.send_fatal_alert( + match &err { + Error::InvalidCertificate(e) => e.clone().into(), + Error::PeerMisbehaved(_) => AlertDescription::IllegalParameter, + _ => AlertDescription::HandshakeFailure, + }, + err, + ) + } + + pub(crate) fn send_fatal_alert( + &mut self, + desc: AlertDescription, + err: impl Into, + ) -> Error { + debug_assert!(!self.sent_fatal_alert); + let m = Message::build_alert(AlertLevel::Fatal, desc); + self.send_msg(m, self.record_layer.is_encrypting()); + self.sent_fatal_alert = true; + err.into() + } + + /// Queues a `close_notify` warning alert to be sent in the next + /// [`Connection::write_tls`] call. This informs the peer that the + /// connection is being closed. + /// + /// Does nothing if any `close_notify` or fatal alert was already sent. + /// + /// [`Connection::write_tls`]: crate::Connection::write_tls + pub fn send_close_notify(&mut self) { + if self.sent_fatal_alert { + return; + } + debug!("Sending warning alert {:?}", AlertDescription::CloseNotify); + self.sent_fatal_alert = true; + self.has_sent_close_notify = true; + self.send_warning_alert_no_log(AlertDescription::CloseNotify); + } + + pub(crate) fn eager_send_close_notify( + &mut self, + outgoing_tls: &mut [u8], + ) -> Result { + self.send_close_notify(); + self.check_required_size(outgoing_tls, [].into_iter())?; + Ok(self.write_fragments(outgoing_tls, [].into_iter())) + } + + fn send_warning_alert_no_log(&mut self, desc: AlertDescription) { + let m = Message::build_alert(AlertLevel::Warning, desc); + self.send_msg(m, self.record_layer.is_encrypting()); + } + + fn check_required_size<'a>( + &self, + outgoing_tls: &mut [u8], + fragments: impl Iterator>, + ) -> Result<(), EncryptError> { + let mut required_size = self.sendable_tls.len(); + + for m in fragments { + required_size += m.encoded_len(&self.record_layer); + } + + if required_size > outgoing_tls.len() { + return Err(EncryptError::InsufficientSize(InsufficientSizeError { + required_size, + })); + } + + Ok(()) + } + + fn write_fragments<'a>( + &mut self, + outgoing_tls: &mut [u8], + fragments: impl Iterator>, + ) -> usize { + let mut written = 0; + + // Any pre-existing encrypted messages in `sendable_tls` must + // be output before encrypting any of the `fragments`. + while let Some(message) = self.sendable_tls.pop() { + let len = message.len(); + outgoing_tls[written..written + len].copy_from_slice(&message); + written += len; + } + + for m in fragments { + let em = self + .record_layer + .encrypt_outgoing(m) + .encode(); + + let len = em.len(); + outgoing_tls[written..written + len].copy_from_slice(&em); + written += len; + } + + written + } + + pub(crate) fn set_max_fragment_size(&mut self, new: Option) -> Result<(), Error> { + self.message_fragmenter + .set_max_fragment_size(new) + } + + pub(crate) fn get_alpn_protocol(&self) -> Option<&[u8]> { + self.alpn_protocol + .as_ref() + .map(AsRef::as_ref) + } + + /// Returns true if the caller should call [`Connection::read_tls`] as soon + /// as possible. + /// + /// If there is pending plaintext data to read with [`Connection::reader`], + /// this returns false. If your application respects this mechanism, + /// only one full TLS message will be buffered by rustls. + /// + /// [`Connection::reader`]: crate::Connection::reader + /// [`Connection::read_tls`]: crate::Connection::read_tls + pub fn wants_read(&self) -> bool { + // We want to read more data all the time, except when we have unprocessed plaintext. + // This provides back-pressure to the TCP buffers. We also don't want to read more after + // the peer has sent us a close notification. + // + // In the handshake case we don't have readable plaintext before the handshake has + // completed, but also don't want to read if we still have sendable tls. + self.received_plaintext.is_empty() + && !self.has_received_close_notify + && (self.may_send_application_data || self.sendable_tls.is_empty()) + } + + pub(crate) fn current_io_state(&self) -> IoState { + IoState { + tls_bytes_to_write: self.sendable_tls.len(), + plaintext_bytes_to_read: self.received_plaintext.len(), + peer_has_closed: self.has_received_close_notify, + } + } + + pub(crate) fn is_quic(&self) -> bool { + self.protocol == Protocol::Quic + } + + pub(crate) fn should_update_key( + &mut self, + key_update_request: &KeyUpdateRequest, + ) -> Result { + self.temper_counters + .received_key_update_request()?; + + match key_update_request { + KeyUpdateRequest::UpdateNotRequested => Ok(false), + KeyUpdateRequest::UpdateRequested => Ok(self.queued_key_update_message.is_none()), + _ => Err(self.send_fatal_alert( + AlertDescription::IllegalParameter, + InvalidMessage::InvalidKeyUpdate, + )), + } + } + + pub(crate) fn enqueue_key_update_notification(&mut self) { + let message = PlainMessage::from(Message::build_key_update_notify()); + self.queued_key_update_message = Some( + self.record_layer + .encrypt_outgoing(message.borrow_outbound()) + .encode(), + ); + } + + pub(crate) fn received_tls13_change_cipher_spec(&mut self) -> Result<(), Error> { + self.temper_counters + .received_tls13_change_cipher_spec() + } +} + +#[cfg(feature = "std")] +impl CommonState { + /// Send plaintext application data, fragmenting and + /// encrypting it as it goes out. + /// + /// If internal buffers are too small, this function will not accept + /// all the data. + pub(crate) fn buffer_plaintext( + &mut self, + payload: OutboundChunks<'_>, + sendable_plaintext: &mut ChunkVecBuffer, + ) -> usize { + self.perhaps_write_key_update(); + self.send_plain(payload, Limit::Yes, sendable_plaintext) + } + + pub(crate) fn send_early_plaintext(&mut self, data: &[u8]) -> usize { + debug_assert!(self.early_traffic); + debug_assert!(self.record_layer.is_encrypting()); + + if data.is_empty() { + // Don't send empty fragments. + return 0; + } + + self.send_appdata_encrypt(data.into(), Limit::Yes) + } + + /// Encrypt and send some plaintext `data`. `limit` controls + /// whether the per-connection buffer limits apply. + /// + /// Returns the number of bytes written from `data`: this might + /// be less than `data.len()` if buffer limits were exceeded. + fn send_plain( + &mut self, + payload: OutboundChunks<'_>, + limit: Limit, + sendable_plaintext: &mut ChunkVecBuffer, + ) -> usize { + if !self.may_send_application_data { + // If we haven't completed handshaking, buffer + // plaintext to send once we do. + let len = match limit { + Limit::Yes => sendable_plaintext.append_limited_copy(payload), + Limit::No => sendable_plaintext.append(payload.to_vec()), + }; + return len; + } + + self.send_plain_non_buffering(payload, limit) + } +} + +/// Describes which sort of handshake happened. +#[derive(Debug, PartialEq, Clone, Copy)] +pub enum HandshakeKind { + /// A full handshake. + /// + /// This is the typical TLS connection initiation process when resumption is + /// not yet unavailable, and the initial `ClientHello` was accepted by the server. + Full, + + /// A full TLS1.3 handshake, with an extra round-trip for a `HelloRetryRequest`. + /// + /// The server can respond with a `HelloRetryRequest` if the initial `ClientHello` + /// is unacceptable for several reasons, the most likely if no supported key + /// shares were offered by the client. + FullWithHelloRetryRequest, + + /// A resumed handshake. + /// + /// Resumed handshakes involve fewer round trips and less cryptography than + /// full ones, but can only happen when the peers have previously done a full + /// handshake together, and then remember data about it. + Resumed, +} + +/// Values of this structure are returned from [`Connection::process_new_packets`] +/// and tell the caller the current I/O state of the TLS connection. +/// +/// [`Connection::process_new_packets`]: crate::Connection::process_new_packets +#[derive(Debug, Eq, PartialEq)] +pub struct IoState { + tls_bytes_to_write: usize, + plaintext_bytes_to_read: usize, + peer_has_closed: bool, +} + +impl IoState { + /// How many bytes could be written by [`Connection::write_tls`] if called + /// right now. A non-zero value implies [`CommonState::wants_write`]. + /// + /// [`Connection::write_tls`]: crate::Connection::write_tls + pub fn tls_bytes_to_write(&self) -> usize { + self.tls_bytes_to_write + } + + /// How many plaintext bytes could be obtained via [`std::io::Read`] + /// without further I/O. + pub fn plaintext_bytes_to_read(&self) -> usize { + self.plaintext_bytes_to_read + } + + /// True if the peer has sent us a close_notify alert. This is + /// the TLS mechanism to securely half-close a TLS connection, + /// and signifies that the peer will not send any further data + /// on this connection. + /// + /// This is also signalled via returning `Ok(0)` from + /// [`std::io::Read`], after all the received bytes have been + /// retrieved. + pub fn peer_has_closed(&self) -> bool { + self.peer_has_closed + } +} + +pub(crate) trait State: Send + Sync { + fn handle<'m>( + self: Box, + cx: &mut Context<'_, Data>, + message: Message<'m>, + ) -> Result + 'm>, Error> + where + Self: 'm; + + fn export_keying_material( + &self, + _output: &mut [u8], + _label: &[u8], + _context: Option<&[u8]>, + ) -> Result<(), Error> { + Err(Error::HandshakeNotComplete) + } + + fn extract_secrets(&self) -> Result { + Err(Error::HandshakeNotComplete) + } + + fn send_key_update_request(&mut self, _common: &mut CommonState) -> Result<(), Error> { + Err(Error::HandshakeNotComplete) + } + + fn handle_decrypt_error(&self) {} + + fn into_external_state(self: Box) -> Result, Error> { + Err(Error::HandshakeNotComplete) + } + + fn into_owned(self: Box) -> Box + 'static>; +} + +pub(crate) struct Context<'a, Data> { + pub(crate) common: &'a mut CommonState, + pub(crate) data: &'a mut Data, + /// Buffered plaintext. This is `Some` if any plaintext was written during handshake and `None` + /// otherwise. + pub(crate) sendable_plaintext: Option<&'a mut ChunkVecBuffer>, +} + +/// Side of the connection. +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum Side { + /// A client initiates the connection. + Client, + /// A server waits for a client to connect. + Server, +} + +impl Side { + pub(crate) fn peer(&self) -> Self { + match self { + Self::Client => Self::Server, + Self::Server => Self::Client, + } + } +} + +#[derive(Copy, Clone, Eq, PartialEq, Debug)] +pub(crate) enum Protocol { + Tcp, + Quic, +} + +enum Limit { + #[cfg(feature = "std")] + Yes, + No, +} + +/// Tracking technically-allowed protocol actions +/// that we limit to avoid denial-of-service vectors. +struct TemperCounters { + allowed_warning_alerts: u8, + allowed_renegotiation_requests: u8, + allowed_key_update_requests: u8, + allowed_middlebox_ccs: u8, +} + +impl TemperCounters { + fn received_warning_alert(&mut self) -> Result<(), Error> { + match self.allowed_warning_alerts { + 0 => Err(PeerMisbehaved::TooManyWarningAlertsReceived.into()), + _ => { + self.allowed_warning_alerts -= 1; + Ok(()) + } + } + } + + fn received_renegotiation_request(&mut self) -> Result<(), Error> { + match self.allowed_renegotiation_requests { + 0 => Err(PeerMisbehaved::TooManyRenegotiationRequests.into()), + _ => { + self.allowed_renegotiation_requests -= 1; + Ok(()) + } + } + } + + fn received_key_update_request(&mut self) -> Result<(), Error> { + match self.allowed_key_update_requests { + 0 => Err(PeerMisbehaved::TooManyKeyUpdateRequests.into()), + _ => { + self.allowed_key_update_requests -= 1; + Ok(()) + } + } + } + + fn received_tls13_change_cipher_spec(&mut self) -> Result<(), Error> { + match self.allowed_middlebox_ccs { + 0 => Err(PeerMisbehaved::IllegalMiddleboxChangeCipherSpec.into()), + _ => { + self.allowed_middlebox_ccs -= 1; + Ok(()) + } + } + } + + fn received_app_data(&mut self) { + self.allowed_key_update_requests = Self::INITIAL_KEY_UPDATE_REQUESTS; + } + + // cf. BoringSSL `kMaxKeyUpdates` + // + const INITIAL_KEY_UPDATE_REQUESTS: u8 = 32; +} + +impl Default for TemperCounters { + fn default() -> Self { + Self { + // cf. BoringSSL `kMaxWarningAlerts` + // + allowed_warning_alerts: 4, + + // we rebuff renegotiation requests with a `NoRenegotiation` warning alerts. + // a second request after this is fatal. + allowed_renegotiation_requests: 1, + + allowed_key_update_requests: Self::INITIAL_KEY_UPDATE_REQUESTS, + + // At most two CCS are allowed: one after each ClientHello (recall a second + // ClientHello happens after a HelloRetryRequest). + // + // note BoringSSL allows up to 32. + allowed_middlebox_ccs: 2, + } + } +} + +#[derive(Debug, Default)] +pub(crate) enum KxState { + #[default] + None, + Start(&'static dyn SupportedKxGroup), + Complete(&'static dyn SupportedKxGroup), +} + +impl KxState { + pub(crate) fn complete(&mut self) { + debug_assert!(matches!(self, Self::Start(_))); + if let Self::Start(group) = self { + *self = Self::Complete(*group); + } + } +} + +pub(crate) struct HandshakeFlight<'a, const TLS13: bool> { + pub(crate) transcript: &'a mut HandshakeHash, + body: Vec, +} + +impl<'a, const TLS13: bool> HandshakeFlight<'a, TLS13> { + pub(crate) fn new(transcript: &'a mut HandshakeHash) -> Self { + Self { + transcript, + body: Vec::new(), + } + } + + pub(crate) fn add(&mut self, hs: HandshakeMessagePayload<'_>) { + let start_len = self.body.len(); + hs.encode(&mut self.body); + self.transcript + .add(&self.body[start_len..]); + } + + pub(crate) fn finish(self, common: &mut CommonState) { + common.send_msg( + Message { + version: match TLS13 { + true => ProtocolVersion::TLSv1_3, + false => ProtocolVersion::TLSv1_2, + }, + payload: MessagePayload::HandshakeFlight(Payload::new(self.body)), + }, + TLS13, + ); + } +} + +#[cfg(feature = "tls12")] +pub(crate) type HandshakeFlightTls12<'a> = HandshakeFlight<'a, false>; +pub(crate) type HandshakeFlightTls13<'a> = HandshakeFlight<'a, true>; + +const DEFAULT_RECEIVED_PLAINTEXT_LIMIT: usize = 16 * 1024; +pub(crate) const DEFAULT_BUFFER_LIMIT: usize = 64 * 1024; diff --git a/http/vendor/rustls/src/compress.rs b/http/vendor/rustls/src/compress.rs new file mode 100644 index 0000000..14df129 --- /dev/null +++ b/http/vendor/rustls/src/compress.rs @@ -0,0 +1,678 @@ +//! Certificate compression and decompression support +//! +//! This crate supports compression and decompression everywhere +//! certificates are used, in accordance with [RFC8879][rfc8879]. +//! +//! Note that this is only supported for TLS1.3 connections. +//! +//! # Getting started +//! +//! Build this crate with the `brotli` and/or `zlib` crate features. This +//! adds dependencies on these crates. They are used by default if enabled. +//! +//! We especially recommend `brotli` as it has the widest deployment so far. +//! +//! # Custom compression/decompression implementations +//! +//! 1. Implement the [`CertCompressor`] and/or [`CertDecompressor`] traits +//! 2. Provide those to: +//! - [`ClientConfig::cert_compressors`][cc_cc] or [`ServerConfig::cert_compressors`][sc_cc]. +//! - [`ClientConfig::cert_decompressors`][cc_cd] or [`ServerConfig::cert_decompressors`][sc_cd]. +//! +//! These are used in these circumstances: +//! +//! | Peer | Client authentication | Server authentication | +//! | ---- | --------------------- | --------------------- | +//! | *Client* | [`ClientConfig::cert_compressors`][cc_cc] | [`ClientConfig::cert_decompressors`][cc_cd] | +//! | *Server* | [`ServerConfig::cert_decompressors`][sc_cd] | [`ServerConfig::cert_compressors`][sc_cc] | +//! +//! [rfc8879]: https://datatracker.ietf.org/doc/html/rfc8879 +//! [cc_cc]: crate::ClientConfig::cert_compressors +//! [sc_cc]: crate::ServerConfig::cert_compressors +//! [cc_cd]: crate::ClientConfig::cert_decompressors +//! [sc_cd]: crate::ServerConfig::cert_decompressors + +#[cfg(feature = "std")] +use alloc::collections::VecDeque; +use alloc::vec::Vec; +use core::fmt::Debug; +#[cfg(feature = "std")] +use std::sync::Mutex; + +use crate::enums::CertificateCompressionAlgorithm; +use crate::msgs::base::{Payload, PayloadU24}; +use crate::msgs::codec::Codec; +use crate::msgs::handshake::{CertificatePayloadTls13, CompressedCertificatePayload}; +use crate::sync::Arc; + +/// Returns the supported `CertDecompressor` implementations enabled +/// by crate features. +pub fn default_cert_decompressors() -> &'static [&'static dyn CertDecompressor] { + &[ + #[cfg(feature = "brotli")] + BROTLI_DECOMPRESSOR, + #[cfg(feature = "zlib")] + ZLIB_DECOMPRESSOR, + ] +} + +/// An available certificate decompression algorithm. +pub trait CertDecompressor: Debug + Send + Sync { + /// Decompress `input`, writing the result to `output`. + /// + /// `output` is sized to match the declared length of the decompressed data. + /// + /// `Err(DecompressionFailed)` should be returned if decompression produces more, or fewer + /// bytes than fit in `output`, or if the `input` is in any way malformed. + fn decompress(&self, input: &[u8], output: &mut [u8]) -> Result<(), DecompressionFailed>; + + /// Which algorithm this decompressor handles. + fn algorithm(&self) -> CertificateCompressionAlgorithm; +} + +/// Returns the supported `CertCompressor` implementations enabled +/// by crate features. +pub fn default_cert_compressors() -> &'static [&'static dyn CertCompressor] { + &[ + #[cfg(feature = "brotli")] + BROTLI_COMPRESSOR, + #[cfg(feature = "zlib")] + ZLIB_COMPRESSOR, + ] +} + +/// An available certificate compression algorithm. +pub trait CertCompressor: Debug + Send + Sync { + /// Compress `input`, returning the result. + /// + /// `input` is consumed by this function so (if the underlying implementation + /// supports it) the compression can be performed in-place. + /// + /// `level` is a hint as to how much effort to expend on the compression. + /// + /// `Err(CompressionFailed)` may be returned for any reason. + fn compress( + &self, + input: Vec, + level: CompressionLevel, + ) -> Result, CompressionFailed>; + + /// Which algorithm this compressor handles. + fn algorithm(&self) -> CertificateCompressionAlgorithm; +} + +/// A hint for how many resources to dedicate to a compression. +#[derive(Debug, Copy, Clone, Eq, PartialEq)] +pub enum CompressionLevel { + /// This compression is happening interactively during a handshake. + /// + /// Implementations may wish to choose a conservative compression level. + Interactive, + + /// The compression may be amortized over many connections. + /// + /// Implementations may wish to choose an aggressive compression level. + Amortized, +} + +/// A content-less error for when `CertDecompressor::decompress` fails. +#[derive(Debug)] +pub struct DecompressionFailed; + +/// A content-less error for when `CertCompressor::compress` fails. +#[derive(Debug)] +pub struct CompressionFailed; + +#[cfg(feature = "zlib")] +mod feat_zlib_rs { + use zlib_rs::{ + DeflateConfig, InflateConfig, ReturnCode, compress_bound, compress_slice, decompress_slice, + }; + + use super::*; + + /// A certificate decompressor for the Zlib algorithm using the `zlib-rs` crate. + pub const ZLIB_DECOMPRESSOR: &dyn CertDecompressor = &ZlibRsDecompressor; + + #[derive(Debug)] + struct ZlibRsDecompressor; + + impl CertDecompressor for ZlibRsDecompressor { + fn decompress(&self, input: &[u8], output: &mut [u8]) -> Result<(), DecompressionFailed> { + let output_len = output.len(); + match decompress_slice(output, input, InflateConfig::default()) { + (output_filled, ReturnCode::Ok) if output_filled.len() == output_len => Ok(()), + (_, _) => Err(DecompressionFailed), + } + } + + fn algorithm(&self) -> CertificateCompressionAlgorithm { + CertificateCompressionAlgorithm::Zlib + } + } + + /// A certificate compressor for the Zlib algorithm using the `zlib-rs` crate. + pub const ZLIB_COMPRESSOR: &dyn CertCompressor = &ZlibRsCompressor; + + #[derive(Debug)] + struct ZlibRsCompressor; + + impl CertCompressor for ZlibRsCompressor { + fn compress( + &self, + input: Vec, + level: CompressionLevel, + ) -> Result, CompressionFailed> { + let mut output = alloc::vec![0u8; compress_bound(input.len())]; + let config = match level { + CompressionLevel::Interactive => DeflateConfig::default(), + CompressionLevel::Amortized => DeflateConfig::best_compression(), + }; + let (output_filled, rc) = compress_slice(&mut output, &input, config); + if rc != ReturnCode::Ok { + return Err(CompressionFailed); + } + + let used = output_filled.len(); + output.truncate(used); + Ok(output) + } + + fn algorithm(&self) -> CertificateCompressionAlgorithm { + CertificateCompressionAlgorithm::Zlib + } + } +} + +#[cfg(feature = "zlib")] +pub use feat_zlib_rs::{ZLIB_COMPRESSOR, ZLIB_DECOMPRESSOR}; + +#[cfg(feature = "brotli")] +mod feat_brotli { + use std::io::{Cursor, Write}; + + use super::*; + + /// A certificate decompressor for the brotli algorithm using the `brotli` crate. + pub const BROTLI_DECOMPRESSOR: &dyn CertDecompressor = &BrotliDecompressor; + + #[derive(Debug)] + struct BrotliDecompressor; + + impl CertDecompressor for BrotliDecompressor { + fn decompress(&self, input: &[u8], output: &mut [u8]) -> Result<(), DecompressionFailed> { + let mut in_cursor = Cursor::new(input); + let mut out_cursor = Cursor::new(output); + + brotli::BrotliDecompress(&mut in_cursor, &mut out_cursor) + .map_err(|_| DecompressionFailed)?; + + if out_cursor.position() as usize != out_cursor.into_inner().len() { + return Err(DecompressionFailed); + } + + Ok(()) + } + + fn algorithm(&self) -> CertificateCompressionAlgorithm { + CertificateCompressionAlgorithm::Brotli + } + } + + /// A certificate compressor for the brotli algorithm using the `brotli` crate. + pub const BROTLI_COMPRESSOR: &dyn CertCompressor = &BrotliCompressor; + + #[derive(Debug)] + struct BrotliCompressor; + + impl CertCompressor for BrotliCompressor { + fn compress( + &self, + input: Vec, + level: CompressionLevel, + ) -> Result, CompressionFailed> { + let quality = match level { + CompressionLevel::Interactive => QUALITY_FAST, + CompressionLevel::Amortized => QUALITY_SLOW, + }; + let output = Cursor::new(Vec::with_capacity(input.len() / 2)); + let mut compressor = brotli::CompressorWriter::new(output, BUFFER_SIZE, quality, LGWIN); + compressor + .write_all(&input) + .map_err(|_| CompressionFailed)?; + Ok(compressor.into_inner().into_inner()) + } + + fn algorithm(&self) -> CertificateCompressionAlgorithm { + CertificateCompressionAlgorithm::Brotli + } + } + + /// Brotli buffer size. + /// + /// Chosen based on brotli `examples/compress.rs`. + const BUFFER_SIZE: usize = 4096; + + /// This is the default lgwin parameter, see `BrotliEncoderInitParams()` + const LGWIN: u32 = 22; + + /// Compression quality we use for interactive compressions. + /// See for data. + const QUALITY_FAST: u32 = 4; + + /// Compression quality we use for offline compressions (the maximum). + const QUALITY_SLOW: u32 = 11; +} + +#[cfg(feature = "brotli")] +pub use feat_brotli::{BROTLI_COMPRESSOR, BROTLI_DECOMPRESSOR}; + +/// An LRU cache for compressions. +/// +/// The prospect of being able to reuse a given compression for many connections +/// means we can afford to spend more time on that compression (by passing +/// `CompressionLevel::Amortized` to the compressor). +#[derive(Debug)] +pub enum CompressionCache { + /// No caching happens, and compression happens each time using + /// `CompressionLevel::Interactive`. + Disabled, + + /// Compressions are stored in an LRU cache. + #[cfg(feature = "std")] + Enabled(CompressionCacheInner), +} + +/// Innards of an enabled CompressionCache. +/// +/// You cannot make one of these directly. Use [`CompressionCache::new`]. +#[cfg(feature = "std")] +#[derive(Debug)] +pub struct CompressionCacheInner { + /// Maximum size of underlying storage. + size: usize, + + /// LRU-order entries. + /// + /// First is least-used, last is most-used. + entries: Mutex>>, +} + +impl CompressionCache { + /// Make a `CompressionCache` that stores up to `size` compressed + /// certificate messages. + #[cfg(feature = "std")] + pub fn new(size: usize) -> Self { + if size == 0 { + return Self::Disabled; + } + + Self::Enabled(CompressionCacheInner { + size, + entries: Mutex::new(VecDeque::with_capacity(size)), + }) + } + + /// Return a `CompressionCacheEntry`, which is an owning + /// wrapper for a `CompressedCertificatePayload`. + /// + /// `compressor` is the compression function we have negotiated. + /// `original` is the uncompressed certificate message. + pub(crate) fn compression_for( + &self, + compressor: &dyn CertCompressor, + original: &CertificatePayloadTls13<'_>, + ) -> Result, CompressionFailed> { + match self { + Self::Disabled => Self::uncached_compression(compressor, original), + + #[cfg(feature = "std")] + Self::Enabled(_) => self.compression_for_impl(compressor, original), + } + } + + #[cfg(feature = "std")] + fn compression_for_impl( + &self, + compressor: &dyn CertCompressor, + original: &CertificatePayloadTls13<'_>, + ) -> Result, CompressionFailed> { + let (max_size, entries) = match self { + Self::Enabled(CompressionCacheInner { size, entries }) => (*size, entries), + _ => unreachable!(), + }; + + // context is a per-connection quantity, and included in the compressed data. + // it is not suitable for inclusion in the cache. + if !original.context.0.is_empty() { + return Self::uncached_compression(compressor, original); + } + + // cache probe: + let encoding = original.get_encoding(); + let algorithm = compressor.algorithm(); + + let mut cache = entries + .lock() + .map_err(|_| CompressionFailed)?; + for (i, item) in cache.iter().enumerate() { + if item.algorithm == algorithm && item.original == encoding { + // this item is now MRU + let item = cache.remove(i).unwrap(); + cache.push_back(item.clone()); + return Ok(item); + } + } + drop(cache); + + // do compression: + let uncompressed_len = encoding.len() as u32; + let compressed = compressor.compress(encoding.clone(), CompressionLevel::Amortized)?; + let new_entry = Arc::new(CompressionCacheEntry { + algorithm, + original: encoding, + compressed: CompressedCertificatePayload { + alg: algorithm, + uncompressed_len, + compressed: PayloadU24(Payload::new(compressed)), + }, + }); + + // insert into cache + let mut cache = entries + .lock() + .map_err(|_| CompressionFailed)?; + if cache.len() == max_size { + cache.pop_front(); + } + cache.push_back(new_entry.clone()); + Ok(new_entry) + } + + /// Compress `original` using `compressor` at `Interactive` level. + fn uncached_compression( + compressor: &dyn CertCompressor, + original: &CertificatePayloadTls13<'_>, + ) -> Result, CompressionFailed> { + let algorithm = compressor.algorithm(); + let encoding = original.get_encoding(); + let uncompressed_len = encoding.len() as u32; + let compressed = compressor.compress(encoding, CompressionLevel::Interactive)?; + + // this `CompressionCacheEntry` in fact never makes it into the cache, so + // `original` is left empty + Ok(Arc::new(CompressionCacheEntry { + algorithm, + original: Vec::new(), + compressed: CompressedCertificatePayload { + alg: algorithm, + uncompressed_len, + compressed: PayloadU24(Payload::new(compressed)), + }, + })) + } +} + +impl Default for CompressionCache { + fn default() -> Self { + #[cfg(feature = "std")] + { + // 4 entries allows 2 certificate chains times 2 compression algorithms + Self::new(4) + } + + #[cfg(not(feature = "std"))] + { + Self::Disabled + } + } +} + +#[cfg_attr(not(feature = "std"), allow(dead_code))] +#[derive(Debug)] +pub(crate) struct CompressionCacheEntry { + // cache key is algorithm + original: + algorithm: CertificateCompressionAlgorithm, + original: Vec, + + // cache value is compression result: + compressed: CompressedCertificatePayload<'static>, +} + +impl CompressionCacheEntry { + pub(crate) fn compressed_cert_payload(&self) -> CompressedCertificatePayload<'_> { + self.compressed.as_borrowed() + } +} + +#[cfg(all(test, any(feature = "brotli", feature = "zlib")))] +mod tests { + use std::{println, vec}; + + use super::*; + + #[test] + #[cfg(feature = "zlib")] + fn test_zlib() { + test_compressor(ZLIB_COMPRESSOR, ZLIB_DECOMPRESSOR); + } + + #[test] + #[cfg(feature = "brotli")] + fn test_brotli() { + test_compressor(BROTLI_COMPRESSOR, BROTLI_DECOMPRESSOR); + } + + fn test_compressor(comp: &dyn CertCompressor, decomp: &dyn CertDecompressor) { + assert_eq!(comp.algorithm(), decomp.algorithm()); + for sz in [16, 64, 512, 2048, 8192, 16384] { + test_trivial_pairwise(comp, decomp, sz); + } + test_decompress_wrong_len(comp, decomp); + test_decompress_garbage(decomp); + } + + fn test_trivial_pairwise( + comp: &dyn CertCompressor, + decomp: &dyn CertDecompressor, + plain_len: usize, + ) { + let original = vec![0u8; plain_len]; + + for level in [CompressionLevel::Interactive, CompressionLevel::Amortized] { + let compressed = comp + .compress(original.clone(), level) + .unwrap(); + println!( + "{:?} compressed trivial {} -> {} using {:?} level", + comp.algorithm(), + original.len(), + compressed.len(), + level + ); + let mut recovered = vec![0xffu8; plain_len]; + decomp + .decompress(&compressed, &mut recovered) + .unwrap(); + assert_eq!(original, recovered); + } + } + + fn test_decompress_wrong_len(comp: &dyn CertCompressor, decomp: &dyn CertDecompressor) { + let original = vec![0u8; 2048]; + let compressed = comp + .compress(original.clone(), CompressionLevel::Interactive) + .unwrap(); + println!("{compressed:?}"); + + // too big + let mut recovered = vec![0xffu8; original.len() + 1]; + decomp + .decompress(&compressed, &mut recovered) + .unwrap_err(); + + // too small + let mut recovered = vec![0xffu8; original.len() - 1]; + decomp + .decompress(&compressed, &mut recovered) + .unwrap_err(); + } + + fn test_decompress_garbage(decomp: &dyn CertDecompressor) { + let junk = [0u8; 1024]; + let mut recovered = vec![0u8; 512]; + decomp + .decompress(&junk, &mut recovered) + .unwrap_err(); + } + + #[test] + #[cfg(all(feature = "brotli", feature = "zlib"))] + fn test_cache_evicts_lru() { + use core::sync::atomic::{AtomicBool, Ordering}; + + use pki_types::CertificateDer; + + let cache = CompressionCache::default(); + + let cert = CertificateDer::from(vec![1]); + + let cert1 = CertificatePayloadTls13::new([&cert].into_iter(), Some(b"1")); + let cert2 = CertificatePayloadTls13::new([&cert].into_iter(), Some(b"2")); + let cert3 = CertificatePayloadTls13::new([&cert].into_iter(), Some(b"3")); + let cert4 = CertificatePayloadTls13::new([&cert].into_iter(), Some(b"4")); + + // insert zlib (1), (2), (3), (4) + + cache + .compression_for( + &RequireCompress(ZLIB_COMPRESSOR, AtomicBool::default(), true), + &cert1, + ) + .unwrap(); + cache + .compression_for( + &RequireCompress(ZLIB_COMPRESSOR, AtomicBool::default(), true), + &cert2, + ) + .unwrap(); + cache + .compression_for( + &RequireCompress(ZLIB_COMPRESSOR, AtomicBool::default(), true), + &cert3, + ) + .unwrap(); + cache + .compression_for( + &RequireCompress(ZLIB_COMPRESSOR, AtomicBool::default(), true), + &cert4, + ) + .unwrap(); + + // -- now full + + // insert brotli (1) evicts zlib (1) + cache + .compression_for( + &RequireCompress(BROTLI_COMPRESSOR, AtomicBool::default(), true), + &cert4, + ) + .unwrap(); + + // now zlib (2), (3), (4) and brotli (4) exist + cache + .compression_for( + &RequireCompress(ZLIB_COMPRESSOR, AtomicBool::default(), false), + &cert2, + ) + .unwrap(); + cache + .compression_for( + &RequireCompress(ZLIB_COMPRESSOR, AtomicBool::default(), false), + &cert3, + ) + .unwrap(); + cache + .compression_for( + &RequireCompress(ZLIB_COMPRESSOR, AtomicBool::default(), false), + &cert4, + ) + .unwrap(); + cache + .compression_for( + &RequireCompress(BROTLI_COMPRESSOR, AtomicBool::default(), false), + &cert4, + ) + .unwrap(); + + // insert zlib (1) requires re-compression & evicts zlib (2) + cache + .compression_for( + &RequireCompress(ZLIB_COMPRESSOR, AtomicBool::default(), true), + &cert1, + ) + .unwrap(); + + // now zlib (1), (3), (4) and brotli (4) exist + // query zlib (4), (3), (1) to demonstrate LRU tracks usage rather than insertion + cache + .compression_for( + &RequireCompress(ZLIB_COMPRESSOR, AtomicBool::default(), false), + &cert4, + ) + .unwrap(); + cache + .compression_for( + &RequireCompress(ZLIB_COMPRESSOR, AtomicBool::default(), false), + &cert3, + ) + .unwrap(); + cache + .compression_for( + &RequireCompress(ZLIB_COMPRESSOR, AtomicBool::default(), false), + &cert1, + ) + .unwrap(); + + // now brotli (4), zlib (4), (3), (1) + // insert brotli (1) evicting brotli (4) + cache + .compression_for( + &RequireCompress(BROTLI_COMPRESSOR, AtomicBool::default(), true), + &cert1, + ) + .unwrap(); + + // verify brotli (4) disappeared + cache + .compression_for( + &RequireCompress(BROTLI_COMPRESSOR, AtomicBool::default(), true), + &cert4, + ) + .unwrap(); + + #[derive(Debug)] + struct RequireCompress(&'static dyn CertCompressor, AtomicBool, bool); + + impl CertCompressor for RequireCompress { + fn compress( + &self, + input: Vec, + level: CompressionLevel, + ) -> Result, CompressionFailed> { + self.1.store(true, Ordering::SeqCst); + self.0.compress(input, level) + } + + fn algorithm(&self) -> CertificateCompressionAlgorithm { + self.0.algorithm() + } + } + + impl Drop for RequireCompress { + fn drop(&mut self) { + assert_eq!(self.1.load(Ordering::SeqCst), self.2); + } + } + } +} diff --git a/http/vendor/rustls/src/conn.rs b/http/vendor/rustls/src/conn.rs new file mode 100644 index 0000000..4ea90e7 --- /dev/null +++ b/http/vendor/rustls/src/conn.rs @@ -0,0 +1,1305 @@ +use alloc::boxed::Box; +use core::fmt::Debug; +use core::mem; +use core::ops::{Deref, DerefMut, Range}; +#[cfg(feature = "std")] +use std::io; + +use kernel::KernelConnection; + +use crate::common_state::{CommonState, Context, DEFAULT_BUFFER_LIMIT, IoState, State}; +use crate::enums::{AlertDescription, ContentType, ProtocolVersion}; +use crate::error::{Error, PeerMisbehaved}; +use crate::log::trace; +use crate::msgs::deframer::DeframerIter; +use crate::msgs::deframer::buffers::{BufferProgress, DeframerVecBuffer, Delocator, Locator}; +use crate::msgs::deframer::handshake::HandshakeDeframer; +use crate::msgs::handshake::Random; +use crate::msgs::message::{InboundPlainMessage, Message, MessagePayload}; +use crate::record_layer::Decrypted; +use crate::suites::ExtractedSecrets; +use crate::vecbuf::ChunkVecBuffer; + +// pub so that it can be re-exported from the crate root +pub mod kernel; +pub(crate) mod unbuffered; + +#[cfg(feature = "std")] +mod connection { + use alloc::vec::Vec; + use core::fmt::Debug; + use core::ops::{Deref, DerefMut}; + use std::io::{self, BufRead, Read}; + + use crate::ConnectionCommon; + use crate::common_state::{CommonState, IoState}; + use crate::error::Error; + use crate::msgs::message::OutboundChunks; + use crate::suites::ExtractedSecrets; + use crate::vecbuf::ChunkVecBuffer; + + /// A client or server connection. + #[derive(Debug)] + pub enum Connection { + /// A client connection + Client(crate::client::ClientConnection), + /// A server connection + Server(crate::server::ServerConnection), + } + + impl Connection { + /// Read TLS content from `rd`. + /// + /// See [`ConnectionCommon::read_tls()`] for more information. + pub fn read_tls(&mut self, rd: &mut dyn Read) -> Result { + match self { + Self::Client(conn) => conn.read_tls(rd), + Self::Server(conn) => conn.read_tls(rd), + } + } + + /// Writes TLS messages to `wr`. + /// + /// See [`ConnectionCommon::write_tls()`] for more information. + pub fn write_tls(&mut self, wr: &mut dyn io::Write) -> Result { + self.sendable_tls.write_to(wr) + } + + /// Returns an object that allows reading plaintext. + pub fn reader(&mut self) -> Reader<'_> { + match self { + Self::Client(conn) => conn.reader(), + Self::Server(conn) => conn.reader(), + } + } + + /// Returns an object that allows writing plaintext. + pub fn writer(&mut self) -> Writer<'_> { + match self { + Self::Client(conn) => Writer::new(&mut **conn), + Self::Server(conn) => Writer::new(&mut **conn), + } + } + + /// Processes any new packets read by a previous call to [`Connection::read_tls`]. + /// + /// See [`ConnectionCommon::process_new_packets()`] for more information. + pub fn process_new_packets(&mut self) -> Result { + match self { + Self::Client(conn) => conn.process_new_packets(), + Self::Server(conn) => conn.process_new_packets(), + } + } + + /// Derives key material from the agreed connection secrets. + /// + /// See [`ConnectionCommon::export_keying_material()`] for more information. + pub fn export_keying_material>( + &self, + output: T, + label: &[u8], + context: Option<&[u8]>, + ) -> Result { + match self { + Self::Client(conn) => conn.export_keying_material(output, label, context), + Self::Server(conn) => conn.export_keying_material(output, label, context), + } + } + + /// This function uses `io` to complete any outstanding IO for this connection. + /// + /// See [`ConnectionCommon::complete_io()`] for more information. + pub fn complete_io(&mut self, io: &mut T) -> Result<(usize, usize), io::Error> + where + Self: Sized, + T: Read + io::Write, + { + match self { + Self::Client(conn) => conn.complete_io(io), + Self::Server(conn) => conn.complete_io(io), + } + } + + /// Extract secrets, so they can be used when configuring kTLS, for example. + /// Should be used with care as it exposes secret key material. + pub fn dangerous_extract_secrets(self) -> Result { + match self { + Self::Client(client) => client.dangerous_extract_secrets(), + Self::Server(server) => server.dangerous_extract_secrets(), + } + } + + /// Sets a limit on the internal buffers + /// + /// See [`ConnectionCommon::set_buffer_limit()`] for more information. + pub fn set_buffer_limit(&mut self, limit: Option) { + match self { + Self::Client(client) => client.set_buffer_limit(limit), + Self::Server(server) => server.set_buffer_limit(limit), + } + } + + /// Sends a TLS1.3 `key_update` message to refresh a connection's keys + /// + /// See [`ConnectionCommon::refresh_traffic_keys()`] for more information. + pub fn refresh_traffic_keys(&mut self) -> Result<(), Error> { + match self { + Self::Client(client) => client.refresh_traffic_keys(), + Self::Server(server) => server.refresh_traffic_keys(), + } + } + } + + impl Deref for Connection { + type Target = CommonState; + + fn deref(&self) -> &Self::Target { + match self { + Self::Client(conn) => &conn.core.common_state, + Self::Server(conn) => &conn.core.common_state, + } + } + } + + impl DerefMut for Connection { + fn deref_mut(&mut self) -> &mut Self::Target { + match self { + Self::Client(conn) => &mut conn.core.common_state, + Self::Server(conn) => &mut conn.core.common_state, + } + } + } + + /// A structure that implements [`std::io::Read`] for reading plaintext. + pub struct Reader<'a> { + pub(super) received_plaintext: &'a mut ChunkVecBuffer, + pub(super) has_received_close_notify: bool, + pub(super) has_seen_eof: bool, + } + + impl<'a> Reader<'a> { + /// Check the connection's state if no bytes are available for reading. + fn check_no_bytes_state(&self) -> io::Result<()> { + match (self.has_received_close_notify, self.has_seen_eof) { + // cleanly closed; don't care about TCP EOF: express this as Ok(0) + (true, _) => Ok(()), + // unclean closure + (false, true) => Err(io::Error::new( + io::ErrorKind::UnexpectedEof, + UNEXPECTED_EOF_MESSAGE, + )), + // connection still going, but needs more data: signal `WouldBlock` so that + // the caller knows this + (false, false) => Err(io::ErrorKind::WouldBlock.into()), + } + } + + /// Obtain a chunk of plaintext data received from the peer over this TLS connection. + /// + /// This method consumes `self` so that it can return a slice whose lifetime is bounded by + /// the [`ConnectionCommon`] that created this `Reader`. + pub fn into_first_chunk(self) -> io::Result<&'a [u8]> { + match self.received_plaintext.chunk() { + Some(chunk) => Ok(chunk), + None => { + self.check_no_bytes_state()?; + Ok(&[]) + } + } + } + } + + impl Read for Reader<'_> { + /// Obtain plaintext data received from the peer over this TLS connection. + /// + /// If the peer closes the TLS session cleanly, this returns `Ok(0)` once all + /// the pending data has been read. No further data can be received on that + /// connection, so the underlying TCP connection should be half-closed too. + /// + /// If the peer closes the TLS session uncleanly (a TCP EOF without sending a + /// `close_notify` alert) this function returns a `std::io::Error` of type + /// `ErrorKind::UnexpectedEof` once any pending data has been read. + /// + /// Note that support for `close_notify` varies in peer TLS libraries: many do not + /// support it and uncleanly close the TCP connection (this might be + /// vulnerable to truncation attacks depending on the application protocol). + /// This means applications using rustls must both handle EOF + /// from this function, *and* unexpected EOF of the underlying TCP connection. + /// + /// If there are no bytes to read, this returns `Err(ErrorKind::WouldBlock.into())`. + /// + /// You may learn the number of bytes available at any time by inspecting + /// the return of [`Connection::process_new_packets`]. + fn read(&mut self, buf: &mut [u8]) -> io::Result { + let len = self.received_plaintext.read(buf)?; + if len > 0 || buf.is_empty() { + return Ok(len); + } + + self.check_no_bytes_state() + .map(|()| len) + } + + /// Obtain plaintext data received from the peer over this TLS connection. + /// + /// If the peer closes the TLS session, this returns `Ok(())` without filling + /// any more of the buffer once all the pending data has been read. No further + /// data can be received on that connection, so the underlying TCP connection + /// should be half-closed too. + /// + /// If the peer closes the TLS session uncleanly (a TCP EOF without sending a + /// `close_notify` alert) this function returns a `std::io::Error` of type + /// `ErrorKind::UnexpectedEof` once any pending data has been read. + /// + /// Note that support for `close_notify` varies in peer TLS libraries: many do not + /// support it and uncleanly close the TCP connection (this might be + /// vulnerable to truncation attacks depending on the application protocol). + /// This means applications using rustls must both handle EOF + /// from this function, *and* unexpected EOF of the underlying TCP connection. + /// + /// If there are no bytes to read, this returns `Err(ErrorKind::WouldBlock.into())`. + /// + /// You may learn the number of bytes available at any time by inspecting + /// the return of [`Connection::process_new_packets`]. + #[cfg(read_buf)] + fn read_buf(&mut self, mut cursor: core::io::BorrowedCursor<'_, u8>) -> io::Result<()> { + let before = cursor.written(); + self.received_plaintext + .read_buf(cursor.reborrow())?; + let len = cursor.written() - before; + if len > 0 || cursor.capacity() == 0 { + return Ok(()); + } + + self.check_no_bytes_state() + } + } + + impl BufRead for Reader<'_> { + /// Obtain a chunk of plaintext data received from the peer over this TLS connection. + /// This reads the same data as [`Reader::read()`], but returns a reference instead of + /// copying the data. + /// + /// The caller should call [`Reader::consume()`] afterward to advance the buffer. + /// + /// See [`Reader::into_first_chunk()`] for a version of this function that returns a + /// buffer with a longer lifetime. + fn fill_buf(&mut self) -> io::Result<&[u8]> { + Reader { + // reborrow + received_plaintext: self.received_plaintext, + ..*self + } + .into_first_chunk() + } + + fn consume(&mut self, amt: usize) { + self.received_plaintext + .consume_first_chunk(amt) + } + } + + const UNEXPECTED_EOF_MESSAGE: &str = "peer closed connection without sending TLS close_notify: \ +https://docs.rs/rustls/latest/rustls/manual/_03_howto/index.html#unexpected-eof"; + + /// A structure that implements [`std::io::Write`] for writing plaintext. + pub struct Writer<'a> { + sink: &'a mut dyn PlaintextSink, + } + + impl<'a> Writer<'a> { + /// Create a new Writer. + /// + /// This is not an external interface. Get one of these objects + /// from [`Connection::writer`]. + pub(crate) fn new(sink: &'a mut dyn PlaintextSink) -> Self { + Writer { sink } + } + } + + impl io::Write for Writer<'_> { + /// Send the plaintext `buf` to the peer, encrypting + /// and authenticating it. Once this function succeeds + /// you should call [`Connection::write_tls`] which will output the + /// corresponding TLS records. + /// + /// This function buffers plaintext sent before the + /// TLS handshake completes, and sends it as soon + /// as it can. See [`ConnectionCommon::set_buffer_limit`] to control + /// the size of this buffer. + fn write(&mut self, buf: &[u8]) -> io::Result { + self.sink.write(buf) + } + + fn write_vectored(&mut self, bufs: &[io::IoSlice<'_>]) -> io::Result { + self.sink.write_vectored(bufs) + } + + fn flush(&mut self) -> io::Result<()> { + self.sink.flush() + } + } + + /// Internal trait implemented by the [`ServerConnection`]/[`ClientConnection`] + /// allowing them to be the subject of a [`Writer`]. + /// + /// [`ServerConnection`]: crate::ServerConnection + /// [`ClientConnection`]: crate::ClientConnection + pub(crate) trait PlaintextSink { + fn write(&mut self, buf: &[u8]) -> io::Result; + fn write_vectored(&mut self, bufs: &[io::IoSlice<'_>]) -> io::Result; + fn flush(&mut self) -> io::Result<()>; + } + + impl PlaintextSink for ConnectionCommon { + fn write(&mut self, buf: &[u8]) -> io::Result { + let len = self + .core + .common_state + .buffer_plaintext(buf.into(), &mut self.sendable_plaintext); + self.core.maybe_refresh_traffic_keys(); + Ok(len) + } + + fn write_vectored(&mut self, bufs: &[io::IoSlice<'_>]) -> io::Result { + let payload_owner: Vec<&[u8]>; + let payload = match bufs.len() { + 0 => return Ok(0), + 1 => OutboundChunks::Single(bufs[0].deref()), + _ => { + payload_owner = bufs + .iter() + .map(|io_slice| io_slice.deref()) + .collect(); + + OutboundChunks::new(&payload_owner) + } + }; + let len = self + .core + .common_state + .buffer_plaintext(payload, &mut self.sendable_plaintext); + self.core.maybe_refresh_traffic_keys(); + Ok(len) + } + + fn flush(&mut self) -> io::Result<()> { + Ok(()) + } + } +} + +#[cfg(feature = "std")] +pub use connection::{Connection, Reader, Writer}; + +#[derive(Debug)] +pub(crate) struct ConnectionRandoms { + pub(crate) client: [u8; 32], + pub(crate) server: [u8; 32], +} + +impl ConnectionRandoms { + pub(crate) fn new(client: Random, server: Random) -> Self { + Self { + client: client.0, + server: server.0, + } + } +} + +/// Interface shared by client and server connections. +pub struct ConnectionCommon { + pub(crate) core: ConnectionCore, + deframer_buffer: DeframerVecBuffer, + sendable_plaintext: ChunkVecBuffer, +} + +impl ConnectionCommon { + /// Processes any new packets read by a previous call to + /// [`Connection::read_tls`]. + /// + /// Errors from this function relate to TLS protocol errors, and + /// are fatal to the connection. Future calls after an error will do + /// no new work and will return the same error. After an error is + /// received from [`process_new_packets`], you should not call [`read_tls`] + /// any more (it will fill up buffers to no purpose). However, you + /// may call the other methods on the connection, including `write`, + /// `send_close_notify`, and `write_tls`. Most likely you will want to + /// call `write_tls` to send any alerts queued by the error and then + /// close the underlying connection. + /// + /// Success from this function comes with some sundry state data + /// about the connection. + /// + /// [`read_tls`]: Connection::read_tls + /// [`process_new_packets`]: Connection::process_new_packets + #[inline] + pub fn process_new_packets(&mut self) -> Result { + self.core + .process_new_packets(&mut self.deframer_buffer, &mut self.sendable_plaintext) + } + + /// Derives key material from the agreed connection secrets. + /// + /// This function fills in `output` with `output.len()` bytes of key + /// material derived from the master session secret using `label` + /// and `context` for diversification. Ownership of the buffer is taken + /// by the function and returned via the Ok result to ensure no key + /// material leaks if the function fails. + /// + /// See RFC5705 for more details on what this does and is for. + /// + /// For TLS1.3 connections, this function does not use the + /// "early" exporter at any point. + /// + /// This function fails if called prior to the handshake completing; + /// check with [`CommonState::is_handshaking`] first. + /// + /// This function fails if `output.len()` is zero. + #[inline] + pub fn export_keying_material>( + &self, + output: T, + label: &[u8], + context: Option<&[u8]>, + ) -> Result { + self.core + .export_keying_material(output, label, context) + } + + /// Extract secrets, so they can be used when configuring kTLS, for example. + /// Should be used with care as it exposes secret key material. + pub fn dangerous_extract_secrets(self) -> Result { + self.core.dangerous_extract_secrets() + } + + /// Sets a limit on the internal buffers used to buffer + /// unsent plaintext (prior to completing the TLS handshake) + /// and unsent TLS records. This limit acts only on application + /// data written through [`Connection::writer`]. + /// + /// By default the limit is 64KB. The limit can be set + /// at any time, even if the current buffer use is higher. + /// + /// [`None`] means no limit applies, and will mean that written + /// data is buffered without bound -- it is up to the application + /// to appropriately schedule its plaintext and TLS writes to bound + /// memory usage. + /// + /// For illustration: `Some(1)` means a limit of one byte applies: + /// [`Connection::writer`] will accept only one byte, encrypt it and + /// add a TLS header. Once this is sent via [`Connection::write_tls`], + /// another byte may be sent. + /// + /// # Internal write-direction buffering + /// rustls has two buffers whose size are bounded by this setting: + /// + /// ## Buffering of unsent plaintext data prior to handshake completion + /// + /// Calls to [`Connection::writer`] before or during the handshake + /// are buffered (up to the limit specified here). Once the + /// handshake completes this data is encrypted and the resulting + /// TLS records are added to the outgoing buffer. + /// + /// ## Buffering of outgoing TLS records + /// + /// This buffer is used to store TLS records that rustls needs to + /// send to the peer. It is used in these two circumstances: + /// + /// - by [`Connection::process_new_packets`] when a handshake or alert + /// TLS record needs to be sent. + /// - by [`Connection::writer`] post-handshake: the plaintext is + /// encrypted and the resulting TLS record is buffered. + /// + /// This buffer is emptied by [`Connection::write_tls`]. + /// + /// [`Connection::writer`]: crate::Connection::writer + /// [`Connection::write_tls`]: crate::Connection::write_tls + /// [`Connection::process_new_packets`]: crate::Connection::process_new_packets + pub fn set_buffer_limit(&mut self, limit: Option) { + self.sendable_plaintext.set_limit(limit); + self.sendable_tls.set_limit(limit); + } + + /// Sends a TLS1.3 `key_update` message to refresh a connection's keys. + /// + /// This call refreshes our encryption keys. Once the peer receives the message, + /// it refreshes _its_ encryption and decryption keys and sends a response. + /// Once we receive that response, we refresh our decryption keys to match. + /// At the end of this process, keys in both directions have been refreshed. + /// + /// Note that this process does not happen synchronously: this call just + /// arranges that the `key_update` message will be included in the next + /// `write_tls` output. + /// + /// This fails with `Error::HandshakeNotComplete` if called before the initial + /// handshake is complete, or if a version prior to TLS1.3 is negotiated. + /// + /// # Usage advice + /// Note that other implementations (including rustls) may enforce limits on + /// the number of `key_update` messages allowed on a given connection to prevent + /// denial of service. Therefore, this should be called sparingly. + /// + /// rustls implicitly and automatically refreshes traffic keys when needed + /// according to the selected cipher suite's cryptographic constraints. There + /// is therefore no need to call this manually to avoid cryptographic keys + /// "wearing out". + /// + /// The main reason to call this manually is to roll keys when it is known + /// a connection will be idle for a long period. + pub fn refresh_traffic_keys(&mut self) -> Result<(), Error> { + self.core.refresh_traffic_keys() + } +} + +#[cfg(feature = "std")] +impl ConnectionCommon { + /// Returns an object that allows reading plaintext. + pub fn reader(&mut self) -> Reader<'_> { + let common = &mut self.core.common_state; + Reader { + received_plaintext: &mut common.received_plaintext, + // Are we done? i.e., have we processed all received messages, and received a + // close_notify to indicate that no new messages will arrive? + has_received_close_notify: common.has_received_close_notify, + has_seen_eof: common.has_seen_eof, + } + } + + /// Returns an object that allows writing plaintext. + pub fn writer(&mut self) -> Writer<'_> { + Writer::new(self) + } + + /// This function uses `io` to complete any outstanding IO for + /// this connection. + /// + /// This is a convenience function which solely uses other parts + /// of the public API. + /// + /// What this means depends on the connection state: + /// + /// - If the connection [`is_handshaking`], then IO is performed until + /// the handshake is complete. + /// - Otherwise, if [`wants_write`] is true, [`write_tls`] is invoked + /// until it is all written. + /// - Otherwise, if [`wants_read`] is true, [`read_tls`] is invoked + /// once. + /// + /// The return value is the number of bytes read from and written + /// to `io`, respectively. Once both `read()` and `write()` yield `WouldBlock`, + /// this function will propagate the error. + /// + /// Errors from TLS record handling (i.e., from [`process_new_packets`]) + /// are wrapped in an `io::ErrorKind::InvalidData`-kind error. + /// + /// [`is_handshaking`]: CommonState::is_handshaking + /// [`wants_read`]: CommonState::wants_read + /// [`wants_write`]: CommonState::wants_write + /// [`write_tls`]: ConnectionCommon::write_tls + /// [`read_tls`]: ConnectionCommon::read_tls + /// [`process_new_packets`]: ConnectionCommon::process_new_packets + pub fn complete_io(&mut self, io: &mut T) -> Result<(usize, usize), io::Error> + where + Self: Sized, + T: io::Read + io::Write, + { + let mut eof = false; + let mut wrlen = 0; + let mut rdlen = 0; + loop { + let (mut blocked_write, mut blocked_read) = (None, None); + let until_handshaked = self.is_handshaking(); + + if !self.wants_write() && !self.wants_read() { + // We will make no further progress. + return Ok((rdlen, wrlen)); + } + + while self.wants_write() { + match self.write_tls(io) { + Ok(0) => { + io.flush()?; + return Ok((rdlen, wrlen)); // EOF. + } + Ok(n) => wrlen += n, + Err(err) if err.kind() == io::ErrorKind::WouldBlock => { + blocked_write = Some(err); + break; + } + Err(err) => return Err(err), + } + } + if wrlen > 0 { + io.flush()?; + } + + if !until_handshaked && wrlen > 0 { + return Ok((rdlen, wrlen)); + } + + // If we want to write, but are WouldBlocked by the underlying IO, *and* + // have no desire to read; that is everything. + if let (Some(_), false) = (&blocked_write, self.wants_read()) { + return match wrlen { + 0 => Err(blocked_write.unwrap()), + _ => Ok((rdlen, wrlen)), + }; + } + + while !eof && self.wants_read() { + let read_size = match self.read_tls(io) { + Ok(0) => { + eof = true; + Some(0) + } + Ok(n) => { + rdlen += n; + Some(n) + } + Err(err) if err.kind() == io::ErrorKind::WouldBlock => { + blocked_read = Some(err); + break; + } + Err(err) if err.kind() == io::ErrorKind::Interrupted => None, // nothing to do + Err(err) => return Err(err), + }; + if read_size.is_some() { + break; + } + } + + if let Err(e) = self.process_new_packets() { + // In case we have an alert to send describing this error, try a last-gasp + // write -- but don't predate the primary error. + let _ignored = self.write_tls(io); + let _ignored = io.flush(); + return Err(io::Error::new(io::ErrorKind::InvalidData, e)); + }; + + // If we want to read, but are WouldBlocked by the underlying IO, *and* + // have no desire to write; that is everything. + if let (Some(_), false) = (&blocked_read, self.wants_write()) { + return match rdlen { + 0 => Err(blocked_read.unwrap()), + _ => Ok((rdlen, wrlen)), + }; + } + + // if we're doing IO until handshaked, and we believe we've finished handshaking, + // but process_new_packets() has queued TLS data to send, loop around again to write + // the queued messages. + if until_handshaked && !self.is_handshaking() && self.wants_write() { + continue; + } + + let blocked = blocked_write.zip(blocked_read); + match (eof, until_handshaked, self.is_handshaking(), blocked) { + (_, true, false, _) => return Ok((rdlen, wrlen)), + (_, _, _, Some((e, _))) if rdlen == 0 && wrlen == 0 => return Err(e), + (_, false, _, _) => return Ok((rdlen, wrlen)), + (true, true, true, _) => return Err(io::Error::from(io::ErrorKind::UnexpectedEof)), + _ => {} + } + } + } + + /// Extract the first handshake message. + /// + /// This is a shortcut to the `process_new_packets()` -> `process_msg()` -> + /// `process_handshake_messages()` path, specialized for the first handshake message. + pub(crate) fn first_handshake_message(&mut self) -> Result>, Error> { + let mut buffer_progress = self.core.hs_deframer.progress(); + + let res = self + .core + .deframe( + None, + self.deframer_buffer.filled_mut(), + &mut buffer_progress, + ) + .map(|opt| opt.map(|pm| Message::try_from(pm).map(|m| m.into_owned()))); + + match res? { + Some(Ok(msg)) => { + self.deframer_buffer + .discard(buffer_progress.take_discard()); + Ok(Some(msg)) + } + Some(Err(err)) => Err(self.send_fatal_alert(AlertDescription::DecodeError, err)), + None => Ok(None), + } + } + + pub(crate) fn replace_state(&mut self, new: Box>) { + self.core.state = Ok(new); + } + + /// Read TLS content from `rd` into the internal buffer. + /// + /// Due to the internal buffering, `rd` can supply TLS messages in arbitrary-sized chunks (like + /// a socket or pipe might). + /// + /// You should call [`process_new_packets()`] each time a call to this function succeeds in order + /// to empty the incoming TLS data buffer. + /// + /// This function returns `Ok(0)` when the underlying `rd` does so. This typically happens when + /// a socket is cleanly closed, or a file is at EOF. Errors may result from the IO done through + /// `rd`; additionally, errors of `ErrorKind::Other` are emitted to signal backpressure: + /// + /// * In order to empty the incoming TLS data buffer, you should call [`process_new_packets()`] + /// each time a call to this function succeeds. + /// * In order to empty the incoming plaintext data buffer, you should empty it through + /// the [`reader()`] after the call to [`process_new_packets()`]. + /// + /// This function also returns `Ok(0)` once a `close_notify` alert has been successfully + /// received. No additional data is ever read in this state. + /// + /// [`process_new_packets()`]: ConnectionCommon::process_new_packets + /// [`reader()`]: ConnectionCommon::reader + pub fn read_tls(&mut self, rd: &mut dyn io::Read) -> Result { + if self.received_plaintext.is_full() { + return Err(io::Error::new( + io::ErrorKind::Other, + "received plaintext buffer full", + )); + } + + if self.has_received_close_notify { + return Ok(0); + } + + let res = self + .deframer_buffer + .read(rd, self.core.hs_deframer.is_active()); + if let Ok(0) = res { + self.has_seen_eof = true; + } + res + } + + /// Writes TLS messages to `wr`. + /// + /// On success, this function returns `Ok(n)` where `n` is a number of bytes written to `wr` + /// (after encoding and encryption). + /// + /// After this function returns, the connection buffer may not yet be fully flushed. The + /// [`CommonState::wants_write`] function can be used to check if the output buffer is empty. + pub fn write_tls(&mut self, wr: &mut dyn io::Write) -> Result { + self.sendable_tls.write_to(wr) + } +} + +impl<'a, Data> From<&'a mut ConnectionCommon> for Context<'a, Data> { + fn from(conn: &'a mut ConnectionCommon) -> Self { + Self { + common: &mut conn.core.common_state, + data: &mut conn.core.data, + sendable_plaintext: Some(&mut conn.sendable_plaintext), + } + } +} + +impl Deref for ConnectionCommon { + type Target = CommonState; + + fn deref(&self) -> &Self::Target { + &self.core.common_state + } +} + +impl DerefMut for ConnectionCommon { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.core.common_state + } +} + +impl From> for ConnectionCommon { + fn from(core: ConnectionCore) -> Self { + Self { + core, + deframer_buffer: DeframerVecBuffer::default(), + sendable_plaintext: ChunkVecBuffer::new(Some(DEFAULT_BUFFER_LIMIT)), + } + } +} + +/// Interface shared by unbuffered client and server connections. +pub struct UnbufferedConnectionCommon { + pub(crate) core: ConnectionCore, + wants_write: bool, + emitted_peer_closed_state: bool, +} + +impl From> for UnbufferedConnectionCommon { + fn from(core: ConnectionCore) -> Self { + Self { + core, + wants_write: false, + emitted_peer_closed_state: false, + } + } +} + +impl UnbufferedConnectionCommon { + /// Extract secrets, so they can be used when configuring kTLS, for example. + /// Should be used with care as it exposes secret key material. + pub fn dangerous_extract_secrets(self) -> Result { + self.core.dangerous_extract_secrets() + } +} + +impl Deref for UnbufferedConnectionCommon { + type Target = CommonState; + + fn deref(&self) -> &Self::Target { + &self.core.common_state + } +} + +pub(crate) struct ConnectionCore { + pub(crate) state: Result>, Error>, + pub(crate) data: Data, + pub(crate) common_state: CommonState, + pub(crate) hs_deframer: HandshakeDeframer, + + /// We limit consecutive empty fragments to avoid a route for the peer to send + /// us significant but fruitless traffic. + seen_consecutive_empty_fragments: u8, +} + +impl ConnectionCore { + pub(crate) fn new(state: Box>, data: Data, common_state: CommonState) -> Self { + Self { + state: Ok(state), + data, + common_state, + hs_deframer: HandshakeDeframer::default(), + seen_consecutive_empty_fragments: 0, + } + } + + pub(crate) fn process_new_packets( + &mut self, + deframer_buffer: &mut DeframerVecBuffer, + sendable_plaintext: &mut ChunkVecBuffer, + ) -> Result { + let mut state = match mem::replace(&mut self.state, Err(Error::HandshakeNotComplete)) { + Ok(state) => state, + Err(e) => { + self.state = Err(e.clone()); + return Err(e); + } + }; + + let mut buffer_progress = self.hs_deframer.progress(); + + loop { + let res = self.deframe( + Some(&*state), + deframer_buffer.filled_mut(), + &mut buffer_progress, + ); + + let opt_msg = match res { + Ok(opt_msg) => opt_msg, + Err(e) => { + self.state = Err(e.clone()); + deframer_buffer.discard(buffer_progress.take_discard()); + return Err(e); + } + }; + + let Some(msg) = opt_msg else { + break; + }; + + match self.process_msg(msg, state, Some(sendable_plaintext)) { + Ok(new) => state = new, + Err(e) => { + self.state = Err(e.clone()); + deframer_buffer.discard(buffer_progress.take_discard()); + return Err(e); + } + } + + if self + .common_state + .has_received_close_notify + { + // "Any data received after a closure alert has been received MUST be ignored." + // -- + // This is data that has already been accepted in `read_tls`. + buffer_progress.add_discard(deframer_buffer.filled().len()); + break; + } + + deframer_buffer.discard(buffer_progress.take_discard()); + } + + deframer_buffer.discard(buffer_progress.take_discard()); + self.state = Ok(state); + Ok(self.common_state.current_io_state()) + } + + /// Pull a message out of the deframer and send any messages that need to be sent as a result. + fn deframe<'b>( + &mut self, + state: Option<&dyn State>, + buffer: &'b mut [u8], + buffer_progress: &mut BufferProgress, + ) -> Result>, Error> { + // before processing any more of `buffer`, return any extant messages from `hs_deframer` + if self.hs_deframer.has_message_ready() { + Ok(self.take_handshake_message(buffer, buffer_progress)) + } else { + self.process_more_input(state, buffer, buffer_progress) + } + } + + fn take_handshake_message<'b>( + &mut self, + buffer: &'b mut [u8], + buffer_progress: &mut BufferProgress, + ) -> Option> { + self.hs_deframer + .iter(buffer) + .next() + .map(|(message, discard)| { + buffer_progress.add_discard(discard); + message + }) + } + + fn process_more_input<'b>( + &mut self, + state: Option<&dyn State>, + buffer: &'b mut [u8], + buffer_progress: &mut BufferProgress, + ) -> Result>, Error> { + let version_is_tls13 = matches!( + self.common_state.negotiated_version, + Some(ProtocolVersion::TLSv1_3) + ); + + let locator = Locator::new(buffer); + + loop { + let mut iter = DeframerIter::new(&mut buffer[buffer_progress.processed()..]); + + let (message, processed) = loop { + let message = match iter.next().transpose() { + Ok(Some(message)) => message, + Ok(None) => return Ok(None), + Err(err) => return Err(self.handle_deframe_error(err, state)), + }; + + let allowed_plaintext = match message.typ { + // CCS messages are always plaintext. + ContentType::ChangeCipherSpec => true, + // Alerts are allowed to be plaintext if-and-only-if: + // * The negotiated protocol version is TLS 1.3. - In TLS 1.2 it is unambiguous when + // keying changes based on the CCS message. Only TLS 1.3 requires these heuristics. + // * We have not yet decrypted any messages from the peer - if we have we don't + // expect any plaintext. + // * The payload size is indicative of a plaintext alert message. + ContentType::Alert + if version_is_tls13 + && !self + .common_state + .record_layer + .has_decrypted() + && message.payload.len() <= 2 => + { + true + } + // In other circumstances, we expect all messages to be encrypted. + _ => false, + }; + + if allowed_plaintext && !self.hs_deframer.is_active() { + break (message.into_plain_message(), iter.bytes_consumed()); + } + + let message = match self + .common_state + .record_layer + .decrypt_incoming(message) + { + // failed decryption during trial decryption is not allowed to be + // interleaved with partial handshake data. + Ok(None) if !self.hs_deframer.is_aligned() => { + return Err( + PeerMisbehaved::RejectedEarlyDataInterleavedWithHandshakeMessage.into(), + ); + } + + // failed decryption during trial decryption. + Ok(None) => continue, + + Ok(Some(message)) => message, + + Err(err) => return Err(self.handle_deframe_error(err, state)), + }; + + let Decrypted { + want_close_before_decrypt, + plaintext, + } = message; + + if want_close_before_decrypt { + self.common_state.send_close_notify(); + } + + break (plaintext, iter.bytes_consumed()); + }; + + if !self.hs_deframer.is_aligned() && message.typ != ContentType::Handshake { + // "Handshake messages MUST NOT be interleaved with other record + // types. That is, if a handshake message is split over two or more + // records, there MUST NOT be any other records between them." + // https://www.rfc-editor.org/rfc/rfc8446#section-5.1 + return Err(PeerMisbehaved::MessageInterleavedWithHandshakeMessage.into()); + } + + match message.payload.len() { + 0 => { + if self.seen_consecutive_empty_fragments + == ALLOWED_CONSECUTIVE_EMPTY_FRAGMENTS_MAX + { + return Err(PeerMisbehaved::TooManyEmptyFragments.into()); + } + self.seen_consecutive_empty_fragments += 1; + } + _ => { + self.seen_consecutive_empty_fragments = 0; + } + }; + + buffer_progress.add_processed(processed); + + // do an end-run around the borrow checker, converting `message` (containing + // a borrowed slice) to an unborrowed one (containing a `Range` into the + // same buffer). the reborrow happens inside the branch that returns the + // message. + // + // is fixed by -Zpolonius + // https://github.com/rust-lang/rfcs/blob/master/text/2094-nll.md#problem-case-3-conditional-control-flow-across-functions + let unborrowed = InboundUnborrowedMessage::unborrow(&locator, message); + + if unborrowed.typ != ContentType::Handshake { + let message = unborrowed.reborrow(&Delocator::new(buffer)); + buffer_progress.add_discard(processed); + return Ok(Some(message)); + } + + let message = unborrowed.reborrow(&Delocator::new(buffer)); + self.hs_deframer + .input_message(message, &locator, buffer_progress.processed()); + self.hs_deframer.coalesce(buffer)?; + + self.common_state.aligned_handshake = self.hs_deframer.is_aligned(); + + if self.hs_deframer.has_message_ready() { + // trial decryption finishes with the first handshake message after it started. + self.common_state + .record_layer + .finish_trial_decryption(); + + return Ok(self.take_handshake_message(buffer, buffer_progress)); + } + } + } + + fn handle_deframe_error(&mut self, error: Error, state: Option<&dyn State>) -> Error { + match error { + error @ Error::InvalidMessage(_) => { + if self.common_state.is_quic() { + self.common_state.quic.alert = Some(AlertDescription::DecodeError); + error + } else { + self.common_state + .send_fatal_alert(AlertDescription::DecodeError, error) + } + } + Error::PeerSentOversizedRecord => self + .common_state + .send_fatal_alert(AlertDescription::RecordOverflow, error), + Error::DecryptError => { + if let Some(state) = state { + state.handle_decrypt_error(); + } + self.common_state + .send_fatal_alert(AlertDescription::BadRecordMac, error) + } + + error => error, + } + } + + fn process_msg( + &mut self, + msg: InboundPlainMessage<'_>, + state: Box>, + sendable_plaintext: Option<&mut ChunkVecBuffer>, + ) -> Result>, Error> { + // Drop CCS messages during handshake in TLS1.3 + if msg.typ == ContentType::ChangeCipherSpec + && !self + .common_state + .may_receive_application_data + && self.common_state.is_tls13() + { + if !msg.is_valid_ccs() { + // "An implementation which receives any other change_cipher_spec value or + // which receives a protected change_cipher_spec record MUST abort the + // handshake with an "unexpected_message" alert." + return Err(self.common_state.send_fatal_alert( + AlertDescription::UnexpectedMessage, + PeerMisbehaved::IllegalMiddleboxChangeCipherSpec, + )); + } + + self.common_state + .received_tls13_change_cipher_spec()?; + trace!("Dropping CCS"); + return Ok(state); + } + + // Now we can fully parse the message payload. + let msg = match Message::try_from(msg) { + Ok(msg) => msg, + Err(err) => { + return Err(self + .common_state + .send_fatal_alert(AlertDescription::from(err), err)); + } + }; + + // For alerts, we have separate logic. + if let MessagePayload::Alert(alert) = &msg.payload { + self.common_state.process_alert(alert)?; + return Ok(state); + } + + self.common_state + .process_main_protocol(msg, state, &mut self.data, sendable_plaintext) + } + + pub(crate) fn dangerous_extract_secrets(self) -> Result { + Ok(self + .dangerous_into_kernel_connection()? + .0) + } + + pub(crate) fn dangerous_into_kernel_connection( + self, + ) -> Result<(ExtractedSecrets, KernelConnection), Error> { + if !self + .common_state + .enable_secret_extraction + { + return Err(Error::General("Secret extraction is disabled".into())); + } + + if self.common_state.is_handshaking() { + return Err(Error::HandshakeNotComplete); + } + + if !self + .common_state + .sendable_tls + .is_empty() + { + return Err(Error::General( + "cannot convert into an KernelConnection while there are still buffered TLS records to send" + .into() + )); + } + + let state = self.state?; + + let record_layer = &self.common_state.record_layer; + let secrets = state.extract_secrets()?; + let secrets = ExtractedSecrets { + tx: (record_layer.write_seq(), secrets.tx), + rx: (record_layer.read_seq(), secrets.rx), + }; + + let state = state.into_external_state()?; + let external = KernelConnection::new(state, self.common_state)?; + + Ok((secrets, external)) + } + + pub(crate) fn export_keying_material>( + &self, + mut output: T, + label: &[u8], + context: Option<&[u8]>, + ) -> Result { + if output.as_mut().is_empty() { + return Err(Error::General( + "export_keying_material with zero-length output".into(), + )); + } + + match self.state.as_ref() { + Ok(st) => st + .export_keying_material(output.as_mut(), label, context) + .map(|_| output), + Err(e) => Err(e.clone()), + } + } + + /// Trigger a `refresh_traffic_keys` if required by `CommonState`. + fn maybe_refresh_traffic_keys(&mut self) { + if mem::take( + &mut self + .common_state + .refresh_traffic_keys_pending, + ) { + let _ = self.refresh_traffic_keys(); + } + } + + fn refresh_traffic_keys(&mut self) -> Result<(), Error> { + match &mut self.state { + Ok(st) => st.send_key_update_request(&mut self.common_state), + Err(e) => Err(e.clone()), + } + } +} + +/// Data specific to the peer's side (client or server). +pub trait SideData: Debug {} + +/// An InboundPlainMessage which does not borrow its payload, but +/// references a range that can later be borrowed. +struct InboundUnborrowedMessage { + typ: ContentType, + version: ProtocolVersion, + bounds: Range, +} + +impl InboundUnborrowedMessage { + fn unborrow(locator: &Locator, msg: InboundPlainMessage<'_>) -> Self { + Self { + typ: msg.typ, + version: msg.version, + bounds: locator.locate(msg.payload), + } + } + + fn reborrow<'b>(self, delocator: &Delocator<'b>) -> InboundPlainMessage<'b> { + InboundPlainMessage { + typ: self.typ, + version: self.version, + payload: delocator.slice_from_range(&self.bounds), + } + } +} + +/// cf. BoringSSL's `kMaxEmptyRecords` +/// +const ALLOWED_CONSECUTIVE_EMPTY_FRAGMENTS_MAX: u8 = 32; diff --git a/http/vendor/rustls/src/conn/kernel.rs b/http/vendor/rustls/src/conn/kernel.rs new file mode 100644 index 0000000..b90fad3 --- /dev/null +++ b/http/vendor/rustls/src/conn/kernel.rs @@ -0,0 +1,268 @@ +//! Kernel connection API. +//! +//! This module gives you the bare minimum you need to implement a TLS connection +//! that does its own encryption and decryption while still using rustls to manage +//! connection secrets and session tickets. It is intended for use cases like kTLS +//! where you want to use rustls to establish the connection but want to use +//! something else to do the encryption/decryption after that. +//! +//! There are only two things that [`KernelConnection`] is able to do: +//! 1. Compute new traffic secrets when a key update occurs. +//! 2. Save received session tickets sent by a server peer. +//! +//! That's it. Everything else you will need to implement yourself. +//! +//! # Entry Point +//! The entry points into this API are +//! [`UnbufferedClientConnection::dangerous_into_kernel_connection`][client-into] +//! and +//! [`UnbufferedServerConnection::dangerous_into_kernel_connection`][server-into]. +//! +//! In order to actually create an [`KernelConnection`] all of the following +//! must be true: +//! - the connection must have completed its handshake, +//! - the connection must have no buffered TLS data waiting to be sent, and, +//! - the config used to create the connection must have `enable_extract_secrets` +//! set to true. +//! +//! This sounds fairly complicated to achieve at first glance. However, if you +//! drive an unbuffered connection through the handshake until it returns +//! [`WriteTraffic`] then it will end up in an appropriate state to convert +//! into an external connection. +//! +//! [client-into]: crate::client::UnbufferedClientConnection::dangerous_into_kernel_connection +//! [server-into]: crate::server::UnbufferedServerConnection::dangerous_into_kernel_connection +//! [`WriteTraffic`]: crate::unbuffered::ConnectionState::WriteTraffic +//! +//! # Cipher Suite Confidentiality Limits +//! Some cipher suites (notably AES-GCM) have vulnerabilities where they are no +//! longer secure once a certain number of messages have been sent. Normally, +//! rustls tracks how many messages have been written or read and will +//! automatically either refresh keys or emit an error when approaching the +//! confidentiality limit of the cipher suite. +//! +//! [`KernelConnection`] has no way to track this. It is the responsibility +//! of the user of the API to track approximately how many messages have been +//! sent and either refresh the traffic keys or abort the connection before the +//! confidentiality limit is reached. +//! +//! You can find the current confidentiality limit by looking at +//! [`CipherSuiteCommon::confidentiality_limit`] for the cipher suite selected +//! by the connection. +//! +//! [`CipherSuiteCommon::confidentiality_limit`]: crate::CipherSuiteCommon::confidentiality_limit +//! [`KernelConnection`]: crate::kernel::KernelConnection + +use alloc::boxed::Box; +use core::marker::PhantomData; + +use crate::client::ClientConnectionData; +use crate::common_state::Protocol; +use crate::msgs::codec::Codec; +use crate::msgs::handshake::{CertificateChain, NewSessionTicketPayloadTls13}; +use crate::quic::Quic; +use crate::{CommonState, ConnectionTrafficSecrets, Error, ProtocolVersion, SupportedCipherSuite}; + +/// A kernel connection. +/// +/// This does not directly wrap a kernel connection, rather it gives you the +/// minimal interfaces you need to implement a well-behaved TLS connection on +/// top of kTLS. +/// +/// See the [`crate::kernel`] module docs for more details. +pub struct KernelConnection { + state: Box, + + peer_certificates: Option>, + quic: Quic, + + negotiated_version: ProtocolVersion, + protocol: Protocol, + suite: SupportedCipherSuite, + + _data: PhantomData, +} + +impl KernelConnection { + pub(crate) fn new(state: Box, common: CommonState) -> Result { + Ok(Self { + state, + + peer_certificates: common.peer_certificates, + quic: common.quic, + negotiated_version: common + .negotiated_version + .ok_or(Error::HandshakeNotComplete)?, + protocol: common.protocol, + suite: common + .suite + .ok_or(Error::HandshakeNotComplete)?, + + _data: PhantomData, + }) + } + + /// Retrieves the ciphersuite agreed with the peer. + pub fn negotiated_cipher_suite(&self) -> SupportedCipherSuite { + self.suite + } + + /// Retrieves the protocol version agreed with the peer. + pub fn protocol_version(&self) -> ProtocolVersion { + self.negotiated_version + } + + /// Update the traffic secret used for encrypting messages sent to the peer. + /// + /// Returns the new traffic secret and initial sequence number to use. + /// + /// In order to use the new secret you should send a TLS 1.3 key update to + /// the peer and then use the new traffic secrets to encrypt any future + /// messages. + /// + /// Note that it is only possible to update the traffic secrets on a TLS 1.3 + /// connection. Attempting to do so on a non-TLS 1.3 connection will result + /// in an error. + pub fn update_tx_secret(&mut self) -> Result<(u64, ConnectionTrafficSecrets), Error> { + // The sequence number always starts at 0 after a key update. + self.state + .update_secrets(Direction::Transmit) + .map(|secret| (0, secret)) + } + + /// Update the traffic secret used for decrypting messages received from the + /// peer. + /// + /// Returns the new traffic secret and initial sequence number to use. + /// + /// You should call this method once you receive a TLS 1.3 key update message + /// from the peer. + /// + /// Note that it is only possible to update the traffic secrets on a TLS 1.3 + /// connection. Attempting to do so on a non-TLS 1.3 connection will result + /// in an error. + pub fn update_rx_secret(&mut self) -> Result<(u64, ConnectionTrafficSecrets), Error> { + // The sequence number always starts at 0 after a key update. + self.state + .update_secrets(Direction::Receive) + .map(|secret| (0, secret)) + } +} + +impl KernelConnection { + /// Handle a `new_session_ticket` message from the peer. + /// + /// This will register the session ticket within with rustls so that it can + /// be used to establish future TLS connections. + /// + /// # Getting the right payload + /// + /// This method expects to be passed the inner payload of the handshake + /// message. This means that you will need to parse the header of the + /// handshake message in order to determine the correct payload to pass in. + /// The message format is described in [RFC 8446 section 4][0]. `payload` + /// should not include the `msg_type` or `length` fields. + /// + /// Code to parse out the payload should look something like this + /// ```no_run + /// use rustls::{ContentType, HandshakeType}; + /// use rustls::kernel::KernelConnection; + /// use rustls::client::ClientConnectionData; + /// + /// # fn doctest(conn: &mut KernelConnection, typ: ContentType, message: &[u8]) -> Result<(), rustls::Error> { + /// let conn: &mut KernelConnection = // ... + /// # conn; + /// let typ: ContentType = // ... + /// # typ; + /// let mut message: &[u8] = // ... + /// # message; + /// + /// // Processing for other messages not included in this example + /// assert_eq!(typ, ContentType::Handshake); + /// + /// // There may be multiple handshake payloads within a single handshake message. + /// while !message.is_empty() { + /// let (typ, len, rest) = match message { + /// &[typ, a, b, c, ref rest @ ..] => ( + /// HandshakeType::from(typ), + /// u32::from_be_bytes([0, a, b, c]) as usize, + /// rest + /// ), + /// _ => panic!("error handling not included in this example") + /// }; + /// + /// // Processing for other messages not included in this example. + /// assert_eq!(typ, HandshakeType::NewSessionTicket); + /// assert!(rest.len() >= len, "invalid handshake message"); + /// + /// let (payload, rest) = rest.split_at(len); + /// message = rest; + /// + /// conn.handle_new_session_ticket(payload)?; + /// } + /// # Ok(()) + /// # } + /// ``` + /// + /// # Errors + /// This method will return an error if: + /// - This connection is not a TLS 1.3 connection (in TLS 1.2 session tickets + /// are sent as part of the handshake). + /// - The provided payload is not a valid `new_session_ticket` payload or has + /// extra unparsed trailing data. + /// - An error occurs while the connection updates the session ticket store. + /// + /// [0]: https://datatracker.ietf.org/doc/html/rfc8446#section-4 + pub fn handle_new_session_ticket(&mut self, payload: &[u8]) -> Result<(), Error> { + // We want to return a more specific error here first if this is called + // on a non-TLS 1.3 connection since a parsing error isn't the real issue + // here. + if self.protocol_version() != ProtocolVersion::TLSv1_3 { + return Err(Error::General( + "TLS 1.2 session tickets may not be sent once the handshake has completed".into(), + )); + } + + let nst = NewSessionTicketPayloadTls13::read_bytes(payload)?; + let mut cx = KernelContext { + peer_certificates: self.peer_certificates.as_ref(), + protocol: self.protocol, + quic: &self.quic, + }; + self.state + .handle_new_session_ticket(&mut cx, &nst) + } +} + +pub(crate) trait KernelState: Send + Sync { + /// Update the traffic secret for the specified direction on the connection. + fn update_secrets(&mut self, dir: Direction) -> Result; + + /// Handle a new session ticket. + /// + /// This will only ever be called for client connections, as [`KernelConnection`] + /// only exposes the relevant API for client connections. + fn handle_new_session_ticket( + &mut self, + cx: &mut KernelContext<'_>, + message: &NewSessionTicketPayloadTls13, + ) -> Result<(), Error>; +} + +pub(crate) struct KernelContext<'a> { + pub(crate) peer_certificates: Option<&'a CertificateChain<'static>>, + pub(crate) protocol: Protocol, + pub(crate) quic: &'a Quic, +} + +impl KernelContext<'_> { + pub(crate) fn is_quic(&self) -> bool { + self.protocol == Protocol::Quic + } +} + +#[derive(Copy, Clone, Debug, Eq, PartialEq)] +pub(crate) enum Direction { + Transmit, + Receive, +} diff --git a/http/vendor/rustls/src/conn/unbuffered.rs b/http/vendor/rustls/src/conn/unbuffered.rs new file mode 100644 index 0000000..77927b5 --- /dev/null +++ b/http/vendor/rustls/src/conn/unbuffered.rs @@ -0,0 +1,620 @@ +//! Unbuffered connection API + +use alloc::vec::Vec; +use core::num::NonZeroUsize; +use core::{fmt, mem}; +#[cfg(feature = "std")] +use std::error::Error as StdError; + +use super::UnbufferedConnectionCommon; +use crate::Error; +use crate::client::ClientConnectionData; +use crate::msgs::deframer::buffers::DeframerSliceBuffer; +use crate::server::ServerConnectionData; + +impl UnbufferedConnectionCommon { + /// Processes the TLS records in `incoming_tls` buffer until a new [`UnbufferedStatus`] is + /// reached. + pub fn process_tls_records<'c, 'i>( + &'c mut self, + incoming_tls: &'i mut [u8], + ) -> UnbufferedStatus<'c, 'i, ClientConnectionData> { + self.process_tls_records_common(incoming_tls, |_| false, |_, _| unreachable!()) + } +} + +impl UnbufferedConnectionCommon { + /// Processes the TLS records in `incoming_tls` buffer until a new [`UnbufferedStatus`] is + /// reached. + pub fn process_tls_records<'c, 'i>( + &'c mut self, + incoming_tls: &'i mut [u8], + ) -> UnbufferedStatus<'c, 'i, ServerConnectionData> { + self.process_tls_records_common( + incoming_tls, + |conn| conn.peek_early_data().is_some(), + |conn, incoming_tls| ReadEarlyData::new(conn, incoming_tls).into(), + ) + } +} + +impl UnbufferedConnectionCommon { + fn process_tls_records_common<'c, 'i>( + &'c mut self, + incoming_tls: &'i mut [u8], + mut early_data_available: impl FnMut(&mut Self) -> bool, + early_data_state: impl FnOnce(&'c mut Self, &'i mut [u8]) -> ConnectionState<'c, 'i, Data>, + ) -> UnbufferedStatus<'c, 'i, Data> { + let mut buffer = DeframerSliceBuffer::new(incoming_tls); + let mut buffer_progress = self.core.hs_deframer.progress(); + + let (discard, state) = loop { + if early_data_available(self) { + break ( + buffer.pending_discard(), + early_data_state(self, incoming_tls), + ); + } + + if !self + .core + .common_state + .received_plaintext + .is_empty() + { + break ( + buffer.pending_discard(), + ReadTraffic::new(self, incoming_tls).into(), + ); + } + + if let Some(chunk) = self + .core + .common_state + .sendable_tls + .pop() + { + break ( + buffer.pending_discard(), + EncodeTlsData::new(self, chunk).into(), + ); + } + + let deframer_output = if self + .core + .common_state + .has_received_close_notify + { + None + } else { + match self + .core + .deframe(None, buffer.filled_mut(), &mut buffer_progress) + { + Err(err) => { + buffer.queue_discard(buffer_progress.take_discard()); + return UnbufferedStatus { + discard: buffer.pending_discard(), + state: Err(err), + }; + } + Ok(r) => r, + } + }; + + if let Some(msg) = deframer_output { + let mut state = + match mem::replace(&mut self.core.state, Err(Error::HandshakeNotComplete)) { + Ok(state) => state, + Err(e) => { + buffer.queue_discard(buffer_progress.take_discard()); + self.core.state = Err(e.clone()); + return UnbufferedStatus { + discard: buffer.pending_discard(), + state: Err(e), + }; + } + }; + + match self.core.process_msg(msg, state, None) { + Ok(new) => state = new, + + Err(e) => { + buffer.queue_discard(buffer_progress.take_discard()); + self.core.state = Err(e.clone()); + return UnbufferedStatus { + discard: buffer.pending_discard(), + state: Err(e), + }; + } + } + + buffer.queue_discard(buffer_progress.take_discard()); + + self.core.state = Ok(state); + } else if self.wants_write { + break ( + buffer.pending_discard(), + TransmitTlsData { conn: self }.into(), + ); + } else if self + .core + .common_state + .has_received_close_notify + && !self.emitted_peer_closed_state + { + self.emitted_peer_closed_state = true; + break (buffer.pending_discard(), ConnectionState::PeerClosed); + } else if self + .core + .common_state + .has_received_close_notify + && self + .core + .common_state + .has_sent_close_notify + { + break (buffer.pending_discard(), ConnectionState::Closed); + } else if self + .core + .common_state + .may_send_application_data + { + break ( + buffer.pending_discard(), + ConnectionState::WriteTraffic(WriteTraffic { conn: self }), + ); + } else { + break (buffer.pending_discard(), ConnectionState::BlockedHandshake); + } + }; + + UnbufferedStatus { + discard, + state: Ok(state), + } + } +} + +/// The current status of the `UnbufferedConnection*` +#[must_use] +#[derive(Debug)] +pub struct UnbufferedStatus<'c, 'i, Data> { + /// Number of bytes to discard + /// + /// After the `state` field of this object has been handled, `discard` bytes must be + /// removed from the *front* of the `incoming_tls` buffer that was passed to + /// the [`UnbufferedConnectionCommon::process_tls_records`] call that returned this object. + /// + /// This discard operation MUST happen *before* + /// [`UnbufferedConnectionCommon::process_tls_records`] is called again. + pub discard: usize, + + /// The current state of the handshake process + /// + /// This value MUST be handled prior to calling + /// [`UnbufferedConnectionCommon::process_tls_records`] again. See the documentation on the + /// variants of [`ConnectionState`] for more details. + pub state: Result, Error>, +} + +/// The state of the [`UnbufferedConnectionCommon`] object +#[non_exhaustive] // for forwards compatibility; to support caller-side certificate verification +pub enum ConnectionState<'c, 'i, Data> { + /// One, or more, application data records are available + /// + /// See [`ReadTraffic`] for more details on how to use the enclosed object to access + /// the received data. + ReadTraffic(ReadTraffic<'c, 'i, Data>), + + /// Connection has been cleanly closed by the peer. + /// + /// This state is encountered at most once by each connection -- it is + /// "edge" triggered, rather than "level" triggered. + /// + /// It delimits the data received from the peer, meaning you can be sure you + /// have received all the data the peer sent. + /// + /// No further application data will be received from the peer, so no further + /// `ReadTraffic` states will be produced. + /// + /// However, it is possible to _send_ further application data via `WriteTraffic` + /// states, or close the connection cleanly by calling + /// [`WriteTraffic::queue_close_notify()`]. + PeerClosed, + + /// Connection has been cleanly closed by both us and the peer. + /// + /// This is a terminal state. No other states will be produced for this + /// connection. + Closed, + + /// One, or more, early (RTT-0) data records are available + ReadEarlyData(ReadEarlyData<'c, 'i, Data>), + + /// A Handshake record is ready for encoding + /// + /// Call [`EncodeTlsData::encode`] on the enclosed object, providing an `outgoing_tls` + /// buffer to store the encoding + EncodeTlsData(EncodeTlsData<'c, Data>), + + /// Previously encoded handshake records need to be transmitted + /// + /// Transmit the contents of the `outgoing_tls` buffer that was passed to previous + /// [`EncodeTlsData::encode`] calls to the peer. + /// + /// After transmitting the contents, call [`TransmitTlsData::done`] on the enclosed object. + /// The transmitted contents MUST not be sent to the peer more than once so they SHOULD be + /// discarded at this point. + /// + /// At some stages of the handshake process, it's possible to send application-data alongside + /// handshake records. Call [`TransmitTlsData::may_encrypt_app_data`] on the enclosed + /// object to probe if that's allowed. + TransmitTlsData(TransmitTlsData<'c, Data>), + + /// More TLS data is needed to continue with the handshake + /// + /// Request more data from the peer and append the contents to the `incoming_tls` buffer that + /// was passed to [`UnbufferedConnectionCommon::process_tls_records`]. + BlockedHandshake, + + /// The handshake process has been completed. + /// + /// [`WriteTraffic::encrypt`] can be called on the enclosed object to encrypt application + /// data into an `outgoing_tls` buffer. Similarly, [`WriteTraffic::queue_close_notify`] can + /// be used to encrypt a close_notify alert message into a buffer to signal the peer that the + /// connection is being closed. Data written into `outgoing_buffer` by either method MAY be + /// transmitted to the peer during this state. + /// + /// Once this state has been reached, data MAY be requested from the peer and appended to an + /// `incoming_tls` buffer that will be passed to a future + /// [`UnbufferedConnectionCommon::process_tls_records`] invocation. When enough data has been + /// appended to `incoming_tls`, [`UnbufferedConnectionCommon::process_tls_records`] will yield + /// the [`ConnectionState::ReadTraffic`] state. + WriteTraffic(WriteTraffic<'c, Data>), +} + +impl<'c, 'i, Data> From> for ConnectionState<'c, 'i, Data> { + fn from(v: ReadTraffic<'c, 'i, Data>) -> Self { + Self::ReadTraffic(v) + } +} + +impl<'c, 'i, Data> From> for ConnectionState<'c, 'i, Data> { + fn from(v: ReadEarlyData<'c, 'i, Data>) -> Self { + Self::ReadEarlyData(v) + } +} + +impl<'c, Data> From> for ConnectionState<'c, '_, Data> { + fn from(v: EncodeTlsData<'c, Data>) -> Self { + Self::EncodeTlsData(v) + } +} + +impl<'c, Data> From> for ConnectionState<'c, '_, Data> { + fn from(v: TransmitTlsData<'c, Data>) -> Self { + Self::TransmitTlsData(v) + } +} + +impl fmt::Debug for ConnectionState<'_, '_, Data> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::ReadTraffic(..) => f.debug_tuple("ReadTraffic").finish(), + + Self::PeerClosed => write!(f, "PeerClosed"), + + Self::Closed => write!(f, "Closed"), + + Self::ReadEarlyData(..) => f.debug_tuple("ReadEarlyData").finish(), + + Self::EncodeTlsData(..) => f.debug_tuple("EncodeTlsData").finish(), + + Self::TransmitTlsData(..) => f + .debug_tuple("TransmitTlsData") + .finish(), + + Self::BlockedHandshake => f + .debug_tuple("BlockedHandshake") + .finish(), + + Self::WriteTraffic(..) => f.debug_tuple("WriteTraffic").finish(), + } + } +} + +/// Application data is available +pub struct ReadTraffic<'c, 'i, Data> { + conn: &'c mut UnbufferedConnectionCommon, + // for forwards compatibility; to support in-place decryption in the future + _incoming_tls: &'i mut [u8], + + // owner of the latest chunk obtained in `next_record`, as borrowed by + // `AppDataRecord` + chunk: Option>, +} + +impl<'c, 'i, Data> ReadTraffic<'c, 'i, Data> { + fn new(conn: &'c mut UnbufferedConnectionCommon, _incoming_tls: &'i mut [u8]) -> Self { + Self { + conn, + _incoming_tls, + chunk: None, + } + } + + /// Decrypts and returns the next available app-data record + // TODO deprecate in favor of `Iterator` implementation, which requires in-place decryption + pub fn next_record(&mut self) -> Option, Error>> { + self.chunk = self + .conn + .core + .common_state + .received_plaintext + .pop(); + self.chunk.as_ref().map(|chunk| { + Ok(AppDataRecord { + discard: 0, + payload: chunk, + }) + }) + } + + /// Returns the payload size of the next app-data record *without* decrypting it + /// + /// Returns `None` if there are no more app-data records + pub fn peek_len(&self) -> Option { + self.conn + .core + .common_state + .received_plaintext + .peek() + .and_then(|ch| NonZeroUsize::new(ch.len())) + } +} + +/// Early application-data is available. +pub struct ReadEarlyData<'c, 'i, Data> { + conn: &'c mut UnbufferedConnectionCommon, + + // for forwards compatibility; to support in-place decryption in the future + _incoming_tls: &'i mut [u8], + + // owner of the latest chunk obtained in `next_record`, as borrowed by + // `AppDataRecord` + chunk: Option>, +} + +impl<'c, 'i> ReadEarlyData<'c, 'i, ServerConnectionData> { + fn new( + conn: &'c mut UnbufferedConnectionCommon, + _incoming_tls: &'i mut [u8], + ) -> Self { + Self { + conn, + _incoming_tls, + chunk: None, + } + } + + /// decrypts and returns the next available app-data record + // TODO deprecate in favor of `Iterator` implementation, which requires in-place decryption + pub fn next_record(&mut self) -> Option, Error>> { + self.chunk = self.conn.pop_early_data(); + self.chunk.as_ref().map(|chunk| { + Ok(AppDataRecord { + discard: 0, + payload: chunk, + }) + }) + } + + /// returns the payload size of the next app-data record *without* decrypting it + /// + /// returns `None` if there are no more app-data records + pub fn peek_len(&self) -> Option { + self.conn + .peek_early_data() + .and_then(|ch| NonZeroUsize::new(ch.len())) + } +} + +/// A decrypted application-data record +pub struct AppDataRecord<'i> { + /// Number of additional bytes to discard + /// + /// This number MUST be added to the value of [`UnbufferedStatus::discard`] *prior* to the + /// discard operation. See [`UnbufferedStatus::discard`] for more details + pub discard: usize, + + /// The payload of the app-data record + pub payload: &'i [u8], +} + +/// Allows encrypting app-data +pub struct WriteTraffic<'c, Data> { + conn: &'c mut UnbufferedConnectionCommon, +} + +impl WriteTraffic<'_, Data> { + /// Encrypts `application_data` into the `outgoing_tls` buffer + /// + /// Returns the number of bytes that were written into `outgoing_tls`, or an error if + /// the provided buffer is too small. In the error case, `outgoing_tls` is not modified + pub fn encrypt( + &mut self, + application_data: &[u8], + outgoing_tls: &mut [u8], + ) -> Result { + self.conn + .core + .maybe_refresh_traffic_keys(); + self.conn + .core + .common_state + .write_plaintext(application_data.into(), outgoing_tls) + } + + /// Encrypts a close_notify warning alert in `outgoing_tls` + /// + /// Returns the number of bytes that were written into `outgoing_tls`, or an error if + /// the provided buffer is too small. In the error case, `outgoing_tls` is not modified + pub fn queue_close_notify(&mut self, outgoing_tls: &mut [u8]) -> Result { + self.conn + .core + .common_state + .eager_send_close_notify(outgoing_tls) + } + + /// Arranges for a TLS1.3 `key_update` to be sent. + /// + /// This consumes the `WriteTraffic` state: to actually send the message, + /// call [`UnbufferedConnectionCommon::process_tls_records`] again which will + /// return a `ConnectionState::EncodeTlsData` that emits the `key_update` + /// message. + /// + /// See [`ConnectionCommon::refresh_traffic_keys()`] for full documentation, + /// including why you might call this and in what circumstances it will fail. + /// + /// [`ConnectionCommon::refresh_traffic_keys()`]: crate::ConnectionCommon::refresh_traffic_keys + pub fn refresh_traffic_keys(self) -> Result<(), Error> { + self.conn.core.refresh_traffic_keys() + } +} + +/// A handshake record must be encoded +pub struct EncodeTlsData<'c, Data> { + conn: &'c mut UnbufferedConnectionCommon, + chunk: Option>, +} + +impl<'c, Data> EncodeTlsData<'c, Data> { + fn new(conn: &'c mut UnbufferedConnectionCommon, chunk: Vec) -> Self { + Self { + conn, + chunk: Some(chunk), + } + } + + /// Encodes a handshake record into the `outgoing_tls` buffer + /// + /// Returns the number of bytes that were written into `outgoing_tls`, or an error if + /// the provided buffer is too small. In the error case, `outgoing_tls` is not modified + pub fn encode(&mut self, outgoing_tls: &mut [u8]) -> Result { + let Some(chunk) = self.chunk.take() else { + return Err(EncodeError::AlreadyEncoded); + }; + + let required_size = chunk.len(); + + if required_size > outgoing_tls.len() { + self.chunk = Some(chunk); + Err(InsufficientSizeError { required_size }.into()) + } else { + let written = chunk.len(); + outgoing_tls[..written].copy_from_slice(&chunk); + + self.conn.wants_write = true; + + Ok(written) + } + } +} + +/// Previously encoded TLS data must be transmitted +pub struct TransmitTlsData<'c, Data> { + pub(crate) conn: &'c mut UnbufferedConnectionCommon, +} + +impl TransmitTlsData<'_, Data> { + /// Signals that the previously encoded TLS data has been transmitted + pub fn done(self) { + self.conn.wants_write = false; + } + + /// Returns an adapter that allows encrypting application data + /// + /// If allowed at this stage of the handshake process + pub fn may_encrypt_app_data(&mut self) -> Option> { + if self + .conn + .core + .common_state + .may_send_application_data + { + Some(WriteTraffic { conn: self.conn }) + } else { + None + } + } +} + +/// Errors that may arise when encoding a handshake record +#[derive(Debug)] +pub enum EncodeError { + /// Provided buffer was too small + InsufficientSize(InsufficientSizeError), + + /// The handshake record has already been encoded; do not call `encode` again + AlreadyEncoded, +} + +impl From for EncodeError { + fn from(v: InsufficientSizeError) -> Self { + Self::InsufficientSize(v) + } +} + +impl fmt::Display for EncodeError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::InsufficientSize(InsufficientSizeError { required_size }) => write!( + f, + "cannot encode due to insufficient size, {required_size} bytes are required" + ), + Self::AlreadyEncoded => "cannot encode, data has already been encoded".fmt(f), + } + } +} + +#[cfg(feature = "std")] +impl StdError for EncodeError {} + +/// Errors that may arise when encrypting application data +#[derive(Debug)] +pub enum EncryptError { + /// Provided buffer was too small + InsufficientSize(InsufficientSizeError), + + /// Encrypter has been exhausted + EncryptExhausted, +} + +impl From for EncryptError { + fn from(v: InsufficientSizeError) -> Self { + Self::InsufficientSize(v) + } +} + +impl fmt::Display for EncryptError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::InsufficientSize(InsufficientSizeError { required_size }) => write!( + f, + "cannot encrypt due to insufficient size, {required_size} bytes are required" + ), + Self::EncryptExhausted => f.write_str("encrypter has been exhausted"), + } + } +} + +#[cfg(feature = "std")] +impl StdError for EncryptError {} + +/// Provided buffer was too small +#[derive(Clone, Copy, Debug)] +pub struct InsufficientSizeError { + /// buffer must be at least this size + pub required_size: usize, +} diff --git a/http/vendor/rustls/src/crypto/aws_lc_rs/hpke.rs b/http/vendor/rustls/src/crypto/aws_lc_rs/hpke.rs new file mode 100644 index 0000000..2e5c3a5 --- /dev/null +++ b/http/vendor/rustls/src/crypto/aws_lc_rs/hpke.rs @@ -0,0 +1,1191 @@ +use alloc::boxed::Box; +use alloc::vec::Vec; +use core::fmt::{self, Debug, Formatter}; + +use aws_lc_rs::aead::{ + self, Aad, BoundKey, NONCE_LEN, Nonce, NonceSequence, OpeningKey, SealingKey, UnboundKey, +}; +use aws_lc_rs::agreement; +use aws_lc_rs::cipher::{AES_128_KEY_LEN, AES_256_KEY_LEN}; +use aws_lc_rs::digest::{SHA256_OUTPUT_LEN, SHA384_OUTPUT_LEN, SHA512_OUTPUT_LEN}; +use aws_lc_rs::encoding::{AsBigEndian, Curve25519SeedBin, EcPrivateKeyBin}; +use zeroize::Zeroize; + +use crate::crypto::aws_lc_rs::hmac::{HMAC_SHA256, HMAC_SHA384, HMAC_SHA512}; +use crate::crypto::aws_lc_rs::unspecified_err; +use crate::crypto::hpke::{ + EncapsulatedSecret, Hpke, HpkeOpener, HpkePrivateKey, HpkePublicKey, HpkeSealer, HpkeSuite, +}; +use crate::crypto::tls13::{HkdfExpander, HkdfPrkExtract, HkdfUsingHmac, expand}; +use crate::msgs::enums::{HpkeAead, HpkeKdf, HpkeKem}; +use crate::msgs::handshake::HpkeSymmetricCipherSuite; +#[cfg(feature = "std")] +use crate::sync::Arc; +use crate::{Error, OtherError}; + +/// Default [RFC 9180] Hybrid Public Key Encryption (HPKE) suites supported by aws-lc-rs cryptography. +pub static ALL_SUPPORTED_SUITES: &[&dyn Hpke] = &[ + DH_KEM_P256_HKDF_SHA256_AES_128, + DH_KEM_P256_HKDF_SHA256_AES_256, + #[cfg(not(feature = "fips"))] + DH_KEM_P256_HKDF_SHA256_CHACHA20_POLY1305, + DH_KEM_P384_HKDF_SHA384_AES_128, + DH_KEM_P384_HKDF_SHA384_AES_256, + #[cfg(not(feature = "fips"))] + DH_KEM_P384_HKDF_SHA384_CHACHA20_POLY1305, + DH_KEM_P521_HKDF_SHA512_AES_128, + DH_KEM_P521_HKDF_SHA512_AES_256, + #[cfg(not(feature = "fips"))] + DH_KEM_P521_HKDF_SHA512_CHACHA20_POLY1305, + #[cfg(not(feature = "fips"))] + DH_KEM_X25519_HKDF_SHA256_AES_128, + #[cfg(not(feature = "fips"))] + DH_KEM_X25519_HKDF_SHA256_AES_256, + #[cfg(not(feature = "fips"))] + DH_KEM_X25519_HKDF_SHA256_CHACHA20_POLY1305, +]; + +/// HPKE suite using ECDH P-256 for agreement, HKDF SHA-256 for key derivation, and AEAD AES-128-GCM +/// for symmetric encryption. +pub static DH_KEM_P256_HKDF_SHA256_AES_128: &HpkeAwsLcRs = + &HpkeAwsLcRs { + suite: HpkeSuite { + kem: HpkeKem::DHKEM_P256_HKDF_SHA256, + sym: HpkeSymmetricCipherSuite { + kdf_id: HpkeKdf::HKDF_SHA256, + aead_id: HpkeAead::AES_128_GCM, + }, + }, + dh_kem: DH_KEM_P256_HKDF_SHA256, + hkdf: RING_HKDF_HMAC_SHA256, + aead: &aead::AES_128_GCM, + }; + +/// HPKE suite using ECDH P-256 for agreement, HKDF SHA-256 for key derivation and AEAD AES-256-GCM +/// for symmetric encryption. +pub static DH_KEM_P256_HKDF_SHA256_AES_256: &HpkeAwsLcRs = + &HpkeAwsLcRs { + suite: HpkeSuite { + kem: HpkeKem::DHKEM_P256_HKDF_SHA256, + sym: HpkeSymmetricCipherSuite { + kdf_id: HpkeKdf::HKDF_SHA256, + aead_id: HpkeAead::AES_256_GCM, + }, + }, + dh_kem: DH_KEM_P256_HKDF_SHA256, + hkdf: RING_HKDF_HMAC_SHA256, + aead: &aead::AES_256_GCM, + }; + +/// HPKE suite using ECDH P-256 for agreement, HKDF SHA-256 for key derivation, and AEAD +/// CHACHA20-POLY-1305 for symmetric encryption. +pub static DH_KEM_P256_HKDF_SHA256_CHACHA20_POLY1305: &HpkeAwsLcRs< + CHACHA_KEY_LEN, + SHA256_OUTPUT_LEN, +> = &HpkeAwsLcRs { + suite: HpkeSuite { + kem: HpkeKem::DHKEM_P256_HKDF_SHA256, + sym: HpkeSymmetricCipherSuite { + kdf_id: HpkeKdf::HKDF_SHA256, + aead_id: HpkeAead::CHACHA20_POLY_1305, + }, + }, + dh_kem: DH_KEM_P256_HKDF_SHA256, + hkdf: RING_HKDF_HMAC_SHA256, + aead: &aead::CHACHA20_POLY1305, +}; + +/// HPKE suite using ECDH P-384 for agreement, HKDF SHA-384 for key derivation, and AEAD AES-128-GCM +/// for symmetric encryption. +pub static DH_KEM_P384_HKDF_SHA384_AES_128: &HpkeAwsLcRs = + &HpkeAwsLcRs { + suite: HpkeSuite { + kem: HpkeKem::DHKEM_P384_HKDF_SHA384, + sym: HpkeSymmetricCipherSuite { + kdf_id: HpkeKdf::HKDF_SHA384, + aead_id: HpkeAead::AES_128_GCM, + }, + }, + dh_kem: DH_KEM_P384_HKDF_SHA384, + hkdf: RING_HKDF_HMAC_SHA384, + aead: &aead::AES_128_GCM, + }; + +/// HPKE suite using ECDH P-384 for agreement, HKDF SHA-384 for key derivation, and AEAD AES-256-GCM +/// for symmetric encryption. +pub static DH_KEM_P384_HKDF_SHA384_AES_256: &HpkeAwsLcRs = + &HpkeAwsLcRs { + suite: HpkeSuite { + kem: HpkeKem::DHKEM_P384_HKDF_SHA384, + sym: HpkeSymmetricCipherSuite { + kdf_id: HpkeKdf::HKDF_SHA384, + aead_id: HpkeAead::AES_256_GCM, + }, + }, + dh_kem: DH_KEM_P384_HKDF_SHA384, + hkdf: RING_HKDF_HMAC_SHA384, + aead: &aead::AES_256_GCM, + }; + +/// HPKE suite using ECDH P-384 for agreement, HKDF SHA-384 for key derivation, and AEAD +/// CHACHA20-POLY-1305 for symmetric encryption. +pub static DH_KEM_P384_HKDF_SHA384_CHACHA20_POLY1305: &HpkeAwsLcRs< + CHACHA_KEY_LEN, + SHA384_OUTPUT_LEN, +> = &HpkeAwsLcRs { + suite: HpkeSuite { + kem: HpkeKem::DHKEM_P384_HKDF_SHA384, + sym: HpkeSymmetricCipherSuite { + kdf_id: HpkeKdf::HKDF_SHA384, + aead_id: HpkeAead::CHACHA20_POLY_1305, + }, + }, + dh_kem: DH_KEM_P384_HKDF_SHA384, + hkdf: RING_HKDF_HMAC_SHA384, + aead: &aead::CHACHA20_POLY1305, +}; + +/// HPKE suite using ECDH P-521 for agreement, HKDF SHA-512 for key derivation, and AEAD AES-128-GCM +/// for symmetric encryption. +pub static DH_KEM_P521_HKDF_SHA512_AES_128: &HpkeAwsLcRs = + &HpkeAwsLcRs { + suite: HpkeSuite { + kem: HpkeKem::DHKEM_P521_HKDF_SHA512, + sym: HpkeSymmetricCipherSuite { + kdf_id: HpkeKdf::HKDF_SHA512, + aead_id: HpkeAead::AES_128_GCM, + }, + }, + dh_kem: DH_KEM_P521_HKDF_SHA512, + hkdf: RING_HKDF_HMAC_SHA512, + aead: &aead::AES_128_GCM, + }; + +/// HPKE suite using ECDH P-521 for agreement, HKDF SHA-512 for key derivation, and AEAD AES-256-GCM +/// for symmetric encryption. +pub static DH_KEM_P521_HKDF_SHA512_AES_256: &HpkeAwsLcRs = + &HpkeAwsLcRs { + suite: HpkeSuite { + kem: HpkeKem::DHKEM_P521_HKDF_SHA512, + sym: HpkeSymmetricCipherSuite { + kdf_id: HpkeKdf::HKDF_SHA512, + aead_id: HpkeAead::AES_256_GCM, + }, + }, + dh_kem: DH_KEM_P521_HKDF_SHA512, + hkdf: RING_HKDF_HMAC_SHA512, + aead: &aead::AES_256_GCM, + }; + +/// HPKE suite using ECDH P-521 for agreement, HKDF SHA-512 for key derivation, and AEAD +/// CHACHA20-POLY-1305 for symmetric encryption. +pub static DH_KEM_P521_HKDF_SHA512_CHACHA20_POLY1305: &HpkeAwsLcRs< + CHACHA_KEY_LEN, + SHA512_OUTPUT_LEN, +> = &HpkeAwsLcRs { + suite: HpkeSuite { + kem: HpkeKem::DHKEM_P521_HKDF_SHA512, + sym: HpkeSymmetricCipherSuite { + kdf_id: HpkeKdf::HKDF_SHA512, + aead_id: HpkeAead::CHACHA20_POLY_1305, + }, + }, + dh_kem: DH_KEM_P521_HKDF_SHA512, + hkdf: RING_HKDF_HMAC_SHA512, + aead: &aead::CHACHA20_POLY1305, +}; + +/// HPKE suite using ECDH X25519 for agreement, HKDF SHA-256 for key derivation, and AEAD AES-128-GCM +/// for symmetric encryption. +pub static DH_KEM_X25519_HKDF_SHA256_AES_128: &HpkeAwsLcRs = + &HpkeAwsLcRs { + suite: HpkeSuite { + kem: HpkeKem::DHKEM_X25519_HKDF_SHA256, + sym: HpkeSymmetricCipherSuite { + kdf_id: HpkeKdf::HKDF_SHA256, + aead_id: HpkeAead::AES_128_GCM, + }, + }, + dh_kem: DH_KEM_X25519_HKDF_SHA256, + hkdf: RING_HKDF_HMAC_SHA256, + aead: &aead::AES_128_GCM, + }; + +/// HPKE suite using ECDH X25519 for agreement, HKDF SHA-256 for key derivation, and AEAD AES-256-GCM +/// for symmetric encryption. +pub static DH_KEM_X25519_HKDF_SHA256_AES_256: &HpkeAwsLcRs = + &HpkeAwsLcRs { + suite: HpkeSuite { + kem: HpkeKem::DHKEM_X25519_HKDF_SHA256, + sym: HpkeSymmetricCipherSuite { + kdf_id: HpkeKdf::HKDF_SHA256, + aead_id: HpkeAead::AES_256_GCM, + }, + }, + dh_kem: DH_KEM_X25519_HKDF_SHA256, + hkdf: RING_HKDF_HMAC_SHA256, + aead: &aead::AES_256_GCM, + }; + +/// HPKE suite using ECDH X25519 for agreement, HKDF SHA-256 for key derivation, and AEAD +/// CHACHA20-POLY-1305 for symmetric encryption. +pub static DH_KEM_X25519_HKDF_SHA256_CHACHA20_POLY1305: &HpkeAwsLcRs< + CHACHA_KEY_LEN, + SHA256_OUTPUT_LEN, +> = &HpkeAwsLcRs { + suite: HpkeSuite { + kem: HpkeKem::DHKEM_X25519_HKDF_SHA256, + sym: HpkeSymmetricCipherSuite { + kdf_id: HpkeKdf::HKDF_SHA256, + aead_id: HpkeAead::CHACHA20_POLY_1305, + }, + }, + dh_kem: DH_KEM_X25519_HKDF_SHA256, + hkdf: RING_HKDF_HMAC_SHA256, + aead: &aead::CHACHA20_POLY1305, +}; + +/// `HpkeAwsLcRs` holds the concrete instantiations of the algorithms specified by the [HpkeSuite]. +pub struct HpkeAwsLcRs { + suite: HpkeSuite, + dh_kem: &'static DhKem, + hkdf: &'static dyn HkdfPrkExtract, + aead: &'static aead::Algorithm, +} + +impl HpkeAwsLcRs { + /// See [RFC 9180 §5.1 "Creating the Encryption Context"][0]. + /// + /// [0]: https://www.rfc-editor.org/rfc/rfc9180.html#section-5.1 + fn key_schedule( + &self, + shared_secret: KemSharedSecret, + info: &[u8], + ) -> Result, Error> { + // Note: we use an empty IKM for the `psk_id_hash` and `secret` labelled extractions because + // there is no PSK ID in base mode HPKE. + + let suite_id = LabeledSuiteId::Hpke(self.suite); + let psk_id_hash = labeled_extract_for_prk(self.hkdf, suite_id, None, Label::PskIdHash, &[]); + let info_hash = labeled_extract_for_prk(self.hkdf, suite_id, None, Label::InfoHash, info); + let key_schedule_context = [ + &[0][..], // base mode (0x00) + &psk_id_hash, + &info_hash, + ] + .concat(); + + let key = AeadKey(self.key_schedule_labeled_expand::( + &shared_secret, + &key_schedule_context, + Label::Key, + )); + + let base_nonce = self.key_schedule_labeled_expand::( + &shared_secret, + &key_schedule_context, + Label::BaseNonce, + ); + + Ok(KeySchedule { + aead: self.aead, + key, + base_nonce, + seq_num: 0, + }) + } + + fn key_schedule_labeled_expand( + &self, + shared_secret: &KemSharedSecret, + key_schedule_context: &[u8], + label: Label, + ) -> [u8; L] { + let suite_id = LabeledSuiteId::Hpke(self.suite); + labeled_expand::( + suite_id, + labeled_extract_for_expand( + self.hkdf, + suite_id, + Some(&shared_secret.0), + Label::Secret, + &[], + ), + label, + key_schedule_context, + ) + } +} + +impl Hpke for HpkeAwsLcRs { + fn seal( + &self, + info: &[u8], + aad: &[u8], + plaintext: &[u8], + pub_key: &HpkePublicKey, + ) -> Result<(EncapsulatedSecret, Vec), Error> { + let (encap, mut sealer) = self.setup_sealer(info, pub_key)?; + Ok((encap, sealer.seal(aad, plaintext)?)) + } + + fn setup_sealer( + &self, + info: &[u8], + pub_key: &HpkePublicKey, + ) -> Result<(EncapsulatedSecret, Box), Error> { + let (encap, sealer) = Sealer::new(self, info, pub_key)?; + Ok((encap, Box::new(sealer))) + } + + fn open( + &self, + enc: &EncapsulatedSecret, + info: &[u8], + aad: &[u8], + ciphertext: &[u8], + secret_key: &HpkePrivateKey, + ) -> Result, Error> { + self.setup_opener(enc, info, secret_key)? + .open(aad, ciphertext) + } + + fn setup_opener( + &self, + enc: &EncapsulatedSecret, + info: &[u8], + secret_key: &HpkePrivateKey, + ) -> Result, Error> { + Ok(Box::new(Opener::new(self, enc, info, secret_key)?)) + } + + fn fips(&self) -> bool { + matches!( + // We make a FIPS determination based on the suite's DH KEM and AEAD choice. + // We don't need to examine the KDF choice because all supported KDFs are FIPS + // compatible. + (self.suite.kem, self.suite.sym.aead_id), + ( + // Only the NIST "P-curve" DH KEMs are FIPS compatible. + HpkeKem::DHKEM_P256_HKDF_SHA256 + | HpkeKem::DHKEM_P384_HKDF_SHA384 + | HpkeKem::DHKEM_P521_HKDF_SHA512, + // Only the AES AEADs are FIPS compatible. + HpkeAead::AES_128_GCM | HpkeAead::AES_256_GCM, + ) + ) + } + + fn generate_key_pair(&self) -> Result<(HpkePublicKey, HpkePrivateKey), Error> { + (self.dh_kem.key_generator)() + } + + fn suite(&self) -> HpkeSuite { + self.suite + } +} + +impl Debug for HpkeAwsLcRs { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + self.suite.fmt(f) + } +} + +/// Adapts a [KeySchedule] and [AeadKey] for the role of a [HpkeSealer]. +struct Sealer { + key_schedule: KeySchedule, +} + +impl Sealer { + /// See [RFC 9180 §5.1.1 "Encryption to a Public Key"][0]. + /// + /// [0]: https://www.rfc-editor.org/rfc/rfc9180.html#section-5.1.1 + fn new( + suite: &HpkeAwsLcRs, + info: &[u8], + pub_key: &HpkePublicKey, + ) -> Result<(EncapsulatedSecret, Self), Error> { + // def SetupBaseS(pkR, info): + // shared_secret, enc = Encap(pkR) + // return enc, KeyScheduleS(mode_base, shared_secret, info, + // default_psk, default_psk_id) + + let (shared_secret, enc) = suite.dh_kem.encap(pub_key)?; + let key_schedule = suite.key_schedule(shared_secret, info)?; + Ok((enc, Self { key_schedule })) + } + + /// A **test only** constructor that uses a pre-specified ephemeral agreement private key + /// instead of one that is randomly generated. + #[cfg(test)] + fn test_only_new( + suite: &HpkeAwsLcRs, + info: &[u8], + pub_key: &HpkePublicKey, + sk_e: &[u8], + ) -> Result<(EncapsulatedSecret, Self), Error> { + let (shared_secret, enc) = suite + .dh_kem + .test_only_encap(pub_key, sk_e)?; + let key_schedule = suite.key_schedule(shared_secret, info)?; + Ok((enc, Self { key_schedule })) + } +} + +impl HpkeSealer for Sealer { + fn seal(&mut self, aad: &[u8], plaintext: &[u8]) -> Result, Error> { + // def ContextS.Seal(aad, pt): + // ct = Seal(self.key, self.ComputeNonce(self.seq), aad, pt) + // self.IncrementSeq() + // return ct + + let key = UnboundKey::new(self.key_schedule.aead, &self.key_schedule.key.0) + .map_err(unspecified_err)?; + let mut sealing_key = SealingKey::new(key, &mut self.key_schedule); + + let mut in_out_buffer = Vec::from(plaintext); + sealing_key + .seal_in_place_append_tag(Aad::from(aad), &mut in_out_buffer) + .map_err(unspecified_err)?; + + Ok(in_out_buffer) + } +} + +impl Debug for Sealer { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.debug_struct("Sealer").finish() + } +} + +/// Adapts a [KeySchedule] and [AeadKey] for the role of a [HpkeOpener]. +struct Opener { + key_schedule: KeySchedule, +} + +impl Opener { + /// See [RFC 9180 §5.1.1 "Encryption to a Public Key"][0]. + /// + /// [0]: https://www.rfc-editor.org/rfc/rfc9180.html#section-5.1.1 + fn new( + suite: &HpkeAwsLcRs, + enc: &EncapsulatedSecret, + info: &[u8], + secret_key: &HpkePrivateKey, + ) -> Result { + // def SetupBaseR(enc, skR, info): + // shared_secret = Decap(enc, skR) + // return KeyScheduleR(mode_base, shared_secret, info, + // default_psk, default_psk_id) + Ok(Self { + key_schedule: suite.key_schedule(suite.dh_kem.decap(enc, secret_key)?, info)?, + }) + } +} + +impl HpkeOpener for Opener { + fn open(&mut self, aad: &[u8], ciphertext: &[u8]) -> Result, Error> { + // def ContextR.Open(aad, ct): + // pt = Open(self.key, self.ComputeNonce(self.seq), aad, ct) + // if pt == OpenError: + // raise OpenError + // self.IncrementSeq() + // return pt + + let key = UnboundKey::new(self.key_schedule.aead, &self.key_schedule.key.0) + .map_err(unspecified_err)?; + let mut opening_key = OpeningKey::new(key, &mut self.key_schedule); + + let mut in_out_buffer = Vec::from(ciphertext); + let plaintext = opening_key + .open_in_place(Aad::from(aad), &mut in_out_buffer) + .map_err(unspecified_err)?; + + Ok(plaintext.to_vec()) + } +} + +impl Debug for Opener { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.debug_struct("Opener").finish() + } +} + +/// A Diffie-Hellman (DH) based Key Encapsulation Mechanism (KEM). +/// +/// See [RFC 9180 §4.1 "DH-Based KEM (DHKEM)"][0]. +/// +/// [0]: https://www.rfc-editor.org/rfc/rfc9180.html#section-4.1 +struct DhKem { + id: HpkeKem, + agreement_algorithm: &'static agreement::Algorithm, + key_generator: + &'static (dyn Fn() -> Result<(HpkePublicKey, HpkePrivateKey), Error> + Send + Sync), + hkdf: &'static dyn HkdfPrkExtract, +} + +impl DhKem { + /// See [RFC 9180 §4.1 "DH-Based KEM (DHKEM)"][0]. + /// + /// [0]: https://www.rfc-editor.org/rfc/rfc9180.html#section-4.1 + fn encap( + &self, + recipient: &HpkePublicKey, + ) -> Result<(KemSharedSecret, EncapsulatedSecret), Error> { + // def Encap(pkR): + // skE, pkE = GenerateKeyPair() + + let sk_e = + agreement::PrivateKey::generate(self.agreement_algorithm).map_err(unspecified_err)?; + self.encap_impl(recipient, sk_e) + } + + /// A test-only encap operation that uses a fixed `test_only_ske` instead of generating + /// one randomly. + #[cfg(test)] + fn test_only_encap( + &self, + recipient: &HpkePublicKey, + test_only_ske: &[u8], + ) -> Result<(KemSharedSecret, EncapsulatedSecret), Error> { + // For test contexts only, we accept a static sk_e as an argument. + let sk_e = agreement::PrivateKey::from_private_key(self.agreement_algorithm, test_only_ske) + .map_err(key_rejected_err)?; + self.encap_impl(recipient, sk_e) + } + + fn encap_impl( + &self, + recipient: &HpkePublicKey, + sk_e: agreement::PrivateKey, + ) -> Result<(KemSharedSecret, EncapsulatedSecret), Error> { + // def Encap(pkR): + // skE, pkE = GenerateKeyPair() + // dh = DH(skE, pkR) + // enc = SerializePublicKey(pkE) + // + // pkRm = SerializePublicKey(pkR) + // kem_context = concat(enc, pkRm) + // + // shared_secret = ExtractAndExpand(dh, kem_context) + // return shared_secret, enc + + let enc = sk_e + .compute_public_key() + .map_err(unspecified_err)?; + let pk_r = agreement::UnparsedPublicKey::new(self.agreement_algorithm, &recipient.0); + let kem_context = [enc.as_ref(), pk_r.bytes()].concat(); + + let shared_secret = agreement::agree(&sk_e, pk_r, aws_lc_rs::error::Unspecified, |dh| { + Ok(self.extract_and_expand(dh, &kem_context)) + }) + .map_err(unspecified_err)?; + + Ok(( + KemSharedSecret(shared_secret), + EncapsulatedSecret(enc.as_ref().into()), + )) + } + + /// See [RFC 9180 §4.1 "DH-Based KEM (DHKEM)"][0]. + /// + /// [0]: https://www.rfc-editor.org/rfc/rfc9180.html#section-4.1 + fn decap( + &self, + enc: &EncapsulatedSecret, + recipient: &HpkePrivateKey, + ) -> Result, Error> { + // def Decap(enc, skR): + // pkE = DeserializePublicKey(enc) + // dh = DH(skR, pkE) + // + // pkRm = SerializePublicKey(pk(skR)) + // kem_context = concat(enc, pkRm) + // + // shared_secret = ExtractAndExpand(dh, kem_context) + // return shared_secret + + let pk_e = agreement::UnparsedPublicKey::new(self.agreement_algorithm, &enc.0); + let sk_r = agreement::PrivateKey::from_private_key( + self.agreement_algorithm, + recipient.secret_bytes(), + ) + .map_err(key_rejected_err)?; + let pk_rm = sk_r + .compute_public_key() + .map_err(unspecified_err)?; + let kem_context = [&enc.0, pk_rm.as_ref()].concat(); + + let shared_secret = agreement::agree(&sk_r, pk_e, aws_lc_rs::error::Unspecified, |dh| { + Ok(self.extract_and_expand(dh, &kem_context)) + }) + .map_err(unspecified_err)?; + + Ok(KemSharedSecret(shared_secret)) + } + + /// See [RFC 9180 §4.1 "DH-Based KEM (DHKEM)"][0]. + /// + /// [0]: https://www.rfc-editor.org/rfc/rfc9180.html#section-4.1 + fn extract_and_expand(&self, dh: &[u8], kem_context: &[u8]) -> [u8; KDF_SIZE] { + // def ExtractAndExpand(dh, kem_context): + // eae_prk = LabeledExtract("", "eae_prk", dh) + // shared_secret = LabeledExpand(eae_prk, "shared_secret", + // kem_context, Nsecret) + // return shared_secret + + let suite_id = LabeledSuiteId::Kem(self.id); + labeled_expand( + suite_id, + labeled_extract_for_expand(self.hkdf, suite_id, None, Label::EaePrk, dh), + Label::SharedSecret, + kem_context, + ) + } +} + +static DH_KEM_P256_HKDF_SHA256: &DhKem = &DhKem { + id: HpkeKem::DHKEM_P256_HKDF_SHA256, + agreement_algorithm: &agreement::ECDH_P256, + key_generator: &|| generate_p_curve_key_pair(&agreement::ECDH_P256), + hkdf: RING_HKDF_HMAC_SHA256, +}; + +static DH_KEM_P384_HKDF_SHA384: &DhKem = &DhKem { + id: HpkeKem::DHKEM_P384_HKDF_SHA384, + agreement_algorithm: &agreement::ECDH_P384, + key_generator: &|| generate_p_curve_key_pair(&agreement::ECDH_P384), + hkdf: RING_HKDF_HMAC_SHA384, +}; + +static DH_KEM_P521_HKDF_SHA512: &DhKem = &DhKem { + id: HpkeKem::DHKEM_P521_HKDF_SHA512, + agreement_algorithm: &agreement::ECDH_P521, + key_generator: &|| generate_p_curve_key_pair(&agreement::ECDH_P521), + hkdf: RING_HKDF_HMAC_SHA512, +}; + +static DH_KEM_X25519_HKDF_SHA256: &DhKem = &DhKem { + id: HpkeKem::DHKEM_X25519_HKDF_SHA256, + agreement_algorithm: &agreement::X25519, + key_generator: &generate_x25519_key_pair, + hkdf: RING_HKDF_HMAC_SHA256, +}; + +/// Generate a NIST P-256, P-384 or P-512 key pair expressed as a raw big-endian fixed-length +/// integer. +/// +/// We must disambiguate the [`AsBigEndian`] trait in-use and this function uses +/// [`AsBigEndian`], which does not support [`agreement::X25519`]. +/// For generating X25519 keys see [`generate_x25519_key_pair`]. +fn generate_p_curve_key_pair( + alg: &'static agreement::Algorithm, +) -> Result<(HpkePublicKey, HpkePrivateKey), Error> { + // We only initialize DH KEM instances that use this function as a key generator + // for non-X25519 algorithms. Debug assert this just in case since `AsBigEndian` + // will panic for this algorithm. + debug_assert_ne!(alg, &agreement::X25519); + let (public_key, private_key) = generate_key_pair(alg)?; + let raw_private_key: EcPrivateKeyBin<'_> = private_key + .as_be_bytes() + .map_err(unspecified_err)?; + Ok(( + public_key, + HpkePrivateKey::from(raw_private_key.as_ref().to_vec()), + )) +} + +/// Generate a X25519 key pair expressed as a raw big-endian fixed-length +/// integer. +/// +/// We must disambiguate the [`AsBigEndian`] trait in-use and this function uses +/// [`AsBigEndian`], which only supports [`agreement::X25519`]. +/// For generating P-256, P-384 and P-512 keys see [`generate_p_curve_key_pair`]. +fn generate_x25519_key_pair() -> Result<(HpkePublicKey, HpkePrivateKey), Error> { + let (public_key, private_key) = generate_key_pair(&agreement::X25519)?; + let raw_private_key: Curve25519SeedBin<'_> = private_key + .as_be_bytes() + .map_err(unspecified_err)?; + Ok(( + public_key, + HpkePrivateKey::from(raw_private_key.as_ref().to_vec()), + )) +} + +fn generate_key_pair( + alg: &'static agreement::Algorithm, +) -> Result<(HpkePublicKey, agreement::PrivateKey), Error> { + let private_key = agreement::PrivateKey::generate(alg).map_err(unspecified_err)?; + let public_key = HpkePublicKey( + private_key + .compute_public_key() + .map_err(unspecified_err)? + .as_ref() + .to_vec(), + ); + Ok((public_key, private_key)) +} + +/// KeySchedule holds the derived AEAD key, base nonce, and seq number +/// common to both a [Sealer] and [Opener]. +struct KeySchedule { + aead: &'static aead::Algorithm, + key: AeadKey, + base_nonce: [u8; NONCE_LEN], + seq_num: u32, +} + +impl KeySchedule { + /// See [RFC 9180 §5.2 "Encryption and Decryption"][0]. + /// + /// [0]: https://www.rfc-editor.org/rfc/rfc9180.html#section-5.2 + fn compute_nonce(&self) -> [u8; NONCE_LEN] { + // def Context.ComputeNonce(seq): + // seq_bytes = I2OSP(seq, Nn) + // return xor(self.base_nonce, seq_bytes) + + // Each new N-byte nonce is conceptually two parts: + // * N-4 bytes of the base nonce (0s in `nonce` to XOR in as-is). + // * 4 bytes derived from the sequence number XOR the base nonce. + let mut nonce = [0; NONCE_LEN]; + let seq_bytes = self.seq_num.to_be_bytes(); + nonce[NONCE_LEN - seq_bytes.len()..].copy_from_slice(&seq_bytes); + + for (n, &b) in nonce.iter_mut().zip(&self.base_nonce) { + *n ^= b; + } + + nonce + } + + /// See [RFC 9180 §5.2 "Encryption and Decryption"][0]. + /// + /// [0]: https://www.rfc-editor.org/rfc/rfc9180.html#section-5.2 + fn increment_seq_num(&mut self) -> Result<(), aws_lc_rs::error::Unspecified> { + // def Context.IncrementSeq(): + // if self.seq >= (1 << (8*Nn)) - 1: + // raise MessageLimitReachedError + // self.seq += 1 + + // Determine the maximum sequence number using the AEAD nonce's length in bits. + // Do this as an u128 to prevent overflowing. + let max_seq_num = (1u128 << (NONCE_LEN * 8)) - 1; + + // Promote the u32 sequence number to an u128 and compare against the maximum allowed + // sequence number. + if u128::from(self.seq_num) >= max_seq_num { + return Err(aws_lc_rs::error::Unspecified); + } + + self.seq_num += 1; + Ok(()) + } +} + +impl NonceSequence for &mut KeySchedule { + fn advance(&mut self) -> Result { + let nonce = self.compute_nonce(); + self.increment_seq_num()?; + Nonce::try_assume_unique_for_key(&nonce) + } +} + +/// See [RFC 9180 §4 "Cryptographic Dependencies"][0]. +/// +/// [0]: https://www.rfc-editor.org/rfc/rfc9180.html#section-4 +fn labeled_extract_for_expand( + hkdf: &'static dyn HkdfPrkExtract, + suite_id: LabeledSuiteId, + salt: Option<&[u8]>, + label: Label, + ikm: &[u8], +) -> Box { + // def LabeledExtract(salt, label, ikm): + // labeled_ikm = concat("HPKE-v1", suite_id, label, ikm) + // return Extract(salt, labeled_ikm) + + let labeled_ikm = [&b"HPKE-v1"[..], &suite_id.encoded(), label.as_ref(), ikm].concat(); + hkdf.extract_from_secret(salt, &labeled_ikm) +} + +/// See [RFC 9180 §4 "Cryptographic Dependencies"][0]. +/// +/// [0]: https://www.rfc-editor.org/rfc/rfc9180.html#section-4 +fn labeled_extract_for_prk( + hkdf: &'static dyn HkdfPrkExtract, + suite_id: LabeledSuiteId, + salt: Option<&[u8]>, + label: Label, + ikm: &[u8], +) -> Vec { + // def LabeledExtract(salt, label, ikm): + // labeled_ikm = concat("HPKE-v1", suite_id, label, ikm) + // return Extract(salt, labeled_ikm) + + let labeled_ikm = [&b"HPKE-v1"[..], &suite_id.encoded(), label.as_ref(), ikm].concat(); + hkdf.extract_prk_from_secret(salt, &labeled_ikm) +} + +/// See [RFC 9180 §4 "Cryptographic Dependencies"][0]. +/// +/// [0]: https://www.rfc-editor.org/rfc/rfc9180.html#section-4 +fn labeled_expand( + suite_id: LabeledSuiteId, + expander: Box, + label: Label, + kem_context: &[u8], +) -> [u8; L] { + // def LabeledExpand(prk, label, info, L): + // labeled_info = concat(I2OSP(L, 2), "HPKE-v1", suite_id, + // label, info) + // return Expand(prk, labeled_info, L) + + let output_len = u16::to_be_bytes(L as u16); + let info = &[ + &output_len[..], + b"HPKE-v1", + &suite_id.encoded(), + label.as_ref(), + kem_context, + ]; + + expand(&*expander, info) +} + +/// Label describes the possible labels for use with [labeled_extract_for_expand] and [labeled_expand]. +#[derive(Debug)] +enum Label { + PskIdHash, + InfoHash, + Secret, + Key, + BaseNonce, + EaePrk, + SharedSecret, +} + +impl AsRef<[u8]> for Label { + fn as_ref(&self) -> &[u8] { + match self { + Self::PskIdHash => b"psk_id_hash", + Self::InfoHash => b"info_hash", + Self::Secret => b"secret", + Self::Key => b"key", + Self::BaseNonce => b"base_nonce", + Self::EaePrk => b"eae_prk", + Self::SharedSecret => b"shared_secret", + } + } +} + +/// LabeledSuiteId describes the possible suite ID values for use with [labeled_extract_for_expand] and +/// [labeled_expand]. +#[derive(Debug, Copy, Clone)] +enum LabeledSuiteId { + Hpke(HpkeSuite), + Kem(HpkeKem), +} + +impl LabeledSuiteId { + /// The suite ID encoding depends on the context of use. In the general HPKE context, + /// we use a "HPKE" prefix and encode the entire ciphersuite. In the KEM context we use a + /// "KEM" prefix and only encode the KEM ID. + /// + /// See the bottom of [RFC 9180 §4](https://www.rfc-editor.org/rfc/rfc9180.html#section-4) + /// for more information. + fn encoded(&self) -> Vec { + match self { + Self::Hpke(suite) => [ + &b"HPKE"[..], + &u16::from(suite.kem).to_be_bytes(), + &u16::from(suite.sym.kdf_id).to_be_bytes(), + &u16::from(suite.sym.aead_id).to_be_bytes(), + ] + .concat(), + Self::Kem(kem) => [&b"KEM"[..], &u16::from(*kem).to_be_bytes()].concat(), + } + } +} + +/// A newtype wrapper for an unbound AEAD key. +struct AeadKey([u8; KEY_LEN]); + +impl Drop for AeadKey { + fn drop(&mut self) { + self.0.zeroize() + } +} + +/// A newtype wrapper for a DH KEM shared secret. +struct KemSharedSecret([u8; KDF_LEN]); + +impl Drop for KemSharedSecret { + fn drop(&mut self) { + self.0.zeroize(); + } +} + +fn key_rejected_err(_e: aws_lc_rs::error::KeyRejected) -> Error { + #[cfg(feature = "std")] + { + Error::Other(OtherError(Arc::new(_e))) + } + #[cfg(not(feature = "std"))] + { + Error::Other(OtherError()) + } +} + +// The `cipher::chacha::KEY_LEN` const is not exported, so we copy it here: +// https://github.com/aws/aws-lc-rs/blob/0186ef7bb1a4d7e140bae8074a9871f49afedf1b/aws-lc-rs/src/cipher/chacha.rs#L13 +const CHACHA_KEY_LEN: usize = 32; + +static RING_HKDF_HMAC_SHA256: &HkdfUsingHmac<'static> = &HkdfUsingHmac(&HMAC_SHA256); +static RING_HKDF_HMAC_SHA384: &HkdfUsingHmac<'static> = &HkdfUsingHmac(&HMAC_SHA384); +static RING_HKDF_HMAC_SHA512: &HkdfUsingHmac<'static> = &HkdfUsingHmac(&HMAC_SHA512); + +#[cfg(test)] +mod tests { + use alloc::{format, vec}; + + use super::*; + + #[test] + fn smoke_test() { + for suite in ALL_SUPPORTED_SUITES { + _ = format!("{suite:?}"); // HpkeAwsLcRs suites should be Debug. + + // We should be able to generate a random keypair. + let (pk, sk) = suite.generate_key_pair().unwrap(); + + // Info value corresponds to the first RFC 9180 base mode test vector. + let info = &[ + 0x4f, 0x64, 0x65, 0x20, 0x6f, 0x6e, 0x20, 0x61, 0x20, 0x47, 0x72, 0x65, 0x63, 0x69, + 0x61, 0x6e, 0x20, 0x55, 0x72, 0x6e, + ][..]; + + // We should be able to set up a sealer. + let (enc, mut sealer) = suite.setup_sealer(info, &pk).unwrap(); + + _ = format!("{sealer:?}"); // Sealer should be Debug. + + // Setting up a sealer with an invalid public key should fail. + let bad_setup_res = suite.setup_sealer(info, &HpkePublicKey(vec![])); + assert!(matches!(bad_setup_res.unwrap_err(), Error::Other(_))); + + // We should be able to seal some plaintext. + let aad = &[0xC0, 0xFF, 0xEE]; + let pt = &[0xF0, 0x0D]; + let ct = sealer.seal(aad, pt).unwrap(); + + // We should be able to set up an opener. + let mut opener = suite + .setup_opener(&enc, info, &sk) + .unwrap(); + _ = format!("{opener:?}"); // Opener should be Debug. + + // Setting up an opener with an invalid private key should fail. + let bad_key_res = suite.setup_opener(&enc, info, &HpkePrivateKey::from(vec![])); + assert!(matches!(bad_key_res.unwrap_err(), Error::Other(_))); + + // Opening the plaintext should work with the correct opener and aad. + let pt_prime = opener.open(aad, &ct).unwrap(); + assert_eq!(pt_prime, pt); + + // Opening the plaintext with the correct opener and wrong aad should fail. + let open_res = opener.open(&[0x0], &ct); + assert!(matches!(open_res.unwrap_err(), Error::Other(_))); + + // Opening the plaintext with the wrong opener should fail. + let mut sk_rm_prime = sk.secret_bytes().to_vec(); + sk_rm_prime[10] ^= 0xFF; // Corrupt a byte of the private key. + let mut opener_two = suite + .setup_opener(&enc, info, &HpkePrivateKey::from(sk_rm_prime)) + .unwrap(); + let open_res = opener_two.open(aad, &ct); + assert!(matches!(open_res.unwrap_err(), Error::Other(_))); + } + } + + #[cfg(not(feature = "fips"))] // Ensure all supported suites are available to test. + #[test] + fn test_fips() { + let testcases: &[(&dyn Hpke, bool)] = &[ + // FIPS compatible. + (DH_KEM_P256_HKDF_SHA256_AES_128, true), + (DH_KEM_P256_HKDF_SHA256_AES_256, true), + (DH_KEM_P384_HKDF_SHA384_AES_128, true), + (DH_KEM_P384_HKDF_SHA384_AES_256, true), + (DH_KEM_P521_HKDF_SHA512_AES_128, true), + (DH_KEM_P521_HKDF_SHA512_AES_256, true), + // AEAD is not FIPS compatible. + (DH_KEM_P256_HKDF_SHA256_CHACHA20_POLY1305, false), + (DH_KEM_P384_HKDF_SHA384_CHACHA20_POLY1305, false), + (DH_KEM_P521_HKDF_SHA512_CHACHA20_POLY1305, false), + // KEM is not FIPS compatible. + (DH_KEM_X25519_HKDF_SHA256_AES_128, false), + (DH_KEM_X25519_HKDF_SHA256_AES_256, false), + (DH_KEM_X25519_HKDF_SHA256_CHACHA20_POLY1305, false), + ]; + for (suite, expected) in testcases { + assert_eq!(suite.fips(), *expected); + } + } +} + +#[cfg(test)] +mod rfc_tests { + use alloc::string::String; + use std::fs::File; + use std::println; + + use serde::Deserialize; + + use super::*; + + /// Confirm open/seal operations work using the test vectors from [RFC 9180 Appendix A]. + /// + /// [RFC 9180 Appendix A]: https://www.rfc-editor.org/rfc/rfc9180#TestVectors + #[test] + fn check_test_vectors() { + for (idx, vec) in test_vectors().into_iter().enumerate() { + let Some(hpke) = vec.applicable() else { + println!("skipping inapplicable vector {idx}"); + continue; + }; + + println!("testing vector {idx}"); + let pk_r = HpkePublicKey(hex::decode(vec.pk_rm).unwrap()); + let sk_r = HpkePrivateKey::from(hex::decode(vec.sk_rm).unwrap()); + let sk_em = hex::decode(vec.sk_em).unwrap(); + let info = hex::decode(vec.info).unwrap(); + let expected_enc = hex::decode(vec.enc).unwrap(); + + let (enc, mut sealer) = hpke + .setup_test_sealer(&info, &pk_r, &sk_em) + .unwrap(); + assert_eq!(enc.0, expected_enc); + + let mut opener = hpke + .setup_opener(&enc, &info, &sk_r) + .unwrap(); + + for test_encryption in vec.encryptions { + let aad = hex::decode(test_encryption.aad).unwrap(); + let pt = hex::decode(test_encryption.pt).unwrap(); + let expected_ct = hex::decode(test_encryption.ct).unwrap(); + + let ciphertext = sealer.seal(&aad, &pt).unwrap(); + assert_eq!(ciphertext, expected_ct); + + let plaintext = opener.open(&aad, &ciphertext).unwrap(); + assert_eq!(plaintext, pt); + } + } + } + + trait TestHpke: Hpke { + fn setup_test_sealer( + &self, + info: &[u8], + pub_key: &HpkePublicKey, + sk_em: &[u8], + ) -> Result<(EncapsulatedSecret, Box), Error>; + } + + impl TestHpke for HpkeAwsLcRs { + fn setup_test_sealer( + &self, + info: &[u8], + pub_key: &HpkePublicKey, + sk_em: &[u8], + ) -> Result<(EncapsulatedSecret, Box), Error> { + let (encap, sealer) = Sealer::test_only_new(self, info, pub_key, sk_em)?; + Ok((encap, Box::new(sealer))) + } + } + + static TEST_SUITES: &[&dyn TestHpke] = &[ + DH_KEM_P256_HKDF_SHA256_AES_128, + DH_KEM_P256_HKDF_SHA256_AES_256, + #[cfg(not(feature = "fips"))] + DH_KEM_P256_HKDF_SHA256_CHACHA20_POLY1305, + DH_KEM_P384_HKDF_SHA384_AES_128, + DH_KEM_P384_HKDF_SHA384_AES_256, + #[cfg(not(feature = "fips"))] + DH_KEM_P384_HKDF_SHA384_CHACHA20_POLY1305, + DH_KEM_P521_HKDF_SHA512_AES_128, + DH_KEM_P521_HKDF_SHA512_AES_256, + #[cfg(not(feature = "fips"))] + DH_KEM_P521_HKDF_SHA512_CHACHA20_POLY1305, + #[cfg(not(feature = "fips"))] + DH_KEM_X25519_HKDF_SHA256_AES_128, + #[cfg(not(feature = "fips"))] + DH_KEM_X25519_HKDF_SHA256_AES_256, + #[cfg(not(feature = "fips"))] + DH_KEM_X25519_HKDF_SHA256_CHACHA20_POLY1305, + ]; + + #[derive(Deserialize, Debug)] + struct TestVector { + mode: u8, + kem_id: u16, + kdf_id: u16, + aead_id: u16, + info: String, + #[serde(rename(deserialize = "pkRm"))] + pk_rm: String, + #[serde(rename(deserialize = "skRm"))] + sk_rm: String, + #[serde(rename(deserialize = "skEm"))] + sk_em: String, + enc: String, + encryptions: Vec, + } + + #[derive(Deserialize, Debug)] + struct TestEncryption { + aad: String, + pt: String, + ct: String, + } + + impl TestVector { + fn suite(&self) -> HpkeSuite { + HpkeSuite { + kem: HpkeKem::from(self.kem_id), + sym: HpkeSymmetricCipherSuite { + kdf_id: HpkeKdf::from(self.kdf_id), + aead_id: HpkeAead::from(self.aead_id), + }, + } + } + + fn applicable(&self) -> Option<&'static dyn TestHpke> { + // Only base mode test vectors for supported suites are applicable. + if self.mode != 0 { + return None; + } + + Self::lookup_suite(self.suite(), TEST_SUITES) + } + + fn lookup_suite( + suite: HpkeSuite, + supported: &[&'static dyn TestHpke], + ) -> Option<&'static dyn TestHpke> { + supported + .iter() + .find(|s| s.suite() == suite) + .copied() + } + } + + fn test_vectors() -> Vec { + serde_json::from_reader( + &mut File::open("../rustls-provider-test/tests/rfc-9180-test-vectors.json") + .expect("failed to open test vectors data file"), + ) + .expect("failed to deserialize test vectors") + } +} diff --git a/http/vendor/rustls/src/crypto/aws_lc_rs/mod.rs b/http/vendor/rustls/src/crypto/aws_lc_rs/mod.rs new file mode 100644 index 0000000..1ab57da --- /dev/null +++ b/http/vendor/rustls/src/crypto/aws_lc_rs/mod.rs @@ -0,0 +1,348 @@ +use alloc::vec::Vec; + +// aws-lc-rs has a -- roughly -- ring-compatible API, so we just reuse all that +// glue here. The shared files should always use `super::ring_like` to access a +// ring-compatible crate, and `super::ring_shim` to bridge the gaps where they are +// small. +pub(crate) use aws_lc_rs as ring_like; +use pki_types::PrivateKeyDer; +use webpki::aws_lc_rs as webpki_algs; + +use crate::crypto::{CryptoProvider, KeyProvider, SecureRandom, SupportedKxGroup}; +use crate::enums::SignatureScheme; +use crate::rand::GetRandomFailed; +use crate::sign::SigningKey; +use crate::suites::SupportedCipherSuite; +use crate::sync::Arc; +use crate::webpki::WebPkiSupportedAlgorithms; +use crate::{Error, OtherError}; + +/// Hybrid public key encryption (HPKE). +pub mod hpke; +/// Post-quantum secure algorithms. +pub(crate) mod pq; +/// Using software keys for authentication. +pub mod sign; + +#[path = "../ring/hash.rs"] +pub(crate) mod hash; +#[path = "../ring/hmac.rs"] +pub(crate) mod hmac; +#[path = "../ring/kx.rs"] +pub(crate) mod kx; +#[path = "../ring/quic.rs"] +pub(crate) mod quic; +#[cfg(feature = "std")] +pub(crate) mod ticketer; +#[cfg(feature = "tls12")] +pub(crate) mod tls12; +pub(crate) mod tls13; + +/// A `CryptoProvider` backed by aws-lc-rs. +pub fn default_provider() -> CryptoProvider { + CryptoProvider { + cipher_suites: DEFAULT_CIPHER_SUITES.to_vec(), + kx_groups: default_kx_groups(), + signature_verification_algorithms: SUPPORTED_SIG_ALGS, + secure_random: &AwsLcRs, + key_provider: &AwsLcRs, + } +} + +fn default_kx_groups() -> Vec<&'static dyn SupportedKxGroup> { + #[cfg(feature = "fips")] + { + DEFAULT_KX_GROUPS + .iter() + .filter(|cs| cs.fips()) + .copied() + .collect() + } + #[cfg(not(feature = "fips"))] + { + DEFAULT_KX_GROUPS.to_vec() + } +} + +#[derive(Debug)] +struct AwsLcRs; + +impl SecureRandom for AwsLcRs { + fn fill(&self, buf: &mut [u8]) -> Result<(), GetRandomFailed> { + use ring_like::rand::SecureRandom; + + ring_like::rand::SystemRandom::new() + .fill(buf) + .map_err(|_| GetRandomFailed) + } + + fn fips(&self) -> bool { + fips() + } +} + +impl KeyProvider for AwsLcRs { + fn load_private_key( + &self, + key_der: PrivateKeyDer<'static>, + ) -> Result, Error> { + sign::any_supported_type(&key_der) + } + + fn fips(&self) -> bool { + fips() + } +} + +/// The cipher suite configuration that an application should use by default. +/// +/// This will be [`ALL_CIPHER_SUITES`] sans any supported cipher suites that +/// shouldn't be enabled by most applications. +pub static DEFAULT_CIPHER_SUITES: &[SupportedCipherSuite] = &[ + // TLS1.3 suites + tls13::TLS13_AES_256_GCM_SHA384, + tls13::TLS13_AES_128_GCM_SHA256, + #[cfg(not(feature = "fips"))] + tls13::TLS13_CHACHA20_POLY1305_SHA256, + // TLS1.2 suites + #[cfg(feature = "tls12")] + tls12::TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, + #[cfg(feature = "tls12")] + tls12::TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, + #[cfg(all(feature = "tls12", not(feature = "fips")))] + tls12::TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256, + #[cfg(feature = "tls12")] + tls12::TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, + #[cfg(feature = "tls12")] + tls12::TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, + #[cfg(all(feature = "tls12", not(feature = "fips")))] + tls12::TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, +]; + +/// A list of all the cipher suites supported by the rustls aws-lc-rs provider. +pub static ALL_CIPHER_SUITES: &[SupportedCipherSuite] = &[ + // TLS1.3 suites + tls13::TLS13_AES_256_GCM_SHA384, + tls13::TLS13_AES_128_GCM_SHA256, + tls13::TLS13_CHACHA20_POLY1305_SHA256, + // TLS1.2 suites + #[cfg(feature = "tls12")] + tls12::TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, + #[cfg(feature = "tls12")] + tls12::TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, + #[cfg(feature = "tls12")] + tls12::TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256, + #[cfg(feature = "tls12")] + tls12::TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, + #[cfg(feature = "tls12")] + tls12::TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, + #[cfg(feature = "tls12")] + tls12::TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, +]; + +/// All defined cipher suites supported by aws-lc-rs appear in this module. +pub mod cipher_suite { + #[cfg(feature = "tls12")] + pub use super::tls12::{ + TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, + TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, + TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, + }; + pub use super::tls13::{ + TLS13_AES_128_GCM_SHA256, TLS13_AES_256_GCM_SHA384, TLS13_CHACHA20_POLY1305_SHA256, + }; +} + +/// A `WebPkiSupportedAlgorithms` value that reflects webpki's capabilities when +/// compiled against aws-lc-rs. +static SUPPORTED_SIG_ALGS: WebPkiSupportedAlgorithms = WebPkiSupportedAlgorithms { + all: &[ + webpki_algs::ECDSA_P256_SHA256, + webpki_algs::ECDSA_P256_SHA384, + webpki_algs::ECDSA_P256_SHA512, + webpki_algs::ECDSA_P384_SHA256, + webpki_algs::ECDSA_P384_SHA384, + webpki_algs::ECDSA_P384_SHA512, + webpki_algs::ECDSA_P521_SHA256, + webpki_algs::ECDSA_P521_SHA384, + webpki_algs::ECDSA_P521_SHA512, + webpki_algs::ED25519, + webpki_algs::RSA_PSS_2048_8192_SHA256_LEGACY_KEY, + webpki_algs::RSA_PSS_2048_8192_SHA384_LEGACY_KEY, + webpki_algs::RSA_PSS_2048_8192_SHA512_LEGACY_KEY, + webpki_algs::RSA_PKCS1_2048_8192_SHA256, + webpki_algs::RSA_PKCS1_2048_8192_SHA384, + webpki_algs::RSA_PKCS1_2048_8192_SHA512, + webpki_algs::RSA_PKCS1_2048_8192_SHA256_ABSENT_PARAMS, + webpki_algs::RSA_PKCS1_2048_8192_SHA384_ABSENT_PARAMS, + webpki_algs::RSA_PKCS1_2048_8192_SHA512_ABSENT_PARAMS, + ], + mapping: &[ + // Note: for TLS1.2 the curve is not fixed by SignatureScheme. For TLS1.3 it is. + ( + SignatureScheme::ECDSA_NISTP384_SHA384, + &[ + webpki_algs::ECDSA_P384_SHA384, + webpki_algs::ECDSA_P256_SHA384, + webpki_algs::ECDSA_P521_SHA384, + ], + ), + ( + SignatureScheme::ECDSA_NISTP256_SHA256, + &[ + webpki_algs::ECDSA_P256_SHA256, + webpki_algs::ECDSA_P384_SHA256, + webpki_algs::ECDSA_P521_SHA256, + ], + ), + ( + SignatureScheme::ECDSA_NISTP521_SHA512, + &[ + webpki_algs::ECDSA_P521_SHA512, + webpki_algs::ECDSA_P384_SHA512, + webpki_algs::ECDSA_P256_SHA512, + ], + ), + (SignatureScheme::ED25519, &[webpki_algs::ED25519]), + ( + SignatureScheme::RSA_PSS_SHA512, + &[webpki_algs::RSA_PSS_2048_8192_SHA512_LEGACY_KEY], + ), + ( + SignatureScheme::RSA_PSS_SHA384, + &[webpki_algs::RSA_PSS_2048_8192_SHA384_LEGACY_KEY], + ), + ( + SignatureScheme::RSA_PSS_SHA256, + &[webpki_algs::RSA_PSS_2048_8192_SHA256_LEGACY_KEY], + ), + ( + SignatureScheme::RSA_PKCS1_SHA512, + &[webpki_algs::RSA_PKCS1_2048_8192_SHA512], + ), + ( + SignatureScheme::RSA_PKCS1_SHA384, + &[webpki_algs::RSA_PKCS1_2048_8192_SHA384], + ), + ( + SignatureScheme::RSA_PKCS1_SHA256, + &[webpki_algs::RSA_PKCS1_2048_8192_SHA256], + ), + ], +}; + +/// All defined key exchange groups supported by aws-lc-rs appear in this module. +/// +/// [`ALL_KX_GROUPS`] is provided as an array of all of these values. +/// [`DEFAULT_KX_GROUPS`] is provided as an array of this provider's defaults. +pub mod kx_group { + pub use super::kx::{SECP256R1, SECP384R1, X25519}; + pub use super::pq::{MLKEM768, MLKEM1024, SECP256R1MLKEM768, X25519MLKEM768}; +} + +/// A list of the default key exchange groups supported by this provider. +/// +/// This does not contain MLKEM768; by default MLKEM768 is only offered +/// in hybrid with X25519. +pub static DEFAULT_KX_GROUPS: &[&dyn SupportedKxGroup] = &[ + #[cfg(feature = "prefer-post-quantum")] + kx_group::X25519MLKEM768, + kx_group::X25519, + kx_group::SECP256R1, + kx_group::SECP384R1, + #[cfg(not(feature = "prefer-post-quantum"))] + kx_group::X25519MLKEM768, +]; + +/// A list of all the key exchange groups supported by this provider. +pub static ALL_KX_GROUPS: &[&dyn SupportedKxGroup] = &[ + #[cfg(feature = "prefer-post-quantum")] + kx_group::X25519MLKEM768, + #[cfg(feature = "prefer-post-quantum")] + kx_group::SECP256R1MLKEM768, + kx_group::X25519, + kx_group::SECP256R1, + kx_group::SECP384R1, + #[cfg(not(feature = "prefer-post-quantum"))] + kx_group::X25519MLKEM768, + #[cfg(not(feature = "prefer-post-quantum"))] + kx_group::SECP256R1MLKEM768, + kx_group::MLKEM768, + kx_group::MLKEM1024, +]; + +#[cfg(feature = "std")] +pub use ticketer::Ticketer; + +/// Compatibility shims between ring 0.16.x and 0.17.x API +mod ring_shim { + use super::ring_like; + use crate::crypto::SharedSecret; + + pub(super) fn agree_ephemeral( + priv_key: ring_like::agreement::EphemeralPrivateKey, + peer_key: &ring_like::agreement::UnparsedPublicKey<&[u8]>, + ) -> Result { + ring_like::agreement::agree_ephemeral(priv_key, peer_key, (), |secret| { + Ok(SharedSecret::from(secret)) + }) + } +} + +/// Are we in FIPS mode? +pub(super) fn fips() -> bool { + aws_lc_rs::try_fips_mode().is_ok() +} + +pub(super) fn unspecified_err(_e: aws_lc_rs::error::Unspecified) -> Error { + #[cfg(feature = "std")] + { + Error::Other(OtherError(Arc::new(_e))) + } + #[cfg(not(feature = "std"))] + { + Error::Other(OtherError()) + } +} + +#[cfg(test)] +mod tests { + use std::collections::HashSet; + + #[cfg(feature = "fips")] + #[test] + fn default_suites_are_fips() { + assert!( + super::DEFAULT_CIPHER_SUITES + .iter() + .all(|scs| scs.fips()) + ); + } + + #[cfg(not(feature = "fips"))] + #[test] + fn default_suites() { + assert_eq!(super::DEFAULT_CIPHER_SUITES, super::ALL_CIPHER_SUITES); + } + + #[test] + fn certificate_sig_algs() { + // `all` should not contain duplicates (not incorrect, but a waste of time) + assert_eq!( + super::SUPPORTED_SIG_ALGS + .all + .iter() + .map(|alg| { + ( + alg.public_key_alg_id() + .as_ref() + .to_vec(), + alg.signature_alg_id().as_ref().to_vec(), + ) + }) + .collect::>() + .len(), + super::SUPPORTED_SIG_ALGS.all.len(), + ); + } +} diff --git a/http/vendor/rustls/src/crypto/aws_lc_rs/pq/hybrid.rs b/http/vendor/rustls/src/crypto/aws_lc_rs/pq/hybrid.rs new file mode 100644 index 0000000..8e30d78 --- /dev/null +++ b/http/vendor/rustls/src/crypto/aws_lc_rs/pq/hybrid.rs @@ -0,0 +1,205 @@ +use alloc::boxed::Box; +use alloc::vec::Vec; + +use super::INVALID_KEY_SHARE; +use crate::crypto::{ActiveKeyExchange, CompletedKeyExchange, SharedSecret, SupportedKxGroup}; +use crate::ffdhe_groups::FfdheGroup; +use crate::{Error, NamedGroup, ProtocolVersion}; + +/// A generalization of hybrid key exchange. +#[derive(Debug)] +pub(crate) struct Hybrid { + pub(crate) classical: &'static dyn SupportedKxGroup, + pub(crate) post_quantum: &'static dyn SupportedKxGroup, + pub(crate) name: NamedGroup, + pub(crate) layout: Layout, +} + +impl SupportedKxGroup for Hybrid { + fn start(&self) -> Result, Error> { + let classical = self.classical.start()?; + let post_quantum = self.post_quantum.start()?; + + let combined_pub_key = self + .layout + .concat(post_quantum.pub_key(), classical.pub_key()); + + Ok(Box::new(ActiveHybrid { + classical, + post_quantum, + name: self.name, + layout: self.layout, + combined_pub_key, + })) + } + + fn start_and_complete(&self, client_share: &[u8]) -> Result { + let (post_quantum_share, classical_share) = self + .layout + .split_received_client_share(client_share) + .ok_or(INVALID_KEY_SHARE)?; + + let cl = self + .classical + .start_and_complete(classical_share)?; + let pq = self + .post_quantum + .start_and_complete(post_quantum_share)?; + + let combined_pub_key = self + .layout + .concat(&pq.pub_key, &cl.pub_key); + let secret = self + .layout + .concat(pq.secret.secret_bytes(), cl.secret.secret_bytes()); + + Ok(CompletedKeyExchange { + group: self.name, + pub_key: combined_pub_key, + secret: SharedSecret::from(secret), + }) + } + + fn ffdhe_group(&self) -> Option> { + None + } + + fn name(&self) -> NamedGroup { + self.name + } + + fn fips(&self) -> bool { + // Behold! The Night Mare: SP800-56C rev 2: + // + // "In addition to the currently approved techniques for the generation of the + // shared secret Z as specified in SP 800-56A and SP 800-56B, this Recommendation + // permits the use of a "hybrid" shared secret of the form Z′ = Z || T, a + // concatenation consisting of a "standard" shared secret Z that was generated + // during the execution of a key-establishment scheme (as currently specified in + // [SP 800-56A] or [SP 800-56B])" + // + // NIST plan to adjust this and allow both orders: see + // (Jan 2025) lines 1070-1080. + // + // But, for now, we follow the SP800-56C logic: the element appearing first is the + // one that controls approval. + match self.layout.post_quantum_first { + true => self.post_quantum.fips(), + false => self.classical.fips(), + } + } + + fn usable_for_version(&self, version: ProtocolVersion) -> bool { + version == ProtocolVersion::TLSv1_3 + } +} + +struct ActiveHybrid { + classical: Box, + post_quantum: Box, + name: NamedGroup, + layout: Layout, + combined_pub_key: Vec, +} + +impl ActiveKeyExchange for ActiveHybrid { + fn complete(self: Box, peer_pub_key: &[u8]) -> Result { + let (post_quantum_share, classical_share) = self + .layout + .split_received_server_share(peer_pub_key) + .ok_or(INVALID_KEY_SHARE)?; + + let cl = self + .classical + .complete(classical_share)?; + let pq = self + .post_quantum + .complete(post_quantum_share)?; + + let secret = self + .layout + .concat(pq.secret_bytes(), cl.secret_bytes()); + Ok(SharedSecret::from(secret)) + } + + /// Allow the classical computation to be offered and selected separately. + fn hybrid_component(&self) -> Option<(NamedGroup, &[u8])> { + Some((self.classical.group(), self.classical.pub_key())) + } + + fn complete_hybrid_component( + self: Box, + peer_pub_key: &[u8], + ) -> Result { + self.classical.complete(peer_pub_key) + } + + fn pub_key(&self) -> &[u8] { + &self.combined_pub_key + } + + fn ffdhe_group(&self) -> Option> { + None + } + + fn group(&self) -> NamedGroup { + self.name + } +} + +#[derive(Clone, Copy, Debug)] +pub(crate) struct Layout { + /// Length of classical key share. + pub(crate) classical_share_len: usize, + + /// Length of post-quantum key share sent by client + pub(crate) post_quantum_client_share_len: usize, + + /// Length of post-quantum key share sent by server + pub(crate) post_quantum_server_share_len: usize, + + /// Whether the post-quantum element comes first in shares and secrets. + /// + /// For dismal and unprincipled reasons, SECP256R1MLKEM768 has the + /// classical element first, while X25519MLKEM768 has it second. + pub(crate) post_quantum_first: bool, +} + +impl Layout { + fn split_received_client_share<'a>(&self, share: &'a [u8]) -> Option<(&'a [u8], &'a [u8])> { + self.split(share, self.post_quantum_client_share_len) + } + + fn split_received_server_share<'a>(&self, share: &'a [u8]) -> Option<(&'a [u8], &'a [u8])> { + self.split(share, self.post_quantum_server_share_len) + } + + /// Return the PQ and classical component of a key share. + fn split<'a>( + &self, + share: &'a [u8], + post_quantum_share_len: usize, + ) -> Option<(&'a [u8], &'a [u8])> { + if share.len() != self.classical_share_len + post_quantum_share_len { + return None; + } + + Some(match self.post_quantum_first { + true => { + let (first_share, second_share) = share.split_at(post_quantum_share_len); + (first_share, second_share) + } + false => { + let (first_share, second_share) = share.split_at(self.classical_share_len); + (second_share, first_share) + } + }) + } + + fn concat(&self, post_quantum: &[u8], classical: &[u8]) -> Vec { + match self.post_quantum_first { + true => [post_quantum, classical].concat(), + false => [classical, post_quantum].concat(), + } + } +} diff --git a/http/vendor/rustls/src/crypto/aws_lc_rs/pq/mlkem.rs b/http/vendor/rustls/src/crypto/aws_lc_rs/pq/mlkem.rs new file mode 100644 index 0000000..9e48fed --- /dev/null +++ b/http/vendor/rustls/src/crypto/aws_lc_rs/pq/mlkem.rs @@ -0,0 +1,108 @@ +use alloc::boxed::Box; +use alloc::vec::Vec; + +use aws_lc_rs::kem; + +use super::INVALID_KEY_SHARE; +use crate::crypto::{ActiveKeyExchange, CompletedKeyExchange, SharedSecret, SupportedKxGroup}; +use crate::ffdhe_groups::FfdheGroup; +use crate::{Error, NamedGroup, ProtocolVersion}; + +#[derive(Debug)] +pub(crate) struct MlKem { + pub(crate) alg: &'static kem::Algorithm, + pub(crate) group: NamedGroup, +} + +impl SupportedKxGroup for MlKem { + fn start(&self) -> Result, Error> { + let decaps_key = kem::DecapsulationKey::generate(self.alg) + .map_err(|_| Error::General("key generation failed".into()))?; + + let pub_key_bytes = decaps_key + .encapsulation_key() + .and_then(|encaps_key| encaps_key.key_bytes()) + .map_err(|_| Error::General("encaps failed".into()))?; + + Ok(Box::new(Active { + decaps_key: Box::new(decaps_key), + encaps_key_bytes: Vec::from(pub_key_bytes.as_ref()), + group: self.group, + })) + } + + fn start_and_complete(&self, client_share: &[u8]) -> Result { + let encaps_key = + kem::EncapsulationKey::new(self.alg, client_share).map_err(|_| INVALID_KEY_SHARE)?; + + let (ciphertext, shared_secret) = encaps_key + .encapsulate() + .map_err(|_| INVALID_KEY_SHARE)?; + + Ok(CompletedKeyExchange { + group: self.name(), + pub_key: Vec::from(ciphertext.as_ref()), + secret: SharedSecret::from(shared_secret.as_ref()), + }) + } + + fn ffdhe_group(&self) -> Option> { + None + } + + fn name(&self) -> NamedGroup { + self.group + } + + fn fips(&self) -> bool { + // AUDITORS: + // At the time of writing, the ML-KEM implementation in AWS-LC-FIPS module 3.0 + // is FIPS-pending. Some regulatory regimes (eg, FedRAMP rev 5 SC-13) allow + // use of implementations in this state, as if they are already approved. + // + // We follow this liberal interpretation, and say MlKem768 is FIPS-compliant + // if the underlying library is in FIPS mode. + // + // TODO: adjust the `fips()` function return type to allow more policies to + // be expressed, perhaps following something like + // -- + // see + super::super::fips() + } + + fn usable_for_version(&self, version: ProtocolVersion) -> bool { + version == ProtocolVersion::TLSv1_3 + } +} + +struct Active { + decaps_key: Box>, + encaps_key_bytes: Vec, + group: NamedGroup, +} + +impl ActiveKeyExchange for Active { + // The received 'peer_pub_key' is actually the ML-KEM ciphertext, + // which when decapsulated with our `decaps_key` produces the shared + // secret. + fn complete(self: Box, peer_pub_key: &[u8]) -> Result { + let shared_secret = self + .decaps_key + .decapsulate(peer_pub_key.into()) + .map_err(|_| INVALID_KEY_SHARE)?; + + Ok(SharedSecret::from(shared_secret.as_ref())) + } + + fn pub_key(&self) -> &[u8] { + &self.encaps_key_bytes + } + + fn ffdhe_group(&self) -> Option> { + None + } + + fn group(&self) -> NamedGroup { + self.group + } +} diff --git a/http/vendor/rustls/src/crypto/aws_lc_rs/pq/mod.rs b/http/vendor/rustls/src/crypto/aws_lc_rs/pq/mod.rs new file mode 100644 index 0000000..2a61dd8 --- /dev/null +++ b/http/vendor/rustls/src/crypto/aws_lc_rs/pq/mod.rs @@ -0,0 +1,62 @@ +use aws_lc_rs::kem; + +use crate::crypto::SupportedKxGroup; +use crate::crypto::aws_lc_rs::kx_group; +use crate::crypto::aws_lc_rs::pq::mlkem::MlKem; +use crate::{Error, NamedGroup, PeerMisbehaved}; + +mod hybrid; +mod mlkem; + +/// This is the [X25519MLKEM768] key exchange. +/// +/// [X25519MLKEM768]: +pub static X25519MLKEM768: &dyn SupportedKxGroup = &hybrid::Hybrid { + classical: kx_group::X25519, + post_quantum: MLKEM768, + name: NamedGroup::X25519MLKEM768, + layout: hybrid::Layout { + classical_share_len: X25519_LEN, + post_quantum_client_share_len: MLKEM768_ENCAP_LEN, + post_quantum_server_share_len: MLKEM768_CIPHERTEXT_LEN, + post_quantum_first: true, + }, +}; + +/// This is the [SECP256R1MLKEM768] key exchange. +/// +/// [SECP256R1MLKEM768]: +pub static SECP256R1MLKEM768: &dyn SupportedKxGroup = &hybrid::Hybrid { + classical: kx_group::SECP256R1, + post_quantum: MLKEM768, + name: NamedGroup::secp256r1MLKEM768, + layout: hybrid::Layout { + classical_share_len: SECP256R1_LEN, + post_quantum_client_share_len: MLKEM768_ENCAP_LEN, + post_quantum_server_share_len: MLKEM768_CIPHERTEXT_LEN, + post_quantum_first: false, + }, +}; + +/// This is the [MLKEM] key encapsulation mechanism in NIST with security category 3. +/// +/// [MLKEM]: https://datatracker.ietf.org/doc/draft-ietf-tls-mlkem +pub static MLKEM768: &dyn SupportedKxGroup = &MlKem { + alg: &kem::ML_KEM_768, + group: NamedGroup::MLKEM768, +}; + +/// This is the [MLKEM] key encapsulation mechanism in NIST with security category 5. +/// +/// [MLKEM]: https://datatracker.ietf.org/doc/draft-ietf-tls-mlkem +pub static MLKEM1024: &dyn SupportedKxGroup = &MlKem { + alg: &kem::ML_KEM_1024, + group: NamedGroup::MLKEM1024, +}; + +const INVALID_KEY_SHARE: Error = Error::PeerMisbehaved(PeerMisbehaved::InvalidKeyShare); + +const X25519_LEN: usize = 32; +const SECP256R1_LEN: usize = 65; +const MLKEM768_CIPHERTEXT_LEN: usize = 1088; +const MLKEM768_ENCAP_LEN: usize = 1184; diff --git a/http/vendor/rustls/src/crypto/aws_lc_rs/sign.rs b/http/vendor/rustls/src/crypto/aws_lc_rs/sign.rs new file mode 100644 index 0000000..0c874ab --- /dev/null +++ b/http/vendor/rustls/src/crypto/aws_lc_rs/sign.rs @@ -0,0 +1,876 @@ +#![allow(clippy::duplicate_mod)] + +use alloc::boxed::Box; +use alloc::string::ToString; +use alloc::vec::Vec; +use alloc::{format, vec}; +use core::fmt::{self, Debug, Formatter}; + +use pki_types::{PrivateKeyDer, PrivatePkcs8KeyDer, SubjectPublicKeyInfoDer, alg_id}; + +use super::ring_like::rand::SystemRandom; +use super::ring_like::signature::{self, EcdsaKeyPair, Ed25519KeyPair, KeyPair, RsaKeyPair}; +use crate::crypto::signer::{Signer, SigningKey, public_key_to_spki}; +use crate::enums::{SignatureAlgorithm, SignatureScheme}; +use crate::error::Error; +use crate::sync::Arc; + +/// Parse `der` as any supported key encoding/type, returning +/// the first which works. +pub fn any_supported_type(der: &PrivateKeyDer<'_>) -> Result, Error> { + if let Ok(rsa) = RsaSigningKey::new(der) { + return Ok(Arc::new(rsa)); + } + + if let Ok(ecdsa) = any_ecdsa_type(der) { + return Ok(ecdsa); + } + + if let PrivateKeyDer::Pkcs8(pkcs8) = der { + if let Ok(eddsa) = any_eddsa_type(pkcs8) { + return Ok(eddsa); + } + } + + Err(Error::General( + "failed to parse private key as RSA, ECDSA, or EdDSA".into(), + )) +} + +/// Parse `der` as any ECDSA key type, returning the first which works. +/// +/// Both SEC1 (PEM section starting with 'BEGIN EC PRIVATE KEY') and PKCS8 +/// (PEM section starting with 'BEGIN PRIVATE KEY') encodings are supported. +pub fn any_ecdsa_type(der: &PrivateKeyDer<'_>) -> Result, Error> { + if let Ok(ecdsa_p256) = EcdsaSigningKey::new( + der, + SignatureScheme::ECDSA_NISTP256_SHA256, + &signature::ECDSA_P256_SHA256_ASN1_SIGNING, + ) { + return Ok(Arc::new(ecdsa_p256)); + } + + if let Ok(ecdsa_p384) = EcdsaSigningKey::new( + der, + SignatureScheme::ECDSA_NISTP384_SHA384, + &signature::ECDSA_P384_SHA384_ASN1_SIGNING, + ) { + return Ok(Arc::new(ecdsa_p384)); + } + + if let Ok(ecdsa_p521) = EcdsaSigningKey::new( + der, + SignatureScheme::ECDSA_NISTP521_SHA512, + &signature::ECDSA_P521_SHA512_ASN1_SIGNING, + ) { + return Ok(Arc::new(ecdsa_p521)); + } + + Err(Error::General( + "failed to parse ECDSA private key as PKCS#8 or SEC1".into(), + )) +} + +/// Parse `der` as any EdDSA key type, returning the first which works. +/// +/// Note that, at the time of writing, Ed25519 does not have wide support +/// in browsers. It is also not supported by the WebPKI, because the +/// CA/Browser Forum Baseline Requirements do not support it for publicly +/// trusted certificates. +pub fn any_eddsa_type(der: &PrivatePkcs8KeyDer<'_>) -> Result, Error> { + // TODO: Add support for Ed448 + Ok(Arc::new(Ed25519SigningKey::new( + der, + SignatureScheme::ED25519, + )?)) +} + +/// A `SigningKey` for RSA-PKCS1 or RSA-PSS. +/// +/// This is used by the test suite, so it must be `pub`, but it isn't part of +/// the public, stable, API. +#[doc(hidden)] +pub struct RsaSigningKey { + key: Arc, +} + +static ALL_RSA_SCHEMES: &[SignatureScheme] = &[ + SignatureScheme::RSA_PSS_SHA512, + SignatureScheme::RSA_PSS_SHA384, + SignatureScheme::RSA_PSS_SHA256, + SignatureScheme::RSA_PKCS1_SHA512, + SignatureScheme::RSA_PKCS1_SHA384, + SignatureScheme::RSA_PKCS1_SHA256, +]; + +impl RsaSigningKey { + /// Make a new `RsaSigningKey` from a DER encoding, in either + /// PKCS#1 or PKCS#8 format. + pub fn new(der: &PrivateKeyDer<'_>) -> Result { + let key_pair = match der { + PrivateKeyDer::Pkcs1(pkcs1) => RsaKeyPair::from_der(pkcs1.secret_pkcs1_der()), + PrivateKeyDer::Pkcs8(pkcs8) => RsaKeyPair::from_pkcs8(pkcs8.secret_pkcs8_der()), + _ => { + return Err(Error::General( + "failed to parse RSA private key as either PKCS#1 or PKCS#8".into(), + )); + } + } + .map_err(|key_rejected| { + Error::General(format!("failed to parse RSA private key: {key_rejected}")) + })?; + + Ok(Self { + key: Arc::new(key_pair), + }) + } +} + +impl SigningKey for RsaSigningKey { + fn choose_scheme(&self, offered: &[SignatureScheme]) -> Option> { + ALL_RSA_SCHEMES + .iter() + .find(|scheme| offered.contains(scheme)) + .map(|scheme| RsaSigner::new(self.key.clone(), *scheme)) + } + + fn public_key(&self) -> Option> { + Some(public_key_to_spki( + &alg_id::RSA_ENCRYPTION, + self.key.public_key(), + )) + } + + fn algorithm(&self) -> SignatureAlgorithm { + SignatureAlgorithm::RSA + } +} + +impl Debug for RsaSigningKey { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.debug_struct("RsaSigningKey") + .field("algorithm", &self.algorithm()) + .finish() + } +} + +struct RsaSigner { + key: Arc, + scheme: SignatureScheme, + encoding: &'static dyn signature::RsaEncoding, +} + +impl RsaSigner { + fn new(key: Arc, scheme: SignatureScheme) -> Box { + let encoding: &dyn signature::RsaEncoding = match scheme { + SignatureScheme::RSA_PKCS1_SHA256 => &signature::RSA_PKCS1_SHA256, + SignatureScheme::RSA_PKCS1_SHA384 => &signature::RSA_PKCS1_SHA384, + SignatureScheme::RSA_PKCS1_SHA512 => &signature::RSA_PKCS1_SHA512, + SignatureScheme::RSA_PSS_SHA256 => &signature::RSA_PSS_SHA256, + SignatureScheme::RSA_PSS_SHA384 => &signature::RSA_PSS_SHA384, + SignatureScheme::RSA_PSS_SHA512 => &signature::RSA_PSS_SHA512, + _ => unreachable!(), + }; + + Box::new(Self { + key, + scheme, + encoding, + }) + } +} + +impl Signer for RsaSigner { + fn sign(&self, message: &[u8]) -> Result, Error> { + let mut sig = vec![0; self.key.public_modulus_len()]; + + let rng = SystemRandom::new(); + self.key + .sign(self.encoding, &rng, message, &mut sig) + .map(|_| sig) + .map_err(|_| Error::General("signing failed".to_string())) + } + + fn scheme(&self) -> SignatureScheme { + self.scheme + } +} + +impl Debug for RsaSigner { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.debug_struct("RsaSigner") + .field("scheme", &self.scheme) + .finish() + } +} + +/// A SigningKey that uses exactly one TLS-level SignatureScheme +/// and one ring-level signature::SigningAlgorithm. +/// +/// Compare this to RsaSigningKey, which for a particular key is +/// willing to sign with several algorithms. This is quite poor +/// cryptography practice, but is necessary because a given RSA key +/// is expected to work in TLS1.2 (PKCS#1 signatures) and TLS1.3 +/// (PSS signatures) -- nobody is willing to obtain certificates for +/// different protocol versions. +/// +/// Currently this is only implemented for ECDSA keys. +struct EcdsaSigningKey { + key: Arc, + scheme: SignatureScheme, +} + +impl EcdsaSigningKey { + /// Make a new `ECDSASigningKey` from a DER encoding in PKCS#8 or SEC1 + /// format, expecting a key usable with precisely the given signature + /// scheme. + fn new( + der: &PrivateKeyDer<'_>, + scheme: SignatureScheme, + sigalg: &'static signature::EcdsaSigningAlgorithm, + ) -> Result { + let key_pair = match der { + PrivateKeyDer::Sec1(sec1) => { + EcdsaKeyPair::from_private_key_der(sigalg, sec1.secret_sec1_der()) + .map_err(|_| ())? + } + PrivateKeyDer::Pkcs8(pkcs8) => { + EcdsaKeyPair::from_pkcs8(sigalg, pkcs8.secret_pkcs8_der()).map_err(|_| ())? + } + _ => return Err(()), + }; + + Ok(Self { + key: Arc::new(key_pair), + scheme, + }) + } +} + +impl SigningKey for EcdsaSigningKey { + fn choose_scheme(&self, offered: &[SignatureScheme]) -> Option> { + if offered.contains(&self.scheme) { + Some(Box::new(EcdsaSigner { + key: self.key.clone(), + scheme: self.scheme, + })) + } else { + None + } + } + + fn public_key(&self) -> Option> { + let id = match self.scheme { + SignatureScheme::ECDSA_NISTP256_SHA256 => alg_id::ECDSA_P256, + SignatureScheme::ECDSA_NISTP384_SHA384 => alg_id::ECDSA_P384, + SignatureScheme::ECDSA_NISTP521_SHA512 => alg_id::ECDSA_P521, + _ => unreachable!(), + }; + + Some(public_key_to_spki(&id, self.key.public_key())) + } + + fn algorithm(&self) -> SignatureAlgorithm { + self.scheme.algorithm() + } +} + +impl Debug for EcdsaSigningKey { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.debug_struct("EcdsaSigningKey") + .field("algorithm", &self.algorithm()) + .finish() + } +} + +struct EcdsaSigner { + key: Arc, + scheme: SignatureScheme, +} + +impl Signer for EcdsaSigner { + fn sign(&self, message: &[u8]) -> Result, Error> { + let rng = SystemRandom::new(); + self.key + .sign(&rng, message) + .map_err(|_| Error::General("signing failed".into())) + .map(|sig| sig.as_ref().into()) + } + + fn scheme(&self) -> SignatureScheme { + self.scheme + } +} + +impl Debug for EcdsaSigner { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.debug_struct("EcdsaSigner") + .field("scheme", &self.scheme) + .finish() + } +} + +/// A SigningKey that uses exactly one TLS-level SignatureScheme +/// and one ring-level signature::SigningAlgorithm. +/// +/// Compare this to RsaSigningKey, which for a particular key is +/// willing to sign with several algorithms. This is quite poor +/// cryptography practice, but is necessary because a given RSA key +/// is expected to work in TLS1.2 (PKCS#1 signatures) and TLS1.3 +/// (PSS signatures) -- nobody is willing to obtain certificates for +/// different protocol versions. +/// +/// Currently this is only implemented for Ed25519 keys. +struct Ed25519SigningKey { + key: Arc, + scheme: SignatureScheme, +} + +impl Ed25519SigningKey { + /// Make a new `Ed25519SigningKey` from a DER encoding in PKCS#8 format, + /// expecting a key usable with precisely the given signature scheme. + fn new(der: &PrivatePkcs8KeyDer<'_>, scheme: SignatureScheme) -> Result { + match Ed25519KeyPair::from_pkcs8_maybe_unchecked(der.secret_pkcs8_der()) { + Ok(key_pair) => Ok(Self { + key: Arc::new(key_pair), + scheme, + }), + Err(e) => Err(Error::General(format!( + "failed to parse Ed25519 private key: {e}" + ))), + } + } +} + +impl SigningKey for Ed25519SigningKey { + fn choose_scheme(&self, offered: &[SignatureScheme]) -> Option> { + if offered.contains(&self.scheme) { + Some(Box::new(Ed25519Signer { + key: self.key.clone(), + scheme: self.scheme, + })) + } else { + None + } + } + + fn public_key(&self) -> Option> { + Some(public_key_to_spki(&alg_id::ED25519, self.key.public_key())) + } + + fn algorithm(&self) -> SignatureAlgorithm { + self.scheme.algorithm() + } +} + +impl Debug for Ed25519SigningKey { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.debug_struct("Ed25519SigningKey") + .field("algorithm", &self.algorithm()) + .finish() + } +} + +struct Ed25519Signer { + key: Arc, + scheme: SignatureScheme, +} + +impl Signer for Ed25519Signer { + fn sign(&self, message: &[u8]) -> Result, Error> { + Ok(self.key.sign(message).as_ref().into()) + } + + fn scheme(&self) -> SignatureScheme { + self.scheme + } +} + +impl Debug for Ed25519Signer { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.debug_struct("Ed25519Signer") + .field("scheme", &self.scheme) + .finish() + } +} + +#[cfg(test)] +mod tests { + use alloc::format; + + use pki_types::{PrivatePkcs1KeyDer, PrivateSec1KeyDer}; + + use super::*; + + #[test] + fn can_load_ecdsa_nistp256_pkcs8() { + let key = + PrivatePkcs8KeyDer::from(&include_bytes!("../../testdata/nistp256key.pkcs8.der")[..]); + assert!(any_eddsa_type(&key).is_err()); + let key = PrivateKeyDer::Pkcs8(key); + assert!(any_supported_type(&key).is_ok()); + assert!(any_ecdsa_type(&key).is_ok()); + } + + #[test] + fn can_load_ecdsa_nistp256_sec1() { + let key = PrivateKeyDer::Sec1(PrivateSec1KeyDer::from( + &include_bytes!("../../testdata/nistp256key.der")[..], + )); + assert!(any_supported_type(&key).is_ok()); + assert!(any_ecdsa_type(&key).is_ok()); + } + + #[test] + fn can_sign_ecdsa_nistp256() { + let key = PrivateKeyDer::Sec1(PrivateSec1KeyDer::from( + &include_bytes!("../../testdata/nistp256key.der")[..], + )); + + let k = any_supported_type(&key).unwrap(); + assert_eq!(format!("{k:?}"), "EcdsaSigningKey { algorithm: ECDSA }"); + assert_eq!(k.algorithm(), SignatureAlgorithm::ECDSA); + + assert!( + k.choose_scheme(&[SignatureScheme::RSA_PKCS1_SHA256]) + .is_none() + ); + assert!( + k.choose_scheme(&[SignatureScheme::ECDSA_NISTP384_SHA384]) + .is_none() + ); + let s = k + .choose_scheme(&[SignatureScheme::ECDSA_NISTP256_SHA256]) + .unwrap(); + assert_eq!( + format!("{s:?}"), + "EcdsaSigner { scheme: ECDSA_NISTP256_SHA256 }" + ); + assert_eq!(s.scheme(), SignatureScheme::ECDSA_NISTP256_SHA256); + // nb. signature is variable length and asn.1-encoded + assert!( + s.sign(b"hello") + .unwrap() + .starts_with(&[0x30]) + ); + } + + #[test] + fn can_load_ecdsa_nistp384_pkcs8() { + let key = + PrivatePkcs8KeyDer::from(&include_bytes!("../../testdata/nistp384key.pkcs8.der")[..]); + assert!(any_eddsa_type(&key).is_err()); + let key = PrivateKeyDer::Pkcs8(key); + assert!(any_supported_type(&key).is_ok()); + assert!(any_ecdsa_type(&key).is_ok()); + } + + #[test] + fn can_load_ecdsa_nistp384_sec1() { + let key = PrivateKeyDer::Sec1(PrivateSec1KeyDer::from( + &include_bytes!("../../testdata/nistp384key.der")[..], + )); + assert!(any_supported_type(&key).is_ok()); + assert!(any_ecdsa_type(&key).is_ok()); + } + + #[test] + fn can_sign_ecdsa_nistp384() { + let key = PrivateKeyDer::Sec1(PrivateSec1KeyDer::from( + &include_bytes!("../../testdata/nistp384key.der")[..], + )); + + let k = any_supported_type(&key).unwrap(); + assert_eq!(format!("{k:?}"), "EcdsaSigningKey { algorithm: ECDSA }"); + assert_eq!(k.algorithm(), SignatureAlgorithm::ECDSA); + + assert!( + k.choose_scheme(&[SignatureScheme::RSA_PKCS1_SHA256]) + .is_none() + ); + assert!( + k.choose_scheme(&[SignatureScheme::ECDSA_NISTP256_SHA256]) + .is_none() + ); + let s = k + .choose_scheme(&[SignatureScheme::ECDSA_NISTP384_SHA384]) + .unwrap(); + assert_eq!( + format!("{s:?}"), + "EcdsaSigner { scheme: ECDSA_NISTP384_SHA384 }" + ); + assert_eq!(s.scheme(), SignatureScheme::ECDSA_NISTP384_SHA384); + // nb. signature is variable length and asn.1-encoded + assert!( + s.sign(b"hello") + .unwrap() + .starts_with(&[0x30]) + ); + } + + #[test] + fn can_load_ecdsa_nistp521_pkcs8() { + let key = + PrivatePkcs8KeyDer::from(&include_bytes!("../../testdata/nistp521key.pkcs8.der")[..]); + assert!(any_eddsa_type(&key).is_err()); + let key = PrivateKeyDer::Pkcs8(key); + assert!(any_supported_type(&key).is_ok()); + assert!(any_ecdsa_type(&key).is_ok()); + } + + #[test] + fn can_load_ecdsa_nistp521_sec1() { + let key = PrivateKeyDer::Sec1(PrivateSec1KeyDer::from( + &include_bytes!("../../testdata/nistp521key.der")[..], + )); + assert!(any_supported_type(&key).is_ok()); + assert!(any_ecdsa_type(&key).is_ok()); + } + + #[test] + fn can_sign_ecdsa_nistp521() { + let key = PrivateKeyDer::Sec1(PrivateSec1KeyDer::from( + &include_bytes!("../../testdata/nistp521key.der")[..], + )); + + let k = any_supported_type(&key).unwrap(); + assert_eq!(format!("{k:?}"), "EcdsaSigningKey { algorithm: ECDSA }"); + assert_eq!(k.algorithm(), SignatureAlgorithm::ECDSA); + + assert!( + k.choose_scheme(&[SignatureScheme::RSA_PKCS1_SHA256]) + .is_none() + ); + assert!( + k.choose_scheme(&[SignatureScheme::ECDSA_NISTP256_SHA256]) + .is_none() + ); + assert!( + k.choose_scheme(&[SignatureScheme::ECDSA_NISTP384_SHA384]) + .is_none() + ); + let s = k + .choose_scheme(&[SignatureScheme::ECDSA_NISTP521_SHA512]) + .unwrap(); + assert_eq!( + format!("{s:?}"), + "EcdsaSigner { scheme: ECDSA_NISTP521_SHA512 }" + ); + assert_eq!(s.scheme(), SignatureScheme::ECDSA_NISTP521_SHA512); + // nb. signature is variable length and asn.1-encoded + assert!( + s.sign(b"hello") + .unwrap() + .starts_with(&[0x30]) + ); + } + + #[test] + fn can_load_eddsa_pkcs8() { + let key = PrivatePkcs8KeyDer::from(&include_bytes!("../../testdata/eddsakey.der")[..]); + assert!(any_eddsa_type(&key).is_ok()); + let key = PrivateKeyDer::Pkcs8(key); + assert!(any_supported_type(&key).is_ok()); + assert!(any_ecdsa_type(&key).is_err()); + } + + #[test] + fn can_sign_eddsa() { + let key = PrivatePkcs8KeyDer::from(&include_bytes!("../../testdata/eddsakey.der")[..]); + + let k = any_eddsa_type(&key).unwrap(); + assert_eq!(format!("{k:?}"), "Ed25519SigningKey { algorithm: ED25519 }"); + assert_eq!(k.algorithm(), SignatureAlgorithm::ED25519); + + assert!( + k.choose_scheme(&[SignatureScheme::RSA_PKCS1_SHA256]) + .is_none() + ); + assert!( + k.choose_scheme(&[SignatureScheme::ECDSA_NISTP256_SHA256]) + .is_none() + ); + let s = k + .choose_scheme(&[SignatureScheme::ED25519]) + .unwrap(); + assert_eq!(format!("{s:?}"), "Ed25519Signer { scheme: ED25519 }"); + assert_eq!(s.scheme(), SignatureScheme::ED25519); + assert_eq!(s.sign(b"hello").unwrap().len(), 64); + } + + #[test] + fn can_load_rsa2048_pkcs8() { + let key = + PrivatePkcs8KeyDer::from(&include_bytes!("../../testdata/rsa2048key.pkcs8.der")[..]); + assert!(any_eddsa_type(&key).is_err()); + let key = PrivateKeyDer::Pkcs8(key); + assert!(any_supported_type(&key).is_ok()); + assert!(any_ecdsa_type(&key).is_err()); + } + + #[test] + fn can_load_rsa2048_pkcs1() { + let key = PrivateKeyDer::Pkcs1(PrivatePkcs1KeyDer::from( + &include_bytes!("../../testdata/rsa2048key.pkcs1.der")[..], + )); + assert!(any_supported_type(&key).is_ok()); + assert!(any_ecdsa_type(&key).is_err()); + } + + #[test] + fn can_sign_rsa2048() { + let key = PrivateKeyDer::Pkcs8(PrivatePkcs8KeyDer::from( + &include_bytes!("../../testdata/rsa2048key.pkcs8.der")[..], + )); + + let k = any_supported_type(&key).unwrap(); + assert_eq!(format!("{k:?}"), "RsaSigningKey { algorithm: RSA }"); + assert_eq!(k.algorithm(), SignatureAlgorithm::RSA); + + assert!( + k.choose_scheme(&[SignatureScheme::ECDSA_NISTP256_SHA256]) + .is_none() + ); + assert!( + k.choose_scheme(&[SignatureScheme::ED25519]) + .is_none() + ); + + let s = k + .choose_scheme(&[SignatureScheme::RSA_PSS_SHA256]) + .unwrap(); + assert_eq!(format!("{s:?}"), "RsaSigner { scheme: RSA_PSS_SHA256 }"); + assert_eq!(s.scheme(), SignatureScheme::RSA_PSS_SHA256); + assert_eq!(s.sign(b"hello").unwrap().len(), 256); + + for scheme in &[ + SignatureScheme::RSA_PKCS1_SHA256, + SignatureScheme::RSA_PKCS1_SHA384, + SignatureScheme::RSA_PKCS1_SHA512, + SignatureScheme::RSA_PSS_SHA256, + SignatureScheme::RSA_PSS_SHA384, + SignatureScheme::RSA_PSS_SHA512, + ] { + k.choose_scheme(&[*scheme]).unwrap(); + } + } + + #[test] + fn cannot_load_invalid_pkcs8_encoding() { + let key = PrivateKeyDer::Pkcs8(PrivatePkcs8KeyDer::from(&b"invalid"[..])); + assert_eq!( + any_supported_type(&key).err(), + Some(Error::General( + "failed to parse private key as RSA, ECDSA, or EdDSA".into() + )) + ); + assert_eq!( + any_ecdsa_type(&key).err(), + Some(Error::General( + "failed to parse ECDSA private key as PKCS#8 or SEC1".into() + )) + ); + assert_eq!( + RsaSigningKey::new(&key).err(), + Some(Error::General( + "failed to parse RSA private key: InvalidEncoding".into() + )) + ); + } +} + +#[cfg(bench)] +mod benchmarks { + use super::{PrivateKeyDer, PrivatePkcs8KeyDer, SignatureScheme}; + + #[bench] + fn bench_rsa2048_pkcs1_sha256(b: &mut test::Bencher) { + let key = PrivateKeyDer::Pkcs8(PrivatePkcs8KeyDer::from( + &include_bytes!("../../testdata/rsa2048key.pkcs8.der")[..], + )); + let sk = super::any_supported_type(&key).unwrap(); + let signer = sk + .choose_scheme(&[SignatureScheme::RSA_PKCS1_SHA256]) + .unwrap(); + + b.iter(|| { + test::black_box( + signer + .sign(SAMPLE_TLS13_MESSAGE) + .unwrap(), + ); + }); + } + + #[bench] + fn bench_rsa2048_pss_sha256(b: &mut test::Bencher) { + let key = PrivateKeyDer::Pkcs8(PrivatePkcs8KeyDer::from( + &include_bytes!("../../testdata/rsa2048key.pkcs8.der")[..], + )); + let sk = super::any_supported_type(&key).unwrap(); + let signer = sk + .choose_scheme(&[SignatureScheme::RSA_PSS_SHA256]) + .unwrap(); + + b.iter(|| { + test::black_box( + signer + .sign(SAMPLE_TLS13_MESSAGE) + .unwrap(), + ); + }); + } + + #[bench] + fn bench_eddsa(b: &mut test::Bencher) { + let key = PrivateKeyDer::Pkcs8(PrivatePkcs8KeyDer::from( + &include_bytes!("../../testdata/eddsakey.der")[..], + )); + let sk = super::any_supported_type(&key).unwrap(); + let signer = sk + .choose_scheme(&[SignatureScheme::ED25519]) + .unwrap(); + + b.iter(|| { + test::black_box( + signer + .sign(SAMPLE_TLS13_MESSAGE) + .unwrap(), + ); + }); + } + + #[bench] + fn bench_ecdsa_p256_sha256(b: &mut test::Bencher) { + let key = PrivateKeyDer::Pkcs8(PrivatePkcs8KeyDer::from( + &include_bytes!("../../testdata/nistp256key.pkcs8.der")[..], + )); + let sk = super::any_supported_type(&key).unwrap(); + let signer = sk + .choose_scheme(&[SignatureScheme::ECDSA_NISTP256_SHA256]) + .unwrap(); + + b.iter(|| { + test::black_box( + signer + .sign(SAMPLE_TLS13_MESSAGE) + .unwrap(), + ); + }); + } + + #[bench] + fn bench_ecdsa_p384_sha384(b: &mut test::Bencher) { + let key = PrivateKeyDer::Pkcs8(PrivatePkcs8KeyDer::from( + &include_bytes!("../../testdata/nistp384key.pkcs8.der")[..], + )); + let sk = super::any_supported_type(&key).unwrap(); + let signer = sk + .choose_scheme(&[SignatureScheme::ECDSA_NISTP384_SHA384]) + .unwrap(); + + b.iter(|| { + test::black_box( + signer + .sign(SAMPLE_TLS13_MESSAGE) + .unwrap(), + ); + }); + } + + #[bench] + fn bench_ecdsa_p521_sha512(b: &mut test::Bencher) { + let key = PrivateKeyDer::Pkcs8(PrivatePkcs8KeyDer::from( + &include_bytes!("../../testdata/nistp521key.pkcs8.der")[..], + )); + let sk = super::any_supported_type(&key).unwrap(); + let signer = sk + .choose_scheme(&[SignatureScheme::ECDSA_NISTP521_SHA512]) + .unwrap(); + + b.iter(|| { + test::black_box( + signer + .sign(SAMPLE_TLS13_MESSAGE) + .unwrap(), + ); + }); + } + + #[bench] + fn bench_load_and_validate_rsa2048(b: &mut test::Bencher) { + let key = PrivateKeyDer::Pkcs8(PrivatePkcs8KeyDer::from( + &include_bytes!("../../testdata/rsa2048key.pkcs8.der")[..], + )); + + b.iter(|| { + test::black_box(super::any_supported_type(&key).unwrap()); + }); + } + + #[bench] + fn bench_load_and_validate_rsa4096(b: &mut test::Bencher) { + let key = PrivateKeyDer::Pkcs8(PrivatePkcs8KeyDer::from( + &include_bytes!("../../testdata/rsa4096key.pkcs8.der")[..], + )); + + b.iter(|| { + test::black_box(super::any_supported_type(&key).unwrap()); + }); + } + + #[bench] + fn bench_load_and_validate_p256(b: &mut test::Bencher) { + let key = PrivateKeyDer::Pkcs8(PrivatePkcs8KeyDer::from( + &include_bytes!("../../testdata/nistp256key.pkcs8.der")[..], + )); + + b.iter(|| { + test::black_box(super::any_ecdsa_type(&key).unwrap()); + }); + } + + #[bench] + fn bench_load_and_validate_p384(b: &mut test::Bencher) { + let key = PrivateKeyDer::Pkcs8(PrivatePkcs8KeyDer::from( + &include_bytes!("../../testdata/nistp384key.pkcs8.der")[..], + )); + + b.iter(|| { + test::black_box(super::any_ecdsa_type(&key).unwrap()); + }); + } + + #[bench] + fn bench_load_and_validate_p521(b: &mut test::Bencher) { + let key = PrivateKeyDer::Pkcs8(PrivatePkcs8KeyDer::from( + &include_bytes!("../../testdata/nistp521key.pkcs8.der")[..], + )); + + b.iter(|| { + test::black_box(super::any_ecdsa_type(&key).unwrap()); + }); + } + + #[bench] + fn bench_load_and_validate_eddsa(b: &mut test::Bencher) { + let key = PrivatePkcs8KeyDer::from(&include_bytes!("../../testdata/eddsakey.der")[..]); + + b.iter(|| { + test::black_box(super::any_eddsa_type(&key).unwrap()); + }); + } + + const SAMPLE_TLS13_MESSAGE: &[u8] = &[ + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x54, 0x4c, 0x53, 0x20, 0x31, 0x2e, 0x33, 0x2c, 0x20, 0x73, 0x65, + 0x72, 0x76, 0x65, 0x72, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, + 0x65, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x00, 0x04, 0xca, 0xc4, 0x48, 0x0e, 0x70, 0xf2, + 0x1b, 0xa9, 0x1c, 0x16, 0xca, 0x90, 0x48, 0xbe, 0x28, 0x2f, 0xc7, 0xf8, 0x9b, 0x87, 0x72, + 0x93, 0xda, 0x4d, 0x2f, 0x80, 0x80, 0x60, 0x1a, 0xd3, 0x08, 0xe2, 0xb7, 0x86, 0x14, 0x1b, + 0x54, 0xda, 0x9a, 0xc9, 0x6d, 0xe9, 0x66, 0xb4, 0x9f, 0xe2, 0x2c, + ]; +} diff --git a/http/vendor/rustls/src/crypto/aws_lc_rs/ticketer.rs b/http/vendor/rustls/src/crypto/aws_lc_rs/ticketer.rs new file mode 100644 index 0000000..44c7c21 --- /dev/null +++ b/http/vendor/rustls/src/crypto/aws_lc_rs/ticketer.rs @@ -0,0 +1,397 @@ +use alloc::boxed::Box; +use alloc::vec::Vec; +use core::fmt; +use core::fmt::{Debug, Formatter}; +use core::sync::atomic::{AtomicUsize, Ordering}; + +use aws_lc_rs::cipher::{ + AES_256, AES_256_KEY_LEN, AES_CBC_IV_LEN, DecryptionContext, PaddedBlockDecryptingKey, + PaddedBlockEncryptingKey, UnboundCipherKey, +}; +use aws_lc_rs::{hmac, iv}; + +use super::ring_like::rand::{SecureRandom, SystemRandom}; +use super::unspecified_err; +use crate::error::Error; +#[cfg(debug_assertions)] +use crate::log::debug; +use crate::polyfill::try_split_at; +use crate::rand::GetRandomFailed; +use crate::server::ProducesTickets; +use crate::sync::Arc; + +/// A concrete, safe ticket creation mechanism. +pub struct Ticketer {} + +impl Ticketer { + /// Make the recommended `Ticketer`. This produces tickets + /// with a 12 hour life and randomly generated keys. + /// + /// The `Ticketer` uses the [RFC 5077 §4] "Recommended Ticket Construction", + /// using AES 256 for encryption and HMAC-SHA256 for ciphertext authentication. + /// + /// [RFC 5077 §4]: https://www.rfc-editor.org/rfc/rfc5077#section-4 + #[cfg(feature = "std")] + pub fn new() -> Result, Error> { + Ok(Arc::new(crate::ticketer::TicketRotator::new( + 6 * 60 * 60, + make_ticket_generator, + )?)) + } +} + +fn make_ticket_generator() -> Result, GetRandomFailed> { + // NOTE(XXX): Unconditionally mapping errors to `GetRandomFailed` here is slightly + // misleading in some cases (e.g. failure to construct a padded block cipher encrypting key). + // However, we can't change the return type expected from a `TicketSwitcher` `generator` + // without breaking semver. + // Tracking in https://github.com/rustls/rustls/issues/2074 + Ok(Box::new( + Rfc5077Ticketer::new().map_err(|_| GetRandomFailed)?, + )) +} + +/// An RFC 5077 "Recommended Ticket Construction" implementation of a [`Ticketer`]. +struct Rfc5077Ticketer { + aes_encrypt_key: PaddedBlockEncryptingKey, + aes_decrypt_key: PaddedBlockDecryptingKey, + hmac_key: hmac::Key, + key_name: [u8; 16], + lifetime: u32, + maximum_ciphertext_len: AtomicUsize, +} + +impl Rfc5077Ticketer { + fn new() -> Result { + let rand = SystemRandom::new(); + + // Generate a random AES 256 key to use for AES CBC encryption. + let mut aes_key = [0u8; AES_256_KEY_LEN]; + rand.fill(&mut aes_key) + .map_err(|_| GetRandomFailed)?; + + // Convert the raw AES 256 key bytes into encrypting and decrypting keys using CBC mode and + // PKCS#7 padding. We don't want to store just the raw key bytes as constructing the + // cipher keys has some setup overhead. We can't store just the `UnboundCipherKey` since + // constructing the padded encrypt/decrypt specific types consume the `UnboundCipherKey`. + let aes_encrypt_key = + UnboundCipherKey::new(&AES_256, &aes_key[..]).map_err(unspecified_err)?; + let aes_encrypt_key = + PaddedBlockEncryptingKey::cbc_pkcs7(aes_encrypt_key).map_err(unspecified_err)?; + + // Convert the raw AES 256 key bytes into a decrypting key using CBC PKCS#7 padding. + let aes_decrypt_key = + UnboundCipherKey::new(&AES_256, &aes_key[..]).map_err(unspecified_err)?; + let aes_decrypt_key = + PaddedBlockDecryptingKey::cbc_pkcs7(aes_decrypt_key).map_err(unspecified_err)?; + + // Generate a random HMAC SHA256 key to use for HMAC authentication. + let hmac_key = hmac::Key::generate(hmac::HMAC_SHA256, &rand).map_err(unspecified_err)?; + + // Generate a random key name. + let mut key_name = [0u8; 16]; + rand.fill(&mut key_name) + .map_err(|_| GetRandomFailed)?; + + Ok(Self { + aes_encrypt_key, + aes_decrypt_key, + hmac_key, + key_name, + lifetime: 60 * 60 * 12, + maximum_ciphertext_len: AtomicUsize::new(0), + }) + } +} + +impl ProducesTickets for Rfc5077Ticketer { + fn enabled(&self) -> bool { + true + } + + fn lifetime(&self) -> u32 { + self.lifetime + } + + /// Encrypt `message` and return the ciphertext. + fn encrypt(&self, message: &[u8]) -> Option> { + // Encrypt the ticket state - the cipher module handles generating a random IV of + // appropriate size, returning it in the `DecryptionContext`. + let mut encrypted_state = Vec::from(message); + let dec_ctx = self + .aes_encrypt_key + .encrypt(&mut encrypted_state) + .ok()?; + let iv: &[u8] = (&dec_ctx).try_into().ok()?; + + // Produce the MAC tag over the relevant context & encrypted state. + // Quoting RFC 5077: + // "The Message Authentication Code (MAC) is calculated using HMAC-SHA-256 over + // key_name (16 octets) and IV (16 octets), followed by the length of + // the encrypted_state field (2 octets) and its contents (variable + // length)." + let mut hmac_data = + Vec::with_capacity(self.key_name.len() + iv.len() + 2 + encrypted_state.len()); + hmac_data.extend(&self.key_name); + hmac_data.extend(iv); + hmac_data.extend( + u16::try_from(encrypted_state.len()) + .ok()? + .to_be_bytes(), + ); + hmac_data.extend(&encrypted_state); + let tag = hmac::sign(&self.hmac_key, &hmac_data); + let tag = tag.as_ref(); + + // Combine the context, the encrypted state, and the tag to produce the final ciphertext. + // Ciphertext structure is: + // key_name: [u8; 16] + // iv: [u8; 16] + // encrypted_state: [u8, _] + // mac tag: [u8; 32] + let mut ciphertext = + Vec::with_capacity(self.key_name.len() + iv.len() + encrypted_state.len() + tag.len()); + ciphertext.extend(self.key_name); + ciphertext.extend(iv); + ciphertext.extend(encrypted_state); + ciphertext.extend(tag); + + self.maximum_ciphertext_len + .fetch_max(ciphertext.len(), Ordering::SeqCst); + + Some(ciphertext) + } + + fn decrypt(&self, ciphertext: &[u8]) -> Option> { + if ciphertext.len() + > self + .maximum_ciphertext_len + .load(Ordering::SeqCst) + { + #[cfg(debug_assertions)] + debug!("rejected over-length ticket"); + return None; + } + + // Split off the key name from the remaining ciphertext. + let (alleged_key_name, ciphertext) = try_split_at(ciphertext, self.key_name.len())?; + + // Split off the IV from the remaining ciphertext. + let (iv, ciphertext) = try_split_at(ciphertext, AES_CBC_IV_LEN)?; + + // And finally, split the encrypted state from the tag. + let tag_len = self + .hmac_key + .algorithm() + .digest_algorithm() + .output_len(); + let (enc_state, mac) = try_split_at(ciphertext, ciphertext.len() - tag_len)?; + + // Reconstitute the HMAC data to verify the tag. + let mut hmac_data = + Vec::with_capacity(alleged_key_name.len() + iv.len() + 2 + enc_state.len()); + hmac_data.extend(alleged_key_name); + hmac_data.extend(iv); + hmac_data.extend( + u16::try_from(enc_state.len()) + .ok()? + .to_be_bytes(), + ); + hmac_data.extend(enc_state); + hmac::verify(&self.hmac_key, &hmac_data, mac).ok()?; + + // Convert the raw IV back into an appropriate decryption context. + let iv = iv::FixedLength::try_from(iv).ok()?; + let dec_context = DecryptionContext::Iv128(iv); + + // And finally, decrypt the encrypted state. + let mut out = Vec::from(enc_state); + let plaintext = self + .aes_decrypt_key + .decrypt(&mut out, dec_context) + .ok()?; + + Some(plaintext.into()) + } +} + +impl Debug for Rfc5077Ticketer { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + // Note: we deliberately omit keys from the debug output. + f.debug_struct("Rfc5077Ticketer") + .field("lifetime", &self.lifetime) + .finish() + } +} + +#[cfg(test)] +mod tests { + use core::time::Duration; + + use pki_types::UnixTime; + + use super::*; + + #[test] + fn basic_pairwise_test() { + let t = Ticketer::new().unwrap(); + assert!(t.enabled()); + let cipher = t.encrypt(b"hello world").unwrap(); + let plain = t.decrypt(&cipher).unwrap(); + assert_eq!(plain, b"hello world"); + } + + #[test] + fn refuses_decrypt_before_encrypt() { + let t = Ticketer::new().unwrap(); + assert_eq!(t.decrypt(b"hello"), None); + } + + #[test] + fn refuses_decrypt_larger_than_largest_encryption() { + let t = Ticketer::new().unwrap(); + let mut cipher = t.encrypt(b"hello world").unwrap(); + assert_eq!(t.decrypt(&cipher), Some(b"hello world".to_vec())); + + // obviously this would never work anyway, but this + // and `cannot_decrypt_before_encrypt` exercise the + // first branch in `decrypt()` + cipher.push(0); + assert_eq!(t.decrypt(&cipher), None); + } + + #[test] + fn ticketrotator_switching_test() { + let t = Arc::new(crate::ticketer::TicketRotator::new(1, make_ticket_generator).unwrap()); + let now = UnixTime::now(); + let cipher1 = t.encrypt(b"ticket 1").unwrap(); + assert_eq!(t.decrypt(&cipher1).unwrap(), b"ticket 1"); + { + // Trigger new ticketer + t.maybe_roll(UnixTime::since_unix_epoch(Duration::from_secs( + now.as_secs() + 10, + ))); + } + let cipher2 = t.encrypt(b"ticket 2").unwrap(); + assert_eq!(t.decrypt(&cipher1).unwrap(), b"ticket 1"); + assert_eq!(t.decrypt(&cipher2).unwrap(), b"ticket 2"); + { + // Trigger new ticketer + t.maybe_roll(UnixTime::since_unix_epoch(Duration::from_secs( + now.as_secs() + 20, + ))); + } + let cipher3 = t.encrypt(b"ticket 3").unwrap(); + assert!(t.decrypt(&cipher1).is_none()); + assert_eq!(t.decrypt(&cipher2).unwrap(), b"ticket 2"); + assert_eq!(t.decrypt(&cipher3).unwrap(), b"ticket 3"); + } + + #[test] + fn ticketrotator_remains_usable_over_temporary_ticketer_creation_failure() { + let mut t = crate::ticketer::TicketRotator::new(1, make_ticket_generator).unwrap(); + let now = UnixTime::now(); + let cipher1 = t.encrypt(b"ticket 1").unwrap(); + assert_eq!(t.decrypt(&cipher1).unwrap(), b"ticket 1"); + t.generator = fail_generator; + { + // Failed new ticketer; this means we still need to + // rotate. + t.maybe_roll(UnixTime::since_unix_epoch(Duration::from_secs( + now.as_secs() + 10, + ))); + } + + // check post-failure encryption/decryption still works + let cipher2 = t.encrypt(b"ticket 2").unwrap(); + assert_eq!(t.decrypt(&cipher1).unwrap(), b"ticket 1"); + assert_eq!(t.decrypt(&cipher2).unwrap(), b"ticket 2"); + + // do the rotation for real + t.generator = make_ticket_generator; + { + t.maybe_roll(UnixTime::since_unix_epoch(Duration::from_secs( + now.as_secs() + 20, + ))); + } + let cipher3 = t.encrypt(b"ticket 3").unwrap(); + assert!(t.decrypt(&cipher1).is_some()); + assert_eq!(t.decrypt(&cipher2).unwrap(), b"ticket 2"); + assert_eq!(t.decrypt(&cipher3).unwrap(), b"ticket 3"); + } + + #[test] + fn ticketswitcher_switching_test() { + #[expect(deprecated)] + let t = Arc::new(crate::ticketer::TicketSwitcher::new(1, make_ticket_generator).unwrap()); + let now = UnixTime::now(); + let cipher1 = t.encrypt(b"ticket 1").unwrap(); + assert_eq!(t.decrypt(&cipher1).unwrap(), b"ticket 1"); + { + // Trigger new ticketer + t.maybe_roll(UnixTime::since_unix_epoch(Duration::from_secs( + now.as_secs() + 10, + ))); + } + let cipher2 = t.encrypt(b"ticket 2").unwrap(); + assert_eq!(t.decrypt(&cipher1).unwrap(), b"ticket 1"); + assert_eq!(t.decrypt(&cipher2).unwrap(), b"ticket 2"); + { + // Trigger new ticketer + t.maybe_roll(UnixTime::since_unix_epoch(Duration::from_secs( + now.as_secs() + 20, + ))); + } + let cipher3 = t.encrypt(b"ticket 3").unwrap(); + assert!(t.decrypt(&cipher1).is_none()); + assert_eq!(t.decrypt(&cipher2).unwrap(), b"ticket 2"); + assert_eq!(t.decrypt(&cipher3).unwrap(), b"ticket 3"); + } + + #[test] + fn ticketswitcher_recover_test() { + #[expect(deprecated)] + let mut t = crate::ticketer::TicketSwitcher::new(1, make_ticket_generator).unwrap(); + let now = UnixTime::now(); + let cipher1 = t.encrypt(b"ticket 1").unwrap(); + assert_eq!(t.decrypt(&cipher1).unwrap(), b"ticket 1"); + t.generator = fail_generator; + { + // Failed new ticketer + t.maybe_roll(UnixTime::since_unix_epoch(Duration::from_secs( + now.as_secs() + 10, + ))); + } + t.generator = make_ticket_generator; + let cipher2 = t.encrypt(b"ticket 2").unwrap(); + assert_eq!(t.decrypt(&cipher1).unwrap(), b"ticket 1"); + assert_eq!(t.decrypt(&cipher2).unwrap(), b"ticket 2"); + { + // recover + t.maybe_roll(UnixTime::since_unix_epoch(Duration::from_secs( + now.as_secs() + 20, + ))); + } + let cipher3 = t.encrypt(b"ticket 3").unwrap(); + assert!(t.decrypt(&cipher1).is_none()); + assert_eq!(t.decrypt(&cipher2).unwrap(), b"ticket 2"); + assert_eq!(t.decrypt(&cipher3).unwrap(), b"ticket 3"); + } + + #[test] + fn rfc5077ticketer_is_debug_and_producestickets() { + use alloc::format; + + use super::*; + + let t = make_ticket_generator().unwrap(); + + assert_eq!(format!("{t:?}"), "Rfc5077Ticketer { lifetime: 43200 }"); + assert!(t.enabled()); + assert_eq!(t.lifetime(), 43200); + } + + fn fail_generator() -> Result, GetRandomFailed> { + Err(GetRandomFailed) + } +} diff --git a/http/vendor/rustls/src/crypto/aws_lc_rs/tls12.rs b/http/vendor/rustls/src/crypto/aws_lc_rs/tls12.rs new file mode 100644 index 0000000..3845af5 --- /dev/null +++ b/http/vendor/rustls/src/crypto/aws_lc_rs/tls12.rs @@ -0,0 +1,465 @@ +use alloc::boxed::Box; + +use aws_lc_rs::{aead, tls_prf}; + +use crate::crypto::cipher::{ + AeadKey, InboundOpaqueMessage, Iv, KeyBlockShape, MessageDecrypter, MessageEncrypter, + NONCE_LEN, Nonce, Tls12AeadAlgorithm, UnsupportedOperationError, make_tls12_aad, +}; +use crate::crypto::tls12::Prf; +use crate::crypto::{ActiveKeyExchange, KeyExchangeAlgorithm}; +use crate::enums::{CipherSuite, SignatureScheme}; +use crate::error::Error; +use crate::msgs::fragmenter::MAX_FRAGMENT_LEN; +use crate::msgs::message::{ + InboundPlainMessage, OutboundOpaqueMessage, OutboundPlainMessage, PrefixedPayload, +}; +use crate::suites::{CipherSuiteCommon, ConnectionTrafficSecrets, SupportedCipherSuite}; +use crate::tls12::Tls12CipherSuite; +use crate::version::TLS12; + +/// The TLS1.2 ciphersuite TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256. +pub static TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256: SupportedCipherSuite = + SupportedCipherSuite::Tls12(&Tls12CipherSuite { + common: CipherSuiteCommon { + suite: CipherSuite::TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256, + hash_provider: &super::hash::SHA256, + confidentiality_limit: u64::MAX, + }, + kx: KeyExchangeAlgorithm::ECDHE, + sign: TLS12_ECDSA_SCHEMES, + aead_alg: &ChaCha20Poly1305, + prf_provider: &Tls12Prf(&tls_prf::P_SHA256), + }); + +/// The TLS1.2 ciphersuite TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 +pub static TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256: SupportedCipherSuite = + SupportedCipherSuite::Tls12(&Tls12CipherSuite { + common: CipherSuiteCommon { + suite: CipherSuite::TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, + hash_provider: &super::hash::SHA256, + confidentiality_limit: u64::MAX, + }, + kx: KeyExchangeAlgorithm::ECDHE, + sign: TLS12_RSA_SCHEMES, + aead_alg: &ChaCha20Poly1305, + prf_provider: &Tls12Prf(&tls_prf::P_SHA256), + }); + +/// The TLS1.2 ciphersuite TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 +pub static TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256: SupportedCipherSuite = + SupportedCipherSuite::Tls12(&Tls12CipherSuite { + common: CipherSuiteCommon { + suite: CipherSuite::TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, + hash_provider: &super::hash::SHA256, + confidentiality_limit: 1 << 24, + }, + kx: KeyExchangeAlgorithm::ECDHE, + sign: TLS12_RSA_SCHEMES, + aead_alg: &AES128_GCM, + prf_provider: &Tls12Prf(&tls_prf::P_SHA256), + }); + +/// The TLS1.2 ciphersuite TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 +pub static TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384: SupportedCipherSuite = + SupportedCipherSuite::Tls12(&Tls12CipherSuite { + common: CipherSuiteCommon { + suite: CipherSuite::TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, + hash_provider: &super::hash::SHA384, + confidentiality_limit: 1 << 24, + }, + kx: KeyExchangeAlgorithm::ECDHE, + sign: TLS12_RSA_SCHEMES, + aead_alg: &AES256_GCM, + prf_provider: &Tls12Prf(&tls_prf::P_SHA384), + }); + +/// The TLS1.2 ciphersuite TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 +pub static TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256: SupportedCipherSuite = + SupportedCipherSuite::Tls12(&Tls12CipherSuite { + common: CipherSuiteCommon { + suite: CipherSuite::TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, + hash_provider: &super::hash::SHA256, + confidentiality_limit: 1 << 24, + }, + kx: KeyExchangeAlgorithm::ECDHE, + sign: TLS12_ECDSA_SCHEMES, + aead_alg: &AES128_GCM, + prf_provider: &Tls12Prf(&tls_prf::P_SHA256), + }); + +/// The TLS1.2 ciphersuite TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 +pub static TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384: SupportedCipherSuite = + SupportedCipherSuite::Tls12(&Tls12CipherSuite { + common: CipherSuiteCommon { + suite: CipherSuite::TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, + hash_provider: &super::hash::SHA384, + confidentiality_limit: 1 << 24, + }, + kx: KeyExchangeAlgorithm::ECDHE, + sign: TLS12_ECDSA_SCHEMES, + aead_alg: &AES256_GCM, + prf_provider: &Tls12Prf(&tls_prf::P_SHA384), + }); + +static TLS12_ECDSA_SCHEMES: &[SignatureScheme] = &[ + SignatureScheme::ED25519, + SignatureScheme::ECDSA_NISTP521_SHA512, + SignatureScheme::ECDSA_NISTP384_SHA384, + SignatureScheme::ECDSA_NISTP256_SHA256, +]; + +static TLS12_RSA_SCHEMES: &[SignatureScheme] = &[ + SignatureScheme::RSA_PSS_SHA512, + SignatureScheme::RSA_PSS_SHA384, + SignatureScheme::RSA_PSS_SHA256, + SignatureScheme::RSA_PKCS1_SHA512, + SignatureScheme::RSA_PKCS1_SHA384, + SignatureScheme::RSA_PKCS1_SHA256, +]; + +pub(crate) static AES128_GCM: GcmAlgorithm = GcmAlgorithm(&aead::AES_128_GCM); +pub(crate) static AES256_GCM: GcmAlgorithm = GcmAlgorithm(&aead::AES_256_GCM); + +pub(crate) struct GcmAlgorithm(&'static aead::Algorithm); + +impl Tls12AeadAlgorithm for GcmAlgorithm { + fn decrypter(&self, dec_key: AeadKey, dec_iv: &[u8]) -> Box { + // safety: see `encrypter()`. + let dec_key = + aead::TlsRecordOpeningKey::new(self.0, aead::TlsProtocolId::TLS12, dec_key.as_ref()) + .unwrap(); + + let mut ret = GcmMessageDecrypter { + dec_key, + dec_salt: [0u8; 4], + }; + + debug_assert_eq!(dec_iv.len(), 4); + ret.dec_salt.copy_from_slice(dec_iv); + Box::new(ret) + } + + fn encrypter( + &self, + enc_key: AeadKey, + write_iv: &[u8], + explicit: &[u8], + ) -> Box { + // safety: `TlsRecordSealingKey::new` fails if + // - `enc_key`'s length is wrong for `algorithm`. But the length is defined by + // `algorithm.key_len()` in `key_block_shape()`, below. + // - `algorithm` is not supported: but `AES_128_GCM` and `AES_256_GCM` is. + // thus, this `unwrap()` is unreachable. + // + // `TlsProtocolId::TLS13` is deliberate: we reuse the nonce construction from + // RFC7905 and TLS13: a random starting point, XOR'd with the sequence number. This means + // `TlsProtocolId::TLS12` (which wants to see a plain sequence number) is unsuitable. + // + // The most important property is that nonce is unique per key, which is satisfied by + // this construction, even if the nonce is not monotonically increasing. + let enc_key = + aead::TlsRecordSealingKey::new(self.0, aead::TlsProtocolId::TLS13, enc_key.as_ref()) + .unwrap(); + let iv = gcm_iv(write_iv, explicit); + Box::new(GcmMessageEncrypter { enc_key, iv }) + } + + fn key_block_shape(&self) -> KeyBlockShape { + KeyBlockShape { + enc_key_len: self.0.key_len(), + fixed_iv_len: 4, + explicit_nonce_len: 8, + } + } + + fn extract_keys( + &self, + key: AeadKey, + write_iv: &[u8], + explicit: &[u8], + ) -> Result { + let iv = gcm_iv(write_iv, explicit); + Ok(match self.0.key_len() { + 16 => ConnectionTrafficSecrets::Aes128Gcm { key, iv }, + 32 => ConnectionTrafficSecrets::Aes256Gcm { key, iv }, + _ => unreachable!(), + }) + } + + fn fips(&self) -> bool { + super::fips() + } +} + +pub(crate) struct ChaCha20Poly1305; + +impl Tls12AeadAlgorithm for ChaCha20Poly1305 { + fn decrypter(&self, dec_key: AeadKey, iv: &[u8]) -> Box { + let dec_key = aead::LessSafeKey::new( + aead::UnboundKey::new(&aead::CHACHA20_POLY1305, dec_key.as_ref()).unwrap(), + ); + Box::new(ChaCha20Poly1305MessageDecrypter { + dec_key, + dec_offset: Iv::copy(iv), + }) + } + + fn encrypter(&self, enc_key: AeadKey, enc_iv: &[u8], _: &[u8]) -> Box { + let enc_key = aead::LessSafeKey::new( + aead::UnboundKey::new(&aead::CHACHA20_POLY1305, enc_key.as_ref()).unwrap(), + ); + Box::new(ChaCha20Poly1305MessageEncrypter { + enc_key, + enc_offset: Iv::copy(enc_iv), + }) + } + + fn key_block_shape(&self) -> KeyBlockShape { + KeyBlockShape { + enc_key_len: 32, + fixed_iv_len: 12, + explicit_nonce_len: 0, + } + } + + fn extract_keys( + &self, + key: AeadKey, + iv: &[u8], + _explicit: &[u8], + ) -> Result { + // This should always be true because KeyBlockShape and the Iv nonce len are in agreement. + debug_assert_eq!(aead::NONCE_LEN, iv.len()); + Ok(ConnectionTrafficSecrets::Chacha20Poly1305 { + key, + iv: Iv::new(iv[..].try_into().unwrap()), + }) + } + + fn fips(&self) -> bool { + false // not FIPS approved + } +} + +/// A `MessageEncrypter` for AES-GCM AEAD ciphersuites. TLS 1.2 only. +struct GcmMessageEncrypter { + enc_key: aead::TlsRecordSealingKey, + iv: Iv, +} + +/// A `MessageDecrypter` for AES-GCM AEAD ciphersuites. TLS1.2 only. +struct GcmMessageDecrypter { + dec_key: aead::TlsRecordOpeningKey, + dec_salt: [u8; 4], +} + +const GCM_EXPLICIT_NONCE_LEN: usize = 8; +const GCM_OVERHEAD: usize = GCM_EXPLICIT_NONCE_LEN + 16; + +impl MessageDecrypter for GcmMessageDecrypter { + fn decrypt<'a>( + &mut self, + mut msg: InboundOpaqueMessage<'a>, + seq: u64, + ) -> Result, Error> { + let payload = &msg.payload; + if payload.len() < GCM_OVERHEAD { + return Err(Error::DecryptError); + } + + let nonce = { + let mut nonce = [0u8; 12]; + nonce[..4].copy_from_slice(&self.dec_salt); + nonce[4..].copy_from_slice(&payload[..8]); + aead::Nonce::assume_unique_for_key(nonce) + }; + + let aad = aead::Aad::from(make_tls12_aad( + seq, + msg.typ, + msg.version, + payload.len() - GCM_OVERHEAD, + )); + + let payload = &mut msg.payload; + let plain_len = self + .dec_key + .open_in_place(nonce, aad, &mut payload[GCM_EXPLICIT_NONCE_LEN..]) + .map_err(|_| Error::DecryptError)? + .len(); + + if plain_len > MAX_FRAGMENT_LEN { + return Err(Error::PeerSentOversizedRecord); + } + + Ok( + msg.into_plain_message_range( + GCM_EXPLICIT_NONCE_LEN..GCM_EXPLICIT_NONCE_LEN + plain_len, + ), + ) + } +} + +impl MessageEncrypter for GcmMessageEncrypter { + fn encrypt( + &mut self, + msg: OutboundPlainMessage<'_>, + seq: u64, + ) -> Result { + let total_len = self.encrypted_payload_len(msg.payload.len()); + let mut payload = PrefixedPayload::with_capacity(total_len); + + let nonce = aead::Nonce::assume_unique_for_key(Nonce::new(&self.iv, seq).0); + let aad = aead::Aad::from(make_tls12_aad(seq, msg.typ, msg.version, msg.payload.len())); + payload.extend_from_slice(&nonce.as_ref()[4..]); + payload.extend_from_chunks(&msg.payload); + + self.enc_key + .seal_in_place_separate_tag(nonce, aad, &mut payload.as_mut()[GCM_EXPLICIT_NONCE_LEN..]) + .map(|tag| payload.extend_from_slice(tag.as_ref())) + .map_err(|_| Error::EncryptError)?; + + Ok(OutboundOpaqueMessage::new(msg.typ, msg.version, payload)) + } + + fn encrypted_payload_len(&self, payload_len: usize) -> usize { + payload_len + GCM_EXPLICIT_NONCE_LEN + self.enc_key.algorithm().tag_len() + } +} + +/// The RFC7905/RFC7539 ChaCha20Poly1305 construction. +/// This implementation does the AAD construction required in TLS1.2. +/// TLS1.3 uses `TLS13MessageEncrypter`. +struct ChaCha20Poly1305MessageEncrypter { + enc_key: aead::LessSafeKey, + enc_offset: Iv, +} + +/// The RFC7905/RFC7539 ChaCha20Poly1305 construction. +/// This implementation does the AAD construction required in TLS1.2. +/// TLS1.3 uses `TLS13MessageDecrypter`. +struct ChaCha20Poly1305MessageDecrypter { + dec_key: aead::LessSafeKey, + dec_offset: Iv, +} + +const CHACHAPOLY1305_OVERHEAD: usize = 16; + +impl MessageDecrypter for ChaCha20Poly1305MessageDecrypter { + fn decrypt<'a>( + &mut self, + mut msg: InboundOpaqueMessage<'a>, + seq: u64, + ) -> Result, Error> { + let payload = &msg.payload; + + if payload.len() < CHACHAPOLY1305_OVERHEAD { + return Err(Error::DecryptError); + } + + let nonce = aead::Nonce::assume_unique_for_key(Nonce::new(&self.dec_offset, seq).0); + let aad = aead::Aad::from(make_tls12_aad( + seq, + msg.typ, + msg.version, + payload.len() - CHACHAPOLY1305_OVERHEAD, + )); + + let payload = &mut msg.payload; + let plain_len = self + .dec_key + .open_in_place(nonce, aad, payload) + .map_err(|_| Error::DecryptError)? + .len(); + + if plain_len > MAX_FRAGMENT_LEN { + return Err(Error::PeerSentOversizedRecord); + } + + payload.truncate(plain_len); + Ok(msg.into_plain_message()) + } +} + +impl MessageEncrypter for ChaCha20Poly1305MessageEncrypter { + fn encrypt( + &mut self, + msg: OutboundPlainMessage<'_>, + seq: u64, + ) -> Result { + let total_len = self.encrypted_payload_len(msg.payload.len()); + let mut payload = PrefixedPayload::with_capacity(total_len); + + let nonce = aead::Nonce::assume_unique_for_key(Nonce::new(&self.enc_offset, seq).0); + let aad = aead::Aad::from(make_tls12_aad(seq, msg.typ, msg.version, msg.payload.len())); + payload.extend_from_chunks(&msg.payload); + + self.enc_key + .seal_in_place_append_tag(nonce, aad, &mut payload) + .map_err(|_| Error::EncryptError)?; + + Ok(OutboundOpaqueMessage::new(msg.typ, msg.version, payload)) + } + + fn encrypted_payload_len(&self, payload_len: usize) -> usize { + payload_len + self.enc_key.algorithm().tag_len() + } +} + +fn gcm_iv(write_iv: &[u8], explicit: &[u8]) -> Iv { + debug_assert_eq!(write_iv.len(), 4); + debug_assert_eq!(explicit.len(), 8); + + // The GCM nonce is constructed from a 32-bit 'salt' derived + // from the master-secret, and a 64-bit explicit part, + // with no specified construction. Thanks for that. + // + // We use the same construction as TLS1.3/ChaCha20Poly1305: + // a starting point extracted from the key block, xored with + // the sequence number. + let mut iv = [0; NONCE_LEN]; + iv[..4].copy_from_slice(write_iv); + iv[4..].copy_from_slice(explicit); + + Iv::new(iv) +} + +struct Tls12Prf(&'static tls_prf::Algorithm); + +impl Prf for Tls12Prf { + fn for_secret(&self, output: &mut [u8], secret: &[u8], label: &[u8], seed: &[u8]) { + // safety: + // - [1] is safe because our caller guarantees `secret` is non-empty; this is + // the only documented error case. + // - [2] is safe in practice because the only failure from `derive()` is due + // to zero `output.len()`; this is outlawed at higher levels + let derived = tls_prf::Secret::new(self.0, secret) + .unwrap() // [1] + .derive(label, seed, output.len()) + .unwrap(); // [2] + output.copy_from_slice(derived.as_ref()); + } + + fn for_key_exchange( + &self, + output: &mut [u8; 48], + kx: Box, + peer_pub_key: &[u8], + label: &[u8], + seed: &[u8], + ) -> Result<(), Error> { + self.for_secret( + output, + kx.complete_for_tls_version(peer_pub_key, &TLS12)? + .secret_bytes(), + label, + seed, + ); + Ok(()) + } + + fn fips(&self) -> bool { + super::fips() + } +} diff --git a/http/vendor/rustls/src/crypto/aws_lc_rs/tls13.rs b/http/vendor/rustls/src/crypto/aws_lc_rs/tls13.rs new file mode 100644 index 0000000..dbc9d91 --- /dev/null +++ b/http/vendor/rustls/src/crypto/aws_lc_rs/tls13.rs @@ -0,0 +1,425 @@ +use alloc::boxed::Box; + +use aws_lc_rs::hkdf::KeyType; +use aws_lc_rs::{aead, hkdf, hmac}; + +use crate::crypto; +use crate::crypto::cipher::{ + AeadKey, InboundOpaqueMessage, Iv, MessageDecrypter, MessageEncrypter, Nonce, + Tls13AeadAlgorithm, UnsupportedOperationError, make_tls13_aad, +}; +use crate::crypto::tls13::{Hkdf, HkdfExpander, OkmBlock, OutputLengthError}; +use crate::enums::{CipherSuite, ContentType, ProtocolVersion}; +use crate::error::Error; +use crate::msgs::message::{ + InboundPlainMessage, OutboundOpaqueMessage, OutboundPlainMessage, PrefixedPayload, +}; +use crate::suites::{CipherSuiteCommon, ConnectionTrafficSecrets, SupportedCipherSuite}; +use crate::tls13::Tls13CipherSuite; + +/// The TLS1.3 ciphersuite TLS_CHACHA20_POLY1305_SHA256 +pub static TLS13_CHACHA20_POLY1305_SHA256: SupportedCipherSuite = + SupportedCipherSuite::Tls13(TLS13_CHACHA20_POLY1305_SHA256_INTERNAL); + +pub(crate) static TLS13_CHACHA20_POLY1305_SHA256_INTERNAL: &Tls13CipherSuite = &Tls13CipherSuite { + common: CipherSuiteCommon { + suite: CipherSuite::TLS13_CHACHA20_POLY1305_SHA256, + hash_provider: &super::hash::SHA256, + // ref: + confidentiality_limit: u64::MAX, + }, + hkdf_provider: &AwsLcHkdf(hkdf::HKDF_SHA256, hmac::HMAC_SHA256), + aead_alg: &Chacha20Poly1305Aead(AeadAlgorithm(&aead::CHACHA20_POLY1305)), + quic: Some(&super::quic::KeyBuilder { + packet_alg: &aead::CHACHA20_POLY1305, + header_alg: &aead::quic::CHACHA20, + // ref: + confidentiality_limit: u64::MAX, + // ref: + integrity_limit: 1 << 36, + }), +}; + +/// The TLS1.3 ciphersuite TLS_AES_256_GCM_SHA384 +pub static TLS13_AES_256_GCM_SHA384: SupportedCipherSuite = + SupportedCipherSuite::Tls13(&Tls13CipherSuite { + common: CipherSuiteCommon { + suite: CipherSuite::TLS13_AES_256_GCM_SHA384, + hash_provider: &super::hash::SHA384, + confidentiality_limit: 1 << 24, + }, + hkdf_provider: &AwsLcHkdf(hkdf::HKDF_SHA384, hmac::HMAC_SHA384), + aead_alg: &Aes256GcmAead(AeadAlgorithm(&aead::AES_256_GCM)), + quic: Some(&super::quic::KeyBuilder { + packet_alg: &aead::AES_256_GCM, + header_alg: &aead::quic::AES_256, + // ref: + confidentiality_limit: 1 << 23, + // ref: + integrity_limit: 1 << 52, + }), + }); + +/// The TLS1.3 ciphersuite TLS_AES_128_GCM_SHA256 +pub static TLS13_AES_128_GCM_SHA256: SupportedCipherSuite = + SupportedCipherSuite::Tls13(TLS13_AES_128_GCM_SHA256_INTERNAL); + +pub(crate) static TLS13_AES_128_GCM_SHA256_INTERNAL: &Tls13CipherSuite = &Tls13CipherSuite { + common: CipherSuiteCommon { + suite: CipherSuite::TLS13_AES_128_GCM_SHA256, + hash_provider: &super::hash::SHA256, + confidentiality_limit: 1 << 24, + }, + hkdf_provider: &AwsLcHkdf(hkdf::HKDF_SHA256, hmac::HMAC_SHA256), + aead_alg: &Aes128GcmAead(AeadAlgorithm(&aead::AES_128_GCM)), + quic: Some(&super::quic::KeyBuilder { + packet_alg: &aead::AES_128_GCM, + header_alg: &aead::quic::AES_128, + // ref: + confidentiality_limit: 1 << 23, + // ref: + integrity_limit: 1 << 52, + }), +}; + +struct Chacha20Poly1305Aead(AeadAlgorithm); + +impl Tls13AeadAlgorithm for Chacha20Poly1305Aead { + fn encrypter(&self, key: AeadKey, iv: Iv) -> Box { + // safety: the caller arranges that `key` is `key_len()` in bytes, so this unwrap is safe. + Box::new(AeadMessageEncrypter { + enc_key: aead::LessSafeKey::new(aead::UnboundKey::new(self.0.0, key.as_ref()).unwrap()), + iv, + }) + } + + fn decrypter(&self, key: AeadKey, iv: Iv) -> Box { + // safety: the caller arranges that `key` is `key_len()` in bytes, so this unwrap is safe. + Box::new(AeadMessageDecrypter { + dec_key: aead::LessSafeKey::new(aead::UnboundKey::new(self.0.0, key.as_ref()).unwrap()), + iv, + }) + } + + fn key_len(&self) -> usize { + self.0.key_len() + } + + fn extract_keys( + &self, + key: AeadKey, + iv: Iv, + ) -> Result { + Ok(ConnectionTrafficSecrets::Chacha20Poly1305 { key, iv }) + } + + fn fips(&self) -> bool { + false // not FIPS approved + } +} + +struct Aes256GcmAead(AeadAlgorithm); + +impl Tls13AeadAlgorithm for Aes256GcmAead { + fn encrypter(&self, key: AeadKey, iv: Iv) -> Box { + self.0.encrypter(key, iv) + } + + fn decrypter(&self, key: AeadKey, iv: Iv) -> Box { + self.0.decrypter(key, iv) + } + + fn key_len(&self) -> usize { + self.0.key_len() + } + + fn extract_keys( + &self, + key: AeadKey, + iv: Iv, + ) -> Result { + Ok(ConnectionTrafficSecrets::Aes256Gcm { key, iv }) + } + + fn fips(&self) -> bool { + super::fips() + } +} + +struct Aes128GcmAead(AeadAlgorithm); + +impl Tls13AeadAlgorithm for Aes128GcmAead { + fn encrypter(&self, key: AeadKey, iv: Iv) -> Box { + self.0.encrypter(key, iv) + } + + fn decrypter(&self, key: AeadKey, iv: Iv) -> Box { + self.0.decrypter(key, iv) + } + + fn key_len(&self) -> usize { + self.0.key_len() + } + + fn extract_keys( + &self, + key: AeadKey, + iv: Iv, + ) -> Result { + Ok(ConnectionTrafficSecrets::Aes128Gcm { key, iv }) + } + + fn fips(&self) -> bool { + super::fips() + } +} + +// common encrypter/decrypter/key_len items for above Tls13AeadAlgorithm impls +struct AeadAlgorithm(&'static aead::Algorithm); + +impl AeadAlgorithm { + // using aead::TlsRecordSealingKey + fn encrypter(&self, key: AeadKey, iv: Iv) -> Box { + // safety: + // - the caller arranges that `key` is `key_len()` in bytes, so this unwrap is safe. + // - this function should only be used for `Algorithm::AES_128_GCM` or `Algorithm::AES_256_GCM` + Box::new(GcmMessageEncrypter { + enc_key: aead::TlsRecordSealingKey::new( + self.0, + aead::TlsProtocolId::TLS13, + key.as_ref(), + ) + .unwrap(), + iv, + }) + } + + // using aead::TlsRecordOpeningKey + fn decrypter(&self, key: AeadKey, iv: Iv) -> Box { + // safety: + // - the caller arranges that `key` is `key_len()` in bytes, so this unwrap is safe. + // - this function should only be used for `Algorithm::AES_128_GCM` or `Algorithm::AES_256_GCM` + Box::new(GcmMessageDecrypter { + dec_key: aead::TlsRecordOpeningKey::new( + self.0, + aead::TlsProtocolId::TLS13, + key.as_ref(), + ) + .unwrap(), + iv, + }) + } + + fn key_len(&self) -> usize { + self.0.key_len() + } +} + +struct AeadMessageEncrypter { + enc_key: aead::LessSafeKey, + iv: Iv, +} + +struct AeadMessageDecrypter { + dec_key: aead::LessSafeKey, + iv: Iv, +} + +impl MessageEncrypter for AeadMessageEncrypter { + fn encrypt( + &mut self, + msg: OutboundPlainMessage<'_>, + seq: u64, + ) -> Result { + let total_len = self.encrypted_payload_len(msg.payload.len()); + let mut payload = PrefixedPayload::with_capacity(total_len); + + let nonce = aead::Nonce::assume_unique_for_key(Nonce::new(&self.iv, seq).0); + let aad = aead::Aad::from(make_tls13_aad(total_len)); + payload.extend_from_chunks(&msg.payload); + payload.extend_from_slice(&msg.typ.to_array()); + + self.enc_key + .seal_in_place_append_tag(nonce, aad, &mut payload) + .map_err(|_| Error::EncryptError)?; + + Ok(OutboundOpaqueMessage::new( + ContentType::ApplicationData, + // Note: all TLS 1.3 application data records use TLSv1_2 (0x0303) as the legacy record + // protocol version, see https://www.rfc-editor.org/rfc/rfc8446#section-5.1 + ProtocolVersion::TLSv1_2, + payload, + )) + } + + fn encrypted_payload_len(&self, payload_len: usize) -> usize { + payload_len + 1 + self.enc_key.algorithm().tag_len() + } +} + +impl MessageDecrypter for AeadMessageDecrypter { + fn decrypt<'a>( + &mut self, + mut msg: InboundOpaqueMessage<'a>, + seq: u64, + ) -> Result, Error> { + let payload = &mut msg.payload; + if payload.len() < self.dec_key.algorithm().tag_len() { + return Err(Error::DecryptError); + } + + let nonce = aead::Nonce::assume_unique_for_key(Nonce::new(&self.iv, seq).0); + let aad = aead::Aad::from(make_tls13_aad(payload.len())); + let plain_len = self + .dec_key + .open_in_place(nonce, aad, payload) + .map_err(|_| Error::DecryptError)? + .len(); + + payload.truncate(plain_len); + msg.into_tls13_unpadded_message() + } +} + +struct GcmMessageEncrypter { + enc_key: aead::TlsRecordSealingKey, + iv: Iv, +} + +impl MessageEncrypter for GcmMessageEncrypter { + fn encrypt( + &mut self, + msg: OutboundPlainMessage<'_>, + seq: u64, + ) -> Result { + let total_len = self.encrypted_payload_len(msg.payload.len()); + let mut payload = PrefixedPayload::with_capacity(total_len); + + let nonce = aead::Nonce::assume_unique_for_key(Nonce::new(&self.iv, seq).0); + let aad = aead::Aad::from(make_tls13_aad(total_len)); + payload.extend_from_chunks(&msg.payload); + payload.extend_from_slice(&msg.typ.to_array()); + + self.enc_key + .seal_in_place_append_tag(nonce, aad, &mut payload) + .map_err(|_| Error::EncryptError)?; + + Ok(OutboundOpaqueMessage::new( + ContentType::ApplicationData, + ProtocolVersion::TLSv1_2, + payload, + )) + } + + fn encrypted_payload_len(&self, payload_len: usize) -> usize { + payload_len + 1 + self.enc_key.algorithm().tag_len() + } +} + +struct GcmMessageDecrypter { + dec_key: aead::TlsRecordOpeningKey, + iv: Iv, +} + +impl MessageDecrypter for GcmMessageDecrypter { + fn decrypt<'a>( + &mut self, + mut msg: InboundOpaqueMessage<'a>, + seq: u64, + ) -> Result, Error> { + let payload = &mut msg.payload; + if payload.len() < self.dec_key.algorithm().tag_len() { + return Err(Error::DecryptError); + } + + let nonce = aead::Nonce::assume_unique_for_key(Nonce::new(&self.iv, seq).0); + let aad = aead::Aad::from(make_tls13_aad(payload.len())); + let plain_len = self + .dec_key + .open_in_place(nonce, aad, payload) + .map_err(|_| Error::DecryptError)? + .len(); + + payload.truncate(plain_len); + msg.into_tls13_unpadded_message() + } +} + +struct AwsLcHkdf(hkdf::Algorithm, hmac::Algorithm); + +impl Hkdf for AwsLcHkdf { + fn extract_from_zero_ikm(&self, salt: Option<&[u8]>) -> Box { + let zeroes = [0u8; OkmBlock::MAX_LEN]; + let salt = match salt { + Some(salt) => salt, + None => &zeroes[..self.0.len()], + }; + Box::new(AwsLcHkdfExpander { + alg: self.0, + prk: hkdf::Salt::new(self.0, salt).extract(&zeroes[..self.0.len()]), + }) + } + + fn extract_from_secret(&self, salt: Option<&[u8]>, secret: &[u8]) -> Box { + let zeroes = [0u8; OkmBlock::MAX_LEN]; + let salt = match salt { + Some(salt) => salt, + None => &zeroes[..self.0.len()], + }; + Box::new(AwsLcHkdfExpander { + alg: self.0, + prk: hkdf::Salt::new(self.0, salt).extract(secret), + }) + } + + fn expander_for_okm(&self, okm: &OkmBlock) -> Box { + Box::new(AwsLcHkdfExpander { + alg: self.0, + prk: hkdf::Prk::new_less_safe(self.0, okm.as_ref()), + }) + } + + fn hmac_sign(&self, key: &OkmBlock, message: &[u8]) -> crypto::hmac::Tag { + crypto::hmac::Tag::new(hmac::sign(&hmac::Key::new(self.1, key.as_ref()), message).as_ref()) + } + + fn fips(&self) -> bool { + super::fips() + } +} + +struct AwsLcHkdfExpander { + alg: hkdf::Algorithm, + prk: hkdf::Prk, +} + +impl HkdfExpander for AwsLcHkdfExpander { + fn expand_slice(&self, info: &[&[u8]], output: &mut [u8]) -> Result<(), OutputLengthError> { + self.prk + .expand(info, Len(output.len())) + .and_then(|okm| okm.fill(output)) + .map_err(|_| OutputLengthError) + } + + fn expand_block(&self, info: &[&[u8]]) -> OkmBlock { + let mut buf = [0u8; OkmBlock::MAX_LEN]; + let output = &mut buf[..self.hash_len()]; + self.prk + .expand(info, Len(output.len())) + .and_then(|okm| okm.fill(output)) + .unwrap(); + OkmBlock::new(output) + } + + fn hash_len(&self) -> usize { + self.alg.len() + } +} + +struct Len(usize); + +impl KeyType for Len { + fn len(&self) -> usize { + self.0 + } +} diff --git a/http/vendor/rustls/src/crypto/cipher.rs b/http/vendor/rustls/src/crypto/cipher.rs new file mode 100644 index 0000000..b5a6046 --- /dev/null +++ b/http/vendor/rustls/src/crypto/cipher.rs @@ -0,0 +1,364 @@ +use alloc::boxed::Box; +use alloc::string::ToString; +use core::fmt; + +use zeroize::Zeroize; + +use crate::enums::{ContentType, ProtocolVersion}; +use crate::error::Error; +use crate::msgs::codec; +pub use crate::msgs::message::{ + BorrowedPayload, InboundOpaqueMessage, InboundPlainMessage, OutboundChunks, + OutboundOpaqueMessage, OutboundPlainMessage, PlainMessage, PrefixedPayload, +}; +use crate::suites::ConnectionTrafficSecrets; + +/// Factory trait for building `MessageEncrypter` and `MessageDecrypter` for a TLS1.3 cipher suite. +pub trait Tls13AeadAlgorithm: Send + Sync { + /// Build a `MessageEncrypter` for the given key/iv. + fn encrypter(&self, key: AeadKey, iv: Iv) -> Box; + + /// Build a `MessageDecrypter` for the given key/iv. + fn decrypter(&self, key: AeadKey, iv: Iv) -> Box; + + /// The length of key in bytes required by `encrypter()` and `decrypter()`. + fn key_len(&self) -> usize; + + /// Convert the key material from `key`/`iv`, into a `ConnectionTrafficSecrets` item. + /// + /// May return [`UnsupportedOperationError`] if the AEAD algorithm is not a supported + /// variant of `ConnectionTrafficSecrets`. + fn extract_keys( + &self, + key: AeadKey, + iv: Iv, + ) -> Result; + + /// Return `true` if this is backed by a FIPS-approved implementation. + fn fips(&self) -> bool { + false + } +} + +/// Factory trait for building `MessageEncrypter` and `MessageDecrypter` for a TLS1.2 cipher suite. +pub trait Tls12AeadAlgorithm: Send + Sync + 'static { + /// Build a `MessageEncrypter` for the given key/iv and extra key block (which can be used for + /// improving explicit nonce size security, if needed). + /// + /// The length of `key` is set by [`KeyBlockShape::enc_key_len`]. + /// + /// The length of `iv` is set by [`KeyBlockShape::fixed_iv_len`]. + /// + /// The length of `extra` is set by [`KeyBlockShape::explicit_nonce_len`]. + fn encrypter(&self, key: AeadKey, iv: &[u8], extra: &[u8]) -> Box; + + /// Build a `MessageDecrypter` for the given key/iv. + /// + /// The length of `key` is set by [`KeyBlockShape::enc_key_len`]. + /// + /// The length of `iv` is set by [`KeyBlockShape::fixed_iv_len`]. + fn decrypter(&self, key: AeadKey, iv: &[u8]) -> Box; + + /// Return a `KeyBlockShape` that defines how large the `key_block` is and how it + /// is split up prior to calling `encrypter()`, `decrypter()` and/or `extract_keys()`. + fn key_block_shape(&self) -> KeyBlockShape; + + /// Convert the key material from `key`/`iv`, into a `ConnectionTrafficSecrets` item. + /// + /// The length of `key` is set by [`KeyBlockShape::enc_key_len`]. + /// + /// The length of `iv` is set by [`KeyBlockShape::fixed_iv_len`]. + /// + /// The length of `extra` is set by [`KeyBlockShape::explicit_nonce_len`]. + /// + /// May return [`UnsupportedOperationError`] if the AEAD algorithm is not a supported + /// variant of `ConnectionTrafficSecrets`. + fn extract_keys( + &self, + key: AeadKey, + iv: &[u8], + explicit: &[u8], + ) -> Result; + + /// Return `true` if this is backed by a FIPS-approved implementation. + fn fips(&self) -> bool { + false + } +} + +/// An error indicating that the AEAD algorithm does not support the requested operation. +#[derive(Debug, Eq, PartialEq, Clone, Copy)] +pub struct UnsupportedOperationError; + +impl From for Error { + fn from(value: UnsupportedOperationError) -> Self { + Self::General(value.to_string()) + } +} + +impl fmt::Display for UnsupportedOperationError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "operation not supported") + } +} + +#[cfg(feature = "std")] +impl std::error::Error for UnsupportedOperationError {} + +/// How a TLS1.2 `key_block` is partitioned. +/// +/// Note: ciphersuites with non-zero `mac_key_length` are not currently supported. +pub struct KeyBlockShape { + /// How long keys are. + /// + /// `enc_key_length` terminology is from the standard ([RFC5246 A.6]). + /// + /// [RFC5246 A.6]: + pub enc_key_len: usize, + + /// How long the fixed part of the 'IV' is. + /// + /// `fixed_iv_length` terminology is from the standard ([RFC5246 A.6]). + /// + /// This isn't usually an IV, but we continue the + /// terminology misuse to match the standard. + /// + /// [RFC5246 A.6]: + pub fixed_iv_len: usize, + + /// This is a non-standard extension which extends the + /// key block to provide an initial explicit nonce offset, + /// in a deterministic and safe way. GCM needs this, + /// chacha20poly1305 works this way by design. + pub explicit_nonce_len: usize, +} + +/// Objects with this trait can decrypt TLS messages. +pub trait MessageDecrypter: Send + Sync { + /// Decrypt the given TLS message `msg`, using the sequence number + /// `seq` which can be used to derive a unique [`Nonce`]. + fn decrypt<'a>( + &mut self, + msg: InboundOpaqueMessage<'a>, + seq: u64, + ) -> Result, Error>; +} + +/// Objects with this trait can encrypt TLS messages. +pub trait MessageEncrypter: Send + Sync { + /// Encrypt the given TLS message `msg`, using the sequence number + /// `seq` which can be used to derive a unique [`Nonce`]. + fn encrypt( + &mut self, + msg: OutboundPlainMessage<'_>, + seq: u64, + ) -> Result; + + /// Return the length of the ciphertext that results from encrypting plaintext of + /// length `payload_len` + fn encrypted_payload_len(&self, payload_len: usize) -> usize; +} + +impl dyn MessageEncrypter { + pub(crate) fn invalid() -> Box { + Box::new(InvalidMessageEncrypter {}) + } +} + +impl dyn MessageDecrypter { + pub(crate) fn invalid() -> Box { + Box::new(InvalidMessageDecrypter {}) + } +} + +/// A write or read IV. +#[derive(Default)] +pub struct Iv([u8; NONCE_LEN]); + +impl Iv { + /// Create a new `Iv` from a byte array, of precisely `NONCE_LEN` bytes. + #[cfg(feature = "tls12")] + pub fn new(value: [u8; NONCE_LEN]) -> Self { + Self(value) + } + + /// Create a new `Iv` from a byte slice, of precisely `NONCE_LEN` bytes. + #[cfg(feature = "tls12")] + pub fn copy(value: &[u8]) -> Self { + debug_assert_eq!(value.len(), NONCE_LEN); + let mut iv = Self::new(Default::default()); + iv.0.copy_from_slice(value); + iv + } +} + +impl From<[u8; NONCE_LEN]> for Iv { + fn from(bytes: [u8; NONCE_LEN]) -> Self { + Self(bytes) + } +} + +impl AsRef<[u8]> for Iv { + fn as_ref(&self) -> &[u8] { + self.0.as_ref() + } +} + +/// A nonce. This is unique for all messages on a connection. +pub struct Nonce(pub [u8; NONCE_LEN]); + +impl Nonce { + /// Combine an `Iv` and sequence number to produce a unique nonce. + /// + /// This is `iv ^ seq` where `seq` is encoded as a 96-bit big-endian integer. + #[inline] + pub fn new(iv: &Iv, seq: u64) -> Self { + let mut seq_bytes = [0u8; NONCE_LEN]; + codec::put_u64(seq, &mut seq_bytes[4..]); + Self::new_from_seq(iv, seq_bytes) + } + + /// Creates a unique nonce based on the `iv`, the packet number `pn` and multipath `path_id`. + /// + /// The nonce is computed as the XOR between the `iv` and the 96-bit big-ending integer formed + /// by concatenating `path_id` and `pn`. + pub fn for_path(path_id: u32, iv: &Iv, pn: u64) -> Self { + let mut seq_bytes = [0u8; NONCE_LEN]; + seq_bytes[0..4].copy_from_slice(&path_id.to_be_bytes()); + codec::put_u64(pn, &mut seq_bytes[4..]); + Self::new_from_seq(iv, seq_bytes) + } + + /// Creates a unique nonce based on the `iv` and sequence number `seq`. + #[inline] + fn new_from_seq(iv: &Iv, mut seq: [u8; NONCE_LEN]) -> Self { + seq.iter_mut() + .zip(iv.0.iter()) + .for_each(|(s, iv)| { + *s ^= *iv; + }); + + Self(seq) + } +} + +/// Size of TLS nonces (incorrectly termed "IV" in standard) for all supported ciphersuites +/// (AES-GCM, Chacha20Poly1305) +pub const NONCE_LEN: usize = 12; + +/// Returns a TLS1.3 `additional_data` encoding. +/// +/// See RFC8446 s5.2 for the `additional_data` definition. +#[inline] +pub fn make_tls13_aad(payload_len: usize) -> [u8; 5] { + let version = ProtocolVersion::TLSv1_2.to_array(); + [ + ContentType::ApplicationData.into(), + // Note: this is `legacy_record_version`, i.e. TLS1.2 even for TLS1.3. + version[0], + version[1], + (payload_len >> 8) as u8, + (payload_len & 0xff) as u8, + ] +} + +/// Returns a TLS1.2 `additional_data` encoding. +/// +/// See RFC5246 s6.2.3.3 for the `additional_data` definition. +#[inline] +pub fn make_tls12_aad( + seq: u64, + typ: ContentType, + vers: ProtocolVersion, + len: usize, +) -> [u8; TLS12_AAD_SIZE] { + let mut out = [0; TLS12_AAD_SIZE]; + codec::put_u64(seq, &mut out[0..]); + out[8] = typ.into(); + codec::put_u16(vers.into(), &mut out[9..]); + codec::put_u16(len as u16, &mut out[11..]); + out +} + +const TLS12_AAD_SIZE: usize = 8 + 1 + 2 + 2; + +/// A key for an AEAD algorithm. +/// +/// This is a value type for a byte string up to `AeadKey::MAX_LEN` bytes in length. +pub struct AeadKey { + buf: [u8; Self::MAX_LEN], + used: usize, +} + +impl AeadKey { + #[cfg(feature = "tls12")] + pub(crate) fn new(buf: &[u8]) -> Self { + debug_assert!(buf.len() <= Self::MAX_LEN); + let mut key = Self::from([0u8; Self::MAX_LEN]); + key.buf[..buf.len()].copy_from_slice(buf); + key.used = buf.len(); + key + } + + pub(crate) fn with_length(self, len: usize) -> Self { + assert!(len <= self.used); + Self { + buf: self.buf, + used: len, + } + } + + /// Largest possible AEAD key in the ciphersuites we support. + pub(crate) const MAX_LEN: usize = 32; +} + +impl Drop for AeadKey { + fn drop(&mut self) { + self.buf.zeroize(); + } +} + +impl AsRef<[u8]> for AeadKey { + fn as_ref(&self) -> &[u8] { + &self.buf[..self.used] + } +} + +impl From<[u8; Self::MAX_LEN]> for AeadKey { + fn from(bytes: [u8; Self::MAX_LEN]) -> Self { + Self { + buf: bytes, + used: Self::MAX_LEN, + } + } +} + +/// A `MessageEncrypter` which doesn't work. +struct InvalidMessageEncrypter {} + +impl MessageEncrypter for InvalidMessageEncrypter { + fn encrypt( + &mut self, + _m: OutboundPlainMessage<'_>, + _seq: u64, + ) -> Result { + Err(Error::EncryptError) + } + + fn encrypted_payload_len(&self, payload_len: usize) -> usize { + payload_len + } +} + +/// A `MessageDecrypter` which doesn't work. +struct InvalidMessageDecrypter {} + +impl MessageDecrypter for InvalidMessageDecrypter { + fn decrypt<'a>( + &mut self, + _m: InboundOpaqueMessage<'a>, + _seq: u64, + ) -> Result, Error> { + Err(Error::DecryptError) + } +} diff --git a/http/vendor/rustls/src/crypto/hash.rs b/http/vendor/rustls/src/crypto/hash.rs new file mode 100644 index 0000000..214dad4 --- /dev/null +++ b/http/vendor/rustls/src/crypto/hash.rs @@ -0,0 +1,81 @@ +use alloc::boxed::Box; + +pub use crate::msgs::enums::HashAlgorithm; + +/// Describes a single cryptographic hash function. +/// +/// This interface can do both one-shot and incremental hashing, using +/// [`Hash::hash()`] and [`Hash::start()`] respectively. +pub trait Hash: Send + Sync { + /// Start an incremental hash computation. + fn start(&self) -> Box; + + /// Return the output of this hash function with input `data`. + fn hash(&self, data: &[u8]) -> Output; + + /// The length in bytes of this hash function's output. + fn output_len(&self) -> usize; + + /// Which hash function this is, eg, `HashAlgorithm::SHA256`. + fn algorithm(&self) -> HashAlgorithm; + + /// Return `true` if this is backed by a FIPS-approved implementation. + fn fips(&self) -> bool { + false + } +} + +/// A hash output, stored as a value. +pub struct Output { + buf: [u8; Self::MAX_LEN], + used: usize, +} + +impl Output { + /// Build a `hash::Output` from a slice of no more than `Output::MAX_LEN` bytes. + pub fn new(bytes: &[u8]) -> Self { + let mut output = Self { + buf: [0u8; Self::MAX_LEN], + used: bytes.len(), + }; + debug_assert!(bytes.len() <= Self::MAX_LEN); + output.buf[..bytes.len()].copy_from_slice(bytes); + output + } + + /// Maximum supported hash output size: supports up to SHA512. + pub const MAX_LEN: usize = 64; +} + +impl AsRef<[u8]> for Output { + fn as_ref(&self) -> &[u8] { + &self.buf[..self.used] + } +} + +/// How to incrementally compute a hash. +pub trait Context: Send + Sync { + /// Finish the computation, returning the resulting output. + /// + /// The computation remains valid, and more data can be added later with + /// [`Context::update()`]. + /// + /// Compare with [`Context::finish()`] which consumes the computation + /// and prevents any further data being added. This can be more efficient + /// because it avoids a hash context copy to apply Merkle-Damgård padding + /// (if required). + fn fork_finish(&self) -> Output; + + /// Fork the computation, producing another context that has the + /// same prefix as this one. + fn fork(&self) -> Box; + + /// Terminate and finish the computation, returning the resulting output. + /// + /// Further data cannot be added after this, because the context is consumed. + /// Compare [`Context::fork_finish()`]. + fn finish(self: Box) -> Output; + + /// Add `data` to computation. + fn update(&mut self, data: &[u8]); +} diff --git a/http/vendor/rustls/src/crypto/hmac.rs b/http/vendor/rustls/src/crypto/hmac.rs new file mode 100644 index 0000000..6960b7e --- /dev/null +++ b/http/vendor/rustls/src/crypto/hmac.rs @@ -0,0 +1,73 @@ +use alloc::boxed::Box; + +use zeroize::Zeroize; + +/// A concrete HMAC implementation, for a single cryptographic hash function. +/// +/// You should have one object that implements this trait for HMAC-SHA256, another +/// for HMAC-SHA384, etc. +pub trait Hmac: Send + Sync { + /// Prepare to use `key` as a HMAC key. + fn with_key(&self, key: &[u8]) -> Box; + + /// Give the length of the underlying hash function. In RFC2104 terminology this is `L`. + fn hash_output_len(&self) -> usize; + + /// Return `true` if this is backed by a FIPS-approved implementation. + fn fips(&self) -> bool { + false + } +} + +/// A HMAC tag, stored as a value. +#[derive(Clone)] +pub struct Tag { + buf: [u8; Self::MAX_LEN], + used: usize, +} + +impl Tag { + /// Build a tag by copying a byte slice. + /// + /// The slice can be up to [`Tag::MAX_LEN`] bytes in length. + pub fn new(bytes: &[u8]) -> Self { + let mut tag = Self { + buf: [0u8; Self::MAX_LEN], + used: bytes.len(), + }; + tag.buf[..bytes.len()].copy_from_slice(bytes); + tag + } + + /// Maximum supported HMAC tag size: supports up to SHA512. + pub const MAX_LEN: usize = 64; +} + +impl Drop for Tag { + fn drop(&mut self) { + self.buf.zeroize(); + } +} + +impl AsRef<[u8]> for Tag { + fn as_ref(&self) -> &[u8] { + &self.buf[..self.used] + } +} + +/// A HMAC key that is ready for use. +/// +/// The algorithm used is implicit in the `Hmac` object that produced the key. +pub trait Key: Send + Sync { + /// Calculates a tag over `data` -- a slice of byte slices. + fn sign(&self, data: &[&[u8]]) -> Tag { + self.sign_concat(&[], data, &[]) + } + + /// Calculates a tag over the concatenation of `first`, the items in `middle`, and `last`. + fn sign_concat(&self, first: &[u8], middle: &[&[u8]], last: &[u8]) -> Tag; + + /// Returns the length of the tag returned by a computation using + /// this key. + fn tag_len(&self) -> usize; +} diff --git a/http/vendor/rustls/src/crypto/hpke.rs b/http/vendor/rustls/src/crypto/hpke.rs new file mode 100644 index 0000000..6207415 --- /dev/null +++ b/http/vendor/rustls/src/crypto/hpke.rs @@ -0,0 +1,145 @@ +use alloc::boxed::Box; +use alloc::vec::Vec; +use core::fmt::Debug; + +use zeroize::Zeroize; + +use crate::Error; +use crate::msgs::enums::HpkeKem; +use crate::msgs::handshake::HpkeSymmetricCipherSuite; + +/// An HPKE suite, specifying a key encapsulation mechanism and a symmetric cipher suite. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub struct HpkeSuite { + /// The choice of HPKE key encapsulation mechanism. + pub kem: HpkeKem, + + /// The choice of HPKE symmetric cipher suite. + /// + /// This combines a choice of authenticated encryption with additional data (AEAD) algorithm + /// and a key derivation function (KDF). + pub sym: HpkeSymmetricCipherSuite, +} + +/// An HPKE instance that can be used for base-mode single-shot encryption and decryption. +pub trait Hpke: Debug + Send + Sync { + /// Seal the provided `plaintext` to the recipient public key `pub_key` with application supplied + /// `info`, and additional data `aad`. + /// + /// Returns ciphertext that can be used with [Self::open] by the recipient to recover plaintext + /// using the same `info` and `aad` and the private key corresponding to `pub_key`. RFC 9180 + /// refers to `pub_key` as `pkR`. + fn seal( + &self, + info: &[u8], + aad: &[u8], + plaintext: &[u8], + pub_key: &HpkePublicKey, + ) -> Result<(EncapsulatedSecret, Vec), Error>; + + /// Set up a sealer context for the receiver public key `pub_key` with application supplied `info`. + /// + /// Returns both an encapsulated ciphertext and a sealer context that can be used to seal + /// messages to the recipient. RFC 9180 refers to `pub_key` as `pkR`. + fn setup_sealer( + &self, + info: &[u8], + pub_key: &HpkePublicKey, + ) -> Result<(EncapsulatedSecret, Box), Error>; + + /// Open the provided `ciphertext` using the encapsulated secret `enc`, with application + /// supplied `info`, and additional data `aad`. + /// + /// Returns plaintext if the `info` and `aad` match those used with [Self::seal], and + /// decryption with `secret_key` succeeds. RFC 9180 refers to `secret_key` as `skR`. + fn open( + &self, + enc: &EncapsulatedSecret, + info: &[u8], + aad: &[u8], + ciphertext: &[u8], + secret_key: &HpkePrivateKey, + ) -> Result, Error>; + + /// Set up an opener context for the secret key `secret_key` with application supplied `info`. + /// + /// Returns an opener context that can be used to open sealed messages encrypted to the + /// public key corresponding to `secret_key`. RFC 9180 refers to `secret_key` as `skR`. + fn setup_opener( + &self, + enc: &EncapsulatedSecret, + info: &[u8], + secret_key: &HpkePrivateKey, + ) -> Result, Error>; + + /// Generate a new public key and private key pair compatible with this HPKE instance. + /// + /// Key pairs should be encoded as raw big endian fixed length integers sized based + /// on the suite's DH KEM algorithm. + fn generate_key_pair(&self) -> Result<(HpkePublicKey, HpkePrivateKey), Error>; + + /// Return whether the HPKE instance is FIPS compatible. + fn fips(&self) -> bool { + false + } + + /// Return the [HpkeSuite] that this HPKE instance supports. + fn suite(&self) -> HpkeSuite; +} + +/// An HPKE sealer context. +/// +/// This is a stateful object that can be used to seal messages for receipt by +/// a receiver. +pub trait HpkeSealer: Debug + Send + Sync + 'static { + /// Seal the provided `plaintext` with additional data `aad`, returning + /// ciphertext. + fn seal(&mut self, aad: &[u8], plaintext: &[u8]) -> Result, Error>; +} + +/// An HPKE opener context. +/// +/// This is a stateful object that can be used to open sealed messages sealed +/// by a sender. +pub trait HpkeOpener: Debug + Send + Sync + 'static { + /// Open the provided `ciphertext` with additional data `aad`, returning plaintext. + fn open(&mut self, aad: &[u8], ciphertext: &[u8]) -> Result, Error>; +} + +/// An HPKE public key. +#[derive(Clone, Debug)] +pub struct HpkePublicKey(pub Vec); + +/// An HPKE private key. +pub struct HpkePrivateKey(Vec); + +impl HpkePrivateKey { + /// Return the private key bytes. + pub fn secret_bytes(&self) -> &[u8] { + self.0.as_slice() + } +} + +impl From> for HpkePrivateKey { + fn from(bytes: Vec) -> Self { + Self(bytes) + } +} + +impl Drop for HpkePrivateKey { + fn drop(&mut self) { + self.0.zeroize(); + } +} + +/// An HPKE key pair, made of a matching public and private key. +pub struct HpkeKeyPair { + /// A HPKE public key. + pub public_key: HpkePublicKey, + /// A HPKE private key. + pub private_key: HpkePrivateKey, +} + +/// An encapsulated secret returned from setting up a sender or receiver context. +#[derive(Debug)] +pub struct EncapsulatedSecret(pub Vec); diff --git a/http/vendor/rustls/src/crypto/mod.rs b/http/vendor/rustls/src/crypto/mod.rs new file mode 100644 index 0000000..1060d13 --- /dev/null +++ b/http/vendor/rustls/src/crypto/mod.rs @@ -0,0 +1,760 @@ +use alloc::boxed::Box; +use alloc::vec::Vec; +use core::fmt::Debug; + +use pki_types::PrivateKeyDer; +use zeroize::Zeroize; + +#[cfg(all(doc, feature = "tls12"))] +use crate::Tls12CipherSuite; +use crate::msgs::ffdhe_groups::FfdheGroup; +use crate::sign::SigningKey; +use crate::sync::Arc; +pub use crate::webpki::{ + WebPkiSupportedAlgorithms, verify_tls12_signature, verify_tls13_signature, + verify_tls13_signature_with_raw_key, +}; +#[cfg(doc)] +use crate::{ + ClientConfig, ConfigBuilder, ServerConfig, SupportedCipherSuite, Tls13CipherSuite, client, + crypto, server, sign, +}; +use crate::{Error, NamedGroup, ProtocolVersion, SupportedProtocolVersion, suites}; + +/// *ring* based CryptoProvider. +#[cfg(feature = "ring")] +pub mod ring; + +/// aws-lc-rs-based CryptoProvider. +#[cfg(feature = "aws_lc_rs")] +pub mod aws_lc_rs; + +/// TLS message encryption/decryption interfaces. +pub mod cipher; + +/// Hashing interfaces. +pub mod hash; + +/// HMAC interfaces. +pub mod hmac; + +#[cfg(feature = "tls12")] +/// Cryptography specific to TLS1.2. +pub mod tls12; + +/// Cryptography specific to TLS1.3. +pub mod tls13; + +/// Hybrid public key encryption (RFC 9180). +pub mod hpke; + +// Message signing interfaces. Re-exported under rustls::sign. Kept crate-internal here to +// avoid having two import paths to the same types. +pub(crate) mod signer; + +pub use crate::msgs::handshake::KeyExchangeAlgorithm; +pub use crate::rand::GetRandomFailed; +pub use crate::suites::CipherSuiteCommon; + +/// Controls core cryptography used by rustls. +/// +/// This crate comes with two built-in options, provided as +/// `CryptoProvider` structures: +/// +/// - [`crypto::aws_lc_rs::default_provider`]: (behind the `aws_lc_rs` crate feature, +/// which is enabled by default). This provider uses the [aws-lc-rs](https://github.com/aws/aws-lc-rs) +/// crate. The `fips` crate feature makes this option use FIPS140-3-approved cryptography. +/// - [`crypto::ring::default_provider`]: (behind the `ring` crate feature, which +/// is optional). This provider uses the [*ring*](https://github.com/briansmith/ring) +/// crate. +/// +/// This structure provides defaults. Everything in it can be overridden at +/// runtime by replacing field values as needed. +/// +/// # Using the per-process default `CryptoProvider` +/// +/// There is the concept of an implicit default provider, configured at run-time once in +/// a given process. +/// +/// It is used for functions like [`ClientConfig::builder()`] and [`ServerConfig::builder()`]. +/// +/// The intention is that an application can specify the [`CryptoProvider`] they wish to use +/// once, and have that apply to the variety of places where their application does TLS +/// (which may be wrapped inside other libraries). +/// They should do this by calling [`CryptoProvider::install_default()`] early on. +/// +/// To achieve this goal: +/// +/// - _libraries_ should use [`ClientConfig::builder()`]/[`ServerConfig::builder()`] +/// or otherwise rely on the [`CryptoProvider::get_default()`] provider. +/// - _applications_ should call [`CryptoProvider::install_default()`] early +/// in their `fn main()`. If _applications_ uses a custom provider based on the one built-in, +/// they can activate the `custom-provider` feature to ensure its usage. +/// +/// # Using a specific `CryptoProvider` +/// +/// Supply the provider when constructing your [`ClientConfig`] or [`ServerConfig`]: +/// +/// - [`ClientConfig::builder_with_provider()`] +/// - [`ServerConfig::builder_with_provider()`] +/// +/// When creating and configuring a webpki-backed client or server certificate verifier, a choice of +/// provider is also needed to start the configuration process: +/// +/// - [`client::WebPkiServerVerifier::builder_with_provider()`] +/// - [`server::WebPkiClientVerifier::builder_with_provider()`] +/// +/// If you install a custom provider and want to avoid any accidental use of a built-in provider, the feature +/// `custom-provider` can be activated to ensure your custom provider is used everywhere +/// and not a built-in one. This will disable any implicit use of a built-in provider. +/// +/// # Making a custom `CryptoProvider` +/// +/// Your goal will be to populate an instance of this `CryptoProvider` struct. +/// +/// ## Which elements are required? +/// +/// There is no requirement that the individual elements ([`SupportedCipherSuite`], [`SupportedKxGroup`], +/// [`SigningKey`], etc.) come from the same crate. It is allowed and expected that uninteresting +/// elements would be delegated back to one of the default providers (statically) or a parent +/// provider (dynamically). +/// +/// For example, if we want to make a provider that just overrides key loading in the config builder +/// API (with [`ConfigBuilder::with_single_cert`], etc.), it might look like this: +/// +/// ``` +/// # #[cfg(feature = "aws_lc_rs")] { +/// # use std::sync::Arc; +/// # mod fictious_hsm_api { pub fn load_private_key(key_der: pki_types::PrivateKeyDer<'static>) -> ! { unreachable!(); } } +/// use rustls::crypto::aws_lc_rs; +/// +/// pub fn provider() -> rustls::crypto::CryptoProvider { +/// rustls::crypto::CryptoProvider{ +/// key_provider: &HsmKeyLoader, +/// ..aws_lc_rs::default_provider() +/// } +/// } +/// +/// #[derive(Debug)] +/// struct HsmKeyLoader; +/// +/// impl rustls::crypto::KeyProvider for HsmKeyLoader { +/// fn load_private_key(&self, key_der: pki_types::PrivateKeyDer<'static>) -> Result, rustls::Error> { +/// fictious_hsm_api::load_private_key(key_der) +/// } +/// } +/// # } +/// ``` +/// +/// ## References to the individual elements +/// +/// The elements are documented separately: +/// +/// - **Random** - see [`crypto::SecureRandom::fill()`]. +/// - **Cipher suites** - see [`SupportedCipherSuite`], [`Tls12CipherSuite`], and +/// [`Tls13CipherSuite`]. +/// - **Key exchange groups** - see [`crypto::SupportedKxGroup`]. +/// - **Signature verification algorithms** - see [`crypto::WebPkiSupportedAlgorithms`]. +/// - **Authentication key loading** - see [`crypto::KeyProvider::load_private_key()`] and +/// [`sign::SigningKey`]. +/// +/// # Example code +/// +/// See custom [`provider-example/`] for a full client and server example that uses +/// cryptography from the [`RustCrypto`] and [`dalek-cryptography`] projects. +/// +/// ```shell +/// $ cargo run --example client | head -3 +/// Current ciphersuite: TLS13_CHACHA20_POLY1305_SHA256 +/// HTTP/1.1 200 OK +/// Content-Type: text/html; charset=utf-8 +/// Content-Length: 19899 +/// ``` +/// +/// [`provider-example/`]: https://github.com/rustls/rustls/tree/main/provider-example/ +/// [`RustCrypto`]: https://github.com/RustCrypto +/// [`dalek-cryptography`]: https://github.com/dalek-cryptography +/// +/// # FIPS-approved cryptography +/// The `fips` crate feature enables use of the `aws-lc-rs` crate in FIPS mode. +/// +/// You can verify the configuration at runtime by checking +/// [`ServerConfig::fips()`]/[`ClientConfig::fips()`] return `true`. +#[derive(Debug, Clone)] +pub struct CryptoProvider { + /// List of supported ciphersuites, in preference order -- the first element + /// is the highest priority. + /// + /// The `SupportedCipherSuite` type carries both configuration and implementation. + /// + /// A valid `CryptoProvider` must ensure that all cipher suites are accompanied by at least + /// one matching key exchange group in [`CryptoProvider::kx_groups`]. + pub cipher_suites: Vec, + + /// List of supported key exchange groups, in preference order -- the + /// first element is the highest priority. + /// + /// The first element in this list is the _default key share algorithm_, + /// and in TLS1.3 a key share for it is sent in the client hello. + /// + /// The `SupportedKxGroup` type carries both configuration and implementation. + pub kx_groups: Vec<&'static dyn SupportedKxGroup>, + + /// List of signature verification algorithms for use with webpki. + /// + /// These are used for both certificate chain verification and handshake signature verification. + /// + /// This is called by [`ConfigBuilder::with_root_certificates()`], + /// [`server::WebPkiClientVerifier::builder_with_provider()`] and + /// [`client::WebPkiServerVerifier::builder_with_provider()`]. + pub signature_verification_algorithms: WebPkiSupportedAlgorithms, + + /// Source of cryptographically secure random numbers. + pub secure_random: &'static dyn SecureRandom, + + /// Provider for loading private [`SigningKey`]s from [`PrivateKeyDer`]. + pub key_provider: &'static dyn KeyProvider, +} + +impl CryptoProvider { + /// Sets this `CryptoProvider` as the default for this process. + /// + /// This can be called successfully at most once in any process execution. + /// + /// Call this early in your process to configure which provider is used for + /// the provider. The configuration should happen before any use of + /// [`ClientConfig::builder()`] or [`ServerConfig::builder()`]. + pub fn install_default(self) -> Result<(), Arc> { + static_default::install_default(self) + } + + /// Returns the default `CryptoProvider` for this process. + /// + /// This will be `None` if no default has been set yet. + pub fn get_default() -> Option<&'static Arc> { + static_default::get_default() + } + + /// An internal function that: + /// + /// - gets the pre-installed default, or + /// - installs one `from_crate_features()`, or else + /// - panics about the need to call [`CryptoProvider::install_default()`] + pub(crate) fn get_default_or_install_from_crate_features() -> &'static Arc { + if let Some(provider) = Self::get_default() { + return provider; + } + + let provider = Self::from_crate_features() + .expect(r###" +Could not automatically determine the process-level CryptoProvider from Rustls crate features. +Call CryptoProvider::install_default() before this point to select a provider manually, or make sure exactly one of the 'aws-lc-rs' and 'ring' features is enabled. +See the documentation of the CryptoProvider type for more information. + "###); + // Ignore the error resulting from us losing a race, and accept the outcome. + let _ = provider.install_default(); + Self::get_default().unwrap() + } + + /// Returns a provider named unambiguously by rustls crate features. + /// + /// This function returns `None` if the crate features are ambiguous (ie, specify two + /// providers), or specify no providers, or the feature `custom-provider` is activated. + /// In all cases the application should explicitly specify the provider to use + /// with [`CryptoProvider::install_default`]. + fn from_crate_features() -> Option { + #[cfg(all( + feature = "ring", + not(feature = "aws_lc_rs"), + not(feature = "custom-provider") + ))] + { + return Some(ring::default_provider()); + } + + #[cfg(all( + feature = "aws_lc_rs", + not(feature = "ring"), + not(feature = "custom-provider") + ))] + { + return Some(aws_lc_rs::default_provider()); + } + + #[allow(unreachable_code)] + None + } + + /// Returns `true` if this `CryptoProvider` is operating in FIPS mode. + /// + /// This covers only the cryptographic parts of FIPS approval. There are + /// also TLS protocol-level recommendations made by NIST. You should + /// prefer to call [`ClientConfig::fips()`] or [`ServerConfig::fips()`] + /// which take these into account. + pub fn fips(&self) -> bool { + let Self { + cipher_suites, + kx_groups, + signature_verification_algorithms, + secure_random, + key_provider, + } = self; + cipher_suites.iter().all(|cs| cs.fips()) + && kx_groups.iter().all(|kx| kx.fips()) + && signature_verification_algorithms.fips() + && secure_random.fips() + && key_provider.fips() + } +} + +/// A source of cryptographically secure randomness. +pub trait SecureRandom: Send + Sync + Debug { + /// Fill the given buffer with random bytes. + /// + /// The bytes must be sourced from a cryptographically secure random number + /// generator seeded with good quality, secret entropy. + /// + /// This is used for all randomness required by rustls, but not necessarily + /// randomness required by the underlying cryptography library. For example: + /// [`SupportedKxGroup::start()`] requires random material to generate + /// an ephemeral key exchange key, but this is not included in the interface with + /// rustls: it is assumed that the cryptography library provides for this itself. + fn fill(&self, buf: &mut [u8]) -> Result<(), GetRandomFailed>; + + /// Return `true` if this is backed by a FIPS-approved implementation. + fn fips(&self) -> bool { + false + } +} + +/// A mechanism for loading private [`SigningKey`]s from [`PrivateKeyDer`]. +/// +/// This trait is intended to be used with private key material that is sourced from DER, +/// such as a private-key that may be present on-disk. It is not intended to be used with +/// keys held in hardware security modules (HSMs) or physical tokens. For these use-cases +/// see the Rustls manual section on [customizing private key usage]. +/// +/// [customizing private key usage]: +pub trait KeyProvider: Send + Sync + Debug { + /// Decode and validate a private signing key from `key_der`. + /// + /// This is used by [`ConfigBuilder::with_client_auth_cert()`], [`ConfigBuilder::with_single_cert()`], + /// and [`ConfigBuilder::with_single_cert_with_ocsp()`]. The key types and formats supported by this + /// function directly defines the key types and formats supported in those APIs. + /// + /// Return an error if the key type encoding is not supported, or if the key fails validation. + fn load_private_key( + &self, + key_der: PrivateKeyDer<'static>, + ) -> Result, Error>; + + /// Return `true` if this is backed by a FIPS-approved implementation. + /// + /// If this returns `true`, that must be the case for all possible key types + /// supported by [`KeyProvider::load_private_key()`]. + fn fips(&self) -> bool { + false + } +} + +/// A supported key exchange group. +/// +/// This type carries both configuration and implementation. Specifically, +/// it has a TLS-level name expressed using the [`NamedGroup`] enum, and +/// a function which produces a [`ActiveKeyExchange`]. +/// +/// Compare with [`NamedGroup`], which carries solely a protocol identifier. +pub trait SupportedKxGroup: Send + Sync + Debug { + /// Start a key exchange. + /// + /// This will prepare an ephemeral secret key in the supported group, and a corresponding + /// public key. The key exchange can be completed by calling [ActiveKeyExchange#complete] + /// or discarded. + /// + /// # Errors + /// + /// This can fail if the random source fails during ephemeral key generation. + fn start(&self) -> Result, Error>; + + /// Start and complete a key exchange, in one operation. + /// + /// The default implementation for this calls `start()` and then calls + /// `complete()` on the result. This is suitable for Diffie-Hellman-like + /// key exchange algorithms, where there is not a data dependency between + /// our key share (named "pub_key" in this API) and the peer's (`peer_pub_key`). + /// + /// If there is such a data dependency (like key encapsulation mechanisms), this + /// function should be implemented. + fn start_and_complete(&self, peer_pub_key: &[u8]) -> Result { + let kx = self.start()?; + + Ok(CompletedKeyExchange { + group: kx.group(), + pub_key: kx.pub_key().to_vec(), + secret: kx.complete(peer_pub_key)?, + }) + } + + /// FFDHE group the `SupportedKxGroup` operates in. + /// + /// Return `None` if this group is not a FFDHE one. + /// + /// The default implementation calls `FfdheGroup::from_named_group`: this function + /// is extremely linker-unfriendly so it is recommended all key exchange implementers + /// provide this function. + /// + /// `rustls::ffdhe_groups` contains suitable values to return from this, + /// for example [`rustls::ffdhe_groups::FFDHE2048`][crate::ffdhe_groups::FFDHE2048]. + fn ffdhe_group(&self) -> Option> { + #[allow(deprecated)] + FfdheGroup::from_named_group(self.name()) + } + + /// Named group the SupportedKxGroup operates in. + /// + /// If the `NamedGroup` enum does not have a name for the algorithm you are implementing, + /// you can use [`NamedGroup::Unknown`]. + fn name(&self) -> NamedGroup; + + /// Return `true` if this is backed by a FIPS-approved implementation. + fn fips(&self) -> bool { + false + } + + /// Return `true` if this should be offered/selected with the given version. + /// + /// The default implementation returns true for all versions. + fn usable_for_version(&self, _version: ProtocolVersion) -> bool { + true + } +} + +/// An in-progress key exchange originating from a [`SupportedKxGroup`]. +pub trait ActiveKeyExchange: Send + Sync { + /// Completes the key exchange, given the peer's public key. + /// + /// This method must return an error if `peer_pub_key` is invalid: either + /// mis-encoded, or an invalid public key (such as, but not limited to, being + /// in a small order subgroup). + /// + /// If the key exchange algorithm is FFDHE, the result must be left-padded with zeros, + /// as required by [RFC 8446](https://www.rfc-editor.org/rfc/rfc8446#section-7.4.1) + /// (see [`complete_for_tls_version()`](Self::complete_for_tls_version) for more details). + /// + /// The shared secret is returned as a [`SharedSecret`] which can be constructed + /// from a `&[u8]`. + /// + /// This consumes and so terminates the [`ActiveKeyExchange`]. + fn complete(self: Box, peer_pub_key: &[u8]) -> Result; + + /// Completes the key exchange for the given TLS version, given the peer's public key. + /// + /// Note that finite-field Diffie–Hellman key exchange has different requirements for the derived + /// shared secret in TLS 1.2 and TLS 1.3 (ECDHE key exchange is the same in TLS 1.2 and TLS 1.3): + /// + /// In TLS 1.2, the calculated secret is required to be stripped of leading zeros + /// [(RFC 5246)](https://www.rfc-editor.org/rfc/rfc5246#section-8.1.2). + /// + /// In TLS 1.3, the calculated secret is required to be padded with leading zeros to be the same + /// byte-length as the group modulus [(RFC 8446)](https://www.rfc-editor.org/rfc/rfc8446#section-7.4.1). + /// + /// The default implementation of this method delegates to [`complete()`](Self::complete) assuming it is + /// implemented for TLS 1.3 (i.e., for FFDHE KX, removes padding as needed). Implementers of this trait + /// are encouraged to just implement [`complete()`](Self::complete) assuming TLS 1.3, and let the default + /// implementation of this method handle TLS 1.2-specific requirements. + /// + /// This method must return an error if `peer_pub_key` is invalid: either + /// mis-encoded, or an invalid public key (such as, but not limited to, being + /// in a small order subgroup). + /// + /// The shared secret is returned as a [`SharedSecret`] which can be constructed + /// from a `&[u8]`. + /// + /// This consumes and so terminates the [`ActiveKeyExchange`]. + fn complete_for_tls_version( + self: Box, + peer_pub_key: &[u8], + tls_version: &SupportedProtocolVersion, + ) -> Result { + if tls_version.version != ProtocolVersion::TLSv1_2 { + return self.complete(peer_pub_key); + } + + let group = self.group(); + let mut complete_res = self.complete(peer_pub_key)?; + if group.key_exchange_algorithm() == KeyExchangeAlgorithm::DHE { + complete_res.strip_leading_zeros(); + } + Ok(complete_res) + } + + /// For hybrid key exchanges, returns the [`NamedGroup`] and key share + /// for the classical half of this key exchange. + /// + /// There is no requirement for a hybrid scheme (or any other!) to implement + /// `hybrid_component()`. It only enables an optimization; described below. + /// + /// "Hybrid" means a key exchange algorithm which is constructed from two + /// (or more) independent component algorithms. Usually one is post-quantum-secure, + /// and the other is "classical". See + /// + /// + /// # Background + /// Rustls always sends a presumptive key share in its `ClientHello`, using + /// (absent any other information) the first item in [`CryptoProvider::kx_groups`]. + /// If the server accepts the client's selection, it can complete the handshake + /// using that key share. If not, the server sends a `HelloRetryRequest` instructing + /// the client to send a different key share instead. + /// + /// This request costs an extra round trip, and wastes the key exchange computation + /// (in [`SupportedKxGroup::start()`]) the client already did. We would + /// like to avoid those wastes if possible. + /// + /// It is early days for post-quantum-secure hybrid key exchange deployment. + /// This means (commonly) continuing to offer both the hybrid and classical + /// key exchanges, so the handshake can be completed without a `HelloRetryRequest` + /// for servers that support the offered hybrid or classical schemes. + /// + /// Implementing `hybrid_component()` enables two optimizations: + /// + /// 1. Sending both the hybrid and classical key shares in the `ClientHello`. + /// + /// 2. Performing the classical key exchange setup only once. This is important + /// because the classical key exchange setup is relatively expensive. + /// This optimization is permitted and described in + /// + /// + /// Both of these only happen if the classical algorithm appears separately in + /// the client's [`CryptoProvider::kx_groups`], and if the hybrid algorithm appears + /// first in that list. + /// + /// # How it works + /// This function is only called by rustls for clients. It is called when + /// constructing the initial `ClientHello`. rustls follows these steps: + /// + /// 1. If the return value is `None`, nothing further happens. + /// 2. If the given [`NamedGroup`] does not appear in + /// [`CryptoProvider::kx_groups`], nothing further happens. + /// 3. The given key share is added to the `ClientHello`, after the hybrid entry. + /// + /// Then, one of three things may happen when the server replies to the `ClientHello`: + /// + /// 1. The server sends a `HelloRetryRequest`. Everything is thrown away and + /// we start again. + /// 2. The server agrees to our hybrid key exchange: rustls calls + /// [`ActiveKeyExchange::complete()`] consuming `self`. + /// 3. The server agrees to our classical key exchange: rustls calls + /// [`ActiveKeyExchange::complete_hybrid_component()`] which + /// discards the hybrid key data, and completes just the classical key exchange. + fn hybrid_component(&self) -> Option<(NamedGroup, &[u8])> { + None + } + + /// Completes the classical component of the key exchange, given the peer's public key. + /// + /// This is only called if `hybrid_component` returns `Some(_)`. + /// + /// This method must return an error if `peer_pub_key` is invalid: either + /// mis-encoded, or an invalid public key (such as, but not limited to, being + /// in a small order subgroup). + /// + /// The shared secret is returned as a [`SharedSecret`] which can be constructed + /// from a `&[u8]`. + /// + /// See the documentation on [`Self::hybrid_component()`] for explanation. + fn complete_hybrid_component( + self: Box, + _peer_pub_key: &[u8], + ) -> Result { + unreachable!("only called if `hybrid_component()` implemented") + } + + /// Return the public key being used. + /// + /// For ECDHE, the encoding required is defined in + /// [RFC8446 section 4.2.8.2](https://www.rfc-editor.org/rfc/rfc8446#section-4.2.8.2). + /// + /// For FFDHE, the encoding required is defined in + /// [RFC8446 section 4.2.8.1](https://www.rfc-editor.org/rfc/rfc8446#section-4.2.8.1). + fn pub_key(&self) -> &[u8]; + + /// FFDHE group the `ActiveKeyExchange` is operating in. + /// + /// Return `None` if this group is not a FFDHE one. + /// + /// The default implementation calls `FfdheGroup::from_named_group`: this function + /// is extremely linker-unfriendly so it is recommended all key exchange implementers + /// provide this function. + /// + /// `rustls::ffdhe_groups` contains suitable values to return from this, + /// for example [`rustls::ffdhe_groups::FFDHE2048`][crate::ffdhe_groups::FFDHE2048]. + fn ffdhe_group(&self) -> Option> { + #[allow(deprecated)] + FfdheGroup::from_named_group(self.group()) + } + + /// Return the group being used. + fn group(&self) -> NamedGroup; +} + +/// The result from [`SupportedKxGroup::start_and_complete()`]. +pub struct CompletedKeyExchange { + /// Which group was used. + pub group: NamedGroup, + + /// Our key share (sometimes a public key). + pub pub_key: Vec, + + /// The computed shared secret. + pub secret: SharedSecret, +} + +/// The result from [`ActiveKeyExchange::complete`] or [`ActiveKeyExchange::complete_hybrid_component`]. +pub struct SharedSecret { + buf: Vec, + offset: usize, +} + +impl SharedSecret { + /// Returns the shared secret as a slice of bytes. + pub fn secret_bytes(&self) -> &[u8] { + &self.buf[self.offset..] + } + + /// Removes leading zeros from `secret_bytes()` by adjusting the `offset`. + /// + /// This function does not re-allocate. + fn strip_leading_zeros(&mut self) { + let start = self + .secret_bytes() + .iter() + .enumerate() + .find(|(_i, x)| **x != 0) + .map(|(i, _x)| i) + .unwrap_or(self.secret_bytes().len()); + self.offset += start; + } +} + +impl Drop for SharedSecret { + fn drop(&mut self) { + self.buf.zeroize(); + } +} + +impl From<&[u8]> for SharedSecret { + fn from(source: &[u8]) -> Self { + Self { + buf: source.to_vec(), + offset: 0, + } + } +} + +impl From> for SharedSecret { + fn from(buf: Vec) -> Self { + Self { buf, offset: 0 } + } +} + +/// This function returns a [`CryptoProvider`] that uses +/// FIPS140-3-approved cryptography. +/// +/// Using this function expresses in your code that you require +/// FIPS-approved cryptography, and will not compile if you make +/// a mistake with cargo features. +/// +/// See our [FIPS documentation](crate::manual::_06_fips) for +/// more detail. +/// +/// Install this as the process-default provider, like: +/// +/// ```rust +/// # #[cfg(feature = "fips")] { +/// rustls::crypto::default_fips_provider().install_default() +/// .expect("default provider already set elsewhere"); +/// # } +/// ``` +/// +/// You can also use this explicitly, like: +/// +/// ```rust +/// # #[cfg(feature = "fips")] { +/// # let root_store = rustls::RootCertStore::empty(); +/// let config = rustls::ClientConfig::builder_with_provider( +/// rustls::crypto::default_fips_provider().into() +/// ) +/// .with_safe_default_protocol_versions() +/// .unwrap() +/// .with_root_certificates(root_store) +/// .with_no_client_auth(); +/// # } +/// ``` +#[cfg(all(feature = "aws_lc_rs", any(feature = "fips", rustls_docsrs)))] +#[cfg_attr(rustls_docsrs, doc(cfg(feature = "fips")))] +pub fn default_fips_provider() -> CryptoProvider { + aws_lc_rs::default_provider() +} + +mod static_default { + #[cfg(not(feature = "std"))] + use alloc::boxed::Box; + #[cfg(feature = "std")] + use std::sync::OnceLock; + + #[cfg(not(feature = "std"))] + use once_cell::race::OnceBox; + + use super::CryptoProvider; + use crate::sync::Arc; + + #[cfg(feature = "std")] + pub(crate) fn install_default( + default_provider: CryptoProvider, + ) -> Result<(), Arc> { + PROCESS_DEFAULT_PROVIDER.set(Arc::new(default_provider)) + } + + #[cfg(not(feature = "std"))] + pub(crate) fn install_default( + default_provider: CryptoProvider, + ) -> Result<(), Arc> { + PROCESS_DEFAULT_PROVIDER + .set(Box::new(Arc::new(default_provider))) + .map_err(|e| *e) + } + + pub(crate) fn get_default() -> Option<&'static Arc> { + PROCESS_DEFAULT_PROVIDER.get() + } + + #[cfg(feature = "std")] + static PROCESS_DEFAULT_PROVIDER: OnceLock> = OnceLock::new(); + #[cfg(not(feature = "std"))] + static PROCESS_DEFAULT_PROVIDER: OnceBox> = OnceBox::new(); +} + +#[cfg(test)] +mod tests { + use std::vec; + + use super::SharedSecret; + + #[test] + fn test_shared_secret_strip_leading_zeros() { + let test_cases = [ + (vec![0, 1], vec![1]), + (vec![1], vec![1]), + (vec![1, 0, 2], vec![1, 0, 2]), + (vec![0, 0, 1, 2], vec![1, 2]), + (vec![0, 0, 0], vec![]), + (vec![], vec![]), + ]; + for (buf, expected) in test_cases { + let mut secret = SharedSecret::from(&buf[..]); + assert_eq!(secret.secret_bytes(), buf); + secret.strip_leading_zeros(); + assert_eq!(secret.secret_bytes(), expected); + } + } +} diff --git a/http/vendor/rustls/src/crypto/ring/hash.rs b/http/vendor/rustls/src/crypto/ring/hash.rs new file mode 100644 index 0000000..220dc53 --- /dev/null +++ b/http/vendor/rustls/src/crypto/ring/hash.rs @@ -0,0 +1,60 @@ +#![allow(clippy::duplicate_mod)] + +use alloc::boxed::Box; + +use super::ring_like::digest; +use crate::crypto; +use crate::msgs::enums::HashAlgorithm; + +pub(crate) static SHA256: Hash = Hash(&digest::SHA256, HashAlgorithm::SHA256); +pub(crate) static SHA384: Hash = Hash(&digest::SHA384, HashAlgorithm::SHA384); + +pub(crate) struct Hash(&'static digest::Algorithm, HashAlgorithm); + +impl crypto::hash::Hash for Hash { + fn start(&self) -> Box { + Box::new(Context(digest::Context::new(self.0))) + } + + fn hash(&self, bytes: &[u8]) -> crypto::hash::Output { + let mut ctx = digest::Context::new(self.0); + ctx.update(bytes); + convert(ctx.finish()) + } + + fn output_len(&self) -> usize { + self.0.output_len() + } + + fn algorithm(&self) -> HashAlgorithm { + self.1 + } + + fn fips(&self) -> bool { + super::fips() + } +} + +struct Context(digest::Context); + +impl crypto::hash::Context for Context { + fn fork_finish(&self) -> crypto::hash::Output { + convert(self.0.clone().finish()) + } + + fn fork(&self) -> Box { + Box::new(Self(self.0.clone())) + } + + fn finish(self: Box) -> crypto::hash::Output { + convert(self.0.finish()) + } + + fn update(&mut self, data: &[u8]) { + self.0.update(data); + } +} + +fn convert(val: digest::Digest) -> crypto::hash::Output { + crypto::hash::Output::new(val.as_ref()) +} diff --git a/http/vendor/rustls/src/crypto/ring/hmac.rs b/http/vendor/rustls/src/crypto/ring/hmac.rs new file mode 100644 index 0000000..7f30aba --- /dev/null +++ b/http/vendor/rustls/src/crypto/ring/hmac.rs @@ -0,0 +1,48 @@ +#![allow(clippy::duplicate_mod)] + +use alloc::boxed::Box; + +use super::ring_like; +use crate::crypto; + +pub(crate) static HMAC_SHA256: Hmac = Hmac(&ring_like::hmac::HMAC_SHA256); +pub(crate) static HMAC_SHA384: Hmac = Hmac(&ring_like::hmac::HMAC_SHA384); +#[allow(dead_code)] // Only used for TLS 1.2 prf test, and aws-lc-rs HPKE suites. +pub(crate) static HMAC_SHA512: Hmac = Hmac(&ring_like::hmac::HMAC_SHA512); + +pub(crate) struct Hmac(&'static ring_like::hmac::Algorithm); + +impl crypto::hmac::Hmac for Hmac { + fn with_key(&self, key: &[u8]) -> Box { + Box::new(Key(ring_like::hmac::Key::new(*self.0, key))) + } + + fn hash_output_len(&self) -> usize { + self.0.digest_algorithm().output_len() + } + + fn fips(&self) -> bool { + super::fips() + } +} + +struct Key(ring_like::hmac::Key); + +impl crypto::hmac::Key for Key { + fn sign_concat(&self, first: &[u8], middle: &[&[u8]], last: &[u8]) -> crypto::hmac::Tag { + let mut ctx = ring_like::hmac::Context::with_key(&self.0); + ctx.update(first); + for d in middle { + ctx.update(d); + } + ctx.update(last); + crypto::hmac::Tag::new(ctx.sign().as_ref()) + } + + fn tag_len(&self) -> usize { + self.0 + .algorithm() + .digest_algorithm() + .output_len() + } +} diff --git a/http/vendor/rustls/src/crypto/ring/kx.rs b/http/vendor/rustls/src/crypto/ring/kx.rs new file mode 100644 index 0000000..6e0da22 --- /dev/null +++ b/http/vendor/rustls/src/crypto/ring/kx.rs @@ -0,0 +1,188 @@ +#![allow(clippy::duplicate_mod)] + +use alloc::boxed::Box; +use core::fmt; + +use super::ring_like::agreement; +use super::ring_like::rand::SystemRandom; +use crate::crypto::{ActiveKeyExchange, FfdheGroup, SharedSecret, SupportedKxGroup}; +use crate::error::{Error, PeerMisbehaved}; +use crate::msgs::enums::NamedGroup; +use crate::rand::GetRandomFailed; + +/// A key-exchange group supported by *ring*. +struct KxGroup { + /// The IANA "TLS Supported Groups" name of the group + name: NamedGroup, + + /// The corresponding ring agreement::Algorithm + agreement_algorithm: &'static agreement::Algorithm, + + /// Whether the algorithm is allowed by FIPS + /// + /// `SupportedKxGroup::fips()` is true if and only if the algorithm is allowed, + /// _and_ the implementation is FIPS-validated. + fips_allowed: bool, + + /// aws-lc-rs 1.9 and later accepts more formats of public keys than + /// just uncompressed. + /// + /// That is not compatible with TLS: + /// - TLS1.3 outlaws other encodings, + /// - TLS1.2 negotiates other encodings (we only offer uncompressed), and + /// defaults to uncompressed if negotiation is not done. + /// + /// This function should return `true` if the basic shape of its argument + /// is consistent with an uncompressed point encoding. It does not need + /// to verify that the point is on the curve (if the curve requires that + /// for security); aws-lc-rs/ring must do that. + pub_key_validator: fn(&[u8]) -> bool, +} + +impl SupportedKxGroup for KxGroup { + fn start(&self) -> Result, Error> { + let rng = SystemRandom::new(); + let priv_key = agreement::EphemeralPrivateKey::generate(self.agreement_algorithm, &rng) + .map_err(|_| GetRandomFailed)?; + + let pub_key = priv_key + .compute_public_key() + .map_err(|_| GetRandomFailed)?; + + Ok(Box::new(KeyExchange { + name: self.name, + agreement_algorithm: self.agreement_algorithm, + priv_key, + pub_key, + pub_key_validator: self.pub_key_validator, + })) + } + + fn ffdhe_group(&self) -> Option> { + None + } + + fn name(&self) -> NamedGroup { + self.name + } + + fn fips(&self) -> bool { + self.fips_allowed && super::fips() + } +} + +impl fmt::Debug for KxGroup { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + self.name.fmt(f) + } +} + +/// Ephemeral ECDH on curve25519 (see RFC7748) +pub static X25519: &dyn SupportedKxGroup = &KxGroup { + name: NamedGroup::X25519, + agreement_algorithm: &agreement::X25519, + + // "Curves that are included in SP 800-186 but not included in SP 800-56Arev3 are + // not approved for key agreement. E.g., the ECDH X25519 and X448 key agreement + // schemes (defined in RFC 7748) that use Curve25519 and Curve448, respectively, + // are not compliant to SP 800-56Arev3." + // -- + fips_allowed: false, + + pub_key_validator: |point: &[u8]| point.len() == 32, +}; + +/// Ephemeral ECDH on secp256r1 (aka NIST-P256) +pub static SECP256R1: &dyn SupportedKxGroup = &KxGroup { + name: NamedGroup::secp256r1, + agreement_algorithm: &agreement::ECDH_P256, + fips_allowed: true, + pub_key_validator: uncompressed_point, +}; + +/// Ephemeral ECDH on secp384r1 (aka NIST-P384) +pub static SECP384R1: &dyn SupportedKxGroup = &KxGroup { + name: NamedGroup::secp384r1, + agreement_algorithm: &agreement::ECDH_P384, + fips_allowed: true, + pub_key_validator: uncompressed_point, +}; + +fn uncompressed_point(point: &[u8]) -> bool { + // See `UncompressedPointRepresentation`, which is a retelling of + // SEC1 section 2.3.3 "Elliptic-Curve-Point-to-Octet-String Conversion" + // + matches!(point.first(), Some(0x04)) +} + +/// An in-progress key exchange. This has the algorithm, +/// our private key, and our public key. +struct KeyExchange { + name: NamedGroup, + agreement_algorithm: &'static agreement::Algorithm, + priv_key: agreement::EphemeralPrivateKey, + pub_key: agreement::PublicKey, + pub_key_validator: fn(&[u8]) -> bool, +} + +impl ActiveKeyExchange for KeyExchange { + /// Completes the key exchange, given the peer's public key. + fn complete(self: Box, peer: &[u8]) -> Result { + if !(self.pub_key_validator)(peer) { + return Err(PeerMisbehaved::InvalidKeyShare.into()); + } + let peer_key = agreement::UnparsedPublicKey::new(self.agreement_algorithm, peer); + super::ring_shim::agree_ephemeral(self.priv_key, &peer_key) + .map_err(|_| PeerMisbehaved::InvalidKeyShare.into()) + } + + fn ffdhe_group(&self) -> Option> { + None + } + + /// Return the group being used. + fn group(&self) -> NamedGroup { + self.name + } + + /// Return the public key being used. + fn pub_key(&self) -> &[u8] { + self.pub_key.as_ref() + } +} + +#[cfg(test)] +mod tests { + use std::format; + + #[test] + fn kxgroup_fmt_yields_name() { + assert_eq!("X25519", format!("{:?}", super::X25519)); + } +} + +#[cfg(bench)] +mod benchmarks { + #[bench] + fn bench_x25519(b: &mut test::Bencher) { + bench_any(b, super::X25519); + } + + #[bench] + fn bench_ecdh_p256(b: &mut test::Bencher) { + bench_any(b, super::SECP256R1); + } + + #[bench] + fn bench_ecdh_p384(b: &mut test::Bencher) { + bench_any(b, super::SECP384R1); + } + + fn bench_any(b: &mut test::Bencher, kxg: &dyn super::SupportedKxGroup) { + b.iter(|| { + let akx = kxg.start().unwrap(); + let pub_key = akx.pub_key().to_vec(); + test::black_box(akx.complete(&pub_key).unwrap()); + }); + } +} diff --git a/http/vendor/rustls/src/crypto/ring/mod.rs b/http/vendor/rustls/src/crypto/ring/mod.rs new file mode 100644 index 0000000..3ce99b1 --- /dev/null +++ b/http/vendor/rustls/src/crypto/ring/mod.rs @@ -0,0 +1,203 @@ +use pki_types::PrivateKeyDer; +pub(crate) use ring as ring_like; +use webpki::ring as webpki_algs; + +use crate::Error; +use crate::crypto::{CryptoProvider, KeyProvider, SecureRandom, SupportedKxGroup}; +use crate::enums::SignatureScheme; +use crate::rand::GetRandomFailed; +use crate::sign::SigningKey; +use crate::suites::SupportedCipherSuite; +use crate::sync::Arc; +use crate::webpki::WebPkiSupportedAlgorithms; + +/// Using software keys for authentication. +pub mod sign; + +pub(crate) mod hash; +#[cfg(any(test, feature = "tls12"))] +pub(crate) mod hmac; +pub(crate) mod kx; +pub(crate) mod quic; +#[cfg(feature = "std")] +pub(crate) mod ticketer; +#[cfg(feature = "tls12")] +pub(crate) mod tls12; +pub(crate) mod tls13; + +/// A `CryptoProvider` backed by the [*ring*] crate. +/// +/// [*ring*]: https://github.com/briansmith/ring +pub fn default_provider() -> CryptoProvider { + CryptoProvider { + cipher_suites: DEFAULT_CIPHER_SUITES.to_vec(), + kx_groups: DEFAULT_KX_GROUPS.to_vec(), + signature_verification_algorithms: SUPPORTED_SIG_ALGS, + secure_random: &Ring, + key_provider: &Ring, + } +} + +/// Default crypto provider. +#[derive(Debug)] +struct Ring; + +impl SecureRandom for Ring { + fn fill(&self, buf: &mut [u8]) -> Result<(), GetRandomFailed> { + use ring_like::rand::SecureRandom; + + ring_like::rand::SystemRandom::new() + .fill(buf) + .map_err(|_| GetRandomFailed) + } +} + +impl KeyProvider for Ring { + fn load_private_key( + &self, + key_der: PrivateKeyDer<'static>, + ) -> Result, Error> { + sign::any_supported_type(&key_der) + } +} + +/// The cipher suite configuration that an application should use by default. +/// +/// This will be [`ALL_CIPHER_SUITES`] sans any supported cipher suites that +/// shouldn't be enabled by most applications. +pub static DEFAULT_CIPHER_SUITES: &[SupportedCipherSuite] = ALL_CIPHER_SUITES; + +/// A list of all the cipher suites supported by the rustls *ring* provider. +pub static ALL_CIPHER_SUITES: &[SupportedCipherSuite] = &[ + // TLS1.3 suites + tls13::TLS13_AES_256_GCM_SHA384, + tls13::TLS13_AES_128_GCM_SHA256, + tls13::TLS13_CHACHA20_POLY1305_SHA256, + // TLS1.2 suites + #[cfg(feature = "tls12")] + tls12::TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, + #[cfg(feature = "tls12")] + tls12::TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, + #[cfg(feature = "tls12")] + tls12::TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256, + #[cfg(feature = "tls12")] + tls12::TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, + #[cfg(feature = "tls12")] + tls12::TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, + #[cfg(feature = "tls12")] + tls12::TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, +]; + +/// All defined cipher suites supported by *ring* appear in this module. +pub mod cipher_suite { + #[cfg(feature = "tls12")] + pub use super::tls12::{ + TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, + TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, + TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, + }; + pub use super::tls13::{ + TLS13_AES_128_GCM_SHA256, TLS13_AES_256_GCM_SHA384, TLS13_CHACHA20_POLY1305_SHA256, + }; +} + +/// A `WebPkiSupportedAlgorithms` value that reflects webpki's capabilities when +/// compiled against *ring*. +static SUPPORTED_SIG_ALGS: WebPkiSupportedAlgorithms = WebPkiSupportedAlgorithms { + all: &[ + webpki_algs::ECDSA_P256_SHA256, + webpki_algs::ECDSA_P256_SHA384, + webpki_algs::ECDSA_P384_SHA256, + webpki_algs::ECDSA_P384_SHA384, + webpki_algs::ED25519, + webpki_algs::RSA_PSS_2048_8192_SHA256_LEGACY_KEY, + webpki_algs::RSA_PSS_2048_8192_SHA384_LEGACY_KEY, + webpki_algs::RSA_PSS_2048_8192_SHA512_LEGACY_KEY, + webpki_algs::RSA_PKCS1_2048_8192_SHA256, + webpki_algs::RSA_PKCS1_2048_8192_SHA384, + webpki_algs::RSA_PKCS1_2048_8192_SHA512, + webpki_algs::RSA_PKCS1_2048_8192_SHA256_ABSENT_PARAMS, + webpki_algs::RSA_PKCS1_2048_8192_SHA384_ABSENT_PARAMS, + webpki_algs::RSA_PKCS1_2048_8192_SHA512_ABSENT_PARAMS, + ], + mapping: &[ + // Note: for TLS1.2 the curve is not fixed by SignatureScheme. For TLS1.3 it is. + ( + SignatureScheme::ECDSA_NISTP384_SHA384, + &[ + webpki_algs::ECDSA_P384_SHA384, + webpki_algs::ECDSA_P256_SHA384, + ], + ), + ( + SignatureScheme::ECDSA_NISTP256_SHA256, + &[ + webpki_algs::ECDSA_P256_SHA256, + webpki_algs::ECDSA_P384_SHA256, + ], + ), + (SignatureScheme::ED25519, &[webpki_algs::ED25519]), + ( + SignatureScheme::RSA_PSS_SHA512, + &[webpki_algs::RSA_PSS_2048_8192_SHA512_LEGACY_KEY], + ), + ( + SignatureScheme::RSA_PSS_SHA384, + &[webpki_algs::RSA_PSS_2048_8192_SHA384_LEGACY_KEY], + ), + ( + SignatureScheme::RSA_PSS_SHA256, + &[webpki_algs::RSA_PSS_2048_8192_SHA256_LEGACY_KEY], + ), + ( + SignatureScheme::RSA_PKCS1_SHA512, + &[webpki_algs::RSA_PKCS1_2048_8192_SHA512], + ), + ( + SignatureScheme::RSA_PKCS1_SHA384, + &[webpki_algs::RSA_PKCS1_2048_8192_SHA384], + ), + ( + SignatureScheme::RSA_PKCS1_SHA256, + &[webpki_algs::RSA_PKCS1_2048_8192_SHA256], + ), + ], +}; + +/// All defined key exchange groups supported by *ring* appear in this module. +/// +/// [`ALL_KX_GROUPS`] is provided as an array of all of these values. +/// [`DEFAULT_KX_GROUPS`] is provided as an array of this provider's defaults. +pub mod kx_group { + pub use super::kx::{SECP256R1, SECP384R1, X25519}; +} + +/// A list of the default key exchange groups supported by this provider. +pub static DEFAULT_KX_GROUPS: &[&dyn SupportedKxGroup] = ALL_KX_GROUPS; + +/// A list of all the key exchange groups supported by this provider. +pub static ALL_KX_GROUPS: &[&dyn SupportedKxGroup] = + &[kx_group::X25519, kx_group::SECP256R1, kx_group::SECP384R1]; + +#[cfg(feature = "std")] +pub use ticketer::Ticketer; + +/// Compatibility shims between ring 0.16.x and 0.17.x API +mod ring_shim { + use super::ring_like; + use crate::crypto::SharedSecret; + + pub(super) fn agree_ephemeral( + priv_key: ring_like::agreement::EphemeralPrivateKey, + peer_key: &ring_like::agreement::UnparsedPublicKey<&[u8]>, + ) -> Result { + ring_like::agreement::agree_ephemeral(priv_key, peer_key, |secret| { + SharedSecret::from(secret) + }) + .map_err(|_| ()) + } +} + +pub(super) fn fips() -> bool { + false +} diff --git a/http/vendor/rustls/src/crypto/ring/quic.rs b/http/vendor/rustls/src/crypto/ring/quic.rs new file mode 100644 index 0000000..354e6ae --- /dev/null +++ b/http/vendor/rustls/src/crypto/ring/quic.rs @@ -0,0 +1,533 @@ +#![allow(clippy::duplicate_mod)] + +use alloc::boxed::Box; + +use super::ring_like::aead; +use crate::crypto::cipher::{AeadKey, Iv, Nonce}; +use crate::error::Error; +use crate::quic; + +pub(crate) struct HeaderProtectionKey(aead::quic::HeaderProtectionKey); + +impl HeaderProtectionKey { + pub(crate) fn new(key: AeadKey, alg: &'static aead::quic::Algorithm) -> Self { + Self(aead::quic::HeaderProtectionKey::new(alg, key.as_ref()).unwrap()) + } + + fn xor_in_place( + &self, + sample: &[u8], + first: &mut u8, + packet_number: &mut [u8], + masked: bool, + ) -> Result<(), Error> { + // This implements "Header Protection Application" almost verbatim. + // + + let mask = self + .0 + .new_mask(sample) + .map_err(|_| Error::General("sample of invalid length".into()))?; + + // The `unwrap()` will not panic because `new_mask` returns a + // non-empty result. + let (first_mask, pn_mask) = mask.split_first().unwrap(); + + // It is OK for the `mask` to be longer than `packet_number`, + // but a valid `packet_number` will never be longer than `mask`. + if packet_number.len() > pn_mask.len() { + return Err(Error::General("packet number too long".into())); + } + + // Infallible from this point on. Before this point, `first` and + // `packet_number` are unchanged. + + const LONG_HEADER_FORM: u8 = 0x80; + let bits = match *first & LONG_HEADER_FORM == LONG_HEADER_FORM { + true => 0x0f, // Long header: 4 bits masked + false => 0x1f, // Short header: 5 bits masked + }; + + let first_plain = match masked { + // When unmasking, use the packet length bits after unmasking + true => *first ^ (first_mask & bits), + // When masking, use the packet length bits before masking + false => *first, + }; + let pn_len = (first_plain & 0x03) as usize + 1; + + *first ^= first_mask & bits; + for (dst, m) in packet_number + .iter_mut() + .zip(pn_mask) + .take(pn_len) + { + *dst ^= m; + } + + Ok(()) + } +} + +impl quic::HeaderProtectionKey for HeaderProtectionKey { + fn encrypt_in_place( + &self, + sample: &[u8], + first: &mut u8, + packet_number: &mut [u8], + ) -> Result<(), Error> { + self.xor_in_place(sample, first, packet_number, false) + } + + fn decrypt_in_place( + &self, + sample: &[u8], + first: &mut u8, + packet_number: &mut [u8], + ) -> Result<(), Error> { + self.xor_in_place(sample, first, packet_number, true) + } + + #[inline] + fn sample_len(&self) -> usize { + self.0.algorithm().sample_len() + } +} + +pub(crate) struct PacketKey { + /// Encrypts or decrypts a packet's payload + key: aead::LessSafeKey, + /// Computes unique nonces for each packet + iv: Iv, + /// Confidentiality limit (see [`quic::PacketKey::confidentiality_limit`]) + confidentiality_limit: u64, + /// Integrity limit (see [`quic::PacketKey::integrity_limit`]) + integrity_limit: u64, +} + +impl PacketKey { + pub(crate) fn new( + key: AeadKey, + iv: Iv, + confidentiality_limit: u64, + integrity_limit: u64, + aead_algorithm: &'static aead::Algorithm, + ) -> Self { + Self { + key: aead::LessSafeKey::new( + aead::UnboundKey::new(aead_algorithm, key.as_ref()).unwrap(), + ), + iv, + confidentiality_limit, + integrity_limit, + } + } +} + +impl quic::PacketKey for PacketKey { + fn encrypt_in_place( + &self, + packet_number: u64, + header: &[u8], + payload: &mut [u8], + ) -> Result { + let aad = aead::Aad::from(header); + let nonce = aead::Nonce::assume_unique_for_key(Nonce::new(&self.iv, packet_number).0); + let tag = self + .key + .seal_in_place_separate_tag(nonce, aad, payload) + .map_err(|_| Error::EncryptError)?; + Ok(quic::Tag::from(tag.as_ref())) + } + + fn encrypt_in_place_for_path( + &self, + path_id: u32, + packet_number: u64, + header: &[u8], + payload: &mut [u8], + ) -> Result { + let aad = aead::Aad::from(header); + let nonce = + aead::Nonce::assume_unique_for_key(Nonce::for_path(path_id, &self.iv, packet_number).0); + let tag = self + .key + .seal_in_place_separate_tag(nonce, aad, payload) + .map_err(|_| Error::EncryptError)?; + Ok(quic::Tag::from(tag.as_ref())) + } + + /// Decrypt a QUIC packet + /// + /// Takes the packet `header`, which is used as the additional authenticated data, and the + /// `payload`, which includes the authentication tag. + /// + /// If the return value is `Ok`, the decrypted payload can be found in `payload`, up to the + /// length found in the return value. + fn decrypt_in_place<'a>( + &self, + packet_number: u64, + header: &[u8], + payload: &'a mut [u8], + ) -> Result<&'a [u8], Error> { + let payload_len = payload.len(); + let aad = aead::Aad::from(header); + let nonce = aead::Nonce::assume_unique_for_key(Nonce::new(&self.iv, packet_number).0); + self.key + .open_in_place(nonce, aad, payload) + .map_err(|_| Error::DecryptError)?; + + let plain_len = payload_len - self.key.algorithm().tag_len(); + Ok(&payload[..plain_len]) + } + + fn decrypt_in_place_for_path<'a>( + &self, + path_id: u32, + packet_number: u64, + header: &[u8], + payload: &'a mut [u8], + ) -> Result<&'a [u8], Error> { + let payload_len = payload.len(); + let aad = aead::Aad::from(header); + let nonce = + aead::Nonce::assume_unique_for_key(Nonce::for_path(path_id, &self.iv, packet_number).0); + self.key + .open_in_place(nonce, aad, payload) + .map_err(|_| Error::DecryptError)?; + + let plain_len = payload_len - self.key.algorithm().tag_len(); + Ok(&payload[..plain_len]) + } + + /// Tag length for the underlying AEAD algorithm + #[inline] + fn tag_len(&self) -> usize { + self.key.algorithm().tag_len() + } + + /// Confidentiality limit (see [`quic::PacketKey::confidentiality_limit`]) + fn confidentiality_limit(&self) -> u64 { + self.confidentiality_limit + } + + /// Integrity limit (see [`quic::PacketKey::integrity_limit`]) + fn integrity_limit(&self) -> u64 { + self.integrity_limit + } +} + +pub(crate) struct KeyBuilder { + pub(crate) packet_alg: &'static aead::Algorithm, + pub(crate) header_alg: &'static aead::quic::Algorithm, + pub(crate) confidentiality_limit: u64, + pub(crate) integrity_limit: u64, +} + +impl quic::Algorithm for KeyBuilder { + fn packet_key(&self, key: AeadKey, iv: Iv) -> Box { + Box::new(PacketKey::new( + key, + iv, + self.confidentiality_limit, + self.integrity_limit, + self.packet_alg, + )) + } + + fn header_protection_key(&self, key: AeadKey) -> Box { + Box::new(HeaderProtectionKey::new(key, self.header_alg)) + } + + fn aead_key_len(&self) -> usize { + self.packet_alg.key_len() + } + + fn fips(&self) -> bool { + super::fips() + } +} + +#[cfg(test)] +#[macro_rules_attribute::apply(test_for_each_provider)] +mod tests { + use std::dbg; + + use super::provider::tls13::{ + TLS13_AES_128_GCM_SHA256_INTERNAL, TLS13_CHACHA20_POLY1305_SHA256_INTERNAL, + }; + use crate::common_state::Side; + use crate::crypto::tls13::OkmBlock; + use crate::quic::*; + + fn test_short_packet(version: Version, expected: &[u8]) { + const PN: u64 = 654360564; + const SECRET: &[u8] = &[ + 0x9a, 0xc3, 0x12, 0xa7, 0xf8, 0x77, 0x46, 0x8e, 0xbe, 0x69, 0x42, 0x27, 0x48, 0xad, + 0x00, 0xa1, 0x54, 0x43, 0xf1, 0x82, 0x03, 0xa0, 0x7d, 0x60, 0x60, 0xf6, 0x88, 0xf3, + 0x0f, 0x21, 0x63, 0x2b, + ]; + + let secret = OkmBlock::new(SECRET); + let builder = KeyBuilder::new( + &secret, + version, + TLS13_CHACHA20_POLY1305_SHA256_INTERNAL + .quic + .unwrap(), + TLS13_CHACHA20_POLY1305_SHA256_INTERNAL.hkdf_provider, + ); + let packet = builder.packet_key(); + let hpk = builder.header_protection_key(); + + const PLAIN: &[u8] = &[0x42, 0x00, 0xbf, 0xf4, 0x01]; + + let mut buf = PLAIN.to_vec(); + let (header, payload) = buf.split_at_mut(4); + let tag = packet + .encrypt_in_place(PN, header, payload) + .unwrap(); + buf.extend(tag.as_ref()); + + let pn_offset = 1; + let (header, sample) = buf.split_at_mut(pn_offset + 4); + let (first, rest) = header.split_at_mut(1); + let sample = &sample[..hpk.sample_len()]; + hpk.encrypt_in_place(sample, &mut first[0], dbg!(rest)) + .unwrap(); + + assert_eq!(&buf, expected); + + let (header, sample) = buf.split_at_mut(pn_offset + 4); + let (first, rest) = header.split_at_mut(1); + let sample = &sample[..hpk.sample_len()]; + hpk.decrypt_in_place(sample, &mut first[0], rest) + .unwrap(); + + let (header, payload_tag) = buf.split_at_mut(4); + let plain = packet + .decrypt_in_place(PN, header, payload_tag) + .unwrap(); + + assert_eq!(plain, &PLAIN[4..]); + } + + #[test] + fn short_packet_header_protection() { + // https://www.rfc-editor.org/rfc/rfc9001.html#name-chacha20-poly1305-short-hea + test_short_packet( + Version::V1, + &[ + 0x4c, 0xfe, 0x41, 0x89, 0x65, 0x5e, 0x5c, 0xd5, 0x5c, 0x41, 0xf6, 0x90, 0x80, 0x57, + 0x5d, 0x79, 0x99, 0xc2, 0x5a, 0x5b, 0xfb, + ], + ); + } + + #[test] + fn key_update_test_vector() { + fn equal_okm(x: &OkmBlock, y: &OkmBlock) -> bool { + x.as_ref() == y.as_ref() + } + + let mut secrets = Secrets::new( + // Constant dummy values for reproducibility + OkmBlock::new( + &[ + 0xb8, 0x76, 0x77, 0x08, 0xf8, 0x77, 0x23, 0x58, 0xa6, 0xea, 0x9f, 0xc4, 0x3e, + 0x4a, 0xdd, 0x2c, 0x96, 0x1b, 0x3f, 0x52, 0x87, 0xa6, 0xd1, 0x46, 0x7e, 0xe0, + 0xae, 0xab, 0x33, 0x72, 0x4d, 0xbf, + ][..], + ), + OkmBlock::new( + &[ + 0x42, 0xdc, 0x97, 0x21, 0x40, 0xe0, 0xf2, 0xe3, 0x98, 0x45, 0xb7, 0x67, 0x61, + 0x34, 0x39, 0xdc, 0x67, 0x58, 0xca, 0x43, 0x25, 0x9b, 0x87, 0x85, 0x06, 0x82, + 0x4e, 0xb1, 0xe4, 0x38, 0xd8, 0x55, + ][..], + ), + TLS13_AES_128_GCM_SHA256_INTERNAL, + TLS13_AES_128_GCM_SHA256_INTERNAL + .quic + .unwrap(), + Side::Client, + Version::V1, + ); + secrets.update(); + + assert!(equal_okm( + &secrets.client, + &OkmBlock::new( + &[ + 0x42, 0xca, 0xc8, 0xc9, 0x1c, 0xd5, 0xeb, 0x40, 0x68, 0x2e, 0x43, 0x2e, 0xdf, + 0x2d, 0x2b, 0xe9, 0xf4, 0x1a, 0x52, 0xca, 0x6b, 0x22, 0xd8, 0xe6, 0xcd, 0xb1, + 0xe8, 0xac, 0xa9, 0x6, 0x1f, 0xce + ][..] + ) + )); + assert!(equal_okm( + &secrets.server, + &OkmBlock::new( + &[ + 0xeb, 0x7f, 0x5e, 0x2a, 0x12, 0x3f, 0x40, 0x7d, 0xb4, 0x99, 0xe3, 0x61, 0xca, + 0xe5, 0x90, 0xd4, 0xd9, 0x92, 0xe1, 0x4b, 0x7a, 0xce, 0x3, 0xc2, 0x44, 0xe0, + 0x42, 0x21, 0x15, 0xb6, 0xd3, 0x8a + ][..] + ) + )); + } + + #[test] + fn short_packet_header_protection_v2() { + // https://www.ietf.org/archive/id/draft-ietf-quic-v2-10.html#name-chacha20-poly1305-short-head + test_short_packet( + Version::V2, + &[ + 0x55, 0x58, 0xb1, 0xc6, 0x0a, 0xe7, 0xb6, 0xb9, 0x32, 0xbc, 0x27, 0xd7, 0x86, 0xf4, + 0xbc, 0x2b, 0xb2, 0x0f, 0x21, 0x62, 0xba, + ], + ); + } + + #[test] + fn initial_test_vector_v2() { + // https://www.ietf.org/archive/id/draft-ietf-quic-v2-10.html#name-sample-packet-protection-2 + let icid = [0x83, 0x94, 0xc8, 0xf0, 0x3e, 0x51, 0x57, 0x08]; + let server = Keys::initial( + Version::V2, + TLS13_AES_128_GCM_SHA256_INTERNAL, + TLS13_AES_128_GCM_SHA256_INTERNAL + .quic + .unwrap(), + &icid, + Side::Server, + ); + let mut server_payload = [ + 0x02, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x40, 0x5a, 0x02, 0x00, 0x00, 0x56, 0x03, + 0x03, 0xee, 0xfc, 0xe7, 0xf7, 0xb3, 0x7b, 0xa1, 0xd1, 0x63, 0x2e, 0x96, 0x67, 0x78, + 0x25, 0xdd, 0xf7, 0x39, 0x88, 0xcf, 0xc7, 0x98, 0x25, 0xdf, 0x56, 0x6d, 0xc5, 0x43, + 0x0b, 0x9a, 0x04, 0x5a, 0x12, 0x00, 0x13, 0x01, 0x00, 0x00, 0x2e, 0x00, 0x33, 0x00, + 0x24, 0x00, 0x1d, 0x00, 0x20, 0x9d, 0x3c, 0x94, 0x0d, 0x89, 0x69, 0x0b, 0x84, 0xd0, + 0x8a, 0x60, 0x99, 0x3c, 0x14, 0x4e, 0xca, 0x68, 0x4d, 0x10, 0x81, 0x28, 0x7c, 0x83, + 0x4d, 0x53, 0x11, 0xbc, 0xf3, 0x2b, 0xb9, 0xda, 0x1a, 0x00, 0x2b, 0x00, 0x02, 0x03, + 0x04, + ]; + let mut server_header = [ + 0xd1, 0x6b, 0x33, 0x43, 0xcf, 0x00, 0x08, 0xf0, 0x67, 0xa5, 0x50, 0x2a, 0x42, 0x62, + 0xb5, 0x00, 0x40, 0x75, 0x00, 0x01, + ]; + let tag = server + .local + .packet + .encrypt_in_place(1, &server_header, &mut server_payload) + .unwrap(); + let (first, rest) = server_header.split_at_mut(1); + let rest_len = rest.len(); + server + .local + .header + .encrypt_in_place( + &server_payload[2..18], + &mut first[0], + &mut rest[rest_len - 2..], + ) + .unwrap(); + let mut server_packet = server_header.to_vec(); + server_packet.extend(server_payload); + server_packet.extend(tag.as_ref()); + let expected_server_packet = [ + 0xdc, 0x6b, 0x33, 0x43, 0xcf, 0x00, 0x08, 0xf0, 0x67, 0xa5, 0x50, 0x2a, 0x42, 0x62, + 0xb5, 0x00, 0x40, 0x75, 0xd9, 0x2f, 0xaa, 0xf1, 0x6f, 0x05, 0xd8, 0xa4, 0x39, 0x8c, + 0x47, 0x08, 0x96, 0x98, 0xba, 0xee, 0xa2, 0x6b, 0x91, 0xeb, 0x76, 0x1d, 0x9b, 0x89, + 0x23, 0x7b, 0xbf, 0x87, 0x26, 0x30, 0x17, 0x91, 0x53, 0x58, 0x23, 0x00, 0x35, 0xf7, + 0xfd, 0x39, 0x45, 0xd8, 0x89, 0x65, 0xcf, 0x17, 0xf9, 0xaf, 0x6e, 0x16, 0x88, 0x6c, + 0x61, 0xbf, 0xc7, 0x03, 0x10, 0x6f, 0xba, 0xf3, 0xcb, 0x4c, 0xfa, 0x52, 0x38, 0x2d, + 0xd1, 0x6a, 0x39, 0x3e, 0x42, 0x75, 0x75, 0x07, 0x69, 0x80, 0x75, 0xb2, 0xc9, 0x84, + 0xc7, 0x07, 0xf0, 0xa0, 0x81, 0x2d, 0x8c, 0xd5, 0xa6, 0x88, 0x1e, 0xaf, 0x21, 0xce, + 0xda, 0x98, 0xf4, 0xbd, 0x23, 0xf6, 0xfe, 0x1a, 0x3e, 0x2c, 0x43, 0xed, 0xd9, 0xce, + 0x7c, 0xa8, 0x4b, 0xed, 0x85, 0x21, 0xe2, 0xe1, 0x40, + ]; + assert_eq!(server_packet[..], expected_server_packet[..]); + } + + // This test is based on picoquic's output for `multipath_aead_test` in + // `picoquictest/multipath_test.c`. + // + // See + #[test] + fn test_multipath_aead_basic() { + const SECRET: &[u8; 32] = &[ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 35, 26, 27, 28, 29, 30, 31, + ]; + const PN: u64 = 12345; + const PATH_ID: u32 = 2; + const PAYLOAD: &[u8] = b"The quick brown fox jumps over the lazy dog"; + const HEADER: &[u8] = b"This is a test"; + + const EXPECTED: &[u8] = &[ + 123, 139, 232, 52, 136, 25, 201, 143, 250, 89, 87, 39, 37, 63, 0, 210, 220, 227, 186, + 140, 183, 251, 13, 203, 6, 116, 204, 100, 166, 64, 43, 185, 174, 85, 212, 163, 242, + 141, 24, 166, 62, 228, 187, 137, 248, 31, 152, 126, 240, 151, 79, 51, 253, 130, 43, + 114, 173, 234, 254, + ]; + + let secret = OkmBlock::new(SECRET); + let builder = KeyBuilder::new( + &secret, + Version::V1, + TLS13_AES_128_GCM_SHA256_INTERNAL + .quic + .unwrap(), + TLS13_AES_128_GCM_SHA256_INTERNAL.hkdf_provider, + ); + + let packet = builder.packet_key(); + let mut buf = PAYLOAD.to_vec(); + let tag = packet + .encrypt_in_place_for_path(PATH_ID, PN, HEADER, &mut buf) + .unwrap(); + buf.extend_from_slice(tag.as_ref()); + + assert_eq!(buf.as_slice(), EXPECTED); + } + + // This test is based on `multipath_aead_test` in `picoquictest/multipath_test.c` + // + // See + #[test] + fn test_multipath_aead_roundtrip() { + const SECRET: &[u8; 32] = &[ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 35, 26, 27, 28, 29, 30, 31, + ]; + const PAYLOAD: &[u8] = b"The quick brown fox jumps over the lazy dog"; + const HEADER: &[u8] = b"This is a test"; + const PN: u64 = 12345; + + const TEST_PATH_IDS: &[u32] = &[0, 1, 2, 0xaead]; + + let secret = OkmBlock::new(SECRET); + let builder = KeyBuilder::new( + &secret, + Version::V1, + TLS13_AES_128_GCM_SHA256_INTERNAL + .quic + .unwrap(), + TLS13_AES_128_GCM_SHA256_INTERNAL.hkdf_provider, + ); + let packet = builder.packet_key(); + + for &path_id in TEST_PATH_IDS { + let mut buf = PAYLOAD.to_vec(); + let tag = packet + .encrypt_in_place_for_path(path_id, PN, HEADER, &mut buf) + .unwrap(); + buf.extend_from_slice(tag.as_ref()); + let decrypted = packet + .decrypt_in_place_for_path(path_id, PN, HEADER, &mut buf) + .unwrap(); + assert_eq!(decrypted, PAYLOAD); + } + } +} diff --git a/http/vendor/rustls/src/crypto/ring/sign.rs b/http/vendor/rustls/src/crypto/ring/sign.rs new file mode 100644 index 0000000..ad31827 --- /dev/null +++ b/http/vendor/rustls/src/crypto/ring/sign.rs @@ -0,0 +1,822 @@ +#![allow(clippy::duplicate_mod)] + +use alloc::boxed::Box; +use alloc::string::ToString; +use alloc::vec::Vec; +use alloc::{format, vec}; +use core::fmt::{self, Debug, Formatter}; + +use pki_types::{PrivateKeyDer, PrivatePkcs8KeyDer, SubjectPublicKeyInfoDer, alg_id}; + +use super::ring_like::rand::{SecureRandom, SystemRandom}; +use super::ring_like::signature::{self, EcdsaKeyPair, Ed25519KeyPair, KeyPair, RsaKeyPair}; +use crate::crypto::signer::{Signer, SigningKey, public_key_to_spki}; +use crate::enums::{SignatureAlgorithm, SignatureScheme}; +use crate::error::Error; +use crate::sync::Arc; +use crate::x509::{wrap_concat_in_sequence, wrap_in_octet_string}; + +/// Parse `der` as any supported key encoding/type, returning +/// the first which works. +pub fn any_supported_type(der: &PrivateKeyDer<'_>) -> Result, Error> { + if let Ok(rsa) = RsaSigningKey::new(der) { + return Ok(Arc::new(rsa)); + } + + if let Ok(ecdsa) = any_ecdsa_type(der) { + return Ok(ecdsa); + } + + if let PrivateKeyDer::Pkcs8(pkcs8) = der { + if let Ok(eddsa) = any_eddsa_type(pkcs8) { + return Ok(eddsa); + } + } + + Err(Error::General( + "failed to parse private key as RSA, ECDSA, or EdDSA".into(), + )) +} + +/// Parse `der` as any ECDSA key type, returning the first which works. +/// +/// Both SEC1 (PEM section starting with 'BEGIN EC PRIVATE KEY') and PKCS8 +/// (PEM section starting with 'BEGIN PRIVATE KEY') encodings are supported. +pub fn any_ecdsa_type(der: &PrivateKeyDer<'_>) -> Result, Error> { + if let Ok(ecdsa_p256) = EcdsaSigningKey::new( + der, + SignatureScheme::ECDSA_NISTP256_SHA256, + &signature::ECDSA_P256_SHA256_ASN1_SIGNING, + ) { + return Ok(Arc::new(ecdsa_p256)); + } + + if let Ok(ecdsa_p384) = EcdsaSigningKey::new( + der, + SignatureScheme::ECDSA_NISTP384_SHA384, + &signature::ECDSA_P384_SHA384_ASN1_SIGNING, + ) { + return Ok(Arc::new(ecdsa_p384)); + } + + Err(Error::General( + "failed to parse ECDSA private key as PKCS#8 or SEC1".into(), + )) +} + +/// Parse `der` as any EdDSA key type, returning the first which works. +/// +/// Note that, at the time of writing, Ed25519 does not have wide support +/// in browsers. It is also not supported by the WebPKI, because the +/// CA/Browser Forum Baseline Requirements do not support it for publicly +/// trusted certificates. +pub fn any_eddsa_type(der: &PrivatePkcs8KeyDer<'_>) -> Result, Error> { + // TODO: Add support for Ed448 + Ok(Arc::new(Ed25519SigningKey::new( + der, + SignatureScheme::ED25519, + )?)) +} + +/// A `SigningKey` for RSA-PKCS1 or RSA-PSS. +/// +/// This is used by the test suite, so it must be `pub`, but it isn't part of +/// the public, stable, API. +#[doc(hidden)] +pub struct RsaSigningKey { + key: Arc, +} + +static ALL_RSA_SCHEMES: &[SignatureScheme] = &[ + SignatureScheme::RSA_PSS_SHA512, + SignatureScheme::RSA_PSS_SHA384, + SignatureScheme::RSA_PSS_SHA256, + SignatureScheme::RSA_PKCS1_SHA512, + SignatureScheme::RSA_PKCS1_SHA384, + SignatureScheme::RSA_PKCS1_SHA256, +]; + +impl RsaSigningKey { + /// Make a new `RsaSigningKey` from a DER encoding, in either + /// PKCS#1 or PKCS#8 format. + pub fn new(der: &PrivateKeyDer<'_>) -> Result { + let key_pair = match der { + PrivateKeyDer::Pkcs1(pkcs1) => RsaKeyPair::from_der(pkcs1.secret_pkcs1_der()), + PrivateKeyDer::Pkcs8(pkcs8) => RsaKeyPair::from_pkcs8(pkcs8.secret_pkcs8_der()), + _ => { + return Err(Error::General( + "failed to parse RSA private key as either PKCS#1 or PKCS#8".into(), + )); + } + } + .map_err(|key_rejected| { + Error::General(format!("failed to parse RSA private key: {key_rejected}")) + })?; + + Ok(Self { + key: Arc::new(key_pair), + }) + } +} + +impl SigningKey for RsaSigningKey { + fn choose_scheme(&self, offered: &[SignatureScheme]) -> Option> { + ALL_RSA_SCHEMES + .iter() + .find(|scheme| offered.contains(scheme)) + .map(|scheme| RsaSigner::new(self.key.clone(), *scheme)) + } + + fn public_key(&self) -> Option> { + Some(public_key_to_spki( + &alg_id::RSA_ENCRYPTION, + self.key.public_key(), + )) + } + + fn algorithm(&self) -> SignatureAlgorithm { + SignatureAlgorithm::RSA + } +} + +impl Debug for RsaSigningKey { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.debug_struct("RsaSigningKey") + .field("algorithm", &self.algorithm()) + .finish() + } +} + +struct RsaSigner { + key: Arc, + scheme: SignatureScheme, + encoding: &'static dyn signature::RsaEncoding, +} + +impl RsaSigner { + fn new(key: Arc, scheme: SignatureScheme) -> Box { + let encoding: &dyn signature::RsaEncoding = match scheme { + SignatureScheme::RSA_PKCS1_SHA256 => &signature::RSA_PKCS1_SHA256, + SignatureScheme::RSA_PKCS1_SHA384 => &signature::RSA_PKCS1_SHA384, + SignatureScheme::RSA_PKCS1_SHA512 => &signature::RSA_PKCS1_SHA512, + SignatureScheme::RSA_PSS_SHA256 => &signature::RSA_PSS_SHA256, + SignatureScheme::RSA_PSS_SHA384 => &signature::RSA_PSS_SHA384, + SignatureScheme::RSA_PSS_SHA512 => &signature::RSA_PSS_SHA512, + _ => unreachable!(), + }; + + Box::new(Self { + key, + scheme, + encoding, + }) + } +} + +impl Signer for RsaSigner { + fn sign(&self, message: &[u8]) -> Result, Error> { + let mut sig = vec![0; self.key.public().modulus_len()]; + + let rng = SystemRandom::new(); + self.key + .sign(self.encoding, &rng, message, &mut sig) + .map(|_| sig) + .map_err(|_| Error::General("signing failed".to_string())) + } + + fn scheme(&self) -> SignatureScheme { + self.scheme + } +} + +impl Debug for RsaSigner { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.debug_struct("RsaSigner") + .field("scheme", &self.scheme) + .finish() + } +} + +/// A SigningKey that uses exactly one TLS-level SignatureScheme +/// and one ring-level signature::SigningAlgorithm. +/// +/// Compare this to RsaSigningKey, which for a particular key is +/// willing to sign with several algorithms. This is quite poor +/// cryptography practice, but is necessary because a given RSA key +/// is expected to work in TLS1.2 (PKCS#1 signatures) and TLS1.3 +/// (PSS signatures) -- nobody is willing to obtain certificates for +/// different protocol versions. +/// +/// Currently this is only implemented for ECDSA keys. +struct EcdsaSigningKey { + key: Arc, + scheme: SignatureScheme, +} + +impl EcdsaSigningKey { + /// Make a new `ECDSASigningKey` from a DER encoding in PKCS#8 or SEC1 + /// format, expecting a key usable with precisely the given signature + /// scheme. + fn new( + der: &PrivateKeyDer<'_>, + scheme: SignatureScheme, + sigalg: &'static signature::EcdsaSigningAlgorithm, + ) -> Result { + let rng = SystemRandom::new(); + let key_pair = match der { + PrivateKeyDer::Sec1(sec1) => { + Self::convert_sec1_to_pkcs8(scheme, sigalg, sec1.secret_sec1_der(), &rng)? + } + PrivateKeyDer::Pkcs8(pkcs8) => { + EcdsaKeyPair::from_pkcs8(sigalg, pkcs8.secret_pkcs8_der(), &rng).map_err(|_| ())? + } + _ => return Err(()), + }; + + Ok(Self { + key: Arc::new(key_pair), + scheme, + }) + } + + /// Convert a SEC1 encoding to PKCS8, and ask ring to parse it. This + /// can be removed once + /// (or equivalent) is landed. + fn convert_sec1_to_pkcs8( + scheme: SignatureScheme, + sigalg: &'static signature::EcdsaSigningAlgorithm, + maybe_sec1_der: &[u8], + rng: &dyn SecureRandom, + ) -> Result { + let pkcs8_prefix = match scheme { + SignatureScheme::ECDSA_NISTP256_SHA256 => &PKCS8_PREFIX_ECDSA_NISTP256, + SignatureScheme::ECDSA_NISTP384_SHA384 => &PKCS8_PREFIX_ECDSA_NISTP384, + _ => unreachable!(), // all callers are in this file + }; + + let sec1_wrap = wrap_in_octet_string(maybe_sec1_der); + let pkcs8 = wrap_concat_in_sequence(pkcs8_prefix, &sec1_wrap); + + EcdsaKeyPair::from_pkcs8(sigalg, &pkcs8, rng).map_err(|_| ()) + } +} + +// This is (line-by-line): +// - INTEGER Version = 0 +// - SEQUENCE (privateKeyAlgorithm) +// - id-ecPublicKey OID +// - prime256v1 OID +const PKCS8_PREFIX_ECDSA_NISTP256: &[u8] = b"\x02\x01\x00\ + \x30\x13\ + \x06\x07\x2a\x86\x48\xce\x3d\x02\x01\ + \x06\x08\x2a\x86\x48\xce\x3d\x03\x01\x07"; + +// This is (line-by-line): +// - INTEGER Version = 0 +// - SEQUENCE (privateKeyAlgorithm) +// - id-ecPublicKey OID +// - secp384r1 OID +const PKCS8_PREFIX_ECDSA_NISTP384: &[u8] = b"\x02\x01\x00\ + \x30\x10\ + \x06\x07\x2a\x86\x48\xce\x3d\x02\x01\ + \x06\x05\x2b\x81\x04\x00\x22"; + +impl SigningKey for EcdsaSigningKey { + fn choose_scheme(&self, offered: &[SignatureScheme]) -> Option> { + if offered.contains(&self.scheme) { + Some(Box::new(EcdsaSigner { + key: self.key.clone(), + scheme: self.scheme, + })) + } else { + None + } + } + + fn public_key(&self) -> Option> { + let id = match self.scheme { + SignatureScheme::ECDSA_NISTP256_SHA256 => alg_id::ECDSA_P256, + SignatureScheme::ECDSA_NISTP384_SHA384 => alg_id::ECDSA_P384, + _ => unreachable!(), + }; + + Some(public_key_to_spki(&id, self.key.public_key())) + } + + fn algorithm(&self) -> SignatureAlgorithm { + self.scheme.algorithm() + } +} + +impl Debug for EcdsaSigningKey { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.debug_struct("EcdsaSigningKey") + .field("algorithm", &self.algorithm()) + .finish() + } +} + +struct EcdsaSigner { + key: Arc, + scheme: SignatureScheme, +} + +impl Signer for EcdsaSigner { + fn sign(&self, message: &[u8]) -> Result, Error> { + let rng = SystemRandom::new(); + self.key + .sign(&rng, message) + .map_err(|_| Error::General("signing failed".into())) + .map(|sig| sig.as_ref().into()) + } + + fn scheme(&self) -> SignatureScheme { + self.scheme + } +} + +impl Debug for EcdsaSigner { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.debug_struct("EcdsaSigner") + .field("scheme", &self.scheme) + .finish() + } +} + +/// A SigningKey that uses exactly one TLS-level SignatureScheme +/// and one ring-level signature::SigningAlgorithm. +/// +/// Compare this to RsaSigningKey, which for a particular key is +/// willing to sign with several algorithms. This is quite poor +/// cryptography practice, but is necessary because a given RSA key +/// is expected to work in TLS1.2 (PKCS#1 signatures) and TLS1.3 +/// (PSS signatures) -- nobody is willing to obtain certificates for +/// different protocol versions. +/// +/// Currently this is only implemented for Ed25519 keys. +struct Ed25519SigningKey { + key: Arc, + scheme: SignatureScheme, +} + +impl Ed25519SigningKey { + /// Make a new `Ed25519SigningKey` from a DER encoding in PKCS#8 format, + /// expecting a key usable with precisely the given signature scheme. + fn new(der: &PrivatePkcs8KeyDer<'_>, scheme: SignatureScheme) -> Result { + match Ed25519KeyPair::from_pkcs8_maybe_unchecked(der.secret_pkcs8_der()) { + Ok(key_pair) => Ok(Self { + key: Arc::new(key_pair), + scheme, + }), + Err(e) => Err(Error::General(format!( + "failed to parse Ed25519 private key: {e}" + ))), + } + } +} + +impl SigningKey for Ed25519SigningKey { + fn choose_scheme(&self, offered: &[SignatureScheme]) -> Option> { + if offered.contains(&self.scheme) { + Some(Box::new(Ed25519Signer { + key: self.key.clone(), + scheme: self.scheme, + })) + } else { + None + } + } + + fn public_key(&self) -> Option> { + Some(public_key_to_spki(&alg_id::ED25519, self.key.public_key())) + } + + fn algorithm(&self) -> SignatureAlgorithm { + self.scheme.algorithm() + } +} + +impl Debug for Ed25519SigningKey { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.debug_struct("Ed25519SigningKey") + .field("algorithm", &self.algorithm()) + .finish() + } +} + +struct Ed25519Signer { + key: Arc, + scheme: SignatureScheme, +} + +impl Signer for Ed25519Signer { + fn sign(&self, message: &[u8]) -> Result, Error> { + Ok(self.key.sign(message).as_ref().into()) + } + + fn scheme(&self) -> SignatureScheme { + self.scheme + } +} + +impl Debug for Ed25519Signer { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.debug_struct("Ed25519Signer") + .field("scheme", &self.scheme) + .finish() + } +} + +#[cfg(test)] +mod tests { + use alloc::format; + + use pki_types::{PrivatePkcs1KeyDer, PrivateSec1KeyDer}; + + use super::*; + + #[test] + fn can_load_ecdsa_nistp256_pkcs8() { + let key = + PrivatePkcs8KeyDer::from(&include_bytes!("../../testdata/nistp256key.pkcs8.der")[..]); + assert!(any_eddsa_type(&key).is_err()); + let key = PrivateKeyDer::Pkcs8(key); + assert!(any_supported_type(&key).is_ok()); + assert!(any_ecdsa_type(&key).is_ok()); + } + + #[test] + fn can_load_ecdsa_nistp256_sec1() { + let key = PrivateKeyDer::Sec1(PrivateSec1KeyDer::from( + &include_bytes!("../../testdata/nistp256key.der")[..], + )); + assert!(any_supported_type(&key).is_ok()); + assert!(any_ecdsa_type(&key).is_ok()); + } + + #[test] + fn can_sign_ecdsa_nistp256() { + let key = PrivateKeyDer::Sec1(PrivateSec1KeyDer::from( + &include_bytes!("../../testdata/nistp256key.der")[..], + )); + + let k = any_supported_type(&key).unwrap(); + assert_eq!(format!("{k:?}"), "EcdsaSigningKey { algorithm: ECDSA }"); + assert_eq!(k.algorithm(), SignatureAlgorithm::ECDSA); + + assert!( + k.choose_scheme(&[SignatureScheme::RSA_PKCS1_SHA256]) + .is_none() + ); + assert!( + k.choose_scheme(&[SignatureScheme::ECDSA_NISTP384_SHA384]) + .is_none() + ); + let s = k + .choose_scheme(&[SignatureScheme::ECDSA_NISTP256_SHA256]) + .unwrap(); + assert_eq!( + format!("{s:?}"), + "EcdsaSigner { scheme: ECDSA_NISTP256_SHA256 }" + ); + assert_eq!(s.scheme(), SignatureScheme::ECDSA_NISTP256_SHA256); + // nb. signature is variable length and asn.1-encoded + assert!( + s.sign(b"hello") + .unwrap() + .starts_with(&[0x30]) + ); + } + + #[test] + fn can_load_ecdsa_nistp384_pkcs8() { + let key = + PrivatePkcs8KeyDer::from(&include_bytes!("../../testdata/nistp384key.pkcs8.der")[..]); + assert!(any_eddsa_type(&key).is_err()); + let key = PrivateKeyDer::Pkcs8(key); + assert!(any_supported_type(&key).is_ok()); + assert!(any_ecdsa_type(&key).is_ok()); + } + + #[test] + fn can_load_ecdsa_nistp384_sec1() { + let key = PrivateKeyDer::Sec1(PrivateSec1KeyDer::from( + &include_bytes!("../../testdata/nistp384key.der")[..], + )); + assert!(any_supported_type(&key).is_ok()); + assert!(any_ecdsa_type(&key).is_ok()); + } + + #[test] + fn can_sign_ecdsa_nistp384() { + let key = PrivateKeyDer::Sec1(PrivateSec1KeyDer::from( + &include_bytes!("../../testdata/nistp384key.der")[..], + )); + + let k = any_supported_type(&key).unwrap(); + assert_eq!(format!("{k:?}"), "EcdsaSigningKey { algorithm: ECDSA }"); + assert_eq!(k.algorithm(), SignatureAlgorithm::ECDSA); + + assert!( + k.choose_scheme(&[SignatureScheme::RSA_PKCS1_SHA256]) + .is_none() + ); + assert!( + k.choose_scheme(&[SignatureScheme::ECDSA_NISTP256_SHA256]) + .is_none() + ); + let s = k + .choose_scheme(&[SignatureScheme::ECDSA_NISTP384_SHA384]) + .unwrap(); + assert_eq!( + format!("{s:?}"), + "EcdsaSigner { scheme: ECDSA_NISTP384_SHA384 }" + ); + assert_eq!(s.scheme(), SignatureScheme::ECDSA_NISTP384_SHA384); + // nb. signature is variable length and asn.1-encoded + assert!( + s.sign(b"hello") + .unwrap() + .starts_with(&[0x30]) + ); + } + + #[test] + fn can_load_eddsa_pkcs8() { + let key = PrivatePkcs8KeyDer::from(&include_bytes!("../../testdata/eddsakey.der")[..]); + assert!(any_eddsa_type(&key).is_ok()); + let key = PrivateKeyDer::Pkcs8(key); + assert!(any_supported_type(&key).is_ok()); + assert!(any_ecdsa_type(&key).is_err()); + } + + #[test] + fn can_sign_eddsa() { + let key = PrivatePkcs8KeyDer::from(&include_bytes!("../../testdata/eddsakey.der")[..]); + + let k = any_eddsa_type(&key).unwrap(); + assert_eq!(format!("{k:?}"), "Ed25519SigningKey { algorithm: ED25519 }"); + assert_eq!(k.algorithm(), SignatureAlgorithm::ED25519); + + assert!( + k.choose_scheme(&[SignatureScheme::RSA_PKCS1_SHA256]) + .is_none() + ); + assert!( + k.choose_scheme(&[SignatureScheme::ECDSA_NISTP256_SHA256]) + .is_none() + ); + let s = k + .choose_scheme(&[SignatureScheme::ED25519]) + .unwrap(); + assert_eq!(format!("{s:?}"), "Ed25519Signer { scheme: ED25519 }"); + assert_eq!(s.scheme(), SignatureScheme::ED25519); + assert_eq!(s.sign(b"hello").unwrap().len(), 64); + } + + #[test] + fn can_load_rsa2048_pkcs8() { + let key = + PrivatePkcs8KeyDer::from(&include_bytes!("../../testdata/rsa2048key.pkcs8.der")[..]); + assert!(any_eddsa_type(&key).is_err()); + let key = PrivateKeyDer::Pkcs8(key); + assert!(any_supported_type(&key).is_ok()); + assert!(any_ecdsa_type(&key).is_err()); + } + + #[test] + fn can_load_rsa2048_pkcs1() { + let key = PrivateKeyDer::Pkcs1(PrivatePkcs1KeyDer::from( + &include_bytes!("../../testdata/rsa2048key.pkcs1.der")[..], + )); + assert!(any_supported_type(&key).is_ok()); + assert!(any_ecdsa_type(&key).is_err()); + } + + #[test] + fn can_sign_rsa2048() { + let key = PrivateKeyDer::Pkcs8(PrivatePkcs8KeyDer::from( + &include_bytes!("../../testdata/rsa2048key.pkcs8.der")[..], + )); + + let k = any_supported_type(&key).unwrap(); + assert_eq!(format!("{k:?}"), "RsaSigningKey { algorithm: RSA }"); + assert_eq!(k.algorithm(), SignatureAlgorithm::RSA); + + assert!( + k.choose_scheme(&[SignatureScheme::ECDSA_NISTP256_SHA256]) + .is_none() + ); + assert!( + k.choose_scheme(&[SignatureScheme::ED25519]) + .is_none() + ); + + let s = k + .choose_scheme(&[SignatureScheme::RSA_PSS_SHA256]) + .unwrap(); + assert_eq!(format!("{s:?}"), "RsaSigner { scheme: RSA_PSS_SHA256 }"); + assert_eq!(s.scheme(), SignatureScheme::RSA_PSS_SHA256); + assert_eq!(s.sign(b"hello").unwrap().len(), 256); + + for scheme in &[ + SignatureScheme::RSA_PKCS1_SHA256, + SignatureScheme::RSA_PKCS1_SHA384, + SignatureScheme::RSA_PKCS1_SHA512, + SignatureScheme::RSA_PSS_SHA256, + SignatureScheme::RSA_PSS_SHA384, + SignatureScheme::RSA_PSS_SHA512, + ] { + k.choose_scheme(&[*scheme]).unwrap(); + } + } + + #[test] + fn cannot_load_invalid_pkcs8_encoding() { + let key = PrivateKeyDer::Pkcs8(PrivatePkcs8KeyDer::from(&b"invalid"[..])); + assert_eq!( + any_supported_type(&key).err(), + Some(Error::General( + "failed to parse private key as RSA, ECDSA, or EdDSA".into() + )) + ); + assert_eq!( + any_ecdsa_type(&key).err(), + Some(Error::General( + "failed to parse ECDSA private key as PKCS#8 or SEC1".into() + )) + ); + assert_eq!( + RsaSigningKey::new(&key).err(), + Some(Error::General( + "failed to parse RSA private key: InvalidEncoding".into() + )) + ); + } +} + +#[cfg(bench)] +mod benchmarks { + use super::{PrivateKeyDer, PrivatePkcs8KeyDer, SignatureScheme}; + + #[bench] + fn bench_rsa2048_pkcs1_sha256(b: &mut test::Bencher) { + let key = PrivateKeyDer::Pkcs8(PrivatePkcs8KeyDer::from( + &include_bytes!("../../testdata/rsa2048key.pkcs8.der")[..], + )); + let sk = super::any_supported_type(&key).unwrap(); + let signer = sk + .choose_scheme(&[SignatureScheme::RSA_PKCS1_SHA256]) + .unwrap(); + + b.iter(|| { + test::black_box( + signer + .sign(SAMPLE_TLS13_MESSAGE) + .unwrap(), + ); + }); + } + + #[bench] + fn bench_rsa2048_pss_sha256(b: &mut test::Bencher) { + let key = PrivateKeyDer::Pkcs8(PrivatePkcs8KeyDer::from( + &include_bytes!("../../testdata/rsa2048key.pkcs8.der")[..], + )); + let sk = super::any_supported_type(&key).unwrap(); + let signer = sk + .choose_scheme(&[SignatureScheme::RSA_PSS_SHA256]) + .unwrap(); + + b.iter(|| { + test::black_box( + signer + .sign(SAMPLE_TLS13_MESSAGE) + .unwrap(), + ); + }); + } + + #[bench] + fn bench_eddsa(b: &mut test::Bencher) { + let key = PrivateKeyDer::Pkcs8(PrivatePkcs8KeyDer::from( + &include_bytes!("../../testdata/eddsakey.der")[..], + )); + let sk = super::any_supported_type(&key).unwrap(); + let signer = sk + .choose_scheme(&[SignatureScheme::ED25519]) + .unwrap(); + + b.iter(|| { + test::black_box( + signer + .sign(SAMPLE_TLS13_MESSAGE) + .unwrap(), + ); + }); + } + + #[bench] + fn bench_ecdsa_p256_sha256(b: &mut test::Bencher) { + let key = PrivateKeyDer::Pkcs8(PrivatePkcs8KeyDer::from( + &include_bytes!("../../testdata/nistp256key.pkcs8.der")[..], + )); + let sk = super::any_supported_type(&key).unwrap(); + let signer = sk + .choose_scheme(&[SignatureScheme::ECDSA_NISTP256_SHA256]) + .unwrap(); + + b.iter(|| { + test::black_box( + signer + .sign(SAMPLE_TLS13_MESSAGE) + .unwrap(), + ); + }); + } + + #[bench] + fn bench_ecdsa_p384_sha384(b: &mut test::Bencher) { + let key = PrivateKeyDer::Pkcs8(PrivatePkcs8KeyDer::from( + &include_bytes!("../../testdata/nistp384key.pkcs8.der")[..], + )); + let sk = super::any_supported_type(&key).unwrap(); + let signer = sk + .choose_scheme(&[SignatureScheme::ECDSA_NISTP384_SHA384]) + .unwrap(); + + b.iter(|| { + test::black_box( + signer + .sign(SAMPLE_TLS13_MESSAGE) + .unwrap(), + ); + }); + } + + #[bench] + fn bench_load_and_validate_rsa2048(b: &mut test::Bencher) { + let key = PrivateKeyDer::Pkcs8(PrivatePkcs8KeyDer::from( + &include_bytes!("../../testdata/rsa2048key.pkcs8.der")[..], + )); + + b.iter(|| { + test::black_box(super::any_supported_type(&key).unwrap()); + }); + } + + #[bench] + fn bench_load_and_validate_rsa4096(b: &mut test::Bencher) { + let key = PrivateKeyDer::Pkcs8(PrivatePkcs8KeyDer::from( + &include_bytes!("../../testdata/rsa4096key.pkcs8.der")[..], + )); + + b.iter(|| { + test::black_box(super::any_supported_type(&key).unwrap()); + }); + } + + #[bench] + fn bench_load_and_validate_p256(b: &mut test::Bencher) { + let key = PrivateKeyDer::Pkcs8(PrivatePkcs8KeyDer::from( + &include_bytes!("../../testdata/nistp256key.pkcs8.der")[..], + )); + + b.iter(|| { + test::black_box(super::any_ecdsa_type(&key).unwrap()); + }); + } + + #[bench] + fn bench_load_and_validate_p384(b: &mut test::Bencher) { + let key = PrivateKeyDer::Pkcs8(PrivatePkcs8KeyDer::from( + &include_bytes!("../../testdata/nistp384key.pkcs8.der")[..], + )); + + b.iter(|| { + test::black_box(super::any_ecdsa_type(&key).unwrap()); + }); + } + + #[bench] + fn bench_load_and_validate_eddsa(b: &mut test::Bencher) { + let key = PrivatePkcs8KeyDer::from(&include_bytes!("../../testdata/eddsakey.der")[..]); + + b.iter(|| { + test::black_box(super::any_eddsa_type(&key).unwrap()); + }); + } + + const SAMPLE_TLS13_MESSAGE: &[u8] = &[ + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x54, 0x4c, 0x53, 0x20, 0x31, 0x2e, 0x33, 0x2c, 0x20, 0x73, 0x65, + 0x72, 0x76, 0x65, 0x72, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, + 0x65, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x00, 0x04, 0xca, 0xc4, 0x48, 0x0e, 0x70, 0xf2, + 0x1b, 0xa9, 0x1c, 0x16, 0xca, 0x90, 0x48, 0xbe, 0x28, 0x2f, 0xc7, 0xf8, 0x9b, 0x87, 0x72, + 0x93, 0xda, 0x4d, 0x2f, 0x80, 0x80, 0x60, 0x1a, 0xd3, 0x08, 0xe2, 0xb7, 0x86, 0x14, 0x1b, + 0x54, 0xda, 0x9a, 0xc9, 0x6d, 0xe9, 0x66, 0xb4, 0x9f, 0xe2, 0x2c, + ]; +} diff --git a/http/vendor/rustls/src/crypto/ring/ticketer.rs b/http/vendor/rustls/src/crypto/ring/ticketer.rs new file mode 100644 index 0000000..45dcc27 --- /dev/null +++ b/http/vendor/rustls/src/crypto/ring/ticketer.rs @@ -0,0 +1,366 @@ +use alloc::boxed::Box; +use alloc::vec::Vec; +use core::fmt; +use core::fmt::{Debug, Formatter}; +use core::sync::atomic::{AtomicUsize, Ordering}; + +use subtle::ConstantTimeEq; + +use super::ring_like::aead; +use super::ring_like::rand::{SecureRandom, SystemRandom}; +use crate::error::Error; +#[cfg(debug_assertions)] +use crate::log::debug; +use crate::polyfill::try_split_at; +use crate::rand::GetRandomFailed; +use crate::server::ProducesTickets; +use crate::sync::Arc; + +/// A concrete, safe ticket creation mechanism. +pub struct Ticketer {} + +impl Ticketer { + /// Make the recommended `Ticketer`. This produces tickets + /// with a 12 hour life and randomly generated keys. + /// + /// The encryption mechanism used is Chacha20Poly1305. + #[cfg(feature = "std")] + pub fn new() -> Result, Error> { + Ok(Arc::new(crate::ticketer::TicketRotator::new( + 6 * 60 * 60, + make_ticket_generator, + )?)) + } +} + +fn make_ticket_generator() -> Result, GetRandomFailed> { + Ok(Box::new(AeadTicketer::new()?)) +} + +/// This is a `ProducesTickets` implementation which uses +/// any *ring* `aead::Algorithm` to encrypt and authentication +/// the ticket payload. It does not enforce any lifetime +/// constraint. +struct AeadTicketer { + alg: &'static aead::Algorithm, + key: aead::LessSafeKey, + key_name: [u8; 16], + lifetime: u32, + + /// Tracks the largest ciphertext produced by `encrypt`, and + /// uses it to early-reject `decrypt` queries that are too long. + /// + /// Accepting excessively long ciphertexts means a "Partitioning + /// Oracle Attack" (see ) + /// can be more efficient, though also note that these are thought + /// to be cryptographically hard if the key is full-entropy (as it + /// is here). + maximum_ciphertext_len: AtomicUsize, +} + +impl AeadTicketer { + fn new() -> Result { + let mut key = [0u8; 32]; + SystemRandom::new() + .fill(&mut key) + .map_err(|_| GetRandomFailed)?; + + let key = aead::UnboundKey::new(TICKETER_AEAD, &key).unwrap(); + + let mut key_name = [0u8; 16]; + SystemRandom::new() + .fill(&mut key_name) + .map_err(|_| GetRandomFailed)?; + + Ok(Self { + alg: TICKETER_AEAD, + key: aead::LessSafeKey::new(key), + key_name, + lifetime: 60 * 60 * 12, + maximum_ciphertext_len: AtomicUsize::new(0), + }) + } +} + +impl ProducesTickets for AeadTicketer { + fn enabled(&self) -> bool { + true + } + + fn lifetime(&self) -> u32 { + self.lifetime + } + + /// Encrypt `message` and return the ciphertext. + fn encrypt(&self, message: &[u8]) -> Option> { + // Random nonce, because a counter is a privacy leak. + let mut nonce_buf = [0u8; 12]; + SystemRandom::new() + .fill(&mut nonce_buf) + .ok()?; + let nonce = aead::Nonce::assume_unique_for_key(nonce_buf); + let aad = aead::Aad::from(self.key_name); + + // ciphertext structure is: + // key_name: [u8; 16] + // nonce: [u8; 12] + // message: [u8, _] + // tag: [u8; 16] + + let mut ciphertext = Vec::with_capacity( + self.key_name.len() + nonce_buf.len() + message.len() + self.key.algorithm().tag_len(), + ); + ciphertext.extend(self.key_name); + ciphertext.extend(nonce_buf); + ciphertext.extend(message); + let ciphertext = self + .key + .seal_in_place_separate_tag( + nonce, + aad, + &mut ciphertext[self.key_name.len() + nonce_buf.len()..], + ) + .map(|tag| { + ciphertext.extend(tag.as_ref()); + ciphertext + }) + .ok()?; + + self.maximum_ciphertext_len + .fetch_max(ciphertext.len(), Ordering::SeqCst); + Some(ciphertext) + } + + /// Decrypt `ciphertext` and recover the original message. + fn decrypt(&self, ciphertext: &[u8]) -> Option> { + if ciphertext.len() + > self + .maximum_ciphertext_len + .load(Ordering::SeqCst) + { + #[cfg(debug_assertions)] + debug!("rejected over-length ticket"); + return None; + } + + let (alleged_key_name, ciphertext) = try_split_at(ciphertext, self.key_name.len())?; + + let (nonce, ciphertext) = try_split_at(ciphertext, self.alg.nonce_len())?; + + // checking the key_name is the expected one, *and* then putting it into the + // additionally authenticated data is duplicative. this check quickly rejects + // tickets for a different ticketer (see `TicketSwitcher`), while including it + // in the AAD ensures it is authenticated independent of that check and that + // any attempted attack on the integrity such as [^1] must happen for each + // `key_label`, not over a population of potential keys. this approach + // is overall similar to [^2]. + // + // [^1]: https://eprint.iacr.org/2020/1491.pdf + // [^2]: "Authenticated Encryption with Key Identification", fig 6 + // + if ConstantTimeEq::ct_ne(&self.key_name[..], alleged_key_name).into() { + #[cfg(debug_assertions)] + debug!("rejected ticket with wrong ticket_name"); + return None; + } + + // This won't fail since `nonce` has the required length. + let nonce = aead::Nonce::try_assume_unique_for_key(nonce).ok()?; + + let mut out = Vec::from(ciphertext); + + let plain_len = self + .key + .open_in_place(nonce, aead::Aad::from(alleged_key_name), &mut out) + .ok()? + .len(); + out.truncate(plain_len); + + Some(out) + } +} + +impl Debug for AeadTicketer { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + // Note: we deliberately omit the key from the debug output. + f.debug_struct("AeadTicketer") + .field("alg", &self.alg) + .field("lifetime", &self.lifetime) + .finish() + } +} + +static TICKETER_AEAD: &aead::Algorithm = &aead::CHACHA20_POLY1305; + +#[cfg(test)] +mod tests { + use core::time::Duration; + + use pki_types::UnixTime; + + use super::*; + + #[test] + fn basic_pairwise_test() { + let t = Ticketer::new().unwrap(); + assert!(t.enabled()); + let cipher = t.encrypt(b"hello world").unwrap(); + let plain = t.decrypt(&cipher).unwrap(); + assert_eq!(plain, b"hello world"); + } + + #[test] + fn refuses_decrypt_before_encrypt() { + let t = Ticketer::new().unwrap(); + assert_eq!(t.decrypt(b"hello"), None); + } + + #[test] + fn refuses_decrypt_larger_than_largest_encryption() { + let t = Ticketer::new().unwrap(); + let mut cipher = t.encrypt(b"hello world").unwrap(); + assert_eq!(t.decrypt(&cipher), Some(b"hello world".to_vec())); + + // obviously this would never work anyway, but this + // and `cannot_decrypt_before_encrypt` exercise the + // first branch in `decrypt()` + cipher.push(0); + assert_eq!(t.decrypt(&cipher), None); + } + + #[test] + fn ticketrotator_switching_test() { + let t = Arc::new(crate::ticketer::TicketRotator::new(1, make_ticket_generator).unwrap()); + let now = UnixTime::now(); + let cipher1 = t.encrypt(b"ticket 1").unwrap(); + assert_eq!(t.decrypt(&cipher1).unwrap(), b"ticket 1"); + { + // Trigger new ticketer + t.maybe_roll(UnixTime::since_unix_epoch(Duration::from_secs( + now.as_secs() + 10, + ))); + } + let cipher2 = t.encrypt(b"ticket 2").unwrap(); + assert_eq!(t.decrypt(&cipher1).unwrap(), b"ticket 1"); + assert_eq!(t.decrypt(&cipher2).unwrap(), b"ticket 2"); + { + // Trigger new ticketer + t.maybe_roll(UnixTime::since_unix_epoch(Duration::from_secs( + now.as_secs() + 20, + ))); + } + let cipher3 = t.encrypt(b"ticket 3").unwrap(); + assert!(t.decrypt(&cipher1).is_none()); + assert_eq!(t.decrypt(&cipher2).unwrap(), b"ticket 2"); + assert_eq!(t.decrypt(&cipher3).unwrap(), b"ticket 3"); + } + + #[test] + fn ticketrotator_remains_usable_over_temporary_ticketer_creation_failure() { + let mut t = crate::ticketer::TicketRotator::new(1, make_ticket_generator).unwrap(); + let now = UnixTime::now(); + let cipher1 = t.encrypt(b"ticket 1").unwrap(); + assert_eq!(t.decrypt(&cipher1).unwrap(), b"ticket 1"); + t.generator = fail_generator; + { + // Failed new ticketer; this means we still need to + // rotate. + t.maybe_roll(UnixTime::since_unix_epoch(Duration::from_secs( + now.as_secs() + 10, + ))); + } + + // check post-failure encryption/decryption still works + let cipher2 = t.encrypt(b"ticket 2").unwrap(); + assert_eq!(t.decrypt(&cipher1).unwrap(), b"ticket 1"); + assert_eq!(t.decrypt(&cipher2).unwrap(), b"ticket 2"); + + // do the rotation for real + t.generator = make_ticket_generator; + { + t.maybe_roll(UnixTime::since_unix_epoch(Duration::from_secs( + now.as_secs() + 20, + ))); + } + let cipher3 = t.encrypt(b"ticket 3").unwrap(); + assert!(t.decrypt(&cipher1).is_some()); + assert_eq!(t.decrypt(&cipher2).unwrap(), b"ticket 2"); + assert_eq!(t.decrypt(&cipher3).unwrap(), b"ticket 3"); + } + + #[test] + fn ticketswitcher_switching_test() { + #[expect(deprecated)] + let t = Arc::new(crate::ticketer::TicketSwitcher::new(1, make_ticket_generator).unwrap()); + let now = UnixTime::now(); + let cipher1 = t.encrypt(b"ticket 1").unwrap(); + assert_eq!(t.decrypt(&cipher1).unwrap(), b"ticket 1"); + { + // Trigger new ticketer + t.maybe_roll(UnixTime::since_unix_epoch(Duration::from_secs( + now.as_secs() + 10, + ))); + } + let cipher2 = t.encrypt(b"ticket 2").unwrap(); + assert_eq!(t.decrypt(&cipher1).unwrap(), b"ticket 1"); + assert_eq!(t.decrypt(&cipher2).unwrap(), b"ticket 2"); + { + // Trigger new ticketer + t.maybe_roll(UnixTime::since_unix_epoch(Duration::from_secs( + now.as_secs() + 20, + ))); + } + let cipher3 = t.encrypt(b"ticket 3").unwrap(); + assert!(t.decrypt(&cipher1).is_none()); + assert_eq!(t.decrypt(&cipher2).unwrap(), b"ticket 2"); + assert_eq!(t.decrypt(&cipher3).unwrap(), b"ticket 3"); + } + + #[test] + fn ticketswitcher_recover_test() { + #[expect(deprecated)] + let mut t = crate::ticketer::TicketSwitcher::new(1, make_ticket_generator).unwrap(); + let now = UnixTime::now(); + let cipher1 = t.encrypt(b"ticket 1").unwrap(); + assert_eq!(t.decrypt(&cipher1).unwrap(), b"ticket 1"); + t.generator = fail_generator; + { + // Failed new ticketer + t.maybe_roll(UnixTime::since_unix_epoch(Duration::from_secs( + now.as_secs() + 10, + ))); + } + t.generator = make_ticket_generator; + let cipher2 = t.encrypt(b"ticket 2").unwrap(); + assert_eq!(t.decrypt(&cipher1).unwrap(), b"ticket 1"); + assert_eq!(t.decrypt(&cipher2).unwrap(), b"ticket 2"); + { + // recover + t.maybe_roll(UnixTime::since_unix_epoch(Duration::from_secs( + now.as_secs() + 20, + ))); + } + let cipher3 = t.encrypt(b"ticket 3").unwrap(); + assert!(t.decrypt(&cipher1).is_none()); + assert_eq!(t.decrypt(&cipher2).unwrap(), b"ticket 2"); + assert_eq!(t.decrypt(&cipher3).unwrap(), b"ticket 3"); + } + + #[test] + fn aeadticketer_is_debug_and_producestickets() { + use alloc::format; + + use super::*; + + let t = make_ticket_generator().unwrap(); + + let expect = format!("AeadTicketer {{ alg: {TICKETER_AEAD:?}, lifetime: 43200 }}"); + assert_eq!(format!("{t:?}"), expect); + assert!(t.enabled()); + assert_eq!(t.lifetime(), 43200); + } + + fn fail_generator() -> Result, GetRandomFailed> { + Err(GetRandomFailed) + } +} diff --git a/http/vendor/rustls/src/crypto/ring/tls12.rs b/http/vendor/rustls/src/crypto/ring/tls12.rs new file mode 100644 index 0000000..63dfae8 --- /dev/null +++ b/http/vendor/rustls/src/crypto/ring/tls12.rs @@ -0,0 +1,406 @@ +use alloc::boxed::Box; + +use super::ring_like::aead; +use crate::crypto::KeyExchangeAlgorithm; +use crate::crypto::cipher::{ + AeadKey, InboundOpaqueMessage, Iv, KeyBlockShape, MessageDecrypter, MessageEncrypter, + NONCE_LEN, Nonce, Tls12AeadAlgorithm, UnsupportedOperationError, make_tls12_aad, +}; +use crate::crypto::tls12::PrfUsingHmac; +use crate::enums::{CipherSuite, SignatureScheme}; +use crate::error::Error; +use crate::msgs::fragmenter::MAX_FRAGMENT_LEN; +use crate::msgs::message::{ + InboundPlainMessage, OutboundOpaqueMessage, OutboundPlainMessage, PrefixedPayload, +}; +use crate::suites::{CipherSuiteCommon, ConnectionTrafficSecrets, SupportedCipherSuite}; +use crate::tls12::Tls12CipherSuite; + +/// The TLS1.2 ciphersuite TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256. +pub static TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256: SupportedCipherSuite = + SupportedCipherSuite::Tls12(&Tls12CipherSuite { + common: CipherSuiteCommon { + suite: CipherSuite::TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256, + hash_provider: &super::hash::SHA256, + confidentiality_limit: u64::MAX, + }, + kx: KeyExchangeAlgorithm::ECDHE, + sign: TLS12_ECDSA_SCHEMES, + aead_alg: &ChaCha20Poly1305, + prf_provider: &PrfUsingHmac(&super::hmac::HMAC_SHA256), + }); + +/// The TLS1.2 ciphersuite TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 +pub static TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256: SupportedCipherSuite = + SupportedCipherSuite::Tls12(&Tls12CipherSuite { + common: CipherSuiteCommon { + suite: CipherSuite::TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, + hash_provider: &super::hash::SHA256, + confidentiality_limit: u64::MAX, + }, + kx: KeyExchangeAlgorithm::ECDHE, + sign: TLS12_RSA_SCHEMES, + aead_alg: &ChaCha20Poly1305, + prf_provider: &PrfUsingHmac(&super::hmac::HMAC_SHA256), + }); + +/// The TLS1.2 ciphersuite TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 +pub static TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256: SupportedCipherSuite = + SupportedCipherSuite::Tls12(&Tls12CipherSuite { + common: CipherSuiteCommon { + suite: CipherSuite::TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, + hash_provider: &super::hash::SHA256, + confidentiality_limit: 1 << 24, + }, + kx: KeyExchangeAlgorithm::ECDHE, + sign: TLS12_RSA_SCHEMES, + aead_alg: &AES128_GCM, + prf_provider: &PrfUsingHmac(&super::hmac::HMAC_SHA256), + }); + +/// The TLS1.2 ciphersuite TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 +pub static TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384: SupportedCipherSuite = + SupportedCipherSuite::Tls12(&Tls12CipherSuite { + common: CipherSuiteCommon { + suite: CipherSuite::TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, + hash_provider: &super::hash::SHA384, + confidentiality_limit: 1 << 24, + }, + kx: KeyExchangeAlgorithm::ECDHE, + sign: TLS12_RSA_SCHEMES, + aead_alg: &AES256_GCM, + prf_provider: &PrfUsingHmac(&super::hmac::HMAC_SHA384), + }); + +/// The TLS1.2 ciphersuite TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 +pub static TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256: SupportedCipherSuite = + SupportedCipherSuite::Tls12(&Tls12CipherSuite { + common: CipherSuiteCommon { + suite: CipherSuite::TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, + hash_provider: &super::hash::SHA256, + confidentiality_limit: 1 << 24, + }, + kx: KeyExchangeAlgorithm::ECDHE, + sign: TLS12_ECDSA_SCHEMES, + aead_alg: &AES128_GCM, + prf_provider: &PrfUsingHmac(&super::hmac::HMAC_SHA256), + }); + +/// The TLS1.2 ciphersuite TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 +pub static TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384: SupportedCipherSuite = + SupportedCipherSuite::Tls12(&Tls12CipherSuite { + common: CipherSuiteCommon { + suite: CipherSuite::TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, + hash_provider: &super::hash::SHA384, + confidentiality_limit: 1 << 24, + }, + kx: KeyExchangeAlgorithm::ECDHE, + sign: TLS12_ECDSA_SCHEMES, + aead_alg: &AES256_GCM, + prf_provider: &PrfUsingHmac(&super::hmac::HMAC_SHA384), + }); + +static TLS12_ECDSA_SCHEMES: &[SignatureScheme] = &[ + SignatureScheme::ED25519, + SignatureScheme::ECDSA_NISTP521_SHA512, + SignatureScheme::ECDSA_NISTP384_SHA384, + SignatureScheme::ECDSA_NISTP256_SHA256, +]; + +static TLS12_RSA_SCHEMES: &[SignatureScheme] = &[ + SignatureScheme::RSA_PSS_SHA512, + SignatureScheme::RSA_PSS_SHA384, + SignatureScheme::RSA_PSS_SHA256, + SignatureScheme::RSA_PKCS1_SHA512, + SignatureScheme::RSA_PKCS1_SHA384, + SignatureScheme::RSA_PKCS1_SHA256, +]; + +pub(crate) static AES128_GCM: GcmAlgorithm = GcmAlgorithm(&aead::AES_128_GCM); +pub(crate) static AES256_GCM: GcmAlgorithm = GcmAlgorithm(&aead::AES_256_GCM); + +pub(crate) struct GcmAlgorithm(&'static aead::Algorithm); + +impl Tls12AeadAlgorithm for GcmAlgorithm { + fn decrypter(&self, dec_key: AeadKey, dec_iv: &[u8]) -> Box { + let dec_key = + aead::LessSafeKey::new(aead::UnboundKey::new(self.0, dec_key.as_ref()).unwrap()); + + let mut ret = GcmMessageDecrypter { + dec_key, + dec_salt: [0u8; 4], + }; + + debug_assert_eq!(dec_iv.len(), 4); + ret.dec_salt.copy_from_slice(dec_iv); + Box::new(ret) + } + + fn encrypter( + &self, + enc_key: AeadKey, + write_iv: &[u8], + explicit: &[u8], + ) -> Box { + let enc_key = + aead::LessSafeKey::new(aead::UnboundKey::new(self.0, enc_key.as_ref()).unwrap()); + let iv = gcm_iv(write_iv, explicit); + Box::new(GcmMessageEncrypter { enc_key, iv }) + } + + fn key_block_shape(&self) -> KeyBlockShape { + KeyBlockShape { + enc_key_len: self.0.key_len(), + fixed_iv_len: 4, + explicit_nonce_len: 8, + } + } + + fn extract_keys( + &self, + key: AeadKey, + write_iv: &[u8], + explicit: &[u8], + ) -> Result { + let iv = gcm_iv(write_iv, explicit); + Ok(match self.0.key_len() { + 16 => ConnectionTrafficSecrets::Aes128Gcm { key, iv }, + 32 => ConnectionTrafficSecrets::Aes256Gcm { key, iv }, + _ => unreachable!(), + }) + } + + fn fips(&self) -> bool { + super::fips() + } +} + +pub(crate) struct ChaCha20Poly1305; + +impl Tls12AeadAlgorithm for ChaCha20Poly1305 { + fn decrypter(&self, dec_key: AeadKey, iv: &[u8]) -> Box { + let dec_key = aead::LessSafeKey::new( + aead::UnboundKey::new(&aead::CHACHA20_POLY1305, dec_key.as_ref()).unwrap(), + ); + Box::new(ChaCha20Poly1305MessageDecrypter { + dec_key, + dec_offset: Iv::copy(iv), + }) + } + + fn encrypter(&self, enc_key: AeadKey, enc_iv: &[u8], _: &[u8]) -> Box { + let enc_key = aead::LessSafeKey::new( + aead::UnboundKey::new(&aead::CHACHA20_POLY1305, enc_key.as_ref()).unwrap(), + ); + Box::new(ChaCha20Poly1305MessageEncrypter { + enc_key, + enc_offset: Iv::copy(enc_iv), + }) + } + + fn key_block_shape(&self) -> KeyBlockShape { + KeyBlockShape { + enc_key_len: 32, + fixed_iv_len: 12, + explicit_nonce_len: 0, + } + } + + fn extract_keys( + &self, + key: AeadKey, + iv: &[u8], + _explicit: &[u8], + ) -> Result { + // This should always be true because KeyBlockShape and the Iv nonce len are in agreement. + debug_assert_eq!(aead::NONCE_LEN, iv.len()); + Ok(ConnectionTrafficSecrets::Chacha20Poly1305 { + key, + iv: Iv::new(iv[..].try_into().unwrap()), + }) + } + + fn fips(&self) -> bool { + false // not fips approved + } +} + +/// A `MessageEncrypter` for AES-GCM AEAD ciphersuites. TLS 1.2 only. +struct GcmMessageEncrypter { + enc_key: aead::LessSafeKey, + iv: Iv, +} + +/// A `MessageDecrypter` for AES-GCM AEAD ciphersuites. TLS1.2 only. +struct GcmMessageDecrypter { + dec_key: aead::LessSafeKey, + dec_salt: [u8; 4], +} + +const GCM_EXPLICIT_NONCE_LEN: usize = 8; +const GCM_OVERHEAD: usize = GCM_EXPLICIT_NONCE_LEN + 16; + +impl MessageDecrypter for GcmMessageDecrypter { + fn decrypt<'a>( + &mut self, + mut msg: InboundOpaqueMessage<'a>, + seq: u64, + ) -> Result, Error> { + let payload = &msg.payload; + if payload.len() < GCM_OVERHEAD { + return Err(Error::DecryptError); + } + + let nonce = { + let mut nonce = [0u8; 12]; + nonce[..4].copy_from_slice(&self.dec_salt); + nonce[4..].copy_from_slice(&payload[..8]); + aead::Nonce::assume_unique_for_key(nonce) + }; + + let aad = aead::Aad::from(make_tls12_aad( + seq, + msg.typ, + msg.version, + payload.len() - GCM_OVERHEAD, + )); + + let payload = &mut msg.payload; + let plain_len = self + .dec_key + .open_within(nonce, aad, payload, GCM_EXPLICIT_NONCE_LEN..) + .map_err(|_| Error::DecryptError)? + .len(); + + if plain_len > MAX_FRAGMENT_LEN { + return Err(Error::PeerSentOversizedRecord); + } + + payload.truncate(plain_len); + Ok(msg.into_plain_message()) + } +} + +impl MessageEncrypter for GcmMessageEncrypter { + fn encrypt( + &mut self, + msg: OutboundPlainMessage<'_>, + seq: u64, + ) -> Result { + let total_len = self.encrypted_payload_len(msg.payload.len()); + let mut payload = PrefixedPayload::with_capacity(total_len); + + let nonce = aead::Nonce::assume_unique_for_key(Nonce::new(&self.iv, seq).0); + let aad = aead::Aad::from(make_tls12_aad(seq, msg.typ, msg.version, msg.payload.len())); + payload.extend_from_slice(&nonce.as_ref()[4..]); + payload.extend_from_chunks(&msg.payload); + + self.enc_key + .seal_in_place_separate_tag(nonce, aad, &mut payload.as_mut()[GCM_EXPLICIT_NONCE_LEN..]) + .map(|tag| payload.extend_from_slice(tag.as_ref())) + .map_err(|_| Error::EncryptError)?; + + Ok(OutboundOpaqueMessage::new(msg.typ, msg.version, payload)) + } + + fn encrypted_payload_len(&self, payload_len: usize) -> usize { + payload_len + GCM_EXPLICIT_NONCE_LEN + self.enc_key.algorithm().tag_len() + } +} + +/// The RFC7905/RFC7539 ChaCha20Poly1305 construction. +/// This implementation does the AAD construction required in TLS1.2. +/// TLS1.3 uses `TLS13MessageEncrypter`. +struct ChaCha20Poly1305MessageEncrypter { + enc_key: aead::LessSafeKey, + enc_offset: Iv, +} + +/// The RFC7905/RFC7539 ChaCha20Poly1305 construction. +/// This implementation does the AAD construction required in TLS1.2. +/// TLS1.3 uses `TLS13MessageDecrypter`. +struct ChaCha20Poly1305MessageDecrypter { + dec_key: aead::LessSafeKey, + dec_offset: Iv, +} + +const CHACHAPOLY1305_OVERHEAD: usize = 16; + +impl MessageDecrypter for ChaCha20Poly1305MessageDecrypter { + fn decrypt<'a>( + &mut self, + mut msg: InboundOpaqueMessage<'a>, + seq: u64, + ) -> Result, Error> { + let payload = &msg.payload; + + if payload.len() < CHACHAPOLY1305_OVERHEAD { + return Err(Error::DecryptError); + } + + let nonce = aead::Nonce::assume_unique_for_key(Nonce::new(&self.dec_offset, seq).0); + let aad = aead::Aad::from(make_tls12_aad( + seq, + msg.typ, + msg.version, + payload.len() - CHACHAPOLY1305_OVERHEAD, + )); + + let payload = &mut msg.payload; + let plain_len = self + .dec_key + .open_in_place(nonce, aad, payload) + .map_err(|_| Error::DecryptError)? + .len(); + + if plain_len > MAX_FRAGMENT_LEN { + return Err(Error::PeerSentOversizedRecord); + } + + payload.truncate(plain_len); + Ok(msg.into_plain_message()) + } +} + +impl MessageEncrypter for ChaCha20Poly1305MessageEncrypter { + fn encrypt( + &mut self, + msg: OutboundPlainMessage<'_>, + seq: u64, + ) -> Result { + let total_len = self.encrypted_payload_len(msg.payload.len()); + let mut payload = PrefixedPayload::with_capacity(total_len); + + let nonce = aead::Nonce::assume_unique_for_key(Nonce::new(&self.enc_offset, seq).0); + let aad = aead::Aad::from(make_tls12_aad(seq, msg.typ, msg.version, msg.payload.len())); + payload.extend_from_chunks(&msg.payload); + + self.enc_key + .seal_in_place_append_tag(nonce, aad, &mut payload) + .map_err(|_| Error::EncryptError)?; + + Ok(OutboundOpaqueMessage::new(msg.typ, msg.version, payload)) + } + + fn encrypted_payload_len(&self, payload_len: usize) -> usize { + payload_len + self.enc_key.algorithm().tag_len() + } +} + +fn gcm_iv(write_iv: &[u8], explicit: &[u8]) -> Iv { + debug_assert_eq!(write_iv.len(), 4); + debug_assert_eq!(explicit.len(), 8); + + // The GCM nonce is constructed from a 32-bit 'salt' derived + // from the master-secret, and a 64-bit explicit part, + // with no specified construction. Thanks for that. + // + // We use the same construction as TLS1.3/ChaCha20Poly1305: + // a starting point extracted from the key block, xored with + // the sequence number. + let mut iv = [0; NONCE_LEN]; + iv[..4].copy_from_slice(write_iv); + iv[4..].copy_from_slice(explicit); + + Iv::new(iv) +} diff --git a/http/vendor/rustls/src/crypto/ring/tls13.rs b/http/vendor/rustls/src/crypto/ring/tls13.rs new file mode 100644 index 0000000..ef488b6 --- /dev/null +++ b/http/vendor/rustls/src/crypto/ring/tls13.rs @@ -0,0 +1,336 @@ +use alloc::boxed::Box; + +use super::ring_like::hkdf::KeyType; +use super::ring_like::{aead, hkdf, hmac}; +use crate::crypto; +use crate::crypto::cipher::{ + AeadKey, InboundOpaqueMessage, Iv, MessageDecrypter, MessageEncrypter, Nonce, + Tls13AeadAlgorithm, UnsupportedOperationError, make_tls13_aad, +}; +use crate::crypto::tls13::{Hkdf, HkdfExpander, OkmBlock, OutputLengthError}; +use crate::enums::{CipherSuite, ContentType, ProtocolVersion}; +use crate::error::Error; +use crate::msgs::message::{ + InboundPlainMessage, OutboundOpaqueMessage, OutboundPlainMessage, PrefixedPayload, +}; +use crate::suites::{CipherSuiteCommon, ConnectionTrafficSecrets, SupportedCipherSuite}; +use crate::tls13::Tls13CipherSuite; + +/// The TLS1.3 ciphersuite TLS_CHACHA20_POLY1305_SHA256 +pub static TLS13_CHACHA20_POLY1305_SHA256: SupportedCipherSuite = + SupportedCipherSuite::Tls13(TLS13_CHACHA20_POLY1305_SHA256_INTERNAL); + +pub(crate) static TLS13_CHACHA20_POLY1305_SHA256_INTERNAL: &Tls13CipherSuite = &Tls13CipherSuite { + common: CipherSuiteCommon { + suite: CipherSuite::TLS13_CHACHA20_POLY1305_SHA256, + hash_provider: &super::hash::SHA256, + // ref: + confidentiality_limit: u64::MAX, + }, + hkdf_provider: &RingHkdf(hkdf::HKDF_SHA256, hmac::HMAC_SHA256), + aead_alg: &Chacha20Poly1305Aead(AeadAlgorithm(&aead::CHACHA20_POLY1305)), + quic: Some(&super::quic::KeyBuilder { + packet_alg: &aead::CHACHA20_POLY1305, + header_alg: &aead::quic::CHACHA20, + // ref: + confidentiality_limit: u64::MAX, + // ref: + integrity_limit: 1 << 36, + }), +}; + +/// The TLS1.3 ciphersuite TLS_AES_256_GCM_SHA384 +pub static TLS13_AES_256_GCM_SHA384: SupportedCipherSuite = + SupportedCipherSuite::Tls13(&Tls13CipherSuite { + common: CipherSuiteCommon { + suite: CipherSuite::TLS13_AES_256_GCM_SHA384, + hash_provider: &super::hash::SHA384, + confidentiality_limit: 1 << 24, + }, + hkdf_provider: &RingHkdf(hkdf::HKDF_SHA384, hmac::HMAC_SHA384), + aead_alg: &Aes256GcmAead(AeadAlgorithm(&aead::AES_256_GCM)), + quic: Some(&super::quic::KeyBuilder { + packet_alg: &aead::AES_256_GCM, + header_alg: &aead::quic::AES_256, + // ref: + confidentiality_limit: 1 << 23, + // ref: + integrity_limit: 1 << 52, + }), + }); + +/// The TLS1.3 ciphersuite TLS_AES_128_GCM_SHA256 +pub static TLS13_AES_128_GCM_SHA256: SupportedCipherSuite = + SupportedCipherSuite::Tls13(TLS13_AES_128_GCM_SHA256_INTERNAL); + +pub(crate) static TLS13_AES_128_GCM_SHA256_INTERNAL: &Tls13CipherSuite = &Tls13CipherSuite { + common: CipherSuiteCommon { + suite: CipherSuite::TLS13_AES_128_GCM_SHA256, + hash_provider: &super::hash::SHA256, + confidentiality_limit: 1 << 24, + }, + hkdf_provider: &RingHkdf(hkdf::HKDF_SHA256, hmac::HMAC_SHA256), + aead_alg: &Aes128GcmAead(AeadAlgorithm(&aead::AES_128_GCM)), + quic: Some(&super::quic::KeyBuilder { + packet_alg: &aead::AES_128_GCM, + header_alg: &aead::quic::AES_128, + // ref: + confidentiality_limit: 1 << 23, + // ref: + integrity_limit: 1 << 52, + }), +}; + +struct Chacha20Poly1305Aead(AeadAlgorithm); + +impl Tls13AeadAlgorithm for Chacha20Poly1305Aead { + fn encrypter(&self, key: AeadKey, iv: Iv) -> Box { + self.0.encrypter(key, iv) + } + + fn decrypter(&self, key: AeadKey, iv: Iv) -> Box { + self.0.decrypter(key, iv) + } + + fn key_len(&self) -> usize { + self.0.key_len() + } + + fn extract_keys( + &self, + key: AeadKey, + iv: Iv, + ) -> Result { + Ok(ConnectionTrafficSecrets::Chacha20Poly1305 { key, iv }) + } + + fn fips(&self) -> bool { + false // chacha20poly1305 not FIPS approved + } +} + +struct Aes256GcmAead(AeadAlgorithm); + +impl Tls13AeadAlgorithm for Aes256GcmAead { + fn encrypter(&self, key: AeadKey, iv: Iv) -> Box { + self.0.encrypter(key, iv) + } + + fn decrypter(&self, key: AeadKey, iv: Iv) -> Box { + self.0.decrypter(key, iv) + } + + fn key_len(&self) -> usize { + self.0.key_len() + } + + fn extract_keys( + &self, + key: AeadKey, + iv: Iv, + ) -> Result { + Ok(ConnectionTrafficSecrets::Aes256Gcm { key, iv }) + } + + fn fips(&self) -> bool { + super::fips() + } +} + +struct Aes128GcmAead(AeadAlgorithm); + +impl Tls13AeadAlgorithm for Aes128GcmAead { + fn encrypter(&self, key: AeadKey, iv: Iv) -> Box { + self.0.encrypter(key, iv) + } + + fn decrypter(&self, key: AeadKey, iv: Iv) -> Box { + self.0.decrypter(key, iv) + } + + fn key_len(&self) -> usize { + self.0.key_len() + } + + fn extract_keys( + &self, + key: AeadKey, + iv: Iv, + ) -> Result { + Ok(ConnectionTrafficSecrets::Aes128Gcm { key, iv }) + } + + fn fips(&self) -> bool { + super::fips() + } +} + +// common encrypter/decrypter/key_len items for above Tls13AeadAlgorithm impls +struct AeadAlgorithm(&'static aead::Algorithm); + +impl AeadAlgorithm { + fn encrypter(&self, key: AeadKey, iv: Iv) -> Box { + // safety: the caller arranges that `key` is `key_len()` in bytes, so this unwrap is safe. + Box::new(Tls13MessageEncrypter { + enc_key: aead::LessSafeKey::new(aead::UnboundKey::new(self.0, key.as_ref()).unwrap()), + iv, + }) + } + + fn decrypter(&self, key: AeadKey, iv: Iv) -> Box { + // safety: the caller arranges that `key` is `key_len()` in bytes, so this unwrap is safe. + Box::new(Tls13MessageDecrypter { + dec_key: aead::LessSafeKey::new(aead::UnboundKey::new(self.0, key.as_ref()).unwrap()), + iv, + }) + } + + fn key_len(&self) -> usize { + self.0.key_len() + } +} + +struct Tls13MessageEncrypter { + enc_key: aead::LessSafeKey, + iv: Iv, +} + +struct Tls13MessageDecrypter { + dec_key: aead::LessSafeKey, + iv: Iv, +} + +impl MessageEncrypter for Tls13MessageEncrypter { + fn encrypt( + &mut self, + msg: OutboundPlainMessage<'_>, + seq: u64, + ) -> Result { + let total_len = self.encrypted_payload_len(msg.payload.len()); + let mut payload = PrefixedPayload::with_capacity(total_len); + + let nonce = aead::Nonce::assume_unique_for_key(Nonce::new(&self.iv, seq).0); + let aad = aead::Aad::from(make_tls13_aad(total_len)); + payload.extend_from_chunks(&msg.payload); + payload.extend_from_slice(&msg.typ.to_array()); + + self.enc_key + .seal_in_place_append_tag(nonce, aad, &mut payload) + .map_err(|_| Error::EncryptError)?; + + Ok(OutboundOpaqueMessage::new( + ContentType::ApplicationData, + // Note: all TLS 1.3 application data records use TLSv1_2 (0x0303) as the legacy record + // protocol version, see https://www.rfc-editor.org/rfc/rfc8446#section-5.1 + ProtocolVersion::TLSv1_2, + payload, + )) + } + + fn encrypted_payload_len(&self, payload_len: usize) -> usize { + payload_len + 1 + self.enc_key.algorithm().tag_len() + } +} + +impl MessageDecrypter for Tls13MessageDecrypter { + fn decrypt<'a>( + &mut self, + mut msg: InboundOpaqueMessage<'a>, + seq: u64, + ) -> Result, Error> { + let payload = &mut msg.payload; + if payload.len() < self.dec_key.algorithm().tag_len() { + return Err(Error::DecryptError); + } + + let nonce = aead::Nonce::assume_unique_for_key(Nonce::new(&self.iv, seq).0); + let aad = aead::Aad::from(make_tls13_aad(payload.len())); + let plain_len = self + .dec_key + .open_in_place(nonce, aad, payload) + .map_err(|_| Error::DecryptError)? + .len(); + + payload.truncate(plain_len); + msg.into_tls13_unpadded_message() + } +} + +struct RingHkdf(hkdf::Algorithm, hmac::Algorithm); + +impl Hkdf for RingHkdf { + fn extract_from_zero_ikm(&self, salt: Option<&[u8]>) -> Box { + let zeroes = [0u8; OkmBlock::MAX_LEN]; + let salt = match salt { + Some(salt) => salt, + None => &zeroes[..self.0.len()], + }; + Box::new(RingHkdfExpander { + alg: self.0, + prk: hkdf::Salt::new(self.0, salt).extract(&zeroes[..self.0.len()]), + }) + } + + fn extract_from_secret(&self, salt: Option<&[u8]>, secret: &[u8]) -> Box { + let zeroes = [0u8; OkmBlock::MAX_LEN]; + let salt = match salt { + Some(salt) => salt, + None => &zeroes[..self.0.len()], + }; + Box::new(RingHkdfExpander { + alg: self.0, + prk: hkdf::Salt::new(self.0, salt).extract(secret), + }) + } + + fn expander_for_okm(&self, okm: &OkmBlock) -> Box { + Box::new(RingHkdfExpander { + alg: self.0, + prk: hkdf::Prk::new_less_safe(self.0, okm.as_ref()), + }) + } + + fn hmac_sign(&self, key: &OkmBlock, message: &[u8]) -> crypto::hmac::Tag { + crypto::hmac::Tag::new(hmac::sign(&hmac::Key::new(self.1, key.as_ref()), message).as_ref()) + } + + fn fips(&self) -> bool { + super::fips() + } +} + +struct RingHkdfExpander { + alg: hkdf::Algorithm, + prk: hkdf::Prk, +} + +impl HkdfExpander for RingHkdfExpander { + fn expand_slice(&self, info: &[&[u8]], output: &mut [u8]) -> Result<(), OutputLengthError> { + self.prk + .expand(info, Len(output.len())) + .and_then(|okm| okm.fill(output)) + .map_err(|_| OutputLengthError) + } + + fn expand_block(&self, info: &[&[u8]]) -> OkmBlock { + let mut buf = [0u8; OkmBlock::MAX_LEN]; + let output = &mut buf[..self.hash_len()]; + self.prk + .expand(info, Len(output.len())) + .and_then(|okm| okm.fill(output)) + .unwrap(); + OkmBlock::new(output) + } + + fn hash_len(&self) -> usize { + self.alg.len() + } +} + +struct Len(usize); + +impl KeyType for Len { + fn len(&self) -> usize { + self.0 + } +} diff --git a/http/vendor/rustls/src/crypto/signer.rs b/http/vendor/rustls/src/crypto/signer.rs new file mode 100644 index 0000000..659566a --- /dev/null +++ b/http/vendor/rustls/src/crypto/signer.rs @@ -0,0 +1,233 @@ +use alloc::boxed::Box; +use alloc::vec::Vec; +use core::fmt::Debug; + +use pki_types::{AlgorithmIdentifier, CertificateDer, PrivateKeyDer, SubjectPublicKeyInfoDer}; + +use super::CryptoProvider; +use crate::client::ResolvesClientCert; +use crate::enums::{SignatureAlgorithm, SignatureScheme}; +use crate::error::{Error, InconsistentKeys}; +use crate::server::{ClientHello, ParsedCertificate, ResolvesServerCert}; +use crate::sync::Arc; +use crate::x509; + +/// An abstract signing key. +/// +/// This interface is used by rustls to use a private signing key +/// for authentication. This includes server and client authentication. +/// +/// Objects of this type are always used within Rustls as +/// `Arc`. There are no concrete public structs in Rustls +/// that implement this trait. +/// +/// There are two main ways to get a signing key: +/// +/// - [`KeyProvider::load_private_key()`], or +/// - some other method outside of the `KeyProvider` extension trait, +/// for instance: +/// - [`crypto::ring::sign::any_ecdsa_type()`] +/// - [`crypto::ring::sign::any_eddsa_type()`] +/// - [`crypto::ring::sign::any_supported_type()`] +/// - [`crypto::aws_lc_rs::sign::any_ecdsa_type()`] +/// - [`crypto::aws_lc_rs::sign::any_eddsa_type()`] +/// - [`crypto::aws_lc_rs::sign::any_supported_type()`] +/// +/// The `KeyProvider` method `load_private_key()` is called under the hood by +/// [`ConfigBuilder::with_single_cert()`], +/// [`ConfigBuilder::with_client_auth_cert()`], and +/// [`ConfigBuilder::with_single_cert_with_ocsp()`]. +/// +/// A signing key created outside of the `KeyProvider` extension trait can be used +/// to create a [`CertifiedKey`], which in turn can be used to create a +/// [`ResolvesServerCertUsingSni`]. Alternately, a `CertifiedKey` can be returned from a +/// custom implementation of the [`ResolvesServerCert`] or [`ResolvesClientCert`] traits. +/// +/// [`KeyProvider::load_private_key()`]: crate::crypto::KeyProvider::load_private_key +/// [`ConfigBuilder::with_single_cert()`]: crate::ConfigBuilder::with_single_cert +/// [`ConfigBuilder::with_single_cert_with_ocsp()`]: crate::ConfigBuilder::with_single_cert_with_ocsp +/// [`ConfigBuilder::with_client_auth_cert()`]: crate::ConfigBuilder::with_client_auth_cert +/// [`crypto::ring::sign::any_ecdsa_type()`]: crate::crypto::ring::sign::any_ecdsa_type +/// [`crypto::ring::sign::any_eddsa_type()`]: crate::crypto::ring::sign::any_eddsa_type +/// [`crypto::ring::sign::any_supported_type()`]: crate::crypto::ring::sign::any_supported_type +/// [`crypto::aws_lc_rs::sign::any_ecdsa_type()`]: crate::crypto::aws_lc_rs::sign::any_ecdsa_type +/// [`crypto::aws_lc_rs::sign::any_eddsa_type()`]: crate::crypto::aws_lc_rs::sign::any_eddsa_type +/// [`crypto::aws_lc_rs::sign::any_supported_type()`]: crate::crypto::aws_lc_rs::sign::any_supported_type +/// [`ResolvesServerCertUsingSni`]: crate::server::ResolvesServerCertUsingSni +/// [`ResolvesServerCert`]: crate::server::ResolvesServerCert +/// [`ResolvesClientCert`]: crate::client::ResolvesClientCert +pub trait SigningKey: Debug + Send + Sync { + /// Choose a `SignatureScheme` from those offered. + /// + /// Expresses the choice by returning something that implements `Signer`, + /// using the chosen scheme. + fn choose_scheme(&self, offered: &[SignatureScheme]) -> Option>; + + /// Get the RFC 5280-compliant SubjectPublicKeyInfo (SPKI) of this [`SigningKey`] if available. + fn public_key(&self) -> Option> { + // Opt-out by default + None + } + + /// What kind of key we have. + fn algorithm(&self) -> SignatureAlgorithm; +} + +/// A thing that can sign a message. +pub trait Signer: Debug + Send + Sync { + /// Signs `message` using the selected scheme. + /// + /// `message` is not hashed; the implementer must hash it using the hash function + /// implicit in [`Self::scheme()`]. + /// + /// The returned signature format is also defined by [`Self::scheme()`]. + fn sign(&self, message: &[u8]) -> Result, Error>; + + /// Reveals which scheme will be used when you call [`Self::sign()`]. + fn scheme(&self) -> SignatureScheme; +} + +/// Server certificate resolver which always resolves to the same certificate and key. +/// +/// For use with [`ConfigBuilder::with_cert_resolver()`]. +/// +/// [`ConfigBuilder::with_cert_resolver()`]: crate::ConfigBuilder::with_cert_resolver +#[derive(Debug)] +pub struct SingleCertAndKey(Arc); + +impl From for SingleCertAndKey { + fn from(certified_key: CertifiedKey) -> Self { + Self(Arc::new(certified_key)) + } +} + +impl From> for SingleCertAndKey { + fn from(certified_key: Arc) -> Self { + Self(certified_key) + } +} + +impl ResolvesClientCert for SingleCertAndKey { + fn resolve( + &self, + _root_hint_subjects: &[&[u8]], + _sigschemes: &[SignatureScheme], + ) -> Option> { + Some(self.0.clone()) + } + + fn has_certs(&self) -> bool { + true + } +} + +impl ResolvesServerCert for SingleCertAndKey { + fn resolve(&self, _client_hello: ClientHello<'_>) -> Option> { + Some(self.0.clone()) + } +} + +/// A packaged-together certificate chain, matching `SigningKey` and +/// optional stapled OCSP response. +/// +/// Note: this struct is also used to represent an [RFC 7250] raw public key, +/// when the client/server is configured to use raw public keys instead of +/// certificates. +/// +/// [RFC 7250]: https://tools.ietf.org/html/rfc7250 +#[derive(Clone, Debug)] +pub struct CertifiedKey { + /// The certificate chain or raw public key. + pub cert: Vec>, + + /// The certified key. + pub key: Arc, + + /// An optional OCSP response from the certificate issuer, + /// attesting to its continued validity. + pub ocsp: Option>, +} + +impl CertifiedKey { + /// Create a new `CertifiedKey` from a certificate chain and DER-encoded private key. + /// + /// Attempt to parse the private key with the given [`CryptoProvider`]'s [`KeyProvider`] and + /// verify that it matches the public key in the first certificate of the `cert_chain` + /// if possible. + /// + /// [`KeyProvider`]: crate::crypto::KeyProvider + pub fn from_der( + cert_chain: Vec>, + key: PrivateKeyDer<'static>, + provider: &CryptoProvider, + ) -> Result { + let private_key = provider + .key_provider + .load_private_key(key)?; + + let certified_key = Self::new(cert_chain, private_key); + match certified_key.keys_match() { + // Don't treat unknown consistency as an error + Ok(()) | Err(Error::InconsistentKeys(InconsistentKeys::Unknown)) => Ok(certified_key), + Err(err) => Err(err), + } + } + + /// Make a new CertifiedKey, with the given chain and key. + /// + /// The cert chain must not be empty. The first certificate in the chain + /// must be the end-entity certificate. + pub fn new(cert: Vec>, key: Arc) -> Self { + Self { + cert, + key, + ocsp: None, + } + } + + /// Verify the consistency of this [`CertifiedKey`]'s public and private keys. + /// This is done by performing a comparison of SubjectPublicKeyInfo bytes. + pub fn keys_match(&self) -> Result<(), Error> { + let Some(key_spki) = self.key.public_key() else { + return Err(InconsistentKeys::Unknown.into()); + }; + + let cert = ParsedCertificate::try_from(self.end_entity_cert()?)?; + match key_spki == cert.subject_public_key_info() { + true => Ok(()), + false => Err(InconsistentKeys::KeyMismatch.into()), + } + } + + /// The end-entity certificate. + pub fn end_entity_cert(&self) -> Result<&CertificateDer<'_>, Error> { + self.cert + .first() + .ok_or(Error::NoCertificatesPresented) + } +} + +/// Convert a public key and algorithm identifier into [`SubjectPublicKeyInfoDer`]. +pub fn public_key_to_spki( + alg_id: &AlgorithmIdentifier, + public_key: impl AsRef<[u8]>, +) -> SubjectPublicKeyInfoDer<'static> { + // SubjectPublicKeyInfo ::= SEQUENCE { + // algorithm AlgorithmIdentifier, + // subjectPublicKey BIT STRING } + // + // AlgorithmIdentifier ::= SEQUENCE { + // algorithm OBJECT IDENTIFIER, + // parameters ANY DEFINED BY algorithm OPTIONAL } + // + // note that the `pki_types::AlgorithmIdentifier` type is the + // concatenation of `algorithm` and `parameters`, but misses the + // outer `Sequence`. + + let mut spki_inner = x509::wrap_in_sequence(alg_id.as_ref()); + spki_inner.extend(&x509::wrap_in_bit_string(public_key.as_ref())); + + let spki = x509::wrap_in_sequence(&spki_inner); + + SubjectPublicKeyInfoDer::from(spki) +} diff --git a/http/vendor/rustls/src/crypto/tls12.rs b/http/vendor/rustls/src/crypto/tls12.rs new file mode 100644 index 0000000..7128de4 --- /dev/null +++ b/http/vendor/rustls/src/crypto/tls12.rs @@ -0,0 +1,169 @@ +use alloc::boxed::Box; + +use super::{ActiveKeyExchange, hmac}; +use crate::error::Error; +use crate::version::TLS12; + +/// Implements [`Prf`] using a [`hmac::Hmac`]. +pub struct PrfUsingHmac<'a>(pub &'a dyn hmac::Hmac); + +impl Prf for PrfUsingHmac<'_> { + fn for_key_exchange( + &self, + output: &mut [u8; 48], + kx: Box, + peer_pub_key: &[u8], + label: &[u8], + seed: &[u8], + ) -> Result<(), Error> { + prf( + output, + self.0 + .with_key( + kx.complete_for_tls_version(peer_pub_key, &TLS12)? + .secret_bytes(), + ) + .as_ref(), + label, + seed, + ); + Ok(()) + } + + fn for_secret(&self, output: &mut [u8], secret: &[u8], label: &[u8], seed: &[u8]) { + prf(output, self.0.with_key(secret).as_ref(), label, seed); + } +} + +/// An instantiation of the TLS1.2 PRF with a specific, implicit hash function. +/// +/// See the definition in [RFC5246 section 5](https://www.rfc-editor.org/rfc/rfc5246#section-5). +/// +/// See [`PrfUsingHmac`] as a route to implementing this trait with just +/// an implementation of [`hmac::Hmac`]. +pub trait Prf: Send + Sync { + /// Computes `PRF(secret, label, seed)` using the secret from a completed key exchange. + /// + /// Completes the given key exchange, and then uses the resulting shared secret + /// to compute the PRF, writing the result into `output`. + /// + /// The caller guarantees that `label`, `seed` are non-empty. The caller makes no + /// guarantees about the contents of `peer_pub_key`. It must be validated by + /// [`ActiveKeyExchange::complete`]. + fn for_key_exchange( + &self, + output: &mut [u8; 48], + kx: Box, + peer_pub_key: &[u8], + label: &[u8], + seed: &[u8], + ) -> Result<(), Error>; + + /// Computes `PRF(secret, label, seed)`, writing the result into `output`. + /// + /// The caller guarantees that `secret`, `label`, and `seed` are non-empty. + fn for_secret(&self, output: &mut [u8], secret: &[u8], label: &[u8], seed: &[u8]); + + /// Return `true` if this is backed by a FIPS-approved implementation. + fn fips(&self) -> bool { + false + } +} + +pub(crate) fn prf(out: &mut [u8], hmac_key: &dyn hmac::Key, label: &[u8], seed: &[u8]) { + // A(1) + let mut current_a = hmac_key.sign(&[label, seed]); + + let chunk_size = hmac_key.tag_len(); + for chunk in out.chunks_mut(chunk_size) { + // P_hash[i] = HMAC_hash(secret, A(i) + seed) + let p_term = hmac_key.sign(&[current_a.as_ref(), label, seed]); + chunk.copy_from_slice(&p_term.as_ref()[..chunk.len()]); + + // A(i+1) = HMAC_hash(secret, A(i)) + current_a = hmac_key.sign(&[current_a.as_ref()]); + } +} + +#[cfg(all(test, feature = "ring"))] +mod tests { + use crate::crypto::hmac::Hmac; + // nb: crypto::aws_lc_rs provider doesn't provide (or need) hmac, + // so cannot be used for this test. + use crate::crypto::ring::hmac; + + // Below known answer tests come from https://mailarchive.ietf.org/arch/msg/tls/fzVCzk-z3FShgGJ6DOXqM1ydxms/ + + #[test] + fn check_sha256() { + let secret = b"\x9b\xbe\x43\x6b\xa9\x40\xf0\x17\xb1\x76\x52\x84\x9a\x71\xdb\x35"; + let seed = b"\xa0\xba\x9f\x93\x6c\xda\x31\x18\x27\xa6\xf7\x96\xff\xd5\x19\x8c"; + let label = b"test label"; + let expect = include_bytes!("../testdata/prf-result.1.bin"); + let mut output = [0u8; 100]; + + super::prf( + &mut output, + &*hmac::HMAC_SHA256.with_key(secret), + label, + seed, + ); + assert_eq!(expect.len(), output.len()); + assert_eq!(expect.to_vec(), output.to_vec()); + } + + #[test] + fn check_sha512() { + let secret = b"\xb0\x32\x35\x23\xc1\x85\x35\x99\x58\x4d\x88\x56\x8b\xbb\x05\xeb"; + let seed = b"\xd4\x64\x0e\x12\xe4\xbc\xdb\xfb\x43\x7f\x03\xe6\xae\x41\x8e\xe5"; + let label = b"test label"; + let expect = include_bytes!("../testdata/prf-result.2.bin"); + let mut output = [0u8; 196]; + + super::prf( + &mut output, + &*hmac::HMAC_SHA512.with_key(secret), + label, + seed, + ); + assert_eq!(expect.len(), output.len()); + assert_eq!(expect.to_vec(), output.to_vec()); + } + + #[test] + fn check_sha384() { + let secret = b"\xb8\x0b\x73\x3d\x6c\xee\xfc\xdc\x71\x56\x6e\xa4\x8e\x55\x67\xdf"; + let seed = b"\xcd\x66\x5c\xf6\xa8\x44\x7d\xd6\xff\x8b\x27\x55\x5e\xdb\x74\x65"; + let label = b"test label"; + let expect = include_bytes!("../testdata/prf-result.3.bin"); + let mut output = [0u8; 148]; + + super::prf( + &mut output, + &*hmac::HMAC_SHA384.with_key(secret), + label, + seed, + ); + assert_eq!(expect.len(), output.len()); + assert_eq!(expect.to_vec(), output.to_vec()); + } +} + +#[cfg(all(bench, feature = "ring"))] +mod benchmarks { + #[bench] + fn bench_sha256(b: &mut test::Bencher) { + use crate::crypto::hmac::Hmac; + use crate::crypto::ring::hmac; + + let label = &b"extended master secret"[..]; + let seed = [0u8; 32]; + let key = &b"secret"[..]; + + b.iter(|| { + let mut out = [0u8; 48]; + super::prf(&mut out, &*hmac::HMAC_SHA256.with_key(key), &label, &seed); + test::black_box(out); + }); + } +} diff --git a/http/vendor/rustls/src/crypto/tls13.rs b/http/vendor/rustls/src/crypto/tls13.rs new file mode 100644 index 0000000..50ecaa8 --- /dev/null +++ b/http/vendor/rustls/src/crypto/tls13.rs @@ -0,0 +1,406 @@ +use alloc::boxed::Box; +use alloc::vec::Vec; + +use zeroize::Zeroize; + +use super::{ActiveKeyExchange, hmac}; +use crate::error::Error; +use crate::version::TLS13; + +/// Implementation of `HkdfExpander` via `hmac::Key`. +pub struct HkdfExpanderUsingHmac(Box); + +impl HkdfExpanderUsingHmac { + fn expand_unchecked(&self, info: &[&[u8]], output: &mut [u8]) { + let mut term = hmac::Tag::new(b""); + + for (n, chunk) in output + .chunks_mut(self.0.tag_len()) + .enumerate() + { + term = self + .0 + .sign_concat(term.as_ref(), info, &[(n + 1) as u8]); + chunk.copy_from_slice(&term.as_ref()[..chunk.len()]); + } + } +} + +impl HkdfExpander for HkdfExpanderUsingHmac { + fn expand_slice(&self, info: &[&[u8]], output: &mut [u8]) -> Result<(), OutputLengthError> { + if output.len() > 255 * self.0.tag_len() { + return Err(OutputLengthError); + } + + self.expand_unchecked(info, output); + Ok(()) + } + + fn expand_block(&self, info: &[&[u8]]) -> OkmBlock { + let mut tag = [0u8; hmac::Tag::MAX_LEN]; + let reduced_tag = &mut tag[..self.0.tag_len()]; + self.expand_unchecked(info, reduced_tag); + OkmBlock::new(reduced_tag) + } + + fn hash_len(&self) -> usize { + self.0.tag_len() + } +} + +/// Implementation of `Hkdf` (and thence `HkdfExpander`) via `hmac::Hmac`. +pub struct HkdfUsingHmac<'a>(pub &'a dyn hmac::Hmac); + +impl Hkdf for HkdfUsingHmac<'_> { + fn extract_from_zero_ikm(&self, salt: Option<&[u8]>) -> Box { + let zeroes = [0u8; hmac::Tag::MAX_LEN]; + Box::new(HkdfExpanderUsingHmac(self.0.with_key( + &self.extract_prk_from_secret(salt, &zeroes[..self.0.hash_output_len()]), + ))) + } + + fn extract_from_secret(&self, salt: Option<&[u8]>, secret: &[u8]) -> Box { + Box::new(HkdfExpanderUsingHmac( + self.0 + .with_key(&self.extract_prk_from_secret(salt, secret)), + )) + } + + fn expander_for_okm(&self, okm: &OkmBlock) -> Box { + Box::new(HkdfExpanderUsingHmac(self.0.with_key(okm.as_ref()))) + } + + fn hmac_sign(&self, key: &OkmBlock, message: &[u8]) -> hmac::Tag { + self.0 + .with_key(key.as_ref()) + .sign(&[message]) + } +} + +impl HkdfPrkExtract for HkdfUsingHmac<'_> { + fn extract_prk_from_secret(&self, salt: Option<&[u8]>, secret: &[u8]) -> Vec { + let zeroes = [0u8; hmac::Tag::MAX_LEN]; + let salt = match salt { + Some(salt) => salt, + None => &zeroes[..self.0.hash_output_len()], + }; + self.0 + .with_key(salt) + .sign(&[secret]) + .as_ref() + .to_vec() + } +} + +/// Implementation of `HKDF-Expand` with an implicitly stored and immutable `PRK`. +pub trait HkdfExpander: Send + Sync { + /// `HKDF-Expand(PRK, info, L)` into a slice. + /// + /// Where: + /// + /// - `PRK` is the implicit key material represented by this instance. + /// - `L` is `output.len()`. + /// - `info` is a slice of byte slices, which should be processed sequentially + /// (or concatenated if that is not possible). + /// + /// Returns `Err(OutputLengthError)` if `L` is larger than `255 * HashLen`. + /// Otherwise, writes to `output`. + fn expand_slice(&self, info: &[&[u8]], output: &mut [u8]) -> Result<(), OutputLengthError>; + + /// `HKDF-Expand(PRK, info, L=HashLen)` returned as a value. + /// + /// - `PRK` is the implicit key material represented by this instance. + /// - `L := HashLen`. + /// - `info` is a slice of byte slices, which should be processed sequentially + /// (or concatenated if that is not possible). + /// + /// This is infallible, because by definition `OkmBlock` is always exactly + /// `HashLen` bytes long. + fn expand_block(&self, info: &[&[u8]]) -> OkmBlock; + + /// Return what `HashLen` is for this instance. + /// + /// This must be no larger than [`OkmBlock::MAX_LEN`]. + fn hash_len(&self) -> usize; +} + +/// A HKDF implementation oriented to the needs of TLS1.3. +/// +/// See [RFC5869](https://datatracker.ietf.org/doc/html/rfc5869) for the terminology +/// used in this definition. +/// +/// You can use [`HkdfUsingHmac`] which implements this trait on top of an implementation +/// of [`hmac::Hmac`]. +pub trait Hkdf: Send + Sync { + /// `HKDF-Extract(salt, 0_HashLen)` + /// + /// `0_HashLen` is a string of `HashLen` zero bytes. + /// + /// A `salt` of `None` should be treated as a sequence of `HashLen` zero bytes. + fn extract_from_zero_ikm(&self, salt: Option<&[u8]>) -> Box; + + /// `HKDF-Extract(salt, secret)` + /// + /// A `salt` of `None` should be treated as a sequence of `HashLen` zero bytes. + fn extract_from_secret(&self, salt: Option<&[u8]>, secret: &[u8]) -> Box; + + /// `HKDF-Extract(salt, shared_secret)` where `shared_secret` is the result of a key exchange. + /// + /// Custom implementations should complete the key exchange by calling + /// `kx.complete(peer_pub_key)` and then using this as the input keying material to + /// `HKDF-Extract`. + /// + /// A `salt` of `None` should be treated as a sequence of `HashLen` zero bytes. + fn extract_from_kx_shared_secret( + &self, + salt: Option<&[u8]>, + kx: Box, + peer_pub_key: &[u8], + ) -> Result, Error> { + Ok(self.extract_from_secret( + salt, + kx.complete_for_tls_version(peer_pub_key, &TLS13)? + .secret_bytes(), + )) + } + + /// Build a `HkdfExpander` using `okm` as the secret PRK. + fn expander_for_okm(&self, okm: &OkmBlock) -> Box; + + /// Signs `message` using `key` viewed as a HMAC key. + /// + /// This should use the same hash function as the HKDF functions in this + /// trait. + /// + /// See [RFC2104](https://datatracker.ietf.org/doc/html/rfc2104) for the + /// definition of HMAC. + fn hmac_sign(&self, key: &OkmBlock, message: &[u8]) -> hmac::Tag; + + /// Return `true` if this is backed by a FIPS-approved implementation. + fn fips(&self) -> bool { + false + } +} + +/// An extended HKDF implementation that supports directly extracting a pseudo-random key (PRK). +/// +/// The base [`Hkdf`] trait is tailored to the needs of TLS 1.3, where all extracted PRKs +/// are expanded as-is, and so can be safely encapsulated without exposing the caller +/// to the key material. +/// +/// In other contexts (for example, hybrid public key encryption (HPKE)) it may be necessary +/// to use the extracted PRK directly for purposes other than an immediate expansion. +/// This trait can be implemented to offer this functionality when it is required. +pub(crate) trait HkdfPrkExtract: Hkdf { + /// `HKDF-Extract(salt, secret)` + /// + /// A `salt` of `None` should be treated as a sequence of `HashLen` zero bytes. + /// + /// In most cases you should prefer [`Hkdf::extract_from_secret`] and using the + /// returned [HkdfExpander] instead of handling the PRK directly. + fn extract_prk_from_secret(&self, salt: Option<&[u8]>, secret: &[u8]) -> Vec; +} + +/// `HKDF-Expand(PRK, info, L)` to construct any type from a byte array. +/// +/// - `PRK` is the implicit key material represented by this instance. +/// - `L := N`; N is the size of the byte array. +/// - `info` is a slice of byte slices, which should be processed sequentially +/// (or concatenated if that is not possible). +/// +/// This is infallible, because the set of types (and therefore their length) is known +/// at compile time. +pub fn expand(expander: &dyn HkdfExpander, info: &[&[u8]]) -> T +where + T: From<[u8; N]>, +{ + let mut output = [0u8; N]; + expander + .expand_slice(info, &mut output) + .expect("expand type parameter T is too large"); + T::from(output) +} + +/// Output key material from HKDF, as a value type. +#[derive(Clone)] +pub struct OkmBlock { + buf: [u8; Self::MAX_LEN], + used: usize, +} + +impl OkmBlock { + /// Build a single OKM block by copying a byte slice. + /// + /// The slice can be up to [`OkmBlock::MAX_LEN`] bytes in length. + pub fn new(bytes: &[u8]) -> Self { + let mut tag = Self { + buf: [0u8; Self::MAX_LEN], + used: bytes.len(), + }; + tag.buf[..bytes.len()].copy_from_slice(bytes); + tag + } + + /// Maximum supported HMAC tag size: supports up to SHA512. + pub const MAX_LEN: usize = 64; +} + +impl Drop for OkmBlock { + fn drop(&mut self) { + self.buf.zeroize(); + } +} + +impl AsRef<[u8]> for OkmBlock { + fn as_ref(&self) -> &[u8] { + &self.buf[..self.used] + } +} + +/// An error type used for `HkdfExpander::expand_slice` when +/// the slice exceeds the maximum HKDF output length. +#[derive(Debug)] +pub struct OutputLengthError; + +#[cfg(all(test, feature = "ring"))] +mod tests { + use std::prelude::v1::*; + + use super::{Hkdf, HkdfUsingHmac, expand}; + // nb: crypto::aws_lc_rs provider doesn't provide (or need) hmac, + // so cannot be used for this test. + use crate::crypto::ring::hmac; + + struct ByteArray([u8; N]); + + impl From<[u8; N]> for ByteArray { + fn from(array: [u8; N]) -> Self { + Self(array) + } + } + + /// Test cases from appendix A in the RFC, minus cases requiring SHA1. + + #[test] + fn test_case_1() { + let hkdf = HkdfUsingHmac(&hmac::HMAC_SHA256); + let ikm = &[0x0b; 22]; + let salt = &[ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, + ]; + let info: &[&[u8]] = &[ + &[0xf0, 0xf1, 0xf2], + &[0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9], + ]; + + let output: ByteArray<42> = expand( + hkdf.extract_from_secret(Some(salt), ikm) + .as_ref(), + info, + ); + + assert_eq!( + &output.0, + &[ + 0x3c, 0xb2, 0x5f, 0x25, 0xfa, 0xac, 0xd5, 0x7a, 0x90, 0x43, 0x4f, 0x64, 0xd0, 0x36, + 0x2f, 0x2a, 0x2d, 0x2d, 0x0a, 0x90, 0xcf, 0x1a, 0x5a, 0x4c, 0x5d, 0xb0, 0x2d, 0x56, + 0xec, 0xc4, 0xc5, 0xbf, 0x34, 0x00, 0x72, 0x08, 0xd5, 0xb8, 0x87, 0x18, 0x58, 0x65 + ] + ); + } + + #[test] + fn test_case_2() { + let hkdf = HkdfUsingHmac(&hmac::HMAC_SHA256); + let ikm: Vec = (0x00u8..=0x4f).collect(); + let salt: Vec = (0x60u8..=0xaf).collect(); + let info: Vec = (0xb0u8..=0xff).collect(); + + let output: ByteArray<82> = expand( + hkdf.extract_from_secret(Some(&salt), &ikm) + .as_ref(), + &[&info], + ); + + assert_eq!( + &output.0, + &[ + 0xb1, 0x1e, 0x39, 0x8d, 0xc8, 0x03, 0x27, 0xa1, 0xc8, 0xe7, 0xf7, 0x8c, 0x59, 0x6a, + 0x49, 0x34, 0x4f, 0x01, 0x2e, 0xda, 0x2d, 0x4e, 0xfa, 0xd8, 0xa0, 0x50, 0xcc, 0x4c, + 0x19, 0xaf, 0xa9, 0x7c, 0x59, 0x04, 0x5a, 0x99, 0xca, 0xc7, 0x82, 0x72, 0x71, 0xcb, + 0x41, 0xc6, 0x5e, 0x59, 0x0e, 0x09, 0xda, 0x32, 0x75, 0x60, 0x0c, 0x2f, 0x09, 0xb8, + 0x36, 0x77, 0x93, 0xa9, 0xac, 0xa3, 0xdb, 0x71, 0xcc, 0x30, 0xc5, 0x81, 0x79, 0xec, + 0x3e, 0x87, 0xc1, 0x4c, 0x01, 0xd5, 0xc1, 0xf3, 0x43, 0x4f, 0x1d, 0x87 + ] + ); + } + + #[test] + fn test_case_3() { + let hkdf = HkdfUsingHmac(&hmac::HMAC_SHA256); + let ikm = &[0x0b; 22]; + let salt = &[]; + let info = &[]; + + let output: ByteArray<42> = expand( + hkdf.extract_from_secret(Some(salt), ikm) + .as_ref(), + info, + ); + + assert_eq!( + &output.0, + &[ + 0x8d, 0xa4, 0xe7, 0x75, 0xa5, 0x63, 0xc1, 0x8f, 0x71, 0x5f, 0x80, 0x2a, 0x06, 0x3c, + 0x5a, 0x31, 0xb8, 0xa1, 0x1f, 0x5c, 0x5e, 0xe1, 0x87, 0x9e, 0xc3, 0x45, 0x4e, 0x5f, + 0x3c, 0x73, 0x8d, 0x2d, 0x9d, 0x20, 0x13, 0x95, 0xfa, 0xa4, 0xb6, 0x1a, 0x96, 0xc8 + ] + ); + } + + #[test] + fn test_salt_not_provided() { + // can't use test case 7, because we don't have (or want) SHA1. + // + // this output is generated with cryptography.io: + // + // >>> hkdf.HKDF(algorithm=hashes.SHA384(), length=96, salt=None, info=b"hello").derive(b"\x0b" * 40) + + let hkdf = HkdfUsingHmac(&hmac::HMAC_SHA384); + let ikm = &[0x0b; 40]; + let info = &[&b"hel"[..], &b"lo"[..]]; + + let output: ByteArray<96> = expand( + hkdf.extract_from_secret(None, ikm) + .as_ref(), + info, + ); + + assert_eq!( + &output.0, + &[ + 0xd5, 0x45, 0xdd, 0x3a, 0xff, 0x5b, 0x19, 0x46, 0xd4, 0x86, 0xfd, 0xb8, 0xd8, 0x88, + 0x2e, 0xe0, 0x1c, 0xc1, 0xa5, 0x48, 0xb6, 0x05, 0x75, 0xe4, 0xd7, 0x5d, 0x0f, 0x5f, + 0x23, 0x40, 0xee, 0x6c, 0x9e, 0x7c, 0x65, 0xd0, 0xee, 0x79, 0xdb, 0xb2, 0x07, 0x1d, + 0x66, 0xa5, 0x50, 0xc4, 0x8a, 0xa3, 0x93, 0x86, 0x8b, 0x7c, 0x69, 0x41, 0x6b, 0x3e, + 0x61, 0x44, 0x98, 0xb8, 0xc2, 0xfc, 0x82, 0x82, 0xae, 0xcd, 0x46, 0xcf, 0xb1, 0x47, + 0xdc, 0xd0, 0x69, 0x0d, 0x19, 0xad, 0xe6, 0x6c, 0x70, 0xfe, 0x87, 0x92, 0x04, 0xb6, + 0x82, 0x2d, 0x97, 0x7e, 0x46, 0x80, 0x4c, 0xe5, 0x76, 0x72, 0xb4, 0xb8 + ] + ); + } + + #[test] + fn test_output_length_bounds() { + let hkdf = HkdfUsingHmac(&hmac::HMAC_SHA256); + let ikm = &[]; + let info = &[]; + + let mut output = [0u8; 32 * 255 + 1]; + assert!( + hkdf.extract_from_secret(None, ikm) + .expand_slice(info, &mut output) + .is_err() + ); + } +} diff --git a/http/vendor/rustls/src/enums.rs b/http/vendor/rustls/src/enums.rs new file mode 100644 index 0000000..4b450aa --- /dev/null +++ b/http/vendor/rustls/src/enums.rs @@ -0,0 +1,693 @@ +#![allow(non_camel_case_types)] +#![allow(missing_docs)] +use crate::msgs::codec::{Codec, Reader}; +use crate::msgs::enums::HashAlgorithm; + +enum_builder! { + /// The `AlertDescription` TLS protocol enum. Values in this enum are taken + /// from the various RFCs covering TLS, and are listed by IANA. + /// The `Unknown` item is used when processing unrecognised ordinals. + #[repr(u8)] + pub enum AlertDescription { + CloseNotify => 0x00, + UnexpectedMessage => 0x0a, + BadRecordMac => 0x14, + DecryptionFailed => 0x15, + RecordOverflow => 0x16, + DecompressionFailure => 0x1e, + HandshakeFailure => 0x28, + NoCertificate => 0x29, + BadCertificate => 0x2a, + UnsupportedCertificate => 0x2b, + CertificateRevoked => 0x2c, + CertificateExpired => 0x2d, + CertificateUnknown => 0x2e, + IllegalParameter => 0x2f, + UnknownCA => 0x30, + AccessDenied => 0x31, + DecodeError => 0x32, + DecryptError => 0x33, + ExportRestriction => 0x3c, + ProtocolVersion => 0x46, + InsufficientSecurity => 0x47, + InternalError => 0x50, + InappropriateFallback => 0x56, + UserCanceled => 0x5a, + NoRenegotiation => 0x64, + MissingExtension => 0x6d, + UnsupportedExtension => 0x6e, + CertificateUnobtainable => 0x6f, + UnrecognisedName => 0x70, + BadCertificateStatusResponse => 0x71, + BadCertificateHashValue => 0x72, + UnknownPSKIdentity => 0x73, + CertificateRequired => 0x74, + NoApplicationProtocol => 0x78, + EncryptedClientHelloRequired => 0x79, // https://datatracker.ietf.org/doc/html/draft-ietf-tls-esni-18#section-11.2 + } +} + +enum_builder! { + /// The `HandshakeType` TLS protocol enum. Values in this enum are taken + /// from the various RFCs covering TLS, and are listed by IANA. + /// The `Unknown` item is used when processing unrecognised ordinals. + #[repr(u8)] + pub enum HandshakeType { + HelloRequest => 0x00, + ClientHello => 0x01, + ServerHello => 0x02, + HelloVerifyRequest => 0x03, + NewSessionTicket => 0x04, + EndOfEarlyData => 0x05, + HelloRetryRequest => 0x06, + EncryptedExtensions => 0x08, + Certificate => 0x0b, + ServerKeyExchange => 0x0c, + CertificateRequest => 0x0d, + ServerHelloDone => 0x0e, + CertificateVerify => 0x0f, + ClientKeyExchange => 0x10, + Finished => 0x14, + CertificateURL => 0x15, + CertificateStatus => 0x16, + KeyUpdate => 0x18, + CompressedCertificate => 0x19, + MessageHash => 0xfe, + } +} + +enum_builder! { + /// The `ContentType` TLS protocol enum. Values in this enum are taken + /// from the various RFCs covering TLS, and are listed by IANA. + /// The `Unknown` item is used when processing unrecognised ordinals. + #[repr(u8)] + pub enum ContentType { + ChangeCipherSpec => 0x14, + Alert => 0x15, + Handshake => 0x16, + ApplicationData => 0x17, + Heartbeat => 0x18, + } +} + +enum_builder! { + /// The `ProtocolVersion` TLS protocol enum. Values in this enum are taken + /// from the various RFCs covering TLS, and are listed by IANA. + /// The `Unknown` item is used when processing unrecognised ordinals. + #[repr(u16)] + pub enum ProtocolVersion { + SSLv2 => 0x0002, + SSLv3 => 0x0300, + TLSv1_0 => 0x0301, + TLSv1_1 => 0x0302, + TLSv1_2 => 0x0303, + TLSv1_3 => 0x0304, + DTLSv1_0 => 0xFEFF, + DTLSv1_2 => 0xFEFD, + DTLSv1_3 => 0xFEFC, + } +} + +enum_builder! { + /// The `CipherSuite` TLS protocol enum. Values in this enum are taken + /// from the various RFCs covering TLS, and are listed by IANA. + /// The `Unknown` item is used when processing unrecognised ordinals. + #[repr(u16)] + pub enum CipherSuite { + TLS_NULL_WITH_NULL_NULL => 0x0000, + TLS_PSK_WITH_AES_128_GCM_SHA256 => 0x00a8, + TLS_PSK_WITH_AES_256_GCM_SHA384 => 0x00a9, + TLS_EMPTY_RENEGOTIATION_INFO_SCSV => 0x00ff, + TLS13_AES_128_GCM_SHA256 => 0x1301, + TLS13_AES_256_GCM_SHA384 => 0x1302, + TLS13_CHACHA20_POLY1305_SHA256 => 0x1303, + TLS13_AES_128_CCM_SHA256 => 0x1304, + TLS13_AES_128_CCM_8_SHA256 => 0x1305, + TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA => 0xc009, + TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA => 0xc00a, + TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA => 0xc013, + TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA => 0xc014, + TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 => 0xc023, + TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 => 0xc024, + TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 => 0xc027, + TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 => 0xc028, + TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 => 0xc02b, + TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 => 0xc02c, + TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 => 0xc02f, + TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 => 0xc030, + TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 => 0xcca8, + TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 => 0xcca9, + + !Debug: + TLS_RSA_WITH_NULL_MD5 => 0x0001, + TLS_RSA_WITH_NULL_SHA => 0x0002, + TLS_RSA_EXPORT_WITH_RC4_40_MD5 => 0x0003, + TLS_RSA_WITH_RC4_128_MD5 => 0x0004, + TLS_RSA_WITH_RC4_128_SHA => 0x0005, + TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5 => 0x0006, + TLS_RSA_WITH_IDEA_CBC_SHA => 0x0007, + TLS_RSA_EXPORT_WITH_DES40_CBC_SHA => 0x0008, + TLS_RSA_WITH_DES_CBC_SHA => 0x0009, + TLS_RSA_WITH_3DES_EDE_CBC_SHA => 0x000a, + TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA => 0x000b, + TLS_DH_DSS_WITH_DES_CBC_SHA => 0x000c, + TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA => 0x000d, + TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA => 0x000e, + TLS_DH_RSA_WITH_DES_CBC_SHA => 0x000f, + TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA => 0x0010, + TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA => 0x0011, + TLS_DHE_DSS_WITH_DES_CBC_SHA => 0x0012, + TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA => 0x0013, + TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA => 0x0014, + TLS_DHE_RSA_WITH_DES_CBC_SHA => 0x0015, + TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA => 0x0016, + TLS_DH_anon_EXPORT_WITH_RC4_40_MD5 => 0x0017, + TLS_DH_anon_WITH_RC4_128_MD5 => 0x0018, + TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA => 0x0019, + TLS_DH_anon_WITH_DES_CBC_SHA => 0x001a, + TLS_DH_anon_WITH_3DES_EDE_CBC_SHA => 0x001b, + SSL_FORTEZZA_KEA_WITH_NULL_SHA => 0x001c, + SSL_FORTEZZA_KEA_WITH_FORTEZZA_CBC_SHA => 0x001d, + TLS_KRB5_WITH_DES_CBC_SHA_or_SSL_FORTEZZA_KEA_WITH_RC4_128_SHA => 0x001e, + TLS_KRB5_WITH_3DES_EDE_CBC_SHA => 0x001f, + TLS_KRB5_WITH_RC4_128_SHA => 0x0020, + TLS_KRB5_WITH_IDEA_CBC_SHA => 0x0021, + TLS_KRB5_WITH_DES_CBC_MD5 => 0x0022, + TLS_KRB5_WITH_3DES_EDE_CBC_MD5 => 0x0023, + TLS_KRB5_WITH_RC4_128_MD5 => 0x0024, + TLS_KRB5_WITH_IDEA_CBC_MD5 => 0x0025, + TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA => 0x0026, + TLS_KRB5_EXPORT_WITH_RC2_CBC_40_SHA => 0x0027, + TLS_KRB5_EXPORT_WITH_RC4_40_SHA => 0x0028, + TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5 => 0x0029, + TLS_KRB5_EXPORT_WITH_RC2_CBC_40_MD5 => 0x002a, + TLS_KRB5_EXPORT_WITH_RC4_40_MD5 => 0x002b, + TLS_PSK_WITH_NULL_SHA => 0x002c, + TLS_DHE_PSK_WITH_NULL_SHA => 0x002d, + TLS_RSA_PSK_WITH_NULL_SHA => 0x002e, + TLS_RSA_WITH_AES_128_CBC_SHA => 0x002f, + TLS_DH_DSS_WITH_AES_128_CBC_SHA => 0x0030, + TLS_DH_RSA_WITH_AES_128_CBC_SHA => 0x0031, + TLS_DHE_DSS_WITH_AES_128_CBC_SHA => 0x0032, + TLS_DHE_RSA_WITH_AES_128_CBC_SHA => 0x0033, + TLS_DH_anon_WITH_AES_128_CBC_SHA => 0x0034, + TLS_RSA_WITH_AES_256_CBC_SHA => 0x0035, + TLS_DH_DSS_WITH_AES_256_CBC_SHA => 0x0036, + TLS_DH_RSA_WITH_AES_256_CBC_SHA => 0x0037, + TLS_DHE_DSS_WITH_AES_256_CBC_SHA => 0x0038, + TLS_DHE_RSA_WITH_AES_256_CBC_SHA => 0x0039, + TLS_DH_anon_WITH_AES_256_CBC_SHA => 0x003a, + TLS_RSA_WITH_NULL_SHA256 => 0x003b, + TLS_RSA_WITH_AES_128_CBC_SHA256 => 0x003c, + TLS_RSA_WITH_AES_256_CBC_SHA256 => 0x003d, + TLS_DH_DSS_WITH_AES_128_CBC_SHA256 => 0x003e, + TLS_DH_RSA_WITH_AES_128_CBC_SHA256 => 0x003f, + TLS_DHE_DSS_WITH_AES_128_CBC_SHA256 => 0x0040, + TLS_RSA_WITH_CAMELLIA_128_CBC_SHA => 0x0041, + TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA => 0x0042, + TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA => 0x0043, + TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA => 0x0044, + TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA => 0x0045, + TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA => 0x0046, + TLS_ECDH_ECDSA_WITH_NULL_SHA_draft => 0x0047, + TLS_ECDH_ECDSA_WITH_RC4_128_SHA_draft => 0x0048, + TLS_ECDH_ECDSA_WITH_DES_CBC_SHA_draft => 0x0049, + TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA_draft => 0x004a, + TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA_draft => 0x004b, + TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA_draft => 0x004c, + TLS_ECDH_ECNRA_WITH_DES_CBC_SHA_draft => 0x004d, + TLS_ECDH_ECNRA_WITH_3DES_EDE_CBC_SHA_draft => 0x004e, + TLS_ECMQV_ECDSA_NULL_SHA_draft => 0x004f, + TLS_ECMQV_ECDSA_WITH_RC4_128_SHA_draft => 0x0050, + TLS_ECMQV_ECDSA_WITH_DES_CBC_SHA_draft => 0x0051, + TLS_ECMQV_ECDSA_WITH_3DES_EDE_CBC_SHA_draft => 0x0052, + TLS_ECMQV_ECNRA_NULL_SHA_draft => 0x0053, + TLS_ECMQV_ECNRA_WITH_RC4_128_SHA_draft => 0x0054, + TLS_ECMQV_ECNRA_WITH_DES_CBC_SHA_draft => 0x0055, + TLS_ECMQV_ECNRA_WITH_3DES_EDE_CBC_SHA_draft => 0x0056, + TLS_ECDH_anon_NULL_WITH_SHA_draft => 0x0057, + TLS_ECDH_anon_WITH_RC4_128_SHA_draft => 0x0058, + TLS_ECDH_anon_WITH_DES_CBC_SHA_draft => 0x0059, + TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA_draft => 0x005a, + TLS_ECDH_anon_EXPORT_WITH_DES40_CBC_SHA_draft => 0x005b, + TLS_ECDH_anon_EXPORT_WITH_RC4_40_SHA_draft => 0x005c, + TLS_RSA_EXPORT1024_WITH_RC4_56_MD5 => 0x0060, + TLS_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5 => 0x0061, + TLS_RSA_EXPORT1024_WITH_DES_CBC_SHA => 0x0062, + TLS_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA => 0x0063, + TLS_RSA_EXPORT1024_WITH_RC4_56_SHA => 0x0064, + TLS_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA => 0x0065, + TLS_DHE_DSS_WITH_RC4_128_SHA => 0x0066, + TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 => 0x0067, + TLS_DH_DSS_WITH_AES_256_CBC_SHA256 => 0x0068, + TLS_DH_RSA_WITH_AES_256_CBC_SHA256 => 0x0069, + TLS_DHE_DSS_WITH_AES_256_CBC_SHA256 => 0x006a, + TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 => 0x006b, + TLS_DH_anon_WITH_AES_128_CBC_SHA256 => 0x006c, + TLS_DH_anon_WITH_AES_256_CBC_SHA256 => 0x006d, + TLS_DHE_DSS_WITH_3DES_EDE_CBC_RMD => 0x0072, + TLS_DHE_DSS_WITH_AES_128_CBC_RMD => 0x0073, + TLS_DHE_DSS_WITH_AES_256_CBC_RMD => 0x0074, + TLS_DHE_RSA_WITH_3DES_EDE_CBC_RMD => 0x0077, + TLS_DHE_RSA_WITH_AES_128_CBC_RMD => 0x0078, + TLS_DHE_RSA_WITH_AES_256_CBC_RMD => 0x0079, + TLS_RSA_WITH_3DES_EDE_CBC_RMD => 0x007c, + TLS_RSA_WITH_AES_128_CBC_RMD => 0x007d, + TLS_RSA_WITH_AES_256_CBC_RMD => 0x007e, + TLS_GOSTR341094_WITH_28147_CNT_IMIT => 0x0080, + TLS_GOSTR341001_WITH_28147_CNT_IMIT => 0x0081, + TLS_GOSTR341094_WITH_NULL_GOSTR3411 => 0x0082, + TLS_GOSTR341001_WITH_NULL_GOSTR3411 => 0x0083, + TLS_RSA_WITH_CAMELLIA_256_CBC_SHA => 0x0084, + TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA => 0x0085, + TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA => 0x0086, + TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA => 0x0087, + TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA => 0x0088, + TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA => 0x0089, + TLS_PSK_WITH_RC4_128_SHA => 0x008a, + TLS_PSK_WITH_3DES_EDE_CBC_SHA => 0x008b, + TLS_PSK_WITH_AES_128_CBC_SHA => 0x008c, + TLS_PSK_WITH_AES_256_CBC_SHA => 0x008d, + TLS_DHE_PSK_WITH_RC4_128_SHA => 0x008e, + TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA => 0x008f, + TLS_DHE_PSK_WITH_AES_128_CBC_SHA => 0x0090, + TLS_DHE_PSK_WITH_AES_256_CBC_SHA => 0x0091, + TLS_RSA_PSK_WITH_RC4_128_SHA => 0x0092, + TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA => 0x0093, + TLS_RSA_PSK_WITH_AES_128_CBC_SHA => 0x0094, + TLS_RSA_PSK_WITH_AES_256_CBC_SHA => 0x0095, + TLS_RSA_WITH_SEED_CBC_SHA => 0x0096, + TLS_DH_DSS_WITH_SEED_CBC_SHA => 0x0097, + TLS_DH_RSA_WITH_SEED_CBC_SHA => 0x0098, + TLS_DHE_DSS_WITH_SEED_CBC_SHA => 0x0099, + TLS_DHE_RSA_WITH_SEED_CBC_SHA => 0x009a, + TLS_DH_anon_WITH_SEED_CBC_SHA => 0x009b, + TLS_RSA_WITH_AES_128_GCM_SHA256 => 0x009c, + TLS_RSA_WITH_AES_256_GCM_SHA384 => 0x009d, + TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 => 0x009e, + TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 => 0x009f, + TLS_DH_RSA_WITH_AES_128_GCM_SHA256 => 0x00a0, + TLS_DH_RSA_WITH_AES_256_GCM_SHA384 => 0x00a1, + TLS_DHE_DSS_WITH_AES_128_GCM_SHA256 => 0x00a2, + TLS_DHE_DSS_WITH_AES_256_GCM_SHA384 => 0x00a3, + TLS_DH_DSS_WITH_AES_128_GCM_SHA256 => 0x00a4, + TLS_DH_DSS_WITH_AES_256_GCM_SHA384 => 0x00a5, + TLS_DH_anon_WITH_AES_128_GCM_SHA256 => 0x00a6, + TLS_DH_anon_WITH_AES_256_GCM_SHA384 => 0x00a7, + TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 => 0x00aa, + TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 => 0x00ab, + TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 => 0x00ac, + TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 => 0x00ad, + TLS_PSK_WITH_AES_128_CBC_SHA256 => 0x00ae, + TLS_PSK_WITH_AES_256_CBC_SHA384 => 0x00af, + TLS_PSK_WITH_NULL_SHA256 => 0x00b0, + TLS_PSK_WITH_NULL_SHA384 => 0x00b1, + TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 => 0x00b2, + TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 => 0x00b3, + TLS_DHE_PSK_WITH_NULL_SHA256 => 0x00b4, + TLS_DHE_PSK_WITH_NULL_SHA384 => 0x00b5, + TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 => 0x00b6, + TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 => 0x00b7, + TLS_RSA_PSK_WITH_NULL_SHA256 => 0x00b8, + TLS_RSA_PSK_WITH_NULL_SHA384 => 0x00b9, + TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 => 0x00ba, + TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256 => 0x00bb, + TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256 => 0x00bc, + TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256 => 0x00bd, + TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 => 0x00be, + TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256 => 0x00bf, + TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 => 0x00c0, + TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256 => 0x00c1, + TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256 => 0x00c2, + TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256 => 0x00c3, + TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 => 0x00c4, + TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256 => 0x00c5, + TLS_ECDH_ECDSA_WITH_NULL_SHA => 0xc001, + TLS_ECDH_ECDSA_WITH_RC4_128_SHA => 0xc002, + TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA => 0xc003, + TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA => 0xc004, + TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA => 0xc005, + TLS_ECDHE_ECDSA_WITH_NULL_SHA => 0xc006, + TLS_ECDHE_ECDSA_WITH_RC4_128_SHA => 0xc007, + TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA => 0xc008, + TLS_ECDH_RSA_WITH_NULL_SHA => 0xc00b, + TLS_ECDH_RSA_WITH_RC4_128_SHA => 0xc00c, + TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA => 0xc00d, + TLS_ECDH_RSA_WITH_AES_128_CBC_SHA => 0xc00e, + TLS_ECDH_RSA_WITH_AES_256_CBC_SHA => 0xc00f, + TLS_ECDHE_RSA_WITH_NULL_SHA => 0xc010, + TLS_ECDHE_RSA_WITH_RC4_128_SHA => 0xc011, + TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA => 0xc012, + TLS_ECDH_anon_WITH_NULL_SHA => 0xc015, + TLS_ECDH_anon_WITH_RC4_128_SHA => 0xc016, + TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA => 0xc017, + TLS_ECDH_anon_WITH_AES_128_CBC_SHA => 0xc018, + TLS_ECDH_anon_WITH_AES_256_CBC_SHA => 0xc019, + TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA => 0xc01a, + TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA => 0xc01b, + TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA => 0xc01c, + TLS_SRP_SHA_WITH_AES_128_CBC_SHA => 0xc01d, + TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA => 0xc01e, + TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA => 0xc01f, + TLS_SRP_SHA_WITH_AES_256_CBC_SHA => 0xc020, + TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA => 0xc021, + TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA => 0xc022, + TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 => 0xc025, + TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 => 0xc026, + TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 => 0xc029, + TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 => 0xc02a, + TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 => 0xc02d, + TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 => 0xc02e, + TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 => 0xc031, + TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 => 0xc032, + TLS_ECDHE_PSK_WITH_RC4_128_SHA => 0xc033, + TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA => 0xc034, + TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA => 0xc035, + TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA => 0xc036, + TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 => 0xc037, + TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 => 0xc038, + TLS_ECDHE_PSK_WITH_NULL_SHA => 0xc039, + TLS_ECDHE_PSK_WITH_NULL_SHA256 => 0xc03a, + TLS_ECDHE_PSK_WITH_NULL_SHA384 => 0xc03b, + TLS_RSA_WITH_ARIA_128_CBC_SHA256 => 0xc03c, + TLS_RSA_WITH_ARIA_256_CBC_SHA384 => 0xc03d, + TLS_DH_DSS_WITH_ARIA_128_CBC_SHA256 => 0xc03e, + TLS_DH_DSS_WITH_ARIA_256_CBC_SHA384 => 0xc03f, + TLS_DH_RSA_WITH_ARIA_128_CBC_SHA256 => 0xc040, + TLS_DH_RSA_WITH_ARIA_256_CBC_SHA384 => 0xc041, + TLS_DHE_DSS_WITH_ARIA_128_CBC_SHA256 => 0xc042, + TLS_DHE_DSS_WITH_ARIA_256_CBC_SHA384 => 0xc043, + TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256 => 0xc044, + TLS_DHE_RSA_WITH_ARIA_256_CBC_SHA384 => 0xc045, + TLS_DH_anon_WITH_ARIA_128_CBC_SHA256 => 0xc046, + TLS_DH_anon_WITH_ARIA_256_CBC_SHA384 => 0xc047, + TLS_ECDHE_ECDSA_WITH_ARIA_128_CBC_SHA256 => 0xc048, + TLS_ECDHE_ECDSA_WITH_ARIA_256_CBC_SHA384 => 0xc049, + TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256 => 0xc04a, + TLS_ECDH_ECDSA_WITH_ARIA_256_CBC_SHA384 => 0xc04b, + TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256 => 0xc04c, + TLS_ECDHE_RSA_WITH_ARIA_256_CBC_SHA384 => 0xc04d, + TLS_ECDH_RSA_WITH_ARIA_128_CBC_SHA256 => 0xc04e, + TLS_ECDH_RSA_WITH_ARIA_256_CBC_SHA384 => 0xc04f, + TLS_RSA_WITH_ARIA_128_GCM_SHA256 => 0xc050, + TLS_RSA_WITH_ARIA_256_GCM_SHA384 => 0xc051, + TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256 => 0xc052, + TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384 => 0xc053, + TLS_DH_RSA_WITH_ARIA_128_GCM_SHA256 => 0xc054, + TLS_DH_RSA_WITH_ARIA_256_GCM_SHA384 => 0xc055, + TLS_DHE_DSS_WITH_ARIA_128_GCM_SHA256 => 0xc056, + TLS_DHE_DSS_WITH_ARIA_256_GCM_SHA384 => 0xc057, + TLS_DH_DSS_WITH_ARIA_128_GCM_SHA256 => 0xc058, + TLS_DH_DSS_WITH_ARIA_256_GCM_SHA384 => 0xc059, + TLS_DH_anon_WITH_ARIA_128_GCM_SHA256 => 0xc05a, + TLS_DH_anon_WITH_ARIA_256_GCM_SHA384 => 0xc05b, + TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256 => 0xc05c, + TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384 => 0xc05d, + TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256 => 0xc05e, + TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384 => 0xc05f, + TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256 => 0xc060, + TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384 => 0xc061, + TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256 => 0xc062, + TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384 => 0xc063, + TLS_PSK_WITH_ARIA_128_CBC_SHA256 => 0xc064, + TLS_PSK_WITH_ARIA_256_CBC_SHA384 => 0xc065, + TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256 => 0xc066, + TLS_DHE_PSK_WITH_ARIA_256_CBC_SHA384 => 0xc067, + TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256 => 0xc068, + TLS_RSA_PSK_WITH_ARIA_256_CBC_SHA384 => 0xc069, + TLS_PSK_WITH_ARIA_128_GCM_SHA256 => 0xc06a, + TLS_PSK_WITH_ARIA_256_GCM_SHA384 => 0xc06b, + TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256 => 0xc06c, + TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384 => 0xc06d, + TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256 => 0xc06e, + TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384 => 0xc06f, + TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256 => 0xc070, + TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384 => 0xc071, + TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 => 0xc072, + TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 => 0xc073, + TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 => 0xc074, + TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 => 0xc075, + TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 => 0xc076, + TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 => 0xc077, + TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 => 0xc078, + TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 => 0xc079, + TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256 => 0xc07a, + TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384 => 0xc07b, + TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 => 0xc07c, + TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 => 0xc07d, + TLS_DH_RSA_WITH_CAMELLIA_128_GCM_SHA256 => 0xc07e, + TLS_DH_RSA_WITH_CAMELLIA_256_GCM_SHA384 => 0xc07f, + TLS_DHE_DSS_WITH_CAMELLIA_128_GCM_SHA256 => 0xc080, + TLS_DHE_DSS_WITH_CAMELLIA_256_GCM_SHA384 => 0xc081, + TLS_DH_DSS_WITH_CAMELLIA_128_GCM_SHA256 => 0xc082, + TLS_DH_DSS_WITH_CAMELLIA_256_GCM_SHA384 => 0xc083, + TLS_DH_anon_WITH_CAMELLIA_128_GCM_SHA256 => 0xc084, + TLS_DH_anon_WITH_CAMELLIA_256_GCM_SHA384 => 0xc085, + TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 => 0xc086, + TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 => 0xc087, + TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 => 0xc088, + TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 => 0xc089, + TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 => 0xc08a, + TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 => 0xc08b, + TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 => 0xc08c, + TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 => 0xc08d, + TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 => 0xc08e, + TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384 => 0xc08f, + TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 => 0xc090, + TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 => 0xc091, + TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 => 0xc092, + TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384 => 0xc093, + TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 => 0xc094, + TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384 => 0xc095, + TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 => 0xc096, + TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 => 0xc097, + TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 => 0xc098, + TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 => 0xc099, + TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 => 0xc09a, + TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 => 0xc09b, + TLS_RSA_WITH_AES_128_CCM => 0xc09c, + TLS_RSA_WITH_AES_256_CCM => 0xc09d, + TLS_DHE_RSA_WITH_AES_128_CCM => 0xc09e, + TLS_DHE_RSA_WITH_AES_256_CCM => 0xc09f, + TLS_RSA_WITH_AES_128_CCM_8 => 0xc0a0, + TLS_RSA_WITH_AES_256_CCM_8 => 0xc0a1, + TLS_DHE_RSA_WITH_AES_128_CCM_8 => 0xc0a2, + TLS_DHE_RSA_WITH_AES_256_CCM_8 => 0xc0a3, + TLS_PSK_WITH_AES_128_CCM => 0xc0a4, + TLS_PSK_WITH_AES_256_CCM => 0xc0a5, + TLS_DHE_PSK_WITH_AES_128_CCM => 0xc0a6, + TLS_DHE_PSK_WITH_AES_256_CCM => 0xc0a7, + TLS_PSK_WITH_AES_128_CCM_8 => 0xc0a8, + TLS_PSK_WITH_AES_256_CCM_8 => 0xc0a9, + TLS_PSK_DHE_WITH_AES_128_CCM_8 => 0xc0aa, + TLS_PSK_DHE_WITH_AES_256_CCM_8 => 0xc0ab, + TLS_ECDHE_ECDSA_WITH_AES_128_CCM => 0xc0ac, + TLS_ECDHE_ECDSA_WITH_AES_256_CCM => 0xc0ad, + TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 => 0xc0ae, + TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8 => 0xc0af, + TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256 => 0xccaa, + TLS_PSK_WITH_CHACHA20_POLY1305_SHA256 => 0xccab, + TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256 => 0xccac, + TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256 => 0xccad, + TLS_RSA_PSK_WITH_CHACHA20_POLY1305_SHA256 => 0xccae, + SSL_RSA_FIPS_WITH_DES_CBC_SHA => 0xfefe, + SSL_RSA_FIPS_WITH_3DES_EDE_CBC_SHA => 0xfeff, + } +} + +enum_builder! { + /// The `SignatureScheme` TLS protocol enum. Values in this enum are taken + /// from the various RFCs covering TLS, and are listed by IANA. + /// The `Unknown` item is used when processing unrecognised ordinals. + #[repr(u16)] + pub enum SignatureScheme { + RSA_PKCS1_SHA1 => 0x0201, + ECDSA_SHA1_Legacy => 0x0203, + RSA_PKCS1_SHA256 => 0x0401, + ECDSA_NISTP256_SHA256 => 0x0403, + RSA_PKCS1_SHA384 => 0x0501, + ECDSA_NISTP384_SHA384 => 0x0503, + RSA_PKCS1_SHA512 => 0x0601, + ECDSA_NISTP521_SHA512 => 0x0603, + RSA_PSS_SHA256 => 0x0804, + RSA_PSS_SHA384 => 0x0805, + RSA_PSS_SHA512 => 0x0806, + ED25519 => 0x0807, + ED448 => 0x0808, + // https://datatracker.ietf.org/doc/html/draft-ietf-tls-mldsa-00#name-iana-considerations + ML_DSA_44 => 0x0904, + ML_DSA_65 => 0x0905, + ML_DSA_87 => 0x0906, + } +} + +impl SignatureScheme { + pub(crate) fn algorithm(&self) -> SignatureAlgorithm { + match *self { + Self::RSA_PKCS1_SHA1 + | Self::RSA_PKCS1_SHA256 + | Self::RSA_PKCS1_SHA384 + | Self::RSA_PKCS1_SHA512 + | Self::RSA_PSS_SHA256 + | Self::RSA_PSS_SHA384 + | Self::RSA_PSS_SHA512 => SignatureAlgorithm::RSA, + Self::ECDSA_SHA1_Legacy + | Self::ECDSA_NISTP256_SHA256 + | Self::ECDSA_NISTP384_SHA384 + | Self::ECDSA_NISTP521_SHA512 => SignatureAlgorithm::ECDSA, + Self::ED25519 => SignatureAlgorithm::ED25519, + Self::ED448 => SignatureAlgorithm::ED448, + _ => SignatureAlgorithm::Unknown(0), + } + } + + /// Whether a particular `SignatureScheme` is allowed for TLS protocol signatures + /// in TLS1.3. + /// + /// This prevents (eg) RSA_PKCS1_SHA256 being offered or accepted, even if our + /// verifier supports it for other protocol versions. + /// + /// See RFC8446 s4.2.3: + /// + /// This is a denylist so that newly-allocated `SignatureScheme`s values are + /// allowed in TLS1.3 by default. + pub(crate) fn supported_in_tls13(&self) -> bool { + let [hash, sign] = self.to_array(); + + // This covers both disallowing SHA1 items in `SignatureScheme`, and + // old hash functions. See the section beginning "Legacy algorithms:" + // and item starting "In TLS 1.2, the extension contained hash/signature + // pairs" in RFC8446 section 4.2.3. + match HashAlgorithm::from(hash) { + HashAlgorithm::NONE + | HashAlgorithm::MD5 + | HashAlgorithm::SHA1 + | HashAlgorithm::SHA224 => return false, + _ => (), + }; + + // RSA-PKCS1 is also disallowed for TLS1.3, see the section beginning + // "RSASSA-PKCS1-v1_5 algorithms:" in RFC8446 section 4.2.3. + // + // (nb. SignatureAlgorithm::RSA is RSA-PKCS1, and does not cover RSA-PSS + // or RSAE-PSS.) + // + // This also covers the outlawing of DSA mentioned elsewhere in 4.2.3. + !matches!( + SignatureAlgorithm::from(sign), + SignatureAlgorithm::Anonymous | SignatureAlgorithm::RSA | SignatureAlgorithm::DSA + ) + } +} + +enum_builder! { + /// The `SignatureAlgorithm` TLS protocol enum. Values in this enum are taken + /// from the various RFCs covering TLS, and are listed by IANA. + /// The `Unknown` item is used when processing unrecognised ordinals. + #[repr(u8)] + pub enum SignatureAlgorithm { + Anonymous => 0x00, + RSA => 0x01, + DSA => 0x02, + ECDSA => 0x03, + ED25519 => 0x07, + ED448 => 0x08, + } +} + +enum_builder! { + /// The "TLS Certificate Compression Algorithm IDs" TLS protocol enum. + /// Values in this enum are taken from [RFC8879]. + /// + /// [RFC8879]: https://www.rfc-editor.org/rfc/rfc8879.html#section-7.3 + #[repr(u16)] + pub enum CertificateCompressionAlgorithm { + Zlib => 1, + Brotli => 2, + Zstd => 3, + } +} + +enum_builder! { + /// The `CertificateType` enum sent in the cert_type extensions. + /// Values in this enum are taken from the various RFCs covering TLS, and are listed by IANA. + /// + /// [RFC 6091 Section 5]: + /// [RFC 7250 Section 7]: + #[repr(u8)] + #[derive(Default)] + pub enum CertificateType { + #[default] + X509 => 0x00, + RawPublicKey => 0x02, + } +} + +enum_builder! { + /// The type of Encrypted Client Hello (`EchClientHelloType`). + /// + /// Specified in [draft-ietf-tls-esni Section 5]. + /// + /// [draft-ietf-tls-esni Section 5]: + #[repr(u8)] + pub enum EchClientHelloType { + ClientHelloOuter => 0, + ClientHelloInner => 1 + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::msgs::enums::tests::{test_enum8, test_enum16}; + + #[test] + fn test_enums() { + test_enum8::(SignatureAlgorithm::Anonymous, SignatureAlgorithm::ECDSA); + test_enum8::(ContentType::ChangeCipherSpec, ContentType::Heartbeat); + test_enum8::(HandshakeType::HelloRequest, HandshakeType::MessageHash); + test_enum8::( + AlertDescription::CloseNotify, + AlertDescription::NoApplicationProtocol, + ); + test_enum16::( + CertificateCompressionAlgorithm::Zlib, + CertificateCompressionAlgorithm::Zstd, + ); + test_enum8::(CertificateType::X509, CertificateType::RawPublicKey); + } + + #[test] + fn tls13_signature_restrictions() { + // rsa-pkcs1 denied + assert!(!SignatureScheme::RSA_PKCS1_SHA1.supported_in_tls13()); + assert!(!SignatureScheme::RSA_PKCS1_SHA256.supported_in_tls13()); + assert!(!SignatureScheme::RSA_PKCS1_SHA384.supported_in_tls13()); + assert!(!SignatureScheme::RSA_PKCS1_SHA512.supported_in_tls13()); + + // dsa denied + assert!(!SignatureScheme::from(0x0201).supported_in_tls13()); + assert!(!SignatureScheme::from(0x0202).supported_in_tls13()); + assert!(!SignatureScheme::from(0x0203).supported_in_tls13()); + assert!(!SignatureScheme::from(0x0204).supported_in_tls13()); + assert!(!SignatureScheme::from(0x0205).supported_in_tls13()); + assert!(!SignatureScheme::from(0x0206).supported_in_tls13()); + + // common + assert!(SignatureScheme::ED25519.supported_in_tls13()); + assert!(SignatureScheme::ED448.supported_in_tls13()); + assert!(SignatureScheme::RSA_PSS_SHA256.supported_in_tls13()); + assert!(SignatureScheme::RSA_PSS_SHA384.supported_in_tls13()); + assert!(SignatureScheme::RSA_PSS_SHA512.supported_in_tls13()); + + // rsa_pss_rsae_* + assert!(SignatureScheme::from(0x0804).supported_in_tls13()); + assert!(SignatureScheme::from(0x0805).supported_in_tls13()); + assert!(SignatureScheme::from(0x0806).supported_in_tls13()); + + // ecdsa_brainpool* + assert!(SignatureScheme::from(0x081a).supported_in_tls13()); + assert!(SignatureScheme::from(0x081b).supported_in_tls13()); + assert!(SignatureScheme::from(0x081c).supported_in_tls13()); + } +} diff --git a/http/vendor/rustls/src/error.rs b/http/vendor/rustls/src/error.rs new file mode 100644 index 0000000..3aaf3bb --- /dev/null +++ b/http/vendor/rustls/src/error.rs @@ -0,0 +1,1387 @@ +use alloc::format; +use alloc::string::String; +use alloc::vec::Vec; +use core::fmt; +#[cfg(feature = "std")] +use std::time::SystemTimeError; + +use pki_types::{AlgorithmIdentifier, ServerName, UnixTime}; +use webpki::KeyUsage; + +use crate::enums::{AlertDescription, ContentType, HandshakeType}; +use crate::msgs::handshake::{EchConfigPayload, KeyExchangeAlgorithm}; +use crate::rand; + +/// rustls reports protocol errors using this type. +#[non_exhaustive] +#[derive(Debug, PartialEq, Clone)] +pub enum Error { + /// We received a TLS message that isn't valid right now. + /// `expect_types` lists the message types we can expect right now. + /// `got_type` is the type we found. This error is typically + /// caused by a buggy TLS stack (the peer or this one), a broken + /// network, or an attack. + InappropriateMessage { + /// Which types we expected + expect_types: Vec, + /// What type we received + got_type: ContentType, + }, + + /// We received a TLS handshake message that isn't valid right now. + /// `expect_types` lists the handshake message types we can expect + /// right now. `got_type` is the type we found. + InappropriateHandshakeMessage { + /// Which handshake type we expected + expect_types: Vec, + /// What handshake type we received + got_type: HandshakeType, + }, + + /// An error occurred while handling Encrypted Client Hello (ECH). + InvalidEncryptedClientHello(EncryptedClientHelloError), + + /// The peer sent us a TLS message with invalid contents. + InvalidMessage(InvalidMessage), + + /// The peer didn't give us any certificates. + NoCertificatesPresented, + + /// The certificate verifier doesn't support the given type of name. + UnsupportedNameType, + + /// We couldn't decrypt a message. This is invariably fatal. + DecryptError, + + /// We couldn't encrypt a message because it was larger than the allowed message size. + /// This should never happen if the application is using valid record sizes. + EncryptError, + + /// The peer doesn't support a protocol version/feature we require. + /// The parameter gives a hint as to what version/feature it is. + PeerIncompatible(PeerIncompatible), + + /// The peer deviated from the standard TLS protocol. + /// The parameter gives a hint where. + PeerMisbehaved(PeerMisbehaved), + + /// We received a fatal alert. This means the peer is unhappy. + AlertReceived(AlertDescription), + + /// We saw an invalid certificate. + /// + /// The contained error is from the certificate validation trait + /// implementation. + InvalidCertificate(CertificateError), + + /// A provided certificate revocation list (CRL) was invalid. + InvalidCertRevocationList(CertRevocationListError), + + /// A catch-all error for unlikely errors. + General(String), + + /// We failed to figure out what time it currently is. + FailedToGetCurrentTime, + + /// We failed to acquire random bytes from the system. + FailedToGetRandomBytes, + + /// This function doesn't work until the TLS handshake + /// is complete. + HandshakeNotComplete, + + /// The peer sent an oversized record/fragment. + PeerSentOversizedRecord, + + /// An incoming connection did not support any known application protocol. + NoApplicationProtocol, + + /// The `max_fragment_size` value supplied in configuration was too small, + /// or too large. + BadMaxFragmentSize, + + /// Specific failure cases from [`keys_match`] or a [`crate::crypto::signer::SigningKey`] that cannot produce a corresponding public key. + /// + /// [`keys_match`]: crate::crypto::signer::CertifiedKey::keys_match + InconsistentKeys(InconsistentKeys), + + /// Any other error. + /// + /// This variant should only be used when the error is not better described by a more + /// specific variant. For example, if a custom crypto provider returns a + /// provider specific error. + /// + /// Enums holding this variant will never compare equal to each other. + Other(OtherError), +} + +/// Specific failure cases from [`keys_match`] or a [`crate::crypto::signer::SigningKey`] that cannot produce a corresponding public key. +/// +/// [`keys_match`]: crate::crypto::signer::CertifiedKey::keys_match +#[non_exhaustive] +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub enum InconsistentKeys { + /// The public key returned by the [`SigningKey`] does not match the public key information in the certificate. + /// + /// [`SigningKey`]: crate::crypto::signer::SigningKey + KeyMismatch, + + /// The [`SigningKey`] cannot produce its corresponding public key. + /// + /// [`SigningKey`]: crate::crypto::signer::SigningKey + Unknown, +} + +impl From for Error { + #[inline] + fn from(e: InconsistentKeys) -> Self { + Self::InconsistentKeys(e) + } +} + +/// A corrupt TLS message payload that resulted in an error. +#[non_exhaustive] +#[derive(Debug, Clone, Copy, PartialEq)] +pub enum InvalidMessage { + /// A certificate payload exceeded rustls's 64KB limit + CertificatePayloadTooLarge, + /// An advertised message was larger then expected. + HandshakePayloadTooLarge, + /// The peer sent us a syntactically incorrect ChangeCipherSpec payload. + InvalidCcs, + /// An unknown content type was encountered during message decoding. + InvalidContentType, + /// A peer sent an invalid certificate status type + InvalidCertificateStatusType, + /// Context was incorrectly attached to a certificate request during a handshake. + InvalidCertRequest, + /// A peer's DH params could not be decoded + InvalidDhParams, + /// A message was zero-length when its record kind forbids it. + InvalidEmptyPayload, + /// A peer sent an unexpected key update request. + InvalidKeyUpdate, + /// A peer's server name could not be decoded + InvalidServerName, + /// A TLS message payload was larger then allowed by the specification. + MessageTooLarge, + /// Message is shorter than the expected length + MessageTooShort, + /// Missing data for the named handshake payload value + MissingData(&'static str), + /// A peer did not advertise its supported key exchange groups. + MissingKeyExchange, + /// A peer sent an empty list of signature schemes + NoSignatureSchemes, + /// Trailing data found for the named handshake payload value + TrailingData(&'static str), + /// A peer sent an unexpected message type. + UnexpectedMessage(&'static str), + /// An unknown TLS protocol was encountered during message decoding. + UnknownProtocolVersion, + /// A peer sent a non-null compression method. + UnsupportedCompression, + /// A peer sent an unknown elliptic curve type. + UnsupportedCurveType, + /// A peer sent an unsupported key exchange algorithm. + UnsupportedKeyExchangeAlgorithm(KeyExchangeAlgorithm), + /// A server sent an empty ticket + EmptyTicketValue, + /// A peer sent an empty list of items, but a non-empty list is required. + /// + /// The argument names the context. + IllegalEmptyList(&'static str), + /// A peer sent an empty value, but a non-empty value is required. + IllegalEmptyValue, + /// A peer sent a message where a given extension type was repeated + DuplicateExtension(u16), + /// A peer sent a message with a PSK offer extension in wrong position + PreSharedKeyIsNotFinalExtension, + /// A server sent a HelloRetryRequest with an unknown extension + UnknownHelloRetryRequestExtension, + /// The peer sent a TLS1.3 Certificate with an unknown extension + UnknownCertificateExtension, +} + +impl From for Error { + #[inline] + fn from(e: InvalidMessage) -> Self { + Self::InvalidMessage(e) + } +} + +impl From for AlertDescription { + fn from(e: InvalidMessage) -> Self { + match e { + InvalidMessage::PreSharedKeyIsNotFinalExtension => Self::IllegalParameter, + InvalidMessage::DuplicateExtension(_) => Self::IllegalParameter, + InvalidMessage::UnknownHelloRetryRequestExtension => Self::UnsupportedExtension, + _ => Self::DecodeError, + } + } +} + +#[non_exhaustive] +#[allow(missing_docs)] +#[derive(Debug, PartialEq, Clone)] +/// The set of cases where we failed to make a connection because we thought +/// the peer was misbehaving. +/// +/// This is `non_exhaustive`: we might add or stop using items here in minor +/// versions. We also don't document what they mean. Generally a user of +/// rustls shouldn't vary its behaviour on these error codes, and there is +/// nothing it can do to improve matters. +/// +/// Please file a bug against rustls if you see `Error::PeerMisbehaved` in +/// the wild. +pub enum PeerMisbehaved { + AttemptedDowngradeToTls12WhenTls13IsSupported, + BadCertChainExtensions, + DisallowedEncryptedExtension, + DuplicateClientHelloExtensions, + DuplicateEncryptedExtensions, + DuplicateHelloRetryRequestExtensions, + DuplicateNewSessionTicketExtensions, + DuplicateServerHelloExtensions, + DuplicateServerNameTypes, + EarlyDataAttemptedInSecondClientHello, + EarlyDataExtensionWithoutResumption, + EarlyDataOfferedWithVariedCipherSuite, + HandshakeHashVariedAfterRetry, + IllegalHelloRetryRequestWithEmptyCookie, + IllegalHelloRetryRequestWithNoChanges, + IllegalHelloRetryRequestWithOfferedGroup, + IllegalHelloRetryRequestWithUnofferedCipherSuite, + IllegalHelloRetryRequestWithUnofferedNamedGroup, + IllegalHelloRetryRequestWithUnsupportedVersion, + IllegalHelloRetryRequestWithWrongSessionId, + IllegalHelloRetryRequestWithInvalidEch, + IllegalMiddleboxChangeCipherSpec, + IllegalTlsInnerPlaintext, + IncorrectBinder, + InvalidCertCompression, + InvalidMaxEarlyDataSize, + InvalidKeyShare, + KeyEpochWithPendingFragment, + KeyUpdateReceivedInQuicConnection, + MessageInterleavedWithHandshakeMessage, + MissingBinderInPskExtension, + MissingKeyShare, + MissingPskModesExtension, + MissingQuicTransportParameters, + OfferedDuplicateCertificateCompressions, + OfferedDuplicateKeyShares, + OfferedEarlyDataWithOldProtocolVersion, + OfferedEmptyApplicationProtocol, + OfferedIncorrectCompressions, + PskExtensionMustBeLast, + PskExtensionWithMismatchedIdsAndBinders, + RefusedToFollowHelloRetryRequest, + RejectedEarlyDataInterleavedWithHandshakeMessage, + ResumptionAttemptedWithVariedEms, + ResumptionOfferedWithVariedCipherSuite, + ResumptionOfferedWithVariedEms, + ResumptionOfferedWithIncompatibleCipherSuite, + SelectedDifferentCipherSuiteAfterRetry, + SelectedInvalidPsk, + SelectedTls12UsingTls13VersionExtension, + SelectedUnofferedApplicationProtocol, + SelectedUnofferedCertCompression, + SelectedUnofferedCipherSuite, + SelectedUnofferedCompression, + SelectedUnofferedKxGroup, + SelectedUnofferedPsk, + SelectedUnusableCipherSuiteForVersion, + ServerEchoedCompatibilitySessionId, + ServerHelloMustOfferUncompressedEcPoints, + ServerNameDifferedOnRetry, + ServerNameMustContainOneHostName, + SignedKxWithWrongAlgorithm, + SignedHandshakeWithUnadvertisedSigScheme, + TooManyEmptyFragments, + TooManyKeyUpdateRequests, + TooManyRenegotiationRequests, + TooManyWarningAlertsReceived, + TooMuchEarlyDataReceived, + UnexpectedCleartextExtension, + UnsolicitedCertExtension, + UnsolicitedEncryptedExtension, + UnsolicitedSctList, + UnsolicitedServerHelloExtension, + WrongGroupForKeyShare, + UnsolicitedEchExtension, +} + +impl From for Error { + #[inline] + fn from(e: PeerMisbehaved) -> Self { + Self::PeerMisbehaved(e) + } +} + +#[non_exhaustive] +#[allow(missing_docs)] +#[derive(Debug, PartialEq, Clone)] +/// The set of cases where we failed to make a connection because a peer +/// doesn't support a TLS version/feature we require. +/// +/// This is `non_exhaustive`: we might add or stop using items here in minor +/// versions. +pub enum PeerIncompatible { + EcPointsExtensionRequired, + ExtendedMasterSecretExtensionRequired, + IncorrectCertificateTypeExtension, + KeyShareExtensionRequired, + NamedGroupsExtensionRequired, + NoCertificateRequestSignatureSchemesInCommon, + NoCipherSuitesInCommon, + NoEcPointFormatsInCommon, + NoKxGroupsInCommon, + NoSignatureSchemesInCommon, + NullCompressionRequired, + ServerDoesNotSupportTls12Or13, + ServerSentHelloRetryRequestWithUnknownExtension, + ServerTlsVersionIsDisabledByOurConfig, + SignatureAlgorithmsExtensionRequired, + SupportedVersionsExtensionRequired, + Tls12NotOffered, + Tls12NotOfferedOrEnabled, + Tls13RequiredForQuic, + UncompressedEcPointsRequired, + UnsolicitedCertificateTypeExtension, + ServerRejectedEncryptedClientHello(Option>), +} + +impl From for Error { + #[inline] + fn from(e: PeerIncompatible) -> Self { + Self::PeerIncompatible(e) + } +} + +#[non_exhaustive] +#[derive(Debug, Clone)] +/// The ways in which certificate validators can express errors. +/// +/// Note that the rustls TLS protocol code interprets specifically these +/// error codes to send specific TLS alerts. Therefore, if a +/// custom certificate validator uses incorrect errors the library as +/// a whole will send alerts that do not match the standard (this is usually +/// a minor issue, but could be misleading). +pub enum CertificateError { + /// The certificate is not correctly encoded. + BadEncoding, + + /// The current time is after the `notAfter` time in the certificate. + Expired, + + /// The current time is after the `notAfter` time in the certificate. + /// + /// This variant is semantically the same as `Expired`, but includes + /// extra data to improve error reports. + ExpiredContext { + /// The validation time. + time: UnixTime, + /// The `notAfter` time of the certificate. + not_after: UnixTime, + }, + + /// The current time is before the `notBefore` time in the certificate. + NotValidYet, + + /// The current time is before the `notBefore` time in the certificate. + /// + /// This variant is semantically the same as `NotValidYet`, but includes + /// extra data to improve error reports. + NotValidYetContext { + /// The validation time. + time: UnixTime, + /// The `notBefore` time of the certificate. + not_before: UnixTime, + }, + + /// The certificate has been revoked. + Revoked, + + /// The certificate contains an extension marked critical, but it was + /// not processed by the certificate validator. + UnhandledCriticalExtension, + + /// The certificate chain is not issued by a known root certificate. + UnknownIssuer, + + /// The certificate's revocation status could not be determined. + UnknownRevocationStatus, + + /// The certificate's revocation status could not be determined, because the CRL is expired. + ExpiredRevocationList, + + /// The certificate's revocation status could not be determined, because the CRL is expired. + /// + /// This variant is semantically the same as `ExpiredRevocationList`, but includes + /// extra data to improve error reports. + ExpiredRevocationListContext { + /// The validation time. + time: UnixTime, + /// The nextUpdate time of the CRL. + next_update: UnixTime, + }, + + /// A certificate is not correctly signed by the key of its alleged + /// issuer. + BadSignature, + + /// A signature inside a certificate or on a handshake was made with an unsupported algorithm. + #[deprecated( + since = "0.23.29", + note = "use `UnsupportedSignatureAlgorithmContext` instead" + )] + UnsupportedSignatureAlgorithm, + + /// A signature inside a certificate or on a handshake was made with an unsupported algorithm. + UnsupportedSignatureAlgorithmContext { + /// The signature algorithm OID that was unsupported. + signature_algorithm_id: Vec, + /// Supported algorithms that were available for signature verification. + supported_algorithms: Vec, + }, + + /// A signature was made with an algorithm that doesn't match the relevant public key. + UnsupportedSignatureAlgorithmForPublicKeyContext { + /// The signature algorithm OID. + signature_algorithm_id: Vec, + /// The public key algorithm OID. + public_key_algorithm_id: Vec, + }, + + /// The subject names in an end-entity certificate do not include + /// the expected name. + NotValidForName, + + /// The subject names in an end-entity certificate do not include + /// the expected name. + /// + /// This variant is semantically the same as `NotValidForName`, but includes + /// extra data to improve error reports. + NotValidForNameContext { + /// Expected server name. + expected: ServerName<'static>, + + /// The names presented in the end entity certificate. + /// + /// These are the subject names as present in the leaf certificate and may contain DNS names + /// with or without a wildcard label as well as IP address names. + presented: Vec, + }, + + /// The certificate is being used for a different purpose than allowed. + InvalidPurpose, + + /// The certificate is being used for a different purpose than allowed. + /// + /// This variant is semantically the same as `InvalidPurpose`, but includes + /// extra data to improve error reports. + InvalidPurposeContext { + /// Extended key purpose that was required by the application. + required: ExtendedKeyPurpose, + /// Extended key purposes that were presented in the peer's certificate. + presented: Vec, + }, + + /// The OCSP response provided to the verifier was invalid. + /// + /// This should be returned from [`ServerCertVerifier::verify_server_cert()`] + /// when a verifier checks its `ocsp_response` parameter and finds it invalid. + /// + /// This maps to [`AlertDescription::BadCertificateStatusResponse`]. + /// + /// [`ServerCertVerifier::verify_server_cert()`]: crate::client::danger::ServerCertVerifier::verify_server_cert + InvalidOcspResponse, + + /// The certificate is valid, but the handshake is rejected for other + /// reasons. + ApplicationVerificationFailure, + + /// Any other error. + /// + /// This can be used by custom verifiers to expose the underlying error + /// (where they are not better described by the more specific errors + /// above). + /// + /// It is also used by the default verifier in case its error is + /// not covered by the above common cases. + /// + /// Enums holding this variant will never compare equal to each other. + Other(OtherError), +} + +impl PartialEq for CertificateError { + fn eq(&self, other: &Self) -> bool { + use CertificateError::*; + #[allow(clippy::match_like_matches_macro)] + match (self, other) { + (BadEncoding, BadEncoding) => true, + (Expired, Expired) => true, + ( + ExpiredContext { + time: left_time, + not_after: left_not_after, + }, + ExpiredContext { + time: right_time, + not_after: right_not_after, + }, + ) => (left_time, left_not_after) == (right_time, right_not_after), + (NotValidYet, NotValidYet) => true, + ( + NotValidYetContext { + time: left_time, + not_before: left_not_before, + }, + NotValidYetContext { + time: right_time, + not_before: right_not_before, + }, + ) => (left_time, left_not_before) == (right_time, right_not_before), + (Revoked, Revoked) => true, + (UnhandledCriticalExtension, UnhandledCriticalExtension) => true, + (UnknownIssuer, UnknownIssuer) => true, + (BadSignature, BadSignature) => true, + #[allow(deprecated)] + (UnsupportedSignatureAlgorithm, UnsupportedSignatureAlgorithm) => true, + ( + UnsupportedSignatureAlgorithmContext { + signature_algorithm_id: left_signature_algorithm_id, + supported_algorithms: left_supported_algorithms, + }, + UnsupportedSignatureAlgorithmContext { + signature_algorithm_id: right_signature_algorithm_id, + supported_algorithms: right_supported_algorithms, + }, + ) => { + (left_signature_algorithm_id, left_supported_algorithms) + == (right_signature_algorithm_id, right_supported_algorithms) + } + ( + UnsupportedSignatureAlgorithmForPublicKeyContext { + signature_algorithm_id: left_signature_algorithm_id, + public_key_algorithm_id: left_public_key_algorithm_id, + }, + UnsupportedSignatureAlgorithmForPublicKeyContext { + signature_algorithm_id: right_signature_algorithm_id, + public_key_algorithm_id: right_public_key_algorithm_id, + }, + ) => { + (left_signature_algorithm_id, left_public_key_algorithm_id) + == (right_signature_algorithm_id, right_public_key_algorithm_id) + } + (NotValidForName, NotValidForName) => true, + ( + NotValidForNameContext { + expected: left_expected, + presented: left_presented, + }, + NotValidForNameContext { + expected: right_expected, + presented: right_presented, + }, + ) => (left_expected, left_presented) == (right_expected, right_presented), + (InvalidPurpose, InvalidPurpose) => true, + ( + InvalidPurposeContext { + required: left_required, + presented: left_presented, + }, + InvalidPurposeContext { + required: right_required, + presented: right_presented, + }, + ) => (left_required, left_presented) == (right_required, right_presented), + (InvalidOcspResponse, InvalidOcspResponse) => true, + (ApplicationVerificationFailure, ApplicationVerificationFailure) => true, + (UnknownRevocationStatus, UnknownRevocationStatus) => true, + (ExpiredRevocationList, ExpiredRevocationList) => true, + ( + ExpiredRevocationListContext { + time: left_time, + next_update: left_next_update, + }, + ExpiredRevocationListContext { + time: right_time, + next_update: right_next_update, + }, + ) => (left_time, left_next_update) == (right_time, right_next_update), + _ => false, + } + } +} + +// The following mapping are heavily referenced in: +// * [OpenSSL Implementation](https://github.com/openssl/openssl/blob/45bb98bfa223efd3258f445ad443f878011450f0/ssl/statem/statem_lib.c#L1434) +// * [BoringSSL Implementation](https://github.com/google/boringssl/blob/583c60bd4bf76d61b2634a58bcda99a92de106cb/ssl/ssl_x509.cc#L1323) +impl From for AlertDescription { + fn from(e: CertificateError) -> Self { + use CertificateError::*; + match e { + BadEncoding + | UnhandledCriticalExtension + | NotValidForName + | NotValidForNameContext { .. } => Self::BadCertificate, + // RFC 5246/RFC 8446 + // certificate_expired + // A certificate has expired or **is not currently valid**. + Expired | ExpiredContext { .. } | NotValidYet | NotValidYetContext { .. } => { + Self::CertificateExpired + } + Revoked => Self::CertificateRevoked, + // OpenSSL, BoringSSL and AWS-LC all generate an Unknown CA alert for + // the case where revocation status can not be determined, so we do the same here. + UnknownIssuer + | UnknownRevocationStatus + | ExpiredRevocationList + | ExpiredRevocationListContext { .. } => Self::UnknownCA, + InvalidOcspResponse => Self::BadCertificateStatusResponse, + #[allow(deprecated)] + BadSignature + | UnsupportedSignatureAlgorithm + | UnsupportedSignatureAlgorithmContext { .. } + | UnsupportedSignatureAlgorithmForPublicKeyContext { .. } => Self::DecryptError, + InvalidPurpose | InvalidPurposeContext { .. } => Self::UnsupportedCertificate, + ApplicationVerificationFailure => Self::AccessDenied, + // RFC 5246/RFC 8446 + // certificate_unknown + // Some other (unspecified) issue arose in processing the + // certificate, rendering it unacceptable. + Other(..) => Self::CertificateUnknown, + } + } +} + +impl fmt::Display for CertificateError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + #[cfg(feature = "std")] + Self::NotValidForNameContext { + expected, + presented, + } => { + write!( + f, + "certificate not valid for name {:?}; certificate ", + expected.to_str() + )?; + + match presented.as_slice() { + &[] => write!( + f, + "is not valid for any names (according to its subjectAltName extension)" + ), + [one] => write!(f, "is only valid for {one}"), + many => { + write!(f, "is only valid for ")?; + + let n = many.len(); + let all_but_last = &many[..n - 1]; + let last = &many[n - 1]; + + for (i, name) in all_but_last.iter().enumerate() { + write!(f, "{name}")?; + if i < n - 2 { + write!(f, ", ")?; + } + } + write!(f, " or {last}") + } + } + } + + Self::ExpiredContext { time, not_after } => write!( + f, + "certificate expired: verification time {} (UNIX), \ + but certificate is not valid after {} \ + ({} seconds ago)", + time.as_secs(), + not_after.as_secs(), + time.as_secs() + .saturating_sub(not_after.as_secs()) + ), + + Self::NotValidYetContext { time, not_before } => write!( + f, + "certificate not valid yet: verification time {} (UNIX), \ + but certificate is not valid before {} \ + ({} seconds in future)", + time.as_secs(), + not_before.as_secs(), + not_before + .as_secs() + .saturating_sub(time.as_secs()) + ), + + Self::ExpiredRevocationListContext { time, next_update } => write!( + f, + "certificate revocation list expired: \ + verification time {} (UNIX), \ + but CRL is not valid after {} \ + ({} seconds ago)", + time.as_secs(), + next_update.as_secs(), + time.as_secs() + .saturating_sub(next_update.as_secs()) + ), + + Self::InvalidPurposeContext { + required, + presented, + } => { + write!( + f, + "certificate does not allow extended key usage for {required}, allows " + )?; + for (i, eku) in presented.iter().enumerate() { + if i > 0 { + write!(f, ", ")?; + } + write!(f, "{eku}")?; + } + Ok(()) + } + + other => write!(f, "{other:?}"), + } + } +} + +impl From for Error { + #[inline] + fn from(e: CertificateError) -> Self { + Self::InvalidCertificate(e) + } +} + +/// Extended Key Usage (EKU) purpose values. +/// +/// These are usually represented as OID values in the certificate's extension (if present), but +/// we represent the values that are most relevant to rustls as named enum variants. +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum ExtendedKeyPurpose { + /// Client authentication + ClientAuth, + /// Server authentication + ServerAuth, + /// Other EKU values + /// + /// Represented here as a `Vec` for human readability. + Other(Vec), +} + +impl ExtendedKeyPurpose { + pub(crate) fn for_values(values: impl Iterator) -> Self { + let values = values.collect::>(); + match &*values { + KeyUsage::CLIENT_AUTH_REPR => Self::ClientAuth, + KeyUsage::SERVER_AUTH_REPR => Self::ServerAuth, + _ => Self::Other(values), + } + } +} + +impl fmt::Display for ExtendedKeyPurpose { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::ClientAuth => write!(f, "client authentication"), + Self::ServerAuth => write!(f, "server authentication"), + Self::Other(values) => { + for (i, value) in values.iter().enumerate() { + if i > 0 { + write!(f, ", ")?; + } + write!(f, "{value}")?; + } + Ok(()) + } + } + } +} + +#[non_exhaustive] +#[derive(Debug, Clone)] +/// The ways in which a certificate revocation list (CRL) can be invalid. +pub enum CertRevocationListError { + /// The CRL had a bad signature from its issuer. + BadSignature, + + /// The CRL had an unsupported signature from its issuer. + #[deprecated( + since = "0.23.29", + note = "use `UnsupportedSignatureAlgorithmContext` instead" + )] + UnsupportedSignatureAlgorithm, + + /// A signature inside a certificate or on a handshake was made with an unsupported algorithm. + UnsupportedSignatureAlgorithmContext { + /// The signature algorithm OID that was unsupported. + signature_algorithm_id: Vec, + /// Supported algorithms that were available for signature verification. + supported_algorithms: Vec, + }, + + /// A signature was made with an algorithm that doesn't match the relevant public key. + UnsupportedSignatureAlgorithmForPublicKeyContext { + /// The signature algorithm OID. + signature_algorithm_id: Vec, + /// The public key algorithm OID. + public_key_algorithm_id: Vec, + }, + + /// The CRL contained an invalid CRL number. + InvalidCrlNumber, + + /// The CRL contained a revoked certificate with an invalid serial number. + InvalidRevokedCertSerialNumber, + + /// The CRL issuer does not specify the cRLSign key usage. + IssuerInvalidForCrl, + + /// The CRL is invalid for some other reason. + /// + /// Enums holding this variant will never compare equal to each other. + Other(OtherError), + + /// The CRL is not correctly encoded. + ParseError, + + /// The CRL is not a v2 X.509 CRL. + UnsupportedCrlVersion, + + /// The CRL, or a revoked certificate in the CRL, contained an unsupported critical extension. + UnsupportedCriticalExtension, + + /// The CRL is an unsupported delta CRL, containing only changes relative to another CRL. + UnsupportedDeltaCrl, + + /// The CRL is an unsupported indirect CRL, containing revoked certificates issued by a CA + /// other than the issuer of the CRL. + UnsupportedIndirectCrl, + + /// The CRL contained a revoked certificate with an unsupported revocation reason. + /// See RFC 5280 Section 5.3.1[^1] for a list of supported revocation reasons. + /// + /// [^1]: + UnsupportedRevocationReason, +} + +impl PartialEq for CertRevocationListError { + fn eq(&self, other: &Self) -> bool { + use CertRevocationListError::*; + #[allow(clippy::match_like_matches_macro)] + match (self, other) { + (BadSignature, BadSignature) => true, + #[allow(deprecated)] + (UnsupportedSignatureAlgorithm, UnsupportedSignatureAlgorithm) => true, + ( + UnsupportedSignatureAlgorithmContext { + signature_algorithm_id: left_signature_algorithm_id, + supported_algorithms: left_supported_algorithms, + }, + UnsupportedSignatureAlgorithmContext { + signature_algorithm_id: right_signature_algorithm_id, + supported_algorithms: right_supported_algorithms, + }, + ) => { + (left_signature_algorithm_id, left_supported_algorithms) + == (right_signature_algorithm_id, right_supported_algorithms) + } + ( + UnsupportedSignatureAlgorithmForPublicKeyContext { + signature_algorithm_id: left_signature_algorithm_id, + public_key_algorithm_id: left_public_key_algorithm_id, + }, + UnsupportedSignatureAlgorithmForPublicKeyContext { + signature_algorithm_id: right_signature_algorithm_id, + public_key_algorithm_id: right_public_key_algorithm_id, + }, + ) => { + (left_signature_algorithm_id, left_public_key_algorithm_id) + == (right_signature_algorithm_id, right_public_key_algorithm_id) + } + (InvalidCrlNumber, InvalidCrlNumber) => true, + (InvalidRevokedCertSerialNumber, InvalidRevokedCertSerialNumber) => true, + (IssuerInvalidForCrl, IssuerInvalidForCrl) => true, + (ParseError, ParseError) => true, + (UnsupportedCrlVersion, UnsupportedCrlVersion) => true, + (UnsupportedCriticalExtension, UnsupportedCriticalExtension) => true, + (UnsupportedDeltaCrl, UnsupportedDeltaCrl) => true, + (UnsupportedIndirectCrl, UnsupportedIndirectCrl) => true, + (UnsupportedRevocationReason, UnsupportedRevocationReason) => true, + _ => false, + } + } +} + +impl From for Error { + #[inline] + fn from(e: CertRevocationListError) -> Self { + Self::InvalidCertRevocationList(e) + } +} + +#[non_exhaustive] +#[derive(Debug, Clone, Eq, PartialEq)] +/// An error that occurred while handling Encrypted Client Hello (ECH). +pub enum EncryptedClientHelloError { + /// The provided ECH configuration list was invalid. + InvalidConfigList, + /// No compatible ECH configuration. + NoCompatibleConfig, + /// The client configuration has server name indication (SNI) disabled. + SniRequired, +} + +impl From for Error { + #[inline] + fn from(e: EncryptedClientHelloError) -> Self { + Self::InvalidEncryptedClientHello(e) + } +} + +fn join(items: &[T]) -> String { + items + .iter() + .map(|x| format!("{x:?}")) + .collect::>() + .join(" or ") +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::InappropriateMessage { + expect_types, + got_type, + } => write!( + f, + "received unexpected message: got {:?} when expecting {}", + got_type, + join::(expect_types) + ), + Self::InappropriateHandshakeMessage { + expect_types, + got_type, + } => write!( + f, + "received unexpected handshake message: got {:?} when expecting {}", + got_type, + join::(expect_types) + ), + Self::InvalidMessage(typ) => { + write!(f, "received corrupt message of type {typ:?}") + } + Self::PeerIncompatible(why) => write!(f, "peer is incompatible: {why:?}"), + Self::PeerMisbehaved(why) => write!(f, "peer misbehaved: {why:?}"), + Self::AlertReceived(alert) => write!(f, "received fatal alert: {alert:?}"), + Self::InvalidCertificate(err) => { + write!(f, "invalid peer certificate: {err}") + } + Self::InvalidCertRevocationList(err) => { + write!(f, "invalid certificate revocation list: {err:?}") + } + Self::NoCertificatesPresented => write!(f, "peer sent no certificates"), + Self::UnsupportedNameType => write!(f, "presented server name type wasn't supported"), + Self::DecryptError => write!(f, "cannot decrypt peer's message"), + Self::InvalidEncryptedClientHello(err) => { + write!(f, "encrypted client hello failure: {err:?}") + } + Self::EncryptError => write!(f, "cannot encrypt message"), + Self::PeerSentOversizedRecord => write!(f, "peer sent excess record size"), + Self::HandshakeNotComplete => write!(f, "handshake not complete"), + Self::NoApplicationProtocol => write!(f, "peer doesn't support any known protocol"), + Self::FailedToGetCurrentTime => write!(f, "failed to get current time"), + Self::FailedToGetRandomBytes => write!(f, "failed to get random bytes"), + Self::BadMaxFragmentSize => { + write!(f, "the supplied max_fragment_size was too small or large") + } + Self::InconsistentKeys(why) => { + write!(f, "keys may not be consistent: {why:?}") + } + Self::General(err) => write!(f, "unexpected error: {err}"), + Self::Other(err) => write!(f, "other error: {err}"), + } + } +} + +#[cfg(feature = "std")] +impl From for Error { + #[inline] + fn from(_: SystemTimeError) -> Self { + Self::FailedToGetCurrentTime + } +} + +#[cfg(feature = "std")] +impl std::error::Error for Error {} + +impl From for Error { + fn from(_: rand::GetRandomFailed) -> Self { + Self::FailedToGetRandomBytes + } +} + +mod other_error { + use core::fmt; + #[cfg(feature = "std")] + use std::error::Error as StdError; + + use super::Error; + #[cfg(feature = "std")] + use crate::sync::Arc; + + /// Any other error that cannot be expressed by a more specific [`Error`] variant. + /// + /// For example, an `OtherError` could be produced by a custom crypto provider + /// exposing a provider specific error. + /// + /// Enums holding this type will never compare equal to each other. + #[derive(Debug, Clone)] + pub struct OtherError(#[cfg(feature = "std")] pub Arc); + + impl PartialEq for OtherError { + fn eq(&self, _other: &Self) -> bool { + false + } + } + + impl From for Error { + fn from(value: OtherError) -> Self { + Self::Other(value) + } + } + + impl fmt::Display for OtherError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + #[cfg(feature = "std")] + { + write!(f, "{}", self.0) + } + #[cfg(not(feature = "std"))] + { + f.write_str("no further information available") + } + } + } + + #[cfg(feature = "std")] + impl StdError for OtherError { + fn source(&self) -> Option<&(dyn StdError + 'static)> { + Some(self.0.as_ref()) + } + } +} + +pub use other_error::OtherError; + +#[cfg(test)] +mod tests { + use core::time::Duration; + use std::prelude::v1::*; + use std::{println, vec}; + + use pki_types::ServerName; + + use super::{ + CertRevocationListError, Error, InconsistentKeys, InvalidMessage, OtherError, UnixTime, + }; + #[cfg(feature = "std")] + use crate::sync::Arc; + + #[test] + fn certificate_error_equality() { + use super::CertificateError::*; + assert_eq!(BadEncoding, BadEncoding); + assert_eq!(Expired, Expired); + let context = ExpiredContext { + time: UnixTime::since_unix_epoch(Duration::from_secs(1234)), + not_after: UnixTime::since_unix_epoch(Duration::from_secs(123)), + }; + assert_eq!(context, context); + assert_ne!( + context, + ExpiredContext { + time: UnixTime::since_unix_epoch(Duration::from_secs(12345)), + not_after: UnixTime::since_unix_epoch(Duration::from_secs(123)), + } + ); + assert_ne!( + context, + ExpiredContext { + time: UnixTime::since_unix_epoch(Duration::from_secs(1234)), + not_after: UnixTime::since_unix_epoch(Duration::from_secs(1234)), + } + ); + assert_eq!(NotValidYet, NotValidYet); + let context = NotValidYetContext { + time: UnixTime::since_unix_epoch(Duration::from_secs(123)), + not_before: UnixTime::since_unix_epoch(Duration::from_secs(1234)), + }; + assert_eq!(context, context); + assert_ne!( + context, + NotValidYetContext { + time: UnixTime::since_unix_epoch(Duration::from_secs(1234)), + not_before: UnixTime::since_unix_epoch(Duration::from_secs(1234)), + } + ); + assert_ne!( + context, + NotValidYetContext { + time: UnixTime::since_unix_epoch(Duration::from_secs(123)), + not_before: UnixTime::since_unix_epoch(Duration::from_secs(12345)), + } + ); + assert_eq!(Revoked, Revoked); + assert_eq!(UnhandledCriticalExtension, UnhandledCriticalExtension); + assert_eq!(UnknownIssuer, UnknownIssuer); + assert_eq!(ExpiredRevocationList, ExpiredRevocationList); + assert_eq!(UnknownRevocationStatus, UnknownRevocationStatus); + let context = ExpiredRevocationListContext { + time: UnixTime::since_unix_epoch(Duration::from_secs(1234)), + next_update: UnixTime::since_unix_epoch(Duration::from_secs(123)), + }; + assert_eq!(context, context); + assert_ne!( + context, + ExpiredRevocationListContext { + time: UnixTime::since_unix_epoch(Duration::from_secs(12345)), + next_update: UnixTime::since_unix_epoch(Duration::from_secs(123)), + } + ); + assert_ne!( + context, + ExpiredRevocationListContext { + time: UnixTime::since_unix_epoch(Duration::from_secs(1234)), + next_update: UnixTime::since_unix_epoch(Duration::from_secs(1234)), + } + ); + assert_eq!(BadSignature, BadSignature); + #[allow(deprecated)] + { + assert_eq!(UnsupportedSignatureAlgorithm, UnsupportedSignatureAlgorithm); + } + assert_eq!( + UnsupportedSignatureAlgorithmContext { + signature_algorithm_id: vec![1, 2, 3], + supported_algorithms: vec![] + }, + UnsupportedSignatureAlgorithmContext { + signature_algorithm_id: vec![1, 2, 3], + supported_algorithms: vec![] + } + ); + assert_eq!( + UnsupportedSignatureAlgorithmForPublicKeyContext { + signature_algorithm_id: vec![1, 2, 3], + public_key_algorithm_id: vec![4, 5, 6] + }, + UnsupportedSignatureAlgorithmForPublicKeyContext { + signature_algorithm_id: vec![1, 2, 3], + public_key_algorithm_id: vec![4, 5, 6] + } + ); + assert_eq!(NotValidForName, NotValidForName); + let context = NotValidForNameContext { + expected: ServerName::try_from("example.com") + .unwrap() + .to_owned(), + presented: vec!["other.com".into()], + }; + assert_eq!(context, context); + assert_ne!( + context, + NotValidForNameContext { + expected: ServerName::try_from("example.com") + .unwrap() + .to_owned(), + presented: vec![] + } + ); + assert_ne!( + context, + NotValidForNameContext { + expected: ServerName::try_from("huh.com") + .unwrap() + .to_owned(), + presented: vec!["other.com".into()], + } + ); + assert_eq!(InvalidPurpose, InvalidPurpose); + assert_eq!( + ApplicationVerificationFailure, + ApplicationVerificationFailure + ); + assert_eq!(InvalidOcspResponse, InvalidOcspResponse); + let other = Other(OtherError( + #[cfg(feature = "std")] + Arc::from(Box::from("")), + )); + assert_ne!(other, other); + assert_ne!(BadEncoding, Expired); + } + + #[test] + fn crl_error_equality() { + use super::CertRevocationListError::*; + assert_eq!(BadSignature, BadSignature); + #[allow(deprecated)] + { + assert_eq!(UnsupportedSignatureAlgorithm, UnsupportedSignatureAlgorithm); + } + assert_eq!( + UnsupportedSignatureAlgorithmContext { + signature_algorithm_id: vec![1, 2, 3], + supported_algorithms: vec![] + }, + UnsupportedSignatureAlgorithmContext { + signature_algorithm_id: vec![1, 2, 3], + supported_algorithms: vec![] + } + ); + assert_eq!( + UnsupportedSignatureAlgorithmForPublicKeyContext { + signature_algorithm_id: vec![1, 2, 3], + public_key_algorithm_id: vec![4, 5, 6] + }, + UnsupportedSignatureAlgorithmForPublicKeyContext { + signature_algorithm_id: vec![1, 2, 3], + public_key_algorithm_id: vec![4, 5, 6] + } + ); + assert_eq!(InvalidCrlNumber, InvalidCrlNumber); + assert_eq!( + InvalidRevokedCertSerialNumber, + InvalidRevokedCertSerialNumber + ); + assert_eq!(IssuerInvalidForCrl, IssuerInvalidForCrl); + assert_eq!(ParseError, ParseError); + assert_eq!(UnsupportedCriticalExtension, UnsupportedCriticalExtension); + assert_eq!(UnsupportedCrlVersion, UnsupportedCrlVersion); + assert_eq!(UnsupportedDeltaCrl, UnsupportedDeltaCrl); + assert_eq!(UnsupportedIndirectCrl, UnsupportedIndirectCrl); + assert_eq!(UnsupportedRevocationReason, UnsupportedRevocationReason); + let other = Other(OtherError( + #[cfg(feature = "std")] + Arc::from(Box::from("")), + )); + assert_ne!(other, other); + assert_ne!(BadSignature, InvalidCrlNumber); + } + + #[test] + #[cfg(feature = "std")] + fn other_error_equality() { + let other_error = OtherError(Arc::from(Box::from(""))); + assert_ne!(other_error, other_error); + let other: Error = other_error.into(); + assert_ne!(other, other); + } + + #[test] + fn smoke() { + use crate::enums::{AlertDescription, ContentType, HandshakeType}; + + let all = vec![ + Error::InappropriateMessage { + expect_types: vec![ContentType::Alert], + got_type: ContentType::Handshake, + }, + Error::InappropriateHandshakeMessage { + expect_types: vec![HandshakeType::ClientHello, HandshakeType::Finished], + got_type: HandshakeType::ServerHello, + }, + Error::InvalidMessage(InvalidMessage::InvalidCcs), + Error::NoCertificatesPresented, + Error::DecryptError, + super::PeerIncompatible::Tls12NotOffered.into(), + super::PeerMisbehaved::UnsolicitedCertExtension.into(), + Error::AlertReceived(AlertDescription::ExportRestriction), + super::CertificateError::Expired.into(), + super::CertificateError::NotValidForNameContext { + expected: ServerName::try_from("example.com") + .unwrap() + .to_owned(), + presented: vec![], + } + .into(), + super::CertificateError::NotValidForNameContext { + expected: ServerName::try_from("example.com") + .unwrap() + .to_owned(), + presented: vec!["DnsName(\"hello.com\")".into()], + } + .into(), + super::CertificateError::NotValidForNameContext { + expected: ServerName::try_from("example.com") + .unwrap() + .to_owned(), + presented: vec![ + "DnsName(\"hello.com\")".into(), + "DnsName(\"goodbye.com\")".into(), + ], + } + .into(), + super::CertificateError::NotValidYetContext { + time: UnixTime::since_unix_epoch(Duration::from_secs(300)), + not_before: UnixTime::since_unix_epoch(Duration::from_secs(320)), + } + .into(), + super::CertificateError::ExpiredContext { + time: UnixTime::since_unix_epoch(Duration::from_secs(320)), + not_after: UnixTime::since_unix_epoch(Duration::from_secs(300)), + } + .into(), + super::CertificateError::ExpiredRevocationListContext { + time: UnixTime::since_unix_epoch(Duration::from_secs(320)), + next_update: UnixTime::since_unix_epoch(Duration::from_secs(300)), + } + .into(), + super::CertificateError::InvalidOcspResponse.into(), + Error::General("undocumented error".to_string()), + Error::FailedToGetCurrentTime, + Error::FailedToGetRandomBytes, + Error::HandshakeNotComplete, + Error::PeerSentOversizedRecord, + Error::NoApplicationProtocol, + Error::BadMaxFragmentSize, + Error::InconsistentKeys(InconsistentKeys::KeyMismatch), + Error::InconsistentKeys(InconsistentKeys::Unknown), + Error::InvalidCertRevocationList(CertRevocationListError::BadSignature), + Error::Other(OtherError( + #[cfg(feature = "std")] + Arc::from(Box::from("")), + )), + ]; + + for err in all { + println!("{err:?}:"); + println!(" fmt '{err}'"); + } + } + + #[test] + fn rand_error_mapping() { + use super::rand; + let err: Error = rand::GetRandomFailed.into(); + assert_eq!(err, Error::FailedToGetRandomBytes); + } + + #[cfg(feature = "std")] + #[test] + fn time_error_mapping() { + use std::time::SystemTime; + + let time_error = SystemTime::UNIX_EPOCH + .duration_since(SystemTime::now()) + .unwrap_err(); + let err: Error = time_error.into(); + assert_eq!(err, Error::FailedToGetCurrentTime); + } +} diff --git a/http/vendor/rustls/src/hash_hs.rs b/http/vendor/rustls/src/hash_hs.rs new file mode 100644 index 0000000..8b4edc6 --- /dev/null +++ b/http/vendor/rustls/src/hash_hs.rs @@ -0,0 +1,347 @@ +use alloc::boxed::Box; +use alloc::vec::Vec; +use core::mem; + +use crate::crypto::hash; +use crate::msgs::codec::Codec; +use crate::msgs::enums::HashAlgorithm; +use crate::msgs::handshake::HandshakeMessagePayload; +use crate::msgs::message::{Message, MessagePayload}; + +/// Early stage buffering of handshake payloads. +/// +/// Before we know the hash algorithm to use to verify the handshake, we just buffer the messages. +/// During the handshake, we may restart the transcript due to a HelloRetryRequest, reverting +/// from the `HandshakeHash` to a `HandshakeHashBuffer` again. +#[derive(Clone)] +pub(crate) struct HandshakeHashBuffer { + buffer: Vec, + client_auth_enabled: bool, +} + +impl HandshakeHashBuffer { + pub(crate) fn new() -> Self { + Self { + buffer: Vec::new(), + client_auth_enabled: false, + } + } + + /// We might be doing client auth, so need to keep a full + /// log of the handshake. + pub(crate) fn set_client_auth_enabled(&mut self) { + self.client_auth_enabled = true; + } + + /// Hash/buffer a handshake message. + pub(crate) fn add_message(&mut self, m: &Message<'_>) { + match &m.payload { + MessagePayload::Handshake { encoded, .. } => self.add_raw(encoded.bytes()), + MessagePayload::HandshakeFlight(payload) => self.add_raw(payload.bytes()), + _ => {} + }; + } + + /// Hash or buffer a byte slice. + fn add_raw(&mut self, buf: &[u8]) { + self.buffer.extend_from_slice(buf); + } + + /// Get the hash value if we were to hash `extra` too. + pub(crate) fn hash_given( + &self, + provider: &'static dyn hash::Hash, + extra: &[u8], + ) -> hash::Output { + let mut ctx = provider.start(); + ctx.update(&self.buffer); + ctx.update(extra); + ctx.finish() + } + + /// We now know what hash function the verify_data will use. + pub(crate) fn start_hash(self, provider: &'static dyn hash::Hash) -> HandshakeHash { + let mut ctx = provider.start(); + ctx.update(&self.buffer); + HandshakeHash { + provider, + ctx, + client_auth: match self.client_auth_enabled { + true => Some(self.buffer), + false => None, + }, + } + } +} + +/// This deals with keeping a running hash of the handshake +/// payloads. This is computed by buffering initially. Once +/// we know what hash function we need to use we switch to +/// incremental hashing. +/// +/// For client auth, we also need to buffer all the messages. +/// This is disabled in cases where client auth is not possible. +pub(crate) struct HandshakeHash { + provider: &'static dyn hash::Hash, + ctx: Box, + + /// buffer for client-auth. + client_auth: Option>, +} + +impl HandshakeHash { + /// We decided not to do client auth after all, so discard + /// the transcript. + pub(crate) fn abandon_client_auth(&mut self) { + self.client_auth = None; + } + + /// Hash/buffer a handshake message. + pub(crate) fn add_message(&mut self, m: &Message<'_>) -> &mut Self { + match &m.payload { + MessagePayload::Handshake { encoded, .. } => self.add_raw(encoded.bytes()), + MessagePayload::HandshakeFlight(payload) => self.add_raw(payload.bytes()), + _ => self, + } + } + + /// Hash/buffer an encoded handshake message. + pub(crate) fn add(&mut self, bytes: &[u8]) { + self.add_raw(bytes); + } + + /// Hash or buffer a byte slice. + fn add_raw(&mut self, buf: &[u8]) -> &mut Self { + self.ctx.update(buf); + + if let Some(buffer) = &mut self.client_auth { + buffer.extend_from_slice(buf); + } + + self + } + + /// Get the hash value if we were to hash `extra` too, + /// using hash function `hash`. + pub(crate) fn hash_given(&self, extra: &[u8]) -> hash::Output { + let mut ctx = self.ctx.fork(); + ctx.update(extra); + ctx.finish() + } + + pub(crate) fn into_hrr_buffer(self) -> HandshakeHashBuffer { + let old_hash = self.ctx.finish(); + let old_handshake_hash_msg = + HandshakeMessagePayload::build_handshake_hash(old_hash.as_ref()); + + HandshakeHashBuffer { + client_auth_enabled: self.client_auth.is_some(), + buffer: old_handshake_hash_msg.get_encoding(), + } + } + + /// Take the current hash value, and encapsulate it in a + /// 'handshake_hash' handshake message. Start this hash + /// again, with that message at the front. + pub(crate) fn rollup_for_hrr(&mut self) { + let ctx = &mut self.ctx; + + let old_ctx = mem::replace(ctx, self.provider.start()); + let old_hash = old_ctx.finish(); + let old_handshake_hash_msg = + HandshakeMessagePayload::build_handshake_hash(old_hash.as_ref()); + + self.add_raw(&old_handshake_hash_msg.get_encoding()); + } + + /// Get the current hash value. + pub(crate) fn current_hash(&self) -> hash::Output { + self.ctx.fork_finish() + } + + /// Takes this object's buffer containing all handshake messages + /// so far. This method only works once; it resets the buffer + /// to empty. + #[cfg(feature = "tls12")] + pub(crate) fn take_handshake_buf(&mut self) -> Option> { + self.client_auth.take() + } + + /// The hashing algorithm + pub(crate) fn algorithm(&self) -> HashAlgorithm { + self.provider.algorithm() + } +} + +impl Clone for HandshakeHash { + fn clone(&self) -> Self { + Self { + provider: self.provider, + ctx: self.ctx.fork(), + client_auth: self.client_auth.clone(), + } + } +} + +#[cfg(test)] +#[macro_rules_attribute::apply(test_for_each_provider)] +mod tests { + use super::provider::hash::SHA256; + use super::*; + use crate::crypto::hash::Hash; + use crate::enums::ProtocolVersion; + use crate::msgs::base::Payload; + use crate::msgs::handshake::{HandshakeMessagePayload, HandshakePayload}; + + #[test] + fn hashes_correctly() { + let mut hhb = HandshakeHashBuffer::new(); + hhb.add_raw(b"hello"); + assert_eq!(hhb.buffer.len(), 5); + let mut hh = hhb.start_hash(&SHA256); + assert!(hh.client_auth.is_none()); + hh.add_raw(b"world"); + let h = hh.current_hash(); + let h = h.as_ref(); + assert_eq!(h[0], 0x93); + assert_eq!(h[1], 0x6a); + assert_eq!(h[2], 0x18); + assert_eq!(h[3], 0x5c); + } + + #[test] + fn hashes_message_types() { + // handshake protocol encoding of 0x0e 00 00 00 + let server_hello_done_message = Message { + version: ProtocolVersion::TLSv1_2, + payload: MessagePayload::handshake(HandshakeMessagePayload( + HandshakePayload::ServerHelloDone, + )), + }; + + let app_data_ignored = Message { + version: ProtocolVersion::TLSv1_3, + payload: MessagePayload::ApplicationData(Payload::Borrowed(b"hello")), + }; + + let end_of_early_data_flight = Message { + version: ProtocolVersion::TLSv1_3, + payload: MessagePayload::HandshakeFlight(Payload::Borrowed(b"\x05\x00\x00\x00")), + }; + + // buffered mode + let mut hhb = HandshakeHashBuffer::new(); + hhb.add_message(&server_hello_done_message); + hhb.add_message(&app_data_ignored); + hhb.add_message(&end_of_early_data_flight); + assert_eq!( + hhb.start_hash(&SHA256) + .current_hash() + .as_ref(), + SHA256 + .hash(b"\x0e\x00\x00\x00\x05\x00\x00\x00") + .as_ref() + ); + + // non-buffered mode + let mut hh = HandshakeHashBuffer::new().start_hash(&SHA256); + hh.add_message(&server_hello_done_message); + hh.add_message(&app_data_ignored); + hh.add_message(&end_of_early_data_flight); + assert_eq!( + hh.current_hash().as_ref(), + SHA256 + .hash(b"\x0e\x00\x00\x00\x05\x00\x00\x00") + .as_ref() + ); + } + + #[cfg(feature = "tls12")] + #[test] + fn buffers_correctly() { + let mut hhb = HandshakeHashBuffer::new(); + hhb.set_client_auth_enabled(); + hhb.add_raw(b"hello"); + assert_eq!(hhb.buffer.len(), 5); + let mut hh = hhb.start_hash(&SHA256); + assert_eq!( + hh.client_auth + .as_ref() + .map(|buf| buf.len()), + Some(5) + ); + hh.add_raw(b"world"); + assert_eq!( + hh.client_auth + .as_ref() + .map(|buf| buf.len()), + Some(10) + ); + let h = hh.current_hash(); + let h = h.as_ref(); + assert_eq!(h[0], 0x93); + assert_eq!(h[1], 0x6a); + assert_eq!(h[2], 0x18); + assert_eq!(h[3], 0x5c); + let buf = hh.take_handshake_buf(); + assert_eq!(Some(b"helloworld".to_vec()), buf); + } + + #[test] + fn abandon() { + let mut hhb = HandshakeHashBuffer::new(); + hhb.set_client_auth_enabled(); + hhb.add_raw(b"hello"); + assert_eq!(hhb.buffer.len(), 5); + let mut hh = hhb.start_hash(&SHA256); + assert_eq!( + hh.client_auth + .as_ref() + .map(|buf| buf.len()), + Some(5) + ); + hh.abandon_client_auth(); + assert_eq!(hh.client_auth, None); + hh.add_raw(b"world"); + assert_eq!(hh.client_auth, None); + let h = hh.current_hash(); + let h = h.as_ref(); + assert_eq!(h[0], 0x93); + assert_eq!(h[1], 0x6a); + assert_eq!(h[2], 0x18); + assert_eq!(h[3], 0x5c); + } + + #[test] + fn clones_correctly() { + let mut hhb = HandshakeHashBuffer::new(); + hhb.set_client_auth_enabled(); + hhb.add_raw(b"hello"); + assert_eq!(hhb.buffer.len(), 5); + + // Cloning the HHB should result in the same buffer and client auth state. + let mut hhb_prime = hhb.clone(); + assert_eq!(hhb_prime.buffer, hhb.buffer); + assert!(hhb_prime.client_auth_enabled); + + // Updating the HHB clone shouldn't affect the original. + hhb_prime.add_raw(b"world"); + assert_eq!(hhb_prime.buffer.len(), 10); + assert_ne!(hhb.buffer, hhb_prime.buffer); + + let hh = hhb.start_hash(&SHA256); + let hh_hash = hh.current_hash(); + let hh_hash = hh_hash.as_ref(); + + // Cloning the HH should result in the same current hash. + let mut hh_prime = hh.clone(); + let hh_prime_hash = hh_prime.current_hash(); + let hh_prime_hash = hh_prime_hash.as_ref(); + assert_eq!(hh_hash, hh_prime_hash); + + // Updating the HH clone shouldn't affect the original. + hh_prime.add_raw(b"goodbye"); + assert_eq!(hh.current_hash().as_ref(), hh_hash); + assert_ne!(hh_prime.current_hash().as_ref(), hh_hash); + } +} diff --git a/http/vendor/rustls/src/key_log.rs b/http/vendor/rustls/src/key_log.rs new file mode 100644 index 0000000..0ffcccf --- /dev/null +++ b/http/vendor/rustls/src/key_log.rs @@ -0,0 +1,61 @@ +use core::fmt::Debug; + +#[cfg(all(doc, feature = "std"))] +use crate::KeyLogFile; + +/// This trait represents the ability to do something useful +/// with key material, such as logging it to a file for debugging. +/// +/// Naturally, secrets passed over the interface are *extremely* +/// sensitive and can break the security of past, present and +/// future sessions. +/// +/// You'll likely want some interior mutability in your +/// implementation to make this useful. +/// +/// See [`KeyLogFile`] that implements the standard +/// `SSLKEYLOGFILE` environment variable behaviour. +pub trait KeyLog: Debug + Send + Sync { + /// Log the given `secret`. `client_random` is provided for + /// session identification. `label` describes precisely what + /// `secret` means: + /// + /// - `CLIENT_RANDOM`: `secret` is the master secret for a TLSv1.2 session. + /// - `CLIENT_EARLY_TRAFFIC_SECRET`: `secret` encrypts early data + /// transmitted by a client + /// - `SERVER_HANDSHAKE_TRAFFIC_SECRET`: `secret` encrypts + /// handshake messages from the server during a TLSv1.3 handshake. + /// - `CLIENT_HANDSHAKE_TRAFFIC_SECRET`: `secret` encrypts + /// handshake messages from the client during a TLSv1.3 handshake. + /// - `SERVER_TRAFFIC_SECRET_0`: `secret` encrypts post-handshake data + /// from the server in a TLSv1.3 session. + /// - `CLIENT_TRAFFIC_SECRET_0`: `secret` encrypts post-handshake data + /// from the client in a TLSv1.3 session. + /// - `EXPORTER_SECRET`: `secret` is the post-handshake exporter secret + /// in a TLSv1.3 session. + /// + /// These strings are selected to match the NSS key log format: + /// + fn log(&self, label: &str, client_random: &[u8], secret: &[u8]); + + /// Indicates whether the secret with label `label` will be logged. + /// + /// If `will_log` returns true then `log` will be called with the secret. + /// Otherwise, `log` will not be called for the secret. This is a + /// performance optimization. + fn will_log(&self, _label: &str) -> bool { + true + } +} + +/// KeyLog that does exactly nothing. +#[derive(Debug)] +pub struct NoKeyLog; + +impl KeyLog for NoKeyLog { + fn log(&self, _: &str, _: &[u8], _: &[u8]) {} + #[inline] + fn will_log(&self, _label: &str) -> bool { + false + } +} diff --git a/http/vendor/rustls/src/key_log_file.rs b/http/vendor/rustls/src/key_log_file.rs new file mode 100644 index 0000000..2779629 --- /dev/null +++ b/http/vendor/rustls/src/key_log_file.rs @@ -0,0 +1,162 @@ +use alloc::vec::Vec; +use core::fmt::{Debug, Formatter}; +use std::env::var_os; +use std::ffi::OsString; +use std::fs::{File, OpenOptions}; +use std::io; +use std::io::Write; +use std::sync::Mutex; + +use crate::KeyLog; +use crate::log::warn; + +// Internal mutable state for KeyLogFile +struct KeyLogFileInner { + file: Option, + buf: Vec, +} + +impl KeyLogFileInner { + fn new(var: Option) -> Self { + let Some(path) = &var else { + return Self { + file: None, + buf: Vec::new(), + }; + }; + + #[cfg_attr(not(feature = "logging"), allow(unused_variables))] + let file = match OpenOptions::new() + .append(true) + .create(true) + .open(path) + { + Ok(f) => Some(f), + Err(e) => { + warn!("unable to create key log file {path:?}: {e}"); + None + } + }; + + Self { + file, + buf: Vec::new(), + } + } + + fn try_write(&mut self, label: &str, client_random: &[u8], secret: &[u8]) -> io::Result<()> { + let Some(file) = &mut self.file else { + return Ok(()); + }; + + self.buf.clear(); + write!(self.buf, "{label} ")?; + for b in client_random.iter() { + write!(self.buf, "{b:02x}")?; + } + write!(self.buf, " ")?; + for b in secret.iter() { + write!(self.buf, "{b:02x}")?; + } + writeln!(self.buf)?; + file.write_all(&self.buf) + } +} + +impl Debug for KeyLogFileInner { + fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { + f.debug_struct("KeyLogFileInner") + // Note: we omit self.buf deliberately as it may contain key data. + .field("file", &self.file) + .finish() + } +} + +/// [`KeyLog`] implementation that opens a file whose name is +/// given by the `SSLKEYLOGFILE` environment variable, and writes +/// keys into it. +/// +/// If `SSLKEYLOGFILE` is not set, this does nothing. +/// +/// If such a file cannot be opened, or cannot be written then +/// this does nothing but logs errors at warning-level. +pub struct KeyLogFile(Mutex); + +impl KeyLogFile { + /// Makes a new `KeyLogFile`. The environment variable is + /// inspected and the named file is opened during this call. + pub fn new() -> Self { + let var = var_os("SSLKEYLOGFILE"); + Self(Mutex::new(KeyLogFileInner::new(var))) + } +} + +impl KeyLog for KeyLogFile { + fn log(&self, label: &str, client_random: &[u8], secret: &[u8]) { + #[cfg_attr(not(feature = "logging"), allow(unused_variables))] + match self + .0 + .lock() + .unwrap() + .try_write(label, client_random, secret) + { + Ok(()) => {} + Err(e) => { + warn!("error writing to key log file: {e}"); + } + } + } +} + +impl Debug for KeyLogFile { + fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { + match self.0.try_lock() { + Ok(key_log_file) => write!(f, "{key_log_file:?}"), + Err(_) => write!(f, "KeyLogFile {{ }}"), + } + } +} + +#[cfg(all(test, target_os = "linux"))] +mod tests { + use super::*; + + fn init() { + let _ = env_logger::builder() + .is_test(true) + .try_init(); + } + + #[test] + fn test_env_var_is_not_set() { + init(); + let mut inner = KeyLogFileInner::new(None); + assert!( + inner + .try_write("label", b"random", b"secret") + .is_ok() + ); + } + + #[test] + fn test_env_var_cannot_be_opened() { + init(); + let mut inner = KeyLogFileInner::new(Some("/dev/does-not-exist".into())); + assert!( + inner + .try_write("label", b"random", b"secret") + .is_ok() + ); + } + + #[test] + fn test_env_var_cannot_be_written() { + init(); + let mut inner = KeyLogFileInner::new(Some("/dev/full".into())); + assert!( + inner + .try_write("label", b"random", b"secret") + .is_err() + ); + } +} diff --git a/http/vendor/rustls/src/lib.rs b/http/vendor/rustls/src/lib.rs new file mode 100644 index 0000000..33c0d9c --- /dev/null +++ b/http/vendor/rustls/src/lib.rs @@ -0,0 +1,718 @@ +//! # Rustls - a modern TLS library +//! +//! Rustls is a TLS library that aims to provide a good level of cryptographic security, +//! requires no configuration to achieve that security, and provides no unsafe features or +//! obsolete cryptography by default. +//! +//! Rustls implements TLS1.2 and TLS1.3 for both clients and servers. See [the full +//! list of protocol features](manual::_04_features). +//! +//! ### Platform support +//! +//! While Rustls itself is platform independent, by default it uses [`aws-lc-rs`] for implementing +//! the cryptography in TLS. See [the aws-lc-rs FAQ][aws-lc-rs-platforms-faq] for more details of the +//! platform/architecture support constraints in aws-lc-rs. +//! +//! [`ring`] is also available via the `ring` crate feature: see +//! [the supported `ring` target platforms][ring-target-platforms]. +//! +//! By providing a custom instance of the [`crypto::CryptoProvider`] struct, you +//! can replace all cryptography dependencies of rustls. This is a route to being portable +//! to a wider set of architectures and environments, or compliance requirements. See the +//! [`crypto::CryptoProvider`] documentation for more details. +//! +//! Specifying `default-features = false` when depending on rustls will remove the implicit +//! dependency on aws-lc-rs. +//! +//! Rustls requires Rust 1.71 or later. It has an optional dependency on zlib-rs which requires 1.75 or later. +//! +//! [ring-target-platforms]: https://github.com/briansmith/ring/blob/2e8363b433fa3b3962c877d9ed2e9145612f3160/include/ring-core/target.h#L18-L64 +//! [`crypto::CryptoProvider`]: crate::crypto::CryptoProvider +//! [`ring`]: https://crates.io/crates/ring +//! [aws-lc-rs-platforms-faq]: https://aws.github.io/aws-lc-rs/faq.html#can-i-run-aws-lc-rs-on-x-platform-or-architecture +//! [`aws-lc-rs`]: https://crates.io/crates/aws-lc-rs +//! +//! ### Cryptography providers +//! +//! Since Rustls 0.22 it has been possible to choose the provider of the cryptographic primitives +//! that Rustls uses. This may be appealing if you have specific platform, compliance or feature +//! requirements that aren't met by the default provider, [`aws-lc-rs`]. +//! +//! Users that wish to customize the provider in use can do so when constructing `ClientConfig` +//! and `ServerConfig` instances using the `with_crypto_provider` method on the respective config +//! builder types. See the [`crypto::CryptoProvider`] documentation for more details. +//! +//! #### Built-in providers +//! +//! Rustls ships with two built-in providers controlled by associated crate features: +//! +//! * [`aws-lc-rs`] - enabled by default, available with the `aws_lc_rs` crate feature enabled. +//! * [`ring`] - available with the `ring` crate feature enabled. +//! +//! See the documentation for [`crypto::CryptoProvider`] for details on how providers are +//! selected. +//! +//! #### Third-party providers +//! +//! The community has also started developing third-party providers for Rustls: +//! +//! * [`boring-rustls-provider`] - a work-in-progress provider that uses [`boringssl`] for +//! cryptography. +//! * [`rustls-graviola`] - a provider that uses [`graviola`] for cryptography. +//! * [`rustls-mbedtls-provider`] - a provider that uses [`mbedtls`] for cryptography. +//! * [`rustls-openssl`] - a provider that uses [OpenSSL] for cryptography. +//! * [`rustls-rustcrypto`] - an experimental provider that uses the crypto primitives +//! from [`RustCrypto`] for cryptography. +//! * [`rustls-symcrypt`] - a provider that uses Microsoft's [SymCrypt] library. +//! * [`rustls-wolfcrypt-provider`] - a work-in-progress provider that uses [`wolfCrypt`] for cryptography. +//! +//! [`rustls-graviola`]: https://crates.io/crates/rustls-graviola +//! [`graviola`]: https://github.com/ctz/graviola +//! [`rustls-mbedtls-provider`]: https://github.com/fortanix/rustls-mbedtls-provider +//! [`mbedtls`]: https://github.com/Mbed-TLS/mbedtls +//! [`rustls-openssl`]: https://github.com/tofay/rustls-openssl +//! [OpenSSL]: https://openssl-library.org/ +//! [`rustls-symcrypt`]: https://github.com/microsoft/rustls-symcrypt +//! [SymCrypt]: https://github.com/microsoft/SymCrypt +//! [`boring-rustls-provider`]: https://github.com/janrueth/boring-rustls-provider +//! [`boringssl`]: https://github.com/google/boringssl +//! [`rustls-rustcrypto`]: https://github.com/RustCrypto/rustls-rustcrypto +//! [`RustCrypto`]: https://github.com/RustCrypto +//! [`rustls-wolfcrypt-provider`]: https://github.com/wolfSSL/rustls-wolfcrypt-provider +//! [`wolfCrypt`]: https://www.wolfssl.com/products/wolfcrypt +//! +//! #### Custom provider +//! +//! We also provide a simple example of writing your own provider in the [custom provider example]. +//! This example implements a minimal provider using parts of the [`RustCrypto`] ecosystem. +//! +//! See the [Making a custom CryptoProvider] section of the documentation for more information +//! on this topic. +//! +//! [custom provider example]: https://github.com/rustls/rustls/tree/main/provider-example/ +//! [`RustCrypto`]: https://github.com/RustCrypto +//! [Making a custom CryptoProvider]: https://docs.rs/rustls/latest/rustls/crypto/struct.CryptoProvider.html#making-a-custom-cryptoprovider +//! +//! ## Design overview +//! +//! Rustls is a low-level library. If your goal is to make HTTPS connections you may prefer +//! to use a library built on top of Rustls like [hyper] or [ureq]. +//! +//! [hyper]: https://crates.io/crates/hyper +//! [ureq]: https://crates.io/crates/ureq +//! +//! ### Rustls does not take care of network IO +//! It doesn't make or accept TCP connections, or do DNS, or read or write files. +//! +//! Our [examples] directory contains demos that show how to handle I/O using the +//! [`stream::Stream`] helper, as well as more complex asynchronous I/O using [`mio`]. +//! If you're already using Tokio for an async runtime you may prefer to use [`tokio-rustls`] instead +//! of interacting with rustls directly. +//! +//! [examples]: https://github.com/rustls/rustls/tree/main/examples +//! [`tokio-rustls`]: https://github.com/rustls/tokio-rustls +//! +//! ### Rustls provides encrypted pipes +//! These are the [`ServerConnection`] and [`ClientConnection`] types. You supply raw TLS traffic +//! on the left (via the [`read_tls()`] and [`write_tls()`] methods) and then read/write the +//! plaintext on the right: +//! +//! [`read_tls()`]: Connection::read_tls +//! [`write_tls()`]: Connection::read_tls +//! +//! ```text +//! TLS Plaintext +//! === ========= +//! read_tls() +-----------------------+ reader() as io::Read +//! | | +//! +---------> ClientConnection +---------> +//! | or | +//! <---------+ ServerConnection <---------+ +//! | | +//! write_tls() +-----------------------+ writer() as io::Write +//! ``` +//! +//! ### Rustls takes care of server certificate verification +//! You do not need to provide anything other than a set of root certificates to trust. +//! Certificate verification cannot be turned off or disabled in the main API. +//! +//! ## Getting started +//! This is the minimum you need to do to make a TLS client connection. +//! +//! First we load some root certificates. These are used to authenticate the server. +//! The simplest way is to depend on the [`webpki_roots`] crate which contains +//! the Mozilla set of root certificates. +//! +//! ```rust,no_run +//! # #[cfg(feature = "aws-lc-rs")] { +//! let root_store = rustls::RootCertStore::from_iter( +//! webpki_roots::TLS_SERVER_ROOTS +//! .iter() +//! .cloned(), +//! ); +//! # } +//! ``` +//! +//! [`webpki_roots`]: https://crates.io/crates/webpki-roots +//! +//! Next, we make a `ClientConfig`. You're likely to make one of these per process, +//! and use it for all connections made by that process. +//! +//! ```rust,no_run +//! # #[cfg(feature = "aws_lc_rs")] { +//! # let root_store: rustls::RootCertStore = panic!(); +//! let config = rustls::ClientConfig::builder() +//! .with_root_certificates(root_store) +//! .with_no_client_auth(); +//! # } +//! ``` +//! +//! Now we can make a connection. You need to provide the server's hostname so we +//! know what to expect to find in the server's certificate. +//! +//! ```rust +//! # #[cfg(feature = "aws_lc_rs")] { +//! # use rustls; +//! # use webpki; +//! # use std::sync::Arc; +//! # rustls::crypto::aws_lc_rs::default_provider().install_default(); +//! # let root_store = rustls::RootCertStore::from_iter( +//! # webpki_roots::TLS_SERVER_ROOTS +//! # .iter() +//! # .cloned(), +//! # ); +//! # let config = rustls::ClientConfig::builder() +//! # .with_root_certificates(root_store) +//! # .with_no_client_auth(); +//! let rc_config = Arc::new(config); +//! let example_com = "example.com".try_into().unwrap(); +//! let mut client = rustls::ClientConnection::new(rc_config, example_com); +//! # } +//! ``` +//! +//! Now you should do appropriate IO for the `client` object. If `client.wants_read()` yields +//! true, you should call `client.read_tls()` when the underlying connection has data. +//! Likewise, if `client.wants_write()` yields true, you should call `client.write_tls()` +//! when the underlying connection is able to send data. You should continue doing this +//! as long as the connection is valid. +//! +//! The return types of `read_tls()` and `write_tls()` only tell you if the IO worked. No +//! parsing or processing of the TLS messages is done. After each `read_tls()` you should +//! therefore call `client.process_new_packets()` which parses and processes the messages. +//! Any error returned from `process_new_packets` is fatal to the connection, and will tell you +//! why. For example, if the server's certificate is expired `process_new_packets` will +//! return `Err(InvalidCertificate(Expired))`. From this point on, +//! `process_new_packets` will not do any new work and will return that error continually. +//! +//! You can extract newly received data by calling `client.reader()` (which implements the +//! `io::Read` trait). You can send data to the peer by calling `client.writer()` (which +//! implements `io::Write` trait). Note that `client.writer().write()` buffers data you +//! send if the TLS connection is not yet established: this is useful for writing (say) a +//! HTTP request, but this is buffered so avoid large amounts of data. +//! +//! The following code uses a fictional socket IO API for illustration, and does not handle +//! errors. +//! +//! ```rust,no_run +//! # #[cfg(feature = "aws_lc_rs")] { +//! # let mut client = rustls::ClientConnection::new(panic!(), panic!()).unwrap(); +//! # struct Socket { } +//! # impl Socket { +//! # fn ready_for_write(&self) -> bool { false } +//! # fn ready_for_read(&self) -> bool { false } +//! # fn wait_for_something_to_happen(&self) { } +//! # } +//! # +//! # use std::io::{Read, Write, Result}; +//! # impl Read for Socket { +//! # fn read(&mut self, buf: &mut [u8]) -> Result { panic!() } +//! # } +//! # impl Write for Socket { +//! # fn write(&mut self, buf: &[u8]) -> Result { panic!() } +//! # fn flush(&mut self) -> Result<()> { panic!() } +//! # } +//! # +//! # fn connect(_address: &str, _port: u16) -> Socket { +//! # panic!(); +//! # } +//! use std::io; +//! use rustls::Connection; +//! +//! client.writer().write(b"GET / HTTP/1.0\r\n\r\n").unwrap(); +//! let mut socket = connect("example.com", 443); +//! loop { +//! if client.wants_read() && socket.ready_for_read() { +//! client.read_tls(&mut socket).unwrap(); +//! client.process_new_packets().unwrap(); +//! +//! let mut plaintext = Vec::new(); +//! client.reader().read_to_end(&mut plaintext).unwrap(); +//! io::stdout().write(&plaintext).unwrap(); +//! } +//! +//! if client.wants_write() && socket.ready_for_write() { +//! client.write_tls(&mut socket).unwrap(); +//! } +//! +//! socket.wait_for_something_to_happen(); +//! } +//! # } +//! ``` +//! +//! # Examples +//! +//! You can find several client and server examples of varying complexity in the [examples] +//! directory, including [`tlsserver-mio`](https://github.com/rustls/rustls/blob/main/examples/src/bin/tlsserver-mio.rs) +//! and [`tlsclient-mio`](https://github.com/rustls/rustls/blob/main/examples/src/bin/tlsclient-mio.rs) +//! \- full worked examples using [`mio`]. +//! +//! [`mio`]: https://docs.rs/mio/latest/mio/ +//! +//! # Manual +//! +//! The [rustls manual](crate::manual) explains design decisions and includes how-to guidance. +//! +//! # Crate features +//! Here's a list of what features are exposed by the rustls crate and what +//! they mean. +//! +//! - `std` (enabled by default): enable the high-level (buffered) Connection API and other functionality +//! which relies on the `std` library. +//! +//! - `aws_lc_rs` (enabled by default): makes the rustls crate depend on the [`aws-lc-rs`] crate. +//! Use `rustls::crypto::aws_lc_rs::default_provider().install_default()` to +//! use it as the default `CryptoProvider`, or provide it explicitly +//! when making a `ClientConfig` or `ServerConfig`. +//! +//! Note that aws-lc-rs has additional build-time dependencies like cmake. +//! See [the documentation](https://aws.github.io/aws-lc-rs/requirements/index.html) for details. +//! +//! - `ring`: makes the rustls crate depend on the *ring* crate for cryptography. +//! Use `rustls::crypto::ring::default_provider().install_default()` to +//! use it as the default `CryptoProvider`, or provide it explicitly +//! when making a `ClientConfig` or `ServerConfig`. +//! +//! - `fips`: enable support for FIPS140-3-approved cryptography, via the [`aws-lc-rs`] crate. +//! This feature enables the `aws_lc_rs` crate feature, which makes the rustls crate depend +//! on [aws-lc-rs](https://github.com/aws/aws-lc-rs). It also changes the default +//! for [`ServerConfig::require_ems`] and [`ClientConfig::require_ems`]. +//! +//! See [manual::_06_fips] for more details. +//! +//! - `prefer-post-quantum` (enabled by default): for the [`aws-lc-rs`]-backed provider, +//! prioritizes post-quantum secure key exchange by default (using X25519MLKEM768). +//! This feature merely alters the order of `rustls::crypto::aws_lc_rs::DEFAULT_KX_GROUPS`. +//! See [the manual][x25519mlkem768-manual] for more details. +//! +//! - `custom-provider`: disables implicit use of built-in providers (`aws-lc-rs` or `ring`). This forces +//! applications to manually install one, for instance, when using a custom `CryptoProvider`. +//! +//! - `tls12` (enabled by default): enable support for TLS version 1.2. Note that, due to the +//! additive nature of Cargo features and because it is enabled by default, other crates +//! in your dependency graph could re-enable it for your application. If you want to disable +//! TLS 1.2 for security reasons, consider explicitly enabling TLS 1.3 only in the config +//! builder API. +//! +//! - `logging` (enabled by default): make the rustls crate depend on the `log` crate. +//! rustls outputs interesting protocol-level messages at `trace!` and `debug!` level, +//! and protocol-level errors at `warn!` and `error!` level. The log messages do not +//! contain secret key data, and so are safe to archive without affecting session security. +//! +//! - `read_buf`: when building with Rust Nightly, adds support for the unstable +//! `std::io::ReadBuf` and related APIs. This reduces costs from initializing +//! buffers. Will do nothing on non-Nightly releases. +//! +//! - `brotli`: uses the `brotli` crate for RFC8879 certificate compression support. +//! +//! - `zlib`: uses the `zlib-rs` crate for RFC8879 certificate compression support. +//! +//! [x25519mlkem768-manual]: manual::_05_defaults#about-the-post-quantum-secure-key-exchange-x25519mlkem768 + +// Require docs for public APIs, deny unsafe code, etc. +#![forbid(unsafe_code, unused_must_use)] +#![cfg_attr(not(any(read_buf, bench, coverage_nightly)), forbid(unstable_features))] +#![warn( + clippy::alloc_instead_of_core, + clippy::manual_let_else, + clippy::std_instead_of_core, + clippy::use_self, + clippy::upper_case_acronyms, + elided_lifetimes_in_paths, + missing_docs, + trivial_casts, + trivial_numeric_casts, + unreachable_pub, + unused_import_braces, + unused_extern_crates, + unused_qualifications +)] +// Relax these clippy lints: +// - ptr_arg: this triggers on references to type aliases that are Vec +// underneath. +// - too_many_arguments: some things just need a lot of state, wrapping it +// doesn't necessarily make it easier to follow what's going on +// - new_ret_no_self: we sometimes return `Arc`, which seems fine +// - single_component_path_imports: our top-level `use log` import causes +// a false positive, https://github.com/rust-lang/rust-clippy/issues/5210 +// - new_without_default: for internal constructors, the indirection is not +// helpful +#![allow( + clippy::too_many_arguments, + clippy::new_ret_no_self, + clippy::ptr_arg, + clippy::single_component_path_imports, + clippy::new_without_default +)] +// Enable documentation for all features on docs.rs +#![cfg_attr(rustls_docsrs, feature(doc_cfg))] +// Enable coverage() attr for nightly coverage builds, see +// +// (`coverage_nightly` is a cfg set by `cargo-llvm-cov`) +#![cfg_attr(coverage_nightly, feature(coverage_attribute))] +// XXX: Because of https://github.com/rust-lang/rust/issues/54726, we cannot +// write `#![rustversion::attr(nightly, feature(read_buf))]` here. Instead, +// build.rs set `read_buf` for (only) Rust Nightly to get the same effect. +// +// All the other conditional logic in the crate could use +// `#[rustversion::nightly]` instead of `#[cfg(read_buf)]`; `#[cfg(read_buf)]` +// is used to avoid needing `rustversion` to be compiled twice during +// cross-compiling. +#![cfg_attr(read_buf, feature(read_buf))] +#![cfg_attr(read_buf, feature(core_io))] +#![cfg_attr(read_buf, feature(core_io_borrowed_buf))] +#![cfg_attr(bench, feature(test))] +#![no_std] + +extern crate alloc; +// This `extern crate` plus the `#![no_std]` attribute changes the default prelude from +// `std::prelude` to `core::prelude`. That forces one to _explicitly_ import (`use`) everything that +// is in `std::prelude` but not in `core::prelude`. This helps maintain no-std support as even +// developers that are not interested in, or aware of, no-std support and / or that never run +// `cargo build --no-default-features` locally will get errors when they rely on `std::prelude` API. +#[cfg(any(feature = "std", test))] +extern crate std; + +#[cfg(doc)] +use crate::crypto::CryptoProvider; + +// Import `test` sysroot crate for `Bencher` definitions. +#[cfg(bench)] +#[allow(unused_extern_crates)] +extern crate test; + +// log for logging (optional). +#[cfg(feature = "logging")] +use log; + +#[cfg(not(feature = "logging"))] +mod log { + macro_rules! trace ( ($($tt:tt)*) => {{}} ); + macro_rules! debug ( ($($tt:tt)*) => {{}} ); + macro_rules! error ( ($($tt:tt)*) => {{}} ); + macro_rules! _warn ( ($($tt:tt)*) => {{}} ); + pub(crate) use {_warn as warn, debug, error, trace}; +} + +#[cfg(test)] +#[macro_use] +mod test_macros; + +/// This internal `sync` module aliases the `Arc` implementation to allow downstream forks +/// of rustls targeting architectures without atomic pointers to replace the implementation +/// with another implementation such as `portable_atomic_util::Arc` in one central location. +mod sync { + #[allow(clippy::disallowed_types)] + pub(crate) type Arc = alloc::sync::Arc; + #[allow(clippy::disallowed_types)] + pub(crate) type Weak = alloc::sync::Weak; +} + +#[macro_use] +mod msgs; +mod common_state; +pub mod compress; +mod conn; +/// Crypto provider interface. +pub mod crypto; +mod error; +mod hash_hs; +#[cfg(any(feature = "std", feature = "hashbrown"))] +mod limited_cache; +mod rand; +mod record_layer; +#[cfg(feature = "std")] +mod stream; +#[cfg(feature = "tls12")] +mod tls12; +mod tls13; +mod vecbuf; +mod verify; +#[cfg(test)] +mod verifybench; +mod x509; +#[macro_use] +mod check; +#[cfg(feature = "logging")] +mod bs_debug; +mod builder; +mod enums; +mod key_log; +#[cfg(feature = "std")] +mod key_log_file; +mod suites; +mod versions; +mod webpki; + +/// Internal classes that are used in integration tests. +/// The contents of this section DO NOT form part of the stable interface. +#[allow(missing_docs)] +#[doc(hidden)] +pub mod internal { + /// Low-level TLS message parsing and encoding functions. + pub mod msgs { + pub mod base { + pub use crate::msgs::base::{Payload, PayloadU16}; + } + pub mod codec { + pub use crate::msgs::codec::{Codec, Reader}; + } + pub mod enums { + pub use crate::msgs::enums::{ + AlertLevel, EchVersion, ExtensionType, HpkeAead, HpkeKdf, HpkeKem, + }; + } + pub mod fragmenter { + pub use crate::msgs::fragmenter::MessageFragmenter; + } + pub mod handshake { + pub use crate::msgs::handshake::{ + EchConfigContents, EchConfigPayload, HpkeKeyConfig, HpkeSymmetricCipherSuite, + }; + } + pub mod message { + pub use crate::msgs::message::{ + Message, MessagePayload, OutboundOpaqueMessage, PlainMessage, + }; + } + pub mod persist { + pub use crate::msgs::persist::ServerSessionValue; + } + } + + pub use crate::tls13::key_schedule::{derive_traffic_iv, derive_traffic_key}; + + pub mod fuzzing { + pub use crate::msgs::deframer::fuzz_deframer; + } +} + +/// Unbuffered connection API +/// +/// This is an alternative to the [`crate::ConnectionCommon`] API that does not internally buffer +/// TLS nor plaintext data. Instead those buffers are managed by the API user so they have +/// control over when and how to allocate, resize and dispose of them. +/// +/// This API is lower level than the `ConnectionCommon` API and is built around a state machine +/// interface where the API user must handle each state to advance and complete the +/// handshake process. +/// +/// Like the `ConnectionCommon` API, no IO happens internally so all IO must be handled by the API +/// user. Unlike the `ConnectionCommon` API, this API does not make use of the [`std::io::Read`] and +/// [`std::io::Write`] traits so it's usable in no-std context. +/// +/// The entry points into this API are [`crate::client::UnbufferedClientConnection::new`], +/// [`crate::server::UnbufferedServerConnection::new`] and +/// [`unbuffered::UnbufferedConnectionCommon::process_tls_records`]. The state machine API is +/// documented in [`unbuffered::ConnectionState`]. +/// +/// # Examples +/// +/// [`unbuffered-client`] and [`unbuffered-server`] are examples that fully exercise the API in +/// std, non-async context. +/// +/// [`unbuffered-client`]: https://github.com/rustls/rustls/blob/main/examples/src/bin/unbuffered-client.rs +/// [`unbuffered-server`]: https://github.com/rustls/rustls/blob/main/examples/src/bin/unbuffered-server.rs +pub mod unbuffered { + pub use crate::conn::UnbufferedConnectionCommon; + pub use crate::conn::unbuffered::{ + AppDataRecord, ConnectionState, EncodeError, EncodeTlsData, EncryptError, + InsufficientSizeError, ReadEarlyData, ReadTraffic, TransmitTlsData, UnbufferedStatus, + WriteTraffic, + }; +} + +// The public interface is: +pub use crate::builder::{ConfigBuilder, ConfigSide, WantsVerifier, WantsVersions}; +pub use crate::common_state::{CommonState, HandshakeKind, IoState, Side}; +#[cfg(feature = "std")] +pub use crate::conn::{Connection, Reader, Writer}; +pub use crate::conn::{ConnectionCommon, SideData, kernel}; +pub use crate::enums::{ + AlertDescription, CertificateCompressionAlgorithm, CipherSuite, ContentType, HandshakeType, + ProtocolVersion, SignatureAlgorithm, SignatureScheme, +}; +pub use crate::error::{ + CertRevocationListError, CertificateError, EncryptedClientHelloError, Error, + ExtendedKeyPurpose, InconsistentKeys, InvalidMessage, OtherError, PeerIncompatible, + PeerMisbehaved, +}; +pub use crate::key_log::{KeyLog, NoKeyLog}; +#[cfg(feature = "std")] +pub use crate::key_log_file::KeyLogFile; +pub use crate::msgs::enums::NamedGroup; +pub use crate::msgs::ffdhe_groups; +pub use crate::msgs::handshake::DistinguishedName; +#[cfg(feature = "std")] +pub use crate::stream::{Stream, StreamOwned}; +pub use crate::suites::{ + CipherSuiteCommon, ConnectionTrafficSecrets, ExtractedSecrets, SupportedCipherSuite, +}; +#[cfg(feature = "std")] +pub use crate::ticketer::TicketRotator; +#[cfg(any(feature = "std", feature = "hashbrown"))] // < XXX: incorrect feature gate +pub use crate::ticketer::TicketSwitcher; +#[cfg(feature = "tls12")] +pub use crate::tls12::Tls12CipherSuite; +pub use crate::tls13::Tls13CipherSuite; +pub use crate::verify::DigitallySignedStruct; +pub use crate::versions::{ALL_VERSIONS, DEFAULT_VERSIONS, SupportedProtocolVersion}; +pub use crate::webpki::RootCertStore; + +/// Items for use in a client. +pub mod client { + pub(super) mod builder; + mod client_conn; + mod common; + mod ech; + pub(super) mod handy; + mod hs; + #[cfg(test)] + mod test; + #[cfg(feature = "tls12")] + mod tls12; + mod tls13; + + pub use builder::WantsClientCert; + pub use client_conn::{ + ClientConfig, ClientConnectionData, ClientSessionStore, EarlyDataError, ResolvesClientCert, + Resumption, Tls12Resumption, UnbufferedClientConnection, + }; + #[cfg(feature = "std")] + pub use client_conn::{ClientConnection, WriteEarlyData}; + pub use ech::{EchConfig, EchGreaseConfig, EchMode, EchStatus}; + pub use handy::AlwaysResolvesClientRawPublicKeys; + #[cfg(any(feature = "std", feature = "hashbrown"))] + pub use handy::ClientSessionMemoryCache; + + /// Dangerous configuration that should be audited and used with extreme care. + pub mod danger { + pub use super::builder::danger::DangerousClientConfigBuilder; + pub use super::client_conn::danger::DangerousClientConfig; + pub use crate::verify::{HandshakeSignatureValid, ServerCertVerified, ServerCertVerifier}; + } + + pub use crate::msgs::persist::{Tls12ClientSessionValue, Tls13ClientSessionValue}; + pub use crate::webpki::{ + ServerCertVerifierBuilder, VerifierBuilderError, WebPkiServerVerifier, + verify_server_cert_signed_by_trust_anchor, verify_server_name, + }; +} + +pub use client::ClientConfig; +#[cfg(feature = "std")] +pub use client::ClientConnection; + +/// Items for use in a server. +pub mod server { + pub(crate) mod builder; + mod common; + pub(crate) mod handy; + mod hs; + mod server_conn; + #[cfg(test)] + mod test; + #[cfg(feature = "tls12")] + mod tls12; + mod tls13; + + pub use builder::WantsServerCert; + #[cfg(any(feature = "std", feature = "hashbrown"))] + pub use handy::ResolvesServerCertUsingSni; + #[cfg(any(feature = "std", feature = "hashbrown"))] + pub use handy::ServerSessionMemoryCache; + pub use handy::{AlwaysResolvesServerRawPublicKeys, NoServerSessionStorage}; + pub use server_conn::{ + Accepted, ClientHello, ProducesTickets, ResolvesServerCert, ServerConfig, + ServerConnectionData, StoresServerSessions, UnbufferedServerConnection, + }; + #[cfg(feature = "std")] + pub use server_conn::{AcceptedAlert, Acceptor, ReadEarlyData, ServerConnection}; + + pub use crate::enums::CertificateType; + pub use crate::verify::NoClientAuth; + pub use crate::webpki::{ + ClientCertVerifierBuilder, ParsedCertificate, VerifierBuilderError, WebPkiClientVerifier, + }; + + /// Dangerous configuration that should be audited and used with extreme care. + pub mod danger { + pub use crate::verify::{ClientCertVerified, ClientCertVerifier}; + } +} + +pub use server::ServerConfig; +#[cfg(feature = "std")] +pub use server::ServerConnection; + +/// All defined protocol versions appear in this module. +/// +/// ALL_VERSIONS is a provided as an array of all of these values. +pub mod version { + #[cfg(feature = "tls12")] + pub use crate::versions::TLS12; + pub use crate::versions::TLS13; +} + +/// Re-exports the contents of the [rustls-pki-types](https://docs.rs/rustls-pki-types) crate for easy access +pub mod pki_types { + #[doc(no_inline)] + pub use pki_types::*; +} + +/// Message signing interfaces. +pub mod sign { + pub use crate::crypto::signer::{ + CertifiedKey, Signer, SigningKey, SingleCertAndKey, public_key_to_spki, + }; +} + +/// APIs for implementing QUIC TLS +pub mod quic; + +#[cfg(any(feature = "std", feature = "hashbrown"))] // < XXX: incorrect feature gate +/// APIs for implementing TLS tickets +pub mod ticketer; + +/// This is the rustls manual. +pub mod manual; + +pub mod time_provider; + +/// APIs abstracting over locking primitives. +pub mod lock; + +/// Polyfills for features that are not yet stabilized or available with current MSRV. +pub(crate) mod polyfill; + +#[cfg(any(feature = "std", feature = "hashbrown"))] +mod hash_map { + #[cfg(feature = "std")] + pub(crate) use std::collections::HashMap; + #[cfg(feature = "std")] + pub(crate) use std::collections::hash_map::Entry; + + #[cfg(all(not(feature = "std"), feature = "hashbrown"))] + pub(crate) use hashbrown::HashMap; + #[cfg(all(not(feature = "std"), feature = "hashbrown"))] + pub(crate) use hashbrown::hash_map::Entry; +} diff --git a/http/vendor/rustls/src/limited_cache.rs b/http/vendor/rustls/src/limited_cache.rs new file mode 100644 index 0000000..6ae8bf9 --- /dev/null +++ b/http/vendor/rustls/src/limited_cache.rs @@ -0,0 +1,250 @@ +use alloc::collections::VecDeque; +use core::borrow::Borrow; +use core::hash::Hash; + +use crate::hash_map::{Entry, HashMap}; + +/// A HashMap-alike, which never gets larger than a specified +/// capacity, and evicts the oldest insertion to maintain this. +/// +/// The requested capacity may be rounded up by the underlying +/// collections. This implementation uses all the allocated +/// storage. +/// +/// This is inefficient: it stores keys twice. +pub(crate) struct LimitedCache { + map: HashMap, + + // first item is the oldest key + oldest: VecDeque, +} + +impl LimitedCache +where + K: Eq + Hash + Clone + core::fmt::Debug, + V: Default, +{ + pub(crate) fn get_or_insert_default_and_edit(&mut self, k: K, edit: impl FnOnce(&mut V)) { + let inserted_new_item = match self.map.entry(k) { + Entry::Occupied(value) => { + edit(value.into_mut()); + false + } + entry @ Entry::Vacant(_) => { + self.oldest + .push_back(entry.key().clone()); + edit(entry.or_insert_with(V::default)); + true + } + }; + + // ensure next insertion does not require a realloc + if inserted_new_item && self.oldest.capacity() == self.oldest.len() { + if let Some(oldest_key) = self.oldest.pop_front() { + self.map.remove(&oldest_key); + } + } + } + + pub(crate) fn get_mut(&mut self, k: &Q) -> Option<&mut V> + where + K: Borrow, + { + self.map.get_mut(k) + } +} + +impl LimitedCache +where + K: Eq + Hash + Clone + core::fmt::Debug, + V: Default, +{ + /// Create a new LimitedCache with the given rough capacity. + pub(crate) fn new(capacity_order_of_magnitude: usize) -> Self { + Self { + map: HashMap::with_capacity(capacity_order_of_magnitude), + oldest: VecDeque::with_capacity(capacity_order_of_magnitude), + } + } + + pub(crate) fn insert(&mut self, k: K, v: V) { + let inserted_new_item = match self.map.entry(k) { + Entry::Occupied(mut old) => { + // Note: does not freshen entry in `oldest` + old.insert(v); + false + } + + entry @ Entry::Vacant(_) => { + self.oldest + .push_back(entry.key().clone()); + entry.or_insert(v); + true + } + }; + + // ensure next insertion does not require a realloc + if inserted_new_item && self.oldest.capacity() == self.oldest.len() { + if let Some(oldest_key) = self.oldest.pop_front() { + self.map.remove(&oldest_key); + } + } + } + + pub(crate) fn get(&self, k: &Q) -> Option<&V> + where + K: Borrow, + { + self.map.get(k) + } + + pub(crate) fn remove(&mut self, k: &Q) -> Option + where + K: Borrow, + { + let value = self.map.remove(k)?; + + // O(N) search, followed by O(N) removal + if let Some(index) = self + .oldest + .iter() + .position(|item| item.borrow() == k) + { + self.oldest.remove(index); + } + + Some(value) + } +} + +#[cfg(test)] +mod tests { + use std::prelude::v1::*; + + type Test = super::LimitedCache; + + #[test] + fn test_updates_existing_item() { + let mut t = Test::new(3); + t.insert("abc".into(), 1); + t.insert("abc".into(), 2); + assert_eq!(t.get("abc"), Some(&2)); + } + + #[test] + fn test_evicts_oldest_item() { + let mut t = Test::new(3); + t.insert("abc".into(), 1); + t.insert("def".into(), 2); + t.insert("ghi".into(), 3); + + assert_eq!(t.get("abc"), None); + assert_eq!(t.get("def"), Some(&2)); + assert_eq!(t.get("ghi"), Some(&3)); + } + + #[test] + fn test_evicts_second_oldest_item_if_first_removed() { + let mut t = Test::new(3); + t.insert("abc".into(), 1); + t.insert("def".into(), 2); + + assert_eq!(t.remove("abc"), Some(1)); + + t.insert("ghi".into(), 3); + t.insert("jkl".into(), 4); + + assert_eq!(t.get("abc"), None); + assert_eq!(t.get("def"), None); + assert_eq!(t.get("ghi"), Some(&3)); + assert_eq!(t.get("jkl"), Some(&4)); + } + + #[test] + fn test_evicts_after_second_oldest_item_removed() { + let mut t = Test::new(3); + t.insert("abc".into(), 1); + t.insert("def".into(), 2); + + assert_eq!(t.remove("def"), Some(2)); + assert_eq!(t.get("abc"), Some(&1)); + + t.insert("ghi".into(), 3); + t.insert("jkl".into(), 4); + + assert_eq!(t.get("abc"), None); + assert_eq!(t.get("def"), None); + assert_eq!(t.get("ghi"), Some(&3)); + assert_eq!(t.get("jkl"), Some(&4)); + } + + #[test] + fn test_removes_all_items() { + let mut t = Test::new(3); + t.insert("abc".into(), 1); + t.insert("def".into(), 2); + + assert_eq!(t.remove("def"), Some(2)); + assert_eq!(t.remove("abc"), Some(1)); + + t.insert("ghi".into(), 3); + t.insert("jkl".into(), 4); + t.insert("mno".into(), 5); + + assert_eq!(t.get("abc"), None); + assert_eq!(t.get("def"), None); + assert_eq!(t.get("ghi"), None); + assert_eq!(t.get("jkl"), Some(&4)); + assert_eq!(t.get("mno"), Some(&5)); + } + + #[test] + fn test_inserts_many_items() { + let mut t = Test::new(3); + + for _ in 0..10000 { + t.insert("abc".into(), 1); + t.insert("def".into(), 2); + t.insert("ghi".into(), 3); + } + } + + #[test] + fn test_get_or_insert_default_and_edit_evicts_old_items_to_meet_capacity() { + let mut t = Test::new(3); + + t.get_or_insert_default_and_edit("abc".into(), |v| *v += 1); + t.get_or_insert_default_and_edit("def".into(), |v| *v += 2); + + // evicts "abc" + t.get_or_insert_default_and_edit("ghi".into(), |v| *v += 3); + assert_eq!(t.get("abc"), None); + + // evicts "def" + t.get_or_insert_default_and_edit("jkl".into(), |v| *v += 4); + assert_eq!(t.get("def"), None); + + // evicts "ghi" + t.get_or_insert_default_and_edit("abc".into(), |v| *v += 5); + assert_eq!(t.get("ghi"), None); + + // evicts "jkl" + t.get_or_insert_default_and_edit("def".into(), |v| *v += 6); + + assert_eq!(t.get("abc"), Some(&5)); + assert_eq!(t.get("def"), Some(&6)); + assert_eq!(t.get("ghi"), None); + assert_eq!(t.get("jkl"), None); + } + + #[test] + fn test_get_or_insert_default_and_edit_edits_existing_item() { + let mut t = Test::new(3); + + t.get_or_insert_default_and_edit("abc".into(), |v| *v += 1); + t.get_or_insert_default_and_edit("abc".into(), |v| *v += 2); + t.get_or_insert_default_and_edit("abc".into(), |v| *v += 3); + + assert_eq!(t.get("abc"), Some(&6)); + } +} diff --git a/http/vendor/rustls/src/lock.rs b/http/vendor/rustls/src/lock.rs new file mode 100644 index 0000000..b632b2c --- /dev/null +++ b/http/vendor/rustls/src/lock.rs @@ -0,0 +1,89 @@ +#[cfg(not(feature = "std"))] +pub use no_std_lock::*; +#[cfg(feature = "std")] +pub use std_lock::*; + +#[cfg(feature = "std")] +mod std_lock { + use std::sync::Mutex as StdMutex; + pub use std::sync::MutexGuard; + + /// A wrapper around [`std::sync::Mutex`]. + #[derive(Debug)] + pub struct Mutex { + inner: StdMutex, + } + + impl Mutex { + /// Creates a new mutex in an unlocked state ready for use. + pub fn new(data: T) -> Self { + Self { + inner: StdMutex::new(data), + } + } + + /// Acquires the mutex, blocking the current thread until it is able to do so. + /// + /// This will return `None` in the case the mutex is poisoned. + #[inline] + pub fn lock(&self) -> Option> { + self.inner.lock().ok() + } + } +} + +#[cfg(not(feature = "std"))] +mod no_std_lock { + use alloc::boxed::Box; + use core::fmt::Debug; + use core::ops::DerefMut; + + use crate::sync::Arc; + + /// A no-std compatible wrapper around [`Lock`]. + #[derive(Debug)] + pub struct Mutex { + inner: Arc>, + } + + impl Mutex { + /// Creates a new mutex in an unlocked state ready for use. + pub fn new(val: T) -> Self + where + M: MakeMutex, + T: Send + 'static, + { + Self { + inner: M::make_mutex(val), + } + } + + /// Acquires the mutex, blocking the current thread until it is able to do so. + /// + /// This will return `None` in the case the mutex is poisoned. + #[inline] + pub fn lock(&self) -> Option> { + self.inner.lock().ok() + } + } + + /// A lock protecting shared data. + pub trait Lock: Debug + Send + Sync { + /// Acquire the lock. + fn lock(&self) -> Result, Poisoned>; + } + + /// A lock builder. + pub trait MakeMutex { + /// Create a new mutex. + fn make_mutex(value: T) -> Arc> + where + T: Send + 'static; + } + + /// A no-std compatible mutex guard. + pub type MutexGuard<'a, T> = Box + 'a>; + + /// A marker type used to indicate `Lock::lock` failed due to a poisoned lock. + pub struct Poisoned; +} diff --git a/http/vendor/rustls/src/manual/defaults.rs b/http/vendor/rustls/src/manual/defaults.rs new file mode 100644 index 0000000..f6f70dc --- /dev/null +++ b/http/vendor/rustls/src/manual/defaults.rs @@ -0,0 +1,71 @@ +/*! + +## Rationale for defaults + +### Why is AES-256 preferred over AES-128? + +This is a trade-off between: + +1. classical security level: searching a 2^128 key space is as implausible as 2^256. +2. post-quantum security level: the difference is more meaningful, and AES-256 seems like the conservative choice. +3. performance: AES-256 is around 40% slower than AES-128, though hardware acceleration typically narrows this gap. + +The choice is frankly quite marginal. + +### Why is AES-GCM preferred over chacha20-poly1305? + +Hardware support for accelerating AES-GCM is widespread, and hardware-accelerated AES-GCM +is quicker than un-accelerated chacha20-poly1305. + +However, if you know your application will run on a platform without that, you should +_definitely_ change the default order to prefer chacha20-poly1305: both the performance and +the implementation security will be improved. We think this is an uncommon case. + +### Why is x25519 preferred for key exchange over nistp256? + +Both provide roughly the same classical security level, but x25519 has better performance and +it's _much_ more likely that both peers will have good quality implementations. + +### About the post-quantum-secure key exchange `X25519MLKEM768` + +[`X25519MLKEM768`] -- a hybrid[^1], post-quantum-secure[^2] key exchange +algorithm -- is available when using the aws-lc-rs provider. + +The `prefer-post-quantum` crate feature makes `X25519MLKEM768` the +highest-priority key exchange algorithm. Otherwise, it is available but +not highest-priority. + +[X25519MLKEM768] is pre-standardization, but is now widely deployed, +for example, by [Chrome] and [Cloudflare]. + +You may see unexpected connection failures (such as [tldr.fail]) +-- [please report these to us][interop-bug]. + +The two components of this key exchange are well regarded: +X25519 alone is already used by default by rustls, and tends to have +higher quality implementations than other elliptic curves. +ML-KEM-768 was standardized by NIST in [FIPS203]. + +[`MLKEM768`] is available separately, but is not currently enabled +by default out of conservatism. + +[^1]: meaning: a construction that runs a classical and post-quantum + key exchange, and uses the output of both together. This is a hedge + against the post-quantum half being broken. + +[^2]: a "post-quantum-secure" algorithm is one posited to be invulnerable + to attack using a cryptographically-relevant quantum computer. In contrast, + classical algorithms would be broken by such a computer. Note that such computers + do not currently exist, and may never exist, but current traffic could be captured + now and attacked later. + +[X25519MLKEM768]: +[`X25519MLKEM768`]: crate::crypto::aws_lc_rs::kx_group::X25519MLKEM768 +[`MLKEM768`]: crate::crypto::aws_lc_rs::kx_group::MLKEM768 +[FIPS203]: +[Chrome]: +[Cloudflare]: +[interop-bug]: +[tldr.fail]: + +*/ diff --git a/http/vendor/rustls/src/manual/features.rs b/http/vendor/rustls/src/manual/features.rs new file mode 100644 index 0000000..69daf48 --- /dev/null +++ b/http/vendor/rustls/src/manual/features.rs @@ -0,0 +1,100 @@ +/*! + +The below list reflects the support provided with the default crate features. +Items marked with an asterisk `*` can be extended or altered via public +APIs ([`CryptoProvider`] for example). + +[`CryptoProvider`]: crate::crypto::CryptoProvider + +## Current features + +* TLS1.2 and TLS1.3 +* ECDSA, Ed25519 or RSA server authentication by clients `*` +* ECDSA, Ed25519[^1] or RSA server authentication by servers `*` +* Forward secrecy using ECDHE; with curve25519, nistp256 or nistp384 curves `*` +* Post-quantum hybrid key exchange with [X25519MLKEM768](https://datatracker.ietf.org/doc/draft-ietf-tls-ecdhe-mlkem/) [^2] `*` +* AES128-GCM and AES256-GCM bulk encryption, with safe nonces `*` +* ChaCha20-Poly1305 bulk encryption ([RFC7905](https://tools.ietf.org/html/rfc7905)) `*` +* ALPN support +* SNI support +* Tunable fragment size to make TLS messages match size of underlying transport +* Optional use of vectored IO to minimise system calls +* TLS1.2 session resumption +* TLS1.2 resumption via tickets ([RFC5077](https://tools.ietf.org/html/rfc5077)) +* TLS1.3 resumption via tickets or session storage +* TLS1.3 0-RTT data +* Server and optional client authentication +* Extended master secret support ([RFC7627](https://tools.ietf.org/html/rfc7627)) +* Exporters ([RFC5705](https://tools.ietf.org/html/rfc5705)) +* OCSP stapling by servers +* [RFC7250](https://tools.ietf.org/html/rfc7250) raw public keys for TLS1.3 +* [RFC8879](https://tools.ietf.org/html/rfc8879) certificate compression by clients + and servers `*` +* Client-side Encrypted client hello (ECH) + ([draft-ietf-tls-esni](https://datatracker.ietf.org/doc/draft-ietf-tls-esni/)). + +[^1]: Note that, at the time of writing, Ed25519 does not have wide support + in browsers. It is also not supported by the WebPKI, because the + CA/Browser Forum Baseline Requirements do not support it for publicly + trusted certificates. +[^2]: See [the documentation][crate::manual::_05_defaults#about-the-post-quantum-secure-key-exchange-x25519mlkem768] + +## Non-features + +For reasons explained in the other sections of this manual, rustls does not +and will not support: + +* SSL1, SSL2, SSL3, TLS1 or TLS1.1 +* RC4 +* DES or triple DES +* EXPORT ciphersuites +* MAC-then-encrypt ciphersuites +* Ciphersuites without forward secrecy +* Renegotiation +* Kerberos +* TLS 1.2 protocol compression +* Discrete-log Diffie-Hellman `*` +* Automatic protocol version downgrade +* Using CA certificates directly to authenticate a server/client (often called "self-signed + certificates"). _Rustls' default certificate verifier does not support using a trust anchor as + both a CA certificate and an end-entity certificate in order to limit complexity and risk in + path building. While dangerous, all authentication can be turned off if required -- + see the [example code](https://github.com/rustls/rustls/blob/v/0.23.23/examples/src/bin/tlsclient-mio.rs#L338)_ `*` + +### About "custom extensions" + +OpenSSL allows an application to add arbitrary TLS extensions (via +the `SSL_CTX_add_custom_ext` function and associated APIs). We don't +support this, with the following rationale: + +Such an API is limited to extensions that are quite narrow in scope: +they cannot change the meaning of standard messages, or introduce new +messages, or make any changes to the connection's cryptography. + +However, there is no reasonable way to technically limit that API to +that set of extensions. That makes the API pretty unsafe (in the +TLS and cryptography sense, not memory safety sense). This could +cause security or interop failures. + +Instead, we suggest that potential users of that API consider: + +- whether their use can fit in standard extensions such as ALPN, + or [ALPS][alps][^3]. +- if not, whether they can fit in a more general extension, and define + and standardize that in the [IETF TLSWG][tlswg]. + +Note the above is not a guarantee or offer that rustls will implement +any specific extensions that are standardized by the IETF TLSWG. +It is a non-goal of this project to implement absolutely everything. + +For experimentation and pre-standardization testing, we suggest +forking rustls. + +See also: [Go's position on such an API][golang]. + +[alps]: https://datatracker.ietf.org/doc/html/draft-vvv-tls-alps +[golang]: https://github.com/golang/go/issues/51497 +[tlswg]: https://datatracker.ietf.org/wg/tls/charter/ +[^3]: rustls does not currently implement ALPS, but it is something we + would consider once standardised and deployed. +*/ diff --git a/http/vendor/rustls/src/manual/fips.rs b/http/vendor/rustls/src/manual/fips.rs new file mode 100644 index 0000000..04a2428 --- /dev/null +++ b/http/vendor/rustls/src/manual/fips.rs @@ -0,0 +1,63 @@ +/*! # Using rustls with FIPS-approved cryptography + +To use FIPS-approved cryptography with rustls, you should +utilize a FIPS-approved `CryptoProvider`. +rustls ships with one using `aws-lc-rs`, take these actions to make use of it: + +## 1. Enable the `fips` crate feature for rustls. + +Use: + +```toml +rustls = { version = "0.23", features = [ "fips" ] } +``` + +## 2. Use the FIPS `CryptoProvider` + +This is [`default_fips_provider()`]: + +```rust,ignore +rustls::crypto::default_fips_provider() + .install_default() + .expect("default provider already set elsewhere"); +``` + +This snippet makes use of the process-default provider, +and that assumes all your uses of rustls use that. +See [`CryptoProvider`] documentation for other ways to +specify which `CryptoProvider` to use. + +## 3. Validate the FIPS status of your `ClientConfig`/`ServerConfig` at run-time + +See [`ClientConfig::fips()`] or [`ServerConfig::fips()`]. + +You could, for example: + +```rust,ignore +# let client_config = unreachable!(); +assert!(client_config.fips()); +``` + +But maybe your application has an error handling +or health-check strategy better than panicking. + +# aws-lc-rs FIPS approval status + +This is covered by [FIPS 140-3 certificate #4816][cert-4816]. +See [the security policy][policy-4816] for precisely which +environments and functions this certificate covers. + +Later releases of aws-lc-rs may be covered by later certificates, +or be pending certification. + +For the most up-to-date details see the latest documentation +for the [`aws-lc-fips-sys`] crate. + +[`aws-lc-fips-sys`]: https://crates.io/crates/aws-lc-fips-sys +[`default_fips_provider()`]: crate::crypto::default_fips_provider +[`CryptoProvider`]: crate::crypto::CryptoProvider +[`ClientConfig::fips()`]: crate::client::ClientConfig::fips +[`ServerConfig::fips()`]: crate::server::ServerConfig::fips +[cert-4816]: https://csrc.nist.gov/projects/cryptographic-module-validation-program/certificate/4816 +[policy-4816]: https://csrc.nist.gov/CSRC/media/projects/cryptographic-module-validation-program/documents/security-policies/140sp4816.pdf +*/ diff --git a/http/vendor/rustls/src/manual/howto.rs b/http/vendor/rustls/src/manual/howto.rs new file mode 100644 index 0000000..6c00c69 --- /dev/null +++ b/http/vendor/rustls/src/manual/howto.rs @@ -0,0 +1,124 @@ +/*! # Customising private key usage + +By default rustls supports PKCS#8-format[^1] RSA or ECDSA keys, plus PKCS#1-format RSA keys. + +However, if your private key resides in a HSM, or in another process, or perhaps +another machine, rustls has some extension points to support this: + +The main trait you must implement is [`sign::SigningKey`][signing_key]. The primary method here +is [`choose_scheme()`][choose_scheme] where you are given a set of [`SignatureScheme`s][sig_scheme] the client says +it supports: you must choose one (or return `None` -- this aborts the handshake). Having +done that, you return an implementation of the [`sign::Signer`][signer] trait. +The [`sign()`][sign_method] performs the signature and returns it. + +(Unfortunately this is currently designed for keys with low latency access, like in a +PKCS#11 provider, Microsoft CryptoAPI, etc. so is blocking rather than asynchronous. +It's a TODO to make these and other extension points async.) + +Once you have these two pieces, configuring a server to use them involves, briefly: + +- packaging your [`sign::SigningKey`][signing_key] with the matching certificate chain into a [`sign::CertifiedKey`][certified_key] +- making a [`ResolvesServerCertUsingSni`][cert_using_sni] and feeding in your [`sign::CertifiedKey`][certified_key] for all SNI hostnames you want to use it for, +- setting that as your `ServerConfig`'s [`cert_resolver`][cert_resolver] + +For a complete example of implementing a custom [`sign::SigningKey`][signing_key] and +[`sign::Signer`][signer] see the [`signer` module in the `rustls-cng` crate][rustls-cng-signer]. + +[signing_key]: crate::crypto::signer::SigningKey +[choose_scheme]: crate::crypto::signer::SigningKey::choose_scheme +[sig_scheme]: crate::SignatureScheme +[signer]: crate::crypto::signer::Signer +[sign_method]: crate::crypto::signer::Signer::sign +[certified_key]: crate::crypto::signer::CertifiedKey +[cert_using_sni]: crate::server::ResolvesServerCertUsingSni +[cert_resolver]: crate::ServerConfig::cert_resolver +[rustls-cng-signer]: https://github.com/rustls/rustls-cng/blob/dev/src/signer.rs + +[^1]: For PKCS#8 it does not support password encryption -- there's not a meaningful threat + model addressed by this, and the encryption supported is typically extremely poor. + +# Unexpected EOF + +TLS has a `close_notify` mechanism to prevent truncation attacks[^2]. +According to the TLS RFCs, each party is required to send a `close_notify` message before +closing the write side of the connection. However, some implementations don't send it. +So long as the application layer protocol (for instance HTTP/2) has message length framing +and can reject truncated messages, this is not a security problem. + +Rustls treats an EOF without `close_notify` as an error of type `std::io::Error` with +`ErrorKind::UnexpectedEof`. In some situations it's appropriate for the application to handle +this error the same way it would handle a normal EOF (a read returning `Ok(0)`). In particular +if `UnexpectedEof` occurs on an idle connection it is appropriate to treat it the same way as a +clean shutdown. And if an application always uses messages with length framing (in other words, +messages are never delimited by the close of the TCP connection), it can unconditionally +ignore `UnexpectedEof` errors from rustls. + +[^2]: + +# Debugging + +If you encounter a bug with Rustls it can be helpful to collect up as much diagnostic +information as possible. + +## Collecting logs + +If your bug reproduces with one of the [Rustls examples] you can use the +[`RUST_LOG`] environment variable to increase the log verbosity. If you're using +your own application, you may need to configure it with a logging backend +like `env_logger`. + +Consider reproducing your bug with `RUST_LOG=rustls=trace` and sharing the result +in a [GitHub gist]. + +[Rustls examples]: https://github.com/rustls/rustls/tree/main/examples +[`RUST_LOG`]: https://docs.rs/env_logger/latest/env_logger/#enabling-logging +[`env_logger`]: https://docs.rs/env_logger/ +[GitHub gist]: https://docs.github.com/en/get-started/writing-on-github/editing-and-sharing-content-with-gists/creating-gists + +## Taking a packet capture + +When logs aren't enough taking a packet capture ("pcap") is another helpful tool. +The details of how to accomplish this vary by operating system/context. + +### tcpdump + +As one example, on Linux using [`tcpdump`] is often easiest. + +If you know the IP address of the remote server your bug demonstrates with you +could take a short packet capture with this command (after replacing +`XX.XX.XX.XX` with the correct IP address): + +```bash +sudo tcpdump -i any tcp and dst host XX.XX.XX.XX -C5 -w rustls.pcap +``` + +The `-i any` captures on any network interface. The `tcp and dst host XX.XX.XX.XX` +portion target the capture to TCP traffic to the specified IP address. The `-C5` +argument limits the capture to at most 5MB. Lastly the `-w` argument writes the +capture to `rustls.pcap`. + +Another approach is to use `tcp and port XXXX` instead of `tcp and dst host XX.XX.XX.XX` +to capture all traffic to a specific port instead of a specific host server. + +[`tcpdump`]: https://www.redhat.com/en/blog/introduction-using-tcpdump-linux-command-line + +### SSLKEYLOGFILE + +If the bug you are reporting happens after data is encrypted you may also wish to +share the secret keys required to decrypt the post-handshake traffic. + +If you're using one of the [Rustls examples] you can set the `SSLKEYLOGFILE` environment +variable to a path where secrets will be written. E.g. `SSLKEYLOGFILE=rustls.pcap.keys`. + +If you're using your own application you may need to customize the Rustls `ClientConfig` +or `ServerConfig`'s `key_log` setting like the example applications do. + +With the file from `SSLKEYLOGFILE` it is possible to use [Wireshark] or another tool to +decrypt the post-handshake messages, following [these instructions][curl-sslkeylogfile]. + +Remember this allows plaintext decryption and should only be done in testing contexts +where no sensitive data (API keys, etc) are being shared. + +[Wireshark]: https://www.wireshark.org/download.html +[curl-sslkeylogfile]: https://everything.curl.dev/usingcurl/tls/sslkeylogfile.html +*/ diff --git a/http/vendor/rustls/src/manual/implvulns.rs b/http/vendor/rustls/src/manual/implvulns.rs new file mode 100644 index 0000000..a073350 --- /dev/null +++ b/http/vendor/rustls/src/manual/implvulns.rs @@ -0,0 +1,104 @@ +/*! # A review of TLS Implementation Vulnerabilities + +An important part of engineering involves studying and learning from the mistakes of the past. +It would be tremendously unfortunate to spend effort re-discovering and re-fixing the same +vulnerabilities that were discovered in the past. + +## Memory safety + +Being written entirely in the safe-subset of Rust immediately offers us freedom from the entire +class of memory safety vulnerabilities. There are too many to exhaustively list, and there will +certainly be more in the future. + +Examples: + +- Heartbleed [CVE-2014-0160](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-0160) (OpenSSL) +- Memory corruption in ASN.1 decoder [CVE-2016-2108](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-2108) (OpenSSL) +- Buffer overflow in read_server_hello [CVE-2014-3466](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-3466) (GnuTLS) + +## `goto fail` + +This is the name of a vulnerability in Apple Secure Transport [CVE-2014-1266](https://nvd.nist.gov/vuln/detail/CVE-2014-1266). +This boiled down to the following code, which validates the server's signature on the key exchange: + +```c + if ((err = SSLHashSHA1.update(&hashCtx, &serverRandom)) != 0) + goto fail; + if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0) + goto fail; +> goto fail; + if ((err = SSLHashSHA1.final(&hashCtx, &hashOut)) != 0) + goto fail; +``` + +The marked line was duplicated, likely accidentally during a merge. This meant +the remaining part of the function (including the actual signature validation) +was unconditionally skipped. + +Ultimately the one countermeasure to this type of bug is basic testing: that a +valid signature returns success, and that an invalid one does not. rustls +has such testing, but this is really table stakes for security code. + +Further than this, though, we could consider that the *lack* of an error from +this function is a poor indicator that the signature was valid. rustls, instead, +has zero-size and non-copyable types that indicate a particular signature validation +has been performed. These types can be thought of as *capabilities* originated only +by designated signature verification functions -- such functions can then be a focus +of manual code review. Like capabilities, values of these types are otherwise unforgeable, +and are communicable only by Rust's move semantics. + +Values of these types are threaded through the protocol state machine, leading to terminal +states that look like: + +```ignore +struct ExpectTraffic { + (...) + _cert_verified: verify::ServerCertVerified, + _sig_verified: verify::HandshakeSignatureValid, + _fin_verified: verify::FinishedMessageVerified, +} +``` + +Since this state requires a value of these types, it will be a compile-time error to +reach that state without performing the requisite security-critical operations. + +This approach is not infallible, but it has zero runtime cost. + +## State machine attacks: EarlyCCS and SMACK/SKIP/FREAK + +EarlyCCS [CVE-2014-0224](https://nvd.nist.gov/vuln/detail/CVE-2014-0224) was a vulnerability in OpenSSL +found in 2014. The TLS `ChangeCipherSpec` message would be processed at inappropriate times, leading +to data being encrypted with the wrong keys (specifically, keys which were not secret). This resulted +from OpenSSL taking a *reactive* strategy to incoming messages ("when I get a message X, I should do Y") +which allows it to diverge from the proper state machine under attacker control. + +[SMACK](https://mitls.org/pages/attacks/SMACK) is a similar suite of vulnerabilities found in JSSE, +CyaSSL, OpenSSL, Mono and axTLS. "SKIP-TLS" demonstrated that some implementations allowed handshake +messages (and in one case, the entire handshake!) to be skipped leading to breaks in security. "FREAK" +found that some implementations incorrectly allowed export-only state transitions (i.e., transitions that +were only valid when an export ciphersuite was in use). + +rustls represents its protocol state machine carefully to avoid these defects. We model the handshake, +CCS and application data subprotocols in the same single state machine. Each state in this machine is +represented with a single struct, and transitions are modelled as functions that consume the current state +plus one TLS message[^1] and return a struct representing the next state. These functions fully validate +the message type before further operations. + +A sample sequence for a full TLSv1.2 handshake by a client looks like: + +- `hs::ExpectServerHello` (Note: ClientHello is logically sent before this state); transition to `tls12::ExpectCertificate` +- `tls12::ExpectCertificate`; transition to `tls12::ExpectServerKX` +- `tls12::ExpectServerKX`; transition to `tls12::ExpectServerDoneOrCertReq` +- `tls12::ExpectServerDoneOrCertReq`; delegates to `tls12::ExpectCertificateRequest` or `tls12::ExpectServerDone` depending on incoming message. + - `tls12::ExpectServerDone`; transition to `tls12::ExpectCCS` +- `tls12::ExpectCCS`; transition to `tls12::ExpectFinished` +- `tls12::ExpectFinished`; transition to `tls12::ExpectTraffic` +- `tls12::ExpectTraffic`; terminal state; transitions to `tls12::ExpectTraffic` + +In the future we plan to formally prove that all possible transitions modelled in this system of types +are correct with respect to the standard(s). At the moment we rely merely on exhaustive testing. + +[^1]: a logical TLS message: post-decryption, post-fragmentation. + + +*/ diff --git a/http/vendor/rustls/src/manual/mod.rs b/http/vendor/rustls/src/manual/mod.rs new file mode 100644 index 0000000..0e4fddc --- /dev/null +++ b/http/vendor/rustls/src/manual/mod.rs @@ -0,0 +1,34 @@ +/*! + +This documentation primarily aims to explain design decisions taken in rustls. + +It does this from a few aspects: how rustls attempts to avoid construction errors +that occurred in other TLS libraries, how rustls attempts to avoid past TLS +protocol vulnerabilities, and assorted advice for achieving common tasks with rustls. +*/ +#![allow(non_snake_case)] + +/// This section discusses vulnerabilities in other TLS implementations, theorising their +/// root cause and how we aim to avoid them in rustls. +#[path = "implvulns.rs"] +pub mod _01_impl_vulnerabilities; + +/// This section discusses vulnerabilities and design errors in the TLS protocol. +#[path = "tlsvulns.rs"] +pub mod _02_tls_vulnerabilities; + +/// This section collects together goal-oriented documentation. +#[path = "howto.rs"] +pub mod _03_howto; + +/// This section documents rustls itself: what protocol features are and are not implemented. +#[path = "features.rs"] +pub mod _04_features; + +/// This section provides rationale for the defaults in rustls. +#[path = "defaults.rs"] +pub mod _05_defaults; + +/// This section provides guidance on using rustls with FIPS-approved cryptography. +#[path = "fips.rs"] +pub mod _06_fips; diff --git a/http/vendor/rustls/src/manual/tlsvulns.rs b/http/vendor/rustls/src/manual/tlsvulns.rs new file mode 100644 index 0000000..6d2220e --- /dev/null +++ b/http/vendor/rustls/src/manual/tlsvulns.rs @@ -0,0 +1,175 @@ +/*! # A review of protocol vulnerabilities + +## CBC MAC-then-encrypt ciphersuites + +Back in 2000 [Bellare and Namprempre](https://eprint.iacr.org/2000/025) discussed how to make authenticated +encryption by composing separate encryption and authentication primitives. That paper included this table: + +| Composition Method | Privacy | | | Integrity | | +|--------------------|---------|-|-|-----------|-| +|| IND-CPA | IND-CCA | NM-CPA | INT-PTXT | INT-CTXT | +| Encrypt-and-MAC | insecure | insecure | insecure | secure | insecure | +| MAC-then-encrypt | secure | insecure | insecure | secure | insecure | +| Encrypt-then-MAC | secure | secure | secure | secure | secure | + +One may assume from this fairly clear result that encrypt-and-MAC and MAC-then-encrypt compositions would be quickly abandoned +in favour of the remaining proven-secure option. But that didn't happen, not in TLSv1.1 (2006) nor in TLSv1.2 (2008). Worse, +both RFCs included incorrect advice on countermeasures for implementers, suggesting that the flaw was "not believed to be large +enough to be exploitable". + +[Lucky 13](http://www.isg.rhul.ac.uk/tls/Lucky13.html) (2013) exploited this flaw and affected all implementations, including +those written [after discovery](https://aws.amazon.com/blogs/security/s2n-and-lucky-13/). OpenSSL even had a +[memory safety vulnerability in the fix for Lucky 13](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-2107), which +gives a flavour of the kind of complexity required to remove the side channel. + +rustls does not implement CBC MAC-then-encrypt ciphersuites for these reasons. TLSv1.3 removed support for these +ciphersuites in 2018. + +There are some further rejected options worth mentioning: [RFC7366](https://tools.ietf.org/html/rfc7366) defines +Encrypt-then-MAC for TLS, but unfortunately cannot be negotiated without also supporting MAC-then-encrypt +(clients cannot express "I offer CBC, but only EtM and not MtE"). + +## RSA PKCS#1 encryption + +"RSA key exchange" in TLS involves the client choosing a large random value and encrypting it using the server's +public key. This has two overall problems: + +1. It provides no _forward secrecy_: later compromise of the server's private key breaks confidentiality of + *all* past sessions using that key. This is a crucial property in the presence of software that is often + [poor at keeping a secret](http://heartbleed.com/). +2. The padding used in practice in TLS ("PKCS#1", or fully "RSAES-PKCS1-v1_5") has been known to be broken since + [1998](http://archiv.infsec.ethz.ch/education/fs08/secsem/bleichenbacher98.pdf). + +In a similar pattern to the MAC-then-encrypt problem discussed above, TLSv1.0 (1999), TLSv1.1 (2006) and TLSv1.2 (2008) +continued to specify use of PKCS#1 encryption, again with incrementally more complex and incorrect advice on countermeasures. + +[ROBOT](https://robotattack.org/) (2018) showed that implementations were still vulnerable to these attacks twenty years later. +[The Marvin Attack](https://people.redhat.com/~hkario/marvin/) (2023) demonstrated the same a further five years later. + +rustls does not support RSA key exchange. TLSv1.3 also removed support. + +## BEAST + +[BEAST](https://vnhacker.blogspot.com/2011/09/beast.html) ([CVE-2011-3389](https://nvd.nist.gov/vuln/detail/CVE-2011-3389)) +was demonstrated in 2011 by Thai Duong and Juliano Rizzo, +and was another vulnerability in CBC-based ciphersuites in SSLv3.0 and TLSv1.0. CBC mode is vulnerable to adaptive +chosen-plaintext attacks if the IV is predictable. In the case of these protocol versions, the IV was the previous +block of ciphertext (as if the entire TLS session was one CBC ciphertext, albeit revealed incrementally). This was +obviously predictable, since it was published on the wire. + +OpenSSL contained a countermeasure for this problem from 2002 onwards: it encrypts an empty message before each real +one, so that the IV used in the real message is unpredictable. This was turned off by default due to bugs in IE6. + +TLSv1.1 fix this vulnerability, but not any of the other deficiencies of CBC mode (see above). + +rustls does not support these ciphersuites. + +## CRIME + +In 2002 [John Kelsey](https://www.iacr.org/cryptodb/archive/2002/FSE/3091/3091.pdf) discussed the length side channel +as applied to compression of combined secret and attacker-chosen strings. + +Compression continued to be an option in TLSv1.1 (2006) and in TLSv1.2 (2008). Support in libraries was widespread. + +[CRIME](https://en.wikipedia.org/wiki/CRIME) ([CVE-2012-4929](https://nvd.nist.gov/vuln/detail/CVE-2012-4929)) +was demonstrated in 2012, again by Thai Duong and Juliano Rizzo. It attacked several protocols offering transparent +compression of application data, allowing quick adaptive chosen-plaintext attacks against secret values like cookies. + +rustls does not implement compression. TLSv1.3 also removed support. + +## Logjam / FREAK + +Way back when SSL was first being born, circa 1995, the US government considered cryptography a munition requiring +export control. SSL contained specific ciphersuites with dramatically small key sizes that were not subject +to export control. These controls were dropped in 2000. + +Since the "export-grade" ciphersuites no longer fulfilled any purpose, and because they were actively harmful to users, +one may have expected software support to disappear quickly. This did not happen. + +In 2015 [the FREAK attack](https://mitls.org/pages/attacks/SMACK#freak) ([CVE-2015-0204](https://nvd.nist.gov/vuln/detail/CVE-2015-0204)) +and [the Logjam attack](https://weakdh.org/) ([CVE-2015-4000](https://nvd.nist.gov/vuln/detail/CVE-2015-4000)) both +demonstrated total breaks of security in the presence of servers that accepted export ciphersuites. FREAK factored +512-bit RSA keys, while Logjam optimised solving discrete logs in the 512-bit group used by many different servers. + +Naturally, rustls does not implement any of these ciphersuites. + +## SWEET32 + +Block ciphers are vulnerable to birthday attacks, where the probability of repeating a block increases dramatically +once a particular key has been used for many blocks. For block ciphers with 64-bit blocks, this becomes probable +once a given key encrypts the order of 32GB of data. + +[Sweet32](https://sweet32.info/) ([CVE-2016-2183](https://nvd.nist.gov/vuln/detail/CVE-2016-2183)) attacked this fact +in the context of TLS support for 3DES, breaking confidentiality by analysing a large amount of attacker-induced traffic +in one session. + +rustls does not support any 64-bit block ciphers. + +## DROWN + +[DROWN](https://drownattack.com/) ([CVE-2016-0800](https://nvd.nist.gov/vuln/detail/CVE-2016-0800)) is a cross-protocol +attack that breaks the security of TLSv1.2 and earlier (when used with RSA key exchange) by using SSLv2. It is required +that the server uses the same key for both protocol versions. + +rustls naturally does not support SSLv2, but most importantly does not support RSA key exchange for TLSv1.2. + +## Poodle + +[POODLE](https://cdn1.vox-cdn.com/uploads/chorus_asset/file/2354994/ssl-poodle.0.pdf) ([CVE-2014-3566](https://nvd.nist.gov/vuln/detail/CVE-2014-3566)) +is an attack against CBC mode ciphersuites in SSLv3. This was possible in most cases because some clients willingly +downgraded to SSLv3 after failed handshakes for later versions. + +rustls does not support CBC mode ciphersuites, or SSLv3. Note that rustls does not need to implement `TLS_FALLBACK_SCSV` +introduced as a countermeasure because it contains no ability to downgrade from TLS 1.2 to earlier protocol versions, +and TLS 1.3 has protocol-level downgrade protection based on the [ServerHello server random value](https://www.rfc-editor.org/rfc/rfc8446#section-4.1.3). + +## GCM nonces + +[RFC5288](https://tools.ietf.org/html/rfc5288) introduced GCM-based ciphersuites for use in TLS. Unfortunately +the design was poor; it reused design for an unrelated security setting proposed in RFC5116. + +GCM is a typical nonce-based AEAD: it requires a unique (but not necessarily unpredictable) 96-bit nonce for each encryption +with a given key. The design specified by RFC5288 left two-thirds of the nonce construction up to implementations: + +- wasting 8 bytes per TLS ciphertext, +- meaning correct operation cannot be tested for (e.g., in protocol-level test vectors). + +There were no trade-offs here: TLS has a 64-bit sequence number that is not allowed to wrap and would make an ideal nonce. + +As a result, a [2016 study](https://eprint.iacr.org/2016/475.pdf) found: + +- implementations from IBM, A10 and Citrix used randomly-chosen nonces, which are unlikely to be unique over long connections, +- an implementation from Radware used the same nonce for the first two messages. + +rustls uses a counter from a random starting point for GCM nonces. TLSv1.3 and the Chacha20-Poly1305 TLSv1.2 ciphersuite +standardise this method. + +## Renegotiation + +In 2009 Marsh Ray and Steve Dispensa [discovered](https://kryptera.se/Renegotiating%20TLS.pdf) that the renegotiation +feature of all versions of TLS allows a MitM to splice a request of their choice onto the front of the client's real HTTP +request. A countermeasure was proposed and widely implemented to bind renegotiations to their previous negotiations; +unfortunately this was insufficient. + +rustls does not support renegotiation in TLSv1.2. TLSv1.3 also no longer supports renegotiation. + +## 3SHAKE + +[3SHAKE](https://www.mitls.org/pages/attacks/3SHAKE) (2014) described a complex attack that broke the "Secure Renegotiation" extension +introduced as a countermeasure to the previous protocol flaw. + +rustls does not support renegotiation for TLSv1.2 connections, or RSA key exchange, and both are required for this attack +to work. rustls implements the "Extended Master Secret" (RFC7627) extension for TLSv1.2 which was standardised as a countermeasure. + +TLSv1.3 no longer supports renegotiation and RSA key exchange. It also effectively incorporates the improvements made in RFC7627. + +## KCI + +[This vulnerability](https://kcitls.org/) makes use of TLS ciphersuites (those offering static DH) which were standardised +yet not widely used. However, they were implemented by libraries, and as a result enabled for various clients. It coupled +this with misconfigured certificates (on services including facebook.com) which allowed their misuse to MitM connections. + +rustls does not support static DH/EC-DH ciphersuites. We assert that it is misissuance to sign an EC certificate +with the keyUsage extension allowing both signatures and key exchange. That it isn't is probably a failure +of CAB Forum baseline requirements. +*/ diff --git a/http/vendor/rustls/src/msgs/alert.rs b/http/vendor/rustls/src/msgs/alert.rs new file mode 100644 index 0000000..e66f64c --- /dev/null +++ b/http/vendor/rustls/src/msgs/alert.rs @@ -0,0 +1,26 @@ +use alloc::vec::Vec; + +use crate::enums::AlertDescription; +use crate::error::InvalidMessage; +use crate::msgs::codec::{Codec, Reader}; +use crate::msgs::enums::AlertLevel; + +#[derive(Debug)] +pub struct AlertMessagePayload { + pub level: AlertLevel, + pub description: AlertDescription, +} + +impl Codec<'_> for AlertMessagePayload { + fn encode(&self, bytes: &mut Vec) { + self.level.encode(bytes); + self.description.encode(bytes); + } + + fn read(r: &mut Reader<'_>) -> Result { + let level = AlertLevel::read(r)?; + let description = AlertDescription::read(r)?; + r.expect_empty("AlertMessagePayload") + .map(|_| Self { level, description }) + } +} diff --git a/http/vendor/rustls/src/msgs/base.rs b/http/vendor/rustls/src/msgs/base.rs new file mode 100644 index 0000000..4204714 --- /dev/null +++ b/http/vendor/rustls/src/msgs/base.rs @@ -0,0 +1,238 @@ +use alloc::vec::Vec; +use core::fmt; +use core::marker::PhantomData; + +use pki_types::CertificateDer; +use zeroize::Zeroize; + +use crate::error::InvalidMessage; +use crate::msgs::codec; +use crate::msgs::codec::{Codec, Reader}; + +/// An externally length'd payload +#[derive(Clone, Eq, PartialEq)] +pub enum Payload<'a> { + Borrowed(&'a [u8]), + Owned(Vec), +} + +impl<'a> Codec<'a> for Payload<'a> { + fn encode(&self, bytes: &mut Vec) { + bytes.extend_from_slice(self.bytes()); + } + + fn read(r: &mut Reader<'a>) -> Result { + Ok(Self::read(r)) + } +} + +impl<'a> Payload<'a> { + pub fn bytes(&self) -> &[u8] { + match self { + Self::Borrowed(bytes) => bytes, + Self::Owned(bytes) => bytes, + } + } + + pub fn into_owned(self) -> Payload<'static> { + Payload::Owned(self.into_vec()) + } + + pub fn into_vec(self) -> Vec { + match self { + Self::Borrowed(bytes) => bytes.to_vec(), + Self::Owned(bytes) => bytes, + } + } + + pub fn read(r: &mut Reader<'a>) -> Self { + Self::Borrowed(r.rest()) + } +} + +impl Payload<'static> { + pub fn new(bytes: impl Into>) -> Self { + Self::Owned(bytes.into()) + } + + pub fn empty() -> Self { + Self::Borrowed(&[]) + } +} + +impl<'a> Codec<'a> for CertificateDer<'a> { + fn encode(&self, bytes: &mut Vec) { + codec::u24(self.as_ref().len() as u32).encode(bytes); + bytes.extend(self.as_ref()); + } + + fn read(r: &mut Reader<'a>) -> Result { + let len = codec::u24::read(r)?.0 as usize; + let mut sub = r.sub(len)?; + let body = sub.rest(); + Ok(Self::from(body)) + } +} + +impl fmt::Debug for Payload<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + hex(f, self.bytes()) + } +} + +/// An arbitrary, unknown-content, u24-length-prefixed payload +#[derive(Clone, Eq, PartialEq)] +pub(crate) struct PayloadU24<'a>(pub(crate) Payload<'a>); + +impl PayloadU24<'_> { + pub(crate) fn into_owned(self) -> PayloadU24<'static> { + PayloadU24(self.0.into_owned()) + } +} + +impl<'a> Codec<'a> for PayloadU24<'a> { + fn encode(&self, bytes: &mut Vec) { + let inner = self.0.bytes(); + codec::u24(inner.len() as u32).encode(bytes); + bytes.extend_from_slice(inner); + } + + fn read(r: &mut Reader<'a>) -> Result { + let len = codec::u24::read(r)?.0 as usize; + let mut sub = r.sub(len)?; + Ok(Self(Payload::read(&mut sub))) + } +} + +impl fmt::Debug for PayloadU24<'_> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + self.0.fmt(f) + } +} + +/// An arbitrary, unknown-content, u16-length-prefixed payload +/// +/// The `C` type parameter controls whether decoded values may +/// be empty. +#[derive(Clone, Eq, PartialEq)] +pub struct PayloadU16(pub(crate) Vec, PhantomData); + +impl PayloadU16 { + pub fn new(bytes: Vec) -> Self { + debug_assert!(bytes.len() >= C::MIN); + Self(bytes, PhantomData) + } +} + +impl PayloadU16 { + pub(crate) fn empty() -> Self { + Self::new(Vec::new()) + } +} + +impl Codec<'_> for PayloadU16 { + fn encode(&self, bytes: &mut Vec) { + debug_assert!(self.0.len() >= C::MIN); + (self.0.len() as u16).encode(bytes); + bytes.extend_from_slice(&self.0); + } + + fn read(r: &mut Reader<'_>) -> Result { + let len = u16::read(r)? as usize; + if len < C::MIN { + return Err(InvalidMessage::IllegalEmptyValue); + } + let mut sub = r.sub(len)?; + let body = sub.rest().to_vec(); + Ok(Self(body, PhantomData)) + } +} + +impl fmt::Debug for PayloadU16 { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + hex(f, &self.0) + } +} + +/// An arbitrary, unknown-content, u8-length-prefixed payload +/// +/// `C` controls the minimum length accepted when decoding. +#[derive(Clone, Eq, PartialEq)] +pub(crate) struct PayloadU8(pub(crate) Vec, PhantomData); + +impl PayloadU8 { + pub(crate) fn encode_slice(slice: &[u8], bytes: &mut Vec) { + (slice.len() as u8).encode(bytes); + bytes.extend_from_slice(slice); + } + + pub(crate) fn new(bytes: Vec) -> Self { + debug_assert!(bytes.len() >= C::MIN); + Self(bytes, PhantomData) + } +} + +impl PayloadU8 { + pub(crate) fn empty() -> Self { + Self(Vec::new(), PhantomData) + } +} + +impl Codec<'_> for PayloadU8 { + fn encode(&self, bytes: &mut Vec) { + debug_assert!(self.0.len() >= C::MIN); + (self.0.len() as u8).encode(bytes); + bytes.extend_from_slice(&self.0); + } + + fn read(r: &mut Reader<'_>) -> Result { + let len = u8::read(r)? as usize; + if len < C::MIN { + return Err(InvalidMessage::IllegalEmptyValue); + } + let mut sub = r.sub(len)?; + let body = sub.rest().to_vec(); + Ok(Self(body, PhantomData)) + } +} + +impl Zeroize for PayloadU8 { + fn zeroize(&mut self) { + self.0.zeroize(); + } +} + +impl fmt::Debug for PayloadU8 { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + hex(f, &self.0) + } +} + +pub trait Cardinality: Clone + Eq + PartialEq { + const MIN: usize; +} + +#[derive(Clone, Eq, PartialEq)] +pub struct MaybeEmpty; + +impl Cardinality for MaybeEmpty { + const MIN: usize = 0; +} + +#[derive(Clone, Eq, PartialEq)] +pub struct NonEmpty; + +impl Cardinality for NonEmpty { + const MIN: usize = 1; +} + +// Format an iterator of u8 into a hex string +pub(super) fn hex<'a>( + f: &mut fmt::Formatter<'_>, + payload: impl IntoIterator, +) -> fmt::Result { + for b in payload { + write!(f, "{b:02x}")?; + } + Ok(()) +} diff --git a/http/vendor/rustls/src/msgs/ccs.rs b/http/vendor/rustls/src/msgs/ccs.rs new file mode 100644 index 0000000..ac2c9e6 --- /dev/null +++ b/http/vendor/rustls/src/msgs/ccs.rs @@ -0,0 +1,23 @@ +use alloc::vec::Vec; + +use crate::error::InvalidMessage; +use crate::msgs::codec::{Codec, Reader}; + +#[derive(Debug)] +pub struct ChangeCipherSpecPayload; + +impl Codec<'_> for ChangeCipherSpecPayload { + fn encode(&self, bytes: &mut Vec) { + 1u8.encode(bytes); + } + + fn read(r: &mut Reader<'_>) -> Result { + let typ = u8::read(r)?; + if typ != 1 { + return Err(InvalidMessage::InvalidCcs); + } + + r.expect_empty("ChangeCipherSpecPayload") + .map(|_| Self {}) + } +} diff --git a/http/vendor/rustls/src/msgs/codec.rs b/http/vendor/rustls/src/msgs/codec.rs new file mode 100644 index 0000000..bd62cd3 --- /dev/null +++ b/http/vendor/rustls/src/msgs/codec.rs @@ -0,0 +1,404 @@ +use alloc::vec::Vec; +use core::fmt::Debug; +use core::marker::PhantomData; + +use crate::error::InvalidMessage; + +/// Wrapper over a slice of bytes that allows reading chunks from +/// with the current position state held using a cursor. +/// +/// A new reader for a sub section of the buffer can be created +/// using the `sub` function or a section of a certain length can +/// be obtained using the `take` function +pub struct Reader<'a> { + /// The underlying buffer storing the readers content + buffer: &'a [u8], + /// Stores the current reading position for the buffer + cursor: usize, +} + +impl<'a> Reader<'a> { + /// Creates a new Reader of the provided `bytes` slice with + /// the initial cursor position of zero. + pub fn init(bytes: &'a [u8]) -> Self { + Reader { + buffer: bytes, + cursor: 0, + } + } + + /// Attempts to create a new Reader on a sub section of this + /// readers bytes by taking a slice of the provided `length` + /// will return None if there is not enough bytes + pub fn sub(&mut self, length: usize) -> Result { + match self.take(length) { + Some(bytes) => Ok(Reader::init(bytes)), + None => Err(InvalidMessage::MessageTooShort), + } + } + + /// Borrows a slice of all the remaining bytes + /// that appear after the cursor position. + /// + /// Moves the cursor to the end of the buffer length. + pub fn rest(&mut self) -> &'a [u8] { + let rest = &self.buffer[self.cursor..]; + self.cursor = self.buffer.len(); + rest + } + + /// Attempts to borrow a slice of bytes from the current + /// cursor position of `length` if there is not enough + /// bytes remaining after the cursor to take the length + /// then None is returned instead. + pub fn take(&mut self, length: usize) -> Option<&'a [u8]> { + if self.left() < length { + return None; + } + let current = self.cursor; + self.cursor += length; + Some(&self.buffer[current..current + length]) + } + + /// Used to check whether the reader has any content left + /// after the cursor (cursor has not reached end of buffer) + pub fn any_left(&self) -> bool { + self.cursor < self.buffer.len() + } + + pub fn expect_empty(&self, name: &'static str) -> Result<(), InvalidMessage> { + match self.any_left() { + true => Err(InvalidMessage::TrailingData(name)), + false => Ok(()), + } + } + + /// Returns the cursor position which is also the number + /// of bytes that have been read from the buffer. + pub fn used(&self) -> usize { + self.cursor + } + + /// Returns the number of bytes that are still able to be + /// read (The number of remaining takes) + pub fn left(&self) -> usize { + self.buffer.len() - self.cursor + } +} + +/// Trait for implementing encoding and decoding functionality +/// on something. +pub trait Codec<'a>: Debug + Sized { + /// Function for encoding itself by appending itself to + /// the provided vec of bytes. + fn encode(&self, bytes: &mut Vec); + + /// Function for decoding itself from the provided reader + /// will return Some if the decoding was successful or + /// None if it was not. + fn read(_: &mut Reader<'a>) -> Result; + + /// Convenience function for encoding the implementation + /// into a vec and returning it + fn get_encoding(&self) -> Vec { + let mut bytes = Vec::new(); + self.encode(&mut bytes); + bytes + } + + /// Function for wrapping a call to the read function in + /// a Reader for the slice of bytes provided + /// + /// Returns `Err(InvalidMessage::ExcessData(_))` if + /// `Self::read` does not read the entirety of `bytes`. + fn read_bytes(bytes: &'a [u8]) -> Result { + let mut reader = Reader::init(bytes); + Self::read(&mut reader).and_then(|r| { + reader.expect_empty("read_bytes")?; + Ok(r) + }) + } +} + +impl Codec<'_> for u8 { + fn encode(&self, bytes: &mut Vec) { + bytes.push(*self); + } + + fn read(r: &mut Reader<'_>) -> Result { + match r.take(1) { + Some(&[byte]) => Ok(byte), + _ => Err(InvalidMessage::MissingData("u8")), + } + } +} + +pub(crate) fn put_u16(v: u16, out: &mut [u8]) { + let out: &mut [u8; 2] = (&mut out[..2]).try_into().unwrap(); + *out = u16::to_be_bytes(v); +} + +impl Codec<'_> for u16 { + fn encode(&self, bytes: &mut Vec) { + let mut b16 = [0u8; 2]; + put_u16(*self, &mut b16); + bytes.extend_from_slice(&b16); + } + + fn read(r: &mut Reader<'_>) -> Result { + match r.take(2) { + Some(&[b1, b2]) => Ok(Self::from_be_bytes([b1, b2])), + _ => Err(InvalidMessage::MissingData("u16")), + } + } +} + +// Make a distinct type for u24, even though it's a u32 underneath +#[allow(non_camel_case_types)] +#[derive(Debug, Copy, Clone)] +pub struct u24(pub u32); + +#[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))] +impl From for usize { + #[inline] + fn from(v: u24) -> Self { + v.0 as Self + } +} + +impl Codec<'_> for u24 { + fn encode(&self, bytes: &mut Vec) { + let be_bytes = u32::to_be_bytes(self.0); + bytes.extend_from_slice(&be_bytes[1..]); + } + + fn read(r: &mut Reader<'_>) -> Result { + match r.take(3) { + Some(&[a, b, c]) => Ok(Self(u32::from_be_bytes([0, a, b, c]))), + _ => Err(InvalidMessage::MissingData("u24")), + } + } +} + +impl Codec<'_> for u32 { + fn encode(&self, bytes: &mut Vec) { + bytes.extend(Self::to_be_bytes(*self)); + } + + fn read(r: &mut Reader<'_>) -> Result { + match r.take(4) { + Some(&[a, b, c, d]) => Ok(Self::from_be_bytes([a, b, c, d])), + _ => Err(InvalidMessage::MissingData("u32")), + } + } +} + +pub(crate) fn put_u64(v: u64, bytes: &mut [u8]) { + let bytes: &mut [u8; 8] = (&mut bytes[..8]).try_into().unwrap(); + *bytes = u64::to_be_bytes(v); +} + +impl Codec<'_> for u64 { + fn encode(&self, bytes: &mut Vec) { + let mut b64 = [0u8; 8]; + put_u64(*self, &mut b64); + bytes.extend_from_slice(&b64); + } + + fn read(r: &mut Reader<'_>) -> Result { + match r.take(8) { + Some(&[a, b, c, d, e, f, g, h]) => Ok(Self::from_be_bytes([a, b, c, d, e, f, g, h])), + _ => Err(InvalidMessage::MissingData("u64")), + } + } +} + +/// Implement `Codec` for lists of elements that implement `TlsListElement`. +/// +/// `TlsListElement` provides the size of the length prefix for the list. +impl<'a, T: Codec<'a> + TlsListElement + Debug> Codec<'a> for Vec { + fn encode(&self, bytes: &mut Vec) { + let nest = LengthPrefixedBuffer::new(T::SIZE_LEN, bytes); + + for i in self { + i.encode(nest.buf); + } + } + + fn read(r: &mut Reader<'a>) -> Result { + let mut ret = Self::new(); + for item in TlsListIter::::new(r)? { + ret.push(item?); + } + + Ok(ret) + } +} + +/// An iterator over a vector of `TlsListElements`. +/// +/// All uses _MUST_ exhaust the iterator, as errors may be delayed +/// until the last element. +pub(crate) struct TlsListIter<'a, T: Codec<'a> + TlsListElement + Debug> { + sub: Reader<'a>, + _t: PhantomData, +} + +impl<'a, T: Codec<'a> + TlsListElement + Debug> TlsListIter<'a, T> { + pub(crate) fn new(r: &mut Reader<'a>) -> Result { + let len = T::SIZE_LEN.read(r)?; + let sub = r.sub(len)?; + Ok(Self { + sub, + _t: PhantomData, + }) + } +} + +impl<'a, T: Codec<'a> + TlsListElement + Debug> Iterator for TlsListIter<'a, T> { + type Item = Result; + + fn next(&mut self) -> Option { + match self.sub.any_left() { + true => Some(T::read(&mut self.sub)), + false => None, + } + } +} + +impl Codec<'_> for () { + fn encode(&self, _: &mut Vec) {} + + fn read(r: &mut Reader<'_>) -> Result { + r.expect_empty("Empty") + } +} + +/// A trait for types that can be encoded and decoded in a list. +/// +/// This trait is used to implement `Codec` for `Vec`. Lists in the TLS wire format are +/// prefixed with a length, the size of which depends on the type of the list elements. +/// As such, the `Codec` implementation for `Vec` requires an implementation of this trait +/// for its element type `T`. +pub(crate) trait TlsListElement { + const SIZE_LEN: ListLength; +} + +/// The length of the length prefix for a list. +/// +/// The types that appear in lists are limited to three kinds of length prefixes: +/// 1, 2, and 3 bytes. For the latter kind, we require a `TlsListElement` implementer +/// to specify a maximum length and error if the actual length is larger. +pub(crate) enum ListLength { + /// U8 but non-empty + NonZeroU8 { empty_error: InvalidMessage }, + + /// U16, perhaps empty + U16, + + /// U16 but non-empty + NonZeroU16 { empty_error: InvalidMessage }, + + /// U24 with imposed upper bound + U24 { max: usize, error: InvalidMessage }, +} + +impl ListLength { + pub(crate) fn read(&self, r: &mut Reader<'_>) -> Result { + Ok(match self { + Self::NonZeroU8 { empty_error } => match usize::from(u8::read(r)?) { + 0 => return Err(*empty_error), + len => len, + }, + Self::U16 => usize::from(u16::read(r)?), + Self::NonZeroU16 { empty_error } => match usize::from(u16::read(r)?) { + 0 => return Err(*empty_error), + len => len, + }, + Self::U24 { max, error } => match usize::from(u24::read(r)?) { + len if len > *max => return Err(*error), + len => len, + }, + }) + } +} + +/// Tracks encoding a length-delimited structure in a single pass. +pub(crate) struct LengthPrefixedBuffer<'a> { + pub(crate) buf: &'a mut Vec, + len_offset: usize, + size_len: ListLength, +} + +impl<'a> LengthPrefixedBuffer<'a> { + /// Inserts a dummy length into `buf`, and remembers where it went. + /// + /// After this, the body of the length-delimited structure should be appended to `LengthPrefixedBuffer::buf`. + /// The length header is corrected in `LengthPrefixedBuffer::drop`. + pub(crate) fn new(size_len: ListLength, buf: &'a mut Vec) -> Self { + let len_offset = buf.len(); + buf.extend(match size_len { + ListLength::NonZeroU8 { .. } => &[0xff][..], + ListLength::U16 | ListLength::NonZeroU16 { .. } => &[0xff, 0xff], + ListLength::U24 { .. } => &[0xff, 0xff, 0xff], + }); + + Self { + buf, + len_offset, + size_len, + } + } +} + +impl Drop for LengthPrefixedBuffer<'_> { + /// Goes back and corrects the length previously inserted at the start of the structure. + fn drop(&mut self) { + match self.size_len { + ListLength::NonZeroU8 { .. } => { + let len = self.buf.len() - self.len_offset - 1; + debug_assert!(len <= 0xff); + self.buf[self.len_offset] = len as u8; + } + ListLength::U16 | ListLength::NonZeroU16 { .. } => { + let len = self.buf.len() - self.len_offset - 2; + debug_assert!(len <= 0xffff); + let out: &mut [u8; 2] = (&mut self.buf[self.len_offset..self.len_offset + 2]) + .try_into() + .unwrap(); + *out = u16::to_be_bytes(len as u16); + } + ListLength::U24 { .. } => { + let len = self.buf.len() - self.len_offset - 3; + debug_assert!(len <= 0xff_ffff); + let len_bytes = u32::to_be_bytes(len as u32); + let out: &mut [u8; 3] = (&mut self.buf[self.len_offset..self.len_offset + 3]) + .try_into() + .unwrap(); + out.copy_from_slice(&len_bytes[1..]); + } + } + } +} + +#[cfg(test)] +mod tests { + use std::prelude::v1::*; + use std::vec; + + use super::*; + + #[test] + fn interrupted_length_prefixed_buffer_leaves_maximum_length() { + let mut buf = Vec::new(); + let nested = LengthPrefixedBuffer::new(ListLength::U16, &mut buf); + nested.buf.push(0xaa); + assert_eq!(nested.buf, &vec![0xff, 0xff, 0xaa]); + // <- if the buffer is accidentally read here, there is no possibility + // that the contents of the length-prefixed buffer are interpreted + // as a subsequent encoding (perhaps allowing injection of a different + // extension) + drop(nested); + assert_eq!(buf, vec![0x00, 0x01, 0xaa]); + } +} diff --git a/http/vendor/rustls/src/msgs/deframer/buffers.rs b/http/vendor/rustls/src/msgs/deframer/buffers.rs new file mode 100644 index 0000000..bf09874 --- /dev/null +++ b/http/vendor/rustls/src/msgs/deframer/buffers.rs @@ -0,0 +1,296 @@ +use alloc::vec::Vec; +use core::mem; +use core::ops::Range; +#[cfg(feature = "std")] +use std::io; + +#[cfg(feature = "std")] +use crate::msgs::message::MAX_WIRE_SIZE; + +/// Conversion from a slice within a larger buffer into +/// a `Range` offset within. +#[derive(Debug)] +pub(crate) struct Locator { + bounds: Range<*const u8>, +} + +impl Locator { + #[inline] + pub(crate) fn new(slice: &[u8]) -> Self { + Self { + bounds: slice.as_ptr_range(), + } + } + + #[inline] + pub(crate) fn locate(&self, slice: &[u8]) -> Range { + let bounds = slice.as_ptr_range(); + debug_assert!(self.fully_contains(slice)); + let start = bounds.start as usize - self.bounds.start as usize; + let len = bounds.end as usize - bounds.start as usize; + Range { + start, + end: start + len, + } + } + + #[inline] + pub(crate) fn fully_contains(&self, slice: &[u8]) -> bool { + let bounds = slice.as_ptr_range(); + bounds.start >= self.bounds.start && bounds.end <= self.bounds.end + } +} + +/// Conversion from a `Range` offset to the original slice. +pub(crate) struct Delocator<'b> { + slice: &'b [u8], +} + +impl<'b> Delocator<'b> { + #[inline] + pub(crate) fn new(slice: &'b [u8]) -> Self { + Self { slice } + } + + #[inline] + pub(crate) fn slice_from_range(&'_ self, range: &Range) -> &'b [u8] { + // safety: this unwrap is safe so long as `range` came from `locate()` + // for the same buffer + self.slice.get(range.clone()).unwrap() + } + + #[inline] + pub(crate) fn locator(self) -> Locator { + Locator::new(self.slice) + } +} + +/// Reordering the underlying buffer based on ranges. +pub(crate) struct Coalescer<'b> { + slice: &'b mut [u8], +} + +impl<'b> Coalescer<'b> { + #[inline] + pub(crate) fn new(slice: &'b mut [u8]) -> Self { + Self { slice } + } + + #[inline] + pub(crate) fn copy_within(&mut self, from: Range, to: Range) { + debug_assert!(from.len() == to.len()); + debug_assert!(self.slice.get(from.clone()).is_some()); + debug_assert!(self.slice.get(to.clone()).is_some()); + self.slice.copy_within(from, to.start); + } + + #[inline] + pub(crate) fn delocator(self) -> Delocator<'b> { + Delocator::new(self.slice) + } +} + +/// Accounting structure tracking progress in parsing a single buffer. +#[derive(Clone, Debug)] +pub(crate) struct BufferProgress { + /// Prefix of the buffer that has been processed so far. + /// + /// `processed` may exceed `discard`, that means we have parsed + /// some buffer, but are still using it. This happens due to + /// in-place decryption of incoming records, and in-place + /// reassembly of handshake messages. + /// + /// 0 <= processed <= len + processed: usize, + + /// Prefix of the buffer that can be removed. + /// + /// If `discard` exceeds `processed`, that means we are ignoring + /// data without processing it. + /// + /// 0 <= discard <= len + discard: usize, +} + +impl BufferProgress { + pub(super) fn new(processed: usize) -> Self { + Self { + processed, + discard: 0, + } + } + + #[inline] + pub(crate) fn add_discard(&mut self, discard: usize) { + self.discard += discard; + } + + #[inline] + pub(crate) fn add_processed(&mut self, processed: usize) { + self.processed += processed; + } + + #[inline] + pub(crate) fn take_discard(&mut self) -> usize { + // the caller is about to discard `discard` bytes + // from the front of the buffer. adjust `processed` + // down by the same amount. + self.processed = self + .processed + .saturating_sub(self.discard); + mem::take(&mut self.discard) + } + + #[inline] + pub(crate) fn processed(&self) -> usize { + self.processed + } +} + +#[derive(Default, Debug)] +pub(crate) struct DeframerVecBuffer { + /// Buffer of data read from the socket, in the process of being parsed into messages. + /// + /// For buffer size management, checkout out the [`DeframerVecBuffer::prepare_read()`] method. + buf: Vec, + + /// What size prefix of `buf` is used. + used: usize, +} + +impl DeframerVecBuffer { + /// Discard `taken` bytes from the start of our buffer. + pub(crate) fn discard(&mut self, taken: usize) { + #[allow(clippy::comparison_chain)] + if taken < self.used { + /* Before: + * +----------+----------+----------+ + * | taken | pending |xxxxxxxxxx| + * +----------+----------+----------+ + * 0 ^ taken ^ self.used + * + * After: + * +----------+----------+----------+ + * | pending |xxxxxxxxxxxxxxxxxxxxx| + * +----------+----------+----------+ + * 0 ^ self.used + */ + + self.buf + .copy_within(taken..self.used, 0); + self.used -= taken; + } else if taken >= self.used { + self.used = 0; + } + } + + pub(crate) fn filled_mut(&mut self) -> &mut [u8] { + &mut self.buf[..self.used] + } + + pub(crate) fn filled(&self) -> &[u8] { + &self.buf[..self.used] + } +} + +#[cfg(feature = "std")] +impl DeframerVecBuffer { + /// Read some bytes from `rd`, and add them to the buffer. + pub(crate) fn read(&mut self, rd: &mut dyn io::Read, in_handshake: bool) -> io::Result { + if let Err(err) = self.prepare_read(in_handshake) { + return Err(io::Error::new(io::ErrorKind::InvalidData, err)); + } + + // Try to do the largest reads possible. Note that if + // we get a message with a length field out of range here, + // we do a zero length read. That looks like an EOF to + // the next layer up, which is fine. + let new_bytes = rd.read(&mut self.buf[self.used..])?; + self.used += new_bytes; + Ok(new_bytes) + } + + /// Resize the internal `buf` if necessary for reading more bytes. + fn prepare_read(&mut self, is_joining_hs: bool) -> Result<(), &'static str> { + /// TLS allows for handshake messages of up to 16MB. We + /// restrict that to 64KB to limit potential for denial-of- + /// service. + const MAX_HANDSHAKE_SIZE: u32 = 0xffff; + + const READ_SIZE: usize = 4096; + + // We allow a maximum of 64k of buffered data for handshake messages only. Enforce this + // by varying the maximum allowed buffer size here based on whether a prefix of a + // handshake payload is currently being buffered. Given that the first read of such a + // payload will only ever be 4k bytes, the next time we come around here we allow a + // larger buffer size. Once the large message and any following handshake messages in + // the same flight have been consumed, `pop()` will call `discard()` to reset `used`. + // At this point, the buffer resizing logic below should reduce the buffer size. + let allow_max = match is_joining_hs { + true => MAX_HANDSHAKE_SIZE as usize, + false => MAX_WIRE_SIZE, + }; + + if self.used >= allow_max { + return Err("message buffer full"); + } + + // If we can and need to increase the buffer size to allow a 4k read, do so. After + // dealing with a large handshake message (exceeding `OutboundOpaqueMessage::MAX_WIRE_SIZE`), + // make sure to reduce the buffer size again (large messages should be rare). + // Also, reduce the buffer size if there are neither full nor partial messages in it, + // which usually means that the other side suspended sending data. + let need_capacity = Ord::min(allow_max, self.used + READ_SIZE); + if need_capacity > self.buf.len() { + self.buf.resize(need_capacity, 0); + } else if self.used == 0 || self.buf.len() > allow_max { + self.buf.resize(need_capacity, 0); + self.buf.shrink_to(need_capacity); + } + + Ok(()) + } + + /// Append `bytes` to the end of this buffer. + /// + /// Return a `Range` saying where it went. + pub(crate) fn extend(&mut self, bytes: &[u8]) -> Range { + let len = bytes.len(); + let start = self.used; + let end = start + len; + if self.buf.len() < end { + self.buf.resize(end, 0); + } + self.buf[start..end].copy_from_slice(bytes); + self.used += len; + Range { start, end } + } +} + +/// A borrowed version of [`DeframerVecBuffer`] that tracks discard operations +#[derive(Debug)] +pub(crate) struct DeframerSliceBuffer<'a> { + // a fully initialized buffer that will be deframed + buf: &'a mut [u8], + // number of bytes to discard from the front of `buf` at a later time + discard: usize, +} + +impl<'a> DeframerSliceBuffer<'a> { + pub(crate) fn new(buf: &'a mut [u8]) -> Self { + Self { buf, discard: 0 } + } + + /// Tracks a pending discard operation of `num_bytes` + pub(crate) fn queue_discard(&mut self, num_bytes: usize) { + self.discard += num_bytes; + } + + pub(crate) fn pending_discard(&self) -> usize { + self.discard + } + + pub(crate) fn filled_mut(&mut self) -> &mut [u8] { + &mut self.buf[self.discard..] + } +} diff --git a/http/vendor/rustls/src/msgs/deframer/handshake.rs b/http/vendor/rustls/src/msgs/deframer/handshake.rs new file mode 100644 index 0000000..0d91f0e --- /dev/null +++ b/http/vendor/rustls/src/msgs/deframer/handshake.rs @@ -0,0 +1,525 @@ +use alloc::vec::Vec; +use core::mem; +use core::ops::Range; + +use super::buffers::{BufferProgress, Coalescer, Delocator, Locator}; +use crate::error::InvalidMessage; +use crate::msgs::codec::{Codec, u24}; +use crate::msgs::message::InboundPlainMessage; +use crate::{ContentType, ProtocolVersion}; + +#[derive(Debug)] +pub(crate) struct HandshakeDeframer { + /// Spans covering individual handshake payloads, in order of receipt. + spans: Vec, + + /// Discard value, tracking the rightmost extent of the last message + /// in `spans`. + outer_discard: usize, +} + +impl HandshakeDeframer { + /// Accepts a message into the deframer. + /// + /// `containing_buffer` allows mapping the message payload to its position + /// in the input buffer, and thereby avoid retaining a borrow on the input + /// buffer. + /// + /// That is required because our processing of handshake messages requires + /// them to be contiguous (and avoiding that would mean supporting gather-based + /// parsing in a large number of places, including `core`, `webpki`, and the + /// `CryptoProvider` interface). `coalesce()` arranges for that to happen, but + /// to do so it needs to move the fragments together in the original buffer. + /// This would not be possible if the messages were borrowing from that buffer. + /// + /// `outer_discard` is the rightmost extent of the original message. + pub(crate) fn input_message( + &mut self, + msg: InboundPlainMessage<'_>, + containing_buffer: &Locator, + outer_discard: usize, + ) { + debug_assert_eq!(msg.typ, ContentType::Handshake); + debug_assert!(containing_buffer.fully_contains(msg.payload)); + debug_assert!(self.outer_discard <= outer_discard); + + self.outer_discard = outer_discard; + + // if our last span is incomplete, we can blindly add this as a new span -- + // no need to attempt parsing it with `DissectHandshakeIter`. + // + // `coalesce()` will later move this new message to be contiguous with + // `_last_incomplete`, and reparse the result. + // + // we cannot merge these processes, because `coalesce` mutates the underlying + // buffer, and `msg` borrows it. + if let Some(_last_incomplete) = self + .spans + .last() + .filter(|span| !span.is_complete()) + { + self.spans.push(FragmentSpan { + version: msg.version, + size: None, + bounds: containing_buffer.locate(msg.payload), + }); + return; + } + + // otherwise, we can expect `msg` to contain a handshake header introducing + // a new message (and perhaps several of them.) + for span in DissectHandshakeIter::new(msg, containing_buffer) { + self.spans.push(span); + } + } + + /// Returns a `BufferProgress` that skips over unprocessed handshake data. + pub(crate) fn progress(&self) -> BufferProgress { + BufferProgress::new(self.outer_discard) + } + + /// Do we have a message ready? ie, would `iter().next()` return `Some`? + pub(crate) fn has_message_ready(&self) -> bool { + match self.spans.first() { + Some(span) => span.is_complete(), + None => false, + } + } + + /// Do we have any message data, partial or otherwise? + pub(crate) fn is_active(&self) -> bool { + !self.spans.is_empty() + } + + /// We are "aligned" if there is no partial fragment of a handshake + /// message. + pub(crate) fn is_aligned(&self) -> bool { + self.spans + .iter() + .all(|span| span.is_complete()) + } + + /// Iterate over the complete messages. + pub(crate) fn iter<'a, 'b>(&'a mut self, containing_buffer: &'b [u8]) -> HandshakeIter<'a, 'b> { + HandshakeIter { + deframer: self, + containing_buffer: Delocator::new(containing_buffer), + index: 0, + } + } + + /// Coalesce the handshake portions of the given buffer, + /// if needed. + /// + /// This does nothing if there is nothing to do. + /// + /// In a normal TLS stream, handshake messages need not be contiguous. + /// For example, each handshake message could be delivered in its own + /// outer TLS message. This would mean the handshake messages are + /// separated by the outer TLS message headers, and likely also + /// separated by encryption overhead (any explicit nonce in front, + /// any padding and authentication tag afterwards). + /// + /// For a toy example of one handshake message in two fragments, and: + /// + /// - the letter `h` for handshake header octets + /// - the letter `H` for handshake payload octets + /// - the letter `x` for octets in the buffer ignored by this code, + /// + /// the buffer and `spans` data structure could look like: + /// + /// ```text + /// 0 1 2 3 4 5 6 7 8 9 a b c d e f 0 1 2 3 4 5 6 7 8 9 + /// x x x x x h h h h H H H x x x x x H H H H H H x x x + /// '------------' '----------' + /// | | + /// spans = [ { bounds = (5, 12), | + /// size = Some(9), .. }, | + /// { bounds = (17, 23), .. } ] + /// ``` + /// + /// In this case, `requires_coalesce` returns `Some(0)`. Then + /// `coalesce_one` moves the second range leftwards: + /// + /// ```text + /// 0 1 2 3 4 5 6 7 8 9 a b c d e f 0 1 2 3 4 5 6 7 8 9 + /// x x x x x h h h h H H H x x x x x H H H H H H x x x + /// '----------' + /// ^ '----------' + /// | v + /// '--<---<--' + /// copy_within(from = (17, 23), + /// to = (12, 18)) + /// ``` + /// + /// Leaving the buffer and spans: + /// + /// ```text + /// 0 1 2 3 4 5 6 7 8 9 a b c d e f 0 1 2 3 4 5 6 7 8 9 + /// x x x x x h h h h H H H H H H H H H x x x x x x x x + /// '------------------------' + /// | + /// spans = [ { bounds = (5, 18), size = Some(9), .. } ] + /// ``` + pub(crate) fn coalesce(&mut self, containing_buffer: &mut [u8]) -> Result<(), InvalidMessage> { + // Strategy: while there is work to do, scan `spans` + // for a pair where the first is not complete. move + // the second down towards the first, then reparse the contents. + while let Some(i) = self.requires_coalesce() { + self.coalesce_one(i, Coalescer::new(containing_buffer)); + } + + // check resulting spans pass our imposed length limit + match self + .spans + .iter() + .any(|span| span.size.unwrap_or_default() > MAX_HANDSHAKE_SIZE) + { + true => Err(InvalidMessage::HandshakePayloadTooLarge), + false => Ok(()), + } + } + + /// Within `containing_buffer`, move `span[index+1]` to be contiguous + /// with `span[index]`. + fn coalesce_one(&mut self, index: usize, mut containing_buffer: Coalescer<'_>) { + let second = self.spans.remove(index + 1); + let mut first = self.spans.remove(index); + + // move the entirety of `second` to be contiguous with `first` + let len = second.bounds.len(); + let target = Range { + start: first.bounds.end, + end: first.bounds.end + len, + }; + + containing_buffer.copy_within(second.bounds, target); + let delocator = containing_buffer.delocator(); + + // now adjust `first` to cover both + first.bounds.end += len; + + // finally, attempt to re-dissect `first` + let msg = InboundPlainMessage { + typ: ContentType::Handshake, + version: first.version, + payload: delocator.slice_from_range(&first.bounds), + }; + + for (i, span) in DissectHandshakeIter::new(msg, &delocator.locator()).enumerate() { + self.spans.insert(index + i, span); + } + } + + /// We require coalescing if any span except the last is not complete. + /// + /// Returns an index into `spans` for the first non-complete span: + /// this will never be the last item. + fn requires_coalesce(&self) -> Option { + self.spans + .split_last() + .and_then(|(_last, elements)| { + elements + .iter() + .enumerate() + .find_map(|(i, span)| (!span.is_complete()).then_some(i)) + }) + } +} + +impl Default for HandshakeDeframer { + fn default() -> Self { + Self { + // capacity: a typical upper limit on handshake messages in + // a single flight + spans: Vec::with_capacity(16), + outer_discard: 0, + } + } +} + +struct DissectHandshakeIter<'a, 'b> { + version: ProtocolVersion, + payload: &'b [u8], + containing_buffer: &'a Locator, +} + +impl<'a, 'b> DissectHandshakeIter<'a, 'b> { + fn new(msg: InboundPlainMessage<'b>, containing_buffer: &'a Locator) -> Self { + Self { + version: msg.version, + payload: msg.payload, + containing_buffer, + } + } +} + +impl Iterator for DissectHandshakeIter<'_, '_> { + type Item = FragmentSpan; + + fn next(&mut self) -> Option { + if self.payload.is_empty() { + return None; + } + + // If there is not enough data to have a header the length is unknown + if self.payload.len() < HANDSHAKE_HEADER_LEN { + let buf = mem::take(&mut self.payload); + let bounds = self.containing_buffer.locate(buf); + return Some(FragmentSpan { + version: self.version, + size: None, + bounds: bounds.clone(), + }); + } + + let (header, rest) = mem::take(&mut self.payload).split_at(HANDSHAKE_HEADER_LEN); + + // safety: header[1..] is exactly 3 bytes, so `u24::read_bytes` cannot fail + let size = u24::read_bytes(&header[1..]) + .unwrap() + .into(); + + let available = if size < rest.len() { + self.payload = &rest[size..]; + size + } else { + rest.len() + }; + + let mut bounds = self.containing_buffer.locate(header); + bounds.end += available; + Some(FragmentSpan { + version: self.version, + size: Some(size), + bounds: bounds.clone(), + }) + } +} + +pub(crate) struct HandshakeIter<'a, 'b> { + deframer: &'a mut HandshakeDeframer, + containing_buffer: Delocator<'b>, + index: usize, +} + +impl<'b> Iterator for HandshakeIter<'_, 'b> { + type Item = (InboundPlainMessage<'b>, usize); + + fn next(&mut self) -> Option { + let next_span = self.deframer.spans.get(self.index)?; + + if !next_span.is_complete() { + return None; + } + + // if this is the last handshake message, then we'll end + // up with an empty `spans` and can discard the remainder + // of the input buffer. + let discard = if self.deframer.spans.len() - 1 == self.index { + mem::take(&mut self.deframer.outer_discard) + } else { + 0 + }; + + self.index += 1; + Some(( + InboundPlainMessage { + typ: ContentType::Handshake, + version: next_span.version, + payload: self + .containing_buffer + .slice_from_range(&next_span.bounds), + }, + discard, + )) + } +} + +impl Drop for HandshakeIter<'_, '_> { + fn drop(&mut self) { + self.deframer.spans.drain(..self.index); + } +} + +#[derive(Debug)] +struct FragmentSpan { + /// version taken from containing message. + version: ProtocolVersion, + + /// size of the handshake message body (excluding header) + /// + /// `None` means the size is unknown, because `bounds` is not + /// large enough to encompass a whole header. + size: Option, + + /// bounds of the handshake message, including header + bounds: Range, +} + +impl FragmentSpan { + /// A `FragmentSpan` is "complete" if its size is known, and its + /// bounds exactly encompasses one handshake message. + fn is_complete(&self) -> bool { + match self.size { + Some(sz) => sz + HANDSHAKE_HEADER_LEN == self.bounds.len(), + None => false, + } + } +} + +const HANDSHAKE_HEADER_LEN: usize = 1 + 3; + +/// TLS allows for handshake messages of up to 16MB. We +/// restrict that to 64KB to limit potential for denial-of- +/// service. +const MAX_HANDSHAKE_SIZE: usize = 0xffff; + +#[cfg(test)] +mod tests { + use std::vec; + + use super::*; + use crate::msgs::deframer::DeframerIter; + + fn add_bytes(hs: &mut HandshakeDeframer, slice: &[u8], within: &[u8]) { + let msg = InboundPlainMessage { + typ: ContentType::Handshake, + version: ProtocolVersion::TLSv1_3, + payload: slice, + }; + let locator = Locator::new(within); + let discard = locator.locate(slice).end; + hs.input_message(msg, &locator, discard); + } + + #[test] + fn coalesce() { + let mut input = vec![0, 0, 0, 0x21, 0, 0, 0, 0, 0x01, 0xff, 0x00, 0x01]; + let mut hs = HandshakeDeframer::default(); + + add_bytes(&mut hs, &input[3..4], &input); + assert_eq!(hs.requires_coalesce(), None); + add_bytes(&mut hs, &input[4..6], &input); + assert_eq!(hs.requires_coalesce(), Some(0)); + add_bytes(&mut hs, &input[8..10], &input); + assert_eq!(hs.requires_coalesce(), Some(0)); + + std::println!("before: {hs:?}"); + hs.coalesce(&mut input).unwrap(); + std::println!("after: {hs:?}"); + + let (msg, discard) = hs.iter(&input).next().unwrap(); + std::println!("msg {msg:?} discard {discard:?}"); + assert_eq!(msg.typ, ContentType::Handshake); + assert_eq!(msg.version, ProtocolVersion::TLSv1_3); + assert_eq!(msg.payload, &[0x21, 0x00, 0x00, 0x01, 0xff]); + + input.drain(..discard); + assert_eq!(input, &[0, 1]); + } + + #[test] + fn append() { + let mut input = vec![0, 0, 0, 0x21, 0, 0, 5, 0, 0, 1, 2, 3, 4, 5, 0]; + let mut hs = HandshakeDeframer::default(); + + add_bytes(&mut hs, &input[3..7], &input); + add_bytes(&mut hs, &input[9..14], &input); + assert_eq!(hs.spans.len(), 2); + + hs.coalesce(&mut input).unwrap(); + assert_eq!(hs.spans.len(), 1); + + let (msg, discard) = std::dbg!(hs.iter(&input).next().unwrap()); + assert_eq!(msg.typ, ContentType::Handshake); + assert_eq!(msg.version, ProtocolVersion::TLSv1_3); + assert_eq!(msg.payload, &[0x21, 0x00, 0x00, 0x05, 1, 2, 3, 4, 5]); + + input.drain(..discard); + assert_eq!(input, &[0]); + } + + #[test] + fn coalesce_rejects_excess_size_message() { + const X: u8 = 0xff; + let mut input = vec![0x21, 0x01, 0x00, X, 0x00, 0xab, X]; + let mut hs = HandshakeDeframer::default(); + + // split header over multiple messages, which motivates doing + // this check in `coalesce()` + add_bytes(&mut hs, &input[0..3], &input); + add_bytes(&mut hs, &input[4..6], &input); + + assert_eq!( + hs.coalesce(&mut input), + Err(InvalidMessage::HandshakePayloadTooLarge) + ); + } + + #[test] + fn iter_only_returns_full_messages() { + let input = [0, 0, 0, 0x21, 0, 0, 1, 0xab, 0x21, 0, 0, 1]; + + let mut hs = HandshakeDeframer::default(); + + add_bytes(&mut hs, &input[3..8], &input); + add_bytes(&mut hs, &input[8..12], &input); + + let mut iter = hs.iter(&input); + let (msg, discard) = iter.next().unwrap(); + assert!(iter.next().is_none()); + + assert_eq!(msg.typ, ContentType::Handshake); + assert_eq!(msg.version, ProtocolVersion::TLSv1_3); + assert_eq!(msg.payload, &[0x21, 0x00, 0x00, 0x01, 0xab]); + assert_eq!(discard, 0); + } + + #[test] + fn handshake_flight() { + // intended to be a realistic example + let mut input = include_bytes!("../../testdata/handshake-test.1.bin").to_vec(); + let locator = Locator::new(&input); + + let mut hs = HandshakeDeframer::default(); + + let mut iter = DeframerIter::new(&mut input[..]); + + while let Some(message) = iter.next() { + let plain = message.unwrap().into_plain_message(); + std::println!("message {plain:?}"); + + hs.input_message(plain, &locator, iter.bytes_consumed()); + } + + hs.coalesce(&mut input[..]).unwrap(); + + let mut iter = hs.iter(&input[..]); + for _ in 0..4 { + let (msg, discard) = iter.next().unwrap(); + assert!(matches!( + msg, + InboundPlainMessage { + typ: ContentType::Handshake, + .. + } + )); + assert_eq!(discard, 0); + } + + let (msg, discard) = iter.next().unwrap(); + assert!(matches!( + msg, + InboundPlainMessage { + typ: ContentType::Handshake, + .. + } + )); + assert_eq!(discard, 4280); + drop(iter); + + input.drain(0..discard); + assert!(input.is_empty()); + } +} diff --git a/http/vendor/rustls/src/msgs/deframer/mod.rs b/http/vendor/rustls/src/msgs/deframer/mod.rs new file mode 100644 index 0000000..4122b52 --- /dev/null +++ b/http/vendor/rustls/src/msgs/deframer/mod.rs @@ -0,0 +1,238 @@ +use core::mem; + +use crate::error::{Error, InvalidMessage}; +use crate::msgs::codec::Reader; +use crate::msgs::message::{ + HEADER_SIZE, InboundOpaqueMessage, MessageError, read_opaque_message_header, +}; + +pub(crate) mod buffers; +pub(crate) mod handshake; + +/// A deframer of TLS wire messages. +/// +/// Returns `Some(Ok(_))` containing each `InboundOpaqueMessage` deframed +/// from the buffer. +/// +/// Returns `None` if no further messages can be deframed from the +/// buffer. More data is required for further progress. +/// +/// Returns `Some(Err(_))` if the peer is not talking TLS, but some +/// other protocol. The caller should abort the connection, because +/// the deframer cannot recover. +/// +/// Call `bytes_consumed()` to learn how many bytes the iterator has +/// processed from the front of the original buffer. This is only updated +/// when a message is successfully deframed (ie. `Some(Ok(_))` is returned). +pub(crate) struct DeframerIter<'a> { + buf: &'a mut [u8], + consumed: usize, +} + +impl<'a> DeframerIter<'a> { + /// Make a new `DeframerIter` + pub(crate) fn new(buf: &'a mut [u8]) -> Self { + Self { buf, consumed: 0 } + } + + /// How many bytes were processed successfully from the front + /// of the buffer passed to `new()`? + pub(crate) fn bytes_consumed(&self) -> usize { + self.consumed + } +} + +impl<'a> Iterator for DeframerIter<'a> { + type Item = Result, Error>; + + fn next(&mut self) -> Option { + let mut reader = Reader::init(self.buf); + + let (typ, version, len) = match read_opaque_message_header(&mut reader) { + Ok(header) => header, + Err(err) => { + let err = match err { + MessageError::TooShortForHeader | MessageError::TooShortForLength => { + return None; + } + MessageError::InvalidEmptyPayload => InvalidMessage::InvalidEmptyPayload, + MessageError::MessageTooLarge => InvalidMessage::MessageTooLarge, + MessageError::InvalidContentType => InvalidMessage::InvalidContentType, + MessageError::UnknownProtocolVersion => InvalidMessage::UnknownProtocolVersion, + }; + return Some(Err(err.into())); + } + }; + + let end = HEADER_SIZE + len as usize; + + self.buf.get(HEADER_SIZE..end)?; + + // we now have a TLS header and body on the front of `self.buf`. remove + // it from the front. + let (consumed, remainder) = mem::take(&mut self.buf).split_at_mut(end); + self.buf = remainder; + self.consumed += end; + + Some(Ok(InboundOpaqueMessage::new( + typ, + version, + &mut consumed[HEADER_SIZE..], + ))) + } +} + +pub fn fuzz_deframer(data: &[u8]) { + let mut buf = data.to_vec(); + let mut iter = DeframerIter::new(&mut buf); + + for message in iter.by_ref() { + if message.is_err() { + break; + } + } + + assert!(iter.bytes_consumed() <= buf.len()); +} + +#[cfg(feature = "std")] +#[cfg(test)] +mod tests { + use alloc::vec::Vec; + use std::prelude::v1::*; + + use super::*; + use crate::ContentType; + + #[test] + fn iterator_empty_before_header_received() { + assert!( + DeframerIter::new(&mut []) + .next() + .is_none() + ); + assert!( + DeframerIter::new(&mut [0x16]) + .next() + .is_none() + ); + assert!( + DeframerIter::new(&mut [0x16, 0x03]) + .next() + .is_none() + ); + assert!( + DeframerIter::new(&mut [0x16, 0x03, 0x03]) + .next() + .is_none() + ); + assert!( + DeframerIter::new(&mut [0x16, 0x03, 0x03, 0x00]) + .next() + .is_none() + ); + assert!( + DeframerIter::new(&mut [0x16, 0x03, 0x03, 0x00, 0x01]) + .next() + .is_none() + ); + } + + #[test] + fn iterate_one_message() { + let mut buffer = [0x17, 0x03, 0x03, 0x00, 0x01, 0x00]; + let mut iter = DeframerIter::new(&mut buffer); + assert_eq!( + iter.next().unwrap().unwrap().typ, + ContentType::ApplicationData + ); + assert_eq!(iter.bytes_consumed(), 6); + assert!(iter.next().is_none()); + } + + #[test] + fn iterate_two_messages() { + let mut buffer = [ + 0x16, 0x03, 0x03, 0x00, 0x01, 0x00, 0x17, 0x03, 0x03, 0x00, 0x01, 0x00, + ]; + let mut iter = DeframerIter::new(&mut buffer); + assert_eq!(iter.next().unwrap().unwrap().typ, ContentType::Handshake); + assert_eq!(iter.bytes_consumed(), 6); + assert_eq!( + iter.next().unwrap().unwrap().typ, + ContentType::ApplicationData + ); + assert_eq!(iter.bytes_consumed(), 12); + assert!(iter.next().is_none()); + } + + #[test] + fn iterator_invalid_protocol_version_rejected() { + let mut buffer = include_bytes!("../../testdata/deframer-invalid-version.bin").to_vec(); + let mut iter = DeframerIter::new(&mut buffer); + assert_eq!( + iter.next().unwrap().err(), + Some(Error::InvalidMessage( + InvalidMessage::UnknownProtocolVersion + )) + ); + } + + #[test] + fn iterator_invalid_content_type_rejected() { + let mut buffer = include_bytes!("../../testdata/deframer-invalid-contenttype.bin").to_vec(); + let mut iter = DeframerIter::new(&mut buffer); + assert_eq!( + iter.next().unwrap().err(), + Some(Error::InvalidMessage(InvalidMessage::InvalidContentType)) + ); + } + + #[test] + fn iterator_excess_message_length_rejected() { + let mut buffer = include_bytes!("../../testdata/deframer-invalid-length.bin").to_vec(); + let mut iter = DeframerIter::new(&mut buffer); + assert_eq!( + iter.next().unwrap().err(), + Some(Error::InvalidMessage(InvalidMessage::MessageTooLarge)) + ); + } + + #[test] + fn iterator_zero_message_length_rejected() { + let mut buffer = include_bytes!("../../testdata/deframer-invalid-empty.bin").to_vec(); + let mut iter = DeframerIter::new(&mut buffer); + assert_eq!( + iter.next().unwrap().err(), + Some(Error::InvalidMessage(InvalidMessage::InvalidEmptyPayload)) + ); + } + + #[test] + fn iterator_over_many_messages() { + let client_hello = include_bytes!("../../testdata/deframer-test.1.bin"); + let mut buffer = Vec::with_capacity(3 * client_hello.len()); + buffer.extend(client_hello); + buffer.extend(client_hello); + buffer.extend(client_hello); + let mut iter = DeframerIter::new(&mut buffer); + let mut count = 0; + + for message in iter.by_ref() { + let message = message.unwrap(); + assert_eq!(ContentType::Handshake, message.typ); + count += 1; + } + + assert_eq!(count, 3); + assert_eq!(client_hello.len() * 3, iter.bytes_consumed()); + } + + #[test] + fn exercise_fuzz_deframer() { + fuzz_deframer(&[0xff, 0xff, 0xff, 0xff, 0xff]); + for prefix in 0..7 { + fuzz_deframer(&[0x16, 0x03, 0x03, 0x00, 0x01, 0xff][..prefix]); + } + } +} diff --git a/http/vendor/rustls/src/msgs/enums.rs b/http/vendor/rustls/src/msgs/enums.rs new file mode 100644 index 0000000..fb10bbe --- /dev/null +++ b/http/vendor/rustls/src/msgs/enums.rs @@ -0,0 +1,502 @@ +#![allow(clippy::upper_case_acronyms)] +#![allow(non_camel_case_types)] +use crate::crypto::{KeyExchangeAlgorithm, hash}; +use crate::msgs::codec::{Codec, Reader}; + +enum_builder! { + /// The `HashAlgorithm` TLS protocol enum. Values in this enum are taken + /// from the various RFCs covering TLS, and are listed by IANA. + /// The `Unknown` item is used when processing unrecognised ordinals. + #[repr(u8)] + pub enum HashAlgorithm { + NONE => 0x00, + MD5 => 0x01, + SHA1 => 0x02, + SHA224 => 0x03, + SHA256 => 0x04, + SHA384 => 0x05, + SHA512 => 0x06, + } +} + +impl HashAlgorithm { + /// Returns the hash of the empty input. + /// + /// This returns `None` for some hash algorithms, so the caller + /// should be prepared to do the computation themselves in this case. + pub(crate) fn hash_for_empty_input(&self) -> Option { + match self { + Self::SHA256 => Some(hash::Output::new( + b"\xe3\xb0\xc4\x42\x98\xfc\x1c\x14\ + \x9a\xfb\xf4\xc8\x99\x6f\xb9\x24\ + \x27\xae\x41\xe4\x64\x9b\x93\x4c\ + \xa4\x95\x99\x1b\x78\x52\xb8\x55", + )), + Self::SHA384 => Some(hash::Output::new( + b"\x38\xb0\x60\xa7\x51\xac\x96\x38\ + \x4c\xd9\x32\x7e\xb1\xb1\xe3\x6a\ + \x21\xfd\xb7\x11\x14\xbe\x07\x43\ + \x4c\x0c\xc7\xbf\x63\xf6\xe1\xda\ + \x27\x4e\xde\xbf\xe7\x6f\x65\xfb\ + \xd5\x1a\xd2\xf1\x48\x98\xb9\x5b", + )), + _ => None, + } + } +} + +enum_builder! { + /// The `ClientCertificateType` TLS protocol enum. Values in this enum are taken + /// from the various RFCs covering TLS, and are listed by IANA. + /// The `Unknown` item is used when processing unrecognised ordinals. + #[repr(u8)] + pub(crate) enum ClientCertificateType { + RSASign => 0x01, + DSSSign => 0x02, + RSAFixedDH => 0x03, + DSSFixedDH => 0x04, + RSAEphemeralDH => 0x05, + DSSEphemeralDH => 0x06, + FortezzaDMS => 0x14, + ECDSASign => 0x40, + RSAFixedECDH => 0x41, + ECDSAFixedECDH => 0x42, + } +} + +enum_builder! { + /// The `Compression` TLS protocol enum. Values in this enum are taken + /// from the various RFCs covering TLS, and are listed by IANA. + /// The `Unknown` item is used when processing unrecognised ordinals. + #[repr(u8)] + pub enum Compression { + Null => 0x00, + Deflate => 0x01, + LSZ => 0x40, + } +} + +enum_builder! { + /// The `AlertLevel` TLS protocol enum. Values in this enum are taken + /// from the various RFCs covering TLS, and are listed by IANA. + /// The `Unknown` item is used when processing unrecognised ordinals. + #[repr(u8)] + pub enum AlertLevel { + Warning => 0x01, + Fatal => 0x02, + } +} + +enum_builder! { + /// The `HeartbeatMessageType` TLS protocol enum. Values in this enum are taken + /// from the various RFCs covering TLS, and are listed by IANA. + /// The `Unknown` item is used when processing unrecognised ordinals. + #[repr(u8)] + pub(crate) enum HeartbeatMessageType { + Request => 0x01, + Response => 0x02, + } +} + +enum_builder! { + /// The `ExtensionType` TLS protocol enum. Values in this enum are taken + /// from the various RFCs covering TLS, and are listed by IANA. + /// The `Unknown` item is used when processing unrecognised ordinals. + #[repr(u16)] + pub enum ExtensionType { + ServerName => 0x0000, + MaxFragmentLength => 0x0001, + ClientCertificateUrl => 0x0002, + TrustedCAKeys => 0x0003, + TruncatedHMAC => 0x0004, + StatusRequest => 0x0005, + UserMapping => 0x0006, + ClientAuthz => 0x0007, + ServerAuthz => 0x0008, + CertificateType => 0x0009, + EllipticCurves => 0x000a, + ECPointFormats => 0x000b, + SRP => 0x000c, + SignatureAlgorithms => 0x000d, + UseSRTP => 0x000e, + Heartbeat => 0x000f, + ALProtocolNegotiation => 0x0010, + SCT => 0x0012, + ClientCertificateType => 0x0013, + ServerCertificateType => 0x0014, + Padding => 0x0015, + ExtendedMasterSecret => 0x0017, + CompressCertificate => 0x001b, + SessionTicket => 0x0023, + PreSharedKey => 0x0029, + EarlyData => 0x002a, + SupportedVersions => 0x002b, + Cookie => 0x002c, + PSKKeyExchangeModes => 0x002d, + TicketEarlyDataInfo => 0x002e, + CertificateAuthorities => 0x002f, + OIDFilters => 0x0030, + PostHandshakeAuth => 0x0031, + SignatureAlgorithmsCert => 0x0032, + KeyShare => 0x0033, + TransportParameters => 0x0039, + NextProtocolNegotiation => 0x3374, + ChannelId => 0x754f, + RenegotiationInfo => 0xff01, + TransportParametersDraft => 0xffa5, + EncryptedClientHello => 0xfe0d, // https://datatracker.ietf.org/doc/html/draft-ietf-tls-esni-18#section-11.1 + EncryptedClientHelloOuterExtensions => 0xfd00, // https://datatracker.ietf.org/doc/html/draft-ietf-tls-esni-18#section-5.1 + } +} + +impl ExtensionType { + /// Returns true if the extension type can be compressed in an "inner" client hello for ECH. + /// + /// This function should only return true for extension types where the inner hello and outer + /// hello extensions values will always be identical. Extensions that may be identical + /// sometimes (e.g. server name, cert compression methods), but not always, SHOULD NOT be + /// compressed. + /// + /// See [draft-ietf-esni-18 §5](https://datatracker.ietf.org/doc/html/draft-ietf-tls-esni-18#section-5) + /// and [draft-ietf-esni-18 §10.5](https://datatracker.ietf.org/doc/html/draft-ietf-tls-esni-18#section-10.5) + /// for more information. + pub(crate) fn ech_compress(&self) -> bool { + // We match which extensions we will compress with BoringSSL and Go's stdlib. + matches!( + self, + Self::StatusRequest + | Self::EllipticCurves + | Self::SignatureAlgorithms + | Self::SignatureAlgorithmsCert + | Self::ALProtocolNegotiation + | Self::SupportedVersions + | Self::Cookie + | Self::KeyShare + | Self::PSKKeyExchangeModes + ) + } +} + +enum_builder! { + /// The `ServerNameType` TLS protocol enum. Values in this enum are taken + /// from the various RFCs covering TLS, and are listed by IANA. + /// The `Unknown` item is used when processing unrecognised ordinals. + #[repr(u8)] + pub(crate) enum ServerNameType { + HostName => 0x00, + } +} + +enum_builder! { + /// The `NamedCurve` TLS protocol enum. Values in this enum are taken + /// from the various RFCs covering TLS, and are listed by IANA. + /// The `Unknown` item is used when processing unrecognised ordinals. + /// + /// This enum is used for recognizing elliptic curve parameters advertised + /// by a peer during a TLS handshake. It is **not** a list of curves that + /// Rustls supports. See [`crate::crypto::ring::kx_group`] for the list of supported + /// elliptic curve groups. + #[repr(u16)] + pub(crate) enum NamedCurve { + sect163k1 => 0x0001, + sect163r1 => 0x0002, + sect163r2 => 0x0003, + sect193r1 => 0x0004, + sect193r2 => 0x0005, + sect233k1 => 0x0006, + sect233r1 => 0x0007, + sect239k1 => 0x0008, + sect283k1 => 0x0009, + sect283r1 => 0x000a, + sect409k1 => 0x000b, + sect409r1 => 0x000c, + sect571k1 => 0x000d, + sect571r1 => 0x000e, + secp160k1 => 0x000f, + secp160r1 => 0x0010, + secp160r2 => 0x0011, + secp192k1 => 0x0012, + secp192r1 => 0x0013, + secp224k1 => 0x0014, + secp224r1 => 0x0015, + secp256k1 => 0x0016, + secp256r1 => 0x0017, + secp384r1 => 0x0018, + secp521r1 => 0x0019, + brainpoolp256r1 => 0x001a, + brainpoolp384r1 => 0x001b, + brainpoolp512r1 => 0x001c, + X25519 => 0x001d, + X448 => 0x001e, + arbitrary_explicit_prime_curves => 0xff01, + arbitrary_explicit_char2_curves => 0xff02, + } +} + +enum_builder! { + /// The `NamedGroup` TLS protocol enum. Values in this enum are taken + /// from the various RFCs covering TLS, and are listed by IANA. + /// The `Unknown` item is used when processing unrecognised ordinals. + #[repr(u16)] + pub enum NamedGroup { + secp256r1 => 0x0017, + secp384r1 => 0x0018, + secp521r1 => 0x0019, + X25519 => 0x001d, + X448 => 0x001e, + FFDHE2048 => 0x0100, + FFDHE3072 => 0x0101, + FFDHE4096 => 0x0102, + FFDHE6144 => 0x0103, + FFDHE8192 => 0x0104, + MLKEM512 => 0x0200, + MLKEM768 => 0x0201, + MLKEM1024 => 0x0202, + secp256r1MLKEM768 => 0x11eb, + X25519MLKEM768 => 0x11ec, + } +} + +impl NamedGroup { + /// Return the key exchange algorithm associated with this `NamedGroup` + pub fn key_exchange_algorithm(self) -> KeyExchangeAlgorithm { + match u16::from(self) { + x if (0x100..0x200).contains(&x) => KeyExchangeAlgorithm::DHE, + _ => KeyExchangeAlgorithm::ECDHE, + } + } +} + +enum_builder! { + /// The `ECPointFormat` TLS protocol enum. Values in this enum are taken + /// from the various RFCs covering TLS, and are listed by IANA. + /// The `Unknown` item is used when processing unrecognised ordinals. + #[repr(u8)] + pub enum ECPointFormat { + Uncompressed => 0x00, + ANSIX962CompressedPrime => 0x01, + ANSIX962CompressedChar2 => 0x02, + } +} + +enum_builder! { + /// The `HeartbeatMode` TLS protocol enum. Values in this enum are taken + /// from the various RFCs covering TLS, and are listed by IANA. + /// The `Unknown` item is used when processing unrecognised ordinals. + #[repr(u8)] + pub(crate) enum HeartbeatMode { + PeerAllowedToSend => 0x01, + PeerNotAllowedToSend => 0x02, + } +} + +enum_builder! { + /// The `ECCurveType` TLS protocol enum. Values in this enum are taken + /// from the various RFCs covering TLS, and are listed by IANA. + /// The `Unknown` item is used when processing unrecognised ordinals. + #[repr(u8)] + pub(crate) enum ECCurveType { + ExplicitPrime => 0x01, + ExplicitChar2 => 0x02, + NamedCurve => 0x03, + } +} + +enum_builder! { + /// The `PskKeyExchangeMode` TLS protocol enum. Values in this enum are taken + /// from the various RFCs covering TLS, and are listed by IANA. + /// The `Unknown` item is used when processing unrecognised ordinals. + #[repr(u8)] + pub enum PskKeyExchangeMode { + PSK_KE => 0x00, + PSK_DHE_KE => 0x01, + } +} + +enum_builder! { + /// The `KeyUpdateRequest` TLS protocol enum. Values in this enum are taken + /// from the various RFCs covering TLS, and are listed by IANA. + /// The `Unknown` item is used when processing unrecognised ordinals. + #[repr(u8)] + pub enum KeyUpdateRequest { + UpdateNotRequested => 0x00, + UpdateRequested => 0x01, + } +} + +enum_builder! { + /// The `CertificateStatusType` TLS protocol enum. Values in this enum are taken + /// from the various RFCs covering TLS, and are listed by IANA. + /// The `Unknown` item is used when processing unrecognised ordinals. + #[repr(u8)] + pub enum CertificateStatusType { + OCSP => 0x01, + } +} + +enum_builder! { + /// The Key Encapsulation Mechanism (`Kem`) type for HPKE operations. + /// Listed by IANA, as specified in [RFC 9180 Section 7.1] + /// + /// [RFC 9180 Section 7.1]: + #[repr(u16)] + pub enum HpkeKem { + DHKEM_P256_HKDF_SHA256 => 0x0010, + DHKEM_P384_HKDF_SHA384 => 0x0011, + DHKEM_P521_HKDF_SHA512 => 0x0012, + DHKEM_X25519_HKDF_SHA256 => 0x0020, + DHKEM_X448_HKDF_SHA512 => 0x0021, + } +} + +enum_builder! { + /// The Key Derivation Function (`Kdf`) type for HPKE operations. + /// Listed by IANA, as specified in [RFC 9180 Section 7.2] + /// + /// [RFC 9180 Section 7.2]: + #[repr(u16)] + #[derive(Default)] + pub enum HpkeKdf { + // TODO(XXX): revisit the default configuration. This is just what Cloudflare ships right now. + #[default] + HKDF_SHA256 => 0x0001, + HKDF_SHA384 => 0x0002, + HKDF_SHA512 => 0x0003, + } +} + +enum_builder! { + /// The Authenticated Encryption with Associated Data (`Aead`) type for HPKE operations. + /// Listed by IANA, as specified in [RFC 9180 Section 7.3] + /// + /// [RFC 9180 Section 7.3]: + #[repr(u16)] + #[derive(Default)] + pub enum HpkeAead { + // TODO(XXX): revisit the default configuration. This is just what Cloudflare ships right now. + #[default] + AES_128_GCM => 0x0001, + AES_256_GCM => 0x0002, + CHACHA20_POLY_1305 => 0x0003, + EXPORT_ONLY => 0xFFFF, + } +} + +impl HpkeAead { + /// Returns the length of the tag for the AEAD algorithm, or none if the AEAD is EXPORT_ONLY. + pub(crate) fn tag_len(&self) -> Option { + match self { + // See RFC 9180 Section 7.3, column `Nt`, the length in bytes of the authentication tag + // for the algorithm. + // https://www.rfc-editor.org/rfc/rfc9180.html#section-7.3 + Self::AES_128_GCM | Self::AES_256_GCM | Self::CHACHA20_POLY_1305 => Some(16), + _ => None, + } + } +} + +enum_builder! { + /// The Encrypted Client Hello protocol version (`EchVersion`). + /// + /// Specified in [draft-ietf-tls-esni Section 4]. + /// TODO(XXX): Update reference once RFC is published. + /// + /// [draft-ietf-tls-esni Section 4]: + #[repr(u16)] + pub enum EchVersion { + V18 => 0xfe0d, + } +} + +#[cfg(test)] +pub(crate) mod tests { + // These tests are intended to provide coverage and + // check panic-safety of relatively unused values. + + use std::prelude::v1::*; + + use super::*; + + #[test] + fn test_enums() { + test_enum8::(HashAlgorithm::NONE, HashAlgorithm::SHA512); + test_enum8::( + ClientCertificateType::RSASign, + ClientCertificateType::ECDSAFixedECDH, + ); + test_enum8::(Compression::Null, Compression::LSZ); + test_enum8::(AlertLevel::Warning, AlertLevel::Fatal); + test_enum8::( + HeartbeatMessageType::Request, + HeartbeatMessageType::Response, + ); + test_enum16::(ExtensionType::ServerName, ExtensionType::RenegotiationInfo); + test_enum8::(ServerNameType::HostName, ServerNameType::HostName); + test_enum16::( + NamedCurve::sect163k1, + NamedCurve::arbitrary_explicit_char2_curves, + ); + test_enum16::(NamedGroup::secp256r1, NamedGroup::FFDHE8192); + test_enum8::( + ECPointFormat::Uncompressed, + ECPointFormat::ANSIX962CompressedChar2, + ); + test_enum8::( + HeartbeatMode::PeerAllowedToSend, + HeartbeatMode::PeerNotAllowedToSend, + ); + test_enum8::(ECCurveType::ExplicitPrime, ECCurveType::NamedCurve); + test_enum8::( + PskKeyExchangeMode::PSK_KE, + PskKeyExchangeMode::PSK_DHE_KE, + ); + test_enum8::( + KeyUpdateRequest::UpdateNotRequested, + KeyUpdateRequest::UpdateRequested, + ); + test_enum8::( + CertificateStatusType::OCSP, + CertificateStatusType::OCSP, + ); + } + + pub(crate) fn test_enum8 Codec<'a>>(first: T, last: T) { + let first_v = get8(&first); + let last_v = get8(&last); + + for val in first_v..last_v + 1 { + let mut buf = Vec::new(); + val.encode(&mut buf); + assert_eq!(buf.len(), 1); + + let t = T::read_bytes(&buf).unwrap(); + assert_eq!(val, get8(&t)); + } + } + + pub(crate) fn test_enum16 Codec<'a>>(first: T, last: T) { + let first_v = get16(&first); + let last_v = get16(&last); + + for val in first_v..last_v + 1 { + let mut buf = Vec::new(); + val.encode(&mut buf); + assert_eq!(buf.len(), 2); + + let t = T::read_bytes(&buf).unwrap(); + assert_eq!(val, get16(&t)); + } + } + + fn get8 Codec<'a>>(enum_value: &T) -> u8 { + let enc = enum_value.get_encoding(); + assert_eq!(enc.len(), 1); + enc[0] + } + + fn get16 Codec<'a>>(enum_value: &T) -> u16 { + let enc = enum_value.get_encoding(); + assert_eq!(enc.len(), 2); + (enc[0] as u16 >> 8) | (enc[1] as u16) + } +} diff --git a/http/vendor/rustls/src/msgs/ffdhe_groups.rs b/http/vendor/rustls/src/msgs/ffdhe_groups.rs new file mode 100644 index 0000000..ac105b5 --- /dev/null +++ b/http/vendor/rustls/src/msgs/ffdhe_groups.rs @@ -0,0 +1,323 @@ +//! This module contains parameters for FFDHE named groups as defined +//! in [RFC 7919 Appendix A](https://datatracker.ietf.org/doc/html/rfc7919#appendix-A). + +use crate::NamedGroup; + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +/// Parameters of an FFDHE group, with Big-endian byte order +pub struct FfdheGroup<'a> { + pub p: &'a [u8], + pub g: &'a [u8], +} + +impl FfdheGroup<'static> { + /// Return the `FfdheGroup` corresponding to the provided `NamedGroup` + /// if it is indeed an FFDHE group + #[deprecated( + since = "0.23.13", + note = "This function is linker-unfriendly. Use `SupportedKxGroup::ffdhe_group()` instead" + )] + pub fn from_named_group(named_group: NamedGroup) -> Option { + match named_group { + NamedGroup::FFDHE2048 => Some(FFDHE2048), + NamedGroup::FFDHE3072 => Some(FFDHE3072), + NamedGroup::FFDHE4096 => Some(FFDHE4096), + NamedGroup::FFDHE6144 => Some(FFDHE6144), + NamedGroup::FFDHE8192 => Some(FFDHE8192), + _ => None, + } + } +} + +impl<'a> FfdheGroup<'a> { + /// Return the `NamedGroup` for the `FfdheGroup` if it represents one. + #[deprecated( + since = "0.23.13", + note = "This function is linker-unfriendly. Use `SupportedKxGroup::name()` instead" + )] + pub fn named_group(&self) -> Option { + match *self { + FFDHE2048 => Some(NamedGroup::FFDHE2048), + FFDHE3072 => Some(NamedGroup::FFDHE3072), + FFDHE4096 => Some(NamedGroup::FFDHE4096), + FFDHE6144 => Some(NamedGroup::FFDHE6144), + FFDHE8192 => Some(NamedGroup::FFDHE8192), + _ => None, + } + } + + /// Construct an `FfdheGroup` from the given `p` and `g`, trimming any potential leading zeros. + pub fn from_params_trimming_leading_zeros(p: &'a [u8], g: &'a [u8]) -> Self { + fn trim_leading_zeros(buf: &[u8]) -> &[u8] { + for start in 0..buf.len() { + if buf[start] != 0 { + return &buf[start..]; + } + } + &[] + } + + FfdheGroup { + p: trim_leading_zeros(p), + g: trim_leading_zeros(g), + } + } +} + +/// FFDHE2048 group defined in [RFC 7919 Appendix A.1] +/// +/// [RFC 7919 Appendix A.1]: https://datatracker.ietf.org/doc/html/rfc7919#appendix-A.1 +pub const FFDHE2048: FfdheGroup<'static> = FfdheGroup { + p: &[ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xad, 0xf8, 0x54, 0x58, 0xa2, 0xbb, 0x4a, + 0x9a, 0xaf, 0xdc, 0x56, 0x20, 0x27, 0x3d, 0x3c, 0xf1, 0xd8, 0xb9, 0xc5, 0x83, 0xce, 0x2d, + 0x36, 0x95, 0xa9, 0xe1, 0x36, 0x41, 0x14, 0x64, 0x33, 0xfb, 0xcc, 0x93, 0x9d, 0xce, 0x24, + 0x9b, 0x3e, 0xf9, 0x7d, 0x2f, 0xe3, 0x63, 0x63, 0x0c, 0x75, 0xd8, 0xf6, 0x81, 0xb2, 0x02, + 0xae, 0xc4, 0x61, 0x7a, 0xd3, 0xdf, 0x1e, 0xd5, 0xd5, 0xfd, 0x65, 0x61, 0x24, 0x33, 0xf5, + 0x1f, 0x5f, 0x06, 0x6e, 0xd0, 0x85, 0x63, 0x65, 0x55, 0x3d, 0xed, 0x1a, 0xf3, 0xb5, 0x57, + 0x13, 0x5e, 0x7f, 0x57, 0xc9, 0x35, 0x98, 0x4f, 0x0c, 0x70, 0xe0, 0xe6, 0x8b, 0x77, 0xe2, + 0xa6, 0x89, 0xda, 0xf3, 0xef, 0xe8, 0x72, 0x1d, 0xf1, 0x58, 0xa1, 0x36, 0xad, 0xe7, 0x35, + 0x30, 0xac, 0xca, 0x4f, 0x48, 0x3a, 0x79, 0x7a, 0xbc, 0x0a, 0xb1, 0x82, 0xb3, 0x24, 0xfb, + 0x61, 0xd1, 0x08, 0xa9, 0x4b, 0xb2, 0xc8, 0xe3, 0xfb, 0xb9, 0x6a, 0xda, 0xb7, 0x60, 0xd7, + 0xf4, 0x68, 0x1d, 0x4f, 0x42, 0xa3, 0xde, 0x39, 0x4d, 0xf4, 0xae, 0x56, 0xed, 0xe7, 0x63, + 0x72, 0xbb, 0x19, 0x0b, 0x07, 0xa7, 0xc8, 0xee, 0x0a, 0x6d, 0x70, 0x9e, 0x02, 0xfc, 0xe1, + 0xcd, 0xf7, 0xe2, 0xec, 0xc0, 0x34, 0x04, 0xcd, 0x28, 0x34, 0x2f, 0x61, 0x91, 0x72, 0xfe, + 0x9c, 0xe9, 0x85, 0x83, 0xff, 0x8e, 0x4f, 0x12, 0x32, 0xee, 0xf2, 0x81, 0x83, 0xc3, 0xfe, + 0x3b, 0x1b, 0x4c, 0x6f, 0xad, 0x73, 0x3b, 0xb5, 0xfc, 0xbc, 0x2e, 0xc2, 0x20, 0x05, 0xc5, + 0x8e, 0xf1, 0x83, 0x7d, 0x16, 0x83, 0xb2, 0xc6, 0xf3, 0x4a, 0x26, 0xc1, 0xb2, 0xef, 0xfa, + 0x88, 0x6b, 0x42, 0x38, 0x61, 0x28, 0x5c, 0x97, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, + ], + g: &[2], +}; + +/// FFDHE3072 group defined in [RFC 7919 Appendix A.2] +/// +/// [RFC 7919 Appendix A.2]: https://datatracker.ietf.org/doc/html/rfc7919#appendix-A.2 +pub const FFDHE3072: FfdheGroup<'static> = FfdheGroup { + p: &[ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xad, 0xf8, 0x54, 0x58, 0xa2, 0xbb, 0x4a, + 0x9a, 0xaf, 0xdc, 0x56, 0x20, 0x27, 0x3d, 0x3c, 0xf1, 0xd8, 0xb9, 0xc5, 0x83, 0xce, 0x2d, + 0x36, 0x95, 0xa9, 0xe1, 0x36, 0x41, 0x14, 0x64, 0x33, 0xfb, 0xcc, 0x93, 0x9d, 0xce, 0x24, + 0x9b, 0x3e, 0xf9, 0x7d, 0x2f, 0xe3, 0x63, 0x63, 0x0c, 0x75, 0xd8, 0xf6, 0x81, 0xb2, 0x02, + 0xae, 0xc4, 0x61, 0x7a, 0xd3, 0xdf, 0x1e, 0xd5, 0xd5, 0xfd, 0x65, 0x61, 0x24, 0x33, 0xf5, + 0x1f, 0x5f, 0x06, 0x6e, 0xd0, 0x85, 0x63, 0x65, 0x55, 0x3d, 0xed, 0x1a, 0xf3, 0xb5, 0x57, + 0x13, 0x5e, 0x7f, 0x57, 0xc9, 0x35, 0x98, 0x4f, 0x0c, 0x70, 0xe0, 0xe6, 0x8b, 0x77, 0xe2, + 0xa6, 0x89, 0xda, 0xf3, 0xef, 0xe8, 0x72, 0x1d, 0xf1, 0x58, 0xa1, 0x36, 0xad, 0xe7, 0x35, + 0x30, 0xac, 0xca, 0x4f, 0x48, 0x3a, 0x79, 0x7a, 0xbc, 0x0a, 0xb1, 0x82, 0xb3, 0x24, 0xfb, + 0x61, 0xd1, 0x08, 0xa9, 0x4b, 0xb2, 0xc8, 0xe3, 0xfb, 0xb9, 0x6a, 0xda, 0xb7, 0x60, 0xd7, + 0xf4, 0x68, 0x1d, 0x4f, 0x42, 0xa3, 0xde, 0x39, 0x4d, 0xf4, 0xae, 0x56, 0xed, 0xe7, 0x63, + 0x72, 0xbb, 0x19, 0x0b, 0x07, 0xa7, 0xc8, 0xee, 0x0a, 0x6d, 0x70, 0x9e, 0x02, 0xfc, 0xe1, + 0xcd, 0xf7, 0xe2, 0xec, 0xc0, 0x34, 0x04, 0xcd, 0x28, 0x34, 0x2f, 0x61, 0x91, 0x72, 0xfe, + 0x9c, 0xe9, 0x85, 0x83, 0xff, 0x8e, 0x4f, 0x12, 0x32, 0xee, 0xf2, 0x81, 0x83, 0xc3, 0xfe, + 0x3b, 0x1b, 0x4c, 0x6f, 0xad, 0x73, 0x3b, 0xb5, 0xfc, 0xbc, 0x2e, 0xc2, 0x20, 0x05, 0xc5, + 0x8e, 0xf1, 0x83, 0x7d, 0x16, 0x83, 0xb2, 0xc6, 0xf3, 0x4a, 0x26, 0xc1, 0xb2, 0xef, 0xfa, + 0x88, 0x6b, 0x42, 0x38, 0x61, 0x1f, 0xcf, 0xdc, 0xde, 0x35, 0x5b, 0x3b, 0x65, 0x19, 0x03, + 0x5b, 0xbc, 0x34, 0xf4, 0xde, 0xf9, 0x9c, 0x02, 0x38, 0x61, 0xb4, 0x6f, 0xc9, 0xd6, 0xe6, + 0xc9, 0x07, 0x7a, 0xd9, 0x1d, 0x26, 0x91, 0xf7, 0xf7, 0xee, 0x59, 0x8c, 0xb0, 0xfa, 0xc1, + 0x86, 0xd9, 0x1c, 0xae, 0xfe, 0x13, 0x09, 0x85, 0x13, 0x92, 0x70, 0xb4, 0x13, 0x0c, 0x93, + 0xbc, 0x43, 0x79, 0x44, 0xf4, 0xfd, 0x44, 0x52, 0xe2, 0xd7, 0x4d, 0xd3, 0x64, 0xf2, 0xe2, + 0x1e, 0x71, 0xf5, 0x4b, 0xff, 0x5c, 0xae, 0x82, 0xab, 0x9c, 0x9d, 0xf6, 0x9e, 0xe8, 0x6d, + 0x2b, 0xc5, 0x22, 0x36, 0x3a, 0x0d, 0xab, 0xc5, 0x21, 0x97, 0x9b, 0x0d, 0xea, 0xda, 0x1d, + 0xbf, 0x9a, 0x42, 0xd5, 0xc4, 0x48, 0x4e, 0x0a, 0xbc, 0xd0, 0x6b, 0xfa, 0x53, 0xdd, 0xef, + 0x3c, 0x1b, 0x20, 0xee, 0x3f, 0xd5, 0x9d, 0x7c, 0x25, 0xe4, 0x1d, 0x2b, 0x66, 0xc6, 0x2e, + 0x37, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + ], + g: &[2], +}; + +/// FFDHE4096 group defined in [RFC 7919 Appendix A.3] +/// +/// [RFC 7919 Appendix A.3]: https://datatracker.ietf.org/doc/html/rfc7919#appendix-A.3 +pub const FFDHE4096: FfdheGroup<'static> = FfdheGroup { + p: &[ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xad, 0xf8, 0x54, 0x58, 0xa2, 0xbb, 0x4a, + 0x9a, 0xaf, 0xdc, 0x56, 0x20, 0x27, 0x3d, 0x3c, 0xf1, 0xd8, 0xb9, 0xc5, 0x83, 0xce, 0x2d, + 0x36, 0x95, 0xa9, 0xe1, 0x36, 0x41, 0x14, 0x64, 0x33, 0xfb, 0xcc, 0x93, 0x9d, 0xce, 0x24, + 0x9b, 0x3e, 0xf9, 0x7d, 0x2f, 0xe3, 0x63, 0x63, 0x0c, 0x75, 0xd8, 0xf6, 0x81, 0xb2, 0x02, + 0xae, 0xc4, 0x61, 0x7a, 0xd3, 0xdf, 0x1e, 0xd5, 0xd5, 0xfd, 0x65, 0x61, 0x24, 0x33, 0xf5, + 0x1f, 0x5f, 0x06, 0x6e, 0xd0, 0x85, 0x63, 0x65, 0x55, 0x3d, 0xed, 0x1a, 0xf3, 0xb5, 0x57, + 0x13, 0x5e, 0x7f, 0x57, 0xc9, 0x35, 0x98, 0x4f, 0x0c, 0x70, 0xe0, 0xe6, 0x8b, 0x77, 0xe2, + 0xa6, 0x89, 0xda, 0xf3, 0xef, 0xe8, 0x72, 0x1d, 0xf1, 0x58, 0xa1, 0x36, 0xad, 0xe7, 0x35, + 0x30, 0xac, 0xca, 0x4f, 0x48, 0x3a, 0x79, 0x7a, 0xbc, 0x0a, 0xb1, 0x82, 0xb3, 0x24, 0xfb, + 0x61, 0xd1, 0x08, 0xa9, 0x4b, 0xb2, 0xc8, 0xe3, 0xfb, 0xb9, 0x6a, 0xda, 0xb7, 0x60, 0xd7, + 0xf4, 0x68, 0x1d, 0x4f, 0x42, 0xa3, 0xde, 0x39, 0x4d, 0xf4, 0xae, 0x56, 0xed, 0xe7, 0x63, + 0x72, 0xbb, 0x19, 0x0b, 0x07, 0xa7, 0xc8, 0xee, 0x0a, 0x6d, 0x70, 0x9e, 0x02, 0xfc, 0xe1, + 0xcd, 0xf7, 0xe2, 0xec, 0xc0, 0x34, 0x04, 0xcd, 0x28, 0x34, 0x2f, 0x61, 0x91, 0x72, 0xfe, + 0x9c, 0xe9, 0x85, 0x83, 0xff, 0x8e, 0x4f, 0x12, 0x32, 0xee, 0xf2, 0x81, 0x83, 0xc3, 0xfe, + 0x3b, 0x1b, 0x4c, 0x6f, 0xad, 0x73, 0x3b, 0xb5, 0xfc, 0xbc, 0x2e, 0xc2, 0x20, 0x05, 0xc5, + 0x8e, 0xf1, 0x83, 0x7d, 0x16, 0x83, 0xb2, 0xc6, 0xf3, 0x4a, 0x26, 0xc1, 0xb2, 0xef, 0xfa, + 0x88, 0x6b, 0x42, 0x38, 0x61, 0x1f, 0xcf, 0xdc, 0xde, 0x35, 0x5b, 0x3b, 0x65, 0x19, 0x03, + 0x5b, 0xbc, 0x34, 0xf4, 0xde, 0xf9, 0x9c, 0x02, 0x38, 0x61, 0xb4, 0x6f, 0xc9, 0xd6, 0xe6, + 0xc9, 0x07, 0x7a, 0xd9, 0x1d, 0x26, 0x91, 0xf7, 0xf7, 0xee, 0x59, 0x8c, 0xb0, 0xfa, 0xc1, + 0x86, 0xd9, 0x1c, 0xae, 0xfe, 0x13, 0x09, 0x85, 0x13, 0x92, 0x70, 0xb4, 0x13, 0x0c, 0x93, + 0xbc, 0x43, 0x79, 0x44, 0xf4, 0xfd, 0x44, 0x52, 0xe2, 0xd7, 0x4d, 0xd3, 0x64, 0xf2, 0xe2, + 0x1e, 0x71, 0xf5, 0x4b, 0xff, 0x5c, 0xae, 0x82, 0xab, 0x9c, 0x9d, 0xf6, 0x9e, 0xe8, 0x6d, + 0x2b, 0xc5, 0x22, 0x36, 0x3a, 0x0d, 0xab, 0xc5, 0x21, 0x97, 0x9b, 0x0d, 0xea, 0xda, 0x1d, + 0xbf, 0x9a, 0x42, 0xd5, 0xc4, 0x48, 0x4e, 0x0a, 0xbc, 0xd0, 0x6b, 0xfa, 0x53, 0xdd, 0xef, + 0x3c, 0x1b, 0x20, 0xee, 0x3f, 0xd5, 0x9d, 0x7c, 0x25, 0xe4, 0x1d, 0x2b, 0x66, 0x9e, 0x1e, + 0xf1, 0x6e, 0x6f, 0x52, 0xc3, 0x16, 0x4d, 0xf4, 0xfb, 0x79, 0x30, 0xe9, 0xe4, 0xe5, 0x88, + 0x57, 0xb6, 0xac, 0x7d, 0x5f, 0x42, 0xd6, 0x9f, 0x6d, 0x18, 0x77, 0x63, 0xcf, 0x1d, 0x55, + 0x03, 0x40, 0x04, 0x87, 0xf5, 0x5b, 0xa5, 0x7e, 0x31, 0xcc, 0x7a, 0x71, 0x35, 0xc8, 0x86, + 0xef, 0xb4, 0x31, 0x8a, 0xed, 0x6a, 0x1e, 0x01, 0x2d, 0x9e, 0x68, 0x32, 0xa9, 0x07, 0x60, + 0x0a, 0x91, 0x81, 0x30, 0xc4, 0x6d, 0xc7, 0x78, 0xf9, 0x71, 0xad, 0x00, 0x38, 0x09, 0x29, + 0x99, 0xa3, 0x33, 0xcb, 0x8b, 0x7a, 0x1a, 0x1d, 0xb9, 0x3d, 0x71, 0x40, 0x00, 0x3c, 0x2a, + 0x4e, 0xce, 0xa9, 0xf9, 0x8d, 0x0a, 0xcc, 0x0a, 0x82, 0x91, 0xcd, 0xce, 0xc9, 0x7d, 0xcf, + 0x8e, 0xc9, 0xb5, 0x5a, 0x7f, 0x88, 0xa4, 0x6b, 0x4d, 0xb5, 0xa8, 0x51, 0xf4, 0x41, 0x82, + 0xe1, 0xc6, 0x8a, 0x00, 0x7e, 0x5e, 0x65, 0x5f, 0x6a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, + ], + g: &[2], +}; + +/// FFDHE6144 group defined in [RFC 7919 Appendix A.4] +/// +/// [RFC 7919 Appendix A.4]: https://datatracker.ietf.org/doc/html/rfc7919#appendix-A.4 +pub const FFDHE6144: FfdheGroup<'static> = FfdheGroup { + p: &[ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xad, 0xf8, 0x54, 0x58, 0xa2, 0xbb, 0x4a, + 0x9a, 0xaf, 0xdc, 0x56, 0x20, 0x27, 0x3d, 0x3c, 0xf1, 0xd8, 0xb9, 0xc5, 0x83, 0xce, 0x2d, + 0x36, 0x95, 0xa9, 0xe1, 0x36, 0x41, 0x14, 0x64, 0x33, 0xfb, 0xcc, 0x93, 0x9d, 0xce, 0x24, + 0x9b, 0x3e, 0xf9, 0x7d, 0x2f, 0xe3, 0x63, 0x63, 0x0c, 0x75, 0xd8, 0xf6, 0x81, 0xb2, 0x02, + 0xae, 0xc4, 0x61, 0x7a, 0xd3, 0xdf, 0x1e, 0xd5, 0xd5, 0xfd, 0x65, 0x61, 0x24, 0x33, 0xf5, + 0x1f, 0x5f, 0x06, 0x6e, 0xd0, 0x85, 0x63, 0x65, 0x55, 0x3d, 0xed, 0x1a, 0xf3, 0xb5, 0x57, + 0x13, 0x5e, 0x7f, 0x57, 0xc9, 0x35, 0x98, 0x4f, 0x0c, 0x70, 0xe0, 0xe6, 0x8b, 0x77, 0xe2, + 0xa6, 0x89, 0xda, 0xf3, 0xef, 0xe8, 0x72, 0x1d, 0xf1, 0x58, 0xa1, 0x36, 0xad, 0xe7, 0x35, + 0x30, 0xac, 0xca, 0x4f, 0x48, 0x3a, 0x79, 0x7a, 0xbc, 0x0a, 0xb1, 0x82, 0xb3, 0x24, 0xfb, + 0x61, 0xd1, 0x08, 0xa9, 0x4b, 0xb2, 0xc8, 0xe3, 0xfb, 0xb9, 0x6a, 0xda, 0xb7, 0x60, 0xd7, + 0xf4, 0x68, 0x1d, 0x4f, 0x42, 0xa3, 0xde, 0x39, 0x4d, 0xf4, 0xae, 0x56, 0xed, 0xe7, 0x63, + 0x72, 0xbb, 0x19, 0x0b, 0x07, 0xa7, 0xc8, 0xee, 0x0a, 0x6d, 0x70, 0x9e, 0x02, 0xfc, 0xe1, + 0xcd, 0xf7, 0xe2, 0xec, 0xc0, 0x34, 0x04, 0xcd, 0x28, 0x34, 0x2f, 0x61, 0x91, 0x72, 0xfe, + 0x9c, 0xe9, 0x85, 0x83, 0xff, 0x8e, 0x4f, 0x12, 0x32, 0xee, 0xf2, 0x81, 0x83, 0xc3, 0xfe, + 0x3b, 0x1b, 0x4c, 0x6f, 0xad, 0x73, 0x3b, 0xb5, 0xfc, 0xbc, 0x2e, 0xc2, 0x20, 0x05, 0xc5, + 0x8e, 0xf1, 0x83, 0x7d, 0x16, 0x83, 0xb2, 0xc6, 0xf3, 0x4a, 0x26, 0xc1, 0xb2, 0xef, 0xfa, + 0x88, 0x6b, 0x42, 0x38, 0x61, 0x1f, 0xcf, 0xdc, 0xde, 0x35, 0x5b, 0x3b, 0x65, 0x19, 0x03, + 0x5b, 0xbc, 0x34, 0xf4, 0xde, 0xf9, 0x9c, 0x02, 0x38, 0x61, 0xb4, 0x6f, 0xc9, 0xd6, 0xe6, + 0xc9, 0x07, 0x7a, 0xd9, 0x1d, 0x26, 0x91, 0xf7, 0xf7, 0xee, 0x59, 0x8c, 0xb0, 0xfa, 0xc1, + 0x86, 0xd9, 0x1c, 0xae, 0xfe, 0x13, 0x09, 0x85, 0x13, 0x92, 0x70, 0xb4, 0x13, 0x0c, 0x93, + 0xbc, 0x43, 0x79, 0x44, 0xf4, 0xfd, 0x44, 0x52, 0xe2, 0xd7, 0x4d, 0xd3, 0x64, 0xf2, 0xe2, + 0x1e, 0x71, 0xf5, 0x4b, 0xff, 0x5c, 0xae, 0x82, 0xab, 0x9c, 0x9d, 0xf6, 0x9e, 0xe8, 0x6d, + 0x2b, 0xc5, 0x22, 0x36, 0x3a, 0x0d, 0xab, 0xc5, 0x21, 0x97, 0x9b, 0x0d, 0xea, 0xda, 0x1d, + 0xbf, 0x9a, 0x42, 0xd5, 0xc4, 0x48, 0x4e, 0x0a, 0xbc, 0xd0, 0x6b, 0xfa, 0x53, 0xdd, 0xef, + 0x3c, 0x1b, 0x20, 0xee, 0x3f, 0xd5, 0x9d, 0x7c, 0x25, 0xe4, 0x1d, 0x2b, 0x66, 0x9e, 0x1e, + 0xf1, 0x6e, 0x6f, 0x52, 0xc3, 0x16, 0x4d, 0xf4, 0xfb, 0x79, 0x30, 0xe9, 0xe4, 0xe5, 0x88, + 0x57, 0xb6, 0xac, 0x7d, 0x5f, 0x42, 0xd6, 0x9f, 0x6d, 0x18, 0x77, 0x63, 0xcf, 0x1d, 0x55, + 0x03, 0x40, 0x04, 0x87, 0xf5, 0x5b, 0xa5, 0x7e, 0x31, 0xcc, 0x7a, 0x71, 0x35, 0xc8, 0x86, + 0xef, 0xb4, 0x31, 0x8a, 0xed, 0x6a, 0x1e, 0x01, 0x2d, 0x9e, 0x68, 0x32, 0xa9, 0x07, 0x60, + 0x0a, 0x91, 0x81, 0x30, 0xc4, 0x6d, 0xc7, 0x78, 0xf9, 0x71, 0xad, 0x00, 0x38, 0x09, 0x29, + 0x99, 0xa3, 0x33, 0xcb, 0x8b, 0x7a, 0x1a, 0x1d, 0xb9, 0x3d, 0x71, 0x40, 0x00, 0x3c, 0x2a, + 0x4e, 0xce, 0xa9, 0xf9, 0x8d, 0x0a, 0xcc, 0x0a, 0x82, 0x91, 0xcd, 0xce, 0xc9, 0x7d, 0xcf, + 0x8e, 0xc9, 0xb5, 0x5a, 0x7f, 0x88, 0xa4, 0x6b, 0x4d, 0xb5, 0xa8, 0x51, 0xf4, 0x41, 0x82, + 0xe1, 0xc6, 0x8a, 0x00, 0x7e, 0x5e, 0x0d, 0xd9, 0x02, 0x0b, 0xfd, 0x64, 0xb6, 0x45, 0x03, + 0x6c, 0x7a, 0x4e, 0x67, 0x7d, 0x2c, 0x38, 0x53, 0x2a, 0x3a, 0x23, 0xba, 0x44, 0x42, 0xca, + 0xf5, 0x3e, 0xa6, 0x3b, 0xb4, 0x54, 0x32, 0x9b, 0x76, 0x24, 0xc8, 0x91, 0x7b, 0xdd, 0x64, + 0xb1, 0xc0, 0xfd, 0x4c, 0xb3, 0x8e, 0x8c, 0x33, 0x4c, 0x70, 0x1c, 0x3a, 0xcd, 0xad, 0x06, + 0x57, 0xfc, 0xcf, 0xec, 0x71, 0x9b, 0x1f, 0x5c, 0x3e, 0x4e, 0x46, 0x04, 0x1f, 0x38, 0x81, + 0x47, 0xfb, 0x4c, 0xfd, 0xb4, 0x77, 0xa5, 0x24, 0x71, 0xf7, 0xa9, 0xa9, 0x69, 0x10, 0xb8, + 0x55, 0x32, 0x2e, 0xdb, 0x63, 0x40, 0xd8, 0xa0, 0x0e, 0xf0, 0x92, 0x35, 0x05, 0x11, 0xe3, + 0x0a, 0xbe, 0xc1, 0xff, 0xf9, 0xe3, 0xa2, 0x6e, 0x7f, 0xb2, 0x9f, 0x8c, 0x18, 0x30, 0x23, + 0xc3, 0x58, 0x7e, 0x38, 0xda, 0x00, 0x77, 0xd9, 0xb4, 0x76, 0x3e, 0x4e, 0x4b, 0x94, 0xb2, + 0xbb, 0xc1, 0x94, 0xc6, 0x65, 0x1e, 0x77, 0xca, 0xf9, 0x92, 0xee, 0xaa, 0xc0, 0x23, 0x2a, + 0x28, 0x1b, 0xf6, 0xb3, 0xa7, 0x39, 0xc1, 0x22, 0x61, 0x16, 0x82, 0x0a, 0xe8, 0xdb, 0x58, + 0x47, 0xa6, 0x7c, 0xbe, 0xf9, 0xc9, 0x09, 0x1b, 0x46, 0x2d, 0x53, 0x8c, 0xd7, 0x2b, 0x03, + 0x74, 0x6a, 0xe7, 0x7f, 0x5e, 0x62, 0x29, 0x2c, 0x31, 0x15, 0x62, 0xa8, 0x46, 0x50, 0x5d, + 0xc8, 0x2d, 0xb8, 0x54, 0x33, 0x8a, 0xe4, 0x9f, 0x52, 0x35, 0xc9, 0x5b, 0x91, 0x17, 0x8c, + 0xcf, 0x2d, 0xd5, 0xca, 0xce, 0xf4, 0x03, 0xec, 0x9d, 0x18, 0x10, 0xc6, 0x27, 0x2b, 0x04, + 0x5b, 0x3b, 0x71, 0xf9, 0xdc, 0x6b, 0x80, 0xd6, 0x3f, 0xdd, 0x4a, 0x8e, 0x9a, 0xdb, 0x1e, + 0x69, 0x62, 0xa6, 0x95, 0x26, 0xd4, 0x31, 0x61, 0xc1, 0xa4, 0x1d, 0x57, 0x0d, 0x79, 0x38, + 0xda, 0xd4, 0xa4, 0x0e, 0x32, 0x9c, 0xd0, 0xe4, 0x0e, 0x65, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, + ], + g: &[2], +}; + +/// FFDHE8192 group defined in [RFC 7919 Appendix A.5] +/// +/// [RFC 7919 Appendix A.5]: https://datatracker.ietf.org/doc/html/rfc7919#appendix-A.5 +pub const FFDHE8192: FfdheGroup<'static> = FfdheGroup { + p: &[ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xad, 0xf8, 0x54, 0x58, 0xa2, 0xbb, 0x4a, + 0x9a, 0xaf, 0xdc, 0x56, 0x20, 0x27, 0x3d, 0x3c, 0xf1, 0xd8, 0xb9, 0xc5, 0x83, 0xce, 0x2d, + 0x36, 0x95, 0xa9, 0xe1, 0x36, 0x41, 0x14, 0x64, 0x33, 0xfb, 0xcc, 0x93, 0x9d, 0xce, 0x24, + 0x9b, 0x3e, 0xf9, 0x7d, 0x2f, 0xe3, 0x63, 0x63, 0x0c, 0x75, 0xd8, 0xf6, 0x81, 0xb2, 0x02, + 0xae, 0xc4, 0x61, 0x7a, 0xd3, 0xdf, 0x1e, 0xd5, 0xd5, 0xfd, 0x65, 0x61, 0x24, 0x33, 0xf5, + 0x1f, 0x5f, 0x06, 0x6e, 0xd0, 0x85, 0x63, 0x65, 0x55, 0x3d, 0xed, 0x1a, 0xf3, 0xb5, 0x57, + 0x13, 0x5e, 0x7f, 0x57, 0xc9, 0x35, 0x98, 0x4f, 0x0c, 0x70, 0xe0, 0xe6, 0x8b, 0x77, 0xe2, + 0xa6, 0x89, 0xda, 0xf3, 0xef, 0xe8, 0x72, 0x1d, 0xf1, 0x58, 0xa1, 0x36, 0xad, 0xe7, 0x35, + 0x30, 0xac, 0xca, 0x4f, 0x48, 0x3a, 0x79, 0x7a, 0xbc, 0x0a, 0xb1, 0x82, 0xb3, 0x24, 0xfb, + 0x61, 0xd1, 0x08, 0xa9, 0x4b, 0xb2, 0xc8, 0xe3, 0xfb, 0xb9, 0x6a, 0xda, 0xb7, 0x60, 0xd7, + 0xf4, 0x68, 0x1d, 0x4f, 0x42, 0xa3, 0xde, 0x39, 0x4d, 0xf4, 0xae, 0x56, 0xed, 0xe7, 0x63, + 0x72, 0xbb, 0x19, 0x0b, 0x07, 0xa7, 0xc8, 0xee, 0x0a, 0x6d, 0x70, 0x9e, 0x02, 0xfc, 0xe1, + 0xcd, 0xf7, 0xe2, 0xec, 0xc0, 0x34, 0x04, 0xcd, 0x28, 0x34, 0x2f, 0x61, 0x91, 0x72, 0xfe, + 0x9c, 0xe9, 0x85, 0x83, 0xff, 0x8e, 0x4f, 0x12, 0x32, 0xee, 0xf2, 0x81, 0x83, 0xc3, 0xfe, + 0x3b, 0x1b, 0x4c, 0x6f, 0xad, 0x73, 0x3b, 0xb5, 0xfc, 0xbc, 0x2e, 0xc2, 0x20, 0x05, 0xc5, + 0x8e, 0xf1, 0x83, 0x7d, 0x16, 0x83, 0xb2, 0xc6, 0xf3, 0x4a, 0x26, 0xc1, 0xb2, 0xef, 0xfa, + 0x88, 0x6b, 0x42, 0x38, 0x61, 0x1f, 0xcf, 0xdc, 0xde, 0x35, 0x5b, 0x3b, 0x65, 0x19, 0x03, + 0x5b, 0xbc, 0x34, 0xf4, 0xde, 0xf9, 0x9c, 0x02, 0x38, 0x61, 0xb4, 0x6f, 0xc9, 0xd6, 0xe6, + 0xc9, 0x07, 0x7a, 0xd9, 0x1d, 0x26, 0x91, 0xf7, 0xf7, 0xee, 0x59, 0x8c, 0xb0, 0xfa, 0xc1, + 0x86, 0xd9, 0x1c, 0xae, 0xfe, 0x13, 0x09, 0x85, 0x13, 0x92, 0x70, 0xb4, 0x13, 0x0c, 0x93, + 0xbc, 0x43, 0x79, 0x44, 0xf4, 0xfd, 0x44, 0x52, 0xe2, 0xd7, 0x4d, 0xd3, 0x64, 0xf2, 0xe2, + 0x1e, 0x71, 0xf5, 0x4b, 0xff, 0x5c, 0xae, 0x82, 0xab, 0x9c, 0x9d, 0xf6, 0x9e, 0xe8, 0x6d, + 0x2b, 0xc5, 0x22, 0x36, 0x3a, 0x0d, 0xab, 0xc5, 0x21, 0x97, 0x9b, 0x0d, 0xea, 0xda, 0x1d, + 0xbf, 0x9a, 0x42, 0xd5, 0xc4, 0x48, 0x4e, 0x0a, 0xbc, 0xd0, 0x6b, 0xfa, 0x53, 0xdd, 0xef, + 0x3c, 0x1b, 0x20, 0xee, 0x3f, 0xd5, 0x9d, 0x7c, 0x25, 0xe4, 0x1d, 0x2b, 0x66, 0x9e, 0x1e, + 0xf1, 0x6e, 0x6f, 0x52, 0xc3, 0x16, 0x4d, 0xf4, 0xfb, 0x79, 0x30, 0xe9, 0xe4, 0xe5, 0x88, + 0x57, 0xb6, 0xac, 0x7d, 0x5f, 0x42, 0xd6, 0x9f, 0x6d, 0x18, 0x77, 0x63, 0xcf, 0x1d, 0x55, + 0x03, 0x40, 0x04, 0x87, 0xf5, 0x5b, 0xa5, 0x7e, 0x31, 0xcc, 0x7a, 0x71, 0x35, 0xc8, 0x86, + 0xef, 0xb4, 0x31, 0x8a, 0xed, 0x6a, 0x1e, 0x01, 0x2d, 0x9e, 0x68, 0x32, 0xa9, 0x07, 0x60, + 0x0a, 0x91, 0x81, 0x30, 0xc4, 0x6d, 0xc7, 0x78, 0xf9, 0x71, 0xad, 0x00, 0x38, 0x09, 0x29, + 0x99, 0xa3, 0x33, 0xcb, 0x8b, 0x7a, 0x1a, 0x1d, 0xb9, 0x3d, 0x71, 0x40, 0x00, 0x3c, 0x2a, + 0x4e, 0xce, 0xa9, 0xf9, 0x8d, 0x0a, 0xcc, 0x0a, 0x82, 0x91, 0xcd, 0xce, 0xc9, 0x7d, 0xcf, + 0x8e, 0xc9, 0xb5, 0x5a, 0x7f, 0x88, 0xa4, 0x6b, 0x4d, 0xb5, 0xa8, 0x51, 0xf4, 0x41, 0x82, + 0xe1, 0xc6, 0x8a, 0x00, 0x7e, 0x5e, 0x0d, 0xd9, 0x02, 0x0b, 0xfd, 0x64, 0xb6, 0x45, 0x03, + 0x6c, 0x7a, 0x4e, 0x67, 0x7d, 0x2c, 0x38, 0x53, 0x2a, 0x3a, 0x23, 0xba, 0x44, 0x42, 0xca, + 0xf5, 0x3e, 0xa6, 0x3b, 0xb4, 0x54, 0x32, 0x9b, 0x76, 0x24, 0xc8, 0x91, 0x7b, 0xdd, 0x64, + 0xb1, 0xc0, 0xfd, 0x4c, 0xb3, 0x8e, 0x8c, 0x33, 0x4c, 0x70, 0x1c, 0x3a, 0xcd, 0xad, 0x06, + 0x57, 0xfc, 0xcf, 0xec, 0x71, 0x9b, 0x1f, 0x5c, 0x3e, 0x4e, 0x46, 0x04, 0x1f, 0x38, 0x81, + 0x47, 0xfb, 0x4c, 0xfd, 0xb4, 0x77, 0xa5, 0x24, 0x71, 0xf7, 0xa9, 0xa9, 0x69, 0x10, 0xb8, + 0x55, 0x32, 0x2e, 0xdb, 0x63, 0x40, 0xd8, 0xa0, 0x0e, 0xf0, 0x92, 0x35, 0x05, 0x11, 0xe3, + 0x0a, 0xbe, 0xc1, 0xff, 0xf9, 0xe3, 0xa2, 0x6e, 0x7f, 0xb2, 0x9f, 0x8c, 0x18, 0x30, 0x23, + 0xc3, 0x58, 0x7e, 0x38, 0xda, 0x00, 0x77, 0xd9, 0xb4, 0x76, 0x3e, 0x4e, 0x4b, 0x94, 0xb2, + 0xbb, 0xc1, 0x94, 0xc6, 0x65, 0x1e, 0x77, 0xca, 0xf9, 0x92, 0xee, 0xaa, 0xc0, 0x23, 0x2a, + 0x28, 0x1b, 0xf6, 0xb3, 0xa7, 0x39, 0xc1, 0x22, 0x61, 0x16, 0x82, 0x0a, 0xe8, 0xdb, 0x58, + 0x47, 0xa6, 0x7c, 0xbe, 0xf9, 0xc9, 0x09, 0x1b, 0x46, 0x2d, 0x53, 0x8c, 0xd7, 0x2b, 0x03, + 0x74, 0x6a, 0xe7, 0x7f, 0x5e, 0x62, 0x29, 0x2c, 0x31, 0x15, 0x62, 0xa8, 0x46, 0x50, 0x5d, + 0xc8, 0x2d, 0xb8, 0x54, 0x33, 0x8a, 0xe4, 0x9f, 0x52, 0x35, 0xc9, 0x5b, 0x91, 0x17, 0x8c, + 0xcf, 0x2d, 0xd5, 0xca, 0xce, 0xf4, 0x03, 0xec, 0x9d, 0x18, 0x10, 0xc6, 0x27, 0x2b, 0x04, + 0x5b, 0x3b, 0x71, 0xf9, 0xdc, 0x6b, 0x80, 0xd6, 0x3f, 0xdd, 0x4a, 0x8e, 0x9a, 0xdb, 0x1e, + 0x69, 0x62, 0xa6, 0x95, 0x26, 0xd4, 0x31, 0x61, 0xc1, 0xa4, 0x1d, 0x57, 0x0d, 0x79, 0x38, + 0xda, 0xd4, 0xa4, 0x0e, 0x32, 0x9c, 0xcf, 0xf4, 0x6a, 0xaa, 0x36, 0xad, 0x00, 0x4c, 0xf6, + 0x00, 0xc8, 0x38, 0x1e, 0x42, 0x5a, 0x31, 0xd9, 0x51, 0xae, 0x64, 0xfd, 0xb2, 0x3f, 0xce, + 0xc9, 0x50, 0x9d, 0x43, 0x68, 0x7f, 0xeb, 0x69, 0xed, 0xd1, 0xcc, 0x5e, 0x0b, 0x8c, 0xc3, + 0xbd, 0xf6, 0x4b, 0x10, 0xef, 0x86, 0xb6, 0x31, 0x42, 0xa3, 0xab, 0x88, 0x29, 0x55, 0x5b, + 0x2f, 0x74, 0x7c, 0x93, 0x26, 0x65, 0xcb, 0x2c, 0x0f, 0x1c, 0xc0, 0x1b, 0xd7, 0x02, 0x29, + 0x38, 0x88, 0x39, 0xd2, 0xaf, 0x05, 0xe4, 0x54, 0x50, 0x4a, 0xc7, 0x8b, 0x75, 0x82, 0x82, + 0x28, 0x46, 0xc0, 0xba, 0x35, 0xc3, 0x5f, 0x5c, 0x59, 0x16, 0x0c, 0xc0, 0x46, 0xfd, 0x82, + 0x51, 0x54, 0x1f, 0xc6, 0x8c, 0x9c, 0x86, 0xb0, 0x22, 0xbb, 0x70, 0x99, 0x87, 0x6a, 0x46, + 0x0e, 0x74, 0x51, 0xa8, 0xa9, 0x31, 0x09, 0x70, 0x3f, 0xee, 0x1c, 0x21, 0x7e, 0x6c, 0x38, + 0x26, 0xe5, 0x2c, 0x51, 0xaa, 0x69, 0x1e, 0x0e, 0x42, 0x3c, 0xfc, 0x99, 0xe9, 0xe3, 0x16, + 0x50, 0xc1, 0x21, 0x7b, 0x62, 0x48, 0x16, 0xcd, 0xad, 0x9a, 0x95, 0xf9, 0xd5, 0xb8, 0x01, + 0x94, 0x88, 0xd9, 0xc0, 0xa0, 0xa1, 0xfe, 0x30, 0x75, 0xa5, 0x77, 0xe2, 0x31, 0x83, 0xf8, + 0x1d, 0x4a, 0x3f, 0x2f, 0xa4, 0x57, 0x1e, 0xfc, 0x8c, 0xe0, 0xba, 0x8a, 0x4f, 0xe8, 0xb6, + 0x85, 0x5d, 0xfe, 0x72, 0xb0, 0xa6, 0x6e, 0xde, 0xd2, 0xfb, 0xab, 0xfb, 0xe5, 0x8a, 0x30, + 0xfa, 0xfa, 0xbe, 0x1c, 0x5d, 0x71, 0xa8, 0x7e, 0x2f, 0x74, 0x1e, 0xf8, 0xc1, 0xfe, 0x86, + 0xfe, 0xa6, 0xbb, 0xfd, 0xe5, 0x30, 0x67, 0x7f, 0x0d, 0x97, 0xd1, 0x1d, 0x49, 0xf7, 0xa8, + 0x44, 0x3d, 0x08, 0x22, 0xe5, 0x06, 0xa9, 0xf4, 0x61, 0x4e, 0x01, 0x1e, 0x2a, 0x94, 0x83, + 0x8f, 0xf8, 0x8c, 0xd6, 0x8c, 0x8b, 0xb7, 0xc5, 0xc6, 0x42, 0x4c, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, + ], + g: &[2], +}; + +#[test] +fn named_group_ffdhe_group_roundtrip() { + use NamedGroup::*; + let ffdhe_groups = [FFDHE2048, FFDHE3072, FFDHE4096, FFDHE6144, FFDHE8192]; + for g in ffdhe_groups { + #[allow(deprecated)] + let roundtrip = FfdheGroup::from_named_group(g) + .unwrap() + .named_group(); + assert_eq!(roundtrip, Some(g)); + } +} diff --git a/http/vendor/rustls/src/msgs/fragmenter.rs b/http/vendor/rustls/src/msgs/fragmenter.rs new file mode 100644 index 0000000..4863677 --- /dev/null +++ b/http/vendor/rustls/src/msgs/fragmenter.rs @@ -0,0 +1,232 @@ +use crate::Error; +use crate::enums::{ContentType, ProtocolVersion}; +use crate::msgs::message::{OutboundChunks, OutboundPlainMessage, PlainMessage}; +pub(crate) const MAX_FRAGMENT_LEN: usize = 16384; +pub(crate) const PACKET_OVERHEAD: usize = 1 + 2 + 2; +pub(crate) const MAX_FRAGMENT_SIZE: usize = MAX_FRAGMENT_LEN + PACKET_OVERHEAD; + +pub struct MessageFragmenter { + max_frag: usize, +} + +impl Default for MessageFragmenter { + fn default() -> Self { + Self { + max_frag: MAX_FRAGMENT_LEN, + } + } +} + +impl MessageFragmenter { + /// Take `msg` and fragment it into new messages with the same type and version. + /// + /// Each returned message size is no more than `max_frag`. + /// + /// Return an iterator across those messages. + /// + /// Payloads are borrowed from `msg`. + pub fn fragment_message<'a>( + &self, + msg: &'a PlainMessage, + ) -> impl Iterator> + 'a { + self.fragment_payload(msg.typ, msg.version, msg.payload.bytes().into()) + } + + /// Take `payload` and fragment it into new messages with given type and version. + /// + /// Each returned message size is no more than `max_frag`. + /// + /// Return an iterator across those messages. + /// + /// Payloads are borrowed from `payload`. + pub(crate) fn fragment_payload<'a>( + &self, + typ: ContentType, + version: ProtocolVersion, + payload: OutboundChunks<'a>, + ) -> impl ExactSizeIterator> { + Chunker::new(payload, self.max_frag).map(move |payload| OutboundPlainMessage { + typ, + version, + payload, + }) + } + + /// Set the maximum fragment size that will be produced. + /// + /// This includes overhead. A `max_fragment_size` of 10 will produce TLS fragments + /// up to 10 bytes long. + /// + /// A `max_fragment_size` of `None` sets the highest allowable fragment size. + /// + /// Returns BadMaxFragmentSize if the size is smaller than 32 or larger than 16389. + pub fn set_max_fragment_size(&mut self, max_fragment_size: Option) -> Result<(), Error> { + self.max_frag = match max_fragment_size { + Some(sz @ 32..=MAX_FRAGMENT_SIZE) => sz - PACKET_OVERHEAD, + None => MAX_FRAGMENT_LEN, + _ => return Err(Error::BadMaxFragmentSize), + }; + Ok(()) + } +} + +/// An iterator over borrowed fragments of a payload +struct Chunker<'a> { + payload: OutboundChunks<'a>, + limit: usize, +} + +impl<'a> Chunker<'a> { + fn new(payload: OutboundChunks<'a>, limit: usize) -> Self { + Self { payload, limit } + } +} + +impl<'a> Iterator for Chunker<'a> { + type Item = OutboundChunks<'a>; + + fn next(&mut self) -> Option { + if self.payload.is_empty() { + return None; + } + + let (before, after) = self.payload.split_at(self.limit); + self.payload = after; + Some(before) + } +} + +impl ExactSizeIterator for Chunker<'_> { + fn len(&self) -> usize { + (self.payload.len() + self.limit - 1) / self.limit + } +} + +#[cfg(test)] +mod tests { + use std::prelude::v1::*; + use std::vec; + + use super::{MessageFragmenter, PACKET_OVERHEAD}; + use crate::enums::{ContentType, ProtocolVersion}; + use crate::msgs::base::Payload; + use crate::msgs::message::{OutboundChunks, OutboundPlainMessage, PlainMessage}; + + fn msg_eq( + m: &OutboundPlainMessage<'_>, + total_len: usize, + typ: &ContentType, + version: &ProtocolVersion, + bytes: &[u8], + ) { + assert_eq!(&m.typ, typ); + assert_eq!(&m.version, version); + assert_eq!(m.payload.to_vec(), bytes); + + let buf = m.to_unencrypted_opaque().encode(); + + assert_eq!(total_len, buf.len()); + } + + #[test] + fn smoke() { + let typ = ContentType::Handshake; + let version = ProtocolVersion::TLSv1_2; + let data: Vec = (1..70u8).collect(); + let m = PlainMessage { + typ, + version, + payload: Payload::new(data), + }; + + let mut frag = MessageFragmenter::default(); + frag.set_max_fragment_size(Some(32)) + .unwrap(); + let q = frag + .fragment_message(&m) + .collect::>(); + assert_eq!(q.len(), 3); + msg_eq( + &q[0], + 32, + &typ, + &version, + &[ + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, + ], + ); + msg_eq( + &q[1], + 32, + &typ, + &version, + &[ + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, 52, 53, 54, + ], + ); + msg_eq( + &q[2], + 20, + &typ, + &version, + &[55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69], + ); + } + + #[test] + fn non_fragment() { + let m = PlainMessage { + typ: ContentType::Handshake, + version: ProtocolVersion::TLSv1_2, + payload: Payload::new(b"\x01\x02\x03\x04\x05\x06\x07\x08".to_vec()), + }; + + let mut frag = MessageFragmenter::default(); + frag.set_max_fragment_size(Some(32)) + .unwrap(); + let q = frag + .fragment_message(&m) + .collect::>(); + assert_eq!(q.len(), 1); + msg_eq( + &q[0], + PACKET_OVERHEAD + 8, + &ContentType::Handshake, + &ProtocolVersion::TLSv1_2, + b"\x01\x02\x03\x04\x05\x06\x07\x08", + ); + } + + #[test] + fn fragment_multiple_slices() { + let typ = ContentType::Handshake; + let version = ProtocolVersion::TLSv1_2; + let payload_owner: Vec<&[u8]> = vec![&[b'a'; 8], &[b'b'; 12], &[b'c'; 32], &[b'd'; 20]]; + let borrowed_payload = OutboundChunks::new(&payload_owner); + let mut frag = MessageFragmenter::default(); + frag.set_max_fragment_size(Some(37)) // 32 + packet overhead + .unwrap(); + + let fragments = frag + .fragment_payload(typ, version, borrowed_payload) + .collect::>(); + assert_eq!(fragments.len(), 3); + msg_eq( + &fragments[0], + 37, + &typ, + &version, + b"aaaaaaaabbbbbbbbbbbbcccccccccccc", + ); + msg_eq( + &fragments[1], + 37, + &typ, + &version, + b"ccccccccccccccccccccdddddddddddd", + ); + msg_eq(&fragments[2], 13, &typ, &version, b"dddddddd"); + } +} diff --git a/http/vendor/rustls/src/msgs/handshake.rs b/http/vendor/rustls/src/msgs/handshake.rs new file mode 100644 index 0000000..093f2d1 --- /dev/null +++ b/http/vendor/rustls/src/msgs/handshake.rs @@ -0,0 +1,3210 @@ +use alloc::boxed::Box; +use alloc::collections::BTreeSet; +#[cfg(feature = "logging")] +use alloc::string::String; +use alloc::vec; +use alloc::vec::Vec; +use core::ops::{Deref, DerefMut}; +use core::{fmt, iter}; + +use pki_types::{CertificateDer, DnsName}; + +#[cfg(feature = "tls12")] +use crate::crypto::ActiveKeyExchange; +use crate::crypto::SecureRandom; +use crate::enums::{ + CertificateCompressionAlgorithm, CertificateType, CipherSuite, EchClientHelloType, + HandshakeType, ProtocolVersion, SignatureScheme, +}; +use crate::error::InvalidMessage; +#[cfg(feature = "tls12")] +use crate::ffdhe_groups::FfdheGroup; +use crate::log::warn; +use crate::msgs::base::{MaybeEmpty, NonEmpty, Payload, PayloadU8, PayloadU16, PayloadU24}; +use crate::msgs::codec::{ + self, Codec, LengthPrefixedBuffer, ListLength, Reader, TlsListElement, TlsListIter, +}; +use crate::msgs::enums::{ + CertificateStatusType, ClientCertificateType, Compression, ECCurveType, ECPointFormat, + EchVersion, ExtensionType, HpkeAead, HpkeKdf, HpkeKem, KeyUpdateRequest, NamedGroup, + PskKeyExchangeMode, ServerNameType, +}; +use crate::rand; +use crate::sync::Arc; +use crate::verify::DigitallySignedStruct; +use crate::x509::wrap_in_sequence; + +/// Create a newtype wrapper around a given type. +/// +/// This is used to create newtypes for the various TLS message types which is used to wrap +/// the `PayloadU8` or `PayloadU16` types. This is typically used for types where we don't need +/// anything other than access to the underlying bytes. +macro_rules! wrapped_payload( + ($(#[$comment:meta])* $vis:vis struct $name:ident, $inner:ident$(<$inner_ty:ty>)?,) => { + $(#[$comment])* + #[derive(Clone, Debug)] + $vis struct $name($inner$(<$inner_ty>)?); + + impl From> for $name { + fn from(v: Vec) -> Self { + Self($inner::new(v)) + } + } + + impl AsRef<[u8]> for $name { + fn as_ref(&self) -> &[u8] { + self.0.0.as_slice() + } + } + + impl Codec<'_> for $name { + fn encode(&self, bytes: &mut Vec) { + self.0.encode(bytes); + } + + fn read(r: &mut Reader<'_>) -> Result { + Ok(Self($inner::read(r)?)) + } + } + } +); + +#[derive(Clone, Copy, Eq, PartialEq)] +pub(crate) struct Random(pub(crate) [u8; 32]); + +impl fmt::Debug for Random { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + super::base::hex(f, &self.0) + } +} + +static HELLO_RETRY_REQUEST_RANDOM: Random = Random([ + 0xcf, 0x21, 0xad, 0x74, 0xe5, 0x9a, 0x61, 0x11, 0xbe, 0x1d, 0x8c, 0x02, 0x1e, 0x65, 0xb8, 0x91, + 0xc2, 0xa2, 0x11, 0x16, 0x7a, 0xbb, 0x8c, 0x5e, 0x07, 0x9e, 0x09, 0xe2, 0xc8, 0xa8, 0x33, 0x9c, +]); + +static ZERO_RANDOM: Random = Random([0u8; 32]); + +impl Codec<'_> for Random { + fn encode(&self, bytes: &mut Vec) { + bytes.extend_from_slice(&self.0); + } + + fn read(r: &mut Reader<'_>) -> Result { + let Some(bytes) = r.take(32) else { + return Err(InvalidMessage::MissingData("Random")); + }; + + let mut opaque = [0; 32]; + opaque.clone_from_slice(bytes); + Ok(Self(opaque)) + } +} + +impl Random { + pub(crate) fn new(secure_random: &dyn SecureRandom) -> Result { + let mut data = [0u8; 32]; + secure_random.fill(&mut data)?; + Ok(Self(data)) + } +} + +impl From<[u8; 32]> for Random { + #[inline] + fn from(bytes: [u8; 32]) -> Self { + Self(bytes) + } +} + +#[derive(Copy, Clone)] +pub(crate) struct SessionId { + len: usize, + data: [u8; 32], +} + +impl fmt::Debug for SessionId { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + super::base::hex(f, &self.data[..self.len]) + } +} + +impl PartialEq for SessionId { + fn eq(&self, other: &Self) -> bool { + if self.len != other.len { + return false; + } + + let mut diff = 0u8; + for i in 0..self.len { + diff |= self.data[i] ^ other.data[i]; + } + + diff == 0u8 + } +} + +impl Codec<'_> for SessionId { + fn encode(&self, bytes: &mut Vec) { + debug_assert!(self.len <= 32); + bytes.push(self.len as u8); + bytes.extend_from_slice(self.as_ref()); + } + + fn read(r: &mut Reader<'_>) -> Result { + let len = u8::read(r)? as usize; + if len > 32 { + return Err(InvalidMessage::TrailingData("SessionID")); + } + + let Some(bytes) = r.take(len) else { + return Err(InvalidMessage::MissingData("SessionID")); + }; + + let mut out = [0u8; 32]; + out[..len].clone_from_slice(&bytes[..len]); + Ok(Self { data: out, len }) + } +} + +impl SessionId { + pub(crate) fn random(secure_random: &dyn SecureRandom) -> Result { + let mut data = [0u8; 32]; + secure_random.fill(&mut data)?; + Ok(Self { data, len: 32 }) + } + + pub(crate) fn empty() -> Self { + Self { + data: [0u8; 32], + len: 0, + } + } + + #[cfg(feature = "tls12")] + pub(crate) fn is_empty(&self) -> bool { + self.len == 0 + } +} + +impl AsRef<[u8]> for SessionId { + fn as_ref(&self) -> &[u8] { + &self.data[..self.len] + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct UnknownExtension { + pub(crate) typ: ExtensionType, + pub(crate) payload: Payload<'static>, +} + +impl UnknownExtension { + fn encode(&self, bytes: &mut Vec) { + self.payload.encode(bytes); + } + + fn read(typ: ExtensionType, r: &mut Reader<'_>) -> Self { + let payload = Payload::read(r).into_owned(); + Self { typ, payload } + } +} + +#[derive(Clone, Copy, Debug)] +pub(crate) struct SupportedEcPointFormats { + pub(crate) uncompressed: bool, +} + +impl Codec<'_> for SupportedEcPointFormats { + fn encode(&self, bytes: &mut Vec) { + let inner = LengthPrefixedBuffer::new(ECPointFormat::SIZE_LEN, bytes); + + if self.uncompressed { + ECPointFormat::Uncompressed.encode(inner.buf); + } + } + + fn read(r: &mut Reader<'_>) -> Result { + let mut uncompressed = false; + + for pf in TlsListIter::::new(r)? { + if let ECPointFormat::Uncompressed = pf? { + uncompressed = true; + } + } + + Ok(Self { uncompressed }) + } +} + +impl Default for SupportedEcPointFormats { + fn default() -> Self { + Self { uncompressed: true } + } +} + +/// RFC8422: `ECPointFormat ec_point_format_list<1..2^8-1>` +impl TlsListElement for ECPointFormat { + const SIZE_LEN: ListLength = ListLength::NonZeroU8 { + empty_error: InvalidMessage::IllegalEmptyList("ECPointFormats"), + }; +} + +/// RFC8422: `NamedCurve named_curve_list<2..2^16-1>` +impl TlsListElement for NamedGroup { + const SIZE_LEN: ListLength = ListLength::NonZeroU16 { + empty_error: InvalidMessage::IllegalEmptyList("NamedGroups"), + }; +} + +/// RFC8446: `SignatureScheme supported_signature_algorithms<2..2^16-2>;` +impl TlsListElement for SignatureScheme { + const SIZE_LEN: ListLength = ListLength::NonZeroU16 { + empty_error: InvalidMessage::NoSignatureSchemes, + }; +} + +#[derive(Clone, Debug)] +pub(crate) enum ServerNamePayload<'a> { + /// A successfully decoded value: + SingleDnsName(DnsName<'a>), + + /// A DNS name which was actually an IP address + IpAddress, + + /// A successfully decoded, but syntactically-invalid value. + Invalid, +} + +impl ServerNamePayload<'_> { + fn into_owned(self) -> ServerNamePayload<'static> { + match self { + Self::SingleDnsName(d) => ServerNamePayload::SingleDnsName(d.to_owned()), + Self::IpAddress => ServerNamePayload::IpAddress, + Self::Invalid => ServerNamePayload::Invalid, + } + } + + /// RFC6066: `ServerName server_name_list<1..2^16-1>` + const SIZE_LEN: ListLength = ListLength::NonZeroU16 { + empty_error: InvalidMessage::IllegalEmptyList("ServerNames"), + }; +} + +/// Simplified encoding/decoding for a `ServerName` extension payload to/from `DnsName` +/// +/// This is possible because: +/// +/// - the spec (RFC6066) disallows multiple names for a given name type +/// - name types other than ServerNameType::HostName are not defined, and they and +/// any data that follows them cannot be skipped over. +impl<'a> Codec<'a> for ServerNamePayload<'a> { + fn encode(&self, bytes: &mut Vec) { + let server_name_list = LengthPrefixedBuffer::new(Self::SIZE_LEN, bytes); + + let ServerNamePayload::SingleDnsName(dns_name) = self else { + return; + }; + + ServerNameType::HostName.encode(server_name_list.buf); + let name_slice = dns_name.as_ref().as_bytes(); + (name_slice.len() as u16).encode(server_name_list.buf); + server_name_list + .buf + .extend_from_slice(name_slice); + } + + fn read(r: &mut Reader<'a>) -> Result { + let mut found = None; + + let len = Self::SIZE_LEN.read(r)?; + let mut sub = r.sub(len)?; + + while sub.any_left() { + let typ = ServerNameType::read(&mut sub)?; + + let payload = match typ { + ServerNameType::HostName => HostNamePayload::read(&mut sub)?, + _ => { + // Consume remainder of extension bytes. Since the length of the item + // is an unknown encoding, we cannot continue. + sub.rest(); + break; + } + }; + + // "The ServerNameList MUST NOT contain more than one name of + // the same name_type." - RFC6066 + if found.is_some() { + warn!("Illegal SNI extension: duplicate host_name received"); + return Err(InvalidMessage::InvalidServerName); + } + + found = match payload { + HostNamePayload::HostName(dns_name) => { + Some(Self::SingleDnsName(dns_name.to_owned())) + } + + HostNamePayload::IpAddress(_invalid) => { + warn!( + "Illegal SNI extension: ignoring IP address presented as hostname ({_invalid:?})" + ); + Some(Self::IpAddress) + } + + HostNamePayload::Invalid(_invalid) => { + warn!( + "Illegal SNI hostname received {:?}", + String::from_utf8_lossy(&_invalid.0) + ); + Some(Self::Invalid) + } + }; + } + + Ok(found.unwrap_or(Self::Invalid)) + } +} + +impl<'a> From<&DnsName<'a>> for ServerNamePayload<'static> { + fn from(value: &DnsName<'a>) -> Self { + Self::SingleDnsName(trim_hostname_trailing_dot_for_sni(value)) + } +} + +#[derive(Clone, Debug)] +pub(crate) enum HostNamePayload { + HostName(DnsName<'static>), + IpAddress(PayloadU16), + Invalid(PayloadU16), +} + +impl HostNamePayload { + fn read(r: &mut Reader<'_>) -> Result { + use pki_types::ServerName; + let raw = PayloadU16::::read(r)?; + + match ServerName::try_from(raw.0.as_slice()) { + Ok(ServerName::DnsName(d)) => Ok(Self::HostName(d.to_owned())), + Ok(ServerName::IpAddress(_)) => Ok(Self::IpAddress(raw)), + Ok(_) | Err(_) => Ok(Self::Invalid(raw)), + } + } +} + +wrapped_payload!( + /// RFC7301: `opaque ProtocolName<1..2^8-1>;` + pub(crate) struct ProtocolName, PayloadU8, +); + +impl PartialEq for ProtocolName { + fn eq(&self, other: &Self) -> bool { + self.0 == other.0 + } +} + +impl Deref for ProtocolName { + type Target = [u8]; + + fn deref(&self) -> &Self::Target { + self.as_ref() + } +} + +/// RFC7301: `ProtocolName protocol_name_list<2..2^16-1>` +impl TlsListElement for ProtocolName { + const SIZE_LEN: ListLength = ListLength::NonZeroU16 { + empty_error: InvalidMessage::IllegalEmptyList("ProtocolNames"), + }; +} + +/// RFC7301 encodes a single protocol name as `Vec` +#[derive(Clone, Debug)] +pub(crate) struct SingleProtocolName(ProtocolName); + +impl SingleProtocolName { + pub(crate) fn new(single: ProtocolName) -> Self { + Self(single) + } + + const SIZE_LEN: ListLength = ListLength::NonZeroU16 { + empty_error: InvalidMessage::IllegalEmptyList("ProtocolNames"), + }; +} + +impl Codec<'_> for SingleProtocolName { + fn encode(&self, bytes: &mut Vec) { + let body = LengthPrefixedBuffer::new(Self::SIZE_LEN, bytes); + self.0.encode(body.buf); + } + + fn read(reader: &mut Reader<'_>) -> Result { + let len = Self::SIZE_LEN.read(reader)?; + let mut sub = reader.sub(len)?; + + let item = ProtocolName::read(&mut sub)?; + + if sub.any_left() { + Err(InvalidMessage::TrailingData("SingleProtocolName")) + } else { + Ok(Self(item)) + } + } +} + +impl AsRef for SingleProtocolName { + fn as_ref(&self) -> &ProtocolName { + &self.0 + } +} + +// --- TLS 1.3 Key shares --- +#[derive(Clone, Debug)] +pub(crate) struct KeyShareEntry { + pub(crate) group: NamedGroup, + /// RFC8446: `opaque key_exchange<1..2^16-1>;` + pub(crate) payload: PayloadU16, +} + +impl KeyShareEntry { + pub(crate) fn new(group: NamedGroup, payload: impl Into>) -> Self { + Self { + group, + payload: PayloadU16::new(payload.into()), + } + } +} + +impl Codec<'_> for KeyShareEntry { + fn encode(&self, bytes: &mut Vec) { + self.group.encode(bytes); + self.payload.encode(bytes); + } + + fn read(r: &mut Reader<'_>) -> Result { + let group = NamedGroup::read(r)?; + let payload = PayloadU16::read(r)?; + + Ok(Self { group, payload }) + } +} + +// --- TLS 1.3 PresharedKey offers --- +#[derive(Clone, Debug)] +pub(crate) struct PresharedKeyIdentity { + /// RFC8446: `opaque identity<1..2^16-1>;` + pub(crate) identity: PayloadU16, + pub(crate) obfuscated_ticket_age: u32, +} + +impl PresharedKeyIdentity { + pub(crate) fn new(id: Vec, age: u32) -> Self { + Self { + identity: PayloadU16::new(id), + obfuscated_ticket_age: age, + } + } +} + +impl Codec<'_> for PresharedKeyIdentity { + fn encode(&self, bytes: &mut Vec) { + self.identity.encode(bytes); + self.obfuscated_ticket_age.encode(bytes); + } + + fn read(r: &mut Reader<'_>) -> Result { + Ok(Self { + identity: PayloadU16::read(r)?, + obfuscated_ticket_age: u32::read(r)?, + }) + } +} + +/// RFC8446: `PskIdentity identities<7..2^16-1>;` +impl TlsListElement for PresharedKeyIdentity { + const SIZE_LEN: ListLength = ListLength::NonZeroU16 { + empty_error: InvalidMessage::IllegalEmptyList("PskIdentities"), + }; +} + +wrapped_payload!( + /// RFC8446: `opaque PskBinderEntry<32..255>;` + pub(crate) struct PresharedKeyBinder, PayloadU8, +); + +/// RFC8446: `PskBinderEntry binders<33..2^16-1>;` +impl TlsListElement for PresharedKeyBinder { + const SIZE_LEN: ListLength = ListLength::NonZeroU16 { + empty_error: InvalidMessage::IllegalEmptyList("PskBinders"), + }; +} + +#[derive(Clone, Debug)] +pub(crate) struct PresharedKeyOffer { + pub(crate) identities: Vec, + pub(crate) binders: Vec, +} + +impl PresharedKeyOffer { + /// Make a new one with one entry. + pub(crate) fn new(id: PresharedKeyIdentity, binder: Vec) -> Self { + Self { + identities: vec![id], + binders: vec![PresharedKeyBinder::from(binder)], + } + } +} + +impl Codec<'_> for PresharedKeyOffer { + fn encode(&self, bytes: &mut Vec) { + self.identities.encode(bytes); + self.binders.encode(bytes); + } + + fn read(r: &mut Reader<'_>) -> Result { + Ok(Self { + identities: Vec::read(r)?, + binders: Vec::read(r)?, + }) + } +} + +// --- RFC6066 certificate status request --- +wrapped_payload!(pub(crate) struct ResponderId, PayloadU16,); + +/// RFC6066: `ResponderID responder_id_list<0..2^16-1>;` +impl TlsListElement for ResponderId { + const SIZE_LEN: ListLength = ListLength::U16; +} + +#[derive(Clone, Debug)] +pub(crate) struct OcspCertificateStatusRequest { + pub(crate) responder_ids: Vec, + pub(crate) extensions: PayloadU16, +} + +impl Codec<'_> for OcspCertificateStatusRequest { + fn encode(&self, bytes: &mut Vec) { + CertificateStatusType::OCSP.encode(bytes); + self.responder_ids.encode(bytes); + self.extensions.encode(bytes); + } + + fn read(r: &mut Reader<'_>) -> Result { + Ok(Self { + responder_ids: Vec::read(r)?, + extensions: PayloadU16::read(r)?, + }) + } +} + +#[derive(Clone, Debug)] +pub(crate) enum CertificateStatusRequest { + Ocsp(OcspCertificateStatusRequest), + Unknown((CertificateStatusType, Payload<'static>)), +} + +impl Codec<'_> for CertificateStatusRequest { + fn encode(&self, bytes: &mut Vec) { + match self { + Self::Ocsp(r) => r.encode(bytes), + Self::Unknown((typ, payload)) => { + typ.encode(bytes); + payload.encode(bytes); + } + } + } + + fn read(r: &mut Reader<'_>) -> Result { + let typ = CertificateStatusType::read(r)?; + + match typ { + CertificateStatusType::OCSP => { + let ocsp_req = OcspCertificateStatusRequest::read(r)?; + Ok(Self::Ocsp(ocsp_req)) + } + _ => { + let data = Payload::read(r).into_owned(); + Ok(Self::Unknown((typ, data))) + } + } + } +} + +impl CertificateStatusRequest { + pub(crate) fn build_ocsp() -> Self { + let ocsp = OcspCertificateStatusRequest { + responder_ids: Vec::new(), + extensions: PayloadU16::empty(), + }; + Self::Ocsp(ocsp) + } +} + +// --- + +/// RFC8446: `PskKeyExchangeMode ke_modes<1..255>;` +#[derive(Clone, Copy, Debug, Default)] +pub(crate) struct PskKeyExchangeModes { + pub(crate) psk_dhe: bool, + pub(crate) psk: bool, +} + +impl Codec<'_> for PskKeyExchangeModes { + fn encode(&self, bytes: &mut Vec) { + let inner = LengthPrefixedBuffer::new(PskKeyExchangeMode::SIZE_LEN, bytes); + if self.psk_dhe { + PskKeyExchangeMode::PSK_DHE_KE.encode(inner.buf); + } + if self.psk { + PskKeyExchangeMode::PSK_KE.encode(inner.buf); + } + } + + fn read(reader: &mut Reader<'_>) -> Result { + let mut psk_dhe = false; + let mut psk = false; + + for ke in TlsListIter::::new(reader)? { + match ke? { + PskKeyExchangeMode::PSK_DHE_KE => psk_dhe = true, + PskKeyExchangeMode::PSK_KE => psk = true, + _ => continue, + }; + } + + Ok(Self { psk_dhe, psk }) + } +} + +impl TlsListElement for PskKeyExchangeMode { + const SIZE_LEN: ListLength = ListLength::NonZeroU8 { + empty_error: InvalidMessage::IllegalEmptyList("PskKeyExchangeModes"), + }; +} + +/// RFC8446: `KeyShareEntry client_shares<0..2^16-1>;` +impl TlsListElement for KeyShareEntry { + const SIZE_LEN: ListLength = ListLength::U16; +} + +/// The body of the `SupportedVersions` extension when it appears in a +/// `ClientHello` +/// +/// This is documented as a preference-order vector, but we (as a server) +/// ignore the preference of the client. +/// +/// RFC8446: `ProtocolVersion versions<2..254>;` +#[derive(Clone, Copy, Debug, Default)] +pub(crate) struct SupportedProtocolVersions { + pub(crate) tls13: bool, + pub(crate) tls12: bool, +} + +impl SupportedProtocolVersions { + /// Return true if `filter` returns true for any enabled version. + pub(crate) fn any(&self, filter: impl Fn(ProtocolVersion) -> bool) -> bool { + if self.tls13 && filter(ProtocolVersion::TLSv1_3) { + return true; + } + if self.tls12 && filter(ProtocolVersion::TLSv1_2) { + return true; + } + false + } + + const LIST_LENGTH: ListLength = ListLength::NonZeroU8 { + empty_error: InvalidMessage::IllegalEmptyList("ProtocolVersions"), + }; +} + +impl Codec<'_> for SupportedProtocolVersions { + fn encode(&self, bytes: &mut Vec) { + let inner = LengthPrefixedBuffer::new(Self::LIST_LENGTH, bytes); + if self.tls13 { + ProtocolVersion::TLSv1_3.encode(inner.buf); + } + if self.tls12 { + ProtocolVersion::TLSv1_2.encode(inner.buf); + } + } + + fn read(reader: &mut Reader<'_>) -> Result { + let mut tls12 = false; + let mut tls13 = false; + + for pv in TlsListIter::::new(reader)? { + match pv? { + ProtocolVersion::TLSv1_3 => tls13 = true, + ProtocolVersion::TLSv1_2 => tls12 = true, + _ => continue, + }; + } + + Ok(Self { tls13, tls12 }) + } +} + +impl TlsListElement for ProtocolVersion { + const SIZE_LEN: ListLength = ListLength::NonZeroU8 { + empty_error: InvalidMessage::IllegalEmptyList("ProtocolVersions"), + }; +} + +/// RFC7250: `CertificateType client_certificate_types<1..2^8-1>;` +/// +/// Ditto `CertificateType server_certificate_types<1..2^8-1>;` +impl TlsListElement for CertificateType { + const SIZE_LEN: ListLength = ListLength::NonZeroU8 { + empty_error: InvalidMessage::IllegalEmptyList("CertificateTypes"), + }; +} + +/// RFC8879: `CertificateCompressionAlgorithm algorithms<2..2^8-2>;` +impl TlsListElement for CertificateCompressionAlgorithm { + const SIZE_LEN: ListLength = ListLength::NonZeroU8 { + empty_error: InvalidMessage::IllegalEmptyList("CertificateCompressionAlgorithms"), + }; +} + +/// A precursor to `ClientExtensions`, allowing customisation. +/// +/// This is smaller than `ClientExtensions`, as it only contains the extensions +/// we need to vary between different protocols (eg, TCP-TLS versus QUIC). +#[derive(Clone, Default)] +pub(crate) struct ClientExtensionsInput<'a> { + /// QUIC transport parameters + pub(crate) transport_parameters: Option>, + + /// ALPN protocols + pub(crate) protocols: Option>, +} + +impl ClientExtensionsInput<'_> { + pub(crate) fn from_alpn(alpn_protocols: Vec>) -> ClientExtensionsInput<'static> { + let protocols = match alpn_protocols.is_empty() { + true => None, + false => Some( + alpn_protocols + .into_iter() + .map(ProtocolName::from) + .collect::>(), + ), + }; + + ClientExtensionsInput { + transport_parameters: None, + protocols, + } + } + + pub(crate) fn into_owned(self) -> ClientExtensionsInput<'static> { + let Self { + transport_parameters, + protocols, + } = self; + ClientExtensionsInput { + transport_parameters: transport_parameters.map(|x| x.into_owned()), + protocols, + } + } +} + +#[derive(Clone)] +pub(crate) enum TransportParameters<'a> { + /// QUIC transport parameters (RFC9001 prior to draft 33) + QuicDraft(Payload<'a>), + + /// QUIC transport parameters (RFC9001) + Quic(Payload<'a>), +} + +impl TransportParameters<'_> { + pub(crate) fn into_owned(self) -> TransportParameters<'static> { + match self { + Self::QuicDraft(v) => TransportParameters::QuicDraft(v.into_owned()), + Self::Quic(v) => TransportParameters::Quic(v.into_owned()), + } + } +} + +extension_struct! { + /// A representation of extensions present in a `ClientHello` message + /// + /// All extensions are optional (by definition) so are represented with `Option`. + /// + /// Some extensions have an empty value and are represented with Option<()>. + /// + /// Unknown extensions are dropped during parsing. + pub(crate) struct ClientExtensions<'a> { + /// Requested server name indication (RFC6066) + ExtensionType::ServerName => + pub(crate) server_name: Option>, + + /// Certificate status is requested (RFC6066) + ExtensionType::StatusRequest => + pub(crate) certificate_status_request: Option, + + /// Supported groups (RFC4492/RFC8446) + ExtensionType::EllipticCurves => + pub(crate) named_groups: Option>, + + /// Supported EC point formats (RFC4492) + ExtensionType::ECPointFormats => + pub(crate) ec_point_formats: Option, + + /// Supported signature schemes (RFC5246/RFC8446) + ExtensionType::SignatureAlgorithms => + pub(crate) signature_schemes: Option>, + + /// Offered ALPN protocols (RFC6066) + ExtensionType::ALProtocolNegotiation => + pub(crate) protocols: Option>, + + /// Available client certificate types (RFC7250) + ExtensionType::ClientCertificateType => + pub(crate) client_certificate_types: Option>, + + /// Acceptable server certificate types (RFC7250) + ExtensionType::ServerCertificateType => + pub(crate) server_certificate_types: Option>, + + /// Extended master secret is requested (RFC7627) + ExtensionType::ExtendedMasterSecret => + pub(crate) extended_master_secret_request: Option<()>, + + /// Offered certificate compression methods (RFC8879) + ExtensionType::CompressCertificate => + pub(crate) certificate_compression_algorithms: Option>, + + /// Session ticket offer or request (RFC5077/RFC8446) + ExtensionType::SessionTicket => + pub(crate) session_ticket: Option, + + /// Offered preshared keys (RFC8446) + ExtensionType::PreSharedKey => + pub(crate) preshared_key_offer: Option, + + /// Early data is requested (RFC8446) + ExtensionType::EarlyData => + pub(crate) early_data_request: Option<()>, + + /// Supported TLS versions (RFC8446) + ExtensionType::SupportedVersions => + pub(crate) supported_versions: Option, + + /// Stateless HelloRetryRequest cookie (RFC8446) + ExtensionType::Cookie => + pub(crate) cookie: Option>, + + /// Offered preshared key modes (RFC8446) + ExtensionType::PSKKeyExchangeModes => + pub(crate) preshared_key_modes: Option, + + /// Certificate authority names (RFC8446) + ExtensionType::CertificateAuthorities => + pub(crate) certificate_authority_names: Option>, + + /// Offered key exchange shares (RFC8446) + ExtensionType::KeyShare => + pub(crate) key_shares: Option>, + + /// QUIC transport parameters (RFC9001) + ExtensionType::TransportParameters => + pub(crate) transport_parameters: Option>, + + /// Secure renegotiation (RFC5746) + ExtensionType::RenegotiationInfo => + pub(crate) renegotiation_info: Option, + + /// QUIC transport parameters (RFC9001 prior to draft 33) + ExtensionType::TransportParametersDraft => + pub(crate) transport_parameters_draft: Option>, + + /// Encrypted inner client hello (draft-ietf-tls-esni) + ExtensionType::EncryptedClientHello => + pub(crate) encrypted_client_hello: Option, + + /// Encrypted client hello outer extensions (draft-ietf-tls-esni) + ExtensionType::EncryptedClientHelloOuterExtensions => + pub(crate) encrypted_client_hello_outer: Option>, + } + { + /// Order randomization seed. + pub(crate) order_seed: u16, + + /// Extensions that must appear contiguously. + pub(crate) contiguous_extensions: Vec, + } +} + +impl ClientExtensions<'_> { + pub(crate) fn into_owned(self) -> ClientExtensions<'static> { + let Self { + server_name, + certificate_status_request, + named_groups, + ec_point_formats, + signature_schemes, + protocols, + client_certificate_types, + server_certificate_types, + extended_master_secret_request, + certificate_compression_algorithms, + session_ticket, + preshared_key_offer, + early_data_request, + supported_versions, + cookie, + preshared_key_modes, + certificate_authority_names, + key_shares, + transport_parameters, + renegotiation_info, + transport_parameters_draft, + encrypted_client_hello, + encrypted_client_hello_outer, + order_seed, + contiguous_extensions, + } = self; + ClientExtensions { + server_name: server_name.map(|x| x.into_owned()), + certificate_status_request, + named_groups, + ec_point_formats, + signature_schemes, + protocols, + client_certificate_types, + server_certificate_types, + extended_master_secret_request, + certificate_compression_algorithms, + session_ticket, + preshared_key_offer, + early_data_request, + supported_versions, + cookie, + preshared_key_modes, + certificate_authority_names, + key_shares, + transport_parameters: transport_parameters.map(|x| x.into_owned()), + renegotiation_info, + transport_parameters_draft: transport_parameters_draft.map(|x| x.into_owned()), + encrypted_client_hello, + encrypted_client_hello_outer, + order_seed, + contiguous_extensions, + } + } + + pub(crate) fn used_extensions_in_encoding_order(&self) -> Vec { + let mut exts = self.order_insensitive_extensions_in_random_order(); + exts.extend(&self.contiguous_extensions); + + if self + .encrypted_client_hello_outer + .is_some() + { + exts.push(ExtensionType::EncryptedClientHelloOuterExtensions); + } + if self.encrypted_client_hello.is_some() { + exts.push(ExtensionType::EncryptedClientHello); + } + if self.preshared_key_offer.is_some() { + exts.push(ExtensionType::PreSharedKey); + } + exts + } + + /// Returns extensions which don't need a specific order, in randomized order. + /// + /// Extensions are encoded in three portions: + /// + /// - First, extensions not otherwise dealt with by other cases. + /// These are encoded in random order, controlled by `self.order_seed`, + /// and this is the set of extensions returned by this function. + /// + /// - Second, extensions named in `self.contiguous_extensions`, in the order + /// given by that field. + /// + /// - Lastly, any ECH and PSK extensions (in that order). These + /// are required to be last by the standard. + fn order_insensitive_extensions_in_random_order(&self) -> Vec { + let mut order = self.collect_used(); + + // Remove extensions which have specific order requirements. + order.retain(|ext| { + !(matches!( + ext, + ExtensionType::PreSharedKey + | ExtensionType::EncryptedClientHello + | ExtensionType::EncryptedClientHelloOuterExtensions + ) || self.contiguous_extensions.contains(ext)) + }); + + order.sort_by_cached_key(|new_ext| { + let seed = ((self.order_seed as u32) << 16) | (u16::from(*new_ext) as u32); + low_quality_integer_hash(seed) + }); + + order + } +} + +impl<'a> Codec<'a> for ClientExtensions<'a> { + fn encode(&self, bytes: &mut Vec) { + let order = self.used_extensions_in_encoding_order(); + + if order.is_empty() { + return; + } + + let body = LengthPrefixedBuffer::new(ListLength::U16, bytes); + for item in order { + self.encode_one(item, body.buf); + } + } + + fn read(r: &mut Reader<'a>) -> Result { + let mut out = Self::default(); + + // extensions length can be absent if no extensions + if !r.any_left() { + return Ok(out); + } + + let mut checker = DuplicateExtensionChecker::new(); + + let len = usize::from(u16::read(r)?); + let mut sub = r.sub(len)?; + + while sub.any_left() { + let typ = out.read_one(&mut sub, |unknown| checker.check(unknown))?; + + // PreSharedKey offer must come last + if typ == ExtensionType::PreSharedKey && sub.any_left() { + return Err(InvalidMessage::PreSharedKeyIsNotFinalExtension); + } + } + + Ok(out) + } +} + +fn trim_hostname_trailing_dot_for_sni(dns_name: &DnsName<'_>) -> DnsName<'static> { + let dns_name_str = dns_name.as_ref(); + + // RFC6066: "The hostname is represented as a byte string using + // ASCII encoding without a trailing dot" + if dns_name_str.ends_with('.') { + let trimmed = &dns_name_str[0..dns_name_str.len() - 1]; + DnsName::try_from(trimmed) + .unwrap() + .to_owned() + } else { + dns_name.to_owned() + } +} + +#[derive(Clone, Debug)] +pub(crate) enum ClientSessionTicket { + Request, + Offer(Payload<'static>), +} + +impl<'a> Codec<'a> for ClientSessionTicket { + fn encode(&self, bytes: &mut Vec) { + match self { + Self::Request => (), + Self::Offer(p) => p.encode(bytes), + } + } + + fn read(r: &mut Reader<'a>) -> Result { + Ok(match r.left() { + 0 => Self::Request, + _ => Self::Offer(Payload::read(r).into_owned()), + }) + } +} + +#[derive(Default)] +pub(crate) struct ServerExtensionsInput<'a> { + /// QUIC transport parameters + pub(crate) transport_parameters: Option>, +} + +extension_struct! { + pub(crate) struct ServerExtensions<'a> { + /// Supported EC point formats (RFC4492) + ExtensionType::ECPointFormats => + pub(crate) ec_point_formats: Option, + + /// Server name indication acknowledgement (RFC6066) + ExtensionType::ServerName => + pub(crate) server_name_ack: Option<()>, + + /// Session ticket acknowledgement (RFC5077) + ExtensionType::SessionTicket => + pub(crate) session_ticket_ack: Option<()>, + + ExtensionType::RenegotiationInfo => + pub(crate) renegotiation_info: Option, + + /// Selected ALPN protocol (RFC7301) + ExtensionType::ALProtocolNegotiation => + pub(crate) selected_protocol: Option, + + /// Key exchange server share (RFC8446) + ExtensionType::KeyShare => + pub(crate) key_share: Option, + + /// Selected preshared key index (RFC8446) + ExtensionType::PreSharedKey => + pub(crate) preshared_key: Option, + + /// Required client certificate type (RFC7250) + ExtensionType::ClientCertificateType => + pub(crate) client_certificate_type: Option, + + /// Selected server certificate type (RFC7250) + ExtensionType::ServerCertificateType => + pub(crate) server_certificate_type: Option, + + /// Extended master secret is in use (RFC7627) + ExtensionType::ExtendedMasterSecret => + pub(crate) extended_master_secret_ack: Option<()>, + + /// Certificate status acknowledgement (RFC6066) + ExtensionType::StatusRequest => + pub(crate) certificate_status_request_ack: Option<()>, + + /// Selected TLS version (RFC8446) + ExtensionType::SupportedVersions => + pub(crate) selected_version: Option, + + /// QUIC transport parameters (RFC9001) + ExtensionType::TransportParameters => + pub(crate) transport_parameters: Option>, + + /// QUIC transport parameters (RFC9001 prior to draft 33) + ExtensionType::TransportParametersDraft => + pub(crate) transport_parameters_draft: Option>, + + /// Early data is accepted (RFC8446) + ExtensionType::EarlyData => + pub(crate) early_data_ack: Option<()>, + + /// Encrypted inner client hello response (draft-ietf-tls-esni) + ExtensionType::EncryptedClientHello => + pub(crate) encrypted_client_hello_ack: Option, + } + { + pub(crate) unknown_extensions: BTreeSet, + } +} + +impl ServerExtensions<'_> { + fn into_owned(self) -> ServerExtensions<'static> { + let Self { + ec_point_formats, + server_name_ack, + session_ticket_ack, + renegotiation_info, + selected_protocol, + key_share, + preshared_key, + client_certificate_type, + server_certificate_type, + extended_master_secret_ack, + certificate_status_request_ack, + selected_version, + transport_parameters, + transport_parameters_draft, + early_data_ack, + encrypted_client_hello_ack, + unknown_extensions, + } = self; + ServerExtensions { + ec_point_formats, + server_name_ack, + session_ticket_ack, + renegotiation_info, + selected_protocol, + key_share, + preshared_key, + client_certificate_type, + server_certificate_type, + extended_master_secret_ack, + certificate_status_request_ack, + selected_version, + transport_parameters: transport_parameters.map(|x| x.into_owned()), + transport_parameters_draft: transport_parameters_draft.map(|x| x.into_owned()), + early_data_ack, + encrypted_client_hello_ack, + unknown_extensions, + } + } +} + +impl<'a> Codec<'a> for ServerExtensions<'a> { + fn encode(&self, bytes: &mut Vec) { + let extensions = LengthPrefixedBuffer::new(ListLength::U16, bytes); + + for ext in Self::ALL_EXTENSIONS { + self.encode_one(*ext, extensions.buf); + } + } + + fn read(r: &mut Reader<'a>) -> Result { + let mut out = Self::default(); + let mut checker = DuplicateExtensionChecker::new(); + + let len = usize::from(u16::read(r)?); + let mut sub = r.sub(len)?; + + while sub.any_left() { + out.read_one(&mut sub, |unknown| checker.check(unknown))?; + } + + out.unknown_extensions = checker.0; + Ok(out) + } +} + +#[derive(Clone, Debug)] +pub(crate) struct ClientHelloPayload { + pub(crate) client_version: ProtocolVersion, + pub(crate) random: Random, + pub(crate) session_id: SessionId, + pub(crate) cipher_suites: Vec, + pub(crate) compression_methods: Vec, + pub(crate) extensions: Box>, +} + +impl ClientHelloPayload { + pub(crate) fn ech_inner_encoding(&self, to_compress: Vec) -> Vec { + let mut bytes = Vec::new(); + self.payload_encode(&mut bytes, Encoding::EchInnerHello { to_compress }); + bytes + } + + pub(crate) fn payload_encode(&self, bytes: &mut Vec, purpose: Encoding) { + self.client_version.encode(bytes); + self.random.encode(bytes); + + match purpose { + // SessionID is required to be empty in the encoded inner client hello. + Encoding::EchInnerHello { .. } => SessionId::empty().encode(bytes), + _ => self.session_id.encode(bytes), + } + + self.cipher_suites.encode(bytes); + self.compression_methods.encode(bytes); + + let to_compress = match purpose { + Encoding::EchInnerHello { to_compress } if !to_compress.is_empty() => to_compress, + _ => { + self.extensions.encode(bytes); + return; + } + }; + + let mut compressed = self.extensions.clone(); + + // First, eliminate the full-fat versions of the extensions + for e in &to_compress { + compressed.clear(*e); + } + + // Replace with the marker noting which extensions were elided. + compressed.encrypted_client_hello_outer = Some(to_compress); + + // And encode as normal. + compressed.encode(bytes); + } + + pub(crate) fn has_keyshare_extension_with_duplicates(&self) -> bool { + self.key_shares + .as_ref() + .map(|entries| { + has_duplicates::<_, _, u16>( + entries + .iter() + .map(|kse| u16::from(kse.group)), + ) + }) + .unwrap_or_default() + } + + pub(crate) fn has_certificate_compression_extension_with_duplicates(&self) -> bool { + if let Some(algs) = &self.certificate_compression_algorithms { + has_duplicates::<_, _, u16>(algs.iter().cloned()) + } else { + false + } + } +} + +impl Codec<'_> for ClientHelloPayload { + fn encode(&self, bytes: &mut Vec) { + self.payload_encode(bytes, Encoding::Standard) + } + + fn read(r: &mut Reader<'_>) -> Result { + let ret = Self { + client_version: ProtocolVersion::read(r)?, + random: Random::read(r)?, + session_id: SessionId::read(r)?, + cipher_suites: Vec::read(r)?, + compression_methods: Vec::read(r)?, + extensions: Box::new(ClientExtensions::read(r)?.into_owned()), + }; + + match r.any_left() { + true => Err(InvalidMessage::TrailingData("ClientHelloPayload")), + false => Ok(ret), + } + } +} + +impl Deref for ClientHelloPayload { + type Target = ClientExtensions<'static>; + fn deref(&self) -> &Self::Target { + &self.extensions + } +} + +impl DerefMut for ClientHelloPayload { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.extensions + } +} + +/// RFC8446: `CipherSuite cipher_suites<2..2^16-2>;` +impl TlsListElement for CipherSuite { + const SIZE_LEN: ListLength = ListLength::NonZeroU16 { + empty_error: InvalidMessage::IllegalEmptyList("CipherSuites"), + }; +} + +/// RFC5246: `CompressionMethod compression_methods<1..2^8-1>;` +impl TlsListElement for Compression { + const SIZE_LEN: ListLength = ListLength::NonZeroU8 { + empty_error: InvalidMessage::IllegalEmptyList("Compressions"), + }; +} + +/// draft-ietf-tls-esni-17: `ExtensionType OuterExtensions<2..254>;` +impl TlsListElement for ExtensionType { + const SIZE_LEN: ListLength = ListLength::NonZeroU8 { + empty_error: InvalidMessage::IllegalEmptyList("ExtensionTypes"), + }; +} + +extension_struct! { + /// A representation of extensions present in a `HelloRetryRequest` message + pub(crate) struct HelloRetryRequestExtensions<'a> { + ExtensionType::KeyShare => + pub(crate) key_share: Option, + + ExtensionType::Cookie => + pub(crate) cookie: Option>, + + ExtensionType::SupportedVersions => + pub(crate) supported_versions: Option, + + ExtensionType::EncryptedClientHello => + pub(crate) encrypted_client_hello: Option>, + } + { + /// Records decoding order of records, and controls encoding order. + pub(crate) order: Option>, + } +} + +impl HelloRetryRequestExtensions<'_> { + fn into_owned(self) -> HelloRetryRequestExtensions<'static> { + let Self { + key_share, + cookie, + supported_versions, + encrypted_client_hello, + order, + } = self; + HelloRetryRequestExtensions { + key_share, + cookie, + supported_versions, + encrypted_client_hello: encrypted_client_hello.map(|x| x.into_owned()), + order, + } + } +} + +impl<'a> Codec<'a> for HelloRetryRequestExtensions<'a> { + fn encode(&self, bytes: &mut Vec) { + let extensions = LengthPrefixedBuffer::new(ListLength::U16, bytes); + + for ext in self + .order + .as_deref() + .unwrap_or(Self::ALL_EXTENSIONS) + { + self.encode_one(*ext, extensions.buf); + } + } + + fn read(r: &mut Reader<'a>) -> Result { + let mut out = Self::default(); + + // we must record order, so re-encoding round trips. this is needed, + // unfortunately, for ECH HRR confirmation + let mut order = vec![]; + + let len = usize::from(u16::read(r)?); + let mut sub = r.sub(len)?; + + while sub.any_left() { + let typ = out.read_one(&mut sub, |_unk| { + Err(InvalidMessage::UnknownHelloRetryRequestExtension) + })?; + + order.push(typ); + } + + out.order = Some(order); + Ok(out) + } +} + +#[derive(Clone, Debug)] +pub(crate) struct HelloRetryRequest { + pub(crate) legacy_version: ProtocolVersion, + pub(crate) session_id: SessionId, + pub(crate) cipher_suite: CipherSuite, + pub(crate) extensions: HelloRetryRequestExtensions<'static>, +} + +impl Codec<'_> for HelloRetryRequest { + fn encode(&self, bytes: &mut Vec) { + self.payload_encode(bytes, Encoding::Standard) + } + + fn read(r: &mut Reader<'_>) -> Result { + let session_id = SessionId::read(r)?; + let cipher_suite = CipherSuite::read(r)?; + let compression = Compression::read(r)?; + + if compression != Compression::Null { + return Err(InvalidMessage::UnsupportedCompression); + } + + Ok(Self { + legacy_version: ProtocolVersion::Unknown(0), + session_id, + cipher_suite, + extensions: HelloRetryRequestExtensions::read(r)?.into_owned(), + }) + } +} + +impl HelloRetryRequest { + fn payload_encode(&self, bytes: &mut Vec, purpose: Encoding) { + self.legacy_version.encode(bytes); + HELLO_RETRY_REQUEST_RANDOM.encode(bytes); + self.session_id.encode(bytes); + self.cipher_suite.encode(bytes); + Compression::Null.encode(bytes); + + match purpose { + // For the purpose of ECH confirmation, the Encrypted Client Hello extension + // must have its payload replaced by 8 zero bytes. + // + // See draft-ietf-tls-esni-18 7.2.1: + // + Encoding::EchConfirmation + if self + .extensions + .encrypted_client_hello + .is_some() => + { + let hrr_confirmation = [0u8; 8]; + HelloRetryRequestExtensions { + encrypted_client_hello: Some(Payload::Borrowed(&hrr_confirmation)), + ..self.extensions.clone() + } + .encode(bytes); + } + _ => self.extensions.encode(bytes), + } + } +} + +impl Deref for HelloRetryRequest { + type Target = HelloRetryRequestExtensions<'static>; + fn deref(&self) -> &Self::Target { + &self.extensions + } +} + +impl DerefMut for HelloRetryRequest { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.extensions + } +} + +#[derive(Clone, Debug)] +pub(crate) struct ServerHelloPayload { + pub(crate) legacy_version: ProtocolVersion, + pub(crate) random: Random, + pub(crate) session_id: SessionId, + pub(crate) cipher_suite: CipherSuite, + pub(crate) compression_method: Compression, + pub(crate) extensions: Box>, +} + +impl Codec<'_> for ServerHelloPayload { + fn encode(&self, bytes: &mut Vec) { + self.payload_encode(bytes, Encoding::Standard) + } + + // minus version and random, which have already been read. + fn read(r: &mut Reader<'_>) -> Result { + let session_id = SessionId::read(r)?; + let suite = CipherSuite::read(r)?; + let compression = Compression::read(r)?; + + // RFC5246: + // "The presence of extensions can be detected by determining whether + // there are bytes following the compression_method field at the end of + // the ServerHello." + let extensions = Box::new( + if r.any_left() { + ServerExtensions::read(r)? + } else { + ServerExtensions::default() + } + .into_owned(), + ); + + let ret = Self { + legacy_version: ProtocolVersion::Unknown(0), + random: ZERO_RANDOM, + session_id, + cipher_suite: suite, + compression_method: compression, + extensions, + }; + + r.expect_empty("ServerHelloPayload") + .map(|_| ret) + } +} + +impl ServerHelloPayload { + fn payload_encode(&self, bytes: &mut Vec, encoding: Encoding) { + debug_assert!( + !matches!(encoding, Encoding::EchConfirmation), + "we cannot compute an ECH confirmation on a received ServerHello" + ); + + self.legacy_version.encode(bytes); + self.random.encode(bytes); + self.session_id.encode(bytes); + self.cipher_suite.encode(bytes); + self.compression_method.encode(bytes); + self.extensions.encode(bytes); + } +} + +impl Deref for ServerHelloPayload { + type Target = ServerExtensions<'static>; + fn deref(&self) -> &Self::Target { + &self.extensions + } +} + +impl DerefMut for ServerHelloPayload { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.extensions + } +} + +#[derive(Clone, Default, Debug)] +pub(crate) struct CertificateChain<'a>(pub(crate) Vec>); + +impl CertificateChain<'_> { + pub(crate) fn into_owned(self) -> CertificateChain<'static> { + CertificateChain( + self.0 + .into_iter() + .map(|c| c.into_owned()) + .collect(), + ) + } +} + +impl<'a> Codec<'a> for CertificateChain<'a> { + fn encode(&self, bytes: &mut Vec) { + Vec::encode(&self.0, bytes) + } + + fn read(r: &mut Reader<'a>) -> Result { + Vec::read(r).map(Self) + } +} + +impl<'a> Deref for CertificateChain<'a> { + type Target = [CertificateDer<'a>]; + + fn deref(&self) -> &[CertificateDer<'a>] { + &self.0 + } +} + +impl TlsListElement for CertificateDer<'_> { + const SIZE_LEN: ListLength = ListLength::U24 { + max: CERTIFICATE_MAX_SIZE_LIMIT, + error: InvalidMessage::CertificatePayloadTooLarge, + }; +} + +/// TLS has a 16MB size limit on any handshake message, +/// plus a 16MB limit on any given certificate. +/// +/// We contract that to 64KB to limit the amount of memory allocation +/// that is directly controllable by the peer. +pub(crate) const CERTIFICATE_MAX_SIZE_LIMIT: usize = 0x1_0000; + +extension_struct! { + pub(crate) struct CertificateExtensions<'a> { + ExtensionType::StatusRequest => + pub(crate) status: Option>, + } +} + +impl CertificateExtensions<'_> { + fn into_owned(self) -> CertificateExtensions<'static> { + CertificateExtensions { + status: self.status.map(|s| s.into_owned()), + } + } +} + +impl<'a> Codec<'a> for CertificateExtensions<'a> { + fn encode(&self, bytes: &mut Vec) { + let extensions = LengthPrefixedBuffer::new(ListLength::U16, bytes); + + for ext in Self::ALL_EXTENSIONS { + self.encode_one(*ext, extensions.buf); + } + } + + fn read(r: &mut Reader<'a>) -> Result { + let mut out = Self::default(); + + let len = usize::from(u16::read(r)?); + let mut sub = r.sub(len)?; + + while sub.any_left() { + out.read_one(&mut sub, |_unk| { + Err(InvalidMessage::UnknownCertificateExtension) + })?; + } + + Ok(out) + } +} + +#[derive(Debug)] +pub(crate) struct CertificateEntry<'a> { + pub(crate) cert: CertificateDer<'a>, + pub(crate) extensions: CertificateExtensions<'a>, +} + +impl<'a> Codec<'a> for CertificateEntry<'a> { + fn encode(&self, bytes: &mut Vec) { + self.cert.encode(bytes); + self.extensions.encode(bytes); + } + + fn read(r: &mut Reader<'a>) -> Result { + Ok(Self { + cert: CertificateDer::read(r)?, + extensions: CertificateExtensions::read(r)?.into_owned(), + }) + } +} + +impl<'a> CertificateEntry<'a> { + pub(crate) fn new(cert: CertificateDer<'a>) -> Self { + Self { + cert, + extensions: CertificateExtensions::default(), + } + } + + pub(crate) fn into_owned(self) -> CertificateEntry<'static> { + CertificateEntry { + cert: self.cert.into_owned(), + extensions: self.extensions.into_owned(), + } + } +} + +impl TlsListElement for CertificateEntry<'_> { + const SIZE_LEN: ListLength = ListLength::U24 { + max: CERTIFICATE_MAX_SIZE_LIMIT, + error: InvalidMessage::CertificatePayloadTooLarge, + }; +} + +#[derive(Debug)] +pub(crate) struct CertificatePayloadTls13<'a> { + pub(crate) context: PayloadU8, + pub(crate) entries: Vec>, +} + +impl<'a> Codec<'a> for CertificatePayloadTls13<'a> { + fn encode(&self, bytes: &mut Vec) { + self.context.encode(bytes); + self.entries.encode(bytes); + } + + fn read(r: &mut Reader<'a>) -> Result { + Ok(Self { + context: PayloadU8::read(r)?, + entries: Vec::read(r)?, + }) + } +} + +impl<'a> CertificatePayloadTls13<'a> { + pub(crate) fn new( + certs: impl Iterator>, + ocsp_response: Option<&'a [u8]>, + ) -> Self { + Self { + context: PayloadU8::empty(), + entries: certs + // zip certificate iterator with `ocsp_response` followed by + // an infinite-length iterator of `None`. + .zip( + ocsp_response + .into_iter() + .map(Some) + .chain(iter::repeat(None)), + ) + .map(|(cert, ocsp)| { + let mut e = CertificateEntry::new(cert.clone()); + if let Some(ocsp) = ocsp { + e.extensions.status = Some(CertificateStatus::new(ocsp)); + } + e + }) + .collect(), + } + } + + pub(crate) fn into_owned(self) -> CertificatePayloadTls13<'static> { + CertificatePayloadTls13 { + context: self.context, + entries: self + .entries + .into_iter() + .map(CertificateEntry::into_owned) + .collect(), + } + } + + pub(crate) fn end_entity_ocsp(&self) -> Vec { + let Some(entry) = self.entries.first() else { + return vec![]; + }; + entry + .extensions + .status + .as_ref() + .map(|status| { + status + .ocsp_response + .0 + .clone() + .into_vec() + }) + .unwrap_or_default() + } + + pub(crate) fn into_certificate_chain(self) -> CertificateChain<'a> { + CertificateChain( + self.entries + .into_iter() + .map(|e| e.cert) + .collect(), + ) + } +} + +/// Describes supported key exchange mechanisms. +#[derive(Clone, Copy, Debug, PartialEq)] +#[non_exhaustive] +pub enum KeyExchangeAlgorithm { + /// Diffie-Hellman Key exchange (with only known parameters as defined in [RFC 7919]). + /// + /// [RFC 7919]: https://datatracker.ietf.org/doc/html/rfc7919 + DHE, + /// Key exchange performed via elliptic curve Diffie-Hellman. + ECDHE, +} + +pub(crate) static ALL_KEY_EXCHANGE_ALGORITHMS: &[KeyExchangeAlgorithm] = + &[KeyExchangeAlgorithm::ECDHE, KeyExchangeAlgorithm::DHE]; + +// We don't support arbitrary curves. It's a terrible +// idea and unnecessary attack surface. Please, +// get a grip. +#[derive(Debug)] +pub(crate) struct EcParameters { + pub(crate) curve_type: ECCurveType, + pub(crate) named_group: NamedGroup, +} + +impl Codec<'_> for EcParameters { + fn encode(&self, bytes: &mut Vec) { + self.curve_type.encode(bytes); + self.named_group.encode(bytes); + } + + fn read(r: &mut Reader<'_>) -> Result { + let ct = ECCurveType::read(r)?; + if ct != ECCurveType::NamedCurve { + return Err(InvalidMessage::UnsupportedCurveType); + } + + let grp = NamedGroup::read(r)?; + + Ok(Self { + curve_type: ct, + named_group: grp, + }) + } +} + +#[cfg(feature = "tls12")] +pub(crate) trait KxDecode<'a>: fmt::Debug + Sized { + /// Decode a key exchange message given the key_exchange `algo` + fn decode(r: &mut Reader<'a>, algo: KeyExchangeAlgorithm) -> Result; +} + +#[cfg(feature = "tls12")] +#[derive(Debug)] +pub(crate) enum ClientKeyExchangeParams { + Ecdh(ClientEcdhParams), + Dh(ClientDhParams), +} + +#[cfg(feature = "tls12")] +impl ClientKeyExchangeParams { + pub(crate) fn pub_key(&self) -> &[u8] { + match self { + Self::Ecdh(ecdh) => &ecdh.public.0, + Self::Dh(dh) => &dh.public.0, + } + } + + pub(crate) fn encode(&self, buf: &mut Vec) { + match self { + Self::Ecdh(ecdh) => ecdh.encode(buf), + Self::Dh(dh) => dh.encode(buf), + } + } +} + +#[cfg(feature = "tls12")] +impl KxDecode<'_> for ClientKeyExchangeParams { + fn decode(r: &mut Reader<'_>, algo: KeyExchangeAlgorithm) -> Result { + use KeyExchangeAlgorithm::*; + Ok(match algo { + ECDHE => Self::Ecdh(ClientEcdhParams::read(r)?), + DHE => Self::Dh(ClientDhParams::read(r)?), + }) + } +} + +#[cfg(feature = "tls12")] +#[derive(Debug)] +pub(crate) struct ClientEcdhParams { + /// RFC4492: `opaque point <1..2^8-1>;` + pub(crate) public: PayloadU8, +} + +#[cfg(feature = "tls12")] +impl Codec<'_> for ClientEcdhParams { + fn encode(&self, bytes: &mut Vec) { + self.public.encode(bytes); + } + + fn read(r: &mut Reader<'_>) -> Result { + let pb = PayloadU8::read(r)?; + Ok(Self { public: pb }) + } +} + +#[cfg(feature = "tls12")] +#[derive(Debug)] +pub(crate) struct ClientDhParams { + /// RFC5246: `opaque dh_Yc<1..2^16-1>;` + pub(crate) public: PayloadU16, +} + +#[cfg(feature = "tls12")] +impl Codec<'_> for ClientDhParams { + fn encode(&self, bytes: &mut Vec) { + self.public.encode(bytes); + } + + fn read(r: &mut Reader<'_>) -> Result { + Ok(Self { + public: PayloadU16::read(r)?, + }) + } +} + +#[derive(Debug)] +pub(crate) struct ServerEcdhParams { + pub(crate) curve_params: EcParameters, + /// RFC4492: `opaque point <1..2^8-1>;` + pub(crate) public: PayloadU8, +} + +impl ServerEcdhParams { + #[cfg(feature = "tls12")] + pub(crate) fn new(kx: &dyn ActiveKeyExchange) -> Self { + Self { + curve_params: EcParameters { + curve_type: ECCurveType::NamedCurve, + named_group: kx.group(), + }, + public: PayloadU8::new(kx.pub_key().to_vec()), + } + } +} + +impl Codec<'_> for ServerEcdhParams { + fn encode(&self, bytes: &mut Vec) { + self.curve_params.encode(bytes); + self.public.encode(bytes); + } + + fn read(r: &mut Reader<'_>) -> Result { + let cp = EcParameters::read(r)?; + let pb = PayloadU8::read(r)?; + + Ok(Self { + curve_params: cp, + public: pb, + }) + } +} + +#[derive(Debug)] +#[allow(non_snake_case)] +pub(crate) struct ServerDhParams { + /// RFC5246: `opaque dh_p<1..2^16-1>;` + pub(crate) dh_p: PayloadU16, + /// RFC5246: `opaque dh_g<1..2^16-1>;` + pub(crate) dh_g: PayloadU16, + /// RFC5246: `opaque dh_Ys<1..2^16-1>;` + pub(crate) dh_Ys: PayloadU16, +} + +impl ServerDhParams { + #[cfg(feature = "tls12")] + pub(crate) fn new(kx: &dyn ActiveKeyExchange) -> Self { + let Some(params) = kx.ffdhe_group() else { + panic!("invalid NamedGroup for DHE key exchange: {:?}", kx.group()); + }; + + Self { + dh_p: PayloadU16::new(params.p.to_vec()), + dh_g: PayloadU16::new(params.g.to_vec()), + dh_Ys: PayloadU16::new(kx.pub_key().to_vec()), + } + } + + #[cfg(feature = "tls12")] + pub(crate) fn as_ffdhe_group(&self) -> FfdheGroup<'_> { + FfdheGroup::from_params_trimming_leading_zeros(&self.dh_p.0, &self.dh_g.0) + } +} + +impl Codec<'_> for ServerDhParams { + fn encode(&self, bytes: &mut Vec) { + self.dh_p.encode(bytes); + self.dh_g.encode(bytes); + self.dh_Ys.encode(bytes); + } + + fn read(r: &mut Reader<'_>) -> Result { + Ok(Self { + dh_p: PayloadU16::read(r)?, + dh_g: PayloadU16::read(r)?, + dh_Ys: PayloadU16::read(r)?, + }) + } +} + +#[allow(dead_code)] +#[derive(Debug)] +pub(crate) enum ServerKeyExchangeParams { + Ecdh(ServerEcdhParams), + Dh(ServerDhParams), +} + +impl ServerKeyExchangeParams { + #[cfg(feature = "tls12")] + pub(crate) fn new(kx: &dyn ActiveKeyExchange) -> Self { + match kx.group().key_exchange_algorithm() { + KeyExchangeAlgorithm::DHE => Self::Dh(ServerDhParams::new(kx)), + KeyExchangeAlgorithm::ECDHE => Self::Ecdh(ServerEcdhParams::new(kx)), + } + } + + #[cfg(feature = "tls12")] + pub(crate) fn pub_key(&self) -> &[u8] { + match self { + Self::Ecdh(ecdh) => &ecdh.public.0, + Self::Dh(dh) => &dh.dh_Ys.0, + } + } + + pub(crate) fn encode(&self, buf: &mut Vec) { + match self { + Self::Ecdh(ecdh) => ecdh.encode(buf), + Self::Dh(dh) => dh.encode(buf), + } + } +} + +#[cfg(feature = "tls12")] +impl KxDecode<'_> for ServerKeyExchangeParams { + fn decode(r: &mut Reader<'_>, algo: KeyExchangeAlgorithm) -> Result { + use KeyExchangeAlgorithm::*; + Ok(match algo { + ECDHE => Self::Ecdh(ServerEcdhParams::read(r)?), + DHE => Self::Dh(ServerDhParams::read(r)?), + }) + } +} + +#[derive(Debug)] +pub(crate) struct ServerKeyExchange { + pub(crate) params: ServerKeyExchangeParams, + pub(crate) dss: DigitallySignedStruct, +} + +impl ServerKeyExchange { + pub(crate) fn encode(&self, buf: &mut Vec) { + self.params.encode(buf); + self.dss.encode(buf); + } +} + +#[derive(Debug)] +pub(crate) enum ServerKeyExchangePayload { + Known(ServerKeyExchange), + Unknown(Payload<'static>), +} + +impl From for ServerKeyExchangePayload { + fn from(value: ServerKeyExchange) -> Self { + Self::Known(value) + } +} + +impl Codec<'_> for ServerKeyExchangePayload { + fn encode(&self, bytes: &mut Vec) { + match self { + Self::Known(x) => x.encode(bytes), + Self::Unknown(x) => x.encode(bytes), + } + } + + fn read(r: &mut Reader<'_>) -> Result { + // read as Unknown, fully parse when we know the + // KeyExchangeAlgorithm + Ok(Self::Unknown(Payload::read(r).into_owned())) + } +} + +impl ServerKeyExchangePayload { + #[cfg(feature = "tls12")] + pub(crate) fn unwrap_given_kxa(&self, kxa: KeyExchangeAlgorithm) -> Option { + if let Self::Unknown(unk) = self { + let mut rd = Reader::init(unk.bytes()); + + let result = ServerKeyExchange { + params: ServerKeyExchangeParams::decode(&mut rd, kxa).ok()?, + dss: DigitallySignedStruct::read(&mut rd).ok()?, + }; + + if !rd.any_left() { + return Some(result); + }; + } + + None + } +} + +/// RFC5246: `ClientCertificateType certificate_types<1..2^8-1>;` +impl TlsListElement for ClientCertificateType { + const SIZE_LEN: ListLength = ListLength::NonZeroU8 { + empty_error: InvalidMessage::IllegalEmptyList("ClientCertificateTypes"), + }; +} + +wrapped_payload!( + /// A `DistinguishedName` is a `Vec` wrapped in internal types. + /// + /// It contains the DER or BER encoded [`Subject` field from RFC 5280](https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.6) + /// for a single certificate. The Subject field is [encoded as an RFC 5280 `Name`](https://datatracker.ietf.org/doc/html/rfc5280#page-116). + /// It can be decoded using [x509-parser's FromDer trait](https://docs.rs/x509-parser/latest/x509_parser/prelude/trait.FromDer.html). + /// + /// ```ignore + /// for name in distinguished_names { + /// use x509_parser::prelude::FromDer; + /// println!("{}", x509_parser::x509::X509Name::from_der(&name.0)?.1); + /// } + /// ``` + /// + /// The TLS encoding is defined in RFC5246: `opaque DistinguishedName<1..2^16-1>;` + pub struct DistinguishedName, + PayloadU16, +); + +impl DistinguishedName { + /// Create a [`DistinguishedName`] after prepending its outer SEQUENCE encoding. + /// + /// This can be decoded using [x509-parser's FromDer trait](https://docs.rs/x509-parser/latest/x509_parser/prelude/trait.FromDer.html). + /// + /// ```ignore + /// use x509_parser::prelude::FromDer; + /// println!("{}", x509_parser::x509::X509Name::from_der(dn.as_ref())?.1); + /// ``` + pub fn in_sequence(bytes: &[u8]) -> Self { + Self(PayloadU16::new(wrap_in_sequence(bytes))) + } +} + +/// RFC8446: `DistinguishedName authorities<3..2^16-1>;` however, +/// RFC5246: `DistinguishedName certificate_authorities<0..2^16-1>;` +impl TlsListElement for DistinguishedName { + const SIZE_LEN: ListLength = ListLength::U16; +} + +#[derive(Debug)] +pub(crate) struct CertificateRequestPayload { + pub(crate) certtypes: Vec, + pub(crate) sigschemes: Vec, + pub(crate) canames: Vec, +} + +impl Codec<'_> for CertificateRequestPayload { + fn encode(&self, bytes: &mut Vec) { + self.certtypes.encode(bytes); + self.sigschemes.encode(bytes); + self.canames.encode(bytes); + } + + fn read(r: &mut Reader<'_>) -> Result { + let certtypes = Vec::read(r)?; + let sigschemes = Vec::read(r)?; + let canames = Vec::read(r)?; + + if sigschemes.is_empty() { + warn!("meaningless CertificateRequest message"); + Err(InvalidMessage::NoSignatureSchemes) + } else { + Ok(Self { + certtypes, + sigschemes, + canames, + }) + } + } +} + +extension_struct! { + pub(crate) struct CertificateRequestExtensions { + ExtensionType::SignatureAlgorithms => + pub(crate) signature_algorithms: Option>, + + ExtensionType::CertificateAuthorities => + pub(crate) authority_names: Option>, + + ExtensionType::CompressCertificate => + pub(crate) certificate_compression_algorithms: Option>, + } +} + +impl Codec<'_> for CertificateRequestExtensions { + fn encode(&self, bytes: &mut Vec) { + let extensions = LengthPrefixedBuffer::new(ListLength::U16, bytes); + + for ext in Self::ALL_EXTENSIONS { + self.encode_one(*ext, extensions.buf); + } + } + + fn read(r: &mut Reader<'_>) -> Result { + let mut out = Self::default(); + + let mut checker = DuplicateExtensionChecker::new(); + + let len = usize::from(u16::read(r)?); + let mut sub = r.sub(len)?; + + while sub.any_left() { + out.read_one(&mut sub, |unknown| checker.check(unknown))?; + } + + if out + .signature_algorithms + .as_ref() + .map(|algs| algs.is_empty()) + .unwrap_or_default() + { + return Err(InvalidMessage::NoSignatureSchemes); + } + + Ok(out) + } +} + +#[derive(Debug)] +pub(crate) struct CertificateRequestPayloadTls13 { + pub(crate) context: PayloadU8, + pub(crate) extensions: CertificateRequestExtensions, +} + +impl Codec<'_> for CertificateRequestPayloadTls13 { + fn encode(&self, bytes: &mut Vec) { + self.context.encode(bytes); + self.extensions.encode(bytes); + } + + fn read(r: &mut Reader<'_>) -> Result { + let context = PayloadU8::read(r)?; + let extensions = CertificateRequestExtensions::read(r)?; + + Ok(Self { + context, + extensions, + }) + } +} + +// -- NewSessionTicket -- +#[derive(Debug)] +pub(crate) struct NewSessionTicketPayload { + pub(crate) lifetime_hint: u32, + // Tickets can be large (KB), so we deserialise this straight + // into an Arc, so it can be passed directly into the client's + // session object without copying. + pub(crate) ticket: Arc, +} + +impl NewSessionTicketPayload { + #[cfg(feature = "tls12")] + pub(crate) fn new(lifetime_hint: u32, ticket: Vec) -> Self { + Self { + lifetime_hint, + ticket: Arc::new(PayloadU16::new(ticket)), + } + } +} + +impl Codec<'_> for NewSessionTicketPayload { + fn encode(&self, bytes: &mut Vec) { + self.lifetime_hint.encode(bytes); + self.ticket.encode(bytes); + } + + fn read(r: &mut Reader<'_>) -> Result { + let lifetime = u32::read(r)?; + let ticket = Arc::new(PayloadU16::read(r)?); + + Ok(Self { + lifetime_hint: lifetime, + ticket, + }) + } +} + +// -- NewSessionTicket electric boogaloo -- +extension_struct! { + pub(crate) struct NewSessionTicketExtensions { + ExtensionType::EarlyData => + pub(crate) max_early_data_size: Option, + } +} + +impl Codec<'_> for NewSessionTicketExtensions { + fn encode(&self, bytes: &mut Vec) { + let extensions = LengthPrefixedBuffer::new(ListLength::U16, bytes); + + for ext in Self::ALL_EXTENSIONS { + self.encode_one(*ext, extensions.buf); + } + } + + fn read(r: &mut Reader<'_>) -> Result { + let mut out = Self::default(); + + let mut checker = DuplicateExtensionChecker::new(); + + let len = usize::from(u16::read(r)?); + let mut sub = r.sub(len)?; + + while sub.any_left() { + out.read_one(&mut sub, |unknown| checker.check(unknown))?; + } + + Ok(out) + } +} + +#[derive(Debug)] +pub(crate) struct NewSessionTicketPayloadTls13 { + pub(crate) lifetime: u32, + pub(crate) age_add: u32, + pub(crate) nonce: PayloadU8, + pub(crate) ticket: Arc, + pub(crate) extensions: NewSessionTicketExtensions, +} + +impl NewSessionTicketPayloadTls13 { + pub(crate) fn new(lifetime: u32, age_add: u32, nonce: Vec, ticket: Vec) -> Self { + Self { + lifetime, + age_add, + nonce: PayloadU8::new(nonce), + ticket: Arc::new(PayloadU16::new(ticket)), + extensions: NewSessionTicketExtensions::default(), + } + } +} + +impl Codec<'_> for NewSessionTicketPayloadTls13 { + fn encode(&self, bytes: &mut Vec) { + self.lifetime.encode(bytes); + self.age_add.encode(bytes); + self.nonce.encode(bytes); + self.ticket.encode(bytes); + self.extensions.encode(bytes); + } + + fn read(r: &mut Reader<'_>) -> Result { + let lifetime = u32::read(r)?; + let age_add = u32::read(r)?; + let nonce = PayloadU8::read(r)?; + // nb. RFC8446: `opaque ticket<1..2^16-1>;` + let ticket = Arc::new(match PayloadU16::::read(r) { + Err(InvalidMessage::IllegalEmptyValue) => Err(InvalidMessage::EmptyTicketValue), + Err(err) => Err(err), + Ok(pl) => Ok(PayloadU16::new(pl.0)), + }?); + let extensions = NewSessionTicketExtensions::read(r)?; + + Ok(Self { + lifetime, + age_add, + nonce, + ticket, + extensions, + }) + } +} + +// -- RFC6066 certificate status types + +/// Only supports OCSP +#[derive(Clone, Debug)] +pub(crate) struct CertificateStatus<'a> { + pub(crate) ocsp_response: PayloadU24<'a>, +} + +impl<'a> Codec<'a> for CertificateStatus<'a> { + fn encode(&self, bytes: &mut Vec) { + CertificateStatusType::OCSP.encode(bytes); + self.ocsp_response.encode(bytes); + } + + fn read(r: &mut Reader<'a>) -> Result { + let typ = CertificateStatusType::read(r)?; + + match typ { + CertificateStatusType::OCSP => Ok(Self { + ocsp_response: PayloadU24::read(r)?, + }), + _ => Err(InvalidMessage::InvalidCertificateStatusType), + } + } +} + +impl<'a> CertificateStatus<'a> { + pub(crate) fn new(ocsp: &'a [u8]) -> Self { + CertificateStatus { + ocsp_response: PayloadU24(Payload::Borrowed(ocsp)), + } + } + + #[cfg(feature = "tls12")] + pub(crate) fn into_inner(self) -> Vec { + self.ocsp_response.0.into_vec() + } + + pub(crate) fn into_owned(self) -> CertificateStatus<'static> { + CertificateStatus { + ocsp_response: self.ocsp_response.into_owned(), + } + } +} + +// -- RFC8879 compressed certificates + +#[derive(Debug)] +pub(crate) struct CompressedCertificatePayload<'a> { + pub(crate) alg: CertificateCompressionAlgorithm, + pub(crate) uncompressed_len: u32, + pub(crate) compressed: PayloadU24<'a>, +} + +impl<'a> Codec<'a> for CompressedCertificatePayload<'a> { + fn encode(&self, bytes: &mut Vec) { + self.alg.encode(bytes); + codec::u24(self.uncompressed_len).encode(bytes); + self.compressed.encode(bytes); + } + + fn read(r: &mut Reader<'a>) -> Result { + Ok(Self { + alg: CertificateCompressionAlgorithm::read(r)?, + uncompressed_len: codec::u24::read(r)?.0, + compressed: PayloadU24::read(r)?, + }) + } +} + +impl CompressedCertificatePayload<'_> { + fn into_owned(self) -> CompressedCertificatePayload<'static> { + CompressedCertificatePayload { + compressed: self.compressed.into_owned(), + ..self + } + } + + pub(crate) fn as_borrowed(&self) -> CompressedCertificatePayload<'_> { + CompressedCertificatePayload { + alg: self.alg, + uncompressed_len: self.uncompressed_len, + compressed: PayloadU24(Payload::Borrowed(self.compressed.0.bytes())), + } + } +} + +#[derive(Debug)] +pub(crate) enum HandshakePayload<'a> { + HelloRequest, + ClientHello(ClientHelloPayload), + ServerHello(ServerHelloPayload), + HelloRetryRequest(HelloRetryRequest), + Certificate(CertificateChain<'a>), + CertificateTls13(CertificatePayloadTls13<'a>), + CompressedCertificate(CompressedCertificatePayload<'a>), + ServerKeyExchange(ServerKeyExchangePayload), + CertificateRequest(CertificateRequestPayload), + CertificateRequestTls13(CertificateRequestPayloadTls13), + CertificateVerify(DigitallySignedStruct), + ServerHelloDone, + EndOfEarlyData, + ClientKeyExchange(Payload<'a>), + NewSessionTicket(NewSessionTicketPayload), + NewSessionTicketTls13(NewSessionTicketPayloadTls13), + EncryptedExtensions(Box>), + KeyUpdate(KeyUpdateRequest), + Finished(Payload<'a>), + CertificateStatus(CertificateStatus<'a>), + MessageHash(Payload<'a>), + Unknown((HandshakeType, Payload<'a>)), +} + +impl HandshakePayload<'_> { + fn encode(&self, bytes: &mut Vec) { + use self::HandshakePayload::*; + match self { + HelloRequest | ServerHelloDone | EndOfEarlyData => {} + ClientHello(x) => x.encode(bytes), + ServerHello(x) => x.encode(bytes), + HelloRetryRequest(x) => x.encode(bytes), + Certificate(x) => x.encode(bytes), + CertificateTls13(x) => x.encode(bytes), + CompressedCertificate(x) => x.encode(bytes), + ServerKeyExchange(x) => x.encode(bytes), + ClientKeyExchange(x) => x.encode(bytes), + CertificateRequest(x) => x.encode(bytes), + CertificateRequestTls13(x) => x.encode(bytes), + CertificateVerify(x) => x.encode(bytes), + NewSessionTicket(x) => x.encode(bytes), + NewSessionTicketTls13(x) => x.encode(bytes), + EncryptedExtensions(x) => x.encode(bytes), + KeyUpdate(x) => x.encode(bytes), + Finished(x) => x.encode(bytes), + CertificateStatus(x) => x.encode(bytes), + MessageHash(x) => x.encode(bytes), + Unknown((_, x)) => x.encode(bytes), + } + } + + pub(crate) fn handshake_type(&self) -> HandshakeType { + use self::HandshakePayload::*; + match self { + HelloRequest => HandshakeType::HelloRequest, + ClientHello(_) => HandshakeType::ClientHello, + ServerHello(_) => HandshakeType::ServerHello, + HelloRetryRequest(_) => HandshakeType::HelloRetryRequest, + Certificate(_) | CertificateTls13(_) => HandshakeType::Certificate, + CompressedCertificate(_) => HandshakeType::CompressedCertificate, + ServerKeyExchange(_) => HandshakeType::ServerKeyExchange, + CertificateRequest(_) | CertificateRequestTls13(_) => HandshakeType::CertificateRequest, + CertificateVerify(_) => HandshakeType::CertificateVerify, + ServerHelloDone => HandshakeType::ServerHelloDone, + EndOfEarlyData => HandshakeType::EndOfEarlyData, + ClientKeyExchange(_) => HandshakeType::ClientKeyExchange, + NewSessionTicket(_) | NewSessionTicketTls13(_) => HandshakeType::NewSessionTicket, + EncryptedExtensions(_) => HandshakeType::EncryptedExtensions, + KeyUpdate(_) => HandshakeType::KeyUpdate, + Finished(_) => HandshakeType::Finished, + CertificateStatus(_) => HandshakeType::CertificateStatus, + MessageHash(_) => HandshakeType::MessageHash, + Unknown((t, _)) => *t, + } + } + + fn wire_handshake_type(&self) -> HandshakeType { + match self.handshake_type() { + // A `HelloRetryRequest` appears on the wire as a `ServerHello` with a magic `random` value. + HandshakeType::HelloRetryRequest => HandshakeType::ServerHello, + other => other, + } + } + + fn into_owned(self) -> HandshakePayload<'static> { + use HandshakePayload::*; + + match self { + HelloRequest => HelloRequest, + ClientHello(x) => ClientHello(x), + ServerHello(x) => ServerHello(x), + HelloRetryRequest(x) => HelloRetryRequest(x), + Certificate(x) => Certificate(x.into_owned()), + CertificateTls13(x) => CertificateTls13(x.into_owned()), + CompressedCertificate(x) => CompressedCertificate(x.into_owned()), + ServerKeyExchange(x) => ServerKeyExchange(x), + CertificateRequest(x) => CertificateRequest(x), + CertificateRequestTls13(x) => CertificateRequestTls13(x), + CertificateVerify(x) => CertificateVerify(x), + ServerHelloDone => ServerHelloDone, + EndOfEarlyData => EndOfEarlyData, + ClientKeyExchange(x) => ClientKeyExchange(x.into_owned()), + NewSessionTicket(x) => NewSessionTicket(x), + NewSessionTicketTls13(x) => NewSessionTicketTls13(x), + EncryptedExtensions(x) => EncryptedExtensions(Box::new(x.into_owned())), + KeyUpdate(x) => KeyUpdate(x), + Finished(x) => Finished(x.into_owned()), + CertificateStatus(x) => CertificateStatus(x.into_owned()), + MessageHash(x) => MessageHash(x.into_owned()), + Unknown((t, x)) => Unknown((t, x.into_owned())), + } + } +} + +#[derive(Debug)] +pub struct HandshakeMessagePayload<'a>(pub(crate) HandshakePayload<'a>); + +impl<'a> Codec<'a> for HandshakeMessagePayload<'a> { + fn encode(&self, bytes: &mut Vec) { + self.payload_encode(bytes, Encoding::Standard); + } + + fn read(r: &mut Reader<'a>) -> Result { + Self::read_version(r, ProtocolVersion::TLSv1_2) + } +} + +impl<'a> HandshakeMessagePayload<'a> { + pub(crate) fn read_version( + r: &mut Reader<'a>, + vers: ProtocolVersion, + ) -> Result { + let typ = HandshakeType::read(r)?; + let len = codec::u24::read(r)?.0 as usize; + let mut sub = r.sub(len)?; + + let payload = match typ { + HandshakeType::HelloRequest if sub.left() == 0 => HandshakePayload::HelloRequest, + HandshakeType::ClientHello => { + HandshakePayload::ClientHello(ClientHelloPayload::read(&mut sub)?) + } + HandshakeType::ServerHello => { + let version = ProtocolVersion::read(&mut sub)?; + let random = Random::read(&mut sub)?; + + if random == HELLO_RETRY_REQUEST_RANDOM { + let mut hrr = HelloRetryRequest::read(&mut sub)?; + hrr.legacy_version = version; + HandshakePayload::HelloRetryRequest(hrr) + } else { + let mut shp = ServerHelloPayload::read(&mut sub)?; + shp.legacy_version = version; + shp.random = random; + HandshakePayload::ServerHello(shp) + } + } + HandshakeType::Certificate if vers == ProtocolVersion::TLSv1_3 => { + let p = CertificatePayloadTls13::read(&mut sub)?; + HandshakePayload::CertificateTls13(p) + } + HandshakeType::Certificate => { + HandshakePayload::Certificate(CertificateChain::read(&mut sub)?) + } + HandshakeType::ServerKeyExchange => { + let p = ServerKeyExchangePayload::read(&mut sub)?; + HandshakePayload::ServerKeyExchange(p) + } + HandshakeType::ServerHelloDone => { + sub.expect_empty("ServerHelloDone")?; + HandshakePayload::ServerHelloDone + } + HandshakeType::ClientKeyExchange => { + HandshakePayload::ClientKeyExchange(Payload::read(&mut sub)) + } + HandshakeType::CertificateRequest if vers == ProtocolVersion::TLSv1_3 => { + let p = CertificateRequestPayloadTls13::read(&mut sub)?; + HandshakePayload::CertificateRequestTls13(p) + } + HandshakeType::CertificateRequest => { + let p = CertificateRequestPayload::read(&mut sub)?; + HandshakePayload::CertificateRequest(p) + } + HandshakeType::CompressedCertificate => HandshakePayload::CompressedCertificate( + CompressedCertificatePayload::read(&mut sub)?, + ), + HandshakeType::CertificateVerify => { + HandshakePayload::CertificateVerify(DigitallySignedStruct::read(&mut sub)?) + } + HandshakeType::NewSessionTicket if vers == ProtocolVersion::TLSv1_3 => { + let p = NewSessionTicketPayloadTls13::read(&mut sub)?; + HandshakePayload::NewSessionTicketTls13(p) + } + HandshakeType::NewSessionTicket => { + let p = NewSessionTicketPayload::read(&mut sub)?; + HandshakePayload::NewSessionTicket(p) + } + HandshakeType::EncryptedExtensions => { + HandshakePayload::EncryptedExtensions(Box::new(ServerExtensions::read(&mut sub)?)) + } + HandshakeType::KeyUpdate => { + HandshakePayload::KeyUpdate(KeyUpdateRequest::read(&mut sub)?) + } + HandshakeType::EndOfEarlyData => { + sub.expect_empty("EndOfEarlyData")?; + HandshakePayload::EndOfEarlyData + } + HandshakeType::Finished => HandshakePayload::Finished(Payload::read(&mut sub)), + HandshakeType::CertificateStatus => { + HandshakePayload::CertificateStatus(CertificateStatus::read(&mut sub)?) + } + HandshakeType::MessageHash => { + // does not appear on the wire + return Err(InvalidMessage::UnexpectedMessage("MessageHash")); + } + HandshakeType::HelloRetryRequest => { + // not legal on wire + return Err(InvalidMessage::UnexpectedMessage("HelloRetryRequest")); + } + _ => HandshakePayload::Unknown((typ, Payload::read(&mut sub))), + }; + + sub.expect_empty("HandshakeMessagePayload") + .map(|_| Self(payload)) + } + + pub(crate) fn encoding_for_binder_signing(&self) -> Vec { + let mut ret = self.get_encoding(); + let ret_len = ret.len() - self.total_binder_length(); + ret.truncate(ret_len); + ret + } + + pub(crate) fn total_binder_length(&self) -> usize { + match &self.0 { + HandshakePayload::ClientHello(ch) => match &ch.preshared_key_offer { + Some(offer) => { + let mut binders_encoding = Vec::new(); + offer + .binders + .encode(&mut binders_encoding); + binders_encoding.len() + } + _ => 0, + }, + _ => 0, + } + } + + pub(crate) fn payload_encode(&self, bytes: &mut Vec, encoding: Encoding) { + // output type, length, and encoded payload + self.0 + .wire_handshake_type() + .encode(bytes); + + let nested = LengthPrefixedBuffer::new( + ListLength::U24 { + max: usize::MAX, + error: InvalidMessage::MessageTooLarge, + }, + bytes, + ); + + match &self.0 { + // for Server Hello and HelloRetryRequest payloads we need to encode the payload + // differently based on the purpose of the encoding. + HandshakePayload::ServerHello(payload) => payload.payload_encode(nested.buf, encoding), + HandshakePayload::HelloRetryRequest(payload) => { + payload.payload_encode(nested.buf, encoding) + } + + // All other payload types are encoded the same regardless of purpose. + _ => self.0.encode(nested.buf), + } + } + + pub(crate) fn build_handshake_hash(hash: &[u8]) -> Self { + Self(HandshakePayload::MessageHash(Payload::new(hash.to_vec()))) + } + + pub(crate) fn into_owned(self) -> HandshakeMessagePayload<'static> { + HandshakeMessagePayload(self.0.into_owned()) + } +} + +#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)] +pub struct HpkeSymmetricCipherSuite { + pub kdf_id: HpkeKdf, + pub aead_id: HpkeAead, +} + +impl Codec<'_> for HpkeSymmetricCipherSuite { + fn encode(&self, bytes: &mut Vec) { + self.kdf_id.encode(bytes); + self.aead_id.encode(bytes); + } + + fn read(r: &mut Reader<'_>) -> Result { + Ok(Self { + kdf_id: HpkeKdf::read(r)?, + aead_id: HpkeAead::read(r)?, + }) + } +} + +/// draft-ietf-tls-esni-24: `HpkeSymmetricCipherSuite cipher_suites<4..2^16-4>;` +impl TlsListElement for HpkeSymmetricCipherSuite { + const SIZE_LEN: ListLength = ListLength::NonZeroU16 { + empty_error: InvalidMessage::IllegalEmptyList("HpkeSymmetricCipherSuites"), + }; +} + +#[derive(Clone, Debug, PartialEq)] +pub struct HpkeKeyConfig { + pub config_id: u8, + pub kem_id: HpkeKem, + /// draft-ietf-tls-esni-24: `opaque HpkePublicKey<1..2^16-1>;` + pub public_key: PayloadU16, + pub symmetric_cipher_suites: Vec, +} + +impl Codec<'_> for HpkeKeyConfig { + fn encode(&self, bytes: &mut Vec) { + self.config_id.encode(bytes); + self.kem_id.encode(bytes); + self.public_key.encode(bytes); + self.symmetric_cipher_suites + .encode(bytes); + } + + fn read(r: &mut Reader<'_>) -> Result { + Ok(Self { + config_id: u8::read(r)?, + kem_id: HpkeKem::read(r)?, + public_key: PayloadU16::read(r)?, + symmetric_cipher_suites: Vec::::read(r)?, + }) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub struct EchConfigContents { + pub key_config: HpkeKeyConfig, + pub maximum_name_length: u8, + pub public_name: DnsName<'static>, + pub extensions: Vec, +} + +impl EchConfigContents { + /// Returns true if there is more than one extension of a given + /// type. + pub(crate) fn has_duplicate_extension(&self) -> bool { + has_duplicates::<_, _, u16>( + self.extensions + .iter() + .map(|ext| ext.ext_type()), + ) + } + + /// Returns true if there is at least one mandatory unsupported extension. + pub(crate) fn has_unknown_mandatory_extension(&self) -> bool { + self.extensions + .iter() + // An extension is considered mandatory if the high bit of its type is set. + .any(|ext| { + matches!(ext.ext_type(), ExtensionType::Unknown(_)) + && u16::from(ext.ext_type()) & 0x8000 != 0 + }) + } +} + +impl Codec<'_> for EchConfigContents { + fn encode(&self, bytes: &mut Vec) { + self.key_config.encode(bytes); + self.maximum_name_length.encode(bytes); + let dns_name = &self.public_name.borrow(); + PayloadU8::::encode_slice(dns_name.as_ref().as_ref(), bytes); + self.extensions.encode(bytes); + } + + fn read(r: &mut Reader<'_>) -> Result { + Ok(Self { + key_config: HpkeKeyConfig::read(r)?, + maximum_name_length: u8::read(r)?, + public_name: { + DnsName::try_from( + PayloadU8::::read(r)? + .0 + .as_slice(), + ) + .map_err(|_| InvalidMessage::InvalidServerName)? + .to_owned() + }, + extensions: Vec::read(r)?, + }) + } +} + +/// An encrypted client hello (ECH) config. +#[derive(Clone, Debug, PartialEq)] +pub enum EchConfigPayload { + /// A recognized V18 ECH configuration. + V18(EchConfigContents), + /// An unknown version ECH configuration. + Unknown { + version: EchVersion, + contents: PayloadU16, + }, +} + +impl TlsListElement for EchConfigPayload { + const SIZE_LEN: ListLength = ListLength::U16; +} + +impl Codec<'_> for EchConfigPayload { + fn encode(&self, bytes: &mut Vec) { + match self { + Self::V18(c) => { + // Write the version, the length, and the contents. + EchVersion::V18.encode(bytes); + let inner = LengthPrefixedBuffer::new(ListLength::U16, bytes); + c.encode(inner.buf); + } + Self::Unknown { version, contents } => { + // Unknown configuration versions are opaque. + version.encode(bytes); + contents.encode(bytes); + } + } + } + + fn read(r: &mut Reader<'_>) -> Result { + let version = EchVersion::read(r)?; + let length = u16::read(r)?; + let mut contents = r.sub(length as usize)?; + + Ok(match version { + EchVersion::V18 => Self::V18(EchConfigContents::read(&mut contents)?), + _ => { + // Note: we don't PayloadU16::read() here because we've already read the length prefix. + let data = PayloadU16::new(contents.rest().into()); + Self::Unknown { + version, + contents: data, + } + } + }) + } +} + +#[derive(Clone, Debug, PartialEq)] +pub enum EchConfigExtension { + Unknown(UnknownExtension), +} + +impl EchConfigExtension { + pub(crate) fn ext_type(&self) -> ExtensionType { + match self { + Self::Unknown(r) => r.typ, + } + } +} + +impl Codec<'_> for EchConfigExtension { + fn encode(&self, bytes: &mut Vec) { + self.ext_type().encode(bytes); + + let nested = LengthPrefixedBuffer::new(ListLength::U16, bytes); + match self { + Self::Unknown(r) => r.encode(nested.buf), + } + } + + fn read(r: &mut Reader<'_>) -> Result { + let typ = ExtensionType::read(r)?; + let len = u16::read(r)? as usize; + let mut sub = r.sub(len)?; + + #[allow(clippy::match_single_binding)] // Future-proofing. + let ext = match typ { + _ => Self::Unknown(UnknownExtension::read(typ, &mut sub)), + }; + + sub.expect_empty("EchConfigExtension") + .map(|_| ext) + } +} + +impl TlsListElement for EchConfigExtension { + const SIZE_LEN: ListLength = ListLength::U16; +} + +/// Representation of the `ECHClientHello` client extension specified in +/// [draft-ietf-tls-esni Section 5]. +/// +/// [draft-ietf-tls-esni Section 5]: +#[derive(Clone, Debug)] +pub(crate) enum EncryptedClientHello { + /// A `ECHClientHello` with type [EchClientHelloType::ClientHelloOuter]. + Outer(EncryptedClientHelloOuter), + /// An empty `ECHClientHello` with type [EchClientHelloType::ClientHelloInner]. + /// + /// This variant has no payload. + Inner, +} + +impl Codec<'_> for EncryptedClientHello { + fn encode(&self, bytes: &mut Vec) { + match self { + Self::Outer(payload) => { + EchClientHelloType::ClientHelloOuter.encode(bytes); + payload.encode(bytes); + } + Self::Inner => { + EchClientHelloType::ClientHelloInner.encode(bytes); + // Empty payload. + } + } + } + + fn read(r: &mut Reader<'_>) -> Result { + match EchClientHelloType::read(r)? { + EchClientHelloType::ClientHelloOuter => { + Ok(Self::Outer(EncryptedClientHelloOuter::read(r)?)) + } + EchClientHelloType::ClientHelloInner => Ok(Self::Inner), + _ => Err(InvalidMessage::InvalidContentType), + } + } +} + +/// Representation of the ECHClientHello extension with type outer specified in +/// [draft-ietf-tls-esni Section 5]. +/// +/// [draft-ietf-tls-esni Section 5]: +#[derive(Clone, Debug)] +pub(crate) struct EncryptedClientHelloOuter { + /// The cipher suite used to encrypt ClientHelloInner. Must match a value from + /// ECHConfigContents.cipher_suites list. + pub cipher_suite: HpkeSymmetricCipherSuite, + /// The ECHConfigContents.key_config.config_id for the chosen ECHConfig. + pub config_id: u8, + /// The HPKE encapsulated key, used by servers to decrypt the corresponding payload field. + /// This field is empty in a ClientHelloOuter sent in response to a HelloRetryRequest. + pub enc: PayloadU16, + /// The serialized and encrypted ClientHelloInner structure, encrypted using HPKE. + pub payload: PayloadU16, +} + +impl Codec<'_> for EncryptedClientHelloOuter { + fn encode(&self, bytes: &mut Vec) { + self.cipher_suite.encode(bytes); + self.config_id.encode(bytes); + self.enc.encode(bytes); + self.payload.encode(bytes); + } + + fn read(r: &mut Reader<'_>) -> Result { + Ok(Self { + cipher_suite: HpkeSymmetricCipherSuite::read(r)?, + config_id: u8::read(r)?, + enc: PayloadU16::read(r)?, + payload: PayloadU16::read(r)?, + }) + } +} + +/// Representation of the ECHEncryptedExtensions extension specified in +/// [draft-ietf-tls-esni Section 5]. +/// +/// [draft-ietf-tls-esni Section 5]: +#[derive(Clone, Debug)] +pub(crate) struct ServerEncryptedClientHello { + pub(crate) retry_configs: Vec, +} + +impl Codec<'_> for ServerEncryptedClientHello { + fn encode(&self, bytes: &mut Vec) { + self.retry_configs.encode(bytes); + } + + fn read(r: &mut Reader<'_>) -> Result { + Ok(Self { + retry_configs: Vec::::read(r)?, + }) + } +} + +/// The method of encoding to use for a handshake message. +/// +/// In some cases a handshake message may be encoded differently depending on the purpose +/// the encoded message is being used for. +pub(crate) enum Encoding { + /// Standard RFC 8446 encoding. + Standard, + /// Encoding for ECH confirmation for HRR. + EchConfirmation, + /// Encoding for ECH inner client hello. + EchInnerHello { to_compress: Vec }, +} + +fn has_duplicates, E: Into, T: Eq + Ord>(iter: I) -> bool { + let mut seen = BTreeSet::new(); + + for x in iter { + if !seen.insert(x.into()) { + return true; + } + } + + false +} + +struct DuplicateExtensionChecker(BTreeSet); + +impl DuplicateExtensionChecker { + fn new() -> Self { + Self(BTreeSet::new()) + } + + fn check(&mut self, typ: ExtensionType) -> Result<(), InvalidMessage> { + let u = u16::from(typ); + match self.0.insert(u) { + true => Ok(()), + false => Err(InvalidMessage::DuplicateExtension(u)), + } + } +} + +fn low_quality_integer_hash(mut x: u32) -> u32 { + x = x + .wrapping_add(0x7ed55d16) + .wrapping_add(x << 12); + x = (x ^ 0xc761c23c) ^ (x >> 19); + x = x + .wrapping_add(0x165667b1) + .wrapping_add(x << 5); + x = x.wrapping_add(0xd3a2646c) ^ (x << 9); + x = x + .wrapping_add(0xfd7046c5) + .wrapping_add(x << 3); + x = (x ^ 0xb55a4f09) ^ (x >> 16); + x +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_ech_config_dupe_exts() { + let unknown_ext = EchConfigExtension::Unknown(UnknownExtension { + typ: ExtensionType::Unknown(0x42), + payload: Payload::new(vec![0x42]), + }); + let mut config = config_template(); + config + .extensions + .push(unknown_ext.clone()); + config.extensions.push(unknown_ext); + + assert!(config.has_duplicate_extension()); + assert!(!config.has_unknown_mandatory_extension()); + } + + #[test] + fn test_ech_config_mandatory_exts() { + let mandatory_unknown_ext = EchConfigExtension::Unknown(UnknownExtension { + typ: ExtensionType::Unknown(0x42 | 0x8000), // Note: high bit set. + payload: Payload::new(vec![0x42]), + }); + let mut config = config_template(); + config + .extensions + .push(mandatory_unknown_ext); + + assert!(!config.has_duplicate_extension()); + assert!(config.has_unknown_mandatory_extension()); + } + + fn config_template() -> EchConfigContents { + EchConfigContents { + key_config: HpkeKeyConfig { + config_id: 0, + kem_id: HpkeKem::DHKEM_P256_HKDF_SHA256, + public_key: PayloadU16::new(b"xxx".into()), + symmetric_cipher_suites: vec![HpkeSymmetricCipherSuite { + kdf_id: HpkeKdf::HKDF_SHA256, + aead_id: HpkeAead::AES_128_GCM, + }], + }, + maximum_name_length: 0, + public_name: DnsName::try_from("example.com").unwrap(), + extensions: vec![], + } + } +} diff --git a/http/vendor/rustls/src/msgs/handshake_test.rs b/http/vendor/rustls/src/msgs/handshake_test.rs new file mode 100644 index 0000000..53cf88f --- /dev/null +++ b/http/vendor/rustls/src/msgs/handshake_test.rs @@ -0,0 +1,1051 @@ +use std::prelude::v1::*; +use std::{format, println, vec}; + +use pki_types::{CertificateDer, DnsName}; + +use super::base::{Payload, PayloadU8, PayloadU16, PayloadU24}; +use super::codec::{Codec, Reader, put_u16}; +use super::enums::{ + ClientCertificateType, Compression, ECCurveType, ExtensionType, KeyUpdateRequest, NamedGroup, +}; +use super::handshake::{ + CertificateChain, CertificateEntry, CertificateExtensions, CertificatePayloadTls13, + CertificateRequestExtensions, CertificateRequestPayload, CertificateRequestPayloadTls13, + CertificateStatus, CertificateStatusRequest, ClientExtensions, ClientHelloPayload, + ClientSessionTicket, CompressedCertificatePayload, DistinguishedName, EcParameters, + EncryptedClientHello, HandshakeMessagePayload, HandshakePayload, HelloRetryRequest, + HelloRetryRequestExtensions, KeyShareEntry, NewSessionTicketExtensions, + NewSessionTicketPayload, NewSessionTicketPayloadTls13, PresharedKeyBinder, + PresharedKeyIdentity, PresharedKeyOffer, ProtocolName, PskKeyExchangeModes, Random, + ServerDhParams, ServerEcdhParams, ServerEncryptedClientHello, ServerExtensions, + ServerHelloPayload, ServerKeyExchange, ServerKeyExchangeParams, ServerKeyExchangePayload, + ServerNamePayload, SessionId, SingleProtocolName, SupportedEcPointFormats, + SupportedProtocolVersions, +}; +use crate::enums::{ + CertificateCompressionAlgorithm, CertificateType, CipherSuite, HandshakeType, ProtocolVersion, + SignatureScheme, +}; +use crate::error::InvalidMessage; +use crate::sync::Arc; +use crate::verify::DigitallySignedStruct; + +#[test] +fn rejects_short_random() { + let bytes = [0x01; 31]; + let mut rd = Reader::init(&bytes); + assert!(Random::read(&mut rd).is_err()); +} + +#[test] +fn reads_random() { + let bytes = [0x01; 32]; + let mut rd = Reader::init(&bytes); + let rnd = Random::read(&mut rd).unwrap(); + println!("{rnd:?}"); + + assert!(!rd.any_left()); +} + +#[test] +fn debug_random() { + assert_eq!( + "0101010101010101010101010101010101010101010101010101010101010101", + format!("{:?}", Random::from([1; 32])) + ); +} + +#[test] +fn rejects_truncated_session_id() { + let bytes = [32; 32]; + let mut rd = Reader::init(&bytes); + assert!(SessionId::read(&mut rd).is_err()); +} + +#[test] +fn rejects_session_id_with_bad_length() { + let bytes = [33; 33]; + let mut rd = Reader::init(&bytes); + assert!(SessionId::read(&mut rd).is_err()); +} + +#[test] +fn session_id_with_different_lengths_are_unequal() { + let a = SessionId::read(&mut Reader::init(&[1u8, 1])).unwrap(); + let b = SessionId::read(&mut Reader::init(&[2u8, 1, 2])).unwrap(); + assert_ne!(a, b); +} + +#[test] +fn accepts_short_session_id() { + let bytes = [1; 2]; + let mut rd = Reader::init(&bytes); + let sess = SessionId::read(&mut rd).unwrap(); + println!("{sess:?}"); + + #[cfg(feature = "tls12")] + assert!(!sess.is_empty()); + assert_ne!(sess, SessionId::empty()); + assert!(!rd.any_left()); +} + +#[test] +fn accepts_empty_session_id() { + let bytes = [0; 1]; + let mut rd = Reader::init(&bytes); + let sess = SessionId::read(&mut rd).unwrap(); + println!("{sess:?}"); + + #[cfg(feature = "tls12")] + assert!(sess.is_empty()); + assert_eq!(sess, SessionId::empty()); + assert!(!rd.any_left()); +} + +#[test] +fn debug_session_id() { + let bytes = [ + 32, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, + ]; + let mut rd = Reader::init(&bytes); + let sess = SessionId::read(&mut rd).unwrap(); + assert_eq!( + "0101010101010101010101010101010101010101010101010101010101010101", + format!("{sess:?}") + ); +} + +#[test] +fn refuses_client_exts_with_unparsed_bytes() { + let bytes = [0x00u8, 0x08, 0x00, 0x0b, 0x00, 0x04, 0x02, 0xf8, 0x01, 0x02]; + assert_eq!( + ClientExtensions::read_bytes(&bytes).unwrap_err(), + InvalidMessage::TrailingData("ClientExtensions") + ); +} + +#[test] +fn refuses_server_ext_with_unparsed_bytes() { + let bytes = [0x00u8, 0x08, 0x00, 0x0b, 0x00, 0x04, 0x02, 0xf8, 0x01, 0x02]; + assert_eq!( + ServerExtensions::read_bytes(&bytes).unwrap_err(), + InvalidMessage::TrailingData("ServerExtensions") + ); +} + +#[test] +fn refuses_certificate_ext_with_unparsed_bytes() { + let bytes = [ + 0x00u8, 0x09, 0x00, 0x05, 0x00, 0x05, 0x01, 0x00, 0x00, 0x00, 0x01, + ]; + assert_eq!( + CertificateExtensions::read_bytes(&bytes).unwrap_err(), + InvalidMessage::TrailingData("CertificateExtensions") + ); +} + +#[test] +fn refuses_certificate_ext_with_unknown_type() { + let bytes = [0x00u8, 0x08, 0x00, 0x05, 0x00, 0x03, 0x99, 0x00, 0x00, 0x00]; + assert_eq!( + CertificateExtensions::read_bytes(&bytes).unwrap_err(), + InvalidMessage::InvalidCertificateStatusType + ); +} + +#[test] +fn refuses_certificate_req_ext_with_unparsed_bytes() { + let bytes = [ + 0x00u8, 0x09, 0x00, 0x0d, 0x00, 0x05, 0x00, 0x02, 0x01, 0x02, 0xff, + ]; + assert_eq!( + CertificateRequestExtensions::read_bytes(&bytes).unwrap_err(), + InvalidMessage::TrailingData("CertificateRequestExtensions") + ); +} + +#[test] +fn refuses_certificate_req_ext_with_duplicate() { + let bytes = [0x00u8, 0x08, 0x00, 0x99, 0x00, 0x00, 0x00, 0x99, 0x00, 0x00]; + assert_eq!( + CertificateRequestExtensions::read_bytes(&bytes).unwrap_err(), + InvalidMessage::DuplicateExtension(0x0099) + ); +} + +#[test] +fn refuses_new_session_ticket_ext_with_unparsed_bytes() { + let bytes = [ + 0x00u8, 0x09, 0x00, 0x2a, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x01, + ]; + assert_eq!( + NewSessionTicketExtensions::read_bytes(&bytes).unwrap_err(), + InvalidMessage::TrailingData("NewSessionTicketExtensions") + ); +} + +#[test] +fn refuses_new_session_ticket_ext_with_duplicate_extension() { + let bytes = [0x00u8, 0x08, 0x00, 0x99, 0x00, 0x00, 0x00, 0x99, 0x00, 0x00]; + assert_eq!( + NewSessionTicketExtensions::read_bytes(&bytes).unwrap_err(), + InvalidMessage::DuplicateExtension(0x0099) + ); +} + +#[test] +fn rejects_truncated_sni() { + let bytes = [0, 1, 0]; + assert!(ServerNamePayload::read(&mut Reader::init(&bytes)).is_err()); + + let bytes = [0, 2, 0, 1]; + assert!(ServerNamePayload::read(&mut Reader::init(&bytes)).is_err()); + + let bytes = [0, 3, 0, 1, 0]; + assert!(ServerNamePayload::read(&mut Reader::init(&bytes)).is_err()); + + let bytes = [0, 4, 0, 2, 0, 0]; + assert!(ServerNamePayload::read(&mut Reader::init(&bytes)).is_err()); + + let bytes = [0, 5, 0, 3, 0, 0, 0]; + assert!(ServerNamePayload::read(&mut Reader::init(&bytes)).is_err()); + + let bytes = [0, 5, 0, 3, 0, 0, 1]; + assert!(ServerNamePayload::read(&mut Reader::init(&bytes)).is_err()); + + let bytes = [0, 6, 0, 4, 0, 0, 2, 0x68]; + assert!(ServerNamePayload::read(&mut Reader::init(&bytes)).is_err()); +} + +#[test] +fn rejects_empty_sni_extension() { + assert_eq!( + ClientExtensions::read_bytes(&[0, 6, 0, 0, 0, 2, 0, 0]).unwrap_err(), + InvalidMessage::IllegalEmptyList("ServerNames") + ); +} + +#[test] +fn rejects_duplicate_names_in_sni_extension() { + assert_eq!( + ClientExtensions::read_bytes(&[0, 14, 0, 0, 0, 10, 0, 8, 0, 0, 1, b'a', 0, 0, 1, b'b',]) + .unwrap_err(), + InvalidMessage::InvalidServerName + ); +} + +#[test] +fn can_round_trip_psk_identity() { + let bytes = [0, 1, 0x99, 0x11, 0x22, 0x33, 0x44]; + let psk_id = PresharedKeyIdentity::read(&mut Reader::init(&bytes)).unwrap(); + println!("{psk_id:?}"); + assert_eq!(psk_id.obfuscated_ticket_age, 0x11223344); + assert_eq!(psk_id.get_encoding(), bytes.to_vec()); + + let bytes = [0, 5, 0x1, 0x2, 0x3, 0x4, 0x5, 0x11, 0x22, 0x33, 0x44]; + let psk_id = PresharedKeyIdentity::read(&mut Reader::init(&bytes)).unwrap(); + println!("{psk_id:?}"); + assert_eq!(psk_id.identity.0, vec![0x1, 0x2, 0x3, 0x4, 0x5]); + assert_eq!(psk_id.obfuscated_ticket_age, 0x11223344); + assert_eq!(psk_id.get_encoding(), bytes.to_vec()); +} + +#[test] +fn can_round_trip_psk_offer() { + let bytes = [ + 0, 7, 0, 1, 0x99, 0x11, 0x22, 0x33, 0x44, 0, 4, 3, 0x01, 0x02, 0x3, + ]; + let psko = PresharedKeyOffer::read(&mut Reader::init(&bytes)).unwrap(); + println!("{psko:?}"); + + assert_eq!(psko.identities.len(), 1); + assert_eq!(psko.identities[0].identity.0, vec![0x99]); + assert_eq!(psko.identities[0].obfuscated_ticket_age, 0x11223344); + assert_eq!(psko.binders.len(), 1); + assert_eq!(psko.binders[0].as_ref(), &[1, 2, 3]); + assert_eq!(psko.get_encoding(), bytes.to_vec()); +} + +#[test] +fn can_round_trip_cert_status_req_for_ocsp() { + let ext = CertificateStatusRequest::build_ocsp(); + println!("{ext:?}"); + + let bytes = [ + 0, 11, 1, // OCSP + 0, 5, 0, 3, 0, 1, 1, 0, 1, 2, + ]; + + let csr = CertificateStatusRequest::read(&mut Reader::init(&bytes)).unwrap(); + println!("{csr:?}"); + assert_eq!(csr.get_encoding(), bytes.to_vec()); +} + +#[test] +fn can_round_trip_cert_status_req_for_other() { + let bytes = [ + 0, 5, 2, // !OCSP + 1, 2, 3, 4, + ]; + + let csr = CertificateStatusRequest::read(&mut Reader::init(&bytes)).unwrap(); + println!("{csr:?}"); + assert_eq!(csr.get_encoding(), bytes.to_vec()); +} + +#[test] +fn can_print_all_client_extensions() { + println!("client hello {:?}", sample_client_hello_payload()); +} + +#[test] +fn can_clone_all_client_extensions() { + let exts = sample_client_hello_payload().extensions; + let exts2 = exts.clone(); + println!("{exts:?}, {exts2:?}"); +} + +#[test] +fn client_extensions_basics() { + let src = ClientExtensions { + early_data_request: Some(()), + ..Default::default() + }; + let mut target = ClientExtensions::default(); + + assert_eq!(src.collect_used(), vec![ExtensionType::EarlyData]); + assert_eq!(target.collect_used(), vec![]); + + target.clone_one(&src, ExtensionType::EarlyData); + assert_eq!(target.collect_used(), vec![ExtensionType::EarlyData]); +} + +#[test] +fn client_extensions_empty() { + // both sides of empty-encoding branch + assert_eq!(ClientExtensions::default().get_encoding(), Vec::::new()); + assert_eq!( + ClientExtensions::read_bytes(&[]) + .unwrap() + .collect_used(), + vec![] + ); + + let early_data = b"\x00\x04\x00\x2a\x00\x00"; + assert_eq!( + ClientExtensions { + early_data_request: Some(()), + ..Default::default() + } + .get_encoding(), + early_data + ); + assert_eq!( + ClientExtensions::read_bytes(early_data) + .unwrap() + .collect_used(), + vec![ExtensionType::EarlyData] + ); +} + +#[test] +fn client_extensions_decode_checks_duplicates() { + // base + ClientExtensions::read_bytes(b"\x00\x04\x00\x2a\x00\x00").unwrap(); + + // duplicate known + assert_eq!( + ClientExtensions::read_bytes(b"\x00\x08\x00\x2a\x00\x00\x00\x2a\x00\x00").unwrap_err(), + InvalidMessage::DuplicateExtension(0x002a) + ); + + // duplicate unknown + assert_eq!( + ClientExtensions::read_bytes(b"\x00\x08\xff\xff\x00\x00\xff\xff\x00\x00").unwrap_err(), + InvalidMessage::DuplicateExtension(0xffff) + ); +} + +#[test] +fn client_extensions_ordering() { + // the important thing here is that PSK requests come last, + // ECH requests come second to last, and order of other extensions + // do vary. + + let psk_offer = PresharedKeyOffer { + identities: vec![], + binders: vec![], + }; + + let psk_and_ech = ClientExtensions { + early_data_request: Some(()), + extended_master_secret_request: Some(()), + preshared_key_offer: Some(psk_offer.clone()), + encrypted_client_hello: Some(EncryptedClientHello::Inner), + ..Default::default() + }; + + let psk_and_ech_with_contiguous = ClientExtensions { + contiguous_extensions: vec![ExtensionType::ExtendedMasterSecret], + ..psk_and_ech.clone() + }; + + let ech = ClientExtensions { + early_data_request: Some(()), + extended_master_secret_request: Some(()), + encrypted_client_hello: Some(EncryptedClientHello::Inner), + ..Default::default() + }; + + let psk = ClientExtensions { + early_data_request: Some(()), + extended_master_secret_request: Some(()), + preshared_key_offer: Some(psk_offer), + ..Default::default() + }; + + let neither = ClientExtensions { + early_data_request: Some(()), + extended_master_secret_request: Some(()), + ..Default::default() + }; + + fn encoding_with_order(order_seed: u16, exts: &ClientExtensions<'_>) -> Vec { + let mut e = exts.clone(); + e.order_seed = order_seed; + e.get_encoding() + } + + assert_ne!( + encoding_with_order(0, &psk_and_ech), + encoding_with_order(1, &psk_and_ech) + ); + assert_eq!( + encoding_with_order(0, &psk_and_ech_with_contiguous), + encoding_with_order(1, &psk_and_ech_with_contiguous) + ); + assert_ne!(encoding_with_order(0, &ech), encoding_with_order(1, &ech)); + assert_ne!(encoding_with_order(0, &psk), encoding_with_order(1, &psk)); + assert_ne!( + encoding_with_order(0, &neither), + encoding_with_order(1, &neither) + ); + + // check order invariants hold for all seeds + for seed in 0..=0xffff { + // must end with ECH and then PSK + assert!(encoding_with_order(seed, &psk_and_ech).ends_with( + b"\xfe\x0d\x00\x01\x01\ + \x00\x29\x00\x04\x00\x00\x00\x00" + )); + + // must end with EMS, then ECH and then PSK + assert!( + encoding_with_order(seed, &psk_and_ech_with_contiguous).ends_with( + b"\x00\x17\x00\x00\ + \xfe\x0d\x00\x01\x01\ + \x00\x29\x00\x04\x00\x00\x00\x00" + ) + ); + + // just PSK + assert!(encoding_with_order(seed, &psk).ends_with(b"\x00\x29\x00\x04\x00\x00\x00\x00")); + + // just ECH + assert!(encoding_with_order(seed, &ech).ends_with(b"\xfe\x0d\x00\x01\x01")); + } +} + +#[test] +fn test_truncated_psk_offer() { + let ext = PresharedKeyOffer { + identities: vec![PresharedKeyIdentity::new(vec![3, 4, 5], 123456)], + binders: vec![PresharedKeyBinder::from(vec![1, 2, 3])], + }; + + let mut enc = ext.get_encoding(); + println!("testing {ext:?} enc {enc:?}"); + for l in 0..enc.len() { + if l == 9 { + continue; + } + put_u16(l as u16, &mut enc); + let rc = PresharedKeyOffer::read_bytes(&enc); + assert!(rc.is_err()); + } +} + +#[test] +fn test_truncated_client_hello_is_detected() { + let ch = sample_client_hello_payload(); + let enc = ch.get_encoding(); + println!("testing {ch:?} enc {enc:?}"); + + for l in 0..enc.len() { + println!("len {:?} enc {:?}", l, &enc[..l]); + if l == 41 { + continue; // where extensions are empty + } + assert!(ClientHelloPayload::read_bytes(&enc[..l]).is_err()); + } +} + +#[test] +fn test_truncated_client_extension_is_detected() { + let chp = sample_client_hello_payload(); + + let enc = chp.extensions.get_encoding(); + println!("testing enc {enc:?}"); + + // "outer" truncation, i.e., where the extension-level length is longer than + // the input + for l in 1..enc.len() { + assert!(ClientExtensions::read_bytes(&enc[..l]).is_err()); + } +} + +#[test] +fn test_truncated_hello_retry_extension_is_detected() { + let hrr = sample_hello_retry_request(); + + let mut enc = hrr.extensions.get_encoding(); + println!("testing enc {enc:?}"); + + // "outer" truncation, i.e., where the extension-level length is longer than + // the input + for l in 0..enc.len() { + assert!(HelloRetryRequestExtensions::read_bytes(&enc[..l]).is_err()); + } + + // "inner" truncation, where the extension-level length agrees with the input + // length, but isn't long enough for the type of extension + for l in 0..(enc.len() - 4) { + put_u16(l as u16, &mut enc); + println!(" encoding {enc:?} len {l:?}"); + assert!(HelloRetryRequestExtensions::read_bytes(&enc).is_err()); + } +} + +#[test] +fn test_truncated_server_extension_is_detected() { + let shp = sample_server_hello_payload(); + + let mut enc = shp.extensions.get_encoding(); + println!("testing enc {enc:?}"); + + // "outer" truncation, i.e., where the extension-level length is longer than + // the input + for l in 0..enc.len() { + assert!(ServerExtensions::read_bytes(&enc[..l]).is_err()); + } + + // "inner" truncation, where the extension-level length agrees with the input + // length, but isn't long enough for the type of extension + for l in 0..(enc.len() - 4) { + put_u16(l as u16, &mut enc[..2]); + println!(" encoding {enc:?} len {l:?}"); + assert!(ServerExtensions::read_bytes(&enc).is_err()); + } +} + +#[test] +fn can_print_all_server_extensions() { + println!("server hello {:?}", sample_server_hello_payload()); +} + +#[test] +fn can_clone_all_server_extensions() { + let exts = sample_server_hello_payload().extensions; + let exts2 = exts.clone(); + println!("{exts:?}, {exts2:?}"); +} + +#[test] +fn can_round_trip_all_tls12_handshake_payloads() { + for hm in all_tls12_handshake_payloads().iter() { + println!("{:?}", hm.0.handshake_type()); + let bytes = hm.get_encoding(); + let mut rd = Reader::init(&bytes); + let other = HandshakeMessagePayload::read(&mut rd).unwrap(); + assert!(!rd.any_left()); + assert_eq!(hm.get_encoding(), other.get_encoding()); + + println!("{hm:?}"); + println!("{other:?}"); + } +} + +#[test] +fn can_into_owned_all_tls12_handshake_payloads() { + for hm in all_tls12_handshake_payloads().drain(..) { + let enc = hm.get_encoding(); + let debug = format!("{hm:?}"); + let other = hm.into_owned(); + assert_eq!(enc, other.get_encoding()); + assert_eq!(debug, format!("{other:?}")); + } +} + +#[test] +fn can_detect_truncation_of_all_tls12_handshake_payloads() { + for hm in all_tls12_handshake_payloads().iter() { + let mut enc = hm.get_encoding(); + println!("test {hm:?} enc {enc:?}"); + + // outer truncation + for l in 0..enc.len() { + assert!(HandshakeMessagePayload::read_bytes(&enc[..l]).is_err()) + } + + // inner truncation + for l in 0..enc.len() - 4 { + put_u24(l as u32, &mut enc[1..]); + println!(" check len {l:?} enc {enc:?}"); + + match (hm.0.handshake_type(), l) { + (HandshakeType::ClientHello, 41) + | (HandshakeType::ServerHello, 38) + | (HandshakeType::ServerKeyExchange, _) + | (HandshakeType::ClientKeyExchange, _) + | (HandshakeType::Finished, _) + | (HandshakeType::Unknown(_), _) => continue, + _ => {} + }; + + assert!( + HandshakeMessagePayload::read_version( + &mut Reader::init(&enc), + ProtocolVersion::TLSv1_2 + ) + .is_err() + ); + assert!(HandshakeMessagePayload::read_bytes(&enc).is_err()); + } + } +} + +#[test] +fn can_round_trip_all_tls13_handshake_payloads() { + for hm in all_tls13_handshake_payloads().iter() { + println!("{:?}", hm.0.handshake_type()); + let bytes = hm.get_encoding(); + let mut rd = Reader::init(&bytes); + + let other = + HandshakeMessagePayload::read_version(&mut rd, ProtocolVersion::TLSv1_3).unwrap(); + assert!(!rd.any_left()); + assert_eq!(hm.get_encoding(), other.get_encoding()); + + println!("{hm:?}"); + println!("{other:?}"); + } +} + +#[test] +fn can_into_owned_all_tls13_handshake_payloads() { + for hm in all_tls13_handshake_payloads().drain(..) { + let enc = hm.get_encoding(); + let debug = format!("{hm:?}"); + let other = hm.into_owned(); + assert_eq!(enc, other.get_encoding()); + assert_eq!(debug, format!("{other:?}")); + } +} + +#[test] +fn can_detect_truncation_of_all_tls13_handshake_payloads() { + for hm in all_tls13_handshake_payloads().iter() { + let mut enc = hm.get_encoding(); + println!("test {hm:?} enc {enc:?}"); + + // outer truncation + for l in 0..enc.len() { + assert!(HandshakeMessagePayload::read_bytes(&enc[..l]).is_err()) + } + + // inner truncation + for l in 0..enc.len() - 4 { + put_u24(l as u32, &mut enc[1..]); + println!(" check len {l:?} enc {enc:?}"); + + match (hm.0.handshake_type(), l) { + (HandshakeType::ClientHello, 41) + | (HandshakeType::ServerHello, 38) + | (HandshakeType::ServerKeyExchange, _) + | (HandshakeType::ClientKeyExchange, _) + | (HandshakeType::Finished, _) + | (HandshakeType::Unknown(_), _) => continue, + _ => {} + }; + + assert!( + HandshakeMessagePayload::read_version( + &mut Reader::init(&enc), + ProtocolVersion::TLSv1_3 + ) + .is_err() + ); + } + } +} + +fn put_u24(u: u32, b: &mut [u8]) { + b[0] = (u >> 16) as u8; + b[1] = (u >> 8) as u8; + b[2] = u as u8; +} + +#[test] +fn cannot_read_message_hash_from_network() { + let mh = HandshakeMessagePayload(HandshakePayload::MessageHash(Payload::new(vec![1, 2, 3]))); + println!("mh {mh:?}"); + let enc = mh.get_encoding(); + assert!(HandshakeMessagePayload::read_bytes(&enc).is_err()); +} + +#[test] +fn cannot_decode_huge_certificate() { + let mut buf = [0u8; 65 * 1024]; + // exactly 64KB decodes fine + buf[0] = 0x0b; + buf[1] = 0x01; + buf[2] = 0x00; + buf[3] = 0x03; + buf[4] = 0x01; + buf[5] = 0x00; + buf[6] = 0x00; + buf[7] = 0x00; + buf[8] = 0xff; + buf[9] = 0xfd; + HandshakeMessagePayload::read_bytes(&buf[..0x10000 + 7]).unwrap(); + + // however 64KB + 1 byte does not + buf[1] = 0x01; + buf[2] = 0x00; + buf[3] = 0x04; + buf[4] = 0x01; + buf[5] = 0x00; + buf[6] = 0x01; + assert_eq!( + HandshakeMessagePayload::read_bytes(&buf[..0x10001 + 7]).unwrap_err(), + InvalidMessage::CertificatePayloadTooLarge + ); +} + +#[test] +fn can_decode_server_hello_from_api_devicecheck_apple_com() { + let data = include_bytes!("../testdata/hello-api.devicecheck.apple.com.bin"); + let mut r = Reader::init(data); + let hm = HandshakeMessagePayload::read(&mut r).unwrap(); + println!("msg: {hm:?}"); +} + +#[test] +fn wrapped_dn_encoding() { + let subject = b"subject"; + let dn = DistinguishedName::in_sequence(&subject[..]); + const DER_SEQUENCE_TAG: u8 = 0x30; + let expected_prefix = vec![DER_SEQUENCE_TAG, subject.len() as u8]; + assert_eq!(dn.as_ref(), [expected_prefix, subject.to_vec()].concat()); +} + +fn sample_hello_retry_request() -> HelloRetryRequest { + HelloRetryRequest { + legacy_version: ProtocolVersion::TLSv1_2, + session_id: SessionId::empty(), + cipher_suite: CipherSuite::TLS_NULL_WITH_NULL_NULL, + extensions: HelloRetryRequestExtensions { + key_share: Some(NamedGroup::X25519), + cookie: Some(PayloadU16::new(vec![0])), + supported_versions: Some(ProtocolVersion::TLSv1_2), + encrypted_client_hello: Some(Payload::new(vec![1, 2, 3])), + order: None, + }, + } +} + +fn sample_client_hello_payload() -> ClientHelloPayload { + ClientHelloPayload { + client_version: ProtocolVersion::TLSv1_2, + random: Random::from([0; 32]), + session_id: SessionId::empty(), + cipher_suites: vec![CipherSuite::TLS_NULL_WITH_NULL_NULL], + compression_methods: vec![Compression::Null], + extensions: Box::new(ClientExtensions { + server_name: Some(ServerNamePayload::from( + &DnsName::try_from("hello").unwrap(), + )), + cookie: Some(PayloadU16::new(vec![1, 2, 3])), + signature_schemes: Some(vec![SignatureScheme::ECDSA_NISTP256_SHA256]), + session_ticket: Some(ClientSessionTicket::Request), + ec_point_formats: Some(SupportedEcPointFormats::default()), + named_groups: Some(vec![NamedGroup::X25519]), + protocols: Some(vec![ProtocolName::from(vec![0])]), + supported_versions: Some(SupportedProtocolVersions { + tls13: true, + ..Default::default() + }), + key_shares: Some(vec![KeyShareEntry::new(NamedGroup::X25519, &[1, 2, 3][..])]), + preshared_key_modes: Some(PskKeyExchangeModes { + psk_dhe: true, + psk: false, + }), + preshared_key_offer: Some(PresharedKeyOffer { + identities: vec![ + PresharedKeyIdentity::new(vec![3, 4, 5], 123456), + PresharedKeyIdentity::new(vec![6, 7, 8], 7891011), + ], + binders: vec![ + PresharedKeyBinder::from(vec![1, 2, 3]), + PresharedKeyBinder::from(vec![3, 4, 5]), + ], + }), + extended_master_secret_request: Some(()), + certificate_status_request: Some(CertificateStatusRequest::build_ocsp()), + server_certificate_types: Some(vec![CertificateType::RawPublicKey]), + client_certificate_types: Some(vec![CertificateType::RawPublicKey]), + transport_parameters: Some(Payload::new(vec![1, 2, 3])), + early_data_request: Some(()), + certificate_compression_algorithms: Some(vec![CertificateCompressionAlgorithm::Brotli]), + encrypted_client_hello: Some(EncryptedClientHello::Inner), + encrypted_client_hello_outer: Some(vec![ExtensionType::SCT]), + ..Default::default() + }), + } +} + +fn sample_server_hello_payload() -> ServerHelloPayload { + ServerHelloPayload { + legacy_version: ProtocolVersion::TLSv1_2, + random: Random::from([0; 32]), + session_id: SessionId::empty(), + cipher_suite: CipherSuite::TLS_NULL_WITH_NULL_NULL, + compression_method: Compression::Null, + extensions: Box::new(ServerExtensions { + ec_point_formats: Some(SupportedEcPointFormats::default()), + server_name_ack: Some(()), + session_ticket_ack: Some(()), + renegotiation_info: Some(PayloadU8::new(vec![0])), + selected_protocol: Some(SingleProtocolName::new(ProtocolName::from(vec![0]))), + key_share: Some(KeyShareEntry::new(NamedGroup::X25519, &[1, 2, 3][..])), + preshared_key: Some(3), + early_data_ack: Some(()), + encrypted_client_hello_ack: Some(ServerEncryptedClientHello { + retry_configs: vec![], + }), + extended_master_secret_ack: Some(()), + certificate_status_request_ack: Some(()), + selected_version: Some(ProtocolVersion::TLSv1_2), + transport_parameters: Some(Payload::new(vec![1, 2, 3])), + transport_parameters_draft: None, + client_certificate_type: Some(CertificateType::RawPublicKey), + server_certificate_type: Some(CertificateType::RawPublicKey), + unknown_extensions: Default::default(), + }), + } +} + +fn all_tls12_handshake_payloads() -> Vec> { + vec![ + HandshakeMessagePayload(HandshakePayload::HelloRequest), + HandshakeMessagePayload(HandshakePayload::ClientHello(sample_client_hello_payload())), + HandshakeMessagePayload(HandshakePayload::ServerHello(sample_server_hello_payload())), + HandshakeMessagePayload(HandshakePayload::HelloRetryRequest( + sample_hello_retry_request(), + )), + HandshakeMessagePayload(HandshakePayload::Certificate(CertificateChain(vec![ + CertificateDer::from(vec![1, 2, 3]), + ]))), + HandshakeMessagePayload(HandshakePayload::ServerKeyExchange( + sample_ecdhe_server_key_exchange_payload(), + )), + HandshakeMessagePayload(HandshakePayload::ServerKeyExchange( + sample_dhe_server_key_exchange_payload(), + )), + HandshakeMessagePayload(HandshakePayload::ServerKeyExchange( + sample_unknown_server_key_exchange_payload(), + )), + HandshakeMessagePayload(HandshakePayload::CertificateRequest( + sample_certificate_request_payload(), + )), + HandshakeMessagePayload(HandshakePayload::ServerHelloDone), + HandshakeMessagePayload(HandshakePayload::ClientKeyExchange(Payload::Borrowed(&[ + 1, 2, 3, + ]))), + HandshakeMessagePayload(HandshakePayload::NewSessionTicket( + sample_new_session_ticket_payload(), + )), + HandshakeMessagePayload(HandshakePayload::EncryptedExtensions( + sample_encrypted_extensions(), + )), + HandshakeMessagePayload(HandshakePayload::KeyUpdate( + KeyUpdateRequest::UpdateRequested, + )), + HandshakeMessagePayload(HandshakePayload::KeyUpdate( + KeyUpdateRequest::UpdateNotRequested, + )), + HandshakeMessagePayload(HandshakePayload::Finished(Payload::Borrowed(&[1, 2, 3]))), + HandshakeMessagePayload(HandshakePayload::CertificateStatus( + sample_certificate_status(), + )), + HandshakeMessagePayload(HandshakePayload::Unknown(( + HandshakeType::Unknown(99), + Payload::Borrowed(&[1, 2, 3]), + ))), + ] +} + +fn all_tls13_handshake_payloads() -> Vec> { + vec![ + HandshakeMessagePayload(HandshakePayload::HelloRequest), + HandshakeMessagePayload(HandshakePayload::ClientHello(sample_client_hello_payload())), + HandshakeMessagePayload(HandshakePayload::ServerHello(sample_server_hello_payload())), + HandshakeMessagePayload(HandshakePayload::HelloRetryRequest( + sample_hello_retry_request(), + )), + HandshakeMessagePayload(HandshakePayload::CertificateTls13( + sample_certificate_payload_tls13(), + )), + HandshakeMessagePayload(HandshakePayload::CompressedCertificate( + sample_compressed_certificate(), + )), + HandshakeMessagePayload(HandshakePayload::ServerKeyExchange( + sample_ecdhe_server_key_exchange_payload(), + )), + HandshakeMessagePayload(HandshakePayload::ServerKeyExchange( + sample_dhe_server_key_exchange_payload(), + )), + HandshakeMessagePayload(HandshakePayload::ServerKeyExchange( + sample_unknown_server_key_exchange_payload(), + )), + HandshakeMessagePayload(HandshakePayload::CertificateRequestTls13( + sample_certificate_request_payload_tls13(), + )), + HandshakeMessagePayload(HandshakePayload::CertificateVerify( + DigitallySignedStruct::new(SignatureScheme::ECDSA_NISTP256_SHA256, vec![1, 2, 3]), + )), + HandshakeMessagePayload(HandshakePayload::ServerHelloDone), + HandshakeMessagePayload(HandshakePayload::ClientKeyExchange(Payload::Borrowed(&[ + 1, 2, 3, + ]))), + HandshakeMessagePayload(HandshakePayload::NewSessionTicketTls13( + sample_new_session_ticket_payload_tls13(), + )), + HandshakeMessagePayload(HandshakePayload::EncryptedExtensions( + sample_encrypted_extensions(), + )), + HandshakeMessagePayload(HandshakePayload::KeyUpdate( + KeyUpdateRequest::UpdateRequested, + )), + HandshakeMessagePayload(HandshakePayload::KeyUpdate( + KeyUpdateRequest::UpdateNotRequested, + )), + HandshakeMessagePayload(HandshakePayload::Finished(Payload::Borrowed(&[1, 2, 3]))), + HandshakeMessagePayload(HandshakePayload::CertificateStatus( + sample_certificate_status(), + )), + HandshakeMessagePayload(HandshakePayload::Unknown(( + HandshakeType::Unknown(99), + Payload::Borrowed(&[1, 2, 3]), + ))), + ] +} + +fn sample_certificate_payload_tls13() -> CertificatePayloadTls13<'static> { + CertificatePayloadTls13 { + context: PayloadU8::new(vec![1, 2, 3]), + entries: vec![CertificateEntry { + cert: CertificateDer::from(vec![3, 4, 5]), + extensions: CertificateExtensions { + status: Some(CertificateStatus { + ocsp_response: PayloadU24(Payload::new(vec![1, 2, 3])), + }), + }, + }], + } +} + +fn sample_compressed_certificate() -> CompressedCertificatePayload<'static> { + CompressedCertificatePayload { + alg: CertificateCompressionAlgorithm::Brotli, + uncompressed_len: 123, + compressed: PayloadU24(Payload::new(vec![1, 2, 3])), + } +} + +fn sample_ecdhe_server_key_exchange_payload() -> ServerKeyExchangePayload { + ServerKeyExchangePayload::Known(ServerKeyExchange { + params: ServerKeyExchangeParams::Ecdh(ServerEcdhParams { + curve_params: EcParameters { + curve_type: ECCurveType::NamedCurve, + named_group: NamedGroup::X25519, + }, + public: PayloadU8::new(vec![1, 2, 3]), + }), + dss: DigitallySignedStruct::new(SignatureScheme::RSA_PSS_SHA256, vec![1, 2, 3]), + }) +} + +fn sample_dhe_server_key_exchange_payload() -> ServerKeyExchangePayload { + ServerKeyExchangePayload::Known(ServerKeyExchange { + params: ServerKeyExchangeParams::Dh(ServerDhParams { + dh_p: PayloadU16::new(vec![1, 2, 3]), + dh_g: PayloadU16::new(vec![2]), + dh_Ys: PayloadU16::new(vec![1, 2]), + }), + dss: DigitallySignedStruct::new(SignatureScheme::RSA_PSS_SHA256, vec![1, 2, 3]), + }) +} + +fn sample_unknown_server_key_exchange_payload() -> ServerKeyExchangePayload { + ServerKeyExchangePayload::Unknown(Payload::Borrowed(&[1, 2, 3])) +} + +fn sample_certificate_request_payload() -> CertificateRequestPayload { + CertificateRequestPayload { + certtypes: vec![ClientCertificateType::RSASign], + sigschemes: vec![SignatureScheme::ECDSA_NISTP256_SHA256], + canames: vec![DistinguishedName::from(vec![1, 2, 3])], + } +} + +fn sample_certificate_request_payload_tls13() -> CertificateRequestPayloadTls13 { + CertificateRequestPayloadTls13 { + context: PayloadU8::new(vec![1, 2, 3]), + extensions: CertificateRequestExtensions { + signature_algorithms: Some(vec![SignatureScheme::ECDSA_NISTP256_SHA256]), + authority_names: Some(vec![DistinguishedName::from(vec![1, 2, 3])]), + certificate_compression_algorithms: Some(vec![CertificateCompressionAlgorithm::Zlib]), + }, + } +} + +fn sample_new_session_ticket_payload() -> NewSessionTicketPayload { + NewSessionTicketPayload { + lifetime_hint: 1234, + ticket: Arc::new(PayloadU16::new(vec![1, 2, 3])), + } +} + +fn sample_new_session_ticket_payload_tls13() -> NewSessionTicketPayloadTls13 { + NewSessionTicketPayloadTls13 { + lifetime: 123, + age_add: 1234, + nonce: PayloadU8::new(vec![1, 2, 3]), + ticket: Arc::new(PayloadU16::new(vec![4, 5, 6])), + extensions: NewSessionTicketExtensions { + max_early_data_size: Some(1234), + }, + } +} + +fn sample_encrypted_extensions() -> Box> { + sample_server_hello_payload().extensions +} + +fn sample_certificate_status() -> CertificateStatus<'static> { + CertificateStatus { + ocsp_response: PayloadU24(Payload::new(vec![1, 2, 3])), + } +} diff --git a/http/vendor/rustls/src/msgs/macros.rs b/http/vendor/rustls/src/msgs/macros.rs new file mode 100644 index 0000000..d6a1891 --- /dev/null +++ b/http/vendor/rustls/src/msgs/macros.rs @@ -0,0 +1,329 @@ +/// A macro which defines an enum type. +macro_rules! enum_builder { + ( + $(#[doc = $comment:literal])* + #[repr($uint:ty)] + $(#[$metas:meta])* + $enum_vis:vis enum $enum_name:ident + { + $( + $(#[$enum_metas:meta])* + $enum_var:ident => $enum_val:literal),* $(,)? + $( !Debug: + $( + $(#[$enum_metas_nd:meta])* + $enum_var_nd:ident => $enum_val_nd:literal + ),* $(,)? + )? + } + ) => { + $(#[doc = $comment])* + $(#[$metas])* + #[non_exhaustive] + #[derive(PartialEq, Eq, Clone, Copy)] + $enum_vis enum $enum_name { + $( + $(#[$enum_metas])* + $enum_var + ),* + $( + , + $( + $(#[$enum_metas_nd])* + $enum_var_nd + ),* + )? + ,Unknown($uint) + } + + impl $enum_name { + // NOTE(allow) generated irrespective if there are callers + #[allow(dead_code)] + $enum_vis fn to_array(self) -> [u8; core::mem::size_of::<$uint>()] { + <$uint>::from(self).to_be_bytes() + } + + // NOTE(allow) generated irrespective if there are callers + #[allow(dead_code)] + $enum_vis fn as_str(&self) -> Option<&'static str> { + match self { + $( $enum_name::$enum_var => Some(stringify!($enum_var))),* + $(, $( $enum_name::$enum_var_nd => Some(stringify!($enum_var_nd))),* )? + ,$enum_name::Unknown(_) => None, + } + } + } + + impl Codec<'_> for $enum_name { + // NOTE(allow) fully qualified Vec is only needed in no-std mode + #[allow(unused_qualifications)] + fn encode(&self, bytes: &mut alloc::vec::Vec) { + <$uint>::from(*self).encode(bytes); + } + + fn read(r: &mut Reader<'_>) -> Result { + match <$uint>::read(r) { + Ok(x) => Ok($enum_name::from(x)), + Err(_) => Err(crate::error::InvalidMessage::MissingData(stringify!($enum_name))), + } + } + } + + impl From<$uint> for $enum_name { + fn from(x: $uint) -> Self { + match x { + $($enum_val => $enum_name::$enum_var),* + $(, $($enum_val_nd => $enum_name::$enum_var_nd),* )? + , x => $enum_name::Unknown(x), + } + } + } + + impl From<$enum_name> for $uint { + fn from(value: $enum_name) -> Self { + match value { + $( $enum_name::$enum_var => $enum_val),* + $(, $( $enum_name::$enum_var_nd => $enum_val_nd),* )? + ,$enum_name::Unknown(x) => x + } + } + } + + impl core::fmt::Debug for $enum_name { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + match self { + $( $enum_name::$enum_var => f.write_str(stringify!($enum_var)), )* + _ => write!(f, "{}(0x{:x?})", stringify!($enum_name), <$uint>::from(*self)), + } + } + } + }; +} + +/// A macro which defines a structure containing TLS extensions +/// +/// The contents are defined by two blocks, which are merged to +/// give the struct's items. The second block is optional. +/// +/// The first block defines the items read-into by decoding, +/// and used for encoding. +/// +/// The type of each item in the first block _must_ be an `Option`. +/// This records the presence of that extension. +/// +/// Each item in the first block is prefixed with a match arm, +/// which must match an `ExtensionType` variant. This maps +/// the item to its extension type. +/// +/// Items in the second block are not encoded or decoded-to. +/// They therefore must have a reasonable `Default` value. +/// +/// All items must have a `Default`, `Debug` and `Clone`. +macro_rules! extension_struct { + ( + $(#[doc = $comment:literal])* + $struct_vis:vis struct $struct_name:ident$(<$struct_lt:lifetime>)* + { + $( + $(#[$item_attr:meta])* + $item_id:path => $item_vis:vis $item_slot:ident : Option<$item_ty:ty>, + )+ + } $( + { + $( + $(#[$meta_attr:meta])* + $meta_vis:vis $meta_slot:ident : $meta_ty:ty, + )+ + })* + ) => { + $(#[doc = $comment])* + #[non_exhaustive] + #[derive(Clone, Default)] + $struct_vis struct $struct_name$(<$struct_lt>)* { + $( + $(#[$item_attr])* + $item_vis $item_slot: Option<$item_ty>, + )+ + $($( + $(#[$meta_attr])* + $meta_vis $meta_slot: $meta_ty, + )+)* + } + + impl<'a> $struct_name$(<$struct_lt>)* { + /// Reads one extension typ, length and body from `r`. + /// + /// Unhandled extensions (according to `read_extension_body()` are inserted into `unknown_extensions`) + fn read_one( + &mut self, + r: &mut Reader<'a>, + mut unknown: impl FnMut(ExtensionType) -> Result<(), InvalidMessage>, + ) -> Result { + let typ = ExtensionType::read(r)?; + let len = usize::from(u16::read(r)?); + let mut ext_body = r.sub(len)?; + match self.read_extension_body(typ, &mut ext_body)? { + true => ext_body.expect_empty(stringify!($struct_name))?, + false => unknown(typ)?, + + }; + Ok(typ) + } + + /// Reads one extension body for an extension named by `typ`. + /// + /// Returns `true` if handled, `false` otherwise. + /// + /// `r` is fully consumed if `typ` is unhandled. + fn read_extension_body( + &mut self, + typ: ExtensionType, + r: &mut Reader<'a>, + ) -> Result { + match typ { + $( + $item_id => Self::read_once(r, $item_id, &mut self.$item_slot)?, + )* + + // read and ignore unhandled extensions + _ => { + r.rest(); + return Ok(false); + } + } + + Ok(true) + } + + /// Decode `r` as `T` into `out`, only if `out` is `None`. + fn read_once(r: &mut Reader<'a>, id: ExtensionType, out: &mut Option) -> Result<(), InvalidMessage> + where T: Codec<'a>, + { + if let Some(_) = out { + return Err(InvalidMessage::DuplicateExtension(u16::from(id))); + } + + *out = Some(T::read(r)?); + Ok(()) + } + + /// Encode one extension body for `typ` into `output`. + /// + /// Adds nothing to `output` if `typ` is absent from this + /// struct, either because it is `None` or unhandled by + /// this struct. + fn encode_one( + &self, + typ: ExtensionType, + output: &mut Vec, + ) { + match typ { + $( + $item_id => if let Some(item) = &self.$item_slot { + typ.encode(output); + item.encode(LengthPrefixedBuffer::new(ListLength::U16, output).buf); + }, + + )* + _ => {}, + } + } + + /// Return a list of extensions whose items are `Some` + #[allow(dead_code)] + pub(crate) fn collect_used(&self) -> Vec { + let mut r = Vec::with_capacity(Self::ALL_EXTENSIONS.len()); + + $( + if let Some(_) = &self.$item_slot { + r.push($item_id); + } + )* + + r + } + + /// Clone the value of the extension identified by `typ` from `source` to `self`. + /// + /// Does nothing if `typ` is not an extension handled by this object. + #[allow(dead_code)] + pub(crate) fn clone_one( + &mut self, + source: &Self, + typ: ExtensionType, + ) { + match typ { + $( + $item_id => self.$item_slot = source.$item_slot.clone(), + )* + _ => {}, + } + } + + /// Remove the extension identified by `typ` from `self`. + #[allow(dead_code)] + pub(crate) fn clear(&mut self, typ: ExtensionType) { + match typ { + $( + $item_id => self.$item_slot = None, + )* + _ => {}, + } + } + + /// Return true if all present extensions are named in `allowed` + #[allow(dead_code)] + pub(crate) fn only_contains(&self, allowed: &[ExtensionType]) -> bool { + $( + if let Some(_) = &self.$item_slot { + if !allowed.contains(&$item_id) { + return false; + } + } + )* + + true + } + + /// Return true if any extension named in `exts` is present. + #[allow(dead_code)] + pub(crate) fn contains_any(&self, exts: &[ExtensionType]) -> bool { + for e in exts { + if self.contains(*e) { + return true; + } + } + false + } + + fn contains(&self, e: ExtensionType) -> bool { + match e { + $( + + $item_id => self.$item_slot.is_some(), + )* + _ => false, + } + } + + /// Every `ExtensionType` this structure may encode/decode. + const ALL_EXTENSIONS: &'static [ExtensionType] = &[ + $($item_id,)* + ]; + } + + impl<'a> core::fmt::Debug for $struct_name$(<$struct_lt>)* { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut ds = f.debug_struct(stringify!($struct_name)); + $( + if let Some(ext) = &self.$item_slot { + ds.field(stringify!($item_slot), ext); + } + )* + $($( + ds.field(stringify!($meta_slot), &self.$meta_slot); + )+)* + ds.finish_non_exhaustive() + } + } + } +} diff --git a/http/vendor/rustls/src/msgs/message/inbound.rs b/http/vendor/rustls/src/msgs/message/inbound.rs new file mode 100644 index 0000000..f8b2181 --- /dev/null +++ b/http/vendor/rustls/src/msgs/message/inbound.rs @@ -0,0 +1,161 @@ +use core::ops::{Deref, DerefMut, Range}; + +use crate::enums::{ContentType, ProtocolVersion}; +use crate::error::{Error, PeerMisbehaved}; +use crate::msgs::fragmenter::MAX_FRAGMENT_LEN; + +/// A TLS frame, named TLSPlaintext in the standard. +/// +/// This inbound type borrows its encrypted payload from a buffer elsewhere. +/// It is used for joining and is consumed by decryption. +pub struct InboundOpaqueMessage<'a> { + pub typ: ContentType, + pub version: ProtocolVersion, + pub payload: BorrowedPayload<'a>, +} + +impl<'a> InboundOpaqueMessage<'a> { + /// Construct a new `InboundOpaqueMessage` from constituent fields. + /// + /// `payload` is borrowed. + pub fn new(typ: ContentType, version: ProtocolVersion, payload: &'a mut [u8]) -> Self { + Self { + typ, + version, + payload: BorrowedPayload(payload), + } + } + + /// Force conversion into a plaintext message. + /// + /// This should only be used for messages that are known to be in plaintext. Otherwise, the + /// `InboundOpaqueMessage` should be decrypted into a `PlainMessage` using a `MessageDecrypter`. + pub fn into_plain_message(self) -> InboundPlainMessage<'a> { + InboundPlainMessage { + typ: self.typ, + version: self.version, + payload: self.payload.into_inner(), + } + } + + /// Force conversion into a plaintext message. + /// + /// `range` restricts the resulting message: this function panics if it is out of range for + /// the underlying message payload. + /// + /// This should only be used for messages that are known to be in plaintext. Otherwise, the + /// `InboundOpaqueMessage` should be decrypted into a `PlainMessage` using a `MessageDecrypter`. + pub fn into_plain_message_range(self, range: Range) -> InboundPlainMessage<'a> { + InboundPlainMessage { + typ: self.typ, + version: self.version, + payload: &self.payload.into_inner()[range], + } + } + + /// For TLS1.3 (only), checks the length msg.payload is valid and removes the padding. + /// + /// Returns an error if the message (pre-unpadding) is too long, or the padding is invalid, + /// or the message (post-unpadding) is too long. + pub fn into_tls13_unpadded_message(mut self) -> Result, Error> { + let payload = &mut self.payload; + + if payload.len() > MAX_FRAGMENT_LEN + 1 { + return Err(Error::PeerSentOversizedRecord); + } + + self.typ = unpad_tls13_payload(payload); + if self.typ == ContentType::Unknown(0) { + return Err(PeerMisbehaved::IllegalTlsInnerPlaintext.into()); + } + + if payload.len() > MAX_FRAGMENT_LEN { + return Err(Error::PeerSentOversizedRecord); + } + + self.version = ProtocolVersion::TLSv1_3; + Ok(self.into_plain_message()) + } +} + +pub struct BorrowedPayload<'a>(&'a mut [u8]); + +impl Deref for BorrowedPayload<'_> { + type Target = [u8]; + + fn deref(&self) -> &Self::Target { + self.0 + } +} + +impl DerefMut for BorrowedPayload<'_> { + fn deref_mut(&mut self) -> &mut Self::Target { + self.0 + } +} + +impl<'a> BorrowedPayload<'a> { + pub fn truncate(&mut self, len: usize) { + if len >= self.len() { + return; + } + + self.0 = core::mem::take(&mut self.0) + .split_at_mut(len) + .0; + } + + pub(crate) fn into_inner(self) -> &'a mut [u8] { + self.0 + } + + pub(crate) fn pop(&mut self) -> Option { + if self.is_empty() { + return None; + } + + let len = self.len(); + let last = self[len - 1]; + self.truncate(len - 1); + Some(last) + } +} + +/// A TLS frame, named `TLSPlaintext` in the standard. +/// +/// This inbound type borrows its decrypted payload from the original buffer. +/// It results from decryption. +#[derive(Debug)] +pub struct InboundPlainMessage<'a> { + pub typ: ContentType, + pub version: ProtocolVersion, + pub payload: &'a [u8], +} + +impl InboundPlainMessage<'_> { + /// Returns true if the payload is a CCS message. + /// + /// We passthrough ChangeCipherSpec messages in the deframer without decrypting them. + /// Note: this is prior to the record layer, so is unencrypted. See + /// third paragraph of section 5 in RFC8446. + pub(crate) fn is_valid_ccs(&self) -> bool { + self.typ == ContentType::ChangeCipherSpec && self.payload == [0x01] + } +} + +/// Decode a TLS1.3 `TLSInnerPlaintext` encoding. +/// +/// `p` is a message payload, immediately post-decryption. This function +/// removes zero padding bytes, until a non-zero byte is encountered which is +/// the content type, which is returned. See RFC8446 s5.2. +/// +/// ContentType(0) is returned if the message payload is empty or all zeroes. +fn unpad_tls13_payload(p: &mut BorrowedPayload<'_>) -> ContentType { + loop { + match p.pop() { + Some(0) => {} + Some(content_type) => return ContentType::from(content_type), + None => return ContentType::Unknown(0), + } + } +} diff --git a/http/vendor/rustls/src/msgs/message/mod.rs b/http/vendor/rustls/src/msgs/message/mod.rs new file mode 100644 index 0000000..d5cecc9 --- /dev/null +++ b/http/vendor/rustls/src/msgs/message/mod.rs @@ -0,0 +1,262 @@ +use crate::enums::{AlertDescription, ContentType, HandshakeType, ProtocolVersion}; +use crate::error::InvalidMessage; +use crate::msgs::alert::AlertMessagePayload; +use crate::msgs::base::Payload; +use crate::msgs::ccs::ChangeCipherSpecPayload; +use crate::msgs::codec::{Codec, Reader}; +use crate::msgs::enums::{AlertLevel, KeyUpdateRequest}; +use crate::msgs::handshake::{HandshakeMessagePayload, HandshakePayload}; + +mod inbound; +pub use inbound::{BorrowedPayload, InboundOpaqueMessage, InboundPlainMessage}; + +mod outbound; +use alloc::vec::Vec; + +pub(crate) use outbound::read_opaque_message_header; +pub use outbound::{OutboundChunks, OutboundOpaqueMessage, OutboundPlainMessage, PrefixedPayload}; + +#[derive(Debug)] +pub enum MessagePayload<'a> { + Alert(AlertMessagePayload), + // one handshake message, parsed + Handshake { + parsed: HandshakeMessagePayload<'a>, + encoded: Payload<'a>, + }, + // (potentially) multiple handshake messages, unparsed + HandshakeFlight(Payload<'a>), + ChangeCipherSpec(ChangeCipherSpecPayload), + ApplicationData(Payload<'a>), +} + +impl<'a> MessagePayload<'a> { + pub fn encode(&self, bytes: &mut Vec) { + match self { + Self::Alert(x) => x.encode(bytes), + Self::Handshake { encoded, .. } => bytes.extend(encoded.bytes()), + Self::HandshakeFlight(x) => bytes.extend(x.bytes()), + Self::ChangeCipherSpec(x) => x.encode(bytes), + Self::ApplicationData(x) => x.encode(bytes), + } + } + + pub fn handshake(parsed: HandshakeMessagePayload<'a>) -> Self { + Self::Handshake { + encoded: Payload::new(parsed.get_encoding()), + parsed, + } + } + + pub fn new( + typ: ContentType, + vers: ProtocolVersion, + payload: &'a [u8], + ) -> Result { + let mut r = Reader::init(payload); + match typ { + ContentType::ApplicationData => Ok(Self::ApplicationData(Payload::Borrowed(payload))), + ContentType::Alert => AlertMessagePayload::read(&mut r).map(MessagePayload::Alert), + ContentType::Handshake => { + HandshakeMessagePayload::read_version(&mut r, vers).map(|parsed| Self::Handshake { + parsed, + encoded: Payload::Borrowed(payload), + }) + } + ContentType::ChangeCipherSpec => { + ChangeCipherSpecPayload::read(&mut r).map(MessagePayload::ChangeCipherSpec) + } + _ => Err(InvalidMessage::InvalidContentType), + } + } + + pub fn content_type(&self) -> ContentType { + match self { + Self::Alert(_) => ContentType::Alert, + Self::Handshake { .. } | Self::HandshakeFlight(_) => ContentType::Handshake, + Self::ChangeCipherSpec(_) => ContentType::ChangeCipherSpec, + Self::ApplicationData(_) => ContentType::ApplicationData, + } + } + + pub(crate) fn into_owned(self) -> MessagePayload<'static> { + use MessagePayload::*; + match self { + Alert(x) => Alert(x), + Handshake { parsed, encoded } => Handshake { + parsed: parsed.into_owned(), + encoded: encoded.into_owned(), + }, + HandshakeFlight(x) => HandshakeFlight(x.into_owned()), + ChangeCipherSpec(x) => ChangeCipherSpec(x), + ApplicationData(x) => ApplicationData(x.into_owned()), + } + } +} + +impl From> for PlainMessage { + fn from(msg: Message<'_>) -> Self { + let typ = msg.payload.content_type(); + let payload = match msg.payload { + MessagePayload::ApplicationData(payload) => payload.into_owned(), + _ => { + let mut buf = Vec::new(); + msg.payload.encode(&mut buf); + Payload::Owned(buf) + } + }; + + Self { + typ, + version: msg.version, + payload, + } + } +} + +/// A decrypted TLS frame +/// +/// This type owns all memory for its interior parts. It can be decrypted from an OpaqueMessage +/// or encrypted into an OpaqueMessage, and it is also used for joining and fragmenting. +#[derive(Clone, Debug)] +pub struct PlainMessage { + pub typ: ContentType, + pub version: ProtocolVersion, + pub payload: Payload<'static>, +} + +impl PlainMessage { + pub fn into_unencrypted_opaque(self) -> OutboundOpaqueMessage { + OutboundOpaqueMessage { + version: self.version, + typ: self.typ, + payload: PrefixedPayload::from(self.payload.bytes()), + } + } + + pub fn borrow_inbound(&self) -> InboundPlainMessage<'_> { + InboundPlainMessage { + version: self.version, + typ: self.typ, + payload: self.payload.bytes(), + } + } + + pub fn borrow_outbound(&self) -> OutboundPlainMessage<'_> { + OutboundPlainMessage { + version: self.version, + typ: self.typ, + payload: self.payload.bytes().into(), + } + } +} + +/// A message with decoded payload +#[derive(Debug)] +pub struct Message<'a> { + pub version: ProtocolVersion, + pub payload: MessagePayload<'a>, +} + +impl Message<'_> { + pub fn is_handshake_type(&self, hstyp: HandshakeType) -> bool { + // Bit of a layering violation, but OK. + if let MessagePayload::Handshake { parsed, .. } = &self.payload { + parsed.0.handshake_type() == hstyp + } else { + false + } + } + + pub fn build_alert(level: AlertLevel, desc: AlertDescription) -> Self { + Self { + version: ProtocolVersion::TLSv1_2, + payload: MessagePayload::Alert(AlertMessagePayload { + level, + description: desc, + }), + } + } + + pub fn build_key_update_notify() -> Self { + Self { + version: ProtocolVersion::TLSv1_3, + payload: MessagePayload::handshake(HandshakeMessagePayload( + HandshakePayload::KeyUpdate(KeyUpdateRequest::UpdateNotRequested), + )), + } + } + + pub fn build_key_update_request() -> Self { + Self { + version: ProtocolVersion::TLSv1_3, + payload: MessagePayload::handshake(HandshakeMessagePayload( + HandshakePayload::KeyUpdate(KeyUpdateRequest::UpdateRequested), + )), + } + } + + #[cfg(feature = "std")] + pub(crate) fn into_owned(self) -> Message<'static> { + let Self { version, payload } = self; + Message { + version, + payload: payload.into_owned(), + } + } + + #[cfg(test)] + pub(crate) fn into_wire_bytes(self) -> Vec { + PlainMessage::from(self) + .into_unencrypted_opaque() + .encode() + } +} + +impl TryFrom for Message<'static> { + type Error = InvalidMessage; + + fn try_from(plain: PlainMessage) -> Result { + Ok(Self { + version: plain.version, + payload: MessagePayload::new(plain.typ, plain.version, plain.payload.bytes())? + .into_owned(), + }) + } +} + +/// Parses a plaintext message into a well-typed [`Message`]. +/// +/// A [`PlainMessage`] must contain plaintext content. Encrypted content should be stored in an +/// [`InboundOpaqueMessage`] and decrypted before being stored into a [`PlainMessage`]. +impl<'a> TryFrom> for Message<'a> { + type Error = InvalidMessage; + + fn try_from(plain: InboundPlainMessage<'a>) -> Result { + Ok(Self { + version: plain.version, + payload: MessagePayload::new(plain.typ, plain.version, plain.payload)?, + }) + } +} + +#[derive(Debug)] +pub enum MessageError { + TooShortForHeader, + TooShortForLength, + InvalidEmptyPayload, + MessageTooLarge, + InvalidContentType, + UnknownProtocolVersion, +} + +/// Content type, version and size. +pub(crate) const HEADER_SIZE: usize = 1 + 2 + 2; + +/// Maximum message payload size. +/// That's 2^14 payload bytes and a 2KB allowance for ciphertext overheads. +const MAX_PAYLOAD: u16 = 16_384 + 2048; + +/// Maximum on-the-wire message size. +#[cfg(feature = "std")] +pub(crate) const MAX_WIRE_SIZE: usize = MAX_PAYLOAD as usize + HEADER_SIZE; diff --git a/http/vendor/rustls/src/msgs/message/outbound.rs b/http/vendor/rustls/src/msgs/message/outbound.rs new file mode 100644 index 0000000..810c066 --- /dev/null +++ b/http/vendor/rustls/src/msgs/message/outbound.rs @@ -0,0 +1,422 @@ +use alloc::vec::Vec; + +use super::{HEADER_SIZE, MAX_PAYLOAD, MessageError, PlainMessage}; +use crate::enums::{ContentType, ProtocolVersion}; +use crate::msgs::base::Payload; +use crate::msgs::codec::{Codec, Reader}; +use crate::record_layer::RecordLayer; + +/// A TLS frame, named `TLSPlaintext` in the standard. +/// +/// This outbound type borrows its "to be encrypted" payload from the "user". +/// It is used for fragmenting and is consumed by encryption. +#[derive(Debug)] +pub struct OutboundPlainMessage<'a> { + pub typ: ContentType, + pub version: ProtocolVersion, + pub payload: OutboundChunks<'a>, +} + +impl OutboundPlainMessage<'_> { + pub(crate) fn encoded_len(&self, record_layer: &RecordLayer) -> usize { + HEADER_SIZE + record_layer.encrypted_len(self.payload.len()) + } + + pub(crate) fn to_unencrypted_opaque(&self) -> OutboundOpaqueMessage { + let mut payload = PrefixedPayload::with_capacity(self.payload.len()); + payload.extend_from_chunks(&self.payload); + OutboundOpaqueMessage { + version: self.version, + typ: self.typ, + payload, + } + } +} + +/// A collection of borrowed plaintext slices. +/// +/// Warning: OutboundChunks does not guarantee that the simplest variant is used. +/// Multiple can hold non fragmented or empty payloads. +#[derive(Debug, Clone)] +pub enum OutboundChunks<'a> { + /// A single byte slice. Contrary to `Multiple`, this uses a single pointer indirection + Single(&'a [u8]), + /// A collection of chunks (byte slices) + /// and cursors to single out a fragmented range of bytes. + /// OutboundChunks assumes that start <= end + Multiple { + chunks: &'a [&'a [u8]], + start: usize, + end: usize, + }, +} + +impl<'a> OutboundChunks<'a> { + /// Create a payload from a slice of byte slices. + /// If fragmented the cursors are added by default: start = 0, end = length + pub fn new(chunks: &'a [&'a [u8]]) -> Self { + if chunks.len() == 1 { + Self::Single(chunks[0]) + } else { + Self::Multiple { + chunks, + start: 0, + end: chunks + .iter() + .map(|chunk| chunk.len()) + .sum(), + } + } + } + + /// Create a payload with a single empty slice + pub fn new_empty() -> Self { + Self::Single(&[]) + } + + /// Flatten the slice of byte slices to an owned vector of bytes + pub fn to_vec(&self) -> Vec { + let mut vec = Vec::with_capacity(self.len()); + self.copy_to_vec(&mut vec); + vec + } + + /// Append all bytes to a vector + pub fn copy_to_vec(&self, vec: &mut Vec) { + match *self { + Self::Single(chunk) => vec.extend_from_slice(chunk), + Self::Multiple { chunks, start, end } => { + let mut size = 0; + for chunk in chunks.iter() { + let psize = size; + let len = chunk.len(); + size += len; + if size <= start || psize >= end { + continue; + } + let start = start.saturating_sub(psize); + let end = if end - psize < len { end - psize } else { len }; + vec.extend_from_slice(&chunk[start..end]); + } + } + } + } + + /// Split self in two, around an index + /// Works similarly to `split_at` in the core library, except it doesn't panic if out of bound + pub fn split_at(&self, mid: usize) -> (Self, Self) { + match *self { + Self::Single(chunk) => { + let mid = Ord::min(mid, chunk.len()); + (Self::Single(&chunk[..mid]), Self::Single(&chunk[mid..])) + } + Self::Multiple { chunks, start, end } => { + let mid = Ord::min(start + mid, end); + ( + Self::Multiple { + chunks, + start, + end: mid, + }, + Self::Multiple { + chunks, + start: mid, + end, + }, + ) + } + } + } + + /// Returns true if the payload is empty + pub fn is_empty(&self) -> bool { + self.len() == 0 + } + + /// Returns the cumulative length of all chunks + pub fn len(&self) -> usize { + match self { + Self::Single(chunk) => chunk.len(), + Self::Multiple { start, end, .. } => end - start, + } + } +} + +impl<'a> From<&'a [u8]> for OutboundChunks<'a> { + fn from(payload: &'a [u8]) -> Self { + Self::Single(payload) + } +} + +/// A TLS frame, named `TLSPlaintext` in the standard. +/// +/// This outbound type owns all memory for its interior parts. +/// It results from encryption and is used for io write. +#[derive(Clone, Debug)] +pub struct OutboundOpaqueMessage { + pub typ: ContentType, + pub version: ProtocolVersion, + pub payload: PrefixedPayload, +} + +impl OutboundOpaqueMessage { + /// Construct a new `OpaqueMessage` from constituent fields. + /// + /// `body` is moved into the `payload` field. + pub fn new(typ: ContentType, version: ProtocolVersion, payload: PrefixedPayload) -> Self { + Self { + typ, + version, + payload, + } + } + + /// Construct by decoding from a [`Reader`]. + /// + /// `MessageError` allows callers to distinguish between valid prefixes (might + /// become valid if we read more data) and invalid data. + pub fn read(r: &mut Reader<'_>) -> Result { + let (typ, version, len) = read_opaque_message_header(r)?; + + let content = r + .take(len as usize) + .ok_or(MessageError::TooShortForLength)?; + + Ok(Self { + typ, + version, + payload: PrefixedPayload::from(content), + }) + } + + pub fn encode(self) -> Vec { + let length = self.payload.len() as u16; + let mut encoded_payload = self.payload.0; + encoded_payload[0] = self.typ.into(); + encoded_payload[1..3].copy_from_slice(&self.version.to_array()); + encoded_payload[3..5].copy_from_slice(&(length).to_be_bytes()); + encoded_payload + } + + /// Force conversion into a plaintext message. + /// + /// This should only be used for messages that are known to be in plaintext. Otherwise, the + /// `OutboundOpaqueMessage` should be decrypted into a `PlainMessage` using a `MessageDecrypter`. + pub fn into_plain_message(self) -> PlainMessage { + PlainMessage { + version: self.version, + typ: self.typ, + payload: Payload::Owned(self.payload.as_ref().to_vec()), + } + } +} + +#[derive(Clone, Debug)] +pub struct PrefixedPayload(Vec); + +impl PrefixedPayload { + pub fn with_capacity(capacity: usize) -> Self { + let mut prefixed_payload = Vec::with_capacity(HEADER_SIZE + capacity); + prefixed_payload.resize(HEADER_SIZE, 0); + Self(prefixed_payload) + } + + pub fn extend_from_slice(&mut self, slice: &[u8]) { + self.0.extend_from_slice(slice) + } + + pub fn extend_from_chunks(&mut self, chunks: &OutboundChunks<'_>) { + chunks.copy_to_vec(&mut self.0) + } + + pub fn truncate(&mut self, len: usize) { + self.0.truncate(len + HEADER_SIZE) + } + + fn len(&self) -> usize { + self.0.len() - HEADER_SIZE + } +} + +impl AsRef<[u8]> for PrefixedPayload { + fn as_ref(&self) -> &[u8] { + &self.0[HEADER_SIZE..] + } +} + +impl AsMut<[u8]> for PrefixedPayload { + fn as_mut(&mut self) -> &mut [u8] { + &mut self.0[HEADER_SIZE..] + } +} + +impl<'a> Extend<&'a u8> for PrefixedPayload { + fn extend>(&mut self, iter: T) { + self.0.extend(iter) + } +} + +impl From<&[u8]> for PrefixedPayload { + fn from(content: &[u8]) -> Self { + let mut payload = Vec::with_capacity(HEADER_SIZE + content.len()); + payload.extend(&[0u8; HEADER_SIZE]); + payload.extend(content); + Self(payload) + } +} + +impl From<&[u8; N]> for PrefixedPayload { + fn from(content: &[u8; N]) -> Self { + Self::from(&content[..]) + } +} + +pub(crate) fn read_opaque_message_header( + r: &mut Reader<'_>, +) -> Result<(ContentType, ProtocolVersion, u16), MessageError> { + let typ = ContentType::read(r).map_err(|_| MessageError::TooShortForHeader)?; + // Don't accept any new content-types. + if let ContentType::Unknown(_) = typ { + return Err(MessageError::InvalidContentType); + } + + let version = ProtocolVersion::read(r).map_err(|_| MessageError::TooShortForHeader)?; + // Accept only versions 0x03XX for any XX. + match &version { + ProtocolVersion::Unknown(v) if (v & 0xff00) != 0x0300 => { + return Err(MessageError::UnknownProtocolVersion); + } + _ => {} + }; + + let len = u16::read(r).map_err(|_| MessageError::TooShortForHeader)?; + + // Reject undersize messages + // implemented per section 5.1 of RFC8446 (TLSv1.3) + // per section 6.2.1 of RFC5246 (TLSv1.2) + if typ != ContentType::ApplicationData && len == 0 { + return Err(MessageError::InvalidEmptyPayload); + } + + // Reject oversize messages + if len >= MAX_PAYLOAD { + return Err(MessageError::MessageTooLarge); + } + + Ok((typ, version, len)) +} + +#[cfg(test)] +mod tests { + use std::{println, vec}; + + use super::*; + + #[test] + fn split_at_with_single_slice() { + let owner: &[u8] = &[0, 1, 2, 3, 4, 5, 6, 7]; + let borrowed_payload = OutboundChunks::Single(owner); + + let (before, after) = borrowed_payload.split_at(6); + println!("before:{before:?}\nafter:{after:?}"); + assert_eq!(before.to_vec(), &[0, 1, 2, 3, 4, 5]); + assert_eq!(after.to_vec(), &[6, 7]); + } + + #[test] + fn split_at_with_multiple_slices() { + let owner: Vec<&[u8]> = vec![&[0, 1, 2, 3], &[4, 5], &[6, 7, 8], &[9, 10, 11, 12]]; + let borrowed_payload = OutboundChunks::new(&owner); + + let (before, after) = borrowed_payload.split_at(3); + println!("before:{before:?}\nafter:{after:?}"); + assert_eq!(before.to_vec(), &[0, 1, 2]); + assert_eq!(after.to_vec(), &[3, 4, 5, 6, 7, 8, 9, 10, 11, 12]); + + let (before, after) = borrowed_payload.split_at(8); + println!("before:{before:?}\nafter:{after:?}"); + assert_eq!(before.to_vec(), &[0, 1, 2, 3, 4, 5, 6, 7]); + assert_eq!(after.to_vec(), &[8, 9, 10, 11, 12]); + + let (before, after) = borrowed_payload.split_at(11); + println!("before:{before:?}\nafter:{after:?}"); + assert_eq!(before.to_vec(), &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); + assert_eq!(after.to_vec(), &[11, 12]); + } + + #[test] + fn split_out_of_bounds() { + let owner: Vec<&[u8]> = vec![&[0, 1, 2, 3], &[4, 5], &[6, 7, 8], &[9, 10, 11, 12]]; + + let single_payload = OutboundChunks::Single(owner[0]); + let (before, after) = single_payload.split_at(17); + println!("before:{before:?}\nafter:{after:?}"); + assert_eq!(before.to_vec(), &[0, 1, 2, 3]); + assert!(after.is_empty()); + + let multiple_payload = OutboundChunks::new(&owner); + let (before, after) = multiple_payload.split_at(17); + println!("before:{before:?}\nafter:{after:?}"); + assert_eq!(before.to_vec(), &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]); + assert!(after.is_empty()); + + let empty_payload = OutboundChunks::new_empty(); + let (before, after) = empty_payload.split_at(17); + println!("before:{before:?}\nafter:{after:?}"); + assert!(before.is_empty()); + assert!(after.is_empty()); + } + + #[test] + fn empty_slices_mixed() { + let owner: Vec<&[u8]> = vec![&[], &[], &[0], &[], &[1, 2], &[], &[3], &[4], &[], &[]]; + let mut borrowed_payload = OutboundChunks::new(&owner); + let mut fragment_count = 0; + let mut fragment; + let expected_fragments: &[&[u8]] = &[&[0, 1], &[2, 3], &[4]]; + + while !borrowed_payload.is_empty() { + (fragment, borrowed_payload) = borrowed_payload.split_at(2); + println!("{fragment:?}"); + assert_eq!(&expected_fragments[fragment_count], &fragment.to_vec()); + fragment_count += 1; + } + assert_eq!(fragment_count, expected_fragments.len()); + } + + #[test] + fn exhaustive_splitting() { + let owner: Vec = (0..127).collect(); + let slices = (0..7) + .map(|i| &owner[((1 << i) - 1)..((1 << (i + 1)) - 1)]) + .collect::>(); + let payload = OutboundChunks::new(&slices); + + assert_eq!(payload.to_vec(), owner); + println!("{payload:#?}"); + + for start in 0..128 { + for end in start..128 { + for mid in 0..(end - start) { + let witness = owner[start..end].split_at(mid); + let split_payload = payload + .split_at(end) + .0 + .split_at(start) + .1 + .split_at(mid); + assert_eq!( + witness.0, + split_payload.0.to_vec(), + "start: {start}, mid:{mid}, end:{end}" + ); + assert_eq!( + witness.1, + split_payload.1.to_vec(), + "start: {start}, mid:{mid}, end:{end}" + ); + } + } + } + } +} diff --git a/http/vendor/rustls/src/msgs/message_test.rs b/http/vendor/rustls/src/msgs/message_test.rs new file mode 100644 index 0000000..965a357 --- /dev/null +++ b/http/vendor/rustls/src/msgs/message_test.rs @@ -0,0 +1,124 @@ +use std::io::Read; +use std::path::{Path, PathBuf}; +use std::prelude::v1::*; +use std::{format, fs, println, vec}; + +use super::base::Payload; +use super::codec::Reader; +use super::enums::AlertLevel; +use super::message::{Message, OutboundOpaqueMessage, PlainMessage}; +use crate::enums::{AlertDescription, HandshakeType}; +use crate::msgs::base::{MaybeEmpty, NonEmpty, PayloadU8, PayloadU16, PayloadU24}; + +#[test] +fn test_read_fuzz_corpus() { + fn corpus_dir() -> PathBuf { + let from_subcrate = Path::new("../fuzz/corpus/message"); + let from_root = Path::new("fuzz/corpus/message"); + + if from_root.is_dir() { + from_root.to_path_buf() + } else { + from_subcrate.to_path_buf() + } + } + + for file in fs::read_dir(corpus_dir()).unwrap() { + let mut f = fs::File::open(file.unwrap().path()).unwrap(); + let mut bytes = Vec::new(); + f.read_to_end(&mut bytes).unwrap(); + + let mut rd = Reader::init(&bytes); + let msg = OutboundOpaqueMessage::read(&mut rd) + .unwrap() + .into_plain_message(); + println!("{msg:?}"); + + let Ok(msg) = Message::try_from(msg) else { + continue; + }; + + let enc = PlainMessage::from(msg) + .into_unencrypted_opaque() + .encode(); + assert_eq!(bytes.to_vec(), enc); + assert_eq!(bytes[..rd.used()].to_vec(), enc); + } +} + +#[test] +fn can_read_safari_client_hello_with_ip_address_in_sni_extension() { + let _ = env_logger::Builder::new() + .filter(None, log::LevelFilter::Trace) + .try_init(); + + let bytes = b"\ + \x16\x03\x01\x00\xeb\x01\x00\x00\xe7\x03\x03\xb6\x1f\xe4\x3a\x55\ + \x90\x3e\xc0\x28\x9c\x12\xe0\x5c\x84\xea\x90\x1b\xfb\x11\xfc\xbd\ + \x25\x55\xda\x9f\x51\x93\x1b\x8d\x92\x66\xfd\x00\x00\x2e\xc0\x2c\ + \xc0\x2b\xc0\x24\xc0\x23\xc0\x0a\xc0\x09\xcc\xa9\xc0\x30\xc0\x2f\ + \xc0\x28\xc0\x27\xc0\x14\xc0\x13\xcc\xa8\x00\x9d\x00\x9c\x00\x3d\ + \x00\x3c\x00\x35\x00\x2f\xc0\x08\xc0\x12\x00\x0a\x01\x00\x00\x90\ + \xff\x01\x00\x01\x00\x00\x00\x00\x0e\x00\x0c\x00\x00\x09\x31\x32\ + \x37\x2e\x30\x2e\x30\x2e\x31\x00\x17\x00\x00\x00\x0d\x00\x18\x00\ + \x16\x04\x03\x08\x04\x04\x01\x05\x03\x02\x03\x08\x05\x08\x05\x05\ + \x01\x08\x06\x06\x01\x02\x01\x00\x05\x00\x05\x01\x00\x00\x00\x00\ + \x33\x74\x00\x00\x00\x12\x00\x00\x00\x10\x00\x30\x00\x2e\x02\x68\ + \x32\x05\x68\x32\x2d\x31\x36\x05\x68\x32\x2d\x31\x35\x05\x68\x32\ + \x2d\x31\x34\x08\x73\x70\x64\x79\x2f\x33\x2e\x31\x06\x73\x70\x64\ + \x79\x2f\x33\x08\x68\x74\x74\x70\x2f\x31\x2e\x31\x00\x0b\x00\x02\ + \x01\x00\x00\x0a\x00\x0a\x00\x08\x00\x1d\x00\x17\x00\x18\x00\x19"; + let mut rd = Reader::init(bytes); + let m = OutboundOpaqueMessage::read(&mut rd).unwrap(); + println!("m = {m:?}"); + Message::try_from(m.into_plain_message()).unwrap(); +} + +#[test] +fn alert_is_not_handshake() { + let m = Message::build_alert(AlertLevel::Fatal, AlertDescription::DecodeError); + assert!(!m.is_handshake_type(HandshakeType::ClientHello)); +} + +#[test] +fn construct_all_types() { + let samples = [ + &b"\x14\x03\x04\x00\x01\x01"[..], + &b"\x15\x03\x04\x00\x02\x01\x16"[..], + &b"\x16\x03\x04\x00\x05\x18\x00\x00\x01\x00"[..], + &b"\x17\x03\x04\x00\x04\x11\x22\x33\x44"[..], + &b"\x18\x03\x04\x00\x04\x11\x22\x33\x44"[..], + ]; + for &bytes in samples.iter() { + let m = OutboundOpaqueMessage::read(&mut Reader::init(bytes)).unwrap(); + println!("m = {m:?}"); + let m = Message::try_from(m.into_plain_message()); + println!("m' = {m:?}"); + } +} + +#[test] +fn debug_payload() { + assert_eq!("01020304", format!("{:?}", Payload::new(vec![1, 2, 3, 4]))); + assert_eq!( + "01020304", + format!("{:?}", PayloadU8::::new(vec![1, 2, 3, 4])) + ); + assert_eq!( + "01020304", + format!("{:?}", PayloadU16::::new(vec![1, 2, 3, 4])) + ); + assert_eq!( + "01020304", + format!("{:?}", PayloadU24(Payload::new(vec![1, 2, 3, 4]))) + ); +} + +#[test] +fn into_wire_format() { + // Message::into_wire_bytes() include both message-level and handshake-level headers + assert_eq!( + Message::build_key_update_request().into_wire_bytes(), + &[0x16, 0x3, 0x4, 0x0, 0x5, 0x18, 0x0, 0x0, 0x1, 0x1] + ); +} diff --git a/http/vendor/rustls/src/msgs/mod.rs b/http/vendor/rustls/src/msgs/mod.rs new file mode 100644 index 0000000..270c2db --- /dev/null +++ b/http/vendor/rustls/src/msgs/mod.rs @@ -0,0 +1,74 @@ +#![allow(missing_docs)] +//! cat says: +//! +//! ```text +//! ___ _ _ _ _ ___ ___ ___ ___ ___ _ _ ___ _____ ___ ___ _ _ +//! | __| | | | | | | | _ \ __/ __/ _ \ / __| \| |_ _|_ _|_ _/ _ \| \| | +//! | _|| |_| | |__| |__ | / _| (_| (_) | (_ | .` || | | | | | (_) | .` | +//! |_| \___/|____|____| |_|_\___\___\___/ \___|_|\_|___| |_| |___\___/|_|\_| +//! +//! +//! .__....._ _.....__, +//! .": o :': ;': o :". +//! `. `-' .'. .'. `-' .' +//! `---' `---' +//! +//! _...----... ... ... ...----..._ +//! .-'__..-""'---- `. `"` .' ----'""-..__`-. +//! '.-' _.--"""' `-._.-' '"""--._ `-.` +//! ' .-"' : `"-. ` +//! ' `. _.'"'._ .' ` +//! `. ,.-'" "'-., .' +//! `. .' +//! `-._ _.-' +//! `"'--...___...--'"` +//! +//! ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ _ _ ___ +//! | _ ) __| __/ _ \| _ \ __| | _ \ _ \/ _ \ / __| __/ __/ __|_ _| \| |/ __| +//! | _ \ _|| _| (_) | / _| | _/ / (_) | (__| _|\__ \__ \| || .` | (_ | +//! |___/___|_| \___/|_|_\___| |_| |_|_\\___/ \___|___|___/___/___|_|\_|\___| +//! ``` +//! +//! + +#[macro_use] +mod macros; + +pub(crate) mod alert; +pub(crate) mod base; +pub(crate) mod ccs; +pub(crate) mod codec; +pub(crate) mod deframer; +pub(crate) mod enums; +pub(crate) mod fragmenter; +pub(crate) mod handshake; +pub(crate) mod message; +pub(crate) mod persist; + +#[cfg(test)] +mod handshake_test; + +pub mod ffdhe_groups; +#[cfg(test)] +mod message_test; + +#[cfg(test)] +mod tests { + use super::codec::Reader; + use super::message::{Message, OutboundOpaqueMessage}; + + #[test] + fn smoketest() { + let bytes = include_bytes!("../testdata/handshake-test.1.bin"); + let mut r = Reader::init(bytes); + + while r.any_left() { + let m = OutboundOpaqueMessage::read(&mut r).unwrap(); + + let out = m.clone().encode(); + assert!(!out.is_empty()); + + Message::try_from(m.into_plain_message()).unwrap(); + } + } +} diff --git a/http/vendor/rustls/src/msgs/persist.rs b/http/vendor/rustls/src/msgs/persist.rs new file mode 100644 index 0000000..8231c8f --- /dev/null +++ b/http/vendor/rustls/src/msgs/persist.rs @@ -0,0 +1,492 @@ +use alloc::vec::Vec; +use core::cmp; + +use pki_types::{DnsName, UnixTime}; +use zeroize::Zeroizing; + +use crate::client::ResolvesClientCert; +use crate::enums::{CipherSuite, ProtocolVersion}; +use crate::error::InvalidMessage; +use crate::msgs::base::{MaybeEmpty, PayloadU8, PayloadU16}; +use crate::msgs::codec::{Codec, Reader}; +#[cfg(feature = "tls12")] +use crate::msgs::handshake::SessionId; +use crate::msgs::handshake::{CertificateChain, ProtocolName}; +use crate::sync::{Arc, Weak}; +#[cfg(feature = "tls12")] +use crate::tls12::Tls12CipherSuite; +use crate::tls13::Tls13CipherSuite; +use crate::verify::ServerCertVerifier; + +pub(crate) struct Retrieved { + pub(crate) value: T, + retrieved_at: UnixTime, +} + +impl Retrieved { + pub(crate) fn new(value: T, retrieved_at: UnixTime) -> Self { + Self { + value, + retrieved_at, + } + } + + pub(crate) fn map(&self, f: impl FnOnce(&T) -> Option<&M>) -> Option> { + Some(Retrieved { + value: f(&self.value)?, + retrieved_at: self.retrieved_at, + }) + } +} + +impl Retrieved<&Tls13ClientSessionValue> { + pub(crate) fn obfuscated_ticket_age(&self) -> u32 { + let age_secs = self + .retrieved_at + .as_secs() + .saturating_sub(self.value.common.epoch); + let age_millis = age_secs as u32 * 1000; + age_millis.wrapping_add(self.value.age_add) + } +} + +impl> Retrieved { + pub(crate) fn has_expired(&self) -> bool { + let common = &*self.value; + common.lifetime_secs != 0 + && common + .epoch + .saturating_add(u64::from(common.lifetime_secs)) + < self.retrieved_at.as_secs() + } +} + +impl core::ops::Deref for Retrieved { + type Target = T; + + fn deref(&self) -> &Self::Target { + &self.value + } +} + +#[derive(Debug)] +pub struct Tls13ClientSessionValue { + suite: &'static Tls13CipherSuite, + age_add: u32, + max_early_data_size: u32, + pub(crate) common: ClientSessionCommon, + quic_params: PayloadU16, +} + +impl Tls13ClientSessionValue { + pub(crate) fn new( + suite: &'static Tls13CipherSuite, + ticket: Arc, + secret: &[u8], + server_cert_chain: CertificateChain<'static>, + server_cert_verifier: &Arc, + client_creds: &Arc, + time_now: UnixTime, + lifetime_secs: u32, + age_add: u32, + max_early_data_size: u32, + ) -> Self { + Self { + suite, + age_add, + max_early_data_size, + common: ClientSessionCommon::new( + ticket, + secret, + time_now, + lifetime_secs, + server_cert_chain, + server_cert_verifier, + client_creds, + ), + quic_params: PayloadU16::new(Vec::new()), + } + } + + pub fn max_early_data_size(&self) -> u32 { + self.max_early_data_size + } + + pub fn suite(&self) -> &'static Tls13CipherSuite { + self.suite + } + + #[doc(hidden)] + /// Test only: rewind epoch by `delta` seconds. + pub fn rewind_epoch(&mut self, delta: u32) { + self.common.epoch -= delta as u64; + } + + #[doc(hidden)] + /// Test only: replace `max_early_data_size` with `new` + pub fn _private_set_max_early_data_size(&mut self, new: u32) { + self.max_early_data_size = new; + } + + pub fn set_quic_params(&mut self, quic_params: &[u8]) { + self.quic_params = PayloadU16::new(quic_params.to_vec()); + } + + pub fn quic_params(&self) -> Vec { + self.quic_params.0.clone() + } +} + +impl core::ops::Deref for Tls13ClientSessionValue { + type Target = ClientSessionCommon; + + fn deref(&self) -> &Self::Target { + &self.common + } +} + +#[derive(Debug, Clone)] +pub struct Tls12ClientSessionValue { + #[cfg(feature = "tls12")] + suite: &'static Tls12CipherSuite, + #[cfg(feature = "tls12")] + pub(crate) session_id: SessionId, + #[cfg(feature = "tls12")] + extended_ms: bool, + #[doc(hidden)] + #[cfg(feature = "tls12")] + pub(crate) common: ClientSessionCommon, +} + +#[cfg(feature = "tls12")] +impl Tls12ClientSessionValue { + pub(crate) fn new( + suite: &'static Tls12CipherSuite, + session_id: SessionId, + ticket: Arc, + master_secret: &[u8], + server_cert_chain: CertificateChain<'static>, + server_cert_verifier: &Arc, + client_creds: &Arc, + time_now: UnixTime, + lifetime_secs: u32, + extended_ms: bool, + ) -> Self { + Self { + suite, + session_id, + extended_ms, + common: ClientSessionCommon::new( + ticket, + master_secret, + time_now, + lifetime_secs, + server_cert_chain, + server_cert_verifier, + client_creds, + ), + } + } + + pub(crate) fn ticket(&mut self) -> Arc { + self.common.ticket.clone() + } + + pub(crate) fn extended_ms(&self) -> bool { + self.extended_ms + } + + pub(crate) fn suite(&self) -> &'static Tls12CipherSuite { + self.suite + } + + #[doc(hidden)] + /// Test only: rewind epoch by `delta` seconds. + pub fn rewind_epoch(&mut self, delta: u32) { + self.common.epoch -= delta as u64; + } +} + +#[cfg(feature = "tls12")] +impl core::ops::Deref for Tls12ClientSessionValue { + type Target = ClientSessionCommon; + + fn deref(&self) -> &Self::Target { + &self.common + } +} + +#[derive(Debug, Clone)] +pub struct ClientSessionCommon { + ticket: Arc, + secret: Zeroizing, + epoch: u64, + lifetime_secs: u32, + server_cert_chain: Arc>, + server_cert_verifier: Weak, + client_creds: Weak, +} + +impl ClientSessionCommon { + fn new( + ticket: Arc, + secret: &[u8], + time_now: UnixTime, + lifetime_secs: u32, + server_cert_chain: CertificateChain<'static>, + server_cert_verifier: &Arc, + client_creds: &Arc, + ) -> Self { + Self { + ticket, + secret: Zeroizing::new(PayloadU8::new(secret.to_vec())), + epoch: time_now.as_secs(), + lifetime_secs: cmp::min(lifetime_secs, MAX_TICKET_LIFETIME), + server_cert_chain: Arc::new(server_cert_chain), + server_cert_verifier: Arc::downgrade(server_cert_verifier), + client_creds: Arc::downgrade(client_creds), + } + } + + pub(crate) fn compatible_config( + &self, + server_cert_verifier: &Arc, + client_creds: &Arc, + ) -> bool { + let same_verifier = Weak::ptr_eq( + &Arc::downgrade(server_cert_verifier), + &self.server_cert_verifier, + ); + let same_creds = Weak::ptr_eq(&Arc::downgrade(client_creds), &self.client_creds); + + match (same_verifier, same_creds) { + (true, true) => true, + (false, _) => { + crate::log::trace!("resumption not allowed between different ServerCertVerifiers"); + false + } + (_, _) => { + crate::log::trace!( + "resumption not allowed between different ResolvesClientCert values" + ); + false + } + } + } + + pub(crate) fn server_cert_chain(&self) -> &CertificateChain<'static> { + &self.server_cert_chain + } + + pub(crate) fn secret(&self) -> &[u8] { + self.secret.0.as_ref() + } + + pub(crate) fn ticket(&self) -> &[u8] { + self.ticket.0.as_ref() + } +} + +static MAX_TICKET_LIFETIME: u32 = 7 * 24 * 60 * 60; + +/// This is the maximum allowed skew between server and client clocks, over +/// the maximum ticket lifetime period. This encompasses TCP retransmission +/// times in case packet loss occurs when the client sends the ClientHello +/// or receives the NewSessionTicket, _and_ actual clock skew over this period. +static MAX_FRESHNESS_SKEW_MS: u32 = 60 * 1000; + +// --- Server types --- +#[derive(Debug)] +pub struct ServerSessionValue { + pub(crate) sni: Option>, + pub(crate) version: ProtocolVersion, + pub(crate) cipher_suite: CipherSuite, + pub(crate) master_secret: Zeroizing, + pub(crate) extended_ms: bool, + pub(crate) client_cert_chain: Option>, + pub(crate) alpn: Option, + pub(crate) application_data: PayloadU16, + pub creation_time_sec: u64, + pub(crate) age_obfuscation_offset: u32, + freshness: Option, +} + +impl Codec<'_> for ServerSessionValue { + fn encode(&self, bytes: &mut Vec) { + if let Some(sni) = &self.sni { + 1u8.encode(bytes); + let sni_bytes: &str = sni.as_ref(); + PayloadU8::::encode_slice(sni_bytes.as_bytes(), bytes); + } else { + 0u8.encode(bytes); + } + self.version.encode(bytes); + self.cipher_suite.encode(bytes); + self.master_secret.encode(bytes); + (u8::from(self.extended_ms)).encode(bytes); + if let Some(chain) = &self.client_cert_chain { + 1u8.encode(bytes); + chain.encode(bytes); + } else { + 0u8.encode(bytes); + } + if let Some(alpn) = &self.alpn { + 1u8.encode(bytes); + alpn.encode(bytes); + } else { + 0u8.encode(bytes); + } + self.application_data.encode(bytes); + self.creation_time_sec.encode(bytes); + self.age_obfuscation_offset + .encode(bytes); + } + + fn read(r: &mut Reader<'_>) -> Result { + let has_sni = u8::read(r)?; + let sni = if has_sni == 1 { + let dns_name = PayloadU8::::read(r)?; + let dns_name = match DnsName::try_from(dns_name.0.as_slice()) { + Ok(dns_name) => dns_name.to_owned(), + Err(_) => return Err(InvalidMessage::InvalidServerName), + }; + + Some(dns_name) + } else { + None + }; + + let v = ProtocolVersion::read(r)?; + let cs = CipherSuite::read(r)?; + let ms = Zeroizing::new(PayloadU8::read(r)?); + let ems = u8::read(r)?; + let has_ccert = u8::read(r)? == 1; + let ccert = if has_ccert { + Some(CertificateChain::read(r)?.into_owned()) + } else { + None + }; + let has_alpn = u8::read(r)? == 1; + let alpn = if has_alpn { + Some(PayloadU8::read(r)?) + } else { + None + }; + let application_data = PayloadU16::read(r)?; + let creation_time_sec = u64::read(r)?; + let age_obfuscation_offset = u32::read(r)?; + + Ok(Self { + sni, + version: v, + cipher_suite: cs, + master_secret: ms, + extended_ms: ems == 1u8, + client_cert_chain: ccert, + alpn, + application_data, + creation_time_sec, + age_obfuscation_offset, + freshness: None, + }) + } +} + +impl ServerSessionValue { + pub(crate) fn new( + sni: Option<&DnsName<'_>>, + v: ProtocolVersion, + cs: CipherSuite, + ms: &[u8], + client_cert_chain: Option>, + alpn: Option, + application_data: Vec, + creation_time: UnixTime, + age_obfuscation_offset: u32, + ) -> Self { + Self { + sni: sni.map(|dns| dns.to_owned()), + version: v, + cipher_suite: cs, + master_secret: Zeroizing::new(PayloadU8::new(ms.to_vec())), + extended_ms: false, + client_cert_chain, + alpn: alpn.map(|p| PayloadU8::new(p.as_ref().to_vec())), + application_data: PayloadU16::new(application_data), + creation_time_sec: creation_time.as_secs(), + age_obfuscation_offset, + freshness: None, + } + } + + #[cfg(feature = "tls12")] + pub(crate) fn set_extended_ms_used(&mut self) { + self.extended_ms = true; + } + + pub(crate) fn set_freshness( + mut self, + obfuscated_client_age_ms: u32, + time_now: UnixTime, + ) -> Self { + let client_age_ms = obfuscated_client_age_ms.wrapping_sub(self.age_obfuscation_offset); + let server_age_ms = (time_now + .as_secs() + .saturating_sub(self.creation_time_sec) as u32) + .saturating_mul(1000); + + let age_difference = server_age_ms.abs_diff(client_age_ms); + + self.freshness = Some(age_difference <= MAX_FRESHNESS_SKEW_MS); + self + } + + pub(crate) fn is_fresh(&self) -> bool { + self.freshness.unwrap_or_default() + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[cfg(feature = "std")] // for UnixTime::now + #[test] + fn serversessionvalue_is_debug() { + use std::{println, vec}; + let ssv = ServerSessionValue::new( + None, + ProtocolVersion::TLSv1_3, + CipherSuite::TLS13_AES_128_GCM_SHA256, + &[1, 2, 3], + None, + None, + vec![4, 5, 6], + UnixTime::now(), + 0x12345678, + ); + println!("{ssv:?}"); + } + + #[test] + fn serversessionvalue_no_sni() { + let bytes = [ + 0x00, 0x03, 0x03, 0xc0, 0x23, 0x03, 0x01, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0xfe, 0xed, 0xf0, 0x0d, + ]; + let mut rd = Reader::init(&bytes); + let ssv = ServerSessionValue::read(&mut rd).unwrap(); + assert_eq!(ssv.get_encoding(), bytes); + } + + #[test] + fn serversessionvalue_with_cert() { + let bytes = [ + 0x00, 0x03, 0x03, 0xc0, 0x23, 0x03, 0x01, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0xfe, 0xed, 0xf0, 0x0d, + ]; + let mut rd = Reader::init(&bytes); + let ssv = ServerSessionValue::read(&mut rd).unwrap(); + assert_eq!(ssv.get_encoding(), bytes); + } +} diff --git a/http/vendor/rustls/src/polyfill.rs b/http/vendor/rustls/src/polyfill.rs new file mode 100644 index 0000000..82571a2 --- /dev/null +++ b/http/vendor/rustls/src/polyfill.rs @@ -0,0 +1,9 @@ +/// Non-panicking `let (nonce, ciphertext) = ciphertext.split_at(...)`. +// TODO(XXX): remove once MSRV reaches 1.80 +#[allow(dead_code)] // Complicated conditional compilation guards elided +pub(crate) fn try_split_at(slice: &[u8], mid: usize) -> Option<(&[u8], &[u8])> { + match mid > slice.len() { + true => None, + false => Some(slice.split_at(mid)), + } +} diff --git a/http/vendor/rustls/src/quic.rs b/http/vendor/rustls/src/quic.rs new file mode 100644 index 0000000..d1b7326 --- /dev/null +++ b/http/vendor/rustls/src/quic.rs @@ -0,0 +1,1056 @@ +use alloc::boxed::Box; +use alloc::collections::VecDeque; +use alloc::vec::Vec; +#[cfg(feature = "std")] +use core::fmt::Debug; + +/// This module contains optional APIs for implementing QUIC TLS. +use crate::common_state::Side; +use crate::crypto::cipher::{AeadKey, Iv}; +use crate::crypto::tls13::{Hkdf, HkdfExpander, OkmBlock}; +use crate::enums::AlertDescription; +use crate::error::Error; +use crate::tls13::Tls13CipherSuite; +use crate::tls13::key_schedule::{ + hkdf_expand_label, hkdf_expand_label_aead_key, hkdf_expand_label_block, +}; + +#[cfg(feature = "std")] +mod connection { + use alloc::vec::Vec; + use core::fmt::{self, Debug}; + use core::ops::{Deref, DerefMut}; + + use pki_types::ServerName; + + use super::{DirectionalKeys, KeyChange, Version}; + use crate::client::{ClientConfig, ClientConnectionData}; + use crate::common_state::{CommonState, DEFAULT_BUFFER_LIMIT, Protocol}; + use crate::conn::{ConnectionCore, SideData}; + use crate::enums::{AlertDescription, ContentType, ProtocolVersion}; + use crate::error::Error; + use crate::msgs::base::Payload; + use crate::msgs::deframer::buffers::{DeframerVecBuffer, Locator}; + use crate::msgs::handshake::{ + ClientExtensionsInput, ServerExtensionsInput, TransportParameters, + }; + use crate::msgs::message::InboundPlainMessage; + use crate::server::{ServerConfig, ServerConnectionData}; + use crate::sync::Arc; + use crate::vecbuf::ChunkVecBuffer; + + /// A QUIC client or server connection. + #[derive(Debug)] + pub enum Connection { + /// A client connection + Client(ClientConnection), + /// A server connection + Server(ServerConnection), + } + + impl Connection { + /// Return the TLS-encoded transport parameters for the session's peer. + /// + /// See [`ConnectionCommon::quic_transport_parameters()`] for more details. + pub fn quic_transport_parameters(&self) -> Option<&[u8]> { + match self { + Self::Client(conn) => conn.quic_transport_parameters(), + Self::Server(conn) => conn.quic_transport_parameters(), + } + } + + /// Compute the keys for encrypting/decrypting 0-RTT packets, if available + pub fn zero_rtt_keys(&self) -> Option { + match self { + Self::Client(conn) => conn.zero_rtt_keys(), + Self::Server(conn) => conn.zero_rtt_keys(), + } + } + + /// Consume unencrypted TLS handshake data. + /// + /// Handshake data obtained from separate encryption levels should be supplied in separate calls. + pub fn read_hs(&mut self, plaintext: &[u8]) -> Result<(), Error> { + match self { + Self::Client(conn) => conn.read_hs(plaintext), + Self::Server(conn) => conn.read_hs(plaintext), + } + } + + /// Emit unencrypted TLS handshake data. + /// + /// When this returns `Some(_)`, the new keys must be used for future handshake data. + pub fn write_hs(&mut self, buf: &mut Vec) -> Option { + match self { + Self::Client(conn) => conn.write_hs(buf), + Self::Server(conn) => conn.write_hs(buf), + } + } + + /// Emit the TLS description code of a fatal alert, if one has arisen. + /// + /// Check after `read_hs` returns `Err(_)`. + pub fn alert(&self) -> Option { + match self { + Self::Client(conn) => conn.alert(), + Self::Server(conn) => conn.alert(), + } + } + + /// Derives key material from the agreed connection secrets. + /// + /// This function fills in `output` with `output.len()` bytes of key + /// material derived from the master session secret using `label` + /// and `context` for diversification. Ownership of the buffer is taken + /// by the function and returned via the Ok result to ensure no key + /// material leaks if the function fails. + /// + /// See RFC5705 for more details on what this does and is for. + /// + /// For TLS1.3 connections, this function does not use the + /// "early" exporter at any point. + /// + /// This function fails if called prior to the handshake completing; + /// check with [`CommonState::is_handshaking`] first. + #[inline] + pub fn export_keying_material>( + &self, + output: T, + label: &[u8], + context: Option<&[u8]>, + ) -> Result { + match self { + Self::Client(conn) => conn + .core + .export_keying_material(output, label, context), + Self::Server(conn) => conn + .core + .export_keying_material(output, label, context), + } + } + } + + impl Deref for Connection { + type Target = CommonState; + + fn deref(&self) -> &Self::Target { + match self { + Self::Client(conn) => &conn.core.common_state, + Self::Server(conn) => &conn.core.common_state, + } + } + } + + impl DerefMut for Connection { + fn deref_mut(&mut self) -> &mut Self::Target { + match self { + Self::Client(conn) => &mut conn.core.common_state, + Self::Server(conn) => &mut conn.core.common_state, + } + } + } + + /// A QUIC client connection. + pub struct ClientConnection { + inner: ConnectionCommon, + } + + impl ClientConnection { + /// Make a new QUIC ClientConnection. + /// + /// This differs from `ClientConnection::new()` in that it takes an extra `params` argument, + /// which contains the TLS-encoded transport parameters to send. + pub fn new( + config: Arc, + quic_version: Version, + name: ServerName<'static>, + params: Vec, + ) -> Result { + Self::new_with_alpn( + config.clone(), + quic_version, + name, + params, + config.alpn_protocols.clone(), + ) + } + + /// Make a new QUIC ClientConnection with custom ALPN protocols. + pub fn new_with_alpn( + config: Arc, + quic_version: Version, + name: ServerName<'static>, + params: Vec, + alpn_protocols: Vec>, + ) -> Result { + if !config.supports_version(ProtocolVersion::TLSv1_3) { + return Err(Error::General( + "TLS 1.3 support is required for QUIC".into(), + )); + } + + if !config.supports_protocol(Protocol::Quic) { + return Err(Error::General( + "at least one ciphersuite must support QUIC".into(), + )); + } + + let exts = ClientExtensionsInput { + transport_parameters: Some(match quic_version { + Version::V1Draft => TransportParameters::QuicDraft(Payload::new(params)), + Version::V1 | Version::V2 => TransportParameters::Quic(Payload::new(params)), + }), + + ..ClientExtensionsInput::from_alpn(alpn_protocols) + }; + + let mut inner = ConnectionCore::for_client(config, name, exts, Protocol::Quic)?; + inner.common_state.quic.version = quic_version; + Ok(Self { + inner: inner.into(), + }) + } + + /// Returns True if the server signalled it will process early data. + /// + /// If you sent early data and this returns false at the end of the + /// handshake then the server will not process the data. This + /// is not an error, but you may wish to resend the data. + pub fn is_early_data_accepted(&self) -> bool { + self.inner.core.is_early_data_accepted() + } + + /// Returns the number of TLS1.3 tickets that have been received. + pub fn tls13_tickets_received(&self) -> u32 { + self.inner.tls13_tickets_received + } + } + + impl Deref for ClientConnection { + type Target = ConnectionCommon; + + fn deref(&self) -> &Self::Target { + &self.inner + } + } + + impl DerefMut for ClientConnection { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.inner + } + } + + impl Debug for ClientConnection { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("quic::ClientConnection") + .finish() + } + } + + impl From for Connection { + fn from(c: ClientConnection) -> Self { + Self::Client(c) + } + } + + /// A QUIC server connection. + pub struct ServerConnection { + inner: ConnectionCommon, + } + + impl ServerConnection { + /// Make a new QUIC ServerConnection. + /// + /// This differs from `ServerConnection::new()` in that it takes an extra `params` argument, + /// which contains the TLS-encoded transport parameters to send. + pub fn new( + config: Arc, + quic_version: Version, + params: Vec, + ) -> Result { + if !config.supports_version(ProtocolVersion::TLSv1_3) { + return Err(Error::General( + "TLS 1.3 support is required for QUIC".into(), + )); + } + + if !config.supports_protocol(Protocol::Quic) { + return Err(Error::General( + "at least one ciphersuite must support QUIC".into(), + )); + } + + if config.max_early_data_size != 0 && config.max_early_data_size != 0xffff_ffff { + return Err(Error::General( + "QUIC sessions must set a max early data of 0 or 2^32-1".into(), + )); + } + + let exts = ServerExtensionsInput { + transport_parameters: Some(match quic_version { + Version::V1Draft => TransportParameters::QuicDraft(Payload::new(params)), + Version::V1 | Version::V2 => TransportParameters::Quic(Payload::new(params)), + }), + }; + + let mut core = ConnectionCore::for_server(config, exts)?; + core.common_state.protocol = Protocol::Quic; + core.common_state.quic.version = quic_version; + Ok(Self { inner: core.into() }) + } + + /// Explicitly discard early data, notifying the client + /// + /// Useful if invariants encoded in `received_resumption_data()` cannot be respected. + /// + /// Must be called while `is_handshaking` is true. + pub fn reject_early_data(&mut self) { + self.inner.core.reject_early_data() + } + + /// Retrieves the server name, if any, used to select the certificate and + /// private key. + /// + /// This returns `None` until some time after the client's server name indication + /// (SNI) extension value is processed during the handshake. It will never be + /// `None` when the connection is ready to send or process application data, + /// unless the client does not support SNI. + /// + /// This is useful for application protocols that need to enforce that the + /// server name matches an application layer protocol hostname. For + /// example, HTTP/1.1 servers commonly expect the `Host:` header field of + /// every request on a connection to match the hostname in the SNI extension + /// when the client provides the SNI extension. + /// + /// The server name is also used to match sessions during session resumption. + pub fn server_name(&self) -> Option<&str> { + self.inner.core.get_sni_str() + } + } + + impl Deref for ServerConnection { + type Target = ConnectionCommon; + + fn deref(&self) -> &Self::Target { + &self.inner + } + } + + impl DerefMut for ServerConnection { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.inner + } + } + + impl Debug for ServerConnection { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("quic::ServerConnection") + .finish() + } + } + + impl From for Connection { + fn from(c: ServerConnection) -> Self { + Self::Server(c) + } + } + + /// A shared interface for QUIC connections. + pub struct ConnectionCommon { + core: ConnectionCore, + deframer_buffer: DeframerVecBuffer, + sendable_plaintext: ChunkVecBuffer, + } + + impl ConnectionCommon { + /// Return the TLS-encoded transport parameters for the session's peer. + /// + /// While the transport parameters are technically available prior to the + /// completion of the handshake, they cannot be fully trusted until the + /// handshake completes, and reliance on them should be minimized. + /// However, any tampering with the parameters will cause the handshake + /// to fail. + pub fn quic_transport_parameters(&self) -> Option<&[u8]> { + self.core + .common_state + .quic + .params + .as_ref() + .map(|v| v.as_ref()) + } + + /// Compute the keys for encrypting/decrypting 0-RTT packets, if available + pub fn zero_rtt_keys(&self) -> Option { + let suite = self + .core + .common_state + .suite + .and_then(|suite| suite.tls13())?; + Some(DirectionalKeys::new( + suite, + suite.quic?, + self.core + .common_state + .quic + .early_secret + .as_ref()?, + self.core.common_state.quic.version, + )) + } + + /// Consume unencrypted TLS handshake data. + /// + /// Handshake data obtained from separate encryption levels should be supplied in separate calls. + pub fn read_hs(&mut self, plaintext: &[u8]) -> Result<(), Error> { + let range = self.deframer_buffer.extend(plaintext); + + self.core.hs_deframer.input_message( + InboundPlainMessage { + typ: ContentType::Handshake, + version: ProtocolVersion::TLSv1_3, + payload: &self.deframer_buffer.filled()[range.clone()], + }, + &Locator::new(self.deframer_buffer.filled()), + range.end, + ); + + self.core + .hs_deframer + .coalesce(self.deframer_buffer.filled_mut())?; + + self.core + .process_new_packets(&mut self.deframer_buffer, &mut self.sendable_plaintext)?; + + Ok(()) + } + + /// Emit unencrypted TLS handshake data. + /// + /// When this returns `Some(_)`, the new keys must be used for future handshake data. + pub fn write_hs(&mut self, buf: &mut Vec) -> Option { + self.core + .common_state + .quic + .write_hs(buf) + } + + /// Emit the TLS description code of a fatal alert, if one has arisen. + /// + /// Check after `read_hs` returns `Err(_)`. + pub fn alert(&self) -> Option { + self.core.common_state.quic.alert + } + } + + impl Deref for ConnectionCommon { + type Target = CommonState; + + fn deref(&self) -> &Self::Target { + &self.core.common_state + } + } + + impl DerefMut for ConnectionCommon { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.core.common_state + } + } + + impl From> for ConnectionCommon { + fn from(core: ConnectionCore) -> Self { + Self { + core, + deframer_buffer: DeframerVecBuffer::default(), + sendable_plaintext: ChunkVecBuffer::new(Some(DEFAULT_BUFFER_LIMIT)), + } + } + } +} + +#[cfg(feature = "std")] +pub use connection::{ClientConnection, Connection, ConnectionCommon, ServerConnection}; + +#[derive(Default)] +pub(crate) struct Quic { + /// QUIC transport parameters received from the peer during the handshake + pub(crate) params: Option>, + pub(crate) alert: Option, + pub(crate) hs_queue: VecDeque<(bool, Vec)>, + pub(crate) early_secret: Option, + pub(crate) hs_secrets: Option, + pub(crate) traffic_secrets: Option, + /// Whether keys derived from traffic_secrets have been passed to the QUIC implementation + #[cfg(feature = "std")] + pub(crate) returned_traffic_keys: bool, + pub(crate) version: Version, +} + +#[cfg(feature = "std")] +impl Quic { + pub(crate) fn write_hs(&mut self, buf: &mut Vec) -> Option { + while let Some((_, msg)) = self.hs_queue.pop_front() { + buf.extend_from_slice(&msg); + if let Some(&(true, _)) = self.hs_queue.front() { + if self.hs_secrets.is_some() { + // Allow the caller to switch keys before proceeding. + break; + } + } + } + + if let Some(secrets) = self.hs_secrets.take() { + return Some(KeyChange::Handshake { + keys: Keys::new(&secrets), + }); + } + + if let Some(mut secrets) = self.traffic_secrets.take() { + if !self.returned_traffic_keys { + self.returned_traffic_keys = true; + let keys = Keys::new(&secrets); + secrets.update(); + return Some(KeyChange::OneRtt { + keys, + next: secrets, + }); + } + } + + None + } +} + +/// Secrets used to encrypt/decrypt traffic +#[derive(Clone)] +pub struct Secrets { + /// Secret used to encrypt packets transmitted by the client + pub(crate) client: OkmBlock, + /// Secret used to encrypt packets transmitted by the server + pub(crate) server: OkmBlock, + /// Cipher suite used with these secrets + suite: &'static Tls13CipherSuite, + quic: &'static dyn Algorithm, + side: Side, + version: Version, +} + +impl Secrets { + pub(crate) fn new( + client: OkmBlock, + server: OkmBlock, + suite: &'static Tls13CipherSuite, + quic: &'static dyn Algorithm, + side: Side, + version: Version, + ) -> Self { + Self { + client, + server, + suite, + quic, + side, + version, + } + } + + /// Derive the next set of packet keys + pub fn next_packet_keys(&mut self) -> PacketKeySet { + let keys = PacketKeySet::new(self); + self.update(); + keys + } + + pub(crate) fn update(&mut self) { + self.client = hkdf_expand_label_block( + self.suite + .hkdf_provider + .expander_for_okm(&self.client) + .as_ref(), + self.version.key_update_label(), + &[], + ); + self.server = hkdf_expand_label_block( + self.suite + .hkdf_provider + .expander_for_okm(&self.server) + .as_ref(), + self.version.key_update_label(), + &[], + ); + } + + fn local_remote(&self) -> (&OkmBlock, &OkmBlock) { + match self.side { + Side::Client => (&self.client, &self.server), + Side::Server => (&self.server, &self.client), + } + } +} + +/// Keys used to communicate in a single direction +pub struct DirectionalKeys { + /// Encrypts or decrypts a packet's headers + pub header: Box, + /// Encrypts or decrypts the payload of a packet + pub packet: Box, +} + +impl DirectionalKeys { + pub(crate) fn new( + suite: &'static Tls13CipherSuite, + quic: &'static dyn Algorithm, + secret: &OkmBlock, + version: Version, + ) -> Self { + let builder = KeyBuilder::new(secret, version, quic, suite.hkdf_provider); + Self { + header: builder.header_protection_key(), + packet: builder.packet_key(), + } + } +} + +/// All AEADs we support have 16-byte tags. +const TAG_LEN: usize = 16; + +/// Authentication tag from an AEAD seal operation. +pub struct Tag([u8; TAG_LEN]); + +impl From<&[u8]> for Tag { + fn from(value: &[u8]) -> Self { + let mut array = [0u8; TAG_LEN]; + array.copy_from_slice(value); + Self(array) + } +} + +impl AsRef<[u8]> for Tag { + fn as_ref(&self) -> &[u8] { + &self.0 + } +} + +/// How a `Tls13CipherSuite` generates `PacketKey`s and `HeaderProtectionKey`s. +pub trait Algorithm: Send + Sync { + /// Produce a `PacketKey` encrypter/decrypter for this suite. + /// + /// `suite` is the entire suite this `Algorithm` appeared in. + /// `key` and `iv` is the key material to use. + fn packet_key(&self, key: AeadKey, iv: Iv) -> Box; + + /// Produce a `HeaderProtectionKey` encrypter/decrypter for this suite. + /// + /// `key` is the key material, which is `aead_key_len()` bytes in length. + fn header_protection_key(&self, key: AeadKey) -> Box; + + /// The length in bytes of keys for this Algorithm. + /// + /// This controls the size of `AeadKey`s presented to `packet_key()` and `header_protection_key()`. + fn aead_key_len(&self) -> usize; + + /// Whether this algorithm is FIPS-approved. + fn fips(&self) -> bool { + false + } +} + +/// A QUIC header protection key +pub trait HeaderProtectionKey: Send + Sync { + /// Adds QUIC Header Protection. + /// + /// `sample` must contain the sample of encrypted payload; see + /// [Header Protection Sample]. + /// + /// `first` must reference the first byte of the header, referred to as + /// `packet[0]` in [Header Protection Application]. + /// + /// `packet_number` must reference the Packet Number field; this is + /// `packet[pn_offset:pn_offset+pn_length]` in [Header Protection Application]. + /// + /// Returns an error without modifying anything if `sample` is not + /// the correct length (see [Header Protection Sample] and [`Self::sample_len()`]), + /// or `packet_number` is longer than allowed (see [Packet Number Encoding and Decoding]). + /// + /// Otherwise, `first` and `packet_number` will have the header protection added. + /// + /// [Header Protection Application]: https://datatracker.ietf.org/doc/html/rfc9001#section-5.4.1 + /// [Header Protection Sample]: https://datatracker.ietf.org/doc/html/rfc9001#section-5.4.2 + /// [Packet Number Encoding and Decoding]: https://datatracker.ietf.org/doc/html/rfc9000#section-17.1 + fn encrypt_in_place( + &self, + sample: &[u8], + first: &mut u8, + packet_number: &mut [u8], + ) -> Result<(), Error>; + + /// Removes QUIC Header Protection. + /// + /// `sample` must contain the sample of encrypted payload; see + /// [Header Protection Sample]. + /// + /// `first` must reference the first byte of the header, referred to as + /// `packet[0]` in [Header Protection Application]. + /// + /// `packet_number` must reference the Packet Number field; this is + /// `packet[pn_offset:pn_offset+pn_length]` in [Header Protection Application]. + /// + /// Returns an error without modifying anything if `sample` is not + /// the correct length (see [Header Protection Sample] and [`Self::sample_len()`]), + /// or `packet_number` is longer than allowed (see + /// [Packet Number Encoding and Decoding]). + /// + /// Otherwise, `first` and `packet_number` will have the header protection removed. + /// + /// [Header Protection Application]: https://datatracker.ietf.org/doc/html/rfc9001#section-5.4.1 + /// [Header Protection Sample]: https://datatracker.ietf.org/doc/html/rfc9001#section-5.4.2 + /// [Packet Number Encoding and Decoding]: https://datatracker.ietf.org/doc/html/rfc9000#section-17.1 + fn decrypt_in_place( + &self, + sample: &[u8], + first: &mut u8, + packet_number: &mut [u8], + ) -> Result<(), Error>; + + /// Expected sample length for the key's algorithm + fn sample_len(&self) -> usize; +} + +/// Keys to encrypt or decrypt the payload of a packet +pub trait PacketKey: Send + Sync { + /// Encrypt a QUIC packet + /// + /// Takes a `packet_number`, used to derive the nonce; the packet `header`, which is used as + /// the additional authenticated data; and the `payload`. The authentication tag is returned if + /// encryption succeeds. + /// + /// Fails if and only if the payload is longer than allowed by the cipher suite's AEAD algorithm. + fn encrypt_in_place( + &self, + packet_number: u64, + header: &[u8], + payload: &mut [u8], + ) -> Result; + + /// Encrypts a multipath QUIC packet + /// + /// Takes a `path_id` and `packet_number`, used to derive the nonce; the packet `header`, which is used as + /// the additional authenticated data; and the `payload`. The authentication tag is returned if + /// encryption succeeds. + /// + /// Fails if and only if the payload is longer than allowed by the cipher suite's AEAD algorithm. + /// + /// See . + fn encrypt_in_place_for_path( + &self, + _path_id: u32, + _packet_number: u64, + _header: &[u8], + _payload: &mut [u8], + ) -> Result { + Err(Error::EncryptError) + } + + /// Decrypt a QUIC packet + /// + /// Takes the packet `header`, which is used as the additional authenticated data, and the + /// `payload`, which includes the authentication tag. + /// + /// If the return value is `Ok`, the decrypted payload can be found in `payload`, up to the + /// length found in the return value. + fn decrypt_in_place<'a>( + &self, + packet_number: u64, + header: &[u8], + payload: &'a mut [u8], + ) -> Result<&'a [u8], Error>; + + /// Decrypt a multipath QUIC packet + /// + /// Takes a `path_id` and `packet_number`, used to derive the nonce; the packet `header`, which is used as + /// the additional authenticated data; and the `payload`. The authentication tag is returned if + /// encryption succeeds. + /// + /// If the return value is `Ok`, the decrypted payload can be found in `payload`, up to the + /// length found in the return value. + /// + /// See . + fn decrypt_in_place_for_path<'a>( + &self, + _path_id: u32, + _packet_number: u64, + _header: &[u8], + _payload: &'a mut [u8], + ) -> Result<&'a [u8], Error> { + Err(Error::DecryptError) + } + + /// Tag length for the underlying AEAD algorithm + fn tag_len(&self) -> usize; + + /// Number of QUIC messages that can be safely encrypted with a single key of this type. + /// + /// Once a `MessageEncrypter` produced for this suite has encrypted more than + /// `confidentiality_limit` messages, an attacker gains an advantage in distinguishing it + /// from an ideal pseudorandom permutation (PRP). + /// + /// This is to be set on the assumption that messages are maximally sized -- + /// 2 ** 16. For non-QUIC TCP connections see [`CipherSuiteCommon::confidentiality_limit`][csc-limit]. + /// + /// [csc-limit]: crate::crypto::CipherSuiteCommon::confidentiality_limit + fn confidentiality_limit(&self) -> u64; + + /// Number of QUIC messages that can be safely decrypted with a single key of this type + /// + /// Once a `MessageDecrypter` produced for this suite has failed to decrypt `integrity_limit` + /// messages, an attacker gains an advantage in forging messages. + /// + /// This is not relevant for TLS over TCP (which is also implemented in this crate) + /// because a single failed decryption is fatal to the connection. + /// However, this quantity is used by QUIC. + fn integrity_limit(&self) -> u64; +} + +/// Packet protection keys for bidirectional 1-RTT communication +pub struct PacketKeySet { + /// Encrypts outgoing packets + pub local: Box, + /// Decrypts incoming packets + pub remote: Box, +} + +impl PacketKeySet { + fn new(secrets: &Secrets) -> Self { + let (local, remote) = secrets.local_remote(); + let (version, alg, hkdf) = (secrets.version, secrets.quic, secrets.suite.hkdf_provider); + Self { + local: KeyBuilder::new(local, version, alg, hkdf).packet_key(), + remote: KeyBuilder::new(remote, version, alg, hkdf).packet_key(), + } + } +} + +pub(crate) struct KeyBuilder<'a> { + expander: Box, + version: Version, + alg: &'a dyn Algorithm, +} + +impl<'a> KeyBuilder<'a> { + pub(crate) fn new( + secret: &OkmBlock, + version: Version, + alg: &'a dyn Algorithm, + hkdf: &'a dyn Hkdf, + ) -> Self { + Self { + expander: hkdf.expander_for_okm(secret), + version, + alg, + } + } + + /// Derive packet keys + pub(crate) fn packet_key(&self) -> Box { + let aead_key_len = self.alg.aead_key_len(); + let packet_key = hkdf_expand_label_aead_key( + self.expander.as_ref(), + aead_key_len, + self.version.packet_key_label(), + &[], + ); + + let packet_iv = + hkdf_expand_label(self.expander.as_ref(), self.version.packet_iv_label(), &[]); + self.alg + .packet_key(packet_key, packet_iv) + } + + /// Derive header protection keys + pub(crate) fn header_protection_key(&self) -> Box { + let header_key = hkdf_expand_label_aead_key( + self.expander.as_ref(), + self.alg.aead_key_len(), + self.version.header_key_label(), + &[], + ); + self.alg + .header_protection_key(header_key) + } +} + +/// Produces QUIC initial keys from a TLS 1.3 ciphersuite and a QUIC key generation algorithm. +#[derive(Clone, Copy)] +pub struct Suite { + /// The TLS 1.3 ciphersuite used to derive keys. + pub suite: &'static Tls13CipherSuite, + /// The QUIC key generation algorithm used to derive keys. + pub quic: &'static dyn Algorithm, +} + +impl Suite { + /// Produce a set of initial keys given the connection ID, side and version + pub fn keys(&self, client_dst_connection_id: &[u8], side: Side, version: Version) -> Keys { + Keys::initial( + version, + self.suite, + self.quic, + client_dst_connection_id, + side, + ) + } +} + +/// Complete set of keys used to communicate with the peer +pub struct Keys { + /// Encrypts outgoing packets + pub local: DirectionalKeys, + /// Decrypts incoming packets + pub remote: DirectionalKeys, +} + +impl Keys { + /// Construct keys for use with initial packets + pub fn initial( + version: Version, + suite: &'static Tls13CipherSuite, + quic: &'static dyn Algorithm, + client_dst_connection_id: &[u8], + side: Side, + ) -> Self { + const CLIENT_LABEL: &[u8] = b"client in"; + const SERVER_LABEL: &[u8] = b"server in"; + let salt = version.initial_salt(); + let hs_secret = suite + .hkdf_provider + .extract_from_secret(Some(salt), client_dst_connection_id); + + let secrets = Secrets { + version, + client: hkdf_expand_label_block(hs_secret.as_ref(), CLIENT_LABEL, &[]), + server: hkdf_expand_label_block(hs_secret.as_ref(), SERVER_LABEL, &[]), + suite, + quic, + side, + }; + Self::new(&secrets) + } + + fn new(secrets: &Secrets) -> Self { + let (local, remote) = secrets.local_remote(); + Self { + local: DirectionalKeys::new(secrets.suite, secrets.quic, local, secrets.version), + remote: DirectionalKeys::new(secrets.suite, secrets.quic, remote, secrets.version), + } + } +} + +/// Key material for use in QUIC packet spaces +/// +/// QUIC uses 4 different sets of keys (and progressive key updates for long-running connections): +/// +/// * Initial: these can be created from [`Keys::initial()`] +/// * 0-RTT keys: can be retrieved from [`ConnectionCommon::zero_rtt_keys()`] +/// * Handshake: these are returned from [`ConnectionCommon::write_hs()`] after `ClientHello` and +/// `ServerHello` messages have been exchanged +/// * 1-RTT keys: these are returned from [`ConnectionCommon::write_hs()`] after the handshake is done +/// +/// Once the 1-RTT keys have been exchanged, either side may initiate a key update. Progressive +/// update keys can be obtained from the [`Secrets`] returned in [`KeyChange::OneRtt`]. Note that +/// only packet keys are updated by key updates; header protection keys remain the same. +pub enum KeyChange { + /// Keys for the handshake space + Handshake { + /// Header and packet keys for the handshake space + keys: Keys, + }, + /// Keys for 1-RTT data + OneRtt { + /// Header and packet keys for 1-RTT data + keys: Keys, + /// Secrets to derive updated keys from + next: Secrets, + }, +} + +/// QUIC protocol version +/// +/// Governs version-specific behavior in the TLS layer +#[non_exhaustive] +#[derive(Clone, Copy, Debug, Default)] +pub enum Version { + /// Draft versions 29, 30, 31 and 32 + V1Draft, + /// First stable RFC + #[default] + V1, + /// Anti-ossification variant of V1 + V2, +} + +impl Version { + fn initial_salt(self) -> &'static [u8; 20] { + match self { + Self::V1Draft => &[ + // https://datatracker.ietf.org/doc/html/draft-ietf-quic-tls-32#section-5.2 + 0xaf, 0xbf, 0xec, 0x28, 0x99, 0x93, 0xd2, 0x4c, 0x9e, 0x97, 0x86, 0xf1, 0x9c, 0x61, + 0x11, 0xe0, 0x43, 0x90, 0xa8, 0x99, + ], + Self::V1 => &[ + // https://www.rfc-editor.org/rfc/rfc9001.html#name-initial-secrets + 0x38, 0x76, 0x2c, 0xf7, 0xf5, 0x59, 0x34, 0xb3, 0x4d, 0x17, 0x9a, 0xe6, 0xa4, 0xc8, + 0x0c, 0xad, 0xcc, 0xbb, 0x7f, 0x0a, + ], + Self::V2 => &[ + // https://www.ietf.org/archive/id/draft-ietf-quic-v2-10.html#name-initial-salt-2 + 0x0d, 0xed, 0xe3, 0xde, 0xf7, 0x00, 0xa6, 0xdb, 0x81, 0x93, 0x81, 0xbe, 0x6e, 0x26, + 0x9d, 0xcb, 0xf9, 0xbd, 0x2e, 0xd9, + ], + } + } + + /// Key derivation label for packet keys. + pub(crate) fn packet_key_label(&self) -> &'static [u8] { + match self { + Self::V1Draft | Self::V1 => b"quic key", + Self::V2 => b"quicv2 key", + } + } + + /// Key derivation label for packet "IV"s. + pub(crate) fn packet_iv_label(&self) -> &'static [u8] { + match self { + Self::V1Draft | Self::V1 => b"quic iv", + Self::V2 => b"quicv2 iv", + } + } + + /// Key derivation for header keys. + pub(crate) fn header_key_label(&self) -> &'static [u8] { + match self { + Self::V1Draft | Self::V1 => b"quic hp", + Self::V2 => b"quicv2 hp", + } + } + + fn key_update_label(&self) -> &'static [u8] { + match self { + Self::V1Draft | Self::V1 => b"quic ku", + Self::V2 => b"quicv2 ku", + } + } +} + +#[cfg(test)] +mod tests { + use std::prelude::v1::*; + + use super::PacketKey; + use crate::quic::HeaderProtectionKey; + + #[test] + fn auto_traits() { + fn assert_auto() {} + assert_auto::>(); + assert_auto::>(); + } +} diff --git a/http/vendor/rustls/src/rand.rs b/http/vendor/rustls/src/rand.rs new file mode 100644 index 0000000..2359386 --- /dev/null +++ b/http/vendor/rustls/src/rand.rs @@ -0,0 +1,34 @@ +//! The single place where we generate random material for our own use. + +use alloc::vec; +use alloc::vec::Vec; + +use crate::crypto::SecureRandom; + +/// Make a [`Vec`] of the given size containing random material. +pub(crate) fn random_vec( + secure_random: &dyn SecureRandom, + len: usize, +) -> Result, GetRandomFailed> { + let mut v = vec![0; len]; + secure_random.fill(&mut v)?; + Ok(v) +} + +/// Return a uniformly random [`u32`]. +pub(crate) fn random_u32(secure_random: &dyn SecureRandom) -> Result { + let mut buf = [0u8; 4]; + secure_random.fill(&mut buf)?; + Ok(u32::from_be_bytes(buf)) +} + +/// Return a uniformly random [`u16`]. +pub(crate) fn random_u16(secure_random: &dyn SecureRandom) -> Result { + let mut buf = [0u8; 2]; + secure_random.fill(&mut buf)?; + Ok(u16::from_be_bytes(buf)) +} + +/// Random material generation failed. +#[derive(Debug)] +pub struct GetRandomFailed; diff --git a/http/vendor/rustls/src/record_layer.rs b/http/vendor/rustls/src/record_layer.rs new file mode 100644 index 0000000..8c2ea6b --- /dev/null +++ b/http/vendor/rustls/src/record_layer.rs @@ -0,0 +1,336 @@ +use alloc::boxed::Box; +use core::cmp::min; + +use crate::crypto::cipher::{InboundOpaqueMessage, MessageDecrypter, MessageEncrypter}; +use crate::error::Error; +use crate::log::trace; +use crate::msgs::message::{InboundPlainMessage, OutboundOpaqueMessage, OutboundPlainMessage}; + +#[derive(PartialEq)] +enum DirectionState { + /// No keying material. + Invalid, + + /// Keying material present, but not yet in use. + Prepared, + + /// Keying material in use. + Active, +} + +/// Record layer that tracks decryption and encryption keys. +pub(crate) struct RecordLayer { + message_encrypter: Box, + message_decrypter: Box, + write_seq_max: u64, + write_seq: u64, + read_seq: u64, + has_decrypted: bool, + encrypt_state: DirectionState, + decrypt_state: DirectionState, + + // Message encrypted with other keys may be encountered, so failures + // should be swallowed by the caller. This struct tracks the amount + // of message size this is allowed for. + trial_decryption_len: Option, +} + +impl RecordLayer { + /// Create new record layer with no keys. + pub(crate) fn new() -> Self { + Self { + message_encrypter: ::invalid(), + message_decrypter: ::invalid(), + write_seq_max: 0, + write_seq: 0, + read_seq: 0, + has_decrypted: false, + encrypt_state: DirectionState::Invalid, + decrypt_state: DirectionState::Invalid, + trial_decryption_len: None, + } + } + + /// Decrypt a TLS message. + /// + /// `encr` is a decoded message allegedly received from the peer. + /// If it can be decrypted, its decryption is returned. Otherwise, + /// an error is returned. + pub(crate) fn decrypt_incoming<'a>( + &mut self, + encr: InboundOpaqueMessage<'a>, + ) -> Result>, Error> { + if self.decrypt_state != DirectionState::Active { + return Ok(Some(Decrypted { + want_close_before_decrypt: false, + plaintext: encr.into_plain_message(), + })); + } + + // Set to `true` if the peer appears to getting close to encrypting + // too many messages with this key. + // + // Perhaps if we send an alert well before their counter wraps, a + // buggy peer won't make a terrible mistake here? + // + // Note that there's no reason to refuse to decrypt: the security + // failure has already happened. + let want_close_before_decrypt = self.read_seq == SEQ_SOFT_LIMIT; + + let encrypted_len = encr.payload.len(); + match self + .message_decrypter + .decrypt(encr, self.read_seq) + { + Ok(plaintext) => { + self.read_seq += 1; + if !self.has_decrypted { + self.has_decrypted = true; + } + Ok(Some(Decrypted { + want_close_before_decrypt, + plaintext, + })) + } + Err(Error::DecryptError) if self.doing_trial_decryption(encrypted_len) => { + trace!("Dropping undecryptable message after aborted early_data"); + Ok(None) + } + Err(err) => Err(err), + } + } + + /// Encrypt a TLS message. + /// + /// `plain` is a TLS message we'd like to send. This function + /// panics if the requisite keying material hasn't been established yet. + pub(crate) fn encrypt_outgoing( + &mut self, + plain: OutboundPlainMessage<'_>, + ) -> OutboundOpaqueMessage { + debug_assert!(self.encrypt_state == DirectionState::Active); + assert!(self.next_pre_encrypt_action() != PreEncryptAction::Refuse); + let seq = self.write_seq; + self.write_seq += 1; + self.message_encrypter + .encrypt(plain, seq) + .unwrap() + } + + /// Prepare to use the given `MessageEncrypter` for future message encryption. + /// It is not used until you call `start_encrypting`. + pub(crate) fn prepare_message_encrypter( + &mut self, + cipher: Box, + max_messages: u64, + ) { + self.message_encrypter = cipher; + self.write_seq = 0; + self.write_seq_max = min(SEQ_SOFT_LIMIT, max_messages); + self.encrypt_state = DirectionState::Prepared; + } + + /// Prepare to use the given `MessageDecrypter` for future message decryption. + /// It is not used until you call `start_decrypting`. + pub(crate) fn prepare_message_decrypter(&mut self, cipher: Box) { + self.message_decrypter = cipher; + self.read_seq = 0; + self.decrypt_state = DirectionState::Prepared; + } + + /// Start using the `MessageEncrypter` previously provided to the previous + /// call to `prepare_message_encrypter`. + pub(crate) fn start_encrypting(&mut self) { + debug_assert!(self.encrypt_state == DirectionState::Prepared); + self.encrypt_state = DirectionState::Active; + } + + /// Start using the `MessageDecrypter` previously provided to the previous + /// call to `prepare_message_decrypter`. + pub(crate) fn start_decrypting(&mut self) { + debug_assert!(self.decrypt_state == DirectionState::Prepared); + self.decrypt_state = DirectionState::Active; + } + + /// Set and start using the given `MessageEncrypter` for future outgoing + /// message encryption. + pub(crate) fn set_message_encrypter( + &mut self, + cipher: Box, + max_messages: u64, + ) { + self.prepare_message_encrypter(cipher, max_messages); + self.start_encrypting(); + } + + /// Set and start using the given `MessageDecrypter` for future incoming + /// message decryption. + pub(crate) fn set_message_decrypter(&mut self, cipher: Box) { + self.prepare_message_decrypter(cipher); + self.start_decrypting(); + self.trial_decryption_len = None; + } + + /// Set and start using the given `MessageDecrypter` for future incoming + /// message decryption, and enable "trial decryption" mode for when TLS1.3 + /// 0-RTT is attempted but rejected by the server. + pub(crate) fn set_message_decrypter_with_trial_decryption( + &mut self, + cipher: Box, + max_length: usize, + ) { + self.prepare_message_decrypter(cipher); + self.start_decrypting(); + self.trial_decryption_len = Some(max_length); + } + + pub(crate) fn finish_trial_decryption(&mut self) { + self.trial_decryption_len = None; + } + + pub(crate) fn next_pre_encrypt_action(&self) -> PreEncryptAction { + self.pre_encrypt_action(0) + } + + /// Return a remedial action when we are near to encrypting too many messages. + /// + /// `add` is added to the current sequence number. `add` as `0` means + /// "the next message processed by `encrypt_outgoing`" + pub(crate) fn pre_encrypt_action(&self, add: u64) -> PreEncryptAction { + match self.write_seq.saturating_add(add) { + v if v == self.write_seq_max => PreEncryptAction::RefreshOrClose, + SEQ_HARD_LIMIT.. => PreEncryptAction::Refuse, + _ => PreEncryptAction::Nothing, + } + } + + pub(crate) fn is_encrypting(&self) -> bool { + self.encrypt_state == DirectionState::Active + } + + /// Return true if we have ever decrypted a message. This is used in place + /// of checking the read_seq since that will be reset on key updates. + pub(crate) fn has_decrypted(&self) -> bool { + self.has_decrypted + } + + pub(crate) fn write_seq(&self) -> u64 { + self.write_seq + } + + pub(crate) fn read_seq(&self) -> u64 { + self.read_seq + } + + pub(crate) fn encrypted_len(&self, payload_len: usize) -> usize { + self.message_encrypter + .encrypted_payload_len(payload_len) + } + + fn doing_trial_decryption(&mut self, requested: usize) -> bool { + match self + .trial_decryption_len + .and_then(|value| value.checked_sub(requested)) + { + Some(remaining) => { + self.trial_decryption_len = Some(remaining); + true + } + _ => false, + } + } +} + +/// Result of decryption. +#[derive(Debug)] +pub(crate) struct Decrypted<'a> { + /// Whether the peer appears to be getting close to encrypting too many messages with this key. + pub(crate) want_close_before_decrypt: bool, + /// The decrypted message. + pub(crate) plaintext: InboundPlainMessage<'a>, +} + +#[derive(Debug, Eq, PartialEq)] +pub(crate) enum PreEncryptAction { + /// No action is needed before calling `encrypt_outgoing` + Nothing, + + /// A `key_update` request should be sent ASAP. + /// + /// If that is not possible (for example, the connection is TLS1.2), a `close_notify` + /// alert should be sent instead. + RefreshOrClose, + + /// Do not call `encrypt_outgoing` further, it will panic rather than + /// over-use the key. + Refuse, +} + +const SEQ_SOFT_LIMIT: u64 = 0xffff_ffff_ffff_0000u64; +const SEQ_HARD_LIMIT: u64 = 0xffff_ffff_ffff_fffeu64; + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_has_decrypted() { + use crate::{ContentType, ProtocolVersion}; + + struct PassThroughDecrypter; + impl MessageDecrypter for PassThroughDecrypter { + fn decrypt<'a>( + &mut self, + m: InboundOpaqueMessage<'a>, + _: u64, + ) -> Result, Error> { + Ok(m.into_plain_message()) + } + } + + // A record layer starts out invalid, having never decrypted. + let mut record_layer = RecordLayer::new(); + assert!(matches!( + record_layer.decrypt_state, + DirectionState::Invalid + )); + assert_eq!(record_layer.read_seq, 0); + assert!(!record_layer.has_decrypted()); + + // Preparing the record layer should update the decrypt state, but shouldn't affect whether it + // has decrypted. + record_layer.prepare_message_decrypter(Box::new(PassThroughDecrypter)); + assert!(matches!( + record_layer.decrypt_state, + DirectionState::Prepared + )); + assert_eq!(record_layer.read_seq, 0); + assert!(!record_layer.has_decrypted()); + + // Starting decryption should update the decrypt state, but not affect whether it has decrypted. + record_layer.start_decrypting(); + assert!(matches!(record_layer.decrypt_state, DirectionState::Active)); + assert_eq!(record_layer.read_seq, 0); + assert!(!record_layer.has_decrypted()); + + // Decrypting a message should update the read_seq and track that we have now performed + // a decryption. + record_layer + .decrypt_incoming(InboundOpaqueMessage::new( + ContentType::Handshake, + ProtocolVersion::TLSv1_2, + &mut [0xC0, 0xFF, 0xEE], + )) + .unwrap(); + assert!(matches!(record_layer.decrypt_state, DirectionState::Active)); + assert_eq!(record_layer.read_seq, 1); + assert!(record_layer.has_decrypted()); + + // Resetting the record layer message decrypter (as if a key update occurred) should reset + // the read_seq number, but not our knowledge of whether we have decrypted previously. + record_layer.set_message_decrypter(Box::new(PassThroughDecrypter)); + assert!(matches!(record_layer.decrypt_state, DirectionState::Active)); + assert_eq!(record_layer.read_seq, 0); + assert!(record_layer.has_decrypted()); + } +} diff --git a/http/vendor/rustls/src/server/builder.rs b/http/vendor/rustls/src/server/builder.rs new file mode 100644 index 0000000..daf6e09 --- /dev/null +++ b/http/vendor/rustls/src/server/builder.rs @@ -0,0 +1,132 @@ +use alloc::vec::Vec; +use core::marker::PhantomData; + +use pki_types::{CertificateDer, PrivateKeyDer}; + +use super::{ResolvesServerCert, ServerConfig, handy}; +use crate::builder::{ConfigBuilder, WantsVerifier}; +use crate::error::Error; +use crate::sign::{CertifiedKey, SingleCertAndKey}; +use crate::sync::Arc; +use crate::verify::{ClientCertVerifier, NoClientAuth}; +use crate::{NoKeyLog, compress, versions}; + +impl ConfigBuilder { + /// Choose how to verify client certificates. + pub fn with_client_cert_verifier( + self, + client_cert_verifier: Arc, + ) -> ConfigBuilder { + ConfigBuilder { + state: WantsServerCert { + versions: self.state.versions, + verifier: client_cert_verifier, + }, + provider: self.provider, + time_provider: self.time_provider, + side: PhantomData, + } + } + + /// Disable client authentication. + pub fn with_no_client_auth(self) -> ConfigBuilder { + self.with_client_cert_verifier(Arc::new(NoClientAuth)) + } +} + +/// A config builder state where the caller must supply how to provide a server certificate to +/// the connecting peer. +/// +/// For more information, see the [`ConfigBuilder`] documentation. +#[derive(Clone, Debug)] +pub struct WantsServerCert { + versions: versions::EnabledVersions, + verifier: Arc, +} + +impl ConfigBuilder { + /// Sets a single certificate chain and matching private key. This + /// certificate and key is used for all subsequent connections, + /// irrespective of things like SNI hostname. + /// + /// Note that the end-entity certificate must have the + /// [Subject Alternative Name](https://tools.ietf.org/html/rfc6125#section-4.1) + /// extension to describe, e.g., the valid DNS name. The `commonName` field is + /// disregarded. + /// + /// `cert_chain` is a vector of DER-encoded certificates. + /// `key_der` is a DER-encoded private key as PKCS#1, PKCS#8, or SEC1. The + /// `aws-lc-rs` and `ring` [`CryptoProvider`][crate::CryptoProvider]s support + /// all three encodings, but other `CryptoProviders` may not. + /// + /// This function fails if `key_der` is invalid, or if the + /// `SubjectPublicKeyInfo` from the private key does not match the public + /// key for the end-entity certificate from the `cert_chain`. + pub fn with_single_cert( + self, + cert_chain: Vec>, + key_der: PrivateKeyDer<'static>, + ) -> Result { + let certified_key = CertifiedKey::from_der(cert_chain, key_der, self.crypto_provider())?; + Ok(self.with_cert_resolver(Arc::new(SingleCertAndKey::from(certified_key)))) + } + + /// Sets a single certificate chain, matching private key and optional OCSP + /// response. This certificate and key is used for all + /// subsequent connections, irrespective of things like SNI hostname. + /// + /// `cert_chain` is a vector of DER-encoded certificates. + /// `key_der` is a DER-encoded private key as PKCS#1, PKCS#8, or SEC1. The + /// `aws-lc-rs` and `ring` [`CryptoProvider`][crate::CryptoProvider]s support + /// all three encodings, but other `CryptoProviders` may not. + /// `ocsp` is a DER-encoded OCSP response. Ignored if zero length. + /// + /// This function fails if `key_der` is invalid, or if the + /// `SubjectPublicKeyInfo` from the private key does not match the public + /// key for the end-entity certificate from the `cert_chain`. + pub fn with_single_cert_with_ocsp( + self, + cert_chain: Vec>, + key_der: PrivateKeyDer<'static>, + ocsp: Vec, + ) -> Result { + let mut certified_key = + CertifiedKey::from_der(cert_chain, key_der, self.crypto_provider())?; + if !ocsp.is_empty() { + certified_key.ocsp = Some(ocsp); + } + Ok(self.with_cert_resolver(Arc::new(SingleCertAndKey::from(certified_key)))) + } + + /// Sets a custom [`ResolvesServerCert`]. + pub fn with_cert_resolver(self, cert_resolver: Arc) -> ServerConfig { + #[cfg(feature = "tls12")] + let require_ems = self.provider.fips(); + + ServerConfig { + provider: self.provider, + verifier: self.state.verifier, + cert_resolver, + ignore_client_order: false, + max_fragment_size: None, + #[cfg(feature = "std")] + session_storage: handy::ServerSessionMemoryCache::new(256), + #[cfg(not(feature = "std"))] + session_storage: Arc::new(handy::NoServerSessionStorage {}), + ticketer: Arc::new(handy::NeverProducesTickets {}), + alpn_protocols: Vec::new(), + versions: self.state.versions, + key_log: Arc::new(NoKeyLog {}), + enable_secret_extraction: false, + max_early_data_size: 0, + send_half_rtt_data: false, + send_tls13_tickets: 2, + #[cfg(feature = "tls12")] + require_ems, + time_provider: self.time_provider, + cert_compressors: compress::default_cert_compressors().to_vec(), + cert_compression_cache: Arc::new(compress::CompressionCache::default()), + cert_decompressors: compress::default_cert_decompressors().to_vec(), + } + } +} diff --git a/http/vendor/rustls/src/server/common.rs b/http/vendor/rustls/src/server/common.rs new file mode 100644 index 0000000..8310998 --- /dev/null +++ b/http/vendor/rustls/src/server/common.rs @@ -0,0 +1,35 @@ +use pki_types::CertificateDer; + +use crate::sign; + +/// ActiveCertifiedKey wraps [`sign::CertifiedKey`] and tracks OSCP state in a single handshake. +pub(super) struct ActiveCertifiedKey<'a> { + key: &'a sign::CertifiedKey, + ocsp: Option<&'a [u8]>, +} + +impl ActiveCertifiedKey<'_> { + pub(super) fn from_certified_key(key: &sign::CertifiedKey) -> ActiveCertifiedKey<'_> { + ActiveCertifiedKey { + key, + ocsp: key.ocsp.as_deref(), + } + } + + /// Get the certificate chain + #[inline] + pub(super) fn get_cert(&self) -> &[CertificateDer<'static>] { + &self.key.cert + } + + /// Get the signing key + #[inline] + pub(super) fn get_key(&self) -> &dyn sign::SigningKey { + &*self.key.key + } + + #[inline] + pub(super) fn get_ocsp(&self) -> Option<&[u8]> { + self.ocsp + } +} diff --git a/http/vendor/rustls/src/server/handy.rs b/http/vendor/rustls/src/server/handy.rs new file mode 100644 index 0000000..ea3ec5d --- /dev/null +++ b/http/vendor/rustls/src/server/handy.rs @@ -0,0 +1,356 @@ +use alloc::vec::Vec; +use core::fmt::Debug; + +use crate::server::ClientHello; +use crate::sync::Arc; +use crate::{server, sign}; + +/// Something which never stores sessions. +#[derive(Debug)] +pub struct NoServerSessionStorage {} + +impl server::StoresServerSessions for NoServerSessionStorage { + fn put(&self, _id: Vec, _sec: Vec) -> bool { + false + } + fn get(&self, _id: &[u8]) -> Option> { + None + } + fn take(&self, _id: &[u8]) -> Option> { + None + } + fn can_cache(&self) -> bool { + false + } +} + +#[cfg(any(feature = "std", feature = "hashbrown"))] +mod cache { + use alloc::vec::Vec; + use core::fmt::{Debug, Formatter}; + + use crate::lock::Mutex; + use crate::sync::Arc; + use crate::{limited_cache, server}; + + /// An implementer of `StoresServerSessions` that stores everything + /// in memory. If enforces a limit on the number of stored sessions + /// to bound memory usage. + pub struct ServerSessionMemoryCache { + cache: Mutex, Vec>>, + } + + impl ServerSessionMemoryCache { + /// Make a new ServerSessionMemoryCache. `size` is the maximum + /// number of stored sessions, and may be rounded-up for + /// efficiency. + #[cfg(feature = "std")] + pub fn new(size: usize) -> Arc { + Arc::new(Self { + cache: Mutex::new(limited_cache::LimitedCache::new(size)), + }) + } + + /// Make a new ServerSessionMemoryCache. `size` is the maximum + /// number of stored sessions, and may be rounded-up for + /// efficiency. + #[cfg(not(feature = "std"))] + pub fn new(size: usize) -> Arc { + Arc::new(Self { + cache: Mutex::new::(limited_cache::LimitedCache::new(size)), + }) + } + } + + impl server::StoresServerSessions for ServerSessionMemoryCache { + fn put(&self, key: Vec, value: Vec) -> bool { + self.cache + .lock() + .unwrap() + .insert(key, value); + true + } + + fn get(&self, key: &[u8]) -> Option> { + self.cache + .lock() + .unwrap() + .get(key) + .cloned() + } + + fn take(&self, key: &[u8]) -> Option> { + self.cache.lock().unwrap().remove(key) + } + + fn can_cache(&self) -> bool { + true + } + } + + impl Debug for ServerSessionMemoryCache { + fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { + f.debug_struct("ServerSessionMemoryCache") + .finish() + } + } + + #[cfg(test)] + mod tests { + use std::vec; + + use super::*; + use crate::server::StoresServerSessions; + + #[test] + fn test_serversessionmemorycache_accepts_put() { + let c = ServerSessionMemoryCache::new(4); + assert!(c.put(vec![0x01], vec![0x02])); + } + + #[test] + fn test_serversessionmemorycache_persists_put() { + let c = ServerSessionMemoryCache::new(4); + assert!(c.put(vec![0x01], vec![0x02])); + assert_eq!(c.get(&[0x01]), Some(vec![0x02])); + assert_eq!(c.get(&[0x01]), Some(vec![0x02])); + } + + #[test] + fn test_serversessionmemorycache_overwrites_put() { + let c = ServerSessionMemoryCache::new(4); + assert!(c.put(vec![0x01], vec![0x02])); + assert!(c.put(vec![0x01], vec![0x04])); + assert_eq!(c.get(&[0x01]), Some(vec![0x04])); + } + + #[test] + fn test_serversessionmemorycache_drops_to_maintain_size_invariant() { + let c = ServerSessionMemoryCache::new(2); + assert!(c.put(vec![0x01], vec![0x02])); + assert!(c.put(vec![0x03], vec![0x04])); + assert!(c.put(vec![0x05], vec![0x06])); + assert!(c.put(vec![0x07], vec![0x08])); + assert!(c.put(vec![0x09], vec![0x0a])); + + let count = c.get(&[0x01]).iter().count() + + c.get(&[0x03]).iter().count() + + c.get(&[0x05]).iter().count() + + c.get(&[0x07]).iter().count() + + c.get(&[0x09]).iter().count(); + + assert!(count < 5); + } + } +} + +#[cfg(any(feature = "std", feature = "hashbrown"))] +pub use cache::ServerSessionMemoryCache; + +/// Something which never produces tickets. +#[derive(Debug)] +pub(super) struct NeverProducesTickets {} + +impl server::ProducesTickets for NeverProducesTickets { + fn enabled(&self) -> bool { + false + } + fn lifetime(&self) -> u32 { + 0 + } + fn encrypt(&self, _bytes: &[u8]) -> Option> { + None + } + fn decrypt(&self, _bytes: &[u8]) -> Option> { + None + } +} + +/// An exemplar `ResolvesServerCert` implementation that always resolves to a single +/// [RFC 7250] raw public key. +/// +/// [RFC 7250]: https://tools.ietf.org/html/rfc7250 +#[derive(Clone, Debug)] +pub struct AlwaysResolvesServerRawPublicKeys(Arc); + +impl AlwaysResolvesServerRawPublicKeys { + /// Create a new `AlwaysResolvesServerRawPublicKeys` instance. + pub fn new(certified_key: Arc) -> Self { + Self(certified_key) + } +} + +impl server::ResolvesServerCert for AlwaysResolvesServerRawPublicKeys { + fn resolve(&self, _client_hello: ClientHello<'_>) -> Option> { + Some(self.0.clone()) + } + + fn only_raw_public_keys(&self) -> bool { + true + } +} + +#[cfg(any(feature = "std", feature = "hashbrown"))] +mod sni_resolver { + use alloc::string::{String, ToString}; + use core::fmt::Debug; + + use pki_types::{DnsName, ServerName}; + + use crate::error::Error; + use crate::hash_map::HashMap; + use crate::server::ClientHello; + use crate::sync::Arc; + use crate::webpki::{ParsedCertificate, verify_server_name}; + use crate::{server, sign}; + + /// Something that resolves do different cert chains/keys based + /// on client-supplied server name (via SNI). + #[derive(Debug)] + pub struct ResolvesServerCertUsingSni { + by_name: HashMap>, + } + + impl ResolvesServerCertUsingSni { + /// Create a new and empty (i.e., knows no certificates) resolver. + pub fn new() -> Self { + Self { + by_name: HashMap::new(), + } + } + + /// Add a new `sign::CertifiedKey` to be used for the given SNI `name`. + /// + /// This function fails if `name` is not a valid DNS name, or if + /// it's not valid for the supplied certificate, or if the certificate + /// chain is syntactically faulty. + pub fn add(&mut self, name: &str, ck: sign::CertifiedKey) -> Result<(), Error> { + let server_name = { + let checked_name = DnsName::try_from(name) + .map_err(|_| Error::General("Bad DNS name".into())) + .map(|name| name.to_lowercase_owned())?; + ServerName::DnsName(checked_name) + }; + + // Check the certificate chain for validity: + // - it should be non-empty list + // - the first certificate should be parsable as a x509v3, + // - the first certificate should quote the given server name + // (if provided) + // + // These checks are not security-sensitive. They are the + // *server* attempting to detect accidental misconfiguration. + + ck.end_entity_cert() + .and_then(ParsedCertificate::try_from) + .and_then(|cert| verify_server_name(&cert, &server_name))?; + + if let ServerName::DnsName(name) = server_name { + self.by_name + .insert(name.as_ref().to_string(), Arc::new(ck)); + } + Ok(()) + } + } + + impl server::ResolvesServerCert for ResolvesServerCertUsingSni { + fn resolve(&self, client_hello: ClientHello<'_>) -> Option> { + if let Some(name) = client_hello.server_name() { + self.by_name.get(name).cloned() + } else { + // This kind of resolver requires SNI + None + } + } + } + + #[cfg(test)] + mod tests { + use super::*; + use crate::server::ResolvesServerCert; + + #[test] + fn test_resolvesservercertusingsni_requires_sni() { + let rscsni = ResolvesServerCertUsingSni::new(); + assert!( + rscsni + .resolve(ClientHello { + server_name: &None, + signature_schemes: &[], + alpn: None, + server_cert_types: None, + client_cert_types: None, + cipher_suites: &[], + certificate_authorities: None, + named_groups: None, + }) + .is_none() + ); + } + + #[test] + fn test_resolvesservercertusingsni_handles_unknown_name() { + let rscsni = ResolvesServerCertUsingSni::new(); + let name = DnsName::try_from("hello.com") + .unwrap() + .to_owned(); + assert!( + rscsni + .resolve(ClientHello { + server_name: &Some(name), + signature_schemes: &[], + alpn: None, + server_cert_types: None, + client_cert_types: None, + cipher_suites: &[], + certificate_authorities: None, + named_groups: None, + }) + .is_none() + ); + } + } +} + +#[cfg(any(feature = "std", feature = "hashbrown"))] +pub use sni_resolver::ResolvesServerCertUsingSni; + +#[cfg(test)] +mod tests { + use std::vec; + + use super::*; + use crate::server::{ProducesTickets, StoresServerSessions}; + + #[test] + fn test_noserversessionstorage_drops_put() { + let c = NoServerSessionStorage {}; + assert!(!c.put(vec![0x01], vec![0x02])); + } + + #[test] + fn test_noserversessionstorage_denies_gets() { + let c = NoServerSessionStorage {}; + c.put(vec![0x01], vec![0x02]); + assert_eq!(c.get(&[]), None); + assert_eq!(c.get(&[0x01]), None); + assert_eq!(c.get(&[0x02]), None); + } + + #[test] + fn test_noserversessionstorage_denies_takes() { + let c = NoServerSessionStorage {}; + assert_eq!(c.take(&[]), None); + assert_eq!(c.take(&[0x01]), None); + assert_eq!(c.take(&[0x02]), None); + } + + #[test] + fn test_neverproducestickets_does_nothing() { + let npt = NeverProducesTickets {}; + assert!(!npt.enabled()); + assert_eq!(0, npt.lifetime()); + assert_eq!(None, npt.encrypt(&[])); + assert_eq!(None, npt.decrypt(&[])); + } +} diff --git a/http/vendor/rustls/src/server/hs.rs b/http/vendor/rustls/src/server/hs.rs new file mode 100644 index 0000000..d98336e --- /dev/null +++ b/http/vendor/rustls/src/server/hs.rs @@ -0,0 +1,763 @@ +use alloc::borrow::ToOwned; +use alloc::boxed::Box; +use alloc::vec::Vec; + +use pki_types::DnsName; + +use super::server_conn::ServerConnectionData; +#[cfg(feature = "tls12")] +use super::tls12; +use crate::common_state::{KxState, Protocol, State}; +use crate::conn::ConnectionRandoms; +use crate::crypto::SupportedKxGroup; +use crate::enums::{ + AlertDescription, CertificateType, CipherSuite, HandshakeType, ProtocolVersion, + SignatureAlgorithm, SignatureScheme, +}; +use crate::error::{Error, PeerIncompatible, PeerMisbehaved}; +use crate::hash_hs::{HandshakeHash, HandshakeHashBuffer}; +use crate::log::{debug, trace}; +use crate::msgs::enums::{Compression, ExtensionType, NamedGroup}; +#[cfg(feature = "tls12")] +use crate::msgs::handshake::SessionId; +use crate::msgs::handshake::{ + ClientHelloPayload, HandshakePayload, KeyExchangeAlgorithm, ProtocolName, Random, + ServerExtensions, ServerExtensionsInput, ServerNamePayload, SingleProtocolName, + TransportParameters, +}; +use crate::msgs::message::{Message, MessagePayload}; +use crate::msgs::persist; +use crate::server::common::ActiveCertifiedKey; +use crate::server::{ClientHello, ServerConfig, tls13}; +use crate::sync::Arc; +use crate::{SupportedCipherSuite, suites}; + +pub(super) type NextState<'a> = Box + 'a>; +pub(super) type NextStateOrError<'a> = Result, Error>; +pub(super) type ServerContext<'a> = crate::common_state::Context<'a, ServerConnectionData>; + +pub(super) fn can_resume( + suite: SupportedCipherSuite, + sni: &Option>, + using_ems: bool, + resumedata: &persist::ServerSessionValue, +) -> bool { + // The RFCs underspecify what happens if we try to resume to + // an unoffered/varying suite. We merely don't resume in weird cases. + // + // RFC 6066 says "A server that implements this extension MUST NOT accept + // the request to resume the session if the server_name extension contains + // a different name. Instead, it proceeds with a full handshake to + // establish a new session." + // + // RFC 8446: "The server MUST ensure that it selects + // a compatible PSK (if any) and cipher suite." + resumedata.cipher_suite == suite.suite() + && (resumedata.extended_ms == using_ems || (resumedata.extended_ms && !using_ems)) + && &resumedata.sni == sni +} + +#[derive(Default)] +pub(super) struct ExtensionProcessing { + // extensions to reply with + pub(super) extensions: Box>, + #[cfg(feature = "tls12")] + pub(super) send_ticket: bool, +} + +impl ExtensionProcessing { + pub(super) fn new(extra_exts: ServerExtensionsInput<'static>) -> Self { + let ServerExtensionsInput { + transport_parameters, + } = extra_exts; + + let mut extensions = Box::new(ServerExtensions::default()); + match transport_parameters { + Some(TransportParameters::Quic(v)) => extensions.transport_parameters = Some(v), + Some(TransportParameters::QuicDraft(v)) => { + extensions.transport_parameters_draft = Some(v) + } + None => {} + } + + Self { + extensions, + #[cfg(feature = "tls12")] + send_ticket: false, + } + } + + pub(super) fn process_common( + &mut self, + config: &ServerConfig, + cx: &mut ServerContext<'_>, + ocsp_response: &mut Option<&[u8]>, + hello: &ClientHelloPayload, + resumedata: Option<&persist::ServerSessionValue>, + ) -> Result<(), Error> { + // ALPN + let our_protocols = &config.alpn_protocols; + if let Some(their_protocols) = &hello.protocols { + cx.common.alpn_protocol = our_protocols + .iter() + .find(|ours| { + their_protocols + .iter() + .any(|theirs| theirs.as_ref() == ours.as_slice()) + }) + .map(|bytes| ProtocolName::from(bytes.clone())); + if let Some(selected_protocol) = &cx.common.alpn_protocol { + debug!("Chosen ALPN protocol {selected_protocol:?}"); + + self.extensions.selected_protocol = + Some(SingleProtocolName::new(selected_protocol.clone())); + } else if !our_protocols.is_empty() { + return Err(cx.common.send_fatal_alert( + AlertDescription::NoApplicationProtocol, + Error::NoApplicationProtocol, + )); + } + } + + if cx.common.is_quic() { + // QUIC has strict ALPN, unlike TLS's more backwards-compatible behavior. RFC 9001 + // says: "The server MUST treat the inability to select a compatible application + // protocol as a connection error of type 0x0178". We judge that ALPN was desired + // (rather than some out-of-band protocol negotiation mechanism) if and only if any ALPN + // protocols were configured locally or offered by the client. This helps prevent + // successful establishment of connections between peers that can't understand + // each other. + if cx.common.alpn_protocol.is_none() + && (!our_protocols.is_empty() || hello.protocols.is_some()) + { + return Err(cx.common.send_fatal_alert( + AlertDescription::NoApplicationProtocol, + Error::NoApplicationProtocol, + )); + } + + let transport_params = hello + .transport_parameters + .as_ref() + .or(hello + .transport_parameters_draft + .as_ref()); + match transport_params { + Some(params) => cx.common.quic.params = Some(params.to_owned().into_vec()), + None => { + return Err(cx + .common + .missing_extension(PeerMisbehaved::MissingQuicTransportParameters)); + } + } + } + + let for_resume = resumedata.is_some(); + // SNI + if let (false, Some(ServerNamePayload::SingleDnsName(_))) = (for_resume, &hello.server_name) + { + self.extensions.server_name_ack = Some(()); + } + + // Send status_request response if we have one. This is not allowed + // if we're resuming, and is only triggered if we have an OCSP response + // to send. + if !for_resume + && hello + .certificate_status_request + .is_some() + { + if ocsp_response.is_some() && !cx.common.is_tls13() { + // Only TLS1.2 sends confirmation in ServerHello + self.extensions + .certificate_status_request_ack = Some(()); + } + } else { + // Throw away any OCSP response so we don't try to send it later. + ocsp_response.take(); + } + + self.validate_server_cert_type_extension(hello, config, cx)?; + self.validate_client_cert_type_extension(hello, config, cx)?; + + Ok(()) + } + + #[cfg(feature = "tls12")] + pub(super) fn process_tls12( + &mut self, + config: &ServerConfig, + hello: &ClientHelloPayload, + using_ems: bool, + ) { + // Renegotiation. + // (We don't do reneg at all, but would support the secure version if we did.) + + use crate::msgs::base::PayloadU8; + let secure_reneg_offered = hello.renegotiation_info.is_some() + || hello + .cipher_suites + .contains(&CipherSuite::TLS_EMPTY_RENEGOTIATION_INFO_SCSV); + + if secure_reneg_offered { + self.extensions.renegotiation_info = Some(PayloadU8::new(Vec::new())); + } + + // Tickets: + // If we get any SessionTicket extension and have tickets enabled, + // we send an ack. + if hello.session_ticket.is_some() && config.ticketer.enabled() { + self.send_ticket = true; + self.extensions.session_ticket_ack = Some(()); + } + + // Confirm use of EMS if offered. + if using_ems { + self.extensions + .extended_master_secret_ack = Some(()); + } + } + + fn validate_server_cert_type_extension( + &mut self, + hello: &ClientHelloPayload, + config: &ServerConfig, + cx: &mut ServerContext<'_>, + ) -> Result<(), Error> { + let client_supports = hello + .server_certificate_types + .as_deref() + .unwrap_or_default(); + + self.process_cert_type_extension( + client_supports, + config + .cert_resolver + .only_raw_public_keys(), + ExtensionType::ServerCertificateType, + cx, + ) + } + + fn validate_client_cert_type_extension( + &mut self, + hello: &ClientHelloPayload, + config: &ServerConfig, + cx: &mut ServerContext<'_>, + ) -> Result<(), Error> { + let client_supports = hello + .client_certificate_types + .as_deref() + .unwrap_or_default(); + + self.process_cert_type_extension( + client_supports, + config + .verifier + .requires_raw_public_keys(), + ExtensionType::ClientCertificateType, + cx, + ) + } + + fn process_cert_type_extension( + &mut self, + client_supports: &[CertificateType], + requires_raw_keys: bool, + extension_type: ExtensionType, + cx: &mut ServerContext<'_>, + ) -> Result<(), Error> { + debug_assert!( + extension_type == ExtensionType::ClientCertificateType + || extension_type == ExtensionType::ServerCertificateType + ); + let raw_key_negotation_result = match ( + requires_raw_keys, + client_supports.contains(&CertificateType::RawPublicKey), + client_supports.contains(&CertificateType::X509), + ) { + (true, true, _) => Ok((extension_type, CertificateType::RawPublicKey)), + (false, _, true) => Ok((extension_type, CertificateType::X509)), + (false, true, false) => Err(Error::PeerIncompatible( + PeerIncompatible::IncorrectCertificateTypeExtension, + )), + (true, false, _) => Err(Error::PeerIncompatible( + PeerIncompatible::IncorrectCertificateTypeExtension, + )), + (false, false, false) => return Ok(()), + }; + + match raw_key_negotation_result { + Ok((ExtensionType::ClientCertificateType, cert_type)) => { + self.extensions.client_certificate_type = Some(cert_type); + } + Ok((ExtensionType::ServerCertificateType, cert_type)) => { + self.extensions.server_certificate_type = Some(cert_type); + } + Err(err) => { + return Err(cx + .common + .send_fatal_alert(AlertDescription::HandshakeFailure, err)); + } + Ok((_, _)) => unreachable!(), + } + Ok(()) + } +} + +pub(super) struct ExpectClientHello { + pub(super) config: Arc, + pub(super) extra_exts: ServerExtensionsInput<'static>, + pub(super) transcript: HandshakeHashOrBuffer, + #[cfg(feature = "tls12")] + pub(super) session_id: SessionId, + #[cfg(feature = "tls12")] + pub(super) using_ems: bool, + pub(super) done_retry: bool, + pub(super) send_tickets: usize, +} + +impl ExpectClientHello { + pub(super) fn new( + config: Arc, + extra_exts: ServerExtensionsInput<'static>, + ) -> Self { + let mut transcript_buffer = HandshakeHashBuffer::new(); + + if config.verifier.offer_client_auth() { + transcript_buffer.set_client_auth_enabled(); + } + + Self { + config, + extra_exts, + transcript: HandshakeHashOrBuffer::Buffer(transcript_buffer), + #[cfg(feature = "tls12")] + session_id: SessionId::empty(), + #[cfg(feature = "tls12")] + using_ems: false, + done_retry: false, + send_tickets: 0, + } + } + + /// Continues handling of a `ClientHello` message once config and certificate are available. + pub(super) fn with_certified_key( + self, + mut sig_schemes: Vec, + client_hello: &ClientHelloPayload, + m: &Message<'_>, + cx: &mut ServerContext<'_>, + ) -> NextStateOrError<'static> { + let tls13_enabled = self + .config + .supports_version(ProtocolVersion::TLSv1_3); + let tls12_enabled = self + .config + .supports_version(ProtocolVersion::TLSv1_2); + + // Are we doing TLS1.3? + let version = if let Some(versions) = &client_hello.supported_versions { + if versions.tls13 && tls13_enabled { + ProtocolVersion::TLSv1_3 + } else if !versions.tls12 || !tls12_enabled { + return Err(cx.common.send_fatal_alert( + AlertDescription::ProtocolVersion, + PeerIncompatible::Tls12NotOfferedOrEnabled, + )); + } else if cx.common.is_quic() { + return Err(cx.common.send_fatal_alert( + AlertDescription::ProtocolVersion, + PeerIncompatible::Tls13RequiredForQuic, + )); + } else { + ProtocolVersion::TLSv1_2 + } + } else if u16::from(client_hello.client_version) < u16::from(ProtocolVersion::TLSv1_2) { + return Err(cx.common.send_fatal_alert( + AlertDescription::ProtocolVersion, + PeerIncompatible::Tls12NotOffered, + )); + } else if !tls12_enabled && tls13_enabled { + return Err(cx.common.send_fatal_alert( + AlertDescription::ProtocolVersion, + PeerIncompatible::SupportedVersionsExtensionRequired, + )); + } else if cx.common.is_quic() { + return Err(cx.common.send_fatal_alert( + AlertDescription::ProtocolVersion, + PeerIncompatible::Tls13RequiredForQuic, + )); + } else { + ProtocolVersion::TLSv1_2 + }; + + cx.common.negotiated_version = Some(version); + + // We communicate to the upper layer what kind of key they should choose + // via the sigschemes value. Clients tend to treat this extension + // orthogonally to offered ciphersuites (even though, in TLS1.2 it is not). + // So: reduce the offered sigschemes to those compatible with the + // intersection of ciphersuites. + let client_suites = self + .config + .provider + .cipher_suites + .iter() + .copied() + .filter(|scs| { + client_hello + .cipher_suites + .contains(&scs.suite()) + }) + .collect::>(); + + sig_schemes + .retain(|scheme| suites::compatible_sigscheme_for_suites(*scheme, &client_suites)); + + // We adhere to the TLS 1.2 RFC by not exposing this to the cert resolver if TLS version is 1.2 + let certificate_authorities = match version { + ProtocolVersion::TLSv1_2 => None, + _ => client_hello + .certificate_authority_names + .as_deref(), + }; + // Choose a certificate. + let certkey = { + let client_hello = ClientHello { + server_name: &cx.data.sni, + signature_schemes: &sig_schemes, + alpn: client_hello.protocols.as_ref(), + client_cert_types: client_hello + .client_certificate_types + .as_deref(), + server_cert_types: client_hello + .server_certificate_types + .as_deref(), + cipher_suites: &client_hello.cipher_suites, + certificate_authorities, + named_groups: client_hello.named_groups.as_deref(), + }; + trace!("Resolving server certificate: {client_hello:#?}"); + + let certkey = self + .config + .cert_resolver + .resolve(client_hello); + + certkey.ok_or_else(|| { + cx.common.send_fatal_alert( + AlertDescription::AccessDenied, + Error::General("no server certificate chain resolved".to_owned()), + ) + })? + }; + let certkey = ActiveCertifiedKey::from_certified_key(&certkey); + + let (suite, skxg) = self + .choose_suite_and_kx_group( + version, + certkey.get_key().algorithm(), + cx.common.protocol, + client_hello + .named_groups + .as_deref() + .unwrap_or_default(), + &client_hello.cipher_suites, + ) + .map_err(|incompat| { + cx.common + .send_fatal_alert(AlertDescription::HandshakeFailure, incompat) + })?; + + debug!("decided upon suite {suite:?}"); + cx.common.suite = Some(suite); + cx.common.kx_state = KxState::Start(skxg); + + // Start handshake hash. + let starting_hash = suite.hash_provider(); + let transcript = match self.transcript { + HandshakeHashOrBuffer::Buffer(inner) => inner.start_hash(starting_hash), + HandshakeHashOrBuffer::Hash(inner) + if inner.algorithm() == starting_hash.algorithm() => + { + inner + } + _ => { + return Err(cx.common.send_fatal_alert( + AlertDescription::IllegalParameter, + PeerMisbehaved::HandshakeHashVariedAfterRetry, + )); + } + }; + + // Save their Random. + let randoms = ConnectionRandoms::new( + client_hello.random, + Random::new(self.config.provider.secure_random)?, + ); + match suite { + SupportedCipherSuite::Tls13(suite) => tls13::CompleteClientHelloHandling { + config: self.config, + transcript, + suite, + randoms, + done_retry: self.done_retry, + send_tickets: self.send_tickets, + extra_exts: self.extra_exts, + } + .handle_client_hello(cx, certkey, m, client_hello, skxg, sig_schemes), + #[cfg(feature = "tls12")] + SupportedCipherSuite::Tls12(suite) => tls12::CompleteClientHelloHandling { + config: self.config, + transcript, + session_id: self.session_id, + suite, + using_ems: self.using_ems, + randoms, + send_ticket: self.send_tickets > 0, + extra_exts: self.extra_exts, + } + .handle_client_hello( + cx, + certkey, + m, + client_hello, + skxg, + sig_schemes, + tls13_enabled, + ), + } + } + + fn choose_suite_and_kx_group( + &self, + selected_version: ProtocolVersion, + sig_key_algorithm: SignatureAlgorithm, + protocol: Protocol, + client_groups: &[NamedGroup], + client_suites: &[CipherSuite], + ) -> Result<(SupportedCipherSuite, &'static dyn SupportedKxGroup), PeerIncompatible> { + // Determine which `KeyExchangeAlgorithm`s are theoretically possible, based + // on the offered and supported groups. + let mut ecdhe_possible = false; + let mut ffdhe_possible = false; + let mut ffdhe_offered = false; + let mut supported_groups = Vec::with_capacity(client_groups.len()); + + for offered_group in client_groups { + let supported = self + .config + .provider + .kx_groups + .iter() + .find(|skxg| { + skxg.usable_for_version(selected_version) && skxg.name() == *offered_group + }); + + match offered_group.key_exchange_algorithm() { + KeyExchangeAlgorithm::DHE => { + ffdhe_possible |= supported.is_some(); + ffdhe_offered = true; + } + KeyExchangeAlgorithm::ECDHE => { + ecdhe_possible |= supported.is_some(); + } + } + + supported_groups.push(supported); + } + + let first_supported_dhe_kxg = if selected_version == ProtocolVersion::TLSv1_2 { + // https://datatracker.ietf.org/doc/html/rfc7919#section-4 (paragraph 2) + let first_supported_dhe_kxg = self + .config + .provider + .kx_groups + .iter() + .find(|skxg| skxg.name().key_exchange_algorithm() == KeyExchangeAlgorithm::DHE); + ffdhe_possible |= !ffdhe_offered && first_supported_dhe_kxg.is_some(); + first_supported_dhe_kxg + } else { + // In TLS1.3, the server may only directly negotiate a group. + None + }; + + if !ecdhe_possible && !ffdhe_possible { + return Err(PeerIncompatible::NoKxGroupsInCommon); + } + + let mut suitable_suites_iter = self + .config + .provider + .cipher_suites + .iter() + .filter(|suite| { + // Reduce our supported ciphersuites by the certified key's algorithm. + suite.usable_for_signature_algorithm(sig_key_algorithm) + // And version + && suite.version().version == selected_version + // And protocol + && suite.usable_for_protocol(protocol) + // And support one of key exchange groups + && (ecdhe_possible && suite.usable_for_kx_algorithm(KeyExchangeAlgorithm::ECDHE) + || ffdhe_possible && suite.usable_for_kx_algorithm(KeyExchangeAlgorithm::DHE)) + }); + + // RFC 7919 (https://datatracker.ietf.org/doc/html/rfc7919#section-4) requires us to send + // the InsufficientSecurity alert in case we don't recognize client's FFDHE groups (i.e., + // `suitable_suites` becomes empty). But that does not make a lot of sense (e.g., client + // proposes FFDHE4096 and we only support FFDHE2048), so we ignore that requirement here, + // and continue to send HandshakeFailure. + + let suite = if self.config.ignore_client_order { + suitable_suites_iter.find(|suite| client_suites.contains(&suite.suite())) + } else { + let suitable_suites = suitable_suites_iter.collect::>(); + client_suites + .iter() + .find_map(|client_suite| { + suitable_suites + .iter() + .find(|x| *client_suite == x.suite()) + }) + .copied() + } + .ok_or(PeerIncompatible::NoCipherSuitesInCommon)?; + + // Finally, choose a key exchange group that is compatible with the selected cipher + // suite. + let maybe_skxg = supported_groups + .iter() + .find_map(|maybe_skxg| match maybe_skxg { + Some(skxg) => suite + .usable_for_kx_algorithm(skxg.name().key_exchange_algorithm()) + .then_some(*skxg), + None => None, + }); + + if selected_version == ProtocolVersion::TLSv1_3 { + // This unwrap is structurally guaranteed by the early return for `!ffdhe_possible && !ecdhe_possible` + return Ok((*suite, *maybe_skxg.unwrap())); + } + + // For TLS1.2, the server can unilaterally choose a DHE group if it has one and + // there was no better option. + match maybe_skxg { + Some(skxg) => Ok((*suite, *skxg)), + None if suite.usable_for_kx_algorithm(KeyExchangeAlgorithm::DHE) => { + // If kx for the selected cipher suite is DHE and no DHE groups are specified in the extension, + // the server is free to choose DHE params, we choose the first DHE kx group of the provider. + if let Some(server_selected_ffdhe_skxg) = first_supported_dhe_kxg { + Ok((*suite, *server_selected_ffdhe_skxg)) + } else { + Err(PeerIncompatible::NoKxGroupsInCommon) + } + } + None => Err(PeerIncompatible::NoKxGroupsInCommon), + } + } +} + +impl State for ExpectClientHello { + fn handle<'m>( + self: Box, + cx: &mut ServerContext<'_>, + m: Message<'m>, + ) -> NextStateOrError<'m> + where + Self: 'm, + { + let (client_hello, sig_schemes) = process_client_hello(&m, self.done_retry, cx)?; + self.with_certified_key(sig_schemes, client_hello, &m, cx) + } + + fn into_owned(self: Box) -> NextState<'static> { + self + } +} + +/// Configuration-independent validation of a `ClientHello` message. +/// +/// This represents the first part of the `ClientHello` handling, where we do all validation that +/// doesn't depend on a `ServerConfig` being available and extract everything needed to build a +/// [`ClientHello`] value for a [`ResolvesServerCert`]. +/// +/// Note that this will modify `data.sni` even if config or certificate resolution fail. +/// +/// [`ResolvesServerCert`]: crate::server::ResolvesServerCert +pub(super) fn process_client_hello<'m>( + m: &'m Message<'m>, + done_retry: bool, + cx: &mut ServerContext<'_>, +) -> Result<(&'m ClientHelloPayload, Vec), Error> { + let client_hello = + require_handshake_msg!(m, HandshakeType::ClientHello, HandshakePayload::ClientHello)?; + trace!("we got a clienthello {client_hello:?}"); + + if !client_hello + .compression_methods + .contains(&Compression::Null) + { + return Err(cx.common.send_fatal_alert( + AlertDescription::IllegalParameter, + PeerIncompatible::NullCompressionRequired, + )); + } + + // No handshake messages should follow this one in this flight. + cx.common.check_aligned_handshake()?; + + // Extract and validate the SNI DNS name, if any, before giving it to + // the cert resolver. In particular, if it is invalid then we should + // send an Illegal Parameter alert instead of the Internal Error alert + // (or whatever) that we'd send if this were checked later or in a + // different way. + // + // [RFC6066][] specifies that literal IP addresses are illegal in + // `ServerName`s with a `name_type` of `host_name`. + // + // Some clients incorrectly send such extensions: we choose to + // successfully parse these (into `ServerNamePayload::IpAddress`) + // but then act like the client sent no `server_name` extension. + // + // [RFC6066]: https://datatracker.ietf.org/doc/html/rfc6066#section-3 + let sni = match &client_hello.server_name { + Some(ServerNamePayload::SingleDnsName(dns_name)) => Some(dns_name.to_lowercase_owned()), + Some(ServerNamePayload::IpAddress) => None, + Some(ServerNamePayload::Invalid) => { + return Err(cx.common.send_fatal_alert( + AlertDescription::IllegalParameter, + PeerMisbehaved::ServerNameMustContainOneHostName, + )); + } + None => None, + }; + + // save only the first SNI + if let (Some(sni), false) = (&sni, done_retry) { + // Save the SNI into the session. + // The SNI hostname is immutable once set. + assert!(cx.data.sni.is_none()); + cx.data.sni = Some(sni.clone()); + } else if cx.data.sni != sni { + return Err(PeerMisbehaved::ServerNameDifferedOnRetry.into()); + } + + let sig_schemes = client_hello + .signature_schemes + .as_ref() + .ok_or_else(|| { + cx.common.send_fatal_alert( + AlertDescription::HandshakeFailure, + PeerIncompatible::SignatureAlgorithmsExtensionRequired, + ) + })?; + + Ok((client_hello, sig_schemes.to_owned())) +} + +pub(crate) enum HandshakeHashOrBuffer { + Buffer(HandshakeHashBuffer), + Hash(HandshakeHash), +} diff --git a/http/vendor/rustls/src/server/server_conn.rs b/http/vendor/rustls/src/server/server_conn.rs new file mode 100644 index 0000000..92b3864 --- /dev/null +++ b/http/vendor/rustls/src/server/server_conn.rs @@ -0,0 +1,1285 @@ +use alloc::boxed::Box; +use alloc::vec::Vec; +use core::fmt; +use core::fmt::{Debug, Formatter}; +use core::marker::PhantomData; +use core::ops::{Deref, DerefMut}; +#[cfg(feature = "std")] +use std::io; + +use pki_types::{DnsName, UnixTime}; + +use super::hs; +#[cfg(feature = "std")] +use crate::WantsVerifier; +use crate::builder::ConfigBuilder; +use crate::common_state::{CommonState, Side}; +#[cfg(feature = "std")] +use crate::common_state::{Protocol, State}; +use crate::conn::{ConnectionCommon, ConnectionCore, UnbufferedConnectionCommon}; +#[cfg(doc)] +use crate::crypto; +use crate::crypto::CryptoProvider; +use crate::enums::{CertificateType, CipherSuite, ProtocolVersion, SignatureScheme}; +use crate::error::Error; +use crate::kernel::KernelConnection; +use crate::log::trace; +use crate::msgs::base::Payload; +use crate::msgs::handshake::{ClientHelloPayload, ProtocolName, ServerExtensionsInput}; +use crate::msgs::message::Message; +use crate::suites::ExtractedSecrets; +use crate::sync::Arc; +#[cfg(feature = "std")] +use crate::time_provider::DefaultTimeProvider; +use crate::time_provider::TimeProvider; +use crate::vecbuf::ChunkVecBuffer; +use crate::{ + DistinguishedName, KeyLog, NamedGroup, WantsVersions, compress, sign, verify, versions, +}; + +/// A trait for the ability to store server session data. +/// +/// The keys and values are opaque. +/// +/// Inserted keys are randomly chosen by the library and have +/// no internal structure (in other words, you may rely on all +/// bits being uniformly random). Queried keys are untrusted data. +/// +/// Both the keys and values should be treated as +/// **highly sensitive data**, containing enough key material +/// to break all security of the corresponding sessions. +/// +/// Implementations can be lossy (in other words, forgetting +/// key/value pairs) without any negative security consequences. +/// +/// However, note that `take` **must** reliably delete a returned +/// value. If it does not, there may be security consequences. +/// +/// `put` and `take` are mutating operations; this isn't expressed +/// in the type system to allow implementations freedom in +/// how to achieve interior mutability. `Mutex` is a common +/// choice. +pub trait StoresServerSessions: Debug + Send + Sync { + /// Store session secrets encoded in `value` against `key`, + /// overwrites any existing value against `key`. Returns `true` + /// if the value was stored. + fn put(&self, key: Vec, value: Vec) -> bool; + + /// Find a value with the given `key`. Return it, or None + /// if it doesn't exist. + fn get(&self, key: &[u8]) -> Option>; + + /// Find a value with the given `key`. Return it and delete it; + /// or None if it doesn't exist. + fn take(&self, key: &[u8]) -> Option>; + + /// Whether the store can cache another session. This is used to indicate to clients + /// whether their session can be resumed; the implementation is not required to remember + /// a session even if it returns `true` here. + fn can_cache(&self) -> bool; +} + +/// A trait for the ability to encrypt and decrypt tickets. +pub trait ProducesTickets: Debug + Send + Sync { + /// Returns true if this implementation will encrypt/decrypt + /// tickets. Should return false if this is a dummy + /// implementation: the server will not send the SessionTicket + /// extension and will not call the other functions. + fn enabled(&self) -> bool; + + /// Returns the lifetime in seconds of tickets produced now. + /// The lifetime is provided as a hint to clients that the + /// ticket will not be useful after the given time. + /// + /// This lifetime must be implemented by key rolling and + /// erasure, *not* by storing a lifetime in the ticket. + /// + /// The objective is to limit damage to forward secrecy caused + /// by tickets, not just limiting their lifetime. + fn lifetime(&self) -> u32; + + /// Encrypt and authenticate `plain`, returning the resulting + /// ticket. Return None if `plain` cannot be encrypted for + /// some reason: an empty ticket will be sent and the connection + /// will continue. + fn encrypt(&self, plain: &[u8]) -> Option>; + + /// Decrypt `cipher`, validating its authenticity protection + /// and recovering the plaintext. `cipher` is fully attacker + /// controlled, so this decryption must be side-channel free, + /// panic-proof, and otherwise bullet-proof. If the decryption + /// fails, return None. + fn decrypt(&self, cipher: &[u8]) -> Option>; +} + +/// How to choose a certificate chain and signing key for use +/// in server authentication. +/// +/// This is suitable when selecting a certificate does not require +/// I/O or when the application is using blocking I/O anyhow. +/// +/// For applications that use async I/O and need to do I/O to choose +/// a certificate (for instance, fetching a certificate from a data store), +/// the [`Acceptor`] interface is more suitable. +pub trait ResolvesServerCert: Debug + Send + Sync { + /// Choose a certificate chain and matching key given simplified + /// ClientHello information. + /// + /// Return `None` to abort the handshake. + fn resolve(&self, client_hello: ClientHello<'_>) -> Option>; + + /// Return true when the server only supports raw public keys. + fn only_raw_public_keys(&self) -> bool { + false + } +} + +/// A struct representing the received Client Hello +#[derive(Debug)] +pub struct ClientHello<'a> { + pub(super) server_name: &'a Option>, + pub(super) signature_schemes: &'a [SignatureScheme], + pub(super) alpn: Option<&'a Vec>, + pub(super) server_cert_types: Option<&'a [CertificateType]>, + pub(super) client_cert_types: Option<&'a [CertificateType]>, + pub(super) cipher_suites: &'a [CipherSuite], + /// The [certificate_authorities] extension, if it was sent by the client. + /// + /// [certificate_authorities]: https://datatracker.ietf.org/doc/html/rfc8446#section-4.2.4 + pub(super) certificate_authorities: Option<&'a [DistinguishedName]>, + pub(super) named_groups: Option<&'a [NamedGroup]>, +} + +impl<'a> ClientHello<'a> { + /// Get the server name indicator. + /// + /// Returns `None` if the client did not supply a SNI. + pub fn server_name(&self) -> Option<&str> { + self.server_name + .as_ref() + .map( as AsRef>::as_ref) + } + + /// Get the compatible signature schemes. + /// + /// Returns standard-specified default if the client omitted this extension. + pub fn signature_schemes(&self) -> &[SignatureScheme] { + self.signature_schemes + } + + /// Get the ALPN protocol identifiers submitted by the client. + /// + /// Returns `None` if the client did not include an ALPN extension. + /// + /// Application Layer Protocol Negotiation (ALPN) is a TLS extension that lets a client + /// submit a set of identifiers that each a represent an application-layer protocol. + /// The server will then pick its preferred protocol from the set submitted by the client. + /// Each identifier is represented as a byte array, although common values are often ASCII-encoded. + /// See the official RFC-7301 specifications at + /// for more information on ALPN. + /// + /// For example, a HTTP client might specify "http/1.1" and/or "h2". Other well-known values + /// are listed in the at IANA registry at + /// . + /// + /// The server can specify supported ALPN protocols by setting [`ServerConfig::alpn_protocols`]. + /// During the handshake, the server will select the first protocol configured that the client supports. + pub fn alpn(&self) -> Option> { + self.alpn.map(|protocols| { + protocols + .iter() + .map(|proto| proto.as_ref()) + }) + } + + /// Get cipher suites. + pub fn cipher_suites(&self) -> &[CipherSuite] { + self.cipher_suites + } + + /// Get the server certificate types offered in the ClientHello. + /// + /// Returns `None` if the client did not include a certificate type extension. + pub fn server_cert_types(&self) -> Option<&'a [CertificateType]> { + self.server_cert_types + } + + /// Get the client certificate types offered in the ClientHello. + /// + /// Returns `None` if the client did not include a certificate type extension. + pub fn client_cert_types(&self) -> Option<&'a [CertificateType]> { + self.client_cert_types + } + + /// Get the [certificate_authorities] extension sent by the client. + /// + /// Returns `None` if the client did not send this extension. + /// + /// [certificate_authorities]: https://datatracker.ietf.org/doc/html/rfc8446#section-4.2.4 + pub fn certificate_authorities(&self) -> Option<&'a [DistinguishedName]> { + self.certificate_authorities + } + + /// Get the [`named_groups`] extension sent by the client. + /// + /// This means different things in different versions of TLS: + /// + /// Originally it was introduced as the "[`elliptic_curves`]" extension for TLS1.2. + /// It described the elliptic curves supported by a client for all purposes: key + /// exchange, signature verification (for server authentication), and signing (for + /// client auth). Later [RFC7919] extended this to include FFDHE "named groups", + /// but FFDHE groups in this context only relate to key exchange. + /// + /// In TLS1.3 it was renamed to "[`named_groups`]" and now describes all types + /// of key exchange mechanisms, and does not relate at all to elliptic curves + /// used for signatures. + /// + /// [`elliptic_curves`]: https://datatracker.ietf.org/doc/html/rfc4492#section-5.1.1 + /// [RFC7919]: https://datatracker.ietf.org/doc/html/rfc7919#section-2 + /// [`named_groups`]:https://datatracker.ietf.org/doc/html/rfc8446#section-4.2.7 + pub fn named_groups(&self) -> Option<&'a [NamedGroup]> { + self.named_groups + } +} + +/// Common configuration for a set of server sessions. +/// +/// Making one of these is cheap, though one of the inputs may be expensive: gathering trust roots +/// from the operating system to add to the [`RootCertStore`] passed to a `ClientCertVerifier` +/// builder may take on the order of a few hundred milliseconds. +/// +/// These must be created via the [`ServerConfig::builder()`] or [`ServerConfig::builder_with_provider()`] +/// function. +/// +/// # Defaults +/// +/// * [`ServerConfig::max_fragment_size`]: the default is `None` (meaning 16kB). +/// * [`ServerConfig::session_storage`]: if the `std` feature is enabled, the default stores 256 +/// sessions in memory. If the `std` feature is not enabled, the default is to not store any +/// sessions. In a no-std context, by enabling the `hashbrown` feature you may provide your +/// own `session_storage` using [`ServerSessionMemoryCache`] and a `crate::lock::MakeMutex` +/// implementation. +/// * [`ServerConfig::alpn_protocols`]: the default is empty -- no ALPN protocol is negotiated. +/// * [`ServerConfig::key_log`]: key material is not logged. +/// * [`ServerConfig::send_tls13_tickets`]: 2 tickets are sent. +/// * [`ServerConfig::cert_compressors`]: depends on the crate features, see [`compress::default_cert_compressors()`]. +/// * [`ServerConfig::cert_compression_cache`]: caches the most recently used 4 compressions +/// * [`ServerConfig::cert_decompressors`]: depends on the crate features, see [`compress::default_cert_decompressors()`]. +/// +/// # Sharing resumption storage between `ServerConfig`s +/// +/// In a program using many `ServerConfig`s it may improve resumption rates +/// (which has a significant impact on connection performance) if those +/// configs share [`ServerConfig::session_storage`] or [`ServerConfig::ticketer`]. +/// +/// However, caution is needed: other fields influence the security of a session +/// and resumption between them can be surprising. If sharing +/// [`ServerConfig::session_storage`] or [`ServerConfig::ticketer`] between two +/// `ServerConfig`s, you should also evaluate the following fields and ensure +/// they are equivalent: +/// +/// * `ServerConfig::verifier` -- client authentication requirements, +/// * [`ServerConfig::cert_resolver`] -- server identities. +/// +/// To illustrate, imagine two `ServerConfig`s `A` and `B`. `A` requires +/// client authentication, `B` does not. If `A` and `B` shared a resumption store, +/// it would be possible for a session originated by `B` (that is, an unauthenticated client) +/// to be inserted into the store, and then resumed by `A`. This would give a false +/// impression to the user of `A` that the client was authenticated. This is possible +/// whether the resumption is performed statefully (via [`ServerConfig::session_storage`]) +/// or statelessly (via [`ServerConfig::ticketer`]). +/// +/// _Unlike_ `ClientConfig`, rustls does not enforce any policy here. +/// +/// [`RootCertStore`]: crate::RootCertStore +/// [`ServerSessionMemoryCache`]: crate::server::handy::ServerSessionMemoryCache +#[derive(Clone, Debug)] +pub struct ServerConfig { + /// Source of randomness and other crypto. + pub(super) provider: Arc, + + /// Ignore the client's ciphersuite order. Instead, + /// choose the top ciphersuite in the server list + /// which is supported by the client. + pub ignore_client_order: bool, + + /// The maximum size of plaintext input to be emitted in a single TLS record. + /// A value of None is equivalent to the [TLS maximum] of 16 kB. + /// + /// rustls enforces an arbitrary minimum of 32 bytes for this field. + /// Out of range values are reported as errors from [ServerConnection::new]. + /// + /// Setting this value to a little less than the TCP MSS may improve latency + /// for stream-y workloads. + /// + /// [TLS maximum]: https://datatracker.ietf.org/doc/html/rfc8446#section-5.1 + /// [ServerConnection::new]: crate::server::ServerConnection::new + pub max_fragment_size: Option, + + /// How to store client sessions. + /// + /// See [ServerConfig#sharing-resumption-storage-between-serverconfigs] + /// for a warning related to this field. + pub session_storage: Arc, + + /// How to produce tickets. + /// + /// See [ServerConfig#sharing-resumption-storage-between-serverconfigs] + /// for a warning related to this field. + pub ticketer: Arc, + + /// How to choose a server cert and key. This is usually set by + /// [ConfigBuilder::with_single_cert] or [ConfigBuilder::with_cert_resolver]. + /// For async applications, see also [Acceptor]. + pub cert_resolver: Arc, + + /// Protocol names we support, most preferred first. + /// If empty we don't do ALPN at all. + pub alpn_protocols: Vec>, + + /// Supported protocol versions, in no particular order. + /// The default is all supported versions. + pub(super) versions: versions::EnabledVersions, + + /// How to verify client certificates. + pub(super) verifier: Arc, + + /// How to output key material for debugging. The default + /// does nothing. + pub key_log: Arc, + + /// Allows traffic secrets to be extracted after the handshake, + /// e.g. for kTLS setup. + pub enable_secret_extraction: bool, + + /// Amount of early data to accept for sessions created by + /// this config. Specify 0 to disable early data. The + /// default is 0. + /// + /// Read the early data via [`ServerConnection::early_data`]. + /// + /// The units for this are _both_ plaintext bytes, _and_ ciphertext + /// bytes, depending on whether the server accepts a client's early_data + /// or not. It is therefore recommended to include some slop in + /// this value to account for the unknown amount of ciphertext + /// expansion in the latter case. + pub max_early_data_size: u32, + + /// Whether the server should send "0.5RTT" data. This means the server + /// sends data after its first flight of handshake messages, without + /// waiting for the client to complete the handshake. + /// + /// This can improve TTFB latency for either server-speaks-first protocols, + /// or client-speaks-first protocols when paired with "0RTT" data. This + /// comes at the cost of a subtle weakening of the normal handshake + /// integrity guarantees that TLS provides. Note that the initial + /// `ClientHello` is indirectly authenticated because it is included + /// in the transcript used to derive the keys used to encrypt the data. + /// + /// This only applies to TLS1.3 connections. TLS1.2 connections cannot + /// do this optimisation and this setting is ignored for them. It is + /// also ignored for TLS1.3 connections that even attempt client + /// authentication. + /// + /// This defaults to false. This means the first application data + /// sent by the server comes after receiving and validating the client's + /// handshake up to the `Finished` message. This is the safest option. + pub send_half_rtt_data: bool, + + /// How many TLS1.3 tickets to send immediately after a successful + /// handshake. + /// + /// Because TLS1.3 tickets are single-use, this allows + /// a client to perform multiple resumptions. + /// + /// The default is 2. + /// + /// If this is 0, no tickets are sent and clients will not be able to + /// do any resumption. + pub send_tls13_tickets: usize, + + /// If set to `true`, requires the client to support the extended + /// master secret extraction method defined in [RFC 7627]. + /// + /// The default is `true` if the configured [`CryptoProvider`] is + /// FIPS-compliant (i.e., [`CryptoProvider::fips()`] returns `true`), + /// `false` otherwise. + /// + /// It must be set to `true` to meet FIPS requirement mentioned in section + /// **D.Q Transition of the TLS 1.2 KDF to Support the Extended Master + /// Secret** from [FIPS 140-3 IG.pdf]. + /// + /// [RFC 7627]: https://datatracker.ietf.org/doc/html/rfc7627 + /// [FIPS 140-3 IG.pdf]: https://csrc.nist.gov/csrc/media/Projects/cryptographic-module-validation-program/documents/fips%20140-3/FIPS%20140-3%20IG.pdf + #[cfg(feature = "tls12")] + pub require_ems: bool, + + /// Provides the current system time + pub time_provider: Arc, + + /// How to compress the server's certificate chain. + /// + /// If a client supports this extension, and advertises support + /// for one of the compression algorithms included here, the + /// server certificate will be compressed according to [RFC8779]. + /// + /// This only applies to TLS1.3 connections. It is ignored for + /// TLS1.2 connections. + /// + /// [RFC8779]: https://datatracker.ietf.org/doc/rfc8879/ + pub cert_compressors: Vec<&'static dyn compress::CertCompressor>, + + /// Caching for compressed certificates. + /// + /// This is optional: [`compress::CompressionCache::Disabled`] gives + /// a cache that does no caching. + pub cert_compression_cache: Arc, + + /// How to decompress the clients's certificate chain. + /// + /// If this is non-empty, the [RFC8779] certificate compression + /// extension is offered when requesting client authentication, + /// and any compressed certificates are transparently decompressed + /// during the handshake. + /// + /// This only applies to TLS1.3 connections. It is ignored for + /// TLS1.2 connections. + /// + /// [RFC8779]: https://datatracker.ietf.org/doc/rfc8879/ + pub cert_decompressors: Vec<&'static dyn compress::CertDecompressor>, +} + +impl ServerConfig { + /// Create a builder for a server configuration with + /// [the process-default `CryptoProvider`][CryptoProvider#using-the-per-process-default-cryptoprovider] + /// and safe protocol version defaults. + /// + /// For more information, see the [`ConfigBuilder`] documentation. + #[cfg(feature = "std")] + pub fn builder() -> ConfigBuilder { + Self::builder_with_protocol_versions(versions::DEFAULT_VERSIONS) + } + + /// Create a builder for a server configuration with + /// [the process-default `CryptoProvider`][CryptoProvider#using-the-per-process-default-cryptoprovider] + /// and the provided protocol versions. + /// + /// Panics if + /// - the supported versions are not compatible with the provider (eg. + /// the combination of ciphersuites supported by the provider and supported + /// versions lead to zero cipher suites being usable), + /// - if a `CryptoProvider` cannot be resolved using a combination of + /// the crate features and process default. + /// + /// For more information, see the [`ConfigBuilder`] documentation. + #[cfg(feature = "std")] + pub fn builder_with_protocol_versions( + versions: &[&'static versions::SupportedProtocolVersion], + ) -> ConfigBuilder { + // Safety assumptions: + // 1. that the provider has been installed (explicitly or implicitly) + // 2. that the process-level default provider is usable with the supplied protocol versions. + Self::builder_with_provider( + CryptoProvider::get_default_or_install_from_crate_features().clone(), + ) + .with_protocol_versions(versions) + .unwrap() + } + + /// Create a builder for a server configuration with a specific [`CryptoProvider`]. + /// + /// This will use the provider's configured ciphersuites. You must additionally choose + /// which protocol versions to enable, using `with_protocol_versions` or + /// `with_safe_default_protocol_versions` and handling the `Result` in case a protocol + /// version is not supported by the provider's ciphersuites. + /// + /// For more information, see the [`ConfigBuilder`] documentation. + #[cfg(feature = "std")] + pub fn builder_with_provider( + provider: Arc, + ) -> ConfigBuilder { + ConfigBuilder { + state: WantsVersions {}, + provider, + time_provider: Arc::new(DefaultTimeProvider), + side: PhantomData, + } + } + + /// Create a builder for a server configuration with no default implementation details. + /// + /// This API must be used by `no_std` users. + /// + /// You must provide a specific [`TimeProvider`]. + /// + /// You must provide a specific [`CryptoProvider`]. + /// + /// This will use the provider's configured ciphersuites. You must additionally choose + /// which protocol versions to enable, using `with_protocol_versions` or + /// `with_safe_default_protocol_versions` and handling the `Result` in case a protocol + /// version is not supported by the provider's ciphersuites. + /// + /// For more information, see the [`ConfigBuilder`] documentation. + pub fn builder_with_details( + provider: Arc, + time_provider: Arc, + ) -> ConfigBuilder { + ConfigBuilder { + state: WantsVersions {}, + provider, + time_provider, + side: PhantomData, + } + } + + /// Return `true` if connections made with this `ServerConfig` will + /// operate in FIPS mode. + /// + /// This is different from [`CryptoProvider::fips()`]: [`CryptoProvider::fips()`] + /// is concerned only with cryptography, whereas this _also_ covers TLS-level + /// configuration that NIST recommends. + pub fn fips(&self) -> bool { + #[cfg(feature = "tls12")] + { + self.provider.fips() && self.require_ems + } + + #[cfg(not(feature = "tls12"))] + { + self.provider.fips() + } + } + + /// Return the crypto provider used to construct this client configuration. + pub fn crypto_provider(&self) -> &Arc { + &self.provider + } + + /// We support a given TLS version if it's quoted in the configured + /// versions *and* at least one ciphersuite for this version is + /// also configured. + pub(crate) fn supports_version(&self, v: ProtocolVersion) -> bool { + self.versions.contains(v) + && self + .provider + .cipher_suites + .iter() + .any(|cs| cs.version().version == v) + } + + #[cfg(feature = "std")] + pub(crate) fn supports_protocol(&self, proto: Protocol) -> bool { + self.provider + .cipher_suites + .iter() + .any(|cs| cs.usable_for_protocol(proto)) + } + + pub(super) fn current_time(&self) -> Result { + self.time_provider + .current_time() + .ok_or(Error::FailedToGetCurrentTime) + } +} + +#[cfg(feature = "std")] +mod connection { + use alloc::boxed::Box; + use core::fmt; + use core::fmt::{Debug, Formatter}; + use core::ops::{Deref, DerefMut}; + use std::io; + + use super::{ + Accepted, Accepting, EarlyDataState, ServerConfig, ServerConnectionData, + ServerExtensionsInput, + }; + use crate::common_state::{CommonState, Context, Side}; + use crate::conn::{ConnectionCommon, ConnectionCore}; + use crate::error::Error; + use crate::server::hs; + use crate::suites::ExtractedSecrets; + use crate::sync::Arc; + use crate::vecbuf::ChunkVecBuffer; + + /// Allows reading of early data in resumed TLS1.3 connections. + /// + /// "Early data" is also known as "0-RTT data". + /// + /// This structure implements [`std::io::Read`]. + pub struct ReadEarlyData<'a> { + early_data: &'a mut EarlyDataState, + } + + impl<'a> ReadEarlyData<'a> { + fn new(early_data: &'a mut EarlyDataState) -> Self { + ReadEarlyData { early_data } + } + } + + impl io::Read for ReadEarlyData<'_> { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + self.early_data.read(buf) + } + + #[cfg(read_buf)] + fn read_buf(&mut self, cursor: core::io::BorrowedCursor<'_, u8>) -> io::Result<()> { + self.early_data.read_buf(cursor) + } + } + + /// This represents a single TLS server connection. + /// + /// Send TLS-protected data to the peer using the `io::Write` trait implementation. + /// Read data from the peer using the `io::Read` trait implementation. + pub struct ServerConnection { + pub(super) inner: ConnectionCommon, + } + + impl ServerConnection { + /// Make a new ServerConnection. `config` controls how + /// we behave in the TLS protocol. + pub fn new(config: Arc) -> Result { + Ok(Self { + inner: ConnectionCommon::from(ConnectionCore::for_server( + config, + ServerExtensionsInput::default(), + )?), + }) + } + + /// Retrieves the server name, if any, used to select the certificate and + /// private key. + /// + /// This returns `None` until some time after the client's server name indication + /// (SNI) extension value is processed during the handshake. It will never be + /// `None` when the connection is ready to send or process application data, + /// unless the client does not support SNI. + /// + /// This is useful for application protocols that need to enforce that the + /// server name matches an application layer protocol hostname. For + /// example, HTTP/1.1 servers commonly expect the `Host:` header field of + /// every request on a connection to match the hostname in the SNI extension + /// when the client provides the SNI extension. + /// + /// The server name is also used to match sessions during session resumption. + pub fn server_name(&self) -> Option<&str> { + self.inner.core.get_sni_str() + } + + /// Application-controlled portion of the resumption ticket supplied by the client, if any. + /// + /// Recovered from the prior session's `set_resumption_data`. Integrity is guaranteed by rustls. + /// + /// Returns `Some` if and only if a valid resumption ticket has been received from the client. + pub fn received_resumption_data(&self) -> Option<&[u8]> { + self.inner + .core + .data + .received_resumption_data + .as_ref() + .map(|x| &x[..]) + } + + /// Set the resumption data to embed in future resumption tickets supplied to the client. + /// + /// Defaults to the empty byte string. Must be less than 2^15 bytes to allow room for other + /// data. Should be called while `is_handshaking` returns true to ensure all transmitted + /// resumption tickets are affected. + /// + /// Integrity will be assured by rustls, but the data will be visible to the client. If secrecy + /// from the client is desired, encrypt the data separately. + pub fn set_resumption_data(&mut self, data: &[u8]) { + assert!(data.len() < 2usize.pow(15)); + self.inner.core.data.resumption_data = data.into(); + } + + /// Explicitly discard early data, notifying the client + /// + /// Useful if invariants encoded in `received_resumption_data()` cannot be respected. + /// + /// Must be called while `is_handshaking` is true. + pub fn reject_early_data(&mut self) { + self.inner.core.reject_early_data() + } + + /// Returns an `io::Read` implementer you can read bytes from that are + /// received from a client as TLS1.3 0RTT/"early" data, during the handshake. + /// + /// This returns `None` in many circumstances, such as : + /// + /// - Early data is disabled if [`ServerConfig::max_early_data_size`] is zero (the default). + /// - The session negotiated with the client is not TLS1.3. + /// - The client just doesn't support early data. + /// - The connection doesn't resume an existing session. + /// - The client hasn't sent a full ClientHello yet. + pub fn early_data(&mut self) -> Option> { + let data = &mut self.inner.core.data; + if data.early_data.was_accepted() { + Some(ReadEarlyData::new(&mut data.early_data)) + } else { + None + } + } + + /// Return true if the connection was made with a `ServerConfig` that is FIPS compatible. + /// + /// This is different from [`crate::crypto::CryptoProvider::fips()`]: + /// it is concerned only with cryptography, whereas this _also_ covers TLS-level + /// configuration that NIST recommends, as well as ECH HPKE suites if applicable. + pub fn fips(&self) -> bool { + self.inner.core.common_state.fips + } + + /// Extract secrets, so they can be used when configuring kTLS, for example. + /// Should be used with care as it exposes secret key material. + pub fn dangerous_extract_secrets(self) -> Result { + self.inner.dangerous_extract_secrets() + } + } + + impl Debug for ServerConnection { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.debug_struct("ServerConnection") + .finish() + } + } + + impl Deref for ServerConnection { + type Target = ConnectionCommon; + + fn deref(&self) -> &Self::Target { + &self.inner + } + } + + impl DerefMut for ServerConnection { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.inner + } + } + + impl From for crate::Connection { + fn from(conn: ServerConnection) -> Self { + Self::Server(conn) + } + } + + /// Handle a server-side connection before configuration is available. + /// + /// `Acceptor` allows the caller to choose a [`ServerConfig`] after reading + /// the [`super::ClientHello`] of an incoming connection. This is useful for servers + /// that choose different certificates or cipher suites based on the + /// characteristics of the `ClientHello`. In particular it is useful for + /// servers that need to do some I/O to load a certificate and its private key + /// and don't want to use the blocking interface provided by + /// [`super::ResolvesServerCert`]. + /// + /// Create an Acceptor with [`Acceptor::default()`]. + /// + /// # Example + /// + /// ```no_run + /// # #[cfg(feature = "aws_lc_rs")] { + /// # fn choose_server_config( + /// # _: rustls::server::ClientHello, + /// # ) -> std::sync::Arc { + /// # unimplemented!(); + /// # } + /// # #[allow(unused_variables)] + /// # fn main() { + /// use rustls::server::{Acceptor, ServerConfig}; + /// let listener = std::net::TcpListener::bind("127.0.0.1:0").unwrap(); + /// for stream in listener.incoming() { + /// let mut stream = stream.unwrap(); + /// let mut acceptor = Acceptor::default(); + /// let accepted = loop { + /// acceptor.read_tls(&mut stream).unwrap(); + /// if let Some(accepted) = acceptor.accept().unwrap() { + /// break accepted; + /// } + /// }; + /// + /// // For some user-defined choose_server_config: + /// let config = choose_server_config(accepted.client_hello()); + /// let conn = accepted + /// .into_connection(config) + /// .unwrap(); + /// + /// // Proceed with handling the ServerConnection. + /// } + /// # } + /// # } + /// ``` + pub struct Acceptor { + inner: Option>, + } + + impl Default for Acceptor { + /// Return an empty Acceptor, ready to receive bytes from a new client connection. + fn default() -> Self { + Self { + inner: Some( + ConnectionCore::new( + Box::new(Accepting), + ServerConnectionData::default(), + CommonState::new(Side::Server), + ) + .into(), + ), + } + } + } + + impl Acceptor { + /// Read TLS content from `rd`. + /// + /// Returns an error if this `Acceptor` has already yielded an [`Accepted`]. For more details, + /// refer to [`Connection::read_tls()`]. + /// + /// [`Connection::read_tls()`]: crate::Connection::read_tls + pub fn read_tls(&mut self, rd: &mut dyn io::Read) -> Result { + match &mut self.inner { + Some(conn) => conn.read_tls(rd), + None => Err(io::Error::new( + io::ErrorKind::Other, + "acceptor cannot read after successful acceptance", + )), + } + } + + /// Check if a `ClientHello` message has been received. + /// + /// Returns `Ok(None)` if the complete `ClientHello` has not yet been received. + /// Do more I/O and then call this function again. + /// + /// Returns `Ok(Some(accepted))` if the connection has been accepted. Call + /// `accepted.into_connection()` to continue. Do not call this function again. + /// + /// Returns `Err((err, alert))` if an error occurred. If an alert is returned, the + /// application should call `alert.write()` to send the alert to the client. It should + /// not call `accept()` again. + pub fn accept(&mut self) -> Result, (Error, AcceptedAlert)> { + let Some(mut connection) = self.inner.take() else { + return Err(( + Error::General("Acceptor polled after completion".into()), + AcceptedAlert::empty(), + )); + }; + + let message = match connection.first_handshake_message() { + Ok(Some(msg)) => msg, + Ok(None) => { + self.inner = Some(connection); + return Ok(None); + } + Err(err) => return Err((err, AcceptedAlert::from(connection))), + }; + + let mut cx = Context::from(&mut connection); + let sig_schemes = match hs::process_client_hello(&message, false, &mut cx) { + Ok((_, sig_schemes)) => sig_schemes, + Err(err) => { + return Err((err, AcceptedAlert::from(connection))); + } + }; + + Ok(Some(Accepted { + connection, + message, + sig_schemes, + })) + } + } + + /// Represents a TLS alert resulting from handling the client's `ClientHello` message. + /// + /// When [`Acceptor::accept()`] returns an error, it yields an `AcceptedAlert` such that the + /// application can communicate failure to the client via [`AcceptedAlert::write()`]. + pub struct AcceptedAlert(ChunkVecBuffer); + + impl AcceptedAlert { + pub(super) fn empty() -> Self { + Self(ChunkVecBuffer::new(None)) + } + + /// Send the alert to the client. + /// + /// To account for short writes this function should be called repeatedly until it + /// returns `Ok(0)` or an error. + pub fn write(&mut self, wr: &mut dyn io::Write) -> Result { + self.0.write_to(wr) + } + + /// Send the alert to the client. + /// + /// This function will invoke the writer until the buffer is empty. + pub fn write_all(&mut self, wr: &mut dyn io::Write) -> Result<(), io::Error> { + while self.write(wr)? != 0 {} + Ok(()) + } + } + + impl From> for AcceptedAlert { + fn from(conn: ConnectionCommon) -> Self { + Self(conn.core.common_state.sendable_tls) + } + } + + impl Debug for AcceptedAlert { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.debug_struct("AcceptedAlert").finish() + } + } +} + +#[cfg(feature = "std")] +pub use connection::{AcceptedAlert, Acceptor, ReadEarlyData, ServerConnection}; + +/// Unbuffered version of `ServerConnection` +/// +/// See the [`crate::unbuffered`] module docs for more details +pub struct UnbufferedServerConnection { + inner: UnbufferedConnectionCommon, +} + +impl UnbufferedServerConnection { + /// Make a new ServerConnection. `config` controls how we behave in the TLS protocol. + pub fn new(config: Arc) -> Result { + Ok(Self { + inner: UnbufferedConnectionCommon::from(ConnectionCore::for_server( + config, + ServerExtensionsInput::default(), + )?), + }) + } + + /// Extract secrets, so they can be used when configuring kTLS, for example. + /// Should be used with care as it exposes secret key material. + #[deprecated = "dangerous_extract_secrets() does not support session tickets or \ + key updates, use dangerous_into_kernel_connection() instead"] + pub fn dangerous_extract_secrets(self) -> Result { + self.inner.dangerous_extract_secrets() + } + + /// Extract secrets and an [`KernelConnection`] object. + /// + /// This allows you use rustls to manage keys and then manage encryption and + /// decryption yourself (e.g. for kTLS). + /// + /// Should be used with care as it exposes secret key material. + /// + /// See the [`crate::kernel`] documentations for details on prerequisites + /// for calling this method. + pub fn dangerous_into_kernel_connection( + self, + ) -> Result<(ExtractedSecrets, KernelConnection), Error> { + self.inner + .core + .dangerous_into_kernel_connection() + } +} + +impl Deref for UnbufferedServerConnection { + type Target = UnbufferedConnectionCommon; + + fn deref(&self) -> &Self::Target { + &self.inner + } +} + +impl DerefMut for UnbufferedServerConnection { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.inner + } +} + +impl UnbufferedConnectionCommon { + pub(crate) fn pop_early_data(&mut self) -> Option> { + self.core.data.early_data.pop() + } + + pub(crate) fn peek_early_data(&self) -> Option<&[u8]> { + self.core.data.early_data.peek() + } +} + +/// Represents a `ClientHello` message received through the [`Acceptor`]. +/// +/// Contains the state required to resume the connection through [`Accepted::into_connection()`]. +pub struct Accepted { + connection: ConnectionCommon, + message: Message<'static>, + sig_schemes: Vec, +} + +impl Accepted { + /// Get the [`ClientHello`] for this connection. + pub fn client_hello(&self) -> ClientHello<'_> { + let payload = Self::client_hello_payload(&self.message); + let ch = ClientHello { + server_name: &self.connection.core.data.sni, + signature_schemes: &self.sig_schemes, + alpn: payload.protocols.as_ref(), + server_cert_types: payload + .server_certificate_types + .as_deref(), + client_cert_types: payload + .client_certificate_types + .as_deref(), + cipher_suites: &payload.cipher_suites, + certificate_authorities: payload + .certificate_authority_names + .as_deref(), + named_groups: payload.named_groups.as_deref(), + }; + + trace!("Accepted::client_hello(): {ch:#?}"); + ch + } + + /// Convert the [`Accepted`] into a [`ServerConnection`]. + /// + /// Takes the state returned from [`Acceptor::accept()`] as well as the [`ServerConfig`] and + /// [`sign::CertifiedKey`] that should be used for the session. Returns an error if + /// configuration-dependent validation of the received `ClientHello` message fails. + #[cfg(feature = "std")] + pub fn into_connection( + mut self, + config: Arc, + ) -> Result { + if let Err(err) = self + .connection + .set_max_fragment_size(config.max_fragment_size) + { + // We have a connection here, but it won't contain an alert since the error + // is with the fragment size configured in the `ServerConfig`. + return Err((err, AcceptedAlert::empty())); + } + + self.connection.enable_secret_extraction = config.enable_secret_extraction; + + let state = hs::ExpectClientHello::new(config, ServerExtensionsInput::default()); + let mut cx = hs::ServerContext::from(&mut self.connection); + + let ch = Self::client_hello_payload(&self.message); + let new = match state.with_certified_key(self.sig_schemes, ch, &self.message, &mut cx) { + Ok(new) => new, + Err(err) => return Err((err, AcceptedAlert::from(self.connection))), + }; + + self.connection.replace_state(new); + Ok(ServerConnection { + inner: self.connection, + }) + } + + fn client_hello_payload<'a>(message: &'a Message<'_>) -> &'a ClientHelloPayload { + match &message.payload { + crate::msgs::message::MessagePayload::Handshake { parsed, .. } => match &parsed.0 { + crate::msgs::handshake::HandshakePayload::ClientHello(ch) => ch, + _ => unreachable!(), + }, + _ => unreachable!(), + } + } +} + +impl Debug for Accepted { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.debug_struct("Accepted").finish() + } +} + +#[cfg(feature = "std")] +struct Accepting; + +#[cfg(feature = "std")] +impl State for Accepting { + fn handle<'m>( + self: Box, + _cx: &mut hs::ServerContext<'_>, + _m: Message<'m>, + ) -> Result + 'm>, Error> + where + Self: 'm, + { + Err(Error::General("unreachable state".into())) + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + self + } +} + +#[derive(Default)] +pub(super) enum EarlyDataState { + #[default] + New, + Accepted { + received: ChunkVecBuffer, + left: usize, + }, + Rejected, +} + +impl EarlyDataState { + pub(super) fn reject(&mut self) { + *self = Self::Rejected; + } + + pub(super) fn accept(&mut self, max_size: usize) { + *self = Self::Accepted { + received: ChunkVecBuffer::new(Some(max_size)), + left: max_size, + }; + } + + #[cfg(feature = "std")] + fn was_accepted(&self) -> bool { + matches!(self, Self::Accepted { .. }) + } + + pub(super) fn was_rejected(&self) -> bool { + matches!(self, Self::Rejected) + } + + fn peek(&self) -> Option<&[u8]> { + match self { + Self::Accepted { received, .. } => received.peek(), + _ => None, + } + } + + fn pop(&mut self) -> Option> { + match self { + Self::Accepted { received, .. } => received.pop(), + _ => None, + } + } + + #[cfg(feature = "std")] + fn read(&mut self, buf: &mut [u8]) -> io::Result { + match self { + Self::Accepted { received, .. } => received.read(buf), + _ => Err(io::Error::from(io::ErrorKind::BrokenPipe)), + } + } + + #[cfg(read_buf)] + fn read_buf(&mut self, cursor: core::io::BorrowedCursor<'_, u8>) -> io::Result<()> { + match self { + Self::Accepted { received, .. } => received.read_buf(cursor), + _ => Err(io::Error::from(io::ErrorKind::BrokenPipe)), + } + } + + pub(super) fn take_received_plaintext(&mut self, bytes: Payload<'_>) -> bool { + let available = bytes.bytes().len(); + let Self::Accepted { received, left } = self else { + return false; + }; + + if received.apply_limit(available) != available || available > *left { + return false; + } + + received.append(bytes.into_vec()); + *left -= available; + true + } +} + +impl Debug for EarlyDataState { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + match self { + Self::New => write!(f, "EarlyDataState::New"), + Self::Accepted { received, left } => write!( + f, + "EarlyDataState::Accepted {{ received: {}, left: {} }}", + received.len(), + left + ), + Self::Rejected => write!(f, "EarlyDataState::Rejected"), + } + } +} + +impl ConnectionCore { + pub(crate) fn for_server( + config: Arc, + extra_exts: ServerExtensionsInput<'static>, + ) -> Result { + let mut common = CommonState::new(Side::Server); + common.set_max_fragment_size(config.max_fragment_size)?; + common.enable_secret_extraction = config.enable_secret_extraction; + common.fips = config.fips(); + Ok(Self::new( + Box::new(hs::ExpectClientHello::new(config, extra_exts)), + ServerConnectionData::default(), + common, + )) + } + + #[cfg(feature = "std")] + pub(crate) fn reject_early_data(&mut self) { + assert!( + self.common_state.is_handshaking(), + "cannot retroactively reject early data" + ); + self.data.early_data.reject(); + } + + #[cfg(feature = "std")] + pub(crate) fn get_sni_str(&self) -> Option<&str> { + self.data.get_sni_str() + } +} + +/// State associated with a server connection. +#[derive(Default, Debug)] +pub struct ServerConnectionData { + pub(super) sni: Option>, + pub(super) received_resumption_data: Option>, + pub(super) resumption_data: Vec, + pub(super) early_data: EarlyDataState, +} + +impl ServerConnectionData { + #[cfg(feature = "std")] + pub(super) fn get_sni_str(&self) -> Option<&str> { + self.sni.as_ref().map(AsRef::as_ref) + } +} + +impl crate::conn::SideData for ServerConnectionData {} + +#[cfg(feature = "std")] +#[cfg(test)] +mod tests { + use std::format; + + use super::*; + + // these branches not reachable externally, unless something else goes wrong. + #[test] + fn test_read_in_new_state() { + assert_eq!( + format!("{:?}", EarlyDataState::default().read(&mut [0u8; 5])), + "Err(Kind(BrokenPipe))" + ); + } + + #[cfg(read_buf)] + #[test] + fn test_read_buf_in_new_state() { + use core::io::BorrowedBuf; + + let mut buf = [0u8; 5]; + let mut buf: BorrowedBuf<'_, u8> = buf.as_mut_slice().into(); + assert_eq!( + format!("{:?}", EarlyDataState::default().read_buf(buf.unfilled())), + "Err(Kind(BrokenPipe))" + ); + } +} diff --git a/http/vendor/rustls/src/server/test.rs b/http/vendor/rustls/src/server/test.rs new file mode 100644 index 0000000..12fbf62 --- /dev/null +++ b/http/vendor/rustls/src/server/test.rs @@ -0,0 +1,371 @@ +use alloc::boxed::Box; +use alloc::vec; + +use super::ServerConnectionData; +use crate::common_state::Context; +use crate::enums::{CipherSuite, SignatureScheme}; +use crate::msgs::base::PayloadU16; +use crate::msgs::enums::{Compression, NamedGroup}; +use crate::msgs::handshake::{ + ClientExtensions, ClientHelloPayload, HandshakeMessagePayload, HandshakePayload, KeyShareEntry, + Random, ServerNamePayload, SessionId, SupportedProtocolVersions, +}; +use crate::msgs::message::{Message, MessagePayload}; +use crate::{CommonState, Error, PeerIncompatible, PeerMisbehaved, ProtocolVersion, Side}; + +#[test] +fn null_compression_required() { + assert_eq!( + test_process_client_hello(ClientHelloPayload { + compression_methods: vec![], + ..minimal_client_hello() + }), + Err(PeerIncompatible::NullCompressionRequired.into()), + ); +} + +#[test] +fn server_ignores_sni_with_ip_address() { + let mut ch = minimal_client_hello(); + ch.extensions.server_name = Some(ServerNamePayload::IpAddress); + std::println!("{:?}", ch.extensions); + assert_eq!(test_process_client_hello(ch), Ok(())); +} + +#[test] +fn server_rejects_sni_with_illegal_dns_name() { + let mut ch = minimal_client_hello(); + ch.extensions.server_name = Some(ServerNamePayload::Invalid); + std::println!("{:?}", ch.extensions); + assert_eq!( + test_process_client_hello(ch), + Err(PeerMisbehaved::ServerNameMustContainOneHostName.into()) + ); +} + +fn test_process_client_hello(hello: ClientHelloPayload) -> Result<(), Error> { + let m = Message { + version: ProtocolVersion::TLSv1_2, + payload: MessagePayload::handshake(HandshakeMessagePayload(HandshakePayload::ClientHello( + hello, + ))), + }; + super::hs::process_client_hello( + &m, + false, + &mut Context { + common: &mut CommonState::new(Side::Server), + data: &mut ServerConnectionData::default(), + sendable_plaintext: None, + }, + ) + .map(|_| ()) +} + +#[macro_rules_attribute::apply(test_for_each_provider)] +mod tests { + use alloc::vec::Vec; + + use super::super::*; + use crate::common_state::KxState; + use crate::crypto::{ + ActiveKeyExchange, CryptoProvider, KeyExchangeAlgorithm, SupportedKxGroup, + }; + use crate::enums::CertificateType; + use crate::pki_types::pem::PemObject; + use crate::pki_types::{CertificateDer, PrivateKeyDer}; + use crate::server::{AlwaysResolvesServerRawPublicKeys, ServerConfig, ServerConnection}; + use crate::sign::CertifiedKey; + use crate::sync::Arc; + use crate::{CipherSuiteCommon, SupportedCipherSuite, Tls12CipherSuite, version}; + + #[cfg(feature = "tls12")] + #[test] + fn test_server_rejects_no_extended_master_secret_extension_when_require_ems_or_fips() { + let provider = super::provider::default_provider(); + let mut config = ServerConfig::builder_with_provider(provider.into()) + .with_protocol_versions(&[&version::TLS12]) + .unwrap() + .with_no_client_auth() + .with_single_cert(server_cert(), server_key()) + .unwrap(); + + if config.provider.fips() { + assert!(config.require_ems); + } else { + config.require_ems = true; + } + let mut conn = ServerConnection::new(config.into()).unwrap(); + + let mut ch = minimal_client_hello(); + ch.extensions + .extended_master_secret_request + .take(); + let ch = Message { + version: ProtocolVersion::TLSv1_3, + payload: MessagePayload::handshake(HandshakeMessagePayload( + HandshakePayload::ClientHello(ch), + )), + }; + conn.read_tls(&mut ch.into_wire_bytes().as_slice()) + .unwrap(); + + assert_eq!( + conn.process_new_packets(), + Err(Error::PeerIncompatible( + PeerIncompatible::ExtendedMasterSecretExtensionRequired + )) + ); + } + + #[cfg(feature = "tls12")] + #[test] + fn server_picks_ffdhe_group_when_clienthello_has_no_ffdhe_group_in_groups_ext() { + let config = ServerConfig::builder_with_provider(ffdhe_provider().into()) + .with_protocol_versions(&[&version::TLS12]) + .unwrap() + .with_no_client_auth() + .with_single_cert(server_cert(), server_key()) + .unwrap(); + + let mut ch = minimal_client_hello(); + ch.cipher_suites + .push(TLS_DHE_RSA_WITH_AES_128_GCM_SHA256.suite()); + + server_chooses_ffdhe_group_for_client_hello( + ServerConnection::new(config.into()).unwrap(), + ch, + ); + } + + #[cfg(feature = "tls12")] + #[test] + fn server_picks_ffdhe_group_when_clienthello_has_no_groups_ext() { + let config = ServerConfig::builder_with_provider(ffdhe_provider().into()) + .with_protocol_versions(&[&version::TLS12]) + .unwrap() + .with_no_client_auth() + .with_single_cert(server_cert(), server_key()) + .unwrap(); + + let mut ch = minimal_client_hello(); + ch.cipher_suites + .push(TLS_DHE_RSA_WITH_AES_128_GCM_SHA256.suite()); + ch.extensions.named_groups.take(); + + server_chooses_ffdhe_group_for_client_hello( + ServerConnection::new(config.into()).unwrap(), + ch, + ); + } + + #[cfg(feature = "tls12")] + #[test] + fn server_accepts_client_with_no_ecpoints_extension_and_only_ffdhe_cipher_suites() { + let config = ServerConfig::builder_with_provider(ffdhe_provider().into()) + .with_protocol_versions(&[&version::TLS12]) + .unwrap() + .with_no_client_auth() + .with_single_cert(server_cert(), server_key()) + .unwrap(); + + let mut ch = minimal_client_hello(); + ch.cipher_suites + .push(TLS_DHE_RSA_WITH_AES_128_GCM_SHA256.suite()); + ch.extensions.ec_point_formats.take(); + + server_chooses_ffdhe_group_for_client_hello( + ServerConnection::new(config.into()).unwrap(), + ch, + ); + } + + fn server_chooses_ffdhe_group_for_client_hello( + mut conn: ServerConnection, + client_hello: ClientHelloPayload, + ) { + let ch = Message { + version: ProtocolVersion::TLSv1_3, + payload: MessagePayload::handshake(HandshakeMessagePayload( + HandshakePayload::ClientHello(client_hello), + )), + }; + conn.read_tls(&mut ch.into_wire_bytes().as_slice()) + .unwrap(); + conn.process_new_packets().unwrap(); + + let KxState::Start(skxg) = &conn.kx_state else { + panic!("unexpected kx_state"); + }; + assert_eq!(skxg.name(), FAKE_FFDHE_GROUP.name()); + } + + #[test] + fn test_server_requiring_rpk_client_rejects_x509_client() { + let mut ch = minimal_client_hello(); + ch.extensions.client_certificate_types = Some(vec![CertificateType::X509]); + let ch = Message { + version: ProtocolVersion::TLSv1_3, + payload: MessagePayload::handshake(HandshakeMessagePayload( + HandshakePayload::ClientHello(ch), + )), + }; + + let mut conn = ServerConnection::new(server_config_for_rpk().into()).unwrap(); + conn.read_tls(&mut ch.into_wire_bytes().as_slice()) + .unwrap(); + assert_eq!( + conn.process_new_packets().unwrap_err(), + PeerIncompatible::IncorrectCertificateTypeExtension.into(), + ); + } + + #[test] + fn test_rpk_only_server_rejects_x509_only_client() { + let mut ch = minimal_client_hello(); + ch.extensions.server_certificate_types = Some(vec![CertificateType::X509]); + let ch = Message { + version: ProtocolVersion::TLSv1_3, + payload: MessagePayload::handshake(HandshakeMessagePayload( + HandshakePayload::ClientHello(ch), + )), + }; + + let mut conn = ServerConnection::new(server_config_for_rpk().into()).unwrap(); + conn.read_tls(&mut ch.into_wire_bytes().as_slice()) + .unwrap(); + assert_eq!( + conn.process_new_packets().unwrap_err(), + PeerIncompatible::IncorrectCertificateTypeExtension.into(), + ); + } + + fn server_config_for_rpk() -> ServerConfig { + let x25519_provider = CryptoProvider { + kx_groups: vec![super::provider::kx_group::X25519], + ..super::provider::default_provider() + }; + ServerConfig::builder_with_provider(x25519_provider.into()) + .with_protocol_versions(&[&version::TLS13]) + .unwrap() + .with_no_client_auth() + .with_cert_resolver(Arc::new(AlwaysResolvesServerRawPublicKeys::new(Arc::new( + server_certified_key(), + )))) + } + + fn server_certified_key() -> CertifiedKey { + let key = super::provider::default_provider() + .key_provider + .load_private_key(server_key()) + .unwrap(); + let public_key_as_cert = vec![CertificateDer::from( + key.public_key() + .unwrap() + .as_ref() + .to_vec(), + )]; + CertifiedKey::new(public_key_as_cert, key) + } + + fn server_key() -> PrivateKeyDer<'static> { + PrivateKeyDer::from_pem_reader( + &mut include_bytes!("../../../test-ca/rsa-2048/end.key").as_slice(), + ) + .unwrap() + } + + fn server_cert() -> Vec> { + vec![ + CertificateDer::from(&include_bytes!("../../../test-ca/rsa-2048/end.der")[..]), + CertificateDer::from(&include_bytes!("../../../test-ca/rsa-2048/inter.der")[..]), + ] + } + + fn ffdhe_provider() -> CryptoProvider { + CryptoProvider { + kx_groups: vec![FAKE_FFDHE_GROUP], + cipher_suites: vec![TLS_DHE_RSA_WITH_AES_128_GCM_SHA256], + ..super::provider::default_provider() + } + } + + static FAKE_FFDHE_GROUP: &'static dyn SupportedKxGroup = &FakeFfdheGroup; + + #[derive(Debug)] + struct FakeFfdheGroup; + + impl SupportedKxGroup for FakeFfdheGroup { + fn name(&self) -> NamedGroup { + NamedGroup::FFDHE2048 + } + + fn start(&self) -> Result, Error> { + Ok(Box::new(ActiveFakeFfdhe)) + } + } + + #[derive(Debug)] + struct ActiveFakeFfdhe; + + impl ActiveKeyExchange for ActiveFakeFfdhe { + #[cfg_attr(coverage_nightly, coverage(off))] + fn complete( + self: Box, + _peer_pub_key: &[u8], + ) -> Result { + todo!() + } + + fn pub_key(&self) -> &[u8] { + b"ActiveFakeFfdhe pub key" + } + + fn group(&self) -> NamedGroup { + NamedGroup::FFDHE2048 + } + } + + static TLS_DHE_RSA_WITH_AES_128_GCM_SHA256: SupportedCipherSuite = + SupportedCipherSuite::Tls12(&TLS12_DHE_RSA_WITH_AES_128_GCM_SHA256); + + static TLS12_DHE_RSA_WITH_AES_128_GCM_SHA256: Tls12CipherSuite = + match &super::provider::cipher_suite::TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 { + SupportedCipherSuite::Tls12(provider) => Tls12CipherSuite { + common: CipherSuiteCommon { + suite: CipherSuite::TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, + ..provider.common + }, + kx: KeyExchangeAlgorithm::DHE, + ..**provider + }, + _ => unreachable!(), + }; +} + +fn minimal_client_hello() -> ClientHelloPayload { + ClientHelloPayload { + client_version: ProtocolVersion::TLSv1_3, + random: Random::from([0u8; 32]), + session_id: SessionId::empty(), + cipher_suites: vec![ + CipherSuite::TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, + CipherSuite::TLS13_AES_128_GCM_SHA256, + ], + compression_methods: vec![Compression::Null], + extensions: Box::new(ClientExtensions { + signature_schemes: Some(vec![SignatureScheme::RSA_PSS_SHA256]), + named_groups: Some(vec![NamedGroup::X25519, NamedGroup::secp256r1]), + supported_versions: Some(SupportedProtocolVersions { + tls12: true, + tls13: true, + }), + key_shares: Some(vec![KeyShareEntry { + group: NamedGroup::X25519, + payload: PayloadU16::new(vec![0xab; 32]), + }]), + extended_master_secret_request: Some(()), + ..ClientExtensions::default() + }), + } +} diff --git a/http/vendor/rustls/src/server/tls12.rs b/http/vendor/rustls/src/server/tls12.rs new file mode 100644 index 0000000..d3dfa5c --- /dev/null +++ b/http/vendor/rustls/src/server/tls12.rs @@ -0,0 +1,1003 @@ +use alloc::boxed::Box; +use alloc::string::ToString; +use alloc::vec; +use alloc::vec::Vec; + +pub(super) use client_hello::CompleteClientHelloHandling; +use pki_types::UnixTime; +use subtle::ConstantTimeEq; + +use super::common::ActiveCertifiedKey; +use super::hs::{self, ServerContext}; +use super::server_conn::{ProducesTickets, ServerConfig, ServerConnectionData}; +use crate::check::inappropriate_message; +use crate::common_state::{CommonState, HandshakeFlightTls12, HandshakeKind, Side, State}; +use crate::conn::ConnectionRandoms; +use crate::conn::kernel::{Direction, KernelContext, KernelState}; +use crate::crypto::ActiveKeyExchange; +use crate::enums::{AlertDescription, ContentType, HandshakeType, ProtocolVersion}; +use crate::error::{Error, PeerIncompatible, PeerMisbehaved}; +use crate::hash_hs::HandshakeHash; +use crate::log::{debug, trace}; +use crate::msgs::base::Payload; +use crate::msgs::ccs::ChangeCipherSpecPayload; +use crate::msgs::codec::Codec; +use crate::msgs::handshake::{ + CertificateChain, ClientKeyExchangeParams, HandshakeMessagePayload, HandshakePayload, + NewSessionTicketPayload, NewSessionTicketPayloadTls13, SessionId, +}; +use crate::msgs::message::{Message, MessagePayload}; +use crate::msgs::persist; +use crate::suites::PartiallyExtractedSecrets; +use crate::sync::Arc; +use crate::tls12::{self, ConnectionSecrets, Tls12CipherSuite}; +use crate::{ConnectionTrafficSecrets, verify}; + +mod client_hello { + use pki_types::CertificateDer; + + use super::*; + use crate::common_state::KxState; + use crate::crypto::SupportedKxGroup; + use crate::enums::SignatureScheme; + use crate::msgs::enums::{ClientCertificateType, Compression}; + use crate::msgs::handshake::{ + CertificateRequestPayload, CertificateStatus, ClientHelloPayload, ClientSessionTicket, + Random, ServerExtensionsInput, ServerHelloPayload, ServerKeyExchange, + ServerKeyExchangeParams, ServerKeyExchangePayload, + }; + use crate::sign; + use crate::verify::DigitallySignedStruct; + + pub(in crate::server) struct CompleteClientHelloHandling { + pub(in crate::server) config: Arc, + pub(in crate::server) transcript: HandshakeHash, + pub(in crate::server) session_id: SessionId, + pub(in crate::server) suite: &'static Tls12CipherSuite, + pub(in crate::server) using_ems: bool, + pub(in crate::server) randoms: ConnectionRandoms, + pub(in crate::server) send_ticket: bool, + pub(in crate::server) extra_exts: ServerExtensionsInput<'static>, + } + + impl CompleteClientHelloHandling { + pub(in crate::server) fn handle_client_hello( + mut self, + cx: &mut ServerContext<'_>, + server_key: ActiveCertifiedKey<'_>, + chm: &Message<'_>, + client_hello: &ClientHelloPayload, + selected_kxg: &'static dyn SupportedKxGroup, + sigschemes_ext: Vec, + tls13_enabled: bool, + ) -> hs::NextStateOrError<'static> { + // -- TLS1.2 only from hereon in -- + self.transcript.add_message(chm); + + if client_hello + .extended_master_secret_request + .is_some() + { + self.using_ems = true; + } else if self.config.require_ems { + return Err(cx.common.send_fatal_alert( + AlertDescription::HandshakeFailure, + PeerIncompatible::ExtendedMasterSecretExtensionRequired, + )); + } + + // "RFC 4492 specified that if this extension is missing, + // it means that only the uncompressed point format is + // supported" + // - + let supported_ec_point_formats = client_hello + .ec_point_formats + .unwrap_or_default(); + + trace!("ecpoints {supported_ec_point_formats:?}"); + + if !supported_ec_point_formats.uncompressed { + return Err(cx.common.send_fatal_alert( + AlertDescription::IllegalParameter, + PeerIncompatible::UncompressedEcPointsRequired, + )); + } + + // -- If TLS1.3 is enabled, signal the downgrade in the server random + if tls13_enabled { + self.randoms.server[24..].copy_from_slice(&tls12::DOWNGRADE_SENTINEL); + } + + // -- Check for resumption -- + // We can do this either by (in order of preference): + // 1. receiving a ticket that decrypts + // 2. receiving a sessionid that is in our cache + // + // If we receive a ticket, the sessionid won't be in our + // cache, so don't check. + // + // If either works, we end up with a ServerConnectionValue + // which is passed to start_resumption and concludes + // our handling of the ClientHello. + // + let mut ticket_received = false; + let resume_data = client_hello + .session_ticket + .as_ref() + .and_then(|ticket_ext| match ticket_ext { + ClientSessionTicket::Offer(ticket) => Some(ticket), + _ => None, + }) + .and_then(|ticket| { + ticket_received = true; + debug!("Ticket received"); + let data = self + .config + .ticketer + .decrypt(ticket.bytes()); + if data.is_none() { + debug!("Ticket didn't decrypt"); + } + data + }) + .or_else(|| { + // Perhaps resume? If we received a ticket, the sessionid + // does not correspond to a real session. + if client_hello.session_id.is_empty() || ticket_received { + return None; + } + + self.config + .session_storage + .get(client_hello.session_id.as_ref()) + }) + .and_then(|x| persist::ServerSessionValue::read_bytes(&x).ok()) + .filter(|resumedata| { + hs::can_resume(self.suite.into(), &cx.data.sni, self.using_ems, resumedata) + }); + + if let Some(data) = resume_data { + return self.start_resumption(cx, client_hello, &client_hello.session_id, data); + } + + // Now we have chosen a ciphersuite, we can make kx decisions. + let sigschemes = self + .suite + .resolve_sig_schemes(&sigschemes_ext); + + if sigschemes.is_empty() { + return Err(cx.common.send_fatal_alert( + AlertDescription::HandshakeFailure, + PeerIncompatible::NoSignatureSchemesInCommon, + )); + } + + let mut ocsp_response = server_key.get_ocsp(); + + // If we're not offered a ticket or a potential session ID, allocate a session ID. + if !self.config.session_storage.can_cache() { + self.session_id = SessionId::empty(); + } else if self.session_id.is_empty() && !ticket_received { + self.session_id = SessionId::random(self.config.provider.secure_random)?; + } + + cx.common.kx_state = KxState::Start(selected_kxg); + cx.common.handshake_kind = Some(HandshakeKind::Full); + + let mut flight = HandshakeFlightTls12::new(&mut self.transcript); + + self.send_ticket = emit_server_hello( + &mut flight, + &self.config, + cx, + self.session_id, + self.suite, + self.using_ems, + &mut ocsp_response, + client_hello, + None, + &self.randoms, + self.extra_exts, + )?; + emit_certificate(&mut flight, server_key.get_cert()); + if let Some(ocsp_response) = ocsp_response { + emit_cert_status(&mut flight, ocsp_response); + } + let server_kx = emit_server_kx( + &mut flight, + sigschemes, + selected_kxg, + server_key.get_key(), + &self.randoms, + )?; + let doing_client_auth = emit_certificate_req(&mut flight, &self.config)?; + emit_server_hello_done(&mut flight); + + flight.finish(cx.common); + + if doing_client_auth { + Ok(Box::new(ExpectCertificate { + config: self.config, + transcript: self.transcript, + randoms: self.randoms, + session_id: self.session_id, + suite: self.suite, + using_ems: self.using_ems, + server_kx, + send_ticket: self.send_ticket, + })) + } else { + Ok(Box::new(ExpectClientKx { + config: self.config, + transcript: self.transcript, + randoms: self.randoms, + session_id: self.session_id, + suite: self.suite, + using_ems: self.using_ems, + server_kx, + client_cert: None, + send_ticket: self.send_ticket, + })) + } + } + + fn start_resumption( + mut self, + cx: &mut ServerContext<'_>, + client_hello: &ClientHelloPayload, + id: &SessionId, + resumedata: persist::ServerSessionValue, + ) -> hs::NextStateOrError<'static> { + debug!("Resuming connection"); + + if resumedata.extended_ms && !self.using_ems { + return Err(cx.common.send_fatal_alert( + AlertDescription::IllegalParameter, + PeerMisbehaved::ResumptionAttemptedWithVariedEms, + )); + } + + self.session_id = *id; + let mut flight = HandshakeFlightTls12::new(&mut self.transcript); + self.send_ticket = emit_server_hello( + &mut flight, + &self.config, + cx, + self.session_id, + self.suite, + self.using_ems, + &mut None, + client_hello, + Some(&resumedata), + &self.randoms, + self.extra_exts, + )?; + flight.finish(cx.common); + + let secrets = ConnectionSecrets::new_resume( + self.randoms, + self.suite, + &resumedata.master_secret.0, + ); + self.config.key_log.log( + "CLIENT_RANDOM", + &secrets.randoms.client, + &secrets.master_secret, + ); + cx.common + .start_encryption_tls12(&secrets, Side::Server); + cx.common.peer_certificates = resumedata.client_cert_chain; + cx.common.handshake_kind = Some(HandshakeKind::Resumed); + + if self.send_ticket { + let now = self.config.current_time()?; + + emit_ticket( + &secrets, + &mut self.transcript, + self.using_ems, + cx, + &*self.config.ticketer, + now, + )?; + } + emit_ccs(cx.common); + cx.common + .record_layer + .start_encrypting(); + emit_finished(&secrets, &mut self.transcript, cx.common); + + Ok(Box::new(ExpectCcs { + config: self.config, + secrets, + transcript: self.transcript, + session_id: self.session_id, + using_ems: self.using_ems, + resuming: true, + send_ticket: self.send_ticket, + })) + } + } + + fn emit_server_hello( + flight: &mut HandshakeFlightTls12<'_>, + config: &ServerConfig, + cx: &mut ServerContext<'_>, + session_id: SessionId, + suite: &'static Tls12CipherSuite, + using_ems: bool, + ocsp_response: &mut Option<&[u8]>, + hello: &ClientHelloPayload, + resumedata: Option<&persist::ServerSessionValue>, + randoms: &ConnectionRandoms, + extra_exts: ServerExtensionsInput<'static>, + ) -> Result { + let mut ep = hs::ExtensionProcessing::new(extra_exts); + ep.process_common(config, cx, ocsp_response, hello, resumedata)?; + ep.process_tls12(config, hello, using_ems); + + let sh = HandshakeMessagePayload(HandshakePayload::ServerHello(ServerHelloPayload { + legacy_version: ProtocolVersion::TLSv1_2, + random: Random::from(randoms.server), + session_id, + cipher_suite: suite.common.suite, + compression_method: Compression::Null, + extensions: ep.extensions, + })); + trace!("sending server hello {sh:?}"); + flight.add(sh); + + Ok(ep.send_ticket) + } + + fn emit_certificate( + flight: &mut HandshakeFlightTls12<'_>, + cert_chain: &[CertificateDer<'static>], + ) { + flight.add(HandshakeMessagePayload(HandshakePayload::Certificate( + CertificateChain(cert_chain.to_vec()), + ))); + } + + fn emit_cert_status(flight: &mut HandshakeFlightTls12<'_>, ocsp: &[u8]) { + flight.add(HandshakeMessagePayload( + HandshakePayload::CertificateStatus(CertificateStatus::new(ocsp)), + )); + } + + fn emit_server_kx( + flight: &mut HandshakeFlightTls12<'_>, + sigschemes: Vec, + selected_group: &'static dyn SupportedKxGroup, + signing_key: &dyn sign::SigningKey, + randoms: &ConnectionRandoms, + ) -> Result, Error> { + let kx = selected_group.start()?; + let kx_params = ServerKeyExchangeParams::new(&*kx); + + let mut msg = Vec::new(); + msg.extend(randoms.client); + msg.extend(randoms.server); + kx_params.encode(&mut msg); + + let signer = signing_key + .choose_scheme(&sigschemes) + .ok_or_else(|| Error::General("incompatible signing key".to_string()))?; + let sigscheme = signer.scheme(); + let sig = signer.sign(&msg)?; + + let skx = ServerKeyExchangePayload::from(ServerKeyExchange { + params: kx_params, + dss: DigitallySignedStruct::new(sigscheme, sig), + }); + + flight.add(HandshakeMessagePayload( + HandshakePayload::ServerKeyExchange(skx), + )); + Ok(kx) + } + + fn emit_certificate_req( + flight: &mut HandshakeFlightTls12<'_>, + config: &ServerConfig, + ) -> Result { + let client_auth = &config.verifier; + + if !client_auth.offer_client_auth() { + return Ok(false); + } + + let verify_schemes = client_auth.supported_verify_schemes(); + + let names = config + .verifier + .root_hint_subjects() + .to_vec(); + + let cr = CertificateRequestPayload { + certtypes: vec![ + ClientCertificateType::RSASign, + ClientCertificateType::ECDSASign, + ], + sigschemes: verify_schemes, + canames: names, + }; + + let creq = HandshakeMessagePayload(HandshakePayload::CertificateRequest(cr)); + + trace!("Sending CertificateRequest {creq:?}"); + flight.add(creq); + Ok(true) + } + + fn emit_server_hello_done(flight: &mut HandshakeFlightTls12<'_>) { + flight.add(HandshakeMessagePayload(HandshakePayload::ServerHelloDone)); + } +} + +// --- Process client's Certificate for client auth --- +struct ExpectCertificate { + config: Arc, + transcript: HandshakeHash, + randoms: ConnectionRandoms, + session_id: SessionId, + suite: &'static Tls12CipherSuite, + using_ems: bool, + server_kx: Box, + send_ticket: bool, +} + +impl State for ExpectCertificate { + fn handle<'m>( + mut self: Box, + cx: &mut ServerContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + self.transcript.add_message(&m); + let cert_chain = require_handshake_msg_move!( + m, + HandshakeType::Certificate, + HandshakePayload::Certificate + )?; + + // If we can't determine if the auth is mandatory, abort + let mandatory = self + .config + .verifier + .client_auth_mandatory(); + + trace!("certs {cert_chain:?}"); + + let client_cert = match cert_chain.split_first() { + None if mandatory => { + return Err(cx.common.send_fatal_alert( + AlertDescription::CertificateRequired, + Error::NoCertificatesPresented, + )); + } + None => { + debug!("client auth requested but no certificate supplied"); + self.transcript.abandon_client_auth(); + None + } + Some((end_entity, intermediates)) => { + let now = self.config.current_time()?; + + self.config + .verifier + .verify_client_cert(end_entity, intermediates, now) + .map_err(|err| { + cx.common + .send_cert_verify_error_alert(err) + })?; + + Some(cert_chain) + } + }; + + Ok(Box::new(ExpectClientKx { + config: self.config, + transcript: self.transcript, + randoms: self.randoms, + session_id: self.session_id, + suite: self.suite, + using_ems: self.using_ems, + server_kx: self.server_kx, + client_cert, + send_ticket: self.send_ticket, + })) + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + self + } +} + +// --- Process client's KeyExchange --- +struct ExpectClientKx<'a> { + config: Arc, + transcript: HandshakeHash, + randoms: ConnectionRandoms, + session_id: SessionId, + suite: &'static Tls12CipherSuite, + using_ems: bool, + server_kx: Box, + client_cert: Option>, + send_ticket: bool, +} + +impl State for ExpectClientKx<'_> { + fn handle<'m>( + mut self: Box, + cx: &mut ServerContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + let client_kx = require_handshake_msg!( + m, + HandshakeType::ClientKeyExchange, + HandshakePayload::ClientKeyExchange + )?; + self.transcript.add_message(&m); + let ems_seed = self + .using_ems + .then(|| self.transcript.current_hash()); + + // Complete key agreement, and set up encryption with the + // resulting premaster secret. + let peer_kx_params = tls12::decode_kx_params::( + self.suite.kx, + cx.common, + client_kx.bytes(), + )?; + let secrets = ConnectionSecrets::from_key_exchange( + self.server_kx, + peer_kx_params.pub_key(), + ems_seed, + self.randoms, + self.suite, + ) + .map_err(|err| { + cx.common + .send_fatal_alert(AlertDescription::IllegalParameter, err) + })?; + cx.common.kx_state.complete(); + + self.config.key_log.log( + "CLIENT_RANDOM", + &secrets.randoms.client, + &secrets.master_secret, + ); + cx.common + .start_encryption_tls12(&secrets, Side::Server); + + match self.client_cert { + Some(client_cert) => Ok(Box::new(ExpectCertificateVerify { + config: self.config, + secrets, + transcript: self.transcript, + session_id: self.session_id, + using_ems: self.using_ems, + client_cert, + send_ticket: self.send_ticket, + })), + _ => Ok(Box::new(ExpectCcs { + config: self.config, + secrets, + transcript: self.transcript, + session_id: self.session_id, + using_ems: self.using_ems, + resuming: false, + send_ticket: self.send_ticket, + })), + } + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + Box::new(ExpectClientKx { + config: self.config, + transcript: self.transcript, + randoms: self.randoms, + session_id: self.session_id, + suite: self.suite, + using_ems: self.using_ems, + server_kx: self.server_kx, + client_cert: self + .client_cert + .map(|cert| cert.into_owned()), + send_ticket: self.send_ticket, + }) + } +} + +// --- Process client's certificate proof --- +struct ExpectCertificateVerify<'a> { + config: Arc, + secrets: ConnectionSecrets, + transcript: HandshakeHash, + session_id: SessionId, + using_ems: bool, + client_cert: CertificateChain<'a>, + send_ticket: bool, +} + +impl State for ExpectCertificateVerify<'_> { + fn handle<'m>( + mut self: Box, + cx: &mut ServerContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + let rc = { + let sig = require_handshake_msg!( + m, + HandshakeType::CertificateVerify, + HandshakePayload::CertificateVerify + )?; + + match self.transcript.take_handshake_buf() { + Some(msgs) => { + let certs = &self.client_cert; + self.config + .verifier + .verify_tls12_signature(&msgs, &certs[0], sig) + } + None => { + // This should be unreachable; the handshake buffer was initialized with + // client authentication if the verifier wants to offer it. + // `transcript.abandon_client_auth()` can extract it, but its only caller in + // this flow will also set `ExpectClientKx::client_cert` to `None`, making it + // impossible to reach this state. + return Err(cx.common.send_fatal_alert( + AlertDescription::AccessDenied, + Error::General("client authentication not set up".into()), + )); + } + } + }; + + if let Err(e) = rc { + return Err(cx + .common + .send_cert_verify_error_alert(e)); + } + + trace!("client CertificateVerify OK"); + cx.common.peer_certificates = Some(self.client_cert.into_owned()); + + self.transcript.add_message(&m); + Ok(Box::new(ExpectCcs { + config: self.config, + secrets: self.secrets, + transcript: self.transcript, + session_id: self.session_id, + using_ems: self.using_ems, + resuming: false, + send_ticket: self.send_ticket, + })) + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + Box::new(ExpectCertificateVerify { + config: self.config, + secrets: self.secrets, + transcript: self.transcript, + session_id: self.session_id, + using_ems: self.using_ems, + client_cert: self.client_cert.into_owned(), + send_ticket: self.send_ticket, + }) + } +} + +// --- Process client's ChangeCipherSpec --- +struct ExpectCcs { + config: Arc, + secrets: ConnectionSecrets, + transcript: HandshakeHash, + session_id: SessionId, + using_ems: bool, + resuming: bool, + send_ticket: bool, +} + +impl State for ExpectCcs { + fn handle<'m>( + self: Box, + cx: &mut ServerContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + match m.payload { + MessagePayload::ChangeCipherSpec(..) => {} + payload => { + return Err(inappropriate_message( + &payload, + &[ContentType::ChangeCipherSpec], + )); + } + } + + // CCS should not be received interleaved with fragmented handshake-level + // message. + cx.common.check_aligned_handshake()?; + + cx.common + .record_layer + .start_decrypting(); + Ok(Box::new(ExpectFinished { + config: self.config, + secrets: self.secrets, + transcript: self.transcript, + session_id: self.session_id, + using_ems: self.using_ems, + resuming: self.resuming, + send_ticket: self.send_ticket, + })) + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + self + } +} + +// --- Process client's Finished --- +fn get_server_connection_value_tls12( + secrets: &ConnectionSecrets, + using_ems: bool, + cx: &ServerContext<'_>, + time_now: UnixTime, +) -> persist::ServerSessionValue { + let version = ProtocolVersion::TLSv1_2; + + let mut v = persist::ServerSessionValue::new( + cx.data.sni.as_ref(), + version, + secrets.suite().common.suite, + secrets.master_secret(), + cx.common.peer_certificates.clone(), + cx.common.alpn_protocol.clone(), + cx.data.resumption_data.clone(), + time_now, + 0, + ); + + if using_ems { + v.set_extended_ms_used(); + } + + v +} + +fn emit_ticket( + secrets: &ConnectionSecrets, + transcript: &mut HandshakeHash, + using_ems: bool, + cx: &mut ServerContext<'_>, + ticketer: &dyn ProducesTickets, + now: UnixTime, +) -> Result<(), Error> { + let plain = get_server_connection_value_tls12(secrets, using_ems, cx, now).get_encoding(); + + // If we can't produce a ticket for some reason, we can't + // report an error. Send an empty one. + let ticket = ticketer + .encrypt(&plain) + .unwrap_or_default(); + let ticket_lifetime = ticketer.lifetime(); + + let m = Message { + version: ProtocolVersion::TLSv1_2, + payload: MessagePayload::handshake(HandshakeMessagePayload( + HandshakePayload::NewSessionTicket(NewSessionTicketPayload::new( + ticket_lifetime, + ticket, + )), + )), + }; + + transcript.add_message(&m); + cx.common.send_msg(m, false); + Ok(()) +} + +fn emit_ccs(common: &mut CommonState) { + let m = Message { + version: ProtocolVersion::TLSv1_2, + payload: MessagePayload::ChangeCipherSpec(ChangeCipherSpecPayload {}), + }; + + common.send_msg(m, false); +} + +fn emit_finished( + secrets: &ConnectionSecrets, + transcript: &mut HandshakeHash, + common: &mut CommonState, +) { + let vh = transcript.current_hash(); + let verify_data = secrets.server_verify_data(&vh); + let verify_data_payload = Payload::new(verify_data); + + let f = Message { + version: ProtocolVersion::TLSv1_2, + payload: MessagePayload::handshake(HandshakeMessagePayload(HandshakePayload::Finished( + verify_data_payload, + ))), + }; + + transcript.add_message(&f); + common.send_msg(f, true); +} + +struct ExpectFinished { + config: Arc, + secrets: ConnectionSecrets, + transcript: HandshakeHash, + session_id: SessionId, + using_ems: bool, + resuming: bool, + send_ticket: bool, +} + +impl State for ExpectFinished { + fn handle<'m>( + mut self: Box, + cx: &mut ServerContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + let finished = + require_handshake_msg!(m, HandshakeType::Finished, HandshakePayload::Finished)?; + + cx.common.check_aligned_handshake()?; + + let vh = self.transcript.current_hash(); + let expect_verify_data = self.secrets.client_verify_data(&vh); + + let _fin_verified = + match ConstantTimeEq::ct_eq(&expect_verify_data[..], finished.bytes()).into() { + true => verify::FinishedMessageVerified::assertion(), + false => { + return Err(cx + .common + .send_fatal_alert(AlertDescription::DecryptError, Error::DecryptError)); + } + }; + + // Save connection, perhaps + if !self.resuming && !self.session_id.is_empty() { + let now = self.config.current_time()?; + + let value = get_server_connection_value_tls12(&self.secrets, self.using_ems, cx, now); + + let worked = self + .config + .session_storage + .put(self.session_id.as_ref().to_vec(), value.get_encoding()); + #[cfg_attr(not(feature = "logging"), allow(clippy::if_same_then_else))] + if worked { + debug!("Session saved"); + } else { + debug!("Session not saved"); + } + } + + // Send our CCS and Finished. + self.transcript.add_message(&m); + if !self.resuming { + if self.send_ticket { + let now = self.config.current_time()?; + emit_ticket( + &self.secrets, + &mut self.transcript, + self.using_ems, + cx, + &*self.config.ticketer, + now, + )?; + } + emit_ccs(cx.common); + cx.common + .record_layer + .start_encrypting(); + emit_finished(&self.secrets, &mut self.transcript, cx.common); + } + + cx.common + .start_traffic(&mut cx.sendable_plaintext); + Ok(Box::new(ExpectTraffic { + secrets: self.secrets, + _fin_verified, + })) + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + self + } +} + +// --- Process traffic --- +struct ExpectTraffic { + secrets: ConnectionSecrets, + _fin_verified: verify::FinishedMessageVerified, +} + +impl ExpectTraffic {} + +impl State for ExpectTraffic { + fn handle<'m>( + self: Box, + cx: &mut ServerContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + match m.payload { + MessagePayload::ApplicationData(payload) => cx + .common + .take_received_plaintext(payload), + payload => { + return Err(inappropriate_message( + &payload, + &[ContentType::ApplicationData], + )); + } + } + Ok(self) + } + + fn export_keying_material( + &self, + output: &mut [u8], + label: &[u8], + context: Option<&[u8]>, + ) -> Result<(), Error> { + self.secrets + .export_keying_material(output, label, context); + Ok(()) + } + + fn extract_secrets(&self) -> Result { + self.secrets + .extract_secrets(Side::Server) + } + + fn into_external_state(self: Box) -> Result, Error> { + Ok(self) + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + self + } +} + +impl KernelState for ExpectTraffic { + fn update_secrets(&mut self, _: Direction) -> Result { + Err(Error::General( + "TLS 1.2 connections do not support traffic secret updates".into(), + )) + } + + fn handle_new_session_ticket( + &mut self, + _cx: &mut KernelContext<'_>, + _message: &NewSessionTicketPayloadTls13, + ) -> Result<(), Error> { + unreachable!( + "server connections should never have handle_new_session_ticket called on them" + ) + } +} diff --git a/http/vendor/rustls/src/server/tls13.rs b/http/vendor/rustls/src/server/tls13.rs new file mode 100644 index 0000000..b8b70e7 --- /dev/null +++ b/http/vendor/rustls/src/server/tls13.rs @@ -0,0 +1,1535 @@ +use alloc::boxed::Box; +use alloc::vec; +use alloc::vec::Vec; + +pub(super) use client_hello::CompleteClientHelloHandling; +use pki_types::{CertificateDer, UnixTime}; +use subtle::ConstantTimeEq; + +use super::hs::{self, HandshakeHashOrBuffer, ServerContext}; +use super::server_conn::ServerConnectionData; +use crate::check::{inappropriate_handshake_message, inappropriate_message}; +use crate::common_state::{ + CommonState, HandshakeFlightTls13, HandshakeKind, Protocol, Side, State, +}; +use crate::conn::ConnectionRandoms; +use crate::conn::kernel::{Direction, KernelContext, KernelState}; +use crate::enums::{AlertDescription, ContentType, HandshakeType, ProtocolVersion}; +use crate::error::{Error, InvalidMessage, PeerIncompatible, PeerMisbehaved}; +use crate::hash_hs::HandshakeHash; +use crate::log::{debug, trace, warn}; +use crate::msgs::codec::{Codec, Reader}; +use crate::msgs::enums::KeyUpdateRequest; +use crate::msgs::handshake::{ + CERTIFICATE_MAX_SIZE_LIMIT, CertificateChain, CertificatePayloadTls13, HandshakeMessagePayload, + HandshakePayload, NewSessionTicketPayloadTls13, +}; +use crate::msgs::message::{Message, MessagePayload}; +use crate::msgs::persist; +use crate::server::ServerConfig; +use crate::suites::PartiallyExtractedSecrets; +use crate::sync::Arc; +use crate::tls13::key_schedule::{ + KeyScheduleResumption, KeyScheduleTraffic, KeyScheduleTrafficWithClientFinishedPending, +}; +use crate::tls13::{ + Tls13CipherSuite, construct_client_verify_message, construct_server_verify_message, +}; +use crate::{ConnectionTrafficSecrets, compress, rand, verify}; + +mod client_hello { + use super::*; + use crate::compress::CertCompressor; + use crate::crypto::SupportedKxGroup; + use crate::enums::SignatureScheme; + use crate::msgs::base::{Payload, PayloadU8}; + use crate::msgs::ccs::ChangeCipherSpecPayload; + use crate::msgs::enums::{Compression, NamedGroup}; + use crate::msgs::handshake::{ + CertificatePayloadTls13, CertificateRequestExtensions, CertificateRequestPayloadTls13, + ClientHelloPayload, HelloRetryRequest, HelloRetryRequestExtensions, KeyShareEntry, Random, + ServerExtensions, ServerExtensionsInput, ServerHelloPayload, SessionId, + }; + use crate::server::common::ActiveCertifiedKey; + use crate::sign; + use crate::tls13::key_schedule::{ + KeyScheduleEarly, KeyScheduleHandshake, KeySchedulePreHandshake, + }; + use crate::verify::DigitallySignedStruct; + + #[derive(PartialEq)] + pub(super) enum EarlyDataDecision { + Disabled, + RequestedButRejected, + Accepted, + } + + pub(in crate::server) struct CompleteClientHelloHandling { + pub(in crate::server) config: Arc, + pub(in crate::server) transcript: HandshakeHash, + pub(in crate::server) suite: &'static Tls13CipherSuite, + pub(in crate::server) randoms: ConnectionRandoms, + pub(in crate::server) done_retry: bool, + pub(in crate::server) send_tickets: usize, + pub(in crate::server) extra_exts: ServerExtensionsInput<'static>, + } + + fn max_early_data_size(configured: u32) -> usize { + if configured != 0 { + configured as usize + } else { + // The relevant max_early_data_size may in fact be unknowable: if + // we (the server) have turned off early_data but the client has + // a stale ticket from when we allowed early_data: we'll naturally + // reject early_data but need an upper bound on the amount of data + // to drop. + // + // Use a single maximum-sized message. + 16384 + } + } + + impl CompleteClientHelloHandling { + fn check_binder( + &self, + suite: &'static Tls13CipherSuite, + client_hello: &Message<'_>, + psk: &[u8], + binder: &[u8], + ) -> bool { + let binder_plaintext = match &client_hello.payload { + MessagePayload::Handshake { parsed, encoded } => { + &encoded.bytes()[..encoded.bytes().len() - parsed.total_binder_length()] + } + _ => unreachable!(), + }; + + let handshake_hash = self + .transcript + .hash_given(binder_plaintext); + + let key_schedule = KeyScheduleEarly::new(suite, psk); + let real_binder = + key_schedule.resumption_psk_binder_key_and_sign_verify_data(&handshake_hash); + + ConstantTimeEq::ct_eq(real_binder.as_ref(), binder).into() + } + + fn attempt_tls13_ticket_decryption( + &mut self, + ticket: &[u8], + ) -> Option { + if self.config.ticketer.enabled() { + self.config + .ticketer + .decrypt(ticket) + .and_then(|plain| persist::ServerSessionValue::read_bytes(&plain).ok()) + } else { + self.config + .session_storage + .take(ticket) + .and_then(|plain| persist::ServerSessionValue::read_bytes(&plain).ok()) + } + } + + pub(in crate::server) fn handle_client_hello( + mut self, + cx: &mut ServerContext<'_>, + server_key: ActiveCertifiedKey<'_>, + chm: &Message<'_>, + client_hello: &ClientHelloPayload, + selected_kxg: &'static dyn SupportedKxGroup, + mut sigschemes_ext: Vec, + ) -> hs::NextStateOrError<'static> { + if client_hello.compression_methods.len() != 1 { + return Err(cx.common.send_fatal_alert( + AlertDescription::IllegalParameter, + PeerMisbehaved::OfferedIncorrectCompressions, + )); + } + + sigschemes_ext.retain(SignatureScheme::supported_in_tls13); + + let shares_ext = client_hello + .key_shares + .as_ref() + .ok_or_else(|| { + cx.common.send_fatal_alert( + AlertDescription::HandshakeFailure, + PeerIncompatible::KeyShareExtensionRequired, + ) + })?; + + if client_hello.has_keyshare_extension_with_duplicates() { + return Err(cx.common.send_fatal_alert( + AlertDescription::IllegalParameter, + PeerMisbehaved::OfferedDuplicateKeyShares, + )); + } + + if client_hello.has_certificate_compression_extension_with_duplicates() { + return Err(cx.common.send_fatal_alert( + AlertDescription::IllegalParameter, + PeerMisbehaved::OfferedDuplicateCertificateCompressions, + )); + } + + let cert_compressor = client_hello + .certificate_compression_algorithms + .as_ref() + .and_then(|offered| + // prefer server order when choosing a compression: the client's + // extension here does not denote any preference. + self.config + .cert_compressors + .iter() + .find(|compressor| offered.contains(&compressor.algorithm())) + .cloned()); + + let early_data_requested = client_hello + .early_data_request + .is_some(); + + // EarlyData extension is illegal in second ClientHello + if self.done_retry && early_data_requested { + return Err({ + cx.common.send_fatal_alert( + AlertDescription::IllegalParameter, + PeerMisbehaved::EarlyDataAttemptedInSecondClientHello, + ) + }); + } + + // See if there is a KeyShare for the selected kx group. + let chosen_share_and_kxg = shares_ext.iter().find_map(|share| { + (share.group == selected_kxg.name()).then_some((share, selected_kxg)) + }); + + let Some(chosen_share_and_kxg) = chosen_share_and_kxg else { + // We don't have a suitable key share. Send a HelloRetryRequest + // for the mutually_preferred_group. + self.transcript.add_message(chm); + + if self.done_retry { + return Err(cx.common.send_fatal_alert( + AlertDescription::IllegalParameter, + PeerMisbehaved::RefusedToFollowHelloRetryRequest, + )); + } + + emit_hello_retry_request( + &mut self.transcript, + self.suite, + client_hello.session_id, + cx.common, + selected_kxg.name(), + ); + emit_fake_ccs(cx.common); + + let skip_early_data = max_early_data_size(self.config.max_early_data_size); + + let next = Box::new(hs::ExpectClientHello { + config: self.config, + transcript: HandshakeHashOrBuffer::Hash(self.transcript), + #[cfg(feature = "tls12")] + session_id: SessionId::empty(), + #[cfg(feature = "tls12")] + using_ems: false, + done_retry: true, + send_tickets: self.send_tickets, + extra_exts: self.extra_exts, + }); + + return if early_data_requested { + Ok(Box::new(ExpectAndSkipRejectedEarlyData { + skip_data_left: skip_early_data, + next, + })) + } else { + Ok(next) + }; + }; + + let mut chosen_psk_index = None; + let mut resumedata = None; + + if let Some(psk_offer) = &client_hello.preshared_key_offer { + // "A client MUST provide a "psk_key_exchange_modes" extension if it + // offers a "pre_shared_key" extension. If clients offer + // "pre_shared_key" without a "psk_key_exchange_modes" extension, + // servers MUST abort the handshake." - RFC8446 4.2.9 + if client_hello + .preshared_key_modes + .is_none() + { + return Err(cx.common.send_fatal_alert( + AlertDescription::MissingExtension, + PeerMisbehaved::MissingPskModesExtension, + )); + } + + if psk_offer.binders.is_empty() { + return Err(cx.common.send_fatal_alert( + AlertDescription::DecodeError, + PeerMisbehaved::MissingBinderInPskExtension, + )); + } + + if psk_offer.binders.len() != psk_offer.identities.len() { + return Err(cx.common.send_fatal_alert( + AlertDescription::IllegalParameter, + PeerMisbehaved::PskExtensionWithMismatchedIdsAndBinders, + )); + } + + let now = self.config.current_time()?; + + for (i, psk_id) in psk_offer.identities.iter().enumerate() { + let maybe_resume_data = self + .attempt_tls13_ticket_decryption(&psk_id.identity.0) + .map(|resumedata| { + resumedata.set_freshness(psk_id.obfuscated_ticket_age, now) + }) + .filter(|resumedata| { + hs::can_resume(self.suite.into(), &cx.data.sni, false, resumedata) + }); + + let Some(resume) = maybe_resume_data else { + continue; + }; + + if !self.check_binder( + self.suite, + chm, + &resume.master_secret.0, + psk_offer.binders[i].as_ref(), + ) { + return Err(cx.common.send_fatal_alert( + AlertDescription::DecryptError, + PeerMisbehaved::IncorrectBinder, + )); + } + + chosen_psk_index = Some(i); + resumedata = Some(resume); + break; + } + } + + if !client_hello + .preshared_key_modes + .as_ref() + .map(|offer| offer.psk_dhe) + .unwrap_or_default() + { + debug!("Client unwilling to resume, PSK_DHE_KE not offered"); + self.send_tickets = 0; + chosen_psk_index = None; + resumedata = None; + } else { + self.send_tickets = self.config.send_tls13_tickets; + } + + if let Some(resume) = &resumedata { + cx.data.received_resumption_data = Some(resume.application_data.0.clone()); + cx.common + .peer_certificates + .clone_from(&resume.client_cert_chain); + } + + let full_handshake = resumedata.is_none(); + self.transcript.add_message(chm); + let key_schedule = emit_server_hello( + &mut self.transcript, + &self.randoms, + self.suite, + cx, + &client_hello.session_id, + chosen_share_and_kxg, + chosen_psk_index, + resumedata + .as_ref() + .map(|x| &x.master_secret.0[..]), + &self.config, + )?; + if !self.done_retry { + emit_fake_ccs(cx.common); + } + + if full_handshake { + cx.common + .handshake_kind + .get_or_insert(HandshakeKind::Full); + } else { + cx.common.handshake_kind = Some(HandshakeKind::Resumed); + } + + let mut ocsp_response = server_key.get_ocsp(); + let mut flight = HandshakeFlightTls13::new(&mut self.transcript); + let doing_early_data = emit_encrypted_extensions( + &mut flight, + self.suite, + cx, + &mut ocsp_response, + client_hello, + resumedata.as_ref(), + self.extra_exts, + &self.config, + )?; + + let doing_client_auth = if full_handshake { + let client_auth = emit_certificate_req_tls13(&mut flight, &self.config)?; + + if let Some(compressor) = cert_compressor { + emit_compressed_certificate_tls13( + &mut flight, + &self.config, + server_key.get_cert(), + ocsp_response, + compressor, + ); + } else { + emit_certificate_tls13(&mut flight, server_key.get_cert(), ocsp_response); + } + emit_certificate_verify_tls13( + &mut flight, + cx.common, + server_key.get_key(), + &sigschemes_ext, + )?; + client_auth + } else { + false + }; + + // If we're not doing early data, then the next messages we receive + // are encrypted with the handshake keys. + match doing_early_data { + EarlyDataDecision::Disabled => { + key_schedule.set_handshake_decrypter(None, cx.common); + cx.data.early_data.reject(); + } + EarlyDataDecision::RequestedButRejected => { + debug!( + "Client requested early_data, but not accepted: switching to handshake keys with trial decryption" + ); + key_schedule.set_handshake_decrypter( + Some(max_early_data_size(self.config.max_early_data_size)), + cx.common, + ); + cx.data.early_data.reject(); + } + EarlyDataDecision::Accepted => { + cx.data + .early_data + .accept(self.config.max_early_data_size as usize); + } + } + + cx.common.check_aligned_handshake()?; + let key_schedule_traffic = + emit_finished_tls13(flight, &self.randoms, cx, key_schedule, &self.config); + + if !doing_client_auth && self.config.send_half_rtt_data { + // Application data can be sent immediately after Finished, in one + // flight. However, if client auth is enabled, we don't want to send + // application data to an unauthenticated peer. + cx.common + .start_outgoing_traffic(&mut cx.sendable_plaintext); + } + + if doing_client_auth { + if self + .config + .cert_decompressors + .is_empty() + { + Ok(Box::new(ExpectCertificate { + config: self.config, + transcript: self.transcript, + suite: self.suite, + key_schedule: key_schedule_traffic, + send_tickets: self.send_tickets, + message_already_in_transcript: false, + })) + } else { + Ok(Box::new(ExpectCertificateOrCompressedCertificate { + config: self.config, + transcript: self.transcript, + suite: self.suite, + key_schedule: key_schedule_traffic, + send_tickets: self.send_tickets, + })) + } + } else if doing_early_data == EarlyDataDecision::Accepted && !cx.common.is_quic() { + // Not used for QUIC: RFC 9001 §8.3: Clients MUST NOT send the EndOfEarlyData + // message. A server MUST treat receipt of a CRYPTO frame in a 0-RTT packet as a + // connection error of type PROTOCOL_VIOLATION. + Ok(Box::new(ExpectEarlyData { + config: self.config, + transcript: self.transcript, + suite: self.suite, + key_schedule: key_schedule_traffic, + send_tickets: self.send_tickets, + })) + } else { + Ok(Box::new(ExpectFinished { + config: self.config, + transcript: self.transcript, + suite: self.suite, + key_schedule: key_schedule_traffic, + send_tickets: self.send_tickets, + })) + } + } + } + + fn emit_server_hello( + transcript: &mut HandshakeHash, + randoms: &ConnectionRandoms, + suite: &'static Tls13CipherSuite, + cx: &mut ServerContext<'_>, + session_id: &SessionId, + share_and_kxgroup: (&KeyShareEntry, &'static dyn SupportedKxGroup), + chosen_psk_idx: Option, + resuming_psk: Option<&[u8]>, + config: &ServerConfig, + ) -> Result { + // Prepare key exchange; the caller already found the matching SupportedKxGroup + let (share, kxgroup) = share_and_kxgroup; + debug_assert_eq!(kxgroup.name(), share.group); + let ckx = kxgroup + .start_and_complete(&share.payload.0) + .map_err(|err| { + cx.common + .send_fatal_alert(AlertDescription::IllegalParameter, err) + })?; + cx.common.kx_state.complete(); + + let extensions = Box::new(ServerExtensions { + key_share: Some(KeyShareEntry::new(ckx.group, ckx.pub_key)), + selected_version: Some(ProtocolVersion::TLSv1_3), + preshared_key: chosen_psk_idx.map(|idx| idx as u16), + ..Default::default() + }); + + let sh = Message { + version: ProtocolVersion::TLSv1_2, + payload: MessagePayload::handshake(HandshakeMessagePayload( + HandshakePayload::ServerHello(ServerHelloPayload { + legacy_version: ProtocolVersion::TLSv1_2, + random: Random::from(randoms.server), + session_id: *session_id, + cipher_suite: suite.common.suite, + compression_method: Compression::Null, + extensions, + }), + )), + }; + + cx.common.check_aligned_handshake()?; + + let client_hello_hash = transcript.hash_given(&[]); + + trace!("sending server hello {sh:?}"); + transcript.add_message(&sh); + cx.common.send_msg(sh, false); + + // Start key schedule + let key_schedule_pre_handshake = if let Some(psk) = resuming_psk { + let early_key_schedule = KeyScheduleEarly::new(suite, psk); + early_key_schedule.client_early_traffic_secret( + &client_hello_hash, + &*config.key_log, + &randoms.client, + cx.common, + ); + + KeySchedulePreHandshake::from(early_key_schedule) + } else { + KeySchedulePreHandshake::new(suite) + }; + + // Do key exchange + let key_schedule = key_schedule_pre_handshake.into_handshake(ckx.secret); + + let handshake_hash = transcript.current_hash(); + let key_schedule = key_schedule.derive_server_handshake_secrets( + handshake_hash, + &*config.key_log, + &randoms.client, + cx.common, + ); + + Ok(key_schedule) + } + + fn emit_fake_ccs(common: &mut CommonState) { + if common.is_quic() { + return; + } + let m = Message { + version: ProtocolVersion::TLSv1_2, + payload: MessagePayload::ChangeCipherSpec(ChangeCipherSpecPayload {}), + }; + common.send_msg(m, false); + } + + fn emit_hello_retry_request( + transcript: &mut HandshakeHash, + suite: &'static Tls13CipherSuite, + session_id: SessionId, + common: &mut CommonState, + group: NamedGroup, + ) { + let req = HelloRetryRequest { + legacy_version: ProtocolVersion::TLSv1_2, + session_id, + cipher_suite: suite.common.suite, + extensions: HelloRetryRequestExtensions { + key_share: Some(group), + supported_versions: Some(ProtocolVersion::TLSv1_3), + ..Default::default() + }, + }; + + let m = Message { + version: ProtocolVersion::TLSv1_2, + payload: MessagePayload::handshake(HandshakeMessagePayload( + HandshakePayload::HelloRetryRequest(req), + )), + }; + + trace!("Requesting retry {m:?}"); + transcript.rollup_for_hrr(); + transcript.add_message(&m); + common.send_msg(m, false); + common.handshake_kind = Some(HandshakeKind::FullWithHelloRetryRequest); + } + + fn decide_if_early_data_allowed( + cx: &mut ServerContext<'_>, + client_hello: &ClientHelloPayload, + resumedata: Option<&persist::ServerSessionValue>, + suite: &'static Tls13CipherSuite, + config: &ServerConfig, + ) -> EarlyDataDecision { + let early_data_requested = client_hello + .early_data_request + .is_some(); + let rejected_or_disabled = match early_data_requested { + true => EarlyDataDecision::RequestedButRejected, + false => EarlyDataDecision::Disabled, + }; + + let Some(resume) = resumedata else { + // never any early data if not resuming. + return rejected_or_disabled; + }; + + /* Non-zero max_early_data_size controls whether early_data is allowed at all. + * We also require stateful resumption. */ + let early_data_configured = config.max_early_data_size > 0 && !config.ticketer.enabled(); + + /* "For PSKs provisioned via NewSessionTicket, a server MUST validate + * that the ticket age for the selected PSK identity (computed by + * subtracting ticket_age_add from PskIdentity.obfuscated_ticket_age + * modulo 2^32) is within a small tolerance of the time since the ticket + * was issued (see Section 8)." -- this is implemented in ServerSessionValue::set_freshness() + * and related. + * + * "In order to accept early data, the server [...] MUST verify that the + * following values are the same as those associated with the + * selected PSK: + * + * - The TLS version number + * - The selected cipher suite + * - The selected ALPN [RFC7301] protocol, if any" + * + * (RFC8446, 4.2.10) */ + let early_data_possible = early_data_requested + && resume.is_fresh() + && Some(resume.version) == cx.common.negotiated_version + && resume.cipher_suite == suite.common.suite + && resume.alpn.as_ref().map(|p| &p.0[..]) == cx.common.alpn_protocol.as_deref(); + + if early_data_configured && early_data_possible && !cx.data.early_data.was_rejected() { + EarlyDataDecision::Accepted + } else { + if cx.common.is_quic() { + // Clobber value set in tls13::emit_server_hello + cx.common.quic.early_secret = None; + } + + rejected_or_disabled + } + } + + fn emit_encrypted_extensions( + flight: &mut HandshakeFlightTls13<'_>, + suite: &'static Tls13CipherSuite, + cx: &mut ServerContext<'_>, + ocsp_response: &mut Option<&[u8]>, + hello: &ClientHelloPayload, + resumedata: Option<&persist::ServerSessionValue>, + extra_exts: ServerExtensionsInput<'static>, + config: &ServerConfig, + ) -> Result { + let mut ep = hs::ExtensionProcessing::new(extra_exts); + ep.process_common(config, cx, ocsp_response, hello, resumedata)?; + + let early_data = decide_if_early_data_allowed(cx, hello, resumedata, suite, config); + if early_data == EarlyDataDecision::Accepted { + ep.extensions.early_data_ack = Some(()); + } + + let ee = HandshakeMessagePayload(HandshakePayload::EncryptedExtensions(ep.extensions)); + + trace!("sending encrypted extensions {ee:?}"); + flight.add(ee); + Ok(early_data) + } + + fn emit_certificate_req_tls13( + flight: &mut HandshakeFlightTls13<'_>, + config: &ServerConfig, + ) -> Result { + if !config.verifier.offer_client_auth() { + return Ok(false); + } + + let cr = CertificateRequestPayloadTls13 { + context: PayloadU8::empty(), + extensions: CertificateRequestExtensions { + signature_algorithms: Some( + config + .verifier + .supported_verify_schemes(), + ), + certificate_compression_algorithms: match config.cert_decompressors.as_slice() { + &[] => None, + decomps => Some( + decomps + .iter() + .map(|decomp| decomp.algorithm()) + .collect(), + ), + }, + authority_names: match config.verifier.root_hint_subjects() { + &[] => None, + authorities => Some(authorities.to_vec()), + }, + }, + }; + + let creq = HandshakeMessagePayload(HandshakePayload::CertificateRequestTls13(cr)); + + trace!("Sending CertificateRequest {creq:?}"); + flight.add(creq); + Ok(true) + } + + fn emit_certificate_tls13( + flight: &mut HandshakeFlightTls13<'_>, + cert_chain: &[CertificateDer<'static>], + ocsp_response: Option<&[u8]>, + ) { + let cert = HandshakeMessagePayload(HandshakePayload::CertificateTls13( + CertificatePayloadTls13::new(cert_chain.iter(), ocsp_response), + )); + + trace!("sending certificate {cert:?}"); + flight.add(cert); + } + + fn emit_compressed_certificate_tls13( + flight: &mut HandshakeFlightTls13<'_>, + config: &ServerConfig, + cert_chain: &[CertificateDer<'static>], + ocsp_response: Option<&[u8]>, + cert_compressor: &'static dyn CertCompressor, + ) { + let payload = CertificatePayloadTls13::new(cert_chain.iter(), ocsp_response); + + let Ok(entry) = config + .cert_compression_cache + .compression_for(cert_compressor, &payload) + else { + return emit_certificate_tls13(flight, cert_chain, ocsp_response); + }; + + let c = HandshakeMessagePayload(HandshakePayload::CompressedCertificate( + entry.compressed_cert_payload(), + )); + + trace!("sending compressed certificate {c:?}"); + flight.add(c); + } + + fn emit_certificate_verify_tls13( + flight: &mut HandshakeFlightTls13<'_>, + common: &mut CommonState, + signing_key: &dyn sign::SigningKey, + schemes: &[SignatureScheme], + ) -> Result<(), Error> { + let message = construct_server_verify_message(&flight.transcript.current_hash()); + + let signer = signing_key + .choose_scheme(schemes) + .ok_or_else(|| { + common.send_fatal_alert( + AlertDescription::HandshakeFailure, + PeerIncompatible::NoSignatureSchemesInCommon, + ) + })?; + + let scheme = signer.scheme(); + let sig = signer.sign(message.as_ref())?; + + let cv = DigitallySignedStruct::new(scheme, sig); + + let cv = HandshakeMessagePayload(HandshakePayload::CertificateVerify(cv)); + + trace!("sending certificate-verify {cv:?}"); + flight.add(cv); + Ok(()) + } + + fn emit_finished_tls13( + mut flight: HandshakeFlightTls13<'_>, + randoms: &ConnectionRandoms, + cx: &mut ServerContext<'_>, + key_schedule: KeyScheduleHandshake, + config: &ServerConfig, + ) -> KeyScheduleTrafficWithClientFinishedPending { + let handshake_hash = flight.transcript.current_hash(); + let verify_data = key_schedule.sign_server_finish(&handshake_hash); + let verify_data_payload = Payload::new(verify_data.as_ref()); + + let fin = HandshakeMessagePayload(HandshakePayload::Finished(verify_data_payload)); + + trace!("sending finished {fin:?}"); + flight.add(fin); + let hash_at_server_fin = flight.transcript.current_hash(); + flight.finish(cx.common); + + // Now move to application data keys. Read key change is deferred until + // the Finish message is received & validated. + key_schedule.into_traffic_with_client_finished_pending( + hash_at_server_fin, + &*config.key_log, + &randoms.client, + cx.common, + ) + } +} + +struct ExpectAndSkipRejectedEarlyData { + skip_data_left: usize, + next: Box, +} + +impl State for ExpectAndSkipRejectedEarlyData { + fn handle<'m>( + mut self: Box, + cx: &mut ServerContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + /* "The server then ignores early data by skipping all records with an external + * content type of "application_data" (indicating that they are encrypted), + * up to the configured max_early_data_size." + * (RFC8446, 14.2.10) */ + if let MessagePayload::ApplicationData(skip_data) = &m.payload { + if skip_data.bytes().len() <= self.skip_data_left { + self.skip_data_left -= skip_data.bytes().len(); + return Ok(self); + } + } + + self.next.handle(cx, m) + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + self + } +} + +struct ExpectCertificateOrCompressedCertificate { + config: Arc, + transcript: HandshakeHash, + suite: &'static Tls13CipherSuite, + key_schedule: KeyScheduleTrafficWithClientFinishedPending, + send_tickets: usize, +} + +impl State for ExpectCertificateOrCompressedCertificate { + fn handle<'m>( + self: Box, + cx: &mut ServerContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + match m.payload { + MessagePayload::Handshake { + parsed: HandshakeMessagePayload(HandshakePayload::CertificateTls13(..)), + .. + } => Box::new(ExpectCertificate { + config: self.config, + transcript: self.transcript, + suite: self.suite, + key_schedule: self.key_schedule, + send_tickets: self.send_tickets, + message_already_in_transcript: false, + }) + .handle(cx, m), + + MessagePayload::Handshake { + parsed: HandshakeMessagePayload(HandshakePayload::CompressedCertificate(..)), + .. + } => Box::new(ExpectCompressedCertificate { + config: self.config, + transcript: self.transcript, + suite: self.suite, + key_schedule: self.key_schedule, + send_tickets: self.send_tickets, + }) + .handle(cx, m), + + payload => Err(inappropriate_handshake_message( + &payload, + &[ContentType::Handshake], + &[ + HandshakeType::Certificate, + HandshakeType::CompressedCertificate, + ], + )), + } + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + self + } +} + +struct ExpectCompressedCertificate { + config: Arc, + transcript: HandshakeHash, + suite: &'static Tls13CipherSuite, + key_schedule: KeyScheduleTrafficWithClientFinishedPending, + send_tickets: usize, +} + +impl State for ExpectCompressedCertificate { + fn handle<'m>( + mut self: Box, + cx: &mut ServerContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + self.transcript.add_message(&m); + let compressed_cert = require_handshake_msg_move!( + m, + HandshakeType::CompressedCertificate, + HandshakePayload::CompressedCertificate + )?; + + let selected_decompressor = self + .config + .cert_decompressors + .iter() + .find(|item| item.algorithm() == compressed_cert.alg); + + let Some(decompressor) = selected_decompressor else { + return Err(cx.common.send_fatal_alert( + AlertDescription::BadCertificate, + PeerMisbehaved::SelectedUnofferedCertCompression, + )); + }; + + if compressed_cert.uncompressed_len as usize > CERTIFICATE_MAX_SIZE_LIMIT { + return Err(cx.common.send_fatal_alert( + AlertDescription::BadCertificate, + InvalidMessage::MessageTooLarge, + )); + } + + let mut decompress_buffer = vec![0u8; compressed_cert.uncompressed_len as usize]; + if let Err(compress::DecompressionFailed) = + decompressor.decompress(compressed_cert.compressed.0.bytes(), &mut decompress_buffer) + { + return Err(cx.common.send_fatal_alert( + AlertDescription::BadCertificate, + PeerMisbehaved::InvalidCertCompression, + )); + } + + let cert_payload = + match CertificatePayloadTls13::read(&mut Reader::init(&decompress_buffer)) { + Ok(cm) => cm, + Err(err) => { + return Err(cx + .common + .send_fatal_alert(AlertDescription::BadCertificate, err)); + } + }; + trace!( + "Client certificate decompressed using {:?} ({} bytes -> {})", + compressed_cert.alg, + compressed_cert + .compressed + .0 + .bytes() + .len(), + compressed_cert.uncompressed_len, + ); + + let m = Message { + version: ProtocolVersion::TLSv1_3, + payload: MessagePayload::handshake(HandshakeMessagePayload( + HandshakePayload::CertificateTls13(cert_payload.into_owned()), + )), + }; + + Box::new(ExpectCertificate { + config: self.config, + transcript: self.transcript, + suite: self.suite, + key_schedule: self.key_schedule, + send_tickets: self.send_tickets, + message_already_in_transcript: true, + }) + .handle(cx, m) + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + self + } +} + +struct ExpectCertificate { + config: Arc, + transcript: HandshakeHash, + suite: &'static Tls13CipherSuite, + key_schedule: KeyScheduleTrafficWithClientFinishedPending, + send_tickets: usize, + message_already_in_transcript: bool, +} + +impl State for ExpectCertificate { + fn handle<'m>( + mut self: Box, + cx: &mut ServerContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + if !self.message_already_in_transcript { + self.transcript.add_message(&m); + } + let certp = require_handshake_msg_move!( + m, + HandshakeType::Certificate, + HandshakePayload::CertificateTls13 + )?; + + // We don't send any CertificateRequest extensions, so any extensions + // here are illegal. + if certp + .entries + .iter() + .any(|e| !e.extensions.only_contains(&[])) + { + return Err(PeerMisbehaved::UnsolicitedCertExtension.into()); + } + + let client_cert = certp.into_certificate_chain(); + + let mandatory = self + .config + .verifier + .client_auth_mandatory(); + + let Some((end_entity, intermediates)) = client_cert.split_first() else { + if !mandatory { + debug!("client auth requested but no certificate supplied"); + self.transcript.abandon_client_auth(); + return Ok(Box::new(ExpectFinished { + config: self.config, + suite: self.suite, + key_schedule: self.key_schedule, + transcript: self.transcript, + send_tickets: self.send_tickets, + })); + } + + return Err(cx.common.send_fatal_alert( + AlertDescription::CertificateRequired, + Error::NoCertificatesPresented, + )); + }; + + let now = self.config.current_time()?; + + self.config + .verifier + .verify_client_cert(end_entity, intermediates, now) + .map_err(|err| { + cx.common + .send_cert_verify_error_alert(err) + })?; + + Ok(Box::new(ExpectCertificateVerify { + config: self.config, + suite: self.suite, + transcript: self.transcript, + key_schedule: self.key_schedule, + client_cert: client_cert.into_owned(), + send_tickets: self.send_tickets, + })) + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + self + } +} + +struct ExpectCertificateVerify { + config: Arc, + transcript: HandshakeHash, + suite: &'static Tls13CipherSuite, + key_schedule: KeyScheduleTrafficWithClientFinishedPending, + client_cert: CertificateChain<'static>, + send_tickets: usize, +} + +impl State for ExpectCertificateVerify { + fn handle<'m>( + mut self: Box, + cx: &mut ServerContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + let rc = { + let sig = require_handshake_msg!( + m, + HandshakeType::CertificateVerify, + HandshakePayload::CertificateVerify + )?; + let handshake_hash = self.transcript.current_hash(); + self.transcript.abandon_client_auth(); + let certs = &self.client_cert; + let msg = construct_client_verify_message(&handshake_hash); + + self.config + .verifier + .verify_tls13_signature(msg.as_ref(), &certs[0], sig) + }; + + if let Err(e) = rc { + return Err(cx + .common + .send_cert_verify_error_alert(e)); + } + + trace!("client CertificateVerify OK"); + cx.common.peer_certificates = Some(self.client_cert); + + self.transcript.add_message(&m); + Ok(Box::new(ExpectFinished { + config: self.config, + suite: self.suite, + key_schedule: self.key_schedule, + transcript: self.transcript, + send_tickets: self.send_tickets, + })) + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + self + } +} + +// --- Process (any number of) early ApplicationData messages, +// followed by a terminating handshake EndOfEarlyData message --- + +struct ExpectEarlyData { + config: Arc, + transcript: HandshakeHash, + suite: &'static Tls13CipherSuite, + key_schedule: KeyScheduleTrafficWithClientFinishedPending, + send_tickets: usize, +} + +impl State for ExpectEarlyData { + fn handle<'m>( + mut self: Box, + cx: &mut ServerContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + match m.payload { + MessagePayload::ApplicationData(payload) => { + match cx + .data + .early_data + .take_received_plaintext(payload) + { + true => Ok(self), + false => Err(cx.common.send_fatal_alert( + AlertDescription::UnexpectedMessage, + PeerMisbehaved::TooMuchEarlyDataReceived, + )), + } + } + MessagePayload::Handshake { + parsed: HandshakeMessagePayload(HandshakePayload::EndOfEarlyData), + .. + } => { + self.key_schedule + .update_decrypter(cx.common); + self.transcript.add_message(&m); + Ok(Box::new(ExpectFinished { + config: self.config, + suite: self.suite, + key_schedule: self.key_schedule, + transcript: self.transcript, + send_tickets: self.send_tickets, + })) + } + payload => Err(inappropriate_handshake_message( + &payload, + &[ContentType::ApplicationData, ContentType::Handshake], + &[HandshakeType::EndOfEarlyData], + )), + } + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + self + } +} + +// --- Process client's Finished --- +fn get_server_session_value( + suite: &'static Tls13CipherSuite, + resumption: &KeyScheduleResumption, + cx: &ServerContext<'_>, + nonce: &[u8], + time_now: UnixTime, + age_obfuscation_offset: u32, +) -> persist::ServerSessionValue { + let version = ProtocolVersion::TLSv1_3; + + let secret = resumption.derive_ticket_psk(nonce); + + persist::ServerSessionValue::new( + cx.data.sni.as_ref(), + version, + suite.common.suite, + secret.as_ref(), + cx.common.peer_certificates.clone(), + cx.common.alpn_protocol.clone(), + cx.data.resumption_data.clone(), + time_now, + age_obfuscation_offset, + ) +} + +struct ExpectFinished { + config: Arc, + transcript: HandshakeHash, + suite: &'static Tls13CipherSuite, + key_schedule: KeyScheduleTrafficWithClientFinishedPending, + send_tickets: usize, +} + +impl ExpectFinished { + fn emit_ticket( + flight: &mut HandshakeFlightTls13<'_>, + suite: &'static Tls13CipherSuite, + cx: &ServerContext<'_>, + resumption: &KeyScheduleResumption, + config: &ServerConfig, + ) -> Result<(), Error> { + let secure_random = config.provider.secure_random; + let nonce = rand::random_vec(secure_random, 32)?; + let age_add = rand::random_u32(secure_random)?; + + let now = config.current_time()?; + + let plain = + get_server_session_value(suite, resumption, cx, &nonce, now, age_add).get_encoding(); + + let stateless = config.ticketer.enabled(); + let (ticket, lifetime) = if stateless { + let Some(ticket) = config.ticketer.encrypt(&plain) else { + return Ok(()); + }; + (ticket, config.ticketer.lifetime()) + } else { + let id = rand::random_vec(secure_random, 32)?; + let stored = config + .session_storage + .put(id.clone(), plain); + if !stored { + trace!("resumption not available; not issuing ticket"); + return Ok(()); + } + let stateful_lifetime = 24 * 60 * 60; // this is a bit of a punt + (id, stateful_lifetime) + }; + + let mut payload = NewSessionTicketPayloadTls13::new(lifetime, age_add, nonce, ticket); + + if config.max_early_data_size > 0 { + if !stateless { + payload.extensions.max_early_data_size = Some(config.max_early_data_size); + } else { + // We implement RFC8446 section 8.1: by enforcing that 0-RTT is + // only possible if using stateful resumption + warn!("early_data with stateless resumption is not allowed"); + } + } + + let t = HandshakeMessagePayload(HandshakePayload::NewSessionTicketTls13(payload)); + trace!("sending new ticket {t:?} (stateless: {stateless})"); + flight.add(t); + + Ok(()) + } +} + +impl State for ExpectFinished { + fn handle<'m>( + mut self: Box, + cx: &mut ServerContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + let finished = + require_handshake_msg!(m, HandshakeType::Finished, HandshakePayload::Finished)?; + + let handshake_hash = self.transcript.current_hash(); + let (key_schedule_before_finished, expect_verify_data) = self + .key_schedule + .sign_client_finish(&handshake_hash, cx.common); + + let fin = match ConstantTimeEq::ct_eq(expect_verify_data.as_ref(), finished.bytes()).into() + { + true => verify::FinishedMessageVerified::assertion(), + false => { + return Err(cx + .common + .send_fatal_alert(AlertDescription::DecryptError, Error::DecryptError)); + } + }; + + // Note: future derivations include Client Finished, but not the + // main application data keying. + self.transcript.add_message(&m); + + cx.common.check_aligned_handshake()?; + + let (key_schedule_traffic, resumption) = + key_schedule_before_finished.into_traffic(self.transcript.current_hash()); + + let mut flight = HandshakeFlightTls13::new(&mut self.transcript); + for _ in 0..self.send_tickets { + Self::emit_ticket(&mut flight, self.suite, cx, &resumption, &self.config)?; + } + flight.finish(cx.common); + + // Application data may now flow, even if we have client auth enabled. + cx.common + .start_traffic(&mut cx.sendable_plaintext); + + Ok(match cx.common.is_quic() { + true => Box::new(ExpectQuicTraffic { + key_schedule: key_schedule_traffic, + _fin_verified: fin, + }), + false => Box::new(ExpectTraffic { + key_schedule: key_schedule_traffic, + _fin_verified: fin, + }), + }) + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + self + } +} + +// --- Process traffic --- +struct ExpectTraffic { + key_schedule: KeyScheduleTraffic, + _fin_verified: verify::FinishedMessageVerified, +} + +impl ExpectTraffic { + fn handle_key_update( + &mut self, + common: &mut CommonState, + key_update_request: &KeyUpdateRequest, + ) -> Result<(), Error> { + if let Protocol::Quic = common.protocol { + return Err(common.send_fatal_alert( + AlertDescription::UnexpectedMessage, + PeerMisbehaved::KeyUpdateReceivedInQuicConnection, + )); + } + + common.check_aligned_handshake()?; + + if common.should_update_key(key_update_request)? { + self.key_schedule + .update_encrypter_and_notify(common); + } + + // Update our read-side keys. + self.key_schedule + .update_decrypter(common); + Ok(()) + } +} + +impl State for ExpectTraffic { + fn handle<'m>( + mut self: Box, + cx: &mut ServerContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + match m.payload { + MessagePayload::ApplicationData(payload) => cx + .common + .take_received_plaintext(payload), + MessagePayload::Handshake { + parsed: HandshakeMessagePayload(HandshakePayload::KeyUpdate(key_update)), + .. + } => self.handle_key_update(cx.common, &key_update)?, + payload => { + return Err(inappropriate_handshake_message( + &payload, + &[ContentType::ApplicationData, ContentType::Handshake], + &[HandshakeType::KeyUpdate], + )); + } + } + + Ok(self) + } + + fn export_keying_material( + &self, + output: &mut [u8], + label: &[u8], + context: Option<&[u8]>, + ) -> Result<(), Error> { + self.key_schedule + .export_keying_material(output, label, context) + } + + fn extract_secrets(&self) -> Result { + self.key_schedule + .extract_secrets(Side::Server) + } + + fn send_key_update_request(&mut self, common: &mut CommonState) -> Result<(), Error> { + self.key_schedule + .request_key_update_and_update_encrypter(common) + } + + fn into_external_state(self: Box) -> Result, Error> { + Ok(self) + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + self + } +} + +impl KernelState for ExpectTraffic { + fn update_secrets(&mut self, dir: Direction) -> Result { + self.key_schedule + .refresh_traffic_secret(match dir { + Direction::Transmit => Side::Server, + Direction::Receive => Side::Client, + }) + } + + fn handle_new_session_ticket( + &mut self, + _cx: &mut KernelContext<'_>, + _message: &NewSessionTicketPayloadTls13, + ) -> Result<(), Error> { + unreachable!( + "server connections should never have handle_new_session_ticket called on them" + ) + } +} + +struct ExpectQuicTraffic { + key_schedule: KeyScheduleTraffic, + _fin_verified: verify::FinishedMessageVerified, +} + +impl State for ExpectQuicTraffic { + fn handle<'m>( + self: Box, + _cx: &mut ServerContext<'_>, + m: Message<'m>, + ) -> hs::NextStateOrError<'m> + where + Self: 'm, + { + // reject all messages + Err(inappropriate_message(&m.payload, &[])) + } + + fn export_keying_material( + &self, + output: &mut [u8], + label: &[u8], + context: Option<&[u8]>, + ) -> Result<(), Error> { + self.key_schedule + .export_keying_material(output, label, context) + } + + fn into_owned(self: Box) -> hs::NextState<'static> { + self + } +} + +impl KernelState for ExpectQuicTraffic { + fn update_secrets(&mut self, _: Direction) -> Result { + Err(Error::General( + "QUIC connections do not support key updates".into(), + )) + } + + fn handle_new_session_ticket( + &mut self, + _cx: &mut KernelContext<'_>, + _message: &NewSessionTicketPayloadTls13, + ) -> Result<(), Error> { + unreachable!("handle_new_session_ticket should not be called for server-side connections") + } +} diff --git a/http/vendor/rustls/src/stream.rs b/http/vendor/rustls/src/stream.rs new file mode 100644 index 0000000..ee57862 --- /dev/null +++ b/http/vendor/rustls/src/stream.rs @@ -0,0 +1,285 @@ +use core::ops::{Deref, DerefMut}; +use std::io::{BufRead, IoSlice, Read, Result, Write}; + +use crate::conn::{ConnectionCommon, SideData}; + +/// This type implements `io::Read` and `io::Write`, encapsulating +/// a Connection `C` and an underlying transport `T`, such as a socket. +/// +/// Relies on [`ConnectionCommon::complete_io()`] to perform the necessary I/O. +/// +/// This allows you to use a rustls Connection like a normal stream. +#[derive(Debug)] +pub struct Stream<'a, C: 'a + ?Sized, T: 'a + Read + Write + ?Sized> { + /// Our TLS connection + pub conn: &'a mut C, + + /// The underlying transport, like a socket + pub sock: &'a mut T, +} + +impl<'a, C, T, S> Stream<'a, C, T> +where + C: 'a + DerefMut + Deref>, + T: 'a + Read + Write, + S: SideData, +{ + /// Make a new Stream using the Connection `conn` and socket-like object + /// `sock`. This does not fail and does no IO. + pub fn new(conn: &'a mut C, sock: &'a mut T) -> Self { + Self { conn, sock } + } + + /// If we're handshaking, complete all the IO for that. + /// If we have data to write, write it all. + fn complete_prior_io(&mut self) -> Result<()> { + if self.conn.is_handshaking() { + self.conn.complete_io(self.sock)?; + } + + if self.conn.wants_write() { + self.conn.complete_io(self.sock)?; + } + + Ok(()) + } + + fn prepare_read(&mut self) -> Result<()> { + self.complete_prior_io()?; + + // We call complete_io() in a loop since a single call may read only + // a partial packet from the underlying transport. A full packet is + // needed to get more plaintext, which we must do if EOF has not been + // hit. + while self.conn.wants_read() { + if self.conn.complete_io(self.sock)?.0 == 0 { + break; + } + } + + Ok(()) + } + + // Implements `BufRead::fill_buf` but with more flexible lifetimes, so StreamOwned can reuse it + fn fill_buf(mut self) -> Result<&'a [u8]> + where + S: 'a, + { + self.prepare_read()?; + self.conn.reader().into_first_chunk() + } +} + +impl<'a, C, T, S> Read for Stream<'a, C, T> +where + C: 'a + DerefMut + Deref>, + T: 'a + Read + Write, + S: SideData, +{ + fn read(&mut self, buf: &mut [u8]) -> Result { + self.prepare_read()?; + self.conn.reader().read(buf) + } + + #[cfg(read_buf)] + fn read_buf(&mut self, cursor: core::io::BorrowedCursor<'_, u8>) -> Result<()> { + self.prepare_read()?; + self.conn.reader().read_buf(cursor) + } +} + +impl<'a, C, T, S> BufRead for Stream<'a, C, T> +where + C: 'a + DerefMut + Deref>, + T: 'a + Read + Write, + S: 'a + SideData, +{ + fn fill_buf(&mut self) -> Result<&[u8]> { + // reborrow to get an owned `Stream` + Stream { + conn: self.conn, + sock: self.sock, + } + .fill_buf() + } + + fn consume(&mut self, amt: usize) { + self.conn.reader().consume(amt) + } +} + +impl<'a, C, T, S> Write for Stream<'a, C, T> +where + C: 'a + DerefMut + Deref>, + T: 'a + Read + Write, + S: SideData, +{ + fn write(&mut self, buf: &[u8]) -> Result { + self.complete_prior_io()?; + + let len = self.conn.writer().write(buf)?; + + // Try to write the underlying transport here, but don't let + // any errors mask the fact we've consumed `len` bytes. + // Callers will learn of permanent errors on the next call. + let _ = self.conn.complete_io(self.sock); + + Ok(len) + } + + fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result { + self.complete_prior_io()?; + + let len = self + .conn + .writer() + .write_vectored(bufs)?; + + // Try to write the underlying transport here, but don't let + // any errors mask the fact we've consumed `len` bytes. + // Callers will learn of permanent errors on the next call. + let _ = self.conn.complete_io(self.sock); + + Ok(len) + } + + fn flush(&mut self) -> Result<()> { + self.complete_prior_io()?; + + self.conn.writer().flush()?; + if self.conn.wants_write() { + self.conn.complete_io(self.sock)?; + } + Ok(()) + } +} + +/// This type implements `io::Read` and `io::Write`, encapsulating +/// and owning a Connection `C` and an underlying transport `T`, such as a socket. +/// +/// Relies on [`ConnectionCommon::complete_io()`] to perform the necessary I/O. +/// +/// This allows you to use a rustls Connection like a normal stream. +#[derive(Debug)] +pub struct StreamOwned { + /// Our connection + pub conn: C, + + /// The underlying transport, like a socket + pub sock: T, +} + +impl StreamOwned +where + C: DerefMut + Deref>, + T: Read + Write, + S: SideData, +{ + /// Make a new StreamOwned taking the Connection `conn` and socket-like + /// object `sock`. This does not fail and does no IO. + /// + /// This is the same as `Stream::new` except `conn` and `sock` are + /// moved into the StreamOwned. + pub fn new(conn: C, sock: T) -> Self { + Self { conn, sock } + } + + /// Get a reference to the underlying socket + pub fn get_ref(&self) -> &T { + &self.sock + } + + /// Get a mutable reference to the underlying socket + pub fn get_mut(&mut self) -> &mut T { + &mut self.sock + } + + /// Extract the `conn` and `sock` parts from the `StreamOwned` + pub fn into_parts(self) -> (C, T) { + (self.conn, self.sock) + } +} + +impl<'a, C, T, S> StreamOwned +where + C: DerefMut + Deref>, + T: Read + Write, + S: SideData, +{ + fn as_stream(&'a mut self) -> Stream<'a, C, T> { + Stream { + conn: &mut self.conn, + sock: &mut self.sock, + } + } +} + +impl Read for StreamOwned +where + C: DerefMut + Deref>, + T: Read + Write, + S: SideData, +{ + fn read(&mut self, buf: &mut [u8]) -> Result { + self.as_stream().read(buf) + } + + #[cfg(read_buf)] + fn read_buf(&mut self, cursor: core::io::BorrowedCursor<'_, u8>) -> Result<()> { + self.as_stream().read_buf(cursor) + } +} + +impl BufRead for StreamOwned +where + C: DerefMut + Deref>, + T: Read + Write, + S: 'static + SideData, +{ + fn fill_buf(&mut self) -> Result<&[u8]> { + self.as_stream().fill_buf() + } + + fn consume(&mut self, amt: usize) { + self.as_stream().consume(amt) + } +} + +impl Write for StreamOwned +where + C: DerefMut + Deref>, + T: Read + Write, + S: SideData, +{ + fn write(&mut self, buf: &[u8]) -> Result { + self.as_stream().write(buf) + } + + fn flush(&mut self) -> Result<()> { + self.as_stream().flush() + } +} + +#[cfg(test)] +mod tests { + use std::net::TcpStream; + + use super::{Stream, StreamOwned}; + use crate::client::ClientConnection; + use crate::server::ServerConnection; + + #[test] + fn stream_can_be_created_for_connection_and_tcpstream() { + type _Test<'a> = Stream<'a, ClientConnection, TcpStream>; + } + + #[test] + fn streamowned_can_be_created_for_client_and_tcpstream() { + type _Test = StreamOwned; + } + + #[test] + fn streamowned_can_be_created_for_server_and_tcpstream() { + type _Test = StreamOwned; + } +} diff --git a/http/vendor/rustls/src/suites.rs b/http/vendor/rustls/src/suites.rs new file mode 100644 index 0000000..aebe1a3 --- /dev/null +++ b/http/vendor/rustls/src/suites.rs @@ -0,0 +1,273 @@ +use core::fmt; + +use crate::common_state::Protocol; +use crate::crypto::cipher::{AeadKey, Iv}; +use crate::crypto::{self, KeyExchangeAlgorithm}; +use crate::enums::{CipherSuite, SignatureAlgorithm, SignatureScheme}; +use crate::msgs::handshake::ALL_KEY_EXCHANGE_ALGORITHMS; +#[cfg(feature = "tls12")] +use crate::tls12::Tls12CipherSuite; +use crate::tls13::Tls13CipherSuite; +#[cfg(feature = "tls12")] +use crate::versions::TLS12; +use crate::versions::{SupportedProtocolVersion, TLS13}; + +/// Common state for cipher suites (both for TLS 1.2 and TLS 1.3) +pub struct CipherSuiteCommon { + /// The TLS enumeration naming this cipher suite. + pub suite: CipherSuite, + + /// Which hash function the suite uses. + pub hash_provider: &'static dyn crypto::hash::Hash, + + /// Number of TCP-TLS messages that can be safely encrypted with a single key of this type + /// + /// Once a `MessageEncrypter` produced for this suite has encrypted more than + /// `confidentiality_limit` messages, an attacker gains an advantage in distinguishing it + /// from an ideal pseudorandom permutation (PRP). + /// + /// This is to be set on the assumption that messages are maximally sized -- + /// each is 214 bytes. It **does not** consider confidentiality limits for + /// QUIC connections - see the [`quic::PacketKey::confidentiality_limit`] field for + /// this context. + /// + /// For AES-GCM implementations, this should be set to 224 to limit attack + /// probability to one in 260. See [AEBounds] (Table 1) and [draft-irtf-aead-limits-08]: + /// + /// ```python + /// >>> p = 2 ** -60 + /// >>> L = (2 ** 14 // 16) + 1 + /// >>> qlim = (math.sqrt(p) * (2 ** (129 // 2)) - 1) / (L + 1) + /// >>> print(int(qlim).bit_length()) + /// 24 + /// ``` + /// [AEBounds]: https://eprint.iacr.org/2024/051.pdf + /// [draft-irtf-aead-limits-08]: https://www.ietf.org/archive/id/draft-irtf-cfrg-aead-limits-08.html#section-5.1.1 + /// [`quic::PacketKey::confidentiality_limit`]: crate::quic::PacketKey::confidentiality_limit + /// + /// For chacha20-poly1305 implementations, this should be set to `u64::MAX`: + /// see + pub confidentiality_limit: u64, +} + +impl CipherSuiteCommon { + /// Return `true` if this is backed by a FIPS-approved implementation. + /// + /// This means all the constituent parts that do cryptography return `true` for `fips()`. + pub fn fips(&self) -> bool { + self.hash_provider.fips() + } +} + +/// A cipher suite supported by rustls. +/// +/// This type carries both configuration and implementation. Compare with +/// [`CipherSuite`], which carries solely a cipher suite identifier. +#[derive(Clone, Copy, PartialEq)] +pub enum SupportedCipherSuite { + /// A TLS 1.2 cipher suite + #[cfg(feature = "tls12")] + Tls12(&'static Tls12CipherSuite), + /// A TLS 1.3 cipher suite + Tls13(&'static Tls13CipherSuite), +} + +impl SupportedCipherSuite { + /// The cipher suite's identifier + pub fn suite(&self) -> CipherSuite { + self.common().suite + } + + /// The hash function the ciphersuite uses. + pub(crate) fn hash_provider(&self) -> &'static dyn crypto::hash::Hash { + self.common().hash_provider + } + + pub(crate) fn common(&self) -> &CipherSuiteCommon { + match self { + #[cfg(feature = "tls12")] + Self::Tls12(inner) => &inner.common, + Self::Tls13(inner) => &inner.common, + } + } + + /// Return the inner `Tls13CipherSuite` for this suite, if it is a TLS1.3 suite. + pub fn tls13(&self) -> Option<&'static Tls13CipherSuite> { + match self { + #[cfg(feature = "tls12")] + Self::Tls12(_) => None, + Self::Tls13(inner) => Some(inner), + } + } + + /// Return supported protocol version for the cipher suite. + pub fn version(&self) -> &'static SupportedProtocolVersion { + match self { + #[cfg(feature = "tls12")] + Self::Tls12(_) => &TLS12, + Self::Tls13(_) => &TLS13, + } + } + + /// Return true if this suite is usable for a key only offering `sig_alg` + /// signatures. This resolves to true for all TLS1.3 suites. + pub fn usable_for_signature_algorithm(&self, _sig_alg: SignatureAlgorithm) -> bool { + match self { + Self::Tls13(_) => true, // no constraint expressed by ciphersuite (e.g., TLS1.3) + #[cfg(feature = "tls12")] + Self::Tls12(inner) => inner + .sign + .iter() + .any(|scheme| scheme.algorithm() == _sig_alg), + } + } + + /// Return true if this suite is usable for the given [`Protocol`]. + /// + /// All cipher suites are usable for TCP-TLS. Only TLS1.3 suites + /// with `Tls13CipherSuite::quic` provided are usable for QUIC. + pub(crate) fn usable_for_protocol(&self, proto: Protocol) -> bool { + match proto { + Protocol::Tcp => true, + Protocol::Quic => self + .tls13() + .and_then(|cs| cs.quic) + .is_some(), + } + } + + /// Return `true` if this is backed by a FIPS-approved implementation. + pub fn fips(&self) -> bool { + match self { + #[cfg(feature = "tls12")] + Self::Tls12(cs) => cs.fips(), + Self::Tls13(cs) => cs.fips(), + } + } + + /// Return the list of `KeyExchangeAlgorithm`s supported by this cipher suite. + /// + /// TLS 1.3 cipher suites support both ECDHE and DHE key exchange, but TLS 1.2 suites + /// support one or the other. + pub(crate) fn key_exchange_algorithms(&self) -> &[KeyExchangeAlgorithm] { + match self { + #[cfg(feature = "tls12")] + Self::Tls12(tls12) => core::slice::from_ref(&tls12.kx), + Self::Tls13(_) => ALL_KEY_EXCHANGE_ALGORITHMS, + } + } + + /// Say if the given `KeyExchangeAlgorithm` is supported by this cipher suite. + /// + /// TLS 1.3 cipher suites support all key exchange types, but TLS 1.2 suites + /// support only one. + pub(crate) fn usable_for_kx_algorithm(&self, _kxa: KeyExchangeAlgorithm) -> bool { + match self { + #[cfg(feature = "tls12")] + Self::Tls12(tls12) => tls12.kx == _kxa, + Self::Tls13(_) => true, + } + } +} + +impl fmt::Debug for SupportedCipherSuite { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + self.suite().fmt(f) + } +} + +/// Return true if `sigscheme` is usable by any of the given suites. +pub(crate) fn compatible_sigscheme_for_suites( + sigscheme: SignatureScheme, + common_suites: &[SupportedCipherSuite], +) -> bool { + let sigalg = sigscheme.algorithm(); + common_suites + .iter() + .any(|&suite| suite.usable_for_signature_algorithm(sigalg)) +} + +/// Secrets for transmitting/receiving data over a TLS session. +/// +/// After performing a handshake with rustls, these secrets can be extracted +/// to configure kTLS for a socket, and have the kernel take over encryption +/// and/or decryption. +pub struct ExtractedSecrets { + /// sequence number and secrets for the "tx" (transmit) direction + pub tx: (u64, ConnectionTrafficSecrets), + + /// sequence number and secrets for the "rx" (receive) direction + pub rx: (u64, ConnectionTrafficSecrets), +} + +/// [ExtractedSecrets] minus the sequence numbers +pub(crate) struct PartiallyExtractedSecrets { + /// secrets for the "tx" (transmit) direction + pub(crate) tx: ConnectionTrafficSecrets, + + /// secrets for the "rx" (receive) direction + pub(crate) rx: ConnectionTrafficSecrets, +} + +/// Secrets used to encrypt/decrypt data in a TLS session. +/// +/// These can be used to configure kTLS for a socket in one direction. +/// The only other piece of information needed is the sequence number, +/// which is in [ExtractedSecrets]. +#[non_exhaustive] +pub enum ConnectionTrafficSecrets { + /// Secrets for the AES_128_GCM AEAD algorithm + Aes128Gcm { + /// AEAD Key + key: AeadKey, + /// Initialization vector + iv: Iv, + }, + + /// Secrets for the AES_256_GCM AEAD algorithm + Aes256Gcm { + /// AEAD Key + key: AeadKey, + /// Initialization vector + iv: Iv, + }, + + /// Secrets for the CHACHA20_POLY1305 AEAD algorithm + Chacha20Poly1305 { + /// AEAD Key + key: AeadKey, + /// Initialization vector + iv: Iv, + }, +} + +#[cfg(test)] +#[macro_rules_attribute::apply(test_for_each_provider)] +mod tests { + use std::println; + + use super::provider::tls13::*; + + #[test] + fn test_scs_is_debug() { + println!("{:?}", super::provider::ALL_CIPHER_SUITES); + } + + #[test] + fn test_can_resume_to() { + assert!( + TLS13_AES_128_GCM_SHA256 + .tls13() + .unwrap() + .can_resume_from(TLS13_CHACHA20_POLY1305_SHA256_INTERNAL) + .is_some() + ); + assert!( + TLS13_AES_256_GCM_SHA384 + .tls13() + .unwrap() + .can_resume_from(TLS13_CHACHA20_POLY1305_SHA256_INTERNAL) + .is_none() + ); + } +} diff --git a/http/vendor/rustls/src/test_macros.rs b/http/vendor/rustls/src/test_macros.rs new file mode 100644 index 0000000..237578e --- /dev/null +++ b/http/vendor/rustls/src/test_macros.rs @@ -0,0 +1,71 @@ +//! Macros used for unit testing. + +/// Instantiate the given test functions once for each built-in provider. +/// +/// The selected provider module is bound as `provider`; you can rely on this +/// having the union of the items common to the `crypto::ring` and +/// `crypto::aws_lc_rs` modules. +#[cfg(test)] +macro_rules! test_for_each_provider { + ($($tt:tt)+) => { + #[cfg(feature = "ring")] + mod test_with_ring { + use crate::crypto::ring as provider; + #[allow(unused_imports)] + use super::*; + $($tt)+ + } + + #[cfg(feature = "aws_lc_rs")] + mod test_with_aws_lc_rs { + use crate::crypto::aws_lc_rs as provider; + #[allow(unused_imports)] + use super::*; + $($tt)+ + } + }; +} + +/// Instantiate the given benchmark functions once for each built-in provider. +/// +/// The selected provider module is bound as `provider`; you can rely on this +/// having the union of the items common to the `crypto::ring` and +/// `crypto::aws_lc_rs` modules. +#[cfg(bench)] +macro_rules! bench_for_each_provider { + ($($tt:tt)+) => { + #[cfg(feature = "ring")] + mod bench_with_ring { + use crate::crypto::ring as provider; + #[allow(unused_imports)] + use super::*; + $($tt)+ + } + + #[cfg(feature = "aws_lc_rs")] + mod bench_with_aws_lc_rs { + use crate::crypto::aws_lc_rs as provider; + #[allow(unused_imports)] + use super::*; + $($tt)+ + } + }; +} + +#[cfg(test)] +#[macro_rules_attribute::apply(test_for_each_provider)] +mod tests { + #[test] + fn test_each_provider() { + std::println!("provider is {:?}", super::provider::default_provider()); + } +} + +#[cfg(all(test, bench))] +#[macro_rules_attribute::apply(bench_for_each_provider)] +mod benchmarks { + #[bench] + fn bench_each_provider(b: &mut test::Bencher) { + b.iter(|| super::provider::default_provider()); + } +} diff --git a/http/vendor/rustls/src/ticketer.rs b/http/vendor/rustls/src/ticketer.rs new file mode 100644 index 0000000..d1b5e14 --- /dev/null +++ b/http/vendor/rustls/src/ticketer.rs @@ -0,0 +1,365 @@ +use alloc::boxed::Box; +use alloc::vec::Vec; +use core::mem; +#[cfg(feature = "std")] +use std::sync::{RwLock, RwLockReadGuard}; + +use pki_types::UnixTime; + +use crate::lock::{Mutex, MutexGuard}; +use crate::server::ProducesTickets; +#[cfg(not(feature = "std"))] +use crate::time_provider::TimeProvider; +use crate::{Error, rand}; + +#[derive(Debug)] +pub(crate) struct TicketSwitcherState { + next: Option>, + current: Box, + previous: Option>, + next_switch_time: u64, +} + +/// A ticketer that has a 'current' sub-ticketer and a single +/// 'previous' ticketer. It creates a new ticketer every so +/// often, demoting the current ticketer. +#[cfg_attr(feature = "std", derive(Debug))] +pub struct TicketSwitcher { + pub(crate) generator: fn() -> Result, rand::GetRandomFailed>, + lifetime: u32, + state: Mutex, + #[cfg(not(feature = "std"))] + time_provider: &'static dyn TimeProvider, +} + +impl TicketSwitcher { + /// Creates a new `TicketSwitcher`, which rotates through sub-ticketers + /// based on the passage of time. + /// + /// `lifetime` is in seconds, and is how long the current ticketer + /// is used to generate new tickets. Tickets are accepted for no + /// longer than twice this duration. `generator` produces a new + /// `ProducesTickets` implementation. + #[cfg(feature = "std")] + #[deprecated(note = "use TicketRotator instead")] + pub fn new( + lifetime: u32, + generator: fn() -> Result, rand::GetRandomFailed>, + ) -> Result { + Ok(Self { + generator, + lifetime, + state: Mutex::new(TicketSwitcherState { + next: Some(generator()?), + current: generator()?, + previous: None, + next_switch_time: UnixTime::now() + .as_secs() + .saturating_add(u64::from(lifetime)), + }), + }) + } + + /// Creates a new `TicketSwitcher`, which rotates through sub-ticketers + /// based on the passage of time. + /// + /// `lifetime` is in seconds, and is how long the current ticketer + /// is used to generate new tickets. Tickets are accepted for no + /// longer than twice this duration. `generator` produces a new + /// `ProducesTickets` implementation. + #[cfg(not(feature = "std"))] + pub fn new( + lifetime: u32, + generator: fn() -> Result, rand::GetRandomFailed>, + time_provider: &'static dyn TimeProvider, + ) -> Result { + Ok(Self { + generator, + lifetime, + state: Mutex::new::(TicketSwitcherState { + next: Some(generator()?), + current: generator()?, + previous: None, + next_switch_time: time_provider + .current_time() + .unwrap() + .as_secs() + .saturating_add(u64::from(lifetime)), + }), + time_provider, + }) + } + + /// If it's time, demote the `current` ticketer to `previous` (so it + /// does no new encryptions but can do decryption) and use next for a + /// new `current` ticketer. + /// + /// Calling this regularly will ensure timely key erasure. Otherwise, + /// key erasure will be delayed until the next encrypt/decrypt call. + /// + /// For efficiency, this is also responsible for locking the state mutex + /// and returning the mutexguard. + pub(crate) fn maybe_roll(&self, now: UnixTime) -> Option> { + // The code below aims to make switching as efficient as possible + // in the common case that the generator never fails. To achieve this + // we run the following steps: + // 1. If no switch is necessary, just return the mutexguard + // 2. Shift over all of the ticketers (so current becomes previous, + // and next becomes current). After this, other threads can + // start using the new current ticketer. + // 3. unlock mutex and generate new ticketer. + // 4. Place new ticketer in next and return current + // + // There are a few things to note here. First, we don't check whether + // a new switch might be needed in step 4, even though, due to locking + // and entropy collection, significant amounts of time may have passed. + // This is to guarantee that the thread doing the switch will eventually + // make progress. + // + // Second, because next may be None, step 2 can fail. In that case + // we enter a recovery mode where we generate 2 new ticketers, one for + // next and one for the current ticketer. We then take the mutex a + // second time and redo the time check to see if a switch is still + // necessary. + // + // This somewhat convoluted approach ensures good availability of the + // mutex, by ensuring that the state is usable and the mutex not held + // during generation. It also ensures that, so long as the inner + // ticketer never generates panics during encryption/decryption, + // we are guaranteed to never panic when holding the mutex. + + let now = now.as_secs(); + let mut are_recovering = false; // Are we recovering from previous failure? + { + // Scope the mutex so we only take it for as long as needed + let mut state = self.state.lock()?; + + // Fast path in case we do not need to switch to the next ticketer yet + if now <= state.next_switch_time { + return Some(state); + } + + // Make the switch, or mark for recovery if not possible + match state.next.take() { + Some(next) => { + state.previous = Some(mem::replace(&mut state.current, next)); + state.next_switch_time = now.saturating_add(u64::from(self.lifetime)); + } + _ => are_recovering = true, + } + } + + // We always need a next, so generate it now + let next = (self.generator)().ok()?; + if !are_recovering { + // Normal path, generate new next and place it in the state + let mut state = self.state.lock()?; + state.next = Some(next); + Some(state) + } else { + // Recovering, generate also a new current ticketer, and modify state + // as needed. (we need to redo the time check, otherwise this might + // result in very rapid switching of ticketers) + let new_current = (self.generator)().ok()?; + let mut state = self.state.lock()?; + state.next = Some(next); + if now > state.next_switch_time { + state.previous = Some(mem::replace(&mut state.current, new_current)); + state.next_switch_time = now.saturating_add(u64::from(self.lifetime)); + } + Some(state) + } + } +} + +impl ProducesTickets for TicketSwitcher { + fn lifetime(&self) -> u32 { + self.lifetime * 2 + } + + fn enabled(&self) -> bool { + true + } + + fn encrypt(&self, message: &[u8]) -> Option> { + #[cfg(feature = "std")] + let now = UnixTime::now(); + #[cfg(not(feature = "std"))] + let now = self + .time_provider + .current_time() + .unwrap(); + + self.maybe_roll(now)? + .current + .encrypt(message) + } + + fn decrypt(&self, ciphertext: &[u8]) -> Option> { + #[cfg(feature = "std")] + let now = UnixTime::now(); + #[cfg(not(feature = "std"))] + let now = self + .time_provider + .current_time() + .unwrap(); + + let state = self.maybe_roll(now)?; + + // Decrypt with the current key; if that fails, try with the previous. + state + .current + .decrypt(ciphertext) + .or_else(|| { + state + .previous + .as_ref() + .and_then(|previous| previous.decrypt(ciphertext)) + }) + } +} + +#[cfg(not(feature = "std"))] +impl core::fmt::Debug for TicketSwitcher { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.debug_struct("TicketSwitcher") + .field("generator", &self.generator) + .field("lifetime", &self.lifetime) + .field("state", &**self.state.lock().unwrap()) + .finish() + } +} + +#[cfg(feature = "std")] +#[derive(Debug)] +pub(crate) struct TicketRotatorState { + current: Box, + previous: Option>, + next_switch_time: u64, +} + +/// A ticketer that has a 'current' sub-ticketer and a single +/// 'previous' ticketer. It creates a new ticketer every so +/// often, demoting the current ticketer. +#[cfg(feature = "std")] +pub struct TicketRotator { + pub(crate) generator: fn() -> Result, rand::GetRandomFailed>, + lifetime: u32, + state: RwLock, +} + +#[cfg(feature = "std")] +impl TicketRotator { + /// Creates a new `TicketRotator`, which rotates through sub-ticketers + /// based on the passage of time. + /// + /// `lifetime` is in seconds, and is how long the current ticketer + /// is used to generate new tickets. Tickets are accepted for no + /// longer than twice this duration. `generator` produces a new + /// `ProducesTickets` implementation. + pub fn new( + lifetime: u32, + generator: fn() -> Result, rand::GetRandomFailed>, + ) -> Result { + Ok(Self { + generator, + lifetime, + state: RwLock::new(TicketRotatorState { + current: generator()?, + previous: None, + next_switch_time: UnixTime::now() + .as_secs() + .saturating_add(u64::from(lifetime)), + }), + }) + } + + /// If it's time, demote the `current` ticketer to `previous` (so it + /// does no new encryptions but can do decryption) and replace it + /// with a new one. + /// + /// Calling this regularly will ensure timely key erasure. Otherwise, + /// key erasure will be delayed until the next encrypt/decrypt call. + /// + /// For efficiency, this is also responsible for locking the state rwlock + /// and returning it for read. + pub(crate) fn maybe_roll( + &self, + now: UnixTime, + ) -> Option> { + let now = now.as_secs(); + + // Fast, common, & read-only path in case we do not need to switch + // to the next ticketer yet + { + let read = self.state.read().ok()?; + + if now <= read.next_switch_time { + return Some(read); + } + } + + // We need to switch ticketers, and make a new one. + // Generate a potential "next" ticketer outside the lock. + let next = (self.generator)().ok()?; + + let mut write = self.state.write().ok()?; + + if now <= write.next_switch_time { + // Another thread beat us to it. Nothing to do. + drop(write); + + return self.state.read().ok(); + } + + // Now we have: + // - confirmed we need rotation + // - confirmed we are the thread that will do it + // - successfully made the replacement ticketer + write.previous = Some(mem::replace(&mut write.current, next)); + write.next_switch_time = now.saturating_add(u64::from(self.lifetime)); + drop(write); + + self.state.read().ok() + } +} + +#[cfg(feature = "std")] +impl ProducesTickets for TicketRotator { + fn lifetime(&self) -> u32 { + self.lifetime * 2 + } + + fn enabled(&self) -> bool { + true + } + + fn encrypt(&self, message: &[u8]) -> Option> { + self.maybe_roll(UnixTime::now())? + .current + .encrypt(message) + } + + fn decrypt(&self, ciphertext: &[u8]) -> Option> { + let state = self.maybe_roll(UnixTime::now())?; + + // Decrypt with the current key; if that fails, try with the previous. + state + .current + .decrypt(ciphertext) + .or_else(|| { + state + .previous + .as_ref() + .and_then(|previous| previous.decrypt(ciphertext)) + }) + } +} + +#[cfg(feature = "std")] +impl core::fmt::Debug for TicketRotator { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.debug_struct("TicketRotator") + .finish_non_exhaustive() + } +} diff --git a/http/vendor/rustls/src/time_provider.rs b/http/vendor/rustls/src/time_provider.rs new file mode 100644 index 0000000..e43f4d6 --- /dev/null +++ b/http/vendor/rustls/src/time_provider.rs @@ -0,0 +1,30 @@ +//! The library's source of time. + +use core::fmt::Debug; + +use pki_types::UnixTime; + +/// An object that provides the current time. +/// +/// This is used to, for example, check if a certificate has expired during +/// certificate validation, or to check the age of a ticket. +pub trait TimeProvider: Debug + Send + Sync { + /// Returns the current wall time. + /// + /// This is not required to be monotonic. + /// + /// Return `None` if unable to retrieve the time. + fn current_time(&self) -> Option; +} + +#[derive(Debug)] +#[cfg(feature = "std")] +/// Default `TimeProvider` implementation that uses `std` +pub struct DefaultTimeProvider; + +#[cfg(feature = "std")] +impl TimeProvider for DefaultTimeProvider { + fn current_time(&self) -> Option { + Some(UnixTime::now()) + } +} diff --git a/http/vendor/rustls/src/tls12/mod.rs b/http/vendor/rustls/src/tls12/mod.rs new file mode 100644 index 0000000..c927185 --- /dev/null +++ b/http/vendor/rustls/src/tls12/mod.rs @@ -0,0 +1,380 @@ +use alloc::boxed::Box; +use alloc::vec; +use alloc::vec::Vec; +use core::fmt; + +use zeroize::Zeroize; + +use crate::common_state::{CommonState, Side}; +use crate::conn::ConnectionRandoms; +use crate::crypto; +use crate::crypto::cipher::{AeadKey, MessageDecrypter, MessageEncrypter, Tls12AeadAlgorithm}; +use crate::crypto::hash; +use crate::enums::{AlertDescription, SignatureScheme}; +use crate::error::{Error, InvalidMessage}; +use crate::msgs::codec::{Codec, Reader}; +use crate::msgs::handshake::{KeyExchangeAlgorithm, KxDecode}; +use crate::suites::{CipherSuiteCommon, PartiallyExtractedSecrets, SupportedCipherSuite}; + +/// A TLS 1.2 cipher suite supported by rustls. +pub struct Tls12CipherSuite { + /// Common cipher suite fields. + pub common: CipherSuiteCommon, + + /// How to compute the TLS1.2 PRF for the suite's hash function. + /// + /// If you have a TLS1.2 PRF implementation, you should directly implement the [`crypto::tls12::Prf`] trait. + /// + /// If not, you can implement the [`crypto::hmac::Hmac`] trait (and associated), and then use + /// [`crypto::tls12::PrfUsingHmac`]. + pub prf_provider: &'static dyn crypto::tls12::Prf, + + /// How to exchange/agree keys. + /// + /// In TLS1.2, the key exchange method (eg, Elliptic Curve Diffie-Hellman with Ephemeral keys -- ECDHE) + /// is baked into the cipher suite, but the details to achieve it are negotiated separately. + /// + /// This controls how protocol messages (like the `ClientKeyExchange` message) are interpreted + /// once this cipher suite has been negotiated. + pub kx: KeyExchangeAlgorithm, + + /// How to sign messages for authentication. + /// + /// This is a set of [`SignatureScheme`]s that are usable once this cipher suite has been + /// negotiated. + /// + /// The precise scheme used is then chosen from this set by the selected authentication key. + pub sign: &'static [SignatureScheme], + + /// How to produce a [`MessageDecrypter`] or [`MessageEncrypter`] + /// from raw key material. + pub aead_alg: &'static dyn Tls12AeadAlgorithm, +} + +impl Tls12CipherSuite { + /// Resolve the set of supported [`SignatureScheme`]s from the + /// offered signature schemes. If we return an empty + /// set, the handshake terminates. + pub fn resolve_sig_schemes(&self, offered: &[SignatureScheme]) -> Vec { + self.sign + .iter() + .filter(|pref| offered.contains(pref)) + .cloned() + .collect() + } + + /// Return `true` if this is backed by a FIPS-approved implementation. + /// + /// This means all the constituent parts that do cryptography return `true` for `fips()`. + pub fn fips(&self) -> bool { + self.common.fips() && self.prf_provider.fips() && self.aead_alg.fips() + } +} + +impl From<&'static Tls12CipherSuite> for SupportedCipherSuite { + fn from(s: &'static Tls12CipherSuite) -> Self { + Self::Tls12(s) + } +} + +impl PartialEq for Tls12CipherSuite { + fn eq(&self, other: &Self) -> bool { + self.common.suite == other.common.suite + } +} + +impl fmt::Debug for Tls12CipherSuite { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Tls12CipherSuite") + .field("suite", &self.common.suite) + .finish() + } +} + +/// TLS1.2 per-connection keying material +pub(crate) struct ConnectionSecrets { + pub(crate) randoms: ConnectionRandoms, + suite: &'static Tls12CipherSuite, + pub(crate) master_secret: [u8; 48], +} + +impl ConnectionSecrets { + pub(crate) fn from_key_exchange( + kx: Box, + peer_pub_key: &[u8], + ems_seed: Option, + randoms: ConnectionRandoms, + suite: &'static Tls12CipherSuite, + ) -> Result { + let mut ret = Self { + randoms, + suite, + master_secret: [0u8; 48], + }; + + let (label, seed) = match ems_seed { + Some(seed) => ("extended master secret", Seed::Ems(seed)), + None => ( + "master secret", + Seed::Randoms(join_randoms(&ret.randoms.client, &ret.randoms.server)), + ), + }; + + // The API contract for for_key_exchange is that the caller guarantees `label` and `seed` + // slice parameters are non-empty. + // `label` is guaranteed non-empty because it's assigned from a `&str` above. + // `seed.as_ref()` is guaranteed non-empty by documentation on the AsRef impl. + ret.suite + .prf_provider + .for_key_exchange( + &mut ret.master_secret, + kx, + peer_pub_key, + label.as_bytes(), + seed.as_ref(), + )?; + + Ok(ret) + } + + pub(crate) fn new_resume( + randoms: ConnectionRandoms, + suite: &'static Tls12CipherSuite, + master_secret: &[u8], + ) -> Self { + let mut ret = Self { + randoms, + suite, + master_secret: [0u8; 48], + }; + ret.master_secret + .copy_from_slice(master_secret); + ret + } + + /// Make a `MessageCipherPair` based on the given supported ciphersuite `self.suite`, + /// and the session's `secrets`. + pub(crate) fn make_cipher_pair(&self, side: Side) -> MessageCipherPair { + // Make a key block, and chop it up. + // Note: we don't implement any ciphersuites with nonzero mac_key_len. + let key_block = self.make_key_block(); + let shape = self.suite.aead_alg.key_block_shape(); + + let (client_write_key, key_block) = key_block.split_at(shape.enc_key_len); + let (server_write_key, key_block) = key_block.split_at(shape.enc_key_len); + let (client_write_iv, key_block) = key_block.split_at(shape.fixed_iv_len); + let (server_write_iv, extra) = key_block.split_at(shape.fixed_iv_len); + + let (write_key, write_iv, read_key, read_iv) = match side { + Side::Client => ( + client_write_key, + client_write_iv, + server_write_key, + server_write_iv, + ), + Side::Server => ( + server_write_key, + server_write_iv, + client_write_key, + client_write_iv, + ), + }; + + ( + self.suite + .aead_alg + .decrypter(AeadKey::new(read_key), read_iv), + self.suite + .aead_alg + .encrypter(AeadKey::new(write_key), write_iv, extra), + ) + } + + fn make_key_block(&self) -> Vec { + let shape = self.suite.aead_alg.key_block_shape(); + + let len = (shape.enc_key_len + shape.fixed_iv_len) * 2 + shape.explicit_nonce_len; + + let mut out = vec![0u8; len]; + + // NOTE: opposite order to above for no good reason. + // Don't design security protocols on drugs, kids. + let randoms = join_randoms(&self.randoms.server, &self.randoms.client); + self.suite.prf_provider.for_secret( + &mut out, + &self.master_secret, + b"key expansion", + &randoms, + ); + + out + } + + pub(crate) fn suite(&self) -> &'static Tls12CipherSuite { + self.suite + } + + pub(crate) fn master_secret(&self) -> &[u8] { + &self.master_secret[..] + } + + fn make_verify_data(&self, handshake_hash: &hash::Output, label: &[u8]) -> Vec { + let mut out = vec![0u8; 12]; + + self.suite.prf_provider.for_secret( + &mut out, + &self.master_secret, + label, + handshake_hash.as_ref(), + ); + + out + } + + pub(crate) fn client_verify_data(&self, handshake_hash: &hash::Output) -> Vec { + self.make_verify_data(handshake_hash, b"client finished") + } + + pub(crate) fn server_verify_data(&self, handshake_hash: &hash::Output) -> Vec { + self.make_verify_data(handshake_hash, b"server finished") + } + + pub(crate) fn export_keying_material( + &self, + output: &mut [u8], + label: &[u8], + context: Option<&[u8]>, + ) { + let mut randoms = Vec::new(); + randoms.extend_from_slice(&self.randoms.client); + randoms.extend_from_slice(&self.randoms.server); + if let Some(context) = context { + assert!(context.len() <= 0xffff); + (context.len() as u16).encode(&mut randoms); + randoms.extend_from_slice(context); + } + + self.suite + .prf_provider + .for_secret(output, &self.master_secret, label, &randoms); + } + + pub(crate) fn extract_secrets(&self, side: Side) -> Result { + // Make a key block, and chop it up + let key_block = self.make_key_block(); + let shape = self.suite.aead_alg.key_block_shape(); + + let (client_key, key_block) = key_block.split_at(shape.enc_key_len); + let (server_key, key_block) = key_block.split_at(shape.enc_key_len); + let (client_iv, key_block) = key_block.split_at(shape.fixed_iv_len); + let (server_iv, explicit_nonce) = key_block.split_at(shape.fixed_iv_len); + + let client_secrets = self.suite.aead_alg.extract_keys( + AeadKey::new(client_key), + client_iv, + explicit_nonce, + )?; + let server_secrets = self.suite.aead_alg.extract_keys( + AeadKey::new(server_key), + server_iv, + explicit_nonce, + )?; + + let (tx, rx) = match side { + Side::Client => (client_secrets, server_secrets), + Side::Server => (server_secrets, client_secrets), + }; + Ok(PartiallyExtractedSecrets { tx, rx }) + } +} + +impl Drop for ConnectionSecrets { + fn drop(&mut self) { + self.master_secret.zeroize(); + } +} + +enum Seed { + Ems(hash::Output), + Randoms([u8; 64]), +} + +impl AsRef<[u8]> for Seed { + /// This is guaranteed to return a non-empty slice. + fn as_ref(&self) -> &[u8] { + match self { + // seed is a hash::Output, which is a fixed, non-zero length array. + Self::Ems(seed) => seed.as_ref(), + // randoms is a fixed, non-zero length array. + Self::Randoms(randoms) => randoms.as_ref(), + } + } +} + +fn join_randoms(first: &[u8; 32], second: &[u8; 32]) -> [u8; 64] { + let mut randoms = [0u8; 64]; + randoms[..32].copy_from_slice(first); + randoms[32..].copy_from_slice(second); + randoms +} + +type MessageCipherPair = (Box, Box); + +pub(crate) fn decode_kx_params<'a, T: KxDecode<'a>>( + kx_algorithm: KeyExchangeAlgorithm, + common: &mut CommonState, + kx_params: &'a [u8], +) -> Result { + let mut rd = Reader::init(kx_params); + let kx_params = T::decode(&mut rd, kx_algorithm)?; + match rd.any_left() { + false => Ok(kx_params), + true => Err(common.send_fatal_alert( + AlertDescription::DecodeError, + InvalidMessage::InvalidDhParams, + )), + } +} + +pub(crate) const DOWNGRADE_SENTINEL: [u8; 8] = [0x44, 0x4f, 0x57, 0x4e, 0x47, 0x52, 0x44, 0x01]; + +#[cfg(test)] +#[macro_rules_attribute::apply(test_for_each_provider)] +mod tests { + use super::provider::kx_group::X25519; + use super::*; + use crate::common_state::{CommonState, Side}; + use crate::msgs::handshake::{ServerEcdhParams, ServerKeyExchangeParams}; + + #[test] + fn server_ecdhe_remaining_bytes() { + let key = X25519.start().unwrap(); + let server_params = ServerEcdhParams::new(&*key); + let mut server_buf = Vec::new(); + server_params.encode(&mut server_buf); + server_buf.push(34); + + let mut common = CommonState::new(Side::Client); + assert!( + decode_kx_params::( + KeyExchangeAlgorithm::ECDHE, + &mut common, + &server_buf + ) + .is_err() + ); + } + + #[test] + fn client_ecdhe_invalid() { + let mut common = CommonState::new(Side::Server); + assert!( + decode_kx_params::( + KeyExchangeAlgorithm::ECDHE, + &mut common, + &[34], + ) + .is_err() + ); + } +} diff --git a/http/vendor/rustls/src/tls13/key_schedule.rs b/http/vendor/rustls/src/tls13/key_schedule.rs new file mode 100644 index 0000000..4bf0421 --- /dev/null +++ b/http/vendor/rustls/src/tls13/key_schedule.rs @@ -0,0 +1,1308 @@ +//! Key schedule maintenance for TLS1.3 + +use alloc::boxed::Box; +use alloc::string::ToString; +use core::ops::Deref; + +use crate::common_state::{CommonState, Side}; +use crate::crypto::cipher::{AeadKey, Iv, MessageDecrypter, Tls13AeadAlgorithm}; +use crate::crypto::tls13::{Hkdf, HkdfExpander, OkmBlock, OutputLengthError, expand}; +use crate::crypto::{SharedSecret, hash, hmac}; +use crate::error::Error; +use crate::msgs::message::Message; +use crate::suites::PartiallyExtractedSecrets; +use crate::{ConnectionTrafficSecrets, KeyLog, Tls13CipherSuite, quic}; + +// We express the state of a contained KeySchedule using these +// typestates. This means we can write code that cannot accidentally +// (e.g.) encrypt application data using a KeySchedule solely constructed +// with an empty or trivial secret, or extract the wrong kind of secrets +// at a given point. + +/// The "early secret" stage of the key schedule WITH a PSK. +/// +/// This is only useful when you need to use one of the binder +/// keys, the "client_early_traffic_secret", or +/// "early_exporter_master_secret". +/// +/// See [`KeySchedulePreHandshake`] for more information. +pub(crate) struct KeyScheduleEarly { + ks: KeySchedule, +} + +impl KeyScheduleEarly { + pub(crate) fn new(suite: &'static Tls13CipherSuite, secret: &[u8]) -> Self { + Self { + ks: KeySchedule::new(suite, secret), + } + } + + /// Computes the `client_early_traffic_secret` and writes it + /// to `common`. + /// + /// `hs_hash` is `Transcript-Hash(ClientHello)`. + /// + /// ```text + /// Derive-Secret(., "c e traffic", ClientHello) + /// = client_early_traffic_secret + /// ``` + pub(crate) fn client_early_traffic_secret( + &self, + hs_hash: &hash::Output, + key_log: &dyn KeyLog, + client_random: &[u8; 32], + common: &mut CommonState, + ) { + let client_early_traffic_secret = self.ks.derive_logged_secret( + SecretKind::ClientEarlyTrafficSecret, + hs_hash.as_ref(), + key_log, + client_random, + ); + + match common.side { + Side::Client => self + .ks + .set_encrypter(&client_early_traffic_secret, common), + Side::Server => self + .ks + .set_decrypter(&client_early_traffic_secret, common), + } + + if common.is_quic() { + // If 0-RTT should be rejected, this will be clobbered by ExtensionProcessing + // before the application can see. + common.quic.early_secret = Some(client_early_traffic_secret); + } + } + + pub(crate) fn resumption_psk_binder_key_and_sign_verify_data( + &self, + hs_hash: &hash::Output, + ) -> hmac::Tag { + let resumption_psk_binder_key = self + .ks + .derive_for_empty_hash(SecretKind::ResumptionPskBinderKey); + self.ks + .sign_verify_data(&resumption_psk_binder_key, hs_hash) + } +} + +/// The "early secret" stage of the key schedule. +/// +/// Call [`KeySchedulePreHandshake::new`] to create it without +/// a PSK, or use [`From`] to create it with +/// a PSK. +/// +/// ```text +/// 0 +/// | +/// v +/// PSK -> HKDF-Extract = Early Secret +/// | +/// +-----> Derive-Secret(., "ext binder" | "res binder", "") +/// | = binder_key +/// | +/// +-----> Derive-Secret(., "c e traffic", ClientHello) +/// | = client_early_traffic_secret +/// | +/// +-----> Derive-Secret(., "e exp master", ClientHello) +/// | = early_exporter_master_secret +/// v +/// Derive-Secret(., "derived", "") +/// ``` +pub(crate) struct KeySchedulePreHandshake { + ks: KeySchedule, +} + +impl KeySchedulePreHandshake { + /// Creates a key schedule without a PSK. + pub(crate) fn new(suite: &'static Tls13CipherSuite) -> Self { + Self { + ks: KeySchedule::new_with_empty_secret(suite), + } + } + + /// `shared_secret` is the "(EC)DHE" secret input to + /// "HKDF-Extract": + /// + /// ```text + /// (EC)DHE -> HKDF-Extract = Handshake Secret + /// ``` + pub(crate) fn into_handshake( + mut self, + shared_secret: SharedSecret, + ) -> KeyScheduleHandshakeStart { + self.ks + .input_secret(shared_secret.secret_bytes()); + KeyScheduleHandshakeStart { ks: self.ks } + } +} + +/// Creates a key schedule with a PSK. +impl From for KeySchedulePreHandshake { + fn from(KeyScheduleEarly { ks }: KeyScheduleEarly) -> Self { + Self { ks } + } +} + +/// KeySchedule during handshake. +/// +/// Created by [`KeySchedulePreHandshake`]. +pub(crate) struct KeyScheduleHandshakeStart { + ks: KeySchedule, +} + +impl KeyScheduleHandshakeStart { + pub(crate) fn derive_client_handshake_secrets( + mut self, + early_data_enabled: bool, + hs_hash: hash::Output, + suite: &'static Tls13CipherSuite, + key_log: &dyn KeyLog, + client_random: &[u8; 32], + common: &mut CommonState, + ) -> KeyScheduleHandshake { + debug_assert_eq!(common.side, Side::Client); + // Suite might have changed due to resumption + self.ks.inner = suite.into(); + let new = self.into_handshake(hs_hash, key_log, client_random, common); + + // Decrypt with the peer's key, encrypt with our own key + new.ks + .set_decrypter(&new.server_handshake_traffic_secret, common); + + if !early_data_enabled { + // Set the client encryption key for handshakes if early data is not used + new.ks + .set_encrypter(&new.client_handshake_traffic_secret, common); + } + + new + } + + pub(crate) fn derive_server_handshake_secrets( + self, + hs_hash: hash::Output, + key_log: &dyn KeyLog, + client_random: &[u8; 32], + common: &mut CommonState, + ) -> KeyScheduleHandshake { + debug_assert_eq!(common.side, Side::Server); + let new = self.into_handshake(hs_hash, key_log, client_random, common); + + // Set up to encrypt with handshake secrets, but decrypt with early_data keys. + // If not doing early_data after all, this is corrected later to the handshake + // keys (now stored in key_schedule). + new.ks + .set_encrypter(&new.server_handshake_traffic_secret, common); + new + } + + pub(crate) fn server_ech_confirmation_secret( + &mut self, + client_hello_inner_random: &[u8], + hs_hash: hash::Output, + ) -> [u8; 8] { + /* + Per ietf-tls-esni-17 section 7.2: + + accept_confirmation = HKDF-Expand-Label( + HKDF-Extract(0, ClientHelloInner.random), + "ech accept confirmation", + transcript_ech_conf,8) + */ + hkdf_expand_label( + self.ks + .suite + .hkdf_provider + .extract_from_secret(None, client_hello_inner_random) + .as_ref(), + SecretKind::ServerEchConfirmationSecret.to_bytes(), + hs_hash.as_ref(), + ) + } + + fn into_handshake( + self, + hs_hash: hash::Output, + key_log: &dyn KeyLog, + client_random: &[u8; 32], + common: &mut CommonState, + ) -> KeyScheduleHandshake { + // Use an empty handshake hash for the initial handshake. + let client_secret = self.ks.derive_logged_secret( + SecretKind::ClientHandshakeTrafficSecret, + hs_hash.as_ref(), + key_log, + client_random, + ); + + let server_secret = self.ks.derive_logged_secret( + SecretKind::ServerHandshakeTrafficSecret, + hs_hash.as_ref(), + key_log, + client_random, + ); + + if common.is_quic() { + common.quic.hs_secrets = Some(quic::Secrets::new( + client_secret.clone(), + server_secret.clone(), + self.ks.suite, + self.ks.suite.quic.unwrap(), + common.side, + common.quic.version, + )); + } + + KeyScheduleHandshake { + ks: self.ks, + client_handshake_traffic_secret: client_secret, + server_handshake_traffic_secret: server_secret, + } + } +} + +pub(crate) struct KeyScheduleHandshake { + ks: KeySchedule, + client_handshake_traffic_secret: OkmBlock, + server_handshake_traffic_secret: OkmBlock, +} + +impl KeyScheduleHandshake { + pub(crate) fn sign_server_finish(&self, hs_hash: &hash::Output) -> hmac::Tag { + self.ks + .sign_finish(&self.server_handshake_traffic_secret, hs_hash) + } + + pub(crate) fn set_handshake_encrypter(&self, common: &mut CommonState) { + debug_assert_eq!(common.side, Side::Client); + self.ks + .set_encrypter(&self.client_handshake_traffic_secret, common); + } + + pub(crate) fn set_handshake_decrypter( + &self, + skip_requested: Option, + common: &mut CommonState, + ) { + debug_assert_eq!(common.side, Side::Server); + let secret = &self.client_handshake_traffic_secret; + match skip_requested { + None => self.ks.set_decrypter(secret, common), + Some(max_early_data_size) => common + .record_layer + .set_message_decrypter_with_trial_decryption( + self.ks + .derive_decrypter(&self.client_handshake_traffic_secret), + max_early_data_size, + ), + } + } + + pub(crate) fn into_traffic_with_client_finished_pending( + self, + hs_hash: hash::Output, + key_log: &dyn KeyLog, + client_random: &[u8; 32], + common: &mut CommonState, + ) -> KeyScheduleTrafficWithClientFinishedPending { + debug_assert_eq!(common.side, Side::Server); + + let before_finished = + KeyScheduleBeforeFinished::new(self.ks, hs_hash, key_log, client_random); + let (_client_secret, server_secret) = ( + &before_finished.current_client_traffic_secret, + &before_finished.current_server_traffic_secret, + ); + + before_finished + .ks + .set_encrypter(server_secret, common); + + if common.is_quic() { + common.quic.traffic_secrets = Some(quic::Secrets::new( + _client_secret.clone(), + server_secret.clone(), + before_finished.ks.suite, + before_finished.ks.suite.quic.unwrap(), + common.side, + common.quic.version, + )); + } + + KeyScheduleTrafficWithClientFinishedPending { + handshake_client_traffic_secret: self.client_handshake_traffic_secret, + before_finished, + } + } + + pub(crate) fn into_pre_finished_client_traffic( + self, + pre_finished_hash: hash::Output, + handshake_hash: hash::Output, + key_log: &dyn KeyLog, + client_random: &[u8; 32], + ) -> (KeyScheduleClientBeforeFinished, hmac::Tag) { + let before_finished = + KeyScheduleBeforeFinished::new(self.ks, pre_finished_hash, key_log, client_random); + let tag = before_finished + .ks + .sign_finish(&self.client_handshake_traffic_secret, &handshake_hash); + (KeyScheduleClientBeforeFinished(before_finished), tag) + } +} + +/// Keys derived (but not installed) before client's Finished message. +pub(crate) struct KeyScheduleBeforeFinished { + ks: KeySchedule, + current_client_traffic_secret: OkmBlock, + current_server_traffic_secret: OkmBlock, + current_exporter_secret: OkmBlock, +} + +impl KeyScheduleBeforeFinished { + fn new( + mut ks: KeySchedule, + hs_hash: hash::Output, + key_log: &dyn KeyLog, + client_random: &[u8; 32], + ) -> Self { + ks.input_empty(); + + let current_client_traffic_secret = ks.derive_logged_secret( + SecretKind::ClientApplicationTrafficSecret, + hs_hash.as_ref(), + key_log, + client_random, + ); + + let current_server_traffic_secret = ks.derive_logged_secret( + SecretKind::ServerApplicationTrafficSecret, + hs_hash.as_ref(), + key_log, + client_random, + ); + + let current_exporter_secret = ks.derive_logged_secret( + SecretKind::ExporterMasterSecret, + hs_hash.as_ref(), + key_log, + client_random, + ); + + Self { + ks, + current_client_traffic_secret, + current_server_traffic_secret, + current_exporter_secret, + } + } + + pub(crate) fn into_traffic( + self, + hs_hash: hash::Output, + ) -> (KeyScheduleTraffic, KeyScheduleResumption) { + let Self { + ks, + current_client_traffic_secret, + current_server_traffic_secret, + current_exporter_secret, + } = self; + + let resumption_master_secret = + ks.derive(SecretKind::ResumptionMasterSecret, hs_hash.as_ref()); + + ( + KeyScheduleTraffic { + ks: ks.inner, + current_client_traffic_secret, + current_server_traffic_secret, + current_exporter_secret, + }, + KeyScheduleResumption { + ks: ks.inner, + resumption_master_secret, + }, + ) + } +} + +/// Client-side key schedule before the finished message is sent. +/// +/// This differs from `KeyScheduleTrafficWithClientFinishedPending` because +/// none of the final traffic secrets are installed yet. After the finished +/// message is sent, `into_traffic()` does that. +pub(crate) struct KeyScheduleClientBeforeFinished(KeyScheduleBeforeFinished); + +impl KeyScheduleClientBeforeFinished { + pub(crate) fn into_traffic( + self, + common: &mut CommonState, + hs_hash: hash::Output, + ) -> (KeyScheduleTraffic, KeyScheduleResumption) { + let next = self.0; + + debug_assert_eq!(common.side, Side::Client); + let (client_secret, server_secret) = ( + &next.current_client_traffic_secret, + &next.current_server_traffic_secret, + ); + + next.ks + .set_decrypter(server_secret, common); + next.ks + .set_encrypter(client_secret, common); + + if common.is_quic() { + common.quic.traffic_secrets = Some(quic::Secrets::new( + client_secret.clone(), + server_secret.clone(), + next.ks.suite, + next.ks.suite.quic.unwrap(), + common.side, + common.quic.version, + )); + } + + next.into_traffic(hs_hash) + } +} + +/// KeySchedule during traffic stage, retaining the ability to calculate the client's +/// finished verify_data. The traffic stage key schedule can be extracted from it +/// through signing the client finished hash. +pub(crate) struct KeyScheduleTrafficWithClientFinishedPending { + handshake_client_traffic_secret: OkmBlock, + before_finished: KeyScheduleBeforeFinished, +} + +impl KeyScheduleTrafficWithClientFinishedPending { + pub(crate) fn update_decrypter(&self, common: &mut CommonState) { + debug_assert_eq!(common.side, Side::Server); + self.before_finished + .ks + .set_decrypter(&self.handshake_client_traffic_secret, common); + } + + pub(crate) fn sign_client_finish( + self, + hs_hash: &hash::Output, + common: &mut CommonState, + ) -> (KeyScheduleBeforeFinished, hmac::Tag) { + debug_assert_eq!(common.side, Side::Server); + let tag = self + .before_finished + .ks + .sign_finish(&self.handshake_client_traffic_secret, hs_hash); + + // Install keying to read future messages. + self.before_finished.ks.set_decrypter( + &self + .before_finished + .current_client_traffic_secret, + common, + ); + + (self.before_finished, tag) + } +} + +/// KeySchedule during traffic stage. All traffic & exporter keys are guaranteed +/// to be available. +pub(crate) struct KeyScheduleTraffic { + ks: KeyScheduleSuite, + current_client_traffic_secret: OkmBlock, + current_server_traffic_secret: OkmBlock, + current_exporter_secret: OkmBlock, +} + +impl KeyScheduleTraffic { + pub(crate) fn update_encrypter_and_notify(&mut self, common: &mut CommonState) { + let secret = self.next_application_traffic_secret(common.side); + common.enqueue_key_update_notification(); + self.ks.set_encrypter(&secret, common); + } + + pub(crate) fn request_key_update_and_update_encrypter( + &mut self, + common: &mut CommonState, + ) -> Result<(), Error> { + common.check_aligned_handshake()?; + common.send_msg_encrypt(Message::build_key_update_request().into()); + let secret = self.next_application_traffic_secret(common.side); + self.ks.set_encrypter(&secret, common); + Ok(()) + } + + pub(crate) fn update_decrypter(&mut self, common: &mut CommonState) { + let secret = self.next_application_traffic_secret(common.side.peer()); + self.ks.set_decrypter(&secret, common); + } + + pub(crate) fn next_application_traffic_secret(&mut self, side: Side) -> OkmBlock { + let current = match side { + Side::Client => &mut self.current_client_traffic_secret, + Side::Server => &mut self.current_server_traffic_secret, + }; + + let secret = self.ks.derive_next(current); + *current = secret.clone(); + secret + } + + pub(crate) fn export_keying_material( + &self, + out: &mut [u8], + label: &[u8], + context: Option<&[u8]>, + ) -> Result<(), Error> { + self.ks + .export_keying_material(&self.current_exporter_secret, out, label, context) + } + + pub(crate) fn refresh_traffic_secret( + &mut self, + side: Side, + ) -> Result { + let secret = self.next_application_traffic_secret(side); + let (key, iv) = expand_secret( + &secret, + self.ks.suite.hkdf_provider, + self.ks.suite.aead_alg.key_len(), + ); + Ok(self + .ks + .suite + .aead_alg + .extract_keys(key, iv)?) + } + + pub(crate) fn extract_secrets(&self, side: Side) -> Result { + let (client_key, client_iv) = expand_secret( + &self.current_client_traffic_secret, + self.ks.suite.hkdf_provider, + self.ks.suite.aead_alg.key_len(), + ); + let (server_key, server_iv) = expand_secret( + &self.current_server_traffic_secret, + self.ks.suite.hkdf_provider, + self.ks.suite.aead_alg.key_len(), + ); + let client_secrets = self + .ks + .suite + .aead_alg + .extract_keys(client_key, client_iv)?; + let server_secrets = self + .ks + .suite + .aead_alg + .extract_keys(server_key, server_iv)?; + + let (tx, rx) = match side { + Side::Client => (client_secrets, server_secrets), + Side::Server => (server_secrets, client_secrets), + }; + Ok(PartiallyExtractedSecrets { tx, rx }) + } +} + +pub(crate) struct KeyScheduleResumption { + ks: KeyScheduleSuite, + resumption_master_secret: OkmBlock, +} + +impl KeyScheduleResumption { + pub(crate) fn derive_ticket_psk(&self, nonce: &[u8]) -> OkmBlock { + self.ks + .derive_ticket_psk(&self.resumption_master_secret, nonce) + } +} + +fn expand_secret(secret: &OkmBlock, hkdf: &'static dyn Hkdf, aead_key_len: usize) -> (AeadKey, Iv) { + let expander = hkdf.expander_for_okm(secret); + + ( + hkdf_expand_label_aead_key(expander.as_ref(), aead_key_len, b"key", &[]), + hkdf_expand_label(expander.as_ref(), b"iv", &[]), + ) +} + +/// This is the TLS1.3 key schedule. It stores the current secret and +/// the type of hash. This isn't used directly; but only through the +/// typestates. +struct KeySchedule { + current: Box, + inner: KeyScheduleSuite, +} + +impl KeySchedule { + fn new(suite: &'static Tls13CipherSuite, secret: &[u8]) -> Self { + Self { + current: suite + .hkdf_provider + .extract_from_secret(None, secret), + inner: suite.into(), + } + } + + /// Creates a key schedule without a PSK. + fn new_with_empty_secret(suite: &'static Tls13CipherSuite) -> Self { + Self { + current: suite + .hkdf_provider + .extract_from_zero_ikm(None), + inner: suite.into(), + } + } + + /// Input the empty secret. + /// + /// RFC 8446: "If a given secret is not available, then the + /// 0-value consisting of a string of Hash.length bytes set + /// to zeros is used." + fn input_empty(&mut self) { + let salt = self.derive_for_empty_hash(SecretKind::DerivedSecret); + self.current = self + .suite + .hkdf_provider + .extract_from_zero_ikm(Some(salt.as_ref())); + } + + /// Input the given secret. + fn input_secret(&mut self, secret: &[u8]) { + let salt = self.derive_for_empty_hash(SecretKind::DerivedSecret); + self.current = self + .suite + .hkdf_provider + .extract_from_secret(Some(salt.as_ref()), secret); + } + + /// Derive a secret of given `kind`, using current handshake hash `hs_hash`. + /// + /// More specifically + /// ```text + /// Derive-Secret(., "derived", Messages) + /// ``` + /// where `hs_hash` is `Messages`. + fn derive(&self, kind: SecretKind, hs_hash: &[u8]) -> OkmBlock { + hkdf_expand_label_block(self.current.as_ref(), kind.to_bytes(), hs_hash) + } + + fn derive_logged_secret( + &self, + kind: SecretKind, + hs_hash: &[u8], + key_log: &dyn KeyLog, + client_random: &[u8; 32], + ) -> OkmBlock { + let output = self.derive(kind, hs_hash); + + let log_label = kind + .log_label() + .expect("not a loggable secret"); + if key_log.will_log(log_label) { + key_log.log(log_label, client_random, output.as_ref()); + } + output + } + + /// Derive a secret of given `kind` using the hash of the empty string + /// for the handshake hash. + /// + /// More specifically: + /// ```text + /// Derive-Secret(., Label, "") + /// ``` + /// where `kind` is `Label`. + /// + /// Useful only for the following `SecretKind`s: + /// - `SecretKind::ExternalPskBinderKey` + /// - `SecretKind::ResumptionPSKBinderKey` + /// - `SecretKind::DerivedSecret` + fn derive_for_empty_hash(&self, kind: SecretKind) -> OkmBlock { + let hp = self.suite.common.hash_provider; + let empty_hash = hp + .algorithm() + .hash_for_empty_input() + .unwrap_or_else(|| hp.start().finish()); + self.derive(kind, empty_hash.as_ref()) + } +} + +impl Deref for KeySchedule { + type Target = KeyScheduleSuite; + + fn deref(&self) -> &Self::Target { + &self.inner + } +} + +/// This is a component part of `KeySchedule`, and groups operations +/// that do not depend on the root key schedule secret. +#[derive(Clone, Copy)] +struct KeyScheduleSuite { + suite: &'static Tls13CipherSuite, +} + +impl KeyScheduleSuite { + fn set_encrypter(&self, secret: &OkmBlock, common: &mut CommonState) { + let expander = self + .suite + .hkdf_provider + .expander_for_okm(secret); + let key = derive_traffic_key(expander.as_ref(), self.suite.aead_alg); + let iv = derive_traffic_iv(expander.as_ref()); + + common + .record_layer + .set_message_encrypter( + self.suite.aead_alg.encrypter(key, iv), + self.suite.common.confidentiality_limit, + ); + } + + fn set_decrypter(&self, secret: &OkmBlock, common: &mut CommonState) { + common + .record_layer + .set_message_decrypter(self.derive_decrypter(secret)); + } + + fn derive_decrypter(&self, secret: &OkmBlock) -> Box { + let expander = self + .suite + .hkdf_provider + .expander_for_okm(secret); + let key = derive_traffic_key(expander.as_ref(), self.suite.aead_alg); + let iv = derive_traffic_iv(expander.as_ref()); + self.suite.aead_alg.decrypter(key, iv) + } + + /// Sign the finished message consisting of `hs_hash` using a current + /// traffic secret. + /// + /// See RFC 8446 section 4.4.4. + fn sign_finish(&self, base_key: &OkmBlock, hs_hash: &hash::Output) -> hmac::Tag { + self.sign_verify_data(base_key, hs_hash) + } + + /// Sign the finished message consisting of `hs_hash` using the key material + /// `base_key`. + /// + /// See RFC 8446 section 4.4.4. + fn sign_verify_data(&self, base_key: &OkmBlock, hs_hash: &hash::Output) -> hmac::Tag { + let expander = self + .suite + .hkdf_provider + .expander_for_okm(base_key); + let hmac_key = hkdf_expand_label_block(expander.as_ref(), b"finished", &[]); + + self.suite + .hkdf_provider + .hmac_sign(&hmac_key, hs_hash.as_ref()) + } + + /// Derive the next application traffic secret, returning it. + fn derive_next(&self, base_key: &OkmBlock) -> OkmBlock { + let expander = self + .suite + .hkdf_provider + .expander_for_okm(base_key); + hkdf_expand_label_block(expander.as_ref(), b"traffic upd", &[]) + } + + /// Derive the PSK to use given a resumption_master_secret and + /// ticket_nonce. + fn derive_ticket_psk(&self, rms: &OkmBlock, nonce: &[u8]) -> OkmBlock { + let expander = self + .suite + .hkdf_provider + .expander_for_okm(rms); + hkdf_expand_label_block(expander.as_ref(), b"resumption", nonce) + } + + fn export_keying_material( + &self, + current_exporter_secret: &OkmBlock, + out: &mut [u8], + label: &[u8], + context: Option<&[u8]>, + ) -> Result<(), Error> { + let secret = { + let h_empty = self + .suite + .common + .hash_provider + .hash(&[]); + + let expander = self + .suite + .hkdf_provider + .expander_for_okm(current_exporter_secret); + hkdf_expand_label_block(expander.as_ref(), label, h_empty.as_ref()) + }; + + let h_context = self + .suite + .common + .hash_provider + .hash(context.unwrap_or(&[])); + + let expander = self + .suite + .hkdf_provider + .expander_for_okm(&secret); + hkdf_expand_label_slice(expander.as_ref(), b"exporter", h_context.as_ref(), out) + .map_err(|_| Error::General("exporting too much".to_string())) + } +} + +impl From<&'static Tls13CipherSuite> for KeyScheduleSuite { + fn from(suite: &'static Tls13CipherSuite) -> Self { + Self { suite } + } +} + +/// [HKDF-Expand-Label] where the output is an AEAD key. +/// +/// [HKDF-Expand-Label]: +pub fn derive_traffic_key( + expander: &dyn HkdfExpander, + aead_alg: &dyn Tls13AeadAlgorithm, +) -> AeadKey { + hkdf_expand_label_aead_key(expander, aead_alg.key_len(), b"key", &[]) +} + +/// [HKDF-Expand-Label] where the output is an IV. +/// +/// [HKDF-Expand-Label]: +pub fn derive_traffic_iv(expander: &dyn HkdfExpander) -> Iv { + hkdf_expand_label(expander, b"iv", &[]) +} + +/// [HKDF-Expand-Label] where the output length is a compile-time constant, and therefore +/// it is infallible. +/// +/// [HKDF-Expand-Label]: +pub(crate) fn hkdf_expand_label, const N: usize>( + expander: &dyn HkdfExpander, + label: &[u8], + context: &[u8], +) -> T { + hkdf_expand_label_inner(expander, label, context, N, |e, info| expand(e, info)) +} + +/// [HKDF-Expand-Label] where the output is one block in size. +pub(crate) fn hkdf_expand_label_block( + expander: &dyn HkdfExpander, + label: &[u8], + context: &[u8], +) -> OkmBlock { + hkdf_expand_label_inner(expander, label, context, expander.hash_len(), |e, info| { + e.expand_block(info) + }) +} + +/// [HKDF-Expand-Label] where the output is an AEAD key. +pub(crate) fn hkdf_expand_label_aead_key( + expander: &dyn HkdfExpander, + key_len: usize, + label: &[u8], + context: &[u8], +) -> AeadKey { + hkdf_expand_label_inner(expander, label, context, key_len, |e, info| { + let key: AeadKey = expand(e, info); + key.with_length(key_len) + }) +} + +/// [HKDF-Expand-Label] where the output is a slice. +/// +/// This can fail because HKDF-Expand is limited in its maximum output length. +fn hkdf_expand_label_slice( + expander: &dyn HkdfExpander, + label: &[u8], + context: &[u8], + output: &mut [u8], +) -> Result<(), OutputLengthError> { + hkdf_expand_label_inner(expander, label, context, output.len(), |e, info| { + e.expand_slice(info, output) + }) +} + +pub(crate) fn server_ech_hrr_confirmation_secret( + hkdf_provider: &'static dyn Hkdf, + client_hello_inner_random: &[u8], + hs_hash: hash::Output, +) -> [u8; 8] { + /* + Per ietf-tls-esni-17 section 7.2.1: + + hrr_accept_confirmation = HKDF-Expand-Label( + HKDF-Extract(0, ClientHelloInner1.random), + "hrr ech accept confirmation", + transcript_hrr_ech_conf, + 8) + */ + hkdf_expand_label( + hkdf_provider + .extract_from_secret(None, client_hello_inner_random) + .as_ref(), + SecretKind::ServerEchHrrConfirmationSecret.to_bytes(), + hs_hash.as_ref(), + ) +} + +fn hkdf_expand_label_inner( + expander: &dyn HkdfExpander, + label: &[u8], + context: &[u8], + n: usize, + f: F, +) -> T +where + F: FnOnce(&dyn HkdfExpander, &[&[u8]]) -> T, +{ + const LABEL_PREFIX: &[u8] = b"tls13 "; + + let output_len = u16::to_be_bytes(n as u16); + let label_len = u8::to_be_bytes((LABEL_PREFIX.len() + label.len()) as u8); + let context_len = u8::to_be_bytes(context.len() as u8); + + let info = &[ + &output_len[..], + &label_len[..], + LABEL_PREFIX, + label, + &context_len[..], + context, + ]; + + f(expander, info) +} + +/// The kinds of secret we can extract from `KeySchedule`. +#[derive(Debug, Clone, Copy, PartialEq)] +enum SecretKind { + ResumptionPskBinderKey, + ClientEarlyTrafficSecret, + ClientHandshakeTrafficSecret, + ServerHandshakeTrafficSecret, + ClientApplicationTrafficSecret, + ServerApplicationTrafficSecret, + ExporterMasterSecret, + ResumptionMasterSecret, + DerivedSecret, + ServerEchConfirmationSecret, + ServerEchHrrConfirmationSecret, +} + +impl SecretKind { + fn to_bytes(self) -> &'static [u8] { + use self::SecretKind::*; + match self { + ResumptionPskBinderKey => b"res binder", + ClientEarlyTrafficSecret => b"c e traffic", + ClientHandshakeTrafficSecret => b"c hs traffic", + ServerHandshakeTrafficSecret => b"s hs traffic", + ClientApplicationTrafficSecret => b"c ap traffic", + ServerApplicationTrafficSecret => b"s ap traffic", + ExporterMasterSecret => b"exp master", + ResumptionMasterSecret => b"res master", + DerivedSecret => b"derived", + // https://datatracker.ietf.org/doc/html/draft-ietf-tls-esni-18#section-7.2 + ServerEchConfirmationSecret => b"ech accept confirmation", + // https://datatracker.ietf.org/doc/html/draft-ietf-tls-esni-18#section-7.2.1 + ServerEchHrrConfirmationSecret => b"hrr ech accept confirmation", + } + } + + fn log_label(self) -> Option<&'static str> { + use self::SecretKind::*; + Some(match self { + ClientEarlyTrafficSecret => "CLIENT_EARLY_TRAFFIC_SECRET", + ClientHandshakeTrafficSecret => "CLIENT_HANDSHAKE_TRAFFIC_SECRET", + ServerHandshakeTrafficSecret => "SERVER_HANDSHAKE_TRAFFIC_SECRET", + ClientApplicationTrafficSecret => "CLIENT_TRAFFIC_SECRET_0", + ServerApplicationTrafficSecret => "SERVER_TRAFFIC_SECRET_0", + ExporterMasterSecret => "EXPORTER_SECRET", + _ => { + return None; + } + }) + } +} + +#[cfg(test)] +#[macro_rules_attribute::apply(test_for_each_provider)] +mod tests { + use core::fmt::Debug; + use std::prelude::v1::*; + use std::vec; + + use super::provider::ring_like::aead; + use super::provider::tls13::{ + TLS13_AES_128_GCM_SHA256_INTERNAL, TLS13_CHACHA20_POLY1305_SHA256_INTERNAL, + }; + use super::{KeySchedule, SecretKind, derive_traffic_iv, derive_traffic_key}; + use crate::KeyLog; + use crate::msgs::enums::HashAlgorithm; + + #[test] + fn empty_hash() { + let sha256 = super::provider::tls13::TLS13_AES_128_GCM_SHA256 + .tls13() + .unwrap() + .common + .hash_provider; + let sha384 = super::provider::tls13::TLS13_AES_256_GCM_SHA384 + .tls13() + .unwrap() + .common + .hash_provider; + + assert!( + sha256.start().finish().as_ref() + == HashAlgorithm::SHA256 + .hash_for_empty_input() + .unwrap() + .as_ref() + ); + assert!( + sha384.start().finish().as_ref() + == HashAlgorithm::SHA384 + .hash_for_empty_input() + .unwrap() + .as_ref() + ); + + // a theoretical example of unsupported hash + assert!( + HashAlgorithm::SHA1 + .hash_for_empty_input() + .is_none() + ); + } + + #[test] + fn test_vectors() { + /* These test vectors generated with OpenSSL. */ + let hs_start_hash = [ + 0xec, 0x14, 0x7a, 0x06, 0xde, 0xa3, 0xc8, 0x84, 0x6c, 0x02, 0xb2, 0x23, 0x8e, 0x41, + 0xbd, 0xdc, 0x9d, 0x89, 0xf9, 0xae, 0xa1, 0x7b, 0x5e, 0xfd, 0x4d, 0x74, 0x82, 0xaf, + 0x75, 0x88, 0x1c, 0x0a, + ]; + + let hs_full_hash = [ + 0x75, 0x1a, 0x3d, 0x4a, 0x14, 0xdf, 0xab, 0xeb, 0x68, 0xe9, 0x2c, 0xa5, 0x91, 0x8e, + 0x24, 0x08, 0xb9, 0xbc, 0xb0, 0x74, 0x89, 0x82, 0xec, 0x9c, 0x32, 0x30, 0xac, 0x30, + 0xbb, 0xeb, 0x23, 0xe2, + ]; + + let ecdhe_secret = [ + 0xe7, 0xb8, 0xfe, 0xf8, 0x90, 0x3b, 0x52, 0x0c, 0xb9, 0xa1, 0x89, 0x71, 0xb6, 0x9d, + 0xd4, 0x5d, 0xca, 0x53, 0xce, 0x2f, 0x12, 0xbf, 0x3b, 0xef, 0x93, 0x15, 0xe3, 0x12, + 0x71, 0xdf, 0x4b, 0x40, + ]; + + let client_hts = [ + 0x61, 0x7b, 0x35, 0x07, 0x6b, 0x9d, 0x0e, 0x08, 0xcf, 0x73, 0x1d, 0x94, 0xa8, 0x66, + 0x14, 0x78, 0x41, 0x09, 0xef, 0x25, 0x55, 0x51, 0x92, 0x1d, 0xd4, 0x6e, 0x04, 0x01, + 0x35, 0xcf, 0x46, 0xab, + ]; + + let client_hts_key = [ + 0x62, 0xd0, 0xdd, 0x00, 0xf6, 0x96, 0x19, 0xd3, 0xb8, 0x19, 0x3a, 0xb4, 0xa0, 0x95, + 0x85, 0xa7, + ]; + + let client_hts_iv = [ + 0xff, 0xf7, 0x5d, 0xf5, 0xad, 0x35, 0xd5, 0xcb, 0x3c, 0x53, 0xf3, 0xa9, + ]; + + let server_hts = [ + 0xfc, 0xf7, 0xdf, 0xe6, 0x4f, 0xa2, 0xc0, 0x4f, 0x62, 0x35, 0x38, 0x7f, 0x43, 0x4e, + 0x01, 0x42, 0x23, 0x36, 0xd9, 0xc0, 0x39, 0xde, 0x68, 0x47, 0xa0, 0xb9, 0xdd, 0xcf, + 0x29, 0xa8, 0x87, 0x59, + ]; + + let server_hts_key = [ + 0x04, 0x67, 0xf3, 0x16, 0xa8, 0x05, 0xb8, 0xc4, 0x97, 0xee, 0x67, 0x04, 0x7b, 0xbc, + 0xbc, 0x54, + ]; + + let server_hts_iv = [ + 0xde, 0x83, 0xa7, 0x3e, 0x9d, 0x81, 0x4b, 0x04, 0xc4, 0x8b, 0x78, 0x09, + ]; + + let client_ats = [ + 0xc1, 0x4a, 0x6d, 0x79, 0x76, 0xd8, 0x10, 0x2b, 0x5a, 0x0c, 0x99, 0x51, 0x49, 0x3f, + 0xee, 0x87, 0xdc, 0xaf, 0xf8, 0x2c, 0x24, 0xca, 0xb2, 0x14, 0xe8, 0xbe, 0x71, 0xa8, + 0x20, 0x6d, 0xbd, 0xa5, + ]; + + let client_ats_key = [ + 0xcc, 0x9f, 0x5f, 0x98, 0x0b, 0x5f, 0x10, 0x30, 0x6c, 0xba, 0xd7, 0xbe, 0x98, 0xd7, + 0x57, 0x2e, + ]; + + let client_ats_iv = [ + 0xb8, 0x09, 0x29, 0xe8, 0xd0, 0x2c, 0x70, 0xf6, 0x11, 0x62, 0xed, 0x6b, + ]; + + let server_ats = [ + 0x2c, 0x90, 0x77, 0x38, 0xd3, 0xf8, 0x37, 0x02, 0xd1, 0xe4, 0x59, 0x8f, 0x48, 0x48, + 0x53, 0x1d, 0x9f, 0x93, 0x65, 0x49, 0x1b, 0x9f, 0x7f, 0x52, 0xc8, 0x22, 0x29, 0x0d, + 0x4c, 0x23, 0x21, 0x92, + ]; + + let server_ats_key = [ + 0x0c, 0xb2, 0x95, 0x62, 0xd8, 0xd8, 0x8f, 0x48, 0xb0, 0x2c, 0xbf, 0xbe, 0xd7, 0xe6, + 0x2b, 0xb3, + ]; + + let server_ats_iv = [ + 0x0d, 0xb2, 0x8f, 0x98, 0x85, 0x86, 0xa1, 0xb7, 0xe4, 0xd5, 0xc6, 0x9c, + ]; + + let mut ks = KeySchedule::new_with_empty_secret(TLS13_CHACHA20_POLY1305_SHA256_INTERNAL); + ks.input_secret(&ecdhe_secret); + + assert_traffic_secret( + &ks, + SecretKind::ClientHandshakeTrafficSecret, + &hs_start_hash, + &client_hts, + &client_hts_key, + &client_hts_iv, + ); + + assert_traffic_secret( + &ks, + SecretKind::ServerHandshakeTrafficSecret, + &hs_start_hash, + &server_hts, + &server_hts_key, + &server_hts_iv, + ); + + ks.input_empty(); + + assert_traffic_secret( + &ks, + SecretKind::ClientApplicationTrafficSecret, + &hs_full_hash, + &client_ats, + &client_ats_key, + &client_ats_iv, + ); + + assert_traffic_secret( + &ks, + SecretKind::ServerApplicationTrafficSecret, + &hs_full_hash, + &server_ats, + &server_ats_key, + &server_ats_iv, + ); + } + + fn assert_traffic_secret( + ks: &KeySchedule, + kind: SecretKind, + hash: &[u8], + expected_traffic_secret: &[u8], + expected_key: &[u8], + expected_iv: &[u8], + ) { + #[derive(Debug)] + struct Log<'a>(&'a [u8]); + impl KeyLog for Log<'_> { + fn log(&self, _label: &str, _client_random: &[u8], secret: &[u8]) { + assert_eq!(self.0, secret); + } + } + let log = Log(expected_traffic_secret); + let traffic_secret = ks.derive_logged_secret(kind, hash, &log, &[0; 32]); + + // Since we can't test key equality, we test the output of sealing with the key instead. + let aead_alg = &aead::AES_128_GCM; + let expander = TLS13_AES_128_GCM_SHA256_INTERNAL + .hkdf_provider + .expander_for_okm(&traffic_secret); + let key = derive_traffic_key( + expander.as_ref(), + TLS13_AES_128_GCM_SHA256_INTERNAL.aead_alg, + ); + let key = aead::UnboundKey::new(aead_alg, key.as_ref()).unwrap(); + let seal_output = seal_zeroes(key); + let expected_key = aead::UnboundKey::new(aead_alg, expected_key).unwrap(); + let expected_seal_output = seal_zeroes(expected_key); + assert_eq!(seal_output, expected_seal_output); + assert!(seal_output.len() >= 48); // Sanity check. + + let iv = derive_traffic_iv(expander.as_ref()); + assert_eq!(iv.as_ref(), expected_iv); + } + + fn seal_zeroes(key: aead::UnboundKey) -> Vec { + let key = aead::LessSafeKey::new(key); + let mut seal_output = vec![0; 32]; + key.seal_in_place_append_tag( + aead::Nonce::assume_unique_for_key([0; aead::NONCE_LEN]), + aead::Aad::empty(), + &mut seal_output, + ) + .unwrap(); + seal_output + } +} + +#[cfg(all(test, bench))] +#[macro_rules_attribute::apply(bench_for_each_provider)] +mod benchmarks { + #[bench] + fn bench_sha256(b: &mut test::Bencher) { + use core::fmt::Debug; + + use super::provider::tls13::TLS13_CHACHA20_POLY1305_SHA256_INTERNAL; + use super::{KeySchedule, SecretKind, derive_traffic_iv, derive_traffic_key}; + use crate::KeyLog; + + fn extract_traffic_secret(ks: &KeySchedule, kind: SecretKind) { + #[derive(Debug)] + struct Log; + + impl KeyLog for Log { + fn log(&self, _label: &str, _client_random: &[u8], _secret: &[u8]) {} + } + + let hash = [0u8; 32]; + let traffic_secret = ks.derive_logged_secret(kind, &hash, &Log, &[0u8; 32]); + let traffic_secret_expander = TLS13_CHACHA20_POLY1305_SHA256_INTERNAL + .hkdf_provider + .expander_for_okm(&traffic_secret); + test::black_box(derive_traffic_key( + traffic_secret_expander.as_ref(), + TLS13_CHACHA20_POLY1305_SHA256_INTERNAL.aead_alg, + )); + test::black_box(derive_traffic_iv(traffic_secret_expander.as_ref())); + } + + b.iter(|| { + let mut ks = + KeySchedule::new_with_empty_secret(TLS13_CHACHA20_POLY1305_SHA256_INTERNAL); + ks.input_secret(&[0u8; 32]); + + extract_traffic_secret(&ks, SecretKind::ClientHandshakeTrafficSecret); + extract_traffic_secret(&ks, SecretKind::ServerHandshakeTrafficSecret); + + ks.input_empty(); + + extract_traffic_secret(&ks, SecretKind::ClientApplicationTrafficSecret); + extract_traffic_secret(&ks, SecretKind::ServerApplicationTrafficSecret); + }); + } +} diff --git a/http/vendor/rustls/src/tls13/mod.rs b/http/vendor/rustls/src/tls13/mod.rs new file mode 100644 index 0000000..ab55c88 --- /dev/null +++ b/http/vendor/rustls/src/tls13/mod.rs @@ -0,0 +1,125 @@ +use core::fmt; + +use crate::crypto; +use crate::crypto::hash; +use crate::suites::{CipherSuiteCommon, SupportedCipherSuite}; + +pub(crate) mod key_schedule; + +/// A TLS 1.3 cipher suite supported by rustls. +pub struct Tls13CipherSuite { + /// Common cipher suite fields. + pub common: CipherSuiteCommon, + + /// How to complete HKDF with the suite's hash function. + /// + /// If you have a HKDF implementation, you should directly implement the `crypto::tls13::Hkdf` + /// trait (and associated). + /// + /// If not, you can implement the [`crypto::hmac::Hmac`] trait (and associated), and then use + /// [`crypto::tls13::HkdfUsingHmac`]. + pub hkdf_provider: &'static dyn crypto::tls13::Hkdf, + + /// How to produce a [MessageDecrypter] or [MessageEncrypter] + /// from raw key material. + /// + /// [MessageDecrypter]: crate::crypto::cipher::MessageDecrypter + /// [MessageEncrypter]: crate::crypto::cipher::MessageEncrypter + pub aead_alg: &'static dyn crypto::cipher::Tls13AeadAlgorithm, + + /// How to create QUIC header and record protection algorithms + /// for this suite. + /// + /// Provide `None` to opt out of QUIC support for this suite. It will + /// not be offered in QUIC handshakes. + pub quic: Option<&'static dyn crate::quic::Algorithm>, +} + +impl Tls13CipherSuite { + /// Can a session using suite self resume from suite prev? + pub fn can_resume_from(&self, prev: &'static Self) -> Option<&'static Self> { + (prev.common.hash_provider.algorithm() == self.common.hash_provider.algorithm()) + .then_some(prev) + } + + /// Return `true` if this is backed by a FIPS-approved implementation. + /// + /// This means all the constituent parts that do cryptography return `true` for `fips()`. + pub fn fips(&self) -> bool { + let Self { + common, + hkdf_provider, + aead_alg, + quic, + } = self; + common.fips() + && hkdf_provider.fips() + && aead_alg.fips() + && quic.map(|q| q.fips()).unwrap_or(true) + } + + /// Returns a `quic::Suite` for the ciphersuite, if supported. + pub fn quic_suite(&'static self) -> Option { + self.quic + .map(|quic| crate::quic::Suite { quic, suite: self }) + } +} + +impl From<&'static Tls13CipherSuite> for SupportedCipherSuite { + fn from(s: &'static Tls13CipherSuite) -> Self { + Self::Tls13(s) + } +} + +impl PartialEq for Tls13CipherSuite { + fn eq(&self, other: &Self) -> bool { + self.common.suite == other.common.suite + } +} + +impl fmt::Debug for Tls13CipherSuite { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Tls13CipherSuite") + .field("suite", &self.common.suite) + .finish() + } +} + +/// Constructs the signature message specified in section 4.4.3 of RFC8446. +pub(crate) fn construct_client_verify_message(handshake_hash: &hash::Output) -> VerifyMessage { + VerifyMessage::new(handshake_hash, CLIENT_CONSTANT) +} + +/// Constructs the signature message specified in section 4.4.3 of RFC8446. +pub(crate) fn construct_server_verify_message(handshake_hash: &hash::Output) -> VerifyMessage { + VerifyMessage::new(handshake_hash, SERVER_CONSTANT) +} + +pub(crate) struct VerifyMessage { + buf: [u8; MAX_VERIFY_MSG], + used: usize, +} + +impl VerifyMessage { + fn new(handshake_hash: &hash::Output, context_string_with_0: &[u8; 34]) -> Self { + let used = 64 + context_string_with_0.len() + handshake_hash.as_ref().len(); + let mut buf = [0x20u8; MAX_VERIFY_MSG]; + + let (_spaces, context) = buf.split_at_mut(64); + let (context, hash) = context.split_at_mut(34); + context.copy_from_slice(context_string_with_0); + hash[..handshake_hash.as_ref().len()].copy_from_slice(handshake_hash.as_ref()); + + Self { buf, used } + } +} + +impl AsRef<[u8]> for VerifyMessage { + fn as_ref(&self) -> &[u8] { + &self.buf[..self.used] + } +} + +const SERVER_CONSTANT: &[u8; 34] = b"TLS 1.3, server CertificateVerify\x00"; +const CLIENT_CONSTANT: &[u8; 34] = b"TLS 1.3, client CertificateVerify\x00"; +const MAX_VERIFY_MSG: usize = 64 + CLIENT_CONSTANT.len() + hash::Output::MAX_LEN; diff --git a/http/vendor/rustls/src/vecbuf.rs b/http/vendor/rustls/src/vecbuf.rs new file mode 100644 index 0000000..c050a30 --- /dev/null +++ b/http/vendor/rustls/src/vecbuf.rs @@ -0,0 +1,377 @@ +use alloc::collections::VecDeque; +use alloc::vec::Vec; +use core::{cmp, mem}; +#[cfg(feature = "std")] +use std::io; +#[cfg(feature = "std")] +use std::io::Read; + +#[cfg(feature = "std")] +use crate::msgs::message::OutboundChunks; + +/// This is a byte buffer that is built from a deque of byte vectors. +/// +/// This avoids extra copies when appending a new byte vector, +/// at the expense of more complexity when reading out. +pub(crate) struct ChunkVecBuffer { + /// How many bytes have been consumed in the first chunk. + /// + /// Invariant: zero if `chunks.is_empty()` + /// Invariant: 0 <= `prefix_used` < `chunks[0].len()` + prefix_used: usize, + + chunks: VecDeque>, + + /// The total upper limit (in bytes) of this object. + limit: Option, +} + +impl ChunkVecBuffer { + pub(crate) fn new(limit: Option) -> Self { + Self { + prefix_used: 0, + chunks: VecDeque::new(), + limit, + } + } + + /// Sets the upper limit on how many bytes this + /// object can store. + /// + /// Setting a lower limit than the currently stored + /// data is not an error. + /// + /// A [`None`] limit is interpreted as no limit. + pub(crate) fn set_limit(&mut self, new_limit: Option) { + self.limit = new_limit; + } + + /// If we're empty + pub(crate) fn is_empty(&self) -> bool { + self.chunks.is_empty() + } + + /// How many bytes we're storing + pub(crate) fn len(&self) -> usize { + self.chunks + .iter() + .fold(0usize, |acc, chunk| acc + chunk.len()) + - self.prefix_used + } + + /// For a proposed append of `len` bytes, how many + /// bytes should we actually append to adhere to the + /// currently set `limit`? + pub(crate) fn apply_limit(&self, len: usize) -> usize { + if let Some(limit) = self.limit { + let space = limit.saturating_sub(self.len()); + cmp::min(len, space) + } else { + len + } + } + + /// Take and append the given `bytes`. + pub(crate) fn append(&mut self, bytes: Vec) -> usize { + let len = bytes.len(); + + if !bytes.is_empty() { + if self.chunks.is_empty() { + debug_assert_eq!(self.prefix_used, 0); + } + + self.chunks.push_back(bytes); + } + + len + } + + /// Take one of the chunks from this object. + /// + /// This function returns `None` if the object `is_empty`. + pub(crate) fn pop(&mut self) -> Option> { + let mut first = self.chunks.pop_front(); + + if let Some(first) = &mut first { + // slice off `prefix_used` if needed (uncommon) + let prefix = mem::take(&mut self.prefix_used); + first.drain(0..prefix); + } + + first + } + + #[cfg(read_buf)] + /// Read data out of this object, writing it into `cursor`. + pub(crate) fn read_buf( + &mut self, + mut cursor: core::io::BorrowedCursor<'_, u8>, + ) -> io::Result<()> { + while !self.is_empty() && cursor.capacity() > 0 { + let chunk = &self.chunks[0][self.prefix_used..]; + let used = cmp::min(chunk.len(), cursor.capacity()); + cursor.append(&chunk[..used]); + self.consume(used); + } + + Ok(()) + } + + /// Inspect the first chunk from this object. + pub(crate) fn peek(&self) -> Option<&[u8]> { + self.chunks + .front() + .map(|ch| ch.as_slice()) + } +} + +#[cfg(feature = "std")] +impl ChunkVecBuffer { + pub(crate) fn is_full(&self) -> bool { + self.limit + .map(|limit| self.len() > limit) + .unwrap_or_default() + } + + /// Append a copy of `bytes`, perhaps a prefix if + /// we're near the limit. + pub(crate) fn append_limited_copy(&mut self, payload: OutboundChunks<'_>) -> usize { + let take = self.apply_limit(payload.len()); + self.append(payload.split_at(take).0.to_vec()); + take + } + + /// Read data out of this object, writing it into `buf` + /// and returning how many bytes were written there. + pub(crate) fn read(&mut self, buf: &mut [u8]) -> io::Result { + let mut offs = 0; + + while offs < buf.len() && !self.is_empty() { + let used = (&self.chunks[0][self.prefix_used..]).read(&mut buf[offs..])?; + + self.consume(used); + offs += used; + } + + Ok(offs) + } + + pub(crate) fn consume_first_chunk(&mut self, used: usize) { + // this backs (infallible) `BufRead::consume`, where `used` is + // user-supplied. + assert!( + used <= self + .chunk() + .map(|ch| ch.len()) + .unwrap_or_default(), + "illegal `BufRead::consume` usage", + ); + self.consume(used); + } + + fn consume(&mut self, used: usize) { + // first, mark the rightmost extent of the used buffer + self.prefix_used += used; + + // then reduce `prefix_used` by discarding wholly-covered + // buffers + while let Some(buf) = self.chunks.front() { + if self.prefix_used < buf.len() { + return; + } else { + self.prefix_used -= buf.len(); + self.chunks.pop_front(); + } + } + + debug_assert_eq!( + self.prefix_used, 0, + "attempted to `ChunkVecBuffer::consume` more than available" + ); + } + + /// Read data out of this object, passing it `wr` + pub(crate) fn write_to(&mut self, wr: &mut dyn io::Write) -> io::Result { + if self.is_empty() { + return Ok(0); + } + + let mut prefix = self.prefix_used; + let mut bufs = [io::IoSlice::new(&[]); 64]; + for (iov, chunk) in bufs.iter_mut().zip(self.chunks.iter()) { + *iov = io::IoSlice::new(&chunk[prefix..]); + prefix = 0; + } + let len = cmp::min(bufs.len(), self.chunks.len()); + let bufs = &bufs[..len]; + let used = wr.write_vectored(bufs)?; + let available_bytes = bufs.iter().map(|ch| ch.len()).sum(); + + if used > available_bytes { + // This is really unrecoverable, since the amount of data written + // is now unknown. Consume all the potentially-written data in + // case the caller ignores the error. + // See for background. + self.consume(available_bytes); + return Err(io::Error::new( + io::ErrorKind::Other, + std::format!("illegal write_vectored return value ({used} > {available_bytes})"), + )); + } + self.consume(used); + Ok(used) + } + + /// Returns the first contiguous chunk of data, or None if empty. + pub(crate) fn chunk(&self) -> Option<&[u8]> { + self.chunks + .front() + .map(|chunk| &chunk[self.prefix_used..]) + } +} + +#[cfg(all(test, feature = "std"))] +mod tests { + use alloc::vec; + use alloc::vec::Vec; + + use super::ChunkVecBuffer; + + #[test] + fn short_append_copy_with_limit() { + let mut cvb = ChunkVecBuffer::new(Some(12)); + assert_eq!(cvb.append_limited_copy(b"hello"[..].into()), 5); + assert_eq!(cvb.append_limited_copy(b"world"[..].into()), 5); + assert_eq!(cvb.append_limited_copy(b"hello"[..].into()), 2); + assert_eq!(cvb.append_limited_copy(b"world"[..].into()), 0); + + let mut buf = [0u8; 12]; + assert_eq!(cvb.read(&mut buf).unwrap(), 12); + assert_eq!(buf.to_vec(), b"helloworldhe".to_vec()); + } + + #[test] + fn read_byte_by_byte() { + let mut cvb = ChunkVecBuffer::new(None); + cvb.append(b"test fixture data".to_vec()); + assert!(!cvb.is_empty()); + for expect in b"test fixture data" { + let mut byte = [0]; + assert_eq!(cvb.read(&mut byte).unwrap(), 1); + assert_eq!(byte[0], *expect); + } + + assert_eq!(cvb.read(&mut [0]).unwrap(), 0); + } + + #[test] + fn every_possible_chunk_interleaving() { + let input = (0..=0xffu8) + .cycle() + .take(4096) + .collect::>(); + + for input_chunk_len in 1..64usize { + for output_chunk_len in 1..65usize { + std::println!("check input={input_chunk_len} output={output_chunk_len}"); + let mut cvb = ChunkVecBuffer::new(None); + for chunk in input.chunks(input_chunk_len) { + cvb.append(chunk.to_vec()); + } + + assert_eq!(cvb.len(), input.len()); + let mut buf = vec![0u8; output_chunk_len]; + + for expect in input.chunks(output_chunk_len) { + assert_eq!(expect.len(), cvb.read(&mut buf).unwrap()); + assert_eq!(expect, &buf[..expect.len()]); + } + + assert_eq!(cvb.read(&mut [0]).unwrap(), 0); + } + } + } + + #[cfg(read_buf)] + #[test] + fn read_buf() { + use core::io::BorrowedBuf; + use core::mem::MaybeUninit; + + { + let mut cvb = ChunkVecBuffer::new(None); + cvb.append(b"test ".to_vec()); + cvb.append(b"fixture ".to_vec()); + cvb.append(b"data".to_vec()); + + let mut buf = [MaybeUninit::::uninit(); 8]; + let mut buf: BorrowedBuf<'_, u8> = buf.as_mut_slice().into(); + cvb.read_buf(buf.unfilled()).unwrap(); + assert_eq!(buf.filled(), b"test fix"); + buf.clear(); + cvb.read_buf(buf.unfilled()).unwrap(); + assert_eq!(buf.filled(), b"ture dat"); + buf.clear(); + cvb.read_buf(buf.unfilled()).unwrap(); + assert_eq!(buf.filled(), b"a"); + } + + { + let mut cvb = ChunkVecBuffer::new(None); + cvb.append(b"short message".to_vec()); + + let mut buf = [MaybeUninit::::uninit(); 1024]; + let mut buf: BorrowedBuf<'_, u8> = buf.as_mut_slice().into(); + cvb.read_buf(buf.unfilled()).unwrap(); + assert_eq!(buf.filled(), b"short message"); + } + } +} + +#[cfg(bench)] +mod benchmarks { + use alloc::vec; + + use super::ChunkVecBuffer; + + #[bench] + fn read_one_byte_from_large_message(b: &mut test::Bencher) { + b.iter(|| { + let mut cvb = ChunkVecBuffer::new(None); + cvb.append(vec![0u8; 16_384]); + assert_eq!(1, cvb.read(&mut [0u8]).unwrap()); + }); + } + + #[bench] + fn read_all_individual_from_large_message(b: &mut test::Bencher) { + b.iter(|| { + let mut cvb = ChunkVecBuffer::new(None); + cvb.append(vec![0u8; 16_384]); + loop { + if let Ok(0) = cvb.read(&mut [0u8]) { + break; + } + } + }); + } + + #[bench] + fn read_half_bytes_from_large_message(b: &mut test::Bencher) { + b.iter(|| { + let mut cvb = ChunkVecBuffer::new(None); + cvb.append(vec![0u8; 16_384]); + assert_eq!(8192, cvb.read(&mut [0u8; 8192]).unwrap()); + assert_eq!(8192, cvb.read(&mut [0u8; 8192]).unwrap()); + }); + } + + #[bench] + fn read_entire_large_message(b: &mut test::Bencher) { + b.iter(|| { + let mut cvb = ChunkVecBuffer::new(None); + cvb.append(vec![0u8; 16_384]); + assert_eq!(16_384, cvb.read(&mut [0u8; 16_384]).unwrap()); + }); + } +} diff --git a/http/vendor/rustls/src/verify.rs b/http/vendor/rustls/src/verify.rs new file mode 100644 index 0000000..4673154 --- /dev/null +++ b/http/vendor/rustls/src/verify.rs @@ -0,0 +1,383 @@ +use alloc::vec::Vec; +use core::fmt::Debug; + +use pki_types::{CertificateDer, ServerName, UnixTime}; + +use crate::enums::SignatureScheme; +use crate::error::{Error, InvalidMessage}; +use crate::msgs::base::PayloadU16; +use crate::msgs::codec::{Codec, Reader}; +use crate::msgs::handshake::DistinguishedName; + +// Marker types. These are used to bind the fact some verification +// (certificate chain or handshake signature) has taken place into +// protocol states. We use this to have the compiler check that there +// are no 'goto fail'-style elisions of important checks before we +// reach the traffic stage. +// +// These types are public, but cannot be directly constructed. This +// means their origins can be precisely determined by looking +// for their `assertion` constructors. + +/// Zero-sized marker type representing verification of a signature. +#[derive(Debug)] +pub struct HandshakeSignatureValid(()); + +impl HandshakeSignatureValid { + /// Make a `HandshakeSignatureValid` + pub fn assertion() -> Self { + Self(()) + } +} + +#[derive(Debug)] +pub(crate) struct FinishedMessageVerified(()); + +impl FinishedMessageVerified { + pub(crate) fn assertion() -> Self { + Self(()) + } +} + +/// Zero-sized marker type representing verification of a server cert chain. +#[allow(unreachable_pub)] +#[derive(Debug)] +pub struct ServerCertVerified(()); + +#[allow(unreachable_pub)] +impl ServerCertVerified { + /// Make a `ServerCertVerified` + pub fn assertion() -> Self { + Self(()) + } +} + +/// Zero-sized marker type representing verification of a client cert chain. +#[derive(Debug)] +pub struct ClientCertVerified(()); + +impl ClientCertVerified { + /// Make a `ClientCertVerified` + pub fn assertion() -> Self { + Self(()) + } +} + +/// Something that can verify a server certificate chain, and verify +/// signatures made by certificates. +#[allow(unreachable_pub)] +pub trait ServerCertVerifier: Debug + Send + Sync { + /// Verify the end-entity certificate `end_entity` is valid for the + /// hostname `dns_name` and chains to at least one trust anchor. + /// + /// `intermediates` contains all certificates other than `end_entity` that + /// were sent as part of the server's [Certificate] message. It is in the + /// same order that the server sent them and may be empty. + /// + /// Note that none of the certificates have been parsed yet, so it is the responsibility of + /// the implementer to handle invalid data. It is recommended that the implementer returns + /// [`Error::InvalidCertificate`] containing [`CertificateError::BadEncoding`] when these cases are encountered. + /// + /// [Certificate]: https://datatracker.ietf.org/doc/html/rfc8446#section-4.4.2 + /// [`CertificateError::BadEncoding`]: crate::error::CertificateError::BadEncoding + fn verify_server_cert( + &self, + end_entity: &CertificateDer<'_>, + intermediates: &[CertificateDer<'_>], + server_name: &ServerName<'_>, + ocsp_response: &[u8], + now: UnixTime, + ) -> Result; + + /// Verify a signature allegedly by the given server certificate. + /// + /// `message` is not hashed, and needs hashing during the verification. + /// The signature and algorithm are within `dss`. `cert` contains the + /// public key to use. + /// + /// `cert` has already been validated by [`ServerCertVerifier::verify_server_cert`]. + /// + /// If and only if the signature is valid, return `Ok(HandshakeSignatureValid)`. + /// Otherwise, return an error -- rustls will send an alert and abort the + /// connection. + /// + /// This method is only called for TLS1.2 handshakes. Note that, in TLS1.2, + /// SignatureSchemes such as `SignatureScheme::ECDSA_NISTP256_SHA256` are not + /// in fact bound to the specific curve implied in their name. + fn verify_tls12_signature( + &self, + message: &[u8], + cert: &CertificateDer<'_>, + dss: &DigitallySignedStruct, + ) -> Result; + + /// Verify a signature allegedly by the given server certificate. + /// + /// This method is only called for TLS1.3 handshakes. + /// + /// This method is very similar to `verify_tls12_signature`: but note the + /// tighter ECDSA SignatureScheme semantics -- e.g. `SignatureScheme::ECDSA_NISTP256_SHA256` + /// must only validate signatures using public keys on the right curve -- + /// rustls does not enforce this requirement for you. + /// + /// `cert` has already been validated by [`ServerCertVerifier::verify_server_cert`]. + /// + /// If and only if the signature is valid, return `Ok(HandshakeSignatureValid)`. + /// Otherwise, return an error -- rustls will send an alert and abort the + /// connection. + fn verify_tls13_signature( + &self, + message: &[u8], + cert: &CertificateDer<'_>, + dss: &DigitallySignedStruct, + ) -> Result; + + /// Return the list of SignatureSchemes that this verifier will handle, + /// in `verify_tls12_signature` and `verify_tls13_signature` calls. + /// + /// This should be in priority order, with the most preferred first. + fn supported_verify_schemes(&self) -> Vec; + + /// Returns whether this verifier requires raw public keys as defined + /// in [RFC 7250](https://tools.ietf.org/html/rfc7250). + fn requires_raw_public_keys(&self) -> bool { + false + } + + /// Return the [`DistinguishedName`]s of certificate authorities that this verifier trusts. + /// + /// If specified, will be sent as the [`certificate_authorities`] extension in ClientHello. + /// Note that this is only applicable to TLS 1.3. + /// + /// [`certificate_authorities`]: https://datatracker.ietf.org/doc/html/rfc8446#section-4.2.4 + fn root_hint_subjects(&self) -> Option<&[DistinguishedName]> { + None + } +} + +/// Something that can verify a client certificate chain +#[allow(unreachable_pub)] +pub trait ClientCertVerifier: Debug + Send + Sync { + /// Returns `true` to enable the server to request a client certificate and + /// `false` to skip requesting a client certificate. Defaults to `true`. + fn offer_client_auth(&self) -> bool { + true + } + + /// Return `true` to require a client certificate and `false` to make + /// client authentication optional. + /// Defaults to `self.offer_client_auth()`. + fn client_auth_mandatory(&self) -> bool { + self.offer_client_auth() + } + + /// Returns the [`DistinguishedName`] [subjects] that the server will hint to clients to + /// identify acceptable authentication trust anchors. + /// + /// These hint values help the client pick a client certificate it believes the server will + /// accept. The hints must be DER-encoded X.500 distinguished names, per [RFC 5280 A.1]. They + /// are sent in the [`certificate_authorities`] extension of a [`CertificateRequest`] message + /// when [ClientCertVerifier::offer_client_auth] is true. When an empty list is sent the client + /// should always provide a client certificate if it has one. + /// + /// Generally this list should contain the [`DistinguishedName`] of each root trust + /// anchor in the root cert store that the server is configured to use for authenticating + /// presented client certificates. + /// + /// In some circumstances this list may be customized to include [`DistinguishedName`] entries + /// that do not correspond to a trust anchor in the server's root cert store. For example, + /// the server may be configured to trust a root CA that cross-signed an issuer certificate + /// that the client considers a trust anchor. From the server's perspective the cross-signed + /// certificate is an intermediate, and not present in the server's root cert store. The client + /// may have the cross-signed certificate configured as a trust anchor, and be unaware of the + /// root CA that cross-signed it. If the server's hints list only contained the subjects of the + /// server's root store the client would consider a client certificate issued by the cross-signed + /// issuer unacceptable, since its subject was not hinted. To avoid this circumstance the server + /// should customize the hints list to include the subject of the cross-signed issuer in addition + /// to the subjects from the root cert store. + /// + /// [subjects]: https://datatracker.ietf.org/doc/html/rfc5280#section-4.1.2.6 + /// [RFC 5280 A.1]: https://www.rfc-editor.org/rfc/rfc5280#appendix-A.1 + /// [`CertificateRequest`]: https://datatracker.ietf.org/doc/html/rfc8446#section-4.3.2 + /// [`certificate_authorities`]: https://datatracker.ietf.org/doc/html/rfc8446#section-4.2.4 + fn root_hint_subjects(&self) -> &[DistinguishedName]; + + /// Verify the end-entity certificate `end_entity` is valid, acceptable, + /// and chains to at least one of the trust anchors trusted by + /// this verifier. + /// + /// `intermediates` contains the intermediate certificates the + /// client sent along with the end-entity certificate; it is in the same + /// order that the peer sent them and may be empty. + /// + /// Note that none of the certificates have been parsed yet, so it is the responsibility of + /// the implementer to handle invalid data. It is recommended that the implementer returns + /// an [InvalidCertificate] error with the [BadEncoding] variant when these cases are encountered. + /// + /// [InvalidCertificate]: Error#variant.InvalidCertificate + /// [BadEncoding]: crate::CertificateError#variant.BadEncoding + fn verify_client_cert( + &self, + end_entity: &CertificateDer<'_>, + intermediates: &[CertificateDer<'_>], + now: UnixTime, + ) -> Result; + + /// Verify a signature allegedly by the given client certificate. + /// + /// `message` is not hashed, and needs hashing during the verification. + /// The signature and algorithm are within `dss`. `cert` contains the + /// public key to use. + /// + /// `cert` has already been validated by [`ClientCertVerifier::verify_client_cert`]. + /// + /// If and only if the signature is valid, return `Ok(HandshakeSignatureValid)`. + /// Otherwise, return an error -- rustls will send an alert and abort the + /// connection. + /// + /// This method is only called for TLS1.2 handshakes. Note that, in TLS1.2, + /// SignatureSchemes such as `SignatureScheme::ECDSA_NISTP256_SHA256` are not + /// in fact bound to the specific curve implied in their name. + fn verify_tls12_signature( + &self, + message: &[u8], + cert: &CertificateDer<'_>, + dss: &DigitallySignedStruct, + ) -> Result; + + /// Verify a signature allegedly by the given client certificate. + /// + /// This method is only called for TLS1.3 handshakes. + /// + /// This method is very similar to `verify_tls12_signature`, but note the + /// tighter ECDSA SignatureScheme semantics in TLS 1.3. For example, + /// `SignatureScheme::ECDSA_NISTP256_SHA256` + /// must only validate signatures using public keys on the right curve -- + /// rustls does not enforce this requirement for you. + fn verify_tls13_signature( + &self, + message: &[u8], + cert: &CertificateDer<'_>, + dss: &DigitallySignedStruct, + ) -> Result; + + /// Return the list of SignatureSchemes that this verifier will handle, + /// in `verify_tls12_signature` and `verify_tls13_signature` calls. + /// + /// This should be in priority order, with the most preferred first. + fn supported_verify_schemes(&self) -> Vec; + + /// Returns whether this verifier requires raw public keys as defined + /// in [RFC 7250](https://tools.ietf.org/html/rfc7250). + fn requires_raw_public_keys(&self) -> bool { + false + } +} + +/// Turns off client authentication. +/// +/// In contrast to using +/// `WebPkiClientVerifier::builder(roots).allow_unauthenticated().build()`, the `NoClientAuth` +/// `ClientCertVerifier` will not offer client authentication at all, vs offering but not +/// requiring it. +#[derive(Debug)] +pub struct NoClientAuth; + +impl ClientCertVerifier for NoClientAuth { + fn offer_client_auth(&self) -> bool { + false + } + + fn root_hint_subjects(&self) -> &[DistinguishedName] { + unimplemented!(); + } + + fn verify_client_cert( + &self, + _end_entity: &CertificateDer<'_>, + _intermediates: &[CertificateDer<'_>], + _now: UnixTime, + ) -> Result { + unimplemented!(); + } + + fn verify_tls12_signature( + &self, + _message: &[u8], + _cert: &CertificateDer<'_>, + _dss: &DigitallySignedStruct, + ) -> Result { + unimplemented!(); + } + + fn verify_tls13_signature( + &self, + _message: &[u8], + _cert: &CertificateDer<'_>, + _dss: &DigitallySignedStruct, + ) -> Result { + unimplemented!(); + } + + fn supported_verify_schemes(&self) -> Vec { + unimplemented!(); + } +} + +/// This type combines a [`SignatureScheme`] and a signature payload produced with that scheme. +#[derive(Debug, Clone)] +pub struct DigitallySignedStruct { + /// The [`SignatureScheme`] used to produce the signature. + pub scheme: SignatureScheme, + sig: PayloadU16, +} + +impl DigitallySignedStruct { + pub(crate) fn new(scheme: SignatureScheme, sig: Vec) -> Self { + Self { + scheme, + sig: PayloadU16::new(sig), + } + } + + /// Get the signature. + pub fn signature(&self) -> &[u8] { + &self.sig.0 + } +} + +impl Codec<'_> for DigitallySignedStruct { + fn encode(&self, bytes: &mut Vec) { + self.scheme.encode(bytes); + self.sig.encode(bytes); + } + + fn read(r: &mut Reader<'_>) -> Result { + let scheme = SignatureScheme::read(r)?; + let sig = PayloadU16::read(r)?; + + Ok(Self { scheme, sig }) + } +} + +#[test] +fn assertions_are_debug() { + use std::format; + + assert_eq!( + format!("{:?}", ClientCertVerified::assertion()), + "ClientCertVerified(())" + ); + assert_eq!( + format!("{:?}", HandshakeSignatureValid::assertion()), + "HandshakeSignatureValid(())" + ); + assert_eq!( + format!("{:?}", FinishedMessageVerified::assertion()), + "FinishedMessageVerified(())" + ); + assert_eq!( + format!("{:?}", ServerCertVerified::assertion()), + "ServerCertVerified(())" + ); +} diff --git a/http/vendor/rustls/src/verifybench.rs b/http/vendor/rustls/src/verifybench.rs new file mode 100644 index 0000000..9a675d8 --- /dev/null +++ b/http/vendor/rustls/src/verifybench.rs @@ -0,0 +1,243 @@ +//! This program does benchmarking of the functions in verify.rs, +//! that do certificate chain validation and signature verification. +//! +//! This uses captured certificate chains for a selection of websites, +//! saved in `testdata/cert-{SITE}.{I}.der`. +//! +//! To update that data: +//! +//! - delete all `testdata/cert-*.der`. +//! - run the `admin/capture-certdata` script. +//! - update the verification timestamp near the bottom of this file +//! to the current time. +//! - where a website's chain length changed, reflect that in the list +//! of certificate files below. +//! +//! This does not need to be done regularly; because the verification +//! time is fixed, it only needs doing if a root certificate is +//! distrusted. + +#![cfg(bench)] + +use core::time::Duration; +use std::prelude::v1::*; + +use pki_types::{CertificateDer, ServerName, UnixTime}; +use webpki_roots; + +use crate::crypto::CryptoProvider; +use crate::verify::ServerCertVerifier; +use crate::webpki::{RootCertStore, WebPkiServerVerifier}; + +#[macro_rules_attribute::apply(bench_for_each_provider)] +mod benchmarks { + use super::{Context, provider}; + + #[bench] + fn reddit_cert(b: &mut test::Bencher) { + let ctx = Context::new( + provider::default_provider(), + "reddit.com", + &[ + include_bytes!("testdata/cert-reddit.0.der"), + include_bytes!("testdata/cert-reddit.1.der"), + ], + ); + b.iter(|| ctx.verify_once()); + } + + #[bench] + fn github_cert(b: &mut test::Bencher) { + let ctx = Context::new( + provider::default_provider(), + "github.com", + &[ + include_bytes!("testdata/cert-github.0.der"), + include_bytes!("testdata/cert-github.1.der"), + include_bytes!("testdata/cert-github.2.der"), + ], + ); + b.iter(|| ctx.verify_once()); + } + + #[bench] + fn arstechnica_cert(b: &mut test::Bencher) { + let ctx = Context::new( + provider::default_provider(), + "arstechnica.com", + &[ + include_bytes!("testdata/cert-arstechnica.0.der"), + include_bytes!("testdata/cert-arstechnica.1.der"), + include_bytes!("testdata/cert-arstechnica.2.der"), + ], + ); + b.iter(|| ctx.verify_once()); + } + + #[bench] + fn servo_cert(b: &mut test::Bencher) { + let ctx = Context::new( + provider::default_provider(), + "servo.org", + &[ + include_bytes!("testdata/cert-servo.0.der"), + include_bytes!("testdata/cert-servo.1.der"), + include_bytes!("testdata/cert-servo.2.der"), + ], + ); + b.iter(|| ctx.verify_once()); + } + + #[bench] + fn twitter_cert(b: &mut test::Bencher) { + let ctx = Context::new( + provider::default_provider(), + "twitter.com", + &[ + include_bytes!("testdata/cert-twitter.0.der"), + include_bytes!("testdata/cert-twitter.1.der"), + ], + ); + b.iter(|| ctx.verify_once()); + } + + #[bench] + fn wikipedia_cert(b: &mut test::Bencher) { + let ctx = Context::new( + provider::default_provider(), + "wikipedia.org", + &[ + include_bytes!("testdata/cert-wikipedia.0.der"), + include_bytes!("testdata/cert-wikipedia.1.der"), + ], + ); + b.iter(|| ctx.verify_once()); + } + + #[bench] + fn google_cert(b: &mut test::Bencher) { + let ctx = Context::new( + provider::default_provider(), + "www.google.com", + &[ + include_bytes!("testdata/cert-google.0.der"), + include_bytes!("testdata/cert-google.1.der"), + include_bytes!("testdata/cert-google.2.der"), + ], + ); + b.iter(|| ctx.verify_once()); + } + + #[bench] + fn hn_cert(b: &mut test::Bencher) { + let ctx = Context::new( + provider::default_provider(), + "news.ycombinator.com", + &[ + include_bytes!("testdata/cert-hn.0.der"), + include_bytes!("testdata/cert-hn.1.der"), + ], + ); + b.iter(|| ctx.verify_once()); + } + + #[bench] + fn stackoverflow_cert(b: &mut test::Bencher) { + let ctx = Context::new( + provider::default_provider(), + "stackoverflow.com", + &[ + include_bytes!("testdata/cert-stackoverflow.0.der"), + include_bytes!("testdata/cert-stackoverflow.1.der"), + ], + ); + b.iter(|| ctx.verify_once()); + } + + #[bench] + fn duckduckgo_cert(b: &mut test::Bencher) { + let ctx = Context::new( + provider::default_provider(), + "duckduckgo.com", + &[ + include_bytes!("testdata/cert-duckduckgo.0.der"), + include_bytes!("testdata/cert-duckduckgo.1.der"), + include_bytes!("testdata/cert-duckduckgo.2.der"), + ], + ); + b.iter(|| ctx.verify_once()); + } + + #[bench] + fn rustlang_cert(b: &mut test::Bencher) { + let ctx = Context::new( + provider::default_provider(), + "www.rust-lang.org", + &[ + include_bytes!("testdata/cert-rustlang.0.der"), + include_bytes!("testdata/cert-rustlang.1.der"), + ], + ); + b.iter(|| ctx.verify_once()); + } + + #[bench] + fn wapo_cert(b: &mut test::Bencher) { + let ctx = Context::new( + provider::default_provider(), + "www.washingtonpost.com", + &[ + include_bytes!("testdata/cert-wapo.0.der"), + include_bytes!("testdata/cert-wapo.1.der"), + ], + ); + b.iter(|| ctx.verify_once()); + } +} + +struct Context { + server_name: ServerName<'static>, + chain: Vec>, + now: UnixTime, + verifier: WebPkiServerVerifier, +} + +impl Context { + fn new(provider: CryptoProvider, domain: &'static str, certs: &[&'static [u8]]) -> Self { + let mut roots = RootCertStore::empty(); + roots.extend( + webpki_roots::TLS_SERVER_ROOTS + .iter() + .cloned(), + ); + Self { + server_name: domain.try_into().unwrap(), + chain: certs + .iter() + .copied() + .map(|bytes| CertificateDer::from(bytes.to_vec())) + .collect(), + // Feb 4, 2026, around 11:41 UTC + now: UnixTime::since_unix_epoch(Duration::from_secs(1_770_205_316)), + verifier: WebPkiServerVerifier::new_without_revocation( + roots, + provider.signature_verification_algorithms, + ), + } + } + + fn verify_once(&self) { + const OCSP_RESPONSE: &[u8] = &[]; + + let (end_entity, intermediates) = self.chain.split_first().unwrap(); + self.verifier + .verify_server_cert( + end_entity, + intermediates, + &self.server_name, + OCSP_RESPONSE, + self.now, + ) + .unwrap(); + } +} diff --git a/http/vendor/rustls/src/versions.rs b/http/vendor/rustls/src/versions.rs new file mode 100644 index 0000000..4acdf99 --- /dev/null +++ b/http/vendor/rustls/src/versions.rs @@ -0,0 +1,97 @@ +use core::fmt; + +use crate::enums::ProtocolVersion; + +/// A TLS protocol version supported by rustls. +/// +/// All possible instances of this class are provided by the library in +/// the [`ALL_VERSIONS`] array, as well as individually as [`TLS12`] +/// and [`TLS13`]. +#[non_exhaustive] +#[derive(Eq, PartialEq)] +pub struct SupportedProtocolVersion { + /// The TLS enumeration naming this version. + pub version: ProtocolVersion, +} + +impl fmt::Debug for SupportedProtocolVersion { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + self.version.fmt(f) + } +} + +/// TLS1.2 +#[cfg(feature = "tls12")] +pub static TLS12: SupportedProtocolVersion = SupportedProtocolVersion { + version: ProtocolVersion::TLSv1_2, +}; + +/// TLS1.3 +pub static TLS13: SupportedProtocolVersion = SupportedProtocolVersion { + version: ProtocolVersion::TLSv1_3, +}; + +/// A list of all the protocol versions supported by rustls. +pub static ALL_VERSIONS: &[&SupportedProtocolVersion] = &[ + &TLS13, + #[cfg(feature = "tls12")] + &TLS12, +]; + +/// The version configuration that an application should use by default. +/// +/// This will be [`ALL_VERSIONS`] for now, but gives space in the future +/// to remove a version from here and require users to opt-in to older +/// versions. +pub static DEFAULT_VERSIONS: &[&SupportedProtocolVersion] = ALL_VERSIONS; + +#[derive(Clone, Copy)] +pub(crate) struct EnabledVersions { + #[cfg(feature = "tls12")] + tls12: Option<&'static SupportedProtocolVersion>, + tls13: Option<&'static SupportedProtocolVersion>, +} + +impl fmt::Debug for EnabledVersions { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let mut list = &mut f.debug_list(); + #[cfg(feature = "tls12")] + if let Some(v) = self.tls12 { + list = list.entry(v); + } + if let Some(v) = self.tls13 { + list = list.entry(v); + } + list.finish() + } +} + +impl EnabledVersions { + pub(crate) fn new(versions: &[&'static SupportedProtocolVersion]) -> Self { + let mut ev = Self { + #[cfg(feature = "tls12")] + tls12: None, + tls13: None, + }; + + for v in versions { + match v.version { + #[cfg(feature = "tls12")] + ProtocolVersion::TLSv1_2 => ev.tls12 = Some(v), + ProtocolVersion::TLSv1_3 => ev.tls13 = Some(v), + _ => {} + } + } + + ev + } + + pub(crate) fn contains(&self, version: ProtocolVersion) -> bool { + match version { + #[cfg(feature = "tls12")] + ProtocolVersion::TLSv1_2 => self.tls12.is_some(), + ProtocolVersion::TLSv1_3 => self.tls13.is_some(), + _ => false, + } + } +} diff --git a/http/vendor/rustls/src/webpki/anchors.rs b/http/vendor/rustls/src/webpki/anchors.rs new file mode 100644 index 0000000..01cefed --- /dev/null +++ b/http/vendor/rustls/src/webpki/anchors.rs @@ -0,0 +1,143 @@ +use alloc::vec::Vec; +use alloc::{fmt, format}; + +use pki_types::{CertificateDer, TrustAnchor}; +use webpki::anchor_from_trusted_cert; + +use super::pki_error; +use crate::log::{debug, trace}; +use crate::{DistinguishedName, Error}; + +/// A container for root certificates able to provide a root-of-trust +/// for connection authentication. +#[derive(Clone)] +pub struct RootCertStore { + /// The list of roots. + pub roots: Vec>, +} + +impl RootCertStore { + /// Make a new, empty `RootCertStore`. + pub fn empty() -> Self { + Self { roots: Vec::new() } + } + + /// Parse the given DER-encoded certificates and add all that can be parsed + /// in a best-effort fashion. + /// + /// This is because large collections of root certificates often + /// include ancient or syntactically invalid certificates. + /// + /// Returns the number of certificates added, and the number that were ignored. + pub fn add_parsable_certificates<'a>( + &mut self, + der_certs: impl IntoIterator>, + ) -> (usize, usize) { + let mut valid_count = 0; + let mut invalid_count = 0; + + for der_cert in der_certs { + #[cfg_attr(not(feature = "logging"), allow(unused_variables))] + match anchor_from_trusted_cert(&der_cert) { + Ok(anchor) => { + self.roots.push(anchor.to_owned()); + valid_count += 1; + } + Err(err) => { + trace!("invalid cert der {:?}", der_cert.as_ref()); + debug!("certificate parsing failed: {err:?}"); + invalid_count += 1; + } + }; + } + + debug!( + "add_parsable_certificates processed {valid_count} valid and {invalid_count} invalid certs" + ); + + (valid_count, invalid_count) + } + + /// Add a single DER-encoded certificate to the store. + /// + /// This is suitable for a small set of root certificates that are expected to parse + /// successfully. For large collections of roots (for example from a system store) it + /// is expected that some of them might not be valid according to the rules rustls + /// implements. As long as a relatively limited number of certificates are affected, + /// this should not be a cause for concern. Use [`RootCertStore::add_parsable_certificates`] + /// in order to add as many valid roots as possible and to understand how many certificates + /// have been diagnosed as malformed. + pub fn add(&mut self, der: CertificateDer<'_>) -> Result<(), Error> { + self.roots.push( + anchor_from_trusted_cert(&der) + .map_err(pki_error)? + .to_owned(), + ); + Ok(()) + } + + /// Return the DER encoded [`DistinguishedName`] of each trust anchor subject in the root + /// cert store. + /// + /// Each [`DistinguishedName`] will be a DER-encoded X.500 distinguished name, per + /// [RFC 5280 A.1], including the outer `SEQUENCE`. + /// + /// [RFC 5280 A.1]: https://www.rfc-editor.org/rfc/rfc5280#appendix-A.1 + pub fn subjects(&self) -> Vec { + self.roots + .iter() + .map(|ta| DistinguishedName::in_sequence(ta.subject.as_ref())) + .collect() + } + + /// Return true if there are no certificates. + pub fn is_empty(&self) -> bool { + self.len() == 0 + } + + /// Say how many certificates are in the container. + pub fn len(&self) -> usize { + self.roots.len() + } +} + +impl FromIterator> for RootCertStore { + fn from_iter>>(iter: T) -> Self { + Self { + roots: iter.into_iter().collect(), + } + } +} + +impl Extend> for RootCertStore { + fn extend>>(&mut self, iter: T) { + self.roots.extend(iter); + } +} + +impl fmt::Debug for RootCertStore { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("RootCertStore") + .field("roots", &format!("({} roots)", self.roots.len())) + .finish() + } +} + +#[test] +fn root_cert_store_debug() { + use core::iter; + + use pki_types::Der; + + let ta = TrustAnchor { + subject: Der::from_slice(&[]), + subject_public_key_info: Der::from_slice(&[]), + name_constraints: None, + }; + let store = RootCertStore::from_iter(iter::repeat(ta).take(138)); + + assert_eq!( + format!("{store:?}"), + "RootCertStore { roots: \"(138 roots)\" }" + ); +} diff --git a/http/vendor/rustls/src/webpki/client_verifier.rs b/http/vendor/rustls/src/webpki/client_verifier.rs new file mode 100644 index 0000000..060f0f7 --- /dev/null +++ b/http/vendor/rustls/src/webpki/client_verifier.rs @@ -0,0 +1,665 @@ +use alloc::vec::Vec; + +use pki_types::{CertificateDer, CertificateRevocationListDer, UnixTime}; +use webpki::{CertRevocationList, ExpirationPolicy, RevocationCheckDepth, UnknownStatusPolicy}; + +use super::{VerifierBuilderError, pki_error}; +#[cfg(doc)] +use crate::ConfigBuilder; +#[cfg(doc)] +use crate::crypto; +use crate::crypto::{CryptoProvider, WebPkiSupportedAlgorithms}; +#[cfg(doc)] +use crate::server::ServerConfig; +use crate::sync::Arc; +use crate::verify::{ + ClientCertVerified, ClientCertVerifier, DigitallySignedStruct, HandshakeSignatureValid, + NoClientAuth, +}; +use crate::webpki::parse_crls; +use crate::webpki::verify::{ParsedCertificate, verify_tls12_signature, verify_tls13_signature}; +use crate::{DistinguishedName, Error, RootCertStore, SignatureScheme}; + +/// A builder for configuring a `webpki` client certificate verifier. +/// +/// For more information, see the [`WebPkiClientVerifier`] documentation. +#[derive(Debug, Clone)] +pub struct ClientCertVerifierBuilder { + roots: Arc, + root_hint_subjects: Vec, + crls: Vec>, + revocation_check_depth: RevocationCheckDepth, + unknown_revocation_policy: UnknownStatusPolicy, + revocation_expiration_policy: ExpirationPolicy, + anon_policy: AnonymousClientPolicy, + supported_algs: WebPkiSupportedAlgorithms, +} + +impl ClientCertVerifierBuilder { + pub(crate) fn new( + roots: Arc, + supported_algs: WebPkiSupportedAlgorithms, + ) -> Self { + Self { + root_hint_subjects: roots.subjects(), + roots, + crls: Vec::new(), + anon_policy: AnonymousClientPolicy::Deny, + revocation_check_depth: RevocationCheckDepth::Chain, + unknown_revocation_policy: UnknownStatusPolicy::Deny, + revocation_expiration_policy: ExpirationPolicy::Ignore, + supported_algs, + } + } + + /// Clear the list of trust anchor hint subjects. + /// + /// By default, the client cert verifier will use the subjects provided by the root cert + /// store configured for client authentication. Calling this function will remove these + /// hint subjects, indicating the client should make a free choice of which certificate + /// to send. + /// + /// See [`ClientCertVerifier::root_hint_subjects`] for more information on + /// circumstances where you may want to clear the default hint subjects. + pub fn clear_root_hint_subjects(mut self) -> Self { + self.root_hint_subjects = Vec::default(); + self + } + + /// Add additional [`DistinguishedName`]s to the list of trust anchor hint subjects. + /// + /// By default, the client cert verifier will use the subjects provided by the root cert + /// store configured for client authentication. Calling this function will add to these + /// existing hint subjects. Calling this function with empty `subjects` will have no + /// effect. + /// + /// See [`ClientCertVerifier::root_hint_subjects`] for more information on + /// circumstances where you may want to override the default hint subjects. + pub fn add_root_hint_subjects( + mut self, + subjects: impl IntoIterator, + ) -> Self { + self.root_hint_subjects.extend(subjects); + self + } + + /// Verify the revocation state of presented client certificates against the provided + /// certificate revocation lists (CRLs). Calling `with_crls` multiple times appends the + /// given CRLs to the existing collection. + /// + /// By default all certificates in the verified chain built from the presented client + /// certificate to a trust anchor will have their revocation status checked. Calling + /// [`only_check_end_entity_revocation`][Self::only_check_end_entity_revocation] will + /// change this behavior to only check the end entity client certificate. + /// + /// By default if a certificate's revocation status can not be determined using the + /// configured CRLs, it will be treated as an error. Calling + /// [`allow_unknown_revocation_status`][Self::allow_unknown_revocation_status] will change + /// this behavior to allow unknown revocation status. + pub fn with_crls( + mut self, + crls: impl IntoIterator>, + ) -> Self { + self.crls.extend(crls); + self + } + + /// Only check the end entity certificate revocation status when using CRLs. + /// + /// If CRLs are provided using [`with_crls`][Self::with_crls] only check the end entity + /// certificate's revocation status. Overrides the default behavior of checking revocation + /// status for each certificate in the verified chain built to a trust anchor + /// (excluding the trust anchor itself). + /// + /// If no CRLs are provided then this setting has no effect. Neither the end entity certificate + /// or any intermediates will have revocation status checked. + pub fn only_check_end_entity_revocation(mut self) -> Self { + self.revocation_check_depth = RevocationCheckDepth::EndEntity; + self + } + + /// Allow unauthenticated clients to connect. + /// + /// Clients that offer a client certificate issued by a trusted root, and clients that offer no + /// client certificate will be allowed to connect. + pub fn allow_unauthenticated(mut self) -> Self { + self.anon_policy = AnonymousClientPolicy::Allow; + self + } + + /// Allow unknown certificate revocation status when using CRLs. + /// + /// If CRLs are provided with [`with_crls`][Self::with_crls] and it isn't possible to + /// determine the revocation status of a certificate, do not treat it as an error condition. + /// Overrides the default behavior where unknown revocation status is considered an error. + /// + /// If no CRLs are provided then this setting has no effect as revocation status checks + /// are not performed. + pub fn allow_unknown_revocation_status(mut self) -> Self { + self.unknown_revocation_policy = UnknownStatusPolicy::Allow; + self + } + + /// Enforce the CRL nextUpdate field (i.e. expiration) + /// + /// If CRLs are provided with [`with_crls`][Self::with_crls] and the verification time is + /// beyond the time in the CRL nextUpdate field, it is expired and treated as an error condition. + /// Overrides the default behavior where expired CRLs are not treated as an error condition. + /// + /// If no CRLs are provided then this setting has no effect as revocation status checks + /// are not performed. + pub fn enforce_revocation_expiration(mut self) -> Self { + self.revocation_expiration_policy = ExpirationPolicy::Enforce; + self + } + + /// Build a client certificate verifier. The built verifier will be used for the server to offer + /// client certificate authentication, to control how offered client certificates are validated, + /// and to determine what to do with anonymous clients that do not respond to the client + /// certificate authentication offer with a client certificate. + /// + /// If `with_signature_verification_algorithms` was not called on the builder, a default set of + /// signature verification algorithms is used, controlled by the selected [`CryptoProvider`]. + /// + /// Once built, the provided `Arc` can be used with a Rustls + /// [`ServerConfig`] to configure client certificate validation using + /// [`with_client_cert_verifier`][ConfigBuilder::with_client_cert_verifier]. + /// + /// # Errors + /// This function will return a [`VerifierBuilderError`] if: + /// 1. No trust anchors have been provided. + /// 2. DER encoded CRLs have been provided that can not be parsed successfully. + pub fn build(self) -> Result, VerifierBuilderError> { + if self.roots.is_empty() { + return Err(VerifierBuilderError::NoRootAnchors); + } + + Ok(Arc::new(WebPkiClientVerifier::new( + self.roots, + self.root_hint_subjects, + parse_crls(self.crls)?, + self.revocation_check_depth, + self.unknown_revocation_policy, + self.revocation_expiration_policy, + self.anon_policy, + self.supported_algs, + ))) + } +} + +/// A client certificate verifier that uses the `webpki` crate[^1] to perform client certificate +/// validation. +/// +/// It must be created via the [`WebPkiClientVerifier::builder()`] or +/// [`WebPkiClientVerifier::builder_with_provider()`] functions. +/// +/// Once built, the provided `Arc` can be used with a Rustls [`ServerConfig`] +/// to configure client certificate validation using [`with_client_cert_verifier`][ConfigBuilder::with_client_cert_verifier]. +/// +/// Example: +/// +/// To require all clients present a client certificate issued by a trusted CA: +/// ```no_run +/// # #[cfg(any(feature = "ring", feature = "aws_lc_rs"))] { +/// # use rustls::RootCertStore; +/// # use rustls::server::WebPkiClientVerifier; +/// # let roots = RootCertStore::empty(); +/// let client_verifier = WebPkiClientVerifier::builder(roots.into()) +/// .build() +/// .unwrap(); +/// # } +/// ``` +/// +/// Or, to allow clients presenting a client certificate authenticated by a trusted CA, or +/// anonymous clients that present no client certificate: +/// ```no_run +/// # #[cfg(any(feature = "ring", feature = "aws_lc_rs"))] { +/// # use rustls::RootCertStore; +/// # use rustls::server::WebPkiClientVerifier; +/// # let roots = RootCertStore::empty(); +/// let client_verifier = WebPkiClientVerifier::builder(roots.into()) +/// .allow_unauthenticated() +/// .build() +/// .unwrap(); +/// # } +/// ``` +/// +/// If you wish to disable advertising client authentication: +/// ```no_run +/// # use rustls::RootCertStore; +/// # use rustls::server::WebPkiClientVerifier; +/// # let roots = RootCertStore::empty(); +/// let client_verifier = WebPkiClientVerifier::no_client_auth(); +/// ``` +/// +/// You can also configure the client verifier to check for certificate revocation with +/// client certificate revocation lists (CRLs): +/// ```no_run +/// # #[cfg(any(feature = "ring", feature = "aws_lc_rs"))] { +/// # use rustls::RootCertStore; +/// # use rustls::server::{WebPkiClientVerifier}; +/// # let roots = RootCertStore::empty(); +/// # let crls = Vec::new(); +/// let client_verifier = WebPkiClientVerifier::builder(roots.into()) +/// .with_crls(crls) +/// .build() +/// .unwrap(); +/// # } +/// ``` +/// +/// [^1]: +#[derive(Debug)] +pub struct WebPkiClientVerifier { + roots: Arc, + root_hint_subjects: Vec, + crls: Vec>, + revocation_check_depth: RevocationCheckDepth, + unknown_revocation_policy: UnknownStatusPolicy, + revocation_expiration_policy: ExpirationPolicy, + anonymous_policy: AnonymousClientPolicy, + supported_algs: WebPkiSupportedAlgorithms, +} + +impl WebPkiClientVerifier { + /// Create a builder for the `webpki` client certificate verifier configuration using + /// the [process-default `CryptoProvider`][CryptoProvider#using-the-per-process-default-cryptoprovider]. + /// + /// Client certificate authentication will be offered by the server, and client certificates + /// will be verified using the trust anchors found in the provided `roots`. If you + /// wish to disable client authentication use [`WebPkiClientVerifier::no_client_auth()`] instead. + /// + /// Use [`Self::builder_with_provider`] if you wish to specify an explicit provider. + /// + /// For more information, see the [`ClientCertVerifierBuilder`] documentation. + pub fn builder(roots: Arc) -> ClientCertVerifierBuilder { + Self::builder_with_provider( + roots, + CryptoProvider::get_default_or_install_from_crate_features().clone(), + ) + } + + /// Create a builder for the `webpki` client certificate verifier configuration using + /// a specified [`CryptoProvider`]. + /// + /// Client certificate authentication will be offered by the server, and client certificates + /// will be verified using the trust anchors found in the provided `roots`. If you + /// wish to disable client authentication use [WebPkiClientVerifier::no_client_auth()] instead. + /// + /// The cryptography used comes from the specified [`CryptoProvider`]. + /// + /// For more information, see the [`ClientCertVerifierBuilder`] documentation. + pub fn builder_with_provider( + roots: Arc, + provider: Arc, + ) -> ClientCertVerifierBuilder { + ClientCertVerifierBuilder::new(roots, provider.signature_verification_algorithms) + } + + /// Create a new `WebPkiClientVerifier` that disables client authentication. The server will + /// not offer client authentication and anonymous clients will be accepted. + /// + /// This is in contrast to using `WebPkiClientVerifier::builder().allow_unauthenticated().build()`, + /// which will produce a verifier that will offer client authentication, but not require it. + pub fn no_client_auth() -> Arc { + Arc::new(NoClientAuth {}) + } + + /// Construct a new `WebpkiClientVerifier`. + /// + /// * `roots` is a list of trust anchors to use for certificate validation. + /// * `root_hint_subjects` is a list of distinguished names to use for hinting acceptable + /// certificate authority subjects to a client. + /// * `crls` is a `Vec` of owned certificate revocation lists (CRLs) to use for + /// client certificate validation. + /// * `revocation_check_depth` controls which certificates have their revocation status checked + /// when `crls` are provided. + /// * `unknown_revocation_policy` controls how certificates with an unknown revocation status + /// are handled when `crls` are provided. + /// * `anonymous_policy` controls whether client authentication is required, or if anonymous + /// clients can connect. + /// * `supported_algs` specifies which signature verification algorithms should be used. + pub(crate) fn new( + roots: Arc, + root_hint_subjects: Vec, + crls: Vec>, + revocation_check_depth: RevocationCheckDepth, + unknown_revocation_policy: UnknownStatusPolicy, + revocation_expiration_policy: ExpirationPolicy, + anonymous_policy: AnonymousClientPolicy, + supported_algs: WebPkiSupportedAlgorithms, + ) -> Self { + Self { + roots, + root_hint_subjects, + crls, + revocation_check_depth, + unknown_revocation_policy, + revocation_expiration_policy, + anonymous_policy, + supported_algs, + } + } +} + +impl ClientCertVerifier for WebPkiClientVerifier { + fn offer_client_auth(&self) -> bool { + true + } + + fn client_auth_mandatory(&self) -> bool { + match self.anonymous_policy { + AnonymousClientPolicy::Allow => false, + AnonymousClientPolicy::Deny => true, + } + } + + fn root_hint_subjects(&self) -> &[DistinguishedName] { + &self.root_hint_subjects + } + + fn verify_client_cert( + &self, + end_entity: &CertificateDer<'_>, + intermediates: &[CertificateDer<'_>], + now: UnixTime, + ) -> Result { + let cert = ParsedCertificate::try_from(end_entity)?; + + let crl_refs = self.crls.iter().collect::>(); + + let revocation = if self.crls.is_empty() { + None + } else { + Some( + webpki::RevocationOptionsBuilder::new(&crl_refs) + // Note: safe to unwrap here - new is only fallible if no CRLs are provided + // and we verify this above. + .unwrap() + .with_depth(self.revocation_check_depth) + .with_status_policy(self.unknown_revocation_policy) + .with_expiration_policy(self.revocation_expiration_policy) + .build(), + ) + }; + + cert.0 + .verify_for_usage( + self.supported_algs.all, + &self.roots.roots, + intermediates, + now, + webpki::KeyUsage::client_auth(), + revocation, + None, + ) + .map_err(pki_error) + .map(|_| ClientCertVerified::assertion()) + } + + fn verify_tls12_signature( + &self, + message: &[u8], + cert: &CertificateDer<'_>, + dss: &DigitallySignedStruct, + ) -> Result { + verify_tls12_signature(message, cert, dss, &self.supported_algs) + } + + fn verify_tls13_signature( + &self, + message: &[u8], + cert: &CertificateDer<'_>, + dss: &DigitallySignedStruct, + ) -> Result { + verify_tls13_signature(message, cert, dss, &self.supported_algs) + } + + fn supported_verify_schemes(&self) -> Vec { + self.supported_algs.supported_schemes() + } +} + +/// Controls how the [WebPkiClientVerifier] handles anonymous clients. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub(crate) enum AnonymousClientPolicy { + /// Clients that do not present a client certificate are allowed. + Allow, + /// Clients that do not present a client certificate are denied. + Deny, +} + +#[cfg(test)] +#[macro_rules_attribute::apply(test_for_each_provider)] +mod tests { + use std::prelude::v1::*; + use std::{format, println, vec}; + + use pki_types::pem::PemObject; + use pki_types::{CertificateDer, CertificateRevocationListDer}; + + use super::{WebPkiClientVerifier, provider}; + use crate::RootCertStore; + use crate::server::VerifierBuilderError; + use crate::sync::Arc; + + fn load_crls(crls_der: &[&[u8]]) -> Vec> { + crls_der + .iter() + .map(|pem_bytes| CertificateRevocationListDer::from_pem_slice(pem_bytes).unwrap()) + .collect() + } + + fn test_crls() -> Vec> { + load_crls(&[ + include_bytes!("../../../test-ca/ecdsa-p256/client.revoked.crl.pem").as_slice(), + include_bytes!("../../../test-ca/rsa-2048/client.revoked.crl.pem").as_slice(), + ]) + } + + fn load_roots(roots_der: &[&[u8]]) -> Arc { + let mut roots = RootCertStore::empty(); + roots_der.iter().for_each(|der| { + roots + .add(CertificateDer::from(der.to_vec())) + .unwrap() + }); + roots.into() + } + + fn test_roots() -> Arc { + load_roots(&[ + include_bytes!("../../../test-ca/ecdsa-p256/ca.der").as_slice(), + include_bytes!("../../../test-ca/rsa-2048/ca.der").as_slice(), + ]) + } + + #[test] + fn test_client_verifier_no_auth() { + // We should be able to build a verifier that turns off client authentication. + WebPkiClientVerifier::no_client_auth(); + } + + #[test] + fn test_client_verifier_required_auth() { + // We should be able to build a verifier that requires client authentication, and does + // no revocation checking. + let builder = WebPkiClientVerifier::builder_with_provider( + test_roots(), + provider::default_provider().into(), + ); + // The builder should be Debug. + println!("{builder:?}"); + builder.build().unwrap(); + } + + #[test] + fn test_client_verifier_optional_auth() { + // We should be able to build a verifier that allows client authentication, and anonymous + // access, and does no revocation checking. + let builder = WebPkiClientVerifier::builder_with_provider( + test_roots(), + provider::default_provider().into(), + ) + .allow_unauthenticated(); + // The builder should be Debug. + println!("{builder:?}"); + builder.build().unwrap(); + } + + #[test] + fn test_client_verifier_without_crls_required_auth() { + // We should be able to build a verifier that requires client authentication, and does + // no revocation checking, that hasn't been configured to determine how to handle + // unauthenticated clients yet. + let builder = WebPkiClientVerifier::builder_with_provider( + test_roots(), + provider::default_provider().into(), + ); + // The builder should be Debug. + println!("{builder:?}"); + builder.build().unwrap(); + } + + #[test] + fn test_client_verifier_without_crls_opptional_auth() { + // We should be able to build a verifier that allows client authentication, + // and anonymous access, that does no revocation checking. + let builder = WebPkiClientVerifier::builder_with_provider( + test_roots(), + provider::default_provider().into(), + ) + .allow_unauthenticated(); + // The builder should be Debug. + println!("{builder:?}"); + builder.build().unwrap(); + } + + #[test] + fn test_with_invalid_crls() { + // Trying to build a client verifier with invalid CRLs should error at build time. + let result = WebPkiClientVerifier::builder_with_provider( + test_roots(), + provider::default_provider().into(), + ) + .with_crls(vec![CertificateRevocationListDer::from(vec![0xFF])]) + .build(); + assert!(matches!(result, Err(VerifierBuilderError::InvalidCrl(_)))); + } + + #[test] + fn test_with_crls_multiple_calls() { + // We should be able to call `with_crls` on a client verifier multiple times. + let initial_crls = test_crls(); + let extra_crls = + load_crls(&[ + include_bytes!("../../../test-ca/eddsa/client.revoked.crl.pem").as_slice(), + ]); + let builder = WebPkiClientVerifier::builder_with_provider( + test_roots(), + provider::default_provider().into(), + ) + .with_crls(initial_crls.clone()) + .with_crls(extra_crls.clone()); + + // There should be the expected number of crls. + assert_eq!(builder.crls.len(), initial_crls.len() + extra_crls.len()); + // The builder should be Debug. + println!("{builder:?}"); + builder.build().unwrap(); + } + + #[test] + fn test_client_verifier_with_crls_required_auth_implicit() { + // We should be able to build a verifier that requires client authentication, and that does + // revocation checking with CRLs, and that does not allow any anonymous access. + let builder = WebPkiClientVerifier::builder_with_provider( + test_roots(), + provider::default_provider().into(), + ) + .with_crls(test_crls()); + // The builder should be Debug. + println!("{builder:?}"); + builder.build().unwrap(); + } + + #[test] + fn test_client_verifier_with_crls_optional_auth() { + // We should be able to build a verifier that supports client authentication, that does + // revocation checking with CRLs, and that allows anonymous access. + let builder = WebPkiClientVerifier::builder_with_provider( + test_roots(), + provider::default_provider().into(), + ) + .with_crls(test_crls()) + .allow_unauthenticated(); + // The builder should be Debug. + println!("{builder:?}"); + builder.build().unwrap(); + } + + #[test] + fn test_client_verifier_ee_only() { + // We should be able to build a client verifier that only checks EE revocation status. + let builder = WebPkiClientVerifier::builder_with_provider( + test_roots(), + provider::default_provider().into(), + ) + .with_crls(test_crls()) + .only_check_end_entity_revocation(); + // The builder should be Debug. + println!("{builder:?}"); + builder.build().unwrap(); + } + + #[test] + fn test_client_verifier_allow_unknown() { + // We should be able to build a client verifier that allows unknown revocation status + let builder = WebPkiClientVerifier::builder_with_provider( + test_roots(), + provider::default_provider().into(), + ) + .with_crls(test_crls()) + .allow_unknown_revocation_status(); + // The builder should be Debug. + println!("{builder:?}"); + builder.build().unwrap(); + } + + #[test] + fn test_client_verifier_enforce_expiration() { + // We should be able to build a client verifier that allows unknown revocation status + let builder = WebPkiClientVerifier::builder_with_provider( + test_roots(), + provider::default_provider().into(), + ) + .with_crls(test_crls()) + .enforce_revocation_expiration(); + // The builder should be Debug. + println!("{builder:?}"); + builder.build().unwrap(); + } + + #[test] + fn test_builder_no_roots() { + // Trying to create a client verifier builder with no trust anchors should fail at build time + let result = WebPkiClientVerifier::builder_with_provider( + RootCertStore::empty().into(), + provider::default_provider().into(), + ) + .build(); + assert!(matches!(result, Err(VerifierBuilderError::NoRootAnchors))); + } + + #[test] + fn smoke() { + let all = vec![ + VerifierBuilderError::NoRootAnchors, + VerifierBuilderError::InvalidCrl(crate::CertRevocationListError::ParseError), + ]; + + for err in all { + let _ = format!("{err:?}"); + let _ = format!("{err}"); + } + } +} diff --git a/http/vendor/rustls/src/webpki/mod.rs b/http/vendor/rustls/src/webpki/mod.rs new file mode 100644 index 0000000..ead32d0 --- /dev/null +++ b/http/vendor/rustls/src/webpki/mod.rs @@ -0,0 +1,314 @@ +use alloc::vec::Vec; +use core::fmt; + +use pki_types::CertificateRevocationListDer; +use webpki::{CertRevocationList, InvalidNameContext, OwnedCertRevocationList}; + +use crate::error::{ + CertRevocationListError, CertificateError, Error, ExtendedKeyPurpose, OtherError, +}; +#[cfg(feature = "std")] +use crate::sync::Arc; + +mod anchors; +mod client_verifier; +mod server_verifier; +mod verify; + +pub use anchors::RootCertStore; +pub use client_verifier::{ClientCertVerifierBuilder, WebPkiClientVerifier}; +pub use server_verifier::{ServerCertVerifierBuilder, WebPkiServerVerifier}; +// Conditionally exported from crate. +#[allow(unreachable_pub)] +pub use verify::{ + ParsedCertificate, verify_server_cert_signed_by_trust_anchor, verify_server_name, +}; +pub use verify::{ + WebPkiSupportedAlgorithms, verify_tls12_signature, verify_tls13_signature, + verify_tls13_signature_with_raw_key, +}; + +/// An error that can occur when building a certificate verifier. +#[derive(Debug, Clone)] +#[non_exhaustive] +pub enum VerifierBuilderError { + /// No root trust anchors were provided. + NoRootAnchors, + /// A provided CRL could not be parsed. + InvalidCrl(CertRevocationListError), +} + +impl From for VerifierBuilderError { + fn from(value: CertRevocationListError) -> Self { + Self::InvalidCrl(value) + } +} + +impl fmt::Display for VerifierBuilderError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::NoRootAnchors => write!(f, "no root trust anchors were provided"), + Self::InvalidCrl(e) => write!(f, "provided CRL could not be parsed: {e:?}"), + } + } +} + +#[cfg(feature = "std")] +impl std::error::Error for VerifierBuilderError {} + +fn pki_error(error: webpki::Error) -> Error { + use webpki::Error::*; + match error { + BadDer | BadDerTime | TrailingData(_) => CertificateError::BadEncoding.into(), + CertNotValidYet { time, not_before } => { + CertificateError::NotValidYetContext { time, not_before }.into() + } + CertExpired { time, not_after } => { + CertificateError::ExpiredContext { time, not_after }.into() + } + InvalidCertValidity => CertificateError::Expired.into(), + UnknownIssuer => CertificateError::UnknownIssuer.into(), + CertNotValidForName(InvalidNameContext { + expected, + presented, + }) => CertificateError::NotValidForNameContext { + expected, + presented, + } + .into(), + CertRevoked => CertificateError::Revoked.into(), + UnknownRevocationStatus => CertificateError::UnknownRevocationStatus.into(), + CrlExpired { time, next_update } => { + CertificateError::ExpiredRevocationListContext { time, next_update }.into() + } + IssuerNotCrlSigner => CertRevocationListError::IssuerInvalidForCrl.into(), + + InvalidSignatureForPublicKey => CertificateError::BadSignature.into(), + #[allow(deprecated)] + UnsupportedSignatureAlgorithm | UnsupportedSignatureAlgorithmForPublicKey => { + CertificateError::UnsupportedSignatureAlgorithm.into() + } + UnsupportedSignatureAlgorithmContext(cx) => { + CertificateError::UnsupportedSignatureAlgorithmContext { + signature_algorithm_id: cx.signature_algorithm_id, + supported_algorithms: cx.supported_algorithms, + } + .into() + } + UnsupportedSignatureAlgorithmForPublicKeyContext(cx) => { + CertificateError::UnsupportedSignatureAlgorithmForPublicKeyContext { + signature_algorithm_id: cx.signature_algorithm_id, + public_key_algorithm_id: cx.public_key_algorithm_id, + } + .into() + } + + InvalidCrlSignatureForPublicKey => CertRevocationListError::BadSignature.into(), + #[allow(deprecated)] + UnsupportedCrlSignatureAlgorithm | UnsupportedCrlSignatureAlgorithmForPublicKey => { + CertRevocationListError::UnsupportedSignatureAlgorithm.into() + } + UnsupportedCrlSignatureAlgorithmContext(cx) => { + CertRevocationListError::UnsupportedSignatureAlgorithmContext { + signature_algorithm_id: cx.signature_algorithm_id, + supported_algorithms: cx.supported_algorithms, + } + .into() + } + UnsupportedCrlSignatureAlgorithmForPublicKeyContext(cx) => { + CertRevocationListError::UnsupportedSignatureAlgorithmForPublicKeyContext { + signature_algorithm_id: cx.signature_algorithm_id, + public_key_algorithm_id: cx.public_key_algorithm_id, + } + .into() + } + + #[allow(deprecated)] + RequiredEkuNotFound => CertificateError::InvalidPurpose.into(), + RequiredEkuNotFoundContext(webpki::RequiredEkuNotFoundContext { required, present }) => { + CertificateError::InvalidPurposeContext { + required: ExtendedKeyPurpose::for_values(required.oid_values()), + presented: present + .into_iter() + .map(|eku| ExtendedKeyPurpose::for_values(eku.into_iter())) + .collect(), + } + .into() + } + + _ => CertificateError::Other(OtherError( + #[cfg(feature = "std")] + Arc::new(error), + )) + .into(), + } +} + +fn crl_error(e: webpki::Error) -> CertRevocationListError { + use webpki::Error::*; + match e { + InvalidCrlSignatureForPublicKey => CertRevocationListError::BadSignature, + #[allow(deprecated)] + UnsupportedCrlSignatureAlgorithm | UnsupportedCrlSignatureAlgorithmForPublicKey => { + CertRevocationListError::UnsupportedSignatureAlgorithm + } + UnsupportedCrlSignatureAlgorithmContext(cx) => { + CertRevocationListError::UnsupportedSignatureAlgorithmContext { + signature_algorithm_id: cx.signature_algorithm_id, + supported_algorithms: cx.supported_algorithms, + } + } + UnsupportedSignatureAlgorithmForPublicKeyContext(cx) => { + CertRevocationListError::UnsupportedSignatureAlgorithmForPublicKeyContext { + signature_algorithm_id: cx.signature_algorithm_id, + public_key_algorithm_id: cx.public_key_algorithm_id, + } + } + InvalidCrlNumber => CertRevocationListError::InvalidCrlNumber, + InvalidSerialNumber => CertRevocationListError::InvalidRevokedCertSerialNumber, + IssuerNotCrlSigner => CertRevocationListError::IssuerInvalidForCrl, + MalformedExtensions | BadDer | BadDerTime => CertRevocationListError::ParseError, + UnsupportedCriticalExtension => CertRevocationListError::UnsupportedCriticalExtension, + UnsupportedCrlVersion => CertRevocationListError::UnsupportedCrlVersion, + UnsupportedDeltaCrl => CertRevocationListError::UnsupportedDeltaCrl, + UnsupportedIndirectCrl => CertRevocationListError::UnsupportedIndirectCrl, + UnsupportedRevocationReason => CertRevocationListError::UnsupportedRevocationReason, + + _ => CertRevocationListError::Other(OtherError( + #[cfg(feature = "std")] + Arc::new(e), + )), + } +} + +fn parse_crls( + crls: Vec>, +) -> Result>, CertRevocationListError> { + crls.iter() + .map(|der| OwnedCertRevocationList::from_der(der.as_ref()).map(Into::into)) + .collect::, _>>() + .map_err(crl_error) +} + +#[cfg(test)] +mod tests { + use alloc::vec; + + use super::*; + + #[test] + fn pki_crl_errors() { + // CRL signature errors should be turned into BadSignature. + assert_eq!( + pki_error(webpki::Error::InvalidCrlSignatureForPublicKey), + Error::InvalidCertRevocationList(CertRevocationListError::BadSignature), + ); + + #[allow(deprecated)] + { + assert_eq!( + pki_error(webpki::Error::UnsupportedCrlSignatureAlgorithm), + Error::InvalidCertRevocationList( + CertRevocationListError::UnsupportedSignatureAlgorithm + ), + ); + assert_eq!( + pki_error(webpki::Error::UnsupportedCrlSignatureAlgorithmForPublicKey), + Error::InvalidCertRevocationList( + CertRevocationListError::UnsupportedSignatureAlgorithm + ), + ); + } + + assert_eq!( + pki_error(webpki::Error::UnsupportedCrlSignatureAlgorithmContext( + webpki::UnsupportedSignatureAlgorithmContext { + signature_algorithm_id: vec![], + supported_algorithms: vec![], + } + )), + Error::InvalidCertRevocationList( + CertRevocationListError::UnsupportedSignatureAlgorithmContext { + signature_algorithm_id: vec![], + supported_algorithms: vec![], + } + ) + ); + assert_eq!( + pki_error( + webpki::Error::UnsupportedCrlSignatureAlgorithmForPublicKeyContext( + webpki::UnsupportedSignatureAlgorithmForPublicKeyContext { + signature_algorithm_id: vec![], + public_key_algorithm_id: vec![], + } + ) + ), + Error::InvalidCertRevocationList( + CertRevocationListError::UnsupportedSignatureAlgorithmForPublicKeyContext { + signature_algorithm_id: vec![], + public_key_algorithm_id: vec![], + } + ) + ); + + // Revoked cert errors should be turned into Revoked. + assert_eq!( + pki_error(webpki::Error::CertRevoked), + Error::InvalidCertificate(CertificateError::Revoked), + ); + + // Issuer not CRL signer errors should be turned into IssuerInvalidForCrl + assert_eq!( + pki_error(webpki::Error::IssuerNotCrlSigner), + Error::InvalidCertRevocationList(CertRevocationListError::IssuerInvalidForCrl) + ); + } + + #[test] + fn crl_error_from_webpki() { + use CertRevocationListError::*; + #[allow(deprecated)] + let testcases = &[ + (webpki::Error::InvalidCrlSignatureForPublicKey, BadSignature), + ( + webpki::Error::UnsupportedCrlSignatureAlgorithm, + UnsupportedSignatureAlgorithm, + ), + ( + webpki::Error::UnsupportedCrlSignatureAlgorithmForPublicKey, + UnsupportedSignatureAlgorithm, + ), + (webpki::Error::InvalidCrlNumber, InvalidCrlNumber), + ( + webpki::Error::InvalidSerialNumber, + InvalidRevokedCertSerialNumber, + ), + (webpki::Error::IssuerNotCrlSigner, IssuerInvalidForCrl), + (webpki::Error::MalformedExtensions, ParseError), + (webpki::Error::BadDer, ParseError), + (webpki::Error::BadDerTime, ParseError), + ( + webpki::Error::UnsupportedCriticalExtension, + UnsupportedCriticalExtension, + ), + (webpki::Error::UnsupportedCrlVersion, UnsupportedCrlVersion), + (webpki::Error::UnsupportedDeltaCrl, UnsupportedDeltaCrl), + ( + webpki::Error::UnsupportedIndirectCrl, + UnsupportedIndirectCrl, + ), + ( + webpki::Error::UnsupportedRevocationReason, + UnsupportedRevocationReason, + ), + ]; + for t in testcases { + assert_eq!(crl_error(t.0.clone()), t.1); + } + + assert!(matches!( + crl_error(webpki::Error::NameConstraintViolation), + Other(..) + )); + } +} diff --git a/http/vendor/rustls/src/webpki/server_verifier.rs b/http/vendor/rustls/src/webpki/server_verifier.rs new file mode 100644 index 0000000..5aa9235 --- /dev/null +++ b/http/vendor/rustls/src/webpki/server_verifier.rs @@ -0,0 +1,448 @@ +use alloc::vec::Vec; + +use pki_types::{CertificateDer, CertificateRevocationListDer, ServerName, UnixTime}; +use webpki::{CertRevocationList, ExpirationPolicy, RevocationCheckDepth, UnknownStatusPolicy}; + +use crate::crypto::{CryptoProvider, WebPkiSupportedAlgorithms}; +use crate::log::trace; +use crate::sync::Arc; +use crate::verify::{ + DigitallySignedStruct, HandshakeSignatureValid, ServerCertVerified, ServerCertVerifier, +}; +use crate::webpki::verify::{ + ParsedCertificate, verify_server_cert_signed_by_trust_anchor_impl, verify_tls12_signature, + verify_tls13_signature, +}; +use crate::webpki::{VerifierBuilderError, parse_crls, verify_server_name}; +#[cfg(doc)] +use crate::{ConfigBuilder, ServerConfig, crypto}; +use crate::{Error, RootCertStore, SignatureScheme}; + +/// A builder for configuring a `webpki` server certificate verifier. +/// +/// For more information, see the [`WebPkiServerVerifier`] documentation. +#[derive(Debug, Clone)] +pub struct ServerCertVerifierBuilder { + roots: Arc, + crls: Vec>, + revocation_check_depth: RevocationCheckDepth, + unknown_revocation_policy: UnknownStatusPolicy, + revocation_expiration_policy: ExpirationPolicy, + supported_algs: WebPkiSupportedAlgorithms, +} + +impl ServerCertVerifierBuilder { + pub(crate) fn new( + roots: Arc, + supported_algs: WebPkiSupportedAlgorithms, + ) -> Self { + Self { + roots, + crls: Vec::new(), + revocation_check_depth: RevocationCheckDepth::Chain, + unknown_revocation_policy: UnknownStatusPolicy::Deny, + revocation_expiration_policy: ExpirationPolicy::Ignore, + supported_algs, + } + } + + /// Verify the revocation state of presented client certificates against the provided + /// certificate revocation lists (CRLs). Calling `with_crls` multiple times appends the + /// given CRLs to the existing collection. + pub fn with_crls( + mut self, + crls: impl IntoIterator>, + ) -> Self { + self.crls.extend(crls); + self + } + + /// Only check the end entity certificate revocation status when using CRLs. + /// + /// If CRLs are provided using [`with_crls`][Self::with_crls] only check the end entity + /// certificate's revocation status. Overrides the default behavior of checking revocation + /// status for each certificate in the verified chain built to a trust anchor + /// (excluding the trust anchor itself). + /// + /// If no CRLs are provided then this setting has no effect. Neither the end entity certificate + /// or any intermediates will have revocation status checked. + pub fn only_check_end_entity_revocation(mut self) -> Self { + self.revocation_check_depth = RevocationCheckDepth::EndEntity; + self + } + + /// Allow unknown certificate revocation status when using CRLs. + /// + /// If CRLs are provided with [`with_crls`][Self::with_crls] and it isn't possible to + /// determine the revocation status of a certificate, do not treat it as an error condition. + /// Overrides the default behavior where unknown revocation status is considered an error. + /// + /// If no CRLs are provided then this setting has no effect as revocation status checks + /// are not performed. + pub fn allow_unknown_revocation_status(mut self) -> Self { + self.unknown_revocation_policy = UnknownStatusPolicy::Allow; + self + } + + /// Enforce the CRL nextUpdate field (i.e. expiration) + /// + /// If CRLs are provided with [`with_crls`][Self::with_crls] and the verification time is + /// beyond the time in the CRL nextUpdate field, it is expired and treated as an error condition. + /// Overrides the default behavior where expired CRLs are not treated as an error condition. + /// + /// If no CRLs are provided then this setting has no effect as revocation status checks + /// are not performed. + pub fn enforce_revocation_expiration(mut self) -> Self { + self.revocation_expiration_policy = ExpirationPolicy::Enforce; + self + } + + /// Build a server certificate verifier, allowing control over the root certificates to use as + /// trust anchors, and to control how server certificate revocation checking is performed. + /// + /// If `with_signature_verification_algorithms` was not called on the builder, a default set of + /// signature verification algorithms is used, controlled by the selected [`crypto::CryptoProvider`]. + /// + /// Once built, the provided `Arc` can be used with a Rustls + /// [`ServerConfig`] to configure client certificate validation using + /// [`with_client_cert_verifier`][ConfigBuilder::with_client_cert_verifier]. + /// + /// # Errors + /// This function will return a [`VerifierBuilderError`] if: + /// 1. No trust anchors have been provided. + /// 2. DER encoded CRLs have been provided that can not be parsed successfully. + pub fn build(self) -> Result, VerifierBuilderError> { + if self.roots.is_empty() { + return Err(VerifierBuilderError::NoRootAnchors); + } + + Ok(WebPkiServerVerifier::new( + self.roots, + parse_crls(self.crls)?, + self.revocation_check_depth, + self.unknown_revocation_policy, + self.revocation_expiration_policy, + self.supported_algs, + ) + .into()) + } +} + +/// Default `ServerCertVerifier`, see the trait impl for more information. +#[allow(unreachable_pub)] +#[derive(Debug)] +pub struct WebPkiServerVerifier { + roots: Arc, + crls: Vec>, + revocation_check_depth: RevocationCheckDepth, + unknown_revocation_policy: UnknownStatusPolicy, + revocation_expiration_policy: ExpirationPolicy, + supported: WebPkiSupportedAlgorithms, +} + +#[allow(unreachable_pub)] +impl WebPkiServerVerifier { + /// Create a builder for the `webpki` server certificate verifier configuration using + /// the [process-default `CryptoProvider`][CryptoProvider#using-the-per-process-default-cryptoprovider]. + /// + /// Server certificates will be verified using the trust anchors found in the provided `roots`. + /// + /// Use [`Self::builder_with_provider`] if you wish to specify an explicit provider. + /// + /// For more information, see the [`ServerCertVerifierBuilder`] documentation. + pub fn builder(roots: Arc) -> ServerCertVerifierBuilder { + Self::builder_with_provider( + roots, + CryptoProvider::get_default_or_install_from_crate_features().clone(), + ) + } + + /// Create a builder for the `webpki` server certificate verifier configuration using + /// a specified [`CryptoProvider`]. + /// + /// Server certificates will be verified using the trust anchors found in the provided `roots`. + /// + /// The cryptography used comes from the specified [`CryptoProvider`]. + /// + /// For more information, see the [`ServerCertVerifierBuilder`] documentation. + pub fn builder_with_provider( + roots: Arc, + provider: Arc, + ) -> ServerCertVerifierBuilder { + ServerCertVerifierBuilder::new(roots, provider.signature_verification_algorithms) + } + + /// Short-cut for creating a `WebPkiServerVerifier` that does not perform certificate revocation + /// checking, avoiding the need to use a builder. + pub(crate) fn new_without_revocation( + roots: impl Into>, + supported_algs: WebPkiSupportedAlgorithms, + ) -> Self { + Self::new( + roots, + Vec::default(), + RevocationCheckDepth::Chain, + UnknownStatusPolicy::Allow, + ExpirationPolicy::Ignore, + supported_algs, + ) + } + + /// Constructs a new `WebPkiServerVerifier`. + /// + /// * `roots` is the set of trust anchors to trust for issuing server certs. + /// * `crls` are a vec of owned certificate revocation lists (CRLs) to use for + /// client certificate validation. + /// * `revocation_check_depth` controls which certificates have their revocation status checked + /// when `crls` are provided. + /// * `unknown_revocation_policy` controls how certificates with an unknown revocation status + /// are handled when `crls` are provided. + /// * `supported` is the set of supported algorithms that will be used for + /// certificate verification and TLS handshake signature verification. + pub(crate) fn new( + roots: impl Into>, + crls: Vec>, + revocation_check_depth: RevocationCheckDepth, + unknown_revocation_policy: UnknownStatusPolicy, + revocation_expiration_policy: ExpirationPolicy, + supported: WebPkiSupportedAlgorithms, + ) -> Self { + Self { + roots: roots.into(), + crls, + revocation_check_depth, + unknown_revocation_policy, + revocation_expiration_policy, + supported, + } + } +} + +impl ServerCertVerifier for WebPkiServerVerifier { + /// Will verify the certificate is valid in the following ways: + /// - Signed by a trusted `RootCertStore` CA + /// - Not Expired + /// - Valid for DNS entry + /// - Valid revocation status (if applicable). + /// + /// Depending on the verifier's configuration revocation status checking may be performed for + /// each certificate in the chain to a root CA (excluding the root itself), or only the + /// end entity certificate. Similarly, unknown revocation status may be treated as an error + /// or allowed based on configuration. + fn verify_server_cert( + &self, + end_entity: &CertificateDer<'_>, + intermediates: &[CertificateDer<'_>], + server_name: &ServerName<'_>, + ocsp_response: &[u8], + now: UnixTime, + ) -> Result { + let cert = ParsedCertificate::try_from(end_entity)?; + + let crl_refs = self.crls.iter().collect::>(); + + let revocation = if self.crls.is_empty() { + None + } else { + // Note: unwrap here is safe because RevocationOptionsBuilder only errors when given + // empty CRLs. + Some( + webpki::RevocationOptionsBuilder::new(crl_refs.as_slice()) + // Note: safe to unwrap here - new is only fallible if no CRLs are provided + // and we verify this above. + .unwrap() + .with_depth(self.revocation_check_depth) + .with_status_policy(self.unknown_revocation_policy) + .with_expiration_policy(self.revocation_expiration_policy) + .build(), + ) + }; + + // Note: we use the crate-internal `_impl` fn here in order to provide revocation + // checking information, if applicable. + verify_server_cert_signed_by_trust_anchor_impl( + &cert, + &self.roots, + intermediates, + revocation, + now, + self.supported.all, + )?; + + if !ocsp_response.is_empty() { + trace!("Unvalidated OCSP response: {:?}", ocsp_response.to_vec()); + } + + verify_server_name(&cert, server_name)?; + Ok(ServerCertVerified::assertion()) + } + + fn verify_tls12_signature( + &self, + message: &[u8], + cert: &CertificateDer<'_>, + dss: &DigitallySignedStruct, + ) -> Result { + verify_tls12_signature(message, cert, dss, &self.supported) + } + + fn verify_tls13_signature( + &self, + message: &[u8], + cert: &CertificateDer<'_>, + dss: &DigitallySignedStruct, + ) -> Result { + verify_tls13_signature(message, cert, dss, &self.supported) + } + + fn supported_verify_schemes(&self) -> Vec { + self.supported.supported_schemes() + } +} + +#[cfg(test)] +#[macro_rules_attribute::apply(test_for_each_provider)] +mod tests { + use std::prelude::v1::*; + use std::{println, vec}; + + use pki_types::pem::PemObject; + use pki_types::{CertificateDer, CertificateRevocationListDer}; + + use super::{VerifierBuilderError, WebPkiServerVerifier, provider}; + use crate::RootCertStore; + use crate::sync::Arc; + + fn load_crls(crls_der: &[&[u8]]) -> Vec> { + crls_der + .iter() + .map(|pem_bytes| CertificateRevocationListDer::from_pem_slice(pem_bytes).unwrap()) + .collect() + } + + fn test_crls() -> Vec> { + load_crls(&[ + include_bytes!("../../../test-ca/ecdsa-p256/client.revoked.crl.pem").as_slice(), + include_bytes!("../../../test-ca/rsa-2048/client.revoked.crl.pem").as_slice(), + ]) + } + + fn load_roots(roots_der: &[&[u8]]) -> Arc { + let mut roots = RootCertStore::empty(); + roots_der.iter().for_each(|der| { + roots + .add(CertificateDer::from(der.to_vec())) + .unwrap() + }); + roots.into() + } + + fn test_roots() -> Arc { + load_roots(&[ + include_bytes!("../../../test-ca/ecdsa-p256/ca.der").as_slice(), + include_bytes!("../../../test-ca/rsa-2048/ca.der").as_slice(), + ]) + } + + #[test] + fn test_with_invalid_crls() { + // Trying to build a server verifier with invalid CRLs should error at build time. + let result = WebPkiServerVerifier::builder_with_provider( + test_roots(), + provider::default_provider().into(), + ) + .with_crls(vec![CertificateRevocationListDer::from(vec![0xFF])]) + .build(); + assert!(matches!(result, Err(VerifierBuilderError::InvalidCrl(_)))); + } + + #[test] + fn test_with_crls_multiple_calls() { + // We should be able to call `with_crls` on a server verifier multiple times. + let initial_crls = test_crls(); + let extra_crls = + load_crls(&[ + include_bytes!("../../../test-ca/eddsa/client.revoked.crl.pem").as_slice(), + ]); + + let builder = WebPkiServerVerifier::builder_with_provider( + test_roots(), + provider::default_provider().into(), + ) + .with_crls(initial_crls.clone()) + .with_crls(extra_crls.clone()); + + // There should be the expected number of crls. + assert_eq!(builder.crls.len(), initial_crls.len() + extra_crls.len()); + // The builder should be Debug. + println!("{builder:?}"); + builder.build().unwrap(); + } + + #[test] + fn test_builder_no_roots() { + // Trying to create a server verifier builder with no trust anchors should fail at build time + let result = WebPkiServerVerifier::builder_with_provider( + RootCertStore::empty().into(), + provider::default_provider().into(), + ) + .build(); + assert!(matches!(result, Err(VerifierBuilderError::NoRootAnchors))); + } + + #[test] + fn test_server_verifier_ee_only() { + // We should be able to build a server cert. verifier that only checks the EE cert. + let builder = WebPkiServerVerifier::builder_with_provider( + test_roots(), + provider::default_provider().into(), + ) + .only_check_end_entity_revocation(); + // The builder should be Debug. + println!("{builder:?}"); + builder.build().unwrap(); + } + + #[test] + fn test_server_verifier_allow_unknown() { + // We should be able to build a server cert. verifier that allows unknown revocation + // status. + let builder = WebPkiServerVerifier::builder_with_provider( + test_roots(), + provider::default_provider().into(), + ) + .allow_unknown_revocation_status(); + // The builder should be Debug. + println!("{builder:?}"); + builder.build().unwrap(); + } + + #[test] + fn test_server_verifier_allow_unknown_ee_only() { + // We should be able to build a server cert. verifier that allows unknown revocation + // status and only checks the EE cert. + let builder = WebPkiServerVerifier::builder_with_provider( + test_roots(), + provider::default_provider().into(), + ) + .allow_unknown_revocation_status() + .only_check_end_entity_revocation(); + // The builder should be Debug. + println!("{builder:?}"); + builder.build().unwrap(); + } + + #[test] + fn test_server_verifier_enforce_expiration() { + // We should be able to build a server cert. verifier that allows unknown revocation + // status. + let builder = WebPkiServerVerifier::builder_with_provider( + test_roots(), + provider::default_provider().into(), + ) + .enforce_revocation_expiration(); + // The builder should be Debug. + println!("{builder:?}"); + builder.build().unwrap(); + } +} diff --git a/http/vendor/rustls/src/webpki/verify.rs b/http/vendor/rustls/src/webpki/verify.rs new file mode 100644 index 0000000..5c3e79b --- /dev/null +++ b/http/vendor/rustls/src/webpki/verify.rs @@ -0,0 +1,289 @@ +use alloc::vec::Vec; +use core::fmt; + +use pki_types::{ + CertificateDer, ServerName, SignatureVerificationAlgorithm, SubjectPublicKeyInfoDer, UnixTime, +}; + +use super::anchors::RootCertStore; +use super::pki_error; +use crate::enums::SignatureScheme; +use crate::error::{Error, PeerMisbehaved}; +use crate::verify::{DigitallySignedStruct, HandshakeSignatureValid}; + +/// Verify that the end-entity certificate `end_entity` is a valid server cert +/// and chains to at least one of the trust anchors in the `roots` [RootCertStore]. +/// +/// This function is primarily useful when building a custom certificate verifier. It +/// performs **no revocation checking**. Implementers must handle this themselves, +/// along with checking that the server certificate is valid for the subject name +/// being used (see [`verify_server_name`]). +/// +/// `intermediates` contains all certificates other than `end_entity` that +/// were sent as part of the server's `Certificate` message. It is in the +/// same order that the server sent them and may be empty. +#[allow(dead_code)] +pub fn verify_server_cert_signed_by_trust_anchor( + cert: &ParsedCertificate<'_>, + roots: &RootCertStore, + intermediates: &[CertificateDer<'_>], + now: UnixTime, + supported_algs: &[&dyn SignatureVerificationAlgorithm], +) -> Result<(), Error> { + verify_server_cert_signed_by_trust_anchor_impl( + cert, + roots, + intermediates, + None, // No revocation checking supported with this API. + now, + supported_algs, + ) +} + +/// Verify that the `end_entity` has an alternative name matching the `server_name`. +/// +/// Note: this only verifies the name and should be used in conjunction with more verification +/// like [verify_server_cert_signed_by_trust_anchor] +pub fn verify_server_name( + cert: &ParsedCertificate<'_>, + server_name: &ServerName<'_>, +) -> Result<(), Error> { + cert.0 + .verify_is_valid_for_subject_name(server_name) + .map_err(pki_error) +} + +/// Describes which `webpki` signature verification algorithms are supported and +/// how they map to TLS [`SignatureScheme`]s. +#[derive(Clone, Copy)] +#[allow(unreachable_pub)] +pub struct WebPkiSupportedAlgorithms { + /// A list of all supported signature verification algorithms. + /// + /// Used for verifying certificate chains. + /// + /// The order of this list is not significant. + pub all: &'static [&'static dyn SignatureVerificationAlgorithm], + + /// A mapping from TLS `SignatureScheme`s to matching webpki signature verification algorithms. + /// + /// This is one (`SignatureScheme`) to many ([`SignatureVerificationAlgorithm`]) because + /// (depending on the protocol version) there is not necessary a 1-to-1 mapping. + /// + /// For TLS1.2, all `SignatureVerificationAlgorithm`s are tried in sequence. + /// + /// For TLS1.3, only the first is tried. + /// + /// The supported schemes in this mapping is communicated to the peer and the order is significant. + /// The first mapping is our highest preference. + pub mapping: &'static [( + SignatureScheme, + &'static [&'static dyn SignatureVerificationAlgorithm], + )], +} + +impl WebPkiSupportedAlgorithms { + /// Return all the `scheme` items in `mapping`, maintaining order. + pub fn supported_schemes(&self) -> Vec { + self.mapping + .iter() + .map(|item| item.0) + .collect() + } + + /// Return the first item in `mapping` that matches `scheme`. + fn convert_scheme( + &self, + scheme: SignatureScheme, + ) -> Result<&[&'static dyn SignatureVerificationAlgorithm], Error> { + self.mapping + .iter() + .filter_map(|item| if item.0 == scheme { Some(item.1) } else { None }) + .next() + .ok_or_else(|| PeerMisbehaved::SignedHandshakeWithUnadvertisedSigScheme.into()) + } + + /// Return `true` if all cryptography is FIPS-approved. + pub fn fips(&self) -> bool { + self.all.iter().all(|alg| alg.fips()) + && self + .mapping + .iter() + .all(|item| item.1.iter().all(|alg| alg.fips())) + } +} + +impl fmt::Debug for WebPkiSupportedAlgorithms { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "WebPkiSupportedAlgorithms {{ all: [ .. ], mapping: ")?; + f.debug_list() + .entries(self.mapping.iter().map(|item| item.0)) + .finish()?; + write!(f, " }}") + } +} + +/// Wrapper around internal representation of a parsed certificate. +/// +/// This is used in order to avoid parsing twice when specifying custom verification +pub struct ParsedCertificate<'a>(pub(crate) webpki::EndEntityCert<'a>); + +impl ParsedCertificate<'_> { + /// Get the parsed certificate's SubjectPublicKeyInfo (SPKI) + pub fn subject_public_key_info(&self) -> SubjectPublicKeyInfoDer<'static> { + self.0.subject_public_key_info() + } +} + +impl<'a> TryFrom<&'a CertificateDer<'a>> for ParsedCertificate<'a> { + type Error = Error; + fn try_from(value: &'a CertificateDer<'a>) -> Result { + webpki::EndEntityCert::try_from(value) + .map_err(pki_error) + .map(ParsedCertificate) + } +} + +/// Verify a message signature using the `cert` public key and any supported scheme. +/// +/// This function verifies the `dss` signature over `message` using the subject public key from +/// `cert`. Since TLS 1.2 doesn't provide enough information to map the `dss.scheme` into a single +/// [`SignatureVerificationAlgorithm`], this function will map to several candidates and try each in +/// succession until one succeeds or we exhaust all candidates. +/// +/// See [WebPkiSupportedAlgorithms::mapping] for more information. +pub fn verify_tls12_signature( + message: &[u8], + cert: &CertificateDer<'_>, + dss: &DigitallySignedStruct, + supported_schemes: &WebPkiSupportedAlgorithms, +) -> Result { + let possible_algs = supported_schemes.convert_scheme(dss.scheme)?; + let cert = webpki::EndEntityCert::try_from(cert).map_err(pki_error)?; + + let mut error = None; + for alg in possible_algs { + match cert.verify_signature(*alg, message, dss.signature()) { + Err(err @ webpki::Error::UnsupportedSignatureAlgorithmForPublicKeyContext(_)) => { + error = Some(err); + continue; + } + Err(e) => return Err(pki_error(e)), + Ok(()) => return Ok(HandshakeSignatureValid::assertion()), + } + } + + #[allow(deprecated)] // The `unwrap_or()` should be statically unreachable + Err(pki_error(error.unwrap_or( + webpki::Error::UnsupportedSignatureAlgorithmForPublicKey, + ))) +} + +/// Verify a message signature using the `cert` public key and the first TLS 1.3 compatible +/// supported scheme. +/// +/// This function verifies the `dss` signature over `message` using the subject public key from +/// `cert`. Unlike [verify_tls12_signature], this function only tries the first matching scheme. See +/// [WebPkiSupportedAlgorithms::mapping] for more information. +pub fn verify_tls13_signature( + msg: &[u8], + cert: &CertificateDer<'_>, + dss: &DigitallySignedStruct, + supported_schemes: &WebPkiSupportedAlgorithms, +) -> Result { + if !dss.scheme.supported_in_tls13() { + return Err(PeerMisbehaved::SignedHandshakeWithUnadvertisedSigScheme.into()); + } + + let alg = supported_schemes.convert_scheme(dss.scheme)?[0]; + + let cert = webpki::EndEntityCert::try_from(cert).map_err(pki_error)?; + + cert.verify_signature(alg, msg, dss.signature()) + .map_err(pki_error) + .map(|_| HandshakeSignatureValid::assertion()) +} + +/// Verify a message signature using a raw public key and the first TLS 1.3 compatible +/// supported scheme. +pub fn verify_tls13_signature_with_raw_key( + msg: &[u8], + spki: &SubjectPublicKeyInfoDer<'_>, + dss: &DigitallySignedStruct, + supported_schemes: &WebPkiSupportedAlgorithms, +) -> Result { + if !dss.scheme.supported_in_tls13() { + return Err(PeerMisbehaved::SignedHandshakeWithUnadvertisedSigScheme.into()); + } + + let raw_key = webpki::RawPublicKeyEntity::try_from(spki).map_err(pki_error)?; + let alg = supported_schemes.convert_scheme(dss.scheme)?[0]; + + raw_key + .verify_signature(alg, msg, dss.signature()) + .map_err(pki_error) + .map(|_| HandshakeSignatureValid::assertion()) +} + +/// Verify that the end-entity certificate `end_entity` is a valid server cert +/// and chains to at least one of the trust anchors in the `roots` [RootCertStore]. +/// +/// `intermediates` contains all certificates other than `end_entity` that +/// were sent as part of the server's `Certificate` message. It is in the +/// same order that the server sent them and may be empty. +/// +/// `revocation` controls how revocation checking is performed, if at all. +/// +/// This function exists to be used by [`verify_server_cert_signed_by_trust_anchor`], +/// and differs only in providing a `Option` argument. We +/// can't include this argument in `verify_server_cert_signed_by_trust_anchor` because +/// it will leak the webpki types into Rustls' public API. +pub(crate) fn verify_server_cert_signed_by_trust_anchor_impl( + cert: &ParsedCertificate<'_>, + roots: &RootCertStore, + intermediates: &[CertificateDer<'_>], + revocation: Option>, + now: UnixTime, + supported_algs: &[&dyn SignatureVerificationAlgorithm], +) -> Result<(), Error> { + let result = cert.0.verify_for_usage( + supported_algs, + &roots.roots, + intermediates, + now, + webpki::KeyUsage::server_auth(), + revocation, + None, + ); + match result { + Ok(_) => Ok(()), + Err(e) => Err(pki_error(e)), + } +} + +#[cfg(test)] +mod tests { + use std::format; + + use super::*; + + #[test] + fn certificate_debug() { + assert_eq!( + "CertificateDer(0x6162)", + format!("{:?}", CertificateDer::from(b"ab".to_vec())) + ); + } + + #[cfg(feature = "ring")] + #[test] + fn webpki_supported_algorithms_is_debug() { + assert_eq!( + "WebPkiSupportedAlgorithms { all: [ .. ], mapping: [ECDSA_NISTP384_SHA384, ECDSA_NISTP256_SHA256, ED25519, RSA_PSS_SHA512, RSA_PSS_SHA384, RSA_PSS_SHA256, RSA_PKCS1_SHA512, RSA_PKCS1_SHA384, RSA_PKCS1_SHA256] }", + format!( + "{:?}", + crate::crypto::ring::default_provider().signature_verification_algorithms + ) + ); + } +} diff --git a/http/vendor/rustls/src/x509.rs b/http/vendor/rustls/src/x509.rs new file mode 100644 index 0000000..2620fe8 --- /dev/null +++ b/http/vendor/rustls/src/x509.rs @@ -0,0 +1,147 @@ +// Additional x509/asn1 functions to those provided in webpki/ring. + +use alloc::vec::Vec; + +/// Prepend stuff to `bytes` to put it in a DER SEQUENCE. +pub(crate) fn wrap_in_sequence(bytes: &[u8]) -> Vec { + asn1_wrap(DER_SEQUENCE_TAG, bytes, &[]) +} + +/// Prepend stuff to `bytes_a` + `bytes_b` to put it in a DER SEQUENCE. +#[cfg_attr(not(feature = "ring"), allow(dead_code))] +pub(crate) fn wrap_concat_in_sequence(bytes_a: &[u8], bytes_b: &[u8]) -> Vec { + asn1_wrap(DER_SEQUENCE_TAG, bytes_a, bytes_b) +} + +/// Prepend stuff to `bytes` to put it in a DER BIT STRING. +pub(crate) fn wrap_in_bit_string(bytes: &[u8]) -> Vec { + asn1_wrap(DER_BIT_STRING_TAG, &[0u8], bytes) +} + +/// Prepend stuff to `bytes` to put it in a DER OCTET STRING. +#[cfg_attr(not(feature = "ring"), allow(dead_code))] +pub(crate) fn wrap_in_octet_string(bytes: &[u8]) -> Vec { + asn1_wrap(DER_OCTET_STRING_TAG, bytes, &[]) +} + +fn asn1_wrap(tag: u8, bytes_a: &[u8], bytes_b: &[u8]) -> Vec { + let len = bytes_a.len() + bytes_b.len(); + + if len <= 0x7f { + // Short form + let mut ret = Vec::with_capacity(2 + len); + ret.push(tag); + ret.push(len as u8); + ret.extend_from_slice(bytes_a); + ret.extend_from_slice(bytes_b); + ret + } else { + // Long form + let size = len.to_be_bytes(); + let leading_zero_bytes = size + .iter() + .position(|&x| x != 0) + .unwrap_or(size.len()); + assert!(leading_zero_bytes < size.len()); + let encoded_bytes = size.len() - leading_zero_bytes; + + let mut ret = Vec::with_capacity(2 + encoded_bytes + len); + ret.push(tag); + + ret.push(0x80 + encoded_bytes as u8); + ret.extend_from_slice(&size[leading_zero_bytes..]); + + ret.extend_from_slice(bytes_a); + ret.extend_from_slice(bytes_b); + ret + } +} + +const DER_SEQUENCE_TAG: u8 = 0x30; +const DER_BIT_STRING_TAG: u8 = 0x03; +const DER_OCTET_STRING_TAG: u8 = 0x04; + +#[cfg(test)] +mod tests { + use std::vec; + + use super::*; + + #[test] + fn test_empty() { + assert_eq!(vec![0x30, 0x00], wrap_in_sequence(&[])); + } + + #[test] + fn test_small() { + assert_eq!( + vec![0x30, 0x04, 0x00, 0x11, 0x22, 0x33], + wrap_in_sequence(&[0x00, 0x11, 0x22, 0x33]) + ); + } + + #[test] + fn test_medium() { + let mut val = Vec::new(); + val.resize(255, 0x12); + assert_eq!( + vec![0x30, 0x81, 0xff, 0x12, 0x12, 0x12], + wrap_in_sequence(&val)[..6] + ); + } + + #[test] + fn test_large() { + let mut val = Vec::new(); + val.resize(4660, 0x12); + wrap_in_sequence(&val); + assert_eq!( + vec![0x30, 0x82, 0x12, 0x34, 0x12, 0x12], + wrap_in_sequence(&val)[..6] + ); + } + + #[test] + fn test_huge() { + let mut val = Vec::new(); + val.resize(0xffff, 0x12); + let result = wrap_in_sequence(&val); + assert_eq!(vec![0x30, 0x82, 0xff, 0xff, 0x12, 0x12], result[..6]); + assert_eq!(result.len(), 0xffff + 4); + } + + #[test] + fn test_gigantic() { + let mut val = Vec::new(); + val.resize(0x100000, 0x12); + let result = wrap_in_sequence(&val); + assert_eq!(vec![0x30, 0x83, 0x10, 0x00, 0x00, 0x12, 0x12], result[..7]); + assert_eq!(result.len(), 0x100000 + 5); + } + + #[test] + fn test_ludicrous() { + let mut val = Vec::new(); + val.resize(0x1000000, 0x12); + let result = wrap_in_sequence(&val); + assert_eq!( + vec![0x30, 0x84, 0x01, 0x00, 0x00, 0x00, 0x12, 0x12], + result[..8] + ); + assert_eq!(result.len(), 0x1000000 + 6); + } + + #[test] + fn test_wrap_in_bit_string() { + // The BIT STRING encoding starts with a single octet on + // the front saying how many bits to disregard from the + // last octet. So this zero means "no bits" unused, which + // is correct because our input is an string of octets. + // + // So if we encode &[0x55u8] with this function, we should get: + // + // 0x03 0x02 0x00 0x55 + // ^ tag ^ len ^ no unused bits ^ value + assert_eq!(wrap_in_bit_string(&[0x55u8]), vec![0x03, 0x02, 0x00, 0x55]); + } +} diff --git a/http/vendor/shlex/.cargo-checksum.json b/http/vendor/shlex/.cargo-checksum.json new file mode 100644 index 0000000..d4d6c00 --- /dev/null +++ b/http/vendor/shlex/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{".cargo_vcs_info.json":"429e30490041b626645c03d9e4508b7087a9630b213c093497f23745a704e44d",".github/workflows/test.yml":"a2dcac65344f67fa4bfac683bb118bebf3c30c456144e43dc1622bf134ae9a3a","CHANGELOG.md":"9d36d8fe05063ed2f386dc430f8cc612df59f3bf0da2d5d27be4c97c4e08cd1c","Cargo.lock":"310568f0d3714c3485288793f7b17bf3d0590f57002317e2392977026f24fb20","Cargo.toml":"b6ead6cf404555ced33f7574c6c11413e29e7bcd5eb0ceeb59452830a46675ed","Cargo.toml.orig":"c5a6784dc911e13f22aa3fdb79f83142a64777047534ce447dc94783c58389b7","LICENSE-APACHE":"553fffcd9b1cb158bc3e9edc35da85ca5c3b3d7d2e61c883ebcfa8a65814b583","LICENSE-MIT":"4455bf75a91154108304cb283e0fea9948c14f13e20d60887cf2552449dea3b1","README.md":"082e505bba5dffc5904af5602b45d01129173e617db62c81e6c11d71c964ea71","src/bytes.rs":"14ac6d79be6cd93543de6cbba8a4c07181aacf7d02d01a1e5f51b63a89bf11c0","src/lib.rs":"d707a605a9dbe52b48c53f5d0209ab457d1db535f10acad060883b6c3d8d7a91","src/quoting_warning.md":"f546c856f6db2aa8dd02ebc900a6de53817c973aca21892eb575dd541307438b"},"package":"f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"} \ No newline at end of file diff --git a/http/vendor/shlex/.cargo_vcs_info.json b/http/vendor/shlex/.cargo_vcs_info.json new file mode 100644 index 0000000..565c523 --- /dev/null +++ b/http/vendor/shlex/.cargo_vcs_info.json @@ -0,0 +1,6 @@ +{ + "git": { + "sha1": "e82b1411beb7c92871c2c078c9ab415bbcf207ef" + }, + "path_in_vcs": "" +} \ No newline at end of file diff --git a/http/vendor/shlex/.github/workflows/test.yml b/http/vendor/shlex/.github/workflows/test.yml new file mode 100644 index 0000000..bb477bf --- /dev/null +++ b/http/vendor/shlex/.github/workflows/test.yml @@ -0,0 +1,57 @@ +name: Rust + +on: + pull_request: + push: + +jobs: + stable: + name: Test + Clippy (stable) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: rustup toolchain install stable --no-self-update + - run: rustup default stable + - run: rustup component add clippy + - run: RUSTFLAGS=-Dwarnings cargo test + - run: cargo clippy -- -Dwarnings + - run: cargo doc + - run: RUSTFLAGS=-Dwarnings cargo build --manifest-path fuzz/Cargo.toml --all + + beta: + name: Test + Clippy (beta) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: rustup toolchain install beta --no-self-update + - run: rustup default beta + - run: rustup component add clippy + - run: RUSTFLAGS=-Dwarnings cargo test + - run: cargo clippy -- -Dwarnings + - run: RUSTFLAGS=-Dwarnings cargo build --manifest-path fuzz/Cargo.toml --all + + stable-no-default-features: + name: Test + Clippy (stable, no default features) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: rustup toolchain install stable --no-self-update + - run: rustup default stable + - run: rustup component add clippy + - run: RUSTFLAGS=-Dwarnings cargo test --no-default-features && cargo clippy --no-default-features -- -Dwarnings + + msrv: + name: Test (MSRV) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - run: rustup toolchain install 1.46 --no-self-update + - run: rustup default 1.46 + # We expect an unknown_lints warning on 1.46. + # Any new warnings added should be flagged because they might indicate + # a bug, but feel free to add them to -A below if they are harmless and + # don't happen on newer Rust versions. + # Also, no Clippy because we probably don't care what old Clippy + # thinks. + - run: RUSTFLAGS='-Dwarnings -Aunknown_lints' cargo test + diff --git a/http/vendor/shlex/CHANGELOG.md b/http/vendor/shlex/CHANGELOG.md new file mode 100644 index 0000000..9d7dd30 --- /dev/null +++ b/http/vendor/shlex/CHANGELOG.md @@ -0,0 +1,43 @@ +# 2.0.1 + +* Fixes a compile error when building the documentation. + +# 2.0.0 + +* **Breaking:** Items that were marked as deprecated in 1.x have been removed: `join`, `quote`, `bytes::join`, and `bytes::quote`. +* **Breaking:** The `DerefMut` impl for `Shlex` has been removed since it was unsound. New `unsafe` APIs have been added in its place: `Shlex::from_bytes`, `Shlex::as_bytes_mut`. + +# 1.3.0 + +* Full fix for the high-severity security vulnerability [RUSTSEC-2024-0006](https://rustsec.org/advisories/RUSTSEC-2024-0006.html) a.k.a. [GHSA-r7qv-8r2h-pg27](https://github.com/comex/rust-shlex/security/advisories/GHSA-r7qv-8r2h-pg27): + * Deprecates quote APIs in favor of `try_` equivalents that complain about nul bytes. + * Also adds a builder API, which allows re-enabling nul bytes without using the deprecated interface, and in the future can allow other things (as discussed in quoting_warning). + * Adds documentation about various security risks that remain, particularly with interactive shells. +* Adds explicit MSRV of 1.46.0. + +# 1.2.1 + +* Partial fix for the high-severity security vulnerability [RUSTSEC-2024-0006](https://rustsec.org/advisories/RUSTSEC-2024-0006.html) a.k.a. [GHSA-r7qv-8r2h-pg27](https://github.com/comex/rust-shlex/security/advisories/GHSA-r7qv-8r2h-pg27) without bumping MSRV: + * The bytes `{` and `\xa0` are now escaped by quoting functions. + +# 1.2.0 + +* Adds `bytes` module to support operating directly on byte strings. + +# 1.1.0 + +* Adds the `std` feature (enabled by default). +* Disabling the `std` feature makes the crate work in `#![no_std]` mode, assuming presence of the `alloc` crate. + +# 1.0.0 + +* Adds the `join` convenience function. +* Fixes parsing of `'\\n'` to match the behavior of bash/Zsh/Python `shlex`. The result was previously `\n`, now it is `\\n`. + +# 0.1.1 + +* Adds handling of `#` comments. + +# 0.1.0 + +This is the initial release. diff --git a/http/vendor/shlex/Cargo.lock b/http/vendor/shlex/Cargo.lock new file mode 100644 index 0000000..712e024 --- /dev/null +++ b/http/vendor/shlex/Cargo.lock @@ -0,0 +1,5 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "shlex" +version = "2.0.1" diff --git a/http/vendor/shlex/Cargo.toml b/http/vendor/shlex/Cargo.toml new file mode 100644 index 0000000..b188bbb --- /dev/null +++ b/http/vendor/shlex/Cargo.toml @@ -0,0 +1,51 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies. +# +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. + +[package] +edition = "2018" +rust-version = "1.46.0" +name = "shlex" +version = "2.0.1" +authors = [ + "comex ", + "Fenhl ", + "Adrian Taylor ", + "Alex Touchet ", + "Daniel Parks ", + "Garrett Berg ", +] +build = false +autolib = false +autobins = false +autoexamples = false +autotests = false +autobenches = false +description = "Split a string into shell words, like Python's shlex." +readme = "README.md" +categories = [ + "command-line-interface", + "parser-implementations", +] +license = "MIT OR Apache-2.0" +repository = "https://github.com/comex/rust-shlex" + +[features] +default = ["std"] +std = [] + +[lib] +name = "shlex" +path = "src/lib.rs" + +[lints.rust.unexpected_cfgs] +level = "warn" +priority = 0 +check-cfg = ["cfg(manual_codegen_check)"] diff --git a/http/vendor/shlex/Cargo.toml.orig b/http/vendor/shlex/Cargo.toml.orig new file mode 100644 index 0000000..71036b7 --- /dev/null +++ b/http/vendor/shlex/Cargo.toml.orig @@ -0,0 +1,27 @@ +[package] +name = "shlex" +version = "2.0.1" +authors = [ + "comex ", + "Fenhl ", + "Adrian Taylor ", + "Alex Touchet ", + "Daniel Parks ", + "Garrett Berg ", +] +license = "MIT OR Apache-2.0" +repository = "https://github.com/comex/rust-shlex" +description = "Split a string into shell words, like Python's shlex." +categories = [ + "command-line-interface", + "parser-implementations" +] +rust-version = "1.46.0" +edition = "2018" + +[features] +std = [] +default = ["std"] + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(manual_codegen_check)'] } diff --git a/http/vendor/shlex/LICENSE-APACHE b/http/vendor/shlex/LICENSE-APACHE new file mode 100644 index 0000000..3746504 --- /dev/null +++ b/http/vendor/shlex/LICENSE-APACHE @@ -0,0 +1,13 @@ +Copyright 2015 Nicholas Allegra (comex). + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/http/vendor/shlex/LICENSE-MIT b/http/vendor/shlex/LICENSE-MIT new file mode 100644 index 0000000..5ec1fe1 --- /dev/null +++ b/http/vendor/shlex/LICENSE-MIT @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Nicholas Allegra (comex). + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/http/vendor/shlex/README.md b/http/vendor/shlex/README.md new file mode 100644 index 0000000..6400a6f --- /dev/null +++ b/http/vendor/shlex/README.md @@ -0,0 +1,39 @@ +[![ci badge]][ci link] [![crates.io badge]][crates.io link] [![docs.rs badge]][docs.rs link] + +[crates.io badge]: https://img.shields.io/crates/v/shlex.svg?style=flat-square +[crates.io link]: https://crates.io/crates/shlex +[docs.rs badge]: https://img.shields.io/badge/docs-online-dddddd.svg?style=flat-square +[docs.rs link]: https://docs.rs/shlex +[ci badge]: https://img.shields.io/github/actions/workflow/status/comex/rust-shlex/test.yml?branch=master&style=flat-square +[ci link]: https://github.com/comex/rust-shlex/actions + +Same idea as (but implementation not directly based on) the Python shlex +module. However, this implementation does not support any of the Python +module's customization because it makes parsing slower and is fairly useless. +You only get the default settings of shlex.split, which mimic the POSIX shell: + + +This implementation also deviates from the Python version in not treating \r +specially, which I believe is more compliant. + +This crate can be used on either normal Rust strings, or on byte strings with +the `bytes` module. The algorithms used are oblivious to UTF-8 high bytes, so +internally they all work on bytes directly as a micro-optimization. + +Disabling the `std` feature (which is enabled by default) will allow the crate +to work in `no_std` environments, where the `alloc` crate, and a global +allocator, are available. + +# LICENSE + +The source code in this repository is Licensed under either of +- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or + https://www.apache.org/licenses/LICENSE-2.0) +- MIT license ([LICENSE-MIT](LICENSE-MIT) or + https://opensource.org/licenses/MIT) + +at your option. + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in the work by you, as defined in the Apache-2.0 license, shall +be dual licensed as above, without any additional terms or conditions. diff --git a/http/vendor/shlex/src/bytes.rs b/http/vendor/shlex/src/bytes.rs new file mode 100644 index 0000000..52401fc --- /dev/null +++ b/http/vendor/shlex/src/bytes.rs @@ -0,0 +1,516 @@ +// Copyright 2015 Nicholas Allegra (comex). +// Licensed under the Apache License, Version 2.0 or +// the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +//! [`Shlex`] and friends for byte strings. +//! +//! This is used internally by the [outer module](crate), and may be more +//! convenient if you are working with byte slices (`[u8]`) or types that are +//! wrappers around bytes, such as [`OsStr`](std::ffi::OsStr): +//! +//! ```rust +//! #[cfg(unix)] { +//! use shlex::bytes::try_quote; +//! use std::ffi::OsStr; +//! use std::os::unix::ffi::OsStrExt; +//! +//! // `\x80` is invalid in UTF-8. +//! let os_str = OsStr::from_bytes(b"a\x80b c"); +//! assert_eq!(try_quote(os_str.as_bytes()).unwrap(), &b"'a\x80b c'"[..]); +//! } +//! ``` +//! +//! (On Windows, `OsStr` uses 16 bit wide characters so this will not work.) + +extern crate alloc; +use alloc::vec::Vec; +use alloc::borrow::Cow; +#[cfg(test)] +use alloc::borrow::ToOwned; +#[cfg(all(doc, not(doctest)))] +use crate::{self as shlex, quoting_warning}; + +use super::QuoteError; + +/// An iterator that takes an input byte string and splits it into the words using the same syntax as +/// the POSIX shell. +pub struct Shlex<'a> { + in_iter: core::slice::Iter<'a, u8>, + /// The number of newlines read so far, plus one. + pub line_no: usize, + /// An input string is erroneous if it ends while inside a quotation or right after an + /// unescaped backslash. Since Iterator does not have a mechanism to return an error, if that + /// happens, Shlex just throws out the last token, ends the iteration, and sets 'had_error' to + /// true; best to check it after you're done iterating. + pub had_error: bool, +} + +impl<'a> Shlex<'a> { + pub fn new(in_bytes: &'a [u8]) -> Self { + Shlex { + in_iter: in_bytes.iter(), + line_no: 1, + had_error: false, + } + } + + fn parse_word(&mut self, mut ch: u8) -> Option> { + let mut result: Vec = Vec::new(); + loop { + match ch as char { + '"' => if let Err(()) = self.parse_double(&mut result) { + self.had_error = true; + return None; + }, + '\'' => if let Err(()) = self.parse_single(&mut result) { + self.had_error = true; + return None; + }, + '\\' => if let Some(ch2) = self.next_char() { + if ch2 != b'\n' { result.push(ch2); } + } else { + self.had_error = true; + return None; + }, + ' ' | '\t' | '\n' => { break; }, + _ => { result.push(ch); }, + } + if let Some(ch2) = self.next_char() { ch = ch2; } else { break; } + } + Some(result) + } + + fn parse_double(&mut self, result: &mut Vec) -> Result<(), ()> { + loop { + if let Some(ch2) = self.next_char() { + match ch2 as char { + '\\' => { + if let Some(ch3) = self.next_char() { + match ch3 as char { + // \$ => $ + '$' | '`' | '"' | '\\' => { result.push(ch3); }, + // \ => nothing + '\n' => {}, + // \x => =x + _ => { result.push(b'\\'); result.push(ch3); } + } + } else { + return Err(()); + } + }, + '"' => { return Ok(()); }, + _ => { result.push(ch2); }, + } + } else { + return Err(()); + } + } + } + + fn parse_single(&mut self, result: &mut Vec) -> Result<(), ()> { + loop { + if let Some(ch2) = self.next_char() { + match ch2 as char { + '\'' => { return Ok(()); }, + _ => { result.push(ch2); }, + } + } else { + return Err(()); + } + } + } + + fn next_char(&mut self) -> Option { + let res = self.in_iter.next().copied(); + if res == Some(b'\n') { self.line_no += 1; } + res + } +} + +impl Iterator for Shlex<'_> { + type Item = Vec; + fn next(&mut self) -> Option { + if let Some(mut ch) = self.next_char() { + // skip initial whitespace + loop { + match ch as char { + ' ' | '\t' | '\n' => {}, + '#' => { + while let Some(ch2) = self.next_char() { + if ch2 as char == '\n' { break; } + } + }, + _ => { break; } + } + if let Some(ch2) = self.next_char() { ch = ch2; } else { return None; } + } + self.parse_word(ch) + } else { // no initial character + None + } + } + +} + +/// Convenience function that consumes the whole byte string at once. Returns None if the input was +/// erroneous. +pub fn split(in_bytes: &[u8]) -> Option>> { + let mut shl = Shlex::new(in_bytes); + let res = shl.by_ref().collect(); + if shl.had_error { None } else { Some(res) } +} + +/// A more configurable interface to quote strings. If you only want the default settings you can +/// use the convenience functions [`try_quote`] and [`try_join`]. +/// +/// The string equivalent is [`shlex::Quoter`]. +#[derive(Default, Debug, Clone)] +pub struct Quoter { + allow_nul: bool, + // TODO: more options +} + +impl Quoter { + /// Create a new [`Quoter`] with default settings. + #[inline] + pub fn new() -> Self { + Self::default() + } + + /// Set whether to allow [nul bytes](quoting_warning#nul-bytes). By default they are not + /// allowed and will result in an error of [`QuoteError::Nul`]. + #[inline] + pub fn allow_nul(mut self, allow: bool) -> Self { + self.allow_nul = allow; + self + } + + /// Convenience function that consumes an iterable of words and turns it into a single byte string, + /// quoting words when necessary. Consecutive words will be separated by a single space. + pub fn join<'a, I: IntoIterator>(&self, words: I) -> Result, QuoteError> { + Ok(words.into_iter() + .map(|word| self.quote(word)) + .collect::>, QuoteError>>()? + .join(&b' ')) + } + + /// Given a single word, return a byte string suitable to encode it as a shell argument. + /// + /// If given valid UTF-8, this will never produce invalid UTF-8. This is because it only + /// ever inserts valid ASCII characters before or after existing ASCII characters (or + /// returns two single quotes if the input was an empty string). It will never modify a + /// multibyte UTF-8 character. + pub fn quote<'a>(&self, mut in_bytes: &'a [u8]) -> Result, QuoteError> { + if in_bytes.is_empty() { + // Empty string. Special case that isn't meaningful as only part of a word. + return Ok(b"''"[..].into()); + } + if !self.allow_nul && in_bytes.contains(&b'\0') { + return Err(QuoteError::Nul); + } + let mut out: Vec = Vec::new(); + while !in_bytes.is_empty() { + // Pick a quoting strategy for some prefix of the input. Normally this will cover the + // entire input, but in some case we might need to divide the input into multiple chunks + // that are quoted differently. + let (cur_len, strategy) = quoting_strategy(in_bytes); + if cur_len == in_bytes.len() && strategy == QuotingStrategy::Unquoted && out.is_empty() { + // Entire string can be represented unquoted. Reuse the allocation. + return Ok(in_bytes.into()); + } + let (cur_chunk, rest) = in_bytes.split_at(cur_len); + assert!(rest.len() < in_bytes.len()); // no infinite loop + in_bytes = rest; + append_quoted_chunk(&mut out, cur_chunk, strategy); + } + Ok(out.into()) + } + +} + +#[derive(PartialEq)] +enum QuotingStrategy { + /// No quotes and no backslash escapes. (If backslash escapes would be necessary, we use a + /// different strategy instead.) + Unquoted, + /// Single quoted. + SingleQuoted, + /// Double quotes, potentially with backslash escapes. + DoubleQuoted, + // TODO: add $'xxx' and "$(printf 'xxx')" styles +} + +/// Is this ASCII byte okay to emit unquoted? +const fn unquoted_ok(c: u8) -> bool { + match c as char { + // Allowed characters: + '+' | '-' | '.' | '/' | ':' | '@' | ']' | '_' | + '0'..='9' | 'A'..='Z' | 'a'..='z' + => true, + + // Non-allowed characters: + // From POSIX https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html + // "The application shall quote the following characters if they are to represent themselves:" + '|' | '&' | ';' | '<' | '>' | '(' | ')' | '$' | '`' | '\\' | '"' | '\'' | ' ' | '\t' | '\n' | + // "and the following may need to be quoted under certain circumstances[..]:" + '*' | '?' | '[' | '#' | '~' | '=' | '%' | + // Brace expansion. These ought to be in the POSIX list but aren't yet; + // see: https://www.austingroupbugs.net/view.php?id=1193 + '{' | '}' | + // Also quote comma, just to be safe in the extremely odd case that the user of this crate + // is intentionally placing a quoted string inside a brace expansion, e.g.: + // format!("echo foo{{a,b,{}}}" | shlex::quote(some_str)) + ',' | + // '\r' is allowed in a word by all real shells I tested, but is treated as a word + // separator by Python `shlex` | and might be translated to '\n' in interactive mode. + '\r' | + // '!' and '^' are treated specially in interactive mode; see quoting_warning. + '!' | '^' | + // Nul bytes and control characters. + '\x00' ..= '\x1f' | '\x7f' + => false, + '\u{80}' ..= '\u{10ffff}' => { + // This is unreachable since `unquoted_ok` is only called for 0..128. + // Non-ASCII bytes are handled separately in `quoting_strategy`. + // Can't call unreachable!() from `const fn` on old Rust, so... + unquoted_ok(c) + }, + } + // Note: The logic cited above for quoting comma might suggest that `..` should also be quoted, + // it as a special case of brace expansion). But it's not necessary. There are three cases: + // + // 1. The user wants comma-based brace expansion, but the untrusted string being `quote`d + // contains `..`, so they get something like `{foo,bar,3..5}`. + // => That's safe; both Bash and Zsh expand this to `foo bar 3..5` rather than + // `foo bar 3 4 5`. The presence of commas disables sequence expression expansion. + // + // 2. The user wants comma-based brace expansion where the contents of the braces are a + // variable number of `quote`d strings and nothing else. There happens to be exactly + // one string and it contains `..`, so they get something like `{3..5}`. + // => Then this will expand as a sequence expression, which is unintended. But I don't mind, + // because any such code is already buggy. Suppose the untrusted string *didn't* contain + // `,` or `..`, resulting in shell input like `{foo}`. Then the shell would interpret it + // as the literal string `{foo}` rather than brace-expanding it into `foo`. + // + // 3. The user wants a sequence expression and wants to supply an untrusted string as one of + // the endpoints or the increment. + // => Well, that's just silly, since the endpoints can only be numbers or single letters. +} + +/// Optimized version of `unquoted_ok`. +fn unquoted_ok_fast(c: u8) -> bool { + const UNQUOTED_OK_MASK: u128 = { + // Make a mask of all bytes in 0..<0x80 that pass. + let mut c = 0u8; + let mut mask = 0u128; + while c < 0x80 { + if unquoted_ok(c) { + mask |= 1u128 << c; + } + c += 1; + } + mask + }; + ((UNQUOTED_OK_MASK >> c) & 1) != 0 +} + +/// Is this ASCII byte okay to emit in single quotes? +fn single_quoted_ok(c: u8) -> bool { + match c { + // No single quotes in single quotes. + b'\'' => false, + // To work around a Bash bug, ^ is only allowed right after an opening single quote; see + // quoting_warning. + b'^' => false, + // Backslashes in single quotes are literal according to POSIX, but Fish treats them as an + // escape character. Ban them. Fish doesn't aim to be POSIX-compatible, but we *can* + // achieve Fish compatibility using double quotes, so we might as well. + b'\\' => false, + _ => true + } +} + +/// Is this ASCII byte okay to emit in double quotes? +fn double_quoted_ok(c: u8) -> bool { + match c { + // Work around Python `shlex` bug where parsing "\`" and "\$" doesn't strip the + // backslash, even though POSIX requires it. + b'`' | b'$' => false, + // '!' and '^' are treated specially in interactive mode; see quoting_warning. + b'!' | b'^' => false, + _ => true + } +} + +/// Given an input, return a quoting strategy that can cover some prefix of the string, along with +/// the size of that prefix. +/// +/// Precondition: input size is nonzero. (Empty strings are handled by the caller.) +/// Postcondition: returned size is nonzero. +#[cfg_attr(manual_codegen_check, inline(never))] +fn quoting_strategy(in_bytes: &[u8]) -> (usize, QuotingStrategy) { + const UNQUOTED_OK: u8 = 1; + const SINGLE_QUOTED_OK: u8 = 2; + const DOUBLE_QUOTED_OK: u8 = 4; + + let mut prev_ok = SINGLE_QUOTED_OK | DOUBLE_QUOTED_OK | UNQUOTED_OK; + let mut i = 0; + + if in_bytes[0] == b'^' { + // To work around a Bash bug, ^ is only allowed right after an opening single quote; see + // quoting_warning. + prev_ok = SINGLE_QUOTED_OK; + i = 1; + } + + while i < in_bytes.len() { + let c = in_bytes[i]; + let mut cur_ok = prev_ok; + + if c >= 0x80 { + // Normally, non-ASCII characters shouldn't require quoting, but see quoting_warning.md + // about \xa0. For now, just treat all non-ASCII characters as requiring quotes. This + // also ensures things are safe in the off-chance that you're in a legacy 8-bit locale that + // has additional characters satisfying `isblank`. + cur_ok &= !UNQUOTED_OK; + } else { + if !unquoted_ok_fast(c) { + cur_ok &= !UNQUOTED_OK; + } + if !single_quoted_ok(c){ + cur_ok &= !SINGLE_QUOTED_OK; + } + if !double_quoted_ok(c) { + cur_ok &= !DOUBLE_QUOTED_OK; + } + } + + if cur_ok == 0 { + // There are no quoting strategies that would work for both the previous characters and + // this one. So we have to end the chunk before this character. The caller will call + // `quoting_strategy` again to handle the rest of the string. + break; + } + + prev_ok = cur_ok; + i += 1; + } + + // Pick the best allowed strategy. + let strategy = if prev_ok & UNQUOTED_OK != 0 { + QuotingStrategy::Unquoted + } else if prev_ok & SINGLE_QUOTED_OK != 0 { + QuotingStrategy::SingleQuoted + } else if prev_ok & DOUBLE_QUOTED_OK != 0 { + QuotingStrategy::DoubleQuoted + } else { + unreachable!() + }; + debug_assert!(i > 0); + (i, strategy) +} + +fn append_quoted_chunk(out: &mut Vec, cur_chunk: &[u8], strategy: QuotingStrategy) { + match strategy { + QuotingStrategy::Unquoted => { + out.extend_from_slice(cur_chunk); + }, + QuotingStrategy::SingleQuoted => { + out.reserve(cur_chunk.len() + 2); + out.push(b'\''); + out.extend_from_slice(cur_chunk); + out.push(b'\''); + }, + QuotingStrategy::DoubleQuoted => { + out.reserve(cur_chunk.len() + 2); + out.push(b'"'); + for &c in cur_chunk.iter() { + if let b'$' | b'`' | b'"' | b'\\' = c { + // Add a preceding backslash. + // Note: We shouldn't actually get here for $ and ` because they don't pass + // `double_quoted_ok`. + out.push(b'\\'); + } + // Add the character itself. + out.push(c); + } + out.push(b'"'); + }, + } +} + +/// Convenience function that consumes an iterable of words and turns it into a single byte string, +/// quoting words when necessary. Consecutive words will be separated by a single space. +/// +/// Uses default settings. The only error that can be returned is [`QuoteError::Nul`]. +/// +/// Equivalent to [`Quoter::new().join(words)`](Quoter). +/// +/// The string equivalent is [shlex::try_join]. +pub fn try_join<'a, I: IntoIterator>(words: I) -> Result, QuoteError> { + Quoter::new().join(words) +} + +/// Given a single word, return a string suitable to encode it as a shell argument. +/// +/// Uses default settings. The only error that can be returned is [`QuoteError::Nul`]. +/// +/// Equivalent to [`Quoter::new().quote(in_bytes)`](Quoter). +/// +/// The string equivalent is [shlex::try_quote]. +pub fn try_quote(in_bytes: &[u8]) -> Result, QuoteError> { + Quoter::new().quote(in_bytes) +} + +#[cfg(test)] +const INVALID_UTF8: &[u8] = b"\xa1"; + +#[test] +#[allow(invalid_from_utf8)] +fn test_invalid_utf8() { + // Check that our test string is actually invalid UTF-8. + assert!(core::str::from_utf8(INVALID_UTF8).is_err()); +} + +#[cfg(test)] +static SPLIT_TEST_ITEMS: &[(&[u8], Option<&[&[u8]]>)] = &[ + (b"foo$baz", Some(&[b"foo$baz"])), + (b"foo baz", Some(&[b"foo", b"baz"])), + (b"foo\"bar\"baz", Some(&[b"foobarbaz"])), + (b"foo \"bar\"baz", Some(&[b"foo", b"barbaz"])), + (b" foo \nbar", Some(&[b"foo", b"bar"])), + (b"foo\\\nbar", Some(&[b"foobar"])), + (b"\"foo\\\nbar\"", Some(&[b"foobar"])), + (b"'baz\\$b'", Some(&[b"baz\\$b"])), + (b"'baz\\\''", None), + (b"\\", None), + (b"\"\\", None), + (b"'\\", None), + (b"\"", None), + (b"'", None), + (b"foo #bar\nbaz", Some(&[b"foo", b"baz"])), + (b"foo #bar", Some(&[b"foo"])), + (b"foo#bar", Some(&[b"foo#bar"])), + (b"foo\"#bar", None), + (b"'\\n'", Some(&[b"\\n"])), + (b"'\\\\n'", Some(&[b"\\\\n"])), + (INVALID_UTF8, Some(&[INVALID_UTF8])), +]; + +#[test] +fn test_split() { + for &(input, output) in SPLIT_TEST_ITEMS { + assert_eq!(split(input), output.map(|o| o.iter().map(|&x| x.to_owned()).collect())); + } +} + +#[test] +fn test_lineno() { + let mut sh = Shlex::new(b"\nfoo\nbar"); + while let Some(word) = sh.next() { + if word == b"bar" { + assert_eq!(sh.line_no, 3); + } + } +} diff --git a/http/vendor/shlex/src/lib.rs b/http/vendor/shlex/src/lib.rs new file mode 100644 index 0000000..c26e090 --- /dev/null +++ b/http/vendor/shlex/src/lib.rs @@ -0,0 +1,324 @@ +// Copyright 2015 Nicholas Allegra (comex). +// Licensed under the Apache License, Version 2.0 or +// the MIT license , at your option. This file may not be +// copied, modified, or distributed except according to those terms. + +//! Parse strings like, and escape strings for, POSIX shells. +//! +//! Same idea as (but implementation not directly based on) the Python shlex module. +//! +//! Disabling the `std` feature (which is enabled by default) will allow the crate to work in +//! `no_std` environments, where the `alloc` crate, and a global allocator, are available. +//! +//! ## Warning +//! +//! The [`try_quote`]/[`try_join`] family of APIs does not quote control characters (because they +//! cannot be quoted portably). +//! +//! This is fully safe in noninteractive contexts, like shell scripts and `sh -c` arguments (or +//! even scripts `source`d from interactive shells). +//! +//! But if you are quoting for human consumption, you should keep in mind that ugly inputs produce +//! ugly outputs (which may not be copy-pastable). +//! +//! And if by chance you are piping the output of [`try_quote`]/[`try_join`] directly to the stdin +//! of an interactive shell, you should stop, because control characters can lead to arbitrary +//! command injection. +//! +//! For more information, and for information about more minor issues, please see [quoting_warning]. +//! +//! ## Compatibility +//! +//! This crate's quoting functionality tries to be compatible with **any POSIX-compatible shell**; +//! it's tested against `bash`, `zsh`, `dash`, Busybox `ash`, and `mksh`, plus `fish` (which is not +//! POSIX-compatible but close enough). +//! +//! It also aims to be compatible with Python `shlex` and C `wordexp`. + +#![cfg_attr(not(feature = "std"), no_std)] + +extern crate alloc; +use alloc::vec::Vec; +use alloc::borrow::Cow; +use alloc::string::String; +#[cfg(test)] +use alloc::vec; +#[cfg(test)] +use alloc::borrow::ToOwned; + +pub mod bytes; +#[cfg(all(doc, not(doctest)))] +#[path = "quoting_warning.md"] +pub mod quoting_warning; + +/// An iterator that takes an input string and splits it into the words using the same syntax as +/// the POSIX shell. +/// +/// See [`bytes::Shlex`]. +pub struct Shlex<'a>(bytes::Shlex<'a>); + +impl<'a> Shlex<'a> { + pub fn new(in_str: &'a str) -> Self { + Self(bytes::Shlex::new(in_str.as_bytes())) + } + + /// # Safety + /// + /// The parameter must have been constructed from valid UTF-8. + pub unsafe fn from_bytes(bytes: bytes::Shlex<'a>) -> Self { + Self(bytes) + } + + /// # Safety + /// + /// If the returned reference is reassigned, the new [`bytes::Shlex`] must have been constructed from valid UTF-8. + pub unsafe fn as_bytes_mut(&mut self) -> &mut bytes::Shlex<'a> { + &mut self.0 + } +} + +impl Iterator for Shlex<'_> { + type Item = String; + fn next(&mut self) -> Option { + self.0.next().map(|byte_word| { + // Safety: given valid UTF-8, bytes::Shlex will always return valid UTF-8. + unsafe { String::from_utf8_unchecked(byte_word) } + }) + } +} + +impl<'a> core::ops::Deref for Shlex<'a> { + type Target = bytes::Shlex<'a>; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +/// Convenience function that consumes the whole string at once. Returns None if the input was +/// erroneous. +pub fn split(in_str: &str) -> Option> { + let mut shl = Shlex::new(in_str); + let res = shl.by_ref().collect(); + if shl.had_error { None } else { Some(res) } +} + +/// Errors from [`Quoter::quote`], [`Quoter::join`], etc. (and their [`bytes`] counterparts). +/// +/// By default, the only error that can be returned is [`QuoteError::Nul`]. If you call +/// `allow_nul(true)`, then no errors can be returned at all. Any error variants added in the +/// future will not be enabled by default; they will be enabled through corresponding non-default +/// [`Quoter`] options. +/// +/// ...In theory. In the unlikely event that additional classes of inputs are discovered that, +/// like nul bytes, are fundamentally unsafe to quote even for non-interactive shells, the risk +/// will be mitigated by adding corresponding [`QuoteError`] variants that *are* enabled by +/// default. +#[non_exhaustive] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub enum QuoteError { + /// The input contained a nul byte. In most cases, shells fundamentally [cannot handle strings + /// containing nul bytes](quoting_warning#nul-bytes), no matter how they are quoted. But if + /// you're sure you can handle nul bytes, you can call `allow_nul(true)` on the `Quoter` to let + /// them pass through. + Nul, +} + +impl core::fmt::Display for QuoteError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + match self { + QuoteError::Nul => f.write_str("cannot shell-quote string containing nul byte"), + } + } +} + +#[cfg(feature = "std")] +impl std::error::Error for QuoteError {} + +/// A more configurable interface to quote strings. If you only want the default settings you can +/// use the convenience functions [`try_quote`] and [`try_join`]. +/// +/// The bytes equivalent is [`bytes::Quoter`]. +#[derive(Default, Debug, Clone)] +pub struct Quoter { + inner: bytes::Quoter, +} + +impl Quoter { + /// Create a new [`Quoter`] with default settings. + #[inline] + pub fn new() -> Self { + Self::default() + } + + /// Set whether to allow [nul bytes](quoting_warning#nul-bytes). By default they are not + /// allowed and will result in an error of [`QuoteError::Nul`]. + #[inline] + pub fn allow_nul(mut self, allow: bool) -> Self { + self.inner = self.inner.allow_nul(allow); + self + } + + /// Convenience function that consumes an iterable of words and turns it into a single string, + /// quoting words when necessary. Consecutive words will be separated by a single space. + pub fn join<'a, I: IntoIterator>(&self, words: I) -> Result { + // Safety: given valid UTF-8, bytes::join() will always return valid UTF-8. + self.inner.join(words.into_iter().map(|s| s.as_bytes())) + .map(|bytes| unsafe { String::from_utf8_unchecked(bytes) }) + } + + /// Given a single word, return a string suitable to encode it as a shell argument. + pub fn quote<'a>(&self, in_str: &'a str) -> Result, QuoteError> { + Ok(match self.inner.quote(in_str.as_bytes())? { + Cow::Borrowed(out) => { + // Safety: given valid UTF-8, bytes::quote() will always return valid UTF-8. + unsafe { core::str::from_utf8_unchecked(out) }.into() + } + Cow::Owned(out) => { + // Safety: given valid UTF-8, bytes::quote() will always return valid UTF-8. + unsafe { String::from_utf8_unchecked(out) }.into() + } + }) + } +} + +impl From for Quoter { + fn from(inner: bytes::Quoter) -> Quoter { + Quoter { inner } + } +} + +impl From for bytes::Quoter { + fn from(quoter: Quoter) -> bytes::Quoter { + quoter.inner + } +} + +/// Convenience function that consumes an iterable of words and turns it into a single string, +/// quoting words when necessary. Consecutive words will be separated by a single space. +/// +/// Uses default settings. The only error that can be returned is [`QuoteError::Nul`]. +/// +/// Equivalent to [`Quoter::new().join(words)`](Quoter). +/// +/// The bytes equivalent is [bytes::try_join]. +pub fn try_join<'a, I: IntoIterator>(words: I) -> Result { + Quoter::new().join(words) +} + +/// Given a single word, return a string suitable to encode it as a shell argument. +/// +/// Uses default settings. The only error that can be returned is [`QuoteError::Nul`]. +/// +/// Equivalent to [`Quoter::new().quote(in_str)`](Quoter). +/// +/// The bytes equivalent is [bytes::try_quote]. +pub fn try_quote(in_str: &str) -> Result, QuoteError> { + Quoter::new().quote(in_str) +} + +#[cfg(test)] +static SPLIT_TEST_ITEMS: &[(&str, Option<&[&str]>)] = &[ + ("foo$baz", Some(&["foo$baz"])), + ("foo baz", Some(&["foo", "baz"])), + ("foo\"bar\"baz", Some(&["foobarbaz"])), + ("foo \"bar\"baz", Some(&["foo", "barbaz"])), + (" foo \nbar", Some(&["foo", "bar"])), + ("foo\\\nbar", Some(&["foobar"])), + ("\"foo\\\nbar\"", Some(&["foobar"])), + ("'baz\\$b'", Some(&["baz\\$b"])), + ("'baz\\\''", None), + ("\\", None), + ("\"\\", None), + ("'\\", None), + ("\"", None), + ("'", None), + ("foo #bar\nbaz", Some(&["foo", "baz"])), + ("foo #bar", Some(&["foo"])), + ("foo#bar", Some(&["foo#bar"])), + ("foo\"#bar", None), + ("'\\n'", Some(&["\\n"])), + ("'\\\\n'", Some(&["\\\\n"])), +]; + +#[test] +fn test_split() { + for &(input, output) in SPLIT_TEST_ITEMS { + assert_eq!(split(input), output.map(|o| o.iter().map(|&x| x.to_owned()).collect())); + } +} + +#[test] +fn test_lineno() { + let mut sh = Shlex::new("\nfoo\nbar"); + while let Some(word) = sh.next() { + if word == "bar" { + assert_eq!(sh.line_no, 3); + } + } +} + +#[test] +#[cfg_attr(not(feature = "std"), allow(unreachable_code, unused_mut))] +fn test_quote() { + // This is a list of (unquoted, quoted) pairs. + // But it's using a single long (raw) string literal with an ad-hoc format, just because it's + // hard to read if we have to put the test strings through Rust escaping on top of the escaping + // being tested. (Even raw string literals are noisy for short strings). + // Ad-hoc: "NL" is replaced with a literal newline; no other escape sequences. + let tests = r#" + <> => <''> + => + => <'foo bar'> + <"foo bar'"> => <"\"foo bar'\""> + <'foo bar'> => <"'foo bar'"> + <"> => <'"'> + <"'> => <"\"'"> + => <'hello!world'> + <'hello!world> => <"'hello"'!world'> + <'hello!> => <"'hello"'!'> + => <'hello ''^ world'> + => + => <'!world'"'"> + <{a, b}> => <'{a, b}'> + => <'NL'> + <^> => <'^'> + => + => <'NLx''^'> + => <'NL''^x'> + => <'NL ''^x'> + <{a,b}> => <'{a,b}'> + => <'a,b'> + + <'$> => <"'"'$'> + <"^> => <'"''^'> + "#; + let mut ok = true; + for test in tests.trim().split('\n') { + let parts: Vec = test + .replace("NL", "\n") + .split("=>") + .map(|part| part.trim().trim_start_matches('<').trim_end_matches('>').to_owned()) + .collect(); + assert!(parts.len() == 2); + let unquoted = &*parts[0]; + let quoted_expected = &*parts[1]; + let quoted_actual = try_quote(&parts[0]).unwrap(); + if quoted_expected != quoted_actual { + #[cfg(not(feature = "std"))] + panic!("FAIL: for input <{}>, expected <{}>, got <{}>", + unquoted, quoted_expected, quoted_actual); + #[cfg(feature = "std")] + println!("FAIL: for input <{}>, expected <{}>, got <{}>", + unquoted, quoted_expected, quoted_actual); + ok = false; + } + } + assert!(ok); +} + +#[test] +fn test_fallible() { + assert_eq!(try_join(vec!["\0"]), Err(QuoteError::Nul)); + assert_eq!(try_quote("\0"), Err(QuoteError::Nul)); +} diff --git a/http/vendor/shlex/src/quoting_warning.md b/http/vendor/shlex/src/quoting_warning.md new file mode 100644 index 0000000..15dcd0b --- /dev/null +++ b/http/vendor/shlex/src/quoting_warning.md @@ -0,0 +1,365 @@ +// vim: textwidth=99 +/* +Meta note: This file is loaded as a .rs file by rustdoc only. +*/ +/*! + +A more detailed version of the [warning at the top level](super#warning) about the `quote`/`join` +family of APIs. + +In general, passing the output of these APIs to a shell should recover the original string(s). +This page lists cases where it fails to do so. + +In noninteractive contexts, there are only minor issues. 'Noninteractive' includes shell scripts +and `sh -c` arguments, or even scripts `source`d from interactive shells. The issues are: + +- [Nul bytes](#nul-bytes) + +- [Overlong commands](#overlong-commands) + +If you are writing directly to the stdin of an interactive (`-i`) shell (i.e., if you are +pretending to be a terminal), or if you are writing to a cooked-mode pty (even if the other end is +noninteractive), then there is a **severe** security issue: + +- [Control characters](#control-characters-interactive-contexts-only) + +Finally, there are some [solved issues](#solved-issues). + +# List of issues + +## Nul bytes + +For non-interactive shells, the most problematic input is nul bytes (bytes with value 0). The +convenience functions all default to returning [`QuoteError::Nul`] when encountering them, but +[`Quoter::allow_nul`] or [`bytes::Quoter::allow_nul`] can be used to leave them as-is. + +In Unix, nul bytes can't appear in command arguments, environment variables, or filenames. It's +not a question of proper quoting; they just can't be used at all. This is a consequence of Unix's +system calls all being designed around nul-terminated C strings. + +Shells inherit that limitation. Most of them do not accept nul bytes in strings even internally. +Even when they do, it's pretty much useless or even dangerous, since you can't pass them to +external commands. + +In some cases, you might fail to pass the nul byte to the shell in the first place. For example, +the following code uses [`Quoter::join`] to tunnel a command over an SSH connection: + +```rust +std::process::Command::new("ssh") + .arg("myhost") + .arg("--") + .arg(Quoter::new().allow_nul(true).join(my_cmd_args).unwrap()) +``` + +If any argument in `my_cmd_args` contains a nul byte, then `join(my_cmd_args)` will contain a nul +byte. But `join(my_cmd_args)` is itself being passed as an argument to a command (the ssh +command), and command arguments can't contain nul bytes! So this will simply result in the +`Command` failing to launch. + +Still, there are other ways to smuggle nul bytes into a shell. How the shell reacts depends on the +shell and the method of smuggling. For example, here is Bash 5.2.21 exhibiting three different +behaviors: + +- With ANSI-C quoting, the string is truncated at the first nul byte: + ```bash + $ echo $'foo\0bar' | hexdump -C + 00000000 66 6f 6f 0a |foo.| + ``` + +- With command substitution, nul bytes are removed with a warning: + ```bash + $ echo $(printf 'foo\0bar') | hexdump -C + bash: warning: command substitution: ignored null byte in input + 00000000 66 6f 6f 62 61 72 0a |foobar.| + ``` + +- When a nul byte appears directly in a shell script, it's removed with no warning: + ```bash + $ printf 'echo "foo\0bar"' | bash | hexdump -C + 00000000 66 6f 6f 62 61 72 0a |foobar.| + ``` + +Zsh, in contrast, actually allows nul bytes internally, in shell variables and even arguments to +builtin commands. But if a variable is exported to the environment, or if an argument is used for +an external command, then the child process will see it silently truncated at the first nul. This +might actually be more dangerous, depending on the use case. + +## Overlong commands + +If you pass a long string into a shell, several things might happen: + +- It might succeed, yet the shell might have trouble actually doing anything with it. For example: + + ```bash + x=$(printf '%010000000d' 0); /bin/echo $x + bash: /bin/echo: Argument list too long + ``` + +- If you're using certain shells (e.g. Busybox Ash) *and* using a pty for communication, then the + shell will impose a line length limit, ignoring all input past the limit. + +- If you're using a pty in cooked mode, then by default, if you write so many bytes as input that + it fills the kernel's internal buffer, the kernel will simply drop those bytes, instead of + blocking waiting for the shell to empty out the buffer. In other words, random bits of input can + be lost, which is obviously insecure. + +Future versions of this crate may add an option to [`Quoter`] to check the length for you. + +## Control characters (*interactive contexts only*) + +Control characters are the bytes from `\x00` to `\x1f`, plus `\x7f`. `\x00` (the nul byte) is +discussed [above](#nul-bytes), but what about the rest? Well, many of them correspond to terminal +keyboard shortcuts. For example, when you press Ctrl-A at a shell prompt, your terminal sends the +byte `\x01`. The shell sees that byte and (if not configured differently) takes the standard +action for Ctrl-A, which is to move the cursor to the beginning of the line. + +This means that it's quite dangerous to pipe bytes to an interactive shell. For example, here is a +program that tries to tell Bash to echo an arbitrary string, 'safely': +```rust +use std::process::{Command, Stdio}; +use std::io::Write; + +let evil_string = "\x01do_something_evil; "; +let quoted = shlex::try_quote(evil_string).unwrap(); +println!("quoted string is {:?}", quoted); + +let mut bash = Command::new("bash") + .arg("-i") // force interactive mode + .stdin(Stdio::piped()) + .spawn() + .unwrap(); +let stdin = bash.stdin.as_mut().unwrap(); +write!(stdin, "echo {}\n", quoted).unwrap(); +``` + +Here's the output of the program (with irrelevant bits removed): + +```text +quoted string is "'\u{1}do_something_evil; '" +/tmp comex$ do_something_evil; 'echo ' +bash: do_something_evil: command not found +bash: echo : command not found +``` + +Even though we quoted it, Bash still ran an arbitrary command! + +This is not because the quoting was insufficient, per se. In single quotes, all input is supposed +to be treated as raw data until the closing single quote. And in fact, this would work fine +without the `"-i"` argument. + +But line input is a separate stage from shell syntax parsing. After all, if you type a single +quote on the keyboard, you wouldn't expect it to disable all your keyboard shortcuts. So a control +character always has its designated effect, no matter if it's quoted or backslash-escaped. + +Also, some control characters are interpreted by the kernel tty layer instead, like CTRL-C to send +SIGINT. These can be an issue even with noninteractive shells, but only if using a pty for +communication, as opposed to a pipe. + +To be safe, you just have to avoid sending them. + +### Why not just use hex escapes? + +In any normal programming languages, this would be no big deal. + +Any normal language has a way to escape arbitrary characters in strings by writing out their +numeric values. For example, Rust lets you write them in hexadecimal, like `"\x4f"` (or +`"\u{1d546}"` for Unicode). In this way, arbitrary strings can be represented using only 'nice' +simple characters. Any remotely suspicious character can be replaced with a numeric escape +sequence, where the escape sequence itself consists only of alphanumeric characters and some +punctuation. The result may not be the most readable[^choices], but it's quite safe from being +misinterpreted or corrupted in transit. + +Shell is not normal. It has no numeric escape sequences. + +There are a few different ways to quote characters (unquoted, unquoted-with-backslash, single +quotes, double quotes), but all of them involve writing the character itself. If the input +contains a control character, the output must contain that same character. + +### Mitigation: terminal filters + +In practice, automating interactive shells like in the above example is pretty uncommon these days. +In most cases, the only way for a programmatically generated string to make its way to the input of +an interactive shell is if a human copies and pastes it into their terminal. + +And many terminals detect when you paste a string containing control characters. iTerm2 strips +them out; gnome-terminal replaces them with alternate characters[^gr]; Kitty outright prompts for +confirmation. This mitigates the risk. + +But it's not perfect. Some other terminals don't implement this check or implement it incorrectly. +Also, these checks tend to not filter the tab character, which could trigger tab completion. In +most cases that's a non-issue, because most shells support paste bracketing, which disables tab and +some other control characters[^bracketing] within pasted text. But in some cases paste bracketing +gets disabled. + +### Future possibility: ANSI-C quoting + +I said that shell syntax has no numeric escapes, but that only applies to *portable* shell syntax. +Bash and Zsh support an obscure alternate quoting style with the syntax `$'foo'`. It's called +["ANSI-C quoting"][ansic], and inside it you can use all the escape sequences supported by C, +including hex escapes: + +```bash +$ echo $'\x41\n\x42' +A +B +``` + +But other shells don't support it — including Dash, a popular choice for `/bin/sh`, and Busybox's +Ash, frequently seen on stripped-down embedded systems. This crate's quoting functionality [tries +to be compatible](crate#compatibility) with those shells, plus all other POSIX-compatible shells. +That makes ANSI-C quoting a no-go. + +Still, future versions of this crate may provide an option to enable ANSI-C quoting, at the cost of +reduced portability. + +### Future possibility: printf + +Another option would be to invoke the `printf` command, which is required by POSIX to support octal +escapes. For example, you could 'escape' the Rust string `"\x01"` into the shell syntax `"$(printf +'\001')"`. The shell will execute the command `printf` with the first argument being literally a +backslash followed by three digits; `printf` will output the actual byte with value 1; and the +shell will substitute that back into the original command. + +The problem is that 'escaping' a string into a command substitution just feels too surprising. If +nothing else, it only works with an actual shell; [other languages' shell parsing +routines](crate#compatibility) wouldn't understand it. Neither would this crate's own parser, +though that could be fixed. + +Future versions of this crate may provide an option to use `printf` for quoting. + +### Special note: newlines + +Did you know that `\r` and `\n` are control characters? They aren't as dangerous as other control +characters (if quoted properly). But there's still an issue with them in interactive contexts. + +Namely, in some cases, interactive shells and/or the tty layer will 'helpfully' translate between +different line ending conventions. The possibilities include replacing `\r` with `\n`, replacing +`\n` with `\r\n`, and others. This can't result in command injection, but it's still a lossy +transformation which can result in a failure to round-trip (i.e. the shell sees a different string +from what was originally passed to `quote`). + +Numeric escapes would solve this as well. + +# Solved issues + +## Solved: Past vulnerability (GHSA-r7qv-8r2h-pg27 / RUSTSEC-2024-0006) + +Versions of this crate before 1.3.0 did not quote `{`, `}`, and `\xa0`. + +See: +- +- + +## Solved: `!` and `^` + +There are two non-control characters which have a special meaning in interactive contexts only: `!` and +`^`. Luckily, these can be escaped adequately. + +The `!` character triggers [history expansion][he]; the `^` character can trigger a variant of +history expansion known as [Quick Substitution][qs]. Both of these characters get expanded even +inside of double-quoted strings\! + +If we're in a double-quoted string, then we can't just escape these characters with a backslash. +Only a specific set of characters can be backslash-escaped inside double quotes; the set of +supported characters depends on the shell, but it often doesn't include `!` and `^`.[^escbs] +Trying to backslash-escape an unsupported character produces a literal backslash: +```bash +$ echo "\!" +\! +``` + +However, these characters don't get expanded in single-quoted strings, so this crate just +single-quotes them. + +But there's a Bash bug where `^` actually does get partially expanded in single-quoted strings: +```bash +$ echo ' +> ^a^b +> ' + +!!:s^a^b +``` + +To work around that, this crate forces `^` to appear right after an opening single quote. For +example, the string `"^` is quoted into `'"''^'` instead of `'"^'`. This restriction is overkill, +since `^` is only meaningful right after a newline, but it's a sufficient restriction (after all, a +`^` character can't be preceded by a newline if it's forced to be preceded by a single quote), and +for now it simplifies things. + +## Solved: `\xa0` + +The byte `\xa0` may be treated as a shell word separator, specifically on Bash on macOS when using +the default UTF-8 locale, only when the input is invalid UTF-8. This crate handles the issue by +always using quotes for arguments containing this byte. + +In fact, this crate always uses quotes for arguments containing any non-ASCII bytes. This may be +changed in the future, since it's a bit unfriendly to non-English users. But for now it +minimizes risk, especially considering the large number of different legacy single-byte locales +someone might hypothetically be running their shell in. + +### Demonstration + +```bash +$ echo -e 'ls a\xa0b' | bash +ls: a: No such file or directory +ls: b: No such file or directory +``` +The normal behavior would be to output a single line, e.g.: +```bash +$ echo -e 'ls a\xa0b' | bash +ls: cannot access 'a'$'\240''b': No such file or directory +``` +(The specific quoting in the error doesn't matter.) + +### Cause + +Just for fun, here's why this behavior occurs: + +Bash decides which bytes serve as word separators based on the libc function [`isblank`][isblank]. +On macOS on UTF-8 locales, this passes for `\xa0`, corresponding to U+00A0 NO-BREAK SPACE. + +This is doubly unique compared to the other systems I tested (Linux/glibc, Linux/musl, and +Windows/MSVC). First, the other systems don't allow bytes in the range [0x80, 0xFF] to pass +isfoo functions in UTF-8 locales, even if the corresponding Unicode codepoint +does pass, as determined by the wide-character equivalent function, iswfoo. +Second, the other systems don't treat U+00A0 as blank (even using `iswblank`). + +Meanwhile, Bash checks for multi-byte sequences and forbids them from being treated as special +characters, so the proper UTF-8 encoding of U+00A0, `b"\xc2\xa0"`, is not treated as a word +separator. Treatment as a word separator only happens for `b"\xa0"` alone, which is illegal UTF-8. + +[ansic]: https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html +[he]: https://www.gnu.org/software/bash/manual/html_node/History-Interaction.html +[qs]: https://www.gnu.org/software/bash/manual/html_node/Event-Designators.html +[isblank]: https://man7.org/linux/man-pages/man3/isblank.3p.html +[nul]: #nul-bytes + +[^choices]: This can lead to tough choices over which + characters to escape and which to leave as-is, especially when Unicode gets involved and you + have to balance the risk of confusion with the benefit of properly supporting non-English + languages. +
+
+ We don't have the luxury of those choices. + +[^gr]: For example, backspace (in Unicode lingo, U+0008 BACKSPACE) turns into U+2408 SYMBOL FOR BACKSPACE. + +[^bracketing]: It typically disables almost all handling of control characters by the shell proper, + but one necessary exception is the end-of-paste sequence itself (which starts with the control + character `\x1b`). In addition, paste bracketing does not suppress handling of control + characters by the kernel tty layer, such as `\x03` sending SIGINT (which typically clears the + currently typed command, making it dangerous in a similar way to `\x01`). + +[^escbs]: For example, Dash doesn't remove the backslash from `"\!"` because it simply doesn't know + anything about `!` as a special character: it doesn't support history expansion. On the other + end of the spectrum, Zsh supports history expansion and does remove the backslash — though only + in interactive mode. Bash's behavior is weirder. It supports history expansion, and if you + write `"\!"`, the backslash does prevent history expansion from occurring — but it doesn't get + removed! + +*/ + +// `use` declarations to make auto links work: +use crate::{bytes, Shlex, Quoter, QuoteError}; + +// TODO: add more about copy-paste and human readability. diff --git a/http/vendor/subtle/.cargo-checksum.json b/http/vendor/subtle/.cargo-checksum.json new file mode 100644 index 0000000..1c58592 --- /dev/null +++ b/http/vendor/subtle/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{".cargo_vcs_info.json":"7d885b684d7e5fb3dd82cb4d9c093bff170cd2ac7c2d03b37721c93fc371a290",".github/workflows/test.yml":"93e02ec47355f7703ea786d49e9fbdbff5120c0eb65e93bae8c0b57fd0aa4d83","CHANGELOG.md":"02f92a31269311c965b1dfa705f22f341dc9cce73af08a8c9840c91b8ceb79df","CONTRIBUTING.md":"2fbb44138ececdef7c0950fae6ed1dcad481fb2f368df0e3734c9902be791f3e","Cargo.toml":"a3b9aefa358b0cd742de62e880ea080414ead838847a95892acaa58575dfc4cf","Cargo.toml.orig":"96e660a887170f9c01deb01a166b5e0c881a3e8fb7d5fe78658c7ce5eef3440d","LICENSE":"d1fc1bc0d155df60b2e7705b6b2ae02a05c96f948e1cec6e2fb86360b09f346b","README.md":"3c538225aea51d063002e1b9732904053061914993f7ec880a18bd597d9df49b","src/lib.rs":"ced6ebd3622af527cbbbb09feb57a2894751ff07e7ca8f97f22bad89401e5c8d","tests/mod.rs":"11223367ef0f5555bd7c5d52dbbc3cee481207208af82319e5c33eadf7a18c08"},"package":"13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"} \ No newline at end of file diff --git a/http/vendor/subtle/.cargo_vcs_info.json b/http/vendor/subtle/.cargo_vcs_info.json new file mode 100644 index 0000000..5265798 --- /dev/null +++ b/http/vendor/subtle/.cargo_vcs_info.json @@ -0,0 +1,6 @@ +{ + "git": { + "sha1": "5457b5448b021d1da101ababbb854e6657233943" + }, + "path_in_vcs": "" +} \ No newline at end of file diff --git a/http/vendor/subtle/.github/workflows/test.yml b/http/vendor/subtle/.github/workflows/test.yml new file mode 100644 index 0000000..7c1616a --- /dev/null +++ b/http/vendor/subtle/.github/workflows/test.yml @@ -0,0 +1,64 @@ +on: [push, pull_request] + +name: Test + +jobs: + test: + name: cargo test + runs-on: ubuntu-latest + strategy: + matrix: + rust: + - stable + - beta + - nightly + - 1.60.0 + steps: + - name: checkout + uses: actions/checkout@v2 + - name: toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: ${{ matrix.rust }} + target: thumbv7em-none-eabi + override: true + - name: test + uses: actions-rs/cargo@v1 + with: + command: test + - name: nightly + uses: actions-rs/cargo@v1 + with: + command: test + args: --features nightly + - name: no-default-features + uses: actions-rs/cargo@v1 + with: + command: test + args: --no-default-features + - name: std + uses: actions-rs/cargo@v1 + with: + command: test + args: --no-default-features --features std + - name: std const-generics + uses: actions-rs/cargo@v1 + with: + command: test + args: --no-default-features --features "std const-generics" + - name: std i128 + uses: actions-rs/cargo@v1 + with: + command: test + args: --no-default-features --features "std i128" + - name: std i128 const-generics + uses: actions-rs/cargo@v1 + with: + command: test + args: --no-default-features --features "std i128 const-generics" + - name: no std build + uses: actions-rs/cargo@v1 + with: + command: build + args: --no-default-features --target thumbv7em-none-eabi diff --git a/http/vendor/subtle/CHANGELOG.md b/http/vendor/subtle/CHANGELOG.md new file mode 100644 index 0000000..e6a3863 --- /dev/null +++ b/http/vendor/subtle/CHANGELOG.md @@ -0,0 +1,74 @@ +# Changelog + +Entries are listed in reverse chronological order. + +## 2.5.0 + +* Add constant-timedness note to the documentation for `CtOption::unwrap_or_else`. +* Add `CtOption::expect`. +* Add `ConstantTimeEq::ct_ne` with default implementation. +* Add new `core_hint_black_box` feature from Diane Hosfelt and Amber + Sprenkels which utilises the original `black_box` functionality from + when subtle was first written, which has now found it's way into the + Rust standard library. +* Add new `const-generics` feature from @survived which adds support + for subtle traits for generic arrays `[T; N]`. +* Add new feature for supporting `core::cmp::Ordering` for types which + implement subtle traits, patch from @tarcieri. +* Update `rand` dependency to 0.8. + +## 2.4.1 + +* Fix a bug in how the README was included in the documentation builds + which caused nightly builds to break. + +## 2.4.0 + +* Add new `ConstantTimeGreater` and `ConstantTimeLess` traits, as well + as implementations for unsigned integers, by @isislovecruft. + +## 2.3.0 + +* Add `impl ConstantTimeEq for Choice` by @tarcieri. +* Add `impl From> for Option` by @CPerezz. This is useful for + handling library code that produces `CtOption`s in contexts where timing + doesn't matter. +* Introduce an MSRV policy. + +## 2.2.3 + +* Remove the `nightly`-only asm-based `black_box` barrier in favor of the + volatile-based one, fixing compilation on current nightlies. + +## 2.2.2 + +* Update README.md to clarify that 2.2 and above do not require the `nightly` + feature. + +## 2.2.1 + +* Adds an `or_else` combinator for `CtOption`, by @ebfull. +* Optimized `black_box` for `nightly`, by @jethrogb. +* Optimized `black_box` for `stable`, by @dsprenkels. +* Fixed CI for `no_std`, by @dsprenkels. +* Fixed fuzz target compilation, by @3for. + +## 2.2.0 + +* Error during `cargo publish`, yanked. + +## 2.1.1 + +* Adds the "crypto" tag to crate metadata. +* New shorter, more efficient ct_eq() for integers, contributed by Thomas Pornin. + +## 2.1.0 + +* Adds a new `CtOption` which acts as a constant-time `Option` + (thanks to @ebfull for the implementation). +* `Choice` now itself implements `ConditionallySelectable`. + +## 2.0.0 + +* Stable version with traits reworked from 1.0.0 to interact better + with the orphan rules. diff --git a/http/vendor/subtle/CONTRIBUTING.md b/http/vendor/subtle/CONTRIBUTING.md new file mode 100644 index 0000000..2d24605 --- /dev/null +++ b/http/vendor/subtle/CONTRIBUTING.md @@ -0,0 +1,33 @@ +# Contributing to subtle + +If you have questions or comments, please feel free to email the +authors. + +For feature requests, suggestions, and bug reports, please open an +issue on [our Github](https://github.com/dalek-cryptography/subtle). (Or, +send us an email if you're opposed to using Github for whatever reason.) + +Patches are welcomed as pull requests on +[our Github](https://github.com/dalek-cryptography/subtle), as well as by +email (preferably sent to all of the authors listed in `Cargo.toml`). + +We're happy to take generalised utility code, provided the code is: + +1. constant time for all potential valid invocations, and +2. applicable to implementations of several different protocols/primitives. + +All issues on subtle are mentored, if you want help with a bug just ask +@isislovecruft or @hdevalence. + +Some issues are easier than others. The `easy` label can be used to find the +easy issues. If you want to work on an issue, please leave a comment so that we +can assign it to you! + +# Code of Conduct + +We follow the [Rust Code of Conduct](http://www.rust-lang.org/conduct.html), +with the following additional clauses: + +* We respect the rights to privacy and anonymity for contributors and people in + the community. If someone wishes to contribute under a pseudonym different to + their primary identity, that wish is to be respected by all contributors. diff --git a/http/vendor/subtle/Cargo.toml b/http/vendor/subtle/Cargo.toml new file mode 100644 index 0000000..bf78f6f --- /dev/null +++ b/http/vendor/subtle/Cargo.toml @@ -0,0 +1,70 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies. +# +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. + +[package] +edition = "2018" +name = "subtle" +version = "2.6.1" +authors = [ + "Isis Lovecruft ", + "Henry de Valence ", +] +build = false +exclude = [ + "**/.gitignore", + ".travis.yml", +] +autobins = false +autoexamples = false +autotests = false +autobenches = false +description = "Pure-Rust traits and utilities for constant-time cryptographic implementations." +homepage = "https://dalek.rs/" +documentation = "https://docs.rs/subtle" +readme = "README.md" +keywords = [ + "cryptography", + "crypto", + "constant-time", + "utilities", +] +categories = [ + "cryptography", + "no-std", +] +license = "BSD-3-Clause" +repository = "https://github.com/dalek-cryptography/subtle" + +[lib] +name = "subtle" +path = "src/lib.rs" + +[[test]] +name = "mod" +path = "tests/mod.rs" + +[dev-dependencies.rand] +version = "0.8" + +[features] +const-generics = [] +core_hint_black_box = [] +default = [ + "std", + "i128", +] +i128 = [] +nightly = [] +std = [] + +[badges.travis-ci] +branch = "main" +repository = "dalek-cryptography/subtle" diff --git a/http/vendor/subtle/Cargo.toml.orig b/http/vendor/subtle/Cargo.toml.orig new file mode 100644 index 0000000..0a313ee --- /dev/null +++ b/http/vendor/subtle/Cargo.toml.orig @@ -0,0 +1,39 @@ +[package] +name = "subtle" +# Before incrementing: +# - update CHANGELOG +# - update html_root_url +# - update README if necessary by semver +# - if any updates were made to the README, also update the module documentation in src/lib.rs +version = "2.6.1" +edition = "2018" +authors = ["Isis Lovecruft ", + "Henry de Valence "] +readme = "README.md" +license = "BSD-3-Clause" +repository = "https://github.com/dalek-cryptography/subtle" +homepage = "https://dalek.rs/" +documentation = "https://docs.rs/subtle" +categories = ["cryptography", "no-std"] +keywords = ["cryptography", "crypto", "constant-time", "utilities"] +description = "Pure-Rust traits and utilities for constant-time cryptographic implementations." +exclude = [ + "**/.gitignore", + ".travis.yml", +] + +[badges] +travis-ci = { repository = "dalek-cryptography/subtle", branch = "main"} + +[dev-dependencies] +rand = { version = "0.8" } + +[features] +const-generics = [] +# DEPRECATED: As of 2.5.1, this feature does nothing. +core_hint_black_box = [] +default = ["std", "i128"] +std = [] +i128 = [] +# DEPRECATED: As of 2.4.1, this feature does nothing. +nightly = [] diff --git a/http/vendor/subtle/LICENSE b/http/vendor/subtle/LICENSE new file mode 100644 index 0000000..9e2751f --- /dev/null +++ b/http/vendor/subtle/LICENSE @@ -0,0 +1,29 @@ +Copyright (c) 2016-2017 Isis Agora Lovecruft, Henry de Valence. All rights reserved. +Copyright (c) 2016-2024 Isis Agora Lovecruft. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +1. Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/http/vendor/subtle/README.md b/http/vendor/subtle/README.md new file mode 100644 index 0000000..a9eb261 --- /dev/null +++ b/http/vendor/subtle/README.md @@ -0,0 +1,74 @@ +# subtle [![](https://img.shields.io/crates/v/subtle.svg)](https://crates.io/crates/subtle) [![](https://img.shields.io/badge/dynamic/json.svg?label=docs&uri=https%3A%2F%2Fcrates.io%2Fapi%2Fv1%2Fcrates%2Fsubtle%2Fversions&query=%24.versions%5B0%5D.num&colorB=4F74A6)](https://doc.dalek.rs/subtle) [![](https://travis-ci.org/dalek-cryptography/subtle.svg?branch=master)](https://travis-ci.org/dalek-cryptography/subtle) + +**Pure-Rust traits and utilities for constant-time cryptographic implementations.** + +It consists of a `Choice` type, and a collection of traits using `Choice` +instead of `bool` which are intended to execute in constant-time. The `Choice` +type is a wrapper around a `u8` that holds a `0` or `1`. + +```toml +subtle = "2.6" +``` + +This crate represents a “best-effort” attempt, since side-channels +are ultimately a property of a deployed cryptographic system +including the hardware it runs on, not just of software. + +The traits are implemented using bitwise operations, and should execute in +constant time provided that a) the bitwise operations are constant-time and +b) the bitwise operations are not recognized as a conditional assignment and +optimized back into a branch. + +For a compiler to recognize that bitwise operations represent a conditional +assignment, it needs to know that the value used to generate the bitmasks is +really a boolean `i1` rather than an `i8` byte value. In an attempt to +prevent this refinement, the crate tries to hide the value of a `Choice`'s +inner `u8` by passing it through a volatile read. For more information, see +the _About_ section below. + +Rust versions from 1.51 or higher have const generics support. You may enable +`const-generics` feautre to have `subtle` traits implemented for arrays `[T; N]`. + +Versions prior to `2.2` recommended use of the `nightly` feature to enable an +optimization barrier; this is not required in versions `2.2` and above. + +Note: the `subtle` crate contains `debug_assert`s to check invariants during +debug builds. These invariant checks involve secret-dependent branches, and +are not present when compiled in release mode. This crate is intended to be +used in release mode. + +## Documentation + +Documentation is available [here][docs]. + +## Minimum Supported Rust Version + +Rust **1.41** or higher. + +Minimum supported Rust version can be changed in the future, but it will be done with a minor version bump. + +## About + +This library aims to be the Rust equivalent of Go’s `crypto/subtle` module. + +Old versions of the optimization barrier in `impl From for Choice` were +based on Tim Maclean's [work on `rust-timing-shield`][rust-timing-shield], +which attempts to provide a more comprehensive approach for preventing +software side-channels in Rust code. +From version `2.2`, it was based on Diane Hosfelt and Amber Sprenkels' work on +"Secret Types in Rust". + +`subtle` is authored by isis agora lovecruft and Henry de Valence. + +## Warning + +This code is a low-level library, intended for specific use-cases implementing +cryptographic protocols. It represents a best-effort attempt to protect +against some software side-channels. Because side-channel resistance is not a +property of software alone, but of software together with hardware, any such +effort is fundamentally limited. + +**USE AT YOUR OWN RISK** + +[docs]: https://docs.rs/subtle +[rust-timing-shield]: https://www.chosenplaintext.ca/open-source/rust-timing-shield/security diff --git a/http/vendor/subtle/src/lib.rs b/http/vendor/subtle/src/lib.rs new file mode 100644 index 0000000..9fc143b --- /dev/null +++ b/http/vendor/subtle/src/lib.rs @@ -0,0 +1,1008 @@ +// -*- mode: rust; -*- +// +// This file is part of subtle, part of the dalek cryptography project. +// Copyright (c) 2016-2018 isis lovecruft, Henry de Valence +// See LICENSE for licensing information. +// +// Authors: +// - isis agora lovecruft +// - Henry de Valence + +#![no_std] +#![deny(missing_docs)] +#![doc(html_logo_url = "https://doc.dalek.rs/assets/dalek-logo-clear.png")] +#![doc(html_root_url = "https://docs.rs/subtle/2.6.0")] + +//! # subtle [![](https://img.shields.io/crates/v/subtle.svg)](https://crates.io/crates/subtle) [![](https://img.shields.io/badge/dynamic/json.svg?label=docs&uri=https%3A%2F%2Fcrates.io%2Fapi%2Fv1%2Fcrates%2Fsubtle%2Fversions&query=%24.versions%5B0%5D.num&colorB=4F74A6)](https://doc.dalek.rs/subtle) [![](https://travis-ci.org/dalek-cryptography/subtle.svg?branch=master)](https://travis-ci.org/dalek-cryptography/subtle) +//! +//! **Pure-Rust traits and utilities for constant-time cryptographic implementations.** +//! +//! It consists of a `Choice` type, and a collection of traits using `Choice` +//! instead of `bool` which are intended to execute in constant-time. The `Choice` +//! type is a wrapper around a `u8` that holds a `0` or `1`. +//! +//! ```toml +//! subtle = "2.6" +//! ``` +//! +//! This crate represents a “best-effort” attempt, since side-channels +//! are ultimately a property of a deployed cryptographic system +//! including the hardware it runs on, not just of software. +//! +//! The traits are implemented using bitwise operations, and should execute in +//! constant time provided that a) the bitwise operations are constant-time and +//! b) the bitwise operations are not recognized as a conditional assignment and +//! optimized back into a branch. +//! +//! For a compiler to recognize that bitwise operations represent a conditional +//! assignment, it needs to know that the value used to generate the bitmasks is +//! really a boolean `i1` rather than an `i8` byte value. In an attempt to +//! prevent this refinement, the crate tries to hide the value of a `Choice`'s +//! inner `u8` by passing it through a volatile read. For more information, see +//! the _About_ section below. +//! +//! Rust versions from 1.51 or higher have const generics support. You may enable +//! `const-generics` feautre to have `subtle` traits implemented for arrays `[T; N]`. +//! +//! Versions prior to `2.2` recommended use of the `nightly` feature to enable an +//! optimization barrier; this is not required in versions `2.2` and above. +//! +//! Note: the `subtle` crate contains `debug_assert`s to check invariants during +//! debug builds. These invariant checks involve secret-dependent branches, and +//! are not present when compiled in release mode. This crate is intended to be +//! used in release mode. +//! +//! ## Documentation +//! +//! Documentation is available [here][docs]. +//! +//! ## Minimum Supported Rust Version +//! +//! Rust **1.41** or higher. +//! +//! Minimum supported Rust version can be changed in the future, but it will be done with a minor version bump. +//! +//! ## About +//! +//! This library aims to be the Rust equivalent of Go’s `crypto/subtle` module. +//! +//! Old versions of the optimization barrier in `impl From for Choice` were +//! based on Tim Maclean's [work on `rust-timing-shield`][rust-timing-shield], +//! which attempts to provide a more comprehensive approach for preventing +//! software side-channels in Rust code. +//! From version `2.2`, it was based on Diane Hosfelt and Amber Sprenkels' work on +//! "Secret Types in Rust". +//! +//! `subtle` is authored by isis agora lovecruft and Henry de Valence. +//! +//! ## Warning +//! +//! This code is a low-level library, intended for specific use-cases implementing +//! cryptographic protocols. It represents a best-effort attempt to protect +//! against some software side-channels. Because side-channel resistance is not a +//! property of software alone, but of software together with hardware, any such +//! effort is fundamentally limited. +//! +//! **USE AT YOUR OWN RISK** +//! +//! [docs]: https://docs.rs/subtle +//! [rust-timing-shield]: https://www.chosenplaintext.ca/open-source/rust-timing-shield/security + +#[cfg(feature = "std")] +#[macro_use] +extern crate std; + +use core::cmp; +use core::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Neg, Not}; +use core::option::Option; + +#[cfg(feature = "core_hint_black_box")] +use core::hint::black_box; + +/// The `Choice` struct represents a choice for use in conditional assignment. +/// +/// It is a wrapper around a `u8`, which should have the value either `1` (true) +/// or `0` (false). +/// +/// The conversion from `u8` to `Choice` passes the value through an optimization +/// barrier, as a best-effort attempt to prevent the compiler from inferring that +/// the `Choice` value is a boolean. This strategy is based on Tim Maclean's +/// [work on `rust-timing-shield`][rust-timing-shield], which attempts to provide +/// a more comprehensive approach for preventing software side-channels in Rust +/// code. +/// +/// The `Choice` struct implements operators for AND, OR, XOR, and NOT, to allow +/// combining `Choice` values. These operations do not short-circuit. +/// +/// [rust-timing-shield]: +/// https://www.chosenplaintext.ca/open-source/rust-timing-shield/security +#[derive(Copy, Clone, Debug)] +pub struct Choice(u8); + +impl Choice { + /// Unwrap the `Choice` wrapper to reveal the underlying `u8`. + /// + /// # Note + /// + /// This function only exists as an **escape hatch** for the rare case + /// where it's not possible to use one of the `subtle`-provided + /// trait impls. + /// + /// **To convert a `Choice` to a `bool`, use the `From` implementation instead.** + #[inline] + pub fn unwrap_u8(&self) -> u8 { + self.0 + } +} + +impl From for bool { + /// Convert the `Choice` wrapper into a `bool`, depending on whether + /// the underlying `u8` was a `0` or a `1`. + /// + /// # Note + /// + /// This function exists to avoid having higher-level cryptographic protocol + /// implementations duplicating this pattern. + /// + /// The intended use case for this conversion is at the _end_ of a + /// higher-level primitive implementation: for example, in checking a keyed + /// MAC, where the verification should happen in constant-time (and thus use + /// a `Choice`) but it is safe to return a `bool` at the end of the + /// verification. + #[inline] + fn from(source: Choice) -> bool { + debug_assert!((source.0 == 0u8) | (source.0 == 1u8)); + source.0 != 0 + } +} + +impl BitAnd for Choice { + type Output = Choice; + #[inline] + fn bitand(self, rhs: Choice) -> Choice { + (self.0 & rhs.0).into() + } +} + +impl BitAndAssign for Choice { + #[inline] + fn bitand_assign(&mut self, rhs: Choice) { + *self = *self & rhs; + } +} + +impl BitOr for Choice { + type Output = Choice; + #[inline] + fn bitor(self, rhs: Choice) -> Choice { + (self.0 | rhs.0).into() + } +} + +impl BitOrAssign for Choice { + #[inline] + fn bitor_assign(&mut self, rhs: Choice) { + *self = *self | rhs; + } +} + +impl BitXor for Choice { + type Output = Choice; + #[inline] + fn bitxor(self, rhs: Choice) -> Choice { + (self.0 ^ rhs.0).into() + } +} + +impl BitXorAssign for Choice { + #[inline] + fn bitxor_assign(&mut self, rhs: Choice) { + *self = *self ^ rhs; + } +} + +impl Not for Choice { + type Output = Choice; + #[inline] + fn not(self) -> Choice { + (1u8 & (!self.0)).into() + } +} + +/// This function is a best-effort attempt to prevent the compiler from knowing +/// anything about the value of the returned `u8`, other than its type. +/// +/// Because we want to support stable Rust, we don't have access to inline +/// assembly or test::black_box, so we use the fact that volatile values will +/// never be elided to register values. +/// +/// Note: Rust's notion of "volatile" is subject to change over time. While this +/// code may break in a non-destructive way in the future, “constant-time” code +/// is a continually moving target, and this is better than doing nothing. +#[cfg(not(feature = "core_hint_black_box"))] +#[inline(never)] +fn black_box(input: T) -> T { + unsafe { + // Optimization barrier + // + // SAFETY: + // - &input is not NULL because we own input; + // - input is Copy and always live; + // - input is always properly aligned. + core::ptr::read_volatile(&input) + } +} + +impl From for Choice { + #[inline] + fn from(input: u8) -> Choice { + debug_assert!((input == 0u8) | (input == 1u8)); + + // Our goal is to prevent the compiler from inferring that the value held inside the + // resulting `Choice` struct is really a `bool` instead of a `u8`. + Choice(black_box(input)) + } +} + +/// An `Eq`-like trait that produces a `Choice` instead of a `bool`. +/// +/// # Example +/// +/// ``` +/// use subtle::ConstantTimeEq; +/// let x: u8 = 5; +/// let y: u8 = 13; +/// +/// assert_eq!(x.ct_eq(&y).unwrap_u8(), 0); +/// assert_eq!(x.ct_eq(&x).unwrap_u8(), 1); +/// ``` +// +// #[inline] is specified on these function prototypes to signify that they +#[allow(unused_attributes)] // should be in the actual implementation +pub trait ConstantTimeEq { + /// Determine if two items are equal. + /// + /// The `ct_eq` function should execute in constant time. + /// + /// # Returns + /// + /// * `Choice(1u8)` if `self == other`; + /// * `Choice(0u8)` if `self != other`. + #[inline] + #[allow(unused_attributes)] + fn ct_eq(&self, other: &Self) -> Choice; + + /// Determine if two items are NOT equal. + /// + /// The `ct_ne` function should execute in constant time. + /// + /// # Returns + /// + /// * `Choice(0u8)` if `self == other`; + /// * `Choice(1u8)` if `self != other`. + #[inline] + fn ct_ne(&self, other: &Self) -> Choice { + !self.ct_eq(other) + } +} + +impl ConstantTimeEq for [T] { + /// Check whether two slices of `ConstantTimeEq` types are equal. + /// + /// # Note + /// + /// This function short-circuits if the lengths of the input slices + /// are different. Otherwise, it should execute in time independent + /// of the slice contents. + /// + /// Since arrays coerce to slices, this function works with fixed-size arrays: + /// + /// ``` + /// # use subtle::ConstantTimeEq; + /// # + /// let a: [u8; 8] = [0,1,2,3,4,5,6,7]; + /// let b: [u8; 8] = [0,1,2,3,0,1,2,3]; + /// + /// let a_eq_a = a.ct_eq(&a); + /// let a_eq_b = a.ct_eq(&b); + /// + /// assert_eq!(a_eq_a.unwrap_u8(), 1); + /// assert_eq!(a_eq_b.unwrap_u8(), 0); + /// ``` + #[inline] + fn ct_eq(&self, _rhs: &[T]) -> Choice { + let len = self.len(); + + // Short-circuit on the *lengths* of the slices, not their + // contents. + if len != _rhs.len() { + return Choice::from(0); + } + + // This loop shouldn't be shortcircuitable, since the compiler + // shouldn't be able to reason about the value of the `u8` + // unwrapped from the `ct_eq` result. + let mut x = 1u8; + for (ai, bi) in self.iter().zip(_rhs.iter()) { + x &= ai.ct_eq(bi).unwrap_u8(); + } + + x.into() + } +} + +impl ConstantTimeEq for Choice { + #[inline] + fn ct_eq(&self, rhs: &Choice) -> Choice { + !(*self ^ *rhs) + } +} + +/// Given the bit-width `$bit_width` and the corresponding primitive +/// unsigned and signed types `$t_u` and `$t_i` respectively, generate +/// an `ConstantTimeEq` implementation. +macro_rules! generate_integer_equal { + ($t_u:ty, $t_i:ty, $bit_width:expr) => { + impl ConstantTimeEq for $t_u { + #[inline] + fn ct_eq(&self, other: &$t_u) -> Choice { + // x == 0 if and only if self == other + let x: $t_u = self ^ other; + + // If x == 0, then x and -x are both equal to zero; + // otherwise, one or both will have its high bit set. + let y: $t_u = (x | x.wrapping_neg()) >> ($bit_width - 1); + + // Result is the opposite of the high bit (now shifted to low). + ((y ^ (1 as $t_u)) as u8).into() + } + } + impl ConstantTimeEq for $t_i { + #[inline] + fn ct_eq(&self, other: &$t_i) -> Choice { + // Bitcast to unsigned and call that implementation. + (*self as $t_u).ct_eq(&(*other as $t_u)) + } + } + }; +} + +generate_integer_equal!(u8, i8, 8); +generate_integer_equal!(u16, i16, 16); +generate_integer_equal!(u32, i32, 32); +generate_integer_equal!(u64, i64, 64); +#[cfg(feature = "i128")] +generate_integer_equal!(u128, i128, 128); +generate_integer_equal!(usize, isize, ::core::mem::size_of::() * 8); + +/// `Ordering` is `#[repr(i8)]` making it possible to leverage `i8::ct_eq`. +impl ConstantTimeEq for cmp::Ordering { + #[inline] + fn ct_eq(&self, other: &Self) -> Choice { + (*self as i8).ct_eq(&(*other as i8)) + } +} + +/// A type which can be conditionally selected in constant time. +/// +/// This trait also provides generic implementations of conditional +/// assignment and conditional swaps. +// +// #[inline] is specified on these function prototypes to signify that they +#[allow(unused_attributes)] // should be in the actual implementation +pub trait ConditionallySelectable: Copy { + /// Select `a` or `b` according to `choice`. + /// + /// # Returns + /// + /// * `a` if `choice == Choice(0)`; + /// * `b` if `choice == Choice(1)`. + /// + /// This function should execute in constant time. + /// + /// # Example + /// + /// ``` + /// use subtle::ConditionallySelectable; + /// # + /// # fn main() { + /// let x: u8 = 13; + /// let y: u8 = 42; + /// + /// let z = u8::conditional_select(&x, &y, 0.into()); + /// assert_eq!(z, x); + /// let z = u8::conditional_select(&x, &y, 1.into()); + /// assert_eq!(z, y); + /// # } + /// ``` + #[inline] + #[allow(unused_attributes)] + fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self; + + /// Conditionally assign `other` to `self`, according to `choice`. + /// + /// This function should execute in constant time. + /// + /// # Example + /// + /// ``` + /// use subtle::ConditionallySelectable; + /// # + /// # fn main() { + /// let mut x: u8 = 13; + /// let mut y: u8 = 42; + /// + /// x.conditional_assign(&y, 0.into()); + /// assert_eq!(x, 13); + /// x.conditional_assign(&y, 1.into()); + /// assert_eq!(x, 42); + /// # } + /// ``` + #[inline] + fn conditional_assign(&mut self, other: &Self, choice: Choice) { + *self = Self::conditional_select(self, other, choice); + } + + /// Conditionally swap `self` and `other` if `choice == 1`; otherwise, + /// reassign both unto themselves. + /// + /// This function should execute in constant time. + /// + /// # Example + /// + /// ``` + /// use subtle::ConditionallySelectable; + /// # + /// # fn main() { + /// let mut x: u8 = 13; + /// let mut y: u8 = 42; + /// + /// u8::conditional_swap(&mut x, &mut y, 0.into()); + /// assert_eq!(x, 13); + /// assert_eq!(y, 42); + /// u8::conditional_swap(&mut x, &mut y, 1.into()); + /// assert_eq!(x, 42); + /// assert_eq!(y, 13); + /// # } + /// ``` + #[inline] + fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice) { + let t: Self = *a; + a.conditional_assign(&b, choice); + b.conditional_assign(&t, choice); + } +} + +macro_rules! to_signed_int { + (u8) => { + i8 + }; + (u16) => { + i16 + }; + (u32) => { + i32 + }; + (u64) => { + i64 + }; + (u128) => { + i128 + }; + (i8) => { + i8 + }; + (i16) => { + i16 + }; + (i32) => { + i32 + }; + (i64) => { + i64 + }; + (i128) => { + i128 + }; +} + +macro_rules! generate_integer_conditional_select { + ($($t:tt)*) => ($( + impl ConditionallySelectable for $t { + #[inline] + fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self { + // if choice = 0, mask = (-0) = 0000...0000 + // if choice = 1, mask = (-1) = 1111...1111 + let mask = -(choice.unwrap_u8() as to_signed_int!($t)) as $t; + a ^ (mask & (a ^ b)) + } + + #[inline] + fn conditional_assign(&mut self, other: &Self, choice: Choice) { + // if choice = 0, mask = (-0) = 0000...0000 + // if choice = 1, mask = (-1) = 1111...1111 + let mask = -(choice.unwrap_u8() as to_signed_int!($t)) as $t; + *self ^= mask & (*self ^ *other); + } + + #[inline] + fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice) { + // if choice = 0, mask = (-0) = 0000...0000 + // if choice = 1, mask = (-1) = 1111...1111 + let mask = -(choice.unwrap_u8() as to_signed_int!($t)) as $t; + let t = mask & (*a ^ *b); + *a ^= t; + *b ^= t; + } + } + )*) +} + +generate_integer_conditional_select!( u8 i8); +generate_integer_conditional_select!( u16 i16); +generate_integer_conditional_select!( u32 i32); +generate_integer_conditional_select!( u64 i64); +#[cfg(feature = "i128")] +generate_integer_conditional_select!(u128 i128); + +/// `Ordering` is `#[repr(i8)]` where: +/// +/// - `Less` => -1 +/// - `Equal` => 0 +/// - `Greater` => 1 +/// +/// Given this, it's possible to operate on orderings as if they're integers, +/// which allows leveraging conditional masking for predication. +impl ConditionallySelectable for cmp::Ordering { + fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self { + let a = *a as i8; + let b = *b as i8; + let ret = i8::conditional_select(&a, &b, choice); + + // SAFETY: `Ordering` is `#[repr(i8)]` and `ret` has been assigned to + // a value which was originally a valid `Ordering` then cast to `i8` + unsafe { *((&ret as *const _) as *const cmp::Ordering) } + } +} + +impl ConditionallySelectable for Choice { + #[inline] + fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self { + Choice(u8::conditional_select(&a.0, &b.0, choice)) + } +} + +#[cfg(feature = "const-generics")] +impl ConditionallySelectable for [T; N] +where + T: ConditionallySelectable, +{ + #[inline] + fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self { + let mut output = *a; + output.conditional_assign(b, choice); + output + } + + fn conditional_assign(&mut self, other: &Self, choice: Choice) { + for (a_i, b_i) in self.iter_mut().zip(other) { + a_i.conditional_assign(b_i, choice) + } + } +} + +/// A type which can be conditionally negated in constant time. +/// +/// # Note +/// +/// A generic implementation of `ConditionallyNegatable` is provided +/// for types `T` which are `ConditionallySelectable` and have `Neg` +/// implemented on `&T`. +// +// #[inline] is specified on these function prototypes to signify that they +#[allow(unused_attributes)] // should be in the actual implementation +pub trait ConditionallyNegatable { + /// Negate `self` if `choice == Choice(1)`; otherwise, leave it + /// unchanged. + /// + /// This function should execute in constant time. + #[inline] + #[allow(unused_attributes)] + fn conditional_negate(&mut self, choice: Choice); +} + +impl ConditionallyNegatable for T +where + T: ConditionallySelectable, + for<'a> &'a T: Neg, +{ + #[inline] + fn conditional_negate(&mut self, choice: Choice) { + // Need to cast to eliminate mutability + let self_neg: T = -(self as &T); + self.conditional_assign(&self_neg, choice); + } +} + +/// The `CtOption` type represents an optional value similar to the +/// [`Option`](core::option::Option) type but is intended for +/// use in constant time APIs. +/// +/// Any given `CtOption` is either `Some` or `None`, but unlike +/// `Option` these variants are not exposed. The +/// [`is_some()`](CtOption::is_some) method is used to determine if +/// the value is `Some`, and [`unwrap_or()`](CtOption::unwrap_or) and +/// [`unwrap_or_else()`](CtOption::unwrap_or_else) methods are +/// provided to access the underlying value. The value can also be +/// obtained with [`unwrap()`](CtOption::unwrap) but this will panic +/// if it is `None`. +/// +/// Functions that are intended to be constant time may not produce +/// valid results for all inputs, such as square root and inversion +/// operations in finite field arithmetic. Returning an `Option` +/// from these functions makes it difficult for the caller to reason +/// about the result in constant time, and returning an incorrect +/// value burdens the caller and increases the chance of bugs. +#[derive(Clone, Copy, Debug)] +pub struct CtOption { + value: T, + is_some: Choice, +} + +impl From> for Option { + /// Convert the `CtOption` wrapper into an `Option`, depending on whether + /// the underlying `is_some` `Choice` was a `0` or a `1` once unwrapped. + /// + /// # Note + /// + /// This function exists to avoid ending up with ugly, verbose and/or bad handled + /// conversions from the `CtOption` wraps to an `Option` or `Result`. + /// This implementation doesn't intend to be constant-time nor try to protect the + /// leakage of the `T` since the `Option` will do it anyways. + fn from(source: CtOption) -> Option { + if source.is_some().unwrap_u8() == 1u8 { + Option::Some(source.value) + } else { + None + } + } +} + +impl CtOption { + /// This method is used to construct a new `CtOption` and takes + /// a value of type `T`, and a `Choice` that determines whether + /// the optional value should be `Some` or not. If `is_some` is + /// false, the value will still be stored but its value is never + /// exposed. + #[inline] + pub fn new(value: T, is_some: Choice) -> CtOption { + CtOption { + value: value, + is_some: is_some, + } + } + + /// Returns the contained value, consuming the `self` value. + /// + /// # Panics + /// + /// Panics if the value is none with a custom panic message provided by + /// `msg`. + pub fn expect(self, msg: &str) -> T { + assert_eq!(self.is_some.unwrap_u8(), 1, "{}", msg); + + self.value + } + + /// This returns the underlying value but panics if it + /// is not `Some`. + #[inline] + pub fn unwrap(self) -> T { + assert_eq!(self.is_some.unwrap_u8(), 1); + + self.value + } + + /// This returns the underlying value if it is `Some` + /// or the provided value otherwise. + #[inline] + pub fn unwrap_or(self, def: T) -> T + where + T: ConditionallySelectable, + { + T::conditional_select(&def, &self.value, self.is_some) + } + + /// This returns the underlying value if it is `Some` + /// or the value produced by the provided closure otherwise. + /// + /// This operates in constant time, because the provided closure + /// is always called. + #[inline] + pub fn unwrap_or_else(self, f: F) -> T + where + T: ConditionallySelectable, + F: FnOnce() -> T, + { + T::conditional_select(&f(), &self.value, self.is_some) + } + + /// Returns a true `Choice` if this value is `Some`. + #[inline] + pub fn is_some(&self) -> Choice { + self.is_some + } + + /// Returns a true `Choice` if this value is `None`. + #[inline] + pub fn is_none(&self) -> Choice { + !self.is_some + } + + /// Returns a `None` value if the option is `None`, otherwise + /// returns a `CtOption` enclosing the value of the provided closure. + /// The closure is given the enclosed value or, if the option is + /// `None`, it is provided a dummy value computed using + /// `Default::default()`. + /// + /// This operates in constant time, because the provided closure + /// is always called. + #[inline] + pub fn map(self, f: F) -> CtOption + where + T: Default + ConditionallySelectable, + F: FnOnce(T) -> U, + { + CtOption::new( + f(T::conditional_select( + &T::default(), + &self.value, + self.is_some, + )), + self.is_some, + ) + } + + /// Returns a `None` value if the option is `None`, otherwise + /// returns the result of the provided closure. The closure is + /// given the enclosed value or, if the option is `None`, it + /// is provided a dummy value computed using `Default::default()`. + /// + /// This operates in constant time, because the provided closure + /// is always called. + #[inline] + pub fn and_then(self, f: F) -> CtOption + where + T: Default + ConditionallySelectable, + F: FnOnce(T) -> CtOption, + { + let mut tmp = f(T::conditional_select( + &T::default(), + &self.value, + self.is_some, + )); + tmp.is_some &= self.is_some; + + tmp + } + + /// Returns `self` if it contains a value, and otherwise returns the result of + /// calling `f`. The provided function `f` is always called. + #[inline] + pub fn or_else(self, f: F) -> CtOption + where + T: ConditionallySelectable, + F: FnOnce() -> CtOption, + { + let is_none = self.is_none(); + let f = f(); + + Self::conditional_select(&self, &f, is_none) + } + + /// Convert the `CtOption` wrapper into an `Option`, depending on whether + /// the underlying `is_some` `Choice` was a `0` or a `1` once unwrapped. + /// + /// # Note + /// + /// This function exists to avoid ending up with ugly, verbose and/or bad handled + /// conversions from the `CtOption` wraps to an `Option` or `Result`. + /// This implementation doesn't intend to be constant-time nor try to protect the + /// leakage of the `T` since the `Option` will do it anyways. + /// + /// It's equivalent to the corresponding `From` impl, however this version is + /// friendlier for type inference. + pub fn into_option(self) -> Option { + self.into() + } +} + +impl ConditionallySelectable for CtOption { + fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self { + CtOption::new( + T::conditional_select(&a.value, &b.value, choice), + Choice::conditional_select(&a.is_some, &b.is_some, choice), + ) + } +} + +impl ConstantTimeEq for CtOption { + /// Two `CtOption`s are equal if they are both `Some` and + /// their values are equal, or both `None`. + #[inline] + fn ct_eq(&self, rhs: &CtOption) -> Choice { + let a = self.is_some(); + let b = rhs.is_some(); + + (a & b & self.value.ct_eq(&rhs.value)) | (!a & !b) + } +} + +/// A type which can be compared in some manner and be determined to be greater +/// than another of the same type. +pub trait ConstantTimeGreater { + /// Determine whether `self > other`. + /// + /// The bitwise-NOT of the return value of this function should be usable to + /// determine if `self <= other`. + /// + /// This function should execute in constant time. + /// + /// # Returns + /// + /// A `Choice` with a set bit if `self > other`, and with no set bits + /// otherwise. + /// + /// # Example + /// + /// ``` + /// use subtle::ConstantTimeGreater; + /// + /// let x: u8 = 13; + /// let y: u8 = 42; + /// + /// let x_gt_y = x.ct_gt(&y); + /// + /// assert_eq!(x_gt_y.unwrap_u8(), 0); + /// + /// let y_gt_x = y.ct_gt(&x); + /// + /// assert_eq!(y_gt_x.unwrap_u8(), 1); + /// + /// let x_gt_x = x.ct_gt(&x); + /// + /// assert_eq!(x_gt_x.unwrap_u8(), 0); + /// ``` + fn ct_gt(&self, other: &Self) -> Choice; +} + +macro_rules! generate_unsigned_integer_greater { + ($t_u: ty, $bit_width: expr) => { + impl ConstantTimeGreater for $t_u { + /// Returns Choice::from(1) iff x > y, and Choice::from(0) iff x <= y. + /// + /// # Note + /// + /// This algoritm would also work for signed integers if we first + /// flip the top bit, e.g. `let x: u8 = x ^ 0x80`, etc. + #[inline] + fn ct_gt(&self, other: &$t_u) -> Choice { + let gtb = self & !other; // All the bits in self that are greater than their corresponding bits in other. + let mut ltb = !self & other; // All the bits in self that are less than their corresponding bits in other. + let mut pow = 1; + + // Less-than operator is okay here because it's dependent on the bit-width. + while pow < $bit_width { + ltb |= ltb >> pow; // Bit-smear the highest set bit to the right. + pow += pow; + } + let mut bit = gtb & !ltb; // Select the highest set bit. + let mut pow = 1; + + while pow < $bit_width { + bit |= bit >> pow; // Shift it to the right until we end up with either 0 or 1. + pow += pow; + } + // XXX We should possibly do the above flattening to 0 or 1 in the + // Choice constructor rather than making it a debug error? + Choice::from((bit & 1) as u8) + } + } + }; +} + +generate_unsigned_integer_greater!(u8, 8); +generate_unsigned_integer_greater!(u16, 16); +generate_unsigned_integer_greater!(u32, 32); +generate_unsigned_integer_greater!(u64, 64); +#[cfg(feature = "i128")] +generate_unsigned_integer_greater!(u128, 128); + +impl ConstantTimeGreater for cmp::Ordering { + #[inline] + fn ct_gt(&self, other: &Self) -> Choice { + // No impl of `ConstantTimeGreater` for `i8`, so use `u8` + let a = (*self as i8) + 1; + let b = (*other as i8) + 1; + (a as u8).ct_gt(&(b as u8)) + } +} + +/// A type which can be compared in some manner and be determined to be less +/// than another of the same type. +pub trait ConstantTimeLess: ConstantTimeEq + ConstantTimeGreater { + /// Determine whether `self < other`. + /// + /// The bitwise-NOT of the return value of this function should be usable to + /// determine if `self >= other`. + /// + /// A default implementation is provided and implemented for the unsigned + /// integer types. + /// + /// This function should execute in constant time. + /// + /// # Returns + /// + /// A `Choice` with a set bit if `self < other`, and with no set bits + /// otherwise. + /// + /// # Example + /// + /// ``` + /// use subtle::ConstantTimeLess; + /// + /// let x: u8 = 13; + /// let y: u8 = 42; + /// + /// let x_lt_y = x.ct_lt(&y); + /// + /// assert_eq!(x_lt_y.unwrap_u8(), 1); + /// + /// let y_lt_x = y.ct_lt(&x); + /// + /// assert_eq!(y_lt_x.unwrap_u8(), 0); + /// + /// let x_lt_x = x.ct_lt(&x); + /// + /// assert_eq!(x_lt_x.unwrap_u8(), 0); + /// ``` + #[inline] + fn ct_lt(&self, other: &Self) -> Choice { + !self.ct_gt(other) & !self.ct_eq(other) + } +} + +impl ConstantTimeLess for u8 {} +impl ConstantTimeLess for u16 {} +impl ConstantTimeLess for u32 {} +impl ConstantTimeLess for u64 {} +#[cfg(feature = "i128")] +impl ConstantTimeLess for u128 {} + +impl ConstantTimeLess for cmp::Ordering { + #[inline] + fn ct_lt(&self, other: &Self) -> Choice { + // No impl of `ConstantTimeLess` for `i8`, so use `u8` + let a = (*self as i8) + 1; + let b = (*other as i8) + 1; + (a as u8).ct_lt(&(b as u8)) + } +} + +/// Wrapper type which implements an optimization barrier for all accesses. +#[derive(Clone, Copy, Debug)] +pub struct BlackBox(T); + +impl BlackBox { + /// Constructs a new instance of `BlackBox` which will wrap the specified value. + /// + /// All access to the inner value will be mediated by a `black_box` optimization barrier. + pub fn new(value: T) -> Self { + Self(value) + } + + /// Read the inner value, applying an optimization barrier on access. + pub fn get(self) -> T { + black_box(self.0) + } +} diff --git a/http/vendor/subtle/tests/mod.rs b/http/vendor/subtle/tests/mod.rs new file mode 100644 index 0000000..888b9d0 --- /dev/null +++ b/http/vendor/subtle/tests/mod.rs @@ -0,0 +1,432 @@ +use std::cmp; + +use rand::rngs::OsRng; +use rand::RngCore; + +use subtle::*; + +#[test] +#[should_panic] +fn slices_equal_different_lengths() { + let a: [u8; 3] = [0, 0, 0]; + let b: [u8; 4] = [0, 0, 0, 0]; + + assert_eq!((&a).ct_eq(&b).unwrap_u8(), 1); +} + +#[test] +fn slices_equal() { + let a: [u8; 8] = [1, 2, 3, 4, 5, 6, 7, 8]; + let b: [u8; 8] = [1, 2, 3, 4, 4, 3, 2, 1]; + + let a_eq_a = (&a).ct_eq(&a); + let a_eq_b = (&a).ct_eq(&b); + + assert_eq!(a_eq_a.unwrap_u8(), 1); + assert_eq!(a_eq_b.unwrap_u8(), 0); + + let c: [u8; 16] = [0u8; 16]; + + let a_eq_c = (&a).ct_eq(&c); + assert_eq!(a_eq_c.unwrap_u8(), 0); +} + +#[test] +fn conditional_assign_i32() { + let mut a: i32 = 5; + let b: i32 = 13; + + a.conditional_assign(&b, 0.into()); + assert_eq!(a, 5); + a.conditional_assign(&b, 1.into()); + assert_eq!(a, 13); +} + +#[test] +fn conditional_assign_i64() { + let mut c: i64 = 2343249123; + let d: i64 = 8723884895; + + c.conditional_assign(&d, 0.into()); + assert_eq!(c, 2343249123); + c.conditional_assign(&d, 1.into()); + assert_eq!(c, 8723884895); +} + +macro_rules! generate_integer_conditional_select_tests { + ($($t:ty)*) => ($( + let x: $t = 0; // all 0 bits + let y: $t = !0; // all 1 bits + + assert_eq!(<$t>::conditional_select(&x, &y, 0.into()), x); + assert_eq!(<$t>::conditional_select(&x, &y, 1.into()), y); + + let mut z = x; + let mut w = y; + + <$t>::conditional_swap(&mut z, &mut w, 0.into()); + assert_eq!(z, x); + assert_eq!(w, y); + <$t>::conditional_swap(&mut z, &mut w, 1.into()); + assert_eq!(z, y); + assert_eq!(w, x); + + z.conditional_assign(&x, 1.into()); + w.conditional_assign(&y, 0.into()); + assert_eq!(z, x); + assert_eq!(w, x); + )*) +} + +#[test] +fn integer_conditional_select() { + generate_integer_conditional_select_tests!(u8 u16 u32 u64); + generate_integer_conditional_select_tests!(i8 i16 i32 i64); + #[cfg(feature = "i128")] + generate_integer_conditional_select_tests!(i128 u128); +} + +#[test] +fn custom_conditional_select_i16() { + let x: i16 = 257; + let y: i16 = 514; + + assert_eq!(i16::conditional_select(&x, &y, 0.into()), 257); + assert_eq!(i16::conditional_select(&x, &y, 1.into()), 514); +} + +#[test] +fn ordering_conditional_select() { + assert_eq!( + cmp::Ordering::conditional_select(&cmp::Ordering::Less, &cmp::Ordering::Greater, 0.into()), + cmp::Ordering::Less + ); + + assert_eq!( + cmp::Ordering::conditional_select(&cmp::Ordering::Less, &cmp::Ordering::Greater, 1.into()), + cmp::Ordering::Greater + ); +} + +macro_rules! generate_integer_equal_tests { + ($($t:ty),*) => ($( + let y: $t = 0; // all 0 bits + let z: $t = !0; // all 1 bits + + let x = z; + + assert_eq!(x.ct_eq(&y).unwrap_u8(), 0); + assert_eq!(x.ct_eq(&z).unwrap_u8(), 1); + assert_eq!(x.ct_ne(&y).unwrap_u8(), 1); + assert_eq!(x.ct_ne(&z).unwrap_u8(), 0); + )*) +} + +#[test] +fn integer_equal() { + generate_integer_equal_tests!(u8, u16, u32, u64); + generate_integer_equal_tests!(i8, i16, i32, i64); + #[cfg(feature = "i128")] + generate_integer_equal_tests!(i128, u128); + generate_integer_equal_tests!(isize, usize); +} + +#[test] +fn choice_into_bool() { + let choice_true: bool = Choice::from(1).into(); + + assert!(choice_true); + + let choice_false: bool = Choice::from(0).into(); + + assert!(!choice_false); +} + +#[test] +fn conditional_select_choice() { + let t = Choice::from(1); + let f = Choice::from(0); + + assert_eq!(bool::from(Choice::conditional_select(&t, &f, f)), true); + assert_eq!(bool::from(Choice::conditional_select(&t, &f, t)), false); + assert_eq!(bool::from(Choice::conditional_select(&f, &t, f)), false); + assert_eq!(bool::from(Choice::conditional_select(&f, &t, t)), true); +} + +#[test] +fn choice_equal() { + assert!(Choice::from(0).ct_eq(&Choice::from(0)).unwrap_u8() == 1); + assert!(Choice::from(0).ct_eq(&Choice::from(1)).unwrap_u8() == 0); + assert!(Choice::from(1).ct_eq(&Choice::from(0)).unwrap_u8() == 0); + assert!(Choice::from(1).ct_eq(&Choice::from(1)).unwrap_u8() == 1); +} + +#[test] +fn ordering_equal() { + let a = cmp::Ordering::Equal; + let b = cmp::Ordering::Greater; + let c = a; + + assert_eq!(a.ct_eq(&b).unwrap_u8(), 0); + assert_eq!(a.ct_eq(&c).unwrap_u8(), 1); +} + +#[test] +fn test_ctoption() { + let a = CtOption::new(10, Choice::from(1)); + let b = CtOption::new(9, Choice::from(1)); + let c = CtOption::new(10, Choice::from(0)); + let d = CtOption::new(9, Choice::from(0)); + + // Test is_some / is_none + assert!(bool::from(a.is_some())); + assert!(bool::from(!a.is_none())); + assert!(bool::from(b.is_some())); + assert!(bool::from(!b.is_none())); + assert!(bool::from(!c.is_some())); + assert!(bool::from(c.is_none())); + assert!(bool::from(!d.is_some())); + assert!(bool::from(d.is_none())); + + // Test unwrap for Some + assert_eq!(a.unwrap(), 10); + assert_eq!(b.unwrap(), 9); + + // Test equality + assert!(bool::from(a.ct_eq(&a))); + assert!(bool::from(!a.ct_eq(&b))); + assert!(bool::from(!a.ct_eq(&c))); + assert!(bool::from(!a.ct_eq(&d))); + + // Test equality of None with different + // dummy value + assert!(bool::from(c.ct_eq(&d))); + + // Test unwrap_or + assert_eq!(CtOption::new(1, Choice::from(1)).unwrap_or(2), 1); + assert_eq!(CtOption::new(1, Choice::from(0)).unwrap_or(2), 2); + + // Test unwrap_or_else + assert_eq!(CtOption::new(1, Choice::from(1)).unwrap_or_else(|| 2), 1); + assert_eq!(CtOption::new(1, Choice::from(0)).unwrap_or_else(|| 2), 2); + + // Test map + assert_eq!( + CtOption::new(1, Choice::from(1)) + .map(|v| { + assert_eq!(v, 1); + 2 + }) + .unwrap(), + 2 + ); + assert_eq!( + CtOption::new(1, Choice::from(0)) + .map(|_| 2) + .is_none() + .unwrap_u8(), + 1 + ); + + // Test and_then + assert_eq!( + CtOption::new(1, Choice::from(1)) + .and_then(|v| { + assert_eq!(v, 1); + CtOption::new(2, Choice::from(0)) + }) + .is_none() + .unwrap_u8(), + 1 + ); + assert_eq!( + CtOption::new(1, Choice::from(1)) + .and_then(|v| { + assert_eq!(v, 1); + CtOption::new(2, Choice::from(1)) + }) + .unwrap(), + 2 + ); + + assert_eq!( + CtOption::new(1, Choice::from(0)) + .and_then(|_| CtOption::new(2, Choice::from(0))) + .is_none() + .unwrap_u8(), + 1 + ); + assert_eq!( + CtOption::new(1, Choice::from(0)) + .and_then(|_| CtOption::new(2, Choice::from(1))) + .is_none() + .unwrap_u8(), + 1 + ); + + // Test or_else + assert_eq!( + CtOption::new(1, Choice::from(0)) + .or_else(|| CtOption::new(2, Choice::from(1))) + .unwrap(), + 2 + ); + assert_eq!( + CtOption::new(1, Choice::from(1)) + .or_else(|| CtOption::new(2, Choice::from(0))) + .unwrap(), + 1 + ); + assert_eq!( + CtOption::new(1, Choice::from(1)) + .or_else(|| CtOption::new(2, Choice::from(1))) + .unwrap(), + 1 + ); + assert!(bool::from( + CtOption::new(1, Choice::from(0)) + .or_else(|| CtOption::new(2, Choice::from(0))) + .is_none() + )); + + // Test (in)equality + assert!(CtOption::new(1, Choice::from(0)).ct_eq(&CtOption::new(1, Choice::from(1))).unwrap_u8() == 0); + assert!(CtOption::new(1, Choice::from(1)).ct_eq(&CtOption::new(1, Choice::from(0))).unwrap_u8() == 0); + assert!(CtOption::new(1, Choice::from(0)).ct_eq(&CtOption::new(2, Choice::from(1))).unwrap_u8() == 0); + assert!(CtOption::new(1, Choice::from(1)).ct_eq(&CtOption::new(2, Choice::from(0))).unwrap_u8() == 0); + assert!(CtOption::new(1, Choice::from(0)).ct_eq(&CtOption::new(1, Choice::from(0))).unwrap_u8() == 1); + assert!(CtOption::new(1, Choice::from(0)).ct_eq(&CtOption::new(2, Choice::from(0))).unwrap_u8() == 1); + assert!(CtOption::new(1, Choice::from(1)).ct_eq(&CtOption::new(2, Choice::from(1))).unwrap_u8() == 0); + assert!(CtOption::new(1, Choice::from(1)).ct_eq(&CtOption::new(2, Choice::from(1))).unwrap_u8() == 0); + assert!(CtOption::new(1, Choice::from(1)).ct_eq(&CtOption::new(1, Choice::from(1))).unwrap_u8() == 1); + assert!(CtOption::new(1, Choice::from(1)).ct_eq(&CtOption::new(1, Choice::from(1))).unwrap_u8() == 1); +} + +#[test] +#[should_panic] +fn unwrap_none_ctoption() { + // This test might fail (in release mode?) if the + // compiler decides to optimize it away. + CtOption::new(10, Choice::from(0)).unwrap(); +} + +macro_rules! generate_greater_than_test { + ($ty: ty) => { + for _ in 0..100 { + let x = OsRng.next_u64() as $ty; + let y = OsRng.next_u64() as $ty; + let z = x.ct_gt(&y); + + println!("x={}, y={}, z={:?}", x, y, z); + + if x < y { + assert!(z.unwrap_u8() == 0); + } else if x == y { + assert!(z.unwrap_u8() == 0); + } else if x > y { + assert!(z.unwrap_u8() == 1); + } + } + } +} + +#[test] +fn greater_than_u8() { + generate_greater_than_test!(u8); +} + +#[test] +fn greater_than_u16() { + generate_greater_than_test!(u16); +} + +#[test] +fn greater_than_u32() { + generate_greater_than_test!(u32); +} + +#[test] +fn greater_than_u64() { + generate_greater_than_test!(u64); +} + +#[cfg(feature = "i128")] +#[test] +fn greater_than_u128() { + generate_greater_than_test!(u128); +} + +#[test] +fn greater_than_ordering() { + assert_eq!(cmp::Ordering::Less.ct_gt(&cmp::Ordering::Greater).unwrap_u8(), 0); + assert_eq!(cmp::Ordering::Greater.ct_gt(&cmp::Ordering::Less).unwrap_u8(), 1); +} + +#[test] +/// Test that the two's compliment min and max, i.e. 0000...0001 < 1111...1110, +/// gives the correct result. (This fails using the bit-twiddling algorithm that +/// go/crypto/subtle uses.) +fn less_than_twos_compliment_minmax() { + let z = 1u32.ct_lt(&(2u32.pow(31)-1)); + + assert!(z.unwrap_u8() == 1); +} + +macro_rules! generate_less_than_test { + ($ty: ty) => { + for _ in 0..100 { + let x = OsRng.next_u64() as $ty; + let y = OsRng.next_u64() as $ty; + let z = x.ct_gt(&y); + + println!("x={}, y={}, z={:?}", x, y, z); + + if x < y { + assert!(z.unwrap_u8() == 0); + } else if x == y { + assert!(z.unwrap_u8() == 0); + } else if x > y { + assert!(z.unwrap_u8() == 1); + } + } + } +} + +#[test] +fn less_than_u8() { + generate_less_than_test!(u8); +} + +#[test] +fn less_than_u16() { + generate_less_than_test!(u16); +} + +#[test] +fn less_than_u32() { + generate_less_than_test!(u32); +} + +#[test] +fn less_than_u64() { + generate_less_than_test!(u64); +} + +#[cfg(feature = "i128")] +#[test] +fn less_than_u128() { + generate_less_than_test!(u128); +} + +#[test] +fn less_than_ordering() { + assert_eq!(cmp::Ordering::Greater.ct_lt(&cmp::Ordering::Less).unwrap_u8(), 0); + assert_eq!(cmp::Ordering::Less.ct_lt(&cmp::Ordering::Greater).unwrap_u8(), 1); +} + +#[test] +fn black_box_round_trip() { + let n = 42u64; + let black_box = BlackBox::new(n); + assert_eq!(n, black_box.get()); +} diff --git a/http/vendor/untrusted/.cargo-checksum.json b/http/vendor/untrusted/.cargo-checksum.json new file mode 100644 index 0000000..df4a551 --- /dev/null +++ b/http/vendor/untrusted/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{".cargo_vcs_info.json":"cd62304eec306f79e9aa5a11def1ed08ff9c3ed35a1077be72022d881f8d6a1f",".github/workflows/ci.yml":"4830a250e36d82cd7345f856c6a9ed13fcff13a68af188fe5fa72497456e7c1d","Cargo.toml":"25efda62e6e0a7e3cf463ff88bd9d9321befb22de7660cd63b2a0a195d70aed6","Cargo.toml.orig":"6c0de4b4eb8c2aa14aa20cf57a72e518bf1a7e937f1954a78ec345936439344a","LICENSE.txt":"7abd9b6960dcf7d4d0a48606a5b71bfe37d472db68d70637f3a58a56785f1621","README.md":"8ec7954c78b7bceecc1757f2af855045969c3197ad306c9a5d3a6e0c43a8a9cd","deny.toml":"3a34becaf845de9c7dbafc56c6b5778d56d36097ec8283d09192841b409e8f27","mk/cargo.sh":"766c00df2767ac0998000e9b55d076b6dbbeb05ecf4c4d9b317df8551fae1bbe","mk/install-build-tools.sh":"90ec3cce41b1660b5103a37803e537ff167bae17badaca2d89f492116555919d","mk/llvm-snapshot.gpg.key":"88c1936349db1b7798b92cb62fe7d69e0b676b7900f4cb120c1c8ad5ac6b93d6","mk/runner":"471602c60f4243f87ebf952f8e69c07dfa29d8c69f2ef3885a4c61a2d6bf3b33","rustfmt.toml":"0dd6766a2c7a732a0535c8a51d0d84d27cec54c648b132a561ca66c601fc6312","src/input.rs":"aaa007b7051f03b32f6c71fa8164780435e637bb2242df7792942b699d2d9cbd","src/lib.rs":"860cdbec448f82196aa2242ad52945dfc60f29fcfbc28d244877fca0c0331fcc","src/no_panic.rs":"bf39e1314721d8350a09aa19628b64a2393b3b489906f1591a722bd47f4351e6","src/reader.rs":"3826d4de44a970ed42e3f7dead6f4b51b60ccf02c03b9ac7140c80a9e57b104d","tests/tests.rs":"cefcc4543e3d49e1af0e6e6efebebbdfb61cad131d0ea2d69c14ed11f398cca5"},"package":"8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"} \ No newline at end of file diff --git a/http/vendor/untrusted/.cargo_vcs_info.json b/http/vendor/untrusted/.cargo_vcs_info.json new file mode 100644 index 0000000..6d86344 --- /dev/null +++ b/http/vendor/untrusted/.cargo_vcs_info.json @@ -0,0 +1,5 @@ +{ + "git": { + "sha1": "89c8b8415f692d3803d183fc5fbf9ec08a6adcf4" + } +} diff --git a/http/vendor/untrusted/.github/workflows/ci.yml b/http/vendor/untrusted/.github/workflows/ci.yml new file mode 100644 index 0000000..113a6a0 --- /dev/null +++ b/http/vendor/untrusted/.github/workflows/ci.yml @@ -0,0 +1,212 @@ +name: ci +permissions: + contents: read +on: + pull_request: + push: +jobs: + rustfmt: + runs-on: ubuntu-18.04 + + steps: + - uses: briansmith/actions-rs-toolchain@v1 + with: + toolchain: stable + profile: minimal + components: rustfmt + - uses: briansmith/actions-checkout@v2 + with: + persist-credentials: false + - run: cargo fmt --all -- --check + + clippy: + runs-on: ubuntu-18.04 + + steps: + - uses: briansmith/actions-rs-toolchain@v1 + with: + toolchain: stable + profile: minimal + components: clippy + + - uses: briansmith/actions-checkout@v2 + with: + persist-credentials: false + + - run: cargo clippy --all-features ---all-targets -- --deny warnings + + audit: + runs-on: ubuntu-18.04 + + steps: + - uses: briansmith/actions-rs-toolchain@v1 + with: + toolchain: stable + profile: minimal + + - uses: briansmith/actions-cache@v2 + with: + path: | + ~/.cargo/bin/cargo-audit + ~/.cargo/.crates.toml + ~/.cargo/.crates2.json + key: ${{ runner.os }}-v2-cargo-audit-0.13.1 + + - run: cargo install cargo-audit --vers "0.13.1" + + - uses: briansmith/actions-checkout@v2 + with: + persist-credentials: false + + - run: cargo generate-lockfile + + - run: cargo audit --deny warnings + + deny: + runs-on: ubuntu-18.04 + + steps: + - uses: briansmith/actions-rs-toolchain@v1 + with: + toolchain: stable + profile: minimal + + - uses: briansmith/actions-cache@v2 + with: + path: | + ~/.cargo/bin/cargo-deny + ~/.cargo/.crates.toml + ~/.cargo/.crates2.json + key: ${{ runner.os }}-v2-cargo-deny-0.8.4 + + - run: cargo install cargo-deny --vers "0.8.4" + + - uses: briansmith/actions-checkout@v2 + with: + persist-credentials: false + + - run: cargo deny check + + # Verify that documentation builds. + rustdoc: + runs-on: ubuntu-18.04 + + strategy: + matrix: + rust_channel: + - stable + - beta + - nightly + + include: + - target: x86_64-unknown-linux-gnu + + steps: + - uses: briansmith/actions-rs-toolchain@v1 + with: + override: true + target: ${{ matrix.target }} + toolchain: ${{ matrix.rust_channel }} + + - uses: briansmith/actions-checkout@v2 + with: + persist-credentials: false + + - run: | + cargo doc --all-features + + test: + runs-on: ${{ matrix.host_os }} + + strategy: + matrix: + features: + - # Default + + target: + - i686-unknown-linux-musl + - x86_64-unknown-linux-gnu + + mode: + - # debug + - --release + + rust_channel: + - stable + - nightly + - 1.49.0 # MSRV + - beta + + include: + - target: i686-unknown-linux-musl + host_os: ubuntu-18.04 + + - target: x86_64-unknown-linux-gnu + host_os: ubuntu-18.04 + + steps: + - uses: briansmith/actions-checkout@v2 + with: + persist-credentials: false + + - uses: briansmith/actions-rs-toolchain@v1 + with: + override: true + target: ${{ matrix.target }} + toolchain: ${{ matrix.rust_channel }} + + - run: | + cargo test -vv --target=${{ matrix.target }} ${{ matrix.cargo_options }} ${{ matrix.features }} ${{ matrix.mode }} + + coverage: + runs-on: ${{ matrix.host_os }} + + strategy: + matrix: + features: + - --all-features + + target: + - x86_64-unknown-linux-musl + + mode: + - # debug + + # Coverage collection is Nightly-only + rust_channel: + - nightly + + # TODO: targets + include: + - target: x86_64-unknown-linux-musl + host_os: ubuntu-18.04 + + steps: + - if: ${{ contains(matrix.host_os, 'ubuntu') }} + run: sudo apt-get update -y + + - uses: briansmith/actions-checkout@v2 + with: + persist-credentials: false + + - if: ${{ !contains(matrix.host_os, 'windows') }} + run: RING_COVERAGE=1 mk/install-build-tools.sh --target=${{ matrix.target }} ${{ matrix.features }} + + - uses: briansmith/actions-rs-toolchain@v1 + with: + override: true + target: ${{ matrix.target }} + toolchain: ${{ matrix.rust_channel }} + + - if: ${{ matrix.target == 'aarch64-apple-darwin' }} + run: echo "DEVELOPER_DIR=/Applications/Xcode_12.2.app/Contents/Developer" >> $GITHUB_ENV + + - if: ${{ !contains(matrix.host_os, 'windows') }} + run: | + RING_COVERAGE=1 mk/cargo.sh +${{ matrix.rust_channel }} test -vv --target=${{ matrix.target }} ${{ matrix.cargo_options }} ${{ matrix.features }} ${{ matrix.mode }} + + - uses: briansmith/codecov-codecov-action@v1 + with: + directory: ./target/${{ matrix.target }}/debug/coverage/reports + fail_ci_if_error: true + verbose: true diff --git a/http/vendor/untrusted/Cargo.toml b/http/vendor/untrusted/Cargo.toml new file mode 100644 index 0000000..f739c11 --- /dev/null +++ b/http/vendor/untrusted/Cargo.toml @@ -0,0 +1,28 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies +# +# If you believe there's an error in this file please file an +# issue against the rust-lang/cargo repository. If you're +# editing this file be aware that the upstream Cargo.toml +# will likely look very different (and much more reasonable) + +[package] +edition = "2018" +name = "untrusted" +version = "0.9.0" +authors = ["Brian Smith "] +description = "Safe, fast, zero-panic, zero-crashing, zero-allocation parsing of untrusted inputs in Rust." +documentation = "https://briansmith.org/rustdoc/untrusted/" +readme = "README.md" +license = "ISC" +repository = "https://github.com/briansmith/untrusted" +[profile.bench] +opt-level = 2 +lto = true + +[lib] +name = "untrusted" diff --git a/http/vendor/untrusted/Cargo.toml.orig b/http/vendor/untrusted/Cargo.toml.orig new file mode 100644 index 0000000..92be239 --- /dev/null +++ b/http/vendor/untrusted/Cargo.toml.orig @@ -0,0 +1,17 @@ +[package] +authors = ["Brian Smith "] +description = "Safe, fast, zero-panic, zero-crashing, zero-allocation parsing of untrusted inputs in Rust." +documentation = "https://briansmith.org/rustdoc/untrusted/" +edition = "2018" +license = "ISC" +name = "untrusted" +readme = "README.md" +repository = "https://github.com/briansmith/untrusted" +version = "0.9.0" + +[lib] +name = "untrusted" + +[profile.bench] +opt-level = 2 +lto = true diff --git a/http/vendor/untrusted/LICENSE.txt b/http/vendor/untrusted/LICENSE.txt new file mode 100644 index 0000000..7151db6 --- /dev/null +++ b/http/vendor/untrusted/LICENSE.txt @@ -0,0 +1,13 @@ +// Copyright 2015-2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/http/vendor/untrusted/README.md b/http/vendor/untrusted/README.md new file mode 100644 index 0000000..9cbf9df --- /dev/null +++ b/http/vendor/untrusted/README.md @@ -0,0 +1,109 @@ +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. + + + +untrusted.rs +============ + +Safe, fast, zero-panic, zero-crashing, zero-allocation parsing of untrusted +inputs in Rust. + +untrusted.rs is 100% Rust with no use of `unsafe`. It never uses the heap. +No part of untrusted.rs's API will ever panic or cause a crash. It is +`#![no_std]` and so it works perfectly with both libcore- and libstd- based +projects. It does not depend on any crates other than libcore. + +untrusted.rs is intended to be used with the latest version of Rust Stable. +It should usually work with the latest Rust Beta and Rust Nightly versions +too. Using a version of untrusted.rs other than the latest release available +on crates.io is not recommended. + + + +Documentation +------------- + +See the documentation at +https://briansmith.org/rustdoc/untrusted/. + +To use untrusted.rs in your project, add a dependency to your +Cargo.toml like this: + +``` +[dependencies] +untrusted = "0.2" +``` + + + +Examples +-------- + +[*ring*](https://github.com/briansmith/ring)'s parser for the subset of ASN.1 +DER it needs to understand, +[`ring::der`](https://github.com/briansmith/ring/blob/master/src/der.rs), is +built on top of untrusted.rs. *ring* also uses untrusted.rs to parse ECC public +keys, RSA PKCS#1 1.5 padding, and everything else. + +All of [webpki](https://github.com/briansmith/webpki)'s parsing of X.509 +certificates (also ASN.1 DER) is done using untrusted.rs. + + + +Contributing +------------ + +Patches welcome! + +When contributing changes, state that you agree to license your contribution +under the same terms as the existing code by putting this at the bottom of your +commit message: + +``` + +I agree to license my contributions to each file under the terms given +at the top of each file I changed. +``` + +Currently, the biggest needs for this library are: + +* Unit tests. +* Documentation. +* More examples. +* Static analysis and fuzzing. + + + +Online Automated Testing +------------------------ + +Travis CI is used for Android, Linux, and Mac OS X. The tests are run for the +current release of each Rust channel (Stable, Beta, Nightly). Since +untrusted.rs only depends on libcore and it only uses 100% cross-platform code +without using `unsafe`, it should work anywhere as long as these platforms are +passing. + +
+ + + +Bug Reporting +------------- + +Please report bugs either as pull requests or as issues in [the issue +tracker](https://github.com/briansmith/untrusted/issues). untrusted.rs has a +**full disclosure** vulnerability policy. **Please do NOT attempt to report +any security vulnerability in this code privately to anybody.** + + + +License +------- + +See [LICENSE.txt](LICENSE.txt), an ISC-style (simplified MIT) license. diff --git a/http/vendor/untrusted/deny.toml b/http/vendor/untrusted/deny.toml new file mode 100644 index 0000000..dbc7922 --- /dev/null +++ b/http/vendor/untrusted/deny.toml @@ -0,0 +1,20 @@ +[advisories] +unmaintained = "deny" +yanked = "deny" +notice = "deny" + +[licenses] +allow = [ + "ISC", +] +confidence-threshold = 1.0 + +[bans] +# We don't maintain a fixed Cargo.lock so enforcing +# `multiple-versions = "deny"` is impractical. +multiple-versions = "allow" +wildcards = "deny" + +[sources] +unknown-registry = "deny" +unknown-git = "deny" diff --git a/http/vendor/untrusted/mk/cargo.sh b/http/vendor/untrusted/mk/cargo.sh new file mode 100644 index 0000000..a7b8154 --- /dev/null +++ b/http/vendor/untrusted/mk/cargo.sh @@ -0,0 +1,153 @@ +#!/usr/bin/env bash +# +# Copyright 2020 Brian Smith. +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +set -eux -o pipefail +IFS=$'\n\t' + +rustflags_self_contained="-Clink-self-contained=yes -Clinker=rust-lld" +qemu_aarch64="qemu-aarch64 -L /usr/aarch64-linux-gnu" +qemu_arm="qemu-arm -L /usr/arm-linux-gnueabihf" + +# Avoid putting the Android tools in `$PATH` because there are tools in this +# directory like `clang` that would conflict with the same-named tools that may +# be needed to compile the build script, or to compile for other targets. +if [ -n "${ANDROID_SDK_ROOT-}" ]; then + android_tools=$ANDROID_SDK_ROOT/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin +fi + +for arg in $*; do + case $arg in + --target=*) + target=${arg#*=} + ;; + *) + ;; + esac +done + +# See comments in install-build-tools.sh. +llvm_version=10 +if [ -n "${RING_COVERAGE-}" ]; then + llvm_version=11 +fi + +case $target in + aarch64-linux-android) + export CC_aarch64_linux_android=$android_tools/aarch64-linux-android21-clang + export AR_aarch64_linux_android=$android_tools/aarch64-linux-android-ar + export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=$android_tools/aarch64-linux-android21-clang + ;; + aarch64-unknown-linux-gnu) + export CC_aarch64_unknown_linux_gnu=clang-$llvm_version + export AR_aarch64_unknown_linux_gnu=llvm-ar-$llvm_version + export CFLAGS_aarch64_unknown_linux_gnu="--sysroot=/usr/aarch64-linux-gnu" + export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc + export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER="$qemu_aarch64" + ;; + aarch64-unknown-linux-musl) + export CC_aarch64_unknown_linux_musl=clang-$llvm_version + export AR_aarch64_unknown_linux_musl=llvm-ar-$llvm_version + export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="$rustflags_self_contained" + export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUNNER="$qemu_aarch64" + ;; + arm-unknown-linux-gnueabihf) + export CC_arm_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc + export AR_arm_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc-ar + export CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc + export CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_RUNNER="$qemu_arm" + ;; + armv7-linux-androideabi) + export CC_armv7_linux_androideabi=$android_tools/armv7a-linux-androideabi18-clang + export AR_armv7_linux_androideabi=$android_tools/arm-linux-androideabi-ar + export CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER=$android_tools/armv7a-linux-androideabi18-clang + ;; + armv7-unknown-linux-musleabihf) + export CC_armv7_unknown_linux_musleabihf=clang-$llvm_version + export AR_armv7_unknown_linux_musleabihf=llvm-ar-$llvm_version + export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABIHF_RUSTFLAGS="$rustflags_self_contained" + export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABIHF_RUNNER="$qemu_arm" + ;; + i686-unknown-linux-gnu) + export CC_i686_unknown_linux_gnu=clang-$llvm_version + export AR_i686_unknown_linux_gnu=llvm-ar-$llvm_version + export CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_LINKER=clang-$llvm_version + ;; + i686-unknown-linux-musl) + export CC_i686_unknown_linux_musl=clang-$llvm_version + export AR_i686_unknown_linux_musl=llvm-ar-$llvm_version + export CARGO_TARGET_I686_UNKNOWN_LINUX_MUSL_RUSTFLAGS="$rustflags_self_contained" + ;; + x86_64-unknown-linux-musl) + export CC_x86_64_unknown_linux_musl=clang-$llvm_version + export AR_x86_64_unknown_linux_musl=llvm-ar-$llvm_version + # XXX: Work around https://github.com/rust-lang/rust/issues/79555. + if [ -n "${RING_COVERAGE-}" ]; then + export CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=clang-$llvm_version + else + export CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUSTFLAGS="$rustflags_self_contained" + fi + ;; + wasm32-unknown-unknown) + # The first two are only needed for when the "wasm_c" feature is enabled. + export CC_wasm32_unknown_unknown=clang-$llvm_version + export AR_wasm32_unknown_unknown=llvm-ar-$llvm_version + export CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER=wasm-bindgen-test-runner + ;; + *) + ;; +esac + +if [ -n "${RING_COVERAGE-}" ]; then + # XXX: Collides between release and debug. + coverage_dir=$PWD/target/$target/debug/coverage + mkdir -p "$coverage_dir" + rm -f "$coverage_dir/*.profraw" + + export RING_BUILD_EXECUTABLE_LIST="$coverage_dir/executables" + truncate --size=0 "$RING_BUILD_EXECUTABLE_LIST" + + # This doesn't work when profiling under QEMU. Instead mk/runner does + # something similar but different. + # export LLVM_PROFILE_FILE="$coverage_dir/%m.profraw" + + # ${target} with hyphens replaced by underscores, lowercase and uppercase. + target_lower=${target//-/_} + target_upper=${target_lower^^} + + cflags_var=CFLAGS_${target_lower} + declare -x "${cflags_var}=-fprofile-instr-generate -fcoverage-mapping ${!cflags_var-}" + + runner_var=CARGO_TARGET_${target_upper}_RUNNER + declare -x "${runner_var}=mk/runner ${!runner_var-}" + + rustflags_var=CARGO_TARGET_${target_upper}_RUSTFLAGS + declare -x "${rustflags_var}=-Zinstrument-coverage ${!rustflags_var-}" +fi + +cargo "$@" + +if [ -n "${RING_COVERAGE-}" ]; then + while read executable; do + basename=$(basename "$executable") + llvm-profdata-$llvm_version merge -sparse ""$coverage_dir"/$basename.profraw" -o "$coverage_dir"/$basename.profdata + mkdir -p "$coverage_dir"/reports + llvm-cov-$llvm_version export \ + --instr-profile "$coverage_dir"/$basename.profdata \ + --format lcov \ + "$executable" \ + > "$coverage_dir"/reports/coverage-$basename.txt + done < "$RING_BUILD_EXECUTABLE_LIST" +fi diff --git a/http/vendor/untrusted/mk/install-build-tools.sh b/http/vendor/untrusted/mk/install-build-tools.sh new file mode 100644 index 0000000..e997bbb --- /dev/null +++ b/http/vendor/untrusted/mk/install-build-tools.sh @@ -0,0 +1,95 @@ +#!/usr/bin/env bash +# +# Copyright 2020 Brian Smith. +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +set -eux -o pipefail +IFS=$'\n\t' + +target=$1 +features=${2-} + +function install_packages { + sudo apt-get -yq --no-install-suggests --no-install-recommends install "$@" +} + +use_clang= +case $target in +--target*android*) + mkdir -p "${ANDROID_SDK_ROOT}/licenses" + android_license_file="${ANDROID_SDK_ROOT}/licenses/android-sdk-license" + accept_android_license=24333f8a63b6825ea9c5514f83c2829b004d1fee + grep --quiet --no-messages "$accept_android_license" "$android_license_file" \ + || echo $accept_android_license >> "$android_license_file" + sudo "${ANDROID_SDK_ROOT}/tools/bin/sdkmanager" ndk-bundle + ;; +esac + +case $target in +--target=aarch64-unknown-linux-gnu) + # Clang is needed for code coverage. + use_clang=1 + install_packages \ + qemu-user \ + gcc-aarch64-linux-gnu \ + libc6-dev-arm64-cross + ;; +--target=aarch64-unknown-linux-musl|--target=armv7-unknown-linux-musleabihf) + use_clang=1 + install_packages \ + qemu-user + ;; +--target=arm-unknown-linux-gnueabihf) + install_packages \ + qemu-user \ + gcc-arm-linux-gnueabihf \ + libc6-dev-armhf-cross + ;; +--target=i686-unknown-linux-gnu) + use_clang=1 + install_packages \ + gcc-multilib \ + libc6-dev-i386 + ;; +--target=i686-unknown-linux-musl|--target=x86_64-unknown-linux-musl) + use_clang=1 + ;; +--target=wasm32-unknown-unknown) + # The version of wasm-bindgen-cli must match the wasm-bindgen version. + wasm_bindgen_version=$(cargo metadata --format-version 1 | jq -r '.packages | map(select( .name == "wasm-bindgen")) | map(.version) | .[0]') + cargo install wasm-bindgen-cli --vers "$wasm_bindgen_version" --bin wasm-bindgen-test-runner + case ${features-} in + *wasm32_c*) + use_clang=1 + ;; + *) + ;; + esac + ;; +--target=*) + ;; +esac + +if [ -n "$use_clang" ]; then + llvm_version=10 + if [ -n "${RING_COVERAGE-}" ]; then + # https://github.com/rust-lang/rust/pull/79365 upgraded the coverage file + # format to one that only LLVM 11+ can use + llvm_version=11 + sudo apt-key add mk/llvm-snapshot.gpg.key + sudo add-apt-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-$llvm_version main" + sudo apt-get update + fi + install_packages clang-$llvm_version llvm-$llvm_version +fi diff --git a/http/vendor/untrusted/mk/llvm-snapshot.gpg.key b/http/vendor/untrusted/mk/llvm-snapshot.gpg.key new file mode 100644 index 0000000..87a01ff --- /dev/null +++ b/http/vendor/untrusted/mk/llvm-snapshot.gpg.key @@ -0,0 +1,54 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v1.4.12 (GNU/Linux) +Comment: See https://apt.llvm.org/. +Comment: Fingerprint: 6084 F3CF 814B 57C1 CF12 EFD5 15CF 4D18 AF4F 7421 + +mQINBFE9lCwBEADi0WUAApM/mgHJRU8lVkkw0CHsZNpqaQDNaHefD6Rw3S4LxNmM +EZaOTkhP200XZM8lVdbfUW9xSjA3oPldc1HG26NjbqqCmWpdo2fb+r7VmU2dq3NM +R18ZlKixiLDE6OUfaXWKamZsXb6ITTYmgTO6orQWYrnW6ckYHSeaAkW0wkDAryl2 +B5v8aoFnQ1rFiVEMo4NGzw4UX+MelF7rxaaregmKVTPiqCOSPJ1McC1dHFN533FY +Wh/RVLKWo6npu+owtwYFQW+zyQhKzSIMvNujFRzhIxzxR9Gn87MoLAyfgKEzrbbT +DhqqNXTxS4UMUKCQaO93TzetX/EBrRpJj+vP640yio80h4Dr5pAd7+LnKwgpTDk1 +G88bBXJAcPZnTSKu9I2c6KY4iRNbvRz4i+ZdwwZtdW4nSdl2792L7Sl7Nc44uLL/ +ZqkKDXEBF6lsX5XpABwyK89S/SbHOytXv9o4puv+65Ac5/UShspQTMSKGZgvDauU +cs8kE1U9dPOqVNCYq9Nfwinkf6RxV1k1+gwtclxQuY7UpKXP0hNAXjAiA5KS5Crq +7aaJg9q2F4bub0mNU6n7UI6vXguF2n4SEtzPRk6RP+4TiT3bZUsmr+1ktogyOJCc +Ha8G5VdL+NBIYQthOcieYCBnTeIH7D3Sp6FYQTYtVbKFzmMK+36ERreL/wARAQAB +tD1TeWx2ZXN0cmUgTGVkcnUgLSBEZWJpYW4gTExWTSBwYWNrYWdlcyA8c3lsdmVz +dHJlQGRlYmlhbi5vcmc+iQI4BBMBAgAiBQJRPZQsAhsDBgsJCAcDAgYVCAIJCgsE +FgIDAQIeAQIXgAAKCRAVz00Yr090Ibx+EADArS/hvkDF8juWMXxh17CgR0WZlHCC +9CTBWkg5a0bNN/3bb97cPQt/vIKWjQtkQpav6/5JTVCSx2riL4FHYhH0iuo4iAPR +udC7Cvg8g7bSPrKO6tenQZNvQm+tUmBHgFiMBJi92AjZ/Qn1Shg7p9ITivFxpLyX +wpmnF1OKyI2Kof2rm4BFwfSWuf8Fvh7kDMRLHv+MlnK/7j/BNpKdozXxLcwoFBmn +l0WjpAH3OFF7Pvm1LJdf1DjWKH0Dc3sc6zxtmBR/KHHg6kK4BGQNnFKujcP7TVdv +gMYv84kun14pnwjZcqOtN3UJtcx22880DOQzinoMs3Q4w4o05oIF+sSgHViFpc3W +R0v+RllnH05vKZo+LDzc83DQVrdwliV12eHxrMQ8UYg88zCbF/cHHnlzZWAJgftg +hB08v1BKPgYRUzwJ6VdVqXYcZWEaUJmQAPuAALyZESw94hSo28FAn0/gzEc5uOYx +K+xG/lFwgAGYNb3uGM5m0P6LVTfdg6vDwwOeTNIExVk3KVFXeSQef2ZMkhwA7wya +KJptkb62wBHFE+o9TUdtMCY6qONxMMdwioRE5BYNwAsS1PnRD2+jtlI0DzvKHt7B +MWd8hnoUKhMeZ9TNmo+8CpsAtXZcBho0zPGz/R8NlJhAWpdAZ1CmcPo83EW86Yq7 +BxQUKnNHcwj2ebkCDQRRPZQsARAA4jxYmbTHwmMjqSizlMJYNuGOpIidEdx9zQ5g +zOr431/VfWq4S+VhMDhs15j9lyml0y4ok215VRFwrAREDg6UPMr7ajLmBQGau0Fc +bvZJ90l4NjXp5p0NEE/qOb9UEHT7EGkEhaZ1ekkWFTWCgsy7rRXfZLxB6sk7pzLC +DshyW3zjIakWAnpQ5j5obiDy708pReAuGB94NSyb1HoW/xGsGgvvCw4r0w3xPStw +F1PhmScE6NTBIfLliea3pl8vhKPlCh54Hk7I8QGjo1ETlRP4Qll1ZxHJ8u25f/ta +RES2Aw8Hi7j0EVcZ6MT9JWTI83yUcnUlZPZS2HyeWcUj+8nUC8W4N8An+aNps9l/ +21inIl2TbGo3Yn1JQLnA1YCoGwC34g8QZTJhElEQBN0X29ayWW6OdFx8MDvllbBV +ymmKq2lK1U55mQTfDli7S3vfGz9Gp/oQwZ8bQpOeUkc5hbZszYwP4RX+68xDPfn+ +M9udl+qW9wu+LyePbW6HX90LmkhNkkY2ZzUPRPDHZANU5btaPXc2H7edX4y4maQa +xenqD0lGh9LGz/mps4HEZtCI5CY8o0uCMF3lT0XfXhuLksr7Pxv57yue8LLTItOJ +d9Hmzp9G97SRYYeqU+8lyNXtU2PdrLLq7QHkzrsloG78lCpQcalHGACJzrlUWVP/ +fN3Ht3kAEQEAAYkCHwQYAQIACQUCUT2ULAIbDAAKCRAVz00Yr090IbhWEADbr50X +OEXMIMGRLe+YMjeMX9NG4jxs0jZaWHc/WrGR+CCSUb9r6aPXeLo+45949uEfdSsB +pbaEdNWxF5Vr1CSjuO5siIlgDjmT655voXo67xVpEN4HhMrxugDJfCa6z97P0+ML +PdDxim57uNqkam9XIq9hKQaurxMAECDPmlEXI4QT3eu5qw5/knMzDMZj4Vi6hovL +wvvAeLHO/jsyfIdNmhBGU2RWCEZ9uo/MeerPHtRPfg74g+9PPfP6nyHD2Wes6yGd +oVQwtPNAQD6Cj7EaA2xdZYLJ7/jW6yiPu98FFWP74FN2dlyEA2uVziLsfBrgpS4l +tVOlrO2YzkkqUGrybzbLpj6eeHx+Cd7wcjI8CalsqtL6cG8cUEjtWQUHyTbQWAgG +5VPEgIAVhJ6RTZ26i/G+4J8neKyRs4vz+57UGwY6zI4AB1ZcWGEE3Bf+CDEDgmnP +LSwbnHefK9IljT9XU98PelSryUO/5UPw7leE0akXKB4DtekToO226px1VnGp3Bov +1GBGvpHvL2WizEwdk+nfk8LtrLzej+9FtIcq3uIrYnsac47Pf7p0otcFeTJTjSq3 +krCaoG4Hx0zGQG2ZFpHrSrZTVy6lxvIdfi0beMgY6h78p6M9eYZHQHc02DjFkQXN +bXb5c6gCHESH5PXwPU4jQEE7Ib9J6sbk7ZT2Mw== +=j+4q +-----END PGP PUBLIC KEY BLOCK----- diff --git a/http/vendor/untrusted/mk/runner b/http/vendor/untrusted/mk/runner new file mode 100644 index 0000000..ffa1441 --- /dev/null +++ b/http/vendor/untrusted/mk/runner @@ -0,0 +1,21 @@ +#!/bin/bash +set -eux -o pipefail +IFS=$'\n\t' + +for arg in $*; do + # There can be some arguments prefixed in front of the executable, e.g. + # when qemu-user is used. There can be arguments after the executable, + # e.g. `cargo test` arguments like `TESTNAME`. + if [[ $arg = */deps/* ]]; then + executable=$arg + break + fi +done + +export LLVM_PROFILE_FILE=$(dirname "$RING_BUILD_EXECUTABLE_LIST")/$(basename "$executable").profraw + +if [ -n "$RING_BUILD_EXECUTABLE_LIST" ]; then + echo "$executable" >> "$RING_BUILD_EXECUTABLE_LIST" +fi + +$* diff --git a/http/vendor/untrusted/rustfmt.toml b/http/vendor/untrusted/rustfmt.toml new file mode 100644 index 0000000..a032c00 --- /dev/null +++ b/http/vendor/untrusted/rustfmt.toml @@ -0,0 +1,5 @@ +edition = "2018" +max_width = 100 +newline_style = "Unix" +reorder_imports = true +use_field_init_shorthand = true diff --git a/http/vendor/untrusted/src/input.rs b/http/vendor/untrusted/src/input.rs new file mode 100644 index 0000000..91b5b50 --- /dev/null +++ b/http/vendor/untrusted/src/input.rs @@ -0,0 +1,101 @@ +// Copyright 2015-2021 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use crate::{no_panic, Reader}; + +/// A wrapper around `&'a [u8]` that helps in writing panic-free code. +/// +/// No methods of `Input` will ever panic. +/// +/// Intentionally avoids implementing `PartialEq` and `Eq` to avoid implicit +/// non-constant-time comparisons. +#[derive(Clone, Copy)] +pub struct Input<'a> { + value: no_panic::Slice<'a>, +} + +/// The value is intentionally omitted from the output to avoid leaking +/// secrets. +impl core::fmt::Debug for Input<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.debug_struct("Input").finish() + } +} + +impl<'a> Input<'a> { + /// Construct a new `Input` for the given input `bytes`. + pub const fn from(bytes: &'a [u8]) -> Self { + // This limit is important for avoiding integer overflow. In particular, + // `Reader` assumes that an `i + 1 > i` if `input.value.get(i)` does + // not return `None`. According to the Rust language reference, the + // maximum object size is `core::isize::MAX`, and in practice it is + // impossible to create an object of size `core::usize::MAX` or larger. + Self { + value: no_panic::Slice::new(bytes), + } + } + + /// Returns `true` if the input is empty and false otherwise. + #[inline] + pub fn is_empty(&self) -> bool { + self.value.is_empty() + } + + /// Returns the length of the `Input`. + #[inline] + pub fn len(&self) -> usize { + self.value.len() + } + + /// Calls `read` with the given input as a `Reader`, ensuring that `read` + /// consumed the entire input. If `read` does not consume the entire input, + /// `incomplete_read` is returned. + pub fn read_all(&self, incomplete_read: E, read: F) -> Result + where + F: FnOnce(&mut Reader<'a>) -> Result, + { + let mut input = Reader::new(*self); + let result = read(&mut input)?; + if input.at_end() { + Ok(result) + } else { + Err(incomplete_read) + } + } + + /// Access the input as a slice so it can be processed by functions that + /// are not written using the Input/Reader framework. + #[inline] + pub fn as_slice_less_safe(&self) -> &'a [u8] { + self.value.as_slice_less_safe() + } + + pub(super) fn into_value(self) -> no_panic::Slice<'a> { + self.value + } +} + +impl<'a> From<&'a [u8]> for Input<'a> { + #[inline] + fn from(value: &'a [u8]) -> Self { + no_panic::Slice::new(value).into() + } +} + +impl<'a> From> for Input<'a> { + #[inline] + fn from(value: no_panic::Slice<'a>) -> Self { + Self { value } + } +} diff --git a/http/vendor/untrusted/src/lib.rs b/http/vendor/untrusted/src/lib.rs new file mode 100644 index 0000000..9add1b4 --- /dev/null +++ b/http/vendor/untrusted/src/lib.rs @@ -0,0 +1,121 @@ +// Copyright 2015-2021 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! untrusted.rs: Safe, fast, zero-panic, zero-crashing, zero-allocation +//! parsing of untrusted inputs in Rust. +//! +//! git clone https://github.com/briansmith/untrusted +//! +//! untrusted.rs goes beyond Rust's normal safety guarantees by also +//! guaranteeing that parsing will be panic-free, as long as +//! `untrusted::Input::as_slice_less_safe()` is not used. It avoids copying +//! data and heap allocation and strives to prevent common pitfalls such as +//! accidentally parsing input bytes multiple times. In order to meet these +//! goals, untrusted.rs is limited in functionality such that it works best for +//! input languages with a small fixed amount of lookahead such as ASN.1, TLS, +//! TCP/IP, and many other networking, IPC, and related protocols. Languages +//! that require more lookahead and/or backtracking require some significant +//! contortions to parse using this framework. It would not be realistic to use +//! it for parsing programming language code, for example. +//! +//! The overall pattern for using untrusted.rs is: +//! +//! 1. Write a recursive-descent-style parser for the input language, where the +//! input data is given as a `&mut untrusted::Reader` parameter to each +//! function. Each function should have a return type of `Result` for +//! some value type `V` and some error type `E`, either or both of which may +//! be `()`. Functions for parsing the lowest-level language constructs +//! should be defined. Those lowest-level functions will parse their inputs +//! using `::read_byte()`, `Reader::peek()`, and similar functions. +//! Higher-level language constructs are then parsed by calling the +//! lower-level functions in sequence. +//! +//! 2. Wrap the top-most functions of your recursive-descent parser in +//! functions that take their input data as an `untrusted::Input`. The +//! wrapper functions should call the `Input`'s `read_all` (or a variant +//! thereof) method. The wrapper functions are the only ones that should be +//! exposed outside the parser's module. +//! +//! 3. After receiving the input data to parse, wrap it in an `untrusted::Input` +//! using `untrusted::Input::from()` as early as possible. Pass the +//! `untrusted::Input` to the wrapper functions when they need to be parsed. +//! +//! In general parsers built using `untrusted::Reader` do not need to explicitly +//! check for end-of-input unless they are parsing optional constructs, because +//! `Reader::read_byte()` will return `Err(EndOfInput)` on end-of-input. +//! Similarly, parsers using `untrusted::Reader` generally don't need to check +//! for extra junk at the end of the input as long as the parser's API uses the +//! pattern described above, as `read_all` and its variants automatically check +//! for trailing junk. `Reader::skip_to_end()` must be used when any remaining +//! unread input should be ignored without triggering an error. +//! +//! untrusted.rs works best when all processing of the input data is done +//! through the `untrusted::Input` and `untrusted::Reader` types. In +//! particular, avoid trying to parse input data using functions that take +//! byte slices. However, when you need to access a part of the input data as +//! a slice to use a function that isn't written using untrusted.rs, +//! `Input::as_slice_less_safe()` can be used. +//! +//! It is recommend to use `use untrusted;` and then `untrusted::Input`, +//! `untrusted::Reader`, etc., instead of using `use untrusted::*`. Qualifying +//! the names with `untrusted` helps remind the reader of the code that it is +//! dealing with *untrusted* input. +//! +//! # Examples +//! +//! [*ring*](https://github.com/briansmith/ring)'s parser for the subset of +//! ASN.1 DER it needs to understand, +//! [`ring::der`](https://github.com/briansmith/ring/blob/main/src/io/der.rs), +//! is built on top of untrusted.rs. *ring* also uses untrusted.rs to parse ECC +//! public keys, RSA PKCS#1 1.5 padding, and for all other parsing it does. +//! +//! All of [webpki](https://github.com/briansmith/webpki)'s parsing of X.509 +//! certificates (also ASN.1 DER) is done using untrusted.rs. + +#![doc(html_root_url = "https://briansmith.org/rustdoc/")] +#![no_std] + +mod input; +mod no_panic; +mod reader; + +pub use { + input::Input, + reader::{EndOfInput, Reader}, +}; + +/// Calls `read` with the given input as a `Reader`, ensuring that `read` +/// consumed the entire input. When `input` is `None`, `read` will be +/// called with `None`. +pub fn read_all_optional<'a, F, R, E>( + input: Option>, + incomplete_read: E, + read: F, +) -> Result +where + F: FnOnce(Option<&mut Reader<'a>>) -> Result, +{ + match input { + Some(input) => { + let mut input = Reader::new(input); + let result = read(Some(&mut input))?; + if input.at_end() { + Ok(result) + } else { + Err(incomplete_read) + } + } + None => read(None), + } +} diff --git a/http/vendor/untrusted/src/no_panic.rs b/http/vendor/untrusted/src/no_panic.rs new file mode 100644 index 0000000..e4c8354 --- /dev/null +++ b/http/vendor/untrusted/src/no_panic.rs @@ -0,0 +1,40 @@ +/// A wrapper around a slice that exposes no functions that can panic. +/// +/// Intentionally avoids implementing `Debug`, `Eq`, and `PartialEq` to avoid +/// creating a side channel that would leak information about the value. +#[derive(Clone, Copy)] +pub struct Slice<'a> { + bytes: &'a [u8], +} + +impl<'a> Slice<'a> { + #[inline] + pub const fn new(bytes: &'a [u8]) -> Self { + Self { bytes } + } + + #[inline] + pub fn get(&self, i: usize) -> Option<&u8> { + self.bytes.get(i) + } + + #[inline] + pub fn subslice(&self, r: core::ops::Range) -> Option { + self.bytes.get(r).map(|bytes| Self { bytes }) + } + + #[inline] + pub fn is_empty(&self) -> bool { + self.bytes.is_empty() + } + + #[inline] + pub fn len(&self) -> usize { + self.bytes.len() + } + + #[inline] + pub fn as_slice_less_safe(&self) -> &'a [u8] { + self.bytes + } +} diff --git a/http/vendor/untrusted/src/reader.rs b/http/vendor/untrusted/src/reader.rs new file mode 100644 index 0000000..d815573 --- /dev/null +++ b/http/vendor/untrusted/src/reader.rs @@ -0,0 +1,140 @@ +// Copyright 2015-2021 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use crate::{no_panic, Input}; + +/// A read-only, forward-only cursor into the data in an `Input`. +/// +/// Using `Reader` to parse input helps to ensure that no byte of the input +/// will be accidentally processed more than once. Using `Reader` in +/// conjunction with `read_all` and `read_all_optional` helps ensure that no +/// byte of the input is accidentally left unprocessed. The methods of `Reader` +/// never panic, so `Reader` also assists the writing of panic-free code. +/// +/// Intentionally avoids implementing `PartialEq` and `Eq` to avoid implicit +/// non-constant-time comparisons. +pub struct Reader<'a> { + input: no_panic::Slice<'a>, + i: usize, +} + +/// Avoids writing the value or position to avoid creating a side channel, +/// though `Reader` can't avoid leaking the position via timing. +impl core::fmt::Debug for Reader<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.debug_struct("Reader").finish() + } +} + +impl<'a> Reader<'a> { + /// Construct a new Reader for the given input. Use `read_all` or + /// `read_all_optional` instead of `Reader::new` whenever possible. + #[inline] + pub fn new(input: Input<'a>) -> Self { + Self { + input: input.into_value(), + i: 0, + } + } + + /// Returns `true` if the reader is at the end of the input, and `false` + /// otherwise. + #[inline] + pub fn at_end(&self) -> bool { + self.i == self.input.len() + } + + /// Returns `true` if there is at least one more byte in the input and that + /// byte is equal to `b`, and false otherwise. + #[inline] + pub fn peek(&self, b: u8) -> bool { + match self.input.get(self.i) { + Some(actual_b) => b == *actual_b, + None => false, + } + } + + /// Reads the next input byte. + /// + /// Returns `Ok(b)` where `b` is the next input byte, or `Err(EndOfInput)` + /// if the `Reader` is at the end of the input. + #[inline] + pub fn read_byte(&mut self) -> Result { + match self.input.get(self.i) { + Some(b) => { + self.i += 1; // safe from overflow; see Input::from(). + Ok(*b) + } + None => Err(EndOfInput), + } + } + + /// Skips `num_bytes` of the input, returning the skipped input as an + /// `Input`. + /// + /// Returns `Ok(i)` if there are at least `num_bytes` of input remaining, + /// and `Err(EndOfInput)` otherwise. + #[inline] + pub fn read_bytes(&mut self, num_bytes: usize) -> Result, EndOfInput> { + let new_i = self.i.checked_add(num_bytes).ok_or(EndOfInput)?; + let ret = self + .input + .subslice(self.i..new_i) + .map(From::from) + .ok_or(EndOfInput)?; + self.i = new_i; + Ok(ret) + } + + /// Skips the reader to the end of the input, returning the skipped input + /// as an `Input`. + #[inline] + pub fn read_bytes_to_end(&mut self) -> Input<'a> { + let to_skip = self.input.len() - self.i; + self.read_bytes(to_skip).unwrap() + } + + /// Calls `read()` with the given input as a `Reader`. On success, returns a + /// pair `(bytes_read, r)` where `bytes_read` is what `read()` consumed and + /// `r` is `read()`'s return value. + pub fn read_partial(&mut self, read: F) -> Result<(Input<'a>, R), E> + where + F: FnOnce(&mut Reader<'a>) -> Result, + { + let start = self.i; + let r = read(self)?; + let bytes_read = self.input.subslice(start..self.i).unwrap().into(); + Ok((bytes_read, r)) + } + + /// Skips `num_bytes` of the input. + /// + /// Returns `Ok(i)` if there are at least `num_bytes` of input remaining, + /// and `Err(EndOfInput)` otherwise. + #[inline] + pub fn skip(&mut self, num_bytes: usize) -> Result<(), EndOfInput> { + self.read_bytes(num_bytes).map(|_| ()) + } + + /// Skips the reader to the end of the input. + #[inline] + pub fn skip_to_end(&mut self) { + let _ = self.read_bytes_to_end(); + } +} + +/// The error type used to indicate the end of the input was reached before the +/// operation could be completed. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub struct EndOfInput; diff --git a/http/vendor/untrusted/tests/tests.rs b/http/vendor/untrusted/tests/tests.rs new file mode 100644 index 0000000..5e37eb7 --- /dev/null +++ b/http/vendor/untrusted/tests/tests.rs @@ -0,0 +1,134 @@ +// Copyright 2015-2019 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#[test] +fn test_debug() { + const INPUTS: &[&[u8]] = &[b"", b"foo"]; + for input in INPUTS { + let input = untrusted::Input::from(input); + assert_eq!(format!("{:?}", &input), "Input"); + input + .read_all(untrusted::EndOfInput, |r| { + assert_eq!(format!("{:?}", r), "Reader"); + r.skip_to_end(); + assert_eq!(format!("{:?}", r), "Reader"); + Ok(()) + }) + .unwrap(); + } +} + +#[test] +fn test_input_clone_and_copy() { + const INPUTS: &[&[u8]] = &[b"", b"a", b"foo"]; + for input in INPUTS { + let input = untrusted::Input::from(input); + let copy = input; + assert_eq!(input.as_slice_less_safe(), copy.as_slice_less_safe()); + assert_eq!( + input.as_slice_less_safe(), + input.clone().as_slice_less_safe() + ); + } +} + +#[test] +fn test_input_from() { + let _ = untrusted::Input::from(b"foo"); +} + +#[test] +fn test_input_is_empty() { + let input = untrusted::Input::from(b""); + assert!(input.is_empty()); + let input = untrusted::Input::from(b"foo"); + assert!(!input.is_empty()); +} + +#[test] +fn test_input_len() { + let input = untrusted::Input::from(b"foo"); + assert_eq!(input.len(), 3); +} + +#[test] +fn test_input_read_all() { + let input = untrusted::Input::from(b"foo"); + let result = input.read_all(untrusted::EndOfInput, |input| { + assert_eq!(b'f', input.read_byte()?); + assert_eq!(b'o', input.read_byte()?); + assert_eq!(b'o', input.read_byte()?); + assert!(input.at_end()); + Ok(()) + }); + assert_eq!(result, Ok(())); +} + +#[test] +fn test_input_read_all_unconsume() { + let input = untrusted::Input::from(b"foo"); + let result = input.read_all(untrusted::EndOfInput, |input| { + assert_eq!(b'f', input.read_byte()?); + assert!(!input.at_end()); + Ok(()) + }); + assert_eq!(result, Err(untrusted::EndOfInput)); +} + +#[test] +fn test_input_as_slice_less_safe() { + let slice = b"foo"; + let input = untrusted::Input::from(slice); + assert_eq!(input.as_slice_less_safe(), slice); +} + +#[test] +fn using_reader_after_skip_and_get_error_returns_error_must_not_panic() { + let input = untrusted::Input::from(&[]); + let r = input.read_all(untrusted::EndOfInput, |input| { + let r = input.read_bytes(1); + assert_eq!(r.unwrap_err(), untrusted::EndOfInput); + Ok(input.read_bytes_to_end()) + }); + let _ = r; // "Use" r. The value of `r` is undefined here. +} + +#[test] +fn size_assumptions() { + // Assume that a pointer can address any point in the address space, and + // infer that this implies that a byte slice will never be + // `core::usize::MAX` bytes long. + assert_eq!( + core::mem::size_of::<*const u8>(), + core::mem::size_of::() + ); +} + +#[test] +fn const_fn() { + const _INPUT: untrusted::Input<'static> = untrusted::Input::from(&[]); +} + +#[test] +fn test_vec_into() { + extern crate std; + let vec = vec![0u8; 0]; + let _x: untrusted::Input = (&vec[..]).into(); +} + +#[test] +fn test_from_slice() { + let slice: &[u8] = &[0u8]; + let _x: untrusted::Input = slice.into(); +} diff --git a/http/vendor/wasi/.cargo-checksum.json b/http/vendor/wasi/.cargo-checksum.json new file mode 100644 index 0000000..cf9c9a7 --- /dev/null +++ b/http/vendor/wasi/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"bf825de0291d010bd0ba2f20ab2154ee66856b65d811e6dcfb5df7faecd8d2dd","src/lib.rs":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"},"package":"ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"} \ No newline at end of file diff --git a/http/vendor/wasi/Cargo.toml b/http/vendor/wasi/Cargo.toml new file mode 100644 index 0000000..e7b2b5e --- /dev/null +++ b/http/vendor/wasi/Cargo.toml @@ -0,0 +1,37 @@ +[badges.maintenance] +status = "experimental" + +[dependencies.core] +optional = true +package = "rustc-std-workspace-core" +version = "1.0" + +[dependencies.rustc-std-workspace-alloc] +optional = true +version = "1.0" + +[features] +default = ["std"] +rustc-dep-of-std = ["core", "rustc-std-workspace-alloc"] +std = [] + +[lib] +path = "src/lib.rs" + +[package] +authors = ["The Cranelift Project Developers"] +autobenches = false +autobins = false +autoexamples = false +autolib = false +autotests = false +categories = ["no-std", "wasm"] +description = "Experimental WASI API bindings for Rust" +documentation = "https://docs.rs/wasi" +edition = "2018" +keywords = ["webassembly", "wasm"] +license = "Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT" +name = "wasi" +readme = "README.md" +repository = "https://github.com/bytecodealliance/wasi" +version = "0.11.1+wasi-snapshot-preview1" diff --git a/http/vendor/wasi/src/lib.rs b/http/vendor/wasi/src/lib.rs new file mode 100644 index 0000000..e69de29 diff --git a/http/vendor/webpki-roots/.cargo-checksum.json b/http/vendor/webpki-roots/.cargo-checksum.json new file mode 100644 index 0000000..896743a --- /dev/null +++ b/http/vendor/webpki-roots/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{".cargo_vcs_info.json":"65df70098b7e0edc547ade4ce44e6d8060439d961203e0e3574ebe2738eaf26f","Cargo.lock":"875d715f6119d883967375aae1eaf7ba272300e76eaca0bd8e1cbd08caba0878","Cargo.toml":"3f60ab8eff92c9cf50107deba8bd445a9d5026621057ab88d8f8d4751b48de9c","Cargo.toml.orig":"433d786c12db396fd9cf9c9147585e49fc4f1420b26e1fea887ebaf443ab20a8","LICENSE":"e271993808fec50ab29350b39539cdec611a9103f827e0aa26d61da70e2d33f8","README.md":"3f785bbd28b6628dadc4203a9368b729453aaa65df454e54a0c2f8a7a42395f5","src/lib.rs":"f1fb31b194a2c4dd7811af83080b59e99fefa8efce1c51be96313f327b0495e9","tests/codegen.rs":"06afca3127ffc684836406544e44ccfbb7cd0ae7ae15102c42bc62d076765ecd","tests/data/tubitak/inter.der":"bf32da954571659aaf715c13ee703e3643dfcbaeee2d82110ca68eb57cb67ce0","tests/data/tubitak/root.der":"46edc3689046d53a453fb3104ab80dcaec658b2660ea1629dd7e867990648716","tests/data/tubitak/subj.der":"8f0d491077ddc360e7416620af2cf4a8a4010e5b6f5a6d0f557f4f2499a38029","tests/verify.rs":"ef69aafbd92ba96b74325569025b44b04b021d526217ef69e7c3d46d83414632"},"package":"bf85cb06032201fa7c6f829d7db5a7e5aa45bcc0655327713065f6f0576731bf"} \ No newline at end of file diff --git a/http/vendor/webpki-roots/.cargo_vcs_info.json b/http/vendor/webpki-roots/.cargo_vcs_info.json new file mode 100644 index 0000000..d6c5c9f --- /dev/null +++ b/http/vendor/webpki-roots/.cargo_vcs_info.json @@ -0,0 +1,6 @@ +{ + "git": { + "sha1": "50729cd212ccd332be193856258fa93da2876d6a" + }, + "path_in_vcs": "webpki-roots" +} \ No newline at end of file diff --git a/http/vendor/webpki-roots/Cargo.lock b/http/vendor/webpki-roots/Cargo.lock new file mode 100644 index 0000000..e2f34db --- /dev/null +++ b/http/vendor/webpki-roots/Cargo.lock @@ -0,0 +1,718 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "asn1-rs" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7f43a50ac4fdca5df8e885c21b835997f0a1cdee65494a6847694a98652d9d8" +dependencies = [ + "asn1-rs-derive", + "asn1-rs-impl", + "displaydoc", + "nom", + "num-traits", + "rusticata-macros", + "thiserror", + "time", +] + +[[package]] +name = "asn1-rs-derive" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3109e49b1e4909e9db6515a30c633684d68cdeaa252f215214cb4fa1a5bfee2c" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "asn1-rs-impl" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + +[[package]] +name = "aws-lc-rs" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ec2f1fc3ec205783a5da9a7e6c1509cc69dedf09a1949e412c1e18469326d00" +dependencies = [ + "aws-lc-sys", + "untrusted 0.7.1", + "zeroize", +] + +[[package]] +name = "aws-lc-sys" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a2f9779ce85b93ab6170dd940ad0169b5766ff848247aff13bb788b832fe3f4" +dependencies = [ + "cc", + "cmake", + "dunce", + "fs_extra", +] + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bit-vec" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b71798fca2c1fe1086445a7258a4bc81e6e49dcd24c8d0dd9a1e57395b603f51" +dependencies = [ + "serde", +] + +[[package]] +name = "cc" +version = "1.2.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dad887fd958be91b5098c0248def011f4523ab786cd411be668777e55063501f" +dependencies = [ + "find-msvc-tools", + "jobserver", + "libc", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "cmake" +version = "0.1.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0f78a02292a74a88ac736019ab962ece0bc380e3f977bf72e376c5d78ff0678" +dependencies = [ + "cc", +] + +[[package]] +name = "data-encoding" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4ae5f15dda3c708c0ade84bfee31ccab44a3da4f88015ed22f63732abe300c8" + +[[package]] +name = "der-parser" +version = "10.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07da5016415d5a3c4dd39b11ed26f915f52fc4e0dc197d87908bc916e51bc1a6" +dependencies = [ + "asn1-rs", + "displaydoc", + "nom", + "num-bigint", + "num-traits", + "rusticata-macros", +] + +[[package]] +name = "deranged" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" + +[[package]] +name = "displaydoc" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ac70aa55017e108007fbaf5aa0f54b021c98f92ff8af59d42eda9da96e3dd4f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "dunce" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasip2", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "jobserver" +version = "0.1.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" +dependencies = [ + "getrandom 0.3.4", + "libc", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.186" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" + +[[package]] +name = "log" +version = "0.4.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "953f07c43838f8e6f9758cab68bf5bed85465e7587ebe0b823f1bcd81978ad3a" + +[[package]] +name = "memchr" +version = "2.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88904434abc2901f197fe8cc55f0445e7ded921dba5911dad2e2b39b48e663c4" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-conv" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "oid-registry" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12f40cff3dde1b6087cc5d5f5d4d65712f34016a03ed60e9c08dcc392736b5b7" +dependencies = [ + "asn1-rs", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "pem" +version = "3.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d30c53c26bc5b31a98cd02d20f25a7c8567146caf63ed593a9d87b2775291be" +dependencies = [ + "base64", + "serde_core", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "rcgen" +version = "0.14.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57f6d249aad744e274e682777a50283a225a32705394ee6d5fcc01efa25e4055" +dependencies = [ + "pem", + "ring", + "rustls-pki-types", + "time", + "x509-parser", + "yasna", +] + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.17", + "libc", + "untrusted 0.9.0", + "windows-sys", +] + +[[package]] +name = "rusticata-macros" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faf0c4a6ece9950b9abdb62b1cfcf2a68b3b67a10ba445b3bb85be2a293d0632" +dependencies = [ + "nom", +] + +[[package]] +name = "rustls" +version = "0.23.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef86cd5876211988985292b91c96a8f2d298df24e75989a43a3c73f2d4d8168b" +dependencies = [ + "aws-lc-rs", + "log", + "once_cell", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pki-types" +version = "1.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30a7197ae7eb376e574fe940d068c30fe0462554a3ddbe4eca7838e049c937a9" +dependencies = [ + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61c429a8649f110dddef65e2a5ad240f747e85f7758a6bccc7e5777bd33f756e" +dependencies = [ + "aws-lc-rs", + "ring", + "rustls-pki-types", + "untrusted 0.9.0", +] + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "2.0.118" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9ae57f904213ebb649ce6895b8a66c66f0203b9319718f69a5612a065b1422" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thiserror" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "time" +version = "0.3.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711a53c2d47bbd818258c498c8dbfe186a2526c631495cfe7e078567f86b8469" +dependencies = [ + "deranged", + "num-conv", + "powerfmt", + "serde_core", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109" + +[[package]] +name = "time-macros" +version = "0.2.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71c652a3727a9cbb9a02f707f530b618ce00d0ccd762009c8c23bd191df3c17d" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tokio" +version = "1.52.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc7f01b389ac15039e4dc9531aa973a135d7a4135281b12d7c1bc79fd57fffe" +dependencies = [ + "pin-project-lite", + "tokio-macros", +] + +[[package]] +name = "tokio-macros" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "385a6cb71ab9ab790c5fe8d67f1645e6c450a7ce006a33de03daa956cf70a496" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.4+wasi-0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "webpki-roots" +version = "1.0.8" +dependencies = [ + "aws-lc-rs", + "hex", + "percent-encoding", + "rcgen", + "rustls", + "rustls-pki-types", + "rustls-webpki", + "tokio", + "x509-parser", + "yasna", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "wit-bindgen" +version = "0.57.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" + +[[package]] +name = "x509-parser" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d43b0f71ce057da06bc0851b23ee24f3f86190b07203dd8f567d0b706a185202" +dependencies = [ + "asn1-rs", + "data-encoding", + "der-parser", + "lazy_static", + "nom", + "oid-registry", + "ring", + "rusticata-macros", + "thiserror", + "time", +] + +[[package]] +name = "yasna" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5f6765e852b9b4dc8e2a76843e4d64d1cea8e79bcde0b6901aea8e7c7f08282" +dependencies = [ + "bit-vec", + "time", +] + +[[package]] +name = "zeroize" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" diff --git a/http/vendor/webpki-roots/Cargo.toml b/http/vendor/webpki-roots/Cargo.toml new file mode 100644 index 0000000..3ac0609 --- /dev/null +++ b/http/vendor/webpki-roots/Cargo.toml @@ -0,0 +1,77 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies. +# +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. + +[package] +edition = "2021" +rust-version = "1.70" +name = "webpki-roots" +version = "1.0.8" +build = false +autolib = false +autobins = false +autoexamples = false +autotests = false +autobenches = false +description = "Mozilla's CA root certificates for use with webpki" +homepage = "https://github.com/rustls/webpki-roots" +readme = "README.md" +license = "CDLA-Permissive-2.0" +repository = "https://github.com/rustls/webpki-roots" + +[lib] +name = "webpki_roots" +path = "src/lib.rs" + +[[test]] +name = "codegen" +path = "tests/codegen.rs" + +[[test]] +name = "verify" +path = "tests/verify.rs" + +[dependencies.pki-types] +version = "1.8" +default-features = false +package = "rustls-pki-types" + +[dev-dependencies.aws-lc-rs] +version = "1.15.2" + +[dev-dependencies.hex] +version = "0.4.3" + +[dev-dependencies.percent-encoding] +version = "2.3" + +[dev-dependencies.rcgen] +version = "0.14.3" + +[dev-dependencies.rustls] +version = "0.23" + +[dev-dependencies.tokio] +version = "1" +features = [ + "macros", + "rt-multi-thread", +] + +[dev-dependencies.webpki] +version = "0.103" +features = ["alloc"] +package = "rustls-webpki" + +[dev-dependencies.x509-parser] +version = "0.18" + +[dev-dependencies.yasna] +version = "0.6" diff --git a/http/vendor/webpki-roots/Cargo.toml.orig b/http/vendor/webpki-roots/Cargo.toml.orig new file mode 100644 index 0000000..d534f1b --- /dev/null +++ b/http/vendor/webpki-roots/Cargo.toml.orig @@ -0,0 +1,25 @@ +[package] +name = "webpki-roots" +version = "1.0.8" +edition = { workspace = true } +rust-version = { workspace = true } +readme = "README.md" +license = "CDLA-Permissive-2.0" +homepage = { workspace = true } +repository = { workspace = true } +description = "Mozilla's CA root certificates for use with webpki" + +[dependencies] +pki-types = { workspace = true } + +[dev-dependencies] +aws-lc-rs = { workspace = true } +hex = { workspace = true } +percent-encoding = { workspace = true } +rcgen = { workspace = true } +rustls = { workspace = true } +tokio = { version = "1", features = ["macros", "rt-multi-thread"] } +webpki = { workspace = true } +webpki-ccadb = { path = "../webpki-ccadb" } +x509-parser = { workspace = true } +yasna = { workspace = true } diff --git a/http/vendor/webpki-roots/LICENSE b/http/vendor/webpki-roots/LICENSE new file mode 100644 index 0000000..8e84169 --- /dev/null +++ b/http/vendor/webpki-roots/LICENSE @@ -0,0 +1,61 @@ +# Community Data License Agreement - Permissive - Version 2.0 + +This is the Community Data License Agreement - Permissive, Version +2.0 (the "agreement"). Data Provider(s) and Data Recipient(s) agree +as follows: + +## 1. Provision of the Data + +1.1. A Data Recipient may use, modify, and share the Data made +available by Data Provider(s) under this agreement if that Data +Recipient follows the terms of this agreement. + +1.2. This agreement does not impose any restriction on a Data +Recipient's use, modification, or sharing of any portions of the +Data that are in the public domain or that may be used, modified, +or shared under any other legal exception or limitation. + +## 2. Conditions for Sharing Data + +2.1. A Data Recipient may share Data, with or without modifications, so +long as the Data Recipient makes available the text of this agreement +with the shared Data. + +## 3. No Restrictions on Results + +3.1. This agreement does not impose any restriction or obligations +with respect to the use, modification, or sharing of Results. + +## 4. No Warranty; Limitation of Liability + +4.1. All Data Recipients receive the Data subject to the following +terms: + +THE DATA IS PROVIDED ON AN "AS IS" BASIS, WITHOUT REPRESENTATIONS, +WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED +INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, +NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + +NO DATA PROVIDER SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING +WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE DATA OR RESULTS, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +## 5. Definitions + +5.1. "Data" means the material received by a Data Recipient under +this agreement. + +5.2. "Data Provider" means any person who is the source of Data +provided under this agreement and in reliance on a Data Recipient's +agreement to its terms. + +5.3. "Data Recipient" means any person who receives Data directly +or indirectly from a Data Provider and agrees to the terms of this +agreement. + +5.4. "Results" means any outcome obtained by computational analysis +of Data, including for example machine learning models and models' +insights. diff --git a/http/vendor/webpki-roots/README.md b/http/vendor/webpki-roots/README.md new file mode 100644 index 0000000..0f6b7d7 --- /dev/null +++ b/http/vendor/webpki-roots/README.md @@ -0,0 +1,20 @@ +# webpki-roots +This is a crate containing Mozilla's root certificates for use with +the [webpki](https://github.com/rustls/webpki) or +[rustls](https://github.com/rustls/rustls) crates. + +This crate is inspired by [certifi.io](https://certifi.io/en/latest/) and +uses the data provided by the [Common CA Database (CCADB)](https://www.ccadb.org/). + +[![webpki-roots](https://github.com/rustls/webpki-roots/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/rustls/webpki-roots/actions/workflows/build.yml) +[![Crate](https://img.shields.io/crates/v/webpki-roots.svg)](https://crates.io/crates/webpki-roots) + +# License +The underlying data is used via the [CCADB Data Usage Terms](https://www.ccadb.org/rootstores/usage#ccadb-data-usage-terms) (see [`LICENSE`](LICENSE)). +The data in this crate is a derived work of the CCADB data. + +# Regenerating sources +Sources are generated in an integration test, in `tests/codegen.rs`. The test +will fail if the sources are out of date relative to upstream, and update +`src/lib.rs` if so. The code is generated in deterministic order so changes +to the source should only result from upstream changes. diff --git a/http/vendor/webpki-roots/src/lib.rs b/http/vendor/webpki-roots/src/lib.rs new file mode 100644 index 0000000..97964de --- /dev/null +++ b/http/vendor/webpki-roots/src/lib.rs @@ -0,0 +1,4492 @@ +//! A compiled-in copy of the root certificates trusted by Mozilla. +//! +//! To use this library with rustls 0.22: +//! +//! ```rust +//! let root_store = rustls::RootCertStore { +//! roots: webpki_roots::TLS_SERVER_ROOTS.to_vec(), +//! }; +//! ``` +//! +//! This library is suitable for use in applications that can always be recompiled and instantly deployed. +//! For applications that are deployed to end-users and cannot be recompiled, or which need certification +//! before deployment, consider a library that uses the platform native certificate verifier such as +//! [rustls-platform-verifier]. This has the additional benefit of supporting OS provided CA constraints +//! and revocation data. +//! +//! [rustls-platform-verifier]: https://docs.rs/rustls-platform-verifier +// +// This library is automatically generated from the Mozilla +// IncludedCACertificateReportPEMCSV report via ccadb.org. Don't edit it. +// +// The generation is done deterministically so you can verify it +// yourself by inspecting and re-running the generation process. + +#![no_std] +#![forbid(unsafe_code, unstable_features)] +#![deny( + elided_lifetimes_in_paths, + trivial_casts, + trivial_numeric_casts, + unused_import_braces, + unused_extern_crates, + unused_qualifications +)] + +use pki_types::{Der, TrustAnchor}; + +pub const TLS_SERVER_ROOTS: &[TrustAnchor<'static>] = &[ + /* + * Issuer: CN=DigiCert TLS ECC P384 Root G5 O=DigiCert, Inc. + * Subject: CN=DigiCert TLS ECC P384 Root G5 O=DigiCert, Inc. + * Label: "DigiCert TLS ECC P384 Root G5" + * Serial: 13129116028163249804115411775095713523 + * SHA256 Fingerprint: 01:8e:13:f0:77:25:32:cf:80:9b:d1:b1:72:81:86:72:83:fc:48:c6:e1:3b:e9:c6:98:12:85:4a:49:0c:1b:05 + * -----BEGIN CERTIFICATE----- + * MIICGTCCAZ+gAwIBAgIQCeCTZaz32ci5PhwLBCou8zAKBggqhkjOPQQDAzBOMQsw + * CQYDVQQGEwJVUzEXMBUGA1UEChMORGlnaUNlcnQsIEluYy4xJjAkBgNVBAMTHURp + * Z2lDZXJ0IFRMUyBFQ0MgUDM4NCBSb290IEc1MB4XDTIxMDExNTAwMDAwMFoXDTQ2 + * MDExNDIzNTk1OVowTjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDkRpZ2lDZXJ0LCBJ + * bmMuMSYwJAYDVQQDEx1EaWdpQ2VydCBUTFMgRUNDIFAzODQgUm9vdCBHNTB2MBAG + * ByqGSM49AgEGBSuBBAAiA2IABMFEoc8Rl1Ca3iOCNQfN0MsYndLxf3c1TzvdlHJS + * 7cI7+Oz6e2tYIOyZrsn8aLN1udsJ7MgT9U7GCh1mMEy7H0cKPGEQQil8pQgO4CLp + * 0zVozptjn4S1mU1YoI71VOeVyaNCMEAwHQYDVR0OBBYEFMFRRVBZqz7nLFr6ICIS + * B4CIfBFqMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MAoGCCqGSM49 + * BAMDA2gAMGUCMQCJao1H5+z8blUD2WdsJk6Dxv3J+ysTvLd6jLRl0mlpYxNjOyZQ + * LgGheQaRnUi/wr4CMEfDFXuxoJGZSZOoPHzoRgaLLPIxAJSdYsiJvRmEFOml+wG4 + * DXZDjC5Ty3zfDBeWUA== + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1\x170\x15\x06\x03U\x04\n\x13\x0eDigiCert, Inc.1&0$\x06\x03U\x04\x03\x13\x1dDigiCert TLS ECC P384 Root G5"), + subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\"\x03b\x00\x04\xc1D\xa1\xcf\x11\x97P\x9a\xde#\x825\x07\xcd\xd0\xcb\x18\x9d\xd2\xf1\x7fw5O;\xdd\x94rR\xed\xc2;\xf8\xec\xfa{kX \xec\x99\xae\xc9\xfch\xb3u\xb9\xdb\t\xec\xc8\x13\xf5N\xc6\n\x1df0L\xbb\x1fG\nOx\x1f\x94q$\xea\xdep\xfc\xf1\x93\xfe\x9e\x93Z\xe4\x94Z\x97T\x0c5{_l\xee\x00\x1f$\xec\x03\xba\x02\xf5v\xf4\x9f\xd4\x9a\xed\x85,8\"/\xc7\xd8/v\x11O\xfdl\\\xe8\xf5\x8e\'\x87\x7f\x19J!G\x90\x1dy\x8d\x1c[\xf8\xcfJ\x85\xe4\xed\xb3[\x8d\xbe\xc4d(]A\xc4n\xac8ZO#tt\xa9\x12\xc3\xf6\xd2\xb9\x11\x153\x07\x91\xd8;7:c0\x06\xd1\xc5\"6(b#\x10\xe0F\xcc\x97\xac\xd6+]d$\xd5\xee\x1c\x0e\xde\xfb\x08Zu*\xf6cm\xce\x0bB\xbe\xd1\xbap\x1c\x9c!\xe5\x0f1i\x17\xd7\xfc\n\xb4\xde\xed\x80\x9c\xcb\x92\xb4\x8b\xf5\xdeY\xa2X\t\xa5cG\x0b\xe1A24A\xd9\x9a\xb1\xd9\xa8\xb0\x1bZ\xde\r\r\xf4\xe2\xb2]5\x80\xb9\x81\xd4\x84i\x91\x02\xcbu\xd0\x8d\xc5\xb5=\t\x91\t\x8f\x14\xa1\x14ty>\xd6\xc9\x15\x1d\xa4YY\"\xdc\xf6\x8aE=<\x12\xd6>]2/\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=TrustAsia TLS RSA Root CA O=TrustAsia Technologies, Inc. + * Subject: CN=TrustAsia TLS RSA Root CA O=TrustAsia Technologies, Inc. + * Label: "TrustAsia TLS RSA Root CA" + * Serial: 160405846464868906657516898462547310235378010780 + * SHA256 Fingerprint: 06:c0:8d:7d:af:d8:76:97:1e:b1:12:4f:e6:7f:84:7e:c0:c7:a1:58:d3:ea:53:cb:e9:40:e2:ea:97:91:f4:c3 + * -----BEGIN CERTIFICATE----- + * MIIFgDCCA2igAwIBAgIUHBjYz+VTPyI1RlNUJDxsR9FcSpwwDQYJKoZIhvcNAQEM + * BQAwWDELMAkGA1UEBhMCQ04xJTAjBgNVBAoTHFRydXN0QXNpYSBUZWNobm9sb2dp + * ZXMsIEluYy4xIjAgBgNVBAMTGVRydXN0QXNpYSBUTFMgUlNBIFJvb3QgQ0EwHhcN + * MjQwNTE1MDU0MTU3WhcNNDQwNTE1MDU0MTU2WjBYMQswCQYDVQQGEwJDTjElMCMG + * A1UEChMcVHJ1c3RBc2lhIFRlY2hub2xvZ2llcywgSW5jLjEiMCAGA1UEAxMZVHJ1 + * c3RBc2lhIFRMUyBSU0EgUm9vdCBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCC + * AgoCggIBAMMWuBtqpERz5dZO9LnPWwvB0ZqB9WOwj0PBuwhaGnrhB3YmH49pVr7+ + * NmDQDIPNlOrnxS1cLwUWAp4KqC/lYCZUlviYQB2srp10Zy9U+5RjmOMmSoPGlbYJ + * Q1DNDX3eRA5gEk9bNb2/mThtfWza4mhzH/kxpRkQcwUqwzIZheo0qt1CHjCNP561 + * HmHVb70AcnKtEj+qpklz8oYVlQwQX1Fkzv93uMltrOXVmPGZLmzjyUT5tUMnCE32 + * ft5EebuyjBza00tsLtbDeLdM1aTk2tyKjg7/D8OmYCYozza/+lcK7Fs/6TAWe8Tb + * xNRkoDD75f0dcZLdKY9BWN4ArTr9PXwaqLEX8E40eFgl1oUh63kd0Nyrz2I8sMeX + * i9bQn9P+PN7F4/w6g3CEIR0JwqH8uyghZVNgepBtljhb//HXeltt08lwSUq6HTrQ + * UNoyIBnkiz/r1RYmNzz7dZ6wB3C4FGB33PYPXFIKvF1tjVEK2sUYyJtt3LCDs3+j + * TnhMmCWr8n4uIF6CFabW2I+s5c0yhsj55NqJ4js+k8UTav/H9xj8Z7XvGCxUq0DT + * bE3txci3OE9kxJRMT6DNrqXGJyV1J23G2pyOsAWZ1SgRxSHUuPzHlqtKZFlhaxP8 + * S8ySpg+kUb8OWJDZgoM5pl+z+m6Ss80zDoWo8SnTq1mt1tve1CuBAgMBAAGjQjBA + * MA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFLgHkXlcBvRG/XtZylomkadFK/hT + * MA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQwFAAOCAgEAIZtqBSBdGBanEqT3 + * Rz/NyjuujsCCztxIJXgXbODgcMTWltnZ9r96nBO7U5WS/8+S4PPFJzVXqDuiGev4 + * iqME3mmL5Dw8veWv0BIb5Ylrc5tvJQJLkIKvQMKtuppgJFqBTQUYo+IzeXoLH5Pt + * 7DlK9RME7I10nYEKqG/odv6LTytpEoYKNDbdgptvT+Bz3Ul/KD7JO6NXBNiT2Twp + * 2xIQaOHEibgGIOcberyxk2GaGUARtWqFVwHxtlotJnMnlvm5P1vQiJ3koP26TpUJ + * g3933FEFlJ0gcXax7PqJtZwuhfG5WyRasQmr2soaB82G39tp27RIGAAtvKLEiUUj + * pQ7hRGU+isFqMB3iYPg6qocJQrmBktwliJiJ8Xw18WLK7nn4GS/+X/jbh87qqA8M + * pugLoDzga5SYnH+tBuYc6kIQX+ImFTw3OffXvO645e8D7r0i+yiGNFjEWn9hongP + * XvPKnbwbPKfILfanIhHKA9jnZwqKDss1jjQ52MjqjZ9k4DewbNfFj8GQYSbbJIwe + * SsCI3zWQzj8C9GRh3sfIB5XeMhg6j6JCQCTl1jNdfK7vsU1P1FeQNWrcrgSXSYk0 + * ly4wBOeY99sLAZDBHwo/+ML+TvrbmnNzFrwFuHnYWa8G5z9nODmxfKuU4CkUpijy + * 323imttUQ/hHWKNddBWcwauwxzQ= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02CN1%0#\x06\x03U\x04\n\x13\x1cTrustAsia Technologies, Inc.1\"0 \x06\x03U\x04\x03\x13\x19TrustAsia TLS RSA Root CA"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xc3\x16\xb8\x1bj\xa4Ds\xe5\xd6N\xf4\xb9\xcf[\x0b\xc1\xd1\x9a\x81\xf5c\xb0\x8fC\xc1\xbb\x08Z\x1az\xe1\x07v&\x1f\x8fiV\xbe\xfe6`\xd0\x0c\x83\xcd\x94\xea\xe7\xc5-\\/\x05\x16\x02\x9e\n\xa8/\xe5`&T\x96\xf8\x98@\x1d\xac\xae\x9dtg/T\xfb\x94c\x98\xe3&J\x83\xc6\x95\xb6\tCP\xcd\r}\xdeD\x0e`\x12O[5\xbd\xbf\x998m}l\xda\xe2hs\x1f\xf91\xa5\x19\x10s\x05*\xc32\x19\x85\xea4\xaa\xddB\x1e0\x8d?\x9e\xb5\x1ea\xd5o\xbd\x00rr\xad\x12?\xaa\xa6Is\xf2\x86\x15\x95\x0c\x10_Qd\xce\xffw\xb8\xc9m\xac\xe5\xd5\x98\xf1\x99.l\xe3\xc9D\xf9\xb5C\'\x08M\xf6~\xdeDy\xbb\xb2\x8c\x1c\xda\xd3Kl.\xd6\xc3x\xb7L\xd5\xa4\xe4\xda\xdc\x8a\x8e\x0e\xff\x0f\xc3\xa6`&(\xcf6\xbf\xfaW\n\xec[?\xe90\x16{\xc4\xdb\xc4\xd4d\xa00\xfb\xe5\xfd\x1dq\x92\xdd)\x8fAX\xde\x00\xad:\xfd=|\x1a\xa8\xb1\x17\xf0N4xX%\xd6\x85!\xeby\x1d\xd0\xdc\xab\xcfb<\xb0\xc7\x97\x8b\xd6\xd0\x9f\xd3\xfe<\xde\xc5\xe3\xfc:\x83p\x84!\x1d\t\xc2\xa1\xfc\xbb(!eS`z\x90m\x968[\xff\xf1\xd7z[m\xd3\xc9pIJ\xba\x1d:\xd0P\xda2 \x19\xe4\x8b?\xeb\xd5\x16&7<\xfbu\x9e\xb0\x07p\xb8\x14`w\xdc\xf6\x0f\\R\n\xbc]m\x8dQ\n\xda\xc5\x18\xc8\x9bm\xdc\xb0\x83\xb3\x7f\xa3NxL\x98%\xab\xf2~. ^\x82\x15\xa6\xd6\xd8\x8f\xac\xe5\xcd2\x86\xc8\xf9\xe4\xda\x89\xe2;>\x93\xc5\x13j\xff\xc7\xf7\x18\xfcg\xb5\xef\x18,T\xab@\xd3lM\xed\xc5\xc8\xb78Od\xc4\x94LO\xa0\xcd\xae\xa5\xc6\'%u\'m\xc6\xda\x9c\x8e\xb0\x05\x99\xd5(\x11\xc5!\xd4\xb8\xfc\xc7\x96\xabJdYak\x13\xfcK\xcc\x92\xa6\x0f\xa4Q\xbf\x0eX\x90\xd9\x82\x839\xa6_\xb3\xfan\x92\xb3\xcd3\x0e\x85\xa8\xf1)\xd3\xabY\xad\xd6\xdb\xde\xd4+\x81\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=D-TRUST EV Root CA 1 2020 O=D-Trust GmbH + * Subject: CN=D-TRUST EV Root CA 1 2020 O=D-Trust GmbH + * Label: "D-TRUST EV Root CA 1 2020" + * Serial: 126288379621884218666039612629459926992 + * SHA256 Fingerprint: 08:17:0d:1a:a3:64:53:90:1a:2f:95:92:45:e3:47:db:0c:8d:37:ab:aa:bc:56:b8:1a:a1:00:dc:95:89:70:db + * -----BEGIN CERTIFICATE----- + * MIIC2zCCAmCgAwIBAgIQXwJB13qHfEwDo6yWjfv/0DAKBggqhkjOPQQDAzBIMQsw + * CQYDVQQGEwJERTEVMBMGA1UEChMMRC1UcnVzdCBHbWJIMSIwIAYDVQQDExlELVRS + * VVNUIEVWIFJvb3QgQ0EgMSAyMDIwMB4XDTIwMDIxMTEwMDAwMFoXDTM1MDIxMTA5 + * NTk1OVowSDELMAkGA1UEBhMCREUxFTATBgNVBAoTDEQtVHJ1c3QgR21iSDEiMCAG + * A1UEAxMZRC1UUlVTVCBFViBSb290IENBIDEgMjAyMDB2MBAGByqGSM49AgEGBSuB + * BAAiA2IABPEL3YZDIBnfl4XoIkqbz52Yv7QFJsnL46bSj8WeeHsxiamJrSc8ZRCC + * /N/DnU7wMyPE0jL1HLDfMxddxfCxivnvubcUyilKwg+pf3VlSSowZ/Rk99Yad9rD + * wpdhQntJraOCAQ0wggEJMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFH8QARY3 + * OqQo5FD4pPfsazK2/umLMA4GA1UdDwEB/wQEAwIBBjCBxgYDVR0fBIG+MIG7MD6g + * PKA6hjhodHRwOi8vY3JsLmQtdHJ1c3QubmV0L2NybC9kLXRydXN0X2V2X3Jvb3Rf + * Y2FfMV8yMDIwLmNybDB5oHegdYZzbGRhcDovL2RpcmVjdG9yeS5kLXRydXN0Lm5l + * dC9DTj1ELVRSVVNUJTIwRVYlMjBSb290JTIwQ0ElMjAxJTIwMjAyMCxPPUQtVHJ1 + * c3QlMjBHbWJILEM9REU/Y2VydGlmaWNhdGVyZXZvY2F0aW9ubGlzdDAKBggqhkjO + * PQQDAwNpADBmAjEAyjzGKnXCXnViOTYAYFqLwZOZzNnbQTs7h5kXO9XMT8oi96CA + * y/m0sRtW9XLS/BnRAjEAkfcwkz8QRitxpNA7RJvAKQIFskF3UfN5Wp6OFKBOQtJb + * gfM0agPnIjhQW+0ZT0MW + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02DE1\x150\x13\x06\x03U\x04\n\x13\x0cD-Trust GmbH1\"0 \x06\x03U\x04\x03\x13\x19D-TRUST EV Root CA 1 2020"), + subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\"\x03b\x00\x04\xf1\x0b\xdd\x86C \x19\xdf\x97\x85\xe8\"J\x9b\xcf\x9d\x98\xbf\xb4\x05&\xc9\xcb\xe3\xa6\xd2\x8f\xc5\x9ex{1\x89\xa9\x89\xad\'\xc0\xce\x9a\xaf\xacVB*9%p\xd6\xbf\xb5{6\xad\xac\xf6s\xdc\xcd\xd7\x1d\x8a\x83\xa5\xfb+\x90\x157k\x1c&G\xdc;)V\x93j\xb3\xc1j:\x9d=\xf5\xc1\x978X\x05\x8b\x1c\x11\xe3\xe4\xb4\xb8]\x85\x1d\x83\xfex_\x0bEh\x18H\xa5Fs4;\xfe\x0f\xc8v\xbb\xc7\x18\xf3\x05\xd1\x86\xf3\x85\xed\xe7\xb9\xd92\xadU\x88\xce\xa6\xb6\x91\xb0O\xac~\x15#\x96\xf6?\xf0 4\x16\xde\n\xc6\xc4\x04Ey\x7f\xa7\xfd\xbe\xd2\xa9\xa5\xaf\x9c\xc5#*\xf7R\x0b\x06\xceA\x00\x7f\x97\xe1\n$<\x1d\x01\x04\xee=\xd2\x8d\t\x97\x0c\xe0u\xe4\xfa\xfbw\x8a*\xf5\x03`K6\x8b\x16#\x16\xad\tq\xf4J\xf4(P\xb4\xfe\x88\x1cn?l//\tY[\xa5[\x0b3\x99\xe2\xc3=\x89\xf9j,\xef\xb2\xd3\x06\xe9"), + name_constraints: None + }, + + /* + * Issuer: CN=GlobalSign O=GlobalSign OU=GlobalSign ECC Root CA - R5 + * Subject: CN=GlobalSign O=GlobalSign OU=GlobalSign ECC Root CA - R5 + * Label: "GlobalSign" + * Serial: 32785792099990507226680698011560947931244 + * SHA256 Fingerprint: 17:9f:bc:14:8a:3d:d0:0f:d2:4e:a1:34:58:cc:43:bf:a7:f5:9c:81:82:d7:83:a5:13:f6:eb:ec:10:0c:89:24 + * -----BEGIN CERTIFICATE----- + * MIICHjCCAaSgAwIBAgIRYFlJ4CYuu1X5CneKcflK2GwwCgYIKoZIzj0EAwMwUDEk + * MCIGA1UECxMbR2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI1MRMwEQYDVQQKEwpH + * bG9iYWxTaWduMRMwEQYDVQQDEwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoX + * DTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMbR2xvYmFsU2lnbiBFQ0MgUm9vdCBD + * QSAtIFI1MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQDEwpHbG9iYWxTaWdu + * MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAER0UOlvt9Xb/pOdEh+J8LttV7HpI6SFkc + * 8GIxLcB6KP4ap1yztsyX50XUWPrRd21DosCHZTQKH3rd6zwzocWdTaRvQZU4f8ke + * hOvRnkmSh5SHDDqFSmafnVmTTZdhBoZKo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYD + * VR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUPeYpSJvqB8ohREom3m7e0oPQn1kwCgYI + * KoZIzj0EAwMDaAAwZQIxAOVpEslu28YxuglB4Zf4+/2a4n0Sye18ZNPLBSWLVtmg + * 515dTguDnFt2KaAJJiFqYgIwcdK1j1zqO+F4CYWodZI7yFz9SO8NdCKoCOJuxUnO + * xwy8p2Fp8fc74SrL+SvzZpA3 + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1$0\"\x06\x03U\x04\x0b\x13\x1bGlobalSign ECC Root CA - R51\x130\x11\x06\x03U\x04\n\x13\nGlobalSign1\x130\x11\x06\x03U\x04\x03\x13\nGlobalSign"), + subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\"\x03b\x00\x04GE\x0e\x96\xfb}]\xbf\xe99\xd1!\xf8\x9f\x0b\xb6\xd5{\x1e\x92:HY\x1c\xf0b1-\xc0z(\xfe\x1a\xa7\\\xb3\xb6\xcc\x97\xe7E\xd4X\xfa\xd1wmC\xa2\xc0\x87e4\n\x1fz\xdd\xeb<3\xa1\xc5\x9dM\xa4oA\x958\x7f\xc9\x1e\x84\xeb\xd1\x9eI\x92\x87\x94\x87\x0c:\x85Jf\x9f\x9dY\x93M\x97a\x06\x86J"), + name_constraints: None + }, + + /* + * Issuer: CN=Amazon Root CA 3 O=Amazon + * Subject: CN=Amazon Root CA 3 O=Amazon + * Label: "Amazon Root CA 3" + * Serial: 143266986699090766294700635381230934788665930 + * SHA256 Fingerprint: 18:ce:6c:fe:7b:f1:4e:60:b2:e3:47:b8:df:e8:68:cb:31:d0:2e:bb:3a:da:27:15:69:f5:03:43:b4:6d:b3:a4 + * -----BEGIN CERTIFICATE----- + * MIIBtjCCAVugAwIBAgITBmyf1XSXNmY/Owua2eiedgPySjAKBggqhkjOPQQDAjA5 + * MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24g + * Um9vdCBDQSAzMB4XDTE1MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkG + * A1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJvb3Qg + * Q0EgMzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABCmXp8ZBf8ANm+gBG1bG8lKl + * ui2yEujSLtf6ycXYqm0fc4E7O5hrOXwzpcVOho6AF2hiRVd9RFgdszflZwjrZt6j + * QjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSr + * ttvXBp43rDCGB5Fwx5zEGbF4wDAKBggqhkjOPQQDAgNJADBGAiEA4IWSoxe3jfkr + * BqWTrBqYaGFy+uGh0PsceGCmQ5nFuMQCIQCcAu/xlJyzlvnrxir4tiz+OpAUFteM + * YyRIHN8wfdVoOw== + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1\x0f0\r\x06\x03U\x04\n\x13\x06Amazon1\x190\x17\x06\x03U\x04\x03\x13\x10Amazon Root CA 3"), + subject_public_key_info: Der::from_slice(b"0\x13\x06\x07*\x86H\xce=\x02\x01\x06\x08*\x86H\xce=\x03\x01\x07\x03B\x00\x04)\x97\xa7\xc6A\x7f\xc0\r\x9b\xe8\x01\x1bV\xc6\xf2R\xa5\xba-\xb2\x12\xe8\xd2.\xd7\xfa\xc9\xc5\xd8\xaam\x1fs\x81;;\x98k9|3\xa5\xc5N\x86\x8e\x80\x17hbEW}DX\x1d\xb37\xe5g\x08\xebf\xde"), + name_constraints: None + }, + + /* + * Issuer: CN=SwissSign RSA TLS Root CA 2022 - 1 O=SwissSign AG + * Subject: CN=SwissSign RSA TLS Root CA 2022 - 1 O=SwissSign AG + * Label: "SwissSign RSA TLS Root CA 2022 - 1" + * Serial: 388078645722908516278762308316089881486363258315 + * SHA256 Fingerprint: 19:31:44:f4:31:e0:fd:db:74:07:17:d4:de:92:6a:57:11:33:88:4b:43:60:d3:0e:27:29:13:cb:e6:60:ce:41 + * -----BEGIN CERTIFICATE----- + * MIIFkzCCA3ugAwIBAgIUQ/oMX04bgBhE79G0TzUfRPSA7cswDQYJKoZIhvcNAQEL + * BQAwUTELMAkGA1UEBhMCQ0gxFTATBgNVBAoTDFN3aXNzU2lnbiBBRzErMCkGA1UE + * AxMiU3dpc3NTaWduIFJTQSBUTFMgUm9vdCBDQSAyMDIyIC0gMTAeFw0yMjA2MDgx + * MTA4MjJaFw00NzA2MDgxMTA4MjJaMFExCzAJBgNVBAYTAkNIMRUwEwYDVQQKEwxT + * d2lzc1NpZ24gQUcxKzApBgNVBAMTIlN3aXNzU2lnbiBSU0EgVExTIFJvb3QgQ0Eg + * MjAyMiAtIDEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDLKmjiC8NX + * vDVjvHClO/OMPE5Xlm7DTjak9gLKHqquuN6orx122ro10JFwB9+zBvKK8i5VUXu7 + * LCTLf5ImgKO0lPaCoaTo+nUdWfMHamFk4saMla+ju45vVs9xzF6BYQ1t8qsCLqSX + * 5XH8irCRIFucdFJtrhUnWXjyCcplDn/L9Ovn3KlMd/YrFgSVrpxxpT8q2kFC5zyE + * EPThPYxr4iuRR1VPuFa+Rd4iUU1OKNlfGUEGjw5NBuBwQCMBauTLE5tzrE0USJIt + * /m2n+IdreXXhvhCxqohAWVTXz8TQm0SzOGlkjIHRI36qOTw7D59Ke4LKa2/KIj4x + * 0LDQKhySio/YGZxH5D4MucLNvkEM+KRHBdvBFzA4OmnczcNpI/2aDwLOEGrOyvi5 + * KaM2iYauC8BPY7kGWUleDsFpswrzd34unYyzJ5jSmY0lpx+Gs6ZUcDj8fV3oT4MM + * 0ZPlEuRU2j7yrTrePjxF8CgPBrnh25d7mUWe3f6VWQQvdT/TromZhqwUtKiE+shd + * OxtYk8EXlFXIC+OCeYSf8wCENO7cMdWP8vpPlkwGqnj73mSiI80fPsWMvDdUDrta + * clXvyFu1cvh43zcgTFeRc5JzrBh3Q4IgaezprClG5QtO+DdziZaKHG29777YtvTK + * wP1H8K4LWCDFyB02rpeNUIMmJCn3nTsPBQIDAQABo2MwYTAPBgNVHRMBAf8EBTAD + * AQH/MA4GA1UdDwEB/wQEAwIBBjAfBgNVHSMEGDAWgBRvjmKLk0Ow4UD2p8P98Q+4 + * DxU4pTAdBgNVHQ4EFgQUb45ii5NDsOFA9qfD/fEPuA8VOKUwDQYJKoZIhvcNAQEL + * BQADggIBAKwsKUF9+lz1GpUYvyypiqkkVHX1uECry6gkUSsYP2OprphWKwVDIqO3 + * 10aewCoSPY6WlkDfDDOLazeROpW7OSltwAJsipQLBwJNGD77+3v1dj2b9l4wBlgz + * Hqp41eZUBDqyggmNzhYzWUUo8aWjlw5DI/0LIICQ/+Mmz7hkkeUFjxOgdg3XNwwQ + * iJb0Pr6VvfHDffCjw3lHC1ySFWPtUnWK50Zpy1FVCypM9fJkT6lc/2cyjlUtMoIc + * gC9qkfjLvH4YoiaoLqNTKIftV+Vlek4ASltOU8liNr3CjlvrzG4ngRhZi0Rjn9UM + * ZfQpZX+RLOV/fuiJz48gy20HQhFRJjKKLjpHE7iNvUcNCfAWpO2Whi4Z2L6MOuhF + * LhG6rlrnub+xzI/goP+4s9GFe3lmozm1O2bYQL7Pt2eLSMkZJVX8vY3PXtpOpvJp + * zv1/THfQwUY1mFwjmwJFQ5Ra3bxHrSL+ul4vkSkphnsh3m5kt8sNjzdbowhq6/Td + * Ao9QAwKxuDdollDruF/UKIqlIgyKhPBZLtU30WHlQnNYKoH3dtvi4k0NX/a3vgW0 + * rk4N3hY9A4GzJl5LuEsAz/+MF7psYC0nhzck5npgL7XTgwSqT0N1osGDsieYK7EO + * gLrAhV5Cud+xYJHT6xh+cHiudoO+cVrQkOPKwRYlZ0rwtnu64ZzZ + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02CH1\x150\x13\x06\x03U\x04\n\x13\x0cSwissSign AG1+0)\x06\x03U\x04\x03\x13\"SwissSign RSA TLS Root CA 2022 - 1"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xcb*h\xe2\x0b\xc3W\xbc5c\xbcp\xa5;\xf3\x8c1\xd0\xb0\xd0*\x1c\x92\x8a\x8f\xd8\x19\x9cG\xe4>\x0c\xb9\xc2\xcd\xbeA\x0c\xf8\xa4G\x05\xdb\xc1\x1708:i\xdc\xcd\xc3i#\xfd\x9a\x0f\x02\xce\x10j\xce\xca\xf8\xb9)\xa36\x89\x86\xae\x0b\xc0Oc\xb9\x06YI^\x0e\xc1i\xb3\n\xf3w~.\x9d\x8c\xb3\'\x98\xd2\x99\x8d%\xa7\x1f\x86\xb3\xa6Tp8\xfc}]\xe8O\x83\x0c\xd1\x93\xe5\x12\xe4T\xda>\xf2\xad:\xde>\xc5\x8c\xbc7T\x0e\xbbZrU\xef\xc8[\xb5r\xf8x\xdf7 LW\x91s\x92s\xac\x18wC\x82 i\xec\xe9\xac)F\xe5\x0bN\xf87s\x89\x96\x8a\x1cm\xbd\xef\xbe\xd8\xb6\xf4\xca\xc0\xfdG\xf0\xae\x0bX \xc5\xc8\x1d6\xae\x97\x8dP\x83&$)\xf7\x9d;\x0f\x05\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=Amazon Root CA 2 O=Amazon + * Subject: CN=Amazon Root CA 2 O=Amazon + * Label: "Amazon Root CA 2" + * Serial: 143266982885963551818349160658925006970653239 + * SHA256 Fingerprint: 1b:a5:b2:aa:8c:65:40:1a:82:96:01:18:f8:0b:ec:4f:62:30:4d:83:ce:c4:71:3a:19:c3:9c:01:1e:a4:6d:b4 + * -----BEGIN CERTIFICATE----- + * MIIFQTCCAymgAwIBAgITBmyf0pY1hp8KD+WGePhbJruKNzANBgkqhkiG9w0BAQwF + * ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6 + * b24gUm9vdCBDQSAyMB4XDTE1MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTEL + * MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJv + * b3QgQ0EgMjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK2Wny2cSkxK + * gXlRmeyKy2tgURO8TW0G/LAIjd0ZEGrHJgw12MBvIITplLGbhQPDW9tK6Mj4kHbZ + * W0/jTOgGNk3Mmqw9DJArktQGGWCsN0R5hYGCrVo34A3MnaZMUnbqQ523BNFQ9lXg + * 1dKmSYXpN+nKfq5clU1Imj+uIFptiJXZNLhSGkOQsL9sBbm2eLfq0OQ6PBJTYv9K + * 8nu+NQWpEjTj82R0Yiw9AElaKP4yRLuH3WUnAnE72kr3H9rN9yFVkE8P7K6C4Z9r + * 2UXTu/Bfh+08LDmG2j/e7HJV63mjrdvdfLC6HM783k81ds8P+HgfajZRRidhW+me + * z/CiVX18JYpvL7TFz4QuK/0NURBs+18bvBt+xa47mAExkv8LV/SasrlX6avvDXbR + * 8O70zoan4G7ptGmh32n2M8ZpLpcTnqWHsFcQgTfJU7O7f/aS0ZzQGPSSbtqDT6Zj + * mUyl+17vIWR6IF9sZIUVyzfpYgwLKhbcAS4y2j5L9Z469hdAlO+ekQiG+r5jqFoz + * 7Mt0Q5X5bGlSNscpb/xVA1wf+5+9R+vnSUeVC06JIglJ4PVhHvG/LopyboBZ/1c6 + * +XUyo05f7O0oYtlNc/LMgRdg7c3r3NunysV+Ar3yVAhU/bQtCSwXVEqY0VThUWcI + * 0u1ufm8/0i2BWSlmy5A5lREedCf+3euvAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMB + * Af8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSwDPBMMPQFWAJI/TPlUq9LhONm + * UjANBgkqhkiG9w0BAQwFAAOCAgEAqqiAjw54o+Ci1M3m9Zh6O+oAA7CXDpO8Wqj2 + * LIxyh6mx/H9z/WNxeKWHWc8w4Q0QshNabYL1auaAn6AFC2jkR2vHat+2/XcycuUY + * +gn0oJMsXdKMdYV2ZZAMA3m3MSNjrXiDCYZohMr/+c8mmpJ5581LxedhpxfL86kS + * k5Nrp+gvU5LEYFiwzAJRGFuFjWJZY7attN6a+yb3ACfAXVU3dJnJUH/jWS5E4ywl + * 7uxMMne0nxrpS10gxdr9HIcWxkPo1LsmmkVwXqkLN1PiRnsn/eBG8om3zEK2yygm + * btmlyTrIQRNg91CMFa6ybRoVGld45pIq2WWQgj9sAq+uEjonljYE1x2igGOpm/Hl + * urR8FLBOybEfdF849lHqm/osohHUqS0nGkWxr7JOcQ3AWEbWaQbLU8uz/mtBzUF+ + * fUwPfHJ5elnNXkoOrJupmHN5fLT0zLm4BwyydFy4x2+IoZCn9Kr5v2c69BoVYh63 + * n749sSmvZ6ES8lgQGVMDMBu4Gon2nL2XA46jCfMdiyHxtN/kHNGfZQIG6lzWE7OE + * 76KlXIx3KadowGuuQNKotOrN8I1LOJwZmhsoVLiJkO/KdYE+HvJkJMcYr07/R54H + * 9jVlpNMKVv/1F2Rs76giJUmTtt8AF9pYfl3uxRuw0dFfIRDH+fO6AgonB8Xx1sfT + * 4PsJYGw= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1\x0f0\r\x06\x03U\x04\n\x13\x06Amazon1\x190\x17\x06\x03U\x04\x03\x13\x10Amazon Root CA 2"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xad\x96\x9f-\x9cJLJ\x81yQ\x99\xec\x8a\xcbk`Q\x13\xbcMm\x06\xfc\xb0\x08\x8d\xdd\x19\x10j\xc7&\x0c5\xd8\xc0o \x84\xe9\x94\xb1\x9b\x85\x03\xc3[\xdbJ\xe8\xc8\xf8\x90v\xd9[O\xe3L\xe8\x066M\xcc\x9a\xac=\x0c\x90+\x92\xd4\x06\x19`\xac7Dy\x85\x81\x82\xadZ7\xe0\r\xcc\x9d\xa6LRv\xeaC\x9d\xb7\x04\xd1P\xf6U\xe0\xd5\xd2\xa6I\x85\xe97\xe9\xca~\xae\\\x95MH\x9a?\xae Zm\x88\x95\xd94\xb8R\x1aC\x90\xb0\xbfl\x05\xb9\xb6x\xb7\xea\xd0\xe4:<\x12Sb\xffJ\xf2{\xbe5\x05\xa9\x124\xe3\xf3dtb,=\x00IZ(\xfe2D\xbb\x87\xdde\'\x02q;\xdaJ\xf7\x1f\xda\xcd\xf7!U\x90O\x0f\xec\xae\x82\xe1\x9fk\xd9E\xd3\xbb\xf0_\x87\xed<,9\x86\xda?\xde\xecrU\xeby\xa3\xad\xdb\xdd|\xb0\xba\x1c\xce\xfc\xdeO5v\xcf\x0f\xf8x\x1fj6QF\'a[\xe9\x9e\xcf\xf0\xa2U}|%\x8ao/\xb4\xc5\xcf\x84.+\xfd\rQ\x10l\xfb_\x1b\xbc\x1b~\xc5\xae;\x98\x011\x92\xff\x0bW\xf4\x9a\xb2\xb9W\xe9\xab\xef\rv\xd1\xf0\xee\xf4\xce\x86\xa7\xe0n\xe9\xb4i\xa1\xdfi\xf63\xc6i.\x97\x13\x9e\xa5\x87\xb0W\x10\x817\xc9S\xb3\xbb\x7f\xf6\x92\xd1\x9c\xd0\x18\xf4\x92n\xda\x83O\xa6c\x99L\xa5\xfb^\xef!dz _ld\x85\x15\xcb7\xe9b\x0c\x0b*\x16\xdc\x01.2\xda>K\xf5\x9e:\xf6\x17@\x94\xef\x9e\x91\x08\x86\xfa\xbec\xa8Z3\xec\xcbtC\x95\xf9liR6\xc7)o\xfcU\x03\\\x1f\xfb\x9f\xbdG\xeb\xe7IG\x95\x0bN\x89\"\tI\xe0\xf5a\x1e\xf1\xbf.\x8arn\x80Y\xffW:\xf9u2\xa3N_\xec\xed(b\xd9Ms\xf2\xcc\x81\x17`\xed\xcd\xeb\xdc\xdb\xa7\xca\xc5~\x02\xbd\xf2T\x08T\xfd\xb4-\t,\x17TJ\x98\xd1T\xe1Qg\x08\xd2\xedn~o?\xd2-\x81Y)f\xcb\x909\x95\x11\x1et\'\xfe\xdd\xeb\xaf\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=SSL.com EV Root Certification Authority ECC O=SSL Corporation + * Subject: CN=SSL.com EV Root Certification Authority ECC O=SSL Corporation + * Label: "SSL.com EV Root Certification Authority ECC" + * Serial: 3182246526754555285 + * SHA256 Fingerprint: 22:a2:c1:f7:bd:ed:70:4c:c1:e7:01:b5:f4:08:c3:10:88:0f:e9:56:b5:de:2a:4a:44:f9:9c:87:3a:25:a7:c8 + * -----BEGIN CERTIFICATE----- + * MIIClDCCAhqgAwIBAgIILCmcWxbtBZUwCgYIKoZIzj0EAwIwfzELMAkGA1UEBhMC + * VVMxDjAMBgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9T + * U0wgQ29ycG9yYXRpb24xNDAyBgNVBAMMK1NTTC5jb20gRVYgUm9vdCBDZXJ0aWZp + * Y2F0aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYwMjEyMTgxNTIzWhcNNDEwMjEyMTgx + * NTIzWjB/MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAOBgNVBAcMB0hv + * dXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjE0MDIGA1UEAwwrU1NMLmNv + * bSBFViBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49 + * AgEGBSuBBAAiA2IABKoSR5CYG/vvw0AHgyBO8TCCogbR8pKGYfL2IWjKAMTH6kMA + * VIbc/R/fALhBYlzccBYy3h+Z1MzFB8gIH2EWB1E9fVwHU+M1OIzfzZ/ZLg1Kthku + * WnBaBu2+8KGwytAJKaNjMGEwHQYDVR0OBBYEFFvKXuXe0oGqzagtZFG22XKbl+ZP + * MA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUW8pe5d7SgarNqC1kUbbZcpuX + * 5k8wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2gAMGUCMQCK5kCJN+vp1RPZ + * ytRrJPOwPYdGWBrssd9v+1a6cGvHOMzosYxPD/fxZ3YOg9AeUY8CMD32IygmTMZg + * h5Mmm7I1HrrW9zzRHM76JTymGoEVW/MSD2zuZYrJh6j5B+BimoxcSg== + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1\x0e0\x0c\x06\x03U\x04\x08\x0c\x05Texas1\x100\x0e\x06\x03U\x04\x07\x0c\x07Houston1\x180\x16\x06\x03U\x04\n\x0c\x0fSSL Corporation1402\x06\x03U\x04\x03\x0c+SSL.com EV Root Certification Authority ECC"), + subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\"\x03b\x00\x04\xaa\x12G\x90\x98\x1b\xfb\xef\xc3@\x07\x83 N\xf10\x82\xa2\x06\xd1\xf2\x92\x86a\xf2\xf6!h\xca\x00\xc4\xc7\xeaC\x00T\x86\xdc\xfd\x1f\xdf\x00\xb8Ab\\\xdcp\x162\xde\x1f\x99\xd4\xcc\xc5\x07\xc8\x08\x1fa\x16\x07Q=}\\\x07S\xe358\x8c\xdf\xcd\x9f\xd9.\rJ\xb6\x19.ZpZ\x06\xed\xbe\xf0\xa1\xb0\xca\xd0\t)"), + name_constraints: None + }, + + /* + * Issuer: CN=Telia Root CA v2 O=Telia Finland Oyj + * Subject: CN=Telia Root CA v2 O=Telia Finland Oyj + * Label: "Telia Root CA v2" + * Serial: 7288924052977061235122729490515358 + * SHA256 Fingerprint: 24:2b:69:74:2f:cb:1e:5b:2a:bf:98:89:8b:94:57:21:87:54:4e:5b:4d:99:11:78:65:73:62:1f:6a:74:b8:2c + * -----BEGIN CERTIFICATE----- + * MIIFdDCCA1ygAwIBAgIPAWdfJ9b+euPkrL4JWwWeMA0GCSqGSIb3DQEBCwUAMEQx + * CzAJBgNVBAYTAkZJMRowGAYDVQQKDBFUZWxpYSBGaW5sYW5kIE95ajEZMBcGA1UE + * AwwQVGVsaWEgUm9vdCBDQSB2MjAeFw0xODExMjkxMTU1NTRaFw00MzExMjkxMTU1 + * NTRaMEQxCzAJBgNVBAYTAkZJMRowGAYDVQQKDBFUZWxpYSBGaW5sYW5kIE95ajEZ + * MBcGA1UEAwwQVGVsaWEgUm9vdCBDQSB2MjCCAiIwDQYJKoZIhvcNAQEBBQADggIP + * ADCCAgoCggIBALLQPwe84nvQa5n44ndp586dpAO8gm2h/oFlH0wnrI4AuhZ76zBq + * AMCzdGh+sq/H1WKzej9Qyow2RCRj0jbpDIX2Q3bVTKFgcmfiKDOlyzG4OiIjNLh9 + * vVYiQJ3q9HsDrWj8soFPmNB06o3lfc1jw6P23pLCWBnglrvFxKk9pXSW/q/5iaq9 + * lRdU2HhE8Qx3FZLgmEKnpNaqIJLNwaCzlrI6hEKNfdWV5Nbb6WLEWLN5xYzTNTOD + * n3WhUidhOPFZPY5Q4L15POdslv5e2QJltI5c0BE0312/UqeBAMN/mUWZFdUXyApT + * 7GPzmX3MaRKGwhfwAZ6/hLzRUssbkmbOpFPlob/E2wnW5olWK8jjfN7j/4nlNW4o + * 6GwLI1GpJQXrSPjdscr6bAhR77cYbETKJuFzxokGgeWKrLDiKca5JLNrRBH0pUPC + * TEPlcDaMtjNXepUugqD0XBCzYYP2AgWGLnwtbNwDRm41k9V6lS/eINhbfpSQBGq6 + * WT0EBXWdN6IOLj3rwaRSg/7Qa9RmjtzG6RJOHSpXqhC8fF6CfaamyfItufUXJ63R + * DolUK5X6wK0dmBR4M0KGCqlztft0DbcbMBnEWg4cJ7faGND/isgFuvGqHKI3t+ZI + * pEYslOqodmJHixBTB0hXbOKSTbauBcvcwUpej6w9GU7C7WB1K9vBykLVAgMBAAGj + * YzBhMB8GA1UdIwQYMBaAFHKs5DN5qkWH9v2sHZ7Wxy+G2CQ5MB0GA1UdDgQWBBRy + * rOQzeapFh/b9rB2e1scvhtgkOTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUw + * AwEB/zANBgkqhkiG9w0BAQsFAAOCAgEAoDtZpwmUPjaE0n4vOaWWl/oRrfxn83EJ + * 8rKJhGdEr7nv7ZbsnGTbMjBvZ5qsfl+yqwE2foH65IRe0qw24GtixX1LDoJt0nZi + * 0f6X+J8wfBj5tFJ3gh1229MdqfDBmgC9bXXYfef6xzijnHDoRnkDry5023X4blMM + * A8iZGok1GTzTyVR8qPAs5m4HeW9q4ebqkYJpCh3DflminmtGFZhb069GHWLIzoBS + * SRE/yQQSwxN8PzuKlts8oB4KtItUsiRnDe+Cy748fdHif64W1lZYudogsYMVoe+K + * TTJvQS8TUoKU1xrBeKJR3Stwbbca+few4GeXVtt8YVMJAygCQMez2P2ccGrGKMOF + * 6eLtGpOg3kuYooQ+BXcBlj37tCAPnHICehIv1aO6UXivKitEZU61/Qrowc15h2Er + * 3oBXRb9n8ZuRXqWk7FlIEA04x7D6w0RtBPV4UBySllva9bguulvP5fBqnUsvWHMt + * Ty3EHD70sz+rFQ47GUGKpMFXEmZxTPpT41frYpUJnlTd0cI8Vzy9OK2YZLe4A5pT + * VmBds9hCG1xLEooc6+t9xnppxyd/pPiL8uSUZodL6ZQHCRJ5irLrdATczvREWeAW + * ysUsWNc8e89ihmpQfTU2Zqf7N+cox9jQraVplI/owd8k+BsHMYeB2F326CjYSlKA + * rBPuUBQemMc= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02FI1\x1a0\x18\x06\x03U\x04\n\x0c\x11Telia Finland Oyj1\x190\x17\x06\x03U\x04\x03\x0c\x10Telia Root CA v2"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xb2\xd0?\x07\xbc\xe2{\xd0k\x99\xf8\xe2wi\xe7\xce\x9d\xa4\x03\xbc\x82m\xa1\xfe\x81e\x1fL\'\xac\x8e\x00\xba\x16{\xeb0j\x00\xc0\xb3th~\xb2\xaf\xc7\xd5b\xb3z?P\xca\x8c6D$c\xd26\xe9\x0c\x85\xf6Cv\xd5L\xa1`rg\xe2(3\xa5\xcb1\xb8:\"#4\xb8}\xbdV\"@\x9d\xea\xf4{\x03\xadh\xfc\xb2\x81O\x98\xd0t\xea\x8d\xe5}\xcdc\xc3\xa3\xf6\xde\x92\xc2X\x19\xe0\x96\xbb\xc5\xc4\xa9=\xa5t\x96\xfe\xaf\xf9\x89\xaa\xbd\x95\x17T\xd8xD\xf1\x0cw\x15\x92\xe0\x98B\xa7\xa4\xd6\xaa \x92\xcd\xc1\xa0\xb3\x96\xb2:\x84B\x8d}\xd5\x95\xe4\xd6\xdb\xe9b\xc4X\xb3y\xc5\x8c\xd353\x83\x9fu\xa1R\'a8\xf1Y=\x8eP\xe0\xbdy<\xe7l\x96\xfe^\xd9\x02e\xb4\x8e\\\xd0\x114\xdf]\xbfR\xa7\x81\x00\xc3\x7f\x99E\x99\x15\xd5\x17\xc8\nS\xecc\xf3\x99}\xcci\x12\x86\xc2\x17\xf0\x01\x9e\xbf\x84\xbc\xd1R\xcb\x1b\x92f\xce\xa4S\xe5\xa1\xbf\xc4\xdb\t\xd6\xe6\x89V+\xc8\xe3|\xde\xe3\xff\x89\xe55n(\xe8l\x0b#Q\xa9%\x05\xebH\xf8\xdd\xb1\xca\xfal\x08Q\xef\xb7\x18lD\xca&\xe1s\xc6\x89\x06\x81\xe5\x8a\xac\xb0\xe2)\xc6\xb9$\xb3kD\x11\xf4\xa5C\xc2LC\xe5p6\x8c\xb63Wz\x95.\x82\xa0\xf4\\\x10\xb3a\x83\xf6\x02\x05\x86.|-l\xdc\x03Fn5\x93\xd5z\x95/\xde \xd8[~\x94\x90\x04j\xbaY=\x04\x05u\x9d7\xa2\x0e.=\xeb\xc1\xa4R\x83\xfe\xd0k\xd4f\x8e\xdc\xc6\xe9\x12N\x1d*W\xaa\x10\xbc|^\x82}\xa6\xa6\xc9\xf2-\xb9\xf5\x17\'\xad\xd1\x0e\x89T+\x95\xfa\xc0\xad\x1d\x98\x14x3B\x86\n\xa9s\xb5\xfbt\r\xb7\x1b0\x19\xc4Z\x0e\x1c\'\xb7\xda\x18\xd0\xff\x8a\xc8\x05\xba\xf1\xaa\x1c\xa27\xb7\xe6H\xa4F,\x94\xea\xa8vbG\x8b\x10S\x07HWl\xe2\x92M\xb6\xae\x05\xcb\xdc\xc1J^\x8f\xac=\x19N\xc2\xed`u+\xdb\xc1\xcaB\xd5\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=Izenpe.com O=IZENPE S.A. + * Subject: CN=Izenpe.com O=IZENPE S.A. + * Label: "Izenpe.com" + * Serial: 917563065490389241595536686991402621 + * SHA256 Fingerprint: 25:30:cc:8e:98:32:15:02:ba:d9:6f:9b:1f:ba:1b:09:9e:2d:29:9e:0f:45:48:bb:91:4f:36:3b:c0:d4:53:1f + * -----BEGIN CERTIFICATE----- + * MIIF8TCCA9mgAwIBAgIQALC3WhZIX7/hy/WL1xnmfTANBgkqhkiG9w0BAQsFADA4 + * MQswCQYDVQQGEwJFUzEUMBIGA1UECgwLSVpFTlBFIFMuQS4xEzARBgNVBAMMCkl6 + * ZW5wZS5jb20wHhcNMDcxMjEzMTMwODI4WhcNMzcxMjEzMDgyNzI1WjA4MQswCQYD + * VQQGEwJFUzEUMBIGA1UECgwLSVpFTlBFIFMuQS4xEzARBgNVBAMMCkl6ZW5wZS5j + * b20wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDJ03rKDx6sp4boFmVq + * scIbRTJxldn+EFvMr+eleQGPicPK8lVx93e+d5TzcqQsRNiekpsUOqHnJJAKClaO + * xdgmlOHZSOEtPtoKct2jmRXagaKH9HtuJneJWK3W6wyyQXpzbm3benhB6QiIEn6H + * LmYRY2xU+zydcsC8Lv/Ct90NduM61/e0aL6i9eOBbsFGb12N4E3GVFWJGjMxCrFX + * uaOKmMPsOzTFlUFpfnXCPCDFYbpRR6AgkJOhkEvzTnyFRVSa0QUmQbC1TR0zvsQD + * yCV8wXDbO/QJLVQnSKwv4cSsPsjLkkxTOTcj7NMB+eAJRE1NZMDhDVqHIrytG6P+ + * JrUV86f8hBnp7KGItERphIPzidF0BqnMC9bC3ieFUCbKF7jJeodWLBoBHmy+E60Q + * rLUk9TiRodZL2vG70t5HtfG8gfZZa88ZU+mNFctKy6lvROUbQc/hhqfK0GqfvEyN + * BjNaooXlkDWgYlwWTvDjovoDGrQscbNYLN57C9saD+veIR8GdwYDsMnvmfzAuU8L + * hij+0rnq49qlw0dpEuDb8PYZi+17cNcC1u2HGCgsBCRMd+RIihrGO5rUD8r6ddIB + * QFqNeb+Lz0vPqhbBleStTIo+F5HUsWLlguWABKQDfo2/2n+iD5dPDNMN+9fR5XJ+ + * HMh3/1uaD7euBUbl8agW7EekFwIDAQABo4H2MIHzMIGwBgNVHREEgagwgaWBD2lu + * Zm9AaXplbnBlLmNvbaSBkTCBjjFHMEUGA1UECgw+SVpFTlBFIFMuQS4gLSBDSUYg + * QTAxMzM3MjYwLVJNZXJjLlZpdG9yaWEtR2FzdGVpeiBUMTA1NSBGNjIgUzgxQzBB + * BgNVBAkMOkF2ZGEgZGVsIE1lZGl0ZXJyYW5lbyBFdG9yYmlkZWEgMTQgLSAwMTAx + * MCBWaXRvcmlhLUdhc3RlaXowDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC + * AQYwHQYDVR0OBBYEFB0cZQ6o8iV7tJHP5LGx5r1VdGwFMA0GCSqGSIb3DQEBCwUA + * A4ICAQB4pgwWSp9MiDrAyw6lFn2fuUhfGI8NYjb2zRlrrKvV9pF9rnHzP7MOeIWb + * laQnIUdCSnxIOvVFfLMMjlF4rJUT3sb9fbgakEyrkgPH7UIBzg/YsfqikuFgba56 + * awmqxinuaElnMIAkejEWOVt+8Rwu3WwJrfIxwYJOubv5vr8qhT/AQKM6WfxZSzwo + * JNu0FXWuDYi6LnPAvViH5ULy617uHjAimcs30cQhbIHsvm0m5hzkQiCeR7Csg1lw + * LDXWrzY0tM07+DKo7+N4ifuNRSzanLh+QBxh5z6ikixL8s36mLYp//Pye6kfLqCT + * VyvehQP5aTfLnnhqBbTFMXiJ7HqnheG5ezzevh55hM6fcA5ZwjUukCox2eRFekGk + * LhObNA5me0mrZJfQRsN5nXJQY6aYWwa9SG3YOYNw6DXwBdGqvOPbyALqfP2C2sJb + * UjWumDqtujWTI6cfSN01RpiyEGjkpTHCClguGYEQyVB1/OpaFs4R1+7vUIgtYf8/ + * QnMFlEPVjjxOAToZpR9GTnfQXeWBIiGH/pR9hNiTrdZoQ0iy2+tzJOeRf1SktoA+ + * naM8THLCV8Sg1Mw4J87VBp6iSNnpn86CcDaTmjvfliHjWbcM2pE38P1ZWrOZyGls + * QyYBNWNgVYkDOnXYukrZVP/u3oDYLdE41V4tC5h9Pmzb/CaIxw== + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02ES1\x140\x12\x06\x03U\x04\n\x0c\x0bIZENPE S.A.1\x130\x11\x06\x03U\x04\x03\x0c\nIzenpe.com"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xc9\xd3z\xca\x0f\x1e\xac\xa7\x86\xe8\x16ej\xb1\xc2\x1bE2q\x95\xd9\xfe\x10[\xcc\xaf\xe7\xa5y\x01\x8f\x89\xc3\xca\xf2Uq\xf7w\xbew\x94\xf3r\xa4,D\xd8\x9e\x92\x9b\x14:\xa1\xe7$\x90\n\nV\x8e\xc5\xd8&\x94\xe1\xd9H\xe1->\xda\nr\xdd\xa3\x99\x15\xda\x81\xa2\x87\xf4{n&w\x89X\xad\xd6\xeb\x0c\xb2Azsnm\xdbzxA\xe9\x08\x88\x12~\x87.f\x11clT\xfb<\x9dr\xc0\xbc.\xff\xc2\xb7\xdd\rv\xe3:\xd7\xf7\xb4h\xbe\xa2\xf5\xe3\x81n\xc1Fo]\x8d\xe0M\xc6TU\x89\x1a31\n\xb1W\xb9\xa3\x8a\x98\xc3\xec;4\xc5\x95Ai~u\xc2< \xc5a\xbaQG\xa0 \x90\x93\xa1\x90K\xf3N|\x85ET\x9a\xd1\x05&A\xb0\xb5M\x1d3\xbe\xc4\x03\xc8%|\xc1p\xdb;\xf4\t-T\'H\xac/\xe1\xc4\xac>\xc8\xcb\x92LS97#\xec\xd3\x01\xf9\xe0\tDMMd\xc0\xe1\rZ\x87\"\xbc\xad\x1b\xa3\xfe&\xb5\x15\xf3\xa7\xfc\x84\x19\xe9\xec\xa1\x88\xb4Di\x84\x83\xf3\x89\xd1t\x06\xa9\xcc\x0b\xd6\xc2\xde\'\x85P&\xca\x17\xb8\xc9z\x87V,\x1a\x01\x1el\xbe\x13\xad\x10\xac\xb5$\xf58\x91\xa1\xd6K\xda\xf1\xbb\xd2\xdeG\xb5\xf1\xbc\x81\xf6Yk\xcf\x19S\xe9\x8d\x15\xcbJ\xcb\xa9oD\xe5\x1bA\xcf\xe1\x86\xa7\xca\xd0j\x9f\xbcL\x8d\x063Z\xa2\x85\xe5\x905\xa0b\\\x16N\xf0\xe3\xa2\xfa\x03\x1a\xb4,q\xb3X,\xde{\x0b\xdb\x1a\x0f\xeb\xde!\x1f\x06w\x06\x03\xb0\xc9\xef\x99\xfc\xc0\xb9O\x0b\x86(\xfe\xd2\xb9\xea\xe3\xda\xa5\xc3Gi\x12\xe0\xdb\xf0\xf6\x19\x8b\xed{p\xd7\x02\xd6\xed\x87\x18(,\x04$Lw\xe4H\x8a\x1a\xc6;\x9a\xd4\x0f\xca\xfau\xd2\x01@Z\x8dy\xbf\x8b\xcfK\xcf\xaa\x16\xc1\x95\xe4\xadL\x8a>\x17\x91\xd4\xb1b\xe5\x82\xe5\x80\x04\xa4\x03~\x8d\xbf\xda\x7f\xa2\x0f\x97O\x0c\xd3\r\xfb\xd7\xd1\xe5r~\x1c\xc8w\xff[\x9a\x0f\xb7\xae\x05F\xe5\xf1\xa8\x16\xecG\xa4\x17\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=GlobalSign O=GlobalSign OU=GlobalSign Root CA - R6 + * Subject: CN=GlobalSign O=GlobalSign OU=GlobalSign Root CA - R6 + * Label: "GlobalSign" + * Serial: 1417766617973444989252670301619537 + * SHA256 Fingerprint: 2c:ab:ea:fe:37:d0:6c:a2:2a:ba:73:91:c0:03:3d:25:98:29:52:c4:53:64:73:49:76:3a:3a:b5:ad:6c:cf:69 + * -----BEGIN CERTIFICATE----- + * MIIFgzCCA2ugAwIBAgIORea7A4Mzw4VlSOb/RVEwDQYJKoZIhvcNAQEMBQAwTDEg + * MB4GA1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjYxEzARBgNVBAoTCkdsb2Jh + * bFNpZ24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMTQxMjEwMDAwMDAwWhcNMzQx + * MjEwMDAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSNjET + * MBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCAiIwDQYJ + * KoZIhvcNAQEBBQADggIPADCCAgoCggIBAJUH6HPKZvnsFMp7PPcNCPG0RQssgrRI + * xutbPK6DuEGSMxSkb3/pKszGsIhrxbaJ0cay/xTOURQh7ErdG1rG1ofuTToVBu1k + * ZguSgMpE3nOUTvOniX9PeGMIyBJQbUJmL025eShNUhqKGoC3GYEOfsSKvGRMIRxD + * aNc9PIrFsmbVkJq3MQbFvuJtMgamHvm566qjuL++gmNQ0PAYid/kD3n16qIfKtJw + * LnvnvJO7bVPiSHyMEAc4/2ayd2F+4OqMPKq0pPbzlUoSB239jLKJz9CgYXfIWHSw + * 1CM69106yqLbnQneXUQtkPGBzVeS+n68UARjNN9rkxi+azayOeSsJDa38O+2HBNX + * k7besvjihbdzorg1qkXy4J02oW9UivFyVm4uiMVRQkQVlO6jxTiWm05OWgtH8wY2 + * SXcwvHE35absIQh1/OZhFj931dmRl4QKbNQCTXTAFO39OfuD8l4UoQSwC+n+7o/h + * bguyCLNhZglqsQY6ZZZZwPA1/cnaKI0aEYdwgQqomnUdnjqGBQCe24DWJfncBZ4n + * WUx2OVvq+aWh2IMP0f/fMBH5hc8zSPXKbWQULHpYT9NLCEnFlWQaYw55PfWzjMpY + * rZxCRXluDocZXFSxZba/jJvcE+kNb7gu3GduyYsRtYQUigAZcIN5kZeR1Bonvzce + * MgfYFGM8KEyvAgMBAAGjYzBhMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTAD + * AQH/MB0GA1UdDgQWBBSubAWjkxPioufi1xzWx/B/yGdToDAfBgNVHSMEGDAWgBSu + * bAWjkxPioufi1xzWx/B/yGdToDANBgkqhkiG9w0BAQwFAAOCAgEAgyXt6NH9lVLN + * nsAEoJFp5lzQhN7craJP6Ed41mWYqVuoPId8AorRbrcWc+ZfwFSY1XS+wc3iEZGt + * Ixg93eFyRJa0lV7Ae46ZeBZDE1ZXs6KzO7V33EByrKPrmzU+sQghoefEQzd5Mr61 + * 55wsTLxDKZmOMNOsIeDjHfrYBzN2VAAiKrlNIC5waNrlU/yDXNOd8v9EDERm8tLj + * vUYAGm0CuiVdjaExUd1URhxN25mW7xocBFymFe944Hn+Xds+qkxV/ZoVqW/hpvvf + * cDDpw+5CRu3CkwWJ+n1jez/QcYF8AOiYrg54NMMl+68KnyBr3TsTjxKM4kEaSHpz + * oHdpx7Zcf4LIHv5YGygrqGytXm3ABdJ7t+uA/iU3/gKbaKxCXcPu9czc8FB10jZp + * nOZ7BN9uBmm23goJSFmH63sUYHpkqmlD75HHTOwY3WzvUy2MmeFe8nI+z1TIvWfs + * pA9MRf/TuTAjB0yPEL+GltmZWrSZVxykzLsViVO6LAUP5MSeGbEYNNVMnbrt9x+v + * JJUEeKgDu+6B5dpffItKoZB0JaezPkvILFa9x8jvOOJckvB595yEunQtYQEgfn7R + * 8k8HWV+LLUNS60YMlOH1Zkd5d9VUWx+tJDfLRVpOoERIyNiwmcUVhAn21klJwGW4 + * 5hpxbqCo8YLoRT5s1gLXCmeDBVrJpBA= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1 0\x1e\x06\x03U\x04\x0b\x13\x17GlobalSign Root CA - R61\x130\x11\x06\x03U\x04\n\x13\nGlobalSign1\x130\x11\x06\x03U\x04\x03\x13\nGlobalSign"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\x95\x07\xe8s\xcaf\xf9\xec\x14\xca{<\xf7\r\x08\xf1\xb4E\x0b,\x82\xb4H\xc6\xeb[<\xae\x83\xb8A\x923\x14\xa4o\x7f\xe9*\xcc\xc6\xb0\x88k\xc5\xb6\x89\xd1\xc6\xb2\xff\x14\xceQ\x14!\xecJ\xdd\x1bZ\xc6\xd6\x87\xeeM:\x15\x06\xeddf\x0b\x92\x80\xcaD\xdes\x94N\xf3\xa7\x89\x7fOxc\x08\xc8\x12PmBf/M\xb9y(MR\x1a\x8a\x1a\x80\xb7\x19\x81\x0e~\xc4\x8a\xbcdL!\x1cCh\xd7=<\x8a\xc5\xb2f\xd5\x90\x9a\xb71\x06\xc5\xbe\xe2m2\x06\xa6\x1e\xf9\xb9\xeb\xaa\xa3\xb8\xbf\xbe\x82cP\xd0\xf0\x18\x89\xdf\xe4\x0fy\xf5\xea\xa2\x1f*\xd2p.{\xe7\xbc\x93\xbbmS\xe2H|\x8c\x10\x078\xfff\xb2wa~\xe0\xea\x8c<\xaa\xb4\xa4\xf6\xf3\x95J\x12\x07m\xfd\x8c\xb2\x89\xcf\xd0\xa0aw\xc8Xt\xb0\xd4#:\xf7]:\xca\xa2\xdb\x9d\t\xde]D-\x90\xf1\x81\xcdW\x92\xfa~\xbcP\x04c4\xdfk\x93\x18\xbek6\xb29\xe4\xac$6\xb7\xf0\xef\xb6\x1c\x13W\x93\xb6\xde\xb2\xf8\xe2\x85\xb7s\xa2\xb85\xaaE\xf2\xe0\x9d6\xa1oT\x8a\xf1rVn.\x88\xc5QBD\x15\x94\xee\xa3\xc58\x96\x9bNNZ\x0bG\xf3\x066Iw0\xbcq7\xe5\xa6\xec!\x08u\xfc\xe6a\x16?w\xd5\xd9\x91\x97\x84\nl\xd4\x02Mt\xc0\x14\xed\xfd9\xfb\x83\xf2^\x14\xa1\x04\xb0\x0b\xe9\xfe\xee\x8f\xe1n\x0b\xb2\x08\xb3af\tj\xb1\x06:e\x96Y\xc0\xf05\xfd\xc9\xda(\x8d\x1a\x11\x87p\x81\n\xa8\x9au\x1d\x9e:\x86\x05\x00\x9e\xdb\x80\xd6%\xf9\xdc\x05\x9e\'YLv9[\xea\xf9\xa5\xa1\xd8\x83\x0f\xd1\xff\xdf0\x11\xf9\x85\xcf3H\xf5\xcamd\x14,zXO\xd3K\x08I\xc5\x95d\x1ac\x0ey=\xf5\xb3\x8c\xcaX\xad\x9cBEyn\x0e\x87\x19\\T\xb1e\xb6\xbf\x8c\x9b\xdc\x13\xe9\ro\xb8.\xdcgn\xc9\x8b\x11\xb5\x84\x14\x8a\x00\x19p\x83y\x91\x97\x91\xd4\x1a\'\xbf7\x1e2\x07\xd8\x14c<(L\xaf\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=Starfield Root Certificate Authority - G2 O=Starfield Technologies, Inc. + * Subject: CN=Starfield Root Certificate Authority - G2 O=Starfield Technologies, Inc. + * Label: "Starfield Root Certificate Authority - G2" + * Serial: 0 + * SHA256 Fingerprint: 2c:e1:cb:0b:f9:d2:f9:e1:02:99:3f:be:21:51:52:c3:b2:dd:0c:ab:de:1c:68:e5:31:9b:83:91:54:db:b7:f5 + * -----BEGIN CERTIFICATE----- + * MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMx + * EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoT + * HFN0YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVs + * ZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAw + * MFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6 + * b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQgVGVj + * aG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZp + * Y2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC + * ggEBAL3twQP89o/8ArFvW59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMg + * nLRJdzIpVv257IzdIvpy3Cdhl+72WoTsbhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1 + * HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNkN3mSwOxGXn/hbVNMYq/N + * Hwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7NfZTD4p7dN + * dloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0 + * HZbUJtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAO + * BgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0G + * CSqGSIb3DQEBCwUAA4IBAQARWfolTwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjU + * sHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx4mcujJUDJi5DnUox9g61DLu3 + * 4jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUwF5okxBDgBPfg + * 8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K + * pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1 + * mMpYjn0q7pBZc2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0 + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1\x100\x0e\x06\x03U\x04\x08\x13\x07Arizona1\x130\x11\x06\x03U\x04\x07\x13\nScottsdale1%0#\x06\x03U\x04\n\x13\x1cStarfield Technologies, Inc.1200\x06\x03U\x04\x03\x13)Starfield Root Certificate Authority - G2"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x01\x0f\x000\x82\x01\n\x02\x82\x01\x01\x00\xbd\xed\xc1\x03\xfc\xf6\x8f\xfc\x02\xb1o[\x9fH\xd9\x9dy\xe2\xa2\xb7\x03aV\x18\xc3G\xb6\xd7\xca=5.\x89C\xf7\xa1i\x9b\xde\x8a\x1a\xfd\x13 \x9c\xb4Iw2)V\xfd\xb9\xec\x8c\xdd\"\xfar\xdc\'a\x97\xee\xf6Z\x84\xecn\x19\xb9\x89,\xdc\x84[\xd5t\xfbk_\xc5\x89\xa5\x10R\x89FU\xf4\xb8u\x1c\xe6\x7f\xe4T\xaeK\xf8UrW\x02\x19\xf8\x17qY\xeb\x1e(\x07t\xc5\x9dH\xbel\xb4\xf4\xa4\xb0\xf3d7y\x92\xc0\xecF^\x7f\xe1mSLb\xaf\xcd\x1f\x0bc\xbb:\x9d\xfb\xfcy\x00\x98at\xcf&\x82@c\xf3\xb2rj\x19\r\x99\xca\xd4\x0eu\xcc7\xfb\x8b\x89\xc1Y\xf1b\x7f_\xb3_e0\xf8\xa7\xb7MvZ\x1ev^4\xc0\xe8\x96V\x99\x8a\xb3\xf0\x7f\xa4\xcd\xbd\xdc21|\x91\xcf\xe0_\x11\xf8k\xaaI\\\xd1\x99\x94\xd1\xa2\xe3c[\tv\xb5Vb\xe1Kt\x1d\x96\xd4&\xd4\x08\x04Y\xd0\x98\x0e\x0e\xe6\xde\xfc\xc3\xec\x1f\x90\xf1\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=TunTrust Root CA O=Agence Nationale de Certification Electronique + * Subject: CN=TunTrust Root CA O=Agence Nationale de Certification Electronique + * Label: "TunTrust Root CA" + * Serial: 108534058042236574382096126452369648152337120275 + * SHA256 Fingerprint: 2e:44:10:2a:b5:8c:b8:54:19:45:1c:8e:19:d9:ac:f3:66:2c:af:bc:61:4b:6a:53:96:0a:30:f7:d0:e2:eb:41 + * -----BEGIN CERTIFICATE----- + * MIIFszCCA5ugAwIBAgIUEwLV4kBMkkaGFmddtLu7sms+/BMwDQYJKoZIhvcNAQEL + * BQAwYTELMAkGA1UEBhMCVE4xNzA1BgNVBAoMLkFnZW5jZSBOYXRpb25hbGUgZGUg + * Q2VydGlmaWNhdGlvbiBFbGVjdHJvbmlxdWUxGTAXBgNVBAMMEFR1blRydXN0IFJv + * b3QgQ0EwHhcNMTkwNDI2MDg1NzU2WhcNNDQwNDI2MDg1NzU2WjBhMQswCQYDVQQG + * EwJUTjE3MDUGA1UECgwuQWdlbmNlIE5hdGlvbmFsZSBkZSBDZXJ0aWZpY2F0aW9u + * IEVsZWN0cm9uaXF1ZTEZMBcGA1UEAwwQVHVuVHJ1c3QgUm9vdCBDQTCCAiIwDQYJ + * KoZIhvcNAQEBBQADggIPADCCAgoCggIBAMPN0/y9BFPdDCA61YguBUtB9YOCfvdZ + * n56eY+hz2vYGqU8ftPkLHzmMmiDQfgbU7DTZhrx1W4eI8NLZ1KMKsmwb60ksPqxd + * 2JQDoOw05TDENX37Jk0bbjBU2PWARZw5rZzJJQRNmpA+TkBuimvNKWfGzC3gdOgF + * VwpIUPp6Q9p+7FuaDmJ2/uqdHYVy7BG7NegfJ7/Boce7SBbdVtfMTqDhuazb1YMZ + * GoXRlJfXyqNlC/M4+QKu3fZnz8k/9YosRxqZbwUN/dAdgjH8KcwAWJeRTIAAHDOF + * li/LQcKLEITDCSSJH7UP2dl3RxiSlGBcx5kDPP73lad9UKGAwqmDrViWVSHbhlnU + * r8a83YFuB9tgYv7sEG7aaAH0gxupPqJbI9dkxt/con3YS7qC0lH4Zr8GRuR5KiY2 + * eY8fTpkdso8MDhz/yV3A/ZAQprE38806JG60hZC/gLkMjNWb1sjxVj8agIl6qeIb + * MlEsPvLfe/ZdeikZjuXIvTZxi11Mwh0/rViizz1wTaZQmCXcI/m4WEEIcb9PuISg + * jwBUFfyRbVinljvrS5YnzWuioYasDXxU5mZMZl+QviGaAkYt5IPCgLnPSz7ofzwB + * 7I9ezX/SKEIBlYrilz0QIX32nRzFNKHsLA4KUiwSVXAkPcvCFDVDXSdOvsC9qnyW + * 5/yeYa1E0wCXAgMBAAGjYzBhMB0GA1UdDgQWBBQGmpsfU33x9aTI04Y+oXNZtPdE + * ITAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFAaamx9TffH1pMjThj6hc1m0 + * 90QhMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsFAAOCAgEAqgVutt0Vyb+z + * xiD2BkewhpMl0425yAA/l/VSJ4hxyXT968pk21vvHl26v9Hr7lxpuhbI87mP0zYu + * QEkHDVneixCwSQXi/5E/S7fdAo74gShczNxtr18UnH1YeA32gAm56Q6XKRm4t+v4 + * FstVEuTGfbvE7Pi1HE4+Z7/FXxttbUcoqgRYYdZ2vyJ/0Adqp2RT8JeNnYA/u8EH + * 22Wv5psymsNUk8QcCMNE+3tjEUPRahphanltkE8pjkcFwRJpadbGNjHh/PqAulxP + * xOu3Mqz4dWEX1xAZufHSCe96Qp1bWgvUxpVOKs7/B9dPfhgGiPEZtdmYu65xxBzn + * dFlY7wyJz4sfdZMaBBSSSFCp61cpABbjNhzI+L/wM9VBD8TMPN3pM0MBkRArHtG5 + * Xc0yGYuPjCB31yLEQtyEFpslbei0VXF/sHyz03FJuc9SpAQ/3D2gu68zngowYI7b + * nV2UqL1g52KAdoGDDIzMMEZJ4gzSqK/rYXHv5yJiqfdcZGyfFoxnNidF9Ql7v/YQ + * CvGwjVRDjAS6oz/v4jXH+XTgbzRB0L9zZVcg+ZtnemZoJE6AZb0QmQZZ8mWvuMZH + * u/2QeItBcy6vVR/cO5JyboTT0GFMDcx2V+IthSIVNg3rAZ3r2OvEhJn7wAzMMujj + * d9qDRIueVSjAi1jTkD5OGwDxFa2DK5o= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02TN1705\x06\x03U\x04\n\x0c.Agence Nationale de Certification Electronique1\x190\x17\x06\x03U\x04\x03\x0c\x10TunTrust Root CA"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xc3\xcd\xd3\xfc\xbd\x04S\xdd\x0c :\xd5\x88.\x05KA\xf5\x83\x82~\xf7Y\x9f\x9e\x9ec\xe8s\xda\xf6\x06\xa9O\x1f\xb4\xf9\x0b\x1f9\x8c\x9a \xd0~\x06\xd4\xec4\xd9\x86\xbcu[\x87\x88\xf0\xd2\xd9\xd4\xa3\n\xb2l\x1b\xebI,>\xac]\xd8\x94\x03\xa0\xec4\xe50\xc45}\xfb&M\x1bn0T\xd8\xf5\x80E\x9c9\xad\x9c\xc9%\x04M\x9a\x90>N@n\x8ak\xcd)g\xc6\xcc-\xe0t\xe8\x05W\nHP\xfazC\xda~\xec[\x9a\x0ebv\xfe\xea\x9d\x1d\x85r\xec\x11\xbb5\xe8\x1f\'\xbf\xc1\xa1\xc7\xbbH\x16\xddV\xd7\xccN\xa0\xe1\xb9\xac\xdb\xd5\x83\x19\x1a\x85\xd1\x94\x97\xd7\xca\xa3e\x0b\xf38\xf9\x02\xae\xdd\xf6g\xcf\xc9?\xf5\x8a,G\x1a\x99o\x05\r\xfd\xd0\x1d\x821\xfc)\xcc\x00X\x97\x91L\x80\x00\x1c3\x85\x96/\xcbA\xc2\x8b\x10\x84\xc3\t$\x89\x1f\xb5\x0f\xd9\xd9wG\x18\x92\x94`\\\xc7\x99\x03<\xfe\xf7\x95\xa7}P\xa1\x80\xc2\xa9\x83\xadX\x96U!\xdb\x86Y\xd4\xaf\xc6\xbc\xdd\x81n\x07\xdb`b\xfe\xec\x10n\xdah\x01\xf4\x83\x1b\xa9>\xa2[#\xd7d\xc6\xdf\xdc\xa2}\xd8K\xba\x82\xd2Q\xf8f\xbf\x06F\xe4y*&6y\x8f\x1fN\x99\x1d\xb2\x8f\x0c\x0e\x1c\xff\xc9]\xc0\xfd\x90\x10\xa6\xb17\xf3\xcd:$n\xb4\x85\x90\xbf\x80\xb9\x0c\x8c\xd5\x9b\xd6\xc8\xf1V?\x1a\x80\x89z\xa9\xe2\x1b2Q,>\xf2\xdf{\xf6]z)\x19\x8e\xe5\xc8\xbd6q\x8b]L\xc2\x1d?\xadX\xa2\xcf=pM\xa6P\x98%\xdc#\xf9\xb8XA\x08q\xbfO\xb8\x84\xa0\x8f\x00T\x15\xfc\x91mX\xa7\x96;\xebK\x96\'\xcdk\xa2\xa1\x86\xac\r|T\xe6fLf_\x90\xbe!\x9a\x02F-\xe4\x83\xc2\x80\xb9\xcfK>\xe8\x7f<\x01\xec\x8f^\xcd\x7f\xd2(B\x01\x95\x8a\xe2\x97=\x10!}\xf6\x9d\x1c\xc54\xa1\xec,\x0e\nR,\x12Up$=\xcb\xc2\x145C]\'N\xbe\xc0\xbd\xaa|\x96\xe7\xfc\x9ea\xadD\xd3\x00\x97\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=SSL.com EV Root Certification Authority RSA R2 O=SSL Corporation + * Subject: CN=SSL.com EV Root Certification Authority RSA R2 O=SSL Corporation + * Label: "SSL.com EV Root Certification Authority RSA R2" + * Serial: 6248227494352943350 + * SHA256 Fingerprint: 2e:7b:f1:6c:c2:24:85:a7:bb:e2:aa:86:96:75:07:61:b0:ae:39:be:3b:2f:e9:d0:cc:6d:4e:f7:34:91:42:5c + * -----BEGIN CERTIFICATE----- + * MIIF6zCCA9OgAwIBAgIIVrYpzTS8ePYwDQYJKoZIhvcNAQELBQAwgYIxCzAJBgNV + * BAYTAlVTMQ4wDAYDVQQIDAVUZXhhczEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UE + * CgwPU1NMIENvcnBvcmF0aW9uMTcwNQYDVQQDDC5TU0wuY29tIEVWIFJvb3QgQ2Vy + * dGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIyMB4XDTE3MDUzMTE4MTQzN1oXDTQy + * MDUzMDE4MTQzN1owgYIxCzAJBgNVBAYTAlVTMQ4wDAYDVQQIDAVUZXhhczEQMA4G + * A1UEBwwHSG91c3RvbjEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9uMTcwNQYDVQQD + * DC5TU0wuY29tIEVWIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIy + * MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAjzZlQOHWTcDXtOlG2mvq + * M0fNTPl9fb69LT3w23jhhqXZuglXaO1XPqDQCEGD5yhBJB/jchXQARr7XnAjssuf + * OePPxU7Gkm0mxnu7s9onnQqG6YE3Bf7wcXHswxzpY6IXFJ3vG2fThVUCAtZJycxa + * 4bH3bzKfydQ7iEGonL3Lq9ttewkfokxykNorCPzPPFTOZw+oz12WGQvE43LrrdF9 + * HSfvkusQv1vrO6/PgN3B0pYEW3p+pKk8OHakYo6gOV7qd89dAFmPZiw+B6KjBSYR + * aZfqhbcPlgtLyEDhULouisv3D5oi53+aNxPN8k0TayHRwMwi8qFG9kRpnMphNQcA + * b9ZhCBHqurj26bNg5U257J8UZslXWNvNh2n4ioYSA0e/ZhN2rHd9NCSFg83XqpyQ + * Gp8hLH94t2S42Oim9HizVcuE0jLEeK6jj2HdzghTreyI/BXkmg3mnxp3zkyPuBQV + * PWKchjgGAGYS5Fl2WlPAApiiECtoRHuOec4zSnaqW4EWG7WK2NAAe15itAnWhmMO + * pgWVSbooi4iTsjQc2KRVbrcc0N6ZVTsj9CLg+SlmJuwgUHfbSguPvuUCYHBBXtSu + * UDkiFCbLsjtzdFVHB3mBOagwE0TlBIqulhMlQg+5U8Sb/M3kHN48+qvWBkofZ6aY + * MBzdLNvcGJVXZsb/XItW9XcCAwEAAaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAfBgNV + * HSMEGDAWgBT5YLvU49U09rj1BoAlp3PbRmmonjAdBgNVHQ4EFgQU+WC71OPVNPa4 + * 9QaAJadz20ZpqJ4wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4ICAQBW + * s47LCp1Jjr+kxJG7ZhcFUZh1++VQLHqe8RT6q9OKPv+RKY9ji9i0qVQBDb6Thi/5 + * Sm3HXvVX+cpVHBK+Rw82xd9qt9t1wkclf7nxY/hoLVUE0fKNsKTPvDxeH3jnpaAg + * cLAExbf3cqfeIg29MyVGjGSSJuM+LmOW2puMPfgYCdcDzH2GguDKBAdRUNf/ktUM + * 79qGn5nX67evaOI5JpS6aLe/g9Pqemc9YmeuJeVy6OLk7K4S9ksrPJ/psEDzOFSz + * /bdoyNrGj1E8svuR3Bznm53htw1yj+KkxKl4+esUrMZDBcJlOSgYAsOCsp0FvmXt + * ll9ldDz7CTUue5wT/RsPXcdtgTpWD8w74a8CLyKsRspGPKAcTNZEtF4uXBVmCeEm + * Kf7GUmG6sXP/wwyc5WxqlD8UykAWlYTzWamsX0xhk23RO8yilQwipmdnRC652dKK + * QbNmC1r7fSOl8hqw/96bg5Qu0T/fkreRrwU7ZcegbLHNYhLDkBvjJc40vG93drEQ + * w/cFGsDWr3RiSBd3kmmQYRzelYB0VI8YHMPzA9C/pEN1hlMYegouCRw2n5H9gooi + * S9EOUCXdywMMF8mDAAhONU2Ki+3wApRmLER/y5UnlhetCTCstnEXbosX9hwJ1C07 + * mKVx01QT2WDz9UtmT/rx7iASjbSsV7FFY6GsdqnC+w== + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1\x0e0\x0c\x06\x03U\x04\x08\x0c\x05Texas1\x100\x0e\x06\x03U\x04\x07\x0c\x07Houston1\x180\x16\x06\x03U\x04\n\x0c\x0fSSL Corporation1705\x06\x03U\x04\x03\x0c.SSL.com EV Root Certification Authority RSA R2"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\x8f6e@\xe1\xd6M\xc0\xd7\xb4\xe9F\xdak\xea3G\xcdL\xf9}}\xbe\xbd-=\xf0\xdbx\xe1\x86\xa5\xd9\xba\tWh\xedW>\xa0\xd0\x08A\x83\xe7(A$\x1f\xe3r\x15\xd0\x01\x1a\xfb^p#\xb2\xcb\x9f9\xe3\xcf\xc5N\xc6\x92m&\xc6{\xbb\xb3\xda\'\x9d\n\x86\xe9\x817\x05\xfe\xf0qq\xec\xc3\x1c\xe9c\xa2\x17\x14\x9d\xef\x1bg\xd3\x85U\x02\x02\xd6I\xc9\xccZ\xe1\xb1\xf7o2\x9f\xc9\xd4;\x88A\xa8\x9c\xbd\xcb\xab\xdbm{\t\x1f\xa2Lr\x90\xda+\x08\xfc\xcf\x07\xa2\xa3\x05&\x11i\x97\xea\x85\xb7\x0f\x96\x0bK\xc8@\xe1P\xba.\x8a\xcb\xf7\x0f\x9a\"\xe7\x7f\x9a7\x13\xcd\xf2M\x13k!\xd1\xc0\xcc\"\xf2\xa1F\xf6Di\x9c\xcaa5\x07\x00o\xd6a\x08\x11\xea\xba\xb8\xf6\xe9\xb3`\xe5M\xb9\xec\x9f\x14f\xc9WX\xdb\xcd\x87i\xf8\x8a\x86\x12\x03G\xbff\x13v\xacw}4$\x85\x83\xcd\xd7\xaa\x9c\x90\x1a\x9f!,\x7fx\xb7d\xb8\xd8\xe8\xa6\xf4x\xb3U\xcb\x84\xd22\xc4x\xae\xa3\x8fa\xdd\xce\x08S\xad\xec\x88\xfc\x15\xe4\x9a\r\xe6\x9f\x1aw\xceL\x8f\xb8\x14\x15=b\x9c\x868\x06\x00f\x12\xe4YvZS\xc0\x02\x98\xa2\x10+hD{\x8ey\xce3Jv\xaa[\x81\x16\x1b\xb5\x8a\xd8\xd0\x00{^b\xb4\t\xd6\x86c\x0e\xa6\x05\x95I\xba(\x8b\x88\x93\xb24\x1c\xd8\xa4Un\xb7\x1c\xd0\xde\x99U;#\xf4\"\xe0\xf9)f&\xec Pw\xdbJ\x0b\x8f\xbe\xe5\x02`pA^\xd4\xaeP9\"\x14&\xcb\xb2;stUG\x07y\x819\xa80\x13D\xe5\x04\x8a\xae\x96\x13%B\x0f\xb9S\xc4\x9b\xfc\xcd\xe4\x1c\xde<\xfa\xab\xd6\x06J\x1fg\xa6\x980\x1c\xdd,\xdb\xdc\x18\x95Wf\xc6\xff\\\x8bV\xf5w\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=IdenTrust Public Sector Root CA 1 O=IdenTrust + * Subject: CN=IdenTrust Public Sector Root CA 1 O=IdenTrust + * Label: "IdenTrust Public Sector Root CA 1" + * Serial: 13298821034946342390521976156843933698 + * SHA256 Fingerprint: 30:d0:89:5a:9a:44:8a:26:20:91:63:55:22:d1:f5:20:10:b5:86:7a:ca:e1:2c:78:ef:95:8f:d4:f4:38:9f:2f + * -----BEGIN CERTIFICATE----- + * MIIFZjCCA06gAwIBAgIQCgFCgAAAAUUjz0Z8AAAAAjANBgkqhkiG9w0BAQsFADBN + * MQswCQYDVQQGEwJVUzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVu + * VHJ1c3QgUHVibGljIFNlY3RvciBSb290IENBIDEwHhcNMTQwMTE2MTc1MzMyWhcN + * MzQwMTE2MTc1MzMyWjBNMQswCQYDVQQGEwJVUzESMBAGA1UEChMJSWRlblRydXN0 + * MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3RvciBSb290IENBIDEwggIi + * MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2IpT8pEiv6EdrCvsnduTyP4o7 + * ekosMSqMjbCpwzFrqHd2hCa2rIFCDQjrVVi7evi8ZX3yoG2LqEfpYnYeEe4IFNGy + * RBb06tD6Hi9e28tzQa68ALBKK0CyrOE7S8ItneShm+waOh7wCLPQ5CQ1B5+ctMlS + * bdsHyo+1W/CD80/HLaXIrcuVIKQxKFdYWuSNG5qrng0M8gozOSI5Cpcu81N3uURF + * /YTLNiCBWS2ab21ISGHKTN9T0a9SvESfqy9rg3LvdYDaBjMbXcjaY8ZNzaxmMc3R + * 3j6HEDbhuaR672BQssvKplbgN6+rNBM5Jeg5ZuSYeqoSmJxZZoY+rfGwyj4GD3vw + * EUs3oERte8uojHH01bWRNszwFcYr3lEXsZdMUD2xlVl8BX0tIdUAvwFnol57plzy + * 9yLxkA2T26pEUWbMfXYD62qoKjgZl3YNa4ph+bz27nb9cCvdKTz4Ch5bQhyLVi9V + * GxyhLrXHFub4qjySjmm2AcG1hp2JDws4lFTo6tyePSW8Uybt1as5qsVATFSrsrTZ + * 2fjXctscvG29ZV/viDUqZi/u9rNl8DONfJhBaUYPQxxp+pu10GFqzcpL2UyQRqsV + * WaFHVCkugyhfHMKiq3IXAAaOReyL4jM9f9oZRORicsPfIsbyVtTdX5Vy7W1f90gD + * W/3FKqD2cyOEEBsB5wIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/ + * BAUwAwEB/zAdBgNVHQ4EFgQU43HgntinQtnbcZFrlJPrw6PRFKMwDQYJKoZIhvcN + * AQELBQADggIBAEf63QqwEZE4rU1d9+UOl1QZgkiHVIyqZJnYWv6IAcVYpZmxI1Qj + * t2odIFflAWJBF9MJ23XLblSQdf4an4EKwt3X9wnQW3IV5B4Jaj0z8yGa5hV+rVHV + * DRDtfULAj+7AmgjVQdZcDiFpboBhDhXAuM/FSRJSzL46zNQuOAXeNf0fb7iAaJg9 + * TaDKQGXSc3z1i9kKlT/YPyNtGtEqJBnZhbMX73huqVjRI9PHE+1yJX9dsXNw0H8G + * lwmEKYBhHfpe/3OsoOOJuBxxFcbeMX8S3OFtm6/n6J91eEyrRjuazr8FGF1NFTwW + * mhlQBJqymm9li1JfPFgEKCXAZmExfrngdbkaqIHWchezxQMxNRF4eKLg6TCMf4Df + * WN88uieW4oA0beOY02QnrEh+KHdcxiVhJfiFDGX6xDIvpZgF5PgLZxYWxoK4Mhn5 + * +bl53B/N66+rDt0b20XkeucC4pVd/GnwU2lhlXV5C15V5jgclKlZM57IcXR5f1GJ + * tshquDDIajjDbp7hNxbqBWJMWxJH7ae0s1hWx0nzfxJoCTFx8G34Tkf71oXuxVhA + * GaQdp/lLQzfcaFpPz+vCZHTetBXZ9FRUGi8c15dxVJCO2SCdUyt/q4/i6jC8UDfv + * 8Ue1fXwsBOxonbRJRBD0ckscZOf85muQ3Wl9af0AVqW3rLatt8o+Ae+c + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1\x120\x10\x06\x03U\x04\n\x13\tIdenTrust1*0(\x06\x03U\x04\x03\x13!IdenTrust Public Sector Root CA 1"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xb6\"\x94\xfc\xa4H\xaf\xe8Gk\n\xfb\'v\xe4\xf2?\x8a;zJ,1*\x8c\x8d\xb0\xa9\xc31k\xa8wv\x84&\xb6\xac\x81B\r\x08\xebUX\xbbz\xf8\xbce}\xf2\xa0m\x8b\xa8G\xe9bv\x1e\x11\xee\x08\x14\xd1\xb2D\x16\xf4\xea\xd0\xfa\x1e/^\xdb\xcbsA\xae\xbc\x00\xb0J+@\xb2\xac\xe1;K\xc2-\x9d\xe4\xa1\x9b\xec\x1a:\x1e\xf0\x08\xb3\xd0\xe4$5\x07\x9f\x9c\xb4\xc9Rm\xdb\x07\xca\x8f\xb5[\xf0\x83\xf3O\xc7-\xa5\xc8\xad\xcb\x95 \xa41(WXZ\xe4\x8d\x1b\x9a\xab\x9e\r\x0c\xf2\n39\"9\n\x97.\xf3Sw\xb9DE\xfd\x84\xcb6 \x81Y-\x9aomHHa\xcaL\xdfS\xd1\xafR\xbcD\x9f\xab/k\x83r\xefu\x80\xda\x063\x1b]\xc8\xdac\xc6M\xcd\xacf1\xcd\xd1\xde>\x87\x106\xe1\xb9\xa4z\xef`P\xb2\xcb\xca\xa6V\xe07\xaf\xab4\x139%\xe89f\xe4\x98z\xaa\x12\x98\x9cYf\x86>\xad\xf1\xb0\xca>\x06\x0f{\xf0\x11K7\xa0Dm{\xcb\xa8\x8cq\xf4\xd5\xb5\x916\xcc\xf0\x15\xc6+\xdeQ\x17\xb1\x97LP=\xb1\x95Y|\x05}-!\xd5\x00\xbf\x01g\xa2^{\xa6\\\xf2\xf7\"\xf1\x90\r\x93\xdb\xaaDQf\xcc}v\x03\xebj\xa8*8\x19\x97v\rk\x8aa\xf9\xbc\xf6\xeev\xfdp+\xdd)<\xf8\n\x1e[B\x1c\x8bV/U\x1b\x1c\xa1.\xb5\xc7\x16\xe6\xf8\xaa<\x92\x8ei\xb6\x01\xc1\xb5\x86\x9d\x89\x0f\x0b8\x94T\xe8\xea\xdc\x9e=%\xbcS&\xed\xd5\xab9\xaa\xc5@LT\xab\xb2\xb4\xd9\xd9\xf8\xd7r\xdb\x1c\xbcm\xbde_\xef\x885*f/\xee\xf6\xb3e\xf03\x8d|\x98AiF\x0fC\x1ci\xfa\x9b\xb5\xd0aj\xcd\xcaK\xd9L\x90F\xab\x15Y\xa1GT).\x83(_\x1c\xc2\xa2\xabr\x17\x00\x06\x8eE\xec\x8b\xe23=\x7f\xda\x19D\xe4br\xc3\xdf\"\xc6\xf2V\xd4\xdd_\x95r\xedm_\xf7H\x03[\xfd\xc5*\xa0\xf6s#\x84\x10\x1b\x01\xe7\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=vTrus ECC Root CA O=iTrusChina Co.,Ltd. + * Subject: CN=vTrus ECC Root CA O=iTrusChina Co.,Ltd. + * Label: "vTrus ECC Root CA" + * Serial: 630369271402956006249506845124680065938238527194 + * SHA256 Fingerprint: 30:fb:ba:2c:32:23:8e:2a:98:54:7a:f9:79:31:e5:50:42:8b:9b:3f:1c:8e:eb:66:33:dc:fa:86:c5:b2:7d:d3 + * -----BEGIN CERTIFICATE----- + * MIICDzCCAZWgAwIBAgIUbmq8WapTvpg5Z6LSa6Q75m0c1towCgYIKoZIzj0EAwMw + * RzELMAkGA1UEBhMCQ04xHDAaBgNVBAoTE2lUcnVzQ2hpbmEgQ28uLEx0ZC4xGjAY + * BgNVBAMTEXZUcnVzIEVDQyBSb290IENBMB4XDTE4MDczMTA3MjY0NFoXDTQzMDcz + * MTA3MjY0NFowRzELMAkGA1UEBhMCQ04xHDAaBgNVBAoTE2lUcnVzQ2hpbmEgQ28u + * LEx0ZC4xGjAYBgNVBAMTEXZUcnVzIEVDQyBSb290IENBMHYwEAYHKoZIzj0CAQYF + * K4EEACIDYgAEZVBKrox5lkqqHAjDo6LN/llWQXf9JpRCux3NCNtzslt188+cToL0 + * v/hhJoVs1oVbcnDS/dtitN9Ti72xRFhiQgnH+n9bEOf+QP3A2MMrMudwpremIFUd + * e4BdS49nTPEQo0IwQDAdBgNVHQ4EFgQUmDnNvtiyjPeyq+GtJK97fKHbH88wDwYD + * VR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwCgYIKoZIzj0EAwMDaAAwZQIw + * V53dVvHH4+m4SVBrm2nDb+zDfSXkV5UTQJtS0zvzQBm8JsctBp61ezaf9SXUY2sA + * AjEA6dPGnlaaKsyh2j/IZivTWJwghfqrkYpwcBE4YGQLYgmRWAD5Tfs0aNoJrSEG + * GJTO + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02CN1\x1c0\x1a\x06\x03U\x04\n\x13\x13iTrusChina Co.,Ltd.1\x1a0\x18\x06\x03U\x04\x03\x13\x11vTrus ECC Root CA"), + subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\"\x03b\x00\x04ePJ\xae\x8cy\x96J\xaa\x1c\x08\xc3\xa3\xa2\xcd\xfeYVAw\xfd&\x94B\xbb\x1d\xcd\x08\xdbs\xb2[u\xf3\xcf\x9cN\x82\xf4\xbf\xf8a&\x85l\xd6\x85[rp\xd2\xfd\xdbb\xb4\xdfS\x8b\xbd\xb1DXbB\t\xc7\xfa\x7f[\x10\xe7\xfe@\xfd\xc0\xd8\xc3+2\xe7p\xa6\xb7\xa6 U\x1d{\x80]K\x8fgL\xf1\x10"), + name_constraints: None + }, + + /* + * Issuer: CN=DigiCert Global Root G3 O=DigiCert Inc OU=www.digicert.com + * Subject: CN=DigiCert Global Root G3 O=DigiCert Inc OU=www.digicert.com + * Label: "DigiCert Global Root G3" + * Serial: 7089244469030293291760083333884364146 + * SHA256 Fingerprint: 31:ad:66:48:f8:10:41:38:c7:38:f3:9e:a4:32:01:33:39:3e:3a:18:cc:02:29:6e:f9:7c:2a:c9:ef:67:31:d0 + * -----BEGIN CERTIFICATE----- + * MIICPzCCAcWgAwIBAgIQBVVWvPJepDU1w6QP1atFcjAKBggqhkjOPQQDAzBhMQsw + * CQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cu + * ZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMzAe + * Fw0xMzA4MDExMjAwMDBaFw0zODAxMTUxMjAwMDBaMGExCzAJBgNVBAYTAlVTMRUw + * EwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5jb20x + * IDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEczMHYwEAYHKoZIzj0CAQYF + * K4EEACIDYgAE3afZu4q4C/sLfyHS8L6+c/MzXRq8NOrexpu80JX28MzQC7phW1FG + * fp4tn+6OYwwX7Adw9c+ELkCDnOg/QW07rdOkFFk2eJ0DQ+4QE2xy3q6Ip6FrtUPO + * Z9wj/wMco+I+o0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAd + * BgNVHQ4EFgQUs9tIpPmhxdiuNkHMEWNpYim8S8YwCgYIKoZIzj0EAwMDaAAwZQIx + * AK288mw/EkrRLTnDCgmXc/SINoyIJ7vmiI1Qhadj+Z4y3maTD/HMsQmP3Wyr+mt/ + * oAIwOWZbwmSNuJ5Q3KjVSaLtx9zRSX8XAbjIho9OjIgrqJqpisXRAL34VOKa5Vt8 + * sycX + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1\x150\x13\x06\x03U\x04\n\x13\x0cDigiCert Inc1\x190\x17\x06\x03U\x04\x0b\x13\x10www.digicert.com1 0\x1e\x06\x03U\x04\x03\x13\x17DigiCert Global Root G3"), + subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\"\x03b\x00\x04\xdd\xa7\xd9\xbb\x8a\xb8\x0b\xfb\x0b\x7f!\xd2\xf0\xbe\xbes\xf33]\x1a\xbc4\xea\xde\xc6\x9b\xbc\xd0\x95\xf6\xf0\xcc\xd0\x0b\xbaa[QF~\x9e-\x9f\xee\x8ec\x0c\x17\xec\x07p\xf5\xcf\x84.@\x83\x9c\xe8?Am;\xad\xd3\xa4\x14Y6x\x9d\x03C\xee\x10\x13lr\xde\xae\x88\xa7\xa1k\xb5C\xceg\xdc#\xff\x03\x1c\xa3\xe2>"), + name_constraints: None + }, + + /* + * Issuer: CN=SSL.com Root Certification Authority ECC O=SSL Corporation + * Subject: CN=SSL.com Root Certification Authority ECC O=SSL Corporation + * Label: "SSL.com Root Certification Authority ECC" + * Serial: 8495723813297216424 + * SHA256 Fingerprint: 34:17:bb:06:cc:60:07:da:1b:96:1c:92:0b:8a:b4:ce:3f:ad:82:0e:4a:a3:0b:9a:cb:c4:a7:4e:bd:ce:bc:65 + * -----BEGIN CERTIFICATE----- + * MIICjTCCAhSgAwIBAgIIdebfy8FoW6gwCgYIKoZIzj0EAwIwfDELMAkGA1UEBhMC + * VVMxDjAMBgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9T + * U0wgQ29ycG9yYXRpb24xMTAvBgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZpY2F0 + * aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYwMjEyMTgxNDAzWhcNNDEwMjEyMTgxNDAz + * WjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAOBgNVBAcMB0hvdXN0 + * b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NMLmNvbSBS + * b290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49AgEGBSuB + * BAAiA2IABEVuqVDEpiM2nl8ojRfLliJkP9x6jh3MCLOicSS6jkm5BBtHllirLZXI + * 7Z4INcgn64mMU1jrYor+8FsPazFSY0E7ic3s7LaNGdM0B9y7xgZ/wkWV7Mt/qCPg + * CemB+vNH06NjMGEwHQYDVR0OBBYEFILRhXMw5zUE044CkvvlpNHEIejNMA8GA1Ud + * EwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUgtGFczDnNQTTjgKS++Wk0cQh6M0wDgYD + * VR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2cAMGQCMG/n61kRpGDPYbCWe+0F+S8T + * kdzt5fxQaxFGRrMcIQBiu77D5+jNB5n5DQtdcj7EqgIwH7y6C+IwJPt8bYBVCpk+ + * gA0z5Wajs6O7pdWLjwkspl1+4vAHCGht0nxpbl/f5Wpl + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1\x0e0\x0c\x06\x03U\x04\x08\x0c\x05Texas1\x100\x0e\x06\x03U\x04\x07\x0c\x07Houston1\x180\x16\x06\x03U\x04\n\x0c\x0fSSL Corporation110/\x06\x03U\x04\x03\x0c(SSL.com Root Certification Authority ECC"), + subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\"\x03b\x00\x04En\xa9P\xc4\xa6#6\x9e_(\x8d\x17\xcb\x96\"d?\xdcz\x8e\x1d\xcc\x08\xb3\xa2q$\xba\x8eI\xb9\x04\x1bG\x96X\xab-\x95\xc8\xed\x9e\x085\xc8\'\xeb\x89\x8cSX\xebb\x8a\xfe\xf0[\x0fk1RcA;\x89\xcd\xec\xec\xb6\x8d\x19\xd34\x07\xdc\xbb\xc6\x06\x7f\xc2E\x95\xec\xcb\x7f\xa8#\xe0\t\xe9\x81\xfa\xf3G\xd3"), + name_constraints: None + }, + + /* + * Issuer: CN=GTS Root R4 O=Google Trust Services LLC + * Subject: CN=GTS Root R4 O=Google Trust Services LLC + * Label: "GTS Root R4" + * Serial: 159662532700760215368942768210 + * SHA256 Fingerprint: 34:9d:fa:40:58:c5:e2:63:12:3b:39:8a:e7:95:57:3c:4e:13:13:c8:3f:e6:8f:93:55:6c:d5:e8:03:1b:3c:7d + * -----BEGIN CERTIFICATE----- + * MIICCTCCAY6gAwIBAgINAgPlwGjvYxqccpBQUjAKBggqhkjOPQQDAzBHMQswCQYD + * VQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIG + * A1UEAxMLR1RTIFJvb3QgUjQwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAw + * WjBHMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2Vz + * IExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjQwdjAQBgcqhkjOPQIBBgUrgQQAIgNi + * AATzdHOnaItgrkO4NcWBMHtLSZ37wWHO5t5GvWvVYRg1rkDdc/eJkTBa6zzuhXyi + * QHY7qca4R9gq55KRanPpsXI5nymfopjTX15YhmUPoYRlBtHci8nHc8iMai/lxKvR + * HYqjQjBAMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQW + * BBSATNbrdP9JNqPV2Py1PsVq8JQdjDAKBggqhkjOPQQDAwNpADBmAjEA6ED/g94D + * 9J+uHXqnLrmvT/aDHQ4thQEd0dlq7A/Cr8deVl5c1RxYIigL9zC2L7F8AjEA8GE8 + * p/SgguMh1YQdc4acLa/KNJvxn7kjNuK8YAOdgLOaVsjh4rsUecrNIdSUtUlD + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1\"0 \x06\x03U\x04\n\x13\x19Google Trust Services LLC1\x140\x12\x06\x03U\x04\x03\x13\x0bGTS Root R4"), + subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\"\x03b\x00\x04\xf3ts\xa7h\x8b`\xaeC\xb85\xc5\x810{KI\x9d\xfb\xc1a\xce\xe6\xdeF\xbdk\xd5a\x185\xae@\xdds\xf7\x89\x910Z\xeb<\xee\x85|\xa2@v;\xa9\xc6\xb8G\xd8*\xe7\x92\x91js\xe9\xb1r9\x9f)\x9f\xa2\x98\xd3_^X\x86e\x0f\xa1\x84e\x06\xd1\xdc\x8b\xc9\xc7s\xc8\x8cj/\xe5\xc4\xab\xd1\x1d\x8a"), + name_constraints: None + }, + + /* + * Issuer: CN=GTS Root R3 O=Google Trust Services LLC + * Subject: CN=GTS Root R3 O=Google Trust Services LLC + * Label: "GTS Root R3" + * Serial: 159662495401136852707857743206 + * SHA256 Fingerprint: 34:d8:a7:3e:e2:08:d9:bc:db:0d:95:65:20:93:4b:4e:40:e6:94:82:59:6e:8b:6f:73:c8:42:6b:01:0a:6f:48 + * -----BEGIN CERTIFICATE----- + * MIICCTCCAY6gAwIBAgINAgPluILrIPglJ209ZjAKBggqhkjOPQQDAzBHMQswCQYD + * VQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIG + * A1UEAxMLR1RTIFJvb3QgUjMwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAw + * WjBHMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2Vz + * IExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjMwdjAQBgcqhkjOPQIBBgUrgQQAIgNi + * AAQfTzOHMymKoYTey8chWEGJ6ladK0uFxh1MJ7x/JlFyb+Kf1qPKzEUURout736G + * jOyxfi//qXGdGIRFBEFVbivqJn+7kAHjSxm65FSWRQmx1WyRRK2EE46ajA2ADDL2 + * 4CejQjBAMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQW + * BBTB8Sa6oC2uhYHP0/EqEr24Cmf9vDAKBggqhkjOPQQDAwNpADBmAjEA9uEglRR7 + * VKOQFhG/hMjqb2sXnh5GmCCbn9MN2azTL818+FsuVbu/3ZL3pAzcMeGiAjEA/Jdm + * ZuVDFhOD3cffL74UOO0BzrEXGhF16b0DjyZ+hOXJYKaV11RZt+cRLInUue4X + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1\"0 \x06\x03U\x04\n\x13\x19Google Trust Services LLC1\x140\x12\x06\x03U\x04\x03\x13\x0bGTS Root R3"), + subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\"\x03b\x00\x04\x1fO3\x873)\x8a\xa1\x84\xde\xcb\xc7!XA\x89\xeaV\x9d+K\x85\xc6\x1dL\'\xbc\x7f&Qro\xe2\x9f\xd6\xa3\xca\xccE\x14F\x8b\xad\xef~\x86\x8c\xec\xb1~/\xff\xa9q\x9d\x18\x84E\x04AUn+\xea&\x7f\xbb\x90\x01\xe3K\x19\xba\xe4T\x96E\t\xb1\xd5l\x91D\xad\x84\x13\x8e\x9a\x8c\r\x80\x0c2\xf6\xe0\'"), + name_constraints: None + }, + + /* + * Issuer: CN=Microsoft ECC Root Certificate Authority 2017 O=Microsoft Corporation + * Subject: CN=Microsoft ECC Root Certificate Authority 2017 O=Microsoft Corporation + * Label: "Microsoft ECC Root Certificate Authority 2017" + * Serial: 136839042543790627607696632466672567020 + * SHA256 Fingerprint: 35:8d:f3:9d:76:4a:f9:e1:b7:66:e9:c9:72:df:35:2e:e1:5c:fa:c2:27:af:6a:d1:d7:0e:8e:4a:6e:dc:ba:02 + * -----BEGIN CERTIFICATE----- + * MIICWTCCAd+gAwIBAgIQZvI9r4fei7FK6gxXMQHC7DAKBggqhkjOPQQDAzBlMQsw + * CQYDVQQGEwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYwNAYD + * VQQDEy1NaWNyb3NvZnQgRUNDIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIw + * MTcwHhcNMTkxMjE4MjMwNjQ1WhcNNDIwNzE4MjMxNjA0WjBlMQswCQYDVQQGEwJV + * UzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYwNAYDVQQDEy1NaWNy + * b3NvZnQgRUNDIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwdjAQBgcq + * hkjOPQIBBgUrgQQAIgNiAATUvD0CQnVBEyPNgASGAlEvaqiBYgtlzPbKnR5vSmZR + * ogPZnZH6thaxjG7efM3beaYvzrvOcS/lpaso7GMEZpn4+vKTEAXhgShC48Zo9OYb + * hGBKia/teQ87zvH2RPUBeMCjVDBSMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8E + * BTADAQH/MB0GA1UdDgQWBBTIy5lycFIM+Oa+sgRXKSrPQhDtNTAQBgkrBgEEAYI3 + * FQEEAwIBADAKBggqhkjOPQQDAwNoADBlAjBY8k3qDPlfXu5gKcs68tvWMoQZP3zV + * L8KxzJOuULsJMsbG7X7JNpQS5GiFBqIb0C8CMQCZ6Ra0DvpWSNSkMBaReNtUjGUB + * iudQZsIxtzm6uBoiB078a1QWIP8rtedMDE2mT3M= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1\x1e0\x1c\x06\x03U\x04\n\x13\x15Microsoft Corporation1604\x06\x03U\x04\x03\x13-Microsoft ECC Root Certificate Authority 2017"), + subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\"\x03b\x00\x04\xd4\xbc=\x02BuA\x13#\xcd\x80\x04\x86\x02Q/j\xa8\x81b\x0be\xcc\xf6\xca\x9d\x1eoJfQ\xa2\x03\xd9\x9d\x91\xfa\xb6\x16\xb1\x8cn\xde|\xcd\xdby\xa6/\xce\xbb\xceq/\xe5\xa5\xab(\xecc\x04f\x99\xf8\xfa\xf2\x93\x10\x05\xe1\x81(B\xe3\xc6h\xf4\xe6\x1b\x84`J\x89\xaf\xedy\x0f;\xce\xf1\xf6D\xf5\x01x\xc0"), + name_constraints: None + }, + + /* + * Issuer: CN=DigiCert TLS RSA4096 Root G5 O=DigiCert, Inc. + * Subject: CN=DigiCert TLS RSA4096 Root G5 O=DigiCert, Inc. + * Label: "DigiCert TLS RSA4096 Root G5" + * Serial: 11930366277458970227240571539258396554 + * SHA256 Fingerprint: 37:1a:00:dc:05:33:b3:72:1a:7e:eb:40:e8:41:9e:70:79:9d:2b:0a:0f:2c:1d:80:69:31:65:f7:ce:c4:ad:75 + * -----BEGIN CERTIFICATE----- + * MIIFZjCCA06gAwIBAgIQCPm0eKj6ftpqMzeJ3nzPijANBgkqhkiG9w0BAQwFADBN + * MQswCQYDVQQGEwJVUzEXMBUGA1UEChMORGlnaUNlcnQsIEluYy4xJTAjBgNVBAMT + * HERpZ2lDZXJ0IFRMUyBSU0E0MDk2IFJvb3QgRzUwHhcNMjEwMTE1MDAwMDAwWhcN + * NDYwMTE0MjM1OTU5WjBNMQswCQYDVQQGEwJVUzEXMBUGA1UEChMORGlnaUNlcnQs + * IEluYy4xJTAjBgNVBAMTHERpZ2lDZXJ0IFRMUyBSU0E0MDk2IFJvb3QgRzUwggIi + * MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCz0PTJeRGd/fxmgefM1eS87IE+ + * ajWOLrfn3q/5B03PMJ3qCQuZvWxX2hhKuHisOjmopkisLnLlvevxGs3npAOpPxG0 + * 2C+JFvuUAT27L/gTBaF4HI4o4EXgg/RZG5Wzrn4DReW+wkL+7vI8toUTmDKdFqgp + * wgscONyfMXdcvyej/Cestyu9dJsXLfKB2l2w4SMXPohKEiPQ6s+d3gMXsUJKoBZM + * pG2T6T867jp8nVid9E6P/DsjyG244gXazOvswzH016cpVIDPRFtMbzCe88zdH5RD + * nU1/cHAN1DrRN/BsnZvAFJNY781BOHW8EwOVfH/jXOnVDdXifBBiqmvwPXbzP6Po + * sMH976pXTayGpxi0KcEsDr9kvimM2AItzVwv8n/vFfQMFawKsPHTDU9qTXeXAaDx + * Zre3zu/O7Oyldcqs4+Fj97ihBMi8ez9dLRYiVu1ISf6nL3kwJZu6ay0/nTvEF+cd + * Lvvyz6b84xQslpghjLSR6Rlgg/IwKwZzUNWYOwbpx4oMYIwo+FKbbuH2TbsGJJvX + * KyY//SovcfXWJL5/MZ4PbeiPT02jP/816t9JXkGPhvnxd3lLG7SjXi/7RgLQZhNe + * XoVPzthwiHvOAbWWl9fNff2C+MIkwcoBOU+NosEUQB+cZtUMCUbW8tDRSHZWOkPL + * tgoRObqME2wGtZ7P6wIDAQABo0IwQDAdBgNVHQ4EFgQUUTMc7TZArxfTJc1paPKv + * TiM+s0EwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcN + * AQEMBQADggIBAGCmr1tfV9qJ20tQqcQjNSH/0GEwhJG3PxDPJY7Jv0Y02cEhJhxw + * GXIeo8mH/qlDZJY6yFMECrZBu8RHANmfGBg7sg7zNOok992vIGCukihfNudd5N7H + * PNtQOa27PShNlnx2xlv0wdsUpasZYgcYQF+Xkdycx6u1UQ3maVNVzDl92sURVXLF + * O4uJ+DQtpBflF+aZfTCIITfNMBc9uPK8qHWgQ9w+iUuQrm0D4ByjoJYJu32jtyoQ + * REtGBzRj7TG5BO6jm5qu5jF49OokYTurWGT/u4cnYiWB39yhL/btp/96j1EuMPik + * AdKFOV8BmZZvWltwGUb+hmA+rYAQCd05JS9Yf7vSdPD3Rh9GOUrYU9DzLjtxpdRv + * /PNn5AeP3SYZ4Y1b+qOTEZvpyDrDVWiakuFSdjjo4bq9+0/V77PnSIMx8IIh47a+ + * p6tv75/fTM8BuGJqIz3nCU2AG3swpMPdB380vqQmsvZB6Akd4yCYqjdP//fx4ilw + * MUc/dNAUFvohigLVigmUdy7yWSiLfFCSCmZ4OIN1xLVaqBHG5cGdZlXPU8Sv13WF + * qUITVuwhd4GTWgzqltlJyqEI8pc7bZsEGCREjnwB8twl2F6GmrE52/WRMmrRpnCK + * ovfepEWFJqgejF0pW8hL2JpqA15w8oVPbEtoL8pU9ozaMv7Da4M/OMZ+ + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1\x170\x15\x06\x03U\x04\n\x13\x0eDigiCert, Inc.1%0#\x06\x03U\x04\x03\x13\x1cDigiCert TLS RSA4096 Root G5"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xb3\xd0\xf4\xc9y\x11\x9d\xfd\xfcf\x81\xe7\xcc\xd5\xe4\xbc\xec\x81>j5\x8e.\xb7\xe7\xde\xaf\xf9\x07M\xcf0\x9d\xea\t\x0b\x99\xbdlW\xda\x18J\xb8x\xac:9\xa8\xa6H\xac.r\xe5\xbd\xeb\xf1\x1a\xcd\xe7\xa4\x03\xa9?\x11\xb4\xd8/\x89\x16\xfb\x94\x01=\xbb/\xf8\x13\x05\xa1x\x1c\x8e(\xe0E\xe0\x83\xf4Y\x1b\x95\xb3\xae~\x03E\xe5\xbe\xc2B\xfe\xee\xf2<\xb6\x85\x13\x982\x9d\x16\xa8)\xc2\x0b\x1c8\xdc\x9f1w\\\xbf\'\xa3\xfc\'\xac\xb7+\xbdt\x9b\x17-\xf2\x81\xda]\xb0\xe1#\x17>\x88J\x12#\xd0\xea\xcf\x9d\xde\x03\x17\xb1BJ\xa0\x16L\xa4m\x93\xe9?:\xee:|\x9dX\x9d\xf4N\x8f\xfc;#\xc8m\xb8\xe2\x05\xda\xcc\xeb\xec\xc31\xf4\xd7\xa7)T\x80\xcfD[Lo0\x9e\xf3\xcc\xdd\x1f\x94C\x9dM\x7fpp\r\xd4:\xd17\xf0l\x9d\x9b\xc0\x14\x93X\xef\xcdA8u\xbc\x13\x03\x95|\x7f\xe3\\\xe9\xd5\r\xd5\xe2|\x10b\xaak\xf0=v\xf3?\xa3\xe8\xb0\xc1\xfd\xef\xaaWM\xac\x86\xa7\x18\xb4)\xc1,\x0e\xbfd\xbe)\x8c\xd8\x02-\xcd\\/\xf2\x7f\xef\x15\xf4\x0c\x15\xac\n\xb0\xf1\xd3\rOjMw\x97\x01\xa0\xf1f\xb7\xb7\xce\xef\xce\xec\xec\xa5u\xca\xac\xe3\xe1c\xf7\xb8\xa1\x04\xc8\xbc{?]-\x16\"V\xedHI\xfe\xa7/y0%\x9b\xbak-?\x9d;\xc4\x17\xe7\x1d.\xfb\xf2\xcf\xa6\xfc\xe3\x14,\x96\x98!\x8c\xb4\x91\xe9\x19`\x83\xf20+\x06sP\xd5\x98;\x06\xe9\xc7\x8a\x0c`\x8c(\xf8R\x9bn\xe1\xf6M\xbb\x06$\x9b\xd7+&?\xfd*/q\xf5\xd6$\xbe\x7f1\x9e\x0fm\xe8\x8fOM\xa3?\xff5\xea\xdfI^A\x8f\x86\xf9\xf1wyK\x1b\xb4\xa3^/\xfbF\x02\xd0f\x13^^\x85O\xce\xd8p\x88{\xce\x01\xb5\x96\x97\xd7\xcd}\xfd\x82\xf8\xc2$\xc1\xca\x019O\x8d\xa2\xc1\x14@\x1f\x9cf\xd5\x0c\tF\xd6\xf2\xd0\xd1HvV:C\xcb\xb6\n\x119\xba\x8c\x13l\x06\xb5\x9e\xcf\xeb\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=Microsec e-Szigno Root CA 2009 O=Microsec Ltd. + * Subject: CN=Microsec e-Szigno Root CA 2009 O=Microsec Ltd. + * Label: "Microsec e-Szigno Root CA 2009" + * Serial: 14014712776195784473 + * SHA256 Fingerprint: 3c:5f:81:fe:a5:fa:b8:2c:64:bf:a2:ea:ec:af:cd:e8:e0:77:fc:86:20:a7:ca:e5:37:16:3d:f3:6e:db:f3:78 + * -----BEGIN CERTIFICATE----- + * MIIECjCCAvKgAwIBAgIJAMJ+QwRORz8ZMA0GCSqGSIb3DQEBCwUAMIGCMQswCQYD + * VQQGEwJIVTERMA8GA1UEBwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0 + * ZC4xJzAlBgNVBAMMHk1pY3Jvc2VjIGUtU3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0G + * CSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5odTAeFw0wOTA2MTYxMTMwMThaFw0y + * OTEyMzAxMTMwMThaMIGCMQswCQYDVQQGEwJIVTERMA8GA1UEBwwIQnVkYXBlc3Qx + * FjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xJzAlBgNVBAMMHk1pY3Jvc2VjIGUtU3pp + * Z25vIFJvb3QgQ0EgMjAwOTEfMB0GCSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5o + * dTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOn4j/NjrdqG2KfgQvvP + * kd6mJviZpWNwrZuuyjNAfW2WbqEORO7hE52UQlKavXWFdCyoDh2Tthi3jCyoz/tc + * cbna7P7ofo/kLx2yqHWH2Leh5TvPmUpG0IMZfcChEhyVbUr02MelTTMuhTlAdX4U + * fIASmFDHQWe4oIBhVKZsTh/gnQ4H6cm6M+f+wFUoLAKApxn1ntxVUwOXewdI/5n7 + * N4okxFnMUBBjjqqpGrCEGob5X7uxUG6k0QrM1XF+H6cbfPVTbiJfyyvm1HxdrtbC + * xkzlBQHZ7Vf8wSN5/PrIJIOV87VqUQHQd9bpEqH5GoP7ghu5sJf0dgYzQ0mg/wu1 + * +rUCAwEAAaOBgDB+MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0G + * A1UdDgQWBBTLD8bfQkPMPcu1SCOhGnqmKrs0aDAfBgNVHSMEGDAWgBTLD8bfQkPM + * Pcu1SCOhGnqmKrs0aDAbBgNVHREEFDASgRBpbmZvQGUtc3ppZ25vLmh1MA0GCSqG + * SIb3DQEBCwUAA4IBAQDJ0Q5eLtXMs3w+y/w9/w0olZMEyL/azXm4Q5DwpL7v8u8h + * mLzU1F0G9u5C7DBsoKqpyvGvivo/C3NqPuouQH4frlRheesuCDfXI/OMn74dseGk + * ddug4lQUsbocKaQY9hK6ohQU4zE1yED/t+AFdlfBHFny+L/k7SViXITwfn4fs775 + * tyERzAMBVnCnEJIeGzSBHq2cGsMEPO0CYdYeBvNfOofyK/FFh+U9rNHHV4S9a67c + * 2Pm2G2JwCz02yULyMtd6YebS2z3PyKnJm9zbWETXbzivf3jTo60adbocwTZ8jx5t + * HMN1Rq41Bab2XD0h7lbwyYIiLXpUq3DDfSJlgnCW + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02HU1\x110\x0f\x06\x03U\x04\x07\x0c\x08Budapest1\x160\x14\x06\x03U\x04\n\x0c\rMicrosec Ltd.1\'0%\x06\x03U\x04\x03\x0c\x1eMicrosec e-Szigno Root CA 20091\x1f0\x1d\x06\t*\x86H\x86\xf7\r\x01\t\x01\x16\x10info@e-szigno.hu"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x01\x0f\x000\x82\x01\n\x02\x82\x01\x01\x00\xe9\xf8\x8f\xf3c\xad\xda\x86\xd8\xa7\xe0B\xfb\xcf\x91\xde\xa6&\xf8\x99\xa5cp\xad\x9b\xae\xca3@}m\x96n\xa1\x0eD\xee\xe1\x13\x9d\x94BR\x9a\xbdu\x85t,\xa8\x0e\x1d\x93\xb6\x18\xb7\x8c,\xa8\xcf\xfb\\q\xb9\xda\xec\xfe\xe8~\x8f\xe4/\x1d\xb2\xa8u\x87\xd8\xb7\xa1\xe5;\xcf\x99JF\xd0\x83\x19}\xc0\xa1\x12\x1c\x95mJ\xf4\xd8\xc7\xa5M3.\x859@u~\x14|\x80\x12\x98P\xc7Ag\xb8\xa0\x80aT\xa6lN\x1f\xe0\x9d\x0e\x07\xe9\xc9\xba3\xe7\xfe\xc0U(,\x02\x80\xa7\x19\xf5\x9e\xdcUS\x03\x97{\x07H\xff\x99\xfb7\x8a$\xc4Y\xccP\x10c\x8e\xaa\xa9\x1a\xb0\x84\x1a\x86\xf9_\xbb\xb1Pn\xa4\xd1\n\xcc\xd5q~\x1f\xa7\x1b|\xf5Sn\"_\xcb+\xe6\xd4|]\xae\xd6\xc2\xc6L\xe5\x05\x01\xd9\xedW\xfc\xc1#y\xfc\xfa\xc8$\x83\x95\xf3\xb5jQ\x01\xd0w\xd6\xe9\x12\xa1\xf9\x1a\x83\xfb\x82\x1b\xb9\xb0\x97\xf4v\x063CI\xa0\xff\x0b\xb5\xfa\xb5\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=TWCA CYBER Root CA O=TAIWAN-CA OU=Root CA + * Subject: CN=TWCA CYBER Root CA O=TAIWAN-CA OU=Root CA + * Label: "TWCA CYBER Root CA" + * Serial: 85076849864375384482682434040119489222 + * SHA256 Fingerprint: 3f:63:bb:28:14:be:17:4e:c8:b6:43:9c:f0:8d:6d:56:f0:b7:c4:05:88:3a:56:48:a3:34:42:4d:6b:3e:c5:58 + * -----BEGIN CERTIFICATE----- + * MIIFjTCCA3WgAwIBAgIQQAE0jMIAAAAAAAAAATzyxjANBgkqhkiG9w0BAQwFADBQ + * MQswCQYDVQQGEwJUVzESMBAGA1UEChMJVEFJV0FOLUNBMRAwDgYDVQQLEwdSb290 + * IENBMRswGQYDVQQDExJUV0NBIENZQkVSIFJvb3QgQ0EwHhcNMjIxMTIyMDY1NDI5 + * WhcNNDcxMTIyMTU1OTU5WjBQMQswCQYDVQQGEwJUVzESMBAGA1UEChMJVEFJV0FO + * LUNBMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDExJUV0NBIENZQkVSIFJvb3Qg + * Q0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDG+Moe2Qkgfh1sTs6P + * 40czRJzHyWmqOlt47nDSkvgEs1JSHWdyKKHfi12VCv7qze33Kc7wb3+szT3vsxxF + * avcokPFhV8UMxKNQXd7UtcsZyoC5dc4pztKFIuwCY8xEMCDa6pFbVuYdHNWdZsc/ + * 34bKS1PE2Y2yHer43CdTo0fhYcx9tbD47nORxc5zb87uEB8aBs/pJ2DFTxnk684i + * JkXXYJndzk834H/nY62wuFm40AZoNWDTNq5xQwTxaWV4fPMf88oon1oglWa0zbfu + * j3ikRRjpJi+NmykosaS3Om251Bw4ckVYsV7r8Cibt4LK/c/WMw+f+5eesRycnupf + * Xtuq3VTpMCEobY5583WSjCb+3MX2w7DfRFlDo7YDKPYIMKoNM+HvnKkHIuNZW0CP + * 2oi3aQiotyMuRAlZN1vH4xfyIutuOVLF3lSnmMlLIJXcRolftBL5hSmO68gnFSDA + * S9TMfAxsNAwmmyYxpjyn9tnQS6Jk/zuZQXLB4HCX8SS7K8R0IrGsayIyJNN4KsDA + * oS/xUgXJP+92ZuJF2A09rZXIx4kmyA+upwMu+8Ff+iDhcK2wZSA3M2Cw1a/XDBzC + * kHDXShi8fgGwsOsVHkQGzaRP6AzRwyAQ4VRlnrZR0Bp2a0JaWHY06rc3Ga4udfmW + * 5cFZ95RXKSWNOkyrTZpB0F8mAwIDAQABo2MwYTAOBgNVHQ8BAf8EBAMCAQYwDwYD + * VR0TAQH/BAUwAwEB/zAfBgNVHSMEGDAWgBSdhWEUfMFib5do5E83QOGt4A1WNzAd + * BgNVHQ4EFgQUnYVhFHzBYm+XaORPN0DhreANVjcwDQYJKoZIhvcNAQEMBQADggIB + * AGSPesRiDrWIzLjHhg6hShbNcAu3p4ULs3a2D6f/CIsLJc+o1IN1KriWiLb73y0t + * tGlTITVX1olNc79pj3CjYcya2x6a4CD4bLubIp1dhDGaLIrdaqHXKGnK/nZVekZn + * 68xDiBaiA9a5F/gZbG0jAn/xX9AKKSM70aoK7akXJlQKTcKlTfjF/biBzysseKNn + * TKkHmvPfXvt89YnNdJdhEGoHK4Fa0o635yDRIG4kqIQnoVesqlVYL9zZyvpoBJ7t + * RCT5dEA7IzOrg1oYJkK2bVS1FmAwbLGg+LhBoF1JSdJlBTrq/p1hvIbZv97Tujqx + * f36SNI7JAG7cmL3c7IAFrQI932XtCwP39xaEBDG6k5TY8hL4iuO/Qq+n1M0RFxbI + * Qh0UqEL20kCGoE8jypZFVmAGzbdVAaYBlGX+bgUJurSkquLvWL69J1bY73NxW0Qz + * 8ppy6rBePm6pUlvscG21h483XjyMnM7k8M4MZ0HMzvaAq07MTFb1wWFZk7Q+ptq4 + * NxKfKjLji7gh7MMrZQzvIt6IKTtM1/r+t+FHvpw+PoP7UV31aPcuIYXcv/Fa4nzX + * xeSDwWrruoBa3lwtcHb4yOWHh8qgnaHlIhInD0Q9HWzq1MKLL295q39QpsQZp6F6 + * t5b5wR9iWqJDB0BeJsas7a5wFsWqynKKTbDPAYsDP27X + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02TW1\x120\x10\x06\x03U\x04\n\x13\tTAIWAN-CA1\x100\x0e\x06\x03U\x04\x0b\x13\x07Root CA1\x1b0\x19\x06\x03U\x04\x03\x13\x12TWCA CYBER Root CA"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xc6\xf8\xca\x1e\xd9\t ~\x1dlN\xce\x8f\xe3G3D\x9c\xc7\xc9i\xaa:[x\xeep\xd2\x92\xf8\x04\xb3RR\x1dgr(\xa1\xdf\x8b]\x95\n\xfe\xea\xcd\xed\xf7)\xce\xf0o\x7f\xac\xcd=\xef\xb3\x1cEj\xf7(\x90\xf1aW\xc5\x0c\xc4\xa3P]\xde\xd4\xb5\xcb\x19\xca\x80\xb9u\xce)\xce\xd2\x85\"\xec\x02c\xccD0 \xda\xea\x91[V\xe6\x1d\x1c\xd5\x9df\xc7?\xdf\x86\xcaKS\xc4\xd9\x8d\xb2\x1d\xea\xf8\xdc\'S\xa3G\xe1a\xcc}\xb5\xb0\xf8\xees\x91\xc5\xceso\xce\xee\x10\x1f\x1a\x06\xcf\xe9\'`\xc5O\x19\xe4\xeb\xce\"&E\xd7`\x99\xdd\xceO7\xe0\x7f\xe7c\xad\xb0\xb8Y\xb8\xd0\x06h5`\xd36\xaeqC\x04\xf1iex|\xf3\x1f\xf3\xca(\x9fZ \x95f\xb4\xcd\xb7\xee\x8fx\xa4E\x18\xe9&/\x8d\x9b)(\xb1\xa4\xb7:m\xb9\xd4\x1c8rEX\xb1^\xeb\xf0(\x9b\xb7\x82\xca\xfd\xcf\xd63\x0f\x9f\xfb\x97\x9e\xb1\x1c\x9c\x9e\xea_^\xdb\xaa\xddT\xe90!(m\x8ey\xf3u\x92\x8c&\xfe\xdc\xc5\xf6\xc3\xb0\xdfDYC\xa3\xb6\x03(\xf6\x080\xaa\r3\xe1\xef\x9c\xa9\x07\"\xe3Y[@\x8f\xda\x88\xb7i\x08\xa8\xb7#.D\tY7[\xc7\xe3\x17\xf2\"\xebn9R\xc5\xdeT\xa7\x98\xc9K \x95\xdcF\x89_\xb4\x12\xf9\x85)\x8e\xeb\xc8\'\x15 \xc0K\xd4\xcc|\x0cl4\x0c&\x9b&1\xa6<\xa7\xf6\xd9\xd0K\xa2d\xff;\x99Ar\xc1\xe0p\x97\xf1$\xbb+\xc4t\"\xb1\xack\"2$\xd3x*\xc0\xc0\xa1/\xf1R\x05\xc9?\xefvf\xe2E\xd8\r=\xad\x95\xc8\xc7\x89&\xc8\x0f\xae\xa7\x03.\xfb\xc1_\xfa \xe1p\xad\xb0e 73`\xb0\xd5\xaf\xd7\x0c\x1c\xc2\x90p\xd7J\x18\xbc~\x01\xb0\xb0\xeb\x15\x1eD\x06\xcd\xa4O\xe8\x0c\xd1\xc3 \x10\xe1Te\x9e\xb6Q\xd0\x1avkBZXv4\xea\xb77\x19\xae.u\xf9\x96\xe5\xc1Y\xf7\x94W)%\x8d:L\xabM\x9aA\xd0_&\x03\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=HARICA TLS ECC Root CA 2021 O=Hellenic Academic and Research Institutions CA + * Subject: CN=HARICA TLS ECC Root CA 2021 O=Hellenic Academic and Research Institutions CA + * Label: "HARICA TLS ECC Root CA 2021" + * Serial: 137515985548005187474074462014555733966 + * SHA256 Fingerprint: 3f:99:cc:47:4a:cf:ce:4d:fe:d5:87:94:66:5e:47:8d:15:47:73:9f:2e:78:0f:1b:b4:ca:9b:13:30:97:d4:01 + * -----BEGIN CERTIFICATE----- + * MIICVDCCAdugAwIBAgIQZ3SdjXfYO2rbIvT/WeK/zjAKBggqhkjOPQQDAzBsMQsw + * CQYDVQQGEwJHUjE3MDUGA1UECgwuSGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2Vh + * cmNoIEluc3RpdHV0aW9ucyBDQTEkMCIGA1UEAwwbSEFSSUNBIFRMUyBFQ0MgUm9v + * dCBDQSAyMDIxMB4XDTIxMDIxOTExMDExMFoXDTQ1MDIxMzExMDEwOVowbDELMAkG + * A1UEBhMCR1IxNzA1BgNVBAoMLkhlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJj + * aCBJbnN0aXR1dGlvbnMgQ0ExJDAiBgNVBAMMG0hBUklDQSBUTFMgRUNDIFJvb3Qg + * Q0EgMjAyMTB2MBAGByqGSM49AgEGBSuBBAAiA2IABDgI/rGgltJ6rK9JOtDA4MM7 + * KKrxcm1lAEeIhPyaJmuqS7psBAqIXhfyVYf8MLA04jRYVxqEU+kw2anylnTDUR9Y + * STHMmE5gEYd103KUkE+bECUqqHgtvpBBWJAVcqeht6NCMEAwDwYDVR0TAQH/BAUw + * AwEB/zAdBgNVHQ4EFgQUyRtTgRL+BNUW0aq8mm+3oJUZbsowDgYDVR0PAQH/BAQD + * AgGGMAoGCCqGSM49BAMDA2cAMGQCMBHervjcToiwqfAircJRQO9gcS3ujwLEXQNw + * SaSS6sUUiHCm0w2wqsosQJz76YJumgIwK0eaB8bRwoF8yguWGEEbo/QwCZ61IygN + * nxS2PFOiTAZpffpskcYqSUXm7LcT4Tps + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02GR1705\x06\x03U\x04\n\x0c.Hellenic Academic and Research Institutions CA1$0\"\x06\x03U\x04\x03\x0c\x1bHARICA TLS ECC Root CA 2021"), + subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\"\x03b\x00\x048\x08\xfe\xb1\xa0\x96\xd2z\xac\xafI:\xd0\xc0\xe0\xc3;(\xaa\xf1rme\x00G\x88\x84\xfc\x9a&k\xaaK\xbal\x04\n\x88^\x17\xf2U\x87\xfc0\xb04\xe24XW\x1a\x84S\xe90\xd9\xa9\xf2\x96t\xc3Q\x1fXI1\xcc\x98N`\x11\x87u\xd3r\x94\x90O\x9b\x10%*\xa8x-\xbe\x90AX\x90\x15r\xa7\xa1\xb7"), + name_constraints: None + }, + + /* + * Issuer: CN=emSign Root CA - G1 O=eMudhra Technologies Limited OU=emSign PKI + * Subject: CN=emSign Root CA - G1 O=eMudhra Technologies Limited OU=emSign PKI + * Label: "emSign Root CA - G1" + * Serial: 235931866688319308814040 + * SHA256 Fingerprint: 40:f6:af:03:46:a9:9a:a1:cd:1d:55:5a:4e:9c:ce:62:c7:f9:63:46:03:ee:40:66:15:83:3d:c8:c8:d0:03:67 + * -----BEGIN CERTIFICATE----- + * MIIDlDCCAnygAwIBAgIKMfXkYgxsWO3W2DANBgkqhkiG9w0BAQsFADBnMQswCQYD + * VQQGEwJJTjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBU + * ZWNobm9sb2dpZXMgTGltaXRlZDEcMBoGA1UEAxMTZW1TaWduIFJvb3QgQ0EgLSBH + * MTAeFw0xODAyMTgxODMwMDBaFw00MzAyMTgxODMwMDBaMGcxCzAJBgNVBAYTAklO + * MRMwEQYDVQQLEwplbVNpZ24gUEtJMSUwIwYDVQQKExxlTXVkaHJhIFRlY2hub2xv + * Z2llcyBMaW1pdGVkMRwwGgYDVQQDExNlbVNpZ24gUm9vdCBDQSAtIEcxMIIBIjAN + * BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk0u76WaK7p1b1TST0Bsew+eeuGQz + * f2N4aLTNLnF115sgxk0pvLZoYIr3IZpWNVrzdr3YzZr/k1ZLpVkGoZM0Kd0WNHVO + * 8oG0x5ZOrRkVUkr+PHB1cM2vK6sVmjM8qrOLqs1D/fXqcP/tzxE7lM5OMhbTI0Aq + * d7OvPAEsbO2ZLIvZTmmYsvePQbAyeGHWDV/D+qJAkh1cF+ZwPjXnorfCYuKrpDhM + * tTk1b+oDafo6VGiFbdbyL0NVHpENDtjVaqSW0RM8LHhQ6DqS0hdW5TUaQBw+jSzt + * Od9C4INBdN+jzcKGYEho42kLVACL5HZpIQ15TjQIXhTCzLG3rdd8cIrHhQIDAQAB + * o0IwQDAdBgNVHQ4EFgQU++8Nhp6w492pufEhF38+/PB3KxowDgYDVR0PAQH/BAQD + * AgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAFn/8oz1h31x + * PaOfG1vR2vjTnGs2vZupYeveFix0PZ7mddrXuqe8QhfnPZHr5X3dPpzxz5KsbEjM + * wiI/aTvFthUvozXGaCocV685743QNcMYDHsAVhzNixl03r4PEuDQqqE/AjSxcM6d + * GNYIAwlG7mDgfrbESQRRfXBgvKqy/3lyeqYdPV8q+Mri/Tm3R7nrft8EI6/6nAYH + * 6ftjk4BAtcZsCjEozgyfz7MjNYBBjWzEN3uBL4ChQEKF6dk4jeihU80Bv2noWgby + * RQuQ+q7hv53yrlc8pa6yVvSLZUDp/TGBLPQ5Cdjua6e0ph0VpZj3AYHYhX3zUVxx + * iN66zB+Afko= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02IN1\x130\x11\x06\x03U\x04\x0b\x13\nemSign PKI1%0#\x06\x03U\x04\n\x13\x1ceMudhra Technologies Limited1\x1c0\x1a\x06\x03U\x04\x03\x13\x13emSign Root CA - G1"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x01\x0f\x000\x82\x01\n\x02\x82\x01\x01\x00\x93K\xbb\xe9f\x8a\xee\x9d[\xd54\x93\xd0\x1b\x1e\xc3\xe7\x9e\xb8d3\x7fcxh\xb4\xcd.qu\xd7\x9b \xc6M)\xbc\xb6h`\x8a\xf7!\x9aV5Z\xf3v\xbd\xd8\xcd\x9a\xff\x93VK\xa5Y\x06\xa1\x934)\xdd\x164uN\xf2\x81\xb4\xc7\x96N\xad\x19\x15RJ\xfe5\xe7\xa2\xb7\xc2b\xe2\xab\xa48L\xb595o\xea\x03i\xfa:Th\x85m\xd6\xf2/CU\x1e\x91\r\x0e\xd8\xd5j\xa4\x96\xd1\x13<,xP\xe8:\x92\xd2\x17V\xe55\x1a@\x1c>\x8d,\xed9\xdfB\xe0\x83At\xdf\xa3\xcd\xc2\x86`Hh\xe3i\x0bT\x00\x8b\xe4vi!\ryN4\x08^\x14\xc2\xcc\xb1\xb7\xad\xd7|p\x8a\xc7\x85\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=Hellenic Academic and Research Institutions ECC RootCA 2015 O=Hellenic Academic and Research Institutions Cert. Authority + * Subject: CN=Hellenic Academic and Research Institutions ECC RootCA 2015 O=Hellenic Academic and Research Institutions Cert. Authority + * Label: "Hellenic Academic and Research Institutions ECC RootCA 2015" + * Serial: 0 + * SHA256 Fingerprint: 44:b5:45:aa:8a:25:e6:5a:73:ca:15:dc:27:fc:36:d2:4c:1c:b9:95:3a:06:65:39:b1:15:82:dc:48:7b:48:33 + * -----BEGIN CERTIFICATE----- + * MIICwzCCAkqgAwIBAgIBADAKBggqhkjOPQQDAjCBqjELMAkGA1UEBhMCR1IxDzAN + * BgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJl + * c2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3JpdHkxRDBCBgNVBAMTO0hl + * bGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgRUNDIFJv + * b3RDQSAyMDE1MB4XDTE1MDcwNzEwMzcxMloXDTQwMDYzMDEwMzcxMlowgaoxCzAJ + * BgNVBAYTAkdSMQ8wDQYDVQQHEwZBdGhlbnMxRDBCBgNVBAoTO0hlbGxlbmljIEFj + * YWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9yaXR5 + * MUQwQgYDVQQDEztIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0 + * dXRpb25zIEVDQyBSb290Q0EgMjAxNTB2MBAGByqGSM49AgEGBSuBBAAiA2IABJKg + * QehLgoRc4vgxEZmGZE4JJS+dQS8KrjVPdJWyUWRrjWvmP3CV8AVER6ZyOFB2lQJa + * jq4onvktTpnvLEhvTCUp6NFxW98dwXU3tNf6e3pCnGoKVlp8aQuqgAkkbH7BRqNC + * MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFLQi + * C4KZJAEOnLvkDv2/+5cgk5kqMAoGCCqGSM49BAMCA2cAMGQCMGfOFmI4oqxiRaep + * lSTAGiecMjvAwNW6qef4BENThe5SId6d9SWDPp5YSy/XZxMOIQIwBeF1Ad5o7Sof + * TUwJCA3sS61kFyjndc5FZXIhF8siQQ6ME5g4mlRtm8rifOoCWCKR + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02GR1\x0f0\r\x06\x03U\x04\x07\x13\x06Athens1D0B\x06\x03U\x04\n\x13;Hellenic Academic and Research Institutions Cert. Authority1D0B\x06\x03U\x04\x03\x13;Hellenic Academic and Research Institutions ECC RootCA 2015"), + subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\"\x03b\x00\x04\x92\xa0A\xe8K\x82\x84\\\xe2\xf81\x11\x99\x86dN\t%/\x9dA/\n\xae5Ot\x95\xb2Qdk\x8dk\xe6?p\x95\xf0\x05DG\xa6r8Pv\x95\x02Z\x8e\xae(\x9e\xf9-N\x99\xef,HoL%)\xe8\xd1q[\xdf\x1d\xc1u7\xb4\xd7\xfa{zB\x9cj\nVZ|i\x0b\xaa\x80\t$l~\xc1F"), + name_constraints: None + }, + + /* + * Issuer: CN=Go Daddy Root Certificate Authority - G2 O=GoDaddy.com, Inc. + * Subject: CN=Go Daddy Root Certificate Authority - G2 O=GoDaddy.com, Inc. + * Label: "Go Daddy Root Certificate Authority - G2" + * Serial: 0 + * SHA256 Fingerprint: 45:14:0b:32:47:eb:9c:c8:c5:b4:f0:d7:b5:30:91:f7:32:92:08:9e:6e:5a:63:e2:74:9d:d3:ac:a9:19:8e:da + * -----BEGIN CERTIFICATE----- + * MIIDxTCCAq2gAwIBAgIBADANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMx + * EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoT + * EUdvRGFkZHkuY29tLCBJbmMuMTEwLwYDVQQDEyhHbyBEYWRkeSBSb290IENlcnRp + * ZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIz + * NTk1OVowgYMxCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQH + * EwpTY290dHNkYWxlMRowGAYDVQQKExFHb0RhZGR5LmNvbSwgSW5jLjExMC8GA1UE + * AxMoR28gRGFkZHkgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIw + * DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL9xYgjx+lk09xvJGKP3gElY6SKD + * E6bFIEMBO4Tx5oVJnyfq9oQbTqC023CYxzIBsQU+B07u9PpPL1kwIuerGVZr4oAH + * /PMWdYA5UXvl+TW2dE6pjYIT5LY/qQOD+qK+ihVqf94Lw7YZFAXK6sOoBJQ7Rnwy + * DfMAZiLIjWltNowRGLfTshxgtDj6AozO091GB94KPutdfMh8+7ArU6SSYmlRJQVh + * GkSBjCypQ5Yj36w6gZoOKcUcqeldHraenjAKOc7xiID7S13MMuyFYkMlNAJWJwGR + * tDtwKj9useiciAF9n9T521NtYJ2/LOdYq7hfRvzOxBsDPAnrSTFcaUaz4EcCAwEA + * AaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYE + * FDqahQcQZyi27/a9BUFuIMGU2g/eMA0GCSqGSIb3DQEBCwUAA4IBAQCZ21151fmX + * WWcDYfF+OwYxdS2hII5PZYe096acvNjpL9DbWu7PdIxztDhC2gV7+AJ1uP2lsdeu + * 9tfeE8tTEH6KRtGX+rcuKxGrkLAngPnon1rpN5+r5N9ss4UXnT3ZJE95kTXWXwTr + * gIOrmgIttRD02JDHBHNA7XIloKmf7J6raBKZV8aPEjoJpL1E/QYVN8Gb5DKj7Tjo + * 2GTzLH4U/ALqn83/B2gX2yKQOC16jdFU8WnjXzPKej17CuPKf1855eJ1usV2GDPO + * LPAvTK33sefOT6jEm0pUBsV/fdUID+Ic/n4XuKxe9tQWskMJDE32p2u0mYRlynqI + * 4uJEvlz36hz1 + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1\x100\x0e\x06\x03U\x04\x08\x13\x07Arizona1\x130\x11\x06\x03U\x04\x07\x13\nScottsdale1\x1a0\x18\x06\x03U\x04\n\x13\x11GoDaddy.com, Inc.110/\x06\x03U\x04\x03\x13(Go Daddy Root Certificate Authority - G2"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x01\x0f\x000\x82\x01\n\x02\x82\x01\x01\x00\xbfqb\x08\xf1\xfaY4\xf7\x1b\xc9\x18\xa3\xf7\x80IX\xe9\"\x83\x13\xa6\xc5 C\x01;\x84\xf1\xe6\x85I\x9f\'\xea\xf6\x84\x1bN\xa0\xb4\xdbp\x98\xc72\x01\xb1\x05>\x07N\xee\xf4\xfaO/Y0\"\xe7\xab\x19Vk\xe2\x80\x07\xfc\xf3\x16u\x809Q{\xe5\xf95\xb6tN\xa9\x8d\x82\x13\xe4\xb6?\xa9\x03\x83\xfa\xa2\xbe\x8a\x15j\x7f\xde\x0b\xc3\xb6\x19\x14\x05\xca\xea\xc3\xa8\x04\x94;F|2\r\xf3\x00f\"\xc8\x8dim6\x8c\x11\x18\xb7\xd3\xb2\x1c`\xb48\xfa\x02\x8c\xce\xd3\xddF\x07\xde\n>\xeb]|\xc8|\xfb\xb0+S\xa4\x92biQ%\x05a\x1aD\x81\x8c,\xa9C\x96#\xdf\xac:\x81\x9a\x0e)\xc5\x1c\xa9\xe9]\x1e\xb6\x9e\x9e0\n9\xce\xf1\x88\x80\xfbK]\xcc2\xec\x85bC%4\x02V\'\x01\x91\xb4;p*?n\xb1\xe8\x9c\x88\x01}\x9f\xd4\xf9\xdbSm`\x9d\xbf,\xe7X\xab\xb8_F\xfc\xce\xc4\x1b\x03<\t\xebI1\\iF\xb3\xe0G\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=TUBITAK Kamu SM SSL Kok Sertifikasi - Surum 1 O=Turkiye Bilimsel ve Teknolojik Arastirma Kurumu - TUBITAK OU=Kamu Sertifikasyon Merkezi - Kamu SM + * Subject: CN=TUBITAK Kamu SM SSL Kok Sertifikasi - Surum 1 O=Turkiye Bilimsel ve Teknolojik Arastirma Kurumu - TUBITAK OU=Kamu Sertifikasyon Merkezi - Kamu SM + * Label: "TUBITAK Kamu SM SSL Kok Sertifikasi - Surum 1" + * Serial: 1 + * SHA256 Fingerprint: 46:ed:c3:68:90:46:d5:3a:45:3f:b3:10:4a:b8:0d:ca:ec:65:8b:26:60:ea:16:29:dd:7e:86:79:90:64:87:16 + * -----BEGIN CERTIFICATE----- + * MIIEYzCCA0ugAwIBAgIBATANBgkqhkiG9w0BAQsFADCB0jELMAkGA1UEBhMCVFIx + * GDAWBgNVBAcTD0dlYnplIC0gS29jYWVsaTFCMEAGA1UEChM5VHVya2l5ZSBCaWxp + * bXNlbCB2ZSBUZWtub2xvamlrIEFyYXN0aXJtYSBLdXJ1bXUgLSBUVUJJVEFLMS0w + * KwYDVQQLEyRLYW11IFNlcnRpZmlrYXN5b24gTWVya2V6aSAtIEthbXUgU00xNjA0 + * BgNVBAMTLVRVQklUQUsgS2FtdSBTTSBTU0wgS29rIFNlcnRpZmlrYXNpIC0gU3Vy + * dW0gMTAeFw0xMzExMjUwODI1NTVaFw00MzEwMjUwODI1NTVaMIHSMQswCQYDVQQG + * EwJUUjEYMBYGA1UEBxMPR2ViemUgLSBLb2NhZWxpMUIwQAYDVQQKEzlUdXJraXll + * IEJpbGltc2VsIHZlIFRla25vbG9qaWsgQXJhc3Rpcm1hIEt1cnVtdSAtIFRVQklU + * QUsxLTArBgNVBAsTJEthbXUgU2VydGlmaWthc3lvbiBNZXJrZXppIC0gS2FtdSBT + * TTE2MDQGA1UEAxMtVFVCSVRBSyBLYW11IFNNIFNTTCBLb2sgU2VydGlmaWthc2kg + * LSBTdXJ1bSAxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAr3UwM6q7 + * a9OZLBI3hNmNe5eA027n/5tQlT6QlVZC1xl8JoSNkvoBHToP4mQ4t4y86Ij5iySr + * LqP1N+RAjhgleYN1Hzv/bKjFxlb4tO2KRKOrbEz8HdDc72i9z+SqzvBV96I01INr + * N3wcwv61A+xXzry0tcXtAA9TNypN9E8Mg/uGz8v+jE69h/mniyFXnHrfA2eJLJ2X + * YacQuFWQfw4tJzh03+f92k4S400VIgLI4OD8D62K18lUUMw7D8oWgITQUVbDjlZ/ + * iSIzL+aFCr2lqBs23tPcLG07xxO9WSMs5uWk99gL7eqQQESolbuT1dCANLZGeA4f + * AJNG4e7p+exPFwIDAQABo0IwQDAdBgNVHQ4EFgQUZT/HiobGPN08VFw1+DrtUgxH + * V8gwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEL + * BQADggEBACo/4fEyjq7hmFxLXs9rHmoJ0iKpEsdeV31zVmSAhHqT5Am5EM2fKifh + * AHe+SMg1qIGf5LgsyX8OsNJLN13qudULXjS99HMpw+0mFZx+CFOKWI3QSyjfwbPf + * IPP54+M638yclNhOT8NrF7f3cuitZjO1JVOr4PhMqZ398g26rrnZqsZr+ZO7rqu4 + * lzwDGrpDxpa5RXI4s6ehlj2Re37AIVNMh+3yC1SVUZPVIqUNivGTDj5UDrDYyU7c + * 8jEyVupk+eq1nRZmQnLzf9OxMUP8pI4X8W0jq5Rm+K37DwhuJi1/FwcJsoz7UMCf + * lo3Ptv0AnVoUmr8CRPXBwp8iXqIPoeM= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02TR1\x180\x16\x06\x03U\x04\x07\x13\x0fGebze - Kocaeli1B0@\x06\x03U\x04\n\x139Turkiye Bilimsel ve Teknolojik Arastirma Kurumu - TUBITAK1-0+\x06\x03U\x04\x0b\x13$Kamu Sertifikasyon Merkezi - Kamu SM1604\x06\x03U\x04\x03\x13-TUBITAK Kamu SM SSL Kok Sertifikasi - Surum 1"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x01\x0f\x000\x82\x01\n\x02\x82\x01\x01\x00\xafu03\xaa\xbbk\xd3\x99,\x127\x84\xd9\x8d{\x97\x80\xd3n\xe7\xff\x9bP\x95>\x90\x95VB\xd7\x19|&\x84\x8d\x92\xfa\x01\x1d:\x0f\xe2d8\xb7\x8c\xbc\xe8\x88\xf9\x8b$\xab.\xa3\xf57\xe4@\x8e\x18%y\x83u\x1f;\xffl\xa8\xc5\xc6V\xf8\xb4\xed\x8aD\xa3\xablL\xfc\x1d\xd0\xdc\xefh\xbd\xcf\xe4\xaa\xce\xf0U\xf7\xa24\xd4\x83k7|\x1c\xc2\xfe\xb5\x03\xecW\xce\xbc\xb4\xb5\xc5\xed\x00\x0fS7*M\xf4O\x0c\x83\xfb\x86\xcf\xcb\xfe\x8cN\xbd\x87\xf9\xa7\x8b!W\x9cz\xdf\x03g\x89,\x9d\x97a\xa7\x10\xb8U\x90\x7f\x0e-\'8t\xdf\xe7\xfd\xdaN\x12\xe3M\x15\"\x02\xc8\xe0\xe0\xfc\x0f\xad\x8a\xd7\xc9TP\xcc;\x0f\xca\x16\x80\x84\xd0QV\xc3\x8eV\x7f\x89\"3/\xe6\x85\n\xbd\xa5\xa8\x1b6\xde\xd3\xdc,m;\xc7\x13\xbdY#,\xe6\xe5\xa4\xf7\xd8\x0b\xed\xea\x90@D\xa8\x95\xbb\x93\xd5\xd0\x804\xb6Fx\x0e\x1f\x00\x93F\xe1\xee\xe9\xf9\xecO\x17\x02\x03\x01\x00\x01"), + name_constraints: Some(Der::from_slice(b"\xa0\x070\x05\x82\x03.tr")) + }, + + /* + * Issuer: CN=D-TRUST Root Class 3 CA 2 2009 O=D-Trust GmbH + * Subject: CN=D-TRUST Root Class 3 CA 2 2009 O=D-Trust GmbH + * Label: "D-TRUST Root Class 3 CA 2 2009" + * Serial: 623603 + * SHA256 Fingerprint: 49:e7:a4:42:ac:f0:ea:62:87:05:00:54:b5:25:64:b6:50:e4:f4:9e:42:e3:48:d6:aa:38:e0:39:e9:57:b1:c1 + * -----BEGIN CERTIFICATE----- + * MIIEMzCCAxugAwIBAgIDCYPzMA0GCSqGSIb3DQEBCwUAME0xCzAJBgNVBAYTAkRF + * MRUwEwYDVQQKDAxELVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBD + * bGFzcyAzIENBIDIgMjAwOTAeFw0wOTExMDUwODM1NThaFw0yOTExMDUwODM1NTha + * ME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQKDAxELVRydXN0IEdtYkgxJzAlBgNVBAMM + * HkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTCCASIwDQYJKoZIhvcNAQEB + * BQADggEPADCCAQoCggEBANOySs96R+91myP6Oi/WUEWJNTrGa9v+2wBoqOADER03 + * UAifTUpolDWzU9GUY6cgVq/eUXjsKj3zSEhQPgrfRlWLJ23DEE0NkVJD2IfgXU42 + * tSHKXzlABF9bfsyjxiupQB7ZNoTWSPOSHjRGICTBpFGOShrvUD9pXRl/RcPHAY9R + * ySPocq60vFYJfxLLHLGvKZAKyVXMD9O0Gu1HNVpK7ZxzBCHQqr0ME7UAyiZsxGsM + * lFqVlNpQmvH/pStmMaTJOKDfHR+4CS7zp+hnUquVH+BGPtikw8paxTGA6Eian5Rp + * /hnd2HN8gcqW3o7tszIFZYQ05ub9VxC1X3a/L7AQDcUCAwEAAaOCARowggEWMA8G + * A1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFP3aFMSfMN4hvR5COfyrYyNJ4PGEMA4G + * A1UdDwEB/wQEAwIBBjCB0wYDVR0fBIHLMIHIMIGAoH6gfIZ6bGRhcDovL2RpcmVj + * dG9yeS5kLXRydXN0Lm5ldC9DTj1ELVRSVVNUJTIwUm9vdCUyMENsYXNzJTIwMyUy + * MENBJTIwMiUyMDIwMDksTz1ELVRydXN0JTIwR21iSCxDPURFP2NlcnRpZmljYXRl + * cmV2b2NhdGlvbmxpc3QwQ6BBoD+GPWh0dHA6Ly93d3cuZC10cnVzdC5uZXQvY3Js + * L2QtdHJ1c3Rfcm9vdF9jbGFzc18zX2NhXzJfMjAwOS5jcmwwDQYJKoZIhvcNAQEL + * BQADggEBAH+X2zDI36ScfSF6gHDOFBJpiBSVYEQBrLLpME+bUMJm2H6NMLVwMeni + * acfzcNsgFYbQDfC+rAF1hM5+n02/t2A7nPPKHeJeaNijnZflQGDSNiH+0LS4F9p0 + * o3/U37CYAqxva2ssJSRyoWXuJVrl5jLn8t+rSfrzkGkj2wTZ51xY/GXUl77M/C4K + * zCUqNQT4YJEVdT1B/yMfGchs64JTBKbkTCJNjYy6zltz7GRUUG3RnFX7acM2w4y8 + * PIWmawomDeCTmGCufsYkl4phX5GOZpIJhzbNi5stPvZR1FDUWSi9g/LMKHtThm3Y + * Johw1+qRzT65ysCQblrGXnRl11z+o+I= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02DE1\x150\x13\x06\x03U\x04\n\x0c\x0cD-Trust GmbH1\'0%\x06\x03U\x04\x03\x0c\x1eD-TRUST Root Class 3 CA 2 2009"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x01\x0f\x000\x82\x01\n\x02\x82\x01\x01\x00\xd3\xb2J\xcfzG\xefu\x9b#\xfa:/\xd6PE\x895:\xc6k\xdb\xfe\xdb\x00h\xa8\xe0\x03\x11\x1d7P\x08\x9fMJh\x945\xb3S\xd1\x94c\xa7 V\xaf\xdeQx\xec*=\xf3HHP>\n\xdfFU\x8b\'m\xc3\x10M\r\x91RC\xd8\x87\xe0]N6\xb5!\xca_9@\x04_[~\xcc\xa3\xc6+\xa9@\x1e\xd96\x84\xd6H\xf3\x92\x1e4F $\xc1\xa4Q\x8eJ\x1a\xefP?i]\x19\x7fE\xc3\xc7\x01\x8fQ\xc9#\xe8r\xae\xb4\xbcV\t\x7f\x12\xcb\x1c\xb1\xaf)\x90\n\xc9U\xcc\x0f\xd3\xb4\x1a\xedG5ZJ\xed\x9cs\x04!\xd0\xaa\xbd\x0c\x13\xb5\x00\xca&l\xc4k\x0c\x94Z\x95\x94\xdaP\x9a\xf1\xff\xa5+f1\xa4\xc98\xa0\xdf\x1d\x1f\xb8\t.\xf3\xa7\xe8gR\xab\x95\x1f\xe0F>\xd8\xa4\xc3\xcaZ\xc51\x80\xe8H\x9a\x9f\x94i\xfe\x19\xdd\xd8s|\x81\xca\x96\xde\x8e\xed\xb32\x05e\x844\xe6\xe6\xfdW\x10\xb5_v\xbf/\xb0\x10\r\xc5\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=SecureSign Root CA14 O=Cybertrust Japan Co., Ltd. + * Subject: CN=SecureSign Root CA14 O=Cybertrust Japan Co., Ltd. + * Label: "SecureSign Root CA14" + * Serial: 575790784512929437950770173562378038616896959179 + * SHA256 Fingerprint: 4b:00:9c:10:34:49:4f:9a:b5:6b:ba:3b:a1:d6:27:31:fc:4d:20:d8:95:5a:dc:ec:10:a9:25:60:72:61:e3:38 + * -----BEGIN CERTIFICATE----- + * MIIFcjCCA1qgAwIBAgIUZNtaDCBO6Ncpd8hQJ6JaJ90t8sswDQYJKoZIhvcNAQEM + * BQAwUTELMAkGA1UEBhMCSlAxIzAhBgNVBAoTGkN5YmVydHJ1c3QgSmFwYW4gQ28u + * LCBMdGQuMR0wGwYDVQQDExRTZWN1cmVTaWduIFJvb3QgQ0ExNDAeFw0yMDA0MDgw + * NzA2MTlaFw00NTA0MDgwNzA2MTlaMFExCzAJBgNVBAYTAkpQMSMwIQYDVQQKExpD + * eWJlcnRydXN0IEphcGFuIENvLiwgTHRkLjEdMBsGA1UEAxMUU2VjdXJlU2lnbiBS + * b290IENBMTQwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDF0nqh1oq/ + * FjHQmNE6lPxauG4iwWL3pwon71D2LrGeaBLwbCRjOfHw3xDG3rdSINVSW0KZnvOg + * vlIfX8xnbacuUKLBl422+JX1sLrcneC+y9/3OPJH9aaakpUqYllQC6KxNedlsmGy + * 6pJxaeQp8E+BgQQ8sqVb1MWoWWd7VRxJq3qdwudzTe/NCcLEVxLbAQ4jeQkHO6Lo + * /IrPj8BGJJw4J+CDnRugv3gVEOuGTgpa/d/aLIJ+7sr2KeH6caH3iGicnPCNvg9J + * kdjqOvn90Ghx2+m1K06Ckm9mH+Dw3EzsytHqunQG+bOEkJTRX45zGRBdAuVwpcAQ + * 0BB8b8VYSbSwbprafZX1zNoCr7gsfXmPvkPx+SgojQlD+Ajda8iLLCSxjVIHvXib + * y8posqTdDEx5YMaZ0ZPxMBoH064iwurO8YQJzOAUbn8/ftKChazcqRZOhaBgy/ac + * 18izju3Gm5h1DVXoX+WViwKkrkMpKBGk5hIwAUt1ax5mnXkvpXYvHUC0bcl9eQjs + * 0Wq2XSqypWa9a4X0dFbD9ed1Uigspf9mR6XU/v6eVL9lfgHWMI+lNpyiUBzuOIAB + * SMbHdPTGrMNASRZhdCyvjG817XsYAFs2PJxQDcqSMxDxJklt33UkN4Ii1+iW/RVL + * ApY+B3KVfqs9TC7XyvDf4Fg/LS8EmjijAQIDAQABo0IwQDAPBgNVHRMBAf8EBTAD + * AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUBpOjCl4oaTeqYR3r6/wtbyPk + * 86AwDQYJKoZIhvcNAQEMBQADggIBAJaAcgkGfpzMkwQWu6A6jZJOtxEaCnFxEM0E + * rX+lRVAQZk5KQaID2RFPeje5S+LGjzJmdSX7684/AykmjbgWHfYfM25I5uj4V7Ib + * ed87hwriZLoAymzvftAj63iP/2SbNDefNWWipAA9EiOWWF3KY4fGoweITedpdopT + * zfFP7ELyk+OZpDc8h7hi2/DsHzc/N19DzFGdtfCXwreFamgLRB7lUe6TzktuhsHS + * DCRZNhqfLJGP4xjblJUK7ZGqDpncllPjYYPGFrojutzdfhrGe0K22VoF3Jpf1d+4 + * 2kd92jjbrDnVHmtsKheMYc2xbXIBw8MgAGJoFjHVdqqGuw6qnsb58Nn4DSEC5MUo + * FlkRudlpcyqSeLiSV5sI8jrlL5WwWLdrIBRtFO8KvH7YVdiI2i/6GaX7i+B/OfVy + * K4XELKzvGUWSTLNhB9xNH27SgRNcmvMSZ4PPmz+Ln52kuaiWA3rF7iDeM9ovnhp6 + * dB7h7sxaOgTdsxoEqBRjrLdHEoOabPXm6RUVkRqEGQ6UROcSjiVbgGcZ3GOTEAtl + * Lor6CZpO2oYofaphNdgOpygau1LgePhsumywbrmHXumZNTfxPWQrqaA0k89jL9WB + * 365jJ6UeTo3cKXhZ+PmhIIynJkBugnLNeLLIjzwec+fBH7/PzqUqm9tEZDKgu39c + * JRNItX+S + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02JP1#0!\x06\x03U\x04\n\x13\x1aCybertrust Japan Co., Ltd.1\x1d0\x1b\x06\x03U\x04\x03\x13\x14SecureSign Root CA14"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xc5\xd2z\xa1\xd6\x8a\xbf\x161\xd0\x98\xd1:\x94\xfcZ\xb8n\"\xc1b\xf7\xa7\n\'\xefP\xf6.\xb1\x9eh\x12\xf0l$c9\xf1\xf0\xdf\x10\xc6\xde\xb7R \xd5R[B\x99\x9e\xf3\xa0\xbeR\x1f_\xccgm\xa7.P\xa2\xc1\x97\x8d\xb6\xf8\x95\xf5\xb0\xba\xdc\x9d\xe0\xbe\xcb\xdf\xf78\xf2G\xf5\xa6\x9a\x92\x95*bYP\x0b\xa2\xb15\xe7e\xb2a\xb2\xea\x92qi\xe4)\xf0O\x81\x81\x04<\xb2\xa5[\xd4\xc5\xa8Yg{U\x1cI\xabz\x9d\xc2\xe7sM\xef\xcd\t\xc2\xc4W\x12\xdb\x01\x0e#y\t\x07;\xa2\xe8\xfc\x8a\xcf\x8f\xc0F$\x9c8\'\xe0\x83\x9d\x1b\xa0\xbfx\x15\x10\xeb\x86N\nZ\xfd\xdf\xda,\x82~\xee\xca\xf6)\xe1\xfaq\xa1\xf7\x88h\x9c\x9c\xf0\x8d\xbe\x0fI\x91\xd8\xea:\xf9\xfd\xd0hq\xdb\xe9\xb5+N\x82\x92of\x1f\xe0\xf0\xdcL\xec\xca\xd1\xea\xbat\x06\xf9\xb3\x84\x90\x94\xd1_\x8es\x19\x10]\x02\xe5p\xa5\xc0\x10\xd0\x10|o\xc5XI\xb4\xb0n\x9a\xda}\x95\xf5\xcc\xda\x02\xaf\xb8,}y\x8f\xbeC\xf1\xf9((\x8d\tC\xf8\x08\xddk\xc8\x8b,$\xb1\x8dR\x07\xbdx\x9b\xcb\xcah\xb2\xa4\xdd\x0cLy`\xc6\x99\xd1\x93\xf10\x1a\x07\xd3\xae\"\xc2\xea\xce\xf1\x84\t\xcc\xe0\x14n\x7f?~\xd2\x82\x85\xac\xdc\xa9\x16N\x85\xa0`\xcb\xf6\x9c\xd7\xc8\xb3\x8e\xed\xc6\x9b\x98u\rU\xe8_\xe5\x95\x8b\x02\xa4\xaeC)(\x11\xa4\xe6\x120\x01Kuk\x1ef\x9dy/\xa5v/\x1d@\xb4m\xc9}y\x08\xec\xd1j\xb6]*\xb2\xa5f\xbdk\x85\xf4tV\xc3\xf5\xe7uR(,\xa5\xfffG\xa5\xd4\xfe\xfe\x9eT\xbfe~\x01\xd60\x8f\xa56\x9c\xa2P\x1c\xee8\x80\x01H\xc6\xc7t\xf4\xc6\xac\xc3@I\x16at,\xaf\x8co5\xed{\x18\x00[6<\x9cP\r\xca\x923\x10\xf1&Im\xdfu$7\x82\"\xd7\xe8\x96\xfd\x15K\x02\x96>\x07r\x95~\xab=L.\xd7\xca\xf0\xdf\xe0X?-/\x04\x9a8\xa3\x01\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=GlobalSign Root R46 O=GlobalSign nv-sa + * Subject: CN=GlobalSign Root R46 O=GlobalSign nv-sa + * Label: "GlobalSign Root R46" + * Serial: 1552617688466950547958867513931858518042577 + * SHA256 Fingerprint: 4f:a3:12:6d:8d:3a:11:d1:c4:85:5a:4f:80:7c:ba:d6:cf:91:9d:3a:5a:88:b0:3b:ea:2c:63:72:d9:3c:40:c9 + * -----BEGIN CERTIFICATE----- + * MIIFWjCCA0KgAwIBAgISEdK7udcjGJ5AXwqdLdDfJWfRMA0GCSqGSIb3DQEBDAUA + * MEYxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRwwGgYD + * VQQDExNHbG9iYWxTaWduIFJvb3QgUjQ2MB4XDTE5MDMyMDAwMDAwMFoXDTQ2MDMy + * MDAwMDAwMFowRjELMAkGA1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYt + * c2ExHDAaBgNVBAMTE0dsb2JhbFNpZ24gUm9vdCBSNDYwggIiMA0GCSqGSIb3DQEB + * AQUAA4ICDwAwggIKAoICAQCsrHQy6LNl5brtQyYdpokNRbopiLKkHWPd08EsCVeJ + * OaFV6Wc0dwxu5FUdUiXSE2te4R2pt32JMl8Nnp8semNgQB+msLZ4j5lUlghYruQG + * vGIFAha/r6gjA7aUD7xubMLL1aa7DOn2wQL7Id5m3RerdELv8HQvJfTqa1VbkNud + * 316HCkD7rRlr+/fKYIje2sGP1q7Vf9Q8g+7XFkyDRTNrJ9CG0Bwta/OrffGFqfUo + * 0q3v84RLHIf8E6M6cqJaESvWJ3En7YEtbWaBkoe0G1h6zD8K+kZPTXhc+CtI4wSE + * y132tGqzZfxCnlEmIyDLPRT5ge1lFgBPGmSXZgjPjHvjK8Cd+RTyG/FWaha/LIWF + * zXg4mutCagI0GIMXTpRW+LaCtfOW3T3zvn8gdz57GSNrLNRyc0NXfeD412lPFzYE + * +cCQYDdF3uYM2HSNrpyibXRdQr4G9dlkbgIQrImwTDsHTUB+JMWKmIJ5jqSngiCN + * I/onccnfxkF0oE32kRbcRoxfKWMxWXEM2G/CtjJ9++ZdU6Z+Ffy7dXxd7Pj2Fxzs + * x2sZy/N78CsHpdlseVR2bJ0cpm4O6XkMqCNqo98bMDGfsVR7/mrLZqrcZdCinkqa + * ByFrgY/bxFn63iLABJzjqls2k+g9vXqhnQt2sQvHnf3PmKgGwvgqo6GDoLclcqUC + * 4wIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNV + * HQ4EFgQUA1yrc4GHqMywptWU4jaWSf8FmSwwDQYJKoZIhvcNAQEMBQADggIBAHx4 + * 7PYCLLtbfpIrXTncvtgdokIzTfnvpCo7RGkerNlFo048p9gkUbJUHJNOxO97k4Vg + * JuoJSOD1u8fpaNK7ajFxzHmuEajwmf3lH7wvqMxX63bEIaZHU1VNaL8FpO7XJqti + * 2kM3S+LGteWygxk6x9PbTZ4IevPuzz5i+6zoYMzRx6Fcg0XERczzF2sUyQQCPtIk + * pnnpHs6i58FZFZ8d4kuaPp92CC1r2LpXFNqD6v6MVenQTqnMdzGxRBF6XLE+0xRF + * FRhiJBPSy03OXIPBNvIQtQ6IbbjhVp+J3pZmOUdkLG5NrmJ7v2B0GbhWrJKsFjLt + * rWhV/pi60zTe9Mlhww6G9kuEYO4Ne7UyWHmRVSyBQ7N0H3qqJZ4d16GLuc1CLgSk + * ZoNNiTW2bKg2SnkheCLQQrzRQDGQob4Ez8pn7fXwgNNgyYMqIgXQBztSvwyeqiv5 + * u+YfjyW6hY0XHgL+XVAEV8/+LbzvXMAaq7afJMbfc2hIkCwU9D9SGuTSyxTDYWnP + * 4vkYxboznxSjBF25cfe1lNj2M8FawTSLfJvdkzrnE6JwYZ+vj+vYxXX4M2bUdGc6 + * N3ec592kD3ZDZopD8p/7DEJ4Y9HiD2971KE9dJeFt0g5QdYg/NA6s/rob8SKunE3 + * vouXsXgxT7PntgMTzlSdriVZzH81Xwj3QEUxeCp6 + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02BE1\x190\x17\x06\x03U\x04\n\x13\x10GlobalSign nv-sa1\x1c0\x1a\x06\x03U\x04\x03\x13\x13GlobalSign Root R46"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xac\xact2\xe8\xb3e\xe5\xba\xedC&\x1d\xa6\x89\rE\xba)\x88\xb2\xa4\x1dc\xdd\xd3\xc1,\tW\x899\xa1U\xe9g4w\x0cn\xe4U\x1dR%\xd2\x13k^\xe1\x1d\xa9\xb7}\x892_\r\x9e\x9f,zc`@\x1f\xa6\xb0\xb6x\x8f\x99T\x96\x08X\xae\xe4\x06\xbcb\x05\x02\x16\xbf\xaf\xa8#\x03\xb6\x94\x0f\xbcnl\xc2\xcb\xd5\xa6\xbb\x0c\xe9\xf6\xc1\x02\xfb!\xdef\xdd\x17\xabtB\xef\xf0t/%\xf4\xeakU[\x90\xdb\x9d\xdf^\x87\n@\xfb\xad\x19k\xfb\xf7\xca`\x88\xde\xda\xc1\x8f\xd6\xae\xd5\x7f\xd4<\x83\xee\xd7\x16L\x83E3k\'\xd0\x86\xd0\x1c-k\xf3\xab}\xf1\x85\xa9\xf5(\xd2\xad\xef\xf3\x84K\x1c\x87\xfc\x13\xa3:r\xa2Z\x11+\xd6\'q\'\xed\x81-mf\x81\x92\x87\xb4\x1bXz\xcc?\n\xfaFOMx\\\xf8+H\xe3\x04\x84\xcb]\xf6\xb4j\xb3e\xfcB\x9eQ&# \xcb=\x14\xf9\x81\xede\x16\x00O\x1ad\x97f\x08\xcf\x8c{\xe3+\xc0\x9d\xf9\x14\xf2\x1b\xf1Vj\x16\xbf,\x85\x85\xcdx8\x9a\xebBj\x024\x18\x83\x17N\x94V\xf8\xb6\x82\xb5\xf3\x96\xdd=\xf3\xbe\x7f w>{\x19#k,\xd4rsCW}\xe0\xf8\xd7iO\x176\x04\xf9\xc0\x90`7E\xde\xe6\x0c\xd8t\x8d\xae\x9c\xa2mt]B\xbe\x06\xf5\xd9dn\x02\x10\xac\x89\xb0L;\x07M@~$\xc5\x8a\x98\x82y\x8e\xa4\xa7\x82 \x8d#\xfa\'q\xc9\xdf\xc6At\xa0M\xf6\x91\x16\xdcF\x8c_)c1Yq\x0c\xd8o\xc2\xb62}\xfb\xe6]S\xa6~\x15\xfc\xbbu|]\xec\xf8\xf6\x17\x1c\xec\xc7k\x19\xcb\xf3{\xf0+\x07\xa5\xd9lyTvl\x9d\x1c\xa6n\x0e\xe9y\x0c\xa8#j\xa3\xdf\x1b01\x9f\xb1T{\xfej\xcbf\xaa\xdce\xd0\xa2\x9eJ\x9a\x07!k\x81\x8f\xdb\xc4Y\xfa\xde\"\xc0\x04\x9c\xe3\xaa[6\x93\xe8=\xbdz\xa1\x9d\x0bv\xb1\x0b\xc7\x9d\xfd\xcf\x98\xa8\x06\xc2\xf8*\xa3\xa1\x83\xa0\xb7%r\xa5\x02\xe3\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=USERTrust ECC Certification Authority O=The USERTRUST Network + * Subject: CN=USERTrust ECC Certification Authority O=The USERTRUST Network + * Label: "USERTrust ECC Certification Authority" + * Serial: 123013823720199481456569720443997572134 + * SHA256 Fingerprint: 4f:f4:60:d5:4b:9c:86:da:bf:bc:fc:57:12:e0:40:0d:2b:ed:3f:bc:4d:4f:bd:aa:86:e0:6a:dc:d2:a9:ad:7a + * -----BEGIN CERTIFICATE----- + * MIICjzCCAhWgAwIBAgIQXIuZxVqUxdJxVt7NiYDMJjAKBggqhkjOPQQDAzCBiDEL + * MAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNl + * eSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMT + * JVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTAwMjAx + * MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMCVVMxEzARBgNVBAgT + * Ck5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVUaGUg + * VVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlm + * aWNhdGlvbiBBdXRob3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQarFRaqflo + * I+d61SRvU8Za2EurxtW20eZzca7dnNYMYf3boIkDuAUU7FfO7l0/4iGzzvfUinng + * o4N+LZfQYcTxmdwlkWOrfzCjtHDix6EznPO/LlxTsV+zfTJ/ijTjeXmjQjBAMB0G + * A1UdDgQWBBQ64QmG1M8ZwpZ2dEl23OA1xmNjmjAOBgNVHQ8BAf8EBAMCAQYwDwYD + * VR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjA2Z6EWCNzklwBBHU6+4WMB + * zzuqQhFkoJ2UOQIReVx7Hfpkue4WQrO/isIJxOzksU0CMQDpKmFHjFJKS04YcPbW + * RNZu9YO6bVi9JNlWSOrvxKJGgYhqOkbRqZtNyWHa0V1Xahg= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1\x130\x11\x06\x03U\x04\x08\x13\nNew Jersey1\x140\x12\x06\x03U\x04\x07\x13\x0bJersey City1\x1e0\x1c\x06\x03U\x04\n\x13\x15The USERTRUST Network1.0,\x06\x03U\x04\x03\x13%USERTrust ECC Certification Authority"), + subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\"\x03b\x00\x04\x1a\xacTZ\xa9\xf9h#\xe7z\xd5$oS\xc6Z\xd8K\xab\xc6\xd5\xb6\xd1\xe6sq\xae\xdd\x9c\xd6\x0ca\xfd\xdb\xa0\x89\x03\xb8\x05\x14\xecW\xce\xee]?\xe2!\xb3\xce\xf7\xd4\x8ay\xe0\xa3\x83~-\x97\xd0a\xc4\xf1\x99\xdc%\x91c\xab\x7f0\xa3\xb4p\xe2\xc7\xa13\x9c\xf3\xbf.\\S\xb1_\xb3}2\x7f\x8a4\xe3yy"), + name_constraints: None + }, + + /* + * Issuer: O=SECOM Trust Systems CO.,LTD. OU=Security Communication RootCA2 + * Subject: O=SECOM Trust Systems CO.,LTD. OU=Security Communication RootCA2 + * Label: "Security Communication RootCA2" + * Serial: 0 + * SHA256 Fingerprint: 51:3b:2c:ec:b8:10:d4:cd:e5:dd:85:39:1a:df:c6:c2:dd:60:d8:7b:b7:36:d2:b5:21:48:4a:a4:7a:0e:be:f6 + * -----BEGIN CERTIFICATE----- + * MIIDdzCCAl+gAwIBAgIBADANBgkqhkiG9w0BAQsFADBdMQswCQYDVQQGEwJKUDEl + * MCMGA1UEChMcU0VDT00gVHJ1c3QgU3lzdGVtcyBDTy4sTFRELjEnMCUGA1UECxMe + * U2VjdXJpdHkgQ29tbXVuaWNhdGlvbiBSb290Q0EyMB4XDTA5MDUyOTA1MDAzOVoX + * DTI5MDUyOTA1MDAzOVowXTELMAkGA1UEBhMCSlAxJTAjBgNVBAoTHFNFQ09NIFRy + * dXN0IFN5c3RlbXMgQ08uLExURC4xJzAlBgNVBAsTHlNlY3VyaXR5IENvbW11bmlj + * YXRpb24gUm9vdENBMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANAV + * OVKxUrO6xVmCxF1SrjpDZYBLx/KWvNs2l9amZIyoXvDjChz335c9S672XewhtUGr + * zbl+dp+++T42NKA7wfYxEUV0kz1XgMX5iZnK5atq1LXaQZAQwdbWQonCv/Q4EpVM + * VAX3NuRFg3sUZdbcDE3R3n4MqzvEFb46VqZab3ZpUql6ucjrappdUtAtCms1FgkQ + * hNBqyjoGADdH5H5XTz+L62e4iKrFvlNVspHEfbmwhRkGeC7bYRr6hfVKkaHnFtWO + * ojnflLhwHyg/i/xAXmODPIMqGplrz95Zajv8bxbXH/1KEOtOghY6rCcMU/Gt1SSw + * awNQwS08Ft1ENCcadfsCAwEAAaNCMEAwHQYDVR0OBBYEFAqFqXdlBZh8QIH4D5cs + * OPEK7DzPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3 + * DQEBCwUAA4IBAQBMOqNErLlFsceTfsgLCkLfZOoc7llsCLqJX2rKSpWeeo8HxdpF + * coJxDjrSzG+ntKEju/Ykn8sX/oymzsLS28yN/HH8AynBbF0zX2S2ZTuJbxh2ePXc + * okgfGT+Ok+vx+hfuzU7jBBJV1uXk3fs+BXziHV7Gp7yXT2g69ekuCkO2r1dcYmh8 + * t/2jioSgrGK+KwmHNPBqAbubKVY8/gA3zyNs8U6qtnRGEmyR7jTV7JqR50S+kDFy + * 1UkC9gLl9B/rfNmWVan/7Ir5mUf/NVoCqgTLiluHcSmRvaS0eg29mvVXIwAHIRc/ + * SjnRBUkLp7Y3gaVdjKozXoEofKd9J+sAro03 + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02JP1%0#\x06\x03U\x04\n\x13\x1cSECOM Trust Systems CO.,LTD.1\'0%\x06\x03U\x04\x0b\x13\x1eSecurity Communication RootCA2"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x01\x0f\x000\x82\x01\n\x02\x82\x01\x01\x00\xd0\x159R\xb1R\xb3\xba\xc5Y\x82\xc4]R\xae:Ce\x80K\xc7\xf2\x96\xbc\xdb6\x97\xd6\xa6d\x8c\xa8^\xf0\xe3\n\x1c\xf7\xdf\x97=K\xae\xf6]\xec!\xb5A\xab\xcd\xb9~v\x9f\xbe\xf9>64\xa0;\xc1\xf61\x11Et\x93=W\x80\xc5\xf9\x89\x99\xca\xe5\xabj\xd4\xb5\xdaA\x90\x10\xc1\xd6\xd6B\x89\xc2\xbf\xf48\x12\x95LT\x05\xf76\xe4E\x83{\x14e\xd6\xdc\x0cM\xd1\xde~\x0c\xab;\xc4\x15\xbe:V\xa6ZoviR\xa9z\xb9\xc8\xebj\x9a]R\xd0-\nk5\x16\t\x10\x84\xd0j\xca:\x06\x007G\xe4~WO?\x8b\xebg\xb8\x88\xaa\xc5\xbeSU\xb2\x91\xc4}\xb9\xb0\x85\x19\x06x.\xdba\x1a\xfa\x85\xf5J\x91\xa1\xe7\x16\xd5\x8e\xa29\xdf\x94\xb8p\x1f(?\x8b\xfc@^c\x83<\x83*\x1a\x99k\xcf\xdeYj;\xfco\x16\xd7\x1f\xfdJ\x10\xebN\x82\x16:\xac\'\x0cS\xf1\xad\xd5$\xb0k\x03P\xc1-<\x16\xddD4\'\x1au\xfb\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=COMODO RSA Certification Authority O=COMODO CA Limited + * Subject: CN=COMODO RSA Certification Authority O=COMODO CA Limited + * Label: "COMODO RSA Certification Authority" + * Serial: 101909084537582093308941363524873193117 + * SHA256 Fingerprint: 52:f0:e1:c4:e5:8e:c6:29:29:1b:60:31:7f:07:46:71:b8:5d:7e:a8:0d:5b:07:27:34:63:53:4b:32:b4:02:34 + * -----BEGIN CERTIFICATE----- + * MIIF2DCCA8CgAwIBAgIQTKr5yttjb+Af907YWwOGnTANBgkqhkiG9w0BAQwFADCB + * hTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G + * A1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNV + * BAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTAwMTE5 + * MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0IxGzAZBgNVBAgT + * EkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMR + * Q09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNh + * dGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCR + * 6FSS0gpWsawNJN3Fz0RndJkrN6N9I3AAcbxT38T6KhKPS38QVr2fcHK3YX/JSw8X + * pz3jsARh7v8Rl8f0hj4K+j5c+ZPmNHrZFGvnnLOFoIJ6dq9xkNfs/Q36nGz637CC + * 9BR++b7Epi9Pf5l/tfxnQ3K9DADWietrLNPtj5gcFKt+5eNu/Nio5JIk2kNrYrhV + * /erBvGy2i/MOjZrkm2xpmfh4SDBF1a3hDTxFYPwyllEnvGfDyi62a+pGx8cgoLEf + * Zd5ICLqkTqnyg0Y3hOvozIFIQ2dOciqbXL1MGyiKXCJ7tKuY2e7gUYPDCUZObT6Z + * +pUX2nwzV0E8jVHtC7ZcryxjGt9XyD+86V3Em69FmeKjWiS0uqlWPc9vqv9JWL7w + * qP/0uK3pN/u6uPQLOvnoQ0IeidiEyxPx2bvhiWC4jChWrBQdnArncevPDt09qZah + * SL0896+1DSJMwBGB7FY79tOi4lu3sgQiUpWAk2nojkxl8ZEDLXB0AuqLZxUpaVIC + * u9ffUGpVRr+goyhhf3DQw6KqLCGqR84onAZFdr+CGCe01a60y1Dma/RMhnEw6abf + * Fobg2P9A3fvQQoh/ozM6LlweQRGBY84YcWsr7KaKtzFcOmpH4MN5WdYgGq/yapiq + * crxXStJLnbsQ/LBMQeXtHT1eKJ2czL+zUdqnR+WEUwIDAQABo0IwQDAdBgNVHQ4E + * FgQUu69+Aj36pvE8hI6t7jiY7NkyMtQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB + * /wQFMAMBAf8wDQYJKoZIhvcNAQEMBQADggIBAArx1UaEt65Ru2yyTUEUAJNMnMvl + * wFTPoCWOAvn9sKIN9SCYPBMtrFaisNZ+EZLpLrqeLppysb0ZRGxhNaKatBYSaVqM + * 4dc+pBroLwP0rmEdEBsqpIt6xf4FpuHA1sj+nq6PK7o9mfjYcwlYRm6mnPTXJ9OV + * 2jeDchzTc+CiR5kDOF3VSXkAKRzH7JsgHAckaVd4sjn8OoSgtZx8jb8uk2Intzna + * FxiuvTwJaP+EmzzV1gsD41eeFPfR60/IvYcjt7ZJQ3mFXLrrkguhxuhoqEwWsRqZ + * CuhTLJK7oQkYdQxlqHvLI7cawiiFwxv/0Cti76R7CZGYZ4wUAc1oBmpjIXUDgIiK + * boHGhfKppC3n9KUkEEeDys30jXlYsQab5xoq2Z0B15R97QNKyvDb6KkBPvVWmcke + * jkk9u+UJueBPSZI9FoJAzMxZxuY67RIuaTxslbH9qh17f4a+Hg4yRvv7E491f0yL + * S0Zj/gA0QHDBw7mh3aZw4gSzQbzpgJHqZJx64SIDqZxubw5lT2yHh17zbqD5daWb + * QOhTsiedSrnAdyGN/4fy3ryM7xfft0kL0fJuMAsaDk527RH89elWsn2/x20Kk4yl + * 0MC2Hb46TpSi125sC8KKfPog88Tk5c0NqMuRkrF8hey1FGlmDoLnzc7ILaZRfyHB + * NVOFBkpdn627G190 + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02GB1\x1b0\x19\x06\x03U\x04\x08\x13\x12Greater Manchester1\x100\x0e\x06\x03U\x04\x07\x13\x07Salford1\x1a0\x18\x06\x03U\x04\n\x13\x11COMODO CA Limited1+0)\x06\x03U\x04\x03\x13\"COMODO RSA Certification Authority"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\x91\xe8T\x92\xd2\nV\xb1\xac\r$\xdd\xc5\xcfDgt\x99+7\xa3}#p\x00q\xbcS\xdf\xc4\xfa*\x12\x8fK\x7f\x10V\xbd\x9fpr\xb7a\x7f\xc9K\x0f\x17\xa7=\xe3\xb0\x04a\xee\xff\x11\x97\xc7\xf4\x86>\n\xfa>\\\xf9\x93\xe64z\xd9\x14k\xe7\x9c\xb3\x85\xa0\x82zv\xafq\x90\xd7\xec\xfd\r\xfa\x9cl\xfa\xdf\xb0\x82\xf4\x14~\xf9\xbe\xc4\xa6/O\x7f\x99\x7f\xb5\xfcgCr\xbd\x0c\x00\xd6\x89\xebk,\xd3\xed\x8f\x98\x1c\x14\xab~\xe5\xe3n\xfc\xd8\xa8\xe4\x92$\xdaCkb\xb8U\xfd\xea\xc1\xbcl\xb6\x8b\xf3\x0e\x8d\x9a\xe4\x9bli\x99\xf8xH0E\xd5\xad\xe1\r\x99\xfa\x95\x17\xda|3WA<\x8dQ\xed\x0b\xb6\\\xaf,c\x1a\xdfW\xc8?\xbc\xe9]\xc4\x9b\xafE\x99\xe2\xa3Z$\xb4\xba\xa9V=\xcfo\xaa\xffIX\xbe\xf0\xa8\xff\xf4\xb8\xad\xe97\xfb\xba\xb8\xf4\x0b:\xf9\xe8CB\x1e\x89\xd8\x84\xcb\x13\xf1\xd9\xbb\xe1\x89`\xb8\x8c(V\xac\x14\x1d\x9c\n\xe7q\xeb\xcf\x0e\xdd=\xa9\x96\xa1H\xbd<\xf7\xaf\xb5\r\"L\xc0\x11\x81\xecV;\xf6\xd3\xa2\xe2[\xb7\xb2\x04\"R\x95\x80\x93i\xe8\x8eLe\xf1\x91\x03-pt\x02\xea\x8bg\x15)iR\x02\xbb\xd7\xdfPjUF\xbf\xa0\xa3(a\x7fp\xd0\xc3\xa2\xaa,!\xaaG\xce(\x9c\x06Ev\xbf\x82\x18\'\xb4\xd5\xae\xb4\xcbP\xe6k\xf4L\x86q0\xe9\xa6\xdf\x16\x86\xe0\xd8\xff@\xdd\xfb\xd0B\x88\x7f\xa33:.\\\x1eA\x11\x81c\xce\x18qk+\xec\xa6\x8a\xb71\\:jG\xe0\xc3yY\xd6 \x1a\xaf\xf2j\x98\xaar\xbcWJ\xd2K\x9d\xbb\x10\xfc\xb0LA\xe5\xed\x1d=^(\x9d\x9c\xcc\xbf\xb3Q\xda\xa7G\xe5\x84S\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=DigiCert Trusted Root G4 O=DigiCert Inc OU=www.digicert.com + * Subject: CN=DigiCert Trusted Root G4 O=DigiCert Inc OU=www.digicert.com + * Label: "DigiCert Trusted Root G4" + * Serial: 7451500558977370777930084869016614236 + * SHA256 Fingerprint: 55:2f:7b:dc:f1:a7:af:9e:6c:e6:72:01:7f:4f:12:ab:f7:72:40:c7:8e:76:1a:c2:03:d1:d9:d2:0a:c8:99:88 + * -----BEGIN CERTIFICATE----- + * MIIFkDCCA3igAwIBAgIQBZsbV56OITLiOQe9p3d1XDANBgkqhkiG9w0BAQwFADBi + * MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 + * d3cuZGlnaWNlcnQuY29tMSEwHwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3Qg + * RzQwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1MTIwMDAwWjBiMQswCQYDVQQGEwJV + * UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQu + * Y29tMSEwHwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3QgRzQwggIiMA0GCSqG + * SIb3DQEBAQUAA4ICDwAwggIKAoICAQC/5pBzaN675F1KPDAiMGkz7MKnJS7JIT3y + * ithZwuEppz1Yq3aaza57G4QNxDAf8xukOBbrVsaXbR2rsnnyyhHS5F/WBTxSD1If + * xp4VpX6+n6lXFllVcq9ok3DCsrp1mWpzMpTREEQQLt+C8weE5nQ7bXHiLQwb7iDV + * ySAdYyktzuxeTsiT+CFhmzTrBcZe7FsavOvJz82sNEBfsXpm7nfISKhmV1efVFiO + * DCu3T6cw2Vbuyntd463JT17lNecxy9qTXtyOj4DatpGYQJB5w3jHtrHEtWoYOAMQ + * jdjUN6QuBX2I9YI+EJFwq1WCQTLX2wRzKm6RAXwhTNS8rhsDdV14Ztk6MUSaM0C/ + * CNdaSaTC5qmgZ92kJ7yhTzm1EVgX9yRcRo9k98FpiHaYdj1ZXUJ2h4mXaXpI8OCi + * EhtmmnTK3kse5w5jrubU75KSOp493ADkRSWJtppEGSt+wJS00mFt6zPZxd9LBADM + * fRyVw4/3IbKyEbe7f/LVjHAsQWCqsWMYRJUadmJ+9oCw++hkpjPRiQfhvbfmQ6QY + * uKZ3AeEPlAwhHbJUKSWJbOUOUlFHdL4mrLZBdd56rF+NP8m800ERElvlEFDrMcXK + * chYiCd98THU/Y+whX8QgUWtvsauGi0/C1kVfnSD8oR7FwI+isX4KJpn15GkvmB0t + * 9dmpsh3lGwIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIB + * hjAdBgNVHQ4EFgQU7NfjgtJxXWRM3y5nP+e6mK4cD08wDQYJKoZIhvcNAQEMBQAD + * ggIBALth2X2pbL4XxJEbw6GiAI3jZGgPVs93rnD5/ZpKmbnJeFwMDF/k5hQpVgs2 + * SV1EY+CtnJYYZhsjDT156W1r1lT40jzBQ0CuHVD1UvyQO7uYmWlrx8GnqGikJ9yd + * +SeuMIW59mdNOj6PWTkiU0TryF0Dyu1Qen1iIQqAyHNm0aAFYF/opbSnr6j3bTWc + * fFqK1qI4mfN4i/RN0iAL3gTujJtHgXINwBQy7zBZLq7gcfJW5GqXb5JQbZaNaHqa + * sjYUegbyJLkJEVDXCLG4iXqEI2FCKeWjzaIgQdfRnGTZ6iahixTXTBmyUEFxPT9N + * cCOGDErcgdLMMpSEDQgJlxxPwO5rIHQw0uA5NBCFIRUBCOhVMt5xSdkoF1BN5r5N + * 0XWs0Mr7QbhDparTwwVETyw2m+L64kW4I1NsBm9nVX9GtUw/bihaeSbSpKhil9Ie + * 4u1Ki7wb/UdKDd9nZn6yW0HQO+T0O/QEY+nvwlQAUaCKKsnOeMzV6ocEGLPOr0mI + * r/OSmbaz5mEP0oUA51Aa5BuVnRmhuZyxm7EAHu/QD09CbMkKvO5D+jpxpchNJqU1 + * /YldvIViHTLSoCtU7ZpXwdv6EM8Zt4tKG48BtieVU+i2iW1bvGjUI+iLUaJW+fCm + * gKDWHrO8Dw9TdSmq6hN35N6MgSGtBxBHEa2HPQfRdbzP82Z+ + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1\x150\x13\x06\x03U\x04\n\x13\x0cDigiCert Inc1\x190\x17\x06\x03U\x04\x0b\x13\x10www.digicert.com1!0\x1f\x06\x03U\x04\x03\x13\x18DigiCert Trusted Root G4"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xbf\xe6\x90sh\xde\xbb\xe4]J<0\"0i3\xec\xc2\xa7%.\xc9!=\xf2\x8a\xd8Y\xc2\xe1)\xa7=X\xabv\x9a\xcd\xae{\x1b\x84\r\xc40\x1f\xf3\x1b\xa48\x16\xebV\xc6\x97m\x1d\xab\xb2y\xf2\xca\x11\xd2\xe4_\xd6\x05\x10\x91p\xabU\x82A2\xd7\xdb\x04s*n\x91\x01|!L\xd4\xbc\xae\x1b\x03u]xf\xd9:1D\x9a3@\xbf\x08\xd7ZI\xa4\xc2\xe6\xa9\xa0g\xdd\xa4\'\xbc\xa1O9\xb5\x11X\x17\xf7$\\F\x8fd\xf7\xc1i\x88v\x98v=Y]Bv\x87\x89\x97izH\xf0\xe0\xa2\x12\x1bf\x9at\xca\xdeK\x1e\xe7\x0ec\xae\xe6\xd4\xef\x92\x92:\x9e=\xdc\x00\xe4E%\x89\xb6\x9aD\x19+~\xc0\x94\xb4\xd2am\xeb3\xd9\xc5\xdfK\x04\x00\xcc}\x1c\x95\xc3\x8f\xf7!\xb2\xb2\x11\xb7\xbb\x7f\xf2\xd5\x8cp,A`\xaa\xb1c\x18D\x95\x1avb~\xf6\x80\xb0\xfb\xe8d\xa63\xd1\x89\x07\xe1\xbd\xb7\xe6C\xa4\x18\xb8\xa6w\x01\xe1\x0f\x94\x0c!\x1d\xb2T)%\x89l\xe5\x0eRQGt\xbe&\xac\xb6Au\xdez\xac_\x8d?\xc9\xbc\xd3A\x11\x12[\xe5\x10P\xeb1\xc5\xcar\x16\"\t\xdf|Lu?c\xec!_\xc4 Qko\xb1\xab\x86\x8bO\xc2\xd6E_\x9d \xfc\xa1\x1e\xc5\xc0\x8f\xa2\xb1~\n&\x99\xf5\xe4i/\x98\x1d-\xf5\xd9\xa9\xb2\x1d\xe5\x1b\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=AC RAIZ FNMT-RCM SERVIDORES SEGUROS O=FNMT-RCM OU=Ceres + * Subject: CN=AC RAIZ FNMT-RCM SERVIDORES SEGUROS O=FNMT-RCM OU=Ceres + * Label: "AC RAIZ FNMT-RCM SERVIDORES SEGUROS" + * Serial: 131542671362353147877283741781055151509 + * SHA256 Fingerprint: 55:41:53:b1:3d:2c:f9:dd:b7:53:bf:be:1a:4e:0a:e0:8d:0a:a4:18:70:58:fe:60:a2:b8:62:b2:e4:b8:7b:cb + * -----BEGIN CERTIFICATE----- + * MIICbjCCAfOgAwIBAgIQYvYybOXE42hcG2LdnC6dlTAKBggqhkjOPQQDAzB4MQsw + * CQYDVQQGEwJFUzERMA8GA1UECgwIRk5NVC1SQ00xDjAMBgNVBAsMBUNlcmVzMRgw + * FgYDVQRhDA9WQVRFUy1RMjgyNjAwNEoxLDAqBgNVBAMMI0FDIFJBSVogRk5NVC1S + * Q00gU0VSVklET1JFUyBTRUdVUk9TMB4XDTE4MTIyMDA5MzczM1oXDTQzMTIyMDA5 + * MzczM1oweDELMAkGA1UEBhMCRVMxETAPBgNVBAoMCEZOTVQtUkNNMQ4wDAYDVQQL + * DAVDZXJlczEYMBYGA1UEYQwPVkFURVMtUTI4MjYwMDRKMSwwKgYDVQQDDCNBQyBS + * QUlaIEZOTVQtUkNNIFNFUlZJRE9SRVMgU0VHVVJPUzB2MBAGByqGSM49AgEGBSuB + * BAAiA2IABPa6V1PIyqvfNkpSIeSX0oNnnvBlUdBeh8dHsVnyV0ebAAKTRBdp20LH + * sbI6GA60XYyzZl2hNPk2LEnb80b8s0RpRBNm/dfF/a82Tc4DTQdxz69qBdKiQ1oK + * Um8BA06Oi6NCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYD + * VR0OBBYEFAG5L++/EYZg8k/QQW6rcx/n0m5JMAoGCCqGSM49BAMDA2kAMGYCMQCu + * SuMrQMN0EfKVrRYj3k4MGuZdpSRea0R7/DjiT8ucRRcRTBQnJlU5dUoDzBOQn5IC + * MQD6SmxgiHPz7riYYqnOK8LZiqZwMR2vsJRM60/G49HzYqc8/5MuB1xJAWdpEgJy + * v+c= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02ES1\x110\x0f\x06\x03U\x04\n\x0c\x08FNMT-RCM1\x0e0\x0c\x06\x03U\x04\x0b\x0c\x05Ceres1\x180\x16\x06\x03U\x04a\x0c\x0fVATES-Q2826004J1,0*\x06\x03U\x04\x03\x0c#AC RAIZ FNMT-RCM SERVIDORES SEGUROS"), + subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\"\x03b\x00\x04\xf6\xbaWS\xc8\xca\xab\xdf6JR!\xe4\x97\xd2\x83g\x9e\xf0eQ\xd0^\x87\xc7G\xb1Y\xf2WG\x9b\x00\x02\x93D\x17i\xdbB\xc7\xb1\xb2:\x18\x0e\xb4]\x8c\xb3f]\xa14\xf96,I\xdb\xf3F\xfc\xb3DiD\x13f\xfd\xd7\xc5\xfd\xaf6M\xce\x03M\x07q\xcf\xafj\x05\xd2\xa2CZ\nRo\x01\x03N\x8e\x8b"), + name_constraints: None + }, + + /* + * Issuer: CN=Actalis Authentication Root CA O=Actalis S.p.A./03358520967 + * Subject: CN=Actalis Authentication Root CA O=Actalis S.p.A./03358520967 + * Label: "Actalis Authentication Root CA" + * Serial: 6271844772424770508 + * SHA256 Fingerprint: 55:92:60:84:ec:96:3a:64:b9:6e:2a:be:01:ce:0b:a8:6a:64:fb:fe:bc:c7:aa:b5:af:c1:55:b3:7f:d7:60:66 + * -----BEGIN CERTIFICATE----- + * MIIFuzCCA6OgAwIBAgIIVwoRl0LE48wwDQYJKoZIhvcNAQELBQAwazELMAkGA1UE + * BhMCSVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8w + * MzM1ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290 + * IENBMB4XDTExMDkyMjExMjIwMloXDTMwMDkyMjExMjIwMlowazELMAkGA1UEBhMC + * SVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8wMzM1 + * ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290IENB + * MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAp8bEpSmkLO/lGMWwUKNv + * UTufClrJwkg4CsIcoBh/kbWHuUA/3R1oHwiD1S0eiKD4j1aPbZkCkpAW1V8IbInX + * 4ay8IMKx4INRimlNAJZaby/ARH6jDuSRzVju3PvHHkVH3Se5CAGfpiEd9UEtL0z9 + * KK3giq0itFZljoZUj5NDKd45RnijMCO6zfB9E1fAXdKDa0hMxKufgFpbOr3JpyI/ + * gCczWw63igxdBzcIy2zSekciRDXFzMwujt0q7bd9Zg1fYVEiVRvjRuPjPdA1Yprb + * rxTIW6HMiRvhMCb8oJsfgadHHwTrozmSBp+Z07/T6k9QnBn+locePGX2oxgkg4YQ + * 51Q+qDp2JE+BIcXjDwL4k5RHILv+1A7TaLndxHqEguNTVHnd25zS8gebLra8Pu2F + * be8lEfKXGkJh90qX6IuxEAf6ZYGyojnP9zz/GPvG8VqLWeICrHuS0E4UT1lF9gxe + * KF+w6D9Fz8+vm2/7hNN3WpVvrJSEnu68wEqPSpP4RCHiMUVhUE4Q2OM1fEwZtN4F + * v6MGn8i1zeQf1xcGDXqVdFUNaBr8EBtiZJ1t4JWgw5QHVw0U5r0F+7if5t+L4sbn + * fpb2U8WANFAoWPASUHEXMLrmeGO89LKtmyuy/uE5jF66CyCU3nuDuP/jVo23Eek7 + * jPKxwV2dpAtMK9myGPW1n0sCAwEAAaNjMGEwHQYDVR0OBBYEFFLYiDrIn3hm7Ynz + * ezhwlMkCAjbQMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUUtiIOsifeGbt + * ifN7OHCUyQICNtAwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBCwUAA4ICAQAL + * e3KHwGCmSUyIWOYdiPcUZEim2FgKDk8TNd81HdTtBjHIgT5q1d07GjLukD0R0i70 + * jsNjLiNmsGe+b7bAEzlgqqI0JZN1Ut6nna0Oh4lScWoWPBkdg/iaKWW+9D+a2fDz + * WochcYBNy+A4mz+7+uAwTc+G02UQGRjRlwKxK3JCaKygvU5a2hi/a5iB0P2avl4V + * SM0RFbnAKVy06Ij3Pjaut2L9HmLecHgQHEhb2rykOLpn7VU+Xlff1ANATIGk0k9j + * pwlCCRT8AKnCgHNPLsBA2RF7SOp6AsDT6ygBJlh0wcBzIm2Tlf05fbsq4/aC4yyX + * X04fkZT6/iyj2HYauE2yOE+b+h1IYHkm4vP9qdCa6HCPSXrW5b0KDtst842/6+Ok + * fcvHlXHo2qN8xcL4dJIEG4aspCJTQLas/kx2z/uUMsA1n3Y/buWQbqCmJqK4LL7R + * K4X9p2jIugErsWx0Hbhzlefut8cl8ABMALJ+tguLHPPAUJ4lueAI3jZm/zel0btU + * ZCzJJ7VLkn5l/9Mt4blOvH+kQSGQQXemOR/qnuOf0GZvBeyqdn6/axag67XH/JJU + * LysRJyU3eExRarDzzFhdFPFqSBX/wge2sY0PjlxQRrM9vwGYT7JZVEc+NHt4bVaT + * LnPqZih4zR0Uv6CPLy64Lo7yFIrM6bV8+2ydDKXhlg== + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02IT1\x0e0\x0c\x06\x03U\x04\x07\x0c\x05Milan1#0!\x06\x03U\x04\n\x0c\x1aActalis S.p.A./033585209671\'0%\x06\x03U\x04\x03\x0c\x1eActalis Authentication Root CA"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xa7\xc6\xc4\xa5)\xa4,\xef\xe5\x18\xc5\xb0P\xa3oQ;\x9f\nZ\xc9\xc2H8\n\xc2\x1c\xa0\x18\x7f\x91\xb5\x87\xb9@?\xdd\x1dh\x1f\x08\x83\xd5-\x1e\x88\xa0\xf8\x8fV\x8fm\x99\x02\x92\x90\x16\xd5_\x08l\x89\xd7\xe1\xac\xbc \xc2\xb1\xe0\x83Q\x8aiM\x00\x96Zo/\xc0D~\xa3\x0e\xe4\x91\xcdX\xee\xdc\xfb\xc7\x1eEG\xdd\'\xb9\x08\x01\x9f\xa6!\x1d\xf5A-/L\xfd(\xad\xe0\x8a\xad\"\xb4Ve\x8e\x86T\x8f\x93C)\xde9Fx\xa30#\xba\xcd\xf0}\x13W\xc0]\xd2\x83kHL\xc4\xab\x9f\x80Z[:\xbd\xc9\xa7\"?\x80\'3[\x0e\xb7\x8a\x0c]\x077\x08\xcbl\xd2zG\"D5\xc5\xcc\xcc.\x8e\xdd*\xed\xb7}f\r_aQ\"U\x1b\xe3F\xe3\xe3=\xd05b\x9a\xdb\xaf\x14\xc8[\xa1\xcc\x89\x1b\xe10&\xfc\xa0\x9b\x1f\x81\xa7G\x1f\x04\xeb\xa39\x92\x06\x9f\x99\xd3\xbf\xd3\xeaOP\x9c\x19\xfe\x96\x87\x1e\xa8:v$O\x81!\xc5\xe3\x0f\x02\xf8\x93\x94G \xbb\xfe\xd4\x0e\xd3h\xb9\xdd\xc4z\x84\x82\xe3STy\xdd\xdb\x9c\xd2\xf2\x07\x9b.\xb6\xbc>\xed\x85m\xef%\x11\xf2\x97\x1aBa\xf7J\x97\xe8\x8b\xb1\x10\x07\xfae\x81\xb2\xa29\xcf\xf7<\xff\x18\xfb\xc6\xf1Z\x8bY\xe2\x02\xac{\x92\xd0N\x14OYE\xf6\x0c^(_\xb0\xe8?E\xcf\xcf\xaf\x9bo\xfb\x84\xd3wZ\x95o\xac\x94\x84\x9e\xee\xbc\xc0J\x8fJ\x93\xf8D!\xe21EaPN\x10\xd8\xe35|L\x19\xb4\xde\x05\xbf\xa3\x06\x9f\xc8\xb5\xcd\xe4\x1f\xd7\x17\x06\rz\x95tU\rh\x1a\xfc\x10\x1bbd\x9dm\xe0\x95\xa0\xc3\x94\x07W\r\x14\xe6\xbd\x05\xfb\xb8\x9f\xe6\xdf\x8b\xe2\xc6\xe7~\x96\xf6S\xc5\x804P(X\xf0\x12Pq\x170\xba\xe6xc\xbc\xf4\xb2\xad\x9b+\xb2\xfe\xe19\x8c^\xba\x0b \x94\xde{\x83\xb8\xff\xe3V\x8d\xb7\x11\xe9;\x8c\xf2\xb1\xc1]\x9d\xa4\x0bL+\xd9\xb2\x18\xf5\xb5\x9fK\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=Starfield Services Root Certificate Authority - G2 O=Starfield Technologies, Inc. + * Subject: CN=Starfield Services Root Certificate Authority - G2 O=Starfield Technologies, Inc. + * Label: "Starfield Services Root Certificate Authority - G2" + * Serial: 0 + * SHA256 Fingerprint: 56:8d:69:05:a2:c8:87:08:a4:b3:02:51:90:ed:cf:ed:b1:97:4a:60:6a:13:c6:e5:29:0f:cb:2a:e6:3e:da:b5 + * -----BEGIN CERTIFICATE----- + * MIID7zCCAtegAwIBAgIBADANBgkqhkiG9w0BAQsFADCBmDELMAkGA1UEBhMCVVMx + * EDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoT + * HFN0YXJmaWVsZCBUZWNobm9sb2dpZXMsIEluYy4xOzA5BgNVBAMTMlN0YXJmaWVs + * ZCBTZXJ2aWNlcyBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5 + * MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgZgxCzAJBgNVBAYTAlVTMRAwDgYD + * VQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFy + * ZmllbGQgVGVjaG5vbG9naWVzLCBJbmMuMTswOQYDVQQDEzJTdGFyZmllbGQgU2Vy + * dmljZXMgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZI + * hvcNAQEBBQADggEPADCCAQoCggEBANUMOsQq+U7i9b4Zl1+OiFOxHz/Lz58gE20p + * OsgPfTz3a3Y4Y9k2YKibXlwAgLIvWX/2h/klQ4bnaRtSmpDhcePYLQ1Ob/bISdm2 + * 8xpWriu2dBTrz/sm4xq6HZYuajtYlIlHVv8loJNwU4PahHQUw2eeBGg6345AWh1K + * Ts9DkTvnVtYAcMtS7nt9rjrnvDH5RfbCYM8TWQIrgMw0R9+53pBlbQLPLJGmpufe + * hRhJfGZOozptqbXuNC66DQO4M99H67FrjSXZm86B0UVGMpZwh94CDklDhbZsc7tk + * 6mFBrMnUVN+HL8cisibMn1lUaJ/8viovxFUcdUBgF4UCVTmLfwUCAwEAAaNCMEAw + * DwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJxfAN+q + * AdcwKziIorhtSpzyEZGDMA0GCSqGSIb3DQEBCwUAA4IBAQBLNqaEd2ndOxmfZyMI + * bw5hyf2E3F/YNoHN2BtBLZ9g3ccaaNnRbobhiCPPE95Dz+I0swSdHynVv/heyNXB + * ve6SbzJ08pGCL72CQnqtKrcgfU28elUSwhXqvfdqlS5sdJ/PHLTyxQGjhdByPq1z + * qwubdQxtRbeOlKyWN7Wg0I8VRw7j6IPdj/3vQQF3zCepYoUz8jcI73HPdwbeyBkd + * iEDPfUYd/x7H4c7/I9vG+o1VTqkC50cRRj70/b17KSa7qWFiNyi2LSr2EIZkyXCn + * 0q23KXB56jzaYyWf/Wi3MOxw+3WKt21gZ7IeyLnp2KhvAotnDU0mV3HaIPzBSlCN + * sSi6 + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1\x100\x0e\x06\x03U\x04\x08\x13\x07Arizona1\x130\x11\x06\x03U\x04\x07\x13\nScottsdale1%0#\x06\x03U\x04\n\x13\x1cStarfield Technologies, Inc.1;09\x06\x03U\x04\x03\x132Starfield Services Root Certificate Authority - G2"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x01\x0f\x000\x82\x01\n\x02\x82\x01\x01\x00\xd5\x0c:\xc4*\xf9N\xe2\xf5\xbe\x19\x97_\x8e\x88S\xb1\x1f?\xcb\xcf\x9f \x13m):\xc8\x0f}<\xf7kv8c\xd96`\xa8\x9b^\\\x00\x80\xb2/Y\x7f\xf6\x87\xf9%C\x86\xe7i\x1bR\x9a\x90\xe1q\xe3\xd8-\rNo\xf6\xc8I\xd9\xb6\xf3\x1aV\xae+\xb6t\x14\xeb\xcf\xfb&\xe3\x1a\xba\x1d\x96.j;X\x94\x89GV\xff%\xa0\x93pS\x83\xda\x84t\x14\xc3g\x9e\x04h:\xdf\x8e@Z\x1dJN\xcfC\x91;\xe7V\xd6\x00p\xcbR\xee{}\xae:\xe7\xbc1\xf9E\xf6\xc2`\xcf\x13Y\x02+\x80\xcc4G\xdf\xb9\xde\x90em\x02\xcf,\x91\xa6\xa6\xe7\xde\x85\x18I|fN\xa3:m\xa9\xb5\xee4.\xba\r\x03\xb83\xdfG\xeb\xb1k\x8d%\xd9\x9b\xce\x81\xd1EF2\x96p\x87\xde\x02\x0eIC\x85\xb6ls\xbbd\xeaaA\xac\xc9\xd4T\xdf\x87/\xc7\"\xb2&\xcc\x9fYTh\x9f\xfc\xbe*/\xc4U\x1cu@`\x17\x85\x02U9\x8b\x7f\x05\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=BJCA Global Root CA2 O=BEIJING CERTIFICATE AUTHORITY + * Subject: CN=BJCA Global Root CA2 O=BEIJING CERTIFICATE AUTHORITY + * Label: "BJCA Global Root CA2" + * Serial: 58605626836079930195615843123109055211 + * SHA256 Fingerprint: 57:4d:f6:93:1e:27:80:39:66:7b:72:0a:fd:c1:60:0f:c2:7e:b6:6d:d3:09:29:79:fb:73:85:64:87:21:28:82 + * -----BEGIN CERTIFICATE----- + * MIICJTCCAaugAwIBAgIQLBcIfWQqwP6FGFkGz7RK6zAKBggqhkjOPQQDAzBUMQsw + * CQYDVQQGEwJDTjEmMCQGA1UECgwdQkVJSklORyBDRVJUSUZJQ0FURSBBVVRIT1JJ + * VFkxHTAbBgNVBAMMFEJKQ0EgR2xvYmFsIFJvb3QgQ0EyMB4XDTE5MTIxOTAzMTgy + * MVoXDTQ0MTIxMjAzMTgyMVowVDELMAkGA1UEBhMCQ04xJjAkBgNVBAoMHUJFSUpJ + * TkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZMR0wGwYDVQQDDBRCSkNBIEdsb2JhbCBS + * b290IENBMjB2MBAGByqGSM49AgEGBSuBBAAiA2IABJ3LgJGNU2e1uVCxA/jlSR9B + * IgmwUVJY1is0j8USRhTFiy8shP8sbqjV8QnjAyEUxEM9fMEsxEtqSs3ph+B99iK+ + * +kpRuDCK/eHeGBIK9ke35xe/J4rUQUyWPGCWwf0VHKNCMEAwHQYDVR0OBBYEFNJK + * sVF/BvDRgh9Obl+rg/xI1LCRMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQD + * AgEGMAoGCCqGSM49BAMDA2gAMGUCMBq8W9f+qdJUDkpd0m2xQNz0Q9XSSpkZElaA + * 94M04TVOSG0ED1cxMDAtsaqdAzjbBgIxAMvMh1PLet8gUXOQwKhbYdDFUDn9hf7B + * 43j4ptZLvZuHjw/l1lOWqzzIQNph91Oj9w== + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02CN1&0$\x06\x03U\x04\n\x0c\x1dBEIJING CERTIFICATE AUTHORITY1\x1d0\x1b\x06\x03U\x04\x03\x0c\x14BJCA Global Root CA2"), + subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\"\x03b\x00\x04\x9d\xcb\x80\x91\x8dSg\xb5\xb9P\xb1\x03\xf8\xe5I\x1fA\"\t\xb0QRX\xd6+4\x8f\xc5\x12F\x14\xc5\x8b/,\x84\xff,n\xa8\xd5\xf1\t\xe3\x03!\x14\xc4C=|\xc1,\xc4KjJ\xcd\xe9\x87\xe0}\xf6\"\xbe\xfaJQ\xb80\x8a\xfd\xe1\xde\x18\x12\n\xf6G\xb7\xe7\x17\xbf\'\x8a\xd4AL\x96<`\x96\xc1\xfd\x15\x1c"), + name_constraints: None + }, + + /* + * Issuer: CN=Telekom Security TLS ECC Root 2020 O=Deutsche Telekom Security GmbH + * Subject: CN=Telekom Security TLS ECC Root 2020 O=Deutsche Telekom Security GmbH + * Label: "Telekom Security TLS ECC Root 2020" + * Serial: 72082518505882327255703894282316633856 + * SHA256 Fingerprint: 57:8a:f4:de:d0:85:3f:4e:59:98:db:4a:ea:f9:cb:ea:8d:94:5f:60:b6:20:a3:8d:1a:3c:13:b2:bc:7b:a8:e1 + * -----BEGIN CERTIFICATE----- + * MIICQjCCAcmgAwIBAgIQNjqWjMlcsljN0AFdxeVXADAKBggqhkjOPQQDAzBjMQsw + * CQYDVQQGEwJERTEnMCUGA1UECgweRGV1dHNjaGUgVGVsZWtvbSBTZWN1cml0eSBH + * bWJIMSswKQYDVQQDDCJUZWxla29tIFNlY3VyaXR5IFRMUyBFQ0MgUm9vdCAyMDIw + * MB4XDTIwMDgyNTA3NDgyMFoXDTQ1MDgyNTIzNTk1OVowYzELMAkGA1UEBhMCREUx + * JzAlBgNVBAoMHkRldXRzY2hlIFRlbGVrb20gU2VjdXJpdHkgR21iSDErMCkGA1UE + * AwwiVGVsZWtvbSBTZWN1cml0eSBUTFMgRUNDIFJvb3QgMjAyMDB2MBAGByqGSM49 + * AgEGBSuBBAAiA2IABM6//leov9Wq9xCazbzREaK9Z0LMkOsVGJDZos0MKiXrPk/O + * tdKPD/M12kOLAoC+b1EkHQ9rK8qfwm9QMuU3ILYg/4gND21Ju9sGpIeQkpT0CdDP + * f8iAC8GXs7s1J8nCG6NCMEAwHQYDVR0OBBYEFONyzG6VmUex5rNhTNHLq+O6zd6f + * MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMAoGCCqGSM49BAMDA2cA + * MGQCMHVSi7ekEE+uShCLsoRbQuHmKjYC2qBuGT8lv9pZMo7k+5Dck2TOrbRBR2Di + * z6fLHgIwN0GMZt9Ba9aDAEH9L1r3ULRn0SyocddDypwnJJGDSA3PzfdUga/sf+Rn + * 27iQ7t0l + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02DE1\'0%\x06\x03U\x04\n\x0c\x1eDeutsche Telekom Security GmbH1+0)\x06\x03U\x04\x03\x0c\"Telekom Security TLS ECC Root 2020"), + subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\"\x03b\x00\x04\xce\xbf\xfeW\xa8\xbf\xd5\xaa\xf7\x10\x9a\xcd\xbc\xd1\x11\xa2\xbdgB\xcc\x90\xeb\x15\x18\x90\xd9\xa2\xcd\x0c*%\xeb>O\xce\xb5\xd2\x8f\x0f\xf35\xdaC\x8b\x02\x80\xbeoQ$\x1d\x0fk+\xca\x9f\xc2oP2\xe57 \xb6 \xff\x88\r\x0fmI\xbb\xdb\x06\xa4\x87\x90\x92\x94\xf4\t\xd0\xcf\x7f\xc8\x80\x0b\xc1\x97\xb3\xbb5\'\xc9\xc2\x1b"), + name_constraints: None + }, + + /* + * Issuer: CN=Autoridad de Certificacion Firmaprofesional CIF A62634068 + * Subject: CN=Autoridad de Certificacion Firmaprofesional CIF A62634068 + * Label: "Autoridad de Certificacion Firmaprofesional CIF A62634068" + * Serial: 1977337328857672817 + * SHA256 Fingerprint: 57:de:05:83:ef:d2:b2:6e:03:61:da:99:da:9d:f4:64:8d:ef:7e:e8:44:1c:3b:72:8a:fa:9b:cd:e0:f9:b2:6a + * -----BEGIN CERTIFICATE----- + * MIIGFDCCA/ygAwIBAgIIG3Dp0v+ubHEwDQYJKoZIhvcNAQELBQAwUTELMAkGA1UE + * BhMCRVMxQjBABgNVBAMMOUF1dG9yaWRhZCBkZSBDZXJ0aWZpY2FjaW9uIEZpcm1h + * cHJvZmVzaW9uYWwgQ0lGIEE2MjYzNDA2ODAeFw0xNDA5MjMxNTIyMDdaFw0zNjA1 + * MDUxNTIyMDdaMFExCzAJBgNVBAYTAkVTMUIwQAYDVQQDDDlBdXRvcmlkYWQgZGUg + * Q2VydGlmaWNhY2lvbiBGaXJtYXByb2Zlc2lvbmFsIENJRiBBNjI2MzQwNjgwggIi + * MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKlmuO6vj78aI14H9M2uDDUtd9 + * thDIAl6zQyrET2qyyhxdKJp4ERppWVevtSBC5IsP5t9bpgOSL/UR5GLXMnE42QQM + * cas9UX4PB99jBVzpv5RvwSmCwLTaUbDBPLutN0pcyvFLNg4kq7/DhHf9qFD0sefG + * L9ItWY16Ck6WaVICqjaY7Pz6FIMMNx/Jkjd/14Et5cS54D40/mf0PmbR0/RAz15i + * NA9wBj4gGFrO93IbJWyTdBSTo3OxDqqHECNZXyAFGUftaI6SEspd/NYrspI8IM/h + * X68gvqB2f3bl7BqGYTM+53u0P6APjqK5am+5hyZvQWyIplD9amML9ZMWGxmPsu2b + * m8mQ9QEM3xk9Dz44I8kvjwzRAv4bVdZO0I08r0+k8/6vKtMFnXkIoctXMbScyJCy + * Z/QYFpM6/EfY0XiWMR+6KwxfXZmtY4laJCB22N/9q06mIqqdXuYnin1oKaPnirja + * EbsXLZmdEyRG98Xi2J+Of8ePdG1asuhy9azuJBCtLxTa/y2aRnFHvkLfuwHb9H/T + * KI8xWVvTyQKmtFLKbpf7Q8UIJm+K9Lv9nyiqDdVF8xM6HdjAeI9BZzwelGSuewvF + * 6NkBiDkal4ZkQdU7hwxu+g/GvUgUvzlN1J5Bto+WHWOWk9mVBngxaJ43BjuAiUVh + * OSPHG0SjFeUc+JIwuwIDAQABo4HvMIHsMB0GA1UdDgQWBBRlzeurNR4APn7VdMAc + * tHNHDhpkLzASBgNVHRMBAf8ECDAGAQH/AgEBMIGmBgNVHSAEgZ4wgZswgZgGBFUd + * IAAwgY8wLwYIKwYBBQUHAgEWI2h0dHA6Ly93d3cuZmlybWFwcm9mZXNpb25hbC5j + * b20vY3BzMFwGCCsGAQUFBwICMFAeTgBQAGEAcwBlAG8AIABkAGUAIABsAGEAIABC + * AG8AbgBhAG4AbwB2AGEAIAA0ADcAIABCAGEAcgBjAGUAbABvAG4AYQAgADAAOAAw + * ADEANzAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZIhvcNAQELBQADggIBAHSHKAIrdx9m + * iWTtj3QuRhy7qPj4Cx2Dtjqn6EWKB7fgPiDL4QjbEwj4KKE1soCzC1HA01aajTNF + * Sa9J8OA9B3pFE1r/yJfY0xgsfZb43aJlQ3CTkBW6kN/oGbDbLIpgD7dvlAceHabJ + * hfa9NPhAeGIQcDq+fUs5gakQ1JZBu/hfHAsdCPKxsIl68veg4MSPi3i1O1ilI45P + * Vf42O+AMt8oqMEEgtIDNrvx2ZnOorm7hfNoD6JQg5iKj0B+QXSBTFCZX2lSX3xZE + * EAEeiGaPcjiT3SC3NL7X8e5jjkd5KAb881lFJWAiMxujX6i6KtoaPc1A6ozuBRWV + * 1aUsIC+nmCjuRfzxuIgALI9C2lHVnOUTaHFFQ4ueCyE8S1wF3BqfmI7avSKecs2t + * CsvMo2ebKHTEm9caPARYpoKdrcd7b/+Alun4jWq9GJAd/0kakFI3ky88Al2CdgtR + * 5xbHV/g4+afNmyJU72OwFW1TZQNKXkqgsqeOSQBZONXH9IBk9W6VULgRfhVwOEqw + * f9DEMnDAGf/JOC0ULGb0QkTmVXYbgBVX/8Cnp6o5qtjTcNAuuuuUavpfNIbnYrX9 + * ivAwhZTJryQCL2/W3Wf+47BVTwSYT6RBVuKT0Gro1vP7ZeDOdcQxWQzugsgMYDNK + * GbqEZycPvEJdvSRUDewdcAZfpLz6IHxV + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02ES1B0@\x06\x03U\x04\x03\x0c9Autoridad de Certificacion Firmaprofesional CIF A62634068"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xca\x96k\x8e\xea\xf8\xfb\xf1\xa25\xe0\x7fL\xda\xe0\xc3R\xd7}\xb6\x10\xc8\x02^\xb3C*\xc4Oj\xb2\xca\x1c](\x9ax\x11\x1aiYW\xaf\xb5 B\xe4\x8b\x0f\xe6\xdf[\xa6\x03\x92/\xf5\x11\xe4b\xd72q8\xd9\x04\x0cq\xab=Q~\x0f\x07\xdfc\x05\\\xe9\xbf\x94o\xc1)\x82\xc0\xb4\xdaQ\xb0\xc1<\xbb\xad7J\\\xca\xf1K6\x0e$\xab\xbf\xc3\x84w\xfd\xa8P\xf4\xb1\xe7\xc6/\xd2-Y\x8dz\nN\x96iR\x02\xaa6\x98\xec\xfc\xfa\x14\x83\x0c7\x1f\xc9\x927\x7f\xd7\x81-\xe5\xc4\xb9\xe0>4\xfeg\xf4>f\xd1\xd3\xf4@\xcf^b4\x0fp\x06> \x18Z\xce\xf7r\x1b%l\x93t\x14\x93\xa3s\xb1\x0e\xaa\x87\x10#Y_ \x05\x19G\xedh\x8e\x92\x12\xca]\xfc\xd6+\xb2\x92< \xcf\xe1_\xaf \xbe\xa0v\x7fv\xe5\xec\x1a\x86a3>\xe7{\xb4?\xa0\x0f\x8e\xa2\xb9jo\xb9\x87&oAl\x88\xa6P\xfdjc\x0b\xf5\x93\x16\x1b\x19\x8f\xb2\xed\x9b\x9b\xc9\x90\xf5\x01\x0c\xdf\x19=\x0f>8#\xc9/\x8f\x0c\xd1\x02\xfe\x1bU\xd6N\xd0\x8d<\xafO\xa4\xf3\xfe\xaf*\xd3\x05\x9dy\x08\xa1\xcbW1\xb4\x9c\xc8\x90\xb2g\xf4\x18\x16\x93:\xfcG\xd8\xd1x\x961\x1f\xba+\x0c_]\x99\xadc\x89Z$ v\xd8\xdf\xfd\xabN\xa6\"\xaa\x9d^\xe6\'\x8a}h)\xa3\xe7\x8a\xb8\xda\x11\xbb\x17-\x99\x9d\x13$F\xf7\xc5\xe2\xd8\x9f\x8e\x7f\xc7\x8ftmZ\xb2\xe8r\xf5\xac\xee$\x10\xad/\x14\xda\xff-\x9aFqG\xbeB\xdf\xbb\x01\xdb\xf4\x7f\xd3(\x8f1Y[\xd3\xc9\x02\xa6\xb4R\xcan\x97\xfbC\xc5\x08&o\x8a\xf4\xbb\xfd\x9f(\xaa\r\xd5E\xf3\x13:\x1d\xd8\xc0x\x8fAg<\x1e\x94d\xae{\x0b\xc5\xe8\xd9\x01\x889\x1a\x97\x86dA\xd5;\x87\x0cn\xfa\x0f\xc6\xbdH\x14\xbf9M\xd4\x9eA\xb6\x8f\x96\x1dc\x96\x93\xd9\x95\x06x1h\x9e7\x06;\x80\x89Ea9#\xc7\x1bD\xa3\x15\xe5\x1c\xf8\x920\xbb\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=TWCA Global Root CA O=TAIWAN-CA OU=Root CA + * Subject: CN=TWCA Global Root CA O=TAIWAN-CA OU=Root CA + * Label: "TWCA Global Root CA" + * Serial: 3262 + * SHA256 Fingerprint: 59:76:90:07:f7:68:5d:0f:cd:50:87:2f:9f:95:d5:75:5a:5b:2b:45:7d:81:f3:69:2b:61:0a:98:67:2f:0e:1b + * -----BEGIN CERTIFICATE----- + * MIIFQTCCAymgAwIBAgICDL4wDQYJKoZIhvcNAQELBQAwUTELMAkGA1UEBhMCVFcx + * EjAQBgNVBAoTCVRBSVdBTi1DQTEQMA4GA1UECxMHUm9vdCBDQTEcMBoGA1UEAxMT + * VFdDQSBHbG9iYWwgUm9vdCBDQTAeFw0xMjA2MjcwNjI4MzNaFw0zMDEyMzExNTU5 + * NTlaMFExCzAJBgNVBAYTAlRXMRIwEAYDVQQKEwlUQUlXQU4tQ0ExEDAOBgNVBAsT + * B1Jvb3QgQ0ExHDAaBgNVBAMTE1RXQ0EgR2xvYmFsIFJvb3QgQ0EwggIiMA0GCSqG + * SIb3DQEBAQUAA4ICDwAwggIKAoICAQCwBdvI64zEbooh745NnHEKH1Jw7W2CnJfF + * 10xORUnLQEK1EjRsGcJ0pDFfhQKX7EMzClPSnIyOt7h52yvVavKOZsTuKwEHktSz + * 0ALfUPZVr2YOy+BHYC8rMjk1Ujoog/h7FsYYuGLWRyWRzvAZEk2tY/XTP3VfKfCh + * MBwqoJimFb3u/Rk28OKRQ4/6ytYQJ0lM793B8YVwm8rqqFpD/G2Gb3PpN0Wp8DbH + * zIh1HrtsBv+baz4X7GGqcXzGHaL3SekVtTzWoWH1EfcFbx39Eb7QMAfCKbAJTibc + * 46KokWofwpFFiFzlmLhxpRUZyXx1EcxwdE8tmx2RRP1WKKD+u4ZqyPpcC1jcxkt2 + * yKsi2XMPpfRaAok/T54igu6idFMqPVMnaR1sjjIsZAAmY2E2TqNGtz99sy2sbZCi + * laLOz9qC5wc0GZbpuCGqKX6mOL6OKUohZnkfs8O1CWfe1tQHRvMq2uYiN2DLgbYP + * oA/pyJV/v1WRBXrPPRXAb94JlAGD1zQbzECl8LibZ9WYkTunhHiVJqRaCPgrdLQA + * BDzfuBSO6N+pjWxnkjMdwLfS7JLIvgm/LCkFbwJrnu+8vyq8W8BQj0FwcYeyTbcE + * qYSjMq+u7msXi7Kx/mzhkIyIqJdIzshNy/MGz19qCkKxHh53L46g5pIOBvwFItIm + * 4TFRfTLcDwIDAQABoyMwITAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB + * /zANBgkqhkiG9w0BAQsFAAOCAgEAXzSBdu+WHdXltdkCY4QWwa6gcFGn90xHNcgL + * 1yg9iXHZqjNB6hQbbCEAwGxCGX6faVsgQt+i0trEfJdLjbDorMjupWkEmQqSpqsn + * LhpNgb+E1HAerUf+/UqdM+DyucRFCCEK2mlpc3INvjT+lIutwx4116KD7+U4x6WF + * H6vPNOw/KP4M8VeGTslV9xzU2KV9Bnpv1d8Q34FOIWWxtuEXeZVFBs5fzNxGiWNo + * RI2T9GRwoD2dKAXDOXC4Ynsg/eTb6QihuJ49CcdP+yz4k3ZB3lLg4VfSnQO8d57+ + * nile98FRYB/e2guyLXW3Q0iT5/Z5xoRdgFlglPx4mI88k1HtQJAH32RjJMtOcQWh + * 15QaiDLxInQirqWm2BJpTGCjAu4r7NRjkgtevi92a6O2JryPA9gK8kxkRr05YuWW + * 6zRjESjMlfGt7+/cgFhI6Uu46mWs6fyAtbXIRfmswZ/ZuepiiI7E8UuDEq3mi4TW + * nsLrgxifarsbJGAzcMzs9zLzXNl5fe+epP7JI8Mk7hWSsT2RTyaGvWZzJBPqpK5j + * wa19hAM8EHiGG3njxPPyBJUgriOCxLM6AGK/5jYk4Ve6xx6QddVfP5VhK8E7zeWz + * aGHQRiapIVJpLesux+t3zqY6tQMzT3bR51xUAV3LePTJDL/PEo4XLSNolOer/qmy + * KwbQBM0= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02TW1\x120\x10\x06\x03U\x04\n\x13\tTAIWAN-CA1\x100\x0e\x06\x03U\x04\x0b\x13\x07Root CA1\x1c0\x1a\x06\x03U\x04\x03\x13\x13TWCA Global Root CA"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xb0\x05\xdb\xc8\xeb\x8c\xc4n\x8a!\xef\x8eM\x9cq\n\x1fRp\xedm\x82\x9c\x97\xc5\xd7LNEI\xcb@B\xb5\x124l\x19\xc2t\xa41_\x85\x02\x97\xecC3\nS\xd2\x9c\x8c\x8e\xb7\xb8y\xdb+\xd5j\xf2\x8ef\xc4\xee+\x01\x07\x92\xd4\xb3\xd0\x02\xdfP\xf6U\xaff\x0e\xcb\xe0G`/+295R:(\x83\xf8{\x16\xc6\x18\xb8b\xd6G%\x91\xce\xf0\x19\x12M\xadc\xf5\xd3?u_)\xf0\xa10\x1c*\xa0\x98\xa6\x15\xbd\xee\xfd\x196\xf0\xe2\x91C\x8f\xfa\xca\xd6\x10\'IL\xef\xdd\xc1\xf1\x85p\x9b\xca\xea\xa8ZC\xfcm\x86os\xe97E\xa9\xf06\xc7\xcc\x88u\x1e\xbbl\x06\xff\x9bk>\x17\xeca\xaaq|\xc6\x1d\xa2\xf7I\xe9\x15\xb5<\xd6\xa1a\xf5\x11\xf7\x05o\x1d\xfd\x11\xbe\xd00\x07\xc2)\xb0\tN&\xdc\xe3\xa2\xa8\x91j\x1f\xc2\x91E\x88\\\xe5\x98\xb8q\xa5\x15\x19\xc9|u\x11\xccptO-\x9b\x1d\x91D\xfdV(\xa0\xfe\xbb\x86j\xc8\xfa\\\x0bX\xdc\xc6Kv\xc8\xab\"\xd9s\x0f\xa5\xf4Z\x02\x89?O\x9e\"\x82\xee\xa2tS*=S\'i\x1dl\x8e2,d\x00&ca6N\xa3F\xb7?}\xb3-\xacm\x90\xa2\x95\xa2\xce\xcf\xda\x82\xe7\x074\x19\x96\xe9\xb8!\xaa)~\xa68\xbe\x8e)J!fy\x1f\xb3\xc3\xb5\tg\xde\xd6\xd4\x07F\xf3*\xda\xe6\"7`\xcb\x81\xb6\x0f\xa0\x0f\xe9\xc8\x95\x7f\xbfU\x91\x05z\xcf=\x15\xc0o\xde\t\x94\x01\x83\xd74\x1b\xcc@\xa5\xf0\xb8\x9bg\xd5\x98\x91;\xa7\x84x\x95&\xa4Z\x08\xf8+t\xb4\x00\x04<\xdf\xb8\x14\x8e\xe8\xdf\xa9\x8dlg\x923\x1d\xc0\xb7\xd2\xec\x92\xc8\xbe\t\xbf,)\x05o\x02k\x9e\xef\xbc\xbf*\xbc[\xc0P\x8fApq\x87\xb2M\xb7\x04\xa9\x84\xa32\xaf\xae\xeek\x17\x8b\xb2\xb1\xfel\xe1\x90\x8c\x88\xa8\x97H\xce\xc8M\xcb\xf3\x06\xcf_j\nB\xb1\x1e\x1ew/\x8e\xa0\xe6\x92\x0e\x06\xfc\x05\"\xd2&\xe11Q}2\xdc\x0f\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=Hongkong Post Root CA 3 O=Hongkong Post + * Subject: CN=Hongkong Post Root CA 3 O=Hongkong Post + * Label: "Hongkong Post Root CA 3" + * Serial: 46170865288971385588281144162979347873371282084 + * SHA256 Fingerprint: 5a:2f:c0:3f:0c:83:b0:90:bb:fa:40:60:4b:09:88:44:6c:76:36:18:3d:f9:84:6e:17:10:1a:44:7f:b8:ef:d6 + * -----BEGIN CERTIFICATE----- + * MIIFzzCCA7egAwIBAgIUCBZfikyl7ADJk0DfxMauI7gcWqQwDQYJKoZIhvcNAQEL + * BQAwbzELMAkGA1UEBhMCSEsxEjAQBgNVBAgTCUhvbmcgS29uZzESMBAGA1UEBxMJ + * SG9uZyBLb25nMRYwFAYDVQQKEw1Ib25na29uZyBQb3N0MSAwHgYDVQQDExdIb25n + * a29uZyBQb3N0IFJvb3QgQ0EgMzAeFw0xNzA2MDMwMjI5NDZaFw00MjA2MDMwMjI5 + * NDZaMG8xCzAJBgNVBAYTAkhLMRIwEAYDVQQIEwlIb25nIEtvbmcxEjAQBgNVBAcT + * CUhvbmcgS29uZzEWMBQGA1UEChMNSG9uZ2tvbmcgUG9zdDEgMB4GA1UEAxMXSG9u + * Z2tvbmcgUG9zdCBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIK + * AoICAQCziNfqzg8gTr7m1gNt7ln8wlffKWihgw4+aMdoWJwcYEuJQwy51BWy7sFO + * dem1p+/l6TWZ5Mwc50tfjTMwIDNT2aa71T4Tjukfh0mtUC1Qyhi+AViiE3CWu4mI + * VoBc+L0sPOFMV4i707mV78vH9toxdCim5lSJ9UExyuUmGs2C4HDaOym71QP1mbpV + * 9WTRYA6ziUm4ii8F0oRFKHyPaFASePwLtVPLwpgchKOesL4jpNrcyCse2m5FHomY + * 2vkALgbpDDtw1VAliJnLzXNg99X/NWfFobxeq81KuEXryGgeDQ0URhLj0mRiikKY + * vLTGCAj4/ahMZJx2Ab0vqWwzD9g/KLg8aQFChn5pwckGyuV6RmXpwtZQQS4/t+Tt + * bNe/JgERohYpSms0BpDsE9K2+2p20jzt8NYt3eEV7KObLyzJPivkaTv/ciWxNoZb + * x39ri1UbSsUgYT2uy1DhCDq+sI9jQVMwCFk8mB13umOResoQUGC/8Ne8lYePl8X+ + * l2oBlKN8W4UdKjk60FSh0Tlxnf0h+bV78OLgAo9uliQlLKAeLKjEiafv7ZkGL7YK + * TE/bosw3Gq9HhS2KX8Q0NEwA/RiTZxPRN+ZItIsGxVd7GYYKecsAyVKvQv83j+Gj + * Hno9UKtjBucVtT+2RTeUN7F+8kjDf8V1/peNRY8apxpyKBpADwIDAQABo2MwYTAP + * BgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAfBgNVHSMEGDAWgBQXnc0e + * i9Y5K3DTXNSguB+wAPzFYTAdBgNVHQ4EFgQUF53NHovWOStw01zUoLgfsAD8xWEw + * DQYJKoZIhvcNAQELBQADggIBAFbVe27mIgHSQpsY1Q7XZiNc4/6gx5LS6ZStS6LG + * 7BJ8dNVI0lkUmcDrudHr9EgwW62nV3OZqdPlt9EuWSRY3GguLmLYauRwCy0gUCCk + * MpXRAJi70/33MvJJrsZ64Ee+bs7Lo3I6LWldy8joRTnU+kLBEUx3XZL7av9YROXr + * gZ6voJmtvqkBZss4HTzfQx/0TW60uhdG/H39h4F5ag0zD/ov+BS5gLNdTaqX4fnk + * GMX41TiMJjz98iji7lpJiCzfeT2OnpA8vUFKOt1b9pq0zj8lMH8yfaIDlNDceqFS + * 3m6TjRgm/VWsvY+b0s+v54Ysyx8Jb6NvqYTUc79NoXQbTiNg8swOqn+knEwlqLJm + * Ozj/2ZQw9nKEvmhVEA/GcywWaZMH/rFF7buiVWqw2rVKAiUnhde3t4ZEFolsgCs+ + * l6mc1X5VTMbeRRAc6uk7nwNT7u56AQIWeNTowr5GdogTPyK7SBIdUgC0An4hGh6c + * JfTzPV4e0hz5sy229zdcxsshTrD3mUcYhcErulWuBurQB7Lcq9CClnXO0lD+mefP + * L5/ndtFhKvshuzHQqp9HpLIiyhY6UFfEW0NnxWViA0kB60PZ2Pierc+xYw5F9KBa + * LJstxabArahH9CdMOA0uG0k7UvToiIMrVCjU8jVStDKDYmlkDJGcn5fqdBb9HxEG + * mpv0 + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02HK1\x120\x10\x06\x03U\x04\x08\x13\tHong Kong1\x120\x10\x06\x03U\x04\x07\x13\tHong Kong1\x160\x14\x06\x03U\x04\n\x13\rHongkong Post1 0\x1e\x06\x03U\x04\x03\x13\x17Hongkong Post Root CA 3"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xb3\x88\xd7\xea\xce\x0f N\xbe\xe6\xd6\x03m\xeeY\xfc\xc2W\xdf)h\xa1\x83\x0e>h\xc7hX\x9c\x1c`K\x89C\x0c\xb9\xd4\x15\xb2\xee\xc1Nu\xe9\xb5\xa7\xef\xe5\xe95\x99\xe4\xcc\x1c\xe7K_\x8d30 3S\xd9\xa6\xbb\xd5>\x13\x8e\xe9\x1f\x87I\xadP-P\xca\x18\xbe\x01X\xa2\x13p\x96\xbb\x89\x88V\x80\\\xf8\xbd,<\xe1LW\x88\xbb\xd3\xb9\x95\xef\xcb\xc7\xf6\xda1t(\xa6\xe6T\x89\xf5A1\xca\xe5&\x1a\xcd\x82\xe0p\xda;)\xbb\xd5\x03\xf5\x99\xbaU\xf5d\xd1`\x0e\xb3\x89I\xb8\x8a/\x05\xd2\x84E(|\x8fhP\x12x\xfc\x0b\xb5S\xcb\xc2\x98\x1c\x84\xa3\x9e\xb0\xbe#\xa4\xda\xdc\xc8+\x1e\xdanE\x1e\x89\x98\xda\xf9\x00.\x06\xe9\x0c;p\xd5P%\x88\x99\xcb\xcds`\xf7\xd5\xff5g\xc5\xa1\xbc^\xab\xcdJ\xb8E\xeb\xc8h\x1e\r\r\x14F\x12\xe3\xd2db\x8aB\x98\xbc\xb4\xc6\x08\x08\xf8\xfd\xa8Ld\x9cv\x01\xbd/\xa9l3\x0f\xd8?(\xb8+\xe4i;\xffr%\xb16\x86[\xc7\x7fk\x8bU\x1bJ\xc5 a=\xae\xcbP\xe1\x08:\xbe\xb0\x8fcAS0\x08Y<\x98\x1dw\xbac\x91z\xca\x10P`\xbf\xf0\xd7\xbc\x95\x87\x8f\x97\xc5\xfe\x97j\x01\x94\xa3|[\x85\x1d*9:\xd0T\xa1\xd19q\x9d\xfd!\xf9\xb5{\xf0\xe2\xe0\x02\x8fn\x96$%,\xa0\x1e,\xa8\xc4\x89\xa7\xef\xed\x99\x06/\xb6\nLO\xdb\xa2\xcc7\x1a\xafG\x85-\x8a_\xc444L\x00\xfd\x18\x93g\x13\xd17\xe6H\xb4\x8b\x06\xc5W{\x19\x86\ny\xcb\x00\xc9R\xafB\xff7\x8f\xe1\xa3\x1ez=P\xabc\x06\xe7\x15\xb5?\xb6E7\x947\xb1~\xf2H\xc3\x7f\xc5u\xfe\x97\x8dE\x8f\x1a\xa7\x1ar(\x1a@\x0f\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=Certum Trusted Network CA O=Unizeto Technologies S.A. OU=Certum Certification Authority + * Subject: CN=Certum Trusted Network CA O=Unizeto Technologies S.A. OU=Certum Certification Authority + * Label: "Certum Trusted Network CA" + * Serial: 279744 + * SHA256 Fingerprint: 5c:58:46:8d:55:f5:8e:49:7e:74:39:82:d2:b5:00:10:b6:d1:65:37:4a:cf:83:a7:d4:a3:2d:b7:68:c4:40:8e + * -----BEGIN CERTIFICATE----- + * MIIDuzCCAqOgAwIBAgIDBETAMA0GCSqGSIb3DQEBBQUAMH4xCzAJBgNVBAYTAlBM + * MSIwIAYDVQQKExlVbml6ZXRvIFRlY2hub2xvZ2llcyBTLkEuMScwJQYDVQQLEx5D + * ZXJ0dW0gQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxIjAgBgNVBAMTGUNlcnR1bSBU + * cnVzdGVkIE5ldHdvcmsgQ0EwHhcNMDgxMDIyMTIwNzM3WhcNMjkxMjMxMTIwNzM3 + * WjB+MQswCQYDVQQGEwJQTDEiMCAGA1UEChMZVW5pemV0byBUZWNobm9sb2dpZXMg + * Uy5BLjEnMCUGA1UECxMeQ2VydHVtIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MSIw + * IAYDVQQDExlDZXJ0dW0gVHJ1c3RlZCBOZXR3b3JrIENBMIIBIjANBgkqhkiG9w0B + * AQEFAAOCAQ8AMIIBCgKCAQEA4/t9o3K6wvDJFIf1awFO4W5AB7ptJ11/91sts1rH + * UV+rpDKmYYe2bg+G0jACl/jXaVehGDldamR5xgFZrDwxSjh80gTSSyjoIF87B6LM + * TXPb865Px1bVWqeWifrzq2jUI4ZZJ88JJ7ysbnKDHDBy3+Ci6dLhdHUZvSqeexVU + * BBvXQzmtVSjF4hq79MDkrjhJM8x2hZ85RdKknvISjFH4fOQtf/WsX+sWn7Et0brM + * kUJ3TCXJkDhv2/DM+44el1k+1WBO5gUo7Ul5E0u6SNsv+XLTOcr+H9g0cvW0QM8x + * AcPs3hEtF10fuFDRXhmnad4HMyjKUJX5p1TLVIZQRan5SQIDAQABo0IwQDAPBgNV + * HRMBAf8EBTADAQH/MB0GA1UdDgQWBBQIds3LB/8k9sXN7buQvOKEN0Z19zAOBgNV + * HQ8BAf8EBAMCAQYwDQYJKoZIhvcNAQEFBQADggEBAKaorSLOAT2mo/9i0Eidi15y + * sHhE49wcrwn9I0j6vSrEuVUEtRCjjSfeC4Jj0O7eDDd5QVsisrCaQVymcODU0HfL + * I9MA4GxWL+FpDQ3Zqr8hgVDZBqWo/5U30Kr+4rP1mS1FhIrlQgnXdAIv94nYmem8 + * J9RHjboNRhx3zxSkHLmkMcScKHQDNP8zGSal6Q10tz6XxnboJ5ajZt3hrvJBW8qY + * VoNzcOSGGtIxQbovvi0TWnZvTuhOgQ4/WwMioBK+ZlgRSssDxLQqKi2WF+A5VLxI + * 03YnnZotBqbJ7DnSq9ufmgsnAjUpsUCV5/nonFWIGUbWtzT1fs45mtk48VH3Tyw= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02PL1\"0 \x06\x03U\x04\n\x13\x19Unizeto Technologies S.A.1\'0%\x06\x03U\x04\x0b\x13\x1eCertum Certification Authority1\"0 \x06\x03U\x04\x03\x13\x19Certum Trusted Network CA"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x01\x0f\x000\x82\x01\n\x02\x82\x01\x01\x00\xe3\xfb}\xa3r\xba\xc2\xf0\xc9\x14\x87\xf5k\x01N\xe1n@\x07\xbam\']\x7f\xf7[-\xb3Z\xc7Q_\xab\xa42\xa6a\x87\xb6n\x0f\x86\xd20\x02\x97\xf8\xd7iW\xa1\x189]jdy\xc6\x01Y\xac<1J8|\xd2\x04\xd2K(\xe8 _;\x07\xa2\xccMs\xdb\xf3\xaeO\xc7V\xd5Z\xa7\x96\x89\xfa\xf3\xabh\xd4#\x86Y\'\xcf\t\'\xbc\xacnr\x83\x1c0r\xdf\xe0\xa2\xe9\xd2\xe1tu\x19\xbd*\x9e{\x15T\x04\x1b\xd7C9\xadU(\xc5\xe2\x1a\xbb\xf4\xc0\xe4\xae8I3\xccv\x85\x9f9E\xd2\xa4\x9e\xf2\x12\x8cQ\xf8|\xe4-\x7f\xf5\xac_\xeb\x16\x9f\xb1-\xd1\xba\xcc\x91BwL%\xc9\x908o\xdb\xf0\xcc\xfb\x8e\x1e\x97Y>\xd5`N\xe6\x05(\xedIy\x13K\xbaH\xdb/\xf9r\xd39\xca\xfe\x1f\xd84r\xf5\xb4@\xcf1\x01\xc3\xec\xde\x11-\x17]\x1f\xb8P\xd1^\x19\xa7i\xde\x073(\xcaP\x95\xf9\xa7T\xcbT\x86PE\xa9\xf9I\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=CFCA EV ROOT O=China Financial Certification Authority + * Subject: CN=CFCA EV ROOT O=China Financial Certification Authority + * Label: "CFCA EV ROOT" + * Serial: 407555286 + * SHA256 Fingerprint: 5c:c3:d7:8e:4e:1d:5e:45:54:7a:04:e6:87:3e:64:f9:0c:f9:53:6d:1c:cc:2e:f8:00:f3:55:c4:c5:fd:70:fd + * -----BEGIN CERTIFICATE----- + * MIIFjTCCA3WgAwIBAgIEGErM1jANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJD + * TjEwMC4GA1UECgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9y + * aXR5MRUwEwYDVQQDDAxDRkNBIEVWIFJPT1QwHhcNMTIwODA4MDMwNzAxWhcNMjkx + * MjMxMDMwNzAxWjBWMQswCQYDVQQGEwJDTjEwMC4GA1UECgwnQ2hpbmEgRmluYW5j + * aWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRUwEwYDVQQDDAxDRkNBIEVWIFJP + * T1QwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDXXWvNED8fBVnVBU03 + * sQ7smCuOFR36k0sXgiFxEFLXUWRwFsJVaU2OFW2fvwwbwuCjZ9YMrM8irq93VCpL + * TIpTUnrD7i7es3ElweldPe6hL6P3KjzJIx1qqx2hp/Hz7KDVRM8Vz3IvHWOX6Jn5 + * /ZOkVIBMUtRSqy5J35DNuF++P96hyk0g1CXohClTt7GIH//62pCfCqktQT+x8Rgp + * 7hZZLDRJGqgG16iI0gNyejLi6mhNbiyWZXvKWfry4t3uMCz7zEasxGPrb382KzRz + * EpR/38wmnvFyXVBlWY9ps4deMm/DGIq1lY+wejfeWkU7xzbh72fROdOXW3NiGUgt + * hxwG+3SYIElz8AXSG7Ggo7cbcNOIabla1jj0Ytwli3i/+Oh+uFzJlU9fpy25IGvP + * a931DfSCt/SyZi4QKPaXWnuWFo8BGS1sbn85WAZkgwGDg8NNkt0yxoekN+kWzqot + * aK8KgWU6cMGbrU1tVMoqLUuFG7OA5nBFDWteNfB/O7ic5ARwiRIlk9oKmSJgamNg + * TnYGmE69g60dWIolhdLHZR4tjsbftsbhf4oEIRUpdPA+nJCdDC7xij5aqgwJHsfV + * PKPtl8MeNPo4+QgO48BdK4PRVmrJtqhUUy54Mmc9gn900PvhtgVguXDbjgv5E1hv + * cWAQUhC5wUEJ73IfZzF4/5YFjQIDAQABo2MwYTAfBgNVHSMEGDAWgBTj/i39KNAL + * tbq2osS/BqoFjJP7LzAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAd + * BgNVHQ4EFgQU4/4t/SjQC7W6tqLEvwaqBYyT+y8wDQYJKoZIhvcNAQELBQADggIB + * ACXGumvrh8vegjmWPfBEp2uEcwPenStPuiB/vHiyz5ewG5zz13ku9Ui20vsXiObT + * ej/tUxPQ4i9qecsAIyjmHjdXNYmEwnZPNDatZ8POQQaIxffu2Bq41gt/UP+TqhdL + * jOztUmCypAbqTuv0axn96/Ua4CUqmtzHQTb3yHQFhDmVOdYLO6Qn+gjYXB74BGBS + * ESgoA//vU2YApUo0FmZ8/Qmkrp5nGm9BC2sGE5uPhnEFtC+NiWYzKXZUmhH4J/qy + * P5Hgzg0b8zAarb8iXRvTvyUFTeGSGn+ZnzxEk8rUQElsgIfXBDrDMlI1Dlb4pd19 + * xIsNER9Tyx6yF7Zod1rg1MvIB671Oi6ON7fQAUtDKXeMOZePglr4UeWJoBjnaH9d + * Ci77o0cOPaYjesYBx4/IXr9tgFa+iiS6M+qf4TIRnvHST4D2G0CvOJ4RUHlzEhLN + * 5mydLIhyPDCBBpEi6lmt2hkuIsKNuYyH4Ga8cyNfIWRjgEj1oDwYPZTISEEdQLpe + * /v5WOaHIz16eGWRGENoXkbcFgKyLmZJ956LYBws2J+dIeWCKw9cTXPhyQN9Ky8+Z + * AAoACxGV2lZFA4gKn2fQ1XmxqI1AbQ3CekD6819kR5LLU7m7Wc5P/dAVUwHY3+vZ + * 5nbv0CO7O6l5s9UCKc2Jo5YPSjXnTkLAdc0Hz+Ys63su + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02CN100.\x06\x03U\x04\n\x0c\'China Financial Certification Authority1\x150\x13\x06\x03U\x04\x03\x0c\x0cCFCA EV ROOT"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xd7]k\xcd\x10?\x1f\x05Y\xd5\x05M7\xb1\x0e\xec\x98+\x8e\x15\x1d\xfa\x93K\x17\x82!q\x10R\xd7Qdp\x16\xc2UiM\x8e\x15m\x9f\xbf\x0c\x1b\xc2\xe0\xa3g\xd6\x0c\xac\xcf\"\xae\xafwT*KL\x8aSRz\xc3\xee.\xde\xb3q%\xc1\xe9]=\xee\xa1/\xa3\xf7*<\xc9#\x1dj\xab\x1d\xa1\xa7\xf1\xf3\xec\xa0\xd5D\xcf\x15\xcfr/\x1dc\x97\xe8\x99\xf9\xfd\x93\xa4T\x80LR\xd4R\xab.I\xdf\x90\xcd\xb8_\xbe?\xde\xa1\xcaM \xd4%\xe8\x84)S\xb7\xb1\x88\x1f\xff\xfa\xda\x90\x9f\n\xa9-A?\xb1\xf1\x18)\xee\x16Y,4I\x1a\xa8\x06\xd7\xa8\x88\xd2\x03rz2\xe2\xeahMn,\x96e{\xcaY\xfa\xf2\xe2\xdd\xee0,\xfb\xccF\xac\xc4c\xebo\x7f6+4s\x12\x94\x7f\xdf\xcc&\x9e\xf1r]PeY\x8fi\xb3\x87^2o\xc3\x18\x8a\xb5\x95\x8f\xb0z7\xdeZE;\xc76\xe1\xefg\xd19\xd3\x97[sb\x19H-\x87\x1c\x06\xfbt\x98 Is\xf0\x05\xd2\x1b\xb1\xa0\xa3\xb7\x1bp\xd3\x88i\xb9Z\xd68\xf4b\xdc%\x8bx\xbf\xf8\xe8~\xb8\\\xc9\x95O_\xa7-\xb9 k\xcfk\xdd\xf5\r\xf4\x82\xb7\xf4\xb2f.\x10(\xf6\x97Z{\x96\x16\x8f\x01\x19-ln\x7f9X\x06d\x83\x01\x83\x83\xc3M\x92\xdd2\xc6\x87\xa47\xe9\x16\xce\xaa-h\xaf\n\x81e:p\xc1\x9b\xadMmT\xca*-K\x85\x1b\xb3\x80\xe6pE\rk^5\xf0\x7f;\xb8\x9c\xe4\x04p\x89\x12%\x93\xda\n\x99\"`jc`Nv\x06\x98N\xbd\x83\xad\x1dX\x8a%\x85\xd2\xc7e\x1e-\x8e\xc6\xdf\xb6\xc6\xe1\x7f\x8a\x04!\x15)t\xf0>\x9c\x90\x9d\x0c.\xf1\x8a>Z\xaa\x0c\t\x1e\xc7\xd5<\xa3\xed\x97\xc3\x1e4\xfa8\xf9\x08\x0e\xe3\xc0]+\x83\xd1Vj\xc9\xb6\xa8TS.x2g=\x82\x7ft\xd0\xfb\xe1\xb6\x05`\xb9p\xdb\x8e\x0b\xf9\x13Xoq`\x10R\x10\xb9\xc1A\t\xefr\x1fg1x\xff\x96\x05\x8d\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=IdenTrust Commercial Root CA 1 O=IdenTrust + * Subject: CN=IdenTrust Commercial Root CA 1 O=IdenTrust + * Label: "IdenTrust Commercial Root CA 1" + * Serial: 13298821034946342390520003877796839426 + * SHA256 Fingerprint: 5d:56:49:9b:e4:d2:e0:8b:cf:ca:d0:8a:3e:38:72:3d:50:50:3b:de:70:69:48:e4:2f:55:60:30:19:e5:28:ae + * -----BEGIN CERTIFICATE----- + * MIIFYDCCA0igAwIBAgIQCgFCgAAAAUUjyES1AAAAAjANBgkqhkiG9w0BAQsFADBK + * MQswCQYDVQQGEwJVUzESMBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVu + * VHJ1c3QgQ29tbWVyY2lhbCBSb290IENBIDEwHhcNMTQwMTE2MTgxMjIzWhcNMzQw + * MTE2MTgxMjIzWjBKMQswCQYDVQQGEwJVUzESMBAGA1UEChMJSWRlblRydXN0MScw + * JQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBSb290IENBIDEwggIiMA0GCSqG + * SIb3DQEBAQUAA4ICDwAwggIKAoICAQCnUBneP5k91DNG8W9RYYKyqU+PZ4ldhNlT + * 3Qwo2dfw/66VQ3KZ+bVdfIrBQuExUHTRgQ18zZshq0PirK1ehm7zCYofWjK9ouuU + * +ehcCuz/mNKvcbO0U59Oh++SvL3sTzIwiEsXXlfEU8L2ApeN2WIrvyQfYo3fw7gp + * S0l4PJNgiCL8mdo2yMKi1CxUAGc1bnO/AljwpN3lsKImesrgNqUZFvX9t++uP0D1 + * bVoE/c40yiTcdCMbXTMTEl3EASX2MN0CXZ/g1Ue9tOsbobtJSdifWwLziuQkkORi + * T0/Br4sOdBeo0XKIanoBScy0RnnGF7HamB4HWfp1IYVl3ZBWzvurpWCdxJ35UrCL + * vYf5jysjCiN2O/cz4ckA82n5S6LgTrx+kzmEB/dEcH7+B1rlsazRGMzyNeVJSQjK + * Vsk9+w8YfYs7wRPCTY/JTw436R+hDmrfYi7LNQZReSzIJTj0+kuniVyc0uMNOYZK + * dHzVWYfCP04MXFL0PfdSgvHqo6z9STQaKPNBiDoT7uje/5kdX7rL6B7yuVBgwDHT + * c+XvvqDtMwt0viAgxGds8AgDelWAf0ZOlqf0Hj7h9tgJ4TNkK2PXMl6f+cB7D3hv + * l7yTmvmcEpB4eoCHFddydJxVdHixuuFucAS6T6C6aMN7/zHwcz09lCqxC0EOoP5N + * iGVreTO01wIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB + * /zAdBgNVHQ4EFgQU7UQZwNPwBovupHu+QucmVMiONnYwDQYJKoZIhvcNAQELBQAD + * ggIBAA2ukDL2pkt8RHYZYR4nKM1eVO8lvOMIkPkp165oCOGUAFjvLi5+U1KMtlwH + * 6oi6mYtQlNeCgN9hCQCTrQ0U5s7B8jeUeLBfnLOic7iPBZM4zY0+sLj7wM+x8uwt + * LRvM7Kqas6pgghstO8OEPVeKlh6cdbjTMM1gCIOQ045U8U1mwF10A0Cj7oV+wh93 + * nAbowacYXVKV7cndJZ5t+qntozo00Fl72u1Q8zW/7esUTTHHYPTa8Yec4kjixsU3 + * +wYQ+nVZZjFHKdp2mhzpgq7vmrlR94gjmmmVYjzlVYA211QC//G5Xc7UI2/YRYRK + * W2XviQzdFKcgyxilJbQN+QHwotL0AMh0jqEqSI5l2xPE4iUXfeu+h1sXIFRRk0pT + * AwvsXcoz7WL9RccvW9xYoIA55vrX/hMUpu09lEpCdNTDd1lzzY9GvlU47/rokTLq + * l1gEIt44w8y8bckzOmoKaT+gyOpyj4xjhiO9bTyWnpXgSUyqorkqG5w2gXjtw+hG + * 4iZZRHUe2XWJUc0QhJ1hYMtd+ZciTY6Y5uN/9lu7rs3KSoFrXgvzUeF0K+l+J6fZ + * mUlO+KWA2yUPHGNiiskzZ2s8EIPGrd6ozRaOjfAHN3Gf8qv8QfXBi+wAN10J5U6A + * 7/qxXDgGpRtK4dw4LTzcqx+QGtVKnO7RcGzM7vRX+Bi6hG6H + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1\x120\x10\x06\x03U\x04\n\x13\tIdenTrust1\'0%\x06\x03U\x04\x03\x13\x1eIdenTrust Commercial Root CA 1"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xa7P\x19\xde?\x99=\xd43F\xf1oQa\x82\xb2\xa9O\x8fg\x89]\x84\xd9S\xdd\x0c(\xd9\xd7\xf0\xff\xae\x95Cr\x99\xf9\xb5]|\x8a\xc1B\xe11Pt\xd1\x81\r|\xcd\x9b!\xabC\xe2\xac\xad^\x86n\xf3\t\x8a\x1fZ2\xbd\xa2\xeb\x94\xf9\xe8\\\n\xec\xff\x98\xd2\xafq\xb3\xb4S\x9fN\x87\xef\x92\xbc\xbd\xecO20\x88K\x17^W\xc4S\xc2\xf6\x02\x97\x8d\xd9b+\xbf$\x1fb\x8d\xdf\xc3\xb8)KIx<\x93`\x88\"\xfc\x99\xda6\xc8\xc2\xa2\xd4,T\x00g5ns\xbf\x02X\xf0\xa4\xdd\xe5\xb0\xa2&z\xca\xe06\xa5\x19\x16\xf5\xfd\xb7\xef\xae?@\xf5mZ\x04\xfd\xce4\xca$\xdct#\x1b]3\x13\x12]\xc4\x01%\xf60\xdd\x02]\x9f\xe0\xd5G\xbd\xb4\xeb\x1b\xa1\xbbII\xd8\x9f[\x02\xf3\x8a\xe4$\x90\xe4bOO\xc1\xaf\x8b\x0et\x17\xa8\xd1r\x88jz\x01I\xcc\xb4Fy\xc6\x17\xb1\xda\x98\x1e\x07Y\xfau!\x85e\xdd\x90V\xce\xfb\xab\xa5`\x9d\xc4\x9d\xf9R\xb0\x8b\xbd\x87\xf9\x8f+#\n#v;\xf73\xe1\xc9\x00\xf3i\xf9K\xa2\xe0N\xbc~\x939\x84\x07\xf7Dp~\xfe\x07Z\xe5\xb1\xac\xd1\x18\xcc\xf25\xe5II\x08\xcaV\xc9=\xfb\x0f\x18}\x8b;\xc1\x13\xc2M\x8f\xc9O\x0e7\xe9\x1f\xa1\x0ej\xdfb.\xcb5\x06Qy,\xc8%8\xf4\xfaK\xa7\x89\\\x9c\xd2\xe3\r9\x86Jt|\xd5Y\x87\xc2?N\x0c\\R\xf4=\xf7R\x82\xf1\xea\xa3\xac\xfdI4\x1a(\xf3A\x88:\x13\xee\xe8\xde\xff\x99\x1d_\xba\xcb\xe8\x1e\xf2\xb9P`\xc01\xd3s\xe5\xef\xbe\xa0\xed3\x0bt\xbe \xc4gl\xf0\x08\x03zU\x80\x7fFN\x96\xa7\xf4\x1e>\xe1\xf6\xd8\t\xe13d+c\xd72^\x9f\xf9\xc0{\x0fxo\x97\xbc\x93\x9a\xf9\x9c\x12\x90xz\x80\x87\x15\xd7rt\x9cUtx\xb1\xba\xe1np\x04\xbaO\xa0\xbah\xc3{\xff1\xf0s==\x94*\xb1\x0bA\x0e\xa0\xfeM\x88eky3\xb4\xd7\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: O=CERTSIGN SA OU=certSIGN ROOT CA G2 + * Subject: O=CERTSIGN SA OU=certSIGN ROOT CA G2 + * Label: "certSIGN ROOT CA G2" + * Serial: 313609486401300475190 + * SHA256 Fingerprint: 65:7c:fe:2f:a7:3f:aa:38:46:25:71:f3:32:a2:36:3a:46:fc:e7:02:09:51:71:07:02:cd:fb:b6:ee:da:33:05 + * -----BEGIN CERTIFICATE----- + * MIIFRzCCAy+gAwIBAgIJEQA0tk7GNi02MA0GCSqGSIb3DQEBCwUAMEExCzAJBgNV + * BAYTAlJPMRQwEgYDVQQKEwtDRVJUU0lHTiBTQTEcMBoGA1UECxMTY2VydFNJR04g + * Uk9PVCBDQSBHMjAeFw0xNzAyMDYwOTI3MzVaFw00MjAyMDYwOTI3MzVaMEExCzAJ + * BgNVBAYTAlJPMRQwEgYDVQQKEwtDRVJUU0lHTiBTQTEcMBoGA1UECxMTY2VydFNJ + * R04gUk9PVCBDQSBHMjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMDF + * dRmRfUR0dIf+DjuW3NgBFszuY5HnC2/OOwppGnzC46+CjobXXo9X69MhWf05N0Iw + * vlDqtg+piNguLWkh59E3GE59kdUWX2tbAMI5Qw02hVK5U2UPHULlj88F0+7cDBrZ + * uIt4ImfkabBoxTzkbFpG583H+u/E7Eu9aqSs/cwoUe+StCmrqzWaTOTECMYmzPhp + * n+Sc8CnTXPnGFiWeI8MgwT0PPzhAsP6CRDiqWhqKa2NYOLQV07YRaXseVO6MGiKs + * cpc/I1mbySKEwQdPzH/iV8oScLumZfNpdWO9lfsbl83kqK/20U6o2YpxJM02PbyW + * xPFsqa7lzw1uKA2wDrXKUXt4FMMgL3/7FFXhEZn91QqhngLjYl/rNUssuHLoPj1P + * rCy7Lobio3aP5ZMqz6WryFyNSwb/EkaseMsUBzXgqd+L6a8VTxaJW732jcZZroiF + * DsGJ6x9nxUWO/203Nit4ZoORUSs9/1F3dmKh7Gc+PoGD4FapUB8fepmrY7+EF3fx + * DTvf95xhszWYijqy7DwaNz9+j5LP2RIUZNoQAhVB/0/E6xyjyfqZ90bp4RjZsbgy + * LcsUDFDYg2WD7rlcz8sFWkz6GZdr1l0T08JcVLwyc6B49fFtHsufpaafItzRUZ6C + * eWRgKRM+o/1Pcmqr4tTluCRVLERLiohEnMqE0yo7AgMBAAGjQjBAMA8GA1UdEwEB + * /wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBSCIS1mxteg4BXrzkwJ + * d8RgnlRuAzANBgkqhkiG9w0BAQsFAAOCAgEAYN4auOfyYILVAzOBywaK8SJJ6ejq + * kX/GM15oGQOGO0MBzwdw5AgeZYWR5hEit/UCI46uuR59H35s5r0l1ZUa8gWmr4UC + * b6741jH/JclKyMeKqdmfS0mbEVeZkkMR3rYzpMzXjWR91M08KCy0mpbqTfXERMQl + * qiCA2ClV9+BB/AYm/7k29UMUA2Z44RGx2iBfRgB4ACGlHgAoYXhvqAEBj500mv/0 + * OJD7uNGzcgbJceaBxXntC6Z58hMLnPddDnskk7RI24Zf3lCGeOdA5jGokHZwYa+c + * NywRtYK3qq4kNFtyDGkNzVmf9nGvnAvRCjj5BiKDUyUM/FHE5r7iOZULJK2v0ZXk + * ltd0ZGtxTgI8qoXzIKNDOXZbbFD+mpwUHmUUihW9o4JFWklWatKcsWMy5WHgUyIO + * pwpJ6st+H6jiYoD2EEVSmAYY3qXNL3+q1Ok+CHLsIwMCPKaq2LxndD0UF/tUSxfj + * 03k9bWtJySgOLnRQvwzZRjoQhsmnP+mg7H/rpXdYaXHmgwo38oZJar55CJD2AhZk + * PuXaTH4MNMn5X7azKFGnpyuqSfqNZSlO42sTp5SjLVFteAxEy9/eCG/Oo2Sr05WE + * 1LlSVHJ7liXMvGnjSG4N0MedJ5qq+BOS3R7fY581qRY27Iy4g/Q9iY/NtBde17MX + * QRBdJ3NghVdJIgc= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02RO1\x140\x12\x06\x03U\x04\n\x13\x0bCERTSIGN SA1\x1c0\x1a\x06\x03U\x04\x0b\x13\x13certSIGN ROOT CA G2"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xc0\xc5u\x19\x91}Dtt\x87\xfe\x0e;\x96\xdc\xd8\x01\x16\xcc\xeec\x91\xe7\x0bo\xce;\ni\x1a|\xc2\xe3\xaf\x82\x8e\x86\xd7^\x8fW\xeb\xd3!Y\xfd97B0\xbeP\xea\xb6\x0f\xa9\x88\xd8.-i!\xe7\xd17\x18N}\x91\xd5\x16_k[\x00\xc29C\r6\x85R\xb9Se\x0f\x1dB\xe5\x8f\xcf\x05\xd3\xee\xdc\x0c\x1a\xd9\xb8\x8bx\"g\xe4i\xb0h\xc5<\xe4lZF\xe7\xcd\xc7\xfa\xef\xc4\xecK\xbdj\xa4\xac\xfd\xcc(Q\xef\x92\xb4)\xab\xab5\x9aL\xe4\xc4\x08\xc6&\xcc\xf8i\x9f\xe4\x9c\xf0)\xd3\\\xf9\xc6\x16%\x9e#\xc3 \xc1=\x0f?8@\xb0\xfe\x82D8\xaaZ\x1a\x8akcX8\xb4\x15\xd3\xb6\x11i{\x1eT\xee\x8c\x1a\"\xacr\x97?#Y\x9b\xc9\"\x84\xc1\x07O\xcc\x7f\xe2W\xca\x12p\xbb\xa6e\xf3iuc\xbd\x95\xfb\x1b\x97\xcd\xe4\xa8\xaf\xf6\xd1N\xa8\xd9\x8aq$\xcd6=\xbc\x96\xc4\xf1l\xa9\xae\xe5\xcf\rn(\r\xb0\x0e\xb5\xcaQ{x\x14\xc3 /\x7f\xfb\x14U\xe1\x11\x99\xfd\xd5\n\xa1\x9e\x02\xe3b_\xeb5K,\xb8r\xe8>=O\xac,\xbb.\x86\xe2\xa3v\x8f\xe5\x93*\xcf\xa5\xab\xc8\\\x8dK\x06\xff\x12F\xacx\xcb\x14\x075\xe0\xa9\xdf\x8b\xe9\xaf\x15O\x16\x89[\xbd\xf6\x8d\xc6Y\xae\x88\x85\x0e\xc1\x89\xeb\x1fg\xc5E\x8e\xffm76+xf\x83\x91Q+=\xffQwvb\xa1\xecg>>\x81\x83\xe0V\xa9P\x1f\x1fz\x99\xabc\xbf\x84\x17w\xf1\r;\xdf\xf7\x9ca\xb35\x98\x8a:\xb2\xec<\x1a7?~\x8f\x92\xcf\xd9\x12\x14d\xda\x10\x02\x15A\xffO\xc4\xeb\x1c\xa3\xc9\xfa\x99\xf7F\xe9\xe1\x18\xd9\xb1\xb82-\xcb\x14\x0cP\xd8\x83e\x83\xee\xb9\\\xcf\xcb\x05ZL\xfa\x19\x97k\xd6]\x13\xd3\xc2\\T\xbc2s\xa0x\xf5\xf1m\x1e\xcb\x9f\xa5\xa6\x9f\"\xdc\xd1Q\x9e\x82yd`)\x13>\xa3\xfdOrj\xab\xe2\xd4\xe5\xb8$U,DK\x8a\x88D\x9c\xca\x84\xd3*;\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=ISRG Root X2 O=Internet Security Research Group + * Subject: CN=ISRG Root X2 O=Internet Security Research Group + * Label: "ISRG Root X2" + * Serial: 87493402998870891108772069816698636114 + * SHA256 Fingerprint: 69:72:9b:8e:15:a8:6e:fc:17:7a:57:af:b7:17:1d:fc:64:ad:d2:8c:2f:ca:8c:f1:50:7e:34:45:3c:cb:14:70 + * -----BEGIN CERTIFICATE----- + * MIICGzCCAaGgAwIBAgIQQdKd0XLq7qeAwSxs6S+HUjAKBggqhkjOPQQDAzBPMQsw + * CQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJuZXQgU2VjdXJpdHkgUmVzZWFyY2gg + * R3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBYMjAeFw0yMDA5MDQwMDAwMDBaFw00 + * MDA5MTcxNjAwMDBaME8xCzAJBgNVBAYTAlVTMSkwJwYDVQQKEyBJbnRlcm5ldCBT + * ZWN1cml0eSBSZXNlYXJjaCBHcm91cDEVMBMGA1UEAxMMSVNSRyBSb290IFgyMHYw + * EAYHKoZIzj0CAQYFK4EEACIDYgAEzZvVn4CDCuwJSvMWSj5cz3es3mcFDR0HttwW + * +1qLFNvicWDEukWVEYmO6gbf9yoWHKS5xcUy4APgHoIYOIvXRdgKam7mAHf7AlF9 + * ItgKbppbd9/w+kHsOdx1ymgHDB/qo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0T + * AQH/BAUwAwEB/zAdBgNVHQ4EFgQUfEKWrt5LSDv6kviejM9ti6lyN5UwCgYIKoZI + * zj0EAwMDaAAwZQIwe3lORlCEwkSHRhtFcP9Ymd70/aTSVaYgLXTWNLxBo1BfASdW + * tL4ndQavEi51mI38AjEAi/V3bNTIZargCyzuFJ0nN6T5U6VR5CmD1/iQMVtCnwr1 + * /q4AaOeMSQ+2b1tbFfLn + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1)0\'\x06\x03U\x04\n\x13 Internet Security Research Group1\x150\x13\x06\x03U\x04\x03\x13\x0cISRG Root X2"), + subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\"\x03b\x00\x04\xcd\x9b\xd5\x9f\x80\x83\n\xec\tJ\xf3\x16J>\\\xcfw\xac\xdeg\x05\r\x1d\x07\xb6\xdc\x16\xfbZ\x8b\x14\xdb\xe2q`\xc4\xbaE\x95\x11\x89\x8e\xea\x06\xdf\xf7*\x16\x1c\xa4\xb9\xc5\xc52\xe0\x03\xe0\x1e\x82\x188\x8b\xd7E\xd8\njn\xe6\x00w\xfb\x02Q}\"\xd8\nn\x9a[w\xdf\xf0\xfaA\xec9\xdcu\xcah\x07\x0c\x1f\xea"), + name_constraints: None + }, + + /* + * Issuer: CN=Certum EC-384 CA O=Asseco Data Systems S.A. OU=Certum Certification Authority + * Subject: CN=Certum EC-384 CA O=Asseco Data Systems S.A. OU=Certum Certification Authority + * Label: "Certum EC-384 CA" + * Serial: 160250656287871593594747141429395092468 + * SHA256 Fingerprint: 6b:32:80:85:62:53:18:aa:50:d1:73:c9:8d:8b:da:09:d5:7e:27:41:3d:11:4c:f7:87:a0:f5:d0:6c:03:0c:f6 + * -----BEGIN CERTIFICATE----- + * MIICZTCCAeugAwIBAgIQeI8nXIESUiClBNAt3bpz9DAKBggqhkjOPQQDAzB0MQsw + * CQYDVQQGEwJQTDEhMB8GA1UEChMYQXNzZWNvIERhdGEgU3lzdGVtcyBTLkEuMScw + * JQYDVQQLEx5DZXJ0dW0gQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxGTAXBgNVBAMT + * EENlcnR1bSBFQy0zODQgQ0EwHhcNMTgwMzI2MDcyNDU0WhcNNDMwMzI2MDcyNDU0 + * WjB0MQswCQYDVQQGEwJQTDEhMB8GA1UEChMYQXNzZWNvIERhdGEgU3lzdGVtcyBT + * LkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxGTAX + * BgNVBAMTEENlcnR1bSBFQy0zODQgQ0EwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAATE + * KI6rGFtqvm5kN2PkzeyrOvfMobgOgknXhimfoZTy42B4mIF4Bk3y7JoOV2CDn7Tm + * Fy8as10CW4kjPMIRBSqniBMY81CE1700LCeJVf/OTOffph8oxPBUw7l8t1Ot68Kj + * QjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFI0GZnQkdjrzife81r1HfS+8 + * EF9LMA4GA1UdDwEB/wQEAwIBBjAKBggqhkjOPQQDAwNoADBlAjADVS2m5hjEfO/J + * UG7BJw+ch69u1RsIGL2SKcHvlJF40jocVYli5RsJHrpka/F2tNQCMQC0QoSZ/6vn + * nvuRlydd3LBbMHHOXjgaatkl5+r3YZJW+OraNsKHZZYuciUvf9/DE8k= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02PL1!0\x1f\x06\x03U\x04\n\x13\x18Asseco Data Systems S.A.1\'0%\x06\x03U\x04\x0b\x13\x1eCertum Certification Authority1\x190\x17\x06\x03U\x04\x03\x13\x10Certum EC-384 CA"), + subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\"\x03b\x00\x04\xc4(\x8e\xab\x18[j\xbend7c\xe4\xcd\xec\xab:\xf7\xcc\xa1\xb8\x0e\x82I\xd7\x86)\x9f\xa1\x94\xf2\xe3`x\x98\x81x\x06M\xf2\xec\x9a\x0eW`\x83\x9f\xb4\xe6\x17/\x1a\xb3]\x02[\x89#<\xc2\x11\x05*\xa7\x88\x13\x18\xf3P\x84\xd7\xbd4,\'\x89U\xff\xceL\xe7\xdf\xa6\x1f(\xc4\xf0T\xc3\xb9|\xb7S\xad\xeb\xc2"), + name_constraints: None + }, + + /* + * Issuer: CN=OISTE WISeKey Global Root GB CA O=WISeKey OU=OISTE Foundation Endorsed + * Subject: CN=OISTE WISeKey Global Root GB CA O=WISeKey OU=OISTE Foundation Endorsed + * Label: "OISTE WISeKey Global Root GB CA" + * Serial: 157768595616588414422159278966750757568 + * SHA256 Fingerprint: 6b:9c:08:e8:6e:b0:f7:67:cf:ad:65:cd:98:b6:21:49:e5:49:4a:67:f5:84:5e:7b:d1:ed:01:9f:27:b8:6b:d6 + * -----BEGIN CERTIFICATE----- + * MIIDtTCCAp2gAwIBAgIQdrEgUnTwhYdGs/gjGvbCwDANBgkqhkiG9w0BAQsFADBt + * MQswCQYDVQQGEwJDSDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUg + * Rm91bmRhdGlvbiBFbmRvcnNlZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9i + * YWwgUm9vdCBHQiBDQTAeFw0xNDEyMDExNTAwMzJaFw0zOTEyMDExNTEwMzFaMG0x + * CzAJBgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYDVQQLExlPSVNURSBG + * b3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEdsb2Jh + * bCBSb290IEdCIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2Be3 + * HEokKtaXscriHvt9OO+Y9bI5mE4nuBFde9IllIiCFSZqGzG7qFshISvYD06fWvGx + * WuR51jIjK+FTzJlFXHtPrby/h0oLS5daqPZI7H17Dc0hBt+eFf1Biki3IPShehtX + * 1F1Q/7pn2COZH8g/497/b1t3sWtuuMlk9+HKQUYOKXHQuSP8yYFfTvdv37+ErXNk + * u7dCjmn21HYdfp2nuFeKUWdy19SouJVUQHMD9ur06/4oQnc/nSMbsrY9gBQHTC5P + * 99UKFg29ZkM3fiNDecNAhvVMKdqOmq0NpQSHiB6F4+lT1ZvIiwNjeOvgGUpuuy9r + * M2RYk61pv48b74JIxwIDAQABo1EwTzALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/BAUw + * AwEB/zAdBgNVHQ4EFgQUNQ/INmNe4qPs+TtmFc5RUuORmj0wEAYJKwYBBAGCNxUB + * BAMCAQAwDQYJKoZIhvcNAQELBQADggEBAEBM+4eymYGQfp3FsLAmzYh7KzKNbrgh + * cViXfa43FK8+5/ea4n32cZiZBKpDdHij40lhPnOMTZTg+XHEthYOU3gf1qKHLwI5 + * gSk8rxWYITD+KJAAjNHhy/peyP34EEY7onhCkRd0VQreUGdNZtGn//3ZwLWoo4rO + * ZvUPQ82nK1d7Y0Zqqi5S2PTt4W2tKZB4SLrhI6qjiey1q5bAtEuiHZeeevJuQHHf + * aPFlTc58Bd9TZaml8LGXBHAVRgOY1NK/VLSgWH1Sb9pWJmLU2NuJMW8c8CLC02Ic + * Nc1MaRVUGpCY3useX8p3x8uOPUNpnJpY0CQ73xtAln41rYHHTnG6iBM= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02CH1\x100\x0e\x06\x03U\x04\n\x13\x07WISeKey1\"0 \x06\x03U\x04\x0b\x13\x19OISTE Foundation Endorsed1(0&\x06\x03U\x04\x03\x13\x1fOISTE WISeKey Global Root GB CA"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x01\x0f\x000\x82\x01\n\x02\x82\x01\x01\x00\xd8\x17\xb7\x1cJ$*\xd6\x97\xb1\xca\xe2\x1e\xfb}8\xef\x98\xf5\xb29\x98N\'\xb8\x11]{\xd2%\x94\x88\x82\x15&j\x1b1\xbb\xa8[!!+\xd8\x0fN\x9fZ\xf1\xb1Z\xe4y\xd62#+\xe1S\xcc\x99E\\{O\xad\xbc\xbf\x87J\x0bK\x97Z\xa8\xf6H\xec}{\r\xcd!\x06\xdf\x9e\x15\xfdA\x8aH\xb7 \xf4\xa1z\x1bW\xd4]P\xff\xbag\xd8#\x99\x1f\xc8?\xe3\xde\xffo[w\xb1kn\xb8\xc9d\xf7\xe1\xcaAF\x0e)q\xd0\xb9#\xfc\xc9\x81_N\xf7o\xdf\xbf\x84\xadsd\xbb\xb7B\x8ei\xf6\xd4v\x1d~\x9d\xa7\xb8W\x8aQgr\xd7\xd4\xa8\xb8\x95T@s\x03\xf6\xea\xf4\xeb\xfe(Bw?\x9d#\x1b\xb2\xb6=\x80\x14\x07L.O\xf7\xd5\n\x16\r\xbdfC7~#Cy\xc3@\x86\xf5L)\xda\x8e\x9a\xad\r\xa5\x04\x87\x88\x1e\x85\xe3\xe9S\xd5\x9b\xc8\x8b\x03cx\xeb\xe0\x19Jn\xbb/k3dX\x93\xadi\xbf\x8f\x1b\xef\x82H\xc7\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=NetLock Arany (Class Gold) Főtanúsítvány O=NetLock Kft. OU=Tanúsítványkiadók (Certification Services) + * Subject: CN=NetLock Arany (Class Gold) Főtanúsítvány O=NetLock Kft. OU=Tanúsítványkiadók (Certification Services) + * Label: "NetLock Arany (Class Gold) Főtanúsítvány" + * Serial: 80544274841616 + * SHA256 Fingerprint: 6c:61:da:c3:a2:de:f0:31:50:6b:e0:36:d2:a6:fe:40:19:94:fb:d1:3d:f9:c8:d4:66:59:92:74:c4:46:ec:98 + * -----BEGIN CERTIFICATE----- + * MIIEFTCCAv2gAwIBAgIGSUEs5AAQMA0GCSqGSIb3DQEBCwUAMIGnMQswCQYDVQQG + * EwJIVTERMA8GA1UEBwwIQnVkYXBlc3QxFTATBgNVBAoMDE5ldExvY2sgS2Z0LjE3 + * MDUGA1UECwwuVGFuw7pzw610dsOhbnlraWFkw7NrIChDZXJ0aWZpY2F0aW9uIFNl + * cnZpY2VzKTE1MDMGA1UEAwwsTmV0TG9jayBBcmFueSAoQ2xhc3MgR29sZCkgRsWR + * dGFuw7pzw610dsOhbnkwHhcNMDgxMjExMTUwODIxWhcNMjgxMjA2MTUwODIxWjCB + * pzELMAkGA1UEBhMCSFUxETAPBgNVBAcMCEJ1ZGFwZXN0MRUwEwYDVQQKDAxOZXRM + * b2NrIEtmdC4xNzA1BgNVBAsMLlRhbsO6c8OtdHbDoW55a2lhZMOzayAoQ2VydGlm + * aWNhdGlvbiBTZXJ2aWNlcykxNTAzBgNVBAMMLE5ldExvY2sgQXJhbnkgKENsYXNz + * IEdvbGQpIEbFkXRhbsO6c8OtdHbDoW55MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A + * MIIBCgKCAQEAxCRec75LbRTDofTjl5Bu0jBFHjzuZ9lk4BqKf8owyoPjIMHj9DrT + * lF8afFttvzBPhCf2nx9JvMaZCpDyD/V/Q4Q3Y1GLeqVw/HpYzY6b7cNGbIRwXdrz + * AZAj/E4wqX7hJ2Pn7WQ8oLjJM2P+FpD/sLj916jAwJRDC7bVWaaeVtAkH3B5r9s5 + * VA1lddkVQZQBr17s9o3x/61k/iCa11zr/qYfCGSji3ZVrR47KGAuhyXoqq8fxmRG + * ILdwfzzeSNuWU7c5d+Qa4scWhHaXWy+7GRWF+GmF9ZmnqfI0p6m2pgP8b4Y9VHx2 + * BJtr+UBdADTHLpl1neWIA6pN+APSQnbAGwIDAKiLo0UwQzASBgNVHRMBAf8ECDAG + * AQH/AgEEMA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUzPpnk/C2uNClwB7zU/2M + * U9+D15YwDQYJKoZIhvcNAQELBQADggEBAKt/7hwWqZw8UQCgwBEIBaeZ5m8BiFRh + * bvG5GK1Krf6BQCOUL/t1fC8oS2IkgYIL9WHxHG64YTjrgfpioTtaYtOUZcTh5m2C + * +C8lcLIhJsFyUR+MLMOEkMNaj7rP9KdlpeuY0fsFskZ1FSNqb4VjMIDw1Z4fKRzC + * bLBQWV2QWzuoDTDPv31/zvGdg73JRm4gpvlhUbohL3u+pRVjodSVh/GeufOJ8z2F + * uLjbvrW5KfnaNwUASZQDhETnv0Mxz3WLJdH0pmT1kvarBes96aULNmLazAZfNou2 + * XjG4Kvte9nHfRCaexOYNkbQudZWAUWpLMKawYqGT8ZvYzsRjdT9ZR7E= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02HU1\x110\x0f\x06\x03U\x04\x07\x0c\x08Budapest1\x150\x13\x06\x03U\x04\n\x0c\x0cNetLock Kft.1705\x06\x03U\x04\x0b\x0c.Tan\xc3\xbas\xc3\xadtv\xc3\xa1nykiad\xc3\xb3k (Certification Services)1503\x06\x03U\x04\x03\x0c,NetLock Arany (Class Gold) F\xc5\x91tan\xc3\xbas\xc3\xadtv\xc3\xa1ny"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x01\x0f\x000\x82\x01\n\x02\x82\x01\x01\x00\xc4$^s\xbeKm\x14\xc3\xa1\xf4\xe3\x97\x90n\xd20E\x1e<\xeeg\xd9d\xe0\x1a\x8a\x7f\xca0\xca\x83\xe3 \xc1\xe3\xf4:\xd3\x94_\x1a|[m\xbf0O\x84\'\xf6\x9f\x1fI\xbc\xc6\x99\n\x90\xf2\x0f\xf5\x7fC\x847cQ\x8bz\xa5p\xfczX\xcd\x8e\x9b\xed\xc3Fl\x84p]\xda\xf3\x01\x90#\xfcN0\xa9~\xe1\'c\xe7\xedd<\xa0\xb8\xc93c\xfe\x16\x90\xff\xb0\xb8\xfd\xd7\xa8\xc0\xc0\x94C\x0b\xb6\xd5Y\xa6\x9eV\xd0$\x1fpy\xaf\xdb9T\reu\xd9\x15A\x94\x01\xaf^\xec\xf6\x8d\xf1\xff\xadd\xfe \x9a\xd7\\\xeb\xfe\xa6\x1f\x08d\xa3\x8bvU\xad\x1e;(`.\x87%\xe8\xaa\xaf\x1f\xc6dF \xb7p\x7f<\xdeH\xdb\x96S\xb79w\xe4\x1a\xe2\xc7\x16\x84v\x97[/\xbb\x19\x15\x85\xf8i\x85\xf5\x99\xa7\xa9\xf24\xa7\xa9\xb6\xa6\x03\xfco\x86=T|v\x04\x9bk\xf9@]\x004\xc7.\x99u\x9d\xe5\x88\x03\xaaM\xf8\x03\xd2Bv\xc0\x1b\x02\x03\x00\xa8\x8b"), + name_constraints: None + }, + + /* + * Issuer: CN=Certainly Root R1 O=Certainly + * Subject: CN=Certainly Root R1 O=Certainly + * Label: "Certainly Root R1" + * Serial: 188833316161142517227353805653483829216 + * SHA256 Fingerprint: 77:b8:2c:d8:64:4c:43:05:f7:ac:c5:cb:15:6b:45:67:50:04:03:3d:51:c6:0c:62:02:a8:e0:c3:34:67:d3:a0 + * -----BEGIN CERTIFICATE----- + * MIIFRzCCAy+gAwIBAgIRAI4P+UuQcWhlM1T01EQ5t+AwDQYJKoZIhvcNAQELBQAw + * PTELMAkGA1UEBhMCVVMxEjAQBgNVBAoTCUNlcnRhaW5seTEaMBgGA1UEAxMRQ2Vy + * dGFpbmx5IFJvb3QgUjEwHhcNMjEwNDAxMDAwMDAwWhcNNDYwNDAxMDAwMDAwWjA9 + * MQswCQYDVQQGEwJVUzESMBAGA1UEChMJQ2VydGFpbmx5MRowGAYDVQQDExFDZXJ0 + * YWlubHkgUm9vdCBSMTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANA2 + * 1B/q3avk0bbm+yLA3RMNansiExyXPGhjZjKcA7WNpIGD2ngwEc/csiu+kr+O5MQT + * vqRoTNoCaBZ0vrLdBORrKt03H2As2/X3oXyVtwxwhi7xOu9S98zTm/mLvg7fMbed + * aFySpvXl8wo0tf97ouSHocavFwDvA5HtqRxOcT3Si2yJ9HiG5mpJoM610rCrm/b0 + * 1C7jcvk2xusVtyWMOvwlDbMicyF0yEqWYZL1LwsYpfSt4u5BvQF5+paMjRcCMLT5 + * r3gajLQ2EBAHBXDQ9DGQilHFhiZ5shGIXsXwClTNSaa/ApzSRKft43jvRl5tcdF5 + * cBxGX1HpyTfcX35pe0HfNEXgO4T0oYoKNp43zGJS4YkNKPl6I7ENPT2a/Z2B7yyQ + * wHtETrtJ4A5KVpK8y7XdeReJkd5hiXSSqOMyhb5OhaRLWcsrxXiOcVTQAjeZjOVJ + * 6uBUcqQRBi8LjMFbvrWhsFNunLhgkR9Za/kt9JQKl7XsxXYDVBtlUrpMklZRNaBA + * 2CnbrlJ2Oy0wQJuK0EJWtLeIAaSHO1OWzaMWj/Nmqhexx2DgwUMFDO6bW2BvBlyH + * Wyf5QBGenDPBt+U1VwV/J84XIIwc/PH72jEpSe31C4SnT8H2TsIonPru4K8H+zMR + * eiFPCyEQtkA6qyI6BJyLm4SGcprSp6XEtHWRqSsjAgMBAAGjQjBAMA4GA1UdDwEB + * /wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTgqj8ljZ9EXME66C6u + * d0yEPmcM9DANBgkqhkiG9w0BAQsFAAOCAgEAuVevuBLaV4OPaAszHQNTVfSVcOQr + * PbA56/qJYv331hgELyE03fFo8NWWWt7CgKPBjcZq91l3rhVkz1t5BXdm6ozTaw3d + * 8VkswTOlMIAVRQdFGjEitpIAq5lNOo93r6kiyi9jyhXWx8bwPWz8HA2YEGGeEaIi + * 1wrykXprOQ4vMMM2SZ/g6Q8CRFA3lFV96p/2O7qUpUzpvD5RtOjKkjZUbVwlKNrd + * rRT90+7iIgXr0PK3aBLXWopBGsaSpVo7Y0VPv+E6dyIvXL9G+VoDhRNCX8reU9di + * taY1BMJH/5n9hN9czulegChB8n3nHpDYT3Y+gjwN/KUD+nsa2UUeYNrEjvn8K8l7 + * lcUq/6qJ34IxD3L/DCfXCh5WAFAeDJDBlrXYFIW7pw0WwfgHJBu6haEaBQmAupVj + * yTrsJZ9/nbqkRxWbRHDxakvWOF5D8xh+UG7pWijmZeZ3Gzr9Hb4DJqPb1OG7fpYn + * Kx3upPvaJVQTA945xsMfTZDsjxtK0hzthZU4UHlG1sGQUDGpXJpuHfUzVounmdLy + * yCwzk5Iwx06MZTMQZBf9JBeW0Y3COmor6xOLRPIh80oat3df1+2IpHLlOR+Vnb5n + * wXARPbv0+Em34yaXOp/SX3z7wJl8OSngex2/DaeP0ik0biQVy96QXr8axGbqwua6 + * OV+KmalBWQewLK8= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1\x120\x10\x06\x03U\x04\n\x13\tCertainly1\x1a0\x18\x06\x03U\x04\x03\x13\x11Certainly Root R1"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xd06\xd4\x1f\xea\xdd\xab\xe4\xd1\xb6\xe6\xfb\"\xc0\xdd\x13\rj{\"\x13\x1c\x97+\x1c\x1f\x18Lq\xaa5\x8c\xad\xf8n\xe8;J\xd9\xe5\x94\x02\xd6\x89\x84\x13\xaam\xc8O3\xccP\x967\x923\xdc_\x88\xe7\x9fT\xd9H\xf0\x98C\xd6f\xfd\x9f\x178C\xc5\x01Q\x0b\xd7\xe3#\x0f\x14][\x14\xe7K\xbe\xdd\xf4\xc8\xda\x037\xd1\xd69\xa1!Q0\x83\xb0m\xd70N\x96[\x91\xf0p$\xab\xbfE\x81dC\r\xbd!:/<\xe9\x9e\r\xcb \xb5B\'\xcc\xdao\x9b\xeed0\x909\xcd\x93e\x81!1\xb5#P37\"\xe38\xed\xf810\xccE\xfeb\xf9\xd1]2yB\x87\xdfj\xccV\x19@M\xce\xaa\xbb\xf9\xb5vI\x94\xf1\'\xf8\x91\xa5\x83\xe5\x06\xb3c\x0e\x80\xdc\xe0\x12U\x80\xa6;f\xb49\x87-\xc8\xf0\xd0\xd1\x14\xe9\xe4\rM\x0e\xf6]Wr\xc5;\x1cGV\x9d\xe2\xd5\xfb\x81a\x8c\xccM\x80\x904[\xb7\xd7\x14u\xdc\xd8\x04H\x9f\xc0\xc1(\x88\xb4\xe9\x1c\xca\xa7\xb1\xf1V\xb7{ILY\xe5 \x15\xa8\x84\x02)\xfa8\x94i\x9aI\x06\x8f\xcd\x1fy\x14\x17\x12\x0c\x83z\xde\x1f\xb1\x97\xee\xf9\x97x(\xa4\xc8D\x92\xe9}&\x05\xa6Xr\x9by\x13\xd8\x11_\xae\xc58b4h\xb2\x860\x8e\xf8\x90a\x9e2l\xf5\x076\xcd\xa2Ln\xec\x8a6\xed\xf2\xe6\x99\x15Dp\xc3|\xbc\x9c9\xc0\xb4\xe1k\xf7\x83%#W\xd9\x12\x80\xe5I\xf0u\x0f\xef\x8d\xeb\x1c\x9bT(\xb4!<\xfc|\n\xff\xef{ku\xff\x8b\x1d\xa0\x19\x05\xab\xfa\xf8+\x81B\xe88\xba\xbb\xfb\xaa\xfd=\xe0\xf3\xca\xdfN\x97\x97)\xed\xf3\x18V\xe9\xa5\x96\xac\xbd\xc3\x90\x98\xb2\xe0\xf9\xa2\xd4\xa6GC|m\xcf\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=DigiCert Assured ID Root G2 O=DigiCert Inc OU=www.digicert.com + * Subject: CN=DigiCert Assured ID Root G2 O=DigiCert Inc OU=www.digicert.com + * Label: "DigiCert Assured ID Root G2" + * Serial: 15385348160840213938643033620894905419 + * SHA256 Fingerprint: 7d:05:eb:b6:82:33:9f:8c:94:51:ee:09:4e:eb:fe:fa:79:53:a1:14:ed:b2:f4:49:49:45:2f:ab:7d:2f:c1:85 + * -----BEGIN CERTIFICATE----- + * MIIDljCCAn6gAwIBAgIQC5McOtY5Z+pnI7/Dr5r0SzANBgkqhkiG9w0BAQsFADBl + * MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 + * d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJv + * b3QgRzIwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1MTIwMDAwWjBlMQswCQYDVQQG + * EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNl + * cnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzIwggEi + * MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDZ5ygvUj82ckmIkzTz+GoeMVSA + * n61UQbVH35ao1K+ALbkKz3X9iaV9JPrjIgwrvJUXCzO/GU1BBpAAvQxNEP4Htecc + * biJVMWWXvdMX0h5i89vqbFCMP4QMls+3ywPgym2hFEwbid3tALBSfK+RbLE4E9Hp + * EgjAALAcKxHad3A2m67OeYfcgnDmCXRwVWmvo2ifv922ebPynXApVfSr/5Vh88lA + * bx3RvpO704gqu52/clpWcTs/1PPRCv4o76Pu2ZmvA9OPYLfykqGxvYmJHzDNw6Yu + * YjOuFgJ3RFrngQo8p0Quebg/BLxcoIfhG69Rjs3sLPr4/m3wOnyqi+RnlTGNAgMB + * AAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQW + * BBTOw0q5mVXyuNtgv6l+vVa1lzan1jANBgkqhkiG9w0BAQsFAAOCAQEAyqVVjOPI + * QW5pJ6d1Ee88hjZv0p3GeDgdaZaikmkuOGybfQTUiaWxMTeKySHMq2zNixya1r9I + * 0jJmwYrA8y8678Dj1JGG0VDjA9tzd29KOVPt3ibHtX2vK0LRdWLjSisCx1BL4Gni + * lmwORGYQRI+tBev4eaymG+g3NJ1TyWGqolKvSnAWhsI6yLETcDbYz+70CjTVW0z9 + * B5yiutkBclzzTcHdDrEcDcRjvq30FPuJ7KJBDkzMyFdA0G4Dqs0MjomZmWzwPDCv + * ON9vvKO+KSAnq3T/EyJ43pdSVR6DtVQgA+6uwE9W3jfMw3+qBCe703e4YtsXfJwo + * IhNzbM8m9Yop5w== + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1\x150\x13\x06\x03U\x04\n\x13\x0cDigiCert Inc1\x190\x17\x06\x03U\x04\x0b\x13\x10www.digicert.com1$0\"\x06\x03U\x04\x03\x13\x1bDigiCert Assured ID Root G2"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x01\x0f\x000\x82\x01\n\x02\x82\x01\x01\x00\xd9\xe7(/R?6rI\x88\x934\xf3\xf8j\x1e1T\x80\x9f\xadTA\xb5G\xdf\x96\xa8\xd4\xaf\x80-\xb9\n\xcfu\xfd\x89\xa5}$\xfa\xe3\"\x0c+\xbc\x95\x17\x0b3\xbf\x19MA\x06\x90\x00\xbd\x0cM\x10\xfe\x07\xb5\xe7\x1cn\"U1e\x97\xbd\xd3\x17\xd2\x1eb\xf3\xdb\xealP\x8c?\x84\x0c\x96\xcf\xb7\xcb\x03\xe0\xcam\xa1\x14L\x1b\x89\xdd\xed\x00\xb0R|\xaf\x91l\xb18\x13\xd1\xe9\x12\x08\xc0\x00\xb0\x1c+\x11\xdawp6\x9b\xae\xcey\x87\xdc\x82p\xe6\ttpUi\xaf\xa3h\x9f\xbf\xdd\xb6y\xb3\xf2\x9dp)U\xf4\xab\xff\x95a\xf3\xc9@o\x1d\xd1\xbe\x93\xbb\xd3\x88*\xbb\x9d\xbfrZVq;?\xd4\xf3\xd1\n\xfe(\xef\xa3\xee\xd9\x99\xaf\x03\xd3\x8f`\xb7\xf2\x92\xa1\xb1\xbd\x89\x89\x1f0\xcd\xc3\xa6.b3\xae\x16\x02wDZ\xe7\x81\n<\xa7D.y\xb8?\x04\xbc\\\xa0\x87\xe1\x1b\xafQ\x8e\xcd\xec,\xfa\xf8\xfem\xf0:|\xaa\x8b\xe4g\x951\x8d\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=DigiCert Assured ID Root G3 O=DigiCert Inc OU=www.digicert.com + * Subject: CN=DigiCert Assured ID Root G3 O=DigiCert Inc OU=www.digicert.com + * Label: "DigiCert Assured ID Root G3" + * Serial: 15459312981008553731928384953135426796 + * SHA256 Fingerprint: 7e:37:cb:8b:4c:47:09:0c:ab:36:55:1b:a6:f4:5d:b8:40:68:0f:ba:16:6a:95:2d:b1:00:71:7f:43:05:3f:c2 + * -----BEGIN CERTIFICATE----- + * MIICRjCCAc2gAwIBAgIQC6Fa+h3foLVJRK/NJKBs7DAKBggqhkjOPQQDAzBlMQsw + * CQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cu + * ZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3Qg + * RzMwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1MTIwMDAwWjBlMQswCQYDVQQGEwJV + * UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQu + * Y29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwdjAQBgcq + * hkjOPQIBBgUrgQQAIgNiAAQZ57ysRGXtzbg/WPuNsVepRC0FFfLvC/8QdJ+1YlJf + * Zn4f5dwbRXkLzMZTCp2NXQLZqVneAlr2lSoOjThKiknGvMYDOAdfVdp+CW7if17Q + * RSAPWXYQ1qAk8C3eNvJsKTmjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/ + * BAQDAgGGMB0GA1UdDgQWBBTL0L2p4ZgFUaFNN6KDec6NHSrkhDAKBggqhkjOPQQD + * AwNnADBkAjAlpIFFAmsSS3V0T8gj43DydXLefInwz5FyYZ5eEJJZVrmDxxDnOOlY + * JjZ91eQ0hjkCMHw2U/Aw5WJjOpnitqM7mzT6HtoQknFekROn3aRukswy1vUhZscv + * 6pZjamVFkpUBtA== + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1\x150\x13\x06\x03U\x04\n\x13\x0cDigiCert Inc1\x190\x17\x06\x03U\x04\x0b\x13\x10www.digicert.com1$0\"\x06\x03U\x04\x03\x13\x1bDigiCert Assured ID Root G3"), + subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\"\x03b\x00\x04\x19\xe7\xbc\xacDe\xed\xcd\xb8?X\xfb\x8d\xb1W\xa9D-\x05\x15\xf2\xef\x0b\xff\x10t\x9f\xb5bR_f~\x1f\xe5\xdc\x1bEy\x0b\xcc\xc6S\n\x9d\x8d]\x02\xd9\xa9Y\xde\x02Z\xf6\x95*\x0e\x8d8J\x8aI\xc6\xbc\xc6\x038\x07_U\xda~\tn\xe2\x7f^\xd0E \x0fYv\x10\xd6\xa0$\xf0-\xde6\xf2l)9"), + name_constraints: None + }, + + /* + * Issuer: CN=Atos TrustedRoot Root CA RSA TLS 2021 O=Atos + * Subject: CN=Atos TrustedRoot Root CA RSA TLS 2021 O=Atos + * Label: "Atos TrustedRoot Root CA RSA TLS 2021" + * Serial: 111436099570196163832749341232207667876 + * SHA256 Fingerprint: 81:a9:08:8e:a5:9f:b3:64:c5:48:a6:f8:55:59:09:9b:6f:04:05:ef:bf:18:e5:32:4e:c9:f4:57:ba:00:11:2f + * -----BEGIN CERTIFICATE----- + * MIIFZDCCA0ygAwIBAgIQU9XP5hmTC/srBRLYwiqipDANBgkqhkiG9w0BAQwFADBM + * MS4wLAYDVQQDDCVBdG9zIFRydXN0ZWRSb290IFJvb3QgQ0EgUlNBIFRMUyAyMDIx + * MQ0wCwYDVQQKDARBdG9zMQswCQYDVQQGEwJERTAeFw0yMTA0MjIwOTIxMTBaFw00 + * MTA0MTcwOTIxMDlaMEwxLjAsBgNVBAMMJUF0b3MgVHJ1c3RlZFJvb3QgUm9vdCBD + * QSBSU0EgVExTIDIwMjExDTALBgNVBAoMBEF0b3MxCzAJBgNVBAYTAkRFMIICIjAN + * BgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAtoAOxHm9BYx9sKOdTSJNy/BBl01Z + * 4NH+VoyX8te9j2y3I49f1cTYQcvyAh5x5en2XssIKl4w8i1mx4QbZFc4nXUtVsYv + * Ye+W/CBGvevUez8/fEc4BKkbqlLfEzfTFRVOvV98r61jx3ncCHvVoOX3W3WsgFWZ + * kmGbzSoXfduP9LVq6hdKZChmFSlsAvFr1bqjM9xaZ6cF4r9lthawEO3NUDPJcFDs + * GY6wx/J0W2tExn2WuZgIWWbeKQGb9Cpt0xU6kGpn8bRrZtkh68rZYnxGEFzedUln + * nkL5/nWpo63/dgpnQOPF943HhZpZnmKaau1Fh5hnstVKPNe0OwANwI8f4UDErmwh + * 3El+fsqyjW22v5MvoVw+j8rtgI5Y4dtXz4U2OLJxpAmMkokIiEjxQGMYsluMWuPD + * 0xeqqxmjLBvk1cbiZnrXghmmOxYsL3GHX0WelXOTwkKBIROW1527k2gV+p2kHYzy + * geBYBr3JtuP2iV2J+axEoctr+hbxx1A9JNr3w+SH1VbxT5Aw+kUJWdo0zuATHAR8 + * ANSbhqRAvNncTFd+rrcztl524WWLZt+NyteYr842mIycg5kDcPOvdO3GDjbnvezB + * c6eUWsuSZIKmAMFwoW4sKeFYV+xafJlrJaSQOoD0IJ2azsct+bJLKZWD6TWNp0lI + * pw9MGZHQ9b8Q4HECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU + * dEmZ0f+0emhFdcN+tNzMzjkz2ggwDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEB + * DAUAA4ICAQAjQ1MkYlxt/T7Cz1UAbMVWiLkO3TriJQ2VSpfKgInuKs1l+NsW4AmS + * 4BjHeJi78+xCUvuppILXTdiK/ORO/auQxDh1MoSf/7OwKwIzNsAQkG8dnK/haZPs + * o0UvFJ/1TCplQ3IM98P4lYsU84UgYt1UU90s3BiVaU+DR3BAM1h3Egyi61IxHkzJ + * qM7F78PRreBrAwA0JrRUITWXAdxfG/F851X6LWh3e9NpzNMOa7pNdkTWwhWaJuyw + * xfW70Xp0wmzNxbVe9kzmWy2B27O3Opee7c9GslA9hGCZcbUztVdF5kJHdWoOsAgM + * rr3e97sPWD2PAzHoPYJQyi9eDF20l74gNAf0xBLh7tew2VktafcxBPTy+av5EzH4 + * AXcOPUIjJsyacmdRIXrMPIWo6iFqO9taPKU0nprALN+AnCng33eU0aKAQv9qTFsR + * 0PXNor6uzFFcw9VUewyu1rkGd4Di7wcaaMxZUa1+XGdrudviB0JbuAEFWDlN5LuY + * o7Ey7Nmj1m+UI/87tyll5gfp77YZ6ufCOB0yiJA8EytuzO+rdwY0d4RPcuSBhPm5 + * dDTedk+SKlOxJTnbPP/lPqYO5Wue/9vsL3SD3460s6neFE3/MaNFcyT6lSnMEpcE + * oji2jbDwN/zIIX8/syQbPYtuzE2wFg2WHYMfRsCbvUOZ58SWLs5fyQ== + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1.0,\x06\x03U\x04\x03\x0c%Atos TrustedRoot Root CA RSA TLS 20211\r0\x0b\x06\x03U\x04\n\x0c\x04Atos1\x0b0\t\x06\x03U\x04\x06\x13\x02DE"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xb6\x80\x0e\xc4y\xbd\x05\x8c}\xb0\xa3\x9dM\"M\xcb\xf0A\x97MY\xe0\xd1\xfeV\x8c\x97\xf2\xd7\xbd\x8fl\xb7#\x8f_\xd5\xc4\xd8A\xcb\xf2\x02\x1eq\xe5\xe9\xf6^\xcb\x08*^0\xf2-f\xc7\x84\x1bdW8\x9du-V\xc6/a\xef\x96\xfc F\xbd\xeb\xd4{??|G8\x04\xa9\x1b\xaaR\xdf\x137\xd3\x15\x15N\xbd_|\xaf\xadc\xc7y\xdc\x08{\xd5\xa0\xe5\xf7[u\xac\x80U\x99\x92a\x9b\xcd*\x17}\xdb\x8f\xf4\xb5j\xea\x17Jd(f\x15)l\x02\xf1k\xd5\xba\xa33\xdcZg\xa7\x05\xe2\xbfe\xb6\x16\xb0\x10\xed\xcdP3\xc9pP\xec\x19\x8e\xb0\xc7\xf2t[kD\xc6}\x96\xb9\x98\x08Yf\xde)\x01\x9b\xf4*m\xd3\x15:\x90jg\xf1\xb4kf\xd9!\xeb\xca\xd9b|F\x10\\\xdeuIg\x9eB\xf9\xfeu\xa9\xa3\xad\xffv\ng@\xe3\xc5\xf7\x8d\xc7\x85\x9aY\x9eb\x9aj\xedE\x87\x98g\xb2\xd5J<\xd7\xb4;\x00\r\xc0\x8f\x1f\xe1@\xc4\xael!\xdcI~~\xca\xb2\x8dm\xb6\xbf\x93/\xa1\\>\x8f\xca\xed\x80\x8eX\xe1\xdbW\xcf\x8568\xb2q\xa4\t\x8c\x92\x89\x08\x88H\xf1@c\x18\xb2[\x8cZ\xe3\xc3\xd3\x17\xaa\xab\x19\xa3,\x1b\xe4\xd5\xc6\xe2fz\xd7\x82\x19\xa6;\x16,/q\x87_E\x9e\x95s\x93\xc2B\x81!\x13\x96\xd7\x9d\xbb\x93h\x15\xfa\x9d\xa4\x1d\x8c\xf2\x81\xe0X\x06\xbd\xc9\xb6\xe3\xf6\x89]\x89\xf9\xacD\xa1\xcbk\xfa\x16\xf1\xc7P=$\xda\xf7\xc3\xe4\x87\xd5V\xf1O\x900\xfaE\tY\xda4\xce\xe0\x13\x1c\x04|\x00\xd4\x9b\x86\xa4@\xbc\xd9\xdcLW~\xae\xb73\xb6^v\xe1e\x8bf\xdf\x8d\xca\xd7\x98\xaf\xce6\x98\x8c\x9c\x83\x99\x03p\xf3\xaft\xed\xc6\x0e6\xe7\xbd\xec\xc1s\xa7\x94Z\xcb\x92d\x82\xa6\x00\xc1p\xa1n,)\xe1XW\xecZ|\x99k%\xa4\x90:\x80\xf4 \x9d\x9a\xce\xc7-\xf9\xb2K)\x95\x83\xe95\x8d\xa7IH\xa7\x0fL\x19\x91\xd0\xf5\xbf\x10\xe0q\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=OISTE WISeKey Global Root GC CA O=WISeKey OU=OISTE Foundation Endorsed + * Subject: CN=OISTE WISeKey Global Root GC CA O=WISeKey OU=OISTE Foundation Endorsed + * Label: "OISTE WISeKey Global Root GC CA" + * Serial: 44084345621038548146064804565436152554 + * SHA256 Fingerprint: 85:60:f9:1c:36:24:da:ba:95:70:b5:fe:a0:db:e3:6f:f1:1a:83:23:be:94:86:85:4f:b3:f3:4a:55:71:19:8d + * -----BEGIN CERTIFICATE----- + * MIICaTCCAe+gAwIBAgIQISpWDK7aDKtARb8roi066jAKBggqhkjOPQQDAzBtMQsw + * CQYDVQQGEwJDSDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUgRm91 + * bmRhdGlvbiBFbmRvcnNlZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwg + * Um9vdCBHQyBDQTAeFw0xNzA1MDkwOTQ4MzRaFw00MjA1MDkwOTU4MzNaMG0xCzAJ + * BgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYDVQQLExlPSVNURSBGb3Vu + * ZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEdsb2JhbCBS + * b290IEdDIENBMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAETOlQwMYPchi82PG6s4ni + * eUqjFqdrVCTbUf/q9Akkwwsin8tqJ4KBDdLArzHkdIJuyiXZjHWd8dvQmqJLIX4W + * p2OQ0jnUsYd4XxiWD1AbNTcPasbc2RNNpI6QN+a9WzGRo1QwUjAOBgNVHQ8BAf8E + * BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUSIcUrOPDnpBgOtfKie7T + * rYy0UGYwEAYJKwYBBAGCNxUBBAMCAQAwCgYIKoZIzj0EAwMDaAAwZQIwJsdpW9zV + * 57LnyAyMjMPdeYwbY9XJUpROTYJKcx6ygISpJcBMWm1JKWB4E+J+SOtkAjEA2zQg + * Mgj/mkkCtojeFK9dbJlxjRo/i9fgojaGHAeCOnZT/cKi7e97sIBPWA9LUzm9 + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02CH1\x100\x0e\x06\x03U\x04\n\x13\x07WISeKey1\"0 \x06\x03U\x04\x0b\x13\x19OISTE Foundation Endorsed1(0&\x06\x03U\x04\x03\x13\x1fOISTE WISeKey Global Root GC CA"), + subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\"\x03b\x00\x04L\xe9P\xc0\xc6\x0fr\x18\xbc\xd8\xf1\xba\xb3\x89\xe2yJ\xa3\x16\xa7kT$\xdbQ\xff\xea\xf4\t$\xc3\x0b\"\x9f\xcbj\'\x82\x81\r\xd2\xc0\xaf1\xe4t\x82n\xca%\xd9\x8cu\x9d\xf1\xdb\xd0\x9a\xa2K!~\x16\xa7c\x90\xd29\xd4\xb1\x87x_\x18\x96\x0fP\x1b57\x0fj\xc6\xdc\xd9\x13M\xa4\x8e\x907\xe6\xbd[1\x91"), + name_constraints: None + }, + + /* + * Issuer: CN=SSL.com Root Certification Authority RSA O=SSL Corporation + * Subject: CN=SSL.com Root Certification Authority RSA O=SSL Corporation + * Label: "SSL.com Root Certification Authority RSA" + * Serial: 8875640296558310041 + * SHA256 Fingerprint: 85:66:6a:56:2e:e0:be:5c:e9:25:c1:d8:89:0a:6f:76:a8:7e:c1:6d:4d:7d:5f:29:ea:74:19:cf:20:12:3b:69 + * -----BEGIN CERTIFICATE----- + * MIIF3TCCA8WgAwIBAgIIeyyb0xaAMpkwDQYJKoZIhvcNAQELBQAwfDELMAkGA1UE + * BhMCVVMxDjAMBgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQK + * DA9TU0wgQ29ycG9yYXRpb24xMTAvBgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZp + * Y2F0aW9uIEF1dGhvcml0eSBSU0EwHhcNMTYwMjEyMTczOTM5WhcNNDEwMjEyMTcz + * OTM5WjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAOBgNVBAcMB0hv + * dXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NMLmNv + * bSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFJTQTCCAiIwDQYJKoZIhvcN + * AQEBBQADggIPADCCAgoCggIBAPkP3aMrfcvQKv7sZ4Wm5y4bunfh4/WvpOz6Sl2R + * xFdHaxh3a3by/ZPkPQ/CFp4LZsNWlJ4Xg4XOVu/yFv0AYvUiCVToZRdOQbngT0aX + * qhvIuG5iXmmxX9sqAn78bMrzQdjt0Oj8P2FI7bADFB0QDksZ4LtO7IZl/zbzXmcC + * C52GVWH9ejjt/uIZALdvoVBidXQ8oPrIJZK0bnoix/geoeOy3ZExqysdBP+lSgQ3 + * 6YWkMyv94tZVNHwZpEpox7Ko07fKoZOI68GXvIz5HdkihCR0xwQ9aqkpk8zruFvh + * /l8lqjRYyMEjVJ0bmBHDOJx+PYZspQ9AhnwC9FwCTyjLrnGfDzrIM/4RJTXq/LrF + * YD3ZfBjVsqnTdXgDciLKOsMf7yzlLqn6niy2UUb9rwPW6mBo6oUWNmuF6R7As93E + * JNyAKoFBbZQ+yODJgUEAnl6/f8UImKIYLEJAs/lvOCdLToD0PYFH4Ih86hzOtXVc + * US4cK38acijnALXRdMbX5J+tB5O2UzU1/Dfkw/ZdFr4hc96SCvigY2q8lpJqPvi8 + * ZVWb3vUNiSYE/CUapiVpy8JtynziWV+XrOvvLsi81xtZPCvM8hnIk2snYxnP/Okm + * +Mpxm3+T/jRnhE6Z6/yzeAkzcLpmpnbtG3PrGqUNxCITIJRWCk4sbE6x/c+cCbqi + * M+2HAgMBAAGjYzBhMB0GA1UdDgQWBBTdBAkHovV6fVJTEpKV7jiAJQ2mWTAPBgNV + * HRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFN0ECQei9Xp9UlMSkpXuOIAlDaZZMA4G + * A1UdDwEB/wQEAwIBhjANBgkqhkiG9w0BAQsFAAOCAgEAIBgRlCn7Jp0cHh5wYfGV + * cpNxJK1ok1iOMq8bs3AD/CUrdIWQPXhq9LmLpZc7tRiRux6n+UBbkflVma8eEdBc + * Hadm47GUBwwyOabqG7B52B2ccETjit3E+ZUfijhDPwGFpUenPUayvOUiaPd7nNgs + * PgohyC0zrL/FgZkxdMF1ccW+sfAjRfSda/wZY52jvATGGAslu1OJD7OAUN5F7kR/ + * q5R4ZJjT9ijdh9hwZXT7DrkT66cPYakylszeu+1jTBi7qUD3oFRuIIhxdRjqerQ0 + * cuAjJ3dctpDqhiVAq+8zD8ufgr6iIPv2tS0a5sKFsXQP+8hlAqRSAUfdSSLBv9jr + * a6x+3uxjMxW3IwiPxg+NQVrdjsW5j+VFP3jbutIbQLH+cU0/4IGiul607BXgk90I + * H37hVZkLId6Tngr75qNJvTYw/ud3sqB1l7UtgYgXZSD32pAAn8lSzDLKNXz1PQ/Y + * K9f1JmzJBjSWFupwWRoyeXkLtoh/D1JIPb9s2KJELtFOt3JY04kTlf5Eq/jXixtu + * nLwsoFvVagCvXzfh1foQC5ichucmj87w7G6KVwuA406ywKBjYZC6VWg3dGq2ktuf + * oYYitmUnDuy2n0Jg5GfCtdpBC8TTi2EbvPofkSvXRAdeuims2cXp71NIWuuA8ShY + * Ic2wBlX7Jz9TkHCpBB5XJ7k= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1\x0e0\x0c\x06\x03U\x04\x08\x0c\x05Texas1\x100\x0e\x06\x03U\x04\x07\x0c\x07Houston1\x180\x16\x06\x03U\x04\n\x0c\x0fSSL Corporation110/\x06\x03U\x04\x03\x0c(SSL.com Root Certification Authority RSA"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xf9\x0f\xdd\xa3+}\xcb\xd0*\xfe\xecg\x85\xa6\xe7.\x1b\xbaw\xe1\xe3\xf5\xaf\xa4\xec\xfaJ]\x91\xc4WGk\x18wkv\xf2\xfd\x93\xe4=\x0f\xc2\x16\x9e\x0bf\xc3V\x94\x9e\x17\x83\x85\xceV\xef\xf2\x16\xfd\x00b\xf5\"\tT\xe8e\x17NA\xb9\xe0OF\x97\xaa\x1b\xc8\xb8nb^i\xb1_\xdb*\x02~\xfcl\xca\xf3A\xd8\xed\xd0\xe8\xfc?aH\xed\xb0\x03\x14\x1d\x10\x0eK\x19\xe0\xbbN\xec\x86e\xff6\xf3^g\x02\x0b\x9d\x86Ua\xfdz8\xed\xfe\xe2\x19\x00\xb7o\xa1Pbut<\xa0\xfa\xc8%\x92\xb4nz\"\xc7\xf8\x1e\xa1\xe3\xb2\xdd\x911\xab+\x1d\x04\xff\xa5J\x047\xe9\x85\xa43+\xfd\xe2\xd6U4|\x19\xa4Jh\xc7\xb2\xa8\xd3\xb7\xca\xa1\x93\x88\xeb\xc1\x97\xbc\x8c\xf9\x1d\xd9\"\x84$t\xc7\x04=j\xa9)\x93\xcc\xeb\xb8[\xe1\xfe_%\xaa4X\xc8\xc1#T\x9d\x1b\x98\x11\xc38\x9c~=\x86l\xa5\x0f@\x86|\x02\xf4\\\x02O(\xcb\xaeq\x9f\x0f:\xc83\xfe\x11%5\xea\xfc\xba\xc5`=\xd9|\x18\xd5\xb2\xa9\xd3ux\x03r\"\xca:\xc3\x1f\xef,\xe5.\xa9\xfa\x9e,\xb6QF\xfd\xaf\x03\xd6\xea`h\xea\x85\x166k\x85\xe9\x1e\xc0\xb3\xdd\xc4$\xdc\x80*\x81Am\x94>\xc8\xe0\xc9\x81A\x00\x9e^\xbf\x7f\xc5\x08\x98\xa2\x18,B@\xb3\xf9o8\'KN\x80\xf4=\x81G\xe0\x88|\xea\x1c\xce\xb5u\\Q.\x1c+\x7f\x1ar(\xe7\x00\xb5\xd1t\xc6\xd7\xe4\x9f\xad\x07\x93\xb6S55\xfc7\xe4\xc3\xf6]\x16\xbe!s\xde\x92\n\xf8\xa0cj\xbc\x96\x92j>\xf8\xbceU\x9b\xde\xf5\r\x89&\x04\xfc%\x1a\xa6%i\xcb\xc2m\xca|\xe2Y_\x97\xac\xeb\xef.\xc8\xbc\xd7\x1bY<+\xcc\xf2\x19\xc8\x93k\'c\x19\xcf\xfc\xe9&\xf8\xcaq\x9b\x7f\x93\xfe4g\x84N\x99\xeb\xfc\xb3x\t3p\xbaf\xa6v\xed\x1bs\xeb\x1a\xa5\r\xc4\"\x13 \x94V\nN,lN\xb1\xfd\xcf\x9c\t\xba\xa23\xed\x87\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=emSign ECC Root CA - G3 O=eMudhra Technologies Limited OU=emSign PKI + * Subject: CN=emSign ECC Root CA - G3 O=eMudhra Technologies Limited OU=emSign PKI + * Label: "emSign ECC Root CA - G3" + * Serial: 287880440101571086945156 + * SHA256 Fingerprint: 86:a1:ec:ba:08:9c:4a:8d:3b:be:27:34:c6:12:ba:34:1d:81:3e:04:3c:f9:e8:a8:62:cd:5c:57:a3:6b:be:6b + * -----BEGIN CERTIFICATE----- + * MIICTjCCAdOgAwIBAgIKPPYHqWhwDtqLhDAKBggqhkjOPQQDAzBrMQswCQYDVQQG + * EwJJTjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNo + * bm9sb2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0g + * RzMwHhcNMTgwMjE4MTgzMDAwWhcNNDMwMjE4MTgzMDAwWjBrMQswCQYDVQQGEwJJ + * TjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9s + * b2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0gRzMw + * djAQBgcqhkjOPQIBBgUrgQQAIgNiAAQjpQy4LRL1KPOxst3iAhKAnjlfSU2fySU0 + * WXTsuwYc58Byr+iuL+FBVIcUqEqy6HyC5ltqtdyzdc6LBtCGI79G1Y4PPwT01xyS + * fvalY8L1X44uT6EYGQIrMgqCZH0Wk9GjQjBAMB0GA1UdDgQWBBR8XQKEE9TMipuB + * zhccLikenEhjQjAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggq + * hkjOPQQDAwNpADBmAjEAvvNhzwIQHWSVB7gYboiFBS+DCBeQyh+KTOgNG3qxrdWB + * CUfvO6wIBHxcmbHtRwfSAjEAnbpV/KlK6O3t5nYBQnvI+GDZjVGLVTv7jHvrZQnD + * +JbNR6iC8hZVdyR+EhCVBCyj + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02IN1\x130\x11\x06\x03U\x04\x0b\x13\nemSign PKI1%0#\x06\x03U\x04\n\x13\x1ceMudhra Technologies Limited1 0\x1e\x06\x03U\x04\x03\x13\x17emSign ECC Root CA - G3"), + subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\"\x03b\x00\x04#\xa5\x0c\xb8-\x12\xf5(\xf3\xb1\xb2\xdd\xe2\x02\x12\x80\x9e9_IM\x9f\xc9%4Yt\xec\xbb\x06\x1c\xe7\xc0r\xaf\xe8\xae/\xe1AT\x87\x14\xa8J\xb2\xe8|\x82\xe6[j\xb5\xdc\xb3u\xce\x8b\x06\xd0\x86#\xbfF\xd5\x8e\x0f?\x04\xf4\xd7\x1c\x92~\xf6\xa5c\xc2\xf5_\x8e.O\xa1\x18\x19\x02+2\n\x82d}\x16\x93\xd1"), + name_constraints: None + }, + + /* + * Issuer: CN=QuoVadis Root CA 3 G3 O=QuoVadis Limited + * Subject: CN=QuoVadis Root CA 3 G3 O=QuoVadis Limited + * Label: "QuoVadis Root CA 3 G3" + * Serial: 268090761170461462463995952157327242137089239581 + * SHA256 Fingerprint: 88:ef:81:de:20:2e:b0:18:45:2e:43:f8:64:72:5c:ea:5f:bd:1f:c2:d9:d2:05:73:07:09:c5:d8:b8:69:0f:46 + * -----BEGIN CERTIFICATE----- + * MIIFYDCCA0igAwIBAgIULvWbAiin23r/1aOp7r0DoM8Sah0wDQYJKoZIhvcNAQEL + * BQAwSDELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAc + * BgNVBAMTFVF1b1ZhZGlzIFJvb3QgQ0EgMyBHMzAeFw0xMjAxMTIyMDI2MzJaFw00 + * MjAxMTIyMDI2MzJaMEgxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM + * aW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDMgRzMwggIiMA0GCSqG + * SIb3DQEBAQUAA4ICDwAwggIKAoICAQCzyw4QZ47qFJenMioKVjZ/aEzHs286IxSR + * /xl/pcqs7rN2nXrpixurazHb+gtTTK/FpRp5PIpM/6zfJd5O2YIyC0TeytuMrKNu + * FoM7pmRLMon7FhY4futD4tN0SsJiCnMK3UmzV9KwCoWdcTzeo8vAMvMBOSBDGzXR + * U7Ox7sWTaYI+FrUoRqHe6okJ7UO4BUaKhvVZR74bbwEhELn9qdIoyhA5CcoTNs+c + * ra1AdHkrAj80//ogaX3T7mH1urPnMNA3I4ZyYUUpSFlob3emLoG+B01vr87ERROR + * FHAGjx+f+IdpsQ7vw4kZ6+ocYfx6bIrc1gMLnia6Et3UVDmrJqMz6nWB2i3ND0/k + * A9HvFZcba5DFApCTZgIhsUfei5pKgLlVj7WiL8DWM2fafsSntARE60f75li59wzw + * eyuxwHApw0BiLTtIadwjPEjrewl5qW3aqDCYz4ByA4imW0aucnl8CAMhZa634Ryl + * sSqiMd5mBPfAdOhx3v89WcyWJhKLhZVXGqtrdQtEPREoPHtht+KPZ0/l7DxMYIBp + * VzgeAVuNVejH38DMdyM0SXV89pgR6y3e7UEuFAUCf+D+IOs15xGsIs5XPd7JMG0Q + * A4XN8f+MFrXBsj6IbGB/kE+V9/YtrQE5BwT6dYB9v0lQ7e/JxHwc64B+27bQ3RP+ + * ydOc17KXqQIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIB + * BjAdBgNVHQ4EFgQUxhfQvKjqAkPyGwaZXSuQILnXnOQwDQYJKoZIhvcNAQELBQAD + * ggIBADRh2Va1EodVTd2jNTFGu6QHcrxfYWLopfsLN7E8trP6KZ1/AvWkyaiTt3px + * KGmPc+FSkNrVvjrlt3ZqVoAh313m6Tqe5T72omnHKgqwGEfcIHB9UqM+WXzBusnI + * FUBhynLWcKzSt/Ac5IYp8M7vaGPQtSCKFWGafoaYtMnCdvvMujAWzKNhxnQT5Wvv + * oxXqA/4Ti2Tk08HS6IT7SdEQTXlm66r99I0xHnAUrdzeZxNMgRVhvLfZkXdxGYFg + * u/BYpbWcC/ePIlUnwEsBbTuZDdQdm2NnL9DuDcpmvJRPpq3t/O5jrFc/ZSXPsoaP + * 0Aj/uHYUbt7lJ+yreLVTubY/6CD50qi+YUbKh4yE8/nxoGibIh6BJpsQBJFxwAYf + * 3KDTuVan45gtf4Od34wrnDKOMpTwATwiKp9Dwi7DmDkHOHv8XgBCH/MyJnmDhPbl + * 8MFREsALHgQjDFSlTC9JxUrRtm5gDWv8a4uFJGS3iQ6rJUdbPM9+Sb3H6QrG2vd+ + * DhcI00iX0HGS8A85PjRqHH3Y8iKuu2n0M7SmSFXRDw4m6Oy2Cy2nhTXN/VnIn9HN + * PlopNLk9hM6xZdRZkZFWdSHBd575euFgndOtBBj0fOtek49TSiIp+EgrPk2GrFt/ + * ywaZWWDYWGWVjUTR939+J399roD1B0y2PpxxVJkES/1Y+Zj0 + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02BM1\x190\x17\x06\x03U\x04\n\x13\x10QuoVadis Limited1\x1e0\x1c\x06\x03U\x04\x03\x13\x15QuoVadis Root CA 3 G3"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xb3\xcb\x0e\x10g\x8e\xea\x14\x97\xa72*\nV6\x7fhL\xc7\xb3o:#\x14\x91\xff\x19\x7f\xa5\xca\xac\xee\xb3v\x9dz\xe9\x8b\x1b\xabk1\xdb\xfa\x0bSL\xaf\xc5\xa5\x1ay<\x8aL\xff\xac\xdf%\xdeN\xd9\x822\x0bD\xde\xca\xdb\x8c\xac\xa3n\x16\x83;\xa6dK2\x89\xfb\x16\x168~\xebC\xe2\xd3tJ\xc2b\ns\n\xddI\xb3W\xd2\xb0\n\x85\x9dq<\xde\xa3\xcb\xc02\xf3\x019 C\x1b5\xd1S\xb3\xb1\xee\xc5\x93i\x82>\x16\xb5(F\xa1\xde\xea\x89\t\xedC\xb8\x05F\x8a\x86\xf5YG\xbe\x1bo\x01!\x10\xb9\xfd\xa9\xd2(\xca\x109\t\xca\x136\xcf\x9c\xad\xad@ty+\x02?4\xff\xfa i}\xd3\xeea\xf5\xba\xb3\xe70\xd07#\x86raE)HYhow\xa6.\x81\xbe\x07Mo\xaf\xce\xc4E\x13\x91\x14p\x06\x8f\x1f\x9f\xf8\x87i\xb1\x0e\xef\xc3\x89\x19\xeb\xea\x1ca\xfczl\x8a\xdc\xd6\x03\x0b\x9e&\xba\x12\xdd\xd4T9\xab&\xa33\xeau\x81\xda-\xcd\x0fO\xe4\x03\xd1\xef\x15\x97\x1bk\x90\xc5\x02\x90\x93f\x02!\xb1G\xde\x8b\x9aJ\x80\xb9U\x8f\xb5\xa2/\xc0\xd63g\xda~\xc4\xa7\xb4\x04D\xebG\xfb\xe6X\xb9\xf7\x0c\xf0{+\xb1\xc0p)\xc3@b-;Hi\xdc#\x88l`\x7f\x90O\x95\xf7\xf6-\xad\x019\x07\x04\xfau\x80}\xbfIP\xed\xef\xc9\xc4|\x1c\xeb\x80~\xdb\xb6\xd0\xdd\x13\xfe\xc9\xd3\x9c\xd7\xb2\x97\xa9\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=NAVER Global Root Certification Authority O=NAVER BUSINESS PLATFORM Corp. + * Subject: CN=NAVER Global Root Certification Authority O=NAVER BUSINESS PLATFORM Corp. + * Label: "NAVER Global Root Certification Authority" + * Serial: 9013692873798656336226253319739695165984492813 + * SHA256 Fingerprint: 88:f4:38:dc:f8:ff:d1:fa:8f:42:91:15:ff:e5:f8:2a:e1:e0:6e:0c:70:c3:75:fa:ad:71:7b:34:a4:9e:72:65 + * -----BEGIN CERTIFICATE----- + * MIIFojCCA4qgAwIBAgIUAZQwHqIL3fXFMyqxQ0Rx+NZQTQ0wDQYJKoZIhvcNAQEM + * BQAwaTELMAkGA1UEBhMCS1IxJjAkBgNVBAoMHU5BVkVSIEJVU0lORVNTIFBMQVRG + * T1JNIENvcnAuMTIwMAYDVQQDDClOQVZFUiBHbG9iYWwgUm9vdCBDZXJ0aWZpY2F0 + * aW9uIEF1dGhvcml0eTAeFw0xNzA4MTgwODU4NDJaFw0zNzA4MTgyMzU5NTlaMGkx + * CzAJBgNVBAYTAktSMSYwJAYDVQQKDB1OQVZFUiBCVVNJTkVTUyBQTEFURk9STSBD + * b3JwLjEyMDAGA1UEAwwpTkFWRVIgR2xvYmFsIFJvb3QgQ2VydGlmaWNhdGlvbiBB + * dXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC21PGTXLVA + * iQqrDZBbUGOukJR0F0Vy1ntlWilLp1agS7gvQnXp2XskWjFlqxcX0TM62RHcQDaH + * 38dq6SZeWYp34+hInDEW+j6RscrJo+KfziFTowI2MMtSAuXaMl3Dxeb57hHHi8lE + * HoSTGEq0n+USZGnQJoViAbbJAh2+g1G7XNr4rRVqmfeSVPc0W+m/6imBEtRTkZaz + * kVrd/pBzKPswRrXKCAfHcXLJZtM0l/aM9BhK4dA9WkW2aacp+yPOiNgSnABIqKYP + * szuSjXEOdMWLyEz59JuOuDxp7W87UC9Y7cSw0BwbagzivESq2M0UXZR4Yb8Obtoq + * vC8MC3GmsxY/nOb5zJ9TNeIDoKAYv7vxvvTWjIcNQvcGufFt7QSUqP620wbGQGHf + * nZ3zVHbOUzoBppJB7ASjjw2i1QnK1sua8e9DXcCrpUHPXFNwcMmIpi3Ua2FzUCaG + * YQ5fG8Ir4ozVu53BA0K6lNpfqbDKzE0K70dpAy8i+/Eozr9dUGWokG2zdLAIx6yo + * 0es+nPxdGoMuK8u180SdOqcXYZaicdNwlhVNt0xz7hlcxVs+Qf6sdWA7G2POAN3a + * CJBitOUt7kinaxeZVL6HSuOpXgRM6xBtVNbv8ejyYhbLgGvtPe31HzClrkvJE+2K + * AQHJuFFYwGY6sWZLxNUxAmLpdIQM201GLQIDAQABo0IwQDAdBgNVHQ4EFgQU0p+I + * 36HNLL3s9TsBAZMzJ7LrYEswDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMB + * Af8wDQYJKoZIhvcNAQEMBQADggIBADLKgLOdPVQG3dLSLvCkASELZ0jKbY7gyKoN + * qo0hV4/GPnrK21HUUrPUloSlWGB/5QuOH/XcChWB5Tu2tyIvCZwTFrFsDDUIbatj + * cu3cvuzHV+YwIHHW1xDBE1UBjCpD5EHxzzp6U5LOogMFDTjfArsQLtk70pt6wKGm + * +LUx5vR1yblTmXVHIloUFcd4G7ad6Qz4G3bxhYTeodoS76TiEJd6eN4MUZeoIUCL + * hr0N8F5OSza7OyAfikJW4Qsav3vQIkMsRIz75Sq0bBwcupTgE34h5prCy8VCZLQe + * lHsIJchxzIdFV4XTnyliIoNRlwAYl3dqmJLJfGBs32x9SuRwTMKeuB330DTHD8z7 + * p/8Dvq1wkNoL3chtl1+afwkyQf3NosxabUzyqkn+Zvjp2DXrDige7kgvOtB5CTh8 + * piKCk5XQA76+AqAF3SAi428diDRgxuYKuQl1C/AH6GmWNcf7I4GOODm4RStDeKLR + * LBT/DShycpWbXgnbiUSYqqFJu3FS8r/2/yehNq+4tneI3TqkbZs0kNwUXTC/t+sX + * 5Ie3cdCh13cV1ELX8vMxmV2b3RZtP+oGI/hGoiLtk/bdmuYqh7GYVPEi92tF4+KO + * dh2ajcQGjTa3FPOdVGm3jjzVpG2Tgbet9r1ke8LJaDmgkpzNNIaRkPpkUZ3+/uul + * 9XXeifdy + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02KR1&0$\x06\x03U\x04\n\x0c\x1dNAVER BUSINESS PLATFORM Corp.1200\x06\x03U\x04\x03\x0c)NAVER Global Root Certification Authority"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xb6\xd4\xf1\x93\\\xb5@\x89\n\xab\r\x90[Pc\xae\x90\x94t\x17Er\xd6{eZ)K\xa7V\xa0K\xb8/Bu\xe9\xd9{$Z1e\xab\x17\x17\xd13:\xd9\x11\xdc@6\x87\xdf\xc7j\xe9&^Y\x8aw\xe3\xe8H\x9c1\x16\xfa>\x91\xb1\xca\xc9\xa3\xe2\x9f\xce!S\xa3\x0260\xcbR\x02\xe5\xda2]\xc3\xc5\xe6\xf9\xee\x11\xc7\x8b\xc9D\x1e\x84\x93\x18J\xb4\x9f\xe5\x12di\xd0&\x85b\x01\xb6\xc9\x02\x1d\xbe\x83Q\xbb\\\xda\xf8\xad\x15j\x99\xf7\x92T\xf74[\xe9\xbf\xea)\x81\x12\xd4S\x91\x96\xb3\x91Z\xdd\xfe\x90s(\xfb0F\xb5\xca\x08\x07\xc7qr\xc9f\xd34\x97\xf6\x8c\xf4\x18J\xe1\xd0=ZE\xb6i\xa7)\xfb#\xce\x88\xd8\x12\x9c\x00H\xa8\xa6\x0f\xb3;\x92\x8dq\x0et\xc5\x8b\xc8L\xf9\xf4\x9b\x8e\xb8\x9c\xfc]\x1a\x83.+\xcb\xb5\xf3D\x9d:\xa7\x17a\x96\xa2q\xd3p\x96\x15M\xb7Ls\xee\x19\\\xc5[>A\xfe\xacu`;\x1bc\xce\x00\xdd\xda\x08\x90b\xb4\xe5-\xeeH\xa7k\x17\x99T\xbe\x87J\xe3\xa9^\x04L\xeb\x10mT\xd6\xef\xf1\xe8\xf2b\x16\xcb\x80k\xed=\xed\xf5\x1f0\xa5\xaeK\xc9\x13\xed\x8a\x01\x01\xc9\xb8QX\xc0f:\xb1fK\xc4\xd51\x02b\xe9t\x84\x0c\xdbMF-\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=vTrus Root CA O=iTrusChina Co.,Ltd. + * Subject: CN=vTrus Root CA O=iTrusChina Co.,Ltd. + * Label: "vTrus Root CA" + * Serial: 387574501246983434957692974888460947164905180485 + * SHA256 Fingerprint: 8a:71:de:65:59:33:6f:42:6c:26:e5:38:80:d0:0d:88:a1:8d:a4:c6:a9:1f:0d:cb:61:94:e2:06:c5:c9:63:87 + * -----BEGIN CERTIFICATE----- + * MIIFVjCCAz6gAwIBAgIUQ+NxE9izWRRdt86M/TX9b7wFjUUwDQYJKoZIhvcNAQEL + * BQAwQzELMAkGA1UEBhMCQ04xHDAaBgNVBAoTE2lUcnVzQ2hpbmEgQ28uLEx0ZC4x + * FjAUBgNVBAMTDXZUcnVzIFJvb3QgQ0EwHhcNMTgwNzMxMDcyNDA1WhcNNDMwNzMx + * MDcyNDA1WjBDMQswCQYDVQQGEwJDTjEcMBoGA1UEChMTaVRydXNDaGluYSBDby4s + * THRkLjEWMBQGA1UEAxMNdlRydXMgUm9vdCBDQTCCAiIwDQYJKoZIhvcNAQEBBQAD + * ggIPADCCAgoCggIBAL1VfGHTuB0EYgWgrmy3cLRB6ksDXhA/kFocizuwZotsSKYc + * IrrVQJLuM7IjWcmOvFjai57QGfIvWcaMY1q6n6MLsLOaXLoRuBLpDLvPbmyAhykU + * AyyNJJrIZIO1aqwTLDPxn9wsYTwaP3BVm60AUn/PBLn+NvqcwBauYv6WTEN+VRS+ + * GrPSbcKvdmaVayqwlHeFXgQPYh1jdfdr58tbmnDsPmcF8P4HCIDPKNsFxhQnL4Z9 + * 8Cfe/+Z+M0jnCx5Y0ScrUw5XSmXX+6KAYPxMvDVTAWqXcoKv8R1w6Jz1717CbMdH + * flqUhSZNO7rrTOiwCcJlwp2dCZtOtZcFrPUGoPc2BX70kLJrxLT5ZOrpGgrIDajt + * J8nU57O5q4IikCc9Kuh8kO+8T/3iCiSn3mUkpF3qwHYw03dQ+A0Em5Q2AXPKBlim + * 0zvc+gRGE1WKyURHuFE5Gi7oNOJ5y1lKCn+8pu8fA2dqWSslYpPZUxlmPCdiKYZN + * pGvu/9ROutW04o5IWgAZCfEF2c6Rsffr6TlP9m8EQ5pV9T4FFL2/s1m02I4zhKOQ + * UqqzApVg+QxMaPnu1RcN+HFXtSXkKe5lXa/R7jwXC1pDxaWG6iSe4gUH3DRCEpHW + * OXSuTEGC2/KmSNGzm/MzqvOmwMVO9fSddmPmAsYiS8GVP1BkLFTltvA8Kc9XAgMB + * AAGjQjBAMB0GA1UdDgQWBBRUYnBj8XWEQ1iO0RYgscasGrz2iTAPBgNVHRMBAf8E + * BTADAQH/MA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsFAAOCAgEAKbqSSaet + * 8PFww+SX8J+pJdVrnjT+5hpk9jprUrIQeBqfTNqK2uwcN1LgQkv7bHbKJAs5EhWd + * nxEt/Hlk3ODg9d3gV8mlsnZwUKT+twpw1aA08XXXTUm6EdGz2OyC/+sOxL9kLX1j + * bhd47F18iMjrjld22VkE+rxSH0Ws8HqA7Oxvdq6R2xCOBNyS36D25q5J08FsEhvM + * Kar5CKXiNxTKsbhm7xqC5PD48acWabfbqWE8n/Uxy+QARsIvdLGx14HuqCaVvIiv + * TDUHKgLKeBRtRytAVunLKmChZwOgzoy8sHJnxDHO2zTlJQNgJXtxmOTAGytfdELS + * S8VZCAeHvsXDf+eW2eHcKJfWjwXj9ZtOyh1QRwVTsMo554WgicEFOwE30z9J4nfr + * I8iIZjs9OXYhRvHsXyO466JmdXTBQPfYaJqT4i2pLr0cox7IdMakLXogqzu4sEb9 + * b91fUlV1YvCXoHzXOP0l382gmxDPi7g4Xl7FtKYCNqEeXxzP4padKar9mK5S4fNB + * UvupLnKWnyfjqnN9+BojZns7q2WwMgFLFT49ok8MKzWixtlnEjUwzXYuFrOZnk1P + * Ti07NEPhmg4NpGaXutIcSkwsKouLgU9xGqndXHt7CMUADTdA43x7VF8vhV929ven + * sBxXVsFy6K2ir40zSbofitzmdHxghm+Hl3s= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02CN1\x1c0\x1a\x06\x03U\x04\n\x13\x13iTrusChina Co.,Ltd.1\x160\x14\x06\x03U\x04\x03\x13\rvTrus Root CA"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xbdU|a\xd3\xb8\x1d\x04b\x05\xa0\xael\xb7p\xb4A\xeaK\x03^\x10?\x90Z\x1c\x8b;\xb0f\x8blH\xa6\x1c\"\xba\xd5@\x92\xee3\xb2#Y\xc9\x8e\xbcX\xda\x8b\x9e\xd0\x19\xf2/Y\xc6\x8ccZ\xba\x9f\xa3\x0b\xb0\xb3\x9a\\\xba\x11\xb8\x12\xe9\x0c\xbb\xcfnl\x80\x87)\x14\x03,\x8d$\x9a\xc8d\x83\xb5j\xac\x13,3\xf1\x9f\xdc,a<\x1a?pU\x9b\xad\x00R\x7f\xcf\x04\xb9\xfe6\xfa\x9c\xc0\x16\xaeb\xfe\x96LC~U\x14\xbe\x1a\xb3\xd2m\xc2\xafvf\x95k*\xb0\x94w\x85^\x04\x0fb\x1dcu\xf7k\xe7\xcb[\x9ap\xec>g\x05\xf0\xfe\x07\x08\x80\xcf(\xdb\x05\xc6\x14\'/\x86}\xf0\'\xde\xff\xe6~3H\xe7\x0b\x1eX\xd1\'+S\x0eWJe\xd7\xfb\xa2\x80`\xfcL\xbc5S\x01j\x97r\x82\xaf\xf1\x1dp\xe8\x9c\xf5\xef^\xc2l\xc7G~Z\x94\x85&M;\xba\xebL\xe8\xb0\t\xc2e\xc2\x9d\x9d\t\x9bN\xb5\x97\x05\xac\xf5\x06\xa0\xf76\x05~\xf4\x90\xb2k\xc4\xb4\xf9d\xea\xe9\x1a\n\xc8\r\xa8\xed\'\xc9\xd4\xe7\xb3\xb9\xab\x82\"\x90\'=*\xe8|\x90\xef\xbcO\xfd\xe2\n$\xa7\xdee$\xa4]\xea\xc0v0\xd3wP\xf8\r\x04\x9b\x946\x01s\xca\x06X\xa6\xd3;\xdc\xfa\x04F\x13U\x8a\xc9DG\xb8Q9\x1a.\xe84\xe2y\xcbYJ\n\x7f\xbc\xa6\xef\x1f\x03gjY+%b\x93\xd9S\x19f<\'b)\x86M\xa4k\xee\xff\xd4N\xba\xd5\xb4\xe2\x8eHZ\x00\x19\t\xf1\x05\xd9\xce\x91\xb1\xf7\xeb\xe99O\xf6o\x04C\x9aU\xf5>\x05\x14\xbd\xbf\xb3Y\xb4\xd8\x8e3\x84\xa3\x90R\xaa\xb3\x02\x95`\xf9\x0cLh\xf9\xee\xd5\x17\r\xf8qW\xb5%\xe4)\xeee]\xaf\xd1\xee<\x17\x0bZC\xc5\xa5\x86\xea$\x9e\xe2\x05\x07\xdc4B\x12\x91\xd69t\xaeLA\x82\xdb\xf2\xa6H\xd1\xb3\x9b\xf33\xaa\xf3\xa6\xc0\xc5N\xf5\xf4\x9dvc\xe6\x02\xc6\"K\xc1\x95?Pd,T\xe5\xb6\xf0<)\xcfW\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=QuoVadis Root CA 1 G3 O=QuoVadis Limited + * Subject: CN=QuoVadis Root CA 1 G3 O=QuoVadis Limited + * Label: "QuoVadis Root CA 1 G3" + * Serial: 687049649626669250736271037606554624078720034195 + * SHA256 Fingerprint: 8a:86:6f:d1:b2:76:b5:7e:57:8e:92:1c:65:82:8a:2b:ed:58:e9:f2:f2:88:05:41:34:b7:f1:f4:bf:c9:cc:74 + * -----BEGIN CERTIFICATE----- + * MIIFYDCCA0igAwIBAgIUeFhfLq0sGUvjNwc1NBMotZbUZZMwDQYJKoZIhvcNAQEL + * BQAwSDELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAc + * BgNVBAMTFVF1b1ZhZGlzIFJvb3QgQ0EgMSBHMzAeFw0xMjAxMTIxNzI3NDRaFw00 + * MjAxMTIxNzI3NDRaMEgxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM + * aW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDEgRzMwggIiMA0GCSqG + * SIb3DQEBAQUAA4ICDwAwggIKAoICAQCgvlAQjunybEC0BJyFuTHK3C3kEakEPBtV + * wedYMB0ktMPvhd6MLOHBPd+C5k+tR4ds7FtJwUrVu4/sh6x/gpqG7D0DmVIB0jWe + * rNrwU8lmPNSsAgHaJNM7qAJGr6Qc4/hzWHa39g6QDbXwz8z6+cZM5cOGMAqNF341 + * 68Xfuw6cwI2H44g4hWf6Pser4BOcBRiYz5P1sZK0/CPTz9XEJ0ngnjybCKOLXSoh + * 4Pw5qlPafX7PGglTvF0FBM+hSo+LdoINofjSxxR3W5A2B4GbPgb6Ul5jxaYA/qXp + * UhtStZI5cgMJYr2wYBZupt0lwgNm3fME0UDiTouG9G/lg6AnhF4EwfWQvTA9xO+o + * abw4m6SkltFi2mnAAZauy8RRNOoMqv8hjlmPSlzkYZqn0ukqeI1RPToV7qJZjqlc + * 3sX5kCLliEVx3ZGZbHqfPT2YfF72vhZooF6uCyP8Wg+qInYtyaEQHeTTRCOQiJ/G + * KubX9ZqzWB4vMIkIG1SitZgj7Ah3HJVdYdHLiZxfokqRmu8hqkkWCKi9YSgxyXSt + * hfbZxbGL0eUQMk1fiyA6PEkfM4VZDdvLCXVDaXP7a3F98N/ETH3Goy7IlXnLc6KO + * Tk0k+17kBL5yG6YnLUlamXrXXAkgt3+UuU/xDRxeiEIbEbfnkduebPRq34wGmAOt + * zCjvpUfzUwIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIB + * BjAdBgNVHQ4EFgQUo5fW816iEOGrRZ88F2Q87gFwnMwwDQYJKoZIhvcNAQELBQAD + * ggIBABj6W3X8PnrHX3fHyt/PX8MSxEBd1DKquGrX1RUVRpgjpeaQWxiZTOOtQqOC + * MTaIzen7xASWSIsBx40Bz1szBpZGZnQdT+3Btrm0DWHMY37XLneMlhwqI2hrhVd2 + * cDMT/uFPpiN3GPoajOi9ZcnPP/TJF9zrx7zABC4tRi9pZsMbj/7sPtPKlL92CiUN + * qXsCHKnQO18LwIE6PWThv6ctTr1NxNgpxiIY0MWscgKCP6o6ojoilzHdCGPDdRS5 + * YCgtW2jgFqlmgiNR9etT2DGbe+m3nUvriBbP+V04ikkwj+3x6xn0dxoxGE1nVGwv + * b2X52z3sIexe9PSLymBlVNFxZPT5pqOBMzYzcfCkeF9OrYMh3jRJjehZrJ3ydlo2 + * 8hP0r+AJx2EqbPfgna67hkooby7utHnNkDPDs3b69fBsnQGQ+p6Q9pxyz0fawx/k + * NSBT8lTR32GDpgLiJTjehTItXnOQUl1CxM49S+H5GYQd1aJQzEH7QRTDvdbJWqNj + * ZgKAvQU6O0ec7AAmTPWIUb+oI38YB7AL7YsmoWTTYUrrXJ/es69nA7Mf3W1daWhp + * q1467HxpvMc7hU6eFbm0FU/DlXpY18ls6Wy58yljXrQs8C097Vpl4KlbQMJImYFt + * nh8GKjwStIsPm6Ik8KaN1nrgS7ZklmOVhMJKzRwuJIczYOXD + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02BM1\x190\x17\x06\x03U\x04\n\x13\x10QuoVadis Limited1\x1e0\x1c\x06\x03U\x04\x03\x13\x15QuoVadis Root CA 1 G3"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xa0\xbeP\x10\x8e\xe9\xf2l@\xb4\x04\x9c\x85\xb91\xca\xdc-\xe4\x11\xa9\x04<\x1bU\xc1\xe7X0\x1d$\xb4\xc3\xef\x85\xde\x8c,\xe1\xc1=\xdf\x82\xe6O\xadG\x87l\xec[I\xc1J\xd5\xbb\x8f\xec\x87\xac\x7f\x82\x9a\x86\xec=\x03\x99R\x01\xd25\x9e\xac\xda\xf0S\xc9f<\xd4\xac\x02\x01\xda$\xd3;\xa8\x02F\xaf\xa4\x1c\xe3\xf8sXv\xb7\xf6\x0e\x90\r\xb5\xf0\xcf\xcc\xfa\xf9\xc6L\xe5\xc3\x860\n\x8d\x17~5\xeb\xc5\xdf\xbb\x0e\x9c\xc0\x8d\x87\xe3\x888\x85g\xfa>\xc7\xab\xe0\x13\x9c\x05\x18\x98\xcf\x93\xf5\xb1\x92\xb4\xfc#\xd3\xcf\xd5\xc4\'I\xe0\x9e<\x9b\x08\xa3\x8b]*!\xe0\xfc9\xaaS\xda}~\xcf\x1a\tS\xbc]\x05\x04\xcf\xa1J\x8f\x8bv\x82\r\xa1\xf8\xd2\xc7\x14w[\x906\x07\x81\x9b>\x06\xfaR^c\xc5\xa6\x00\xfe\xa5\xe9R\x1bR\xb5\x929r\x03\tb\xbd\xb0`\x16n\xa6\xdd%\xc2\x03f\xdd\xf3\x04\xd1@\xe2N\x8b\x86\xf4o\xe5\x83\xa0\'\x84^\x04\xc1\xf5\x90\xbd0=\xc4\xef\xa8i\xbc8\x9b\xa4\xa4\x96\xd1b\xdai\xc0\x01\x96\xae\xcb\xc4Q4\xea\x0c\xaa\xff!\x8eY\x8fJ\\\xe4a\x9a\xa7\xd2\xe9*x\x8dQ=:\x15\xee\xa2Y\x8e\xa9\\\xde\xc5\xf9\x90\"\xe5\x88Eq\xdd\x91\x99lz\x9f==\x98|^\xf6\xbe\x16h\xa0^\xae\x0b#\xfcZ\x0f\xaa\"v-\xc9\xa1\x10\x1d\xe4\xd3D#\x90\x88\x9f\xc6*\xe6\xd7\xf5\x9a\xb3X\x1e/0\x89\x08\x1bT\xa2\xb5\x98#\xec\x08w\x1c\x95]a\xd1\xcb\x89\x9c_\xa2J\x91\x9a\xef!\xaaI\x16\x08\xa8\xbda(1\xc9t\xad\x85\xf6\xd9\xc5\xb1\x8b\xd1\xe5\x102M_\x8b :\xb3zM\xa8\x03\xe2\xe2~\x01\x16Yh\x18C3\xb0\xd2\xdc\xb0\x1aC5\xee\xa5\xda\xa9F\\\xae\x86\x81A\x01Jt&\xec\x9f\x06\xbf\xc2\x057dux)h\xfd\xc5\xf5\xeb\xfeG\xf9\xe4\x85\xb0\xe1{1\x9d\xa6\x7fr\xa3\xb9\xc4,.\xcc\x99W\x0e!\x0cE\x01\x94e\xebe\t\xc6c\"\x0b3I\x92H<\xfc\xcd\xce\xb0>\x8e\x9e\x8b\xf8\xfeI\xc55rG\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=Amazon Root CA 1 O=Amazon + * Subject: CN=Amazon Root CA 1 O=Amazon + * Label: "Amazon Root CA 1" + * Serial: 143266978916655856878034712317230054538369994 + * SHA256 Fingerprint: 8e:cd:e6:88:4f:3d:87:b1:12:5b:a3:1a:c3:fc:b1:3d:70:16:de:7f:57:cc:90:4f:e1:cb:97:c6:ae:98:19:6e + * -----BEGIN CERTIFICATE----- + * MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsF + * ADA5MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6 + * b24gUm9vdCBDQSAxMB4XDTE1MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTEL + * MAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJv + * b3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALJ4gHHKeNXj + * ca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgHFzZM + * 9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qw + * IFAGbHrQgLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6 + * VOujw5H5SNz/0egwLX0tdHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L + * 93FcXmn/6pUCyziKrlA4b9v7LWIbxcceVOF34GfID5yHI9Y/QCB/IIDEgEw+OyQm + * jgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC + * AYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3DQEBCwUA + * A4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDI + * U5PMCCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUs + * N+gDS63pYaACbvXy8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vv + * o/ufQJVtMVT8QtPHRh8jrdkPSHCa2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU + * 5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2xJNDd2ZhwLnoQdeXeGADbkpy + * rqXRfboQnoZsG4q5WTP468SQvvG5 + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1\x0f0\r\x06\x03U\x04\n\x13\x06Amazon1\x190\x17\x06\x03U\x04\x03\x13\x10Amazon Root CA 1"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x01\x0f\x000\x82\x01\n\x02\x82\x01\x01\x00\xb2x\x80q\xcax\xd5\xe3q\xafG\x80Pt}n\xd8\xd7\x88v\xf4\x99h\xf7X!`\xf9t\x84\x01/\xac\x02-\x86\xd3\xa0CzN\xb2\xa4\xd06\xba\x01\xbe\x8d\xdbH\xc8\x07\x176L\xf4\xee\x88#\xc7>\xeb7\xf5\xb5\x19\xf8Ih\xb0\xde\xd7\xb9v8\x1da\x9e\xa4\xfe\x826\xa5\xe5JV\xe4E\xe1\xf9\xfd\xb4\x16\xfat\xda\x9c\x9b59/\xfa\xb0 P\x06lz\xd0\x80\xb2\xa6\xf9\xaf\xecG\x19\x8fP8\x07\xdc\xa2\x879X\xf8\xba\xd5\xa9\xf9Hg0\x96\xee\x94x^o\x89\xa3Q\xc00\x86f\xa1Ef\xbaT\xeb\xa3\xc3\x91\xf9H\xdc\xff\xd1\xe80-}-tp5\xd7\x88$\xf7\x9e\xc4Yn\xbbs\x87\x17\xf22F(\xb8C\xfa\xb7\x1d\xaa\xca\xb4\xf2\x9f$\x0e-K\xf7q\\^i\xff\xea\x95\x02\xcb8\x8a\xaeP8o\xdb\xfb-b\x1b\xc5\xc7\x1eT\xe1w\xe0g\xc8\x0f\x9c\x87#\xd6?@ \x7f \x80\xc4\x80L>;$&\x8e\x04\xael\x9a\xc8\xaa\r\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=SSL.com TLS RSA Root CA 2022 O=SSL Corporation + * Subject: CN=SSL.com TLS RSA Root CA 2022 O=SSL Corporation + * Label: "SSL.com TLS RSA Root CA 2022" + * Serial: 148535279242832292258835760425842727825 + * SHA256 Fingerprint: 8f:af:7d:2e:2c:b4:70:9b:b8:e0:b3:36:66:bf:75:a5:dd:45:b5:de:48:0f:8e:a8:d4:bf:e6:be:bc:17:f2:ed + * -----BEGIN CERTIFICATE----- + * MIIFiTCCA3GgAwIBAgIQb77arXO9CEDii02+1PdbkTANBgkqhkiG9w0BAQsFADBO + * MQswCQYDVQQGEwJVUzEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9uMSUwIwYDVQQD + * DBxTU0wuY29tIFRMUyBSU0EgUm9vdCBDQSAyMDIyMB4XDTIyMDgyNTE2MzQyMloX + * DTQ2MDgxOTE2MzQyMVowTjELMAkGA1UEBhMCVVMxGDAWBgNVBAoMD1NTTCBDb3Jw + * b3JhdGlvbjElMCMGA1UEAwwcU1NMLmNvbSBUTFMgUlNBIFJvb3QgQ0EgMjAyMjCC + * AiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANCkCXJPQIgSYT41I57u9nTP + * L3tYPc48DRAokC+X94xI2KDYJbFMsBFMF3NQ0CJKY7uB0ylu1bUJPiYYf7ISf5OY + * t6/wNr/y7hienDtSxUcZXXTzZGbVXcdotL8bHAajvI9AI7YexoS9UcQbOcGV0ins + * S657Lb85/bRi3pZ7QcacoOAGcvvwB5cJOYF0r/c0WRFXCsJbwST0MXMwgsadugL3 + * PnxEX4MN8/HdIGkWCVDi1FW24IBydm5MR7d1VVm0U3TZlMZBrViKMWYPHqIbKUBO + * L9975hYsLfy/7PO0+r4Y9ptJ1O4Fbtk085zx7AGL0SDGD6C1vBdOSHtRwvzpXGk3 + * R2azaPgVKPC506QVzFpPulJwoxJF3ca6TvvC0PeoUidtbnm1jPx7jMEWTO6Af77w + * dr5BUxIzrlo4QqvXDz5BjXYHMtWrifZOZ9mxQnUjbvPNQrL8VfVThxc7wDNY8VLS + * +YCk8OjwO4s4zKTGkH8PnP2L0aPP2oOnaclQNtVcBdIKQXTbYxE3waWglksejBYS + * d66UNHsef8JmAOSqg+qKkK3ONkRN0VHpvB/zagX9wHQfJRlAUW7qglFA35u5CCoG + * AtUjHBPW6dvbxrB6y3snm/vg1UYk7RBLY0ulBY+6uB0rpvqR4pJSvezrZ5dtmi2f + * gTIFZzL7SAg/2SW4BCUvAgMBAAGjYzBhMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0j + * BBgwFoAU+y437uOEeicuzRk1sTN8/9REQrkwHQYDVR0OBBYEFPsuN+7jhHonLs0Z + * NbEzfP/UREK5MA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0BAQsFAAOCAgEAjYlt + * hEUY8U+zoO9opMAdrDC8Z2awms22qyIZZtM7QbUQnRC6cm4pJCAcAZli05bg4vsM + * QtfhWsSWTVTNj8pDU/0quOr4ZcoBwq1gaAafORpR2eCNJvkLTqVTJXojpBzOCBvf + * R4iyrT7gJ4eLSYwfqUdYe5byiB0YrrPRpgqU+tvT5TgKa3kSM/tKWTcWQA673vWJ + * DPFs0/dRa1419dvAJuoSc06pkZCmF8NsLzjUo3KUQyxi4U5cMj29TH0ZR6LDSeeW + * P4+a0zvkEdiLA9z2tmBVGKaBUfPhqBVq6+AL8BQx1rmMRTqoENjwuSfr98t67wVy + * lrXEj5ZzxOhWc5y8aVFjvO9nHEMaX3cZHxj4HCUp+UmZKbaSPaKDN7EgkaibMOlq + * bLQjk2UEqxHzDh1TJElTHaE/nUiSEeJ9DU/1172iWD54nR4fK/4huxoTtrEoZP2w + * AgDHbICivRZQIA9ygV/MlP+7mea6kMvq+cYMwq7FGc4zoWtcu358NFcXrfA/rs3q + * r5nsLFR+jM4uElZI7xc7P0peYNLcdDa8pUNjyw9bowJWCZ4kLOGGgYz+qxcs+sji + * Mho6/4UIyYOf8kpIEFR3N+2ivEC+5BB09+Rbu7nzifmPQdjH5FCQNYA+HLhNkNPU + * 98OwoX6EyneSMSy4kLGCenROmxMmtNVQZlR4rmA= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1\x180\x16\x06\x03U\x04\n\x0c\x0fSSL Corporation1%0#\x06\x03U\x04\x03\x0c\x1cSSL.com TLS RSA Root CA 2022"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xd0\xa4\trO@\x88\x12a>5#\x9e\xee\xf6t\xcf/{X=\xce<\r\x10(\x90/\x97\xf7\x8cH\xd8\xa0\xd8%\xb1L\xb0\x11L\x17sP\xd0\"Jc\xbb\x81\xd3)n\xd5\xb5\t>&\x18\x7f\xb2\x12\x7f\x93\x98\xb7\xaf\xf06\xbf\xf2\xee\x18\x9e\x9c;R\xc5G\x19]t\xf3df\xd5]\xc7h\xb4\xbf\x1b\x1c\x06\xa3\xbc\x8f@#\xb6\x1e\xc6\x84\xbdQ\xc4\x1b9\xc1\x95\xd2)\xecK\xae{-\xbf9\xfd\xb4b\xde\x96{A\xc6\x9c\xa0\xe0\x06r\xfb\xf0\x07\x97\t9\x81t\xaf\xf74Y\x11W\n\xc2[\xc1$\xf41s0\x82\xc6\x9d\xba\x02\xf7>|D_\x83\r\xf3\xf1\xdd i\x16\tP\xe2\xd4U\xb6\xe0\x80rvnLG\xb7uUY\xb4St\xd9\x94\xc6A\xadX\x8a1f\x0f\x1e\xa2\x1b)@N/\xdf{\xe6\x16,-\xfc\xbf\xec\xf3\xb4\xfa\xbe\x18\xf6\x9bI\xd4\xee\x05n\xd94\xf3\x9c\xf1\xec\x01\x8b\xd1 \xc6\x0f\xa0\xb5\xbc\x17NH{Q\xc2\xfc\xe9\\i7Gf\xb3h\xf8\x15(\xf0\xb9\xd3\xa4\x15\xccZO\xbaRp\xa3\x12E\xdd\xc6\xbaN\xfb\xc2\xd0\xf7\xa8R\'mny\xb5\x8c\xfc{\x8c\xc1\x16L\xee\x80\x7f\xbe\xf0v\xbeAS\x123\xaeZ8B\xab\xd7\x0f>A\x8dv\x072\xd5\xab\x89\xf6Ng\xd9\xb1Bu#n\xf3\xcdB\xb2\xfcU\xf5S\x87\x17;\xc03X\xf1R\xd2\xf9\x80\xa4\xf0\xe8\xf0;\x8b8\xcc\xa4\xc6\x90\x7f\x0f\x9c\xfd\x8b\xd1\xa3\xcf\xda\x83\xa7i\xc9P6\xd5\\\x05\xd2\nAt\xdbc\x117\xc1\xa5\xa0\x96K\x1e\x8c\x16\x12w\xae\x944{\x1e\x7f\xc2f\x00\xe4\xaa\x83\xea\x8a\x90\xad\xce6DM\xd1Q\xe9\xbc\x1f\xf3j\x05\xfd\xc0t\x1f%\x19@Qn\xea\x82Q@\xdf\x9b\xb9\x08*\x06\x02\xd5#\x1c\x13\xd6\xe9\xdb\xdb\xc6\xb0z\xcb{\'\x9b\xfb\xe0\xd5F$\xed\x10KcK\xa5\x05\x8f\xba\xb8\x1d+\xa6\xfa\x91\xe2\x92R\xbd\xec\xebg\x97m\x9a-\x9f\x812\x05g2\xfbH\x08?\xd9%\xb8\x04%/\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=QuoVadis Root CA 2 G3 O=QuoVadis Limited + * Subject: CN=QuoVadis Root CA 2 G3 O=QuoVadis Limited + * Label: "QuoVadis Root CA 2 G3" + * Serial: 390156079458959257446133169266079962026824725800 + * SHA256 Fingerprint: 8f:e4:fb:0a:f9:3a:4d:0d:67:db:0b:eb:b2:3e:37:c7:1b:f3:25:dc:bc:dd:24:0e:a0:4d:af:58:b4:7e:18:40 + * -----BEGIN CERTIFICATE----- + * MIIFYDCCA0igAwIBAgIURFc0JFuBiZs18s64KztbpybwdSgwDQYJKoZIhvcNAQEL + * BQAwSDELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAc + * BgNVBAMTFVF1b1ZhZGlzIFJvb3QgQ0EgMiBHMzAeFw0xMjAxMTIxODU5MzJaFw00 + * MjAxMTIxODU5MzJaMEgxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM + * aW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDIgRzMwggIiMA0GCSqG + * SIb3DQEBAQUAA4ICDwAwggIKAoICAQChriWyARjcV4g/Ruv5r+LrI3HimtFhZiFf + * qq8nUeVuGxbULX1QsFN3vXg6YOJkApt8hpvWGo6t/x8Vf9WVHhLL5hSEBMHfNrMW + * n4rjyduYNM7YMxcoRvynyfDStNVNCXJJ+fKH46nafaF9a7I6JaltUkSs+L5u+9ym + * c5GQYaYDFCDy54ejiK2toIz/pgslUiXnFgHVy7g1gQyjO/Dh4fxaXc6AcW34Sas+ + * O7q414AB+6XrW7PFXmAqMaCvN+ggOp+oMiwMzAkd056OXbxMmO7FGmh77FOm6RQ1 + * o9/NgJ8MSPsc9PG/Srj61YxxSscfrf5BmrODXfKEVu+lV0POKa2Mq1W/xPtbAd0j + * IaFYAI7D0GoT7RPjEiuA3GfmlbLNHiJuKvhB1PLKFAeNilUSxmn1uIZoL1NesNKq + * IcGY5jDjZ1XHm26sGahVpkUG0CM62+tlXSoREfA7T8pt9DTEceT/AFr2XK4jYIVz + * 8eQQsSWu1ZK7E8EM4DnatDlXtas1qnIhO4M15zHfeiFuuDIIfR0ykRVKYnLP43eh + * vNURG3YBZwjgQQvD6xVu+KQZ2aKrr+InUlYrAoosFCT5v0ICvybIxo/gbjh9Uy3l + * 7ZizlWNof/k19N+IxWA1ksB8aRxhlRbQ694Lrz4EEEVlWFA4r0jyWbYW8jwNkALG + * cC4BrTwV1wIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIB + * BjAdBgNVHQ4EFgQU7edvdlq/YOxJW8ald7tyFnGbxD0wDQYJKoZIhvcNAQELBQAD + * ggIBAJHfgD9DCX5xwvfrs4iP4VGyvD11+ShdyLyZm3tdquXK4Qr36LLTn91nMX66 + * AarHakE7kNQIXLJgapDwyM4DYvmL7ftuKtwGTTwpD4kWilhMSA/ohGHqPHKmd+RC + * roijQ1h5fq7KpVMNqT1wvSAZYaRsOPxDMuHBR//47PERIjKWnML2W2mWeyAMQ0Ga + * W/ZZGYjeVYg3UQt4XAoeo0L9x52ID8DyeAIkVJOviYeIyUqAHerQbj5hLja7NQ4n + * lv1mNDthcnPxFlxHBlRJAHpYErAK74X9sbgzdWqTHBLmYF5vHX/JHyPLhGGfHoJE + * +V+tYlUkmlKY7VHnoX6XOuYvHxHaU4AshZ6rNRDbIl9qxV6XU/IyAgkwo1jwDQHV + * csaxfGl7w/U2Rcxhbl5MlMVerugOXou/983g7aEOGzPuVBj+D77vfoRrQ+NwmNtd + * dbINWQeFFSM51vHfqSYP1kjHs6Yi9TM3WpVHn3u6GBVv/9YUZINJ0gpnIdsPNWNg + * KCLjsZWDzYWm3S8P52dSbrsvhXz1SnPnxT7AvSESBT/8twNJAlvIJebiVDj1eYeM + * HVOyToV7BjjHLPj4sHKNJeV3UvQDHEimUF+IIDBu8oJDqz2XhOdT+yHBTw8imoa4 + * WSr2Rz0ZiC3oheGe7IUIarFsNMkd7EgrO3jtZsSOeWmD3n+M + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02BM1\x190\x17\x06\x03U\x04\n\x13\x10QuoVadis Limited1\x1e0\x1c\x06\x03U\x04\x03\x13\x15QuoVadis Root CA 2 G3"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xa1\xae%\xb2\x01\x18\xdcW\x88?F\xeb\xf9\xaf\xe2\xeb#q\xe2\x9a\xd1af!_\xaa\xaf\'Q\xe5n\x1b\x16\xd4-}P\xb0Sw\xbdx:`\xe2d\x02\x9b|\x86\x9b\xd6\x1a\x8e\xad\xff\x1f\x15\x7f\xd5\x95\x1e\x12\xcb\xe6\x14\x84\x04\xc1\xdf6\xb3\x16\x9f\x8a\xe3\xc9\xdb\x984\xce\xd83\x17(F\xfc\xa7\xc9\xf0\xd2\xb4\xd5M\trI\xf9\xf2\x87\xe3\xa9\xda}\xa1}k\xb2:%\xa9mRD\xac\xf8\xben\xfb\xdc\xa6s\x91\x90a\xa6\x03\x14 \xf2\xe7\x87\xa3\x88\xad\xad\xa0\x8c\xff\xa6\x0b%R%\xe7\x16\x01\xd5\xcb\xb85\x81\x0c\xa3;\xf0\xe1\xe1\xfcZ]\xce\x80qm\xf8I\xab>;\xba\xb8\xd7\x80\x01\xfb\xa5\xeb[\xb3\xc5^`*1\xa0\xaf7\xe8 :\x9f\xa82,\x0c\xcc\t\x1d\xd3\x9e\x8e]\xbcL\x98\xee\xc5\x1ah{\xecS\xa6\xe9\x145\xa3\xdf\xcd\x80\x9f\x0cH\xfb\x1c\xf4\xf1\xbfJ\xb8\xfa\xd5\x8cqJ\xc7\x1f\xad\xfeA\x9a\xb3\x83]\xf2\x84V\xef\xa5WC\xce)\xad\x8c\xabU\xbf\xc4\xfb[\x01\xdd#!\xa1X\x00\x8e\xc3\xd0j\x13\xed\x13\xe3\x12+\x80\xdcg\xe6\x95\xb2\xcd\x1e\"n*\xf8A\xd4\xf2\xca\x14\x07\x8d\x8aU\x12\xc6i\xf5\xb8\x86h/S^\xb0\xd2\xaa!\xc1\x98\xe60\xe3gU\xc7\x9bn\xac\x19\xa8U\xa6E\x06\xd0#:\xdb\xebe]*\x11\x11\xf0;O\xcam\xf44\xc4q\xe4\xff\x00Z\xf6\\\xae#`\x85s\xf1\xe4\x10\xb1%\xae\xd5\x92\xbb\x13\xc1\x0c\xe09\xda\xb49W\xb5\xab5\xaar!;\x835\xe71\xdfz!n\xb82\x08}\x1d2\x91\x15Jbr\xcf\xe3w\xa1\xbc\xd5\x11\x1bv\x01g\x08\xe0A\x0b\xc3\xeb\x15n\xf8\xa4\x19\xd9\xa2\xab\xaf\xe2\'RV+\x02\x8a,\x14$\xf9\xbfB\x02\xbf&\xc8\xc6\x8f\xe0n8}S-\xe5\xed\x98\xb3\x95ch\x7f\xf95\xf4\xdf\x88\xc5`5\x92\xc0|i\x1ca\x95\x16\xd0\xeb\xde\x0b\xaf>\x04\x10EeXP8\xafH\xf2Y\xb6\x16\xf2<\r\x90\x02\xc6p.\x01\xad<\x15\xd7\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=T-TeleSec GlobalRoot Class 2 O=T-Systems Enterprise Services GmbH OU=T-Systems Trust Center + * Subject: CN=T-TeleSec GlobalRoot Class 2 O=T-Systems Enterprise Services GmbH OU=T-Systems Trust Center + * Label: "T-TeleSec GlobalRoot Class 2" + * Serial: 1 + * SHA256 Fingerprint: 91:e2:f5:78:8d:58:10:eb:a7:ba:58:73:7d:e1:54:8a:8e:ca:cd:01:45:98:bc:0b:14:3e:04:1b:17:05:25:52 + * -----BEGIN CERTIFICATE----- + * MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUx + * KzApBgNVBAoMIlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAd + * BgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNl + * YyBHbG9iYWxSb290IENsYXNzIDIwHhcNMDgxMDAxMTA0MDE0WhcNMzMxMDAxMjM1 + * OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lzdGVtcyBFbnRlcnBy + * aXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBDZW50 + * ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDIwggEiMA0G + * CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCqX9obX+hzkeXaXPSi5kfl82hVYAUd + * AqSzm1nzHoqvNK38DcLZSBnuaY/JIPwhqgcZ7bBcrGXHX+0CfHt8LRvWurmAwhiC + * FoT6ZrAIxlQjgeTNuUk/9k9uN0goOA/FvudocP05l03Sx5iRUKrERLMjfTlH6VJi + * 1hKTXrcxlkIF+3anHqP1wvzpesVsqXFP6st4vGCvx9702cu+fjOlbpSD8DT6Iavq + * jnKgP6TeMFvvhk1qlVtDRKgQFRzlAVfFmPHmBiiRqiDFt1MmUUOyCxGVWOHAD3bZ + * wI18gfNycJ5v/hqO2V81xrJvNHy+SE/iWjnX2J14np+GPgNeGYtEotXHAgMBAAGj + * QjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS/ + * WSA2AHmgoCJrjNXyYdK4LMuCSjANBgkqhkiG9w0BAQsFAAOCAQEAMQOiYQsfdOhy + * NsZt+U2e+iKo4YFWz827n+qrkRk4r6p8FU3ztqONpfSO9kSpp+ghla0+AGIWiPAC + * uvxhI+YzmzB6azZie60EI4RYZeLbK4rnJVM3YlNfvNoBYimipidx5joifsFvHZVw + * IEoHNN/q/xWA5brXethbdXwFeilHfkCoMRN3zUA7tFFHei4R40cR3p1m0IvVVGb6 + * g1XqfMIpiRvpb7PO4gWEyS8+eIVibslfwXhjdFjASBgMmTnrpMwatXlajRWc2BQN + * 9noHV8cigwUtPJslJj0Ys6lDfMjIq2SPDqO/nBudMNva0Bkuqjzx+zOAduTNrRlP + * BSeOE6Fuwg== + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02DE1+0)\x06\x03U\x04\n\x0c\"T-Systems Enterprise Services GmbH1\x1f0\x1d\x06\x03U\x04\x0b\x0c\x16T-Systems Trust Center1%0#\x06\x03U\x04\x03\x0c\x1cT-TeleSec GlobalRoot Class 2"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x01\x0f\x000\x82\x01\n\x02\x82\x01\x01\x00\xaa_\xda\x1b_\xe8s\x91\xe5\xda\\\xf4\xa2\xe6G\xe5\xf3hU`\x05\x1d\x02\xa4\xb3\x9bY\xf3\x1e\x8a\xaf4\xad\xfc\r\xc2\xd9H\x19\xeei\x8f\xc9 \xfc!\xaa\x07\x19\xed\xb0\\\xace\xc7_\xed\x02|{|-\x1b\xd6\xba\xb9\x80\xc2\x18\x82\x16\x84\xfaf\xb0\x08\xc6T#\x81\xe4\xcd\xb9I?\xf6On7H(8\x0f\xc5\xbe\xe7hp\xfd9\x97M\xd2\xc7\x98\x91P\xaa\xc4D\xb3#}9G\xe9Rb\xd6\x12\x93^\xb71\x96B\x05\xfbv\xa7\x1e\xa3\xf5\xc2\xfc\xe9z\xc5l\xa9qO\xea\xcbx\xbc`\xaf\xc7\xde\xf4\xd9\xcb\xbe~3\xa5n\x94\x83\xf04\xfa!\xab\xea\x8er\xa0?\xa4\xde0[\xef\x86Mj\x95[CD\xa8\x10\x15\x1c\xe5\x01W\xc5\x98\xf1\xe6\x06(\x91\xaa \xc5\xb7S&QC\xb2\x0b\x11\x95X\xe1\xc0\x0fv\xd9\xc0\x8d|\x81\xf3rp\x9eo\xfe\x1a\x8e\xd9_5\xc6\xb2o4|\xbeHO\xe2Z9\xd7\xd8\x9dx\x9e\x9f\x86>\x03^\x19\x8bD\xa2\xd5\xc7\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=ISRG Root X1 O=Internet Security Research Group + * Subject: CN=ISRG Root X1 O=Internet Security Research Group + * Label: "ISRG Root X1" + * Serial: 172886928669790476064670243504169061120 + * SHA256 Fingerprint: 96:bc:ec:06:26:49:76:f3:74:60:77:9a:cf:28:c5:a7:cf:e8:a3:c0:aa:e1:1a:8f:fc:ee:05:c0:bd:df:08:c6 + * -----BEGIN CERTIFICATE----- + * MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw + * TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh + * cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4 + * WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu + * ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY + * MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc + * h77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+ + * 0TM8ukj13Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6U + * A5/TR5d8mUgjU+g4rk8Kb4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sW + * T8KOEUt+zwvo/7V3LvSye0rgTBIlDHCNAymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyH + * B5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ4Q7e2RCOFvu396j3x+UC + * B5iPNgiV5+I3lg02dZ77DnKxHZu8A/lJBdiB3QW0KtZB6awBdpUKD9jf1b0SHzUv + * KBds0pjBqAlkd25HN7rOrFleaJ1/ctaJxQZBKT5ZPt0m9STJEadao0xAH0ahmbWn + * OlFuhjuefXKnEgV4We0+UXgVCwOPjdAvBbI+e0ocS3MFEvzG6uBQE3xDk3SzynTn + * jh8BCNAw1FtxNrQHusEwMFxIt4I7mKZ9YIqioymCzLq9gwQbooMDQaHWBfEbwrbw + * qHyGO0aoSCqI3Haadr8faqU9GY/rOPNk3sgrDQoo//fb4hVC1CLQJ13hef4Y53CI + * rU7m2Ys6xt0nUW7/vGT1M0NPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV + * HRMBAf8EBTADAQH/MB0GA1UdDgQWBBR5tFnme7bl5AFzgAiIyBpY9umbbjANBgkq + * hkiG9w0BAQsFAAOCAgEAVR9YqbyyqFDQDLHYGmkgJykIrGF1XIpu+ILlaS/V9lZL + * ubhzEFnTIZd+50xx+7LSYK05qAvqFyFWhfFQDlnrzuBZ6brJFe+GnY+EgPbk6ZGQ + * 3BebYhtF8GaV0nxvwuo77x/Py9auJ/GpsMiu/X1+mvoiBOv/2X/qkSsisRcOj/KK + * NFtY2PwByVS5uCbMiogziUwthDyC3+6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5 + * ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJwTdwJx4nLCgdNbOhdjsnvzqvHu7Ur + * TkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nxe5AW0wdeRlN8NwdC + * jNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZAJzVc + * oyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq + * 4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA + * mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d + * emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1)0\'\x06\x03U\x04\n\x13 Internet Security Research Group1\x150\x13\x06\x03U\x04\x03\x13\x0cISRG Root X1"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xad\xe8$s\xf4\x147\xf3\x9b\x9e+W(\x1c\x87\xbe\xdc\xb7\xdf8\x90\x8cn<\xe6W\xa0x\xf7u\xc2\xa2\xfe\xf5jn\xf6\x00O(\xdb\xdeh\x86lD\x93\xb6\xb1c\xfd\x14\x12k\xbf\x1f\xd2\xea1\x9b!~\xd13<\xbaH\xf5\xddy\xdf\xb3\xb8\xff\x12\xf1!\x9aK\xc1\x8a\x86qiJffl\x8f~Y>\xdd&\xf5$\xc9\x11\xa7Z\xa3L@\x1fF\xa1\x99\xb5\xa7:Qn\x86;\x9e}r\xa7\x12\x05xY\xed>Qx\x15\x0b\x03\x8f\x8d\xd0/\x05\xb2>{J\x1cKs\x05\x12\xfc\xc6\xea\xe0P\x13|C\x93t\xb3\xcat\xe7\x8e\x1f\x01\x08\xd00\xd4[q6\xb4\x07\xba\xc100\\H\xb7\x82;\x98\xa6}`\x8a\xa2\xa3)\x82\xcc\xba\xbd\x83\x04\x1b\xa2\x83\x03A\xa1\xd6\x05\xf1\x1b\xc2\xb6\xf0\xa8|\x86;F\xa8H*\x88\xdcv\x9av\xbf\x1fj\xa5=\x19\x8f\xeb8\xf3d\xde\xc8+\r\n(\xff\xf7\xdb\xe2\x15B\xd4\"\xd0\']\xe1y\xfe\x18\xe7p\x88\xadN\xe6\xd9\x8b:\xc6\xdd\'Qn\xff\xbcd\xf53CO\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=Buypass Class 2 Root CA O=Buypass AS-983163327 + * Subject: CN=Buypass Class 2 Root CA O=Buypass AS-983163327 + * Label: "Buypass Class 2 Root CA" + * Serial: 2 + * SHA256 Fingerprint: 9a:11:40:25:19:7c:5b:b9:5d:94:e6:3d:55:cd:43:79:08:47:b6:46:b2:3c:df:11:ad:a4:a0:0e:ff:15:fb:48 + * -----BEGIN CERTIFICATE----- + * MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEd + * MBsGA1UECgwUQnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3Mg + * Q2xhc3MgMiBSb290IENBMB4XDTEwMTAyNjA4MzgwM1oXDTQwMTAyNjA4MzgwM1ow + * TjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1eXBhc3MgQVMtOTgzMTYzMzI3MSAw + * HgYDVQQDDBdCdXlwYXNzIENsYXNzIDIgUm9vdCBDQTCCAiIwDQYJKoZIhvcNAQEB + * BQADggIPADCCAgoCggIBANfHXvfBB9R3+0Mh9PT1aeTuMgHbo4Yf5FkNuud1g1Lr + * 6hxhFUi7HQfKjK6w3Jad6sNgkoaCKHOcVgb/S2TwDCo3SbXlzwx87vFKu3MwZfPV + * L4O2fuPn9Z6rYPnT8Z2SdIrkHJasW4DptfQxh6NR/Md+oW+OU3fUl8FVM5I+GC91 + * 1K2GScuVr1QGbNgGE41b/+EmGVnAJLqBcXmQRFBoJJRfuLMR8SlBYaNByyM21cHx + * MlAQTn/0hpPshNOOvEu/XAFOBz3cFIqUCqTqc/sLUegTBxj6DvEr0VQVfTzh97QZ + * QmdiXnfgolXsttlpF9U6r0TtSsWe5HonfOV116rLJeffawrbD02TTqigzXsu8lkB + * arcNuAeBfos4GzjmCleZPe4h6KP1DBbdi+w0jpwqHAAVF41og9JwnxgIzRFo1clr + * Us3ERo/ctfPYV3Me6ZQ5BL/T3jjetFPsaRyifsSP5BtwrfKi+fv3FmRmaZ9JUaLi + * FRhnBkp/1Wy1TbMz4GHrXb7pmA8y1x1LPC5aAVKRCfLf6o3YBkBjqhHk/sM3nhRS + * P/TizPJhk9H9Z2vXUq6/aKtAQ6BXNVN48FP4YUIHZMbXb5tMOA1jrGKvNouicwoN + * 9SG9dKpN6nIDSdvHXx1iY8f93ZHsM+71bbRuMGjeyNYmsHVee7QHIJihdjK4TWxP + * AgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFMmAd+BikoL1Rpzz + * uvdMw964o605MA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsFAAOCAgEAU18h + * 9bqwOlI5LJKwbADJ784g7wbylp7ppHR/ehb8t/W2+xUbP6umwHJdELFx7rxP462s + * A20ucS6vxOOto70MEae0/0qyexAQH6dXQbLArvQsWdZHEIjzIVEpMMpghq9Gqx3t + * OluwlN5E40EIosHsHdb9T7bWR9AUC8rmyrV7d35BH16Dx7aMOZawP5aBQW9gkOLo + * +fsicdl9sz1Gv7SEr5AcD48Saq/v7h56rgJKihcrdv6sVIkkLE8/trKnToyokZf7 + * KcZ7XC25y2a2t6hbElGFtQl+Ynhw/qlqYLYdDnkM/crqJIByw5c/8nerQyIKx+u2 + * DISCLIBrQYoIwOula9+ZEsuK1V6ADJHgJgg2SMX6OBE1/yWDLfJ6v9r9jv6ly0Us + * H8SIU653DtmadsWOLB2jutXsMq7Aqqz30XpN69QH4kj3Io6wpJ9qzo6ysmD0oyLQ + * I+uUWnpp3Q+/QFesa1lQ2aOZ4W7+jQF5JyMV3pKdewlNWudLSDBaGOYKbeaP4NK7 + * 5t98biGCwWg5TbSYWGZizEqQXsP6JwSxeRV0mcy+rSDeJmAc61ZRpqPq5KM/p/9h + * 3PFaTWwyI0PurKju7koSCTxdccK+efrCh2gdC/1cacwG0Jp9VJkqyTkaGa9LKkPz + * Y11aWOIv4x3kqdbQCtCev9eBCfHJxyYNrJgWVqA= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02NO1\x1d0\x1b\x06\x03U\x04\n\x0c\x14Buypass AS-9831633271 0\x1e\x06\x03U\x04\x03\x0c\x17Buypass Class 2 Root CA"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xd7\xc7^\xf7\xc1\x07\xd4w\xfbC!\xf4\xf4\xf5i\xe4\xee2\x01\xdb\xa3\x86\x1f\xe4Y\r\xba\xe7u\x83R\xeb\xea\x1ca\x15H\xbb\x1d\x07\xca\x8c\xae\xb0\xdc\x96\x9d\xea\xc3`\x92\x86\x82(s\x9cV\x06\xffKd\xf0\x0c*7I\xb5\xe5\xcf\x0c|\xee\xf1J\xbbs0e\xf3\xd5/\x83\xb6~\xe3\xe7\xf5\x9e\xab`\xf9\xd3\xf1\x9d\x92t\x8a\xe4\x1c\x96\xac[\x80\xe9\xb5\xf41\x87\xa3Q\xfc\xc7~\xa1o\x8eSw\xd4\x97\xc1U3\x92>\x18/u\xd4\xad\x86I\xcb\x95\xafT\x06l\xd8\x06\x13\x8d[\xff\xe1&\x19Y\xc0$\xba\x81qy\x90DPh$\x94_\xb8\xb3\x11\xf1)Aa\xa3A\xcb#6\xd5\xc1\xf12P\x10N\x7f\xf4\x86\x93\xec\x84\xd3\x8e\xbcK\xbf\\\x01N\x07=\xdc\x14\x8a\x94\n\xa4\xeas\xfb\x0bQ\xe8\x13\x07\x18\xfa\x0e\xf1+\xd1T\x15}<\xe1\xf7\xb4\x19Bgb^w\xe0\xa2U\xec\xb6\xd9i\x17\xd5:\xafD\xedJ\xc5\x9e\xe4z\'|\xe5u\xd7\xaa\xcb%\xe7\xdfk\n\xdb\x0fM\x93N\xa8\xa0\xcd{.\xf2Y\x01j\xb7\r\xb8\x07\x81~\x8b8\x1b8\xe6\nW\x99=\xee!\xe8\xa3\xf5\x0c\x16\xdd\x8b\xec4\x8e\x9c*\x1c\x00\x15\x17\x8dh\x83\xd2p\x9f\x18\x08\xcd\x11h\xd5\xc9kR\xcd\xc4F\x8f\xdc\xb5\xf3\xd8Ws\x1e\xe9\x949\x04\xbf\xd3\xde8\xde\xb4S\xeci\x1c\xa2~\xc4\x8f\xe4\x1bp\xad\xf2\xa2\xf9\xfb\xf7\x16dfi\x9fIQ\xa2\xe2\x15\x18g\x06J\x7f\xd5l\xb5M\xb33\xe0a\xeb]\xbe\xe9\x98\x0f2\xd7\x1dK<.Z\x01R\x91\t\xf2\xdf\xea\x8d\xd8\x06@c\xaa\x11\xe4\xfe\xc37\x9e\x14R?\xf4\xe2\xcc\xf2a\x93\xd1\xfdgk\xd7R\xae\xbfh\xab@C\xa0W5Sx\xf0S\xf8aB\x07d\xc6\xd7o\x9bL8\rc\xacb\xaf6\x8b\xa2s\n\r\xf5!\xbdt\xaaM\xear\x03I\xdb\xc7_\x1dbc\xc7\xfd\xdd\x91\xec3\xee\xf5m\xb4n0h\xde\xc8\xd6&\xb0u^{\xb4\x07 \x98\xa1v2\xb8MlO\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=ACCVRAIZ1 O=ACCV OU=PKIACCV + * Subject: CN=ACCVRAIZ1 O=ACCV OU=PKIACCV + * Label: "ACCVRAIZ1" + * Serial: 6828503384748696800 + * SHA256 Fingerprint: 9a:6e:c0:12:e1:a7:da:9d:be:34:19:4d:47:8a:d7:c0:db:18:22:fb:07:1d:f1:29:81:49:6e:d1:04:38:41:13 + * -----BEGIN CERTIFICATE----- + * MIIH0zCCBbugAwIBAgIIXsO3pkN/pOAwDQYJKoZIhvcNAQEFBQAwQjESMBAGA1UE + * AwwJQUNDVlJBSVoxMRAwDgYDVQQLDAdQS0lBQ0NWMQ0wCwYDVQQKDARBQ0NWMQsw + * CQYDVQQGEwJFUzAeFw0xMTA1MDUwOTM3MzdaFw0zMDEyMzEwOTM3MzdaMEIxEjAQ + * BgNVBAMMCUFDQ1ZSQUlaMTEQMA4GA1UECwwHUEtJQUNDVjENMAsGA1UECgwEQUND + * VjELMAkGA1UEBhMCRVMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCb + * qau/YUqXry+XZpp0X9DZlv3P4uRm7x8fRzPCRKPfmt4ftVTdFXxpNRFvu8gMjmoY + * HtiP2Ra8EEg2XPBjs5BaXCQ316PWywlxufEBcoSwfdtNgM3802/J+Nq2DoLSRYWo + * G2ioPej0RGy9ocLLA76MPhMAhN9KSMDjIgro6TenGEyxCQ0jVn8ETdkXhBilyNpA + * lHPrzg5XPAOBOp0KoVdDaaxXbXmQeOW1tDvYvEyNKKGno6e6Ak4l0Squ7a4DIrhr + * IA8wKFSVf+DuzgpmndFALW4ir50awQUZ0m/A8p/4e7MCQvtQqR0tkw8jq8bBD5L/ + * 0KIV9VMJcRz/RROE5iZe+OCIHAr8Fraocwa48GOEAqDGWuzndN9wrqODJerWx5eH + * k6fGioozl2A3ED6XPm4pFdahD9GILBKfb6qkxkLrQaLjlUPTAYVtjrs78yM2x/47 + * 4KElB0iryYl0/wiPgL/AlmXz7uxLaL2diMMxs0Dx6M/2OLuc5NF/1OVYm3z61PMO + * m3WR5LpSLhl+0fXNWhn8ugb2+1KoS5kE3fj5tItQo05iifCHJPqDQsGH+tUtKSpa + * cXpkatcnYGMN285J9Y0fkIkyF/hzQ7jSWpOGYdbhdQrqeWZ2iE9x6wQl1gpaepPl + * uUsXQA+xtrn13k/c4LOsOxFwYIRKQ26ZIMApcQrAZQIDAQABo4ICyzCCAscwfQYI + * KwYBBQUHAQEEcTBvMEwGCCsGAQUFBzAChkBodHRwOi8vd3d3LmFjY3YuZXMvZmls + * ZWFkbWluL0FyY2hpdm9zL2NlcnRpZmljYWRvcy9yYWl6YWNjdjEuY3J0MB8GCCsG + * AQUFBzABhhNodHRwOi8vb2NzcC5hY2N2LmVzMB0GA1UdDgQWBBTSh7Tj3zcnk1X2 + * VuqB5TbMjB4/vTAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFNKHtOPfNyeT + * VfZW6oHlNsyMHj+9MIIBcwYDVR0gBIIBajCCAWYwggFiBgRVHSAAMIIBWDCCASIG + * CCsGAQUFBwICMIIBFB6CARAAQQB1AHQAbwByAGkAZABhAGQAIABkAGUAIABDAGUA + * cgB0AGkAZgBpAGMAYQBjAGkA8wBuACAAUgBhAO0AegAgAGQAZQAgAGwAYQAgAEEA + * QwBDAFYAIAAoAEEAZwBlAG4AYwBpAGEAIABkAGUAIABUAGUAYwBuAG8AbABvAGcA + * 7QBhACAAeQAgAEMAZQByAHQAaQBmAGkAYwBhAGMAaQDzAG4AIABFAGwAZQBjAHQA + * cgDzAG4AaQBjAGEALAAgAEMASQBGACAAUQA0ADYAMAAxADEANQA2AEUAKQAuACAA + * QwBQAFMAIABlAG4AIABoAHQAdABwADoALwAvAHcAdwB3AC4AYQBjAGMAdgAuAGUA + * czAwBggrBgEFBQcCARYkaHR0cDovL3d3dy5hY2N2LmVzL2xlZ2lzbGFjaW9uX2Mu + * aHRtMFUGA1UdHwROMEwwSqBIoEaGRGh0dHA6Ly93d3cuYWNjdi5lcy9maWxlYWRt + * aW4vQXJjaGl2b3MvY2VydGlmaWNhZG9zL3JhaXphY2N2MV9kZXIuY3JsMA4GA1Ud + * DwEB/wQEAwIBBjAXBgNVHREEEDAOgQxhY2N2QGFjY3YuZXMwDQYJKoZIhvcNAQEF + * BQADggIBAJcxAp/n/UNnSEQU5CmH7UwoZtCPNdpNYbdKl02125DgBS4OxnnQ8pdp + * D70ER9m+27Up2pvZrqmZ1dM8MJP1jaGo/AaNRPTKFpV8M9xii6g3+CfYCS0b78gU + * JyCpZET/LtZ1qmxNYEAZSUNUY9rizLpm5U9EelvZaoErQNV/+QEnWCzI7UiRfD+m + * AM/EKXMRNt6GGT6d7hmKG9Ww7Y49nCrADdg9ZuM8Db3VlFzi4qc1GwQA9j9ajepD + * vV+JHanBsMyZ4k0ACtrJJ1vnE5Bc5PUzolVt3OAJTS+xJlsndQAJxGJ3KQhfnlms + * tn6tn1QwIgPBHnFk/vk4CpYY3QIUrCPLBhwepH2NDd4nQeit2hW3sCPdK6jT2iWH + * 7ehVRE2I9DZ+hJp4rPcOVkkO1jMl1oRQQmwgEh0q1b688nCBpHBgvgW1m54ERL5h + * I6zppSSMEYCUWqKiuUnSwdzRp+0xESyeGabu4VXhwOrPDYTkF7eifKXeVSUG7szA + * h1xA2syVP1XgNce4hL60Xc16gwFy7ofmXx2utYXGJt/mwZrpHgJHnyqobalbz+xF + * d3+YJ5oyXSrjhO7FmGYvliAd3djDJ9ew+f7Zfc3Qn48LFFhRny+Lwzgt3uiP1o2H + * pPVWQxaZLPSkVrQ0uGE3ycJYgBugl6H8WY3pEfbRD0tVNEYqi4Y7 + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x120\x10\x06\x03U\x04\x03\x0c\tACCVRAIZ11\x100\x0e\x06\x03U\x04\x0b\x0c\x07PKIACCV1\r0\x0b\x06\x03U\x04\n\x0c\x04ACCV1\x0b0\t\x06\x03U\x04\x06\x13\x02ES"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\x9b\xa9\xab\xbfaJ\x97\xaf/\x97f\x9at_\xd0\xd9\x96\xfd\xcf\xe2\xe4f\xef\x1f\x1fG3\xc2D\xa3\xdf\x9a\xde\x1f\xb5T\xdd\x15|i5\x11o\xbb\xc8\x0c\x8ej\x18\x1e\xd8\x8f\xd9\x16\xbc\x10H6\\\xf0c\xb3\x90Z\\$7\xd7\xa3\xd6\xcb\tq\xb9\xf1\x01r\x84\xb0}\xdbM\x80\xcd\xfc\xd3o\xc9\xf8\xda\xb6\x0e\x82\xd2E\x85\xa8\x1bh\xa8=\xe8\xf4Dl\xbd\xa1\xc2\xcb\x03\xbe\x8c>\x13\x00\x84\xdfJH\xc0\xe3\"\n\xe8\xe97\xa7\x18L\xb1\t\r#V\x7f\x04M\xd9\x17\x84\x18\xa5\xc8\xda@\x94s\xeb\xce\x0eW<\x03\x81:\x9d\n\xa1WCi\xacWmy\x90x\xe5\xb5\xb4;\xd8\xbcL\x8d(\xa1\xa7\xa3\xa7\xba\x02N%\xd1*\xae\xed\xae\x03\"\xb8k \x0f0(T\x95\x7f\xe0\xee\xce\nf\x9d\xd1@-n\"\xaf\x9d\x1a\xc1\x05\x19\xd2o\xc0\xf2\x9f\xf8{\xb3\x02B\xfbP\xa9\x1d-\x93\x0f#\xab\xc6\xc1\x0f\x92\xff\xd0\xa2\x15\xf5S\tq\x1c\xffE\x13\x84\xe6&^\xf8\xe0\x88\x1c\n\xfc\x16\xb6\xa8s\x06\xb8\xf0c\x84\x02\xa0\xc6Z\xec\xe7t\xdfp\xae\xa3\x83%\xea\xd6\xc7\x97\x87\x93\xa7\xc6\x8a\x8a3\x97`7\x10>\x97>n)\x15\xd6\xa1\x0f\xd1\x88,\x12\x9fo\xaa\xa4\xc6B\xebA\xa2\xe3\x95C\xd3\x01\x85m\x8e\xbb;\xf3#6\xc7\xfe;\xe0\xa1%\x07H\xab\xc9\x89t\xff\x08\x8f\x80\xbf\xc0\x96e\xf3\xee\xecKh\xbd\x9d\x88\xc31\xb3@\xf1\xe8\xcf\xf68\xbb\x9c\xe4\xd1\x7f\xd4\xe5X\x9b|\xfa\xd4\xf3\x0e\x9bu\x91\xe4\xbaR.\x19~\xd1\xf5\xcdZ\x19\xfc\xba\x06\xf6\xfbR\xa8K\x99\x04\xdd\xf8\xf9\xb4\x8bP\xa3Nb\x89\xf0\x87$\xfa\x83B\xc1\x87\xfa\xd5-)*Zqzdj\xd7\'`c\r\xdb\xceI\xf5\x8d\x1f\x90\x892\x17\xf8sC\xb8\xd2Z\x93\x86a\xd6\xe1u\n\xeayfv\x88Oq\xeb\x04%\xd6\nZz\x93\xe5\xb9K\x17@\x0f\xb1\xb6\xb9\xf5\xdeO\xdc\xe0\xb3\xac;\x11p`\x84JCn\x99 \xc0)q\n\xc0e\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=OISTE Server Root RSA G1 O=OISTE Foundation + * Subject: CN=OISTE Server Root RSA G1 O=OISTE Foundation + * Label: "OISTE Server Root RSA G1" + * Serial: 113845518112613905024960613408179309848 + * SHA256 Fingerprint: 9a:e3:62:32:a5:18:9f:fd:db:35:3d:fd:26:52:0c:01:53:95:d2:27:77:da:c5:9d:b5:7b:98:c0:89:a6:51:e6 + * -----BEGIN CERTIFICATE----- + * MIIFgzCCA2ugAwIBAgIQVaXZZ5Qoxu0M+ifdWwFNGDANBgkqhkiG9w0BAQwFADBL + * MQswCQYDVQQGEwJDSDEZMBcGA1UECgwQT0lTVEUgRm91bmRhdGlvbjEhMB8GA1UE + * AwwYT0lTVEUgU2VydmVyIFJvb3QgUlNBIEcxMB4XDTIzMDUzMTE0MzcxNloXDTQ4 + * MDUyNDE0MzcxNVowSzELMAkGA1UEBhMCQ0gxGTAXBgNVBAoMEE9JU1RFIEZvdW5k + * YXRpb24xITAfBgNVBAMMGE9JU1RFIFNlcnZlciBSb290IFJTQSBHMTCCAiIwDQYJ + * KoZIhvcNAQEBBQADggIPADCCAgoCggIBAKqu9KuCz/vlNwvn1ZatkOhLKdxVYOPM + * vLO8LZK55KN68YG0nnJyQ98/qwsmtO57Gmn7KNByXEptaZnwYx4M0rH/1ow00O7b + * rEi56rAUjtgHqSSY3ekJvqgiG1k50SeH3BzN+Puz6+mTeO0Pzjd8JnduodgsIUzk + * ik/HEzxux9UTl7Ko2yRpg1bTacuCErudG/L4NPKYKyqOBGf244ehHa1uzjZ0Dl4z + * O8vbUZeUapU8zhhabkvG/AePLhq5SvdkNCncpo1Q4Y2LS+VIG24ugBA/5J8bZT8R + * tOpXaZ+0AOuFJJkk9SGdl6r7NH8CaxWQrbueWhl/pIzY+m0o/DjH40ytas7ZTpOS + * jswMZ78LS5bOZmdTaMsXEY5Z96ycG7mOaES3GK/m5Q9l3JUJsJMStR8+lKXHiHUh + * sd4JJCpM4rzsTGdHwimIuQq6+cF0zowYJmXa92/GjHtoXAvuY8BeS/FOzJ8vD+Ho + * mnqT8eDI278n5mUpezbgMxVz8p1rhAhoKzYHKyfMeNhqhw5HdPSqoBNdZH702xSu + * +zrkL8Fl47l6QGzwBrd7KJvX4V84c5Ss2XCTLdyEr0YconosP4EmQufU2MVshGYR + * i3drVByjtdgQ8K4p92cIiBdcuJd5z+orKu5YM+Vt6SmqZQENghPsJQtdLEByFSnT + * kCz3GkPVavBpAgMBAAGjYzBhMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAU + * 8snBDw1jALvsRQ5KH7WxszbNDo0wHQYDVR0OBBYEFPLJwQ8NYwC77EUOSh+1sbM2 + * zQ6NMA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0BAQwFAAOCAgEANGd5sjrG5T33 + * I3K5Ce+SrScfoE4KsvXaFwyihdJ+klH9FWXXXGtkFu6KRcoMQzZENdl//nk6HOjG + * 5D1rd9QhEOP28yBOqb6J8xycqd+8MDoX0TJD0KqKchxRKEzdNsjkLWd9kYccnbz8 + * qyiWXmFcuCIzGEgWUOrKL+mlSdx/PKQZvDatkuK59EvV6wit53j+F8Bdh3foZ3dP + * AGav9LEDOr4SfEE15fSmG0eLy3n31r8Xbk5l8PjaV8GUgeV6Vg27Rn9vkf195hfk + * gSe7BYhW3SCl95gtkRlpMV+bMPKZrXJAlszYd2abtNUOshD+FKrDgHGdPY3ofRRs + * YWSGRqbXVMW215AWRqWFyp464+YTFrYVI8ypKVL9AMb2kI5Wj4kI3Zaq5tNqqYY1 + * 9tVFeEJKRvwDyF7YZvZFZSS0vod7VSCd9521Kvy5YhnLbDuv0204bKt7ph6N/Ome + * /msVuduCmsuY33OhkKCgxeDoAaijFJzIwZqsFVAzje18KotzlUBDJvyBpCpfOZC3 + * J8tRd/iWkx7P8nd9H0aTolkelUTFLXVksNb54Dxp6gS1HAviRkRNQzuXSXERvSS2 + * wq1yVAb+axj5d9spLFKebXd7Yv0PTY6YMjAwcRLWJTXjn/hvnLXrahut6hDTlhZy + * BiElxky8j3C7DOReIoMt0r7+hVu05L0= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02CH1\x190\x17\x06\x03U\x04\n\x0c\x10OISTE Foundation1!0\x1f\x06\x03U\x04\x03\x0c\x18OISTE Server Root RSA G1"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xaa\xae\xf4\xab\x82\xcf\xfb\xe57\x0b\xe7\xd5\x96\xad\x90\xe8K)\xdcU`\xe3\xcc\xbc\xb3\xbc-\x92\xb9\xe4\xa3z\xf1\x81\xb4\x9errC\xdf?\xab\x0b&\xb4\xee{\x1ai\xfb(\xd0r\\Jmi\x99\xf0c\x1e\x0c\xd2\xb1\xff\xd6\x8c4\xd0\xee\xdb\xacH\xb9\xea\xb0\x14\x8e\xd8\x07\xa9$\x98\xdd\xe9\t\xbe\xa8\"\x1bY9\xd1\'\x87\xdc\x1c\xcd\xf8\xfb\xb3\xeb\xe9\x93x\xed\x0f\xce7|&wn\xa1\xd8,!L\xe4\x8aO\xc7\x13\x94\xa5\xc7\x88u!\xb1\xde\t$*L\xe2\xbc\xecLgG\xc2)\x88\xb9\n\xba\xf9\xc1t\xce\x8c\x18&e\xda\xf7o\xc6\x8c{h\\\x0b\xeec\xc0^K\xf1N\xcc\x9f/\x0f\xe1\xe8\x9az\x93\xf1\xe0\xc8\xdb\xbf\'\xe6e){6\xe03\x15s\xf2\x9dk\x84\x08h+6\x07+\'\xccx\xd8j\x87\x0eGt\xf4\xaa\xa0\x13]d~\xf4\xdb\x14\xae\xfb:\xe4/\xc1e\xe3\xb9z@l\xf0\x06\xb7{(\x9b\xd7\xe1_8s\x94\xac\xd9p\x93-\xdc\x84\xafF\x1c\xa2z,?\x81&B\xe7\xd4\xd8\xc5l\x84f\x11\x8bwkT\x1c\xa3\xb5\xd8\x10\xf0\xae)\xf7g\x08\x88\x17\\\xb8\x97y\xcf\xea+*\xeeX3\xe5m\xe9)\xaae\x01\r\x82\x13\xec%\x0b],@r\x15)\xd3\x90,\xf7\x1aC\xd5j\xf0i\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=UCA Global G2 Root O=UniTrust + * Subject: CN=UCA Global G2 Root O=UniTrust + * Label: "UCA Global G2 Root" + * Serial: 124779693093741543919145257850076631279 + * SHA256 Fingerprint: 9b:ea:11:c9:76:fe:01:47:64:c1:be:56:a6:f9:14:b5:a5:60:31:7a:bd:99:88:39:33:82:e5:16:1a:a0:49:3c + * -----BEGIN CERTIFICATE----- + * MIIFRjCCAy6gAwIBAgIQXd+x2lqj7V2+WmUgZQOQ7zANBgkqhkiG9w0BAQsFADA9 + * MQswCQYDVQQGEwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxGzAZBgNVBAMMElVDQSBH + * bG9iYWwgRzIgUm9vdDAeFw0xNjAzMTEwMDAwMDBaFw00MDEyMzEwMDAwMDBaMD0x + * CzAJBgNVBAYTAkNOMREwDwYDVQQKDAhVbmlUcnVzdDEbMBkGA1UEAwwSVUNBIEds + * b2JhbCBHMiBSb290MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAxeYr + * b3zvJgUno4Ek2m/LAfmZmqkywiKHYUGRO8vDaBsGxUypK8FnFyIdK+35KYmToni9 + * kmugow2ifsqTs6bRjDXVdfkX9s9FxeV67HeToI8jrg4aA3++1NDtLnurRiNb/yzm + * VHqUwCoV8MmNsHo7JOHXaOIxPAYzRrZUEaalLyJUKlgNAQLx+hVRZ2zA+te2G3/R + * VogvGjqNO7uCEeBHANBSh6v7hn4PJGtAnTRnvI3HLYZveT6OqTwXS3+wmeOwcWDc + * C/Vkw85DvG1xudLeJ1uK6NjGruFZfc8oLTW4lVYa8bJYS7cSN8h8s+1LgOGN+jIj + * tm+3SJUIsUROhYw6AlQgL9+/V087OpAh18EmNVQg7Mc/R+zvWr9LesGtOxdQXGLY + * D0tK3Cv6brxzks3sx1DoQZbXqX5t2Okdj4q1uViSukqSKwxW/YDrCPBeKW4bHAyv + * j5OJrdu9o54hyokZ7N+1wxrrFv54NkzWbtA+FxyQF2smuvt6L78RHBgOLXMDj6Dl + * NaBa4kx1HXHhOThTeEDMg5PXCp6dW4+K5OXgSORIskfNTip1KnvyIvbJvgmRlld6 + * iIis7nCs+dwp4wwcOxJORNanTrAmyPPZGpeRaOrvjUYG0lZFWJo8DA+DuAUlwznP + * O6Q0ibd5Ei9Hxeepl2n8pndntd978XplFeRhVmUCAwEAAaNCMEAwDgYDVR0PAQH/ + * BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFIHEjMz15DD/pQwIX4wV + * ZyF0Ad/fMA0GCSqGSIb3DQEBCwUAA4ICAQATZSL1jiutROTL/7lo5sOASD0Ee/oj + * L3rtNtqyzm325p7lX1iPyzcyochltq44PTUbPrw7tgTQvPlJ9Zv3hcU2tsu8+Mg5 + * 1eRfB70VVJd0ysrtT7q6ZHafgbiERUlMjW+i67HM0cOU2kTC5uLqGOiiHycFutfl + * 1qnN3e92mI0ADs0b+gO3joBYDic/UvuUospeZcnWhNq5NXHzJsBPd+aBJ9J3O5oU + * b3n09tDh05S60FdRvScFDcH9yBIw7m+NESsIndTUv4BFFJqIRNow6rSn4+7vW4LV + * PtateJLbXDzz2K36uGt/xDYotgIVilQsnLAXc47QN6MUPJiVAAwpBVueSUmxX8fj + * y88nZY41F7dXyDDZQVu5FLbowg+UMaeUmMxq67XhJ/UQqAHojhJi6IjMtX9Gl8Cb + * EGY4GjZGXyJoPd/JxhMnq1MGrKI8hgZlb7F+sSlEmqO6SWkoaY/X5V+tBIZkbxqg + * DMUIYs6Ao9Dz7GjevjPHF1t/gMRMTLGmhIrDO7gJzRSBuhjjVFc2/tsvfEehOjPI + * +Vg7RE+xygKJBJYoaMVLuCaJu9YzL1DV/pqJuhgyklTGW+Cd+V7lDSKb9triyCGy + * YiGqhkCyLmTTX8jjfhFnRR8F/uOi77Oos/N9j/gMHyIfLXC0uAE0djAA5SN4p1bX + * UB+K+wb1whnw0A== + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02CN1\x110\x0f\x06\x03U\x04\n\x0c\x08UniTrust1\x1b0\x19\x06\x03U\x04\x03\x0c\x12UCA Global G2 Root"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xc5\xe6+o|\xef&\x05\'\xa3\x81$\xdao\xcb\x01\xf9\x99\x9a\xa92\xc2\"\x87aA\x91;\xcb\xc3h\x1b\x06\xc5L\xa9+\xc1g\x17\"\x1d+\xed\xf9)\x89\x93\xa2x\xbd\x92k\xa0\xa3\r\xa2~\xca\x93\xb3\xa6\xd1\x8c5\xd5u\xf9\x17\xf6\xcfE\xc5\xe5z\xecw\x93\xa0\x8f#\xae\x0e\x1a\x03\x7f\xbe\xd4\xd0\xed.{\xabF#[\xff,\xe6Tz\x94\xc0*\x15\xf0\xc9\x8d\xb0z;$\xe1\xd7h\xe21<\x063F\xb6T\x11\xa6\xa5/\"T*X\r\x01\x02\xf1\xfa\x15Qgl\xc0\xfa\xd7\xb6\x1b\x7f\xd1V\x88/\x1a:\x8d;\xbb\x82\x11\xe0G\x00\xd0R\x87\xab\xfb\x86~\x0f$k@\x9d4g\xbc\x8d\xc7-\x86oy>\x8e\xa9<\x17K\x7f\xb0\x99\xe3\xb0q`\xdc\x0b\xf5d\xc3\xceC\xbcmq\xb9\xd2\xde\'[\x8a\xe8\xd8\xc6\xae\xe1Y}\xcf(-5\xb8\x95V\x1a\xf1\xb2XK\xb7\x127\xc8|\xb3\xedK\x80\xe1\x8d\xfa2#\xb6o\xb7H\x95\x08\xb1DN\x85\x8c:\x02T /\xdf\xbfWO;:\x90!\xd7\xc1&5T \xec\xc7?G\xec\xefZ\xbfKz\xc1\xad;\x17P\\b\xd8\x0fKJ\xdc+\xfan\xbcs\x92\xcd\xec\xc7P\xe8A\x96\xd7\xa9~m\xd8\xe9\x1d\x8f\x8a\xb5\xb9X\x92\xbaJ\x92+\x0cV\xfd\x80\xeb\x08\xf0^)n\x1b\x1c\x0c\xaf\x8f\x93\x89\xad\xdb\xbd\xa3\x9e!\xca\x89\x19\xec\xdf\xb5\xc3\x1a\xeb\x16\xfex6L\xd6n\xd0>\x17\x1c\x90\x17k&\xba\xfbz/\xbf\x11\x1c\x18\x0e-s\x03\x8f\xa0\xe55\xa0Z\xe2Lu\x1dq\xe198Sx@\xcc\x83\x93\xd7\n\x9e\x9d[\x8f\x8a\xe4\xe5\xe0H\xe4H\xb2G\xcdN*u*{\xf2\"\xf6\xc9\xbe\t\x91\x96Wz\x88\x88\xac\xeep\xac\xf9\xdc)\xe3\x0c\x1c;\x12ND\xd6\xa7N\xb0&\xc8\xf3\xd9\x1a\x97\x91h\xea\xef\x8dF\x06\xd2VEX\x9a<\x0c\x0f\x83\xb8\x05%\xc39\xcf;\xa44\x89\xb7y\x12/G\xc5\xe7\xa9\x97i\xfc\xa6wg\xb5\xdf{\xf1ze\x15\xe4aVe\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=Hellenic Academic and Research Institutions RootCA 2015 O=Hellenic Academic and Research Institutions Cert. Authority + * Subject: CN=Hellenic Academic and Research Institutions RootCA 2015 O=Hellenic Academic and Research Institutions Cert. Authority + * Label: "Hellenic Academic and Research Institutions RootCA 2015" + * Serial: 0 + * SHA256 Fingerprint: a0:40:92:9a:02:ce:53:b4:ac:f4:f2:ff:c6:98:1c:e4:49:6f:75:5e:6d:45:fe:0b:2a:69:2b:cd:52:52:3f:36 + * -----BEGIN CERTIFICATE----- + * MIIGCzCCA/OgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBpjELMAkGA1UEBhMCR1Ix + * DzANBgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5k + * IFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNVBAMT + * N0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgUm9v + * dENBIDIwMTUwHhcNMTUwNzA3MTAxMTIxWhcNNDAwNjMwMTAxMTIxWjCBpjELMAkG + * A1UEBhMCR1IxDzANBgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNh + * ZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3JpdHkx + * QDA+BgNVBAMTN0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1 + * dGlvbnMgUm9vdENBIDIwMTUwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoIC + * AQDC+Kk/G4n8PDwEXT2QNrCROnk8ZlrvbTkBSRq0t89/TSNTt5AA4xMqKKYx8ZEA + * 4yjsriFBzh/a/X0SWwGDD7mwX5nh8hKDgE0GPt+sr+ehiGsxr/CL0BgzuNtFajT0 + * AoAkKAoCFZVedioNmToUW/bLy1O8E00BiDeUJRtCvCLYjqOWXjrZMts+6PAQZe10 + * 4S+nfK8nNLspfZu2zwnI5dMK/IhlZXQK3HMcXM1AsRzUtoSMTFDPaI6oWa7CJ06C + * ojXdFPQf/7J31Ycvqm59JCfnxssm5uX+Zwdj2EUN3TpZZTlYepKZcj2chF6IIbjV + * 9Cz82XBST3i4vTwri5WY9bPRaM8gFH5MXF/ni+X1NYEZN9cRCLdmvtNKzoNXADrD + * gfgXy5I2XdGj2HUb4Ysn6npIQf1FGQatJ5lOwXBH3bWfgVMS5bGMSF0xQxfjjMZ6 + * Y5ZLKTBOhE5iGV48zpeQpX8B653g+IuJ3SWYPZK2fu/Z8VFRfS0myGlZYeCsargq + * NhEEelC9MoS+L9xy1dcdFkfkR2YgP/SWxa+OAXqlD3pk9Q0Yh9muiNX6hME6wGko + * LfINaFGq46V3xqSQDqE3izEjR8EJCOtu93ib14L8hCCZSRm2Ekax+0VVFqmjZayc + * Bw/qa9wfLgZy7IaIEuQt218FL+TwA9MmM+eAws1CoRc0CwIDAQABo0IwQDAPBgNV + * HRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUcRVnyMjJvXVd + * ctA4GGqd83EkVAswDQYJKoZIhvcNAQELBQADggIBAHW7bVRLqhBYRjTyYtcWNl0I + * XtVsyIe9tC5G8jH4fOpCtZMWVdyhDBKg2mF+D1hYc2Ryx+hFjtyp8iY/xnmMsVMI + * M4GwVhO+5lFc2JsKT0ucVlMC6U/2DWDqTUJV6HwbISHTGzrMd/K4kPFox/la/vot + * 9L/J9UUbzjgQKjeKeaO04wlshYaT/4mWJ3iBj2fjRnRUjtkNaeJK9E10A/+yd+2V + * Z5fkscWrv2oj6NSU4kQoYsRL4vDY4ilrGnB+JGGTe08DMiUNRSQrlrRGar9KC/ea + * j8GsGsVn82800vpzY4zvFrCopEYq+OsS7HK07/grfoxSwIuEVPkvPuNVqNxmsdnh + * X9izjFk0WaSrT2y7HxjbdavYy5LNlDhhDgcGH0tGEPEVvo2FXDtKK4F5D7Rpn0lQ + * l033DlZdwJVqwjbDG2jJ9SrcR5q+ss7FJej6A7na+RZukYT1HCjI/CbM1xyQVqdf + * bzoEvM14iQuODy+jqk+iGxI9FghAD/FGTNeqewjBCvVtJ94Cj8rDtSvK6evIIVM4 + * pcw72Hc3MKJP2W/R8kCtQXoXxdZKNYm3QdV8hn9VTYNKpXMgwDqvkPGaJI7ZjnHK + * e7iG2rKPmT4dEw0SEe7Uq/DpFXYC5ODfqiAeW2GFZECpkJcNrVPSWh2HagCXZWK0 + * vm9qp/UsQu0yrbYhnr68 + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02GR1\x0f0\r\x06\x03U\x04\x07\x13\x06Athens1D0B\x06\x03U\x04\n\x13;Hellenic Academic and Research Institutions Cert. Authority1@0>\x06\x03U\x04\x03\x137Hellenic Academic and Research Institutions RootCA 2015"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xc2\xf8\xa9?\x1b\x89\xfc<<\x04]=\x906\xb0\x91:y\xdf\xac\xaf\xe7\xa1\x88k1\xaf\xf0\x8b\xd0\x183\xb8\xdbEj4\xf4\x02\x80$(\n\x02\x15\x95^v*\r\x99:\x14[\xf6\xcb\xcbS\xbc\x13M\x01\x887\x94%\x1bB\xbc\"\xd8\x8e\xa3\x96^:\xd92\xdb>\xe8\xf0\x10e\xedt\xe1/\xa7|\xaf\'4\xbb)}\x9b\xb6\xcf\t\xc8\xe5\xd3\n\xfc\x88eet\n\xdcs\x1c\\\xcd@\xb1\x1c\xd4\xb6\x84\x8cLP\xcfh\x8e\xa8Y\xae\xc2\'N\x82\xa25\xdd\x14\xf4\x1f\xff\xb2w\xd5\x87/\xaan}$\'\xe7\xc6\xcb&\xe6\xe5\xfeg\x07c\xd8E\r\xdd:Ye9Xz\x92\x99r=\x9c\x84^\x88!\xb8\xd5\xf4,\xfc\xd9pROx\xb8\xbd<+\x8b\x95\x98\xf5\xb3\xd1h\xcf \x14~L\\_\xe7\x8b\xe5\xf55\x81\x197\xd7\x11\x08\xb7f\xbe\xd3J\xce\x83W\x00:\xc3\x81\xf8\x17\xcb\x926]\xd1\xa3\xd8u\x1b\xe1\x8b\'\xeazHA\xfdE\x19\x06\xad\'\x99N\xc1pG\xdd\xb5\x9f\x81S\x12\xe5\xb1\x8cH]1C\x17\xe3\x8c\xc6zc\x96K)0N\x84Nb\x19^<\xce\x97\x90\xa5\x7f\x01\xeb\x9d\xe0\xf8\x8b\x89\xdd%\x98=\x92\xb6~\xef\xd9\xf1QQ}-&\xc8iYa\xe0\xacj\xb8*6\x11\x04zP\xbd2\x84\xbe/\xdcr\xd5\xd7\x1d\x16G\xe4Gf ?\xf4\x96\xc5\xaf\x8e\x01z\xa5\x0fzd\xf5\r\x18\x87\xd9\xae\x88\xd5\xfa\x84\xc1:\xc0i(-\xf2\rhQ\xaa\xe3\xa5w\xc6\xa4\x90\x0e\xa17\x8b1#G\xc1\t\x08\xebn\xf7x\x9b\xd7\x82\xfc\x84 \x99I\x19\xb6\x12F\xb1\xfbEU\x16\xa9\xa3e\xac\x9c\x07\x0f\xeak\xdc\x1f.\x06r\xec\x86\x88\x12\xe4-\xdb_\x05/\xe4\xf0\x03\xd3&3\xe7\x80\xc2\xcdB\xa1\x174\x0b\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=SZAFIR ROOT CA2 O=Krajowa Izba Rozliczeniowa S.A. + * Subject: CN=SZAFIR ROOT CA2 O=Krajowa Izba Rozliczeniowa S.A. + * Label: "SZAFIR ROOT CA2" + * Serial: 357043034767186914217277344587386743377558296292 + * SHA256 Fingerprint: a1:33:9d:33:28:1a:0b:56:e5:57:d3:d3:2b:1c:e7:f9:36:7e:b0:94:bd:5f:a7:2a:7e:50:04:c8:de:d7:ca:fe + * -----BEGIN CERTIFICATE----- + * MIIDcjCCAlqgAwIBAgIUPopdB+xV0jLVt+O2XwHrLdzk1uQwDQYJKoZIhvcNAQEL + * BQAwUTELMAkGA1UEBhMCUEwxKDAmBgNVBAoMH0tyYWpvd2EgSXpiYSBSb3psaWN6 + * ZW5pb3dhIFMuQS4xGDAWBgNVBAMMD1NaQUZJUiBST09UIENBMjAeFw0xNTEwMTkw + * NzQzMzBaFw0zNTEwMTkwNzQzMzBaMFExCzAJBgNVBAYTAlBMMSgwJgYDVQQKDB9L + * cmFqb3dhIEl6YmEgUm96bGljemVuaW93YSBTLkEuMRgwFgYDVQQDDA9TWkFGSVIg + * Uk9PVCBDQTIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC3vD5QqEvN + * QLXOYeeWyrSh2gwisPq1e3YAd4wLz32ohswmUeQgPYUM1ljj5/QqGJ3a0a4m7utT + * 3PSQ1hNKDJA8w/Ta0o4NkjrcsbH/ON7Dui1fgLkCvUqdGw+0w8LBZwPd3BucPbOw + * 3gAeqDRHu5rr/gsUvTaE2g0gv/pby6kWIK05YO4vdbbnl5z5Pv1+TW9NL++IDWr6 + * 3fE9biCloBK0TXC5ztdyO4mTp4CEHCdJckm1/zuVnsHMyAHs6A6KCpbns6aH5db5 + * BSsNl0BwPLqsdVqc1U2dAgrSS5tmS0YHF2Wtn2yIANwiieDhZNRnvDF5YTy7ykHN + * XGoAyDw4jlivAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQD + * AgEGMB0GA1UdDgQWBBQuFqlKGLXLzPVvUPMjX/hd56zwyDANBgkqhkiG9w0BAQsF + * AAOCAQEAtXP4A9xZWx126aMqe5Aosk3AM0+qmrHUuOQn/6mWmc5G4G18TKI4pAZw + * 8PRBEew/R40/cof5O/2kbytTAOD/OblqBw7rHRz2onKQy4I9EYKL0rufKq8h5mOG + * nXkZ7/e7DDWQw4rtTw/1zBLZpD67oPwglV9PJi8RI4NOdQcPv5vRtB3pEAT+ymCP + * oky4rc/hkA/NrgrHXXu3UNLUYfrVFdvXn4dRVOul4+vJhaAlIDf7js4MNIThPIGy + * d05DpYhfhmehPea0XGG2Ptv+tyjFogeutcrKjSoS75ftwjCkySp6+/NNIxuZMzSg + * LvWpCz/UXeHPhJ/iGcJfitYgHuNztw== + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02PL1(0&\x06\x03U\x04\n\x0c\x1fKrajowa Izba Rozliczeniowa S.A.1\x180\x16\x06\x03U\x04\x03\x0c\x0fSZAFIR ROOT CA2"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x01\x0f\x000\x82\x01\n\x02\x82\x01\x01\x00\xb7\xbc>P\xa8K\xcd@\xb5\xcea\xe7\x96\xca\xb4\xa1\xda\x0c\"\xb0\xfa\xb5{v\x00w\x8c\x0b\xcf}\xa8\x86\xcc&Q\xe4 =\x85\x0c\xd6X\xe3\xe7\xf4*\x18\x9d\xda\xd1\xae&\xee\xebS\xdc\xf4\x90\xd6\x13J\x0c\x90<\xc3\xf4\xda\xd2\x8e\r\x92:\xdc\xb1\xb1\xff8\xde\xc3\xba-_\x80\xb9\x02\xbdJ\x9d\x1b\x0f\xb4\xc3\xc2\xc1g\x03\xdd\xdc\x1b\x9c=\xb3\xb0\xde\x00\x1e\xa84G\xbb\x9a\xeb\xfe\x0b\x14\xbd6\x84\xda\r \xbf\xfa[\xcb\xa9\x16 \xad9`\xee/u\xb6\xe7\x97\x9c\xf9>\xfd~MoM/\xef\x88\rj\xfa\xdd\xf1=n \xa5\xa0\x12\xb4Mp\xb9\xce\xd7r;\x89\x93\xa7\x80\x84\x1c\'IrI\xb5\xff;\x95\x9e\xc1\xcc\xc8\x01\xec\xe8\x0e\x8a\n\x96\xe7\xb3\xa6\x87\xe5\xd6\xf9\x05+\r\x97@p<\xba\xacuZ\x9c\xd5M\x9d\x02\n\xd2K\x9bfKF\x07\x17e\xad\x9fl\x88\x00\xdc\"\x89\xe0\xe1d\xd4g\xbc1ya<\xbb\xcaA\xcd\\j\x00\xc8<8\x8eX\xaf\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=GlobalSign O=GlobalSign OU=GlobalSign ECC Root CA - R4 + * Subject: CN=GlobalSign O=GlobalSign OU=GlobalSign ECC Root CA - R4 + * Label: "GlobalSign" + * Serial: 159662223612894884239637590694 + * SHA256 Fingerprint: b0:85:d7:0b:96:4f:19:1a:73:e4:af:0d:54:ae:7a:0e:07:aa:fd:af:9b:71:dd:08:62:13:8a:b7:32:5a:24:a2 + * -----BEGIN CERTIFICATE----- + * MIIB3DCCAYOgAwIBAgINAgPlfvU/k/2lCSGypjAKBggqhkjOPQQDAjBQMSQwIgYD + * VQQLExtHbG9iYWxTaWduIEVDQyBSb290IENBIC0gUjQxEzARBgNVBAoTCkdsb2Jh + * bFNpZ24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMTIxMTEzMDAwMDAwWhcNMzgw + * MTE5MDMxNDA3WjBQMSQwIgYDVQQLExtHbG9iYWxTaWduIEVDQyBSb290IENBIC0g + * UjQxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2JhbFNpZ24wWTAT + * BgcqhkjOPQIBBggqhkjOPQMBBwNCAAS4xnnTj2wlDp8uORkcA6SumuU5BwkWymOx + * uYb4ilfBV85C+nOh92VC/x7BALJucw7/xyHlGKSq2XE/qNS5zowdo0IwQDAOBgNV + * HQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUVLB7rUW44kB/ + * +wpu+74zyTyjhNUwCgYIKoZIzj0EAwIDRwAwRAIgIk90crlgr/HmnKAWBVBfw147 + * bmF0774BxL4YSFlhgjICICadVGNA3jdgUM/I2O2dgq43mLyjj0xMqTQrbO/7lZsm + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1$0\"\x06\x03U\x04\x0b\x13\x1bGlobalSign ECC Root CA - R41\x130\x11\x06\x03U\x04\n\x13\nGlobalSign1\x130\x11\x06\x03U\x04\x03\x13\nGlobalSign"), + subject_public_key_info: Der::from_slice(b"0\x13\x06\x07*\x86H\xce=\x02\x01\x06\x08*\x86H\xce=\x03\x01\x07\x03B\x00\x04\xb8\xc6y\xd3\x8fl%\x0e\x9f.9\x19\x1c\x03\xa4\xae\x9a\xe59\x07\t\x16\xcac\xb1\xb9\x86\xf8\x8aW\xc1W\xceB\xfas\xa1\xf7eB\xff\x1e\xc1\x00\xb2ns\x0e\xff\xc7!\xe5\x18\xa4\xaa\xd9q?\xa8\xd4\xb9\xce\x8c\x1d"), + name_constraints: None + }, + + /* + * Issuer: CN=Atos TrustedRoot Root CA ECC TLS 2021 O=Atos + * Subject: CN=Atos TrustedRoot Root CA ECC TLS 2021 O=Atos + * Label: "Atos TrustedRoot Root CA ECC TLS 2021" + * Serial: 81873346711060652204712539181482831616 + * SHA256 Fingerprint: b2:fa:e5:3e:14:cc:d7:ab:92:12:06:47:01:ae:27:9c:1d:89:88:fa:cb:77:5f:a8:a0:08:91:4e:66:39:88:a8 + * -----BEGIN CERTIFICATE----- + * MIICFTCCAZugAwIBAgIQPZg7pmY9kGP3fiZXOATvADAKBggqhkjOPQQDAzBMMS4w + * LAYDVQQDDCVBdG9zIFRydXN0ZWRSb290IFJvb3QgQ0EgRUNDIFRMUyAyMDIxMQ0w + * CwYDVQQKDARBdG9zMQswCQYDVQQGEwJERTAeFw0yMTA0MjIwOTI2MjNaFw00MTA0 + * MTcwOTI2MjJaMEwxLjAsBgNVBAMMJUF0b3MgVHJ1c3RlZFJvb3QgUm9vdCBDQSBF + * Q0MgVExTIDIwMjExDTALBgNVBAoMBEF0b3MxCzAJBgNVBAYTAkRFMHYwEAYHKoZI + * zj0CAQYFK4EEACIDYgAEloZYKDcKZ9Cg3iQZGeHkBQcfl+3oZIK59sRxUM6KDP/X + * tXa7oWyTbIOiaG6l2b4siJVBzV3dscqDY4PMwL502eCdpO5KTlbgmClBk1IQ1SQ4 + * AjJn8ZQSb+/Xxd4u/RmAo0IwQDAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBR2 + * KCXWfeBmmnoJsmo7jjPXNtNPojAOBgNVHQ8BAf8EBAMCAYYwCgYIKoZIzj0EAwMD + * aAAwZQIwW5kp85wxtolrbNa9d+F851F+uDrNozZffPc8dz7kUK2o59JZDCaOMDtu + * CCrCp1rIAjEAmeMM56PDr9NJLkaCI2ZdyQAUEv049OGYa3cpetskz2VAv9LcjBHo + * 9H1/IISpQuQo + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1.0,\x06\x03U\x04\x03\x0c%Atos TrustedRoot Root CA ECC TLS 20211\r0\x0b\x06\x03U\x04\n\x0c\x04Atos1\x0b0\t\x06\x03U\x04\x06\x13\x02DE"), + subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\"\x03b\x00\x04\x96\x86X(7\ng\xd0\xa0\xde$\x19\x19\xe1\xe4\x05\x07\x1f\x97\xed\xe8d\x82\xb9\xf6\xc4qP\xce\x8a\x0c\xff\xd7\xb5v\xbb\xa1l\x93l\x83\xa2hn\xa5\xd9\xbe,\x88\x95A\xcd]\xdd\xb1\xca\x83c\x83\xcc\xc0\xbet\xd9\xe0\x9d\xa4\xeeJNV\xe0\x98)A\x93R\x10\xd5$8\x022g\xf1\x94\x12o\xef\xd7\xc5\xde.\xfd\x19\x80"), + name_constraints: None + }, + + /* + * Issuer: CN=Certainly Root E1 O=Certainly + * Subject: CN=Certainly Root E1 O=Certainly + * Label: "Certainly Root E1" + * Serial: 8168531406727139161245376702891150584 + * SHA256 Fingerprint: b4:58:5f:22:e4:ac:75:6a:4e:86:12:a1:36:1c:5d:9d:03:1a:93:fd:84:fe:bb:77:8f:a3:06:8b:0f:c4:2d:c2 + * -----BEGIN CERTIFICATE----- + * MIIB9zCCAX2gAwIBAgIQBiUzsUcDMydc+Y2aub/M+DAKBggqhkjOPQQDAzA9MQsw + * CQYDVQQGEwJVUzESMBAGA1UEChMJQ2VydGFpbmx5MRowGAYDVQQDExFDZXJ0YWlu + * bHkgUm9vdCBFMTAeFw0yMTA0MDEwMDAwMDBaFw00NjA0MDEwMDAwMDBaMD0xCzAJ + * BgNVBAYTAlVTMRIwEAYDVQQKEwlDZXJ0YWlubHkxGjAYBgNVBAMTEUNlcnRhaW5s + * eSBSb290IEUxMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE3m/4fxzf7flHh4axpMCK + * +IKXgOqPyEpeKn2IaKcBYhSRJHpcnqMXfYqGITQYUBsQ3tA3SybHGWCA6TS9YBk2 + * QNYphwk8kXr2vBMj3VlOBF7PyAIcGFPBMdjaIOlEjeR2o0IwQDAOBgNVHQ8BAf8E + * BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU8ygYy2R17ikq6+2uI1g4 + * hevIIgcwCgYIKoZIzj0EAwMDaAAwZQIxALGOWiDDshliTd6wT99u0nCK8Z9+aozm + * ut6Dacpps6kFtZaSF4fC0urQe87YQVt8rgIwRt7qy12a7DLCZRawTDBcMPPaTnOG + * BtjOiQRINzf43TNRnXCve1XYAS59BWQOhriR + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1\x120\x10\x06\x03U\x04\n\x13\tCertainly1\x1a0\x18\x06\x03U\x04\x03\x13\x11Certainly Root E1"), + subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\"\x03b\x00\x04\xdeo\xf8\x7f\x1c\xdf\xed\xf9G\x87\x86\xb1\xa4\xc0\x8a\xf8\x82\x97\x80\xea\x8f\xc8J^*}\x88h\xa7\x01b\x14\x91$z\\\x9e\xa3\x17}\x8a\x86!4\x18P\x1b\x10\xde\xd07K&\xc7\x19`\x80\xe94\xbd`\x196@\xd6)\x87\t<\x91z\xf6\xbc\x13#\xddYN\x04^\xcf\xc8\x02\x1c\x18S\xc11\xd8\xda \xe9D\x8d\xe4v"), + name_constraints: None + }, + + /* + * Issuer: CN=e-Szigno TLS Root CA 2023 O=Microsec Ltd. + * Subject: CN=e-Szigno TLS Root CA 2023 O=Microsec Ltd. + * Label: "e-Szigno TLS Root CA 2023" + * Serial: 71934828665710877219916191754 + * SHA256 Fingerprint: b4:91:41:50:2d:00:66:3d:74:0f:2e:7e:c3:40:c5:28:00:96:26:66:12:1a:36:d0:9c:f7:dd:2b:90:38:4f:b4 + * -----BEGIN CERTIFICATE----- + * MIICzzCCAjGgAwIBAgINAOhvGHvWOWuYSkmYCjAKBggqhkjOPQQDBDB1MQswCQYD + * VQQGEwJIVTERMA8GA1UEBwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0 + * ZC4xFzAVBgNVBGEMDlZBVEhVLTIzNTg0NDk3MSIwIAYDVQQDDBllLVN6aWdubyBU + * TFMgUm9vdCBDQSAyMDIzMB4XDTIzMDcxNzE0MDAwMFoXDTM4MDcxNzE0MDAwMFow + * dTELMAkGA1UEBhMCSFUxETAPBgNVBAcMCEJ1ZGFwZXN0MRYwFAYDVQQKDA1NaWNy + * b3NlYyBMdGQuMRcwFQYDVQRhDA5WQVRIVS0yMzU4NDQ5NzEiMCAGA1UEAwwZZS1T + * emlnbm8gVExTIFJvb3QgQ0EgMjAyMzCBmzAQBgcqhkjOPQIBBgUrgQQAIwOBhgAE + * AGgP36J8PKp0iGEKjcJMpQEiFNT3YHdCnAo4YKGMZz6zY+n6kbCLS+Y53wLCMAFS + * AL/fjO1ZrTJlqwlZULUZwmgcAOAFX9pQJhzDrAQixTpN7+lXWDajwRlTEArRzT/v + * SzUaQ49CE0y5LBqcvjC2xN7cS53kpDzLLtmt3999Cd8ukv+ho2MwYTAPBgNVHRMB + * Af8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUWYQCYlpGePVd3I8K + * ECgj3NXW+0UwHwYDVR0jBBgwFoAUWYQCYlpGePVd3I8KECgj3NXW+0UwCgYIKoZI + * zj0EAwQDgYsAMIGHAkIBLdqu9S54tma4n7Zwf2Z0z+yOfP7AAXmazlIC58PRDHpt + * y7Ve7hekm9sEdu4pKeiv+62sUvTXK9Z3hBC9xdIoaDQCQTV2WnXzkoYI9bIeCvZl + * C9p2x1L/Cx6AcCIwwzPbGO2E14vs7dOoY4G1VnxHx1YwlGhza9IuqbnZLBwpvQy6 + * uWWL + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02HU1\x110\x0f\x06\x03U\x04\x07\x0c\x08Budapest1\x160\x14\x06\x03U\x04\n\x0c\rMicrosec Ltd.1\x170\x15\x06\x03U\x04a\x0c\x0eVATHU-235844971\"0 \x06\x03U\x04\x03\x0c\x19e-Szigno TLS Root CA 2023"), + subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00#\x03\x81\x86\x00\x04\x00h\x0f\xdf\xa2|<\xaat\x88a\n\x8d\xc2L\xa5\x01\"\x14\xd4\xf7`wB\x9c\n8`\xa1\x8cg>\xb3c\xe9\xfa\x91\xb0\x8bK\xe69\xdf\x02\xc20\x01R\x00\xbf\xdf\x8c\xedY\xad2e\xab\tYP\xb5\x19\xc2h\x1c\x00\xe0\x05_\xdaP&\x1c\xc3\xac\x04\"\xc5:M\xef\xe9WX6\xa3\xc1\x19S\x10\n\xd1\xcd?\xefK5\x1aC\x8fB\x13L\xb9,\x1a\x9c\xbe0\xb6\xc4\xde\xdcK\x9d\xe4\xa4<\xcb.\xd9\xad\xdf\xdf}\t\xdf.\x92\xff\xa1"), + name_constraints: None + }, + + /* + * Issuer: CN=Certum Trusted Network CA 2 O=Unizeto Technologies S.A. OU=Certum Certification Authority + * Subject: CN=Certum Trusted Network CA 2 O=Unizeto Technologies S.A. OU=Certum Certification Authority + * Label: "Certum Trusted Network CA 2" + * Serial: 44979900017204383099463764357512596969 + * SHA256 Fingerprint: b6:76:f2:ed:da:e8:77:5c:d3:6c:b0:f6:3c:d1:d4:60:39:61:f4:9e:62:65:ba:01:3a:2f:03:07:b6:d0:b8:04 + * -----BEGIN CERTIFICATE----- + * MIIF0jCCA7qgAwIBAgIQIdbQSk8lD8kyN/yqXhKN6TANBgkqhkiG9w0BAQ0FADCB + * gDELMAkGA1UEBhMCUEwxIjAgBgNVBAoTGVVuaXpldG8gVGVjaG5vbG9naWVzIFMu + * QS4xJzAlBgNVBAsTHkNlcnR1bSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEkMCIG + * A1UEAxMbQ2VydHVtIFRydXN0ZWQgTmV0d29yayBDQSAyMCIYDzIwMTExMDA2MDgz + * OTU2WhgPMjA0NjEwMDYwODM5NTZaMIGAMQswCQYDVQQGEwJQTDEiMCAGA1UEChMZ + * VW5pemV0byBUZWNobm9sb2dpZXMgUy5BLjEnMCUGA1UECxMeQ2VydHVtIENlcnRp + * ZmljYXRpb24gQXV0aG9yaXR5MSQwIgYDVQQDExtDZXJ0dW0gVHJ1c3RlZCBOZXR3 + * b3JrIENBIDIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC9+Xj45tWA + * DGSdhhuWZGc/IjoedQF97/tcZ4zJzFxrqZHmuULlIEub2pt7uZld2ZuAS9eEQCsn + * 0+i6MLs+CRqnSZXvK0AkwpfHp+6bJe+oCgCXhVqqndwpyeI1B+twTUrWwbNWuKFB + * OJvR+zF/j+Bf4bE/D44WSWDXBo0Y+aomEKsq09DRZ40bRr5HMNUuctHFY9rnY3lE + * fktjJImGLjQ/KUxSiyqnwOKRKIm5wFv5HdnnJ63/mgKXwcZQkpsCLL2puTRZCr+E + * Sv/f/rOf69me4Jgj7KZrdxYq28ytOxykh9xGc14ZYmhFV+SQgkK7QtbwYeDBoz1m + * o130GO6IyY0XRSmZMnUCMe4pJshrAua1YkV/NxVaI2iJ1D7eTiew8EAMvE0Xy02i + * sx7QBlrd9pPPV3WZ9fqGGmd4s7+W/jTcvedSVuWz5XV710GRBdxdaeOVDUO5/IOW + * OZV7bIBaTxNyxtd9KXpEulKkKtVBRgkg/iKgtlswjbyJDNXXcPiHUv3a76xRLgez + * Tv7QCdpw75j6VuZt27VXS9zlLCUVyJ4ueE742pyehizKV/Ma5ciSixqClnrDvFAS + * adgOWkaLOusm+iPJtrCBvkIApPjW/jAux9JG9uWOdf3yzLnQh1vMBhBgu4M1t15n + * 3kfsmUjxpKEV/q2MYo45VU85FrmxY53/twIDAQABo0IwQDAPBgNVHRMBAf8EBTAD + * AQH/MB0GA1UdDgQWBBS2oVQ5AsOgP46KvPrU+Bym0ToO/TAOBgNVHQ8BAf8EBAMC + * AQYwDQYJKoZIhvcNAQENBQADggIBAHGlDs7k6b8/ONWJWsQCYftMxRQXLYtPU2sQ + * F/xlhMcQSZDe28cmk4gmb3DWAl45oPePq5a1pRNcgRRtDoGCERuKTsZPpd1iHkTf + * CVn0W3cLN+mLIMb4Ck4uWBzrM9DPhmDJ2vuAL55MYIR4PSFk1vtBHxgP58l1cb29 + * XN40hz5BsA72udY/CROWFC/emh1auVbONTqwX3BNXuMp8SMoclm2q8KMZiYcdywm + * djWLKKdpoPk79SPdhRB0yZADVpHnr7pH1BKXESLjokmUbOe3lEu6LaTaM4tMpkT/ + * WjzGHWTYtTHkpjx6qFcL2+1hGsvxznN3Y6SHb0xRONbkX8eftoEq5IVIeVheO/jb + * AoJnwTnbw3RLPTYe+SmTiGhbqEQZIfCn6IENLOiTNrQ3ssqwGyZ6miUfmpqAnksq + * P/ujmv5zMnHCnsZy4YpoJ/HkD7TETKVhk/iXEAcqMCWpuchxuO9ozC1+9eB+D4Ko + * b7a6bINDd82Kkhehnlt4Fj1F4jNy3eFmypnTycUm/Q1oBEauttmbjL4ZvrHG8hnj + * XALKLNhvSgfZyTXaQHXyxKcZb55CEJh15pWLYLztxRLXis7VmFxWlgPF7ncGNf/P + * 5O4/E2Hu29othfDNrp2yGAlFw5Khchf8R7agCyzxxN5DaAhqXzvwdmP7zAYspsbi + * DrW5viSP + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02PL1\"0 \x06\x03U\x04\n\x13\x19Unizeto Technologies S.A.1\'0%\x06\x03U\x04\x0b\x13\x1eCertum Certification Authority1$0\"\x06\x03U\x04\x03\x13\x1bCertum Trusted Network CA 2"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xbd\xf9x\xf8\xe6\xd5\x80\x0cd\x9d\x86\x1b\x96dg?\":\x1eu\x01}\xef\xfb\\g\x8c\xc9\xcc\\k\xa9\x91\xe6\xb9B\xe5 K\x9b\xda\x9b{\xb9\x99]\xd9\x9b\x80K\xd7\x84@+\'\xd3\xe8\xba0\xbb>\t\x1a\xa7I\x95\xef+@$\xc2\x97\xc7\xa7\xee\x9b%\xef\xa8\n\x00\x97\x85Z\xaa\x9d\xdc)\xc9\xe25\x07\xebpMJ\xd6\xc1\xb3V\xb8\xa1A8\x9b\xd1\xfb1\x7f\x8f\xe0_\xe1\xb1?\x0f\x8e\x16I`\xd7\x06\x8d\x18\xf9\xaa&\x10\xab*\xd3\xd0\xd1g\x8d\x1bF\xbeG0\xd5.r\xd1\xc5c\xda\xe7cyD~Kc$\x89\x86.4?)LR\x8b*\xa7\xc0\xe2\x91(\x89\xb9\xc0[\xf9\x1d\xd9\xe7\'\xad\xff\x9a\x02\x97\xc1\xc6P\x92\x9b\x02,\xbd\xa9\xb94Y\n\xbf\x84J\xff\xdf\xfe\xb3\x9f\xeb\xd9\x9e\xe0\x98#\xec\xa6kw\x16*\xdb\xcc\xad;\x1c\xa4\x87\xdcFs^\x19bhEW\xe4\x90\x82B\xbbB\xd6\xf0a\xe0\xc1\xa3=f\xa3]\xf4\x18\xee\x88\xc9\x8d\x17E)\x992u\x021\xee)&\xc8k\x02\xe6\xb5bE\x7f7\x15Z#h\x89\xd4>\xdeN\'\xb0\xf0@\x0c\xbcM\x17\xcbM\xa2\xb3\x1e\xd0\x06Z\xdd\xf6\x93\xcfWu\x99\xf5\xfa\x86\x1agx\xb3\xbf\x96\xfe4\xdc\xbd\xe7RV\xe5\xb3\xe5u{\xd7A\x91\x05\xdc]i\xe3\x95\rC\xb9\xfc\x83\x969\x95{l\x80ZO\x13r\xc6\xd7})zD\xbaR\xa4*\xd5AF\t \xfe\"\xa0\xb6[0\x8d\xbc\x89\x0c\xd5\xd7p\xf8\x87R\xfd\xda\xef\xacQ.\x07\xb3N\xfe\xd0\t\xdap\xef\x98\xfaV\xe6m\xdb\xb5WK\xdc\xe5,%\x15\xc8\x9e.xN\xf8\xda\x9c\x9e\x86,\xcaW\xf3\x1a\xe5\xc8\x92\x8b\x1a\x82\x96z\xc3\xbcP\x12i\xd8\x0eZF\x8b:\xeb&\xfa#\xc9\xb6\xb0\x81\xbeB\x00\xa4\xf8\xd6\xfe0.\xc7\xd2F\xf6\xe5\x8eu\xfd\xf2\xcc\xb9\xd0\x87[\xcc\x06\x10`\xbb\x835\xb7^g\xdeG\xec\x99H\xf1\xa4\xa1\x15\xfe\xad\x8cb\x8e9UO9\x16\xb9\xb1c\x9d\xff\xb7\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=emSign ECC Root CA - C3 O=eMudhra Inc OU=emSign PKI + * Subject: CN=emSign ECC Root CA - C3 O=eMudhra Inc OU=emSign PKI + * Label: "emSign ECC Root CA - C3" + * Serial: 582948710642506000014504 + * SHA256 Fingerprint: bc:4d:80:9b:15:18:9d:78:db:3e:1d:8c:f4:f9:72:6a:79:5d:a1:64:3c:a5:f1:35:8e:1d:db:0e:dc:0d:7e:b3 + * -----BEGIN CERTIFICATE----- + * MIICKzCCAbGgAwIBAgIKe3G2gla4EnycqDAKBggqhkjOPQQDAzBaMQswCQYDVQQG + * EwJVUzETMBEGA1UECxMKZW1TaWduIFBLSTEUMBIGA1UEChMLZU11ZGhyYSBJbmMx + * IDAeBgNVBAMTF2VtU2lnbiBFQ0MgUm9vdCBDQSAtIEMzMB4XDTE4MDIxODE4MzAw + * MFoXDTQzMDIxODE4MzAwMFowWjELMAkGA1UEBhMCVVMxEzARBgNVBAsTCmVtU2ln + * biBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMSAwHgYDVQQDExdlbVNpZ24gRUND + * IFJvb3QgQ0EgLSBDMzB2MBAGByqGSM49AgEGBSuBBAAiA2IABP2lYa57JhAd6bci + * MK4G9IGzsUJxlTm801Ljr6/58pc1kjZGDoeVjbk5Wum739D+yAdBPLtVb4Ojavti + * sIGJAnB9SMVK4+kiVCJNk7tCDK93nCOmfddhEc5lx/h//vXyqaNCMEAwHQYDVR0O + * BBYEFPtaSNCAIEDyqOkAB2kZd6fmw/TPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMB + * Af8EBTADAQH/MAoGCCqGSM49BAMDA2gAMGUCMQC02C8Cif22TGK6Q04ThHK1rt0c + * 3ta13FaPWEBaLd4gTCKDypOofu4SQMfWh0/434UCMBwUZOR8loMRnLDRWmFLpg9J + * 0wD8ofzkpf9/rdcw0Md3f76BB1UwUCAU9Vc4CqgxUQ== + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1\x130\x11\x06\x03U\x04\x0b\x13\nemSign PKI1\x140\x12\x06\x03U\x04\n\x13\x0beMudhra Inc1 0\x1e\x06\x03U\x04\x03\x13\x17emSign ECC Root CA - C3"), + subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\"\x03b\x00\x04\xfd\xa5a\xae{&\x10\x1d\xe9\xb7\"0\xae\x06\xf4\x81\xb3\xb1Bq\x959\xbc\xd3R\xe3\xaf\xaf\xf9\xf2\x975\x926F\x0e\x87\x95\x8d\xb99Z\xe9\xbb\xdf\xd0\xfe\xc8\x07A<\xbbUo\x83\xa3j\xfbb\xb0\x81\x89\x02p}H\xc5J\xe3\xe9\"T\"M\x93\xbbB\x0c\xafw\x9c#\xa6}\xd7a\x11\xcee\xc7\xf8\x7f\xfe\xf5\xf2\xa9"), + name_constraints: None + }, + + /* + * Issuer: CN=TrustAsia Global Root CA G4 O=TrustAsia Technologies, Inc. + * Subject: CN=TrustAsia Global Root CA G4 O=TrustAsia Technologies, Inc. + * Label: "TrustAsia Global Root CA G4" + * Serial: 451799571007117016466790293371524403291602933463 + * SHA256 Fingerprint: be:4b:56:cb:50:56:c0:13:6a:52:6d:f4:44:50:8d:aa:36:a0:b5:4f:42:e4:ac:38:f7:2a:f4:70:e4:79:65:4c + * -----BEGIN CERTIFICATE----- + * MIICVTCCAdygAwIBAgIUTyNkuI6XY57GU4HBdk7LKnQV1tcwCgYIKoZIzj0EAwMw + * WjELMAkGA1UEBhMCQ04xJTAjBgNVBAoMHFRydXN0QXNpYSBUZWNobm9sb2dpZXMs + * IEluYy4xJDAiBgNVBAMMG1RydXN0QXNpYSBHbG9iYWwgUm9vdCBDQSBHNDAeFw0y + * MTA1MjAwMjEwMjJaFw00NjA1MTkwMjEwMjJaMFoxCzAJBgNVBAYTAkNOMSUwIwYD + * VQQKDBxUcnVzdEFzaWEgVGVjaG5vbG9naWVzLCBJbmMuMSQwIgYDVQQDDBtUcnVz + * dEFzaWEgR2xvYmFsIFJvb3QgQ0EgRzQwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAATx + * s8045CVD5d4ZCbuBeaIVXxVjAd7Cq92zphtnS4CDr5nLrBfbK5bKfFJV4hrhPVbw + * LxYI+hW8m7tH5j/uqOFMjPXTNvk4XatwmkcN4oFBButJ+bAp3TPsUKV/eSm4IJij + * YzBhMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUpbtKl86zK3+kMd6Xg1mD + * pm9xy94wHQYDVR0OBBYEFKW7SpfOsyt/pDHel4NZg6ZvccveMA4GA1UdDwEB/wQE + * AwIBBjAKBggqhkjOPQQDAwNnADBkAjBe8usGzEkxn0AAbbd+NvBNEU/zy4k6LHiR + * UKNbwMp1JvK/kF0LgoxgKJ/GcJpo5PECMFxYDlZ2z1jD1xCMuo6u47xkdUfFVZDj + * /bpV6wfEU6s3qe4hsiFbYI89MvHVI5TWWA== + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02CN1%0#\x06\x03U\x04\n\x0c\x1cTrustAsia Technologies, Inc.1$0\"\x06\x03U\x04\x03\x0c\x1bTrustAsia Global Root CA G4"), + subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\"\x03b\x00\x04\xf1\xb3\xcd8\xe4%C\xe5\xde\x19\t\xbb\x81y\xa2\x15_\x15c\x01\xde\xc2\xab\xdd\xb3\xa6\x1bgK\x80\x83\xaf\x99\xcb\xac\x17\xdb+\x96\xca|RU\xe2\x1a\xe1=V\xf0/\x16\x08\xfa\x15\xbc\x9b\xbbG\xe6?\xee\xa8\xe1L\x8c\xf5\xd36\xf98]\xabp\x9aG\r\xe2\x81A\x06\xebI\xf9\xb0)\xdd3\xecP\xa5\x7fy)\xb8 \x98"), + name_constraints: None + }, + + /* + * Issuer: CN=e-Szigno Root CA 2017 O=Microsec Ltd. + * Subject: CN=e-Szigno Root CA 2017 O=Microsec Ltd. + * Label: "e-Szigno Root CA 2017" + * Serial: 411379200276854331539784714 + * SHA256 Fingerprint: be:b0:0b:30:83:9b:9b:c3:2c:32:e4:44:79:05:95:06:41:f2:64:21:b1:5e:d0:89:19:8b:51:8a:e2:ea:1b:99 + * -----BEGIN CERTIFICATE----- + * MIICQDCCAeWgAwIBAgIMAVRI7yH9l1kN9QQKMAoGCCqGSM49BAMCMHExCzAJBgNV + * BAYTAkhVMREwDwYDVQQHDAhCdWRhcGVzdDEWMBQGA1UECgwNTWljcm9zZWMgTHRk + * LjEXMBUGA1UEYQwOVkFUSFUtMjM1ODQ0OTcxHjAcBgNVBAMMFWUtU3ppZ25vIFJv + * b3QgQ0EgMjAxNzAeFw0xNzA4MjIxMjA3MDZaFw00MjA4MjIxMjA3MDZaMHExCzAJ + * BgNVBAYTAkhVMREwDwYDVQQHDAhCdWRhcGVzdDEWMBQGA1UECgwNTWljcm9zZWMg + * THRkLjEXMBUGA1UEYQwOVkFUSFUtMjM1ODQ0OTcxHjAcBgNVBAMMFWUtU3ppZ25v + * IFJvb3QgQ0EgMjAxNzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABJbcPYrYsHtv + * xie+RJCxs1YVe45DJH0ahFnuY2iyxl6H0BVIHqiQrb1TotreOpCmYF9oMrWGQd+H + * Wyx7xf58etqjYzBhMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0G + * A1UdDgQWBBSHERUI0arBeAyxr87GyZDvvzAEwDAfBgNVHSMEGDAWgBSHERUI0arB + * eAyxr87GyZDvvzAEwDAKBggqhkjOPQQDAgNJADBGAiEAtVfd14pVCzbhhkT61Nlo + * jbjcI4qKDdQvfepz7L9NbKgCIQDLpbQS+ue16M9+k/zzNY9vTlp8tLxOsvxyqltZ + * +efcMQ== + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02HU1\x110\x0f\x06\x03U\x04\x07\x0c\x08Budapest1\x160\x14\x06\x03U\x04\n\x0c\rMicrosec Ltd.1\x170\x15\x06\x03U\x04a\x0c\x0eVATHU-235844971\x1e0\x1c\x06\x03U\x04\x03\x0c\x15e-Szigno Root CA 2017"), + subject_public_key_info: Der::from_slice(b"0\x13\x06\x07*\x86H\xce=\x02\x01\x06\x08*\x86H\xce=\x03\x01\x07\x03B\x00\x04\x96\xdc=\x8a\xd8\xb0{o\xc6\'\xbeD\x90\xb1\xb3V\x15{\x8eC$}\x1a\x84Y\xeech\xb2\xc6^\x87\xd0\x15H\x1e\xa8\x90\xad\xbdS\xa2\xda\xde:\x90\xa6`_h2\xb5\x86A\xdf\x87[,{\xc5\xfe|z\xda"), + name_constraints: None + }, + + /* + * Issuer: CN=TWCA Root Certification Authority O=TAIWAN-CA OU=Root CA + * Subject: CN=TWCA Root Certification Authority O=TAIWAN-CA OU=Root CA + * Label: "TWCA Root Certification Authority" + * Serial: 1 + * SHA256 Fingerprint: bf:d8:8f:e1:10:1c:41:ae:3e:80:1b:f8:be:56:35:0e:e9:ba:d1:a6:b9:bd:51:5e:dc:5c:6d:5b:87:11:ac:44 + * -----BEGIN CERTIFICATE----- + * MIIDezCCAmOgAwIBAgIBATANBgkqhkiG9w0BAQUFADBfMQswCQYDVQQGEwJUVzES + * MBAGA1UECgwJVEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFU + * V0NBIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDgwODI4MDcyNDMz + * WhcNMzAxMjMxMTU1OTU5WjBfMQswCQYDVQQGEwJUVzESMBAGA1UECgwJVEFJV0FO + * LUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NBIFJvb3QgQ2VydGlm + * aWNhdGlvbiBBdXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB + * AQCwfnK4pAOU5qfeCTiRShFAh6d8WWQUe7UREN3+v9XAu1bihSX0NXIP+FPQQeFE + * AcK0HMMxQhZHhTMidrIKbw/lJVBPhYa+v5guEGcevhEFhgWQxFnQfHgQsIBct+HH + * K3XLfJ+utdGdIzdjp9xCoi2SBBtQwXu4PhvJVgSLL1KbralW6cH/ralYhzC2gfeX + * RfwZVzsrb+RH9JlF/h3x+JejiB03HFyP4HYlmlD4oFT/RJB2I9IyxsOrBr/8+7/z + * rX2SYgJbKdM1o5OaQ2RgXbL6Mv87BK9NQGr5x+PvI/1ry+UPizgN7gr8/g+YnzAx + * 3WxSZfmLgb4i4RxYA7qRG4kHAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV + * HRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqOFsmjd6LWvJPelSDGRjjCDWmujANBgkq + * hkiG9w0BAQUFAAOCAQEAPNV3PdrfibqHDAhUaiBQkr6wQT25JmSDCi/oQMCXKCeC + * MErJk/9q56YAf4lCmtYR5VPOL8zy2gXE/uJQxDqGfczafhAJO5I1KlOy/usrBdls + * XebQ79NqZp4VKIV66IIArB6nCWlWQtNoURi+VJq/REG6Sb4gumlc7rh3zc5sH62D + * lhh9DrUUOYTxKOkto557HnpyWoOzeW/vtPzQCqVYT0bf+215WfKEIlKuD8z7fDvn + * aspHYcN6+NOSBB+4IIThNlQWx0DeO4pz3N/GCUzf7Nr/1FNCocnyYh0igzyXxfkZ + * YiesZSLX0zzG5Y6yU8xJzrww/nsOM5D77dIUkR8Hrw== + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02TW1\x120\x10\x06\x03U\x04\n\x0c\tTAIWAN-CA1\x100\x0e\x06\x03U\x04\x0b\x0c\x07Root CA1*0(\x06\x03U\x04\x03\x0c!TWCA Root Certification Authority"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x01\x0f\x000\x82\x01\n\x02\x82\x01\x01\x00\xb0~r\xb8\xa4\x03\x94\xe6\xa7\xde\t8\x91J\x11@\x87\xa7|Yd\x14{\xb5\x11\x10\xdd\xfe\xbf\xd5\xc0\xbbV\xe2\x85%\xf45r\x0f\xf8S\xd0A\xe1D\x01\xc2\xb4\x1c\xc31B\x16G\x853\"v\xb2\no\x0f\xe5%PO\x85\x86\xbe\xbf\x98.\x10g\x1e\xbe\x11\x05\x86\x05\x90\xc4Y\xd0|x\x10\xb0\x80\\\xb7\xe1\xc7+u\xcb|\x9f\xae\xb5\xd1\x9d#7c\xa7\xdcB\xa2-\x92\x04\x1bP\xc1{\xb8>\x1b\xc9V\x04\x8b/R\x9b\xad\xa9V\xe9\xc1\xff\xad\xa9X\x870\xb6\x81\xf7\x97E\xfc\x19W;+o\xe4G\xf4\x99E\xfe\x1d\xf1\xf8\x97\xa3\x88\x1d7\x1c\\\x8f\xe0v%\x9aP\xf8\xa0T\xffD\x90v#\xd22\xc6\xc3\xab\x06\xbf\xfc\xfb\xbf\xf3\xad}\x92b\x02[)\xd35\xa3\x93\x9aCd`]\xb2\xfa2\xff;\x04\xafM@j\xf9\xc7\xe3\xef#\xfdk\xcb\xe5\x0f\x8b8\r\xee\n\xfc\xfe\x0f\x98\x9f01\xddlRe\xf9\x8b\x81\xbe\"\xe1\x1cX\x03\xba\x91\x1b\x89\x07\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=GDCA TrustAUTH R5 ROOT O=GUANG DONG CERTIFICATE AUTHORITY CO.,LTD. + * Subject: CN=GDCA TrustAUTH R5 ROOT O=GUANG DONG CERTIFICATE AUTHORITY CO.,LTD. + * Label: "GDCA TrustAUTH R5 ROOT" + * Serial: 9009899650740120186 + * SHA256 Fingerprint: bf:ff:8f:d0:44:33:48:7d:6a:8a:a6:0c:1a:29:76:7a:9f:c2:bb:b0:5e:42:0f:71:3a:13:b9:92:89:1d:38:93 + * -----BEGIN CERTIFICATE----- + * MIIFiDCCA3CgAwIBAgIIfQmX/vBH6nowDQYJKoZIhvcNAQELBQAwYjELMAkGA1UE + * BhMCQ04xMjAwBgNVBAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZ + * IENPLixMVEQuMR8wHQYDVQQDDBZHRENBIFRydXN0QVVUSCBSNSBST09UMB4XDTE0 + * MTEyNjA1MTMxNVoXDTQwMTIzMTE1NTk1OVowYjELMAkGA1UEBhMCQ04xMjAwBgNV + * BAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZIENPLixMVEQuMR8w + * HQYDVQQDDBZHRENBIFRydXN0QVVUSCBSNSBST09UMIICIjANBgkqhkiG9w0BAQEF + * AAOCAg8AMIICCgKCAgEA2aMW8Mh0dHeb7zMNOwZ+Vfy1YI92hhJCfVZmPoiC7XJj + * Dp6L3TQsAlFRwxn9WVSEyfFrs0yw6ehGXTjGoqcuEVe6ghWinI9tsJlKCvLriXBj + * TnnEt1u9ol2x8kECK62pOqPseQrsXzrj/e+APK00mxqriCZ7VqKChh/rNYmDf1+u + * KU49tm7srsHwJ5uu4/Ts765/94Y9cnrrpftZTqfrlYwiOXnhLQiPzLyRuEH3FMEj + * qcOtmkVEs7LXLM3GKeJQEK5cy4KOFxg2fZfmiJqwTTQJ9Cy5WmYqsBebnh52nUpm + * MUHfP/vFBu8btn4aRjb3ZGM74zkYI+dndRTVdVeSN72+ahsmUPI2JgaQxXABZG12 + * ZuGR224HwGGALrIuL4xwp9E7PLOR5G62xDtw8mySlwnNR30YwPO7ng/Wi64HtloP + * zgsMR6flPri9fcebNaBhlzpBdRfMK5Z3KpIhHtmVdiBnaM8Nvd/WHwlqmuLMc3Gk + * L30SgLdTMEZeS1SZD2fJpcjyIMGC7J0R38IC+xo70e0gmu9lZJIQDSri3nDxGGeC + * jGHeuLzRL5z7D9Ar7Rt2ueQ5Vfj4oR24qoAATILnsn8JuLwwoC8N9VKejveSswoA + * HQBUlwbgsQfZxw9cZX08bVlX5O2ljelAU58VS6Bx9hoh49pwBiFYFIeFd3mqgnkC + * AwEAAaNCMEAwHQYDVR0OBBYEFOLJQJ9NzuiaoXzPDj9lxSmIahlRMA8GA1UdEwEB + * /wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4ICAQDRSVfg + * p8xoWLoBDysZzY2wYUWsEe1jUGn4H3++Fo/9nesLqjJHdtJnJO29fDMylyrHBYZm + * DRd9FBUb1Ov9H5r2XpdptxolpAqzkT9fNqyL7FeoPueBihhXOYV0GkLH6VsTX4/5 + * COmSdI31R9KrO9b7eGZONn356ZLpBN79SWP8bfsUcZNnL0dKt7n/HipzcEYwv1ry + * L3ml4Y0M2fmyYzeMN2WFcGpcWwlyua1jPLHd+PwyvzeG5LuOmCd+uh8W4XAR8gPf + * JWIyJyYYMoSf/wA6E7qaTfRPuBRwIrHKK5DOKcFw9C+df/KQHtZa37dG/OaG+svg + * IHZ6uqbL9XzeYqWxi+7egmaKTjowHz+Ay60nugxe19CxVsp3cbK1daFQqUBDF8Io + * 2c9Si1vIY9RCPqAzekYu9wogRlR+ak8x8YF+QnQ4ZXMn7sZ8uI7XpTrXmKGcjBBV + * 09tL7ECQ8s1uV9JiDnxXk7Gnbc2dg7sq5+W2O3FYrf3RRbxake5TFW/TRQl1brqQ + * XR4EzzffHqhmsYzmIGrv/EhOdJhCrylvLmrH+33RZjEizIYAfmaDDEL0vTSSwxrq + * T8p+ck0LcIymSLumoRT2+1hEmRSuqguTaaApJUqlyyvdimYHFngVV3Eb7PVHhPOe + * MTd61X8kreS8/f3MboPoDKi3QWwH3b08hpcv0g== + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02CN1200\x06\x03U\x04\n\x0c)GUANG DONG CERTIFICATE AUTHORITY CO.,LTD.1\x1f0\x1d\x06\x03U\x04\x03\x0c\x16GDCA TrustAUTH R5 ROOT"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xd9\xa3\x16\xf0\xc8ttw\x9b\xef3\r;\x06~U\xfc\xb5`\x8fv\x86\x12B}Vf>\x88\x82\xedrc\x0e\x9e\x8b\xdd4,\x02QQ\xc3\x19\xfdYT\x84\xc9\xf1k\xb3L\xb0\xe9\xe8F]8\xc6\xa2\xa7.\x11W\xba\x82\x15\xa2\x9c\x8fm\xb0\x99J\n\xf2\xeb\x89pcNy\xc4\xb7[\xbd\xa2]\xb1\xf2A\x02+\xad\xa9:\xa3\xecy\n\xec_:\xe3\xfd\xef\x80<\xad4\x9b\x1a\xab\x88&{V\xa2\x82\x86\x1f\xeb5\x89\x83\x7f_\xae)N=\xb6n\xec\xae\xc1\xf0\'\x9b\xae\xe3\xf4\xec\xef\xae\x7f\xf7\x86=rz\xeb\xa5\xfbYN\xa7\xeb\x95\x8c\"9y\xe1-\x08\x8f\xcc\xbc\x91\xb8A\xf7\x14\xc1#\xa9\xc3\xad\x9aED\xb3\xb2\xd7,\xcd\xc6)\xe2P\x10\xae\\\xcb\x82\x8e\x17\x186}\x97\xe6\x88\x9a\xb0M4\t\xf4,\xb9Zf*\xb0\x17\x9b\x9e\x1ev\x9dJf1A\xdf?\xfb\xc5\x06\xef\x1b\xb6~\x1aF6\xf7dc;\xe39\x18#\xe7gu\x14\xd5uW\x927\xbd\xbej\x1b&P\xf26&\x06\x90\xc5p\x01dmvf\xe1\x91\xdbn\x07\xc0a\x80.\xb2./\x8cp\xa7\xd1;<\xb3\x91\xe4n\xb6\xc4;p\xf2l\x92\x97\t\xcdG}\x18\xc0\xf3\xbb\x9e\x0f\xd6\x8b\xae\x07\xb6Z\x0f\xce\x0b\x0cG\xa7\xe5>\xb8\xbd}\xc7\x9b5\xa0a\x97:Au\x17\xcc+\x96w*\x92!\x1e\xd9\x95v gh\xcf\r\xbd\xdf\xd6\x1f\tj\x9a\xe2\xccsq\xa4/}\x12\x80\xb7S0F^KT\x99\x0fg\xc9\xa5\xc8\xf2 \xc1\x82\xec\x9d\x11\xdf\xc2\x02\xfb\x1a;\xd1\xed \x9a\xefed\x92\x10\r*\xe2\xdep\xf1\x18g\x82\x8ca\xde\xb8\xbc\xd1/\x9c\xfb\x0f\xd0+\xed\x1bv\xb9\xe49U\xf8\xf8\xa1\x1d\xb8\xaa\x80\x00L\x82\xe7\xb2\x7f\t\xb8\xbc0\xa0/\r\xf5R\x9e\x8e\xf7\x92\xb3\n\x00\x1d\x00T\x97\x06\xe0\xb1\x07\xd9\xc7\x0f\\e}}\xf0\x88m\xae)\x98\xe1\x9b\\S\x99\xdb\xf7\x08\xff\xd5j\xe0\x8e\xcbD\xa6\xf0\xc1\x8c\xbdO\xd4\xce\xd4\x88S\xe8^W\xd7N\xbe,?\xf3\x12\xa7\x00\xe9\x82\xe3*[2|K\x9b\x14)\x9e\xf8-\x83\xb5\xeb\x8e1I=&a\xe9\x1dr\x8b\x89\xb6\n\xbb\x9c35\x0f\xda\xec\xde\xa9J\x1f\xc93\xb1"), + name_constraints: None + }, + + /* + * Issuer: CN=SSL.com TLS ECC Root CA 2022 O=SSL Corporation + * Subject: CN=SSL.com TLS ECC Root CA 2022 O=SSL Corporation + * Label: "SSL.com TLS ECC Root CA 2022" + * Serial: 26605119622390491762507526719404364228 + * SHA256 Fingerprint: c3:2f:fd:9f:46:f9:36:d1:6c:36:73:99:09:59:43:4b:9a:d6:0a:af:bb:9e:7c:f3:36:54:f1:44:cc:1b:a1:43 + * -----BEGIN CERTIFICATE----- + * MIICOjCCAcCgAwIBAgIQFAP1q/s3ixdAW+JDsqXRxDAKBggqhkjOPQQDAzBOMQsw + * CQYDVQQGEwJVUzEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9uMSUwIwYDVQQDDBxT + * U0wuY29tIFRMUyBFQ0MgUm9vdCBDQSAyMDIyMB4XDTIyMDgyNTE2MzM0OFoXDTQ2 + * MDgxOTE2MzM0N1owTjELMAkGA1UEBhMCVVMxGDAWBgNVBAoMD1NTTCBDb3Jwb3Jh + * dGlvbjElMCMGA1UEAwwcU1NMLmNvbSBUTFMgRUNDIFJvb3QgQ0EgMjAyMjB2MBAG + * ByqGSM49AgEGBSuBBAAiA2IABEUpNXP6wrgjzhR9qLFNoFs27iosU8NgCTWyJGYm + * acCzldZdkkAZDsalE3D07xJRKF3nzL35PIXBz5SQySvOkkJYWWf9lCcQZIxPBLFN + * SeR7T5v15wj4A4j3p8OSSxlUgaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSME + * GDAWgBSJjy+j6CugFFR781a4Jl9nOAuc0DAdBgNVHQ4EFgQUiY8vo+groBRUe/NW + * uCZfZzgLnNAwDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMDA2gAMGUCMFXjIlbp + * 15IkWE8elDIPDAI2wv2sdDJO4fscgIijzPvX6yv/N33w7deedWo1dlJF4AIxAMeN + * b0Igj762TVntd00pxCAgRWSGOlDGxK0tk/UYfXLtqc/ErFc2KAhl3zx5Zn6g6g== + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1\x180\x16\x06\x03U\x04\n\x0c\x0fSSL Corporation1%0#\x06\x03U\x04\x03\x0c\x1cSSL.com TLS ECC Root CA 2022"), + subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\"\x03b\x00\x04E)5s\xfa\xc2\xb8#\xce\x14}\xa8\xb1M\xa0[6\xee*,S\xc3`\t5\xb2$f&i\xc0\xb3\x95\xd6]\x92@\x19\x0e\xc6\xa5\x13p\xf4\xef\x12Q(]\xe7\xcc\xbd\xf9<\x85\xc1\xcf\x94\x90\xc9+\xce\x92BXYg\xfd\x94\'\x10d\x8cO\x04\xb1MI\xe4{O\x9b\xf5\xe7\x08\xf8\x03\x88\xf7\xa7\xc3\x92K\x19T\x81"), + name_constraints: None + }, + + /* + * Issuer: CN=Microsoft RSA Root Certificate Authority 2017 O=Microsoft Corporation + * Subject: CN=Microsoft RSA Root Certificate Authority 2017 O=Microsoft Corporation + * Label: "Microsoft RSA Root Certificate Authority 2017" + * Serial: 40975477897264996090493496164228220339 + * SHA256 Fingerprint: c7:41:f7:0f:4b:2a:8d:88:bf:2e:71:c1:41:22:ef:53:ef:10:eb:a0:cf:a5:e6:4c:fa:20:f4:18:85:30:73:e0 + * -----BEGIN CERTIFICATE----- + * MIIFqDCCA5CgAwIBAgIQHtOXCV/YtLNHcB6qvn9FszANBgkqhkiG9w0BAQwFADBl + * MQswCQYDVQQGEwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYw + * NAYDVQQDEy1NaWNyb3NvZnQgUlNBIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5 + * IDIwMTcwHhcNMTkxMjE4MjI1MTIyWhcNNDIwNzE4MjMwMDIzWjBlMQswCQYDVQQG + * EwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYwNAYDVQQDEy1N + * aWNyb3NvZnQgUlNBIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwggIi + * MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKW76UM4wplZEWCpW9R2LBifOZ + * Nt9GkMml7Xhqb0eRaPgnZ1AzHaGm++DlQ6OEAlcBXZxIQIJTELy/xztokLaCLeX0 + * ZdDMbRnMlfl7rEqUrQ7eS0MdhweSE5CAg2Q1OQT85elss7YfUJQ4ZVBcF0a5toW1 + * HLUX6NZFndiyJrDKxHBKrmCk3bPZ7Pw71VdyvD/IybLeS2v4I2wDwAW9lcfNcztm + * gGTjGqwu+UcF8ga2m3P1eDNbx6H7JyqhtJqRjJHTOoI+dkC0zVJhUXAoP8XFWvLJ + * jEm7FFtNyP9nTUwSlq31/niol4fX/V4ggNyhSyL71Imtus5Hl0dVe49FyGcohJUc + * aDDv70ngNXtk55iwlNpNhTs+VcQor1fznhPbRiefHqJeRIOkpcrVE7NLP8TjwuaG + * YaRSMLl6IE9vDzhTyzMMEyuP1pq9KsgtsRx9S1HKR9FIJ3Jdh+vVReZIZZ2vUpC6 + * W6IYZVcSn2i51BVrlMRpIpj0M+Dt+VGOQVDJNE92kKz8OMHY4Xu54+OU4UZpyw4K + * UGsTuqwPN1q3ErWQgR5WrlcihtnJ0tHXUeOrO8ZV/R4O03QK0dqq6mm4lyiPSMQH + * +FJDOvTKVTUssKZqwJz58oHhEmrARdlns87/I6KJClTUFLkqqNfs+avNJVgyeY+Q + * W5g5xAgGwax/Dj0ApQIDAQABo1QwUjAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/ + * BAUwAwEB/zAdBgNVHQ4EFgQUCctZf4aycI8awznjwNnpv7tNsiMwEAYJKwYBBAGC + * NxUBBAMCAQAwDQYJKoZIhvcNAQEMBQADggIBAKyvPl3CEZaJjqPnktaXFbgToqZC + * LgLNFgVZJ8og6Lq46BrsTaiXVq5lQ7GPAJtSzVXNUzltYkyLDVt8LkS/gxCP81OC + * gMNPOsduET/m4xaRhPtthH80dK2Jp86519efhGSSvpWhrQlTM93uCupKUY5vVau6 + * tZRGrox/2KJQJWVggEbbMwSubLWYdFQl3JPk+ONVFT24bcMKpBLBaYVu32TxU5nh + * SnUgnZUP5NbcA/FZGOhHibJXWpS2qdgXKxdJ5XbLwVaZOjex/2kskZGT4d9Mozd2 + * TaGf+G0eHdP67Pv0RR0Tbc/3WeUiJ3IrhvNXuzDtJE3cfVa7o7P4NHmJweDyAmH3 + * pvwPuxwXC65B2Xy9J6P9LjrRk5Sxcx0ki69bIImtt2dmefU6xqaWM/5TkshGsRGR + * xpl/j8nWZjEgQRCHLQzWwa80mMpkg/sTV9HB8Dx6jKXB/ZUhoHHBk2dxEuqPiApp + * GWSZI1b7rCoucL5mxAyE7+WL85MB+GqQk2dLsmijtWKP6T+MejteD+eMuMZ87zf9 + * dOLITzNy4ZQ5bb0Sr74MTnB8G2+NszKTc0QWbej09+CVgI+WXTik9KveCjCHk9hN + * AHFiRSdLOkKEW39lt2c0Ui2cFmuqqNh7o0JMcccMyj6D5KbvtwEwXlGjefVwaaZB + * RA+GsCyRxj3qrg+E + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1\x1e0\x1c\x06\x03U\x04\n\x13\x15Microsoft Corporation1604\x06\x03U\x04\x03\x13-Microsoft RSA Root Certificate Authority 2017"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xca[\xbe\x943\x8c)\x95\x91\x16\n\x95\xbdGb\xc1\x89\xf3\x996\xdfF\x90\xc9\xa5\xedxjoG\x91h\xf8\'gP3\x1d\xa1\xa6\xfb\xe0\xe5C\xa3\x84\x02W\x01]\x9cH@\x82S\x10\xbc\xbf\xc7;h\x90\xb6\x82-\xe5\xf4e\xd0\xccm\x19\xcc\x95\xf9{\xacJ\x94\xad\x0e\xdeKC\x1d\x87\x07\x92\x13\x90\x80\x83d59\x04\xfc\xe5\xe9l\xb3\xb6\x1fP\x948eP\\\x17F\xb9\xb6\x85\xb5\x1c\xb5\x17\xe8\xd6E\x9d\xd8\xb2&\xb0\xca\xc4pJ\xae`\xa4\xdd\xb3\xd9\xec\xfc;\xd5Wr\xbc?\xc8\xc9\xb2\xdeKk\xf8#l\x03\xc0\x05\xbd\x95\xc7\xcds;f\x80d\xe3\x1a\xac.\xf9G\x05\xf2\x06\xb6\x9bs\xf5x3[\xc7\xa1\xfb\'*\xa1\xb4\x9a\x91\x8c\x91\xd3:\x82>v@\xb4\xcdRaQp(?\xc5\xc5Z\xf2\xc9\x8cI\xbb\x14[M\xc8\xffgML\x12\x96\xad\xf5\xfex\xa8\x97\x87\xd7\xfd^ \x80\xdc\xa1K\"\xfb\xd4\x89\xad\xba\xceG\x97GU{\x8fE\xc8g(\x84\x95\x1ch0\xef\xefI\xe05{d\xe7\x98\xb0\x94\xdaM\x85;>U\xc4(\xafW\xf3\x9e\x13\xdbF\'\x9f\x1e\xa2^D\x83\xa4\xa5\xca\xd5\x13\xb3K?\xc4\xe3\xc2\xe6\x86a\xa4R0\xb9z Oo\x0f8S\xcb3\x0c\x13+\x8f\xd6\x9a\xbd*\xc8-\xb1\x1c}KQ\xcaG\xd1H\'r]\x87\xeb\xd5E\xe6He\x9d\xafR\x90\xba[\xa2\x18eW\x12\x9fh\xb9\xd4\x15k\x94\xc4i\"\x98\xf43\xe0\xed\xf9Q\x8eAP\xc94Ov\x90\xac\xfc8\xc1\xd8\xe1{\xb9\xe3\xe3\x94\xe1Fi\xcb\x0e\nPk\x13\xba\xac\x0f7Z\xb7\x12\xb5\x90\x81\x1eV\xaeW\"\x86\xd9\xc9\xd2\xd1\xd7Q\xe3\xab;\xc6U\xfd\x1e\x0e\xd3t\n\xd1\xda\xaa\xeai\xb8\x97(\x8fH\xc4\x07\xf8RC:\xf4\xcaU5,\xb0\xa6j\xc0\x9c\xf9\xf2\x81\xe1\x12j\xc0E\xd9g\xb3\xce\xff#\xa2\x89\nT\xd4\x14\xb9*\xa8\xd7\xec\xf9\xab\xcd%X2y\x8f\x90[\x989\xc4\x08\x06\xc1\xac\x7f\x0e=\x00\xa5\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=Sectigo Public Server Authentication Root E46 O=Sectigo Limited + * Subject: CN=Sectigo Public Server Authentication Root E46 O=Sectigo Limited + * Label: "Sectigo Public Server Authentication Root E46" + * Serial: 88989738453351742415770396670917916916 + * SHA256 Fingerprint: c9:0f:26:f0:fb:1b:40:18:b2:22:27:51:9b:5c:a2:b5:3e:2c:a5:b3:be:5c:f1:8e:fe:1b:ef:47:38:0c:53:83 + * -----BEGIN CERTIFICATE----- + * MIICOjCCAcGgAwIBAgIQQvLM2htpN0RfFf51KBC49DAKBggqhkjOPQQDAzBfMQsw + * CQYDVQQGEwJHQjEYMBYGA1UEChMPU2VjdGlnbyBMaW1pdGVkMTYwNAYDVQQDEy1T + * ZWN0aWdvIFB1YmxpYyBTZXJ2ZXIgQXV0aGVudGljYXRpb24gUm9vdCBFNDYwHhcN + * MjEwMzIyMDAwMDAwWhcNNDYwMzIxMjM1OTU5WjBfMQswCQYDVQQGEwJHQjEYMBYG + * A1UEChMPU2VjdGlnbyBMaW1pdGVkMTYwNAYDVQQDEy1TZWN0aWdvIFB1YmxpYyBT + * ZXJ2ZXIgQXV0aGVudGljYXRpb24gUm9vdCBFNDYwdjAQBgcqhkjOPQIBBgUrgQQA + * IgNiAAR2+pmpbiDt+dd34wc7qNs9Xzjoq1WmVk/WSOrsfy2qw7LFeeyZYX8QeccC + * WvkEN/U0NSt3zn8gj1KjAIns1aeibVvjS5KToID1AZTc8GgHHs3u/iVStSBDHBv+ + * 6xnOQ6OjQjBAMB0GA1UdDgQWBBTRItpMWfFLXyY4qp3W7usNw/upYTAOBgNVHQ8B + * Af8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNnADBkAjAn7qRa + * qCG76UeXlImldCBteU/IvZNeWBj7LRoAasm4PdCkT0RHlAFWovgzJQxC36oCMB3q + * 4S6ILuH5px0CMk7yn2xVdOOurvulGu7t0vzCAxHrRVxgED1cf5kDW21USAGKcw== + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02GB1\x180\x16\x06\x03U\x04\n\x13\x0fSectigo Limited1604\x06\x03U\x04\x03\x13-Sectigo Public Server Authentication Root E46"), + subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\"\x03b\x00\x04v\xfa\x99\xa9n \xed\xf9\xd7w\xe3\x07;\xa8\xdb=_8\xe8\xabU\xa6VO\xd6H\xea\xec\x7f-\xaa\xc3\xb2\xc5y\xec\x99a\x7f\x10y\xc7\x02Z\xf9\x047\xf545+w\xce\x7f \x8fR\xa3\x00\x89\xec\xd5\xa7\xa2m[\xe3K\x92\x93\xa0\x80\xf5\x01\x94\xdc\xf0h\x07\x1e\xcd\xee\xfe%R\xb5 C\x1c\x1b\xfe\xeb\x19\xceC\xa3"), + name_constraints: None + }, + + /* + * Issuer: CN=DigiCert Global Root G2 O=DigiCert Inc OU=www.digicert.com + * Subject: CN=DigiCert Global Root G2 O=DigiCert Inc OU=www.digicert.com + * Label: "DigiCert Global Root G2" + * Serial: 4293743540046975378534879503202253541 + * SHA256 Fingerprint: cb:3c:cb:b7:60:31:e5:e0:13:8f:8d:d3:9a:23:f9:de:47:ff:c3:5e:43:c1:14:4c:ea:27:d4:6a:5a:b1:cb:5f + * -----BEGIN CERTIFICATE----- + * MIIDjjCCAnagAwIBAgIQAzrx5qcRqaC7KGSxHQn65TANBgkqhkiG9w0BAQsFADBh + * MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 + * d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBH + * MjAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUxMjAwMDBaMGExCzAJBgNVBAYTAlVT + * MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j + * b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEcyMIIBIjANBgkqhkiG + * 9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuzfNNNx7a8myaJCtSnX/RrohCgiN9RlUyfuI + * 2/Ou8jqJkTx65qsGGmvPrC3oXgkkRLpimn7Wo6h+4FR1IAWsULecYxpsMNzaHxmx + * 1x7e/dfgy5SDN67sH0NO3Xss0r0upS/kqbitOtSZpLYl6ZtrAGCSYP9PIUkY92eQ + * q2EGnI/yuum06ZIya7XzV+hdG82MHauVBJVJ8zUtluNJbd134/tJS7SsVQepj5Wz + * tCO7TG1F8PapspUwtP1MVYwnSlcUfIKdzXOS0xZKBgyMUNGPHgm+F6HmIcr9g+UQ + * vIOlCsRnKPZzFBQ9RnbDhxSJITRNrw9FDKZJobq7nMWxM4MphQIDAQABo0IwQDAP + * BgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUTiJUIBiV + * 5uNu5g/6+rkS7QYXjzkwDQYJKoZIhvcNAQELBQADggEBAGBnKJRvDkhj6zHd6mcY + * 1Yl9PMWLSn/pvtsrF9+wX3N3KjITOYFnQoQj8kVnNeyIv/iPsGEMNKSuIEyExtv4 + * NeF22d+mQrvHRAiGfzZ0JFrabA0UWTW98kndth/Jsw1HKj2ZL7tcu7XUIOGZX1NG + * Fdtom/DzMNU+MeKNhJ7jitralj41E6Vf8PlwUHBHQRFXGU7Aj64GxJUTFy8bJZ91 + * 8rGOmaFvE7FBcf6IKshPECBV1/MUReXgRPTqh5Uykw7+U0b6LJ3/iyK5S9kJRaTe + * pLiaWN0bfVKfjllDiIGknibVb63dDcY3fe0Dkhvld1927jyNxF1WW6LZZm6zNTfl + * MrY= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1\x150\x13\x06\x03U\x04\n\x13\x0cDigiCert Inc1\x190\x17\x06\x03U\x04\x0b\x13\x10www.digicert.com1 0\x1e\x06\x03U\x04\x03\x13\x17DigiCert Global Root G2"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x01\x0f\x000\x82\x01\n\x02\x82\x01\x01\x00\xbb7\xcd4\xdc{k\xc9\xb2h\x90\xadJu\xffF\xba!\n\x08\x8d\xf5\x19T\xc9\xfb\x88\xdb\xf3\xae\xf2:\x89\x91\xc9\xcb&Y\rs\xde\xb0\xc8\xe9&\x0e\x83\x15\xc6\xef[\x8b\xd2\x04`\xcaI\xa6(\xf6i;\xf6\xcb\xc8(\x91\xe5\x9d\x8aaW7\xact\x14\xdct\xe0:\xeer/.\x9c\xfb\xd0\xbb\xbf\xf5=\x00\xe1\x063\xe8\x82+\xaeS\xa6:\x16s\x8c\xddA\x0e :\xc0\xb4\xa7\xa1\xe9\xb2O\x90.2`\xe9W\xcb\xb9\x04\x92hh\xe58&`u\xb2\x9fw\xff\x91\x14\xef\xae I\xfc\xad@\x15H\xd1\x021a\x19^\xb8\x97\xef\xadw\xb7d\x9az\xbf_\xc1\x13\xef\x9bb\xfb\rl\xe0Ti\x16\xa9\x03\xdan\xe9\x83\x93qv\xc6i\x85\x82\x17\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=GlobalSign Root E46 O=GlobalSign nv-sa + * Subject: CN=GlobalSign Root E46 O=GlobalSign nv-sa + * Label: "GlobalSign Root E46" + * Serial: 1552617690338932563915843282459653771421763 + * SHA256 Fingerprint: cb:b9:c4:4d:84:b8:04:3e:10:50:ea:31:a6:9f:51:49:55:d7:bf:d2:e2:c6:b4:93:01:01:9a:d6:1d:9f:50:58 + * -----BEGIN CERTIFICATE----- + * MIICCzCCAZGgAwIBAgISEdK7ujNu1LzmJGjFDYQdmOhDMAoGCCqGSM49BAMDMEYx + * CzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRwwGgYDVQQD + * ExNHbG9iYWxTaWduIFJvb3QgRTQ2MB4XDTE5MDMyMDAwMDAwMFoXDTQ2MDMyMDAw + * MDAwMFowRjELMAkGA1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2Ex + * HDAaBgNVBAMTE0dsb2JhbFNpZ24gUm9vdCBFNDYwdjAQBgcqhkjOPQIBBgUrgQQA + * IgNiAAScDrHPt+ieUnd1NPqlRqetMhkytAepJ8qUuwzSChDH2omwlwxwEwkBjtjq + * R+q+soArzfwoDdusvKSGN+1wCAB16pMLey5SnCNoIwZD7JIvU4Tb+0cUB+hflGdd + * yXqBPCCjQjBAMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1Ud + * DgQWBBQxCpCPtsad0kRLgLWi5h+xEk8blTAKBggqhkjOPQQDAwNoADBlAjEA31SQ + * 7Zvvi5QCkxeCmb6zniz2C5GMn0oUsfZkvLtoURMMA/cVi4RguYv/Uo7njLwcAjA8 + * +RHUjE7AwWHCFUyqqx0LMV87HOIAl0Qx5v5zli/altP+CAezNIm8BZ/3Hobui3A= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02BE1\x190\x17\x06\x03U\x04\n\x13\x10GlobalSign nv-sa1\x1c0\x1a\x06\x03U\x04\x03\x13\x13GlobalSign Root E46"), + subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\"\x03b\x00\x04\x9c\x0e\xb1\xcf\xb7\xe8\x9eRwu4\xfa\xa5F\xa7\xad2\x192\xb4\x07\xa9\'\xca\x94\xbb\x0c\xd2\n\x10\xc7\xda\x89\xb0\x97\x0cp\x13\t\x01\x8e\xd8\xeaG\xea\xbe\xb2\x80+\xcd\xfc(\r\xdb\xac\xbc\xa4\x867\xedp\x08\x00u\xea\x93\x0b{.R\x9c#h#\x06C\xec\x92/S\x84\xdb\xfbG\x14\x07\xe8_\x94g]\xc9z\x81< "), + name_constraints: None + }, + + /* + * Issuer: CN=UCA Extended Validation Root O=UniTrust + * Subject: CN=UCA Extended Validation Root O=UniTrust + * Label: "UCA Extended Validation Root" + * Serial: 106100277556486529736699587978573607008 + * SHA256 Fingerprint: d4:3a:f9:b3:54:73:75:5c:96:84:fc:06:d7:d8:cb:70:ee:5c:28:e7:73:fb:29:4e:b4:1e:e7:17:22:92:4d:24 + * -----BEGIN CERTIFICATE----- + * MIIFWjCCA0KgAwIBAgIQT9Irj/VkyDOeTzRYZiNwYDANBgkqhkiG9w0BAQsFADBH + * MQswCQYDVQQGEwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxJTAjBgNVBAMMHFVDQSBF + * eHRlbmRlZCBWYWxpZGF0aW9uIFJvb3QwHhcNMTUwMzEzMDAwMDAwWhcNMzgxMjMx + * MDAwMDAwWjBHMQswCQYDVQQGEwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxJTAjBgNV + * BAMMHFVDQSBFeHRlbmRlZCBWYWxpZGF0aW9uIFJvb3QwggIiMA0GCSqGSIb3DQEB + * AQUAA4ICDwAwggIKAoICAQCpCQcoEwKwmeBkqh5DFnpzsZGgdT6o+uM4AHrsiWog + * D4vFsJszA1qGxliG1cGFu0/GnEBNyr7uaZa4rYEwmnySBesFK5pI0Lh2PpbIILvS + * sPGP2KxFRv+qZ2C0d35qHzwaUnoEPQc8hQ2E0B92CvdqFN9y4zR8V05WAT558aop + * O2z6+I9tTcg1367r3CTueUWnhbYFiN6IXSV8l2RnCdm/WhUFhvMJHuxYMjMR83dk + * sHYf5BA1FxvyDrFspCqjc/wJHx4yGVMR59mzLC52LqGj3n5qiAno8geK+LLNEOfi + * c0CTuwjRP+H8C5SzJe98ptfRr5//lpr1kXuYC3fUfugH0mK1lTnj8/FtDw5lhIpj + * VMWAtuCeS31HJqcBCF3RiJ7XwzJE+oJKCmhUfzhTA8ykADNkUVkLo4KRel7sFsLz + * KuZi2irbWWIQJUoqgQtHB0MGcIfS+pMRKXpITeuUx3BNr2fVUbGAIAEBtHoIppB/ + * TuDvB0GHr2qlXov7z1CymlSvw4m6WC31MJixNnI5fkkE/SmnTHnkBVfblLkWU41G + * sx2VYVdWf6/wFlthWG82UBEL2KwrlRYaDh8IzTY0ZRBiZtWAXxQgXy0MoHgKaNYs + * 1+lvK9JKBZP8nm9rZ/+I8U6laUpSNwXqxhaN0sSZ0YIrO7o1dfdRUVjzyAfd5LQD + * fwIDAQABo0IwQDAdBgNVHQ4EFgQU2XQ65DA9DfcS3H5aBZ8eNJr34RQwDwYDVR0T + * AQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQELBQADggIBADaN + * l8xCFWQpN5smLNb7rhVpLGsaGvdftvkHTFnq88nIua7Mui563MD1sC3AO6+fcAUR + * ap8lTwEpcOPlDOHqWnzcSbvBHiqB9RZLcpHIojG5qtr8nR/zXUACE/xOHAbKsxSQ + * VBcZEhrxH9cMaVr2cXj0lH2RC47skFSOvG+hTKv8dGT9cZr4QQehzZHkPJrgmzI5 + * c6sq1WnIeJEmMX3ixzDx/BR4dxIOE/TdFpS/S2d7cFOFyrC78zhNLJA5wA3CXWvp + * 4uXViI3WLL+rG761KIcSF3Ru/H38j9CHJrAb+7lsq+KePRXBOy5nAliRn+/4Qh8s + * t2j1da3Ptfb/EX3C8CSlrdP6oDyp+l3cpaDvRKS+1ujl5BOWF3sGPjLtx7dCvHaj + * 2GU4Kzg1USEODm8uNBNA4StnDG1KQTAYI1oyVZnJF+A83vbsea0rWBmirSwiGpWO + * vpaQXUJXxPkUAzUrHC1RVwinOt4/5Mi0A3PCwSaAuwtCH60NryZy2sy+s6ODWA2C + * xR9GUeOcGMyNm43sSet1UNWMKFnKdDTajAshqx7qG+XH/RU+wBeq+yNuJkbL+vmx + * cmtpzyKEC2IPrNkZAJSidjzULZrtBJ4tBmIQN1IchXIbJ+XMxjHsN+xjWZsLHXbM + * fjKaiJUINlK73nZfdklJrX+9ZSCyycErdhh2n1ax + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02CN1\x110\x0f\x06\x03U\x04\n\x0c\x08UniTrust1%0#\x06\x03U\x04\x03\x0c\x1cUCA Extended Validation Root"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xa9\t\x07(\x13\x02\xb0\x99\xe0d\xaa\x1eC\x16zs\xb1\x91\xa0u>\xa8\xfa\xe38\x00z\xec\x89j \x0f\x8b\xc5\xb0\x9b3\x03Z\x86\xc6X\x86\xd5\xc1\x85\xbbO\xc6\x9c@M\xca\xbe\xeei\x96\xb8\xad\x810\x9a|\x92\x05\xeb\x05+\x9aH\xd0\xb8v>\x96\xc8 \xbb\xd2\xb0\xf1\x8f\xd8\xacEF\xff\xaag`\xb4w~j\x1f<\x1aRz\x04=\x07<\x85\r\x84\xd0\x1fv\n\xf7j\x14\xdfr\xe34|WNV\x01>y\xf1\xaa);l\xfa\xf8\x8fmM\xc85\xdf\xae\xeb\xdc$\xeeyE\xa7\x85\xb6\x05\x88\xde\x88]%|\x97dg\t\xd9\xbfZ\x15\x05\x86\xf3\t\x1e\xecX23\x11\xf3wd\xb0v\x1f\xe4\x105\x17\x1b\xf2\x0e\xb1l\xa4*\xa3s\xfc\t\x1f\x1e2\x19S\x11\xe7\xd9\xb3,.v.\xa1\xa3\xde~j\x88\t\xe8\xf2\x07\x8a\xf8\xb2\xcd\x10\xe7\xe2s@\x93\xbb\x08\xd1?\xe1\xfc\x0b\x94\xb3%\xef|\xa6\xd7\xd1\xaf\x9f\xff\x96\x9a\xf5\x91{\x98\x0bw\xd4~\xe8\x07\xd2b\xb5\x959\xe3\xf3\xf1m\x0f\x0ee\x84\x8acT\xc5\x80\xb6\xe0\x9eK}G&\xa7\x01\x08]\xd1\x88\x9e\xd7\xc32D\xfa\x82J\nhT\x7f8S\x03\xcc\xa4\x003dQY\x0b\xa3\x82\x91z^\xec\x16\xc2\xf3*\xe6b\xda*\xdbYb\x10%J*\x81\x0bG\x07C\x06p\x87\xd2\xfa\x93\x11)zHM\xeb\x94\xc7pM\xafg\xd5Q\xb1\x80 \x01\x01\xb4z\x08\xa6\x90\x7fN\xe0\xef\x07A\x87\xafj\xa5^\x8b\xfb\xcfP\xb2\x9aT\xaf\xc3\x89\xbaX-\xf50\x98\xb16r9~I\x04\xfd)\xa7Ly\xe4\x05W\xdb\x94\xb9\x16S\x8dF\xb3\x1d\x95aWV\x7f\xaf\xf0\x16[aXo6P\x11\x0b\xd8\xac+\x95\x16\x1a\x0e\x1f\x08\xcd64e\x10bf\xd5\x80_\x14 _-\x0c\xa0x\nh\xd6,\xd7\xe9o+\xd2J\x05\x93\xfc\x9eokg\xff\x88\xf1N\xa5iJR7\x05\xea\xc6\x16\x8d\xd2\xc4\x99\xd1\x82+;\xba5u\xf7QQX\xf3\xc8\x07\xdd\xe4\xb4\x03\x7f\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=Certigna Root CA O=Dhimyotis OU=0002 48146308100036 + * Subject: CN=Certigna Root CA O=Dhimyotis OU=0002 48146308100036 + * Label: "Certigna Root CA" + * Serial: 269714418870597844693661054334862075617 + * SHA256 Fingerprint: d4:8d:3d:23:ee:db:50:a4:59:e5:51:97:60:1c:27:77:4b:9d:7b:18:c9:4d:5a:05:95:11:a1:02:50:b9:31:68 + * -----BEGIN CERTIFICATE----- + * MIIGWzCCBEOgAwIBAgIRAMrpG4nxVQMNo+ZBbcTjpuEwDQYJKoZIhvcNAQELBQAw + * WjELMAkGA1UEBhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczEcMBoGA1UECwwTMDAw + * MiA0ODE0NjMwODEwMDAzNjEZMBcGA1UEAwwQQ2VydGlnbmEgUm9vdCBDQTAeFw0x + * MzEwMDEwODMyMjdaFw0zMzEwMDEwODMyMjdaMFoxCzAJBgNVBAYTAkZSMRIwEAYD + * VQQKDAlEaGlteW90aXMxHDAaBgNVBAsMEzAwMDIgNDgxNDYzMDgxMDAwMzYxGTAX + * BgNVBAMMEENlcnRpZ25hIFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAw + * ggIKAoICAQDNGDllGlmx6mQWDoyUJJV8g9PFOSbcDO8WV43X2KyjQn+Cyu3NW9sO + * ty3tRQgXstmzy9YXUnIo245Onoq2C/mehJpNdt4iKVzSs9IGPjA5qXSjklYcoW9M + * CiBtnyN6tMbaLOQdLNyzKNAT8kxOAkmhVECe5uUFoC2EyP+YbNDrihqECB63aCPu + * I9Vwzm1RaRDuoXrC0SIxwoKF0vJVdlB8JXrJhFwLrN1CTivngqIkicuQstDuI7pm + * TLtipPlTWmR7fJj6o0ieD5Wupxj0auwuA0Wv8HT4Ks16XdG+RCYyKfHx9WzMfgIh + * C59vpD++nVPiz32pLHxYGpfhPTc3GGYo0kDFUYqMwy3OU4gkWGQwFsWq4NYKpkDf + * ePb1BHxpE4S80dGnBs8B92jAqFe7OmGtBIyT46388NtEbVncSVmurJqZNjBBe3Yz + * IoejwpKGbvlw7q6Hh5UbxHq9MfPU0uWZ/75I7HX1eBYdpnDBfzwboZL7z8g81sWT + * Co/1VTp2lc5ZmIoJlXcymoO6LAQ6l73UL77XbJuiyn1tJslV1c/DeVIICZkHJC1k + * JWumIWmbat10TWuXekG9qxf5kBdIjzb5LdXF2+6qhUVB+s06RbFo5jZMm5BX7CO5 + * hwjCxAnxl4YqKE3idMDaxIzb3+KhF1nOJFl0Mdp//TBt2dzhauH8XwIDAQABo4IB + * GjCCARYwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYE + * FBiHVuBud+4kNTxOc5of1uHieX4rMB8GA1UdIwQYMBaAFBiHVuBud+4kNTxOc5of + * 1uHieX4rMEQGA1UdIAQ9MDswOQYEVR0gADAxMC8GCCsGAQUFBwIBFiNodHRwczov + * L3d3d3cuY2VydGlnbmEuZnIvYXV0b3JpdGVzLzBtBgNVHR8EZjBkMC+gLaArhilo + * dHRwOi8vY3JsLmNlcnRpZ25hLmZyL2NlcnRpZ25hcm9vdGNhLmNybDAxoC+gLYYr + * aHR0cDovL2NybC5kaGlteW90aXMuY29tL2NlcnRpZ25hcm9vdGNhLmNybDANBgkq + * hkiG9w0BAQsFAAOCAgEAlLieT/DjlQgi581oQfccVdV8AOItOoldaDgvUSILSo3L + * 6btdPrtcPbEo/uRTVRPPoZAbAh1fZkYJMyjhDSSXcNMQH+pkV5a7XdrnxIxPTGRG + * HVyH41neQtGbqH6mid2PHMkwgu07nM3A6RngatgCdTer9zQoKJHyBApPNeNgJgH6 + * 0BGM+RFq7q89w1DTj18zeTyGqHNFkIwgtnJzFyO+B2XleJINugHA64wcZr+shncB + * lA2c5uk5jR+mUYyZDDl34bSb+hxnV29qao6pK0xXeXpXIs/NX2NGjVxZOob4Mkdi + * o2cNGJHc+6Zr9UhhcyNZjgKnvETq9Emd8VRY+WCv2hikLyhF3HqgiIZd8zvn/yk1 + * gPxkQ5Tm4xxvvq0OKmOZK8l+hfZx6AYDlf7ej0gcWtSS6Cvu5zHbugRqh5jnxV/v + * faci9wHYTfmJ0A6aBVmknpjZbyvKcL5kwlWj9Omvw5Ip3IgWJJk8jSaYtlu3zM63 + * Nwf9JtmYhST/WSMDmu2dnajkXjjO11INb9I/bbEFa0nOipFGc/T2L/Coc3cOZayh + * jWZSaX5LaAzHHjcng6WMxwLkFM1JAbBzs/3GkDpv0mztO+7skb6iQ12LAEpmJURw + * 3kAP+HwV96LOPNdeE4yBFxgX0b3xdxA61GU5wSesVywlVP+i2k+KYTlerj1KjL0= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02FR1\x120\x10\x06\x03U\x04\n\x0c\tDhimyotis1\x1c0\x1a\x06\x03U\x04\x0b\x0c\x130002 481463081000361\x190\x17\x06\x03U\x04\x03\x0c\x10Certigna Root CA"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xcd\x189e\x1aY\xb1\xead\x16\x0e\x8c\x94$\x95|\x83\xd3\xc59&\xdc\x0c\xef\x16W\x8d\xd7\xd8\xac\xa3B\x7f\x82\xca\xed\xcd[\xdb\x0e\xb7-\xedE\x08\x17\xb2\xd9\xb3\xcb\xd6\x17Rr(\xdb\x8eN\x9e\x8a\xb6\x0b\xf9\x9e\x84\x9aMv\xde\")\\\xd2\xb3\xd2\x06>09\xa9t\xa3\x92V\x1c\xa1oL\n m\x9f#z\xb4\xc6\xda,\xe4\x1d,\xdc\xb3(\xd0\x13\xf2LN\x02I\xa1T@\x9e\xe6\xe5\x05\xa0-\x84\xc8\xff\x98l\xd0\xeb\x8a\x1a\x84\x08\x1e\xb7h#\xee#\xd5p\xcemQi\x10\xee\xa1z\xc2\xd1\"1\xc2\x82\x85\xd2\xf2UvP|%z\xc9\x84\\\x0b\xac\xddBN+\xe7\x82\xa2$\x89\xcb\x90\xb2\xd0\xee#\xbafL\xbbb\xa4\xf9SZd{|\x98\xfa\xa3H\x9e\x0f\x95\xae\xa7\x18\xf4j\xec.\x03E\xaf\xf0t\xf8*\xcdz]\xd1\xbeD&2)\xf1\xf1\xf5l\xcc~\x02!\x0b\x9fo\xa4?\xbe\x9dS\xe2\xcf}\xa9,|X\x1a\x97\xe1=77\x18f(\xd2@\xc5Q\x8a\x8c\xc3-\xceS\x88$Xd0\x16\xc5\xaa\xe0\xd6\n\xa6@\xdfx\xf6\xf5\x04|i\x13\x84\xbc\xd1\xd1\xa7\x06\xcf\x01\xf7h\xc0\xa8W\xbb:a\xad\x04\x8c\x93\xe3\xad\xfc\xf0\xdbDmY\xdcIY\xae\xac\x9a\x9960A{v3\"\x87\xa3\xc2\x92\x86n\xf9p\xee\xae\x87\x87\x95\x1b\xc4z\xbd1\xf3\xd4\xd2\xe5\x99\xff\xbeH\xecu\xf5x\x16\x1d\xa6p\xc1\x7f<\x1b\xa1\x92\xfb\xcf\xc8<\xd6\xc5\x93\n\x8f\xf5U:v\x95\xceY\x98\x8a\t\x95w2\x9a\x83\xba,\x04:\x97\xbd\xd4/\xbe\xd7l\x9b\xa2\xca}m&\xc9U\xd5\xcf\xc3yR\x08\t\x99\x07$-d%k\xa6!i\x9bj\xddtMk\x97zA\xbd\xab\x17\xf9\x90\x17H\x8f6\xf9-\xd5\xc5\xdb\xee\xaa\x85EA\xfa\xcd:E\xb1h\xe66L\x9b\x90W\xec#\xb9\x87\x08\xc2\xc4\t\xf1\x97\x86*(M\xe2t\xc0\xda\xc4\x8c\xdb\xdf\xe2\xa1\x17Y\xce$Yt1\xda\x7f\xfd0m\xd9\xdc\xe1j\xe1\xfc_\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=GTS Root R1 O=Google Trust Services LLC + * Subject: CN=GTS Root R1 O=Google Trust Services LLC + * Label: "GTS Root R1" + * Serial: 159662320309726417404178440727 + * SHA256 Fingerprint: d9:47:43:2a:bd:e7:b7:fa:90:fc:2e:6b:59:10:1b:12:80:e0:e1:c7:e4:e4:0f:a3:c6:88:7f:ff:57:a7:f4:cf + * -----BEGIN CERTIFICATE----- + * MIIFVzCCAz+gAwIBAgINAgPlk28xsBNJiGuiFzANBgkqhkiG9w0BAQwFADBHMQsw + * CQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEU + * MBIGA1UEAxMLR1RTIFJvb3QgUjEwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAw + * MDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZp + * Y2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjEwggIiMA0GCSqGSIb3DQEBAQUA + * A4ICDwAwggIKAoICAQC2EQKLHuOhd5s73L+UPreVp0A8of2C+X0yBoJx9vaMf/vo + * 27xqLpeXo4xL+Sv2sfnOhB2x+cWX3u+58qPpvBKJXqeqUqv4IyfLpLGcY9vXmX7w + * Cl7raKb0xlpHDU0QM+NOsROjyBhsS+z8CZDfnWQpJSMHobTSPS5g4M/SCYe7zUjw + * TcLCeoiKu7rPWRnWr4+wB7CeMfGCwcDfLqZtbBkOtdh+JhpFAz2weaSUKK0Pfybl + * qAj+lug8aJRT7oM6iCsVlgmy4HqMLnXWnOunVmSPlk9orj2XwoSPwLxAwAtcvfaH + * szVsrBhQf4TgTM2S0yDpM7xSma8ytSmzJSq0SPly4cpk9+aCEI3oncKKiPo4Zor8 + * Y/kB+Xj9e1x3+naH+uzfsQ55lVe0vSbv1gHR6xYKu44LtcXFilWr06zqkUspzBmk + * MiVOKvFlRNACzqrOSbTqn3yDsEB750Orp2yjj32JgfpMpf/VjsPOS+C12LOORc92 + * wO1AK/1TD7Cn1TsNsYqiA94xrcx36m97PtbfkSIS5r762DL8EGMUUXLeXdYWk70p + * aDPvOmbsB4om3xPXV2V4J95eSRQAogB/mqghtqmxlbCluQ0WEdrHbEg8QOB+DVrN + * VjzRlwW5y0vtOUucxD/SVRNuJLDWcfr0wbrM7Rv1/oFB2ACYPTrIrnqYNxgFlQID + * AQABo0IwQDAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4E + * FgQU5K8rJnEaK0gnhS9SZizv8IkTcT4wDQYJKoZIhvcNAQEMBQADggIBAJ+qQibb + * C5u+/x6Wki4+omVKapi6Ist9wTrYggoGxval3sBOh2Z5ofmmWJyq+bXmYOfg6LEe + * QkEzCzc9zolwFcq1JKjPa7XSQCGYzyI0zzvFIoTgxQ6KfF2I5DUkzps+GlQebtuy + * h6f88/qBVRRiClmpIgUxPoLW7ttXNLwzldMXG+gnoot7TiYaelpkttGsN/H9oPM4 + * 7HLwEXWdyzRSjeZ2axfG34arJ45JK3VmgRAhpuo+9K4l/3wV3s6MJT/KYnAK9y8J + * ZgfIPxz88NtFMN9iiMG1D53Dn0reWVlHxYciNuaCp+0KueIHoI17eko8cdLiA6Ef + * MgfdG+RCzgwARWGAtQsgWSl4vflVy2PFPEz0tv/bal8xa5meLMFrUKTX5hgUvYU/ + * Z6tGn6D/Qqc6f1zLXbBwHSs09dR2CQzreExZBfMzQsNhFRAbd03OIozUhfJFfbdT + * 6u9AWpQKXCBfTkBdYiJ23//OYb2MI3jSNwLgjt7RETeJ9r/tSQdirpLsQBqvFAnZ + * 0E6yove+7u7Y/9waLd64NnHi/Hm3lCXRSHNboTXns5lndcEZOitHTtNCjv0xyBZm + * 2tIMPNuzjsmhDYAPexZ3FL//2wmUspO8IFgV6dtxQ/PeEMMA3KgqlbbC1j+Qa3bb + * bP6MvPJwNQzcmRk13NfIRmPVNnGuV/u3gm3c + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1\"0 \x06\x03U\x04\n\x13\x19Google Trust Services LLC1\x140\x12\x06\x03U\x04\x03\x13\x0bGTS Root R1"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xb6\x11\x02\x8b\x1e\xe3\xa1w\x9b;\xdc\xbf\x94>\xb7\x95\xa7@<\xa1\xfd\x82\xf9}2\x06\x82q\xf6\xf6\x8c\x7f\xfb\xe8\xdb\xbcj.\x97\x97\xa3\x8cK\xf9+\xf6\xb1\xf9\xce\x84\x1d\xb1\xf9\xc5\x97\xde\xef\xb9\xf2\xa3\xe9\xbc\x12\x89^\xa7\xaaR\xab\xf8#\'\xcb\xa4\xb1\x9cc\xdb\xd7\x99~\xf0\n^\xebh\xa6\xf4\xc6ZG\rM\x103\xe3N\xb1\x13\xa3\xc8\x18lK\xec\xfc\t\x90\xdf\x9dd)%#\x07\xa1\xb4\xd2=.`\xe0\xcf\xd2\t\x87\xbb\xcdH\xf0M\xc2\xc2z\x88\x8a\xbb\xba\xcfY\x19\xd6\xaf\x8f\xb0\x07\xb0\x9e1\xf1\x82\xc1\xc0\xdf.\xa6ml\x19\x0e\xb5\xd8~&\x1aE\x03=\xb0y\xa4\x94(\xad\x0f\x7f&\xe5\xa8\x08\xfe\x96\xe8\xd6\xdf\x91\"\x12\xe6\xbe\xfa\xd82\xfc\x10c\x14Qr\xde]\xd6\x16\x93\xbd)h3\xef:f\xec\x07\x8a&\xdf\x13\xd7Wex\'\xde^I\x14\x00\xa2\x00\x7f\x9a\xa8!\xb6\xa9\xb1\x95\xb0\xa5\xb9\r\x16\x11\xda\xc7lH<@\xe0~\rZ\xcdV<\xd1\x97\x05\xb9\xcbK\xed9K\x9c\xc4?\xd2U\x13n$\xb0\xd6q\xfa\xf4\xc1\xba\xcc\xed\x1b\xf5\xfe\x81A\xd8\x00\x98=:\xc8\xaez\x987\x18\x05\x95\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=HARICA TLS RSA Root CA 2021 O=Hellenic Academic and Research Institutions CA + * Subject: CN=HARICA TLS RSA Root CA 2021 O=Hellenic Academic and Research Institutions CA + * Label: "HARICA TLS RSA Root CA 2021" + * Serial: 76817823531813593706434026085292783742 + * SHA256 Fingerprint: d9:5d:0e:8e:da:79:52:5b:f9:be:b1:1b:14:d2:10:0d:32:94:98:5f:0c:62:d9:fa:bd:9c:d9:99:ec:cb:7b:1d + * -----BEGIN CERTIFICATE----- + * MIIFpDCCA4ygAwIBAgIQOcqTHO9D88aOk8f0ZIk4fjANBgkqhkiG9w0BAQsFADBs + * MQswCQYDVQQGEwJHUjE3MDUGA1UECgwuSGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJl + * c2VhcmNoIEluc3RpdHV0aW9ucyBDQTEkMCIGA1UEAwwbSEFSSUNBIFRMUyBSU0Eg + * Um9vdCBDQSAyMDIxMB4XDTIxMDIxOTEwNTUzOFoXDTQ1MDIxMzEwNTUzN1owbDEL + * MAkGA1UEBhMCR1IxNzA1BgNVBAoMLkhlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNl + * YXJjaCBJbnN0aXR1dGlvbnMgQ0ExJDAiBgNVBAMMG0hBUklDQSBUTFMgUlNBIFJv + * b3QgQ0EgMjAyMTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAIvC569l + * mwVnlskNJLnQDmT8zuIkGCyEf3dRywQRNrhe7Wlxp57kJQmXZ8FHws+RFjZiPTgE + * 4VGC/6zStGndLuwRo0Xua2s7TL+MjaQenRG56Tj5eg4MmOIjHdFOY9TnuEFE+2uv + * a9of08WRiFukiZLRgeaMOVig1mlDqa2YUlhu2wr7a89o+uOkXjpFc5gH6l8Cct4M + * pbOfrqkdtx2z/IpZ525yZa31MJQjB/OCFks1mJxTuy/K5FrZx40d/JiZ+yykgmvw + * Kh+OC19xXFyuQnspiYHLA6OZyoieC0AJQTPb5lh6/a6ZcMBaD9YThnEvdmn8kN3b + * LW7R8pv1GmuebxWMevBLKKAiOIAkbDakO/IwkfN4E8/BPzWr8R0RI7VDIp4BkrcY + * AuUR0YLbFQDMYTfBKnya4dC6s1BG7oKsnTH4+yPiAwBIcKMJJnkVU2DzOFytOOqB + * AGMUuTNe3QvboEUHGjMJ+E20pwKmafTCWQWIZYVWrkvL4N48fS0ayOn7H6NhStYq + * E613TBoYm5EPWNgGVMWX+Ko/IIqmhaZ39qb8HOLubpQzKoNQhArlT4b4UEV4AIHr + * W2jjJo3Me1xR9BQsQL4aYB16cmEdH2MtiKrOokWQCPxrvrNQKlr9qEgYRtaQQJKQ + * CoReaDH46+0N0x3GfZkYVVYnZS6NRcUk7M7jAgMBAAGjQjBAMA8GA1UdEwEB/wQF + * MAMBAf8wHQYDVR0OBBYEFApII6ZgpJIKM+qTW8VX6iVNvRLuMA4GA1UdDwEB/wQE + * AwIBhjANBgkqhkiG9w0BAQsFAAOCAgEAPpBIqm5iFSVmewzVjIuJndftTgfvnNAU + * X15QvWiWkKQUEapobQk1OUAJ2vQJLDSle1mESSmXdMgHHkdt8s4cUCbjnj1AUz/3 + * f5Z2EMVGpdAgS1D0NTsY9FVqQRtHBmg8uwkIYtlfVUKqrFOFrJVWNlar5AWMxaja + * H6NpvVMPxP/cyuN+8kyIhkdGGvMA9YCRotxDQpSbIPDRzbLrLFPCU3hKTwSUQZqP + * JzLB5UkZv/HywouoCjkxKLR9YjYsTewfM7Z+d21+UPCfDtcRj88YxeMn/ibvBZ3P + * zzfF0HvaO7AWhAw6k9a+F9sPPg4ZeAnHqQJyIkv3N3a6dcSFA1pj1bF1BcK5vZSt + * jBWZp5N99sXzqnTPBIWUmAD04vnKJGW/4GKvyMX6ssmeVkjaef2WdhW+o45WxLM0 + * /L5H9MG0qPzVMIho7suuyWPEdr6sOBjhXlzPrjoiUevRi7PzKzMHVIf6tLITe7pT + * BGIBnfHAT+7hOtSLIBD6Alfm78ELt5BGnBkpjNxvoEppaZS3JGWg/6w/zgH7IS79 + * aPib8qXPMThcFarmlwDB31qlpzmq6YR/PFGoOtmUW4y/Twhx5duoXNTSpv4Ao8YW + * xw/ogM4cKGR0GQjTQuPOAF1/sdwTsOEFy9EgqoZ0njnnkf3/W9b3raYvAwtt41dU + * 63ZTGI0RmLo= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02GR1705\x06\x03U\x04\n\x0c.Hellenic Academic and Research Institutions CA1$0\"\x06\x03U\x04\x03\x0c\x1bHARICA TLS RSA Root CA 2021"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\x8b\xc2\xe7\xafe\x9b\x05g\x96\xc9\r$\xb9\xd0\x0ed\xfc\xce\xe2$\x18,\x84\x7fwQ\xcb\x04\x116\xb8^\xediq\xa7\x9e\xe4%\t\x97g\xc1G\xc2\xcf\x91\x166b=8\x04\xe1Q\x82\xff\xac\xd2\xb4i\xdd.\xec\x11\xa3E\xeekk;L\xbf\x8c\x8d\xa4\x1e\x9d\x11\xb9\xe98\xf9z\x0e\x0c\x98\xe2#\x1d\xd1Nc\xd4\xe7\xb8AD\xfbk\xafk\xda\x1f\xd3\xc5\x91\x88[\xa4\x89\x92\xd1\x81\xe6\x8c9X\xa0\xd6iC\xa9\xad\x98RXn\xdb\n\xfbk\xcfh\xfa\xe3\xa4^:Es\x98\x07\xea_\x02r\xde\x0c\xa5\xb3\x9f\xae\xa9\x1d\xb7\x1d\xb3\xfc\x8aY\xe7nre\xad\xf50\x94#\x07\xf3\x82\x16K5\x98\x9cS\xbb/\xca\xe4Z\xd9\xc7\x8d\x1d\xfc\x98\x99\xfb,\xa4\x82k\xf0*\x1f\x8e\x0b_q\\\\\xaeB{)\x89\x81\xcb\x03\xa3\x99\xca\x88\x9e\x0b@\tA3\xdb\xe6Xz\xfd\xae\x99p\xc0Z\x0f\xd6\x13\x86q/vi\xfc\x90\xdd\xdb-n\xd1\xf2\x9b\xf5\x1ak\x9eo\x15\x8cz\xf0K(\xa0\"8\x80$l6\xa4;\xf20\x91\xf3x\x13\xcf\xc1?5\xab\xf1\x1d\x11#\xb5C\"\x9e\x01\x92\xb7\x18\x02\xe5\x11\xd1\x82\xdb\x15\x00\xcca7\xc1*|\x9a\xe1\xd0\xba\xb3PF\xee\x82\xac\x9d1\xf8\xfb#\xe2\x03\x00Hp\xa3\t&y\x15S`\xf38\\\xad8\xea\x81\x00c\x14\xb93^\xdd\x0b\xdb\xa0E\x07\x1a3\t\xf8M\xb4\xa7\x02\xa6i\xf4\xc2Y\x05\x88e\x85V\xaeK\xcb\xe0\xde<}-\x1a\xc8\xe9\xfb\x1f\xa3aJ\xd6*\x13\xadwL\x1a\x18\x9b\x91\x0fX\xd8\x06T\xc5\x97\xf8\xaa? \x8a\xa6\x85\xa6w\xf6\xa6\xfc\x1c\xe2\xeen\x943*\x83P\x84\n\xe5O\x86\xf8PEx\x00\x81\xeb[h\xe3&\x8d\xcc{\\Q\xf4\x14,@\xbe\x1a`\x1dzra\x1d\x1fc-\x88\xaa\xce\xa2E\x90\x08\xfck\xbe\xb3P*Z\xfd\xa8H\x18F\xd6\x90@\x92\x90\n\x84^h1\xf8\xeb\xed\r\xd3\x1d\xc6}\x99\x18UV\'e.\x8dE\xc5$\xec\xce\xe3\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=TrustAsia Global Root CA G3 O=TrustAsia Technologies, Inc. + * Subject: CN=TrustAsia Global Root CA G3 O=TrustAsia Technologies, Inc. + * Label: "TrustAsia Global Root CA G3" + * Serial: 576386314500428537169965010905813481816650257167 + * SHA256 Fingerprint: e0:d3:22:6a:eb:11:63:c2:e4:8f:f9:be:3b:50:b4:c6:43:1b:e7:bb:1e:ac:c5:c3:6b:5d:5e:c5:09:03:9a:08 + * -----BEGIN CERTIFICATE----- + * MIIFpTCCA42gAwIBAgIUZPYOZXdhaqs7tOqFhLuxibhxkw8wDQYJKoZIhvcNAQEM + * BQAwWjELMAkGA1UEBhMCQ04xJTAjBgNVBAoMHFRydXN0QXNpYSBUZWNobm9sb2dp + * ZXMsIEluYy4xJDAiBgNVBAMMG1RydXN0QXNpYSBHbG9iYWwgUm9vdCBDQSBHMzAe + * Fw0yMTA1MjAwMjEwMTlaFw00NjA1MTkwMjEwMTlaMFoxCzAJBgNVBAYTAkNOMSUw + * IwYDVQQKDBxUcnVzdEFzaWEgVGVjaG5vbG9naWVzLCBJbmMuMSQwIgYDVQQDDBtU + * cnVzdEFzaWEgR2xvYmFsIFJvb3QgQ0EgRzMwggIiMA0GCSqGSIb3DQEBAQUAA4IC + * DwAwggIKAoICAQDAMYJhkuSUGwoqZdC+BqmHO1ES6nBBruL7dOoKjbmzTNyPtxNS + * T1QY4SxzlZHFZjtqz6xjbYdT8PfxObegQ2OwxANdV6nnRM7EoYNl9lA+sX4WuDqK + * AtCWHwDNBSHvBm3dIZwZQ0WhxeiAysKtQGIXBsaqvPPW5vxQfmZCHzyLpnl5hkA1 + * nyDvP+uLRx+PjsXUjrYsyUQE49RDdT/VP68czH5GX6zfZBCK70bwkPAPLfSIC7Ep + * qq+FqklYqL9joDiR5rPmd2jE+SoZhLsO4fWvieylL1AgdB4SQXMeJNnKziyhWTXA + * yB1GJ2Faj/lN03J5Zh6fFZAhLf3ti1ZwA0pJPn9pMRJpxx5cynoTi+jm9WAPzJMs + * hH/x/Gr8m0ed262IPfN2dTPXS6TIi/n1Q1hPy8gDVI+lhXgEGvNz8teHHUGf59gX + * zhqcD0r83ERoVGjiQTz+LISGNzzNPy+i2+f3VANfWdP3kXjHi3dqFuVJhZBFcnAv + * kV34PmVACxmZySYgWmjBNb9Pp1Hx2BErW+Canig7CjoKH8GB5S7wprlppYiU5msT + * f9FkPz2ccEblooV7WIQn3MSAPmeamseaMQ4w7OYXQJXZRe0Blqq/DPNL0WP3E1jA + * uPP6Z92bfW1K/zJMtSU7/xxnD4UiWQWRkUF3gdCFTIcQcf+eQxuulXUtgQIDAQAB + * o2MwYTAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFEDk5PIj7zjKsK5Xf/Ih + * MBY027ySMB0GA1UdDgQWBBRA5OTyI+84yrCuV3/yITAWNNu8kjAOBgNVHQ8BAf8E + * BAMCAQYwDQYJKoZIhvcNAQEMBQADggIBACY7UeFNOPMyGLS0XuFlXsSUT9SnYaP4 + * wM8zAQLpw6o1D/GUE3d3NZ4tVlFEbuHGLige/9rsR82XRBf34EzC4Xx8MnpmyFq2 + * XFNFV1pF1AWZLy4jVe5jaN/TG3inEpQGAHUNcoTpLrxaatXeL1nHo+zSh2bbt1S1 + * JKv0Q3jbSwTEb93mPmY+KfJLaHEih6D4sTNjduMNhXJEIlU/HHzp/LgV6FL6qj6j + * ITk1dImmasI5+njPtqzn59ZW/yOSLlALqbUHM/Q4X6RJpstlcHboCoWASzY9M/eV + * VHUl2qzEc4Jl6VL1XP04lQJqaTDFHApXB64ipCz5xUG3uOyfT0gA+QEEVcys+TIx + * xHWVBqB/0Y0n3bOppHKH/lmLmnp0Ft0WpWIp6zqW3IunaFnT63eROfjXy9mPX1on + * AX1daBli2MjN9LdyR75bl87yraKZk62Uy5P2EgmVtqvXO9A/EcswFi55gORngS1d + * 7XB4tmBZrOFdRWOPyN9yaFvqHbgB8X7754qz41SgOAngPN5C8sLtLpvzHzW2Ntjj + * gKGLzZlkD8Kqq7HK9W+eQ42EVJmzbsASZthwEPEGNTNDqJwuuhQxzhB/HIbjj9LV + * +Hfsm6vxL2PZQl/gZ4FkkfGXL/xuJvYz+NO1+MRiqzFRJQJ6+N1rZdVtTTDIZbpo + * FGWsJwt0ivKH + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02CN1%0#\x06\x03U\x04\n\x0c\x1cTrustAsia Technologies, Inc.1$0\"\x06\x03U\x04\x03\x0c\x1bTrustAsia Global Root CA G3"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xc01\x82a\x92\xe4\x94\x1b\n*e\xd0\xbe\x06\xa9\x87;Q\x12\xeapA\xae\xe2\xfbt\xea\n\x8d\xb9\xb3L\xdc\x8f\xb7\x13ROT\x18\xe1,s\x95\x91\xc5f;j\xcf\xaccm\x87S\xf0\xf7\xf19\xb7\xa0Cc\xb0\xc4\x03]W\xa9\xe7D\xce\xc4\xa1\x83e\xf6P>\xb1~\x16\xb8:\x8a\x02\xd0\x96\x1f\x00\xcd\x05!\xef\x06m\xdd!\x9c\x19CE\xa1\xc5\xe8\x80\xca\xc2\xad@b\x17\x06\xc6\xaa\xbc\xf3\xd6\xe6\xfcP~fB\x1f<\x8b\xa6yy\x86@5\x9f \xef?\xeb\x8bG\x1f\x8f\x8e\xc5\xd4\x8e\xb6,\xc9D\x04\xe3\xd4Cu?\xd5?\xaf\x1c\xcc~F_\xac\xdfd\x10\x8a\xefF\xf0\x90\xf0\x0f-\xf4\x88\x0b\xb1)\xaa\xaf\x85\xaaIX\xa8\xbfc\xa08\x91\xe6\xb3\xe6wh\xc4\xf9*\x19\x84\xbb\x0e\xe1\xf5\xaf\x89\xec\xa5/P t\x1e\x12As\x1e$\xd9\xca\xce,\xa1Y5\xc0\xc8\x1dF\'aZ\x8f\xf9M\xd3ryf\x1e\x9f\x15\x90!-\xfd\xed\x8bVp\x03JI>\x7fi1\x12i\xc7\x1e\\\xcaz\x13\x8b\xe8\xe6\xf5`\x0f\xcc\x93,\x84\x7f\xf1\xfcj\xfc\x9bG\x9d\xdb\xad\x88=\xf3vu3\xd7K\xa4\xc8\x8b\xf9\xf5CXO\xcb\xc8\x03T\x8f\xa5\x85x\x04\x1a\xf3s\xf2\xd7\x87\x1dA\x9f\xe7\xd8\x17\xce\x1a\x9c\x0fJ\xfc\xdcDhTh\xe2A<\xfe,\x84\x867<\xcd?/\xa2\xdb\xe7\xf7T\x03_Y\xd3\xf7\x91x\xc7\x8bwj\x16\xe5I\x85\x90Erp/\x91]\xf8>e@\x0b\x19\x99\xc9& Zh\xc15\xbfO\xa7Q\xf1\xd8\x11+[\xe0\x9a\x9e(;\n:\n\x1f\xc1\x81\xe5.\xf0\xa6\xb9i\xa5\x88\x94\xe6k\x13\x7f\xd1d?=\x9cpF\xe5\xa2\x85{X\x84\'\xdc\xc4\x80>g\x9a\x9a\xc7\x9a1\x0e0\xec\xe6\x17@\x95\xd9E\xed\x01\x96\xaa\xbf\x0c\xf3K\xd1c\xf7\x13X\xc0\xb8\xf3\xfag\xdd\x9b}mJ\xff2L\xb5%;\xff\x1cg\x0f\x85\"Y\x05\x91\x91Aw\x81\xd0\x85L\x87\x10q\xff\x9eC\x1b\xae\x95u-\x81\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=CA Disig Root R2 O=Disig a.s. + * Subject: CN=CA Disig Root R2 O=Disig a.s. + * Label: "CA Disig Root R2" + * Serial: 10572350602393338211 + * SHA256 Fingerprint: e2:3d:4a:03:6d:7b:70:e9:f5:95:b1:42:20:79:d2:b9:1e:df:bb:1f:b6:51:a0:63:3e:aa:8a:9d:c5:f8:07:03 + * -----BEGIN CERTIFICATE----- + * MIIFaTCCA1GgAwIBAgIJAJK4iNuwisFjMA0GCSqGSIb3DQEBCwUAMFIxCzAJBgNV + * BAYTAlNLMRMwEQYDVQQHEwpCcmF0aXNsYXZhMRMwEQYDVQQKEwpEaXNpZyBhLnMu + * MRkwFwYDVQQDExBDQSBEaXNpZyBSb290IFIyMB4XDTEyMDcxOTA5MTUzMFoXDTQy + * MDcxOTA5MTUzMFowUjELMAkGA1UEBhMCU0sxEzARBgNVBAcTCkJyYXRpc2xhdmEx + * EzARBgNVBAoTCkRpc2lnIGEucy4xGTAXBgNVBAMTEENBIERpc2lnIFJvb3QgUjIw + * ggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCio8QACdaFXS1tFPbCw3Oe + * NcJxVX6B+6tGUODBfEl45qt5WDza/3wcn9iXAng+a0EE6UG9vgMsRfYvZNSrXaNH + * PWSb6WiaxswbP7q+sos0Ai6YVRn8jG+qX9pMzk0DIaPY0jSTVpbLTAwAFjxfGs3I + * x2ymrdMxp7zo5eFm1tL7A7RBZckQrg4FY8aAamkw/dLukO8NJ9+flXP04SXabBbe + * QTg06ov80egEFGEtQX6sx3dOy1FU+16SGBsEWmjGycT6txOgmLcRK7fWV8x8nhfR + * yyX+hk4kLlYMeE2eARKmK6cBZW58Yh2EhN/qwGu1pSqVg8NTEQxzHQuyRpDRQjrO + * QG6Vrf/GlK1ul4SOfW+eioANSW1z4nuSHsPzwfPrLgVv2RvPN3YEyLRa5Beny912 + * H9AZdugsBbPWnDTYltxhh5EF5EQIM8HauQhl1K6yNg3ruji6DOWbnuuNZt2Zz9aJ + * QfYEkoopKW1rOhzndX0CcQ7zwOe9yxndnWCywmZgtrEE7snmhrmaZkCo5xHtgUUD + * i/ZnWejBBhG93c+AAk9lQHhcR1DIm+YfgXvkRKhbhZri3lrVx/k6RGZL5DJUfORs + * nLMOPReisjQS1n6yqEm70XooQL6iFh/f5DcfEXP7kAplQ6INfPgGAVUzfbANuPT1 + * rqVCV3w2EYx7XsQDnYx5nQIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1Ud + * DwEB/wQEAwIBBjAdBgNVHQ4EFgQUtZn4r7CU9eMg1gqtzk5WpC5uQu0wDQYJKoZI + * hvcNAQELBQADggIBACYGXnDnZTPIgm7ZnBc6G3pmsgH2eDtpXi/q/075KMOYKmFM + * tCQSin1tERT3nLXK5ryeJ45MGcipvXrA1zYObYVybqjGom32+nNjf7xueQgcnYqf + * GopTpti72TVVsRHFqQOzVju5hJMiXn7B9hJSi+osZ7z+Nkz1uM/Rs0mSO9MpDpkb + * lvdhuDvEK7Z4bLQjb/D907JedR+Zlais9trhxTF7+9FGs9K8Z7RiVLoJ92Owk6Ka + * +elSLotgEqv89WBW7xBci8QaQtyDW2QOy7W81k/BfDxujRNt+3vrMNDcTa/F1bal + * TFtxyegxvug4BkihGuLq0t4SOVga/4AOgnXmt8kHbA7v/zjxmHHEt38OFdAlab0i + * nSvtBfZGR6ztwPDUO+Ls7pZbkBNOHlY667DvlruWIxG68kOGdGSVyCh13x01utI3 + * gzhTODY7z2zp+WsO0PsE6E9312UBeIYMej4hYvF/Y3EMyZ9E26gnonW+boE+18Dr + * G5gPcFw0sorMwIUY6256s/daoQe/qUKS82Ail+QUoQebTnbAjn39pCXHR+3/H3Os + * zMOl6W8KjptlwlCFtaOgUxLMVYdh84GuEEZhvUQhuMI9dM9+JDX6HAcOmz0iyu8x + * L4ysEr3vQCj8KWefshNPZiTEUxnpHikV7+ZtsH8tZ/3zbBt1RqPlShfppNcL + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02SK1\x130\x11\x06\x03U\x04\x07\x13\nBratislava1\x130\x11\x06\x03U\x04\n\x13\nDisig a.s.1\x190\x17\x06\x03U\x04\x03\x13\x10CA Disig Root R2"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xa2\xa3\xc4\x00\t\xd6\x85]-m\x14\xf6\xc2\xc3s\x9e5\xc2qU~\x81\xfb\xabFP\xe0\xc1|Ix\xe6\xabyX<\xda\xff|\x1c\x9f\xd8\x97\x02x>kA\x04\xe9A\xbd\xbe\x03,E\xf6/d\xd4\xab]\xa3G=d\x9b\xe9h\x9a\xc6\xcc\x1b?\xba\xbe\xb2\x8b4\x02.\x98U\x19\xfc\x8co\xaa_\xdaL\xceM\x03!\xa3\xd8\xd24\x93V\x96\xcbL\x0c\x00\x16<_\x1a\xcd\xc8\xc7l\xa6\xad\xd31\xa7\xbc\xe8\xe5\xe1f\xd6\xd2\xfb\x03\xb4Ae\xc9\x10\xae\x0e\x05c\xc6\x80ji0\xfd\xd2\xee\x90\xef\r\'\xdf\x9f\x95s\xf4\xe1%\xdal\x16\xdeA84\xea\x8b\xfc\xd1\xe8\x04\x14a-A~\xac\xc7wN\xcbQT\xfb^\x92\x18\x1b\x04Zh\xc6\xc9\xc4\xfa\xb7\x13\xa0\x98\xb7\x11+\xb7\xd6W\xcc|\x9e\x17\xd1\xcb%\xfe\x86N$.V\x0cxM\x9e\x01\x12\xa6+\xa7\x01en|b\x1d\x84\x84\xdf\xea\xc0k\xb5\xa5*\x95\x83\xc3S\x11\x0cs\x1d\x0b\xb2F\x90\xd1B:\xce@n\x95\xad\xff\xc6\x94\xadn\x97\x84\x8e}o\x9e\x8a\x80\rIms\xe2{\x92\x1e\xc3\xf3\xc1\xf3\xeb.\x05o\xd9\x1b\xcf7v\x04\xc8\xb4Z\xe4\x17\xa7\xcb\xddv\x1f\xd0\x19v\xe8,\x05\xb3\xd6\x9c4\xd8\x96\xdca\x87\x91\x05\xe4D\x083\xc1\xda\xb9\x08e\xd4\xae\xb26\r\xeb\xba8\xba\x0c\xe5\x9b\x9e\xeb\x8df\xdd\x99\xcf\xd6\x89A\xf6\x04\x92\x8a))mk:\x1c\xe7u}\x02q\x0e\xf3\xc0\xe7\xbd\xcb\x19\xdd\x9d`\xb2\xc2f`\xb6\xb1\x04\xee\xc9\xe6\x86\xb9\x9af@\xa8\xe7\x11\xed\x81E\x03\x8b\xf6gY\xe8\xc1\x06\x11\xbd\xdd\xcf\x80\x02Oe@x\\GP\xc8\x9b\xe6\x1f\x81{\xe4D\xa8[\x85\x9a\xe2\xdeZ\xd5\xc7\xf9:DfK\xe42T|\xe4l\x9c\xb3\x0e=\x17\xa2\xb24\x12\xd6~\xb2\xa8I\xbb\xd1z(@\xbe\xa2\x16\x1f\xdf\xe47\x1f\x11s\xfb\x90\neC\xa2\r|\xf8\x06\x01U3}\xb0\r\xb8\xf4\xf5\xae\xa5BW|6\x11\x8c{^\xc4\x03\x9d\x8cy\x9d\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=Amazon Root CA 4 O=Amazon + * Subject: CN=Amazon Root CA 4 O=Amazon + * Label: "Amazon Root CA 4" + * Serial: 143266989758080763974105200630763877849284878 + * SHA256 Fingerprint: e3:5d:28:41:9e:d0:20:25:cf:a6:90:38:cd:62:39:62:45:8d:a5:c6:95:fb:de:a3:c2:2b:0b:fb:25:89:70:92 + * -----BEGIN CERTIFICATE----- + * MIIB8jCCAXigAwIBAgITBmyf18G7EEwpQ+Vxe3ssyBrBDjAKBggqhkjOPQQDAzA5 + * MQswCQYDVQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24g + * Um9vdCBDQSA0MB4XDTE1MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkG + * A1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZMBcGA1UEAxMQQW1hem9uIFJvb3Qg + * Q0EgNDB2MBAGByqGSM49AgEGBSuBBAAiA2IABNKrijdPo1MN/sGKe0uoe0ZLY7Bi + * 9i0b2whxIdIA6GO9mif78DluXeo9pcmBqqNbIJhFXRbb/egQbeOc4OO9X4Ri83Bk + * M6DLJC9wuoihKqB1+IGuYgbEgds5bimwHvouXKNCMEAwDwYDVR0TAQH/BAUwAwEB + * /zAOBgNVHQ8BAf8EBAMCAYYwHQYDVR0OBBYEFNPsxzplbszh2naaVvuc84ZtV+WB + * MAoGCCqGSM49BAMDA2gAMGUCMDqLIfG9fhGt0O9Yli/W651+kI0rz2ZVwyzjKKlw + * CkcO8DdZEv8tmZQoTipPNU0zWgIxAOp1AE47xDqUEpHJWEadIRNyp4iciuRMStuW + * 1KyLa2tJElMzrdfkviT8tQp21KW8EA== + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02US1\x0f0\r\x06\x03U\x04\n\x13\x06Amazon1\x190\x17\x06\x03U\x04\x03\x13\x10Amazon Root CA 4"), + subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\"\x03b\x00\x04\xd2\xab\x8a7O\xa3S\r\xfe\xc1\x8a{K\xa8{FKc\xb0b\xf6-\x1b\xdb\x08q!\xd2\x00\xe8c\xbd\x9a\'\xfb\xf09n]\xea=\xa5\xc9\x81\xaa\xa3[ \x98E]\x16\xdb\xfd\xe8\x10m\xe3\x9c\xe0\xe3\xbd_\x84b\xf3pd3\xa0\xcb$/p\xba\x88\xa1*\xa0u\xf8\x81\xaeb\x06\xc4\x81\xdb9n)\xb0\x1e\xfa.\\"), + name_constraints: None + }, + + /* + * Issuer: CN=D-TRUST BR Root CA 1 2020 O=D-Trust GmbH + * Subject: CN=D-TRUST BR Root CA 1 2020 O=D-Trust GmbH + * Label: "D-TRUST BR Root CA 1 2020" + * Serial: 165870826978392376648679885835942448534 + * SHA256 Fingerprint: e5:9a:aa:81:60:09:c2:2b:ff:5b:25:ba:d3:7d:f3:06:f0:49:79:7c:1f:81:d8:5a:b0:89:e6:57:bd:8f:00:44 + * -----BEGIN CERTIFICATE----- + * MIIC2zCCAmCgAwIBAgIQfMmPK4TX3+oPyWWa00tNljAKBggqhkjOPQQDAzBIMQsw + * CQYDVQQGEwJERTEVMBMGA1UEChMMRC1UcnVzdCBHbWJIMSIwIAYDVQQDExlELVRS + * VVNUIEJSIFJvb3QgQ0EgMSAyMDIwMB4XDTIwMDIxMTA5NDUwMFoXDTM1MDIxMTA5 + * NDQ1OVowSDELMAkGA1UEBhMCREUxFTATBgNVBAoTDEQtVHJ1c3QgR21iSDEiMCAG + * A1UEAxMZRC1UUlVTVCBCUiBSb290IENBIDEgMjAyMDB2MBAGByqGSM49AgEGBSuB + * BAAiA2IABMbLxyjR+4T1mu9CFCDhQ2tuda38KwOE1HaTJddZO0Flax7mNCq7dPYS + * zuht56vkPE4/RAiLzRZxy7+SmfSk1zxQVFKQhYN4lGdnoxwJGT11NIXe7WB9xwy0 + * QVK5buXuQqOCAQ0wggEJMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFHOREKv/ + * VbNafAkl1bK6CKBrqx9tMA4GA1UdDwEB/wQEAwIBBjCBxgYDVR0fBIG+MIG7MD6g + * PKA6hjhodHRwOi8vY3JsLmQtdHJ1c3QubmV0L2NybC9kLXRydXN0X2JyX3Jvb3Rf + * Y2FfMV8yMDIwLmNybDB5oHegdYZzbGRhcDovL2RpcmVjdG9yeS5kLXRydXN0Lm5l + * dC9DTj1ELVRSVVNUJTIwQlIlMjBSb290JTIwQ0ElMjAxJTIwMjAyMCxPPUQtVHJ1 + * c3QlMjBHbWJILEM9REU/Y2VydGlmaWNhdGVyZXZvY2F0aW9ubGlzdDAKBggqhkjO + * PQQDAwNpADBmAjEAlJAtE/rhY/hhY+ithXhUkZy4kzg+GkHaQBZTQgjKL47xPoFW + * wKrY7RjEsK70PvomAjEA8yjixtsrmfu3Ubgko6SUeho/5jbiA1czijDLgsfWFBHV + * dWNbFJWcHwHP2NVypw87 + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02DE1\x150\x13\x06\x03U\x04\n\x13\x0cD-Trust GmbH1\"0 \x06\x03U\x04\x03\x13\x19D-TRUST BR Root CA 1 2020"), + subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\"\x03b\x00\x04\xc6\xcb\xc7(\xd1\xfb\x84\xf5\x9a\xefB\x14 \xe1Cknu\xad\xfc+\x03\x84\xd4v\x93%\xd7Y;Aek\x1e\xe64*\xbbt\xf6\x12\xce\xe8m\xe7\xab\xe4\xe2\xe8t\xc9\x18\xb4\x91\xd4bd\xdb\x7f\xa3\x06\xf1\x88\x18j\x90\"<\xbc\xfe\x13\xf0\x87\x14{\xf6\xe4\x1f\x8e\xd4\xe4Q\xc6\x11gF\x08Q\xcb\x86\x14T?\xbc3\xfe~l\x9c\xff\x16\x9d\x18\xbdQ\x8e5\xa6\xa7f\xc8rg\xdb!f\xb1\xd4\x9bx\x03\xc0P:\xe8\xcc\xf0\xdc\xbc\x9eL\xfe\xaf\x05\x965\x1fWZ\xb7\xff\xce\xf9=\xb7,\xb6\xf6T\xdd\xc8\xe7\x12:M\xaeL\x8a\xb7\\\x9a\xb4\xb7 =\xca\x7f\"4\xae~;hf\x01D\xe7\x01NFS\x9b3`\xf7\x94\xbeS7\x90sC\xf32\xc3S\xef\xdb\xaa\xfetNi\xc7k\x8c`\x93\xde\xc4\xc7\x0c\xdf\xe12\xae\xcc\x93;Qx\x95g\x8b\xee=V\xfe\x0c\xd0i\x0f\x1b\x0f\xf3%&k3m\xf7nG\xfasC\xe5~\x0e\xa5f\xb1)|2\x84cU\x89\xc4\r\xc1\x93T0\x19\x13\xac\xd3}7\xa7\xeb]:l5\\\xdbA\xd7\x12\xda\xa9I\x0b\xdf\xd8\x80\x8a\t\x93b\x8e\xb5f\xcf%\x88\xcd\x84\xb8\xb1?\xa49\x0f\xd9\x02\x9e\xeb\x12L\x95|\xf3k\x05\xa9^\x16\x83\xcc\xb8g\xe2\xe8\x13\x9d\xcc[\x82\xd3L\xb3\xed[\xff\xde\xe5s\xac#;-\x00\xbf5Ut\tI\xd8IX\x1a\x7f\x926\xe6Q\x92\x0e\xf3&}\x1cM\x17\xbc\xc9\xecC&\xd0\xbfA_@\xa9DD\xf4\x99\xe7W\x87\x9eP\x1fWT\xa8>\xfdtc/\xb1Pe\t\xe6XB.C\x1aL\xb4\xf0%GY\xfa\x04\x1e\x93\xd4&FJP\x81\xb2\xde\xbex\xb7\xfcg\x15\xe1\xc9W\x84\x1e\x0fc\xd6\xe9b\xba\xd6_U.\xea\\\xc6(\x08\x04%9\xb8\x0e+\xa9\xf2L\x97\x1c\x07?\rR\xf5\xed\xef/\x82\x0f\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: O=FNMT-RCM OU=AC RAIZ FNMT-RCM + * Subject: O=FNMT-RCM OU=AC RAIZ FNMT-RCM + * Label: "AC RAIZ FNMT-RCM" + * Serial: 485876308206448804701554682760554759 + * SHA256 Fingerprint: eb:c5:57:0c:29:01:8c:4d:67:b1:aa:12:7b:af:12:f7:03:b4:61:1e:bc:17:b7:da:b5:57:38:94:17:9b:93:fa + * -----BEGIN CERTIFICATE----- + * MIIFgzCCA2ugAwIBAgIPXZONMGc2yAYdGsdUhGkHMA0GCSqGSIb3DQEBCwUAMDsx + * CzAJBgNVBAYTAkVTMREwDwYDVQQKDAhGTk1ULVJDTTEZMBcGA1UECwwQQUMgUkFJ + * WiBGTk1ULVJDTTAeFw0wODEwMjkxNTU5NTZaFw0zMDAxMDEwMDAwMDBaMDsxCzAJ + * BgNVBAYTAkVTMREwDwYDVQQKDAhGTk1ULVJDTTEZMBcGA1UECwwQQUMgUkFJWiBG + * Tk1ULVJDTTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBALpxgHpMhm5/ + * yBNtwMZ9HACXjywMI7sQmkCpGreHiPibVmr75nuOi5KOpyVdWRHbNi63URcfqQgf + * BBckWKo3Shjf5TnUV/3XwSyRAZHiItQDwFj8d0fsjz50Q7qsNI1NOHZnjrDIbzAz + * WHFctPVrbtQBULgTfmxKo0nRIBnuvMApGGWn3v7v3QqQIecaZ5JCEJhfTzC8PhxF + * tBDXaEAUwED653cXeuYLj2VbPNmaUtu1vZ5Gzz3rkQUCwJaydkxNEJY7kvqcfw+Z + * 374jNUUeAlz+taibmSXaXvMiwzn15Cou08YfxGyqxRxqAQVKL9LFwag0Jl1mpdIC + * IfkYtwb1TplvqKtMUejPUBjFd8g5CSxJkjKZqLsXF3mwWsXmo8RZZUc1g16p6DUL + * mbvkzSDGm0oGObVo/CK67lWMK07q87Hj/LaZmtVC+nFNCM+HHmpxffnTtOmlcYF7 + * wk5HlqX2doWjKI/pgG6BU6VtX7hI+cL5NqYuSf+4lsKMB7ObiFj86xsc3i1w4peS + * MKGJ47xVqCfWS+2QrYv6YyVZLag13cqXM7zlzced0ezvXg5KkAYmY6252TUtB7p2 + * ZSysV4999AeU14ECll2jB0nVetBX+RvnU0Z1qrB5QstocQjpYL05ac70r8NWQMet + * UqIJ5G+GR4of6ygnXYMgrwTJbFaai0b1AgMBAAGjgYMwgYAwDwYDVR0TAQH/BAUw + * AwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFPd9xf3E6Jobd2Sn9R2gzL+H + * YJptMD4GA1UdIAQ3MDUwMwYEVR0gADArMCkGCCsGAQUFBwIBFh1odHRwOi8vd3d3 + * LmNlcnQuZm5tdC5lcy9kcGNzLzANBgkqhkiG9w0BAQsFAAOCAgEAB5BK3/MjTvDD + * nFFlm5wioooMhfNzKWtN/gHiqQxjAb8EZ6WdmF/9ARP67Jpi6Yb+tmLSbkyU+8B1 + * RXxlDPiyN8+sD8+Nb/kZ94/sHvJwnvDKuO+3/3Y3dlv2bojzr2IyIpMNOmqOFGYM + * LVN0V2Ue1bLdI4E7pWYjJ2cJj+F3qkPNZVEI7VFY/uY5+ctHhKQV8Xa7pO6kO8Rf + * 77IzlhEYt8llvhjho6Tc+hj507wTmzl6NLrTQfv6MooqtyuGC2mDOL7Nii4LcK2N + * JpLuHvUBKwrZ1pebbuCoGRw6IYsMHkCtA+fdZn71uSANA+iW+YJF1DngoABd15jm + * fZ5nc8OaKveri6E6FO80vFIOiZiaBECEHX5FaZNXzuvO+FB8TxxuBEOb+dY7Ixjp + * 6o7RTUaN8Tvkasq6+yO3m/qZASlaWFot4/nUbQ4mrcFuNLwy+AwF+mWj2zs3gyLp + * 1txyM/1d8iC9djwj2ij3+RvrWWTV3F9yfiD8zYm1kGdNYno/Tq0dwzn+evQoFt9B + * 9kiABdcPUXmsEKvU7ANm5mqwujGSQkBqvjrTcuFqN1W8rB2Vt2lh8kORdOag0wok + * RqEIr9baRRmW1FMdW4R58MD3R++Lj8UGrp1MYp3/RgT408m2ECVAdf4WqslKYIYv + * uu8wd+RU4riEmViAqhOLUTpPSPaLtrM= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02ES1\x110\x0f\x06\x03U\x04\n\x0c\x08FNMT-RCM1\x190\x17\x06\x03U\x04\x0b\x0c\x10AC RAIZ FNMT-RCM"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xbaq\x80zL\x86n\x7f\xc8\x13m\xc0\xc6}\x1c\x00\x97\x8f,\x0c#\xbb\x10\x9a@\xa9\x1a\xb7\x87\x88\xf8\x9bVj\xfb\xe6{\x8e\x8b\x92\x8e\xa7%]Y\x11\xdb6.\xb7Q\x17\x1f\xa9\x08\x1f\x04\x17$X\xaa7J\x18\xdf\xe59\xd4W\xfd\xd7\xc1,\x91\x01\x91\xe2\"\xd4\x03\xc0X\xfcwG\xec\x8f>tC\xba\xac4\x8dM8vg\x8e\xb0\xc8o03Xq\\\xb4\xf5kn\xd4\x01P\xb8\x13~lJ\xa3I\xd1 \x19\xee\xbc\xc0)\x18e\xa7\xde\xfe\xef\xdd\n\x90!\xe7\x1ag\x92B\x10\x98_O0\xbc>\x1cE\xb4\x10\xd7h@\x14\xc0@\xfa\xe7w\x17z\xe6\x0b\x8fe[<\xd9\x9aR\xdb\xb5\xbd\x9eF\xcf=\xeb\x91\x05\x02\xc0\x96\xb2vLM\x10\x96;\x92\xfa\x9c\x7f\x0f\x99\xdf\xbe#5E\x1e\x02\\\xfe\xb5\xa8\x9b\x99%\xda^\xf3\"\xc39\xf5\xe4*.\xd3\xc6\x1f\xc4l\xaa\xc5\x1cj\x01\x05J/\xd2\xc5\xc1\xa84&]f\xa5\xd2\x02!\xf9\x18\xb7\x06\xf5N\x99o\xa8\xabLQ\xe8\xcfP\x18\xc5w\xc89\t,I\x922\x99\xa8\xbb\x17\x17y\xb0Z\xc5\xe6\xa3\xc4YeG5\x83^\xa9\xe85\x0b\x99\xbb\xe4\xcd \xc6\x9bJ\x069\xb5h\xfc\"\xba\xeeU\x8c+N\xea\xf3\xb1\xe3\xfc\xb6\x99\x9a\xd5B\xfaqM\x08\xcf\x87\x1ejq}\xf9\xd3\xb4\xe9\xa5q\x81{\xc2NG\x96\xa5\xf6v\x85\xa3(\x8f\xe9\x80n\x81S\xa5m_\xb8H\xf9\xc2\xf96\xa6.I\xff\xb8\x96\xc2\x8c\x07\xb3\x9b\x88X\xfc\xeb\x1b\x1c\xde-p\xe2\x97\x920\xa1\x89\xe3\xbcU\xa8\'\xd6K\xed\x90\xad\x8b\xfac%Y-\xa85\xdd\xca\x973\xbc\xe5\xcd\xc7\x9d\xd1\xec\xef^\x0eJ\x90\x06&c\xad\xb9\xd95-\x07\xbave,\xacW\x8f}\xf4\x07\x94\xd7\x81\x02\x96]\xa3\x07I\xd5z\xd0W\xf9\x1b\xe7SFu\xaa\xb0yB\xcbhq\x08\xe9`\xbd9i\xce\xf4\xaf\xc3V@\xc7\xadR\xa2\t\xe4o\x86G\x8a\x1f\xeb(\']\x83 \xaf\x04\xc9lV\x9a\x8bF\xf5\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=Buypass Class 3 Root CA O=Buypass AS-983163327 + * Subject: CN=Buypass Class 3 Root CA O=Buypass AS-983163327 + * Label: "Buypass Class 3 Root CA" + * Serial: 2 + * SHA256 Fingerprint: ed:f7:eb:bc:a2:7a:2a:38:4d:38:7b:7d:40:10:c6:66:e2:ed:b4:84:3e:4c:29:b4:ae:1d:5b:93:32:e6:b2:4d + * -----BEGIN CERTIFICATE----- + * MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEd + * MBsGA1UECgwUQnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3Mg + * Q2xhc3MgMyBSb290IENBMB4XDTEwMTAyNjA4Mjg1OFoXDTQwMTAyNjA4Mjg1OFow + * TjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1eXBhc3MgQVMtOTgzMTYzMzI3MSAw + * HgYDVQQDDBdCdXlwYXNzIENsYXNzIDMgUm9vdCBDQTCCAiIwDQYJKoZIhvcNAQEB + * BQADggIPADCCAgoCggIBAKXaCpUWUOOV8l6ddjEGMnqb8RB2uACatVI2zSRHsJ8Y + * ZLya9vrVediQYkwiL944PdbgqOkcLNt4EemOaFEVcsfzM4fkoF0LXOBXByow9c3E + * N3coTRiR5r/VUv1xLXA+58bEiuPwKAv0dpihi4dVsjoT/Lc+JzeOIuOoTyrvYLs9 + * tznDDgFHmV0ST9tD+leh7fmdvhFHJlsTmKtdFoqwNxxXnUX/iJY2v7vKB3tvh2PX + * 0DJq1l1sDPGzbjniazEuOQAnFN44wOwZZoYS6J1yFhNkUsepNxz9gjDthBgd9K5c + * /3ATAOux9TN6S9ZV+AWNS2mw9bMoNlwUxFFzTWsL8TQH2xc519woe2v1n/MuwU8X + * KhDzzMro6/1rqy6any2CbgTUUgGTLT2G/H783+9CHaZr77kgxve9oKeV/afmiSTY + * zIw0bOIjL9kSGiG5VZFvC5F5GQytQIgLcOJ60g7YaEi7ghM5EFjp2CoHxhLbWNvS + * O1UQRwUVZ2J+GGOmRj8JDlQyXr8NYnon74Do29lLBlo3WiXQCBJ31G8JUJc9yB3D + * 34xFMFbG02SrZvPAXpacw8Tvw3xrizp5f7NJzz3iiZ+gMEuFuZyUJHmPfWupRWgP + * K9Dx2hzLabjKSWJtyNBjYt1gD1iqj6G8BaVmos8bdrKEZLFMOVLAMLrwjEsCsLa3 + * AgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFEe4zf/lb+74suwv + * Tg75JbCOPGvDMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsFAAOCAgEAACAj + * QTUEkMJAYmDv4jVM1z+s4jSQuKFvdvoWFqRINyzpkMLyPPgKn9iB5btb2iUspKdV + * cSQy9sgL8rxq+JOssgfCX5/bzMiKqr5qb+FJEMwx14C7u8jYog5kV+qi9cKpMRXS + * IGrs/CIBKM+GuIAeqcwRpTzyFrNHnfzSgCHEy9BHcEGhyoMZCCxt8l13nIoUE9Q2 + * HJLw5QY33KbmkJs4j1xrG0aGQ0JfPgEHU1RdZX33inOhmlRaHylDFCfChQ+1iHsa + * O5S3HWCntZznKWlXWpuTekMwGwPXYshApqr8ZORK15FTAaggiG6cX0S5y2CBNOxv + * 033aSF/rtJC8LakcC6wc1aJoIIAE1vyxjy+7SjENSoYc6+I2KSb12tjE8nVhz36u + * dmNKekBlk4f4HoCMhuWG1o8O/FMsYOgWYRqiPkN7zTlgVGr18okmAWiDSKIz6MkE + * kbIRNBE+6tBDGR8Dk5AM/1E9V/RBbuHLoL7ryWPNbczk+DaqaJ3tvV2XcEQNtg41 + * 3OEMXbugUZTLfhbrES+jkkXITHHZvMmZUldGL1DPvTVp9D0VzgalLA8+9oG6lLvD + * u79leNKGef9JOxqDDPDeeOzI8k1MGt6CKfjBWtrt7uYnXuhF0J0cUahoq0Tj0Itq + * 4/g7u9xN12TyUb7mqqta6THuBrxzvxNiCp/HuZc= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02NO1\x1d0\x1b\x06\x03U\x04\n\x0c\x14Buypass AS-9831633271 0\x1e\x06\x03U\x04\x03\x0c\x17Buypass Class 3 Root CA"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xa5\xda\n\x95\x16P\xe3\x95\xf2^\x9dv1\x062z\x9b\xf1\x10v\xb8\x00\x9a\xb5R6\xcd$G\xb0\x9f\x18d\xbc\x9a\xf6\xfa\xd5y\xd8\x90bL\"/\xde8=\xd6\xe0\xa8\xe9\x1c,\xdbx\x11\xe9\x8ehQ\x15r\xc7\xf33\x87\xe4\xa0]\x0b\\\xe0W\x07*0\xf5\xcd\xc47w(M\x18\x91\xe6\xbf\xd5R\xfdq-p>\xe7\xc6\xc4\x8a\xe3\xf0(\x0b\xf4v\x98\xa1\x8b\x87U\xb2:\x13\xfc\xb7>\'7\x8e\"\xe3\xa8O*\xef`\xbb=\xb79\xc3\x0e\x01G\x99]\x12O\xdbC\xfaW\xa1\xed\xf9\x9d\xbe\x11G&[\x13\x98\xab]\x16\x8a\xb07\x1cW\x9dE\xff\x88\x966\xbf\xbb\xca\x07{o\x87c\xd7\xd02j\xd6]l\x0c\xf1\xb3n9\xe2k1.9\x00\'\x14\xde8\xc0\xec\x19f\x86\x12\xe8\x9dr\x16\x13dR\xc7\xa97\x1c\xfd\x820\xed\x84\x18\x1d\xf4\xae\\\xffp\x13\x00\xeb\xb1\xf53zK\xd6U\xf8\x05\x8dKi\xb0\xf5\xb3(6\\\x14\xc4QsMk\x0b\xf14\x07\xdb\x179\xd7\xdc({k\xf5\x9f\xf3.\xc1O\x17*\x10\xf3\xcc\xca\xe8\xeb\xfdk\xab.\x9a\x9f-\x82n\x04\xd4R\x01\x93-=\x86\xfc~\xfc\xdf\xefB\x1d\xa6k\xef\xb9 \xc6\xf7\xbd\xa0\xa7\x95\xfd\xa7\xe6\x89$\xd8\xcc\x8c4l\xe2#/\xd9\x12\x1a!\xb9U\x91o\x0b\x91y\x19\x0c\xad@\x88\x0bp\xe2z\xd2\x0e\xd8hH\xbb\x82\x139\x10X\xe9\xd8*\x07\xc6\x12\xdbX\xdb\xd2;U\x10G\x05\x15gb~\x18c\xa6F?\t\x0eT2^\xbf\rbz\'\xef\x80\xe8\xdb\xd9K\x06Z7Z%\xd0\x08\x12w\xd4o\tP\x97=\xc8\x1d\xc3\xdf\x8cE0V\xc6\xd3d\xabf\xf3\xc0^\x96\x9c\xc3\xc4\xef\xc3|k\x8b:y\x7f\xb3I\xcf=\xe2\x89\x9f\xa00K\x85\xb9\x9c\x94$y\x8f}k\xa9Eh\x0f+\xd0\xf1\xda\x1c\xcbi\xb8\xcaIbm\xc8\xd0cb\xdd`\x0fX\xaa\x8f\xa1\xbc\x05\xa5f\xa2\xcf\x1bv\xb2\x84d\xb1L9R\xc00\xba\xf0\x8cK\x02\xb0\xb6\xb7\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=D-TRUST Root Class 3 CA 2 EV 2009 O=D-Trust GmbH + * Subject: CN=D-TRUST Root Class 3 CA 2 EV 2009 O=D-Trust GmbH + * Label: "D-TRUST Root Class 3 CA 2 EV 2009" + * Serial: 623604 + * SHA256 Fingerprint: ee:c5:49:6b:98:8c:e9:86:25:b9:34:09:2e:ec:29:08:be:d0:b0:f3:16:c2:d4:73:0c:84:ea:f1:f3:d3:48:81 + * -----BEGIN CERTIFICATE----- + * MIIEQzCCAyugAwIBAgIDCYP0MA0GCSqGSIb3DQEBCwUAMFAxCzAJBgNVBAYTAkRF + * MRUwEwYDVQQKDAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBD + * bGFzcyAzIENBIDIgRVYgMjAwOTAeFw0wOTExMDUwODUwNDZaFw0yOTExMDUwODUw + * NDZaMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQKDAxELVRydXN0IEdtYkgxKjAoBgNV + * BAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAwOTCCASIwDQYJKoZI + * hvcNAQEBBQADggEPADCCAQoCggEBAJnxhDRwui+3MKCOvXwEz75ivJn9gpfSegpn + * ljgJ9hBOlSJzmY3aFS3nBfwZcyK3jpgAvDw9rKFs+9Z5JUut8Mxk2og+KbgPCdM0 + * 3TP1YtHhzRnp7hhPTFiu4h7WDFsVWtg6uMQYZB7jM7K1iXdODL/ZlGsTl28So/6Z + * qQTMFexgaDbtCHu39b+T7WYxg4zGcTSHThfqr4uRjRxWQa4iN1438h3Z0S0NL2lR + * p75mpoo6Kr3HGrHhFPC+Oh25z1uxav60sUYgovseO3Dvk5h9jHOW8sXvhXCtKSb8 + * HgQ+HKDYD8tSg2J87otTlZCpV6LqYQXY+U3EJ/pure3511H3a6UCAwEAAaOCASQw + * ggEgMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFNOUikxiEyoZLsyvcop9Ntea + * HNxnMA4GA1UdDwEB/wQEAwIBBjCB3QYDVR0fBIHVMIHSMIGHoIGEoIGBhn9sZGFw + * Oi8vZGlyZWN0b3J5LmQtdHJ1c3QubmV0L0NOPUQtVFJVU1QlMjBSb290JTIwQ2xh + * c3MlMjAzJTIwQ0ElMjAyJTIwRVYlMjAyMDA5LE89RC1UcnVzdCUyMEdtYkgsQz1E + * RT9jZXJ0aWZpY2F0ZXJldm9jYXRpb25saXN0MEagRKBChkBodHRwOi8vd3d3LmQt + * dHJ1c3QubmV0L2NybC9kLXRydXN0X3Jvb3RfY2xhc3NfM19jYV8yX2V2XzIwMDku + * Y3JsMA0GCSqGSIb3DQEBCwUAA4IBAQA07XtaPKSUiO8aEXUHL7P+PPoeUSbrh/Yp + * 3uDx1MYkCenBz1UbtDDZzhr+BlGmFaQt77JLvyAoJUnRpjZ3NOhk31KxEcdzes05 + * nsKtjHEh8lprr988TlWvsoRlFIm5d8sqMb7Po23Pb0iUMkZv53GMoKaEGTcH8gNF + * CSuGdXzfX2lXANtu2KZyIktQ1HWYVt+3GP9DQ1CuekR78HlR10M9p9OB0/DJT7na + * xpeG0ILD5EJt/rDiZE4OJudANCa1CInXCGNjOCd1HjPqbqjdn5lPdE2BiYBL3ZqX + * KVwvvoFBuYz/6n1gBp7N1z3TLqMVvKjmJuVvw9y4AyHqnxbxLFS1 + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02DE1\x150\x13\x06\x03U\x04\n\x0c\x0cD-Trust GmbH1*0(\x06\x03U\x04\x03\x0c!D-TRUST Root Class 3 CA 2 EV 2009"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x01\x0f\x000\x82\x01\n\x02\x82\x01\x01\x00\x99\xf1\x844p\xba/\xb70\xa0\x8e\xbd|\x04\xcf\xbeb\xbc\x99\xfd\x82\x97\xd2z\ng\x968\t\xf6\x10N\x95\"s\x99\x8d\xda\x15-\xe7\x05\xfc\x19s\"\xb7\x8e\x98\x00\xbc<=\xac\xa1l\xfb\xd6y%K\xad\xf0\xccd\xda\x88>)\xb8\x0f\t\xd34\xdd3\xf5b\xd1\xe1\xcd\x19\xe9\xee\x18OLX\xae\xe2\x1e\xd6\x0c[\x15Z\xd8:\xb8\xc4\x18d\x1e\xe33\xb2\xb5\x89wN\x0c\xbf\xd9\x94k\x13\x97o\x12\xa3\xfe\x99\xa9\x04\xcc\x15\xec`h6\xed\x08{\xb7\xf5\xbf\x93\xedf1\x83\x8c\xc6q4\x87N\x17\xea\xaf\x8b\x91\x8d\x1cVA\xae\"7^7\xf2\x1d\xd9\xd1-\r/iQ\xa7\xbef\xa6\x8a:*\xbd\xc7\x1a\xb1\xe1\x14\xf0\xbe:\x1d\xb9\xcf[\xb1j\xfe\xb4\xb1F \xa2\xfb\x1e;p\xef\x93\x98}\x8cs\x96\xf2\xc5\xef\x85p\xad)&\xfc\x1e\x04>\x1c\xa0\xd8\x0f\xcbR\x83b|\xee\x8bS\x95\x90\xa9W\xa2\xeaa\x05\xd8\xf9M\xc4\'\xfan\xad\xed\xf9\xd7Q\xf7k\xa5\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=OISTE Server Root ECC G1 O=OISTE Foundation + * Subject: CN=OISTE Server Root ECC G1 O=OISTE Foundation + * Label: "OISTE Server Root ECC G1" + * Serial: 47819833811561661340092227008453318557 + * SHA256 Fingerprint: ee:c9:97:c0:c3:0f:21:6f:7e:3b:8b:30:7d:2b:ae:42:41:2d:75:3f:c8:21:9d:af:d1:52:0b:25:72:85:0f:49 + * -----BEGIN CERTIFICATE----- + * MIICNTCCAbqgAwIBAgIQI/nD1jWvjyhLH/BU6n6XnTAKBggqhkjOPQQDAzBLMQsw + * CQYDVQQGEwJDSDEZMBcGA1UECgwQT0lTVEUgRm91bmRhdGlvbjEhMB8GA1UEAwwY + * T0lTVEUgU2VydmVyIFJvb3QgRUNDIEcxMB4XDTIzMDUzMTE0NDIyOFoXDTQ4MDUy + * NDE0NDIyN1owSzELMAkGA1UEBhMCQ0gxGTAXBgNVBAoMEE9JU1RFIEZvdW5kYXRp + * b24xITAfBgNVBAMMGE9JU1RFIFNlcnZlciBSb290IEVDQyBHMTB2MBAGByqGSM49 + * AgEGBSuBBAAiA2IABBcv+hK8rBjzCvRE1nZCnrPoH7d5qVi2+GXROiFPqOujvqQy + * cvO2Ackr/XeFblPdreqqLiWStukhEaivtUwL85Zgmjvn6hp4LrQ95SjeHIC6XG4N + * 2xml4z+cKrhAS93mT6NjMGEwDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSMEGDAWgBQ3 + * TYhlz/w9itWj8UnATgwQb0K0nDAdBgNVHQ4EFgQUN02IZc/8PYrVo/FJwE4MEG9C + * tJwwDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMDA2kAMGYCMQCpKjAd0MKfkFFR + * QD6VVCHNFmb3U2wIFjnQEnx/Yxvf4zgAOdktUyBFCxxgZzFDJe0CMQCSia7pXGKD + * YmH5LVerVrkR3SW+ak5KGoJr3M/TvEqzPNcum9v4KGm8ay3sMaE641c= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02CH1\x190\x17\x06\x03U\x04\n\x0c\x10OISTE Foundation1!0\x1f\x06\x03U\x04\x03\x0c\x18OISTE Server Root ECC G1"), + subject_public_key_info: Der::from_slice(b"0\x10\x06\x07*\x86H\xce=\x02\x01\x06\x05+\x81\x04\x00\"\x03b\x00\x04\x17/\xfa\x12\xbc\xac\x18\xf3\n\xf4D\xd6vB\x9e\xb3\xe8\x1f\xb7y\xa9X\xb6\xf8e\xd1:!O\xa8\xeb\xa3\xbe\xa42r\xf3\xb6\x01\xc9+\xfdw\x85nS\xdd\xad\xea\xaa.%\x92\xb6\xe9!\x11\xa8\xaf\xb5L\x0b\xf3\x96`\x9a;\xe7\xea\x1ax.\xb4=\xe5(\xde\x1c\x80\xba\\n\r\xdb\x19\xa5\xe3?\x9c*\xb8@K\xdd\xe6O"), + name_constraints: None + }, + + /* + * Issuer: CN=Telekom Security TLS RSA Root 2023 O=Deutsche Telekom Security GmbH + * Subject: CN=Telekom Security TLS RSA Root 2023 O=Deutsche Telekom Security GmbH + * Label: "Telekom Security TLS RSA Root 2023" + * Serial: 44676229530606711399881795178081572759 + * SHA256 Fingerprint: ef:c6:5c:ad:bb:59:ad:b6:ef:e8:4d:a2:23:11:b3:56:24:b7:1b:3b:1e:a0:da:8b:66:55:17:4e:c8:97:86:46 + * -----BEGIN CERTIFICATE----- + * MIIFszCCA5ugAwIBAgIQIZxULej27HF3+k7ow3BXlzANBgkqhkiG9w0BAQwFADBj + * MQswCQYDVQQGEwJERTEnMCUGA1UECgweRGV1dHNjaGUgVGVsZWtvbSBTZWN1cml0 + * eSBHbWJIMSswKQYDVQQDDCJUZWxla29tIFNlY3VyaXR5IFRMUyBSU0EgUm9vdCAy + * MDIzMB4XDTIzMDMyODEyMTY0NVoXDTQ4MDMyNzIzNTk1OVowYzELMAkGA1UEBhMC + * REUxJzAlBgNVBAoMHkRldXRzY2hlIFRlbGVrb20gU2VjdXJpdHkgR21iSDErMCkG + * A1UEAwwiVGVsZWtvbSBTZWN1cml0eSBUTFMgUlNBIFJvb3QgMjAyMzCCAiIwDQYJ + * KoZIhvcNAQEBBQADggIPADCCAgoCggIBAO01oYGA88tKaVvC+1GDrib94W7zgRJ9 + * cUD/h3VCKSHtgVIs3xLBGYSJwb3FKNXVS2xE1kzbB5ZKVXrKNoIENqil/Cf2SfHV + * cp6R+SPWcHu79ZvB7JPPGeplfohwoHP89v+1VmLhc2o0mD6CuKyVU/QBoCcHcqMA + * U6DksquDOFczJZSfvkgdmOGjup5czQRxUX11eKvzWarE4GC+j4NSuHUaQTXtvPM6 + * Y+mpFEXX5lLRbtLevOP1Czvm4MS9Q2QTps70mDdsipWol8hHD/BeEIvnHRz+sTug + * BTNoBUGCwQMrAcjnj02r6LX2zWtEtefdi+zqJbQAIldNsLGyMcEWzv/9FIS3R/qy + * 8XDe24tsNlikfLMR0cN3f1+2JeANxdKz+bi4d9s3cXFH42AYTyS2dTd4uaNir73J + * co4vzLuu2+QVUhkHM/tqty1LkCiCc/4YizWN26cEar7qwU02OxY2kTLvtkCJkUPg + * 8qKrBC7m8kwOFjQgrIfBLX7JZkcXFBGk8/ehJImr2BrIoVyxo/eMbcgByU/J7MT8 + * rFEz0ciD0cmfHdRHNCk+y7AO+oMLKFjlKdw/fKifybYKu6boRhYPluV75Gp6SG12 + * mAWl3G0eQh5C2hrgUve1g8Aae3g1LDj1H/1Joy7SWWO/gLCMk3PLNaaZlSJhZQNg + * +y+TS/qanIA7AgMBAAGjYzBhMA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUtqeX + * gj10hZv3PJ+TmpV5dVKMbUcwDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSMEGDAWgBS2 + * p5eCPXSFm/c8n5OalXl1UoxtRzANBgkqhkiG9w0BAQwFAAOCAgEAqMxhpr51nhVQ + * pGv7qHBFfLp+sVr8WyP6Cnf4mHGCDG3gXkaqk/QeoMPhk9tLrbKmXauw1GLLXrtm + * 9S3ul0A8Yute1hTWjOKWi0FpkzXmuZlrYrShF2Y0pmtjxrlO8iLpWA1WQdH6DErw + * M807u20hOq6OcrXDSvvpfeWxm4bu4uB9tPcy/SKE8YXJN3nptT+/XOR0so8RYgDd + * GGah2XsjX/GO1WfoVNpbOms2b/mBsTNHM3dA+VKq3dSDz4V4mZqTuXNnQkYRIer+ + * CqkbGmVps4+uFrb2S1ayLfmlyOw7YqPta9BO1UAJpB+Y1zqlklkg5LB9zVtzaL1t + * xKITDmcZuI1CfmwMmm6gJC3VRRvcxAIU/oVbZZfKTpBQCHpCNfnqwmbU+AGuHrS+ + * w6jv/naaoqYfRvaE7fzbzsQCzndILIyy7MMAo+wsVRjBfhnu4S/yrYObnqsZ38aK + * L4x35bcF7DvB7L6Gs4a8wPfc5+pbrrLMtTWGS9DiP7bY+A4A7l3j941Y/8+LN+lj + * X273CXE2whJdV/LItM3z7gLfEdxquVeEHVlNjM7IDiPCtyaaEBRx/pOyiriA8A4Q + * ntOoUAw3gi/q4Iqd4Sw5/7W0cwDk90imc6y/st53BIe0o82bNSQ3+pCTE4FCxpgm + * dTdmQRCsu/WU48IxK63nI1bMNSWSs1A= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02DE1\'0%\x06\x03U\x04\n\x0c\x1eDeutsche Telekom Security GmbH1+0)\x06\x03U\x04\x03\x0c\"Telekom Security TLS RSA Root 2023"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xed5\xa1\x81\x80\xf3\xcbJi[\xc2\xfbQ\x83\xae&\xfd\xe1n\xf3\x81\x12}q@\xff\x87uB)!\xed\x81R,\xdf\x12\xc1\x19\x84\x89\xc1\xbd\xc5(\xd5\xd5KlD\xd6L\xdb\x07\x96JUz\xca6\x82\x046\xa8\xa5\xfc\'\xf6I\xf1\xd5r\x9e\x91\xf9#\xd6p{\xbb\xf5\x9b\xc1\xec\x93\xcf\x19\xeae~\x88p\xa0s\xfc\xf6\xff\xb5Vb\xe1sj4\x98>\x82\xb8\xac\x95S\xf4\x01\xa0\'\x07r\xa3\x00S\xa0\xe4\xb2\xab\x838W3%\x94\x9f\xbeH\x1d\x98\xe1\xa3\xba\x9e\\\xcd\x04qQ}ux\xab\xf3Y\xaa\xc4\xe0`\xbe\x8f\x83R\xb8u\x1aA5\xed\xbc\xf3:c\xe9\xa9\x14E\xd7\xe6R\xd1n\xd2\xde\xbc\xe3\xf5\x0b;\xe6\xe0\xc4\xbdCd\x13\xa6\xce\xf4\x987l\x8a\x95\xa8\x97\xc8G\x0f\xf0^\x10\x8b\xe7\x1d\x1c\xfe\xb1;\xa0\x053h\x05A\x82\xc1\x03+\x01\xc8\xe7\x8fM\xab\xe8\xb5\xf6\xcdkD\xb5\xe7\xdd\x8b\xec\xea%\xb4\x00\"WM\xb0\xb1\xb21\xc1\x16\xce\xff\xfd\x14\x84\xb7G\xfa\xb2\xf1p\xde\xdb\x8bl6X\xa4|\xb3\x11\xd1\xc3w\x7f_\xb6%\xe0\r\xc5\xd2\xb3\xf9\xb8\xb8w\xdb7qqG\xe3`\x18O$\xb6u7x\xb9\xa3b\xaf\xbd\xc9r\x8e/\xcc\xbb\xae\xdb\xe4\x15R\x19\x073\xfbj\xb7-K\x90(\x82s\xfe\x18\x8b5\x8d\xdb\xa7\x04j\xbe\xea\xc1M6;\x166\x912\xef\xb6@\x89\x91C\xe0\xf2\xa2\xab\x04.\xe6\xf2L\x0e\x164 \xac\x87\xc1-~\xc9fG\x17\x14\x11\xa4\xf3\xf7\xa1$\x89\xab\xd8\x1a\xc8\xa1\\\xb1\xa3\xf7\x8cm\xc8\x01\xc9O\xc9\xec\xc4\xfc\xacQ3\xd1\xc8\x83\xd1\xc9\x9f\x1d\xd4G4)>\xcb\xb0\x0e\xfa\x83\x0b(X\xe5)\xdc?|\xa8\x9f\xc9\xb6\n\xbb\xa6\xe8F\x16\x0f\x96\xe5{\xe4jzHmv\x98\x05\xa5\xdcm\x1eB\x1eB\xda\x1a\xe0R\xf7\xb5\x83\xc0\x1a{x5,8\xf5\x1f\xfdI\xa3.\xd2Yc\xbf\x80\xb0\x8c\x93s\xcb5\xa6\x99\x95\"ae\x03`\xfb/\x93K\xfa\x9a\x9c\x80;\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=HiPKI Root CA - G1 O=Chunghwa Telecom Co., Ltd. + * Subject: CN=HiPKI Root CA - G1 O=Chunghwa Telecom Co., Ltd. + * Label: "HiPKI Root CA - G1" + * Serial: 60966262342023497858655262305426234976 + * SHA256 Fingerprint: f0:15:ce:3c:c2:39:bf:ef:06:4b:e9:f1:d2:c4:17:e1:a0:26:4a:0a:94:be:1f:0c:8d:12:18:64:eb:69:49:cc + * -----BEGIN CERTIFICATE----- + * MIIFajCCA1KgAwIBAgIQLd2szmKXlKFD6LDNdmpeYDANBgkqhkiG9w0BAQsFADBP + * MQswCQYDVQQGEwJUVzEjMCEGA1UECgwaQ2h1bmdod2EgVGVsZWNvbSBDby4sIEx0 + * ZC4xGzAZBgNVBAMMEkhpUEtJIFJvb3QgQ0EgLSBHMTAeFw0xOTAyMjIwOTQ2MDRa + * Fw0zNzEyMzExNTU5NTlaME8xCzAJBgNVBAYTAlRXMSMwIQYDVQQKDBpDaHVuZ2h3 + * YSBUZWxlY29tIENvLiwgTHRkLjEbMBkGA1UEAwwSSGlQS0kgUm9vdCBDQSAtIEcx + * MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA9B5/UnMyDHPkvRN0o9Qw + * qNCuS9i233VHZvR85zkEHmpwINJaR3JnVfSl6J3VHiGh8Ge6zCFovkRTv4354twv + * Vcg3Px+kwJyz5HdcoEb+d/oaoDjq7Zpy3iu9lFc6uux55199QmQ5eiY29yTw1S+6 + * lZgRZq2XNdZ1AYDgr/SEYYwNHl98h5ZeQa/rh+r4XfEuiAU+TCK72h8q3VJGZDnz + * Qs7ZngyzsHeXZJzA9KMuH5UHsBffMNsAGJZMoYFL3QRtU6M9/Aes1MU3guvklQgZ + * KILSQjqj2FPseYlgSGDIcpJQ3AOPgz+yQlda22rpEZfdhSi8MEyr48KxRURHH+CK + * FgeW0iEPU8DtqX7UTuybCeyvQqww1r/REEXgphaypcXTT3OUM3ECoWqj1jOXTyFj + * HluP2cFeRXF3D4FdXyGarYPM+l7WjSNfGz1BryB1ZlpK9p/7qxj3ccC2HTHsOyDr + * y+K49a6SsvfhhEvyovKTmiKe0xRvNlS9H15ZFblzqMF8b3ti6RZsR1pl8w4Rm0bZ + * /W3c1pzAtH2lsN0/Vm+h+fbkEkj9Bn8SV7apI09bA8PgcSojt/ewsTu8mL3WmKgM + * a/aOEmem8rJY5AIJEzypuxC00jBF8ez3ABHfZfjcK0NVvxaXxA/VLGGEqnKG/uY6 + * fsI/fe78LxQ+5oXdUG+3Se0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAdBgNV + * HQ4EFgQU8ncX+l6o/vY9cdVouslGDDjYr7AwDgYDVR0PAQH/BAQDAgGGMA0GCSqG + * SIb3DQEBCwUAA4ICAQBQUfB13HAE4/+qddRxosuej6ip0691x1TPOhwEmSKsxBHi + * 7zNKpiMdDg1H2DfHb680f0+BazVP6XKlMeJ45/dOlBhbQH3PayFUhuaVevvGyuqc + * SE5XCV0vrPSltJczWNWseanMX/mF+lLFjfiRFOs6DRfQUsJ748JzjkZ4Bjgs6Fza + * ZsT0pPBWGTMpWmWSBUdGSquEwx4noR8RkpkndZMPvDY7l1ePJlsMu5wP1G4wB9Tc + * XzZoZjmDlicmisjEOf6aIW/Vcobpf2Lll07QJNBAsNB1CI69aO4I1258EHBGG3zg + * iLKecoaZAeO/n0kZtCW+VmWuF2PlHt/o/0elv+EmBYTksMCv5wiZqAxeJoBF1Pho + * L5aPruJKHJwWDBNvOIf2u8g0X5IDUXlwpt/L9ZlNec1OvFefQ05rLisY+GpzjLrF + * Ne85akEez3GoorKGB1s6yeHvP2UEgEcyRHCVTjFnanRbEEV16rCf0OY1/k6fi8wr + * kkVbbiVghUbN0aqwdmaTd5a+g744tiROJgvM7XpWGuDpWsZkrUx6AEhEL7lAuxM+ + * vhV4nYWBSipX3tUZQ9rbyltHhoMLP7YNdnhzeSJesYAfz77RP1YQmCuVh6EfnWQU + * YDksswBVLuT1sw5XxJFBAJw/6KXf6vb/yPCtbVKoF6ubYfwSUTXkJf2vqmqGOQ== + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02TW1#0!\x06\x03U\x04\n\x0c\x1aChunghwa Telecom Co., Ltd.1\x1b0\x19\x06\x03U\x04\x03\x0c\x12HiPKI Root CA - G1"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xf4\x1e\x7fRs2\x0cs\xe4\xbd\x13t\xa3\xd40\xa8\xd0\xaeK\xd8\xb6\xdfuGf\xf4|\xe79\x04\x1ejp \xd2ZGrgU\xf4\xa5\xe8\x9d\xd5\x1e!\xa1\xf0g\xba\xcc!h\xbeDS\xbf\x8d\xf9\xe2\xdc/U\xc87?\x1f\xa4\xc0\x9c\xb3\xe4w\\\xa0F\xfew\xfa\x1a\xa08\xea\xed\x9ar\xde+\xbd\x94W:\xba\xecy\xe7_}Bd9z&6\xf7$\xf0\xd5/\xba\x95\x98\x11f\xad\x975\xd6u\x01\x80\xe0\xaf\xf4\x84a\x8c\r\x1e_|\x87\x96^A\xaf\xeb\x87\xea\xf8]\xf1.\x88\x05>L\"\xbb\xda\x1f*\xddRFd9\xf3B\xce\xd9\x9e\x0c\xb3\xb0w\x97d\x9c\xc0\xf4\xa3.\x1f\x95\x07\xb0\x17\xdf0\xdb\x00\x18\x96L\xa1\x81K\xdd\x04mS\xa3=\xfc\x07\xac\xd4\xc57\x82\xeb\xe4\x95\x08\x19(\x82\xd2B:\xa3\xd8S\xecy\x89`H`\xc8r\x92P\xdc\x03\x8f\x83?\xb2BWZ\xdbj\xe9\x11\x97\xdd\x85(\xbc0L\xab\xe3\xc2\xb1EDG\x1f\xe0\x8a\x16\x07\x96\xd2!\x0fS\xc0\xed\xa9~\xd4N\xec\x9b\t\xec\xafB\xac0\xd6\xbf\xd1\x10E\xe0\xa6\x16\xb2\xa5\xc5\xd3Os\x943q\x02\xa1j\xa3\xd63\x97O!c\x1e[\x8f\xd9\xc1^Eqw\x0f\x81]_!\x9a\xad\x83\xcc\xfa^\xd6\x8d#_\x1b=A\xaf ufZJ\xf6\x9f\xfb\xab\x18\xf7q\xc0\xb6\x1d1\xec; \xeb\xcb\xe2\xb8\xf5\xae\x92\xb2\xf7\xe1\x84K\xf2\xa2\xf2\x93\x9a\"\x9e\xd3\x14o6T\xbd\x1f^Y\x15\xb9s\xa8\xc1|o{b\xe9\x16lGZe\xf3\x0e\x11\x9bF\xd9\xfdm\xdc\xd6\x9c\xc0\xb4}\xa5\xb0\xdd?Vo\xa1\xf9\xf6\xe4\x12H\xfd\x06\x7f\x12W\xb6\xa9#O[\x03\xc3\xe0q*#\xb7\xf7\xb0\xb1;\xbc\x98\xbd\xd6\x98\xa8\x0ck\xf6\x8e\x12g\xa6\xf2\xb2X\xe4\x02\t\x13<\xa9\xbb\x10\xb4\xd20E\xf1\xec\xf7\x00\x11\xdfe\xf8\xdc+CU\xbf\x16\x97\xc4\x0f\xd5,a\x84\xaar\x86\xfe\xe6:~\xc2?}\xee\xfc/\x14>\xe6\x85\xddPo\xb7I\xed\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=Atos TrustedRoot 2011 O=Atos + * Subject: CN=Atos TrustedRoot 2011 O=Atos + * Label: "Atos TrustedRoot 2011" + * Serial: 6643877497813316402 + * SHA256 Fingerprint: f3:56:be:a2:44:b7:a9:1e:b3:5d:53:ca:9a:d7:86:4a:ce:01:8e:2d:35:d5:f8:f9:6d:df:68:a6:f4:1a:a4:74 + * -----BEGIN CERTIFICATE----- + * MIIDdzCCAl+gAwIBAgIIXDPLYixfszIwDQYJKoZIhvcNAQELBQAwPDEeMBwGA1UE + * AwwVQXRvcyBUcnVzdGVkUm9vdCAyMDExMQ0wCwYDVQQKDARBdG9zMQswCQYDVQQG + * EwJERTAeFw0xMTA3MDcxNDU4MzBaFw0zMDEyMzEyMzU5NTlaMDwxHjAcBgNVBAMM + * FUF0b3MgVHJ1c3RlZFJvb3QgMjAxMTENMAsGA1UECgwEQXRvczELMAkGA1UEBhMC + * REUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCVhTuXbyo7LjvPpvMp + * Nb7PGKw+qtn4TaA+Gke5vJrf8v7MPkfoepbCJI419KkM/IL9bcFyYie96mvr54rM + * VD6QUM+A1JX76LWC1BTFtqlVJVfbsVD2sGBkWXppzwO3bw2+yj5vdHLqqjAqc2K+ + * SZFhyBH+DgMq92og3AIVDV4VavzjgsG1xZ1kCWyjWZgHJ8cblithdHFsQ/H3NYkQ + * 4J7sVaE3IqKHBAUsR320HLliKWYoyrfhk/WklAOZuXCFteZI6o1Q/NnezG8HDt0L + * cp2AMBYHlT8oDv3FdU9T1nSatCQujgKRz3bFmx5VdJx4IbHwLfELn8LVlhgf8FQi + * eowHAgMBAAGjfTB7MB0GA1UdDgQWBBSnpQaxLKYJYO7Rl+lwrrw7GWzbITAPBgNV + * HRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFKelBrEspglg7tGX6XCuvDsZbNshMBgG + * A1UdIAQRMA8wDQYLKwYBBAGwLQMEAQEwDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3 + * DQEBCwUAA4IBAQAmdzTblEiGKkGdLD4GkGDEjKwLVLgfuXvTBznk+j57sj1O7Z8j + * vZfza1zv7v1Apt+hk6EKhqzvINB5Ab149xnYJDE0BAGmuhWawyfc2E8PzBhj/5kP + * DpFrdRbhIfzYJsdHt6bPWHJxfrrhTZVHO8mvbaG0weyJ9rQPOLXiZNwlz6bb65pc + * maHFCN795trV1lpFDMS3wrUU77QR/w4VtfX128a961qn8FYiqTxlVMYVqL2Gns2D + * lmh6cYGJ4Qvh6hEbaAjMaZ7snkGeRDImeuKHCnE96+RapNLbxc3G3mB/ufNPRJLv + * KrcYPqcZ2Qt9sTdBQrC6YB3y/gkRsPCHe6ed + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x1e0\x1c\x06\x03U\x04\x03\x0c\x15Atos TrustedRoot 20111\r0\x0b\x06\x03U\x04\n\x0c\x04Atos1\x0b0\t\x06\x03U\x04\x06\x13\x02DE"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x01\x0f\x000\x82\x01\n\x02\x82\x01\x01\x00\x95\x85;\x97o*;.;\xcf\xa6\xf3)5\xbe\xcf\x18\xac>\xaa\xd9\xf8M\xa0>\x1aG\xb9\xbc\x9a\xdf\xf2\xfe\xcc>G\xe8z\x96\xc2$\x8e5\xf4\xa9\x0c\xfc\x82\xfdm\xc1rb\'\xbd\xeak\xeb\xe7\x8a\xccT>\x90P\xcf\x80\xd4\x95\xfb\xe8\xb5\x82\xd4\x14\xc5\xb6\xa9U%W\xdb\xb1P\xf6\xb0`dYzi\xcf\x03\xb7o\r\xbe\xca>otr\xea\xaa0*sb\xbeI\x91a\xc8\x11\xfe\x0e\x03*\xf7j \xdc\x02\x15\r^\x15j\xfc\xe3\x82\xc1\xb5\xc5\x9dd\tl\xa3Y\x98\x07\'\xc7\x1b\x96+atqlC\xf1\xf75\x89\x10\xe0\x9e\xecU\xa17\"\xa2\x87\x04\x05,G}\xb4\x1c\xb9b)f(\xca\xb7\xe1\x93\xf5\xa4\x94\x03\x99\xb9p\x85\xb5\xe6H\xea\x8dP\xfc\xd9\xde\xcco\x07\x0e\xdd\x0br\x9d\x800\x16\x07\x95?(\x0e\xfd\xc5uOS\xd6t\x9a\xb4$.\x8e\x02\x91\xcfv\xc5\x9b\x1eUt\x9cx!\xb1\xf0-\xf1\x0b\x9f\xc2\xd5\x96\x18\x1f\xf0T\"z\x8c\x07\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=BJCA Global Root CA1 O=BEIJING CERTIFICATE AUTHORITY + * Subject: CN=BJCA Global Root CA1 O=BEIJING CERTIFICATE AUTHORITY + * Label: "BJCA Global Root CA1" + * Serial: 113562791157148395269083148143378328608 + * SHA256 Fingerprint: f3:89:6f:88:fe:7c:0a:88:27:66:a7:fa:6a:d2:74:9f:b5:7a:7f:3e:98:fb:76:9c:1f:a7:b0:9c:2c:44:d5:ae + * -----BEGIN CERTIFICATE----- + * MIIFdDCCA1ygAwIBAgIQVW9l47TZkGobCdFsPsBsIDANBgkqhkiG9w0BAQsFADBU + * MQswCQYDVQQGEwJDTjEmMCQGA1UECgwdQkVJSklORyBDRVJUSUZJQ0FURSBBVVRI + * T1JJVFkxHTAbBgNVBAMMFEJKQ0EgR2xvYmFsIFJvb3QgQ0ExMB4XDTE5MTIxOTAz + * MTYxN1oXDTQ0MTIxMjAzMTYxN1owVDELMAkGA1UEBhMCQ04xJjAkBgNVBAoMHUJF + * SUpJTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZMR0wGwYDVQQDDBRCSkNBIEdsb2Jh + * bCBSb290IENBMTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAPFmCL3Z + * xRVhy4QEQaVpN3cdwbB7+sN3SJATcmTRuHyQNZ0YeYjjlwE8R4HyDqKYDZ4/N+AZ + * spDyRhySsTphzvq3Rp4Dhtczbu33RYx2N95ulpH3134rhxfVizXuhJFyV9xgw8O5 + * 58dnJCNPYwpj9mZ9S1WnP3hkSWkSl+BMDdMJoDIwOvqfwPKcxRIqLhy1BDPapDgR + * at7GGPZHOiJBhyL8xIkoVNiMpTAK+BcWyqw3/XmnkRd4OJmtWO2y3syJfQOcs4ll + * 5+M7sSKGjwZteAf9kRJ/sGsciQ35uMt0WwfCyPQ10WRjeulumijWML3mG90Vr4Tq + * nMfK9Q7q8l0ph49pczm+LiRvRSGsxdRpJQaDrXpIhRMsDQa4bHlW/KNnMoH1V6XK + * V0Jp6VwkYe/iMBhORJhVb3rCk9gZtt58R4oRTklH2yiUAguUSiz5EtBP6DF+bHq/ + * pj+bOT0CFqMYs2esWz8sgytnOYFcuX6U1WTdno9uruh8W7TXakdI136z1C2OVnZO + * z2nxbkRs1CTqjSShGL+9V/6pmTW12xB3uD1IutbB5/EjPtffhZ0nPNRAvQoMvfXn + * jSXWgXSHRtQpdaJCbPdzied9v3pKH9MiyRVVz99vfFXQpIsHETdfg6YmV6YBW37+ + * WGgHqel62bno/1Afq8K0wM7o6v0PvY1NuLxxAgMBAAGjQjBAMB0GA1UdDgQWBBTF + * 7+3M2I0hxkjk49cULqcWk+WYATAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQE + * AwIBBjANBgkqhkiG9w0BAQsFAAOCAgEAUoKsITQfI/Ki2Pm4rzc2IInRNwPWaZ+4 + * YRC6ojGYWUfo0Q0lHhVBDOAqVdVXUsv45Mdpox1NcQJeXyFFYEhcCY5JEMEE3Kli + * awLwQ8hOnThJdMkycFRtwUf8jrQ2ntScvd0g1lPJGKm1Vrl2i5VnZu69mP6u775u + * +2D2/VnGKhs/I0qUJDAnyIm860Qkmss9vk/Ves6OF8tiwdneHg56/0OGNFK8YT88 + * X7vZdrRTvJez/opMEi4r89fO4aL/3Xtw+zuhTaRjAv04l5U/BXCga99igUOLtFkN + * SoxUnMW7gZ/NfaXvCyUeOiDbHPwfmGcCCtRzRBPbUYQaVQNW4AB+dAb/OMRyHdOo + * P2gxXdMJxy6MW2Pg6Nwe0uxhHvLe5e/2mXZgLR6UcnHGCyoyx5JO1UbXHfmpGQrI + * +pXObSOYqgs4rZpWDW+N8TEAiMEXnM0ZNjX+VVOg4DwzX5Ze4jLp3zO7Bkqp2IRz + * znfSxqxx4VyjHQy7Ct9f4qNx2No3WqB4K/TUfet27fJhcKVlmtOJNBir+3I+17Q9 + * eVzYH6Eze9mCUAyTF6ps3MKCuwJXNq+YJyo5UOGwifUll35HaBC07HPKs5fRJNz2 + * YqAo07WjuGS3iGJCz51TzZm+ZGiPTx4SSPfSKcOYKMryMguTjClPPGAyzQWWYezy + * r/6zcCwupvI= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02CN1&0$\x06\x03U\x04\n\x0c\x1dBEIJING CERTIFICATE AUTHORITY1\x1d0\x1b\x06\x03U\x04\x03\x0c\x14BJCA Global Root CA1"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xf1f\x08\xbd\xd9\xc5\x15a\xcb\x84\x04A\xa5i7w\x1d\xc1\xb0{\xfa\xc3wH\x90\x13rd\xd1\xb8|\x905\x9d\x18y\x88\xe3\x97\x01\xd7\xdf\x85\x9d\'<\xd4@\xbd\n\x0c\xbd\xf5\xe7\x8d%\xd6\x81t\x87F\xd4)u\xa2Bl\xf7s\x89\xe7}\xbfzJ\x1f\xd3\"\xc9\x15U\xcf\xdfo|U\xd0\xa4\x8b\x07\x117_\x83\xa6&W\xa6\x01[~\xfeXh\x07\xa9\xe9z\xd9\xb9\xe8\xffP\x1f\xab\xc2\xb4\xc0\xce\xe8\xea\xfd\x0f\xbd\x8dM\xb8\xbcq\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=ANF Secure Server Root CA O=ANF Autoridad de Certificacion OU=ANF CA Raiz + * Subject: CN=ANF Secure Server Root CA O=ANF Autoridad de Certificacion OU=ANF CA Raiz + * Label: "ANF Secure Server Root CA" + * Serial: 996390341000653745 + * SHA256 Fingerprint: fb:8f:ec:75:91:69:b9:10:6b:1e:51:16:44:c6:18:c5:13:04:37:3f:6c:06:43:08:8d:8b:ef:fd:1b:99:75:99 + * -----BEGIN CERTIFICATE----- + * MIIF7zCCA9egAwIBAgIIDdPjvGz5a7EwDQYJKoZIhvcNAQELBQAwgYQxEjAQBgNV + * BAUTCUc2MzI4NzUxMDELMAkGA1UEBhMCRVMxJzAlBgNVBAoTHkFORiBBdXRvcmlk + * YWQgZGUgQ2VydGlmaWNhY2lvbjEUMBIGA1UECxMLQU5GIENBIFJhaXoxIjAgBgNV + * BAMTGUFORiBTZWN1cmUgU2VydmVyIFJvb3QgQ0EwHhcNMTkwOTA0MTAwMDM4WhcN + * MzkwODMwMTAwMDM4WjCBhDESMBAGA1UEBRMJRzYzMjg3NTEwMQswCQYDVQQGEwJF + * UzEnMCUGA1UEChMeQU5GIEF1dG9yaWRhZCBkZSBDZXJ0aWZpY2FjaW9uMRQwEgYD + * VQQLEwtBTkYgQ0EgUmFpejEiMCAGA1UEAxMZQU5GIFNlY3VyZSBTZXJ2ZXIgUm9v + * dCBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANvrayvmZFSVgpCj + * cqQZAZ2cC4Ffc0m6p6zzBE57lgvsEeBbphzOG9INgxwruJ4dfkUyYA8H6XdYfp9q + * yGFOtibBTI3/TO80sh9l2Ll49a2pcbnvT1gdpd50IJeh7WhM3pIXS7yr/2WanvtH + * 2Vdy8wmhrnZEE26cLUQ5vPnHO6RYPUG9tMJJo8gN0pcvB2VSAKduyK9o7PQUlrZX + * H1bDOZ8rbeTzPvY1ZNoMHKGESy9LS+IsJJ1tk0DrtSOOMspvRdOoiXsezx76W0OL + * zc2oD2rKDF65nkeP8Nm2CgtYZRczuSPkdxl9y0oukntPLxB3sY0vaJxizOBQ+OyR + * p1RMVwnVdmPF6GUe7m1qzwmd+nxPrWAI/VaZDxUse6mAq4xhj0oHdkLePfTdsiQz + * W7i1o0TJrH93PB0j7IKppuLIBkwC/qxcmZkLLxCKpvR/1Yd0DVlJRfbwcVw5Kda/ + * SiOL9V8BY9KHcyi1Swr1+KuCLH5zJTIdC2MKF4EA/7Z2Xue0sUDKIbvVgFHlSFJn + * LNJhiQcND85Cd8BEc5xEUKDbEAotlRyBr+Qc5RQe8TZBAQIvfXOn3kLMTOmJDVb3 + * n5HUA8ZsyY/b2BzgQJhdZpmYgG4t/wHFzstGH6wCxkPmrqKEPMVOHj1tyRRM4y5B + * u8o5vzY8KhmqQYdOpc5LMnndkEl/AgMBAAGjYzBhMB8GA1UdIwQYMBaAFJxf0Gxj + * o1+TypOYCK2Mh6UsXME3MB0GA1UdDgQWBBScX9BsY6Nfk8qTmAitjIelLFzBNzAO + * BgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOC + * AgEATh65isagmD9uw2nAalxJUqzLK114OMHVVISfk/CHGT0sZonrDUL8zPB1hT+L + * 9IBdeeUXZ701guLyPI59WzbLWoAAKfLOKyzxj6ptBZNscsdW699QIyjlRRA96Gej + * rw5VD5AJYu9LWaL2U/HANeQvwSS9eS9OICI7/RogsKQOLHDtdD+4E5UGUcjohybK + * pFtqFiGS3XNgnhAY3jyB6ugYw3yJ8otQPr0R4hUDqDZ9MwFsSBXXiJCZBMXM5gf0 + * vPSQ7RPi6ovDj6MzD8EpTBNO2hVWcXNyglD2mjN8orGoGjR0ZVzO0eurU+AagNjq + * OknkJjCb5RyKqKkVMoaZkgoQI1YS4PbOTOK7vtuNknMBZi9iPrJyJ0U27U1W45eZ + * /zo1PqVUSlJZS2Db7v54EX9K3BR5YLZrZAPbFYPhor72I5dQ8AkzNqdxliXzuUJ9 + * 2zg/LFis6ELhDtjTO0wugumDLmsx2d1Hhk9tl5EuT+IocTUW0fJz/iUrB0ckYyfI + * +PbZa/wSMVYIwFNCr5zQM378BvAxRAMU8Vjq8moNqRGyg77FGr8H6lnco4g175x2 + * MjxNBiLOFeXdntiP2t7SxDnlF4HPOEfrf4htWRvfn0IUrn7PqLBmZdo3r5+qPeoo + * tt7VMVgWglvquxl1AnMaykgaIZOQCo6ThKd9OyMYkomgjaw= + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x120\x10\x06\x03U\x04\x05\x13\tG632875101\x0b0\t\x06\x03U\x04\x06\x13\x02ES1\'0%\x06\x03U\x04\n\x13\x1eANF Autoridad de Certificacion1\x140\x12\x06\x03U\x04\x0b\x13\x0bANF CA Raiz1\"0 \x06\x03U\x04\x03\x13\x19ANF Secure Server Root CA"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x02\x0f\x000\x82\x02\n\x02\x82\x02\x01\x00\xdb\xebk+\xe6dT\x95\x82\x90\xa3r\xa4\x19\x01\x9d\x9c\x0b\x81_sI\xba\xa7\xac\xf3\x04N{\x96\x0b\xec\x11\xe0[\xa6\x1c\xce\x1b\xd2\r\x83\x1c+\xb8\x9e\x1d~E2`\x0f\x07\xe9wX~\x9fj\xc8aN\xb6&\xc1L\x8d\xffL\xef4\xb2\x1fe\xd8\xb9x\xf5\xad\xa9q\xb9\xefOX\x1d\xa5\xdet \x97\xa1\xedhL\xde\x92\x17K\xbc\xab\xffe\x9a\x9e\xfbG\xd9Wr\xf3\t\xa1\xaevD\x13n\x9c-D9\xbc\xf9\xc7;\xa4X=A\xbd\xb4\xc2I\xa3\xc8\r\xd2\x97/\x07eR\x00\xa7n\xc8\xafh\xec\xf4\x14\x96\xb6W\x1fV\xc39\x9f+m\xe4\xf3>\xf65d\xda\x0c\x1c\xa1\x84K/KK\xe2,$\x9dm\x93@\xeb\xb5#\x8e2\xcaoE\xd3\xa8\x89{\x1e\xcf\x1e\xfa[C\x8b\xcd\xcd\xa8\x0fj\xca\x0c^\xb9\x9eG\x8f\xf0\xd9\xb6\n\x0bXe\x173\xb9#\xe4w\x19}\xcbJ.\x92{O/\x10w\xb1\x8d/h\x9cb\xcc\xe0P\xf8\xec\x91\xa7TLW\t\xd5vc\xc5\xe8e\x1e\xeemj\xcf\t\x9d\xfa|O\xad`\x08\xfdV\x99\x0f\x15,{\xa9\x80\xab\x8ca\x8fJ\x07vB\xde=\xf4\xdd\xb2$3[\xb8\xb5\xa3D\xc9\xac\x7fw<\x1d#\xec\x82\xa9\xa6\xe2\xc8\x06L\x02\xfe\xac\\\x99\x99\x0b/\x10\x8a\xa6\xf4\x7f\xd5\x87t\rYIE\xf6\xf0q\\9)\xd6\xbfJ#\x8b\xf5_\x01c\xd2\x87s(\xb5K\n\xf5\xf8\xab\x82,~s%2\x1d\x0bc\n\x17\x81\x00\xff\xb6v^\xe7\xb4\xb1@\xca!\xbb\xd5\x80Q\xe5HRg,\xd2a\x89\x07\r\x0f\xceBw\xc0Ds\x9cDP\xa0\xdb\x10\n-\x95\x1c\x81\xaf\xe4\x1c\xe5\x14\x1e\xf16A\x01\x02/}s\xa7\xdeB\xccL\xe9\x89\rV\xf7\x9f\x91\xd4\x03\xc6l\xc9\x8f\xdb\xd8\x1c\xe0@\x98]f\x99\x98\x80n-\xff\x01\xc5\xce\xcbF\x1f\xac\x02\xc6C\xe6\xae\xa2\x84<\xc5N\x1e=m\xc9\x14L\xe3.A\xbb\xca9\xbf6<*\x19\xaaA\x87N\xa5\xceK2y\xdd\x90I\x7f\x02\x03\x01\x00\x01"), + name_constraints: None + }, + + /* + * Issuer: CN=T-TeleSec GlobalRoot Class 3 O=T-Systems Enterprise Services GmbH OU=T-Systems Trust Center + * Subject: CN=T-TeleSec GlobalRoot Class 3 O=T-Systems Enterprise Services GmbH OU=T-Systems Trust Center + * Label: "T-TeleSec GlobalRoot Class 3" + * Serial: 1 + * SHA256 Fingerprint: fd:73:da:d3:1c:64:4f:f1:b4:3b:ef:0c:cd:da:96:71:0b:9c:d9:87:5e:ca:7e:31:70:7a:f3:e9:6d:52:2b:bd + * -----BEGIN CERTIFICATE----- + * MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUx + * KzApBgNVBAoMIlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAd + * BgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNl + * YyBHbG9iYWxSb290IENsYXNzIDMwHhcNMDgxMDAxMTAyOTU2WhcNMzMxMDAxMjM1 + * OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lzdGVtcyBFbnRlcnBy + * aXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBDZW50 + * ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDMwggEiMA0G + * CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC9dZPwYiJvJK7genasfb3ZJNW4t/zN + * 8ELg63iIVl6bmlQdTQyK9tPPcPRStdiTBONGhnFBSivwKixVA9ZIw+A5OO3yXDw/ + * RLyTPWGrTs0NvvAgJ1gORH8EGoel15YUNpDQSXuhdfsaa3Ox+M6pCSzyU9XDFES4 + * hqX2iys52qMzVNn6chr3IhUciJFrf2blw2qAsCTz34ZFiP0Zf3WHHx+xGwpzJFu5 + * ZeAsVMhg02YXP+HMVDNzkQI6pn97djmiH5a2OK61yJN0HZ65tOVgnS9W0eDrXltM + * EnAMbEQgqxHY9Bn20pxSN+f6tsIxO0rUFJmtxxr1XV/6B7h8DR/Wgx6zAgMBAAGj + * QjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS1 + * A/d2O2GCahKqGFPrAyGUv/7OyjANBgkqhkiG9w0BAQsFAAOCAQEAVj3vlNW92nOy + * WL6ukK2YJ5f+AbGwUgC4TeQbIXQbfsDuXmkqJa9c1h3a0nnJ85cp4IaH3gRZD/FZ + * 1GSFS5mvJQQeyUapl96Cshtwn5z2r3Ex3XsFpSzTucpH9sry9uetuUg/vBa3wW30 + * 6gmv7PO15wWeph6KU1HWk4HMdJP2udqmJQV0eVp+QD6CSyYRMG7hP0HHRwA11fXT + * 91Q+gT3aSWqas+8QPebrb9HIIkfLzM8BMZLZGOMivgkeGj5asuRrDFR6fUNOuIml + * e9eiPZaGzPImNC1qkp2aGtAw4l1OBLBfiyB+d8E9lYLRRpo7PHi4b6HQDWSieB4p + * TpPDpFQUWw== + * -----END CERTIFICATE----- + */ + TrustAnchor { + subject: Der::from_slice(b"1\x0b0\t\x06\x03U\x04\x06\x13\x02DE1+0)\x06\x03U\x04\n\x0c\"T-Systems Enterprise Services GmbH1\x1f0\x1d\x06\x03U\x04\x0b\x0c\x16T-Systems Trust Center1%0#\x06\x03U\x04\x03\x0c\x1cT-TeleSec GlobalRoot Class 3"), + subject_public_key_info: Der::from_slice(b"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x01\x0f\x000\x82\x01\n\x02\x82\x01\x01\x00\xbdu\x93\xf0b\"o$\xae\xe0zv\xac}\xbd\xd9$\xd5\xb8\xb7\xfc\xcd\xf0B\xe0\xebx\x88V^\x9b\x9aT\x1dM\x0c\x8a\xf6\xd3\xcfp\xf4R\xb5\xd8\x93\x04\xe3F\x86qAJ+\xf0*,U\x03\xd6H\xc3\xe098\xed\xf2\\\x08\x1e\x14*7\x0b\x88<\xca\xb0\xf4\xc8\xc2\xa1\xae\xbc\xc1\xbe)gU\xe2\xfc\xadY\\\xfe\xbdW,\xb0\x90\x8d\xc2\xed7\xb6|\x99\x88\xb5\xd5\x03\x9a=\x15\r=:\xa8\xa8E\xf0\x95N%Y\x1d\xcd\x98i\xbb\xd3\xcc2\xc9\x8d\xef\x81\xfe\xad}\x89\xbb\xba`\x13\xcae\x95g\xa0\xf3\x19\xf6\x03V\xd4j\xd3\'\xe2\xa1\xad\x83\xf0J\x12\"w\x1c\x05s\xe2\x19qB\xc0\xecuF\x9a\x90X\xe0j\x8e+\xa5F0\x04\x8e\x19\xb2\x17\xe3\xbe\xa9\xba\x7fV\xf1$\x03\xd7\xb2!(v\x0e60Ly\xd5A\x9a\x9a\xa8\xb85\xba\x0c:\xf2D\x1b \x88\xf7\xc5%\xd7=\xc6\xe3>C\xdd\x87\xfe\xc4\xea\xf5S>Le\xff;J\xcbxZk\x17_\r\xc7\xc3ON\x9a*\xa2\xedWM\"\xe2F\x9a?\x0f\x914$}U\xe3\x8c\x957\xd3\x1a\xf0\t+,\xd2\xc9\x8d\xb4\r\x00\xabg)(\xd8\x01\xf5\x19\x04\xb6\x1d\xbev\xfer\\\xc4\x85\xca\xd2\x80A\xdf\x05\xa8\xa3\xd5\x84\x90O\x0b\xf3\xe0?\x9b\x19\xd27\x89?\xf2{R\x1c\x8c\xf6\xe1\xf7<\x07\x97\x8c\x0e\xa2Y\x81\x0c\xb2\x90=\xd3\xe3YF\xed\x0f\xa9\xa7\xde\x80kZ\xaa\x07\xb6\x19\xcb\xbcW\xf3\x97!z\x0c\xb1+t>\xeb\xda\xa7g-L\xc4\x98\x9e6\tvff\xfc\x1a?\xeaHT\x1c\xbe0\xbd\x80P\xbf|\xb5\xce\x00\xf6\x0ca\xd9\xe7$\x03\xe0\xe3\x01\x81\x0e\xbd\xd8\x854\x88\xbd\xb26\xa8{\\\x08\xe5D\x80\x8co\xf8/\xd5!\xca\x1d\x1c\xd0\xfb\xc4\xb5\x87\xd1:N\xc7v\xb55H\xb5\x02\x03\x01\x00\x01"), + name_constraints: None + }, + +]; diff --git a/http/vendor/webpki-roots/tests/codegen.rs b/http/vendor/webpki-roots/tests/codegen.rs new file mode 100644 index 0000000..d3b7838 --- /dev/null +++ b/http/vendor/webpki-roots/tests/codegen.rs @@ -0,0 +1,172 @@ +use std::ascii::escape_default; +use std::fmt::Write; +use std::fs; + +use aws_lc_rs::digest; +use pki_types::CertificateDer; +use webpki::anchor_from_trusted_cert; +use webpki_ccadb::fetch_ccadb_roots; +use x509_parser::prelude::AttributeTypeAndValue; +use x509_parser::x509::X509Name; + +#[tokio::test] +async fn new_generated_code_is_fresh() { + let tls_roots_map = fetch_ccadb_roots().await; + let mut code = String::with_capacity(256 * 1_024); + code.push_str(HEADER); + code.push_str("pub const TLS_SERVER_ROOTS: &[TrustAnchor<'static>] = &[\n"); + let (mut subject, mut spki, mut name_constraints) = + (String::new(), String::new(), String::new()); + + for root in tls_roots_map.values() { + // Verify the DER FP matches the metadata FP. + let der = root.der(); + let calculated_fp = digest::digest(&digest::SHA256, &der); + let metadata_fp = hex::decode(&root.sha256_fingerprint).expect("malformed fingerprint"); + assert_eq!(calculated_fp.as_ref(), metadata_fp.as_slice()); + + let ta_der = CertificateDer::from(der.as_ref()); + let ta = anchor_from_trusted_cert(&ta_der).expect("malformed trust anchor der"); + subject.clear(); + for &b in ta.subject.as_ref() { + write!(&mut subject, "{}", escape_default(b)).unwrap(); + } + + spki.clear(); + for &b in ta.subject_public_key_info.as_ref() { + write!(&mut spki, "{}", escape_default(b)).unwrap(); + } + + name_constraints.clear(); + if let Some(nc) = &root.mozilla_applied_constraints() { + for &b in nc.iter() { + write!(&mut name_constraints, "{}", escape_default(b)).unwrap(); + } + } + + let (_, parsed_cert) = + x509_parser::parse_x509_certificate(&der).expect("malformed x509 der"); + let issuer = name_to_string(parsed_cert.issuer()); + let subject_str = name_to_string(parsed_cert.subject()); + let label = root.common_name_or_certificate_name.clone(); + let serial = root.serial().to_string(); + let sha256_fp = root.sha256_fp(); + + // Write comment + code.push_str(" /*\n"); + code.push_str(&format!(" * Issuer: {issuer}\n")); + code.push_str(&format!(" * Subject: {subject_str}\n")); + code.push_str(&format!(" * Label: {label:?}\n")); + code.push_str(&format!(" * Serial: {serial}\n")); + code.push_str(&format!(" * SHA256 Fingerprint: {sha256_fp}\n")); + for ln in root.pem().lines() { + code.push_str(" * "); + code.push_str(ln.trim()); + code.push('\n'); + } + code.push_str(" */\n"); + + // Write the code + code.push_str(" TrustAnchor {\n"); + code.write_fmt(format_args!( + " subject: Der::from_slice(b\"{subject}\"),\n" + )) + .unwrap(); + code.write_fmt(format_args!( + " subject_public_key_info: Der::from_slice(b\"{spki}\"),\n" + )) + .unwrap(); + match name_constraints.is_empty() { + false => code + .write_fmt(format_args!( + " name_constraints: Some(Der::from_slice(b\"{name_constraints}\"))\n" + )) + .unwrap(), + true => code.push_str(" name_constraints: None\n"), + } + code.push_str(" },\n\n"); + } + code.push_str("];\n"); + + // Check that the generated code matches the checked-in code + let old = fs::read_to_string("src/lib.rs").unwrap(); + if old != code { + fs::write("src/lib.rs", code).unwrap(); + panic!("generated code changed"); + } +} + +/// The built-in x509_parser::X509Name Display impl uses a different sort order than +/// the one historically used by mkcert.org^[0]. We re-create that sort order here to +/// avoid unnecessary churn in the generated code. +/// +/// [0]: +fn name_to_string(name: &X509Name) -> String { + let mut ret = String::with_capacity(256); + + if let Some(cn) = name + .iter_common_name() + .next() + .and_then(|cn| cn.as_str().ok()) + { + write!(ret, "CN={cn}").unwrap(); + } + + let mut append_attrs = |attrs: Vec<&AttributeTypeAndValue>, label| { + let str_parts = attrs + .iter() + .filter_map(|attr| attr.as_str().ok()) + .collect::>() + .join("/"); + if !str_parts.is_empty() { + if !ret.is_empty() { + ret.push(' '); + } + write!(ret, "{label}={str_parts}").unwrap(); + } + }; + + append_attrs(name.iter_organization().collect(), "O"); + append_attrs(name.iter_organizational_unit().collect(), "OU"); + + ret +} + +const HEADER: &str = r#"//! A compiled-in copy of the root certificates trusted by Mozilla. +//! +//! To use this library with rustls 0.22: +//! +//! ```rust +//! let root_store = rustls::RootCertStore { +//! roots: webpki_roots::TLS_SERVER_ROOTS.to_vec(), +//! }; +//! ``` +//! +//! This library is suitable for use in applications that can always be recompiled and instantly deployed. +//! For applications that are deployed to end-users and cannot be recompiled, or which need certification +//! before deployment, consider a library that uses the platform native certificate verifier such as +//! [rustls-platform-verifier]. This has the additional benefit of supporting OS provided CA constraints +//! and revocation data. +//! +//! [rustls-platform-verifier]: https://docs.rs/rustls-platform-verifier +// +// This library is automatically generated from the Mozilla +// IncludedCACertificateReportPEMCSV report via ccadb.org. Don't edit it. +// +// The generation is done deterministically so you can verify it +// yourself by inspecting and re-running the generation process. + +#![no_std] +#![forbid(unsafe_code, unstable_features)] +#![deny( + elided_lifetimes_in_paths, + trivial_casts, + trivial_numeric_casts, + unused_import_braces, + unused_extern_crates, + unused_qualifications +)] + +use pki_types::{Der, TrustAnchor}; + +"#; diff --git a/http/vendor/webpki-roots/tests/data/tubitak/inter.der b/http/vendor/webpki-roots/tests/data/tubitak/inter.der new file mode 100644 index 0000000..e0b79ba Binary files /dev/null and b/http/vendor/webpki-roots/tests/data/tubitak/inter.der differ diff --git a/http/vendor/webpki-roots/tests/data/tubitak/root.der b/http/vendor/webpki-roots/tests/data/tubitak/root.der new file mode 100644 index 0000000..a4dfe1f Binary files /dev/null and b/http/vendor/webpki-roots/tests/data/tubitak/root.der differ diff --git a/http/vendor/webpki-roots/tests/data/tubitak/subj.der b/http/vendor/webpki-roots/tests/data/tubitak/subj.der new file mode 100644 index 0000000..42cf939 Binary files /dev/null and b/http/vendor/webpki-roots/tests/data/tubitak/subj.der differ diff --git a/http/vendor/webpki-roots/tests/verify.rs b/http/vendor/webpki-roots/tests/verify.rs new file mode 100644 index 0000000..1436c3f --- /dev/null +++ b/http/vendor/webpki-roots/tests/verify.rs @@ -0,0 +1,202 @@ +use core::time::Duration; +use std::convert::TryFrom; + +use pki_types::{CertificateDer, ServerName, SignatureVerificationAlgorithm, UnixTime}; +use rcgen::{ + BasicConstraints, CertificateParams, CertifiedIssuer, DnType, IsCa, Issuer, KeyPair, + KeyUsagePurpose, +}; +use webpki::{anchor_from_trusted_cert, EndEntityCert, Error, KeyUsage}; +use x509_parser::extensions::{GeneralName, NameConstraints as X509ParserNameConstraints}; +use x509_parser::prelude::FromDer; + +use webpki_roots::TLS_SERVER_ROOTS; + +#[test] +fn name_constraints() { + for name_constraints in TLS_SERVER_ROOTS + .iter() + .filter_map(|ta| ta.name_constraints.as_ref()) + { + let time = UnixTime::since_unix_epoch(Duration::from_secs(0x40000000)); // Time matching rcgen default. + let test_case = ConstraintTest::new(name_constraints.as_ref()); + let trust_anchors = &[anchor_from_trusted_cert(&test_case.trust_anchor).unwrap()]; + + // Each permitted EE should verify without error. + for permitted_ee in test_case.permitted_certs { + webpki::EndEntityCert::try_from(&permitted_ee) + .unwrap() + .verify_for_usage( + ALL_ALGORITHMS, + trust_anchors, + &[], + time, + KeyUsage::server_auth(), + None, + None, + ) + .unwrap(); + } + + // Each forbidden EE should fail to verify with the expected name constraint error. + for forbidden_ee in test_case.forbidden_certs { + let ee = EndEntityCert::try_from(&forbidden_ee).unwrap(); + let result = ee.verify_for_usage( + ALL_ALGORITHMS, + trust_anchors, + &[], + time, + KeyUsage::server_auth(), + None, + None, + ); + assert!(matches!(result, Err(Error::NameConstraintViolation))); + } + } +} + +struct ConstraintTest { + trust_anchor: CertificateDer<'static>, + permitted_certs: Vec>, + forbidden_certs: Vec>, +} + +impl ConstraintTest { + fn new(webpki_name_constraints: &[u8]) -> Self { + let name_constraints = rcgen_name_constraints(webpki_name_constraints); + + // Create a trust anchor CA certificate that has the name constraints we want to test. + let trust_anchor = { + let mut params = CertificateParams::new([]).unwrap(); + params + .distinguished_name + .push(DnType::CommonName, "Name Constraint Test CA"); + params.is_ca = IsCa::Ca(BasicConstraints::Unconstrained); + params.key_usages = vec![ + KeyUsagePurpose::KeyCertSign, + KeyUsagePurpose::DigitalSignature, + ]; + params.name_constraints = Some(name_constraints.clone()); + + let key = KeyPair::generate().unwrap(); + CertifiedIssuer::self_signed(params, key).unwrap() + }; + + let certs_for_subtrees = |suffix| { + name_constraints + .permitted_subtrees + .iter() + .filter_map(|subtree| match subtree { + rcgen::GeneralSubtree::DnsName(dns_name) => Some(rcgen_ee_for_name( + format!("valid{dns_name}{suffix}"), + &trust_anchor, + )), + _ => None, + }) + .collect() + }; + + Self { + // For each permitted subtree in the name constraints, issue an end entity certificate + // that contains a DNS name matching the permitted subtree base. + permitted_certs: certs_for_subtrees(""), + // For each permitted subtree in the name constraints, issue an end entity certificate + // that contains a DNS name that will **not** match the permitted subtree base. + forbidden_certs: certs_for_subtrees(".invalid"), + trust_anchor: trust_anchor.der().to_owned(), + } + } +} + +fn rcgen_ee_for_name(name: String, issuer: &Issuer<'_, KeyPair>) -> CertificateDer<'static> { + let mut ee = CertificateParams::new(vec![name.clone()]).unwrap(); + ee.distinguished_name.push(DnType::CommonName, name); + ee.is_ca = IsCa::NoCa; + let key_pair = KeyPair::generate().unwrap(); + ee.signed_by(&key_pair, issuer).unwrap().into() +} + +/// Convert the webpki trust anchor DER encoding of name constraints to rcgen NameConstraints. +fn rcgen_name_constraints(der: &[u8]) -> rcgen::NameConstraints { + // x509 parser expects the outer SEQUENCE that the webpki trust anchor representation elides + // so wrap the DER up. + let wrapped_der = yasna::construct_der(|writer| { + writer.write_sequence(|writer| { + writer.next().write_der(der); + }) + }); + + // Constraints should parse with no trailing data. + let (trailing, constraints) = X509ParserNameConstraints::from_der(&wrapped_der).unwrap(); + assert!( + trailing.is_empty(), + "unexpected trailing DER in name constraint" + ); + + // There should be at least one permitted subtree. + assert!( + constraints.permitted_subtrees.is_some(), + "empty permitted subtrees in constraints" + ); + + // We don't expect any excluded subtrees as this time. + assert!(constraints.excluded_subtrees.is_none()); + + // Collect all of the DNS names from the x509-parser representation, mapping to the rcgen + // representation usable in cert parameters. We don't expect to find any other types of general + // name and x509-parser doesn't parse the subtree minimum and maximum (which we would assert to + // be missing for proper encoding anyway). + let permitted_subtrees = match constraints.permitted_subtrees { + None => Vec::default(), + Some(subtrees) => subtrees + .iter() + .map(|subtree| match &subtree.base { + GeneralName::DNSName(base) => rcgen::GeneralSubtree::DnsName(base.to_string()), + name => panic!("unexpected subtree base general name type: {name}"), + }) + .collect(), + }; + + rcgen::NameConstraints { + permitted_subtrees, + excluded_subtrees: Vec::default(), + } +} + +#[test] +fn tubitak_name_constraint_works() { + let root = CertificateDer::from(&include_bytes!("data/tubitak/root.der")[..]); + let inter = CertificateDer::from(&include_bytes!("data/tubitak/inter.der")[..]); + let subj = CertificateDer::from(&include_bytes!("data/tubitak/subj.der")[..]); + + let roots = [anchor_from_trusted_cert(&root).unwrap().to_owned()]; + let now = UnixTime::since_unix_epoch(Duration::from_secs(1493668479)); + let cert = EndEntityCert::try_from(&subj).unwrap(); + cert.verify_for_usage( + ALL_ALGORITHMS, + &roots, + &[inter, root], + now, + KeyUsage::server_auth(), + None, + None, + ) + .unwrap(); + + let subject = ServerName::try_from("testssl.kamusm.gov.tr").unwrap(); + cert.verify_is_valid_for_subject_name(&subject).unwrap(); +} + +static ALL_ALGORITHMS: &[&dyn SignatureVerificationAlgorithm] = &[ + webpki::aws_lc_rs::ECDSA_P256_SHA256, + webpki::aws_lc_rs::ECDSA_P256_SHA384, + webpki::aws_lc_rs::ECDSA_P384_SHA256, + webpki::aws_lc_rs::ECDSA_P384_SHA384, + webpki::aws_lc_rs::RSA_PKCS1_2048_8192_SHA256, + webpki::aws_lc_rs::RSA_PKCS1_2048_8192_SHA384, + webpki::aws_lc_rs::RSA_PKCS1_2048_8192_SHA512, + webpki::aws_lc_rs::RSA_PKCS1_3072_8192_SHA384, + webpki::aws_lc_rs::RSA_PSS_2048_8192_SHA256_LEGACY_KEY, + webpki::aws_lc_rs::RSA_PSS_2048_8192_SHA384_LEGACY_KEY, + webpki::aws_lc_rs::RSA_PSS_2048_8192_SHA512_LEGACY_KEY, +]; diff --git a/http/vendor/windows-sys/.cargo-checksum.json b/http/vendor/windows-sys/.cargo-checksum.json new file mode 100644 index 0000000..13baf24 --- /dev/null +++ b/http/vendor/windows-sys/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"53fa735ad6f1cb288252d15b3425d3fd57da178f5aadb31928c482af6daef82c","src/lib.rs":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"},"package":"282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"} \ No newline at end of file diff --git a/http/vendor/windows-sys/Cargo.toml b/http/vendor/windows-sys/Cargo.toml new file mode 100644 index 0000000..0442fe6 --- /dev/null +++ b/http/vendor/windows-sys/Cargo.toml @@ -0,0 +1,257 @@ +[dependencies.windows-targets] +version = "0.52.0" + +[features] +Wdk = [] +Wdk_Foundation = ["Wdk"] +Wdk_Graphics = ["Wdk"] +Wdk_Graphics_Direct3D = ["Wdk_Graphics"] +Wdk_Storage = ["Wdk"] +Wdk_Storage_FileSystem = ["Wdk_Storage"] +Wdk_Storage_FileSystem_Minifilters = ["Wdk_Storage_FileSystem"] +Wdk_System = ["Wdk"] +Wdk_System_IO = ["Wdk_System"] +Wdk_System_OfflineRegistry = ["Wdk_System"] +Wdk_System_Registry = ["Wdk_System"] +Wdk_System_SystemInformation = ["Wdk_System"] +Wdk_System_SystemServices = ["Wdk_System"] +Wdk_System_Threading = ["Wdk_System"] +Win32 = [] +Win32_Data = ["Win32"] +Win32_Data_HtmlHelp = ["Win32_Data"] +Win32_Data_RightsManagement = ["Win32_Data"] +Win32_Devices = ["Win32"] +Win32_Devices_AllJoyn = ["Win32_Devices"] +Win32_Devices_BiometricFramework = ["Win32_Devices"] +Win32_Devices_Bluetooth = ["Win32_Devices"] +Win32_Devices_Communication = ["Win32_Devices"] +Win32_Devices_DeviceAndDriverInstallation = ["Win32_Devices"] +Win32_Devices_DeviceQuery = ["Win32_Devices"] +Win32_Devices_Display = ["Win32_Devices"] +Win32_Devices_Enumeration = ["Win32_Devices"] +Win32_Devices_Enumeration_Pnp = ["Win32_Devices_Enumeration"] +Win32_Devices_Fax = ["Win32_Devices"] +Win32_Devices_HumanInterfaceDevice = ["Win32_Devices"] +Win32_Devices_PortableDevices = ["Win32_Devices"] +Win32_Devices_Properties = ["Win32_Devices"] +Win32_Devices_Pwm = ["Win32_Devices"] +Win32_Devices_Sensors = ["Win32_Devices"] +Win32_Devices_SerialCommunication = ["Win32_Devices"] +Win32_Devices_Tapi = ["Win32_Devices"] +Win32_Devices_Usb = ["Win32_Devices"] +Win32_Devices_WebServicesOnDevices = ["Win32_Devices"] +Win32_Foundation = ["Win32"] +Win32_Gaming = ["Win32"] +Win32_Globalization = ["Win32"] +Win32_Graphics = ["Win32"] +Win32_Graphics_Dwm = ["Win32_Graphics"] +Win32_Graphics_Gdi = ["Win32_Graphics"] +Win32_Graphics_GdiPlus = ["Win32_Graphics"] +Win32_Graphics_Hlsl = ["Win32_Graphics"] +Win32_Graphics_OpenGL = ["Win32_Graphics"] +Win32_Graphics_Printing = ["Win32_Graphics"] +Win32_Graphics_Printing_PrintTicket = ["Win32_Graphics_Printing"] +Win32_Management = ["Win32"] +Win32_Management_MobileDeviceManagementRegistration = ["Win32_Management"] +Win32_Media = ["Win32"] +Win32_Media_Audio = ["Win32_Media"] +Win32_Media_DxMediaObjects = ["Win32_Media"] +Win32_Media_KernelStreaming = ["Win32_Media"] +Win32_Media_Multimedia = ["Win32_Media"] +Win32_Media_Streaming = ["Win32_Media"] +Win32_Media_WindowsMediaFormat = ["Win32_Media"] +Win32_NetworkManagement = ["Win32"] +Win32_NetworkManagement_Dhcp = ["Win32_NetworkManagement"] +Win32_NetworkManagement_Dns = ["Win32_NetworkManagement"] +Win32_NetworkManagement_InternetConnectionWizard = ["Win32_NetworkManagement"] +Win32_NetworkManagement_IpHelper = ["Win32_NetworkManagement"] +Win32_NetworkManagement_Multicast = ["Win32_NetworkManagement"] +Win32_NetworkManagement_Ndis = ["Win32_NetworkManagement"] +Win32_NetworkManagement_NetBios = ["Win32_NetworkManagement"] +Win32_NetworkManagement_NetManagement = ["Win32_NetworkManagement"] +Win32_NetworkManagement_NetShell = ["Win32_NetworkManagement"] +Win32_NetworkManagement_NetworkDiagnosticsFramework = ["Win32_NetworkManagement"] +Win32_NetworkManagement_P2P = ["Win32_NetworkManagement"] +Win32_NetworkManagement_QoS = ["Win32_NetworkManagement"] +Win32_NetworkManagement_Rras = ["Win32_NetworkManagement"] +Win32_NetworkManagement_Snmp = ["Win32_NetworkManagement"] +Win32_NetworkManagement_WNet = ["Win32_NetworkManagement"] +Win32_NetworkManagement_WebDav = ["Win32_NetworkManagement"] +Win32_NetworkManagement_WiFi = ["Win32_NetworkManagement"] +Win32_NetworkManagement_WindowsConnectionManager = ["Win32_NetworkManagement"] +Win32_NetworkManagement_WindowsFilteringPlatform = ["Win32_NetworkManagement"] +Win32_NetworkManagement_WindowsFirewall = ["Win32_NetworkManagement"] +Win32_NetworkManagement_WindowsNetworkVirtualization = ["Win32_NetworkManagement"] +Win32_Networking = ["Win32"] +Win32_Networking_ActiveDirectory = ["Win32_Networking"] +Win32_Networking_Clustering = ["Win32_Networking"] +Win32_Networking_HttpServer = ["Win32_Networking"] +Win32_Networking_Ldap = ["Win32_Networking"] +Win32_Networking_WebSocket = ["Win32_Networking"] +Win32_Networking_WinHttp = ["Win32_Networking"] +Win32_Networking_WinInet = ["Win32_Networking"] +Win32_Networking_WinSock = ["Win32_Networking"] +Win32_Networking_WindowsWebServices = ["Win32_Networking"] +Win32_Security = ["Win32"] +Win32_Security_AppLocker = ["Win32_Security"] +Win32_Security_Authentication = ["Win32_Security"] +Win32_Security_Authentication_Identity = ["Win32_Security_Authentication"] +Win32_Security_Authorization = ["Win32_Security"] +Win32_Security_Credentials = ["Win32_Security"] +Win32_Security_Cryptography = ["Win32_Security"] +Win32_Security_Cryptography_Catalog = ["Win32_Security_Cryptography"] +Win32_Security_Cryptography_Certificates = ["Win32_Security_Cryptography"] +Win32_Security_Cryptography_Sip = ["Win32_Security_Cryptography"] +Win32_Security_Cryptography_UI = ["Win32_Security_Cryptography"] +Win32_Security_DiagnosticDataQuery = ["Win32_Security"] +Win32_Security_DirectoryServices = ["Win32_Security"] +Win32_Security_EnterpriseData = ["Win32_Security"] +Win32_Security_ExtensibleAuthenticationProtocol = ["Win32_Security"] +Win32_Security_Isolation = ["Win32_Security"] +Win32_Security_LicenseProtection = ["Win32_Security"] +Win32_Security_NetworkAccessProtection = ["Win32_Security"] +Win32_Security_WinTrust = ["Win32_Security"] +Win32_Security_WinWlx = ["Win32_Security"] +Win32_Storage = ["Win32"] +Win32_Storage_Cabinets = ["Win32_Storage"] +Win32_Storage_CloudFilters = ["Win32_Storage"] +Win32_Storage_Compression = ["Win32_Storage"] +Win32_Storage_DistributedFileSystem = ["Win32_Storage"] +Win32_Storage_FileHistory = ["Win32_Storage"] +Win32_Storage_FileSystem = ["Win32_Storage"] +Win32_Storage_Imapi = ["Win32_Storage"] +Win32_Storage_IndexServer = ["Win32_Storage"] +Win32_Storage_InstallableFileSystems = ["Win32_Storage"] +Win32_Storage_IscsiDisc = ["Win32_Storage"] +Win32_Storage_Jet = ["Win32_Storage"] +Win32_Storage_Nvme = ["Win32_Storage"] +Win32_Storage_OfflineFiles = ["Win32_Storage"] +Win32_Storage_OperationRecorder = ["Win32_Storage"] +Win32_Storage_Packaging = ["Win32_Storage"] +Win32_Storage_Packaging_Appx = ["Win32_Storage_Packaging"] +Win32_Storage_ProjectedFileSystem = ["Win32_Storage"] +Win32_Storage_StructuredStorage = ["Win32_Storage"] +Win32_Storage_Vhd = ["Win32_Storage"] +Win32_Storage_Xps = ["Win32_Storage"] +Win32_System = ["Win32"] +Win32_System_AddressBook = ["Win32_System"] +Win32_System_Antimalware = ["Win32_System"] +Win32_System_ApplicationInstallationAndServicing = ["Win32_System"] +Win32_System_ApplicationVerifier = ["Win32_System"] +Win32_System_ClrHosting = ["Win32_System"] +Win32_System_Com = ["Win32_System"] +Win32_System_Com_Marshal = ["Win32_System_Com"] +Win32_System_Com_StructuredStorage = ["Win32_System_Com"] +Win32_System_Com_Urlmon = ["Win32_System_Com"] +Win32_System_ComponentServices = ["Win32_System"] +Win32_System_Console = ["Win32_System"] +Win32_System_CorrelationVector = ["Win32_System"] +Win32_System_DataExchange = ["Win32_System"] +Win32_System_DeploymentServices = ["Win32_System"] +Win32_System_DeveloperLicensing = ["Win32_System"] +Win32_System_Diagnostics = ["Win32_System"] +Win32_System_Diagnostics_Ceip = ["Win32_System_Diagnostics"] +Win32_System_Diagnostics_Debug = ["Win32_System_Diagnostics"] +Win32_System_Diagnostics_Debug_Extensions = ["Win32_System_Diagnostics_Debug"] +Win32_System_Diagnostics_Etw = ["Win32_System_Diagnostics"] +Win32_System_Diagnostics_ProcessSnapshotting = ["Win32_System_Diagnostics"] +Win32_System_Diagnostics_ToolHelp = ["Win32_System_Diagnostics"] +Win32_System_DistributedTransactionCoordinator = ["Win32_System"] +Win32_System_Environment = ["Win32_System"] +Win32_System_ErrorReporting = ["Win32_System"] +Win32_System_EventCollector = ["Win32_System"] +Win32_System_EventLog = ["Win32_System"] +Win32_System_EventNotificationService = ["Win32_System"] +Win32_System_GroupPolicy = ["Win32_System"] +Win32_System_HostCompute = ["Win32_System"] +Win32_System_HostComputeNetwork = ["Win32_System"] +Win32_System_HostComputeSystem = ["Win32_System"] +Win32_System_Hypervisor = ["Win32_System"] +Win32_System_IO = ["Win32_System"] +Win32_System_Iis = ["Win32_System"] +Win32_System_Ioctl = ["Win32_System"] +Win32_System_JobObjects = ["Win32_System"] +Win32_System_Js = ["Win32_System"] +Win32_System_Kernel = ["Win32_System"] +Win32_System_LibraryLoader = ["Win32_System"] +Win32_System_Mailslots = ["Win32_System"] +Win32_System_Mapi = ["Win32_System"] +Win32_System_Memory = ["Win32_System"] +Win32_System_Memory_NonVolatile = ["Win32_System_Memory"] +Win32_System_MessageQueuing = ["Win32_System"] +Win32_System_MixedReality = ["Win32_System"] +Win32_System_Ole = ["Win32_System"] +Win32_System_PasswordManagement = ["Win32_System"] +Win32_System_Performance = ["Win32_System"] +Win32_System_Performance_HardwareCounterProfiling = ["Win32_System_Performance"] +Win32_System_Pipes = ["Win32_System"] +Win32_System_Power = ["Win32_System"] +Win32_System_ProcessStatus = ["Win32_System"] +Win32_System_Recovery = ["Win32_System"] +Win32_System_Registry = ["Win32_System"] +Win32_System_RemoteDesktop = ["Win32_System"] +Win32_System_RemoteManagement = ["Win32_System"] +Win32_System_RestartManager = ["Win32_System"] +Win32_System_Restore = ["Win32_System"] +Win32_System_Rpc = ["Win32_System"] +Win32_System_Search = ["Win32_System"] +Win32_System_Search_Common = ["Win32_System_Search"] +Win32_System_SecurityCenter = ["Win32_System"] +Win32_System_Services = ["Win32_System"] +Win32_System_SetupAndMigration = ["Win32_System"] +Win32_System_Shutdown = ["Win32_System"] +Win32_System_StationsAndDesktops = ["Win32_System"] +Win32_System_SubsystemForLinux = ["Win32_System"] +Win32_System_SystemInformation = ["Win32_System"] +Win32_System_SystemServices = ["Win32_System"] +Win32_System_Threading = ["Win32_System"] +Win32_System_Time = ["Win32_System"] +Win32_System_TpmBaseServices = ["Win32_System"] +Win32_System_UserAccessLogging = ["Win32_System"] +Win32_System_Variant = ["Win32_System"] +Win32_System_VirtualDosMachines = ["Win32_System"] +Win32_System_WindowsProgramming = ["Win32_System"] +Win32_System_Wmi = ["Win32_System"] +Win32_UI = ["Win32"] +Win32_UI_Accessibility = ["Win32_UI"] +Win32_UI_ColorSystem = ["Win32_UI"] +Win32_UI_Controls = ["Win32_UI"] +Win32_UI_Controls_Dialogs = ["Win32_UI_Controls"] +Win32_UI_HiDpi = ["Win32_UI"] +Win32_UI_Input = ["Win32_UI"] +Win32_UI_Input_Ime = ["Win32_UI_Input"] +Win32_UI_Input_KeyboardAndMouse = ["Win32_UI_Input"] +Win32_UI_Input_Pointer = ["Win32_UI_Input"] +Win32_UI_Input_Touch = ["Win32_UI_Input"] +Win32_UI_Input_XboxController = ["Win32_UI_Input"] +Win32_UI_InteractionContext = ["Win32_UI"] +Win32_UI_Magnification = ["Win32_UI"] +Win32_UI_Shell = ["Win32_UI"] +Win32_UI_Shell_PropertiesSystem = ["Win32_UI_Shell"] +Win32_UI_TabletPC = ["Win32_UI"] +Win32_UI_TextServices = ["Win32_UI"] +Win32_UI_WindowsAndMessaging = ["Win32_UI"] +Win32_Web = ["Win32"] +Win32_Web_InternetExplorer = ["Win32_Web"] +default = [] +docs = [] + +[lib] +path = "src/lib.rs" + +[package] +authors = ["Microsoft"] +categories = ["os::windows-apis"] +description = "Rust for Windows" +edition = "2021" +license = "MIT OR Apache-2.0" +name = "windows-sys" +readme = "readme.md" +repository = "https://github.com/microsoft/windows-rs" +rust-version = "1.56" +version = "0.52.0" + +[package.metadata.docs.rs] +all-features = true +default-target = "x86_64-pc-windows-msvc" +targets = [] diff --git a/http/vendor/windows-sys/src/lib.rs b/http/vendor/windows-sys/src/lib.rs new file mode 100644 index 0000000..e69de29 diff --git a/http/vendor/windows-targets/.cargo-checksum.json b/http/vendor/windows-targets/.cargo-checksum.json new file mode 100644 index 0000000..57f934e --- /dev/null +++ b/http/vendor/windows-targets/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"ad9c93807327c66d969a4280a693d46a8becd5a30b66dd0aaf2c25bd4f95cead","src/lib.rs":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"},"package":"9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"} \ No newline at end of file diff --git a/http/vendor/windows-targets/Cargo.toml b/http/vendor/windows-targets/Cargo.toml new file mode 100644 index 0000000..37535ad --- /dev/null +++ b/http/vendor/windows-targets/Cargo.toml @@ -0,0 +1,53 @@ +[lib] +path = "src/lib.rs" + +[lints.rust] +missing_docs = "warn" + +[lints.rust.rust_2018_idioms] +level = "warn" +priority = -1 + +[lints.rust.unexpected_cfgs] +check-cfg = ["cfg(windows_raw_dylib, windows_debugger_visualizer, windows_slim_errors)"] +level = "warn" +priority = 0 + +[package] +authors = ["Microsoft"] +autobenches = false +autobins = false +autoexamples = false +autotests = false +description = "Import libs for Windows" +edition = "2021" +license = "MIT OR Apache-2.0" +name = "windows-targets" +readme = "readme.md" +repository = "https://github.com/microsoft/windows-rs" +rust-version = "1.56" +version = "0.52.6" + +[target.aarch64-pc-windows-gnullvm.dependencies.windows_aarch64_gnullvm] +version = "0.52.6" + +[target.'cfg(all(any(target_arch = "x86_64", target_arch = "arm64ec"), target_env = "msvc", not(windows_raw_dylib)))'.dependencies.windows_x86_64_msvc] +version = "0.52.6" + +[target.'cfg(all(target_arch = "aarch64", target_env = "msvc", not(windows_raw_dylib)))'.dependencies.windows_aarch64_msvc] +version = "0.52.6" + +[target.'cfg(all(target_arch = "x86", target_env = "gnu", not(target_abi = "llvm"), not(windows_raw_dylib)))'.dependencies.windows_i686_gnu] +version = "0.52.6" + +[target.'cfg(all(target_arch = "x86", target_env = "msvc", not(windows_raw_dylib)))'.dependencies.windows_i686_msvc] +version = "0.52.6" + +[target.'cfg(all(target_arch = "x86_64", target_env = "gnu", not(target_abi = "llvm"), not(windows_raw_dylib)))'.dependencies.windows_x86_64_gnu] +version = "0.52.6" + +[target.i686-pc-windows-gnullvm.dependencies.windows_i686_gnullvm] +version = "0.52.6" + +[target.x86_64-pc-windows-gnullvm.dependencies.windows_x86_64_gnullvm] +version = "0.52.6" diff --git a/http/vendor/windows-targets/src/lib.rs b/http/vendor/windows-targets/src/lib.rs new file mode 100644 index 0000000..e69de29 diff --git a/http/vendor/windows_aarch64_gnullvm/.cargo-checksum.json b/http/vendor/windows_aarch64_gnullvm/.cargo-checksum.json new file mode 100644 index 0000000..00023b8 --- /dev/null +++ b/http/vendor/windows_aarch64_gnullvm/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"9b6fac6779dba88cb577281a67a5d987465cca10afec637a2808f998051593cd","src/lib.rs":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"},"package":"32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"} \ No newline at end of file diff --git a/http/vendor/windows_aarch64_gnullvm/Cargo.toml b/http/vendor/windows_aarch64_gnullvm/Cargo.toml new file mode 100644 index 0000000..39a45a9 --- /dev/null +++ b/http/vendor/windows_aarch64_gnullvm/Cargo.toml @@ -0,0 +1,21 @@ +[lib] +path = "src/lib.rs" + +[package] +authors = ["Microsoft"] +autobenches = false +autobins = false +autoexamples = false +autotests = false +description = "Import lib for Windows" +edition = "2021" +license = "MIT OR Apache-2.0" +name = "windows_aarch64_gnullvm" +readme = false +repository = "https://github.com/microsoft/windows-rs" +rust-version = "1.56" +version = "0.52.6" + +[package.metadata.docs.rs] +default-target = "x86_64-pc-windows-msvc" +targets = [] diff --git a/http/vendor/windows_aarch64_gnullvm/src/lib.rs b/http/vendor/windows_aarch64_gnullvm/src/lib.rs new file mode 100644 index 0000000..e69de29 diff --git a/http/vendor/windows_aarch64_msvc/.cargo-checksum.json b/http/vendor/windows_aarch64_msvc/.cargo-checksum.json new file mode 100644 index 0000000..c43a607 --- /dev/null +++ b/http/vendor/windows_aarch64_msvc/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"7a2bee0434d406468f209044c74712cfaca9db652efe520b0c1e44cb315fab16","src/lib.rs":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"},"package":"09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"} \ No newline at end of file diff --git a/http/vendor/windows_aarch64_msvc/Cargo.toml b/http/vendor/windows_aarch64_msvc/Cargo.toml new file mode 100644 index 0000000..d1f8d4a --- /dev/null +++ b/http/vendor/windows_aarch64_msvc/Cargo.toml @@ -0,0 +1,21 @@ +[lib] +path = "src/lib.rs" + +[package] +authors = ["Microsoft"] +autobenches = false +autobins = false +autoexamples = false +autotests = false +description = "Import lib for Windows" +edition = "2021" +license = "MIT OR Apache-2.0" +name = "windows_aarch64_msvc" +readme = false +repository = "https://github.com/microsoft/windows-rs" +rust-version = "1.56" +version = "0.52.6" + +[package.metadata.docs.rs] +default-target = "x86_64-pc-windows-msvc" +targets = [] diff --git a/http/vendor/windows_aarch64_msvc/src/lib.rs b/http/vendor/windows_aarch64_msvc/src/lib.rs new file mode 100644 index 0000000..e69de29 diff --git a/http/vendor/windows_i686_gnu/.cargo-checksum.json b/http/vendor/windows_i686_gnu/.cargo-checksum.json new file mode 100644 index 0000000..aab6ca7 --- /dev/null +++ b/http/vendor/windows_i686_gnu/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"2ebdbcff51e6ce96f1cf87afddbfec109d3e685b2aaac51297f35e2b588543c5","src/lib.rs":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"},"package":"8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"} \ No newline at end of file diff --git a/http/vendor/windows_i686_gnu/Cargo.toml b/http/vendor/windows_i686_gnu/Cargo.toml new file mode 100644 index 0000000..6b2c749 --- /dev/null +++ b/http/vendor/windows_i686_gnu/Cargo.toml @@ -0,0 +1,21 @@ +[lib] +path = "src/lib.rs" + +[package] +authors = ["Microsoft"] +autobenches = false +autobins = false +autoexamples = false +autotests = false +description = "Import lib for Windows" +edition = "2021" +license = "MIT OR Apache-2.0" +name = "windows_i686_gnu" +readme = false +repository = "https://github.com/microsoft/windows-rs" +rust-version = "1.56" +version = "0.52.6" + +[package.metadata.docs.rs] +default-target = "x86_64-pc-windows-msvc" +targets = [] diff --git a/http/vendor/windows_i686_gnu/src/lib.rs b/http/vendor/windows_i686_gnu/src/lib.rs new file mode 100644 index 0000000..e69de29 diff --git a/http/vendor/windows_i686_gnullvm/.cargo-checksum.json b/http/vendor/windows_i686_gnullvm/.cargo-checksum.json new file mode 100644 index 0000000..ed7e01b --- /dev/null +++ b/http/vendor/windows_i686_gnullvm/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"c55bb85be8d843c6b46f4aba5432ee1a41819d37b90d09f5c643dd83e0b9a674","src/lib.rs":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"},"package":"0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"} \ No newline at end of file diff --git a/http/vendor/windows_i686_gnullvm/Cargo.toml b/http/vendor/windows_i686_gnullvm/Cargo.toml new file mode 100644 index 0000000..0dd647c --- /dev/null +++ b/http/vendor/windows_i686_gnullvm/Cargo.toml @@ -0,0 +1,21 @@ +[lib] +path = "src/lib.rs" + +[package] +authors = ["Microsoft"] +autobenches = false +autobins = false +autoexamples = false +autotests = false +description = "Import lib for Windows" +edition = "2021" +license = "MIT OR Apache-2.0" +name = "windows_i686_gnullvm" +readme = false +repository = "https://github.com/microsoft/windows-rs" +rust-version = "1.56" +version = "0.52.6" + +[package.metadata.docs.rs] +default-target = "x86_64-pc-windows-msvc" +targets = [] diff --git a/http/vendor/windows_i686_gnullvm/src/lib.rs b/http/vendor/windows_i686_gnullvm/src/lib.rs new file mode 100644 index 0000000..e69de29 diff --git a/http/vendor/windows_i686_msvc/.cargo-checksum.json b/http/vendor/windows_i686_msvc/.cargo-checksum.json new file mode 100644 index 0000000..81a6ca3 --- /dev/null +++ b/http/vendor/windows_i686_msvc/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"ef21c88850dee053b3e50396547799c57204f6edb2e2f07f1f481d1c8c90a641","src/lib.rs":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"},"package":"240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"} \ No newline at end of file diff --git a/http/vendor/windows_i686_msvc/Cargo.toml b/http/vendor/windows_i686_msvc/Cargo.toml new file mode 100644 index 0000000..be9374d --- /dev/null +++ b/http/vendor/windows_i686_msvc/Cargo.toml @@ -0,0 +1,21 @@ +[lib] +path = "src/lib.rs" + +[package] +authors = ["Microsoft"] +autobenches = false +autobins = false +autoexamples = false +autotests = false +description = "Import lib for Windows" +edition = "2021" +license = "MIT OR Apache-2.0" +name = "windows_i686_msvc" +readme = false +repository = "https://github.com/microsoft/windows-rs" +rust-version = "1.56" +version = "0.52.6" + +[package.metadata.docs.rs] +default-target = "x86_64-pc-windows-msvc" +targets = [] diff --git a/http/vendor/windows_i686_msvc/src/lib.rs b/http/vendor/windows_i686_msvc/src/lib.rs new file mode 100644 index 0000000..e69de29 diff --git a/http/vendor/windows_x86_64_gnu/.cargo-checksum.json b/http/vendor/windows_x86_64_gnu/.cargo-checksum.json new file mode 100644 index 0000000..ce35a1a --- /dev/null +++ b/http/vendor/windows_x86_64_gnu/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"9ec2434667bea125152e843c55337c6462c56a1112ea215665c4552e3ba97f6b","src/lib.rs":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"},"package":"147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"} \ No newline at end of file diff --git a/http/vendor/windows_x86_64_gnu/Cargo.toml b/http/vendor/windows_x86_64_gnu/Cargo.toml new file mode 100644 index 0000000..a90a71b --- /dev/null +++ b/http/vendor/windows_x86_64_gnu/Cargo.toml @@ -0,0 +1,21 @@ +[lib] +path = "src/lib.rs" + +[package] +authors = ["Microsoft"] +autobenches = false +autobins = false +autoexamples = false +autotests = false +description = "Import lib for Windows" +edition = "2021" +license = "MIT OR Apache-2.0" +name = "windows_x86_64_gnu" +readme = false +repository = "https://github.com/microsoft/windows-rs" +rust-version = "1.56" +version = "0.52.6" + +[package.metadata.docs.rs] +default-target = "x86_64-pc-windows-msvc" +targets = [] diff --git a/http/vendor/windows_x86_64_gnu/src/lib.rs b/http/vendor/windows_x86_64_gnu/src/lib.rs new file mode 100644 index 0000000..e69de29 diff --git a/http/vendor/windows_x86_64_gnullvm/.cargo-checksum.json b/http/vendor/windows_x86_64_gnullvm/.cargo-checksum.json new file mode 100644 index 0000000..676fe94 --- /dev/null +++ b/http/vendor/windows_x86_64_gnullvm/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"8086fd9fb5d06c52b0fc793335492160d84e340e5a208079049ef60aacf2eeb1","src/lib.rs":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"},"package":"24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"} \ No newline at end of file diff --git a/http/vendor/windows_x86_64_gnullvm/Cargo.toml b/http/vendor/windows_x86_64_gnullvm/Cargo.toml new file mode 100644 index 0000000..d0279a7 --- /dev/null +++ b/http/vendor/windows_x86_64_gnullvm/Cargo.toml @@ -0,0 +1,21 @@ +[lib] +path = "src/lib.rs" + +[package] +authors = ["Microsoft"] +autobenches = false +autobins = false +autoexamples = false +autotests = false +description = "Import lib for Windows" +edition = "2021" +license = "MIT OR Apache-2.0" +name = "windows_x86_64_gnullvm" +readme = false +repository = "https://github.com/microsoft/windows-rs" +rust-version = "1.56" +version = "0.52.6" + +[package.metadata.docs.rs] +default-target = "x86_64-pc-windows-msvc" +targets = [] diff --git a/http/vendor/windows_x86_64_gnullvm/src/lib.rs b/http/vendor/windows_x86_64_gnullvm/src/lib.rs new file mode 100644 index 0000000..e69de29 diff --git a/http/vendor/windows_x86_64_msvc/.cargo-checksum.json b/http/vendor/windows_x86_64_msvc/.cargo-checksum.json new file mode 100644 index 0000000..a8fbdd5 --- /dev/null +++ b/http/vendor/windows_x86_64_msvc/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{"Cargo.toml":"25e6646aea9d47dce6cf15990da3903adf9dc128306c34846988f49b67c898c9","src/lib.rs":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"},"package":"589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"} \ No newline at end of file diff --git a/http/vendor/windows_x86_64_msvc/Cargo.toml b/http/vendor/windows_x86_64_msvc/Cargo.toml new file mode 100644 index 0000000..e84876f --- /dev/null +++ b/http/vendor/windows_x86_64_msvc/Cargo.toml @@ -0,0 +1,21 @@ +[lib] +path = "src/lib.rs" + +[package] +authors = ["Microsoft"] +autobenches = false +autobins = false +autoexamples = false +autotests = false +description = "Import lib for Windows" +edition = "2021" +license = "MIT OR Apache-2.0" +name = "windows_x86_64_msvc" +readme = false +repository = "https://github.com/microsoft/windows-rs" +rust-version = "1.56" +version = "0.52.6" + +[package.metadata.docs.rs] +default-target = "x86_64-pc-windows-msvc" +targets = [] diff --git a/http/vendor/windows_x86_64_msvc/src/lib.rs b/http/vendor/windows_x86_64_msvc/src/lib.rs new file mode 100644 index 0000000..e69de29 diff --git a/http/vendor/zeroize/.cargo-checksum.json b/http/vendor/zeroize/.cargo-checksum.json new file mode 100644 index 0000000..934ff3b --- /dev/null +++ b/http/vendor/zeroize/.cargo-checksum.json @@ -0,0 +1 @@ +{"files":{".cargo_vcs_info.json":"5d873212e3cef47f1d7572d13333a1e2f9c63a7136911a1d97074aa742684e6f","CHANGELOG.md":"3697f546e1f4882c552c829e519e41920e340468c36235e00e58243fa60b72c5","Cargo.lock":"d20e85bfdcc029e5d83ff3ef3141bc681b154ab6fe8dc603e7389eed7c10a391","Cargo.toml":"d9c34827131f0367c3c209f2c858c142d34be9512a9c6fb59179e369a1d7c32a","Cargo.toml.orig":"624a3c4ea0c3a281ba1f2c5bec1172348e2b111ac45ae7eda62bd799ba9f97a1","LICENSE-APACHE":"cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30","LICENSE-MIT":"8c7516d4b27b1e495be5e38b612298b63de48d05f49cdac94f70f3cd70f8864b","README.md":"aeba37a1b36508217d66d1c88e8621f762cb51491dd49cd44a4f1162501aca1b","src/aarch64.rs":"24b184c6ccbdba95713e06b6f2f56a75beef33f0ec257f31563b98bbefba7150","src/barrier.rs":"52a2d35e198abcb08ec77f4067fc17a759aa4cf2a48600eb7fc4a667323f77a4","src/lib.rs":"61012679ef3d0cc4e29b6f9c9d6c572c4ba8110e70a1e1c527da6bfaf77494ef","src/stack.rs":"9ef73091eab4aeb562f87147008f66411d3c70ea4f9807437828a8ba50f4c9d5","src/x86.rs":"901288b70df954fe4a62d811a0fcc2248776cea28edfeff0c35eba2d1446cbad","tests/alloc.rs":"618a6088647ca51c7086ebe80c04587c2bda57fbf55ed0364d3b5415b5870441","tests/zeroize.rs":"56a69fc036bcb0efccb393828d64f16311a819acc48fa753f2d5837dbb2dc807","tests/zeroize_derive.rs":"1dabb3a1fe3579fa3010e7af94a438fe76f41a4cd776e395d00ebd7209470a4a"},"package":"e13c156562582aa81c60cb29407084cdb54c4164760106ab78e6c5b0858cf64e"} \ No newline at end of file diff --git a/http/vendor/zeroize/.cargo_vcs_info.json b/http/vendor/zeroize/.cargo_vcs_info.json new file mode 100644 index 0000000..a1127e1 --- /dev/null +++ b/http/vendor/zeroize/.cargo_vcs_info.json @@ -0,0 +1,6 @@ +{ + "git": { + "sha1": "0b715735a660a8566ccd240bf42489fe2ed98efb" + }, + "path_in_vcs": "zeroize" +} \ No newline at end of file diff --git a/http/vendor/zeroize/CHANGELOG.md b/http/vendor/zeroize/CHANGELOG.md new file mode 100644 index 0000000..0272a4c --- /dev/null +++ b/http/vendor/zeroize/CHANGELOG.md @@ -0,0 +1,297 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## 1.9.0 (2026-06-12) +### Added +- `Zeroizing` is now `repr(transparent)` ([#1253]) +- `optimization_barrier` function ([#1261]) +- `Zeroizing` now supports `?Sized` ([#1318]) +- `zeroize_stack` function ([#1331]) + +### Changed +- Edition changed to 2024 and MSRV bumped to 1.85 ([#1149]) +- Replace `atomic_fence` with `optimization_barrier` ([#1252]) +- Bump `zeroize_derive` to v1.5 ([#1492]) +- Always enable AVX-512 support ([#1493]) + +[#1149]: https://github.com/RustCrypto/utils/pull/1149 +[#1252]: https://github.com/RustCrypto/utils/pull/1252 +[#1253]: https://github.com/RustCrypto/utils/pull/1253 +[#1261]: https://github.com/RustCrypto/utils/pull/1261 +[#1318]: https://github.com/RustCrypto/utils/pull/1318 +[#1331]: https://github.com/RustCrypto/utils/pull/1331 +[#1492]: https://github.com/RustCrypto/utils/pull/1492 +[#1493]: https://github.com/RustCrypto/utils/pull/1493 + +## 1.8.2 (2025-09-29) +### Changed +- Switch from `doc_auto_cfg` to `doc_cfg` ([#1228]) + +[#1228]: https://github.com/RustCrypto/utils/pull/1228 + +## 1.8.1 (2024-05-25) +### Changed +- Feature-gate AVX-512 support under `simd`; restores MSRV 1.60 ([#1073]) + +[#1073]: https://github.com/RustCrypto/utils/pull/1073 + +## 1.8.0 (2024-04-24) [YANKED] + +NOTE: yanked due concerns over the MSRV bump. See [#1067]. + +### Added +- Unsafe `zeroize_flat_type` function ([#1045]) +- `Zeroize` impls for `__m512` types on `x86`/`x86_64` targets ([#1052]) + +### Changed +- Bump MSRV to 1.72 ([#1052]) +- Always enable AArch64 support ([#1064]) + +### Fixed +- Nightly warnings ([#1055]) + +[#1045]: https://github.com/RustCrypto/utils/pull/1045 +[#1052]: https://github.com/RustCrypto/utils/pull/1052 +[#1055]: https://github.com/RustCrypto/utils/pull/1055 +[#1064]: https://github.com/RustCrypto/utils/pull/1064 +[#1067]: https://github.com/RustCrypto/utils/pull/1067 + +## 1.7.0 (2023-11-16) +### Changed +- Bump MSRV to 1.60 ([#900]) + +## 1.6.1 (2023-11-15) [YANKED] + +NOTE: yanked because [#900] bumped MSRV to 1.60, which vioates our MSRV policy. + +### Added +- Impl `Zeroize` for `MaybeUninit` ([#900]) + +### Removed +- Unnecessary `cfg`s on SIMD type impls ([#930]) + +[#900]: https://github.com/RustCrypto/utils/pull/900 +[#930]: https://github.com/RustCrypto/utils/pull/930 + +## 1.6.0 (2023-03-26) +### Added +- Impl `Zeroize` for `core::num::Wrapping` ([#818]) +- Impl `Zeroize` for `str` and `Box` ([#842]) + +### Changed +- 2021 edition upgrade; MSRV 1.56 ([#869]) + +[#818]: https://github.com/RustCrypto/utils/pull/818 +[#842]: https://github.com/RustCrypto/utils/pull/842 +[#869]: https://github.com/RustCrypto/utils/pull/869 + +## 1.5.7 (2022-07-20) +### Added +- Optional `serde` support ([#780]) + +[#780]: https://github.com/RustCrypto/utils/pull/780 + +## 1.5.6 (2022-06-29) +### Added +- `#[inline(always)]` annotations ([#772]) +- `#[ignore]` attribute on flaky CString test ([#776]) + +### Changed +- Factor integration tests into `tests/` ([#771]) + +[#771]: https://github.com/RustCrypto/utils/pull/771 +[#772]: https://github.com/RustCrypto/utils/pull/772 +[#776]: https://github.com/RustCrypto/utils/pull/776 + +## 1.5.5 (2022-04-30) +### Added +- Impl `Zeroize` for std::ffi::CString ([#759]) +- `AsRef` and `AsMut` impls for `Zeroizing` ([#761]) + +[#759]: https://github.com/RustCrypto/utils/pull/759 +[#761]: https://github.com/RustCrypto/utils/pull/761 + +## 1.5.4 (2022-03-16) +### Added +- Nightly-only support for zeroizing ARM64 SIMD registers ([#749]) + +[#749]: https://github.com/RustCrypto/utils/pull/749 + +## 1.5.3 (2022-02-25) +### Fixed +- Deriving `ZeroizeOnDrop` on `DerefMut` ([#739]) + +[#739]: https://github.com/RustCrypto/utils/pull/739 + +## 1.5.2 (2022-01-31) [YANKED] +### Fixed +- Ambiguous method for `AssertZeroizeOnDrop` ([#725]) + +[#725]: https://github.com/RustCrypto/utils/pull/725 + +## 1.5.1 (2022-01-27) [YANKED] +### Fixed +- Double `mut` on `AssertZeroizeOnDrop` ([#719]) + +[#719]: https://github.com/RustCrypto/utils/pull/719 + +## 1.5.0 (2022-01-14) [YANKED] +### Added +- `Zeroize` impls for `PhantomData`, `PhantomPinned`, and tuples with 0-10 elements ([#660]) +- `#[zeroize(bound = "T: MyTrait")]` ([#663]) +- `ZeroizeOnDrop` trait and custom derive ([#699], [#700], [#703]) + +[#660]: https://github.com/RustCrypto/utils/pull/660 +[#663]: https://github.com/RustCrypto/utils/pull/663 +[#699]: https://github.com/RustCrypto/utils/pull/699 +[#700]: https://github.com/RustCrypto/utils/pull/700 +[#703]: https://github.com/RustCrypto/utils/pull/703 + +## 1.4.3 (2021-11-04) +### Added +- Implement `Zeroize` for `NonZeroX` + +### Changed +- Moved to `RustCrypto/utils` repository + +## 1.4.2 (2021-09-21) +### Added +- Derive `Default` on `Zeroizing` + +## 1.4.1 (2021-07-20) +### Added +- Implement Zeroize for `[MaybeUninit]` + +## 1.4.0 (2021-07-18) +NOTE: This release includes an MSRV bump to Rust 1.51. Please use `zeroize = "1.3.0"` +if you would like to support older Rust versions. + +### Added +- Use const generics to impl `Zeroize` for `[Z; N]`; MSRV 1.51 +- `Zeroizing::clone_from` now zeroizes the destination before cloning + +## 1.3.0 (2021-04-19) +### Added +- impl `Zeroize` for `Box<[Z]>` +- Clear residual space within `Option` + +### Changed +- Ensure `Option` is `None` when zeroized +- Bump MSRV to 1.47 + +## 1.2.0 (2020-12-09) +### Added +- `Zeroize` support for x86(-64) SIMD registers + +### Changed +- Simplify `String::zeroize` +- MSRV 1.44+ + +## 1.1.1 (2020-09-15) +- Add `doc_cfg` +- zeroize entire capacity of `String` +- zeroize entire capacity of `Vec` + +## 1.1.0 (2019-12-02) +- Add `TryZeroize` trait +- Add `From` impl for `Zeroizing` +- Remove `bytes-preview` feature + +## 1.0.0 (2019-10-13) +- Initial 1.0 release 🎉 +- zeroize_derive: Remove legacy `no_drop` attribute support +- Rename `bytes` feature to `bytes-preview` +- Further relax `Zeroize` trait bounds for `Vec` +- Derive `Clone`, `Debug`, and `Eq` for `Zeroizing` + +## 1.0.0-pre (2019-09-30) +- Loosen `Vec` trait bounds for `Zeroize` + +## 0.10.1 (2019-09-03) +- (Optionally) Impl `Zeroize` for `Bytes` and `BytesMut` + +## 0.10.0 (2019-08-19) +Barring unforeseen circumstances, this release aims to be the last `0.x` +release prior to a `zeroize` 1.0 release. + +- Disable `zeroize_derive` Cargo feature by default +- Remove `std` feature in favor of `alloc`; MSRV 1.36+ +- Deprecate `#[zeroize(no_drop)]` attribute +- Use 1.0 `proc-macro2`, `quote`, and `syn` crates + +## 0.9.3 (2019-07-27) +- Improved attribute parser; fixes nightly build + +## 0.9.2 (2019-06-28) +- README.md: add Gitter badges; update image links + +## 0.9.1 (2019-06-04) +- Impl `Zeroize` for `Option` + +## 0.9.0 (2019-06-04) +**NOTICE**: This release changes the default behavior of `derive(Zeroize)` +to no longer derive a `Drop` impl. If you wish to derive `Drop`, you must +now explicitly add a `#[zeroize(drop)]` attribute on the type for which you +are deriving `Zeroize`. + +- Remove CPU fences +- Remove scary language about undefined behavior +- Bound blanket array impls on `Zeroize` instead of `DefaultIsZeroes` +- Require `zeroize(drop)` or `zeroize(no_drop)` attributes when deriving + `Zeroize` . +- Support stabilized 'alloc' crate + +## 0.8.0 (2019-05-20) +- Impl `Drop` by default when deriving `Zeroize` + +## 0.7.0 (2019-05-19) +- Use synstructure for custom derive +- Add explicit array impls for `DefaultIsZeroes` +- Remove `nightly` feature +- Add `Zeroizing` to zeroize values on drop + +## 0.6.0 (2019-03-23) +- Add ZeroizeOnDrop marker trait + custom derive +- Custom derive support for `Zeroize` +- Rename `ZeroizeWithDefault` to `DefaultIsZeroes` + +## 0.5.2 (2018-12-25) +- Add `debug_assert!` to ensure string interiors are zeroized + +## 0.5.1 (2018-12-24) +- Avoid re-exporting the whole prelude + +## 0.5.0 (2018-12-24) +This release is a rewrite which replaces FFI bindings to OS-specific APIs with +a pure Rust solution. + +- Use `core::sync::atomic` fences +- Test wasm target +- Rewrite using `core::ptr::write_volatile` + +## 0.4.2 (2018-10-12) +- Fix ldd scraper for older glibc versions + +## 0.4.1 (2018-10-12) +- Support musl-libc + +## 0.4.0 (2018-10-12) +- Impl `Zeroize` trait on concrete types + +## 0.3.0 (2018-10-11) +- Replace `secure_zero_memory` with `Zeroize` + +## 0.2.0 (2018-10-11) +- Add `Zeroize` trait + +## 0.1.2 (2018-10-03) +- README.md: Fix intrinsic links + +## 0.1.1 (2018-10-03) +- Documentation improvements + +## 0.1.0 (2018-10-03) +- Initial release diff --git a/http/vendor/zeroize/Cargo.lock b/http/vendor/zeroize/Cargo.lock new file mode 100644 index 0000000..68e95a6 --- /dev/null +++ b/http/vendor/zeroize/Cargo.lock @@ -0,0 +1,86 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "syn" +version = "2.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "zeroize" +version = "1.9.0" +dependencies = [ + "serde", + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c50655cbb0fe3fc43170059e702f1ce5e19b84cec58dc87b037a09935c2f328" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/http/vendor/zeroize/Cargo.toml b/http/vendor/zeroize/Cargo.toml new file mode 100644 index 0000000..6479967 --- /dev/null +++ b/http/vendor/zeroize/Cargo.toml @@ -0,0 +1,123 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies. +# +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. + +[package] +edition = "2024" +rust-version = "1.85" +name = "zeroize" +version = "1.9.0" +authors = ["The RustCrypto Project Developers"] +build = false +autolib = false +autobins = false +autoexamples = false +autotests = false +autobenches = false +description = """ +Securely clear secrets from memory with a simple trait built on +stable Rust primitives which guarantee memory is zeroed using an +operation will not be 'optimized away' by the compiler. +Uses a portable pure Rust implementation that works everywhere, +even WASM! +""" +documentation = "https://docs.rs/zeroize" +readme = "README.md" +keywords = [ + "memory", + "memset", + "secure", + "volatile", + "zero", +] +categories = [ + "cryptography", + "memory-management", + "no-std", + "os", +] +license = "Apache-2.0 OR MIT" +repository = "https://github.com/RustCrypto/utils" + +[package.metadata.docs.rs] +all-features = true + +[features] +aarch64 = [] +alloc = [] +default = ["alloc"] +derive = ["zeroize_derive"] +simd = [] +std = ["alloc"] + +[lib] +name = "zeroize" +path = "src/lib.rs" + +[[test]] +name = "alloc" +path = "tests/alloc.rs" + +[[test]] +name = "zeroize" +path = "tests/zeroize.rs" + +[[test]] +name = "zeroize_derive" +path = "tests/zeroize_derive.rs" + +[dependencies.serde] +version = "1" +optional = true +default-features = false + +[dependencies.zeroize_derive] +version = "1.5" +optional = true + +[lints.clippy] +borrow_as_ptr = "warn" +cast_lossless = "warn" +cast_possible_truncation = "warn" +cast_possible_wrap = "warn" +cast_precision_loss = "warn" +cast_sign_loss = "warn" +checked_conversions = "warn" +doc_markdown = "warn" +from_iter_instead_of_collect = "warn" +implicit_saturating_sub = "warn" +manual_assert = "warn" +map_unwrap_or = "warn" +missing_errors_doc = "warn" +missing_panics_doc = "warn" +mod_module_files = "warn" +must_use_candidate = "warn" +needless_range_loop = "allow" +ptr_as_ptr = "warn" +redundant_closure_for_method_calls = "warn" +ref_as_ptr = "warn" +return_self_not_must_use = "warn" +semicolon_if_nothing_returned = "warn" +std_instead_of_alloc = "warn" +std_instead_of_core = "warn" +trivially_copy_pass_by_ref = "warn" +undocumented_unsafe_blocks = "warn" +unnecessary_safety_comment = "warn" +unwrap_in_result = "warn" +unwrap_used = "warn" + +[lints.rust] +missing_copy_implementations = "warn" +missing_debug_implementations = "warn" +missing_docs = "warn" +trivial_casts = "warn" +trivial_numeric_casts = "warn" +unused_lifetimes = "warn" +unused_qualifications = "warn" diff --git a/http/vendor/zeroize/Cargo.toml.orig b/http/vendor/zeroize/Cargo.toml.orig new file mode 100644 index 0000000..c0d6884 --- /dev/null +++ b/http/vendor/zeroize/Cargo.toml.orig @@ -0,0 +1,38 @@ +[package] +name = "zeroize" +version = "1.9.0" +authors = ["The RustCrypto Project Developers"] +edition = "2024" +rust-version = "1.85" +documentation = "https://docs.rs/zeroize" +readme = "README.md" +repository = "https://github.com/RustCrypto/utils" +license = "Apache-2.0 OR MIT" +keywords = ["memory", "memset", "secure", "volatile", "zero"] +categories = ["cryptography", "memory-management", "no-std", "os"] +description = """ +Securely clear secrets from memory with a simple trait built on +stable Rust primitives which guarantee memory is zeroed using an +operation will not be 'optimized away' by the compiler. +Uses a portable pure Rust implementation that works everywhere, +even WASM! +""" + +[dependencies] +serde = { version = "1", default-features = false, optional = true } +zeroize_derive = { version = "1.5", optional = true } + +[features] +default = ["alloc"] +alloc = [] +std = ["alloc"] + +aarch64 = [] # NOTE: vestigial no-op feature; AArch64 support is always enabled now +derive = ["zeroize_derive"] +simd = [] # NOTE: vestigial no-op feature; always enabled + +[lints] +workspace = true + +[package.metadata.docs.rs] +all-features = true diff --git a/http/vendor/zeroize/LICENSE-APACHE b/http/vendor/zeroize/LICENSE-APACHE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/http/vendor/zeroize/LICENSE-APACHE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/http/vendor/zeroize/LICENSE-MIT b/http/vendor/zeroize/LICENSE-MIT new file mode 100644 index 0000000..3cd1ff7 --- /dev/null +++ b/http/vendor/zeroize/LICENSE-MIT @@ -0,0 +1,25 @@ +Copyright (c) 2018-2026 The RustCrypto Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/http/vendor/zeroize/README.md b/http/vendor/zeroize/README.md new file mode 100644 index 0000000..9db4cca --- /dev/null +++ b/http/vendor/zeroize/README.md @@ -0,0 +1,96 @@ +# [RustCrypto]: zeroize + +[![Crate][crate-image]][crate-link] +[![Docs][docs-image]][docs-link] +[![Build Status][build-image]][build-link] +![Apache 2.0/MIT Licensed][license-image] +![MSRV][rustc-image] +[![Project Chat][chat-image]][chat-link] + +Securely zero memory (a.k.a. [zeroize]) while avoiding compiler optimizations. + +This crate implements a portable approach to securely zeroing memory using +techniques which guarantee they won't be "optimized away" by the compiler. + +The [`Zeroize` trait] is the crate's primary API. + +[Documentation] + +## About + +[Zeroing memory securely is hard] - compilers optimize for performance, and +in doing so they love to "optimize away" unnecessary zeroing calls. There are +many documented "tricks" to attempt to avoid these optimizations and ensure +that a zeroing routine is performed reliably. + +This crate isn't about tricks: it uses [core::ptr::write_volatile] +and [core::sync::atomic] memory fences to provide easy-to-use, portable +zeroing behavior which works on all of Rust's core number types and slices +thereof, implemented in pure Rust with no usage of FFI or assembly. + +- No insecure fallbacks! +- No dependencies! +- No FFI or inline assembly! **WASM friendly** (and tested)! +- `#![no_std]` i.e. **embedded-friendly**! +- No functionality besides securely zeroing memory! +- (Optional) Custom derive support for zeroing complex structures + +## Minimum Supported Rust Version + +Requires Rust **1.85** or newer. + +In the future, we reserve the right to change MSRV (i.e. MSRV is out-of-scope for this crate's +semantic versioning guarantees). + +## Example + +``` +use zeroize::Zeroize; + +// Protip: don't embed secrets in your source code. +// This is just an example. +let mut secret = b"Air shield password: 1,2,3,4,5".to_vec(); +// [ ... ] open the air shield here + +// Now that we're done using the secret, zero it out. +secret.zeroize(); +``` + +## License + +Licensed under either of: + +* [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) +* [MIT license](http://opensource.org/licenses/MIT) + +at your option. + +### Contribution + +Unless you explicitly state otherwise, any contribution intentionally submitted +for inclusion in the work by you, as defined in the Apache-2.0 license, shall be +dual licensed as above, without any additional terms or conditions. + +[//]: # (badges) + +[crate-image]: https://img.shields.io/crates/v/zeroize.svg +[crate-link]: https://crates.io/crates/zeroize +[build-image]: https://github.com/RustCrypto/utils/actions/workflows/zeroize.yml/badge.svg?branch=master +[build-link]: https://github.com/RustCrypto/utils/actions/workflows/zeroize.yml?query=branch:master +[docs-image]: https://docs.rs/zeroize/badge.svg +[docs-link]: https://docs.rs/zeroize/ +[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg +[rustc-image]: https://img.shields.io/badge/rustc-1.85+-blue.svg +[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg +[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260052-utils + +[//]: # (general links) + +[RustCrypto]: https://github.com/RustCrypto +[zeroize]: https://en.wikipedia.org/wiki/Zeroisation +[`Zeroize` trait]: https://docs.rs/zeroize/latest/zeroize/trait.Zeroize.html +[Documentation]: https://docs.rs/zeroize/ +[Zeroing memory securely is hard]: http://www.daemonology.net/blog/2014-09-04-how-to-zero-a-buffer.html +[core::ptr::write_volatile]: https://doc.rust-lang.org/core/ptr/fn.write_volatile.html +[core::sync::atomic]: https://doc.rust-lang.org/stable/core/sync/atomic/index.html +[good cryptographic hygiene]: https://github.com/veorq/cryptocoding#clean-memory-of-secret-data diff --git a/http/vendor/zeroize/src/aarch64.rs b/http/vendor/zeroize/src/aarch64.rs new file mode 100644 index 0000000..68c5998 --- /dev/null +++ b/http/vendor/zeroize/src/aarch64.rs @@ -0,0 +1,31 @@ +//! [`Zeroize`] impls for ARM64 SIMD registers. + +use crate::{Zeroize, optimization_barrier, volatile_write}; + +use core::arch::aarch64::*; + +macro_rules! impl_zeroize_for_simd_register { + ($($type:ty),* $(,)?) => { + $( + impl Zeroize for $type { + #[inline] + fn zeroize(&mut self) { + volatile_write(self, unsafe { core::mem::zeroed() }); + optimization_barrier(self); + } + } + )+ + }; +} + +// TODO(tarcieri): other NEON register types? +impl_zeroize_for_simd_register! { + uint8x8_t, + uint8x16_t, + uint16x4_t, + uint16x8_t, + uint32x2_t, + uint32x4_t, + uint64x1_t, + uint64x2_t, +} diff --git a/http/vendor/zeroize/src/barrier.rs b/http/vendor/zeroize/src/barrier.rs new file mode 100644 index 0000000..d61abc5 --- /dev/null +++ b/http/vendor/zeroize/src/barrier.rs @@ -0,0 +1,102 @@ +/// Observe the referenced data and prevent the compiler from removing previous writes to it. +/// +/// This function acts like [`core::hint::black_box`] but takes a reference and +/// does not return the passed value. +/// +/// It's implemented using the [`core::arch::asm!`] macro on target arches where `asm!` is stable, +/// i.e. `aarch64`, `arm`, `arm64ec`, `loongarch64`, `riscv32`, `riscv64`, `s390x`, `x86`, and +/// `x86_64`. +/// +/// On all other targets it's implemented using [`core::hint::black_box`] and custom `black_box` +/// implemented using `#[inline(never)]` and `read_volatile`. +/// +/// # Examples +/// ``` +/// use core::num::NonZeroU32; +/// use zeroize::{ZeroizeOnDrop, zeroize_flat_type}; +/// +/// # type ThirdPartyType = u32; +/// +/// struct DataToZeroize { +/// buf: [u8; 32], +/// // `ThirdPartyType` can be a type with private fields +/// // defined in a third-party crate and which does not implement +/// // `Zeroize` or zeroization on drop. +/// data: ThirdPartyType, +/// pos: NonZeroU32, +/// } +/// +/// struct SomeMoreFlatData(u64); +/// +/// impl Drop for DataToZeroize { +/// fn drop(&mut self) { +/// self.buf = [0u8; 32]; +/// self.data = ThirdPartyType::default(); +/// self.pos = NonZeroU32::new(32).unwrap(); +/// zeroize::optimization_barrier(self); +/// } +/// } +/// +/// impl zeroize::ZeroizeOnDrop for DataToZeroize {} +/// +/// let mut data = DataToZeroize { +/// buf: [3u8; 32], +/// data: ThirdPartyType::default(), +/// pos: NonZeroU32::new(32).unwrap(), +/// }; +/// +/// // data gets zeroized when dropped +/// ``` +/// +/// Note that erasure of `ThirdPartyType` demonstrated above can be fragile if it contains +/// `MaybeUninit` or `union` data. It also does not perform erasure of types like `Box` or `Vec`. +pub fn optimization_barrier(val: &T) { + #[cfg(all( + not(miri), + any( + target_arch = "aarch64", + target_arch = "arm", + target_arch = "arm64ec", + target_arch = "loongarch64", + target_arch = "riscv32", + target_arch = "riscv64", + target_arch = "s390x", + target_arch = "x86", + target_arch = "x86_64", + ) + ))] + unsafe { + core::arch::asm!( + "# {}", + in(reg) core::ptr::from_ref::(val).cast::<()>(), + options(readonly, preserves_flags, nostack), + ); + } + #[cfg(not(all( + not(miri), + any( + target_arch = "aarch64", + target_arch = "arm", + target_arch = "arm64ec", + target_arch = "loongarch64", + target_arch = "riscv32", + target_arch = "riscv64", + target_arch = "s390x", + target_arch = "x86", + target_arch = "x86_64", + ) + )))] + { + /// Custom version of `core::hint::black_box` implemented using + /// `#[inline(never)]` and `read_volatile`. + #[inline(never)] + fn custom_black_box(p: *const u8) { + let _ = unsafe { core::ptr::read_volatile(p) }; + } + + core::hint::black_box(val); + if size_of_val(val) > 0 { + custom_black_box(core::ptr::from_ref(val).cast::()); + } + } +} diff --git a/http/vendor/zeroize/src/lib.rs b/http/vendor/zeroize/src/lib.rs new file mode 100644 index 0000000..6f0a303 --- /dev/null +++ b/http/vendor/zeroize/src/lib.rs @@ -0,0 +1,850 @@ +#![no_std] +#![cfg_attr(docsrs, feature(doc_cfg))] +#![doc = include_str!("../README.md")] +#![doc( + html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg", + html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg" +)] +#![allow(clippy::undocumented_unsafe_blocks, reason = "TODO")] + +//! ## Usage +//! +//! ### Traits +//! +//! The [`Zeroize`] trait is the core API of this crate. It's intended to be impl'd on values that +//! may-or-may-not contain secrets, for example the `zeroize` crate itself defines them on the +//! core integers e.g. `u8`, `u16`, `i8`, `i16`, as well as arrays thereof. Its core API is +//! [`Zeroize::zeroize`], a method which takes `&mut self` and writes over the type's internal +//! memory with some placeholder value, typically some form of `0`. +//! +//! The [`DefaultIsZeroes`] marker trait can be impl'd on types which have a [`Default`] impl that +//! can be used for [`Zeroize`]. Types which implement this trait receive a blanket impl of the +//! [`Zeroize`] trait. +//! +//! We recommend that types which always contain secrets, and especially ones which need to maintain +//! complex invariants, do NOT impl the [`Zeroize`] trait, but instead provide a [`Drop`] impl which +//! takes care of erasing the secret values from memory directly. Such types can mark that they're +//! doing this with the [`ZeroizeOnDrop`] marker trait. Note that [`ZeroizeOnDrop`] is *just* a +//! marker trait, and making it actually work requires actually providing a [`Drop`] impl which +//! takes care of zeroizing secrets. +//! +//! Why not impl [`Zeroize`] for such types, e.g. a `SecretKey` type? The problem is [`Zeroize`] +//! would effectively leave such types in an invalid state, and a sort of use-after-zeroize +//! condition becomes possible. For that reason, we recommend these types automatically handle +//! zeroization in their [`Drop`] handler alone. +//! +//! ### Supported types +//! +//! The [`Zeroize`] trait is impl'd on all of Rust's core scalar types including +//! integers, floats, `bool`, and `char`. +//! +//! Additionally, it's implemented on slices and `IterMut`s of the above types. +//! +//! When the `alloc` feature is enabled (which it is by default), it's also +//! impl'd for `Vec` for the above types as well as `String`, where it provides +//! [`Vec::clear`] / [`String::clear`]-like behavior (truncating to zero-length) +//! but ensures the backing memory is securely zeroed with some caveats. +//! +//! With the `std` feature enabled (which it is **not** by default), [`Zeroize`] +//! is also implemented for [`CString`]. After calling `zeroize()` on a `CString`, +//! its internal buffer will contain exactly one nul byte. The backing +//! memory is zeroed by converting it to a `Vec` and back into a `CString`. +//! (NOTE: see "Stack/Heap Zeroing Notes" for important `Vec`/`String`/`CString` details) +//! +//! [`CString`]: https://doc.rust-lang.org/std/ffi/struct.CString.html +//! +//! The [`DefaultIsZeroes`] marker trait can be impl'd on types which also +//! impl [`Default`], which implements [`Zeroize`] by overwriting a value with +//! the default value. +//! +//! ### Custom Derive Support +//! +//! This crate has custom derive support for the `Zeroize` trait, +//! gated under the `zeroize` crate's `zeroize_derive` Cargo feature, +//! which automatically calls `zeroize()` on all members of a struct +//! or tuple struct. +//! +//! Attributes supported for `Zeroize`: +//! +//! On the item level: +//! - `#[zeroize(drop)]`: *deprecated* use `ZeroizeOnDrop` instead +//! - `#[zeroize(bound = "T: MyTrait")]`: this replaces any trait bounds +//! inferred by zeroize +//! +//! On the field level: +//! - `#[zeroize(skip)]`: skips this field or variant when calling `zeroize()` +//! +//! Attributes supported for `ZeroizeOnDrop`: +//! +//! On the field level: +//! - `#[zeroize(skip)]`: skips this field or variant when calling `zeroize()` +//! +//! Example which derives `Drop`: +//! +//! ``` +//! # #[cfg(feature = "zeroize_derive")] +//! # { +//! use zeroize::{Zeroize, ZeroizeOnDrop}; +//! +//! // This struct will be zeroized on drop +//! #[derive(Zeroize, ZeroizeOnDrop)] +//! struct MyStruct([u8; 32]); +//! # } +//! ``` +//! +//! Example which does not derive `Drop` (useful for e.g. `Copy` types) +//! +//! ``` +//! #[cfg(feature = "zeroize_derive")] +//! # { +//! use zeroize::Zeroize; +//! +//! // This struct will *NOT* be zeroized on drop +//! #[derive(Copy, Clone, Zeroize)] +//! struct MyStruct([u8; 32]); +//! # } +//! ``` +//! +//! Example which only derives `Drop`: +//! +//! ``` +//! # #[cfg(feature = "zeroize_derive")] +//! # { +//! use zeroize::ZeroizeOnDrop; +//! +//! // This struct will be zeroized on drop +//! #[derive(ZeroizeOnDrop)] +//! struct MyStruct([u8; 32]); +//! # } +//! ``` +//! +//! ### `Zeroizing`: wrapper for zeroizing arbitrary values on drop +//! +//! `Zeroizing` is a generic wrapper type that impls `Deref` +//! and `DerefMut`, allowing access to an inner value of type `Z`, and also +//! impls a `Drop` handler which calls `zeroize()` on its contents: +//! +//! ``` +//! use zeroize::Zeroizing; +//! +//! fn use_secret() { +//! let mut secret = Zeroizing::new([0u8; 5]); +//! +//! // Set the air shield password +//! // Protip (again): don't embed secrets in your source code. +//! secret.copy_from_slice(&[1, 2, 3, 4, 5]); +//! assert_eq!(secret.as_ref(), &[1, 2, 3, 4, 5]); +//! +//! // The contents of `secret` will be automatically zeroized on drop +//! } +//! +//! # use_secret() +//! ``` +//! +//! ## What guarantees does this crate provide? +//! +//! This crate guarantees the zeroing operation can't be "optimized away" by the compiler, as +//! ensured by LLVM's volatile semantics. +//! +//! Previously there were worries that the approach used by this crate (mixing volatile and +//! non-volatile accesses) was undefined behavior due to language contained +//! in the documentation for `write_volatile`, however after some discussion +//! within the [Unsafe Code Guidelines Working Group], [these remarks have been removed] and the +//! specific usage pattern in this crate is considered to be well-defined. +//! +//! All of that said, there is still potential for microarchitectural attacks +//! (ala Spectre/Meltdown) to leak "zeroized" secrets through covert channels. +//! This crate makes no guarantees that zeroized values cannot be leaked +//! through such channels, as they represent flaws in the underlying hardware. +//! +//! ## Stack/Heap Zeroing Notes +//! +//! This crate can be used to zero values from either the stack or the heap. We recommend storing +//! sensitive data on the heap whenever possible to reduce the potential for making copies in memory +//! via Rust move semantics, however note that stack spilling and other optimizations may leave +//! temporary copies of data from the heap on the stack. +//! +//! [`zeroize_stack`] can be used to zeroize stack memory. +//! +//! [`Pin`][`core::pin::Pin`] can be leveraged in conjunction with this crate to ensure data kept +//! on the stack isn't moved. +//! +//! The `Zeroize` impls for `Vec`, `String` and `CString` zeroize the entire capacity of their +//! backing buffer, but cannot guarantee copies of the data were not previously made by buffer +//! reallocation. It's therefore important when attempting to zeroize such buffers to initialize +//! them to the correct capacity, and take care to prevent subsequent reallocation. +//! +//! The [`secrecy`] crate provides higher-level abstractions for eliminating +//! usage patterns which can cause reallocations: +//! +//! [`secrecy`]: https://docs.rs/secrecy +//! +//! ## What about: clearing registers, `mlock()`, `mprotect()`, etc? +//! +//! This crate is focused on providing simple, unobtrusive support for reliably +//! zeroing memory using the best approach possible on stable Rust. +//! +//! Clearing registers is a difficult problem that can't easily be solved by +//! something like a crate, and requires either inline ASM or rustc support. +//! See for background on +//! this particular problem. +//! +//! Other memory protection mechanisms are interesting and useful, but often +//! overkill (e.g. defending against RAM scraping or attackers with swap access). +//! In as much as there may be merit to these approaches, there are also many +//! other crates that already implement more sophisticated memory protections. +//! Such protections are explicitly out-of-scope for this crate. +//! +//! Zeroing memory is [good cryptographic hygiene] and this crate seeks to promote +//! it in the most unobtrusive manner possible. This includes omitting complex +//! `unsafe` memory protection systems and just trying to make the best memory +//! zeroing crate available. +//! +//! [Unsafe Code Guidelines Working Group]: https://github.com/rust-lang/unsafe-code-guidelines +//! [these remarks have been removed]: https://github.com/rust-lang/rust/pull/60972 +//! [good cryptographic hygiene]: https://github.com/veorq/cryptocoding#clean-memory-of-secret-data +//! [`Ordering::SeqCst`]: core::sync::atomic::Ordering::SeqCst + +#[cfg(feature = "alloc")] +extern crate alloc; +#[cfg(feature = "std")] +extern crate std; + +#[cfg(feature = "zeroize_derive")] +pub use zeroize_derive::{Zeroize, ZeroizeOnDrop}; + +#[cfg(target_arch = "aarch64")] +mod aarch64; +#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +mod x86; + +mod barrier; +pub use barrier::optimization_barrier; + +mod stack; +pub use stack::zeroize_stack; + +use core::{ + marker::{PhantomData, PhantomPinned}, + mem::{MaybeUninit, size_of}, + num::{ + self, NonZeroI8, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI128, NonZeroIsize, NonZeroU8, + NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU128, NonZeroUsize, + }, + ops, ptr, + slice::IterMut, +}; + +#[cfg(feature = "alloc")] +use alloc::{boxed::Box, string::String, vec::Vec}; + +#[cfg(feature = "std")] +use std::ffi::CString; + +/// Trait for securely erasing values from memory. +pub trait Zeroize { + /// Zero out this object from memory using Rust intrinsics which ensure the + /// zeroization operation is not "optimized away" by the compiler. + fn zeroize(&mut self); +} + +/// Marker trait signifying that this type will [`Zeroize::zeroize`] itself on [`Drop`]. +pub trait ZeroizeOnDrop {} + +/// Marker trait for types whose [`Default`] is the desired zeroization result +pub trait DefaultIsZeroes: Copy + Default + Sized {} + +/// Fallible trait for representing cases where zeroization may or may not be +/// possible. +/// +/// This is primarily useful for scenarios like reference counted data, where +/// zeroization is only possible when the last reference is dropped. +pub trait TryZeroize { + /// Try to zero out this object from memory using Rust intrinsics which + /// ensure the zeroization operation is not "optimized away" by the + /// compiler. + #[must_use] + fn try_zeroize(&mut self) -> bool; +} + +impl Zeroize for Z +where + Z: DefaultIsZeroes, +{ + fn zeroize(&mut self) { + volatile_write(self, Z::default()); + optimization_barrier(self); + } +} + +macro_rules! impl_zeroize_with_default { + ($($type:ty),+) => { + $(impl DefaultIsZeroes for $type {})+ + }; +} + +#[rustfmt::skip] +impl_zeroize_with_default! { + PhantomPinned, (), bool, char, + f32, f64, + i8, i16, i32, i64, i128, isize, + u8, u16, u32, u64, u128, usize +} + +/// `PhantomPinned` is zero sized so provide a `ZeroizeOnDrop` implementation. +impl ZeroizeOnDrop for PhantomPinned {} + +/// `()` is zero sized so provide a `ZeroizeOnDrop` implementation. +impl ZeroizeOnDrop for () {} + +macro_rules! impl_zeroize_for_non_zero { + ($($type:ty),+) => { + $( + impl Zeroize for $type { + fn zeroize(&mut self) { + const ONE: $type = match <$type>::new(1) { + Some(one) => one, + None => unreachable!(), + }; + volatile_write(self, ONE); + optimization_barrier(self); + } + } + )+ + }; +} + +impl_zeroize_for_non_zero!( + NonZeroI8, + NonZeroI16, + NonZeroI32, + NonZeroI64, + NonZeroI128, + NonZeroIsize, + NonZeroU8, + NonZeroU16, + NonZeroU32, + NonZeroU64, + NonZeroU128, + NonZeroUsize +); + +impl Zeroize for num::Wrapping +where + Z: Zeroize, +{ + fn zeroize(&mut self) { + self.0.zeroize(); + } +} + +/// Impl [`Zeroize`] on arrays of types that impl [`Zeroize`]. +impl Zeroize for [Z; N] +where + Z: Zeroize, +{ + fn zeroize(&mut self) { + self.iter_mut().zeroize(); + } +} + +/// Impl [`ZeroizeOnDrop`] on arrays of types that impl [`ZeroizeOnDrop`]. +impl ZeroizeOnDrop for [Z; N] where Z: ZeroizeOnDrop {} + +impl Zeroize for IterMut<'_, Z> +where + Z: Zeroize, +{ + fn zeroize(&mut self) { + for elem in self { + elem.zeroize(); + } + } +} + +impl Zeroize for Option +where + Z: Zeroize, +{ + fn zeroize(&mut self) { + if let Some(value) = self { + value.zeroize(); + + // Ensures self is None and that the value was dropped. Without the take, the drop + // of the (zeroized) value isn't called, which might lead to a leak or other + // unexpected behavior. For example, if this were Option>, the above call to + // zeroize would not free the allocated memory, but the `take` call will. + self.take(); + } + + // Ensure that if the `Option` were previously `Some` but a value was copied/moved out + // that the remaining space in the `Option` is zeroized. + // + // Safety: + // + // The memory pointed to by `self` is valid for `size_of::()` bytes. + // It is also properly aligned, because `u8` has an alignment of `1`. + unsafe { + volatile_set( + ptr::from_mut::(self).cast::(), + 0, + size_of::(), + ); + } + + // Ensures self is overwritten with the `None` bit pattern. volatile_write can't be + // used because Option is not copy. + // + // Safety: + // + // self is safe to replace with `None`, which the take() call above should have + // already done semantically. Any value which needed to be dropped will have been + // done so by take(). + unsafe { ptr::write_volatile(self, None) } + + optimization_barrier(self); + } +} + +impl ZeroizeOnDrop for Option where Z: ZeroizeOnDrop {} + +/// Impl [`Zeroize`] on [`MaybeUninit`] types. +/// +/// This fills the memory with zeroes. +/// Note that this ignore invariants that `Z` might have, because +/// [`MaybeUninit`] removes all invariants. +impl Zeroize for MaybeUninit { + fn zeroize(&mut self) { + // Safety: + // `MaybeUninit` is valid for any byte pattern, including zeros. + unsafe { ptr::write_volatile(self, MaybeUninit::zeroed()) } + optimization_barrier(self); + } +} + +/// Impl [`Zeroize`] on slices of [`MaybeUninit`] types. +/// +/// This impl can eventually be optimized using an memset intrinsic, +/// such as [`core::intrinsics::volatile_set_memory`]. +/// +/// This fills the slice with zeroes. +/// +/// Note that this ignore invariants that `Z` might have, because +/// [`MaybeUninit`] removes all invariants. +impl Zeroize for [MaybeUninit] { + fn zeroize(&mut self) { + let ptr = self.as_mut_ptr().cast::>(); + let size = self.len().checked_mul(size_of::()).expect("overflow"); + assert!(isize::try_from(size).is_ok()); + + // Safety: + // + // This is safe, because every valid pointer is well aligned for u8 + // and it is backed by a single allocated object for at least `self.len() * size_pf::()` bytes. + // and 0 is a valid value for `MaybeUninit` + // The memory of the slice should not wrap around the address space. + unsafe { volatile_set(ptr, MaybeUninit::zeroed(), size) } + optimization_barrier(self); + } +} + +/// Impl [`Zeroize`] on slices of types that can be zeroized with [`Default`]. +/// +/// This impl can eventually be optimized using an memset intrinsic, +/// such as [`core::intrinsics::volatile_set_memory`]. For that reason the +/// blanket impl on slices is bounded by [`DefaultIsZeroes`]. +/// +/// To zeroize a mut slice of `Z: Zeroize` which does not impl +/// [`DefaultIsZeroes`], call `iter_mut().zeroize()`. +impl Zeroize for [Z] +where + Z: DefaultIsZeroes, +{ + fn zeroize(&mut self) { + assert!(isize::try_from(self.len()).is_ok()); + + // Safety: + // + // This is safe, because the slice is well aligned and is backed by a single allocated + // object for at least `self.len()` elements of type `Z`. + // `self.len()` is also not larger than an `isize`, because of the assertion above. + // The memory of the slice should not wrap around the address space. + unsafe { volatile_set(self.as_mut_ptr(), Z::default(), self.len()) }; + optimization_barrier(self); + } +} + +impl Zeroize for str { + fn zeroize(&mut self) { + // Safety: + // A zeroized byte slice is a valid UTF-8 string. + unsafe { self.as_bytes_mut().zeroize() } + } +} + +/// [`PhantomData`] is always zero sized so provide a [`Zeroize`] implementation. +impl Zeroize for PhantomData { + fn zeroize(&mut self) {} +} + +/// [`PhantomData` is always zero sized so provide a `ZeroizeOnDrop` implementation. +impl ZeroizeOnDrop for PhantomData {} + +macro_rules! impl_zeroize_tuple { + ( $( $type_name:ident ),+ ) => { + impl<$($type_name: Zeroize),+> Zeroize for ($($type_name,)+) { + fn zeroize(&mut self) { + #[allow(non_snake_case)] + let ($($type_name,)+) = self; + $($type_name.zeroize());+ + } + } + + impl<$($type_name: ZeroizeOnDrop),+> ZeroizeOnDrop for ($($type_name,)+) { } + } +} + +// Generic implementations for tuples up to 10 parameters. +impl_zeroize_tuple!(A); +impl_zeroize_tuple!(A, B); +impl_zeroize_tuple!(A, B, C); +impl_zeroize_tuple!(A, B, C, D); +impl_zeroize_tuple!(A, B, C, D, E); +impl_zeroize_tuple!(A, B, C, D, E, F); +impl_zeroize_tuple!(A, B, C, D, E, F, G); +impl_zeroize_tuple!(A, B, C, D, E, F, G, H); +impl_zeroize_tuple!(A, B, C, D, E, F, G, H, I); +impl_zeroize_tuple!(A, B, C, D, E, F, G, H, I, J); + +#[cfg(feature = "alloc")] +impl Zeroize for Vec +where + Z: Zeroize, +{ + /// "Best effort" zeroization for `Vec`. + /// + /// Ensures the entire capacity of the `Vec` is zeroed. Cannot ensure that + /// previous reallocations did not leave values on the heap. + fn zeroize(&mut self) { + // Zeroize all the initialized elements. + self.iter_mut().zeroize(); + + // Set the Vec's length to 0 and drop all the elements. + self.clear(); + + // Zero the full capacity of `Vec`. + self.spare_capacity_mut().zeroize(); + } +} + +#[cfg(feature = "alloc")] +impl ZeroizeOnDrop for Vec where Z: ZeroizeOnDrop {} + +#[cfg(feature = "alloc")] +impl Zeroize for Box<[Z]> +where + Z: Zeroize, +{ + /// Unlike `Vec`, `Box<[Z]>` cannot reallocate, so we can be sure that we are not leaving + /// values on the heap. + fn zeroize(&mut self) { + self.iter_mut().zeroize(); + } +} + +#[cfg(feature = "alloc")] +impl ZeroizeOnDrop for Box<[Z]> where Z: ZeroizeOnDrop {} + +#[cfg(feature = "alloc")] +impl Zeroize for Box { + fn zeroize(&mut self) { + self.as_mut().zeroize(); + } +} + +#[cfg(feature = "alloc")] +impl Zeroize for String { + fn zeroize(&mut self) { + unsafe { self.as_mut_vec() }.zeroize(); + } +} + +#[cfg(feature = "std")] +impl Zeroize for CString { + fn zeroize(&mut self) { + use core::mem; + + // mem::take uses replace internally to swap the pointer + // Unfortunately this results in an allocation for a Box::new(&[0]) as CString must + // contain a trailing zero byte + let this = mem::take(self); + + // - CString::into_bytes_with_nul calls ::into_vec which takes ownership of the heap pointer + // as a Vec + // - Calling .zeroize() on the resulting vector clears out the bytes + // From: https://github.com/RustCrypto/utils/pull/759#issuecomment-1087976570 + let mut buf = this.into_bytes_with_nul(); + buf.zeroize(); + + // expect() should never fail, because zeroize() truncates the Vec + let zeroed = CString::new(buf).expect("buf not truncated"); + + // Replace self by the zeroed CString to maintain the original ptr of the buffer + let _ = mem::replace(self, zeroed); + } +} + +/// `Zeroizing` is a wrapper for any `Z: Zeroize` type which implements a +/// `Drop` handler which zeroizes dropped values. +/// +/// `Zeroizing` is defined with `repr(transparent)`, which means it is +/// guaranteed to have the same physical representation as the underlying type. +#[derive(Debug, Default, Eq, PartialEq)] +#[repr(transparent)] +pub struct Zeroizing(Z); + +impl Zeroizing +where + Z: Zeroize, +{ + /// Move value inside a `Zeroizing` wrapper which ensures it will be + /// zeroized when it's dropped. + #[inline(always)] + pub fn new(value: Z) -> Self { + Self(value) + } +} + +impl Clone for Zeroizing { + #[inline(always)] + fn clone(&self) -> Self { + Self(self.0.clone()) + } + + #[inline(always)] + fn clone_from(&mut self, source: &Self) { + self.0.zeroize(); + self.0.clone_from(&source.0); + } +} + +impl From for Zeroizing +where + Z: Zeroize, +{ + #[inline(always)] + fn from(value: Z) -> Zeroizing { + Zeroizing(value) + } +} + +impl ops::Deref for Zeroizing +where + Z: Zeroize + ?Sized, +{ + type Target = Z; + + #[inline(always)] + fn deref(&self) -> &Z { + &self.0 + } +} + +impl ops::DerefMut for Zeroizing +where + Z: Zeroize + ?Sized, +{ + #[inline(always)] + fn deref_mut(&mut self) -> &mut Z { + &mut self.0 + } +} + +impl AsRef for Zeroizing +where + T: ?Sized, + Z: AsRef + Zeroize + ?Sized, +{ + #[inline(always)] + fn as_ref(&self) -> &T { + self.0.as_ref() + } +} + +impl AsMut for Zeroizing +where + T: ?Sized, + Z: AsMut + Zeroize + ?Sized, +{ + #[inline(always)] + fn as_mut(&mut self) -> &mut T { + self.0.as_mut() + } +} + +impl Zeroize for Zeroizing +where + Z: Zeroize + ?Sized, +{ + fn zeroize(&mut self) { + self.0.zeroize(); + } +} + +impl ZeroizeOnDrop for Zeroizing where Z: Zeroize + ?Sized {} + +impl Drop for Zeroizing +where + Z: Zeroize + ?Sized, +{ + fn drop(&mut self) { + self.0.zeroize(); + } +} + +#[cfg(feature = "serde")] +impl serde::Serialize for Zeroizing +where + Z: Zeroize + serde::Serialize + ?Sized, +{ + #[inline(always)] + fn serialize(&self, serializer: S) -> Result + where + S: serde::Serializer, + { + self.0.serialize(serializer) + } +} + +#[cfg(feature = "serde")] +impl<'de, Z> serde::Deserialize<'de> for Zeroizing +where + Z: Zeroize + serde::Deserialize<'de>, +{ + #[inline(always)] + fn deserialize(deserializer: D) -> Result + where + D: serde::Deserializer<'de>, + { + Ok(Self(Z::deserialize(deserializer)?)) + } +} + +/// Perform a volatile write to the destination +#[inline(always)] +fn volatile_write(dst: &mut T, src: T) { + unsafe { ptr::write_volatile(dst, src) } +} + +/// Perform a volatile `memset` operation which fills a slice with a value +/// +/// # Safety +/// The memory pointed to by `dst` must be a single allocated object that is valid for `count` +/// contiguous elements of `T`. +/// `count` must not be larger than an `isize`. +/// `dst` being offset by `size_of:: * count` bytes must not wrap around the address space. +/// Also `dst` must be properly aligned. +#[inline(always)] +unsafe fn volatile_set(dst: *mut T, src: T, count: usize) { + // TODO(tarcieri): use `volatile_set_memory` when stabilized + for i in 0..count { + // Safety: + // + // This is safe because there is room for at least `count` objects of type `T` in the + // allocation pointed to by `dst`, because `count <= isize::MAX` and because + // `dst.add(count)` must not wrap around the address space. + let ptr = unsafe { dst.add(i) }; + + // Safety: + // + // This is safe, because the pointer is valid and because `dst` is well aligned for `T` and + // `ptr` is an offset of `dst` by a multiple of `size_of::()` bytes. + unsafe { ptr::write_volatile(ptr, src) }; + } +} + +/// Zeroizes a flat type/struct. Only zeroizes the values that it owns, and it does not work on +/// dynamically sized values or trait objects. It would be inefficient to use this function on a +/// type that already implements `ZeroizeOnDrop`. +/// +/// # Safety +/// - The type must not contain references to outside data or dynamically sized data, such as +/// `Vec` or `String`. +/// - Values stored in the type must not have `Drop` impls. +/// - This function can invalidate the type if it is used after this function is called on it. +/// It is advisable to call this function only in `impl Drop`. +/// - The bit pattern of all zeroes must be valid for the data being zeroized. This may not be +/// true for enums and pointers. +/// +/// # Incompatible data types +/// Some data types that cannot be safely zeroized using `zeroize_flat_type` include, +/// but are not limited to: +/// - References: `&T` and `&mut T` +/// - Non-nullable types: `NonNull`, `NonZeroU32`, etc. +/// - Enums with explicit non-zero tags. +/// - Smart pointers and collections: `Arc`, `Box`, `Vec`, `HashMap`, `String`, etc. +/// +/// # Examples +/// Safe usage for a struct containing strictly flat data: +/// ``` +/// use zeroize::{ZeroizeOnDrop, zeroize_flat_type}; +/// +/// struct DataToZeroize { +/// flat_data_1: [u8; 32], +/// flat_data_2: SomeMoreFlatData, +/// } +/// +/// struct SomeMoreFlatData(u64); +/// +/// impl Drop for DataToZeroize { +/// fn drop(&mut self) { +/// unsafe { zeroize_flat_type(self as *mut Self) } +/// } +/// } +/// impl ZeroizeOnDrop for DataToZeroize {} +/// +/// let mut data = DataToZeroize { +/// flat_data_1: [3u8; 32], +/// flat_data_2: SomeMoreFlatData(123u64) +/// }; +/// +/// // data gets zeroized when dropped +/// ``` +#[inline(always)] +pub unsafe fn zeroize_flat_type(data: *mut F) { + let size = size_of::(); + // Safety: + // + // This is safe because `size_of()` returns the exact size of the object in memory, and + // `data_ptr` points directly to the first byte of the data. + unsafe { + volatile_set(data.cast::(), 0, size); + } + optimization_barrier(&data); +} + +/// Internal module used as support for `AssertZeroizeOnDrop`. +#[doc(hidden)] +pub mod __internal { + use super::*; + + /// Auto-deref workaround for deriving `ZeroizeOnDrop`. + pub trait AssertZeroizeOnDrop { + fn zeroize_or_on_drop(self); + } + + impl AssertZeroizeOnDrop for &&mut T { + fn zeroize_or_on_drop(self) {} + } + + /// Auto-deref workaround for deriving `ZeroizeOnDrop`. + pub trait AssertZeroize { + fn zeroize_or_on_drop(&mut self); + } + + impl AssertZeroize for T { + fn zeroize_or_on_drop(&mut self) { + self.zeroize(); + } + } +} diff --git a/http/vendor/zeroize/src/stack.rs b/http/vendor/zeroize/src/stack.rs new file mode 100644 index 0000000..cd4875c --- /dev/null +++ b/http/vendor/zeroize/src/stack.rs @@ -0,0 +1,52 @@ +/// Zeroize `N` bytes of stack space. +/// +/// Most algorithm implementations use stack to store temporary data. +/// Such temporaries may contain sensitive information (e.g. cryptgraphic keys) +/// and can stay on stack after the computation is finished. If an attacker +/// is able for some reasons to read stack data freely, it may result in +/// leaking of the sensitive data. +/// +/// # WARNING +/// This function requires you to estimate how much stack space is used by your +/// sensitive computation. This can be done by tools like [`cargo-call-stack`], +/// but note that stack usage depends on optimization level and compiler flags. +/// +/// [`cargo-call-stack`]: https://github.com/japaric/cargo-call-stack +/// +/// Additionally, you must annotate your sensitive function with `#[inline(never)]`. +/// +/// For example, the following example **DOES NOT** erase stack properly: +/// ``` +/// pub fn encrypt_data(key: &[u8; 16], data: &mut [u8]) { +/// leaking_encryption(key, data); +/// zeroize::zeroize_stack::<65_536>(); +/// } +/// # fn leaking_encryption(_: &[u8; 16], _: &mut [u8]) {} +/// ``` +/// `leaking_encryption` may get inlined and `zeroize_stack` will erase +/// stack memory above the stack frame reserved by `encrypt_data`, i.e. +/// it will **NOT** erase stack memory used by `leaking_encryption`. +/// +/// You should wrap your computation in the following way: +/// ``` +/// #[inline(never)] +/// fn encrypt_data_inner(key: &[u8; 16], data: &mut [u8]) { +/// leaking_encryption(key, data); +/// } +/// +/// pub fn encrypt_data(key: &[u8; 16], data: &mut [u8]) { +/// encrypt_data_inner(key, data); +/// zeroize::zeroize_stack::<65_536>(); +/// } +/// # fn leaking_encryption(_: &[u8; 16], _: &mut [u8]) {} +/// ``` +/// Finally, note that `#[inline(never)]` is just a hint and may be ignored +/// by the compiler. It works properly in practice, but such stack zeroization +/// should be considered as "best effort" and in cases where it's not enough +/// you should inspect the generated binary to verify that you got a desired +/// codegen. +#[inline(never)] +pub fn zeroize_stack() { + let buf = [0u8; N]; + crate::optimization_barrier(&buf); +} diff --git a/http/vendor/zeroize/src/x86.rs b/http/vendor/zeroize/src/x86.rs new file mode 100644 index 0000000..b3a4070 --- /dev/null +++ b/http/vendor/zeroize/src/x86.rs @@ -0,0 +1,26 @@ +//! [`Zeroize`] impls for x86 SIMD registers + +use crate::{Zeroize, optimization_barrier, volatile_write}; + +#[cfg(target_arch = "x86")] +use core::arch::x86::*; +#[cfg(target_arch = "x86_64")] +use core::arch::x86_64::*; + +macro_rules! impl_zeroize_for_simd_register { + ($($type:ty),* $(,)?) => { + $( + impl Zeroize for $type { + #[inline] + fn zeroize(&mut self) { + volatile_write(self, unsafe { core::mem::zeroed() }); + optimization_barrier(self); + } + } + )* + }; +} + +impl_zeroize_for_simd_register!( + __m128, __m128d, __m128i, __m256, __m256d, __m256i, __m512, __m512d, __m512i +); diff --git a/http/vendor/zeroize/tests/alloc.rs b/http/vendor/zeroize/tests/alloc.rs new file mode 100644 index 0000000..5dbdd71 --- /dev/null +++ b/http/vendor/zeroize/tests/alloc.rs @@ -0,0 +1,74 @@ +//! Tests for `Zeroize` impls on heap-allocated data structures + +#![allow(clippy::std_instead_of_core, clippy::undocumented_unsafe_blocks)] + +use std::alloc::{GlobalAlloc, Layout, System}; +use zeroize::Zeroize; + +// Allocator that ensures that deallocated data is zeroized. +struct ProxyAllocator; + +unsafe impl GlobalAlloc for ProxyAllocator { + unsafe fn alloc(&self, layout: Layout) -> *mut u8 { + unsafe { System.alloc(layout) } + } + + unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { + if layout.size() == 160 { + for i in 0..layout.size() { + let b = unsafe { core::ptr::read(ptr.add(i)) }; + assert_eq!(b, 0); + } + } + + unsafe { System.dealloc(ptr, layout) } + } +} + +#[global_allocator] +static PROXY_ALLOCATOR: ProxyAllocator = ProxyAllocator; + +struct SecretBox(Box); + +impl SecretBox { + fn new(val: S) -> Self { + Self(Box::new(val)) + } +} + +impl Drop for SecretBox { + fn drop(&mut self) { + self.0.as_mut().zeroize(); + } +} + +#[test] +fn secret_box_alloc_test() { + let b1 = SecretBox::new([u128::MAX; 10]); + core::hint::black_box(&b1); + let b2 = SecretBox::new([u8::MAX; 160]); + core::hint::black_box(&b2); +} + +struct ObserveSecretBox(Box); + +impl ObserveSecretBox { + fn new(val: S) -> Self { + Self(Box::new(val)) + } +} + +impl Drop for ObserveSecretBox { + fn drop(&mut self) { + *self.0 = Default::default(); + zeroize::optimization_barrier(&self); + } +} + +#[test] +fn observe_secret_box_alloc_test() { + let b1 = ObserveSecretBox::new([u128::MAX; 10]); + core::hint::black_box(&b1); + let b2 = SecretBox::new([u8::MAX; 160]); + core::hint::black_box(&b2); +} diff --git a/http/vendor/zeroize/tests/zeroize.rs b/http/vendor/zeroize/tests/zeroize.rs new file mode 100644 index 0000000..fed1753 --- /dev/null +++ b/http/vendor/zeroize/tests/zeroize.rs @@ -0,0 +1,304 @@ +//! zeroize integration tests. + +#![allow( + clippy::missing_safety_doc, + clippy::std_instead_of_alloc, + clippy::undocumented_unsafe_blocks +)] + +use core::{ + marker::{PhantomData, PhantomPinned}, + mem::{MaybeUninit, size_of}, + num::*, + ptr, +}; +use std::sync::Arc; +use zeroize::*; + +#[cfg(feature = "std")] +use std::ffi::CString; + +#[derive(Clone, Debug, PartialEq)] +struct ZeroizedOnDrop(u64); + +impl Drop for ZeroizedOnDrop { + fn drop(&mut self) { + self.0.zeroize(); + } +} + +#[test] +fn non_zero() { + macro_rules! non_zero_test { + ($($type:ty),+) => { + $(let mut value = <$type>::new(42).unwrap(); + value.zeroize(); + assert_eq!(value.get(), 1);)+ + }; + } + + non_zero_test!( + NonZeroI8, + NonZeroI16, + NonZeroI32, + NonZeroI64, + NonZeroI128, + NonZeroIsize, + NonZeroU8, + NonZeroU16, + NonZeroU32, + NonZeroU64, + NonZeroU128, + NonZeroUsize + ); +} + +#[test] +fn zeroize_byte_arrays() { + let mut arr = [42u8; 137]; + arr.zeroize(); + assert_eq!(arr.as_ref(), [0u8; 137].as_ref()); +} + +#[test] +fn zeroize_on_drop_byte_arrays() { + let mut arr = [ZeroizedOnDrop(42); 1]; + unsafe { ptr::drop_in_place(&raw mut arr) }; + assert_eq!(arr.as_ref(), [ZeroizedOnDrop(0); 1].as_ref()); +} + +#[test] +fn zeroize_maybeuninit_byte_arrays() { + let mut arr = [MaybeUninit::new(42u64); 64]; + arr.zeroize(); + let arr_init: [u64; 64] = unsafe { core::mem::transmute(arr) }; + assert_eq!(arr_init, [0u64; 64]); +} + +#[test] +fn zeroize_check_zerosize_types() { + // Since we assume these types have zero size, we test this holds for + // the current version of Rust. + assert_eq!(size_of::<()>(), 0); + assert_eq!(size_of::(), 0); + assert_eq!(size_of::>(), 0); +} + +#[test] +fn zeroize_check_tuple() { + let mut tup1 = (42u8,); + tup1.zeroize(); + assert_eq!(tup1, (0u8,)); + + let mut tup2 = (42u8, 42u8); + tup2.zeroize(); + assert_eq!(tup2, (0u8, 0u8)); +} + +#[test] +fn zeroize_on_drop_check_tuple() { + let mut tup1 = (ZeroizedOnDrop(42),); + unsafe { ptr::drop_in_place(&raw mut tup1) }; + assert_eq!(tup1, (ZeroizedOnDrop(0),)); + + let mut tup2 = (ZeroizedOnDrop(42), ZeroizedOnDrop(42)); + unsafe { ptr::drop_in_place(&raw mut tup2) }; + assert_eq!(tup2, (ZeroizedOnDrop(0), ZeroizedOnDrop(0))); +} + +#[cfg(feature = "alloc")] +#[test] +fn zeroize_vec() { + let mut vec = vec![42; 3]; + vec.zeroize(); + assert!(vec.is_empty()); +} + +#[cfg(feature = "alloc")] +#[test] +fn zeroize_vec_entire_capacity() { + #[derive(Clone)] + struct PanicOnNonZeroDrop(u64); + + impl Zeroize for PanicOnNonZeroDrop { + fn zeroize(&mut self) { + self.0 = 0; + } + } + + impl Drop for PanicOnNonZeroDrop { + fn drop(&mut self) { + assert!(self.0 == 0, "dropped non-zeroized data"); + } + } + + // Ensure that the entire capacity of the vec is zeroized and that no unitinialized data + // is ever interpreted as initialized + let mut vec = vec![PanicOnNonZeroDrop(42); 2]; + + unsafe { + vec.set_len(1); + } + + vec.zeroize(); + + unsafe { + vec.set_len(2); + } + + drop(vec); +} + +#[cfg(feature = "alloc")] +#[test] +fn zeroize_string() { + let mut string = String::from("Hello, world!"); + string.zeroize(); + assert!(string.is_empty()); +} + +#[cfg(feature = "alloc")] +#[test] +fn zeroize_string_entire_capacity() { + let mut string = String::from("Hello, world!"); + string.truncate(5); + + string.zeroize(); + + // convert the string to a vec to easily access the unused capacity + let mut as_vec = string.into_bytes(); + unsafe { as_vec.set_len(as_vec.capacity()) }; + + assert!(as_vec.iter().all(|byte| *byte == 0)); +} + +// TODO(tarcieri): debug flaky test (with potential UB?) See: RustCrypto/utils#774 +#[cfg(feature = "std")] +#[ignore] +#[test] +fn zeroize_c_string() { + let mut cstring = CString::new("Hello, world!").expect("CString::new failed"); + let orig_len = cstring.as_bytes().len(); + let orig_ptr = cstring.as_bytes().as_ptr(); + cstring.zeroize(); + // This doesn't quite test that the original memory has been cleared, but only that + // cstring now owns an empty buffer + assert!(cstring.as_bytes().is_empty()); + for i in 0..orig_len { + unsafe { + // Using a simple deref, only one iteration of the loop is performed + // presumably because after zeroize, the internal buffer has a length of one/ + // `read_volatile` seems to "fix" this + // Note that this is very likely UB + assert_eq!(orig_ptr.add(i).read_volatile(), 0); + } + } +} + +#[cfg(feature = "alloc")] +#[test] +fn zeroize_box() { + let mut boxed_arr = Box::new([42u8; 3]); + boxed_arr.zeroize(); + assert_eq!(boxed_arr.as_ref(), &[0u8; 3]); +} + +#[cfg(feature = "alloc")] +#[test] +fn asref() { + let mut buffer: Zeroizing> = Default::default(); + let _asmut: &mut [u8] = buffer.as_mut(); + let _asref: &[u8] = buffer.as_ref(); + + let mut buffer: Zeroizing> = Default::default(); + let _asmut: &mut [u8] = buffer.as_mut(); + let _asref: &[u8] = buffer.as_ref(); +} + +#[cfg(feature = "alloc")] +#[test] +fn box_unsized_zeroizing() { + let mut b: Box> = Box::new(Zeroizing::new([1, 2, 3, 4])); + { + let s: &[u8] = &b; + assert_eq!(s, &[1, 2, 3, 4]); + + let s: &[u8] = b.as_ref(); + assert_eq!(s, &[1, 2, 3, 4]); + + let s: &mut [u8] = b.as_mut(); + assert_eq!(s, &[1, 2, 3, 4]); + } + + unsafe { + ptr::drop_in_place(&raw mut *b); + } + + let s: &[u8] = &b; + assert_eq!(s, &[0, 0, 0, 0]); +} + +#[cfg(feature = "alloc")] +#[test] +fn arc_unsized_zeroizing() { + let mut arc: Arc> = Arc::new(Zeroizing::new([1, 2, 3, 4])); + { + let s: &[u8] = &arc; + assert_eq!(s, &[1, 2, 3, 4]); + + let s: &[u8] = arc.as_ref(); + assert_eq!(s, &[1, 2, 3, 4]); + } + + unsafe { + let inner = Arc::get_mut(&mut arc).unwrap(); + ptr::drop_in_place(inner); + } + + let s: &[u8] = &arc; + assert_eq!(s, &[0, 0, 0, 0]); +} + +// This is a weird way to use zeroizing, but it's technically allowed b/c +// unsized types can be stored inside Zeroizing, so make sure it works as +// expected. +#[test] +fn zeroizing_dyn_trait() { + trait TestTrait: Zeroize { + fn data(&self) -> &[u8]; + } + + struct TestStruct { + data: [u8; 4], + } + + impl Zeroize for TestStruct { + fn zeroize(&mut self) { + self.data.zeroize(); + } + } + + impl Drop for TestStruct { + fn drop(&mut self) { + self.zeroize(); + } + } + + impl TestTrait for TestStruct { + fn data(&self) -> &[u8] { + &self.data + } + } + + let mut b: Box> = + Box::new(Zeroizing::new(TestStruct { data: [1, 2, 3, 4] })); + + unsafe { + ptr::drop_in_place(&raw mut *b); + } + + let inner: &Zeroizing = &b; + let inner: &dyn TestTrait = core::ops::Deref::deref(inner); + + assert_eq!(inner.data(), &[0, 0, 0, 0]); +} diff --git a/http/vendor/zeroize/tests/zeroize_derive.rs b/http/vendor/zeroize/tests/zeroize_derive.rs new file mode 100644 index 0000000..aac1005 --- /dev/null +++ b/http/vendor/zeroize/tests/zeroize_derive.rs @@ -0,0 +1,372 @@ +//! Integration tests for `zeroize_derive` proc macros + +#![cfg(feature = "zeroize_derive")] +#![allow(clippy::undocumented_unsafe_blocks)] + +use core::ptr; +use zeroize::{Zeroize, ZeroizeOnDrop}; + +#[test] +fn derive_tuple_struct_test() { + #[derive(Zeroize, ZeroizeOnDrop)] + struct Z([u8; 3]); + + let mut value = Z([1, 2, 3]); + value.zeroize(); + assert_eq!(&value.0, &[0, 0, 0]); +} + +#[test] +#[cfg(feature = "alloc")] +fn derive_struct_test() { + #[derive(Zeroize, ZeroizeOnDrop)] + struct Z { + string: String, + vec: Vec, + bytearray: [u8; 3], + number: usize, + boolean: bool, + } + + let mut value = Z { + string: String::from("Hello, world!"), + vec: vec![1, 2, 3], + bytearray: [4, 5, 6], + number: 42, + boolean: true, + }; + + value.zeroize(); + + assert!(value.string.is_empty()); + assert!(value.vec.is_empty()); + assert_eq!(&value.bytearray, &[0, 0, 0]); + assert_eq!(value.number, 0); + assert!(!value.boolean); +} + +#[test] +fn derive_enum_test() { + #[derive(Zeroize, ZeroizeOnDrop)] + enum Z { + #[allow(dead_code)] + Variant1, + Variant2(usize), + } + + let mut value = Z::Variant2(26); + + value.zeroize(); + + assert!(matches!(value, Z::Variant2(0))); +} + +/// Test that the custom macro actually derived `Drop` for `Z` +#[test] +fn derive_struct_drop() { + #[derive(Zeroize, ZeroizeOnDrop)] + struct Z([u8; 3]); + + assert!(core::mem::needs_drop::()); +} + +/// Test that the custom macro actually derived `Drop` for `Z` +#[test] +fn derive_enum_drop() { + #[allow(dead_code)] + #[derive(Zeroize, ZeroizeOnDrop)] + enum Z { + Variant1, + Variant2(usize), + } + + assert!(core::mem::needs_drop::()); +} + +/// Test that the custom macro actually derived `Drop` for `Z` +#[test] +fn derive_struct_only_drop() { + #[derive(ZeroizeOnDrop)] + struct Z([u8; 3]); + + assert!(core::mem::needs_drop::()); +} + +/// Test that the custom macro actually derived `Drop` for `Z` +#[test] +fn derive_enum_only_drop() { + #[allow(dead_code)] + #[derive(ZeroizeOnDrop)] + enum Z { + Variant1, + Variant2(usize), + } + + assert!(core::mem::needs_drop::()); +} + +/// Test that `Drop` is not derived in the following case by defining a +/// `Drop` impl which should conflict if the custom derive defined one too +#[allow(dead_code)] +#[derive(Zeroize)] +struct ZeroizeNoDropStruct([u8; 3]); + +impl Drop for ZeroizeNoDropStruct { + fn drop(&mut self) {} +} + +#[allow(dead_code)] +#[derive(Zeroize)] +enum ZeroizeNoDropEnum { + Variant([u8; 3]), +} + +impl Drop for ZeroizeNoDropEnum { + fn drop(&mut self) {} +} + +#[test] +#[cfg(feature = "alloc")] +fn derive_struct_skip() { + #[derive(Zeroize, ZeroizeOnDrop)] + struct Z { + string: String, + vec: Vec, + #[zeroize(skip)] + bytearray: [u8; 3], + number: usize, + boolean: bool, + } + + let mut value = Z { + string: String::from("Hello, world!"), + vec: vec![1, 2, 3], + bytearray: [4, 5, 6], + number: 42, + boolean: true, + }; + + value.zeroize(); + + assert!(value.string.is_empty()); + assert!(value.vec.is_empty()); + assert_eq!(&value.bytearray, &[4, 5, 6]); + assert_eq!(value.number, 0); + assert!(!value.boolean); +} + +#[test] +#[cfg(feature = "alloc")] +fn derive_enum_skip() { + #[derive(Zeroize, ZeroizeOnDrop)] + enum Z { + #[allow(dead_code)] + Variant1, + #[zeroize(skip)] + Variant2([u8; 3]), + #[zeroize(skip)] + Variant3 { + string: String, + vec: Vec, + bytearray: [u8; 3], + number: usize, + boolean: bool, + }, + Variant4 { + string: String, + vec: Vec, + #[zeroize(skip)] + bytearray: [u8; 3], + number: usize, + boolean: bool, + }, + } + + let mut value = Z::Variant2([4, 5, 6]); + + value.zeroize(); + + assert!(matches!(&value, Z::Variant2([4, 5, 6]))); + + let mut value = Z::Variant3 { + string: String::from("Hello, world!"), + vec: vec![1, 2, 3], + bytearray: [4, 5, 6], + number: 42, + boolean: true, + }; + + value.zeroize(); + + assert!(matches!( + &value, + Z::Variant3 { string, vec, bytearray, number, boolean } + if string == "Hello, world!" && + vec == &[1, 2, 3] && + bytearray == &[4, 5, 6] && + *number == 42 && + *boolean + )); + + let mut value = Z::Variant4 { + string: String::from("Hello, world!"), + vec: vec![1, 2, 3], + bytearray: [4, 5, 6], + number: 42, + boolean: true, + }; + + value.zeroize(); + + assert!(matches!( + &value, + Z::Variant4 { string, vec, bytearray, number, boolean } + if string.is_empty() && + vec.is_empty() && + bytearray == &[4, 5, 6] && + *number == 0 && + !boolean + )); +} + +#[test] +fn derive_bound() { + trait T: Zeroize {} + + impl T for u8 {} + + #[derive(Zeroize)] + #[zeroize(bound = "X: T")] + struct Z(X); + + let mut value = Z(5_u8); + + value.zeroize(); + + assert_eq!(value.0, 0); +} + +#[test] +fn derive_inherit_zeroize_on_drop() { + #[derive(ZeroizeOnDrop)] + struct X([u8; 3]); + + #[derive(ZeroizeOnDrop)] + struct Z(X); + + let mut value = Z(X([1, 2, 3])); + unsafe { + ptr::drop_in_place(&raw mut value); + } + assert_eq!(&value.0.0, &[0, 0, 0]); +} + +#[test] +fn derive_inherit_from_both() { + #[derive(Zeroize, ZeroizeOnDrop)] + struct X([u8; 3]); + + #[derive(ZeroizeOnDrop)] + struct Z(X); + + let mut value = Z(X([1, 2, 3])); + unsafe { + ptr::drop_in_place(&raw mut value); + } + assert_eq!(&value.0.0, &[0, 0, 0]); +} + +#[test] +fn derive_inherit_both() { + #[derive(Zeroize, ZeroizeOnDrop)] + struct X([u8; 3]); + + #[derive(Zeroize, ZeroizeOnDrop)] + struct Z(X); + + let mut value = Z(X([1, 2, 3])); + unsafe { + ptr::drop_in_place(&raw mut value); + } + assert_eq!(&value.0.0, &[0, 0, 0]); +} + +#[test] +fn derive_deref() { + struct X([u8; 3]); + + impl core::ops::Deref for X { + type Target = [u8]; + + fn deref(&self) -> &Self::Target { + &self.0 + } + } + + impl core::ops::DerefMut for X { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } + } + + #[derive(Zeroize, ZeroizeOnDrop)] + struct Z(X); + + let mut value = Z(X([1, 2, 3])); + unsafe { + ptr::drop_in_place(&raw mut value); + } + assert_eq!(&value.0.0, &[0, 0, 0]); +} + +#[test] +#[cfg(feature = "alloc")] +#[allow(dead_code)] +fn derive_zeroize_on_drop_generic() { + #[derive(ZeroizeOnDrop)] + struct Y(Box); + + #[derive(ZeroizeOnDrop)] + struct Z(Vec); +} + +#[test] +#[allow(dead_code)] +#[allow(unused_assignments)] +fn derive_zeroize_unused_param() { + #[derive(Zeroize)] + struct Z { + arr: [u32; 5], + #[zeroize(skip)] + skipped: T, + } +} + +#[test] +#[allow(dead_code)] +#[allow(unused_assignments)] +// Issue https://github.com/RustCrypto/utils/issues/878 +fn derive_zeroize_with_marker() { + #[derive(ZeroizeOnDrop, Zeroize)] + struct Test { + #[zeroize(skip)] + field: Option, + } + + #[allow(dead_code)] + trait Secret: ZeroizeOnDrop + Zeroize {} + + impl Secret for Test {} + + trait Marker {} +} + +#[test] +#[allow(dead_code)] +// Issue https://github.com/RustCrypto/utils/issues/878 +fn derive_zeroize_used_param() { + #[derive(Zeroize)] + struct Z { + used: T, + } +} diff --git a/learning-goal.md b/learning-goal.md new file mode 100644 index 0000000..d556ad2 --- /dev/null +++ b/learning-goal.md @@ -0,0 +1,67 @@ +# Learning Goal: Data Analysis Foundations + +## My Learning Goal +Within 2 months, get the lay of the land of NLP and data analysis techniques, and rebuild a working mathematical understanding of basic statistical analysis. + +## Why It Matters +I often struggle with information overload and figuring out what's important. I want to be able to take a jumble of data and extract the vital things without getting lost — to orient myself to concrete facts. + +## My If-Then Plans +- If I reach for a library to solve a problem I actually want to learn, then I will not use the library — I will crack open a new crate and write it myself, using the library's source code as reference if needed. + +## My First Step +Download some textbooks, do Wikipedia dives, take notes, and pull out a spreadsheet to work through basic statistics. + +--- + +# Learning Goal: PostgreSQL Fluency + +## My Learning Goal +Within 6 months, develop fluency with SQL and PostgreSQL — being able to construct complex expressions freely because I understand what they mean and how they work, not just looking them up. + +## Why It Matters +Right now I can build a database but struggle to extract specific subsets of information. With this fluency I'd be able to get at key information easily — which connects directly to the broader goal of not getting lost in data. + +## My If-Then Plans +- If I get stuck on an SQL expression, then I will work through specific examples from the dataset manually — in a spreadsheet if needed — to figure out what the query actually needs to do. +- If I feel lost and don't have enough of a map to know what to ask, then I will play with the data manually, doing the operations step by step, to figure out what has to happen to get from a lot of data down to the specific data I need. + +## My First Step +Use the real database work already in front of me as the practice ground — every time I hit a wall, work through it manually before reaching for an answer. + +--- + +# Learning Goal: Profiling, Performance, and Testing + +## My Learning Goal +Within 2–3 months, learn the profiling tools in the Rust ecosystem. Within 6 months to a year, develop good profiling technique — making it a natural, habitual part of how I work, not something bolted on after the fact. + +## Why It Matters +I'm doing non-traditional DB design with event sourcing and writing my own algorithms for big data work. I need to know if things are actually fast, and whether improvements actually improve them — not just feel like it. + +## My If-Then Plans +- Even if my code feels fast enough, I will still create profiling loops throughout to understand how long things are actually taking and establish a baseline. +- If I find myself blindly trying techniques to increase speed, I will instead write profiling code first to find the real bottlenecks — so I know where to focus and when I've actually improved things. + +## My First Step +Learn the Rust profiling ecosystem — find the tools, get one set up in the current project, and create a first profiling loop. + +--- + +# Learning Goal: Rust Type System + +## My Goal +Within 3–6 months, be able to design traits, type structures, and trait bounds independently — without needing LLM assistance to construct them. When I can look at a data relationship, translate it into types and bounds myself, and work through the design to completion, I'll know I'm there. + +## Why It Matters +The same way I can follow pointers and imagine data structures spatially, I want that fluency with types — not memorizing rules, but being able to see the shape of a problem and express it. + +## My Self-Check +If I can't sketch the whole structure in an editor without leaning on example code, I haven't internalized it yet. + +## My If-Then Plans +- If I get stuck and start losing motivation, then I will open my journal and work through it in writing. +- If I reach for example code before I can sketch something myself, then I will close it and try to sketch it in an editor first. + +## My First Step +Keep working on the data collection and analysis project — writing as much of the code manually as possible, without LLM assistance from the start. diff --git a/postgresql-client/Cargo.toml b/postgresql-client/Cargo.toml new file mode 100644 index 0000000..5bfc47d --- /dev/null +++ b/postgresql-client/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "postgresql-client" +version = "0.0.0" +edition = "2024" + +[dependencies] \ No newline at end of file diff --git a/postgresql-client/src/dns.rs b/postgresql-client/src/dns.rs new file mode 100644 index 0000000..af65fb0 --- /dev/null +++ b/postgresql-client/src/dns.rs @@ -0,0 +1,10 @@ +use std::net::{IpAddr, Ipv4Addr}; + +#[derive(Debug)] +pub enum DnsError { + NotFound +} + +pub fn resolve_url(url: String) -> Result { + Ok(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1))) +} \ No newline at end of file diff --git a/postgresql-client/src/lib.rs b/postgresql-client/src/lib.rs new file mode 100644 index 0000000..330ddff --- /dev/null +++ b/postgresql-client/src/lib.rs @@ -0,0 +1,25 @@ + +mod message; +use message::{Message, MessageError}; + +mod session; +pub use session::{PsqlSession, Location}; + +mod types; + +mod dns; + +#[derive(Debug)] +pub enum PsqlError { + LostConnection, + Message(MessageError), +} + +type PsqlResult = Result; + + + +pub fn send_message(message: Message) -> PsqlResult<()> { + Ok(()) +} + diff --git a/postgresql-client/src/message.rs b/postgresql-client/src/message.rs new file mode 100644 index 0000000..76c76b4 --- /dev/null +++ b/postgresql-client/src/message.rs @@ -0,0 +1,1607 @@ +use std::ffi::{CStr, CString}; + +pub enum Message { + Backend(BackendMessage), + Frontend(FrontendMessage), +} + +#[derive(Debug)] +pub enum MessageError { + MalformedMessage, + TypeByteDecodeError(char), + IoError(std::io::Error), +} + +/// Upper bound on a single message's declared length. A peer (or a corrupt +/// length field) claiming an absurd size would otherwise leave the framing +/// loop waiting forever for bytes that never arrive; capping it turns that +/// hang into a clean `MalformedMessage`. 1 GiB - 1 matches Postgres's own +/// MaxAllocSize, the largest message it will ever send. +const MAX_MESSAGE_LEN: usize = 0x3FFF_FFFF; + +#[repr(u8)] +#[derive(PartialEq, Copy,Clone)] +pub enum FrontendMessageTypeByte { + Bind = b'B', + Close = b'C', + CopyData = b'd', + CopyDone = b'c', + CopyFail = b'f', + Describe = b'D', + Execute = b'E', + Flush = b'H', + FunctionCall = b'F', + Parse = b'P', + Query = b'Q', + AuthCredMessage = b'p', + Sync = b'S', + Terminate = b'X', +} + +impl FrontendMessageTypeByte { + fn to_type(&self, expecting: Option) -> Result { + Ok(match self { + FrontendMessageTypeByte::Bind => FrontendMessageType::Bind, + FrontendMessageTypeByte::Close => FrontendMessageType::Close, + FrontendMessageTypeByte::CopyData => FrontendMessageType::CopyData, + FrontendMessageTypeByte::CopyDone => FrontendMessageType::CopyDone, + FrontendMessageTypeByte::CopyFail => FrontendMessageType::CopyFail, + FrontendMessageTypeByte::Describe => FrontendMessageType::Describe, + FrontendMessageTypeByte::Execute => FrontendMessageType::Execute, + FrontendMessageTypeByte::Flush => FrontendMessageType::Flush, + FrontendMessageTypeByte::FunctionCall => FrontendMessageType::FunctionCall, + FrontendMessageTypeByte::Parse => FrontendMessageType::Parse, + FrontendMessageTypeByte::Query => FrontendMessageType::Query, + FrontendMessageTypeByte::Sync => FrontendMessageType::Sync, + FrontendMessageTypeByte::Terminate => FrontendMessageType::Terminate, + FrontendMessageTypeByte::AuthCredMessage => if expecting.ok_or(MessageError::MalformedMessage)?.is_auth_cred() { expecting.unwrap() } else {Err(MessageError::MalformedMessage)?} + }) + } +} + +impl TryFrom for FrontendMessageTypeByte { + type Error = MessageError; + + fn try_from(value: u8) -> Result { + Ok(match value { + b'B' => FrontendMessageTypeByte::Bind, + b'C' => FrontendMessageTypeByte::Close, + b'd' => FrontendMessageTypeByte::CopyData, + b'c' => FrontendMessageTypeByte::CopyDone, + b'f' => FrontendMessageTypeByte::CopyFail, + b'D' => FrontendMessageTypeByte::Describe, + b'E' => FrontendMessageTypeByte::Execute, + b'H' => FrontendMessageTypeByte::Flush, + b'F' => FrontendMessageTypeByte::FunctionCall, + b'P' => FrontendMessageTypeByte::Parse, + b'Q' => FrontendMessageTypeByte::Query, + b'p' => FrontendMessageTypeByte::AuthCredMessage, + b'S' => FrontendMessageTypeByte::Sync, + b'X' => FrontendMessageTypeByte::Terminate, + _ => Err(Self::Error::MalformedMessage)?, + }) + } +} + +#[derive(Copy,Clone)] +pub enum FrontendMessageType { + // Type Byte-less variants. + Startup, + CancelRequest, + SslRequest, + GssEnc, + + // 'p' byte variants. + GssResponse, + SaslInitialResponse, + SaslResponse, + PasswordMessage, + + // Normal unique variants. + Bind, + Close, + CopyData, + CopyDone, + CopyFail, + Describe, + Execute, + Flush, + FunctionCall, + Parse, + Query, + Sync, + Terminate, +} + +impl FrontendMessageType { + fn from_discrim(discrim: i32, is_startup: bool) -> Result { + match discrim { + 80877104 => Ok(FrontendMessageType::GssEnc), + 80877103 => Ok(FrontendMessageType::SslRequest), + 80877102 => Ok(FrontendMessageType::CancelRequest), + _ => if is_startup { Ok(FrontendMessageType::Startup) } else { Err(MessageError::MalformedMessage) }, //Hopefully. + } + } + + fn is_auth_cred(&self) -> bool { + match self { + Self::GssResponse | Self::SaslInitialResponse | Self::SaslResponse | Self::PasswordMessage => true, + _ => false, + } + } + + fn is_startup(&self) -> bool { + match self { + Self::Startup => true, + _ => false, + } + } +} + +pub enum FrontendMessage { + // Type Byte-less variants. + Startup { + version_major: i16, + version_minor: i16, + params: Vec<(CString,CString)>, + }, + CancelRequest { + pid: i32, + key: Vec, + }, + SslRequest, + GssEnc, + + // 'p' byte variants. + GssResponse { + data: Vec, + }, + SaslInitialResponse { + auth_mech: CString, + sasl_initial: Option>, + }, + SaslResponse { + data: Vec, + }, + PasswordMessage { + password: CString, + }, + + // Normal unique variants. + Bind { + dest_portal: CString, + src_prepared_stmt: CString, + formats: Vec, + params: Vec>>, + result_formats: Vec, + }, //'B' + Close { + target: Target, + target_name: CString, + + }, + CopyData { + data: Vec, + }, + CopyDone, + CopyFail { + error_message: CString, + }, + Describe { + target: Target, + target_name: CString, + }, + Execute { + portal_name: CString, + num_rows: i32, + }, + Flush, + FunctionCall { + oid: i32, + formats: Vec, + arguments: Vec>, + result_format: Format, + }, + Parse { + dest_stmt_name: CString, + query: CString, + param_data_type_oids: Vec, + }, + Query { + query: CString, + }, + Sync, + Terminate, +} + +impl FrontendMessage { + /// The leading type byte for this message, or `None` for the startup-class + /// messages (Startup, CancelRequest, SSLRequest, GSSENCRequest) which are + /// length-prefixed only and carry no type byte. + fn type_byte(&self) -> Option { + Some(match self { + FrontendMessage::Startup { .. } + | FrontendMessage::CancelRequest { .. } + | FrontendMessage::SslRequest + | FrontendMessage::GssEnc => return None, + FrontendMessage::GssResponse { .. } + | FrontendMessage::SaslInitialResponse { .. } + | FrontendMessage::SaslResponse { .. } + | FrontendMessage::PasswordMessage { .. } => b'p', + FrontendMessage::Bind { .. } => b'B', + FrontendMessage::Close { .. } => b'C', + FrontendMessage::CopyData { .. } => b'd', + FrontendMessage::CopyDone => b'c', + FrontendMessage::CopyFail { .. } => b'f', + FrontendMessage::Describe { .. } => b'D', + FrontendMessage::Execute { .. } => b'E', + FrontendMessage::Flush => b'H', + FrontendMessage::FunctionCall { .. } => b'F', + FrontendMessage::Parse { .. } => b'P', + FrontendMessage::Query { .. } => b'Q', + FrontendMessage::Sync => b'S', + FrontendMessage::Terminate => b'X', + }) + } + + fn to_buffer(&self) -> Result,MessageError> { + let mut buf: Vec = vec!(); + let mut body: Vec = vec!(); + + let length = 4i32 + match self { + FrontendMessage::Startup { version_major, version_minor, params } => { + let mut length = 4; + body.extend_from_slice(version_major.to_be_bytes().as_slice()); + body.extend_from_slice(version_minor.to_be_bytes().as_slice()); + for param in params { + body.extend_from_slice(param.0.as_bytes_with_nul()); + body.extend_from_slice(param.1.as_bytes_with_nul()); + length += param.0.count_bytes() as i32 + param.1.count_bytes() as i32 + 2; + } + body.push(b'\0'); // parameter list terminated by a final zero byte + length + 1 + }, FrontendMessage::CancelRequest { pid, key } => { + body.extend_from_slice(80877102i32.to_be_bytes().as_slice()); + body.extend_from_slice(pid.to_be_bytes().as_slice()); + body.extend_from_slice(key.as_slice()); + 8 + key.len() as i32 + }, FrontendMessage::SslRequest => { + body.extend_from_slice(80877103i32.to_be_bytes().as_slice()); + 4 + }, FrontendMessage::GssEnc => { + body.extend_from_slice(80877104i32.to_be_bytes().as_slice()); + 4 + }, FrontendMessage::GssResponse { data } => { + body.extend_from_slice((data.len() as i32).to_be_bytes().as_slice()); + body.extend_from_slice(data.as_slice()); + 4 + data.len() as i32 + }, FrontendMessage::SaslInitialResponse { auth_mech, sasl_initial } => { + body.extend_from_slice(auth_mech.as_bytes_with_nul()); + 1 + auth_mech.count_bytes() as i32 + match sasl_initial { + Some(si) => { + body.extend_from_slice((si.len() as i32).to_be_bytes().as_slice()); + body.extend_from_slice(si.as_slice()); + 4 + si.len() as i32 + }, None => { + body.extend_from_slice((-1i32).to_be_bytes().as_slice()); + 4i32 + } + } + }, FrontendMessage::SaslResponse { data } => { + body.extend_from_slice(data.as_slice()); + data.len() as i32 + }, FrontendMessage::PasswordMessage { password } => { + body.extend_from_slice(password.as_bytes_with_nul()); + password.count_bytes() as i32 + 1 + }, FrontendMessage::Bind { dest_portal, src_prepared_stmt, formats, params, result_formats } => { + //TODO: This one *really* needs double-checking + body.extend_from_slice(dest_portal.as_bytes_with_nul()); + body.extend_from_slice(src_prepared_stmt.as_bytes_with_nul()); + body.extend_from_slice((formats.len() as i16).to_be_bytes().as_slice()); + for format in formats { + body.extend_from_slice((*format as i16).to_be_bytes().as_slice()); + } + body.extend_from_slice((params.len() as i16).to_be_bytes().as_slice()); + let mut params_len = 0i32; + for param in params { + params_len += match param { + Some(p) => { + body.extend_from_slice((p.len() as i32).to_be_bytes().as_slice()); + body.extend_from_slice(p.as_slice()); + p.len() as i32 + 4 + }, None => { + body.extend_from_slice((-1i32).to_be_bytes().as_slice()); + 4 + }, + } + } + body.extend_from_slice((result_formats.len() as i16).to_be_bytes().as_slice()); + for format in result_formats { + body.extend_from_slice((*format as i16).to_be_bytes().as_slice()); + } + dest_portal.count_bytes() as i32 + 1 + src_prepared_stmt.count_bytes() as i32 + 1 + + 2 + (formats.len() * 2) as i32 + 2 + params_len + 2 + (result_formats.len() * 2) as i32 + } + FrontendMessage::Close { target, target_name } => { + body.push((*target) as u8); + body.extend_from_slice(target_name.as_bytes_with_nul()); + target_name.count_bytes() as i32 + 2 + } + FrontendMessage::CopyData { data } => { + body.extend_from_slice(data.as_slice()); + data.len() as i32 + }, FrontendMessage::CopyDone => { + 0 + }, FrontendMessage::CopyFail { error_message } => { + body.extend_from_slice(error_message.as_bytes_with_nul()); + error_message.count_bytes() as i32 + 1 + } + FrontendMessage::Describe { target, target_name } => { + body.push((*target) as u8); + body.extend_from_slice(target_name.as_bytes_with_nul()); + 2 + target_name.count_bytes() as i32 + }, FrontendMessage::Execute { portal_name, num_rows } => { + body.extend_from_slice(portal_name.as_bytes_with_nul()); + body.extend_from_slice((*num_rows).to_be_bytes().as_slice()); + (portal_name.count_bytes() + 1) as i32 + 4 + }, FrontendMessage::Flush => { + 0 + }, FrontendMessage::FunctionCall { oid, formats, arguments, result_format } => { + body.extend_from_slice(oid.to_be_bytes().as_slice()); + body.extend_from_slice((formats.len() as i16).to_be_bytes().as_slice()); + for format in formats { + body.extend_from_slice((*format as i16).to_be_bytes().as_slice()) + } + body.extend_from_slice((arguments.len() as i16).to_be_bytes().as_slice()); + let mut arguments_len = 0i32; + for argument in arguments { + let al = argument.len() as i32; + body.extend_from_slice(al.to_be_bytes().as_slice()); + body.extend_from_slice(argument.as_slice()); + arguments_len += al + 4; + } + body.extend_from_slice((*result_format as i16).to_be_bytes().as_slice()); + 10 + (formats.len() * 2) as i32 + arguments_len + }, FrontendMessage::Parse { dest_stmt_name, query, param_data_type_oids } => { + body.extend_from_slice(dest_stmt_name.as_bytes_with_nul()); + body.extend_from_slice(query.as_bytes_with_nul()); + body.extend_from_slice((param_data_type_oids.len() as i16).to_be_bytes().as_slice()); + for oid in param_data_type_oids { + body.extend_from_slice(oid.to_be_bytes().as_slice()); + } + dest_stmt_name.count_bytes() as i32 + query.count_bytes() as i32 + 4 + (param_data_type_oids.len() * 4) as i32 + }, FrontendMessage::Query { query } => { + body.extend_from_slice(query.as_bytes_with_nul()); + query.count_bytes() as i32 + 1 + }, FrontendMessage::Sync => { + 0 + }, FrontendMessage::Terminate => { + 0 + }, + }; + + if let Some(type_byte) = self.type_byte() { + buf.push(type_byte); + } + buf.extend_from_slice(&(length as i32).to_be_bytes()); + buf.extend_from_slice(body.as_slice()); + Ok(buf) + } + + fn from_buffer(buf: &[u8], has_type_byte: bool, expecting_startup: bool, expecting: Option) -> Result, MessageError> { + if buf.len() < 4 { return Ok(None)} + // Need the length field to read the header. On the typed path the type byte + // precedes it, so we need length_offset + 4 bytes present. + let (type_byte, length_offset) = match has_type_byte { + true => (Some(FrontendMessageTypeByte::try_from(*buf.get(0).ok_or(MessageError::MalformedMessage)?)?), 1), + false => (None, 0), + }; + + let length = match buf.get(length_offset..length_offset + 4) { + Some(l) => i32::from_be_bytes(l.try_into().map_err(|_| MessageError::MalformedMessage)?) as usize, + None => return Ok(None), // header not fully arrived + }; + + // Length counts itself but not the type byte → minimum legal value is 4, + // regardless of length_offset. (length_offset is buffer geometry, not length.) + if length < 4 || length > MAX_MESSAGE_LEN { + return Err(MessageError::MalformedMessage); + } + + // Total frame occupies `length + length_offset` bytes; body starts after the + // length field. None = frame not fully arrived = incomplete. + let body = match buf.get(length_offset + 4 .. length + length_offset) { + Some(b) => b, + None => return Ok(None), + }; + + let message_type = match type_byte { + Some(tb) => tb.to_type(expecting)?, + None => { + // Discriminant is the first 4 bytes of the body. Reading it here only + // selects the type; the Startup/Cancel arms re-read from body as needed. + let discrim = i32::from_be_bytes( + body.get(0..4).ok_or(MessageError::MalformedMessage)? + .try_into().map_err(|_| MessageError::MalformedMessage)?, + ); + FrontendMessageType::from_discrim(discrim, expecting_startup)? + }, + }; + + let consumed = length + length_offset; + + let mut reader = BodyReader { buffer: body, pos: 0 }; + + Ok(Some((match message_type { + FrontendMessageType::Startup => { + let version_major = reader.i16()?; + let version_minor = reader.i16()?; + + let mut params = vec!(); + loop { + let name = reader.c_string()?; + if name.is_empty() { break; } + let value = reader.c_string()?; + params.push((name, value)); + } + FrontendMessage::Startup { version_major, version_minor, params } + }, FrontendMessageType::CancelRequest => { + let _ = reader.i32()?; + let pid = reader.i32()?; + let key = reader.rest().to_owned(); + FrontendMessage::CancelRequest { pid, key } + }, FrontendMessageType::SslRequest => FrontendMessage::SslRequest, + FrontendMessageType::GssEnc => FrontendMessage::GssEnc, + FrontendMessageType::GssResponse => FrontendMessage::GssResponse { data: reader.rest().to_owned() }, + FrontendMessageType::SaslInitialResponse => { + let auth_mech = reader.c_string()?; + let response_length = reader.i32()?; + let sasl_initial = if response_length == -1 { None } + else if response_length < -1 { return Err(MessageError::MalformedMessage) } + else { Some(reader.bytes(response_length as usize)?) }; + FrontendMessage::SaslInitialResponse { auth_mech, sasl_initial } + }, FrontendMessageType::SaslResponse => FrontendMessage::SaslResponse { data: reader.rest().to_owned() }, + FrontendMessageType::PasswordMessage => FrontendMessage::PasswordMessage { password: reader.c_string()? }, + FrontendMessageType::Bind => { + let dest_portal = reader.c_string()?; + let src_prepared_stmt = reader.c_string()?; + let num_formats = reader.i16()?; + let mut formats = vec!(); + for _ in 0..num_formats { + formats.push(Format::try_from(reader.i16()?)?); + } + let num_params = reader.i16()?; + let mut params = vec!(); + for _ in 0..num_params { + let param_len = reader.i32()?; + params.push( if param_len == -1 { None } + else if param_len < -1 { return Err(MessageError::MalformedMessage)} + else { Some(reader.bytes(param_len as usize)?)}); + } + let num_result_formats = reader.i16()?; + let mut result_formats = vec!(); + for _ in 0..num_result_formats { + result_formats.push(Format::try_from(reader.i16()?)?); + } + FrontendMessage::Bind { dest_portal, src_prepared_stmt, formats, params, result_formats, } + }, FrontendMessageType::Close => { + let target = Target::try_from(reader.u8()?)?; + let target_name = reader.c_string()?; + FrontendMessage::Close { target, target_name } + }, FrontendMessageType::CopyData => FrontendMessage::CopyData { data: reader.rest().to_owned() }, + FrontendMessageType::CopyDone => FrontendMessage::CopyDone, + FrontendMessageType::CopyFail => FrontendMessage::CopyFail { error_message: reader.c_string()? }, + FrontendMessageType::Describe => { + let target = Target::try_from(reader.u8()?)?; + let target_name = reader.c_string()?; + FrontendMessage::Describe { target, target_name } + }, FrontendMessageType::Execute => { + let portal_name = reader.c_string()?; + let num_rows = reader.i32()?; + FrontendMessage::Execute { portal_name, num_rows } + }, FrontendMessageType::Flush => FrontendMessage::Flush, + FrontendMessageType::FunctionCall => { + let oid = reader.i32()?; + let num_formats = reader.i16()?; + let mut formats = vec!(); + for _ in 0..num_formats { + formats.push(Format::try_from(reader.i16()?)?); + } + let num_arguments = reader.i16()?; + let mut arguments = vec!(); + for _ in 0..num_arguments { + let arg_len = reader.i32()?; + arguments.push(reader.bytes(arg_len as usize)?.to_owned()); + } + let result_format = Format::try_from(reader.i16()?)?; + FrontendMessage::FunctionCall { oid, formats, arguments, result_format } + }, FrontendMessageType::Parse => { + let dest_stmt_name = reader.c_string()?; + let query = reader.c_string()?; + let num_data_types = reader.i16()?; + let mut param_data_type_oids = vec!(); + for _ in 0..num_data_types { + param_data_type_oids.push(reader.i32()?); + } + FrontendMessage::Parse { dest_stmt_name, query, param_data_type_oids } + }, + FrontendMessageType::Query => { + FrontendMessage::Query { query: reader.c_string()? } + }, FrontendMessageType::Sync => FrontendMessage::Sync, + FrontendMessageType::Terminate => FrontendMessage::Terminate, + }, consumed))) + } +} + +#[repr(u8)] +#[derive(Copy,Clone)] +pub enum BackendMessageTypeByte { + AuthenticationRequest = b'R', + BackendKeyData = b'K', + BindComplete = b'2', + CloseComplete = b'3', + CommandComplete = b'C', + CopyData = b'd', + CopyDone = b'c', + CopyInResponse = b'G', + CopyOutResponse = b'H', + CopyBothResponse = b'W', + DataRow = b'D', + EmptyQueryResponse = b'I', + ErrorResponse = b'E', + FunctionCallResponse = b'V', + NegotiateProtocolVersion = b'v', + NoData = b'n', + NoticeResponse = b'N', + NotificationResponse = b'A', + ParameterDescription = b't', + ParameterStatus = b'S', + ParseComplete = b'1', + PortalSuspended = b's', + ReadyForQuery = b'Z', + RowDescription = b'T', +} + +impl BackendMessageTypeByte { + fn from_type(message_type: BackendMessageType) -> BackendMessageTypeByte { + match message_type { + BackendMessageType::BackendKeyData => BackendMessageTypeByte::BackendKeyData , + BackendMessageType::BindComplete => BackendMessageTypeByte::BindComplete , + BackendMessageType::CloseComplete => BackendMessageTypeByte::CloseComplete , + BackendMessageType::CommandComplete => BackendMessageTypeByte::CommandComplete , + BackendMessageType::CopyData => BackendMessageTypeByte::CopyData , + BackendMessageType::CopyDone => BackendMessageTypeByte::CopyDone , + BackendMessageType::CopyInResponse => BackendMessageTypeByte::CopyInResponse , + BackendMessageType::CopyOutResponse => BackendMessageTypeByte::CopyOutResponse , + BackendMessageType::CopyBothResponse => BackendMessageTypeByte::CopyBothResponse , + BackendMessageType::DataRow => BackendMessageTypeByte::DataRow , + BackendMessageType::EmptyQueryResponse => BackendMessageTypeByte::EmptyQueryResponse , + BackendMessageType::ErrorResponse => BackendMessageTypeByte::ErrorResponse , + BackendMessageType::FunctionCallResponse => BackendMessageTypeByte::FunctionCallResponse , + BackendMessageType::NegotiateProtocolVersion => BackendMessageTypeByte::NegotiateProtocolVersion , + BackendMessageType::NoData => BackendMessageTypeByte::NoData , + BackendMessageType::NoticeResponse => BackendMessageTypeByte::NoticeResponse , + BackendMessageType::NotificationResponse => BackendMessageTypeByte::NotificationResponse , + BackendMessageType::ParameterDescription => BackendMessageTypeByte::ParameterDescription , + BackendMessageType::ParameterStatus => BackendMessageTypeByte::ParameterStatus , + BackendMessageType::ParseComplete => BackendMessageTypeByte::ParseComplete , + BackendMessageType::PortalSuspended => BackendMessageTypeByte::PortalSuspended , + BackendMessageType::ReadyForQuery => BackendMessageTypeByte::ReadyForQuery , + BackendMessageType::RowDescription => BackendMessageTypeByte::RowDescription , + BackendMessageType::AuthenticationOk => BackendMessageTypeByte::AuthenticationRequest, + BackendMessageType::AuthenticationKerberosV5 => BackendMessageTypeByte::AuthenticationRequest, + BackendMessageType::AuthenticationCleartextPassword => BackendMessageTypeByte::AuthenticationRequest, + BackendMessageType::AuthenticationMd5Password => BackendMessageTypeByte::AuthenticationRequest, + BackendMessageType::AuthenticationGss => BackendMessageTypeByte::AuthenticationRequest, + BackendMessageType::AuthenticationGssContinue => BackendMessageTypeByte::AuthenticationRequest, + BackendMessageType::AuthenticationSppi => BackendMessageTypeByte::AuthenticationRequest, + BackendMessageType::AuthenticationSasl => BackendMessageTypeByte::AuthenticationRequest, + BackendMessageType::AuthenticationSaslContinue => BackendMessageTypeByte::AuthenticationRequest, + BackendMessageType::AuthenticationSaslFinal => BackendMessageTypeByte::AuthenticationRequest, + } + } +} + + +impl TryFrom for BackendMessageTypeByte { + type Error = MessageError; + + fn try_from(value: u8) -> Result { + Ok(match value { + b'R' => BackendMessageTypeByte::AuthenticationRequest, + b'K' => BackendMessageTypeByte::BackendKeyData, + b'2' => BackendMessageTypeByte::BindComplete, + b'3' => BackendMessageTypeByte::CloseComplete, + b'C' => BackendMessageTypeByte::CommandComplete, + b'd' => BackendMessageTypeByte::CopyData, + b'c' => BackendMessageTypeByte::CopyDone, + b'G' => BackendMessageTypeByte::CopyInResponse, + b'H' => BackendMessageTypeByte::CopyOutResponse, + b'W' => BackendMessageTypeByte::CopyBothResponse, + b'D' => BackendMessageTypeByte::DataRow, + b'I' => BackendMessageTypeByte::EmptyQueryResponse, + b'E' => BackendMessageTypeByte::ErrorResponse, + b'V' => BackendMessageTypeByte::FunctionCallResponse, + b'v' => BackendMessageTypeByte::NegotiateProtocolVersion, + b'n' => BackendMessageTypeByte::NoData, + b'N' => BackendMessageTypeByte::NoticeResponse, + b'A' => BackendMessageTypeByte::NotificationResponse, + b't' => BackendMessageTypeByte::ParameterDescription, + b'S' => BackendMessageTypeByte::ParameterStatus, + b'1' => BackendMessageTypeByte::ParseComplete, + b's' => BackendMessageTypeByte::PortalSuspended, + b'Z' => BackendMessageTypeByte::ReadyForQuery, + b'T' => BackendMessageTypeByte::RowDescription, + _ => Err(MessageError::MalformedMessage)?, + }) + } +} + +pub enum BackendMessageType { + // Types with 'R' type byte. + AuthenticationOk, + AuthenticationKerberosV5, + AuthenticationCleartextPassword, + AuthenticationMd5Password, + AuthenticationGss, + AuthenticationGssContinue, + AuthenticationSppi, + AuthenticationSasl, + AuthenticationSaslContinue, + AuthenticationSaslFinal, + BackendKeyData, //'K' + BindComplete, //'2' + CloseComplete, //'3' + CommandComplete, //'C' + CopyData, //'d' + CopyDone, //'c' + CopyInResponse, //'G' + CopyOutResponse, //'H' + CopyBothResponse, //'W' + DataRow, //'D' + EmptyQueryResponse, //'I' + ErrorResponse, //'E' + FunctionCallResponse, //'V' + NegotiateProtocolVersion, //'v' + NoData, //'n' + NoticeResponse, //'N' + NotificationResponse, //'A' + ParameterDescription, //'t' + ParameterStatus, //'S' + ParseComplete, //'1' + PortalSuspended, //'s' + ReadyForQuery, //'Z' + RowDescription, //'T' +} + +impl BackendMessageType { + fn from_byte(byte: BackendMessageTypeByte, discrim: Option) -> Result { + Ok(match byte { + BackendMessageTypeByte::BackendKeyData => BackendMessageType::BackendKeyData , + BackendMessageTypeByte::BindComplete => BackendMessageType::BindComplete , + BackendMessageTypeByte::CloseComplete => BackendMessageType::CloseComplete , + BackendMessageTypeByte::CommandComplete => BackendMessageType::CommandComplete , + BackendMessageTypeByte::CopyData => BackendMessageType::CopyData , + BackendMessageTypeByte::CopyDone => BackendMessageType::CopyDone , + BackendMessageTypeByte::CopyInResponse => BackendMessageType::CopyInResponse , + BackendMessageTypeByte::CopyOutResponse => BackendMessageType::CopyOutResponse , + BackendMessageTypeByte::CopyBothResponse => BackendMessageType::CopyBothResponse , + BackendMessageTypeByte::DataRow => BackendMessageType::DataRow , + BackendMessageTypeByte::EmptyQueryResponse => BackendMessageType::EmptyQueryResponse , + BackendMessageTypeByte::ErrorResponse => BackendMessageType::ErrorResponse , + BackendMessageTypeByte::FunctionCallResponse => BackendMessageType::FunctionCallResponse , + BackendMessageTypeByte::NegotiateProtocolVersion => BackendMessageType::NegotiateProtocolVersion , + BackendMessageTypeByte::NoData => BackendMessageType::NoData , + BackendMessageTypeByte::NoticeResponse => BackendMessageType::NoticeResponse , + BackendMessageTypeByte::NotificationResponse => BackendMessageType::NotificationResponse , + BackendMessageTypeByte::ParameterDescription => BackendMessageType::ParameterDescription , + BackendMessageTypeByte::ParameterStatus => BackendMessageType::ParameterStatus , + BackendMessageTypeByte::ParseComplete => BackendMessageType::ParseComplete , + BackendMessageTypeByte::PortalSuspended => BackendMessageType::PortalSuspended , + BackendMessageTypeByte::ReadyForQuery => BackendMessageType::ReadyForQuery , + BackendMessageTypeByte::RowDescription => BackendMessageType::RowDescription , + BackendMessageTypeByte::AuthenticationRequest => match discrim { + Some(0) => BackendMessageType::AuthenticationOk, + Some(2) => BackendMessageType::AuthenticationKerberosV5, + Some(3) => BackendMessageType::AuthenticationCleartextPassword, + Some(5) => BackendMessageType::AuthenticationMd5Password, + Some(7) => BackendMessageType::AuthenticationGss, + Some(8) => BackendMessageType::AuthenticationGssContinue, + Some(9) => BackendMessageType::AuthenticationSppi, + Some(10) => BackendMessageType::AuthenticationSasl, + Some(11) => BackendMessageType::AuthenticationSaslContinue, + Some(12) => BackendMessageType::AuthenticationSaslFinal, + _ => Err(MessageError::MalformedMessage)?, + }, + }) + } +} + +pub enum BackendMessage { + AuthenticationOk, + AuthenticationKerberosV5, + AuthenticationCleartextPassword, + AuthenticationMd5Password { + salt: [u8; 4], + }, + AuthenticationGss, + AuthenticationGssContinue { + data: Vec, + }, + AuthenticationSppi, + AuthenticationSasl { + mechanism_names: Vec, + }, + AuthenticationSaslContinue { + data: Vec, + }, + AuthenticationSaslFinal { + data: Vec, + }, + BackendKeyData { + pid: i32, + key: Vec, + }, //'K' + BindComplete, //'2' + CloseComplete, //'3' + CommandComplete { + tag: CommandTag, + }, //'C' + CopyData { + data: Vec, + }, //'d' + CopyDone, //'c' + CopyInResponse { + overall_format: Format, + formats: Vec, + }, //'G' + CopyOutResponse { + overall_format: Format, + formats: Vec, + }, //'H' + CopyBothResponse { + overall_format: Format, + formats: Vec, + }, //'W' + DataRow { + data: Vec>>, + }, //'D' + EmptyQueryResponse, //'I' + ErrorResponse { + errors: Vec<(Option, CString)> + }, //'E' + FunctionCallResponse { + value: Option>, + }, //'V' + NegotiateProtocolVersion { + minor_version: i32, + unrecognized_options: Vec, + }, //'v' + NoData, //'n' + NoticeResponse { + notices: Vec<(Option, CString)>, + }, //'N' + NotificationResponse { + pid: i32, + channel_name: CString, + payload: CString, + }, //'A' + ParameterDescription { + object_ids: Vec, + }, //'t' + ParameterStatus { + param_name: CString, + param_value: CString, + }, //'S' + ParseComplete, //'1' + PortalSuspended, //'s' + ReadyForQuery { + transaction_status: TransactionStatus, + }, //'Z' + RowDescription { + fields: Vec, + }, //'T' +} + +impl BackendMessage { + fn get_type_byte(&self) -> BackendMessageTypeByte { + match self { + BackendMessage::AuthenticationOk => BackendMessageTypeByte::AuthenticationRequest, + BackendMessage::AuthenticationKerberosV5 => BackendMessageTypeByte::AuthenticationRequest, + BackendMessage::AuthenticationCleartextPassword => BackendMessageTypeByte::AuthenticationRequest, + BackendMessage::AuthenticationMd5Password { .. } => BackendMessageTypeByte::AuthenticationRequest, + BackendMessage::AuthenticationGss => BackendMessageTypeByte::AuthenticationRequest, + BackendMessage::AuthenticationGssContinue { .. } => BackendMessageTypeByte::AuthenticationRequest, + BackendMessage::AuthenticationSppi => BackendMessageTypeByte::AuthenticationRequest, + BackendMessage::AuthenticationSasl { .. } => BackendMessageTypeByte::AuthenticationRequest, + BackendMessage::AuthenticationSaslContinue { .. } => BackendMessageTypeByte::AuthenticationRequest, + BackendMessage::AuthenticationSaslFinal { .. } => BackendMessageTypeByte::AuthenticationRequest, + BackendMessage::BackendKeyData { .. } => BackendMessageTypeByte::BackendKeyData, + BackendMessage::BindComplete => BackendMessageTypeByte::BindComplete, + BackendMessage::CloseComplete => BackendMessageTypeByte::CloseComplete, + BackendMessage::CommandComplete { .. } => BackendMessageTypeByte::CommandComplete, + BackendMessage::CopyData { .. } => BackendMessageTypeByte::CopyData, + BackendMessage::CopyDone => BackendMessageTypeByte::CopyDone, + BackendMessage::CopyInResponse { .. } => BackendMessageTypeByte::CopyInResponse, + BackendMessage::CopyOutResponse { .. } => BackendMessageTypeByte::CopyOutResponse, + BackendMessage::CopyBothResponse { .. } => BackendMessageTypeByte::CopyBothResponse, + BackendMessage::DataRow { .. } => BackendMessageTypeByte::DataRow, + BackendMessage::EmptyQueryResponse => BackendMessageTypeByte::EmptyQueryResponse, + BackendMessage::ErrorResponse { .. } => BackendMessageTypeByte::ErrorResponse, + BackendMessage::FunctionCallResponse { .. } => BackendMessageTypeByte::FunctionCallResponse, + BackendMessage::NegotiateProtocolVersion { .. } => BackendMessageTypeByte::NegotiateProtocolVersion, + BackendMessage::NoData => BackendMessageTypeByte::NoData, + BackendMessage::NoticeResponse { .. } => BackendMessageTypeByte::NoticeResponse, + BackendMessage::NotificationResponse { .. } => BackendMessageTypeByte::NotificationResponse, + BackendMessage::ParameterDescription { .. } => BackendMessageTypeByte::ParameterDescription, + BackendMessage::ParameterStatus { .. } => BackendMessageTypeByte::ParameterStatus, + BackendMessage::ParseComplete => BackendMessageTypeByte::ParseComplete, + BackendMessage::PortalSuspended => BackendMessageTypeByte::PortalSuspended, + BackendMessage::ReadyForQuery { .. } => BackendMessageTypeByte::ReadyForQuery, + BackendMessage::RowDescription { .. } => BackendMessageTypeByte::RowDescription, + } + } + + fn to_buffer(&self) -> Result, MessageError> { + let mut buf: Vec = vec!(); + let mut body: Vec = vec!(); + + buf.push(self.get_type_byte() as u8); + + let length = match self { + BackendMessage::AuthenticationOk => { + body.extend_from_slice(0i32.to_be_bytes().as_slice()); 8 + }, BackendMessage::AuthenticationKerberosV5 => { + body.extend_from_slice(2i32.to_be_bytes().as_slice()); 8 + }, BackendMessage::AuthenticationCleartextPassword => { + body.extend_from_slice(3i32.to_be_bytes().as_slice()); 8 + }, BackendMessage::AuthenticationMd5Password { salt } => { + body.extend_from_slice(5i32.to_be_bytes().as_slice()); + body.extend_from_slice(salt); 12 + }, BackendMessage::AuthenticationGss => { + body.extend_from_slice(7i32.to_be_bytes().as_slice()); 8 + }, BackendMessage::AuthenticationGssContinue { data } => { + body.extend_from_slice(8i32.to_be_bytes().as_slice()); + body.extend_from_slice(data.as_slice()); 8 + data.len() as i32 + }, BackendMessage::AuthenticationSppi => { + body.extend_from_slice(9i32.to_be_bytes().as_slice()); 8 + }, BackendMessage::AuthenticationSasl { mechanism_names } => { + body.extend_from_slice(10i32.to_be_bytes().as_slice()); + let length = mechanism_names.iter().fold(0, |acc,n| { + body.extend_from_slice(n.as_bytes_with_nul()); + acc + n.count_bytes() + 1 + }) as i32 + 9; body.push(b'\0'); length + }, BackendMessage::AuthenticationSaslContinue { data } => { + body.extend_from_slice(11i32.to_be_bytes().as_slice()); + body.extend_from_slice(data.as_slice()); 8 + data.len() as i32 + }, BackendMessage::AuthenticationSaslFinal { data } => { + body.extend_from_slice(12i32.to_be_bytes().as_slice()); + body.extend_from_slice(data.as_slice()); 8 + data.len() as i32 + }, BackendMessage::BackendKeyData { pid, key } => { + body.extend_from_slice(pid.to_be_bytes().as_slice()); + body.extend_from_slice(key); + 8 + key.len() as i32 + }, BackendMessage::BindComplete => 4, + BackendMessage::CloseComplete => 4, + BackendMessage::CommandComplete { tag } => { + let command_string: CString = tag.as_cstring(); + body.extend_from_slice(command_string.as_bytes_with_nul()); + 4 + command_string.count_bytes() as i32 + 1 as i32 + }, BackendMessage::CopyData { data } => { + body.extend_from_slice(data.as_slice()); + 4 + data.len() as i32 + }, BackendMessage::CopyDone => 4, + BackendMessage::CopyInResponse { overall_format, formats } => { + body.push(*overall_format as u8); + body.extend_from_slice((formats.len() as i16).to_be_bytes().as_slice()); + for f in formats { body.extend_from_slice((*f as i16).to_be_bytes().as_slice())}; + (7+ formats.len()*2) as i32 + }, BackendMessage::CopyOutResponse { overall_format, formats } => { + body.push(*overall_format as u8); + body.extend_from_slice((formats.len() as i16).to_be_bytes().as_slice()); + for f in formats { body.extend_from_slice((*f as i16).to_be_bytes().as_slice())}; + (7+ formats.len()*2) as i32 + }, BackendMessage::CopyBothResponse { overall_format, formats } => { + body.push(*overall_format as u8); + body.extend_from_slice((formats.len() as i16).to_be_bytes().as_slice()); + for f in formats { body.extend_from_slice((*f as i16).to_be_bytes().as_slice())}; + (7+ formats.len()*2) as i32 + }, BackendMessage::DataRow { data } => { + let mut length = 6i32; // 4 (length field) + 2 (column count) + body.extend_from_slice((data.len() as i16).to_be_bytes().as_slice()); + for col in data { + match col { + Some(c) => { + body.extend_from_slice((c.len() as i32).to_be_bytes().as_slice()); + body.extend_from_slice(c.as_slice()); + length += 4 + c.len() as i32; + }, None => { + body.extend_from_slice((-1i32).to_be_bytes().as_slice()); + length += 4; + } + } + } + length + }, BackendMessage::EmptyQueryResponse => 4, + BackendMessage::ErrorResponse { errors } => { + let mut length = 4i32; + for error in errors { + // None = a field type we didn't recognise on parse; its original + // byte is gone, so we drop it rather than emit a garbage field. + if let Some(e) = error.0 { + body.push(e as u8); + body.extend_from_slice(error.1.as_bytes_with_nul()); + length += 1 + error.1.count_bytes() as i32 + 1; + } + } + body.push(b'\0'); // the field list is terminated by a zero byte + length + 1 + } BackendMessage::FunctionCallResponse { value } => { + match value { + Some(v) => { + body.extend_from_slice((v.len() as i32).to_be_bytes().as_slice()); + body.extend_from_slice(v.as_slice()); + 8 + v.len() as i32 + }, None => { + body.extend_from_slice((-1i32).to_be_bytes().as_slice()); + 8 + } + } + } BackendMessage::NegotiateProtocolVersion { minor_version, unrecognized_options } => { + let mut length = 12i32; + body.extend_from_slice(minor_version.to_be_bytes().as_slice()); + body.extend_from_slice((unrecognized_options.len() as i32).to_be_bytes().as_slice()); + for ur_opt in unrecognized_options { + body.extend_from_slice(ur_opt.as_bytes_with_nul()); + length += ur_opt.count_bytes() as i32 + 1; + } + length + }, BackendMessage::NoData => 4, + BackendMessage::NoticeResponse { notices } => { + let mut length = 4i32; + for notice in notices { + if let Some(n) = notice.0 { + body.push(n as u8); + body.extend_from_slice(notice.1.as_bytes_with_nul()); + length += 1 + notice.1.count_bytes() as i32 + 1; + } + } + body.push(b'\0'); // the field list is terminated by a zero byte + length + 1 + }, BackendMessage::NotificationResponse { pid, channel_name, payload } => { + body.extend_from_slice(pid.to_be_bytes().as_slice()); + body.extend_from_slice(channel_name.as_bytes_with_nul()); + body.extend_from_slice(payload.as_bytes_with_nul()); + 8 + channel_name.count_bytes() as i32+ payload.count_bytes() as i32 + 2 + }, BackendMessage::ParameterDescription { object_ids } => { + body.extend_from_slice((object_ids.len() as i16).to_be_bytes().as_slice()); + for o_id in object_ids { + body.extend_from_slice((*o_id).to_be_bytes().as_slice()); + } + 6 + object_ids.len() as i32 * 4 + }, BackendMessage::ParameterStatus { param_name, param_value } => { + body.extend_from_slice(param_name.as_bytes_with_nul()); + body.extend_from_slice(param_value.as_bytes_with_nul()); + 4 + param_name.count_bytes() as i32 + param_value.count_bytes() as i32 + 2 + }, BackendMessage::ParseComplete => 4, + BackendMessage::PortalSuspended => 4, + BackendMessage::ReadyForQuery { transaction_status } => { + body.push(*transaction_status as u8); + 5 + }, BackendMessage::RowDescription { fields } => { + let mut length = 6; + body.extend_from_slice((fields.len() as i16).to_be_bytes().as_slice()); + for field in fields { + length += 19 + field.name.count_bytes() as i32; + body.extend_from_slice(field.name.as_bytes_with_nul()); + match field.table_oid { + Some(oid) => body.extend_from_slice(oid.to_be_bytes().as_slice()), + None => body.extend_from_slice((0i32).to_be_bytes().as_slice()), + }; + match field.attr_num { + Some(attr) => body.extend_from_slice(attr.to_be_bytes().as_slice()), + None => body.extend_from_slice((0i16).to_be_bytes().as_slice()), + }; + body.extend_from_slice(field.type_oid.to_be_bytes().as_slice()); + body.extend_from_slice(field.type_size.to_be_bytes().as_slice()); + body.extend_from_slice(field.type_modifier.to_be_bytes().as_slice()); + body.extend_from_slice((field.format as i16).to_be_bytes().as_slice()); + } + length + }, + }; + + buf.extend_from_slice(&(length as i32).to_be_bytes()); + buf.extend_from_slice(body.as_slice()); + + Ok(buf) + } + + //fn from_buffer(buf: &[u8]) -> Result, MessageError> { + // if buf.len() < 4 { return Ok(None) } + + // let type_byte = BackendMessageTypeByte::try_from(buf[0])?; + + // let length = i32::from_be_bytes( + // buf.get(1..5).ok_or(MessageError::MalformedMessage)? // or `else return Ok(None)` — see below + // .try_into().map_err(|_| MessageError::MalformedMessage)?, + // ) as usize; + // if length < 4 { return Err(MessageError::MalformedMessage)} + + // let (discrim, body_offset) = match type_byte { + // BackendMessageTypeByte::AuthenticationRequest => ( + // Some(i32::from_be_bytes(buf[5..9].try_into().map_err(|_| MessageError::MalformedMessage)?)), + // 9 + // ), _ => ( + // None, + // 5 + // ), + // }; + + // let body = match buf.get(body_offset..length+1) { + // Some(b) => b, + // None => return Ok(None), + // }; + + // let message_type = BackendMessageType::from_byte(type_byte, discrim)?; + + // let mut reader = BodyReader { buffer: body, pos: 0 }; + fn from_buffer(buf: &[u8]) -> Result, MessageError> { + // Need at least the type byte + 4-byte length to read the header at all. + let header = match buf.get(0..5) { + Some(h) => h, + None => return Ok(None), // incomplete: header not fully arrived + }; + + let type_byte = BackendMessageTypeByte::try_from(header[0])?; + let length = i32::from_be_bytes( + header[1..5].try_into().map_err(|_| MessageError::MalformedMessage)?, + ) as usize; + + // Length counts itself (the 4 length bytes) but not the type byte, so the + // smallest legal value is 4. Below that the frame is malformed, not short; + // above MAX_MESSAGE_LEN it's a corrupt/hostile length we refuse to wait for. + if length < 4 || length > MAX_MESSAGE_LEN { + return Err(MessageError::MalformedMessage); + } + + // AuthenticationRequest carries a 4-byte sub-discriminant at the front of + // its body; everything else starts its body right after the length field. + let body_offset = match type_byte { + BackendMessageTypeByte::AuthenticationRequest => 9, + _ => 5, + }; + + // The declared length must be able to cover whatever header we consume past + // the length field. Total frame occupies `length + 1` bytes (type byte is + // the +1, not counted in length), so the body ends at `length + 1`. + // If that end is before where the body starts, the length is lying → malformed. + if length + 1 < body_offset { + return Err(MessageError::MalformedMessage); + } + + // For auth, read the discriminant — but only once we know the bytes are present. + // Missing here means the frame isn't fully in the buffer yet (incomplete), + // *not* malformed, because `length` already claims to cover these bytes. + let discrim = match type_byte { + BackendMessageTypeByte::AuthenticationRequest => { + match buf.get(5..9) { + Some(d) => Some(i32::from_be_bytes( + d.try_into().map_err(|_| MessageError::MalformedMessage)?, + )), + None => return Ok(None), + } + } + _ => None, + }; + + // The body is everything from body_offset to the end of the frame. + // None here = frame not fully arrived = incomplete. + let body = match buf.get(body_offset..length + 1) { + Some(b) => b, + None => return Ok(None), + }; + + let consumed = length + 1; + let message_type = BackendMessageType::from_byte(type_byte, discrim)?; + let mut reader = BodyReader { buffer: body, pos: 0 }; + Ok(Some((match message_type { + BackendMessageType::AuthenticationOk => BackendMessage::AuthenticationOk, + BackendMessageType::AuthenticationKerberosV5 => BackendMessage::AuthenticationKerberosV5, + BackendMessageType::AuthenticationCleartextPassword => BackendMessage::AuthenticationCleartextPassword, + BackendMessageType::AuthenticationMd5Password => BackendMessage::AuthenticationMd5Password { salt: reader.bytes(4)?.as_slice().try_into().map_err(|_|MessageError::MalformedMessage)? }, + BackendMessageType::AuthenticationGss => BackendMessage::AuthenticationGss, + BackendMessageType::AuthenticationGssContinue => BackendMessage::AuthenticationGssContinue { data: reader.rest().to_owned() }, + BackendMessageType::AuthenticationSppi => BackendMessage::AuthenticationSppi, + BackendMessageType::AuthenticationSasl => { + let mut mechanism_names = vec!(); + loop { + if reader.peek()? == b'\0' { break } + mechanism_names.push(reader.c_string()?); + } + BackendMessage::AuthenticationSasl { mechanism_names } + }, BackendMessageType::AuthenticationSaslContinue => BackendMessage::AuthenticationSaslContinue { data: reader.rest().to_owned() }, + BackendMessageType::AuthenticationSaslFinal => BackendMessage::AuthenticationSaslFinal { data: reader.rest().to_owned() }, + BackendMessageType::BackendKeyData => BackendMessage::BackendKeyData { pid: reader.i32()?, key: reader.rest().to_owned() }, + BackendMessageType::BindComplete => BackendMessage::BindComplete, + BackendMessageType::CloseComplete => BackendMessage::CloseComplete, + BackendMessageType::CommandComplete => BackendMessage::CommandComplete { tag: CommandTag::from_cstring(reader.c_string()?)? }, + BackendMessageType::CopyData => BackendMessage::CopyData { data: reader.rest().to_owned() }, + BackendMessageType::CopyDone => BackendMessage::CopyDone, + BackendMessageType::CopyInResponse => { + let overall_format = Format::try_from(reader.i8()?)?; + let num_formats = reader.i16()?; + let mut formats = vec!(); + for _ in 0..num_formats { + formats.push(Format::try_from(reader.i16()?)?); + } + BackendMessage::CopyInResponse { overall_format, formats } + }, BackendMessageType::CopyOutResponse => { + let overall_format = Format::try_from(reader.i8()?)?; + let num_formats = reader.i16()?; + let mut formats = vec!(); + for _ in 0..num_formats { + formats.push(Format::try_from(reader.i16()?)?); + } + BackendMessage::CopyOutResponse { overall_format, formats } + }, BackendMessageType::CopyBothResponse => { + let overall_format = Format::try_from(reader.i8()?)?; + let num_formats = reader.i16()?; + let mut formats = vec!(); + for _ in 0..num_formats { + formats.push(Format::try_from(reader.i16()?)?); + } + BackendMessage::CopyBothResponse { overall_format, formats } + }, BackendMessageType::DataRow => { + let num_values = reader.i16()?; + let mut data = vec!(); + for _ in 0..num_values { + let value_len = reader.i32()?; + data.push( if value_len == -1 { None } + else if value_len < -1 { return Err(MessageError::MalformedMessage) } + else { Some(reader.bytes(value_len as usize)?) }); + } + BackendMessage::DataRow { data } + }, BackendMessageType::EmptyQueryResponse => BackendMessage::EmptyQueryResponse, + BackendMessageType::ErrorResponse => { + let mut errors = vec!(); + loop { + let type_byte = reader.u8()?; + if type_byte == b'\0' { break } + let error_type = ErrorType::from_byte(type_byte); + let error_value = reader.c_string()?; + errors.push((error_type, error_value)); + } + BackendMessage::ErrorResponse { errors } + }, BackendMessageType::FunctionCallResponse => { + let value_len = reader.i32()?; + let value = if value_len == -1 { None } + else if value_len < -1 { return Err(MessageError::MalformedMessage) } + else {Some(reader.bytes(value_len as usize)?)}; + BackendMessage::FunctionCallResponse { value } + }, BackendMessageType::NegotiateProtocolVersion => { + let minor_version = reader.i32()?; + let num_unrecognized_options = reader.i32()?; + let mut unrecognized_options = vec!(); + for _ in 0..num_unrecognized_options { + unrecognized_options.push(reader.c_string()?); + } + BackendMessage::NegotiateProtocolVersion { minor_version, unrecognized_options } + }, BackendMessageType::NoData => BackendMessage::NoData, + BackendMessageType::NoticeResponse => { + let mut notices = vec!(); + loop { + let type_byte = reader.u8()?; + if type_byte == b'\0' { break } + let notice_type = NoticeType::from_byte(type_byte); + let notice_value = reader.c_string()?; + notices.push((notice_type, notice_value)); + } + BackendMessage::NoticeResponse { notices } + }, BackendMessageType::NotificationResponse => { + let pid = reader.i32()?; + let channel_name = reader.c_string()?; + let payload = reader.c_string()?; + BackendMessage::NotificationResponse { pid, channel_name, payload } + }, BackendMessageType::ParameterDescription => { + let num_oids = reader.i16()?; + let mut object_ids = vec!(); + for _ in 0..num_oids { + object_ids.push(reader.i32()?); + } + BackendMessage::ParameterDescription { object_ids } + }, BackendMessageType::ParameterStatus => BackendMessage::ParameterStatus { param_name: reader.c_string()?, param_value: reader.c_string()? }, + BackendMessageType::ParseComplete => BackendMessage::ParseComplete, + BackendMessageType::PortalSuspended => BackendMessage::PortalSuspended, + BackendMessageType::ReadyForQuery => BackendMessage::ReadyForQuery { transaction_status: TransactionStatus::try_from(reader.u8()?)? }, + BackendMessageType::RowDescription => { + let num_fields = reader.i16()?; + let mut fields = vec!(); + for _ in 0..num_fields { + // Wire order is name first, then table OID, then column attr number. + let name = reader.c_string()?; + let table_oid = match reader.i32()? { + 0 => None, + s => Some(s), + }; + let attr_num = match reader.i16()? { + 0 => None, + s => Some(s), + }; + fields.push(RowDescription { + name, + table_oid, + attr_num, + type_oid: reader.i32()?, + type_size: reader.i16()?, + type_modifier: reader.i32()?, + format: Format::try_from(reader.i16()?)?, + }); + } + BackendMessage::RowDescription { fields } + }, + }, consumed))) + } +} + +#[derive(Copy,Clone)] +#[repr(u8)] +pub enum Target { + Statement = b'S', + Portal = b'P', +} + +impl TryFrom for Target { + type Error = MessageError; + + fn try_from(value: u8) -> Result { + Ok(match value { + b'S' => Target::Statement, + b'P' => Target::Portal, + _ => Err(MessageError::MalformedMessage)?, + }) + } +} + +pub struct RowDescription { + name: CString, + table_oid: Option, + attr_num: Option, + type_oid: i32, + type_size: i16, + type_modifier: i32, + format: Format, +} + +#[repr(u8)] +#[derive(Copy,Clone)] +pub enum ErrorType { + SeverityLocalized = b'S', + Severity = b'V', + Code = b'C', + Message = b'M', + Detail = b'D', + Hint = b'H', + Position = b'P', + InternalPosition = b'p', + InternalQuery = b'q', + Where = b'W', + SchemaName = b's', + TableName = b't', + ColumnName = b'c', + DataTypeName = b'd', + ConstraintName = b'n', + FileName = b'F', + Line = b'L', + Routine = b'R', +} + +impl TryFrom for ErrorType { + type Error = MessageError; + + fn try_from(value: u8) -> Result { + Ok(match value { + b'S' => ErrorType::SeverityLocalized, + b'V' => ErrorType::Severity, + b'C' => ErrorType::Code, + b'M' => ErrorType::Message, + b'D' => ErrorType::Detail, + b'H' => ErrorType::Hint, + b'P' => ErrorType::Position, + b'p' => ErrorType::InternalPosition, + b'q' => ErrorType::InternalQuery, + b'W' => ErrorType::Where, + b's' => ErrorType::SchemaName, + b't' => ErrorType::TableName, + b'c' => ErrorType::ColumnName, + b'd' => ErrorType::DataTypeName, + b'n' => ErrorType::ConstraintName, + b'F' => ErrorType::FileName, + b'L' => ErrorType::Line, + b'R' => ErrorType::Routine, + _ => Err(MessageError::MalformedMessage)?, + }) + } +} + +impl ErrorType { + fn from_byte(byte: u8) -> Option { + match byte { + b'S' => Some(ErrorType::SeverityLocalized), + b'V' => Some(ErrorType::Severity), + b'C' => Some(ErrorType::Code), + b'M' => Some(ErrorType::Message), + b'D' => Some(ErrorType::Detail), + b'H' => Some(ErrorType::Hint), + b'P' => Some(ErrorType::Position), + b'p' => Some(ErrorType::InternalPosition), + b'q' => Some(ErrorType::InternalQuery), + b'W' => Some(ErrorType::Where), + b's' => Some(ErrorType::SchemaName), + b't' => Some(ErrorType::TableName), + b'c' => Some(ErrorType::ColumnName), + b'd' => Some(ErrorType::DataTypeName), + b'n' => Some(ErrorType::ConstraintName), + b'F' => Some(ErrorType::FileName), + b'L' => Some(ErrorType::Line), + b'R' => Some(ErrorType::Routine), + _ => None, + } + } +} + + + +#[repr(u8)] +#[derive(Copy,Clone)] +pub enum NoticeType { + SeverityLocalized = b'S', + Severity = b'V', + Code = b'C', + Message = b'M', + Detail = b'D', + Hint = b'H', + Position = b'P', + InternalPosition = b'p', + InternalQuery = b'q', + Where = b'W', + SchemaName = b's', + TableName = b't', + ColumnName = b'c', + DataTypeName = b'd', + ConstraintName = b'n', + FileName = b'F', + Line = b'L', + Routine = b'R', +} + +impl TryFrom for NoticeType { + type Error = MessageError; + + fn try_from(value: u8) -> Result { + Ok(match value { + b'S' => NoticeType::SeverityLocalized, + b'V' => NoticeType::Severity, + b'C' => NoticeType::Code, + b'M' => NoticeType::Message, + b'D' => NoticeType::Detail, + b'H' => NoticeType::Hint, + b'P' => NoticeType::Position, + b'p' => NoticeType::InternalPosition, + b'q' => NoticeType::InternalQuery, + b'W' => NoticeType::Where, + b's' => NoticeType::SchemaName, + b't' => NoticeType::TableName, + b'c' => NoticeType::ColumnName, + b'd' => NoticeType::DataTypeName, + b'n' => NoticeType::ConstraintName, + b'F' => NoticeType::FileName, + b'L' => NoticeType::Line, + b'R' => NoticeType::Routine, + _ => Err(MessageError::MalformedMessage)?, + }) + } +} + +impl NoticeType { + fn from_byte(byte: u8) -> Option { + match byte { + b'S' => Some(NoticeType::SeverityLocalized), + b'V' => Some(NoticeType::Severity), + b'C' => Some(NoticeType::Code), + b'M' => Some(NoticeType::Message), + b'D' => Some(NoticeType::Detail), + b'H' => Some(NoticeType::Hint), + b'P' => Some(NoticeType::Position), + b'p' => Some(NoticeType::InternalPosition), + b'q' => Some(NoticeType::InternalQuery), + b'W' => Some(NoticeType::Where), + b's' => Some(NoticeType::SchemaName), + b't' => Some(NoticeType::TableName), + b'c' => Some(NoticeType::ColumnName), + b'd' => Some(NoticeType::DataTypeName), + b'n' => Some(NoticeType::ConstraintName), + b'F' => Some(NoticeType::FileName), + b'L' => Some(NoticeType::Line), + b'R' => Some(NoticeType::Routine), + _ => None, + } + } +} + + +#[repr(u8)] +#[derive(Copy,Clone)] +pub enum TransactionStatus { + Idle = b'I', + InTransaction = b'T', + InFailedTransaction = b'E', +} + +impl TryFrom for TransactionStatus { + type Error = MessageError; + + fn try_from(value: u8) -> Result { + Ok(match value { + b'I' => Self::Idle, + b'T' => Self::InTransaction, + b'E' => Self::InFailedTransaction, + _ => Err(MessageError::MalformedMessage)?, + }) + } +} + +#[derive(Clone)] +pub enum CommandTag { + Insert { + oid: i32, + rows: i32, + }, + Delete { + rows: i32, + }, + Update { + rows: i32, + }, + Merge { + rows: i32, + }, + Select { + rows: i32, + }, + Move { + rows: i32, + }, + Fetch { + rows: i32, + }, + Copy { + rows: Option, + }, + Other { + string: CString, + } +} + +impl CommandTag { + fn as_cstring(&self) -> CString { + match self { + CommandTag::Insert { oid, rows } => CString::new(format!("INSERT 0 {}",rows)).unwrap(), + CommandTag::Delete { rows } => CString::new(format!("DELETE {}", rows)).unwrap(), + CommandTag::Update { rows } => CString::new(format!("UPDATE {}", rows)).unwrap(), + CommandTag::Merge { rows } => CString::new(format!("MERGE {}", rows)).unwrap(), + CommandTag::Select { rows } => CString::new(format!("SELECT {}", rows)).unwrap(), + CommandTag::Move { rows } => CString::new(format!("MOVE {}", rows)).unwrap(), + CommandTag::Fetch { rows } => CString::new(format!("FETCH {}", rows)).unwrap(), + CommandTag::Copy { rows } => match rows { + Some(r) => CString::new(format!("COPY {}", r)).unwrap(), + None => c"COPY".to_owned(), + }, + CommandTag::Other { string } => string.clone(), + } + } + + fn from_cstring(c_string: CString) -> Result { + let s = c_string.to_str().map_err(|_| MessageError::MalformedMessage)?; + + let mut parts = s.split(' '); + let verb = parts.next().ok_or(MessageError::MalformedMessage)?; + let rest: Vec<&str> = parts.collect(); + + fn num(s: &str) -> Result { + s.parse().map_err(|_| MessageError::MalformedMessage) + } + + Ok(match (verb, rest.as_slice()) { + ("INSERT", [oid, rows]) => CommandTag::Insert { oid: num(oid)?, rows: num(rows)? }, + ("DELETE", [rows]) => CommandTag::Delete { rows: num(rows)? }, + ("UPDATE", [rows]) => CommandTag::Update { rows: num(rows)? }, + ("MERGE", [rows]) => CommandTag::Merge { rows: num(rows)? }, + ("SELECT", [rows]) => CommandTag::Select { rows: num(rows)? }, + ("MOVE", [rows]) => CommandTag::Move { rows: num(rows)? }, + ("FETCH", [rows]) => CommandTag::Fetch { rows: num(rows)? }, + ("COPY", [rows]) => CommandTag::Copy { rows: Some(num(rows)?) }, + ("COPY", []) => CommandTag::Copy { rows: None }, + _ => CommandTag::Other { string: c_string }, + }) + } +} + +#[derive(Copy,Clone)] +#[repr(i16)] +pub enum Format { + Text = 0, + Binary = 1, +} + +impl TryFrom for Format { + type Error = MessageError; + fn try_from(value: i16) -> Result { + Ok( match value { + 0 => Format::Text, + 1 => Format::Binary, + _ => Err(MessageError::MalformedMessage)?, + }) + } +} + +impl TryFrom for Format { + type Error = MessageError; + + fn try_from(value: i8) -> Result { + // The 1-byte overall_format in Copy responses; defer to the i16 impl so + // there's a single place that decides what a valid format code is. + Format::try_from(value as i16) + } +} + +pub struct BodyReader<'a> { + buffer: &'a [u8], + pos: usize, +} + +impl<'a> BodyReader<'a> { + fn i32(&mut self) -> Result { + let result = Ok(i32::from_be_bytes(self.buffer.get(self.pos..self.pos+4).ok_or(MessageError::MalformedMessage)?.try_into().map_err(|_| MessageError::MalformedMessage)?)); + self.pos += 4; + result + } + + fn i16(&mut self) -> Result { + let result = i16::from_be_bytes(self.buffer.get(self.pos..self.pos+2).ok_or(MessageError::MalformedMessage)?.try_into().map_err(|_| MessageError::MalformedMessage)?); + self.pos += 2; + Ok(result) + } + + fn u8(&mut self) -> Result { + let result:u8 = *self.buffer.get(self.pos).ok_or(MessageError::MalformedMessage)?; + self.pos += 1; + Ok(result) + } + + fn i8(&mut self) -> Result { + let result:i8 = *self.buffer.get(self.pos).ok_or(MessageError::MalformedMessage)? as i8; + self.pos += 1; + Ok(result) + } + + fn c_string(&mut self) -> Result { + let result = CStr::from_bytes_until_nul(&self.buffer[self.pos..]).map_err(|_|MessageError::MalformedMessage)?.to_owned(); + self.pos += result.count_bytes() + 1; + Ok(result) + } + + fn bytes(&mut self, len: usize) -> Result, MessageError> { + let result = self.buffer.get(self.pos..self.pos+len).ok_or(MessageError::MalformedMessage)?.to_owned(); + self.pos += len; + Ok(result) + } + + fn peek(&self) -> Result { + (self.buffer.get(self.pos)).ok_or(MessageError::MalformedMessage).map(|b| *b) + } + + fn rest(&self) -> &'a [u8] { + &self.buffer[self.pos..] + } +} diff --git a/postgresql-client/src/session.rs b/postgresql-client/src/session.rs new file mode 100644 index 0000000..687cd3d --- /dev/null +++ b/postgresql-client/src/session.rs @@ -0,0 +1,104 @@ +use std::{io::{Read, Write}, net::{IpAddr, Ipv4Addr, SocketAddr, TcpStream}, os::unix::{self, net::UnixStream}}; + +use crate::{PsqlResult, PsqlError}; +use crate::message::{BackendMessage, Message, MessageError}; +use crate::dns::resolve_url; + +pub struct PsqlSession { + location: Location, + connection: SocketConnection, +} + +impl PsqlSession { + //pub fn read_messages(&mut self) -> Result, PsqlError> { + // Ok(()) + //} + + pub fn connect(location: Option) -> PsqlResult { + //Use provided location or default to 127.0.0.1:5432 + let location = location.unwrap_or(Location::Ip(SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 5432))); + + let connection = location.connect().unwrap(); + + Ok(PsqlSession{ + location, + connection, + }) + } + + pub fn wait_for_response(&mut self) -> PsqlResult { + todo!() + } + +} + +#[derive(Debug)] +pub enum Location { + UnixSocket(String), + URI(String), + Ip(SocketAddr), +} + +type ConnectionError = (Location, String); + +impl Location { + fn connect(&self) -> Result { + Ok(match self { + Location::UnixSocket(path) => SocketConnection::Unix(UnixStream::connect(path).unwrap()), + Location::URI(uri) => SocketConnection::Tcp(TcpStream::connect(SocketAddr::new(resolve_url(uri.clone()).unwrap(), 5432)).unwrap()), + Location::Ip(addr) => SocketConnection::Tcp(TcpStream::connect(addr).unwrap()), + }) + } +} + +pub enum SocketConnection { + Unix(UnixStream), + Tcp(TcpStream), +} + +impl Read for SocketConnection { + fn read(&mut self, buf: &mut [u8]) -> std::io::Result { + match self { + SocketConnection::Unix(unix_stream) => unix_stream.read(buf), + SocketConnection::Tcp(tcp_stream) => tcp_stream.read(buf), + } + } +} + +impl Write for SocketConnection { + fn write(&mut self, buf: &[u8]) -> std::io::Result { + match self { + SocketConnection::Unix(unix_stream) => unix_stream.write(buf), + SocketConnection::Tcp(tcp_stream) => tcp_stream.write(buf), + } + } + + fn flush(&mut self) -> std::io::Result<()> { + match self { + SocketConnection::Unix(unix_stream) => unix_stream.flush(), + SocketConnection::Tcp(tcp_stream) => tcp_stream.flush(), + } + } +} + +//pub fn startup(session: &mut PsqlSession) -> PsqlResult<()> { +// let startup_message = Message { +// message_type: MessageType::Startup, +// }; +// +// send_message(startup_message)?; +// +// let response = wait_for_response(session)?; +// +// match response.message_type { +// MessageType::ErrorResponse => todo!(), +// MessageType::NoticeResponse => todo!(), +// MessageType::AuthenticationOk => todo!(), //No auth needed. +// MessageType::AuthenticationRequest(authentication_request_type) => todo!(), //Auth Needed +// _ => Err(PsqlError::UnexpectedMessageType(response.message_type))? +// } +// +// +// +// Ok(()) +//} \ No newline at end of file diff --git a/postgresql-client/src/types.rs b/postgresql-client/src/types.rs new file mode 100644 index 0000000..cb1c41f --- /dev/null +++ b/postgresql-client/src/types.rs @@ -0,0 +1,37 @@ +enum PsqlType { + //Numeric Types. + SmallInt, + Integer, + BigInt, + Decimal, + Numeric, + Real, + DoublePrecision, + SmallSerial, + Serial, + BigSerial, + + Money, + + VarChar, + Char, + BpChar, + Text, + + Bytea, + + Timestamp, + TimestampTz, + Date, + Time, + TimeTz, + Interval, + + Boolean, + + +} + +impl PsqlType { + +} \ No newline at end of file diff --git a/time/Cargo.toml b/time/Cargo.toml new file mode 100644 index 0000000..f59d86f --- /dev/null +++ b/time/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "time" +version = "0.0.0" +edition = "2024" + +[dependencies] \ No newline at end of file diff --git a/time/src/format.rs b/time/src/format.rs new file mode 100644 index 0000000..e69de29 diff --git a/time/src/lib.rs b/time/src/lib.rs new file mode 100644 index 0000000..dd3ccfc --- /dev/null +++ b/time/src/lib.rs @@ -0,0 +1,7 @@ +mod time; +pub use time::*; + +mod utc; +pub use utc::*; + +mod format; \ No newline at end of file diff --git a/time/src/time.rs b/time/src/time.rs new file mode 100644 index 0000000..60efd63 --- /dev/null +++ b/time/src/time.rs @@ -0,0 +1,48 @@ + +pub struct Timestamp { + micros: i64, +} + +pub struct EpochedTimestamp{ + value: i64, + epoch: Epoch, +} + +pub enum Epoch { + Unix, + Postgres, + J2000, + JulianDay, +} + +pub struct CivilDate { + year: i64, + day_of_year: u64, +} + +pub struct CivilDateTime { + date: CivilDate, + micros: i64, +} + +pub struct GregorianDate { + year: i64, + month: u8, + day: u8, +} + +pub struct GregorianDateTime { + date: GregorianDate, + hour: u8, + minute: u8, + second: u8, +} + +pub struct Daystamp { + days: i64, +} + +pub struct DayTime { + days: i64, + micros: i64, +} \ No newline at end of file diff --git a/time/src/utc.rs b/time/src/utc.rs new file mode 100644 index 0000000..31ca73f --- /dev/null +++ b/time/src/utc.rs @@ -0,0 +1,19 @@ + +pub struct UtcTz { + date: Utc, + tz: TimeZone, +} + +pub struct Utc { + year: i64, + month: u8, + day: u16, + hour: u8, + minute: u8, + second: u8, +} + +pub struct TimeZone { + hour_offset: u8, + minute_offset: u8, +} \ No newline at end of file diff --git a/uri/Cargo.toml b/uri/Cargo.toml new file mode 100644 index 0000000..e779a27 --- /dev/null +++ b/uri/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "uri" +version = "0.0.0" +edition = "2024" + +[dependencies] \ No newline at end of file diff --git a/uri/src/lib.rs b/uri/src/lib.rs new file mode 100644 index 0000000..700cc0b --- /dev/null +++ b/uri/src/lib.rs @@ -0,0 +1,59 @@ +use std::{io::{Write, Result as IoResult}, net::IpAddr }; + +pub struct Uri { + scheme: String, + authority: Authority, + path: String, + query: String, +} + +impl Uri { + pub fn write_to(&self, w: &mut W) -> IoResult<()> { + w.write_all(self.scheme.as_bytes())?; + w.write_all(b"://")?; + self.authority.write_to(w)?; + w.write_all(b"/")?; + w.write_all(self.path.as_bytes())?; + w.write_all(b"?")?; + w.write_all(self.path.as_bytes()) + } +} + +pub struct Authority { + user_info: Option, + host: Host, + port: Option, +} + +impl Authority { + pub fn write_to(&self, w: &mut W) -> IoResult<()> { + w.write_all(self.user_info.clone().map(|ui| ui + "@").unwrap_or("".to_owned()).as_bytes())?; + self.host.write_to(w)?; + w.write_all(self.port.map(|p| ":".to_owned() + p.to_string().as_str()).unwrap_or("".to_owned()).as_bytes()) + } +} + +#[derive(Clone)] +pub enum Host { + Ip(IpAddr), + Name(HostName), +} + +impl Host { + pub fn write_to(&self, w: &mut W) -> IoResult<()> { + match self { + Host::Ip(ip_addr) => w.write_all(ip_addr.to_string().as_bytes()), + Host::Name(name) => w.write_all(name.0.as_bytes()), + } + } +} + +#[derive(Clone)] +pub struct HostName(String); + +impl HostName { + pub fn labels_iter(&self) -> impl Iterator { + //TODO: This is probably too simplistic, even though it's meant to be the point. + self.0.split_terminator('.') + } +} \ No newline at end of file diff --git a/web-server/Cargo.toml b/web-server/Cargo.toml new file mode 100644 index 0000000..5c9f17a --- /dev/null +++ b/web-server/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "web-server" +version = "0.0.0" +edition = "2024" + +[dependencies] +uri = {path = "../uri"} +rustls = { version = "0.23.41", default-features = false, features = ["std", "tls12", "ring"] } +rustls-pki-types = "1.14.1" +webpki-roots = "1.0.8" \ No newline at end of file diff --git a/web-server/README.md b/web-server/README.md new file mode 100644 index 0000000..4c5426a --- /dev/null +++ b/web-server/README.md @@ -0,0 +1 @@ +Mostly for testing, but we'll see how we go, it could be useful in other ways too. \ No newline at end of file diff --git a/web-server/src/main.rs b/web-server/src/main.rs new file mode 100644 index 0000000..96540eb --- /dev/null +++ b/web-server/src/main.rs @@ -0,0 +1,36 @@ +use std::path::Path; + +use uri::Host; +use rustls::pki_types::{pem::PemObject, CertificateDer, PrivateKeyDer}; + +fn main() { + println!("Hello, world!"); +} + +struct TlsStuff { + public: Vec>, + private: PrivateKeyDer<'static>, +} + +/// Load the full certificate chain (leaf first, then intermediates). +fn load_certs(path: impl AsRef) -> Result>, String> { + let certs = CertificateDer::pem_file_iter(path).unwrap() + .collect::, _>>().unwrap(); + Ok(certs) +} + +/// Load the first private key found, regardless of encoding +/// (PKCS#8, PKCS#1/RSA, or SEC1/EC all work). +fn load_key(path: impl AsRef) -> Result, String> { + Ok(PrivateKeyDer::from_pem_file(path).unwrap()) +} + +//Given a file path and a host, respond to any request under that host with the contents of that file. +fn serve_file(path: &Path, host: Host, tls: Option) -> Result<(),String> { + Ok(()) +} + +//Given some html bytes (unverified) and a host, respond to any request under that host with those bytes. +fn serve_html_bytes(bytes: &[u8], host: Host, tls: Option) -> Result<(), String> { + Ok(()) +} \ No newline at end of file

, + other_prime_len_bits: BitLength, +) -> Result, LimbSliceError> { + // `elem_exp_consttime_inner` is parameterized on `STORAGE_LIMBS` only so + // we can run tests with larger-than-supported-in-operation test vectors. + elem_exp_consttime_inner::( + out, + base, + oneRRR, + exponent, + p, + other_prime_len_bits, + ) +} + +// The maximum modulus size supported for `elem_exp_consttime` in normal +// operation. +const ELEM_EXP_CONSTTIME_MAX_MODULUS_LIMBS: usize = 2048 / LIMB_BITS; +const _LIMBS_PER_CHUNK_DIVIDES_ELEM_EXP_CONSTTIME_MAX_MODULUS_LIMBS: () = + assert!(ELEM_EXP_CONSTTIME_MAX_MODULUS_LIMBS % limbs512::LIMBS_PER_CHUNK == 0); +const WINDOW_BITS: u32 = 5; +const TABLE_ENTRIES: usize = 1 << WINDOW_BITS; +const STORAGE_ENTRIES: usize = TABLE_ENTRIES + if cfg!(target_arch = "x86_64") { 3 } else { 0 }; + +#[cfg(not(target_arch = "x86_64"))] +fn elem_exp_consttime_inner( + out: Storage, + base_mod_n: &Elem, + oneRRR: &One, + exponent: &PrivateExponent, + m: &Modulus, + other_prime_len_bits: BitLength, +) -> Result, LimbSliceError> { + use crate::{bssl, limb::Window}; + + let base_rinverse: Elem = elem_reduced(out, base_mod_n, m, other_prime_len_bits); + + let num_limbs = m.limbs().len(); + let m_chunked: AsChunks = match slice::as_chunks(m.limbs()) + { + (m, []) => m, + _ => { + return Err(LimbSliceError::len_mismatch(LenMismatchError::new( + num_limbs, + ))) + } + }; + let cpe = m_chunked.len(); // 512-bit chunks per entry. + + // This code doesn't have the strict alignment requirements that the x86_64 + // version does, but uses the same aligned storage for convenience. + assert!(STORAGE_LIMBS % (STORAGE_ENTRIES * limbs512::LIMBS_PER_CHUNK) == 0); // TODO: `const` + let mut table = limbs512::AlignedStorage::::zeroed(); + let mut table = table + .aligned_chunks_mut(TABLE_ENTRIES, cpe) + .map_err(LimbSliceError::len_mismatch)?; + + // TODO: Rewrite the below in terms of `AsChunks`. + let table = table.as_flattened_mut(); + + fn gather(table: &[Limb], acc: &mut Elem, i: Window) { + prefixed_extern! { + fn LIMBS_select_512_32( + r: *mut Limb, + table: *const Limb, + num_limbs: c::size_t, + i: Window, + ) -> bssl::Result; + } + Result::from(unsafe { + LIMBS_select_512_32(acc.limbs.as_mut_ptr(), table.as_ptr(), acc.limbs.len(), i) + }) + .unwrap(); + } + + fn power( + table: &[Limb], + mut acc: Elem, + m: &Modulus, + i: Window, + mut tmp: Elem, + ) -> (Elem, Elem) { + for _ in 0..WINDOW_BITS { + acc = elem_squared(acc, m); + } + gather(table, &mut tmp, i); + let acc = elem_mul(&tmp, acc, m); + (acc, tmp) + } + + fn entry(table: &[Limb], i: usize, num_limbs: usize) -> &[Limb] { + &table[(i * num_limbs)..][..num_limbs] + } + fn entry_mut(table: &mut [Limb], i: usize, num_limbs: usize) -> &mut [Limb] { + &mut table[(i * num_limbs)..][..num_limbs] + } + + // table[0] = base**0 (i.e. 1). + m.oneR(entry_mut(table, 0, num_limbs)); + + // table[1] = base*R == (base/R * RRR)/R + limbs_mul_mont( + ( + entry_mut(table, 1, num_limbs), + base_rinverse.limbs.as_ref(), + oneRRR.as_ref().limbs.as_ref(), + ), + m.limbs(), + m.n0(), + m.cpu_features(), + )?; + for i in 2..TABLE_ENTRIES { + let (src1, src2) = if i % 2 == 0 { + (i / 2, i / 2) + } else { + (i - 1, 1) + }; + let (previous, rest) = table.split_at_mut(num_limbs * i); + let src1 = entry(previous, src1, num_limbs); + let src2 = entry(previous, src2, num_limbs); + let dst = entry_mut(rest, 0, num_limbs); + limbs_mul_mont((dst, src1, src2), m.limbs(), m.n0(), m.cpu_features())?; + } + + let mut acc = Elem { + limbs: base_rinverse.limbs, + encoding: PhantomData, + }; + let tmp = m.alloc_zero(); + let tmp = Elem { + limbs: tmp.limbs, + encoding: PhantomData, + }; + let (acc, _) = limb::fold_5_bit_windows( + exponent.limbs(), + |initial_window| { + gather(&table, &mut acc, initial_window); + (acc, tmp) + }, + |(acc, tmp), window| power(&table, acc, m, window, tmp), + ); + + Ok(acc.into_unencoded(m)) +} + +#[cfg(target_arch = "x86_64")] +fn elem_exp_consttime_inner( + out: Storage, + base_mod_n: &Elem, + oneRRR: &One, + exponent: &PrivateExponent, + m: &Modulus, + other_prime_len_bits: BitLength, +) -> Result, LimbSliceError> { + use super::limbs::x86_64::mont::{ + gather5, mul_mont5, mul_mont_gather5_amm, power5_amm, scatter5, sqr_mont5, + }; + use crate::{ + cpu::{ + intel::{Adx, Bmi2}, + GetFeature as _, + }, + limb::{LeakyWindow, Window}, + polyfill::slice::AsChunksMut, + }; + + let n0 = m.n0(); + + let cpu2 = m.cpu_features().get_feature(); + let cpu3 = m.cpu_features().get_feature(); + + if base_mod_n.limbs.len() != m.limbs().len() * 2 { + return Err(LimbSliceError::len_mismatch(LenMismatchError::new( + base_mod_n.limbs.len(), + ))); + } + + let m_original: AsChunks = match slice::as_chunks(m.limbs()) { + (m, []) => m, + _ => return Err(LimbSliceError::len_mismatch(LenMismatchError::new(8))), + }; + let cpe = m_original.len(); // 512-bit chunks per entry + + let oneRRR = &oneRRR.as_ref().limbs; + let oneRRR = match slice::as_chunks(oneRRR) { + (c, []) => c, + _ => { + return Err(LimbSliceError::len_mismatch(LenMismatchError::new( + oneRRR.len(), + ))) + } + }; + + // The x86_64 assembly was written under the assumption that the input data + // is aligned to `MOD_EXP_CTIME_ALIGN` bytes, which was/is 64 in OpenSSL. + // Subsequently, it was changed such that, according to BoringSSL, they + // only require 16 byte alignment. We enforce the old, stronger, alignment + // unless/until we can see a benefit to reducing it. + // + // Similarly, OpenSSL uses the x86_64 assembly functions by giving it only + // inputs `tmp`, `am`, and `np` that immediately follow the table. + // According to BoringSSL, in older versions of the OpenSSL code, this + // extra space was required for memory safety because the assembly code + // would over-read the table; according to BoringSSL, this is no longer the + // case. Regardless, the upstream code also contained comments implying + // that this was also important for performance. For now, we do as OpenSSL + // did/does. + const MOD_EXP_CTIME_ALIGN: usize = 64; + // Required by + const _TABLE_ENTRIES_IS_32: () = assert!(TABLE_ENTRIES == 32); + const _STORAGE_ENTRIES_HAS_3_EXTRA: () = assert!(STORAGE_ENTRIES == TABLE_ENTRIES + 3); + + assert!(STORAGE_LIMBS % (STORAGE_ENTRIES * limbs512::LIMBS_PER_CHUNK) == 0); // TODO: `const` + let mut table = limbs512::AlignedStorage::::zeroed(); + let mut table = table + .aligned_chunks_mut(STORAGE_ENTRIES, cpe) + .map_err(LimbSliceError::len_mismatch)?; + let (mut table, mut state) = table.split_at_mut(TABLE_ENTRIES * cpe); + assert_eq!((table.as_ptr() as usize) % MOD_EXP_CTIME_ALIGN, 0); + + // These are named `(tmp, am, np)` in BoringSSL. + let (mut acc, mut rest) = state.split_at_mut(cpe); + let (mut base_cached, mut m_cached) = rest.split_at_mut(cpe); + + // "To improve cache locality" according to upstream. + m_cached + .as_flattened_mut() + .copy_from_slice(m_original.as_flattened()); + let m_cached = m_cached.as_ref(); + + let out: Elem = elem_reduced(out, base_mod_n, m, other_prime_len_bits); + let base_rinverse = match slice::as_chunks(&out.limbs) { + (c, []) => c, + _ => { + return Err(LimbSliceError::len_mismatch(LenMismatchError::new( + out.limbs.len(), + ))) + } + }; + + // base_cached = base*R == (base/R * RRR)/R + mul_mont5( + base_cached.as_mut(), + base_rinverse, + oneRRR, + m_cached, + n0, + cpu2, + )?; + let base_cached = base_cached.as_ref(); + let mut out = Storage::from(out); // recycle. + + // Fill in all the powers of 2 of `acc` into the table using only squaring and without any + // gathering, storing the last calculated power into `acc`. + fn scatter_powers_of_2( + mut table: AsChunksMut, + mut acc: AsChunksMut, + m_cached: AsChunks, + n0: &N0, + mut i: LeakyWindow, + cpu: Option<(Adx, Bmi2)>, + ) -> Result<(), LimbSliceError> { + loop { + scatter5(acc.as_ref(), table.as_mut(), i)?; + i *= 2; + if i >= TABLE_ENTRIES as LeakyWindow { + break; + } + sqr_mont5(acc.as_mut(), m_cached, n0, cpu)?; + } + Ok(()) + } + + // All entries in `table` will be Montgomery encoded. + + // acc = table[0] = base**0 (i.e. 1). + m.oneR(acc.as_flattened_mut()); + scatter5(acc.as_ref(), table.as_mut(), 0)?; + + // acc = base**1 (i.e. base). + acc.as_flattened_mut() + .copy_from_slice(base_cached.as_flattened()); + + // Fill in entries 1, 2, 4, 8, 16. + scatter_powers_of_2(table.as_mut(), acc.as_mut(), m_cached, n0, 1, cpu2)?; + // Fill in entries 3, 6, 12, 24; 5, 10, 20, 30; 7, 14, 28; 9, 18; 11, 22; 13, 26; 15, 30; + // 17; 19; 21; 23; 25; 27; 29; 31. + for i in (3..(TABLE_ENTRIES as LeakyWindow)).step_by(2) { + let power = Window::from(i - 1); + assert!(power < 32); // Not secret, + unsafe { + mul_mont_gather5_amm( + acc.as_mut(), + base_cached, + table.as_ref(), + m_cached, + n0, + power, + cpu3, + ) + }?; + scatter_powers_of_2(table.as_mut(), acc.as_mut(), m_cached, n0, i, cpu2)?; + } + + let table = table.as_ref(); + + let acc = limb::fold_5_bit_windows( + exponent.limbs(), + |initial_window| { + unsafe { gather5(acc.as_mut(), table, initial_window) } + .unwrap_or_else(unwrap_impossible_limb_slice_error); + acc + }, + |mut acc, window| { + unsafe { power5_amm(acc.as_mut(), table, m_cached, n0, window, cpu3) } + .unwrap_or_else(unwrap_impossible_limb_slice_error); + acc + }, + ); + + // Reuse `base_rinverse`'s limbs to save an allocation. + out.limbs.copy_from_slice(acc.as_flattened()); + Ok(from_montgomery_amm(out, m)) +} + +/// Verified a == b**-1 (mod m), i.e. a**-1 == b (mod m). +pub fn verify_inverses_consttime( + a: &Elem, + b: Elem, + m: &Modulus, +) -> Result<(), error::Unspecified> { + let r = elem_mul(a, b, m); + limb::verify_limbs_equal_1_leak_bit(&r.limbs) +} + +#[inline] +pub fn elem_verify_equal_consttime( + a: &Elem, + b: &Elem, +) -> Result<(), error::Unspecified> { + let equal = limb::limbs_equal_limbs_consttime(&a.limbs, &b.limbs) + .unwrap_or_else(unwrap_impossible_len_mismatch_error); + if !equal.leak() { + return Err(error::Unspecified); + } + Ok(()) +} + +#[cold] +#[inline(never)] +fn unwrap_impossible_len_mismatch_error(LenMismatchError { .. }: LenMismatchError) -> T { + unreachable!() +} + +#[cold] +#[inline(never)] +fn unwrap_impossible_limb_slice_error(err: LimbSliceError) { + match err { + LimbSliceError::LenMismatch(_) => unreachable!(), + LimbSliceError::TooShort(_) => unreachable!(), + LimbSliceError::TooLong(_) => unreachable!(), + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::cpu; + use crate::testutil as test; + + // Type-level representation of an arbitrary modulus. + struct M {} + + impl PublicModulus for M {} + + #[test] + fn test_elem_exp_consttime() { + let cpu_features = cpu::features(); + test::run( + test_vector_file!("../../crypto/fipsmodule/bn/test/mod_exp_tests.txt"), + |section, test_case| { + assert_eq!(section, ""); + + let m = consume_modulus::(test_case, "M"); + let m = m.modulus(cpu_features); + let expected_result = consume_elem(test_case, "ModExp", &m); + let base = consume_elem(test_case, "A", &m); + let e = { + let bytes = test_case.consume_bytes("E"); + PrivateExponent::from_be_bytes_for_test_only(untrusted::Input::from(&bytes), &m) + .expect("valid exponent") + }; + + let oneRR = One::newRR(m.alloc_zero(), &m); + let oneRRR = One::newRRR(oneRR, &m); + + // `base` in the test vectors is reduced (mod M) already but + // the API expects the bsae to be (mod N) where N = M * P for + // some other prime of the same length. Fake that here. + // Pretend there's another prime of equal length. + struct N {} + let other_modulus_len_bits = m.len_bits(); + let base: Elem = { + let mut limbs = BoxedLimbs::zero(base.limbs.len() * 2); + limbs[..base.limbs.len()].copy_from_slice(&base.limbs); + Elem { + limbs, + encoding: PhantomData, + } + }; + + let too_big = m.limbs().len() > ELEM_EXP_CONSTTIME_MAX_MODULUS_LIMBS; + let actual_result = if !too_big { + elem_exp_consttime( + m.alloc_zero(), + &base, + &oneRRR, + &e, + &m, + other_modulus_len_bits, + ) + } else { + let actual_result = elem_exp_consttime( + m.alloc_zero(), + &base, + &oneRRR, + &e, + &m, + other_modulus_len_bits, + ); + // TODO: Be more specific with which error we expect? + assert!(actual_result.is_err()); + // Try again with a larger-than-normally-supported limit + elem_exp_consttime_inner::<_, _, { (4096 / LIMB_BITS) * STORAGE_ENTRIES }>( + m.alloc_zero(), + &base, + &oneRRR, + &e, + &m, + other_modulus_len_bits, + ) + }; + match actual_result { + Ok(r) => assert_elem_eq(&r, &expected_result), + Err(LimbSliceError::LenMismatch { .. }) => panic!(), + Err(LimbSliceError::TooLong { .. }) => panic!(), + Err(LimbSliceError::TooShort { .. }) => panic!(), + }; + + Ok(()) + }, + ) + } + + // TODO: fn test_elem_exp_vartime() using + // "src/rsa/bigint_elem_exp_vartime_tests.txt". See that file for details. + // In the meantime, the function is tested indirectly via the RSA + // verification and signing tests. + #[test] + fn test_elem_mul() { + let cpu_features = cpu::features(); + test::run( + test_vector_file!("../../crypto/fipsmodule/bn/test/mod_mul_tests.txt"), + |section, test_case| { + assert_eq!(section, ""); + + let m = consume_modulus::(test_case, "M"); + let m = m.modulus(cpu_features); + let expected_result = consume_elem(test_case, "ModMul", &m); + let a = consume_elem(test_case, "A", &m); + let b = consume_elem(test_case, "B", &m); + + let b = into_encoded(m.alloc_zero(), b, &m); + let a = into_encoded(m.alloc_zero(), a, &m); + let actual_result = elem_mul(&a, b, &m); + let actual_result = actual_result.into_unencoded(&m); + assert_elem_eq(&actual_result, &expected_result); + + Ok(()) + }, + ) + } + + #[test] + fn test_elem_squared() { + let cpu_features = cpu::features(); + test::run( + test_vector_file!("bigint_elem_squared_tests.txt"), + |section, test_case| { + assert_eq!(section, ""); + + let m = consume_modulus::(test_case, "M"); + let m = m.modulus(cpu_features); + let expected_result = consume_elem(test_case, "ModSquare", &m); + let a = consume_elem(test_case, "A", &m); + + let a = into_encoded(m.alloc_zero(), a, &m); + let actual_result = elem_squared(a, &m); + let actual_result = actual_result.into_unencoded(&m); + assert_elem_eq(&actual_result, &expected_result); + + Ok(()) + }, + ) + } + + #[test] + fn test_elem_reduced() { + let cpu_features = cpu::features(); + test::run( + test_vector_file!("bigint_elem_reduced_tests.txt"), + |section, test_case| { + assert_eq!(section, ""); + + struct M {} + + let m_ = consume_modulus::(test_case, "M"); + let m = m_.modulus(cpu_features); + let expected_result = consume_elem(test_case, "R", &m); + let a = + consume_elem_unchecked::(test_case, "A", expected_result.limbs.len() * 2); + let other_modulus_len_bits = m_.len_bits(); + + let actual_result = elem_reduced(m.alloc_zero(), &a, &m, other_modulus_len_bits); + let oneRR = One::newRR(m.alloc_zero(), &m); + let actual_result = elem_mul(oneRR.as_ref(), actual_result, &m); + assert_elem_eq(&actual_result, &expected_result); + + Ok(()) + }, + ) + } + + #[test] + fn test_elem_reduced_once() { + let cpu_features = cpu::features(); + test::run( + test_vector_file!("bigint_elem_reduced_once_tests.txt"), + |section, test_case| { + assert_eq!(section, ""); + + struct M {} + struct O {} + let m = consume_modulus::(test_case, "m"); + let m = m.modulus(cpu_features); + let a = consume_elem_unchecked::(test_case, "a", m.limbs().len()); + let expected_result = consume_elem::(test_case, "r", &m); + let other_modulus_len_bits = m.len_bits(); + + let actual_result = + elem_reduced_once(m.alloc_zero(), &a, &m, other_modulus_len_bits); + assert_elem_eq(&actual_result, &expected_result); + + Ok(()) + }, + ) + } + + fn consume_elem( + test_case: &mut test::TestCase, + name: &str, + m: &Modulus, + ) -> Elem { + let value = test_case.consume_bytes(name); + Elem::from_be_bytes_padded(untrusted::Input::from(&value), m).unwrap() + } + + fn consume_elem_unchecked( + test_case: &mut test::TestCase, + name: &str, + num_limbs: usize, + ) -> Elem { + let bytes = test_case.consume_bytes(name); + let mut limbs = BoxedLimbs::zero(num_limbs); + limb::parse_big_endian_and_pad_consttime(untrusted::Input::from(&bytes), &mut limbs) + .unwrap(); + Elem { + limbs, + encoding: PhantomData, + } + } + + fn consume_modulus(test_case: &mut test::TestCase, name: &str) -> OwnedModulus { + let value = test_case.consume_bytes(name); + OwnedModulus::from( + OwnedModulusValue::from_be_bytes(untrusted::Input::from(&value)).unwrap(), + ) + } + + fn assert_elem_eq(a: &Elem, b: &Elem) { + if elem_verify_equal_consttime(a, b).is_err() { + panic!("{:x?} != {:x?}", &*a.limbs, &*b.limbs); + } + } + + fn into_encoded(out: Storage, a: Elem, m: &Modulus) -> Elem { + let oneRR = One::newRR(out, m); + elem_mul(oneRR.as_ref(), a, m) + } +} diff --git a/http/vendor/ring/src/arithmetic/bigint/boxed_limbs.rs b/http/vendor/ring/src/arithmetic/bigint/boxed_limbs.rs new file mode 100644 index 0000000..6eb465c --- /dev/null +++ b/http/vendor/ring/src/arithmetic/bigint/boxed_limbs.rs @@ -0,0 +1,81 @@ +// Copyright 2015-2023 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::Modulus; +use crate::{ + error, + limb::{self, Limb}, +}; +use alloc::{boxed::Box, vec}; +use core::{ + marker::PhantomData, + ops::{Deref, DerefMut}, +}; + +/// All `BoxedLimbs` are stored in the same number of limbs. +pub(super) struct BoxedLimbs { + limbs: Box<[Limb]>, + + /// The modulus *m* that determines the size of `limbx`. + m: PhantomData, +} + +impl Deref for BoxedLimbs { + type Target = [Limb]; + #[inline] + fn deref(&self) -> &Self::Target { + &self.limbs + } +} + +impl DerefMut for BoxedLimbs { + #[inline] + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.limbs + } +} + +// TODO: `derive(Clone)` after https://github.com/rust-lang/rust/issues/26925 +// is resolved or restrict `M: Clone`. +impl Clone for BoxedLimbs { + fn clone(&self) -> Self { + Self { + limbs: self.limbs.clone(), + m: self.m, + } + } +} + +impl BoxedLimbs { + pub(super) fn from_be_bytes_padded_less_than( + input: untrusted::Input, + m: &Modulus, + ) -> Result { + let mut r = Self::zero(m.limbs().len()); + limb::parse_big_endian_and_pad_consttime(input, &mut r)?; + limb::verify_limbs_less_than_limbs_leak_bit(&r, m.limbs())?; + Ok(r) + } + + pub(super) fn zero(len: usize) -> Self { + Self { + limbs: vec![0; len].into_boxed_slice(), + m: PhantomData, + } + } + + pub(super) fn into_limbs(self) -> Box<[Limb]> { + self.limbs + } +} diff --git a/http/vendor/ring/src/arithmetic/bigint/modulus.rs b/http/vendor/ring/src/arithmetic/bigint/modulus.rs new file mode 100644 index 0000000..b0cd6d6 --- /dev/null +++ b/http/vendor/ring/src/arithmetic/bigint/modulus.rs @@ -0,0 +1,202 @@ +// Copyright 2015-2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::{ + super::montgomery::Unencoded, unwrap_impossible_len_mismatch_error, BoxedLimbs, Elem, + OwnedModulusValue, PublicModulus, Storage, N0, +}; +use crate::{ + bits::BitLength, + cpu, error, + limb::{self, Limb, LIMB_BITS}, + polyfill::LeadingZerosStripped, +}; +use core::marker::PhantomData; + +/// The modulus *m* for a ring ℤ/mℤ, along with the precomputed values needed +/// for efficient Montgomery multiplication modulo *m*. The value must be odd +/// and larger than 2. The larger-than-1 requirement is imposed, at least, by +/// the modular inversion code. +pub struct OwnedModulus { + inner: OwnedModulusValue, + + // n0 * N == -1 (mod r). + // + // r == 2**(N0::LIMBS_USED * LIMB_BITS) and LG_LITTLE_R == lg(r). This + // ensures that we can do integer division by |r| by simply ignoring + // `N0::LIMBS_USED` limbs. Similarly, we can calculate values modulo `r` by + // just looking at the lowest `N0::LIMBS_USED` limbs. This is what makes + // Montgomery multiplication efficient. + // + // As shown in Algorithm 1 of "Fast Prime Field Elliptic Curve Cryptography + // with 256 Bit Primes" by Shay Gueron and Vlad Krasnov, in the loop of a + // multi-limb Montgomery multiplication of a * b (mod n), given the + // unreduced product t == a * b, we repeatedly calculate: + // + // t1 := t % r |t1| is |t|'s lowest limb (see previous paragraph). + // t2 := t1*n0*n + // t3 := t + t2 + // t := t3 / r copy all limbs of |t3| except the lowest to |t|. + // + // In the last step, it would only make sense to ignore the lowest limb of + // |t3| if it were zero. The middle steps ensure that this is the case: + // + // t3 == 0 (mod r) + // t + t2 == 0 (mod r) + // t + t1*n0*n == 0 (mod r) + // t1*n0*n == -t (mod r) + // t*n0*n == -t (mod r) + // n0*n == -1 (mod r) + // n0 == -1/n (mod r) + // + // Thus, in each iteration of the loop, we multiply by the constant factor + // n0, the negative inverse of n (mod r). + // + // TODO(perf): Not all 32-bit platforms actually make use of n0[1]. For the + // ones that don't, we could use a shorter `R` value and use faster `Limb` + // calculations instead of double-precision `u64` calculations. + n0: N0, +} + +impl Clone for OwnedModulus { + fn clone(&self) -> Self { + Self { + inner: self.inner.clone(), + n0: self.n0, + } + } +} + +impl OwnedModulus { + pub(crate) fn from(n: OwnedModulusValue) -> Self { + // n_mod_r = n % r. As explained in the documentation for `n0`, this is + // done by taking the lowest `N0::LIMBS_USED` limbs of `n`. + #[allow(clippy::useless_conversion)] + let n0 = { + prefixed_extern! { + fn bn_neg_inv_mod_r_u64(n: u64) -> u64; + } + + // XXX: u64::from isn't guaranteed to be constant time. + let mut n_mod_r: u64 = u64::from(n.limbs()[0]); + + if N0::LIMBS_USED == 2 { + // XXX: If we use `<< LIMB_BITS` here then 64-bit builds + // fail to compile because of `deny(exceeding_bitshifts)`. + debug_assert_eq!(LIMB_BITS, 32); + n_mod_r |= u64::from(n.limbs()[1]) << 32; + } + N0::precalculated(unsafe { bn_neg_inv_mod_r_u64(n_mod_r) }) + }; + + Self { inner: n, n0 } + } + + pub fn to_elem(&self, l: &Modulus) -> Result, error::Unspecified> { + self.inner.verify_less_than(l)?; + let mut limbs = BoxedLimbs::zero(l.limbs().len()); + limbs[..self.inner.limbs().len()].copy_from_slice(self.inner.limbs()); + Ok(Elem { + limbs, + encoding: PhantomData, + }) + } + + pub(crate) fn modulus(&self, cpu_features: cpu::Features) -> Modulus { + Modulus { + limbs: self.inner.limbs(), + n0: self.n0, + len_bits: self.len_bits(), + m: PhantomData, + cpu_features, + } + } + + pub fn len_bits(&self) -> BitLength { + self.inner.len_bits() + } +} + +impl OwnedModulus { + pub fn be_bytes(&self) -> LeadingZerosStripped + Clone + '_> { + LeadingZerosStripped::new(limb::unstripped_be_bytes(self.inner.limbs())) + } +} + +pub struct Modulus<'a, M> { + limbs: &'a [Limb], + n0: N0, + len_bits: BitLength, + m: PhantomData, + cpu_features: cpu::Features, +} + +impl Modulus<'_, M> { + pub(super) fn oneR(&self, out: &mut [Limb]) { + assert_eq!(self.limbs.len(), out.len()); + + let r = self.limbs.len() * LIMB_BITS; + + // out = 2**r - m where m = self. + limb::limbs_negative_odd(out, self.limbs); + + let lg_m = self.len_bits().as_bits(); + let leading_zero_bits_in_m = r - lg_m; + + // When m's length is a multiple of LIMB_BITS, which is the case we + // most want to optimize for, then we already have + // out == 2**r - m == 2**r (mod m). + if leading_zero_bits_in_m != 0 { + debug_assert!(leading_zero_bits_in_m < LIMB_BITS); + // Correct out to 2**(lg m) (mod m). `limbs_negative_odd` flipped + // all the leading zero bits to ones. Flip them back. + *out.last_mut().unwrap() &= (!0) >> leading_zero_bits_in_m; + + // Now we have out == 2**(lg m) (mod m). Keep doubling until we get + // to 2**r (mod m). + for _ in 0..leading_zero_bits_in_m { + limb::limbs_double_mod(out, self.limbs) + .unwrap_or_else(unwrap_impossible_len_mismatch_error); + } + } + + // Now out == 2**r (mod m) == 1*R. + } + + // TODO: XXX Avoid duplication with `Modulus`. + pub fn alloc_zero(&self) -> Storage { + Storage { + limbs: BoxedLimbs::zero(self.limbs.len()), + } + } + + #[inline] + pub(super) fn limbs(&self) -> &[Limb] { + self.limbs + } + + #[inline] + pub(super) fn n0(&self) -> &N0 { + &self.n0 + } + + pub fn len_bits(&self) -> BitLength { + self.len_bits + } + + #[inline] + pub(crate) fn cpu_features(&self) -> cpu::Features { + self.cpu_features + } +} diff --git a/http/vendor/ring/src/arithmetic/bigint/modulusvalue.rs b/http/vendor/ring/src/arithmetic/bigint/modulusvalue.rs new file mode 100644 index 0000000..84f5884 --- /dev/null +++ b/http/vendor/ring/src/arithmetic/bigint/modulusvalue.rs @@ -0,0 +1,88 @@ +// Copyright 2015-2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::{ + super::{MAX_LIMBS, MIN_LIMBS}, + BoxedLimbs, Modulus, PublicModulus, +}; +use crate::{ + bits::BitLength, + error, + limb::{self, Limb, LIMB_BYTES}, +}; + +/// `OwnedModulus`, without the overhead of Montgomery multiplication support. +pub(crate) struct OwnedModulusValue { + limbs: BoxedLimbs, // Also `value >= 3`. + + len_bits: BitLength, +} + +impl Clone for OwnedModulusValue { + fn clone(&self) -> Self { + Self { + limbs: self.limbs.clone(), + len_bits: self.len_bits, + } + } +} + +impl OwnedModulusValue { + pub(crate) fn from_be_bytes(input: untrusted::Input) -> Result { + let num_limbs = (input.len() + LIMB_BYTES - 1) / LIMB_BYTES; + const _MODULUS_MIN_LIMBS_AT_LEAST_2: () = assert!(MIN_LIMBS >= 2); + if num_limbs < MIN_LIMBS { + return Err(error::KeyRejected::unexpected_error()); + } + if num_limbs > MAX_LIMBS { + return Err(error::KeyRejected::too_large()); + } + // The above implies n >= 3, so we don't need to check that. + + // Reject leading zeros. Also reject the value zero ([0]) because zero + // isn't positive. + if untrusted::Reader::new(input).peek(0) { + return Err(error::KeyRejected::invalid_encoding()); + } + + let mut limbs = BoxedLimbs::zero(num_limbs); + limb::parse_big_endian_and_pad_consttime(input, &mut limbs) + .map_err(|error::Unspecified| error::KeyRejected::unexpected_error())?; + limb::limbs_reject_even_leak_bit(&limbs) + .map_err(|_: error::Unspecified| error::KeyRejected::invalid_component())?; + + let len_bits = limb::limbs_minimal_bits(&limbs); + + Ok(Self { limbs, len_bits }) + } + + pub fn verify_less_than(&self, l: &Modulus) -> Result<(), error::Unspecified> { + if self.len_bits() > l.len_bits() { + return Err(error::Unspecified); + } + if self.limbs.len() == l.limbs().len() { + limb::verify_limbs_less_than_limbs_leak_bit(&self.limbs, l.limbs())?; + } + Ok(()) + } + + pub fn len_bits(&self) -> BitLength { + self.len_bits + } + + #[inline] + pub(super) fn limbs(&self) -> &[Limb] { + &self.limbs + } +} diff --git a/http/vendor/ring/src/arithmetic/bigint/private_exponent.rs b/http/vendor/ring/src/arithmetic/bigint/private_exponent.rs new file mode 100644 index 0000000..82e75bf --- /dev/null +++ b/http/vendor/ring/src/arithmetic/bigint/private_exponent.rs @@ -0,0 +1,77 @@ +// Copyright 2015-2023 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::{limb, BoxedLimbs, Limb, Modulus}; +use crate::error; +use alloc::boxed::Box; + +pub struct PrivateExponent { + // Unlike most `[Limb]` we deal with, these are stored most significant + // word first. + limbs: Box<[Limb]>, +} + +impl PrivateExponent { + // `p` is the modulus for which the exponent is in the interval [1, `p` - 1). + pub fn from_be_bytes_padded( + input: untrusted::Input, + p: &Modulus, + ) -> Result { + let mut dP = BoxedLimbs::from_be_bytes_padded_less_than(input, p)?; + + // Proof that `dP < p - 1`: + // + // If `dP < p` then either `dP == p - 1` or `dP < p - 1`. Since `p` is + // odd, `p - 1` is even. `d` is odd, and an odd number modulo an even + // number is odd. Therefore `dP` must be odd. But then it cannot be + // `p - 1` and so we know `dP < p - 1`. + // + // Further we know `dP != 0` because `dP` is not even. + limb::limbs_reject_even_leak_bit(&dP)?; + dP.reverse(); + + Ok(Self { + limbs: dP.into_limbs(), + }) + } + + // Create a `PrivateExponent` with a value that we do not support in + // production use, to allow testing with additional test vectors. + #[cfg(test)] + pub fn from_be_bytes_for_test_only( + input: untrusted::Input, + p: &Modulus, + ) -> Result { + use crate::limb::LIMB_BYTES; + + // Do exactly what `from_be_bytes_padded` does for any inputs it accepts. + if let r @ Ok(_) = Self::from_be_bytes_padded(input, p) { + return r; + } + + let num_limbs = (input.len() + LIMB_BYTES - 1) / LIMB_BYTES; + let mut limbs = BoxedLimbs::::zero(num_limbs); + limb::parse_big_endian_and_pad_consttime(input, &mut limbs) + .map_err(|error::Unspecified| error::KeyRejected::unexpected_error())?; + limbs.reverse(); + Ok(Self { + limbs: limbs.into_limbs(), + }) + } + + #[inline] + pub(super) fn limbs(&self) -> &[Limb] { + &self.limbs + } +} diff --git a/http/vendor/ring/src/arithmetic/constant.rs b/http/vendor/ring/src/arithmetic/constant.rs new file mode 100644 index 0000000..81d61ea --- /dev/null +++ b/http/vendor/ring/src/arithmetic/constant.rs @@ -0,0 +1,27 @@ +use crate::limb::LeakyLimb; +use core::mem::size_of; + +const fn parse_digit(d: u8) -> u8 { + match d.to_ascii_lowercase() { + b'0'..=b'9' => d - b'0', + b'a'..=b'f' => d - b'a' + 10, + _ => panic!(), + } +} + +// TODO: this would be nicer as a trait, but currently traits don't support const functions +pub const fn limbs_from_hex(hex: &str) -> [LeakyLimb; LIMBS] { + let hex = hex.as_bytes(); + let mut limbs = [0; LIMBS]; + let limb_nibbles = size_of::() * 2; + let mut i = 0; + + while i < hex.len() { + let char = hex[hex.len() - 1 - i]; + let val = parse_digit(char); + limbs[i / limb_nibbles] |= (val as LeakyLimb) << ((i % limb_nibbles) * 4); + i += 1; + } + + limbs +} diff --git a/http/vendor/ring/src/arithmetic/ffi.rs b/http/vendor/ring/src/arithmetic/ffi.rs new file mode 100644 index 0000000..336fb68 --- /dev/null +++ b/http/vendor/ring/src/arithmetic/ffi.rs @@ -0,0 +1,97 @@ +// Copyright 2024-2025 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::{inout::AliasingSlices3, n0::N0, LimbSliceError, MAX_LIMBS, MIN_LIMBS}; +use crate::{c, limb::Limb, polyfill::usize_from_u32}; +use core::{mem::size_of, num::NonZeroUsize}; + +const _MAX_LIMBS_ADDRESSES_MEMORY_SAFETY_ISSUES: () = { + // BoringSSL's limit: 8 kiloBYTES. + const BN_MONTGOMERY_MAX_WORDS: usize = (8 * 1092) / size_of::(); + assert!(MAX_LIMBS <= BN_MONTGOMERY_MAX_WORDS); + + // Some 64-bit assembly implementations were written to take `len` as a + // `c_int`, so they zero out the undefined top half of `len` to convert it + // to a `usize`. But, others don't. + assert!(MAX_LIMBS <= usize_from_u32(u32::MAX)); +}; + +macro_rules! bn_mul_mont_ffi { + ( $in_out:expr, $n:expr, $n0:expr, $cpu:expr, + unsafe { ($MIN_LEN:expr, $MOD_LEN:expr, $Cpu:ty) => $f:ident }) => {{ + use crate::{c, limb::Limb}; + prefixed_extern! { + // `r` and/or 'a' and/or 'b' may alias. + // XXX: BoringSSL declares these functions to return `int`. + fn $f( + r: *mut Limb, + a: *const Limb, + b: *const Limb, + n: *const Limb, + n0: &N0, + len: c::NonZero_size_t, + ); + } + unsafe { + crate::arithmetic::ffi::bn_mul_mont_ffi::<$Cpu, { $MIN_LEN }, { $MOD_LEN }>( + $in_out, $n, $n0, $cpu, $f, + ) + } + }}; +} + +#[inline] +pub(super) unsafe fn bn_mul_mont_ffi( + in_out: impl AliasingSlices3, + n: &[Limb], + n0: &N0, + cpu: Cpu, + f: unsafe extern "C" fn( + r: *mut Limb, + a: *const Limb, + b: *const Limb, + n: *const Limb, + n0: &N0, + len: c::NonZero_size_t, + ), +) -> Result<(), LimbSliceError> { + assert_eq!(n.len() % LEN_MOD, 0); // The caller should guard against this. + + /// The x86 implementation of `bn_mul_mont`, at least, requires at least 4 + /// limbs. For a long time we have required 4 limbs for all targets, though + /// this may be unnecessary. + const _MIN_LIMBS_AT_LEAST_4: () = assert!(MIN_LIMBS >= 4); + // We haven't tested shorter lengths. + assert!(LEN_MIN >= MIN_LIMBS); + if n.len() < LEN_MIN { + return Err(LimbSliceError::too_short(n.len())); + } + let len = NonZeroUsize::new(n.len()).unwrap_or_else(|| { + // Unreachable because we checked against `LEN_MIN`, and we checked + // `LEN_MIN` is nonzero. + unreachable!() + }); + + // Avoid stack overflow from the alloca inside. + if len.get() > MAX_LIMBS { + return Err(LimbSliceError::too_long(n.len())); + } + in_out + .with_non_dangling_non_null_pointers_rab(len, |r, a, b| { + let n = n.as_ptr(); + let _: Cpu = cpu; + unsafe { f(r, a, b, n, n0, len) }; + }) + .map_err(LimbSliceError::len_mismatch) +} diff --git a/http/vendor/ring/src/arithmetic/inout.rs b/http/vendor/ring/src/arithmetic/inout.rs new file mode 100644 index 0000000..0c9c4a1 --- /dev/null +++ b/http/vendor/ring/src/arithmetic/inout.rs @@ -0,0 +1,177 @@ +// Copyright 2025 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +pub(crate) use crate::error::LenMismatchError; +use core::num::NonZeroUsize; + +pub(crate) trait AliasingSlices2 { + /// The pointers passed to `f` will be valid and non-null, and will not + /// be dangling, so they can be passed to C functions. + /// + /// The first pointer, `r`, may be pointing to uninitialized memory for + /// `expected_len` elements of type `T`, properly aligned and writable. + /// `f` must not read from `r` before writing to it. + /// + /// The second & third pointers, `a` and `b`, point to `expected_len` + /// values of type `T`, properly aligned. + /// + /// `r`, `a`, and/or `b` may alias each other only in the following ways: + /// `ptr::eq(r, a)`, `ptr::eq(r, b)`, and/or `ptr::eq(a, b)`; i.e. they + /// will not be "overlapping." + /// + /// Implementations of this trait shouldn't override this default + /// implementation. + #[inline(always)] + fn with_non_dangling_non_null_pointers_ra( + self, + expected_len: NonZeroUsize, + f: impl FnOnce(*mut T, *const T) -> R, + ) -> Result + where + Self: Sized, + { + self.with_potentially_dangling_non_null_pointers_ra(expected_len.get(), f) + } + + /// If `expected_len == 0` then the pointers passed to `f` may be + /// dangling pointers, which should not be passed to C functions. In all + /// other respects, this works like + /// `Self::with_non_dangling_non_null_pointers_rab`. + /// + /// Implementations of this trait should implement this method and not + /// `with_non_dangling_non_null_pointers_rab`. Users of this trait should + /// use `with_non_dangling_non_null_pointers_rab` and not this. + fn with_potentially_dangling_non_null_pointers_ra( + self, + expected_len: usize, + f: impl FnOnce(*mut T, *const T) -> R, + ) -> Result; +} + +impl AliasingSlices2 for &mut [T] { + fn with_potentially_dangling_non_null_pointers_ra( + self, + expected_len: usize, + f: impl FnOnce(*mut T, *const T) -> R, + ) -> Result { + let r = self; + if r.len() != expected_len { + return Err(LenMismatchError::new(r.len())); + } + Ok(f(r.as_mut_ptr(), r.as_ptr())) + } +} + +impl AliasingSlices2 for (&mut [T], &[T]) { + fn with_potentially_dangling_non_null_pointers_ra( + self, + expected_len: usize, + f: impl FnOnce(*mut T, *const T) -> R, + ) -> Result { + let (r, a) = self; + if r.len() != expected_len { + return Err(LenMismatchError::new(r.len())); + } + if a.len() != expected_len { + return Err(LenMismatchError::new(a.len())); + } + Ok(f(r.as_mut_ptr(), a.as_ptr())) + } +} + +pub(crate) trait AliasingSlices3 { + /// The pointers passed to `f` will all be non-null and properly aligned, + /// and will not be dangling. + /// + /// The first pointer, `r` points to potentially-uninitialized writable + /// space for `expected_len` elements of type `T`. Accordingly, `f` must + /// not read from `r` before writing to it. + /// + /// The second & third pointers, `a` and `b`, point to `expected_len` + /// initialized values of type `T`. + /// + /// `r`, `a`, and/or `b` may alias each other, but only in the following + /// ways: `ptr::eq(r, a)`, `ptr::eq(r, b)`, and/or `ptr::eq(a, b)`; they + /// will not be "overlapping." + /// + /// Implementations of this trait shouldn't override this default + /// implementation. + #[inline(always)] + fn with_non_dangling_non_null_pointers_rab( + self, + expected_len: NonZeroUsize, + f: impl FnOnce(*mut T, *const T, *const T) -> R, + ) -> Result + where + Self: Sized, + { + self.with_potentially_dangling_non_null_pointers_rab(expected_len.get(), f) + } + + /// If `expected_len == 0` then the pointers passed to `f` may be + /// dangling pointers, which should not be passed to C functions. In all + /// other respects, this works like + /// `Self::with_non_dangling_non_null_pointers_rab`. + /// + /// Implementations of this trait should implement this method and not + /// `with_non_dangling_non_null_pointers_rab`. Users of this trait should + /// use `with_non_dangling_non_null_pointers_rab` and not this. + fn with_potentially_dangling_non_null_pointers_rab( + self, + expected_len: usize, + f: impl FnOnce(*mut T, *const T, *const T) -> R, + ) -> Result; +} + +impl AliasingSlices3 for &mut [T] { + fn with_potentially_dangling_non_null_pointers_rab( + self, + expected_len: usize, + f: impl FnOnce(*mut T, *const T, *const T) -> R, + ) -> Result { + >::with_potentially_dangling_non_null_pointers_ra( + self, + expected_len, + |r, a| f(r, r, a), + ) + } +} + +impl AliasingSlices3 for (&mut [T], &[T], &[T]) { + fn with_potentially_dangling_non_null_pointers_rab( + self, + expected_len: usize, + f: impl FnOnce(*mut T, *const T, *const T) -> R, + ) -> Result { + let (r, a, b) = self; + ((r, a), b).with_potentially_dangling_non_null_pointers_rab(expected_len, f) + } +} + +impl AliasingSlices3 for (RA, &[T]) +where + RA: AliasingSlices2, +{ + fn with_potentially_dangling_non_null_pointers_rab( + self, + expected_len: usize, + f: impl FnOnce(*mut T, *const T, *const T) -> R, + ) -> Result { + let (ra, b) = self; + if b.len() != expected_len { + return Err(LenMismatchError::new(b.len())); + } + ra.with_potentially_dangling_non_null_pointers_ra(expected_len, |r, a| f(r, a, b.as_ptr())) + } +} diff --git a/http/vendor/ring/src/arithmetic/limbs/aarch64/mod.rs b/http/vendor/ring/src/arithmetic/limbs/aarch64/mod.rs new file mode 100644 index 0000000..fecce47 --- /dev/null +++ b/http/vendor/ring/src/arithmetic/limbs/aarch64/mod.rs @@ -0,0 +1,17 @@ +// Copyright 2025 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#![cfg(all(target_arch = "aarch64", target_endian = "little"))] + +pub(in super::super) mod mont; diff --git a/http/vendor/ring/src/arithmetic/limbs/aarch64/mont.rs b/http/vendor/ring/src/arithmetic/limbs/aarch64/mont.rs new file mode 100644 index 0000000..edd289f --- /dev/null +++ b/http/vendor/ring/src/arithmetic/limbs/aarch64/mont.rs @@ -0,0 +1,59 @@ +// Copyright 2025 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#![cfg(all(target_arch = "aarch64", target_endian = "little"))] + +use super::super::super::{inout::AliasingSlices3 as _, n0::N0, LimbSliceError, MAX_LIMBS}; +use crate::{ + c, + limb::Limb, + polyfill::slice::{AsChunks, AsChunksMut}, +}; +use core::num::NonZeroUsize; + +#[inline] +pub(in super::super::super) fn sqr_mont5( + mut in_out: AsChunksMut, + n: AsChunks, + n0: &N0, +) -> Result<(), LimbSliceError> { + prefixed_extern! { + // `r` and/or 'a' may alias. + // XXX: BoringSSL (kinda, implicitly) declares this to return `int`. + // `num` must be a non-zero multiple of 8. + fn bn_sqr8x_mont( + rp: *mut Limb, + ap: *const Limb, + ap_again: *const Limb, + np: *const Limb, + n0: &N0, + num: c::NonZero_size_t); + } + + let in_out = in_out.as_flattened_mut(); + let n = n.as_flattened(); + let num_limbs = NonZeroUsize::new(n.len()).ok_or_else(|| LimbSliceError::too_short(n.len()))?; + + // Avoid stack overflow from the alloca inside. + if num_limbs.get() > MAX_LIMBS { + return Err(LimbSliceError::too_long(num_limbs.get())); + } + + in_out + .with_non_dangling_non_null_pointers_rab(num_limbs, |r, a, a_again| { + let n = n.as_ptr(); // Non-dangling because num_limbs > 0. + unsafe { bn_sqr8x_mont(r, a, a_again, n, n0, num_limbs) }; + }) + .map_err(LimbSliceError::len_mismatch) +} diff --git a/http/vendor/ring/src/arithmetic/limbs/mod.rs b/http/vendor/ring/src/arithmetic/limbs/mod.rs new file mode 100644 index 0000000..0dc6af3 --- /dev/null +++ b/http/vendor/ring/src/arithmetic/limbs/mod.rs @@ -0,0 +1,16 @@ +// Copyright 2025 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +pub(super) mod aarch64; +pub(super) mod x86_64; diff --git a/http/vendor/ring/src/arithmetic/limbs/x86_64/mod.rs b/http/vendor/ring/src/arithmetic/limbs/x86_64/mod.rs new file mode 100644 index 0000000..d7dc08c --- /dev/null +++ b/http/vendor/ring/src/arithmetic/limbs/x86_64/mod.rs @@ -0,0 +1,17 @@ +// Copyright 2025 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#![cfg(target_arch = "x86_64")] + +pub(in super::super::super) mod mont; diff --git a/http/vendor/ring/src/arithmetic/limbs/x86_64/mont.rs b/http/vendor/ring/src/arithmetic/limbs/x86_64/mont.rs new file mode 100644 index 0000000..bf92c0c --- /dev/null +++ b/http/vendor/ring/src/arithmetic/limbs/x86_64/mont.rs @@ -0,0 +1,312 @@ +// Copyright 2015-2025 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#![cfg(target_arch = "x86_64")] + +use super::super::super::{ + inout::{AliasingSlices2, AliasingSlices3}, + n0::N0, + LimbSliceError, MAX_LIMBS, +}; +use crate::{ + c, + cpu::intel::{Adx, Bmi1, Bmi2}, + error::LenMismatchError, + limb::{LeakyWindow, Limb, Window}, + polyfill::slice::{AsChunks, AsChunksMut}, +}; +use core::num::NonZeroUsize; + +const _512_IS_LIMB_BITS_TIMES_8: () = assert!(8 * Limb::BITS == 512); + +#[inline] +pub(in super::super::super) fn mul_mont5( + mut r: AsChunksMut, + a: AsChunks, + b: AsChunks, + m: AsChunks, + n0: &N0, + maybe_adx_bmi2: Option<(Adx, Bmi2)>, +) -> Result<(), LimbSliceError> { + mul_mont5_4x( + (r.as_flattened_mut(), a.as_flattened(), b.as_flattened()), + m.into(), + n0, + maybe_adx_bmi2, + ) +} + +pub const MIN_4X: usize = 8; + +#[inline] +pub(in super::super::super) fn mul_mont5_4x( + in_out: impl AliasingSlices3, + n: AsChunks, + n0: &N0, + maybe_adx_bmi2: Option<(Adx, Bmi2)>, +) -> Result<(), LimbSliceError> { + const MOD_4X: usize = 4; + let n = n.as_flattened(); + if let Some(cpu) = maybe_adx_bmi2 { + bn_mul_mont_ffi!(in_out, n, n0, cpu, unsafe { + (MIN_4X, MOD_4X, (Adx, Bmi2)) => bn_mulx4x_mont + }) + } else { + bn_mul_mont_ffi!(in_out, n, n0, (), unsafe { + (MIN_4X, MOD_4X, ()) => bn_mul4x_mont + }) + } +} + +#[inline] +pub(in super::super::super) fn sqr_mont5( + mut in_out: AsChunksMut, + n: AsChunks, + n0: &N0, + maybe_adx_bmi2: Option<(Adx, Bmi2)>, +) -> Result<(), LimbSliceError> { + prefixed_extern! { + // `r` and/or 'a' may alias. + // XXX: BoringSSL declares this to return `int`. + // `num` must be a non-zero multiple of 8. + fn bn_sqr8x_mont( + rp: *mut Limb, + ap: *const Limb, + mulx_adx_capable: Limb, + np: *const Limb, + n0: &N0, + num: c::NonZero_size_t); + } + + let in_out = in_out.as_flattened_mut(); + let n = n.as_flattened(); + let num_limbs = NonZeroUsize::new(n.len()).ok_or_else(|| LimbSliceError::too_short(n.len()))?; + + // Avoid stack overflow from the alloca inside. + if num_limbs.get() > MAX_LIMBS { + return Err(LimbSliceError::too_long(num_limbs.get())); + } + + // `Limb::from(mulx_adx.is_some())`, but intentionally branchy. + let mulx_adx_capable = match maybe_adx_bmi2 { + Some(_) => Limb::from(true), + None => Limb::from(false), + }; + + in_out + .with_non_dangling_non_null_pointers_ra(num_limbs, |r, a| { + let n = n.as_ptr(); // Non-dangling because num_limbs > 0. + unsafe { bn_sqr8x_mont(r, a, mulx_adx_capable, n, n0, num_limbs) }; + }) + .map_err(LimbSliceError::len_mismatch) +} + +#[inline(always)] +pub(in super::super::super) fn scatter5( + a: AsChunks, + mut table: AsChunksMut, + power: LeakyWindow, +) -> Result<(), LimbSliceError> { + prefixed_extern! { + // Upstream uses `num: c::size_t` too, and `power: c::size_t`; see + // `_MAX_LIMBS_ADDRESSES_MEMORY_SAFETY_ISSUES`. + fn bn_scatter5( + inp: *const Limb, + num: c::NonZero_size_t, + table: *mut Limb, + power: LeakyWindow, + ); + } + let num_limbs = check_common(a, table.as_ref())?; + let a = a.as_flattened(); + let table = table.as_flattened_mut(); + assert!(power < 32); + unsafe { bn_scatter5(a.as_ptr(), num_limbs, table.as_mut_ptr(), power) }; + Ok(()) +} + +// SAFETY: `power` must be less than 32. +#[inline(always)] +pub(in super::super::super) unsafe fn gather5( + mut r: AsChunksMut, + table: AsChunks, + power: Window, +) -> Result<(), LimbSliceError> { + prefixed_extern! { + // Upstream uses `num: c::size_t` too, and `power: c::size_t`; see + // `_MAX_LIMBS_ADDRESSES_MEMORY_SAFETY_ISSUES`. + fn bn_gather5( + out: *mut Limb, + num: c::NonZero_size_t, + table: *const Limb, + power: Window); + } + let num_limbs = check_common(r.as_ref(), table)?; + let r = r.as_flattened_mut(); + let table = table.as_flattened(); + // SAFETY: We cannot assert that `power` is in range because it is secret. + // TODO: Create a `Window5` type that is guaranteed to be in range. + unsafe { bn_gather5(r.as_mut_ptr(), num_limbs, table.as_ptr(), power) }; + Ok(()) +} + +// SAFETY: `power` must be less than 32. +#[inline(always)] +pub(in super::super::super) unsafe fn mul_mont_gather5_amm( + mut r: AsChunksMut, + a: AsChunks, + table: AsChunks, + n: AsChunks, + n0: &N0, + power: Window, + maybe_adx_bmi1_bmi2: Option<(Adx, Bmi1, Bmi2)>, +) -> Result<(), LimbSliceError> { + prefixed_extern! { + // Upstream has `num: c_int` and `power: c_int`; see + // `_MAX_LIMBS_ADDRESSES_MEMORY_SAFETY_ISSUES`. + fn bn_mul4x_mont_gather5( + rp: *mut Limb, + ap: *const Limb, + table: *const Limb, + np: *const Limb, + n0: &N0, + num: c::NonZero_size_t, + power: Window, + ); + // Upstream has `num: c_int` and `power: c_int`; see + // `_MAX_LIMBS_ADDRESSES_MEMORY_SAFETY_ISSUES`. + fn bn_mulx4x_mont_gather5( + rp: *mut Limb, + ap: *const Limb, + table: *const Limb, + np: *const Limb, + n0: &N0, + num: c::NonZero_size_t, + power: Window, + ); + } + let num_limbs = check_common_with_n(r.as_ref(), table, n)?; + let a = a.as_flattened(); + if a.len() != num_limbs.get() { + return Err(LimbSliceError::len_mismatch(LenMismatchError::new(a.len()))); + } + let r = r.as_flattened_mut(); + let r = r.as_mut_ptr(); + let a = a.as_ptr(); + let table = table.as_flattened(); + let table = table.as_ptr(); + let n = n.as_flattened(); + let n = n.as_ptr(); + // SAFETY: We cannot assert that `power` is in range because it is secret. + // TODO: Create a `Window5` type that is guaranteed to be in range. + if maybe_adx_bmi1_bmi2.is_some() { + unsafe { bn_mulx4x_mont_gather5(r, a, table, n, n0, num_limbs, power) } + } else { + unsafe { bn_mul4x_mont_gather5(r, a, table, n, n0, num_limbs, power) } + }; + Ok(()) +} + +// SAFETY: `power` must be less than 32. +#[inline(always)] +pub(in super::super::super) unsafe fn power5_amm( + mut in_out: AsChunksMut, + table: AsChunks, + n: AsChunks, + n0: &N0, + power: Window, + maybe_adx_bmi1_bmi2: Option<(Adx, Bmi1, Bmi2)>, +) -> Result<(), LimbSliceError> { + prefixed_extern! { + // Upstream has `num: c_int` and `power: c_int`; see + // `_MAX_LIMBS_ADDRESSES_MEMORY_SAFETY_ISSUES`. + fn bn_power5_nohw( + rp: *mut Limb, + ap: *const Limb, + table: *const Limb, + np: *const Limb, + n0: &N0, + num: c::NonZero_size_t, + power: Window, + ); + // Upstream has `num: c_int` and `power: c_int`; see + // `_MAX_LIMBS_ADDRESSES_MEMORY_SAFETY_ISSUES`. + fn bn_powerx5( + rp: *mut Limb, + ap: *const Limb, + table: *const Limb, + np: *const Limb, + n0: &N0, + num: c::NonZero_size_t, + power: Window, + ); + } + let num_limbs = check_common_with_n(in_out.as_ref(), table, n)?; + let in_out = in_out.as_flattened_mut(); + let r = in_out.as_mut_ptr(); + let a = in_out.as_ptr(); + let table = table.as_flattened(); + let table = table.as_ptr(); + let n = n.as_flattened(); + let n = n.as_ptr(); + // SAFETY: We cannot assert that `power` is in range because it is secret. + // TODO: Create a `Window5` type that is guaranteed to be in range. + if maybe_adx_bmi1_bmi2.is_some() { + unsafe { bn_powerx5(r, a, table, n, n0, num_limbs, power) } + } else { + unsafe { bn_power5_nohw(r, a, table, n, n0, num_limbs, power) } + }; + Ok(()) +} + +// Helps the compiler will be able to hoist all of these checks out of the +// loops in the caller. Try to help the compiler by doing the checks +// consistently in each function and also by inlining this function and all the +// callers. +#[inline(always)] +fn check_common( + a: AsChunks, + table: AsChunks, +) -> Result { + assert_eq!((table.as_ptr() as usize) % 16, 0); // According to BoringSSL. + let a = a.as_flattened(); + let table = table.as_flattened(); + let num_limbs = NonZeroUsize::new(a.len()).ok_or_else(|| LimbSliceError::too_short(a.len()))?; + if num_limbs.get() > MAX_LIMBS { + return Err(LimbSliceError::too_long(a.len())); + } + if num_limbs.get() * 32 != table.len() { + return Err(LimbSliceError::len_mismatch(LenMismatchError::new( + table.len(), + ))); + }; + Ok(num_limbs) +} + +#[inline(always)] +fn check_common_with_n( + a: AsChunks, + table: AsChunks, + n: AsChunks, +) -> Result { + // Choose `a` instead of `n` so that every function starts with + // `check_common` passing the exact same arguments, so that the compiler + // can easily de-dupe the checks. + let num_limbs = check_common(a, table)?; + let n = n.as_flattened(); + if n.len() != num_limbs.get() { + return Err(LimbSliceError::len_mismatch(LenMismatchError::new(n.len()))); + } + Ok(num_limbs) +} diff --git a/http/vendor/ring/src/arithmetic/limbs512/mod.rs b/http/vendor/ring/src/arithmetic/limbs512/mod.rs new file mode 100644 index 0000000..8b77ecf --- /dev/null +++ b/http/vendor/ring/src/arithmetic/limbs512/mod.rs @@ -0,0 +1,17 @@ +// Copyright 2025 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +mod storage; + +pub(super) use self::storage::{AlignedStorage, LIMBS_PER_CHUNK}; diff --git a/http/vendor/ring/src/arithmetic/limbs512/storage.rs b/http/vendor/ring/src/arithmetic/limbs512/storage.rs new file mode 100644 index 0000000..210192b --- /dev/null +++ b/http/vendor/ring/src/arithmetic/limbs512/storage.rs @@ -0,0 +1,60 @@ +// Copyright 2025 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use crate::{ + error::LenMismatchError, + limb::{Limb, LIMB_BITS}, + polyfill::slice::{self, AsChunksMut}, +}; +use core::mem::{align_of, size_of}; + +// Some x86_64 assembly is written under the assumption that some of its +// input data and/or temporary storage is aligned to `MOD_EXP_CTIME_ALIGN` +// bytes, which was/is 64 in OpenSSL. +// +// We use this in the non-X86-64 implementation of exponentiation as well, +// with the hope of converging th two implementations into one. + +#[repr(C, align(64))] +pub struct AlignedStorage([Limb; N]); + +const _LIMB_SIZE_DIVIDES_ALIGNMENT: () = + assert!(align_of::>() % size_of::() == 0); + +pub const LIMBS_PER_CHUNK: usize = 512 / LIMB_BITS; + +impl AlignedStorage { + pub fn zeroed() -> Self { + assert_eq!(N % LIMBS_PER_CHUNK, 0); // TODO: const. + Self([0; N]) + } + + // The result will have every chunk aligned on a 64 byte boundary. + pub fn aligned_chunks_mut( + &mut self, + num_entries: usize, + chunks_per_entry: usize, + ) -> Result, LenMismatchError> { + let total_limbs = num_entries * chunks_per_entry * LIMBS_PER_CHUNK; + let len = self.0.len(); + let flattened = self + .0 + .get_mut(..total_limbs) + .ok_or_else(|| LenMismatchError::new(len))?; + match slice::as_chunks_mut(flattened) { + (chunks, []) => Ok(chunks), + (_, r) => Err(LenMismatchError::new(r.len())), + } + } +} diff --git a/http/vendor/ring/src/arithmetic/montgomery.rs b/http/vendor/ring/src/arithmetic/montgomery.rs new file mode 100644 index 0000000..4098ece --- /dev/null +++ b/http/vendor/ring/src/arithmetic/montgomery.rs @@ -0,0 +1,384 @@ +// Copyright 2017-2025 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +pub use super::n0::N0; +use super::{inout::AliasingSlices3, LimbSliceError, MIN_LIMBS}; +use crate::cpu; +use cfg_if::cfg_if; + +// Indicates that the element is not encoded; there is no *R* factor +// that needs to be canceled out. +#[derive(Copy, Clone)] +pub enum Unencoded {} + +// Indicates that the element is encoded; the value has one *R* +// factor that needs to be canceled out. +#[derive(Copy, Clone)] +pub enum R {} + +// Indicates the element is encoded three times; the value has three +// *R* factors that need to be canceled out. +#[allow(clippy::upper_case_acronyms)] +#[derive(Copy, Clone)] +pub enum RRR {} + +// Indicates the element is encoded twice; the value has two *R* +// factors that need to be canceled out. +#[derive(Copy, Clone)] +pub enum RR {} + +// Indicates the element is inversely encoded; the value has one +// 1/*R* factor that needs to be canceled out. +#[derive(Copy, Clone)] +pub enum RInverse {} + +pub trait Encoding {} + +impl Encoding for RRR {} +impl Encoding for RR {} +impl Encoding for R {} +impl Encoding for Unencoded {} +impl Encoding for RInverse {} + +/// The encoding of the result of a reduction. +pub trait ReductionEncoding { + type Output: Encoding; +} + +impl ReductionEncoding for RRR { + type Output = RR; +} + +impl ReductionEncoding for RR { + type Output = R; +} +impl ReductionEncoding for R { + type Output = Unencoded; +} +impl ReductionEncoding for Unencoded { + type Output = RInverse; +} + +/// The encoding of the result of a multiplication. +pub trait ProductEncoding { + type Output: Encoding; +} + +impl ProductEncoding for (Unencoded, E) { + type Output = E::Output; +} + +impl ProductEncoding for (R, E) { + type Output = E; +} + +impl ProductEncoding for (RR, RR) { + type Output = RRR; +} + +impl ProductEncoding for (RInverse, E) +where + E::Output: ReductionEncoding, +{ + type Output = <::Output as ReductionEncoding>::Output; +} + +// XXX: Rust doesn't allow overlapping impls, +// TODO (if/when Rust allows it): +// impl ProductEncoding for +// (E1, E2) { +// type Output = <(E2, E1) as ProductEncoding>::Output; +// } +impl ProductEncoding for (RR, Unencoded) { + type Output = <(Unencoded, RR) as ProductEncoding>::Output; +} +impl ProductEncoding for (RR, RInverse) { + type Output = <(RInverse, RR) as ProductEncoding>::Output; +} + +impl ProductEncoding for (RRR, RInverse) { + type Output = <(RInverse, RRR) as ProductEncoding>::Output; +} + +#[allow(unused_imports)] +use crate::{bssl, c, limb::Limb}; + +#[inline(always)] +pub(super) fn limbs_mul_mont( + in_out: impl AliasingSlices3, + n: &[Limb], + n0: &N0, + cpu: cpu::Features, +) -> Result<(), LimbSliceError> { + const MOD_FALLBACK: usize = 1; // No restriction. + cfg_if! { + if #[cfg(all(target_arch = "aarch64", target_endian = "little"))] { + let _: cpu::Features = cpu; + const MIN_4X: usize = 4; + const MOD_4X: usize = 4; + if n.len() >= MIN_4X && n.len() % MOD_4X == 0 { + bn_mul_mont_ffi!(in_out, n, n0, (), unsafe { + (MIN_4X, MOD_4X, ()) => bn_mul4x_mont + }) + } else { + bn_mul_mont_ffi!(in_out, n, n0, (), unsafe { + (MIN_LIMBS, MOD_FALLBACK, ()) => bn_mul_mont_nohw + }) + } + } else if #[cfg(all(target_arch = "arm", target_endian = "little"))] { + const MIN_8X: usize = 8; + const MOD_8X: usize = 8; + if n.len() >= MIN_8X && n.len() % MOD_8X == 0 { + use crate::cpu::{GetFeature as _, arm::Neon}; + if let Some(cpu) = cpu.get_feature() { + return bn_mul_mont_ffi!(in_out, n, n0, cpu, unsafe { + (MIN_8X, MOD_8X, Neon) => bn_mul8x_mont_neon + }); + } + } + // The ARM version of `bn_mul_mont_nohw` has a minimum of 2. + const _MIN_LIMBS_AT_LEAST_2: () = assert!(MIN_LIMBS >= 2); + bn_mul_mont_ffi!(in_out, n, n0, (), unsafe { + (MIN_LIMBS, MOD_FALLBACK, ()) => bn_mul_mont_nohw + }) + } else if #[cfg(target_arch = "x86")] { + use crate::{cpu::GetFeature as _, cpu::intel::Sse2}; + // The X86 implementation of `bn_mul_mont` has a minimum of 4. + const _MIN_LIMBS_AT_LEAST_4: () = assert!(MIN_LIMBS >= 4); + if let Some(cpu) = cpu.get_feature() { + bn_mul_mont_ffi!(in_out, n, n0, cpu, unsafe { + (MIN_LIMBS, MOD_FALLBACK, Sse2) => bn_mul_mont + }) + } else { + // This isn't really an FFI call; it's defined below. + unsafe { + super::ffi::bn_mul_mont_ffi::<(), {MIN_LIMBS}, 1>(in_out, n, n0, (), + bn_mul_mont_fallback) + } + } + } else if #[cfg(target_arch = "x86_64")] { + use crate::{cpu::GetFeature as _, polyfill::slice}; + use super::limbs::x86_64; + if n.len() >= x86_64::mont::MIN_4X { + if let (n, []) = slice::as_chunks(n) { + return x86_64::mont::mul_mont5_4x(in_out, n, n0, cpu.get_feature()); + } + } + bn_mul_mont_ffi!(in_out, n, n0, (), unsafe { + (MIN_LIMBS, MOD_FALLBACK, ()) => bn_mul_mont_nohw + }) + } else { + // Use the fallback implementation implemented below through the + // FFI wrapper defined below, so that Rust and C code both go + // through `bn_mul_mont`. + bn_mul_mont_ffi!(in_out, n, n0, cpu, unsafe { + (MIN_LIMBS, MOD_FALLBACK, cpu::Features) => bn_mul_mont + }) + } + } +} + +cfg_if! { + if #[cfg(not(any( + all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little"), + target_arch = "x86_64")))] { + + // TODO: Stop calling this from C and un-export it. + #[cfg(not(target_arch = "x86"))] + prefixed_export! { + unsafe extern "C" fn bn_mul_mont( + r: *mut Limb, + a: *const Limb, + b: *const Limb, + n: *const Limb, + n0: &N0, + num_limbs: c::NonZero_size_t, + ) { + unsafe { bn_mul_mont_fallback(r, a, b, n, n0, num_limbs) } + } + } + + #[cfg_attr(target_arch = "x86", cold)] + #[cfg_attr(target_arch = "x86", inline(never))] + unsafe extern "C" fn bn_mul_mont_fallback( + r: *mut Limb, + a: *const Limb, + b: *const Limb, + n: *const Limb, + n0: &N0, + num_limbs: c::NonZero_size_t, + ) { + use super::MAX_LIMBS; + + let num_limbs = num_limbs.get(); + + // The mutable pointer `r` may alias `a` and/or `b`, so the lifetimes of + // any slices for `a` or `b` must not overlap with the lifetime of any + // mutable for `r`. + + // Nothing aliases `n` + let n = unsafe { core::slice::from_raw_parts(n, num_limbs) }; + + let mut tmp = [0; 2 * MAX_LIMBS]; + let tmp = &mut tmp[..(2 * num_limbs)]; + { + let a: &[Limb] = unsafe { core::slice::from_raw_parts(a, num_limbs) }; + let b: &[Limb] = unsafe { core::slice::from_raw_parts(b, num_limbs) }; + limbs_mul(tmp, a, b); + } + let r: &mut [Limb] = unsafe { core::slice::from_raw_parts_mut(r, num_limbs) }; + limbs_from_mont_in_place(r, tmp, n, n0); + } + } +} + +// `bigint` needs then when the `alloc` feature is enabled. `bn_mul_mont` above needs this when +// we are using the platforms for which we don't have `bn_mul_mont` in assembly. +#[cfg(any( + feature = "alloc", + not(any( + all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little"), + target_arch = "x86_64" + )) +))] +pub(super) fn limbs_from_mont_in_place(r: &mut [Limb], tmp: &mut [Limb], m: &[Limb], n0: &N0) { + prefixed_extern! { + fn bn_from_montgomery_in_place( + r: *mut Limb, + num_r: c::size_t, + a: *mut Limb, + num_a: c::size_t, + n: *const Limb, + num_n: c::size_t, + n0: &N0, + ) -> bssl::Result; + } + Result::from(unsafe { + bn_from_montgomery_in_place( + r.as_mut_ptr(), + r.len(), + tmp.as_mut_ptr(), + tmp.len(), + m.as_ptr(), + m.len(), + n0, + ) + }) + .unwrap() +} + +#[cfg(not(any( + all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little"), + target_arch = "x86_64" +)))] +fn limbs_mul(r: &mut [Limb], a: &[Limb], b: &[Limb]) { + debug_assert_eq!(r.len(), 2 * a.len()); + debug_assert_eq!(a.len(), b.len()); + let ab_len = a.len(); + + r[..ab_len].fill(0); + for (i, &b_limb) in b.iter().enumerate() { + r[ab_len + i] = unsafe { + limbs_mul_add_limb(r[i..][..ab_len].as_mut_ptr(), a.as_ptr(), b_limb, ab_len) + }; + } +} + +#[cfg(any( + test, + not(any( + all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little"), + target_arch = "x86_64", + )) +))] +prefixed_extern! { + // `r` must not alias `a` + #[must_use] + fn limbs_mul_add_limb(r: *mut Limb, a: *const Limb, b: Limb, num_limbs: c::size_t) -> Limb; +} + +/// r = r**2 +pub(super) fn limbs_square_mont( + r: &mut [Limb], + n: &[Limb], + n0: &N0, + cpu: cpu::Features, +) -> Result<(), LimbSliceError> { + #[cfg(all(target_arch = "aarch64", target_endian = "little"))] + { + use super::limbs::aarch64; + use crate::polyfill::slice; + if let ((r, []), (n, [])) = (slice::as_chunks_mut(r), slice::as_chunks(n)) { + return aarch64::mont::sqr_mont5(r, n, n0); + } + } + + #[cfg(target_arch = "x86_64")] + { + use super::limbs::x86_64; + use crate::{cpu::GetFeature as _, polyfill::slice}; + if let ((r, []), (n, [])) = (slice::as_chunks_mut(r), slice::as_chunks(n)) { + return x86_64::mont::sqr_mont5(r, n, n0, cpu.get_feature()); + } + } + + limbs_mul_mont(r, n, n0, cpu) +} + +#[cfg(test)] +mod tests { + use super::super::MAX_LIMBS; + use super::*; + use crate::limb::Limb; + + #[test] + // TODO: wasm + fn test_mul_add_words() { + const ZERO: Limb = 0; + const MAX: Limb = ZERO.wrapping_sub(1); + static TEST_CASES: &[(&[Limb], &[Limb], Limb, Limb, &[Limb])] = &[ + (&[0], &[0], 0, 0, &[0]), + (&[MAX], &[0], MAX, 0, &[MAX]), + (&[0], &[MAX], MAX, MAX - 1, &[1]), + (&[MAX], &[MAX], MAX, MAX, &[0]), + (&[0, 0], &[MAX, MAX], MAX, MAX - 1, &[1, MAX]), + (&[1, 0], &[MAX, MAX], MAX, MAX - 1, &[2, MAX]), + (&[MAX, 0], &[MAX, MAX], MAX, MAX, &[0, 0]), + (&[0, 1], &[MAX, MAX], MAX, MAX, &[1, 0]), + (&[MAX, MAX], &[MAX, MAX], MAX, MAX, &[0, MAX]), + ]; + + for (i, (r_input, a, w, expected_retval, expected_r)) in TEST_CASES.iter().enumerate() { + let mut r = [0; MAX_LIMBS]; + let r = { + let r = &mut r[..r_input.len()]; + r.copy_from_slice(r_input); + r + }; + assert_eq!(r.len(), a.len()); // Sanity check + let actual_retval = + unsafe { limbs_mul_add_limb(r.as_mut_ptr(), a.as_ptr(), *w, a.len()) }; + assert_eq!(&r, expected_r, "{}: {:x?} != {:x?}", i, r, expected_r); + assert_eq!( + actual_retval, *expected_retval, + "{}: {:x?} != {:x?}", + i, actual_retval, *expected_retval + ); + } + } +} diff --git a/http/vendor/ring/src/arithmetic/n0.rs b/http/vendor/ring/src/arithmetic/n0.rs new file mode 100644 index 0000000..f0c77dd --- /dev/null +++ b/http/vendor/ring/src/arithmetic/n0.rs @@ -0,0 +1,37 @@ +// Copyright 2015-2022 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use crate::limb::Limb; + +#[derive(Clone, Copy)] +#[repr(transparent)] +pub struct N0([Limb; 2]); + +impl N0 { + #[cfg(feature = "alloc")] + pub(super) const LIMBS_USED: usize = 64 / crate::limb::LIMB_BITS; + + #[inline] + pub const fn precalculated(n0: u64) -> Self { + #[cfg(target_pointer_width = "64")] + { + Self([n0, 0]) + } + + #[cfg(target_pointer_width = "32")] + { + Self([n0 as Limb, (n0 >> crate::limb::LIMB_BITS) as Limb]) + } + } +} diff --git a/http/vendor/ring/src/bb/boolmask.rs b/http/vendor/ring/src/bb/boolmask.rs new file mode 100644 index 0000000..d504df1 --- /dev/null +++ b/http/vendor/ring/src/bb/boolmask.rs @@ -0,0 +1,41 @@ +// Copyright 2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::Word; +use core::ops; + +// BoolMask is either `BoolMask::TRUE` or `BoolMask::FALSE`. +#[repr(transparent)] +pub struct BoolMask(Word); + +impl BoolMask { + #[cfg(test)] + pub(super) const TRUE: Self = Self(Word::MAX); + #[cfg(test)] + pub(super) const FALSE: Self = Self(0); + + /// Returns true if `self` is `BoolMask::TRUE`; otherwise, returns false + /// (`self` is `BoolMask::FALSE`). + pub(crate) fn leak(self) -> bool { + self.0 != 0 + } +} + +impl ops::BitAnd for BoolMask { + type Output = Self; + + fn bitand(self, rhs: Self) -> Self { + Self(self.0 & rhs.0) + } +} diff --git a/http/vendor/ring/src/bb/leaky.rs b/http/vendor/ring/src/bb/leaky.rs new file mode 100644 index 0000000..4ff5b6c --- /dev/null +++ b/http/vendor/ring/src/bb/leaky.rs @@ -0,0 +1,27 @@ +// Copyright 2015-2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#[cfg(target_pointer_width = "64")] +type CompilerWord = u64; + +#[cfg(target_pointer_width = "32")] +type CompilerWord = u32; + +/// A native word that isn't secret. +/// +/// `LeakyWord` supports `as` conversions to/from native types. +/// +/// XXX: This isn't the native word size on targets where a pointer isn't the +/// same size as a native word. TODO: Fix this. +pub(crate) type LeakyWord = CompilerWord; diff --git a/http/vendor/ring/src/bb/mod.rs b/http/vendor/ring/src/bb/mod.rs new file mode 100644 index 0000000..3920a5f --- /dev/null +++ b/http/vendor/ring/src/bb/mod.rs @@ -0,0 +1,162 @@ +// Copyright 2015-2025 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! Building blocks. + +use crate::{c, error}; +use core::{ffi::c_int, num::NonZeroUsize}; + +mod boolmask; +mod leaky; +mod word; + +pub(crate) use self::{boolmask::BoolMask, leaky::LeakyWord, word::Word}; + +/// Returns `Ok(())` if `a == b` and `Err(error::Unspecified)` otherwise. +pub fn verify_slices_are_equal(a: &[u8], b: &[u8]) -> Result<(), error::Unspecified> { + let len = a.len(); // Arbitrary choice. + if b.len() != len { + return Err(error::Unspecified); + } + match NonZeroUsize::new(len) { + Some(len) => { + let a = a.as_ptr(); + let b = b.as_ptr(); + // SAFETY: `a` and `b` are valid non-null non-dangling pointers to `len` + // bytes. + let result = unsafe { CRYPTO_memcmp(a, b, len) }; + match result { + 0 => Ok(()), + _ => Err(error::Unspecified), + } + } + None => Ok(()), // Empty slices are equal. + } +} + +prefixed_extern! { + fn CRYPTO_memcmp(a: *const u8, b: *const u8, len: c::NonZero_size_t) -> c_int; +} + +pub(crate) fn xor_16(a: [u8; 16], b: [u8; 16]) -> [u8; 16] { + let a = u128::from_ne_bytes(a); + let b = u128::from_ne_bytes(b); + let r = a ^ b; + r.to_ne_bytes() +} + +#[inline(always)] +pub(crate) fn xor_assign<'a>(a: impl IntoIterator, b: u8) { + a.into_iter().for_each(|a| *a ^= b); +} + +/// XORs the first N bytes of `b` into `a`, where N is +/// `core::cmp::min(a.len(), b.len())`. +#[inline(always)] +pub(crate) fn xor_assign_at_start<'a>( + a: impl IntoIterator, + b: impl IntoIterator, +) { + a.into_iter().zip(b).for_each(|(a, b)| *a ^= *b); +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::{bssl, rand}; + + fn leak_in_test(a: BoolMask) -> bool { + a.leak() + } + + #[test] + fn test_constant_time() -> Result<(), error::Unspecified> { + prefixed_extern! { + fn bssl_constant_time_test_main() -> bssl::Result; + } + Result::from(unsafe { bssl_constant_time_test_main() }) + } + + #[test] + fn constant_time_conditional_memcpy() -> Result<(), error::Unspecified> { + let rng = rand::SystemRandom::new(); + for _ in 0..100 { + let mut out = rand::generate::<[u8; 256]>(&rng)?.expose(); + let input = rand::generate::<[u8; 256]>(&rng)?.expose(); + + // Mask to 16 bits to make zero more likely than it would otherwise be. + let b = (rand::generate::<[u8; 1]>(&rng)?.expose()[0] & 0x0f) == 0; + + let ref_in = input; + let ref_out = if b { input } else { out }; + + prefixed_extern! { + fn bssl_constant_time_test_conditional_memcpy(dst: &mut [u8; 256], src: &[u8; 256], b: BoolMask); + } + unsafe { + bssl_constant_time_test_conditional_memcpy( + &mut out, + &input, + if b { BoolMask::TRUE } else { BoolMask::FALSE }, + ) + } + assert_eq!(ref_in, input); + assert_eq!(ref_out, out); + } + + Ok(()) + } + + #[test] + fn constant_time_conditional_memxor() -> Result<(), error::Unspecified> { + let rng = rand::SystemRandom::new(); + for _ in 0..256 { + let mut out = rand::generate::<[u8; 256]>(&rng)?.expose(); + let input = rand::generate::<[u8; 256]>(&rng)?.expose(); + + // Mask to 16 bits to make zero more likely than it would otherwise be. + let b = (rand::generate::<[u8; 1]>(&rng)?.expose()[0] & 0x0f) != 0; + + let ref_in = input; + let mut ref_out = out; + if b { + xor_assign_at_start(&mut ref_out, &ref_in) + }; + + prefixed_extern! { + fn bssl_constant_time_test_conditional_memxor(dst: &mut [u8; 256], src: &[u8; 256], b: BoolMask); + } + unsafe { + bssl_constant_time_test_conditional_memxor( + &mut out, + &input, + if b { BoolMask::TRUE } else { BoolMask::FALSE }, + ); + } + + assert_eq!(ref_in, input); + assert_eq!(ref_out, out); + } + + Ok(()) + } + + #[test] + fn test_bool_mask_bitwise_and_is_logical_and() { + assert!(leak_in_test(BoolMask::TRUE & BoolMask::TRUE)); + assert!(!leak_in_test(BoolMask::TRUE & BoolMask::FALSE)); + assert!(!leak_in_test(BoolMask::FALSE & BoolMask::TRUE)); + assert!(!leak_in_test(BoolMask::FALSE & BoolMask::FALSE)); + } +} diff --git a/http/vendor/ring/src/bb/word.rs b/http/vendor/ring/src/bb/word.rs new file mode 100644 index 0000000..a799df3 --- /dev/null +++ b/http/vendor/ring/src/bb/word.rs @@ -0,0 +1,44 @@ +// Copyright 2015-2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::LeakyWord; + +/// A native word that may hold a secret. +/// +/// XXX: Currently this is a type alias of `LeakyWord` so it doesn't enforce, +/// except by convention, the prevention of leaks. This is a temporary state to +/// support the refactorings that will +/// +/// XXX: This isn't the native word size on targets where a pointer isn't the +/// same size as a native word. TODO: Fix this. +/// +/// XXX: Over time, we'll evolve Word into a newtype with an API that minimizes +/// leaks and makes all leaks explicit, like so: +pub(crate) type Word = LeakyWord; + +/* TODO: +#[repr(transparent)] +pub(crate) struct Word(LeakyWord); + +impl Word { + pub fn leak_word(self) -> LeakyWord { self.0 } +} + +impl From for Word { + fn from(w: LeakyWord) -> Self { + // TODO: Use a stronger `black_box`. + Self(core::hint::black_box(w)) + } +} +*/ diff --git a/http/vendor/ring/src/bits.rs b/http/vendor/ring/src/bits.rs new file mode 100644 index 0000000..01b5dc5 --- /dev/null +++ b/http/vendor/ring/src/bits.rs @@ -0,0 +1,135 @@ +// Copyright 2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! Bit lengths. + +use crate::{error::InputTooLongError, polyfill}; + +/// The length of something, in bits. +/// +/// This can represent a bit length that isn't a whole number of bytes. +#[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd)] +#[repr(transparent)] +pub struct BitLength(T); + +pub(crate) trait FromByteLen: Sized { + /// Constructs a `BitLength` from the given length in bytes. + /// + /// Fails if `bytes * 8` is too large for a `T`. + fn from_byte_len(bytes: T) -> Result>; +} + +impl FromByteLen for BitLength { + #[inline] + fn from_byte_len(bytes: usize) -> Result { + match bytes.checked_mul(8) { + Some(bits) => Ok(Self(bits)), + None => Err(InputTooLongError::new(bytes)), + } + } +} + +impl FromByteLen for BitLength { + #[inline] + fn from_byte_len(bytes: u64) -> Result> { + match bytes.checked_mul(8) { + Some(bits) => Ok(Self(bits)), + None => Err(InputTooLongError::new(bytes)), + } + } +} + +impl FromByteLen for BitLength { + #[inline] + fn from_byte_len(bytes: usize) -> Result> { + match polyfill::u64_from_usize(bytes).checked_mul(8) { + Some(bits) => Ok(Self(bits)), + None => Err(InputTooLongError::new(bytes)), + } + } +} + +impl BitLength { + /// Constructs a `BitLength` from the given length in bits. + #[inline] + pub const fn from_bits(bits: T) -> Self { + Self(bits) + } +} + +impl BitLength { + /// The number of bits this bit length represents, as the underlying type. + #[inline] + pub fn as_bits(self) -> T { + self.0 + } +} + +// Lengths measured in bits, where all arithmetic is guaranteed not to +// overflow. +impl BitLength { + #[cfg(feature = "alloc")] + #[inline] + pub(crate) fn half_rounded_up(&self) -> Self { + let round_up = self.0 & 1; + Self((self.0 / 2) + round_up) + } + + /// The bit length, rounded up to a whole number of bytes. + #[inline] + pub const fn as_usize_bytes_rounded_up(&self) -> usize { + // Equivalent to (self.0 + 7) / 8, except with no potential for + // overflow and without branches. + + // Branchless round_up = if self.0 & 0b111 != 0 { 1 } else { 0 }; + let round_up = ((self.0 >> 2) | (self.0 >> 1) | self.0) & 1; + + (self.0 / 8) + round_up + } + + #[cfg(feature = "alloc")] + #[inline] + pub(crate) fn try_sub_1(self) -> Result { + let sum = self.0.checked_sub(1).ok_or(crate::error::Unspecified)?; + Ok(Self(sum)) + } +} + +impl BitLength { + pub fn to_be_bytes(self) -> [u8; 8] { + self.0.to_be_bytes() + } +} + +#[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))] +impl From> for BitLength { + fn from(BitLength(value): BitLength) -> Self { + BitLength(polyfill::u64_from_usize(value)) + } +} + +impl TryFrom> for BitLength { + type Error = >::Error; + + fn try_from(BitLength(value): BitLength) -> Result { + value.try_into().map(BitLength) + } +} + +const _TEST_AS_USIZE_BYTES_ROUNDED_UP_EVEN: () = + assert!(BitLength::from_bits(8192).as_usize_bytes_rounded_up() == 8192 / 8); +const _TEST_AS_USIZE_BYTES_ROUNDED_UP_ONE_BIT_HIGH: () = + assert!(BitLength::from_bits(8192 + 1).as_usize_bytes_rounded_up() == (8192 / 8) + 1); +const _TEST_AS_USIZE_BYTES_ROUNDED_UP_SEVEN_BITS_HIGH: () = + assert!(BitLength::from_bits(8192 + 7).as_usize_bytes_rounded_up() == (8192 / 8) + 1); diff --git a/http/vendor/ring/src/bssl.rs b/http/vendor/ring/src/bssl.rs new file mode 100644 index 0000000..1b1c753 --- /dev/null +++ b/http/vendor/ring/src/bssl.rs @@ -0,0 +1,59 @@ +// Copyright 2015 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use crate::error; +use core::ffi::c_int; + +/// An `int` returned from a foreign function containing **1** if the function +/// was successful or **0** if an error occurred. This is the convention used by +/// C code in `ring`. +#[must_use] +#[repr(transparent)] +pub struct Result(c_int); + +impl From for core::result::Result<(), error::Unspecified> { + fn from(ret: Result) -> Self { + match ret.0 { + 1 => Ok(()), + c => { + debug_assert_eq!(c, 0, "`bssl::Result` value must be 0 or 1"); + Err(error::Unspecified) + } + } + } +} + +#[cfg(test)] +mod tests { + mod result { + use crate::bssl; + use core::{ + ffi::c_int, + mem::{align_of, size_of}, + }; + + #[test] + fn size_and_alignment() { + type Underlying = c_int; + assert_eq!(size_of::(), size_of::()); + assert_eq!(align_of::(), align_of::()); + } + + #[test] + fn semantics() { + assert!(Result::from(bssl::Result(0)).is_err()); + assert!(Result::from(bssl::Result(1)).is_ok()); + } + } +} diff --git a/http/vendor/ring/src/c.rs b/http/vendor/ring/src/c.rs new file mode 100644 index 0000000..f5822eb --- /dev/null +++ b/http/vendor/ring/src/c.rs @@ -0,0 +1,33 @@ +// Copyright 2016-2019 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! C types. +//! +//! Avoid using the `libc` crate to get C types since `libc` doesn't support +//! all the targets we need to support. It turns out that the few types we need +//! are all uniformly defined on the platforms we care about. This will +//! probably change if/when we support 16-bit platforms or platforms where +//! `usize` and `uintptr_t` are different sizes. +//! +//! TODO(MSRV, feature(c_size_t)): Use `core::{ffi::c_size_t}`. +//! TODO(MSRV-1.79): Use `NonZero`. + +// Keep in sync with the checks in base.h that verify these assumptions. + +#![allow(dead_code)] + +use core::num::NonZeroUsize; + +pub(crate) type size_t = usize; +pub(crate) type NonZero_size_t = NonZeroUsize; diff --git a/http/vendor/ring/src/cpu.rs b/http/vendor/ring/src/cpu.rs new file mode 100644 index 0000000..293e1b5 --- /dev/null +++ b/http/vendor/ring/src/cpu.rs @@ -0,0 +1,231 @@ +// Copyright 2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +pub(crate) use self::features::Features; +use core::mem::size_of; + +macro_rules! impl_get_feature { + { + features: [ + $( { ( $( $arch:expr ),+ ) => $Name:ident }, )+ + ], + } => { + $( + #[cfg(any( $( target_arch = $arch ),+ ))] + #[derive(Clone, Copy)] + pub(crate) struct $Name(crate::cpu::Features); + + #[cfg(any( $( target_arch = $arch ),+ ))] + impl $Name { + const fn mask() -> u32 { + 1 << (Shift::$Name as u32) + } + } + + #[cfg(any( $( target_arch = $arch ),+ ))] + impl crate::cpu::GetFeature<$Name> for super::features::Values { + #[inline(always)] + fn get_feature(&self) -> Option<$Name> { + const MASK: u32 = $Name::mask(); + const STATICALLY_DETECTED: bool = (crate::cpu::CAPS_STATIC & MASK) == MASK; + if STATICALLY_DETECTED { // TODO: `const` + return Some($Name(self.cpu())); + } + + if (self.values() & MASK) == MASK { + Some($Name(self.cpu())) + } else { + None + } + } + } + )+ + + #[repr(u32)] + enum Shift { + $( + #[cfg(any( $( target_arch = $arch ),+ ))] + $Name, + )+ + + #[cfg(target_arch = "x86_64")] + IntelCpu, + + #[cfg(any(all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little"), + target_arch = "x86", target_arch = "x86_64"))] + // Synthesized to ensure the dynamic flag set is always non-zero. + // + // Keep this at the end as it is never checked except during init. + Initialized, + } + } +} + +pub(crate) trait GetFeature { + fn get_feature(&self) -> Option; +} + +impl GetFeature<()> for features::Values { + #[inline(always)] + fn get_feature(&self) -> Option<()> { + Some(()) + } +} + +impl GetFeature<(A, B)> for features::Values +where + features::Values: GetFeature, + features::Values: GetFeature, +{ + #[inline(always)] + fn get_feature(&self) -> Option<(A, B)> { + match (self.get_feature(), self.get_feature()) { + (Some(a), Some(b)) => Some((a, b)), + _ => None, + } + } +} + +impl GetFeature<(A, B, C)> for features::Values +where + features::Values: GetFeature, + features::Values: GetFeature, + features::Values: GetFeature, +{ + #[inline(always)] + fn get_feature(&self) -> Option<(A, B, C)> { + match (self.get_feature(), self.get_feature(), self.get_feature()) { + (Some(a), Some(b), Some(c)) => Some((a, b, c)), + _ => None, + } + } +} + +impl GetFeature for Features +where + features::Values: GetFeature, +{ + #[inline(always)] + fn get_feature(&self) -> Option { + self.values().get_feature() + } +} + +#[inline(always)] +pub(crate) fn features() -> Features { + featureflags::get_or_init() +} + +mod features { + use crate::polyfill::NotSend; + + /// A witness indicating that CPU features have been detected and cached. + /// + /// This is a zero-sized type so that it can be "stored" wherever convenient. + #[derive(Copy, Clone)] + pub(crate) struct Features(NotSend); + + impl Features { + pub fn values(self) -> Values { + Values { + values: super::featureflags::get(self), + cpu: self, + } + } + } + + cfg_if::cfg_if! { + if #[cfg(any(all(target_arch = "aarch64", target_endian = "little"), all(target_arch = "arm", target_endian = "little"), + target_arch = "x86", target_arch = "x86_64"))] { + impl Features { + // SAFETY: This must only be called after CPU features have been written + // and synchronized. + pub(super) unsafe fn new_after_feature_flags_written_and_synced_unchecked() -> Self { + Self(NotSend::VALUE) + } + } + } else { + impl Features { + pub(super) fn new_no_features_to_detect() -> Self { + Self(NotSend::VALUE) + } + } + } + } + + pub struct Values { + values: u32, + cpu: Features, + } + + impl Values { + #[inline(always)] + pub(super) fn values(&self) -> u32 { + self.values + } + + #[inline(always)] + pub(super) fn cpu(&self) -> Features { + self.cpu + } + } +} + +const _: () = assert!(size_of::() == 0); + +cfg_if::cfg_if! { + if #[cfg(any(all(target_arch = "aarch64", target_endian = "little"), all(target_arch = "arm", target_endian = "little")))] { + pub mod arm; + use arm::featureflags; + } else if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { + pub mod intel; + use intel::featureflags; + } else { + mod featureflags { + use super::Features; + + #[inline(always)] + pub(super) fn get_or_init() -> Features { + Features::new_no_features_to_detect() + } + + #[inline(always)] + pub(super) fn get(_cpu_features: Features) -> u32 { + STATIC_DETECTED + } + + pub(super) const STATIC_DETECTED: u32 = 0; + pub(super) const FORCE_DYNAMIC_DETECTION: u32 = 0; + } + } +} + +const CAPS_STATIC: u32 = featureflags::STATIC_DETECTED & !featureflags::FORCE_DYNAMIC_DETECTION; + +#[allow(clippy::assertions_on_constants, clippy::bad_bit_mask)] +const _FORCE_DYNAMIC_DETECTION_HONORED: () = + assert!((CAPS_STATIC & featureflags::FORCE_DYNAMIC_DETECTION) == 0); + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_static_is_subset_of_dynamic() { + let cpu = features(); + let dynamic = featureflags::get(cpu); + assert_eq!(dynamic & CAPS_STATIC, CAPS_STATIC); + } +} diff --git a/http/vendor/ring/src/cpu/arm.rs b/http/vendor/ring/src/cpu/arm.rs new file mode 100644 index 0000000..8da973a --- /dev/null +++ b/http/vendor/ring/src/cpu/arm.rs @@ -0,0 +1,192 @@ +// Copyright 2016-2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::CAPS_STATIC; + +mod abi_assumptions { + use core::mem::size_of; + + // TODO: Support ARM64_32; see + // https://github.com/briansmith/ring/issues/1832#issuecomment-1892928147. This also requires + // replacing all `cfg(target_pointer_width)` logic for non-pointer/reference things + // (`N0`, `Limb`, `LimbMask`, `crypto_word_t` etc.). + #[cfg(target_arch = "aarch64")] + const _ASSUMED_POINTER_SIZE: usize = 8; + #[cfg(target_arch = "arm")] + const _ASSUMED_POINTER_SIZE: usize = 4; + const _ASSUMED_USIZE_SIZE: () = assert!(size_of::() == _ASSUMED_POINTER_SIZE); + const _ASSUMED_REF_SIZE: () = assert!(size_of::<&'static u8>() == _ASSUMED_POINTER_SIZE); + + // To support big-endian, we'd need to make several changes as described in + // https://github.com/briansmith/ring/issues/1832. + const _ASSUMED_ENDIANNESS: () = assert!(cfg!(target_endian = "little")); +} + +// uclibc: When linked statically, uclibc doesn't provide getauxval. +// When linked dynamically, recent versions do provide it, but we +// want to support older versions too. Assume that if uclibc is being +// used, this is an embedded target where the user cares a lot about +// minimizing code size and also that they know in advance exactly +// what target features are supported, so rely only on static feature +// detection. + +cfg_if::cfg_if! { + if #[cfg(all(all(target_arch = "aarch64", target_endian = "little"), + any(target_os = "ios", target_os = "macos", target_os = "tvos", target_os = "visionos", target_os = "watchos")))] { + mod darwin; + use darwin as detect; + } else if #[cfg(all(all(target_arch = "aarch64", target_endian = "little"), target_os = "fuchsia"))] { + mod fuchsia; + use fuchsia as detect; + } else if #[cfg(any(target_os = "android", target_os = "linux"))] { + mod linux; + use linux as detect; + } else if #[cfg(all(all(target_arch = "aarch64", target_endian = "little"), target_os = "windows"))] { + mod windows; + use windows as detect; + } else { + mod detect { + pub const FORCE_DYNAMIC_DETECTION: u32 = 0; + pub fn detect_features() -> u32 { 0 } + } + } +} + +impl_get_feature! { + features: [ + // TODO(MSRV): 32-bit ARM doesn't have `target_feature = "neon"` yet. + { ("aarch64", "arm") => Neon }, + + // TODO(MSRV): There is no "pmull" feature listed from + // `rustc --print cfg --target=aarch64-apple-darwin`. Originally ARMv8 tied + // PMULL detection into AES detection, but later versions split it; see + // https://developer.arm.com/downloads/-/exploration-tools/feature-names-for-a-profile + // "Features introduced prior to 2020." Change this to use "pmull" when + // that is supported. + { ("aarch64") => PMull }, + + { ("aarch64") => Aes }, + + { ("aarch64") => Sha256 }, + + // Keep in sync with `ARMV8_SHA512`. + + // "sha3" is overloaded for both SHA-3 and SHA-512. + { ("aarch64") => Sha512 }, + ], +} + +pub(super) mod featureflags { + pub(in super::super) use super::detect::FORCE_DYNAMIC_DETECTION; + use super::*; + use crate::{ + cpu, + polyfill::{once_cell::race, usize_from_u32}, + }; + use core::num::NonZeroUsize; + #[cfg(all(target_arch = "arm", target_endian = "little"))] + use core::sync::atomic::{AtomicU32, Ordering}; + + pub(in super::super) fn get_or_init() -> cpu::Features { + fn init() -> NonZeroUsize { + let detected = detect::detect_features(); + let filtered = (if cfg!(feature = "unstable-testing-arm-no-hw") { + !Neon::mask() + } else { + 0 + }) | (if cfg!(feature = "unstable-testing-arm-no-neon") { + Neon::mask() + } else { + 0 + }); + let detected = detected & !filtered; + let merged = CAPS_STATIC | detected; + + #[cfg(all( + target_arch = "arm", + target_endian = "little", + target_has_atomic = "32" + ))] + if (merged & Neon::mask()) == Neon::mask() { + // `neon_available` is declared as `alignas(4) uint32_t` in the C code. + // AtomicU32 is `#[repr(C, align(4))]`. + prefixed_extern! { + static neon_available: AtomicU32; + } + // SAFETY: The C code only reads `neon_available`, and its + // reads are synchronized through the `OnceNonZeroUsize` + // Acquire/Release semantics as we ensure we have a + // `cpu::Features` instance before calling into the C code. + let p = unsafe { &neon_available }; + p.store(1, Ordering::Relaxed); + } + + let merged = usize_from_u32(merged) | (1 << (Shift::Initialized as u32)); + NonZeroUsize::new(merged).unwrap() // Can't fail because we just set a bit. + } + + // SAFETY: This is the only caller. Any concurrent reading doesn't + // affect the safety of the writing. + let _: NonZeroUsize = FEATURES.get_or_init(init); + + // SAFETY: We initialized the CPU features as required. + unsafe { cpu::Features::new_after_feature_flags_written_and_synced_unchecked() } + } + + pub(in super::super) fn get(_cpu_features: cpu::Features) -> u32 { + // SAFETY: Since only `get_or_init()` could have created + // `_cpu_features`, and it only does so after `FEATURES.get_or_init()`, + // we know we are reading from `FEATURES` after initializing it. + // + // Also, 0 means "no features detected" to users, which is designed to + // be a safe configuration. + let features = FEATURES.get().map(NonZeroUsize::get).unwrap_or(0); + + // The truncation is lossless, as we set the value with a u32. + #[allow(clippy::cast_possible_truncation)] + let features = features as u32; + + features + } + + static FEATURES: race::OnceNonZeroUsize = race::OnceNonZeroUsize::new(); + + // TODO(MSRV): There is no "pmull" feature listed from + // `rustc --print cfg --target=aarch64-apple-darwin`. Originally ARMv8 tied + // PMULL detection into AES detection, but later versions split it; see + // https://developer.arm.com/downloads/-/exploration-tools/feature-names-for-a-profile + // "Features introduced prior to 2020." Change this to use "pmull" when + // that is supported. + // + // "sha3" is overloaded for both SHA-3 and SHA-512. + #[cfg(all(target_arch = "aarch64", target_endian = "little"))] + #[rustfmt::skip] + pub(in super::super) const STATIC_DETECTED: u32 = 0 + | (if cfg!(target_feature = "neon") { Neon::mask() } else { 0 }) + | (if cfg!(target_feature = "aes") { Aes::mask() } else { 0 }) + | (if cfg!(target_feature = "aes") { PMull::mask() } else { 0 }) + | (if cfg!(target_feature = "sha2") { Sha256::mask() } else { 0 }) + | (if cfg!(target_feature = "sha3") { Sha512::mask() } else { 0 }) + ; + + // TODO(MSRV): 32-bit ARM doesn't support any static feature detection yet. + #[cfg(all(target_arch = "arm", target_endian = "little"))] + pub(in super::super) const STATIC_DETECTED: u32 = 0; +} + +#[allow(clippy::assertions_on_constants)] +const _AARCH64_HAS_NEON: () = assert!( + ((CAPS_STATIC & Neon::mask()) == Neon::mask()) + || !cfg!(all(target_arch = "aarch64", target_endian = "little")) +); diff --git a/http/vendor/ring/src/cpu/arm/darwin.rs b/http/vendor/ring/src/cpu/arm/darwin.rs new file mode 100644 index 0000000..6d40bc7 --- /dev/null +++ b/http/vendor/ring/src/cpu/arm/darwin.rs @@ -0,0 +1,113 @@ +// Copyright 2016-2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::{Aes, Neon, PMull, Sha256, Sha512, CAPS_STATIC}; +use crate::polyfill::cstr; + +// ``` +// $ rustc +1.61.0 --print cfg --target=aarch64-apple-ios | grep -E "neon|aes|sha|pmull" +// target_feature="aes" +// target_feature="neon" +// target_feature="sha2" +// $ rustc +1.61.0 --print cfg --target=aarch64-apple-darwin | grep -E "neon|aes|sha|pmull" +// target_feature="aes" +// target_feature="neon" +// target_feature="sha2" +// target_feature="sha3" +// ``` +// +// XXX/TODO(coverage)/TODO(size): aarch64-apple-darwin is statically guaranteed to have "sha3" but +// other aarch64-apple-* targets require dynamic detection. Since we don't have test coverage for +// the other targets yet, we wouldn't have a way of testing the dynamic detection if we statically +// enabled `Sha512` for -darwin. So instead, temporarily, we statically ignore the static +// availability of the feature on -darwin so that it runs the dynamic detection. +pub const MIN_STATIC_FEATURES: u32 = Neon::mask() | Aes::mask() | Sha256::mask() | PMull::mask(); +pub const FORCE_DYNAMIC_DETECTION: u32 = !MIN_STATIC_FEATURES; + +// MSRV: Enforce 1.61.0 onaarch64-apple-*, in particular) prior to. Earlier +// versions of Rust before did not report the AAarch64 CPU features correctly +// for these targets. Cargo.toml specifies `rust-version` but versions before +// Rust 1.56 don't know about it. +#[allow(clippy::assertions_on_constants)] +const _AARCH64_APPLE_TARGETS_EXPECTED_FEATURES: () = + assert!((CAPS_STATIC & MIN_STATIC_FEATURES) == MIN_STATIC_FEATURES); + +// Ensure we don't accidentally allow features statically beyond +// `MIN_STATIC_FEATURES` so that dynamic detection is done uniformly for +// all of these targets. +#[allow(clippy::assertions_on_constants)] +const _AARCH64_APPLE_DARWIN_TARGETS_EXPECTED_FEATURES: () = + assert!(CAPS_STATIC == MIN_STATIC_FEATURES); + +pub fn detect_features() -> u32 { + fn detect_feature(name: cstr::Ref) -> bool { + use crate::polyfill; + use core::mem; + use libc::{c_int, c_void}; + + let mut value: c_int = 0; + let mut len = mem::size_of_val(&value); + let value_ptr = polyfill::ptr::from_mut(&mut value).cast::(); + // SAFETY: `value_ptr` is a valid pointer to `value` and `len` is the size of `value`. + let rc = unsafe { + libc::sysctlbyname(name.as_ptr(), value_ptr, &mut len, core::ptr::null_mut(), 0) + }; + // All the conditions are separated so we can observe them in code coverage. + if rc != 0 { + return false; + } + debug_assert_eq!(len, mem::size_of_val(&value)); + if len != mem::size_of_val(&value) { + return false; + } + value != 0 + } + + // We do not need to check for the presence of NEON, as Armv8-A always has it + const _ASSERT_NEON_DETECTED: () = assert!((CAPS_STATIC & Neon::mask()) == Neon::mask()); + + let mut features = 0; + + // TODO(MSRV 1.77): Use c"..." literal. + const SHA512_NAME: cstr::Ref = + cstr::unwrap_const_from_bytes_with_nul(b"hw.optional.armv8_2_sha512\0"); + if detect_feature(SHA512_NAME) { + features |= Sha512::mask(); + } + + features +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::cpu; + + #[test] + fn sha512_detection() { + // We intentionally disable static feature detection for SHA-512. + const _SHA512_NOT_STATICALLY_DETECTED: () = assert!((CAPS_STATIC & Sha512::mask()) == 0); + + if cfg!(target_os = "macos") { + use crate::cpu::{arm::Sha512, GetFeature as _}; + + // All aarch64-apple-darwin targets have SHA3 enabled statically... + assert!(cfg!(target_feature = "sha3")); + + // ...so we should detect it. + let cpu = cpu::features(); + assert!(matches!(cpu.get_feature(), Some(Sha512 { .. }))); + } + } +} diff --git a/http/vendor/ring/src/cpu/arm/fuchsia.rs b/http/vendor/ring/src/cpu/arm/fuchsia.rs new file mode 100644 index 0000000..bb1232b --- /dev/null +++ b/http/vendor/ring/src/cpu/arm/fuchsia.rs @@ -0,0 +1,58 @@ +// Copyright 2016-2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::{Aes, Neon, PMull, Sha256, Sha512, CAPS_STATIC}; + +pub const FORCE_DYNAMIC_DETECTION: u32 = 0; + +pub fn detect_features() -> u32 { + type zx_status_t = i32; + + #[link(name = "zircon")] + extern "C" { + fn zx_system_get_features(kind: u32, features: *mut u32) -> zx_status_t; + } + + const ZX_OK: i32 = 0; + const ZX_FEATURE_KIND_CPU: u32 = 0; + const ZX_ARM64_FEATURE_ISA_AES: u32 = 1 << 3; + const ZX_ARM64_FEATURE_ISA_PMULL: u32 = 1 << 4; + const ZX_ARM64_FEATURE_ISA_SHA256: u32 = 1 << 6; + const ZX_ARM64_FEATURE_ISA_SHA512: u32 = 1 << 18; + + let mut caps = 0; + let rc = unsafe { zx_system_get_features(ZX_FEATURE_KIND_CPU, &mut caps) }; + + let mut features = 0; + + // We do not need to check for the presence of NEON, as Armv8-A always has it + const _ASSERT_NEON_DETECTED: () = assert!((CAPS_STATIC & Neon::mask()) == Neon::mask()); + + if rc == ZX_OK { + if caps & ZX_ARM64_FEATURE_ISA_AES == ZX_ARM64_FEATURE_ISA_AES { + features |= Aes::mask(); + } + if caps & ZX_ARM64_FEATURE_ISA_PMULL == ZX_ARM64_FEATURE_ISA_PMULL { + features |= PMull::mask(); + } + if caps & ZX_ARM64_FEATURE_ISA_SHA256 == ZX_ARM64_FEATURE_ISA_SHA256 { + features |= Sha256::mask(); + } + if caps & ZX_ARM64_FEATURE_ISA_SHA512 == ZX_ARM64_FEATURE_ISA_SHA512 { + features |= Sha512::mask(); + } + } + + features +} diff --git a/http/vendor/ring/src/cpu/arm/linux.rs b/http/vendor/ring/src/cpu/arm/linux.rs new file mode 100644 index 0000000..db9549c --- /dev/null +++ b/http/vendor/ring/src/cpu/arm/linux.rs @@ -0,0 +1,107 @@ +// Copyright 2016-2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::Neon; + +// Work around a bug in LLVM/rustc where `-C target_cpu=cortex-a72`-- +// and `-C target_cpu=native` on Cortex-A72 Raspberry PI devices in +// particular--enables crypto features even though not all Cortex-A72 +// CPUs have crypto features: +// +// ``` +// $ rustc --print cfg --target=aarch64-unknown-linux-gnu | grep feature +// target_feature="neon" +// $ rustc --print cfg --target=aarch64-unknown-linux-gnu -C target_cpu=cortex-a72 | grep feature +// target_feature="aes" +// target_feature="crc" +// target_feature="neon" +// target_feature="pmuv3" +// target_feature="sha2" +// ``` +// +// XXX/TODO(MSRV https://github.com/llvm/llvm-project/issues/90365): This +// workaround is heavy-handed since it forces extra branches for devices that +// have correctly-modeled feature sets, so it should be removed. +pub const FORCE_DYNAMIC_DETECTION: u32 = !Neon::mask(); + +// `uclibc` does not provide `getauxval` so just use static feature detection +// for it. +#[cfg(target_env = "uclibc")] +pub fn detect_features() -> u32 { + 0 +} + +#[cfg(all( + not(target_env = "uclibc"), + all(target_arch = "aarch64", target_endian = "little") +))] +pub fn detect_features() -> u32 { + use super::{Aes, PMull, Sha256, Sha512, CAPS_STATIC}; + use libc::{getauxval, AT_HWCAP, HWCAP_AES, HWCAP_PMULL, HWCAP_SHA2, HWCAP_SHA512}; + + let mut features = 0; + + // We do not need to check for the presence of NEON, as Armv8-A always has it + const _ASSERT_NEON_DETECTED: () = assert!((CAPS_STATIC & Neon::mask()) == Neon::mask()); + + let caps = unsafe { getauxval(AT_HWCAP) }; + + if caps & HWCAP_AES == HWCAP_AES { + features |= Aes::mask(); + } + if caps & HWCAP_PMULL == HWCAP_PMULL { + features |= PMull::mask(); + } + if caps & HWCAP_SHA2 == HWCAP_SHA2 { + features |= Sha256::mask(); + } + if caps & HWCAP_SHA512 == HWCAP_SHA512 { + features |= Sha512::mask(); + } + + features +} + +#[cfg(all( + not(target_env = "uclibc"), + all(target_arch = "arm", target_endian = "little") +))] +pub fn detect_features() -> u32 { + use super::CAPS_STATIC; + + // The `libc` crate doesn't provide this functionality on all + // 32-bit Linux targets, like Android or -musl. Use this polyfill + // for all 32-bit ARM targets so that testing on one of them will + // be more meaningful to the others. + use libc::c_ulong; + extern "C" { + pub fn getauxval(type_: c_ulong) -> c_ulong; + } + const AT_HWCAP: c_ulong = 16; + const HWCAP_NEON: c_ulong = 1 << 12; + + let mut features = 0; + + if CAPS_STATIC & Neon::mask() != Neon::mask() { + let caps = unsafe { getauxval(AT_HWCAP) }; + + // OpenSSL and BoringSSL don't enable any other features if NEON isn't + // available. We don't enable any hardware implementations for 32-bit ARM. + if caps & HWCAP_NEON == HWCAP_NEON { + features |= Neon::mask(); + } + } + + features +} diff --git a/http/vendor/ring/src/cpu/arm/windows.rs b/http/vendor/ring/src/cpu/arm/windows.rs new file mode 100644 index 0000000..a753706 --- /dev/null +++ b/http/vendor/ring/src/cpu/arm/windows.rs @@ -0,0 +1,38 @@ +// Copyright 2016-2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::{Aes, Neon, PMull, Sha256, CAPS_STATIC}; +use windows_sys::Win32::System::Threading::{ + IsProcessorFeaturePresent, PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE, +}; + +pub const FORCE_DYNAMIC_DETECTION: u32 = 0; + +pub fn detect_features() -> u32 { + // We do not need to check for the presence of NEON, as Armv8-A always has it + const _ASSERT_NEON_DETECTED: () = assert!((CAPS_STATIC & Neon::mask()) == Neon::mask()); + + let mut features = 0; + + let result = unsafe { IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE) }; + + if result != 0 { + // These are all covered by one call in Windows + features |= Aes::mask(); + features |= PMull::mask(); + features |= Sha256::mask(); + } + + features +} diff --git a/http/vendor/ring/src/cpu/intel.rs b/http/vendor/ring/src/cpu/intel.rs new file mode 100644 index 0000000..f45052f --- /dev/null +++ b/http/vendor/ring/src/cpu/intel.rs @@ -0,0 +1,382 @@ +// Copyright 2016-2021 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use cfg_if::cfg_if; + +mod abi_assumptions { + use core::mem::size_of; + + // TOOD: Support targets that do not have SSE and SSE2 enabled, such as + // x86_64-unknown-linux-none. See + // https://github.com/briansmith/ring/issues/1793#issuecomment-1793243725, + // https://github.com/briansmith/ring/issues/1832, + // https://github.com/briansmith/ring/issues/1833. + const _ASSUMES_SSE2: () = + assert!(cfg!(target_feature = "sse") && cfg!(target_feature = "sse2")); + + #[cfg(target_arch = "x86_64")] + const _ASSUMED_POINTER_SIZE: usize = 8; + #[cfg(target_arch = "x86")] + const _ASSUMED_POINTER_SIZE: usize = 4; + const _ASSUMED_USIZE_SIZE: () = assert!(size_of::() == _ASSUMED_POINTER_SIZE); + const _ASSUMED_REF_SIZE: () = assert!(size_of::<&'static u8>() == _ASSUMED_POINTER_SIZE); + + const _ASSUMED_ENDIANNESS: () = assert!(cfg!(target_endian = "little")); +} + +pub(super) mod featureflags { + use super::super::CAPS_STATIC; + use crate::{ + cpu, + polyfill::{once_cell::race, usize_from_u32}, + }; + use core::num::NonZeroUsize; + + pub(in super::super) fn get_or_init() -> cpu::Features { + // SAFETY: `OPENSSL_cpuid_setup` must be called only in + // `INIT.call_once()` below. + prefixed_extern! { + fn OPENSSL_cpuid_setup(out: &mut [u32; 4]); + } + + let _: NonZeroUsize = FEATURES.get_or_init(|| { + let mut cpuid = [0; 4]; + // SAFETY: We assume that it is safe to execute CPUID and XGETBV. + unsafe { + OPENSSL_cpuid_setup(&mut cpuid); + } + let detected = super::cpuid_to_caps_and_set_c_flags(&cpuid); + let merged = CAPS_STATIC | detected; + + let merged = usize_from_u32(merged) | (1 << (super::Shift::Initialized as u32)); + NonZeroUsize::new(merged).unwrap() // Can't fail because we just set a bit. + }); + + // SAFETY: We initialized the CPU features as required. + // `INIT.call_once` has `happens-before` semantics. + unsafe { cpu::Features::new_after_feature_flags_written_and_synced_unchecked() } + } + + pub(in super::super) fn get(_cpu_features: cpu::Features) -> u32 { + // SAFETY: Since only `get_or_init()` could have created + // `_cpu_features`, and it only does so after `FEATURES.get_or_init()`, + // we know we are reading from `FEATURES` after initializing it. + // + // Also, 0 means "no features detected" to users, which is designed to + // be a safe configuration. + let features = FEATURES.get().map(NonZeroUsize::get).unwrap_or(0); + + // The truncation is lossless, as we set the value with a u32. + #[allow(clippy::cast_possible_truncation)] + let features = features as u32; + + features + } + + static FEATURES: race::OnceNonZeroUsize = race::OnceNonZeroUsize::new(); + + #[cfg(target_arch = "x86")] + #[rustfmt::skip] + pub const STATIC_DETECTED: u32 = 0 + | (if cfg!(target_feature = "sse2") { super::Sse2::mask() } else { 0 }) + ; + + // Limited to x86_64-v2 features. + // TODO: Add missing x86-64-v3 features if we find real-world use of x86-64-v3. + // TODO: Add all features we use. + #[cfg(target_arch = "x86_64")] + #[rustfmt::skip] + pub const STATIC_DETECTED: u32 = 0 + | if cfg!(target_feature = "sse4.1") { super::Sse41::mask() } else { 0 } + | if cfg!(target_feature = "ssse3") { super::Ssse3::mask() } else { 0 } + ; + + pub const FORCE_DYNAMIC_DETECTION: u32 = 0; +} + +fn cpuid_to_caps_and_set_c_flags(cpuid: &[u32; 4]) -> u32 { + // "Intel" citations are for "Intel 64 and IA-32 Architectures Software + // Developer’s Manual", Combined Volumes, December 2024. + // "AMD" citations are for "AMD64 Technology AMD64 Architecture + // Programmer’s Manual, Volumes 1-5" Revision 4.08 April 2024. + + // The `prefixed_extern!` uses below assume this + #[cfg(target_arch = "x86_64")] + use core::{mem::align_of, sync::atomic::AtomicU32}; + #[cfg(target_arch = "x86_64")] + const _ATOMIC32_ALIGNMENT_EQUALS_U32_ALIGNMENT: () = + assert!(align_of::() == align_of::()); + + fn check(leaf: u32, bit: u32) -> bool { + let shifted = 1 << bit; + (leaf & shifted) == shifted + } + fn set(out: &mut u32, shift: Shift) { + let shifted = 1 << (shift as u32); + debug_assert_eq!(*out & shifted, 0); + *out |= shifted; + debug_assert_eq!(*out & shifted, shifted); + } + + #[cfg(target_arch = "x86_64")] + let is_intel = check(cpuid[0], 30); // Synthesized by `OPENSSL_cpuid_setup` + + // CPUID leaf 1. + let leaf1_ecx = cpuid[1]; + + // Intel: "Structured Extended Feature Flags Enumeration Leaf" + #[cfg(target_arch = "x86_64")] + let (extended_features_ebx, extended_features_ecx) = (cpuid[2], cpuid[3]); + + let mut caps = 0; + + // AMD: "Collectively the SSE1, [...] are referred to as the legacy SSE + // instructions. All legacy SSE instructions support 128-bit vector + // operands." + + // Intel: "11.6.2 Checking for Intel SSE and SSE2 Support" + // We have to assume the prerequisites for SSE/SSE2 are met since we're + // already almost definitely using SSE registers if these target features + // are enabled. + // + // These also seem to help ensure CMOV support; There doesn't seem to be + // a `cfg!(target_feature = "cmov")`. It is likely that removing these + // assertions will remove the requirement for CMOV. With our without + // CMOV, it is likely that some of our timing side channel prevention does + // not work. Presumably the people who delete these are verifying that it + // all works fine. + const _SSE_REQUIRED: () = assert!(cfg!(target_feature = "sse")); + const _SSE2_REQUIRED: () = assert!(cfg!(target_feature = "sse2")); + + #[cfg(all(target_arch = "x86", not(target_feature = "sse2")))] + { + // If somebody is trying to compile for an x86 target without SSE2 + // and they deleted the `_SSE2_REQUIRED` const assertion above then + // they're probably trying to support a Linux/BSD/etc. distro that + // tries to support ancient x86 systems without SSE/SSE2. Try to + // reduce the harm caused, by implementing dynamic feature detection + // for them so that most systems will work like normal. + // + // Note that usually an x86-64 target with SSE2 disabled by default, + // usually `-none-` targets, will not support dynamically-detected use + // of SIMD registers via CPUID. A whole different mechanism is needed + // to support them. Same for i*86-*-none targets. + let leaf1_edx = cpuid[0]; + let sse1_available = check(leaf1_edx, 25); + let sse2_available = check(leaf1_edx, 26); + if sse1_available && sse2_available { + set(&mut caps, Shift::Sse2); + } + } + + // Sometimes people delete the `_SSE_REQUIRED`/`_SSE2_REQUIRED` const + // assertions in an attempt to support pre-SSE2 32-bit x86 systems. If they + // do, hopefully they won't delete these redundant assertions, so that + // x86_64 isn't affected. + #[cfg(target_arch = "x86_64")] + const _SSE2_REQUIRED_X86_64: () = assert!(cfg!(target_feature = "sse2")); + #[cfg(target_arch = "x86_64")] + const _SSE_REQUIRED_X86_64: () = assert!(cfg!(target_feature = "sse2")); + + // Intel: "12.7.2 Checking for SSSE3 Support" + // If/when we support dynamic detection of SSE/SSE2, make this conditional + // on SSE/SSE2. + if check(leaf1_ecx, 9) { + set(&mut caps, Shift::Ssse3); + } + + // Intel: "12.12.2 Checking for Intel SSE4.1 Support" + // If/when we support dynamic detection of SSE/SSE2, make this conditional + // on SSE/SSE2. + // XXX: We don't check for SSE3 and we're not sure if it is compatible for + // us to do so; does AMD advertise SSE3? TODO: address this. + // XXX: We don't condition this on SSSE3 being available. TODO: address + // this. + #[cfg(target_arch = "x86_64")] + if check(leaf1_ecx, 19) { + set(&mut caps, Shift::Sse41); + } + + // AMD: "The extended SSE instructions include [...]." + + // Intel: "14.3 DETECTION OF INTEL AVX INSTRUCTIONS" + // `OPENSSL_cpuid_setup` clears this bit when it detects the OS doesn't + // support AVX state. + let avx_available = check(leaf1_ecx, 28); + if avx_available { + set(&mut caps, Shift::Avx); + } + + #[cfg(target_arch = "x86_64")] + if avx_available { + // The Intel docs don't seem to document the detection. The instruction + // definitions of the VEX.256 instructions reference the + // VAES/VPCLMULQDQ features and the documentation for the extended + // features gives the values. We combine these into one feature because + // we never use them independently. + let vaes_available = check(extended_features_ecx, 9); + let vclmul_available = check(extended_features_ecx, 10); + if vaes_available && vclmul_available { + set(&mut caps, Shift::VAesClmul); + } + } + + // "14.7.1 Detection of Intel AVX2 Hardware support" + // XXX: We don't condition AVX2 on AVX. TODO: Address this. + // `OPENSSL_cpuid_setup` clears this bit when it detects the OS doesn't + // support AVX state. + #[cfg(target_arch = "x86_64")] + if check(extended_features_ebx, 5) { + set(&mut caps, Shift::Avx2); + + // Declared as `uint32_t` in the C code. + prefixed_extern! { + static avx2_available: AtomicU32; + } + // SAFETY: The C code only reads `avx2_available`, and its reads are + // synchronized through the `OnceNonZeroUsize` Acquire/Release + // semantics as we ensure we have a `cpu::Features` instance before + // calling into the C code. + let flag = unsafe { &avx2_available }; + flag.store(1, core::sync::atomic::Ordering::Relaxed); + } + + // Intel: "12.13.4 Checking for Intel AES-NI Support" + // If/when we support dynamic detection of SSE/SSE2, revisit this. + // TODO: Clarify "interesting" states like (!SSE && AVX && AES-NI) + // and AES-NI & !AVX. + // Each check of `ClMul`, `Aes`, and `Sha` must be paired with a check for + // an AVX feature (e.g. `Avx`) or an SSE feature (e.g. `Ssse3`), as every + // use will either be supported by SSE* or AVX* instructions. We then + // assume that those supporting instructions' prerequisites (e.g. OS + // support for AVX or SSE state, respectively) are the only prerequisites + // for these features. + if check(leaf1_ecx, 1) { + set(&mut caps, Shift::ClMul); + } + if check(leaf1_ecx, 25) { + set(&mut caps, Shift::Aes); + } + // See BoringSSL 69c26de93c82ad98daecaec6e0c8644cdf74b03f before enabling + // static feature detection for this. + #[cfg(target_arch = "x86_64")] + if check(extended_features_ebx, 29) { + set(&mut caps, Shift::Sha); + } + + #[cfg(target_arch = "x86_64")] + { + if is_intel { + set(&mut caps, Shift::IntelCpu); + } + + if check(leaf1_ecx, 22) { + set(&mut caps, Shift::Movbe); + } + + let adx_available = check(extended_features_ebx, 19); + if adx_available { + set(&mut caps, Shift::Adx); + } + + // Some 6th Generation (Skylake) CPUs claim to support BMI1 and BMI2 + // when they don't; see erratum "SKD052". The Intel document at + // https://www.intel.com/content/dam/www/public/us/en/documents/specification-updates/6th-gen-core-u-y-spec-update.pdf + // contains the footnote "Affects 6th Generation Intel Pentium processor + // family and Intel Celeron processor family". Further research indicates + // that Skylake Pentium/Celeron do not implement AVX or ADX. It turns + // out that we only use BMI1 and BMI2 in combination with ADX and/or + // AVX. + // + // rust `std::arch::is_x86_feature_detected` does a very similar thing + // but only looks at AVX, not ADX. Note that they reference an older + // version of the erratum labeled SKL052. + let believe_bmi_bits = !is_intel || (adx_available || avx_available); + + if check(extended_features_ebx, 3) && believe_bmi_bits { + set(&mut caps, Shift::Bmi1); + } + + let bmi2_available = check(extended_features_ebx, 8) && believe_bmi_bits; + if bmi2_available { + set(&mut caps, Shift::Bmi2); + } + + if adx_available && bmi2_available { + // Declared as `uint32_t` in the C code. + prefixed_extern! { + static adx_bmi2_available: AtomicU32; + } + // SAFETY: The C code only reads `adx_bmi2_available`, and its + // reads are synchronized through the `OnceNonZeroUsize` + // Acquire/Release semantics as we ensure we have a + // `cpu::Features` instance before calling into the C code. + let flag = unsafe { &adx_bmi2_available }; + flag.store(1, core::sync::atomic::Ordering::Relaxed); + } + } + + caps +} + +impl_get_feature! { + features: [ + { ("x86_64") => VAesClmul }, + { ("x86", "x86_64") => ClMul }, + { ("x86", "x86_64") => Ssse3 }, + { ("x86_64") => Sse41 }, + { ("x86_64") => Movbe }, + { ("x86", "x86_64") => Aes }, + { ("x86", "x86_64") => Avx }, + { ("x86_64") => Bmi1 }, + { ("x86_64") => Avx2 }, + { ("x86_64") => Bmi2 }, + { ("x86_64") => Adx }, + // See BoringSSL 69c26de93c82ad98daecaec6e0c8644cdf74b03f before enabling + // static feature detection for this. + { ("x86_64") => Sha }, + // x86_64 can just assume SSE2 is available. + { ("x86") => Sse2 }, + ], +} + +cfg_if! { + if #[cfg(target_arch = "x86_64")] { + #[derive(Clone, Copy)] + pub(crate) struct IntelCpu(super::Features); + + impl super::GetFeature for super::features::Values { + fn get_feature(&self) -> Option { + const MASK: u32 = 1 << (Shift::IntelCpu as u32); + if (self.values() & MASK) == MASK { + Some(IntelCpu(self.cpu())) + } else { + None + } + } + } + } +} + +#[cfg(test)] +mod tests { + // This should always pass on any x86 system except very, very, old ones. + #[cfg(target_arch = "x86")] + #[test] + fn x86_has_sse2() { + use super::*; + use crate::cpu::{self, GetFeature as _}; + assert!(matches!(cpu::features().get_feature(), Some(Sse2 { .. }))) + } +} diff --git a/http/vendor/ring/src/data/alg-rsa-encryption.der b/http/vendor/ring/src/data/alg-rsa-encryption.der new file mode 100644 index 0000000..77d159a Binary files /dev/null and b/http/vendor/ring/src/data/alg-rsa-encryption.der differ diff --git a/http/vendor/ring/src/debug.rs b/http/vendor/ring/src/debug.rs new file mode 100644 index 0000000..5de58be --- /dev/null +++ b/http/vendor/ring/src/debug.rs @@ -0,0 +1,84 @@ +// Copyright 2018 Trent Clarke. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +// Generates an implementation of the Debug trait for a type that defers to the +// Debug implementation for a given field. +macro_rules! derive_debug_via_id { + ($typename:ident) => { + impl ::core::fmt::Debug for $typename { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> Result<(), ::core::fmt::Error> { + ::core::fmt::Debug::fmt(&self.id, f) + } + } + }; +} + +macro_rules! derive_debug_via_field { + ($type:ty, $field:ident) => { + derive_debug_via_field!($type, stringify!($type), $field); + }; + + ($type:ty, $typename:expr, $field:ident) => { + impl ::core::fmt::Debug for $type { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> Result<(), ::core::fmt::Error> { + f.debug_struct($typename) + .field(stringify!($field), &self.$field) + .finish() + } + } + }; +} + +// Generates an implementation of the Debug trait for a type that outputs the +// hex encoding of the byte slice representation of the value. +macro_rules! derive_debug_self_as_ref_hex_bytes { + ($typename:ident) => { + impl ::core::fmt::Debug for $typename { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> Result<(), ::core::fmt::Error> { + crate::debug::write_hex_tuple(f, stringify!($typename), self) + } + } + }; +} + +pub(crate) fn write_hex_tuple( + fmt: &mut core::fmt::Formatter, + type_name: &str, + value: &dyn AsRef<[u8]>, +) -> Result<(), ::core::fmt::Error> { + fmt.debug_tuple(type_name) + .field(&HexStr(value.as_ref())) + .finish() +} + +pub struct HexStr<'a>(pub &'a [u8]); + +impl core::fmt::Debug for HexStr<'_> { + fn fmt(&self, fmt: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> { + fmt.write_str("\"")?; + write_hex_bytes(fmt, self.0)?; + fmt.write_str("\"")?; + Ok(()) + } +} + +pub(crate) fn write_hex_bytes( + fmt: &mut core::fmt::Formatter, + bytes: &[u8], +) -> Result<(), ::core::fmt::Error> { + for byte in bytes { + write!(fmt, "{:02x}", byte)?; + } + Ok(()) +} diff --git a/http/vendor/ring/src/deprecated_constant_time.rs b/http/vendor/ring/src/deprecated_constant_time.rs new file mode 100644 index 0000000..5703c6f --- /dev/null +++ b/http/vendor/ring/src/deprecated_constant_time.rs @@ -0,0 +1,22 @@ +// Copyright 2015-2025 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use crate::{bb, error}; + +#[deprecated( + note = "To be removed. Internal function not intended for external use with no promises regarding side channels." +)] +pub fn verify_slices_are_equal(a: &[u8], b: &[u8]) -> Result<(), error::Unspecified> { + bb::verify_slices_are_equal(a, b) +} diff --git a/http/vendor/ring/src/deprecated_test.rs b/http/vendor/ring/src/deprecated_test.rs new file mode 100644 index 0000000..3758aa2 --- /dev/null +++ b/http/vendor/ring/src/deprecated_test.rs @@ -0,0 +1,45 @@ +// Copyright 2025 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#![doc(hidden)] + +/// References a test input file. +#[macro_export] +macro_rules! test_file { + ($file_name:expr) => { + $crate::test::File { + file_name: $file_name, + contents: include_str!($file_name), + } + }; +} + +pub use crate::testutil::{ + compile_time_assert_clone, compile_time_assert_copy, compile_time_assert_eq, + compile_time_assert_send, compile_time_assert_sync, from_hex, run, File, TestCase, +}; + +#[cfg(feature = "std")] +pub use crate::testutil::compile_time_assert_std_error_error; + +#[deprecated(note = "internal API that will be removed")] +#[doc(hidden)] +pub mod rand { + #[deprecated(note = "internal API that will be removed")] + pub type FixedByteRandom = crate::testutil::rand::FixedByteRandom; + #[deprecated(note = "internal API that will be removed")] + pub type FixedSliceRandom<'a> = crate::testutil::rand::FixedSliceRandom<'a>; + #[deprecated(note = "internal API that will be removed")] + pub type FixedSliceSequenceRandom<'a> = crate::testutil::rand::FixedSliceSequenceRandom<'a>; +} diff --git a/http/vendor/ring/src/digest.rs b/http/vendor/ring/src/digest.rs new file mode 100644 index 0000000..e771237 --- /dev/null +++ b/http/vendor/ring/src/digest.rs @@ -0,0 +1,680 @@ +// Copyright 2015-2019 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! SHA-2 and the legacy SHA-1 digest algorithm. +//! +//! If all the data is available in a single contiguous slice then the `digest` +//! function should be used. Otherwise, the digest can be calculated in +//! multiple steps using `Context`. + +use self::{ + dynstate::DynState, + sha2::{SHA256_BLOCK_LEN, SHA512_BLOCK_LEN}, +}; +use crate::{ + bits::{BitLength, FromByteLen as _}, + cpu, debug, error, + polyfill::{self, slice, sliceutil}, +}; +use core::num::Wrapping; + +pub(crate) use self::finish_error::FinishError; + +mod dynstate; +mod sha1; +mod sha2; + +#[derive(Clone)] +pub(crate) struct BlockContext { + state: DynState, + + // Note that SHA-512 has a 128-bit input bit counter, but this + // implementation only supports up to 2^64-1 input bits for all algorithms, + // so a 64-bit counter is more than sufficient. + completed_bytes: u64, + + /// The context's algorithm. + pub algorithm: &'static Algorithm, +} + +impl BlockContext { + pub(crate) fn new(algorithm: &'static Algorithm) -> Self { + Self { + state: algorithm.initial_state.clone(), + completed_bytes: 0, + algorithm, + } + } + + /// Processes all the full blocks in `input`, returning the partial block + /// at the end, which may be empty. + pub(crate) fn update<'i>(&mut self, input: &'i [u8], cpu_features: cpu::Features) -> &'i [u8] { + let (completed_bytes, leftover) = self.block_data_order(input, cpu_features); + // Using saturated addition here allows `update` to be infallible and + // panic-free. If we were to reach the maximum value here then `finish` + // will detect that we processed too much data when it converts this to + // a bit length. + self.completed_bytes = self + .completed_bytes + .saturating_add(polyfill::u64_from_usize(completed_bytes)); + leftover + } + + // On input, `block[..num_pending]` is the (possibly-empty) last *partial* + // chunk of input. It *must* be partial; that is, it is required that + // `num_pending < self.algorithm.block_len`. + // + // `block` may be arbitrarily overwritten. + pub(crate) fn try_finish( + mut self, + block: &mut [u8; MAX_BLOCK_LEN], + num_pending: usize, + cpu_features: cpu::Features, + ) -> Result { + let completed_bits = self + .completed_bytes + .checked_add(polyfill::u64_from_usize(num_pending)) + .ok_or_else(|| { + // Choosing self.completed_bytes here is lossy & somewhat arbitrary. + InputTooLongError::new(self.completed_bytes) + }) + .and_then(BitLength::from_byte_len) + .map_err(FinishError::input_too_long)?; + + let block_len = self.algorithm.block_len(); + let block = &mut block[..block_len]; + + let padding = match block.get_mut(num_pending..) { + Some([separator, padding @ ..]) => { + *separator = 0x80; + padding + } + // Precondition violated. + unreachable => { + return Err(FinishError::pending_not_a_partial_block( + unreachable.as_deref(), + )); + } + }; + + let padding = match padding + .len() + .checked_sub(self.algorithm.block_len.len_len()) + { + Some(_) => padding, + None => { + padding.fill(0); + let (completed_bytes, leftover) = self.block_data_order(block, cpu_features); + debug_assert_eq!((completed_bytes, leftover.len()), (block_len, 0)); + // We don't increase |self.completed_bytes| because the padding + // isn't data, and so it isn't included in the data length. + &mut block[..] + } + }; + + let (to_zero, len) = padding.split_at_mut(padding.len() - 8); + to_zero.fill(0); + len.copy_from_slice(&completed_bits.to_be_bytes()); + + let (completed_bytes, leftover) = self.block_data_order(block, cpu_features); + debug_assert_eq!((completed_bytes, leftover.len()), (block_len, 0)); + + Ok(Digest { + algorithm: self.algorithm, + value: self.state.format_output(), + }) + } + + #[must_use] + fn block_data_order<'d>( + &mut self, + data: &'d [u8], + cpu_features: cpu::Features, + ) -> (usize, &'d [u8]) { + (self.algorithm.block_data_order)(&mut self.state, data, cpu_features) + } +} + +pub(crate) type InputTooLongError = error::InputTooLongError; + +cold_exhaustive_error! { + enum finish_error::FinishError { + input_too_long => InputTooLong(InputTooLongError), + pending_not_a_partial_block_inner => PendingNotAPartialBlock(usize), + } +} + +impl FinishError { + #[cold] + #[inline(never)] + fn pending_not_a_partial_block(padding: Option<&[u8]>) -> Self { + match padding { + None => Self::pending_not_a_partial_block_inner(0), + Some(padding) => Self::pending_not_a_partial_block_inner(padding.len()), + } + } +} + +/// A context for multi-step (Init-Update-Finish) digest calculations. +/// +/// # Examples +/// +/// ``` +/// use ring::digest; +/// +/// let one_shot = digest::digest(&digest::SHA384, b"hello, world"); +/// +/// let mut ctx = digest::Context::new(&digest::SHA384); +/// ctx.update(b"hello"); +/// ctx.update(b", "); +/// ctx.update(b"world"); +/// let multi_part = ctx.finish(); +/// +/// assert_eq!(&one_shot.as_ref(), &multi_part.as_ref()); +/// ``` +#[derive(Clone)] +pub struct Context { + block: BlockContext, + // TODO: More explicitly force 64-bit alignment for |pending|. + pending: [u8; MAX_BLOCK_LEN], + + // Invariant: `self.num_pending < self.block.algorithm.block_len`. + num_pending: usize, +} + +impl Context { + /// Constructs a new context. + pub fn new(algorithm: &'static Algorithm) -> Self { + Self { + block: BlockContext::new(algorithm), + pending: [0u8; MAX_BLOCK_LEN], + num_pending: 0, + } + } + + pub(crate) fn clone_from(block: &BlockContext) -> Self { + Self { + block: block.clone(), + pending: [0u8; MAX_BLOCK_LEN], + num_pending: 0, + } + } + + /// Updates the digest with all the data in `data`. + pub fn update(&mut self, data: &[u8]) { + let cpu_features = cpu::features(); + + let block_len = self.block.algorithm.block_len(); + let buffer = &mut self.pending[..block_len]; + + let to_digest = if self.num_pending == 0 { + data + } else { + let buffer_to_fill = match buffer.get_mut(self.num_pending..) { + Some(buffer_to_fill) => buffer_to_fill, + None => { + // Impossible because of the invariant. + unreachable!(); + } + }; + sliceutil::overwrite_at_start(buffer_to_fill, data); + match slice::split_at_checked(data, buffer_to_fill.len()) { + Some((just_copied, to_digest)) => { + debug_assert_eq!(buffer_to_fill.len(), just_copied.len()); + debug_assert_eq!(self.num_pending + just_copied.len(), block_len); + let leftover = self.block.update(buffer, cpu_features); + debug_assert_eq!(leftover.len(), 0); + self.num_pending = 0; + to_digest + } + None => { + self.num_pending += data.len(); + // If `data` isn't enough to complete a block, buffer it and stop. + debug_assert!(self.num_pending < block_len); + return; + } + } + }; + + let leftover = self.block.update(to_digest, cpu_features); + sliceutil::overwrite_at_start(buffer, leftover); + self.num_pending = leftover.len(); + debug_assert!(self.num_pending < block_len); + } + + /// Finalizes the digest calculation and returns the digest value. + /// + /// `finish` consumes the context so it cannot be (mis-)used after `finish` + /// has been called. + pub fn finish(self) -> Digest { + let cpu = cpu::features(); + self.try_finish(cpu) + .map_err(error::erase::) + .unwrap() + } + + pub(crate) fn try_finish( + mut self, + cpu_features: cpu::Features, + ) -> Result { + self.block + .try_finish(&mut self.pending, self.num_pending, cpu_features) + .map_err(|err| match err { + FinishError::InputTooLong(i) => i, + FinishError::PendingNotAPartialBlock(_) => { + // Due to invariant. + unreachable!() + } + }) + } + + /// The algorithm that this context is using. + #[inline(always)] + pub fn algorithm(&self) -> &'static Algorithm { + self.block.algorithm + } +} + +/// Returns the digest of `data` using the given digest algorithm. +pub fn digest(algorithm: &'static Algorithm, data: &[u8]) -> Digest { + let cpu = cpu::features(); + Digest::compute_from(algorithm, data, cpu) + .map_err(error::erase::) + .unwrap() +} + +/// A calculated digest value. +/// +/// Use [`Self::as_ref`] to get the value as a `&[u8]`. +#[derive(Clone, Copy)] +pub struct Digest { + value: Output, + algorithm: &'static Algorithm, +} + +impl Digest { + pub(crate) fn compute_from( + algorithm: &'static Algorithm, + data: &[u8], + cpu: cpu::Features, + ) -> Result { + let mut ctx = Context::new(algorithm); + ctx.update(data); + ctx.try_finish(cpu) + } + + /// The algorithm that was used to calculate the digest value. + #[inline(always)] + pub fn algorithm(&self) -> &'static Algorithm { + self.algorithm + } +} + +impl AsRef<[u8]> for Digest { + #[inline(always)] + fn as_ref(&self) -> &[u8] { + &self.value.0[..self.algorithm.output_len()] + } +} + +impl core::fmt::Debug for Digest { + fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result { + write!(fmt, "{:?}:", self.algorithm)?; + debug::write_hex_bytes(fmt, self.as_ref()) + } +} + +/// A digest algorithm. +pub struct Algorithm { + output_len: OutputLen, + chaining_len: usize, + block_len: BlockLen, + + /// `block_data_order` processes all the full blocks of data in `data`. It + /// returns the number of bytes processed and the unprocessed data, which + /// is guaranteed to be less than `block_len` bytes long. + block_data_order: for<'d> fn( + state: &mut DynState, + data: &'d [u8], + cpu_features: cpu::Features, + ) -> (usize, &'d [u8]), + + initial_state: DynState, + + id: AlgorithmID, +} + +#[derive(Debug, Eq, PartialEq)] +enum AlgorithmID { + SHA1, + SHA256, + SHA384, + SHA512, + SHA512_256, +} + +impl PartialEq for Algorithm { + fn eq(&self, other: &Self) -> bool { + self.id == other.id + } +} + +impl Eq for Algorithm {} + +derive_debug_via_id!(Algorithm); + +impl Algorithm { + /// The internal block length. + pub fn block_len(&self) -> usize { + self.block_len.into() + } + + /// The size of the chaining value of the digest function, in bytes. + /// + /// For non-truncated algorithms (SHA-1, SHA-256, SHA-512), this is equal + /// to [`Self::output_len()`]. For truncated algorithms (e.g. SHA-384, + /// SHA-512/256), this is equal to the length before truncation. This is + /// mostly helpful for determining the size of an HMAC key that is + /// appropriate for the digest algorithm. + pub fn chaining_len(&self) -> usize { + self.chaining_len + } + + /// The length of a finalized digest. + pub fn output_len(&self) -> usize { + self.output_len.into() + } +} + +/// SHA-1 as specified in [FIPS 180-4]. Deprecated. +/// +/// [FIPS 180-4]: http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf +pub static SHA1_FOR_LEGACY_USE_ONLY: Algorithm = Algorithm { + output_len: sha1::OUTPUT_LEN, + chaining_len: sha1::CHAINING_LEN, + block_len: sha1::BLOCK_LEN, + block_data_order: dynstate::sha1_block_data_order, + initial_state: DynState::new32([ + Wrapping(0x67452301u32), + Wrapping(0xefcdab89u32), + Wrapping(0x98badcfeu32), + Wrapping(0x10325476u32), + Wrapping(0xc3d2e1f0u32), + Wrapping(0), + Wrapping(0), + Wrapping(0), + ]), + id: AlgorithmID::SHA1, +}; + +/// SHA-256 as specified in [FIPS 180-4]. +/// +/// [FIPS 180-4]: http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf +pub static SHA256: Algorithm = Algorithm { + output_len: OutputLen::_256, + chaining_len: SHA256_OUTPUT_LEN, + block_len: SHA256_BLOCK_LEN, + block_data_order: dynstate::sha256_block_data_order, + initial_state: DynState::new32([ + Wrapping(0x6a09e667u32), + Wrapping(0xbb67ae85u32), + Wrapping(0x3c6ef372u32), + Wrapping(0xa54ff53au32), + Wrapping(0x510e527fu32), + Wrapping(0x9b05688cu32), + Wrapping(0x1f83d9abu32), + Wrapping(0x5be0cd19u32), + ]), + id: AlgorithmID::SHA256, +}; + +/// SHA-384 as specified in [FIPS 180-4]. +/// +/// [FIPS 180-4]: http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf +pub static SHA384: Algorithm = Algorithm { + output_len: OutputLen::_384, + chaining_len: SHA512_OUTPUT_LEN, + block_len: SHA512_BLOCK_LEN, + block_data_order: dynstate::sha512_block_data_order, + initial_state: DynState::new64([ + Wrapping(0xcbbb9d5dc1059ed8), + Wrapping(0x629a292a367cd507), + Wrapping(0x9159015a3070dd17), + Wrapping(0x152fecd8f70e5939), + Wrapping(0x67332667ffc00b31), + Wrapping(0x8eb44a8768581511), + Wrapping(0xdb0c2e0d64f98fa7), + Wrapping(0x47b5481dbefa4fa4), + ]), + id: AlgorithmID::SHA384, +}; + +/// SHA-512 as specified in [FIPS 180-4]. +/// +/// [FIPS 180-4]: http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf +pub static SHA512: Algorithm = Algorithm { + output_len: OutputLen::_512, + chaining_len: SHA512_OUTPUT_LEN, + block_len: SHA512_BLOCK_LEN, + block_data_order: dynstate::sha512_block_data_order, + initial_state: DynState::new64([ + Wrapping(0x6a09e667f3bcc908), + Wrapping(0xbb67ae8584caa73b), + Wrapping(0x3c6ef372fe94f82b), + Wrapping(0xa54ff53a5f1d36f1), + Wrapping(0x510e527fade682d1), + Wrapping(0x9b05688c2b3e6c1f), + Wrapping(0x1f83d9abfb41bd6b), + Wrapping(0x5be0cd19137e2179), + ]), + id: AlgorithmID::SHA512, +}; + +/// SHA-512/256 as specified in [FIPS 180-4]. +/// +/// This is *not* the same as just truncating the output of SHA-512, as +/// SHA-512/256 has its own initial state distinct from SHA-512's initial +/// state. +/// +/// [FIPS 180-4]: http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf +pub static SHA512_256: Algorithm = Algorithm { + output_len: OutputLen::_256, + chaining_len: SHA512_OUTPUT_LEN, + block_len: SHA512_BLOCK_LEN, + block_data_order: dynstate::sha512_block_data_order, + initial_state: DynState::new64([ + Wrapping(0x22312194fc2bf72c), + Wrapping(0x9f555fa3c84c64c2), + Wrapping(0x2393b86b6f53b151), + Wrapping(0x963877195940eabd), + Wrapping(0x96283ee2a88effe3), + Wrapping(0xbe5e1e2553863992), + Wrapping(0x2b0199fc2c85b8aa), + Wrapping(0x0eb72ddc81c52ca2), + ]), + id: AlgorithmID::SHA512_256, +}; + +#[derive(Clone, Copy)] +struct Output([u8; MAX_OUTPUT_LEN]); + +/// The maximum block length ([`Algorithm::block_len()`]) of all the algorithms +/// in this module. +pub const MAX_BLOCK_LEN: usize = BlockLen::MAX.into(); + +/// The maximum output length ([`Algorithm::output_len()`]) of all the +/// algorithms in this module. +pub const MAX_OUTPUT_LEN: usize = OutputLen::MAX.into(); + +/// The maximum chaining length ([`Algorithm::chaining_len()`]) of all the +/// algorithms in this module. +pub const MAX_CHAINING_LEN: usize = MAX_OUTPUT_LEN; + +#[inline] +fn format_output(input: [Wrapping; sha2::CHAINING_WORDS], f: F) -> Output +where + F: Fn(T) -> [u8; N], + T: Copy, +{ + let mut output = Output([0; MAX_OUTPUT_LEN]); + output + .0 + .chunks_mut(N) + .zip(input.iter().copied().map(|Wrapping(w)| f(w))) + .for_each(|(o, i)| { + o.copy_from_slice(&i); + }); + output +} + +/// The length of the output of SHA-1, in bytes. +pub const SHA1_OUTPUT_LEN: usize = sha1::OUTPUT_LEN.into(); + +/// The length of the output of SHA-256, in bytes. +pub const SHA256_OUTPUT_LEN: usize = OutputLen::_256.into(); + +/// The length of the output of SHA-384, in bytes. +pub const SHA384_OUTPUT_LEN: usize = OutputLen::_384.into(); + +/// The length of the output of SHA-512, in bytes. +pub const SHA512_OUTPUT_LEN: usize = OutputLen::_512.into(); + +/// The length of the output of SHA-512/256, in bytes. +pub const SHA512_256_OUTPUT_LEN: usize = OutputLen::_256.into(); + +#[derive(Clone, Copy)] +enum BlockLen { + _512 = 512 / 8, + _1024 = 1024 / 8, // MAX +} + +impl BlockLen { + const MAX: Self = Self::_1024; + #[inline(always)] + const fn into(self) -> usize { + self as usize + } + + #[inline(always)] + const fn len_len(self) -> usize { + let len_len = match self { + BlockLen::_512 => LenLen::_64, + BlockLen::_1024 => LenLen::_128, + }; + len_len as usize + } +} + +#[derive(Clone, Copy)] +enum LenLen { + _64 = 64 / 8, + _128 = 128 / 8, +} + +#[derive(Clone, Copy)] +enum OutputLen { + _160 = 160 / 8, + _256 = 256 / 8, + _384 = 384 / 8, + _512 = 512 / 8, // MAX +} + +impl OutputLen { + const MAX: Self = Self::_512; + + #[inline(always)] + const fn into(self) -> usize { + self as usize + } +} + +#[cfg(test)] +mod tests { + mod max_input { + extern crate alloc; + use super::super::super::digest; + use crate::polyfill::u64_from_usize; + use alloc::vec; + + macro_rules! max_input_tests { + ( $algorithm_name:ident ) => { + mod $algorithm_name { + use super::super::super::super::digest; + + #[test] + fn max_input_test() { + super::max_input_test(&digest::$algorithm_name); + } + + #[test] + #[should_panic] + fn too_long_input_test_block() { + super::too_long_input_test_block(&digest::$algorithm_name); + } + + #[test] + #[should_panic] + fn too_long_input_test_byte() { + super::too_long_input_test_byte(&digest::$algorithm_name); + } + } + }; + } + + fn max_input_test(alg: &'static digest::Algorithm) { + let mut context = nearly_full_context(alg); + let next_input = vec![0u8; alg.block_len() - 1]; + context.update(&next_input); + let _ = context.finish(); // no panic + } + + fn too_long_input_test_block(alg: &'static digest::Algorithm) { + let mut context = nearly_full_context(alg); + let next_input = vec![0u8; alg.block_len()]; + context.update(&next_input); + let _ = context.finish(); // should panic + } + + fn too_long_input_test_byte(alg: &'static digest::Algorithm) { + let mut context = nearly_full_context(alg); + let next_input = vec![0u8; alg.block_len() - 1]; + context.update(&next_input); + context.update(&[0]); + let _ = context.finish(); // should panic + } + + fn nearly_full_context(alg: &'static digest::Algorithm) -> digest::Context { + // All implementations currently support up to 2^64-1 bits + // of input; according to the spec, SHA-384 and SHA-512 + // support up to 2^128-1, but that's not implemented yet. + let max_bytes = 1u64 << (64 - 3); + let max_blocks = max_bytes / u64_from_usize(alg.block_len()); + let completed_bytes = (max_blocks - 1) * u64_from_usize(alg.block_len()); + digest::Context { + block: digest::BlockContext { + state: alg.initial_state.clone(), + completed_bytes, + algorithm: alg, + }, + pending: [0u8; digest::MAX_BLOCK_LEN], + num_pending: 0, + } + } + + max_input_tests!(SHA1_FOR_LEGACY_USE_ONLY); + max_input_tests!(SHA256); + max_input_tests!(SHA384); + max_input_tests!(SHA512); + } +} diff --git a/http/vendor/ring/src/digest/dynstate.rs b/http/vendor/ring/src/digest/dynstate.rs new file mode 100644 index 0000000..c74f69f --- /dev/null +++ b/http/vendor/ring/src/digest/dynstate.rs @@ -0,0 +1,98 @@ +// Copyright 2015-2019 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::{format_output, sha1, sha2, Output}; +use crate::{cpu, polyfill::slice}; +use core::mem::size_of; + +// Invariant: When constructed with `new32` (resp. `new64`), `As32` (resp. +// `As64`) is the active variant. +// Invariant: The active variant never changes after initialization. +#[derive(Clone)] +pub(super) enum DynState { + As64(sha2::State64), + As32(sha2::State32), +} + +impl DynState { + pub const fn new32(initial_state: sha2::State32) -> Self { + Self::As32(initial_state) + } + + pub const fn new64(initial_state: sha2::State64) -> Self { + Self::As64(initial_state) + } + + pub fn format_output(self) -> Output { + match self { + Self::As64(state) => { + format_output::<_, _, { size_of::() }>(state, u64::to_be_bytes) + } + Self::As32(state) => { + format_output::<_, _, { size_of::() }>(state, u32::to_be_bytes) + } + } + } +} + +pub(super) fn sha1_block_data_order<'d>( + state: &mut DynState, + data: &'d [u8], + _cpu_features: cpu::Features, +) -> (usize, &'d [u8]) { + let state = match state { + DynState::As32(state) => state, + _ => { + unreachable!(); + } + }; + + let (full_blocks, leftover) = slice::as_chunks(data); + sha1::sha1_block_data_order(state, full_blocks); + (full_blocks.as_flattened().len(), leftover) +} + +pub(super) fn sha256_block_data_order<'d>( + state: &mut DynState, + data: &'d [u8], + cpu_features: cpu::Features, +) -> (usize, &'d [u8]) { + let state = match state { + DynState::As32(state) => state, + _ => { + unreachable!(); + } + }; + + let (full_blocks, leftover) = slice::as_chunks(data); + sha2::block_data_order_32(state, full_blocks, cpu_features); + (full_blocks.len() * sha2::SHA256_BLOCK_LEN.into(), leftover) +} + +pub(super) fn sha512_block_data_order<'d>( + state: &mut DynState, + data: &'d [u8], + cpu_features: cpu::Features, +) -> (usize, &'d [u8]) { + let state = match state { + DynState::As64(state) => state, + _ => { + unreachable!(); + } + }; + + let (full_blocks, leftover) = slice::as_chunks(data); + sha2::block_data_order_64(state, full_blocks, cpu_features); + (full_blocks.len() * sha2::SHA512_BLOCK_LEN.into(), leftover) +} diff --git a/http/vendor/ring/src/digest/sha1.rs b/http/vendor/ring/src/digest/sha1.rs new file mode 100644 index 0000000..e8a4616 --- /dev/null +++ b/http/vendor/ring/src/digest/sha1.rs @@ -0,0 +1,119 @@ +// Copyright 2015-2025 Brian Smith. +// Copyright 2016 Simon Sapin. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::{ + sha2::{ + fallback::{ch, maj, Word}, + State32, + }, + BlockLen, OutputLen, +}; +use crate::polyfill::slice::{self, AsChunks}; +use core::{mem::size_of, num::Wrapping}; + +pub(super) const BLOCK_LEN: BlockLen = BlockLen::_512; +pub const CHAINING_LEN: usize = 160 / 8; +pub(super) const OUTPUT_LEN: OutputLen = OutputLen::_160; +const CHAINING_WORDS: usize = CHAINING_LEN / 4; + +type W32 = Wrapping; + +// FIPS 180-4 4.1.1 +#[inline] +fn parity(x: W32, y: W32, z: W32) -> W32 { + x ^ y ^ z +} + +type State = [W32; CHAINING_WORDS]; +const ROUNDS: usize = 80; + +pub fn sha1_block_data_order(state: &mut State32, data: AsChunks) { + // The unwrap won't fail because `CHAINING_WORDS` is smaller than the + // length. + let state: &mut State = (&mut state[..CHAINING_WORDS]).try_into().unwrap(); + // SAFETY: The caller guarantees that this is called with data pointing to `num` + // `BLOCK_LEN`-long blocks. + *state = block_data_order(*state, data) +} + +#[inline] +#[rustfmt::skip] +fn block_data_order( + mut H: [W32; CHAINING_WORDS], + M: AsChunks, +) -> [W32; CHAINING_WORDS] +{ + for M in M { + let (M, remainder): (AsChunks()}>, &[u8]) = slice::as_chunks(M); + debug_assert!(remainder.is_empty()); + + // FIPS 180-4 6.1.2 Step 1 + let mut W: [W32; ROUNDS] = [W32::ZERO; ROUNDS]; + W.iter_mut().zip(M).for_each(|(Wt, Mt)| { + *Wt = W32::from_be_bytes(*Mt); + }); + for t in 16..ROUNDS { + let wt = W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16]; + W[t] = rotl(wt, 1); + } + + // FIPS 180-4 6.1.2 Step 2 + let [a, b, c, d, e] = H; + + // FIPS 180-4 6.1.2 Step 3 with constants and functions from FIPS 180-4 {4.1.1, 4.2.1} + let (a, b, c, d, e) = step3(a, b, c, d, e, &W, 0, Wrapping(0x5a827999), ch); + let (a, b, c, d, e) = step3(a, b, c, d, e, &W, 20, Wrapping(0x6ed9eba1), parity); + let (a, b, c, d, e) = step3(a, b, c, d, e, &W, 40, Wrapping(0x8f1bbcdc), maj); + let (a, b, c, d, e) = step3(a, b, c, d, e, &W, 60, Wrapping(0xca62c1d6), parity); + + // FIPS 180-4 6.1.2 Step 4 + H[0] += a; + H[1] += b; + H[2] += c; + H[3] += d; + H[4] += e; + } + + H +} + +#[inline(always)] +fn step3( + mut a: W32, + mut b: W32, + mut c: W32, + mut d: W32, + mut e: W32, + W: &[W32; 80], + t: usize, + k: W32, + f: impl Fn(W32, W32, W32) -> W32, +) -> (W32, W32, W32, W32, W32) { + let W = &W[t..(t + 20)]; + for W_t in W.iter() { + let T = rotl(a, 5) + f(b, c, d) + e + k + W_t; + e = d; + d = c; + c = rotl(b, 30); + b = a; + a = T; + } + (a, b, c, d, e) +} + +#[inline(always)] +fn rotl(x: W32, n: u32) -> W32 { + Wrapping(x.0.rotate_left(n)) +} diff --git a/http/vendor/ring/src/digest/sha2/fallback.rs b/http/vendor/ring/src/digest/sha2/fallback.rs new file mode 100644 index 0000000..556f57d --- /dev/null +++ b/http/vendor/ring/src/digest/sha2/fallback.rs @@ -0,0 +1,372 @@ +// Copyright 2019-2025 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::CHAINING_WORDS; +use crate::polyfill::slice::{self, AsChunks}; +use core::{ + num::Wrapping, + ops::{Add, AddAssign, BitAnd, BitOr, BitXor, Not, Shr}, +}; + +#[cfg_attr( + any( + all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little"), + target_arch = "x86_64" + ), + allow(dead_code) +)] +#[inline] +pub(super) fn block_data_order( + mut H: [S; CHAINING_WORDS], + M: AsChunks, +) -> [S; CHAINING_WORDS] +where + for<'a> &'a S::InputBytes: From<&'a [u8; BYTES_LEN]>, +{ + for M in M { + let (M, remainder): (AsChunks, &[u8]) = slice::as_chunks(M); + debug_assert!(remainder.is_empty()); + + // FIPS 180-4 {6.2.2, 6.4.2} Step 1 + // + // TODO(MSRV): Use `let W: [S::from(0); S::ROUNDS]` instead; depends on + // https://github.com/rust-lang/rust/issues/43408. + let mut W = S::zero_w(); + let W = W.as_mut(); + W.iter_mut().zip(M).for_each(|(Wt, Mt)| { + let Mt: &S::InputBytes = Mt.into(); + *Wt = S::from_be_bytes(*Mt); + }); + for t in 16..S::ROUNDS { + W[t] = sigma_1(W[t - 2]) + W[t - 7] + sigma_0(W[t - 15]) + W[t - 16] + } + + // FIPS 180-4 {6.2.2, 6.4.2} Step 2 + let [mut a, mut b, mut c, mut d, mut e, mut f, mut g, mut h] = H; + + // FIPS 180-4 {6.2.2, 6.4.2} Step 3 + for (Kt, Wt) in S::K.as_ref().iter().zip(W.iter()) { + let T1 = h + SIGMA_1(e) + ch(e, f, g) + *Kt + *Wt; + let T2 = SIGMA_0(a) + maj(a, b, c); + h = g; + g = f; + f = e; + e = d + T1; + d = c; + c = b; + b = a; + a = T1 + T2; + } + + // FIPS 180-4 {6.2.2, 6.4.2} Step 4 + H[0] += a; + H[1] += b; + H[2] += c; + H[3] += d; + H[4] += e; + H[5] += f; + H[6] += g; + H[7] += h; + } + + H +} + +// FIPS 180-4 {4.1.1, 4.1.2, 4.1.3} +#[inline(always)] +pub(in super::super) fn ch(x: W, y: W, z: W) -> W { + (x & y) | (!x & z) +} + +// FIPS 180-4 {4.1.1, 4.1.2, 4.1.3} +#[inline(always)] +pub(in super::super) fn maj(x: W, y: W, z: W) -> W { + (x & y) | (x & z) | (y & z) +} + +// FIPS 180-4 {4.1.2, 4.1.3} +#[inline(always)] +fn SIGMA_0(x: S) -> S { + x.rotr(S::BIG_SIGMA_0.0) ^ x.rotr(S::BIG_SIGMA_0.1) ^ x.rotr(S::BIG_SIGMA_0.2) +} + +// FIPS 180-4 {4.1.2, 4.1.3} +#[inline(always)] +fn SIGMA_1(x: S) -> S { + x.rotr(S::BIG_SIGMA_1.0) ^ x.rotr(S::BIG_SIGMA_1.1) ^ x.rotr(S::BIG_SIGMA_1.2) +} + +// FIPS 180-4 {4.1.2, 4.1.3} +#[inline(always)] +fn sigma_0(x: S) -> S { + x.rotr(S::SMALL_SIGMA_0.0) ^ x.rotr(S::SMALL_SIGMA_0.1) ^ (x >> S::SMALL_SIGMA_0.2) +} + +// FIPS 180-4 {4.1.2, 4.1.3} +#[inline(always)] +fn sigma_1(x: S) -> S { + x.rotr(S::SMALL_SIGMA_1.0) ^ x.rotr(S::SMALL_SIGMA_1.1) ^ (x >> S::SMALL_SIGMA_1.2) +} + +// Commonality between SHA-1 and SHA-2 words. +pub(in super::super) trait Word: + 'static + + Sized + + Copy + + Add + + AddAssign + + BitAnd + + BitOr + + Not +{ + const ZERO: Self; + + type InputBytes: Copy; + + fn from_be_bytes(input: Self::InputBytes) -> Self; + + fn rotr(self, count: u32) -> Self; +} + +/// A SHA-2 input word. +pub(super) trait Sha2: Word + BitXor + Shr { + const BIG_SIGMA_0: (u32, u32, u32); + const BIG_SIGMA_1: (u32, u32, u32); + const SMALL_SIGMA_0: (u32, u32, usize); + const SMALL_SIGMA_1: (u32, u32, usize); + + const ROUNDS: usize; + + type W: AsRef<[Self]> + AsMut<[Self]>; + fn zero_w() -> Self::W; + + const K: &'static Self::W; +} + +impl Word for Wrapping { + const ZERO: Self = Self(0); + type InputBytes = [u8; 4]; + + #[inline(always)] + fn from_be_bytes(input: Self::InputBytes) -> Self { + Self(u32::from_be_bytes(input)) + } + + #[inline(always)] + fn rotr(self, count: u32) -> Self { + Self(self.0.rotate_right(count)) + } +} + +// SHA-256 +impl Sha2 for Wrapping { + // FIPS 180-4 4.1.2 + const BIG_SIGMA_0: (u32, u32, u32) = (2, 13, 22); + const BIG_SIGMA_1: (u32, u32, u32) = (6, 11, 25); + const SMALL_SIGMA_0: (u32, u32, usize) = (7, 18, 3); + const SMALL_SIGMA_1: (u32, u32, usize) = (17, 19, 10); + + // FIPS 180-4 {6.2.2} Step 1 + const ROUNDS: usize = 64; + + type W = [Self; Self::ROUNDS]; + fn zero_w() -> Self::W { + [Self::ZERO; Self::ROUNDS] + } + + // FIPS 180-4 4.2.2 + const K: &'static Self::W = &[ + Self(0x428a2f98), + Self(0x71374491), + Self(0xb5c0fbcf), + Self(0xe9b5dba5), + Self(0x3956c25b), + Self(0x59f111f1), + Self(0x923f82a4), + Self(0xab1c5ed5), + Self(0xd807aa98), + Self(0x12835b01), + Self(0x243185be), + Self(0x550c7dc3), + Self(0x72be5d74), + Self(0x80deb1fe), + Self(0x9bdc06a7), + Self(0xc19bf174), + Self(0xe49b69c1), + Self(0xefbe4786), + Self(0x0fc19dc6), + Self(0x240ca1cc), + Self(0x2de92c6f), + Self(0x4a7484aa), + Self(0x5cb0a9dc), + Self(0x76f988da), + Self(0x983e5152), + Self(0xa831c66d), + Self(0xb00327c8), + Self(0xbf597fc7), + Self(0xc6e00bf3), + Self(0xd5a79147), + Self(0x06ca6351), + Self(0x14292967), + Self(0x27b70a85), + Self(0x2e1b2138), + Self(0x4d2c6dfc), + Self(0x53380d13), + Self(0x650a7354), + Self(0x766a0abb), + Self(0x81c2c92e), + Self(0x92722c85), + Self(0xa2bfe8a1), + Self(0xa81a664b), + Self(0xc24b8b70), + Self(0xc76c51a3), + Self(0xd192e819), + Self(0xd6990624), + Self(0xf40e3585), + Self(0x106aa070), + Self(0x19a4c116), + Self(0x1e376c08), + Self(0x2748774c), + Self(0x34b0bcb5), + Self(0x391c0cb3), + Self(0x4ed8aa4a), + Self(0x5b9cca4f), + Self(0x682e6ff3), + Self(0x748f82ee), + Self(0x78a5636f), + Self(0x84c87814), + Self(0x8cc70208), + Self(0x90befffa), + Self(0xa4506ceb), + Self(0xbef9a3f7), + Self(0xc67178f2), + ]; +} + +impl Word for Wrapping { + const ZERO: Self = Self(0); + type InputBytes = [u8; 8]; + + #[inline(always)] + fn from_be_bytes(input: Self::InputBytes) -> Self { + Self(u64::from_be_bytes(input)) + } + + #[inline(always)] + fn rotr(self, count: u32) -> Self { + Self(self.0.rotate_right(count)) + } +} + +// SHA-384 and SHA-512 +impl Sha2 for Wrapping { + // FIPS 180-4 4.1.3 + const BIG_SIGMA_0: (u32, u32, u32) = (28, 34, 39); + const BIG_SIGMA_1: (u32, u32, u32) = (14, 18, 41); + const SMALL_SIGMA_0: (u32, u32, usize) = (1, 8, 7); + const SMALL_SIGMA_1: (u32, u32, usize) = (19, 61, 6); + + // FIPS 180-4 {6.4.2} Step 1 + const ROUNDS: usize = 80; + + type W = [Self; Self::ROUNDS]; + fn zero_w() -> Self::W { + [Self::ZERO; Self::ROUNDS] + } + + // FIPS 180-4 4.2.3 + const K: &'static Self::W = &[ + Self(0x428a2f98d728ae22), + Self(0x7137449123ef65cd), + Self(0xb5c0fbcfec4d3b2f), + Self(0xe9b5dba58189dbbc), + Self(0x3956c25bf348b538), + Self(0x59f111f1b605d019), + Self(0x923f82a4af194f9b), + Self(0xab1c5ed5da6d8118), + Self(0xd807aa98a3030242), + Self(0x12835b0145706fbe), + Self(0x243185be4ee4b28c), + Self(0x550c7dc3d5ffb4e2), + Self(0x72be5d74f27b896f), + Self(0x80deb1fe3b1696b1), + Self(0x9bdc06a725c71235), + Self(0xc19bf174cf692694), + Self(0xe49b69c19ef14ad2), + Self(0xefbe4786384f25e3), + Self(0x0fc19dc68b8cd5b5), + Self(0x240ca1cc77ac9c65), + Self(0x2de92c6f592b0275), + Self(0x4a7484aa6ea6e483), + Self(0x5cb0a9dcbd41fbd4), + Self(0x76f988da831153b5), + Self(0x983e5152ee66dfab), + Self(0xa831c66d2db43210), + Self(0xb00327c898fb213f), + Self(0xbf597fc7beef0ee4), + Self(0xc6e00bf33da88fc2), + Self(0xd5a79147930aa725), + Self(0x06ca6351e003826f), + Self(0x142929670a0e6e70), + Self(0x27b70a8546d22ffc), + Self(0x2e1b21385c26c926), + Self(0x4d2c6dfc5ac42aed), + Self(0x53380d139d95b3df), + Self(0x650a73548baf63de), + Self(0x766a0abb3c77b2a8), + Self(0x81c2c92e47edaee6), + Self(0x92722c851482353b), + Self(0xa2bfe8a14cf10364), + Self(0xa81a664bbc423001), + Self(0xc24b8b70d0f89791), + Self(0xc76c51a30654be30), + Self(0xd192e819d6ef5218), + Self(0xd69906245565a910), + Self(0xf40e35855771202a), + Self(0x106aa07032bbd1b8), + Self(0x19a4c116b8d2d0c8), + Self(0x1e376c085141ab53), + Self(0x2748774cdf8eeb99), + Self(0x34b0bcb5e19b48a8), + Self(0x391c0cb3c5c95a63), + Self(0x4ed8aa4ae3418acb), + Self(0x5b9cca4f7763e373), + Self(0x682e6ff3d6b2b8a3), + Self(0x748f82ee5defb2fc), + Self(0x78a5636f43172f60), + Self(0x84c87814a1f0ab72), + Self(0x8cc702081a6439ec), + Self(0x90befffa23631e28), + Self(0xa4506cebde82bde9), + Self(0xbef9a3f7b2c67915), + Self(0xc67178f2e372532b), + Self(0xca273eceea26619c), + Self(0xd186b8c721c0c207), + Self(0xeada7dd6cde0eb1e), + Self(0xf57d4f7fee6ed178), + Self(0x06f067aa72176fba), + Self(0x0a637dc5a2c898a6), + Self(0x113f9804bef90dae), + Self(0x1b710b35131c471b), + Self(0x28db77f523047d84), + Self(0x32caab7b40c72493), + Self(0x3c9ebe0a15c9bebc), + Self(0x431d67c49c100d4c), + Self(0x4cc5d4becb3e42b6), + Self(0x597f299cfc657e2a), + Self(0x5fcb6fab3ad6faec), + Self(0x6c44198c4a475817), + ]; +} diff --git a/http/vendor/ring/src/digest/sha2/ffi.rs b/http/vendor/ring/src/digest/sha2/ffi.rs new file mode 100644 index 0000000..3ee8044 --- /dev/null +++ b/http/vendor/ring/src/digest/sha2/ffi.rs @@ -0,0 +1,71 @@ +// Copyright 2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::CHAINING_WORDS; +use crate::polyfill::slice::AsChunks; +use core::num::{NonZeroUsize, Wrapping}; + +/// `unsafe { T => f }` means it is safe to call `f` iff we can construct +/// a value of type `T`. +macro_rules! sha2_ffi { + ( $U:ty, $BLOCK_LEN:expr, unsafe { $Cpu:ty => $f:ident }, + $state:expr, $data:expr, $cpu:expr $(,)? ) => {{ + prefixed_extern! { + fn $f( + state: *mut [core::num::Wrapping<$U>; crate::digest::sha2::CHAINING_WORDS], + data: *const [u8; $BLOCK_LEN], + num: crate::c::NonZero_size_t); + } + // SAFETY: The user asserts that $f has the signature above and is safe + // to call if additionally we have a value of type `$Cpu`, which we do. + unsafe { + crate::digest::sha2::ffi::sha2_ffi::<$U, $Cpu, { $BLOCK_LEN }>($state, $data, $cpu, $f) + } + }}; +} + +macro_rules! sha2_32_ffi { + ( unsafe { $Cpu:ty => $f:ident }, $state:expr, $data:expr, $cpu:expr $(,)? ) => { + sha2_ffi!(u32, crate::digest::sha2::SHA256_BLOCK_LEN.into(), + unsafe { $Cpu => $f }, $state, $data, $cpu) + } +} + +macro_rules! sha2_64_ffi { + ( unsafe { $Cpu:ty => $f:ident }, $state:expr, $data:expr, $cpu:expr $(,)? ) => { + sha2_ffi!(u64, SHA512_BLOCK_LEN.into(), unsafe { $Cpu => $f }, $state, $data, $cpu) + } +} + +pub(super) unsafe fn sha2_ffi( + state: &mut [Wrapping; CHAINING_WORDS], + data: AsChunks, + cpu: Cpu, + f: unsafe extern "C" fn( + *mut [Wrapping; CHAINING_WORDS], + *const [u8; BLOCK_LEN], + crate::c::NonZero_size_t, + ), +) { + if let Some(blocks) = NonZeroUsize::new(data.len()) { + let data = data.as_ptr(); + let _: Cpu = cpu; + // SAFETY: + // * `blocks` is non-zero. + // * `data` is non-NULL and points to `blocks` blocks. + // * The caller asserted that `f` meets this contract if we have + // an instance of `Cpu`. + unsafe { f(state, data, blocks) } + } +} diff --git a/http/vendor/ring/src/digest/sha2/mod.rs b/http/vendor/ring/src/digest/sha2/mod.rs new file mode 100644 index 0000000..78ca27b --- /dev/null +++ b/http/vendor/ring/src/digest/sha2/mod.rs @@ -0,0 +1,34 @@ +// Copyright 2019-2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::BlockLen; + +pub(super) use self::{ + sha2_32::{block_data_order_32, State32, SHA256_BLOCK_LEN}, + sha2_64::{block_data_order_64, State64, SHA512_BLOCK_LEN}, +}; + +pub(super) const CHAINING_WORDS: usize = 8; + +#[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little"), + target_arch = "x86_64" +))] +#[macro_use] +mod ffi; + +pub(super) mod fallback; +mod sha2_32; +mod sha2_64; diff --git a/http/vendor/ring/src/digest/sha2/sha2_32.rs b/http/vendor/ring/src/digest/sha2/sha2_32.rs new file mode 100644 index 0000000..4f762d1 --- /dev/null +++ b/http/vendor/ring/src/digest/sha2/sha2_32.rs @@ -0,0 +1,63 @@ +// Copyright 2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::{BlockLen, CHAINING_WORDS}; +use crate::{cpu, polyfill::slice::AsChunks}; +use cfg_if::cfg_if; +use core::num::Wrapping; + +pub(in super::super) const SHA256_BLOCK_LEN: BlockLen = BlockLen::_512; + +pub type State32 = [Wrapping; CHAINING_WORDS]; + +pub(crate) fn block_data_order_32( + state: &mut State32, + data: AsChunks, + cpu: cpu::Features, +) { + cfg_if! { + if #[cfg(all(target_arch = "aarch64", target_endian = "little"))] { + use cpu::{GetFeature as _, arm::Sha256}; + if let Some(cpu) = cpu.get_feature() { + sha2_32_ffi!(unsafe { Sha256 => sha256_block_data_order_hw }, state, data, cpu) + } else { + sha2_32_ffi!(unsafe { () => sha256_block_data_order_nohw }, state, data, ()) + } + } else if #[cfg(all(target_arch = "arm", target_endian = "little"))] { + use cpu::{GetFeature as _, arm::Neon}; + if let Some(cpu) = cpu.get_feature() { + sha2_32_ffi!(unsafe { Neon => sha256_block_data_order_neon }, state, data, cpu) + } else { + sha2_32_ffi!(unsafe { () => sha256_block_data_order_nohw }, state, data, ()) + } + } else if #[cfg(target_arch = "x86_64")] { + use cpu::{GetFeature as _, intel::{Avx, IntelCpu, Sha, Ssse3 }}; + let cpu = cpu.values(); + if let Some(cpu) = cpu.get_feature() { + sha2_32_ffi!(unsafe { (Sha, Ssse3) => sha256_block_data_order_hw }, state, data, cpu) + } else if let Some(cpu) = cpu.get_feature() { + // Pre-Zen AMD CPUs had slow SHLD/SHRD; Zen added the SHA + // extension; see the discussion in upstream's sha1-586.pl. + sha2_32_ffi!(unsafe { (Avx, IntelCpu) => sha256_block_data_order_avx }, state, data, cpu) + } else if let Some(cpu) = cpu.get_feature() { + sha2_32_ffi!(unsafe { Ssse3 => sha256_block_data_order_ssse3 }, state, data, cpu) + } else { + sha2_32_ffi!(unsafe { () => sha256_block_data_order_nohw }, state, data, ()) + } + } else { + let _ = cpu; // Unneeded. + *state = super::fallback::block_data_order(*state, data) + } + } +} diff --git a/http/vendor/ring/src/digest/sha2/sha2_64.rs b/http/vendor/ring/src/digest/sha2/sha2_64.rs new file mode 100644 index 0000000..63c254e --- /dev/null +++ b/http/vendor/ring/src/digest/sha2/sha2_64.rs @@ -0,0 +1,60 @@ +// Copyright 2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::{BlockLen, CHAINING_WORDS}; +use crate::{cpu, polyfill::slice::AsChunks}; +use cfg_if::cfg_if; +use core::num::Wrapping; + +pub(in super::super) const SHA512_BLOCK_LEN: BlockLen = BlockLen::_1024; + +pub type State64 = [Wrapping; CHAINING_WORDS]; + +pub(crate) fn block_data_order_64( + state: &mut State64, + data: AsChunks, + cpu: cpu::Features, +) { + cfg_if! { + if #[cfg(all(target_arch = "aarch64", target_endian = "little"))] { + use cpu::{GetFeature as _, arm::Sha512}; + if let Some(cpu) = cpu.get_feature() { + sha2_64_ffi!(unsafe { Sha512 => sha512_block_data_order_hw }, state, data, cpu) + } else { + sha2_64_ffi!(unsafe { () => sha512_block_data_order_nohw }, state, data, ()) + } + } else if #[cfg(all(target_arch = "arm", target_endian = "little"))] { + use cpu::{GetFeature as _, arm::Neon}; + if let Some(cpu) = cpu.get_feature() { + sha2_64_ffi!(unsafe { Neon => sha512_block_data_order_neon }, state, data, cpu) + } else { + sha2_64_ffi!(unsafe { () => sha512_block_data_order_nohw }, state, data, ()) + } + } else if #[cfg(target_arch = "x86_64")] { + use cpu::{GetFeature as _, intel::{Avx, IntelCpu}}; + if let Some(cpu) = cpu.get_feature() { + // Pre-Zen AMD CPUs had microcoded SHLD/SHRD which makes the + // AVX version slow. We're also unsure of the side channel + // ramifications of those microcoded instructions. + sha2_64_ffi!(unsafe { (Avx, IntelCpu) => sha512_block_data_order_avx }, + state, data, cpu); + } else { + sha2_64_ffi!(unsafe { () => sha512_block_data_order_nohw }, state, data, ()) + } + } else { + let _ = cpu; // Unneeded. + *state = super::fallback::block_data_order(*state, data) + } + } +} diff --git a/http/vendor/ring/src/ec.rs b/http/vendor/ring/src/ec.rs new file mode 100644 index 0000000..33e7fc2 --- /dev/null +++ b/http/vendor/ring/src/ec.rs @@ -0,0 +1,68 @@ +// Copyright 2015-2017 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use crate::{cpu, error, rand}; + +pub use self::keys::{KeyPair, PublicKey, Seed}; + +pub struct Curve { + pub public_key_len: usize, + pub elem_scalar_seed_len: usize, + + pub id: CurveID, + + // Precondition: `bytes` is the correct length. + check_private_key_bytes: fn(bytes: &[u8], cpu: cpu::Features) -> Result<(), error::Unspecified>, + + generate_private_key: fn( + rng: &dyn rand::SecureRandom, + &mut [u8], + cpu: cpu::Features, + ) -> Result<(), error::Unspecified>, + + public_from_private: fn( + public_out: &mut [u8], + private_key: &Seed, + cpu: cpu::Features, + ) -> Result<(), error::Unspecified>, +} + +derive_debug_via_id!(Curve); + +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum CurveID { + Curve25519, + P256, + P384, +} + +const ELEM_MAX_BITS: usize = 384; +pub const ELEM_MAX_BYTES: usize = (ELEM_MAX_BITS + 7) / 8; + +pub const SCALAR_MAX_BYTES: usize = ELEM_MAX_BYTES; +const SEED_MAX_BYTES: usize = ELEM_MAX_BYTES; + +/// The maximum length of a PKCS#8 documents generated by *ring* for ECC keys. +/// +/// This is NOT the maximum length of a PKCS#8 document that can be consumed by +/// `pkcs8::unwrap_key()`. +/// +/// `40` is the length of the P-384 template. It is actually one byte shorter +/// than the P-256 template, but the private key and the public key are much +/// longer. +pub const PKCS8_DOCUMENT_MAX_LEN: usize = 40 + SCALAR_MAX_BYTES + keys::PUBLIC_KEY_MAX_LEN; + +pub mod curve25519; +mod keys; +pub mod suite_b; diff --git a/http/vendor/ring/src/ec/curve25519.rs b/http/vendor/ring/src/ec/curve25519.rs new file mode 100644 index 0000000..4f4596d --- /dev/null +++ b/http/vendor/ring/src/ec/curve25519.rs @@ -0,0 +1,22 @@ +// Copyright 2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! Elliptic curve operations and schemes using Curve25519. + +pub mod ed25519; + +pub mod x25519; + +mod ops; +mod scalar; diff --git a/http/vendor/ring/src/ec/curve25519/ed25519.rs b/http/vendor/ring/src/ec/curve25519/ed25519.rs new file mode 100644 index 0000000..fe1a9ff --- /dev/null +++ b/http/vendor/ring/src/ec/curve25519/ed25519.rs @@ -0,0 +1,32 @@ +// Copyright 2015-2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! EdDSA Signatures. + +use super::ops::ELEM_LEN; +use crate::digest; + +pub mod signing; +pub mod verification; + +/// The length of an Ed25519 public key. +pub const ED25519_PUBLIC_KEY_LEN: usize = ELEM_LEN; + +pub fn eddsa_digest(signature_r: &[u8], public_key: &[u8], msg: &[u8]) -> digest::Digest { + let mut ctx = digest::Context::new(&digest::SHA512); + ctx.update(signature_r); + ctx.update(public_key); + ctx.update(msg); + ctx.finish() +} diff --git a/http/vendor/ring/src/ec/curve25519/ed25519/ed25519_pkcs8_v2_template.der b/http/vendor/ring/src/ec/curve25519/ed25519/ed25519_pkcs8_v2_template.der new file mode 100644 index 0000000..7230086 Binary files /dev/null and b/http/vendor/ring/src/ec/curve25519/ed25519/ed25519_pkcs8_v2_template.der differ diff --git a/http/vendor/ring/src/ec/curve25519/ed25519/signing.rs b/http/vendor/ring/src/ec/curve25519/ed25519/signing.rs new file mode 100644 index 0000000..d6d249d --- /dev/null +++ b/http/vendor/ring/src/ec/curve25519/ed25519/signing.rs @@ -0,0 +1,275 @@ +// Copyright 2015-2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! EdDSA Signatures. + +use super::{super::ops::*, eddsa_digest, ED25519_PUBLIC_KEY_LEN}; +use crate::{ + cpu, digest, error, + io::der, + pkcs8, rand, + signature::{self, KeyPair as SigningKeyPair}, +}; + +/// An Ed25519 key pair, for signing. +pub struct Ed25519KeyPair { + // RFC 8032 Section 5.1.6 calls this *s*. + private_scalar: Scalar, + + // RFC 8032 Section 5.1.6 calls this *prefix*. + private_prefix: Prefix, + + // RFC 8032 Section 5.1.5 calls this *A*. + public_key: PublicKey, +} + +derive_debug_via_field!(Ed25519KeyPair, stringify!(Ed25519KeyPair), public_key); + +impl Ed25519KeyPair { + /// Generates a new key pair and returns the key pair serialized as a + /// PKCS#8 document. + /// + /// The PKCS#8 document will be a v2 `OneAsymmetricKey` with the public key, + /// as described in [RFC 5958 Section 2]; see [RFC 8410 Section 10.3] for an + /// example. + /// + /// [RFC 5958 Section 2]: https://tools.ietf.org/html/rfc5958#section-2 + /// [RFC 8410 Section 10.3]: https://tools.ietf.org/html/rfc8410#section-10.3 + pub fn generate_pkcs8( + rng: &dyn rand::SecureRandom, + ) -> Result { + let cpu_features = cpu::features(); + let seed: [u8; SEED_LEN] = rand::generate(rng)?.expose(); + let key_pair = Self::from_seed_(&seed, cpu_features); + Ok(pkcs8::wrap_key( + &PKCS8_TEMPLATE, + &seed[..], + key_pair.public_key().as_ref(), + )) + } + + /// Constructs an Ed25519 key pair by parsing an unencrypted PKCS#8 v2 + /// Ed25519 private key. + /// + /// `openssl genpkey -algorithm ED25519` generates PKCS# v1 keys, which + /// require the use of `Ed25519KeyPair::from_pkcs8_maybe_unchecked()` + /// instead of `Ed25519KeyPair::from_pkcs8()`. + /// + /// The input must be in PKCS#8 v2 format, and in particular it must contain + /// the public key in addition to the private key. `from_pkcs8()` will + /// verify that the public key and the private key are consistent with each + /// other. + /// + /// Some early implementations of PKCS#8 v2, including earlier versions of + /// *ring* and other implementations, wrapped the public key in the wrong + /// ASN.1 tags. Both that incorrect form and the standardized form are + /// accepted. + /// + /// If you need to parse PKCS#8 v1 files (without the public key) then use + /// `Ed25519KeyPair::from_pkcs8_maybe_unchecked()` instead. + pub fn from_pkcs8(pkcs8: &[u8]) -> Result { + let version = pkcs8::Version::V2Only(pkcs8::PublicKeyOptions { + accept_legacy_ed25519_public_key_tag: true, + }); + let (seed, public_key) = unwrap_pkcs8(version, untrusted::Input::from(pkcs8))?; + Self::from_seed_and_public_key( + seed.as_slice_less_safe(), + public_key.unwrap().as_slice_less_safe(), + ) + } + + /// Constructs an Ed25519 key pair by parsing an unencrypted PKCS#8 v1 or v2 + /// Ed25519 private key. + /// + /// `openssl genpkey -algorithm ED25519` generates PKCS# v1 keys. + /// + /// It is recommended to use `Ed25519KeyPair::from_pkcs8()`, which accepts + /// only PKCS#8 v2 files that contain the public key. + /// `from_pkcs8_maybe_unchecked()` parses PKCS#2 files exactly like + /// `from_pkcs8()`. It also accepts v1 files. PKCS#8 v1 files do not contain + /// the public key, so when a v1 file is parsed the public key will be + /// computed from the private key, and there will be no consistency check + /// between the public key and the private key. + /// + /// Some early implementations of PKCS#8 v2, including earlier versions of + /// *ring* and other implementations, wrapped the public key in the wrong + /// ASN.1 tags. Both that incorrect form and the standardized form are + /// accepted. + /// + /// PKCS#8 v2 files are parsed exactly like `Ed25519KeyPair::from_pkcs8()`. + pub fn from_pkcs8_maybe_unchecked(pkcs8: &[u8]) -> Result { + let version = pkcs8::Version::V1OrV2(pkcs8::PublicKeyOptions { + accept_legacy_ed25519_public_key_tag: true, + }); + let (seed, public_key) = unwrap_pkcs8(version, untrusted::Input::from(pkcs8))?; + if let Some(public_key) = public_key { + Self::from_seed_and_public_key( + seed.as_slice_less_safe(), + public_key.as_slice_less_safe(), + ) + } else { + Self::from_seed_unchecked(seed.as_slice_less_safe()) + } + } + + /// Constructs an Ed25519 key pair from the private key seed `seed` and its + /// public key `public_key`. + /// + /// It is recommended to use `Ed25519KeyPair::from_pkcs8()` instead. + /// + /// The private and public keys will be verified to be consistent with each + /// other. This helps avoid misuse of the key (e.g. accidentally swapping + /// the private key and public key, or using the wrong private key for the + /// public key). This also detects any corruption of the public or private + /// key. + pub fn from_seed_and_public_key( + seed: &[u8], + public_key: &[u8], + ) -> Result { + let pair = Self::from_seed_unchecked(seed)?; + + // This implicitly verifies that `public_key` is the right length. + // XXX: This rejects ~18 keys when they are partially reduced, though + // those keys are virtually impossible to find. + if public_key != pair.public_key.as_ref() { + let err = if public_key.len() != pair.public_key.as_ref().len() { + error::KeyRejected::invalid_encoding() + } else { + error::KeyRejected::inconsistent_components() + }; + return Err(err); + } + + Ok(pair) + } + + /// Constructs a Ed25519 key pair from the private key seed `seed`. + /// + /// It is recommended to use `Ed25519KeyPair::from_pkcs8()` instead. When + /// that is not practical, it is recommended to use + /// `Ed25519KeyPair::from_seed_and_public_key()` instead. + /// + /// Since the public key is not given, the public key will be computed from + /// the private key. It is not possible to detect misuse or corruption of + /// the private key since the public key isn't given as input. + pub fn from_seed_unchecked(seed: &[u8]) -> Result { + let seed = seed + .try_into() + .map_err(|_| error::KeyRejected::invalid_encoding())?; + Ok(Self::from_seed_(seed, cpu::features())) + } + + fn from_seed_(seed: &Seed, cpu_features: cpu::Features) -> Self { + let h = digest::digest(&digest::SHA512, seed); + let (private_scalar, private_prefix) = h.as_ref().split_at(SCALAR_LEN); + + let private_scalar = + MaskedScalar::from_bytes_masked(private_scalar.try_into().unwrap()).into(); + + let a = ExtPoint::from_scalarmult_base(&private_scalar, cpu_features); + + Self { + private_scalar, + private_prefix: private_prefix.try_into().unwrap(), + public_key: PublicKey(a.into_encoded_point(cpu_features)), + } + } + + /// Returns the signature of the message `msg`. + pub fn sign(&self, msg: &[u8]) -> signature::Signature { + let cpu_features = cpu::features(); + signature::Signature::new(|signature_bytes| { + prefixed_extern! { + fn x25519_sc_muladd( + s: &mut [u8; SCALAR_LEN], + a: &Scalar, + b: &Scalar, + c: &Scalar, + ); + } + + let (signature_bytes, _unused) = signature_bytes.split_at_mut(ELEM_LEN + SCALAR_LEN); + let (signature_r, signature_s) = signature_bytes.split_at_mut(ELEM_LEN); + let nonce = { + let mut ctx = digest::Context::new(&digest::SHA512); + ctx.update(&self.private_prefix); + ctx.update(msg); + ctx.finish() + }; + let nonce = Scalar::from_sha512_digest_reduced(nonce); + + let r = ExtPoint::from_scalarmult_base(&nonce, cpu_features); + signature_r.copy_from_slice(&r.into_encoded_point(cpu_features)); + let hram_digest = eddsa_digest(signature_r, self.public_key.as_ref(), msg); + let hram = Scalar::from_sha512_digest_reduced(hram_digest); + unsafe { + x25519_sc_muladd( + signature_s.try_into().unwrap(), + &hram, + &self.private_scalar, + &nonce, + ); + } + + SIGNATURE_LEN + }) + } +} + +impl signature::KeyPair for Ed25519KeyPair { + type PublicKey = PublicKey; + + fn public_key(&self) -> &Self::PublicKey { + &self.public_key + } +} + +#[derive(Clone, Copy)] +pub struct PublicKey([u8; ED25519_PUBLIC_KEY_LEN]); + +impl AsRef<[u8]> for PublicKey { + fn as_ref(&self) -> &[u8] { + self.0.as_ref() + } +} + +derive_debug_self_as_ref_hex_bytes!(PublicKey); + +fn unwrap_pkcs8( + version: pkcs8::Version, + input: untrusted::Input, +) -> Result<(untrusted::Input, Option), error::KeyRejected> { + let (private_key, public_key) = pkcs8::unwrap_key(&PKCS8_TEMPLATE, version, input)?; + let private_key = private_key + .read_all(error::Unspecified, |input| { + der::expect_tag_and_get_value(input, der::Tag::OctetString) + }) + .map_err(|error::Unspecified| error::KeyRejected::invalid_encoding())?; + Ok((private_key, public_key)) +} + +type Prefix = [u8; PREFIX_LEN]; +const PREFIX_LEN: usize = digest::SHA512_OUTPUT_LEN - SCALAR_LEN; + +const SIGNATURE_LEN: usize = ELEM_LEN + SCALAR_LEN; + +type Seed = [u8; SEED_LEN]; +const SEED_LEN: usize = 32; + +static PKCS8_TEMPLATE: pkcs8::Template = pkcs8::Template { + bytes: include_bytes!("ed25519_pkcs8_v2_template.der"), + alg_id_range: core::ops::Range { start: 7, end: 12 }, + curve_id_index: 0, + private_key_index: 0x10, +}; diff --git a/http/vendor/ring/src/ec/curve25519/ed25519/verification.rs b/http/vendor/ring/src/ec/curve25519/ed25519/verification.rs new file mode 100644 index 0000000..8a81f42 --- /dev/null +++ b/http/vendor/ring/src/ec/curve25519/ed25519/verification.rs @@ -0,0 +1,85 @@ +// Copyright 2015-2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! EdDSA Signatures. + +use super::{super::ops::*, eddsa_digest}; +use crate::{cpu, error, sealed, signature}; + +/// Parameters for EdDSA signing and verification. +pub struct EdDSAParameters; + +impl core::fmt::Debug for EdDSAParameters { + fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> { + write!(f, "ring::signature::ED25519") + } +} + +/// Verification of [Ed25519] signatures. +/// +/// Ed25519 uses SHA-512 as the digest algorithm. +/// +/// [Ed25519]: https://ed25519.cr.yp.to/ +pub static ED25519: EdDSAParameters = EdDSAParameters {}; + +impl signature::VerificationAlgorithm for EdDSAParameters { + fn verify( + &self, + public_key: untrusted::Input, + msg: untrusted::Input, + signature: untrusted::Input, + ) -> Result<(), error::Unspecified> { + let cpu_features = cpu::features(); + + let public_key: &[u8; ELEM_LEN] = public_key.as_slice_less_safe().try_into()?; + let (signature_r, signature_s) = signature.read_all(error::Unspecified, |input| { + let signature_r: &[u8; ELEM_LEN] = input + .read_bytes(ELEM_LEN)? + .as_slice_less_safe() + .try_into()?; + let signature_s: &[u8; SCALAR_LEN] = input + .read_bytes(SCALAR_LEN)? + .as_slice_less_safe() + .try_into()?; + Ok((signature_r, signature_s)) + })?; + + let signature_s = Scalar::from_bytes_checked(*signature_s)?; + + let mut a = ExtPoint::from_encoded_point_vartime(public_key)?; + a.invert_vartime(); + + let h_digest = eddsa_digest(signature_r, public_key, msg.as_slice_less_safe()); + let h = Scalar::from_sha512_digest_reduced(h_digest); + + let mut r = Point::new_at_infinity(); + unsafe { x25519_ge_double_scalarmult_vartime(&mut r, &h, &a, &signature_s) }; + let r_check = r.into_encoded_point(cpu_features); + if *signature_r != r_check { + return Err(error::Unspecified); + } + Ok(()) + } +} + +impl sealed::Sealed for EdDSAParameters {} + +prefixed_extern! { + fn x25519_ge_double_scalarmult_vartime( + r: &mut Point, + a_coeff: &Scalar, + a: &ExtPoint, + b_coeff: &Scalar, + ); +} diff --git a/http/vendor/ring/src/ec/curve25519/ops.rs b/http/vendor/ring/src/ec/curve25519/ops.rs new file mode 100644 index 0000000..b34d68c --- /dev/null +++ b/http/vendor/ring/src/ec/curve25519/ops.rs @@ -0,0 +1,180 @@ +// Copyright 2015-2017 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! Elliptic curve operations on the birationally equivalent curves Curve25519 +//! and Edwards25519. + +pub use super::scalar::{MaskedScalar, Scalar, SCALAR_LEN}; +use crate::{ + bssl, cpu, error, + limb::{Limb, LIMB_BITS}, +}; +use core::{ffi::c_int, marker::PhantomData}; + +// Elem` is `fe` in curve25519/internal.h. +// Elem is `fe_loose` in curve25519/internal.h. +// Keep this in sync with curve25519/internal.h. +#[repr(C)] +pub struct Elem { + limbs: [Limb; ELEM_LIMBS], // This is called `v` in the C code. + encoding: PhantomData, +} + +pub trait Encoding {} +pub struct T; +impl Encoding for T {} + +const ELEM_LIMBS: usize = 5 * 64 / LIMB_BITS; + +impl Elem { + fn zero() -> Self { + Self { + limbs: Default::default(), + encoding: PhantomData, + } + } +} + +impl Elem { + fn negate(&mut self) { + unsafe { + x25519_fe_neg(self); + } + } +} + +// An encoding of a curve point. If on Curve25519, it should be encoded as +// described in Section 5 of [RFC 7748]. If on Edwards25519, it should be +// encoded as described in section 5.1.2 of [RFC 8032]. +// +// [RFC 7748] https://tools.ietf.org/html/rfc7748#section-5 +// [RFC 8032] https://tools.ietf.org/html/rfc8032#section-5.1.2 +pub type EncodedPoint = [u8; ELEM_LEN]; +pub const ELEM_LEN: usize = 32; + +// Keep this in sync with `ge_p3` in curve25519/internal.h. +#[repr(C)] +pub struct ExtPoint { + x: Elem, + y: Elem, + z: Elem, + t: Elem, +} + +impl ExtPoint { + // Returns the result of multiplying the base point by the scalar in constant time. + pub(super) fn from_scalarmult_base(scalar: &Scalar, cpu: cpu::Features) -> Self { + let mut r = Self { + x: Elem::zero(), + y: Elem::zero(), + z: Elem::zero(), + t: Elem::zero(), + }; + prefixed_extern! { + fn x25519_ge_scalarmult_base(h: &mut ExtPoint, a: &Scalar, has_fe25519_adx: c_int); + } + unsafe { + x25519_ge_scalarmult_base(&mut r, scalar, has_fe25519_adx(cpu).into()); + } + r + } + + pub fn from_encoded_point_vartime(encoded: &EncodedPoint) -> Result { + let mut point = Self { + x: Elem::zero(), + y: Elem::zero(), + z: Elem::zero(), + t: Elem::zero(), + }; + + Result::from(unsafe { x25519_ge_frombytes_vartime(&mut point, encoded) }).map(|()| point) + } + + pub(super) fn into_encoded_point(self, cpu_features: cpu::Features) -> EncodedPoint { + encode_point(self.x, self.y, self.z, cpu_features) + } + + pub(super) fn invert_vartime(&mut self) { + self.x.negate(); + self.t.negate(); + } +} + +// Keep this in sync with `ge_p2` in curve25519/internal.h. +#[repr(C)] +pub struct Point { + x: Elem, + y: Elem, + z: Elem, +} + +impl Point { + pub fn new_at_infinity() -> Self { + Self { + x: Elem::zero(), + y: Elem::zero(), + z: Elem::zero(), + } + } + + pub(super) fn into_encoded_point(self, cpu_features: cpu::Features) -> EncodedPoint { + encode_point(self.x, self.y, self.z, cpu_features) + } +} + +fn encode_point(x: Elem, y: Elem, z: Elem, _cpu_features: cpu::Features) -> EncodedPoint { + let mut bytes = [0; ELEM_LEN]; + + let sign_bit: u8 = unsafe { + let mut recip = Elem::zero(); + x25519_fe_invert(&mut recip, &z); + + let mut x_over_z = Elem::zero(); + x25519_fe_mul_ttt(&mut x_over_z, &x, &recip); + + let mut y_over_z = Elem::zero(); + x25519_fe_mul_ttt(&mut y_over_z, &y, &recip); + x25519_fe_tobytes(&mut bytes, &y_over_z); + + x25519_fe_isnegative(&x_over_z) + }; + + // The preceding computations must execute in constant time, but this + // doesn't need to. + bytes[ELEM_LEN - 1] ^= sign_bit << 7; + + bytes +} + +#[inline(always)] +pub(super) fn has_fe25519_adx(cpu: cpu::Features) -> bool { + cfg_if::cfg_if! { + if #[cfg(all(target_arch = "x86_64", not(target_os = "windows")))] { + use cpu::{intel::{Adx, Bmi1, Bmi2}, GetFeature as _}; + matches!(cpu.get_feature(), Some((Adx { .. }, Bmi1 { .. }, Bmi2 { .. }))) + } else { + let _ = cpu; + false + } + } +} + +prefixed_extern! { + fn x25519_fe_invert(out: &mut Elem, z: &Elem); + fn x25519_fe_isnegative(elem: &Elem) -> u8; + fn x25519_fe_mul_ttt(h: &mut Elem, f: &Elem, g: &Elem); + fn x25519_fe_neg(f: &mut Elem); + fn x25519_fe_tobytes(bytes: &mut EncodedPoint, elem: &Elem); + fn x25519_ge_frombytes_vartime(h: &mut ExtPoint, s: &EncodedPoint) -> bssl::Result; +} diff --git a/http/vendor/ring/src/ec/curve25519/scalar.rs b/http/vendor/ring/src/ec/curve25519/scalar.rs new file mode 100644 index 0000000..a56e281 --- /dev/null +++ b/http/vendor/ring/src/ec/curve25519/scalar.rs @@ -0,0 +1,78 @@ +// Copyright 2015-2019 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use crate::{ + arithmetic::limbs_from_hex, + digest, error, limb, + polyfill::slice::{self, AsChunks}, +}; +use core::array; + +#[repr(transparent)] +pub struct Scalar([u8; SCALAR_LEN]); + +pub const SCALAR_LEN: usize = 32; + +impl Scalar { + // Constructs a `Scalar` from `bytes`, failing if `bytes` encodes a scalar + // that is not in the range [0, n). + pub fn from_bytes_checked(bytes: [u8; SCALAR_LEN]) -> Result { + const ORDER: [limb::Limb; SCALAR_LEN / limb::LIMB_BYTES] = + limbs_from_hex("1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"); + let order = ORDER.map(limb::Limb::from); + + let (limbs_as_bytes, _empty): (AsChunks, _) = + slice::as_chunks(&bytes); + debug_assert!(_empty.is_empty()); + let limbs: [limb::Limb; SCALAR_LEN / limb::LIMB_BYTES] = + array::from_fn(|i| limb::Limb::from_le_bytes(limbs_as_bytes[i])); + limb::verify_limbs_less_than_limbs_leak_bit(&limbs, &order)?; + + Ok(Self(bytes)) + } + + // Constructs a `Scalar` from `digest` reduced modulo n. + pub fn from_sha512_digest_reduced(digest: digest::Digest) -> Self { + prefixed_extern! { + fn x25519_sc_reduce(s: &mut UnreducedScalar); + } + let mut unreduced = [0u8; digest::SHA512_OUTPUT_LEN]; + unreduced.copy_from_slice(digest.as_ref()); + unsafe { x25519_sc_reduce(&mut unreduced) }; + Self((&unreduced[..SCALAR_LEN]).try_into().unwrap()) + } +} + +#[repr(transparent)] +pub struct MaskedScalar([u8; SCALAR_LEN]); + +impl MaskedScalar { + pub fn from_bytes_masked(bytes: [u8; SCALAR_LEN]) -> Self { + prefixed_extern! { + fn x25519_sc_mask(a: &mut [u8; SCALAR_LEN]); + } + let mut r = Self(bytes); + unsafe { x25519_sc_mask(&mut r.0) }; + r + } +} + +impl From for Scalar { + fn from(MaskedScalar(scalar): MaskedScalar) -> Self { + Self(scalar) + } +} + +type UnreducedScalar = [u8; UNREDUCED_SCALAR_LEN]; +const UNREDUCED_SCALAR_LEN: usize = SCALAR_LEN * 2; diff --git a/http/vendor/ring/src/ec/curve25519/x25519.rs b/http/vendor/ring/src/ec/curve25519/x25519.rs new file mode 100644 index 0000000..216648a --- /dev/null +++ b/http/vendor/ring/src/ec/curve25519/x25519.rs @@ -0,0 +1,249 @@ +// Copyright 2015-2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! X25519 Key agreement. + +use super::{ops, scalar::SCALAR_LEN}; +use crate::{agreement, bb, cpu, ec, error, rand}; +use core::ffi::c_int; + +static CURVE25519: ec::Curve = ec::Curve { + public_key_len: PUBLIC_KEY_LEN, + elem_scalar_seed_len: ELEM_AND_SCALAR_LEN, + id: ec::CurveID::Curve25519, + check_private_key_bytes: x25519_check_private_key_bytes, + generate_private_key: x25519_generate_private_key, + public_from_private: x25519_public_from_private, +}; + +/// X25519 (ECDH using Curve25519) as described in [RFC 7748]. +/// +/// Everything is as described in RFC 7748. Key agreement will fail if the +/// result of the X25519 operation is zero; see the notes on the +/// "all-zero value" in [RFC 7748 section 6.1]. +/// +/// [RFC 7748]: https://tools.ietf.org/html/rfc7748 +/// [RFC 7748 section 6.1]: https://tools.ietf.org/html/rfc7748#section-6.1 +pub static X25519: agreement::Algorithm = agreement::Algorithm { + curve: &CURVE25519, + ecdh: x25519_ecdh, +}; + +#[allow(clippy::unnecessary_wraps)] +fn x25519_check_private_key_bytes( + bytes: &[u8], + _: cpu::Features, +) -> Result<(), error::Unspecified> { + debug_assert_eq!(bytes.len(), PRIVATE_KEY_LEN); + Ok(()) +} + +fn x25519_generate_private_key( + rng: &dyn rand::SecureRandom, + out: &mut [u8], + _: cpu::Features, +) -> Result<(), error::Unspecified> { + rng.fill(out) +} + +fn x25519_public_from_private( + public_out: &mut [u8], + private_key: &ec::Seed, + cpu_features: cpu::Features, +) -> Result<(), error::Unspecified> { + let public_out = public_out.try_into()?; + + let private_key: &[u8; SCALAR_LEN] = private_key.bytes_less_safe().try_into()?; + let private_key = ops::MaskedScalar::from_bytes_masked(*private_key); + + #[cfg(all( + all(target_arch = "arm", target_endian = "little"), + any(target_os = "android", target_os = "linux") + ))] + if let Some(cpu) = >::get_feature(&cpu_features) { + static MONTGOMERY_BASE_POINT: [u8; 32] = [ + 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, + ]; + x25519_neon(public_out, &private_key, &MONTGOMERY_BASE_POINT, cpu); + return Ok(()); + } + + prefixed_extern! { + fn x25519_public_from_private_generic_masked( + public_key_out: &mut PublicKey, + private_key: &PrivateKey, + use_adx: c_int, + ); + } + unsafe { + x25519_public_from_private_generic_masked( + public_out, + &private_key, + ops::has_fe25519_adx(cpu_features).into(), + ); + } + + Ok(()) +} + +fn x25519_ecdh( + out: &mut [u8], + my_private_key: &ec::Seed, + peer_public_key: untrusted::Input, + cpu_features: cpu::Features, +) -> Result<(), error::Unspecified> { + let my_private_key: &[u8; SCALAR_LEN] = my_private_key.bytes_less_safe().try_into()?; + let my_private_key = ops::MaskedScalar::from_bytes_masked(*my_private_key); + let peer_public_key: &[u8; PUBLIC_KEY_LEN] = peer_public_key.as_slice_less_safe().try_into()?; + + fn scalar_mult( + out: &mut ops::EncodedPoint, + scalar: &ops::MaskedScalar, + point: &ops::EncodedPoint, + #[allow(unused_variables)] cpu_features: cpu::Features, + ) { + #[cfg(all( + all(target_arch = "arm", target_endian = "little"), + any(target_os = "android", target_os = "linux") + ))] + if let Some(cpu) = >::get_feature(&cpu_features) { + return x25519_neon(out, scalar, point, cpu); + } + + #[cfg(all(target_arch = "x86_64", not(target_os = "windows")))] + { + if ops::has_fe25519_adx(cpu_features) { + prefixed_extern! { + fn x25519_scalar_mult_adx( + out: &mut ops::EncodedPoint, + scalar: &ops::MaskedScalar, + point: &ops::EncodedPoint, + ); + } + return unsafe { x25519_scalar_mult_adx(out, scalar, point) }; + } + } + + prefixed_extern! { + fn x25519_scalar_mult_generic_masked( + out: &mut ops::EncodedPoint, + scalar: &ops::MaskedScalar, + point: &ops::EncodedPoint, + ); + } + unsafe { + x25519_scalar_mult_generic_masked(out, scalar, point); + } + } + + scalar_mult( + out.try_into()?, + &my_private_key, + peer_public_key, + cpu_features, + ); + + let zeros: SharedSecret = [0; SHARED_SECRET_LEN]; + if bb::verify_slices_are_equal(out, &zeros).is_ok() { + // All-zero output results when the input is a point of small order. + return Err(error::Unspecified); + } + + Ok(()) +} + +// BoringSSL uses `!defined(OPENSSL_APPLE)`. +#[cfg(all( + all(target_arch = "arm", target_endian = "little"), + any(target_os = "android", target_os = "linux") +))] +fn x25519_neon( + out: &mut ops::EncodedPoint, + scalar: &ops::MaskedScalar, + point: &ops::EncodedPoint, + _cpu: cpu::arm::Neon, +) { + prefixed_extern! { + fn x25519_NEON( + out: &mut ops::EncodedPoint, + scalar: &ops::MaskedScalar, + point: &ops::EncodedPoint, + ); + } + unsafe { x25519_NEON(out, scalar, point) } +} + +const ELEM_AND_SCALAR_LEN: usize = ops::ELEM_LEN; + +type PrivateKey = ops::MaskedScalar; +const PRIVATE_KEY_LEN: usize = ELEM_AND_SCALAR_LEN; + +// An X25519 public key as an encoded Curve25519 point. +type PublicKey = [u8; PUBLIC_KEY_LEN]; +const PUBLIC_KEY_LEN: usize = ELEM_AND_SCALAR_LEN; + +// An X25519 shared secret as an encoded Curve25519 point. +type SharedSecret = [u8; SHARED_SECRET_LEN]; +const SHARED_SECRET_LEN: usize = ELEM_AND_SCALAR_LEN; + +#[cfg(test)] +mod tests { + use super::*; + use crate::ec; + use untrusted::Input; + + #[test] + fn test_x25519_public_from_private() { + struct TestVector { + private: [u8; 32], + public: [u8; 32], + } + static TEST_CASES: &[TestVector] = &[ + TestVector { + private: [ + 0x77, 0x07, 0x6d, 0x0a, 0x73, 0x18, 0xa5, 0x7d, 0x3c, 0x16, 0xc1, 0x72, 0x51, + 0xb2, 0x66, 0x45, 0xdf, 0x4c, 0x2f, 0x87, 0xeb, 0xc0, 0x99, 0x2a, 0xb1, 0x77, + 0xfb, 0xa5, 0x1d, 0xb9, 0x2c, 0x2a, + ], + public: [ + 0x85, 0x20, 0xf0, 0x09, 0x89, 0x30, 0xa7, 0x54, 0x74, 0x8b, 0x7d, 0xdc, 0xb4, + 0x3e, 0xf7, 0x5a, 0x0d, 0xbf, 0x3a, 0x0d, 0x26, 0x38, 0x1a, 0xf4, 0xeb, 0xa4, + 0xa9, 0x8e, 0xaa, 0x9b, 0x4e, 0x6a, + ], + }, + TestVector { + private: [ + 0x5d, 0xab, 0x08, 0x7e, 0x62, 0x4a, 0x8a, 0x4b, 0x79, 0xe1, 0x7f, 0x8b, 0x83, + 0x80, 0x0e, 0xe6, 0x6f, 0x3b, 0xb1, 0x29, 0x26, 0x18, 0xb6, 0xfd, 0x1c, 0x2f, + 0x8b, 0x27, 0xff, 0x88, 0xe0, 0xeb, + ], + public: [ + 0xde, 0x9e, 0xdb, 0x7d, 0x7b, 0x7d, 0xc1, 0xb4, 0xd3, 0x5b, 0x61, 0xc2, 0xec, + 0xe4, 0x35, 0x37, 0x3f, 0x83, 0x43, 0xc8, 0x5b, 0x78, 0x67, 0x4d, 0xad, 0xfc, + 0x7e, 0x14, 0x6f, 0x88, 0x2b, 0x4f, + ], + }, + ]; + let cpu_features = cpu::features(); + for test_case in TEST_CASES { + let seed = + ec::Seed::from_bytes(&CURVE25519, Input::from(&test_case.private), cpu_features) + .unwrap(); + let mut output = [0u8; 32]; + x25519_public_from_private(&mut output, &seed, cpu_features).unwrap(); + assert_eq!(output, test_case.public); + } + } +} diff --git a/http/vendor/ring/src/ec/keys.rs b/http/vendor/ring/src/ec/keys.rs new file mode 100644 index 0000000..6cf9250 --- /dev/null +++ b/http/vendor/ring/src/ec/keys.rs @@ -0,0 +1,97 @@ +use super::{Curve, ELEM_MAX_BYTES, SEED_MAX_BYTES}; +use crate::{cpu, error, rand}; + +pub struct KeyPair { + seed: Seed, + public_key: PublicKey, +} + +impl KeyPair { + pub(super) fn derive( + seed: Seed, + cpu_features: cpu::Features, + ) -> Result { + let public_key = seed.compute_public_key(cpu_features)?; + Ok(Self { seed, public_key }) + } + + pub fn public_key(&self) -> &PublicKey { + &self.public_key + } + pub fn split(self) -> (Seed, PublicKey) { + (self.seed, self.public_key) + } +} + +pub struct Seed { + bytes: [u8; SEED_MAX_BYTES], + curve: &'static Curve, +} + +impl Seed { + pub(crate) fn generate( + curve: &'static Curve, + rng: &dyn rand::SecureRandom, + cpu: cpu::Features, + ) -> Result { + let mut r = Self { + bytes: [0u8; SEED_MAX_BYTES], + curve, + }; + (curve.generate_private_key)(rng, &mut r.bytes[..curve.elem_scalar_seed_len], cpu)?; + Ok(r) + } + + pub(crate) fn from_bytes( + curve: &'static Curve, + bytes: untrusted::Input, + cpu: cpu::Features, + ) -> Result { + let bytes = bytes.as_slice_less_safe(); + if curve.elem_scalar_seed_len != bytes.len() { + return Err(error::Unspecified); + } + (curve.check_private_key_bytes)(bytes, cpu)?; + let mut r = Self { + bytes: [0; SEED_MAX_BYTES], + curve, + }; + r.bytes[..curve.elem_scalar_seed_len].copy_from_slice(bytes); + Ok(r) + } + + pub fn bytes_less_safe(&self) -> &[u8] { + &self.bytes[..self.curve.elem_scalar_seed_len] + } + + pub(crate) fn compute_public_key( + &self, + cpu_features: cpu::Features, + ) -> Result { + let mut public_key = PublicKey { + bytes: [0u8; PUBLIC_KEY_MAX_LEN], + len: self.curve.public_key_len, + }; + (self.curve.public_from_private)( + &mut public_key.bytes[..public_key.len], + self, + cpu_features, + )?; + Ok(public_key) + } +} + +#[derive(Copy, Clone)] +pub struct PublicKey { + bytes: [u8; PUBLIC_KEY_MAX_LEN], + len: usize, +} + +impl AsRef<[u8]> for PublicKey { + fn as_ref(&self) -> &[u8] { + &self.bytes[..self.len] + } +} + +/// The maximum length, in bytes, of an encoded public key. +pub const PUBLIC_KEY_MAX_LEN: usize = 1 + (2 * ELEM_MAX_BYTES); diff --git a/http/vendor/ring/src/ec/suite_b.rs b/http/vendor/ring/src/ec/suite_b.rs new file mode 100644 index 0000000..41adcfd --- /dev/null +++ b/http/vendor/ring/src/ec/suite_b.rs @@ -0,0 +1,239 @@ +// Copyright 2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! Elliptic curve operations on P-256 & P-384. + +use self::ops::*; +use crate::{arithmetic::montgomery::*, cpu, ec, error, io::der, pkcs8}; + +// NIST SP 800-56A Step 3: "If q is an odd prime p, verify that +// yQ**2 = xQ**3 + axQ + b in GF(p), where the arithmetic is performed modulo +// p." +// +// That is, verify that (x, y) is on the curve, which is true iif: +// +// y**2 == x**3 + a*x + b (mod q) +// +// Or, equivalently, but more efficiently: +// +// y**2 == (x**2 + a)*x + b (mod q) +// +fn verify_affine_point_is_on_the_curve( + q: &Modulus, + (x, y): (&Elem, &Elem), +) -> Result<(), error::Unspecified> { + verify_affine_point_is_on_the_curve_scaled(q, (x, y), &Elem::from(q.a()), &Elem::from(q.b())) +} + +// Use `verify_affine_point_is_on_the_curve` instead of this function whenever +// the affine coordinates are available or will become available. This function +// should only be used then the affine coordinates are never calculated. See +// the notes for `verify_affine_point_is_on_the_curve_scaled`. +// +// The value `z**2` is returned on success because it is useful for ECDSA +// verification. +// +// This function also verifies that the point is not at infinity. +fn verify_jacobian_point_is_on_the_curve( + q: &Modulus, + p: &Point, +) -> Result, error::Unspecified> { + let z = q.point_z(p); + + // Verify that the point is not at infinity. + q.elem_verify_is_not_zero(&z)?; + + let x = q.point_x(p); + let y = q.point_y(p); + + // We are given Jacobian coordinates (x, y, z). So, we have: + // + // (x/z**2, y/z**3) == (x', y'), + // + // where (x', y') are the affine coordinates. The curve equation is: + // + // y'**2 == x'**3 + a*x' + b == (x'**2 + a)*x' + b + // + // Substituting our Jacobian coordinates, we get: + // + // / y \**2 / / x \**2 \ / x \ + // | ---- | == | | ---- | + a | * | ---- | + b + // \ z**3 / \ \ z**2 / / \ z**2 / + // + // Simplify: + // + // y**2 / x**2 \ x + // ---- == | ---- + a | * ---- + b + // z**6 \ z**4 / z**2 + // + // Multiply both sides by z**6: + // + // z**6 / x**2 \ z**6 + // ---- * y**2 == | ---- + a | * ---- * x + (z**6) * b + // z**6 \ z**4 / z**2 + // + // Simplify: + // + // / x**2 \ + // y**2 == | ---- + a | * z**4 * x + (z**6) * b + // \ z**4 / + // + // Distribute z**4: + // + // / z**4 \ + // y**2 == | ---- * x**2 + z**4 * a | * x + (z**6) * b + // \ z**4 / + // + // Simplify: + // + // y**2 == (x**2 + z**4 * a) * x + (z**6) * b + // + let z2 = q.elem_squared(&z); + let z4 = q.elem_squared(&z2); + let z4_a = q.elem_product(&z4, &Elem::from(q.a())); + let z6 = q.elem_product(&z4, &z2); + let z6_b = q.elem_product(&z6, &Elem::from(q.b())); + verify_affine_point_is_on_the_curve_scaled(q, (&x, &y), &z4_a, &z6_b)?; + Ok(z2) +} + +// Handles the common logic of point-is-on-the-curve checks for both affine and +// Jacobian cases. +// +// When doing the check that the point is on the curve after a computation, +// to avoid fault attacks or mitigate potential bugs, it is better for security +// to use `verify_affine_point_is_on_the_curve` on the affine coordinates, +// because it provides some protection against faults that occur in the +// computation of the inverse of `z`. See the paper and presentation "Fault +// Attacks on Projective-to-Affine Coordinates Conversion" by Diana Maimuţ, +// Cédric Murdica, David Naccache, Mehdi Tibouchi. That presentation concluded +// simply "Check the validity of the result after conversion to affine +// coordinates." (It seems like a good idea to verify that +// z_inv * z == 1 mod q too). +// +// In the case of affine coordinates (x, y), `a_scaled` and `b_scaled` are +// `a` and `b`, respectively. In the case of Jacobian coordinates (x, y, z), +// the computation and comparison is the same, except `a_scaled` and `b_scaled` +// are (z**4 * a) and (z**6 * b), respectively. Thus, performance is another +// reason to prefer doing the check on the affine coordinates, as Jacobian +// computation requires 3 extra multiplications and 2 extra squarings. +// +// An example of a fault attack that isn't mitigated by a point-on-the-curve +// check after multiplication is given in "Sign Change Fault Attacks On +// Elliptic Curve Cryptosystems" by Johannes Blömer, Martin Otto, and +// Jean-Pierre Seifert. +fn verify_affine_point_is_on_the_curve_scaled( + q: &Modulus, + (x, y): (&Elem, &Elem), + a_scaled: &Elem, + b_scaled: &Elem, +) -> Result<(), error::Unspecified> { + let lhs = q.elem_squared(y); + + let mut rhs = q.elem_squared(x); + q.add_assign(&mut rhs, a_scaled); + q.elem_mul(&mut rhs, x); + q.add_assign(&mut rhs, b_scaled); + + if !q.elems_are_equal(&lhs, &rhs).leak() { + return Err(error::Unspecified); + } + + Ok(()) +} + +pub(crate) fn key_pair_from_pkcs8( + curve: &'static ec::Curve, + template: &pkcs8::Template, + input: untrusted::Input, + cpu_features: cpu::Features, +) -> Result { + let (ec_private_key, _) = pkcs8::unwrap_key(template, pkcs8::Version::V1Only, input)?; + let (private_key, public_key) = + ec_private_key.read_all(error::KeyRejected::invalid_encoding(), |input| { + // https://tools.ietf.org/html/rfc5915#section-3 + der::nested( + input, + der::Tag::Sequence, + error::KeyRejected::invalid_encoding(), + |input| key_pair_from_pkcs8_(template, input), + ) + })?; + key_pair_from_bytes(curve, private_key, public_key, cpu_features) +} + +fn key_pair_from_pkcs8_<'a>( + template: &pkcs8::Template, + input: &mut untrusted::Reader<'a>, +) -> Result<(untrusted::Input<'a>, untrusted::Input<'a>), error::KeyRejected> { + let version = der::small_nonnegative_integer(input) + .map_err(|error::Unspecified| error::KeyRejected::invalid_encoding())?; + if version != 1 { + return Err(error::KeyRejected::version_not_supported()); + } + + let private_key = der::expect_tag_and_get_value(input, der::Tag::OctetString) + .map_err(|error::Unspecified| error::KeyRejected::invalid_encoding())?; + + // [0] parameters (optional). + if input.peek(u8::from(der::Tag::ContextSpecificConstructed0)) { + let actual_alg_id = + der::expect_tag_and_get_value(input, der::Tag::ContextSpecificConstructed0) + .map_err(|error::Unspecified| error::KeyRejected::invalid_encoding())?; + if actual_alg_id.as_slice_less_safe() != template.curve_oid().as_slice_less_safe() { + return Err(error::KeyRejected::wrong_algorithm()); + } + } + + // [1] publicKey. The RFC says it is optional, but we require it + // to be present. + let public_key = der::nested( + input, + der::Tag::ContextSpecificConstructed1, + error::Unspecified, + der::bit_string_with_no_unused_bits, + ) + .map_err(|error::Unspecified| error::KeyRejected::invalid_encoding())?; + + Ok((private_key, public_key)) +} + +pub(crate) fn key_pair_from_bytes( + curve: &'static ec::Curve, + private_key_bytes: untrusted::Input, + public_key_bytes: untrusted::Input, + cpu_features: cpu::Features, +) -> Result { + let seed = ec::Seed::from_bytes(curve, private_key_bytes, cpu_features) + .map_err(|error::Unspecified| error::KeyRejected::invalid_component())?; + + let r = ec::KeyPair::derive(seed, cpu_features) + .map_err(|error::Unspecified| error::KeyRejected::unexpected_error())?; + if public_key_bytes.as_slice_less_safe() != r.public_key().as_ref() { + return Err(error::KeyRejected::inconsistent_components()); + } + + Ok(r) +} + +pub mod curve; + +pub mod ecdh; + +pub mod ecdsa; + +mod ops; + +mod private_key; +mod public_key; diff --git a/http/vendor/ring/src/ec/suite_b/curve.rs b/http/vendor/ring/src/ec/suite_b/curve.rs new file mode 100644 index 0000000..0e9f1a9 --- /dev/null +++ b/http/vendor/ring/src/ec/suite_b/curve.rs @@ -0,0 +1,93 @@ +// Copyright 2015-2017 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use crate::{cpu, ec, error, rand}; + +/// A key agreement algorithm. +macro_rules! suite_b_curve { + ( $NAME:ident, $bits:expr, $private_key_ops:expr, $id:expr, + $check_private_key_bytes:ident, $generate_private_key:ident, + $public_from_private:ident) => { + /// Public keys are encoding in uncompressed form using the + /// Octet-String-to-Elliptic-Curve-Point algorithm in + /// [SEC 1: Elliptic Curve Cryptography, Version 2.0]. Public keys are + /// validated during key agreement according to + /// [NIST Special Publication 800-56A, revision 2] and Appendix B.3 of + /// the NSA's [Suite B Implementer's Guide to NIST SP 800-56A]. + /// + /// [SEC 1: Elliptic Curve Cryptography, Version 2.0]: + /// http://www.secg.org/sec1-v2.pdf + /// [NIST Special Publication 800-56A, revision 2]: + /// http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-56Ar2.pdf + /// [Suite B Implementer's Guide to NIST SP 800-56A]: + /// https://github.com/briansmith/ring/blob/main/doc/ecdh.pdf + pub static $NAME: ec::Curve = ec::Curve { + public_key_len: 1 + (2 * (($bits + 7) / 8)), + elem_scalar_seed_len: ($bits + 7) / 8, + id: $id, + check_private_key_bytes: $check_private_key_bytes, + generate_private_key: $generate_private_key, + public_from_private: $public_from_private, + }; + + fn $check_private_key_bytes( + bytes: &[u8], + cpu: cpu::Features, + ) -> Result<(), error::Unspecified> { + debug_assert_eq!(bytes.len(), $bits / 8); + ec::suite_b::private_key::check_scalar_big_endian_bytes($private_key_ops, bytes, cpu) + } + + fn $generate_private_key( + rng: &dyn rand::SecureRandom, + out: &mut [u8], + cpu: cpu::Features, + ) -> Result<(), error::Unspecified> { + ec::suite_b::private_key::generate_private_scalar_bytes($private_key_ops, rng, out, cpu) + } + + fn $public_from_private( + public_out: &mut [u8], + private_key: &ec::Seed, + cpu: cpu::Features, + ) -> Result<(), error::Unspecified> { + ec::suite_b::private_key::public_from_private( + $private_key_ops, + public_out, + private_key, + cpu, + ) + } + }; +} + +suite_b_curve!( + P256, + 256, + &ec::suite_b::ops::p256::PRIVATE_KEY_OPS, + ec::CurveID::P256, + p256_check_private_key_bytes, + p256_generate_private_key, + p256_public_from_private +); + +suite_b_curve!( + P384, + 384, + &ec::suite_b::ops::p384::PRIVATE_KEY_OPS, + ec::CurveID::P384, + p384_check_private_key_bytes, + p384_generate_private_key, + p384_public_from_private +); diff --git a/http/vendor/ring/src/ec/suite_b/ecdh.rs b/http/vendor/ring/src/ec/suite_b/ecdh.rs new file mode 100644 index 0000000..59b4374 --- /dev/null +++ b/http/vendor/ring/src/ec/suite_b/ecdh.rs @@ -0,0 +1,243 @@ +// Copyright 2015-2017 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! ECDH key agreement using the P-256 and P-384 curves. + +use super::{ops::*, private_key::*, public_key::*}; +use crate::{agreement, cpu, ec, error}; + +/// A key agreement algorithm. +macro_rules! ecdh { + ( $NAME:ident, $curve:expr, $name_str:expr, $private_key_ops:expr, + $public_key_ops:expr, $ecdh:ident ) => { + #[doc = "ECDH using the NSA Suite B"] + #[doc=$name_str] + #[doc = "curve."] + /// + /// Public keys are encoding in uncompressed form using the + /// Octet-String-to-Elliptic-Curve-Point algorithm in + /// [SEC 1: Elliptic Curve Cryptography, Version 2.0]. Public keys are + /// validated during key agreement according to + /// [NIST Special Publication 800-56A, revision 2] and Appendix B.3 of + /// the NSA's [Suite B Implementer's Guide to NIST SP 800-56A]. + /// + /// [SEC 1: Elliptic Curve Cryptography, Version 2.0]: + /// http://www.secg.org/sec1-v2.pdf + /// [NIST Special Publication 800-56A, revision 2]: + /// http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-56Ar2.pdf + /// [Suite B Implementer's Guide to NIST SP 800-56A]: + /// https://github.com/briansmith/ring/blob/main/doc/ecdh.pdf + pub static $NAME: agreement::Algorithm = agreement::Algorithm { + curve: $curve, + ecdh: $ecdh, + }; + + fn $ecdh( + out: &mut [u8], + my_private_key: &ec::Seed, + peer_public_key: untrusted::Input, + cpu: cpu::Features, + ) -> Result<(), error::Unspecified> { + ecdh( + $private_key_ops, + $public_key_ops, + out, + my_private_key, + peer_public_key, + cpu, + ) + } + }; +} + +ecdh!( + ECDH_P256, + &ec::suite_b::curve::P256, + "P-256 (secp256r1)", + &p256::PRIVATE_KEY_OPS, + &p256::PUBLIC_KEY_OPS, + p256_ecdh +); + +ecdh!( + ECDH_P384, + &ec::suite_b::curve::P384, + "P-384 (secp384r1)", + &p384::PRIVATE_KEY_OPS, + &p384::PUBLIC_KEY_OPS, + p384_ecdh +); + +fn ecdh( + private_key_ops: &PrivateKeyOps, + public_key_ops: &PublicKeyOps, + out: &mut [u8], + my_private_key: &ec::Seed, + peer_public_key: untrusted::Input, + cpu: cpu::Features, +) -> Result<(), error::Unspecified> { + // The NIST SP 800-56Ar2 steps are from section 5.7.1.2 Elliptic Curve + // Cryptography Cofactor Diffie-Hellman (ECC CDH) Primitive. + // + // The "NSA Guide" steps are from section 3.1 of the NSA guide, "Ephemeral + // Unified Model." + + let q = &public_key_ops.common.elem_modulus(cpu); + + // NSA Guide Step 1 is handled separately. + + // NIST SP 800-56Ar2 5.6.2.2.2. + // NSA Guide Step 2. + // + // `parse_uncompressed_point` verifies that the point is not at infinity + // and that it is on the curve, using the Partial Public-Key Validation + // Routine. + let peer_public_key = parse_uncompressed_point(public_key_ops, q, peer_public_key)?; + + // NIST SP 800-56Ar2 Step 1. + // NSA Guide Step 3 (except point at infinity check). + // + // Note that the cofactor (h) is one since we only support prime-order + // curves, so we can safely ignore the cofactor. + // + // It is impossible for the result to be the point at infinity because our + // private key is in the range [1, n) and the curve has prime order and + // `parse_uncompressed_point` verified that the peer public key is on the + // curve and not at infinity. However, since the standards require the + // check, we do it using `assert!`. + // + // NIST SP 800-56Ar2 defines "Destroy" thusly: "In this Recommendation, to + // destroy is an action applied to a key or a piece of secret data. After + // a key or a piece of secret data is destroyed, no information about its + // value can be recovered." We interpret "destroy" somewhat liberally: we + // assume that since we throw away the values to be destroyed, no + // information about their values can be recovered. This doesn't meet the + // NSA guide's explicit requirement to "zeroize" them though. + // TODO: this only needs common scalar ops + let n = &private_key_ops.common.scalar_modulus(cpu); + let my_private_key = private_key_as_scalar(n, my_private_key); + let product = private_key_ops.point_mul(&my_private_key, &peer_public_key, cpu); + + // NIST SP 800-56Ar2 Steps 2, 3, 4, and 5. + // NSA Guide Steps 3 (point at infinity check) and 4. + // + // Again, we have a pretty liberal interpretation of the NIST's spec's + // "Destroy" that doesn't meet the NSA requirement to "zeroize." + // `big_endian_affine_from_jacobian` verifies that the result is not at + // infinity and also does an extra check to verify that the point is on + // the curve. + big_endian_affine_from_jacobian(private_key_ops, q, out, None, &product) + + // NSA Guide Step 5 & 6 are deferred to the caller. Again, we have a + // pretty liberal interpretation of the NIST's spec's "Destroy" that + // doesn't meet the NSA requirement to "zeroize." +} + +#[cfg(test)] +mod tests { + use super::super::ops; + use crate::testutil as test; + use crate::{agreement, ec, limb}; + + static SUPPORTED_SUITE_B_ALGS: [(&str, &agreement::Algorithm, &ec::Curve, &ops::CommonOps); 2] = [ + ( + "P-256", + &agreement::ECDH_P256, + &super::super::curve::P256, + &ops::p256::COMMON_OPS, + ), + ( + "P-384", + &agreement::ECDH_P384, + &super::super::curve::P384, + &ops::p384::COMMON_OPS, + ), + ]; + + #[test] + fn test_agreement_suite_b_ecdh_generate() { + // Generates a string of bytes 0x00...00, which will always result in + // a scalar value of zero. + let random_00 = test::rand::FixedByteRandom { byte: 0x00 }; + + // Generates a string of bytes 0xFF...FF, which will be larger than the + // group order of any curve that is supported. + let random_ff = test::rand::FixedByteRandom { byte: 0xff }; + + for &(_, alg, curve, ops) in SUPPORTED_SUITE_B_ALGS.iter() { + // Test that the private key value zero is rejected and that + // `generate` gives up after a while of only getting zeros. + assert!(agreement::EphemeralPrivateKey::generate(alg, &random_00).is_err()); + + // Test that the private key value larger than the group order is + // rejected and that `generate` gives up after a while of only + // getting values larger than the group order. + assert!(agreement::EphemeralPrivateKey::generate(alg, &random_ff).is_err()); + + // Test that a private key value exactly equal to the group order + // is rejected and that `generate` gives up after a while of only + // getting that value from the PRNG. + let mut n_bytes = [0u8; ec::SCALAR_MAX_BYTES]; + let num_bytes = curve.elem_scalar_seed_len; + limb::big_endian_from_limbs(ops.n_limbs(), &mut n_bytes[..num_bytes]); + { + let n_bytes = &mut n_bytes[..num_bytes]; + let rng = test::rand::FixedSliceRandom { bytes: n_bytes }; + assert!(agreement::EphemeralPrivateKey::generate(alg, &rng).is_err()); + } + + // Test that a private key value exactly equal to the group order + // minus 1 is accepted. + let mut n_minus_1_bytes = n_bytes; + { + let n_minus_1_bytes = &mut n_minus_1_bytes[..num_bytes]; + n_minus_1_bytes[num_bytes - 1] -= 1; + let rng = test::rand::FixedSliceRandom { + bytes: n_minus_1_bytes, + }; + let key = agreement::EphemeralPrivateKey::generate(alg, &rng).unwrap(); + assert_eq!(n_minus_1_bytes, key.bytes_for_test()); + } + + // Test that n + 1 also fails. + let mut n_plus_1_bytes = n_bytes; + { + let n_plus_1_bytes = &mut n_plus_1_bytes[..num_bytes]; + n_plus_1_bytes[num_bytes - 1] += 1; + let rng = test::rand::FixedSliceRandom { + bytes: n_plus_1_bytes, + }; + assert!(agreement::EphemeralPrivateKey::generate(alg, &rng).is_err()); + } + + // Test recovery from initial RNG failure. The first value will be + // n, then n + 1, then zero, the next value will be n - 1, which + // will be accepted. + { + let bytes = [ + &n_bytes[..num_bytes], + &n_plus_1_bytes[..num_bytes], + &[0u8; ec::SCALAR_MAX_BYTES][..num_bytes], + &n_minus_1_bytes[..num_bytes], + ]; + let rng = test::rand::FixedSliceSequenceRandom { + bytes: &bytes, + current: core::cell::UnsafeCell::new(0), + }; + let key = agreement::EphemeralPrivateKey::generate(alg, &rng).unwrap(); + assert_eq!(&n_minus_1_bytes[..num_bytes], key.bytes_for_test()); + } + } + } +} diff --git a/http/vendor/ring/src/ec/suite_b/ecdsa.rs b/http/vendor/ring/src/ec/suite_b/ecdsa.rs new file mode 100644 index 0000000..274c991 --- /dev/null +++ b/http/vendor/ring/src/ec/suite_b/ecdsa.rs @@ -0,0 +1,3 @@ +mod digest_scalar; +pub mod signing; +pub mod verification; diff --git a/http/vendor/ring/src/ec/suite_b/ecdsa/digest_scalar.rs b/http/vendor/ring/src/ec/suite_b/ecdsa/digest_scalar.rs new file mode 100644 index 0000000..6479c94 --- /dev/null +++ b/http/vendor/ring/src/ec/suite_b/ecdsa/digest_scalar.rs @@ -0,0 +1,119 @@ +// Copyright 2015-2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! ECDSA Signatures using the P-256 and P-384 curves. + +use crate::{digest, ec::suite_b::ops::*}; + +/// Calculate the digest of `msg` using the digest algorithm `digest_alg`. Then +/// convert the digest to a scalar in the range [0, n) as described in +/// NIST's FIPS 186-4 Section 4.2. Note that this is one of the few cases where +/// a `Scalar` is allowed to have the value zero. +/// +/// NIST's FIPS 186-4 4.2 says "When the length of the output of the hash +/// function is greater than N (i.e., the bit length of q), then the leftmost N +/// bits of the hash function output block shall be used in any calculation +/// using the hash function output during the generation or verification of a +/// digital signature." +/// +/// "Leftmost N bits" means "N most significant bits" because we interpret the +/// digest as a bit-endian encoded integer. +/// +/// The NSA guide instead vaguely suggests that we should convert the digest +/// value to an integer and then reduce it mod `n`. However, real-world +/// implementations (e.g. `digest_to_bn` in OpenSSL and `hashToInt` in Go) do +/// what FIPS 186-4 says to do, not what the NSA guide suggests. +/// +/// Why shifting the value right by at most one bit is sufficient: P-256's `n` +/// has its 256th bit set; i.e. 2**255 < n < 2**256. Once we've truncated the +/// digest to 256 bits and converted it to an integer, it will have a value +/// less than 2**256. If the value is larger than `n` then shifting it one bit +/// right will give a value less than 2**255, which is less than `n`. The +/// analogous argument applies for P-384. However, it does *not* apply in +/// general; for example, it doesn't apply to P-521. +pub(super) fn digest_scalar(n: &Modulus, msg: digest::Digest) -> Scalar { + digest_scalar_(n, msg.as_ref()) +} + +#[cfg(test)] +pub(super) fn digest_bytes_scalar(n: &Modulus, digest: &[u8]) -> Scalar { + digest_scalar_(n, digest) +} + +// This is a separate function solely so that we can test specific digest +// values like all-zero values and values larger than `n`. +fn digest_scalar_(n: &Modulus, digest: &[u8]) -> Scalar { + let len = n.bytes_len(); + let digest = if digest.len() > len { + &digest[..len] + } else { + digest + }; + + scalar_parse_big_endian_partially_reduced_variable_consttime(n, untrusted::Input::from(digest)) + .unwrap() +} + +#[cfg(test)] +mod tests { + use super::digest_bytes_scalar; + use crate::testutil as test; + use crate::{cpu, digest, ec::suite_b::ops::*, limb}; + + #[test] + fn test() { + let cpu = cpu::features(); + test::run( + test_vector_file!("ecdsa_digest_scalar_tests.txt"), + |section, test_case| { + assert_eq!(section, ""); + + let curve_name = test_case.consume_string("Curve"); + let digest_name = test_case.consume_string("Digest"); + let input = test_case.consume_bytes("Input"); + let output = test_case.consume_bytes("Output"); + + let (ops, digest_alg) = match (curve_name.as_str(), digest_name.as_str()) { + ("P-256", "SHA256") => (&p256::PUBLIC_SCALAR_OPS, &digest::SHA256), + ("P-256", "SHA384") => (&p256::PUBLIC_SCALAR_OPS, &digest::SHA384), + ("P-384", "SHA256") => (&p384::PUBLIC_SCALAR_OPS, &digest::SHA256), + ("P-384", "SHA384") => (&p384::PUBLIC_SCALAR_OPS, &digest::SHA384), + _ => { + panic!("Unsupported curve+digest: {}+{}", curve_name, digest_name); + } + }; + let n = &ops.scalar_ops.scalar_modulus(cpu); + + assert_eq!(input.len(), digest_alg.output_len()); + assert_eq!(output.len(), ops.scalar_ops.scalar_bytes_len()); + assert_eq!(output.len(), n.bytes_len()); + + let expected = scalar_parse_big_endian_variable( + n, + limb::AllowZero::Yes, + untrusted::Input::from(&output), + ) + .unwrap(); + + let actual = digest_bytes_scalar(n, &input); + assert_eq!( + ops.scalar_ops.leak_limbs(&actual), + ops.scalar_ops.leak_limbs(&expected) + ); + + Ok(()) + }, + ); + } +} diff --git a/http/vendor/ring/src/ec/suite_b/ecdsa/ecPublicKey_p256_pkcs8_v1_template.der b/http/vendor/ring/src/ec/suite_b/ecdsa/ecPublicKey_p256_pkcs8_v1_template.der new file mode 100644 index 0000000..d579082 Binary files /dev/null and b/http/vendor/ring/src/ec/suite_b/ecdsa/ecPublicKey_p256_pkcs8_v1_template.der differ diff --git a/http/vendor/ring/src/ec/suite_b/ecdsa/ecPublicKey_p384_pkcs8_v1_template.der b/http/vendor/ring/src/ec/suite_b/ecdsa/ecPublicKey_p384_pkcs8_v1_template.der new file mode 100644 index 0000000..76cc36d Binary files /dev/null and b/http/vendor/ring/src/ec/suite_b/ecdsa/ecPublicKey_p384_pkcs8_v1_template.der differ diff --git a/http/vendor/ring/src/ec/suite_b/ecdsa/signing.rs b/http/vendor/ring/src/ec/suite_b/ecdsa/signing.rs new file mode 100644 index 0000000..c2bc733 --- /dev/null +++ b/http/vendor/ring/src/ec/suite_b/ecdsa/signing.rs @@ -0,0 +1,615 @@ +// Copyright 2015-2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! ECDSA Signatures using the P-256 and P-384 curves. + +use super::digest_scalar::digest_scalar; +use crate::{ + arithmetic::montgomery::*, + cpu, digest, + ec::{ + self, + suite_b::{ops::*, private_key}, + }, + error, + io::der, + limb, pkcs8, rand, sealed, signature, +}; +/// An ECDSA signing algorithm. +pub struct EcdsaSigningAlgorithm { + curve: &'static ec::Curve, + private_scalar_ops: &'static PrivateScalarOps, + private_key_ops: &'static PrivateKeyOps, + digest_alg: &'static digest::Algorithm, + pkcs8_template: &'static pkcs8::Template, + format_rs: fn(ops: &'static ScalarOps, r: &Scalar, s: &Scalar, out: &mut [u8]) -> usize, + id: AlgorithmID, +} + +#[derive(Debug, Eq, PartialEq)] +enum AlgorithmID { + ECDSA_P256_SHA256_FIXED_SIGNING, + ECDSA_P384_SHA384_FIXED_SIGNING, + ECDSA_P256_SHA256_ASN1_SIGNING, + ECDSA_P384_SHA384_ASN1_SIGNING, +} + +derive_debug_via_id!(EcdsaSigningAlgorithm); + +impl PartialEq for EcdsaSigningAlgorithm { + fn eq(&self, other: &Self) -> bool { + self.id == other.id + } +} + +impl Eq for EcdsaSigningAlgorithm {} + +impl sealed::Sealed for EcdsaSigningAlgorithm {} + +/// An ECDSA key pair, used for signing. +pub struct EcdsaKeyPair { + d: Scalar, + nonce_key: NonceRandomKey, + alg: &'static EcdsaSigningAlgorithm, + public_key: PublicKey, +} + +derive_debug_via_field!(EcdsaKeyPair, stringify!(EcdsaKeyPair), public_key); + +impl EcdsaKeyPair { + /// Generates a new key pair and returns the key pair serialized as a + /// PKCS#8 document. + /// + /// The PKCS#8 document will be a v1 `OneAsymmetricKey` with the public key + /// included in the `ECPrivateKey` structure, as described in + /// [RFC 5958 Section 2] and [RFC 5915]. The `ECPrivateKey` structure will + /// not have a `parameters` field so the generated key is compatible with + /// PKCS#11. + /// + /// [RFC 5915]: https://tools.ietf.org/html/rfc5915 + /// [RFC 5958 Section 2]: https://tools.ietf.org/html/rfc5958#section-2 + pub fn generate_pkcs8( + alg: &'static EcdsaSigningAlgorithm, + rng: &dyn rand::SecureRandom, + ) -> Result { + let cpu = cpu::features(); + let private_key = ec::Seed::generate(alg.curve, rng, cpu)?; + let public_key = private_key.compute_public_key(cpu)?; + Ok(pkcs8::wrap_key( + alg.pkcs8_template, + private_key.bytes_less_safe(), + public_key.as_ref(), + )) + } + + /// Constructs an ECDSA key pair by parsing an unencrypted PKCS#8 v1 + /// id-ecPublicKey `ECPrivateKey` key. + /// + /// The input must be in PKCS#8 v1 format. It must contain the public key in + /// the `ECPrivateKey` structure; `from_pkcs8()` will verify that the public + /// key and the private key are consistent with each other. The algorithm + /// identifier must identify the curve by name; it must not use an + /// "explicit" encoding of the curve. The `parameters` field of the + /// `ECPrivateKey`, if present, must be the same named curve that is in the + /// algorithm identifier in the PKCS#8 header. + pub fn from_pkcs8( + alg: &'static EcdsaSigningAlgorithm, + pkcs8: &[u8], + rng: &dyn rand::SecureRandom, + ) -> Result { + let key_pair = ec::suite_b::key_pair_from_pkcs8( + alg.curve, + alg.pkcs8_template, + untrusted::Input::from(pkcs8), + cpu::features(), + )?; + Self::new(alg, key_pair, rng) + } + + /// Constructs an ECDSA key pair from the private key and public key bytes + /// + /// The private key must encoded as a big-endian fixed-length integer. For + /// example, a P-256 private key must be 32 bytes prefixed with leading + /// zeros as needed. + /// + /// The public key is encoding in uncompressed form using the + /// Octet-String-to-Elliptic-Curve-Point algorithm in + /// [SEC 1: Elliptic Curve Cryptography, Version 2.0]. + /// + /// This is intended for use by code that deserializes key pairs. It is + /// recommended to use `EcdsaKeyPair::from_pkcs8()` (with a PKCS#8-encoded + /// key) instead. + /// + /// [SEC 1: Elliptic Curve Cryptography, Version 2.0]: + /// http://www.secg.org/sec1-v2.pdf + pub fn from_private_key_and_public_key( + alg: &'static EcdsaSigningAlgorithm, + private_key: &[u8], + public_key: &[u8], + rng: &dyn rand::SecureRandom, + ) -> Result { + let key_pair = ec::suite_b::key_pair_from_bytes( + alg.curve, + untrusted::Input::from(private_key), + untrusted::Input::from(public_key), + cpu::features(), + )?; + Self::new(alg, key_pair, rng) + } + + fn new( + alg: &'static EcdsaSigningAlgorithm, + key_pair: ec::KeyPair, + rng: &dyn rand::SecureRandom, + ) -> Result { + let cpu = cpu::features(); + + let (seed, public_key) = key_pair.split(); + let n = &alg.private_scalar_ops.scalar_ops.scalar_modulus(cpu); + let d = private_key::private_key_as_scalar(n, &seed); + let d = alg.private_scalar_ops.to_mont(&d, cpu); + + let nonce_key = NonceRandomKey::new(alg, &seed, rng)?; + Ok(Self { + d, + nonce_key, + alg, + public_key: PublicKey(public_key), + }) + } + + /// Returns the signature of the `message` using a random nonce generated by `rng`. + pub fn sign( + &self, + rng: &dyn rand::SecureRandom, + message: &[u8], + ) -> Result { + let cpu = cpu::features(); + + // Step 4 (out of order). + let h = digest::digest(self.alg.digest_alg, message); + + // Incorporate `h` into the nonce to hedge against faulty RNGs. (This + // is not an approved random number generator that is mandated in + // the spec.) + let nonce_rng = NonceRandom { + key: &self.nonce_key, + message_digest: &h, + rng, + }; + + self.sign_digest(h, &nonce_rng, cpu) + } + + #[cfg(test)] + fn sign_with_fixed_nonce_during_test( + &self, + rng: &dyn rand::SecureRandom, + message: &[u8], + ) -> Result { + // Step 4 (out of order). + let h = digest::digest(self.alg.digest_alg, message); + + self.sign_digest(h, rng, cpu::features()) + } + + /// Returns the signature of message digest `h` using a "random" nonce + /// generated by `rng`. + fn sign_digest( + &self, + h: digest::Digest, + rng: &dyn rand::SecureRandom, + cpu: cpu::Features, + ) -> Result { + // NSA Suite B Implementer's Guide to ECDSA Section 3.4.1: ECDSA + // Signature Generation. + + // NSA Guide Prerequisites: + // + // Prior to generating an ECDSA signature, the signatory shall + // obtain: + // + // 1. an authentic copy of the domain parameters, + // 2. a digital signature key pair (d,Q), either generated by a + // method from Appendix A.1, or obtained from a trusted third + // party, + // 3. assurance of the validity of the public key Q (see Appendix + // A.3), and + // 4. assurance that he/she/it actually possesses the associated + // private key d (see [SP800-89] Section 6). + // + // The domain parameters are hard-coded into the source code. + // `EcdsaKeyPair::generate_pkcs8()` can be used to meet the second + // requirement; otherwise, it is up to the user to ensure the key pair + // was obtained from a trusted private key. The constructors for + // `EcdsaKeyPair` ensure that #3 and #4 are met subject to the caveats + // in SP800-89 Section 6. + + let ops = self.alg.private_scalar_ops; + let scalar_ops = ops.scalar_ops; + let cops = scalar_ops.common; + let private_key_ops = self.alg.private_key_ops; + let q = &cops.elem_modulus(cpu); + let n = &scalar_ops.scalar_modulus(cpu); + + for _ in 0..100 { + // XXX: iteration conut? + // Step 1. + let k = private_key::random_scalar(self.alg.private_key_ops, n, rng)?; + let k_inv = ops.scalar_inv_to_mont(&k, cpu); + + // Step 2. + let r = private_key_ops.point_mul_base(&k, cpu); + + // Step 3. + let r = { + let (x, _) = private_key::affine_from_jacobian(private_key_ops, q, &r)?; + let x = q.elem_unencoded(&x); + n.elem_reduced_to_scalar(&x) + }; + if n.is_zero(&r) { + continue; + } + + // Step 4 is done by the caller. + + // Step 5. + let e = digest_scalar(n, h); + + // Step 6. + let s = { + let mut e_plus_dr = scalar_ops.scalar_product(&self.d, &r, cpu); + n.add_assign(&mut e_plus_dr, &e); + scalar_ops.scalar_product(&k_inv, &e_plus_dr, cpu) + }; + if n.is_zero(&s) { + continue; + } + + // Step 7 with encoding. + return Ok(signature::Signature::new(|sig_bytes| { + (self.alg.format_rs)(scalar_ops, &r, &s, sig_bytes) + })); + } + + Err(error::Unspecified) + } +} + +/// Generates an ECDSA nonce in a way that attempts to protect against a faulty +/// `SecureRandom`. +struct NonceRandom<'a> { + key: &'a NonceRandomKey, + message_digest: &'a digest::Digest, + rng: &'a dyn rand::SecureRandom, +} + +impl core::fmt::Debug for NonceRandom<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.debug_struct("NonceRandom").finish() + } +} + +impl rand::sealed::SecureRandom for NonceRandom<'_> { + fn fill_impl(&self, dest: &mut [u8]) -> Result<(), error::Unspecified> { + // Use the same digest algorithm that will be used to digest the + // message. The digest algorithm's output is exactly the right size; + // this is checked below. + // + // XXX(perf): The single iteration will require two digest block + // operations because the amount of data digested is larger than one + // block. + let digest_alg = self.key.0.algorithm(); + let mut ctx = digest::Context::new(digest_alg); + + // Digest the randomized digest of the private key. + let key = self.key.0.as_ref(); + ctx.update(key); + + // The random value is digested between the key and the message so that + // the key and the message are not directly digested in the same digest + // block. + assert!(key.len() <= digest_alg.block_len() / 2); + { + let mut rand = [0u8; digest::MAX_BLOCK_LEN]; + let rand = &mut rand[..digest_alg.block_len() - key.len()]; + assert!(rand.len() >= dest.len()); + self.rng.fill(rand)?; + ctx.update(rand); + } + + ctx.update(self.message_digest.as_ref()); + + let nonce = ctx.finish(); + + // `copy_from_slice()` panics if the lengths differ, so we don't have + // to separately assert that the lengths are the same. + dest.copy_from_slice(nonce.as_ref()); + + Ok(()) + } +} + +impl sealed::Sealed for NonceRandom<'_> {} + +struct NonceRandomKey(digest::Digest); + +impl NonceRandomKey { + fn new( + alg: &EcdsaSigningAlgorithm, + seed: &ec::Seed, + rng: &dyn rand::SecureRandom, + ) -> Result { + let mut rand = [0; digest::MAX_OUTPUT_LEN]; + let rand = &mut rand[0..alg.curve.elem_scalar_seed_len]; + + // XXX: `KeyRejected` isn't the right way to model failure of the RNG, + // but to fix that we'd need to break the API by changing the result type. + // TODO: Fix the API in the next breaking release. + rng.fill(rand) + .map_err(|error::Unspecified| error::KeyRejected::rng_failed())?; + + let mut ctx = digest::Context::new(alg.digest_alg); + ctx.update(rand); + ctx.update(seed.bytes_less_safe()); + Ok(Self(ctx.finish())) + } +} + +impl signature::KeyPair for EcdsaKeyPair { + type PublicKey = PublicKey; + + fn public_key(&self) -> &Self::PublicKey { + &self.public_key + } +} + +#[derive(Clone, Copy)] +pub struct PublicKey(ec::PublicKey); + +derive_debug_self_as_ref_hex_bytes!(PublicKey); + +impl AsRef<[u8]> for PublicKey { + fn as_ref(&self) -> &[u8] { + self.0.as_ref() + } +} + +fn format_rs_fixed(ops: &'static ScalarOps, r: &Scalar, s: &Scalar, out: &mut [u8]) -> usize { + let scalar_len = ops.scalar_bytes_len(); + + let (r_out, rest) = out.split_at_mut(scalar_len); + limb::big_endian_from_limbs(ops.leak_limbs(r), r_out); + + let (s_out, _) = rest.split_at_mut(scalar_len); + limb::big_endian_from_limbs(ops.leak_limbs(s), s_out); + + 2 * scalar_len +} + +fn format_rs_asn1(ops: &'static ScalarOps, r: &Scalar, s: &Scalar, out: &mut [u8]) -> usize { + // This assumes `a` is not zero since neither `r` or `s` is allowed to be + // zero. + fn format_integer_tlv(ops: &ScalarOps, a: &Scalar, out: &mut [u8]) -> usize { + let mut fixed = [0u8; ec::SCALAR_MAX_BYTES + 1]; + let fixed = &mut fixed[..(ops.scalar_bytes_len() + 1)]; + limb::big_endian_from_limbs(ops.leak_limbs(a), &mut fixed[1..]); + + // Since `a_fixed_out` is an extra byte long, it is guaranteed to start + // with a zero. + debug_assert_eq!(fixed[0], 0); + + // There must be at least one non-zero byte since `a` isn't zero. + let first_index = fixed.iter().position(|b| *b != 0).unwrap(); + + // If the first byte has its high bit set, it needs to be prefixed with 0x00. + let first_index = if fixed[first_index] & 0x80 != 0 { + first_index - 1 + } else { + first_index + }; + let value = &fixed[first_index..]; + + out[0] = der::Tag::Integer.into(); + + // Lengths less than 128 are encoded in one byte. + assert!(value.len() < 128); + #[allow(clippy::cast_possible_truncation)] + { + out[1] = value.len() as u8; + } + + out[2..][..value.len()].copy_from_slice(value); + + 2 + value.len() + } + + out[0] = der::Tag::Sequence.into(); + let r_tlv_len = format_integer_tlv(ops, r, &mut out[2..]); + let s_tlv_len = format_integer_tlv(ops, s, &mut out[2..][r_tlv_len..]); + + // Lengths less than 128 are encoded in one byte. + let value_len = r_tlv_len + s_tlv_len; + assert!(value_len < 128); + #[allow(clippy::cast_possible_truncation)] + { + out[1] = value_len as u8; + } + + 2 + value_len +} + +/// Signing of fixed-length (PKCS#11 style) ECDSA signatures using the +/// P-256 curve and SHA-256. +/// +/// See "`ECDSA_*_FIXED` Details" in `ring::signature`'s module-level +/// documentation for more details. +pub static ECDSA_P256_SHA256_FIXED_SIGNING: EcdsaSigningAlgorithm = EcdsaSigningAlgorithm { + curve: &ec::suite_b::curve::P256, + private_scalar_ops: &p256::PRIVATE_SCALAR_OPS, + private_key_ops: &p256::PRIVATE_KEY_OPS, + digest_alg: &digest::SHA256, + pkcs8_template: &EC_PUBLIC_KEY_P256_PKCS8_V1_TEMPLATE, + format_rs: format_rs_fixed, + id: AlgorithmID::ECDSA_P256_SHA256_FIXED_SIGNING, +}; + +/// Signing of fixed-length (PKCS#11 style) ECDSA signatures using the +/// P-384 curve and SHA-384. +/// +/// See "`ECDSA_*_FIXED` Details" in `ring::signature`'s module-level +/// documentation for more details. +pub static ECDSA_P384_SHA384_FIXED_SIGNING: EcdsaSigningAlgorithm = EcdsaSigningAlgorithm { + curve: &ec::suite_b::curve::P384, + private_scalar_ops: &p384::PRIVATE_SCALAR_OPS, + private_key_ops: &p384::PRIVATE_KEY_OPS, + digest_alg: &digest::SHA384, + pkcs8_template: &EC_PUBLIC_KEY_P384_PKCS8_V1_TEMPLATE, + format_rs: format_rs_fixed, + id: AlgorithmID::ECDSA_P384_SHA384_FIXED_SIGNING, +}; + +/// Signing of ASN.1 DER-encoded ECDSA signatures using the P-256 curve and +/// SHA-256. +/// +/// See "`ECDSA_*_ASN1` Details" in `ring::signature`'s module-level +/// documentation for more details. +pub static ECDSA_P256_SHA256_ASN1_SIGNING: EcdsaSigningAlgorithm = EcdsaSigningAlgorithm { + curve: &ec::suite_b::curve::P256, + private_scalar_ops: &p256::PRIVATE_SCALAR_OPS, + private_key_ops: &p256::PRIVATE_KEY_OPS, + digest_alg: &digest::SHA256, + pkcs8_template: &EC_PUBLIC_KEY_P256_PKCS8_V1_TEMPLATE, + format_rs: format_rs_asn1, + id: AlgorithmID::ECDSA_P256_SHA256_ASN1_SIGNING, +}; + +/// Signing of ASN.1 DER-encoded ECDSA signatures using the P-384 curve and +/// SHA-384. +/// +/// See "`ECDSA_*_ASN1` Details" in `ring::signature`'s module-level +/// documentation for more details. +pub static ECDSA_P384_SHA384_ASN1_SIGNING: EcdsaSigningAlgorithm = EcdsaSigningAlgorithm { + curve: &ec::suite_b::curve::P384, + private_scalar_ops: &p384::PRIVATE_SCALAR_OPS, + private_key_ops: &p384::PRIVATE_KEY_OPS, + digest_alg: &digest::SHA384, + pkcs8_template: &EC_PUBLIC_KEY_P384_PKCS8_V1_TEMPLATE, + format_rs: format_rs_asn1, + id: AlgorithmID::ECDSA_P384_SHA384_ASN1_SIGNING, +}; + +static EC_PUBLIC_KEY_P256_PKCS8_V1_TEMPLATE: pkcs8::Template = pkcs8::Template { + bytes: include_bytes!("ecPublicKey_p256_pkcs8_v1_template.der"), + alg_id_range: core::ops::Range { start: 8, end: 27 }, + curve_id_index: 9, + private_key_index: 0x24, +}; + +static EC_PUBLIC_KEY_P384_PKCS8_V1_TEMPLATE: pkcs8::Template = pkcs8::Template { + bytes: include_bytes!("ecPublicKey_p384_pkcs8_v1_template.der"), + alg_id_range: core::ops::Range { start: 8, end: 24 }, + curve_id_index: 9, + private_key_index: 0x23, +}; + +#[cfg(test)] +mod tests { + use crate::testutil as test; + use crate::{rand, signature}; + + #[test] + fn signature_ecdsa_sign_fixed_test() { + let rng = rand::SystemRandom::new(); + + test::run( + test_vector_file!("ecdsa_sign_fixed_tests.txt"), + |section, test_case| { + assert_eq!(section, ""); + + let curve_name = test_case.consume_string("Curve"); + let digest_name = test_case.consume_string("Digest"); + let msg = test_case.consume_bytes("Msg"); + let d = test_case.consume_bytes("d"); + let q = test_case.consume_bytes("Q"); + let k = test_case.consume_bytes("k"); + + let expected_result = test_case.consume_bytes("Sig"); + + let alg = match (curve_name.as_str(), digest_name.as_str()) { + ("P-256", "SHA256") => &signature::ECDSA_P256_SHA256_FIXED_SIGNING, + ("P-384", "SHA384") => &signature::ECDSA_P384_SHA384_FIXED_SIGNING, + _ => { + panic!("Unsupported curve+digest: {}+{}", curve_name, digest_name); + } + }; + + let private_key = + signature::EcdsaKeyPair::from_private_key_and_public_key(alg, &d, &q, &rng) + .unwrap(); + let rng = test::rand::FixedSliceRandom { bytes: &k }; + + let actual_result = private_key + .sign_with_fixed_nonce_during_test(&rng, &msg) + .unwrap(); + + assert_eq!(actual_result.as_ref(), &expected_result[..]); + + Ok(()) + }, + ); + } + + #[test] + fn signature_ecdsa_sign_asn1_test() { + let rng = rand::SystemRandom::new(); + + test::run( + test_vector_file!("ecdsa_sign_asn1_tests.txt"), + |section, test_case| { + assert_eq!(section, ""); + + let curve_name = test_case.consume_string("Curve"); + let digest_name = test_case.consume_string("Digest"); + let msg = test_case.consume_bytes("Msg"); + let d = test_case.consume_bytes("d"); + let q = test_case.consume_bytes("Q"); + let k = test_case.consume_bytes("k"); + + let expected_result = test_case.consume_bytes("Sig"); + + let alg = match (curve_name.as_str(), digest_name.as_str()) { + ("P-256", "SHA256") => &signature::ECDSA_P256_SHA256_ASN1_SIGNING, + ("P-384", "SHA384") => &signature::ECDSA_P384_SHA384_ASN1_SIGNING, + _ => { + panic!("Unsupported curve+digest: {}+{}", curve_name, digest_name); + } + }; + + let private_key = + signature::EcdsaKeyPair::from_private_key_and_public_key(alg, &d, &q, &rng) + .unwrap(); + let rng = test::rand::FixedSliceRandom { bytes: &k }; + + let actual_result = private_key + .sign_with_fixed_nonce_during_test(&rng, &msg) + .unwrap(); + + assert_eq!(actual_result.as_ref(), &expected_result[..]); + + Ok(()) + }, + ); + } +} diff --git a/http/vendor/ring/src/ec/suite_b/ecdsa/verification.rs b/http/vendor/ring/src/ec/suite_b/ecdsa/verification.rs new file mode 100644 index 0000000..e500831 --- /dev/null +++ b/http/vendor/ring/src/ec/suite_b/ecdsa/verification.rs @@ -0,0 +1,332 @@ +// Copyright 2015-2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! ECDSA Signatures using the P-256 and P-384 curves. + +use super::digest_scalar::digest_scalar; +use crate::{ + arithmetic::montgomery::*, + cpu, digest, + ec::suite_b::{ops::*, public_key::*, verify_jacobian_point_is_on_the_curve}, + error, + io::der, + limb, sealed, signature, +}; + +/// An ECDSA verification algorithm. +pub struct EcdsaVerificationAlgorithm { + ops: &'static PublicScalarOps, + digest_alg: &'static digest::Algorithm, + split_rs: + for<'a> fn( + ops: &'static ScalarOps, + input: &mut untrusted::Reader<'a>, + ) + -> Result<(untrusted::Input<'a>, untrusted::Input<'a>), error::Unspecified>, + id: AlgorithmID, +} + +#[derive(Debug)] +enum AlgorithmID { + ECDSA_P256_SHA256_ASN1, + ECDSA_P256_SHA256_FIXED, + ECDSA_P256_SHA384_ASN1, + ECDSA_P384_SHA256_ASN1, + ECDSA_P384_SHA384_ASN1, + ECDSA_P384_SHA384_FIXED, +} + +derive_debug_via_id!(EcdsaVerificationAlgorithm); + +impl signature::VerificationAlgorithm for EcdsaVerificationAlgorithm { + fn verify( + &self, + public_key: untrusted::Input, + msg: untrusted::Input, + signature: untrusted::Input, + ) -> Result<(), error::Unspecified> { + let cpu = cpu::features(); + let e = { + // NSA Guide Step 2: "Use the selected hash function to compute H = + // Hash(M)." + let h = digest::digest(self.digest_alg, msg.as_slice_less_safe()); + + // NSA Guide Step 3: "Convert the bit string H to an integer e as + // described in Appendix B.2." + let n = &self.ops.scalar_ops.scalar_modulus(cpu); + digest_scalar(n, h) + }; + + self.verify_digest(public_key, e, signature) + } +} + +impl EcdsaVerificationAlgorithm { + /// This is intentionally not public. + fn verify_digest( + &self, + public_key: untrusted::Input, + e: Scalar, + signature: untrusted::Input, + ) -> Result<(), error::Unspecified> { + let cpu = cpu::features(); + + // NSA Suite B Implementer's Guide to ECDSA Section 3.4.2. + + let public_key_ops = self.ops.public_key_ops; + let scalar_ops = self.ops.scalar_ops; + let q = &public_key_ops.common.elem_modulus(cpu); + let n = &scalar_ops.scalar_modulus(cpu); + + // NSA Guide Prerequisites: + // + // Prior to accepting a verified digital signature as valid the + // verifier shall have: + // + // 1. assurance of the signatory’s claimed identity, + // 2. an authentic copy of the domain parameters, (q, FR, a, b, SEED, + // G, n, h), + // 3. assurance of the validity of the public key, and + // 4. assurance that the claimed signatory actually possessed the + // private key that was used to generate the digital signature at + // the time that the signature was generated. + // + // Prerequisites #1 and #4 are outside the scope of what this function + // can do. Prerequisite #2 is handled implicitly as the domain + // parameters are hard-coded into the source. Prerequisite #3 is + // handled by `parse_uncompressed_point`. + let peer_pub_key = parse_uncompressed_point(public_key_ops, q, public_key)?; + + let (r, s) = signature.read_all(error::Unspecified, |input| { + (self.split_rs)(scalar_ops, input) + })?; + + // NSA Guide Step 1: "If r and s are not both integers in the interval + // [1, n − 1], output INVALID." + let r = scalar_parse_big_endian_variable(n, limb::AllowZero::No, r)?; + let s = scalar_parse_big_endian_variable(n, limb::AllowZero::No, s)?; + + // NSA Guide Step 4: "Compute w = s**−1 mod n, using the routine in + // Appendix B.1." + let w = self.ops.scalar_inv_to_mont_vartime(&s, cpu); + + // NSA Guide Step 5: "Compute u1 = (e * w) mod n, and compute + // u2 = (r * w) mod n." + let u1 = scalar_ops.scalar_product(&e, &w, cpu); + let u2 = scalar_ops.scalar_product(&r, &w, cpu); + + // NSA Guide Step 6: "Compute the elliptic curve point + // R = (xR, yR) = u1*G + u2*Q, using EC scalar multiplication and EC + // addition. If R is equal to the point at infinity, output INVALID." + let product = (self.ops.twin_mul)(&u1, &u2, &peer_pub_key, cpu); + + // Verify that the point we computed is on the curve; see + // `verify_affine_point_is_on_the_curve_scaled` for details on why. It + // would be more secure to do the check on the affine coordinates if we + // were going to convert to affine form (again, see + // `verify_affine_point_is_on_the_curve_scaled` for details on why). + // But, we're going to avoid converting to affine for performance + // reasons, so we do the verification using the Jacobian coordinates. + let z2 = verify_jacobian_point_is_on_the_curve(q, &product)?; + + // NSA Guide Step 7: "Compute v = xR mod n." + // NSA Guide Step 8: "Compare v and r0. If v = r0, output VALID; + // otherwise, output INVALID." + // + // Instead, we use Greg Maxwell's trick to avoid the inversion mod `q` + // that would be necessary to compute the affine X coordinate. + let x = q.point_x(&product); + fn sig_r_equals_x(q: &Modulus, r: &Elem, x: &Elem, z2: &Elem) -> bool { + let r_jacobian = q.elem_product(z2, r); + let x = q.elem_unencoded(x); + q.elems_are_equal(&r_jacobian, &x).leak() + } + let mut r = self.ops.scalar_as_elem(&r); + if sig_r_equals_x(q, &r, &x, &z2) { + return Ok(()); + } + if q.elem_less_than_vartime(&r, &self.ops.q_minus_n) { + let n = Elem::from(self.ops.n()); + q.add_assign(&mut r, &n); + if sig_r_equals_x(q, &r, &x, &z2) { + return Ok(()); + } + } + + Err(error::Unspecified) + } +} + +impl sealed::Sealed for EcdsaVerificationAlgorithm {} + +fn split_rs_fixed<'a>( + ops: &'static ScalarOps, + input: &mut untrusted::Reader<'a>, +) -> Result<(untrusted::Input<'a>, untrusted::Input<'a>), error::Unspecified> { + let scalar_len = ops.scalar_bytes_len(); + let r = input.read_bytes(scalar_len)?; + let s = input.read_bytes(scalar_len)?; + Ok((r, s)) +} + +fn split_rs_asn1<'a>( + _ops: &'static ScalarOps, + input: &mut untrusted::Reader<'a>, +) -> Result<(untrusted::Input<'a>, untrusted::Input<'a>), error::Unspecified> { + der::nested(input, der::Tag::Sequence, error::Unspecified, |input| { + let r = der::positive_integer(input)?.big_endian_without_leading_zero_as_input(); + let s = der::positive_integer(input)?.big_endian_without_leading_zero_as_input(); + Ok((r, s)) + }) +} + +/// Verification of fixed-length (PKCS#11 style) ECDSA signatures using the +/// P-256 curve and SHA-256. +/// +/// See "`ECDSA_*_FIXED` Details" in `ring::signature`'s module-level +/// documentation for more details. +pub static ECDSA_P256_SHA256_FIXED: EcdsaVerificationAlgorithm = EcdsaVerificationAlgorithm { + ops: &p256::PUBLIC_SCALAR_OPS, + digest_alg: &digest::SHA256, + split_rs: split_rs_fixed, + id: AlgorithmID::ECDSA_P256_SHA256_FIXED, +}; + +/// Verification of fixed-length (PKCS#11 style) ECDSA signatures using the +/// P-384 curve and SHA-384. +/// +/// See "`ECDSA_*_FIXED` Details" in `ring::signature`'s module-level +/// documentation for more details. +pub static ECDSA_P384_SHA384_FIXED: EcdsaVerificationAlgorithm = EcdsaVerificationAlgorithm { + ops: &p384::PUBLIC_SCALAR_OPS, + digest_alg: &digest::SHA384, + split_rs: split_rs_fixed, + id: AlgorithmID::ECDSA_P384_SHA384_FIXED, +}; + +/// Verification of ASN.1 DER-encoded ECDSA signatures using the P-256 curve +/// and SHA-256. +/// +/// See "`ECDSA_*_ASN1` Details" in `ring::signature`'s module-level +/// documentation for more details. +pub static ECDSA_P256_SHA256_ASN1: EcdsaVerificationAlgorithm = EcdsaVerificationAlgorithm { + ops: &p256::PUBLIC_SCALAR_OPS, + digest_alg: &digest::SHA256, + split_rs: split_rs_asn1, + id: AlgorithmID::ECDSA_P256_SHA256_ASN1, +}; + +/// *Not recommended*. Verification of ASN.1 DER-encoded ECDSA signatures using +/// the P-256 curve and SHA-384. +/// +/// In most situations, P-256 should be used only with SHA-256 and P-384 +/// should be used only with SHA-384. However, in some cases, particularly TLS +/// on the web, it is necessary to support P-256 with SHA-384 for compatibility +/// with widely-deployed implementations that do not follow these guidelines. +/// +/// See "`ECDSA_*_ASN1` Details" in `ring::signature`'s module-level +/// documentation for more details. +pub static ECDSA_P256_SHA384_ASN1: EcdsaVerificationAlgorithm = EcdsaVerificationAlgorithm { + ops: &p256::PUBLIC_SCALAR_OPS, + digest_alg: &digest::SHA384, + split_rs: split_rs_asn1, + id: AlgorithmID::ECDSA_P256_SHA384_ASN1, +}; + +/// *Not recommended*. Verification of ASN.1 DER-encoded ECDSA signatures using +/// the P-384 curve and SHA-256. +/// +/// In most situations, P-256 should be used only with SHA-256 and P-384 +/// should be used only with SHA-384. However, in some cases, particularly TLS +/// on the web, it is necessary to support P-256 with SHA-384 for compatibility +/// with widely-deployed implementations that do not follow these guidelines. +/// +/// See "`ECDSA_*_ASN1` Details" in `ring::signature`'s module-level +/// documentation for more details. +pub static ECDSA_P384_SHA256_ASN1: EcdsaVerificationAlgorithm = EcdsaVerificationAlgorithm { + ops: &p384::PUBLIC_SCALAR_OPS, + digest_alg: &digest::SHA256, + split_rs: split_rs_asn1, + id: AlgorithmID::ECDSA_P384_SHA256_ASN1, +}; + +/// Verification of ASN.1 DER-encoded ECDSA signatures using the P-384 curve +/// and SHA-384. +/// +/// See "`ECDSA_*_ASN1` Details" in `ring::signature`'s module-level +/// documentation for more details. +pub static ECDSA_P384_SHA384_ASN1: EcdsaVerificationAlgorithm = EcdsaVerificationAlgorithm { + ops: &p384::PUBLIC_SCALAR_OPS, + digest_alg: &digest::SHA384, + split_rs: split_rs_asn1, + id: AlgorithmID::ECDSA_P384_SHA384_ASN1, +}; + +#[cfg(test)] +mod tests { + extern crate alloc; + use super::*; + use crate::testutil as test; + use alloc::{vec, vec::Vec}; + + #[test] + fn test_digest_based_test_vectors() { + let cpu = cpu::features(); + test::run( + test_vector_file!("../../../../crypto/fipsmodule/ecdsa/ecdsa_verify_tests.txt"), + |section, test_case| { + assert_eq!(section, ""); + + let curve_name = test_case.consume_string("Curve"); + + let public_key = { + let mut public_key = vec![0x04]; + public_key.extend(&test_case.consume_bytes("X")); + public_key.extend(&test_case.consume_bytes("Y")); + public_key + }; + + let digest = test_case.consume_bytes("Digest"); + + let sig = { + let mut sig = Vec::new(); + sig.extend(&test_case.consume_bytes("R")); + sig.extend(&test_case.consume_bytes("S")); + sig + }; + + let invalid = test_case.consume_optional_string("Invalid"); + + let alg = match curve_name.as_str() { + "P-256" => &ECDSA_P256_SHA256_FIXED, + "P-384" => &ECDSA_P384_SHA384_FIXED, + _ => { + panic!("Unsupported curve: {}", curve_name); + } + }; + let n = &alg.ops.scalar_ops.scalar_modulus(cpu); + + let digest = super::super::digest_scalar::digest_bytes_scalar(n, &digest[..]); + let actual_result = alg.verify_digest( + untrusted::Input::from(&public_key[..]), + digest, + untrusted::Input::from(&sig[..]), + ); + assert_eq!(actual_result.is_ok(), invalid.is_none()); + + Ok(()) + }, + ); + } +} diff --git a/http/vendor/ring/src/ec/suite_b/ops.rs b/http/vendor/ring/src/ec/suite_b/ops.rs new file mode 100644 index 0000000..7c2ed7f --- /dev/null +++ b/http/vendor/ring/src/ec/suite_b/ops.rs @@ -0,0 +1,1406 @@ +// Copyright 2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use crate::{ + arithmetic::limbs_from_hex, + arithmetic::montgomery::*, + bb::LeakyWord, + cpu, + error::{self, LenMismatchError}, + limb::*, +}; +use core::marker::PhantomData; + +use elem::{mul_mont, unary_op, unary_op_assign, unary_op_from_binary_op_assign}; + +/// A field element, i.e. an element of ℤ/qℤ for the curve's field modulus +/// *q*. +pub type Elem = elem::Elem; +type PublicElem = elem::PublicElem; + +/// Represents the (prime) order *q* of the curve's prime field. +#[derive(Clone, Copy)] +pub enum Q {} + +/// A scalar. Its value is in [0, n). Zero-valued scalars are forbidden in most +/// contexts. +pub type Scalar = elem::Elem; +type PublicScalar = elem::PublicElem; + +/// Represents the prime order *n* of the curve's group. +#[derive(Clone, Copy)] +pub enum N {} + +pub(super) struct Modulus { + // TODO: [Limb; elem::NumLimbs::MAX] + limbs: &'static [Limb; elem::NumLimbs::MAX], + num_limbs: elem::NumLimbs, + cops: &'static CommonOps, + m: PhantomData, + cpu: cpu::Features, +} + +pub struct Point { + // The coordinates are stored in a contiguous array, where the first + // `ops.num_limbs` elements are the X coordinate, the next + // `ops.num_limbs` elements are the Y coordinate, and the next + // `ops.num_limbs` elements are the Z coordinate. This layout is dictated + // by the requirements of the nistz256 code. + xyz: [Limb; 3 * elem::NumLimbs::MAX], +} + +impl Point { + pub fn new_at_infinity() -> Self { + Self { + xyz: [0; 3 * elem::NumLimbs::MAX], + } + } +} + +/// Operations and values needed by all curve operations. +pub struct CommonOps { + num_limbs: elem::NumLimbs, + q: PublicModulus, + n: PublicElem, + + pub a: PublicElem, // Must be -3 mod q + pub b: PublicElem, + + // In all cases, `r`, `a`, and `b` may all alias each other. + elem_mul_mont: unsafe extern "C" fn(r: *mut Limb, a: *const Limb, b: *const Limb), + elem_sqr_mont: unsafe extern "C" fn(r: *mut Limb, a: *const Limb), +} + +impl CommonOps { + pub(super) fn elem_modulus(&'static self, cpu_features: cpu::Features) -> Modulus { + Modulus { + // TODO: limbs: self.q.p.map(Limb::from), + limbs: &self.q.p, + num_limbs: self.num_limbs, + cops: self, + m: PhantomData, + cpu: cpu_features, + } + } + + pub(super) fn scalar_modulus(&'static self, cpu_features: cpu::Features) -> Modulus { + Modulus { + // TODO: limbs: self.n.limbs.map(Limb::from), + limbs: &self.n.limbs, + num_limbs: self.num_limbs, + cops: self, + m: PhantomData, + cpu: cpu_features, + } + } + + // The length of a field element, which is the same as the length of a + // scalar, in bytes. + pub fn len(&self) -> usize { + // Keep in sync with `Modulus::len()` + self.num_limbs.into() * LIMB_BYTES + } + + #[cfg(test)] + pub(super) fn n_limbs(&self) -> &[Limb] { + &self.n.limbs[..self.num_limbs.into()] + } +} + +impl Modulus { + pub fn cpu(&self) -> cpu::Features { + self.cpu + } + + // Keep in sync with `CommonOps::len()`. + pub fn bytes_len(&self) -> usize { + self.num_limbs.into() * LIMB_BYTES + } +} + +impl Modulus { + #[inline] + pub fn add_assign(&self, a: &mut elem::Elem, b: &elem::Elem) { + let num_limbs = self.num_limbs.into(); + limbs_add_assign_mod( + &mut a.limbs[..num_limbs], + &b.limbs[..num_limbs], + &self.limbs[..num_limbs], + ) + .unwrap_or_else(unwrap_impossible_len_mismatch_error) + } +} + +impl Modulus { + #[inline] + pub fn elems_are_equal(&self, a: &Elem, b: &Elem) -> LimbMask { + let num_limbs = self.num_limbs.into(); + limbs_equal_limbs_consttime(&a.limbs[..num_limbs], &b.limbs[..num_limbs]) + .unwrap_or_else(unwrap_impossible_len_mismatch_error) + } + + #[inline] + pub fn elem_unencoded(&self, a: &Elem) -> Elem { + self.elem_product(a, &Elem::one()) + } +} + +impl CommonOps { + #[inline] + fn is_zero(&self, a: &elem::Elem) -> bool { + let num_limbs = self.num_limbs.into(); + limbs_are_zero(&a.limbs[..num_limbs]).leak() + } + + #[inline] + fn elem_mul(&self, a: &mut Elem, b: &Elem, _cpu: cpu::Features) { + elem::binary_op_assign(self.elem_mul_mont, a, b) + } + + #[inline] + fn elem_product( + &self, + a: &Elem, + b: &Elem, + _cpu: cpu::Features, + ) -> Elem<<(EA, EB) as ProductEncoding>::Output> + where + (EA, EB): ProductEncoding, + { + mul_mont(self.elem_mul_mont, a, b) + } + + #[inline] + fn elem_square(&self, a: &mut Elem, _cpu: cpu::Features) { + unary_op_assign(self.elem_sqr_mont, a); + } + + #[inline] + fn elem_squared(&self, a: &Elem, _cpu: cpu::Features) -> Elem { + unary_op(self.elem_sqr_mont, a) + } +} + +impl Modulus { + #[inline] + pub fn elem_mul(&self, a: &mut Elem, b: &Elem) { + self.cops.elem_mul(a, b, self.cpu) + } + + #[inline] + pub fn elem_product( + &self, + a: &Elem, + b: &Elem, + ) -> Elem<<(EA, EB) as ProductEncoding>::Output> + where + (EA, EB): ProductEncoding, + { + self.cops.elem_product(a, b, self.cpu) + } + + #[inline] + pub fn elem_square(&self, a: &mut Elem) { + self.cops.elem_square(a, self.cpu) + } + + #[inline] + pub fn elem_squared(&self, a: &Elem) -> Elem { + self.cops.elem_squared(a, self.cpu) + } +} + +impl Modulus { + #[inline] + pub fn is_zero(&self, a: &elem::Elem) -> bool { + self.cops.is_zero(a) + } +} + +impl Modulus { + pub fn elem_verify_is_not_zero(&self, a: &Elem) -> Result<(), error::Unspecified> { + if self.is_zero(a) { + Err(error::Unspecified) + } else { + Ok(()) + } + } + + pub(super) fn a(&self) -> &'static PublicElem { + &self.cops.a + } + pub(super) fn b(&self) -> &'static PublicElem { + &self.cops.b + } +} + +impl PrivateKeyOps { + pub(super) fn point_sum(&self, a: &Point, b: &Point, _cpu: cpu::Features) -> Point { + let mut r = Point::new_at_infinity(); + unsafe { + (self.point_add_jacobian_impl)(r.xyz.as_mut_ptr(), a.xyz.as_ptr(), b.xyz.as_ptr()) + } + r + } +} + +impl Modulus { + pub fn point_x(&self, p: &Point) -> Elem { + let num_limbs = self.num_limbs.into(); + let mut r = Elem::zero(); + r.limbs[..num_limbs].copy_from_slice(&p.xyz[0..num_limbs]); + r + } + + pub fn point_y(&self, p: &Point) -> Elem { + let num_limbs = self.num_limbs.into(); + let mut r = Elem::zero(); + r.limbs[..num_limbs].copy_from_slice(&p.xyz[num_limbs..(2 * num_limbs)]); + r + } + + pub fn point_z(&self, p: &Point) -> Elem { + let num_limbs = self.num_limbs.into(); + let mut r = Elem::zero(); + r.limbs[..num_limbs].copy_from_slice(&p.xyz[(2 * num_limbs)..(3 * num_limbs)]); + r + } +} + +struct PublicModulus { + p: [LeakyLimb; elem::NumLimbs::MAX], + rr: PublicElem, +} + +/// Operations on private keys, for ECDH and ECDSA signing. +pub struct PrivateKeyOps { + pub common: &'static CommonOps, + elem_inv_squared: fn(q: &Modulus, a: &Elem) -> Elem, + point_mul_base_impl: fn(a: &Scalar, cpu: cpu::Features) -> Point, + point_mul_impl: unsafe extern "C" fn( + r: *mut Limb, // [3][num_limbs] + p_scalar: *const Limb, // [num_limbs] + p_x: *const Limb, // [num_limbs] + p_y: *const Limb, // [num_limbs] + ), + point_add_jacobian_impl: unsafe extern "C" fn(r: *mut Limb, a: *const Limb, b: *const Limb), +} + +impl PrivateKeyOps { + pub fn leak_limbs<'a>(&self, a: &'a Elem) -> &'a [Limb] { + &a.limbs[..self.common.num_limbs.into()] + } + + #[inline(always)] + pub(super) fn point_mul_base(&self, a: &Scalar, cpu: cpu::Features) -> Point { + (self.point_mul_base_impl)(a, cpu) + } + + #[inline(always)] + pub(super) fn point_mul( + &self, + p_scalar: &Scalar, + (p_x, p_y): &(Elem, Elem), + _cpu: cpu::Features, + ) -> Point { + let mut r = Point::new_at_infinity(); + unsafe { + (self.point_mul_impl)( + r.xyz.as_mut_ptr(), + p_scalar.limbs.as_ptr(), + p_x.limbs.as_ptr(), + p_y.limbs.as_ptr(), + ); + } + r + } + + #[inline] + pub(super) fn elem_inverse_squared(&self, q: &Modulus, a: &Elem) -> Elem { + (self.elem_inv_squared)(q, a) + } +} + +/// Operations and values needed by all operations on public keys (ECDH +/// agreement and ECDSA verification). +pub struct PublicKeyOps { + pub common: &'static CommonOps, +} + +impl PublicKeyOps { + // The serialized bytes are in big-endian order, zero-padded. The limbs + // of `Elem` are in the native endianness, least significant limb to + // most significant limb. Besides the parsing, conversion, this also + // implements NIST SP 800-56A Step 2: "Verify that xQ and yQ are integers + // in the interval [0, p-1] in the case that q is an odd prime p[.]" + pub(super) fn elem_parse( + &self, + q: &Modulus, + input: &mut untrusted::Reader, + ) -> Result, error::Unspecified> { + let _cpu = cpu::features(); + let encoded_value = input.read_bytes(self.common.len())?; + let parsed = elem_parse_big_endian_fixed_consttime(q, encoded_value)?; + let mut r = Elem::zero(); + let rr = Elem::from(&self.common.q.rr); + // Montgomery encode (elem_to_mont). + // TODO: do something about this. + unsafe { + (self.common.elem_mul_mont)( + r.limbs.as_mut_ptr(), + parsed.limbs.as_ptr(), + rr.limbs.as_ptr(), + ) + } + Ok(r) + } +} + +// Operations used by both ECDSA signing and ECDSA verification. In general +// these must be side-channel resistant. +pub struct ScalarOps { + pub common: &'static CommonOps, + + scalar_mul_mont: unsafe extern "C" fn(r: *mut Limb, a: *const Limb, b: *const Limb), +} + +impl ScalarOps { + pub(super) fn scalar_modulus(&'static self, cpu_features: cpu::Features) -> Modulus { + self.common.scalar_modulus(cpu_features) + } + + // The (maximum) length of a scalar, not including any padding. + pub fn scalar_bytes_len(&self) -> usize { + self.common.len() + } +} + +impl ScalarOps { + pub fn leak_limbs<'s>(&self, s: &'s Scalar) -> &'s [Limb] { + &s.limbs[..self.common.num_limbs.into()] + } + + #[inline] + pub(super) fn scalar_product( + &self, + a: &Scalar, + b: &Scalar, + _cpu: cpu::Features, + ) -> Scalar<<(EA, EB) as ProductEncoding>::Output> + where + (EA, EB): ProductEncoding, + { + mul_mont(self.scalar_mul_mont, a, b) + } +} + +/// Operations on public scalars needed by ECDSA signature verification. +pub struct PublicScalarOps { + pub scalar_ops: &'static ScalarOps, + pub public_key_ops: &'static PublicKeyOps, + + pub(super) twin_mul: fn( + g_scalar: &Scalar, + p_scalar: &Scalar, + p_xy: &(Elem, Elem), + cpu: cpu::Features, + ) -> Point, + scalar_inv_to_mont_vartime: fn(s: &Scalar, cpu: cpu::Features) -> Scalar, + pub(super) q_minus_n: PublicElem, +} + +impl PublicScalarOps { + pub fn n(&self) -> &PublicElem { + &self.scalar_ops.common.n + } + + #[inline] + pub fn scalar_as_elem(&self, a: &Scalar) -> Elem { + Elem { + limbs: a.limbs, + m: PhantomData, + encoding: PhantomData, + } + } +} + +impl Modulus { + pub fn elem_less_than_vartime(&self, a: &Elem, b: &PublicElem) -> bool { + let num_limbs = self.num_limbs.into(); + limbs_less_than_limbs_vartime(&a.limbs[..num_limbs], &b.limbs[..num_limbs]) + .unwrap_or_else(|LenMismatchError { .. }| unreachable!()) + } +} + +impl PublicScalarOps { + pub(super) fn scalar_inv_to_mont_vartime( + &self, + s: &Scalar, + cpu: cpu::Features, + ) -> Scalar { + (self.scalar_inv_to_mont_vartime)(s, cpu) + } +} + +#[allow(non_snake_case)] +pub struct PrivateScalarOps { + pub scalar_ops: &'static ScalarOps, + + oneRR_mod_n: PublicScalar, // 1 * R**2 (mod n). TOOD: Use One. + scalar_inv_to_mont: fn(a: Scalar, cpu: cpu::Features) -> Scalar, +} + +impl PrivateScalarOps { + pub(super) fn to_mont(&self, s: &Scalar, cpu: cpu::Features) -> Scalar { + self.scalar_ops + .scalar_product(s, &Scalar::from(&self.oneRR_mod_n), cpu) + } + + /// Returns the modular inverse of `a` (mod `n`). Panics if `a` is zero. + pub(super) fn scalar_inv_to_mont(&self, a: &Scalar, cpu: cpu::Features) -> Scalar { + assert!(!self.scalar_ops.common.is_zero(a)); + let a = self.to_mont(a, cpu); + (self.scalar_inv_to_mont)(a, cpu) + } +} + +// XXX: Inefficient and unnecessarily depends on `PrivateKeyOps`. TODO: implement interleaved wNAF +// multiplication. +fn twin_mul_inefficient( + ops: &PrivateKeyOps, + g_scalar: &Scalar, + p_scalar: &Scalar, + p_xy: &(Elem, Elem), + cpu: cpu::Features, +) -> Point { + let scaled_g = ops.point_mul_base(g_scalar, cpu); + let scaled_p = ops.point_mul(p_scalar, p_xy, cpu); + ops.point_sum(&scaled_g, &scaled_p, cpu) +} + +// This assumes n < q < 2*n. +impl Modulus { + pub fn elem_reduced_to_scalar(&self, elem: &Elem) -> Scalar { + let num_limbs = self.num_limbs.into(); + let mut r_limbs = elem.limbs; + limbs_reduce_once(&mut r_limbs[..num_limbs], &self.limbs[..num_limbs]) + .unwrap_or_else(unwrap_impossible_len_mismatch_error); + Scalar { + limbs: r_limbs, + m: PhantomData, + encoding: PhantomData, + } + } +} + +// Returns (`a` squared `squarings` times) * `b`. +fn elem_sqr_mul( + ops: &CommonOps, + a: &Elem, + squarings: LeakyWord, + b: &Elem, + cpu: cpu::Features, +) -> Elem { + debug_assert!(squarings >= 1); + let mut tmp = ops.elem_squared(a, cpu); + for _ in 1..squarings { + ops.elem_square(&mut tmp, cpu); + } + ops.elem_product(&tmp, b, cpu) +} + +// Sets `acc` = (`acc` squared `squarings` times) * `b`. +fn elem_sqr_mul_acc( + ops: &CommonOps, + acc: &mut Elem, + squarings: LeakyWord, + b: &Elem, + cpu: cpu::Features, +) { + debug_assert!(squarings >= 1); + for _ in 0..squarings { + ops.elem_square(acc, cpu); + } + ops.elem_mul(acc, b, cpu) +} + +#[inline] +pub(super) fn elem_parse_big_endian_fixed_consttime( + q: &Modulus, + bytes: untrusted::Input, +) -> Result, error::Unspecified> { + parse_big_endian_fixed_consttime(q, bytes, AllowZero::Yes) +} + +#[inline] +pub(super) fn scalar_parse_big_endian_fixed_consttime( + n: &Modulus, + bytes: untrusted::Input, +) -> Result { + parse_big_endian_fixed_consttime(n, bytes, AllowZero::No) +} + +#[inline] +pub(super) fn scalar_parse_big_endian_variable( + n: &Modulus, + allow_zero: AllowZero, + bytes: untrusted::Input, +) -> Result { + let num_limbs = n.num_limbs.into(); + let mut r = Scalar::zero(); + parse_big_endian_in_range_and_pad_consttime( + bytes, + allow_zero, + &n.limbs[..num_limbs], + &mut r.limbs[..num_limbs], + )?; + Ok(r) +} + +pub(super) fn scalar_parse_big_endian_partially_reduced_variable_consttime( + n: &Modulus, + bytes: untrusted::Input, +) -> Result { + let num_limbs = n.num_limbs.into(); + let mut r = Scalar::zero(); + { + let r = &mut r.limbs[..num_limbs]; + parse_big_endian_and_pad_consttime(bytes, r)?; + limbs_reduce_once(r, &n.limbs[..num_limbs]) + .unwrap_or_else(unwrap_impossible_len_mismatch_error); + } + + Ok(r) +} + +fn parse_big_endian_fixed_consttime( + m: &Modulus, + bytes: untrusted::Input, + allow_zero: AllowZero, +) -> Result, error::Unspecified> { + let num_limbs = m.num_limbs.into(); + if bytes.len() != m.bytes_len() { + return Err(error::Unspecified); + } + let mut r = elem::Elem::zero(); + parse_big_endian_in_range_and_pad_consttime( + bytes, + allow_zero, + &m.limbs[..num_limbs], + &mut r.limbs[..num_limbs], + )?; + Ok(r) +} + +#[cold] +#[inline(never)] +fn unwrap_impossible_len_mismatch_error(LenMismatchError { .. }: LenMismatchError) -> T { + unreachable!() +} + +#[cfg(test)] +mod tests { + extern crate alloc; + use super::*; + use crate::testutil as test; + use alloc::{format, vec, vec::Vec}; + + const ZERO_SCALAR: Scalar = Scalar { + limbs: [0; elem::NumLimbs::MAX], + m: PhantomData, + encoding: PhantomData, + }; + + trait Convert { + fn convert(self, q: &Modulus) -> Elem; + } + + impl Convert for Elem { + fn convert(self, _q: &Modulus) -> Elem { + self + } + } + + impl Convert for Elem { + fn convert(self, q: &Modulus) -> Elem { + q.elem_unencoded(&self) + } + } + + fn q_minus_n_plus_n_equals_0_test(ops: &PublicScalarOps) { + let cops = ops.scalar_ops.common; + let q = &cops.elem_modulus(cpu::features()); + let mut x = Elem::from(&ops.q_minus_n); + q.add_assign(&mut x, &Elem::from(&cops.n)); + assert!(q.is_zero(&x)); + } + + #[test] + fn p256_q_minus_n_plus_n_equals_0_test() { + q_minus_n_plus_n_equals_0_test(&p256::PUBLIC_SCALAR_OPS); + } + + #[test] + fn p384_q_minus_n_plus_n_equals_0_test() { + q_minus_n_plus_n_equals_0_test(&p384::PUBLIC_SCALAR_OPS); + } + + #[test] + fn p256_elem_add_test() { + elem_add_test( + &p256::PUBLIC_SCALAR_OPS, + test_vector_file!("ops/p256_elem_sum_tests.txt"), + ); + } + + #[test] + fn p384_elem_add_test() { + elem_add_test( + &p384::PUBLIC_SCALAR_OPS, + test_vector_file!("ops/p384_elem_sum_tests.txt"), + ); + } + + fn elem_add_test(ops: &PublicScalarOps, test_file: test::File) { + let cops = ops.public_key_ops.common; + let q = &cops.elem_modulus(cpu::features()); + test::run(test_file, |section, test_case| { + assert_eq!(section, ""); + + let a = consume_elem(q, test_case, "a"); + let b = consume_elem(q, test_case, "b"); + let expected_sum = consume_elem(q, test_case, "r"); + + let mut actual_sum = a; + q.add_assign(&mut actual_sum, &b); + assert_limbs_are_equal(cops, &actual_sum.limbs, &expected_sum.limbs); + + let mut actual_sum = b; + q.add_assign(&mut actual_sum, &a); + assert_limbs_are_equal(cops, &actual_sum.limbs, &expected_sum.limbs); + + Ok(()) + }) + } + + // XXX: There's no `p256_sub` in *ring*; it's logic is inlined into + // the point arithmetic functions. Thus, we can't test it. + + #[test] + fn p384_elem_sub_test() { + prefixed_extern! { + fn p384_elem_sub(r: *mut Limb, a: *const Limb, b: *const Limb); + } + elem_sub_test( + &p384::COMMON_OPS, + p384_elem_sub, + test_vector_file!("ops/p384_elem_sum_tests.txt"), + ); + } + + fn elem_sub_test( + ops: &'static CommonOps, + elem_sub: unsafe extern "C" fn(r: *mut Limb, a: *const Limb, b: *const Limb), + test_file: test::File, + ) { + let q = &ops.elem_modulus(cpu::features()); + test::run(test_file, |section, test_case| { + assert_eq!(section, ""); + + let a = consume_elem(q, test_case, "a"); + let b = consume_elem(q, test_case, "b"); + let r = consume_elem(q, test_case, "r"); + + let mut actual_difference = Elem::::zero(); + unsafe { + elem_sub( + actual_difference.limbs.as_mut_ptr(), + r.limbs.as_ptr(), + b.limbs.as_ptr(), + ); + } + assert_limbs_are_equal(ops, &actual_difference.limbs, &a.limbs); + + let mut actual_difference = Elem::::zero(); + unsafe { + elem_sub( + actual_difference.limbs.as_mut_ptr(), + r.limbs.as_ptr(), + a.limbs.as_ptr(), + ); + } + assert_limbs_are_equal(ops, &actual_difference.limbs, &b.limbs); + + Ok(()) + }) + } + + // XXX: There's no `p256_div_by_2` in *ring*; it's logic is inlined + // into the point arithmetic functions. Thus, we can't test it. + + #[test] + fn p384_elem_div_by_2_test() { + prefixed_extern! { + fn p384_elem_div_by_2(r: *mut Limb, a: *const Limb); + } + elem_div_by_2_test( + &p384::COMMON_OPS, + p384_elem_div_by_2, + test_vector_file!("ops/p384_elem_div_by_2_tests.txt"), + ); + } + + fn elem_div_by_2_test( + ops: &'static CommonOps, + elem_div_by_2: unsafe extern "C" fn(r: *mut Limb, a: *const Limb), + test_file: test::File, + ) { + let q = &ops.elem_modulus(cpu::features()); + test::run(test_file, |section, test_case| { + assert_eq!(section, ""); + + let a = consume_elem(q, test_case, "a"); + let r = consume_elem(q, test_case, "r"); + + let mut actual_result = Elem::::zero(); + unsafe { + elem_div_by_2(actual_result.limbs.as_mut_ptr(), a.limbs.as_ptr()); + } + assert_limbs_are_equal(ops, &actual_result.limbs, &r.limbs); + + Ok(()) + }) + } + + // There is no `ecp_nistz256_neg` on other targets. + #[cfg(target_arch = "x86_64")] + #[test] + fn p256_elem_neg_test() { + prefixed_extern! { + fn ecp_nistz256_neg(r: *mut Limb, a: *const Limb); + } + elem_neg_test( + &p256::COMMON_OPS, + ecp_nistz256_neg, + test_vector_file!("ops/p256_elem_neg_tests.txt"), + ); + } + + #[test] + fn p384_elem_neg_test() { + prefixed_extern! { + fn p384_elem_neg(r: *mut Limb, a: *const Limb); + } + elem_neg_test( + &p384::COMMON_OPS, + p384_elem_neg, + test_vector_file!("ops/p384_elem_neg_tests.txt"), + ); + } + + fn elem_neg_test( + ops: &'static CommonOps, + elem_neg: unsafe extern "C" fn(r: *mut Limb, a: *const Limb), + test_file: test::File, + ) { + let q = &ops.elem_modulus(cpu::features()); + test::run(test_file, |section, test_case| { + assert_eq!(section, ""); + + let a = consume_elem(q, test_case, "a"); + let b = consume_elem(q, test_case, "b"); + + // Verify -a == b. + { + let mut actual_result = Elem::::zero(); + unsafe { + elem_neg(actual_result.limbs.as_mut_ptr(), a.limbs.as_ptr()); + } + assert_limbs_are_equal(ops, &actual_result.limbs, &b.limbs); + } + + // Verify -b == a. + { + let mut actual_result = Elem::::zero(); + unsafe { + elem_neg(actual_result.limbs.as_mut_ptr(), b.limbs.as_ptr()); + } + assert_limbs_are_equal(ops, &actual_result.limbs, &a.limbs); + } + + Ok(()) + }) + } + + #[test] + fn p256_elem_mul_test() { + elem_mul_test( + &p256::COMMON_OPS, + test_vector_file!("ops/p256_elem_mul_tests.txt"), + ); + } + + #[test] + fn p384_elem_mul_test() { + elem_mul_test( + &p384::COMMON_OPS, + test_vector_file!("ops/p384_elem_mul_tests.txt"), + ); + } + + fn elem_mul_test(ops: &'static CommonOps, test_file: test::File) { + let q = &ops.elem_modulus(cpu::features()); + test::run(test_file, |section, test_case| { + assert_eq!(section, ""); + + let mut a = consume_elem(q, test_case, "a"); + let b = consume_elem(q, test_case, "b"); + let r = consume_elem(q, test_case, "r"); + q.elem_mul(&mut a, &b); + assert_limbs_are_equal(ops, &a.limbs, &r.limbs); + + Ok(()) + }) + } + + #[test] + fn p256_scalar_mul_test() { + scalar_mul_test( + &p256::SCALAR_OPS, + test_vector_file!("ops/p256_scalar_mul_tests.txt"), + ); + } + + #[test] + fn p384_scalar_mul_test() { + scalar_mul_test( + &p384::SCALAR_OPS, + test_vector_file!("ops/p384_scalar_mul_tests.txt"), + ); + } + + fn scalar_mul_test(ops: &ScalarOps, test_file: test::File) { + let cpu = cpu::features(); + let cops = ops.common; + let n = &cops.scalar_modulus(cpu); + test::run(test_file, |section, test_case| { + assert_eq!(section, ""); + let a = consume_scalar(n, test_case, "a"); + let b = consume_scalar_mont(n, test_case, "b"); + let expected_result = consume_scalar(n, test_case, "r"); + let actual_result = ops.scalar_product(&a, &b, cpu); + assert_limbs_are_equal(cops, &actual_result.limbs, &expected_result.limbs); + + Ok(()) + }) + } + + #[test] + fn p256_scalar_square_test() { + prefixed_extern! { + fn p256_scalar_sqr_rep_mont(r: *mut Limb, a: *const Limb, rep: LeakyWord); + } + scalar_square_test( + &p256::SCALAR_OPS, + p256_scalar_sqr_rep_mont, + test_vector_file!("ops/p256_scalar_square_tests.txt"), + ); + } + + // XXX: There's no `p384_scalar_square_test()` because there's no dedicated + // `p384_scalar_sqr_rep_mont()`. + + fn scalar_square_test( + ops: &ScalarOps, + sqr_rep: unsafe extern "C" fn(r: *mut Limb, a: *const Limb, rep: LeakyWord), + test_file: test::File, + ) { + let cpu = cpu::features(); + let cops = ops.common; + let n = &cops.scalar_modulus(cpu); + test::run(test_file, |section, test_case| { + assert_eq!(section, ""); + let cpu = cpu::features(); + let a = consume_scalar(n, test_case, "a"); + let expected_result = consume_scalar(n, test_case, "r"); + + { + let mut actual_result: Scalar = Scalar { + limbs: [0; elem::NumLimbs::MAX], + m: PhantomData, + encoding: PhantomData, + }; + unsafe { + sqr_rep(actual_result.limbs.as_mut_ptr(), a.limbs.as_ptr(), 1); + } + assert_limbs_are_equal(cops, &actual_result.limbs, &expected_result.limbs); + } + + { + let actual_result = ops.scalar_product(&a, &a, cpu); + assert_limbs_are_equal(cops, &actual_result.limbs, &expected_result.limbs); + } + + Ok(()) + }) + } + + #[test] + #[should_panic(expected = "!self.scalar_ops.common.is_zero(a)")] + fn p256_scalar_inv_to_mont_zero_panic_test() { + let _ = p256::PRIVATE_SCALAR_OPS.scalar_inv_to_mont(&ZERO_SCALAR, cpu::features()); + } + + #[test] + #[should_panic(expected = "!self.scalar_ops.common.is_zero(a)")] + fn p384_scalar_inv_to_mont_zero_panic_test() { + let _ = p384::PRIVATE_SCALAR_OPS.scalar_inv_to_mont(&ZERO_SCALAR, cpu::features()); + } + + #[test] + fn p256_point_sum_test() { + point_sum_test( + &p256::PRIVATE_KEY_OPS, + test_vector_file!("ops/p256_point_sum_tests.txt"), + ); + } + + #[test] + fn p384_point_sum_test() { + point_sum_test( + &p384::PRIVATE_KEY_OPS, + test_vector_file!("ops/p384_point_sum_tests.txt"), + ); + } + + fn point_sum_test(ops: &PrivateKeyOps, test_file: test::File) { + let cpu = cpu::features(); + + test::run(test_file, |section, test_case| { + assert_eq!(section, ""); + + let a = consume_jacobian_point(ops, test_case, "a"); + let b = consume_jacobian_point(ops, test_case, "b"); + let r_expected: TestPoint = consume_point(ops, test_case, "r"); + + let r_actual = ops.point_sum(&a, &b, cpu); + assert_point_actual_equals_expected(ops, &r_actual, &r_expected); + + Ok(()) + }); + } + + #[test] + fn p256_point_sum_mixed_test() { + prefixed_extern! { + fn p256_point_add_affine( + r: *mut Limb, // [p256::COMMON_OPS.num_limbs*3] + a: *const Limb, // [p256::COMMON_OPS.num_limbs*3] + b: *const Limb, // [p256::COMMON_OPS.num_limbs*2] + ); + } + point_sum_mixed_test( + &p256::PRIVATE_KEY_OPS, + p256_point_add_affine, + test_vector_file!("ops/p256_point_sum_mixed_tests.txt"), + ); + } + + // XXX: There is no `nistz384_point_add_affine()`. + + fn point_sum_mixed_test( + ops: &PrivateKeyOps, + point_add_affine: unsafe extern "C" fn( + r: *mut Limb, // [ops.num_limbs*3] + a: *const Limb, // [ops.num_limbs*3] + b: *const Limb, // [ops.num_limbs*2] + ), + test_file: test::File, + ) { + test::run(test_file, |section, test_case| { + assert_eq!(section, ""); + + let a = consume_jacobian_point(ops, test_case, "a"); + let b = consume_affine_point(ops, test_case, "b"); + let r_expected: TestPoint = consume_point(ops, test_case, "r"); + + let mut r_actual = Point::new_at_infinity(); + unsafe { + point_add_affine(r_actual.xyz.as_mut_ptr(), a.xyz.as_ptr(), b.xy.as_ptr()); + } + + assert_point_actual_equals_expected(ops, &r_actual, &r_expected); + + Ok(()) + }); + } + + #[test] + fn p256_point_double_test() { + prefixed_extern! { + fn p256_point_double( + r: *mut Limb, // [p256::COMMON_OPS.num_limbs*3] + a: *const Limb, // [p256::COMMON_OPS.num_limbs*3] + ); + } + point_double_test( + &p256::PRIVATE_KEY_OPS, + p256_point_double, + test_vector_file!("ops/p256_point_double_tests.txt"), + ); + } + + #[test] + fn p384_point_double_test() { + prefixed_extern! { + fn p384_point_double( + r: *mut Limb, // [p384::COMMON_OPS.num_limbs*3] + a: *const Limb, // [p384::COMMON_OPS.num_limbs*3] + ); + } + point_double_test( + &p384::PRIVATE_KEY_OPS, + p384_point_double, + test_vector_file!("ops/p384_point_double_tests.txt"), + ); + } + + fn point_double_test( + ops: &PrivateKeyOps, + point_double: unsafe extern "C" fn( + r: *mut Limb, // [ops.num_limbs*3] + a: *const Limb, // [ops.num_limbs*3] + ), + test_file: test::File, + ) { + test::run(test_file, |section, test_case| { + assert_eq!(section, ""); + + let a = consume_jacobian_point(ops, test_case, "a"); + let r_expected: TestPoint = consume_point(ops, test_case, "r"); + + let mut r_actual = Point::new_at_infinity(); + unsafe { + point_double(r_actual.xyz.as_mut_ptr(), a.xyz.as_ptr()); + } + + assert_point_actual_equals_expected(ops, &r_actual, &r_expected); + + Ok(()) + }); + } + + /// TODO: We should be testing `point_mul` with points other than the generator. + #[test] + fn p256_point_mul_test() { + let generator = ( + Elem::from(&p256::GENERATOR.0), + Elem::from(&p256::GENERATOR.1), + ); + point_mul_base_tests( + &p256::PRIVATE_KEY_OPS, + |s, cpu| p256::PRIVATE_KEY_OPS.point_mul(s, &generator, cpu), + test_vector_file!("ops/p256_point_mul_base_tests.txt"), + ); + } + + /// TODO: We should be testing `point_mul` with points other than the generator. + #[test] + fn p384_point_mul_test() { + let generator = ( + Elem::from(&p384::GENERATOR.0), + Elem::from(&p384::GENERATOR.1), + ); + + point_mul_base_tests( + &p384::PRIVATE_KEY_OPS, + |s, cpu| p384::PRIVATE_KEY_OPS.point_mul(s, &generator, cpu), + test_vector_file!("ops/p384_point_mul_base_tests.txt"), + ); + } + + #[test] + fn p256_point_mul_serialized_test() { + point_mul_serialized_test( + &p256::PRIVATE_KEY_OPS, + &p256::PUBLIC_KEY_OPS, + test_vector_file!("ops/p256_point_mul_serialized_tests.txt"), + ); + } + + fn point_mul_serialized_test( + priv_ops: &PrivateKeyOps, + pub_ops: &PublicKeyOps, + test_file: test::File, + ) { + let cpu = cpu::features(); + let cops = pub_ops.common; + let q = &cops.elem_modulus(cpu); + let n = &cops.scalar_modulus(cpu); + test::run(test_file, |section, test_case| { + assert_eq!(section, ""); + let p_scalar = consume_scalar(n, test_case, "p_scalar"); + + let p = test_case.consume_bytes("p"); + let p = super::super::public_key::parse_uncompressed_point( + pub_ops, + q, + untrusted::Input::from(&p), + ) + .expect("valid point"); + + let expected_result = test_case.consume_bytes("r"); + + let product = priv_ops.point_mul(&p_scalar, &p, cpu::features()); + + let mut actual_result = vec![4u8; 1 + (2 * cops.len())]; + { + let (x, y) = actual_result[1..].split_at_mut(cops.len()); + super::super::private_key::big_endian_affine_from_jacobian( + priv_ops, + q, + x, + Some(y), + &product, + ) + .expect("successful encoding"); + } + + assert_eq!(expected_result, actual_result); + + Ok(()) + }) + } + + #[test] + fn p256_point_mul_base_test() { + point_mul_base_tests( + &p256::PRIVATE_KEY_OPS, + |s, cpu| p256::PRIVATE_KEY_OPS.point_mul_base(s, cpu), + test_vector_file!("ops/p256_point_mul_base_tests.txt"), + ); + } + + #[test] + fn p384_point_mul_base_test() { + point_mul_base_tests( + &p384::PRIVATE_KEY_OPS, + |s, cpu| p384::PRIVATE_KEY_OPS.point_mul_base(s, cpu), + test_vector_file!("ops/p384_point_mul_base_tests.txt"), + ); + } + + pub(super) fn point_mul_base_tests( + ops: &PrivateKeyOps, + f: impl Fn(&Scalar, cpu::Features) -> Point, + test_file: test::File, + ) { + let cpu = cpu::features(); + let n = &ops.common.scalar_modulus(cpu); + test::run(test_file, |section, test_case| { + assert_eq!(section, ""); + let g_scalar = consume_scalar(n, test_case, "g_scalar"); + let expected_result: TestPoint = consume_point(ops, test_case, "r"); + let actual_result = f(&g_scalar, cpu); + assert_point_actual_equals_expected(ops, &actual_result, &expected_result); + Ok(()) + }) + } + + fn assert_point_actual_equals_expected( + ops: &PrivateKeyOps, + actual_point: &Point, + expected_point: &TestPoint, + ) where + Elem: Convert, + { + let cpu = cpu::features(); + + let cops = ops.common; + let q = &cops.elem_modulus(cpu); + let actual_x = &q.point_x(actual_point); + let actual_y = &q.point_y(actual_point); + let actual_z = &q.point_z(actual_point); + match expected_point { + TestPoint::Infinity => { + let zero = Elem::zero(); + assert_elems_are_equal(q, actual_z, &zero); + } + TestPoint::Affine(expected_x, expected_y) => { + let zz_inv = ops.elem_inverse_squared(q, actual_z); + let x_aff = q.elem_product(actual_x, &zz_inv); + let y_aff = { + let zzzz_inv = q.elem_squared(&zz_inv); + let zzz_inv = q.elem_product(actual_z, &zzzz_inv); + q.elem_product(actual_y, &zzz_inv) + }; + + let x_aff = x_aff.convert(q); + let y_aff = y_aff.convert(q); + + assert_elems_are_equal(q, &x_aff, expected_x); + assert_elems_are_equal(q, &y_aff, expected_y); + } + } + } + + fn consume_jacobian_point( + ops: &PrivateKeyOps, + test_case: &mut test::TestCase, + name: &str, + ) -> Point { + let q = &ops.common.elem_modulus(cpu::features()); + let input = test_case.consume_string(name); + let elems = input.split(", ").collect::>(); + assert_eq!(elems.len(), 3); + let mut p = Point::new_at_infinity(); + consume_point_elem(q, &mut p.xyz, &elems, 0); + consume_point_elem(q, &mut p.xyz, &elems, 1); + consume_point_elem(q, &mut p.xyz, &elems, 2); + p + } + + struct AffinePoint { + xy: [Limb; 2 * elem::NumLimbs::MAX], + } + + fn consume_affine_point( + ops: &PrivateKeyOps, + test_case: &mut test::TestCase, + name: &str, + ) -> AffinePoint { + let q = &ops.common.elem_modulus(cpu::features()); + let input = test_case.consume_string(name); + let elems = input.split(", ").collect::>(); + assert_eq!(elems.len(), 2); + let mut p = AffinePoint { + xy: [0; 2 * elem::NumLimbs::MAX], + }; + consume_point_elem(q, &mut p.xy, &elems, 0); + consume_point_elem(q, &mut p.xy, &elems, 1); + p + } + + fn consume_point_elem(q: &Modulus, limbs_out: &mut [Limb], elems: &[&str], i: usize) { + let num_limbs = q.num_limbs.into(); + let bytes = test::from_hex(elems[i]).unwrap(); + let bytes = untrusted::Input::from(&bytes); + let r: Elem = elem_parse_big_endian_fixed_consttime(q, bytes).unwrap(); + // XXX: “Transmute” this to `Elem` limbs. + limbs_out[(i * num_limbs)..((i + 1) * num_limbs)].copy_from_slice(&r.limbs[..num_limbs]); + } + + enum TestPoint { + Infinity, + Affine(Elem, Elem), + } + + fn consume_point( + ops: &PrivateKeyOps, + test_case: &mut test::TestCase, + name: &str, + ) -> TestPoint { + let q = &ops.common.elem_modulus(cpu::features()); + fn consume_point_elem(q: &Modulus, elems: &[&str], i: usize) -> Elem { + let bytes = test::from_hex(elems[i]).unwrap(); + let bytes = untrusted::Input::from(&bytes); + let unencoded: Elem = + elem_parse_big_endian_fixed_consttime(q, bytes).unwrap(); + // XXX: “Transmute” this to `Elem` limbs. + Elem { + limbs: unencoded.limbs, + m: PhantomData, + encoding: PhantomData, + } + } + + let input = test_case.consume_string(name); + if input == "inf" { + return TestPoint::Infinity; + } + let elems = input.split(", ").collect::>(); + assert_eq!(elems.len(), 2); + let x = consume_point_elem(q, &elems, 0); + let y = consume_point_elem(q, &elems, 1); + TestPoint::Affine(x, y) + } + + fn assert_elems_are_equal(q: &Modulus, a: &Elem, b: &Elem) { + assert_limbs_are_equal(q.cops, &a.limbs, &b.limbs) + } + + fn assert_limbs_are_equal( + ops: &CommonOps, + actual: &[Limb; elem::NumLimbs::MAX], + expected: &[Limb; elem::NumLimbs::MAX], + ) { + let num_limbs = ops.num_limbs.into(); + if actual[..num_limbs] != expected[..num_limbs] { + let mut actual_s = alloc::string::String::new(); + let mut expected_s = alloc::string::String::new(); + for j in 0..num_limbs { + let width = LIMB_BITS / 4; + let formatted = format!("{:0width$x}", actual[num_limbs - j - 1]); + actual_s.push_str(&formatted); + let formatted = format!("{:0width$x}", expected[num_limbs - j - 1]); + expected_s.push_str(&formatted); + } + panic!( + "Actual != Expected,\nActual = {}, Expected = {}", + actual_s, expected_s + ); + } + } + + fn consume_elem(q: &Modulus, test_case: &mut test::TestCase, name: &str) -> Elem { + let unpadded_bytes = test_case.consume_bytes(name); + let mut bytes = vec![0; q.bytes_len() - unpadded_bytes.len()]; + bytes.extend(&unpadded_bytes); + + let bytes = untrusted::Input::from(&bytes); + let r: Elem = elem_parse_big_endian_fixed_consttime(q, bytes).unwrap(); + // XXX: “Transmute” this to an `Elem`. + Elem { + limbs: r.limbs, + m: PhantomData, + encoding: PhantomData, + } + } + + fn consume_scalar(n: &Modulus, test_case: &mut test::TestCase, name: &str) -> Scalar { + let bytes = test_case.consume_bytes(name); + let bytes = untrusted::Input::from(&bytes); + scalar_parse_big_endian_variable(n, AllowZero::Yes, bytes).unwrap() + } + + fn consume_scalar_mont( + n: &Modulus, + test_case: &mut test::TestCase, + name: &str, + ) -> Scalar { + let bytes = test_case.consume_bytes(name); + let bytes = untrusted::Input::from(&bytes); + let s = scalar_parse_big_endian_variable(n, AllowZero::Yes, bytes).unwrap(); + // “Transmute” it to a `Scalar`. + Scalar { + limbs: s.limbs, + m: PhantomData, + encoding: PhantomData, + } + } +} + +mod elem; +pub mod p256; +pub mod p384; diff --git a/http/vendor/ring/src/ec/suite_b/ops/elem.rs b/http/vendor/ring/src/ec/suite_b/ops/elem.rs new file mode 100644 index 0000000..6c308d9 --- /dev/null +++ b/http/vendor/ring/src/ec/suite_b/ops/elem.rs @@ -0,0 +1,167 @@ +// Copyright 2017 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use crate::ec::suite_b::ops::{ + p256::NUM_LIMBS as P256_NUM_LIMBS, p384::NUM_LIMBS as P384_NUM_LIMBS, +}; +use crate::{ + arithmetic::{ + limbs_from_hex, + montgomery::{Encoding, ProductEncoding, Unencoded}, + }, + limb::{LeakyLimb, Limb}, +}; +use core::marker::PhantomData; + +#[derive(Clone, Copy)] +pub(super) enum NumLimbs { + P256, + P384, +} + +impl NumLimbs { + pub(super) const MAX: usize = Self::P384.into(); + + pub(super) const fn into(self) -> usize { + match self { + NumLimbs::P256 => P256_NUM_LIMBS, + NumLimbs::P384 => P384_NUM_LIMBS, + } + } +} + +/// Elements of ℤ/mℤ for some modulus *m*. Elements are always fully reduced +/// with respect to *m*; i.e. the 0 <= x < m for every value x. +#[derive(Clone, Copy)] +pub struct Elem { + // XXX: pub + pub(super) limbs: [Limb; NumLimbs::MAX], + + /// The modulus *m* for the ring ℤ/mℤ for which this element is a value. + pub(super) m: PhantomData, + + /// The number of Montgomery factors that need to be canceled out from + /// `value` to get the actual value. + pub(super) encoding: PhantomData, +} + +pub struct PublicElem { + pub(super) limbs: [LeakyLimb; NumLimbs::MAX], + pub(super) m: PhantomData, + pub(super) encoding: PhantomData, +} + +impl From<&PublicElem> for Elem { + fn from(value: &PublicElem) -> Self { + Self { + limbs: core::array::from_fn(|i| Limb::from(value.limbs[i])), + m: value.m, + encoding: value.encoding, + } + } +} + +impl Elem { + // There's no need to convert `value` to the Montgomery domain since + // 0 * R**2 (mod m) == 0, so neither the modulus nor the encoding are needed + // as inputs for constructing a zero-valued element. + pub fn zero() -> Self { + Self { + limbs: [0; NumLimbs::MAX], + m: PhantomData, + encoding: PhantomData, + } + } +} + +impl Elem { + pub fn one() -> Self { + let mut r = Self::zero(); + r.limbs[0] = 1; + r + } +} + +impl PublicElem { + pub const fn from_hex(hex: &str) -> Self { + Self { + limbs: limbs_from_hex(hex), + m: PhantomData, + encoding: PhantomData, + } + } +} + +#[inline] +pub fn mul_mont( + f: unsafe extern "C" fn(r: *mut Limb, a: *const Limb, b: *const Limb), + a: &Elem, + b: &Elem, +) -> Elem::Output> +where + (EA, EB): ProductEncoding, +{ + binary_op(f, a, b) +} + +// let r = f(a, b); return r; +#[inline] +pub fn binary_op( + f: unsafe extern "C" fn(r: *mut Limb, a: *const Limb, b: *const Limb), + a: &Elem, + b: &Elem, +) -> Elem { + let mut r = Elem::zero(); + unsafe { f(r.limbs.as_mut_ptr(), a.limbs.as_ptr(), b.limbs.as_ptr()) } + r +} + +// a := f(a, b); +#[inline] +pub fn binary_op_assign( + f: unsafe extern "C" fn(r: *mut Limb, a: *const Limb, b: *const Limb), + a: &mut Elem, + b: &Elem, +) { + unsafe { f(a.limbs.as_mut_ptr(), a.limbs.as_ptr(), b.limbs.as_ptr()) } +} + +// let r = f(a); return r; +#[inline] +pub fn unary_op( + f: unsafe extern "C" fn(r: *mut Limb, a: *const Limb), + a: &Elem, +) -> Elem { + let mut r = Elem::zero(); + unsafe { f(r.limbs.as_mut_ptr(), a.limbs.as_ptr()) } + r +} + +// a := f(a); +#[inline] +pub fn unary_op_assign( + f: unsafe extern "C" fn(r: *mut Limb, a: *const Limb), + a: &mut Elem, +) { + unsafe { f(a.limbs.as_mut_ptr(), a.limbs.as_ptr()) } +} + +// a := f(a, a); +#[inline] +pub fn unary_op_from_binary_op_assign( + f: unsafe extern "C" fn(r: *mut Limb, a: *const Limb, b: *const Limb), + a: &mut Elem, +) { + unsafe { f(a.limbs.as_mut_ptr(), a.limbs.as_ptr(), a.limbs.as_ptr()) } +} diff --git a/http/vendor/ring/src/ec/suite_b/ops/p256.rs b/http/vendor/ring/src/ec/suite_b/ops/p256.rs new file mode 100644 index 0000000..6f3cd02 --- /dev/null +++ b/http/vendor/ring/src/ec/suite_b/ops/p256.rs @@ -0,0 +1,334 @@ +// Copyright 2016-2023 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::{ + elem::{binary_op, binary_op_assign}, + elem_sqr_mul, elem_sqr_mul_acc, PublicModulus, *, +}; + +pub(super) const NUM_LIMBS: usize = 256 / LIMB_BITS; + +pub static COMMON_OPS: CommonOps = CommonOps { + num_limbs: elem::NumLimbs::P256, + + q: PublicModulus { + p: limbs_from_hex("ffffffff00000001000000000000000000000000ffffffffffffffffffffffff"), + rr: PublicElem::from_hex("4fffffffdfffffffffffffffefffffffbffffffff0000000000000003"), + }, + n: PublicElem::from_hex("ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"), + + a: PublicElem::from_hex("fffffffc00000004000000000000000000000003fffffffffffffffffffffffc"), + b: PublicElem::from_hex("dc30061d04874834e5a220abf7212ed6acf005cd78843090d89cdf6229c4bddf"), + + elem_mul_mont: p256_mul_mont, + elem_sqr_mont: p256_sqr_mont, +}; + +#[cfg(test)] +pub(super) static GENERATOR: (PublicElem, PublicElem) = ( + PublicElem::from_hex("18905f76a53755c679fb732b7762251075ba95fc5fedb60179e730d418a9143c"), + PublicElem::from_hex("8571ff1825885d85d2e88688dd21f3258b4ab8e4ba19e45cddf25357ce95560a"), +); + +pub static PRIVATE_KEY_OPS: PrivateKeyOps = PrivateKeyOps { + common: &COMMON_OPS, + elem_inv_squared: p256_elem_inv_squared, + point_mul_base_impl: p256_point_mul_base_impl, + point_mul_impl: p256_point_mul, + point_add_jacobian_impl: p256_point_add, +}; + +fn p256_elem_inv_squared(q: &Modulus, a: &Elem) -> Elem { + // Calculate a**-2 (mod q) == a**(q - 3) (mod q) + // + // The exponent (q - 3) is: + // + // 0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc + + #[inline] + fn sqr_mul(q: &Modulus, a: &Elem, squarings: LeakyWord, b: &Elem) -> Elem { + elem_sqr_mul(&COMMON_OPS, a, squarings, b, q.cpu()) + } + + #[inline] + fn sqr_mul_acc(q: &Modulus, a: &mut Elem, squarings: LeakyWord, b: &Elem) { + elem_sqr_mul_acc(&COMMON_OPS, a, squarings, b, q.cpu()) + } + + let b_1 = &a; + let b_11 = sqr_mul(q, b_1, 1, b_1); + let b_111 = sqr_mul(q, &b_11, 1, b_1); + let f_11 = sqr_mul(q, &b_111, 3, &b_111); + let fff = sqr_mul(q, &f_11, 6, &f_11); + let fff_111 = sqr_mul(q, &fff, 3, &b_111); + let fffffff_11 = sqr_mul(q, &fff_111, 15, &fff_111); + let ffffffff = sqr_mul(q, &fffffff_11, 2, &b_11); + + // ffffffff00000001 + let mut acc = sqr_mul(q, &ffffffff, 31 + 1, b_1); + + // ffffffff00000001000000000000000000000000ffffffff + sqr_mul_acc(q, &mut acc, 96 + 32, &ffffffff); + + // ffffffff00000001000000000000000000000000ffffffffffffffff + sqr_mul_acc(q, &mut acc, 32, &ffffffff); + + // ffffffff00000001000000000000000000000000fffffffffffffffffffffff_11 + sqr_mul_acc(q, &mut acc, 30, &fffffff_11); + + // ffffffff00000001000000000000000000000000fffffffffffffffffffffffc + q.elem_square(&mut acc); + q.elem_square(&mut acc); + + acc +} + +fn p256_point_mul_base_impl(g_scalar: &Scalar, _cpu: cpu::Features) -> Point { + prefixed_extern! { + fn p256_point_mul_base( + r: *mut Limb, // [3][COMMON_OPS.num_limbs] + g_scalar: *const Limb, // [COMMON_OPS.num_limbs] + ); + } + + let mut r = Point::new_at_infinity(); + unsafe { + p256_point_mul_base(r.xyz.as_mut_ptr(), g_scalar.limbs.as_ptr()); + } + r +} + +pub static PUBLIC_KEY_OPS: PublicKeyOps = PublicKeyOps { + common: &COMMON_OPS, +}; + +pub static SCALAR_OPS: ScalarOps = ScalarOps { + common: &COMMON_OPS, + scalar_mul_mont: p256_scalar_mul_mont, +}; + +pub static PUBLIC_SCALAR_OPS: PublicScalarOps = PublicScalarOps { + scalar_ops: &SCALAR_OPS, + public_key_ops: &PUBLIC_KEY_OPS, + + #[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + target_arch = "x86_64" + ))] + twin_mul: twin_mul_nistz256, + + #[cfg(not(any( + all(target_arch = "aarch64", target_endian = "little"), + target_arch = "x86_64" + )))] + twin_mul: |g_scalar, p_scalar, p_xy, cpu| { + twin_mul_inefficient(&PRIVATE_KEY_OPS, g_scalar, p_scalar, p_xy, cpu) + }, + + q_minus_n: PublicElem::from_hex("4319055358e8617b0c46353d039cdaae"), + + // TODO: Use an optimized variable-time implementation. + scalar_inv_to_mont_vartime: |s, cpu| PRIVATE_SCALAR_OPS.scalar_inv_to_mont(s, cpu), +}; + +#[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + target_arch = "x86_64" +))] +fn twin_mul_nistz256( + g_scalar: &Scalar, + p_scalar: &Scalar, + p_xy: &(Elem, Elem), + cpu: cpu::Features, +) -> Point { + let scaled_g = point_mul_base_vartime(g_scalar, cpu); + let scaled_p = PRIVATE_KEY_OPS.point_mul(p_scalar, p_xy, cpu::features()); + PRIVATE_KEY_OPS.point_sum(&scaled_g, &scaled_p, cpu) +} + +#[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + target_arch = "x86_64" +))] +fn point_mul_base_vartime(g_scalar: &Scalar, _cpu: cpu::Features) -> Point { + prefixed_extern! { + fn p256_point_mul_base_vartime(r: *mut Limb, // [3][COMMON_OPS.num_limbs] + g_scalar: *const Limb, // [COMMON_OPS.num_limbs] + ); + } + let mut scaled_g = Point::new_at_infinity(); + unsafe { + p256_point_mul_base_vartime(scaled_g.xyz.as_mut_ptr(), g_scalar.limbs.as_ptr()); + } + scaled_g +} + +pub static PRIVATE_SCALAR_OPS: PrivateScalarOps = PrivateScalarOps { + scalar_ops: &SCALAR_OPS, + + oneRR_mod_n: PublicScalar::from_hex( + "66e12d94f3d956202845b2392b6bec594699799c49bd6fa683244c95be79eea2", + ), + scalar_inv_to_mont: p256_scalar_inv_to_mont, +}; + +#[allow(clippy::just_underscores_and_digits)] +fn p256_scalar_inv_to_mont(a: Scalar, _cpu: cpu::Features) -> Scalar { + // Calculate the modular inverse of scalar |a| using Fermat's Little + // Theorem: + // + // a**-1 (mod n) == a**(n - 2) (mod n) + // + // The exponent (n - 2) is: + // + // 0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc63254f + + #[inline] + fn mul(a: &Scalar, b: &Scalar) -> Scalar { + binary_op(p256_scalar_mul_mont, a, b) + } + + #[inline] + fn sqr(a: &Scalar) -> Scalar { + let mut tmp = Scalar::zero(); + unsafe { p256_scalar_sqr_rep_mont(tmp.limbs.as_mut_ptr(), a.limbs.as_ptr(), 1) } + tmp + } + + // Returns (`a` squared `squarings` times) * `b`. + fn sqr_mul(a: &Scalar, squarings: LeakyWord, b: &Scalar) -> Scalar { + debug_assert!(squarings >= 1); + let mut tmp = Scalar::zero(); + unsafe { p256_scalar_sqr_rep_mont(tmp.limbs.as_mut_ptr(), a.limbs.as_ptr(), squarings) } + mul(&tmp, b) + } + + // Sets `acc` = (`acc` squared `squarings` times) * `b`. + fn sqr_mul_acc(acc: &mut Scalar, squarings: LeakyWord, b: &Scalar) { + debug_assert!(squarings >= 1); + unsafe { p256_scalar_sqr_rep_mont(acc.limbs.as_mut_ptr(), acc.limbs.as_ptr(), squarings) } + binary_op_assign(p256_scalar_mul_mont, acc, b); + } + + let _1 = &a; + + let _10 = sqr(_1); // 2 + let _100 = sqr(&_10); // 4 + let _101 = mul(&_100, _1); // 5 + let _111 = mul(&_101, &_10); // 7 + + let _1000 = sqr(&_100); // 8 + let _10000 = sqr(&_1000); // 16 + let _100000 = sqr(&_10000); // 32 + + let _100111 = mul(&_111, &_100000); // 39 = 7 + 32 + let _101011 = mul(&_100, &_100111); // 43 = 4 + 39 + let _101111 = mul(&_100, &_101011); // 47 = 4 + 39 + let _1001111 = mul(&_100000, &_101111); // 79 = 32 + 47 + let _86 = sqr(&_101011); // 86 = 43 * 2 + let _1011011 = mul(&_101, &_86); // 91 = 5 + 86 + let _92 = mul(_1, &_1011011); // 92 = 1 + 91 + let _1100011 = mul(&_111, &_92); // 99 = 7 + 92 + let _10111111 = mul(&_92, &_1100011); // 191 = 92 + 99 + let _11011111 = mul(&_100000, &_10111111); // 223 = 32 + 191 + + let ff = mul(&_100000, &_11011111); // 255 = 32 + 223 + let ffff = sqr_mul(&ff, 0 + 8, &ff); + let ffffffff = sqr_mul(&ffff, 0 + 16, &ffff); + + // ffffffff00000000ffffffff + let mut acc = sqr_mul(&ffffffff, 32 + 32, &ffffffff); + + // ffffffff00000000ffffffffffffffff + sqr_mul_acc(&mut acc, 0 + 32, &ffffffff); + + // The rest of the exponent, in binary, is: + // + // 1011110011100110111110101010110110100111000101111001111010000100 + // 1111001110111001110010101100001011111100011000110010010101001111 + + sqr_mul_acc(&mut acc, 6, &_101111); + sqr_mul_acc(&mut acc, 2 + 3, &_111); + sqr_mul_acc(&mut acc, 2 + 8, &_11011111); + sqr_mul_acc(&mut acc, 1 + 3, &_101); + sqr_mul_acc(&mut acc, 1 + 7, &_1011011); + sqr_mul_acc(&mut acc, 1 + 6, &_100111); + sqr_mul_acc(&mut acc, 3 + 6, &_101111); + sqr_mul_acc(&mut acc, 2 + 3, &_111); + sqr_mul_acc(&mut acc, 3, &_101); + sqr_mul_acc(&mut acc, 4 + 7, &_1001111); + sqr_mul_acc(&mut acc, 2 + 3, &_111); + sqr_mul_acc(&mut acc, 1 + 3, &_111); + sqr_mul_acc(&mut acc, 2 + 3, &_111); + sqr_mul_acc(&mut acc, 2 + 6, &_101011); + sqr_mul_acc(&mut acc, 4 + 8, &_10111111); + sqr_mul_acc(&mut acc, 3 + 7, &_1100011); + sqr_mul_acc(&mut acc, 2 + 1, _1); + sqr_mul_acc(&mut acc, 2 + 3, &_101); + sqr_mul_acc(&mut acc, 1 + 7, &_1001111); + + acc +} + +prefixed_extern! { + pub(super) fn p256_mul_mont( + r: *mut Limb, // [COMMON_OPS.num_limbs] + a: *const Limb, // [COMMON_OPS.num_limbs] + b: *const Limb, // [COMMON_OPS.num_limbs] + ); + pub(super) fn p256_sqr_mont( + r: *mut Limb, // [COMMON_OPS.num_limbs] + a: *const Limb, // [COMMON_OPS.num_limbs] + ); + + fn p256_point_add( + r: *mut Limb, // [3][COMMON_OPS.num_limbs] + a: *const Limb, // [3][COMMON_OPS.num_limbs] + b: *const Limb, // [3][COMMON_OPS.num_limbs] + ); + fn p256_point_mul( + r: *mut Limb, // [3][COMMON_OPS.num_limbs] + p_scalar: *const Limb, // [COMMON_OPS.num_limbs] + p_x: *const Limb, // [COMMON_OPS.num_limbs] + p_y: *const Limb, // [COMMON_OPS.num_limbs] + ); + + fn p256_scalar_mul_mont( + r: *mut Limb, // [COMMON_OPS.num_limbs] + a: *const Limb, // [COMMON_OPS.num_limbs] + b: *const Limb, // [COMMON_OPS.num_limbs] + ); + fn p256_scalar_sqr_rep_mont( + r: *mut Limb, // [COMMON_OPS.num_limbs] + a: *const Limb, // [COMMON_OPS.num_limbs] + rep: LeakyWord, + ); +} + +#[cfg(test)] +mod tests { + #[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + target_arch = "x86_64" + ))] + #[test] + fn p256_point_mul_base_vartime_test() { + use super::{super::tests::point_mul_base_tests, *}; + point_mul_base_tests( + &PRIVATE_KEY_OPS, + point_mul_base_vartime, + test_vector_file!("p256_point_mul_base_tests.txt"), + ); + } +} diff --git a/http/vendor/ring/src/ec/suite_b/ops/p384.rs b/http/vendor/ring/src/ec/suite_b/ops/p384.rs new file mode 100644 index 0000000..f1bde6d --- /dev/null +++ b/http/vendor/ring/src/ec/suite_b/ops/p384.rs @@ -0,0 +1,304 @@ +// Copyright 2016-2023 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::{ + elem::{binary_op, binary_op_assign}, + elem_sqr_mul, elem_sqr_mul_acc, PublicModulus, *, +}; + +pub(super) const NUM_LIMBS: usize = 384 / LIMB_BITS; + +pub static COMMON_OPS: CommonOps = CommonOps { + num_limbs: elem::NumLimbs::P384, + + q: PublicModulus { + p: limbs_from_hex("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"), + rr: PublicElem::from_hex("10000000200000000fffffffe000000000000000200000000fffffffe00000001"), + }, + n: PublicElem::from_hex("ffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"), + + a: PublicElem::from_hex("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffffffc0000000000000003fffffffc"), + b: PublicElem::from_hex("cd08114b604fbff9b62b21f41f022094e3374bee94938ae277f2209b1920022ef729add87a4c32ec081188719d412dcc"), + + elem_mul_mont: p384_elem_mul_mont, + elem_sqr_mont: p384_elem_sqr_mont, +}; + +pub(super) static GENERATOR: (PublicElem, PublicElem) = ( + PublicElem::from_hex("4d3aadc2299e1513812ff723614ede2b6454868459a30eff879c3afc541b4d6e20e378e2a0d6ce383dd0756649c0b528"), + PublicElem::from_hex("2b78abc25a15c5e9dd8002263969a840c6c3521968f4ffd98bade7562e83b050a1bfa8bf7bb4a9ac23043dad4b03a4fe"), +); + +pub static PRIVATE_KEY_OPS: PrivateKeyOps = PrivateKeyOps { + common: &COMMON_OPS, + elem_inv_squared: p384_elem_inv_squared, + point_mul_base_impl: p384_point_mul_base_impl, + point_mul_impl: p384_point_mul, + point_add_jacobian_impl: p384_point_add, +}; + +fn p384_elem_inv_squared(q: &Modulus, a: &Elem) -> Elem { + // Calculate a**-2 (mod q) == a**(q - 3) (mod q) + // + // The exponent (q - 3) is: + // + // 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe\ + // ffffffff0000000000000000fffffffc + + #[inline] + fn sqr_mul(q: &Modulus, a: &Elem, squarings: LeakyWord, b: &Elem) -> Elem { + elem_sqr_mul(&COMMON_OPS, a, squarings, b, q.cpu()) + } + + #[inline] + fn sqr_mul_acc(q: &Modulus, a: &mut Elem, squarings: LeakyWord, b: &Elem) { + elem_sqr_mul_acc(&COMMON_OPS, a, squarings, b, q.cpu()) + } + + let b_1 = &a; + let b_11 = sqr_mul(q, b_1, 1, b_1); + let b_111 = sqr_mul(q, &b_11, 1, b_1); + let f_11 = sqr_mul(q, &b_111, 3, &b_111); + let fff = sqr_mul(q, &f_11, 6, &f_11); + let fff_111 = sqr_mul(q, &fff, 3, &b_111); + let fffffff_11 = sqr_mul(q, &fff_111, 15, &fff_111); + + let fffffffffffffff = sqr_mul(q, &fffffff_11, 30, &fffffff_11); + + let ffffffffffffffffffffffffffffff = sqr_mul(q, &fffffffffffffff, 60, &fffffffffffffff); + + // ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + let mut acc = sqr_mul( + q, + &ffffffffffffffffffffffffffffff, + 120, + &ffffffffffffffffffffffffffffff, + ); + + // fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff_111 + sqr_mul_acc(q, &mut acc, 15, &fff_111); + + // fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff + sqr_mul_acc(q, &mut acc, 1 + 30, &fffffff_11); + sqr_mul_acc(q, &mut acc, 2, &b_11); + + // fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff + // 0000000000000000fffffff_11 + sqr_mul_acc(q, &mut acc, 64 + 30, &fffffff_11); + + // fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff + // 0000000000000000fffffffc + q.elem_square(&mut acc); + q.elem_square(&mut acc); + + acc +} + +fn p384_point_mul_base_impl(a: &Scalar, cpu: cpu::Features) -> Point { + // XXX: Not efficient. TODO: Precompute multiples of the generator. + let generator = (Elem::from(&GENERATOR.0), Elem::from(&GENERATOR.1)); + PRIVATE_KEY_OPS.point_mul(a, &generator, cpu) +} + +pub static PUBLIC_KEY_OPS: PublicKeyOps = PublicKeyOps { + common: &COMMON_OPS, +}; + +pub static SCALAR_OPS: ScalarOps = ScalarOps { + common: &COMMON_OPS, + scalar_mul_mont: p384_scalar_mul_mont, +}; + +pub static PUBLIC_SCALAR_OPS: PublicScalarOps = PublicScalarOps { + scalar_ops: &SCALAR_OPS, + public_key_ops: &PUBLIC_KEY_OPS, + twin_mul: |g_scalar, p_scalar, p_xy, cpu| { + twin_mul_inefficient(&PRIVATE_KEY_OPS, g_scalar, p_scalar, p_xy, cpu) + }, + + q_minus_n: PublicElem::from_hex("389cb27e0bc8d21fa7e5f24cb74f58851313e696333ad68c"), + + // TODO: Use an optimized variable-time implementation. + scalar_inv_to_mont_vartime: |s, cpu| PRIVATE_SCALAR_OPS.scalar_inv_to_mont(s, cpu), +}; + +pub static PRIVATE_SCALAR_OPS: PrivateScalarOps = PrivateScalarOps { + scalar_ops: &SCALAR_OPS, + + oneRR_mod_n: PublicScalar::from_hex("c84ee012b39bf213fb05b7a28266895d40d49174aab1cc5bc3e483afcb82947ff3d81e5df1aa4192d319b2419b409a9"), + scalar_inv_to_mont: p384_scalar_inv_to_mont, +}; + +fn p384_scalar_inv_to_mont(a: Scalar, _cpu: cpu::Features) -> Scalar { + // Calculate the modular inverse of scalar |a| using Fermat's Little + // Theorem: + // + // a**-1 (mod n) == a**(n - 2) (mod n) + // + // The exponent (n - 2) is: + // + // 0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf\ + // 581a0db248b0a77aecec196accc52971 + + fn mul(a: &Scalar, b: &Scalar) -> Scalar { + binary_op(p384_scalar_mul_mont, a, b) + } + + fn sqr(a: &Scalar) -> Scalar { + binary_op(p384_scalar_mul_mont, a, a) + } + + fn sqr_mut(a: &mut Scalar) { + unary_op_from_binary_op_assign(p384_scalar_mul_mont, a); + } + + // Returns (`a` squared `squarings` times) * `b`. + fn sqr_mul(a: &Scalar, squarings: LeakyWord, b: &Scalar) -> Scalar { + debug_assert!(squarings >= 1); + let mut tmp = sqr(a); + for _ in 1..squarings { + sqr_mut(&mut tmp); + } + mul(&tmp, b) + } + + // Sets `acc` = (`acc` squared `squarings` times) * `b`. + fn sqr_mul_acc(acc: &mut Scalar, squarings: LeakyWord, b: &Scalar) { + debug_assert!(squarings >= 1); + for _ in 0..squarings { + sqr_mut(acc); + } + binary_op_assign(p384_scalar_mul_mont, acc, b) + } + + // Indexes into `d`. + const B_1: usize = 0; + const B_11: usize = 1; + const B_101: usize = 2; + const B_111: usize = 3; + const B_1001: usize = 4; + const B_1011: usize = 5; + const B_1101: usize = 6; + const B_1111: usize = 7; + const DIGIT_COUNT: usize = 8; + + let mut d = [Scalar::zero(); DIGIT_COUNT]; + d[B_1] = a; + let b_10 = sqr(&d[B_1]); + for i in B_11..DIGIT_COUNT { + d[i] = mul(&d[i - 1], &b_10); + } + + let ff = sqr_mul(&d[B_1111], 0 + 4, &d[B_1111]); + let ffff = sqr_mul(&ff, 0 + 8, &ff); + let ffffffff = sqr_mul(&ffff, 0 + 16, &ffff); + + let ffffffffffffffff = sqr_mul(&ffffffff, 0 + 32, &ffffffff); + + let ffffffffffffffffffffffff = sqr_mul(&ffffffffffffffff, 0 + 32, &ffffffff); + + // ffffffffffffffffffffffffffffffffffffffffffffffff + let mut acc = sqr_mul(&ffffffffffffffffffffffff, 0 + 96, &ffffffffffffffffffffffff); + + // The rest of the exponent, in binary, is: + // + // 1100011101100011010011011000000111110100001101110010110111011111 + // 0101100000011010000011011011001001001000101100001010011101111010 + // 1110110011101100000110010110101011001100110001010010100101110001 + + #[allow(clippy::cast_possible_truncation)] + static REMAINING_WINDOWS: [(u8, u8); 39] = [ + (2, B_11 as u8), + (3 + 3, B_111 as u8), + (1 + 2, B_11 as u8), + (3 + 2, B_11 as u8), + (1 + 4, B_1001 as u8), + (4, B_1011 as u8), + (6 + 4, B_1111 as u8), + (3, B_101 as u8), + (4 + 1, B_1 as u8), + (4, B_1011 as u8), + (4, B_1001 as u8), + (1 + 4, B_1101 as u8), + (4, B_1101 as u8), + (4, B_1111 as u8), + (1 + 4, B_1011 as u8), + (6 + 4, B_1101 as u8), + (5 + 4, B_1101 as u8), + (4, B_1011 as u8), + (2 + 4, B_1001 as u8), + (2 + 1, B_1 as u8), + (3 + 4, B_1011 as u8), + (4 + 3, B_101 as u8), + (2 + 3, B_111 as u8), + (1 + 4, B_1111 as u8), + (1 + 4, B_1011 as u8), + (4, B_1011 as u8), + (2 + 3, B_111 as u8), + (1 + 2, B_11 as u8), + (5 + 2, B_11 as u8), + (2 + 4, B_1011 as u8), + (1 + 3, B_101 as u8), + (1 + 2, B_11 as u8), + (2 + 2, B_11 as u8), + (2 + 2, B_11 as u8), + (3 + 3, B_101 as u8), + (2 + 3, B_101 as u8), + (2 + 3, B_101 as u8), + (2, B_11 as u8), + (3 + 1, B_1 as u8), + ]; + + for &(squarings, digit) in &REMAINING_WINDOWS[..] { + sqr_mul_acc(&mut acc, LeakyWord::from(squarings), &d[usize::from(digit)]); + } + + acc +} + +unsafe extern "C" fn p384_elem_sqr_mont( + r: *mut Limb, // [COMMON_OPS.num_limbs] + a: *const Limb, // [COMMON_OPS.num_limbs] +) { + // XXX: Inefficient. TODO: Make a dedicated squaring routine. + unsafe { + p384_elem_mul_mont(r, a, a); + } +} + +prefixed_extern! { + fn p384_elem_mul_mont( + r: *mut Limb, // [COMMON_OPS.num_limbs] + a: *const Limb, // [COMMON_OPS.num_limbs] + b: *const Limb, // [COMMON_OPS.num_limbs] + ); + + fn p384_point_add( + r: *mut Limb, // [3][COMMON_OPS.num_limbs] + a: *const Limb, // [3][COMMON_OPS.num_limbs] + b: *const Limb, // [3][COMMON_OPS.num_limbs] + ); + fn p384_point_mul( + r: *mut Limb, // [3][COMMON_OPS.num_limbs] + p_scalar: *const Limb, // [COMMON_OPS.num_limbs] + p_x: *const Limb, // [COMMON_OPS.num_limbs] + p_y: *const Limb, // [COMMON_OPS.num_limbs] + ); + + fn p384_scalar_mul_mont( + r: *mut Limb, // [COMMON_OPS.num_limbs] + a: *const Limb, // [COMMON_OPS.num_limbs] + b: *const Limb, // [COMMON_OPS.num_limbs] + ); +} diff --git a/http/vendor/ring/src/ec/suite_b/private_key.rs b/http/vendor/ring/src/ec/suite_b/private_key.rs new file mode 100644 index 0000000..1912929 --- /dev/null +++ b/http/vendor/ring/src/ec/suite_b/private_key.rs @@ -0,0 +1,203 @@ +// Copyright 2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! Functionality shared by operations on private keys (ECC keygen and +//! ECDSA signing). + +use super::{ops::*, verify_affine_point_is_on_the_curve}; +use crate::{arithmetic::montgomery::R, cpu, ec, error, limb, rand}; + +/// Generates a random scalar in the range [1, n). +pub(super) fn random_scalar( + ops: &PrivateKeyOps, + n: &Modulus, + rng: &dyn rand::SecureRandom, +) -> Result { + let mut bytes = [0; ec::SCALAR_MAX_BYTES]; + let bytes = &mut bytes[..ops.common.len()]; + generate_private_scalar_bytes(ops, rng, bytes, n.cpu())?; + scalar_from_big_endian_bytes(n, bytes) +} + +pub(super) fn generate_private_scalar_bytes( + ops: &PrivateKeyOps, + rng: &dyn rand::SecureRandom, + out: &mut [u8], + cpu: cpu::Features, +) -> Result<(), error::Unspecified> { + // [NSA Suite B Implementer's Guide to ECDSA] Appendix A.1.2, and + // [NSA Suite B Implementer's Guide to NIST SP 800-56A] Appendix B.2, + // "Key Pair Generation by Testing Candidates". + // + // [NSA Suite B Implementer's Guide to ECDSA]: doc/ecdsa.pdf + // [NSA Suite B Implementer's Guide to NIST SP 800-56A]: doc/ecdh.pdf + + // TODO: The NSA guide also suggests, in appendix B.1, another mechanism + // that would avoid the need to use `rng.fill()` more than once. It works + // by generating an extra 64 bits of random bytes and then reducing the + // output (mod n). Supposedly, this removes enough of the bias towards + // small values from the modular reduction, but it isn't obvious that it is + // sufficient. TODO: Figure out what we can do to mitigate the bias issue + // and switch to the other mechanism. + + let candidate = out; + + // XXX: The value 100 was chosen to match OpenSSL due to uncertainty of + // what specific value would be better, but it seems bad to try 100 times. + for _ in 0..100 { + // NSA Guide Steps 1, 2, and 3. + // + // Since we calculate the length ourselves, it is pointless to check + // it, since we can only check it by doing the same calculation. + + // NSA Guide Step 4. + // + // The requirement that the random number generator has the + // requested security strength is delegated to `rng`. + rng.fill(candidate)?; + + // NSA Guide Steps 5, 6, and 7. + if check_scalar_big_endian_bytes(ops, candidate, cpu).is_err() { + continue; + } + + // NSA Guide Step 8 is done in `public_from_private()`. + + // NSA Guide Step 9. + return Ok(()); + } + + Err(error::Unspecified) +} + +// The underlying X25519 and Ed25519 code uses an [u8; 32] to store the private +// key. To make the ECDH and ECDSA code similar to that, we also store the +// private key that way, which means we have to convert it to a Scalar whenever +// we need to use it. +#[inline] +pub(super) fn private_key_as_scalar(n: &Modulus, private_key: &ec::Seed) -> Scalar { + // This cannot fail because we know the private key is valid. + scalar_from_big_endian_bytes(n, private_key.bytes_less_safe()).unwrap() +} + +pub(super) fn check_scalar_big_endian_bytes( + ops: &PrivateKeyOps, + bytes: &[u8], + cpu: cpu::Features, +) -> Result<(), error::Unspecified> { + debug_assert_eq!(bytes.len(), ops.common.len()); + let n = &ops.common.scalar_modulus(cpu); + scalar_from_big_endian_bytes(n, bytes).map(|_| ()) +} + +// Parses a fixed-length (zero-padded) big-endian-encoded scalar in the range +// [1, n). This is intended to be constant-time with respect to the actual +// value *only if* the value is actually in range. In other words, this won't +// leak anything about a valid value, but it might leak small amounts of +// information about an invalid value (which constraint it failed). +pub(super) fn scalar_from_big_endian_bytes( + n: &Modulus, + bytes: &[u8], +) -> Result { + // [NSA Suite B Implementer's Guide to ECDSA] Appendix A.1.2, and + // [NSA Suite B Implementer's Guide to NIST SP 800-56A] Appendix B.2, + // "Key Pair Generation by Testing Candidates". + // + // [NSA Suite B Implementer's Guide to ECDSA]: doc/ecdsa.pdf + // [NSA Suite B Implementer's Guide to NIST SP 800-56A]: doc/ecdh.pdf + // + // Steps 5, 6, and 7. + // + // XXX: The NSA guide says that we should verify that the random scalar is + // in the range [0, n - 1) and then add one to it so that it is in the range + // [1, n). Instead, we verify that the scalar is in the range [1, n). This + // way, we avoid needing to compute or store the value (n - 1), we avoid the + // need to implement a function to add one to a scalar, and we avoid needing + // to convert the scalar back into an array of bytes. + scalar_parse_big_endian_fixed_consttime(n, untrusted::Input::from(bytes)) +} + +pub(super) fn public_from_private( + ops: &PrivateKeyOps, + public_out: &mut [u8], + my_private_key: &ec::Seed, + cpu: cpu::Features, +) -> Result<(), error::Unspecified> { + let q = &ops.common.elem_modulus(cpu); + let elem_and_scalar_bytes = ops.common.len(); + debug_assert_eq!(public_out.len(), 1 + (2 * elem_and_scalar_bytes)); + let n = &ops.common.scalar_modulus(cpu); + let my_private_key = private_key_as_scalar(n, my_private_key); + let my_public_key = ops.point_mul_base(&my_private_key, cpu); + public_out[0] = 4; // Uncompressed encoding. + let (x_out, y_out) = public_out[1..].split_at_mut(elem_and_scalar_bytes); + + // `big_endian_affine_from_jacobian` verifies that the point is not at + // infinity and is on the curve. + big_endian_affine_from_jacobian(ops, q, x_out, Some(y_out), &my_public_key) +} + +pub(super) fn affine_from_jacobian( + ops: &PrivateKeyOps, + q: &Modulus, + p: &Point, +) -> Result<(Elem, Elem), error::Unspecified> { + let z = q.point_z(p); + + // Since we restrict our private key to the range [1, n), the curve has + // prime order, and we verify that the peer's point is on the curve, + // there's no way that the result can be at infinity. But, use `assert!` + // instead of `debug_assert!` anyway + assert!(q.elem_verify_is_not_zero(&z).is_ok()); + + let x = q.point_x(p); + let y = q.point_y(p); + + let zz_inv = ops.elem_inverse_squared(q, &z); + + let x_aff = q.elem_product(&x, &zz_inv); + + // `y_aff` is needed to validate the point is on the curve. It is also + // needed in the non-ECDH case where we need to output it. + let y_aff = { + let zzzz_inv = q.elem_squared(&zz_inv); + let zzz_inv = q.elem_product(&z, &zzzz_inv); + q.elem_product(&y, &zzz_inv) + }; + + // If we validated our inputs correctly and then computed (x, y, z), then + // (x, y, z) will be on the curve. See + // `verify_affine_point_is_on_the_curve_scaled` for the motivation. + verify_affine_point_is_on_the_curve(q, (&x_aff, &y_aff))?; + + Ok((x_aff, y_aff)) +} + +pub(super) fn big_endian_affine_from_jacobian( + ops: &PrivateKeyOps, + q: &Modulus, + x_out: &mut [u8], + y_out: Option<&mut [u8]>, + p: &Point, +) -> Result<(), error::Unspecified> { + let (x_aff, y_aff) = affine_from_jacobian(ops, q, p)?; + let x = q.elem_unencoded(&x_aff); + limb::big_endian_from_limbs(ops.leak_limbs(&x), x_out); + if let Some(y_out) = y_out { + let y = q.elem_unencoded(&y_aff); + limb::big_endian_from_limbs(ops.leak_limbs(&y), y_out); + } + + Ok(()) +} diff --git a/http/vendor/ring/src/ec/suite_b/public_key.rs b/http/vendor/ring/src/ec/suite_b/public_key.rs new file mode 100644 index 0000000..328bb37 --- /dev/null +++ b/http/vendor/ring/src/ec/suite_b/public_key.rs @@ -0,0 +1,111 @@ +// Copyright 2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! Functionality shared by operations on public keys (ECDSA verification and +//! ECDH agreement). + +use super::{ops::*, verify_affine_point_is_on_the_curve}; +use crate::{arithmetic::montgomery::*, error}; + +/// Parses a public key encoded in uncompressed form. The key is validated +/// using the ECC Partial Public-Key Validation Routine from +/// [NIST SP 800-56A, revision 2] Section 5.6.2.3.3, the NSA's +/// "Suite B Implementer's Guide to NIST SP 800-56A," Appendix B.3, and the +/// NSA's "Suite B Implementer's Guide to FIPS 186-3 (ECDSA)," Appendix A.3. +/// +/// [NIST SP 800-56A, revision 2]: +/// http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-56Ar2.pdf +pub(super) fn parse_uncompressed_point( + ops: &PublicKeyOps, + q: &Modulus, + input: untrusted::Input, +) -> Result<(Elem, Elem), error::Unspecified> { + // NIST SP 800-56A Step 1: "Verify that Q is not the point at infinity. + // This can be done by inspection if the point is entered in the standard + // affine representation." (We do it by inspection since we only accept + // the affine representation.) + let (x, y) = input.read_all(error::Unspecified, |input| { + // The encoding must be 4, which is the encoding for "uncompressed". + let encoding = input.read_byte()?; + if encoding != 4 { + return Err(error::Unspecified); + } + + // NIST SP 800-56A Step 2: "Verify that xQ and yQ are integers in the + // interval [0, p-1] in the case that q is an odd prime p[.]" + let x = ops.elem_parse(q, input)?; + let y = ops.elem_parse(q, input)?; + Ok((x, y)) + })?; + + // NIST SP 800-56A Step 3: "If q is an odd prime p, verify that + // yQ**2 = xQ**3 + axQ + b in GF(p), where the arithmetic is performed + // modulo p." + verify_affine_point_is_on_the_curve(q, (&x, &y))?; + + // NIST SP 800-56A Note: "Since its order is not verified, there is no + // check that the public key is in the correct EC subgroup." + // + // NSA Suite B Implementer's Guide Note: "ECC Full Public-Key Validation + // includes an additional check to ensure that the point has the correct + // order. This check is not necessary for curves having prime order (and + // cofactor h = 1), such as P-256 and P-384." + + Ok((x, y)) +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::cpu; + use crate::testutil as test; + + #[test] + fn parse_uncompressed_point_test() { + let cpu = cpu::features(); + test::run( + test_vector_file!("suite_b_public_key_tests.txt"), + |section, test_case| { + assert_eq!(section, ""); + + let curve_name = test_case.consume_string("Curve"); + + let public_key = test_case.consume_bytes("Q"); + let public_key = untrusted::Input::from(&public_key); + let is_valid = test_case.consume_string("Result") == "P"; + + let curve_ops = public_key_ops_from_curve_name(&curve_name); + let q = &curve_ops.common.elem_modulus(cpu); + + let result = parse_uncompressed_point(curve_ops, q, public_key); + assert_eq!(is_valid, result.is_ok()); + + // TODO: Verify that we when we re-serialize the parsed (x, y), the + // output is equal to the input. + + Ok(()) + }, + ); + } + + fn public_key_ops_from_curve_name(curve_name: &str) -> &'static PublicKeyOps { + if curve_name == "P-256" { + &p256::PUBLIC_KEY_OPS + } else if curve_name == "P-384" { + &p384::PUBLIC_KEY_OPS + } else { + panic!("Unsupported curve: {}", curve_name); + } + } +} diff --git a/http/vendor/ring/src/error/input_too_long.rs b/http/vendor/ring/src/error/input_too_long.rs new file mode 100644 index 0000000..6000077 --- /dev/null +++ b/http/vendor/ring/src/error/input_too_long.rs @@ -0,0 +1,39 @@ +// Copyright 2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +pub struct InputTooLongError { + /// Note that this might not actually be the (exact) length of the input, + /// and its units might be lost. For example, it could be any of the + /// following: + /// + /// * The length in bytes of the entire input. + /// * The length in bytes of some *part* of the input. + /// * A bit length. + /// * A length in terms of "blocks" or other grouping of input values. + /// * Some intermediate quantity that was used when checking the input + /// length. + /// * Some arbitrary value. + #[allow(dead_code)] + imprecise_input_length: T, +} + +impl InputTooLongError { + #[cold] + #[inline(never)] + pub(crate) fn new(imprecise_input_length: T) -> Self { + Self { + imprecise_input_length, + } + } +} diff --git a/http/vendor/ring/src/error/into_unspecified.rs b/http/vendor/ring/src/error/into_unspecified.rs new file mode 100644 index 0000000..dc0bd94 --- /dev/null +++ b/http/vendor/ring/src/error/into_unspecified.rs @@ -0,0 +1,33 @@ +// Copyright 2016-2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use crate::error::{KeyRejected, Unspecified}; + +impl From for Unspecified { + fn from(source: untrusted::EndOfInput) -> Self { + super::erase(source) + } +} + +impl From for Unspecified { + fn from(source: core::array::TryFromSliceError) -> Self { + super::erase(source) + } +} + +impl From for Unspecified { + fn from(source: KeyRejected) -> Self { + super::erase(source) + } +} diff --git a/http/vendor/ring/src/error/key_rejected.rs b/http/vendor/ring/src/error/key_rejected.rs new file mode 100644 index 0000000..c12d973 --- /dev/null +++ b/http/vendor/ring/src/error/key_rejected.rs @@ -0,0 +1,111 @@ +// Copyright 2016-2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! Error reporting. + +#[cfg(feature = "std")] +extern crate std; + +/// An error parsing or validating a key. +/// +/// The `Display` implementation will return a string that will help you better +/// understand why a key was rejected change which errors are reported in which +/// situations while minimizing the likelihood that any applications will be +/// broken. +/// +/// Here is an incomplete list of reasons a key may be unsupported: +/// +/// * Invalid or Inconsistent Components: A component of the key has an invalid +/// value, or the mathematical relationship between two (or more) components +/// required for a valid key does not hold. +/// +/// * The encoding of the key is invalid. Perhaps the key isn't in the correct +/// format; e.g. it may be Base64 ("PEM") encoded, in which case the Base64 +/// encoding needs to be undone first. +/// +/// * The encoding includes a versioning mechanism and that mechanism indicates +/// that the key is encoded in a version of the encoding that isn't supported. +/// This might happen for multi-prime RSA keys (keys with more than two +/// private prime factors), which aren't supported, for example. +/// +/// * Too small or too Large: One of the primary components of the key is too +/// small or two large. Too-small keys are rejected for security reasons. Some +/// unnecessarily large keys are rejected for performance reasons. +/// +/// * Wrong algorithm: The key is not valid for the algorithm in which it was +/// being used. +/// +/// * Unexpected errors: Report this as a bug. +#[derive(Copy, Clone, Debug)] +pub struct KeyRejected(&'static str); + +impl KeyRejected { + pub(crate) fn inconsistent_components() -> Self { + Self("InconsistentComponents") + } + + pub(crate) fn invalid_component() -> Self { + Self("InvalidComponent") + } + + #[inline] + pub(crate) fn invalid_encoding() -> Self { + Self("InvalidEncoding") + } + + // XXX: See the comment at the call site. + pub(crate) fn rng_failed() -> Self { + Self("RNG failed") + } + + pub(crate) fn public_key_is_missing() -> Self { + Self("PublicKeyIsMissing") + } + + #[cfg(feature = "alloc")] + pub(crate) fn too_small() -> Self { + Self("TooSmall") + } + + #[cfg(feature = "alloc")] + pub(crate) fn too_large() -> Self { + Self("TooLarge") + } + + pub(crate) fn version_not_supported() -> Self { + Self("VersionNotSupported") + } + + pub(crate) fn wrong_algorithm() -> Self { + Self("WrongAlgorithm") + } + + #[cfg(feature = "alloc")] + pub(crate) fn private_modulus_len_not_multiple_of_512_bits() -> Self { + Self("PrivateModulusLenNotMultipleOf512Bits") + } + + pub(crate) fn unexpected_error() -> Self { + Self("UnexpectedError") + } +} + +#[cfg(feature = "std")] +impl std::error::Error for KeyRejected {} + +impl core::fmt::Display for KeyRejected { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + f.write_str(self.0) + } +} diff --git a/http/vendor/ring/src/error/mod.rs b/http/vendor/ring/src/error/mod.rs new file mode 100644 index 0000000..ead174f --- /dev/null +++ b/http/vendor/ring/src/error/mod.rs @@ -0,0 +1,58 @@ +// Copyright 2016-2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! Error reporting. + +pub use self::{key_rejected::KeyRejected, unspecified::Unspecified}; + +pub(crate) use self::{ + input_too_long::InputTooLongError, len_mismatch_error::LenMismatchError, + too_much_output_requested::TooMuchOutputRequestedError, +}; + +mod input_too_long; +mod into_unspecified; +mod key_rejected; +mod unspecified; + +#[cold] +#[inline(never)] +pub(crate) fn erase(_: T) -> Unspecified { + Unspecified +} + +cold_exhaustive_error! { + struct too_much_output_requested::TooMuchOutputRequestedError + with pub(crate) constructor { + // Note that this might not actually be the (exact) output length + // requested, and its units might be lost. For example, it could be any of + // the following: + // + // * The length in bytes of the entire output. + // * The length in bytes of some *part* of the output. + // * A bit length. + // * A length in terms of "blocks" or other grouping of output values. + // * Some intermediate quantity that was used when checking the output + // length. + // * Some arbitrary value. + imprecise_output_length: usize + } +} + +cold_exhaustive_error! { + struct len_mismatch_error::LenMismatchError + with pub(crate) constructor { + len: usize + } +} diff --git a/http/vendor/ring/src/error/unspecified.rs b/http/vendor/ring/src/error/unspecified.rs new file mode 100644 index 0000000..22a3e02 --- /dev/null +++ b/http/vendor/ring/src/error/unspecified.rs @@ -0,0 +1,85 @@ +// Copyright 2016-2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#[cfg(feature = "std")] +extern crate std; + +/// An error with absolutely no details. +/// +/// *ring* uses this unit type as the error type in most of its results +/// because (a) usually the specific reasons for a failure are obvious or are +/// not useful to know, and/or (b) providing more details about a failure might +/// provide a dangerous side channel, and/or (c) it greatly simplifies the +/// error handling logic. +/// +/// `Result` is mostly equivalent to +/// `Result`. However, `ring::error::Unspecified` implements +/// [`std::error::Error`] and users of *ring* can implement +/// `From` to map this to their own error types, as +/// described in [“Error Handling” in the Rust Book]: +/// +/// ``` +/// use ring::rand::{self, SecureRandom}; +/// +/// enum Error { +/// CryptoError, +/// +/// # #[cfg(feature = "alloc")] +/// IOError(std::io::Error), +/// // [...] +/// } +/// +/// impl From for Error { +/// fn from(_: ring::error::Unspecified) -> Self { Error::CryptoError } +/// } +/// +/// fn eight_random_bytes() -> Result<[u8; 8], Error> { +/// let rng = rand::SystemRandom::new(); +/// let mut bytes = [0; 8]; +/// +/// // The `From` implementation above makes this +/// // equivalent to +/// // `rng.fill(&mut bytes).map_err(|_| Error::CryptoError)?`. +/// rng.fill(&mut bytes)?; +/// +/// Ok(bytes) +/// } +/// +/// assert!(eight_random_bytes().is_ok()); +/// ``` +/// +/// Experience with using and implementing other crypto libraries like has +/// shown that sophisticated error reporting facilities often cause significant +/// bugs themselves, both within the crypto library and within users of the +/// crypto library. This approach attempts to minimize complexity in the hopes +/// of avoiding such problems. In some cases, this approach may be too extreme, +/// and it may be important for an operation to provide some details about the +/// cause of a failure. Users of *ring* are encouraged to report such cases so +/// that they can be addressed individually. +/// +/// [`std::error::Error`]: https://doc.rust-lang.org/std/error/trait.Error.html +/// [“Error Handling” in the Rust Book]: +/// https://doc.rust-lang.org/book/first-edition/error-handling.html#the-from-trait +#[derive(Clone, Copy, Debug, PartialEq)] +pub struct Unspecified; + +// This is required for the implementation of `std::error::Error`. +impl core::fmt::Display for Unspecified { + fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { + f.write_str("ring::error::Unspecified") + } +} + +#[cfg(feature = "std")] +impl std::error::Error for Unspecified {} diff --git a/http/vendor/ring/src/hkdf.rs b/http/vendor/ring/src/hkdf.rs new file mode 100644 index 0000000..6a28a4e --- /dev/null +++ b/http/vendor/ring/src/hkdf.rs @@ -0,0 +1,233 @@ +// Copyright 2015 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! HMAC-based Extract-and-Expand Key Derivation Function. +//! +//! HKDF is specified in [RFC 5869]. +//! +//! [RFC 5869]: https://tools.ietf.org/html/rfc5869 + +use crate::{error, hmac}; + +/// An HKDF algorithm. +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +pub struct Algorithm(hmac::Algorithm); + +impl Algorithm { + /// The underlying HMAC algorithm. + #[inline] + pub fn hmac_algorithm(&self) -> hmac::Algorithm { + self.0 + } +} + +/// HKDF using HMAC-SHA-1. Obsolete. +pub static HKDF_SHA1_FOR_LEGACY_USE_ONLY: Algorithm = + Algorithm(hmac::HMAC_SHA1_FOR_LEGACY_USE_ONLY); + +/// HKDF using HMAC-SHA-256. +pub static HKDF_SHA256: Algorithm = Algorithm(hmac::HMAC_SHA256); + +/// HKDF using HMAC-SHA-384. +pub static HKDF_SHA384: Algorithm = Algorithm(hmac::HMAC_SHA384); + +/// HKDF using HMAC-SHA-512. +pub static HKDF_SHA512: Algorithm = Algorithm(hmac::HMAC_SHA512); + +impl KeyType for Algorithm { + fn len(&self) -> usize { + self.0.digest_algorithm().output_len() + } +} + +/// A salt for HKDF operations. +#[derive(Debug)] +pub struct Salt(hmac::Key); + +impl Salt { + /// Constructs a new `Salt` with the given value based on the given digest + /// algorithm. + /// + /// Constructing a `Salt` is relatively expensive so it is good to reuse a + /// `Salt` object instead of re-constructing `Salt`s with the same value. + pub fn new(algorithm: Algorithm, value: &[u8]) -> Self { + Self(hmac::Key::new(algorithm.0, value)) + } + + /// The [HKDF-Extract] operation. + /// + /// [HKDF-Extract]: https://tools.ietf.org/html/rfc5869#section-2.2 + pub fn extract(&self, secret: &[u8]) -> Prk { + // The spec says that if no salt is provided then a key of + // `digest_alg.output_len` bytes of zeros is used. But, HMAC keys are + // already zero-padded to the block length, which is larger than the output + // length of the extract step (the length of the digest). Consequently the + // `Key` constructor will automatically do the right thing for a + // zero-length string. + let salt = &self.0; + let prk = hmac::sign(salt, secret); + Prk(hmac::Key::new(salt.algorithm(), prk.as_ref())) + } + + /// The algorithm used to derive this salt. + #[inline] + pub fn algorithm(&self) -> Algorithm { + Algorithm(self.0.algorithm()) + } +} + +impl From> for Salt { + fn from(okm: Okm<'_, Algorithm>) -> Self { + Self(hmac::Key::from(Okm { + prk: okm.prk, + info: okm.info, + len: okm.len().0, + len_cached: okm.len_cached, + })) + } +} + +/// The length of the OKM (Output Keying Material) for a `Prk::expand()` call. +pub trait KeyType { + /// The length that `Prk::expand()` should expand its input to. + fn len(&self) -> usize; +} + +/// A HKDF PRK (pseudorandom key). +#[derive(Clone, Debug)] +pub struct Prk(hmac::Key); + +impl Prk { + /// Construct a new `Prk` directly with the given value. + /// + /// Usually one can avoid using this. It is useful when the application + /// intentionally wants to leak the PRK secret, e.g. to implement + /// `SSLKEYLOGFILE` functionality. + pub fn new_less_safe(algorithm: Algorithm, value: &[u8]) -> Self { + Self(hmac::Key::new(algorithm.hmac_algorithm(), value)) + } + + /// The [HKDF-Expand] operation. + /// + /// [HKDF-Expand]: https://tools.ietf.org/html/rfc5869#section-2.3 + /// + /// Fails if (and only if) `len` is too large. + #[inline] + pub fn expand<'a, L: KeyType>( + &'a self, + info: &'a [&'a [u8]], + len: L, + ) -> Result, error::Unspecified> { + let len_cached = len.len(); + if len_cached > 255 * self.0.algorithm().digest_algorithm().output_len() { + return Err(error::Unspecified); + } + Ok(Okm { + prk: self, + info, + len, + len_cached, + }) + } +} + +impl From> for Prk { + fn from(okm: Okm) -> Self { + Self(hmac::Key::from(Okm { + prk: okm.prk, + info: okm.info, + len: okm.len().0, + len_cached: okm.len_cached, + })) + } +} + +/// An HKDF OKM (Output Keying Material) +/// +/// Intentionally not `Clone` or `Copy` as an OKM is generally only safe to +/// use once. +#[derive(Debug)] +pub struct Okm<'a, L: KeyType> { + prk: &'a Prk, + info: &'a [&'a [u8]], + len: L, + len_cached: usize, +} + +impl Okm<'_, L> { + /// The `OkmLength` given to `Prk::expand()`. + #[inline] + pub fn len(&self) -> &L { + &self.len + } + + /// Fills `out` with the output of the HKDF-Expand operation for the given + /// inputs. + /// + /// Fails if (and only if) the requested output length is larger than 255 + /// times the size of the digest algorithm's output. (This is the limit + /// imposed by the HKDF specification due to the way HKDF's counter is + /// constructed.) + #[inline] + pub fn fill(self, out: &mut [u8]) -> Result<(), error::Unspecified> { + fill_okm(self.prk, self.info, out, self.len_cached) + } +} + +fn fill_okm( + prk: &Prk, + info: &[&[u8]], + out: &mut [u8], + len: usize, +) -> Result<(), error::Unspecified> { + if out.len() != len { + return Err(error::Unspecified); + } + + let digest_alg = prk.0.algorithm().digest_algorithm(); + assert!(digest_alg.block_len() >= digest_alg.output_len()); + + let mut ctx = hmac::Context::with_key(&prk.0); + + let mut n = 1u8; + let mut out = out; + loop { + for info in info { + ctx.update(info); + } + ctx.update(&[n]); + + let t = ctx.sign(); + let t = t.as_ref(); + + // Append `t` to the output. + out = if out.len() < digest_alg.output_len() { + let len = out.len(); + out.copy_from_slice(&t[..len]); + &mut [] + } else { + let (this_chunk, rest) = out.split_at_mut(digest_alg.output_len()); + this_chunk.copy_from_slice(t); + rest + }; + + if out.is_empty() { + return Ok(()); + } + + ctx = hmac::Context::with_key(&prk.0); + ctx.update(t); + n = n.checked_add(1).unwrap(); + } +} diff --git a/http/vendor/ring/src/hmac.rs b/http/vendor/ring/src/hmac.rs new file mode 100644 index 0000000..f0b2380 --- /dev/null +++ b/http/vendor/ring/src/hmac.rs @@ -0,0 +1,440 @@ +// Copyright 2015-2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! HMAC is specified in [RFC 2104]. +//! +//! After a `Key` is constructed, it can be used for multiple signing or +//! verification operations. Separating the construction of the key from the +//! rest of the HMAC operation allows the per-key precomputation to be done +//! only once, instead of it being done in every HMAC operation. +//! +//! Frequently all the data to be signed in a message is available in a single +//! contiguous piece. In that case, the module-level `sign` function can be +//! used. Otherwise, if the input is in multiple parts, `Context` should be +//! used. +//! +//! # Examples: +//! +//! ## Signing a value and verifying it wasn't tampered with +//! +//! ``` +//! use ring::{hmac, rand}; +//! +//! let rng = rand::SystemRandom::new(); +//! let key = hmac::Key::generate(hmac::HMAC_SHA256, &rng)?; +//! +//! let msg = "hello, world"; +//! +//! let tag = hmac::sign(&key, msg.as_bytes()); +//! +//! // [We give access to the message to an untrusted party, and they give it +//! // back to us. We need to verify they didn't tamper with it.] +//! +//! hmac::verify(&key, msg.as_bytes(), tag.as_ref())?; +//! +//! # Ok::<(), ring::error::Unspecified>(()) +//! ``` +//! +//! ## Using the one-shot API: +//! +//! ``` +//! use ring::{digest, hmac, rand}; +//! use ring::rand::SecureRandom; +//! +//! let msg = "hello, world"; +//! +//! // The sender generates a secure key value and signs the message with it. +//! // Note that in a real protocol, a key agreement protocol would be used to +//! // derive `key_value`. +//! let rng = rand::SystemRandom::new(); +//! let key_value: [u8; digest::SHA256_OUTPUT_LEN] = rand::generate(&rng)?.expose(); +//! +//! let s_key = hmac::Key::new(hmac::HMAC_SHA256, key_value.as_ref()); +//! let tag = hmac::sign(&s_key, msg.as_bytes()); +//! +//! // The receiver (somehow!) knows the key value, and uses it to verify the +//! // integrity of the message. +//! let v_key = hmac::Key::new(hmac::HMAC_SHA256, key_value.as_ref()); +//! hmac::verify(&v_key, msg.as_bytes(), tag.as_ref())?; +//! +//! # Ok::<(), ring::error::Unspecified>(()) +//! ``` +//! +//! ## Using the multi-part API: +//! ``` +//! use ring::{digest, hmac, rand}; +//! use ring::rand::SecureRandom; +//! +//! let parts = ["hello", ", ", "world"]; +//! +//! // The sender generates a secure key value and signs the message with it. +//! // Note that in a real protocol, a key agreement protocol would be used to +//! // derive `key_value`. +//! let rng = rand::SystemRandom::new(); +//! let mut key_value: [u8; digest::SHA384_OUTPUT_LEN] = rand::generate(&rng)?.expose(); +//! +//! let s_key = hmac::Key::new(hmac::HMAC_SHA384, key_value.as_ref()); +//! let mut s_ctx = hmac::Context::with_key(&s_key); +//! for part in &parts { +//! s_ctx.update(part.as_bytes()); +//! } +//! let tag = s_ctx.sign(); +//! +//! // The receiver (somehow!) knows the key value, and uses it to verify the +//! // integrity of the message. +//! let v_key = hmac::Key::new(hmac::HMAC_SHA384, key_value.as_ref()); +//! let mut msg = Vec::::new(); +//! for part in &parts { +//! msg.extend(part.as_bytes()); +//! } +//! hmac::verify(&v_key, &msg.as_ref(), tag.as_ref())?; +//! +//! # Ok::<(), ring::error::Unspecified>(()) +//! ``` +//! +//! [RFC 2104]: https://tools.ietf.org/html/rfc2104 + +use crate::{ + bb, cpu, + digest::{self, Digest, FinishError}, + error, hkdf, rand, +}; + +pub(crate) use crate::digest::InputTooLongError; + +/// An HMAC algorithm. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub struct Algorithm(&'static digest::Algorithm); + +impl Algorithm { + /// The digest algorithm this HMAC algorithm is based on. + #[inline] + pub fn digest_algorithm(&self) -> &'static digest::Algorithm { + self.0 + } +} + +/// HMAC using SHA-1. Obsolete. +pub static HMAC_SHA1_FOR_LEGACY_USE_ONLY: Algorithm = Algorithm(&digest::SHA1_FOR_LEGACY_USE_ONLY); + +/// HMAC using SHA-256. +pub static HMAC_SHA256: Algorithm = Algorithm(&digest::SHA256); + +/// HMAC using SHA-384. +pub static HMAC_SHA384: Algorithm = Algorithm(&digest::SHA384); + +/// HMAC using SHA-512. +pub static HMAC_SHA512: Algorithm = Algorithm(&digest::SHA512); + +/// An HMAC tag. +/// +/// For a given tag `t`, use `t.as_ref()` to get the tag value as a byte slice. +#[derive(Clone, Copy, Debug)] +pub struct Tag(Digest); + +impl AsRef<[u8]> for Tag { + #[inline] + fn as_ref(&self) -> &[u8] { + self.0.as_ref() + } +} + +/// A key to use for HMAC signing. +#[derive(Clone)] +pub struct Key { + inner: digest::BlockContext, + outer: digest::BlockContext, +} + +impl core::fmt::Debug for Key { + fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> { + f.debug_struct("Key") + .field("algorithm", self.algorithm().digest_algorithm()) + .finish() + } +} + +impl Key { + /// Generate an HMAC signing key using the given digest algorithm with a + /// random value generated from `rng`. + /// + /// The key will be `digest_alg.output_len` bytes long, based on the + /// recommendation in [RFC 2104 Section 3]. + /// + /// [RFC 2104 Section 3]: https://tools.ietf.org/html/rfc2104#section-3 + pub fn generate( + algorithm: Algorithm, + rng: &dyn rand::SecureRandom, + ) -> Result { + Self::construct(algorithm, |buf| rng.fill(buf), cpu::features()) + } + + fn construct( + algorithm: Algorithm, + fill: F, + cpu: cpu::Features, + ) -> Result + where + F: FnOnce(&mut [u8]) -> Result<(), error::Unspecified>, + { + let mut key_bytes = [0; digest::MAX_OUTPUT_LEN]; + let key_bytes = &mut key_bytes[..algorithm.0.output_len()]; + fill(key_bytes)?; + Self::try_new(algorithm, key_bytes, cpu).map_err(error::erase::) + } + + /// Construct an HMAC signing key using the given digest algorithm and key + /// value. + /// + /// `key_value` should be a value generated using a secure random number + /// generator (e.g. the `key_value` output by + /// `SealingKey::generate_serializable()`) or derived from a random key by + /// a key derivation function (e.g. `ring::hkdf`). In particular, + /// `key_value` shouldn't be a password. + /// + /// As specified in RFC 2104, if `key_value` is shorter than the digest + /// algorithm's block length (as returned by `digest::Algorithm::block_len()`, + /// not the digest length returned by `digest::Algorithm::output_len()`) then + /// it will be padded with zeros. Similarly, if it is longer than the block + /// length then it will be compressed using the digest algorithm. + /// + /// You should not use keys larger than the `digest_alg.block_len` because + /// the truncation described above reduces their strength to only + /// `digest_alg.output_len * 8` bits. Support for such keys is likely to be + /// removed in a future version of *ring*. + pub fn new(algorithm: Algorithm, key_value: &[u8]) -> Self { + Self::try_new(algorithm, key_value, cpu::features()) + .map_err(error::erase::) + .unwrap() + } + + pub(crate) fn try_new( + algorithm: Algorithm, + key_value: &[u8], + cpu_features: cpu::Features, + ) -> Result { + let digest_alg = algorithm.0; + let mut key = Self { + inner: digest::BlockContext::new(digest_alg), + outer: digest::BlockContext::new(digest_alg), + }; + + let block_len = digest_alg.block_len(); + + let key_hash; + let key_value = if key_value.len() <= block_len { + key_value + } else { + key_hash = Digest::compute_from(digest_alg, key_value, cpu_features)?; + key_hash.as_ref() + }; + + const IPAD: u8 = 0x36; + + let mut padded_key = [IPAD; digest::MAX_BLOCK_LEN]; + let padded_key = &mut padded_key[..block_len]; + + // If the key is shorter than one block then we're supposed to act like + // it is padded with zero bytes up to the block length. `x ^ 0 == x` so + // we can just leave the trailing bytes of `padded_key` untouched. + bb::xor_assign_at_start(&mut padded_key[..], key_value); + + let leftover = key.inner.update(padded_key, cpu_features); + debug_assert_eq!(leftover.len(), 0); + + const OPAD: u8 = 0x5C; + + // Remove the `IPAD` masking, leaving the unmasked padded key, then + // mask with `OPAD`, all in one step. + bb::xor_assign(&mut padded_key[..], IPAD ^ OPAD); + let leftover = key.outer.update(padded_key, cpu_features); + debug_assert_eq!(leftover.len(), 0); + + Ok(key) + } + + /// The digest algorithm for the key. + #[inline] + pub fn algorithm(&self) -> Algorithm { + Algorithm(self.inner.algorithm) + } + + pub(crate) fn sign(&self, data: &[u8], cpu: cpu::Features) -> Result { + let mut ctx = Context::with_key(self); + ctx.update(data); + ctx.try_sign(cpu) + } + + fn verify(&self, data: &[u8], tag: &[u8], cpu: cpu::Features) -> Result<(), VerifyError> { + let computed = self + .sign(data, cpu) + .map_err(VerifyError::InputTooLongError)?; + bb::verify_slices_are_equal(computed.as_ref(), tag) + .map_err(|_: error::Unspecified| VerifyError::Mismatch) + } +} + +impl hkdf::KeyType for Algorithm { + fn len(&self) -> usize { + self.digest_algorithm().output_len() + } +} + +impl From> for Key { + fn from(okm: hkdf::Okm) -> Self { + Self::construct(*okm.len(), |buf| okm.fill(buf), cpu::features()).unwrap() + } +} + +/// A context for multi-step (Init-Update-Finish) HMAC signing. +/// +/// Use `sign` for single-step HMAC signing. +#[derive(Clone)] +pub struct Context { + inner: digest::Context, + outer: digest::BlockContext, +} + +impl core::fmt::Debug for Context { + fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> { + f.debug_struct("Context") + .field("algorithm", self.inner.algorithm()) + .finish() + } +} + +impl Context { + /// Constructs a new HMAC signing context using the given digest algorithm + /// and key. + pub fn with_key(signing_key: &Key) -> Self { + Self { + inner: digest::Context::clone_from(&signing_key.inner), + outer: signing_key.outer.clone(), + } + } + + /// Updates the HMAC with all the data in `data`. `update` may be called + /// zero or more times until `finish` is called. + pub fn update(&mut self, data: &[u8]) { + self.inner.update(data); + } + + /// Finalizes the HMAC calculation and returns the HMAC value. `sign` + /// consumes the context so it cannot be (mis-)used after `sign` has been + /// called. + /// + /// It is generally not safe to implement HMAC verification by comparing + /// the return value of `sign` to a tag. Use `verify` for verification + /// instead. + pub fn sign(self) -> Tag { + self.try_sign(cpu::features()) + .map_err(error::erase::) + .unwrap() + } + + pub(crate) fn try_sign(self, cpu_features: cpu::Features) -> Result { + // Consequently, `num_pending` is valid. + debug_assert_eq!(self.inner.algorithm(), self.outer.algorithm); + debug_assert!(self.inner.algorithm().output_len() < self.outer.algorithm.block_len()); + + let inner = self.inner.try_finish(cpu_features)?; + let inner = inner.as_ref(); + let num_pending = inner.len(); + let buffer = &mut [0u8; digest::MAX_BLOCK_LEN]; + const _BUFFER_IS_LARGE_ENOUGH_TO_HOLD_INNER: () = + assert!(digest::MAX_OUTPUT_LEN < digest::MAX_BLOCK_LEN); + buffer[..num_pending].copy_from_slice(inner); + + self.outer + .try_finish(buffer, num_pending, cpu_features) + .map(Tag) + .map_err(|err| match err { + FinishError::InputTooLong(i) => { + // Unreachable, as we gave the inner context exactly the + // same input we gave the outer context, and + // `inner.try_finish` already succeeded. However, it is + // quite difficult to prove this, and we already return + // `InputTooLongError`, so just forward it along. + i + } + FinishError::PendingNotAPartialBlock(_) => { + // Follows from the assertions above. + unreachable!() + } + }) + } +} + +/// Calculates the HMAC of `data` using the key `key` in one step. +/// +/// Use `Context` to calculate HMACs where the input is in multiple parts. +/// +/// It is generally not safe to implement HMAC verification by comparing the +/// return value of `sign` to a tag. Use `verify` for verification instead. +pub fn sign(key: &Key, data: &[u8]) -> Tag { + key.sign(data, cpu::features()) + .map_err(error::erase::) + .unwrap() +} + +/// Calculates the HMAC of `data` using the signing key `key`, and verifies +/// whether the resultant value equals `tag`, in one step. +/// +/// This is logically equivalent to, but more efficient than, constructing a +/// `Key` with the same value as `key` and then using `verify`. +/// +/// The verification will be done in constant time to prevent timing attacks. +pub fn verify(key: &Key, data: &[u8], tag: &[u8]) -> Result<(), error::Unspecified> { + key.verify(data, tag, cpu::features()) + .map_err(|_: VerifyError| error::Unspecified) +} + +enum VerifyError { + // Theoretically somebody could have calculated a valid tag with a gigantic + // input that we do not support. If we were to support every theoretically + // valid input length, for *every* digest algorithm, then we could argue + // that hitting the input length limit implies a mismatch since nobody + // could have calculated such a tag with the given input. + #[allow(dead_code)] + InputTooLongError(InputTooLongError), + + Mismatch, +} + +#[cfg(test)] +mod tests { + use crate::{hmac, rand}; + + // Make sure that `Key::generate` and `verify_with_own_key` aren't + // completely wacky. + #[test] + pub fn hmac_signing_key_coverage() { + let rng = rand::SystemRandom::new(); + + const HELLO_WORLD_GOOD: &[u8] = b"hello, world"; + const HELLO_WORLD_BAD: &[u8] = b"hello, worle"; + + for algorithm in &[ + hmac::HMAC_SHA1_FOR_LEGACY_USE_ONLY, + hmac::HMAC_SHA256, + hmac::HMAC_SHA384, + hmac::HMAC_SHA512, + ] { + let key = hmac::Key::generate(*algorithm, &rng).unwrap(); + let tag = hmac::sign(&key, HELLO_WORLD_GOOD); + assert!(hmac::verify(&key, HELLO_WORLD_GOOD, tag.as_ref()).is_ok()); + assert!(hmac::verify(&key, HELLO_WORLD_BAD, tag.as_ref()).is_err()) + } + } +} diff --git a/http/vendor/ring/src/io.rs b/http/vendor/ring/src/io.rs new file mode 100644 index 0000000..232d5ff --- /dev/null +++ b/http/vendor/ring/src/io.rs @@ -0,0 +1,31 @@ +// Copyright 2018 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! Serialization and deserialization. + +#[doc(hidden)] +pub mod der; + +#[cfg(feature = "alloc")] +mod writer; + +#[cfg(feature = "alloc")] +pub(crate) mod der_writer; + +pub(crate) mod positive; + +pub use self::positive::Positive; + +#[cfg(feature = "alloc")] +pub(crate) use self::writer::TooLongError; diff --git a/http/vendor/ring/src/io/der.rs b/http/vendor/ring/src/io/der.rs new file mode 100644 index 0000000..52aed92 --- /dev/null +++ b/http/vendor/ring/src/io/der.rs @@ -0,0 +1,301 @@ +// Copyright 2015 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! Building blocks for parsing DER-encoded ASN.1 structures. +//! +//! This module contains the foundational parts of an ASN.1 DER parser. + +use super::Positive; +use crate::error; + +pub const CONSTRUCTED: u8 = 1 << 5; +pub const CONTEXT_SPECIFIC: u8 = 2 << 6; + +#[derive(Clone, Copy, PartialEq)] +#[repr(u8)] +pub enum Tag { + Boolean = 0x01, + Integer = 0x02, + BitString = 0x03, + OctetString = 0x04, + Null = 0x05, + OID = 0x06, + Sequence = CONSTRUCTED | 0x10, // 0x30 + UTCTime = 0x17, + GeneralizedTime = 0x18, + + ContextSpecific1 = CONTEXT_SPECIFIC | 1, + + ContextSpecificConstructed0 = CONTEXT_SPECIFIC | CONSTRUCTED | 0, + ContextSpecificConstructed1 = CONTEXT_SPECIFIC | CONSTRUCTED | 1, + ContextSpecificConstructed3 = CONTEXT_SPECIFIC | CONSTRUCTED | 3, +} + +impl From for usize { + fn from(tag: Tag) -> Self { + Self::from(Tag::into(tag)) + } +} + +impl From for u8 { + fn from(tag: Tag) -> Self { + Tag::into(tag) + } +} + +// `impl From for u8` but as a `const fn`. +impl Tag { + pub const fn into(self) -> u8 { + self as u8 + } +} + +pub fn expect_tag_and_get_value<'a>( + input: &mut untrusted::Reader<'a>, + tag: Tag, +) -> Result, error::Unspecified> { + let (actual_tag, inner) = read_tag_and_get_value(input)?; + if usize::from(tag) != usize::from(actual_tag) { + return Err(error::Unspecified); + } + Ok(inner) +} + +pub fn read_tag_and_get_value<'a>( + input: &mut untrusted::Reader<'a>, +) -> Result<(u8, untrusted::Input<'a>), error::Unspecified> { + let tag = input.read_byte()?; + if (tag & 0x1F) == 0x1F { + return Err(error::Unspecified); // High tag number form is not allowed. + } + + // If the high order bit of the first byte is set to zero then the length + // is encoded in the seven remaining bits of that byte. Otherwise, those + // seven bits represent the number of bytes used to encode the length. + let length = match input.read_byte()? { + n if (n & 0x80) == 0 => usize::from(n), + 0x81 => { + let second_byte = input.read_byte()?; + if second_byte < 128 { + return Err(error::Unspecified); // Not the canonical encoding. + } + usize::from(second_byte) + } + 0x82 => { + let second_byte = usize::from(input.read_byte()?); + let third_byte = usize::from(input.read_byte()?); + let combined = (second_byte << 8) | third_byte; + if combined < 256 { + return Err(error::Unspecified); // Not the canonical encoding. + } + combined + } + _ => { + return Err(error::Unspecified); // We don't support longer lengths. + } + }; + + let inner = input.read_bytes(length)?; + Ok((tag, inner)) +} + +#[inline] +pub fn bit_string_with_no_unused_bits<'a>( + input: &mut untrusted::Reader<'a>, +) -> Result, error::Unspecified> { + bit_string_tagged_with_no_unused_bits(Tag::BitString, input) +} + +pub(crate) fn bit_string_tagged_with_no_unused_bits<'a>( + tag: Tag, + input: &mut untrusted::Reader<'a>, +) -> Result, error::Unspecified> { + nested(input, tag, error::Unspecified, |value| { + let unused_bits_at_end = value.read_byte().map_err(|_| error::Unspecified)?; + if unused_bits_at_end != 0 { + return Err(error::Unspecified); + } + Ok(value.read_bytes_to_end()) + }) +} + +// TODO: investigate taking decoder as a reference to reduce generated code +// size. +pub fn nested<'a, F, R, E: Copy>( + input: &mut untrusted::Reader<'a>, + tag: Tag, + error: E, + decoder: F, +) -> Result +where + F: FnOnce(&mut untrusted::Reader<'a>) -> Result, +{ + let inner = expect_tag_and_get_value(input, tag).map_err(|_| error)?; + inner.read_all(error, decoder) +} + +pub(crate) fn nonnegative_integer<'a>( + input: &mut untrusted::Reader<'a>, +) -> Result, error::Unspecified> { + let value = expect_tag_and_get_value(input, Tag::Integer)?; + match value + .as_slice_less_safe() + .split_first() + .ok_or(error::Unspecified)? + { + // Zero or leading zero. + (0, rest) => { + match rest.first() { + // Zero. + None => Ok(value), + // Necessary leading zero. + Some(&second) if second & 0x80 == 0x80 => Ok(untrusted::Input::from(rest)), + // Unnecessary leading zero. + _ => Err(error::Unspecified), + } + } + // Positive value with no leading zero. + (first, _) if first & 0x80 == 0 => Ok(value), + // Negative value. + (_, _) => Err(error::Unspecified), + } +} + +/// Parse as integer with a value in the in the range [0, 255], returning its +/// numeric value. This is typically used for parsing version numbers. +#[inline] +pub fn small_nonnegative_integer(input: &mut untrusted::Reader) -> Result { + let value = nonnegative_integer(input)?; + match *value.as_slice_less_safe() { + [b] => Ok(b), + _ => Err(error::Unspecified), + } +} + +/// Parses a positive DER integer, returning the big-endian-encoded value, +/// sans any leading zero byte. +pub fn positive_integer<'a>( + input: &mut untrusted::Reader<'a>, +) -> Result, error::Unspecified> { + let value = nonnegative_integer(input)?; + Positive::from_be_bytes(value) +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::error; + + fn with_i<'a, F, R>(value: &'a [u8], f: F) -> Result + where + F: FnOnce(&mut untrusted::Reader<'a>) -> Result, + { + untrusted::Input::from(value).read_all(error::Unspecified, f) + } + + static ZERO_INTEGER: &[u8] = &[0x02, 0x01, 0x00]; + + static GOOD_POSITIVE_INTEGERS_SMALL: &[(&[u8], u8)] = &[ + (&[0x02, 0x01, 0x01], 0x01), + (&[0x02, 0x01, 0x02], 0x02), + (&[0x02, 0x01, 0x7e], 0x7e), + (&[0x02, 0x01, 0x7f], 0x7f), + // Values that need to have an 0x00 prefix to disambiguate them from + // them from negative values. + (&[0x02, 0x02, 0x00, 0x80], 0x80), + (&[0x02, 0x02, 0x00, 0x81], 0x81), + (&[0x02, 0x02, 0x00, 0xfe], 0xfe), + (&[0x02, 0x02, 0x00, 0xff], 0xff), + ]; + + static GOOD_POSITIVE_INTEGERS_LARGE: &[(&[u8], &[u8])] = &[ + (&[0x02, 0x02, 0x01, 0x00], &[0x01, 0x00]), + (&[0x02, 0x02, 0x02, 0x01], &[0x02, 0x01]), + (&[0x02, 0x02, 0x7e, 0xfe], &[0x7e, 0xfe]), + (&[0x02, 0x02, 0x7f, 0xff], &[0x7f, 0xff]), + // Values that need to have an 0x00 prefix to disambiguate them from + // them from negative values. + (&[0x02, 0x03, 0x00, 0x80, 0x00], &[0x80, 0x00]), + (&[0x02, 0x03, 0x00, 0x81, 0x01], &[0x81, 0x01]), + (&[0x02, 0x03, 0x00, 0xfe, 0xfe], &[0xfe, 0xfe]), + (&[0x02, 0x03, 0x00, 0xff, 0xff], &[0xff, 0xff]), + ]; + + static BAD_NONNEGATIVE_INTEGERS: &[&[u8]] = &[ + &[], // At end of input + &[0x02], // Tag only + &[0x02, 0x00], // Empty value + // Length mismatch + &[0x02, 0x00, 0x01], + &[0x02, 0x01], + // Would be valid if leading zero is ignored when comparing length. + &[0x02, 0x01, 0x00, 0x01], + &[0x02, 0x01, 0x01, 0x00], // Would be valid if last byte is ignored. + &[0x02, 0x02, 0x01], + // Values that are missing a necessary leading 0x00 + &[0x02, 0x01, 0x80], + &[0x02, 0x01, 0x81], + &[0x02, 0x01, 0xfe], + &[0x02, 0x01, 0xff], + // Values that have an unnecessary leading 0x00 + &[0x02, 0x02, 0x00, 0x00], + &[0x02, 0x02, 0x00, 0x01], + &[0x02, 0x02, 0x00, 0x02], + &[0x02, 0x02, 0x00, 0x7e], + &[0x02, 0x02, 0x00, 0x7f], + ]; + + #[test] + fn test_small_nonnegative_integer() { + let zero = (ZERO_INTEGER, 0x00); + for &(test_in, test_out) in + core::iter::once(&zero).chain(GOOD_POSITIVE_INTEGERS_SMALL.iter()) + { + let result = with_i(test_in, |input| { + assert_eq!(small_nonnegative_integer(input)?, test_out); + Ok(()) + }); + assert_eq!(result, Ok(())); + } + for &test_in in BAD_NONNEGATIVE_INTEGERS + .iter() + .chain(GOOD_POSITIVE_INTEGERS_LARGE.iter().map(|(input, _)| input)) + { + let result = with_i(test_in, small_nonnegative_integer); + assert_eq!(result, Err(error::Unspecified)); + } + } + + #[test] + fn test_positive_integer() { + for (test_in, test_out) in GOOD_POSITIVE_INTEGERS_SMALL + .iter() + .map(|(test_in, test_out)| (*test_in, core::slice::from_ref(test_out))) + .chain(GOOD_POSITIVE_INTEGERS_LARGE.iter().copied()) + { + let result = with_i(test_in, |input| { + assert_eq!( + positive_integer(input)?.big_endian_without_leading_zero(), + test_out + ); + Ok(()) + }); + assert_eq!(result, Ok(())) + } + for &test_in in core::iter::once(&ZERO_INTEGER).chain(BAD_NONNEGATIVE_INTEGERS.iter()) { + let result = with_i(test_in, positive_integer); + assert!(matches!(result, Err(error::Unspecified))); + } + } +} diff --git a/http/vendor/ring/src/io/der_writer.rs b/http/vendor/ring/src/io/der_writer.rs new file mode 100644 index 0000000..d6f9717 --- /dev/null +++ b/http/vendor/ring/src/io/der_writer.rs @@ -0,0 +1,71 @@ +// Copyright 2018 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::{der::*, writer::*, *}; +use alloc::boxed::Box; + +pub(crate) fn write_positive_integer( + output: &mut dyn Accumulator, + value: &Positive, +) -> Result<(), TooLongError> { + let first_byte = value.first_byte(); + let value = value.big_endian_without_leading_zero_as_input(); + write_tlv(output, Tag::Integer, |output| { + if (first_byte & 0x80) != 0 { + output.write_byte(0)?; // Disambiguate negative number. + } + write_copy(output, value) + }) +} + +pub(crate) fn write_all( + tag: Tag, + write_value: &dyn Fn(&mut dyn Accumulator) -> Result<(), TooLongError>, +) -> Result, TooLongError> { + let length = { + let mut length = LengthMeasurement::zero(); + write_tlv(&mut length, tag, write_value)?; + length + }; + + let mut output = Writer::with_capacity(length); + write_tlv(&mut output, tag, write_value)?; + + Ok(output.into()) +} + +fn write_tlv(output: &mut dyn Accumulator, tag: Tag, write_value: F) -> Result<(), TooLongError> +where + F: Fn(&mut dyn Accumulator) -> Result<(), TooLongError>, +{ + let length: usize = { + let mut length = LengthMeasurement::zero(); + write_value(&mut length)?; + length.into() + }; + let length: u16 = length.try_into().map_err(|_| TooLongError::new())?; + + output.write_byte(tag.into())?; + + let [lo, hi] = length.to_le_bytes(); + if length >= 0x1_00 { + output.write_byte(0x82)?; + output.write_byte(hi)?; + } else if length >= 0x80 { + output.write_byte(0x81)?; + } + output.write_byte(lo)?; + + write_value(output) +} diff --git a/http/vendor/ring/src/io/positive.rs b/http/vendor/ring/src/io/positive.rs new file mode 100644 index 0000000..33f2fef --- /dev/null +++ b/http/vendor/ring/src/io/positive.rs @@ -0,0 +1,98 @@ +// Copyright 2018 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! Serialization and deserialization. + +use crate::error; + +/// A serialized positive integer. +#[derive(Copy, Clone)] +pub struct Positive<'a>(untrusted::Input<'a>); + +impl<'a> Positive<'a> { + #[inline] + pub(crate) fn from_be_bytes(input: untrusted::Input<'a>) -> Result { + // Empty inputs are not allowed. + let &first_byte = input + .as_slice_less_safe() + .first() + .ok_or(error::Unspecified)?; + // Zero isn't allowed and leading zeros aren't allowed. + if first_byte == 0 { + return Err(error::Unspecified); + } + Ok(Self(input)) + } + + /// Returns the value, ordered from significant byte to least significant + /// byte, without any leading zeros. The result is guaranteed to be + /// non-empty. + #[inline] + pub fn big_endian_without_leading_zero(&self) -> &'a [u8] { + self.big_endian_without_leading_zero_as_input() + .as_slice_less_safe() + } + + #[inline] + pub(crate) fn big_endian_without_leading_zero_as_input(&self) -> untrusted::Input<'a> { + self.0 + } +} + +impl Positive<'_> { + /// Returns the first byte. + /// + /// Will not panic because the value is guaranteed to have at least one + /// byte. + pub fn first_byte(&self) -> u8 { + // This won't panic because + self.0.as_slice_less_safe()[0] + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_from_be_bytes() { + static TEST_CASES: &[(&[u8], Result<&[u8], error::Unspecified>)] = &[ + // An empty input isn't a number. + (&[], Err(error::Unspecified)), + // Zero is not positive. + (&[0x00], Err(error::Unspecified)), + // Minimum value. No leading zero required or allowed. + (&[0x00, 0x01], Err(error::Unspecified)), + (&[0x01], Ok(&[0x01])), + // Maximum first byte. No leading zero required or allowed. + (&[0xff], Ok(&[0xff])), + (&[0x00, 0xff], Err(error::Unspecified)), + // The last byte can be zero. + (&[0x01, 0x00], Ok(&[0x01, 0x00])), + (&[0x01, 0x00, 0x00], Ok(&[0x01, 0x00, 0x00])), + // Having no zero bytes are also allowed. + (&[0x01, 0x01], Ok(&[0x01, 0x01])), + // A middle byte can be zero. + (&[0x01, 0x00, 0x01], Ok(&[0x01, 0x00, 0x01])), + (&[0x01, 0x01, 0x01], Ok(&[0x01, 0x01, 0x01])), + ]; + for &(input, result) in TEST_CASES { + let input = untrusted::Input::from(input); + assert_eq!( + Positive::from_be_bytes(input).map(|p| p.big_endian_without_leading_zero()), + result + ); + } + } +} diff --git a/http/vendor/ring/src/io/writer.rs b/http/vendor/ring/src/io/writer.rs new file mode 100644 index 0000000..9ebe0d3 --- /dev/null +++ b/http/vendor/ring/src/io/writer.rs @@ -0,0 +1,97 @@ +// Copyright 2018 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use alloc::{boxed::Box, vec::Vec}; + +pub trait Accumulator { + fn write_byte(&mut self, value: u8) -> Result<(), TooLongError>; + fn write_bytes(&mut self, value: &[u8]) -> Result<(), TooLongError>; +} + +pub(super) struct LengthMeasurement { + len: usize, +} + +impl From for usize { + fn from(len: LengthMeasurement) -> usize { + len.len + } +} + +impl LengthMeasurement { + pub fn zero() -> Self { + Self { len: 0 } + } +} + +impl Accumulator for LengthMeasurement { + fn write_byte(&mut self, _value: u8) -> Result<(), TooLongError> { + self.len = self.len.checked_add(1).ok_or_else(TooLongError::new)?; + Ok(()) + } + fn write_bytes(&mut self, value: &[u8]) -> Result<(), TooLongError> { + self.len = self + .len + .checked_add(value.len()) + .ok_or_else(TooLongError::new)?; + Ok(()) + } +} + +pub(super) struct Writer { + bytes: Vec, + requested_capacity: usize, +} + +impl Writer { + pub(super) fn with_capacity(capacity: LengthMeasurement) -> Self { + Self { + bytes: Vec::with_capacity(capacity.len), + requested_capacity: capacity.len, + } + } +} + +impl From for Box<[u8]> { + fn from(writer: Writer) -> Self { + assert_eq!(writer.requested_capacity, writer.bytes.len()); + writer.bytes.into_boxed_slice() + } +} + +impl Accumulator for Writer { + fn write_byte(&mut self, value: u8) -> Result<(), TooLongError> { + self.bytes.push(value); + Ok(()) + } + fn write_bytes(&mut self, value: &[u8]) -> Result<(), TooLongError> { + self.bytes.extend(value); + Ok(()) + } +} + +pub fn write_copy( + accumulator: &mut dyn Accumulator, + to_copy: untrusted::Input, +) -> Result<(), TooLongError> { + accumulator.write_bytes(to_copy.as_slice_less_safe()) +} + +pub struct TooLongError(()); + +impl TooLongError { + pub fn new() -> Self { + Self(()) + } +} diff --git a/http/vendor/ring/src/lib.rs b/http/vendor/ring/src/lib.rs new file mode 100644 index 0000000..8881809 --- /dev/null +++ b/http/vendor/ring/src/lib.rs @@ -0,0 +1,177 @@ +// Copyright 2015-2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! # Feature Flags +//! +//! +//!
Feature +//! Description +//!
alloc (default) +//! Enable features that require use of the heap, RSA in particular. +//!
less-safe-getrandom-custom-or-rdrand +//! Treat user-provided ("custom") and RDRAND-based getrandom +//! implementations as secure random number generators (see +//! SecureRandom). This feature only works with +//! os = "none" targets. See +//! +//! register_custom_getrandom +//! and +//! RDRAND on x86 +//! for additional details. +//!
less-safe-getrandom-espidf +//! Treat getrandom as a secure random number generator (see +//! SecureRandom) on the esp-idf target. While the esp-idf +//! target does have hardware RNG, it is beyond the scope of ring to +//! ensure its configuration. This feature allows ring to build +//! on esp-idf despite the likelihood that RNG is not secure. +//! This feature only works with os = espidf targets. +//! See +//!
std +//! Enable features that use libstd, in particular +//! std::error::Error integration. Implies `alloc`. +//!
wasm32_unknown_unknown_js +//! When this feature is enabled, for the wasm32-unknown-unknown target, +//! Web APIs will be used to implement features like `ring::rand` that +//! require an operating environment of some kind. This has no effect +//! for any other target. This enables the `getrandom` crate's `js` +//! feature. +//!
+ +// When running mk/package.sh, don't actually build any code. +#![allow( + clippy::collapsible_if, + clippy::identity_op, + clippy::len_without_is_empty, + clippy::let_unit_value, + clippy::new_without_default, + clippy::neg_cmp_op_on_partial_ord, + clippy::too_many_arguments, + clippy::type_complexity, + non_camel_case_types, + non_snake_case, + unsafe_code +)] +#![deny(variant_size_differences)] +#![forbid( + unused_results, + unsafe_op_in_unsafe_fn, + clippy::char_lit_as_u8, + clippy::fn_to_numeric_cast, + clippy::fn_to_numeric_cast_with_truncation, + clippy::ptr_as_ptr +)] +#![warn( + clippy::unnecessary_cast, + clippy::cast_lossless, + clippy::cast_possible_truncation, + clippy::cast_possible_wrap, + clippy::cast_precision_loss, + clippy::cast_sign_loss +)] +#![cfg_attr( + not(any( + all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little"), + target_arch = "x86", + target_arch = "x86_64", + feature = "alloc" + )), + allow(dead_code, unused_imports, unused_macros) +)] +#![no_std] + +#[cfg(feature = "alloc")] +extern crate alloc; + +#[macro_use] +mod debug; + +#[macro_use] +mod prefixed; + +#[doc(hidden)] +#[macro_use] +mod testutil; + +#[macro_use] +mod bssl; + +#[macro_use] +mod polyfill; + +pub mod aead; + +pub mod agreement; +mod arithmetic; +mod bits; + +pub(crate) mod bb; +pub(crate) mod c; + +#[doc(hidden)] +#[deprecated( + note = "Will be removed. Internal module not intended for external use, with no promises regarding side channels." +)] +pub mod deprecated_constant_time; + +#[doc(hidden)] +#[allow(deprecated)] +#[deprecated( + note = "Will be removed. Internal module not intended for external use, with no promises regarding side channels." +)] +pub use deprecated_constant_time as constant_time; + +pub mod io; + +mod cpu; +pub mod digest; +mod ec; +pub mod error; +pub mod hkdf; +pub mod hmac; +mod limb; +pub mod pbkdf2; +pub mod pkcs8; +pub mod rand; + +#[cfg(feature = "alloc")] +pub mod rsa; + +pub mod signature; + +#[cfg(test)] +mod tests; + +mod sealed { + /// Traits that are designed to only be implemented internally in *ring*. + // + // Usage: + // ``` + // use crate::sealed; + // + // pub trait MyType: sealed::Sealed { + // // [...] + // } + // + // impl sealed::Sealed for MyType {} + // ``` + pub trait Sealed {} +} + +#[deprecated(note = "internal API that will be removed")] +pub mod deprecated_test; + +#[allow(deprecated)] +#[deprecated(note = "internal API that will be removed")] +pub use deprecated_test as test; diff --git a/http/vendor/ring/src/limb.rs b/http/vendor/ring/src/limb.rs new file mode 100644 index 0000000..fef4bc0 --- /dev/null +++ b/http/vendor/ring/src/limb.rs @@ -0,0 +1,662 @@ +// Copyright 2016 David Judd. +// Copyright 2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! Unsigned multi-precision integer arithmetic. +//! +//! Limbs ordered least-significant-limb to most-significant-limb. The bits +//! limbs use the native endianness. + +use crate::{ + arithmetic::inout::{AliasingSlices2, AliasingSlices3}, + bb, c, + error::{self, LenMismatchError}, + polyfill::{sliceutil, usize_from_u32, ArrayFlatMap}, +}; +use core::{iter, num::NonZeroUsize}; + +#[cfg(any(test, feature = "alloc"))] +use crate::bits; + +#[cfg(feature = "alloc")] +use core::num::Wrapping; + +// XXX: Not correct for x32 ABIs. +pub type Limb = bb::Word; +pub type LeakyLimb = bb::LeakyWord; +pub const LIMB_BITS: usize = usize_from_u32(Limb::BITS); +pub const LIMB_BYTES: usize = (LIMB_BITS + 7) / 8; + +pub type LimbMask = bb::BoolMask; + +#[inline] +pub fn limbs_equal_limbs_consttime(a: &[Limb], b: &[Limb]) -> Result { + if a.len() != b.len() { + return Err(LenMismatchError::new(a.len())); + } + let all = a.iter().zip(b).fold(0, |running, (a, b)| running | (a ^ b)); + Ok(limb_is_zero(all)) +} + +#[inline] +fn limbs_less_than_limbs(a: &[Limb], b: &[Limb]) -> Result { + prefixed_extern! { + fn LIMBS_less_than(a: *const Limb, b: *const Limb, num_limbs: c::NonZero_size_t) + -> LimbMask; + } + // Use `b.len` because usually `b` will be the modulus which is likely to + // have had its length checked already so this can be elided by the + // optimizer. + // XXX: Questionable whether `LenMismatchError` is appropriate. + let len = NonZeroUsize::new(b.len()).ok_or_else(|| LenMismatchError::new(a.len()))?; + if a.len() != len.get() { + return Err(LenMismatchError::new(a.len())); + } + Ok(unsafe { LIMBS_less_than(a.as_ptr(), b.as_ptr(), len) }) +} + +#[inline] +pub(crate) fn verify_limbs_less_than_limbs_leak_bit( + a: &[Limb], + b: &[Limb], +) -> Result<(), error::Unspecified> { + let r = limbs_less_than_limbs(a, b).map_err(error::erase::)?; + if r.leak() { + Ok(()) + } else { + Err(error::Unspecified) + } +} + +#[inline] +pub fn limbs_less_than_limbs_vartime(a: &[Limb], b: &[Limb]) -> Result { + let r = limbs_less_than_limbs(a, b)?; + Ok(r.leak()) +} + +#[inline] +fn limb_is_zero(limb: Limb) -> LimbMask { + prefixed_extern! { + fn LIMB_is_zero(limb: Limb) -> LimbMask; + } + unsafe { LIMB_is_zero(limb) } +} + +#[inline] +pub fn limbs_are_zero(limbs: &[Limb]) -> LimbMask { + limb_is_zero(limbs.iter().fold(0, |a, b| a | b)) +} + +/// Leaks one bit of information (other than the lengths of the inputs): +/// Whether the given limbs are even. +#[cfg(any(test, feature = "alloc"))] +#[inline] +pub fn limbs_reject_even_leak_bit(limbs: &[Limb]) -> Result<(), error::Unspecified> { + let bottom = *limbs.first().ok_or(error::Unspecified)?; + if limb_is_zero(bottom & 1).leak() { + return Err(error::Unspecified); + } + Ok(()) +} + +#[cfg(any(test, feature = "alloc"))] +#[inline] +pub fn verify_limbs_equal_1_leak_bit(a: &[Limb]) -> Result<(), error::Unspecified> { + if let [bottom, ref rest @ ..] = *a { + let equal = limb_is_zero(bottom ^ 1) & limbs_are_zero(rest); + if equal.leak() { + return Ok(()); + } + } + Err(error::Unspecified) +} + +/// Returns the number of bits in `a`. +// +// This strives to be constant-time with respect to the values of all bits +// except the most significant bit. This does not attempt to be constant-time +// with respect to `a.len()` or the value of the result or the value of the +// most significant bit (It's 1, unless the input is zero, in which case it's +// zero.) +#[cfg(any(test, feature = "alloc"))] +pub fn limbs_minimal_bits(a: &[Limb]) -> bits::BitLength { + for num_limbs in (1..=a.len()).rev() { + let high_limb = a[num_limbs - 1]; + + // Find the number of set bits in |high_limb| by a linear scan from the + // most significant bit to the least significant bit. This works great + // for the most common inputs because usually the most significant bit + // it set. + for high_limb_num_bits in (1..=LIMB_BITS).rev() { + let shifted = unsafe { LIMB_shr(high_limb, high_limb_num_bits - 1) }; + if shifted != 0 { + return bits::BitLength::from_bits( + ((num_limbs - 1) * LIMB_BITS) + high_limb_num_bits, + ); + } + } + } + + // No bits were set. + bits::BitLength::from_bits(0) +} + +/// Equivalent to `if (r >= m) { r -= m; }` +#[inline] +pub fn limbs_reduce_once(r: &mut [Limb], m: &[Limb]) -> Result<(), LenMismatchError> { + prefixed_extern! { + fn LIMBS_reduce_once(r: *mut Limb, m: *const Limb, num_limbs: c::NonZero_size_t); + } + let num_limbs = NonZeroUsize::new(r.len()).ok_or_else(|| LenMismatchError::new(m.len()))?; + let r = r.as_mut_ptr(); // Non-dangling because num_limbs is non-zero. + let m = m.as_ptr(); // Non-dangling because num_limbs is non-zero. + unsafe { LIMBS_reduce_once(r, m, num_limbs) }; + Ok(()) +} + +#[derive(Clone, Copy, PartialEq)] +pub enum AllowZero { + No, + Yes, +} + +/// Parses `input` into `result`, verifies that the value is less than +/// `max_exclusive`, and pads `result` with zeros to its length. If `allow_zero` +/// is not `AllowZero::Yes`, zero values are rejected. +/// +/// This attempts to be constant-time with respect to the actual value *only if* +/// the value is actually in range. In other words, this won't leak anything +/// about a valid value, but it might leak small amounts of information about an +/// invalid value (which constraint it failed). +pub fn parse_big_endian_in_range_and_pad_consttime( + input: untrusted::Input, + allow_zero: AllowZero, + max_exclusive: &[Limb], + result: &mut [Limb], +) -> Result<(), error::Unspecified> { + parse_big_endian_and_pad_consttime(input, result)?; + verify_limbs_less_than_limbs_leak_bit(result, max_exclusive)?; + if allow_zero != AllowZero::Yes { + if limbs_are_zero(result).leak() { + return Err(error::Unspecified); + } + } + Ok(()) +} + +/// Parses `input` into `result`, padding `result` with zeros to its length. +/// This attempts to be constant-time with respect to the value but not with +/// respect to the length; it is assumed that the length is public knowledge. +pub fn parse_big_endian_and_pad_consttime( + input: untrusted::Input, + result: &mut [Limb], +) -> Result<(), error::Unspecified> { + if input.is_empty() { + return Err(error::Unspecified); + } + let input_limbs = input.as_slice_less_safe().rchunks(LIMB_BYTES).map(|chunk| { + let mut padded = [0; LIMB_BYTES]; + sliceutil::overwrite_at_start(&mut padded[(LIMB_BYTES - chunk.len())..], chunk); + Limb::from_be_bytes(padded) + }); + if input_limbs.len() > result.len() { + return Err(error::Unspecified); + } + + result + .iter_mut() + .zip(input_limbs.chain(iter::repeat(0))) + .for_each(|(r, i)| *r = i); + + Ok(()) +} + +pub fn big_endian_from_limbs(limbs: &[Limb], out: &mut [u8]) { + let be_bytes = unstripped_be_bytes(limbs); + assert_eq!(out.len(), be_bytes.len()); + out.iter_mut().zip(be_bytes).for_each(|(o, i)| { + *o = i; + }); +} + +/// Returns an iterator of the big-endian encoding of `limbs`. +/// +/// The number of bytes returned will be a multiple of `LIMB_BYTES` +/// and thus may be padded with leading zeros. +pub fn unstripped_be_bytes(limbs: &[Limb]) -> impl ExactSizeIterator + Clone + '_ { + // The unwrap is safe because a slice can never be larger than `usize` bytes. + ArrayFlatMap::new(limbs.iter().rev().copied(), Limb::to_be_bytes).unwrap() +} + +// Used in FFI +pub type Window = bb::Word; + +// Used in FFI +pub type LeakyWindow = bb::LeakyWord; + +/// Processes `limbs` as a sequence of 5-bit windows, folding the windows from +/// most significant to least significant and returning the accumulated result. +/// The first window will be mapped by `init` to produce the initial value for +/// the accumulator. Then `f` will be called to fold the accumulator and the +/// next window until all windows are processed. When the input's bit length +/// isn't divisible by 5, the window passed to `init` will be partial; all +/// windows passed to `fold` will be full. +/// +/// This is designed to avoid leaking the contents of `limbs` through side +/// channels as long as `init` and `fold` are side-channel free. +/// +/// Panics if `limbs` is empty. +#[cfg(feature = "alloc")] +pub fn fold_5_bit_windows R, F: Fn(R, Window) -> R>( + limbs: &[Limb], + init: I, + fold: F, +) -> R { + #[derive(Clone, Copy)] + #[repr(transparent)] + struct BitIndex(Wrapping); + + const WINDOW_BITS: Wrapping = Wrapping(5); + + prefixed_extern! { + fn LIMBS_window5_split_window( + lower_limb: Limb, + higher_limb: Limb, + index_within_word: BitIndex, + ) -> Window; + fn LIMBS_window5_unsplit_window(limb: Limb, index_within_word: BitIndex) -> Window; + } + + let num_limbs = limbs.len(); + let mut window_low_bit = { + let num_whole_windows = (num_limbs * LIMB_BITS) / 5; + let mut leading_bits = (num_limbs * LIMB_BITS) - (num_whole_windows * 5); + if leading_bits == 0 { + leading_bits = WINDOW_BITS.0; + } + BitIndex(Wrapping(LIMB_BITS - leading_bits)) + }; + + let initial_value = { + let leading_partial_window = + unsafe { LIMBS_window5_split_window(*limbs.first().unwrap(), 0, window_low_bit) }; + window_low_bit.0 -= WINDOW_BITS; + init(leading_partial_window) + }; + + let mut low_limb = Limb::from(0 as LeakyWindow); + limbs.iter().fold(initial_value, |mut acc, current_limb| { + let higher_limb = low_limb; + low_limb = *current_limb; + + if window_low_bit.0 > Wrapping(LIMB_BITS) - WINDOW_BITS { + let window = + unsafe { LIMBS_window5_split_window(low_limb, higher_limb, window_low_bit) }; + window_low_bit.0 -= WINDOW_BITS; + acc = fold(acc, window); + }; + while window_low_bit.0 < Wrapping(LIMB_BITS) { + let window = unsafe { LIMBS_window5_unsplit_window(low_limb, window_low_bit) }; + // The loop exits when this subtraction underflows, causing `window_low_bit` to + // wrap around to a very large value. + window_low_bit.0 -= WINDOW_BITS; + acc = fold(acc, window); + } + window_low_bit.0 += Wrapping(LIMB_BITS); // "Fix" the underflow. + + acc + }) +} + +#[inline] +pub(crate) fn limbs_add_assign_mod( + a: &mut [Limb], + b: &[Limb], + m: &[Limb], +) -> Result<(), LenMismatchError> { + prefixed_extern! { + // `r` and `a` may alias. + fn LIMBS_add_mod( + r: *mut Limb, + a: *const Limb, + b: *const Limb, + m: *const Limb, + num_limbs: c::NonZero_size_t, + ); + } + let num_limbs = NonZeroUsize::new(m.len()).ok_or_else(|| LenMismatchError::new(m.len()))?; + (a, b).with_non_dangling_non_null_pointers_rab(num_limbs, |r, a, b| { + let m = m.as_ptr(); // Also non-dangling because `num_limbs` is non-zero. + unsafe { LIMBS_add_mod(r, a, b, m, num_limbs) } + }) +} + +// r *= 2 (mod m). +pub(crate) fn limbs_double_mod(r: &mut [Limb], m: &[Limb]) -> Result<(), LenMismatchError> { + prefixed_extern! { + // `r` and `a` may alias. + fn LIMBS_shl_mod( + r: *mut Limb, + a: *const Limb, + m: *const Limb, + num_limbs: c::NonZero_size_t); + } + let num_limbs = NonZeroUsize::new(m.len()).ok_or_else(|| LenMismatchError::new(m.len()))?; + r.with_non_dangling_non_null_pointers_ra(num_limbs, |r, a| { + let m = m.as_ptr(); // Also non-dangling because num_limbs > 0. + unsafe { + LIMBS_shl_mod(r, a, m, num_limbs); + } + }) +} + +// *r = -a, assuming a is odd. +pub(crate) fn limbs_negative_odd(r: &mut [Limb], a: &[Limb]) { + debug_assert_eq!(r.len(), a.len()); + // Two's complement step 1: flip all the bits. + // The compiler should optimize this to vectorized (a ^ !0). + r.iter_mut().zip(a.iter()).for_each(|(r, &a)| { + *r = !a; + }); + // Two's complement step 2: Add one. Since `a` is odd, `r` is even. Thus we + // can use a bitwise or for addition. + r[0] |= 1; +} + +#[cfg(any(test, feature = "alloc"))] +prefixed_extern! { + fn LIMB_shr(a: Limb, shift: c::size_t) -> Limb; +} + +#[allow(clippy::useless_conversion)] +#[cfg(test)] +mod tests { + use super::*; + use alloc::vec::Vec; + use cfg_if::cfg_if; + + const MAX: LeakyLimb = LeakyLimb::MAX; + + fn leak_in_test(a: LimbMask) -> bool { + a.leak() + } + + #[test] + fn test_limbs_are_even() { + static EVENS: &[&[LeakyLimb]] = &[ + &[], + &[0], + &[2], + &[0, 0], + &[2, 0], + &[0, 1], + &[0, 2], + &[0, 3], + &[0, 0, 0, 0, MAX], + ]; + for even in EVENS { + let even = &Vec::from_iter(even.iter().copied().map(Limb::from)); + assert!(matches!( + limbs_reject_even_leak_bit(even), + Err(error::Unspecified) + )); + } + static ODDS: &[&[LeakyLimb]] = &[ + &[1], + &[3], + &[1, 0], + &[3, 0], + &[1, 1], + &[1, 2], + &[1, 3], + &[1, 0, 0, 0, MAX], + ]; + for odd in ODDS { + let odd = &Vec::from_iter(odd.iter().copied().map(Limb::from)); + assert!(matches!(limbs_reject_even_leak_bit(odd), Ok(()))); + } + } + + static ZEROES: &[&[LeakyLimb]] = &[ + &[], + &[0], + &[0, 0], + &[0, 0, 0], + &[0, 0, 0, 0], + &[0, 0, 0, 0, 0], + &[0, 0, 0, 0, 0, 0, 0], + &[0, 0, 0, 0, 0, 0, 0, 0], + &[0, 0, 0, 0, 0, 0, 0, 0, 0], + ]; + + static NONZEROES: &[&[LeakyLimb]] = &[ + &[1], + &[0, 1], + &[1, 1], + &[1, 0, 0, 0], + &[0, 1, 0, 0], + &[0, 0, 1, 0], + &[0, 0, 0, 1], + ]; + + #[test] + fn test_limbs_are_zero() { + for zero in ZEROES { + let zero = &Vec::from_iter(zero.iter().copied().map(Limb::from)); + assert!(leak_in_test(limbs_are_zero(zero))); + } + for nonzero in NONZEROES { + let nonzero = &Vec::from_iter(nonzero.iter().copied().map(Limb::from)); + assert!(!leak_in_test(limbs_are_zero(nonzero))); + } + } + + #[test] + fn test_limbs_equal_limb() { + // Equal + static EQUAL: &[&[LeakyLimb]] = &[&[1], &[1, 0], &[1, 0, 0], &[1, 0, 0, 0, 0, 0, 0]]; + for a in EQUAL { + let a = &Vec::from_iter(a.iter().copied().map(Limb::from)); + assert!(matches!(verify_limbs_equal_1_leak_bit(a), Ok(()))); + } + + // Unequal + static UNEQUAL: &[&[LeakyLimb]] = &[ + &[0], + &[2], + &[3], + &[MAX], + &[0, 1], + &[1, 1], + &[0, 0, 0, 0, 0, 0, 0, 1], + &[0, 0, 0, 0, 1, 0, 0, 0], + &[0, 0, 0, 0, 1, 0, 0, 1], + &[MAX, 1], + ]; + for a in UNEQUAL { + let a = &Vec::from_iter(a.iter().copied().map(Limb::from)); + assert!(matches!( + verify_limbs_equal_1_leak_bit(a), + Err(error::Unspecified) + )); + } + } + + #[test] + fn test_parse_big_endian_and_pad_consttime() { + const LIMBS: usize = 4; + + { + // Empty input. + let inp = untrusted::Input::from(&[]); + let mut result = [0; LIMBS].map(From::::from); + assert!(parse_big_endian_and_pad_consttime(inp, &mut result).is_err()); + } + + // The input is longer than will fit in the given number of limbs. + { + let inp = [1, 2, 3, 4, 5, 6, 7, 8, 9]; + let inp = untrusted::Input::from(&inp); + let mut result = [0; 8 / LIMB_BYTES].map(From::::from); + assert!(parse_big_endian_and_pad_consttime(inp, &mut result[..]).is_err()); + } + + // Less than a full limb. + { + let inp = [0xfe]; + let inp = untrusted::Input::from(&inp); + let mut result = [0; LIMBS].map(From::::from); + assert_eq!( + Ok(()), + parse_big_endian_and_pad_consttime(inp, &mut result[..]) + ); + assert_eq!(&[0xfe, 0, 0, 0], &result); + } + + // A whole limb for 32-bit, half a limb for 64-bit. + { + let inp = [0xbe, 0xef, 0xf0, 0x0d]; + let inp = untrusted::Input::from(&inp); + let mut result = [0; LIMBS].map(From::::from); + assert_eq!(Ok(()), parse_big_endian_and_pad_consttime(inp, &mut result)); + assert_eq!(&[0xbeeff00d, 0, 0, 0], &result); + } + + cfg_if! { + if #[cfg(target_pointer_width = "64")] { + static TEST_CASES: &[(&[u8], &[Limb])] = &[ + (&[1], &[1, 0]), + (&[1, 2], &[0x102, 0]), + (&[1, 2, 3], &[0x10203, 0]), + (&[1, 2, 3, 4], &[0x102_0304, 0]), + (&[1, 2, 3, 4, 5], &[0x1_0203_0405, 0]), + (&[1, 2, 3, 4, 5, 6], &[0x102_0304_0506, 0]), + (&[1, 2, 3, 4, 5, 6, 7], &[0x1_0203_0405_0607, 0]), + (&[1, 2, 3, 4, 5, 6, 7, 8], &[0x102_0304_0506_0708, 0]), + (&[1, 2, 3, 4, 5, 6, 7, 8, 9], &[0x0203_0405_0607_0809, 0x1]), + (&[1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa], &[0x0304_0506_0708_090a, 0x102]), + (&[1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb], &[0x0405_0607_0809_0a0b, 0x1_0203]), + ]; + for (be_bytes, limbs) in TEST_CASES { + let mut buf = [0; 2]; + parse_big_endian_and_pad_consttime(untrusted::Input::from(be_bytes), &mut buf) + .unwrap(); + assert_eq!(limbs, &buf, "({be_bytes:x?}, {limbs:x?}"); + } + } else if #[cfg(target_pointer_width = "32")] { + static TEST_CASES: &[(&[u8], &[Limb])] = &[ + (&[1], &[1, 0, 0]), + (&[1, 2], &[0x102, 0, 0]), + (&[1, 2, 3], &[0x10203, 0, 0]), + (&[1, 2, 3, 4], &[0x102_0304, 0, 0]), + (&[1, 2, 3, 4, 5], &[0x0203_0405, 0x1, 0]), + (&[1, 2, 3, 4, 5, 6], &[0x0304_0506, 0x102, 0]), + (&[1, 2, 3, 4, 5, 6, 7], &[0x0405_0607, 0x1_0203, 0]), + (&[1, 2, 3, 4, 5, 6, 7, 8], &[0x0506_0708, 0x102_0304, 0]), + (&[1, 2, 3, 4, 5, 6, 7, 8, 9], &[0x0607_0809, 0x0203_0405, 0x1]), + (&[1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa], &[0x0708_090a, 0x0304_0506, 0x102]), + (&[1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb], &[0x0809_0a0b, 0x0405_0607, 0x1_0203]), + ]; + for (be_bytes, limbs) in TEST_CASES { + let mut buf = [0; 3]; + parse_big_endian_and_pad_consttime(untrusted::Input::from(be_bytes), &mut buf) + .unwrap(); + assert_eq!(limbs, &buf, "({be_bytes:x?}, {limbs:x?}"); + } + } else { + panic!("Unsupported target_pointer_width"); + } + + // XXX: This is a weak set of tests. TODO: expand it. + } + } + + #[test] + fn test_big_endian_from_limbs_same_length() { + #[cfg(target_pointer_width = "32")] + let limbs = [ + 0xbccddeef, 0x89900aab, 0x45566778, 0x01122334, 0xddeeff00, 0x99aabbcc, 0x55667788, + 0x11223344, + ]; + + #[cfg(target_pointer_width = "64")] + let limbs = [ + 0x8990_0aab_bccd_deef, + 0x0112_2334_4556_6778, + 0x99aa_bbcc_ddee_ff00, + 0x1122_3344_5566_7788, + ]; + + let limbs = limbs.map(From::::from); + + let expected = [ + 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, + 0xff, 0x00, 0x01, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x90, 0x0a, 0xab, + 0xbc, 0xcd, 0xde, 0xef, + ]; + + let mut out = [0xabu8; 32]; + big_endian_from_limbs(&limbs[..], &mut out); + assert_eq!(&out[..], &expected[..]); + } + + #[should_panic] + #[test] + fn test_big_endian_from_limbs_fewer_limbs() { + #[cfg(target_pointer_width = "32")] + // Two fewer limbs. + let limbs = [ + 0xbccddeef, 0x89900aab, 0x45566778, 0x01122334, 0xddeeff00, 0x99aabbcc, + ]; + + // One fewer limb. + #[cfg(target_pointer_width = "64")] + let limbs = [ + 0x8990_0aab_bccd_deef, + 0x0112_2334_4556_6778, + 0x99aa_bbcc_ddee_ff00, + ]; + + let limbs = limbs.map(From::::from); + + let mut out = [0xabu8; 32]; + + big_endian_from_limbs(&limbs[..], &mut out); + } + + #[test] + fn test_limbs_minimal_bits() { + const ALL_ONES: LeakyLimb = LeakyLimb::MAX; + static CASES: &[(&[LeakyLimb], usize)] = &[ + (&[], 0), + (&[0], 0), + (&[ALL_ONES], LIMB_BITS), + (&[ALL_ONES, 0], LIMB_BITS), + (&[ALL_ONES, 1], LIMB_BITS + 1), + (&[0, 0], 0), + (&[1, 0], 1), + (&[0, 1], LIMB_BITS + 1), + (&[0, ALL_ONES], 2 * LIMB_BITS), + (&[ALL_ONES, ALL_ONES], 2 * LIMB_BITS), + (&[ALL_ONES, ALL_ONES >> 1], 2 * LIMB_BITS - 1), + (&[ALL_ONES, 0b100_0000], LIMB_BITS + 7), + (&[ALL_ONES, 0b101_0000], LIMB_BITS + 7), + (&[ALL_ONES, ALL_ONES >> 1], LIMB_BITS + (LIMB_BITS) - 1), + ]; + for (limbs, bits) in CASES { + let limbs = &Vec::from_iter(limbs.iter().copied().map(Limb::from)); + assert_eq!(limbs_minimal_bits(limbs).as_bits(), *bits); + } + } +} diff --git a/http/vendor/ring/src/pbkdf2.rs b/http/vendor/ring/src/pbkdf2.rs new file mode 100644 index 0000000..7baacdb --- /dev/null +++ b/http/vendor/ring/src/pbkdf2.rs @@ -0,0 +1,344 @@ +// Copyright 2015 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! PBKDF2 derivation and verification. +//! +//! Use `derive` to derive PBKDF2 outputs. Use `verify` to verify secret +//! against previously-derived outputs. +//! +//! PBKDF2 is specified in [RFC 2898 Section 5.2] with test vectors given in +//! [RFC 6070]. See also [NIST Special Publication 800-132]. +//! +//! [RFC 2898 Section 5.2]: https://tools.ietf.org/html/rfc2898#section-5.2 +//! [RFC 6070]: https://tools.ietf.org/html/rfc6070 +//! [NIST Special Publication 800-132]: +//! http://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf +//! +//! # Examples +//! +//! ## Password Database Example +//! +//! ``` +//! use ring::{digest, pbkdf2}; +//! use std::{collections::HashMap, num::NonZeroU32}; +//! +//! static PBKDF2_ALG: pbkdf2::Algorithm = pbkdf2::PBKDF2_HMAC_SHA256; +//! const CREDENTIAL_LEN: usize = digest::SHA256_OUTPUT_LEN; +//! pub type Credential = [u8; CREDENTIAL_LEN]; +//! +//! enum Error { +//! WrongUsernameOrPassword +//! } +//! +//! struct PasswordDatabase { +//! pbkdf2_iterations: NonZeroU32, +//! db_salt_component: [u8; 16], +//! +//! // Normally this would be a persistent database. +//! storage: HashMap, +//! } +//! +//! impl PasswordDatabase { +//! pub fn store_password(&mut self, username: &str, password: &str) { +//! let salt = self.salt(username); +//! let mut to_store: Credential = [0u8; CREDENTIAL_LEN]; +//! pbkdf2::derive(PBKDF2_ALG, self.pbkdf2_iterations, &salt, +//! password.as_bytes(), &mut to_store); +//! self.storage.insert(String::from(username), to_store); +//! } +//! +//! pub fn verify_password(&self, username: &str, attempted_password: &str) +//! -> Result<(), Error> { +//! match self.storage.get(username) { +//! Some(actual_password) => { +//! let salt = self.salt(username); +//! pbkdf2::verify(PBKDF2_ALG, self.pbkdf2_iterations, &salt, +//! attempted_password.as_bytes(), +//! actual_password) +//! .map_err(|_| Error::WrongUsernameOrPassword) +//! }, +//! +//! None => Err(Error::WrongUsernameOrPassword) +//! } +//! } +//! +//! // The salt should have a user-specific component so that an attacker +//! // cannot crack one password for multiple users in the database. It +//! // should have a database-unique component so that an attacker cannot +//! // crack the same user's password across databases in the unfortunate +//! // but common case that the user has used the same password for +//! // multiple systems. +//! fn salt(&self, username: &str) -> Vec { +//! let mut salt = Vec::with_capacity(self.db_salt_component.len() + +//! username.as_bytes().len()); +//! salt.extend(self.db_salt_component.as_ref()); +//! salt.extend(username.as_bytes()); +//! salt +//! } +//! } +//! +//! fn main() { +//! // Normally these parameters would be loaded from a configuration file. +//! let mut db = PasswordDatabase { +//! pbkdf2_iterations: NonZeroU32::new(100_000).unwrap(), +//! db_salt_component: [ +//! // This value was generated from a secure PRNG. +//! 0xd6, 0x26, 0x98, 0xda, 0xf4, 0xdc, 0x50, 0x52, +//! 0x24, 0xf2, 0x27, 0xd1, 0xfe, 0x39, 0x01, 0x8a +//! ], +//! storage: HashMap::new(), +//! }; +//! +//! db.store_password("alice", "@74d7]404j|W}6u"); +//! +//! // An attempt to log in with the wrong password fails. +//! assert!(db.verify_password("alice", "wrong password").is_err()); +//! +//! // Normally there should be an expoentially-increasing delay between +//! // attempts to further protect against online attacks. +//! +//! // An attempt to log in with the right password succeeds. +//! assert!(db.verify_password("alice", "@74d7]404j|W}6u").is_ok()); +//! } + +use self::{derive_error::DeriveError, verify_error::VerifyError}; +use crate::{ + bb, cpu, digest, + error::{self, TooMuchOutputRequestedError}, + hmac::{self, InputTooLongError}, +}; +use core::num::NonZeroU32; + +/// A PBKDF2 algorithm. +#[derive(Clone, Copy, PartialEq, Eq)] +pub struct Algorithm(hmac::Algorithm); + +/// PBKDF2 using HMAC-SHA1. +pub static PBKDF2_HMAC_SHA1: Algorithm = Algorithm(hmac::HMAC_SHA1_FOR_LEGACY_USE_ONLY); + +/// PBKDF2 using HMAC-SHA256. +pub static PBKDF2_HMAC_SHA256: Algorithm = Algorithm(hmac::HMAC_SHA256); + +/// PBKDF2 using HMAC-SHA384. +pub static PBKDF2_HMAC_SHA384: Algorithm = Algorithm(hmac::HMAC_SHA384); + +/// PBKDF2 using HMAC-SHA512. +pub static PBKDF2_HMAC_SHA512: Algorithm = Algorithm(hmac::HMAC_SHA512); + +/// Fills `out` with the key derived using PBKDF2 with the given inputs. +/// +/// Do not use `derive` as part of verifying a secret; use `verify` instead, to +/// minimize the effectiveness of timing attacks. +/// +/// `out.len()` must be no larger than the digest length * (2**32 - 1), per the +/// PBKDF2 specification. +/// +/// | Parameter | RFC 2898 Section 5.2 Term +/// |-------------|------------------------------------------- +/// | digest_alg | PRF (HMAC with the given digest algorithm) +/// | iterations | c (iteration count) +/// | salt | S (salt) +/// | secret | P (password) +/// | out | dk (derived key) +/// | out.len() | dkLen (derived key length) +/// +/// # Panics +/// +/// Panics if `out.len() > u32::MAX * digest_alg.output_len()`, where +/// `digest_alg` is the underlying HMAC/digest algorithm. +/// +/// Panics if `salt` is so astronomically gigantic that it isn't a valid input +/// to the underlying digest function. +/// +/// Panics if `secret` is so astronomically gigantic that it isn't a valid +/// input to the underlying digest function. +pub fn derive( + algorithm: Algorithm, + iterations: NonZeroU32, + salt: &[u8], + secret: &[u8], + out: &mut [u8], +) { + let cpu = cpu::features(); + try_derive(algorithm, iterations, salt, secret, out, cpu) + .map_err(error::erase::) + .unwrap() +} + +fn try_derive( + algorithm: Algorithm, + iterations: NonZeroU32, + salt: &[u8], + secret: &[u8], + out: &mut [u8], + cpu: cpu::Features, +) -> Result<(), DeriveError> { + let digest_alg = algorithm.0.digest_algorithm(); + let output_len = digest_alg.output_len(); + + // This implementation's performance is asymptotically optimal as described + // in https://jbp.io/2015/08/11/pbkdf2-performance-matters/. However, it + // hasn't been optimized to the same extent as fastpbkdf2. In particular, + // this implementation is probably doing a lot of unnecessary copying. + + let secret = + hmac::Key::try_new(algorithm.0, secret, cpu).map_err(DeriveError::secret_too_long)?; + + // Clear |out|. + out.fill(0); + + let mut idx: u32 = 0; + + let out_len = out.len(); + for chunk in out.chunks_mut(output_len) { + idx = idx.checked_add(1).ok_or_else(|| { + DeriveError::too_much_output_requested(TooMuchOutputRequestedError::new(out_len)) + })?; + // If the salt is too long, then we'll detect this on the first + // iteration before we've written any output. + derive_block(&secret, iterations, salt, idx, chunk, cpu) + .map_err(DeriveError::salt_too_long)?; + } + Ok(()) +} + +fn derive_block( + secret: &hmac::Key, + iterations: NonZeroU32, + salt: &[u8], + idx: u32, + out: &mut [u8], + cpu: cpu::Features, +) -> Result<(), InputTooLongError> { + let mut ctx = hmac::Context::with_key(secret); + ctx.update(salt); + ctx.update(&u32::to_be_bytes(idx)); + + let mut u = ctx.try_sign(cpu)?; + + let mut remaining: u32 = iterations.into(); + loop { + bb::xor_assign_at_start(&mut out[..], u.as_ref()); + + if remaining == 1 { + break; + } + remaining -= 1; + + // This will not fail, because the output of HMAC is never too long to + // be an input for the same algorithm, but we can't prove that with + // only locally-available information. + u = secret.sign(u.as_ref(), cpu)? + } + Ok(()) +} + +cold_exhaustive_error! { + enum derive_error::DeriveError { + secret_too_long => SecretTooLong(InputTooLongError), + salt_too_long => SaltTooLong(InputTooLongError), + too_much_output_requested => TooMuchOutputRequested(TooMuchOutputRequestedError), + } +} + +cold_exhaustive_error! { + enum verify_error::VerifyError { + mismatch => Mismatch(()), + secret_too_long => SecretTooLong(InputTooLongError), + salt_too_long => SaltTooLong(InputTooLongError), + previously_derived_empty => PreviouslyDerivedEmpty(usize), + } +} + +/// Verifies that a previously-derived (e.g., using `derive`) PBKDF2 value +/// matches the PBKDF2 value derived from the other inputs. +/// +/// The comparison is done in constant time to prevent timing attacks. The +/// comparison will fail if `previously_derived` is empty (has a length of +/// zero). +/// +/// | Parameter | RFC 2898 Section 5.2 Term +/// |----------------------------|-------------------------------------------- +/// | digest_alg | PRF (HMAC with the given digest algorithm). +/// | `iterations` | c (iteration count) +/// | `salt` | S (salt) +/// | `secret` | P (password) +/// | `previously_derived` | dk (derived key) +/// | `previously_derived.len()` | dkLen (derived key length) +pub fn verify( + algorithm: Algorithm, + iterations: NonZeroU32, + salt: &[u8], + secret: &[u8], + previously_derived: &[u8], +) -> Result<(), error::Unspecified> { + let cpu = cpu::features(); + try_verify(algorithm, iterations, salt, secret, previously_derived, cpu) + .map_err(error::erase::) +} + +fn try_verify( + algorithm: Algorithm, + iterations: NonZeroU32, + salt: &[u8], + secret: &[u8], + previously_derived: &[u8], + cpu: cpu::Features, +) -> Result<(), VerifyError> { + let digest_alg = algorithm.0.digest_algorithm(); + + if previously_derived.is_empty() { + return Err(VerifyError::previously_derived_empty(0)); + } + + let mut derived_buf = [0u8; digest::MAX_OUTPUT_LEN]; + + let output_len = digest_alg.output_len(); + let secret = + hmac::Key::try_new(algorithm.0, secret, cpu).map_err(VerifyError::secret_too_long)?; + let mut idx: u32 = 0; + + let mut matches = 1; + + for previously_derived_chunk in previously_derived.chunks(output_len) { + idx = idx.checked_add(1).ok_or_else(|| { + // `previously_derived` is so gigantic that PBKDF2 couldn't + // have been used to compute it. + VerifyError::mismatch(()) + })?; + + let derived_chunk = &mut derived_buf[..previously_derived_chunk.len()]; + derived_chunk.fill(0); + + derive_block(&secret, iterations, salt, idx, derived_chunk, cpu) + .map_err(VerifyError::salt_too_long)?; + + // XXX: This isn't fully constant-time-safe. TODO: Fix that. + #[allow(clippy::bool_to_int_with_if)] + let current_block_matches = + if bb::verify_slices_are_equal(derived_chunk, previously_derived_chunk).is_ok() { + 1 + } else { + 0 + }; + + matches &= current_block_matches; + } + + if matches == 0 { + return Err(VerifyError::mismatch(())); + } + + Ok(()) +} diff --git a/http/vendor/ring/src/pkcs8.rs b/http/vendor/ring/src/pkcs8.rs new file mode 100644 index 0000000..5ef66fd --- /dev/null +++ b/http/vendor/ring/src/pkcs8.rs @@ -0,0 +1,216 @@ +// Copyright 2017 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! PKCS#8 is specified in [RFC 5958]. +//! +//! [RFC 5958]: https://tools.ietf.org/html/rfc5958 + +use crate::{ec, error, io::der}; + +pub(crate) struct PublicKeyOptions { + /// Should the wrong public key ASN.1 tagging used by early implementations + /// of PKCS#8 v2 (including earlier versions of *ring*) be accepted? + pub accept_legacy_ed25519_public_key_tag: bool, +} + +pub(crate) enum Version { + V1Only, + V1OrV2(PublicKeyOptions), + V2Only(PublicKeyOptions), +} + +/// A template for constructing PKCS#8 documents. +/// +/// Note that this only works for ECC. +pub(crate) struct Template { + pub bytes: &'static [u8], + + // The range within `bytes` that holds the value (not including the tag and + // length) for use in the PKCS#8 document's privateKeyAlgorithm field. + pub alg_id_range: core::ops::Range, + + // `bytes[alg_id_range][curve_id_index..]` contains the OID identifying the, + // curve, including the tag and length. + pub curve_id_index: usize, + + // `bytes` will be split into two parts at `private_key_index`, where the + // first part is written before the private key and the second part is + // written after the private key. The public key is written after the second + // part. + pub private_key_index: usize, +} + +impl Template { + #[inline] + fn alg_id_value(&self) -> untrusted::Input { + untrusted::Input::from(self.alg_id_value_()) + } + + fn alg_id_value_(&self) -> &[u8] { + &self.bytes[self.alg_id_range.start..self.alg_id_range.end] + } + + #[inline] + pub fn curve_oid(&self) -> untrusted::Input { + untrusted::Input::from(&self.alg_id_value_()[self.curve_id_index..]) + } +} + +/// Parses an unencrypted PKCS#8 private key, verifies that it is the right type +/// of key, and returns the key value. +/// +/// PKCS#8 is specified in [RFC 5958]. +/// +/// [RFC 5958]: https://tools.ietf.org/html/rfc5958 +pub(crate) fn unwrap_key<'a>( + template: &Template, + version: Version, + input: untrusted::Input<'a>, +) -> Result<(untrusted::Input<'a>, Option>), error::KeyRejected> { + unwrap_key_(template.alg_id_value(), version, input) +} + +/// Parses an unencrypted PKCS#8 private key, verifies that it is the right type +/// of key, and returns the key value. +/// +/// `alg_id` must be the encoded value (not including the outermost `SEQUENCE` +/// tag and length) of the `AlgorithmIdentifier` that identifies the key type. +/// The result will be an encoded `RSAPrivateKey` or `ECPrivateKey` or similar. +/// +/// PKCS#8 is specified in [RFC 5958]. +/// +/// [RFC 5958]: https://tools.ietf.org/html/rfc5958 +pub(crate) fn unwrap_key_<'a>( + alg_id: untrusted::Input, + version: Version, + input: untrusted::Input<'a>, +) -> Result<(untrusted::Input<'a>, Option>), error::KeyRejected> { + input.read_all(error::KeyRejected::invalid_encoding(), |input| { + der::nested( + input, + der::Tag::Sequence, + error::KeyRejected::invalid_encoding(), + |input| unwrap_key__(alg_id, version, input), + ) + }) +} + +fn unwrap_key__<'a>( + alg_id: untrusted::Input, + version: Version, + input: &mut untrusted::Reader<'a>, +) -> Result<(untrusted::Input<'a>, Option>), error::KeyRejected> { + let actual_version = der::small_nonnegative_integer(input) + .map_err(|error::Unspecified| error::KeyRejected::invalid_encoding())?; + + // Do things in a specific order to return more useful errors: + // 1. Check for completely unsupported version. + // 2. Check for algorithm mismatch. + // 3. Check for algorithm-specific version mismatch. + + if actual_version > 1 { + return Err(error::KeyRejected::version_not_supported()); + }; + + let actual_alg_id = der::expect_tag_and_get_value(input, der::Tag::Sequence) + .map_err(|error::Unspecified| error::KeyRejected::invalid_encoding())?; + if actual_alg_id.as_slice_less_safe() != alg_id.as_slice_less_safe() { + return Err(error::KeyRejected::wrong_algorithm()); + } + + let public_key_options = match (actual_version, version) { + (0, Version::V1Only) => None, + (0, Version::V1OrV2(_)) => None, + (1, Version::V1OrV2(options)) | (1, Version::V2Only(options)) => Some(options), + _ => { + return Err(error::KeyRejected::version_not_supported()); + } + }; + + let private_key = der::expect_tag_and_get_value(input, der::Tag::OctetString) + .map_err(|error::Unspecified| error::KeyRejected::invalid_encoding())?; + + // Ignore any attributes that are present. + if input.peek(der::Tag::ContextSpecificConstructed0.into()) { + let _ = der::expect_tag_and_get_value(input, der::Tag::ContextSpecificConstructed0) + .map_err(|error::Unspecified| error::KeyRejected::invalid_encoding())?; + } + + let public_key = if let Some(options) = public_key_options { + if input.at_end() { + return Err(error::KeyRejected::public_key_is_missing()); + } + + const INCORRECT_LEGACY: der::Tag = der::Tag::ContextSpecificConstructed1; + let result = if options.accept_legacy_ed25519_public_key_tag + && input.peek(INCORRECT_LEGACY.into()) + { + der::nested( + input, + INCORRECT_LEGACY, + error::Unspecified, + der::bit_string_with_no_unused_bits, + ) + } else { + der::bit_string_tagged_with_no_unused_bits(der::Tag::ContextSpecific1, input) + }; + let public_key = + result.map_err(|error::Unspecified| error::KeyRejected::invalid_encoding())?; + Some(public_key) + } else { + None + }; + + Ok((private_key, public_key)) +} + +/// A generated PKCS#8 document. +pub struct Document { + bytes: [u8; ec::PKCS8_DOCUMENT_MAX_LEN], + len: usize, +} + +impl AsRef<[u8]> for Document { + #[inline] + fn as_ref(&self) -> &[u8] { + &self.bytes[..self.len] + } +} + +pub(crate) fn wrap_key(template: &Template, private_key: &[u8], public_key: &[u8]) -> Document { + let mut result = Document { + bytes: [0; ec::PKCS8_DOCUMENT_MAX_LEN], + len: template.bytes.len() + private_key.len() + public_key.len(), + }; + wrap_key_( + template, + private_key, + public_key, + &mut result.bytes[..result.len], + ); + result +} + +/// Formats a private key "prefix||private_key||middle||public_key" where +/// `template` is "prefix||middle" split at position `private_key_index`. +fn wrap_key_(template: &Template, private_key: &[u8], public_key: &[u8], bytes: &mut [u8]) { + let (before_private_key, after_private_key) = + template.bytes.split_at(template.private_key_index); + let private_key_end_index = template.private_key_index + private_key.len(); + bytes[..template.private_key_index].copy_from_slice(before_private_key); + bytes[template.private_key_index..private_key_end_index].copy_from_slice(private_key); + bytes[private_key_end_index..(private_key_end_index + after_private_key.len())] + .copy_from_slice(after_private_key); + bytes[(private_key_end_index + after_private_key.len())..].copy_from_slice(public_key); +} diff --git a/http/vendor/ring/src/polyfill.rs b/http/vendor/ring/src/polyfill.rs new file mode 100644 index 0000000..cf51320 --- /dev/null +++ b/http/vendor/ring/src/polyfill.rs @@ -0,0 +1,107 @@ +// Copyright 2015-2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! Polyfills for functionality that will (hopefully) be added to Rust's +//! standard library soon. + +#[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))] +#[inline(always)] +pub const fn u64_from_usize(x: usize) -> u64 { + x as u64 +} + +#[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))] +pub const fn usize_from_u32(x: u32) -> usize { + x as usize +} + +#[cfg(all( + target_arch = "aarch64", + target_endian = "little", + target_pointer_width = "64" +))] +#[allow(clippy::cast_possible_truncation)] +pub fn usize_from_u64(x: u64) -> usize { + x as usize +} + +/// const-capable `x.try_into().unwrap_or(usize::MAX)` +#[allow(clippy::cast_possible_truncation)] +#[inline(always)] +pub const fn usize_from_u64_saturated(x: u64) -> usize { + const USIZE_MAX: u64 = u64_from_usize(usize::MAX); + if x < USIZE_MAX { + x as usize + } else { + usize::MAX + } +} + +#[macro_use] +mod cold_error; + +mod array_flat_map; +mod array_split_map; + +pub mod cstr; + +pub mod sliceutil; + +#[cfg(feature = "alloc")] +mod leading_zeros_skipped; + +#[cfg(any( + all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little"), + target_arch = "x86", + target_arch = "x86_64" +))] +pub mod once_cell { + pub mod race; +} + +mod notsend; +pub mod ptr; + +pub mod slice; + +#[cfg(test)] +mod test; + +mod unwrap_const; + +pub use self::{ + array_flat_map::ArrayFlatMap, array_split_map::ArraySplitMap, notsend::NotSend, + unwrap_const::unwrap_const, +}; + +#[cfg(feature = "alloc")] +pub use leading_zeros_skipped::LeadingZerosStripped; + +#[cfg(test)] +mod tests { + use super::*; + #[test] + fn test_usize_from_u64_saturated() { + const USIZE_MAX: u64 = u64_from_usize(usize::MAX); + assert_eq!(usize_from_u64_saturated(u64::MIN), usize::MIN); + assert_eq!(usize_from_u64_saturated(USIZE_MAX), usize::MAX); + assert_eq!(usize_from_u64_saturated(USIZE_MAX - 1), usize::MAX - 1); + + #[cfg(not(target_pointer_width = "64"))] + { + assert_eq!(usize_from_u64_saturated(USIZE_MAX + 1), usize::MAX); + } + } +} diff --git a/http/vendor/ring/src/polyfill/array_flat_map.rs b/http/vendor/ring/src/polyfill/array_flat_map.rs new file mode 100644 index 0000000..8b3abbe --- /dev/null +++ b/http/vendor/ring/src/polyfill/array_flat_map.rs @@ -0,0 +1,127 @@ +use core::iter::FlatMap; + +/// A specialized version of `core::iter::FlatMap` for mapping over exact-sized +/// iterators with a function that returns an array. +/// +/// `ArrayFlatMap` differs from `FlatMap` in that `ArrayFlatMap` implements +/// `ExactSizeIterator`. Since the result of `F` always has `LEN` elements, if +/// `I` is an exact-sized iterator of length `inner_len` then we know the +/// length of the flat-mapped result is `inner_len * LEN`. (The constructor +/// verifies that this multiplication doesn't overflow `usize`.) +#[derive(Clone)] +pub struct ArrayFlatMap { + inner: FlatMap, + remaining: usize, +} + +impl ArrayFlatMap +where + I: ExactSizeIterator, + F: FnMut(I::Item) -> [Item; LEN], +{ + /// Constructs an `ArrayFlatMap` wrapping the given iterator, using the + /// given function + pub fn new(inner: I, f: F) -> Option { + let remaining = inner.len().checked_mul(LEN)?; + let inner = inner.flat_map(f); + Some(Self { inner, remaining }) + } +} + +impl Iterator for ArrayFlatMap +where + I: Iterator, + F: FnMut(I::Item) -> [Item; LEN], +{ + type Item = Item; + + fn next(&mut self) -> Option { + let result = self.inner.next(); + if result.is_some() { + self.remaining -= 1; + } + result + } + + /// Required for implementing `ExactSizeIterator`. + fn size_hint(&self) -> (usize, Option) { + (self.remaining, Some(self.remaining)) + } +} + +impl ExactSizeIterator for ArrayFlatMap +where + I: Iterator, + F: FnMut(I::Item) -> [Item; LEN], +{ +} + +#[cfg(test)] +mod tests { + use super::*; + use core::mem::size_of; + + #[test] + fn test_array_flat_map() { + static TEST_CASES: &[(&[u16], fn(u16) -> [u8; 2], &[u8])] = &[ + // Empty input + (&[], u16::to_be_bytes, &[]), + // Non-empty input. + ( + &[0x0102, 0x0304, 0x0506], + u16::to_be_bytes, + &[1, 2, 3, 4, 5, 6], + ), + // Test with a different mapping function. + ( + &[0x0102, 0x0304, 0x0506], + u16::to_le_bytes, + &[2, 1, 4, 3, 6, 5], + ), + ]; + TEST_CASES.iter().copied().for_each(|(input, f, expected)| { + let mapped = ArrayFlatMap::new(input.iter().copied(), f).unwrap(); + super::super::test::assert_iterator(mapped, expected); + }); + } + + // Does ArrayFlatMap::new() handle overflow correctly? + #[test] + fn test_array_flat_map_len_overflow() { + struct DownwardCounter { + remaining: usize, + } + impl Iterator for DownwardCounter { + type Item = usize; + + fn next(&mut self) -> Option { + if self.remaining > 0 { + let result = self.remaining; + self.remaining -= 1; + Some(result) + } else { + None + } + } + + fn size_hint(&self) -> (usize, Option) { + (self.remaining, Some(self.remaining)) + } + } + impl ExactSizeIterator for DownwardCounter {} + + const MAX: usize = usize::MAX / size_of::(); + + static TEST_CASES: &[(usize, bool)] = &[(MAX, true), (MAX + 1, false)]; + TEST_CASES.iter().copied().for_each(|(input_len, is_some)| { + let inner = DownwardCounter { + remaining: input_len, + }; + let mapped = ArrayFlatMap::new(inner, usize::to_be_bytes); + assert_eq!(mapped.is_some(), is_some); + if let Some(mapped) = mapped { + assert_eq!(mapped.len(), input_len * size_of::()); + } + }); + } +} diff --git a/http/vendor/ring/src/polyfill/array_split_map.rs b/http/vendor/ring/src/polyfill/array_split_map.rs new file mode 100644 index 0000000..c754330 --- /dev/null +++ b/http/vendor/ring/src/polyfill/array_split_map.rs @@ -0,0 +1,71 @@ +// Copyright 2023 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +pub trait ArraySplitMap { + fn array_split_map(self, f: impl Fn([I; CN]) -> O) -> [O; ON]; +} + +impl ArraySplitMap for [I; 12] { + #[inline] + fn array_split_map(self, f: impl Fn([I; 4]) -> O) -> [O; 3] { + let [a0, a1, a2, a3, b0, b1, b2, b3, c0, c1, c2, c3] = self; + [ + f([a0, a1, a2, a3]), + f([b0, b1, b2, b3]), + f([c0, c1, c2, c3]), + ] + } +} + +impl ArraySplitMap for [I; 16] { + #[inline] + fn array_split_map(self, f: impl Fn([I; 4]) -> O) -> [O; 4] { + let [a0, a1, a2, a3, b0, b1, b2, b3, c0, c1, c2, c3, d0, d1, d2, d3] = self; + [ + f([a0, a1, a2, a3]), + f([b0, b1, b2, b3]), + f([c0, c1, c2, c3]), + f([d0, d1, d2, d3]), + ] + } +} + +impl ArraySplitMap for [I; 32] { + #[inline] + fn array_split_map(self, f: impl Fn([I; 4]) -> O) -> [O; 8] { + let [a0, a1, a2, a3, b0, b1, b2, b3, c0, c1, c2, c3, d0, d1, d2, d3, e0, e1, e2, e3, f0, f1, f2, f3, g0, g1, g2, g3, h0, h1, h2, h3] = + self; + [ + f([a0, a1, a2, a3]), + f([b0, b1, b2, b3]), + f([c0, c1, c2, c3]), + f([d0, d1, d2, d3]), + f([e0, e1, e2, e3]), + f([f0, f1, f2, f3]), + f([g0, g1, g2, g3]), + f([h0, h1, h2, h3]), + ] + } +} + +impl ArraySplitMap for [I; 16] { + #[inline] + fn array_split_map(self, f: impl Fn([I; 8]) -> O) -> [O; 2] { + let [a0, a1, a2, a3, a4, a5, a6, a7, b0, b1, b2, b3, b4, b5, b6, b7] = self; + [ + f([a0, a1, a2, a3, a4, a5, a6, a7]), + f([b0, b1, b2, b3, b4, b5, b6, b7]), + ] + } +} diff --git a/http/vendor/ring/src/polyfill/cold_error.rs b/http/vendor/ring/src/polyfill/cold_error.rs new file mode 100644 index 0000000..13fc9f6 --- /dev/null +++ b/http/vendor/ring/src/polyfill/cold_error.rs @@ -0,0 +1,101 @@ +// Copyright 2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +/// Reduces boilerplate for defining error types where we want the compiler to +/// optimize for the non-error path by assuming constructing an error is +/// unlikely/cold code. +/// +/// WARNING: Every struct/variant must contain some *non-constant* value so +/// that the "invariant code" pass of the compiler doesn't recognize the +/// constructor as being "invariant code" and optimizing it away; +/// although such optimization would be nice to take advantage of, it +/// seems to lose the `#[cold]` attribute. +/// +/// Constructor functions ar marked `pub(super)` to ensure that instances can +/// only be constructed from within the enclosing module (and its submodules). +/// +/// XXX: #[inline(never)] is required to avoid the (MIR?) optimizer inlining +/// away the function call and losing the `#[cold]` attribute in the process. +/// We'd otherwise maybe prefer all constructors to be inline. +/// +/// The type is defined in its own submodule `#mod_name` to hide the +/// variant/struct constructor, ensuring instances are only constructed +/// through the generated `$constructor` functions. The constructor methods +/// work around the lack of the ability to mark an enum variant `#[cold]` and +/// `#[inline(never)]`. +macro_rules! cold_exhaustive_error { + // struct + { + struct $mod_name:ident::$Error:ident with $vis:vis constructor { + $field:ident: $ValueType:ty + } + } => { + mod $mod_name { + #[allow(unused_imports)] + use super::*; // So `$ValueType` is in scope. + + pub struct $Error { #[allow(dead_code)] $field: $ValueType } + + impl $Error { + #[cold] + #[inline(never)] + $vis fn new($field: $ValueType) -> Self { + Self { $field } + } + } + } + }; + // struct with default constructor visibility. + { + struct $mod_name:ident::$Error:ident { + $field:ident: $ValueType:ty + } + } => { + cold_exhaustive_error! { + struct $mod_name::$Error with pub(super) constructor { + $field: $ValueType + } + } + }; + + // enum + { + enum $mod_name:ident::$Error:ident { + $( + $constructor:ident => $Variant:ident($ValueType:ty), + )+ + } + } => { + mod $mod_name { + #[allow(unused_imports)] + use super::*; // So `$ValueType` is in scope. + + pub enum $Error { + $( + $Variant(#[allow(dead_code)] $ValueType) + ),+ + } + + impl $Error { + $( + #[cold] + #[inline(never)] + pub(super) fn $constructor(value: $ValueType) -> Self { + Self::$Variant(value) + } + )+ + } + } + }; +} diff --git a/http/vendor/ring/src/polyfill/cstr.rs b/http/vendor/ring/src/polyfill/cstr.rs new file mode 100644 index 0000000..10739f9 --- /dev/null +++ b/http/vendor/ring/src/polyfill/cstr.rs @@ -0,0 +1,107 @@ +// Copyright 2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +#![cfg(all( + target_vendor = "apple", + any( + target_os = "ios", + target_os = "macos", + target_os = "tvos", + target_os = "visionos", + target_os = "watchos" + ) +))] + +//! Work around lack of `core::ffi::CStr` prior to Rust 1.64, and the lack of +//! `const fn` support for `CStr` in later versions. + +#![cfg(all( + all(target_arch = "aarch64", target_endian = "little"), + target_vendor = "apple" +))] + +use core::mem::{align_of, size_of}; + +// TODO(MSRV 1.64): Use `core::ffi::c_char`. +use libc::c_char; + +// TODO(MSRV 1.64): Replace with `&core::ffi::CStr`. +pub struct Ref(&'static [u8]); + +impl Ref { + #[inline(always)] + pub fn as_ptr(&self) -> *const c_char { + const _SAME_ALIGNMENT: () = assert!(align_of::() == align_of::()); + const _SAME_SIZE: () = assert!(size_of::() == size_of::()); + + // It is safe to cast a `*const u8` to a `const c_char` as they are the + // same size and alignment. + self.0.as_ptr().cast() + } + + // SAFETY: Same as `CStr::from_bytes_with_nul_unchecked`. + const unsafe fn from_bytes_with_nul_unchecked(value: &'static [u8]) -> Self { + Self(value) + } +} + +pub const fn unwrap_const_from_bytes_with_nul(value: &'static [u8]) -> Ref { + // XXX: We cannot use `unwrap_const` since `Ref`/`CStr` is not `Copy`. + match const_from_bytes_with_nul(value) { + Some(r) => r, + None => panic!("const_from_bytes_with_nul failed"), + } +} + +// TODO(MSRV 1.72): Replace with `CStr::from_bytes_with_nul`. +#[inline(always)] +const fn const_from_bytes_with_nul(value: &'static [u8]) -> Option { + const fn const_contains(mut value: &[u8], needle: &u8) -> bool { + while let [head, tail @ ..] = value { + if *head == *needle { + return true; + } + value = tail; + } + false + } + + // TODO(MSRV 1.69): Use `core::ffi::CStr::from_bytes_until_nul` + match value { + [before_nul @ .., 0] if !const_contains(before_nul, &0) => { + // SAFETY: + // * `value` is nul-terminated according to the slice pattern. + // * `value` doesn't contain any interior null, by the guard. + // TODO(MSRV 1.64): Use `CStr::from_bytes_with_nul_unchecked` + Some(unsafe { Ref::from_bytes_with_nul_unchecked(value) }) + } + _ => None, + } +} + +mod tests { + use super::const_from_bytes_with_nul; + + // Bad. + const _EMPTY_UNTERMINATED: () = assert!(const_from_bytes_with_nul(b"").is_none()); + const _EMPTY_DOUBLE_TERMINATED: () = assert!(const_from_bytes_with_nul(b"\0\0").is_none()); + const _DOUBLE_NUL: () = assert!(const_from_bytes_with_nul(b"\0\0").is_none()); + const _LEADINGL_NUL: () = assert!(const_from_bytes_with_nul(b"\0a\0").is_none()); + const _INTERNAL_NUL_UNTERMINATED: () = assert!(const_from_bytes_with_nul(b"\0a").is_none()); + + // Good. + const _EMPTY_TERMINATED: () = assert!(const_from_bytes_with_nul(b"\0").is_some()); + const _NONEMPTY: () = assert!(const_from_bytes_with_nul(b"asdf\0").is_some()); + const _1_CHAR: () = assert!(const_from_bytes_with_nul(b"a\0").is_some()); +} diff --git a/http/vendor/ring/src/polyfill/leading_zeros_skipped.rs b/http/vendor/ring/src/polyfill/leading_zeros_skipped.rs new file mode 100644 index 0000000..36053f3 --- /dev/null +++ b/http/vendor/ring/src/polyfill/leading_zeros_skipped.rs @@ -0,0 +1,78 @@ +use core::iter::Peekable; + +/// An iterator that skips all leading zeros. +/// +/// When the wrapped iterator is all zeros, then the last item is retained. +pub struct LeadingZerosStripped +where + I: Iterator, +{ + inner: Peekable, +} + +impl Clone for LeadingZerosStripped +where + I: Iterator, + Peekable: Clone, +{ + fn clone(&self) -> Self { + Self { + inner: self.inner.clone(), + } + } +} + +impl LeadingZerosStripped +where + I: ExactSizeIterator, +{ + pub fn new(inner: I) -> Self { + let mut len = inner.len(); + let mut inner = inner.peekable(); + // Strip all leading zeroes, but don't strip the last byte if all bytes + // were zero. + while len > 1 && inner.next_if_eq(&0).is_some() { + len -= 1; + } + Self { inner } + } +} + +impl Iterator for LeadingZerosStripped +where + I: Iterator, +{ + type Item = I::Item; + + fn next(&mut self) -> Option { + self.inner.next() + } + + fn size_hint(&self) -> (usize, Option) { + self.inner.size_hint() + } +} + +impl ExactSizeIterator for LeadingZerosStripped where I: ExactSizeIterator {} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_leading_zeroes_stripped() { + static TEST_CASES: &[(&[u8], &[u8])] = &[ + (&[], &[]), + (&[0], &[0]), + (&[0, 1], &[1]), + (&[0, 0, 1], &[1]), + (&[0, 0, 0, 1], &[1]), + (&[1, 0], &[1, 0]), + (&[0, 1, 0], &[1, 0]), + ]; + TEST_CASES.iter().copied().for_each(|(input, expected)| { + let stripped = LeadingZerosStripped::new(input.iter().copied()); + super::super::test::assert_iterator(stripped, expected); + }); + } +} diff --git a/http/vendor/ring/src/polyfill/notsend.rs b/http/vendor/ring/src/polyfill/notsend.rs new file mode 100644 index 0000000..9c14006 --- /dev/null +++ b/http/vendor/ring/src/polyfill/notsend.rs @@ -0,0 +1,30 @@ +// Copyright 2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use crate::testutil; +use core::{marker::PhantomData, mem::size_of}; + +/// A ZST that can be added to any type to make the type `!Send`. +#[derive(Clone, Copy)] +pub struct NotSend(PhantomData<*mut ()>); + +impl NotSend { + pub const VALUE: Self = Self(PhantomData); +} + +#[allow(deprecated)] +const _: () = testutil::compile_time_assert_clone::(); +#[allow(deprecated)] +const _: () = testutil::compile_time_assert_copy::(); +const _: () = assert!(size_of::() == 0); diff --git a/http/vendor/ring/src/polyfill/once_cell/LICENSE-APACHE b/http/vendor/ring/src/polyfill/once_cell/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/http/vendor/ring/src/polyfill/once_cell/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/http/vendor/ring/src/polyfill/once_cell/LICENSE-MIT b/http/vendor/ring/src/polyfill/once_cell/LICENSE-MIT new file mode 100644 index 0000000..51feadc --- /dev/null +++ b/http/vendor/ring/src/polyfill/once_cell/LICENSE-MIT @@ -0,0 +1,23 @@ +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHOR OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/http/vendor/ring/src/polyfill/once_cell/race.rs b/http/vendor/ring/src/polyfill/once_cell/race.rs new file mode 100644 index 0000000..6fc4056 --- /dev/null +++ b/http/vendor/ring/src/polyfill/once_cell/race.rs @@ -0,0 +1,77 @@ +//! Thread-safe, non-blocking, "first one wins" flavor of `OnceCell`. +//! +//! If two threads race to initialize a type from the `race` module, they +//! don't block, execute initialization function together, but only one of +//! them stores the result. +//! +//! This module does not require `std` feature. +//! +//! # Atomic orderings +//! +//! All types in this module use `Acquire` and `Release` +//! [atomic orderings](Ordering) for all their operations. While this is not +//! strictly necessary for types other than `OnceBox`, it is useful for users as +//! it allows them to be certain that after `get` or `get_or_init` returns on +//! one thread, any side-effects caused by the setter thread prior to them +//! calling `set` or `get_or_init` will be made visible to that thread; without +//! it, it's possible for it to appear as if they haven't happened yet from the +//! getter thread's perspective. This is an acceptable tradeoff to make since +//! `Acquire` and `Release` have very little performance overhead on most +//! architectures versus `Relaxed`. + +use core::sync::atomic; + +use atomic::{AtomicUsize, Ordering}; +use core::num::NonZeroUsize; + +/// A thread-safe cell which can be written to only once. +pub struct OnceNonZeroUsize { + inner: AtomicUsize, +} + +impl OnceNonZeroUsize { + /// Creates a new empty cell. + #[inline] + pub const fn new() -> OnceNonZeroUsize { + OnceNonZeroUsize { + inner: AtomicUsize::new(0), + } + } + + /// Gets the underlying value. + #[inline] + pub fn get(&self) -> Option { + let val = self.inner.load(Ordering::Acquire); + NonZeroUsize::new(val) + } + + /// Gets the contents of the cell, initializing it with `f` if the cell was + /// empty. + /// + /// If several threads concurrently run `get_or_init`, more than one `f` can + /// be called. However, all threads will return the same value, produced by + /// some `f`. + pub fn get_or_init(&self, f: F) -> NonZeroUsize + where + F: FnOnce() -> NonZeroUsize, + { + let val = self.inner.load(Ordering::Acquire); + match NonZeroUsize::new(val) { + Some(it) => it, + None => self.init(f), + } + } + + #[cold] + #[inline(never)] + fn init(&self, f: impl FnOnce() -> NonZeroUsize) -> NonZeroUsize { + let mut val = f().get(); + let exchange = self + .inner + .compare_exchange(0, val, Ordering::AcqRel, Ordering::Acquire); + if let Err(old) = exchange { + val = old; + } + unsafe { NonZeroUsize::new_unchecked(val) } + } +} diff --git a/http/vendor/ring/src/polyfill/ptr.rs b/http/vendor/ring/src/polyfill/ptr.rs new file mode 100644 index 0000000..58df760 --- /dev/null +++ b/http/vendor/ring/src/polyfill/ptr.rs @@ -0,0 +1,27 @@ +// Copyright 2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +// TODO(MSRV 1.76): Replace with `core::ptr::from_mut`. +#[allow(dead_code)] +#[inline(always)] +pub fn from_mut(r: &mut T) -> *mut T { + r +} + +// TODO(MSRV 1.76): Replace with `core::ptr::from_ref`. +#[allow(dead_code)] +#[inline(always)] +pub const fn from_ref(r: &T) -> *const T { + r +} diff --git a/http/vendor/ring/src/polyfill/slice.rs b/http/vendor/ring/src/polyfill/slice.rs new file mode 100644 index 0000000..8299cc6 --- /dev/null +++ b/http/vendor/ring/src/polyfill/slice.rs @@ -0,0 +1,57 @@ +// Permission is hereby granted, free of charge, to any +// person obtaining a copy of this software and associated +// documentation files (the "Software"), to deal in the +// Software without restriction, including without +// limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of +// the Software, and to permit persons to whom the Software +// is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice +// shall be included in all copies or substantial portions +// of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +// SHALL THE AUTHOR OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +mod as_chunks; +mod as_chunks_mut; + +pub use as_chunks::{as_chunks, AsChunks}; +pub use as_chunks_mut::{as_chunks_mut, AsChunksMut}; + +// TODO(MSRV feature(split_at_checked)): Use `slice::split_at_checked`. +// +// Note that the libcore version is implemented in terms of +// `slice::split_at_unchecked()`, and `slice::split_at()` was changed to be +// implemented in terms of `split_at_checked`. For now, we implement this in +// terms of `split_at` and rely on the optimizer to eliminate the panic. +#[inline(always)] +pub fn split_at_checked(slice: &[T], i: usize) -> Option<(&[T], &[T])> { + if slice.len() >= i { + Some(slice.split_at(i)) + } else { + None + } +} + +// TODO(MSRV-1.77): Use `slice::split_first_chunk_mut`. +#[inline(always)] +pub fn split_first_chunk_mut( + slice: &mut [T], +) -> Option<(&mut [T; N], &mut [T])> { + if slice.len() >= N { + let (head, tail) = slice.split_at_mut(N); + head.try_into().ok().map(|head| (head, tail)) + } else { + None + } +} diff --git a/http/vendor/ring/src/polyfill/slice/as_chunks.rs b/http/vendor/ring/src/polyfill/slice/as_chunks.rs new file mode 100644 index 0000000..bfe5ab5 --- /dev/null +++ b/http/vendor/ring/src/polyfill/slice/as_chunks.rs @@ -0,0 +1,114 @@ +// Copyright 2025 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::AsChunksMut; +use core::ops; + +#[inline(always)] +pub fn as_chunks(slice: &[T]) -> (AsChunks, &[T]) { + assert!(N != 0, "chunk size must be non-zero"); + let len = slice.len() / N; + let (multiple_of_n, remainder) = slice.split_at(len * N); + (AsChunks(multiple_of_n), remainder) +} + +#[derive(Clone, Copy)] +pub struct AsChunks<'a, T, const N: usize>(&'a [T]); + +impl<'a, T, const N: usize> AsChunks<'a, T, N> { + #[inline(always)] + pub fn from_ref(value: &'a [T; N]) -> Self { + Self(value) + } + + #[inline(always)] + pub fn as_flattened(&self) -> &[T] { + self.0 + } + + #[cfg(any(target_arch = "aarch64", target_arch = "arm", target_arch = "x86_64"))] + #[inline(always)] + pub fn as_ptr(&self) -> *const [T; N] { + self.0.as_ptr().cast() + } + + #[inline(always)] + pub fn is_empty(&self) -> bool { + self.0.is_empty() + } + + #[inline(always)] + pub fn len(&self) -> usize { + self.0.len() / N + } +} + +impl ops::Index for AsChunks<'_, T, N> +where + [T]: ops::Index, Output = [T]>, +{ + type Output = [T; N]; + + #[inline(always)] + fn index(&self, index: usize) -> &Self::Output { + let start = N * index; + let slice = &self.0[start..(start + N)]; + slice.try_into().unwrap() + } +} + +impl<'a, T, const N: usize> IntoIterator for AsChunks<'a, T, N> { + type IntoIter = AsChunksIter<'a, T, N>; + type Item = &'a [T; N]; + + #[inline(always)] + fn into_iter(self) -> Self::IntoIter { + AsChunksIter(self.0.chunks_exact(N)) + } +} + +pub struct AsChunksIter<'a, T, const N: usize>(core::slice::ChunksExact<'a, T>); + +impl<'a, T, const N: usize> Iterator for AsChunksIter<'a, T, N> { + type Item = &'a [T; N]; + + #[inline(always)] + fn next(&mut self) -> Option { + self.0.next().map(|x| x.try_into().unwrap()) + } +} + +// `&mut [[T; N]]` is implicitly convertable to `&[[T; N]]` but our types can't +// do that. +impl<'a, T, const N: usize> From<&'a AsChunksMut<'_, T, N>> for AsChunks<'a, T, N> { + #[inline(always)] + fn from(as_mut: &'a AsChunksMut<'_, T, N>) -> Self { + Self(as_mut.as_flattened()) + } +} + +impl<'a, T, const N: usize> From<&'a [T; N]> for AsChunks<'a, T, N> { + #[inline(always)] + fn from(array: &'a [T; N]) -> Self { + Self(array) + } +} + +// TODO: `impl From for AsChunks<'a, T, N>`. +impl<'a, T> From> for AsChunks<'a, T, 4> { + #[inline(always)] + fn from(as_2x: AsChunks<'a, T, 8>) -> Self { + Self(as_2x.0) + } +} diff --git a/http/vendor/ring/src/polyfill/slice/as_chunks_mut.rs b/http/vendor/ring/src/polyfill/slice/as_chunks_mut.rs new file mode 100644 index 0000000..ae32f04 --- /dev/null +++ b/http/vendor/ring/src/polyfill/slice/as_chunks_mut.rs @@ -0,0 +1,88 @@ +// Copyright 2025 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::AsChunks; + +#[inline(always)] +pub fn as_chunks_mut(slice: &mut [T]) -> (AsChunksMut, &mut [T]) { + assert!(N != 0, "chunk size must be non-zero"); + let len = slice.len() / N; + let (multiple_of_n, remainder) = slice.split_at_mut(len * N); + (AsChunksMut(multiple_of_n), remainder) +} + +pub struct AsChunksMut<'a, T, const N: usize>(&'a mut [T]); + +impl AsChunksMut<'_, T, N> { + #[inline(always)] + pub fn as_flattened(&self) -> &[T] { + self.0 + } + + #[inline(always)] + pub fn as_flattened_mut(&mut self) -> &mut [T] { + self.0 + } + + #[cfg(target_arch = "aarch64")] + pub fn as_ptr(&self) -> *const [T; N] { + self.0.as_ptr().cast() + } + + #[cfg(target_arch = "x86_64")] + pub fn as_ptr(&self) -> *const [T; N] { + self.0.as_ptr().cast() + } + + #[cfg(target_arch = "aarch64")] + pub fn as_mut_ptr(&mut self) -> *mut [T; N] { + self.0.as_mut_ptr().cast() + } + + #[cfg(target_arch = "x86_64")] + #[inline(always)] + pub fn as_mut(&mut self) -> AsChunksMut { + AsChunksMut(self.0) + } + + #[inline(always)] + pub fn as_ref(&self) -> AsChunks { + AsChunks::::from(self) + } + + // Argument moved from runtime argument to `const` argument so that + // `CHUNK_LEN * N` is checked at compile time for overflow. + #[inline(always)] + pub fn chunks_mut(&mut self) -> AsChunksMutChunksMutIter { + AsChunksMutChunksMutIter(self.0.chunks_mut(CHUNK_LEN * N)) + } + + #[cfg(target_arch = "x86_64")] + #[inline(always)] + pub fn split_at_mut(&mut self, mid: usize) -> (AsChunksMut, AsChunksMut) { + let (before, after) = self.0.split_at_mut(mid * N); + (AsChunksMut(before), AsChunksMut(after)) + } +} + +pub struct AsChunksMutChunksMutIter<'a, T, const N: usize>(core::slice::ChunksMut<'a, T>); + +impl<'a, T, const N: usize> Iterator for AsChunksMutChunksMutIter<'a, T, N> { + type Item = AsChunksMut<'a, T, N>; + + #[inline(always)] + fn next(&mut self) -> Option { + self.0.next().map(AsChunksMut) + } +} diff --git a/http/vendor/ring/src/polyfill/sliceutil.rs b/http/vendor/ring/src/polyfill/sliceutil.rs new file mode 100644 index 0000000..a6765f1 --- /dev/null +++ b/http/vendor/ring/src/polyfill/sliceutil.rs @@ -0,0 +1,23 @@ +// Copyright 2024 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! Utilities to make dealing with slices less tediuous. + +/// Replaces the first N elements of `a` with the first N elements of `b`, where +/// N is `core::cmp::min(a.len(), b.len())`, leaving the rest unchanged. +pub fn overwrite_at_start(a: &mut [T], b: &[T]) { + a.iter_mut().zip(b).for_each(|(a, b)| { + *a = *b; + }); +} diff --git a/http/vendor/ring/src/polyfill/test.rs b/http/vendor/ring/src/polyfill/test.rs new file mode 100644 index 0000000..ea90a24 --- /dev/null +++ b/http/vendor/ring/src/polyfill/test.rs @@ -0,0 +1,29 @@ +pub fn assert_iterator(it: impl ExactSizeIterator + Clone, expected: &[T]) +where + T: Copy + core::fmt::Debug + PartialEq, +{ + // Assert that the cloned iterator is correct. + assert_exact_size_iterator(it.clone(), expected); + // Assert that the original iterator is correct. + assert_exact_size_iterator(it, expected); +} + +/// Asserts that `it` adheres to the `ExactSizeIterator` contract. +fn assert_exact_size_iterator(mut it: impl ExactSizeIterator, expected: &[T]) +where + T: Copy + core::fmt::Debug + PartialEq, +{ + assert_eq!(it.len(), expected.len()); + assert_eq!(it.size_hint(), expected.iter().size_hint()); + + for i in 0..expected.len() { + let len = it.len(); + assert_eq!(len, expected.len() - i); + assert_eq!(it.size_hint(), (len, Some(len))); + assert_eq!(it.next(), Some(expected[i])); + } + + assert_eq!(it.len(), 0); + assert_eq!(it.size_hint(), (0, Some(0))); + assert_eq!(it.next(), None); +} diff --git a/http/vendor/ring/src/polyfill/unwrap_const.rs b/http/vendor/ring/src/polyfill/unwrap_const.rs new file mode 100644 index 0000000..a1c982f --- /dev/null +++ b/http/vendor/ring/src/polyfill/unwrap_const.rs @@ -0,0 +1,29 @@ +// Copyright 2022 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +/// Polyfill for `Option::unwrap()` as a const fn; feature `const_option`. +/// https://github.com/rust-lang/rust/issues/67441. +/// TODO(MSRV): Replace this with `x.unwrap()`. +/// +/// `T: Copy` avoids "constant functions cannot evaluate destructors." +pub const fn unwrap_const(x: Option) -> T +where + T: Copy, +{ + if let Some(x) = x { + x + } else { + panic!("unwrap_const on `None`"); + } +} diff --git a/http/vendor/ring/src/prefixed.rs b/http/vendor/ring/src/prefixed.rs new file mode 100644 index 0000000..39f3f9f --- /dev/null +++ b/http/vendor/ring/src/prefixed.rs @@ -0,0 +1,118 @@ +// Keep in sync with `core_name_and_version` in build.rs. +macro_rules! core_name_and_version { + () => { + concat!( + env!("CARGO_PKG_NAME"), + "_core_", + env!("CARGO_PKG_VERSION_MAJOR"), + "_", + env!("CARGO_PKG_VERSION_MINOR"), + "_", + env!("CARGO_PKG_VERSION_PATCH"), + "_", + env!("CARGO_PKG_VERSION_PRE"), // Often empty + ) + }; +} + +// Keep in sync with `prefix` in build.rs. +macro_rules! prefix { + ( ) => { + concat!(core_name_and_version!(), "_") + }; +} + +macro_rules! prefixed_extern { + // Functions. + { + $( + $( #[$meta:meta] )* + $vis:vis fn $name:ident ( $( $arg_pat:ident : $arg_ty:ty ),* $(,)? ) + $( -> $ret_ty:ty )?; + )+ + } => { + extern "C" { + $( + prefixed_item! { + link_name + $name + { + $( #[$meta] )* + $vis fn $name ( $( $arg_pat : $arg_ty ),* ) $( -> $ret_ty )?; + } + + } + )+ + } + }; + + // A `static` global variable. + { + $( #[$meta:meta] )* + $vis:vis static $name:ident: $typ:ty; + } => { + extern "C" { + prefixed_item! { + link_name + $name + { + $( #[$meta] )* + $vis static $name: $typ; + } + } + } + }; + + // A `static mut` global variable. + { + $( #[$meta:meta] )* + $vis:vis static mut $name:ident: $typ:ty; + } => { + extern "C" { + prefixed_item! { + link_name + $name + { + $( #[$meta] )* + $vis static mut $name: $typ; + } + } + } + }; +} + +#[deprecated = "`#[export_name]` creates problems and we will stop doing it."] +#[cfg(not(any( + all(target_arch = "aarch64", target_endian = "little"), + all(target_arch = "arm", target_endian = "little"), + target_arch = "x86", + target_arch = "x86_64" +)))] +macro_rules! prefixed_export { + // A function. + { + $( #[$meta:meta] )* + $vis:vis unsafe extern "C" + fn $name:ident ( $( $arg_pat:ident : $arg_ty:ty ),* $(,)? ) $body:block + } => { + prefixed_item! { + export_name + $name + { + $( #[$meta] )* + $vis unsafe extern "C" fn $name ( $( $arg_pat : $arg_ty ),* ) $body + } + } + }; +} + +macro_rules! prefixed_item { + { + $attr:ident + $name:ident + { $item:item } + } => { + #[$attr = concat!(prefix!(), stringify!($name))] + $item + }; +} diff --git a/http/vendor/ring/src/rand.rs b/http/vendor/ring/src/rand.rs new file mode 100644 index 0000000..a451c8f --- /dev/null +++ b/http/vendor/ring/src/rand.rs @@ -0,0 +1,167 @@ +// Copyright 2015-2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +//! Cryptographic pseudo-random number generation. +//! +//! *ring* functions that generate random bytes take a `&dyn SecureRandom` +//! parameter to make it clear which functions are non-deterministic. + +use crate::error; + +/// A secure random number generator. +pub trait SecureRandom: sealed::SecureRandom { + /// Fills `dest` with random bytes. + fn fill(&self, dest: &mut [u8]) -> Result<(), error::Unspecified>; +} + +impl SecureRandom for T +where + T: sealed::SecureRandom, +{ + #[inline(always)] + fn fill(&self, dest: &mut [u8]) -> Result<(), error::Unspecified> { + self.fill_impl(dest) + } +} + +/// A random value constructed from a `SecureRandom` that hasn't been exposed +/// through any safe Rust interface. +/// +/// Intentionally does not implement any traits other than `Sized`. +pub struct Random(T); + +impl Random { + /// Expose the random value. + #[inline] + pub fn expose(self) -> T { + self.0 + } +} + +/// Generate the new random value using `rng`. +#[inline] +pub fn generate( + rng: &dyn SecureRandom, +) -> Result, error::Unspecified> { + let mut r = T::zero(); + rng.fill(r.as_mut_bytes())?; + Ok(Random(r)) +} + +pub(crate) mod sealed { + use crate::error; + + pub trait SecureRandom: core::fmt::Debug { + /// Fills `dest` with random bytes. + fn fill_impl(&self, dest: &mut [u8]) -> Result<(), error::Unspecified>; + } + + pub trait RandomlyConstructable: Sized { + fn zero() -> Self; // `Default::default()` + fn as_mut_bytes(&mut self) -> &mut [u8]; // `AsMut<[u8]>::as_mut` + } + + impl RandomlyConstructable for [u8; N] { + #[inline] + fn zero() -> Self { + [0; N] + } + + #[inline] + fn as_mut_bytes(&mut self) -> &mut [u8] { + &mut self[..] + } + } +} + +/// A type that can be returned by `ring::rand::generate()`. +pub trait RandomlyConstructable: sealed::RandomlyConstructable {} +impl RandomlyConstructable for T where T: sealed::RandomlyConstructable {} + +/// A secure random number generator where the random values come directly +/// from the operating system. +/// +/// "Directly from the operating system" here presently means "whatever the +/// `getrandom` crate does" but that may change in the future. That roughly +/// means calling libc's `getrandom` function or whatever is analogous to that; +/// see the `getrandom` crate's documentation for more info. +/// +/// A single `SystemRandom` may be shared across multiple threads safely. +/// +/// `new()` is guaranteed to always succeed and to have low latency; it won't +/// try to open or read from a file or do similar things. The first call to +/// `fill()` may block a substantial amount of time since any and all +/// initialization is deferred to it. Therefore, it may be a good idea to call +/// `fill()` once at a non-latency-sensitive time to minimize latency for +/// future calls. +#[derive(Clone, Debug)] +pub struct SystemRandom(()); + +impl SystemRandom { + /// Constructs a new `SystemRandom`. + #[inline(always)] + pub fn new() -> Self { + Self(()) + } +} + +impl crate::sealed::Sealed for SystemRandom {} + +// Use the `getrandom` crate whenever it is using the environment's (operating +// system's) CSPRNG. Avoid using it on targets where it uses the `rdrand` +// implementation. +#[cfg(any( + all(feature = "less-safe-getrandom-custom-or-rdrand", target_os = "none"), + all(feature = "less-safe-getrandom-espidf", target_os = "espidf"), + target_os = "aix", + target_os = "android", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "fuchsia", + target_os = "haiku", + target_os = "hermit", + target_os = "hurd", + target_os = "horizon", + target_os = "illumos", + target_os = "linux", + target_os = "netbsd", + target_os = "openbsd", + target_os = "redox", + target_os = "solaris", + target_os = "vita", + target_os = "windows", + all( + target_vendor = "apple", + any( + target_os = "ios", + target_os = "macos", + target_os = "tvos", + target_os = "visionos", + target_os = "watchos", + ) + ), + all( + target_arch = "wasm32", + any( + target_os = "wasi", + all(target_os = "unknown", feature = "wasm32_unknown_unknown_js") + ) + ), +))] +impl sealed::SecureRandom for SystemRandom { + #[inline(always)] + fn fill_impl(&self, dest: &mut [u8]) -> Result<(), error::Unspecified> { + getrandom::getrandom(dest).map_err(|_| error::Unspecified) + } +} diff --git a/http/vendor/ring/src/rsa.rs b/http/vendor/ring/src/rsa.rs new file mode 100644 index 0000000..e1fb2e7 --- /dev/null +++ b/http/vendor/ring/src/rsa.rs @@ -0,0 +1,76 @@ +// Copyright 2015-2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +// *R* and *r* in Montgomery math refer to different things, so we always use +// `R` to refer to *R* to avoid confusion, even when that's against the normal +// naming conventions. Also the standard camelCase names are used for `KeyPair` +// components. + +//! RSA. + +use crate::{ + arithmetic::bigint, + bits, error, + io::{self, der}, +}; + +pub(crate) mod padding; + +// Maximum RSA modulus size supported for signature verification (in bytes). +const PUBLIC_KEY_PUBLIC_MODULUS_MAX_LEN: usize = + bits::BitLength::from_bits(8192).as_usize_bytes_rounded_up(); + +// Keep in sync with the documentation comment for `KeyPair`. +const PRIVATE_KEY_PUBLIC_MODULUS_MAX_BITS: bits::BitLength = bits::BitLength::from_bits(4096); + +/// Parameters for RSA verification. +#[derive(Debug)] +pub struct RsaParameters { + padding_alg: &'static dyn padding::Verification, + min_bits: bits::BitLength, +} + +fn parse_public_key( + input: untrusted::Input, +) -> Result<(io::Positive, io::Positive), error::Unspecified> { + input.read_all(error::Unspecified, |input| { + der::nested(input, der::Tag::Sequence, error::Unspecified, |input| { + let n = der::positive_integer(input)?; + let e = der::positive_integer(input)?; + Ok((n, e)) + }) + }) +} + +// Type-level representation of an RSA public modulus *n*. See +// `super::bigint`'s modulue-level documentation. +enum N {} + +impl bigint::PublicModulus for N {} + +mod keypair; +mod keypair_components; +mod public_exponent; +mod public_key; +mod public_key_components; +mod public_modulus; + +pub(crate) mod verification; + +use self::{public_exponent::PublicExponent, public_modulus::PublicModulus}; + +pub use self::{ + keypair::KeyPair, keypair_components::KeyPairComponents, public_key::PublicKey, + public_key_components::PublicKeyComponents, +}; diff --git a/http/vendor/ring/src/rsa/keypair.rs b/http/vendor/ring/src/rsa/keypair.rs new file mode 100644 index 0000000..5994e55 --- /dev/null +++ b/http/vendor/ring/src/rsa/keypair.rs @@ -0,0 +1,685 @@ +// Copyright 2015-2016 Brian Smith. +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION +// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN +// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +use super::{ + padding::{self, RsaEncoding}, + KeyPairComponents, PublicExponent, PublicKey, PublicKeyComponents, N, +}; + +/// RSA PKCS#1 1.5 signatures. +use crate::{ + arithmetic::{ + bigint, + montgomery::{R, RR, RRR}, + LimbSliceError, + }, + bits::BitLength, + cpu, digest, + error::{self, KeyRejected}, + io::der, + pkcs8, rand, signature, +}; + +/// An RSA key pair, used for signing. +pub struct KeyPair { + p: PrivateCrtPrime